From ad345222ae1399e15b034505d6f565e6d4703dc4 Mon Sep 17 00:00:00 2001 From: xCrystal Date: Mon, 23 Oct 2023 18:40:08 +0200 Subject: [PATCH] Handle white out transition from overworld (incl. battle) to game menu (#27) --- constants/script_constants.asm | 5 +++-- engine/board/menu.asm | 1 + engine/board/spaces.asm | 2 +- engine/events/whiteout.asm | 16 +++++++++++----- engine/overworld/scripting.asm | 4 ++++ 5 files changed, 20 insertions(+), 8 deletions(-) diff --git a/constants/script_constants.asm b/constants/script_constants.asm index a87a92c83..57354855c 100644 --- a/constants/script_constants.asm +++ b/constants/script_constants.asm @@ -333,5 +333,6 @@ DEF NUM_BOARD_EVENTS EQU const_value - 1 ; exitoverworld arguments const_def - const ABANDONED_LEVEL ; 0 - const CLEARED_LEVEL ; 1 + const ABANDONED_LEVEL ; 0 + const CLEARED_LEVEL ; 1 + const WHITED_OUT_IN_LEVEL ; 2 diff --git a/engine/board/menu.asm b/engine/board/menu.asm index 8b469aa0e..3d442e122 100755 --- a/engine/board/menu.asm +++ b/engine/board/menu.asm @@ -57,6 +57,7 @@ BoardMenuScript:: .exit: wait 300 exitoverworld ABANDONED_LEVEL + endall .ConfirmExitText: text "Abandon level and" diff --git a/engine/board/spaces.asm b/engine/board/spaces.asm index 2c4d3ee70..31f36a74d 100755 --- a/engine/board/spaces.asm +++ b/engine/board/spaces.asm @@ -55,7 +55,7 @@ EndSpaceScript:: callasm .FadeOutSlow ; 800 ms wait 400 exitoverworld CLEARED_LEVEL - end + endall .FadeOutSlow: ; clear spaces left sprites diff --git a/engine/events/whiteout.asm b/engine/events/whiteout.asm index 1b22438b8..8293d42c5 100644 --- a/engine/events/whiteout.asm +++ b/engine/events/whiteout.asm @@ -15,10 +15,8 @@ Script_Whiteout: checkflag ENGINE_BUG_CONTEST_TIMER iftrue .bug_contest callasm HalveCoins - callasm GetWhiteoutSpawn farscall Script_AbortBugContest - special WarpToSpawnPoint - newloadmap MAPSETUP_WARP + exitoverworld WHITED_OUT_IN_LEVEL endall .bug_contest @@ -32,9 +30,17 @@ OverworldBGMap: call ClearPalettes call ClearScreen call WaitBGMap2 - call HideSprites + call DisableOverworldHUD + xor a + ld [wDisplaySecondarySprites], a + farcall ClearSpriteAnims + call ClearSprites + call LoadStandardFont + call LoadFrame call RotateThreePalettesLeft - ret + ld a, FALSE + ld [wText2bpp], a + jp SpeechTextbox1bpp BattleBGMap: ld b, CGB_BATTLE_GRAYSCALE diff --git a/engine/overworld/scripting.asm b/engine/overworld/scripting.asm index 9453eebfa..bcb76f90f 100644 --- a/engine/overworld/scripting.asm +++ b/engine/overworld/scripting.asm @@ -1157,6 +1157,8 @@ Script_loadtrainer: Script_startbattle: call DisableOverworldHUD + ld a, FALSE + ld [wText2bpp], a call BufferScreen predef StartBattle ld a, [wBattleResult] @@ -1175,6 +1177,8 @@ Script_reloadmapafterbattle: ld hl, wBattleScriptFlags ld d, [hl] ld [hl], 0 + ld a, TRUE + ld [wText2bpp], a ld a, [wBattleResult] and ~BATTLERESULT_BITMASK cp LOSE