extended support for expanding wall settings in BD engine to level editor
[rocksndiamonds.git] / src / game_bd / main_bd.c
index da296229a6652392b2ecd6f56ea05f05b49e304a..6b3ba1043116ebfb468eccff1cb2b3c83f274adc 100644 (file)
@@ -248,6 +248,30 @@ static void UpdateGameDoorValues_BD(void)
   }
 }
 
+static void PrepareGameTileBitmap_BD(void)
+{
+  struct GraphicInfo_BD *g_template = &graphic_info_bd_color_template;
+  struct GraphicInfo_BD *g_default  = &graphic_info_bd_object[O_STONE][0];
+
+  gd_prepare_tile_bitmap(native_bd_level.cave, g_template->bitmap, 1);
+  gd_set_tile_bitmap_reference(g_default->bitmap);
+}
+
+void PreparePreviewTileBitmap_BD(Bitmap *bitmap, int scale_down_factor)
+{
+  gd_prepare_tile_bitmap(native_bd_level.cave, bitmap, scale_down_factor);
+}
+
+void SetPreviewTileBitmapReference_BD(Bitmap *bitmap)
+{
+  gd_set_tile_bitmap_reference(bitmap);
+}
+
+Bitmap *GetPreviewTileBitmap_BD(Bitmap *bitmap)
+{
+  return gd_get_tile_bitmap(bitmap);
+}
+
 unsigned int InitEngineRandom_BD(int seed)
 {
   if (seed == NEW_RANDOMIZE)
@@ -283,6 +307,9 @@ void InitGameEngine_BD(void)
   game_bd.game->itermax = 8;   // default; dynamically changed at runtime
   game_bd.game->itermax_last = game_bd.game->itermax;
 
+  // prepare tile bitmap with level-specific colors, if available
+  PrepareGameTileBitmap_BD();
+
   // default: start with completely covered playfield
   int next_state = GAME_INT_START_UNCOVER + 1;
 
@@ -359,6 +386,19 @@ void GameActions_BD(byte action[MAX_PLAYERS])
 
   play_game_func(game_bd.game, action[0]);
 
+  // scroll without iterating engine if player out of sight (mainly due to wrap-around)
+  // (this is needed to prevent broken tapes in case of viewport or tile size changes)
+  while (game_bd.game->out_of_window)
+  {
+    RedrawPlayfield_BD(TRUE);
+
+    BlitScreenToBitmap_BD(backbuffer);
+
+    BackToFront();
+
+    play_game_func(game_bd.game, action[0]);
+  }
+
   RedrawPlayfield_BD(FALSE);
 
   UpdateGameDoorValues_BD();
@@ -369,6 +409,11 @@ void GameActions_BD(byte action[MAX_PLAYERS])
 // graphics functions
 // ============================================================================
 
+Bitmap *GetTitleScreen_BD(void)
+{
+  return gd_get_title_screen_bitmap();
+}
+
 void CoverScreen_BD(void)
 {
   game_bd.cover_screen = FALSE;