summaryrefslogtreecommitdiff
path: root/common.asm
diff options
context:
space:
mode:
authorSanky <gsanky@gmail.com>2012-01-19 23:20:23 +0100
committerSanky <gsanky@gmail.com>2012-01-19 23:20:23 +0100
commitbf93a628eb061e056575a28083e8067b00cdb212 (patch)
treece5d2cf745592ad77cfc75a416de16789c06656d /common.asm
parent3d08bc291d70e129bbb8f96b9cc5538525bb71ac (diff)
HealParty script (Predef 7)
hg-commit-id: f92994d7ba58
Diffstat (limited to 'common.asm')
-rw-r--r--common.asm91
1 files changed, 88 insertions, 3 deletions
diff --git a/common.asm b/common.asm
index 685ff1a6..c810941e 100644
--- a/common.asm
+++ b/common.asm
@@ -2960,7 +2960,7 @@ INCBIN "baserom.gbc",$8000,$4000
SECTION "bank3",DATA,BANK[$3]
-INCBIN "baserom.gbc",$C000,$C23D - $C000
+INCBIN "baserom.gbc",$C000,$C23D - $C000
; see also MapHeaderPointers
MapHeaderBanks: ; 423D
@@ -8507,7 +8507,92 @@ _UnnamedText_ef7d: ; 0xef7d
db $50
; 0xef7d + 5 bytes
-INCBIN "baserom.gbc",$ef82,$fbd9 - $ef82
+INCBIN "baserom.gbc",$ef82,$f6a5 - $ef82
+
+HealParty:
+ ld hl, W_PARTYMON1
+ ld de, W_PARTYMON1_HP
+.HealPokemon\@: ; 0xf704
+ ld a, [hli]
+ cp $ff
+ jr z, .DoneHealing\@ ; End if there's no Pokémon
+ push hl
+ push de
+ ld hl, $0003 ; Status offset
+ add hl, de
+ xor a
+ ld [hl], a ; Clean status conditions
+ push de
+ ld b, $4 ; A Pokémon has 4 moves
+.RestorePP\@:
+ ld hl, $0007 ; Move offset
+ add hl, de
+ ld a, [hl]
+ and a
+ jr z, .HealNext\@ ; Skip if there's no move here
+ dec a
+ ld hl, $001c ; PP offset
+ add hl, de
+ push hl
+ push de
+ push bc
+ ld hl, $4000
+ ld bc, $0006
+ call AddNTimes
+ ld de, $cd6d
+ ld a, $e
+ call FarCopyData
+ ld a, [$cd72]
+ pop bc
+ pop de
+ pop hl
+ inc de
+ push bc
+ ld b, a
+ ld a, [hl]
+ and $c0
+ add b
+ ld [hl], a
+ pop bc
+.HealNext\@:
+ dec b
+ jr nz, .RestorePP\@ ; Continue if there's still moves
+ pop de
+ ld hl, $0021 ; Max HP offset
+ add hl, de
+ ld a, [hli]
+ ld [de], a
+ inc de
+ ld a, [hl]
+ ld [de], a ; Restore full HP
+ pop de
+ pop hl
+ push hl
+ ld bc, $002c
+ ld h, d
+ ld l, e
+ add hl, bc
+ ld d, h
+ ld e, l
+ pop hl
+ jr .HealPokemon\@ ; Next Pokémon
+.DoneHealing\@ ; This calls $6606 for each Pokémon in party -- no idea why
+ xor a
+ ld [$cf92], a
+ ld [$d11e], a
+ ld a, [W_NUMINPARTY]
+ ld b, a
+.asm_f711
+ push bc
+ call $6606
+ pop bc
+ ld hl, $cf92
+ inc [hl]
+ dec b
+ jr nz, .asm_f711 ; 0xf71b $f4
+ ret
+
+INCBIN "baserom.gbc",$f71e,$fbd9 - $f71e
UnnamedText_fbd9: ; 0xfbd9
TX_FAR _UnnamedText_fbd9
@@ -29529,7 +29614,7 @@ PredefPointers: ; 7E79
dbw $0F,$7103
dbw $1E,$5ABA
dbw $03,$7132
- dbw $03,$76A5
+ dbw BANK(HealParty),HealParty
dbw BANK(AttackAnimation),AttackAnimation; 08 play attack animation
dbw $03,$771E
dbw $03,$771E