documentation work

This commit is contained in:
Adrienn Tindall 2023-07-27 23:08:36 -04:00
parent cf4179b159
commit f9e1e8d9c0
22 changed files with 202 additions and 211 deletions

View File

@ -164,7 +164,7 @@
.public _u32_div_f
.public gSystem
.public ov08_022225D4
.public ov12_0223A7D4
.public BattleSystem_GetBgConfig
.public BattleSystem_GetBattleType
.public ov12_0223A7E4
.public BattleSystem_GetParty

View File

@ -47,7 +47,7 @@
.public _ll_mul
.public _s32_div_f
.public _u32_div_f
.public ov12_0223A7D4
.public BattleSystem_GetBgConfig
.public BattleSystem_GetBattleType
.public BattleSystem_GetPartyMon
.public ov12_0223A8E4

View File

@ -129,7 +129,7 @@
.public _s32_div_f
.public gSystem
.public ov06_0221BA1C
.public ov12_0223A7D4
.public BattleSystem_GetBgConfig
.public BattleSystem_GetBattleType
.public BattleSystem_GetOpponentDataByBattlerId
.public BattleSystem_GetPartyMon

View File

@ -114,8 +114,8 @@
.public ov12_02237B6C
.public ov12_02237CC4
.public ov12_02237D00
.public ov12_0223A7D4
.public ov12_0223A7D8
.public BattleSystem_GetBgConfig
.public BattleSystem_GetWindow
.public BattleSystem_GetBattleType
.public BattleSystem_GetOpponentDataByBattlerId
.public BattleSystem_GetMaxBattlers

View File

@ -146,8 +146,8 @@
.public ov12_02237B0C
.public ov12_02237BB8
.public ov12_02237ED0
.public ov12_0223A7D4
.public ov12_0223A7D8
.public BattleSystem_GetBgConfig
.public BattleSystem_GetWindow
.public BattleSystem_GetBattleType
.public ov12_0223A7E4
.public BattleSystem_GetOpponentDataByBattlerId

View File

@ -65,8 +65,8 @@
.public MIi_CpuCopy32
.public _s32_div_f
.public _u32_div_f
.public ov12_0223A7D4
.public ov12_0223A7D8
.public BattleSystem_GetBgConfig
.public BattleSystem_GetWindow
.public BattleSystem_GetBattleType
.public ov12_0223A7E4
.public BattleSystem_GetOpponentDataByBattlerId

View File

@ -27,7 +27,7 @@ _0221BE2E:
bl memset
str r5, [r4]
ldr r0, [r5, #8]
bl ov12_0223A7D4
bl BattleSystem_GetBgConfig
mov r1, #0x79
lsl r1, r1, #2
str r0, [r4, r1]
@ -12728,7 +12728,7 @@ ov08_022225D4: ; 0x022225D4
bl memset
str r5, [r4]
ldr r0, [r5]
bl ov12_0223A7D4
bl BattleSystem_GetBgConfig
str r0, [r4, #4]
ldr r0, [r5]
bl ov12_0223A938

View File

@ -1238,7 +1238,7 @@ ov12_0226516C: ; 0x0226516C
sub sp, #0x34
add r5, r0, #0
ldr r0, [r5, #0xc]
bl ov12_0223A7D4
bl BattleSystem_GetBgConfig
add r6, r0, #0
ldr r0, [r5, #0xc]
bl ov12_0223A930
@ -1770,7 +1770,7 @@ ov12_022655F0: ; 0x022655F0
add r4, r0, #0
ldr r0, [r4, #0xc]
add r5, r1, #0
bl ov12_0223A7D4
bl BattleSystem_GetBgConfig
add r6, r0, #0
ldr r0, [r4, #0xc]
bl ov12_0223A930
@ -1872,7 +1872,7 @@ ov12_022656CC: ; 0x022656CC
add r4, r0, #0
ldr r0, [r4, #0xc]
add r5, r1, #0
bl ov12_0223A7D4
bl BattleSystem_GetBgConfig
str r0, [sp, #0x1c]
ldr r0, [r4, #0xc]
bl ov12_0223A930

View File

@ -341,7 +341,7 @@ ov12_02266390: ; 0x02266390
bl ov12_0223A8EC
add r4, r0, #0
ldr r0, [r7]
bl ov12_0223A7D4
bl BattleSystem_GetBgConfig
add r5, r0, #0
ldr r0, [r7]
bl ov12_0223A938
@ -520,7 +520,7 @@ _02266526:
mov r1, #0
strb r1, [r7, r0]
ldr r0, [r7]
bl ov12_0223A7D4
bl BattleSystem_GetBgConfig
str r0, [sp, #0x28]
ldr r0, [r7]
bl ov12_0223A8E4
@ -1630,7 +1630,7 @@ ov12_02266DC4: ; 0x02266DC4
str r0, [sp]
ldr r0, [r5]
mov r4, #0
bl ov12_0223A7D4
bl BattleSystem_GetBgConfig
add r7, r0, #0
ldr r0, _02266E58 ; =0x000006CC
add r1, r0, #4
@ -2303,7 +2303,7 @@ ov12_0226739C: ; 0x0226739C
add r5, r0, #0
bl ov12_02266F84
ldr r0, [r5]
bl ov12_0223A7D4
bl BattleSystem_GetBgConfig
mov r1, #0x10
str r1, [sp]
mov r1, #0x20
@ -2360,7 +2360,7 @@ ov12_02267418: ; 0x02267418
add r5, r0, #0
bl ov12_02266F84
ldr r0, [r5]
bl ov12_0223A7D4
bl BattleSystem_GetBgConfig
mov r1, #0x10
str r1, [sp]
mov r1, #0xa
@ -2649,7 +2649,7 @@ _0226767A:
blt _02267654
_0226767E:
ldr r0, [r5]
bl ov12_0223A7D4
bl BattleSystem_GetBgConfig
ldrh r0, [r6]
cmp r0, #0
bne _022676AA
@ -3013,7 +3013,7 @@ ov12_02267984: ; 0x02267984
add r0, r6, #0
bl FreeToHeap
ldr r0, [r5]
bl ov12_0223A7D4
bl BattleSystem_GetBgConfig
mov r1, #4
ldr r2, [r5, #0x58]
add r6, r0, #0
@ -3023,7 +3023,7 @@ ov12_02267984: ; 0x02267984
mov r1, #4
bl ScheduleBgTilemapBufferTransfer
ldr r0, [r5]
bl ov12_0223A7D4
bl BattleSystem_GetBgConfig
mov r2, #2
add r6, r0, #0
ldr r1, [r5, #0x50]
@ -3884,7 +3884,7 @@ _0226809E:
pop {r3, r4, r5, r6, pc}
_022680E4:
ldr r0, [r4]
bl ov12_0223A7D4
bl BattleSystem_GetBgConfig
ldr r2, _02268124 ; =0x000002FF
add r6, r0, #0
mov r1, #5
@ -4455,7 +4455,7 @@ _0226856A:
bl ov12_0223A8EC
str r0, [sp, #0x20]
ldr r0, [r7]
bl ov12_0223A7D4
bl BattleSystem_GetBgConfig
str r0, [sp, #0x24]
cmp r4, #0
bne _0226858C
@ -4622,7 +4622,7 @@ ov12_022686BC: ; 0x022686BC
sub sp, #8
add r7, r0, #0
ldr r0, [r7]
bl ov12_0223A7D4
bl BattleSystem_GetBgConfig
mov r1, #5
bl GetBgTilemapBuffer
add r4, r0, #0
@ -5117,7 +5117,7 @@ _02268A90:
add r0, r4, #0
bl InitWindow
ldr r0, [r5]
bl ov12_0223A7D4
bl BattleSystem_GetBgConfig
mov r1, #0
str r1, [sp]
str r1, [sp, #4]
@ -5394,7 +5394,7 @@ ov12_02268CA0: ; 0x02268CA0
strb r2, [r0, #2]
strb r1, [r0, #3]
ldr r0, [r5]
bl ov12_0223A7D4
bl BattleSystem_GetBgConfig
add r6, r0, #0
ldr r0, [r5]
bl ov12_0223A938
@ -5699,7 +5699,7 @@ ov12_02268EE4: ; 0x02268EE4
add r6, r1, #0
add r4, r2, #0
add r7, r3, #0
bl ov12_0223A7D4
bl BattleSystem_GetBgConfig
mov r1, #4
str r0, [sp, #4]
bl GetBgTilemapBuffer
@ -5759,7 +5759,7 @@ ov12_02268F58: ; 0x02268F58
sub sp, #0xc
add r4, r1, #0
ldr r0, [r4]
bl ov12_0223A7D4
bl BattleSystem_GetBgConfig
ldr r3, _0226909C ; =0x0000069C
ldrsh r0, [r4, r3]
cmp r0, #0
@ -5925,7 +5925,7 @@ ov12_022690A8: ; 0x022690A8
sub sp, #0x24
add r4, r1, #0
ldr r0, [r4]
bl ov12_0223A7D4
bl BattleSystem_GetBgConfig
ldr r0, _02269350 ; =0x000006A8
add r1, r4, #0
ldr r0, [r4, r0]
@ -6267,7 +6267,7 @@ ov12_02269360: ; 0x02269360
sub sp, #0x10
add r4, r1, #0
ldr r0, [r4]
bl ov12_0223A7D4
bl BattleSystem_GetBgConfig
ldr r1, _022694F0 ; =0x0000069C
ldrsh r0, [r4, r1]
cmp r0, #3
@ -6540,7 +6540,7 @@ ov12_02269568: ; 0x02269568
add r6, r0, #0
ldr r0, [r5]
ldr r0, [r0]
bl ov12_0223A7D4
bl BattleSystem_GetBgConfig
add r4, r0, #0
ldrb r0, [r5, #0x13]
cmp r0, #0
@ -6659,7 +6659,7 @@ ov12_02269668: ; 0x02269668
add r5, r1, #0
ldr r0, [r5]
ldr r0, [r0]
bl ov12_0223A7D4
bl BattleSystem_GetBgConfig
add r6, r0, #0
ldrb r0, [r5, #0x12]
cmp r0, #4
@ -6800,7 +6800,7 @@ ov12_02269774: ; 0x02269774
bne _022697BE
ldr r0, [r4]
ldr r0, [r0]
bl ov12_0223A7D4
bl BattleSystem_GetBgConfig
mov r2, #0
mov r1, #4
add r3, r2, #0
@ -6829,7 +6829,7 @@ _022697BE:
ble _02269828
ldr r0, [r4]
ldr r0, [r0]
bl ov12_0223A7D4
bl BattleSystem_GetBgConfig
ldrb r1, [r4, #0x12]
add r5, r0, #0
cmp r1, #4
@ -9372,7 +9372,7 @@ ov12_0226AA8C: ; 0x0226AA8C
str r0, [sp, #0x1c]
ldr r0, [r0]
add r4, r1, #0
bl ov12_0223A7D4
bl BattleSystem_GetBgConfig
add r5, r0, #0
ldr r0, [sp, #0x1c]
ldr r0, [r0]

View File

@ -603,11 +603,11 @@ _02245D5A:
pop {r3, r4, r5, r6, r7, pc}
_02245D62:
ldr r0, [r4]
bl ov12_0223A7D4
bl BattleSystem_GetBgConfig
add r6, r0, #0
ldr r0, [r4]
mov r1, #1
bl ov12_0223A7D8
bl BattleSystem_GetWindow
add r5, r0, #0
ldr r0, [r4]
bl ov12_0223A938
@ -693,7 +693,7 @@ _02245E0A:
stmia r2!, {r0, r1}
ldr r0, [r4]
mov r1, #1
bl ov12_0223A7D8
bl BattleSystem_GetWindow
add r7, r0, #0
mov r0, #0x5f
ldr r1, [r4, #4]
@ -778,7 +778,7 @@ _02245EC8:
stmia r2!, {r0, r1}
ldr r0, [r4]
mov r1, #1
bl ov12_0223A7D8
bl BattleSystem_GetWindow
mov r1, #0x24
str r1, [sp]
mov r1, #0x60
@ -850,7 +850,7 @@ _02245F5C:
_02245F6C:
ldr r0, [r4]
mov r1, #1
bl ov12_0223A7D8
bl BattleSystem_GetWindow
add r6, r0, #0
mov r1, #0
bl sub_0200E5D4
@ -892,7 +892,7 @@ _02245FBA:
pop {r3, r4, r5, r6, r7, pc}
_02245FCE:
ldr r0, [r4]
bl ov12_0223A7D4
bl BattleSystem_GetBgConfig
add r1, r4, #0
add r0, r6, #0
add r1, #0x38
@ -2207,7 +2207,7 @@ _02246A72:
mov r1, #0
bl ov12_02261294
ldr r0, [r4]
bl ov12_0223A7D4
bl BattleSystem_GetBgConfig
str r0, [sp, #0xd0]
ldr r0, [r4]
bl ov12_0223A938
@ -5173,7 +5173,7 @@ ov12_02248228: ; 0x02248228
bl ov12_0223A9A4
str r0, [sp, #0x24]
add r0, r7, #0
bl ov12_0223A7D4
bl BattleSystem_GetBgConfig
str r0, [sp, #0x1c]
add r0, r7, #0
bl ov12_0223A8E4

View File

@ -2275,7 +2275,7 @@ ov12_022598F8: ; 0x022598F8
add r4, r1, #0
mov r1, #0
add r5, r0, #0
bl ov12_0223A7D8
bl BattleSystem_GetWindow
add r6, r0, #0
mov r1, #0xff
bl FillWindowPixelBuffer
@ -3450,7 +3450,7 @@ _0225A23E:
bne _0225A27A
_0225A26A:
add r0, r6, #0
bl ov12_0223A7D4
bl BattleSystem_GetBgConfig
mov r1, #3
mov r2, #2
mov r3, #0x84
@ -5437,7 +5437,7 @@ ov12_0225B1A8: ; 0x0225B1A8
bl ov12_0223C494
add r0, r5, #0
mov r1, #0
bl ov12_0223A7D8
bl BattleSystem_GetWindow
mov r1, #1
bl WaitingIcon_New
add r1, r0, #0
@ -8968,7 +8968,7 @@ ov12_0225CE28: ; 0x0225CE28
bne _0225CE64
_0225CE4E:
ldr r0, [r4]
bl ov12_0223A7D4
bl BattleSystem_GetBgConfig
mov r1, #3
mov r2, #1
mov r3, #4
@ -10509,7 +10509,7 @@ ov12_0225DAD4: ; 0x0225DAD4
add r4, r1, #0
add r7, r0, #0
ldr r0, [r4]
bl ov12_0223A7D4
bl BattleSystem_GetBgConfig
ldr r0, [r4]
bl ov12_0223A900
add r6, r0, #0
@ -11407,7 +11407,7 @@ ov12_0225E250: ; 0x0225E250
add r4, r1, #0
add r6, r0, #0
ldr r0, [r4]
bl ov12_0223A7D4
bl BattleSystem_GetBgConfig
ldr r0, [r4]
bl ov12_0223A900
add r7, r0, #0
@ -11787,7 +11787,7 @@ ov12_0225E568: ; 0x0225E568
add r4, r1, #0
str r0, [sp, #8]
ldr r0, [r4]
bl ov12_0223A7D4
bl BattleSystem_GetBgConfig
ldrb r1, [r4, #0xd]
ldr r0, [r4]
bl BattleSystem_GetOpponentDataByBattlerId
@ -13736,7 +13736,7 @@ _0225F502: ; jump table
_0225F50A:
ldr r0, [r4]
mov r1, #0
bl ov12_0223A7D8
bl BattleSystem_GetWindow
add r6, r0, #0
mov r1, #0xff
bl FillWindowPixelBuffer
@ -14372,7 +14372,7 @@ ov12_0225FA44: ; 0x0225FA44
add r4, r1, #0
add r6, r0, #0
ldr r0, [r4]
bl ov12_0223A7D4
bl BattleSystem_GetBgConfig
ldr r0, [r4]
bl ov12_0223A900
add r5, r0, #0
@ -15910,7 +15910,7 @@ ov12_02260668: ; 0x02260668
add r4, r1, #0
add r6, r0, #0
ldr r0, [r4]
bl ov12_0223A7D4
bl BattleSystem_GetBgConfig
ldr r0, [r4]
bl ov12_0223A938
add r7, r0, #0
@ -18621,7 +18621,7 @@ _02261B9E:
str r0, [sp, #0x18]
_02261BA8:
ldr r0, [sp]
bl ov12_0223A7D4
bl BattleSystem_GetBgConfig
str r0, [sp, #0x20]
ldr r0, [sp]
bl ov12_0223A938

View File

@ -16,47 +16,13 @@
.public ov12_02249460
.public BattleControllerPlayer_UpdateFieldCondition
.public BattleControllerPlayer_UpdateMonCondition
.public ov12_0224A70C
.public BattleControllerPlayer_UpdateFieldConditionExtra
.public BattleControllerPlayer_TurnEnd
.public BattleControllerPlayer_FightInput
.public BattleControllerPlayer_ItemInput
.public BattleControllerPlayer_PokemonInput
.public BattleControllerPlayer_RunInput
thumb_func_start ov12_0224AD58
ov12_0224AD58: ; 0x0224AD58
push {r3, r4, r5, lr}
add r4, r1, #0
add r5, r0, #0
ldr r2, _0224AD9C ; =0x00000113
add r0, r4, #0
mov r1, #1
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]
mov r0, #0x4a
mov r1, #5
lsl r0, r0, #2
str r1, [r4, r0]
add r0, r5, #0
bl ov12_0223B6B4
sub r1, r0, #1
add r0, r5, #0
bl ov12_0223B6C0
add r0, r5, #0
add r1, r4, #0
mov r2, #0
bl ov12_02263A1C
pop {r3, r4, r5, pc}
nop
_0224AD9C: .word 0x00000113
thumb_func_end ov12_0224AD58
.public BattleControllerPlayer_SafariBallInput
thumb_func_start ov12_0224ADA0
ov12_0224ADA0: ; 0x0224ADA0
@ -7268,13 +7234,13 @@ sPlayerBattleCommands: ; 0x0226CA90
.word ov12_02249460
.word BattleControllerPlayer_UpdateFieldCondition
.word BattleControllerPlayer_UpdateMonCondition
.word ov12_0224A70C
.word BattleControllerPlayer_UpdateFieldConditionExtra
.word BattleControllerPlayer_TurnEnd
.word BattleControllerPlayer_FightInput
.word BattleControllerPlayer_ItemInput
.word BattleControllerPlayer_PokemonInput
.word BattleControllerPlayer_RunInput
.word ov12_0224AD58
.word BattleControllerPlayer_SafariBallInput
.word ov12_0224ADA0
.word ov12_0224AE04
.word ov12_0224AE64

View File

@ -6,20 +6,6 @@
.text
thumb_func_start ov12_0223A7D4
ov12_0223A7D4: ; 0x0223A7D4
ldr r0, [r0, #4]
bx lr
thumb_func_end ov12_0223A7D4
thumb_func_start ov12_0223A7D8
ov12_0223A7D8: ; 0x0223A7D8
ldr r2, [r0, #8]
lsl r0, r1, #4
add r0, r2, r0
bx lr
thumb_func_end ov12_0223A7D8
thumb_func_start BattleSystem_GetBattleType
BattleSystem_GetBattleType: ; 0x0223A7E0
ldr r0, [r0, #0x2c]
@ -3984,7 +3970,7 @@ ov12_0223C34C: ; 0x0223C34C
mov r1, #0
str r2, [sp, #0xc]
add r5, r3, #0
bl ov12_0223A7D8
bl BattleSystem_GetWindow
add r7, r0, #0
ldr r0, [r6, #0x2c]
mov r2, #0x80
@ -4144,7 +4130,7 @@ ov12_0223C494: ; 0x0223C494
add r4, r2, #0
mov r1, #0
add r6, r3, #0
bl ov12_0223A7D8
bl BattleSystem_GetWindow
add r7, r0, #0
add r0, r5, #0
add r1, r4, #0

View File

@ -1,6 +1,7 @@
#ifndef POKEHEARTGOLD_BATTLE_H
#define POKEHEARTGOLD_BATTLE_H
#include "bg_window.h"
#include "item.h"
#include "move.h"
#include "pokemon_storage_system.h"
@ -254,10 +255,10 @@ typedef struct BATTLECONTEXT {
ControllerCommand commandNext;
int stateFieldConditionUpdate;
int fieldConditionUpdateData;
int unk_18;
int unk_1C;
int unk_20;
int unk_24;
int stateUpdateMonCondition;
int updateMonConditionData;
int stateUpdateFieldConditionExtra;
int updateFieldConditionExtraData;
int unk_28;
int unk_2C;
int unk_30;
@ -496,10 +497,14 @@ typedef struct UnkBattleSystemSub220 {
int unk8;
} UnkBattleSystemSub220;
typedef struct BattleSystemSub_C {
} BattleSystemSub_C;
struct BattleSystem {
u32 *unk0;
u32 *unk4;
u32 *unk8;
BgConfig *bgConfig;
Window *window;
u32 *unkC;
u32 *unk10;
u32 *unk14;

View File

@ -20,12 +20,13 @@ void ov12_0224930C(BattleSystem *bsys, BATTLECONTEXT *ctx);
void ov12_02249460(BattleSystem *bsys, BATTLECONTEXT *ctx);
void BattleControllerPlayer_UpdateFieldCondition(BattleSystem *bsys, BATTLECONTEXT *ctx);
void BattleControllerPlayer_UpdateMonCondition(BattleSystem *bsys, BATTLECONTEXT *ctx);
void ov12_0224A70C(BattleSystem *bsys, BATTLECONTEXT *ctx);
void BattleControllerPlayer_UpdateFieldConditionExtra(BattleSystem *bsys, BATTLECONTEXT *ctx);
void BattleControllerPlayer_TurnEnd(BattleSystem *bsys, BATTLECONTEXT *ctx);
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);
//The following functions haven't been decompiled yet
void ov12_0224E384(BattleSystem *bsys, BATTLECONTEXT *ctx);

View File

@ -7,6 +7,10 @@
#include "pokemon.h"
#include "sav_chatot.h"
BgConfig *BattleSystem_GetBgConfig(BattleSystem *bsys);
Window *BattleSystem_GetWindow(BattleSystem *bsys, int index);
//These functions haven't been decompiled
u16 BattleSystem_GetBattleType(BattleSystem *bsys);
u32 BattleSystem_GetFieldSide(BattleSystem *bsys, int battlerId);
int BattleSystem_GetMaxBattlers(BattleSystem *bsys);
@ -45,5 +49,8 @@ void ov12_022642F0(BattleSystem *bsys);
BOOL ov12_022581BC(BattleSystem *bsys, BATTLECONTEXT *ctx);
Bag *BattleSystem_GetBag(BattleSystem *bsys);
BagCursor *BattleSystem_GetBagCursor(BattleSystem *bsys);
int ov12_0223B6B4(BattleSystem *bsys);
void ov12_0223B6C0(BattleSystem *bsys, int item);
void ov12_02263A1C(BattleSystem *bsys, BATTLECONTEXT *ctx, int battlerId);
#endif

View File

@ -1,8 +1,6 @@
#ifndef POKEHEARTGOLD_CONSTANTS_MOVES_H
#define POKEHEARTGOLD_CONSTANTS_MOVES_H
#define LEARNED_MOVES_MAX 4
#define MOVE_NONE 0
#define MOVE_POUND 1
#define MOVE_KARATE_CHOP 2

View File

@ -565,6 +565,7 @@ Overlay OVY_12
{
After OVY_7
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

View File

@ -2649,7 +2649,7 @@ BOOL BtlCmd_TryMimic(BattleSystem *bsys, BATTLECONTEXT *ctx) {
int moveIndex = 0;
int mimicIndex = -1;
for (moveIndex = 0; moveIndex < LEARNED_MOVES_MAX; moveIndex++) {
for (moveIndex = 0; moveIndex < MAX_MON_MOVES; moveIndex++) {
if (ctx->battleMons[ctx->battlerIdAttacker].moves[moveIndex] == ctx->moveNoBattlerPrev[ctx->battlerIdTarget]) {
break;
}
@ -2658,7 +2658,7 @@ BOOL BtlCmd_TryMimic(BattleSystem *bsys, BATTLECONTEXT *ctx) {
}
}
if (moveIndex == LEARNED_MOVES_MAX) {
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) {
@ -2799,10 +2799,10 @@ BOOL BtlCmd_TryEncore(BattleSystem *bsys, BATTLECONTEXT *ctx) {
int encoredMoveIndex = BattleMon_GetMoveIndex(&ctx->battleMons[ctx->battlerIdTarget], ctx->moveNoBattlerPrev[ctx->battlerIdTarget]);
if (IsMoveEncored(ctx, ctx->moveNoBattlerPrev[ctx->battlerIdTarget]) == FALSE) {
encoredMoveIndex = LEARNED_MOVES_MAX;
encoredMoveIndex = MAX_MON_MOVES;
}
if (ctx->battleMons[ctx->battlerIdTarget].unk88.encoredMove == 0 && encoredMoveIndex != LEARNED_MOVES_MAX &&
if (ctx->battleMons[ctx->battlerIdTarget].unk88.encoredMove == 0 && encoredMoveIndex != MAX_MON_MOVES &&
ctx->battleMons[ctx->battlerIdTarget].movePPCur[encoredMoveIndex] && ctx->moveNoBattlerPrev[ctx->battlerIdTarget]) {
ctx->moveTemp = ctx->moveNoBattlerPrev[ctx->battlerIdTarget];
ctx->battleMons[ctx->battlerIdTarget].unk88.encoredMove = ctx->moveTemp;
@ -2875,7 +2875,7 @@ BOOL BtlCmd_TrySketch(BattleSystem *bsys, BATTLECONTEXT *ctx) {
if (ctx->battleMons[ctx->battlerIdAttacker].status2 & STATUS2_TRANSFORMED || ctx->moveNoSketch[ctx->battlerIdTarget] == MOVE_STRUGGLE || ctx->moveNoSketch[ctx->battlerIdTarget] == MOVE_SKETCH || ctx->moveNoSketch[ctx->battlerIdTarget] == MOVE_CHATTER || ctx->moveNoSketch[ctx->battlerIdTarget] == 0) {
BattleScriptIncrementPointer(ctx, adrs);
} else {
for (moveIndex = 0; moveIndex < LEARNED_MOVES_MAX; moveIndex++) {
for (moveIndex = 0; moveIndex < MAX_MON_MOVES; moveIndex++) {
if (ctx->battleMons[ctx->battlerIdAttacker].moves[moveIndex] != MOVE_SKETCH && ctx->battleMons[ctx->battlerIdAttacker].moves[moveIndex] == ctx->moveNoSketch[ctx->battlerIdTarget]) {
break;
}
@ -2883,7 +2883,7 @@ BOOL BtlCmd_TrySketch(BattleSystem *bsys, BATTLECONTEXT *ctx) {
sketchIndex = moveIndex;
}
}
if (moveIndex == LEARNED_MOVES_MAX) {
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;
BattleController_EmitBattleMonToPartyMonCopy(bsys, ctx, ctx->battlerIdAttacker);
@ -2908,7 +2908,7 @@ BOOL BtlCmd_TrySleepTalk(BattleSystem *bsys, BATTLECONTEXT *ctx) {
nonSelectableMoves = 0;
for (moveIndex = 0; moveIndex < LEARNED_MOVES_MAX; moveIndex++) {
for (moveIndex = 0; moveIndex < MAX_MON_MOVES; moveIndex++) {
if (CheckMoveCallsOtherMove(ctx->battleMons[ctx->battlerIdAttacker].moves[moveIndex]) ||
ctx->battleMons[ctx->battlerIdAttacker].moves[moveIndex] == MOVE_FOCUS_PUNCH ||
ctx->battleMons[ctx->battlerIdAttacker].moves[moveIndex] == MOVE_UPROAR ||
@ -2962,7 +2962,7 @@ BOOL BtlCmd_TrySpite(BattleSystem *bsys, BATTLECONTEXT *ctx) {
if (ctx->moveNoBattlerPrev[ctx->battlerIdTarget]) {
moveIndex = BattleMon_GetMoveIndex(&ctx->battleMons[ctx->battlerIdTarget], ctx->moveNoBattlerPrev[ctx->battlerIdTarget]);
if (moveIndex == LEARNED_MOVES_MAX || ctx->battleMons[ctx->battlerIdTarget].movePPCur[moveIndex] == 0) {
if (moveIndex == MAX_MON_MOVES || ctx->battleMons[ctx->battlerIdTarget].movePPCur[moveIndex] == 0) {
BattleScriptIncrementPointer(ctx, adrs);
} else {
ppLoss = 4;
@ -3233,7 +3233,7 @@ BOOL BtlCmd_Transform(BattleSystem *bsys, BATTLECONTEXT *ctx) {
ctx->battleMons[ctx->battlerIdAttacker].slowStartFlag = 0;
ctx->battleMons[ctx->battlerIdAttacker].slowStartEnded = 0;
for (i = 0; (int) i < LEARNED_MOVES_MAX; i++) {
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;
} else {
@ -4062,17 +4062,17 @@ BOOL BtlCmd_TryImprison(BattleSystem *bsys, BATTLECONTEXT *ctx) {
maxBattlers = BattleSystem_GetMaxBattlers(bsys);
for (battlerId = 0; battlerId < maxBattlers; battlerId++) {
if (side != BattleSystem_GetFieldSide(bsys, battlerId)) {
for (i = 0; i < LEARNED_MOVES_MAX; i++) {
for (j = 0; j < LEARNED_MOVES_MAX; j++) {
for (i = 0; i < MAX_MON_MOVES; i++) {
for (j = 0; j < MAX_MON_MOVES; j++) {
if ((ctx->battleMons[ctx->battlerIdAttacker].moves[i] == ctx->battleMons[battlerId].moves[j]) && ctx->battleMons[ctx->battlerIdAttacker].moves[i] && ctx->battleMons[battlerId].moves[j]) {
break;
}
}
if (j != LEARNED_MOVES_MAX) {
if (j != MAX_MON_MOVES) {
break;
}
}
if (j != LEARNED_MOVES_MAX) {
if (j != MAX_MON_MOVES) {
break;
}
}

View File

@ -1060,13 +1060,13 @@ void BattleControllerPlayer_UpdateMonCondition(BattleSystem *bsys, BATTLECONTEXT
return;
}
while (ctx->unk_1C < maxBattlers) {
battlerId = ctx->turnOrder[ctx->unk_1C];
while (ctx->updateMonConditionData < maxBattlers) {
battlerId = ctx->turnOrder[ctx->updateMonConditionData];
if (ctx->unk_3108 & MaskOfFlagNo(battlerId)) {
ctx->unk_1C++;
ctx->updateMonConditionData++;
continue;
}
switch (ctx->unk_18) {
switch (ctx->stateUpdateMonCondition) {
case UMC_STATE_INGRAIN:
if ((ctx->battleMons[battlerId].moveEffectFlags & MOVE_EFFECT_FLAG_INGRAIN) && ctx->battleMons[battlerId].hp != ctx->battleMons[battlerId].maxHp && ctx->battleMons[battlerId].hp) {
if (ctx->battleMons[battlerId].unk88.healBlockTurns) {
@ -1080,7 +1080,7 @@ void BattleControllerPlayer_UpdateMonCondition(BattleSystem *bsys, BATTLECONTEXT
ctx->command = CONTROLLER_COMMAND_RUN_SCRIPT;
flag = 1;
}
ctx->unk_18++;
ctx->stateUpdateMonCondition++;
break;
case UMC_STATE_AQUA_RING:
if ((ctx->battleMons[battlerId].moveEffectFlags & MOVE_EFFECT_FLAG_AQUA_RING) && ctx->battleMons[battlerId].hp != ctx->battleMons[battlerId].maxHp && ctx->battleMons[battlerId].hp) {
@ -1097,25 +1097,25 @@ void BattleControllerPlayer_UpdateMonCondition(BattleSystem *bsys, BATTLECONTEXT
ctx->command = CONTROLLER_COMMAND_RUN_SCRIPT;
flag = 1;
}
ctx->unk_18++;
ctx->stateUpdateMonCondition++;
break;
case UMC_STATE_ABILITY:
if (ov12_02253068(bsys, ctx, battlerId) == TRUE) {
flag = 1;
}
ctx->unk_18++;
ctx->stateUpdateMonCondition++;
break;
case UMC_STATE_HELD_ITEM:
if (TryUseHeldItem(bsys, ctx, battlerId) == TRUE) {
flag = 1;
}
ctx->unk_18++;
ctx->stateUpdateMonCondition++;
break;
case UMC_STATE_LEFTOVERS_RECOVERY:
if (CheckItemGradualHPRestore(bsys, ctx, battlerId) == TRUE) {
flag = 1;
}
ctx->unk_18++;
ctx->stateUpdateMonCondition++;
break;
case UMC_STATE_LEECH_SEED:
if ((ctx->battleMons[battlerId].moveEffectFlags & MOVE_EFFECT_FLAG_LEECH_SEED) && ctx->battleMons[ctx->battleMons[battlerId].moveEffectFlags & MOVE_EFFECT_FLAG_LEECH_SEED_BATTLER].hp &&
@ -1127,7 +1127,7 @@ void BattleControllerPlayer_UpdateMonCondition(BattleSystem *bsys, BATTLECONTEXT
ctx->command = CONTROLLER_COMMAND_RUN_SCRIPT;
flag = 1;
}
ctx->unk_18++;
ctx->stateUpdateMonCondition++;
break;
case UMC_STATE_POISON:
if ((ctx->battleMons[battlerId].status & STATUS_POISON) && ctx->battleMons[battlerId].hp) {
@ -1138,7 +1138,7 @@ void BattleControllerPlayer_UpdateMonCondition(BattleSystem *bsys, BATTLECONTEXT
ctx->command = CONTROLLER_COMMAND_RUN_SCRIPT;
flag = 1;
}
ctx->unk_18++;
ctx->stateUpdateMonCondition++;
break;
case UMC_STATE_BAD_POISON:
if ((ctx->battleMons[battlerId].status & STATUS_BAD_POISON) && ctx->battleMons[battlerId].hp) {
@ -1154,7 +1154,7 @@ void BattleControllerPlayer_UpdateMonCondition(BattleSystem *bsys, BATTLECONTEXT
ctx->command = CONTROLLER_COMMAND_RUN_SCRIPT;
flag = 1;
}
ctx->unk_18++;
ctx->stateUpdateMonCondition++;
break;
case UMC_STATE_BURN:
if ((ctx->battleMons[battlerId].status & STATUS_BURN) && ctx->battleMons[battlerId].hp) {
@ -1164,7 +1164,7 @@ void BattleControllerPlayer_UpdateMonCondition(BattleSystem *bsys, BATTLECONTEXT
ctx->command = CONTROLLER_COMMAND_RUN_SCRIPT;
flag = 1;
}
ctx->unk_18++;
ctx->stateUpdateMonCondition++;
break;
case UMC_STATE_NIGHTMARE:
if ((ctx->battleMons[battlerId].status2 & STATUS2_NIGHTMARE) && ctx->battleMons[battlerId].hp) {
@ -1178,7 +1178,7 @@ void BattleControllerPlayer_UpdateMonCondition(BattleSystem *bsys, BATTLECONTEXT
ctx->battleMons[battlerId].status2 &= ~STATUS2_NIGHTMARE;
}
}
ctx->unk_18++;
ctx->stateUpdateMonCondition++;
break;
case UMC_STATE_CURSE:
if ((ctx->battleMons[battlerId].status2 & STATUS2_CURSE) && ctx->battleMons[battlerId].hp) {
@ -1188,7 +1188,7 @@ void BattleControllerPlayer_UpdateMonCondition(BattleSystem *bsys, BATTLECONTEXT
ctx->command = CONTROLLER_COMMAND_RUN_SCRIPT;
flag = 1;
}
ctx->unk_18++;
ctx->stateUpdateMonCondition++;
break;
case UMC_STATE_BINDING:
if ((ctx->battleMons[battlerId].status2 & STATUS2_BINDING_TURNS) && ctx->battleMons[battlerId].hp) {
@ -1205,7 +1205,7 @@ void BattleControllerPlayer_UpdateMonCondition(BattleSystem *bsys, BATTLECONTEXT
ctx->command = CONTROLLER_COMMAND_RUN_SCRIPT;
flag = 1;
}
ctx->unk_18++;
ctx->stateUpdateMonCondition++;
break;
case UMC_STATE_BAD_DREAMS:
ctx->tempData = CheckAbilityActive(bsys, ctx, CHECK_ABILITY_OPPOSING_SIDE_HP_RET, battlerId, ABILITY_BAD_DREAMS);
@ -1219,7 +1219,7 @@ void BattleControllerPlayer_UpdateMonCondition(BattleSystem *bsys, BATTLECONTEXT
ctx->command = CONTROLLER_COMMAND_RUN_SCRIPT;
flag = 1;
}
ctx->unk_18++;
ctx->stateUpdateMonCondition++;
break;
case UMC_STATE_UPROAR:
if (ctx->battleMons[battlerId].status2 & STATUS2_UPROAR) {
@ -1256,7 +1256,7 @@ void BattleControllerPlayer_UpdateMonCondition(BattleSystem *bsys, BATTLECONTEXT
flag = 1;
}
if (flag != 2) {
ctx->unk_18++;
ctx->stateUpdateMonCondition++;
}
break;
case UMC_STATE_RAMPAGE:
@ -1272,16 +1272,16 @@ void BattleControllerPlayer_UpdateMonCondition(BattleSystem *bsys, BATTLECONTEXT
flag = 1;
}
}
ctx->unk_18++;
ctx->stateUpdateMonCondition++;
break;
case UMC_STATE_DISABLE:
if (ctx->battleMons[battlerId].unk88.disabledMove) {
for (i = 0; i < LEARNED_MOVES_MAX; i++) {
for (i = 0; i < MAX_MON_MOVES; i++) {
if (ctx->battleMons[battlerId].unk88.disabledMove == ctx->battleMons[battlerId].moves[i]) {
break;
}
}
if (i == LEARNED_MOVES_MAX) {
if (i == MAX_MON_MOVES) {
ctx->battleMons[battlerId].unk88.disabledTurns = 0;
}
if (ctx->battleMons[battlerId].unk88.disabledTurns) {
@ -1295,16 +1295,16 @@ void BattleControllerPlayer_UpdateMonCondition(BattleSystem *bsys, BATTLECONTEXT
flag = 1;
}
}
ctx->unk_18++;
ctx->stateUpdateMonCondition++;
break;
case UMC_STATE_ENCORE:
if (ctx->battleMons[battlerId].unk88.encoredMove) {
for (i = 0; i < LEARNED_MOVES_MAX; i++) {
for (i = 0; i < MAX_MON_MOVES; i++) {
if (ctx->battleMons[battlerId].unk88.encoredMove == ctx->battleMons[battlerId].moves[i]) {
break;
}
}
if (i == LEARNED_MOVES_MAX || (i != LEARNED_MOVES_MAX && !ctx->battleMons[battlerId].movePPCur[i])) {
if (i == MAX_MON_MOVES || (i != MAX_MON_MOVES && !ctx->battleMons[battlerId].movePPCur[i])) {
ctx->battleMons[battlerId].unk88.encoredTurns = 0;
}
if (ctx->battleMons[battlerId].unk88.encoredTurns) {
@ -1318,13 +1318,13 @@ void BattleControllerPlayer_UpdateMonCondition(BattleSystem *bsys, BATTLECONTEXT
flag = 1;
}
}
ctx->unk_18++;
ctx->stateUpdateMonCondition++;
break;
case UMC_STATE_LOCK_ON:
if (ctx->battleMons[battlerId].moveEffectFlags & MOVE_EFFECT_FLAG_LOCK_ON) {
ctx->battleMons[battlerId].moveEffectFlags -= 1 << MOVE_EFFECT_FLAG_LOCK_ON_SHIFT;
}
ctx->unk_18++;
ctx->stateUpdateMonCondition++;
break;
case UMC_STATE_CHARGE:
if (ctx->battleMons[battlerId].unk88.isCharged) {
@ -1332,7 +1332,7 @@ void BattleControllerPlayer_UpdateMonCondition(BattleSystem *bsys, BATTLECONTEXT
ctx->battleMons[battlerId].moveEffectFlags &= ~MOVE_EFFECT_FLAG_CHARGE;
}
}
ctx->unk_18++;
ctx->stateUpdateMonCondition++;
break;
case UMC_STATE_TAUNT:
if (ctx->battleMons[battlerId].unk88.tauntTurns) {
@ -1345,7 +1345,7 @@ void BattleControllerPlayer_UpdateMonCondition(BattleSystem *bsys, BATTLECONTEXT
flag = 1;
}
}
ctx->unk_18++;
ctx->stateUpdateMonCondition++;
break;
case UMC_STATE_MAGNET_RISE:
if (ctx->battleMons[battlerId].unk88.magnetRiseTurns) {
@ -1357,7 +1357,7 @@ void BattleControllerPlayer_UpdateMonCondition(BattleSystem *bsys, BATTLECONTEXT
flag = 1;
}
}
ctx->unk_18++;
ctx->stateUpdateMonCondition++;
break;
case UMC_STATE_HEALBLOCK:
if (ctx->battleMons[battlerId].unk88.healBlockTurns) {
@ -1369,7 +1369,7 @@ void BattleControllerPlayer_UpdateMonCondition(BattleSystem *bsys, BATTLECONTEXT
flag = 1;
}
}
ctx->unk_18++;
ctx->stateUpdateMonCondition++;
break;
case UMC_STATE_EMBARGO:
if (ctx->battleMons[battlerId].unk88.embargoFlag) {
@ -1381,7 +1381,7 @@ void BattleControllerPlayer_UpdateMonCondition(BattleSystem *bsys, BATTLECONTEXT
flag = 1;
}
}
ctx->unk_18++;
ctx->stateUpdateMonCondition++;
break;
case UMC_STATE_YAWN:
if (ctx->battleMons[battlerId].moveEffectFlags & MOVE_EFFECT_FLAG_YAWN) {
@ -1395,7 +1395,7 @@ void BattleControllerPlayer_UpdateMonCondition(BattleSystem *bsys, BATTLECONTEXT
flag = 1;
}
}
ctx->unk_18++;
ctx->stateUpdateMonCondition++;
break;
case UMC_STATE_HELD_ITEM_STATUS:
int script;
@ -1407,17 +1407,17 @@ void BattleControllerPlayer_UpdateMonCondition(BattleSystem *bsys, BATTLECONTEXT
ctx->command = CONTROLLER_COMMAND_RUN_SCRIPT;
flag = 1;
}
ctx->unk_18++;
ctx->stateUpdateMonCondition++;
break;
case UMC_STATE_HELD_ITEM_DAMAGE:
if (TryHeldItemNegativeEffect(bsys, ctx, battlerId) == TRUE) {
flag = 1;
}
ctx->unk_18++;
ctx->stateUpdateMonCondition++;
break;
case UMC_STATE_END:
ctx->unk_18 = 0;
ctx->unk_1C++;
ctx->stateUpdateMonCondition = 0;
ctx->updateMonConditionData++;
break;
}
if (flag) {
@ -1425,20 +1425,22 @@ void BattleControllerPlayer_UpdateMonCondition(BattleSystem *bsys, BATTLECONTEXT
return;
}
}
ctx->unk_18 = 0;
ctx->unk_1C = 0;
ctx->stateUpdateMonCondition = 0;
ctx->updateMonConditionData = 0;
ctx->command = CONTROLLER_COMMAND_11;
}
typedef enum UpdateSideConditionState {
USC_STATE_FUTURE_SIGHT,
USC_STATE_PERISH_SONG,
USC_STATE_TRICK_ROOM,
USC_STATE_END
} UpdateSideConditionState;
typedef enum UpdateFieldConditionExtraState {
UFCE_STATE_FUTURE_SIGHT,
UFCE_STATE_PERISH_SONG,
UFCE_STATE_TRICK_ROOM,
UFCE_STATE_END
} UpdateFieldConditionExtraState;
//Future sight and doom desire are here due to mons being able to faint simulataneously, which means exp shouldn't be awarded like when a mon faints due to burn
//Trick room is here due to every other update function being reliant on turn order, meaning it must be updated last
//static
void ov12_0224A70C(BattleSystem *bsys, BATTLECONTEXT *ctx) {
void BattleControllerPlayer_UpdateFieldConditionExtra(BattleSystem *bsys, BATTLECONTEXT *ctx) {
int maxBattlers = BattleSystem_GetMaxBattlers(bsys);
int battlerId;
@ -1448,15 +1450,15 @@ void ov12_0224A70C(BattleSystem *bsys, BATTLECONTEXT *ctx) {
ov12_022642F0(bsys);
switch (ctx->unk_20) {
case USC_STATE_FUTURE_SIGHT:
while (ctx->unk_24 < maxBattlers) {
battlerId = ctx->turnOrder[ctx->unk_24];
switch (ctx->stateUpdateFieldConditionExtra) {
case UFCE_STATE_FUTURE_SIGHT:
while (ctx->updateFieldConditionExtraData < maxBattlers) {
battlerId = ctx->turnOrder[ctx->updateFieldConditionExtraData];
if (ctx->unk_3108 & MaskOfFlagNo(battlerId)) {
ctx->unk_24++;
ctx->updateFieldConditionExtraData++;
continue;
}
ctx->unk_24++;
ctx->updateFieldConditionExtraData++;
if (ctx->fieldConditionData.futureSightTurns[battlerId]) {
if (!(--ctx->fieldConditionData.futureSightTurns[battlerId]) && ctx->battleMons[battlerId].hp) {
ctx->fieldSideConditionFlags[BattleSystem_GetFieldSide(bsys, battlerId)] &= ~SIDE_CONDITION_FUTURE_SIGHT;
@ -1475,16 +1477,16 @@ void ov12_0224A70C(BattleSystem *bsys, BATTLECONTEXT *ctx) {
}
}
}
ctx->unk_20++;
ctx->unk_24 = 0;
case USC_STATE_PERISH_SONG:
while (ctx->unk_24 < maxBattlers) {
battlerId = ctx->turnOrder[ctx->unk_24];
ctx->stateUpdateFieldConditionExtra++;
ctx->updateFieldConditionExtraData = 0;
case UFCE_STATE_PERISH_SONG:
while (ctx->updateFieldConditionExtraData < maxBattlers) {
battlerId = ctx->turnOrder[ctx->updateFieldConditionExtraData];
if (ctx->unk_3108 & MaskOfFlagNo(battlerId)) {
ctx->unk_24++;
ctx->updateFieldConditionExtraData++;
continue;
}
ctx->unk_24++;
ctx->updateFieldConditionExtraData++;
if (ctx->battleMons[battlerId].moveEffectFlags & MOVE_EFFECT_FLAG_PERISH_SONG) {
if (ctx->battleMons[battlerId].unk88.perishSongTurns == 0) {
ctx->battleMons[battlerId].moveEffectFlags &= ~MOVE_EFFECT_FLAG_PERISH_SONG;
@ -1502,9 +1504,9 @@ void ov12_0224A70C(BattleSystem *bsys, BATTLECONTEXT *ctx) {
return;
}
}
ctx->unk_20++;
ctx->unk_24 = 0;
case USC_STATE_TRICK_ROOM:
ctx->stateUpdateFieldConditionExtra++;
ctx->updateFieldConditionExtraData = 0;
case UFCE_STATE_TRICK_ROOM:
if (ctx->fieldCondition & FIELD_CONDITION_TRICK_ROOM) {
ctx->fieldCondition -= 1 << FIELD_CONDITION_TRICK_ROOM_SHIFT;
if (!(ctx->fieldCondition & FIELD_CONDITION_TRICK_ROOM)) {
@ -1514,14 +1516,14 @@ void ov12_0224A70C(BattleSystem *bsys, BATTLECONTEXT *ctx) {
return;
}
}
ctx->unk_20++;
ctx->unk_24 = 0;
ctx->stateUpdateFieldConditionExtra++;
ctx->updateFieldConditionExtraData = 0;
break;
default:
break;
}
ctx->unk_20 = 0;
ctx->unk_24 = 0;
ctx->stateUpdateFieldConditionExtra = 0;
ctx->updateFieldConditionExtraData = 0;
ctx->command = CONTROLLER_COMMAND_12;
}
@ -1684,3 +1686,18 @@ void BattleControllerPlayer_RunInput(BattleSystem *bsys, BATTLECONTEXT *ctx) {
}
}
}
//static
void BattleControllerPlayer_SafariBallInput(BattleSystem *bsys, BATTLECONTEXT *ctx) {
int ball;
ReadBattleScriptFromNarc(ctx, NARC_a_0_0_1, 275);
ctx->battlerIdAttacker = BATTLER_PLAYER;
ctx->battlerIdTarget = BATTLER_ENEMY;
ctx->command = CONTROLLER_COMMAND_RUN_SCRIPT;
ctx->commandNext = CONTROLLER_COMMAND_40;
ctx->itemTemp = ITEM_SAFARI_BALL;
ball = ov12_0223B6B4(bsys) - 1;
ov12_0223B6C0(bsys, ball);
ov12_02263A1C(bsys, ctx, BATTLER_PLAYER);
}

View File

@ -0,0 +1,10 @@
#include "global.h"
#include "battle_system.h"
BgConfig *BattleSystem_GetBgConfig(BattleSystem *bsys) {
return bsys->bgConfig;
}
Window *BattleSystem_GetWindow(BattleSystem *bsys, int index) {
return &bsys->window[index];
}

View File

@ -1753,8 +1753,8 @@ void BattleContext_Init(BATTLECONTEXT *ctx) {
//unidentified states for different state machines
ctx->stateFieldConditionUpdate = 0;
ctx->unk_18 = 0;
ctx->unk_20 = 0;
ctx->stateUpdateMonCondition = 0;
ctx->stateUpdateFieldConditionExtra = 0;
ctx->unk_28 = 0;
ctx->unk_30 = 0;
ctx->unk_3C = 0;
@ -3276,12 +3276,12 @@ BOOL BattleContext_CheckMoveImprisoned(BattleSystem *bsys, BATTLECONTEXT *ctx, i
for (battlerIdCur = 0; battlerIdCur < maxBattlers; battlerIdCur++) {
if ((side != BattleSystem_GetFieldSide(bsys, battlerIdCur)) && (ctx->battleMons[battlerIdCur].moveEffectFlags & MOVE_EFFECT_FLAG_IMPRISON_USER)) {
for (i = 0; i < LEARNED_MOVES_MAX; i++) {
for (i = 0; i < MAX_MON_MOVES; i++) {
if (moveNo == ctx->battleMons[battlerIdCur].moves[i]) {
break;
}
}
if (i != LEARNED_MOVES_MAX) {
if (i != MAX_MON_MOVES) {
ret = TRUE;
}
}
@ -3459,7 +3459,7 @@ BOOL BattleContext_CheckMoveHealBlocked(BattleSystem *bsys, BATTLECONTEXT *ctx,
void ov12_02252E30(BattleSystem *bsys, BATTLECONTEXT *ctx) {
int i;
if (ctx->moveNoTemp == MOVE_LAST_RESORT || ctx->battleMons[ctx->battlerIdAttacker].unk88.lastResortCount == LEARNED_MOVES_MAX) {
if (ctx->moveNoTemp == MOVE_LAST_RESORT || ctx->battleMons[ctx->battlerIdAttacker].unk88.lastResortCount == MAX_MON_MOVES) {
return;
}
@ -3476,7 +3476,7 @@ void ov12_02252E30(BattleSystem *bsys, BATTLECONTEXT *ctx) {
int GetBattlerLearnedMoveCount(BattleSystem *bsys, BATTLECONTEXT *ctx, int battlerId) {
int cnt;
for (cnt = 0; cnt < LEARNED_MOVES_MAX; cnt++) {
for (cnt = 0; cnt < MAX_MON_MOVES; cnt++) {
if (ctx->battleMons[battlerId].moves[cnt] == MOVE_NONE) {
break;
}
@ -3797,7 +3797,7 @@ int TryAbilityOnEntry(BattleSystem *bsys, BATTLECONTEXT *ctx) {
u32 moveStatus;
for (battlerIdCheck = 0; battlerIdCheck < maxBattlers; battlerIdCheck++) {
if (BattleSystem_GetFieldSide(bsys, battlerId) != BattleSystem_GetFieldSide(bsys, battlerIdCheck) && ctx->battleMons[battlerIdCheck].hp) {
for (index = 0; index < LEARNED_MOVES_MAX; index++) {
for (index = 0; index < MAX_MON_MOVES; index++) {
moveNo = ctx->battleMons[battlerIdCheck].moves[index];
if (moveNo) {
moveStatus = 0;
@ -3843,7 +3843,7 @@ int TryAbilityOnEntry(BattleSystem *bsys, BATTLECONTEXT *ctx) {
for (battlerIdCheck = 0; battlerIdCheck < maxBattlers; battlerIdCheck++) {
if (BattleSystem_GetFieldSide(bsys, battlerId) != BattleSystem_GetFieldSide(bsys, battlerIdCheck) && ctx->battleMons[battlerIdCheck].hp) {
hp += ctx->battleMons[battlerIdCheck].hp;
for (index = 0; index < LEARNED_MOVES_MAX; index++) {
for (index = 0; index < MAX_MON_MOVES; index++) {
moveNo = ctx->battleMons[battlerIdCheck].moves[index];
power = ctx->unk_334.moveData[moveNo].power;
switch (power) {
@ -4455,12 +4455,12 @@ BOOL TryUseHeldItem(BattleSystem *bsys, BATTLECONTEXT *ctx, int battlerId) {
break;
case HOLD_EFFECT_PP_RESTORE: //leppa berry
int index;
for (index = 0; index < LEARNED_MOVES_MAX; index++) {
for (index = 0; index < MAX_MON_MOVES; index++) {
if (ctx->battleMons[battlerId].moves[index] && !ctx->battleMons[battlerId].movePPCur[index]) {
break;
}
}
if (index != LEARNED_MOVES_MAX) {
if (index != MAX_MON_MOVES) {
AddBattlerVar(&ctx->battleMons[battlerId], BMON_DATA_MOVE1PP + index, boost);
CopyBattleMonToPartyMon(bsys, ctx, battlerId);
ctx->moveTemp = ctx->battleMons[battlerId].moves[index];
@ -4782,12 +4782,12 @@ BOOL CheckUseHeldItem(BattleSystem *bsys, BATTLECONTEXT *ctx, int battlerId, u32
break;
case HOLD_EFFECT_PP_RESTORE: //leppa berry
int index;
for (index = 0; index < LEARNED_MOVES_MAX; index++) {
for (index = 0; index < MAX_MON_MOVES; index++) {
if (ctx->battleMons[battlerId].moves[index] && !ctx->battleMons[battlerId].movePPCur[index]) {
break;
}
}
if (index != LEARNED_MOVES_MAX) {
if (index != MAX_MON_MOVES) {
AddBattlerVar(&ctx->battleMons[battlerId], BMON_DATA_MOVE1PP + index, boost);
CopyBattleMonToPartyMon(bsys, ctx, battlerId);
ctx->moveTemp = ctx->battleMons[battlerId].moves[index];
@ -5270,7 +5270,7 @@ BOOL TryEatOpponentBerry(BattleSystem *bsys, BATTLECONTEXT *ctx, int battlerId)
int index;
int max = 0;
int maxIndex;
for (index = 0; index < LEARNED_MOVES_MAX; index++) {
for (index = 0; index < MAX_MON_MOVES; index++) {
if (ctx->battleMons[ctx->battlerIdAttacker].moves[index]) {
ppCalc = GetMoveMaxPP(ctx->battleMons[ctx->battlerIdAttacker].moves[index], ctx->battleMons[ctx->battlerIdAttacker].movePP[index]) - ctx->battleMons[ctx->battlerIdAttacker].movePPCur[index];
if (ppCalc > max) {
@ -5510,7 +5510,7 @@ BOOL TryFling(BattleSystem *bsys, BATTLECONTEXT *ctx, int battlerId) {
int index;
int max = 0;
int maxIndex;
for (index = 0; index < LEARNED_MOVES_MAX; index++) {
for (index = 0; index < MAX_MON_MOVES; index++) {
if (ctx->battleMons[ctx->battlerIdTarget].moves[index]) {
ppCalc = GetMoveMaxPP(ctx->battleMons[ctx->battlerIdTarget].moves[index], ctx->battleMons[ctx->battlerIdTarget].movePP[index]) - ctx->battleMons[ctx->battlerIdTarget].movePPCur[index];
if (ppCalc > max) {
@ -7181,7 +7181,7 @@ static u8 Battler_GetType(BATTLECONTEXT *ctx, int battlerId, int var) {
}
static void ov12_02258584(BATTLECONTEXT *ctx, u8 battlerId) {
for (int i = 0; i < LEARNED_MOVES_MAX; i++) {
for (int i = 0; i < MAX_MON_MOVES; i++) {
ctx->unk_334.unk1C[battlerId][i] = 0;
}
}