mirror of
https://github.com/thornAvery/kep-hack.git
synced 2025-10-15 19:54:24 +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 GSSFX_NOT_VERY_EFFECTIVE
|
||||
const GSSFX_DAMAGE
|
||||
const GSSFX_SUPER_EFFECTIVE
|
||||
|
||||
SFX_STOP_ALL_MUSIC EQU $ff
|
||||
|
|
|
@ -2605,6 +2605,131 @@ _PlayCry::
|
|||
call MusicOn
|
||||
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::
|
||||
; clear channels if they aren't already
|
||||
call MusicOff
|
||||
|
|
|
@ -113,8 +113,3 @@ SFX:
|
|||
dba SFX_Shooting_Star
|
||||
|
||||
dba SFX_PokefluteInBattle
|
||||
|
||||
dba Sfx_NotVeryEffective
|
||||
dba Sfx_Damage
|
||||
dba Sfx_SuperEffective
|
||||
|
||||
|
|
|
@ -200,7 +200,7 @@ PlayAnimation:
|
|||
push hl
|
||||
push de
|
||||
call GetMoveSound
|
||||
call nc, AnimPlaySFX
|
||||
call nc, PlayBattleSound
|
||||
pop de
|
||||
pop hl
|
||||
.skipPlayingSound
|
||||
|
@ -256,15 +256,6 @@ PlayAnimation:
|
|||
.AnimationOver
|
||||
ret
|
||||
|
||||
AnimPlaySFX:
|
||||
push de
|
||||
ld e, a
|
||||
xor a
|
||||
ld d, a
|
||||
call PlaySFX
|
||||
pop de
|
||||
ret
|
||||
|
||||
LoadSubanimation:
|
||||
ld a, [wSubAnimAddrPtr + 1]
|
||||
ld h, a
|
||||
|
@ -560,7 +551,7 @@ PlaySubanimation:
|
|||
cp NO_MOVE - 1
|
||||
jr z, .skipPlayingSound
|
||||
call GetMoveSound
|
||||
call nc, AnimPlaySFX
|
||||
call nc, PlayBattleSound
|
||||
.skipPlayingSound
|
||||
ld hl, wOAMBuffer ; base address of OAM buffer
|
||||
ld a, l
|
||||
|
@ -2208,13 +2199,19 @@ GetMoveSound:
|
|||
; jr .done
|
||||
|
||||
.NotCryMove
|
||||
; todo: fix sound modifiers
|
||||
push bc
|
||||
ld a, [hli]
|
||||
; ld [wFrequencyModifier], a
|
||||
ld c, a
|
||||
ld b, 0
|
||||
ld a, [hli]
|
||||
; ld [wTempoModifier], a
|
||||
add $80
|
||||
ld e, a
|
||||
ld a, 0
|
||||
adc 0
|
||||
ld d, a
|
||||
pop af
|
||||
.done
|
||||
ld a, b
|
||||
and a
|
||||
ret
|
||||
|
||||
IsCryMove:
|
||||
|
@ -2625,21 +2622,20 @@ PlayApplyingAttackSound:
|
|||
and $7f
|
||||
ret z
|
||||
cp 10
|
||||
ld a, $20
|
||||
ld b, $30
|
||||
ld c, GSSFX_DAMAGE ; SFX_DAMAGE
|
||||
ld bc, $20
|
||||
ld de, $30 + $80
|
||||
ld a, SFX_DAMAGE
|
||||
jr z, .playSound
|
||||
ld a, $e0
|
||||
ld b, $ff
|
||||
ld c, GSSFX_SUPER_EFFECTIVE ; SFX_SUPER_EFFECTIVE
|
||||
ld bc, $e0
|
||||
ld de, $ff + $80
|
||||
ld a, SFX_SUPER_EFFECTIVE
|
||||
jr nc, .playSound
|
||||
ld a, $50
|
||||
ld b, $1
|
||||
ld c, GSSFX_NOT_VERY_EFFECTIVE ; SFX_NOT_VERY_EFFECTIVE
|
||||
ld bc, $50
|
||||
ld de, $1 + $80
|
||||
ld a, SFX_NOT_VERY_EFFECTIVE
|
||||
.playSound
|
||||
; todo: fix sound modifiers
|
||||
; ld [wFrequencyModifier], a
|
||||
ld a, b
|
||||
; ld a, b
|
||||
; ld [wTempoModifier], a
|
||||
ld a, c
|
||||
jp PlaySound
|
||||
; ld a, c
|
||||
jp PlayBattleSound
|
||||
|
|
|
@ -776,16 +776,19 @@ FaintEnemyPokemon:
|
|||
ld a, [wIsInBattle]
|
||||
dec a
|
||||
jr z, .wild_win
|
||||
|
||||
call WaitForSoundToFinish
|
||||
ld bc, $00
|
||||
ld de, $80
|
||||
ld a, SFX_FAINT_FALL
|
||||
call PlayBattleSound
|
||||
; xor a
|
||||
; ld [wFrequencyModifier], a
|
||||
; ld [wTempoModifier], a
|
||||
ld a, SFX_FAINT_FALL
|
||||
call PlaySoundWaitForCurrent
|
||||
; ld a, SFX_FAINT_FALL
|
||||
; call PlaySoundWaitForCurrent
|
||||
|
||||
; using WaitForSoundToFinish causes a noticeable delay
|
||||
; so use a smaller hard-coded delay for now
|
||||
ld c, 10
|
||||
call DelayFrames
|
||||
call WaitForSoundToFinish
|
||||
;.sfxwait
|
||||
; ld a, [wChannelSoundIDs + Ch5]
|
||||
; cp SFX_FAINT_FALL
|
||||
|
|
|
@ -288,6 +288,48 @@ endr
|
|||
pop hl
|
||||
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::
|
||||
; Play sound effect de.
|
||||
; Sound effects are ordered by priority (highest to lowest)
|
||||
|
|
Loading…
Reference in a new issue