mirror of
https://github.com/thornAvery/kep-hack.git
synced 2025-09-17 02:40:50 +12:00
Update home/audio.asm from pokecrystal
This commit is contained in:
parent
c52ab8fb90
commit
e538d12236
|
@ -2385,9 +2385,6 @@ SetLRTracks:
|
||||||
|
|
||||||
_PlayMusic::
|
_PlayMusic::
|
||||||
call OpenSRAMForSound
|
call OpenSRAMForSound
|
||||||
ld a, e
|
|
||||||
and a
|
|
||||||
jp z, _MapSetup_Sound_Off
|
|
||||||
cp NUM_SONGS
|
cp NUM_SONGS
|
||||||
ret nc ; sfx
|
ret nc ; sfx
|
||||||
; load music
|
; load music
|
||||||
|
|
|
@ -3051,6 +3051,3 @@ PlayApplyingAttackSound:
|
||||||
ld [wTempoModifier], a
|
ld [wTempoModifier], a
|
||||||
ld a, c
|
ld a, c
|
||||||
jp PlaySound
|
jp PlaySound
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -830,7 +830,7 @@ TradeCenter_Trade:
|
||||||
ld [wAudioSavedROMBank], a
|
ld [wAudioSavedROMBank], a
|
||||||
ld a, MUSIC_SAFARI_ZONE
|
ld a, MUSIC_SAFARI_ZONE
|
||||||
ld [wNewSoundID], a
|
ld [wNewSoundID], a
|
||||||
call PlaySound
|
call PlayMusic
|
||||||
ld c, 100
|
ld c, 100
|
||||||
call DelayFrames
|
call DelayFrames
|
||||||
call ClearScreen
|
call ClearScreen
|
||||||
|
@ -921,7 +921,7 @@ CableClub_Run:
|
||||||
ld [wAudioSavedROMBank], a
|
ld [wAudioSavedROMBank], a
|
||||||
ld a, MUSIC_CELADON
|
ld a, MUSIC_CELADON
|
||||||
ld [wNewSoundID], a
|
ld [wNewSoundID], a
|
||||||
jp PlaySound
|
jp PlayMusic
|
||||||
|
|
||||||
EmptyFunc3:
|
EmptyFunc3:
|
||||||
ret
|
ret
|
||||||
|
|
69
home.asm
69
home.asm
|
@ -3193,75 +3193,6 @@ DelayFrames::
|
||||||
jr nz, DelayFrames
|
jr nz, DelayFrames
|
||||||
ret
|
ret
|
||||||
|
|
||||||
PlaySoundWaitForCurrent::
|
|
||||||
push af
|
|
||||||
call WaitForSoundToFinish
|
|
||||||
pop af
|
|
||||||
jp PlaySound
|
|
||||||
|
|
||||||
; Wait for sound to finish playing
|
|
||||||
WaitForSoundToFinish::
|
|
||||||
WaitSFX::
|
|
||||||
; infinite loop until sfx is done playing
|
|
||||||
ld a, [wDanger]
|
|
||||||
and a
|
|
||||||
ret nz
|
|
||||||
ld a, [wSFXDontWait]
|
|
||||||
and a
|
|
||||||
ret nz
|
|
||||||
push hl
|
|
||||||
|
|
||||||
.loop
|
|
||||||
; ch5 on?
|
|
||||||
ld hl, wChannel5 + wChannel1Flags1 - wChannel1 ; + CHANNEL_FLAGS1
|
|
||||||
bit 0, [hl]
|
|
||||||
jr nz, .loop
|
|
||||||
; ch6 on?
|
|
||||||
ld hl, wChannel6 + wChannel1Flags1 - wChannel1 ; + CHANNEL_FLAGS1
|
|
||||||
bit 0, [hl]
|
|
||||||
jr nz, .loop
|
|
||||||
; ch7 on?
|
|
||||||
ld hl, wChannel7 + wChannel1Flags1 - wChannel1 ; + CHANNEL_FLAGS1
|
|
||||||
bit 0, [hl]
|
|
||||||
jr nz, .loop
|
|
||||||
; ch8 on?
|
|
||||||
ld hl, wChannel8 + wChannel1Flags1 - wChannel1 ; + CHANNEL_FLAGS1
|
|
||||||
bit 0, [hl]
|
|
||||||
jr nz, .loop
|
|
||||||
|
|
||||||
pop hl
|
|
||||||
ret
|
|
||||||
|
|
||||||
WaitForSongToFinish::
|
|
||||||
.loop
|
|
||||||
call IsSongPlaying
|
|
||||||
jr c, .loop
|
|
||||||
ret
|
|
||||||
|
|
||||||
IsSongPlaying::
|
|
||||||
; ch1 on?
|
|
||||||
ld hl, wChannel1 + wChannel1Flags1 - wChannel1 ; + CHANNEL_FLAGS1
|
|
||||||
bit 0, [hl]
|
|
||||||
jr nz, .playing
|
|
||||||
; ch2 on?
|
|
||||||
ld hl, wChannel2 + wChannel1Flags1 - wChannel1 ; + CHANNEL_FLAGS1
|
|
||||||
bit 0, [hl]
|
|
||||||
jr nz, .playing
|
|
||||||
; ch3 on?
|
|
||||||
ld hl, wChannel3 + wChannel1Flags1 - wChannel1 ; + CHANNEL_FLAGS1
|
|
||||||
bit 0, [hl]
|
|
||||||
jr nz, .playing
|
|
||||||
; ch4 on?
|
|
||||||
ld hl, wChannel4 + wChannel1Flags1 - wChannel1 ; + CHANNEL_FLAGS1
|
|
||||||
bit 0, [hl]
|
|
||||||
jr z, .notPlaying
|
|
||||||
.playing
|
|
||||||
scf
|
|
||||||
ret
|
|
||||||
.notPlaying
|
|
||||||
xor a
|
|
||||||
ret
|
|
||||||
|
|
||||||
NamePointers::
|
NamePointers::
|
||||||
dw MonsterNames
|
dw MonsterNames
|
||||||
dw MoveNames
|
dw MoveNames
|
||||||
|
|
244
home/audio.asm
244
home/audio.asm
|
@ -50,7 +50,7 @@ PlayDefaultMusicCommon::
|
||||||
.walking
|
.walking
|
||||||
ld a, [wMapMusicSoundID]
|
ld a, [wMapMusicSoundID]
|
||||||
ld b, a
|
ld b, a
|
||||||
call CompareMapMusicBankWithCurrentBank
|
; call CompareMapMusicBankWithCurrentBank
|
||||||
jr c, .next4
|
jr c, .next4
|
||||||
|
|
||||||
.next3
|
.next3
|
||||||
|
@ -71,20 +71,17 @@ PlayDefaultMusicCommon::
|
||||||
;call FadeMusic ; called in updatemusic
|
;call FadeMusic ; called in updatemusic
|
||||||
ret
|
ret
|
||||||
|
|
||||||
UpdateMusic6Times::
|
;UpdateMusic6Times::
|
||||||
;jp UpdateSound
|
;CompareMapMusicBankWithCurrentBank:
|
||||||
;ret ; XXX UpdateMusic
|
; ret
|
||||||
|
|
||||||
CompareMapMusicBankWithCurrentBank:
|
; plays music or SFX specified by a. If value is $ff, music is stopped
|
||||||
ret
|
|
||||||
|
|
||||||
; plays <s>music</s>SFX specified by a. If value is $ff, music is stopped
|
|
||||||
PlaySound::
|
PlaySound::
|
||||||
push de
|
push de
|
||||||
cp $ff
|
cp $ff
|
||||||
jr nz, .notff
|
jr nz, .notff
|
||||||
xor a
|
xor a
|
||||||
call PlayMusic
|
call PlayMusic
|
||||||
pop de
|
pop de
|
||||||
ret
|
ret
|
||||||
.notff
|
.notff
|
||||||
|
@ -103,7 +100,7 @@ OpenSRAMForSound::
|
||||||
ld [MBC1SRamBank], a
|
ld [MBC1SRamBank], a
|
||||||
ret
|
ret
|
||||||
|
|
||||||
;SoundRestart::
|
;MapSetup_Sound_Off::
|
||||||
; push hl
|
; push hl
|
||||||
; push de
|
; push de
|
||||||
; push bc
|
; push bc
|
||||||
|
@ -111,16 +108,16 @@ OpenSRAMForSound::
|
||||||
;
|
;
|
||||||
; call OpenSRAMForSound
|
; call OpenSRAMForSound
|
||||||
;
|
;
|
||||||
; ld a, [hROMBank]
|
; ldh a, [hROMBank]
|
||||||
; push af
|
; push af
|
||||||
; ld a, BANK(_SoundRestart)
|
; ld a, BANK(_MapSetup_Sound_Off)
|
||||||
; ld [hROMBank], a
|
; ldh [hROMBank], a
|
||||||
; ld [MBC1RomBank], a
|
; ld [MBC1RomBank], a
|
||||||
;
|
;
|
||||||
; call _SoundRestart
|
; call _MapSetup_Sound_Off
|
||||||
;
|
;
|
||||||
; pop af
|
; pop af
|
||||||
; ld [hROMBank], a
|
; ldh [hROMBank], a
|
||||||
; ld [MBC1RomBank], a
|
; ld [MBC1RomBank], a
|
||||||
;
|
;
|
||||||
; pop af
|
; pop af
|
||||||
|
@ -129,26 +126,26 @@ OpenSRAMForSound::
|
||||||
; pop hl
|
; pop hl
|
||||||
; ret
|
; ret
|
||||||
|
|
||||||
|
|
||||||
UpdateSound::
|
UpdateSound::
|
||||||
; push hl
|
; push hl
|
||||||
; push de
|
; push de
|
||||||
; push bc
|
; push bc
|
||||||
; push af
|
; push af
|
||||||
|
|
||||||
ld a, [wHaltAudio]
|
ld a, [wHaltAudio]
|
||||||
and a
|
and a
|
||||||
ret nz
|
ret nz
|
||||||
|
|
||||||
ld a, [hROMBank]
|
ldh a, [hROMBank]
|
||||||
push af
|
push af
|
||||||
ld a, BANK(_UpdateSound)
|
ld a, BANK(_UpdateSound)
|
||||||
ld [hROMBank], a
|
ldh [hROMBank], a
|
||||||
ld [MBC1RomBank], a
|
ld [MBC1RomBank], a
|
||||||
|
|
||||||
call _UpdateSound
|
call _UpdateSound
|
||||||
|
|
||||||
pop af
|
pop af
|
||||||
ld [hROMBank], a
|
ldh [hROMBank], a
|
||||||
ld [MBC1RomBank], a
|
ld [MBC1RomBank], a
|
||||||
|
|
||||||
; pop af
|
; pop af
|
||||||
|
@ -157,6 +154,19 @@ UpdateSound::
|
||||||
; pop hl
|
; pop hl
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
_LoadMusicByte::
|
||||||
|
; wCurMusicByte = [a:de]
|
||||||
|
ldh [hROMBank], a
|
||||||
|
ld [MBC1RomBank], a
|
||||||
|
|
||||||
|
ld a, [de]
|
||||||
|
ld [wCurMusicByte], a
|
||||||
|
ld a, BANK(LoadMusicByte)
|
||||||
|
|
||||||
|
ldh [hROMBank], a
|
||||||
|
ld [MBC1RomBank], a
|
||||||
|
ret
|
||||||
|
|
||||||
PlayMusic::
|
PlayMusic::
|
||||||
ld e, a
|
ld e, a
|
||||||
xor a
|
xor a
|
||||||
|
@ -168,28 +178,74 @@ PlayMusic::
|
||||||
push bc
|
push bc
|
||||||
push af
|
push af
|
||||||
|
|
||||||
ld a, [hROMBank]
|
ldh a, [hROMBank]
|
||||||
push af
|
push af
|
||||||
ld a, BANK(_PlayMusic) ; and BANK(_SoundRestart)
|
ld a, BANK(_PlayMusic) ; aka BANK(_MapSetup_Sound_Off)
|
||||||
ld [hROMBank], a
|
ldh [hROMBank], a
|
||||||
ld [MBC1RomBank], a
|
ld [MBC1RomBank], a
|
||||||
|
|
||||||
|
ld a, e
|
||||||
|
and a
|
||||||
|
jr z, .nomusic
|
||||||
|
|
||||||
call _PlayMusic
|
call _PlayMusic
|
||||||
|
jr .end
|
||||||
|
|
||||||
|
.nomusic
|
||||||
|
call _MapSetup_Sound_Off
|
||||||
|
|
||||||
|
.end
|
||||||
pop af
|
pop af
|
||||||
ld [hROMBank], a
|
ldh [hROMBank], a
|
||||||
ld [MBC1RomBank], a
|
ld [MBC1RomBank], a
|
||||||
jr PopAllRet
|
pop af
|
||||||
|
pop bc
|
||||||
|
pop de
|
||||||
|
pop hl
|
||||||
|
ret
|
||||||
|
|
||||||
|
;PlayMusic2::
|
||||||
|
; ld e, a
|
||||||
|
; xor a
|
||||||
|
; ld d, a
|
||||||
|
; Stop playing music, then play music de.
|
||||||
|
;
|
||||||
|
; push hl
|
||||||
|
; push de
|
||||||
|
; push bc
|
||||||
|
; push af
|
||||||
|
;
|
||||||
|
; ldh a, [hROMBank]
|
||||||
|
; push af
|
||||||
|
; ld a, BANK(_PlayMusic)
|
||||||
|
; ldh [hROMBank], a
|
||||||
|
; ld [MBC1RomBank], a
|
||||||
|
;
|
||||||
|
; push de
|
||||||
|
; ld de, MUSIC_NONE
|
||||||
|
; call _PlayMusic
|
||||||
|
; call DelayFrame
|
||||||
|
; pop de
|
||||||
|
; call _PlayMusic
|
||||||
|
;
|
||||||
|
; pop af
|
||||||
|
; ldh [hROMBank], a
|
||||||
|
; ld [MBC1RomBank], a
|
||||||
|
;
|
||||||
|
; pop af
|
||||||
|
; pop bc
|
||||||
|
; pop de
|
||||||
|
; pop hl
|
||||||
|
; ret
|
||||||
|
|
||||||
PlayCry::
|
PlayCry::
|
||||||
; Play monster a's cry.
|
; Play monster a's cry.
|
||||||
; Play a cry given parameters in header de
|
|
||||||
|
|
||||||
push hl
|
push hl
|
||||||
push de
|
push de
|
||||||
push bc
|
push bc
|
||||||
push af
|
push af
|
||||||
|
|
||||||
ld [wd11e], a
|
ld [wd11e], a
|
||||||
predef IndexToPokedex
|
predef IndexToPokedex
|
||||||
ld a, [wd11e]
|
ld a, [wd11e]
|
||||||
|
@ -197,23 +253,18 @@ PlayCry::
|
||||||
ld e, a
|
ld e, a
|
||||||
ld d, 0
|
ld d, 0
|
||||||
|
|
||||||
; Save current bank
|
ldh a, [hROMBank]
|
||||||
ld a, [hROMBank]
|
|
||||||
push af
|
push af
|
||||||
|
|
||||||
; Cry headers are stuck in one bank.
|
; Cries are stuck in one bank.
|
||||||
ld a, BANK(PokemonCries)
|
ld a, BANK(PokemonCries)
|
||||||
ld [hROMBank], a
|
ldh [hROMBank], a
|
||||||
ld [$2000], a
|
ld [MBC1RomBank], a
|
||||||
|
|
||||||
; Each header is 6 bytes long:
|
|
||||||
ld hl, PokemonCries
|
ld hl, PokemonCries
|
||||||
|
rept 6 ; sizeof(mon_cry)
|
||||||
add hl, de
|
add hl, de
|
||||||
add hl, de
|
endr
|
||||||
add hl, de
|
|
||||||
add hl, de
|
|
||||||
add hl, de
|
|
||||||
add hl, de
|
|
||||||
|
|
||||||
ld e, [hl]
|
ld e, [hl]
|
||||||
inc hl
|
inc hl
|
||||||
|
@ -223,25 +274,29 @@ PlayCry::
|
||||||
ld a, [hli]
|
ld a, [hli]
|
||||||
ld [wCryPitch], a
|
ld [wCryPitch], a
|
||||||
ld a, [hli]
|
ld a, [hli]
|
||||||
ld [wCryPitch+1], a
|
ld [wCryPitch + 1], a
|
||||||
ld a, [hli]
|
ld a, [hli]
|
||||||
ld [wCryLength], a
|
ld [wCryLength], a
|
||||||
ld a, [hl]
|
ld a, [hl]
|
||||||
ld [wCryLength+1], a
|
ld [wCryLength + 1], a
|
||||||
|
|
||||||
ld a, BANK(_PlayCry)
|
ld a, BANK(_PlayCry)
|
||||||
ld [hROMBank], a
|
ldh [hROMBank], a
|
||||||
ld [$2000], a
|
ld [MBC1RomBank], a
|
||||||
|
|
||||||
call _PlayCry
|
call _PlayCry
|
||||||
|
|
||||||
pop af
|
pop af
|
||||||
ld [hROMBank], a
|
ldh [hROMBank], a
|
||||||
ld [$2000], a
|
ld [MBC1RomBank], a
|
||||||
|
|
||||||
call WaitForSoundToFinish
|
call WaitForSoundToFinish
|
||||||
|
|
||||||
jr PopAllRet
|
pop af
|
||||||
|
pop bc
|
||||||
|
pop de
|
||||||
|
pop hl
|
||||||
|
ret
|
||||||
|
|
||||||
PlaySFX::
|
PlaySFX::
|
||||||
; Play sound effect de.
|
; Play sound effect de.
|
||||||
|
@ -252,48 +307,97 @@ PlaySFX::
|
||||||
push bc
|
push bc
|
||||||
push af
|
push af
|
||||||
|
|
||||||
; Is something already playing?
|
; Is something already playing?
|
||||||
;call CheckSFX
|
; call CheckSFX
|
||||||
;jr nc, .play
|
; jr nc, .play
|
||||||
; Does it have priority?
|
|
||||||
;ld a, [wCurSFX]
|
; Does it have priority?
|
||||||
;cp e
|
; ld a, [wCurSFX]
|
||||||
;jr c, .quit
|
; cp e
|
||||||
|
; jr c, .done
|
||||||
|
|
||||||
PlaySFX_play
|
|
||||||
.play
|
.play
|
||||||
ld a, [hROMBank]
|
ldh a, [hROMBank]
|
||||||
push af
|
push af
|
||||||
ld a, BANK(_PlaySFX)
|
ld a, BANK(_PlaySFX)
|
||||||
ld [hROMBank], a
|
ldh [hROMBank], a
|
||||||
ld [$2000], a ; bankswitch
|
ld [MBC1RomBank], a
|
||||||
|
|
||||||
ld a, e
|
ld a, e
|
||||||
ld [wCurSFX], a
|
ld [wCurSFX], a
|
||||||
call _PlaySFX
|
call _PlaySFX
|
||||||
|
|
||||||
pop af
|
pop af
|
||||||
ld [hROMBank], a
|
ldh [hROMBank], a
|
||||||
ld [$2000], a ; bankswitch
|
ld [MBC1RomBank], a
|
||||||
.quit
|
|
||||||
PopAllRet:
|
.done
|
||||||
pop af
|
pop af
|
||||||
pop bc
|
pop bc
|
||||||
pop de
|
pop de
|
||||||
pop hl
|
pop hl
|
||||||
ret
|
ret
|
||||||
|
|
||||||
_LoadMusicByte::
|
PlaySoundWaitForCurrent::
|
||||||
; CurMusicByte = [a:de]
|
WaitPlaySFX::
|
||||||
GLOBAL LoadMusicByte
|
push af
|
||||||
|
call WaitForSoundToFinish
|
||||||
|
pop af
|
||||||
|
jp PlaySound
|
||||||
|
|
||||||
ld [hROMBank], a
|
; Wait for sound to finish playing
|
||||||
ld [MBC1RomBank], a
|
WaitForSoundToFinish::
|
||||||
|
WaitSFX::
|
||||||
|
ld a, [wDanger]
|
||||||
|
and a
|
||||||
|
ret nz
|
||||||
|
ld a, [wSFXDontWait]
|
||||||
|
and a
|
||||||
|
ret nz
|
||||||
|
|
||||||
ld a, [de]
|
; infinite loop until sfx is done playing
|
||||||
ld [wCurMusicByte], a
|
|
||||||
ld a, BANK(LoadMusicByte)
|
|
||||||
|
|
||||||
ld [hROMBank], a
|
push hl
|
||||||
ld [MBC1RomBank], a
|
|
||||||
|
.wait
|
||||||
|
ld hl, wChannel5Flags1
|
||||||
|
bit 0, [hl]
|
||||||
|
jr nz, .wait
|
||||||
|
ld hl, wChannel6Flags1
|
||||||
|
bit 0, [hl]
|
||||||
|
jr nz, .wait
|
||||||
|
ld hl, wChannel7Flags1
|
||||||
|
bit 0, [hl]
|
||||||
|
jr nz, .wait
|
||||||
|
ld hl, wChannel8Flags1
|
||||||
|
bit 0, [hl]
|
||||||
|
jr nz, .wait
|
||||||
|
|
||||||
|
pop hl
|
||||||
|
ret
|
||||||
|
|
||||||
|
WaitForSongToFinish::
|
||||||
|
.loop
|
||||||
|
call IsSongPlaying
|
||||||
|
jr c, .loop
|
||||||
|
ret
|
||||||
|
|
||||||
|
IsSongPlaying::
|
||||||
|
; Return carry if any song channels are active.
|
||||||
|
ld a, [wChannel1Flags1]
|
||||||
|
bit 0, a
|
||||||
|
jr nz, .playing
|
||||||
|
ld a, [wChannel2Flags1]
|
||||||
|
bit 0, a
|
||||||
|
jr nz, .playing
|
||||||
|
ld a, [wChannel3Flags1]
|
||||||
|
bit 0, a
|
||||||
|
jr nz, .playing
|
||||||
|
ld a, [wChannel4Flags1]
|
||||||
|
bit 0, a
|
||||||
|
jr nz, .playing
|
||||||
|
and a
|
||||||
|
ret
|
||||||
|
.playing
|
||||||
|
scf
|
||||||
ret
|
ret
|
||||||
|
|
|
@ -2398,7 +2398,7 @@ LoadMapData::
|
||||||
ld a, [wFlags_D733]
|
ld a, [wFlags_D733]
|
||||||
bit 1, a
|
bit 1, a
|
||||||
jr nz, .restoreRomBank
|
jr nz, .restoreRomBank
|
||||||
call UpdateMusic6Times
|
; call UpdateMusic6Times
|
||||||
call PlayDefaultMusicFadeOutCurrent
|
call PlayDefaultMusicFadeOutCurrent
|
||||||
.restoreRomBank
|
.restoreRomBank
|
||||||
pop af
|
pop af
|
||||||
|
|
Loading…
Reference in a new issue