From 453be7ae90d02485609479992f8ea3d988905d22 Mon Sep 17 00:00:00 2001 From: Adrienn Tindall <33725376+adrienntindall@users.noreply.github.com> Date: Wed, 18 Oct 2023 13:13:32 -0400 Subject: [PATCH 01/33] Add GX Plane Mask constants --- asm/overlay_12_022378C0.s | 112 --------------------------- include/battle/battle_022378C0.h | 2 + include/battle/overlay_12_02266024.h | 5 +- include/render_text.h | 1 + include/unk_02026E84.h | 7 ++ lib/include/nitro/gx/gx.h | 9 +++ src/battle/battle_022378C0.c | 45 +++++++++++ 7 files changed, 68 insertions(+), 113 deletions(-) create mode 100644 include/unk_02026E84.h diff --git a/asm/overlay_12_022378C0.s b/asm/overlay_12_022378C0.s index 8f10e56fba..2d9dd14b9b 100644 --- a/asm/overlay_12_022378C0.s +++ b/asm/overlay_12_022378C0.s @@ -7,118 +7,6 @@ .text - thumb_func_start ov12_02237BB8 -ov12_02237BB8: ; 0x02237BB8 - push {r4, r5, r6, lr} - sub sp, #8 - add r5, r0, #0 - ldr r0, _02237CB0 ; =FS_OVERLAY_ID(OVY_8) - bl UnloadOverlayByID - ldr r0, _02237CB4 ; =0x00002445 - ldrb r0, [r5, r0] - cmp r0, #0 - bne _02237BD6 - ldr r0, _02237CB8 ; =FS_OVERLAY_ID(OVY_7) - mov r1, #2 - bl HandleLoadOverlay - b _02237BDE -_02237BD6: - ldr r0, _02237CBC ; =FS_OVERLAY_ID(OVY_10) - mov r1, #2 - bl HandleLoadOverlay -_02237BDE: - add r0, r5, #0 - mov r1, #0 - bl ov12_0223BBF0 - bl sub_02026E9C - add r4, r0, #0 - bl sub_02026E94 - add r1, r0, #0 - mov r0, #0 - add r2, r4, #0 - bl MIi_CpuClear16 - mov r0, #7 - mov r1, #5 - bl NARC_New - add r6, r0, #0 - mov r0, #8 - mov r1, #5 - bl NARC_New - add r4, r0, #0 - add r0, r5, #0 - bl ov12_0223BFC0 - add r1, r0, #0 - add r0, r5, #0 - bl BattleSystem_GetTrainerGender - add r3, r0, #0 - mov r0, #7 - lsl r0, r0, #6 - ldr r0, [r5, r0] - add r1, r4, #0 - str r0, [sp] - add r0, r6, #0 - add r2, r5, #0 - bl ov12_022660D0 - mov r1, #0x67 - lsl r1, r1, #2 - str r0, [r5, r1] - mov r0, #4 - mov r1, #5 - bl FontID_Alloc - ldr r1, _02237CC0 ; =0x000023FF - mov r0, #2 - ldrb r2, [r5, r1] - orr r0, r2 - strb r0, [r5, r1] - ldr r0, [r5, #4] - bl ov12_0226604C - mov r0, #0x10 - mov r1, #1 - bl GX_EngineBToggleLayers - mov r0, #0x67 - lsl r0, r0, #2 - ldr r0, [r5, r0] - bl ov12_02266390 - mov r0, #1 - str r0, [sp] - mov r3, #0 - mov r2, #0x67 - str r3, [sp, #4] - lsl r2, r2, #2 - ldr r2, [r5, r2] - add r0, r6, #0 - add r1, r4, #0 - bl ov12_02266508 - mov r1, #0x67 - lsl r1, r1, #2 - ldr r1, [r5, r1] - add r0, r4, #0 - bl ov12_02266644 - add r0, r6, #0 - bl NARC_Delete - add r0, r4, #0 - bl NARC_Delete - mov r0, #1 - bl sub_020027F0 - add r0, r5, #0 - bl ov12_0223A620 - add r5, #0x90 - ldr r0, [r5] - bl SpriteRenderer_GetG2dRendererPtr - mov r2, #0x11 - mov r1, #0 - lsl r2, r2, #0x10 - bl G2dRenderer_SetSubSurfaceCoords - add sp, #8 - pop {r4, r5, r6, pc} - .balign 4, 0 -_02237CB0: .word FS_OVERLAY_ID(OVY_8) -_02237CB4: .word 0x00002445 -_02237CB8: .word FS_OVERLAY_ID(OVY_7) -_02237CBC: .word FS_OVERLAY_ID(OVY_10) -_02237CC0: .word 0x000023FF - thumb_func_end ov12_02237BB8 - thumb_func_start ov12_02237CC4 ov12_02237CC4: ; 0x02237CC4 push {r4, lr} diff --git a/include/battle/battle_022378C0.h b/include/battle/battle_022378C0.h index 90f8bc5c28..36441f16a7 100644 --- a/include/battle/battle_022378C0.h +++ b/include/battle/battle_022378C0.h @@ -8,6 +8,7 @@ BOOL Battle_Main(OVY_MANAGER *man, int *state); void ov12_02237B0C(BattleSystem *bsys); void ov12_02237B6C(BattleSystem *bsys); +void ov12_02237BB8(BattleSystem *bsys); //the following functions are static and have yet to be decompiled void ov12_022399D4(OVY_MANAGER *man, BattleSetup *setup); @@ -24,6 +25,7 @@ BOOL ov12_0223A3F0(OVY_MANAGER *man); BOOL ov12_0223A5E4(OVY_MANAGER *man); void ov12_0226631C(u32 *); void ov12_022660A8(BgConfig *); +void ov12_0223A620(BattleSystem *bsys); //the following functions aren't static/haven't been checked to their status and are yet to be decompiled void ov12_02238A30(BgConfig *config); diff --git a/include/battle/overlay_12_02266024.h b/include/battle/overlay_12_02266024.h index ad6ef39758..57b0ef454e 100644 --- a/include/battle/overlay_12_02266024.h +++ b/include/battle/overlay_12_02266024.h @@ -4,8 +4,11 @@ #include "battle/battle.h" #include "filesystem.h" -void ov12_02266508(NARC *a0, NARC *a1, u32 *a2, u32 a3, BOOL a4, void *a5); +void *ov12_022660D0(NARC *a0, NARC *a1, BattleSystem *bsys, u32 gender, void *a4); BOOL ov12_02266C64(u32 *a0); BOOL ov12_02266B78(u32 *a0); +void ov12_02266390(void *); +void ov12_02266508(NARC *a0, NARC *a1, void *a2, int a3, BOOL a4, void *a5); +void ov12_02266644(NARC *a0, void *a1); #endif diff --git a/include/render_text.h b/include/render_text.h index 3b021bda40..1c2a472080 100644 --- a/include/render_text.h +++ b/include/render_text.h @@ -17,5 +17,6 @@ BOOL RenderText(struct TextPrinter *printer); void TextFlags_SetCanABSpeedUpPrint(BOOL enable); void sub_02002B50(BOOL enable); void sub_02002B8C(BOOL enable); +void sub_020027F0(); #endif //POKEHEARTGOLD_RENDER_TEXT_H diff --git a/include/unk_02026E84.h b/include/unk_02026E84.h new file mode 100644 index 0000000000..a229865f97 --- /dev/null +++ b/include/unk_02026E84.h @@ -0,0 +1,7 @@ +#ifndef POKEHEARTGOLD_UNK_02026E84_H +#define POKEHEARTGOLD_UNK_02026E84_H + +int sub_02026E9C(void); +void *sub_02026E94(void); + +#endif //POKEHEARTGOLD_UNK_02026E84_H diff --git a/lib/include/nitro/gx/gx.h b/lib/include/nitro/gx/gx.h index d34ed3e507..d95d57ba41 100644 --- a/lib/include/nitro/gx/gx.h +++ b/lib/include/nitro/gx/gx.h @@ -25,6 +25,15 @@ typedef enum { GX_BGMODE_6 = 6 } GXBGMode; +typedef enum { + GX_PLANEMASK_NONE = 0, + GX_PLANEMASK_BG0 = (1 << 0), + GX_PLANEMASK_BG1 = (1 << 1), + GX_PLANEMASK_BG2 = (1 << 2), + GX_PLANEMASK_BG3 = (1 << 3), + GX_PLANEMASK_OBJ = (1 << 4) +} GXPlaneMask; + typedef enum { GX_BG0_AS_2D = 0, GX_BG0_AS_3D = 1 diff --git a/src/battle/battle_022378C0.c b/src/battle/battle_022378C0.c index 03718008fd..d636a7678b 100644 --- a/src/battle/battle_022378C0.c +++ b/src/battle/battle_022378C0.c @@ -1,12 +1,18 @@ #include "battle/battle_022378C0.h" +#include "battle/overlay_12_02266024.h" #include "battle/battle_system.h" +#include "battle/battle_input.h" +#include "render_text.h" #include "system.h" #include "vram_transfer_manager.h" #include "unk_02037C94.h" #include "unk_02004A44.h" #include "unk_020379A0.h" #include "unk_020755E8.h" +#include "unk_02026E84.h" +#include "gx_layers.h" #include "constants/game_stats.h" +#include "filesystem_files_def.h" FS_EXTERN_OVERLAY(OVY_5); FS_EXTERN_OVERLAY(OVY_6); @@ -187,3 +193,42 @@ void ov12_02237B6C(BattleSystem *bsys) { GF_DestroyVramTransferManager(); FontID_Release(4); } + +void ov12_02237BB8(BattleSystem *bsys) { + UnloadOverlayByID(FS_OVERLAY_ID(OVY_8)); + + if (bsys->unk2445 == 0) { + HandleLoadOverlay(FS_OVERLAY_ID(OVY_7), OVY_LOAD_ASYNC); + } else { + HandleLoadOverlay(FS_OVERLAY_ID(OVY_10), OVY_LOAD_ASYNC); + } + + ov12_0223BBF0(bsys, 0); + + int size = sub_02026E9C(); + void *data = sub_02026E94(); + MIi_CpuClear16(0, data, size); + + NARC *unkNarcA = NARC_New(NARC_a_0_0_7, HEAP_ID_BATTLE); + NARC *unkNarcB = NARC_New(NARC_a_0_0_8, HEAP_ID_BATTLE); + + bsys->unk19C = ov12_022660D0(unkNarcA, unkNarcB, bsys, BattleSystem_GetTrainerGender(bsys, ov12_0223BFC0(bsys)), bsys->unk1C0); + + FontID_Alloc(4, HEAP_ID_BATTLE); + + bsys->unk240F_1 = 1; + + ov12_0226604C(bsys->bgConfig); + GX_EngineBToggleLayers((int) GX_PLANEMASK_OBJ, GX_LAYER_TOGGLE_ON); + ov12_02266390(bsys->unk19C); + ov12_02266508(unkNarcA, unkNarcB, bsys->unk19C, 0, TRUE, NULL); + ov12_02266644(unkNarcB, bsys->unk19C); + + NARC_Delete(unkNarcA); + NARC_Delete(unkNarcB); + + sub_020027F0(1); + ov12_0223A620(bsys); + + G2dRenderer_SetSubSurfaceCoords(SpriteRenderer_GetG2dRendererPtr(bsys->unk90), 0, 17 << 16); +} From 3d56715df708834171493c0db36ef666ab019e28 Mon Sep 17 00:00:00 2001 From: Adrienn Tindall <33725376+adrienntindall@users.noreply.github.com> Date: Fri, 3 Nov 2023 15:05:52 -0400 Subject: [PATCH 02/33] Port exp function from plat Co-Authored-By: Rachel --- asm/overlay_12_022378C0.s | 27 - asm/overlay_12_battle_command.s | 1383 +--------------------------- include/battle/battle.h | 6 +- include/battle/battle_022378C0.h | 1 + include/battle/battle_command.h | 3 + include/battle/battle_controller.h | 5 + include/battle/battle_system.h | 1 + include/render_window.h | 2 + src/battle/battle_022378C0.c | 13 + src/battle/battle_command.c | 569 +++++++++++- 10 files changed, 601 insertions(+), 1409 deletions(-) diff --git a/asm/overlay_12_022378C0.s b/asm/overlay_12_022378C0.s index 2d9dd14b9b..ff60e71e5a 100644 --- a/asm/overlay_12_022378C0.s +++ b/asm/overlay_12_022378C0.s @@ -7,33 +7,6 @@ .text - thumb_func_start ov12_02237CC4 -ov12_02237CC4: ; 0x02237CC4 - push {r4, lr} - add r4, r0, #0 - ldr r0, [r4, #8] - bl RemoveWindow - mov r0, #1 - mov r1, #0 - bl GX_EngineAToggleLayers - mov r0, #2 - mov r1, #0 - bl GX_EngineAToggleLayers - ldr r0, [r4, #4] - mov r1, #1 - bl FreeBgTilemapBuffer - ldr r0, [r4, #4] - mov r1, #2 - bl FreeBgTilemapBuffer - ldr r0, [r4, #4] - mov r1, #3 - bl FreeBgTilemapBuffer - add r0, r4, #0 - bl BattleSystem_SetHpBarDisabled - pop {r4, pc} - .balign 4, 0 - thumb_func_end ov12_02237CC4 - thumb_func_start ov12_02237D00 ov12_02237D00: ; 0x02237D00 push {r4, r5, r6, lr} diff --git a/asm/overlay_12_battle_command.s b/asm/overlay_12_battle_command.s index 8b08b4b8b9..c1ab8a8e22 100644 --- a/asm/overlay_12_battle_command.s +++ b/asm/overlay_12_battle_command.s @@ -10,1385 +10,6 @@ .text - thumb_func_start Task_GetExp -Task_GetExp: ; 0x02245898 - push {r3, r4, r5, r6, r7, lr} - sub sp, #0xd8 - add r4, r1, #0 - str r0, [sp, #0x14] - ldr r0, [r4] - bl ov12_0223A930 - str r0, [sp, #0x40] - ldr r0, [r4] - bl BattleSystem_GetBattleType - str r0, [sp, #0x3c] - ldr r0, [r4, #4] - mov r7, #0 - ldr r0, [r0, #0x74] - ldr r5, [r4, #0x48] - asr r1, r0, #1 - mov r0, #1 - and r0, r1 - str r0, [sp, #0x44] - ldr r0, [r4] - add r1, r7, #0 - bl BattleSystem_GetPartySize - cmp r5, r0 - bge _0224591A - ldr r0, [sp, #0x44] - lsl r0, r0, #2 - str r0, [sp, #0x28] -_022458D2: - ldr r0, [r4] - mov r1, #0 - add r2, r5, #0 - bl BattleSystem_GetPartyMon - mov r1, #6 - mov r2, #0 - add r6, r0, #0 - bl GetMonData - lsl r0, r0, #0x10 - lsr r0, r0, #0x10 - mov r1, #1 - mov r2, #5 - bl GetItemAttr - cmp r0, #0x33 - beq _0224591A - add r0, r5, #0 - bl MaskOfFlagNo - add r2, r0, #0 - ldr r1, [r4, #4] - ldr r0, [sp, #0x28] - add r0, r0, r1 - add r0, #0xa4 - ldr r0, [r0] - tst r0, r2 - bne _0224591A - ldr r0, [r4] - mov r1, #0 - add r5, r5, #1 - bl BattleSystem_GetPartySize - cmp r5, r0 - blt _022458D2 -_0224591A: - ldr r0, [r4] - mov r1, #0 - bl BattleSystem_GetPartySize - cmp r5, r0 - bne _0224592C - mov r0, #0x26 - str r0, [r4, #0x28] - b _02245948 -_0224592C: - ldr r0, [sp, #0x3c] - mov r2, #2 - tst r0, r2 - beq _02245948 - ldr r0, [sp, #0x3c] - mov r1, #0x40 - tst r0, r1 - bne _02245948 - ldr r1, [r4, #4] - ldr r0, _02245C30 ; =0x0000219E - ldrb r0, [r1, r0] - cmp r0, r5 - bne _02245948 - add r7, r2, #0 -_02245948: - ldr r0, [r4, #0x28] - cmp r0, #0x26 - bls _02245952 - bl _022463B6 -_02245952: - add r0, r0, r0 - add r0, pc - ldrh r0, [r0, #6] - lsl r0, r0, #0x10 - asr r0, r0, #0x10 - add pc, r0 -_0224595E: ; jump table - .short _022459AC - _0224595E - 2 ; case 0 - .short _02245B7E - _0224595E - 2 ; case 1 - .short _02245B96 - _0224595E - 2 ; case 2 - .short _02245BA8 - _0224595E - 2 ; case 3 - .short _02245BD4 - _0224595E - 2 ; case 4 - .short _02245BE8 - _0224595E - 2 ; case 5 - .short _02245C20 - _0224595E - 2 ; case 6 - .short _02245D28 - _0224595E - 2 ; case 7 - .short _02245D44 - _0224595E - 2 ; case 8 - .short _02245D62 - _0224595E - 2 ; case 9 - .short _02245E0A - _0224595E - 2 ; case 10 - .short _02245F4A - _0224595E - 2 ; case 11 - .short _02245EC8 - _0224595E - 2 ; case 12 - .short _02245F4A - _0224595E - 2 ; case 13 - .short _02245F6C - _0224595E - 2 ; case 14 - .short _02245FCE - _0224595E - 2 ; case 15 - .short _02246082 - _0224595E - 2 ; case 16 - .short _022460E2 - _0224595E - 2 ; case 17 - .short _022460B4 - _0224595E - 2 ; case 18 - .short _022460E2 - _0224595E - 2 ; case 19 - .short _022460FA - _0224595E - 2 ; case 20 - .short _0224611A - _0224595E - 2 ; case 21 - .short _02246162 - _0224595E - 2 ; case 22 - .short _02246186 - _0224595E - 2 ; case 23 - .short _02246272 - _0224595E - 2 ; case 24 - .short _022460E2 - _0224595E - 2 ; case 25 - .short _0224629A - _0224595E - 2 ; case 26 - .short _022460E2 - _0224595E - 2 ; case 27 - .short _022462D6 - _0224595E - 2 ; case 28 - .short _022460E2 - _0224595E - 2 ; case 29 - .short _022462FE - _0224595E - 2 ; case 30 - .short _022461BE - _0224595E - 2 ; case 31 - .short _022460E2 - _0224595E - 2 ; case 32 - .short _022461E8 - _0224595E - 2 ; case 33 - .short _0224620A - _0224595E - 2 ; case 34 - .short _0224625A - _0224595E - 2 ; case 35 - .short _02246364 - _0224595E - 2 ; case 36 - .short _0224637A - _0224595E - 2 ; case 37 - .short _022463A0 - _0224595E - 2 ; case 38 -_022459AC: - add r0, r6, #0 - mov r1, #6 - mov r2, #0 - bl GetMonData - lsl r0, r0, #0x10 - lsr r0, r0, #0x10 - mov r1, #1 - mov r2, #5 - bl GetItemAttr - str r0, [sp, #0x18] - ldr r0, [sp, #0x3c] - mov r1, #1 - and r0, r1 - str r0, [sp, #0x20] - bne _02245A0A - ldr r1, [r4, #4] - ldr r0, _02245C34 ; =0x00002E4C - ldr r2, _02245C38 ; =0x00002FCC - ldr r0, [r1, r0] - ldr r1, [r1, r2] - add r0, r0, r1 - bne _02245A0A - add r0, r6, #0 - mov r1, #0xa3 - mov r2, #0 - bl GetMonData - cmp r0, #0 - beq _02245A0A - ldr r1, [r4, #4] - ldr r0, _02245C3C ; =0x00003144 - ldr r0, [r1, r0] - cmp r0, #0 - bne _02245A0A - ldr r0, _02245C40 ; =SEQ_GS_WIN2 - bl PlayBGM - ldr r1, [r4, #4] - ldr r0, _02245C3C ; =0x00003144 - mov r2, #1 - str r2, [r1, r0] - ldr r0, [r4] - mov r1, #2 - bl BattleSystem_SetCriticalHpMusicFlag -_02245A0A: - mov r0, #0 - str r0, [sp, #0x38] - mov r1, #1 - add r0, sp, #0xb4 - strh r1, [r0, #2] - ldr r2, [sp, #0x38] - add r0, r6, #0 - mov r1, #0xa3 - bl GetMonData - cmp r0, #0 - beq _02245A30 - add r0, r6, #0 - mov r1, #0xa1 - mov r2, #0 - bl GetMonData - cmp r0, #0x64 - bne _02245A32 -_02245A30: - b _02245B3E -_02245A32: - ldr r0, [r4, #4] - str r0, [sp, #0x24] - add r0, r5, #0 - bl MaskOfFlagNo - ldr r1, [sp, #0x44] - lsl r2, r1, #2 - ldr r1, [sp, #0x24] - add r1, r1, r2 - add r1, #0xa4 - ldr r1, [r1] - tst r0, r1 - beq _02245A54 - ldr r0, [sp, #0x24] - add r0, #0x9c - ldr r0, [r0] - str r0, [sp, #0x38] -_02245A54: - ldr r0, [sp, #0x18] - cmp r0, #0x33 - bne _02245A68 - ldr r0, [sp, #0x24] - add r0, #0xa0 - str r0, [sp, #0x24] - ldr r1, [r0] - ldr r0, [sp, #0x38] - add r0, r0, r1 - str r0, [sp, #0x38] -_02245A68: - ldr r0, [sp, #0x18] - cmp r0, #0x42 - bne _02245A7C - ldr r1, [sp, #0x38] - mov r0, #0x96 - mul r0, r1 - mov r1, #0x64 - bl _u32_div_f - str r0, [sp, #0x38] -_02245A7C: - ldr r0, [sp, #0x20] - cmp r0, #0 - beq _02245A90 - ldr r1, [sp, #0x38] - mov r0, #0x96 - mul r0, r1 - mov r1, #0x64 - bl _u32_div_f - str r0, [sp, #0x38] -_02245A90: - ldr r0, [r4] - add r1, r6, #0 - bl ov12_022568B0 - cmp r0, #0 - bne _02245AD2 - add r0, r6, #0 - mov r1, #0xc - mov r2, #0 - bl GetMonData - ldr r1, _02245C44 ; =gGameLanguage - ldrb r1, [r1] - cmp r1, r0 - beq _02245ABE - ldr r1, [sp, #0x38] - mov r0, #0xaa - mul r0, r1 - mov r1, #0x64 - bl _u32_div_f - str r0, [sp, #0x38] - b _02245ACC -_02245ABE: - ldr r1, [sp, #0x38] - mov r0, #0x96 - mul r0, r1 - mov r1, #0x64 - bl _u32_div_f - str r0, [sp, #0x38] -_02245ACC: - mov r1, #2 - add r0, sp, #0xb4 - strh r1, [r0, #2] -_02245AD2: - add r0, r6, #0 - mov r1, #8 - mov r2, #0 - bl GetMonData - str r0, [sp, #0x4c] - add r0, r6, #0 - bl GetMonBaseExperienceAtCurrentLevel - ldr r1, [sp, #0x4c] - sub r0, r1, r0 - str r0, [r4, #0x3c] - ldr r1, [sp, #0x4c] - ldr r0, [sp, #0x38] - add r2, r1, r0 - str r2, [sp, #0x4c] - ldr r3, [r4, #4] - ldr r0, _02245C48 ; =0x0000219C - add r1, r3, r7 - ldrb r0, [r1, r0] - cmp r5, r0 - bne _02245B08 - mov r0, #0xc0 - mul r0, r7 - add r1, r3, r0 - ldr r0, _02245C4C ; =0x00002DA4 - str r2, [r1, r0] -_02245B08: - add r0, r6, #0 - mov r1, #8 - add r2, sp, #0x4c - bl SetMonData - ldr r0, [r4, #4] - ldr r1, [r0, #0x74] - str r0, [sp, #0x1c] - add r6, r1, #0 - mov r0, #0xc0 - mul r6, r0 - ldr r0, [r4] - add r1, r7, #0 - bl BattleSystem_GetParty - ldr r2, [sp, #0x1c] - mov r3, #0xb5 - add r6, r2, r6 - lsl r3, r3, #6 - ldrh r2, [r6, r3] - add r3, #0x26 - ldrb r3, [r6, r3] - add r1, r5, #0 - lsl r3, r3, #0x1b - lsr r3, r3, #0x1b - bl ov12_022463E8 -_02245B3E: - ldr r0, [sp, #0x38] - cmp r0, #0 - beq _02245B76 - mov r1, #0x11 - add r0, sp, #0xb4 - strb r1, [r0, #1] - lsl r0, r5, #8 - orr r0, r7 - str r0, [sp, #0xb8] - ldr r0, [sp, #0x38] - str r0, [sp, #0xbc] - ldr r0, [r4] - bl BattleSystem_GetTextFrameDelay - add r3, r0, #0 - ldr r0, [r4] - ldr r1, [sp, #0x40] - add r2, sp, #0xb4 - bl ov12_0223C494 - str r0, [r4, #0x30] - mov r0, #7 - str r0, [r4, #0x34] - ldr r0, [r4, #0x28] - add sp, #0xd8 - add r0, r0, #1 - str r0, [r4, #0x28] - pop {r3, r4, r5, r6, r7, pc} -_02245B76: - mov r0, #0x25 - add sp, #0xd8 - str r0, [r4, #0x28] - pop {r3, r4, r5, r6, r7, pc} -_02245B7E: - ldr r0, [r4, #0x30] - lsl r0, r0, #0x18 - lsr r0, r0, #0x18 - bl TextPrinterCheckActive - cmp r0, #0 - bne _02245C2A - ldr r0, [r4, #0x28] - add sp, #0xd8 - add r0, r0, #1 - str r0, [r4, #0x28] - pop {r3, r4, r5, r6, r7, pc} -_02245B96: - ldr r0, [r4, #0x34] - sub r0, r0, #1 - str r0, [r4, #0x34] - bne _02245C2A - ldr r0, [r4, #0x28] - add sp, #0xd8 - add r0, r0, #1 - str r0, [r4, #0x28] - pop {r3, r4, r5, r6, r7, pc} -_02245BA8: - ldr r1, [r4, #4] - ldr r0, _02245C48 ; =0x0000219C - add r2, r1, r7 - ldrb r0, [r2, r0] - cmp r5, r0 - bne _02245BCC - ldr r0, [r4] - ldr r3, [r4, #0x3c] - add r2, r7, #0 - bl ov12_02263564 - mov r0, #0 - str r0, [r4, #0x3c] - ldr r0, [r4, #0x28] - add sp, #0xd8 - add r0, r0, #1 - str r0, [r4, #0x28] - pop {r3, r4, r5, r6, r7, pc} -_02245BCC: - mov r0, #5 - add sp, #0xd8 - str r0, [r4, #0x28] - pop {r3, r4, r5, r6, r7, pc} -_02245BD4: - ldr r0, [r4, #4] - bl Link_QueueNotEmpty - cmp r0, #0 - beq _02245C2A - ldr r0, [r4, #0x28] - add sp, #0xd8 - add r0, r0, #1 - str r0, [r4, #0x28] - pop {r3, r4, r5, r6, r7, pc} -_02245BE8: - add r0, r6, #0 - bl Pokemon_TryLevelUp - cmp r0, #0 - beq _02245C18 - ldr r1, [r4, #4] - ldr r0, _02245C48 ; =0x0000219C - add r2, r1, r7 - ldrb r0, [r2, r0] - cmp r5, r0 - bne _02245C10 - ldr r0, [r4] - add r2, r7, #0 - mov r3, #8 - bl BattleController_EmitSetStatus2Effect - ldr r0, [r4] - add r1, r7, #0 - bl ov12_0226399C -_02245C10: - mov r0, #6 - add sp, #0xd8 - str r0, [r4, #0x28] - pop {r3, r4, r5, r6, r7, pc} -_02245C18: - mov r0, #0x25 - add sp, #0xd8 - str r0, [r4, #0x28] - pop {r3, r4, r5, r6, r7, pc} -_02245C20: - ldr r0, [r4, #4] - bl Link_QueueNotEmpty - cmp r0, #0 - bne _02245C2C -_02245C2A: - b _022463B6 -_02245C2C: - ldr r2, _02245C50 ; =ov12_0226C354 - b _02245C54 - .balign 4, 0 -_02245C30: .word 0x0000219E -_02245C34: .word 0x00002E4C -_02245C38: .word 0x00002FCC -_02245C3C: .word 0x00003144 -_02245C40: .word SEQ_GS_WIN2 -_02245C44: .word gGameLanguage -_02245C48: .word 0x0000219C -_02245C4C: .word 0x00002DA4 -_02245C50: .word ov12_0226C354 -_02245C54: - add r3, sp, #0x9c - ldmia r2!, {r0, r1} - stmia r3!, {r0, r1} - ldmia r2!, {r0, r1} - stmia r3!, {r0, r1} - ldmia r2!, {r0, r1} - stmia r3!, {r0, r1} - add r0, r6, #0 - mov r1, #0xa1 - mov r2, #0 - bl GetMonData - str r0, [sp, #0x34] - mov r0, #5 - mov r1, #0x18 - bl AllocFromHeap - mov r1, #0x5f - ldr r2, [r4, #4] - lsl r1, r1, #2 - str r0, [r2, r1] - ldr r0, [r4, #4] - ldr r0, [r0, r1] - mov r1, #0 - str r0, [sp, #0x30] - str r1, [sp, #0x50] -_02245C88: - lsl r2, r1, #2 - add r1, sp, #0x9c - ldr r1, [r1, r2] - add r0, r6, #0 - mov r2, #0 - bl GetMonData - ldr r1, [sp, #0x50] - lsl r2, r1, #2 - ldr r1, [sp, #0x30] - str r0, [r1, r2] - ldr r0, [sp, #0x50] - add r1, r0, #1 - str r1, [sp, #0x50] - cmp r1, #6 - blt _02245C88 - ldr r0, [r4] - bl BattleSystem_GetLocation - add r2, r0, #0 - lsl r2, r2, #0x10 - add r0, r6, #0 - mov r1, #0 - lsr r2, r2, #0x10 - bl MonApplyFriendshipMod - add r0, r6, #0 - mov r1, #0 - bl ApplyMonMoodModifier - add r0, r6, #0 - bl CalcMonStats - ldr r1, [r4, #4] - ldr r0, _02246010 ; =0x0000219C - add r2, r1, r7 - ldrb r3, [r2, r0] - cmp r5, r3 - bne _02245CDE - ldr r0, [r4] - add r2, r7, #0 - bl BattleSystem_ReloadMonData -_02245CDE: - add r0, r5, #0 - bl MaskOfFlagNo - ldr r1, [r4, #4] - ldr r2, _02246014 ; =0x00003109 - ldrb r3, [r1, r2] - orr r0, r3 - strb r0, [r1, r2] - ldr r0, [r4] - ldr r1, [r4, #4] - add r2, r7, #0 - bl ov12_02263A1C - mov r1, #3 - add r0, sp, #0xb4 - strh r1, [r0, #2] - mov r1, #0x11 - strb r1, [r0, #1] - lsl r0, r5, #8 - orr r0, r7 - str r0, [sp, #0xb8] - ldr r0, [sp, #0x34] - str r0, [sp, #0xbc] - ldr r0, [r4] - bl BattleSystem_GetTextFrameDelay - add r3, r0, #0 - ldr r0, [r4] - ldr r1, [sp, #0x40] - add r2, sp, #0xb4 - bl ov12_0223C494 - str r0, [r4, #0x30] - mov r0, #7 - add sp, #0xd8 - str r0, [r4, #0x28] - pop {r3, r4, r5, r6, r7, pc} -_02245D28: - ldr r0, [r4, #0x30] - lsl r0, r0, #0x18 - lsr r0, r0, #0x18 - bl TextPrinterCheckActive - cmp r0, #0 - beq _02245D38 - b _022463B6 -_02245D38: - mov r0, #8 - str r0, [r4, #0x28] - mov r0, #0 - add sp, #0xd8 - str r0, [r4, #0x38] - pop {r3, r4, r5, r6, r7, pc} -_02245D44: - ldr r0, [r4, #4] - add r1, r0, r7 - ldr r0, _02246010 ; =0x0000219C - ldrb r0, [r1, r0] - cmp r5, r0 - beq _02245D5A - ldr r0, [r4] - add r1, r4, #0 - add r2, r6, #0 - bl ov12_02248228 -_02245D5A: - mov r0, #9 - add sp, #0xd8 - str r0, [r4, #0x28] - pop {r3, r4, r5, r6, r7, pc} -_02245D62: - ldr r0, [r4] - bl BattleSystem_GetBgConfig - add r6, r0, #0 - ldr r0, [r4] - mov r1, #1 - bl BattleSystem_GetWindow - add r5, r0, #0 - ldr r0, [r4] - bl BattleSystem_GetPaletteData - add r7, r0, #0 - ldr r0, _02246018 ; =0x04000008 - mov r2, #3 - ldrh r1, [r0] - bic r1, r2 - mov r2, #2 - orr r1, r2 - strh r1, [r0] - mov r0, #1 - add r1, r0, #0 - bl SetBgPriority - mov r0, #2 - mov r1, #0 - bl SetBgPriority - ldr r0, [r4] - mov r1, #1 - bl ov12_0223C224 - mov r0, #5 - str r0, [sp] - add r0, r6, #0 - mov r1, #2 - mov r2, #1 - mov r3, #0 - bl sub_0200E398 - bl sub_0200E3D8 - add r2, r0, #0 - mov r0, #0 - str r0, [sp] - mov r0, #0x20 - str r0, [sp, #4] - mov r0, #0x80 - str r0, [sp, #8] - add r0, r7, #0 - mov r1, #0x26 - mov r3, #5 - bl PaletteData_LoadNarc - mov r0, #7 - str r0, [sp] - mov r0, #0xe - str r0, [sp, #4] - mov r0, #0xc - str r0, [sp, #8] - mov r0, #0xb - str r0, [sp, #0xc] - mov r0, #0xa - str r0, [sp, #0x10] - add r0, r6, #0 - add r1, r5, #0 - mov r2, #2 - mov r3, #0x11 - bl AddWindowParameterized - add r0, r5, #0 - mov r1, #0xff - bl FillWindowPixelBuffer - add r0, r5, #0 - mov r1, #0 - mov r2, #1 - mov r3, #8 - bl DrawFrameAndWindow1 - mov r0, #0xa - add sp, #0xd8 - str r0, [r4, #0x28] - pop {r3, r4, r5, r6, r7, pc} -_02245E0A: - ldr r3, _0224601C ; =ov12_0226C36C - add r2, sp, #0x84 - ldmia r3!, {r0, r1} - stmia r2!, {r0, r1} - ldmia r3!, {r0, r1} - stmia r2!, {r0, r1} - ldmia r3!, {r0, r1} - stmia r2!, {r0, r1} - ldr r3, _02246020 ; =ov12_0226C384 - add r2, sp, #0x6c - ldmia r3!, {r0, r1} - stmia r2!, {r0, r1} - ldmia r3!, {r0, r1} - stmia r2!, {r0, r1} - ldmia r3!, {r0, r1} - stmia r2!, {r0, r1} - ldr r0, [r4] - mov r1, #1 - bl BattleSystem_GetWindow - add r7, r0, #0 - mov r0, #0x5f - ldr r1, [r4, #4] - lsl r0, r0, #2 - ldr r0, [r1, r0] - str r0, [sp, #0x2c] - mov r0, #0 - str r0, [sp, #0x50] -_02245E42: - ldr r2, _02246024 ; =0x000003B3 - add r1, sp, #0xb4 - strh r2, [r1, #2] - mov r2, #4 - strb r2, [r1, #1] - lsl r2, r0, #2 - add r1, sp, #0x84 - ldr r1, [r1, r2] - lsl r0, r0, #4 - str r1, [sp, #0xb8] - mov r1, #0 - str r1, [sp] - str r0, [sp, #4] - add r0, r1, #0 - str r0, [sp, #8] - str r0, [sp, #0xc] - str r0, [sp, #0x10] - ldr r0, [r4] - ldr r2, [sp, #0x40] - add r1, r7, #0 - add r3, sp, #0xb4 - bl ov12_0223C4E8 - mov r1, #0xed - ldr r5, [sp, #0x50] - lsl r1, r1, #2 - add r0, sp, #0xb4 - strh r1, [r0, #2] - mov r1, #7 - strb r1, [r0, #1] - lsl r2, r5, #2 - add r1, sp, #0x6c - ldr r1, [r1, r2] - add r0, r6, #0 - mov r2, #0 - bl GetMonData - ldr r1, [sp, #0x2c] - lsl r2, r5, #2 - ldr r1, [r1, r2] - ldr r2, [sp, #0x40] - sub r0, r0, r1 - str r0, [sp, #0xb8] - mov r0, #2 - str r0, [sp, #0xd0] - mov r0, #0x50 - str r0, [sp] - lsl r0, r5, #4 - str r0, [sp, #4] - mov r0, #0 - str r0, [sp, #8] - str r0, [sp, #0xc] - str r0, [sp, #0x10] - ldr r0, [r4] - add r1, r7, #0 - add r3, sp, #0xb4 - bl ov12_0223C4E8 - ldr r0, [sp, #0x50] - add r0, r0, #1 - str r0, [sp, #0x50] - cmp r0, #6 - blt _02245E42 - mov r0, #0xb - add sp, #0xd8 - str r0, [r4, #0x28] - pop {r3, r4, r5, r6, r7, pc} -_02245EC8: - ldr r3, _02246028 ; =ov12_0226C33C - add r2, sp, #0x54 - ldmia r3!, {r0, r1} - stmia r2!, {r0, r1} - ldmia r3!, {r0, r1} - stmia r2!, {r0, r1} - ldmia r3!, {r0, r1} - stmia r2!, {r0, r1} - ldr r0, [r4] - mov r1, #1 - bl BattleSystem_GetWindow - mov r1, #0x24 - str r1, [sp] - mov r1, #0x60 - str r1, [sp, #4] - mov r1, #0xf - mov r2, #0x50 - mov r3, #0 - add r7, r0, #0 - bl FillWindowPixelRect - mov r1, #0 - str r1, [sp, #0x50] - add r5, sp, #0xb4 -_02245EFA: - ldr r0, _0224602C ; =0x000003B5 - lsl r2, r1, #2 - add r1, sp, #0x54 - strh r0, [r5, #2] - mov r0, #7 - ldr r1, [r1, r2] - strb r0, [r5, #1] - add r0, r6, #0 - mov r2, #0 - bl GetMonData - str r0, [sp, #0xb8] - mov r0, #3 - str r0, [sp, #0xd0] - mov r0, #0x48 - str r0, [sp] - ldr r0, [sp, #0x50] - ldr r2, [sp, #0x40] - lsl r0, r0, #4 - str r0, [sp, #4] - mov r0, #2 - str r0, [sp, #8] - mov r0, #0x24 - str r0, [sp, #0xc] - mov r0, #0 - str r0, [sp, #0x10] - ldr r0, [r4] - add r1, r7, #0 - add r3, r5, #0 - bl ov12_0223C4E8 - ldr r0, [sp, #0x50] - add r1, r0, #1 - str r1, [sp, #0x50] - cmp r1, #6 - blt _02245EFA - mov r0, #0xd - add sp, #0xd8 - str r0, [r4, #0x28] - pop {r3, r4, r5, r6, r7, pc} -_02245F4A: - ldr r0, _02246030 ; =gSystem - ldr r1, [r0, #0x48] - ldr r0, _02246034 ; =0x00000C03 - tst r0, r1 - bne _02245F5C - bl System_GetTouchNew - cmp r0, #0 - beq _02245FEA -_02245F5C: - ldr r0, _02246038 ; =0x000005DC - bl PlaySE - ldr r0, [r4, #0x28] - add sp, #0xd8 - add r0, r0, #1 - str r0, [r4, #0x28] - pop {r3, r4, r5, r6, r7, pc} -_02245F6C: - ldr r0, [r4] - mov r1, #1 - bl BattleSystem_GetWindow - add r6, r0, #0 - mov r1, #0 - bl sub_0200E5D4 - add r0, r6, #0 - bl RemoveWindow - ldr r1, _02246018 ; =0x04000008 - mov r0, #3 - ldrh r2, [r1] - bic r2, r0 - mov r0, #1 - orr r2, r0 - strh r2, [r1] - mov r1, #0 - bl SetBgPriority - mov r0, #2 - mov r1, #1 - bl SetBgPriority - ldr r0, [r4] - mov r1, #0 - bl ov12_0223C224 - ldr r0, [r4, #4] - add r1, r0, r7 - ldr r0, _02246010 ; =0x0000219C - ldrb r0, [r1, r0] - cmp r5, r0 - beq _02245FBA - ldr r0, [r4] - add r1, r4, #0 - bl ov12_022484D4 -_02245FBA: - mov r0, #0x5f - ldr r1, [r4, #4] - lsl r0, r0, #2 - ldr r0, [r1, r0] - bl FreeToHeap - mov r0, #0xf - add sp, #0xd8 - str r0, [r4, #0x28] - pop {r3, r4, r5, r6, r7, pc} -_02245FCE: - ldr r0, [r4] - bl BattleSystem_GetBgConfig - add r1, r4, #0 - add r0, r6, #0 - add r1, #0x38 - add r2, sp, #0x48 - bl MonTryLearnMoveOnLevelUp - cmp r0, #0 - beq _02245FF4 - ldr r1, _0224603C ; =0x0000FFFE - cmp r0, r1 - bne _02245FEC -_02245FEA: - b _022463B6 -_02245FEC: - add r1, r1, #1 - cmp r0, r1 - beq _02245FFC - b _0224600A -_02245FF4: - mov r0, #3 - add sp, #0xd8 - str r0, [r4, #0x28] - pop {r3, r4, r5, r6, r7, pc} -_02245FFC: - add r0, sp, #0x48 - ldrh r0, [r0] - add sp, #0xd8 - str r0, [r4, #0x40] - mov r0, #0x10 - str r0, [r4, #0x28] - pop {r3, r4, r5, r6, r7, pc} -_0224600A: - ldr r1, [r4, #4] - ldr r0, _02246010 ; =0x0000219C - b _02246040 - .balign 4, 0 -_02246010: .word 0x0000219C -_02246014: .word 0x00003109 -_02246018: .word 0x04000008 -_0224601C: .word ov12_0226C36C -_02246020: .word ov12_0226C384 -_02246024: .word 0x000003B3 -_02246028: .word ov12_0226C33C -_0224602C: .word 0x000003B5 -_02246030: .word gSystem -_02246034: .word 0x00000C03 -_02246038: .word 0x000005DC -_0224603C: .word 0x0000FFFE -_02246040: - add r2, r1, r7 - ldrb r3, [r2, r0] - cmp r5, r3 - bne _02246050 - ldr r0, [r4] - add r2, r7, #0 - bl BattleSystem_ReloadMonData -_02246050: - mov r1, #4 - add r0, sp, #0xb4 - strh r1, [r0, #2] - mov r1, #0xa - strb r1, [r0, #1] - lsl r0, r5, #8 - orr r0, r7 - str r0, [sp, #0xb8] - add r0, sp, #0x48 - ldrh r0, [r0] - str r0, [sp, #0xbc] - ldr r0, [r4] - bl BattleSystem_GetTextFrameDelay - add r3, r0, #0 - ldr r0, [r4] - ldr r1, [sp, #0x40] - add r2, sp, #0xb4 - bl ov12_0223C494 - str r0, [r4, #0x30] - mov r0, #0x24 - add sp, #0xd8 - str r0, [r4, #0x28] - pop {r3, r4, r5, r6, r7, pc} -_02246082: - ldr r1, _022463BC ; =0x0000049A - add r0, sp, #0xb4 - strh r1, [r0, #2] - mov r1, #0xa - strb r1, [r0, #1] - lsl r0, r5, #8 - orr r0, r7 - str r0, [sp, #0xb8] - ldr r0, [r4, #0x40] - str r0, [sp, #0xbc] - ldr r0, [r4] - bl BattleSystem_GetTextFrameDelay - add r3, r0, #0 - ldr r0, [r4] - ldr r1, [sp, #0x40] - add r2, sp, #0xb4 - bl ov12_0223C494 - str r0, [r4, #0x30] - ldr r0, [r4, #0x28] - add sp, #0xd8 - add r0, r0, #1 - str r0, [r4, #0x28] - pop {r3, r4, r5, r6, r7, pc} -_022460B4: - ldr r1, _022463C0 ; =0x0000049B - add r0, sp, #0xb4 - strh r1, [r0, #2] - mov r1, #2 - strb r1, [r0, #1] - lsl r0, r5, #8 - orr r0, r7 - str r0, [sp, #0xb8] - ldr r0, [r4] - bl BattleSystem_GetTextFrameDelay - add r3, r0, #0 - ldr r0, [r4] - ldr r1, [sp, #0x40] - add r2, sp, #0xb4 - bl ov12_0223C494 - str r0, [r4, #0x30] - ldr r0, [r4, #0x28] - add sp, #0xd8 - add r0, r0, #1 - str r0, [r4, #0x28] - pop {r3, r4, r5, r6, r7, pc} -_022460E2: - ldr r0, [r4, #0x30] - lsl r0, r0, #0x18 - lsr r0, r0, #0x18 - bl TextPrinterCheckActive - cmp r0, #0 - bne _02246126 - ldr r0, [r4, #0x28] - add sp, #0xd8 - add r0, r0, #1 - str r0, [r4, #0x28] - pop {r3, r4, r5, r6, r7, pc} -_022460FA: - mov r0, #1 - str r0, [sp] - mov r0, #0 - str r0, [sp, #4] - str r0, [sp, #8] - ldr r0, [r4] - ldr r1, [r4, #4] - ldr r3, _022463C4 ; =0x0000049C - add r2, r7, #0 - bl BattleController_EmitDrawYesNoBox - ldr r0, [r4, #0x28] - add sp, #0xd8 - add r0, r0, #1 - str r0, [r4, #0x28] - pop {r3, r4, r5, r6, r7, pc} -_0224611A: - ldr r0, [r4, #4] - add r1, r7, #0 - bl ov12_0225682C - cmp r0, #0 - bne _02246128 -_02246126: - b _022463B6 -_02246128: - ldr r0, [r4, #4] - add r1, r7, #0 - bl ov12_0225682C - cmp r0, #0xff - bne _0224613C - mov r0, #0x1f - add sp, #0xd8 - str r0, [r4, #0x28] - pop {r3, r4, r5, r6, r7, pc} -_0224613C: - ldr r1, _022463C8 ; =0x0000049F - add r0, sp, #0xb4 - strh r1, [r0, #2] - mov r1, #0 - strb r1, [r0, #1] - ldr r0, [r4] - bl BattleSystem_GetTextFrameDelay - add r3, r0, #0 - ldr r0, [r4] - ldr r1, [sp, #0x40] - add r2, sp, #0xb4 - bl ov12_0223C494 - str r0, [r4, #0x30] - mov r0, #0x16 - add sp, #0xd8 - str r0, [r4, #0x28] - pop {r3, r4, r5, r6, r7, pc} -_02246162: - ldr r0, [r4, #0x30] - lsl r0, r0, #0x18 - lsr r0, r0, #0x18 - bl TextPrinterCheckActive - cmp r0, #0 - bne _02246268 - ldr r0, [r4] - ldr r2, [r4, #0x40] - add r1, r7, #0 - add r3, r5, #0 - bl ov12_02263D14 - ldr r0, [r4, #0x28] - add sp, #0xd8 - add r0, r0, #1 - str r0, [r4, #0x28] - pop {r3, r4, r5, r6, r7, pc} -_02246186: - ldr r0, [r4, #4] - add r1, r7, #0 - bl ov12_0225682C - cmp r0, #0xff - bne _0224619A - mov r0, #0x1f - add sp, #0xd8 - str r0, [r4, #0x28] - pop {r3, r4, r5, r6, r7, pc} -_0224619A: - ldr r0, [r4, #4] - add r1, r7, #0 - bl ov12_0225682C - cmp r0, #0 - beq _02246268 - ldr r1, [r4, #4] - lsl r0, r7, #8 - add r1, r1, r0 - mov r0, #0x23 - lsl r0, r0, #8 - ldrb r0, [r1, r0] - add sp, #0xd8 - sub r0, r0, #1 - str r0, [r4, #0x44] - mov r0, #0x18 - str r0, [r4, #0x28] - pop {r3, r4, r5, r6, r7, pc} -_022461BE: - mov r1, #0x4a - lsl r1, r1, #4 - add r0, sp, #0xb4 - strh r1, [r0, #2] - mov r1, #0 - strb r1, [r0, #1] - ldr r0, [r4] - bl BattleSystem_GetTextFrameDelay - add r3, r0, #0 - ldr r0, [r4] - ldr r1, [sp, #0x40] - add r2, sp, #0xb4 - bl ov12_0223C494 - str r0, [r4, #0x30] - ldr r0, [r4, #0x28] - add sp, #0xd8 - add r0, r0, #1 - str r0, [r4, #0x28] - pop {r3, r4, r5, r6, r7, pc} -_022461E8: - mov r0, #2 - str r0, [sp] - ldr r0, [r4, #0x40] - ldr r3, _022463CC ; =0x000004A1 - str r0, [sp, #4] - mov r0, #0 - str r0, [sp, #8] - ldr r0, [r4] - ldr r1, [r4, #4] - add r2, r7, #0 - bl BattleController_EmitDrawYesNoBox - ldr r0, [r4, #0x28] - add sp, #0xd8 - add r0, r0, #1 - str r0, [r4, #0x28] - pop {r3, r4, r5, r6, r7, pc} -_0224620A: - ldr r0, [r4, #4] - add r1, r7, #0 - bl ov12_0225682C - cmp r0, #0 - beq _02246268 - ldr r0, [r4, #4] - add r1, r7, #0 - bl ov12_0225682C - cmp r0, #0xff - bne _0224622A - mov r0, #0x10 - add sp, #0xd8 - str r0, [r4, #0x28] - pop {r3, r4, r5, r6, r7, pc} -_0224622A: - ldr r1, _022463D0 ; =0x000004A4 - add r0, sp, #0xb4 - strh r1, [r0, #2] - mov r1, #0xa - strb r1, [r0, #1] - lsl r0, r5, #8 - orr r0, r7 - str r0, [sp, #0xb8] - ldr r0, [r4, #0x40] - str r0, [sp, #0xbc] - ldr r0, [r4] - bl BattleSystem_GetTextFrameDelay - add r3, r0, #0 - ldr r0, [r4] - ldr r1, [sp, #0x40] - add r2, sp, #0xb4 - bl ov12_0223C494 - str r0, [r4, #0x30] - mov r0, #0x23 - add sp, #0xd8 - str r0, [r4, #0x28] - pop {r3, r4, r5, r6, r7, pc} -_0224625A: - ldr r0, [r4, #0x30] - lsl r0, r0, #0x18 - lsr r0, r0, #0x18 - bl TextPrinterCheckActive - cmp r0, #0 - beq _0224626A -_02246268: - b _022463B6 -_0224626A: - mov r0, #0xf - add sp, #0xd8 - str r0, [r4, #0x28] - pop {r3, r4, r5, r6, r7, pc} -_02246272: - ldr r1, _022463D4 ; =0x000004A5 - add r0, sp, #0xb4 - strh r1, [r0, #2] - mov r1, #0 - strb r1, [r0, #1] - ldr r0, [r4] - bl BattleSystem_GetTextFrameDelay - add r3, r0, #0 - ldr r0, [r4] - ldr r1, [sp, #0x40] - add r2, sp, #0xb4 - bl ov12_0223C494 - str r0, [r4, #0x30] - ldr r0, [r4, #0x28] - add sp, #0xd8 - add r0, r0, #1 - str r0, [r4, #0x28] - pop {r3, r4, r5, r6, r7, pc} -_0224629A: - ldr r1, _022463D8 ; =0x000004A6 - add r0, sp, #0xb4 - strh r1, [r0, #2] - mov r1, #0xa - strb r1, [r0, #1] - lsl r0, r5, #8 - orr r0, r7 - str r0, [sp, #0xb8] - ldr r1, [r4, #0x44] - add r0, r6, #0 - add r1, #0x36 - mov r2, #0 - bl GetMonData - str r0, [sp, #0xbc] - ldr r0, [r4] - bl BattleSystem_GetTextFrameDelay - add r3, r0, #0 - ldr r0, [r4] - ldr r1, [sp, #0x40] - add r2, sp, #0xb4 - bl ov12_0223C494 - str r0, [r4, #0x30] - ldr r0, [r4, #0x28] - add sp, #0xd8 - add r0, r0, #1 - str r0, [r4, #0x28] - pop {r3, r4, r5, r6, r7, pc} -_022462D6: - ldr r1, _022463DC ; =0x000004A7 - add r0, sp, #0xb4 - strh r1, [r0, #2] - mov r1, #0 - strb r1, [r0, #1] - ldr r0, [r4] - bl BattleSystem_GetTextFrameDelay - add r3, r0, #0 - ldr r0, [r4] - ldr r1, [sp, #0x40] - add r2, sp, #0xb4 - bl ov12_0223C494 - str r0, [r4, #0x30] - ldr r0, [r4, #0x28] - add sp, #0xd8 - add r0, r0, #1 - str r0, [r4, #0x28] - pop {r3, r4, r5, r6, r7, pc} -_022462FE: - ldr r1, _022463E0 ; =0x000004A8 - add r0, sp, #0xb4 - strh r1, [r0, #2] - mov r1, #0xa - strb r1, [r0, #1] - lsl r0, r5, #8 - orr r0, r7 - str r0, [sp, #0xb8] - ldr r0, [r4, #0x40] - str r0, [sp, #0xbc] - ldr r0, [r4] - bl BattleSystem_GetTextFrameDelay - add r3, r0, #0 - ldr r0, [r4] - ldr r1, [sp, #0x40] - add r2, sp, #0xb4 - bl ov12_0223C494 - str r0, [r4, #0x30] - mov r0, #0 - str r0, [sp, #0x50] - ldr r1, [r4, #0x44] - add r0, r6, #0 - add r1, #0x3e - add r2, sp, #0x50 - bl SetMonData - ldr r1, [r4, #0x40] - ldr r2, [r4, #0x44] - lsl r1, r1, #0x10 - lsl r2, r2, #0x18 - add r0, r6, #0 - lsr r1, r1, #0x10 - lsr r2, r2, #0x18 - bl MonSetMoveInSlot - ldr r1, [r4, #4] - ldr r0, _022463E4 ; =0x0000219C - add r2, r1, r7 - ldrb r3, [r2, r0] - cmp r5, r3 - bne _0224635C - ldr r0, [r4] - add r2, r7, #0 - bl BattleSystem_ReloadMonData -_0224635C: - mov r0, #0x24 - add sp, #0xd8 - str r0, [r4, #0x28] - pop {r3, r4, r5, r6, r7, pc} -_02246364: - ldr r0, [r4, #0x30] - lsl r0, r0, #0x18 - lsr r0, r0, #0x18 - bl TextPrinterCheckActive - cmp r0, #0 - bne _022463B6 - mov r0, #0xf - add sp, #0xd8 - str r0, [r4, #0x28] - pop {r3, r4, r5, r6, r7, pc} -_0224637A: - add r0, r5, #0 - bl MaskOfFlagNo - ldr r1, [sp, #0x44] - ldr r2, [r4, #4] - mov r3, #0 - mvn r3, r3 - add r2, #0xa4 - lsl r1, r1, #2 - ldr r6, [r2, r1] - eor r0, r3 - and r0, r6 - str r0, [r2, r1] - add r0, r5, #1 - str r0, [r4, #0x48] - mov r0, #0 - add sp, #0xd8 - str r0, [r4, #0x28] - pop {r3, r4, r5, r6, r7, pc} -_022463A0: - mov r0, #0x5e - ldr r1, [r4, #4] - mov r2, #0 - lsl r0, r0, #2 - str r2, [r1, r0] - add r0, r4, #0 - bl FreeToHeap - ldr r0, [sp, #0x14] - bl DestroySysTask -_022463B6: - add sp, #0xd8 - pop {r3, r4, r5, r6, r7, pc} - nop -_022463BC: .word 0x0000049A -_022463C0: .word 0x0000049B -_022463C4: .word 0x0000049C -_022463C8: .word 0x0000049F -_022463CC: .word 0x000004A1 -_022463D0: .word 0x000004A4 -_022463D4: .word 0x000004A5 -_022463D8: .word 0x000004A6 -_022463DC: .word 0x000004A7 -_022463E0: .word 0x000004A8 -_022463E4: .word 0x0000219C - thumb_func_end Task_GetExp - thumb_func_start ov12_022463E8 ov12_022463E8: ; 0x022463E8 push {r3, r4, r5, r6, r7, lr} @@ -5681,6 +4302,7 @@ ov12_0226C324: ; 0x0226C324 .word STAT_SPDEF .word STAT_SPEED +.public ov12_0226C33C ov12_0226C33C: ; 0x0226C33C .word MON_DATA_MAXHP .word MON_DATA_ATK @@ -5689,6 +4311,7 @@ ov12_0226C33C: ; 0x0226C33C .word MON_DATA_SPDEF .word MON_DATA_SPEED +.public ov12_0226C354 ov12_0226C354: ; 0x0226C354 .word MON_DATA_MAXHP .word MON_DATA_ATK @@ -5697,6 +4320,7 @@ ov12_0226C354: ; 0x0226C354 .word MON_DATA_SPDEF .word MON_DATA_SPEED +.public ov12_0226C36C ov12_0226C36C: ; 0x0226C36C .word NUM_BATTLE_STATS .word STAT_ATK @@ -5705,6 +4329,7 @@ ov12_0226C36C: ; 0x0226C36C .word STAT_SPDEF .word STAT_SPEED +.public ov12_0226C384 ov12_0226C384: ; 0x0226C384 .word MON_DATA_MAXHP .word MON_DATA_ATK diff --git a/include/battle/battle.h b/include/battle/battle.h index 2a152fe732..a79bc038a2 100644 --- a/include/battle/battle.h +++ b/include/battle/battle.h @@ -260,6 +260,10 @@ typedef struct BattleMon { UnkBattlemonSub unk88; } BattleMon; +typedef struct StatStruct { + u32 stats[6]; +} StatStruct; + typedef struct BattleContext { u8 unk_0[4]; u8 unk_4[4]; @@ -630,7 +634,7 @@ struct GetterWork { u32 unk14; u32 unk18[3]; int unk24; - int unk28; + int state; int unk2C; int unk30[8]; void *unk50[2]; diff --git a/include/battle/battle_022378C0.h b/include/battle/battle_022378C0.h index 36441f16a7..e06220d38a 100644 --- a/include/battle/battle_022378C0.h +++ b/include/battle/battle_022378C0.h @@ -9,6 +9,7 @@ BOOL Battle_Main(OVY_MANAGER *man, int *state); void ov12_02237B0C(BattleSystem *bsys); void ov12_02237B6C(BattleSystem *bsys); void ov12_02237BB8(BattleSystem *bsys); +void ov12_02237CC4(BattleSystem *bsys); //the following functions are static and have yet to be decompiled void ov12_022399D4(OVY_MANAGER *man, BattleSetup *setup); diff --git a/include/battle/battle_command.h b/include/battle/battle_command.h index 57f330b27c..662c9c10ab 100644 --- a/include/battle/battle_command.h +++ b/include/battle/battle_command.h @@ -238,5 +238,8 @@ void InitBattleMsgData(BattleContext *ctx, BattleMessageData *msgdata); void InitBattleMsg(BattleSystem *bsys, BattleContext *ctx, BattleMessageData *msgdata, BattleMessage *msg); void UpdateFrienshipFainted(BattleSystem *bsys, BattleContext *ctx, int battlerId); int GetMoveMessageNo(BattleContext *ctx, int move); +void ov12_022463E8(Party *party, int slot, u32 species, u32 form); +void ov12_02248228(BattleSystem *bsys, GetterWork *data, Pokemon *mon); +void ov12_022484D4(BattleSystem *bsys, GetterWork *data); #endif diff --git a/include/battle/battle_controller.h b/include/battle/battle_controller.h index 2a2f88190c..5e853f6752 100644 --- a/include/battle/battle_controller.h +++ b/include/battle/battle_controller.h @@ -73,5 +73,10 @@ void ov12_02262FFC(BattleSystem *bsys, BattleContext *ctx, int a2, int battlerId void ov12_02263138(BattleSystem *bsys, BattleContext *ctx, int battlerId); void ov12_02263E18(BattleSystem *bsys, int battlerId); void ov12_0224E414(BattleSystem *bsys, BattleContext *ctx); +void ov12_02263564(BattleSystem *bsys, BattleContext *ctx, int battlerId, u32 a3); +void ov12_0226399C(BattleSystem *bsys, int battlerId); +void ov12_02263A1C(BattleSystem *bsys, BattleContext *ctx, int battlerId); +void ov12_0223C4E8(BattleSystem *bsys, Window *window, u32 *msgLoader, BattleMessage *msg, int a4, int a5, int a6, int a7, int a8); +void ov12_02263D14(BattleSystem *bsys, int battlerId, u32 a2, int slot); #endif diff --git a/include/battle/battle_system.h b/include/battle/battle_system.h index c600fb5c05..11e58ca623 100644 --- a/include/battle/battle_system.h +++ b/include/battle/battle_system.h @@ -149,5 +149,6 @@ void ov12_02263A1C(BattleSystem *bsys, BattleContext *ctx, int battlerId); void ov12_02266008(UnkBattleSystemSub17C *a0); BattleHpBar *OpponentData_GetHpBar(OpponentData *opponentData); void ov12_0226AA8C(u32 *a1, u32 flag); +u32 ov12_0223C494(BattleSystem *bsys, void *msgLoader, BattleMessage *msg, u8 textFrameDelay); #endif diff --git a/include/render_window.h b/include/render_window.h index ae36be8712..dc41dba972 100644 --- a/include/render_window.h +++ b/include/render_window.h @@ -16,5 +16,7 @@ WaitingIcon *WaitingIcon_New(Window *window, u16 tileNum); void sub_0200F450(WaitingIcon *waitingIcon); struct PokepicManager *DrawPokemonPicFromSpecies(BgConfig *bgConfig, enum GFBgLayer layer, int x, int y, u8 paletteNum, u16 baseTile, u16 species, u8 gender, HeapID heapId); struct PokepicManager *DrawPokemonPicFromMon(BgConfig *bgConfig, enum GFBgLayer layer, int x, int y, u8 paletteNum, u16 baseTile, Pokemon *mon, HeapID heapId); +void sub_0200E398(BgConfig *bgConfig, u32 a1, u32 a2, u32 a3, HeapID heapId); +u32 sub_0200E3D8(); #endif //POKEHEARTGOLD_RENDER_WINDOW_H diff --git a/src/battle/battle_022378C0.c b/src/battle/battle_022378C0.c index d636a7678b..112fabb706 100644 --- a/src/battle/battle_022378C0.c +++ b/src/battle/battle_022378C0.c @@ -232,3 +232,16 @@ void ov12_02237BB8(BattleSystem *bsys) { G2dRenderer_SetSubSurfaceCoords(SpriteRenderer_GetG2dRendererPtr(bsys->unk90), 0, 17 << 16); } + +void ov12_02237CC4(BattleSystem *bsys) { + RemoveWindow(bsys->window); + + GX_EngineAToggleLayers(GX_PLANEMASK_BG0, GX_LAYER_TOGGLE_OFF); + GX_EngineAToggleLayers(GX_PLANEMASK_BG1, GX_LAYER_TOGGLE_OFF); + FreeBgTilemapBuffer(bsys->bgConfig, 1); + FreeBgTilemapBuffer(bsys->bgConfig, 2); + FreeBgTilemapBuffer(bsys->bgConfig, 3); + BattleSystem_SetHpBarDisabled(bsys); +} + + diff --git a/src/battle/battle_command.c b/src/battle/battle_command.c index 9722921668..4ec80a0dd0 100644 --- a/src/battle/battle_command.c +++ b/src/battle/battle_command.c @@ -4,12 +4,18 @@ #include "battle/battle_controller_player.h" #include "battle/battle_command.h" #include "item.h" +#include "palette.h" #include "party.h" #include "pokemon.h" +#include "pokemon_mood.h" +#include "render_window.h" +#include "sound.h" #include "system.h" +#include "text.h" #include "unk_0200E320.h" #include "unk_0208805C.h" #include "unk_02025154.h" +#include "unk_02005D10.h" #include "sound_chatot.h" #include "battle/overlay_12_0224E4FC.h" #include "constants/abilities.h" @@ -18,6 +24,7 @@ #include "constants/items.h" #include "constants/moves.h" #include "constants/pokemon.h" +#include "constants/sndseq.h" int BattleScriptReadWord(BattleContext *ctx); static void BattleScriptIncrementPointer(BattleContext *ctx, int adrs); @@ -1240,7 +1247,7 @@ BOOL BtlCmd_InitGetExp(BattleSystem *bsys, BattleContext *ctx) { ctx->getterWork->bsys = bsys; ctx->getterWork->ctx = ctx; - ctx->getterWork->unk28 = 0; + ctx->getterWork->state = 0; ctx->getterWork->unk30[6] = 0; CreateSysTask(Task_GetExp, ctx->getterWork, 0); @@ -1406,7 +1413,7 @@ BOOL BtlCmd_InitGetPokemon(BattleSystem *bsys, BattleContext *ctx) { ctx->getterWork = (GetterWork*) AllocFromHeap(HEAP_ID_BATTLE, sizeof(GetterWork)); ctx->getterWork->bsys = bsys; ctx->getterWork->ctx = ctx; - ctx->getterWork->unk28 = 0; + ctx->getterWork->state = 0; ctx->getterWork->unk24 = unkA; ctx->getterWork->unk2C = ItemToBallId(ctx->itemTemp); @@ -5909,3 +5916,561 @@ static void *BattleScriptGetVarPointer(BattleSystem *bsys, BattleContext *ctx, i return NULL; } + +enum { + STATE_GET_EXP_START = 0, + STATE_GET_EXP_WAIT_MESSAGE_PRINT, + STATE_GET_EXP_WAIT_MESSAGE_DELAY, + STATE_GET_EXP_GAUGE, + STATE_GET_EXP_WAIT_GAUGE, + + STATE_GET_EXP_CHECK_LEVEL_UP, //5 + STATE_GET_EXP_WAIT_LEVEL_UP_EFFECT, + STATE_GET_EXP_WAIT_LEVEL_UP_MESSAGE_PRINT, + + STATE_GET_EXP_LEVEL_UP_SUMMARY_LOAD_ICON, + STATE_GET_EXP_LEVEL_UP_SUMMARY_INIT, + STATE_GET_EXP_LEVEL_UP_SUMMARY_PRINT_DIFF, //10 + STATE_GET_EXP_LEVEL_UP_SUMMARY_PRINT_DIFF_WAIT, + STATE_GET_EXP_LEVEL_UP_SUMMARY_PRINT_TRUE, + STATE_GET_EXP_LEVEL_UP_SUMMARY_PRINT_TRUE_WAIT, + STATE_GET_EXP_LEVEL_UP_CLEAR, + + STATE_GET_EXP_CHECK_LEARN_MOVE, + STATE_GET_EXP_WANTS_TO_LEARN_MOVE_PRINT, + STATE_GET_EXP_WANTS_TO_LEARN_MOVE_PRINT_WAIT, + STATE_GET_EXP_CANT_LEARN_MORE_MOVES_PRINT, + STATE_GET_EXP_CANT_LEARN_MORE_MOVES_PRINT_WAIT, + STATE_GET_EXP_MAKE_IT_FORGET_PROMPT, + STATE_GET_EXP_MAKE_IT_FORGET_ANSWER, + STATE_GET_EXP_MAKE_IT_FORGET_WAIT, + STATE_GET_EXP_MAKE_IT_FORGET_INPUT_TAKEN, + STATE_GET_EXP_ONE_TWO_POOF, + STATE_GET_EXP_ONE_TWO_POOF_WAIT, + STATE_GET_EXP_FORGOT_HOW_TO_USE, + STATE_GET_EXP_FORGOT_HOW_TO_USE_WAIT, + STATE_GET_EXP_AND_DOTDOTDOT, + STATE_GET_EXP_AND_DOTDOTDOT_WAIT, + STATE_GET_EXP_LEARNED_MOVE, + STATE_GET_EXP_MAKE_IT_FORGET_CANCELLED, + STATE_GET_EXP_MAKE_IT_FORGET_CANCELLED_WAIT, + STATE_GET_EXP_GIVE_UP_LEARNING_PROMPT, + STATE_GET_EXP_GIVE_UP_LEARNING_ANSWER, + STATE_GET_EXP_GIVE_UP_LEARNING_WAIT, + STATE_GET_EXP_LEARNED_MOVE_WAIT, + + STATE_GET_EXP_CHECK_DONE, + STATE_GET_EXP_DONE, +}; + +//Note: these structs are needed to match *only as long as the data is in the assembly* +//when the data gets decompiled, they should be embeded in the function as arrays +typedef struct TempStatsStruct { + u32 stats[6]; +} TempStatsStruct; + +extern TempStatsStruct ov12_0226C354; +extern TempStatsStruct ov12_0226C36C; +extern TempStatsStruct ov12_0226C384; +extern TempStatsStruct ov12_0226C33C; + +static void Task_GetExp(SysTask *task, void *inData) +{ + int i; + int slot; + GetterWork *data = inData; + Pokemon *mon; + BattleMessage msg; + int battler; + int expBattler; + u32 *msgLoader; + u32 battleType; + u16 item; + int itemEffect; + + msgLoader = ov12_0223A930(data->bsys); + battleType = BattleSystem_GetBattleType(data->bsys); + battler = data->ctx->battlerIdFainted >> 1 & 1; // init to the side with the fainted mon + expBattler = 0; + + // Figure out which mon we're working on + for (slot = data->unk30[6]; slot < BattleSystem_GetPartySize(data->bsys, expBattler); slot++) { + mon = BattleSystem_GetPartyMon(data->bsys, expBattler, slot); + item = GetMonData(mon, MON_DATA_HELD_ITEM, NULL); + itemEffect = GetItemAttr(item, ITEM_VAR_HOLD_EFFECT, HEAP_ID_BATTLE); + + if (itemEffect == HOLD_EFFECT_EXP_SHARE || (data->ctx->unk_A4[battler] & MaskOfFlagNo(slot))) { + break; + } + } + + if (slot == BattleSystem_GetPartySize(data->bsys, expBattler)) { + data->state = STATE_GET_EXP_DONE; + } else if ((battleType & BATTLE_TYPE_DOUBLES) + && (battleType & BATTLE_TYPE_6) == FALSE + && data->ctx->selectedMonIndex[BATTLER_PLAYER2] == slot) { + expBattler = 2; + } + + switch (data->state) { + case STATE_GET_EXP_START: { + item = GetMonData(mon, MON_DATA_HELD_ITEM, NULL); + itemEffect = GetItemAttr(item, ITEM_VAR_HOLD_EFFECT, HEAP_ID_BATTLE); + + // Declare victory if all wild mons have been defeated + if ((battleType & BATTLE_TYPE_TRAINER) == FALSE + && data->ctx->battleMons[BATTLER_ENEMY].hp + + data->ctx->battleMons[BATTLER_ENEMY2].hp == 0 + && GetMonData(mon, MON_DATA_HP, NULL) + && data->ctx->unk_3144 == FALSE) { + PlayBGM(SEQ_GS_WIN2); + data->ctx->unk_3144 = TRUE; + BattleSystem_SetCriticalHpMusicFlag(data->bsys, 2); // turn off + } + + u32 totalExp = 0; + msg.id = 1; // "{0} gained {1} Exp. Points!" + + if (GetMonData(mon, MON_DATA_HP, NULL) && GetMonData(mon, MON_DATA_LEVEL, NULL) != 100) { + if (data->ctx->unk_A4[battler] & MaskOfFlagNo(slot)) { + totalExp = data->ctx->gainedExp; + } + + if (itemEffect == HOLD_EFFECT_EXP_SHARE) { + totalExp += data->ctx->partyGainedExp; + } + + if (itemEffect == HOLD_EFFECT_EXP_UP) { + totalExp = totalExp * 150 / 100; + } + + if (battleType & BATTLE_TYPE_TRAINER) { + totalExp = totalExp * 150 / 100; + } + + if (ov12_022568B0(data->bsys, mon) == FALSE) { + if (GetMonData(mon, MON_DATA_GAME_LANGUAGE, NULL) != gGameLanguage) { + totalExp = totalExp * 170 / 100; + } else { + totalExp = totalExp * 150 / 100; + } + + msg.id = 2; // "{0} gained a boosted {1} Exp. Points!" + } + + u32 newExp = GetMonData(mon, MON_DATA_EXPERIENCE, NULL); + data->unk30[3] = newExp - GetMonBaseExperienceAtCurrentLevel(mon); + newExp += totalExp; + + if (slot == data->ctx->selectedMonIndex[expBattler]) { + data->ctx->battleMons[expBattler].exp = newExp; + } + + SetMonData(mon, MON_DATA_EXPERIENCE, &newExp); + ov12_022463E8(BattleSystem_GetParty(data->bsys, expBattler), + slot, + data->ctx->battleMons[data->ctx->battlerIdFainted].species, + data->ctx->battleMons[data->ctx->battlerIdFainted].form); + } + + if (totalExp) { + msg.tag = 17; + msg.param[0] = expBattler | (slot << 8); + msg.param[1] = totalExp; + data->unk30[0] = ov12_0223C494(data->bsys, msgLoader, &msg, BattleSystem_GetTextFrameDelay(data->bsys)); + data->unk30[1] = 30 / 4; + data->state++; + } else { + data->state = STATE_GET_EXP_CHECK_DONE; + } + + break; + } + + case STATE_GET_EXP_WAIT_MESSAGE_PRINT: + if (TextPrinterCheckActive(data->unk30[0]) == FALSE) { + data->state++; + } + break; + + case STATE_GET_EXP_WAIT_MESSAGE_DELAY: + if (--data->unk30[1] == 0) { + data->state++; + } + break; + + case STATE_GET_EXP_GAUGE: + // Only animate the gauge for an active battler + if (slot == data->ctx->selectedMonIndex[expBattler]) { + ov12_02263564(data->bsys, data->ctx, expBattler, data->unk30[3]); + data->unk30[3] = 0; + data->state++; + } else { + data->state = STATE_GET_EXP_CHECK_LEVEL_UP; + } + break; + + case STATE_GET_EXP_WAIT_GAUGE: + if (Link_QueueNotEmpty(data->ctx)) { + data->state++; + } + break; + + case STATE_GET_EXP_CHECK_LEVEL_UP: + if (Pokemon_TryLevelUp(mon)) { + // Only play the special level-up animation for an active battler + if (data->ctx->selectedMonIndex[expBattler] == slot) { + BattleController_EmitSetStatus2Effect(data->bsys, data->ctx, expBattler, 8); + ov12_0226399C(data->bsys, expBattler); + } + + data->state = STATE_GET_EXP_WAIT_LEVEL_UP_EFFECT; + } else { + data->state = STATE_GET_EXP_CHECK_DONE; + } + break; + + case STATE_GET_EXP_WAIT_LEVEL_UP_EFFECT: + if (Link_QueueNotEmpty(data->ctx)) { + TempStatsStruct stats = ov12_0226C354; + //TempDataLoader(ov12_0226C354, stats); + int level = GetMonData(mon, MON_DATA_LEVEL, NULL); + // Cache the stats from the previous level for later + data->ctx->unk_17C = AllocFromHeap(HEAP_ID_BATTLE, sizeof(StatStruct)); + StatStruct *oldStats = data->ctx->unk_17C; + for (i = 0; i < 6; i++) { + oldStats->stats[i] = GetMonData(mon, stats.stats[i], NULL); + } + + MonApplyFriendshipMod(mon, 0, BattleSystem_GetLocation(data->bsys)); + ApplyMonMoodModifier(mon, 0); + CalcMonStats(mon); + + if (data->ctx->selectedMonIndex[expBattler] == slot) { + BattleSystem_ReloadMonData(data->bsys, + data->ctx, + expBattler, + data->ctx->selectedMonIndex[expBattler]); + } + + data->ctx->levelUpMons |= MaskOfFlagNo(slot); + ov12_02263A1C(data->bsys, data->ctx, expBattler); + + msg.id = 3; // "{0} grew to Lv. {1}!" + msg.tag = 17; + msg.param[0] = expBattler | (slot << 8); + msg.param[1] = level; + data->unk30[0] = ov12_0223C494(data->bsys, msgLoader, &msg, BattleSystem_GetTextFrameDelay(data->bsys)); + data->state = STATE_GET_EXP_WAIT_LEVEL_UP_MESSAGE_PRINT; + } + break; + + case STATE_GET_EXP_WAIT_LEVEL_UP_MESSAGE_PRINT: + if (TextPrinterCheckActive(data->unk30[0]) == 0) { + data->state = STATE_GET_EXP_LEVEL_UP_SUMMARY_LOAD_ICON; + data->unk30[2] = 0; + } + break; + + case STATE_GET_EXP_LEVEL_UP_SUMMARY_LOAD_ICON: + // Load the Pokemon's Party icon if they are not the active battler + if (data->ctx->selectedMonIndex[expBattler] != slot) { + ov12_02248228(data->bsys, data, mon); + } + + data->state = STATE_GET_EXP_LEVEL_UP_SUMMARY_INIT; + break; + + case STATE_GET_EXP_LEVEL_UP_SUMMARY_INIT: { + BgConfig *bgConfig = BattleSystem_GetBgConfig(data->bsys); + Window *window = BattleSystem_GetWindow(data->bsys, 1); + PaletteData *palette = BattleSystem_GetPaletteData(data->bsys); + + G2_SetBG0Priority(1 + 1); // this is the background + 1; could do with a constant + SetBgPriority(1, 1); + SetBgPriority(2, 0); + + ov12_0223C224(data->bsys, 0 + 1); // gauge's default is 0 + + sub_0200E398(bgConfig, 2, 1, 0, HEAP_ID_BATTLE); + PaletteData_LoadNarc(palette, NARC_a_0_3_8, sub_0200E3D8(), HEAP_ID_BATTLE, 0, 0x20, 8 * 0x10); + AddWindowParameterized(bgConfig, window, 2, 0x11, 0x7, 14, 12, 11, (9 + 1)); + FillWindowPixelBuffer(window, 0xFF); + DrawFrameAndWindow1(window, 0, 1, 8); + + data->state = STATE_GET_EXP_LEVEL_UP_SUMMARY_PRINT_DIFF; + break; + } + + case STATE_GET_EXP_LEVEL_UP_SUMMARY_PRINT_DIFF: { + + TempStatsStruct stats = ov12_0226C36C; + TempStatsStruct monData = ov12_0226C384; + + Window *window = BattleSystem_GetWindow(data->bsys, 1); + StatStruct *oldStats = data->ctx->unk_17C; + + for (i = 0; i < 6; i++) { + msg.id = 947; // stat name + msg.tag = 4; + msg.param[0] = stats.stats[i]; + + ov12_0223C4E8(data->bsys, window, msgLoader, &msg, 0, 16 * i, 0, 0, 0); + + msg.id = 948; // "+{0}" + msg.tag = 7; + msg.param[0] = GetMonData(mon, monData.stats[i], NULL) - oldStats->stats[i]; + msg.unk1C = 2; + + ov12_0223C4E8(data->bsys, window, msgLoader, &msg, 80, 16 * i, 0, 0, 0); + } + + data->state = STATE_GET_EXP_LEVEL_UP_SUMMARY_PRINT_DIFF_WAIT; + break; + } + + case STATE_GET_EXP_LEVEL_UP_SUMMARY_PRINT_TRUE: { + TempStatsStruct monData = ov12_0226C33C; + Window *window = BattleSystem_GetWindow(data->bsys, 1); + + FillWindowPixelRect(window, 0xF, 80, 0, 36, 96); // clear out the diff section (keep the printed stat names) + + for (i = 0; i < 6; i++) { + msg.id = 949; // just a number + msg.tag = 7; + msg.param[0] = GetMonData(mon, monData.stats[i], NULL); + msg.unk1C = 3; + + ov12_0223C4E8(data->bsys, window, msgLoader, &msg, 72, 16 * i, 0x2, 36, 0); + } + + data->state = STATE_GET_EXP_LEVEL_UP_SUMMARY_PRINT_TRUE_WAIT; + break; + } + + case STATE_GET_EXP_LEVEL_UP_SUMMARY_PRINT_DIFF_WAIT: + case STATE_GET_EXP_LEVEL_UP_SUMMARY_PRINT_TRUE_WAIT: + if ((gSystem.newKeys & (PAD_BUTTON_A | PAD_BUTTON_B | PAD_BUTTON_X | PAD_BUTTON_Y)) || System_GetTouchNew()) { + PlaySE(SEQ_SE_DP_SELECT); + data->state++; + } + break; + + case STATE_GET_EXP_LEVEL_UP_CLEAR:{ + Window *window = BattleSystem_GetWindow(data->bsys, 1); + + sub_0200E5D4(window, 0); + RemoveWindow(window); + + G2_SetBG0Priority(1); + SetBgPriority(1, 0); + SetBgPriority(2, 1); + + ov12_0223C224(data->bsys, 0); + + if (data->ctx->selectedMonIndex[expBattler] != slot) { + ov12_022484D4(data->bsys, data); + } + + FreeToHeap(data->ctx->unk_17C); + data->state = 15; + break; + } + + case STATE_GET_EXP_CHECK_LEARN_MOVE: { + u16 move; + BgConfig *bgConfig = BattleSystem_GetBgConfig(data->bsys); // unused, but must be kept to match + + switch (MonTryLearnMoveOnLevelUp(mon, &data->unk30[2], &move)) { + case 0: + data->state = STATE_GET_EXP_GAUGE; + break; + case 0xFFFE: + + break; + case 0xFFFF: + data->unk30[4] = move; + data->state = STATE_GET_EXP_WANTS_TO_LEARN_MOVE_PRINT; + break; + default: + if (data->ctx->selectedMonIndex[expBattler] == slot) { + BattleSystem_ReloadMonData(data->bsys, + data->ctx, + expBattler, + data->ctx->selectedMonIndex[expBattler]); + } + + msg.id = 4; // "{0} learned {1}!" + msg.tag = 10; + msg.param[0] = expBattler | (slot << 8); + msg.param[1] = move; + data->unk30[0] = ov12_0223C494(data->bsys, msgLoader, &msg, BattleSystem_GetTextFrameDelay(data->bsys)); + data->state = STATE_GET_EXP_LEARNED_MOVE_WAIT; + break; + } + + break; + } + + case STATE_GET_EXP_WANTS_TO_LEARN_MOVE_PRINT: + msg.id = 1178; // "{0} wants to learn the move {1}." + msg.tag = 10; + msg.param[0] = expBattler | (slot << 8); + msg.param[1] = data->unk30[4]; + data->unk30[0] = ov12_0223C494(data->bsys, msgLoader, &msg, BattleSystem_GetTextFrameDelay(data->bsys)); + data->state++; + break; + + case STATE_GET_EXP_CANT_LEARN_MORE_MOVES_PRINT: + msg.id = 1179; // "But {0} can't learn more than four moves." + msg.tag = 2; + msg.param[0] = expBattler | (slot << 8); + data->unk30[0] = ov12_0223C494(data->bsys, msgLoader, &msg, BattleSystem_GetTextFrameDelay(data->bsys)); + data->state++; + break; + + case STATE_GET_EXP_WANTS_TO_LEARN_MOVE_PRINT_WAIT: + case STATE_GET_EXP_CANT_LEARN_MORE_MOVES_PRINT_WAIT: + case STATE_GET_EXP_ONE_TWO_POOF_WAIT: + case STATE_GET_EXP_FORGOT_HOW_TO_USE_WAIT: + case STATE_GET_EXP_AND_DOTDOTDOT_WAIT: + case STATE_GET_EXP_MAKE_IT_FORGET_CANCELLED_WAIT: + if (TextPrinterCheckActive(data->unk30[0]) == FALSE) { + data->state++; + } + break; + + case STATE_GET_EXP_MAKE_IT_FORGET_PROMPT: + // "Make it forget another move?" + BattleController_EmitDrawYesNoBox(data->bsys, data->ctx, expBattler, 1180, 1, 0, 0); + data->state++; + break; + + case STATE_GET_EXP_MAKE_IT_FORGET_ANSWER: + if (ov12_0225682C(data->ctx, expBattler)) { + if (ov12_0225682C(data->ctx, expBattler) == 0xFF) { // TODO: could use a const + data->state = STATE_GET_EXP_MAKE_IT_FORGET_CANCELLED; + } else { + msg.id = 1183; // "Which move should be forgotten?" + msg.tag = 0; + data->unk30[0] = ov12_0223C494(data->bsys, msgLoader, &msg, BattleSystem_GetTextFrameDelay(data->bsys)); + data->state = 22; + } + } + break; + + case STATE_GET_EXP_MAKE_IT_FORGET_WAIT: + if (TextPrinterCheckActive(data->unk30[0]) == FALSE) { + ov12_02263D14(data->bsys, expBattler, data->unk30[4], slot); + data->state++; + } + break; + + case STATE_GET_EXP_MAKE_IT_FORGET_INPUT_TAKEN: + if (ov12_0225682C(data->ctx, expBattler) == 0xFF) { + data->state = STATE_GET_EXP_MAKE_IT_FORGET_CANCELLED; + } else if (ov12_0225682C(data->ctx, expBattler)) { + data->unk30[5] = data->ctx->unk_2300[expBattler][0] - 1; + data->state = 24; + } + break; + + case STATE_GET_EXP_MAKE_IT_FORGET_CANCELLED: + msg.id = 1184; // "Well, then..." + msg.tag = 0; + data->unk30[0] = ov12_0223C494(data->bsys, msgLoader, &msg, BattleSystem_GetTextFrameDelay(data->bsys)); + data->state++; + break; + + case STATE_GET_EXP_GIVE_UP_LEARNING_PROMPT: + // "Should this Pokémon give up on learning this new move?" + BattleController_EmitDrawYesNoBox(data->bsys, data->ctx, expBattler, 1185, 2, data->unk30[4], 0); + data->state++; + break; + + case STATE_GET_EXP_GIVE_UP_LEARNING_ANSWER: + if (ov12_0225682C(data->ctx, expBattler)) { + if (ov12_0225682C(data->ctx, expBattler) == 0xFF) { + data->state = STATE_GET_EXP_WANTS_TO_LEARN_MOVE_PRINT; + } else { + msg.id = 1188; // "{0} did not learn {1}." + msg.tag = 10; + msg.param[0] = expBattler | (slot << 8); + msg.param[1] = data->unk30[4]; + data->unk30[0] = ov12_0223C494(data->bsys, msgLoader, &msg, BattleSystem_GetTextFrameDelay(data->bsys)); + data->state = 35; + } + } + break; + + case STATE_GET_EXP_GIVE_UP_LEARNING_WAIT: + if (TextPrinterCheckActive(data->unk30[0]) == FALSE) { + // Check for another move to learn + data->state = STATE_GET_EXP_CHECK_LEARN_MOVE; + } + break; + + case STATE_GET_EXP_ONE_TWO_POOF: + msg.id = 1189; // "1, 2, and... ... Poof!" + msg.tag = 0; + data->unk30[0] = ov12_0223C494(data->bsys, msgLoader, &msg, BattleSystem_GetTextFrameDelay(data->bsys)); + data->state++; + break; + + case STATE_GET_EXP_FORGOT_HOW_TO_USE: + msg.id = 1190; // "{0} forgot how to use {1}." + msg.tag = 10; + msg.param[0] = expBattler | (slot << 8); + msg.param[1] = GetMonData(mon, 54 + data->unk30[5], NULL); + data->unk30[0] = ov12_0223C494(data->bsys, msgLoader, &msg, BattleSystem_GetTextFrameDelay(data->bsys)); + data->state++; + break; + + case STATE_GET_EXP_AND_DOTDOTDOT: + msg.id = 1191; // "And..." + msg.tag = 0; + data->unk30[0] = ov12_0223C494(data->bsys, msgLoader, &msg, BattleSystem_GetTextFrameDelay(data->bsys)); + data->state++; + break; + + case STATE_GET_EXP_LEARNED_MOVE: + msg.id = 1192; // "{0} learned {1}!" + msg.tag = 10; + msg.param[0] = expBattler | (slot << 8); + msg.param[1] = data->unk30[4]; + data->unk30[0] = ov12_0223C494(data->bsys, msgLoader, &msg, BattleSystem_GetTextFrameDelay(data->bsys)); + + i = 0; + SetMonData(mon, MON_DATA_MOVE1PPUP + data->unk30[5], &i); + MonSetMoveInSlot(mon, data->unk30[4], data->unk30[5]); + + if (data->ctx->selectedMonIndex[expBattler] == slot) { + BattleSystem_ReloadMonData(data->bsys, + data->ctx, + expBattler, + data->ctx->selectedMonIndex[expBattler]); + } + + data->state = STATE_GET_EXP_LEARNED_MOVE_WAIT; + break; + + case STATE_GET_EXP_LEARNED_MOVE_WAIT: + if (TextPrinterCheckActive(data->unk30[0]) == FALSE) { + // Check for another move to learn + data->state = STATE_GET_EXP_CHECK_LEARN_MOVE; + } + break; + + case STATE_GET_EXP_CHECK_DONE: + data->ctx->unk_A4[battler] &= (MaskOfFlagNo(slot) ^ 0xFFFFFFFF); // this mon is done + data->unk30[6] = slot + 1; + data->state = STATE_GET_EXP_START; // go back to the top and get the next mon + break; + + case STATE_GET_EXP_DONE: + data->ctx->getterWork = NULL; + FreeToHeap(inData); + DestroySysTask(task); + break; + } +} From 2ff5b0d84b394da9632a79018b26d9e3514f93fc Mon Sep 17 00:00:00 2001 From: Adrienn Tindall <33725376+adrienntindall@users.noreply.github.com> Date: Thu, 16 Nov 2023 09:01:32 -0500 Subject: [PATCH 03/33] Update battle_022378C0.c --- src/battle/battle_022378C0.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/battle/battle_022378C0.c b/src/battle/battle_022378C0.c index 112fabb706..62ec274d40 100644 --- a/src/battle/battle_022378C0.c +++ b/src/battle/battle_022378C0.c @@ -219,7 +219,7 @@ void ov12_02237BB8(BattleSystem *bsys) { bsys->unk240F_1 = 1; ov12_0226604C(bsys->bgConfig); - GX_EngineBToggleLayers((int) GX_PLANEMASK_OBJ, GX_LAYER_TOGGLE_ON); + GfGfx_EngineBTogglePlanes((int) GX_PLANEMASK_OBJ, GX_LAYER_TOGGLE_ON); ov12_02266390(bsys->unk19C); ov12_02266508(unkNarcA, unkNarcB, bsys->unk19C, 0, TRUE, NULL); ov12_02266644(unkNarcB, bsys->unk19C); @@ -236,8 +236,8 @@ void ov12_02237BB8(BattleSystem *bsys) { void ov12_02237CC4(BattleSystem *bsys) { RemoveWindow(bsys->window); - GX_EngineAToggleLayers(GX_PLANEMASK_BG0, GX_LAYER_TOGGLE_OFF); - GX_EngineAToggleLayers(GX_PLANEMASK_BG1, GX_LAYER_TOGGLE_OFF); + GfGfx_EngineATogglePlanes(GX_PLANEMASK_BG0, GX_LAYER_TOGGLE_OFF); + GfGfx_EngineATogglePlanes(GX_PLANEMASK_BG1, GX_LAYER_TOGGLE_OFF); FreeBgTilemapBuffer(bsys->bgConfig, 1); FreeBgTilemapBuffer(bsys->bgConfig, 2); FreeBgTilemapBuffer(bsys->bgConfig, 3); From d684b6411793bbf86ec34a25fa0e2ae4bfa65d68 Mon Sep 17 00:00:00 2001 From: Adrienn Tindall <33725376+adrienntindall@users.noreply.github.com> Date: Thu, 16 Nov 2023 09:42:19 -0500 Subject: [PATCH 04/33] Update constants --- lib/include/nitro/gx/gx.h | 9 --------- src/battle/battle_022378C0.c | 8 ++++---- 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/lib/include/nitro/gx/gx.h b/lib/include/nitro/gx/gx.h index bb01db15b4..f77806740c 100644 --- a/lib/include/nitro/gx/gx.h +++ b/lib/include/nitro/gx/gx.h @@ -25,15 +25,6 @@ typedef enum { GX_BGMODE_6 = 6 } GXBGMode; -typedef enum { - GX_PLANEMASK_NONE = 0, - GX_PLANEMASK_BG0 = (1 << 0), - GX_PLANEMASK_BG1 = (1 << 1), - GX_PLANEMASK_BG2 = (1 << 2), - GX_PLANEMASK_BG3 = (1 << 3), - GX_PLANEMASK_OBJ = (1 << 4) -} GXPlaneMask; - typedef enum { GX_BG0_AS_2D = 0, GX_BG0_AS_3D = 1 diff --git a/src/battle/battle_022378C0.c b/src/battle/battle_022378C0.c index 62ec274d40..722ef7dd16 100644 --- a/src/battle/battle_022378C0.c +++ b/src/battle/battle_022378C0.c @@ -2,6 +2,7 @@ #include "battle/overlay_12_02266024.h" #include "battle/battle_system.h" #include "battle/battle_input.h" +#include "gf_gfx_planes.h" #include "render_text.h" #include "system.h" #include "vram_transfer_manager.h" @@ -10,7 +11,6 @@ #include "unk_020379A0.h" #include "unk_020755E8.h" #include "unk_02026E84.h" -#include "gx_layers.h" #include "constants/game_stats.h" #include "filesystem_files_def.h" @@ -219,7 +219,7 @@ void ov12_02237BB8(BattleSystem *bsys) { bsys->unk240F_1 = 1; ov12_0226604C(bsys->bgConfig); - GfGfx_EngineBTogglePlanes((int) GX_PLANEMASK_OBJ, GX_LAYER_TOGGLE_ON); + GfGfx_EngineBTogglePlanes(GX_PLANEMASK_OBJ, GF_PLANE_TOGGLE_ON); ov12_02266390(bsys->unk19C); ov12_02266508(unkNarcA, unkNarcB, bsys->unk19C, 0, TRUE, NULL); ov12_02266644(unkNarcB, bsys->unk19C); @@ -236,8 +236,8 @@ void ov12_02237BB8(BattleSystem *bsys) { void ov12_02237CC4(BattleSystem *bsys) { RemoveWindow(bsys->window); - GfGfx_EngineATogglePlanes(GX_PLANEMASK_BG0, GX_LAYER_TOGGLE_OFF); - GfGfx_EngineATogglePlanes(GX_PLANEMASK_BG1, GX_LAYER_TOGGLE_OFF); + GfGfx_EngineATogglePlanes(GX_PLANEMASK_BG0, GF_PLANE_TOGGLE_OFF); + GfGfx_EngineATogglePlanes(GX_PLANEMASK_BG1, GF_PLANE_TOGGLE_OFF); FreeBgTilemapBuffer(bsys->bgConfig, 1); FreeBgTilemapBuffer(bsys->bgConfig, 2); FreeBgTilemapBuffer(bsys->bgConfig, 3); From 881ba91f8ea715d121b8e8b3f7c04e9570a84839 Mon Sep 17 00:00:00 2001 From: Adrienn Tindall <33725376+adrienntindall@users.noreply.github.com> Date: Thu, 16 Nov 2023 14:15:44 -0500 Subject: [PATCH 05/33] Decompile battle_02261FD4 --- asm/overlay_12_02261FD4.s | 109 ------------------------------- include/battle/battle.h | 2 +- include/battle/battle_02261FD4.h | 9 +++ include/unk_02007FD8.h | 6 ++ main.lsf | 2 +- src/battle/battle_02261FD4.c | 39 +++++++++++ 6 files changed, 56 insertions(+), 111 deletions(-) delete mode 100644 asm/overlay_12_02261FD4.s create mode 100644 include/battle/battle_02261FD4.h create mode 100644 include/unk_02007FD8.h create mode 100644 src/battle/battle_02261FD4.c diff --git a/asm/overlay_12_02261FD4.s b/asm/overlay_12_02261FD4.s deleted file mode 100644 index f188beadbe..0000000000 --- a/asm/overlay_12_02261FD4.s +++ /dev/null @@ -1,109 +0,0 @@ - .include "asm/macros.inc" - .include "overlay_12_02261FD4.inc" - .include "global.inc" - - .text - - thumb_func_start ov12_02261FD4 -ov12_02261FD4: ; 0x02261FD4 - push {r4, lr} - add r4, r0, #0 - mov r0, #0x66 - lsl r0, r0, #2 - ldr r0, [r4, r0] - cmp r0, #0 - bne _02262008 - add r0, r1, #0 - bl BattleSystem_GetBattleType - mov r1, #0x22 - lsl r1, r1, #4 - tst r0, r1 - bne _02262008 - mov r1, #0xb4 - add r0, r1, #0 - add r0, #0xe8 - strh r1, [r4, r0] - ldr r0, _0226200C ; =ov12_0226203C - ldr r2, _02262010 ; =0x000003F2 - add r1, r4, #0 - bl CreateSysTask - mov r1, #0x66 - lsl r1, r1, #2 - str r0, [r4, r1] -_02262008: - pop {r4, pc} - nop -_0226200C: .word ov12_0226203C -_02262010: .word 0x000003F2 - thumb_func_end ov12_02261FD4 - - thumb_func_start ov12_02262014 -ov12_02262014: ; 0x02262014 - push {r4, lr} - add r4, r0, #0 - mov r0, #0x66 - lsl r0, r0, #2 - ldr r0, [r4, r0] - cmp r0, #0 - beq _0226203A - bl DestroySysTask - mov r0, #0x66 - mov r2, #0 - lsl r0, r0, #2 - str r2, [r4, r0] - add r0, r0, #4 - strh r2, [r4, r0] - ldr r0, [r4, #0x20] - mov r1, #4 - bl sub_020087A4 -_0226203A: - pop {r4, pc} - thumb_func_end ov12_02262014 - - thumb_func_start ov12_0226203C -ov12_0226203C: ; 0x0226203C - push {r3, r4, r5, lr} - add r4, r1, #0 - mov r1, #0x67 - lsl r1, r1, #2 - ldrh r0, [r4, r1] - add r0, #0x14 - strh r0, [r4, r1] - add r0, r1, #0 - ldrh r2, [r4, r1] - sub r0, #0x34 - cmp r2, r0 - blo _0226205C - add r0, r1, #0 - sub r0, #0x34 - sub r0, r2, r0 - strh r0, [r4, r1] -_0226205C: - mov r0, #0x67 - lsl r0, r0, #2 - ldrh r0, [r4, r0] - bl GF_SinDegNoWrap - mov r2, #6 - asr r1, r0, #0x1f - lsl r2, r2, #0xa - mov r3, #0 - bl _ll_mul - add r2, r1, #0 - mov r1, #4 - add r5, r0, #0 - ldr r0, [r4, #0x20] - mov r4, #0 - lsl r3, r1, #9 - add r3, r5, r3 - adc r2, r4 - lsl r2, r2, #0x14 - lsr r3, r3, #0xc - orr r3, r2 - asr r2, r3, #0xb - lsr r2, r2, #0x14 - add r2, r3, r2 - asr r2, r2, #0xc - bl sub_020087A4 - pop {r3, r4, r5, pc} - .balign 4, 0 - thumb_func_end ov12_0226203C diff --git a/include/battle/battle.h b/include/battle/battle.h index a79bc038a2..46ec18e892 100644 --- a/include/battle/battle.h +++ b/include/battle/battle.h @@ -485,7 +485,7 @@ typedef struct OpponentData { u8 unk195; u8 unk196; u8 unk197; - u32 unk198; + SysTask *unk198; u16 unk19C; int unk1A0; u32 *unk1A4; diff --git a/include/battle/battle_02261FD4.h b/include/battle/battle_02261FD4.h new file mode 100644 index 0000000000..722367036b --- /dev/null +++ b/include/battle/battle_02261FD4.h @@ -0,0 +1,9 @@ +#ifndef POKEHEARTGOLD_BATTLE_02261FD4_H +#define POKEHEARTGOLD_BATTLE_02261FD4_H + +#include "battle.h" + +void ov12_02261FD4(OpponentData *data, BattleSystem *bsys); +void ov12_02262014(OpponentData *data); + +#endif diff --git a/include/unk_02007FD8.h b/include/unk_02007FD8.h new file mode 100644 index 0000000000..74c19bf3fd --- /dev/null +++ b/include/unk_02007FD8.h @@ -0,0 +1,6 @@ +#ifndef POKEHEARTGOLD_UNK_02007FD8_H +#define POKEHEARTGOLD_UNK_02007FD8_H + +void sub_020087A4(u32 *a0, int a1, int dy); + +#endif //POKEHEARTGOLD_UNK_02007FD8_H diff --git a/main.lsf b/main.lsf index f94f69f213..8cec2730b6 100644 --- a/main.lsf +++ b/main.lsf @@ -574,7 +574,7 @@ Overlay OVY_12 Object asm/overlay_12_battle_controller_player.o Object src/battle/overlay_12_0224E4FC.o Object asm/overlay_12_battle_controller_opponent.o - Object asm/overlay_12_02261FD4.o + Object src/battle/battle_02261FD4.o Object asm/overlay_12_battle_controller.o Object asm/overlay_12_hp_bar.o Object asm/overlay_12_02265E28.o diff --git a/src/battle/battle_02261FD4.c b/src/battle/battle_02261FD4.c new file mode 100644 index 0000000000..6564935002 --- /dev/null +++ b/src/battle/battle_02261FD4.c @@ -0,0 +1,39 @@ +#include "battle/battle_02261FD4.h" +#include "battle/battle_system.h" +#include "math_util.h" +#include "unk_02007FD8.h" + +static void ov12_0226203C(SysTask *task, void *_data); + +void ov12_02261FD4(OpponentData *data, BattleSystem *bsys) { + if (data->unk198 == NULL && !(BattleSystem_GetBattleType(bsys) & (BATTLE_TYPE_SAFARI | BATTLE_TYPE_PAL_PARK))) + { + data->unk19C = 180; + data->unk198 = CreateSysTask(ov12_0226203C, data, 0x3F2); + } +} + +void ov12_02262014(OpponentData *data) { + if (data->unk198 != NULL) + { + DestroySysTask(data->unk198); + data->unk198 = NULL; + data->unk19C = 0; + sub_020087A4(data->unk20, 4, 0); + } +} + +static void ov12_0226203C(SysTask *task, void *_data) { + OpponentData *data = _data; + + data->unk19C += 20; + + if (data->unk19C >= 360) + { + data->unk19C -= 360; + } + + int dy = FX_Mul(GF_SinDegNoWrap(data->unk19C), 0x1800) / FX32_ONE; + + sub_020087A4(data->unk20, 4, dy); +} From b36e83f4710b6034a60ee1e4bafe598bbc2abab5 Mon Sep 17 00:00:00 2001 From: Adrienn Tindall <33725376+adrienntindall@users.noreply.github.com> Date: Fri, 17 Nov 2023 15:21:05 -0500 Subject: [PATCH 06/33] Added message consts to battle_command --- src/battle/battle_command.c | 87 ++++++++++++++++++------------------- 1 file changed, 42 insertions(+), 45 deletions(-) diff --git a/src/battle/battle_command.c b/src/battle/battle_command.c index 871546bc2c..9f8030037c 100644 --- a/src/battle/battle_command.c +++ b/src/battle/battle_command.c @@ -25,6 +25,7 @@ #include "constants/moves.h" #include "constants/pokemon.h" #include "constants/sndseq.h" +#include "msg_0197.gmm" int BattleScriptReadWord(BattleContext *ctx); static void BattleScriptIncrementPointer(BattleContext *ctx, int adrs); @@ -1558,7 +1559,7 @@ BOOL BtlCmd_BufferStatChangeMsg(BattleSystem *bsys, BattleContext *ctx) { if (ctx->statChangeType == 3 || ctx->statChangeType == 2) { BattleScriptIncrementPointer(ctx, unkB); } else { - ctx->buffMsg.id = 142; + ctx->buffMsg.id = msg_0197_00142; //{0}'s {1} won't go any higher! ctx->buffMsg.tag = 12; ctx->buffMsg.param[0] = CreateNicknameTag(ctx, ctx->battlerIdStatChange); ctx->buffMsg.param[1] = stat + 1; @@ -1566,19 +1567,19 @@ BOOL BtlCmd_BufferStatChangeMsg(BattleSystem *bsys, BattleContext *ctx) { } } else { if (ctx->statChangeType == 3) { - ctx->buffMsg.id = 0x26E; + ctx->buffMsg.id = msg_0197_00622; //{0}'s {1} raised its {2} ctx->buffMsg.tag = 39; ctx->buffMsg.param[0] = CreateNicknameTag(ctx, ctx->battlerIdStatChange); ctx->buffMsg.param[1] = ctx->battleMons[ctx->battlerIdStatChange].ability; ctx->buffMsg.param[2] = stat + 1; } else if (ctx->statChangeType == 5) { - ctx->buffMsg.id = 0x2F4; + ctx->buffMsg.id = msg_0197_00756; //The {1} raised {0}'s {2} ctx->buffMsg.tag = 45; ctx->buffMsg.param[0] = CreateNicknameTag(ctx, ctx->battlerIdStatChange); ctx->buffMsg.param[1] = ctx->itemTemp; ctx->buffMsg.param[2] = stat + 1; } else { - ctx->buffMsg.id = (change == 1) ? 0x2EE:0x2F1; + ctx->buffMsg.id = (change == 1) ? msg_0197_00750:msg_0197_00753; //{0}'s {1} (sharply) rose! ctx->buffMsg.tag = 12; ctx->buffMsg.param[0] = CreateNicknameTag(ctx, ctx->battlerIdStatChange); ctx->buffMsg.param[1] = stat + 1; @@ -1593,20 +1594,20 @@ BOOL BtlCmd_BufferStatChangeMsg(BattleSystem *bsys, BattleContext *ctx) { if (ctx->battlerIdAttacker != ctx->battlerIdStatChange) { //Mist if(ctx->fieldSideConditionData[BattleSystem_GetFieldSide(bsys, ctx->battlerIdStatChange)].mistTurns) { - ctx->buffMsg.id = 273; + ctx->buffMsg.id = msg_0197_00273; // {0} is protected by Mist! ctx->buffMsg.tag = 2; ctx->buffMsg.param[0] = CreateNicknameTag(ctx, ctx->battlerIdStatChange); unkD = 1; } else if (CheckBattlerAbilityIfNotIgnored(ctx, ctx->battlerIdAttacker, ctx->battlerIdStatChange, ABILITY_CLEAR_BODY) == TRUE || CheckBattlerAbilityIfNotIgnored(ctx, ctx->battlerIdAttacker, ctx->battlerIdStatChange, ABILITY_WHITE_SMOKE) == TRUE) { if (ctx->statChangeType == 3) { - ctx->buffMsg.id = 0x2D7; + ctx->buffMsg.id = msg_0197_00727; //{0}'s {1} suppressed {2}'s {3} ctx->buffMsg.tag = 53; ctx->buffMsg.param[0] = CreateNicknameTag(ctx, ctx->battlerIdStatChange); ctx->buffMsg.param[1] = ctx->battleMons[ctx->battlerIdStatChange].ability; ctx->buffMsg.param[2] = CreateNicknameTag(ctx, ctx->battlerIdAttacker); ctx->buffMsg.param[3] = ctx->battleMons[ctx->battlerIdAttacker].ability; } else { - ctx->buffMsg.id = 0x29D; + ctx->buffMsg.id = msg_0197_00669; //{0}'s {1} prevents stat loss! ctx->buffMsg.tag = 11; ctx->buffMsg.param[0] = CreateNicknameTag(ctx, ctx->battlerIdStatChange); ctx->buffMsg.param[1] = ctx->battleMons[ctx->battlerIdStatChange].ability; @@ -1615,14 +1616,14 @@ BOOL BtlCmd_BufferStatChangeMsg(BattleSystem *bsys, BattleContext *ctx) { } else if ((CheckBattlerAbilityIfNotIgnored(ctx, ctx->battlerIdAttacker, ctx->battlerIdStatChange, ABILITY_KEEN_EYE) == TRUE && (1 + stat) == 6) || (CheckBattlerAbilityIfNotIgnored(ctx, ctx->battlerIdAttacker, ctx->battlerIdStatChange, ABILITY_HYPER_CUTTER) == TRUE && (1 + stat) == 1)) { if (ctx->statChangeType == 3) { - ctx->buffMsg.id = 0x2D7; + ctx->buffMsg.id = msg_0197_00727; //{0}'s {1} suppressed {2}'s {3} ctx->buffMsg.tag = 53; ctx->buffMsg.param[0] = CreateNicknameTag(ctx, ctx->battlerIdStatChange); ctx->buffMsg.param[1] = ctx->battleMons[ctx->battlerIdStatChange].ability; ctx->buffMsg.param[2] = CreateNicknameTag(ctx, ctx->battlerIdAttacker); ctx->buffMsg.param[3] = ctx->battleMons[ctx->battlerIdAttacker].ability; } else { - ctx->buffMsg.id = 704; + ctx->buffMsg.id = msg_0197_00704; //{0}'s {1} prvents {2} loss! ctx->buffMsg.tag = 39; ctx->buffMsg.param[0] = CreateNicknameTag(ctx, ctx->battlerIdStatChange); ctx->buffMsg.param[1] = ctx->battleMons[ctx->battlerIdStatChange].ability; @@ -1636,7 +1637,7 @@ BOOL BtlCmd_BufferStatChangeMsg(BattleSystem *bsys, BattleContext *ctx) { BattleScriptIncrementPointer(ctx, unkB); return FALSE; } else { - ctx->buffMsg.id = 145; + ctx->buffMsg.id = msg_0197_00145; //{0}'s {1} won't go lower! ctx->buffMsg.tag = 12; ctx->buffMsg.param[0] = CreateNicknameTag(ctx, ctx->battlerIdStatChange); ctx->buffMsg.param[1] = stat + 1; @@ -1654,7 +1655,7 @@ BOOL BtlCmd_BufferStatChangeMsg(BattleSystem *bsys, BattleContext *ctx) { BattleScriptIncrementPointer(ctx, unkB); return FALSE; } else { - ctx->buffMsg.id = 145; + ctx->buffMsg.id = msg_0197_00145; //{0}'s {1} won't go lower! ctx->buffMsg.tag = 12; ctx->buffMsg.param[0] = CreateNicknameTag(ctx, ctx->battlerIdStatChange); ctx->buffMsg.param[1] = stat + 1; @@ -1674,14 +1675,14 @@ BOOL BtlCmd_BufferStatChangeMsg(BattleSystem *bsys, BattleContext *ctx) { } } if (ctx->statChangeType == 3) { - ctx->buffMsg.id = 0x296; + ctx->buffMsg.id = msg_0197_00662; //{0}'s {1} cuts {2}'s {3} ctx->buffMsg.tag = 54; ctx->buffMsg.param[0] = CreateNicknameTag(ctx, ctx->battlerIdAttacker); ctx->buffMsg.param[1] = ctx->battleMons[ctx->battlerIdAttacker].ability; ctx->buffMsg.param[2] = CreateNicknameTag(ctx, ctx->battlerIdStatChange); ctx->buffMsg.param[3] = stat + 1; } else { - ctx->buffMsg.id = (change == -1) ? 0x2FA:0x2FD; + ctx->buffMsg.id = (change == -1) ? msg_0197_00762 : msg_0197_00765; //{0}'s {1} (harsly) fell! ctx->buffMsg.tag = 12; ctx->buffMsg.param[0] = CreateNicknameTag(ctx, ctx->battlerIdStatChange); ctx->buffMsg.param[1] = stat + 1; @@ -2499,9 +2500,9 @@ BOOL BtlCmd_TryLightScreen(BattleSystem *bsys, BattleContext *ctx) { ctx->buffMsg.param[0] = ctx->moveNoCur; ctx->buffMsg.param[1] = ctx->battlerIdAttacker; if (GetMonsHitCount(bsys, ctx, 1, ctx->battlerIdAttacker) == 2) { - ctx->buffMsg.id = 192; + ctx->buffMsg.id = msg_0197_00192; //{0} raised your team's special defence slightly! } else { - ctx->buffMsg.id = 190; + ctx->buffMsg.id = msg_0197_00190; //{0} raised your team's special defence! } } return FALSE; @@ -2528,9 +2529,9 @@ BOOL BtlCmd_TryReflect(BattleSystem *bsys, BattleContext *ctx) { ctx->buffMsg.param[0] = ctx->moveNoCur; ctx->buffMsg.param[1] = ctx->battlerIdAttacker; if (GetMonsHitCount(bsys, ctx, 1, ctx->battlerIdAttacker) == 2) { - ctx->buffMsg.id = 196; + ctx->buffMsg.id = msg_0197_00196; } else { - ctx->buffMsg.id = 194; + ctx->buffMsg.id = msg_0197_00194; } } return FALSE; @@ -3090,11 +3091,11 @@ BOOL BtlCmd_TryProtect(BattleSystem *bsys, BattleContext *ctx) { if (sProtectSuccessChance[ctx->battleMons[ctx->battlerIdAttacker].unk88.protectSuccessTurns] >= (u32) BattleSystem_Random(bsys) && flag) { if (ctx->unk_334.moveData[ctx->moveNoCur].effect == 111) { ctx->turnData[ctx->battlerIdAttacker].protectFlag = TRUE; - ctx->buffMsg.id = 282; + ctx->buffMsg.id = msg_0197_00282; } if (ctx->unk_334.moveData[ctx->moveNoCur].effect == 116) { ctx->turnData[ctx->battlerIdAttacker].unk0_9 = TRUE; - ctx->buffMsg.id = 442; + ctx->buffMsg.id = msg_0197_00442; } ctx->buffMsg.tag = 2; @@ -3492,7 +3493,7 @@ BOOL BtlCmd_TrySafeguard(BattleSystem *bsys, BattleContext *ctx) { ctx->fieldSideConditionData[fieldSide].safeguardBattler = ctx->battlerIdAttacker; ctx->buffMsg.tag = 1; ctx->buffMsg.param[0] = ctx->battlerIdAttacker; - ctx->buffMsg.id = 198; + ctx->buffMsg.id = msg_0197_00198; } return FALSE; @@ -3777,7 +3778,7 @@ BOOL BtlCmd_BeatUpDamageCalc(BattleSystem *bsys, BattleContext *ctx) { ctx->damage = ApplyDamageRange(bsys, ctx, ctx->damage); ctx->damage *= -1; - ctx->buffMsg.id = 0x1e1; + ctx->buffMsg.id = msg_0197_00481; ctx->buffMsg.tag = 2; ctx->buffMsg.param[0] = (ctx->battlerIdAttacker | (ctx->beatUpCount << 8)); @@ -4013,13 +4014,13 @@ BOOL BtlCmd_TryKnockOff(BattleSystem *bsys, BattleContext *ctx) { int side = BattleSystem_GetFieldSide(bsys, ctx->battlerIdTarget); if (ctx->battleMons[ctx->battlerIdTarget].item && CheckBattlerAbilityIfNotIgnored(ctx, ctx->battlerIdAttacker, ctx->battlerIdTarget, ABILITY_STICKY_HOLD) == TRUE) { - ctx->buffMsg.id = 0x2ca; + ctx->buffMsg.id = msg_0197_00714; ctx->buffMsg.tag = 37; ctx->buffMsg.param[0] = CreateNicknameTag(ctx, ctx->battlerIdTarget); ctx->buffMsg.param[1] = ctx->battleMons[ctx->battlerIdTarget].ability; ctx->buffMsg.param[2] = ctx->moveNoCur; } else if (ctx->battleMons[ctx->battlerIdTarget].item) { - ctx->buffMsg.id = 0x228; + ctx->buffMsg.id = msg_0197_00552; ctx->buffMsg.tag = 33; ctx->buffMsg.param[0] = CreateNicknameTag(ctx, ctx->battlerIdAttacker); ctx->buffMsg.param[1] = CreateNicknameTag(ctx, ctx->battlerIdTarget); @@ -5923,19 +5924,16 @@ enum { STATE_GET_EXP_WAIT_MESSAGE_DELAY, STATE_GET_EXP_GAUGE, STATE_GET_EXP_WAIT_GAUGE, - - STATE_GET_EXP_CHECK_LEVEL_UP, //5 + STATE_GET_EXP_CHECK_LEVEL_UP, STATE_GET_EXP_WAIT_LEVEL_UP_EFFECT, STATE_GET_EXP_WAIT_LEVEL_UP_MESSAGE_PRINT, - STATE_GET_EXP_LEVEL_UP_SUMMARY_LOAD_ICON, STATE_GET_EXP_LEVEL_UP_SUMMARY_INIT, - STATE_GET_EXP_LEVEL_UP_SUMMARY_PRINT_DIFF, //10 + STATE_GET_EXP_LEVEL_UP_SUMMARY_PRINT_DIFF, STATE_GET_EXP_LEVEL_UP_SUMMARY_PRINT_DIFF_WAIT, STATE_GET_EXP_LEVEL_UP_SUMMARY_PRINT_TRUE, STATE_GET_EXP_LEVEL_UP_SUMMARY_PRINT_TRUE_WAIT, STATE_GET_EXP_LEVEL_UP_CLEAR, - STATE_GET_EXP_CHECK_LEARN_MOVE, STATE_GET_EXP_WANTS_TO_LEARN_MOVE_PRINT, STATE_GET_EXP_WANTS_TO_LEARN_MOVE_PRINT_WAIT, @@ -5958,7 +5956,6 @@ enum { STATE_GET_EXP_GIVE_UP_LEARNING_ANSWER, STATE_GET_EXP_GIVE_UP_LEARNING_WAIT, STATE_GET_EXP_LEARNED_MOVE_WAIT, - STATE_GET_EXP_CHECK_DONE, STATE_GET_EXP_DONE, }; @@ -6029,7 +6026,7 @@ static void Task_GetExp(SysTask *task, void *inData) } u32 totalExp = 0; - msg.id = 1; // "{0} gained {1} Exp. Points!" + msg.id = msg_0197_00001; // "{0} gained {1} Exp. Points!" if (GetMonData(mon, MON_DATA_HP, NULL) && GetMonData(mon, MON_DATA_LEVEL, NULL) != 100) { if (data->ctx->unk_A4[battler] & MaskOfFlagNo(slot)) { @@ -6055,7 +6052,7 @@ static void Task_GetExp(SysTask *task, void *inData) totalExp = totalExp * 150 / 100; } - msg.id = 2; // "{0} gained a boosted {1} Exp. Points!" + msg.id = msg_0197_00002; // "{0} gained a boosted {1} Exp. Points!" } u32 newExp = GetMonData(mon, MON_DATA_EXPERIENCE, NULL); @@ -6156,7 +6153,7 @@ static void Task_GetExp(SysTask *task, void *inData) data->ctx->levelUpMons |= MaskOfFlagNo(slot); ov12_02263A1C(data->bsys, data->ctx, expBattler); - msg.id = 3; // "{0} grew to Lv. {1}!" + msg.id = msg_0197_00003; // "{0} grew to Lv. {1}!" msg.tag = 17; msg.param[0] = expBattler | (slot << 8); msg.param[1] = level; @@ -6211,13 +6208,13 @@ static void Task_GetExp(SysTask *task, void *inData) StatStruct *oldStats = data->ctx->unk_17C; for (i = 0; i < 6; i++) { - msg.id = 947; // stat name + msg.id = msg_0197_00947; // stat name msg.tag = 4; msg.param[0] = stats.stats[i]; ov12_0223C4E8(data->bsys, window, msgLoader, &msg, 0, 16 * i, 0, 0, 0); - msg.id = 948; // "+{0}" + msg.id = msg_0197_00948; // "+{0}" msg.tag = 7; msg.param[0] = GetMonData(mon, monData.stats[i], NULL) - oldStats->stats[i]; msg.unk1C = 2; @@ -6236,7 +6233,7 @@ static void Task_GetExp(SysTask *task, void *inData) FillWindowPixelRect(window, 0xF, 80, 0, 36, 96); // clear out the diff section (keep the printed stat names) for (i = 0; i < 6; i++) { - msg.id = 949; // just a number + msg.id = msg_0197_00949; // just a number msg.tag = 7; msg.param[0] = GetMonData(mon, monData.stats[i], NULL); msg.unk1C = 3; @@ -6300,7 +6297,7 @@ static void Task_GetExp(SysTask *task, void *inData) data->ctx->selectedMonIndex[expBattler]); } - msg.id = 4; // "{0} learned {1}!" + msg.id = msg_0197_00004; // "{0} learned {1}!" msg.tag = 10; msg.param[0] = expBattler | (slot << 8); msg.param[1] = move; @@ -6313,7 +6310,7 @@ static void Task_GetExp(SysTask *task, void *inData) } case STATE_GET_EXP_WANTS_TO_LEARN_MOVE_PRINT: - msg.id = 1178; // "{0} wants to learn the move {1}." + msg.id = msg_0197_01178; // "{0} wants to learn the move {1}." msg.tag = 10; msg.param[0] = expBattler | (slot << 8); msg.param[1] = data->unk30[4]; @@ -6322,7 +6319,7 @@ static void Task_GetExp(SysTask *task, void *inData) break; case STATE_GET_EXP_CANT_LEARN_MORE_MOVES_PRINT: - msg.id = 1179; // "But {0} can't learn more than four moves." + msg.id = msg_0197_01179; // "But {0} can't learn more than four moves." msg.tag = 2; msg.param[0] = expBattler | (slot << 8); data->unk30[0] = ov12_0223C494(data->bsys, msgLoader, &msg, BattleSystem_GetTextFrameDelay(data->bsys)); @@ -6351,7 +6348,7 @@ static void Task_GetExp(SysTask *task, void *inData) if (ov12_0225682C(data->ctx, expBattler) == 0xFF) { // TODO: could use a const data->state = STATE_GET_EXP_MAKE_IT_FORGET_CANCELLED; } else { - msg.id = 1183; // "Which move should be forgotten?" + msg.id = msg_0197_01183; // "Which move should be forgotten?" msg.tag = 0; data->unk30[0] = ov12_0223C494(data->bsys, msgLoader, &msg, BattleSystem_GetTextFrameDelay(data->bsys)); data->state = 22; @@ -6376,7 +6373,7 @@ static void Task_GetExp(SysTask *task, void *inData) break; case STATE_GET_EXP_MAKE_IT_FORGET_CANCELLED: - msg.id = 1184; // "Well, then..." + msg.id = msg_0197_01184; // "Well, then..." msg.tag = 0; data->unk30[0] = ov12_0223C494(data->bsys, msgLoader, &msg, BattleSystem_GetTextFrameDelay(data->bsys)); data->state++; @@ -6393,7 +6390,7 @@ static void Task_GetExp(SysTask *task, void *inData) if (ov12_0225682C(data->ctx, expBattler) == 0xFF) { data->state = STATE_GET_EXP_WANTS_TO_LEARN_MOVE_PRINT; } else { - msg.id = 1188; // "{0} did not learn {1}." + msg.id = msg_0197_01188; // "{0} did not learn {1}." msg.tag = 10; msg.param[0] = expBattler | (slot << 8); msg.param[1] = data->unk30[4]; @@ -6411,14 +6408,14 @@ static void Task_GetExp(SysTask *task, void *inData) break; case STATE_GET_EXP_ONE_TWO_POOF: - msg.id = 1189; // "1, 2, and... ... Poof!" + msg.id = msg_0197_01189; // "1, 2, and... ... Poof!" msg.tag = 0; data->unk30[0] = ov12_0223C494(data->bsys, msgLoader, &msg, BattleSystem_GetTextFrameDelay(data->bsys)); data->state++; break; case STATE_GET_EXP_FORGOT_HOW_TO_USE: - msg.id = 1190; // "{0} forgot how to use {1}." + msg.id = msg_0197_01190; // "{0} forgot how to use {1}." msg.tag = 10; msg.param[0] = expBattler | (slot << 8); msg.param[1] = GetMonData(mon, 54 + data->unk30[5], NULL); @@ -6427,14 +6424,14 @@ static void Task_GetExp(SysTask *task, void *inData) break; case STATE_GET_EXP_AND_DOTDOTDOT: - msg.id = 1191; // "And..." + msg.id = msg_0197_01191; // "And..." msg.tag = 0; data->unk30[0] = ov12_0223C494(data->bsys, msgLoader, &msg, BattleSystem_GetTextFrameDelay(data->bsys)); data->state++; break; case STATE_GET_EXP_LEARNED_MOVE: - msg.id = 1192; // "{0} learned {1}!" + msg.id = msg_0197_01192; // "{0} learned {1}!" msg.tag = 10; msg.param[0] = expBattler | (slot << 8); msg.param[1] = data->unk30[4]; From fa7714c0dafc67fd49a3a13e9f91e8f617832453 Mon Sep 17 00:00:00 2001 From: Adrienn Tindall <33725376+adrienntindall@users.noreply.github.com> Date: Mon, 20 Nov 2023 22:47:12 -0600 Subject: [PATCH 07/33] Indentation and stuff --- include/render_text.h | 2 +- include/render_window.h | 2 +- src/battle/battle_022378C0.c | 4 +- src/battle/battle_command.c | 763 +++++++++++++++++------------------ 4 files changed, 383 insertions(+), 388 deletions(-) diff --git a/include/render_text.h b/include/render_text.h index 1c2a472080..25e565a4aa 100644 --- a/include/render_text.h +++ b/include/render_text.h @@ -17,6 +17,6 @@ BOOL RenderText(struct TextPrinter *printer); void TextFlags_SetCanABSpeedUpPrint(BOOL enable); void sub_02002B50(BOOL enable); void sub_02002B8C(BOOL enable); -void sub_020027F0(); +void sub_020027F0(int a0); #endif //POKEHEARTGOLD_RENDER_TEXT_H diff --git a/include/render_window.h b/include/render_window.h index dc41dba972..ca9476d51b 100644 --- a/include/render_window.h +++ b/include/render_window.h @@ -17,6 +17,6 @@ void sub_0200F450(WaitingIcon *waitingIcon); struct PokepicManager *DrawPokemonPicFromSpecies(BgConfig *bgConfig, enum GFBgLayer layer, int x, int y, u8 paletteNum, u16 baseTile, u16 species, u8 gender, HeapID heapId); struct PokepicManager *DrawPokemonPicFromMon(BgConfig *bgConfig, enum GFBgLayer layer, int x, int y, u8 paletteNum, u16 baseTile, Pokemon *mon, HeapID heapId); void sub_0200E398(BgConfig *bgConfig, u32 a1, u32 a2, u32 a3, HeapID heapId); -u32 sub_0200E3D8(); +u32 sub_0200E3D8(void); #endif //POKEHEARTGOLD_RENDER_WINDOW_H diff --git a/src/battle/battle_022378C0.c b/src/battle/battle_022378C0.c index 722ef7dd16..bd3b59b826 100644 --- a/src/battle/battle_022378C0.c +++ b/src/battle/battle_022378C0.c @@ -230,7 +230,7 @@ void ov12_02237BB8(BattleSystem *bsys) { sub_020027F0(1); ov12_0223A620(bsys); - G2dRenderer_SetSubSurfaceCoords(SpriteRenderer_GetG2dRendererPtr(bsys->unk90), 0, 17 << 16); + G2dRenderer_SetSubSurfaceCoords(SpriteRenderer_GetG2dRendererPtr(bsys->unk90), 0, FX32_CONST(272)); } void ov12_02237CC4(BattleSystem *bsys) { @@ -243,5 +243,3 @@ void ov12_02237CC4(BattleSystem *bsys) { FreeBgTilemapBuffer(bsys->bgConfig, 3); BattleSystem_SetHpBarDisabled(bsys); } - - diff --git a/src/battle/battle_command.c b/src/battle/battle_command.c index 9f8030037c..3f1b510f01 100644 --- a/src/battle/battle_command.c +++ b/src/battle/battle_command.c @@ -25,7 +25,7 @@ #include "constants/moves.h" #include "constants/pokemon.h" #include "constants/sndseq.h" -#include "msg_0197.gmm" +#include "msgdata/msg/msg_0197.h" int BattleScriptReadWord(BattleContext *ctx); static void BattleScriptIncrementPointer(BattleContext *ctx, int adrs); @@ -318,7 +318,7 @@ BOOL BtlCmd_TrainerEncounter(BattleSystem *bsys, BattleContext *ctx) { case 3: for (battlerId = 0; battlerId < battlersMax; battlerId++) { opponentData = BattleSystem_GetOpponentData(bsys, battlerId); - if ((opponentData->unk195 & 1) == FALSE) { + if (!(opponentData->unk195 & 1)) { BattleController_EmitTrainerEncounter(bsys, battlerId); if ((BattleSystem_GetBattleType(bsys) & BATTLE_TYPE_MULTI) == 0 && (BattleSystem_GetBattleType(bsys) & BATTLE_TYPE_DOUBLES)) { @@ -370,7 +370,7 @@ BOOL BtlCmd_ThrowPokeball(BattleSystem *bsys, BattleContext *ctx) { case 3: for (battlerId = 0; battlerId < battlersMax; battlerId++) { opponentData = BattleSystem_GetOpponentData(bsys, battlerId); - if ((opponentData->unk195 & 1) == FALSE) { + if (!(opponentData->unk195 & 1)) { BattleController_EmitThrowPokeball(bsys, battlerId, unkC); if ((BattleSystem_GetBattleType(bsys) & BATTLE_TYPE_MULTI) == 0 && (BattleSystem_GetBattleType(bsys) & BATTLE_TYPE_DOUBLES)) { @@ -423,7 +423,7 @@ BOOL BtlCmd_TrainerSlideOut(BattleSystem *bsys, BattleContext *ctx) { case 3: for (battlerId = 0; battlerId < battlersMax; battlerId++) { opponentData = BattleSystem_GetOpponentData(bsys, battlerId); - if ((opponentData->unk195 & 1) == FALSE) { + if (!(opponentData->unk195 & 1)) { BattleController_EmitTrainerSlideOut(bsys, battlerId); if ((BattleSystem_GetBattleType(bsys) & BATTLE_TYPE_MULTI) == 0 && (BattleSystem_GetBattleType(bsys) & BATTLE_TYPE_DOUBLES)) { @@ -509,7 +509,7 @@ BOOL BtlCmd_TrainerSlideIn(BattleSystem *bsys, BattleContext *ctx) { case B_SIDE_PLAYER: for (battlerId = 0; battlerId < battlersMax; battlerId++) { opponentData = BattleSystem_GetOpponentData(bsys, battlerId); - if ((opponentData->unk195 & 1) == FALSE) { + if (!(opponentData->unk195 & 1)) { BattleController_EmitTrainerSlideIn(bsys, battlerId, index); if ((BattleSystem_GetBattleType(bsys) & BATTLE_TYPE_DOUBLES)) { break; @@ -2565,7 +2565,7 @@ BOOL BtlCmd_TryOHKO(BattleSystem *bsys, BattleContext *ctx) { if (CheckBattlerAbilityIfNotIgnored(ctx, ctx->battlerIdAttacker, ctx->battlerIdTarget, ABILITY_STURDY) == TRUE) { ctx->moveStatusFlag |= MOVE_STATUS_19; } else { - if ((ctx->battleMons[ctx->battlerIdTarget].moveEffectFlags & MOVE_EFFECT_FLAG_LOCK_ON) == FALSE && + if (!(ctx->battleMons[ctx->battlerIdTarget].moveEffectFlags & MOVE_EFFECT_FLAG_LOCK_ON) && GetBattlerAbility(ctx, ctx->battlerIdAttacker) != ABILITY_NO_GUARD && GetBattlerAbility(ctx, ctx->battlerIdTarget) != ABILITY_NO_GUARD) { hitChance = ctx->battleMons[ctx->battlerIdAttacker].level - ctx->battleMons[ctx->battlerIdTarget].level + ctx->unk_334.moveData[ctx->moveNoCur].accuracy; @@ -2648,7 +2648,7 @@ BOOL BtlCmd_TryMimic(BattleSystem *bsys, BattleContext *ctx) { int adrs = BattleScriptReadWord(ctx); - if ((CheckLegalMimicMove(ctx->moveNoBattlerPrev[ctx->battlerIdTarget]) == FALSE) || + if ((!CheckLegalMimicMove(ctx->moveNoBattlerPrev[ctx->battlerIdTarget])) || (ctx->battleMons[ctx->battlerIdAttacker].status2 & STATUS2_TRANSFORMED) || (ctx->battleMons[ctx->battlerIdTarget].status2 & STATUS2_SUBSTITUTE) || ctx->moveNoBattlerPrev[ctx->battlerIdTarget] == 0) { @@ -5476,7 +5476,7 @@ BOOL BtlCmd_CheckItemEffectOnHit(BattleSystem *bsys, BattleContext *ctx) { BattleScriptIncrementPointer(ctx, 1); int adrs = BattleScriptReadWord(ctx); - if (CheckItemEffectOnHit(bsys, ctx, &ctx->tempData) == FALSE) { + if (!CheckItemEffectOnHit(bsys, ctx, &ctx->tempData)) { BattleScriptIncrementPointer(ctx, adrs); } @@ -6004,470 +6004,467 @@ static void Task_GetExp(SysTask *task, void *inData) if (slot == BattleSystem_GetPartySize(data->bsys, expBattler)) { data->state = STATE_GET_EXP_DONE; } else if ((battleType & BATTLE_TYPE_DOUBLES) - && (battleType & BATTLE_TYPE_6) == FALSE + && !(battleType & BATTLE_TYPE_6) && data->ctx->selectedMonIndex[BATTLER_PLAYER2] == slot) { expBattler = 2; } switch (data->state) { - case STATE_GET_EXP_START: { - item = GetMonData(mon, MON_DATA_HELD_ITEM, NULL); - itemEffect = GetItemAttr(item, ITEM_VAR_HOLD_EFFECT, HEAP_ID_BATTLE); + case STATE_GET_EXP_START: { + item = GetMonData(mon, MON_DATA_HELD_ITEM, NULL); + itemEffect = GetItemAttr(item, ITEM_VAR_HOLD_EFFECT, HEAP_ID_BATTLE); + + // Declare victory if all wild mons have been defeated + if (!(battleType & BATTLE_TYPE_TRAINER) + && data->ctx->battleMons[BATTLER_ENEMY].hp + + data->ctx->battleMons[BATTLER_ENEMY2].hp == 0 + && GetMonData(mon, MON_DATA_HP, NULL) + && !data->ctx->unk_3144) { + PlayBGM(SEQ_GS_WIN2); + data->ctx->unk_3144 = TRUE; + BattleSystem_SetCriticalHpMusicFlag(data->bsys, 2); // turn off + } - // Declare victory if all wild mons have been defeated - if ((battleType & BATTLE_TYPE_TRAINER) == FALSE - && data->ctx->battleMons[BATTLER_ENEMY].hp - + data->ctx->battleMons[BATTLER_ENEMY2].hp == 0 - && GetMonData(mon, MON_DATA_HP, NULL) - && data->ctx->unk_3144 == FALSE) { - PlayBGM(SEQ_GS_WIN2); - data->ctx->unk_3144 = TRUE; - BattleSystem_SetCriticalHpMusicFlag(data->bsys, 2); // turn off - } + u32 totalExp = 0; + msg.id = msg_0197_00001; // "{0} gained {1} Exp. Points!" - u32 totalExp = 0; - msg.id = msg_0197_00001; // "{0} gained {1} Exp. Points!" + if (GetMonData(mon, MON_DATA_HP, NULL) && GetMonData(mon, MON_DATA_LEVEL, NULL) != 100) { + if (data->ctx->unk_A4[battler] & MaskOfFlagNo(slot)) { + totalExp = data->ctx->gainedExp; + } - if (GetMonData(mon, MON_DATA_HP, NULL) && GetMonData(mon, MON_DATA_LEVEL, NULL) != 100) { - if (data->ctx->unk_A4[battler] & MaskOfFlagNo(slot)) { - totalExp = data->ctx->gainedExp; - } + if (itemEffect == HOLD_EFFECT_EXP_SHARE) { + totalExp += data->ctx->partyGainedExp; + } - if (itemEffect == HOLD_EFFECT_EXP_SHARE) { - totalExp += data->ctx->partyGainedExp; - } + if (itemEffect == HOLD_EFFECT_EXP_UP) { + totalExp = totalExp * 150 / 100; + } - if (itemEffect == HOLD_EFFECT_EXP_UP) { - totalExp = totalExp * 150 / 100; - } + if (battleType & BATTLE_TYPE_TRAINER) { + totalExp = totalExp * 150 / 100; + } - if (battleType & BATTLE_TYPE_TRAINER) { - totalExp = totalExp * 150 / 100; - } + if (!ov12_022568B0(data->bsys, mon)) { + if (GetMonData(mon, MON_DATA_GAME_LANGUAGE, NULL) != gGameLanguage) { + totalExp = totalExp * 170 / 100; + } else { + totalExp = totalExp * 150 / 100; + } - if (ov12_022568B0(data->bsys, mon) == FALSE) { - if (GetMonData(mon, MON_DATA_GAME_LANGUAGE, NULL) != gGameLanguage) { - totalExp = totalExp * 170 / 100; - } else { - totalExp = totalExp * 150 / 100; + msg.id = msg_0197_00002; // "{0} gained a boosted {1} Exp. Points!" } - msg.id = msg_0197_00002; // "{0} gained a boosted {1} Exp. Points!" - } + u32 newExp = GetMonData(mon, MON_DATA_EXPERIENCE, NULL); + data->unk30[3] = newExp - GetMonBaseExperienceAtCurrentLevel(mon); + newExp += totalExp; - u32 newExp = GetMonData(mon, MON_DATA_EXPERIENCE, NULL); - data->unk30[3] = newExp - GetMonBaseExperienceAtCurrentLevel(mon); - newExp += totalExp; + if (slot == data->ctx->selectedMonIndex[expBattler]) { + data->ctx->battleMons[expBattler].exp = newExp; + } - if (slot == data->ctx->selectedMonIndex[expBattler]) { - data->ctx->battleMons[expBattler].exp = newExp; + SetMonData(mon, MON_DATA_EXPERIENCE, &newExp); + ov12_022463E8(BattleSystem_GetParty(data->bsys, expBattler), + slot, + data->ctx->battleMons[data->ctx->battlerIdFainted].species, + data->ctx->battleMons[data->ctx->battlerIdFainted].form); } - SetMonData(mon, MON_DATA_EXPERIENCE, &newExp); - ov12_022463E8(BattleSystem_GetParty(data->bsys, expBattler), - slot, - data->ctx->battleMons[data->ctx->battlerIdFainted].species, - data->ctx->battleMons[data->ctx->battlerIdFainted].form); - } + if (totalExp) { + msg.tag = 17; + msg.param[0] = expBattler | (slot << 8); + msg.param[1] = totalExp; + data->unk30[0] = ov12_0223C494(data->bsys, msgLoader, &msg, BattleSystem_GetTextFrameDelay(data->bsys)); + data->unk30[1] = 30 / 4; + data->state++; + } else { + data->state = STATE_GET_EXP_CHECK_DONE; + } - if (totalExp) { - msg.tag = 17; - msg.param[0] = expBattler | (slot << 8); - msg.param[1] = totalExp; - data->unk30[0] = ov12_0223C494(data->bsys, msgLoader, &msg, BattleSystem_GetTextFrameDelay(data->bsys)); - data->unk30[1] = 30 / 4; - data->state++; - } else { - data->state = STATE_GET_EXP_CHECK_DONE; + break; } - break; - } + case STATE_GET_EXP_WAIT_MESSAGE_PRINT: + if (!TextPrinterCheckActive(data->unk30[0])) { + data->state++; + } + break; - case STATE_GET_EXP_WAIT_MESSAGE_PRINT: - if (TextPrinterCheckActive(data->unk30[0]) == FALSE) { - data->state++; - } - break; + case STATE_GET_EXP_WAIT_MESSAGE_DELAY: + if (--data->unk30[1] == 0) { + data->state++; + } + break; - case STATE_GET_EXP_WAIT_MESSAGE_DELAY: - if (--data->unk30[1] == 0) { - data->state++; - } - break; + case STATE_GET_EXP_GAUGE: + // Only animate the gauge for an active battler + if (slot == data->ctx->selectedMonIndex[expBattler]) { + ov12_02263564(data->bsys, data->ctx, expBattler, data->unk30[3]); + data->unk30[3] = 0; + data->state++; + } else { + data->state = STATE_GET_EXP_CHECK_LEVEL_UP; + } + break; - case STATE_GET_EXP_GAUGE: - // Only animate the gauge for an active battler - if (slot == data->ctx->selectedMonIndex[expBattler]) { - ov12_02263564(data->bsys, data->ctx, expBattler, data->unk30[3]); - data->unk30[3] = 0; - data->state++; - } else { - data->state = STATE_GET_EXP_CHECK_LEVEL_UP; - } - break; + case STATE_GET_EXP_WAIT_GAUGE: + if (Link_QueueNotEmpty(data->ctx)) { + data->state++; + } + break; - case STATE_GET_EXP_WAIT_GAUGE: - if (Link_QueueNotEmpty(data->ctx)) { - data->state++; - } - break; + case STATE_GET_EXP_CHECK_LEVEL_UP: + if (Pokemon_TryLevelUp(mon)) { + // Only play the special level-up animation for an active battler + if (data->ctx->selectedMonIndex[expBattler] == slot) { + BattleController_EmitSetStatus2Effect(data->bsys, data->ctx, expBattler, 8); + ov12_0226399C(data->bsys, expBattler); + } - case STATE_GET_EXP_CHECK_LEVEL_UP: - if (Pokemon_TryLevelUp(mon)) { - // Only play the special level-up animation for an active battler - if (data->ctx->selectedMonIndex[expBattler] == slot) { - BattleController_EmitSetStatus2Effect(data->bsys, data->ctx, expBattler, 8); - ov12_0226399C(data->bsys, expBattler); + data->state = STATE_GET_EXP_WAIT_LEVEL_UP_EFFECT; + } else { + data->state = STATE_GET_EXP_CHECK_DONE; } + break; - data->state = STATE_GET_EXP_WAIT_LEVEL_UP_EFFECT; - } else { - data->state = STATE_GET_EXP_CHECK_DONE; - } - break; + case STATE_GET_EXP_WAIT_LEVEL_UP_EFFECT: + if (Link_QueueNotEmpty(data->ctx)) { + TempStatsStruct stats = ov12_0226C354; + int level = GetMonData(mon, MON_DATA_LEVEL, NULL); + // Cache the stats from the previous level for later + data->ctx->unk_17C = AllocFromHeap(HEAP_ID_BATTLE, sizeof(StatStruct)); + StatStruct *oldStats = data->ctx->unk_17C; + for (i = 0; i < 6; i++) { + oldStats->stats[i] = GetMonData(mon, stats.stats[i], NULL); + } - case STATE_GET_EXP_WAIT_LEVEL_UP_EFFECT: - if (Link_QueueNotEmpty(data->ctx)) { - TempStatsStruct stats = ov12_0226C354; - //TempDataLoader(ov12_0226C354, stats); - int level = GetMonData(mon, MON_DATA_LEVEL, NULL); - // Cache the stats from the previous level for later - data->ctx->unk_17C = AllocFromHeap(HEAP_ID_BATTLE, sizeof(StatStruct)); - StatStruct *oldStats = data->ctx->unk_17C; - for (i = 0; i < 6; i++) { - oldStats->stats[i] = GetMonData(mon, stats.stats[i], NULL); - } + MonApplyFriendshipMod(mon, 0, BattleSystem_GetLocation(data->bsys)); + ApplyMonMoodModifier(mon, 0); + CalcMonStats(mon); - MonApplyFriendshipMod(mon, 0, BattleSystem_GetLocation(data->bsys)); - ApplyMonMoodModifier(mon, 0); - CalcMonStats(mon); + if (data->ctx->selectedMonIndex[expBattler] == slot) { + BattleSystem_ReloadMonData(data->bsys, + data->ctx, + expBattler, + data->ctx->selectedMonIndex[expBattler]); + } - if (data->ctx->selectedMonIndex[expBattler] == slot) { - BattleSystem_ReloadMonData(data->bsys, - data->ctx, - expBattler, - data->ctx->selectedMonIndex[expBattler]); - } + data->ctx->levelUpMons |= MaskOfFlagNo(slot); + ov12_02263A1C(data->bsys, data->ctx, expBattler); - data->ctx->levelUpMons |= MaskOfFlagNo(slot); - ov12_02263A1C(data->bsys, data->ctx, expBattler); + msg.id = msg_0197_00003; // "{0} grew to Lv. {1}!" + msg.tag = 17; + msg.param[0] = expBattler | (slot << 8); + msg.param[1] = level; + data->unk30[0] = ov12_0223C494(data->bsys, msgLoader, &msg, BattleSystem_GetTextFrameDelay(data->bsys)); + data->state = STATE_GET_EXP_WAIT_LEVEL_UP_MESSAGE_PRINT; + } + break; - msg.id = msg_0197_00003; // "{0} grew to Lv. {1}!" - msg.tag = 17; - msg.param[0] = expBattler | (slot << 8); - msg.param[1] = level; - data->unk30[0] = ov12_0223C494(data->bsys, msgLoader, &msg, BattleSystem_GetTextFrameDelay(data->bsys)); - data->state = STATE_GET_EXP_WAIT_LEVEL_UP_MESSAGE_PRINT; - } - break; + case STATE_GET_EXP_WAIT_LEVEL_UP_MESSAGE_PRINT: + if (TextPrinterCheckActive(data->unk30[0]) == 0) { + data->state = STATE_GET_EXP_LEVEL_UP_SUMMARY_LOAD_ICON; + data->unk30[2] = 0; + } + break; - case STATE_GET_EXP_WAIT_LEVEL_UP_MESSAGE_PRINT: - if (TextPrinterCheckActive(data->unk30[0]) == 0) { - data->state = STATE_GET_EXP_LEVEL_UP_SUMMARY_LOAD_ICON; - data->unk30[2] = 0; - } - break; + case STATE_GET_EXP_LEVEL_UP_SUMMARY_LOAD_ICON: + // Load the Pokemon's Party icon if they are not the active battler + if (data->ctx->selectedMonIndex[expBattler] != slot) { + ov12_02248228(data->bsys, data, mon); + } - case STATE_GET_EXP_LEVEL_UP_SUMMARY_LOAD_ICON: - // Load the Pokemon's Party icon if they are not the active battler - if (data->ctx->selectedMonIndex[expBattler] != slot) { - ov12_02248228(data->bsys, data, mon); - } + data->state = STATE_GET_EXP_LEVEL_UP_SUMMARY_INIT; + break; - data->state = STATE_GET_EXP_LEVEL_UP_SUMMARY_INIT; - break; + case STATE_GET_EXP_LEVEL_UP_SUMMARY_INIT: { + BgConfig *bgConfig = BattleSystem_GetBgConfig(data->bsys); + Window *window = BattleSystem_GetWindow(data->bsys, 1); + PaletteData *palette = BattleSystem_GetPaletteData(data->bsys); - case STATE_GET_EXP_LEVEL_UP_SUMMARY_INIT: { - BgConfig *bgConfig = BattleSystem_GetBgConfig(data->bsys); - Window *window = BattleSystem_GetWindow(data->bsys, 1); - PaletteData *palette = BattleSystem_GetPaletteData(data->bsys); + G2_SetBG0Priority(1 + 1); // this is the background + 1; could do with a constant + SetBgPriority(1, 1); + SetBgPriority(2, 0); - G2_SetBG0Priority(1 + 1); // this is the background + 1; could do with a constant - SetBgPriority(1, 1); - SetBgPriority(2, 0); + ov12_0223C224(data->bsys, 0 + 1); // gauge's default is 0 - ov12_0223C224(data->bsys, 0 + 1); // gauge's default is 0 + sub_0200E398(bgConfig, 2, 1, 0, HEAP_ID_BATTLE); + PaletteData_LoadNarc(palette, NARC_a_0_3_8, sub_0200E3D8(), HEAP_ID_BATTLE, 0, 0x20, 8 * 0x10); + AddWindowParameterized(bgConfig, window, 2, 0x11, 0x7, 14, 12, 11, (9 + 1)); + FillWindowPixelBuffer(window, 0xFF); + DrawFrameAndWindow1(window, 0, 1, 8); - sub_0200E398(bgConfig, 2, 1, 0, HEAP_ID_BATTLE); - PaletteData_LoadNarc(palette, NARC_a_0_3_8, sub_0200E3D8(), HEAP_ID_BATTLE, 0, 0x20, 8 * 0x10); - AddWindowParameterized(bgConfig, window, 2, 0x11, 0x7, 14, 12, 11, (9 + 1)); - FillWindowPixelBuffer(window, 0xFF); - DrawFrameAndWindow1(window, 0, 1, 8); + data->state = STATE_GET_EXP_LEVEL_UP_SUMMARY_PRINT_DIFF; + break; + } - data->state = STATE_GET_EXP_LEVEL_UP_SUMMARY_PRINT_DIFF; - break; - } + case STATE_GET_EXP_LEVEL_UP_SUMMARY_PRINT_DIFF: { + + TempStatsStruct stats = ov12_0226C36C; + TempStatsStruct monData = ov12_0226C384; + + Window *window = BattleSystem_GetWindow(data->bsys, 1); + StatStruct *oldStats = data->ctx->unk_17C; - case STATE_GET_EXP_LEVEL_UP_SUMMARY_PRINT_DIFF: { - - TempStatsStruct stats = ov12_0226C36C; - TempStatsStruct monData = ov12_0226C384; - - Window *window = BattleSystem_GetWindow(data->bsys, 1); - StatStruct *oldStats = data->ctx->unk_17C; + for (i = 0; i < 6; i++) { + msg.id = msg_0197_00947; // stat name + msg.tag = 4; + msg.param[0] = stats.stats[i]; - for (i = 0; i < 6; i++) { - msg.id = msg_0197_00947; // stat name - msg.tag = 4; - msg.param[0] = stats.stats[i]; + ov12_0223C4E8(data->bsys, window, msgLoader, &msg, 0, 16 * i, 0, 0, 0); - ov12_0223C4E8(data->bsys, window, msgLoader, &msg, 0, 16 * i, 0, 0, 0); + msg.id = msg_0197_00948; // "+{0}" + msg.tag = 7; + msg.param[0] = GetMonData(mon, monData.stats[i], NULL) - oldStats->stats[i]; + msg.unk1C = 2; - msg.id = msg_0197_00948; // "+{0}" - msg.tag = 7; - msg.param[0] = GetMonData(mon, monData.stats[i], NULL) - oldStats->stats[i]; - msg.unk1C = 2; + ov12_0223C4E8(data->bsys, window, msgLoader, &msg, 80, 16 * i, 0, 0, 0); + } - ov12_0223C4E8(data->bsys, window, msgLoader, &msg, 80, 16 * i, 0, 0, 0); + data->state = STATE_GET_EXP_LEVEL_UP_SUMMARY_PRINT_DIFF_WAIT; + break; } - data->state = STATE_GET_EXP_LEVEL_UP_SUMMARY_PRINT_DIFF_WAIT; - break; - } + case STATE_GET_EXP_LEVEL_UP_SUMMARY_PRINT_TRUE: { + TempStatsStruct monData = ov12_0226C33C; + Window *window = BattleSystem_GetWindow(data->bsys, 1); - case STATE_GET_EXP_LEVEL_UP_SUMMARY_PRINT_TRUE: { - TempStatsStruct monData = ov12_0226C33C; - Window *window = BattleSystem_GetWindow(data->bsys, 1); + FillWindowPixelRect(window, 0xF, 80, 0, 36, 96); // clear out the diff section (keep the printed stat names) - FillWindowPixelRect(window, 0xF, 80, 0, 36, 96); // clear out the diff section (keep the printed stat names) + for (i = 0; i < 6; i++) { + msg.id = msg_0197_00949; // just a number + msg.tag = 7; + msg.param[0] = GetMonData(mon, monData.stats[i], NULL); + msg.unk1C = 3; - for (i = 0; i < 6; i++) { - msg.id = msg_0197_00949; // just a number - msg.tag = 7; - msg.param[0] = GetMonData(mon, monData.stats[i], NULL); - msg.unk1C = 3; + ov12_0223C4E8(data->bsys, window, msgLoader, &msg, 72, 16 * i, 0x2, 36, 0); + } - ov12_0223C4E8(data->bsys, window, msgLoader, &msg, 72, 16 * i, 0x2, 36, 0); + data->state = STATE_GET_EXP_LEVEL_UP_SUMMARY_PRINT_TRUE_WAIT; + break; } + + case STATE_GET_EXP_LEVEL_UP_SUMMARY_PRINT_DIFF_WAIT: + case STATE_GET_EXP_LEVEL_UP_SUMMARY_PRINT_TRUE_WAIT: + if ((gSystem.newKeys & (PAD_BUTTON_A | PAD_BUTTON_B | PAD_BUTTON_X | PAD_BUTTON_Y)) || System_GetTouchNew()) { + PlaySE(SEQ_SE_DP_SELECT); + data->state++; + } + break; - data->state = STATE_GET_EXP_LEVEL_UP_SUMMARY_PRINT_TRUE_WAIT; - break; - } - - case STATE_GET_EXP_LEVEL_UP_SUMMARY_PRINT_DIFF_WAIT: - case STATE_GET_EXP_LEVEL_UP_SUMMARY_PRINT_TRUE_WAIT: - if ((gSystem.newKeys & (PAD_BUTTON_A | PAD_BUTTON_B | PAD_BUTTON_X | PAD_BUTTON_Y)) || System_GetTouchNew()) { - PlaySE(SEQ_SE_DP_SELECT); - data->state++; - } - break; + case STATE_GET_EXP_LEVEL_UP_CLEAR: { + Window *window = BattleSystem_GetWindow(data->bsys, 1); - case STATE_GET_EXP_LEVEL_UP_CLEAR:{ - Window *window = BattleSystem_GetWindow(data->bsys, 1); + sub_0200E5D4(window, 0); + RemoveWindow(window); - sub_0200E5D4(window, 0); - RemoveWindow(window); + G2_SetBG0Priority(1); + SetBgPriority(1, 0); + SetBgPriority(2, 1); - G2_SetBG0Priority(1); - SetBgPriority(1, 0); - SetBgPriority(2, 1); + ov12_0223C224(data->bsys, 0); - ov12_0223C224(data->bsys, 0); + if (data->ctx->selectedMonIndex[expBattler] != slot) { + ov12_022484D4(data->bsys, data); + } - if (data->ctx->selectedMonIndex[expBattler] != slot) { - ov12_022484D4(data->bsys, data); + FreeToHeap(data->ctx->unk_17C); + data->state = 15; + break; } - FreeToHeap(data->ctx->unk_17C); - data->state = 15; - break; - } + case STATE_GET_EXP_CHECK_LEARN_MOVE: { + u16 move; + BgConfig *bgConfig = BattleSystem_GetBgConfig(data->bsys); // unused, but must be kept to match - case STATE_GET_EXP_CHECK_LEARN_MOVE: { - u16 move; - BgConfig *bgConfig = BattleSystem_GetBgConfig(data->bsys); // unused, but must be kept to match + switch (MonTryLearnMoveOnLevelUp(mon, &data->unk30[2], &move)) { + case 0: + data->state = STATE_GET_EXP_GAUGE; + break; + case 0xFFFE: + break; + case 0xFFFF: + data->unk30[4] = move; + data->state = STATE_GET_EXP_WANTS_TO_LEARN_MOVE_PRINT; + break; + default: + if (data->ctx->selectedMonIndex[expBattler] == slot) { + BattleSystem_ReloadMonData(data->bsys, + data->ctx, + expBattler, + data->ctx->selectedMonIndex[expBattler]); + } - switch (MonTryLearnMoveOnLevelUp(mon, &data->unk30[2], &move)) { - case 0: - data->state = STATE_GET_EXP_GAUGE; - break; - case 0xFFFE: - - break; - case 0xFFFF: - data->unk30[4] = move; - data->state = STATE_GET_EXP_WANTS_TO_LEARN_MOVE_PRINT; - break; - default: - if (data->ctx->selectedMonIndex[expBattler] == slot) { - BattleSystem_ReloadMonData(data->bsys, - data->ctx, - expBattler, - data->ctx->selectedMonIndex[expBattler]); + msg.id = msg_0197_00004; // "{0} learned {1}!" + msg.tag = 10; + msg.param[0] = expBattler | (slot << 8); + msg.param[1] = move; + data->unk30[0] = ov12_0223C494(data->bsys, msgLoader, &msg, BattleSystem_GetTextFrameDelay(data->bsys)); + data->state = STATE_GET_EXP_LEARNED_MOVE_WAIT; + break; } + break; + } - msg.id = msg_0197_00004; // "{0} learned {1}!" + case STATE_GET_EXP_WANTS_TO_LEARN_MOVE_PRINT: + msg.id = msg_0197_01178; // "{0} wants to learn the move {1}." msg.tag = 10; msg.param[0] = expBattler | (slot << 8); - msg.param[1] = move; + msg.param[1] = data->unk30[4]; data->unk30[0] = ov12_0223C494(data->bsys, msgLoader, &msg, BattleSystem_GetTextFrameDelay(data->bsys)); - data->state = STATE_GET_EXP_LEARNED_MOVE_WAIT; + data->state++; break; - } - break; - } - - case STATE_GET_EXP_WANTS_TO_LEARN_MOVE_PRINT: - msg.id = msg_0197_01178; // "{0} wants to learn the move {1}." - msg.tag = 10; - msg.param[0] = expBattler | (slot << 8); - msg.param[1] = data->unk30[4]; - data->unk30[0] = ov12_0223C494(data->bsys, msgLoader, &msg, BattleSystem_GetTextFrameDelay(data->bsys)); - data->state++; - break; + case STATE_GET_EXP_CANT_LEARN_MORE_MOVES_PRINT: + msg.id = msg_0197_01179; // "But {0} can't learn more than four moves." + msg.tag = 2; + msg.param[0] = expBattler | (slot << 8); + data->unk30[0] = ov12_0223C494(data->bsys, msgLoader, &msg, BattleSystem_GetTextFrameDelay(data->bsys)); + data->state++; + break; - case STATE_GET_EXP_CANT_LEARN_MORE_MOVES_PRINT: - msg.id = msg_0197_01179; // "But {0} can't learn more than four moves." - msg.tag = 2; - msg.param[0] = expBattler | (slot << 8); - data->unk30[0] = ov12_0223C494(data->bsys, msgLoader, &msg, BattleSystem_GetTextFrameDelay(data->bsys)); - data->state++; - break; + case STATE_GET_EXP_WANTS_TO_LEARN_MOVE_PRINT_WAIT: + case STATE_GET_EXP_CANT_LEARN_MORE_MOVES_PRINT_WAIT: + case STATE_GET_EXP_ONE_TWO_POOF_WAIT: + case STATE_GET_EXP_FORGOT_HOW_TO_USE_WAIT: + case STATE_GET_EXP_AND_DOTDOTDOT_WAIT: + case STATE_GET_EXP_MAKE_IT_FORGET_CANCELLED_WAIT: + if (!TextPrinterCheckActive(data->unk30[0])) { + data->state++; + } + break; - case STATE_GET_EXP_WANTS_TO_LEARN_MOVE_PRINT_WAIT: - case STATE_GET_EXP_CANT_LEARN_MORE_MOVES_PRINT_WAIT: - case STATE_GET_EXP_ONE_TWO_POOF_WAIT: - case STATE_GET_EXP_FORGOT_HOW_TO_USE_WAIT: - case STATE_GET_EXP_AND_DOTDOTDOT_WAIT: - case STATE_GET_EXP_MAKE_IT_FORGET_CANCELLED_WAIT: - if (TextPrinterCheckActive(data->unk30[0]) == FALSE) { + case STATE_GET_EXP_MAKE_IT_FORGET_PROMPT: + // "Make it forget another move?" + BattleController_EmitDrawYesNoBox(data->bsys, data->ctx, expBattler, 1180, 1, 0, 0); data->state++; - } - break; + break; - case STATE_GET_EXP_MAKE_IT_FORGET_PROMPT: - // "Make it forget another move?" - BattleController_EmitDrawYesNoBox(data->bsys, data->ctx, expBattler, 1180, 1, 0, 0); - data->state++; - break; + case STATE_GET_EXP_MAKE_IT_FORGET_ANSWER: + if (ov12_0225682C(data->ctx, expBattler)) { + if (ov12_0225682C(data->ctx, expBattler) == 0xFF) { // TODO: could use a const + data->state = STATE_GET_EXP_MAKE_IT_FORGET_CANCELLED; + } else { + msg.id = msg_0197_01183; // "Which move should be forgotten?" + msg.tag = 0; + data->unk30[0] = ov12_0223C494(data->bsys, msgLoader, &msg, BattleSystem_GetTextFrameDelay(data->bsys)); + data->state = 22; + } + } + break; - case STATE_GET_EXP_MAKE_IT_FORGET_ANSWER: - if (ov12_0225682C(data->ctx, expBattler)) { - if (ov12_0225682C(data->ctx, expBattler) == 0xFF) { // TODO: could use a const + case STATE_GET_EXP_MAKE_IT_FORGET_WAIT: + if (!TextPrinterCheckActive(data->unk30[0])) { + ov12_02263D14(data->bsys, expBattler, data->unk30[4], slot); + data->state++; + } + break; + + case STATE_GET_EXP_MAKE_IT_FORGET_INPUT_TAKEN: + if (ov12_0225682C(data->ctx, expBattler) == 0xFF) { data->state = STATE_GET_EXP_MAKE_IT_FORGET_CANCELLED; - } else { - msg.id = msg_0197_01183; // "Which move should be forgotten?" - msg.tag = 0; - data->unk30[0] = ov12_0223C494(data->bsys, msgLoader, &msg, BattleSystem_GetTextFrameDelay(data->bsys)); - data->state = 22; + } else if (ov12_0225682C(data->ctx, expBattler)) { + data->unk30[5] = data->ctx->unk_2300[expBattler][0] - 1; + data->state = 24; } - } - break; + break; - case STATE_GET_EXP_MAKE_IT_FORGET_WAIT: - if (TextPrinterCheckActive(data->unk30[0]) == FALSE) { - ov12_02263D14(data->bsys, expBattler, data->unk30[4], slot); + case STATE_GET_EXP_MAKE_IT_FORGET_CANCELLED: + msg.id = msg_0197_01184; // "Well, then..." + msg.tag = 0; + data->unk30[0] = ov12_0223C494(data->bsys, msgLoader, &msg, BattleSystem_GetTextFrameDelay(data->bsys)); data->state++; - } - break; - - case STATE_GET_EXP_MAKE_IT_FORGET_INPUT_TAKEN: - if (ov12_0225682C(data->ctx, expBattler) == 0xFF) { - data->state = STATE_GET_EXP_MAKE_IT_FORGET_CANCELLED; - } else if (ov12_0225682C(data->ctx, expBattler)) { - data->unk30[5] = data->ctx->unk_2300[expBattler][0] - 1; - data->state = 24; - } - break; - - case STATE_GET_EXP_MAKE_IT_FORGET_CANCELLED: - msg.id = msg_0197_01184; // "Well, then..." - msg.tag = 0; - data->unk30[0] = ov12_0223C494(data->bsys, msgLoader, &msg, BattleSystem_GetTextFrameDelay(data->bsys)); - data->state++; - break; + break; - case STATE_GET_EXP_GIVE_UP_LEARNING_PROMPT: - // "Should this Pokémon give up on learning this new move?" - BattleController_EmitDrawYesNoBox(data->bsys, data->ctx, expBattler, 1185, 2, data->unk30[4], 0); - data->state++; - break; + case STATE_GET_EXP_GIVE_UP_LEARNING_PROMPT: + // "Should this Pokémon give up on learning this new move?" + BattleController_EmitDrawYesNoBox(data->bsys, data->ctx, expBattler, 1185, 2, data->unk30[4], 0); + data->state++; + break; - case STATE_GET_EXP_GIVE_UP_LEARNING_ANSWER: - if (ov12_0225682C(data->ctx, expBattler)) { - if (ov12_0225682C(data->ctx, expBattler) == 0xFF) { - data->state = STATE_GET_EXP_WANTS_TO_LEARN_MOVE_PRINT; - } else { - msg.id = msg_0197_01188; // "{0} did not learn {1}." - msg.tag = 10; - msg.param[0] = expBattler | (slot << 8); - msg.param[1] = data->unk30[4]; - data->unk30[0] = ov12_0223C494(data->bsys, msgLoader, &msg, BattleSystem_GetTextFrameDelay(data->bsys)); - data->state = 35; + case STATE_GET_EXP_GIVE_UP_LEARNING_ANSWER: + if (ov12_0225682C(data->ctx, expBattler)) { + if (ov12_0225682C(data->ctx, expBattler) == 0xFF) { + data->state = STATE_GET_EXP_WANTS_TO_LEARN_MOVE_PRINT; + } else { + msg.id = msg_0197_01188; // "{0} did not learn {1}." + msg.tag = 10; + msg.param[0] = expBattler | (slot << 8); + msg.param[1] = data->unk30[4]; + data->unk30[0] = ov12_0223C494(data->bsys, msgLoader, &msg, BattleSystem_GetTextFrameDelay(data->bsys)); + data->state = 35; + } } - } - break; + break; - case STATE_GET_EXP_GIVE_UP_LEARNING_WAIT: - if (TextPrinterCheckActive(data->unk30[0]) == FALSE) { - // Check for another move to learn - data->state = STATE_GET_EXP_CHECK_LEARN_MOVE; - } - break; + case STATE_GET_EXP_GIVE_UP_LEARNING_WAIT: + if (!TextPrinterCheckActive(data->unk30[0])) { + // Check for another move to learn + data->state = STATE_GET_EXP_CHECK_LEARN_MOVE; + } + break; - case STATE_GET_EXP_ONE_TWO_POOF: - msg.id = msg_0197_01189; // "1, 2, and... ... Poof!" - msg.tag = 0; - data->unk30[0] = ov12_0223C494(data->bsys, msgLoader, &msg, BattleSystem_GetTextFrameDelay(data->bsys)); - data->state++; - break; - - case STATE_GET_EXP_FORGOT_HOW_TO_USE: - msg.id = msg_0197_01190; // "{0} forgot how to use {1}." - msg.tag = 10; - msg.param[0] = expBattler | (slot << 8); - msg.param[1] = GetMonData(mon, 54 + data->unk30[5], NULL); - data->unk30[0] = ov12_0223C494(data->bsys, msgLoader, &msg, BattleSystem_GetTextFrameDelay(data->bsys)); - data->state++; - break; + case STATE_GET_EXP_ONE_TWO_POOF: + msg.id = msg_0197_01189; // "1, 2, and... ... Poof!" + msg.tag = 0; + data->unk30[0] = ov12_0223C494(data->bsys, msgLoader, &msg, BattleSystem_GetTextFrameDelay(data->bsys)); + data->state++; + break; + + case STATE_GET_EXP_FORGOT_HOW_TO_USE: + msg.id = msg_0197_01190; // "{0} forgot how to use {1}." + msg.tag = 10; + msg.param[0] = expBattler | (slot << 8); + msg.param[1] = GetMonData(mon, 54 + data->unk30[5], NULL); + data->unk30[0] = ov12_0223C494(data->bsys, msgLoader, &msg, BattleSystem_GetTextFrameDelay(data->bsys)); + data->state++; + break; - case STATE_GET_EXP_AND_DOTDOTDOT: - msg.id = msg_0197_01191; // "And..." - msg.tag = 0; - data->unk30[0] = ov12_0223C494(data->bsys, msgLoader, &msg, BattleSystem_GetTextFrameDelay(data->bsys)); - data->state++; - break; - - case STATE_GET_EXP_LEARNED_MOVE: - msg.id = msg_0197_01192; // "{0} learned {1}!" - msg.tag = 10; - msg.param[0] = expBattler | (slot << 8); - msg.param[1] = data->unk30[4]; - data->unk30[0] = ov12_0223C494(data->bsys, msgLoader, &msg, BattleSystem_GetTextFrameDelay(data->bsys)); - - i = 0; - SetMonData(mon, MON_DATA_MOVE1PPUP + data->unk30[5], &i); - MonSetMoveInSlot(mon, data->unk30[4], data->unk30[5]); + case STATE_GET_EXP_AND_DOTDOTDOT: + msg.id = msg_0197_01191; // "And..." + msg.tag = 0; + data->unk30[0] = ov12_0223C494(data->bsys, msgLoader, &msg, BattleSystem_GetTextFrameDelay(data->bsys)); + data->state++; + break; + + case STATE_GET_EXP_LEARNED_MOVE: + msg.id = msg_0197_01192; // "{0} learned {1}!" + msg.tag = 10; + msg.param[0] = expBattler | (slot << 8); + msg.param[1] = data->unk30[4]; + data->unk30[0] = ov12_0223C494(data->bsys, msgLoader, &msg, BattleSystem_GetTextFrameDelay(data->bsys)); + + i = 0; + SetMonData(mon, MON_DATA_MOVE1PPUP + data->unk30[5], &i); + MonSetMoveInSlot(mon, data->unk30[4], data->unk30[5]); - if (data->ctx->selectedMonIndex[expBattler] == slot) { - BattleSystem_ReloadMonData(data->bsys, - data->ctx, - expBattler, - data->ctx->selectedMonIndex[expBattler]); - } + if (data->ctx->selectedMonIndex[expBattler] == slot) { + BattleSystem_ReloadMonData(data->bsys, + data->ctx, + expBattler, + data->ctx->selectedMonIndex[expBattler]); + } - data->state = STATE_GET_EXP_LEARNED_MOVE_WAIT; - break; + data->state = STATE_GET_EXP_LEARNED_MOVE_WAIT; + break; - case STATE_GET_EXP_LEARNED_MOVE_WAIT: - if (TextPrinterCheckActive(data->unk30[0]) == FALSE) { - // Check for another move to learn - data->state = STATE_GET_EXP_CHECK_LEARN_MOVE; - } - break; + case STATE_GET_EXP_LEARNED_MOVE_WAIT: + if (!TextPrinterCheckActive(data->unk30[0])) { + // Check for another move to learn + data->state = STATE_GET_EXP_CHECK_LEARN_MOVE; + } + break; - case STATE_GET_EXP_CHECK_DONE: - data->ctx->unk_A4[battler] &= (MaskOfFlagNo(slot) ^ 0xFFFFFFFF); // this mon is done - data->unk30[6] = slot + 1; - data->state = STATE_GET_EXP_START; // go back to the top and get the next mon - break; + case STATE_GET_EXP_CHECK_DONE: + data->ctx->unk_A4[battler] &= (MaskOfFlagNo(slot) ^ 0xFFFFFFFF); // this mon is done + data->unk30[6] = slot + 1; + data->state = STATE_GET_EXP_START; // go back to the top and get the next mon + break; - case STATE_GET_EXP_DONE: - data->ctx->getterWork = NULL; - FreeToHeap(inData); - DestroySysTask(task); - break; + case STATE_GET_EXP_DONE: + data->ctx->getterWork = NULL; + FreeToHeap(inData); + DestroySysTask(task); + break; } } From 0be430233efe7d0cd7105f3591d932a72c18e728 Mon Sep 17 00:00:00 2001 From: Adrienn Tindall <33725376+adrienntindall@users.noreply.github.com> Date: Mon, 27 Nov 2023 20:59:26 -0500 Subject: [PATCH 08/33] Update battle_command.c --- src/battle/battle_command.c | 741 ++++++++++++++++++------------------ 1 file changed, 365 insertions(+), 376 deletions(-) diff --git a/src/battle/battle_command.c b/src/battle/battle_command.c index 3f1b510f01..45af5cc37d 100644 --- a/src/battle/battle_command.c +++ b/src/battle/battle_command.c @@ -5978,7 +5978,7 @@ static void Task_GetExp(SysTask *task, void *inData) GetterWork *data = inData; Pokemon *mon; BattleMessage msg; - int battler; + int side; int expBattler; u32 *msgLoader; u32 battleType; @@ -5987,7 +5987,7 @@ static void Task_GetExp(SysTask *task, void *inData) msgLoader = ov12_0223A930(data->bsys); battleType = BattleSystem_GetBattleType(data->bsys); - battler = data->ctx->battlerIdFainted >> 1 & 1; // init to the side with the fainted mon + side = (data->ctx->battlerIdFainted >> 1) & 1; //Get side of fainted mon (left or right) expBattler = 0; // Figure out which mon we're working on @@ -5996,7 +5996,7 @@ static void Task_GetExp(SysTask *task, void *inData) item = GetMonData(mon, MON_DATA_HELD_ITEM, NULL); itemEffect = GetItemAttr(item, ITEM_VAR_HOLD_EFFECT, HEAP_ID_BATTLE); - if (itemEffect == HOLD_EFFECT_EXP_SHARE || (data->ctx->unk_A4[battler] & MaskOfFlagNo(slot))) { + if (itemEffect == HOLD_EFFECT_EXP_SHARE || (data->ctx->unk_A4[side] & MaskOfFlagNo(slot))) { break; } } @@ -6010,461 +6010,450 @@ static void Task_GetExp(SysTask *task, void *inData) } switch (data->state) { - case STATE_GET_EXP_START: { - item = GetMonData(mon, MON_DATA_HELD_ITEM, NULL); - itemEffect = GetItemAttr(item, ITEM_VAR_HOLD_EFFECT, HEAP_ID_BATTLE); - - // Declare victory if all wild mons have been defeated - if (!(battleType & BATTLE_TYPE_TRAINER) - && data->ctx->battleMons[BATTLER_ENEMY].hp - + data->ctx->battleMons[BATTLER_ENEMY2].hp == 0 - && GetMonData(mon, MON_DATA_HP, NULL) - && !data->ctx->unk_3144) { - PlayBGM(SEQ_GS_WIN2); - data->ctx->unk_3144 = TRUE; - BattleSystem_SetCriticalHpMusicFlag(data->bsys, 2); // turn off - } - - u32 totalExp = 0; - msg.id = msg_0197_00001; // "{0} gained {1} Exp. Points!" + case STATE_GET_EXP_START: + item = GetMonData(mon, MON_DATA_HELD_ITEM, NULL); + itemEffect = GetItemAttr(item, ITEM_VAR_HOLD_EFFECT, HEAP_ID_BATTLE); - if (GetMonData(mon, MON_DATA_HP, NULL) && GetMonData(mon, MON_DATA_LEVEL, NULL) != 100) { - if (data->ctx->unk_A4[battler] & MaskOfFlagNo(slot)) { - totalExp = data->ctx->gainedExp; - } + // Declare victory if all wild mons have been defeated + if (!(battleType & BATTLE_TYPE_TRAINER) + && data->ctx->battleMons[BATTLER_ENEMY].hp + + data->ctx->battleMons[BATTLER_ENEMY2].hp == 0 + && GetMonData(mon, MON_DATA_HP, NULL) + && !data->ctx->unk_3144) { + PlayBGM(SEQ_GS_WIN2); + data->ctx->unk_3144 = TRUE; + BattleSystem_SetCriticalHpMusicFlag(data->bsys, 2); // turn off + } - if (itemEffect == HOLD_EFFECT_EXP_SHARE) { - totalExp += data->ctx->partyGainedExp; - } + u32 totalExp = 0; + msg.id = msg_0197_00001; // "{0} gained {1} Exp. Points!" - if (itemEffect == HOLD_EFFECT_EXP_UP) { - totalExp = totalExp * 150 / 100; - } - - if (battleType & BATTLE_TYPE_TRAINER) { - totalExp = totalExp * 150 / 100; - } + if (GetMonData(mon, MON_DATA_HP, NULL) && GetMonData(mon, MON_DATA_LEVEL, NULL) != 100) { + if (data->ctx->unk_A4[side] & MaskOfFlagNo(slot)) { + totalExp = data->ctx->gainedExp; + } - if (!ov12_022568B0(data->bsys, mon)) { - if (GetMonData(mon, MON_DATA_GAME_LANGUAGE, NULL) != gGameLanguage) { - totalExp = totalExp * 170 / 100; - } else { - totalExp = totalExp * 150 / 100; - } + if (itemEffect == HOLD_EFFECT_EXP_SHARE) { + totalExp += data->ctx->partyGainedExp; + } - msg.id = msg_0197_00002; // "{0} gained a boosted {1} Exp. Points!" - } + if (itemEffect == HOLD_EFFECT_EXP_UP) { + totalExp = totalExp * 150 / 100; + } - u32 newExp = GetMonData(mon, MON_DATA_EXPERIENCE, NULL); - data->unk30[3] = newExp - GetMonBaseExperienceAtCurrentLevel(mon); - newExp += totalExp; + if (battleType & BATTLE_TYPE_TRAINER) { + totalExp = totalExp * 150 / 100; + } - if (slot == data->ctx->selectedMonIndex[expBattler]) { - data->ctx->battleMons[expBattler].exp = newExp; + if (!ov12_022568B0(data->bsys, mon)) { + if (GetMonData(mon, MON_DATA_GAME_LANGUAGE, NULL) != gGameLanguage) { + totalExp = totalExp * 170 / 100; + } else { + totalExp = totalExp * 150 / 100; } - SetMonData(mon, MON_DATA_EXPERIENCE, &newExp); - ov12_022463E8(BattleSystem_GetParty(data->bsys, expBattler), - slot, - data->ctx->battleMons[data->ctx->battlerIdFainted].species, - data->ctx->battleMons[data->ctx->battlerIdFainted].form); + msg.id = msg_0197_00002; // "{0} gained a boosted {1} Exp. Points!" } - if (totalExp) { - msg.tag = 17; - msg.param[0] = expBattler | (slot << 8); - msg.param[1] = totalExp; - data->unk30[0] = ov12_0223C494(data->bsys, msgLoader, &msg, BattleSystem_GetTextFrameDelay(data->bsys)); - data->unk30[1] = 30 / 4; - data->state++; - } else { - data->state = STATE_GET_EXP_CHECK_DONE; + u32 newExp = GetMonData(mon, MON_DATA_EXPERIENCE, NULL); + data->unk30[3] = newExp - GetMonBaseExperienceAtCurrentLevel(mon); + newExp += totalExp; + + if (slot == data->ctx->selectedMonIndex[expBattler]) { + data->ctx->battleMons[expBattler].exp = newExp; } - break; + SetMonData(mon, MON_DATA_EXPERIENCE, &newExp); + ov12_022463E8(BattleSystem_GetParty(data->bsys, expBattler), + slot, + data->ctx->battleMons[data->ctx->battlerIdFainted].species, + data->ctx->battleMons[data->ctx->battlerIdFainted].form); } - case STATE_GET_EXP_WAIT_MESSAGE_PRINT: - if (!TextPrinterCheckActive(data->unk30[0])) { - data->state++; - } - break; + if (totalExp) { + msg.tag = 17; + msg.param[0] = expBattler | (slot << 8); + msg.param[1] = totalExp; + data->unk30[0] = ov12_0223C494(data->bsys, msgLoader, &msg, BattleSystem_GetTextFrameDelay(data->bsys)); + data->unk30[1] = 7; + data->state++; + } else { + data->state = STATE_GET_EXP_CHECK_DONE; + } - case STATE_GET_EXP_WAIT_MESSAGE_DELAY: - if (--data->unk30[1] == 0) { - data->state++; - } - break; + break; + + case STATE_GET_EXP_WAIT_MESSAGE_PRINT: + if (!TextPrinterCheckActive(data->unk30[0])) { + data->state++; + } + break; - case STATE_GET_EXP_GAUGE: - // Only animate the gauge for an active battler - if (slot == data->ctx->selectedMonIndex[expBattler]) { - ov12_02263564(data->bsys, data->ctx, expBattler, data->unk30[3]); - data->unk30[3] = 0; - data->state++; - } else { - data->state = STATE_GET_EXP_CHECK_LEVEL_UP; - } - break; + case STATE_GET_EXP_WAIT_MESSAGE_DELAY: + if (--data->unk30[1] == 0) { + data->state++; + } + break; - case STATE_GET_EXP_WAIT_GAUGE: - if (Link_QueueNotEmpty(data->ctx)) { - data->state++; - } - break; + case STATE_GET_EXP_GAUGE: + // Only animate the gauge for an active battler + if (slot == data->ctx->selectedMonIndex[expBattler]) { + ov12_02263564(data->bsys, data->ctx, expBattler, data->unk30[3]); + data->unk30[3] = 0; + data->state++; + } else { + data->state = STATE_GET_EXP_CHECK_LEVEL_UP; + } + break; - case STATE_GET_EXP_CHECK_LEVEL_UP: - if (Pokemon_TryLevelUp(mon)) { - // Only play the special level-up animation for an active battler - if (data->ctx->selectedMonIndex[expBattler] == slot) { - BattleController_EmitSetStatus2Effect(data->bsys, data->ctx, expBattler, 8); - ov12_0226399C(data->bsys, expBattler); - } + case STATE_GET_EXP_WAIT_GAUGE: + if (Link_QueueNotEmpty(data->ctx)) { + data->state++; + } + break; - data->state = STATE_GET_EXP_WAIT_LEVEL_UP_EFFECT; - } else { - data->state = STATE_GET_EXP_CHECK_DONE; + case STATE_GET_EXP_CHECK_LEVEL_UP: + if (Pokemon_TryLevelUp(mon)) { + // Only play the special level-up animation for an active battler + if (data->ctx->selectedMonIndex[expBattler] == slot) { + BattleController_EmitSetStatus2Effect(data->bsys, data->ctx, expBattler, 8); + ov12_0226399C(data->bsys, expBattler); } - break; - - case STATE_GET_EXP_WAIT_LEVEL_UP_EFFECT: - if (Link_QueueNotEmpty(data->ctx)) { - TempStatsStruct stats = ov12_0226C354; - int level = GetMonData(mon, MON_DATA_LEVEL, NULL); - // Cache the stats from the previous level for later - data->ctx->unk_17C = AllocFromHeap(HEAP_ID_BATTLE, sizeof(StatStruct)); - StatStruct *oldStats = data->ctx->unk_17C; - for (i = 0; i < 6; i++) { - oldStats->stats[i] = GetMonData(mon, stats.stats[i], NULL); - } - MonApplyFriendshipMod(mon, 0, BattleSystem_GetLocation(data->bsys)); - ApplyMonMoodModifier(mon, 0); - CalcMonStats(mon); + data->state = STATE_GET_EXP_WAIT_LEVEL_UP_EFFECT; + } else { + data->state = STATE_GET_EXP_CHECK_DONE; + } + break; - if (data->ctx->selectedMonIndex[expBattler] == slot) { - BattleSystem_ReloadMonData(data->bsys, - data->ctx, - expBattler, - data->ctx->selectedMonIndex[expBattler]); - } + case STATE_GET_EXP_WAIT_LEVEL_UP_EFFECT: + if (Link_QueueNotEmpty(data->ctx)) { + TempStatsStruct stats = ov12_0226C354; + int level = GetMonData(mon, MON_DATA_LEVEL, NULL); + // Cache the stats from the previous level for later + data->ctx->unk_17C = AllocFromHeap(HEAP_ID_BATTLE, sizeof(StatStruct)); + StatStruct *oldStats = data->ctx->unk_17C; + for (i = 0; i < 6; i++) { + oldStats->stats[i] = GetMonData(mon, stats.stats[i], NULL); + } - data->ctx->levelUpMons |= MaskOfFlagNo(slot); - ov12_02263A1C(data->bsys, data->ctx, expBattler); + MonApplyFriendshipMod(mon, 0, BattleSystem_GetLocation(data->bsys)); + ApplyMonMoodModifier(mon, 0); + CalcMonStats(mon); - msg.id = msg_0197_00003; // "{0} grew to Lv. {1}!" - msg.tag = 17; - msg.param[0] = expBattler | (slot << 8); - msg.param[1] = level; - data->unk30[0] = ov12_0223C494(data->bsys, msgLoader, &msg, BattleSystem_GetTextFrameDelay(data->bsys)); - data->state = STATE_GET_EXP_WAIT_LEVEL_UP_MESSAGE_PRINT; + if (data->ctx->selectedMonIndex[expBattler] == slot) { + BattleSystem_ReloadMonData(data->bsys, + data->ctx, + expBattler, + data->ctx->selectedMonIndex[expBattler]); } - break; - case STATE_GET_EXP_WAIT_LEVEL_UP_MESSAGE_PRINT: - if (TextPrinterCheckActive(data->unk30[0]) == 0) { - data->state = STATE_GET_EXP_LEVEL_UP_SUMMARY_LOAD_ICON; - data->unk30[2] = 0; - } - break; + data->ctx->levelUpMons |= MaskOfFlagNo(slot); + ov12_02263A1C(data->bsys, data->ctx, expBattler); - case STATE_GET_EXP_LEVEL_UP_SUMMARY_LOAD_ICON: - // Load the Pokemon's Party icon if they are not the active battler - if (data->ctx->selectedMonIndex[expBattler] != slot) { - ov12_02248228(data->bsys, data, mon); - } + msg.id = msg_0197_00003; // "{0} grew to Lv. {1}!" + msg.tag = 17; + msg.param[0] = expBattler | (slot << 8); + msg.param[1] = level; + data->unk30[0] = ov12_0223C494(data->bsys, msgLoader, &msg, BattleSystem_GetTextFrameDelay(data->bsys)); + data->state = STATE_GET_EXP_WAIT_LEVEL_UP_MESSAGE_PRINT; + } + break; - data->state = STATE_GET_EXP_LEVEL_UP_SUMMARY_INIT; - break; + case STATE_GET_EXP_WAIT_LEVEL_UP_MESSAGE_PRINT: + if (TextPrinterCheckActive(data->unk30[0]) == 0) { + data->state = STATE_GET_EXP_LEVEL_UP_SUMMARY_LOAD_ICON; + data->unk30[2] = 0; + } + break; - case STATE_GET_EXP_LEVEL_UP_SUMMARY_INIT: { - BgConfig *bgConfig = BattleSystem_GetBgConfig(data->bsys); - Window *window = BattleSystem_GetWindow(data->bsys, 1); - PaletteData *palette = BattleSystem_GetPaletteData(data->bsys); + case STATE_GET_EXP_LEVEL_UP_SUMMARY_LOAD_ICON: + // Load the Pokemon's Party icon if they are not the active battler + if (data->ctx->selectedMonIndex[expBattler] != slot) { + ov12_02248228(data->bsys, data, mon); + } - G2_SetBG0Priority(1 + 1); // this is the background + 1; could do with a constant - SetBgPriority(1, 1); - SetBgPriority(2, 0); + data->state = STATE_GET_EXP_LEVEL_UP_SUMMARY_INIT; + break; - ov12_0223C224(data->bsys, 0 + 1); // gauge's default is 0 + case STATE_GET_EXP_LEVEL_UP_SUMMARY_INIT: { + BgConfig *bgConfig = BattleSystem_GetBgConfig(data->bsys); + Window *window = BattleSystem_GetWindow(data->bsys, 1); + PaletteData *palette = BattleSystem_GetPaletteData(data->bsys); - sub_0200E398(bgConfig, 2, 1, 0, HEAP_ID_BATTLE); - PaletteData_LoadNarc(palette, NARC_a_0_3_8, sub_0200E3D8(), HEAP_ID_BATTLE, 0, 0x20, 8 * 0x10); - AddWindowParameterized(bgConfig, window, 2, 0x11, 0x7, 14, 12, 11, (9 + 1)); - FillWindowPixelBuffer(window, 0xFF); - DrawFrameAndWindow1(window, 0, 1, 8); + G2_SetBG0Priority(2); + SetBgPriority(GF_BG_LYR_MAIN_1, 1); + SetBgPriority(GF_BG_LYR_MAIN_2, 0); - data->state = STATE_GET_EXP_LEVEL_UP_SUMMARY_PRINT_DIFF; - break; - } + ov12_0223C224(data->bsys, 1); - case STATE_GET_EXP_LEVEL_UP_SUMMARY_PRINT_DIFF: { - - TempStatsStruct stats = ov12_0226C36C; - TempStatsStruct monData = ov12_0226C384; - - Window *window = BattleSystem_GetWindow(data->bsys, 1); - StatStruct *oldStats = data->ctx->unk_17C; + sub_0200E398(bgConfig, 2, 1, 0, HEAP_ID_BATTLE); + PaletteData_LoadNarc(palette, NARC_a_0_3_8, sub_0200E3D8(), HEAP_ID_BATTLE, 0, 0x20, 8 * 0x10); + AddWindowParameterized(bgConfig, window, GF_BG_LYR_MAIN_2, 0x11, 0x7, 14, 12, 11, (9 + 1)); + FillWindowPixelBuffer(window, 0xFF); + DrawFrameAndWindow1(window, FALSE, 1, 8); - for (i = 0; i < 6; i++) { - msg.id = msg_0197_00947; // stat name - msg.tag = 4; - msg.param[0] = stats.stats[i]; + data->state = STATE_GET_EXP_LEVEL_UP_SUMMARY_PRINT_DIFF; + break; + } + case STATE_GET_EXP_LEVEL_UP_SUMMARY_PRINT_DIFF: { + + TempStatsStruct stats = ov12_0226C36C; + TempStatsStruct monData = ov12_0226C384; + + Window *window = BattleSystem_GetWindow(data->bsys, 1); + StatStruct *oldStats = data->ctx->unk_17C; - ov12_0223C4E8(data->bsys, window, msgLoader, &msg, 0, 16 * i, 0, 0, 0); + for (i = 0; i < NUM_STATS; i++) { + msg.id = msg_0197_00947; // stat name + msg.tag = 4; + msg.param[0] = stats.stats[i]; - msg.id = msg_0197_00948; // "+{0}" - msg.tag = 7; - msg.param[0] = GetMonData(mon, monData.stats[i], NULL) - oldStats->stats[i]; - msg.unk1C = 2; + ov12_0223C4E8(data->bsys, window, msgLoader, &msg, 0, 16 * i, 0, 0, 0); - ov12_0223C4E8(data->bsys, window, msgLoader, &msg, 80, 16 * i, 0, 0, 0); - } + msg.id = msg_0197_00948; // "+{0}" + msg.tag = 7; + msg.param[0] = GetMonData(mon, monData.stats[i], NULL) - oldStats->stats[i]; + msg.unk1C = 2; - data->state = STATE_GET_EXP_LEVEL_UP_SUMMARY_PRINT_DIFF_WAIT; - break; + ov12_0223C4E8(data->bsys, window, msgLoader, &msg, 80, 16 * i, 0, 0, 0); } - case STATE_GET_EXP_LEVEL_UP_SUMMARY_PRINT_TRUE: { - TempStatsStruct monData = ov12_0226C33C; - Window *window = BattleSystem_GetWindow(data->bsys, 1); - - FillWindowPixelRect(window, 0xF, 80, 0, 36, 96); // clear out the diff section (keep the printed stat names) + data->state = STATE_GET_EXP_LEVEL_UP_SUMMARY_PRINT_DIFF_WAIT; + break; + } + case STATE_GET_EXP_LEVEL_UP_SUMMARY_PRINT_TRUE: { + TempStatsStruct monData = ov12_0226C33C; + Window *window = BattleSystem_GetWindow(data->bsys, 1); - for (i = 0; i < 6; i++) { - msg.id = msg_0197_00949; // just a number - msg.tag = 7; - msg.param[0] = GetMonData(mon, monData.stats[i], NULL); - msg.unk1C = 3; + FillWindowPixelRect(window, 0xF, 80, 0, 36, 96); // clear out the diff section (keep the printed stat names) - ov12_0223C4E8(data->bsys, window, msgLoader, &msg, 72, 16 * i, 0x2, 36, 0); - } + for (i = 0; i < NUM_STATS; i++) { + msg.id = msg_0197_00949; // just a number + msg.tag = 7; + msg.param[0] = GetMonData(mon, monData.stats[i], NULL); + msg.unk1C = 3; - data->state = STATE_GET_EXP_LEVEL_UP_SUMMARY_PRINT_TRUE_WAIT; - break; + ov12_0223C4E8(data->bsys, window, msgLoader, &msg, 72, 16 * i, 0x2, 36, 0); } - - case STATE_GET_EXP_LEVEL_UP_SUMMARY_PRINT_DIFF_WAIT: - case STATE_GET_EXP_LEVEL_UP_SUMMARY_PRINT_TRUE_WAIT: - if ((gSystem.newKeys & (PAD_BUTTON_A | PAD_BUTTON_B | PAD_BUTTON_X | PAD_BUTTON_Y)) || System_GetTouchNew()) { - PlaySE(SEQ_SE_DP_SELECT); - data->state++; - } - break; - case STATE_GET_EXP_LEVEL_UP_CLEAR: { - Window *window = BattleSystem_GetWindow(data->bsys, 1); + data->state = STATE_GET_EXP_LEVEL_UP_SUMMARY_PRINT_TRUE_WAIT; + break; + } + case STATE_GET_EXP_LEVEL_UP_SUMMARY_PRINT_DIFF_WAIT: + case STATE_GET_EXP_LEVEL_UP_SUMMARY_PRINT_TRUE_WAIT: + if ((gSystem.newKeys & (PAD_BUTTON_A | PAD_BUTTON_B | PAD_BUTTON_X | PAD_BUTTON_Y)) || System_GetTouchNew()) { + PlaySE(SEQ_SE_DP_SELECT); + data->state++; + } + break; - sub_0200E5D4(window, 0); - RemoveWindow(window); + case STATE_GET_EXP_LEVEL_UP_CLEAR: + Window *window = BattleSystem_GetWindow(data->bsys, 1); - G2_SetBG0Priority(1); - SetBgPriority(1, 0); - SetBgPriority(2, 1); + sub_0200E5D4(window, 0); + RemoveWindow(window); - ov12_0223C224(data->bsys, 0); + G2_SetBG0Priority(1); + SetBgPriority(GF_BG_LYR_MAIN_1, 0); + SetBgPriority(GF_BG_LYR_MAIN_2, 1); - if (data->ctx->selectedMonIndex[expBattler] != slot) { - ov12_022484D4(data->bsys, data); - } + ov12_0223C224(data->bsys, 0); - FreeToHeap(data->ctx->unk_17C); - data->state = 15; - break; + if (data->ctx->selectedMonIndex[expBattler] != slot) { + ov12_022484D4(data->bsys, data); } - case STATE_GET_EXP_CHECK_LEARN_MOVE: { - u16 move; - BgConfig *bgConfig = BattleSystem_GetBgConfig(data->bsys); // unused, but must be kept to match + FreeToHeap(data->ctx->unk_17C); + data->state = STATE_GET_EXP_CHECK_LEARN_MOVE; + break; - switch (MonTryLearnMoveOnLevelUp(mon, &data->unk30[2], &move)) { - case 0: - data->state = STATE_GET_EXP_GAUGE; - break; - case 0xFFFE: - break; - case 0xFFFF: - data->unk30[4] = move; - data->state = STATE_GET_EXP_WANTS_TO_LEARN_MOVE_PRINT; - break; - default: - if (data->ctx->selectedMonIndex[expBattler] == slot) { - BattleSystem_ReloadMonData(data->bsys, - data->ctx, - expBattler, - data->ctx->selectedMonIndex[expBattler]); - } + case STATE_GET_EXP_CHECK_LEARN_MOVE: + u16 move; + BgConfig *bgConfig = BattleSystem_GetBgConfig(data->bsys); // unused, but must be kept to match - msg.id = msg_0197_00004; // "{0} learned {1}!" - msg.tag = 10; - msg.param[0] = expBattler | (slot << 8); - msg.param[1] = move; - data->unk30[0] = ov12_0223C494(data->bsys, msgLoader, &msg, BattleSystem_GetTextFrameDelay(data->bsys)); - data->state = STATE_GET_EXP_LEARNED_MOVE_WAIT; - break; - } + switch (MonTryLearnMoveOnLevelUp(mon, &data->unk30[2], &move)) { + case 0: + data->state = STATE_GET_EXP_GAUGE; break; - } - - case STATE_GET_EXP_WANTS_TO_LEARN_MOVE_PRINT: - msg.id = msg_0197_01178; // "{0} wants to learn the move {1}." - msg.tag = 10; - msg.param[0] = expBattler | (slot << 8); - msg.param[1] = data->unk30[4]; - data->unk30[0] = ov12_0223C494(data->bsys, msgLoader, &msg, BattleSystem_GetTextFrameDelay(data->bsys)); - data->state++; + case 0xFFFE: break; + case 0xFFFF: + data->unk30[4] = move; + data->state = STATE_GET_EXP_WANTS_TO_LEARN_MOVE_PRINT; + break; + default: + if (data->ctx->selectedMonIndex[expBattler] == slot) { + BattleSystem_ReloadMonData(data->bsys, data->ctx, expBattler, data->ctx->selectedMonIndex[expBattler]); + } - case STATE_GET_EXP_CANT_LEARN_MORE_MOVES_PRINT: - msg.id = msg_0197_01179; // "But {0} can't learn more than four moves." - msg.tag = 2; + msg.id = msg_0197_00004; // "{0} learned {1}!" + msg.tag = 10; msg.param[0] = expBattler | (slot << 8); + msg.param[1] = move; data->unk30[0] = ov12_0223C494(data->bsys, msgLoader, &msg, BattleSystem_GetTextFrameDelay(data->bsys)); - data->state++; - break; - - case STATE_GET_EXP_WANTS_TO_LEARN_MOVE_PRINT_WAIT: - case STATE_GET_EXP_CANT_LEARN_MORE_MOVES_PRINT_WAIT: - case STATE_GET_EXP_ONE_TWO_POOF_WAIT: - case STATE_GET_EXP_FORGOT_HOW_TO_USE_WAIT: - case STATE_GET_EXP_AND_DOTDOTDOT_WAIT: - case STATE_GET_EXP_MAKE_IT_FORGET_CANCELLED_WAIT: - if (!TextPrinterCheckActive(data->unk30[0])) { - data->state++; - } + data->state = STATE_GET_EXP_LEARNED_MOVE_WAIT; break; + } + break; + - case STATE_GET_EXP_MAKE_IT_FORGET_PROMPT: - // "Make it forget another move?" - BattleController_EmitDrawYesNoBox(data->bsys, data->ctx, expBattler, 1180, 1, 0, 0); + case STATE_GET_EXP_WANTS_TO_LEARN_MOVE_PRINT: + msg.id = msg_0197_01178; // "{0} wants to learn the move {1}." + msg.tag = 10; + msg.param[0] = expBattler | (slot << 8); + msg.param[1] = data->unk30[4]; + data->unk30[0] = ov12_0223C494(data->bsys, msgLoader, &msg, BattleSystem_GetTextFrameDelay(data->bsys)); + data->state++; + break; + + case STATE_GET_EXP_CANT_LEARN_MORE_MOVES_PRINT: + msg.id = msg_0197_01179; // "But {0} can't learn more than four moves." + msg.tag = 2; + msg.param[0] = expBattler | (slot << 8); + data->unk30[0] = ov12_0223C494(data->bsys, msgLoader, &msg, BattleSystem_GetTextFrameDelay(data->bsys)); + data->state++; + break; + + case STATE_GET_EXP_WANTS_TO_LEARN_MOVE_PRINT_WAIT: + case STATE_GET_EXP_CANT_LEARN_MORE_MOVES_PRINT_WAIT: + case STATE_GET_EXP_ONE_TWO_POOF_WAIT: + case STATE_GET_EXP_FORGOT_HOW_TO_USE_WAIT: + case STATE_GET_EXP_AND_DOTDOTDOT_WAIT: + case STATE_GET_EXP_MAKE_IT_FORGET_CANCELLED_WAIT: + if (!TextPrinterCheckActive(data->unk30[0])) { data->state++; - break; - - case STATE_GET_EXP_MAKE_IT_FORGET_ANSWER: - if (ov12_0225682C(data->ctx, expBattler)) { - if (ov12_0225682C(data->ctx, expBattler) == 0xFF) { // TODO: could use a const - data->state = STATE_GET_EXP_MAKE_IT_FORGET_CANCELLED; - } else { - msg.id = msg_0197_01183; // "Which move should be forgotten?" - msg.tag = 0; - data->unk30[0] = ov12_0223C494(data->bsys, msgLoader, &msg, BattleSystem_GetTextFrameDelay(data->bsys)); - data->state = 22; - } - } - break; + } + break; - case STATE_GET_EXP_MAKE_IT_FORGET_WAIT: - if (!TextPrinterCheckActive(data->unk30[0])) { - ov12_02263D14(data->bsys, expBattler, data->unk30[4], slot); - data->state++; - } - break; + case STATE_GET_EXP_MAKE_IT_FORGET_PROMPT: + // "Make it forget another move?" + BattleController_EmitDrawYesNoBox(data->bsys, data->ctx, expBattler, 1180, 1, 0, 0); + data->state++; + break; - case STATE_GET_EXP_MAKE_IT_FORGET_INPUT_TAKEN: - if (ov12_0225682C(data->ctx, expBattler) == 0xFF) { + case STATE_GET_EXP_MAKE_IT_FORGET_ANSWER: + if (ov12_0225682C(data->ctx, expBattler)) { + if (ov12_0225682C(data->ctx, expBattler) == 0xFF) { // TODO: could use a const data->state = STATE_GET_EXP_MAKE_IT_FORGET_CANCELLED; - } else if (ov12_0225682C(data->ctx, expBattler)) { - data->unk30[5] = data->ctx->unk_2300[expBattler][0] - 1; - data->state = 24; + } else { + msg.id = msg_0197_01183; // "Which move should be forgotten?" + msg.tag = 0; + data->unk30[0] = ov12_0223C494(data->bsys, msgLoader, &msg, BattleSystem_GetTextFrameDelay(data->bsys)); + data->state = STATE_GET_EXP_MAKE_IT_FORGET_WAIT; } - break; + } + break; - case STATE_GET_EXP_MAKE_IT_FORGET_CANCELLED: - msg.id = msg_0197_01184; // "Well, then..." - msg.tag = 0; - data->unk30[0] = ov12_0223C494(data->bsys, msgLoader, &msg, BattleSystem_GetTextFrameDelay(data->bsys)); + case STATE_GET_EXP_MAKE_IT_FORGET_WAIT: + if (!TextPrinterCheckActive(data->unk30[0])) { + ov12_02263D14(data->bsys, expBattler, data->unk30[4], slot); data->state++; - break; + } + break; - case STATE_GET_EXP_GIVE_UP_LEARNING_PROMPT: - // "Should this Pokémon give up on learning this new move?" - BattleController_EmitDrawYesNoBox(data->bsys, data->ctx, expBattler, 1185, 2, data->unk30[4], 0); - data->state++; - break; + case STATE_GET_EXP_MAKE_IT_FORGET_INPUT_TAKEN: + if (ov12_0225682C(data->ctx, expBattler) == 0xFF) { + data->state = STATE_GET_EXP_MAKE_IT_FORGET_CANCELLED; + } else if (ov12_0225682C(data->ctx, expBattler)) { + data->unk30[5] = data->ctx->unk_2300[expBattler][0] - 1; + data->state = STATE_GET_EXP_ONE_TWO_POOF; + } + break; - case STATE_GET_EXP_GIVE_UP_LEARNING_ANSWER: - if (ov12_0225682C(data->ctx, expBattler)) { - if (ov12_0225682C(data->ctx, expBattler) == 0xFF) { - data->state = STATE_GET_EXP_WANTS_TO_LEARN_MOVE_PRINT; - } else { - msg.id = msg_0197_01188; // "{0} did not learn {1}." - msg.tag = 10; - msg.param[0] = expBattler | (slot << 8); - msg.param[1] = data->unk30[4]; - data->unk30[0] = ov12_0223C494(data->bsys, msgLoader, &msg, BattleSystem_GetTextFrameDelay(data->bsys)); - data->state = 35; - } - } - break; + case STATE_GET_EXP_MAKE_IT_FORGET_CANCELLED: + msg.id = msg_0197_01184; // "Well, then..." + msg.tag = 0; + data->unk30[0] = ov12_0223C494(data->bsys, msgLoader, &msg, BattleSystem_GetTextFrameDelay(data->bsys)); + data->state++; + break; + + case STATE_GET_EXP_GIVE_UP_LEARNING_PROMPT: + // "Should this Pokémon give up on learning this new move?" + BattleController_EmitDrawYesNoBox(data->bsys, data->ctx, expBattler, 1185, 2, data->unk30[4], 0); + data->state++; + break; - case STATE_GET_EXP_GIVE_UP_LEARNING_WAIT: - if (!TextPrinterCheckActive(data->unk30[0])) { - // Check for another move to learn - data->state = STATE_GET_EXP_CHECK_LEARN_MOVE; + case STATE_GET_EXP_GIVE_UP_LEARNING_ANSWER: + if (ov12_0225682C(data->ctx, expBattler)) { + if (ov12_0225682C(data->ctx, expBattler) == 0xFF) { + data->state = STATE_GET_EXP_WANTS_TO_LEARN_MOVE_PRINT; + } else { + msg.id = msg_0197_01188; // "{0} did not learn {1}." + msg.tag = 10; + msg.param[0] = expBattler | (slot << 8); + msg.param[1] = data->unk30[4]; + data->unk30[0] = ov12_0223C494(data->bsys, msgLoader, &msg, BattleSystem_GetTextFrameDelay(data->bsys)); + data->state = 35; } - break; + } + break; - case STATE_GET_EXP_ONE_TWO_POOF: - msg.id = msg_0197_01189; // "1, 2, and... ... Poof!" - msg.tag = 0; - data->unk30[0] = ov12_0223C494(data->bsys, msgLoader, &msg, BattleSystem_GetTextFrameDelay(data->bsys)); - data->state++; - break; - - case STATE_GET_EXP_FORGOT_HOW_TO_USE: - msg.id = msg_0197_01190; // "{0} forgot how to use {1}." - msg.tag = 10; - msg.param[0] = expBattler | (slot << 8); - msg.param[1] = GetMonData(mon, 54 + data->unk30[5], NULL); - data->unk30[0] = ov12_0223C494(data->bsys, msgLoader, &msg, BattleSystem_GetTextFrameDelay(data->bsys)); - data->state++; - break; + case STATE_GET_EXP_GIVE_UP_LEARNING_WAIT: + if (!TextPrinterCheckActive(data->unk30[0])) { + // Check for another move to learn + data->state = STATE_GET_EXP_CHECK_LEARN_MOVE; + } + break; - case STATE_GET_EXP_AND_DOTDOTDOT: - msg.id = msg_0197_01191; // "And..." - msg.tag = 0; - data->unk30[0] = ov12_0223C494(data->bsys, msgLoader, &msg, BattleSystem_GetTextFrameDelay(data->bsys)); - data->state++; - break; + case STATE_GET_EXP_ONE_TWO_POOF: + msg.id = msg_0197_01189; // "1, 2, and... ... Poof!" + msg.tag = 0; + data->unk30[0] = ov12_0223C494(data->bsys, msgLoader, &msg, BattleSystem_GetTextFrameDelay(data->bsys)); + data->state++; + break; - case STATE_GET_EXP_LEARNED_MOVE: - msg.id = msg_0197_01192; // "{0} learned {1}!" - msg.tag = 10; - msg.param[0] = expBattler | (slot << 8); - msg.param[1] = data->unk30[4]; - data->unk30[0] = ov12_0223C494(data->bsys, msgLoader, &msg, BattleSystem_GetTextFrameDelay(data->bsys)); + case STATE_GET_EXP_FORGOT_HOW_TO_USE: + msg.id = msg_0197_01190; // "{0} forgot how to use {1}." + msg.tag = 10; + msg.param[0] = expBattler | (slot << 8); + msg.param[1] = GetMonData(mon, MON_DATA_MOVE1 + data->unk30[5], NULL); + data->unk30[0] = ov12_0223C494(data->bsys, msgLoader, &msg, BattleSystem_GetTextFrameDelay(data->bsys)); + data->state++; + break; + + case STATE_GET_EXP_AND_DOTDOTDOT: + msg.id = msg_0197_01191; // "And..." + msg.tag = 0; + data->unk30[0] = ov12_0223C494(data->bsys, msgLoader, &msg, BattleSystem_GetTextFrameDelay(data->bsys)); + data->state++; + break; - i = 0; - SetMonData(mon, MON_DATA_MOVE1PPUP + data->unk30[5], &i); - MonSetMoveInSlot(mon, data->unk30[4], data->unk30[5]); + case STATE_GET_EXP_LEARNED_MOVE: + msg.id = msg_0197_01192; // "{0} learned {1}!" + msg.tag = 10; + msg.param[0] = expBattler | (slot << 8); + msg.param[1] = data->unk30[4]; + data->unk30[0] = ov12_0223C494(data->bsys, msgLoader, &msg, BattleSystem_GetTextFrameDelay(data->bsys)); + + i = 0; + SetMonData(mon, MON_DATA_MOVE1PPUP + data->unk30[5], &i); + MonSetMoveInSlot(mon, data->unk30[4], data->unk30[5]); - if (data->ctx->selectedMonIndex[expBattler] == slot) { - BattleSystem_ReloadMonData(data->bsys, - data->ctx, - expBattler, - data->ctx->selectedMonIndex[expBattler]); - } + if (data->ctx->selectedMonIndex[expBattler] == slot) { + BattleSystem_ReloadMonData(data->bsys, data->ctx, expBattler, data->ctx->selectedMonIndex[expBattler]); + } - data->state = STATE_GET_EXP_LEARNED_MOVE_WAIT; - break; + data->state = STATE_GET_EXP_LEARNED_MOVE_WAIT; + break; - case STATE_GET_EXP_LEARNED_MOVE_WAIT: - if (!TextPrinterCheckActive(data->unk30[0])) { - // Check for another move to learn - data->state = STATE_GET_EXP_CHECK_LEARN_MOVE; - } - break; + case STATE_GET_EXP_LEARNED_MOVE_WAIT: + if (!TextPrinterCheckActive(data->unk30[0])) { + // Check for another move to learn + data->state = STATE_GET_EXP_CHECK_LEARN_MOVE; + } + break; - case STATE_GET_EXP_CHECK_DONE: - data->ctx->unk_A4[battler] &= (MaskOfFlagNo(slot) ^ 0xFFFFFFFF); // this mon is done - data->unk30[6] = slot + 1; - data->state = STATE_GET_EXP_START; // go back to the top and get the next mon - break; + case STATE_GET_EXP_CHECK_DONE: + data->ctx->unk_A4[side] &= (MaskOfFlagNo(slot) ^ 0xFFFFFFFF); // this mon is done + data->unk30[6] = slot + 1; + data->state = STATE_GET_EXP_START; // go back to the top and get the next mon + break; - case STATE_GET_EXP_DONE: - data->ctx->getterWork = NULL; - FreeToHeap(inData); - DestroySysTask(task); - break; + case STATE_GET_EXP_DONE: + data->ctx->getterWork = NULL; + FreeToHeap(inData); + DestroySysTask(task); + break; } } From e0794d586fd3a2d91879b3dc66826442aa053f46 Mon Sep 17 00:00:00 2001 From: Adrienn Tindall <33725376+adrienntindall@users.noreply.github.com> Date: Tue, 28 Nov 2023 12:57:28 -0500 Subject: [PATCH 09/33] Start work on trainer ai decomp (overlay 10) --- asm/overlay_10.s | 116 ------------------------------------ include/battle/trainer_ai.h | 6 ++ main.lsf | 1 + src/battle/trainer_ai.c | 44 ++++++++++++++ 4 files changed, 51 insertions(+), 116 deletions(-) create mode 100644 include/battle/trainer_ai.h create mode 100644 src/battle/trainer_ai.c diff --git a/asm/overlay_10.s b/asm/overlay_10.s index 95e4a83875..ebce380cdb 100644 --- a/asm/overlay_10.s +++ b/asm/overlay_10.s @@ -4,122 +4,6 @@ .text - thumb_func_start ov10_0221BE20 -ov10_0221BE20: ; 0x0221BE20 - push {r3, r4, r5, r6, r7, lr} - sub sp, #8 - add r6, r0, #0 - mov r0, #0xd5 - str r2, [sp, #4] - add r5, r1, #0 - lsl r0, r0, #2 - add r2, r3, #0 - add r3, r5, r0 - mov r0, #0 - add r1, r0, #0 -_0221BE36: - strb r1, [r3, r0] - add r0, r0, #1 - cmp r0, #0x1c - blo _0221BE36 - mov r7, #0 - mov r0, #0x64 -_0221BE42: - mov r3, #1 - tst r3, r2 - beq _0221BE52 - mov r3, #0xd6 - add r4, r5, r1 - lsl r3, r3, #2 - strb r0, [r4, r3] - b _0221BE5A -_0221BE52: - mov r3, #0xd6 - add r4, r5, r1 - lsl r3, r3, #2 - strb r7, [r4, r3] -_0221BE5A: - lsl r2, r2, #0x17 - add r1, r1, #1 - lsr r2, r2, #0x18 - cmp r1, #4 - blt _0221BE42 - mov r0, #0 - mvn r0, r0 - str r0, [sp] - ldr r2, [sp, #4] - add r0, r6, #0 - add r1, r5, #0 - mov r3, #0 - bl StruggleCheck - lsl r0, r0, #0x18 - lsr r7, r0, #0x18 - mov r4, #0 -_0221BE7C: - add r0, r4, #0 - bl MaskOfFlagNo - tst r0, r7 - beq _0221BE90 - mov r0, #0xd6 - add r2, r5, r4 - mov r1, #0 - lsl r0, r0, #2 - strb r1, [r2, r0] -_0221BE90: - add r0, r6, #0 - bl BattleSystem_Random - lsr r1, r0, #0x1f - lsl r2, r0, #0x1c - sub r2, r2, r1 - mov r0, #0x1c - ror r2, r0 - add r1, r1, r2 - mov r0, #0x64 - sub r2, r0, r1 - mov r0, #0xdb - add r1, r5, r4 - lsl r0, r0, #2 - add r4, r4, #1 - strb r2, [r1, r0] - cmp r4, #4 - blt _0221BE7C - mov r2, #0xf3 - mov r0, #0 - lsl r2, r2, #2 - strb r0, [r5, r2] - mov r0, #1 - ldr r1, [r6, #0x2c] - lsl r0, r0, #8 - tst r1, r0 - beq _0221BECA - lsl r0, r0, #0x15 - b _0221BED6 -_0221BECA: - ldr r0, [sp, #4] - mov r1, #0x34 - mul r1, r0 - add r0, r6, r1 - add r0, #0xb8 - ldr r0, [r0] -_0221BED6: - sub r2, #0x6c - str r0, [r5, r2] - ldr r1, [r6, #0x2c] - mov r0, #2 - tst r0, r1 - beq _0221BEEE - mov r1, #0x36 - lsl r1, r1, #4 - ldr r2, [r5, r1] - mov r0, #0x80 - orr r0, r2 - str r0, [r5, r1] -_0221BEEE: - add sp, #8 - pop {r3, r4, r5, r6, r7, pc} - .balign 4, 0 - thumb_func_end ov10_0221BE20 - thumb_func_start ov10_0221BEF4 ov10_0221BEF4: ; 0x0221BEF4 push {r4, r5, r6, lr} diff --git a/include/battle/trainer_ai.h b/include/battle/trainer_ai.h new file mode 100644 index 0000000000..9985f7eba5 --- /dev/null +++ b/include/battle/trainer_ai.h @@ -0,0 +1,6 @@ +#ifndef POKEHEARTGOLD_TRAINER_AI_H +#define POKEHEARTGOLD_TRAINER_AI_H + +void ov10_0221BE20(BattleSystem *bsys, BattleContext *ctx, u8 battlerId, u8 a3); + +#endif diff --git a/main.lsf b/main.lsf index 254c7bae49..c6ba8e6a3a 100644 --- a/main.lsf +++ b/main.lsf @@ -555,6 +555,7 @@ Overlay OVY_9 Overlay OVY_10 { After OVY_6 + Object src/battle/trainer_ai.o Object asm/overlay_10.o } Overlay OVY_11 diff --git a/src/battle/trainer_ai.c b/src/battle/trainer_ai.c new file mode 100644 index 0000000000..ff410e21ed --- /dev/null +++ b/src/battle/trainer_ai.c @@ -0,0 +1,44 @@ +#include "battle/battle.h" +#include "battle/battle_system.h" +#include "battle/trainer_ai.h" +#include "battle/overlay_12_0224E4FC.h" + +void ov10_0221BE20(BattleSystem *bsys, BattleContext *ctx, u8 battlerId, u8 a3) { + int i; + u8 struggleFlags; + u8 *aiData = (u8 *) &ctx->unk_334; + + for (i = 0; i < (u32) 28; i++) { + aiData[i] = 0; + } + + for (i = 0; i < 4; i++) { + if (a3 & 1) { + ctx->unk_334.unk4[i] = 100; + } else { + ctx->unk_334.unk4[i] = 0; + } + a3 >>= 1; + } + + struggleFlags = StruggleCheck(bsys, ctx, battlerId, 0, -1); + + for (i = 0; i < 4; i++) { + if (struggleFlags & MaskOfFlagNo(i)) { + ctx->unk_334.unk4[i] = 0; + } + ctx->unk_334.unk18[i] = 100 - (BattleSystem_Random(bsys) % 16); + } + + ctx->unk_334.unk98 = 0; + + if (bsys->battleType & BATTLE_TYPE_8) { + ctx->unk_334.unkC = 1 << 0x1d; + } else { + ctx->unk_334.unkC = bsys->trainers[battlerId].data.aiFlags; + } + + if (bsys->battleType & BATTLE_TYPE_DOUBLES) { + ctx->unk_334.unkC |= 0x80; + } +} From 2951dc81b244cfd2804d132305684fc65360a72b Mon Sep 17 00:00:00 2001 From: Adrienn Tindall <33725376+adrienntindall@users.noreply.github.com> Date: Tue, 28 Nov 2023 13:18:15 -0500 Subject: [PATCH 10/33] UnkBtlCtxSub_76 -> TrainerAIData --- include/battle/battle.h | 10 +-- include/constants/battle.h | 5 ++ src/battle/battle_command.c | 58 +++++++------- src/battle/battle_controller_player.c | 16 ++-- src/battle/overlay_12_0224E4FC.c | 108 +++++++++++++------------- src/battle/trainer_ai.c | 18 ++--- 6 files changed, 110 insertions(+), 105 deletions(-) diff --git a/include/battle/battle.h b/include/battle/battle.h index 46ec18e892..f19c6aeaed 100644 --- a/include/battle/battle.h +++ b/include/battle/battle.h @@ -108,13 +108,13 @@ typedef struct SelfTurnData { int shellBellDamage; } SelfTurnData; -typedef struct UnkBtlCtxSub_76 { +typedef struct TrainerAIData { u8 unk0; u8 unk1; u16 unk2; - s8 unk4[4]; + s8 movePoints[4]; //higher points = more priority for selection int unk8; - u32 unkC; + u32 aiFlags; u8 unk10; u8 unk11; u8 unk12; @@ -138,7 +138,7 @@ typedef struct UnkBtlCtxSub_76 { ItemData *itemData; u16 unk280[4]; u16 unk288[4]; -} UnkBtlCtxSub_76; +} TrainerAIData; typedef struct MoveFailFlags { u32 paralysis:1; @@ -341,7 +341,7 @@ typedef struct BattleContext { TurnData turnData[4]; SelfTurnData selfTurnData[4]; MoveFailFlags moveFail[4]; - UnkBtlCtxSub_76 unk_334; + TrainerAIData trainerAIData; u32 * unk_2134; u32 unk_2138; u32 battleStatus; diff --git a/include/constants/battle.h b/include/constants/battle.h index 66ff723c19..35b5c4107e 100644 --- a/include/constants/battle.h +++ b/include/constants/battle.h @@ -469,6 +469,11 @@ typedef enum Terrain { #define STAT_UP_5 11 #define STAT_UP_6 12 +//Trainer AI Flags + +#define AI_DOUBLES (1 << 7) +#define AI_29 (1 << 29) + //Battle Controller Commands #ifndef PM_ASM typedef enum ControllerCommand { diff --git a/src/battle/battle_command.c b/src/battle/battle_command.c index 45af5cc37d..124164a007 100644 --- a/src/battle/battle_command.c +++ b/src/battle/battle_command.c @@ -720,7 +720,7 @@ static void DamageCalcDefault(BattleSystem *bsys, BattleContext *ctx) { } else if (ctx->moveType) { type = ctx->moveType; } else { - type = ctx->unk_334.moveData[ctx->moveNoCur].type; + type = ctx->trainerAIData.moveData[ctx->moveNoCur].type; } ctx->damage = CalcMoveDamage(bsys, ctx, ctx->moveNoCur, ctx->fieldSideConditionFlags[BattleSystem_GetFieldSide(bsys, ctx->battlerIdTarget)], ctx->fieldCondition, ctx->movePower, type, ctx->battlerIdAttacker, ctx->battlerIdTarget, ctx->criticalMultiplier); @@ -1144,7 +1144,7 @@ BOOL BtlCmd_JumpToSubSeq(BattleSystem *bsys, BattleContext *ctx) { BOOL BtlCmd_JumpToCurMoveEffectScript(BattleSystem *bsys, BattleContext *ctx) { BattleScriptIncrementPointer(ctx, 1); - BattleScriptJump(ctx, NARC_a_0_3_0, ctx->unk_334.moveData[ctx->moveNoCur].effect); + BattleScriptJump(ctx, NARC_a_0_3_0, ctx->trainerAIData.moveData[ctx->moveNoCur].effect); return FALSE; } @@ -2314,7 +2314,7 @@ BOOL BtlCmd_TryConversion(BattleSystem *bsys, BattleContext *ctx) { for (i = 0; i < cnt; i++) { if (ctx->battleMons[ctx->battlerIdAttacker].moves[i] != MOVE_CONVERSION) { - moveType = ctx->unk_334.moveData[ctx->battleMons[ctx->battlerIdAttacker].moves[i]].type; + moveType = ctx->trainerAIData.moveData[ctx->battleMons[ctx->battlerIdAttacker].moves[i]].type; if (moveType == TYPE_MYSTERY) { if (GetBattlerVar(ctx, ctx->battlerIdAttacker, BMON_DATA_TYPE_1, NULL) == TYPE_GHOST || GetBattlerVar(ctx, ctx->battlerIdAttacker, BMON_DATA_TYPE_2, NULL) == TYPE_GHOST) { moveType = TYPE_GHOST; @@ -2335,7 +2335,7 @@ BOOL BtlCmd_TryConversion(BattleSystem *bsys, BattleContext *ctx) { do { i = BattleSystem_Random(bsys) % cnt; } while(ctx->battleMons[ctx->battlerIdAttacker].moves[i] == MOVE_CONVERSION); - moveType = ctx->unk_334.moveData[ctx->battleMons[ctx->battlerIdAttacker].moves[i]].type; + moveType = ctx->trainerAIData.moveData[ctx->battleMons[ctx->battlerIdAttacker].moves[i]].type; if (moveType == TYPE_MYSTERY) { if (GetBattlerVar(ctx, ctx->battlerIdAttacker, BMON_DATA_TYPE_1, NULL) == TYPE_GHOST || GetBattlerVar(ctx, ctx->battlerIdAttacker, BMON_DATA_TYPE_2, NULL) == TYPE_GHOST) { moveType = TYPE_GHOST; @@ -2568,7 +2568,7 @@ BOOL BtlCmd_TryOHKO(BattleSystem *bsys, BattleContext *ctx) { if (!(ctx->battleMons[ctx->battlerIdTarget].moveEffectFlags & MOVE_EFFECT_FLAG_LOCK_ON) && GetBattlerAbility(ctx, ctx->battlerIdAttacker) != ABILITY_NO_GUARD && GetBattlerAbility(ctx, ctx->battlerIdTarget) != ABILITY_NO_GUARD) { - hitChance = ctx->battleMons[ctx->battlerIdAttacker].level - ctx->battleMons[ctx->battlerIdTarget].level + ctx->unk_334.moveData[ctx->moveNoCur].accuracy; + hitChance = ctx->battleMons[ctx->battlerIdAttacker].level - ctx->battleMons[ctx->battlerIdTarget].level + ctx->trainerAIData.moveData[ctx->moveNoCur].accuracy; if ((BattleSystem_Random(bsys) % 100) < hitChance && (ctx->battleMons[ctx->battlerIdAttacker].level >= ctx->battleMons[ctx->battlerIdTarget].level)) { hitChance = 1; } else { @@ -2581,7 +2581,7 @@ BOOL BtlCmd_TryOHKO(BattleSystem *bsys, BattleContext *ctx) { ctx->battleMons[ctx->battlerIdAttacker].level >= ctx->battleMons[ctx->battlerIdTarget].level) { hitChance = 1; } else { - hitChance = ctx->battleMons[ctx->battlerIdAttacker].level - ctx->battleMons[ctx->battlerIdTarget].level + ctx->unk_334.moveData[ctx->moveNoCur].accuracy; + hitChance = ctx->battleMons[ctx->battlerIdAttacker].level - ctx->battleMons[ctx->battlerIdTarget].level + ctx->trainerAIData.moveData[ctx->moveNoCur].accuracy; if ((BattleSystem_Random(bsys) % 100) < hitChance && ctx->battleMons[ctx->battlerIdAttacker].level >= ctx->battleMons[ctx->battlerIdTarget].level) { hitChance = 1; } else { @@ -2669,8 +2669,8 @@ BOOL BtlCmd_TryMimic(BattleSystem *bsys, BattleContext *ctx) { if (moveIndex == MAX_MON_MOVES) { ctx->moveTemp = ctx->moveNoBattlerPrev[ctx->battlerIdTarget]; ctx->battleMons[ctx->battlerIdAttacker].moves[mimicIndex] = ctx->moveTemp; - if (ctx->unk_334.moveData[ctx->moveTemp].pp < 5) { - ctx->battleMons[ctx->battlerIdAttacker].movePPCur[mimicIndex] = ctx->unk_334.moveData[ctx->moveTemp].pp; + if (ctx->trainerAIData.moveData[ctx->moveTemp].pp < 5) { + ctx->battleMons[ctx->battlerIdAttacker].movePPCur[mimicIndex] = ctx->trainerAIData.moveData[ctx->moveTemp].pp; } else { ctx->battleMons[ctx->battlerIdAttacker].movePPCur[mimicIndex] = 5; } @@ -2893,7 +2893,7 @@ BOOL BtlCmd_TrySketch(BattleSystem *bsys, BattleContext *ctx) { } if (moveIndex == MAX_MON_MOVES) { ctx->battleMons[ctx->battlerIdAttacker].moves[sketchIndex] = ctx->moveNoSketch[ctx->battlerIdTarget]; - ctx->battleMons[ctx->battlerIdAttacker].movePPCur[sketchIndex] = ctx->unk_334.moveData[ctx->moveNoSketch[ctx->battlerIdTarget]].pp; + ctx->battleMons[ctx->battlerIdAttacker].movePPCur[sketchIndex] = ctx->trainerAIData.moveData[ctx->moveNoSketch[ctx->battlerIdTarget]].pp; BattleController_EmitBattleMonToPartyMonCopy(bsys, ctx, ctx->battlerIdAttacker); ctx->moveTemp = ctx->moveNoSketch[ctx->battlerIdTarget]; if (ctx->moveTemp == MOVE_LAST_RESORT) { @@ -3089,11 +3089,11 @@ BOOL BtlCmd_TryProtect(BattleSystem *bsys, BattleContext *ctx) { } if (sProtectSuccessChance[ctx->battleMons[ctx->battlerIdAttacker].unk88.protectSuccessTurns] >= (u32) BattleSystem_Random(bsys) && flag) { - if (ctx->unk_334.moveData[ctx->moveNoCur].effect == 111) { + if (ctx->trainerAIData.moveData[ctx->moveNoCur].effect == 111) { ctx->turnData[ctx->battlerIdAttacker].protectFlag = TRUE; ctx->buffMsg.id = msg_0197_00282; } - if (ctx->unk_334.moveData[ctx->moveNoCur].effect == 116) { + if (ctx->trainerAIData.moveData[ctx->moveNoCur].effect == 116) { ctx->turnData[ctx->battlerIdAttacker].unk0_9 = TRUE; ctx->buffMsg.id = msg_0197_00442; @@ -3242,8 +3242,8 @@ BOOL BtlCmd_Transform(BattleSystem *bsys, BattleContext *ctx) { ctx->battleMons[ctx->battlerIdAttacker].slowStartEnded = 0; for (i = 0; (int) i < MAX_MON_MOVES; i++) { - if (ctx->unk_334.moveData[ctx->battleMons[ctx->battlerIdAttacker].moves[i]].pp < 5) { - ctx->battleMons[ctx->battlerIdAttacker].movePPCur[i] = ctx->unk_334.moveData[ctx->battleMons[ctx->battlerIdAttacker].moves[i]].pp; + if (ctx->trainerAIData.moveData[ctx->battleMons[ctx->battlerIdAttacker].moves[i]].pp < 5) { + ctx->battleMons[ctx->battlerIdAttacker].movePPCur[i] = ctx->trainerAIData.moveData[ctx->battleMons[ctx->battlerIdAttacker].moves[i]].pp; } else { ctx->battleMons[ctx->battlerIdAttacker].movePPCur[i] = 5; } @@ -3429,7 +3429,7 @@ BOOL BtlCmd_RolloutDamageCalc(BattleSystem *bsys, BattleContext *ctx) { UnlockBattlerOutOfCurrentMove(bsys, ctx, ctx->battlerIdAttacker); } - ctx->movePower = ctx->unk_334.moveData[ctx->moveNoCur].power; + ctx->movePower = ctx->trainerAIData.moveData[ctx->moveNoCur].power; j = 5 - ctx->battleMons[ctx->battlerIdAttacker].unk88.rolloutCount; @@ -3453,7 +3453,7 @@ BOOL BtlCmd_FuryCutterDamageCalc(BattleSystem *bsys, BattleContext *ctx) { ctx->battleMons[ctx->battlerIdAttacker].unk88.furyCutterCount++; } - ctx->movePower = ctx->unk_334.moveData[ctx->moveNoCur].power; + ctx->movePower = ctx->trainerAIData.moveData[ctx->moveNoCur].power; for (i = 1; i < ctx->battleMons[ctx->battlerIdAttacker].unk88.furyCutterCount; i++) { ctx->movePower *= 2; @@ -3766,7 +3766,7 @@ BOOL BtlCmd_BeatUpDamageCalc(BattleSystem *bsys, BattleContext *ctx) { level = GetMonData(mon, MON_DATA_LEVEL, 0); ctx->damage = GetMonBaseStat_HandleAlternateForm(species, form, BASE_ATK); - ctx->damage *= ctx->unk_334.moveData[ctx->moveNoCur].power; + ctx->damage *= ctx->trainerAIData.moveData[ctx->moveNoCur].power; ctx->damage *= (level * 2 / 5 + 2); ctx->damage /= (u32) GetMonBaseStat_HandleAlternateForm(ctx->battleMons[ctx->battlerIdTarget].species, ctx->battleMons[ctx->battlerIdTarget].form, BASE_DEF); ctx->damage /= 50; @@ -3948,7 +3948,7 @@ BOOL BtlCmd_MagicCoat(BattleSystem *bsys, BattleContext *ctx) { if (ctx->fieldSideConditionData[side].followMeFlag && ctx->battleMons[ctx->fieldSideConditionData[side].battlerIdFollowMe].hp) { ctx->battlerIdTarget = ctx->fieldSideConditionData[side].battlerIdFollowMe; - } else if (ctx->unk_334.moveData[ctx->moveNoCur].range == RANGE_ADJACENT_OPPONENTS || ctx->unk_334.moveData[ctx->moveNoCur].range == RANGE_ALL_ADJACENT) { + } else if (ctx->trainerAIData.moveData[ctx->moveNoCur].range == RANGE_ADJACENT_OPPONENTS || ctx->trainerAIData.moveData[ctx->moveNoCur].range == RANGE_ALL_ADJACENT) { ctx->battlerIdTarget = battlerId; } else { side = ov12_022506D4(bsys, ctx, ctx->battlerIdAttacker, (u16) ctx->moveNoCur, 1, 0); @@ -4038,7 +4038,7 @@ BOOL BtlCmd_EruptionDamageCalc(BattleSystem *bsys, BattleContext *ctx) { BattleScriptIncrementPointer(ctx, 1); if (ctx->movePower == 0) { - ctx->movePower = ctx->unk_334.moveData[ctx->moveNoCur].power * ctx->battleMons[ctx->battlerIdAttacker].hp / ctx->battleMons[ctx->battlerIdAttacker].maxHp; + ctx->movePower = ctx->trainerAIData.moveData[ctx->moveNoCur].power * ctx->battleMons[ctx->battlerIdAttacker].hp / ctx->battleMons[ctx->battlerIdAttacker].maxHp; if (ctx->movePower == 0) { ctx->movePower = 1; } @@ -4168,7 +4168,7 @@ BOOL BtlCmd_WeatherBallDamageCalc(BattleSystem *bsys, BattleContext *ctx) { if (!CheckAbilityActive(bsys, ctx, CHECK_ABILITY_ALL_HP, 0, ABILITY_CLOUD_NINE) && !CheckAbilityActive(bsys, ctx, CHECK_ABILITY_ALL_HP, 0, ABILITY_AIR_LOCK)) { if (ctx->fieldCondition & FIELD_CONDITION_WEATHER) { - ctx->movePower = ctx->unk_334.moveData[ctx->moveNoCur].power * 2; + ctx->movePower = ctx->trainerAIData.moveData[ctx->moveNoCur].power * 2; if (ctx->fieldCondition & FIELD_CONDITION_RAIN_ALL) { ctx->moveType = TYPE_WATER; } @@ -4182,7 +4182,7 @@ BOOL BtlCmd_WeatherBallDamageCalc(BattleSystem *bsys, BattleContext *ctx) { ctx->moveType = TYPE_ICE; } } else { - ctx->movePower = ctx->unk_334.moveData[ctx->moveNoCur].power; + ctx->movePower = ctx->trainerAIData.moveData[ctx->moveNoCur].power; } } @@ -4207,7 +4207,7 @@ BOOL BtlCmd_TryPursuit(BattleSystem *bsys, BattleContext *ctx) { } if (moveNo) { moveIndex = BattleMon_GetMoveIndex(&ctx->battleMons[battlerId], moveNo); - if (ctx->unk_334.moveData[moveNo].effect == 128 && ctx->battleMons[battlerId].movePPCur[moveIndex]) { + if (ctx->trainerAIData.moveData[moveNo].effect == 128 && ctx->battleMons[battlerId].movePPCur[moveIndex]) { ctx->battleMons[battlerId].movePPCur[moveIndex]--; if (GetBattlerAbility(ctx, ctx->battlerIdSwitch) == ABILITY_PRESSURE && ctx->battleMons[battlerId].movePPCur[moveIndex]) { ctx->battleMons[battlerId].movePPCur[moveIndex]--; @@ -4389,9 +4389,9 @@ BOOL BtlCmd_PaybackDamageCalc(BattleSystem *bsys, BattleContext *ctx) { BattleScriptIncrementPointer(ctx, 1); if (ctx->unk_21A8[ctx->battlerIdTarget][0] == 40) { - ctx->movePower = ctx->unk_334.moveData[ctx->moveNoCur].power*2; + ctx->movePower = ctx->trainerAIData.moveData[ctx->moveNoCur].power*2; } else { - ctx->movePower = ctx->unk_334.moveData[ctx->moveNoCur].power; + ctx->movePower = ctx->trainerAIData.moveData[ctx->moveNoCur].power; } return FALSE; @@ -4436,7 +4436,7 @@ BOOL BtlCmd_TryMeFirst(BattleSystem *bsys, BattleContext *ctx) { } if (ctx->unk_21A8[ctx->battlerIdTarget][0] != 40 && ctx->turnData[ctx->battlerIdTarget].struggleFlag == 0 && - CheckLegalMeFirstMove(ctx, move) == TRUE && ctx->unk_334.moveData[move].power) { + CheckLegalMeFirstMove(ctx, move) == TRUE && ctx->trainerAIData.moveData[move].power) { ctx->battleMons[ctx->battlerIdAttacker].unk88.meFirstFlag = TRUE; ctx->battleMons[ctx->battlerIdAttacker].unk88.meFirstCount = ctx->meFirstTotal; ctx->moveTemp = move; @@ -4497,7 +4497,7 @@ BOOL BtlCmd_TrySuckerPunch(BattleSystem *bsys, BattleContext *ctx) { } if (ctx->unk_21A8[ctx->battlerIdTarget][0] == 40 || - (ctx->unk_334.moveData[move].power == 0 && !ctx->turnData[ctx->battlerIdTarget].struggleFlag)) { + (ctx->trainerAIData.moveData[move].power == 0 && !ctx->turnData[ctx->battlerIdTarget].struggleFlag)) { BattleScriptIncrementPointer(ctx, adrs); } @@ -5072,9 +5072,9 @@ BOOL BtlCmd_CheckEffectActivation(BattleSystem *bsys, BattleContext *ctx) { int adrs = BattleScriptReadWord(ctx); if (GetBattlerAbility(ctx, ctx->battlerIdAttacker) == ABILITY_SERENE_GRACE) { - effectChance = ctx->unk_334.moveData[ctx->moveNoCur].effectChance*2; + effectChance = ctx->trainerAIData.moveData[ctx->moveNoCur].effectChance*2; } else { - effectChance = ctx->unk_334.moveData[ctx->moveNoCur].effectChance; + effectChance = ctx->trainerAIData.moveData[ctx->moveNoCur].effectChance; } GF_ASSERT(effectChance != 0); @@ -5129,7 +5129,7 @@ BOOL BtlCmd_CheckChatterActivation(BattleSystem *bsys, BattleContext *ctx) { BOOL BtlCmd_GetMoveParam(BattleSystem *bsys, BattleContext *ctx) { BattleScriptIncrementPointer(ctx, 1); - ctx->calcTemp = GetMoveTblAttr(&ctx->unk_334.moveData[ctx->moveNoCur], (MoveAttr) BattleScriptReadWord(ctx)); + ctx->calcTemp = GetMoveTblAttr(&ctx->trainerAIData.moveData[ctx->moveNoCur], (MoveAttr) BattleScriptReadWord(ctx)); return FALSE; } @@ -5684,7 +5684,7 @@ BOOL BtlCmd_CheckCurMoveIsType(BattleSystem *bsys, BattleContext *ctx) { int type = BattleScriptReadWord(ctx); int adrs = BattleScriptReadWord(ctx); - if (ctx->unk_334.moveData[ctx->moveNoCur].type == type) { + if (ctx->trainerAIData.moveData[ctx->moveNoCur].type == type) { BattleScriptIncrementPointer(ctx, adrs); } diff --git a/src/battle/battle_controller_player.c b/src/battle/battle_controller_player.c index 75c5730b24..dd49abece7 100644 --- a/src/battle/battle_controller_player.c +++ b/src/battle/battle_controller_player.c @@ -18,8 +18,8 @@ BattleContext *BattleContext_New(BattleSystem *bsys) { BattleContext_Init(ctx); ov12_02251038(bsys, ctx); ov12_0224E384(bsys, ctx); - LoadMoveTbl(ctx->unk_334.moveData); - ctx->unk_334.itemData = LoadAllItemData(HEAP_ID_BATTLE); + LoadMoveTbl(ctx->trainerAIData.moveData); + ctx->trainerAIData.itemData = LoadAllItemData(HEAP_ID_BATTLE); return ctx; } @@ -39,7 +39,7 @@ BOOL BattleContext_Main(BattleSystem *bsys, BattleContext *ctx) { } void BattleContext_Delete(BattleContext *ctx) { - FreeToHeap(ctx->unk_334.itemData); + FreeToHeap(ctx->trainerAIData.itemData); FreeToHeap(ctx); } @@ -1593,7 +1593,7 @@ void BattleControllerPlayer_ItemInput(BattleSystem *bsys, BattleContext *ctx) { item = (BattleItem *)&ctx->unk_21A8[ctx->battlerIdAttacker][2]; if (BattleSystem_GetFieldSide(bsys, ctx->battlerIdAttacker)) { - switch (ctx->unk_334.unk9D[ctx->battlerIdAttacker >> 1]) { + switch (ctx->trainerAIData.unk9D[ctx->battlerIdAttacker >> 1]) { case 0: script = 289; break; @@ -1601,22 +1601,22 @@ void BattleControllerPlayer_ItemInput(BattleSystem *bsys, BattleContext *ctx) { script = 267; break; case 2: - if ((ctx->unk_334.unk9F[ctx->battlerIdAttacker >> 1] & 1) && (ctx->unk_334.unk9F[ctx->battlerIdAttacker >> 1] & 0x3e)) { + if ((ctx->trainerAIData.unk9F[ctx->battlerIdAttacker >> 1] & 1) && (ctx->trainerAIData.unk9F[ctx->battlerIdAttacker >> 1] & 0x3e)) { ctx->msgTemp = 6; } else { - ctx->msgTemp = LowestFlagNo(ctx->unk_334.unk9F[ctx->battlerIdAttacker >> 1]); + ctx->msgTemp = LowestFlagNo(ctx->trainerAIData.unk9F[ctx->battlerIdAttacker >> 1]); } script = 268; break; case 3: - ctx->msgTemp = ctx->unk_334.unk9F[ctx->battlerIdAttacker >> 1]; + ctx->msgTemp = ctx->trainerAIData.unk9F[ctx->battlerIdAttacker >> 1]; script = 269; break; case 4: script = 270; break; } - ctx->itemTemp = ctx->unk_334.unkA0[ctx->battlerIdAttacker >> 1]; + ctx->itemTemp = ctx->trainerAIData.unkA0[ctx->battlerIdAttacker >> 1]; } else { switch (item->page) { case BTLPOCKETLIST_HP_PP_RESTORE: diff --git a/src/battle/overlay_12_0224E4FC.c b/src/battle/overlay_12_0224E4FC.c index 1dea3078b7..3a23546602 100644 --- a/src/battle/overlay_12_0224E4FC.c +++ b/src/battle/overlay_12_0224E4FC.c @@ -1196,8 +1196,8 @@ u8 CheckSortSpeed(BattleSystem *bsys, BattleContext *ctx, int battlerId1, int ba moveNo2 = GetBattlerVar(ctx, battlerId2, BMON_DATA_MOVE1 + movePos2, NULL); } } - movePriority1 = ctx->unk_334.moveData[moveNo1].priority; - movePriority2 = ctx->unk_334.moveData[moveNo2].priority; + movePriority1 = ctx->trainerAIData.moveData[moveNo1].priority; + movePriority2 = ctx->trainerAIData.moveData[moveNo2].priority; } if (movePriority1 == movePriority2) { @@ -1329,9 +1329,9 @@ BOOL ov12_02250490(BattleSystem *bsys, BattleContext *ctx, int *out) { } else if (ctx->unk_2174 & (1 << 26)) { //the inclusion of serene grace here makes me think this function has to do with secondary move effects if (GetBattlerAbility(ctx, ctx->battlerIdAttacker) == ABILITY_SERENE_GRACE) { - effectChance = ctx->unk_334.moveData[ctx->moveNoCur].effectChance * 2; + effectChance = ctx->trainerAIData.moveData[ctx->moveNoCur].effectChance * 2; } else { - effectChance = ctx->unk_334.moveData[ctx->moveNoCur].effectChance; + effectChance = ctx->trainerAIData.moveData[ctx->moveNoCur].effectChance; } GF_ASSERT(effectChance); @@ -1350,9 +1350,9 @@ BOOL ov12_02250490(BattleSystem *bsys, BattleContext *ctx, int *out) { } else if (ctx->unk_2174) { //the inclusion of serene grace here makes me think this function has to do with secondary move effects if (GetBattlerAbility(ctx, ctx->battlerIdAttacker) == ABILITY_SERENE_GRACE) { - effectChance = ctx->unk_334.moveData[ctx->moveNoCur].effectChance * 2; + effectChance = ctx->trainerAIData.moveData[ctx->moveNoCur].effectChance * 2; } else { - effectChance = ctx->unk_334.moveData[ctx->moveNoCur].effectChance; + effectChance = ctx->trainerAIData.moveData[ctx->moveNoCur].effectChance; } GF_ASSERT(effectChance); @@ -1380,7 +1380,7 @@ int ov12_022506D4(BattleSystem *bsys, BattleContext *ctx, int battlerIdAttacker, int moveRange; if (moveNo) { - moveRange = ctx->unk_334.moveData[moveNo].range; + moveRange = ctx->trainerAIData.moveData[moveNo].range; } else { moveRange = range; } @@ -1524,13 +1524,13 @@ void ov12_02250A18(BattleSystem *bsys, BattleContext *ctx, int battlerIdAttacker moveType = GetDynamicMoveType(bsys, ctx, battlerIdAttacker, moveNo); if (!moveType) { - moveType = ctx->unk_334.moveData[moveNo].type; + moveType = ctx->trainerAIData.moveData[moveNo].type; } maxBattlers = BattleSystem_GetMaxBattlers(bsys); if (moveType == TYPE_ELECTRIC && - (ctx->unk_334.moveData[moveNo].range == RANGE_SINGLE_TARGET || ctx->unk_334.moveData[moveNo].range == RANGE_RANDOM_OPPONENT) && + (ctx->trainerAIData.moveData[moveNo].range == RANGE_SINGLE_TARGET || ctx->trainerAIData.moveData[moveNo].range == RANGE_RANDOM_OPPONENT) && !(ctx->battleStatus & BATTLE_STATUS_CHARGE_TURN) && CheckAbilityActive(bsys, ctx, CHECK_ABILITY_ALL_HP_NOT_USER, battlerIdAttacker, ABILITY_LIGHTNINGROD)) { for (battlerId = 0; battlerId < maxBattlers; battlerId++) { @@ -1544,7 +1544,7 @@ void ov12_02250A18(BattleSystem *bsys, BattleContext *ctx, int battlerIdAttacker ctx->battlerIdTarget = battlerIdTarget; } } else if (moveType == TYPE_WATER && - (ctx->unk_334.moveData[moveNo].range == RANGE_SINGLE_TARGET || ctx->unk_334.moveData[moveNo].range == RANGE_RANDOM_OPPONENT) && + (ctx->trainerAIData.moveData[moveNo].range == RANGE_SINGLE_TARGET || ctx->trainerAIData.moveData[moveNo].range == RANGE_RANDOM_OPPONENT) && !(ctx->battleStatus & BATTLE_STATUS_CHARGE_TURN) && CheckAbilityActive(bsys, ctx, CHECK_ABILITY_ALL_HP_NOT_USER, battlerIdAttacker, ABILITY_STORM_DRAIN)) { for (battlerId = 0; battlerId < maxBattlers; battlerId++) { @@ -2008,7 +2008,7 @@ u32 StruggleCheck(BattleSystem *bsys, BattleContext *ctx, int battlerId, u32 non if ((ctx->battleMons[battlerId].moves[movePos] == ctx->moveNoBattlerPrev[battlerId]) && (struggleCheckFlags & STRUGGLE_CHECK_TORMENT) && (ctx->battleMons[battlerId].status2 & STATUS2_TORMENT)) { nonSelectableMoves |= MaskOfFlagNo(movePos); } - if (ctx->battleMons[battlerId].unk88.tauntTurns && (struggleCheckFlags & STRUGGLE_CHECK_TAUNT) && !(ctx->unk_334.moveData[ctx->battleMons[battlerId].moves[movePos]].power)) { + if (ctx->battleMons[battlerId].unk88.tauntTurns && (struggleCheckFlags & STRUGGLE_CHECK_TAUNT) && !(ctx->trainerAIData.moveData[ctx->battleMons[battlerId].moves[movePos]].power)) { nonSelectableMoves |= MaskOfFlagNo(movePos); } if (BattleContext_CheckMoveImprisoned(bsys, ctx, battlerId, ctx->battleMons[battlerId].moves[movePos]) && (struggleCheckFlags & STRUGGLE_CHECK_IMPRISON)) { @@ -2281,10 +2281,10 @@ int ov12_02251D28(BattleSystem *bsys, BattleContext *ctx, int moveNo, int moveTy } else if (moveTypeDefault) { moveType = moveTypeDefault; } else { - moveType = ctx->unk_334.moveData[moveNo].type; + moveType = ctx->trainerAIData.moveData[moveNo].type; } - movePower = ctx->unk_334.moveData[moveNo].power; + movePower = ctx->trainerAIData.moveData[moveNo].power; //STAB if (!(ctx->battleStatus & BATTLE_STATUS_IGNORE_TYPE_EFFECTIVENESS) && (GetBattlerVar(ctx, battlerIdAttacker, BMON_DATA_TYPE_1, NULL) == moveType || GetBattlerVar(ctx, battlerIdAttacker, BMON_DATA_TYPE_2, NULL) == moveType)) { @@ -2372,7 +2372,7 @@ void ov12_02252054(BattleContext *ctx, int moveNo, int moveTypeDefault, int abil } else if (moveTypeDefault) { moveType = moveTypeDefault; } else { - moveType = ctx->unk_334.moveData[moveNo].type; + moveType = ctx->trainerAIData.moveData[moveNo].type; } if (abilityAttacker != ABILITY_MOLD_BREAKER && abilityTarget == ABILITY_LEVITATE && moveType == TYPE_GROUND && !(ctx->fieldCondition & FIELD_CONDITION_GRAVITY) && item != HOLD_EFFECT_SPEED_DOWN_GROUNDED) { @@ -2582,7 +2582,7 @@ int CheckAbilityActive(BattleSystem *bsys, BattleContext *ctx, int flag, int bat //FIXME: Function name is wrong BOOL BattleCtx_IsIdenticalToCurrentMove(BattleContext *ctx, int moveNo) { - switch (ctx->unk_334.moveData[moveNo].effect) { + switch (ctx->trainerAIData.moveData[moveNo].effect) { case MOVE_EFFECT_BIDE: case MOVE_EFFECT_CHARGE_TURN_HIGH_CRIT: case MOVE_EFFECT_CHARGE_TURN_HIGH_CRIT_FLINCH: @@ -3072,20 +3072,20 @@ int ov12_02252EC8(BattleContext *ctx, int battlerIdAttacker, int battlerIdTarget } else if (ctx->moveType) { moveType = ctx->moveType; } else { - moveType = ctx->unk_334.moveData[ctx->moveNoCur].type; + moveType = ctx->trainerAIData.moveData[ctx->moveNoCur].type; } if (CheckBattlerAbilityIfNotIgnored(ctx, battlerIdAttacker, battlerIdTarget, ABILITY_VOLT_ABSORB) == TRUE && moveType == TYPE_ELECTRIC && battlerIdAttacker != battlerIdTarget) { ctx->hpCalc = DamageDivide(ctx->battleMons[battlerIdTarget].maxHp, 4); state = 178; } - if (CheckBattlerAbilityIfNotIgnored(ctx, battlerIdAttacker, battlerIdTarget, ABILITY_WATER_ABSORB) == TRUE && moveType == TYPE_WATER && !(ctx->battleStatus & BATTLE_STATUS_CHARGE_TURN) && ctx->unk_334.moveData[ctx->moveNoCur].power) { + if (CheckBattlerAbilityIfNotIgnored(ctx, battlerIdAttacker, battlerIdTarget, ABILITY_WATER_ABSORB) == TRUE && moveType == TYPE_WATER && !(ctx->battleStatus & BATTLE_STATUS_CHARGE_TURN) && ctx->trainerAIData.moveData[ctx->moveNoCur].power) { ctx->hpCalc = DamageDivide(ctx->battleMons[battlerIdTarget].maxHp, 4); state = 178; } int moveNoCur = ctx->moveNoCur; if (CheckBattlerAbilityIfNotIgnored(ctx, battlerIdAttacker, battlerIdTarget, ABILITY_FLASH_FIRE) == TRUE && moveType == TYPE_FIRE && !(ctx->battleMons[battlerIdTarget].status & STATUS_FREEZE) && !(ctx->battleStatus & BATTLE_STATUS_CHARGE_TURN)) { - if (ctx->unk_334.moveData[ctx->moveNoCur].power || ctx->moveNoCur == MOVE_WILL_O_WISP) { + if (ctx->trainerAIData.moveData[ctx->moveNoCur].power || ctx->moveNoCur == MOVE_WILL_O_WISP) { state = 179; } } @@ -3100,7 +3100,7 @@ int ov12_02252EC8(BattleContext *ctx, int battlerIdAttacker, int battlerIdTarget if (CheckBattlerAbilityIfNotIgnored(ctx, battlerIdAttacker, battlerIdTarget, ABILITY_MOTOR_DRIVE) == TRUE && moveType == TYPE_ELECTRIC && battlerIdAttacker != battlerIdTarget) { state = 182; } - if (CheckBattlerAbilityIfNotIgnored(ctx, battlerIdAttacker, battlerIdTarget, ABILITY_DRY_SKIN) == TRUE && moveType == TYPE_WATER && !(ctx->battleStatus & BATTLE_STATUS_CHARGE_TURN) && ctx->unk_334.moveData[ctx->moveNoCur].power) { + if (CheckBattlerAbilityIfNotIgnored(ctx, battlerIdAttacker, battlerIdTarget, ABILITY_DRY_SKIN) == TRUE && moveType == TYPE_WATER && !(ctx->battleStatus & BATTLE_STATUS_CHARGE_TURN) && ctx->trainerAIData.moveData[ctx->moveNoCur].power) { ctx->hpCalc = DamageDivide(ctx->battleMons[battlerIdTarget].maxHp, 4); state = 178; } @@ -3362,7 +3362,7 @@ int TryAbilityOnEntry(BattleSystem *bsys, BattleContext *ctx) { if (moveNo) { moveStatus = 0; ctx->damage = ov12_02251D28(bsys, ctx, moveNo, 0, battlerIdCheck, battlerId, ctx->damage, &moveStatus); - if (!(moveStatus & MOVE_STATUS_NO_EFFECT) && !ov12_0225865C(ctx, moveNo) && ((moveStatus & MOVE_STATUS_SUPER_EFFECTIVE) || (ctx->unk_334.moveData[moveNo].effect == MOVE_EFFECT_ONE_HIT_KO && ctx->battleMons[battlerId].level <= ctx->battleMons[battlerIdCheck].level))) { + if (!(moveStatus & MOVE_STATUS_NO_EFFECT) && !ov12_0225865C(ctx, moveNo) && ((moveStatus & MOVE_STATUS_SUPER_EFFECTIVE) || (ctx->trainerAIData.moveData[moveNo].effect == MOVE_EFFECT_ONE_HIT_KO && ctx->battleMons[battlerId].level <= ctx->battleMons[battlerIdCheck].level))) { flag = TRUE; break; } @@ -3405,10 +3405,10 @@ int TryAbilityOnEntry(BattleSystem *bsys, BattleContext *ctx) { hp += ctx->battleMons[battlerIdCheck].hp; for (index = 0; index < MAX_MON_MOVES; index++) { moveNo = ctx->battleMons[battlerIdCheck].moves[index]; - power = ctx->unk_334.moveData[moveNo].power; + power = ctx->trainerAIData.moveData[moveNo].power; switch (power) { case 1: - switch (ctx->unk_334.moveData[moveNo].effect) { + switch (ctx->trainerAIData.moveData[moveNo].effect) { case MOVE_EFFECT_ONE_HIT_KO: if (powerTemp < 150 || (powerTemp == 150 && (BattleSystem_Random(bsys) & 1))) { powerTemp = 150; @@ -3642,7 +3642,7 @@ BOOL CheckAbilityEffectOnHit(BattleSystem *bsys, BattleContext *ctx, int *script !(ctx->battleStatus & BATTLE_STATUS_CHARGE_TURN) && !(ctx->battleStatus2 & BATTLE_STATUS2_4) && (ctx->selfTurnData[ctx->battlerIdTarget].physicalDamage || ctx->selfTurnData[ctx->battlerIdTarget].specialDamage) && - (ctx->unk_334.moveData[ctx->moveNoCur].unkB & 1) && + (ctx->trainerAIData.moveData[ctx->moveNoCur].unkB & 1) && (BattleSystem_Random(bsys) % 10 < 3)) { ctx->statChangeType = 3; ctx->battlerIdStatChange = ctx->battlerIdAttacker; @@ -3659,7 +3659,7 @@ BOOL CheckAbilityEffectOnHit(BattleSystem *bsys, BattleContext *ctx, int *script } else if (ctx->moveType) { moveType = ctx->moveType; } else { - moveType = ctx->unk_334.moveData[ctx->moveNoCur].type; + moveType = ctx->trainerAIData.moveData[ctx->moveNoCur].type; } if (ctx->battleMons[ctx->battlerIdTarget].hp && @@ -3667,7 +3667,7 @@ BOOL CheckAbilityEffectOnHit(BattleSystem *bsys, BattleContext *ctx, int *script ctx->moveNoCur != MOVE_STRUGGLE && (ctx->selfTurnData[ctx->battlerIdTarget].physicalDamage || ctx->selfTurnData[ctx->battlerIdTarget].specialDamage) && !(ctx->battleStatus2 & BATTLE_STATUS2_4) && - ctx->unk_334.moveData[ctx->moveNoCur].power && + ctx->trainerAIData.moveData[ctx->moveNoCur].power && GetBattlerVar(ctx, ctx->battlerIdTarget, BMON_DATA_TYPE_1, NULL) != moveType && GetBattlerVar(ctx, ctx->battlerIdTarget, BMON_DATA_TYPE_2, NULL) != moveType) { *script = 188; @@ -3682,7 +3682,7 @@ BOOL CheckAbilityEffectOnHit(BattleSystem *bsys, BattleContext *ctx, int *script !(ctx->battleStatus & BATTLE_STATUS_CHARGE_TURN) && !(ctx->battleStatus2 & BATTLE_STATUS2_4) && (ctx->selfTurnData[ctx->battlerIdTarget].physicalDamage || ctx->selfTurnData[ctx->battlerIdTarget].specialDamage) && - (ctx->unk_334.moveData[ctx->moveNoCur].unkB & 1)) { + (ctx->trainerAIData.moveData[ctx->moveNoCur].unkB & 1)) { ctx->hpCalc = DamageDivide(ctx->battleMons[ctx->battlerIdAttacker].maxHp * -1, 8); ctx->battlerIdTemp = ctx->battlerIdAttacker; *script = 189; @@ -3696,7 +3696,7 @@ BOOL CheckAbilityEffectOnHit(BattleSystem *bsys, BattleContext *ctx, int *script !(ctx->battleStatus & BATTLE_STATUS_CHARGE_TURN) && !(ctx->battleStatus2 & BATTLE_STATUS2_4) && (ctx->selfTurnData[ctx->battlerIdTarget].physicalDamage || ctx->selfTurnData[ctx->battlerIdTarget].specialDamage) && - (ctx->unk_334.moveData[ctx->moveNoCur].unkB & 1) && + (ctx->trainerAIData.moveData[ctx->moveNoCur].unkB & 1) && (BattleSystem_Random(bsys) % 10 < 3)) { switch (BattleSystem_Random(bsys) % 3) { case 0: @@ -3723,7 +3723,7 @@ BOOL CheckAbilityEffectOnHit(BattleSystem *bsys, BattleContext *ctx, int *script !(ctx->battleStatus & BATTLE_STATUS_CHARGE_TURN) && !(ctx->battleStatus2 & BATTLE_STATUS2_4) && (ctx->selfTurnData[ctx->battlerIdTarget].physicalDamage || ctx->selfTurnData[ctx->battlerIdTarget].specialDamage) && - (ctx->unk_334.moveData[ctx->moveNoCur].unkB & 1) && + (ctx->trainerAIData.moveData[ctx->moveNoCur].unkB & 1) && (BattleSystem_Random(bsys) % 10 < 3)) { ctx->statChangeType = 3; ctx->battlerIdStatChange = ctx->battlerIdAttacker; @@ -3739,7 +3739,7 @@ BOOL CheckAbilityEffectOnHit(BattleSystem *bsys, BattleContext *ctx, int *script !(ctx->battleStatus & BATTLE_STATUS_CHARGE_TURN) && !(ctx->battleStatus2 & BATTLE_STATUS2_4) && (ctx->selfTurnData[ctx->battlerIdTarget].physicalDamage || ctx->selfTurnData[ctx->battlerIdTarget].specialDamage) && - (ctx->unk_334.moveData[ctx->moveNoCur].unkB & 1) && + (ctx->trainerAIData.moveData[ctx->moveNoCur].unkB & 1) && ((BattleSystem_Random(bsys) % 10) < 3)) { ctx->statChangeType = 3; ctx->battlerIdStatChange = ctx->battlerIdAttacker; @@ -3755,7 +3755,7 @@ BOOL CheckAbilityEffectOnHit(BattleSystem *bsys, BattleContext *ctx, int *script !(ctx->battleStatus & BATTLE_STATUS_CHARGE_TURN) && !(ctx->battleStatus2 & BATTLE_STATUS2_4) && (ctx->selfTurnData[ctx->battlerIdTarget].physicalDamage || ctx->selfTurnData[ctx->battlerIdTarget].specialDamage) && - (ctx->unk_334.moveData[ctx->moveNoCur].unkB & 1) && + (ctx->trainerAIData.moveData[ctx->moveNoCur].unkB & 1) && ctx->battleMons[ctx->battlerIdTarget].hp && ((BattleSystem_Random(bsys) % 10) < 3)) { ctx->statChangeType = 3; @@ -3772,7 +3772,7 @@ BOOL CheckAbilityEffectOnHit(BattleSystem *bsys, BattleContext *ctx, int *script !(ctx->battleStatus2 & BATTLE_STATUS2_4) && ctx->battleMons[ctx->battlerIdAttacker].hp && !(ctx->moveStatusFlag & MOVE_STATUS_FAIL) && - (ctx->unk_334.moveData[ctx->moveNoCur].unkB & 1)) { + (ctx->trainerAIData.moveData[ctx->moveNoCur].unkB & 1)) { ctx->hpCalc = DamageDivide(ctx->battleMons[ctx->battlerIdAttacker].maxHp * -1, 4); ctx->battlerIdTemp = ctx->battlerIdAttacker; *script = 193; @@ -4647,7 +4647,7 @@ BOOL CheckItemEffectOnHit(BattleSystem *bsys, BattleContext *ctx, int *script) { ctx->moveNoCur != MOVE_KNOCK_OFF && (ctx->selfTurnData[ctx->battlerIdTarget].physicalDamage || ctx->selfTurnData[ctx->battlerIdTarget].specialDamage) && !(ctx->battleStatus2 & BATTLE_STATUS2_4) && - (ctx->unk_334.moveData[ctx->moveNoCur].unkB & 1)) { + (ctx->trainerAIData.moveData[ctx->moveNoCur].unkB & 1)) { *script = 216; ret = TRUE; } @@ -5742,7 +5742,7 @@ int CalcMoveDamage(BattleSystem *bsys, BattleContext *ctx, u32 moveNo, u32 sideC battleType = BattleSystem_GetBattleType(bsys); if (power == 0) { - movePower = ctx->unk_334.moveData[moveNo].power; + movePower = ctx->trainerAIData.moveData[moveNo].power; } else { movePower = power; } @@ -5750,7 +5750,7 @@ int CalcMoveDamage(BattleSystem *bsys, BattleContext *ctx, u32 moveNo, u32 sideC if (calcAttacker.ability == ABILITY_NORMALIZE) { moveType = TYPE_NORMAL; } else if (type == 0) { - moveType = ctx->unk_334.moveData[moveNo].type; + moveType = ctx->trainerAIData.moveData[moveNo].type; } else { moveType = type & 0x3F; } @@ -5770,7 +5770,7 @@ int CalcMoveDamage(BattleSystem *bsys, BattleContext *ctx, u32 moveNo, u32 sideC movePower = movePower * 15 / 10; } - moveCategory = ctx->unk_334.moveData[moveNo].category; + moveCategory = ctx->trainerAIData.moveData[moveNo].category; if (calcAttacker.ability == ABILITY_HUGE_POWER || calcAttacker.ability == ABILITY_PURE_POWER) { monAtk *= 2; @@ -5975,7 +5975,7 @@ int CalcMoveDamage(BattleSystem *bsys, BattleContext *ctx, u32 moveNo, u32 sideC } } - if (ctx->unk_334.moveData[moveNo].effect == MOVE_EFFECT_HALVE_DEFENSE) { + if (ctx->trainerAIData.moveData[moveNo].effect == MOVE_EFFECT_HALVE_DEFENSE) { monDef /= 2; } @@ -6010,7 +6010,7 @@ int CalcMoveDamage(BattleSystem *bsys, BattleContext *ctx, u32 moveNo, u32 sideC dmg /= 2; } - if ((sideCondition & SIDE_CONDITION_REFLECT) && crit == 1 && ctx->unk_334.moveData[moveNo].effect != MOVE_EFFECT_REMOVE_SCREENS) { + if ((sideCondition & SIDE_CONDITION_REFLECT) && crit == 1 && ctx->trainerAIData.moveData[moveNo].effect != MOVE_EFFECT_REMOVE_SCREENS) { if ((battleType & BATTLE_TYPE_DOUBLES) && GetMonsHitCount(bsys, ctx, 1, battlerIdTarget) == 2) { dmg = dmg * 2 / 3; } else { @@ -6044,7 +6044,7 @@ int CalcMoveDamage(BattleSystem *bsys, BattleContext *ctx, u32 moveNo, u32 sideC dmg /= dmg2; dmg /= 50; - if ((sideCondition & SIDE_CONDITION_LIGHT_SCREEN) && crit == 1 && ctx->unk_334.moveData[moveNo].effect != MOVE_EFFECT_REMOVE_SCREENS) { + if ((sideCondition & SIDE_CONDITION_LIGHT_SCREEN) && crit == 1 && ctx->trainerAIData.moveData[moveNo].effect != MOVE_EFFECT_REMOVE_SCREENS) { if ((battleType & BATTLE_TYPE_DOUBLES) && GetMonsHitCount(bsys, ctx, 1, battlerIdTarget) == 2) { dmg = dmg * 2 / 3; } else { @@ -6053,10 +6053,10 @@ int CalcMoveDamage(BattleSystem *bsys, BattleContext *ctx, u32 moveNo, u32 sideC } } - if ((battleType & BATTLE_TYPE_DOUBLES) && ctx->unk_334.moveData[moveNo].range == RANGE_ADJACENT_OPPONENTS && GetMonsHitCount(bsys, ctx, 1, battlerIdTarget) == 2) { + if ((battleType & BATTLE_TYPE_DOUBLES) && ctx->trainerAIData.moveData[moveNo].range == RANGE_ADJACENT_OPPONENTS && GetMonsHitCount(bsys, ctx, 1, battlerIdTarget) == 2) { dmg = dmg * 3 / 4; } - if ((battleType & BATTLE_TYPE_DOUBLES) && ctx->unk_334.moveData[moveNo].range == RANGE_ALL_ADJACENT && GetMonsHitCount(bsys, ctx, 0, battlerIdTarget) >= 2) { + if ((battleType & BATTLE_TYPE_DOUBLES) && ctx->trainerAIData.moveData[moveNo].range == RANGE_ALL_ADJACENT && GetMonsHitCount(bsys, ctx, 0, battlerIdTarget) >= 2) { dmg = dmg * 3 / 4; } @@ -6222,7 +6222,7 @@ BOOL IsMoveEncored(BattleContext *ctx, u16 moveNo) { int i = 0; do { - if (ctx->unk_334.moveData[sEncoreFailMoves[i]].effect == ctx->unk_334.moveData[moveNo].effect) { + if (ctx->trainerAIData.moveData[sEncoreFailMoves[i]].effect == ctx->trainerAIData.moveData[moveNo].effect) { break; } i++; @@ -6244,7 +6244,7 @@ BOOL CheckLegalMeFirstMove(BattleContext *ctx, u16 moveNo) { int i = 0; do { - if (ctx->unk_334.moveData[sMeFirstUnuseableMoves[i]].effect == ctx->unk_334.moveData[moveNo].effect) { + if (ctx->trainerAIData.moveData[sMeFirstUnuseableMoves[i]].effect == ctx->trainerAIData.moveData[moveNo].effect) { break; } i++; @@ -6256,7 +6256,7 @@ BOOL CheckLegalMeFirstMove(BattleContext *ctx, u16 moveNo) { s32 GetItemVar(BattleContext *ctx, u16 itemNo, u16 var) { ItemData *itemData; u32 index = GetItemIndexMapping(itemNo, 0); - itemData = GetItemDataPtrFromArray(ctx->unk_334.itemData, index); + itemData = GetItemDataPtrFromArray(ctx->trainerAIData.itemData, index); return GetItemAttr_PreloadedItemData(itemData, var); } @@ -6345,7 +6345,7 @@ BOOL CheckItemEffectOnUTurn(BattleSystem *bsys, BattleContext *ctx, int *script) if (itemAttacker == HOLD_EFFECT_HP_DRAIN_ON_ATK && GetBattlerAbility(ctx, ctx->battlerIdAttacker) != ABILITY_MAGIC_GUARD && (ctx->battleStatus & BATTLE_STATUS_MOVE_SUCCESSFUL) && - ctx->unk_334.moveData[ctx->moveNoCur].category != CATEGORY_STATUS && + ctx->trainerAIData.moveData[ctx->moveNoCur].category != CATEGORY_STATUS && ctx->battleMons[ctx->battlerIdAttacker].hp) { ctx->hpCalc = DamageDivide(ctx->battleMons[ctx->battlerIdAttacker].maxHp * -1, 10); ctx->battlerIdTemp = ctx->battlerIdAttacker; @@ -6367,7 +6367,7 @@ BOOL CheckItemEffectOnUTurn(BattleSystem *bsys, BattleContext *ctx, int *script) !ctx->battleMons[ctx->battlerIdAttacker].item && !(ctx->fieldSideConditionData[side].battlerBitKnockedOffItem & MaskOfFlagNo(ctx->selectedMonIndex[ctx->battlerIdAttacker])) && (ctx->selfTurnData[ctx->battlerIdTarget].physicalDamage || ctx->selfTurnData[ctx->battlerIdTarget].specialDamage) && - (ctx->unk_334.moveData[ctx->moveNoCur].unkB & 1)) { + (ctx->trainerAIData.moveData[ctx->moveNoCur].unkB & 1)) { *script = 216; ret = TRUE; } @@ -6410,11 +6410,11 @@ int ov12_022581D4(BattleSystem *bsys, BattleContext *ctx, int var, int battlerId case 8: return ctx->unk_21A8[battlerId][0]; case 9: - return ctx->unk_334.unk9C; + return ctx->trainerAIData.unk9C; case 10: return ctx->unk_3108; case 11: - return ctx->unk_334.unkA4[battlerId]; + return ctx->trainerAIData.unkA4[battlerId]; case 12: return ctx->unk_21A8[battlerId][2]; case 13: @@ -6442,10 +6442,10 @@ void ov12_022582B8(BattleSystem *bsys, BattleContext *ctx, int var, int battlerI ctx->totalTurns = data; break; case 9: - ctx->unk_334.unk9C = data; + ctx->trainerAIData.unk9C = data; break; case 11: - ctx->unk_334.unkA4[battlerId] = data; + ctx->trainerAIData.unkA4[battlerId] = data; break; default: GF_ASSERT(FALSE); @@ -6653,7 +6653,7 @@ static int ov12_022583B4(BattleContext *ctx, int battlerId, int typeEffectivenes } static int ov12_02258440(BattleContext *ctx, int moveNo) { - switch (ctx->unk_334.moveData[moveNo].effect) { + switch (ctx->trainerAIData.moveData[moveNo].effect) { case MOVE_EFFECT_BIDE: case MOVE_EFFECT_CHARGE_TURN_HIGH_CRIT: case MOVE_EFFECT_CHARGE_TURN_HIGH_CRIT_FLINCH: @@ -6742,16 +6742,16 @@ static u8 Battler_GetType(BattleContext *ctx, int battlerId, int var) { static void ov12_02258584(BattleContext *ctx, u8 battlerId) { for (int i = 0; i < MAX_MON_MOVES; i++) { - ctx->unk_334.unk1C[battlerId][i] = 0; + ctx->trainerAIData.unk1C[battlerId][i] = 0; } } static void ov12_0225859C(BattleContext *ctx, u8 battlerId) { - ctx->unk_334.unk5C[battlerId] = 0; + ctx->trainerAIData.unk5C[battlerId] = 0; } static void ov12_022585A8(BattleContext *ctx, u8 battlerId) { - ctx->unk_334.unk60[battlerId] = 0; + ctx->trainerAIData.unk60[battlerId] = 0; } static int ov12_022585B8(BattleSystem *bsys, BattleContext *ctx, int battlerIdTarget1, int battlerIdTarget2) { @@ -6795,7 +6795,7 @@ static const u16 ov12_0226CB64[] = { static BOOL ov12_0225865C(BattleContext *ctx, int moveNo) { for (int i = 0; i < NELEMS(ov12_0226CB64); i++) { - if (ov12_0226CB64[i] == ctx->unk_334.moveData[moveNo].effect) { + if (ov12_0226CB64[i] == ctx->trainerAIData.moveData[moveNo].effect) { return TRUE; } } diff --git a/src/battle/trainer_ai.c b/src/battle/trainer_ai.c index ff410e21ed..49a9a8ac8d 100644 --- a/src/battle/trainer_ai.c +++ b/src/battle/trainer_ai.c @@ -6,7 +6,7 @@ void ov10_0221BE20(BattleSystem *bsys, BattleContext *ctx, u8 battlerId, u8 a3) { int i; u8 struggleFlags; - u8 *aiData = (u8 *) &ctx->unk_334; + u8 *aiData = (u8 *) &ctx->trainerAIData; for (i = 0; i < (u32) 28; i++) { aiData[i] = 0; @@ -14,9 +14,9 @@ void ov10_0221BE20(BattleSystem *bsys, BattleContext *ctx, u8 battlerId, u8 a3) for (i = 0; i < 4; i++) { if (a3 & 1) { - ctx->unk_334.unk4[i] = 100; + ctx->trainerAIData.movePoints[i] = 100; } else { - ctx->unk_334.unk4[i] = 0; + ctx->trainerAIData.movePoints[i] = 0; } a3 >>= 1; } @@ -25,20 +25,20 @@ void ov10_0221BE20(BattleSystem *bsys, BattleContext *ctx, u8 battlerId, u8 a3) for (i = 0; i < 4; i++) { if (struggleFlags & MaskOfFlagNo(i)) { - ctx->unk_334.unk4[i] = 0; + ctx->trainerAIData.movePoints[i] = 0; } - ctx->unk_334.unk18[i] = 100 - (BattleSystem_Random(bsys) % 16); + ctx->trainerAIData.unk18[i] = 100 - (BattleSystem_Random(bsys) % 16); } - ctx->unk_334.unk98 = 0; + ctx->trainerAIData.unk98 = 0; if (bsys->battleType & BATTLE_TYPE_8) { - ctx->unk_334.unkC = 1 << 0x1d; + ctx->trainerAIData.aiFlags = AI_29; } else { - ctx->unk_334.unkC = bsys->trainers[battlerId].data.aiFlags; + ctx->trainerAIData.aiFlags = bsys->trainers[battlerId].data.aiFlags; } if (bsys->battleType & BATTLE_TYPE_DOUBLES) { - ctx->unk_334.unkC |= 0x80; + ctx->trainerAIData.aiFlags |= AI_DOUBLES; } } From a1b964d44eb533e8eb4e0260ba9ebbb4086fccaa Mon Sep 17 00:00:00 2001 From: Adrienn Tindall <33725376+adrienntindall@users.noreply.github.com> Date: Tue, 28 Nov 2023 13:39:14 -0500 Subject: [PATCH 11/33] ov10_0221BEF4 --- asm/overlay_10.s | 42 -------------------------------- include/battle/battle.h | 4 +-- include/battle/trainer_ai.h | 5 ++++ src/battle/overlay_12_0224E4FC.c | 4 +-- src/battle/trainer_ai.c | 20 +++++++++++++++ 5 files changed, 29 insertions(+), 46 deletions(-) diff --git a/asm/overlay_10.s b/asm/overlay_10.s index ebce380cdb..8191a0f5ce 100644 --- a/asm/overlay_10.s +++ b/asm/overlay_10.s @@ -4,48 +4,6 @@ .text - thumb_func_start ov10_0221BEF4 -ov10_0221BEF4: ; 0x0221BEF4 - push {r4, r5, r6, lr} - add r5, r0, #0 - add r2, r1, #0 - mov r1, #0xd9 - ldr r4, [r5, #0x30] - lsl r1, r1, #2 - ldrb r6, [r4, r1] - mov r3, #0x10 - tst r3, r6 - bne _0221BF26 - add r1, #0x6b - strb r2, [r4, r1] - add r1, r4, #0 - bl ov12_02253DA0 - mov r2, #0x3d - lsl r2, r2, #4 - strb r0, [r4, r2] - sub r2, r2, #1 - ldrb r2, [r4, r2] - add r0, r5, #0 - add r1, r4, #0 - mov r3, #0xf - bl ov10_0221BE20 -_0221BF26: - ldr r1, [r5, #0x2c] - mov r0, #2 - tst r0, r1 - bne _0221BF38 - add r0, r5, #0 - add r1, r4, #0 - bl ov10_0221BF44 - pop {r4, r5, r6, pc} -_0221BF38: - add r0, r5, #0 - add r1, r4, #0 - bl ov10_0221C038 - pop {r4, r5, r6, pc} - .balign 4, 0 - thumb_func_end ov10_0221BEF4 - thumb_func_start ov10_0221BF44 ov10_0221BF44: ; 0x0221BF44 push {r4, r5, r6, r7, lr} diff --git a/include/battle/battle.h b/include/battle/battle.h index f19c6aeaed..84338a122b 100644 --- a/include/battle/battle.h +++ b/include/battle/battle.h @@ -128,8 +128,8 @@ typedef struct TrainerAIData { u32 unk78[8]; u8 unk98; u8 unk99[2]; - u8 unk9B; - u8 unk9C; + u8 battlerIdAttacker; + u8 battlerIdTarget; u8 unk9D[2]; u8 unk9F[2]; u16 unkA0[2]; diff --git a/include/battle/trainer_ai.h b/include/battle/trainer_ai.h index 9985f7eba5..7305b2eaf6 100644 --- a/include/battle/trainer_ai.h +++ b/include/battle/trainer_ai.h @@ -2,5 +2,10 @@ #define POKEHEARTGOLD_TRAINER_AI_H void ov10_0221BE20(BattleSystem *bsys, BattleContext *ctx, u8 battlerId, u8 a3); +u8 ov10_0221BEF4(BattleSystem *bsys, u8 battlerId); + +//the following functions are in reality static but need to be decompiled still or are used by non-decompiled functions +u8 ov10_0221BF44(BattleSystem *bsys, BattleContext *ctx); +u8 ov10_0221C038(BattleSystem *bsys, BattleContext *ctx); #endif diff --git a/src/battle/overlay_12_0224E4FC.c b/src/battle/overlay_12_0224E4FC.c index 3a23546602..43f58a20ce 100644 --- a/src/battle/overlay_12_0224E4FC.c +++ b/src/battle/overlay_12_0224E4FC.c @@ -6410,7 +6410,7 @@ int ov12_022581D4(BattleSystem *bsys, BattleContext *ctx, int var, int battlerId case 8: return ctx->unk_21A8[battlerId][0]; case 9: - return ctx->trainerAIData.unk9C; + return ctx->trainerAIData.battlerIdTarget; case 10: return ctx->unk_3108; case 11: @@ -6442,7 +6442,7 @@ void ov12_022582B8(BattleSystem *bsys, BattleContext *ctx, int var, int battlerI ctx->totalTurns = data; break; case 9: - ctx->trainerAIData.unk9C = data; + ctx->trainerAIData.battlerIdTarget = data; break; case 11: ctx->trainerAIData.unkA4[battlerId] = data; diff --git a/src/battle/trainer_ai.c b/src/battle/trainer_ai.c index 49a9a8ac8d..79639fb6d8 100644 --- a/src/battle/trainer_ai.c +++ b/src/battle/trainer_ai.c @@ -42,3 +42,23 @@ void ov10_0221BE20(BattleSystem *bsys, BattleContext *ctx, u8 battlerId, u8 a3) ctx->trainerAIData.aiFlags |= AI_DOUBLES; } } + +u8 ov10_0221BEF4(BattleSystem *bsys, u8 battlerId) { + u8 ret; + BattleContext *ctx = bsys->ctx; + + if (!(ctx->trainerAIData.unk10 & 0x10)) { + ctx->trainerAIData.battlerIdAttacker = battlerId; + ctx->trainerAIData.battlerIdTarget = ov12_02253DA0(bsys, ctx, battlerId); + + ov10_0221BE20(bsys, ctx, ctx->trainerAIData.battlerIdAttacker, 15); + } + + if ((bsys->battleType & BATTLE_TYPE_DOUBLES) == 0) { + ret = ov10_0221BF44(bsys, ctx); + } else { + ret = ov10_0221C038(bsys, ctx); + } + + return ret; +} From 1dbd590a9f2528b8d7d207656b2f92d918f38b29 Mon Sep 17 00:00:00 2001 From: Adrienn Tindall <33725376+adrienntindall@users.noreply.github.com> Date: Tue, 28 Nov 2023 13:48:02 -0500 Subject: [PATCH 12/33] rename overlay_10.s since I'm not gonna be finishing it this pr and want to keep track for later --- asm/{overlay_10.s => overlay_10_trainer_ai.s} | 0 main.lsf | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename asm/{overlay_10.s => overlay_10_trainer_ai.s} (100%) diff --git a/asm/overlay_10.s b/asm/overlay_10_trainer_ai.s similarity index 100% rename from asm/overlay_10.s rename to asm/overlay_10_trainer_ai.s diff --git a/main.lsf b/main.lsf index a2fae6416a..63aa888b08 100644 --- a/main.lsf +++ b/main.lsf @@ -558,7 +558,7 @@ Overlay OVY_10 { After OVY_6 Object src/battle/trainer_ai.o - Object asm/overlay_10.o + Object asm/overlay_10_trainer_ai.o } Overlay OVY_11 { From cb7a13e39e10f45b1c60a6b191d91a2c69444323 Mon Sep 17 00:00:00 2001 From: Adrienn Tindall <33725376+adrienntindall@users.noreply.github.com> Date: Wed, 29 Nov 2023 22:54:56 -0600 Subject: [PATCH 13/33] Update src/battle/battle_02261FD4.c Co-authored-by: Thomas --- src/battle/battle_02261FD4.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/battle/battle_02261FD4.c b/src/battle/battle_02261FD4.c index 6564935002..d6214dc4b3 100644 --- a/src/battle/battle_02261FD4.c +++ b/src/battle/battle_02261FD4.c @@ -28,8 +28,7 @@ static void ov12_0226203C(SysTask *task, void *_data) { data->unk19C += 20; - if (data->unk19C >= 360) - { + if (data->unk19C >= 360) { data->unk19C -= 360; } From dc16cd7a48b4a81b5fe6559670a243d592b57e19 Mon Sep 17 00:00:00 2001 From: Adrienn Tindall <33725376+adrienntindall@users.noreply.github.com> Date: Wed, 29 Nov 2023 22:55:03 -0600 Subject: [PATCH 14/33] Update src/battle/battle_02261FD4.c Co-authored-by: Thomas --- src/battle/battle_02261FD4.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/battle/battle_02261FD4.c b/src/battle/battle_02261FD4.c index d6214dc4b3..2864e48dc7 100644 --- a/src/battle/battle_02261FD4.c +++ b/src/battle/battle_02261FD4.c @@ -14,8 +14,7 @@ void ov12_02261FD4(OpponentData *data, BattleSystem *bsys) { } void ov12_02262014(OpponentData *data) { - if (data->unk198 != NULL) - { + if (data->unk198 != NULL) { DestroySysTask(data->unk198); data->unk198 = NULL; data->unk19C = 0; From 526fb13e94f8f27aa1b833cbc4aef68957da85ad Mon Sep 17 00:00:00 2001 From: Adrienn Tindall <33725376+adrienntindall@users.noreply.github.com> Date: Wed, 29 Nov 2023 22:55:23 -0600 Subject: [PATCH 15/33] Update src/battle/battle_02261FD4.c Co-authored-by: Thomas --- src/battle/battle_02261FD4.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/battle/battle_02261FD4.c b/src/battle/battle_02261FD4.c index 2864e48dc7..38e213060b 100644 --- a/src/battle/battle_02261FD4.c +++ b/src/battle/battle_02261FD4.c @@ -6,8 +6,7 @@ static void ov12_0226203C(SysTask *task, void *_data); void ov12_02261FD4(OpponentData *data, BattleSystem *bsys) { - if (data->unk198 == NULL && !(BattleSystem_GetBattleType(bsys) & (BATTLE_TYPE_SAFARI | BATTLE_TYPE_PAL_PARK))) - { + if (data->unk198 == NULL && !(BattleSystem_GetBattleType(bsys) & (BATTLE_TYPE_SAFARI | BATTLE_TYPE_PAL_PARK))) { data->unk19C = 180; data->unk198 = CreateSysTask(ov12_0226203C, data, 0x3F2); } From 3f1b5c6857bd38012535f35700c56027d1e8840d Mon Sep 17 00:00:00 2001 From: Adrienn Tindall <33725376+adrienntindall@users.noreply.github.com> Date: Sat, 16 Dec 2023 18:30:46 -0500 Subject: [PATCH 16/33] Add consts, etc --- asm/overlay_12_battle_system.s | 53 ---------------------------------- include/battle/battle_system.h | 2 +- src/battle/battle_command.c | 18 +++++------- src/battle/battle_system.c | 14 +++++++++ src/battle/trainer_ai.c | 4 +-- 5 files changed, 24 insertions(+), 67 deletions(-) diff --git a/asm/overlay_12_battle_system.s b/asm/overlay_12_battle_system.s index 2a360bda35..e85d803ff8 100644 --- a/asm/overlay_12_battle_system.s +++ b/asm/overlay_12_battle_system.s @@ -6,59 +6,6 @@ .text - thumb_func_start PokedexSetBattlerSeen -PokedexSetBattlerSeen: ; 0x0223C288 - push {r4, r5, r6, lr} - add r6, r1, #0 - add r5, r0, #0 - lsl r0, r6, #2 - add r0, r5, r0 - ldr r0, [r0, #0x34] - bl ov12_02261258 - add r4, r0, #0 - ldr r1, [r5, #0x30] - add r0, r5, #0 - mov r2, #2 - add r3, r6, #0 - bl ov12_022581D4 - add r2, r0, #0 - add r0, r5, #0 - add r1, r6, #0 - bl BattleSystem_GetPartyMon - add r6, r0, #0 - ldr r0, [r5, #0x2c] - mov r1, #0x84 - tst r1, r0 - bne _0223C2CE - mov r1, #1 - tst r1, r4 - bne _0223C2C6 - sub r0, #0x4a - cmp r0, #1 - bhi _0223C2CE -_0223C2C6: - ldr r0, [r5, #0x60] - add r1, r6, #0 - bl Pokedex_SetMonSeenFlag -_0223C2CE: - mov r0, #1 - tst r0, r4 - bne _0223C2EE - add r0, r6, #0 - mov r1, #0xae - mov r2, #0 - bl GetMonData - mov r1, #0x67 - lsl r1, r1, #2 - cmp r0, r1 - bne _0223C2EE - ldr r0, [r5, #0x60] - add r1, r6, #0 - bl Pokedex_SetMonCaughtFlag -_0223C2EE: - pop {r4, r5, r6, pc} - thumb_func_end PokedexSetBattlerSeen - thumb_func_start ov12_0223C2F0 ov12_0223C2F0: ; 0x0223C2F0 push {r3, r4, r5, lr} diff --git a/include/battle/battle_system.h b/include/battle/battle_system.h index 11e58ca623..c303f5bbcb 100644 --- a/include/battle/battle_system.h +++ b/include/battle/battle_system.h @@ -138,9 +138,9 @@ void ov12_0223C1C4(BattleSystem *bsys, u8 *buffer); void ov12_0223C1F4(BattleSystem *bsys, void **a1); void ov12_0223C224(BattleSystem *bsys, int a1); u32 CalcMoneyLoss(Party *party, PlayerProfile *profile); +void PokedexSetBattlerSeen(BattleSystem *bsys, int battlerId); //These functions haven't been decompiled -void PokedexSetBattlerSeen(BattleSystem *bsys, int battlerId); BOOL Link_QueueNotEmpty(BattleContext *ctx); void ov12_02237ED0(BattleSystem *bsys, int a1); void ov12_022642F0(BattleSystem *bsys); diff --git a/src/battle/battle_command.c b/src/battle/battle_command.c index 124164a007..6264a8bbf7 100644 --- a/src/battle/battle_command.c +++ b/src/battle/battle_command.c @@ -1579,7 +1579,7 @@ BOOL BtlCmd_BufferStatChangeMsg(BattleSystem *bsys, BattleContext *ctx) { ctx->buffMsg.param[1] = ctx->itemTemp; ctx->buffMsg.param[2] = stat + 1; } else { - ctx->buffMsg.id = (change == 1) ? msg_0197_00750:msg_0197_00753; //{0}'s {1} (sharply) rose! + ctx->buffMsg.id = (change == 1) ? msg_0197_00750 : msg_0197_00753; //{0}'s {1} (sharply) rose! ctx->buffMsg.tag = 12; ctx->buffMsg.param[0] = CreateNicknameTag(ctx, ctx->battlerIdStatChange); ctx->buffMsg.param[1] = stat + 1; @@ -2306,7 +2306,7 @@ BOOL BtlCmd_TryConversion(BattleSystem *bsys, BattleContext *ctx) { return FALSE; } - for (cnt = 0; cnt < 4; cnt++) { + for (cnt = 0; cnt < MAX_MON_MOVES; cnt++) { if (ctx->battleMons[ctx->battlerIdAttacker].moves[cnt] == 0) { break; } @@ -2696,13 +2696,13 @@ BOOL BtlCmd_Metronome(BattleSystem *bsys, BattleContext *ctx) { while (TRUE) { moveNo = (BattleSystem_Random(bsys) % 0x1d3) + 1; - for (metronomeIndex = 0; metronomeIndex < 4; metronomeIndex++) { + for (metronomeIndex = 0; metronomeIndex < MAX_MON_MOVES; metronomeIndex++) { if (ctx->battleMons[ctx->battlerIdAttacker].moves[metronomeIndex] == moveNo) { break; } } - if (metronomeIndex != 4) { + if (metronomeIndex != MAX_MON_MOVES) { continue; } @@ -6142,10 +6142,7 @@ static void Task_GetExp(SysTask *task, void *inData) CalcMonStats(mon); if (data->ctx->selectedMonIndex[expBattler] == slot) { - BattleSystem_ReloadMonData(data->bsys, - data->ctx, - expBattler, - data->ctx->selectedMonIndex[expBattler]); + BattleSystem_ReloadMonData(data->bsys, data->ctx, expBattler, data->ctx->selectedMonIndex[expBattler]); } data->ctx->levelUpMons |= MaskOfFlagNo(slot); @@ -6197,7 +6194,6 @@ static void Task_GetExp(SysTask *task, void *inData) break; } case STATE_GET_EXP_LEVEL_UP_SUMMARY_PRINT_DIFF: { - TempStatsStruct stats = ov12_0226C36C; TempStatsStruct monData = ov12_0226C384; @@ -6328,7 +6324,7 @@ static void Task_GetExp(SysTask *task, void *inData) case STATE_GET_EXP_MAKE_IT_FORGET_PROMPT: // "Make it forget another move?" - BattleController_EmitDrawYesNoBox(data->bsys, data->ctx, expBattler, 1180, 1, 0, 0); + BattleController_EmitDrawYesNoBox(data->bsys, data->ctx, expBattler, msg_0197_01180, 1, 0, 0); data->state++; break; @@ -6370,7 +6366,7 @@ static void Task_GetExp(SysTask *task, void *inData) case STATE_GET_EXP_GIVE_UP_LEARNING_PROMPT: // "Should this Pokémon give up on learning this new move?" - BattleController_EmitDrawYesNoBox(data->bsys, data->ctx, expBattler, 1185, 2, data->unk30[4], 0); + BattleController_EmitDrawYesNoBox(data->bsys, data->ctx, expBattler, msg_0197_01185, 2, data->unk30[4], 0); data->state++; break; diff --git a/src/battle/battle_system.c b/src/battle/battle_system.c index ec9ab69164..fc906f4c58 100644 --- a/src/battle/battle_system.c +++ b/src/battle/battle_system.c @@ -1303,3 +1303,17 @@ u32 CalcMoneyLoss(Party *party, PlayerProfile *profile) { return loss; } + +void PokedexSetBattlerSeen(BattleSystem *bsys, int battlerId) { + u32 flag = ov12_02261258(bsys->opponentData[battlerId]); + Pokemon *mon = BattleSystem_GetPartyMon(bsys, battlerId, ov12_022581D4(bsys, bsys->ctx, 2, battlerId)); + + if (!(bsys->battleType & (BATTLE_TYPE_LINK | BATTLE_TYPE_TOWER))) { + if ((flag & 1) || bsys->battleType == (BATTLE_TYPE_6 | BATTLE_TYPE_DOUBLES | BATTLE_TYPE_MULTI) || bsys->battleType == (BATTLE_TYPE_TRAINER | BATTLE_TYPE_6 | BATTLE_TYPE_DOUBLES | BATTLE_TYPE_MULTI)) { + Pokedex_SetMonSeenFlag(bsys->pokedex, mon); + } + } + if (!(flag & 1) && GetMonData(mon, MON_DATA_SPECIES_OR_EGG, NULL) == SPECIES_BURMY) { + Pokedex_SetMonCaughtFlag(bsys->pokedex, mon); + } +} diff --git a/src/battle/trainer_ai.c b/src/battle/trainer_ai.c index 79639fb6d8..306d59fffe 100644 --- a/src/battle/trainer_ai.c +++ b/src/battle/trainer_ai.c @@ -12,7 +12,7 @@ void ov10_0221BE20(BattleSystem *bsys, BattleContext *ctx, u8 battlerId, u8 a3) aiData[i] = 0; } - for (i = 0; i < 4; i++) { + for (i = 0; i < MAX_MON_MOVES; i++) { if (a3 & 1) { ctx->trainerAIData.movePoints[i] = 100; } else { @@ -23,7 +23,7 @@ void ov10_0221BE20(BattleSystem *bsys, BattleContext *ctx, u8 battlerId, u8 a3) struggleFlags = StruggleCheck(bsys, ctx, battlerId, 0, -1); - for (i = 0; i < 4; i++) { + for (i = 0; i < MAX_MON_MOVES; i++) { if (struggleFlags & MaskOfFlagNo(i)) { ctx->trainerAIData.movePoints[i] = 0; } From 78a89dc673cb176acf4d5cd937247bf4a2c497fd Mon Sep 17 00:00:00 2001 From: Adrienn Tindall <33725376+adrienntindall@users.noreply.github.com> Date: Sat, 16 Dec 2023 20:11:53 -0500 Subject: [PATCH 17/33] More bsys functions --- asm/include/overlay_12_battle_command.inc | 4 +- asm/include/overlay_12_battle_controller.inc | 2 +- asm/include/overlay_12_battle_system.inc | 6 +-- asm/overlay_12_battle_command.s | 8 ++-- asm/overlay_12_battle_controller.s | 4 +- asm/overlay_12_battle_system.s | 44 -------------------- include/battle/battle_system.h | 4 +- src/battle/battle_command.c | 28 ++++++------- src/battle/battle_system.c | 16 ++++++- 9 files changed, 44 insertions(+), 72 deletions(-) diff --git a/asm/include/overlay_12_battle_command.inc b/asm/include/overlay_12_battle_command.inc index 3d1aa3ca43..dd890c10e7 100644 --- a/asm/include/overlay_12_battle_command.inc +++ b/asm/include/overlay_12_battle_command.inc @@ -152,8 +152,8 @@ .public BattleSystem_Random .public ov12_0223C134 .public ov12_0223C224 -.public ov12_0223C2F0 -.public ov12_0223C330 +.public BattleSystem_SetPokedexCaught +.public BattleSystem_CheckMonCaught .public ov12_0223C494 .public ov12_0223C4E8 .public BtlCmd_PlayEncounterAnimation diff --git a/asm/include/overlay_12_battle_controller.inc b/asm/include/overlay_12_battle_controller.inc index d19ebe1b8b..0840db79d7 100644 --- a/asm/include/overlay_12_battle_controller.inc +++ b/asm/include/overlay_12_battle_controller.inc @@ -43,7 +43,7 @@ .public BattleSystem_GetRandTemp .public ov12_0223BE68 .public ov12_0223C140 -.public ov12_0223C330 +.public BattleSystem_CheckMonCaught .public ov12_0224ECC4 .public ov12_0224ED00 .public ov12_0224EDC0 diff --git a/asm/include/overlay_12_battle_system.inc b/asm/include/overlay_12_battle_system.inc index 4e8a927aa9..f1fd77c544 100644 --- a/asm/include/overlay_12_battle_system.inc +++ b/asm/include/overlay_12_battle_system.inc @@ -197,9 +197,9 @@ .public ov12_0223C1F4 .public ov12_0223C224 .public CalcMoneyLoss -.public PokedexSetBattlerSeen -.public ov12_0223C2F0 -.public ov12_0223C330 +.public BattleSystem_SetPokedexSeen +.public BattleSystem_SetPokedexCaught +.public BattleSystem_CheckMonCaught .public ov12_0223C340 .public ov12_0223C34C .public ov12_0223C494 diff --git a/asm/overlay_12_battle_command.s b/asm/overlay_12_battle_command.s index c1ab8a8e22..319bfd8a9a 100644 --- a/asm/overlay_12_battle_command.s +++ b/asm/overlay_12_battle_command.s @@ -683,7 +683,7 @@ _02246950: bl GetMonData add r1, r0, #0 ldr r0, [r4] - bl ov12_0223C330 + bl BattleSystem_CheckMonCaught cmp r0, #0 beq _022469E6 ldr r0, [r4] @@ -1282,7 +1282,7 @@ _02246E84: add r6, r0, #0 ldr r0, [r4] add r1, r7, #0 - bl ov12_0223C2F0 + bl BattleSystem_SetPokedexCaught ldr r0, [r4] ldr r1, [r4, #4] add r2, r6, #0 @@ -1398,7 +1398,7 @@ _02246F7E: beq _02246FB4 ldr r0, [r4] add r1, r7, #0 - bl ov12_0223C2F0 + bl BattleSystem_SetPokedexCaught _02246FB4: add r0, r6, #0 bl Mon_GetBoxMon @@ -1908,7 +1908,7 @@ _022473AA: lsl r1, r1, #6 ldrh r1, [r2, r1] add r0, r7, #0 - bl ov12_0223C330 + bl BattleSystem_CheckMonCaught cmp r0, #1 bne _022473FA mov r0, #0x1e diff --git a/asm/overlay_12_battle_controller.s b/asm/overlay_12_battle_controller.s index d593640290..e58d645c18 100644 --- a/asm/overlay_12_battle_controller.s +++ b/asm/overlay_12_battle_controller.s @@ -1371,7 +1371,7 @@ _02262AE2: str r0, [sp, #0x20] ldrh r1, [r7, r6] ldr r0, [sp, #4] - bl ov12_0223C330 + bl BattleSystem_CheckMonCaught add r3, sp, #0x14 lsl r0, r0, #0x18 lsr r0, r0, #0x18 @@ -3468,7 +3468,7 @@ _02263AD0: str r0, [sp, #0x1c] ldrh r1, [r7, r6] ldr r0, [sp, #4] - bl ov12_0223C330 + bl BattleSystem_CheckMonCaught add r3, sp, #0x10 lsl r0, r0, #0x18 lsr r0, r0, #0x18 diff --git a/asm/overlay_12_battle_system.s b/asm/overlay_12_battle_system.s index e85d803ff8..c5dc901c9f 100644 --- a/asm/overlay_12_battle_system.s +++ b/asm/overlay_12_battle_system.s @@ -6,50 +6,6 @@ .text - thumb_func_start ov12_0223C2F0 -ov12_0223C2F0: ; 0x0223C2F0 - push {r3, r4, r5, lr} - add r4, r1, #0 - add r5, r0, #0 - lsl r0, r4, #2 - add r0, r5, r0 - ldr r0, [r0, #0x34] - bl ov12_02261258 - ldr r2, [r5, #0x2c] - mov r1, #0x84 - tst r1, r2 - bne _0223C32C - mov r1, #1 - tst r0, r1 - beq _0223C32C - ldr r1, [r5, #0x30] - add r0, r5, #0 - mov r2, #2 - add r3, r4, #0 - bl ov12_022581D4 - add r2, r0, #0 - add r0, r5, #0 - add r1, r4, #0 - bl BattleSystem_GetPartyMon - add r1, r0, #0 - ldr r0, [r5, #0x60] - bl Pokedex_SetMonCaughtFlag -_0223C32C: - pop {r3, r4, r5, pc} - .balign 4, 0 - thumb_func_end ov12_0223C2F0 - - thumb_func_start ov12_0223C330 -ov12_0223C330: ; 0x0223C330 - ldr r3, _0223C33C ; =Pokedex_CheckMonCaughtFlag - lsl r1, r1, #0x10 - ldr r0, [r0, #0x60] - lsr r1, r1, #0x10 - bx r3 - nop -_0223C33C: .word Pokedex_CheckMonCaughtFlag - thumb_func_end ov12_0223C330 - thumb_func_start ov12_0223C340 ov12_0223C340: ; 0x0223C340 ldr r0, _0223C348 ; =0x04000050 diff --git a/include/battle/battle_system.h b/include/battle/battle_system.h index c303f5bbcb..eacdb5c580 100644 --- a/include/battle/battle_system.h +++ b/include/battle/battle_system.h @@ -138,7 +138,9 @@ void ov12_0223C1C4(BattleSystem *bsys, u8 *buffer); void ov12_0223C1F4(BattleSystem *bsys, void **a1); void ov12_0223C224(BattleSystem *bsys, int a1); u32 CalcMoneyLoss(Party *party, PlayerProfile *profile); -void PokedexSetBattlerSeen(BattleSystem *bsys, int battlerId); +void BattleSystem_SetPokedexSeen(BattleSystem *bsys, int battlerId); +void BattleSystem_SetPokedexCaught(BattleSystem *bsys, int battlerId); +BOOL BattleSystem_CheckMonCaught(BattleSystem *bsys, int battlerId); //These functions haven't been decompiled BOOL Link_QueueNotEmpty(BattleContext *ctx); diff --git a/src/battle/battle_command.c b/src/battle/battle_command.c index 6264a8bbf7..fb0dd0a6df 100644 --- a/src/battle/battle_command.c +++ b/src/battle/battle_command.c @@ -64,7 +64,7 @@ BOOL BtlCmd_PokemonEncounter(BattleSystem *bsys, BattleContext *ctx) { case B_SIDE_ALL: for (battlerId = 0; battlerId < battlersMax; battlerId++) { BattleController_EmitPokemonEncounter(bsys, battlerId); - PokedexSetBattlerSeen(bsys, battlerId); + BattleSystem_SetPokedexSeen(bsys, battlerId); } break; case B_SIDE_PLAYER: @@ -75,7 +75,7 @@ BOOL BtlCmd_PokemonEncounter(BattleSystem *bsys, BattleContext *ctx) { opponentData = BattleSystem_GetOpponentData(bsys, battlerId); if (opponentData->unk195 & 1) { BattleController_EmitPokemonEncounter(bsys, battlerId); - PokedexSetBattlerSeen(bsys, battlerId); + BattleSystem_SetPokedexSeen(bsys, battlerId); } } break; @@ -96,7 +96,7 @@ BOOL BtlCmd_PokemonSlideIn(BattleSystem *bsys, BattleContext *ctx) { default: for (battlerId = 0; battlerId < battlersMax; battlerId++) { BattleController_EmitPokemonSlideIn(bsys, battlerId); - PokedexSetBattlerSeen(bsys, battlerId); + BattleSystem_SetPokedexSeen(bsys, battlerId); } break; case B_SIDE_PLAYER: @@ -104,7 +104,7 @@ BOOL BtlCmd_PokemonSlideIn(BattleSystem *bsys, BattleContext *ctx) { opponentData = BattleSystem_GetOpponentData(bsys, battlerId); if (!(opponentData->unk195 & 1)) { BattleController_EmitPokemonSlideIn(bsys, battlerId); - PokedexSetBattlerSeen(bsys, battlerId); + BattleSystem_SetPokedexSeen(bsys, battlerId); } } BattleSystem_SetExperienceEarnFlags(bsys, ctx, BATTLER_ENEMY); @@ -117,7 +117,7 @@ BOOL BtlCmd_PokemonSlideIn(BattleSystem *bsys, BattleContext *ctx) { BattleSystem_ClearExperienceEarnFlags(ctx, battlerId); BattleSystem_SetExperienceEarnFlags(bsys, ctx, battlerId); BattleController_EmitPokemonSlideIn(bsys, battlerId); - PokedexSetBattlerSeen(bsys, battlerId); + BattleSystem_SetPokedexSeen(bsys, battlerId); } } break; @@ -130,7 +130,7 @@ BOOL BtlCmd_PokemonSlideIn(BattleSystem *bsys, BattleContext *ctx) { BattleSystem_ClearExperienceEarnFlags(ctx, ctx->battlerIdAttacker); BattleSystem_SetExperienceEarnFlags(bsys, ctx, ctx->battlerIdAttacker); } - PokedexSetBattlerSeen(bsys, ctx->battlerIdAttacker); + BattleSystem_SetPokedexSeen(bsys, ctx->battlerIdAttacker); BattleController_EmitPokemonSlideIn(bsys, ctx->battlerIdAttacker); break; case B_SIDE_2: @@ -142,7 +142,7 @@ BOOL BtlCmd_PokemonSlideIn(BattleSystem *bsys, BattleContext *ctx) { BattleSystem_ClearExperienceEarnFlags(ctx, ctx->battlerIdTarget); BattleSystem_SetExperienceEarnFlags(bsys, ctx, ctx->battlerIdTarget); } - PokedexSetBattlerSeen(bsys, ctx->battlerIdTarget); + BattleSystem_SetPokedexSeen(bsys, ctx->battlerIdTarget); BattleController_EmitPokemonSlideIn(bsys, ctx->battlerIdTarget); break; case B_SIDE_6: @@ -154,7 +154,7 @@ BOOL BtlCmd_PokemonSlideIn(BattleSystem *bsys, BattleContext *ctx) { BattleSystem_ClearExperienceEarnFlags(ctx, ctx->battlerIdSwitch); BattleSystem_SetExperienceEarnFlags(bsys, ctx, ctx->battlerIdSwitch); } - PokedexSetBattlerSeen(bsys, ctx->battlerIdSwitch); + BattleSystem_SetPokedexSeen(bsys, ctx->battlerIdSwitch); BattleController_EmitPokemonSlideIn(bsys, ctx->battlerIdSwitch); break; } @@ -174,7 +174,7 @@ BOOL BtlCmd_PokemonSendOut(BattleSystem *bsys, BattleContext *ctx) { default: for (battlerId = 0; battlerId < battlersMax; battlerId++) { BattleController_EmitPokemonSendOut(bsys, battlerId, 0, 0); - PokedexSetBattlerSeen(bsys, battlerId); + BattleSystem_SetPokedexSeen(bsys, battlerId); } break; case 3: @@ -182,7 +182,7 @@ BOOL BtlCmd_PokemonSendOut(BattleSystem *bsys, BattleContext *ctx) { opponentData = BattleSystem_GetOpponentData(bsys, battlerId); if (!(opponentData->unk195 & 1)) { BattleController_EmitPokemonSendOut(bsys, battlerId, 0, 0); - PokedexSetBattlerSeen(bsys, battlerId); + BattleSystem_SetPokedexSeen(bsys, battlerId); } } BattleSystem_SetExperienceEarnFlags(bsys, ctx, BATTLER_ENEMY); @@ -195,7 +195,7 @@ BOOL BtlCmd_PokemonSendOut(BattleSystem *bsys, BattleContext *ctx) { BattleSystem_ClearExperienceEarnFlags(ctx, battlerId); BattleSystem_SetExperienceEarnFlags(bsys, ctx, battlerId); BattleController_EmitPokemonSendOut(bsys, battlerId, 0, 0); - PokedexSetBattlerSeen(bsys, battlerId); + BattleSystem_SetPokedexSeen(bsys, battlerId); } } break; @@ -208,7 +208,7 @@ BOOL BtlCmd_PokemonSendOut(BattleSystem *bsys, BattleContext *ctx) { BattleSystem_ClearExperienceEarnFlags(ctx, ctx->battlerIdAttacker); BattleSystem_SetExperienceEarnFlags(bsys, ctx, ctx->battlerIdAttacker); } - PokedexSetBattlerSeen(bsys, ctx->battlerIdAttacker); + BattleSystem_SetPokedexSeen(bsys, ctx->battlerIdAttacker); BattleController_EmitPokemonSendOut(bsys, ctx->battlerIdAttacker, 0, 0); break; case 2: @@ -220,7 +220,7 @@ BOOL BtlCmd_PokemonSendOut(BattleSystem *bsys, BattleContext *ctx) { BattleSystem_ClearExperienceEarnFlags(ctx, ctx->battlerIdTarget); BattleSystem_SetExperienceEarnFlags(bsys, ctx, ctx->battlerIdTarget); } - PokedexSetBattlerSeen(bsys, ctx->battlerIdTarget); + BattleSystem_SetPokedexSeen(bsys, ctx->battlerIdTarget); BattleController_EmitPokemonSendOut(bsys, ctx->battlerIdTarget, 0, 0); break; case 6: @@ -232,7 +232,7 @@ BOOL BtlCmd_PokemonSendOut(BattleSystem *bsys, BattleContext *ctx) { BattleSystem_ClearExperienceEarnFlags(ctx, ctx->battlerIdSwitch); BattleSystem_SetExperienceEarnFlags(bsys, ctx, ctx->battlerIdSwitch); } - PokedexSetBattlerSeen(bsys, ctx->battlerIdSwitch); + BattleSystem_SetPokedexSeen(bsys, ctx->battlerIdSwitch); BattleController_EmitPokemonSendOut(bsys, ctx->battlerIdSwitch, 0, 0); break; } diff --git a/src/battle/battle_system.c b/src/battle/battle_system.c index fc906f4c58..82c2773217 100644 --- a/src/battle/battle_system.c +++ b/src/battle/battle_system.c @@ -1304,7 +1304,7 @@ u32 CalcMoneyLoss(Party *party, PlayerProfile *profile) { return loss; } -void PokedexSetBattlerSeen(BattleSystem *bsys, int battlerId) { +void BattleSystem_SetPokedexSeen(BattleSystem *bsys, int battlerId) { u32 flag = ov12_02261258(bsys->opponentData[battlerId]); Pokemon *mon = BattleSystem_GetPartyMon(bsys, battlerId, ov12_022581D4(bsys, bsys->ctx, 2, battlerId)); @@ -1317,3 +1317,17 @@ void PokedexSetBattlerSeen(BattleSystem *bsys, int battlerId) { Pokedex_SetMonCaughtFlag(bsys->pokedex, mon); } } + +void BattleSystem_SetPokedexCaught(BattleSystem *bsys, int battlerId) { + u32 flag = ov12_02261258(bsys->opponentData[battlerId]); + + if (!(bsys->battleType & (BATTLE_TYPE_LINK | BATTLE_TYPE_TOWER)) && (flag & 1)) { + int selectedMonIndex = ov12_022581D4(bsys, bsys->ctx, 2, battlerId); + Pokemon *mon = BattleSystem_GetPartyMon(bsys, battlerId, selectedMonIndex); + Pokedex_SetMonCaughtFlag(bsys->pokedex, mon); + } +} + +BOOL BattleSystem_CheckMonCaught(BattleSystem *bsys, int battlerId) { + return Pokedex_CheckMonCaughtFlag(bsys->pokedex, battlerId); +} From 24a06bb1bbd8715b3d2b8d0fea053b3b12ad8a92 Mon Sep 17 00:00:00 2001 From: Adrienn Tindall <33725376+adrienntindall@users.noreply.github.com> Date: Sun, 17 Dec 2023 16:29:53 -0600 Subject: [PATCH 18/33] Update src/battle/battle_02261FD4.c Co-authored-by: PikalaxALT --- src/battle/battle_02261FD4.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/battle/battle_02261FD4.c b/src/battle/battle_02261FD4.c index 38e213060b..03bbe4ae80 100644 --- a/src/battle/battle_02261FD4.c +++ b/src/battle/battle_02261FD4.c @@ -30,7 +30,7 @@ static void ov12_0226203C(SysTask *task, void *_data) { data->unk19C -= 360; } - int dy = FX_Mul(GF_SinDegNoWrap(data->unk19C), 0x1800) / FX32_ONE; + int dy = FX_Mul(GF_SinDegNoWrap(data->unk19C), FX32_CONST(1.5)) / FX32_ONE; sub_020087A4(data->unk20, 4, dy); } From c2d87dcde87cc02b8d13ab9bce890da7da0e0470 Mon Sep 17 00:00:00 2001 From: Adrienn Tindall <33725376+adrienntindall@users.noreply.github.com> Date: Sun, 17 Dec 2023 17:37:11 -0500 Subject: [PATCH 19/33] Decomp battle print message functions --- asm/include/overlay_07.inc | 2 +- asm/include/overlay_12_02264824.inc | 2 +- asm/include/overlay_12_02266024.inc | 2 +- asm/include/overlay_12_0226ADE0.inc | 2 +- asm/include/overlay_12_battle_command.inc | 4 +- .../overlay_12_battle_controller_opponent.inc | 6 +- asm/include/overlay_12_battle_system.inc | 8 +- asm/overlay_07.s | 4 +- asm/overlay_12_02266024.s | 22 +- asm/overlay_12_0226ADE0.s | 2 +- asm/overlay_12_battle_command.s | 16 +- asm/overlay_12_battle_controller_opponent.s | 76 +++---- asm/overlay_12_battle_system.s | 209 ------------------ asm/overlay_12_hp_bar.s | 6 +- include/battle/battle.h | 3 +- include/battle/battle_controller.h | 2 +- include/battle/battle_system.h | 13 +- src/battle/battle_command.c | 28 +-- src/battle/battle_system.c | 77 ++++++- 19 files changed, 179 insertions(+), 305 deletions(-) diff --git a/asm/include/overlay_07.inc b/asm/include/overlay_07.inc index 5756aaea90..e87db2fb2b 100644 --- a/asm/include/overlay_07.inc +++ b/asm/include/overlay_07.inc @@ -240,4 +240,4 @@ .public ov12_0223BB88 .public ov12_0223C1C4 .public ov12_0223C1F4 -.public ov12_0223C340 +.public BattleSystem_SetDefaultBlend diff --git a/asm/include/overlay_12_02264824.inc b/asm/include/overlay_12_02264824.inc index a05045aff9..9b22bf74cd 100644 --- a/asm/include/overlay_12_02264824.inc +++ b/asm/include/overlay_12_02264824.inc @@ -54,7 +54,7 @@ .public ov12_0223A8EC .public BattleSystem_GetHpFont .public BattleSystem_GetLevelFont -.public ov12_0223A930 +.public BattleSystem_GetMessageData .public BattleSystem_GetPaletteData .public ov12_0223A9A4 .public ov12_0226498C diff --git a/asm/include/overlay_12_02266024.inc b/asm/include/overlay_12_02266024.inc index 15fb69fb9c..e3df8f98ac 100644 --- a/asm/include/overlay_12_02266024.inc +++ b/asm/include/overlay_12_02266024.inc @@ -135,7 +135,7 @@ .public BattleSystem_GetPartyMon .public ov12_0223A8E4 .public ov12_0223A8EC -.public ov12_0223A930 +.public BattleSystem_GetMessageData .public BattleSystem_GetPaletteData .public ov12_0223A9A4 .public ov12_0223AAD8 diff --git a/asm/include/overlay_12_0226ADE0.inc b/asm/include/overlay_12_0226ADE0.inc index 457d03a501..bd390086b3 100644 --- a/asm/include/overlay_12_0226ADE0.inc +++ b/asm/include/overlay_12_0226ADE0.inc @@ -28,7 +28,7 @@ .public GF_AssertFail .public G2x_SetBlendAlpha_ .public MI_CpuFill8 -.public ov12_0223C340 +.public BattleSystem_SetDefaultBlend .public ov12_0226ADE0 .public ov12_0226AE78 .public ov12_0226AEE0 diff --git a/asm/include/overlay_12_battle_command.inc b/asm/include/overlay_12_battle_command.inc index dd890c10e7..b817697c87 100644 --- a/asm/include/overlay_12_battle_command.inc +++ b/asm/include/overlay_12_battle_command.inc @@ -126,7 +126,7 @@ .public ov12_0223A8E4 .public ov12_0223A8EC .public ov12_0223A8F4 -.public ov12_0223A930 +.public BattleSystem_GetMessageData .public BattleSystem_GetPaletteData .public BattleSystem_GetPokedex .public ov12_0223A9A4 @@ -154,7 +154,7 @@ .public ov12_0223C224 .public BattleSystem_SetPokedexCaught .public BattleSystem_CheckMonCaught -.public ov12_0223C494 +.public BattleSystem_PrintBattleMessage .public ov12_0223C4E8 .public BtlCmd_PlayEncounterAnimation .public BtlCmd_PokemonEncounter diff --git a/asm/include/overlay_12_battle_controller_opponent.inc b/asm/include/overlay_12_battle_controller_opponent.inc index a44d327b89..c1130a0dee 100644 --- a/asm/include/overlay_12_battle_controller_opponent.inc +++ b/asm/include/overlay_12_battle_controller_opponent.inc @@ -163,7 +163,7 @@ .public ov12_0223A900 .public ov12_0223A908 .public ov12_0223A914 -.public ov12_0223A930 +.public BattleSystem_GetMessageData .public ov12_0223A934 .public BattleSystem_GetPaletteData .public ov12_0223A99C @@ -222,8 +222,8 @@ .public ov12_0223C1A0 .public ov12_0223C1C4 .public ov12_0223C1F4 -.public ov12_0223C34C -.public ov12_0223C494 +.public BattleSystem_PrintTrainerMessage +.public BattleSystem_PrintBattleMessage .public GetBattlerVar .public ov12_022506D4 .public ov12_02251D28 diff --git a/asm/include/overlay_12_battle_system.inc b/asm/include/overlay_12_battle_system.inc index f1fd77c544..a028e6176b 100644 --- a/asm/include/overlay_12_battle_system.inc +++ b/asm/include/overlay_12_battle_system.inc @@ -84,7 +84,7 @@ .public ov12_0223A914 .public BattleSystem_GetHpFont .public BattleSystem_GetLevelFont -.public ov12_0223A930 +.public BattleSystem_GetMessageData .public ov12_0223A934 .public BattleSystem_GetPaletteData .public BattleSystem_GetPokedex @@ -200,9 +200,9 @@ .public BattleSystem_SetPokedexSeen .public BattleSystem_SetPokedexCaught .public BattleSystem_CheckMonCaught -.public ov12_0223C340 -.public ov12_0223C34C -.public ov12_0223C494 +.public BattleSystem_SetDefaultBlend +.public BattleSystem_PrintTrainerMessage +.public BattleSystem_PrintBattleMessage .public ov12_0223C4E8 .public GetBattlerVar .public SetBattlerVar diff --git a/asm/overlay_07.s b/asm/overlay_07.s index ebf222726c..f27b39c40d 100644 --- a/asm/overlay_07.s +++ b/asm/overlay_07.s @@ -1872,7 +1872,7 @@ _0221CADE: add r0, r5, r0 mov r1, #5 bl ov07_0221DD14 - bl ov12_0223C340 + bl BattleSystem_SetDefaultBlend add r0, r5, #0 mov r1, #1 bl ov07_0221FAEC @@ -5004,7 +5004,7 @@ _0221E224: strb r0, [r4, #5] b _0221E272 _0221E250: - bl ov12_0223C340 + bl BattleSystem_SetDefaultBlend mov r0, #2 mov r1, #0 bl ToggleBgLayer diff --git a/asm/overlay_12_02266024.s b/asm/overlay_12_02266024.s index 9f6fe27c8a..a730f6da18 100644 --- a/asm/overlay_12_02266024.s +++ b/asm/overlay_12_02266024.s @@ -1842,7 +1842,7 @@ ov12_02266F84: ; 0x02266F84 ldr r0, _022672F0 ; =0x000006E1 strb r1, [r5, r0] ldr r0, [r5] - bl ov12_0223A930 + bl BattleSystem_GetMessageData add r4, r0, #0 ldr r0, _022672F4 ; =0x0000068A strb r7, [r5, r0] @@ -2420,7 +2420,7 @@ _0226749C: ldr r0, _02267720 ; =0x0000068A strb r1, [r5, r0] ldr r0, [r5] - bl ov12_0223A930 + bl BattleSystem_GetMessageData str r0, [sp, #0x1c] ldrb r1, [r6, #0x10] add r0, r5, #0 @@ -2744,7 +2744,7 @@ ov12_02267760: ; 0x02267760 sub sp, #0x1c add r5, r0, #0 ldr r0, [r5] - bl ov12_0223A930 + bl BattleSystem_GetMessageData mov r1, #0xeb lsl r1, r1, #2 add r6, r0, #0 @@ -2815,7 +2815,7 @@ ov12_022677FC: ; 0x022677FC sub sp, #0x1c add r5, r0, #0 ldr r0, [r5] - bl ov12_0223A930 + bl BattleSystem_GetMessageData ldr r1, _02267884 ; =0x0000049D add r6, r0, #0 bl NewString_ReadMsgData @@ -2886,7 +2886,7 @@ ov12_0226789C: ; 0x0226789C sub sp, #0x24 add r5, r0, #0 ldr r0, [r5] - bl ov12_0223A930 + bl BattleSystem_GetMessageData add r6, r0, #0 ldr r0, [r5] bl ov12_0223A9A4 @@ -2992,7 +2992,7 @@ ov12_02267984: ; 0x02267984 mov r3, #0x1f bl G2x_SetBlendAlpha_ ldr r0, [r5] - bl ov12_0223A930 + bl BattleSystem_GetMessageData ldr r1, _02267A4C ; =0x000004EC bl NewString_ReadMsgData add r4, r0, #0 @@ -3077,7 +3077,7 @@ ov12_02267A58: ; 0x02267A58 sub sp, #0x24 add r5, r0, #0 ldr r0, [r5] - bl ov12_0223A930 + bl BattleSystem_GetMessageData add r6, r0, #0 ldr r0, [r5] bl ov12_0223A9A4 @@ -3176,7 +3176,7 @@ ov12_02267B40: ; 0x02267B40 sub sp, #0x24 add r5, r0, #0 ldr r0, [r5] - bl ov12_0223A930 + bl BattleSystem_GetMessageData add r6, r0, #0 ldr r0, [r5] bl ov12_0223A9A4 @@ -3287,7 +3287,7 @@ ov12_02267C24: ; 0x02267C24 sub r0, r0, #2 strb r1, [r5, r0] ldr r0, [r5] - bl ov12_0223A930 + bl BattleSystem_GetMessageData str r0, [sp, #0x2c] ldr r0, [r5] bl ov12_0223A9A4 @@ -4851,7 +4851,7 @@ ov12_0226885C: ; 0x0226885C ldr r0, [r7] add r5, r1, #0 str r2, [sp, #8] - bl ov12_0223A930 + bl BattleSystem_GetMessageData add r4, r0, #0 add r0, r7, #0 add r1, r5, #0 @@ -9505,7 +9505,7 @@ _0226AAB4: bl ScheduleBgTilemapBufferTransfer ldr r0, [sp, #0x1c] ldr r0, [r0] - bl ov12_0223A930 + bl BattleSystem_GetMessageData ldr r2, _0226AC54 ; =ov12_0226E23C str r0, [sp, #0x20] ldrh r3, [r2, #0x2c] diff --git a/asm/overlay_12_0226ADE0.s b/asm/overlay_12_0226ADE0.s index 140ecc5c2d..3b953adc4d 100644 --- a/asm/overlay_12_0226ADE0.s +++ b/asm/overlay_12_0226ADE0.s @@ -612,7 +612,7 @@ _0226B264: strh r1, [r0] pop {r3, r4, r5, pc} _0226B27A: - bl ov12_0223C340 + bl BattleSystem_SetDefaultBlend add r0, r5, #0 bl DestroySysTask mov r0, #0 diff --git a/asm/overlay_12_battle_command.s b/asm/overlay_12_battle_command.s index 319bfd8a9a..5be808593c 100644 --- a/asm/overlay_12_battle_command.s +++ b/asm/overlay_12_battle_command.s @@ -245,7 +245,7 @@ Task_GetPokemon: ; 0x022465A8 add r4, r1, #0 str r0, [sp, #0x10] ldr r0, [r4] - bl ov12_0223A930 + bl BattleSystem_GetMessageData str r0, [sp, #0x20] ldr r0, [r4] bl BattleSystem_GetPaletteData @@ -568,7 +568,7 @@ _02246826: ldr r0, [r4] ldr r1, [sp, #0x20] add r2, sp, #0x10c - bl ov12_0223C494 + bl BattleSystem_PrintBattleMessage str r0, [r4, #0x30] mov r0, #0x1e str r0, [r4, #0x34] @@ -755,7 +755,7 @@ _022469E6: ldr r0, [r4] ldr r1, [sp, #0x20] add r2, sp, #0xe8 - bl ov12_0223C494 + bl BattleSystem_PrintBattleMessage str r0, [r4, #0x30] mov r0, #0x1e str r0, [r4, #0x34] @@ -1445,7 +1445,7 @@ _02247006: ldr r0, [r4] ldr r1, [sp, #0x20] add r2, sp, #0x9c - bl ov12_0223C494 + bl BattleSystem_PrintBattleMessage str r0, [r4, #0x30] mov r0, #0x1e str r0, [r4, #0x34] @@ -1520,7 +1520,7 @@ _02247094: ldr r0, [r4] ldr r1, [sp, #0x20] add r2, sp, #0x78 - bl ov12_0223C494 + bl BattleSystem_PrintBattleMessage str r0, [r4, #0x30] mov r0, #0x1e str r0, [r4, #0x34] @@ -1555,7 +1555,7 @@ _022470E8: ldr r0, [r4] ldr r1, [sp, #0x20] add r2, sp, #0x54 - bl ov12_0223C494 + bl BattleSystem_PrintBattleMessage str r0, [r4, #0x30] mov r0, #0x1e str r0, [r4, #0x34] @@ -1626,7 +1626,7 @@ _02247174: ldr r0, [r4] ldr r1, [sp, #0x20] add r2, sp, #0x30 - bl ov12_0223C494 + bl BattleSystem_PrintBattleMessage str r0, [r4, #0x30] mov r0, #0x1e str r0, [r4, #0x34] @@ -3787,7 +3787,7 @@ ov12_02248228: ; 0x02248228 add r7, r0, #0 add r5, r1, #0 str r2, [sp, #0x18] - bl ov12_0223A930 + bl BattleSystem_GetMessageData str r0, [sp, #0x28] add r0, r7, #0 bl BattleSystem_GetMessageBuffer diff --git a/asm/overlay_12_battle_controller_opponent.s b/asm/overlay_12_battle_controller_opponent.s index 452ecfceb8..ffc9522bf2 100644 --- a/asm/overlay_12_battle_controller_opponent.s +++ b/asm/overlay_12_battle_controller_opponent.s @@ -4255,7 +4255,7 @@ ov12_0225A85C: ; 0x0225A85C ldr r1, [sp] add r0, r6, #0 add r2, sp, #4 - bl ov12_0223C494 + bl BattleSystem_PrintBattleMessage strb r0, [r4, #6] ldr r0, _0225A8C0 ; =ov12_022605D0 add r1, r4, #0 @@ -4273,7 +4273,7 @@ ov12_0225A8C4: ; 0x0225A8C4 add r5, r0, #0 add r6, r1, #0 add r7, r2, #0 - bl ov12_0223A930 + bl BattleSystem_GetMessageData str r0, [sp] mov r0, #5 mov r1, #8 @@ -4294,7 +4294,7 @@ ov12_0225A8C4: ; 0x0225A8C4 ldr r1, [sp] add r0, r5, #0 add r2, r7, #0 - bl ov12_0223C494 + bl BattleSystem_PrintBattleMessage strb r0, [r4, #6] ldr r0, _0225A910 ; =ov12_022605D0 add r1, r4, #0 @@ -4845,7 +4845,7 @@ ov12_0225ACE8: ; 0x0225ACE8 ldrb r3, [r7, #1] ldr r1, [sp, #4] add r0, r6, #0 - bl ov12_0223C34C + bl BattleSystem_PrintTrainerMessage strb r0, [r4, #6] ldr r0, _0225AD40 ; =ov12_022605D0 add r1, r4, #0 @@ -4867,7 +4867,7 @@ ov12_0225AD44: ; 0x0225AD44 add r7, r2, #0 bl ov12_02261390 add r0, r5, #0 - bl ov12_0223A930 + bl BattleSystem_GetMessageData str r0, [sp] mov r0, #5 mov r1, #8 @@ -4886,7 +4886,7 @@ ov12_0225AD44: ; 0x0225AD44 ldr r1, [sp] add r0, r5, #0 add r2, sp, #4 - bl ov12_0223C494 + bl BattleSystem_PrintBattleMessage strb r0, [r4, #6] ldr r0, _0225AD98 ; =ov12_022605D0 add r1, r4, #0 @@ -4908,7 +4908,7 @@ ov12_0225AD9C: ; 0x0225AD9C add r7, r2, #0 bl ov12_02261464 add r0, r5, #0 - bl ov12_0223A930 + bl BattleSystem_GetMessageData str r0, [sp] mov r0, #5 mov r1, #8 @@ -4927,7 +4927,7 @@ ov12_0225AD9C: ; 0x0225AD9C ldr r1, [sp] add r0, r5, #0 add r2, sp, #4 - bl ov12_0223C494 + bl BattleSystem_PrintBattleMessage strb r0, [r4, #6] ldr r0, _0225ADF0 ; =ov12_022605D0 add r1, r4, #0 @@ -4948,7 +4948,7 @@ ov12_0225ADF4: ; 0x0225ADF4 add r6, r1, #0 bl ov12_02261544 add r0, r5, #0 - bl ov12_0223A930 + bl BattleSystem_GetMessageData add r7, r0, #0 mov r0, #5 mov r1, #8 @@ -4967,7 +4967,7 @@ ov12_0225ADF4: ; 0x0225ADF4 add r0, r5, #0 add r1, r7, #0 add r2, sp, #0 - bl ov12_0223C494 + bl BattleSystem_PrintBattleMessage strb r0, [r4, #6] ldr r0, _0225AE44 ; =ov12_022605D0 add r1, r4, #0 @@ -4989,7 +4989,7 @@ ov12_0225AE48: ; 0x0225AE48 add r7, r2, #0 bl ov12_022615F0 add r0, r5, #0 - bl ov12_0223A930 + bl BattleSystem_GetMessageData str r0, [sp] mov r0, #5 mov r1, #8 @@ -5008,7 +5008,7 @@ ov12_0225AE48: ; 0x0225AE48 ldr r1, [sp] add r0, r5, #0 add r2, sp, #4 - bl ov12_0223C494 + bl BattleSystem_PrintBattleMessage strb r0, [r4, #6] ldr r0, _0225AE9C ; =ov12_022605D0 add r1, r4, #0 @@ -5059,7 +5059,7 @@ ov12_0225AED8: ; 0x0225AED8 add r6, r0, #0 cmp r2, #0 bne _0225AF2A - bl ov12_0223A930 + bl BattleSystem_GetMessageData str r0, [sp] mov r0, #5 mov r1, #0xc @@ -5080,7 +5080,7 @@ ov12_0225AED8: ; 0x0225AED8 ldr r1, [sp] add r0, r6, #0 add r2, r4, #4 - bl ov12_0223C494 + bl BattleSystem_PrintBattleMessage strb r0, [r7, #6] ldr r0, _0225AF70 ; =ov12_02260614 add r1, r7, #0 @@ -5425,7 +5425,7 @@ ov12_0225B1A8: ; 0x0225B1A8 ldrb r1, [r4, r1] cmp r1, #0 bne _0225B1E6 - bl ov12_0223A930 + bl BattleSystem_GetMessageData add r1, r0, #0 ldr r2, _0225B1FC ; =0x0000039B add r0, sp, #0 @@ -5434,7 +5434,7 @@ ov12_0225B1A8: ; 0x0225B1A8 strb r3, [r0, #1] add r0, r5, #0 add r2, sp, #0 - bl ov12_0223C494 + bl BattleSystem_PrintBattleMessage add r0, r5, #0 mov r1, #0 bl BattleSystem_GetWindow @@ -5553,7 +5553,7 @@ ov12_0225B2A4: ; 0x0225B2A4 add r6, r1, #0 bl ov12_02261928 add r0, r5, #0 - bl ov12_0223A930 + bl BattleSystem_GetMessageData add r7, r0, #0 mov r0, #5 mov r1, #8 @@ -5572,7 +5572,7 @@ ov12_0225B2A4: ; 0x0225B2A4 add r0, r5, #0 add r1, r7, #0 add r2, sp, #0 - bl ov12_0223C494 + bl BattleSystem_PrintBattleMessage strb r0, [r4, #6] ldr r0, _0225B2F4 ; =ov12_022605D0 add r1, r4, #0 @@ -5593,7 +5593,7 @@ ov12_0225B2F8: ; 0x0225B2F8 add r6, r1, #0 bl ov12_022619E4 add r0, r5, #0 - bl ov12_0223A930 + bl BattleSystem_GetMessageData add r7, r0, #0 mov r0, #5 mov r1, #8 @@ -5612,7 +5612,7 @@ ov12_0225B2F8: ; 0x0225B2F8 add r0, r5, #0 add r1, r7, #0 add r2, sp, #0 - bl ov12_0223C494 + bl BattleSystem_PrintBattleMessage strb r0, [r4, #6] ldr r0, _0225B348 ; =ov12_022605D0 add r1, r4, #0 @@ -5633,7 +5633,7 @@ ov12_0225B34C: ; 0x0225B34C add r6, r1, #0 bl ov12_02261AD4 add r0, r5, #0 - bl ov12_0223A930 + bl BattleSystem_GetMessageData add r7, r0, #0 mov r0, #5 mov r1, #8 @@ -5652,7 +5652,7 @@ ov12_0225B34C: ; 0x0225B34C add r0, r5, #0 add r1, r7, #0 add r2, sp, #0 - bl ov12_0223C494 + bl BattleSystem_PrintBattleMessage strb r0, [r4, #6] ldr r0, _0225B39C ; =ov12_022605D0 add r1, r4, #0 @@ -10588,7 +10588,7 @@ _0225DB46: strb r0, [r4, #0xa] _0225DB7C: ldr r0, [r4] - bl ov12_0223A930 + bl BattleSystem_GetMessageData add r6, r0, #0 mov r0, #1 lsl r0, r0, #0xa @@ -10620,7 +10620,7 @@ _0225DBA0: strh r0, [r1, #0xe] ldr r0, [r4] add r1, r6, #0 - bl ov12_0223C494 + bl BattleSystem_PrintBattleMessage mov r0, #3 add sp, #0x58 strb r0, [r4, #0xa] @@ -10641,7 +10641,7 @@ _0225DBCC: ldr r0, [r4] add r1, r6, #0 add r2, sp, #0x1c - bl ov12_0223C494 + bl BattleSystem_PrintBattleMessage add r1, r4, #0 add r1, #0x35 strb r0, [r1] @@ -10698,7 +10698,7 @@ _0225DC56: add r1, r6, #0 add r2, sp, #0x1c mov r3, #0 - bl ov12_0223C494 + bl BattleSystem_PrintBattleMessage mov r0, #3 add sp, #0x58 strb r0, [r4, #0xa] @@ -11455,7 +11455,7 @@ _0225E2AC: b _0225E3F8 _0225E2B8: ldr r0, [r4] - bl ov12_0223A930 + bl BattleSystem_GetMessageData add r1, r0, #0 mov r2, #2 add r0, sp, #0x14 @@ -11470,7 +11470,7 @@ _0225E2B8: strh r2, [r0, #0x16] ldr r0, [r4] add r2, sp, #0x28 - bl ov12_0223C494 + bl BattleSystem_PrintBattleMessage add r0, r7, #0 bl ov12_02266AC0 mov r0, #7 @@ -12862,7 +12862,7 @@ _0225EDE0: ldrh r0, [r0, #0x1c] str r0, [sp, #0x90] ldr r0, [r4] - bl ov12_0223A930 + bl BattleSystem_GetMessageData add r5, r0, #0 ldr r0, [r4] bl BattleSystem_GetTextFrameDelay @@ -12870,7 +12870,7 @@ _0225EDE0: ldr r0, [r4] add r1, r5, #0 add r2, sp, #0x8c - bl ov12_0223C494 + bl BattleSystem_PrintBattleMessage strb r0, [r4, #0x11] mov r0, #0x1e strb r0, [r4, #0x17] @@ -13119,7 +13119,7 @@ _0225EFF6: strb r1, [r0, #1] _0225EFFE: ldr r0, [r4] - bl ov12_0223A930 + bl BattleSystem_GetMessageData add r5, r0, #0 ldr r0, [r4] bl BattleSystem_GetTextFrameDelay @@ -13127,7 +13127,7 @@ _0225EFFE: ldr r0, [r4] add r1, r5, #0 add r2, sp, #0x68 - bl ov12_0223C494 + bl BattleSystem_PrintBattleMessage strb r0, [r4, #0x11] mov r0, #0x1e strb r0, [r4, #0x17] @@ -13266,7 +13266,7 @@ _0225F128: pop {r3, r4, r5, r6, r7, pc} _0225F140: ldr r0, [r4] - bl ov12_0223A930 + bl BattleSystem_GetMessageData add r5, r0, #0 ldr r0, [r4, #8] ldr r1, [r0, #4] @@ -13311,7 +13311,7 @@ _0225F18E: ldr r0, [r4] add r1, r5, #0 add r2, sp, #0x44 - bl ov12_0223C494 + bl BattleSystem_PrintBattleMessage strb r0, [r4, #0x11] mov r0, #0x1e strb r0, [r4, #0x17] @@ -13494,7 +13494,7 @@ _0225F2F4: strh r1, [r0, #6] _0225F2FA: ldr r0, [r4] - bl ov12_0223A930 + bl BattleSystem_GetMessageData add r5, r0, #0 ldr r0, [r4] bl BattleSystem_GetTextFrameDelay @@ -13502,7 +13502,7 @@ _0225F2FA: ldr r0, [r4] add r1, r5, #0 add r2, sp, #0x20 - bl ov12_0223C494 + bl BattleSystem_PrintBattleMessage strb r0, [r4, #0x11] mov r0, #0x1e strb r0, [r4, #0x17] @@ -14418,7 +14418,7 @@ _0225FA9C: cmp r0, #0 beq _0225FAE4 ldr r0, [r4] - bl ov12_0223A930 + bl BattleSystem_GetMessageData add r5, r0, #0 ldrb r0, [r4, #0xf] cmp r0, #5 @@ -14442,7 +14442,7 @@ _0225FACA: ldr r0, [r4] add r1, r5, #0 add r2, sp, #0x14 - bl ov12_0223C494 + bl BattleSystem_PrintBattleMessage strh r0, [r4, #0x1a] _0225FAE4: mov r0, #1 diff --git a/asm/overlay_12_battle_system.s b/asm/overlay_12_battle_system.s index c5dc901c9f..f7c865934e 100644 --- a/asm/overlay_12_battle_system.s +++ b/asm/overlay_12_battle_system.s @@ -6,215 +6,6 @@ .text - thumb_func_start ov12_0223C340 -ov12_0223C340: ; 0x0223C340 - ldr r0, _0223C348 ; =0x04000050 - mov r1, #0 - strh r1, [r0] - bx lr - .balign 4, 0 -_0223C348: .word 0x04000050 - thumb_func_end ov12_0223C340 - - thumb_func_start ov12_0223C34C -ov12_0223C34C: ; 0x0223C34C - push {r3, r4, r5, r6, r7, lr} - sub sp, #0x18 - add r4, r1, #0 - add r6, r0, #0 - mov r1, #0 - str r2, [sp, #0xc] - add r5, r3, #0 - bl BattleSystem_GetWindow - add r7, r0, #0 - ldr r0, [r6, #0x2c] - mov r2, #0x80 - add r1, r0, #0 - tst r1, r2 - beq _0223C454 - ldr r1, _0223C488 ; =0x00002710 - cmp r4, r1 - beq _0223C376 - lsl r1, r2, #6 - tst r0, r1 - beq _0223C3D2 -_0223C376: - cmp r5, #0x64 - bne _0223C38E - ldr r0, [sp, #0xc] - add r2, r6, #0 - mov r1, #0x34 - add r2, #0xd0 - mul r1, r0 - add r0, r2, r1 - mov r1, #5 - bl MailMsg_GetExpandedString - b _0223C3A0 -_0223C38E: - ldr r0, [sp, #0xc] - add r2, r6, #0 - mov r1, #0x34 - add r2, #0xd8 - mul r1, r0 - add r0, r2, r1 - mov r1, #5 - bl MailMsg_GetExpandedString -_0223C3A0: - add r4, r0, #0 - add r0, r7, #0 - mov r1, #0xff - bl FillWindowPixelBuffer - ldr r0, [r6, #0x18] - add r1, r4, #0 - bl String_Copy - mov r3, #0 - ldr r0, [sp, #0x30] - str r3, [sp] - str r0, [sp, #4] - ldr r0, _0223C48C ; =ov12_0223CF14 - mov r1, #1 - str r0, [sp, #8] - ldr r2, [r6, #0x18] - add r0, r7, #0 - bl AddTextPrinterParameterized - add r5, r0, #0 - add r0, r4, #0 - bl String_Delete - b _0223C480 -_0223C3D2: - cmp r5, #0x64 - bne _0223C3E0 - lsl r0, r4, #1 - add r0, r4, r0 - add r0, r0, #1 - str r0, [sp, #0x10] - b _0223C3E8 -_0223C3E0: - lsl r0, r4, #1 - add r0, r4, r0 - add r0, r0, #2 - str r0, [sp, #0x10] -_0223C3E8: - mov r4, #0 - add r5, r6, #0 -_0223C3EC: - ldr r0, [r5, #0x48] - bl PlayerProfile_GetVersion - cmp r0, #0 - beq _0223C3FE - add r4, r4, #1 - add r5, r5, #4 - cmp r4, #4 - blt _0223C3EC -_0223C3FE: - cmp r4, #4 - bne _0223C408 - mov r2, #0xb5 - lsl r2, r2, #2 - b _0223C40A -_0223C408: - ldr r2, _0223C490 ; =0x000002D3 -_0223C40A: - mov r0, #0 - mov r1, #0x1b - mov r3, #5 - bl NewMsgDataFromNarc - ldr r1, [sp, #0x10] - str r0, [sp, #0x14] - bl NewString_ReadMsgData - add r4, r0, #0 - add r0, r7, #0 - mov r1, #0xff - bl FillWindowPixelBuffer - ldr r0, [r6, #0x18] - add r1, r4, #0 - bl String_Copy - mov r3, #0 - ldr r0, [sp, #0x30] - str r3, [sp] - str r0, [sp, #4] - ldr r0, _0223C48C ; =ov12_0223CF14 - mov r1, #1 - str r0, [sp, #8] - ldr r2, [r6, #0x18] - add r0, r7, #0 - bl AddTextPrinterParameterized - add r5, r0, #0 - add r0, r4, #0 - bl String_Delete - ldr r0, [sp, #0x14] - bl DestroyMsgData - b _0223C480 -_0223C454: - ldr r2, [r6, #0x18] - add r0, r4, #0 - add r1, r5, #0 - mov r3, #5 - bl GetTrainerMessageByIdPair - add r0, r7, #0 - mov r1, #0xff - bl FillWindowPixelBuffer - mov r3, #0 - ldr r0, [sp, #0x30] - str r3, [sp] - str r0, [sp, #4] - ldr r0, _0223C48C ; =ov12_0223CF14 - mov r1, #1 - str r0, [sp, #8] - ldr r2, [r6, #0x18] - add r0, r7, #0 - bl AddTextPrinterParameterized - add r5, r0, #0 -_0223C480: - lsl r0, r5, #0x18 - lsr r0, r0, #0x18 - add sp, #0x18 - pop {r3, r4, r5, r6, r7, pc} - .balign 4, 0 -_0223C488: .word 0x00002710 -_0223C48C: .word ov12_0223CF14 -_0223C490: .word 0x000002D3 - thumb_func_end ov12_0223C34C - - thumb_func_start ov12_0223C494 -ov12_0223C494: ; 0x0223C494 - push {r3, r4, r5, r6, r7, lr} - sub sp, #0x10 - str r1, [sp, #0xc] - add r5, r0, #0 - add r4, r2, #0 - mov r1, #0 - add r6, r3, #0 - bl BattleSystem_GetWindow - add r7, r0, #0 - add r0, r5, #0 - add r1, r4, #0 - bl ov12_0223C558 - add r0, r5, #0 - add r1, r4, #0 - bl ov12_0223C754 - ldr r1, [sp, #0xc] - add r0, r5, #0 - add r2, r4, #0 - bl ov12_0223CEF4 - add r0, r7, #0 - mov r1, #0xff - bl FillWindowPixelBuffer - mov r3, #0 - str r3, [sp] - ldr r0, _0223C4E4 ; =ov12_0223CF14 - str r6, [sp, #4] - str r0, [sp, #8] - ldr r2, [r5, #0x18] - add r0, r7, #0 - mov r1, #1 - bl AddTextPrinterParameterized - add sp, #0x10 - pop {r3, r4, r5, r6, r7, pc} - nop -_0223C4E4: .word ov12_0223CF14 - thumb_func_end ov12_0223C494 - thumb_func_start ov12_0223C4E8 ov12_0223C4E8: ; 0x0223C4E8 push {r4, r5, r6, r7, lr} diff --git a/asm/overlay_12_hp_bar.s b/asm/overlay_12_hp_bar.s index 0aa8c0a1ca..3c97ef72a0 100644 --- a/asm/overlay_12_hp_bar.s +++ b/asm/overlay_12_hp_bar.s @@ -1241,7 +1241,7 @@ ov12_0226516C: ; 0x0226516C bl BattleSystem_GetBgConfig add r6, r0, #0 ldr r0, [r5, #0xc] - bl ov12_0223A930 + bl BattleSystem_GetMessageData add r7, r0, #0 ldr r0, [r5, #0xc] bl ov12_0223A9A4 @@ -1773,7 +1773,7 @@ ov12_022655F0: ; 0x022655F0 bl BattleSystem_GetBgConfig add r6, r0, #0 ldr r0, [r4, #0xc] - bl ov12_0223A930 + bl BattleSystem_GetMessageData mov r1, #1 lsl r1, r1, #0xa add r2, r5, #0 @@ -1875,7 +1875,7 @@ ov12_022656CC: ; 0x022656CC bl BattleSystem_GetBgConfig str r0, [sp, #0x1c] ldr r0, [r4, #0xc] - bl ov12_0223A930 + bl BattleSystem_GetMessageData str r0, [sp, #0x20] ldr r0, [r4, #0xc] bl ov12_0223A9A4 diff --git a/include/battle/battle.h b/include/battle/battle.h index 84338a122b..963f41e58c 100644 --- a/include/battle/battle.h +++ b/include/battle/battle.h @@ -7,6 +7,7 @@ #include "item.h" #include "font.h" #include "game_stats.h" +#include "msgdata.h" #include "move.h" #include "options.h" #include "palette.h" @@ -520,7 +521,7 @@ struct BattleSystem { u32 *unk0; BgConfig *bgConfig; Window *window; - u32 *unkC; + MsgData *msgData; u32 *unk10; u32 *unk14; String *msgBuffer; diff --git a/include/battle/battle_controller.h b/include/battle/battle_controller.h index 5e853f6752..717fd7393c 100644 --- a/include/battle/battle_controller.h +++ b/include/battle/battle_controller.h @@ -76,7 +76,7 @@ void ov12_0224E414(BattleSystem *bsys, BattleContext *ctx); void ov12_02263564(BattleSystem *bsys, BattleContext *ctx, int battlerId, u32 a3); void ov12_0226399C(BattleSystem *bsys, int battlerId); void ov12_02263A1C(BattleSystem *bsys, BattleContext *ctx, int battlerId); -void ov12_0223C4E8(BattleSystem *bsys, Window *window, u32 *msgLoader, BattleMessage *msg, int a4, int a5, int a6, int a7, int a8); +void ov12_0223C4E8(BattleSystem *bsys, Window *window, MsgData *msgLoader, BattleMessage *msg, int a4, int a5, int a6, int a7, int a8); void ov12_02263D14(BattleSystem *bsys, int battlerId, u32 a2, int slot); #endif diff --git a/include/battle/battle_system.h b/include/battle/battle_system.h index eacdb5c580..50d3a3929b 100644 --- a/include/battle/battle_system.h +++ b/include/battle/battle_system.h @@ -5,6 +5,7 @@ #include "battle/battle.h" #include "battle/battle_setup.h" #include "pokemon.h" +#include "text.h" BgConfig *BattleSystem_GetBgConfig(BattleSystem *bsys); Window *BattleSystem_GetWindow(BattleSystem *bsys, int index); @@ -25,7 +26,7 @@ u32 *ov12_0223A908(BattleSystem *bsys, int index); void ov12_0223A914(BattleSystem *bsys, int index, u32 *a2); FontID *BattleSystem_GetHpFont(BattleSystem *bsys); FontID *BattleSystem_GetLevelFont(BattleSystem *bsys); -u32 *ov12_0223A930(BattleSystem *bsys); +MsgData *BattleSystem_GetMessageData(BattleSystem *bsys); u32 *ov12_0223A934(BattleSystem *bsys); PaletteData *BattleSystem_GetPaletteData(BattleSystem *bsys); Pokedex *BattleSystem_GetPokedex(BattleSystem *bsys); @@ -141,6 +142,9 @@ u32 CalcMoneyLoss(Party *party, PlayerProfile *profile); void BattleSystem_SetPokedexSeen(BattleSystem *bsys, int battlerId); void BattleSystem_SetPokedexCaught(BattleSystem *bsys, int battlerId); BOOL BattleSystem_CheckMonCaught(BattleSystem *bsys, int battlerId); +void BattleSystem_SetDefaultBlend(void); +u8 BattleSystem_PrintTrainerMessage(BattleSystem *bsys, int trainerId, int battlerId, int a2, int delay); +u32 BattleSystem_PrintBattleMessage(BattleSystem *bsys, MsgData *data, BattleMessage *msg, u8 delay); //These functions haven't been decompiled BOOL Link_QueueNotEmpty(BattleContext *ctx); @@ -151,6 +155,11 @@ void ov12_02263A1C(BattleSystem *bsys, BattleContext *ctx, int battlerId); void ov12_02266008(UnkBattleSystemSub17C *a0); BattleHpBar *OpponentData_GetHpBar(OpponentData *opponentData); void ov12_0226AA8C(u32 *a1, u32 flag); -u32 ov12_0223C494(BattleSystem *bsys, void *msgLoader, BattleMessage *msg, u8 textFrameDelay); +BOOL ov12_0223CF14(struct TextPrinterTemplate *template, u16 glyphId); + +//These functions haven't been decompiled AND are confirmed to be static +void ov12_0223C558(BattleSystem *bsys, BattleMessage *msg); +void ov12_0223C754(BattleSystem *bsys, BattleMessage *msg); +void ov12_0223CEF4(BattleSystem *bsys, MsgData *data, BattleMessage *msg); #endif diff --git a/src/battle/battle_command.c b/src/battle/battle_command.c index fb0dd0a6df..419cbe3010 100644 --- a/src/battle/battle_command.c +++ b/src/battle/battle_command.c @@ -5980,12 +5980,12 @@ static void Task_GetExp(SysTask *task, void *inData) BattleMessage msg; int side; int expBattler; - u32 *msgLoader; + MsgData *msgLoader; u32 battleType; u16 item; int itemEffect; - msgLoader = ov12_0223A930(data->bsys); + msgLoader = BattleSystem_GetMessageData(data->bsys); battleType = BattleSystem_GetBattleType(data->bsys); side = (data->ctx->battlerIdFainted >> 1) & 1; //Get side of fainted mon (left or right) expBattler = 0; @@ -6074,7 +6074,7 @@ static void Task_GetExp(SysTask *task, void *inData) msg.tag = 17; msg.param[0] = expBattler | (slot << 8); msg.param[1] = totalExp; - data->unk30[0] = ov12_0223C494(data->bsys, msgLoader, &msg, BattleSystem_GetTextFrameDelay(data->bsys)); + data->unk30[0] = BattleSystem_PrintBattleMessage(data->bsys, msgLoader, &msg, BattleSystem_GetTextFrameDelay(data->bsys)); data->unk30[1] = 7; data->state++; } else { @@ -6152,7 +6152,7 @@ static void Task_GetExp(SysTask *task, void *inData) msg.tag = 17; msg.param[0] = expBattler | (slot << 8); msg.param[1] = level; - data->unk30[0] = ov12_0223C494(data->bsys, msgLoader, &msg, BattleSystem_GetTextFrameDelay(data->bsys)); + data->unk30[0] = BattleSystem_PrintBattleMessage(data->bsys, msgLoader, &msg, BattleSystem_GetTextFrameDelay(data->bsys)); data->state = STATE_GET_EXP_WAIT_LEVEL_UP_MESSAGE_PRINT; } break; @@ -6287,7 +6287,7 @@ static void Task_GetExp(SysTask *task, void *inData) msg.tag = 10; msg.param[0] = expBattler | (slot << 8); msg.param[1] = move; - data->unk30[0] = ov12_0223C494(data->bsys, msgLoader, &msg, BattleSystem_GetTextFrameDelay(data->bsys)); + data->unk30[0] = BattleSystem_PrintBattleMessage(data->bsys, msgLoader, &msg, BattleSystem_GetTextFrameDelay(data->bsys)); data->state = STATE_GET_EXP_LEARNED_MOVE_WAIT; break; } @@ -6299,7 +6299,7 @@ static void Task_GetExp(SysTask *task, void *inData) msg.tag = 10; msg.param[0] = expBattler | (slot << 8); msg.param[1] = data->unk30[4]; - data->unk30[0] = ov12_0223C494(data->bsys, msgLoader, &msg, BattleSystem_GetTextFrameDelay(data->bsys)); + data->unk30[0] = BattleSystem_PrintBattleMessage(data->bsys, msgLoader, &msg, BattleSystem_GetTextFrameDelay(data->bsys)); data->state++; break; @@ -6307,7 +6307,7 @@ static void Task_GetExp(SysTask *task, void *inData) msg.id = msg_0197_01179; // "But {0} can't learn more than four moves." msg.tag = 2; msg.param[0] = expBattler | (slot << 8); - data->unk30[0] = ov12_0223C494(data->bsys, msgLoader, &msg, BattleSystem_GetTextFrameDelay(data->bsys)); + data->unk30[0] = BattleSystem_PrintBattleMessage(data->bsys, msgLoader, &msg, BattleSystem_GetTextFrameDelay(data->bsys)); data->state++; break; @@ -6335,7 +6335,7 @@ static void Task_GetExp(SysTask *task, void *inData) } else { msg.id = msg_0197_01183; // "Which move should be forgotten?" msg.tag = 0; - data->unk30[0] = ov12_0223C494(data->bsys, msgLoader, &msg, BattleSystem_GetTextFrameDelay(data->bsys)); + data->unk30[0] = BattleSystem_PrintBattleMessage(data->bsys, msgLoader, &msg, BattleSystem_GetTextFrameDelay(data->bsys)); data->state = STATE_GET_EXP_MAKE_IT_FORGET_WAIT; } } @@ -6360,7 +6360,7 @@ static void Task_GetExp(SysTask *task, void *inData) case STATE_GET_EXP_MAKE_IT_FORGET_CANCELLED: msg.id = msg_0197_01184; // "Well, then..." msg.tag = 0; - data->unk30[0] = ov12_0223C494(data->bsys, msgLoader, &msg, BattleSystem_GetTextFrameDelay(data->bsys)); + data->unk30[0] = BattleSystem_PrintBattleMessage(data->bsys, msgLoader, &msg, BattleSystem_GetTextFrameDelay(data->bsys)); data->state++; break; @@ -6379,7 +6379,7 @@ static void Task_GetExp(SysTask *task, void *inData) msg.tag = 10; msg.param[0] = expBattler | (slot << 8); msg.param[1] = data->unk30[4]; - data->unk30[0] = ov12_0223C494(data->bsys, msgLoader, &msg, BattleSystem_GetTextFrameDelay(data->bsys)); + data->unk30[0] = BattleSystem_PrintBattleMessage(data->bsys, msgLoader, &msg, BattleSystem_GetTextFrameDelay(data->bsys)); data->state = 35; } } @@ -6395,7 +6395,7 @@ static void Task_GetExp(SysTask *task, void *inData) case STATE_GET_EXP_ONE_TWO_POOF: msg.id = msg_0197_01189; // "1, 2, and... ... Poof!" msg.tag = 0; - data->unk30[0] = ov12_0223C494(data->bsys, msgLoader, &msg, BattleSystem_GetTextFrameDelay(data->bsys)); + data->unk30[0] = BattleSystem_PrintBattleMessage(data->bsys, msgLoader, &msg, BattleSystem_GetTextFrameDelay(data->bsys)); data->state++; break; @@ -6404,14 +6404,14 @@ static void Task_GetExp(SysTask *task, void *inData) msg.tag = 10; msg.param[0] = expBattler | (slot << 8); msg.param[1] = GetMonData(mon, MON_DATA_MOVE1 + data->unk30[5], NULL); - data->unk30[0] = ov12_0223C494(data->bsys, msgLoader, &msg, BattleSystem_GetTextFrameDelay(data->bsys)); + data->unk30[0] = BattleSystem_PrintBattleMessage(data->bsys, msgLoader, &msg, BattleSystem_GetTextFrameDelay(data->bsys)); data->state++; break; case STATE_GET_EXP_AND_DOTDOTDOT: msg.id = msg_0197_01191; // "And..." msg.tag = 0; - data->unk30[0] = ov12_0223C494(data->bsys, msgLoader, &msg, BattleSystem_GetTextFrameDelay(data->bsys)); + data->unk30[0] = BattleSystem_PrintBattleMessage(data->bsys, msgLoader, &msg, BattleSystem_GetTextFrameDelay(data->bsys)); data->state++; break; @@ -6420,7 +6420,7 @@ static void Task_GetExp(SysTask *task, void *inData) msg.tag = 10; msg.param[0] = expBattler | (slot << 8); msg.param[1] = data->unk30[4]; - data->unk30[0] = ov12_0223C494(data->bsys, msgLoader, &msg, BattleSystem_GetTextFrameDelay(data->bsys)); + data->unk30[0] = BattleSystem_PrintBattleMessage(data->bsys, msgLoader, &msg, BattleSystem_GetTextFrameDelay(data->bsys)); i = 0; SetMonData(mon, MON_DATA_MOVE1PPUP + data->unk30[5], &i); diff --git a/src/battle/battle_system.c b/src/battle/battle_system.c index 82c2773217..f580318df2 100644 --- a/src/battle/battle_system.c +++ b/src/battle/battle_system.c @@ -2,8 +2,10 @@ #include "battle/battle_hp_bar.h" #include "battle/battle_controller_opponent.h" #include "battle/battle_system.h" +#include "msgdata.h" #include "party.h" #include "pokemon_mood.h" +#include "text.h" #include "battle/overlay_12_0224E4FC.h" #include "battle/overlay_12_0226BEC4.h" #include "constants/game_stats.h" @@ -107,8 +109,8 @@ FontID *BattleSystem_GetLevelFont(BattleSystem *bsys) { return bsys->levelFont; } -u32 *ov12_0223A930(BattleSystem *bsys) { - return bsys->unkC; +MsgData *BattleSystem_GetMessageData(BattleSystem *bsys) { + return bsys->msgData; } u32 *ov12_0223A934(BattleSystem *bsys) { @@ -1331,3 +1333,74 @@ void BattleSystem_SetPokedexCaught(BattleSystem *bsys, int battlerId) { BOOL BattleSystem_CheckMonCaught(BattleSystem *bsys, int battlerId) { return Pokedex_CheckMonCaughtFlag(bsys->pokedex, battlerId); } + +void BattleSystem_SetDefaultBlend() { + G2_BlendNone(); +} + +u8 BattleSystem_PrintTrainerMessage(BattleSystem *bsys, int trainerId, int battlerId, int a2, int delay) { + Window *window = BattleSystem_GetWindow(bsys, 0); + int index; + + if (bsys->battleType & BATTLE_TYPE_TOWER) { + if (trainerId == 0x2710 || bsys->battleType & BATTLE_TYPE_13) { + String *msg; + + if (a2 == 0x64) { + msg = MailMsg_GetExpandedString(&bsys->trainers[battlerId].winMessage, HEAP_ID_BATTLE); + } else { + msg = MailMsg_GetExpandedString(&bsys->trainers[battlerId].loseMessage, HEAP_ID_BATTLE); + } + FillWindowPixelBuffer(window, 0xFF); + String_Copy(bsys->msgBuffer, msg); + index = AddTextPrinterParameterized(window, 1, bsys->msgBuffer, 0, 0, delay, ov12_0223CF14); + String_Delete(msg); + } else { + MsgData *data; + String *msg; + int stringId; + u32 msgId; + int i; + + if (a2 == 0x64) { + stringId = trainerId*3 + 1; + } else { + stringId = trainerId*3 + 2; + } + + for (i = 0; i < 4; i++) { + if (PlayerProfile_GetVersion(bsys->playerProfile[i]) == 0) { + break; + } + } + + if (i == 4) { + msgId = 724; + } else { + msgId = 723; + } + + data = NewMsgDataFromNarc(MSGDATA_LOAD_DIRECT, NARC_msgdata_msg, msgId, HEAP_ID_BATTLE); + msg = NewString_ReadMsgData(data, stringId); + FillWindowPixelBuffer(window, 0xFF); + String_Copy(bsys->msgBuffer, msg); + index = AddTextPrinterParameterized(window, 1, bsys->msgBuffer, 0, 0, delay, ov12_0223CF14); + String_Delete(msg); + DestroyMsgData(data); + } + } else { + GetTrainerMessageByIdPair(trainerId, a2, bsys->msgBuffer, HEAP_ID_BATTLE); + FillWindowPixelBuffer(window, 0xFF); + index = AddTextPrinterParameterized(window, 1, bsys->msgBuffer, 0, 0, delay, ov12_0223CF14); + } + return index; +} + +u32 BattleSystem_PrintBattleMessage(BattleSystem *bsys, MsgData *data, BattleMessage *msg, u8 delay) { + Window *window = BattleSystem_GetWindow(bsys, 0); + ov12_0223C558(bsys, msg); + ov12_0223C754(bsys, msg); + ov12_0223CEF4(bsys, data, msg); + FillWindowPixelBuffer(window, 0xFF); + return AddTextPrinterParameterized(window, 1, bsys->msgBuffer, 0, 0, delay, ov12_0223CF14); +} From 067c7f4d3a9f04d131893268a94a7ee4fc69a9da Mon Sep 17 00:00:00 2001 From: Adrienn Tindall <33725376+adrienntindall@users.noreply.github.com> Date: Sun, 17 Dec 2023 18:00:31 -0500 Subject: [PATCH 20/33] add OFFSET_OF macro --- include/system.h | 2 ++ src/battle/trainer_ai.c | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/include/system.h b/include/system.h index 923334be30..5fbaf3ca5b 100644 --- a/include/system.h +++ b/include/system.h @@ -9,6 +9,8 @@ #define BUTTONMODE_SWAPXY 2 #define BUTTONMODE_LEQUALSA 3 +#define OFFSET_OF(p_type,field) ((u32)&(((p_type )NULL)->field)) + typedef void (*GFIntrCB)(void *); struct FSCacheEntry { diff --git a/src/battle/trainer_ai.c b/src/battle/trainer_ai.c index 306d59fffe..6fb36303f9 100644 --- a/src/battle/trainer_ai.c +++ b/src/battle/trainer_ai.c @@ -2,13 +2,14 @@ #include "battle/battle_system.h" #include "battle/trainer_ai.h" #include "battle/overlay_12_0224E4FC.h" +#include "system.h" void ov10_0221BE20(BattleSystem *bsys, BattleContext *ctx, u8 battlerId, u8 a3) { int i; u8 struggleFlags; u8 *aiData = (u8 *) &ctx->trainerAIData; - for (i = 0; i < (u32) 28; i++) { + for (i = 0; i < OFFSET_OF(TrainerAIData *, unk1C); i++) { aiData[i] = 0; } From a2d94aca4106d4b32b006677e8cb04729d91fc45 Mon Sep 17 00:00:00 2001 From: Adrienn Tindall <33725376+adrienntindall@users.noreply.github.com> Date: Mon, 18 Dec 2023 06:37:36 -0500 Subject: [PATCH 21/33] Update AddTextPrinterParameterized params --- asm/overlay_12_battle_system.s | 57 ------------------------------ include/battle/battle_controller.h | 1 - include/battle/battle_system.h | 1 + include/text.h | 2 +- src/battle/battle_system.c | 20 +++++++++++ src/list_menu_2d.c | 14 +++----- 6 files changed, 26 insertions(+), 69 deletions(-) diff --git a/asm/overlay_12_battle_system.s b/asm/overlay_12_battle_system.s index f7c865934e..efcccc8b6e 100644 --- a/asm/overlay_12_battle_system.s +++ b/asm/overlay_12_battle_system.s @@ -6,63 +6,6 @@ .text - thumb_func_start ov12_0223C4E8 -ov12_0223C4E8: ; 0x0223C4E8 - push {r4, r5, r6, r7, lr} - sub sp, #0xc - add r7, r3, #0 - add r4, r1, #0 - add r5, r0, #0 - add r1, r7, #0 - add r6, r2, #0 - bl ov12_0223C558 - add r0, r5, #0 - add r1, r7, #0 - bl ov12_0223C754 - add r0, r5, #0 - add r1, r6, #0 - add r2, r7, #0 - bl ov12_0223CEF4 - ldr r1, [sp, #0x28] - mov r0, #1 - tst r0, r1 - beq _0223C51C - add r0, r4, #0 - mov r1, #0xff - bl FillWindowPixelBuffer -_0223C51C: - ldr r1, [sp, #0x28] - mov r0, #2 - tst r0, r1 - beq _0223C534 - mov r0, #0 - ldr r1, [r5, #0x18] - add r2, r0, #0 - bl FontID_String_GetWidth - ldr r1, [sp, #0x2c] - sub r3, r1, r0 - b _0223C536 -_0223C534: - mov r3, #0 -_0223C536: - ldr r0, [sp, #0x24] - mov r1, #0 - str r0, [sp] - ldr r0, [sp, #0x30] - str r0, [sp, #4] - ldr r0, _0223C554 ; =ov12_0223CF14 - str r0, [sp, #8] - add r0, r4, #0 - ldr r4, [sp, #0x20] - ldr r2, [r5, #0x18] - add r3, r4, r3 - bl AddTextPrinterParameterized - add sp, #0xc - pop {r4, r5, r6, r7, pc} - .balign 4, 0 -_0223C554: .word ov12_0223CF14 - thumb_func_end ov12_0223C4E8 - thumb_func_start ov12_0223C558 ov12_0223C558: ; 0x0223C558 push {r4, r5, r6, lr} diff --git a/include/battle/battle_controller.h b/include/battle/battle_controller.h index 717fd7393c..2bf3a5573c 100644 --- a/include/battle/battle_controller.h +++ b/include/battle/battle_controller.h @@ -76,7 +76,6 @@ void ov12_0224E414(BattleSystem *bsys, BattleContext *ctx); void ov12_02263564(BattleSystem *bsys, BattleContext *ctx, int battlerId, u32 a3); void ov12_0226399C(BattleSystem *bsys, int battlerId); void ov12_02263A1C(BattleSystem *bsys, BattleContext *ctx, int battlerId); -void ov12_0223C4E8(BattleSystem *bsys, Window *window, MsgData *msgLoader, BattleMessage *msg, int a4, int a5, int a6, int a7, int a8); void ov12_02263D14(BattleSystem *bsys, int battlerId, u32 a2, int slot); #endif diff --git a/include/battle/battle_system.h b/include/battle/battle_system.h index 50d3a3929b..d2ad6ad4aa 100644 --- a/include/battle/battle_system.h +++ b/include/battle/battle_system.h @@ -145,6 +145,7 @@ BOOL BattleSystem_CheckMonCaught(BattleSystem *bsys, int battlerId); void BattleSystem_SetDefaultBlend(void); u8 BattleSystem_PrintTrainerMessage(BattleSystem *bsys, int trainerId, int battlerId, int a2, int delay); u32 BattleSystem_PrintBattleMessage(BattleSystem *bsys, MsgData *data, BattleMessage *msg, u8 delay); +u32 ov12_0223C4E8(BattleSystem *bsys, Window *window, MsgData *data, BattleMessage *msg, int x, int y, int flag, int width, int delay); //These functions haven't been decompiled BOOL Link_QueueNotEmpty(BattleContext *ctx); diff --git a/include/text.h b/include/text.h index 2829d70ead..5eeb41869e 100644 --- a/include/text.h +++ b/include/text.h @@ -14,7 +14,7 @@ void sub_0201FFE0(const struct FontInfo *fontData); void DecompressGlyphTile(const u8 *src, u8 *dest); // FIXME: Are the x/y params 32bit on all three of these functions? -u16 AddTextPrinterParameterized(Window* window, u8 font_id, String* text, u8 x, u8 y, u32 speed, void* callback); +u16 AddTextPrinterParameterized(Window* window, u8 font_id, String* text, u32 x, u32 y, u32 speed, void* callback); u8 AddTextPrinterParameterized2(Window *window, FontID fontId, String *string, u32 x, u32 y, u32 textSpeed, u32 color, PrinterCallback_t callback); u8 AddTextPrinterParameterized3(Window *window, int fontId, String *string, u8 x, u8 y, u32 textSpeed, u32 color, u32 letterSpacing, u32 lineSpacing, PrinterCallback_t callback); BOOL TextPrinterCheckActive(u8 printerId); diff --git a/src/battle/battle_system.c b/src/battle/battle_system.c index f580318df2..a50b52ab41 100644 --- a/src/battle/battle_system.c +++ b/src/battle/battle_system.c @@ -1404,3 +1404,23 @@ u32 BattleSystem_PrintBattleMessage(BattleSystem *bsys, MsgData *data, BattleMes FillWindowPixelBuffer(window, 0xFF); return AddTextPrinterParameterized(window, 1, bsys->msgBuffer, 0, 0, delay, ov12_0223CF14); } + +u32 ov12_0223C4E8(BattleSystem *bsys, Window *window, MsgData *data, BattleMessage *msg, int x, int y, int flag, int width, int delay) { + int dx; + + ov12_0223C558(bsys, msg); + ov12_0223C754(bsys, msg); + ov12_0223CEF4(bsys, data, msg); + + if (flag & 1) { + FillWindowPixelBuffer(window, 0xFF); + } + + if (flag & 2) { + dx = width - FontID_String_GetWidth(0, bsys->msgBuffer, 0); + } else { + dx = 0; + } + + return AddTextPrinterParameterized(window, 0, bsys->msgBuffer, x + dx, y, delay, ov12_0223CF14); +} diff --git a/src/list_menu_2d.c b/src/list_menu_2d.c index d076bd6deb..3c1e6e8c03 100644 --- a/src/list_menu_2d.c +++ b/src/list_menu_2d.c @@ -175,21 +175,15 @@ static u8 Get2dMenuMaxItemWidth(struct ListMenu2D *listMenu) { static void Print2dMenuItemTexts(struct ListMenu2D *listMenu) { u8 i, j; u8 dx; - u8 x; + u8 x; FillWindowPixelBuffer(listMenu->template.window, GetFontAttribute(listMenu->template.fontId, 6)); x = listMenu->x; dx = listMenu->maxItemWidth + listMenu->maxGlyphWidth * 2; for (i = 0; i < listMenu->template.itemsWide; i++) { for (j = 0; j < listMenu->template.itemsHigh; j++) { - AddTextPrinterParameterized( - listMenu->template.window, - listMenu->template.fontId, - listMenu->template.items[j + i * listMenu->template.itemsHigh].text, - x, - listMenu->y + (listMenu->maxGlyphHeight + listMenu->template.yTop) * j, - TEXT_SPEED_NOTRANSFER, - NULL - ); + u8 y = listMenu->y + (listMenu->maxGlyphHeight + listMenu->template.yTop) * j; + AddTextPrinterParameterized(listMenu->template.window, listMenu->template.fontId, listMenu->template.items[j + i * listMenu->template.itemsHigh].text, + x, y, TEXT_SPEED_NOTRANSFER, NULL); } x += dx; } From 3b3b6c820cb3f3ce5d9a5f2bc4a3ad33dcca88e0 Mon Sep 17 00:00:00 2001 From: Adrienn Tindall <33725376+adrienntindall@users.noreply.github.com> Date: Tue, 19 Dec 2023 01:19:21 -0500 Subject: [PATCH 22/33] Add message tag constants --- include/constants/message_tags.h | 73 +++++++++++++++++++++++++++ src/battle/battle_command.c | 69 ++++++++++++------------- src/battle/battle_controller_player.c | 29 ++++++----- src/battle/overlay_12_0224E4FC.c | 27 +++++----- 4 files changed, 137 insertions(+), 61 deletions(-) create mode 100644 include/constants/message_tags.h diff --git a/include/constants/message_tags.h b/include/constants/message_tags.h new file mode 100644 index 0000000000..20b89d5c8e --- /dev/null +++ b/include/constants/message_tags.h @@ -0,0 +1,73 @@ +#ifndef POKEHEARTGOLD_CONSTANTS_MESSAGE_TAGS_H +#define POKEHEARTGOLD_CONSTANTS_MESSAGE_TAGS_H + +typedef enum MessageTag { + TAG_NONE = 0, + TAG_NONE_SIDE, + + TAG_NICKNAME, + TAG_MOVE, + TAG_STAT, + TAG_ITEM, + TAG_NUMBER, + TAG_NUMBERS, + TAG_TRNAME, + + TAG_NICKNAME_NICKNAME, + TAG_NICKNAME_MOVE, + TAG_NICKNAME_ABILITY, + TAG_NICKNAME_STAT, + TAG_NICKNAME_TYPE, + TAG_NICKNAME_POKE, + TAG_NICKNAME_ITEM, + TAG_NICKNAME_POFFIN, + TAG_NICKNAME_NUM, + TAG_NICKNAME_TRNAME, + TAG_NICKNAME_BOX, + TAG_MOVE_SIDE, + TAG_MOVE_NICKNAME, + TAG_MOVE_MOVE, + TAG_ABILITY_NICKNAME, + TAG_ITEM_MOVE, + TAG_NUMBER_NUMBER, + TAG_TRNAME_TRNAME, + TAG_TRNAME_NICKNAME, + TAG_TRNAME_ITEM, + TAG_TRNAME_NUM, + TAG_TRCLASS_TRNAME, + + TAG_NICKNAME_NICKNAME_MOVE, + TAG_NICKNAME_NICKNAME_ABILITY, + TAG_NICKNAME_NICKNAME_ITEM, + TAG_NICKNAME_MOVE_MOVE, + TAG_NICKNAME_MOVE_NUMBER, + TAG_NICKNAME_ABILITY_NICKNAME, + TAG_NICKNAME_ABILITY_MOVE, + TAG_NICKNAME_ABILITY_ITEM, + TAG_NICKNAME_ABILITY_STAT, + TAG_NICKNAME_ABILITY_TYPE, + TAG_NICKNAME_ABILITY_STATUS, + TAG_NICKNAME_ABILITY_NUMBER, + TAG_NICKNAME_ITEM_NICKNAME, + TAG_NICKNAME_ITEM_MOVE, + TAG_NICKNAME_ITEM_STAT, + TAG_NICKNAME_ITEM_STATUS, + TAG_NICKNAME_BOX_BOX, + TAG_ITEM_NICKNAME_FLAVOR, + TAG_TRNAME_NICKNAME_NICKNAME, + TAG_TRCLASS_TRNAME_NICKNAME, + TAG_TRCLASS_TRNAME_ITEM, + + TAG_NICKNAME_ABILITY_NICKNAME_MOVE, + TAG_NICKNAME_ABILITY_NICKNAME_ABILITY, + TAG_NICKNAME_ABILITY_NICKNAME_STAT, + TAG_NICKNAME_ITEM_NICKNAME_ITEM, + TAG_TRNAME_NICKNAME_TRNAME_NICKNAME, + TAG_TRCLASS_TRNAME_NICKNAME_NICKNAME, + TAG_TRCLASS_TRNAME_NICKNAME_TRNAME, + TAG_TRCLASS_TRNAME_TRCLASS_TRNAME, + + TAG_TRCLASS_TRNAME_NICKNAME_TRCLASS_TRNAME_NICKNAME, +} MessageTag; + +#endif diff --git a/src/battle/battle_command.c b/src/battle/battle_command.c index 419cbe3010..08b23f24e9 100644 --- a/src/battle/battle_command.c +++ b/src/battle/battle_command.c @@ -22,6 +22,7 @@ #include "constants/battle.h" #include "constants/battle_script.h" #include "constants/items.h" +#include "constants/message_tags.h" #include "constants/moves.h" #include "constants/pokemon.h" #include "constants/sndseq.h" @@ -1560,7 +1561,7 @@ BOOL BtlCmd_BufferStatChangeMsg(BattleSystem *bsys, BattleContext *ctx) { BattleScriptIncrementPointer(ctx, unkB); } else { ctx->buffMsg.id = msg_0197_00142; //{0}'s {1} won't go any higher! - ctx->buffMsg.tag = 12; + ctx->buffMsg.tag = TAG_NICKNAME_STAT; ctx->buffMsg.param[0] = CreateNicknameTag(ctx, ctx->battlerIdStatChange); ctx->buffMsg.param[1] = stat + 1; BattleScriptIncrementPointer(ctx, unkA); @@ -1568,19 +1569,19 @@ BOOL BtlCmd_BufferStatChangeMsg(BattleSystem *bsys, BattleContext *ctx) { } else { if (ctx->statChangeType == 3) { ctx->buffMsg.id = msg_0197_00622; //{0}'s {1} raised its {2} - ctx->buffMsg.tag = 39; + ctx->buffMsg.tag = TAG_NICKNAME_ABILITY_STAT; ctx->buffMsg.param[0] = CreateNicknameTag(ctx, ctx->battlerIdStatChange); ctx->buffMsg.param[1] = ctx->battleMons[ctx->battlerIdStatChange].ability; ctx->buffMsg.param[2] = stat + 1; } else if (ctx->statChangeType == 5) { ctx->buffMsg.id = msg_0197_00756; //The {1} raised {0}'s {2} - ctx->buffMsg.tag = 45; + ctx->buffMsg.tag = TAG_NICKNAME_ITEM_STAT; ctx->buffMsg.param[0] = CreateNicknameTag(ctx, ctx->battlerIdStatChange); ctx->buffMsg.param[1] = ctx->itemTemp; ctx->buffMsg.param[2] = stat + 1; } else { ctx->buffMsg.id = (change == 1) ? msg_0197_00750 : msg_0197_00753; //{0}'s {1} (sharply) rose! - ctx->buffMsg.tag = 12; + ctx->buffMsg.tag = TAG_NICKNAME_STAT; ctx->buffMsg.param[0] = CreateNicknameTag(ctx, ctx->battlerIdStatChange); ctx->buffMsg.param[1] = stat + 1; } @@ -1595,20 +1596,20 @@ BOOL BtlCmd_BufferStatChangeMsg(BattleSystem *bsys, BattleContext *ctx) { //Mist if(ctx->fieldSideConditionData[BattleSystem_GetFieldSide(bsys, ctx->battlerIdStatChange)].mistTurns) { ctx->buffMsg.id = msg_0197_00273; // {0} is protected by Mist! - ctx->buffMsg.tag = 2; + ctx->buffMsg.tag = TAG_NICKNAME; ctx->buffMsg.param[0] = CreateNicknameTag(ctx, ctx->battlerIdStatChange); unkD = 1; } else if (CheckBattlerAbilityIfNotIgnored(ctx, ctx->battlerIdAttacker, ctx->battlerIdStatChange, ABILITY_CLEAR_BODY) == TRUE || CheckBattlerAbilityIfNotIgnored(ctx, ctx->battlerIdAttacker, ctx->battlerIdStatChange, ABILITY_WHITE_SMOKE) == TRUE) { if (ctx->statChangeType == 3) { ctx->buffMsg.id = msg_0197_00727; //{0}'s {1} suppressed {2}'s {3} - ctx->buffMsg.tag = 53; + ctx->buffMsg.tag = TAG_NICKNAME_ABILITY_NICKNAME_ABILITY; ctx->buffMsg.param[0] = CreateNicknameTag(ctx, ctx->battlerIdStatChange); ctx->buffMsg.param[1] = ctx->battleMons[ctx->battlerIdStatChange].ability; ctx->buffMsg.param[2] = CreateNicknameTag(ctx, ctx->battlerIdAttacker); ctx->buffMsg.param[3] = ctx->battleMons[ctx->battlerIdAttacker].ability; } else { ctx->buffMsg.id = msg_0197_00669; //{0}'s {1} prevents stat loss! - ctx->buffMsg.tag = 11; + ctx->buffMsg.tag = TAG_NICKNAME_ABILITY; ctx->buffMsg.param[0] = CreateNicknameTag(ctx, ctx->battlerIdStatChange); ctx->buffMsg.param[1] = ctx->battleMons[ctx->battlerIdStatChange].ability; } @@ -1617,14 +1618,14 @@ BOOL BtlCmd_BufferStatChangeMsg(BattleSystem *bsys, BattleContext *ctx) { (CheckBattlerAbilityIfNotIgnored(ctx, ctx->battlerIdAttacker, ctx->battlerIdStatChange, ABILITY_HYPER_CUTTER) == TRUE && (1 + stat) == 1)) { if (ctx->statChangeType == 3) { ctx->buffMsg.id = msg_0197_00727; //{0}'s {1} suppressed {2}'s {3} - ctx->buffMsg.tag = 53; + ctx->buffMsg.tag = TAG_NICKNAME_ABILITY_NICKNAME_ABILITY; ctx->buffMsg.param[0] = CreateNicknameTag(ctx, ctx->battlerIdStatChange); ctx->buffMsg.param[1] = ctx->battleMons[ctx->battlerIdStatChange].ability; ctx->buffMsg.param[2] = CreateNicknameTag(ctx, ctx->battlerIdAttacker); ctx->buffMsg.param[3] = ctx->battleMons[ctx->battlerIdAttacker].ability; } else { ctx->buffMsg.id = msg_0197_00704; //{0}'s {1} prvents {2} loss! - ctx->buffMsg.tag = 39; + ctx->buffMsg.tag = TAG_NICKNAME_ABILITY_STAT; ctx->buffMsg.param[0] = CreateNicknameTag(ctx, ctx->battlerIdStatChange); ctx->buffMsg.param[1] = ctx->battleMons[ctx->battlerIdStatChange].ability; ctx->buffMsg.param[2] = stat + 1; @@ -1638,7 +1639,7 @@ BOOL BtlCmd_BufferStatChangeMsg(BattleSystem *bsys, BattleContext *ctx) { return FALSE; } else { ctx->buffMsg.id = msg_0197_00145; //{0}'s {1} won't go lower! - ctx->buffMsg.tag = 12; + ctx->buffMsg.tag = TAG_NICKNAME_STAT; ctx->buffMsg.param[0] = CreateNicknameTag(ctx, ctx->battlerIdStatChange); ctx->buffMsg.param[1] = stat + 1; BattleScriptIncrementPointer(ctx, unkA); @@ -1656,7 +1657,7 @@ BOOL BtlCmd_BufferStatChangeMsg(BattleSystem *bsys, BattleContext *ctx) { return FALSE; } else { ctx->buffMsg.id = msg_0197_00145; //{0}'s {1} won't go lower! - ctx->buffMsg.tag = 12; + ctx->buffMsg.tag = TAG_NICKNAME_STAT; ctx->buffMsg.param[0] = CreateNicknameTag(ctx, ctx->battlerIdStatChange); ctx->buffMsg.param[1] = stat + 1; BattleScriptIncrementPointer(ctx, unkA); @@ -1676,14 +1677,14 @@ BOOL BtlCmd_BufferStatChangeMsg(BattleSystem *bsys, BattleContext *ctx) { } if (ctx->statChangeType == 3) { ctx->buffMsg.id = msg_0197_00662; //{0}'s {1} cuts {2}'s {3} - ctx->buffMsg.tag = 54; + ctx->buffMsg.tag = TAG_NICKNAME_ABILITY_NICKNAME_STAT; ctx->buffMsg.param[0] = CreateNicknameTag(ctx, ctx->battlerIdAttacker); ctx->buffMsg.param[1] = ctx->battleMons[ctx->battlerIdAttacker].ability; ctx->buffMsg.param[2] = CreateNicknameTag(ctx, ctx->battlerIdStatChange); ctx->buffMsg.param[3] = stat + 1; } else { ctx->buffMsg.id = (change == -1) ? msg_0197_00762 : msg_0197_00765; //{0}'s {1} (harsly) fell! - ctx->buffMsg.tag = 12; + ctx->buffMsg.tag = TAG_NICKNAME_STAT; ctx->buffMsg.param[0] = CreateNicknameTag(ctx, ctx->battlerIdStatChange); ctx->buffMsg.param[1] = stat + 1; } @@ -2496,7 +2497,7 @@ BOOL BtlCmd_TryLightScreen(BattleSystem *bsys, BattleContext *ctx) { if (GetBattlerHeldItemEffect(ctx, ctx->battlerIdAttacker) == HOLD_EFFECT_EXTEND_SCREENS) { ctx->fieldSideConditionData[unkA].lightScreenTurns += GetHeldItemModifier(ctx, ctx->battlerIdAttacker, 0); } - ctx->buffMsg.tag = 20; + ctx->buffMsg.tag = TAG_MOVE_SIDE; ctx->buffMsg.param[0] = ctx->moveNoCur; ctx->buffMsg.param[1] = ctx->battlerIdAttacker; if (GetMonsHitCount(bsys, ctx, 1, ctx->battlerIdAttacker) == 2) { @@ -2525,7 +2526,7 @@ BOOL BtlCmd_TryReflect(BattleSystem *bsys, BattleContext *ctx) { if (GetBattlerHeldItemEffect(ctx, ctx->battlerIdAttacker) == HOLD_EFFECT_EXTEND_SCREENS) { ctx->fieldSideConditionData[unkA].reflectTurns += GetHeldItemModifier(ctx, ctx->battlerIdAttacker, 0); } - ctx->buffMsg.tag = 20; + ctx->buffMsg.tag = TAG_MOVE_SIDE; ctx->buffMsg.param[0] = ctx->moveNoCur; ctx->buffMsg.param[1] = ctx->battlerIdAttacker; if (GetMonsHitCount(bsys, ctx, 1, ctx->battlerIdAttacker) == 2) { @@ -3098,7 +3099,7 @@ BOOL BtlCmd_TryProtect(BattleSystem *bsys, BattleContext *ctx) { ctx->buffMsg.id = msg_0197_00442; } - ctx->buffMsg.tag = 2; + ctx->buffMsg.tag = TAG_NICKNAME; ctx->buffMsg.param[0] = CreateNicknameTag(ctx, ctx->battlerIdAttacker); if (ctx->battleMons[ctx->battlerIdAttacker].unk88.protectSuccessTurns < NELEMS(sProtectSuccessChance) - 1) { @@ -3491,7 +3492,7 @@ BOOL BtlCmd_TrySafeguard(BattleSystem *bsys, BattleContext *ctx) { ctx->fieldSideConditionFlags[fieldSide] |= SIDE_CONDITION_SAFEGUARD; ctx->fieldSideConditionData[fieldSide].safeguardTurns = 5; ctx->fieldSideConditionData[fieldSide].safeguardBattler = ctx->battlerIdAttacker; - ctx->buffMsg.tag = 1; + ctx->buffMsg.tag = TAG_NONE_SIDE; ctx->buffMsg.param[0] = ctx->battlerIdAttacker; ctx->buffMsg.id = msg_0197_00198; } @@ -3779,7 +3780,7 @@ BOOL BtlCmd_BeatUpDamageCalc(BattleSystem *bsys, BattleContext *ctx) { ctx->damage *= -1; ctx->buffMsg.id = msg_0197_00481; - ctx->buffMsg.tag = 2; + ctx->buffMsg.tag = TAG_NICKNAME; ctx->buffMsg.param[0] = (ctx->battlerIdAttacker | (ctx->beatUpCount << 8)); ctx->beatUpCount++; @@ -4015,13 +4016,13 @@ BOOL BtlCmd_TryKnockOff(BattleSystem *bsys, BattleContext *ctx) { if (ctx->battleMons[ctx->battlerIdTarget].item && CheckBattlerAbilityIfNotIgnored(ctx, ctx->battlerIdAttacker, ctx->battlerIdTarget, ABILITY_STICKY_HOLD) == TRUE) { ctx->buffMsg.id = msg_0197_00714; - ctx->buffMsg.tag = 37; + ctx->buffMsg.tag = TAG_NICKNAME_ABILITY_MOVE; ctx->buffMsg.param[0] = CreateNicknameTag(ctx, ctx->battlerIdTarget); ctx->buffMsg.param[1] = ctx->battleMons[ctx->battlerIdTarget].ability; ctx->buffMsg.param[2] = ctx->moveNoCur; } else if (ctx->battleMons[ctx->battlerIdTarget].item) { ctx->buffMsg.id = msg_0197_00552; - ctx->buffMsg.tag = 33; + ctx->buffMsg.tag = TAG_NICKNAME_NICKNAME_ITEM; ctx->buffMsg.param[0] = CreateNicknameTag(ctx, ctx->battlerIdAttacker); ctx->buffMsg.param[1] = CreateNicknameTag(ctx, ctx->battlerIdTarget); ctx->buffMsg.param[2] = ctx->battleMons[ctx->battlerIdTarget].item; @@ -6071,7 +6072,7 @@ static void Task_GetExp(SysTask *task, void *inData) } if (totalExp) { - msg.tag = 17; + msg.tag = TAG_NICKNAME_NUM; msg.param[0] = expBattler | (slot << 8); msg.param[1] = totalExp; data->unk30[0] = BattleSystem_PrintBattleMessage(data->bsys, msgLoader, &msg, BattleSystem_GetTextFrameDelay(data->bsys)); @@ -6149,7 +6150,7 @@ static void Task_GetExp(SysTask *task, void *inData) ov12_02263A1C(data->bsys, data->ctx, expBattler); msg.id = msg_0197_00003; // "{0} grew to Lv. {1}!" - msg.tag = 17; + msg.tag = TAG_NICKNAME_NUM; msg.param[0] = expBattler | (slot << 8); msg.param[1] = level; data->unk30[0] = BattleSystem_PrintBattleMessage(data->bsys, msgLoader, &msg, BattleSystem_GetTextFrameDelay(data->bsys)); @@ -6202,13 +6203,13 @@ static void Task_GetExp(SysTask *task, void *inData) for (i = 0; i < NUM_STATS; i++) { msg.id = msg_0197_00947; // stat name - msg.tag = 4; + msg.tag = TAG_STAT; msg.param[0] = stats.stats[i]; ov12_0223C4E8(data->bsys, window, msgLoader, &msg, 0, 16 * i, 0, 0, 0); msg.id = msg_0197_00948; // "+{0}" - msg.tag = 7; + msg.tag = TAG_NUMBERS; msg.param[0] = GetMonData(mon, monData.stats[i], NULL) - oldStats->stats[i]; msg.unk1C = 2; @@ -6226,7 +6227,7 @@ static void Task_GetExp(SysTask *task, void *inData) for (i = 0; i < NUM_STATS; i++) { msg.id = msg_0197_00949; // just a number - msg.tag = 7; + msg.tag = TAG_NUMBERS; msg.param[0] = GetMonData(mon, monData.stats[i], NULL); msg.unk1C = 3; @@ -6284,7 +6285,7 @@ static void Task_GetExp(SysTask *task, void *inData) } msg.id = msg_0197_00004; // "{0} learned {1}!" - msg.tag = 10; + msg.tag = TAG_NICKNAME_MOVE; msg.param[0] = expBattler | (slot << 8); msg.param[1] = move; data->unk30[0] = BattleSystem_PrintBattleMessage(data->bsys, msgLoader, &msg, BattleSystem_GetTextFrameDelay(data->bsys)); @@ -6296,7 +6297,7 @@ static void Task_GetExp(SysTask *task, void *inData) case STATE_GET_EXP_WANTS_TO_LEARN_MOVE_PRINT: msg.id = msg_0197_01178; // "{0} wants to learn the move {1}." - msg.tag = 10; + msg.tag = TAG_NICKNAME_MOVE; msg.param[0] = expBattler | (slot << 8); msg.param[1] = data->unk30[4]; data->unk30[0] = BattleSystem_PrintBattleMessage(data->bsys, msgLoader, &msg, BattleSystem_GetTextFrameDelay(data->bsys)); @@ -6305,7 +6306,7 @@ static void Task_GetExp(SysTask *task, void *inData) case STATE_GET_EXP_CANT_LEARN_MORE_MOVES_PRINT: msg.id = msg_0197_01179; // "But {0} can't learn more than four moves." - msg.tag = 2; + msg.tag = TAG_NICKNAME; msg.param[0] = expBattler | (slot << 8); data->unk30[0] = BattleSystem_PrintBattleMessage(data->bsys, msgLoader, &msg, BattleSystem_GetTextFrameDelay(data->bsys)); data->state++; @@ -6334,7 +6335,7 @@ static void Task_GetExp(SysTask *task, void *inData) data->state = STATE_GET_EXP_MAKE_IT_FORGET_CANCELLED; } else { msg.id = msg_0197_01183; // "Which move should be forgotten?" - msg.tag = 0; + msg.tag = TAG_NONE; data->unk30[0] = BattleSystem_PrintBattleMessage(data->bsys, msgLoader, &msg, BattleSystem_GetTextFrameDelay(data->bsys)); data->state = STATE_GET_EXP_MAKE_IT_FORGET_WAIT; } @@ -6359,7 +6360,7 @@ static void Task_GetExp(SysTask *task, void *inData) case STATE_GET_EXP_MAKE_IT_FORGET_CANCELLED: msg.id = msg_0197_01184; // "Well, then..." - msg.tag = 0; + msg.tag = TAG_NONE; data->unk30[0] = BattleSystem_PrintBattleMessage(data->bsys, msgLoader, &msg, BattleSystem_GetTextFrameDelay(data->bsys)); data->state++; break; @@ -6376,7 +6377,7 @@ static void Task_GetExp(SysTask *task, void *inData) data->state = STATE_GET_EXP_WANTS_TO_LEARN_MOVE_PRINT; } else { msg.id = msg_0197_01188; // "{0} did not learn {1}." - msg.tag = 10; + msg.tag = TAG_NICKNAME_MOVE; msg.param[0] = expBattler | (slot << 8); msg.param[1] = data->unk30[4]; data->unk30[0] = BattleSystem_PrintBattleMessage(data->bsys, msgLoader, &msg, BattleSystem_GetTextFrameDelay(data->bsys)); @@ -6401,7 +6402,7 @@ static void Task_GetExp(SysTask *task, void *inData) case STATE_GET_EXP_FORGOT_HOW_TO_USE: msg.id = msg_0197_01190; // "{0} forgot how to use {1}." - msg.tag = 10; + msg.tag = TAG_NICKNAME_MOVE; msg.param[0] = expBattler | (slot << 8); msg.param[1] = GetMonData(mon, MON_DATA_MOVE1 + data->unk30[5], NULL); data->unk30[0] = BattleSystem_PrintBattleMessage(data->bsys, msgLoader, &msg, BattleSystem_GetTextFrameDelay(data->bsys)); @@ -6410,14 +6411,14 @@ static void Task_GetExp(SysTask *task, void *inData) case STATE_GET_EXP_AND_DOTDOTDOT: msg.id = msg_0197_01191; // "And..." - msg.tag = 0; + msg.tag = TAG_NONE; data->unk30[0] = BattleSystem_PrintBattleMessage(data->bsys, msgLoader, &msg, BattleSystem_GetTextFrameDelay(data->bsys)); data->state++; break; case STATE_GET_EXP_LEARNED_MOVE: msg.id = msg_0197_01192; // "{0} learned {1}!" - msg.tag = 10; + msg.tag = TAG_NICKNAME_MOVE; msg.param[0] = expBattler | (slot << 8); msg.param[1] = data->unk30[4]; data->unk30[0] = BattleSystem_PrintBattleMessage(data->bsys, msgLoader, &msg, BattleSystem_GetTextFrameDelay(data->bsys)); diff --git a/src/battle/battle_controller_player.c b/src/battle/battle_controller_player.c index dd49abece7..31f8331ffc 100644 --- a/src/battle/battle_controller_player.c +++ b/src/battle/battle_controller_player.c @@ -7,6 +7,7 @@ #include "heap.h" #include "constants/abilities.h" #include "constants/items.h" +#include "constants/message_tags.h" #include "msgdata/msg/msg_0197.h" extern ControllerFunction sPlayerBattleCommands[]; @@ -280,7 +281,7 @@ void BattleControllerPlayer_SelectionScreenInput(BattleSystem *bsys, BattleConte ctx->unk_21A8[battlerId][0] = 21; } else if (BattleSystem_GetBattleType(bsys) & (BATTLE_TYPE_LINK | BATTLE_TYPE_TOWER)) { msg.id = msg_0197_00593; //Items can't be used here - msg.tag = 0; + msg.tag = TAG_NONE; ov12_022639B8(bsys, battlerId, msg); ctx->unk_0[battlerId] = SSI_STATE_15; ctx->unk_4[battlerId] = SSI_STATE_0; @@ -412,7 +413,7 @@ void BattleControllerPlayer_SelectionScreenInput(BattleSystem *bsys, BattleConte ov12_0223BFFC(bsys, 1); ov12_022581BC(bsys, BattleSystem_GetBattleContext(bsys)); } else { - msg.tag = 0; + msg.tag = TAG_NONE; msg.id = msg_0197_00793; //There's no running from a Trainer battle! ov12_022639B8(bsys, battlerId, msg); ctx->unk_0[battlerId] = SSI_STATE_15; @@ -474,7 +475,7 @@ void BattleControllerPlayer_SelectionScreenInput(BattleSystem *bsys, BattleConte } break; case SSI_STATE_NO_MOVES: - msg.tag = 2; + msg.tag = TAG_NICKNAME; msg.id = msg_0197_00608; //Spheal has no moves left! msg.param[0] = CreateNicknameTag(ctx, battlerId); ov12_022639B8(bsys, battlerId, msg); @@ -853,7 +854,7 @@ void BattleControllerPlayer_UpdateFieldCondition(BattleSystem *bsys, BattleConte if (ctx->fieldConditionData.wishTurns[side]) { if (--ctx->fieldConditionData.wishTurns[side] == 0 && ctx->battleMons[side].hp) { ctx->battlerIdTemp = side; - ctx->buffMsg.tag = 2; + ctx->buffMsg.tag = TAG_NICKNAME; ctx->buffMsg.id = msg_0197_00533; //Spheal's wish came true! ctx->buffMsg.param[0] = side | (ctx->fieldConditionData.wishTarget[side] << 8); ctx->hpCalc = DamageDivide(ctx->battleMons[side].maxHp, 2); @@ -877,7 +878,7 @@ void BattleControllerPlayer_UpdateFieldCondition(BattleSystem *bsys, BattleConte if (ctx->fieldCondition & FIELD_CONDITION_RAIN_ALL) { if (ctx->fieldCondition & FIELD_CONDITION_RAIN_PERMANENT) { ctx->buffMsg.id = msg_0197_00801; //Rain continues to fall. - ctx->buffMsg.tag = 0; + ctx->buffMsg.tag = TAG_NONE; ReadBattleScriptFromNarc(ctx, NARC_a_0_0_1, 104); ctx->commandNext = ctx->command; ctx->command = CONTROLLER_COMMAND_RUN_SCRIPT; @@ -887,7 +888,7 @@ void BattleControllerPlayer_UpdateFieldCondition(BattleSystem *bsys, BattleConte ctx->command = CONTROLLER_COMMAND_RUN_SCRIPT; } else { ctx->buffMsg.id = msg_0197_00801; //Rain continues to fall. - ctx->buffMsg.tag = 0; + ctx->buffMsg.tag = TAG_NONE; ReadBattleScriptFromNarc(ctx, NARC_a_0_0_1, 104); ctx->commandNext = ctx->command; ctx->command = CONTROLLER_COMMAND_RUN_SCRIPT; @@ -901,7 +902,7 @@ void BattleControllerPlayer_UpdateFieldCondition(BattleSystem *bsys, BattleConte if (ctx->fieldCondition & FIELD_CONDITION_SANDSTORM_ALL) { if (ctx->fieldCondition & FIELD_CONDITION_SANDSTORM_PERMANENT) { ctx->buffMsg.id = msg_0197_00805; //The sandstorm rages. - ctx->buffMsg.tag = 0; + ctx->buffMsg.tag = TAG_NONE; ReadBattleScriptFromNarc(ctx, NARC_a_0_0_1, 104); ctx->commandNext = ctx->command; ctx->command = CONTROLLER_COMMAND_RUN_SCRIPT; @@ -911,7 +912,7 @@ void BattleControllerPlayer_UpdateFieldCondition(BattleSystem *bsys, BattleConte ctx->command = CONTROLLER_COMMAND_RUN_SCRIPT; } else { ctx->buffMsg.id = msg_0197_00805; //The sandstorm rages. - ctx->buffMsg.tag = 0; + ctx->buffMsg.tag = TAG_NONE; ReadBattleScriptFromNarc(ctx, NARC_a_0_0_1, 104); ctx->commandNext = ctx->command; ctx->command = CONTROLLER_COMMAND_RUN_SCRIPT; @@ -925,7 +926,7 @@ void BattleControllerPlayer_UpdateFieldCondition(BattleSystem *bsys, BattleConte if (ctx->fieldCondition & FIELD_CONDITION_SUN_ALL) { if (ctx->fieldCondition & FIELD_CONDITION_SUN_PERMANENT) { ctx->buffMsg.id = msg_0197_00808; //The sunlight is strong. - ctx->buffMsg.tag = 0; + ctx->buffMsg.tag = TAG_NONE; ReadBattleScriptFromNarc(ctx, NARC_a_0_0_1, 104); ctx->commandNext = ctx->command; ctx->command = CONTROLLER_COMMAND_RUN_SCRIPT; @@ -935,7 +936,7 @@ void BattleControllerPlayer_UpdateFieldCondition(BattleSystem *bsys, BattleConte ctx->command = CONTROLLER_COMMAND_RUN_SCRIPT; } else { ctx->buffMsg.id = msg_0197_00808; //The sunlight is strong. - ctx->buffMsg.tag = 0; + ctx->buffMsg.tag = TAG_NONE; ReadBattleScriptFromNarc(ctx, NARC_a_0_0_1, 104); ctx->commandNext = ctx->command; ctx->command = CONTROLLER_COMMAND_RUN_SCRIPT; @@ -949,7 +950,7 @@ void BattleControllerPlayer_UpdateFieldCondition(BattleSystem *bsys, BattleConte if (ctx->fieldCondition & FIELD_CONDITION_HAIL_ALL) { if (ctx->fieldCondition & FIELD_CONDITION_HAIL_PERMANENT) { ctx->buffMsg.id = msg_0197_00811; //Hail continues to fall. - ctx->buffMsg.tag = 0; + ctx->buffMsg.tag = TAG_NONE; ReadBattleScriptFromNarc(ctx, NARC_a_0_0_1, 104); ctx->commandNext = ctx->command; ctx->command = CONTROLLER_COMMAND_RUN_SCRIPT; @@ -959,7 +960,7 @@ void BattleControllerPlayer_UpdateFieldCondition(BattleSystem *bsys, BattleConte ctx->command = CONTROLLER_COMMAND_RUN_SCRIPT; } else { ctx->buffMsg.id = msg_0197_00811; //Hail continues to fall. - ctx->buffMsg.tag = 0; + ctx->buffMsg.tag = TAG_NONE; ReadBattleScriptFromNarc(ctx, NARC_a_0_0_1, 104); ctx->commandNext = ctx->command; ctx->command = CONTROLLER_COMMAND_RUN_SCRIPT; @@ -972,7 +973,7 @@ void BattleControllerPlayer_UpdateFieldCondition(BattleSystem *bsys, BattleConte case UFC_STATE_FOG: if (ctx->fieldCondition & FIELD_CONDITION_FOG) { ctx->buffMsg.id = msg_0197_00813; //The fog is deep... - ctx->buffMsg.tag = 0; + ctx->buffMsg.tag = TAG_NONE; ReadBattleScriptFromNarc(ctx, NARC_a_0_0_1, 104); ctx->commandNext = ctx->command; ctx->command = CONTROLLER_COMMAND_RUN_SCRIPT; @@ -1463,7 +1464,7 @@ void BattleControllerPlayer_UpdateFieldConditionExtra(BattleSystem *bsys, Battle if (!(--ctx->fieldConditionData.futureSightTurns[battlerId]) && ctx->battleMons[battlerId].hp) { ctx->fieldSideConditionFlags[BattleSystem_GetFieldSide(bsys, battlerId)] &= ~SIDE_CONDITION_FUTURE_SIGHT; ctx->buffMsg.id = msg_0197_00475; //Seadra took the Doom Desire attack! - ctx->buffMsg.tag = 10; + ctx->buffMsg.tag = TAG_NICKNAME_MOVE; ctx->buffMsg.param[0] = CreateNicknameTag(ctx, battlerId); ctx->buffMsg.param[1] = ctx->fieldConditionData.futureSightMoveNo[battlerId]; ctx->battlerIdTemp = battlerId; diff --git a/src/battle/overlay_12_0224E4FC.c b/src/battle/overlay_12_0224E4FC.c index 43f58a20ce..687e43fd66 100644 --- a/src/battle/overlay_12_0224E4FC.c +++ b/src/battle/overlay_12_0224E4FC.c @@ -16,6 +16,7 @@ #include "constants/items.h" #include "constants/moves.h" #include "constants/species.h" +#include "constants/message_tags.h" #include "constants/move_effects.h" #include "msgdata/msg/msg_0197.h" @@ -2040,49 +2041,49 @@ BOOL ov12_02251A28(BattleSystem *bsys, BattleContext *ctx, int battlerId, int mo BOOL ret = TRUE; if (StruggleCheck(bsys, ctx, battlerId, 0, STRUGGLE_CHECK_DISABLED) & MaskOfFlagNo(movePos)) { - msg->tag = 10; + msg->tag = TAG_NICKNAME_MOVE; msg->id = msg_0197_00609; msg->param[0] = CreateNicknameTag(ctx, battlerId); msg->param[1] = ctx->battleMons[battlerId].moves[movePos]; ret = FALSE; } else if (StruggleCheck(bsys, ctx, battlerId, 0, STRUGGLE_CHECK_TORMENT) & MaskOfFlagNo(movePos)) { - msg->tag = 2; + msg->tag = TAG_NICKNAME; msg->id = msg_0197_00612; msg->param[0] = CreateNicknameTag(ctx, battlerId); ret = FALSE; } else if (StruggleCheck(bsys, ctx, battlerId, 0, STRUGGLE_CHECK_TAUNT) & MaskOfFlagNo(movePos)) { - msg->tag = 10; + msg->tag = TAG_NICKNAME_MOVE; msg->id = msg_0197_00613; msg->param[0] = CreateNicknameTag(ctx, battlerId); msg->param[1] = ctx->battleMons[battlerId].moves[movePos]; ret = FALSE; } else if (StruggleCheck(bsys, ctx, battlerId, 0, STRUGGLE_CHECK_IMPRISON) & MaskOfFlagNo(movePos)) { - msg->tag = 10; + msg->tag = TAG_NICKNAME_MOVE; msg->id = msg_0197_00616; msg->param[0] = CreateNicknameTag(ctx, battlerId); msg->param[1] = ctx->battleMons[battlerId].moves[movePos]; ret = FALSE; } else if (StruggleCheck(bsys, ctx, battlerId, 0, STRUGGLE_CHECK_GRAVITY) & MaskOfFlagNo(movePos)) { - msg->tag = 10; + msg->tag = TAG_NICKNAME_MOVE; msg->id = msg_0197_01001; msg->param[0] = CreateNicknameTag(ctx, battlerId); msg->param[1] = ctx->battleMons[battlerId].moves[movePos]; ret = FALSE; } else if (StruggleCheck(bsys, ctx, battlerId, 0, STRUGGLE_CHECK_HEAL_BLOCK) & MaskOfFlagNo(movePos)) { - msg->tag = 34; + msg->tag = TAG_NICKNAME_MOVE_MOVE; msg->id = msg_0197_01057; msg->param[0] = CreateNicknameTag(ctx, battlerId); msg->param[1] = MOVE_HEAL_BLOCK; msg->param[2] = ctx->battleMons[battlerId].moves[movePos]; ret = FALSE; } else if (StruggleCheck(bsys, ctx, battlerId, 0, STRUGGLE_CHECK_CHOICED) & MaskOfFlagNo(movePos)) { - msg->tag = 24; + msg->tag = TAG_ITEM_MOVE; msg->id = msg_0197_00911; msg->param[0] = ctx->battleMons[battlerId].item; msg->param[1] = ctx->battleMons[battlerId].unk88.moveNoChoice; ret = FALSE; } else if (StruggleCheck(bsys, ctx, battlerId, 0, STRUGGLE_CHECK_NO_PP) & MaskOfFlagNo(movePos)) { - msg->tag = 0; + msg->tag = TAG_NONE; msg->id = msg_0197_00823; ret = FALSE; } @@ -2781,7 +2782,7 @@ BOOL CantEscape(BattleSystem *bsys, BattleContext *ctx, int battlerId, BattleMes if (msg == NULL) { return TRUE; } - msg->tag = 11; + msg->tag = TAG_NICKNAME_ABILITY; msg->id = msg_0197_00039; msg->param[0] = CreateNicknameTag(ctx, battlerIdAbility); msg->param[1] = ABILITY_SHADOW_TAG; @@ -2796,7 +2797,7 @@ BOOL CantEscape(BattleSystem *bsys, BattleContext *ctx, int battlerId, BattleMes if (msg == NULL) { return TRUE; } - msg->tag = 11; + msg->tag = TAG_NICKNAME_ABILITY; msg->id = msg_0197_00039; msg->param[0] = CreateNicknameTag(ctx, battlerIdAbility); msg->param[1] = ABILITY_ARENA_TRAP; @@ -2806,7 +2807,7 @@ BOOL CantEscape(BattleSystem *bsys, BattleContext *ctx, int battlerId, BattleMes if (msg == NULL) { return TRUE; } - msg->tag = 11; + msg->tag = TAG_NICKNAME_ABILITY; msg->id = msg_0197_00039; msg->param[0] = CreateNicknameTag(ctx, battlerIdAbility); msg->param[1] = ABILITY_ARENA_TRAP; @@ -2819,7 +2820,7 @@ BOOL CantEscape(BattleSystem *bsys, BattleContext *ctx, int battlerId, BattleMes if (msg == NULL) { return TRUE; } - msg->tag = 11; + msg->tag = TAG_NICKNAME_ABILITY; msg->id = msg_0197_00039; msg->param[0] = CreateNicknameTag(ctx, battlerIdAbility); msg->param[1] = ABILITY_MAGNET_PULL; @@ -2830,7 +2831,7 @@ BOOL CantEscape(BattleSystem *bsys, BattleContext *ctx, int battlerId, BattleMes if (msg == NULL) { return TRUE; } - msg->tag = 0; + msg->tag = TAG_NONE; msg->id = msg_0197_00794; return TRUE; } From 35201982a65f2ece38d876f1cfc60a68fba30585 Mon Sep 17 00:00:00 2001 From: Adrienn Tindall <33725376+adrienntindall@users.noreply.github.com> Date: Tue, 19 Dec 2023 02:11:10 -0500 Subject: [PATCH 23/33] Document battle_system static functions --- asm/overlay_12_battle_system.s | 630 ++++++++++----------------------- src/battle/battle_system.c | 135 +++++++ 2 files changed, 318 insertions(+), 447 deletions(-) diff --git a/asm/overlay_12_battle_system.s b/asm/overlay_12_battle_system.s index efcccc8b6e..23201048bf 100644 --- a/asm/overlay_12_battle_system.s +++ b/asm/overlay_12_battle_system.s @@ -6,270 +6,6 @@ .text - thumb_func_start ov12_0223C558 -ov12_0223C558: ; 0x0223C558 - push {r4, r5, r6, lr} - add r4, r1, #0 - add r6, r0, #0 - bl BattleSystem_GetBattleType - add r5, r0, #0 - ldrb r0, [r4, #1] - mov r1, #0x80 - tst r1, r0 - bne _0223C57E - mov r1, #0x40 - tst r1, r0 - beq _0223C588 - ldr r1, [r4, #0x20] - add r0, r6, #0 - bl BattleSystem_GetFieldSide - cmp r0, #0 - bne _0223C580 -_0223C57E: - b _0223C752 -_0223C580: - ldrh r0, [r4, #2] - add r0, r0, #1 - strh r0, [r4, #2] - pop {r4, r5, r6, pc} -_0223C588: - mov r1, #0x3f - and r0, r1 - cmp r0, #0x3c - bls _0223C592 - b _0223C74E -_0223C592: - add r0, r0, r0 - add r0, pc - ldrh r0, [r0, #6] - lsl r0, r0, #0x10 - asr r0, r0, #0x10 - add pc, r0 -_0223C59E: ; jump table - .short _0223C752 - _0223C59E - 2 ; case 0 - .short _0223C618 - _0223C59E - 2 ; case 1 - .short _0223C630 - _0223C59E - 2 ; case 2 - .short _0223C752 - _0223C59E - 2 ; case 3 - .short _0223C752 - _0223C59E - 2 ; case 4 - .short _0223C752 - _0223C59E - 2 ; case 5 - .short _0223C752 - _0223C59E - 2 ; case 6 - .short _0223C752 - _0223C59E - 2 ; case 7 - .short _0223C752 - _0223C59E - 2 ; case 8 - .short _0223C692 - _0223C59E - 2 ; case 9 - .short _0223C630 - _0223C59E - 2 ; case 10 - .short _0223C630 - _0223C59E - 2 ; case 11 - .short _0223C630 - _0223C59E - 2 ; case 12 - .short _0223C630 - _0223C59E - 2 ; case 13 - .short _0223C630 - _0223C59E - 2 ; case 14 - .short _0223C630 - _0223C59E - 2 ; case 15 - .short _0223C630 - _0223C59E - 2 ; case 16 - .short _0223C630 - _0223C59E - 2 ; case 17 - .short _0223C630 - _0223C59E - 2 ; case 18 - .short _0223C630 - _0223C59E - 2 ; case 19 - .short _0223C656 - _0223C59E - 2 ; case 20 - .short _0223C66E - _0223C59E - 2 ; case 21 - .short _0223C752 - _0223C59E - 2 ; case 22 - .short _0223C66E - _0223C59E - 2 ; case 23 - .short _0223C752 - _0223C59E - 2 ; case 24 - .short _0223C752 - _0223C59E - 2 ; case 25 - .short _0223C752 - _0223C59E - 2 ; case 26 - .short _0223C752 - _0223C59E - 2 ; case 27 - .short _0223C752 - _0223C59E - 2 ; case 28 - .short _0223C752 - _0223C59E - 2 ; case 29 - .short _0223C752 - _0223C59E - 2 ; case 30 - .short _0223C692 - _0223C59E - 2 ; case 31 - .short _0223C692 - _0223C59E - 2 ; case 32 - .short _0223C692 - _0223C59E - 2 ; case 33 - .short _0223C630 - _0223C59E - 2 ; case 34 - .short _0223C630 - _0223C59E - 2 ; case 35 - .short _0223C6F0 - _0223C59E - 2 ; case 36 - .short _0223C630 - _0223C59E - 2 ; case 37 - .short _0223C630 - _0223C59E - 2 ; case 38 - .short _0223C630 - _0223C59E - 2 ; case 39 - .short _0223C630 - _0223C59E - 2 ; case 40 - .short _0223C630 - _0223C59E - 2 ; case 41 - .short _0223C630 - _0223C59E - 2 ; case 42 - .short _0223C6F0 - _0223C59E - 2 ; case 43 - .short _0223C630 - _0223C59E - 2 ; case 44 - .short _0223C630 - _0223C59E - 2 ; case 45 - .short _0223C630 - _0223C59E - 2 ; case 46 - .short _0223C630 - _0223C59E - 2 ; case 47 - .short _0223C66E - _0223C59E - 2 ; case 48 - .short _0223C752 - _0223C59E - 2 ; case 49 - .short _0223C752 - _0223C59E - 2 ; case 50 - .short _0223C752 - _0223C59E - 2 ; case 51 - .short _0223C6F0 - _0223C59E - 2 ; case 52 - .short _0223C6F0 - _0223C59E - 2 ; case 53 - .short _0223C6F0 - _0223C59E - 2 ; case 54 - .short _0223C6F0 - _0223C59E - 2 ; case 55 - .short _0223C752 - _0223C59E - 2 ; case 56 - .short _0223C752 - _0223C59E - 2 ; case 57 - .short _0223C752 - _0223C59E - 2 ; case 58 - .short _0223C752 - _0223C59E - 2 ; case 59 - .short _0223C752 - _0223C59E - 2 ; case 60 -_0223C618: - ldr r1, [r4, #4] - add r0, r6, #0 - lsl r1, r1, #0x18 - lsr r1, r1, #0x18 - bl BattleSystem_GetFieldSide - cmp r0, #0 - beq _0223C64C - ldrh r0, [r4, #2] - add r0, r0, #1 - strh r0, [r4, #2] - pop {r4, r5, r6, pc} -_0223C630: - ldr r1, [r4, #4] - add r0, r6, #0 - lsl r1, r1, #0x18 - lsr r1, r1, #0x18 - bl BattleSystem_GetFieldSide - cmp r0, #0 - beq _0223C64C - ldrh r0, [r4, #2] - add r0, r0, #1 - strh r0, [r4, #2] - mov r0, #1 - tst r0, r5 - bne _0223C64E -_0223C64C: - b _0223C752 -_0223C64E: - ldrh r0, [r4, #2] - add r0, r0, #1 - strh r0, [r4, #2] - pop {r4, r5, r6, pc} -_0223C656: - ldr r1, [r4, #8] - add r0, r6, #0 - lsl r1, r1, #0x18 - lsr r1, r1, #0x18 - bl BattleSystem_GetFieldSide - cmp r0, #0 - beq _0223C752 - ldrh r0, [r4, #2] - add r0, r0, #1 - strh r0, [r4, #2] - pop {r4, r5, r6, pc} -_0223C66E: - ldr r1, [r4, #8] - add r0, r6, #0 - lsl r1, r1, #0x18 - lsr r1, r1, #0x18 - bl BattleSystem_GetFieldSide - cmp r0, #0 - beq _0223C752 - ldrh r0, [r4, #2] - add r0, r0, #1 - strh r0, [r4, #2] - mov r0, #1 - tst r0, r5 - beq _0223C752 - ldrh r0, [r4, #2] - add r0, r0, #1 - strh r0, [r4, #2] - pop {r4, r5, r6, pc} -_0223C692: - ldr r1, [r4, #4] - add r0, r6, #0 - lsl r1, r1, #0x18 - lsr r1, r1, #0x18 - bl BattleSystem_GetFieldSide - cmp r0, #0 - beq _0223C6CC - ldrh r0, [r4, #2] - add r0, r0, #3 - strh r0, [r4, #2] - mov r0, #1 - tst r0, r5 - beq _0223C6B4 - ldrh r0, [r4, #2] - add r0, r0, #2 - strh r0, [r4, #2] -_0223C6B4: - ldr r1, [r4, #8] - add r0, r6, #0 - lsl r1, r1, #0x18 - lsr r1, r1, #0x18 - bl BattleSystem_GetFieldSide - cmp r0, #0 - beq _0223C752 - ldrh r0, [r4, #2] - add r0, r0, #1 - strh r0, [r4, #2] - pop {r4, r5, r6, pc} -_0223C6CC: - ldr r1, [r4, #8] - add r0, r6, #0 - lsl r1, r1, #0x18 - lsr r1, r1, #0x18 - bl BattleSystem_GetFieldSide - cmp r0, #0 - beq _0223C752 - ldrh r0, [r4, #2] - add r0, r0, #1 - strh r0, [r4, #2] - mov r0, #1 - tst r0, r5 - beq _0223C752 - ldrh r0, [r4, #2] - add r0, r0, #1 - strh r0, [r4, #2] - pop {r4, r5, r6, pc} -_0223C6F0: - ldr r1, [r4, #4] - add r0, r6, #0 - lsl r1, r1, #0x18 - lsr r1, r1, #0x18 - bl BattleSystem_GetFieldSide - cmp r0, #0 - beq _0223C72A - ldrh r0, [r4, #2] - add r0, r0, #3 - strh r0, [r4, #2] - mov r0, #1 - tst r0, r5 - beq _0223C712 - ldrh r0, [r4, #2] - add r0, r0, #2 - strh r0, [r4, #2] -_0223C712: - ldr r1, [r4, #0xc] - add r0, r6, #0 - lsl r1, r1, #0x18 - lsr r1, r1, #0x18 - bl BattleSystem_GetFieldSide - cmp r0, #0 - beq _0223C752 - ldrh r0, [r4, #2] - add r0, r0, #1 - strh r0, [r4, #2] - pop {r4, r5, r6, pc} -_0223C72A: - ldr r1, [r4, #0xc] - add r0, r6, #0 - lsl r1, r1, #0x18 - lsr r1, r1, #0x18 - bl BattleSystem_GetFieldSide - cmp r0, #0 - beq _0223C752 - ldrh r0, [r4, #2] - add r0, r0, #1 - strh r0, [r4, #2] - mov r0, #1 - tst r0, r5 - beq _0223C752 - ldrh r0, [r4, #2] - add r0, r0, #1 - strh r0, [r4, #2] - pop {r4, r5, r6, pc} -_0223C74E: - bl GF_AssertFail -_0223C752: - pop {r4, r5, r6, pc} - thumb_func_end ov12_0223C558 - thumb_func_start ov12_0223C754 ov12_0223C754: ; 0x0223C754 push {r3, r4, r5, lr} @@ -353,218 +89,218 @@ _0223C772: ; jump table _0223C7EC: ldr r2, [r4, #4] mov r1, #0 - bl ov12_0223CDD0 + bl BattleMessage_BufferNickname pop {r3, r4, r5, pc} _0223C7F6: ldr r2, [r4, #4] mov r1, #0 - bl ov12_0223CDF4 + bl BattleMessage_BufferMove pop {r3, r4, r5, pc} _0223C800: ldr r2, [r4, #4] mov r1, #0 - bl ov12_0223CE68 + bl BattleMessage_BufferStat pop {r3, r4, r5, pc} _0223C80A: ldr r2, [r4, #4] mov r1, #0 - bl ov12_0223CE00 + bl BattleMessage_BufferItem pop {r3, r4, r5, pc} _0223C814: ldr r2, [r4, #4] mov r1, #0 - bl ov12_0223CE0C + bl BattleMessage_BufferNumber pop {r3, r4, r5, pc} _0223C81E: ldr r2, [r4, #4] ldr r3, [r4, #0x1c] mov r1, #0 - bl ov12_0223CE24 + bl BattleMessage_BufferNumbers pop {r3, r4, r5, pc} _0223C82A: ldr r2, [r4, #4] mov r1, #0 - bl ov12_0223CECC + bl BattleMessage_BufferTrainerName pop {r3, r4, r5, pc} _0223C834: ldr r2, [r4, #4] mov r1, #0 - bl ov12_0223CDD0 + bl BattleMessage_BufferNickname ldr r2, [r4, #8] add r0, r5, #0 mov r1, #1 - bl ov12_0223CDD0 + bl BattleMessage_BufferNickname pop {r3, r4, r5, pc} _0223C848: ldr r2, [r4, #4] mov r1, #0 - bl ov12_0223CDD0 + bl BattleMessage_BufferNickname ldr r2, [r4, #8] add r0, r5, #0 mov r1, #1 - bl ov12_0223CDF4 + bl BattleMessage_BufferMove pop {r3, r4, r5, pc} _0223C85C: ldr r2, [r4, #4] mov r1, #0 - bl ov12_0223CDD0 + bl BattleMessage_BufferNickname ldr r2, [r4, #8] add r0, r5, #0 mov r1, #1 - bl ov12_0223CE5C + bl BattleMessage_BufferAbility pop {r3, r4, r5, pc} _0223C870: ldr r2, [r4, #4] mov r1, #0 - bl ov12_0223CDD0 + bl BattleMessage_BufferNickname ldr r2, [r4, #8] add r0, r5, #0 mov r1, #1 - bl ov12_0223CE68 + bl BattleMessage_BufferStat pop {r3, r4, r5, pc} _0223C884: ldr r2, [r4, #4] mov r1, #0 - bl ov12_0223CDD0 + bl BattleMessage_BufferNickname ldr r2, [r4, #8] add r0, r5, #0 mov r1, #1 - bl ov12_0223CE50 + bl BattleMessage_BufferType pop {r3, r4, r5, pc} _0223C898: ldr r2, [r4, #4] mov r1, #0 - bl ov12_0223CDD0 + bl BattleMessage_BufferNickname ldr r2, [r4, #8] add r0, r5, #0 mov r1, #1 - bl ov12_0223CE80 + bl BattleMessage_BufferPokemon pop {r3, r4, r5, pc} _0223C8AC: ldr r2, [r4, #4] mov r1, #0 - bl ov12_0223CDD0 + bl BattleMessage_BufferNickname ldr r2, [r4, #8] add r0, r5, #0 mov r1, #1 - bl ov12_0223CE00 + bl BattleMessage_BufferItem pop {r3, r4, r5, pc} _0223C8C0: ldr r2, [r4, #4] mov r1, #0 - bl ov12_0223CDD0 + bl BattleMessage_BufferNickname ldr r2, [r4, #8] add r0, r5, #0 mov r1, #1 - bl ov12_0223CEA4 + bl BattleMessage_BufferPoffin pop {r3, r4, r5, pc} _0223C8D4: ldr r2, [r4, #4] mov r1, #0 - bl ov12_0223CDD0 + bl BattleMessage_BufferNickname ldr r2, [r4, #8] add r0, r5, #0 mov r1, #1 - bl ov12_0223CE0C + bl BattleMessage_BufferNumber pop {r3, r4, r5, pc} _0223C8E8: ldr r2, [r4, #4] mov r1, #0 - bl ov12_0223CDD0 + bl BattleMessage_BufferNickname ldr r2, [r4, #8] add r0, r5, #0 mov r1, #1 - bl ov12_0223CECC + bl BattleMessage_BufferTrainerName pop {r3, r4, r5, pc} _0223C8FC: ldr r2, [r4, #4] mov r1, #0 - bl ov12_0223CDD0 + bl BattleMessage_BufferNickname ldr r2, [r4, #8] add r0, r5, #0 mov r1, #1 - bl ov12_0223CEE4 + bl BattleMessage_BufferBoxName pop {r3, r4, r5, pc} _0223C910: ldr r2, [r4, #4] mov r1, #0 - bl ov12_0223CDF4 + bl BattleMessage_BufferMove ldr r2, [r4, #8] add r0, r5, #0 mov r1, #1 - bl ov12_0223CDD0 + bl BattleMessage_BufferNickname pop {r3, r4, r5, pc} _0223C924: ldr r2, [r4, #4] mov r1, #0 - bl ov12_0223CDF4 + bl BattleMessage_BufferMove ldr r2, [r4, #8] add r0, r5, #0 mov r1, #1 - bl ov12_0223CDF4 + bl BattleMessage_BufferMove pop {r3, r4, r5, pc} _0223C938: ldr r2, [r4, #4] mov r1, #0 - bl ov12_0223CE5C + bl BattleMessage_BufferAbility ldr r2, [r4, #8] add r0, r5, #0 mov r1, #1 - bl ov12_0223CDD0 + bl BattleMessage_BufferNickname pop {r3, r4, r5, pc} _0223C94C: ldr r2, [r4, #4] mov r1, #0 - bl ov12_0223CE00 + bl BattleMessage_BufferItem ldr r2, [r4, #8] add r0, r5, #0 mov r1, #1 - bl ov12_0223CDF4 + bl BattleMessage_BufferMove pop {r3, r4, r5, pc} _0223C960: ldr r2, [r4, #4] mov r1, #0 - bl ov12_0223CE0C + bl BattleMessage_BufferNumber ldr r2, [r4, #8] add r0, r5, #0 mov r1, #1 - bl ov12_0223CE0C + bl BattleMessage_BufferNumber pop {r3, r4, r5, pc} _0223C974: ldr r2, [r4, #4] mov r1, #0 - bl ov12_0223CECC + bl BattleMessage_BufferTrainerName ldr r2, [r4, #8] add r0, r5, #0 mov r1, #1 - bl ov12_0223CECC + bl BattleMessage_BufferTrainerName pop {r3, r4, r5, pc} _0223C988: ldr r2, [r4, #4] mov r1, #0 - bl ov12_0223CECC + bl BattleMessage_BufferTrainerName ldr r2, [r4, #8] add r0, r5, #0 mov r1, #1 - bl ov12_0223CDD0 + bl BattleMessage_BufferNickname pop {r3, r4, r5, pc} _0223C99C: ldr r2, [r4, #4] mov r1, #0 - bl ov12_0223CECC + bl BattleMessage_BufferTrainerName ldr r2, [r4, #8] add r0, r5, #0 mov r1, #1 - bl ov12_0223CE00 + bl BattleMessage_BufferItem pop {r3, r4, r5, pc} _0223C9B0: ldr r2, [r4, #4] mov r1, #0 - bl ov12_0223CECC + bl BattleMessage_BufferTrainerName ldr r2, [r4, #8] add r0, r5, #0 mov r1, #1 - bl ov12_0223CE0C + bl BattleMessage_BufferNumber pop {r3, r4, r5, pc} _0223C9C4: ldr r2, [r4, #4] @@ -573,254 +309,254 @@ _0223C9C4: ldr r2, [r4, #8] add r0, r5, #0 mov r1, #1 - bl ov12_0223CECC + bl BattleMessage_BufferTrainerName pop {r3, r4, r5, pc} _0223C9D8: ldr r2, [r4, #4] mov r1, #0 - bl ov12_0223CDD0 + bl BattleMessage_BufferNickname ldr r2, [r4, #8] add r0, r5, #0 mov r1, #1 - bl ov12_0223CDD0 + bl BattleMessage_BufferNickname ldr r2, [r4, #0xc] add r0, r5, #0 mov r1, #2 - bl ov12_0223CDF4 + bl BattleMessage_BufferMove pop {r3, r4, r5, pc} _0223C9F6: ldr r2, [r4, #4] mov r1, #0 - bl ov12_0223CDD0 + bl BattleMessage_BufferNickname ldr r2, [r4, #8] add r0, r5, #0 mov r1, #1 - bl ov12_0223CDD0 + bl BattleMessage_BufferNickname ldr r2, [r4, #0xc] add r0, r5, #0 mov r1, #2 - bl ov12_0223CE5C + bl BattleMessage_BufferAbility pop {r3, r4, r5, pc} _0223CA14: ldr r2, [r4, #4] mov r1, #0 - bl ov12_0223CDD0 + bl BattleMessage_BufferNickname ldr r2, [r4, #8] add r0, r5, #0 mov r1, #1 - bl ov12_0223CDD0 + bl BattleMessage_BufferNickname ldr r2, [r4, #0xc] add r0, r5, #0 mov r1, #2 - bl ov12_0223CE00 + bl BattleMessage_BufferItem pop {r3, r4, r5, pc} _0223CA32: ldr r2, [r4, #4] mov r1, #0 - bl ov12_0223CDD0 + bl BattleMessage_BufferNickname ldr r2, [r4, #8] add r0, r5, #0 mov r1, #1 - bl ov12_0223CDF4 + bl BattleMessage_BufferMove ldr r2, [r4, #0xc] add r0, r5, #0 mov r1, #2 - bl ov12_0223CDF4 + bl BattleMessage_BufferMove pop {r3, r4, r5, pc} _0223CA50: ldr r2, [r4, #4] mov r1, #0 - bl ov12_0223CDD0 + bl BattleMessage_BufferNickname ldr r2, [r4, #8] add r0, r5, #0 mov r1, #1 - bl ov12_0223CDF4 + bl BattleMessage_BufferMove ldr r2, [r4, #0xc] add r0, r5, #0 mov r1, #2 - bl ov12_0223CE0C + bl BattleMessage_BufferNumber pop {r3, r4, r5, pc} _0223CA6E: ldr r2, [r4, #4] mov r1, #0 - bl ov12_0223CDD0 + bl BattleMessage_BufferNickname ldr r2, [r4, #8] add r0, r5, #0 mov r1, #1 - bl ov12_0223CE5C + bl BattleMessage_BufferAbility ldr r2, [r4, #0xc] add r0, r5, #0 mov r1, #2 - bl ov12_0223CDD0 + bl BattleMessage_BufferNickname pop {r3, r4, r5, pc} _0223CA8C: ldr r2, [r4, #4] mov r1, #0 - bl ov12_0223CDD0 + bl BattleMessage_BufferNickname ldr r2, [r4, #8] add r0, r5, #0 mov r1, #1 - bl ov12_0223CE5C + bl BattleMessage_BufferAbility ldr r2, [r4, #0xc] add r0, r5, #0 mov r1, #2 - bl ov12_0223CDF4 + bl BattleMessage_BufferMove pop {r3, r4, r5, pc} _0223CAAA: ldr r2, [r4, #4] mov r1, #0 - bl ov12_0223CDD0 + bl BattleMessage_BufferNickname ldr r2, [r4, #8] add r0, r5, #0 mov r1, #1 - bl ov12_0223CE5C + bl BattleMessage_BufferAbility ldr r2, [r4, #0xc] add r0, r5, #0 mov r1, #2 - bl ov12_0223CE00 + bl BattleMessage_BufferItem pop {r3, r4, r5, pc} _0223CAC8: ldr r2, [r4, #4] mov r1, #0 - bl ov12_0223CDD0 + bl BattleMessage_BufferNickname ldr r2, [r4, #8] add r0, r5, #0 mov r1, #1 - bl ov12_0223CE5C + bl BattleMessage_BufferAbility ldr r2, [r4, #0xc] add r0, r5, #0 mov r1, #2 - bl ov12_0223CE68 + bl BattleMessage_BufferStat pop {r3, r4, r5, pc} _0223CAE6: ldr r2, [r4, #4] mov r1, #0 - bl ov12_0223CDD0 + bl BattleMessage_BufferNickname ldr r2, [r4, #8] add r0, r5, #0 mov r1, #1 - bl ov12_0223CE5C + bl BattleMessage_BufferAbility ldr r2, [r4, #0xc] add r0, r5, #0 mov r1, #2 - bl ov12_0223CE50 + bl BattleMessage_BufferType pop {r3, r4, r5, pc} _0223CB04: ldr r2, [r4, #4] mov r1, #0 - bl ov12_0223CDD0 + bl BattleMessage_BufferNickname ldr r2, [r4, #8] add r0, r5, #0 mov r1, #1 - bl ov12_0223CE5C + bl BattleMessage_BufferAbility ldr r2, [r4, #0xc] add r0, r5, #0 mov r1, #2 - bl ov12_0223CE74 + bl BattleMessage_BufferStatus pop {r3, r4, r5, pc} _0223CB22: ldr r2, [r4, #4] mov r1, #0 - bl ov12_0223CDD0 + bl BattleMessage_BufferNickname ldr r2, [r4, #8] add r0, r5, #0 mov r1, #1 - bl ov12_0223CE5C + bl BattleMessage_BufferAbility ldr r2, [r4, #0xc] add r0, r5, #0 mov r1, #2 - bl ov12_0223CE0C + bl BattleMessage_BufferNumber pop {r3, r4, r5, pc} _0223CB40: ldr r2, [r4, #4] mov r1, #0 - bl ov12_0223CDD0 + bl BattleMessage_BufferNickname ldr r2, [r4, #8] add r0, r5, #0 mov r1, #1 - bl ov12_0223CE00 + bl BattleMessage_BufferItem ldr r2, [r4, #0xc] add r0, r5, #0 mov r1, #2 - bl ov12_0223CDD0 + bl BattleMessage_BufferNickname pop {r3, r4, r5, pc} _0223CB5E: ldr r2, [r4, #4] mov r1, #0 - bl ov12_0223CDD0 + bl BattleMessage_BufferNickname ldr r2, [r4, #8] add r0, r5, #0 mov r1, #1 - bl ov12_0223CE00 + bl BattleMessage_BufferItem ldr r2, [r4, #0xc] add r0, r5, #0 mov r1, #2 - bl ov12_0223CDF4 + bl BattleMessage_BufferMove pop {r3, r4, r5, pc} _0223CB7C: ldr r2, [r4, #4] mov r1, #0 - bl ov12_0223CDD0 + bl BattleMessage_BufferNickname ldr r2, [r4, #8] add r0, r5, #0 mov r1, #1 - bl ov12_0223CE00 + bl BattleMessage_BufferItem ldr r2, [r4, #0xc] add r0, r5, #0 mov r1, #2 - bl ov12_0223CE68 + bl BattleMessage_BufferStat pop {r3, r4, r5, pc} _0223CB9A: ldr r2, [r4, #4] mov r1, #0 - bl ov12_0223CDD0 + bl BattleMessage_BufferNickname ldr r2, [r4, #8] add r0, r5, #0 mov r1, #1 - bl ov12_0223CE00 + bl BattleMessage_BufferItem ldr r2, [r4, #0xc] add r0, r5, #0 mov r1, #2 - bl ov12_0223CE74 + bl BattleMessage_BufferStatus pop {r3, r4, r5, pc} _0223CBB8: ldr r2, [r4, #4] mov r1, #0 - bl ov12_0223CDD0 + bl BattleMessage_BufferNickname ldr r2, [r4, #8] add r0, r5, #0 mov r1, #1 - bl ov12_0223CEE4 + bl BattleMessage_BufferBoxName ldr r2, [r4, #0xc] add r0, r5, #0 mov r1, #2 - bl ov12_0223CEE4 + bl BattleMessage_BufferBoxName pop {r3, r4, r5, pc} _0223CBD6: ldr r2, [r4, #4] mov r1, #0 - bl ov12_0223CE00 + bl BattleMessage_BufferItem ldr r2, [r4, #8] add r0, r5, #0 mov r1, #1 - bl ov12_0223CDD0 + bl BattleMessage_BufferNickname ldr r2, [r4, #0xc] add r0, r5, #0 mov r1, #2 - bl ov12_0223CEA8 + bl BattleMessage_BufferFlavorPreference pop {r3, r4, r5, pc} _0223CBF4: ldr r2, [r4, #4] mov r1, #0 - bl ov12_0223CECC + bl BattleMessage_BufferTrainerName ldr r2, [r4, #8] add r0, r5, #0 mov r1, #1 - bl ov12_0223CDD0 + bl BattleMessage_BufferNickname ldr r2, [r4, #0xc] add r0, r5, #0 mov r1, #2 - bl ov12_0223CDD0 + bl BattleMessage_BufferNickname pop {r3, r4, r5, pc} _0223CC12: ldr r2, [r4, #4] @@ -829,11 +565,11 @@ _0223CC12: ldr r2, [r4, #8] add r0, r5, #0 mov r1, #1 - bl ov12_0223CECC + bl BattleMessage_BufferTrainerName ldr r2, [r4, #0xc] add r0, r5, #0 mov r1, #2 - bl ov12_0223CDD0 + bl BattleMessage_BufferNickname pop {r3, r4, r5, pc} _0223CC30: ldr r2, [r4, #4] @@ -842,96 +578,96 @@ _0223CC30: ldr r2, [r4, #8] add r0, r5, #0 mov r1, #1 - bl ov12_0223CECC + bl BattleMessage_BufferTrainerName ldr r2, [r4, #0xc] add r0, r5, #0 mov r1, #2 - bl ov12_0223CE00 + bl BattleMessage_BufferItem pop {r3, r4, r5, pc} _0223CC4E: ldr r2, [r4, #4] mov r1, #0 - bl ov12_0223CDD0 + bl BattleMessage_BufferNickname ldr r2, [r4, #8] add r0, r5, #0 mov r1, #1 - bl ov12_0223CE5C + bl BattleMessage_BufferAbility ldr r2, [r4, #0xc] add r0, r5, #0 mov r1, #2 - bl ov12_0223CDD0 + bl BattleMessage_BufferNickname ldr r2, [r4, #0x10] add r0, r5, #0 mov r1, #3 - bl ov12_0223CDF4 + bl BattleMessage_BufferMove pop {r3, r4, r5, pc} _0223CC76: ldr r2, [r4, #4] mov r1, #0 - bl ov12_0223CDD0 + bl BattleMessage_BufferNickname ldr r2, [r4, #8] add r0, r5, #0 mov r1, #1 - bl ov12_0223CE5C + bl BattleMessage_BufferAbility ldr r2, [r4, #0xc] add r0, r5, #0 mov r1, #2 - bl ov12_0223CDD0 + bl BattleMessage_BufferNickname ldr r2, [r4, #0x10] add r0, r5, #0 mov r1, #3 - bl ov12_0223CE5C + bl BattleMessage_BufferAbility pop {r3, r4, r5, pc} _0223CC9E: ldr r2, [r4, #4] mov r1, #0 - bl ov12_0223CDD0 + bl BattleMessage_BufferNickname ldr r2, [r4, #8] add r0, r5, #0 mov r1, #1 - bl ov12_0223CE5C + bl BattleMessage_BufferAbility ldr r2, [r4, #0xc] add r0, r5, #0 mov r1, #2 - bl ov12_0223CDD0 + bl BattleMessage_BufferNickname ldr r2, [r4, #0x10] add r0, r5, #0 mov r1, #3 - bl ov12_0223CE68 + bl BattleMessage_BufferStat pop {r3, r4, r5, pc} _0223CCC6: ldr r2, [r4, #4] mov r1, #0 - bl ov12_0223CDD0 + bl BattleMessage_BufferNickname ldr r2, [r4, #8] add r0, r5, #0 mov r1, #1 - bl ov12_0223CE00 + bl BattleMessage_BufferItem ldr r2, [r4, #0xc] add r0, r5, #0 mov r1, #2 - bl ov12_0223CDD0 + bl BattleMessage_BufferNickname ldr r2, [r4, #0x10] add r0, r5, #0 mov r1, #3 - bl ov12_0223CE00 + bl BattleMessage_BufferItem pop {r3, r4, r5, pc} _0223CCEE: ldr r2, [r4, #4] mov r1, #0 - bl ov12_0223CECC + bl BattleMessage_BufferTrainerName ldr r2, [r4, #8] add r0, r5, #0 mov r1, #1 - bl ov12_0223CDD0 + bl BattleMessage_BufferNickname ldr r2, [r4, #0xc] add r0, r5, #0 mov r1, #2 - bl ov12_0223CECC + bl BattleMessage_BufferTrainerName ldr r2, [r4, #0x10] add r0, r5, #0 mov r1, #3 - bl ov12_0223CDD0 + bl BattleMessage_BufferNickname pop {r3, r4, r5, pc} _0223CD16: ldr r2, [r4, #4] @@ -940,15 +676,15 @@ _0223CD16: ldr r2, [r4, #8] add r0, r5, #0 mov r1, #1 - bl ov12_0223CECC + bl BattleMessage_BufferTrainerName ldr r2, [r4, #0xc] add r0, r5, #0 mov r1, #2 - bl ov12_0223CDD0 + bl BattleMessage_BufferNickname ldr r2, [r4, #0x10] add r0, r5, #0 mov r1, #3 - bl ov12_0223CDD0 + bl BattleMessage_BufferNickname pop {r3, r4, r5, pc} _0223CD3E: ldr r2, [r4, #4] @@ -957,15 +693,15 @@ _0223CD3E: ldr r2, [r4, #8] add r0, r5, #0 mov r1, #1 - bl ov12_0223CECC + bl BattleMessage_BufferTrainerName ldr r2, [r4, #0xc] add r0, r5, #0 mov r1, #2 - bl ov12_0223CDD0 + bl BattleMessage_BufferNickname ldr r2, [r4, #0x10] add r0, r5, #0 mov r1, #3 - bl ov12_0223CECC + bl BattleMessage_BufferTrainerName pop {r3, r4, r5, pc} _0223CD66: ldr r2, [r4, #4] @@ -974,7 +710,7 @@ _0223CD66: ldr r2, [r4, #8] add r0, r5, #0 mov r1, #1 - bl ov12_0223CECC + bl BattleMessage_BufferTrainerName ldr r2, [r4, #0xc] add r0, r5, #0 mov r1, #2 @@ -982,7 +718,7 @@ _0223CD66: ldr r2, [r4, #0x10] add r0, r5, #0 mov r1, #3 - bl ov12_0223CECC + bl BattleMessage_BufferTrainerName pop {r3, r4, r5, pc} _0223CD8E: ldr r2, [r4, #4] @@ -991,11 +727,11 @@ _0223CD8E: ldr r2, [r4, #8] add r0, r5, #0 mov r1, #1 - bl ov12_0223CECC + bl BattleMessage_BufferTrainerName ldr r2, [r4, #0xc] add r0, r5, #0 mov r1, #2 - bl ov12_0223CDD0 + bl BattleMessage_BufferNickname ldr r2, [r4, #0x10] add r0, r5, #0 mov r1, #3 @@ -1003,11 +739,11 @@ _0223CD8E: ldr r2, [r4, #0x14] add r0, r5, #0 mov r1, #4 - bl ov12_0223CECC + bl BattleMessage_BufferTrainerName ldr r2, [r4, #0x18] add r0, r5, #0 mov r1, #5 - bl ov12_0223CDD0 + bl BattleMessage_BufferNickname pop {r3, r4, r5, pc} _0223CDCA: bl GF_AssertFail @@ -1015,8 +751,8 @@ _0223CDCE: pop {r3, r4, r5, pc} thumb_func_end ov12_0223C754 - thumb_func_start ov12_0223CDD0 -ov12_0223CDD0: ; 0x0223CDD0 + thumb_func_start BattleMessage_BufferNickname +BattleMessage_BufferNickname: ; 0x0223CDD0 push {r3, r4, r5, lr} mov r3, #0xff lsl r3, r3, #8 @@ -1033,28 +769,28 @@ ov12_0223CDD0: ; 0x0223CDD0 bl BufferBoxMonNickname pop {r3, r4, r5, pc} .balign 4, 0 - thumb_func_end ov12_0223CDD0 + thumb_func_end BattleMessage_BufferNickname - thumb_func_start ov12_0223CDF4 -ov12_0223CDF4: ; 0x0223CDF4 + thumb_func_start BattleMessage_BufferMove +BattleMessage_BufferMove: ; 0x0223CDF4 ldr r3, _0223CDFC ; =BufferMoveName ldr r0, [r0, #0x14] bx r3 nop _0223CDFC: .word BufferMoveName - thumb_func_end ov12_0223CDF4 + thumb_func_end BattleMessage_BufferMove - thumb_func_start ov12_0223CE00 -ov12_0223CE00: ; 0x0223CE00 + thumb_func_start BattleMessage_BufferItem +BattleMessage_BufferItem: ; 0x0223CE00 ldr r3, _0223CE08 ; =BufferItemName ldr r0, [r0, #0x14] bx r3 nop _0223CE08: .word BufferItemName - thumb_func_end ov12_0223CE00 + thumb_func_end BattleMessage_BufferItem - thumb_func_start ov12_0223CE0C -ov12_0223CE0C: ; 0x0223CE0C + thumb_func_start BattleMessage_BufferNumber +BattleMessage_BufferNumber: ; 0x0223CE0C push {r3, lr} sub sp, #8 mov r3, #0 @@ -1066,10 +802,10 @@ ov12_0223CE0C: ; 0x0223CE0C bl BufferIntegerAsString add sp, #8 pop {r3, pc} - thumb_func_end ov12_0223CE0C + thumb_func_end BattleMessage_BufferNumber - thumb_func_start ov12_0223CE24 -ov12_0223CE24: ; 0x0223CE24 + thumb_func_start BattleMessage_BufferNumbers +BattleMessage_BufferNumbers: ; 0x0223CE24 push {r4, lr} sub sp, #8 cmp r3, #0 @@ -1091,46 +827,46 @@ _0223CE3C: add sp, #8 pop {r4, pc} .balign 4, 0 - thumb_func_end ov12_0223CE24 + thumb_func_end BattleMessage_BufferNumbers - thumb_func_start ov12_0223CE50 -ov12_0223CE50: ; 0x0223CE50 + thumb_func_start BattleMessage_BufferType +BattleMessage_BufferType: ; 0x0223CE50 ldr r3, _0223CE58 ; =BufferTypeName ldr r0, [r0, #0x14] bx r3 nop _0223CE58: .word BufferTypeName - thumb_func_end ov12_0223CE50 + thumb_func_end BattleMessage_BufferType - thumb_func_start ov12_0223CE5C -ov12_0223CE5C: ; 0x0223CE5C + thumb_func_start BattleMessage_BufferAbility +BattleMessage_BufferAbility: ; 0x0223CE5C ldr r3, _0223CE64 ; =BufferAbilityName ldr r0, [r0, #0x14] bx r3 nop _0223CE64: .word BufferAbilityName - thumb_func_end ov12_0223CE5C + thumb_func_end BattleMessage_BufferAbility - thumb_func_start ov12_0223CE68 -ov12_0223CE68: ; 0x0223CE68 + thumb_func_start BattleMessage_BufferStat +BattleMessage_BufferStat: ; 0x0223CE68 ldr r3, _0223CE70 ; =BufferStatName ldr r0, [r0, #0x14] bx r3 nop _0223CE70: .word BufferStatName - thumb_func_end ov12_0223CE68 + thumb_func_end BattleMessage_BufferStat - thumb_func_start ov12_0223CE74 -ov12_0223CE74: ; 0x0223CE74 + thumb_func_start BattleMessage_BufferStatus +BattleMessage_BufferStatus: ; 0x0223CE74 ldr r3, _0223CE7C ; =BufferStatusName ldr r0, [r0, #0x14] bx r3 nop _0223CE7C: .word BufferStatusName - thumb_func_end ov12_0223CE74 + thumb_func_end BattleMessage_BufferStatus - thumb_func_start ov12_0223CE80 -ov12_0223CE80: ; 0x0223CE80 + thumb_func_start BattleMessage_BufferPokemon +BattleMessage_BufferPokemon: ; 0x0223CE80 push {r3, r4, r5, lr} mov r3, #0xff lsl r3, r3, #8 @@ -1147,22 +883,22 @@ ov12_0223CE80: ; 0x0223CE80 bl BufferBoxMonSpeciesName pop {r3, r4, r5, pc} .balign 4, 0 - thumb_func_end ov12_0223CE80 + thumb_func_end BattleMessage_BufferPokemon - thumb_func_start ov12_0223CEA4 -ov12_0223CEA4: ; 0x0223CEA4 + thumb_func_start BattleMessage_BufferPoffin +BattleMessage_BufferPoffin: ; 0x0223CEA4 bx lr .balign 4, 0 - thumb_func_end ov12_0223CEA4 + thumb_func_end BattleMessage_BufferPoffin - thumb_func_start ov12_0223CEA8 -ov12_0223CEA8: ; 0x0223CEA8 + thumb_func_start BattleMessage_BufferFlavorPreference +BattleMessage_BufferFlavorPreference: ; 0x0223CEA8 ldr r3, _0223CEB0 ; =BufferFlavorDislikeText ldr r0, [r0, #0x14] bx r3 nop _0223CEB0: .word BufferFlavorDislikeText - thumb_func_end ov12_0223CEA8 + thumb_func_end BattleMessage_BufferFlavorPreference thumb_func_start ov12_0223CEB4 ov12_0223CEB4: ; 0x0223CEB4 @@ -1178,8 +914,8 @@ ov12_0223CEB4: ; 0x0223CEB4 pop {r3, r4, r5, pc} thumb_func_end ov12_0223CEB4 - thumb_func_start ov12_0223CECC -ov12_0223CECC: ; 0x0223CECC + thumb_func_start BattleMessage_BufferTrainerName +BattleMessage_BufferTrainerName: ; 0x0223CECC push {r3, r4, r5, lr} add r4, r1, #0 add r5, r0, #0 @@ -1190,10 +926,10 @@ ov12_0223CECC: ; 0x0223CECC add r1, r4, #0 bl BufferTrainerNameFromDataStruct pop {r3, r4, r5, pc} - thumb_func_end ov12_0223CECC + thumb_func_end BattleMessage_BufferTrainerName - thumb_func_start ov12_0223CEE4 -ov12_0223CEE4: ; 0x0223CEE4 + thumb_func_start BattleMessage_BufferBoxName +BattleMessage_BufferBoxName: ; 0x0223CEE4 push {r4, lr} add r4, r0, #0 add r3, r2, #0 @@ -1201,7 +937,7 @@ ov12_0223CEE4: ; 0x0223CEE4 ldr r2, [r4, #0x64] bl BufferPCBoxName pop {r4, pc} - thumb_func_end ov12_0223CEE4 + thumb_func_end BattleMessage_BufferBoxName thumb_func_start ov12_0223CEF4 ov12_0223CEF4: ; 0x0223CEF4 diff --git a/src/battle/battle_system.c b/src/battle/battle_system.c index a50b52ab41..3769f89a05 100644 --- a/src/battle/battle_system.c +++ b/src/battle/battle_system.c @@ -9,6 +9,7 @@ #include "battle/overlay_12_0224E4FC.h" #include "battle/overlay_12_0226BEC4.h" #include "constants/game_stats.h" +#include "constants/message_tags.h" #include "unk_0202FBCC.h" #include "unk_0200FA24.h" #include "unk_02005D10.h" @@ -1424,3 +1425,137 @@ u32 ov12_0223C4E8(BattleSystem *bsys, Window *window, MsgData *data, BattleMessa return AddTextPrinterParameterized(window, 0, bsys->msgBuffer, x + dx, y, delay, ov12_0223CF14); } + +static void ov12_0223C558(BattleSystem *bsys, BattleMessage *msg) { + u32 battleType = BattleSystem_GetBattleType(bsys); + + if (msg->tag & 0x80) { + return; + } + + if (msg->tag & 0x40) { + if (BattleSystem_GetFieldSide(bsys, msg->battlerId)) { + msg->id++; + } + return; + } + + switch (msg->tag & 0x3F) { + case TAG_NONE: + case TAG_MOVE: + case TAG_STAT: + case TAG_ITEM: + case TAG_NUMBER: + case TAG_NUMBERS: + case TAG_TRNAME: + case TAG_MOVE_MOVE: + case TAG_ITEM_MOVE: + case TAG_NUMBER_NUMBER: + case TAG_TRNAME_TRNAME: + case TAG_TRNAME_NICKNAME: + case TAG_TRNAME_ITEM: + case TAG_TRNAME_NUM: + case TAG_TRCLASS_TRNAME: + case TAG_TRNAME_NICKNAME_NICKNAME: + case TAG_TRCLASS_TRNAME_NICKNAME: + case TAG_TRCLASS_TRNAME_ITEM: + case TAG_TRNAME_NICKNAME_TRNAME_NICKNAME: + case TAG_TRCLASS_TRNAME_NICKNAME_NICKNAME: + case TAG_TRCLASS_TRNAME_NICKNAME_TRNAME: + case TAG_TRCLASS_TRNAME_TRCLASS_TRNAME: + case TAG_TRCLASS_TRNAME_NICKNAME_TRCLASS_TRNAME_NICKNAME: + break; + case TAG_NONE_SIDE: + if (BattleSystem_GetFieldSide(bsys, msg->param[0] & 0xFF)) { + msg->id++; + } + break; + case TAG_NICKNAME: + case TAG_NICKNAME_MOVE: + case TAG_NICKNAME_ABILITY: + case TAG_NICKNAME_STAT: + case TAG_NICKNAME_TYPE: + case TAG_NICKNAME_POKE: + case TAG_NICKNAME_ITEM: + case TAG_NICKNAME_POFFIN: + case TAG_NICKNAME_NUM: + case TAG_NICKNAME_TRNAME: + case TAG_NICKNAME_BOX: + case TAG_NICKNAME_MOVE_MOVE: + case TAG_NICKNAME_MOVE_NUMBER: + case TAG_NICKNAME_ABILITY_MOVE: + case TAG_NICKNAME_ABILITY_ITEM: + case TAG_NICKNAME_ABILITY_STAT: + case TAG_NICKNAME_ABILITY_TYPE: + case TAG_NICKNAME_ABILITY_STATUS: + case TAG_NICKNAME_ABILITY_NUMBER: + case TAG_NICKNAME_ITEM_MOVE: + case TAG_NICKNAME_ITEM_STAT: + case TAG_NICKNAME_ITEM_STATUS: + case TAG_NICKNAME_BOX_BOX: + if (BattleSystem_GetFieldSide(bsys, msg->param[0] & 0xFF)) { + msg->id++; + if (battleType & BATTLE_TYPE_TRAINER) { + msg->id++; + } + } + break; + case TAG_MOVE_SIDE: + if (BattleSystem_GetFieldSide(bsys, msg->param[1] & 0xFF)) { + msg->id++; + } + break; + case TAG_MOVE_NICKNAME: + case TAG_ABILITY_NICKNAME: + case TAG_ITEM_NICKNAME_FLAVOR: + if (BattleSystem_GetFieldSide(bsys, msg->param[1] & 0xFF)) { + msg->id++; + if (battleType & BATTLE_TYPE_TRAINER) { + msg->id++; + } + } + break; + case TAG_NICKNAME_NICKNAME: + case TAG_NICKNAME_NICKNAME_MOVE: + case TAG_NICKNAME_NICKNAME_ABILITY: + case TAG_NICKNAME_NICKNAME_ITEM: + if (BattleSystem_GetFieldSide(bsys, msg->param[0] & 0xFF)) { + msg->id += 3; + if (battleType & BATTLE_TYPE_TRAINER) { + msg->id += 2; + } + if (BattleSystem_GetFieldSide(bsys, msg->param[1] & 0xFF)) { + msg->id++; + } + } else if (BattleSystem_GetFieldSide(bsys, msg->param[1] & 0xFF)) { + msg->id++; + if (battleType & BATTLE_TYPE_TRAINER) { + msg->id++; + } + } + break; + case TAG_NICKNAME_ABILITY_NICKNAME: + case TAG_NICKNAME_ITEM_NICKNAME: + case TAG_NICKNAME_ABILITY_NICKNAME_MOVE: + case TAG_NICKNAME_ABILITY_NICKNAME_ABILITY: + case TAG_NICKNAME_ABILITY_NICKNAME_STAT: + case TAG_NICKNAME_ITEM_NICKNAME_ITEM: + if (BattleSystem_GetFieldSide(bsys, msg->param[0] & 0xFF)) { + msg->id += 3; + if (battleType & BATTLE_TYPE_TRAINER) { + msg->id += 2; + } + if (BattleSystem_GetFieldSide(bsys, msg->param[2] & 0xFF)) { + msg->id++; + } + } else if (BattleSystem_GetFieldSide(bsys, msg->param[2] & 0xFF)) { + msg->id++; + if (battleType & BATTLE_TYPE_TRAINER) { + msg->id++; + } + } + break; + default: + GF_ASSERT(0); + } +} From 8ce73b542831898be13bdc2309835c913e23dfb1 Mon Sep 17 00:00:00 2001 From: Adrienn Tindall <33725376+adrienntindall@users.noreply.github.com> Date: Tue, 19 Dec 2023 04:55:36 -0500 Subject: [PATCH 24/33] Document BattleSystem->MessageFormat field --- asm/include/overlay_12_02264824.inc | 2 +- asm/include/overlay_12_02266024.inc | 2 +- asm/include/overlay_12_battle_command.inc | 2 +- asm/include/overlay_12_battle_system.inc | 2 +- asm/overlay_12_02266024.s | 12 +- asm/overlay_12_battle_command.s | 2 +- asm/overlay_12_battle_system.s | 789 +--------------------- asm/overlay_12_hp_bar.s | 4 +- include/battle/battle.h | 2 +- include/battle/battle_system.h | 16 +- src/battle/battle_system.c | 309 ++++++++- 11 files changed, 332 insertions(+), 810 deletions(-) diff --git a/asm/include/overlay_12_02264824.inc b/asm/include/overlay_12_02264824.inc index 9b22bf74cd..8ed7d680d8 100644 --- a/asm/include/overlay_12_02264824.inc +++ b/asm/include/overlay_12_02264824.inc @@ -56,7 +56,7 @@ .public BattleSystem_GetLevelFont .public BattleSystem_GetMessageData .public BattleSystem_GetPaletteData -.public ov12_0223A9A4 +.public BattleSystem_GetMessageFormat .public ov12_0226498C .public BattleHpBar_LoadResources .public BattleHpBar_FreeResources diff --git a/asm/include/overlay_12_02266024.inc b/asm/include/overlay_12_02266024.inc index e3df8f98ac..30f024aeeb 100644 --- a/asm/include/overlay_12_02266024.inc +++ b/asm/include/overlay_12_02266024.inc @@ -137,7 +137,7 @@ .public ov12_0223A8EC .public BattleSystem_GetMessageData .public BattleSystem_GetPaletteData -.public ov12_0223A9A4 +.public BattleSystem_GetMessageFormat .public ov12_0223AAD8 .public ov12_0223AB54 .public BattleSystem_GetSafariBallCount diff --git a/asm/include/overlay_12_battle_command.inc b/asm/include/overlay_12_battle_command.inc index b817697c87..c11482f161 100644 --- a/asm/include/overlay_12_battle_command.inc +++ b/asm/include/overlay_12_battle_command.inc @@ -129,7 +129,7 @@ .public BattleSystem_GetMessageData .public BattleSystem_GetPaletteData .public BattleSystem_GetPokedex -.public ov12_0223A9A4 +.public BattleSystem_GetMessageFormat .public BattleSystem_GetMessageBuffer .public ov12_0223AAB8 .public ov12_0223AAD8 diff --git a/asm/include/overlay_12_battle_system.inc b/asm/include/overlay_12_battle_system.inc index a028e6176b..9bc5714c50 100644 --- a/asm/include/overlay_12_battle_system.inc +++ b/asm/include/overlay_12_battle_system.inc @@ -97,7 +97,7 @@ .public ov12_0223A984 .public ov12_0223A990 .public ov12_0223A99C -.public ov12_0223A9A4 +.public BattleSystem_GetMessageFormat .public BattleSystem_GetMessageBuffer .public BattleSystem_GetTrainerIndex .public BattleSystem_GetTrainer diff --git a/asm/overlay_12_02266024.s b/asm/overlay_12_02266024.s index a730f6da18..9e1e067e34 100644 --- a/asm/overlay_12_02266024.s +++ b/asm/overlay_12_02266024.s @@ -2099,7 +2099,7 @@ _022671C2: _022671C4: ldr r0, [r5] mov r6, #0 - bl ov12_0223A9A4 + bl BattleSystem_GetMessageFormat str r0, [sp, #0x1c] mov r0, #0x20 mov r1, #5 @@ -2889,7 +2889,7 @@ ov12_0226789C: ; 0x0226789C bl BattleSystem_GetMessageData add r6, r0, #0 ldr r0, [r5] - bl ov12_0223A9A4 + bl BattleSystem_GetMessageFormat add r4, r0, #0 ldr r1, _0226796C ; =0x000004A2 add r0, r6, #0 @@ -3080,7 +3080,7 @@ ov12_02267A58: ; 0x02267A58 bl BattleSystem_GetMessageData add r6, r0, #0 ldr r0, [r5] - bl ov12_0223A9A4 + bl BattleSystem_GetMessageFormat add r4, r0, #0 ldr r1, _02267B28 ; =0x000004C1 add r0, r6, #0 @@ -3179,7 +3179,7 @@ ov12_02267B40: ; 0x02267B40 bl BattleSystem_GetMessageData add r6, r0, #0 ldr r0, [r5] - bl ov12_0223A9A4 + bl BattleSystem_GetMessageFormat add r4, r0, #0 ldr r1, _02267C10 ; =0x000004BF add r0, r6, #0 @@ -3290,7 +3290,7 @@ ov12_02267C24: ; 0x02267C24 bl BattleSystem_GetMessageData str r0, [sp, #0x2c] ldr r0, [r5] - bl ov12_0223A9A4 + bl BattleSystem_GetMessageFormat str r0, [sp, #0x1c] add r0, r5, #0 add r1, sp, #0x40 @@ -4865,7 +4865,7 @@ ov12_0226885C: ; 0x0226885C bl NewString_ReadMsgData str r0, [sp, #0x28] ldr r0, [r7] - bl ov12_0223A9A4 + bl BattleSystem_GetMessageFormat str r0, [sp, #0x24] mov r0, #0x10 mov r1, #5 diff --git a/asm/overlay_12_battle_command.s b/asm/overlay_12_battle_command.s index 5be808593c..9c678544ab 100644 --- a/asm/overlay_12_battle_command.s +++ b/asm/overlay_12_battle_command.s @@ -3793,7 +3793,7 @@ ov12_02248228: ; 0x02248228 bl BattleSystem_GetMessageBuffer str r0, [sp, #0x20] add r0, r7, #0 - bl ov12_0223A9A4 + bl BattleSystem_GetMessageFormat str r0, [sp, #0x24] add r0, r7, #0 bl BattleSystem_GetBgConfig diff --git a/asm/overlay_12_battle_system.s b/asm/overlay_12_battle_system.s index 23201048bf..af117d27a2 100644 --- a/asm/overlay_12_battle_system.s +++ b/asm/overlay_12_battle_system.s @@ -6,789 +6,6 @@ .text - thumb_func_start ov12_0223C754 -ov12_0223C754: ; 0x0223C754 - push {r3, r4, r5, lr} - add r4, r1, #0 - ldrb r2, [r4, #1] - mov r1, #0x3f - add r5, r0, #0 - and r1, r2 - cmp r1, #0x3c - bls _0223C766 - b _0223CDCA -_0223C766: - add r1, r1, r1 - add r1, pc - ldrh r1, [r1, #6] - lsl r1, r1, #0x10 - asr r1, r1, #0x10 - add pc, r1 -_0223C772: ; jump table - .short _0223CDCE - _0223C772 - 2 ; case 0 - .short _0223CDCE - _0223C772 - 2 ; case 1 - .short _0223C7EC - _0223C772 - 2 ; case 2 - .short _0223C7F6 - _0223C772 - 2 ; case 3 - .short _0223C800 - _0223C772 - 2 ; case 4 - .short _0223C80A - _0223C772 - 2 ; case 5 - .short _0223C814 - _0223C772 - 2 ; case 6 - .short _0223C81E - _0223C772 - 2 ; case 7 - .short _0223C82A - _0223C772 - 2 ; case 8 - .short _0223C834 - _0223C772 - 2 ; case 9 - .short _0223C848 - _0223C772 - 2 ; case 10 - .short _0223C85C - _0223C772 - 2 ; case 11 - .short _0223C870 - _0223C772 - 2 ; case 12 - .short _0223C884 - _0223C772 - 2 ; case 13 - .short _0223C898 - _0223C772 - 2 ; case 14 - .short _0223C8AC - _0223C772 - 2 ; case 15 - .short _0223C8C0 - _0223C772 - 2 ; case 16 - .short _0223C8D4 - _0223C772 - 2 ; case 17 - .short _0223C8E8 - _0223C772 - 2 ; case 18 - .short _0223C8FC - _0223C772 - 2 ; case 19 - .short _0223C7F6 - _0223C772 - 2 ; case 20 - .short _0223C910 - _0223C772 - 2 ; case 21 - .short _0223C924 - _0223C772 - 2 ; case 22 - .short _0223C938 - _0223C772 - 2 ; case 23 - .short _0223C94C - _0223C772 - 2 ; case 24 - .short _0223C960 - _0223C772 - 2 ; case 25 - .short _0223C974 - _0223C772 - 2 ; case 26 - .short _0223C988 - _0223C772 - 2 ; case 27 - .short _0223C99C - _0223C772 - 2 ; case 28 - .short _0223C9B0 - _0223C772 - 2 ; case 29 - .short _0223C9C4 - _0223C772 - 2 ; case 30 - .short _0223C9D8 - _0223C772 - 2 ; case 31 - .short _0223C9F6 - _0223C772 - 2 ; case 32 - .short _0223CA14 - _0223C772 - 2 ; case 33 - .short _0223CA32 - _0223C772 - 2 ; case 34 - .short _0223CA50 - _0223C772 - 2 ; case 35 - .short _0223CA6E - _0223C772 - 2 ; case 36 - .short _0223CA8C - _0223C772 - 2 ; case 37 - .short _0223CAAA - _0223C772 - 2 ; case 38 - .short _0223CAC8 - _0223C772 - 2 ; case 39 - .short _0223CAE6 - _0223C772 - 2 ; case 40 - .short _0223CB04 - _0223C772 - 2 ; case 41 - .short _0223CB22 - _0223C772 - 2 ; case 42 - .short _0223CB40 - _0223C772 - 2 ; case 43 - .short _0223CB5E - _0223C772 - 2 ; case 44 - .short _0223CB7C - _0223C772 - 2 ; case 45 - .short _0223CB9A - _0223C772 - 2 ; case 46 - .short _0223CBB8 - _0223C772 - 2 ; case 47 - .short _0223CBD6 - _0223C772 - 2 ; case 48 - .short _0223CBF4 - _0223C772 - 2 ; case 49 - .short _0223CC12 - _0223C772 - 2 ; case 50 - .short _0223CC30 - _0223C772 - 2 ; case 51 - .short _0223CC4E - _0223C772 - 2 ; case 52 - .short _0223CC76 - _0223C772 - 2 ; case 53 - .short _0223CC9E - _0223C772 - 2 ; case 54 - .short _0223CCC6 - _0223C772 - 2 ; case 55 - .short _0223CCEE - _0223C772 - 2 ; case 56 - .short _0223CD16 - _0223C772 - 2 ; case 57 - .short _0223CD3E - _0223C772 - 2 ; case 58 - .short _0223CD66 - _0223C772 - 2 ; case 59 - .short _0223CD8E - _0223C772 - 2 ; case 60 -_0223C7EC: - ldr r2, [r4, #4] - mov r1, #0 - bl BattleMessage_BufferNickname - pop {r3, r4, r5, pc} -_0223C7F6: - ldr r2, [r4, #4] - mov r1, #0 - bl BattleMessage_BufferMove - pop {r3, r4, r5, pc} -_0223C800: - ldr r2, [r4, #4] - mov r1, #0 - bl BattleMessage_BufferStat - pop {r3, r4, r5, pc} -_0223C80A: - ldr r2, [r4, #4] - mov r1, #0 - bl BattleMessage_BufferItem - pop {r3, r4, r5, pc} -_0223C814: - ldr r2, [r4, #4] - mov r1, #0 - bl BattleMessage_BufferNumber - pop {r3, r4, r5, pc} -_0223C81E: - ldr r2, [r4, #4] - ldr r3, [r4, #0x1c] - mov r1, #0 - bl BattleMessage_BufferNumbers - pop {r3, r4, r5, pc} -_0223C82A: - ldr r2, [r4, #4] - mov r1, #0 - bl BattleMessage_BufferTrainerName - pop {r3, r4, r5, pc} -_0223C834: - ldr r2, [r4, #4] - mov r1, #0 - bl BattleMessage_BufferNickname - ldr r2, [r4, #8] - add r0, r5, #0 - mov r1, #1 - bl BattleMessage_BufferNickname - pop {r3, r4, r5, pc} -_0223C848: - ldr r2, [r4, #4] - mov r1, #0 - bl BattleMessage_BufferNickname - ldr r2, [r4, #8] - add r0, r5, #0 - mov r1, #1 - bl BattleMessage_BufferMove - pop {r3, r4, r5, pc} -_0223C85C: - ldr r2, [r4, #4] - mov r1, #0 - bl BattleMessage_BufferNickname - ldr r2, [r4, #8] - add r0, r5, #0 - mov r1, #1 - bl BattleMessage_BufferAbility - pop {r3, r4, r5, pc} -_0223C870: - ldr r2, [r4, #4] - mov r1, #0 - bl BattleMessage_BufferNickname - ldr r2, [r4, #8] - add r0, r5, #0 - mov r1, #1 - bl BattleMessage_BufferStat - pop {r3, r4, r5, pc} -_0223C884: - ldr r2, [r4, #4] - mov r1, #0 - bl BattleMessage_BufferNickname - ldr r2, [r4, #8] - add r0, r5, #0 - mov r1, #1 - bl BattleMessage_BufferType - pop {r3, r4, r5, pc} -_0223C898: - ldr r2, [r4, #4] - mov r1, #0 - bl BattleMessage_BufferNickname - ldr r2, [r4, #8] - add r0, r5, #0 - mov r1, #1 - bl BattleMessage_BufferPokemon - pop {r3, r4, r5, pc} -_0223C8AC: - ldr r2, [r4, #4] - mov r1, #0 - bl BattleMessage_BufferNickname - ldr r2, [r4, #8] - add r0, r5, #0 - mov r1, #1 - bl BattleMessage_BufferItem - pop {r3, r4, r5, pc} -_0223C8C0: - ldr r2, [r4, #4] - mov r1, #0 - bl BattleMessage_BufferNickname - ldr r2, [r4, #8] - add r0, r5, #0 - mov r1, #1 - bl BattleMessage_BufferPoffin - pop {r3, r4, r5, pc} -_0223C8D4: - ldr r2, [r4, #4] - mov r1, #0 - bl BattleMessage_BufferNickname - ldr r2, [r4, #8] - add r0, r5, #0 - mov r1, #1 - bl BattleMessage_BufferNumber - pop {r3, r4, r5, pc} -_0223C8E8: - ldr r2, [r4, #4] - mov r1, #0 - bl BattleMessage_BufferNickname - ldr r2, [r4, #8] - add r0, r5, #0 - mov r1, #1 - bl BattleMessage_BufferTrainerName - pop {r3, r4, r5, pc} -_0223C8FC: - ldr r2, [r4, #4] - mov r1, #0 - bl BattleMessage_BufferNickname - ldr r2, [r4, #8] - add r0, r5, #0 - mov r1, #1 - bl BattleMessage_BufferBoxName - pop {r3, r4, r5, pc} -_0223C910: - ldr r2, [r4, #4] - mov r1, #0 - bl BattleMessage_BufferMove - ldr r2, [r4, #8] - add r0, r5, #0 - mov r1, #1 - bl BattleMessage_BufferNickname - pop {r3, r4, r5, pc} -_0223C924: - ldr r2, [r4, #4] - mov r1, #0 - bl BattleMessage_BufferMove - ldr r2, [r4, #8] - add r0, r5, #0 - mov r1, #1 - bl BattleMessage_BufferMove - pop {r3, r4, r5, pc} -_0223C938: - ldr r2, [r4, #4] - mov r1, #0 - bl BattleMessage_BufferAbility - ldr r2, [r4, #8] - add r0, r5, #0 - mov r1, #1 - bl BattleMessage_BufferNickname - pop {r3, r4, r5, pc} -_0223C94C: - ldr r2, [r4, #4] - mov r1, #0 - bl BattleMessage_BufferItem - ldr r2, [r4, #8] - add r0, r5, #0 - mov r1, #1 - bl BattleMessage_BufferMove - pop {r3, r4, r5, pc} -_0223C960: - ldr r2, [r4, #4] - mov r1, #0 - bl BattleMessage_BufferNumber - ldr r2, [r4, #8] - add r0, r5, #0 - mov r1, #1 - bl BattleMessage_BufferNumber - pop {r3, r4, r5, pc} -_0223C974: - ldr r2, [r4, #4] - mov r1, #0 - bl BattleMessage_BufferTrainerName - ldr r2, [r4, #8] - add r0, r5, #0 - mov r1, #1 - bl BattleMessage_BufferTrainerName - pop {r3, r4, r5, pc} -_0223C988: - ldr r2, [r4, #4] - mov r1, #0 - bl BattleMessage_BufferTrainerName - ldr r2, [r4, #8] - add r0, r5, #0 - mov r1, #1 - bl BattleMessage_BufferNickname - pop {r3, r4, r5, pc} -_0223C99C: - ldr r2, [r4, #4] - mov r1, #0 - bl BattleMessage_BufferTrainerName - ldr r2, [r4, #8] - add r0, r5, #0 - mov r1, #1 - bl BattleMessage_BufferItem - pop {r3, r4, r5, pc} -_0223C9B0: - ldr r2, [r4, #4] - mov r1, #0 - bl BattleMessage_BufferTrainerName - ldr r2, [r4, #8] - add r0, r5, #0 - mov r1, #1 - bl BattleMessage_BufferNumber - pop {r3, r4, r5, pc} -_0223C9C4: - ldr r2, [r4, #4] - mov r1, #0 - bl ov12_0223CEB4 - ldr r2, [r4, #8] - add r0, r5, #0 - mov r1, #1 - bl BattleMessage_BufferTrainerName - pop {r3, r4, r5, pc} -_0223C9D8: - ldr r2, [r4, #4] - mov r1, #0 - bl BattleMessage_BufferNickname - ldr r2, [r4, #8] - add r0, r5, #0 - mov r1, #1 - bl BattleMessage_BufferNickname - ldr r2, [r4, #0xc] - add r0, r5, #0 - mov r1, #2 - bl BattleMessage_BufferMove - pop {r3, r4, r5, pc} -_0223C9F6: - ldr r2, [r4, #4] - mov r1, #0 - bl BattleMessage_BufferNickname - ldr r2, [r4, #8] - add r0, r5, #0 - mov r1, #1 - bl BattleMessage_BufferNickname - ldr r2, [r4, #0xc] - add r0, r5, #0 - mov r1, #2 - bl BattleMessage_BufferAbility - pop {r3, r4, r5, pc} -_0223CA14: - ldr r2, [r4, #4] - mov r1, #0 - bl BattleMessage_BufferNickname - ldr r2, [r4, #8] - add r0, r5, #0 - mov r1, #1 - bl BattleMessage_BufferNickname - ldr r2, [r4, #0xc] - add r0, r5, #0 - mov r1, #2 - bl BattleMessage_BufferItem - pop {r3, r4, r5, pc} -_0223CA32: - ldr r2, [r4, #4] - mov r1, #0 - bl BattleMessage_BufferNickname - ldr r2, [r4, #8] - add r0, r5, #0 - mov r1, #1 - bl BattleMessage_BufferMove - ldr r2, [r4, #0xc] - add r0, r5, #0 - mov r1, #2 - bl BattleMessage_BufferMove - pop {r3, r4, r5, pc} -_0223CA50: - ldr r2, [r4, #4] - mov r1, #0 - bl BattleMessage_BufferNickname - ldr r2, [r4, #8] - add r0, r5, #0 - mov r1, #1 - bl BattleMessage_BufferMove - ldr r2, [r4, #0xc] - add r0, r5, #0 - mov r1, #2 - bl BattleMessage_BufferNumber - pop {r3, r4, r5, pc} -_0223CA6E: - ldr r2, [r4, #4] - mov r1, #0 - bl BattleMessage_BufferNickname - ldr r2, [r4, #8] - add r0, r5, #0 - mov r1, #1 - bl BattleMessage_BufferAbility - ldr r2, [r4, #0xc] - add r0, r5, #0 - mov r1, #2 - bl BattleMessage_BufferNickname - pop {r3, r4, r5, pc} -_0223CA8C: - ldr r2, [r4, #4] - mov r1, #0 - bl BattleMessage_BufferNickname - ldr r2, [r4, #8] - add r0, r5, #0 - mov r1, #1 - bl BattleMessage_BufferAbility - ldr r2, [r4, #0xc] - add r0, r5, #0 - mov r1, #2 - bl BattleMessage_BufferMove - pop {r3, r4, r5, pc} -_0223CAAA: - ldr r2, [r4, #4] - mov r1, #0 - bl BattleMessage_BufferNickname - ldr r2, [r4, #8] - add r0, r5, #0 - mov r1, #1 - bl BattleMessage_BufferAbility - ldr r2, [r4, #0xc] - add r0, r5, #0 - mov r1, #2 - bl BattleMessage_BufferItem - pop {r3, r4, r5, pc} -_0223CAC8: - ldr r2, [r4, #4] - mov r1, #0 - bl BattleMessage_BufferNickname - ldr r2, [r4, #8] - add r0, r5, #0 - mov r1, #1 - bl BattleMessage_BufferAbility - ldr r2, [r4, #0xc] - add r0, r5, #0 - mov r1, #2 - bl BattleMessage_BufferStat - pop {r3, r4, r5, pc} -_0223CAE6: - ldr r2, [r4, #4] - mov r1, #0 - bl BattleMessage_BufferNickname - ldr r2, [r4, #8] - add r0, r5, #0 - mov r1, #1 - bl BattleMessage_BufferAbility - ldr r2, [r4, #0xc] - add r0, r5, #0 - mov r1, #2 - bl BattleMessage_BufferType - pop {r3, r4, r5, pc} -_0223CB04: - ldr r2, [r4, #4] - mov r1, #0 - bl BattleMessage_BufferNickname - ldr r2, [r4, #8] - add r0, r5, #0 - mov r1, #1 - bl BattleMessage_BufferAbility - ldr r2, [r4, #0xc] - add r0, r5, #0 - mov r1, #2 - bl BattleMessage_BufferStatus - pop {r3, r4, r5, pc} -_0223CB22: - ldr r2, [r4, #4] - mov r1, #0 - bl BattleMessage_BufferNickname - ldr r2, [r4, #8] - add r0, r5, #0 - mov r1, #1 - bl BattleMessage_BufferAbility - ldr r2, [r4, #0xc] - add r0, r5, #0 - mov r1, #2 - bl BattleMessage_BufferNumber - pop {r3, r4, r5, pc} -_0223CB40: - ldr r2, [r4, #4] - mov r1, #0 - bl BattleMessage_BufferNickname - ldr r2, [r4, #8] - add r0, r5, #0 - mov r1, #1 - bl BattleMessage_BufferItem - ldr r2, [r4, #0xc] - add r0, r5, #0 - mov r1, #2 - bl BattleMessage_BufferNickname - pop {r3, r4, r5, pc} -_0223CB5E: - ldr r2, [r4, #4] - mov r1, #0 - bl BattleMessage_BufferNickname - ldr r2, [r4, #8] - add r0, r5, #0 - mov r1, #1 - bl BattleMessage_BufferItem - ldr r2, [r4, #0xc] - add r0, r5, #0 - mov r1, #2 - bl BattleMessage_BufferMove - pop {r3, r4, r5, pc} -_0223CB7C: - ldr r2, [r4, #4] - mov r1, #0 - bl BattleMessage_BufferNickname - ldr r2, [r4, #8] - add r0, r5, #0 - mov r1, #1 - bl BattleMessage_BufferItem - ldr r2, [r4, #0xc] - add r0, r5, #0 - mov r1, #2 - bl BattleMessage_BufferStat - pop {r3, r4, r5, pc} -_0223CB9A: - ldr r2, [r4, #4] - mov r1, #0 - bl BattleMessage_BufferNickname - ldr r2, [r4, #8] - add r0, r5, #0 - mov r1, #1 - bl BattleMessage_BufferItem - ldr r2, [r4, #0xc] - add r0, r5, #0 - mov r1, #2 - bl BattleMessage_BufferStatus - pop {r3, r4, r5, pc} -_0223CBB8: - ldr r2, [r4, #4] - mov r1, #0 - bl BattleMessage_BufferNickname - ldr r2, [r4, #8] - add r0, r5, #0 - mov r1, #1 - bl BattleMessage_BufferBoxName - ldr r2, [r4, #0xc] - add r0, r5, #0 - mov r1, #2 - bl BattleMessage_BufferBoxName - pop {r3, r4, r5, pc} -_0223CBD6: - ldr r2, [r4, #4] - mov r1, #0 - bl BattleMessage_BufferItem - ldr r2, [r4, #8] - add r0, r5, #0 - mov r1, #1 - bl BattleMessage_BufferNickname - ldr r2, [r4, #0xc] - add r0, r5, #0 - mov r1, #2 - bl BattleMessage_BufferFlavorPreference - pop {r3, r4, r5, pc} -_0223CBF4: - ldr r2, [r4, #4] - mov r1, #0 - bl BattleMessage_BufferTrainerName - ldr r2, [r4, #8] - add r0, r5, #0 - mov r1, #1 - bl BattleMessage_BufferNickname - ldr r2, [r4, #0xc] - add r0, r5, #0 - mov r1, #2 - bl BattleMessage_BufferNickname - pop {r3, r4, r5, pc} -_0223CC12: - ldr r2, [r4, #4] - mov r1, #0 - bl ov12_0223CEB4 - ldr r2, [r4, #8] - add r0, r5, #0 - mov r1, #1 - bl BattleMessage_BufferTrainerName - ldr r2, [r4, #0xc] - add r0, r5, #0 - mov r1, #2 - bl BattleMessage_BufferNickname - pop {r3, r4, r5, pc} -_0223CC30: - ldr r2, [r4, #4] - mov r1, #0 - bl ov12_0223CEB4 - ldr r2, [r4, #8] - add r0, r5, #0 - mov r1, #1 - bl BattleMessage_BufferTrainerName - ldr r2, [r4, #0xc] - add r0, r5, #0 - mov r1, #2 - bl BattleMessage_BufferItem - pop {r3, r4, r5, pc} -_0223CC4E: - ldr r2, [r4, #4] - mov r1, #0 - bl BattleMessage_BufferNickname - ldr r2, [r4, #8] - add r0, r5, #0 - mov r1, #1 - bl BattleMessage_BufferAbility - ldr r2, [r4, #0xc] - add r0, r5, #0 - mov r1, #2 - bl BattleMessage_BufferNickname - ldr r2, [r4, #0x10] - add r0, r5, #0 - mov r1, #3 - bl BattleMessage_BufferMove - pop {r3, r4, r5, pc} -_0223CC76: - ldr r2, [r4, #4] - mov r1, #0 - bl BattleMessage_BufferNickname - ldr r2, [r4, #8] - add r0, r5, #0 - mov r1, #1 - bl BattleMessage_BufferAbility - ldr r2, [r4, #0xc] - add r0, r5, #0 - mov r1, #2 - bl BattleMessage_BufferNickname - ldr r2, [r4, #0x10] - add r0, r5, #0 - mov r1, #3 - bl BattleMessage_BufferAbility - pop {r3, r4, r5, pc} -_0223CC9E: - ldr r2, [r4, #4] - mov r1, #0 - bl BattleMessage_BufferNickname - ldr r2, [r4, #8] - add r0, r5, #0 - mov r1, #1 - bl BattleMessage_BufferAbility - ldr r2, [r4, #0xc] - add r0, r5, #0 - mov r1, #2 - bl BattleMessage_BufferNickname - ldr r2, [r4, #0x10] - add r0, r5, #0 - mov r1, #3 - bl BattleMessage_BufferStat - pop {r3, r4, r5, pc} -_0223CCC6: - ldr r2, [r4, #4] - mov r1, #0 - bl BattleMessage_BufferNickname - ldr r2, [r4, #8] - add r0, r5, #0 - mov r1, #1 - bl BattleMessage_BufferItem - ldr r2, [r4, #0xc] - add r0, r5, #0 - mov r1, #2 - bl BattleMessage_BufferNickname - ldr r2, [r4, #0x10] - add r0, r5, #0 - mov r1, #3 - bl BattleMessage_BufferItem - pop {r3, r4, r5, pc} -_0223CCEE: - ldr r2, [r4, #4] - mov r1, #0 - bl BattleMessage_BufferTrainerName - ldr r2, [r4, #8] - add r0, r5, #0 - mov r1, #1 - bl BattleMessage_BufferNickname - ldr r2, [r4, #0xc] - add r0, r5, #0 - mov r1, #2 - bl BattleMessage_BufferTrainerName - ldr r2, [r4, #0x10] - add r0, r5, #0 - mov r1, #3 - bl BattleMessage_BufferNickname - pop {r3, r4, r5, pc} -_0223CD16: - ldr r2, [r4, #4] - mov r1, #0 - bl ov12_0223CEB4 - ldr r2, [r4, #8] - add r0, r5, #0 - mov r1, #1 - bl BattleMessage_BufferTrainerName - ldr r2, [r4, #0xc] - add r0, r5, #0 - mov r1, #2 - bl BattleMessage_BufferNickname - ldr r2, [r4, #0x10] - add r0, r5, #0 - mov r1, #3 - bl BattleMessage_BufferNickname - pop {r3, r4, r5, pc} -_0223CD3E: - ldr r2, [r4, #4] - mov r1, #0 - bl ov12_0223CEB4 - ldr r2, [r4, #8] - add r0, r5, #0 - mov r1, #1 - bl BattleMessage_BufferTrainerName - ldr r2, [r4, #0xc] - add r0, r5, #0 - mov r1, #2 - bl BattleMessage_BufferNickname - ldr r2, [r4, #0x10] - add r0, r5, #0 - mov r1, #3 - bl BattleMessage_BufferTrainerName - pop {r3, r4, r5, pc} -_0223CD66: - ldr r2, [r4, #4] - mov r1, #0 - bl ov12_0223CEB4 - ldr r2, [r4, #8] - add r0, r5, #0 - mov r1, #1 - bl BattleMessage_BufferTrainerName - ldr r2, [r4, #0xc] - add r0, r5, #0 - mov r1, #2 - bl ov12_0223CEB4 - ldr r2, [r4, #0x10] - add r0, r5, #0 - mov r1, #3 - bl BattleMessage_BufferTrainerName - pop {r3, r4, r5, pc} -_0223CD8E: - ldr r2, [r4, #4] - mov r1, #0 - bl ov12_0223CEB4 - ldr r2, [r4, #8] - add r0, r5, #0 - mov r1, #1 - bl BattleMessage_BufferTrainerName - ldr r2, [r4, #0xc] - add r0, r5, #0 - mov r1, #2 - bl BattleMessage_BufferNickname - ldr r2, [r4, #0x10] - add r0, r5, #0 - mov r1, #3 - bl ov12_0223CEB4 - ldr r2, [r4, #0x14] - add r0, r5, #0 - mov r1, #4 - bl BattleMessage_BufferTrainerName - ldr r2, [r4, #0x18] - add r0, r5, #0 - mov r1, #5 - bl BattleMessage_BufferNickname - pop {r3, r4, r5, pc} -_0223CDCA: - bl GF_AssertFail -_0223CDCE: - pop {r3, r4, r5, pc} - thumb_func_end ov12_0223C754 - - thumb_func_start BattleMessage_BufferNickname -BattleMessage_BufferNickname: ; 0x0223CDD0 - push {r3, r4, r5, lr} - mov r3, #0xff - lsl r3, r3, #8 - add r4, r1, #0 - lsl r1, r2, #0x18 - and r2, r3 - add r5, r0, #0 - lsr r1, r1, #0x18 - asr r2, r2, #8 - bl BattleSystem_GetPartyMon - add r2, r0, #0 - ldr r0, [r5, #0x14] - add r1, r4, #0 - bl BufferBoxMonNickname - pop {r3, r4, r5, pc} - .balign 4, 0 - thumb_func_end BattleMessage_BufferNickname - - thumb_func_start BattleMessage_BufferMove -BattleMessage_BufferMove: ; 0x0223CDF4 - ldr r3, _0223CDFC ; =BufferMoveName - ldr r0, [r0, #0x14] - bx r3 - nop -_0223CDFC: .word BufferMoveName - thumb_func_end BattleMessage_BufferMove - - thumb_func_start BattleMessage_BufferItem -BattleMessage_BufferItem: ; 0x0223CE00 - ldr r3, _0223CE08 ; =BufferItemName - ldr r0, [r0, #0x14] - bx r3 - nop -_0223CE08: .word BufferItemName - thumb_func_end BattleMessage_BufferItem - thumb_func_start BattleMessage_BufferNumber BattleMessage_BufferNumber: ; 0x0223CE0C push {r3, lr} @@ -900,8 +117,8 @@ BattleMessage_BufferFlavorPreference: ; 0x0223CEA8 _0223CEB0: .word BufferFlavorDislikeText thumb_func_end BattleMessage_BufferFlavorPreference - thumb_func_start ov12_0223CEB4 -ov12_0223CEB4: ; 0x0223CEB4 + thumb_func_start BattleMessage_BufferTrainerClass +BattleMessage_BufferTrainerClass: ; 0x0223CEB4 push {r3, r4, r5, lr} add r4, r1, #0 add r5, r0, #0 @@ -912,7 +129,7 @@ ov12_0223CEB4: ; 0x0223CEB4 add r1, r4, #0 bl BufferTrainerClassNameFromDataStruct pop {r3, r4, r5, pc} - thumb_func_end ov12_0223CEB4 + thumb_func_end BattleMessage_BufferTrainerClass thumb_func_start BattleMessage_BufferTrainerName BattleMessage_BufferTrainerName: ; 0x0223CECC diff --git a/asm/overlay_12_hp_bar.s b/asm/overlay_12_hp_bar.s index 3c97ef72a0..8e45e93f19 100644 --- a/asm/overlay_12_hp_bar.s +++ b/asm/overlay_12_hp_bar.s @@ -1244,7 +1244,7 @@ ov12_0226516C: ; 0x0226516C bl BattleSystem_GetMessageData add r7, r0, #0 ldr r0, [r5, #0xc] - bl ov12_0223A9A4 + bl BattleSystem_GetMessageFormat add r4, r0, #0 mov r0, #0x16 mov r1, #5 @@ -1878,7 +1878,7 @@ ov12_022656CC: ; 0x022656CC bl BattleSystem_GetMessageData str r0, [sp, #0x20] ldr r0, [r4, #0xc] - bl ov12_0223A9A4 + bl BattleSystem_GetMessageFormat add r7, r0, #0 mov r0, #0x1e mov r1, #5 diff --git a/include/battle/battle.h b/include/battle/battle.h index 963f41e58c..9eb27e975f 100644 --- a/include/battle/battle.h +++ b/include/battle/battle.h @@ -523,7 +523,7 @@ struct BattleSystem { Window *window; MsgData *msgData; u32 *unk10; - u32 *unk14; + MessageFormat *msgFormat; String *msgBuffer; u32 unk1C; u32 unk20; diff --git a/include/battle/battle_system.h b/include/battle/battle_system.h index d2ad6ad4aa..02c9c2c8bf 100644 --- a/include/battle/battle_system.h +++ b/include/battle/battle_system.h @@ -39,7 +39,7 @@ u16 *ov12_0223A978(BattleSystem *bsys); u16 *ov12_0223A984(BattleSystem *bsys); u16 *ov12_0223A990(BattleSystem *bsys); UnkBattleSystemSub1D0 *ov12_0223A99C(BattleSystem *bsys); -u32 *ov12_0223A9A4(BattleSystem *bsys); +MessageFormat *BattleSystem_GetMessageFormat(BattleSystem *bsys); String *BattleSystem_GetMessageBuffer(BattleSystem *bsys); u16 BattleSystem_GetTrainerIndex(BattleSystem *bsys, int battlerId); Trainer *BattleSystem_GetTrainer(BattleSystem *bsys, int battlerId); @@ -159,8 +159,18 @@ void ov12_0226AA8C(u32 *a1, u32 flag); BOOL ov12_0223CF14(struct TextPrinterTemplate *template, u16 glyphId); //These functions haven't been decompiled AND are confirmed to be static -void ov12_0223C558(BattleSystem *bsys, BattleMessage *msg); -void ov12_0223C754(BattleSystem *bsys, BattleMessage *msg); void ov12_0223CEF4(BattleSystem *bsys, MsgData *data, BattleMessage *msg); +void BattleMessage_BufferStat(BattleSystem *bsys, int a1, int param); +void BattleMessage_BufferNumber(BattleSystem *bsys, int a1, int param); +void BattleMessage_BufferNumbers(BattleSystem *bsys, int a1, int param, int a3); +void BattleMessage_BufferTrainerName(BattleSystem *bsys, int a1, int param); +void BattleMessage_BufferAbility(BattleSystem *bsys, int a1, int param); +void BattleMessage_BufferType(BattleSystem *bsys, int a1, int param); +void BattleMessage_BufferPokemon(BattleSystem *bsys, int a1, int param); +void BattleMessage_BufferPoffin(BattleSystem *bsys, int a1, int param); +void BattleMessage_BufferTrainerClass(BattleSystem *bsys, int a1, int param); +void BattleMessage_BufferBoxName(BattleSystem *bsys, int a1, int param); +void BattleMessage_BufferStatus(BattleSystem *bsys, int a1, int param); +void BattleMessage_BufferFlavorPreference(BattleSystem *bsys, int a1, int param); #endif diff --git a/src/battle/battle_system.c b/src/battle/battle_system.c index 3769f89a05..189b57b8c3 100644 --- a/src/battle/battle_system.c +++ b/src/battle/battle_system.c @@ -15,6 +15,11 @@ #include "unk_02005D10.h" static u8 ov12_0223BFB0(u8 *buffer, u8 *index, u16 *size); +static void BattleSystem_AdjustMessageForSide(BattleSystem *bsys, BattleMessage *msg); +static void BattleSystem_BufferMessage(BattleSystem *bsys, BattleMessage *msg); +static void BattleMessage_BufferNickname(BattleSystem *bsys, int bufferIndex, int param); +static void BattleMessage_BufferMove(BattleSystem *bsys, int bufferIndex, int param); +static void BattleMessage_BufferItem(BattleSystem *bsys, int bufferIndex, int param); BgConfig *BattleSystem_GetBgConfig(BattleSystem *bsys) { return bsys->bgConfig; @@ -162,8 +167,8 @@ UnkBattleSystemSub1D0 *ov12_0223A99C(BattleSystem *bsys) { return &bsys->unk1D0[0]; } -u32 *ov12_0223A9A4(BattleSystem *bsys) { - return bsys->unk14; +MessageFormat *BattleSystem_GetMessageFormat(BattleSystem *bsys) { + return bsys->msgFormat; } String *BattleSystem_GetMessageBuffer(BattleSystem *bsys) { @@ -1399,8 +1404,8 @@ u8 BattleSystem_PrintTrainerMessage(BattleSystem *bsys, int trainerId, int battl u32 BattleSystem_PrintBattleMessage(BattleSystem *bsys, MsgData *data, BattleMessage *msg, u8 delay) { Window *window = BattleSystem_GetWindow(bsys, 0); - ov12_0223C558(bsys, msg); - ov12_0223C754(bsys, msg); + BattleSystem_AdjustMessageForSide(bsys, msg); + BattleSystem_BufferMessage(bsys, msg); ov12_0223CEF4(bsys, data, msg); FillWindowPixelBuffer(window, 0xFF); return AddTextPrinterParameterized(window, 1, bsys->msgBuffer, 0, 0, delay, ov12_0223CF14); @@ -1409,8 +1414,8 @@ u32 BattleSystem_PrintBattleMessage(BattleSystem *bsys, MsgData *data, BattleMes u32 ov12_0223C4E8(BattleSystem *bsys, Window *window, MsgData *data, BattleMessage *msg, int x, int y, int flag, int width, int delay) { int dx; - ov12_0223C558(bsys, msg); - ov12_0223C754(bsys, msg); + BattleSystem_AdjustMessageForSide(bsys, msg); + BattleSystem_BufferMessage(bsys, msg); ov12_0223CEF4(bsys, data, msg); if (flag & 1) { @@ -1426,7 +1431,7 @@ u32 ov12_0223C4E8(BattleSystem *bsys, Window *window, MsgData *data, BattleMessa return AddTextPrinterParameterized(window, 0, bsys->msgBuffer, x + dx, y, delay, ov12_0223CF14); } -static void ov12_0223C558(BattleSystem *bsys, BattleMessage *msg) { +static void BattleSystem_AdjustMessageForSide(BattleSystem *bsys, BattleMessage *msg) { u32 battleType = BattleSystem_GetBattleType(bsys); if (msg->tag & 0x80) { @@ -1559,3 +1564,293 @@ static void ov12_0223C558(BattleSystem *bsys, BattleMessage *msg) { GF_ASSERT(0); } } + +static void BattleSystem_BufferMessage(BattleSystem *bsys, BattleMessage *msg) { + switch (msg->tag & 0x3F) { + case TAG_NONE: + case TAG_NONE_SIDE: + break; + case TAG_NICKNAME: + BattleMessage_BufferNickname(bsys, 0, msg->param[0]); + break; + case TAG_MOVE: + case TAG_MOVE_SIDE: + BattleMessage_BufferMove(bsys, 0, msg->param[0]); + break; + case TAG_STAT: + BattleMessage_BufferStat(bsys, 0, msg->param[0]); + break; + case TAG_ITEM: + BattleMessage_BufferItem(bsys, 0, msg->param[0]); + break; + case TAG_NUMBER: + BattleMessage_BufferNumber(bsys, 0, msg->param[0]); + break; + case TAG_NUMBERS: + BattleMessage_BufferNumbers(bsys, 0, msg->param[0], msg->unk1C); + break; + case TAG_TRNAME: + BattleMessage_BufferTrainerName(bsys, 0, msg->param[0]); + break; + case TAG_NICKNAME_NICKNAME: + BattleMessage_BufferNickname(bsys, 0, msg->param[0]); + BattleMessage_BufferNickname(bsys, 1, msg->param[1]); + break; + case TAG_NICKNAME_MOVE: + BattleMessage_BufferNickname(bsys, 0, msg->param[0]); + BattleMessage_BufferMove(bsys, 1, msg->param[1]); + break; + case TAG_NICKNAME_ABILITY: + BattleMessage_BufferNickname(bsys, 0, msg->param[0]); + BattleMessage_BufferAbility(bsys, 1, msg->param[1]); + break; + case TAG_NICKNAME_STAT: + BattleMessage_BufferNickname(bsys, 0, msg->param[0]); + BattleMessage_BufferStat(bsys, 1, msg->param[1]); + break; + case TAG_NICKNAME_TYPE: + BattleMessage_BufferNickname(bsys, 0, msg->param[0]); + BattleMessage_BufferType(bsys, 1, msg->param[1]); + break; + case TAG_NICKNAME_POKE: + BattleMessage_BufferNickname(bsys, 0, msg->param[0]); + BattleMessage_BufferPokemon(bsys, 1, msg->param[1]); + break; + case TAG_NICKNAME_ITEM: + BattleMessage_BufferNickname(bsys, 0, msg->param[0]); + BattleMessage_BufferItem(bsys, 1, msg->param[1]); + break; + case TAG_NICKNAME_POFFIN: //unused + BattleMessage_BufferNickname(bsys, 0, msg->param[0]); + BattleMessage_BufferPoffin(bsys, 1, msg->param[1]); + break; + case TAG_NICKNAME_NUM: + BattleMessage_BufferNickname(bsys, 0, msg->param[0]); + BattleMessage_BufferNumber(bsys, 1, msg->param[1]); + break; + case TAG_NICKNAME_TRNAME: + BattleMessage_BufferNickname(bsys, 0, msg->param[0]); + BattleMessage_BufferTrainerName(bsys, 1, msg->param[1]); + break; + case TAG_NICKNAME_BOX: + BattleMessage_BufferNickname(bsys, 0, msg->param[0]); + BattleMessage_BufferBoxName(bsys, 1, msg->param[1]); + break; + case TAG_MOVE_NICKNAME: + BattleMessage_BufferMove(bsys, 0, msg->param[0]); + BattleMessage_BufferNickname(bsys, 1, msg->param[1]); + break; + case TAG_MOVE_MOVE: + BattleMessage_BufferMove(bsys, 0, msg->param[0]); + BattleMessage_BufferMove(bsys, 1, msg->param[1]); + break; + case TAG_ABILITY_NICKNAME: + BattleMessage_BufferAbility(bsys, 0, msg->param[0]); + BattleMessage_BufferNickname(bsys, 1, msg->param[1]); + break; + case TAG_ITEM_MOVE: + BattleMessage_BufferItem(bsys, 0, msg->param[0]); + BattleMessage_BufferMove(bsys, 1, msg->param[1]); + break; + case TAG_NUMBER_NUMBER: + BattleMessage_BufferNumber(bsys, 0, msg->param[0]); + BattleMessage_BufferNumber(bsys, 1, msg->param[1]); + break; + case TAG_TRNAME_TRNAME: + BattleMessage_BufferTrainerName(bsys, 0, msg->param[0]); + BattleMessage_BufferTrainerName(bsys, 1, msg->param[1]); + break; + case TAG_TRNAME_NICKNAME: + BattleMessage_BufferTrainerName(bsys, 0, msg->param[0]); + BattleMessage_BufferNickname(bsys, 1, msg->param[1]); + break; + case TAG_TRNAME_ITEM: + BattleMessage_BufferTrainerName(bsys, 0, msg->param[0]); + BattleMessage_BufferItem(bsys, 1, msg->param[1]); + break; + case TAG_TRNAME_NUM: + BattleMessage_BufferTrainerName(bsys, 0, msg->param[0]); + BattleMessage_BufferNumber(bsys, 1, msg->param[1]); + break; + case TAG_TRCLASS_TRNAME: + BattleMessage_BufferTrainerClass(bsys, 0, msg->param[0]); + BattleMessage_BufferTrainerName(bsys, 1, msg->param[1]); + break; + case TAG_NICKNAME_NICKNAME_MOVE: + BattleMessage_BufferNickname(bsys, 0, msg->param[0]); + BattleMessage_BufferNickname(bsys, 1, msg->param[1]); + BattleMessage_BufferMove(bsys, 2, msg->param[2]); + break; + case TAG_NICKNAME_NICKNAME_ABILITY: + BattleMessage_BufferNickname(bsys, 0, msg->param[0]); + BattleMessage_BufferNickname(bsys, 1, msg->param[1]); + BattleMessage_BufferAbility(bsys, 2, msg->param[2]); + break; + case TAG_NICKNAME_NICKNAME_ITEM: + BattleMessage_BufferNickname(bsys, 0, msg->param[0]); + BattleMessage_BufferNickname(bsys, 1, msg->param[1]); + BattleMessage_BufferItem(bsys, 2, msg->param[2]); + break; + case TAG_NICKNAME_MOVE_MOVE: + BattleMessage_BufferNickname(bsys, 0, msg->param[0]); + BattleMessage_BufferMove(bsys, 1, msg->param[1]); + BattleMessage_BufferMove(bsys, 2, msg->param[2]); + break; + case TAG_NICKNAME_MOVE_NUMBER: + BattleMessage_BufferNickname(bsys, 0, msg->param[0]); + BattleMessage_BufferMove(bsys, 1, msg->param[1]); + BattleMessage_BufferNumber(bsys, 2, msg->param[2]); + break; + case TAG_NICKNAME_ABILITY_NICKNAME: + BattleMessage_BufferNickname(bsys, 0, msg->param[0]); + BattleMessage_BufferAbility(bsys, 1, msg->param[1]); + BattleMessage_BufferNickname(bsys, 2, msg->param[2]); + break; + case TAG_NICKNAME_ABILITY_MOVE: + BattleMessage_BufferNickname(bsys, 0, msg->param[0]); + BattleMessage_BufferAbility(bsys, 1, msg->param[1]); + BattleMessage_BufferMove(bsys, 2, msg->param[2]); + break; + case TAG_NICKNAME_ABILITY_ITEM: + BattleMessage_BufferNickname(bsys, 0, msg->param[0]); + BattleMessage_BufferAbility(bsys, 1, msg->param[1]); + BattleMessage_BufferItem(bsys, 2, msg->param[2]); + break; + case TAG_NICKNAME_ABILITY_STAT: + BattleMessage_BufferNickname(bsys, 0, msg->param[0]); + BattleMessage_BufferAbility(bsys, 1, msg->param[1]); + BattleMessage_BufferStat(bsys, 2, msg->param[2]); + break; + case TAG_NICKNAME_ABILITY_TYPE: + BattleMessage_BufferNickname(bsys, 0, msg->param[0]); + BattleMessage_BufferAbility(bsys, 1, msg->param[1]); + BattleMessage_BufferType(bsys, 2, msg->param[2]); + break; + case TAG_NICKNAME_ABILITY_STATUS: + BattleMessage_BufferNickname(bsys, 0, msg->param[0]); + BattleMessage_BufferAbility(bsys, 1, msg->param[1]); + BattleMessage_BufferStatus(bsys, 2, msg->param[2]); + break; + case TAG_NICKNAME_ABILITY_NUMBER: + BattleMessage_BufferNickname(bsys, 0, msg->param[0]); + BattleMessage_BufferAbility(bsys, 1, msg->param[1]); + BattleMessage_BufferNumber(bsys, 2, msg->param[2]); + break; + case TAG_NICKNAME_ITEM_NICKNAME: + BattleMessage_BufferNickname(bsys, 0, msg->param[0]); + BattleMessage_BufferItem(bsys, 1, msg->param[1]); + BattleMessage_BufferNickname(bsys, 2, msg->param[2]); + break; + case TAG_NICKNAME_ITEM_MOVE: + BattleMessage_BufferNickname(bsys, 0, msg->param[0]); + BattleMessage_BufferItem(bsys, 1, msg->param[1]); + BattleMessage_BufferMove(bsys, 2, msg->param[2]); + break; + case TAG_NICKNAME_ITEM_STAT: + BattleMessage_BufferNickname(bsys, 0, msg->param[0]); + BattleMessage_BufferItem(bsys, 1, msg->param[1]); + BattleMessage_BufferStat(bsys, 2, msg->param[2]); + break; + case TAG_NICKNAME_ITEM_STATUS: + BattleMessage_BufferNickname(bsys, 0, msg->param[0]); + BattleMessage_BufferItem(bsys, 1, msg->param[1]); + BattleMessage_BufferStatus(bsys, 2, msg->param[2]); + break; + case TAG_NICKNAME_BOX_BOX: + BattleMessage_BufferNickname(bsys, 0, msg->param[0]); + BattleMessage_BufferBoxName(bsys, 1, msg->param[1]); + BattleMessage_BufferBoxName(bsys, 2, msg->param[2]); + break; + case TAG_ITEM_NICKNAME_FLAVOR: + BattleMessage_BufferItem(bsys, 0, msg->param[0]); + BattleMessage_BufferNickname(bsys, 1, msg->param[1]); + BattleMessage_BufferFlavorPreference(bsys, 2, msg->param[2]); + break; + case TAG_TRNAME_NICKNAME_NICKNAME: + BattleMessage_BufferTrainerName(bsys, 0, msg->param[0]); + BattleMessage_BufferNickname(bsys, 1, msg->param[1]); + BattleMessage_BufferNickname(bsys, 2, msg->param[2]); + break; + case TAG_TRCLASS_TRNAME_NICKNAME: + BattleMessage_BufferTrainerClass(bsys, 0, msg->param[0]); + BattleMessage_BufferTrainerName(bsys, 1, msg->param[1]); + BattleMessage_BufferNickname(bsys, 2, msg->param[2]); + break; + case TAG_TRCLASS_TRNAME_ITEM: + BattleMessage_BufferTrainerClass(bsys, 0, msg->param[0]); + BattleMessage_BufferTrainerName(bsys, 1, msg->param[1]); + BattleMessage_BufferItem(bsys, 2, msg->param[2]); + break; + case TAG_NICKNAME_ABILITY_NICKNAME_MOVE: + BattleMessage_BufferNickname(bsys, 0, msg->param[0]); + BattleMessage_BufferAbility(bsys, 1, msg->param[1]); + BattleMessage_BufferNickname(bsys, 2, msg->param[2]); + BattleMessage_BufferMove(bsys, 3, msg->param[3]); + break; + case TAG_NICKNAME_ABILITY_NICKNAME_ABILITY: + BattleMessage_BufferNickname(bsys, 0, msg->param[0]); + BattleMessage_BufferAbility(bsys, 1, msg->param[1]); + BattleMessage_BufferNickname(bsys, 2, msg->param[2]); + BattleMessage_BufferAbility(bsys, 3, msg->param[3]); + break; + case TAG_NICKNAME_ABILITY_NICKNAME_STAT: + BattleMessage_BufferNickname(bsys, 0, msg->param[0]); + BattleMessage_BufferAbility(bsys, 1, msg->param[1]); + BattleMessage_BufferNickname(bsys, 2, msg->param[2]); + BattleMessage_BufferStat(bsys, 3, msg->param[3]); + break; + case TAG_NICKNAME_ITEM_NICKNAME_ITEM: + BattleMessage_BufferNickname(bsys, 0, msg->param[0]); + BattleMessage_BufferItem(bsys, 1, msg->param[1]); + BattleMessage_BufferNickname(bsys, 2, msg->param[2]); + BattleMessage_BufferItem(bsys, 3, msg->param[3]); + break; + case TAG_TRNAME_NICKNAME_TRNAME_NICKNAME: + BattleMessage_BufferTrainerName(bsys, 0, msg->param[0]); + BattleMessage_BufferNickname(bsys, 1, msg->param[1]); + BattleMessage_BufferTrainerName(bsys, 2, msg->param[2]); + BattleMessage_BufferNickname(bsys, 3, msg->param[3]); + break; + case TAG_TRCLASS_TRNAME_NICKNAME_NICKNAME: + BattleMessage_BufferTrainerClass(bsys, 0, msg->param[0]); + BattleMessage_BufferTrainerName(bsys, 1, msg->param[1]); + BattleMessage_BufferNickname(bsys, 2, msg->param[2]); + BattleMessage_BufferNickname(bsys, 3, msg->param[3]); + break; + case TAG_TRCLASS_TRNAME_NICKNAME_TRNAME: + BattleMessage_BufferTrainerClass(bsys, 0, msg->param[0]); + BattleMessage_BufferTrainerName(bsys, 1, msg->param[1]); + BattleMessage_BufferNickname(bsys, 2, msg->param[2]); + BattleMessage_BufferTrainerName(bsys, 3, msg->param[3]); + break; + case TAG_TRCLASS_TRNAME_TRCLASS_TRNAME: + BattleMessage_BufferTrainerClass(bsys, 0, msg->param[0]); + BattleMessage_BufferTrainerName(bsys, 1, msg->param[1]); + BattleMessage_BufferTrainerClass(bsys, 2, msg->param[2]); + BattleMessage_BufferTrainerName(bsys, 3, msg->param[3]); + break; + case TAG_TRCLASS_TRNAME_NICKNAME_TRCLASS_TRNAME_NICKNAME: + BattleMessage_BufferTrainerClass(bsys, 0, msg->param[0]); + BattleMessage_BufferTrainerName(bsys, 1, msg->param[1]); + BattleMessage_BufferNickname(bsys, 2, msg->param[2]); + BattleMessage_BufferTrainerClass(bsys, 3, msg->param[3]); + BattleMessage_BufferTrainerName(bsys, 4, msg->param[4]); + BattleMessage_BufferNickname(bsys, 5, msg->param[5]); + break; + default: + GF_ASSERT(0); + } +} + +static void BattleMessage_BufferNickname(BattleSystem *bsys, int bufferIndex, int param) { + Pokemon *mon = BattleSystem_GetPartyMon(bsys, param & 0xFF, (param & 0xFF00) >> 8); + BufferBoxMonNickname(bsys->msgFormat, bufferIndex, &mon->box); +} + +static void BattleMessage_BufferMove(BattleSystem *bsys, int bufferIndex, int param) { + BufferMoveName(bsys->msgFormat, bufferIndex, param); +} + +static void BattleMessage_BufferItem(BattleSystem *bsys, int bufferIndex, int param) { + BufferItemName(bsys->msgFormat, bufferIndex, param); +} From 88c914311bbf2fa7eecde287a8dea170d34636f8 Mon Sep 17 00:00:00 2001 From: Adrienn Tindall <33725376+adrienntindall@users.noreply.github.com> Date: Tue, 19 Dec 2023 05:46:37 -0500 Subject: [PATCH 25/33] Finish decompiling battle_system.c --- asm/include/overlay_12_battle_system.inc | 222 -------------------- asm/overlay_12_battle_system.s | 221 ------------------- include/battle/battle_022378C0.h | 1 + include/battle/battle_02265E28.h | 8 + include/battle/battle_controller.h | 1 + include/battle/battle_controller_opponent.h | 1 + include/battle/battle_system.h | 26 --- include/battle/overlay_12_02266024.h | 1 + main.lsf | 1 - src/battle/battle_controller_player.c | 1 + src/battle/battle_system.c | 111 +++++++++- 11 files changed, 122 insertions(+), 472 deletions(-) delete mode 100644 asm/include/overlay_12_battle_system.inc delete mode 100644 asm/overlay_12_battle_system.s create mode 100644 include/battle/battle_02265E28.h diff --git a/asm/include/overlay_12_battle_system.inc b/asm/include/overlay_12_battle_system.inc deleted file mode 100644 index 9bc5714c50..0000000000 --- a/asm/include/overlay_12_battle_system.inc +++ /dev/null @@ -1,222 +0,0 @@ -#include -#pragma once -.public FontID_String_GetWidth -.public PaletteData_GetUnfadedBuf -.public Sound_SetMasterVolume -.public Sound_Stop -.public PlaySE -.public GF_IsAnySEPlaying -.public PlayFanfare -.public IsFanfarePlaying -.public NewMsgDataFromNarc -.public DestroyMsgData -.public NewString_ReadMsgData -.public BufferBoxMonSpeciesName -.public BufferBoxMonNickname -.public BufferIntegerAsString -.public BufferMoveName -.public BufferAbilityName -.public BufferItemName -.public BufferTypeName -.public BufferStatName -.public BufferStatusName -.public BufferFlavorDislikeText -.public BufferTrainerClassNameFromDataStruct -.public BufferTrainerNameFromDataStruct -.public BufferPCBoxName -.public StringExpandPlaceholders -.public BeginNormalPaletteFade -.public MailMsg_GetExpandedString -.public AllocFromHeap -.public BG_LoadCharTilesData -.public FillWindowPixelBuffer -.public AddTextPrinterParameterized -.public sub_02024B1C -.public GF_AssertFail -.public String_Delete -.public String_Copy -.public PlayerProfile_GetTrainerGender -.public PlayerProfile_CountBadges -.public PlayerProfile_GetMoney -.public PlayerProfile_GetVersion -.public Pokedex_CheckMonCaughtFlag -.public Pokedex_SetMonSeenFlag -.public Pokedex_SetMonCaughtFlag -.public Options_GetTextFrameDelay -.public Options_GetBattleScene -.public Options_GetBattleStyle -.public Options_GetFrame -.public GameStats_Inc -.public GameStats_AddSpecial -.public sub_02030260 -.public sub_0203027C -.public GetMonData -.public SetMonData -.public AddMonData -.public GetMonEvolution -.public Party_GetMaxLevel -.public MaskOfFlagNo -.public GetTrainerMessageByIdPair -.public Party_GetCount -.public Party_GetMonByIndex -.public GetItemAttr -.public BallToItemId -.public ApplyItemEffectOnMonMood -.public MIi_CpuCopy32 -.public _s32_div_f -.public _u32_div_f -.public BattleSystem_GetBgConfig -.public BattleSystem_GetWindow -.public BattleSystem_GetBattleType -.public BattleSystem_GetBattleContext -.public BattleSystem_GetOpponentData -.public BattleSystem_GetMaxBattlers -.public BattleSystem_GetParty -.public BattleSystem_GetPartySize -.public BattleSystem_GetPartyMon -.public ov12_0223A8D4 -.public ov12_0223A8DC -.public ov12_0223A8E4 -.public ov12_0223A8EC -.public ov12_0223A8F4 -.public ov12_0223A900 -.public ov12_0223A908 -.public ov12_0223A914 -.public BattleSystem_GetHpFont -.public BattleSystem_GetLevelFont -.public BattleSystem_GetMessageData -.public ov12_0223A934 -.public BattleSystem_GetPaletteData -.public BattleSystem_GetPokedex -.public BattleSystem_GetSendBufferPtr -.public BattleSystem_GetRecvBufferPtr -.public ov12_0223A954 -.public ov12_0223A960 -.public ov12_0223A96C -.public ov12_0223A978 -.public ov12_0223A984 -.public ov12_0223A990 -.public ov12_0223A99C -.public BattleSystem_GetMessageFormat -.public BattleSystem_GetMessageBuffer -.public BattleSystem_GetTrainerIndex -.public BattleSystem_GetTrainer -.public BattleSystem_GetPlayerProfile -.public BattleSystem_GetBag -.public BattleSystem_GetBagCursor -.public BattleSystem_GetMonBall -.public ov12_0223AAB8 -.public BattleSystem_GetTrainerGender -.public ov12_0223AAD8 -.public ov12_0223AB0C -.public BattleSystem_GetFieldSide -.public BattleSystem_GetMessageIcon -.public BattleSystem_GetPcStorage -.public BattleSystem_GetTerrainId -.public ov12_0223AB54 -.public BattleSystem_GetLocation -.public BattleSystem_GetBattlerIdPartner -.public ov12_0223ABB8 -.public BattleSystem_RecoverStatus -.public BattleSystem_GetBattleSpecial -.public BattleSystem_GetTimezone -.public ov12_0223B52C -.public ov12_0223B580 -.public BattleSystem_CheckEvolution -.public ov12_0223B688 -.public ov12_0223B694 -.public BattleSystem_GetSafariBallCount -.public BattleSystem_SetSafariBallCount -.public BattleSystem_GetOptions -.public BattleSystem_AreBattleAnimationsOn -.public BattleSystem_GetFrame -.public BattleSystem_GetTextFrameDelay -.public BattleSystem_GetBattleStyle -.public ov12_0223B750 -.public BattleSystem_GetChatotVoice -.public BattleSystem_TryChangeForm -.public ov12_0223B854 -.public ov12_0223B870 -.public BattleSystem_SetBackground -.public ov12_0223BAD0 -.public ov12_0223BAD8 -.public ov12_0223BAE0 -.public ov12_0223BAEC -.public BattleSystem_GetWeather -.public ov12_0223BB04 -.public ov12_0223BB10 -.public ov12_0223BB1C -.public BattleSystem_GameStatIncrement -.public ov12_0223BB44 -.public ov12_0223BB64 -.public ov12_0223BB6C -.public ov12_0223BB78 -.public ov12_0223BB80 -.public ov12_0223BB88 -.public ov12_0223BB94 -.public ov12_0223BBA8 -.public ov12_0223BBC0 -.public ov12_0223BBD8 -.public ov12_0223BBF0 -.public ov12_0223BBFC -.public ov12_0223BC08 -.public ov12_0223BC14 -.public ov12_0223BC20 -.public ov12_0223BC2C -.public BattleSystem_GetHpBar -.public BattleSystem_HpBar_Init -.public BattleSystem_SetHpBarEnabled -.public BattleSystem_SetHpBarDisabled -.public BattleSystem_HpBar_Delete -.public BattleSystem_GetBattleOutcomeFlags -.public BattleSystem_SetBattleOutcomeFlags -.public BattleSystem_GetCriticalHpMusicFlag -.public BattleSystem_SetCriticalHpMusicFlag -.public BattleSystem_GetCriticalHpMusicDelay -.public BattleSystem_SetCriticalHpMusicDelay -.public ov12_0223BD8C -.public BattleSystem_Random -.public BattleSystem_GetRandTemp -.public BattleSystem_SetRandTemp -.public ov12_0223BDDC -.public ov12_0223BE0C -.public ov12_0223BE68 -.public ov12_0223BF14 -.public ov12_0223BFC0 -.public ov12_0223BFCC -.public BattleSystem_GetTrainerItem -.public ov12_0223BFEC -.public ov12_0223BFFC -.public ov12_0223C080 -.public ov12_0223C0C4 -.public BattleSystem_GetChatotVoiceParam -.public ov12_0223C134 -.public ov12_0223C140 -.public ov12_0223C1A0 -.public ov12_0223C1C4 -.public ov12_0223C1F4 -.public ov12_0223C224 -.public CalcMoneyLoss -.public BattleSystem_SetPokedexSeen -.public BattleSystem_SetPokedexCaught -.public BattleSystem_CheckMonCaught -.public BattleSystem_SetDefaultBlend -.public BattleSystem_PrintTrainerMessage -.public BattleSystem_PrintBattleMessage -.public ov12_0223C4E8 -.public GetBattlerVar -.public SetBattlerVar -.public AddBattlerVar -.public ov12_022581D4 -.public ov12_022582B8 -.public ov12_02261258 -.public ov12_02261270 -.public OpponentData_GetHpBar -.public BattleHpBar_LoadResources -.public BattleHpBar_FreeResources -.public ov12_02264EE0 -.public BattleHpBar_SetEnabled -.public ov12_02265B64 -.public ov12_02266008 -.public ov12_0226AA8C -.public ov12_0226BEC4 diff --git a/asm/overlay_12_battle_system.s b/asm/overlay_12_battle_system.s deleted file mode 100644 index af117d27a2..0000000000 --- a/asm/overlay_12_battle_system.s +++ /dev/null @@ -1,221 +0,0 @@ -#include "constants/pokemon.h" -#include "constants/sndseq.h" - .include "asm/macros.inc" - .include "overlay_12_battle_system.inc" - .include "global.inc" - - .text - - thumb_func_start BattleMessage_BufferNumber -BattleMessage_BufferNumber: ; 0x0223CE0C - push {r3, lr} - sub sp, #8 - mov r3, #0 - str r3, [sp] - mov r3, #1 - str r3, [sp, #4] - ldr r0, [r0, #0x14] - mov r3, #5 - bl BufferIntegerAsString - add sp, #8 - pop {r3, pc} - thumb_func_end BattleMessage_BufferNumber - - thumb_func_start BattleMessage_BufferNumbers -BattleMessage_BufferNumbers: ; 0x0223CE24 - push {r4, lr} - sub sp, #8 - cmp r3, #0 - beq _0223CE3C - mov r4, #1 - str r4, [sp] - str r4, [sp, #4] - ldr r0, [r0, #0x14] - bl BufferIntegerAsString - add sp, #8 - pop {r4, pc} -_0223CE3C: - mov r3, #1 - str r3, [sp] - str r3, [sp, #4] - ldr r0, [r0, #0x14] - mov r3, #5 - bl BufferIntegerAsString - add sp, #8 - pop {r4, pc} - .balign 4, 0 - thumb_func_end BattleMessage_BufferNumbers - - thumb_func_start BattleMessage_BufferType -BattleMessage_BufferType: ; 0x0223CE50 - ldr r3, _0223CE58 ; =BufferTypeName - ldr r0, [r0, #0x14] - bx r3 - nop -_0223CE58: .word BufferTypeName - thumb_func_end BattleMessage_BufferType - - thumb_func_start BattleMessage_BufferAbility -BattleMessage_BufferAbility: ; 0x0223CE5C - ldr r3, _0223CE64 ; =BufferAbilityName - ldr r0, [r0, #0x14] - bx r3 - nop -_0223CE64: .word BufferAbilityName - thumb_func_end BattleMessage_BufferAbility - - thumb_func_start BattleMessage_BufferStat -BattleMessage_BufferStat: ; 0x0223CE68 - ldr r3, _0223CE70 ; =BufferStatName - ldr r0, [r0, #0x14] - bx r3 - nop -_0223CE70: .word BufferStatName - thumb_func_end BattleMessage_BufferStat - - thumb_func_start BattleMessage_BufferStatus -BattleMessage_BufferStatus: ; 0x0223CE74 - ldr r3, _0223CE7C ; =BufferStatusName - ldr r0, [r0, #0x14] - bx r3 - nop -_0223CE7C: .word BufferStatusName - thumb_func_end BattleMessage_BufferStatus - - thumb_func_start BattleMessage_BufferPokemon -BattleMessage_BufferPokemon: ; 0x0223CE80 - push {r3, r4, r5, lr} - mov r3, #0xff - lsl r3, r3, #8 - add r4, r1, #0 - lsl r1, r2, #0x18 - and r2, r3 - add r5, r0, #0 - lsr r1, r1, #0x18 - asr r2, r2, #8 - bl BattleSystem_GetPartyMon - add r2, r0, #0 - ldr r0, [r5, #0x14] - add r1, r4, #0 - bl BufferBoxMonSpeciesName - pop {r3, r4, r5, pc} - .balign 4, 0 - thumb_func_end BattleMessage_BufferPokemon - - thumb_func_start BattleMessage_BufferPoffin -BattleMessage_BufferPoffin: ; 0x0223CEA4 - bx lr - .balign 4, 0 - thumb_func_end BattleMessage_BufferPoffin - - thumb_func_start BattleMessage_BufferFlavorPreference -BattleMessage_BufferFlavorPreference: ; 0x0223CEA8 - ldr r3, _0223CEB0 ; =BufferFlavorDislikeText - ldr r0, [r0, #0x14] - bx r3 - nop -_0223CEB0: .word BufferFlavorDislikeText - thumb_func_end BattleMessage_BufferFlavorPreference - - thumb_func_start BattleMessage_BufferTrainerClass -BattleMessage_BufferTrainerClass: ; 0x0223CEB4 - push {r3, r4, r5, lr} - add r4, r1, #0 - add r5, r0, #0 - add r1, r2, #0 - bl BattleSystem_GetTrainer - add r2, r0, #0 - ldr r0, [r5, #0x14] - add r1, r4, #0 - bl BufferTrainerClassNameFromDataStruct - pop {r3, r4, r5, pc} - thumb_func_end BattleMessage_BufferTrainerClass - - thumb_func_start BattleMessage_BufferTrainerName -BattleMessage_BufferTrainerName: ; 0x0223CECC - push {r3, r4, r5, lr} - add r4, r1, #0 - add r5, r0, #0 - add r1, r2, #0 - bl BattleSystem_GetTrainer - add r2, r0, #0 - ldr r0, [r5, #0x14] - add r1, r4, #0 - bl BufferTrainerNameFromDataStruct - pop {r3, r4, r5, pc} - thumb_func_end BattleMessage_BufferTrainerName - - thumb_func_start BattleMessage_BufferBoxName -BattleMessage_BufferBoxName: ; 0x0223CEE4 - push {r4, lr} - add r4, r0, #0 - add r3, r2, #0 - ldr r0, [r4, #0x14] - ldr r2, [r4, #0x64] - bl BufferPCBoxName - pop {r4, pc} - thumb_func_end BattleMessage_BufferBoxName - - thumb_func_start ov12_0223CEF4 -ov12_0223CEF4: ; 0x0223CEF4 - push {r3, r4, r5, lr} - add r5, r0, #0 - add r0, r1, #0 - ldrh r1, [r2, #2] - bl NewString_ReadMsgData - add r4, r0, #0 - ldr r0, [r5, #0x14] - ldr r1, [r5, #0x18] - add r2, r4, #0 - bl StringExpandPlaceholders - add r0, r4, #0 - bl String_Delete - pop {r3, r4, r5, pc} - thumb_func_end ov12_0223CEF4 - - thumb_func_start ov12_0223CF14 -ov12_0223CF14: ; 0x0223CF14 - push {r4, lr} - mov r4, #0 - cmp r1, #5 - bhi _0223CF5C - add r0, r1, r1 - add r0, pc - ldrh r0, [r0, #6] - lsl r0, r0, #0x10 - asr r0, r0, #0x10 - add pc, r0 -_0223CF28: ; jump table - .short _0223CF5C - _0223CF28 - 2 ; case 0 - .short _0223CF34 - _0223CF28 - 2 ; case 1 - .short _0223CF3C - _0223CF28 - 2 ; case 2 - .short _0223CF44 - _0223CF28 - 2 ; case 3 - .short _0223CF4C - _0223CF28 - 2 ; case 4 - .short _0223CF54 - _0223CF28 - 2 ; case 5 -_0223CF34: - bl GF_IsAnySEPlaying - add r4, r0, #0 - b _0223CF5C -_0223CF3C: - bl IsFanfarePlaying - add r4, r0, #0 - b _0223CF5C -_0223CF44: - ldr r0, _0223CF60 ; =0x000004A3 - bl PlayFanfare - b _0223CF5C -_0223CF4C: - ldr r0, _0223CF64 ; =0x000005E6 - bl PlaySE - b _0223CF5C -_0223CF54: - mov r0, #0x4a - lsl r0, r0, #4 - bl PlayFanfare -_0223CF5C: - add r0, r4, #0 - pop {r4, pc} - .balign 4, 0 -_0223CF60: .word 0x000004A3 -_0223CF64: .word 0x000005E6 - thumb_func_end ov12_0223CF14 diff --git a/include/battle/battle_022378C0.h b/include/battle/battle_022378C0.h index e06220d38a..030ca51fe1 100644 --- a/include/battle/battle_022378C0.h +++ b/include/battle/battle_022378C0.h @@ -31,5 +31,6 @@ void ov12_0223A620(BattleSystem *bsys); //the following functions aren't static/haven't been checked to their status and are yet to be decompiled void ov12_02238A30(BgConfig *config); void ov12_02238A64(BattleSystem *bsys); +void ov12_02237ED0(BattleSystem *bsys, int a1); #endif diff --git a/include/battle/battle_02265E28.h b/include/battle/battle_02265E28.h new file mode 100644 index 0000000000..73866e7ced --- /dev/null +++ b/include/battle/battle_02265E28.h @@ -0,0 +1,8 @@ +#ifndef POKEHEARTGOLD_BATTLE_02265E28_H +#define POKEHEARTGOLD_BATTLE_02265E28_H + +#include "battle.h" + +void ov12_02266008(UnkBattleSystemSub17C *a0); + +#endif diff --git a/include/battle/battle_controller.h b/include/battle/battle_controller.h index 2bf3a5573c..b0bb897162 100644 --- a/include/battle/battle_controller.h +++ b/include/battle/battle_controller.h @@ -77,5 +77,6 @@ void ov12_02263564(BattleSystem *bsys, BattleContext *ctx, int battlerId, u32 a3 void ov12_0226399C(BattleSystem *bsys, int battlerId); void ov12_02263A1C(BattleSystem *bsys, BattleContext *ctx, int battlerId); void ov12_02263D14(BattleSystem *bsys, int battlerId, u32 a2, int slot); +void ov12_022642F0(BattleSystem *bsys); #endif diff --git a/include/battle/battle_controller_opponent.h b/include/battle/battle_controller_opponent.h index 188a5c5561..5cf6139ae3 100644 --- a/include/battle/battle_controller_opponent.h +++ b/include/battle/battle_controller_opponent.h @@ -6,5 +6,6 @@ u8 ov12_02261258(OpponentData *opponentData); void *ov12_02261270(OpponentData *opponentData); u32 ov12_02261264(OpponentData *opponentData); +BattleHpBar *OpponentData_GetHpBar(OpponentData *opponentData); #endif diff --git a/include/battle/battle_system.h b/include/battle/battle_system.h index 02c9c2c8bf..404b4ea9cd 100644 --- a/include/battle/battle_system.h +++ b/include/battle/battle_system.h @@ -147,30 +147,4 @@ u8 BattleSystem_PrintTrainerMessage(BattleSystem *bsys, int trainerId, int battl u32 BattleSystem_PrintBattleMessage(BattleSystem *bsys, MsgData *data, BattleMessage *msg, u8 delay); u32 ov12_0223C4E8(BattleSystem *bsys, Window *window, MsgData *data, BattleMessage *msg, int x, int y, int flag, int width, int delay); -//These functions haven't been decompiled -BOOL Link_QueueNotEmpty(BattleContext *ctx); -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); -void ov12_0226AA8C(u32 *a1, u32 flag); -BOOL ov12_0223CF14(struct TextPrinterTemplate *template, u16 glyphId); - -//These functions haven't been decompiled AND are confirmed to be static -void ov12_0223CEF4(BattleSystem *bsys, MsgData *data, BattleMessage *msg); -void BattleMessage_BufferStat(BattleSystem *bsys, int a1, int param); -void BattleMessage_BufferNumber(BattleSystem *bsys, int a1, int param); -void BattleMessage_BufferNumbers(BattleSystem *bsys, int a1, int param, int a3); -void BattleMessage_BufferTrainerName(BattleSystem *bsys, int a1, int param); -void BattleMessage_BufferAbility(BattleSystem *bsys, int a1, int param); -void BattleMessage_BufferType(BattleSystem *bsys, int a1, int param); -void BattleMessage_BufferPokemon(BattleSystem *bsys, int a1, int param); -void BattleMessage_BufferPoffin(BattleSystem *bsys, int a1, int param); -void BattleMessage_BufferTrainerClass(BattleSystem *bsys, int a1, int param); -void BattleMessage_BufferBoxName(BattleSystem *bsys, int a1, int param); -void BattleMessage_BufferStatus(BattleSystem *bsys, int a1, int param); -void BattleMessage_BufferFlavorPreference(BattleSystem *bsys, int a1, int param); - #endif diff --git a/include/battle/overlay_12_02266024.h b/include/battle/overlay_12_02266024.h index 57b0ef454e..2c4c259beb 100644 --- a/include/battle/overlay_12_02266024.h +++ b/include/battle/overlay_12_02266024.h @@ -10,5 +10,6 @@ BOOL ov12_02266B78(u32 *a0); void ov12_02266390(void *); void ov12_02266508(NARC *a0, NARC *a1, void *a2, int a3, BOOL a4, void *a5); void ov12_02266644(NARC *a0, void *a1); +void ov12_0226AA8C(u32 *a1, u32 flag); #endif diff --git a/main.lsf b/main.lsf index 0f8c036d89..1a31af576e 100644 --- a/main.lsf +++ b/main.lsf @@ -570,7 +570,6 @@ Overlay OVY_12 Object src/battle/battle_022378C0.o Object asm/overlay_12_022378C0.o Object src/battle/battle_system.o - Object asm/overlay_12_battle_system.o Object src/battle/battle_command.o Object asm/overlay_12_battle_command.o Object src/battle/battle_controller_player.o diff --git a/src/battle/battle_controller_player.c b/src/battle/battle_controller_player.c index 31f8331ffc..f516766da2 100644 --- a/src/battle/battle_controller_player.c +++ b/src/battle/battle_controller_player.c @@ -4,6 +4,7 @@ #include "battle/battle_controller_opponent.h" #include "battle/battle_system.h" #include "battle/overlay_12_0224E4FC.h" +#include "battle/battle_022378C0.h" #include "heap.h" #include "constants/abilities.h" #include "constants/items.h" diff --git a/src/battle/battle_system.c b/src/battle/battle_system.c index 189b57b8c3..260b259873 100644 --- a/src/battle/battle_system.c +++ b/src/battle/battle_system.c @@ -1,15 +1,20 @@ #include "global.h" #include "battle/battle_hp_bar.h" +#include "battle/battle_controller.h" #include "battle/battle_controller_opponent.h" #include "battle/battle_system.h" +#include "battle/battle_022378C0.h" +#include "battle/battle_02265E28.h" #include "msgdata.h" #include "party.h" #include "pokemon_mood.h" #include "text.h" #include "battle/overlay_12_0224E4FC.h" #include "battle/overlay_12_0226BEC4.h" +#include "battle/overlay_12_02266024.h" #include "constants/game_stats.h" #include "constants/message_tags.h" +#include "constants/sndseq.h" #include "unk_0202FBCC.h" #include "unk_0200FA24.h" #include "unk_02005D10.h" @@ -20,6 +25,20 @@ static void BattleSystem_BufferMessage(BattleSystem *bsys, BattleMessage *msg); static void BattleMessage_BufferNickname(BattleSystem *bsys, int bufferIndex, int param); static void BattleMessage_BufferMove(BattleSystem *bsys, int bufferIndex, int param); static void BattleMessage_BufferItem(BattleSystem *bsys, int bufferIndex, int param); +static void BattleMessage_BufferNumber(BattleSystem *bsys, int bufferIndex, int param); +static void BattleMessage_BufferNumbers(BattleSystem *bsys, int bufferIndex, int param, int a3); +static void BattleMessage_BufferType(BattleSystem *bsys, int bufferIndex, int param); +static void BattleMessage_BufferAbility(BattleSystem *bsys, int bufferIndex, int param); +static void BattleMessage_BufferStat(BattleSystem *bsys, int bufferIndex, int param); +static void BattleMessage_BufferStatus(BattleSystem *bsys, int bufferIndex, int param); +static void BattleMessage_BufferPokemon(BattleSystem *bsys, int bufferIndex, int param); +static void BattleMessage_BufferPoffin(BattleSystem *bsys, int bufferIndex, int param); +static void BattleMessage_BufferFlavorPreference(BattleSystem *bsys, int bufferIndex, int param); +static void BattleMessage_BufferTrainerClass(BattleSystem *bsys, int bufferIndex, int param); +static void BattleMessage_BufferTrainerName(BattleSystem *bsys, int bufferIndex, int param); +static void BattleMessage_BufferBoxName(BattleSystem *bsys, int bufferIndex, int param); +static void BattleMessage_ExpandPlaceholders(BattleSystem *bsys, MsgData *data, BattleMessage *msg); +static BOOL ov12_0223CF14(struct TextPrinterTemplate *template, u16 glyphId); BgConfig *BattleSystem_GetBgConfig(BattleSystem *bsys) { return bsys->bgConfig; @@ -1406,7 +1425,7 @@ u32 BattleSystem_PrintBattleMessage(BattleSystem *bsys, MsgData *data, BattleMes Window *window = BattleSystem_GetWindow(bsys, 0); BattleSystem_AdjustMessageForSide(bsys, msg); BattleSystem_BufferMessage(bsys, msg); - ov12_0223CEF4(bsys, data, msg); + BattleMessage_ExpandPlaceholders(bsys, data, msg); FillWindowPixelBuffer(window, 0xFF); return AddTextPrinterParameterized(window, 1, bsys->msgBuffer, 0, 0, delay, ov12_0223CF14); } @@ -1416,7 +1435,7 @@ u32 ov12_0223C4E8(BattleSystem *bsys, Window *window, MsgData *data, BattleMessa BattleSystem_AdjustMessageForSide(bsys, msg); BattleSystem_BufferMessage(bsys, msg); - ov12_0223CEF4(bsys, data, msg); + BattleMessage_ExpandPlaceholders(bsys, data, msg); if (flag & 1) { FillWindowPixelBuffer(window, 0xFF); @@ -1854,3 +1873,91 @@ static void BattleMessage_BufferMove(BattleSystem *bsys, int bufferIndex, int pa static void BattleMessage_BufferItem(BattleSystem *bsys, int bufferIndex, int param) { BufferItemName(bsys->msgFormat, bufferIndex, param); } + +static void BattleMessage_BufferNumber(BattleSystem *bsys, int bufferIndex, int param) { + BufferIntegerAsString(bsys->msgFormat, bufferIndex, param, 5, PRINTING_MODE_LEFT_ALIGN, TRUE); +} + +static void BattleMessage_BufferNumbers(BattleSystem *bsys, int bufferIndex, int param, int a3) { + if (a3) { + BufferIntegerAsString(bsys->msgFormat, bufferIndex, param, a3, PRINTING_MODE_RIGHT_ALIGN, TRUE); + } else { + BufferIntegerAsString(bsys->msgFormat, bufferIndex, param, 5, PRINTING_MODE_RIGHT_ALIGN, TRUE); + } + +} + +static void BattleMessage_BufferType(BattleSystem *bsys, int bufferIndex, int param) { + BufferTypeName(bsys->msgFormat, bufferIndex, param); +} + +static void BattleMessage_BufferAbility(BattleSystem *bsys, int bufferIndex, int param) { + BufferAbilityName(bsys->msgFormat, bufferIndex, param); +} + +static void BattleMessage_BufferStat(BattleSystem *bsys, int bufferIndex, int param) { + BufferStatName(bsys->msgFormat, bufferIndex, param); +} + +static void BattleMessage_BufferStatus(BattleSystem *bsys, int bufferIndex, int param) { + BufferStatusName(bsys->msgFormat, bufferIndex, param); +} + +static void BattleMessage_BufferPokemon(BattleSystem *bsys, int bufferIndex, int param) { + Pokemon *mon = BattleSystem_GetPartyMon(bsys, param & 0xFF, (param & 0xFF00) >> 8); + BufferBoxMonSpeciesName(bsys->msgFormat, bufferIndex, &mon->box); +} + +static void BattleMessage_BufferPoffin(BattleSystem *bsys, int bufferIndex, int param) { + //poffins don't exist in HGSS +} + +static void BattleMessage_BufferFlavorPreference(BattleSystem *bsys, int bufferIndex, int param) { + BufferFlavorDislikeText(bsys->msgFormat, bufferIndex, param); +} + +static void BattleMessage_BufferTrainerClass(BattleSystem *bsys, int bufferIndex, int param) { + Trainer *trainer = BattleSystem_GetTrainer(bsys, param); + BufferTrainerClassNameFromDataStruct(bsys->msgFormat, bufferIndex, trainer); +} + +static void BattleMessage_BufferTrainerName(BattleSystem *bsys, int bufferIndex, int param) { + Trainer *trainer = BattleSystem_GetTrainer(bsys, param); + BufferTrainerNameFromDataStruct(bsys->msgFormat, bufferIndex, trainer); +} + +static void BattleMessage_BufferBoxName(BattleSystem *bsys, int bufferIndex, int param) { + BufferPCBoxName(bsys->msgFormat, bufferIndex, bsys->storage, param); +} + +static void BattleMessage_ExpandPlaceholders(BattleSystem *bsys, MsgData *data, BattleMessage *msg) { + String *str = NewString_ReadMsgData(data, msg->id); + StringExpandPlaceholders(bsys->msgFormat, bsys->msgBuffer, str); + String_Delete(str); +} + +static BOOL ov12_0223CF14(struct TextPrinterTemplate *template, u16 glyphId) { + BOOL ret = FALSE; + + switch (glyphId) { + case 1: + ret = GF_IsAnySEPlaying(); + break; + case 2: + ret = IsFanfarePlaying(); + break; + case 3: + PlayFanfare(0x4A3); + break; + case 4: + PlaySE(SEQ_SE_DP_KON); + break; + case 5: + PlayFanfare(0x4A0); + break; + default: + break; + } + + return ret; +} From 74d1e5c7e1be3911bbe0005f11fb0c9945d1c087 Mon Sep 17 00:00:00 2001 From: Adrienn Tindall <33725376+adrienntindall@users.noreply.github.com> Date: Tue, 19 Dec 2023 11:35:24 -0500 Subject: [PATCH 26/33] Address review changes --- include/battle/overlay_12_02266024.h | 2 +- src/battle/battle_022378C0.c | 6 +++--- src/battle/battle_system.c | 9 +++++---- src/list_menu_2d.c | 2 +- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/include/battle/overlay_12_02266024.h b/include/battle/overlay_12_02266024.h index 2c4c259beb..5181a3ef81 100644 --- a/include/battle/overlay_12_02266024.h +++ b/include/battle/overlay_12_02266024.h @@ -7,7 +7,7 @@ void *ov12_022660D0(NARC *a0, NARC *a1, BattleSystem *bsys, u32 gender, void *a4); BOOL ov12_02266C64(u32 *a0); BOOL ov12_02266B78(u32 *a0); -void ov12_02266390(void *); +void ov12_02266390(void *a0); void ov12_02266508(NARC *a0, NARC *a1, void *a2, int a3, BOOL a4, void *a5); void ov12_02266644(NARC *a0, void *a1); void ov12_0226AA8C(u32 *a1, u32 flag); diff --git a/src/battle/battle_022378C0.c b/src/battle/battle_022378C0.c index bd3b59b826..afbd939a3f 100644 --- a/src/battle/battle_022378C0.c +++ b/src/battle/battle_022378C0.c @@ -238,8 +238,8 @@ void ov12_02237CC4(BattleSystem *bsys) { GfGfx_EngineATogglePlanes(GX_PLANEMASK_BG0, GF_PLANE_TOGGLE_OFF); GfGfx_EngineATogglePlanes(GX_PLANEMASK_BG1, GF_PLANE_TOGGLE_OFF); - FreeBgTilemapBuffer(bsys->bgConfig, 1); - FreeBgTilemapBuffer(bsys->bgConfig, 2); - FreeBgTilemapBuffer(bsys->bgConfig, 3); + FreeBgTilemapBuffer(bsys->bgConfig, GF_BG_LYR_MAIN_1); + FreeBgTilemapBuffer(bsys->bgConfig, GF_BG_LYR_MAIN_2); + FreeBgTilemapBuffer(bsys->bgConfig, GF_BG_LYR_MAIN_3); BattleSystem_SetHpBarDisabled(bsys); } diff --git a/src/battle/battle_system.c b/src/battle/battle_system.c index 260b259873..44c91d00a5 100644 --- a/src/battle/battle_system.c +++ b/src/battle/battle_system.c @@ -18,6 +18,7 @@ #include "unk_0202FBCC.h" #include "unk_0200FA24.h" #include "unk_02005D10.h" +#include "msgdata/msg/msg_0197.h" static u8 ov12_0223BFB0(u8 *buffer, u8 *index, u16 *size); static void BattleSystem_AdjustMessageForSide(BattleSystem *bsys, BattleMessage *msg); @@ -1388,9 +1389,9 @@ u8 BattleSystem_PrintTrainerMessage(BattleSystem *bsys, int trainerId, int battl int i; if (a2 == 0x64) { - stringId = trainerId*3 + 1; + stringId = trainerId * 3 + 1; } else { - stringId = trainerId*3 + 2; + stringId = trainerId * 3 + 2; } for (i = 0; i < 4; i++) { @@ -1400,9 +1401,9 @@ u8 BattleSystem_PrintTrainerMessage(BattleSystem *bsys, int trainerId, int battl } if (i == 4) { - msgId = 724; + msgId = msg_0197_00724; } else { - msgId = 723; + msgId = msg_0197_00723; } data = NewMsgDataFromNarc(MSGDATA_LOAD_DIRECT, NARC_msgdata_msg, msgId, HEAP_ID_BATTLE); diff --git a/src/list_menu_2d.c b/src/list_menu_2d.c index 3c1e6e8c03..c80745bfdb 100644 --- a/src/list_menu_2d.c +++ b/src/list_menu_2d.c @@ -175,7 +175,7 @@ static u8 Get2dMenuMaxItemWidth(struct ListMenu2D *listMenu) { static void Print2dMenuItemTexts(struct ListMenu2D *listMenu) { u8 i, j; u8 dx; - u8 x; + u8 x; FillWindowPixelBuffer(listMenu->template.window, GetFontAttribute(listMenu->template.fontId, 6)); x = listMenu->x; dx = listMenu->maxItemWidth + listMenu->maxGlyphWidth * 2; From b3e6499bc13a01a64beb4cc7e70779cf33ab7347 Mon Sep 17 00:00:00 2001 From: Adrienn Tindall <33725376+adrienntindall@users.noreply.github.com> Date: Wed, 20 Dec 2023 02:41:37 -0500 Subject: [PATCH 27/33] Battle Controller Player Safari Functions --- asm/overlay_12_battle_controller_player.s | 109 +--------------------- include/battle/battle_controller_player.h | 2 + src/battle/battle_controller_player.c | 35 +++++++ 3 files changed, 42 insertions(+), 104 deletions(-) diff --git a/asm/overlay_12_battle_controller_player.s b/asm/overlay_12_battle_controller_player.s index bd60f4b304..c9326f4111 100644 --- a/asm/overlay_12_battle_controller_player.s +++ b/asm/overlay_12_battle_controller_player.s @@ -23,108 +23,9 @@ .public BattleControllerPlayer_PokemonInput .public BattleControllerPlayer_RunInput .public BattleControllerPlayer_SafariBallInput - - thumb_func_start ov12_0224ADA0 -ov12_0224ADA0: ; 0x0224ADA0 - push {r3, r4, r5, lr} - add r4, r1, #0 - add r5, r0, #0 - add r0, r4, #0 - mov r1, #1 - mov r2, #0xe3 - bl ReadBattleScriptFromNarc - mov r0, #0 - str r0, [r4, #0x64] - mov r0, #1 - str r0, [r4, #0x6c] - mov r0, #0x16 - str r0, [r4, #8] - mov r0, #0x28 - str r0, [r4, #0xc] - add r0, r5, #0 - bl BattleSystem_Random - mov r1, #0xa - bl _s32_div_f - mov r0, #0x4e - lsl r0, r0, #2 - str r1, [r4, r0] - ldr r0, _0224ADFC ; =0x0000311D - ldrb r1, [r4, r0] - cmp r1, #0 - beq _0224ADDE - sub r1, r1, #1 - strb r1, [r4, r0] -_0224ADDE: - mov r0, #0x4e - lsl r0, r0, #2 - ldr r1, [r4, r0] - cmp r1, #0 - beq _0224ADFA - mov r1, #1 - sub r0, #8 - str r1, [r4, r0] - ldr r0, _0224AE00 ; =0x0000311C - ldrb r1, [r4, r0] - cmp r1, #0 - beq _0224ADFA - sub r1, r1, #1 - strb r1, [r4, r0] -_0224ADFA: - pop {r3, r4, r5, pc} - .balign 4, 0 -_0224ADFC: .word 0x0000311D -_0224AE00: .word 0x0000311C - thumb_func_end ov12_0224ADA0 - - thumb_func_start ov12_0224AE04 -ov12_0224AE04: ; 0x0224AE04 - push {r3, r4, r5, lr} - add r4, r1, #0 - add r5, r0, #0 - add r0, r4, #0 - mov r1, #1 - mov r2, #0xe4 - bl ReadBattleScriptFromNarc - mov r0, #0 - str r0, [r4, #0x64] - mov r0, #1 - str r0, [r4, #0x6c] - mov r0, #0x16 - str r0, [r4, #8] - mov r0, #0x28 - str r0, [r4, #0xc] - add r0, r5, #0 - bl BattleSystem_Random - mov r1, #0xa - bl _s32_div_f - mov r0, #0x4e - lsl r0, r0, #2 - str r1, [r4, r0] - ldr r0, _0224AE5C ; =0x0000311C - ldrb r1, [r4, r0] - cmp r1, #0xc - bhs _0224AE42 - add r1, r1, #1 - strb r1, [r4, r0] -_0224AE42: - mov r0, #0x4e - lsl r0, r0, #2 - ldr r0, [r4, r0] - cmp r0, #0 - beq _0224AE58 - ldr r0, _0224AE60 ; =0x0000311D - ldrb r1, [r4, r0] - cmp r1, #0xc - bhs _0224AE58 - add r1, r1, #1 - strb r1, [r4, r0] -_0224AE58: - pop {r3, r4, r5, pc} - nop -_0224AE5C: .word 0x0000311C -_0224AE60: .word 0x0000311D - thumb_func_end ov12_0224AE04 - + .public BattleControllerPlayer_SafariThrowMud + .public BattleControllerPlayer_SafariRun + thumb_func_start ov12_0224AE64 ov12_0224AE64: ; 0x0224AE64 push {r4, lr} @@ -7241,8 +7142,8 @@ sPlayerBattleCommands: ; 0x0226CA90 .word BattleControllerPlayer_PokemonInput .word BattleControllerPlayer_RunInput .word BattleControllerPlayer_SafariBallInput - .word ov12_0224ADA0 - .word ov12_0224AE04 + .word BattleControllerPlayer_SafariThrowMud + .word BattleControllerPlayer_SafariRun .word ov12_0224AE64 .word ov12_0224AE84 .word ov12_0224C370 diff --git a/include/battle/battle_controller_player.h b/include/battle/battle_controller_player.h index 0fda1b1691..29fe753ff6 100644 --- a/include/battle/battle_controller_player.h +++ b/include/battle/battle_controller_player.h @@ -27,6 +27,8 @@ void BattleControllerPlayer_ItemInput(BattleSystem *bsys, BattleContext *ctx); void BattleControllerPlayer_PokemonInput(BattleSystem *bsys, BattleContext *ctx); void BattleControllerPlayer_RunInput(BattleSystem *bsys, BattleContext *ctx); void BattleControllerPlayer_SafariBallInput(BattleSystem *bsys, BattleContext *ctx); +void BattleControllerPlayer_SafariThrowMud(BattleSystem *bsys, BattleContext *ctx); +void BattleControllerPlayer_SafariRun(BattleSystem *bsys, BattleContext *ctx); //The following functions haven't been decompiled yet void ov12_0224E384(BattleSystem *bsys, BattleContext *ctx); diff --git a/src/battle/battle_controller_player.c b/src/battle/battle_controller_player.c index f516766da2..bee44296a7 100644 --- a/src/battle/battle_controller_player.c +++ b/src/battle/battle_controller_player.c @@ -1703,3 +1703,38 @@ void BattleControllerPlayer_SafariBallInput(BattleSystem *bsys, BattleContext *c BattleSystem_SetSafariBallCount(bsys, cnt); ov12_02263A1C(bsys, ctx, BATTLER_PLAYER); } + +//static +void BattleControllerPlayer_SafariThrowMud(BattleSystem *bsys, BattleContext *ctx) { + ReadBattleScriptFromNarc(ctx, NARC_a_0_0_1, 227); + ctx->battlerIdAttacker = 0; + ctx->battlerIdTarget = 1; + ctx->command = CONTROLLER_COMMAND_RUN_SCRIPT; + ctx->commandNext = CONTROLLER_COMMAND_40; + ctx->tempData = BattleSystem_Random(bsys) % 10; + if (ctx->safariRunAttempts > 0) { + ctx->safariRunAttempts--; + } + if (ctx->tempData != 0) { + ctx->msgTemp = 1; + if (ctx->unk_311C > 0) { + ctx->unk_311C--; + } + } +} + +//static +void BattleControllerPlayer_SafariRun(BattleSystem *bsys, BattleContext *ctx) { + ReadBattleScriptFromNarc(ctx, NARC_a_0_0_1, 228); + ctx->battlerIdAttacker = 0; + ctx->battlerIdTarget = 1; + ctx->command = CONTROLLER_COMMAND_RUN_SCRIPT; + ctx->commandNext = CONTROLLER_COMMAND_40; + ctx->tempData = BattleSystem_Random(bsys) % 10; + if (ctx->unk_311C < 12) { + ctx->unk_311C++; + } + if (ctx->tempData != 0 && ctx->safariRunAttempts < 12) { + ctx->safariRunAttempts++; + } +} From 5d4c08f6c0a66b78ecf065b6b09456cf7eb68621 Mon Sep 17 00:00:00 2001 From: Adrienn Tindall <33725376+adrienntindall@users.noreply.github.com> Date: Fri, 22 Dec 2023 11:08:33 -0500 Subject: [PATCH 28/33] Disobedience code https://www.youtube.com/watch?v=Mpi0wyVRP0I --- asm/overlay_12_battle_controller_player.s | 467 +--------------------- include/battle/battle_controller_player.h | 5 +- include/player_data.h | 2 +- src/battle/battle_controller_player.c | 163 +++++++- src/player_data.c | 2 +- 5 files changed, 176 insertions(+), 463 deletions(-) diff --git a/asm/overlay_12_battle_controller_player.s b/asm/overlay_12_battle_controller_player.s index c9326f4111..22501d6db2 100644 --- a/asm/overlay_12_battle_controller_player.s +++ b/asm/overlay_12_battle_controller_player.s @@ -22,464 +22,13 @@ .public BattleControllerPlayer_ItemInput .public BattleControllerPlayer_PokemonInput .public BattleControllerPlayer_RunInput - .public BattleControllerPlayer_SafariBallInput + .public BattleControllerPlayer_SafariThrowBall .public BattleControllerPlayer_SafariThrowMud .public BattleControllerPlayer_SafariRun + .public BattleControllerPlayer_SafariWatching + .public BattleControllerPlayer_CatchingContestThrowBall + .public TryDisobedience - thumb_func_start ov12_0224AE64 -ov12_0224AE64: ; 0x0224AE64 - push {r4, lr} - add r4, r1, #0 - add r0, r4, #0 - mov r1, #1 - mov r2, #0xe5 - bl ReadBattleScriptFromNarc - mov r0, #0 - str r0, [r4, #0x64] - mov r0, #1 - str r0, [r4, #0x6c] - mov r0, #0x16 - str r0, [r4, #8] - mov r0, #0x28 - str r0, [r4, #0xc] - pop {r4, pc} - thumb_func_end ov12_0224AE64 - - thumb_func_start ov12_0224AE84 -ov12_0224AE84: ; 0x0224AE84 - push {r3, r4, r5, lr} - add r4, r1, #0 - add r5, r0, #0 - add r0, r4, #0 - mov r1, #1 - mov r2, #0xb - bl ReadBattleScriptFromNarc - mov r0, #0 - str r0, [r4, #0x64] - mov r0, #1 - str r0, [r4, #0x6c] - mov r0, #0x16 - str r0, [r4, #8] - mov r0, #0x28 - ldr r1, _0224AEC8 ; =0x000001F3 - str r0, [r4, #0xc] - add r0, r1, #0 - sub r0, #0xcb - str r1, [r4, r0] - add r0, r5, #0 - bl BattleSystem_GetSafariBallCount - sub r1, r0, #1 - add r0, r5, #0 - bl BattleSystem_SetSafariBallCount - ldr r1, _0224AECC ; =0x0000216C - mov r0, #2 - ldr r2, [r4, r1] - lsl r0, r0, #0x1e - orr r0, r2 - str r0, [r4, r1] - pop {r3, r4, r5, pc} - .balign 4, 0 -_0224AEC8: .word 0x000001F3 -_0224AECC: .word 0x0000216C - thumb_func_end ov12_0224AE84 - - thumb_func_start ov12_0224AED0 -ov12_0224AED0: ; 0x0224AED0 - push {r3, r4, r5, r6, r7, lr} - sub sp, #0x30 - add r5, r0, #0 - add r4, r1, #0 - add r7, r2, #0 - bl BattleSystem_GetBattleType - add r6, r0, #0 - add r0, r5, #0 - mov r1, #0 - bl BattleSystem_GetPlayerProfile - str r0, [sp, #0x28] - mov r0, #0x84 - tst r0, r6 - beq _0224AEF6 - add sp, #0x30 - mov r0, #0 - pop {r3, r4, r5, r6, r7, pc} -_0224AEF6: - ldr r1, [r4, #0x64] - add r0, r5, #0 - bl BattleSystem_GetFieldSide - cmp r0, #0 - beq _0224AF08 - add sp, #0x30 - mov r0, #0 - pop {r3, r4, r5, r6, r7, pc} -_0224AF08: - mov r0, #0x40 - tst r0, r6 - beq _0224AF20 - ldr r1, [r4, #0x64] - add r0, r5, #0 - bl ov12_0223AB0C - cmp r0, #4 - bne _0224AF20 - add sp, #0x30 - mov r0, #0 - pop {r3, r4, r5, r6, r7, pc} -_0224AF20: - add r0, r5, #0 - add r1, r4, #0 - bl ov12_02256854 - cmp r0, #1 - bne _0224AF32 - add sp, #0x30 - mov r0, #0 - pop {r3, r4, r5, r6, r7, pc} -_0224AF32: - ldr r1, [r4, #0x64] - add r0, r4, #0 - bl Battler_CanSelectAction - cmp r0, #0 - bne _0224AF44 - add sp, #0x30 - mov r0, #0 - pop {r3, r4, r5, r6, r7, pc} -_0224AF44: - ldr r0, _0224B1D0 ; =0x00003044 - ldr r0, [r4, r0] - cmp r0, #0x75 - bne _0224AF5E - ldr r0, _0224B1D4 ; =0x0000213C - ldr r1, [r4, r0] - mov r0, #2 - lsl r0, r0, #8 - tst r0, r1 - beq _0224AF5E - add sp, #0x30 - mov r0, #0 - pop {r3, r4, r5, r6, r7, pc} -_0224AF5E: - ldr r0, [sp, #0x28] - bl PlayerProfile_CountBadges - cmp r0, #8 - blt _0224AF6E - add sp, #0x30 - mov r0, #0 - pop {r3, r4, r5, r6, r7, pc} -_0224AF6E: - ldr r0, [sp, #0x28] - mov r6, #0xa - bl PlayerProfile_CountBadges - cmp r0, #1 - blt _0224AF7C - mov r6, #0x14 -_0224AF7C: - ldr r0, [sp, #0x28] - bl PlayerProfile_CountBadges - cmp r0, #2 - blt _0224AF88 - mov r6, #0x1e -_0224AF88: - ldr r0, [sp, #0x28] - mov r1, #3 - bl PlayerProfile_TestBadgeFlag - cmp r0, #0 - beq _0224AF96 - mov r6, #0x32 -_0224AF96: - ldr r0, [sp, #0x28] - mov r1, #5 - bl PlayerProfile_TestBadgeFlag - cmp r0, #0 - beq _0224AFA4 - mov r6, #0x46 -_0224AFA4: - ldr r1, [r4, #0x64] - mov r0, #0xc0 - mul r0, r1 - str r0, [sp, #0x20] - add r1, r4, r0 - ldr r0, _0224B1D8 ; =0x00002D74 - ldrb r0, [r1, r0] - cmp r0, r6 - bhi _0224AFBC - add sp, #0x30 - mov r0, #0 - pop {r3, r4, r5, r6, r7, pc} -_0224AFBC: - add r0, r5, #0 - bl BattleSystem_Random - ldr r1, [sp, #0x20] - lsl r0, r0, #0x18 - add r2, r4, r1 - ldr r1, _0224B1D8 ; =0x00002D74 - lsr r0, r0, #0x18 - ldrb r2, [r2, r1] - add r2, r6, r2 - mul r0, r2 - asr r0, r0, #8 - cmp r0, r6 - bge _0224AFDE - add sp, #0x30 - mov r0, #0 - pop {r3, r4, r5, r6, r7, pc} -_0224AFDE: - ldr r0, _0224B1D0 ; =0x00003044 - ldr r0, [r4, r0] - cmp r0, #0x63 - bne _0224AFF6 - add r1, #0x3c - add r0, r4, r1 - ldr r1, [sp, #0x20] - ldr r2, [r0, r1] - ldr r1, _0224B1DC ; =0xFF7FFFFF - and r2, r1 - ldr r1, [sp, #0x20] - str r2, [r0, r1] -_0224AFF6: - ldr r0, [r4, #0x64] - mov r1, #0xc0 - mul r1, r0 - str r0, [sp, #0x1c] - ldr r0, _0224B1E0 ; =0x00002DAC - add r1, r4, r1 - ldr r1, [r1, r0] - mov r0, #7 - tst r0, r1 - beq _0224B020 - ldr r0, _0224B1D0 ; =0x00003044 - ldr r0, [r4, r0] - cmp r0, #0xad - beq _0224B016 - cmp r0, #0xd6 - bne _0224B020 -_0224B016: - mov r0, #0xfe - str r0, [r7] - add sp, #0x30 - mov r0, #1 - pop {r3, r4, r5, r6, r7, pc} -_0224B020: - ldr r0, [sp, #0x1c] - mov r1, #0xc0 - mul r1, r0 - ldr r0, _0224B1D8 ; =0x00002D74 - add r1, r4, r1 - ldrb r0, [r1, r0] - str r0, [sp, #0x24] - add r0, r5, #0 - bl BattleSystem_Random - ldr r1, [sp, #0x24] - lsl r0, r0, #0x18 - add r1, r6, r1 - lsr r0, r0, #0x18 - mul r0, r1 - asr r0, r0, #8 - cmp r0, r6 - bge _0224B108 - ldr r0, [sp, #0x1c] - lsl r0, r0, #1 - add r1, r4, r0 - ldr r0, _0224B1E4 ; =0x000030BC - ldrh r0, [r1, r0] - bl MaskOfFlagNo - add r3, r0, #0 - mov r0, #0 - mvn r0, r0 - str r0, [sp] - ldr r2, [r4, #0x64] - add r0, r5, #0 - add r1, r4, #0 - bl StruggleCheck - add r6, r0, #0 - cmp r6, #0xf - bne _0224B074 - mov r0, #0xff - str r0, [r7] - add sp, #0x30 - mov r0, #1 - pop {r3, r4, r5, r6, r7, pc} -_0224B074: - add r0, r5, #0 - bl BattleSystem_Random - mov r1, #3 - and r0, r1 - str r0, [sp, #0x2c] - bl MaskOfFlagNo - tst r0, r6 - bne _0224B074 - ldr r0, [r4, #0x64] - ldr r3, _0224B1E4 ; =0x000030BC - lsl r0, r0, #1 - add r1, r4, r0 - ldr r0, [sp, #0x2c] - strh r0, [r1, r3] - ldr r1, [r4, #0x64] - mov r0, #0xc0 - mul r0, r1 - lsl r1, r1, #1 - add r1, r4, r1 - ldrh r1, [r1, r3] - add r0, r4, r0 - lsl r1, r1, #1 - add r1, r0, r1 - ldr r0, _0224B1E8 ; =0x00002D4C - ldrh r1, [r1, r0] - add r0, r3, #0 - sub r0, #0x7c - str r1, [r4, r0] - add r0, r3, #0 - sub r0, #0x7c - ldr r1, [r4, r0] - add r0, r3, #0 - sub r0, #0x78 - str r1, [r4, r0] - mov r0, #1 - str r0, [sp] - mov r0, #0 - str r0, [sp, #4] - sub r3, #0x7c - ldr r3, [r4, r3] - ldr r2, [r4, #0x64] - lsl r3, r3, #0x10 - add r0, r5, #0 - add r1, r4, #0 - lsr r3, r3, #0x10 - bl ov12_022506D4 - str r0, [r4, #0x6c] - cmp r0, #0xff - bne _0224B0E8 - ldr r2, [r4, #0x64] - add r0, r5, #0 - add r1, r4, #0 - bl ov12_02253DA0 - b _0224B0E8 -_0224B0E8: - ldr r1, [r4, #0x64] - add sp, #0x30 - lsl r1, r1, #4 - add r2, r4, r1 - ldr r1, _0224B1EC ; =0x000021AC - str r0, [r2, r1] - mov r0, #1 - lsl r0, r0, #8 - str r0, [r7] - ldr r1, _0224B1F0 ; =0x00002184 - mov r0, #1 - ldr r2, [r4, r1] - orr r0, r2 - str r0, [r4, r1] - mov r0, #2 - pop {r3, r4, r5, r6, r7, pc} -_0224B108: - ldr r0, [sp, #0x24] - sub r0, r0, r6 - lsl r0, r0, #0x18 - lsr r6, r0, #0x18 - add r0, r5, #0 - bl BattleSystem_Random - lsl r0, r0, #0x18 - lsr r0, r0, #0x18 - str r0, [sp, #0x18] - cmp r0, r6 - bge _0224B160 - ldr r1, [r4, #0x64] - mov r0, #0xc0 - mul r0, r1 - add r2, r4, r0 - ldr r0, _0224B1E0 ; =0x00002DAC - ldr r0, [r2, r0] - lsl r0, r0, #0x18 - lsr r0, r0, #0x18 - bne _0224B160 - add r0, r4, #0 - bl GetBattlerAbility - cmp r0, #0x48 - beq _0224B160 - ldr r1, [r4, #0x64] - add r0, r4, #0 - bl GetBattlerAbility - cmp r0, #0xf - beq _0224B160 - mov r1, #6 - lsl r1, r1, #6 - mov r0, #0xf - ldr r2, [r4, r1] - lsl r0, r0, #8 - tst r0, r2 - bne _0224B160 - sub r1, #0x7f - add sp, #0x30 - str r1, [r7] - mov r0, #1 - pop {r3, r4, r5, r6, r7, pc} -_0224B160: - ldr r0, [sp, #0x18] - sub r0, r0, r6 - cmp r0, r6 - bge _0224B1C6 - ldr r1, [r4, #0x64] - mov r0, #0x46 - str r1, [r4, #0x6c] - lsl r0, r0, #2 - str r1, [r4, r0] - ldr r1, [r4, #0x64] - mov r3, #0 - str r3, [sp] - mov r0, #0x28 - str r0, [sp, #4] - lsl r0, r1, #0x18 - str r3, [sp, #8] - lsr r0, r0, #0x18 - str r0, [sp, #0xc] - str r0, [sp, #0x10] - mov r2, #1 - add r0, r5, #0 - add r1, r4, #0 - str r2, [sp, #0x14] - bl CalcMoveDamage - ldr r2, _0224B1F4 ; =0x0000215C - add r1, r4, #0 - str r0, [r4, r2] - ldr r2, [r4, r2] - add r0, r5, #0 - bl ApplyDamageRange - ldr r1, _0224B1F4 ; =0x0000215C - add sp, #0x30 - str r0, [r4, r1] - mov r0, #0 - ldr r2, [r4, r1] - mvn r0, r0 - mul r0, r2 - str r0, [r4, r1] - ldr r0, _0224B1F8 ; =0x00000102 - str r0, [r7] - add r0, r1, #0 - sub r0, #0x20 - ldr r2, [r4, r0] - mov r0, #2 - orr r0, r2 - sub r1, #0x20 - str r0, [r4, r1] - mov r0, #3 - pop {r3, r4, r5, r6, r7, pc} -_0224B1C6: - mov r0, #0xff - str r0, [r7] - mov r0, #1 - add sp, #0x30 - pop {r3, r4, r5, r6, r7, pc} - .balign 4, 0 -_0224B1D0: .word 0x00003044 -_0224B1D4: .word 0x0000213C -_0224B1D8: .word 0x00002D74 -_0224B1DC: .word 0xFF7FFFFF -_0224B1E0: .word 0x00002DAC -_0224B1E4: .word 0x000030BC -_0224B1E8: .word 0x00002D4C -_0224B1EC: .word 0x000021AC -_0224B1F0: .word 0x00002184 -_0224B1F4: .word 0x0000215C -_0224B1F8: .word 0x00000102 - thumb_func_end ov12_0224AED0 - thumb_func_start ov12_0224B1FC ov12_0224B1FC: ; 0x0224B1FC push {r3, r4, r5, r6, r7, lr} @@ -2789,7 +2338,7 @@ _0224C3D6: add r0, r5, #0 add r1, r4, #0 add r2, sp, #0 - bl ov12_0224AED0 + bl TryDisobedience cmp r0, #0 beq _0224C41C cmp r0, #1 @@ -7141,11 +6690,11 @@ sPlayerBattleCommands: ; 0x0226CA90 .word BattleControllerPlayer_ItemInput .word BattleControllerPlayer_PokemonInput .word BattleControllerPlayer_RunInput - .word BattleControllerPlayer_SafariBallInput + .word BattleControllerPlayer_SafariThrowBall .word BattleControllerPlayer_SafariThrowMud .word BattleControllerPlayer_SafariRun - .word ov12_0224AE64 - .word ov12_0224AE84 + .word BattleControllerPlayer_SafariWatching + .word BattleControllerPlayer_CatchingContestThrowBall .word ov12_0224C370 .word ov12_0224C38C .word ov12_0224C4D8 diff --git a/include/battle/battle_controller_player.h b/include/battle/battle_controller_player.h index 29fe753ff6..e97482f1f0 100644 --- a/include/battle/battle_controller_player.h +++ b/include/battle/battle_controller_player.h @@ -26,9 +26,12 @@ void BattleControllerPlayer_FightInput(BattleSystem *bsys, BattleContext *ctx); void BattleControllerPlayer_ItemInput(BattleSystem *bsys, BattleContext *ctx); void BattleControllerPlayer_PokemonInput(BattleSystem *bsys, BattleContext *ctx); void BattleControllerPlayer_RunInput(BattleSystem *bsys, BattleContext *ctx); -void BattleControllerPlayer_SafariBallInput(BattleSystem *bsys, BattleContext *ctx); +void BattleControllerPlayer_SafariThrowBall(BattleSystem *bsys, BattleContext *ctx); void BattleControllerPlayer_SafariThrowMud(BattleSystem *bsys, BattleContext *ctx); void BattleControllerPlayer_SafariRun(BattleSystem *bsys, BattleContext *ctx); +void BattleControllerPlayer_SafariWatching(BattleSystem *bsys, BattleContext *ctx); +void BattleControllerPlayer_CatchingContestThrowBall(BattleSystem *bsys, BattleContext *ctx); +u32 TryDisobedience(BattleSystem *bsys, BattleContext *ctx, int *script); //The following functions haven't been decompiled yet void ov12_0224E384(BattleSystem *bsys, BattleContext *ctx); diff --git a/include/player_data.h b/include/player_data.h index b7aa37ad6e..5a95a012d4 100644 --- a/include/player_data.h +++ b/include/player_data.h @@ -54,7 +54,7 @@ void PlayerProfile_SetTrainerGender(PlayerProfile* profile, int gender); u32 PlayerProfile_GetTrainerGender(PlayerProfile* profile); BOOL PlayerProfile_TestBadgeFlag(PlayerProfile* profile, s32 badge_no); void PlayerProfile_SetBadgeFlag(PlayerProfile* profile, s32 badge_no); -u32 PlayerProfile_CountBadges(PlayerProfile* profile); +s32 PlayerProfile_CountBadges(PlayerProfile* profile); u32 PlayerProfile_GetMoney(PlayerProfile* profile); u32 PlayerProfile_SetMoney(PlayerProfile* profile, u32 amount); u8 PlayerProfile_GetAvatar(PlayerProfile* profile); diff --git a/src/battle/battle_controller_player.c b/src/battle/battle_controller_player.c index bee44296a7..27c1285763 100644 --- a/src/battle/battle_controller_player.c +++ b/src/battle/battle_controller_player.c @@ -1690,7 +1690,7 @@ void BattleControllerPlayer_RunInput(BattleSystem *bsys, BattleContext *ctx) { } //static -void BattleControllerPlayer_SafariBallInput(BattleSystem *bsys, BattleContext *ctx) { +void BattleControllerPlayer_SafariThrowBall(BattleSystem *bsys, BattleContext *ctx) { int cnt; ReadBattleScriptFromNarc(ctx, NARC_a_0_0_1, 275); @@ -1738,3 +1738,164 @@ void BattleControllerPlayer_SafariRun(BattleSystem *bsys, BattleContext *ctx) { ctx->safariRunAttempts++; } } + +//static +void BattleControllerPlayer_SafariWatching(BattleSystem *bsys, BattleContext *ctx) { + ReadBattleScriptFromNarc(ctx, NARC_a_0_0_1, 229); + ctx->battlerIdAttacker = 0; + ctx->battlerIdTarget = 1; + ctx->command = CONTROLLER_COMMAND_RUN_SCRIPT; + ctx->commandNext = CONTROLLER_COMMAND_40; +} + +//static +void BattleControllerPlayer_CatchingContestThrowBall(BattleSystem *bsys, BattleContext *ctx) { + int cnt; + + ReadBattleScriptFromNarc(ctx, NARC_a_0_0_1, 11); + ctx->battlerIdAttacker = BATTLER_PLAYER; + ctx->battlerIdTarget = BATTLER_ENEMY; + ctx->command = CONTROLLER_COMMAND_RUN_SCRIPT; + ctx->commandNext = CONTROLLER_COMMAND_40; + ctx->itemTemp = ITEM_SPORT_BALL; + cnt = BattleSystem_GetSafariBallCount(bsys) - 1; + BattleSystem_SetSafariBallCount(bsys, cnt); + ctx->moveStatusFlag |= 1 << 0x1F; +} + +//static +u32 TryDisobedience(BattleSystem *bsys, BattleContext *ctx, int *script) { + int rnd, struggleRnd; + u32 battleType; + u8 level; + PlayerProfile *profile; + + battleType = BattleSystem_GetBattleType(bsys); + profile = BattleSystem_GetPlayerProfile(bsys, 0); + + if (battleType & (BATTLE_TYPE_LINK | BATTLE_TYPE_TOWER)) { + return 0; + } + + if (BattleSystem_GetFieldSide(bsys, ctx->battlerIdAttacker)) { + return 0; + } + + if ((battleType & BATTLE_TYPE_6) && ov12_0223AB0C(bsys, ctx->battlerIdAttacker) == 4) { + return 0; + } + + if (ov12_02256854(bsys, ctx) == TRUE) { + return 0; + } + + if (!Battler_CanSelectAction(ctx, ctx->battlerIdAttacker)) { + return 0; + } + + if (ctx->moveNoCur == MOVE_BIDE && (ctx->battleStatus & BATTLE_STATUS_CHARGE_MOVE_HIT)) { + return 0; + } + + if (PlayerProfile_CountBadges(profile) >= 8) { + return 0; + } + + level = 10; + + if (PlayerProfile_CountBadges(profile) >= 1) { + level = 20; + } + + if (PlayerProfile_CountBadges(profile) >= 2) { + level = 30; + } + + if (PlayerProfile_TestBadgeFlag(profile, 3)) { + level = 50; + } + + if (PlayerProfile_TestBadgeFlag(profile, 5)) { + level = 70; + } + + if (ctx->battleMons[ctx->battlerIdAttacker].level <= level) { + return 0; + } + + rnd = ((BattleSystem_Random(bsys) & 0xff) * (ctx->battleMons[ctx->battlerIdAttacker].level + level)) >> 8; + + if (rnd < level) { + return 0; + } + + if (ctx->moveNoCur == MOVE_RAGE) { + ctx->battleMons[ctx->battlerIdAttacker].status2 &= ~STATUS2_23; + } + + if (ctx->battleMons[ctx->battlerIdAttacker].status & STATUS_SLEEP && (ctx->moveNoCur == MOVE_SNORE || ctx->moveNoCur == MOVE_SLEEP_TALK)) { + *script = 254; + return 1; + } + + rnd = ((BattleSystem_Random(bsys) & 0xff) * (ctx->battleMons[ctx->battlerIdAttacker].level + level)) >> 8; + + //use a random (useable) move + if (rnd < level) { + rnd = StruggleCheck(bsys, ctx, ctx->battlerIdAttacker, MaskOfFlagNo(ctx->movePos[ctx->battlerIdAttacker]), -1); + + if (rnd == 0xF) { + *script = 255; + return 1; + } + do { + struggleRnd = BattleSystem_Random(bsys) & 3; + } while (MaskOfFlagNo(struggleRnd) & rnd); + + ctx->movePos[ctx->battlerIdAttacker] = struggleRnd; + ctx->moveNoTemp = ctx->battleMons[ctx->battlerIdAttacker].moves[ctx->movePos[ctx->battlerIdAttacker]]; + ctx->moveNoCur = ctx->moveNoTemp; + ctx->battlerIdTarget = ov12_022506D4(bsys, ctx, ctx->battlerIdAttacker, ctx->moveNoTemp, 1, 0); + + if (ctx->battlerIdTarget == BATTLER_NONE) { + ctx->unk_21A8[ctx->battlerIdAttacker][1] = ov12_02253DA0(bsys, ctx, ctx->battlerIdAttacker); + } else { + ctx->unk_21A8[ctx->battlerIdAttacker][1] = ctx->battlerIdTarget; + } + + *script = 256; + ctx->unk_2184 |= 1; + + return 2; // ??? + } + + level = ctx->battleMons[ctx->battlerIdAttacker].level - level; + rnd = BattleSystem_Random(bsys) & 0xFF; + + //take a nap + if (rnd < level && !(ctx->battleMons[ctx->battlerIdAttacker].status & STATUS_ALL) && + GetBattlerAbility(ctx, ctx->battlerIdAttacker) != ABILITY_VITAL_SPIRIT && + GetBattlerAbility(ctx, ctx->battlerIdAttacker) != ABILITY_INSOMNIA && + !(ctx->fieldCondition & (0xF << 8))) { + *script = 257; + return 1; + } + + rnd -= level; + + //hitting itself + if (rnd < level) { + ctx->battlerIdTarget = ctx->battlerIdAttacker; + ctx->battlerIdTemp = ctx->battlerIdTarget; + ctx->hpCalc = CalcMoveDamage(bsys, ctx, MOVE_POUND, 0, 0, 40, 0, ctx->battlerIdAttacker, ctx->battlerIdAttacker, 1); + ctx->hpCalc = ApplyDamageRange(bsys, ctx, ctx->hpCalc); + ctx->hpCalc *= -1; + *script = 258; + ctx->battleStatus |= 2; + return 3; + } + + *script = 255; + + return 1; +} diff --git a/src/player_data.c b/src/player_data.c index e462c4bcfc..1952b7e3ec 100644 --- a/src/player_data.c +++ b/src/player_data.c @@ -140,7 +140,7 @@ void PlayerProfile_SetBadgeFlag(PlayerProfile* profile, s32 badge_no) { } } -u32 PlayerProfile_CountBadges(PlayerProfile* profile) { +s32 PlayerProfile_CountBadges(PlayerProfile* profile) { u32 badges = 0; for (u32 i = profile->johtoBadges; i != 0; i >>= 1) { From ca84bad1f35c5198a1b2c987070b0576e15d5956 Mon Sep 17 00:00:00 2001 From: Adrienn Tindall <33725376+adrienntindall@users.noreply.github.com> Date: Fri, 22 Dec 2023 10:20:52 -0600 Subject: [PATCH 29/33] Update src/battle/battle_system.c Co-authored-by: PikalaxALT --- src/battle/battle_system.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/battle/battle_system.c b/src/battle/battle_system.c index 44c91d00a5..df10114847 100644 --- a/src/battle/battle_system.c +++ b/src/battle/battle_system.c @@ -1954,7 +1954,7 @@ static BOOL ov12_0223CF14(struct TextPrinterTemplate *template, u16 glyphId) { PlaySE(SEQ_SE_DP_KON); break; case 5: - PlayFanfare(0x4A0); + PlayFanfare(SEQ_ME_LVUP); break; default: break; From def7e95a8132baaf29380fa947f08358fb17a5f6 Mon Sep 17 00:00:00 2001 From: Adrienn Tindall <33725376+adrienntindall@users.noreply.github.com> Date: Fri, 22 Dec 2023 10:21:05 -0600 Subject: [PATCH 30/33] Update src/battle/battle_system.c Co-authored-by: PikalaxALT --- src/battle/battle_system.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/battle/battle_system.c b/src/battle/battle_system.c index df10114847..2592401615 100644 --- a/src/battle/battle_system.c +++ b/src/battle/battle_system.c @@ -1948,7 +1948,7 @@ static BOOL ov12_0223CF14(struct TextPrinterTemplate *template, u16 glyphId) { ret = IsFanfarePlaying(); break; case 3: - PlayFanfare(0x4A3); + PlayFanfare(SEQ_ME_POKEGET); break; case 4: PlaySE(SEQ_SE_DP_KON); From 61783f7bb66c622a911e1f996a17d84c9718c4a0 Mon Sep 17 00:00:00 2001 From: Adrienn Tindall <33725376+adrienntindall@users.noreply.github.com> Date: Fri, 22 Dec 2023 11:35:27 -0500 Subject: [PATCH 31/33] Minor documentation --- include/battle/battle.h | 2 +- include/constants/battle.h | 4 ++++ src/battle/battle_command.c | 10 +++++----- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/include/battle/battle.h b/include/battle/battle.h index 9eb27e975f..395eb5561b 100644 --- a/include/battle/battle.h +++ b/include/battle/battle.h @@ -334,7 +334,7 @@ typedef struct BattleContext { int totalDamage[4]; int meFirstTotal; GetterWork *getterWork; - void * unk_17C; + StatStruct *prevLevelStats; u32 fieldCondition; FieldConditionData fieldConditionData; u32 fieldSideConditionFlags[2]; diff --git a/include/constants/battle.h b/include/constants/battle.h index 35b5c4107e..90fc55a469 100644 --- a/include/constants/battle.h +++ b/include/constants/battle.h @@ -525,5 +525,9 @@ typedef enum ControllerCommand { CONTROLLER_COMMAND_45, CONTROLLER_COMMAND_MAX } ControllerCommand; + +//Critical Music Flags +#define CRITICAL_MUSIC_OFF 2 + #endif //PM_ASM #endif //POKEHEARTGOLD_CONSTANTS_BATTLE_H diff --git a/src/battle/battle_command.c b/src/battle/battle_command.c index 08b23f24e9..b54059b364 100644 --- a/src/battle/battle_command.c +++ b/src/battle/battle_command.c @@ -6023,7 +6023,7 @@ static void Task_GetExp(SysTask *task, void *inData) && !data->ctx->unk_3144) { PlayBGM(SEQ_GS_WIN2); data->ctx->unk_3144 = TRUE; - BattleSystem_SetCriticalHpMusicFlag(data->bsys, 2); // turn off + BattleSystem_SetCriticalHpMusicFlag(data->bsys, CRITICAL_MUSIC_OFF); } u32 totalExp = 0; @@ -6132,8 +6132,8 @@ static void Task_GetExp(SysTask *task, void *inData) TempStatsStruct stats = ov12_0226C354; int level = GetMonData(mon, MON_DATA_LEVEL, NULL); // Cache the stats from the previous level for later - data->ctx->unk_17C = AllocFromHeap(HEAP_ID_BATTLE, sizeof(StatStruct)); - StatStruct *oldStats = data->ctx->unk_17C; + data->ctx->prevLevelStats = AllocFromHeap(HEAP_ID_BATTLE, sizeof(StatStruct)); + StatStruct *oldStats = data->ctx->prevLevelStats; for (i = 0; i < 6; i++) { oldStats->stats[i] = GetMonData(mon, stats.stats[i], NULL); } @@ -6199,7 +6199,7 @@ static void Task_GetExp(SysTask *task, void *inData) TempStatsStruct monData = ov12_0226C384; Window *window = BattleSystem_GetWindow(data->bsys, 1); - StatStruct *oldStats = data->ctx->unk_17C; + StatStruct *oldStats = data->ctx->prevLevelStats; for (i = 0; i < NUM_STATS; i++) { msg.id = msg_0197_00947; // stat name @@ -6261,7 +6261,7 @@ static void Task_GetExp(SysTask *task, void *inData) ov12_022484D4(data->bsys, data); } - FreeToHeap(data->ctx->unk_17C); + FreeToHeap(data->ctx->prevLevelStats); data->state = STATE_GET_EXP_CHECK_LEARN_MOVE; break; From 196ce4bd8b005c59937132218186e418edecdc6a Mon Sep 17 00:00:00 2001 From: Adrienn Tindall <33725376+adrienntindall@users.noreply.github.com> Date: Sun, 24 Dec 2023 12:59:33 -0500 Subject: [PATCH 32/33] requested changes --- include/battle/battle.h | 2 +- include/constants/battle.h | 1 + src/battle/battle_command.c | 6 +++--- src/battle/battle_controller_player.c | 4 ++-- src/battle/battle_system.c | 14 +++++++------- 5 files changed, 14 insertions(+), 13 deletions(-) diff --git a/include/battle/battle.h b/include/battle/battle.h index 395eb5561b..bd740f6eca 100644 --- a/include/battle/battle.h +++ b/include/battle/battle.h @@ -28,7 +28,7 @@ typedef struct BattleMessage { u8 tag; u16 id; int param[6]; - int unk1C; + int numDigits; int battlerId; } BattleMessage; diff --git a/include/constants/battle.h b/include/constants/battle.h index 90fc55a469..4882ed254d 100644 --- a/include/constants/battle.h +++ b/include/constants/battle.h @@ -205,6 +205,7 @@ typedef enum Terrain { #define FIELD_CONDITION_HAIL (1 << 6) #define FIELD_CONDITION_HAIL_PERMANENT (1 << 7) #define FIELD_CONDITION_HAIL_ALL (FIELD_CONDITION_HAIL | FIELD_CONDITION_HAIL_PERMANENT) +#define FIELD_CONDITION_UPROAR (15 << 8) #define FIELD_CONDITION_GRAVITY (7 << 12) #define FIELD_CONDITION_FOG (1 << 15) #define FIELD_CONDITION_TRICK_ROOM (7 << 16) diff --git a/src/battle/battle_command.c b/src/battle/battle_command.c index b54059b364..c442978867 100644 --- a/src/battle/battle_command.c +++ b/src/battle/battle_command.c @@ -6134,7 +6134,7 @@ static void Task_GetExp(SysTask *task, void *inData) // Cache the stats from the previous level for later data->ctx->prevLevelStats = AllocFromHeap(HEAP_ID_BATTLE, sizeof(StatStruct)); StatStruct *oldStats = data->ctx->prevLevelStats; - for (i = 0; i < 6; i++) { + for (i = 0; i < NUM_STATS; i++) { oldStats->stats[i] = GetMonData(mon, stats.stats[i], NULL); } @@ -6211,7 +6211,7 @@ static void Task_GetExp(SysTask *task, void *inData) msg.id = msg_0197_00948; // "+{0}" msg.tag = TAG_NUMBERS; msg.param[0] = GetMonData(mon, monData.stats[i], NULL) - oldStats->stats[i]; - msg.unk1C = 2; + msg.numDigits = 2; ov12_0223C4E8(data->bsys, window, msgLoader, &msg, 80, 16 * i, 0, 0, 0); } @@ -6229,7 +6229,7 @@ static void Task_GetExp(SysTask *task, void *inData) msg.id = msg_0197_00949; // just a number msg.tag = TAG_NUMBERS; msg.param[0] = GetMonData(mon, monData.stats[i], NULL); - msg.unk1C = 3; + msg.numDigits = 3; ov12_0223C4E8(data->bsys, window, msgLoader, &msg, 72, 16 * i, 0x2, 36, 0); } diff --git a/src/battle/battle_controller_player.c b/src/battle/battle_controller_player.c index 27c1285763..741edf9092 100644 --- a/src/battle/battle_controller_player.c +++ b/src/battle/battle_controller_player.c @@ -1866,7 +1866,7 @@ u32 TryDisobedience(BattleSystem *bsys, BattleContext *ctx, int *script) { *script = 256; ctx->unk_2184 |= 1; - return 2; // ??? + return 2; } level = ctx->battleMons[ctx->battlerIdAttacker].level - level; @@ -1876,7 +1876,7 @@ u32 TryDisobedience(BattleSystem *bsys, BattleContext *ctx, int *script) { if (rnd < level && !(ctx->battleMons[ctx->battlerIdAttacker].status & STATUS_ALL) && GetBattlerAbility(ctx, ctx->battlerIdAttacker) != ABILITY_VITAL_SPIRIT && GetBattlerAbility(ctx, ctx->battlerIdAttacker) != ABILITY_INSOMNIA && - !(ctx->fieldCondition & (0xF << 8))) { + !(ctx->fieldCondition & FIELD_CONDITION_UPROAR)) { *script = 257; return 1; } diff --git a/src/battle/battle_system.c b/src/battle/battle_system.c index 2592401615..0157fef824 100644 --- a/src/battle/battle_system.c +++ b/src/battle/battle_system.c @@ -27,7 +27,7 @@ static void BattleMessage_BufferNickname(BattleSystem *bsys, int bufferIndex, in static void BattleMessage_BufferMove(BattleSystem *bsys, int bufferIndex, int param); static void BattleMessage_BufferItem(BattleSystem *bsys, int bufferIndex, int param); static void BattleMessage_BufferNumber(BattleSystem *bsys, int bufferIndex, int param); -static void BattleMessage_BufferNumbers(BattleSystem *bsys, int bufferIndex, int param, int a3); +static void BattleMessage_BufferNumbers(BattleSystem *bsys, int bufferIndex, int param, int numDigits); static void BattleMessage_BufferType(BattleSystem *bsys, int bufferIndex, int param); static void BattleMessage_BufferAbility(BattleSystem *bsys, int bufferIndex, int param); static void BattleMessage_BufferStat(BattleSystem *bsys, int bufferIndex, int param); @@ -1581,7 +1581,7 @@ static void BattleSystem_AdjustMessageForSide(BattleSystem *bsys, BattleMessage } break; default: - GF_ASSERT(0); + GF_ASSERT(FALSE); } } @@ -1607,7 +1607,7 @@ static void BattleSystem_BufferMessage(BattleSystem *bsys, BattleMessage *msg) { BattleMessage_BufferNumber(bsys, 0, msg->param[0]); break; case TAG_NUMBERS: - BattleMessage_BufferNumbers(bsys, 0, msg->param[0], msg->unk1C); + BattleMessage_BufferNumbers(bsys, 0, msg->param[0], msg->numDigits); break; case TAG_TRNAME: BattleMessage_BufferTrainerName(bsys, 0, msg->param[0]); @@ -1858,7 +1858,7 @@ static void BattleSystem_BufferMessage(BattleSystem *bsys, BattleMessage *msg) { BattleMessage_BufferNickname(bsys, 5, msg->param[5]); break; default: - GF_ASSERT(0); + GF_ASSERT(FALSE); } } @@ -1879,9 +1879,9 @@ static void BattleMessage_BufferNumber(BattleSystem *bsys, int bufferIndex, int BufferIntegerAsString(bsys->msgFormat, bufferIndex, param, 5, PRINTING_MODE_LEFT_ALIGN, TRUE); } -static void BattleMessage_BufferNumbers(BattleSystem *bsys, int bufferIndex, int param, int a3) { - if (a3) { - BufferIntegerAsString(bsys->msgFormat, bufferIndex, param, a3, PRINTING_MODE_RIGHT_ALIGN, TRUE); +static void BattleMessage_BufferNumbers(BattleSystem *bsys, int bufferIndex, int param, int numDigits) { + if (numDigits) { + BufferIntegerAsString(bsys->msgFormat, bufferIndex, param, numDigits, PRINTING_MODE_RIGHT_ALIGN, TRUE); } else { BufferIntegerAsString(bsys->msgFormat, bufferIndex, param, 5, PRINTING_MODE_RIGHT_ALIGN, TRUE); } From f77b177d00329e0ad122f9e1d75dcda7df16af6e Mon Sep 17 00:00:00 2001 From: Adrienn Tindall <33725376+adrienntindall@users.noreply.github.com> Date: Sun, 24 Dec 2023 14:46:51 -0500 Subject: [PATCH 33/33] StatStruct -> PokemonStats --- include/battle/battle.h | 6 +++--- src/battle/battle_command.c | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/include/battle/battle.h b/include/battle/battle.h index bd740f6eca..2e7faf2b7a 100644 --- a/include/battle/battle.h +++ b/include/battle/battle.h @@ -261,9 +261,9 @@ typedef struct BattleMon { UnkBattlemonSub unk88; } BattleMon; -typedef struct StatStruct { +typedef struct PokemonStats { u32 stats[6]; -} StatStruct; +} PokemonStats; typedef struct BattleContext { u8 unk_0[4]; @@ -334,7 +334,7 @@ typedef struct BattleContext { int totalDamage[4]; int meFirstTotal; GetterWork *getterWork; - StatStruct *prevLevelStats; + PokemonStats *prevLevelStats; u32 fieldCondition; FieldConditionData fieldConditionData; u32 fieldSideConditionFlags[2]; diff --git a/src/battle/battle_command.c b/src/battle/battle_command.c index c442978867..642790a77b 100644 --- a/src/battle/battle_command.c +++ b/src/battle/battle_command.c @@ -6132,8 +6132,8 @@ static void Task_GetExp(SysTask *task, void *inData) TempStatsStruct stats = ov12_0226C354; int level = GetMonData(mon, MON_DATA_LEVEL, NULL); // Cache the stats from the previous level for later - data->ctx->prevLevelStats = AllocFromHeap(HEAP_ID_BATTLE, sizeof(StatStruct)); - StatStruct *oldStats = data->ctx->prevLevelStats; + data->ctx->prevLevelStats = AllocFromHeap(HEAP_ID_BATTLE, sizeof(PokemonStats)); + PokemonStats *oldStats = data->ctx->prevLevelStats; for (i = 0; i < NUM_STATS; i++) { oldStats->stats[i] = GetMonData(mon, stats.stats[i], NULL); } @@ -6199,7 +6199,7 @@ static void Task_GetExp(SysTask *task, void *inData) TempStatsStruct monData = ov12_0226C384; Window *window = BattleSystem_GetWindow(data->bsys, 1); - StatStruct *oldStats = data->ctx->prevLevelStats; + PokemonStats *oldStats = data->ctx->prevLevelStats; for (i = 0; i < NUM_STATS; i++) { msg.id = msg_0197_00947; // stat name