Add Controller Command placeholder documentation

This commit is contained in:
Adrienn Tindall 2023-06-25 04:57:00 -05:00
parent 5ff50bcdf2
commit 24345baf7a
9 changed files with 90 additions and 55 deletions

View File

@ -6,46 +6,6 @@
.text
thumb_func_start BattleMain
BattleMain: ; 0x022486B0
push {r3, r4, r5, lr}
add r4, r1, #0
ldr r1, _022486F4 ; =0x0000311F
add r5, r0, #0
ldrb r1, [r4, r1]
cmp r1, #0
bne _022486D6
bl BattleSystem_GetWinLoseFlags
cmp r0, #0
beq _022486D6
add r0, r5, #0
bl BattleSystem_GetWinLoseFlags
mov r1, #0x40
tst r0, r1
bne _022486D6
mov r0, #0x2a
str r0, [r4, #8]
_022486D6:
ldr r2, [r4, #8]
add r0, r5, #0
lsl r3, r2, #2
ldr r2, _022486F8 ; =sPlayerBattleCommands
add r1, r4, #0
ldr r2, [r2, r3]
blx r2
ldr r0, [r4, #8]
cmp r0, #0x2d
bne _022486EE
mov r0, #1
pop {r3, r4, r5, pc}
_022486EE:
mov r0, #0
pop {r3, r4, r5, pc}
nop
_022486F4: .word 0x0000311F
_022486F8: .word sPlayerBattleCommands
thumb_func_end BattleMain
thumb_func_start BattleContext_Delete
BattleContext_Delete: ; 0x022486FC
push {r4, lr}
@ -12295,6 +12255,7 @@ ov12_0226CA75: ; 0x0226CA75
.byte 0x64, 0x24, 0x64, 0x2B, 0x64, 0x32, 0x64, 0x3C, 0x64, 0x4B, 0x64
.byte 0x01, 0x01, 0x85, 0x64, 0xA6, 0x64, 0x02, 0x01, 0xE9, 0x64, 0x85, 0x32, 0x03, 0x01, 0x00, 0x00
.public sPlayerBattleCommands
sPlayerBattleCommands: ; 0x0226CA90
.word BattleControllerPlayer_GetBattleMon
.word ov12_02248780

View File

@ -6,6 +6,7 @@
#include "pokemon_storage_system.h"
#include "trainer_data.h"
#include "filesystem.h"
#include "constants/battle.h"
typedef struct BATTLEMSG {
u8 unk0;
@ -248,8 +249,8 @@ typedef struct BATTLEMON {
typedef struct BATTLECONTEXT {
u8 unk_0[4];
u8 unk_4[4];
int unk_8;
int unk_C;
ControllerCommand command;
ControllerCommand commandNext;
int unk_10;
int unk_14;
int unk_18;
@ -390,7 +391,7 @@ typedef struct BATTLECONTEXT {
u8 unk_311C;
u8 unk_311D;
u8 runAttempts;
u8 unk_311F;
u8 battleEndFlag;
u8 magnitude;
u8 unk_3121;
s16 hpTemp;

View File

@ -3,6 +3,8 @@
#include "battle.h"
typedef void (*ControllerFunction)(BattleSystem *, BATTLECONTEXT *ctx);
void BattleController_EmitPlayEncounterAnimation(BattleSystem *bsys, BOOL a1);
void BattleController_EmitPokemonEncounter(BattleSystem *bsys, int battlerId);
void BattleController_EmitPokemonSlideIn(BattleSystem *bsys, int battlerId);

View File

@ -4,6 +4,7 @@
#include "battle.h"
BATTLECONTEXT *BattleContext_New(BattleSystem *bsys);
BOOL BattleMain(BattleSystem *bsys, BATTLECONTEXT *ctx);
//The following functions haven't been decompiled yet
void BattleSystem_CheckMoveHitEffect(BattleSystem *bsys, BATTLECONTEXT *ctx, int battlerIdA, int battlerIdB, int moveMsgNo);

View File

@ -32,5 +32,6 @@ void ov12_0223BFFC(BattleSystem *bsys, u32 a1);
void *ov12_0223A938(BattleSystem *bsys);
int ov12_0223AB54(BattleSystem *bsys);
u8 BattleSystem_GetMonBall(BattleSystem *bsys, Pokemon *mon);
u32 BattleSystem_GetWinLoseFlags(BattleSystem *bsys);
#endif

View File

@ -318,4 +318,55 @@ enum Terrain {
#define BMON_DATA_99 99 //unused
#define BMON_DATA_100 100
//Battle Controller Commands
typedef enum ControllerCommand {
CONTROLLER_COMMAND_0,
CONTROLLER_COMMAND_1,
CONTROLLER_COMMAND_2,
CONTROLLER_COMMAND_3,
CONTROLLER_COMMAND_4,
CONTROLLER_COMMAND_5,
CONTROLLER_COMMAND_6,
CONTROLLER_COMMAND_7,
CONTROLLER_COMMAND_8,
CONTROLLER_COMMAND_9,
CONTROLLER_COMMAND_10,
CONTROLLER_COMMAND_11,
CONTROLLER_COMMAND_12,
CONTROLLER_COMMAND_13,
CONTROLLER_COMMAND_14,
CONTROLLER_COMMAND_15,
CONTROLLER_COMMAND_16,
CONTROLLER_COMMAND_17,
CONTROLLER_COMMAND_18,
CONTROLLER_COMMAND_19,
CONTROLLER_COMMAND_20,
CONTROLLER_COMMAND_21,
CONTROLLER_COMMAND_22,
CONTROLLER_COMMAND_23,
CONTROLLER_COMMAND_24,
CONTROLLER_COMMAND_25,
CONTROLLER_COMMAND_26,
CONTROLLER_COMMAND_27,
CONTROLLER_COMMAND_28,
CONTROLLER_COMMAND_29,
CONTROLLER_COMMAND_30,
CONTROLLER_COMMAND_31,
CONTROLLER_COMMAND_32,
CONTROLLER_COMMAND_33,
CONTROLLER_COMMAND_34,
CONTROLLER_COMMAND_35,
CONTROLLER_COMMAND_36,
CONTROLLER_COMMAND_37,
CONTROLLER_COMMAND_38,
CONTROLLER_COMMAND_39,
CONTROLLER_COMMAND_40,
CONTROLLER_COMMAND_41,
CONTROLLER_COMMAND_42,
CONTROLLER_COMMAND_43,
CONTROLLER_COMMAND_44,
CONTROLLER_COMMAND_45,
CONTROLLER_COMMAND_MAX
} ControllerCommand;
#endif

View File

@ -1156,7 +1156,7 @@ BOOL BtlCmd_JumpToEffectScript(BattleSystem *bsys, BATTLECONTEXT *ctx) {
}
if (ctx->battlerIdTarget == 255) {
ctx->unk_C = 39;
ctx->commandNext = CONTROLLER_COMMAND_39;
BattleScriptJump(ctx, NARC_a_0_0_1, 281);
} else {
BattleScriptJump(ctx, NARC_a_0_0_0, ctx->moveNoCur);
@ -2025,7 +2025,7 @@ BOOL BtlCmd_SetMoveToMirrorMove(BattleSystem *bsys, BATTLECONTEXT *ctx) {
ctx->moveNoCur = move;
ctx->battlerIdTarget = ov12_022506D4(bsys, ctx, ctx->battlerIdAttacker, move, 1, 0);
if (ctx->battlerIdTarget == 255) {
ctx->unk_C = 39;
ctx->commandNext = CONTROLLER_COMMAND_39;
BattleScriptJump(ctx, NARC_a_0_0_1, 281);
} else {
ctx->unk_21A8[ctx->battlerIdAttacker][1] = ctx->battlerIdTarget;
@ -2745,7 +2745,7 @@ BOOL BtlCmd_Counter(BattleSystem *bsys, BATTLECONTEXT *ctx) {
if (ctx->battleMons[ctx->battlerIdTarget].hp == 0) {
ctx->battlerIdTarget = ov12_02253DA0(bsys, ctx, ctx->battlerIdAttacker);
if (ctx->battleMons[ctx->battlerIdTarget].hp == 0) {
ctx->unk_C = 39;
ctx->commandNext = CONTROLLER_COMMAND_39;
BattleScriptJump(ctx, NARC_a_0_0_1, 281);
}
}
@ -2776,7 +2776,7 @@ BOOL BtlCmd_MirrorCoat(BattleSystem *bsys, BATTLECONTEXT *ctx) {
if (ctx->battleMons[ctx->battlerIdTarget].hp == 0) {
ctx->battlerIdTarget = ov12_02253DA0(bsys, ctx, ctx->battlerIdAttacker);
if (ctx->battleMons[ctx->battlerIdTarget].hp == 0) {
ctx->unk_C = 39;
ctx->commandNext = CONTROLLER_COMMAND_39;
BattleScriptJump(ctx, NARC_a_0_0_1, 281);
}
}
@ -4499,7 +4499,7 @@ BOOL BtlCmd_MetalBurstDamageCalc(BattleSystem *bsys, BATTLECONTEXT *ctx) {
if (ctx->battleMons[ctx->battlerIdTarget].hp == 0) {
ctx->battlerIdTarget = ov12_02253DA0(bsys, ctx, ctx->battlerIdAttacker);
if (ctx->battleMons[ctx->battlerIdTarget].hp == 0) {
ctx->unk_C = 39;
ctx->commandNext = CONTROLLER_COMMAND_39;
BattleScriptJump(ctx, NARC_a_0_0_1, 281);
}
}

View File

@ -1,7 +1,11 @@
#include "battle_controller_player.h"
#include "battle_controller.h"
#include "battle_system.h"
#include "overlay_12_0224E4FC.h"
#include "heap.h"
extern ControllerFunction sPlayerBattleCommands[];
BATTLECONTEXT *BattleContext_New(BattleSystem *bsys) {
BATTLECONTEXT *ctx = (BATTLECONTEXT *) AllocFromHeap(HEAP_ID_BATTLE, sizeof(BATTLECONTEXT));
MIi_CpuClearFast(0, (u32 *)ctx, sizeof(BATTLECONTEXT));
@ -13,4 +17,18 @@ BATTLECONTEXT *BattleContext_New(BattleSystem *bsys) {
ctx->unk_334.itemData = LoadAllItemData(HEAP_ID_BATTLE);
return ctx;
}
}
BOOL BattleMain(BattleSystem *bsys, BATTLECONTEXT *ctx) {
if (!ctx->battleEndFlag) {
if (BattleSystem_GetWinLoseFlags(bsys) && !(BattleSystem_GetWinLoseFlags(bsys) & 0x40)) {
ctx->command = CONTROLLER_COMMAND_42;
}
}
sPlayerBattleCommands[ctx->command](bsys, ctx);
if (ctx->command == CONTROLLER_COMMAND_45) {
return TRUE;
}
return FALSE;
}

View File

@ -1543,16 +1543,16 @@ BOOL ov12_02250BBC(BattleSystem *bsys, BATTLECONTEXT *ctx) {
if (!(ctx->moveStatusFlag & 0x801FDA49) && ctx->selfTurnData[ctx->battlerIdTarget].lightningRodFlag) {
ctx->selfTurnData[ctx->battlerIdTarget].lightningRodFlag = FALSE;
ReadBattleScriptFromNarc(ctx, NARC_a_0_0_1, 180);
ctx->unk_C = ctx->unk_8;
ctx->unk_8 = 22;
ctx->commandNext = ctx->command;
ctx->command = CONTROLLER_COMMAND_22;
ret = TRUE;
}
if (!(ctx->moveStatusFlag & 0x801FDA49) && ctx->selfTurnData[ctx->battlerIdTarget].stormDrainFlag) {
ctx->selfTurnData[ctx->battlerIdTarget].stormDrainFlag = FALSE;
ReadBattleScriptFromNarc(ctx, NARC_a_0_0_1, 180);
ctx->unk_C = ctx->unk_8;
ctx->unk_8 = 22;
ctx->commandNext = ctx->command;
ctx->command = CONTROLLER_COMMAND_22;
ret = TRUE;
}
@ -3410,8 +3410,8 @@ BOOL ov12_02253068(BattleSystem *bsys, BATTLECONTEXT *ctx, int battlerId) {
if (ret == TRUE) {
ReadBattleScriptFromNarc(ctx, NARC_a_0_0_1, state);
ctx->unk_C = ctx->unk_8;
ctx->unk_8 = 22;
ctx->commandNext = ctx->command;
ctx->command = CONTROLLER_COMMAND_22;
}
return ret;