mirror of
https://github.com/thornAvery/kep-hack.git
synced 2025-12-06 19:31:01 +13:00
Fix battle sound pitch/tempo modifiers
This commit is contained in:
parent
b2afaae7ab
commit
17044ab7eb
|
|
@ -216,8 +216,4 @@ const_value = 1
|
||||||
|
|
||||||
const SFX_POKEFLUTE_IN_BATTLE
|
const SFX_POKEFLUTE_IN_BATTLE
|
||||||
|
|
||||||
const GSSFX_NOT_VERY_EFFECTIVE
|
|
||||||
const GSSFX_DAMAGE
|
|
||||||
const GSSFX_SUPER_EFFECTIVE
|
|
||||||
|
|
||||||
SFX_STOP_ALL_MUSIC EQU $ff
|
SFX_STOP_ALL_MUSIC EQU $ff
|
||||||
|
|
|
||||||
|
|
@ -2605,6 +2605,131 @@ _PlayCry::
|
||||||
call MusicOn
|
call MusicOn
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
_PlayBattleSound::
|
||||||
|
; clear channels if they aren't already
|
||||||
|
call MusicOff
|
||||||
|
ld hl, wChannel5Flags1
|
||||||
|
bit SOUND_CHANNEL_ON, [hl] ; ch5 on?
|
||||||
|
jr z, .ch6
|
||||||
|
res SOUND_CHANNEL_ON, [hl] ; turn it off
|
||||||
|
xor a
|
||||||
|
ldh [rNR11], a ; length/wavepattern = 0
|
||||||
|
ld a, $8
|
||||||
|
ldh [rNR12], a ; envelope = 0
|
||||||
|
xor a
|
||||||
|
ldh [rNR13], a ; frequency lo = 0
|
||||||
|
ld a, $80
|
||||||
|
ldh [rNR14], a ; restart sound (freq hi = 0)
|
||||||
|
xor a
|
||||||
|
ld [wPitchSweep], a ; pitch sweep off
|
||||||
|
ldh [rNR10], a ; pitch sweep off
|
||||||
|
.ch6
|
||||||
|
ld hl, wChannel6Flags1
|
||||||
|
bit SOUND_CHANNEL_ON, [hl]
|
||||||
|
jr z, .ch7
|
||||||
|
res SOUND_CHANNEL_ON, [hl] ; turn it off
|
||||||
|
xor a
|
||||||
|
ldh [rNR21], a ; length/wavepattern = 0
|
||||||
|
ld a, $8
|
||||||
|
ldh [rNR22], a ; envelope = 0
|
||||||
|
xor a
|
||||||
|
ldh [rNR23], a ; frequency lo = 0
|
||||||
|
ld a, $80
|
||||||
|
ldh [rNR24], a ; restart sound (freq hi = 0)
|
||||||
|
.ch7
|
||||||
|
ld hl, wChannel7Flags1
|
||||||
|
bit SOUND_CHANNEL_ON, [hl]
|
||||||
|
jr z, .ch8
|
||||||
|
res SOUND_CHANNEL_ON, [hl] ; turn it off
|
||||||
|
xor a
|
||||||
|
ldh [rNR30], a ; sound mode #3 off
|
||||||
|
ldh [rNR31], a ; length/wavepattern = 0
|
||||||
|
ld a, $8
|
||||||
|
ldh [rNR32], a ; envelope = 0
|
||||||
|
xor a
|
||||||
|
ldh [rNR33], a ; frequency lo = 0
|
||||||
|
ld a, $80
|
||||||
|
ldh [rNR34], a ; restart sound (freq hi = 0)
|
||||||
|
.ch8
|
||||||
|
ld hl, wChannel8Flags1
|
||||||
|
bit SOUND_CHANNEL_ON, [hl]
|
||||||
|
jr z, .chscleared
|
||||||
|
res SOUND_CHANNEL_ON, [hl] ; turn it off
|
||||||
|
xor a
|
||||||
|
ldh [rNR41], a ; length/wavepattern = 0
|
||||||
|
ld a, $8
|
||||||
|
ldh [rNR42], a ; envelope = 0
|
||||||
|
xor a
|
||||||
|
ldh [rNR43], a ; frequency lo = 0
|
||||||
|
ld a, $80
|
||||||
|
ldh [rNR44], a ; restart sound (freq hi = 0)
|
||||||
|
xor a
|
||||||
|
ld [wNoiseSampleAddress], a
|
||||||
|
ld [wNoiseSampleAddress + 1], a
|
||||||
|
.chscleared
|
||||||
|
; start reading sfx header for # chs
|
||||||
|
ld hl, wMusicID
|
||||||
|
ld [hl], e
|
||||||
|
inc hl
|
||||||
|
ld [hl], d
|
||||||
|
ld hl, SFX
|
||||||
|
add hl, de ; three
|
||||||
|
add hl, de ; byte
|
||||||
|
add hl, de ; pointers
|
||||||
|
; get bank
|
||||||
|
ld a, [hli]
|
||||||
|
ld [wMusicBank], a
|
||||||
|
; get address
|
||||||
|
ld e, [hl]
|
||||||
|
inc hl
|
||||||
|
ld d, [hl]
|
||||||
|
; get # channels
|
||||||
|
call LoadMusicByte
|
||||||
|
rlca ; top 2
|
||||||
|
rlca ; bits
|
||||||
|
maskbits NUM_MUSIC_CHANS
|
||||||
|
inc a ; # channels -> # loops
|
||||||
|
.startchannels
|
||||||
|
push af
|
||||||
|
call LoadChannel ; bc = current channel
|
||||||
|
ld hl, CHANNEL_FLAGS1
|
||||||
|
add hl, bc
|
||||||
|
set SOUND_SFX, [hl]
|
||||||
|
|
||||||
|
ld hl, CHANNEL_FLAGS2
|
||||||
|
add hl, bc
|
||||||
|
set SOUND_PITCH_OFFSET, [hl]
|
||||||
|
|
||||||
|
ld hl, CHANNEL_PITCH_OFFSET
|
||||||
|
add hl, bc
|
||||||
|
ld a, [wCryPitch]
|
||||||
|
ld [hli], a
|
||||||
|
ld a, [wCryPitch + 1]
|
||||||
|
ld [hl], a
|
||||||
|
|
||||||
|
; No tempo for channel 4
|
||||||
|
ld a, [wCurChannel]
|
||||||
|
maskbits NUM_MUSIC_CHANS
|
||||||
|
cp CHAN4
|
||||||
|
jr nc, .start
|
||||||
|
|
||||||
|
; Tempo is effectively length
|
||||||
|
ld hl, CHANNEL_TEMPO
|
||||||
|
add hl, bc
|
||||||
|
ld a, [wCryLength]
|
||||||
|
ld [hli], a
|
||||||
|
ld a, [wCryLength + 1]
|
||||||
|
ld [hl], a
|
||||||
|
.start
|
||||||
|
call StartChannel
|
||||||
|
pop af
|
||||||
|
dec a
|
||||||
|
jr nz, .startchannels
|
||||||
|
call MusicOn
|
||||||
|
xor a
|
||||||
|
ld [wSFXPriority], a
|
||||||
|
ret
|
||||||
|
|
||||||
_PlaySFX::
|
_PlaySFX::
|
||||||
; clear channels if they aren't already
|
; clear channels if they aren't already
|
||||||
call MusicOff
|
call MusicOff
|
||||||
|
|
|
||||||
|
|
@ -113,8 +113,3 @@ SFX:
|
||||||
dba SFX_Shooting_Star
|
dba SFX_Shooting_Star
|
||||||
|
|
||||||
dba SFX_PokefluteInBattle
|
dba SFX_PokefluteInBattle
|
||||||
|
|
||||||
dba Sfx_NotVeryEffective
|
|
||||||
dba Sfx_Damage
|
|
||||||
dba Sfx_SuperEffective
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -200,7 +200,7 @@ PlayAnimation:
|
||||||
push hl
|
push hl
|
||||||
push de
|
push de
|
||||||
call GetMoveSound
|
call GetMoveSound
|
||||||
call nc, AnimPlaySFX
|
call nc, PlayBattleSound
|
||||||
pop de
|
pop de
|
||||||
pop hl
|
pop hl
|
||||||
.skipPlayingSound
|
.skipPlayingSound
|
||||||
|
|
@ -256,15 +256,6 @@ PlayAnimation:
|
||||||
.AnimationOver
|
.AnimationOver
|
||||||
ret
|
ret
|
||||||
|
|
||||||
AnimPlaySFX:
|
|
||||||
push de
|
|
||||||
ld e, a
|
|
||||||
xor a
|
|
||||||
ld d, a
|
|
||||||
call PlaySFX
|
|
||||||
pop de
|
|
||||||
ret
|
|
||||||
|
|
||||||
LoadSubanimation:
|
LoadSubanimation:
|
||||||
ld a, [wSubAnimAddrPtr + 1]
|
ld a, [wSubAnimAddrPtr + 1]
|
||||||
ld h, a
|
ld h, a
|
||||||
|
|
@ -560,7 +551,7 @@ PlaySubanimation:
|
||||||
cp NO_MOVE - 1
|
cp NO_MOVE - 1
|
||||||
jr z, .skipPlayingSound
|
jr z, .skipPlayingSound
|
||||||
call GetMoveSound
|
call GetMoveSound
|
||||||
call nc, AnimPlaySFX
|
call nc, PlayBattleSound
|
||||||
.skipPlayingSound
|
.skipPlayingSound
|
||||||
ld hl, wOAMBuffer ; base address of OAM buffer
|
ld hl, wOAMBuffer ; base address of OAM buffer
|
||||||
ld a, l
|
ld a, l
|
||||||
|
|
@ -2208,13 +2199,19 @@ GetMoveSound:
|
||||||
; jr .done
|
; jr .done
|
||||||
|
|
||||||
.NotCryMove
|
.NotCryMove
|
||||||
; todo: fix sound modifiers
|
push bc
|
||||||
ld a, [hli]
|
ld a, [hli]
|
||||||
; ld [wFrequencyModifier], a
|
ld c, a
|
||||||
|
ld b, 0
|
||||||
ld a, [hli]
|
ld a, [hli]
|
||||||
; ld [wTempoModifier], a
|
add $80
|
||||||
|
ld e, a
|
||||||
|
ld a, 0
|
||||||
|
adc 0
|
||||||
|
ld d, a
|
||||||
|
pop af
|
||||||
.done
|
.done
|
||||||
ld a, b
|
and a
|
||||||
ret
|
ret
|
||||||
|
|
||||||
IsCryMove:
|
IsCryMove:
|
||||||
|
|
@ -2625,21 +2622,20 @@ PlayApplyingAttackSound:
|
||||||
and $7f
|
and $7f
|
||||||
ret z
|
ret z
|
||||||
cp 10
|
cp 10
|
||||||
ld a, $20
|
ld bc, $20
|
||||||
ld b, $30
|
ld de, $30 + $80
|
||||||
ld c, GSSFX_DAMAGE ; SFX_DAMAGE
|
ld a, SFX_DAMAGE
|
||||||
jr z, .playSound
|
jr z, .playSound
|
||||||
ld a, $e0
|
ld bc, $e0
|
||||||
ld b, $ff
|
ld de, $ff + $80
|
||||||
ld c, GSSFX_SUPER_EFFECTIVE ; SFX_SUPER_EFFECTIVE
|
ld a, SFX_SUPER_EFFECTIVE
|
||||||
jr nc, .playSound
|
jr nc, .playSound
|
||||||
ld a, $50
|
ld bc, $50
|
||||||
ld b, $1
|
ld de, $1 + $80
|
||||||
ld c, GSSFX_NOT_VERY_EFFECTIVE ; SFX_NOT_VERY_EFFECTIVE
|
ld a, SFX_NOT_VERY_EFFECTIVE
|
||||||
.playSound
|
.playSound
|
||||||
; todo: fix sound modifiers
|
|
||||||
; ld [wFrequencyModifier], a
|
; ld [wFrequencyModifier], a
|
||||||
ld a, b
|
; ld a, b
|
||||||
; ld [wTempoModifier], a
|
; ld [wTempoModifier], a
|
||||||
ld a, c
|
; ld a, c
|
||||||
jp PlaySound
|
jp PlayBattleSound
|
||||||
|
|
|
||||||
|
|
@ -776,16 +776,19 @@ FaintEnemyPokemon:
|
||||||
ld a, [wIsInBattle]
|
ld a, [wIsInBattle]
|
||||||
dec a
|
dec a
|
||||||
jr z, .wild_win
|
jr z, .wild_win
|
||||||
|
|
||||||
|
call WaitForSoundToFinish
|
||||||
|
ld bc, $00
|
||||||
|
ld de, $80
|
||||||
|
ld a, SFX_FAINT_FALL
|
||||||
|
call PlayBattleSound
|
||||||
; xor a
|
; xor a
|
||||||
; ld [wFrequencyModifier], a
|
; ld [wFrequencyModifier], a
|
||||||
; ld [wTempoModifier], a
|
; ld [wTempoModifier], a
|
||||||
ld a, SFX_FAINT_FALL
|
; ld a, SFX_FAINT_FALL
|
||||||
call PlaySoundWaitForCurrent
|
; call PlaySoundWaitForCurrent
|
||||||
|
|
||||||
; using WaitForSoundToFinish causes a noticeable delay
|
call WaitForSoundToFinish
|
||||||
; so use a smaller hard-coded delay for now
|
|
||||||
ld c, 10
|
|
||||||
call DelayFrames
|
|
||||||
;.sfxwait
|
;.sfxwait
|
||||||
; ld a, [wChannelSoundIDs + Ch5]
|
; ld a, [wChannelSoundIDs + Ch5]
|
||||||
; cp SFX_FAINT_FALL
|
; cp SFX_FAINT_FALL
|
||||||
|
|
|
||||||
|
|
@ -288,6 +288,48 @@ endr
|
||||||
pop hl
|
pop hl
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
PlayBattleSound::
|
||||||
|
push hl
|
||||||
|
push de
|
||||||
|
push bc
|
||||||
|
push af
|
||||||
|
|
||||||
|
push af
|
||||||
|
ld a, c
|
||||||
|
ld [wCryPitch], a
|
||||||
|
ld a, b
|
||||||
|
ld [wCryPitch + 1], a
|
||||||
|
ld a, e
|
||||||
|
ld [wCryLength], a
|
||||||
|
ld a, d
|
||||||
|
ld [wCryLength + 1], a
|
||||||
|
pop af
|
||||||
|
|
||||||
|
ld e, a
|
||||||
|
xor a
|
||||||
|
ld d, a
|
||||||
|
|
||||||
|
ldh a, [hLoadedROMBank]
|
||||||
|
push af
|
||||||
|
|
||||||
|
ld a, BANK(_PlayBattleSound)
|
||||||
|
ldh [hLoadedROMBank], a
|
||||||
|
ld [MBC1RomBank], a
|
||||||
|
|
||||||
|
ld a, e
|
||||||
|
ld [wCurSFX], a
|
||||||
|
call _PlayBattleSound
|
||||||
|
|
||||||
|
pop af
|
||||||
|
ldh [hLoadedROMBank], a
|
||||||
|
ld [MBC1RomBank], a
|
||||||
|
|
||||||
|
pop af
|
||||||
|
pop bc
|
||||||
|
pop de
|
||||||
|
pop hl
|
||||||
|
ret
|
||||||
|
|
||||||
PlaySFX::
|
PlaySFX::
|
||||||
; Play sound effect de.
|
; Play sound effect de.
|
||||||
; Sound effects are ordered by priority (highest to lowest)
|
; Sound effects are ordered by priority (highest to lowest)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue