diff options
author | Rangi <35663410+Rangi42@users.noreply.github.com> | 2020-07-07 19:48:22 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-07 19:48:22 -0400 |
commit | 9571c550b6a0dcb3a4f54513c881661a87271024 (patch) | |
tree | d73507228a57e4f3cece2fb93fe7df3a9439553f /home/fade_audio.asm | |
parent | c480632d5494d04f7f5f0298a31877a2293b564e (diff) | |
parent | bbf2f51a02b2544f1bef32a5868503b474ae2fef (diff) |
Merge pull request #263 from Rangi42/master
Syncing style with pokecrystal
Diffstat (limited to 'home/fade_audio.asm')
-rw-r--r-- | home/fade_audio.asm | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/home/fade_audio.asm b/home/fade_audio.asm new file mode 100644 index 00000000..4ad2607d --- /dev/null +++ b/home/fade_audio.asm @@ -0,0 +1,48 @@ +FadeOutAudio:: + ld a, [wAudioFadeOutControl] + and a ; currently fading out audio? + jr nz, .fadingOut + ld a, [wd72c] + bit 1, a + ret nz + ld a, $77 + ldh [rNR50], a + ret +.fadingOut + ld a, [wAudioFadeOutCounter] + and a + jr z, .counterReachedZero + dec a + ld [wAudioFadeOutCounter], a + ret +.counterReachedZero + ld a, [wAudioFadeOutCounterReloadValue] + ld [wAudioFadeOutCounter], a + ldh a, [rNR50] + and a ; has the volume reached 0? + jr z, .fadeOutComplete + ld b, a + and $f + dec a + ld c, a + ld a, b + and $f0 + swap a + dec a + swap a + or c + ldh [rNR50], a + ret +.fadeOutComplete + ld a, [wAudioFadeOutControl] + ld b, a + xor a + ld [wAudioFadeOutControl], a + ld a, SFX_STOP_ALL_MUSIC + ld [wNewSoundID], a + call PlaySound + ld a, [wAudioSavedROMBank] + ld [wAudioROMBank], a + ld a, b + ld [wNewSoundID], a + jp PlaySound |