From: Holger Schemel Date: Sun, 11 Feb 2024 13:27:43 +0000 (+0100) Subject: added screen redraw function for native BD engine X-Git-Tag: 4.4.0.0-test-1~386 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;ds=sidebyside;h=d959ed0d8d9cadec525853c2ab584f8d1ab079ae;p=rocksndiamonds.git added screen redraw function for native BD engine --- diff --git a/src/game.c b/src/game.c index 2bdd28e5..fa168205 100644 --- a/src/game.c +++ b/src/game.c @@ -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(); diff --git a/src/game_bd/export_bd.h b/src/game_bd/export_bd.h index 7c122930..3b9e704c 100644 --- a/src/game_bd/export_bd.h +++ b/src/game_bd/export_bd.h @@ -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 diff --git a/src/game_bd/import_bd.h b/src/game_bd/import_bd.h index 7cf8e4e9..b53372d2 100644 --- a/src/game_bd/import_bd.h +++ b/src/game_bd/import_bd.h @@ -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); diff --git a/src/game_bd/main_bd.c b/src/game_bd/main_bd.c index fdc5cf0c..ccb04e23 100644 --- a/src/game_bd/main_bd.c +++ b/src/game_bd/main_bd.c @@ -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); +} diff --git a/src/tools.c b/src/tools.c index 7c8f8252..d181501e 100644 --- a/src/tools.c +++ b/src/tools.c @@ -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);