diff options
| author | Rangi <remy.oukaour+rangi42@gmail.com> | 2019-01-24 22:30:59 -0500 |
|---|---|---|
| committer | Rangi <remy.oukaour+rangi42@gmail.com> | 2019-01-24 22:30:59 -0500 |
| commit | bd36bcb7313d7cd7c8a6e301d02e6fc60a442c75 (patch) | |
| tree | f00127b399df34b8075da550a9a535f08ff6cc7d /Short-beeping-noise-for-low-HP.md | |
| parent | 6dae27c0994c65bb8187f0c4ab340447bd8294f7 (diff) | |
Short beeping noise for low HP
Diffstat (limited to 'Short-beeping-noise-for-low-HP.md')
| -rw-r--r-- | Short-beeping-noise-for-low-HP.md | 111 |
1 files changed, 111 insertions, 0 deletions
diff --git a/Short-beeping-noise-for-low-HP.md b/Short-beeping-noise-for-low-HP.md new file mode 100644 index 0000000..ef46d88 --- /dev/null +++ b/Short-beeping-noise-for-low-HP.md @@ -0,0 +1,111 @@ +When your Pokémon's HP is in the red, the battle music is replaced by a continuous beeping noise. This can be quite annoying. If you want a brief alert that your HP is low, just follow this tutorial. + +Edit [audio/engine.asm](../blob/master/audio/engine.asm): + +```diff + UpdateChannels: + ... + + .Channel1: + ld a, [wLowHealthAlarm] ++ cp $ff ++ jr z, .Channel5 + bit DANGER_ON_F, a + ret nz + .Channel5: + ... +``` + +```diff + PlayDanger: + ld a, [wLowHealthAlarm] + bit DANGER_ON_F, a + ret z ++ cp $ff ++ ret z + +- ; Don't do anything if SFX is being played +- and $ff ^ (1 << DANGER_ON_F) + ld d, a + call _CheckSFX + jr c, .increment ++ ld a, d + + ; Play the high tone +- and a +- jr z, .begin ++ and $1f ++ ld hl, DangerSoundHigh ++ jr z, .applychannel + + ; Play the low tone + cp 16 ++ jr nz, .increment +- jr z, .halfway +- +- jr .increment +- +-.halfway + ld hl, DangerSoundLow +- jr .applychannel +- +-.begin +- ld hl, DangerSoundHigh + + .applychannel + xor a + ldh [rNR10], a + ld a, [hli] + ldh [rNR11], a + ld a, [hli] + ldh [rNR12], a + ld a, [hli] + ldh [rNR13], a + ld a, [hli] + ldh [rNR14], a + + .increment + ld a, d ++ and $e0 ++ ld e, a ++ ld a, d ++ and $1f + inc a + cp 30 ; Ending frame + jr c, .noreset +- xor a ++ add 2 + .noreset +- ; Make sure the danger sound is kept on +- or 1 << DANGER_ON_F ++ add e ++ jr nz, .load ++ dec a ++.load + ld [wLowHealthAlarm], a + + ; Enable channel 1 if it's off + ld a, [wSoundOutput] + and $11 + ret nz + ld a, [wSoundOutput] + or $11 + ld [wSoundOutput], a + ret + + DangerSoundHigh: + db $80 ; duty 50% + db $e2 ; volume 14, envelope decrease sweep 2 + db $50 ; frequency: $750 + db $87 ; restart sound + + DangerSoundLow: + db $80 ; duty 50% + db $e2 ; volume 14, envelope decrease sweep 2 + db $ee ; frequency: $6ee + db $86 ; restart sound +``` + +TODO: Explain changes. + +With this short edit, the noise will stop after just four beeps. It plays when your HP first turns red, and when you send out a Pokémon with low HP. |
