added screen redraw function for native BD engine
authorHolger Schemel <info@artsoft.org>
Sun, 11 Feb 2024 13:27:43 +0000 (14:27 +0100)
committerHolger Schemel <info@artsoft.org>
Sun, 18 Feb 2024 14:57:43 +0000 (15:57 +0100)
src/game.c
src/game_bd/export_bd.h
src/game_bd/import_bd.h
src/game_bd/main_bd.c
src/tools.c

index 2bdd28e5e5dac725035e2fa097cd5add138a3dac..fa1682053736b0e197c2e9b5b910dcef4dc90217 100644 (file)
@@ -16019,6 +16019,10 @@ void RequestQuitGameExt(boolean skip_request, boolean quick_quit, char *message)
     }
     else
     {
+      // when using BD game engine, cover screen before fading out
+      if (!quick_quit && level.game_engine_type == GAME_ENGINE_TYPE_BD)
+       game_bd.cover_screen = TRUE;
+
       if (quick_quit)
        FadeSkipNextFadeIn();
 
index 7c12293076a2b7c13d4f50b89e7becf382e0a2e7..3b9e704c6099860251a724690878688095d1470c 100644 (file)
@@ -96,5 +96,9 @@ void setLevelInfoToDefaults_BD(void);
 boolean LoadNativeLevel_BD(char *, int, boolean);
 
 unsigned int InitEngineRandom_BD(int);
+void CoverScreen_BD(void);
+
+void BlitScreenToBitmap_BD(Bitmap *);
+void RedrawPlayfield_BD(boolean);
 
 #endif // EXPORT_BD_H
index 7cf8e4e9f16e374634048972bad3c3f4769d2e4f..b53372d2af0c57acb767f2b3402f2f35adb5ff8b 100644 (file)
@@ -28,6 +28,8 @@ void PlayLevelSound_BD(int, int, int, int);
 void StopSound_BD(int, int);
 boolean isSoundPlaying_BD(int, int);
 
+void BackToFront(void);
+
 byte *TapePlayAction_BD(void);
 byte *TapeCorrectAction_BD(byte *);
 boolean TapeIsPlaying_ReplayBD(void);
index fdc5cf0c0a6350f576ac309400ad14bb768536e7..ccb04e23a3f211bebf515d870a31c23aadc57c25 100644 (file)
@@ -200,3 +200,52 @@ unsigned int InitEngineRandom_BD(int seed)
 
   return (unsigned int)seed;
 }
+
+
+// ============================================================================
+// graphics functions
+// ============================================================================
+
+void CoverScreen_BD(void)
+{
+  game_bd.cover_screen = FALSE;
+
+  if (setup.bd_skip_uncovering)
+    return;
+
+  game_bd.game->state_counter = GAME_INT_COVER_START;
+
+  // play game engine (with normal speed) until cave covered
+  while (game_bd.game->state_counter < GAME_INT_COVER_ALL + 1)
+  {
+    play_game_func(game_bd.game, 0);
+
+    RedrawPlayfield_BD(TRUE);
+
+    BlitScreenToBitmap_BD(backbuffer);
+
+    BackToFront();
+  }
+
+  // stop uncovering loop sound when not using native sound engine
+  FadeSounds();
+}
+
+void BlitScreenToBitmap_BD(Bitmap *target_bitmap)
+{
+  int xsize = SXSIZE;
+  int ysize = SYSIZE;
+  int full_xsize = native_bd_level.cave->w * TILESIZE_VAR;
+  int full_ysize = native_bd_level.cave->h * TILESIZE_VAR;
+  int sx = SX + (full_xsize < xsize ? (xsize - full_xsize) / 2 : 0);
+  int sy = SY + (full_ysize < ysize ? (ysize - full_ysize) / 2 : 0);
+  int sxsize = (full_xsize < xsize ? full_xsize : xsize);
+  int sysize = (full_ysize < ysize ? full_ysize : ysize);
+
+  BlitBitmap(gd_screen_bitmap, target_bitmap, 0, 0, sxsize, sysize, sx, sy);
+}
+
+void RedrawPlayfield_BD(boolean force_redraw)
+{
+  gd_drawcave(gd_screen_bitmap, game_bd.game, force_redraw);
+}
index 7c8f825217ccc2459c94bef3b181412ba99aa228..d181501ef101fac3a68dd1ece8097a9af4730d24 100644 (file)
@@ -500,7 +500,9 @@ void RedrawPlayfield(void)
   if (game_status != GAME_MODE_PLAYING)
     return;
 
-  if (level.game_engine_type == GAME_ENGINE_TYPE_EM)
+  if (level.game_engine_type == GAME_ENGINE_TYPE_BD)
+    RedrawPlayfield_BD(TRUE);
+  else if (level.game_engine_type == GAME_ENGINE_TYPE_EM)
     RedrawPlayfield_EM(TRUE);
   else if (level.game_engine_type == GAME_ENGINE_TYPE_SP)
     RedrawPlayfield_SP(TRUE);
@@ -668,7 +670,9 @@ void BlitScreenToBitmap_RND(Bitmap *target_bitmap)
 
 void BlitScreenToBitmap(Bitmap *target_bitmap)
 {
-  if (level.game_engine_type == GAME_ENGINE_TYPE_EM)
+  if (level.game_engine_type == GAME_ENGINE_TYPE_BD)
+    BlitScreenToBitmap_BD(target_bitmap);
+  else if (level.game_engine_type == GAME_ENGINE_TYPE_EM)
     BlitScreenToBitmap_EM(target_bitmap);
   else if (level.game_engine_type == GAME_ENGINE_TYPE_SP)
     BlitScreenToBitmap_SP(target_bitmap);
@@ -1026,6 +1030,10 @@ void FadeOut(int fade_mask)
       fade_type_skip != FADE_MODE_SKIP_FADE_OUT)
     BackToFront();
 
+  // when using BD game engine, cover playfield before fading out after a game
+  if (game_bd.cover_screen)
+    CoverScreen_BD();
+
   SetScreenStates_BeforeFadingOut();
 
   SetTileCursorActive(FALSE);