unsigned int initial_anim_sync_frame;
unsigned int anim_random_frame;
- unsigned int step_delay, step_delay_value;
+
+ DelayCounter step_delay;
int init_delay_counter;
int anim_delay_counter;
part->initial_anim_sync_frame = 0;
part->anim_random_frame = -1;
- part->step_delay = 0;
- part->step_delay_value = graphic_info[control].step_delay;
+ part->step_delay.count = 0;
+ part->step_delay.value = graphic_info[control].step_delay;
part->state = ANIM_STATE_INACTIVE;
part->last_anim_status = -1;
part->initial_anim_sync_frame = 0;
part->anim_random_frame = -1;
- part->step_delay = 0;
- part->step_delay_value = graphic_info[control].step_delay;
+ part->step_delay.count = 0;
+ part->step_delay.value = graphic_info[control].step_delay;
part->state = ANIM_STATE_INACTIVE;
part->last_anim_status = -1;
// special case to prevent expiring loop sounds when playing
PlayGlobalAnimSoundIfLoop(part);
- if (!DelayReachedExt(&part->step_delay, part->step_delay_value,
- anim_sync_frame))
+ if (!DelayReachedExt(&part->step_delay, anim_sync_frame))
return ANIM_STATE_RUNNING;
#if 0
int element_border = graphic_info[IMG_EDITOR_ELEMENT_BORDER].border_size;
int x = editor.settings.element_graphic.x + element_border;
int y = editor.settings.element_graphic.y + element_border;
- static unsigned int action_delay = 0;
- unsigned int action_delay_value = GameFrameDelay;
+ static DelayCounter action_delay = { 0 };
int i;
- if (!DelayReached(&action_delay, action_delay_value))
+ action_delay.value = GameFrameDelay;
+
+ if (!DelayReached(&action_delay))
return;
for (i = 0; i < ED_NUM_SELECTBOX; i++)
static boolean cursor_inside_playfield = FALSE;
static int cursor_mode_last = CURSOR_DEFAULT;
-static unsigned int special_cursor_delay = 0;
-static unsigned int special_cursor_delay_value = 1000;
+static DelayCounter special_cursor_delay = { 1000 };
static boolean special_cursor_enabled = FALSE;
static boolean stop_processing_events = FALSE;
static void HandleEvents(void)
{
Event event;
- unsigned int event_frame_delay = 0;
- unsigned int event_frame_delay_value = GAME_FRAME_DELAY;
+ DelayCounter event_frame_delay = { GAME_FRAME_DELAY };
ResetDelayCounter(&event_frame_delay);
ResetDelayCounter(&event_frame_delay);
// do not handle events for longer than standard frame delay period
- if (DelayReached(&event_frame_delay, event_frame_delay_value))
+ if (DelayReached(&event_frame_delay))
break;
// do not handle any further events if triggered by a special flag
// when showing title screens, hide mouse pointer (if not moved)
if (gfx.cursor_mode != CURSOR_NONE &&
- DelayReached(&special_cursor_delay, special_cursor_delay_value))
+ DelayReached(&special_cursor_delay))
{
SetMouseCursor(CURSOR_NONE);
}
if (gfx.cursor_mode != CURSOR_PLAYFIELD &&
cursor_inside_playfield &&
special_cursor_enabled &&
- DelayReached(&special_cursor_delay, special_cursor_delay_value))
+ DelayReached(&special_cursor_delay))
{
SetMouseCursor(CURSOR_PLAYFIELD);
}
void HandleJoystick(void)
{
- static unsigned int joytest_delay = 0;
- static unsigned int joytest_delay_value = GADGET_FRAME_DELAY;
+ static DelayCounter joytest_delay = { GADGET_FRAME_DELAY };
static int joytest_last = 0;
int delay_value_first = GADGET_FRAME_DELAY_FIRST;
int delay_value = GADGET_FRAME_DELAY;
if (dx || dy || button)
SetPlayfieldMouseCursorEnabled(TRUE);
- if (joytest && !button && !DelayReached(&joytest_delay, joytest_delay_value))
+ if (joytest && !button && !DelayReached(&joytest_delay))
{
// delay joystick/keyboard actions if axes/keys continually pressed
newbutton = dx = dy = 0;
else
{
// first start with longer delay, then continue with shorter delay
- joytest_delay_value =
+ joytest_delay.value =
(use_delay_value_first ? delay_value_first : delay_value);
}
player->can_fall_into_acid = CAN_MOVE_INTO_ACID(player->element_nr);
- player->actual_frame_counter = 0;
+ player->actual_frame_counter.count = 0;
+ player->actual_frame_counter.value = 1;
player->step_counter = 0;
static void AmoebaGrowing(int x, int y)
{
- static unsigned int sound_delay = 0;
- static unsigned int sound_delay_value = 0;
+ static DelayCounter sound_delay = { 0 };
if (!MovDelay[x][y]) // start new growing cycle
{
MovDelay[x][y] = 7;
- if (DelayReached(&sound_delay, sound_delay_value))
+ if (DelayReached(&sound_delay))
{
PlayLevelSoundElementAction(x, y, Store[x][y], ACTION_GROWING);
- sound_delay_value = 30;
+ sound_delay.value = 30;
}
}
static void AmoebaShrinking(int x, int y)
{
- static unsigned int sound_delay = 0;
- static unsigned int sound_delay_value = 0;
+ static DelayCounter sound_delay = { 0 };
if (!MovDelay[x][y]) // start new shrinking cycle
{
MovDelay[x][y] = 7;
- if (DelayReached(&sound_delay, sound_delay_value))
- sound_delay_value = 30;
+ if (DelayReached(&sound_delay))
+ sound_delay.value = 30;
}
if (MovDelay[x][y]) // wait some time before shrinking
if (mode == SCROLL_INIT)
{
- player->actual_frame_counter = FrameCounter;
+ player->actual_frame_counter.count = FrameCounter;
player->GfxPos = move_stepsize * (player->MovPos / move_stepsize);
if ((player->block_last_field || player->block_delay_adjustment > 0) &&
if (player->MovPos != 0) // player has not yet reached destination
return;
}
- else if (!FrameReached(&player->actual_frame_counter, 1))
+ else if (!FrameReached(&player->actual_frame_counter))
return;
if (player->MovPos != 0)
void ScrollScreen(struct PlayerInfo *player, int mode)
{
- static unsigned int screen_frame_counter = 0;
+ static DelayCounter screen_frame_counter = { 0 };
if (mode == SCROLL_INIT)
{
// set scrolling step size according to actual player's moving speed
ScrollStepSize = TILEX / player->move_delay_value;
- screen_frame_counter = FrameCounter;
+ screen_frame_counter.count = FrameCounter;
+ screen_frame_counter.value = 1;
+
ScreenMovDir = player->MovDir;
ScreenMovPos = player->MovPos;
ScreenGfxPos = ScrollStepSize * (ScreenMovPos / ScrollStepSize);
return;
}
- else if (!FrameReached(&screen_frame_counter, 1))
+ else if (!FrameReached(&screen_frame_counter))
return;
if (ScreenMovPos)
int push_delay;
int push_delay_value;
- unsigned int actual_frame_counter;
+ DelayCounter actual_frame_counter;
int drop_delay;
int drop_pressed_delay;
int hold_x, hold_y;
int pacman_nr;
- unsigned int rotate_delay;
- unsigned int pacman_delay;
- unsigned int energy_delay;
- unsigned int overload_delay;
+ DelayCounter rotate_delay;
+ DelayCounter pacman_delay;
+ DelayCounter energy_delay;
+ DelayCounter overload_delay;
};
static int pacman_nr = -1;
// various game engine delay counters
-static unsigned int rotate_delay = 0;
-static unsigned int pacman_delay = 0;
-static unsigned int energy_delay = 0;
-static unsigned int overload_delay = 0;
+static DelayCounter rotate_delay = { AUTO_ROTATE_DELAY };
+static DelayCounter pacman_delay = { PACMAN_MOVE_DELAY };
+static DelayCounter energy_delay = { ENERGY_DELAY };
+static DelayCounter overload_delay = { 0 };
// element masks for scanning pixels of MM elements
static const char mm_masks[10][16][16 + 1] =
CT = Ct = 0;
- rotate_delay = 0;
- pacman_delay = 0;
- energy_delay = 0;
- overload_delay = 0;
+ rotate_delay.count = 0;
+ pacman_delay.count = 0;
+ energy_delay.count = 0;
+ overload_delay.count = 0;
ClickElement(-1, -1, -1);
boolean ClickElement(int x, int y, int button)
{
- static unsigned int click_delay = 0;
- static int click_delay_value = CLICK_DELAY;
+ static DelayCounter click_delay = { CLICK_DELAY };
static boolean new_button = TRUE;
boolean element_clicked = FALSE;
int element;
if (button == -1)
{
// initialize static variables
- click_delay = 0;
- click_delay_value = CLICK_DELAY;
+ click_delay.count = 0;
+ click_delay.value = CLICK_DELAY;
new_button = TRUE;
return FALSE;
if (button == MB_RELEASED)
{
new_button = TRUE;
- click_delay_value = CLICK_DELAY;
+ click_delay.value = CLICK_DELAY;
// release eventually hold auto-rotating mirror
RotateMirror(x, y, MB_RELEASED);
return FALSE;
}
- if (!FrameReached(&click_delay, click_delay_value) && !new_button)
+ if (!FrameReached(&click_delay) && !new_button)
return FALSE;
if (button == MB_MIDDLEBUTTON) // middle button has no function
element_clicked = TRUE;
}
- click_delay_value = (new_button ? CLICK_DELAY_FIRST : CLICK_DELAY);
+ click_delay.value = (new_button ? CLICK_DELAY_FIRST : CLICK_DELAY);
new_button = FALSE;
return element_clicked;
{
int x, y;
- if (!FrameReached(&rotate_delay, AUTO_ROTATE_DELAY))
+ if (!FrameReached(&rotate_delay))
return;
for (x = 0; x < lev_fieldx; x++)
CT = FrameCounter;
- if (game_mm.num_pacman && FrameReached(&pacman_delay, PACMAN_MOVE_DELAY))
+ if (game_mm.num_pacman && FrameReached(&pacman_delay))
{
MovePacMen();
}
}
- if (FrameReached(&energy_delay, ENERGY_DELAY))
+ if (FrameReached(&energy_delay))
{
if (game_mm.energy_left > 0)
{
!IS_WALL_AMOEBA(element))
return;
+ overload_delay.value = HEALTH_DELAY(laser.overloaded);
+
if (((laser.overloaded && laser.overload_value < MAX_LASER_OVERLOAD) ||
(!laser.overloaded && laser.overload_value > 0)) &&
- FrameReached(&overload_delay, HEALTH_DELAY(laser.overloaded)))
+ FrameReached(&overload_delay))
{
if (laser.overloaded)
laser.overload_value++;
static boolean started = FALSE;
static boolean active = FALSE;
static boolean debug = FALSE;
- static unsigned int check_delay = 0;
- static unsigned int start_delay = 0;
- static unsigned int growth_delay = 0;
- static unsigned int update_delay = 0;
- static unsigned int change_delay = 0;
- static unsigned int check_delay_value = XSN_CHECK_DELAY * 1000;
- static unsigned int start_delay_value = 0;
- static unsigned int growth_delay_value = 0;
- static unsigned int update_delay_value = 0;
- static unsigned int change_delay_value = 0;
+ static DelayCounter check_delay = { XSN_CHECK_DELAY * 1000 };
+ static DelayCounter start_delay = { 0 };
+ static DelayCounter growth_delay = { 0 };
+ static DelayCounter update_delay = { 0 };
+ static DelayCounter change_delay = { 0 };
static int percent = 0;
static int debug_value = 0;
boolean reinitialize = FALSE;
if (draw_target != DRAW_TO_SCREEN)
return;
- if (DelayReached(&check_delay, check_delay_value))
+ if (DelayReached(&check_delay))
{
percent = (debug ? debug_value * 100 / XSN_DEBUG_STEPS : xsn_percent());
if (!active_last)
{
- start_delay_value = (debug || setup.debug.xsn_mode == TRUE ? 0 :
+ start_delay.value = (debug || setup.debug.xsn_mode == TRUE ? 0 :
(XSN_START_DELAY + XSN_RND(XSN_START_DELAY)) * 1000);
started = FALSE;
if (!started)
{
- if (!DelayReached(&start_delay, start_delay_value))
+ if (!DelayReached(&start_delay))
return;
- update_delay_value = XSN_UPDATE_DELAY;
- growth_delay_value = XSN_GROWTH_DELAY * 1000;
- change_delay_value = XSN_CHANGE_DELAY * 1000;
+ update_delay.value = XSN_UPDATE_DELAY;
+ growth_delay.value = XSN_GROWTH_DELAY * 1000;
+ change_delay.value = XSN_CHANGE_DELAY * 1000;
ResetDelayCounter(&growth_delay);
ResetDelayCounter(&update_delay);
if (xsn.num_items < xsn.max_items)
{
- if (DelayReached(&growth_delay, growth_delay_value))
+ if (DelayReached(&growth_delay))
{
xsn.num_items += XSN_RND(XSN_GROWTH_RATE * 2);
xsn.num_items = MIN(xsn.num_items, xsn.max_items);
}
}
- if (DelayReached(&update_delay, update_delay_value))
+ if (DelayReached(&update_delay))
{
for (i = 0; i < xsn.num_items; i++)
xsn_update_item(i);
}
- if (DelayReached(&change_delay, change_delay_value))
+ if (DelayReached(&change_delay))
{
xsn_update_change();
- change_delay_value = xsn.change_delay * 1000;
+ change_delay.value = xsn.change_delay * 1000;
}
int xsn_alpha_dx = (gfx.mouse_y > xsn.area_ysize - xsn.max_height ?
game_status == GAME_MODE_LOADING ?
&init_last.busy :
&init_last.busy_playfield);
- static unsigned int action_delay = 0;
- unsigned int action_delay_value = GameFrameDelay;
+ static DelayCounter action_delay = { 0 };
int sync_frame = FrameCounter;
int x, y;
+ action_delay.value = GameFrameDelay;
+
// prevent OS (Windows) from complaining about program not responding
CheckQuitEvent();
if (image_initial[graphic].bitmap == NULL || window == NULL)
return;
- if (!DelayReached(&action_delay, action_delay_value))
+ if (!DelayReached(&action_delay))
return;
if (busy->x == -1)
static boolean WaitForApiThreads(void)
{
- unsigned int thread_delay = 0;
- unsigned int thread_delay_value = 10000;
+ DelayCounter thread_delay = { 10000 };
if (program.api_thread_count == 0)
return TRUE;
// wait for threads to finish (and fail on timeout)
while (program.api_thread_count > 0)
{
- if (DelayReached(&thread_delay, thread_delay_value))
+ if (DelayReached(&thread_delay))
{
Error("failed waiting for threads - TIMEOUT");
boolean HandleGadgets(int mx, int my, int button)
{
- static unsigned int pressed_delay = 0;
- static unsigned int pressed_delay_value = GADGET_FRAME_DELAY;
+ static DelayCounter pressed_delay = { GADGET_FRAME_DELAY };
static int last_button = 0;
static int last_mx = 0, last_my = 0;
static int pressed_mx = 0, pressed_my = 0;
(button != 0 && last_gi != NULL && new_gi == last_gi);
gadget_pressed_delay_reached =
- DelayReached(&pressed_delay, pressed_delay_value);
+ DelayReached(&pressed_delay);
gadget_released = (release_event && last_gi != NULL);
gadget_released_inside = (gadget_released && new_gi == last_gi);
ResetDelayCounter(&pressed_delay);
// start gadget delay with longer delay after first click on gadget
- pressed_delay_value = GADGET_FRAME_DELAY_FIRST;
+ pressed_delay.value = GADGET_FRAME_DELAY_FIRST;
}
else // gadget hold pressed for some time
{
// after first repeated gadget click, continue with shorter delay value
- pressed_delay_value = GADGET_FRAME_DELAY;
+ pressed_delay.value = GADGET_FRAME_DELAY;
}
if (gi->type & GD_TYPE_SCROLLBAR && !gadget_dragging)
sleep_milliseconds(delay);
}
-boolean DelayReachedExt(unsigned int *counter_var, unsigned int delay,
- unsigned int actual_counter)
+boolean DelayReachedExt2(unsigned int *counter_var, unsigned int delay,
+ unsigned int actual_counter)
{
if (actual_counter >= *counter_var &&
actual_counter < *counter_var + delay)
return TRUE;
}
-boolean FrameReached(unsigned int *frame_counter_var, unsigned int frame_delay)
+boolean DelayReachedExt(DelayCounter *counter, unsigned int actual_counter)
{
- return DelayReachedExt(frame_counter_var, frame_delay, FrameCounter);
+ return DelayReachedExt2(&counter->count, counter->value, actual_counter);
}
-boolean DelayReached(unsigned int *counter_var, unsigned int delay)
+boolean FrameReached(DelayCounter *counter)
{
- return DelayReachedExt(counter_var, delay, Counter());
+ return DelayReachedExt(counter, FrameCounter);
}
-void ResetDelayCounterExt(unsigned int *counter_var,
- unsigned int actual_counter)
+boolean DelayReached(DelayCounter *counter)
{
- DelayReachedExt(counter_var, 0, actual_counter);
+ return DelayReachedExt(counter, Counter());
}
-void ResetFrameCounter(unsigned int *frame_counter_var)
+void ResetDelayCounterExt(DelayCounter *counter, unsigned int actual_counter)
{
- FrameReached(frame_counter_var, 0);
+ DelayReachedExt2(&counter->count, 0, actual_counter);
}
-void ResetDelayCounter(unsigned int *counter_var)
+void ResetFrameCounter(DelayCounter *counter)
{
- DelayReached(counter_var, 0);
+ ResetDelayCounterExt(counter, FrameCounter);
}
-int WaitUntilDelayReached(unsigned int *counter_var, unsigned int delay)
+void ResetDelayCounter(DelayCounter *counter)
{
+ ResetDelayCounterExt(counter, Counter());
+}
+
+int WaitUntilDelayReached(DelayCounter *counter)
+{
+ unsigned int *counter_var = &counter->count;
+ unsigned int delay = counter->value;
unsigned int actual_counter;
int skip_frames = 0;
return skip_frames;
}
-void SkipUntilDelayReached(unsigned int *counter_var, unsigned int delay,
+void SkipUntilDelayReached(DelayCounter *counter,
int *loop_var, int last_loop_value)
{
- int skip_frames = WaitUntilDelayReached(counter_var, delay);
+ int skip_frames = WaitUntilDelayReached(counter);
#if 0
#if DEBUG
if (skip_frames)
Debug("internal:SkipUntilDelayReached",
"%d: %d ms -> SKIP %d FRAME(S) [%d ms]",
- *loop_var, delay,
- skip_frames, skip_frames * delay);
+ *loop_var, counter->value,
+ skip_frames, skip_frames * counter->value);
else
Debug("internal:SkipUntilDelayReached",
"%d: %d ms",
- *loop_var, delay);
+ *loop_var, counter->value);
#endif
#endif
void InitCounter(void);
unsigned int Counter(void);
void Delay(unsigned int);
-boolean DelayReachedExt(unsigned int *, unsigned int, unsigned int);
-boolean FrameReached(unsigned int *, unsigned int);
-boolean DelayReached(unsigned int *, unsigned int);
-void ResetDelayCounterExt(unsigned int *, unsigned int);
-void ResetFrameCounter(unsigned int *);
-void ResetDelayCounter(unsigned int *);
-int WaitUntilDelayReached(unsigned int *, unsigned int);
-void SkipUntilDelayReached(unsigned int *, unsigned int, int *, int);
+boolean DelayReachedExt2(unsigned int *, unsigned int, unsigned int);
+boolean DelayReachedExt(DelayCounter *, unsigned int);
+boolean FrameReached(DelayCounter *);
+boolean DelayReached(DelayCounter *);
+void ResetDelayCounterExt(DelayCounter *, unsigned int);
+void ResetFrameCounter(DelayCounter *);
+void ResetDelayCounter(DelayCounter *);
+int WaitUntilDelayReached(DelayCounter *);
+void SkipUntilDelayReached(DelayCounter *, int *, int);
unsigned int init_random_number(int, int);
unsigned int get_random_number(int, int);
static void UpdateScreenExt(SDL_Rect *rect, boolean with_frame_delay)
{
- static unsigned int update_screen_delay = 0;
- unsigned int update_screen_delay_value = 50; // (milliseconds)
+ static DelayCounter update_screen_delay = { 50 }; // (milliseconds)
SDL_Surface *screen = backbuffer->surface;
if (limit_screen_updates &&
- !DelayReached(&update_screen_delay, update_screen_delay_value))
+ !DelayReached(&update_screen_delay))
return;
LimitScreenUpdates(FALSE);
SDL_Rect src_rect_up = { 0, 0, video.width, video.height };
SDL_Rect dst_rect_up = dst_rect_screen;
- if (video.shifted_up || video.shifted_up_delay)
+ if (video.shifted_up || video.shifted_up_delay.count)
{
int time_current = SDL_GetTicks();
int pos = video.shifted_up_pos;
int pos_last = video.shifted_up_pos_last;
- if (!DelayReachedExt(&video.shifted_up_delay, video.shifted_up_delay_value,
- time_current))
+ if (!DelayReachedExt(&video.shifted_up_delay, time_current))
{
- int delay = time_current - video.shifted_up_delay;
- int delay_value = video.shifted_up_delay_value;
+ int delay_count = time_current - video.shifted_up_delay.count;
+ int delay_value = video.shifted_up_delay.value;
- pos = pos_last + (pos - pos_last) * delay / delay_value;
+ pos = pos_last + (pos - pos_last) * delay_count / delay_value;
}
else
{
video.shifted_up_pos_last = pos;
- video.shifted_up_delay = 0;
+ video.shifted_up_delay.count = 0;
}
src_rect_up.y = pos;
// global synchronization point of the game to align video frame delay
if (with_frame_delay)
- WaitUntilDelayReached(&video.frame_delay, video.frame_delay_value);
+ WaitUntilDelayReached(&video.frame_delay);
video.frame_counter++;
if (expire_loop_sounds &&
IS_LOOP(mixer[channel]) && !IS_MUSIC(mixer[channel]) &&
- DelayReached(&mixer[channel].playing_starttime,
- SOUND_LOOP_EXPIRATION_TIME))
+ DelayReachedExt2(&mixer[channel].playing_starttime,
+ SOUND_LOOP_EXPIRATION_TIME, Counter()))
return TRUE;
if (!Mix_Playing(channel))
video.window_scaling_available = WINDOW_SCALING_STATUS;
video.frame_counter = 0;
- video.frame_delay = 0;
- video.frame_delay_value = GAME_FRAME_DELAY;
+ video.frame_delay.count = 0;
+ video.frame_delay.value = GAME_FRAME_DELAY;
video.shifted_up = FALSE;
video.shifted_up_pos = 0;
video.shifted_up_pos_last = 0;
- video.shifted_up_delay = 0;
- video.shifted_up_delay_value = ONE_SECOND_DELAY / 4;
+ video.shifted_up_delay.count = 0;
+ video.shifted_up_delay.value = ONE_SECOND_DELAY / 4;
SDLInitVideoBuffer(fullscreen);
void SetVideoFrameDelay(unsigned int frame_delay_value)
{
- video.frame_delay_value = frame_delay_value;
+ video.frame_delay.value = frame_delay_value;
}
unsigned int GetVideoFrameDelay(void)
{
- return video.frame_delay_value;
+ return video.frame_delay.value;
}
boolean ChangeVideoModeIfNeeded(boolean fullscreen)
int vsync_mode;
unsigned int frame_counter;
- unsigned int frame_delay;
- unsigned int frame_delay_value;
+ DelayCounter frame_delay;
boolean shifted_up;
int shifted_up_pos;
int shifted_up_pos_last;
- unsigned int shifted_up_delay;
- unsigned int shifted_up_delay_value;
+ DelayCounter shifted_up_delay;
boolean initialized;
};
};
typedef struct ListNode ListNode;
+struct DelayCounter
+{
+ unsigned int value;
+ unsigned int count;
+};
+typedef struct DelayCounter DelayCounter;
+
#endif // TYPES_H
static boolean TitleAutoDelayReached(unsigned int *counter_var,
struct TitleFadingInfo *fi)
{
- return DelayReachedExt(counter_var, fi->auto_delay, getAutoDelayCounter(fi));
+ return DelayReachedExt2(counter_var, fi->auto_delay, getAutoDelayCounter(fi));
}
static void ResetTitleAutoDelay(unsigned int *counter_var,
void HandleInfoScreen_Elements(int dx, int dy, int button)
{
- static unsigned int info_delay = 0;
+ static DelayCounter info_delay = { 0 };
static int num_anims;
static int num_pages;
static int page;
int anims_per_page = NUM_INFO_ELEMENTS_ON_SCREEN;
int i;
+ info_delay.value = GameFrameDelay;
+
if (button == MB_MENU_INITIALIZE)
{
boolean new_element = TRUE;
}
else
{
- if (DelayReached(&info_delay, GameFrameDelay))
+ if (DelayReached(&info_delay))
if (page < num_pages)
DrawInfoScreen_HelpAnim(page * anims_per_page, num_anims, FALSE);
while (!finished)
{
Event event;
- unsigned int event_frame_delay = 0;
- unsigned int event_frame_delay_value = GAME_FRAME_DELAY;
+ DelayCounter event_frame_delay = { GAME_FRAME_DELAY };
// reset frame delay counter directly after updating screen
ResetDelayCounter(&event_frame_delay);
}
// do not handle events for longer than standard frame delay period
- if (DelayReached(&event_frame_delay, event_frame_delay_value))
+ if (DelayReached(&event_frame_delay))
break;
}
int font_height = getFontHeight(font_nr);
int ypos1 = SYSIZE / 2 - font_height * 2;
int ypos2 = SYSIZE / 2 - font_height * 1;
- unsigned int wait_frame_delay = 0;
- unsigned int wait_frame_delay_value = 2000;
+ DelayCounter wait_frame_delay = { 2000 };
ResetDelayCounter(&wait_frame_delay);
DrawTextSCentered(ypos1, font_nr, "Keyboard");
DrawTextSCentered(ypos2, font_nr, "configured!");
- while (!DelayReached(&wait_frame_delay, wait_frame_delay_value))
+ while (!DelayReached(&wait_frame_delay))
BackToFront();
ClearEventQueue();
screen_initialized = TRUE;
- unsigned int event_frame_delay = 0;
- unsigned int event_frame_delay_value = GAME_FRAME_DELAY;
+ DelayCounter event_frame_delay = { GAME_FRAME_DELAY };
// reset frame delay counter directly after updating screen
ResetDelayCounter(&event_frame_delay);
}
// do not handle events for longer than standard frame delay period
- if (DelayReached(&event_frame_delay, event_frame_delay_value))
+ if (DelayReached(&event_frame_delay))
break;
}
}
int font_height = getFontHeight(font_nr);
int ypos1 = SYSIZE / 2 - font_height * 2;
int ypos2 = SYSIZE / 2 - font_height * 1;
- unsigned int wait_frame_delay = 0;
- unsigned int wait_frame_delay_value = 2000;
+ DelayCounter wait_frame_delay = { 2000 };
ResetDelayCounter(&wait_frame_delay);
DrawTextSCentered(ypos1, font_nr, message1);
DrawTextSCentered(ypos2, font_nr, message2);
- while (!DelayReached(&wait_frame_delay, wait_frame_delay_value))
+ while (!DelayReached(&wait_frame_delay))
BackToFront();
ClearEventQueue();
int font_height = getFontHeight(font_nr);
int ypos1 = SYSIZE / 2 - font_height * 2;
int ypos2 = SYSIZE / 2 - font_height * 1;
- unsigned int wait_frame_delay = 0;
- unsigned int wait_frame_delay_value = 2000;
+ DelayCounter wait_frame_delay = { 2000 };
ResetDelayCounter(&wait_frame_delay);
DrawTextSCentered(ypos1, font_nr, "Virtual buttons");
DrawTextSCentered(ypos2, font_nr, "configured!");
- while (!DelayReached(&wait_frame_delay, wait_frame_delay_value))
+ while (!DelayReached(&wait_frame_delay))
BackToFront();
ClearEventQueue();
static boolean PlayScoreTape_WaitForDownload(void)
{
- unsigned int download_delay = 0;
- unsigned int download_delay_value = 10000;
+ DelayCounter download_delay = { 10000 };
ResetDelayCounter(&download_delay);
// wait for score tape to be successfully downloaded (and fail on timeout)
while (!server_scores.tape_downloaded)
{
- if (DelayReached(&download_delay, download_delay_value))
+ if (DelayReached(&download_delay))
return FALSE;
UPDATE_BUSY_STATE_NOT_LOADING();
static boolean AutoPlayTapes_WaitForUpload(void)
{
- unsigned int upload_delay = 0;
- unsigned int upload_delay_value = 10000;
+ DelayCounter upload_delay = { 10000 };
ResetDelayCounter(&upload_delay);
// wait for score tape to be successfully uploaded (and fail on timeout)
while (!server_scores.uploaded)
{
- if (DelayReached(&upload_delay, upload_delay_value))
+ if (DelayReached(&upload_delay))
{
PrintNoLog("\r");
Print("- uploading score tape to score server - TIMEOUT.\n");
int mask_mode = (src_bitmap != NULL ? BLIT_MASKED : BLIT_ON_BACKGROUND);
boolean ffwd_delay = (tape.playing && tape.fast_forward);
boolean no_delay = (tape.warp_forward);
- unsigned int anim_delay = 0;
int frame_delay_value = (ffwd_delay ? FfwdFrameDelay : GameFrameDelay);
int anim_delay_value = MAX(1, (no_delay ? 0 : frame_delay_value) / 2);
+ DelayCounter anim_delay = { anim_delay_value };
int font_nr = FONT_ENVELOPE_1 + envelope_nr;
int font_width = getFontWidth(font_nr);
int font_height = getFontHeight(font_nr);
redraw_mask |= REDRAW_FIELD;
BackToFront();
- SkipUntilDelayReached(&anim_delay, anim_delay_value, &i, last_frame);
+ SkipUntilDelayReached(&anim_delay, &i, last_frame);
}
ClearAutoRepeatKeyEvents();
boolean no_delay = (tape.warp_forward);
int delay_value = (ffwd_delay ? delay_value_fast : delay_value_normal);
int anim_delay_value = MAX(1, (no_delay ? 0 : delay_value + 500 * 0) / 2);
- unsigned int anim_delay = 0;
+ DelayCounter anim_delay = { anim_delay_value };
int tile_size = MAX(request.step_offset, 1);
int max_xsize = request.width / tile_size;
BackToFront();
- SkipUntilDelayReached(&anim_delay, anim_delay_value, &i, last_frame);
+ SkipUntilDelayReached(&anim_delay, &i, last_frame);
}
ClearAutoRepeatKeyEvents();
static void DrawPreviewLevelExt(boolean restart)
{
- static unsigned int scroll_delay = 0;
- static unsigned int label_delay = 0;
+ static DelayCounter scroll_delay = { 0 };
+ static DelayCounter label_delay = { 0 };
static int from_x, from_y, scroll_direction;
static int label_state, label_counter;
- unsigned int scroll_delay_value = preview.step_delay;
boolean show_level_border = (BorderElement != EL_EMPTY);
int level_xsize = lev_fieldx + (show_level_border ? 2 : 0);
int level_ysize = lev_fieldy + (show_level_border ? 2 : 0);
+ scroll_delay.value = preview.step_delay;
+ label_delay.value = MICROLEVEL_LABEL_DELAY;
+
if (restart)
{
from_x = 0;
// scroll preview level, if needed
if (preview.anim_mode != ANIM_NONE &&
(level_xsize > preview.xsize || level_ysize > preview.ysize) &&
- DelayReached(&scroll_delay, scroll_delay_value))
+ DelayReached(&scroll_delay))
{
switch (scroll_direction)
{
if (!strEqual(level.name, NAMELESS_LEVEL_NAME) &&
!strEqual(level.author, ANONYMOUS_NAME) &&
!strEqual(level.author, leveldir_current->name) &&
- DelayReached(&label_delay, MICROLEVEL_LABEL_DELAY))
+ DelayReached(&label_delay))
{
int max_label_counter = 23;
};
static int door1 = DOOR_CLOSE_1;
static int door2 = DOOR_CLOSE_2;
- unsigned int door_delay = 0;
- unsigned int door_delay_value;
+ DelayCounter door_delay = { 0 };
int i;
if (door_state == DOOR_GET_STATE)
num_move_steps = max_move_delay / max_step_delay;
num_move_steps_doors_only = max_move_delay_doors_only / max_step_delay;
- door_delay_value = max_step_delay;
+ door_delay.value = max_step_delay;
if ((door_state & DOOR_NO_DELAY) || setup.quick_doors)
{
{
int k2_door = (door_opening ? k : num_move_steps_doors_only - k - 1);
int kk_door = MAX(0, k2_door);
- int sync_frame = kk_door * door_delay_value;
+ int sync_frame = kk_door * door_delay.value;
int frame = getGraphicAnimationFrame(dpc->graphic, sync_frame);
getFixedGraphicSource(dpc->graphic, frame, &bitmap,
{
BackToFront();
- SkipUntilDelayReached(&door_delay, door_delay_value, &k, last_frame);
+ SkipUntilDelayReached(&door_delay, &k, last_frame);
// prevent OS (Windows) from complaining about program not responding
CheckQuitEvent();
{
// wait for specified door action post delay
if (door_state & DOOR_ACTION_1 && door_state & DOOR_ACTION_2)
- door_delay_value = MAX(door_1.post_delay, door_2.post_delay);
+ door_delay.value = MAX(door_1.post_delay, door_2.post_delay);
else if (door_state & DOOR_ACTION_1)
- door_delay_value = door_1.post_delay;
+ door_delay.value = door_1.post_delay;
else if (door_state & DOOR_ACTION_2)
- door_delay_value = door_2.post_delay;
+ door_delay.value = door_2.post_delay;
- while (!DelayReached(&door_delay, door_delay_value))
+ while (!DelayReached(&door_delay))
BackToFront();
}
}