X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Ftools.c;h=f1aa666e8004c9332f2a79579c903c7c59957a4d;hb=3d1ed92c17f56943478f3be499ee74462d393244;hp=2fa69f1151f8656702b3e6993645b243a81b095a;hpb=be789d9a341f5d7369f4aa2f74e2f85f3e004a4c;p=rocksndiamonds.git diff --git a/src/tools.c b/src/tools.c index 2fa69f11..f1aa666e 100644 --- a/src/tools.c +++ b/src/tools.c @@ -24,7 +24,8 @@ /* select level set with EMC X11 graphics before activating EM GFX debugging */ -#define DEBUG_EM_GFX 0 +#define DEBUG_EM_GFX FALSE +#define DEBUG_FRAME_TIME FALSE /* tool button identifiers */ #define TOOL_CTRL_ID_YES 0 @@ -462,6 +463,44 @@ void DrawFramesPerSecond() font_nr, BLIT_OPAQUE); } +#if DEBUG_FRAME_TIME +static void PrintFrameTimeDebugging() +{ + static unsigned int last_counter = 0; + unsigned int counter = Counter(); + int diff_1 = counter - last_counter; + int diff_2 = diff_1 - GAME_FRAME_DELAY; + int diff_2_max = 20; + int diff_2_cut = MIN(ABS(diff_2), diff_2_max); + char diff_bar[2 * diff_2_max + 5]; + int pos = 0; + int i; + + diff_bar[pos++] = (diff_2 < -diff_2_max ? '<' : ' '); + + for (i = 0; i < diff_2_max; i++) + diff_bar[pos++] = (diff_2 >= 0 ? ' ' : + i >= diff_2_max - diff_2_cut ? '-' : ' '); + + diff_bar[pos++] = '|'; + + for (i = 0; i < diff_2_max; i++) + diff_bar[pos++] = (diff_2 <= 0 ? ' ' : i < diff_2_cut ? '+' : ' '); + + diff_bar[pos++] = (diff_2 > diff_2_max ? '>' : ' '); + + diff_bar[pos++] = '\0'; + + Error(ERR_INFO, "%06d [%02d] [%c%02d] %s", + counter, + diff_1, + (diff_2 < 0 ? '-' : diff_2 > 0 ? '+' : ' '), ABS(diff_2), + diff_bar); + + last_counter = counter; +} +#endif + void BackToFront() { if (redraw_mask == REDRAW_NONE) @@ -509,6 +548,13 @@ void BackToFront() } redraw_mask = REDRAW_NONE; + + // force screen redraw in every frame to continue drawing global animations + redraw_mask = REDRAW_FIELD; + +#if DEBUG_FRAME_TIME + PrintFrameTimeDebugging(); +#endif } static void FadeCrossSaveBackbuffer() @@ -628,6 +674,20 @@ static void FadeExt(int fade_mask, int fade_mode, int fade_type) redraw_mask &= ~fade_mask; } +static void SetAnimStatus_BeforeFadingOut() +{ + global.anim_status = GAME_MODE_PSEUDO_FADING; +} + +static void SetAnimStatus_AfterFadingIn() +{ + global.anim_status = global.anim_status_next; + + // force update of global animation status in case of rapid screen changes + redraw_mask = REDRAW_ALL; + BackToFront(); +} + void FadeIn(int fade_mask) { #if 1 @@ -643,10 +703,14 @@ void FadeIn(int fade_mask) FADE_SY = REAL_SY; FADE_SXSIZE = FULL_SXSIZE; FADE_SYSIZE = FULL_SYSIZE; + + SetAnimStatus_AfterFadingIn(); } void FadeOut(int fade_mask) { + SetAnimStatus_BeforeFadingOut(); + #if 0 DrawMaskedBorder(REDRAW_ALL); #endif @@ -8181,6 +8245,8 @@ void JoinRectangles(int *x, int *y, int *width, int *height, void SetGameStatus(int game_status_new) { game_status = game_status_new; + + global.anim_status_next = game_status; } void ChangeViewportPropertiesIfNeeded()