shithub: pokecrystal

Download patch

ref: 0cbea9b553f0abf44b0bf1b28b96429b36a0bac2
parent: 417a73d61a046641ab9a3d7c405f41bddfa1966f
author: yenatch <[email protected]>
date: Thu May 2 20:22:28 EDT 2013

bank 0 battle functions

--- a/battle/effect_commands.asm
+++ b/battle/effect_commands.asm
@@ -182,7 +182,7 @@
 	call FarBattleTextBox
 
 	call CantMove
-	call $399c
+	call UpdateBattleMonInParty
 	ld hl, $5f48
 	call CallBankF
 	ld a, $1
@@ -442,7 +442,7 @@
 	ld hl, WokeUpText
 	call FarBattleTextBox
 	call CantMove
-	call $39b0
+	call UpdateEnemyMonInParty
 	ld hl, $6036
 	call CallBankF
 	ld a, $1
@@ -3268,7 +3268,7 @@
 	ld l, c
 	ld a, $b
 	call $2d83
-	call $39c9
+	call RefreshBattleHuds
 
 	call SwitchTurn
 	xor a
@@ -5385,7 +5385,7 @@
 	ld a, $b
 	call Predef
 .asm_35d7b
-	jp $39c9
+	jp RefreshBattleHuds
 ; 35d7e
 
 
@@ -5443,7 +5443,7 @@
 	ld a, $b
 	call Predef
 .asm_35ddd
-	jp $39c9
+	jp RefreshBattleHuds
 ; 35de0
 
 
@@ -5503,7 +5503,7 @@
 	xor a
 	ld [hl], a
 .asm_35e3a
-	call $39c9
+	call RefreshBattleHuds
 .asm_35e3d
 	jp ResetDamage
 ; 35e40
@@ -5581,8 +5581,8 @@
 	jr z, .asm_35ea4
 	inc a
 	ld [de], a
-	call $398e
-	call $39c9
+	call UpdateOpponentInParty
+	call RefreshBattleHuds
 
 	ld hl, FellAsleepText
 	call FarBattleTextBox
@@ -5659,7 +5659,7 @@
 	call Function0x35ff5
 	ld de, $0106
 	call Function0x37e54
-	call $39c9
+	call RefreshBattleHuds
 
 	ld hl, WasPoisonedText
 	call FarBattleTextBox
@@ -5756,7 +5756,7 @@
 Function0x35fc0: ; 35fc0
 	call Function0x37e01
 	call Function0x35ff5
-	jp $39c9
+	jp RefreshBattleHuds
 ; 35fc9
 
 
@@ -5797,7 +5797,7 @@
 	ld a, $b
 	call $39e7
 	set 3, [hl]
-	jp $398e
+	jp UpdateOpponentInParty
 ; 35fff
 
 
@@ -5895,8 +5895,8 @@
 	ld [$d10a], a
 	ld a, $b
 	call Predef
-	call $39c9
-	jp $399c
+	call RefreshBattleHuds
+	jp UpdateBattleMonInParty
 ; 3608c
 
 
@@ -5928,12 +5928,12 @@
 	ld a, BATTLE_VARS_STATUS_OPP
 	call GetBattleVarPair
 	set 4, [hl]
-	call $398e
+	call UpdateOpponentInParty
 	ld hl, $6c76
 	call CallBankF
 	ld de, $0105
 	call Function0x37e54
-	call $39c9
+	call RefreshBattleHuds
 
 	ld hl, WasBurnedText
 	call FarBattleTextBox
@@ -5965,7 +5965,7 @@
 	call GetPartyLocation
 	xor a
 	ld [hl], a
-	call $398e
+	call UpdateOpponentInParty
 
 	ld hl, DefrostedOpponentText
 	jp FarBattleTextBox
@@ -6003,10 +6003,10 @@
 	ld a, BATTLE_VARS_STATUS_OPP
 	call GetBattleVarPair
 	set 5, [hl]
-	call $398e
+	call UpdateOpponentInParty
 	ld de, $0108
 	call Function0x37e54
-	call $39c9
+	call RefreshBattleHuds
 
 	ld hl, WasFrozenText
 	call FarBattleTextBox
@@ -6054,12 +6054,12 @@
 	ld a, BATTLE_VARS_STATUS_OPP
 	call GetBattleVarPair
 	set 6, [hl]
-	call $398e
+	call UpdateOpponentInParty
 	ld hl, $6c39
 	call CallBankF
 	ld de, $0109
 	call Function0x37e54
-	call $39c9
+	call RefreshBattleHuds
 	call PrintParalyze
 	ld hl, $5de9
 	jp CallBankF
@@ -7158,7 +7158,7 @@
 	cp b
 	jr nc, .asm_367df ; 367dd $0
 .asm_367df
-	call $399c
+	call UpdateBattleMonInParty
 	xor a
 	ld [$cfca], a
 	inc a
@@ -7225,7 +7225,7 @@
 .asm_36852
 	jp .asm_36969
 .asm_36855
-	call $399c
+	call UpdateBattleMonInParty
 	xor a
 	ld [$cfca], a
 	inc a
@@ -7239,7 +7239,7 @@
 	ld a, [$c70f]
 	and a
 	jr z, .asm_368ca ; 36872 $56
-	call $39b0
+	call UpdateEnemyMonInParty
 	ld a, $1
 	ld [$c689], a
 	call Function0x37e01
@@ -7318,7 +7318,7 @@
 	jr .asm_36969
 
 .asm_368f5
-	call $399c
+	call UpdateBattleMonInParty
 	xor a
 	ld [$cfca], a
 	inc a
@@ -7335,7 +7335,7 @@
 	cp $1
 	jr z, .asm_368ca
 
-	call $399c
+	call UpdateBattleMonInParty
 	ld a, $1
 	ld [$c689], a
 	call Function0x37e01
@@ -8017,7 +8017,7 @@
 	ld [$d10a], a
 	ld a, $b
 	call $2d83
-	call $39c9
+	call RefreshBattleHuds
 	ld hl, RecoilText
 	jp FarBattleTextBox
 ; 36d1d
@@ -8188,10 +8188,10 @@
 	ld a, BATTLE_VARS_STATUS_OPP
 	call GetBattleVarPair
 	set 6, [hl]
-	call $398e
+	call UpdateOpponentInParty
 	ld hl, $6c39
 	call CallBankF
-	call $39d4
+	call UpdateBattleHuds
 	call PrintParalyze
 	ld hl, $5de9
 	jp CallBankF
@@ -8310,7 +8310,7 @@
 .asm_36eeb
 	ld hl, MadeSubstituteText
 	call FarBattleTextBox
-	jp $39c9
+	jp RefreshBattleHuds
 .asm_36ef4
 	call Function0x34548
 	call nz, BattleCommand0c
@@ -8784,8 +8784,8 @@
 	ld hl, $4cef
 	call CallBankF
 	call SwitchTurn
-	call $3995
-	call $39c9
+	call UpdateUserInParty
+	call RefreshBattleHuds
 	ld hl, RegainedHealthText
 	jp FarBattleTextBox
 
@@ -9141,7 +9141,7 @@
 	ld hl, $6043
 	rst FarCall
 	call $31f6
-	jp $39c9
+	jp RefreshBattleHuds
 ; 373c9
 
 
@@ -9444,7 +9444,7 @@
 	call $3945
 	res 5, [hl]
 .asm_3757f
-	call $39c9
+	call RefreshBattleHuds
 	ld hl, WasDefrostedText
 	jp FarBattleTextBox
 ; 37588
@@ -9505,7 +9505,7 @@
 	call CallBankF
 	ld hl, $4c3f
 	call CallBankF
-	call $3995
+	call UpdateUserInParty
 	ld hl, PutACurseText
 	jp FarBattleTextBox
 .asm_37604
@@ -10041,7 +10041,7 @@
 	ld hl, RegainedHealthText
 	call FarBattleTextBox
 	call SwitchTurn
-	call $398e
+	call UpdateOpponentInParty
 	jr .asm_37904 ; 378f1 $11
 .asm_378f3
 	call SwitchTurn
@@ -10199,7 +10199,7 @@
 	call Function0x37ae9
 	jp z, Function0x37aab
 
-	call $399c
+	call UpdateBattleMonInParty
 	call Function0x37e01
 
 	ld c, 50
@@ -10253,7 +10253,7 @@
 	call Function0x37af6
 	jp z, Function0x37aab
 
-	call $39b0
+	call UpdateEnemyMonInParty
 	call Function0x37e01
 	call Function0x37a82
 
@@ -10564,7 +10564,7 @@
 	rst FarCall ; callab 3ccef
 
 	call SwitchTurn
-	call $3995
+	call UpdateUserInParty
 
 ; 'regained health!'
 	ld hl, RegainedHealthText
@@ -10646,7 +10646,7 @@
 	ld hl, $4c3f
 	ld a, $f
 	rst FarCall
-	call $3995
+	call UpdateUserInParty
 	ld a, $5
 
 .asm_37c41
--- a/main.asm
+++ b/main.asm
@@ -3867,7 +3867,72 @@
 	ret
 ; 398e
 
-INCBIN "baserom.gbc", $398e, $39e1 - $398e
+
+UpdateOpponentInParty: ; 398e
+	ld a, [hBattleTurn]
+	and a
+	jr z, UpdateEnemyMonInParty
+	jr UpdateBattleMonInParty
+; 3995
+
+UpdateUserInParty: ; 3995
+	ld a, [hBattleTurn]
+	and a
+	jr z, UpdateBattleMonInParty
+	jr UpdateEnemyMonInParty
+; 399c
+
+UpdateBattleMonInParty: ; 399c
+; Update level, status, current HP
+
+	ld a, [CurBattleMon]
+	ld hl, PartyMon1Level
+	call GetPartyLocation
+
+	ld d, h
+	ld e, l
+	ld hl, BattleMonLevel
+	ld bc, BattleMonMaxHP - BattleMonLevel
+	jp CopyBytes
+; 39b0
+
+UpdateEnemyMonInParty: ; 39b0
+; Update level, status, current HP
+
+; No wildmons.
+	ld a, [IsInBattle]
+	dec a
+	ret z
+
+	ld a, [CurOTMon]
+	ld hl, OTPartyMon1Level
+	call GetPartyLocation
+
+	ld d, h
+	ld e, l
+	ld hl, EnemyMonLevel
+	ld bc, EnemyMonMaxHP - EnemyMonLevel
+	jp CopyBytes
+; 39c9
+
+
+RefreshBattleHuds: ; 39c9
+	call UpdateBattleHuds
+	ld c, 3
+	call DelayFrames
+	jp WaitBGMap
+; 39d4
+
+UpdateBattleHuds: ; 39d4
+	ld a, $f
+	ld hl, $5f48
+	rst FarCall ; UpdatePlayerHud
+	ld a, $f
+	ld hl, $6036
+	rst FarCall ; UpdateEnemyHud
+	ret
+; 39e1
+
 
 CleanGetBattleVarPair: ; 39e1
 ; Preserves hl.