From 9ea8b203a29569f4d2ed059d33def627ff2b17aa Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Wed, 14 May 2014 01:56:16 +0200 Subject: [PATCH] rnd-20140514-1-src * fixed level redraw after quick-loading tape with small tile graphics --- ChangeLog | 3 ++ src/conftime.h | 2 +- src/events.c | 4 ++- src/game.c | 63 ++++++++++++++++++++++++++++++++-- src/tape.c | 8 +++++ src/tools.c | 92 ++++++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 168 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0619522e..33999ffa 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +2014-05-13 + * fixed level redraw after quick-loading tape with small tile graphics + 2014-03-03 * added compatibility code for existing request door animation settings diff --git a/src/conftime.h b/src/conftime.h index 556b90cc..3355c2e7 100644 --- a/src/conftime.h +++ b/src/conftime.h @@ -1 +1 @@ -#define COMPILE_DATE_STRING "2014-04-30 21:41" +#define COMPILE_DATE_STRING "2014-05-14 01:51" diff --git a/src/events.c b/src/events.c index 17c39c04..4d70027d 100644 --- a/src/events.c +++ b/src/events.c @@ -1163,7 +1163,9 @@ void HandleButton(int mx, int my, int button, int button_nr) case GAME_MODE_PLAYING: #ifdef DEBUG if (button == MB_PRESSED && !motion_status && IN_GFX_FIELD_PLAY(mx, my)) - DumpTile(LEVELX((mx - SX) / TILEX), LEVELY((my - SY) / TILEY)); + DumpTile(LEVELX((mx - SX) / TILESIZE_VAR), + LEVELY((my - SY) / TILESIZE_VAR)); + // DumpTile(LEVELX((mx - SX) / TILEX), LEVELY((my - SY) / TILEY)); #endif break; diff --git a/src/game.c b/src/game.c index 8b9d1132..335bfdea 100644 --- a/src/game.c +++ b/src/game.c @@ -4338,10 +4338,10 @@ void InitGame() SBY_Upper--; #endif - /* +#if 0 printf("::: START-3: %d, %d\n", SBX_Left, SBX_Right); printf("\n"); - */ +#endif #else @@ -16728,6 +16728,14 @@ static void LoadEngineSnapshotValues_RND() } } +void FreeEngineSnapshot() +{ + FreeEngineSnapshotBuffers(); + + setString(&snapshot_level_identifier, NULL); + snapshot_level_nr = -1; +} + void SaveEngineSnapshot() { /* do not save snapshots from editor */ @@ -16737,6 +16745,25 @@ void SaveEngineSnapshot() /* free previous snapshot buffers, if needed */ FreeEngineSnapshotBuffers(); +#if 1 + /* copy some special values to a structure better suited for the snapshot */ + + if (level.game_engine_type == GAME_ENGINE_TYPE_RND) + SaveEngineSnapshotValues_RND(); + if (level.game_engine_type == GAME_ENGINE_TYPE_EM) + SaveEngineSnapshotValues_EM(); + if (level.game_engine_type == GAME_ENGINE_TYPE_SP) + SaveEngineSnapshotValues_SP(); + + /* save values stored in special snapshot structure */ + + if (level.game_engine_type == GAME_ENGINE_TYPE_RND) + SaveEngineSnapshotBuffer(ARGS_ADDRESS_AND_SIZEOF(engine_snapshot_rnd)); + if (level.game_engine_type == GAME_ENGINE_TYPE_EM) + SaveEngineSnapshotBuffer(ARGS_ADDRESS_AND_SIZEOF(engine_snapshot_em)); + if (level.game_engine_type == GAME_ENGINE_TYPE_SP) + SaveEngineSnapshotBuffer(ARGS_ADDRESS_AND_SIZEOF(engine_snapshot_sp)); +#else /* copy some special values to a structure better suited for the snapshot */ SaveEngineSnapshotValues_RND(); @@ -16748,6 +16775,7 @@ void SaveEngineSnapshot() SaveEngineSnapshotBuffer(ARGS_ADDRESS_AND_SIZEOF(engine_snapshot_rnd)); SaveEngineSnapshotBuffer(ARGS_ADDRESS_AND_SIZEOF(engine_snapshot_em)); SaveEngineSnapshotBuffer(ARGS_ADDRESS_AND_SIZEOF(engine_snapshot_sp)); +#endif /* save further RND engine values */ @@ -16843,9 +16871,40 @@ void LoadEngineSnapshot() /* restore special values from snapshot structure */ +#if 1 + if (level.game_engine_type == GAME_ENGINE_TYPE_RND) + LoadEngineSnapshotValues_RND(); + if (level.game_engine_type == GAME_ENGINE_TYPE_EM) + LoadEngineSnapshotValues_EM(); + if (level.game_engine_type == GAME_ENGINE_TYPE_SP) + LoadEngineSnapshotValues_SP(); +#else LoadEngineSnapshotValues_RND(); LoadEngineSnapshotValues_EM(); LoadEngineSnapshotValues_SP(); +#endif + +#if 0 + printf("::: %d, %d (LoadEngineSnapshot / 1)\n", scroll_x, scroll_y); +#endif + +#if 0 + // needed if tile size was different when saving and loading engine snapshot + if (local_player->present) + { + scroll_x = (local_player->jx < SBX_Left + MIDPOSX ? SBX_Left : + local_player->jx > SBX_Right + MIDPOSX ? SBX_Right : + local_player->jx - MIDPOSX); + + scroll_y = (local_player->jy < SBY_Upper + MIDPOSY ? SBY_Upper : + local_player->jy > SBY_Lower + MIDPOSY ? SBY_Lower : + local_player->jy - MIDPOSY); + } +#endif + +#if 0 + printf("::: %d, %d (LoadEngineSnapshot / 1)\n", scroll_x, scroll_y); +#endif } boolean CheckEngineSnapshot() diff --git a/src/tape.c b/src/tape.c index 9a5aaa91..86a8b215 100644 --- a/src/tape.c +++ b/src/tape.c @@ -1179,6 +1179,10 @@ void TapeQuickLoad() if (CheckEngineSnapshot()) { +#if 0 + printf("::: MARK 1\n"); +#endif + TapeStartGamePlaying(); LoadEngineSnapshot(); @@ -1195,6 +1199,10 @@ void TapeQuickLoad() return; } +#if 0 + printf("::: MARK 2\n"); +#endif + TapeStop(); TapeErase(); diff --git a/src/tools.c b/src/tools.c index 8954a19d..ea92646c 100644 --- a/src/tools.c +++ b/src/tools.c @@ -296,6 +296,68 @@ void SetDrawtoField(int mode) } } +#if 1 + +void RedrawPlayfield(boolean force_redraw, int x, int y, int width, int height) +{ + if (game_status == GAME_MODE_PLAYING && + level.game_engine_type == GAME_ENGINE_TYPE_EM) + { + /* currently there is no partial redraw -- always redraw whole playfield */ + RedrawPlayfield_EM(TRUE); + + /* blit playfield from scroll buffer to normal back buffer for fading in */ + BlitScreenToBitmap_EM(backbuffer); + } + else if (game_status == GAME_MODE_PLAYING && + level.game_engine_type == GAME_ENGINE_TYPE_SP) + { + /* currently there is no partial redraw -- always redraw whole playfield */ + RedrawPlayfield_SP(TRUE); + + /* blit playfield from scroll buffer to normal back buffer for fading in */ + BlitScreenToBitmap_SP(backbuffer); + } + else if (game_status == GAME_MODE_PLAYING && + !game.envelope_active) + { +#if 0 + DrawLevel(); +#else + + SetMainBackgroundImage(IMG_BACKGROUND_PLAYING); + // SetDrawBackgroundMask(REDRAW_FIELD); // !!! CHECK THIS !!! + + for (x = BX1; x <= BX2; x++) + for (y = BY1; y <= BY2; y++) + DrawScreenField(x, y); + + redraw_mask |= REDRAW_FIELD; +#endif + DrawAllPlayers(); + +#if NEW_TILESIZE + BlitScreenToBitmap(backbuffer); +#else + /* blit playfield from scroll buffer to normal back buffer */ + if (setup.soft_scrolling) + { + int fx = FX, fy = FY; + + fx += (ScreenMovDir & (MV_LEFT|MV_RIGHT) ? ScreenGfxPos : 0); + fy += (ScreenMovDir & (MV_UP|MV_DOWN) ? ScreenGfxPos : 0); + + BlitBitmap(fieldbuffer, backbuffer, fx,fy, SXSIZE,SYSIZE, SX,SY); + } +#endif + } + + BlitBitmap(drawto, window, gfx.sx, gfx.sy, gfx.sxsize, gfx.sysize, + gfx.sx, gfx.sy); +} + +#else + void RedrawPlayfield(boolean force_redraw, int x, int y, int width, int height) { if (game_status == GAME_MODE_PLAYING && @@ -362,6 +424,8 @@ void RedrawPlayfield(boolean force_redraw, int x, int y, int width, int height) BlitBitmap(drawto, window, x, y, width, height, x, y); } +#endif + void DrawMaskedBorder_Rect(int x, int y, int width, int height) { Bitmap *bitmap = graphic_info[IMG_GLOBAL_BORDER].bitmap; @@ -3274,6 +3338,14 @@ void ShowEnvelopeRequest(char *text, unsigned int req_state, int action) #if 1 if (game_status == GAME_MODE_PLAYING) { +#if 1 + if (level.game_engine_type == GAME_ENGINE_TYPE_EM) + BlitScreenToBitmap_EM(backbuffer); + else if (level.game_engine_type == GAME_ENGINE_TYPE_SP) + BlitScreenToBitmap_SP(backbuffer); + else + BlitScreenToBitmap(backbuffer); +#else if (level.game_engine_type == GAME_ENGINE_TYPE_EM) BlitScreenToBitmap_EM(backbuffer); else if (level.game_engine_type == GAME_ENGINE_TYPE_SP) @@ -3282,6 +3354,7 @@ void ShowEnvelopeRequest(char *text, unsigned int req_state, int action) { BlitBitmap(fieldbuffer, backbuffer, FX, FY, SXSIZE, SYSIZE, SX, SY); } +#endif } SetDrawtoField(DRAW_BACKBUFFER); @@ -4778,10 +4851,19 @@ static boolean RequestEnvelope(char *text, unsigned int req_state) if (game_status == GAME_MODE_PLAYING) { +#if 1 if (level.game_engine_type == GAME_ENGINE_TYPE_EM) BlitScreenToBitmap_EM(backbuffer); else if (level.game_engine_type == GAME_ENGINE_TYPE_SP) BlitScreenToBitmap_SP(backbuffer); + else + BlitScreenToBitmap(backbuffer); +#else + if (level.game_engine_type == GAME_ENGINE_TYPE_EM) + BlitScreenToBitmap_EM(backbuffer); + else if (level.game_engine_type == GAME_ENGINE_TYPE_SP) + BlitScreenToBitmap_SP(backbuffer); +#endif } /* disable deactivated drawing when quick-loading level tape recording */ @@ -11471,6 +11553,16 @@ void ChangeViewportPropertiesIfNeeded() #endif ) { +#if 1 + // changing tile size invalidates scroll values of engine snapshots + if (new_tilesize_var != TILESIZE_VAR) + { + // printf("::: new_tilesize_var != TILESIZE_VAR\n"); + + FreeEngineSnapshot(); + } +#endif + SX = new_sx; SY = new_sy; DX = new_dx; -- 2.34.1