From 32b5d04c4dc9cfe3c437986bc69460acd7f6c454 Mon Sep 17 00:00:00 2001 From: Adrienn Tindall <33725376+adrienntindall@users.noreply.github.com> Date: Fri, 14 Jul 2023 19:12:28 -0400 Subject: [PATCH] Starting progress on Battle Controller Player again --- asm/overlay_12_battle_controller_player.s | 43 ++--------------------- include/battle.h | 2 +- include/battle_controller_player.h | 1 + include/battle_system.h | 2 ++ include/constants/battle.h | 2 +- src/battle/battle_controller_player.c | 17 +++++++++ src/battle/overlay_12_0224E4FC.c | 4 +-- 7 files changed, 26 insertions(+), 45 deletions(-) diff --git a/asm/overlay_12_battle_controller_player.s b/asm/overlay_12_battle_controller_player.s index 58278fb72e..600283982e 100644 --- a/asm/overlay_12_battle_controller_player.s +++ b/asm/overlay_12_battle_controller_player.s @@ -9,47 +9,8 @@ .public BattleControllerPlayer_StartEncounter .public BattleControllerPlayer_TrainerMessage .public BattleControllerPlayer_PokemonAppear - - thumb_func_start BattleControllerPlayer_SelectionScreenInit -BattleControllerPlayer_SelectionScreenInit: ; 0x022487FC - push {r3, r4, r5, r6, r7, lr} - str r0, [sp] - add r7, r1, #0 - bl BattleSystem_GetMaxBattlers - add r5, r0, #0 - mov r4, #0 - cmp r5, #0 - ble _0224882C - add r6, r7, #0 - add r2, r4, #0 -_02248812: - mov r0, #0xb7 - strb r2, [r7, r4] - lsl r0, r0, #6 - ldr r1, [r6, r0] - add r0, r0, #4 - str r1, [r6, r0] - add r3, r7, r4 - ldr r0, _02248844 ; =0x0000314C - add r4, r4, #1 - strb r2, [r3, r0] - add r6, #0xc0 - cmp r4, r5 - blt _02248812 -_0224882C: - ldr r0, [sp] - mov r1, #0 - bl ov12_0223BB64 - ldr r0, [sp] - mov r1, #1 - bl ov12_02237ED0 - mov r0, #5 - str r0, [r7, #8] - pop {r3, r4, r5, r6, r7, pc} - nop -_02248844: .word 0x0000314C - thumb_func_end BattleControllerPlayer_SelectionScreenInit - + .public BattleControllerPlayer_SelectionScreenInit + thumb_func_start ov12_02248848 ov12_02248848: ; 0x02248848 push {r3, r4, r5, r6, r7, lr} diff --git a/include/battle.h b/include/battle.h index d07ba9f866..5ffd056cef 100644 --- a/include/battle.h +++ b/include/battle.h @@ -243,7 +243,7 @@ typedef struct BattleMon { u8 metGender:4; u8 ball; u32 moveEffectFlags; - u32 unk80; + u32 moveEffectFlagsTemp; UnkBattlemonSub unk88; } BattleMon; diff --git a/include/battle_controller_player.h b/include/battle_controller_player.h index 4cca8ff3cc..95fd73d694 100644 --- a/include/battle_controller_player.h +++ b/include/battle_controller_player.h @@ -13,6 +13,7 @@ void BattleControllerPlayer_GetBattleMon(BattleSystem *bsys, BATTLECONTEXT *ctx) void BattleControllerPlayer_StartEncounter(BattleSystem *bsys, BATTLECONTEXT *ctx); void BattleControllerPlayer_TrainerMessage(BattleSystem *bsys, BATTLECONTEXT *ctx); void BattleControllerPlayer_PokemonAppear(BattleSystem *bsys, BATTLECONTEXT *ctx); +void BattleControllerPlayer_SelectionScreenInit(BattleSystem *bsys, BATTLECONTEXT *ctx); //The following functions haven't been decompiled yet void ov12_0224E384(BattleSystem *bsys, BATTLECONTEXT *ctx); diff --git a/include/battle_system.h b/include/battle_system.h index c1a69dc323..da1798f77f 100644 --- a/include/battle_system.h +++ b/include/battle_system.h @@ -37,5 +37,7 @@ void ov12_0223C0C4(BattleSystem *bsys); int BattleSystem_GetWeather(BattleSystem *bsys); int ov12_0223AB60(BattleSystem *bsys); BOOL ov12_0223BFEC(BattleSystem *bsys); +void ov12_0223BB64(BattleSystem *bsys, int a1); +void ov12_02237ED0(BattleSystem *bsys, int a1); #endif diff --git a/include/constants/battle.h b/include/constants/battle.h index 80791d0bfb..c8ad665e2f 100644 --- a/include/constants/battle.h +++ b/include/constants/battle.h @@ -388,7 +388,7 @@ typedef enum ControllerCommand { CONTROLLER_COMMAND_TRAINER_MESSAGE, CONTROLLER_COMMAND_SEND_OUT, CONTROLLER_COMMAND_SELECTION_SCREEN_INIT, - CONTROLLER_COMMAND_5, + CONTROLLER_COMMAND_SELECTION_SCREEN_INPUT, CONTROLLER_COMMAND_6, CONTROLLER_COMMAND_7, CONTROLLER_COMMAND_8, diff --git a/src/battle/battle_controller_player.c b/src/battle/battle_controller_player.c index c246dbfe45..12729583fd 100644 --- a/src/battle/battle_controller_player.c +++ b/src/battle/battle_controller_player.c @@ -91,3 +91,20 @@ void BattleControllerPlayer_PokemonAppear(BattleSystem *bsys, BATTLECONTEXT *ctx ctx->command = CONTROLLER_COMMAND_SELECTION_SCREEN_INIT; } } + +//static +void BattleControllerPlayer_SelectionScreenInit(BattleSystem *bsys, BATTLECONTEXT *ctx) { + int battlerId; + int maxBattlers = BattleSystem_GetMaxBattlers(bsys); + + for (battlerId = 0; battlerId < maxBattlers; battlerId++) { + ctx->unk_0[battlerId] = 0; + ctx->battleMons[battlerId].moveEffectFlagsTemp = ctx->battleMons[battlerId].moveEffectFlags; + ctx->unk_314C[battlerId] = 0; + } + + ov12_0223BB64(bsys, 0); + ov12_02237ED0(bsys, 1); + + ctx->command = CONTROLLER_COMMAND_SELECTION_SCREEN_INPUT; +} diff --git a/src/battle/overlay_12_0224E4FC.c b/src/battle/overlay_12_0224E4FC.c index 5e1067cbac..7fcfdf24bc 100644 --- a/src/battle/overlay_12_0224E4FC.c +++ b/src/battle/overlay_12_0224E4FC.c @@ -402,7 +402,7 @@ int GetBattlerVar(BATTLECONTEXT *ctx, int battlerId, u32 id, void *data) { case BMON_DATA_MOVE_EFFECT: return mon->moveEffectFlags; case BMON_DATA_MOVE_EFFECT_TEMP: - return mon->unk80; + return mon->moveEffectFlagsTemp; case BMON_DATA_DISABLED_TURNS: return mon->unk88.disabledTurns; case BMON_DATA_ENCORED_TURNS: @@ -656,7 +656,7 @@ void SetBattlerVar(BATTLECONTEXT *ctx, int battlerId, u32 id, void *data) { mon->moveEffectFlags = *data32; break; case BMON_DATA_MOVE_EFFECT_TEMP: - mon->unk80 = *data32; + mon->moveEffectFlagsTemp = *data32; break; case BMON_DATA_DISABLED_TURNS: mon->unk88.disabledTurns = *data8;