Skip to content

Commit

Permalink
Fix BattleHpBar struct
Browse files Browse the repository at this point in the history
  • Loading branch information
adrienntindall committed Aug 8, 2023
1 parent b0e786c commit 1cab87a
Show file tree
Hide file tree
Showing 14 changed files with 84 additions and 87 deletions.
2 changes: 1 addition & 1 deletion asm/include/overlay_12_02264824.inc
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
.public ov12_02264E84
.public ov12_02264EB4
.public ov12_02264EE0
.public ov12_02264F28
.public BattleHpBar_SetEnabled
.public ov12_02264FB0
.public ov12_02265B64
.public ov12_02265C54
Expand Down
4 changes: 2 additions & 2 deletions asm/include/overlay_12_battle_controller_opponent.inc
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@
.public ov12_0223BBC0
.public ov12_0223BBD8
.public BattleSystem_GetHpBar
.public ov12_0223BC98
.public BattleSystem_SetHpBarEnabled
.public ov12_0223BCC8
.public BattleSystem_GetWinLoseFlags
.public ov12_0223BD20
Expand Down Expand Up @@ -270,7 +270,7 @@
.public ov12_02264E68
.public ov12_02264E84
.public ov12_02264EB4
.public ov12_02264F28
.public BattleHpBar_SetEnabled
.public ov12_02264FB0
.public ov12_02265B64
.public ov12_02265C54
Expand Down
4 changes: 2 additions & 2 deletions asm/include/overlay_12_battle_system.inc
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@
.public ov12_0223BC2C
.public BattleSystem_GetHpBar
.public BattleSystem_HpBar_Init
.public ov12_0223BC98
.public BattleSystem_SetHpBarEnabled
.public ov12_0223BCC8
.public ov12_0223BCF0
.public BattleSystem_GetWinLoseFlags
Expand Down Expand Up @@ -215,7 +215,7 @@
.public BattleHpBar_LoadResources
.public ov12_02264C68
.public ov12_02264EE0
.public ov12_02264F28
.public BattleHpBar_SetEnabled
.public ov12_02265B64
.public ov12_02266008
.public ov12_0226AA8C
Expand Down
8 changes: 4 additions & 4 deletions asm/overlay_12_battle_controller_opponent.s
Original file line number Diff line number Diff line change
Expand Up @@ -3732,7 +3732,7 @@ ov12_0225A414: ; 0x0225A414
add r0, #0x27
strb r2, [r0]
add r0, r4, #0
bl ov12_02264F28
bl BattleHpBar_SetEnabled
mov r2, #0
ldr r1, [r4, #0x28]
add r0, r4, #0
Expand Down Expand Up @@ -10430,7 +10430,7 @@ _0225DA42:
bl ov12_02264FB0
add r0, r4, #0
mov r1, #1
bl ov12_02264F28
bl BattleHpBar_SetEnabled
ldrb r0, [r4]
add r0, r0, #1
strb r0, [r4]
Expand Down Expand Up @@ -10496,7 +10496,7 @@ _0225DAAC:
bl DestroySysTask
add r0, r4, #0
mov r1, #0
bl ov12_02264F28
bl BattleHpBar_SetEnabled
_0225DAD0:
pop {r3, r4, r5, pc}
.balign 4, 0
Expand Down Expand Up @@ -14880,7 +14880,7 @@ _0225FE50:
cmp r0, #0
beq _0225FE68
ldr r0, [r4]
bl ov12_0223BC98
bl BattleSystem_SetHpBarEnabled
_0225FE68:
add r0, r4, #0
add r0, #0x6c
Expand Down
31 changes: 1 addition & 30 deletions asm/overlay_12_battle_system.s
Original file line number Diff line number Diff line change
Expand Up @@ -6,35 +6,6 @@

.text

thumb_func_start ov12_0223BC98
ov12_0223BC98: ; 0x0223BC98
push {r3, r4, r5, r6, r7, lr}
add r6, r0, #0
ldr r0, [r6, #0x44]
mov r4, #0
cmp r0, #0
ble _0223BCC4
add r5, r6, #0
mov r7, #1
_0223BCA8:
ldr r0, [r5, #0x34]
bl OpponentData_GetHpBar
ldr r1, [r0, #0x28]
cmp r1, #0
beq _0223BCBA
add r1, r7, #0
bl ov12_02264F28
_0223BCBA:
ldr r0, [r6, #0x44]
add r4, r4, #1
add r5, r5, #4
cmp r4, r0
blt _0223BCA8
_0223BCC4:
pop {r3, r4, r5, r6, r7, pc}
.balign 4, 0
thumb_func_end ov12_0223BC98

thumb_func_start ov12_0223BCC8
ov12_0223BCC8: ; 0x0223BCC8
push {r3, r4, r5, r6, r7, lr}
Expand All @@ -49,7 +20,7 @@ _0223BCD8:
ldr r0, [r5, #0x34]
bl OpponentData_GetHpBar
add r1, r7, #0
bl ov12_02264F28
bl BattleHpBar_SetEnabled
ldr r0, [r6, #0x44]
add r4, r4, #1
add r5, r5, #4
Expand Down
6 changes: 3 additions & 3 deletions asm/overlay_12_hp_bar.s
Original file line number Diff line number Diff line change
Expand Up @@ -928,8 +928,8 @@ _02264F26:
pop {r3, r4, r5, pc}
thumb_func_end ov12_02264F00

thumb_func_start ov12_02264F28
ov12_02264F28: ; 0x02264F28
thumb_func_start BattleHpBar_SetEnabled
BattleHpBar_SetEnabled: ; 0x02264F28
push {r3, r4, r5, lr}
add r5, r0, #0
ldr r0, [r5, #4]
Expand All @@ -943,7 +943,7 @@ ov12_02264F28: ; 0x02264F28
_02264F40:
pop {r3, r4, r5, pc}
.balign 4, 0
thumb_func_end ov12_02264F28
thumb_func_end BattleHpBar_SetEnabled

thumb_func_start ov12_02264F44
ov12_02264F44: ; 0x02264F44
Expand Down
8 changes: 4 additions & 4 deletions include/battle.h
Original file line number Diff line number Diff line change
Expand Up @@ -425,16 +425,16 @@ typedef struct BattleHpBar {
void *unk8;
BattleSystem *bsys;
void *unk10;
s32 hp;
s32 maxHp;
s32 exp;
s32 maxExp;
s32 damage;
s32 hpCalc;
u8 battlerId;
u8 type;
u8 unk26;
u8 unk27;
s32 exp;
s32 maxExp;
s32 hp;
s32 maxHp;
s32 gainedExp;
s32 expCalc;
u8 level;
Expand Down
2 changes: 1 addition & 1 deletion include/battle/battle_hp_bar.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include "battle.h"

void BattleHpBar_LoadResources(BattleHpBar *hpBar);
void ov12_02264F28(BattleHpBar *hpBar, BOOL a1);
void BattleHpBar_SetEnabled(BattleHpBar *hpBar, BOOL a1);
u8 ov12_02265B64(u8 a0, u32 battleType);

#endif
1 change: 1 addition & 0 deletions include/battle_system.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ void ov12_0223BC20(BattleSystem *bsys, u8 a1);
void ov12_0223BC2C(BattleSystem *bsys, u8 a1);
BattleHpBar *BattleSystem_GetHpBar(BattleSystem *bsys, int battlerId);
void BattleSystem_HpBar_Init(BattleSystem *bsys);
void BattleSystem_SetHpBarEnabled(BattleSystem *bsys);

//These functions haven't been decompiled
int BattleSystem_Random(BattleSystem *bsys);
Expand Down
2 changes: 2 additions & 0 deletions include/constants/battle.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ typedef enum Terrain {
#define BATTLE_TYPE_8 (1 << 8)
#define BATTLE_TYPE_PAL_PARK (1 << 9)
#define BATTLE_TYPE_TUTORIAL (1 << 10)
#define BATTLE_TYPE_11 (1 << 11)
#define BATTLE_TYPE_DEBUG (1 << 31)

#define BATTLE_TYPE_NO_EXP (BATTLE_TYPE_LINK | BATTLE_TYPE_SAFARI | BATTLE_TYPE_TOWER | BATTLE_TYPE_PAL_PARK)

Expand Down
7 changes: 7 additions & 0 deletions include/constants/game_stat.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@

#define GAME_STAT_APRICORN_GET 1
#define GAME_STAT_UNK2 2
#define GAME_STAT_UNK6 6
#define GAME_STAT_UNK9 9
#define GAME_STAT_UNK10 10
#define GAME_STAT_UNK11 11
#define GAME_STAT_UNK12 12
#define GAME_STAT_UNK20 20
#define GAME_STAT_UNK21 21
#define GAME_STAT_BADGE_GET 22
#define GAME_STAT_UNK46 46
#define GAME_STAT_BATTLE_POINTS 69
Expand Down
17 changes: 15 additions & 2 deletions src/battle/battle_system.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "party.h"
#include "pokemon_mood.h"
#include "overlay_12_0224E4FC.h"
#include "constants/game_stat.h"

BgConfig *BattleSystem_GetBgConfig(BattleSystem *bsys) {
return bsys->bgConfig;
Expand Down Expand Up @@ -926,7 +927,7 @@ void ov12_0223BB44(BattleSystem *bsys) {
if (bsys->battleSpecial & BATTLE_SPECIAL_RECORDED) {
return;
}
GameStats_AddSpecial(bsys->gameStats, 21);
GameStats_AddSpecial(bsys->gameStats, GAME_STAT_UNK21);
}

void ov12_0223BB64(BattleSystem *bsys, int a1) {
Expand Down Expand Up @@ -1006,6 +1007,18 @@ void BattleSystem_HpBar_Init(BattleSystem *bsys) {
hpBar->bsys = bsys;
hpBar->type = ov12_02265B64(ov12_02261258(bsys->opponentData[i]), BattleSystem_GetBattleType(bsys));
BattleHpBar_LoadResources(hpBar);
ov12_02264F28(hpBar, FALSE);
BattleHpBar_SetEnabled(hpBar, FALSE);
}
}

void BattleSystem_SetHpBarEnabled(BattleSystem *bsys) {
int i;
BattleHpBar *hpBar;

for (i = 0; i < bsys->maxBattlers; i++) {
hpBar = OpponentData_GetHpBar(bsys->opponentData[i]);
if (hpBar->hp) {
BattleHpBar_SetEnabled(hpBar, TRUE);
}
}
}
Loading

0 comments on commit 1cab87a

Please sign in to comment.