diff --git a/asm/include/overlay_12_022378C0.inc b/asm/include/overlay_12_022378C0.inc index 162e0e081..50dedd5d1 100644 --- a/asm/include/overlay_12_022378C0.inc +++ b/asm/include/overlay_12_022378C0.inc @@ -217,7 +217,7 @@ .public BattleSystem_TryChangeForm .public ov12_0223B870 .public ov12_0223BBF0 -.public ov12_0223BC48 +.public BattleSystem_HpBar_Init .public ov12_0223BCC8 .public ov12_0223BD2C .public ov12_0223BD3C @@ -238,7 +238,7 @@ .public ov12_02258E7C .public ov12_02260EA4 .public ov12_02261264 -.public ov12_0226127C +.public OpponentData_GetHpBar .public ov12_022621C4 .public ov12_02265FD4 .public ov12_0226604C diff --git a/asm/include/overlay_12_02264824.inc b/asm/include/overlay_12_02264824.inc index 871dba6af..c8e8af171 100644 --- a/asm/include/overlay_12_02264824.inc +++ b/asm/include/overlay_12_02264824.inc @@ -58,7 +58,7 @@ .public BattleSystem_GetPaletteData .public ov12_0223A9A4 .public ov12_0226498C -.public ov12_02264BCC +.public BattleHpBar_LoadResources .public ov12_02264C68 .public ov12_02264C84 .public ov12_02264DCC diff --git a/asm/include/overlay_12_battle_command.inc b/asm/include/overlay_12_battle_command.inc index 5c1125506..3fae5b32b 100644 --- a/asm/include/overlay_12_battle_command.inc +++ b/asm/include/overlay_12_battle_command.inc @@ -143,7 +143,7 @@ .public BattleSystem_GetTextFrameDelay .public ov12_0223B870 .public ov12_0223BB1C -.public ov12_0223BB28 +.public BattleSystem_GameStatIncrement .public ov12_0223BB44 .public ov12_0223BBF0 .public ov12_0223BCF0 diff --git a/asm/include/overlay_12_battle_controller_opponent.inc b/asm/include/overlay_12_battle_controller_opponent.inc index b5b156db9..9793e9e55 100644 --- a/asm/include/overlay_12_battle_controller_opponent.inc +++ b/asm/include/overlay_12_battle_controller_opponent.inc @@ -195,7 +195,7 @@ .public ov12_0223BAEC .public ov12_0223BB04 .public ov12_0223BB10 -.public ov12_0223BB28 +.public BattleSystem_GameStatIncrement .public ov12_0223BB64 .public ov12_0223BB6C .public ov12_0223BB78 @@ -205,7 +205,7 @@ .public ov12_0223BBA8 .public ov12_0223BBC0 .public ov12_0223BBD8 -.public ov12_0223BC38 +.public BattleSystem_GetHpBar .public ov12_0223BC98 .public ov12_0223BCC8 .public BattleSystem_GetWinLoseFlags @@ -248,7 +248,7 @@ .public ov12_02261258 .public ov12_02261264 .public ov12_02261270 -.public ov12_0226127C +.public OpponentData_GetHpBar .public ov12_02261280 .public ov12_02261294 .public ov12_02261FD4 diff --git a/asm/include/overlay_12_battle_system.inc b/asm/include/overlay_12_battle_system.inc index 8f2fea031..b11a8c98b 100644 --- a/asm/include/overlay_12_battle_system.inc +++ b/asm/include/overlay_12_battle_system.inc @@ -146,7 +146,7 @@ .public ov12_0223BB04 .public ov12_0223BB10 .public ov12_0223BB1C -.public ov12_0223BB28 +.public BattleSystem_GameStatIncrement .public ov12_0223BB44 .public ov12_0223BB64 .public ov12_0223BB6C @@ -163,8 +163,8 @@ .public ov12_0223BC14 .public ov12_0223BC20 .public ov12_0223BC2C -.public ov12_0223BC38 -.public ov12_0223BC48 +.public BattleSystem_GetHpBar +.public BattleSystem_HpBar_Init .public ov12_0223BC98 .public ov12_0223BCC8 .public ov12_0223BCF0 @@ -211,8 +211,8 @@ .public ov12_022582B8 .public ov12_02261258 .public ov12_02261270 -.public ov12_0226127C -.public ov12_02264BCC +.public OpponentData_GetHpBar +.public BattleHpBar_LoadResources .public ov12_02264C68 .public ov12_02264EE0 .public ov12_02264F28 diff --git a/asm/overlay_12_022378C0.s b/asm/overlay_12_022378C0.s index 5e673176a..244968eda 100644 --- a/asm/overlay_12_022378C0.s +++ b/asm/overlay_12_022378C0.s @@ -989,7 +989,7 @@ _02237FD8: mov r2, #0xc0 bl sub_02009408 add r0, r4, #0 - bl ov12_0223BC48 + bl BattleSystem_HpBar_Init bl ov12_022396F0 mov r0, #5 bl ov07_0221BEDC @@ -3813,7 +3813,7 @@ _022398BE: beq _022398FE _022398D6: add r0, r7, #0 - bl ov12_0226127C + bl OpponentData_GetHpBar add r1, r0, #0 beq _022398FE ldr r0, [r1, #0x28] diff --git a/asm/overlay_12_battle_command.s b/asm/overlay_12_battle_command.s index d81877f02..feb3743d5 100644 --- a/asm/overlay_12_battle_command.s +++ b/asm/overlay_12_battle_command.s @@ -2624,7 +2624,7 @@ _02246E2A: bl SetMonData ldr r0, [r4] mov r1, #0x32 - bl ov12_0223BB28 + bl BattleSystem_GameStatIncrement _02246E5C: add r0, r5, #0 bl sub_0208311C diff --git a/asm/overlay_12_battle_controller_opponent.s b/asm/overlay_12_battle_controller_opponent.s index 42fc94960..7a634d076 100644 --- a/asm/overlay_12_battle_controller_opponent.s +++ b/asm/overlay_12_battle_controller_opponent.s @@ -1809,7 +1809,7 @@ ov12_02259514: ; 0x02259514 cmp r1, r0 beq _02259586 add r0, r5, #0 - bl ov12_0223BC38 + bl BattleSystem_GetHpBar bl ov12_02265D74 _02259586: add r0, r4, #0 @@ -1983,14 +1983,14 @@ ov12_022596B8: ; 0x022596B8 cmp r1, #0 bne _022596E4 ldrh r1, [r4, #2] - bl ov12_0223BB28 + bl BattleSystem_GameStatIncrement b _022596E4 _022596D8: ldrb r1, [r5, r1] cmp r1, #0 beq _022596E4 ldrh r1, [r4, #2] - bl ov12_0223BB28 + bl BattleSystem_GameStatIncrement _022596E4: mov r1, #0x65 lsl r1, r1, #2 @@ -10528,7 +10528,7 @@ ov12_0225DAD4: ; 0x0225DAD4 cmp r1, r0 beq _0225DB16 ldr r0, [r4] - bl ov12_0223BC38 + bl BattleSystem_GetHpBar str r0, [sp, #8] b _0225DB1A _0225DB16: @@ -11423,7 +11423,7 @@ ov12_0225E250: ; 0x0225E250 cmp r1, r0 beq _0225E28A ldr r0, [r4] - bl ov12_0223BC38 + bl BattleSystem_GetHpBar add r5, r0, #0 b _0225E28C _0225E28A: @@ -11803,7 +11803,7 @@ ov12_0225E568: ; 0x0225E568 cmp r1, r0 beq _0225E5A2 ldr r0, [r4] - bl ov12_0223BC38 + bl BattleSystem_GetHpBar add r6, r0, #0 b _0225E5A4 _0225E5A2: @@ -13179,7 +13179,7 @@ _0225F070: ldrb r7, [r0] ldr r0, [r4] add r1, r6, #0 - bl ov12_0223BC38 + bl BattleSystem_GetHpBar mov r1, #0 mov r2, #1 add r5, r0, #0 @@ -13244,7 +13244,7 @@ _0225F10A: ldr r1, [r1, #4] ldrb r1, [r1, #0x11] lsl r1, r1, #1 - bl ov12_0223BC38 + bl BattleSystem_GetHpBar add r5, r0, #0 bl ov12_02264E00 mov r1, #0 @@ -13329,7 +13329,7 @@ _0225F1B2: lsl r7, r0, #1 ldr r0, [r4] add r1, r7, #0 - bl ov12_0223BC38 + bl BattleSystem_GetHpBar str r0, [sp, #0x10] ldr r0, [r4, #8] add r1, r7, #0 @@ -14388,7 +14388,7 @@ ov12_0225FA44: ; 0x0225FA44 cmp r1, r0 beq _0225FA7E ldr r0, [r4] - bl ov12_0223BC38 + bl BattleSystem_GetHpBar add r7, r0, #0 b _0225FA80 _0225FA7E: @@ -17416,11 +17416,11 @@ _02261278: bx lr thumb_func_end ov12_02261270 - thumb_func_start ov12_0226127C -ov12_0226127C: ; 0x0226127C + thumb_func_start OpponentData_GetHpBar +OpponentData_GetHpBar: ; 0x0226127C add r0, #0x28 bx lr - thumb_func_end ov12_0226127C + thumb_func_end OpponentData_GetHpBar thumb_func_start ov12_02261280 ov12_02261280: ; 0x02261280 diff --git a/asm/overlay_12_battle_system.s b/asm/overlay_12_battle_system.s index 697cb67cb..214ddb0ff 100644 --- a/asm/overlay_12_battle_system.s +++ b/asm/overlay_12_battle_system.s @@ -6,325 +6,6 @@ .text - thumb_func_start ov12_0223BAD0 -ov12_0223BAD0: ; 0x0223BAD0 - mov r1, #0x22 - lsl r1, r1, #4 - ldr r0, [r0, r1] - bx lr - thumb_func_end ov12_0223BAD0 - - thumb_func_start ov12_0223BAD8 -ov12_0223BAD8: ; 0x0223BAD8 - mov r1, #0x89 - lsl r1, r1, #2 - ldr r0, [r0, r1] - bx lr - thumb_func_end ov12_0223BAD8 - - thumb_func_start ov12_0223BAE0 -ov12_0223BAE0: ; 0x0223BAE0 - ldr r1, _0223BAE8 ; =0x00002228 - add r0, r0, r1 - bx lr - nop -_0223BAE8: .word 0x00002228 - thumb_func_end ov12_0223BAE0 - - thumb_func_start ov12_0223BAEC -ov12_0223BAEC: ; 0x0223BAEC - ldr r1, _0223BAF4 ; =0x00002308 - add r0, r0, r1 - bx lr - nop -_0223BAF4: .word 0x00002308 - thumb_func_end ov12_0223BAEC - - thumb_func_start BattleSystem_GetWeather -BattleSystem_GetWeather: ; 0x0223BAF8 - ldr r1, _0223BB00 ; =0x0000242C - ldr r0, [r0, r1] - bx lr - nop -_0223BB00: .word 0x0000242C - thumb_func_end BattleSystem_GetWeather - - thumb_func_start ov12_0223BB04 -ov12_0223BB04: ; 0x0223BB04 - ldr r1, _0223BB0C ; =0x00002421 - ldrb r0, [r0, r1] - bx lr - nop -_0223BB0C: .word 0x00002421 - thumb_func_end ov12_0223BB04 - - thumb_func_start ov12_0223BB10 -ov12_0223BB10: ; 0x0223BB10 - ldr r2, _0223BB18 ; =0x00002421 - strb r1, [r0, r2] - bx lr - nop -_0223BB18: .word 0x00002421 - thumb_func_end ov12_0223BB10 - - thumb_func_start ov12_0223BB1C -ov12_0223BB1C: ; 0x0223BB1C - ldr r1, _0223BB24 ; =0x00002430 - ldr r0, [r0, r1] - bx lr - nop -_0223BB24: .word 0x00002430 - thumb_func_end ov12_0223BB1C - - thumb_func_start ov12_0223BB28 -ov12_0223BB28: ; 0x0223BB28 - push {r3, lr} - ldr r2, _0223BB40 ; =0x0000240C - ldr r3, [r0, r2] - mov r2, #0x10 - tst r2, r3 - bne _0223BB3E - mov r2, #0x87 - lsl r2, r2, #2 - ldr r0, [r0, r2] - bl GameStats_Inc -_0223BB3E: - pop {r3, pc} - .balign 4, 0 -_0223BB40: .word 0x0000240C - thumb_func_end ov12_0223BB28 - - thumb_func_start ov12_0223BB44 -ov12_0223BB44: ; 0x0223BB44 - push {r3, lr} - ldr r1, _0223BB60 ; =0x0000240C - ldr r2, [r0, r1] - mov r1, #0x10 - tst r1, r2 - bne _0223BB5C - mov r1, #0x87 - lsl r1, r1, #2 - ldr r0, [r0, r1] - mov r1, #0x15 - bl GameStats_AddSpecial -_0223BB5C: - pop {r3, pc} - nop -_0223BB60: .word 0x0000240C - thumb_func_end ov12_0223BB44 - - thumb_func_start ov12_0223BB64 -ov12_0223BB64: ; 0x0223BB64 - mov r2, #0x91 - lsl r2, r2, #6 - str r1, [r0, r2] - bx lr - thumb_func_end ov12_0223BB64 - - thumb_func_start ov12_0223BB6C -ov12_0223BB6C: ; 0x0223BB6C - ldr r2, _0223BB74 ; =0x00002444 - strb r1, [r0, r2] - bx lr - nop -_0223BB74: .word 0x00002444 - thumb_func_end ov12_0223BB6C - - thumb_func_start ov12_0223BB78 -ov12_0223BB78: ; 0x0223BB78 - mov r1, #0x6f - lsl r1, r1, #2 - ldr r0, [r0, r1] - bx lr - thumb_func_end ov12_0223BB78 - - thumb_func_start ov12_0223BB80 -ov12_0223BB80: ; 0x0223BB80 - mov r2, #0x6f - lsl r2, r2, #2 - str r1, [r0, r2] - bx lr - thumb_func_end ov12_0223BB80 - - thumb_func_start ov12_0223BB88 -ov12_0223BB88: ; 0x0223BB88 - mov r2, #0x1d - lsl r2, r2, #4 - add r2, r0, r2 - lsl r0, r1, #4 - add r0, r2, r0 - bx lr - thumb_func_end ov12_0223BB88 - - thumb_func_start ov12_0223BB94 -ov12_0223BB94: ; 0x0223BB94 - push {r3, r4, r5, lr} - add r5, r1, #0 - add r4, r0, #0 - cmp r5, #4 - blt _0223BBA2 - bl GF_AssertFail -_0223BBA2: - lsl r0, r5, #4 - ldr r0, [r4, r0] - pop {r3, r4, r5, pc} - thumb_func_end ov12_0223BB94 - - thumb_func_start ov12_0223BBA8 -ov12_0223BBA8: ; 0x0223BBA8 - push {r4, r5, r6, lr} - add r4, r1, #0 - add r5, r0, #0 - add r6, r2, #0 - cmp r4, #4 - blt _0223BBB8 - bl GF_AssertFail -_0223BBB8: - lsl r0, r4, #4 - add r0, r5, r0 - str r6, [r0, #4] - pop {r4, r5, r6, pc} - thumb_func_end ov12_0223BBA8 - - thumb_func_start ov12_0223BBC0 -ov12_0223BBC0: ; 0x0223BBC0 - push {r4, r5, r6, lr} - add r4, r1, #0 - add r5, r0, #0 - add r6, r2, #0 - cmp r4, #4 - blt _0223BBD0 - bl GF_AssertFail -_0223BBD0: - lsl r0, r4, #4 - add r0, r5, r0 - str r6, [r0, #8] - pop {r4, r5, r6, pc} - thumb_func_end ov12_0223BBC0 - - thumb_func_start ov12_0223BBD8 -ov12_0223BBD8: ; 0x0223BBD8 - push {r4, r5, r6, lr} - add r4, r1, #0 - add r5, r0, #0 - add r6, r2, #0 - cmp r4, #4 - blt _0223BBE8 - bl GF_AssertFail -_0223BBE8: - lsl r0, r4, #4 - add r0, r5, r0 - str r6, [r0, #0xc] - pop {r4, r5, r6, pc} - thumb_func_end ov12_0223BBD8 - - thumb_func_start ov12_0223BBF0 -ov12_0223BBF0: ; 0x0223BBF0 - ldr r2, _0223BBF8 ; =0x000023FD - strb r1, [r0, r2] - bx lr - nop -_0223BBF8: .word 0x000023FD - thumb_func_end ov12_0223BBF0 - - thumb_func_start ov12_0223BBFC -ov12_0223BBFC: ; 0x0223BBFC - ldr r2, _0223BC04 ; =0x000023F4 - str r1, [r0, r2] - bx lr - nop -_0223BC04: .word 0x000023F4 - thumb_func_end ov12_0223BBFC - - thumb_func_start ov12_0223BC08 -ov12_0223BC08: ; 0x0223BC08 - ldr r2, _0223BC10 ; =0x000023F8 - str r1, [r0, r2] - bx lr - nop -_0223BC10: .word 0x000023F8 - thumb_func_end ov12_0223BC08 - - thumb_func_start ov12_0223BC14 -ov12_0223BC14: ; 0x0223BC14 - ldr r2, _0223BC1C ; =0x000023F4 - ldr r0, [r0, r2] - strb r1, [r0] - bx lr - .balign 4, 0 -_0223BC1C: .word 0x000023F4 - thumb_func_end ov12_0223BC14 - - thumb_func_start ov12_0223BC20 -ov12_0223BC20: ; 0x0223BC20 - ldr r2, _0223BC28 ; =0x000023F8 - ldr r0, [r0, r2] - strb r1, [r0] - bx lr - .balign 4, 0 -_0223BC28: .word 0x000023F8 - thumb_func_end ov12_0223BC20 - - thumb_func_start ov12_0223BC2C -ov12_0223BC2C: ; 0x0223BC2C - ldr r2, _0223BC34 ; =0x000023FE - strb r1, [r0, r2] - bx lr - nop -_0223BC34: .word 0x000023FE - thumb_func_end ov12_0223BC2C - - thumb_func_start ov12_0223BC38 -ov12_0223BC38: ; 0x0223BC38 - lsl r1, r1, #2 - add r0, r0, r1 - ldr r3, _0223BC44 ; =ov12_0226127C - ldr r0, [r0, #0x34] - bx r3 - nop -_0223BC44: .word ov12_0226127C - thumb_func_end ov12_0223BC38 - - thumb_func_start ov12_0223BC48 -ov12_0223BC48: ; 0x0223BC48 - push {r3, r4, r5, r6, r7, lr} - add r6, r0, #0 - ldr r0, [r6, #0x44] - mov r7, #0 - cmp r0, #0 - ble _0223BC94 - add r5, r6, #0 -_0223BC56: - ldr r0, [r5, #0x34] - bl ov12_0226127C - add r4, r0, #0 - str r6, [r4, #0xc] - ldr r0, [r5, #0x34] - bl ov12_02261258 - str r0, [sp] - add r0, r6, #0 - bl BattleSystem_GetBattleType - add r1, r0, #0 - ldr r0, [sp] - bl ov12_02265B64 - add r1, r4, #0 - add r1, #0x25 - strb r0, [r1] - add r0, r4, #0 - bl ov12_02264BCC - add r0, r4, #0 - mov r1, #0 - bl ov12_02264F28 - ldr r0, [r6, #0x44] - add r7, r7, #1 - add r5, r5, #4 - cmp r7, r0 - blt _0223BC56 -_0223BC94: - pop {r3, r4, r5, r6, r7, pc} - .balign 4, 0 - thumb_func_end ov12_0223BC48 - thumb_func_start ov12_0223BC98 ov12_0223BC98: ; 0x0223BC98 push {r3, r4, r5, r6, r7, lr} @@ -337,7 +18,7 @@ ov12_0223BC98: ; 0x0223BC98 mov r7, #1 _0223BCA8: ldr r0, [r5, #0x34] - bl ov12_0226127C + bl OpponentData_GetHpBar ldr r1, [r0, #0x28] cmp r1, #0 beq _0223BCBA @@ -366,7 +47,7 @@ ov12_0223BCC8: ; 0x0223BCC8 add r7, r4, #0 _0223BCD8: ldr r0, [r5, #0x34] - bl ov12_0226127C + bl OpponentData_GetHpBar add r1, r7, #0 bl ov12_02264F28 ldr r0, [r6, #0x44] @@ -389,7 +70,7 @@ ov12_0223BCF0: ; 0x0223BCF0 add r5, r6, #0 _0223BCFE: ldr r0, [r5, #0x34] - bl ov12_0226127C + bl OpponentData_GetHpBar bl ov12_02264C68 ldr r0, [r6, #0x44] add r4, r4, #1 @@ -1156,7 +837,7 @@ ov12_0223C224: ; 0x0223C224 add r5, r6, #0 _0223C234: ldr r0, [r5, #0x34] - bl ov12_0226127C + bl OpponentData_GetHpBar add r1, r7, #0 bl ov12_02264EE0 ldr r0, [r6, #0x44] diff --git a/asm/overlay_12_02264824.s b/asm/overlay_12_hp_bar.s similarity index 99% rename from asm/overlay_12_02264824.s rename to asm/overlay_12_hp_bar.s index d51bccee7..2d8e1b7ba 100644 --- a/asm/overlay_12_02264824.s +++ b/asm/overlay_12_hp_bar.s @@ -484,8 +484,8 @@ _02264BC8: .balign 4, 0 thumb_func_end ov12_02264B94 - thumb_func_start ov12_02264BCC -ov12_02264BCC: ; 0x02264BCC + thumb_func_start BattleHpBar_LoadResources +BattleHpBar_LoadResources: ; 0x02264BCC push {r4, r5, r6, r7, lr} sub sp, #0xc add r5, r0, #0 @@ -555,7 +555,7 @@ _02264C5A: pop {r4, r5, r6, r7, pc} .balign 4, 0 _02264C64: .word ov12_0226D368 - thumb_func_end ov12_02264BCC + thumb_func_end BattleHpBar_LoadResources thumb_func_start ov12_02264C68 ov12_02264C68: ; 0x02264C68 diff --git a/include/battle.h b/include/battle.h index cfddd7d94..f4e7baea2 100644 --- a/include/battle.h +++ b/include/battle.h @@ -6,6 +6,7 @@ #include "bg_window.h" #include "item.h" #include "font.h" +#include "game_stats.h" #include "move.h" #include "options.h" #include "palette.h" @@ -418,35 +419,38 @@ typedef struct BATTLECONTEXT { typedef struct BattleSystem BattleSystem; -typedef struct OpponentData_UnkSub_28 { - u8 unk0; - u32 unk4; - u32 unk8; +typedef struct BattleHpBar { + u8 script; + void *unk4; + void *unk8; BattleSystem *bsys; - u32 unk10; - u8 unk14; - u8 unk15; - u8 unk16; - u8 unk17; - int unk18; - int unk1C; - int unk20; - int unk24; - int unk28; - int unk2C; - int unk30; - int unk34; - u8 unk38; - u8 unk39; - u8 unk3A; + void *unk10; + s32 hp; + s32 maxHp; + s32 damage; + s32 hpCalc; + u8 battlerId; + u8 type; + u8 unk26; + u8 unk27; + s32 exp; + s32 maxExp; + s32 gainedExp; + s32 expCalc; + u8 level; + u8 gender; + u8 status; u8 unk3B; u8 unk3C; u8 unk3D; u8 unk3E; - u8 unk3F_0:1, unk3F_1:1, unk3F_2:1, unk3F_3:1; - u32 unk40; + u8 unk3F_0:1; + u8 unk3F_1:1; + u8 unk3F_2:1; + u8 unk3F_3:1; + void *unk40; u16 unk44; -} OpponentData_UnkSub_28; +} BattleHpBar; typedef struct OpponentData_UnkSub_70 { s8 unk0; @@ -465,7 +469,7 @@ typedef struct OpponentData { u32 *unk1C; u32 *unk20; u32 *unk24; - OpponentData_UnkSub_28 unk28; + BattleHpBar hpBar; OpponentData_UnkSub_70 unk70; u32 unk78; u32 *unk7C; @@ -506,10 +510,6 @@ typedef struct UnkBattleSystemSub220 { int unk8; } UnkBattleSystemSub220; -typedef struct BattleSystemSub_C { - -} BattleSystemSub_C; - struct BattleSystem { u32 *unk0; BgConfig *bgConfig; @@ -557,7 +557,7 @@ struct BattleSystem { u32 *unk1CC; UnkBattleSystemSub1D0 unk1D0[4]; UnkBattleSystemSub220 unk220; - u32 *unk22C; + GAME_STATS *gameStats; u8 *unk230; u16 *unk234; u8 sendBuffer[0x1000]; @@ -589,14 +589,14 @@ struct BattleSystem { u16 unk2422; int unk2424; int unk2428; - int unk242C; + int weather; int unk2430; u32 unk2434; int unk2438; int unk243C; - u8 unk2440; - u8 unk2441; - u32 unk2442; + int unk2440; + u8 unk2442; + u8 unk2445; u32 unk2444; u32 unk2448; u16 unk244C[4]; diff --git a/include/battle/battle_hp_bar.h b/include/battle/battle_hp_bar.h new file mode 100644 index 000000000..4a7d2a27f --- /dev/null +++ b/include/battle/battle_hp_bar.h @@ -0,0 +1,10 @@ +#ifndef POKEHEARTGOLD_BATTLE_HP_BAR_H +#define POKEHEARTGOLD_BATTLE_HP_BAR_H + +#include "battle.h" + +void BattleHpBar_LoadResources(BattleHpBar *hpBar); +void ov12_02264F28(BattleHpBar *hpBar, BOOL a1); +u8 ov12_02265B64(u8 a0, u32 battleType); + +#endif diff --git a/include/battle_system.h b/include/battle_system.h index 10920d497..a0e5f6292 100644 --- a/include/battle_system.h +++ b/include/battle_system.h @@ -79,6 +79,33 @@ void BattleSystem_TryChangeForm(BattleSystem *bsys); void ov12_0223B854(BattleSystem *bsys, int battlerId, int selectedMonIndex); void ov12_0223B870(); void BattleSystem_SetBackground(BattleSystem *bsys); +u8 *ov12_0223BAD0(BattleSystem *bsys); +u16 *ov12_0223BAD8(BattleSystem *bsys); +u16 *ov12_0223BAE0(BattleSystem *bsys); +u16 *ov12_0223BAEC(BattleSystem *bsys); +int BattleSystem_GetWeather(BattleSystem *bsys); +u8 ov12_0223BB04(BattleSystem *bsys); +void ov12_0223BB10(BattleSystem *bsys, u8 a1); +int ov12_0223BB1C(BattleSystem *bsys); +void BattleSystem_GameStatIncrement(BattleSystem *bsys, int id); +void ov12_0223BB44(BattleSystem *bsys); +void ov12_0223BB64(BattleSystem *bsys, int a1); +void ov12_0223BB6C(BattleSystem *bsys, u8 a1); +void *ov12_0223BB78(BattleSystem *bsys); +void ov12_0223BB80(BattleSystem *bsys, void *a1); +UnkBattleSystemSub1D0 *ov12_0223BB88(BattleSystem *bsys, int index); +u8 *ov12_0223BB94(UnkBattleSystemSub1D0 *ptr, int index); +void ov12_0223BBA8(UnkBattleSystemSub1D0 *ptr, int index, int a2); +void ov12_0223BBC0(UnkBattleSystemSub1D0 *ptr, int index, int a2); +void ov12_0223BBD8(UnkBattleSystemSub1D0 *ptr, int index, int a2); +void ov12_0223BBF0(BattleSystem *bsys, u8 a1); +void ov12_0223BBFC(BattleSystem *bsys, u8 *a1); +void ov12_0223BC08(BattleSystem *bsys, u8 *a1); +void ov12_0223BC14(BattleSystem *bsys, u8 a1); +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); //These functions haven't been decompiled int BattleSystem_Random(BattleSystem *bsys); @@ -90,12 +117,12 @@ BOOL ov12_0223C080(BattleSystem *bsys); void ov12_0223BFFC(BattleSystem *bsys, u32 a1); u32 BattleSystem_GetWinLoseFlags(BattleSystem *bsys); void ov12_0223C0C4(BattleSystem *bsys); -int BattleSystem_GetWeather(BattleSystem *bsys); BOOL ov12_0223BFEC(BattleSystem *bsys); -void ov12_0223BB64(BattleSystem *bsys, int a1); void ov12_02237ED0(BattleSystem *bsys, int a1); void ov12_022642F0(BattleSystem *bsys); BOOL ov12_022581BC(BattleSystem *bsys, BATTLECONTEXT *ctx); void ov12_02263A1C(BattleSystem *bsys, BATTLECONTEXT *ctx, int battlerId); void ov12_02266008(UnkBattleSystemSub17C *a0); +BattleHpBar *OpponentData_GetHpBar(OpponentData *opponentData); + #endif diff --git a/main.lsf b/main.lsf index 8d244552b..e75a0d880 100644 --- a/main.lsf +++ b/main.lsf @@ -575,7 +575,7 @@ Overlay OVY_12 Object asm/overlay_12_battle_controller_opponent.o Object asm/overlay_12_02261FD4.o Object asm/overlay_12_battle_controller.o - Object asm/overlay_12_02264824.o + Object asm/overlay_12_hp_bar.o Object asm/overlay_12_02265E28.o Object src/battle/battle_input.o Object asm/overlay_12_02266024.o diff --git a/src/battle/battle_system.c b/src/battle/battle_system.c index b0eb890d2..2cd662a1f 100644 --- a/src/battle/battle_system.c +++ b/src/battle/battle_system.c @@ -1,4 +1,5 @@ #include "global.h" +#include "battle/battle_hp_bar.h" #include "battle_controller_opponent.h" #include "battle_system.h" #include "party.h" @@ -881,3 +882,130 @@ void BattleSystem_SetBackground(BattleSystem *bsys) { ov12_02266008(&bsys->unk17C[0]); ov12_02266008(&bsys->unk17C[1]); } + +u8 *ov12_0223BAD0(BattleSystem *bsys) { + return bsys->unk230; +} + +u16 *ov12_0223BAD8(BattleSystem *bsys) { + return bsys->unk234; +} + +u16 *ov12_0223BAE0(BattleSystem *bsys) { + return &bsys->unk2238[0]; +} + +u16 *ov12_0223BAEC(BattleSystem *bsys) { + return &bsys->unk2318[0]; +} + +int BattleSystem_GetWeather(BattleSystem *bsys) { + return bsys->weather; +} + +u8 ov12_0223BB04(BattleSystem *bsys) { + return bsys->unk2421; +} + +void ov12_0223BB10(BattleSystem *bsys, u8 a1) { + bsys->unk2421 = a1; +} + +int ov12_0223BB1C(BattleSystem *bsys) { + return bsys->unk2430; +} + +void BattleSystem_GameStatIncrement(BattleSystem *bsys, int id) { + if (bsys->battleSpecial & BATTLE_SPECIAL_RECORDED) { + return; + } + GameStats_Inc(bsys->gameStats, id); +} + +void ov12_0223BB44(BattleSystem *bsys) { + if (bsys->battleSpecial & BATTLE_SPECIAL_RECORDED) { + return; + } + GameStats_AddSpecial(bsys->gameStats, 21); +} + +void ov12_0223BB64(BattleSystem *bsys, int a1) { + bsys->unk2440 = a1; +} + +void ov12_0223BB6C(BattleSystem *bsys, u8 a1) { + bsys->unk2442 = a1; +} + +void *ov12_0223BB78(BattleSystem *bsys) { + return bsys->unk1BC; +} + +void ov12_0223BB80(BattleSystem *bsys, void *a1) { + bsys->unk1BC = a1; +} + +UnkBattleSystemSub1D0 *ov12_0223BB88(BattleSystem *bsys, int index) { + return &bsys->unk1D0[index]; +} + +u8 *ov12_0223BB94(UnkBattleSystemSub1D0 *ptr, int index) { + GF_ASSERT(index < 4); + return ptr[index].unk0; +} + +void ov12_0223BBA8(UnkBattleSystemSub1D0 *ptr, int index, int a2) { + GF_ASSERT(index < 4); + ptr[index].unk4 = a2; +} + +void ov12_0223BBC0(UnkBattleSystemSub1D0 *ptr, int index, int a2) { + GF_ASSERT(index < 4); + ptr[index].unk8 = a2; +} + +void ov12_0223BBD8(UnkBattleSystemSub1D0 *ptr, int index, int a2) { + GF_ASSERT(index < 4); + ptr[index].unkC = a2; +} + +void ov12_0223BBF0(BattleSystem *bsys, u8 a1) { + bsys->unk23FD = a1; +} + +void ov12_0223BBFC(BattleSystem *bsys, u8 *a1) { + bsys->unk23F4 = a1; +} + +void ov12_0223BC08(BattleSystem *bsys, u8 *a1) { + bsys->unk23F8 = a1; +} + +void ov12_0223BC14(BattleSystem *bsys, u8 a1) { + *bsys->unk23F4 = a1; +} + +void ov12_0223BC20(BattleSystem *bsys, u8 a1) { + *bsys->unk23F8 = a1; +} + +void ov12_0223BC2C(BattleSystem *bsys, u8 a1) { + bsys->unk23FE = a1; +} + +BattleHpBar *BattleSystem_GetHpBar(BattleSystem *bsys, int battlerId) { + return OpponentData_GetHpBar(bsys->opponentData[battlerId]); +} + +void BattleSystem_HpBar_Init(BattleSystem *bsys) { + int i; + BattleHpBar *hpBar; + + for (i = 0; i < bsys->maxBattlers; i++) { + hpBar = OpponentData_GetHpBar(bsys->opponentData[i]); + hpBar->bsys = bsys; + hpBar->type = ov12_02265B64(ov12_02261258(bsys->opponentData[i]), BattleSystem_GetBattleType(bsys)); + BattleHpBar_LoadResources(hpBar); + ov12_02264F28(hpBar, FALSE); + } +}