Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions include/gen/classes.h
Original file line number Diff line number Diff line change
Expand Up @@ -239,11 +239,11 @@ typedef struct {
intptr_t on_click, draw_sprite;
MemBlock arena;
void *radios;
void *checks;
void *edit_boxes;
void *buttons;
SCheckBox *checks;
SEditBox *edit_boxes;
SButton *buttons;
void *listbox;
void *regions;
SRegion *regions;
char *extra_labels[3];
ButtonSlot btn[6];
} Popup;
Expand Down
1 change: 1 addition & 0 deletions include/gen/colonization.h
Original file line number Diff line number Diff line change
Expand Up @@ -5482,6 +5482,7 @@ extern void port_scroll_left(MagicWin *s, int step, RECT *r);
extern void port_scroll_right(MagicWin *s, int step, RECT *r);
extern void port_scroll_up(MagicWin *s, int step, RECT *r);
extern void port_set_capture(Screen *w);
extern void port_slide_step(void);
extern int port_stride(GRPort *port);
extern int port_stride_1068_986d(GRPort *p);
extern void *port_surface_1068_989f(GRPort *port);
Expand Down
8 changes: 4 additions & 4 deletions include/port/corpus_classes.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,11 @@ typedef struct {
long on_click, draw_sprite;
MemBlock arena;
void *radios;
void *checks;
void *edit_boxes;
void *buttons;
SCheckBox *checks;
SEditBox *edit_boxes;
SButton *buttons;
void *listbox;
void *regions;
SRegion *regions;
char *extra_labels[3];
ButtonSlot btn[6];
} Popup;
Expand Down
1 change: 1 addition & 0 deletions src/game/MapWin_SlideIcon.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ void MapWin_SlideIcon(MapWin *w, int u, int flags, int other, register int x1,
GRPort_CopyToPort(&port, w, &r1, &r2);
PieceDraw_noport(u, flags, ux + half, uy, g_tile_w, g_icon_h);
copy_rect_to_screen_1038_e38f(w, &r2);
port_slide_step(); /* PORT: pace each step; the 1995 loop ran at the machine's speed, instant today (src/host/slide_delay.c, issue #6) */
ux += dxs;
uy += dys;
}
Expand Down
5 changes: 3 additions & 2 deletions src/game/Popup_exec.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* PORT: a window's DialogWin base is PORT_DIALOG_BASE (sizeof(GRPort)), not the game's 0x26: 12 bytes further on 64-bit (W9). */
/* PORT: this file's own declarations of DrawKingo, MSHideWindow_of_1050_8cd8, Popup_draw, ctl_get_text, ctl_sel_text, get_checked_1050_8d83, get_w_77a, listbox_get_text_1050_8d5d, win_disable_1050_8c93, win_enable_1050_82e1 removed: the header declares them from the definition (W1 step 3). */
/* PORT: explicit DlgControl * casts for ctl_get_text: the C view of Popup now types its control arrays (include/port/corpus_classes.h), where void * converted implicitly. */
/* Popup_exec: candidate for 1050:50c4 (901 bytes). Verdict: RELOCATABLE.
* size-source: 901, not the census 892. The trailing 9 bytes are the dead second epilogue.
* name-source: sibling-build
Expand Down Expand Up @@ -92,10 +93,10 @@ int Popup_exec(Popup *popup, char *text)
while ((popup->flags & 0x400) == 0)
MSDoTask_1050_8d23();
if (text != 0 && popup->edit_boxes != 0)
ctl_get_text(popup->edit_boxes, text);
ctl_get_text((DlgControl *)popup->edit_boxes, text);
if (popup->n_edits > 1) {
for (i = 0; popup->n_edits > i; i++)
ctl_get_text(&popup->edit_boxes[i], g_name_slots[i]);
ctl_get_text((DlgControl *)&popup->edit_boxes[i], g_name_slots[i]);
}
if (popup->flags & 0x1000) {
if (popup->result == 0) {
Expand Down
3 changes: 2 additions & 1 deletion src/game/popup_get_edit_text.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* PORT: this file's own declarations of ctl_get_text removed: the header declares it from the definition (W1 step 3). */
/* PORT: explicit DlgControl * casts for ctl_get_text: the C view of Popup now types its control arrays (include/port/corpus_classes.h), where void * converted implicitly. */
/* popup_get_edit_text: candidate for 1050:0fd8 (49 bytes, 1 caller). Verdict: RELOCATABLE.
*
* Reads the text of edit box i of the popup's 40-byte edit-box array (pointer at +0x3a8) into the buffer p, through ctl_get_text.
Expand All @@ -14,5 +15,5 @@
/* same object: 4-byte `push cs; call ` (rule 47) */
void popup_get_edit_text(Popup *control, int i, void *p)
{
ctl_get_text(&control->edit_boxes[i], p);
ctl_get_text((DlgControl *)&control->edit_boxes[i], p);
}
43 changes: 43 additions & 0 deletions src/host/slide_delay.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/* slide_delay.c -- paces MapWin_SlideIcon's steps (issue #6).
*
* The 1995 slide has no timer: each step is drawn as fast as the machine can, which on a 1995 PC
* was slow enough to watch and on a modern one is instant, with or without Fast Piece Slide. Each
* step now waits until PORT_SLIDE_MS (default 12) after the previous one; Fast Piece Slide takes
* half as many steps of twice the size, so it stays twice as fast. PORT_SLIDE_MS=0 restores the
* unpaced slide.
*/
#include <windows.h>
#include <stdlib.h>

static int slide_ms = -1;
static LARGE_INTEGER freq;
static LARGE_INTEGER last;

#ifdef __cplusplus
extern "C"
#endif
void port_slide_step(void)
{
LARGE_INTEGER now;
LONGLONG due;

if (slide_ms < 0) {
const char *env = getenv("PORT_SLIDE_MS");
slide_ms = env != NULL ? atoi(env) : 12;
if (slide_ms < 0)
slide_ms = 0;
QueryPerformanceFrequency(&freq);
}
if (slide_ms == 0)
return;
QueryPerformanceCounter(&now);
due = last.QuadPart + freq.QuadPart * slide_ms / 1000;
/* a slide's first step, or one after a long gap, starts the clock instead of waiting */
if (now.QuadPart < due && due - now.QuadPart <= freq.QuadPart * slide_ms / 1000) {
while (now.QuadPart < due) {
Sleep(1);
QueryPerformanceCounter(&now);
}
}
last = now;
}
Loading