X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Ftools.c;h=3948bcb1745ff83ad312b2ae5562cbf94af2bffe;hb=46881519bdb4df7d22412ce87efded94b4244e1d;hp=6a1306e45e903f9238a6526b4a6a86f68bcc1ce2;hpb=8ae535c1c76e1c33572afbcd4b2d3d9c3d7ba63e;p=rocksndiamonds.git diff --git a/src/tools.c b/src/tools.c index 6a1306e4..3948bcb1 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 @@ -292,6 +293,9 @@ static void DrawMaskedBorderExt_Rect(int x, int y, int width, int height, { Bitmap *bitmap = getGlobalBorderBitmapFromGameStatus(); + if (x == -1 && y == -1) + return; + if (blit_to_screen) BlitToScreenMasked(bitmap, x, y, width, height, x, y); else @@ -462,6 +466,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 +551,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 +677,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 +706,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 @@ -2382,13 +2449,13 @@ void DrawEnvelopeRequest(char *text) tile_size, tile_size); /* force DOOR font inside door area */ - game_status = GAME_MODE_PSEUDO_DOOR; + SetGameStatus(GAME_MODE_PSEUDO_DOOR); DrawTextBuffer(sx + sx_offset, sy + sy_offset, text_final, font_nr, line_length, -1, max_lines, line_spacing, mask_mode, request.autowrap, request.centered, FALSE); - game_status = last_game_status; /* restore current game status */ + SetGameStatus(last_game_status); /* restore current game status */ for (i = 0; i < NUM_TOOL_BUTTONS; i++) RedrawGadget(tool_gadget[i]); @@ -2793,7 +2860,7 @@ static void DrawPreviewLevelExt(boolean restart) DrawTextSAligned(pos->x, pos->y, label_text, font_nr, pos->align); } - game_status = last_game_status; /* restore current game status */ + SetGameStatus(last_game_status); /* restore current game status */ return; } @@ -2895,7 +2962,7 @@ static void DrawPreviewLevelExt(boolean restart) DrawPreviewLevelLabelExt(label_state); } - game_status = last_game_status; /* restore current game status */ + SetGameStatus(last_game_status); /* restore current game status */ } void DrawPreviewLevelInitial() @@ -3680,7 +3747,7 @@ static boolean RequestDoor(char *text, unsigned int req_state) DrawBackground(DX, DY, DXSIZE, DYSIZE); /* force DOOR font inside door area */ - game_status = GAME_MODE_PSEUDO_DOOR; + SetGameStatus(GAME_MODE_PSEUDO_DOOR); /* write text for request */ for (text_ptr = text, ty = 0; ty < MAX_REQUEST_LINES; ty++) @@ -3720,7 +3787,7 @@ static boolean RequestDoor(char *text, unsigned int req_state) // text_ptr += tl + (tc == ' ' || tc == '?' || tc == '!' ? 1 : 0); } - game_status = last_game_status; /* restore current game status */ + SetGameStatus(last_game_status); /* restore current game status */ if (req_state & REQ_ASK) { @@ -4164,7 +4231,7 @@ unsigned int MoveDoor(unsigned int door_state) { DX, DY, DXSIZE, DYSIZE }, { VX, VY, VXSIZE, VYSIZE } }; - static int door1 = DOOR_OPEN_1; + static int door1 = DOOR_CLOSE_1; static int door2 = DOOR_CLOSE_2; unsigned int door_delay = 0; unsigned int door_delay_value; @@ -8178,6 +8245,13 @@ void JoinRectangles(int *x, int *y, int *width, int *height, *height = MAX(*height, height2); } +void SetGameStatus(int game_status_new) +{ + game_status = game_status_new; + + global.anim_status_next = game_status; +} + void ChangeViewportPropertiesIfNeeded() { int gfx_game_mode = game_status; @@ -8233,6 +8307,7 @@ void ChangeViewportPropertiesIfNeeded() init_video_buffer = TRUE; init_gfx_buffers = TRUE; + init_gadgets_and_toons = TRUE; // printf("::: video: init_video_buffer, init_gfx_buffers\n"); } @@ -8383,6 +8458,7 @@ void ChangeViewportPropertiesIfNeeded() InitGadgets(); InitToons(); + InitGlobalAnimations(); } if (init_em_graphics)