Skip to content

Commit

Permalink
Starting progress on Battle Controller Player again
Browse files Browse the repository at this point in the history
  • Loading branch information
adrienntindall committed Jul 14, 2023
1 parent 6de58fb commit 32b5d04
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 45 deletions.
43 changes: 2 additions & 41 deletions asm/overlay_12_battle_controller_player.s
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
2 changes: 1 addition & 1 deletion include/battle.h
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ typedef struct BattleMon {
u8 metGender:4;
u8 ball;
u32 moveEffectFlags;
u32 unk80;
u32 moveEffectFlagsTemp;
UnkBattlemonSub unk88;
} BattleMon;

Expand Down
1 change: 1 addition & 0 deletions include/battle_controller_player.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions include/battle_system.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion include/constants/battle.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
17 changes: 17 additions & 0 deletions src/battle/battle_controller_player.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
4 changes: 2 additions & 2 deletions src/battle/overlay_12_0224E4FC.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 32b5d04

Please sign in to comment.