diff --git a/include/gen/classes.h b/include/gen/classes.h index e89d335e..17f0d435 100644 --- a/include/gen/classes.h +++ b/include/gen/classes.h @@ -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; diff --git a/include/gen/colonization.h b/include/gen/colonization.h index 97eb10cd..de730d6c 100644 --- a/include/gen/colonization.h +++ b/include/gen/colonization.h @@ -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); diff --git a/include/port/corpus_classes.h b/include/port/corpus_classes.h index 458c8a13..93d72462 100644 --- a/include/port/corpus_classes.h +++ b/include/port/corpus_classes.h @@ -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; diff --git a/src/game/MapWin_SlideIcon.c b/src/game/MapWin_SlideIcon.c index 4751adc9..f842b19e 100644 --- a/src/game/MapWin_SlideIcon.c +++ b/src/game/MapWin_SlideIcon.c @@ -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; } diff --git a/src/game/Popup_exec.c b/src/game/Popup_exec.c index ed89feb9..60d9905a 100644 --- a/src/game/Popup_exec.c +++ b/src/game/Popup_exec.c @@ -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 @@ -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) { diff --git a/src/game/popup_get_edit_text.c b/src/game/popup_get_edit_text.c index 5d26ac0e..c9cfb2d0 100644 --- a/src/game/popup_get_edit_text.c +++ b/src/game/popup_get_edit_text.c @@ -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. @@ -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); } diff --git a/src/host/slide_delay.c b/src/host/slide_delay.c new file mode 100644 index 00000000..754ca028 --- /dev/null +++ b/src/host/slide_delay.c @@ -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 +#include + +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; +}