2014-05-21 13:26:28 -07:00
|
|
|
; Audio interfaces.
|
|
|
|
|
2019-11-18 09:16:50 -08:00
|
|
|
InitSound::
|
2014-05-21 13:26:28 -07:00
|
|
|
push hl
|
|
|
|
push de
|
|
|
|
push bc
|
|
|
|
push af
|
|
|
|
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hROMBank]
|
2014-05-21 13:26:28 -07:00
|
|
|
push af
|
2019-11-18 09:16:50 -08:00
|
|
|
ld a, BANK(_InitSound)
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hROMBank], a
|
2014-05-21 13:26:28 -07:00
|
|
|
ld [MBC3RomBank], a
|
|
|
|
|
2019-11-18 09:16:50 -08:00
|
|
|
call _InitSound
|
2014-05-21 13:26:28 -07:00
|
|
|
|
|
|
|
pop af
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hROMBank], a
|
2014-05-21 13:26:28 -07:00
|
|
|
ld [MBC3RomBank], a
|
|
|
|
|
|
|
|
pop af
|
|
|
|
pop bc
|
|
|
|
pop de
|
|
|
|
pop hl
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
UpdateSound::
|
2014-05-21 13:26:28 -07:00
|
|
|
push hl
|
|
|
|
push de
|
|
|
|
push bc
|
|
|
|
push af
|
|
|
|
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hROMBank]
|
2014-05-21 13:26:28 -07:00
|
|
|
push af
|
|
|
|
ld a, BANK(_UpdateSound)
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hROMBank], a
|
2014-05-21 13:26:28 -07:00
|
|
|
ld [MBC3RomBank], a
|
|
|
|
|
|
|
|
call _UpdateSound
|
|
|
|
|
|
|
|
pop af
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hROMBank], a
|
2014-05-21 13:26:28 -07:00
|
|
|
ld [MBC3RomBank], a
|
|
|
|
|
|
|
|
pop af
|
|
|
|
pop bc
|
|
|
|
pop de
|
|
|
|
pop hl
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
_LoadMusicByte::
|
2020-12-07 09:44:16 -08:00
|
|
|
; [wCurMusicByte] = [a:de]
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hROMBank], a
|
2014-05-21 13:26:28 -07:00
|
|
|
ld [MBC3RomBank], a
|
|
|
|
|
|
|
|
ld a, [de]
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wCurMusicByte], a
|
2014-05-21 13:26:28 -07:00
|
|
|
ld a, BANK(LoadMusicByte)
|
|
|
|
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hROMBank], a
|
2014-05-21 13:26:28 -07:00
|
|
|
ld [MBC3RomBank], a
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
PlayMusic::
|
2014-05-21 13:26:28 -07:00
|
|
|
; Play music de.
|
|
|
|
|
|
|
|
push hl
|
|
|
|
push de
|
|
|
|
push bc
|
|
|
|
push af
|
|
|
|
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hROMBank]
|
2014-05-21 13:26:28 -07:00
|
|
|
push af
|
2019-11-18 09:16:50 -08:00
|
|
|
ld a, BANK(_PlayMusic) ; aka BANK(_InitSound)
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hROMBank], a
|
2014-05-21 13:26:28 -07:00
|
|
|
ld [MBC3RomBank], a
|
|
|
|
|
|
|
|
ld a, e
|
|
|
|
and a
|
|
|
|
jr z, .nomusic
|
|
|
|
|
|
|
|
call _PlayMusic
|
|
|
|
jr .end
|
|
|
|
|
|
|
|
.nomusic
|
2019-11-18 09:16:50 -08:00
|
|
|
call _InitSound
|
2014-05-21 13:26:28 -07:00
|
|
|
|
|
|
|
.end
|
|
|
|
pop af
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hROMBank], a
|
2014-05-21 13:26:28 -07:00
|
|
|
ld [MBC3RomBank], a
|
|
|
|
pop af
|
|
|
|
pop bc
|
|
|
|
pop de
|
|
|
|
pop hl
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
PlayMusic2::
|
2014-05-21 13:26:28 -07:00
|
|
|
; Stop playing music, then play music de.
|
|
|
|
|
|
|
|
push hl
|
|
|
|
push de
|
|
|
|
push bc
|
|
|
|
push af
|
|
|
|
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hROMBank]
|
2014-05-21 13:26:28 -07:00
|
|
|
push af
|
|
|
|
ld a, BANK(_PlayMusic)
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hROMBank], a
|
2014-05-21 13:26:28 -07:00
|
|
|
ld [MBC3RomBank], a
|
|
|
|
|
|
|
|
push de
|
|
|
|
ld de, MUSIC_NONE
|
|
|
|
call _PlayMusic
|
|
|
|
call DelayFrame
|
|
|
|
pop de
|
|
|
|
call _PlayMusic
|
|
|
|
|
|
|
|
pop af
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hROMBank], a
|
2014-05-21 13:26:28 -07:00
|
|
|
ld [MBC3RomBank], a
|
|
|
|
|
|
|
|
pop af
|
|
|
|
pop bc
|
|
|
|
pop de
|
|
|
|
pop hl
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
PlayCry::
|
2018-01-23 08:17:21 -08:00
|
|
|
; Play cry de.
|
2014-05-21 13:26:28 -07:00
|
|
|
|
|
|
|
push hl
|
|
|
|
push de
|
|
|
|
push bc
|
|
|
|
push af
|
|
|
|
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hROMBank]
|
2014-05-21 13:26:28 -07:00
|
|
|
push af
|
|
|
|
|
2017-12-26 09:50:32 -08:00
|
|
|
; Cries are stuck in one bank.
|
|
|
|
ld a, BANK(PokemonCries)
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hROMBank], a
|
2014-05-21 13:26:28 -07:00
|
|
|
ld [MBC3RomBank], a
|
|
|
|
|
2017-12-26 09:50:32 -08:00
|
|
|
ld hl, PokemonCries
|
2021-03-03 19:22:41 -08:00
|
|
|
rept MON_CRY_LENGTH
|
2014-05-21 13:26:28 -07:00
|
|
|
add hl, de
|
2015-07-20 19:18:18 -07:00
|
|
|
endr
|
2014-05-21 13:26:28 -07:00
|
|
|
|
|
|
|
ld e, [hl]
|
|
|
|
inc hl
|
|
|
|
ld d, [hl]
|
|
|
|
inc hl
|
|
|
|
|
|
|
|
ld a, [hli]
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wCryPitch], a
|
2014-05-21 13:26:28 -07:00
|
|
|
ld a, [hli]
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wCryPitch + 1], a
|
2014-05-21 13:26:28 -07:00
|
|
|
ld a, [hli]
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wCryLength], a
|
2014-05-21 13:26:28 -07:00
|
|
|
ld a, [hl]
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wCryLength + 1], a
|
2014-05-21 13:26:28 -07:00
|
|
|
|
2018-01-16 20:47:45 -08:00
|
|
|
ld a, BANK(_PlayCry)
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hROMBank], a
|
2014-05-21 13:26:28 -07:00
|
|
|
ld [MBC3RomBank], a
|
|
|
|
|
2018-01-16 20:47:45 -08:00
|
|
|
call _PlayCry
|
2014-05-21 13:26:28 -07:00
|
|
|
|
|
|
|
pop af
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hROMBank], a
|
2014-05-21 13:26:28 -07:00
|
|
|
ld [MBC3RomBank], a
|
2016-04-10 11:42:14 -07:00
|
|
|
|
2014-05-21 13:26:28 -07:00
|
|
|
pop af
|
|
|
|
pop bc
|
|
|
|
pop de
|
|
|
|
pop hl
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
PlaySFX::
|
2014-05-21 13:26:28 -07:00
|
|
|
; Play sound effect de.
|
2016-05-28 12:43:41 -07:00
|
|
|
; Sound effects are ordered by priority (highest to lowest)
|
2014-05-21 13:26:28 -07:00
|
|
|
|
|
|
|
push hl
|
|
|
|
push de
|
|
|
|
push bc
|
|
|
|
push af
|
|
|
|
|
|
|
|
; Is something already playing?
|
|
|
|
call CheckSFX
|
|
|
|
jr nc, .play
|
|
|
|
|
|
|
|
; Does it have priority?
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wCurSFX]
|
2014-05-21 13:26:28 -07:00
|
|
|
cp e
|
|
|
|
jr c, .done
|
|
|
|
|
|
|
|
.play
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hROMBank]
|
2014-05-21 13:26:28 -07:00
|
|
|
push af
|
|
|
|
ld a, BANK(_PlaySFX)
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hROMBank], a
|
2014-05-21 13:26:28 -07:00
|
|
|
ld [MBC3RomBank], a
|
|
|
|
|
|
|
|
ld a, e
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wCurSFX], a
|
2014-05-21 13:26:28 -07:00
|
|
|
call _PlaySFX
|
|
|
|
|
|
|
|
pop af
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hROMBank], a
|
2014-05-21 13:26:28 -07:00
|
|
|
ld [MBC3RomBank], a
|
|
|
|
|
|
|
|
.done
|
|
|
|
pop af
|
|
|
|
pop bc
|
|
|
|
pop de
|
|
|
|
pop hl
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
WaitPlaySFX::
|
2014-05-21 13:26:28 -07:00
|
|
|
call WaitSFX
|
|
|
|
call PlaySFX
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
WaitSFX::
|
2014-05-21 13:26:28 -07:00
|
|
|
; infinite loop until sfx is done playing
|
|
|
|
|
|
|
|
push hl
|
2016-04-10 11:42:14 -07:00
|
|
|
|
2014-05-21 13:26:28 -07:00
|
|
|
.wait
|
2018-06-04 02:35:27 -07:00
|
|
|
ld hl, wChannel5Flags1
|
2014-05-21 13:26:28 -07:00
|
|
|
bit 0, [hl]
|
|
|
|
jr nz, .wait
|
2018-06-04 02:35:27 -07:00
|
|
|
ld hl, wChannel6Flags1
|
2014-05-21 13:26:28 -07:00
|
|
|
bit 0, [hl]
|
|
|
|
jr nz, .wait
|
2018-06-04 02:35:27 -07:00
|
|
|
ld hl, wChannel7Flags1
|
2014-05-21 13:26:28 -07:00
|
|
|
bit 0, [hl]
|
|
|
|
jr nz, .wait
|
2018-06-04 02:35:27 -07:00
|
|
|
ld hl, wChannel8Flags1
|
2014-05-21 13:26:28 -07:00
|
|
|
bit 0, [hl]
|
|
|
|
jr nz, .wait
|
2016-04-10 11:42:14 -07:00
|
|
|
|
2014-05-21 13:26:28 -07:00
|
|
|
pop hl
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
IsSFXPlaying::
|
2014-05-21 13:26:28 -07:00
|
|
|
; Return carry if no sound effect is playing.
|
|
|
|
; The inverse of CheckSFX.
|
|
|
|
push hl
|
|
|
|
|
2018-06-04 02:35:27 -07:00
|
|
|
ld hl, wChannel5Flags1
|
2014-05-21 13:26:28 -07:00
|
|
|
bit 0, [hl]
|
|
|
|
jr nz, .playing
|
2018-06-04 02:35:27 -07:00
|
|
|
ld hl, wChannel6Flags1
|
2014-05-21 13:26:28 -07:00
|
|
|
bit 0, [hl]
|
|
|
|
jr nz, .playing
|
2018-06-04 02:35:27 -07:00
|
|
|
ld hl, wChannel7Flags1
|
2014-05-21 13:26:28 -07:00
|
|
|
bit 0, [hl]
|
|
|
|
jr nz, .playing
|
2018-06-04 02:35:27 -07:00
|
|
|
ld hl, wChannel8Flags1
|
2014-05-21 13:26:28 -07:00
|
|
|
bit 0, [hl]
|
|
|
|
jr nz, .playing
|
|
|
|
|
|
|
|
pop hl
|
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
|
|
|
.playing
|
|
|
|
pop hl
|
|
|
|
and a
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
MaxVolume::
|
2017-12-09 10:28:23 -08:00
|
|
|
ld a, MAX_VOLUME
|
2018-01-23 13:45:34 -08:00
|
|
|
ld [wVolume], a
|
2014-05-21 13:26:28 -07:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
LowVolume::
|
2019-09-02 01:40:58 -07:00
|
|
|
ld a, $33 ; 50%
|
2018-01-23 13:45:34 -08:00
|
|
|
ld [wVolume], a
|
2014-05-21 13:26:28 -07:00
|
|
|
ret
|
|
|
|
|
2019-09-02 01:40:58 -07:00
|
|
|
MinVolume::
|
2014-05-21 13:26:28 -07:00
|
|
|
xor a
|
2018-01-23 13:45:34 -08:00
|
|
|
ld [wVolume], a
|
2014-05-21 13:26:28 -07:00
|
|
|
ret
|
|
|
|
|
2020-06-21 15:33:31 -07:00
|
|
|
FadeOutToMusic:: ; unreferenced
|
2014-05-21 13:26:28 -07:00
|
|
|
ld a, 4
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wMusicFade], a
|
2014-05-21 13:26:28 -07:00
|
|
|
ret
|
|
|
|
|
2020-06-21 15:33:31 -07:00
|
|
|
FadeInToMusic::
|
2018-01-09 14:20:47 -08:00
|
|
|
ld a, 4 | (1 << MUSIC_FADE_IN_F)
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wMusicFade], a
|
2014-05-21 13:26:28 -07:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
SkipMusic::
|
2014-05-21 13:26:28 -07:00
|
|
|
; Skip a frames of music.
|
2015-11-05 11:06:03 -08:00
|
|
|
.loop
|
2014-05-21 13:26:28 -07:00
|
|
|
and a
|
|
|
|
ret z
|
|
|
|
dec a
|
|
|
|
call UpdateSound
|
2015-11-05 11:06:03 -08:00
|
|
|
jr .loop
|
2014-05-21 13:26:28 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
FadeToMapMusic::
|
2014-05-21 13:26:28 -07:00
|
|
|
push hl
|
|
|
|
push de
|
|
|
|
push bc
|
|
|
|
push af
|
|
|
|
|
2018-01-16 19:57:19 -08:00
|
|
|
call GetMapMusic_MaybeSpecial
|
2014-05-21 13:26:28 -07:00
|
|
|
ld a, [wMapMusic]
|
|
|
|
cp e
|
|
|
|
jr z, .done
|
|
|
|
|
|
|
|
ld a, 8
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wMusicFade], a
|
2014-05-21 13:26:28 -07:00
|
|
|
ld a, e
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wMusicFadeID], a
|
2014-05-21 13:26:28 -07:00
|
|
|
ld a, d
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wMusicFadeID + 1], a
|
2014-05-21 13:26:28 -07:00
|
|
|
ld a, e
|
|
|
|
ld [wMapMusic], a
|
|
|
|
|
|
|
|
.done
|
|
|
|
pop af
|
|
|
|
pop bc
|
|
|
|
pop de
|
|
|
|
pop hl
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
PlayMapMusic::
|
2014-05-21 13:26:28 -07:00
|
|
|
push hl
|
|
|
|
push de
|
|
|
|
push bc
|
|
|
|
push af
|
|
|
|
|
2018-01-16 19:57:19 -08:00
|
|
|
call GetMapMusic_MaybeSpecial
|
2014-05-21 13:26:28 -07:00
|
|
|
ld a, [wMapMusic]
|
|
|
|
cp e
|
|
|
|
jr z, .done
|
|
|
|
|
|
|
|
push de
|
|
|
|
ld de, MUSIC_NONE
|
|
|
|
call PlayMusic
|
|
|
|
call DelayFrame
|
|
|
|
pop de
|
|
|
|
ld a, e
|
|
|
|
ld [wMapMusic], a
|
|
|
|
call PlayMusic
|
|
|
|
|
|
|
|
.done
|
|
|
|
pop af
|
|
|
|
pop bc
|
|
|
|
pop de
|
|
|
|
pop hl
|
|
|
|
ret
|
|
|
|
|
2019-11-18 09:16:50 -08:00
|
|
|
PlayMapMusicBike::
|
|
|
|
; If the player's on a bike, play the bike music instead of the map music
|
2014-05-21 13:26:28 -07:00
|
|
|
push hl
|
|
|
|
push de
|
|
|
|
push bc
|
|
|
|
push af
|
|
|
|
|
|
|
|
xor a
|
2015-12-26 15:11:55 -08:00
|
|
|
ld [wDontPlayMapMusicOnReload], a
|
2014-05-21 13:26:28 -07:00
|
|
|
ld de, MUSIC_BICYCLE
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wPlayerState]
|
2014-05-21 13:26:28 -07:00
|
|
|
cp PLAYER_BIKE
|
|
|
|
jr z, .play
|
2018-01-16 19:57:19 -08:00
|
|
|
call GetMapMusic_MaybeSpecial
|
2014-05-21 13:26:28 -07:00
|
|
|
.play
|
|
|
|
push de
|
|
|
|
ld de, MUSIC_NONE
|
|
|
|
call PlayMusic
|
|
|
|
call DelayFrame
|
|
|
|
pop de
|
|
|
|
|
|
|
|
ld a, e
|
|
|
|
ld [wMapMusic], a
|
|
|
|
call PlayMusic
|
|
|
|
|
|
|
|
pop af
|
|
|
|
pop bc
|
|
|
|
pop de
|
|
|
|
pop hl
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
TryRestartMapMusic::
|
2015-12-26 15:11:55 -08:00
|
|
|
ld a, [wDontPlayMapMusicOnReload]
|
2014-05-21 13:26:28 -07:00
|
|
|
and a
|
|
|
|
jr z, RestartMapMusic
|
|
|
|
xor a
|
|
|
|
ld [wMapMusic], a
|
|
|
|
ld de, MUSIC_NONE
|
|
|
|
call PlayMusic
|
|
|
|
call DelayFrame
|
|
|
|
xor a
|
2015-12-26 15:11:55 -08:00
|
|
|
ld [wDontPlayMapMusicOnReload], a
|
2014-05-21 13:26:28 -07:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
RestartMapMusic::
|
2014-05-21 13:26:28 -07:00
|
|
|
push hl
|
|
|
|
push de
|
|
|
|
push bc
|
|
|
|
push af
|
|
|
|
ld de, MUSIC_NONE
|
|
|
|
call PlayMusic
|
|
|
|
call DelayFrame
|
|
|
|
ld a, [wMapMusic]
|
|
|
|
ld e, a
|
|
|
|
ld d, 0
|
|
|
|
call PlayMusic
|
|
|
|
pop af
|
|
|
|
pop bc
|
|
|
|
pop de
|
|
|
|
pop hl
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
SpecialMapMusic::
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wPlayerState]
|
2014-05-21 13:26:28 -07:00
|
|
|
cp PLAYER_SURF
|
|
|
|
jr z, .surf
|
|
|
|
cp PLAYER_SURF_PIKA
|
|
|
|
jr z, .surf
|
|
|
|
|
2017-12-28 04:15:46 -08:00
|
|
|
ld a, [wStatusFlags2]
|
2018-01-22 12:40:43 -08:00
|
|
|
bit STATUSFLAGS2_BUG_CONTEST_TIMER_F, a
|
2014-05-21 13:26:28 -07:00
|
|
|
jr nz, .contest
|
|
|
|
|
|
|
|
.no
|
|
|
|
and a
|
|
|
|
ret
|
|
|
|
|
2020-10-26 12:45:57 -07:00
|
|
|
.bike ; unreferenced
|
2014-05-21 13:26:28 -07:00
|
|
|
ld de, MUSIC_BICYCLE
|
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
|
|
|
.surf
|
|
|
|
ld de, MUSIC_SURF
|
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
|
|
|
.contest
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wMapGroup]
|
2014-05-21 13:26:28 -07:00
|
|
|
cp GROUP_ROUTE_35_NATIONAL_PARK_GATE
|
|
|
|
jr nz, .no
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wMapNumber]
|
2014-05-21 13:26:28 -07:00
|
|
|
cp MAP_ROUTE_35_NATIONAL_PARK_GATE
|
|
|
|
jr z, .ranking
|
|
|
|
cp MAP_ROUTE_36_NATIONAL_PARK_GATE
|
|
|
|
jr nz, .no
|
|
|
|
|
|
|
|
.ranking
|
|
|
|
ld de, MUSIC_BUG_CATCHING_CONTEST_RANKING
|
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
GetMapMusic_MaybeSpecial::
|
2014-05-21 13:26:28 -07:00
|
|
|
call SpecialMapMusic
|
|
|
|
ret c
|
2018-01-16 19:57:19 -08:00
|
|
|
call GetMapMusic
|
2014-05-21 13:26:28 -07:00
|
|
|
ret
|
|
|
|
|
2020-06-22 13:30:13 -07:00
|
|
|
PlaceBCDNumberSprite:: ; unreferenced
|
|
|
|
; Places a BCD number at the upper center of the screen.
|
2018-01-10 10:47:57 -08:00
|
|
|
ld a, 4 * TILE_WIDTH
|
2018-01-30 11:52:46 -08:00
|
|
|
ld [wVirtualOAMSprite38YCoord], a
|
|
|
|
ld [wVirtualOAMSprite39YCoord], a
|
2018-01-10 10:47:57 -08:00
|
|
|
ld a, 10 * TILE_WIDTH
|
2018-01-30 11:52:46 -08:00
|
|
|
ld [wVirtualOAMSprite38XCoord], a
|
2018-01-10 10:47:57 -08:00
|
|
|
ld a, 11 * TILE_WIDTH
|
2018-01-30 11:52:46 -08:00
|
|
|
ld [wVirtualOAMSprite39XCoord], a
|
2014-05-21 13:26:28 -07:00
|
|
|
xor a
|
2018-01-30 11:52:46 -08:00
|
|
|
ld [wVirtualOAMSprite38Attributes], a
|
|
|
|
ld [wVirtualOAMSprite39Attributes], a
|
2019-04-19 08:35:27 -07:00
|
|
|
ld a, [wUnusedBCDNumber]
|
2016-01-17 21:39:01 -08:00
|
|
|
cp 100
|
2014-05-21 13:26:28 -07:00
|
|
|
jr nc, .max
|
|
|
|
add 1
|
|
|
|
daa
|
|
|
|
ld b, a
|
|
|
|
swap a
|
|
|
|
and $f
|
|
|
|
add "0"
|
2018-01-30 11:52:46 -08:00
|
|
|
ld [wVirtualOAMSprite38TileID], a
|
2014-05-21 13:26:28 -07:00
|
|
|
ld a, b
|
|
|
|
and $f
|
|
|
|
add "0"
|
2018-01-30 11:52:46 -08:00
|
|
|
ld [wVirtualOAMSprite39TileID], a
|
2014-05-21 13:26:28 -07:00
|
|
|
ret
|
|
|
|
|
|
|
|
.max
|
|
|
|
ld a, "9"
|
2018-01-30 11:52:46 -08:00
|
|
|
ld [wVirtualOAMSprite38TileID], a
|
|
|
|
ld [wVirtualOAMSprite39TileID], a
|
2014-05-21 13:26:28 -07:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
CheckSFX::
|
2014-05-21 13:26:28 -07:00
|
|
|
; Return carry if any SFX channels are active.
|
2018-06-04 02:35:27 -07:00
|
|
|
ld a, [wChannel5Flags1]
|
2014-05-21 13:26:28 -07:00
|
|
|
bit 0, a
|
|
|
|
jr nz, .playing
|
2018-06-04 02:35:27 -07:00
|
|
|
ld a, [wChannel6Flags1]
|
2014-05-21 13:26:28 -07:00
|
|
|
bit 0, a
|
|
|
|
jr nz, .playing
|
2018-06-04 02:35:27 -07:00
|
|
|
ld a, [wChannel7Flags1]
|
2014-05-21 13:26:28 -07:00
|
|
|
bit 0, a
|
|
|
|
jr nz, .playing
|
2018-06-04 02:35:27 -07:00
|
|
|
ld a, [wChannel8Flags1]
|
2014-05-21 13:26:28 -07:00
|
|
|
bit 0, a
|
|
|
|
jr nz, .playing
|
|
|
|
and a
|
|
|
|
ret
|
|
|
|
.playing
|
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
TerminateExpBarSound::
|
2014-05-21 13:26:28 -07:00
|
|
|
xor a
|
2018-06-04 02:35:27 -07:00
|
|
|
ld [wChannel5Flags1], a
|
2019-09-02 01:40:58 -07:00
|
|
|
ld [wPitchSweep], a
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [rNR10], a
|
|
|
|
ldh [rNR11], a
|
|
|
|
ldh [rNR12], a
|
|
|
|
ldh [rNR13], a
|
|
|
|
ldh [rNR14], a
|
2014-05-21 13:26:28 -07:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
ChannelsOff::
|
2014-05-21 13:26:28 -07:00
|
|
|
; Quickly turn off music channels
|
|
|
|
xor a
|
2018-06-04 02:35:27 -07:00
|
|
|
ld [wChannel1Flags1], a
|
|
|
|
ld [wChannel2Flags1], a
|
|
|
|
ld [wChannel3Flags1], a
|
|
|
|
ld [wChannel4Flags1], a
|
2019-09-02 01:40:58 -07:00
|
|
|
ld [wPitchSweep], a
|
2014-05-21 13:26:28 -07:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
SFXChannelsOff::
|
2014-05-21 13:26:28 -07:00
|
|
|
; Quickly turn off sound effect channels
|
|
|
|
xor a
|
2018-06-04 02:35:27 -07:00
|
|
|
ld [wChannel5Flags1], a
|
|
|
|
ld [wChannel6Flags1], a
|
|
|
|
ld [wChannel7Flags1], a
|
|
|
|
ld [wChannel8Flags1], a
|
2019-09-02 01:40:58 -07:00
|
|
|
ld [wPitchSweep], a
|
2014-05-21 13:26:28 -07:00
|
|
|
ret
|