rnd-20140514-1-src
authorHolger Schemel <info@artsoft.org>
Tue, 13 May 2014 23:56:16 +0000 (01:56 +0200)
committerHolger Schemel <info@artsoft.org>
Sat, 30 Aug 2014 09:01:30 +0000 (11:01 +0200)
* fixed level redraw after quick-loading tape with small tile graphics

ChangeLog
src/conftime.h
src/events.c
src/game.c
src/tape.c
src/tools.c

index 0619522e261a2323b046cdbd04487340dc7cd072..33999ffa61e071936e0a7d730bf852c36a9f7ea7 100644 (file)
--- 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
 
index 556b90ccee14988c58c3499fc132edef76ece43c..3355c2e7872fb696fc202c52db18d9ca0ef48d3c 100644 (file)
@@ -1 +1 @@
-#define COMPILE_DATE_STRING "2014-04-30 21:41"
+#define COMPILE_DATE_STRING "2014-05-14 01:51"
index 17c39c0407a887342dbdca3060dcaaf5dc1af68c..4d70027d34911d1aaf5fedc93763d21077fb50e1 100644 (file)
@@ -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;
 
index 8b9d1132f23e7588ac0c6bb68ebabf0bc4ed58d2..335bfdea4c08869fc32ee8f4efd82b9e35e19a64 100644 (file)
@@ -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()
index 9a5aaa9191c08b4211b3bc147c766d4102368864..86a8b2154acf9a1897b82605962c24cadcdc8c71 100644 (file)
@@ -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();
 
index 8954a19dc9ac9d33371ea95e06485e51c97a699d..ea92646c6baecc36ebe2dc47d567e455f55f7ae0 100644 (file)
@@ -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;