Skip to content

Short beeping noise for low HP

Rangi edited this page Nov 25, 2021 · 4 revisions

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:

 UpdateChannels:
 	...

 .Channel1:
 	ld a, [wLowHealthAlarm]
+	cp $ff
+	jr z, .Channel5
 	bit DANGER_ON_F, a
 	ret nz
 .Channel5:
 	...
 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 ~(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

And edit engine/battle/core.asm:

 CheckDanger:
 	ld hl, wBattleMonHP
 	ld a, [hli]
 	or [hl]
 	jr z, .no_danger
 	ld a, [wBattleLowHealthAlarm]
 	and a
 	jr nz, .done
 	ld a, [wPlayerHPPal]
 	cp HP_RED
 	jr z, .danger

 .no_danger
 	ld hl, wLowHealthAlarm
+	ld [hl], 0
-	res DANGER_ON_F, [hl]
 	jr .done

 .danger
 	ld hl, wLowHealthAlarm
 	set DANGER_ON_F, [hl]

 .done
 	ret

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.

Clone this wiki locally