Low health alarm documentation

RenaKunisaki
This commit is contained in:
U-Daniel-PC\Daniel 2015-03-12 10:49:35 -04:00
parent 25f0b7abcd
commit 1c2a1076cb
9 changed files with 71 additions and 52 deletions

View file

@ -365,7 +365,7 @@ SECTION "Audio Engine 1", ROMX, BANK[AUDIO_1]
PlayBattleMusic:: ; 0x90c6 PlayBattleMusic:: ; 0x90c6
xor a xor a
ld [wMusicHeaderPointer], a ld [wMusicHeaderPointer], a
ld [wd083], a ld [wLowHealthAlarm], a
dec a dec a
ld [wc0ee], a ld [wc0ee], a
call PlaySound ; stop music call PlaySound ; stop music
@ -455,63 +455,80 @@ Music_Cities1AlternateTempo:: ; 0x9b81
SECTION "Audio Engine 2", ROMX, BANK[AUDIO_2] SECTION "Audio Engine 2", ROMX, BANK[AUDIO_2]
Func_2136e:: ; 2136e (8:536e) Music_DoLowHealthAlarm:: ; 2136e (8:536e)
ld a, [wd083] ld a, [wLowHealthAlarm]
cp $ff cp $ff
jr z, .asm_2139b jr z, .disableAlarm
bit 7, a
ret z bit 7, a ;alarm enabled?
and $7f ret z ;nope
jr nz, .asm_21383
call Func_213a7 and $7f ;low 7 bits are the timer.
ld a, $1e jr nz, .asm_21383 ;if timer > 0, play low tone.
jr .asm_21395
call .playToneHi
ld a, 30 ;keep this tone for 30 frames.
jr .asm_21395 ;reset the timer.
.asm_21383 .asm_21383
cp $14 cp 20
jr nz, .asm_2138a jr nz, .asm_2138a ;if timer == 20,
call Func_213ac call .playToneLo ;actually set the sound registers.
.asm_2138a .asm_2138a
ld a, $86 ld a, $86
ld [wc02a], a ld [wc02a], a ;disable sound channel?
ld a, [wd083] ld a, [wLowHealthAlarm]
and $7f and $7f ;decrement alarm timer.
dec a dec a
.asm_21395 .asm_21395
; reset the timer and enable flag.
set 7, a set 7, a
ld [wd083], a ld [wLowHealthAlarm], a
ret ret
.asm_2139b
.disableAlarm
xor a xor a
ld [wd083], a ld [wLowHealthAlarm], a ;disable alarm
ld [wc02a], a ld [wc02a], a ;re-enable sound channel?
ld de, Unknown_213c4 ; $53c4 ld de, .toneDataSilence
jr asm_213af jr .playTone
Func_213a7: ; 213a7 (8:53a7) ;update the sound registers to change the frequency.
ld de, Unknown_213bc ; $53bc ;the tone set here stays until we change it.
jr asm_213af .playToneHi
ld de, .toneDataHi
jr .playTone
Func_213ac: ; 213ac (8:53ac) .playToneLo
ld de, Unknown_213c0 ; $53c0 ld de, .toneDataLo
asm_213af: ; 213af (8:53af)
ld hl, $ff10 ;update sound channel 1 to play the alarm, overriding all other sounds.
.playTone
ld hl, rNR10 ;channel 1 sound register
ld c, $5 ld c, $5
xor a xor a
.asm_213b5
.copyLoop
ld [hli], a ld [hli], a
ld a, [de] ld a, [de]
inc de inc de
dec c dec c
jr nz, .asm_213b5 jr nz, .copyLoop
ret ret
Unknown_213bc: ; 213bc (8:53bc) ;bytes to write to sound channel 1 registers for health alarm.
;starting at FF11 (FF10 is always zeroed), so these bytes are:
;length, envelope, freq lo, freq hi
.toneDataHi
db $A0,$E2,$50,$87 db $A0,$E2,$50,$87
Unknown_213c0: ; 213c0 (8:53c0) .toneDataLo
db $B0,$E2,$EE,$86 db $B0,$E2,$EE,$86
Unknown_213c4: ; 213c4 (8:53c4) ;written to stop the alarm
.toneDataSilence
db $00,$00,$00,$80 db $00,$00,$00,$80

View file

@ -162,7 +162,7 @@ Music8_PlayNextNote: ; 21946 (8:5946)
ld a, c ld a, c
cp CH4 cp CH4
jr nz, .beginChecks jr nz, .beginChecks
ld a, [wd083] ld a, [wLowHealthAlarm] ;low health alarm enabled?
bit 7, a bit 7, a
ret nz ret nz
.beginChecks .beginChecks
@ -931,7 +931,7 @@ Func_21e19: ; 21e19 (8:5e19)
ld a, c ld a, c
cp CH4 cp CH4
jr nz, .asm_21e2e jr nz, .asm_21e2e
ld a, [wd083] ld a, [wLowHealthAlarm]
bit 7, a bit 7, a
jr z, .asm_21e2e jr z, .asm_21e2e
xor a xor a

View file

@ -45,7 +45,7 @@ EndOfBattle: ; 137aa (4:77aa)
predef EvolutionAfterBattle predef EvolutionAfterBattle
.resetVariables .resetVariables
xor a xor a
ld [wd083], a ld [wLowHealthAlarm], a ;disable low health alarm
ld [wc02a], a ld [wc02a], a
ld [W_ISINBATTLE], a ld [W_ISINBATTLE], a
ld [W_BATTLETYPE], a ld [W_BATTLETYPE], a

View file

@ -947,7 +947,7 @@ EnemyMonFaintedText: ; 0x3c63e
Func_3c643: ; 3c643 (f:4643) Func_3c643: ; 3c643 (f:4643)
xor a xor a
ld [wd083], a ld [wLowHealthAlarm], a ;disable low health alarm
ld [wc02a], a ld [wc02a], a
inc a inc a
ld [wccf6], a ld [wccf6], a
@ -1089,15 +1089,15 @@ RemoveFaintedPlayerMon: ; 3c741 (f:4741)
predef FlagActionPredef ; clear gain exp flag for fainted mon predef FlagActionPredef ; clear gain exp flag for fainted mon
ld hl, W_ENEMYBATTSTATUS1 ld hl, W_ENEMYBATTSTATUS1
res 2, [hl] ; reset "attacking multiple times" flag res 2, [hl] ; reset "attacking multiple times" flag
ld a, [wd083] ld a, [wLowHealthAlarm]
bit 7, a ; skip sound flag (red bar (?)) bit 7, a ; skip sound flag (red bar (?))
jr z, .skipWaitForSound jr z, .skipWaitForSound
ld a, $ff ld a, $ff
ld [wd083], a ld [wLowHealthAlarm], a ;disable low health alarm
call WaitForSoundToFinish call WaitForSoundToFinish
.skipWaitForSound .skipWaitForSound
; bug? if the player mon faints while the enemy mon is using bide, ; bug? if the player mon faints while the enemy mon is using bide,
; the accumulated damage is overwritten. xxx what values can [wd083] have here? ; the accumulated damage is overwritten. xxx what values can [wLowHealthAlarm] have here?
ld hl, wEnemyBideAccumulatedDamage ld hl, wEnemyBideAccumulatedDamage
ld [hli], a ld [hli], a
ld [hl], a ld [hl], a
@ -1934,16 +1934,16 @@ DrawPlayerHUDAndHPBar: ; 3cd60 (f:4d60)
cp $2 cp $2
jr z, .asm_3cde6 jr z, .asm_3cde6
.asm_3cdd9 .asm_3cdd9
ld hl, wd083 ld hl, wLowHealthAlarm
bit 7, [hl] bit 7, [hl] ;low health alarm enabled?
ld [hl], $0 ld [hl], $0
ret z ret z
xor a xor a
ld [wc02a], a ld [wc02a], a
ret ret
.asm_3cde6 .asm_3cde6
ld hl, wd083 ld hl, wLowHealthAlarm
set 7, [hl] set 7, [hl] ;enable low health alarm
ret ret
DrawEnemyHUDAndHPBar: ; 3cdec (f:4dec) DrawEnemyHUDAndHPBar: ; 3cdec (f:4dec)

View file

@ -7,7 +7,7 @@ Func_7bde9: ; 7bde9 (1e:7de9)
ld a, [wd0b5] ld a, [wd0b5]
push af push af
xor a xor a
ld [wd083], a ld [wLowHealthAlarm], a
ld [wc02a], a ld [wc02a], a
dec a dec a
ld [wc0ee], a ld [wc0ee], a

View file

@ -858,7 +858,7 @@ ItemUseMedicine: ; dabb (3:5abb)
jp .cureStatusAilment jp .cureStatusAilment
.notFullHP ; if the pokemon's current HP doesn't equal its max HP .notFullHP ; if the pokemon's current HP doesn't equal its max HP
xor a xor a
ld [wd083],a ld [wLowHealthAlarm],a ;disable low health alarm
ld [wc02a],a ld [wc02a],a
push hl push hl
push de push de
@ -1645,7 +1645,7 @@ ItemUsePokeflute: ; e140 (3:6140)
; if some pokemon were asleep ; if some pokemon were asleep
ld hl,PlayedFluteHadEffectText ld hl,PlayedFluteHadEffectText
call PrintText call PrintText
ld a,[wd083] ld a,[wLowHealthAlarm]
and a,$80 and a,$80
jr nz,.skipMusic jr nz,.skipMusic
call WaitForSoundToFinish ; wait for sound to end call WaitForSoundToFinish ; wait for sound to end

View file

@ -3223,7 +3223,7 @@ PlaySoundWaitForCurrent:: ; 3740 (0:3740)
; Wait for sound to finish playing ; Wait for sound to finish playing
WaitForSoundToFinish:: ; 3748 (0:3748) WaitForSoundToFinish:: ; 3748 (0:3748)
ld a, [wd083] ld a, [wLowHealthAlarm]
and $80 and $80
ret nz ret nz
push hl push hl

View file

@ -65,7 +65,7 @@ VBlank::
cp BANK(Music8_UpdateMusic) cp BANK(Music8_UpdateMusic)
jr nz, .bank1F jr nz, .bank1F
.bank8 .bank8
call Func_2136e call Music_DoLowHealthAlarm
call Music8_UpdateMusic call Music8_UpdateMusic
jr .afterMusic jr .afterMusic
.bank1F .bank1F

View file

@ -1091,7 +1091,9 @@ W_BASECOORDX:: ; d081
W_BASECOORDY:: ; d082 W_BASECOORDY:: ; d082
ds 1 ds 1
wd083:: ds 1 ; low health alarm counter/enable
; high bit = enable, others = timer to cycle frequencies
wLowHealthAlarm:: ds 1 ; d083
W_FBTILECOUNTER:: ; d084 W_FBTILECOUNTER:: ; d084
; counts how many tiles of the current frame block have been drawn ; counts how many tiles of the current frame block have been drawn