From b2afaae7abb27b62ce376e52ad508f33cf97d042 Mon Sep 17 00:00:00 2001 From: dannye <33dannye@gmail.com> Date: Tue, 30 Mar 2021 01:06:32 -0500 Subject: [PATCH] Fix remaining uses of fade --- audio/alternate_tempo.asm | 4 +++- audio/play_battle_music.asm | 3 +-- engine/battle/animations.asm | 2 +- engine/events/hidden_objects/safari_game.asm | 2 +- engine/events/pokecenter.asm | 2 +- engine/link/cable_club.asm | 13 ++++++------ engine/movie/hall_of_fame.asm | 7 +++---- engine/movie/oak_speech/oak_speech.asm | 9 +++----- engine/overworld/healing_machine.asm | 18 +++++++--------- engine/overworld/player_animations.asm | 1 - home/audio.asm | 16 +++++++------- home/init.asm | 4 ++-- home/overworld.asm | 22 ++++---------------- home/trainers.asm | 2 +- 14 files changed, 43 insertions(+), 62 deletions(-) diff --git a/audio/alternate_tempo.asm b/audio/alternate_tempo.asm index 301eb969..1548607d 100644 --- a/audio/alternate_tempo.asm +++ b/audio/alternate_tempo.asm @@ -38,7 +38,9 @@ Music_RivalAlternateStartAndTempo:: ; an alternate tempo for Cities1 which is used for the Hall of Fame room Music_Cities1AlternateTempo:: ld a, 10 - call StopMusic + ld [wMusicFade], a + xor a + ld [wMusicFadeID], a ld c, 100 call DelayFrames ; wait for the fade-out to finish ld c, 0 ; BANK(Music_Cities1) diff --git a/audio/play_battle_music.asm b/audio/play_battle_music.asm index 0e90971f..f3ef8dd3 100644 --- a/audio/play_battle_music.asm +++ b/audio/play_battle_music.asm @@ -1,8 +1,7 @@ PlayBattleMusic:: xor a - ld [wAudioFadeOutControl], a - ld [wLowHealthAlarm], a ld [wMusicFade], a + ld [wLowHealthAlarm], a dec a ; SFX_STOP_ALL_MUSIC ; ld [wNewSoundID], a call PlayMusic diff --git a/engine/battle/animations.asm b/engine/battle/animations.asm index a1157d9b..06034684 100644 --- a/engine/battle/animations.asm +++ b/engine/battle/animations.asm @@ -884,7 +884,7 @@ TradeJumpPokeball: cp $ff jr nz, .skipPlayingSound .playSound ; play sound if next move distance is 12 or this is the last one - ld a, SFX_BATTLE_18 + ld a, SFX_SWAP call PlaySound .skipPlayingSound push bc diff --git a/engine/events/hidden_objects/safari_game.asm b/engine/events/hidden_objects/safari_game.asm index bbb81a2c..9cba8afa 100644 --- a/engine/events/hidden_objects/safari_game.asm +++ b/engine/events/hidden_objects/safari_game.asm @@ -30,7 +30,7 @@ SafariZoneGameStillGoing: SafariZoneGameOver: call EnableAutoTextBoxDrawing xor a - ld [wAudioFadeOutControl], a + ld [wMusicFade], a dec a ; SFX_STOP_ALL_MUSIC call PlaySound ld c, 0 ; BANK(SFX_Safari_Zone_PA) diff --git a/engine/events/pokecenter.asm b/engine/events/pokecenter.asm index b10de887..a3d16595 100644 --- a/engine/events/pokecenter.asm +++ b/engine/events/pokecenter.asm @@ -24,7 +24,7 @@ DisplayPokemonCenterDialogue_:: predef HealParty farcall AnimateHealingMachine ; do the healing machine animation xor a - ld [wAudioFadeOutControl], a + ld [wMusicFade], a ; ld a, [wAudioSavedROMBank] ; ld [wAudioROMBank], a ld a, [wMapMusicSoundID] diff --git a/engine/link/cable_club.asm b/engine/link/cable_club.asm index 4ebbc44b..173d6060 100644 --- a/engine/link/cable_club.asm +++ b/engine/link/cable_club.asm @@ -825,12 +825,12 @@ TradeCenter_Trade: ld a, [hl] ld [wTradedEnemyMonSpecies], a ld a, 10 - ld [wAudioFadeOutControl], a + ld [wMusicFade], a ; ld a, 0 ; BANK(Music_SafariZone) ; ld [wAudioSavedROMBank], a ld a, MUSIC_SAFARI_ZONE -; ld [wNewSoundID], a - call PlayMusic + ld [wMusicFadeID], a +; call PlayMusic ld c, 100 call DelayFrames call ClearScreen @@ -916,12 +916,13 @@ CableClub_Run: ld [wLinkState], a ldh [hJoy5], a ld a, 10 - ld [wAudioFadeOutControl], a + ld [wMusicFade], a ; ld a, 0 ; BANK(Music_Celadon) ; ld [wAudioSavedROMBank], a ld a, MUSIC_CELADON -; ld [wNewSoundID], a - jp PlayMusic + ld [wMusicFadeID], a +; jp PlayMusic + ret EmptyFunc: ret diff --git a/engine/movie/hall_of_fame.asm b/engine/movie/hall_of_fame.asm index 0f5ea6f1..cfcb9d99 100644 --- a/engine/movie/hall_of_fame.asm +++ b/engine/movie/hall_of_fame.asm @@ -281,8 +281,7 @@ HoFRecordMonInfo: HoFFadeOutScreenAndMusic: ld a, 10 - ld [wAudioFadeOutCounterReloadValue], a - ld [wAudioFadeOutCounter], a - ld a, $ff - ld [wAudioFadeOutControl], a + ld [wMusicFade], a + xor a + ld [wMusicFadeID], a jp GBFadeOutToWhite diff --git a/engine/movie/oak_speech/oak_speech.asm b/engine/movie/oak_speech/oak_speech.asm index 225723c0..ed89b12d 100644 --- a/engine/movie/oak_speech/oak_speech.asm +++ b/engine/movie/oak_speech/oak_speech.asm @@ -133,12 +133,9 @@ OakSpeech: ; ld [wAudioSavedROMBank], a ld a, 10 - call StopMusic -; ld a, 10 -; ld [wAudioFadeOutControl], a -; ld a, SFX_STOP_ALL_MUSIC -; ld [wNewSoundID], a -; call PlaySound + ld [wMusicFade], a + xor a + ld [wMusicFadeID], a pop af ldh [hLoadedROMBank], a diff --git a/engine/overworld/healing_machine.asm b/engine/overworld/healing_machine.asm index f2561b53..7d034ebe 100644 --- a/engine/overworld/healing_machine.asm +++ b/engine/overworld/healing_machine.asm @@ -17,17 +17,13 @@ AnimateHealingMachine: call CopyHealingMachineOAM ld a, 4 - call StopMusic - call WaitForSongToFinish -; ld a, 4 -; ld [wAudioFadeOutControl], a -; ld a, SFX_STOP_ALL_MUSIC -; ld [wNewSoundID], a -; call PlaySound -;.waitLoop -; ld a, [wAudioFadeOutControl] -; and a ; is fade-out finished? -; jr nz, .waitLoop ; if not, check again + ld [wMusicFade], a + xor a + ld [wMusicFadeID], a +.waitLoop + ld a, [wMusicFade] + and a ; is fade-out finished? + jr nz, .waitLoop ; if not, check again ld a, [wPartyCount] ld b, a diff --git a/engine/overworld/player_animations.asm b/engine/overworld/player_animations.asm index 2723bf9c..c458a013 100644 --- a/engine/overworld/player_animations.asm +++ b/engine/overworld/player_animations.asm @@ -122,7 +122,6 @@ _LeaveMapAnim:: .playerNotStandingOnWarpPadOrHole ld a, $4 call StopMusic - call WaitForSongToFinish ld a, [wd732] bit 6, a ; is the last used pokemon center the destination? jr z, .flyAnimation diff --git a/home/audio.asm b/home/audio.asm index e69fa461..d07e7296 100644 --- a/home/audio.asm +++ b/home/audio.asm @@ -60,17 +60,19 @@ PlayDefaultMusicCommon:: .next4 ld a, c - ld [wAudioFadeOutControl], a - and a - jr nz, .next5 - inc a -.next5 ld [wMusicFade], a - ld a, b ld [wLastMusicSoundID], a -; ld [wNewSoundID], a ld [wMusicFadeID], a + +; if no fade, play immediately + ld a, [wMusicFade] + and a + jr nz, .next5 + ld a, b + call PlayMusic +.next5 + ret ;UpdateMusic6Times:: diff --git a/home/init.asm b/home/init.asm index 357cb6d2..a2744ca7 100644 --- a/home/init.asm +++ b/home/init.asm @@ -130,8 +130,8 @@ StopAllSounds:: ; ld [wAudioROMBank], a ; ld [wAudioSavedROMBank], a xor a - ld [wAudioFadeOutControl], a -; ld [wNewSoundID], a + ld [wMusicFade], a + ld [wMusicFadeID], a ld [wLastMusicSoundID], a dec a jp PlaySound diff --git a/home/overworld.asm b/home/overworld.asm index 67c6067d..e0a55c01 100644 --- a/home/overworld.asm +++ b/home/overworld.asm @@ -760,7 +760,6 @@ HandleBlackOut:: call GBFadeOutToBlack ld a, $08 call StopMusic - call WaitForSongToFinish ld hl, wd72e res 5, [hl] ld a, BANK(ResetStatusAndHalveMoneyOnBlackout) ; also BANK(SpecialWarpIn) and BANK(SpecialEnterMap) @@ -775,24 +774,11 @@ StopMusic:: ld [wMusicFade], a xor a ld [wMusicFadeID], a -.wait0 - ld a, [wMusicFadeCount] +.wait + ld a, [wMusicFade] and a - jr z, .wait0 -.wait1 - ld a, [wMusicFadeCount] - and a - jr nz, .wait1 - ret -; ld [wAudioFadeOutControl], a -; ld a, SFX_STOP_ALL_MUSIC -; ld [wNewSoundID], a -; call PlaySound -;.wait -; ld a, [wAudioFadeOutControl] -; and a -; jr nz, .wait -; jp StopAllSounds + jr nz, .wait + jp StopAllSounds HandleFlyWarpOrDungeonWarp:: call UpdateSprites diff --git a/home/trainers.asm b/home/trainers.asm index ea1781fc..3619b2e5 100644 --- a/home/trainers.asm +++ b/home/trainers.asm @@ -406,7 +406,7 @@ PlayTrainerMusic:: and a ret nz xor a - ld [wAudioFadeOutControl], a + ld [wMusicFade], a ld a, SFX_STOP_ALL_MUSIC call PlaySound ; ld a, 0 ; BANK(Music_MeetEvilTrainer)