pokeheartgold/asm/overlay_12_battle_controller_player.s
2024-01-17 07:18:03 -05:00

1395 lines
26 KiB
ArmAsm

#include "constants/pokemon.h"
#include "constants/sndseq.h"
.include "asm/macros.inc"
.include "overlay_12_battle_controller_player.inc"
.include "global.inc"
.text
.public BattleControllerPlayer_GetBattleMon
.public BattleControllerPlayer_StartEncounter
.public BattleControllerPlayer_TrainerMessage
.public BattleControllerPlayer_PokemonAppear
.public BattleControllerPlayer_SelectionScreenInit
.public BattleControllerPlayer_SelectionScreenInput
.public ov12_02249190
.public ov12_0224930C
.public ov12_02249460
.public BattleControllerPlayer_UpdateFieldCondition
.public BattleControllerPlayer_UpdateMonCondition
.public BattleControllerPlayer_UpdateFieldConditionExtra
.public BattleControllerPlayer_TurnEnd
.public BattleControllerPlayer_FightInput
.public BattleControllerPlayer_ItemInput
.public BattleControllerPlayer_PokemonInput
.public BattleControllerPlayer_RunInput
.public BattleControllerPlayer_SafariThrowBall
.public BattleControllerPlayer_SafariThrowMud
.public BattleControllerPlayer_SafariRun
.public BattleControllerPlayer_SafariWatching
.public BattleControllerPlayer_CatchingContestThrowBall
.public TryDisobedience
.public ov12_0224B1FC
.public ov12_0224B398
.public ov12_0224B498
.public ov12_0224B528
.public ov12_0224BC2C
.public ov12_0224BCA4
.public BattleSystem_CheckMoveHit
.public BattleSystem_CheckMoveEffect
.public ov12_0224C204
.public BattleControllerPlayer_RunScript
.public ov12_0224C38C
.public ov12_0224C4D8
.public ov12_0224C5C8
.public ov12_0224C5F8
.public ov12_0224C678
.public ov12_0224C690
.public ov12_0224CAA4
.public ov12_0224CC84
.public ov12_0224CC88
.public ov12_0224CF10
.public ov12_0224CF14
.public ov12_0224D014
.public ov12_0224D03C
.public ov12_0224D1DC
.public ov12_0224D224
.public ov12_0224D238
.public ov12_0224D23C
.public ov12_0224D368
.public ov12_0224D448
.public ov12_0224D464
.public ov12_0224D4F0
.public ov12_0224D504
.public ov12_0224D53C
.public ov12_0224D540
thumb_func_start ov12_0224DB64
ov12_0224DB64: ; 0x0224DB64
push {r3, r4, r5, r6, r7, lr}
sub sp, #0x10
str r0, [sp]
add r5, r1, #0
ldr r0, _0224DBFC ; =0x00002D4C
add r6, r2, #0
mov r1, #0xc0
add r0, r5, r0
mul r1, r6
add r0, r0, r1
str r0, [sp, #8]
ldr r0, [sp, #0x2c]
ldr r1, [sp, #8]
lsl r0, r0, #1
ldrh r1, [r1, r0]
str r3, [sp, #4]
ldr r4, [sp, #0x28]
ldr r7, [sp, #0x30]
str r0, [sp, #0xc]
cmp r1, #0xae
bne _0224DB9E
add r0, r5, #0
bl CurseUserIsGhost
cmp r0, #0
bne _0224DB9E
mov r0, #0x10
str r0, [r4]
b _0224DBAE
_0224DB9E:
ldr r1, [sp, #8]
ldr r0, [sp, #0xc]
ldrh r0, [r1, r0]
lsl r0, r0, #4
add r1, r5, r0
ldr r0, _0224DC00 ; =0x000003E6
ldrh r0, [r1, r0]
str r0, [r4]
_0224DBAE:
ldr r0, [sp, #4]
mov r1, #2
tst r0, r1
beq _0224DBE4
ldr r0, [r4]
add r1, #0xfe
cmp r0, r1
bne _0224DBDE
ldr r0, [sp]
add r1, r6, #0
bl BattleSystem_GetBattlerIdPartner
bl MaskOfFlagNo
ldr r1, _0224DC04 ; =0x00003108
ldrb r1, [r5, r1]
tst r0, r1
bne _0224DBD8
add sp, #0x10
mov r0, #1
pop {r3, r4, r5, r6, r7, pc}
_0224DBD8:
add sp, #0x10
mov r0, #0
pop {r3, r4, r5, r6, r7, pc}
_0224DBDE:
add sp, #0x10
mov r0, #1
pop {r3, r4, r5, r6, r7, pc}
_0224DBE4:
ldr r1, [r4]
ldr r0, _0224DC08 ; =0x00000251
tst r0, r1
beq _0224DBF0
str r6, [r7]
b _0224DBF6
_0224DBF0:
mov r0, #1
eor r0, r6
str r0, [r7]
_0224DBF6:
mov r0, #0
add sp, #0x10
pop {r3, r4, r5, r6, r7, pc}
.balign 4, 0
_0224DBFC: .word 0x00002D4C
_0224DC00: .word 0x000003E6
_0224DC04: .word 0x00003108
_0224DC08: .word 0x00000251
thumb_func_end ov12_0224DB64
thumb_func_start ov12_0224DC0C
ov12_0224DC0C: ; 0x0224DC0C
push {r3, r4, r5, r6, r7, lr}
str r1, [sp]
bl BattleSystem_GetMaxBattlers
add r4, r0, #0
mov r3, #0
cmp r4, #0
ble _0224DC46
ldr r5, [sp]
add r7, r3, #0
add r6, r5, #0
_0224DC22:
ldr r0, _0224DC68 ; =0x00002DB0
add r3, r3, #1
ldr r2, [r6, r0]
ldr r0, _0224DC6C ; =0x0000218C
ldr r1, [r5, r0]
mov r0, #0
mvn r0, r0
eor r0, r1
add r1, r2, #0
and r1, r0
ldr r0, _0224DC68 ; =0x00002DB0
str r1, [r6, r0]
ldr r0, _0224DC6C ; =0x0000218C
add r6, #0xc0
str r7, [r5, r0]
add r5, r5, #4
cmp r3, r4
blt _0224DC22
_0224DC46:
ldr r1, [sp]
mov r0, #0
ldr r1, [r1, #0x64]
lsl r2, r1, #1
ldr r1, [sp]
add r1, r1, r2
ldr r2, _0224DC70 ; =0x00003064
strh r0, [r1, r2]
ldr r1, [sp]
add r2, #0x60
ldr r1, [r1, #0x64]
lsl r3, r1, #1
ldr r1, [sp]
add r1, r1, r3
strh r0, [r1, r2]
pop {r3, r4, r5, r6, r7, pc}
nop
_0224DC68: .word 0x00002DB0
_0224DC6C: .word 0x0000218C
_0224DC70: .word 0x00003064
thumb_func_end ov12_0224DC0C
thumb_func_start ov12_0224DC74
ov12_0224DC74: ; 0x0224DC74
push {r3, r4, r5, r6, r7, lr}
sub sp, #8
add r5, r0, #0
ldr r0, _0224DD0C ; =0x000021EC
str r1, [sp]
ldrb r0, [r5, r0]
add r6, r2, #0
str r3, [sp, #4]
mov r4, #0
bl MaskOfFlagNo
ldr r1, _0224DD10 ; =0x0000213C
lsl r0, r0, #0x18
ldr r2, [r5, r1]
mov r1, #0xf
lsl r1, r1, #0x18
tst r1, r2
beq _0224DD02
add r1, r2, #0
tst r1, r0
bne _0224DCB6
ldr r7, _0224DD0C ; =0x000021EC
add r6, r7, #0
sub r6, #0xb0
_0224DCA4:
add r4, r4, #1
add r0, r5, r4
ldrb r0, [r0, r7]
bl MaskOfFlagNo
ldr r1, [r5, r6]
lsl r0, r0, #0x18
tst r1, r0
beq _0224DCA4
_0224DCB6:
ldr r2, _0224DD10 ; =0x0000213C
mov r1, #0
mvn r1, r1
eor r1, r0
ldr r3, [r5, r2]
asr r0, r0, #0x18
and r1, r3
str r1, [r5, r2]
bl LowestFlagNo
str r0, [r5, #0x74]
ldr r0, [sp, #4]
cmp r0, #1
bne _0224DCDE
add r0, r5, #0
mov r1, #1
mov r2, #6
bl ReadBattleScriptFromNarc
b _0224DCE8
_0224DCDE:
add r0, r5, #0
mov r1, #1
mov r2, #0x53
bl ReadBattleScriptFromNarc
_0224DCE8:
mov r0, #0x16
str r0, [r5, #8]
ldr r0, [sp]
mov r2, #0x28
str r0, [r5, #0xc]
ldr r0, [r5, #0x74]
add sp, #8
lsl r0, r0, #4
add r1, r5, r0
ldr r0, _0224DD14 ; =0x000021A8
str r2, [r1, r0]
mov r0, #1
pop {r3, r4, r5, r6, r7, pc}
_0224DD02:
str r6, [r5, #8]
add r0, r4, #0
add sp, #8
pop {r3, r4, r5, r6, r7, pc}
nop
_0224DD0C: .word 0x000021EC
_0224DD10: .word 0x0000213C
_0224DD14: .word 0x000021A8
thumb_func_end ov12_0224DC74
thumb_func_start ov12_0224DD18
ov12_0224DD18: ; 0x0224DD18
push {r3, r4, r5, lr}
add r5, r0, #0
mov r0, #0x85
lsl r0, r0, #6
add r4, r1, #0
ldr r1, [r5, r0]
mov r0, #0xf
lsl r0, r0, #0x1c
tst r0, r1
beq _0224DD6C
mov r0, #1
lsl r0, r0, #0x1c
add r2, r1, #0
tst r2, r0
bne _0224DD3E
_0224DD36:
lsl r0, r0, #1
add r2, r1, #0
tst r2, r0
beq _0224DD36
_0224DD3E:
mov r2, #0x85
lsl r2, r2, #6
mov r1, #0
mvn r1, r1
eor r1, r0
ldr r3, [r5, r2]
asr r0, r0, #0x1c
and r1, r3
str r1, [r5, r2]
bl LowestFlagNo
mov r2, #0x45
str r0, [r5, #0x74]
add r0, r5, #0
mov r1, #1
lsl r2, r2, #2
bl ReadBattleScriptFromNarc
mov r0, #0x16
str r0, [r5, #8]
str r4, [r5, #0xc]
mov r0, #1
pop {r3, r4, r5, pc}
_0224DD6C:
str r2, [r5, #8]
mov r0, #0
pop {r3, r4, r5, pc}
.balign 4, 0
thumb_func_end ov12_0224DD18
thumb_func_start ov12_0224DD74
ov12_0224DD74: ; 0x0224DD74
push {r4, r5, r6, lr}
add r5, r1, #0
ldr r1, [r5, #0x64]
add r0, r5, #0
bl GetBattlerAbility
cmp r0, #0x60
bne _0224DD88
mov r4, #0
b _0224DD9C
_0224DD88:
ldr r0, _0224DF54 ; =0x00002160
ldr r4, [r5, r0]
cmp r4, #0
bne _0224DD9C
ldr r0, _0224DF58 ; =0x00003044
ldr r0, [r5, r0]
lsl r0, r0, #4
add r1, r5, r0
ldr r0, _0224DF5C ; =0x000003E2
ldrb r4, [r1, r0]
_0224DD9C:
mov r0, #0xc1
lsl r0, r0, #6
ldr r2, [r5, r0]
mov r6, #0x10
lsl r1, r2, #4
add r3, r5, r1
ldr r1, _0224DF60 ; =0x000003E9
ldrb r1, [r3, r1]
tst r1, r6
beq _0224DDE6
ldr r3, _0224DF64 ; =0x0000213C
lsl r6, r6, #0x10
ldr r1, [r5, r3]
tst r1, r6
bne _0224DDE6
ldr r1, [r5, #0x6c]
cmp r1, #0xff
beq _0224DDE6
add r3, r3, #4
ldr r6, [r5, r3]
mov r3, #4
tst r3, r6
beq _0224DDE6
lsl r1, r1, #1
add r3, r5, r1
add r1, r0, #0
add r1, #0x44
strh r2, [r3, r1]
ldr r2, [r5, #0x6c]
ldr r1, [r5, r0]
lsl r2, r2, #3
add r3, r5, r2
ldr r2, [r5, #0x64]
add r0, #0x4c
lsl r2, r2, #1
add r2, r3, r2
strh r1, [r2, r0]
_0224DDE6:
ldr r1, [r5, #0x6c]
cmp r1, #0xff
beq _0224DE30
add r0, r5, #0
bl GetBattlerHeldItemEffect
ldr r1, _0224DF64 ; =0x0000213C
lsl r0, r0, #0x18
ldr r3, [r5, r1]
mov r2, #0x20
lsr r0, r0, #0x18
tst r2, r3
bne _0224DE0A
add r1, r1, #4
ldr r2, [r5, r1]
mov r1, #4
tst r1, r2
beq _0224DE24
_0224DE0A:
cmp r0, #0x37
beq _0224DE24
cmp r0, #0x73
beq _0224DE24
cmp r0, #0x7d
beq _0224DE24
ldr r1, [r5, #0x6c]
mov r0, #0xc0
mul r0, r1
add r1, r5, r0
ldr r0, _0224DF68 ; =0x00002DF8
mov r2, #0
strh r2, [r1, r0]
_0224DE24:
ldr r0, _0224DF64 ; =0x0000213C
mov r1, #1
ldr r2, [r5, r0]
lsl r1, r1, #0x14
tst r1, r2
beq _0224DE32
_0224DE30:
b _0224DF52
_0224DE32:
add r0, r0, #4
ldr r1, [r5, r0]
mov r0, #4
tst r0, r1
beq _0224DE70
ldr r1, [r5, #0x6c]
ldr r0, _0224DF58 ; =0x00003044
lsl r1, r1, #1
add r2, r5, r1
add r1, r0, #0
ldr r3, [r5, r0]
add r1, #0x20
strh r3, [r2, r1]
ldr r1, [r5, #0x6c]
ldr r3, [r5, #0x64]
lsl r1, r1, #1
add r2, r5, r1
add r1, r0, #0
add r1, #0x28
strh r3, [r2, r1]
ldr r1, [r5, #0x6c]
lsl r1, r1, #1
add r2, r5, r1
add r1, r0, #0
add r1, #0x30
strh r4, [r2, r1]
sub r1, r0, #4
ldr r1, [r5, r1]
add r0, r0, #4
str r1, [r5, r0]
b _0224DE9A
_0224DE70:
ldr r0, [r5, #0x6c]
ldr r3, _0224DF6C ; =0x00003064
lsl r0, r0, #1
mov r1, #0
add r0, r5, r0
strh r1, [r0, r3]
ldr r2, [r5, #0x6c]
mov r0, #0xff
lsl r2, r2, #1
add r6, r5, r2
add r2, r3, #0
add r2, #8
strh r0, [r6, r2]
ldr r0, [r5, #0x6c]
lsl r0, r0, #1
add r2, r5, r0
add r0, r3, #0
add r0, #0x10
strh r1, [r2, r0]
sub r3, #0x1c
str r1, [r5, r3]
_0224DE9A:
mov r0, #0x85
lsl r0, r0, #6
ldr r2, [r5, r0]
mov r1, #0x40
tst r1, r2
beq _0224DF2E
add r0, #0x2c
ldr r0, [r5, r0]
ldr r2, _0224DF70 ; =0x801FDA49
tst r0, r2
bne _0224DF2E
ldr r0, _0224DF58 ; =0x00003044
ldr r0, [r5, r0]
lsl r1, r0, #4
add r3, r5, r1
ldr r1, _0224DF74 ; =0x000003E6
ldrh r3, [r3, r1]
cmp r3, #0x40
bgt _0224DED0
bge _0224DEE4
cmp r3, #0x10
bgt _0224DECA
beq _0224DEE4
b _0224DF0A
_0224DECA:
cmp r3, #0x20
beq _0224DEE4
b _0224DF0A
_0224DED0:
lsr r1, r2, #0x17
cmp r3, r1
bgt _0224DEDE
bge _0224DEE4
cmp r3, #0x80
beq _0224DEE4
b _0224DF0A
_0224DEDE:
lsr r1, r2, #0x16
cmp r3, r1
bne _0224DF0A
_0224DEE4:
ldr r1, [r5, #0x6c]
ldr r2, _0224DF78 ; =0x000030C4
lsl r1, r1, #1
mov r0, #0
add r1, r5, r1
strh r0, [r1, r2]
ldr r1, [r5, #0x6c]
mov r4, #0xff
lsl r1, r1, #1
add r3, r5, r1
add r1, r2, #0
add r1, #8
strh r4, [r3, r1]
ldr r1, [r5, #0x6c]
add r2, #0x10
lsl r1, r1, #1
add r1, r5, r1
strh r0, [r1, r2]
pop {r4, r5, r6, pc}
_0224DF0A:
ldr r1, [r5, #0x6c]
lsl r1, r1, #1
add r2, r5, r1
ldr r1, _0224DF78 ; =0x000030C4
strh r0, [r2, r1]
ldr r0, [r5, #0x6c]
ldr r3, [r5, #0x64]
lsl r0, r0, #1
add r2, r5, r0
add r0, r1, #0
add r0, #8
strh r3, [r2, r0]
ldr r0, [r5, #0x6c]
add r1, #0x10
lsl r0, r0, #1
add r0, r5, r0
strh r4, [r0, r1]
pop {r4, r5, r6, pc}
_0224DF2E:
ldr r1, [r5, #0x6c]
ldr r2, _0224DF78 ; =0x000030C4
lsl r1, r1, #1
mov r0, #0
add r1, r5, r1
strh r0, [r1, r2]
ldr r1, [r5, #0x6c]
mov r4, #0xff
lsl r1, r1, #1
add r3, r5, r1
add r1, r2, #0
add r1, #8
strh r4, [r3, r1]
ldr r1, [r5, #0x6c]
add r2, #0x10
lsl r1, r1, #1
add r1, r5, r1
strh r0, [r1, r2]
_0224DF52:
pop {r4, r5, r6, pc}
.balign 4, 0
_0224DF54: .word 0x00002160
_0224DF58: .word 0x00003044
_0224DF5C: .word 0x000003E2
_0224DF60: .word 0x000003E9
_0224DF64: .word 0x0000213C
_0224DF68: .word 0x00002DF8
_0224DF6C: .word 0x00003064
_0224DF70: .word 0x801FDA49
_0224DF74: .word 0x000003E6
_0224DF78: .word 0x000030C4
thumb_func_end ov12_0224DD74
thumb_func_start ov12_0224DF7C
ov12_0224DF7C: ; 0x0224DF7C
push {r4, lr}
add r4, r1, #0
add r0, r4, #0
mov r1, #1
mov r2, #0x10
bl ReadBattleScriptFromNarc
ldr r0, [r4, #8]
str r0, [r4, #0xc]
mov r0, #0x16
str r0, [r4, #8]
mov r0, #1
pop {r4, pc}
.balign 4, 0
thumb_func_end ov12_0224DF7C
thumb_func_start ov12_0224DF98
ov12_0224DF98: ; 0x0224DF98
push {r3, r4, r5, lr}
ldr r2, _0224DFE8 ; =0x0000216C
add r5, r1, #0
ldr r0, [r5, r2]
mov r4, #0
cmp r0, #0
beq _0224DFCC
add r1, r2, #0
add r1, #0x11
ldrb r1, [r5, r1]
cmp r1, #0
beq _0224DFCA
ldr r1, [r5, #0x74]
cmp r1, #0xff
bne _0224DFC6
add r2, #0x10
ldrb r1, [r5, r2]
cmp r1, #1
beq _0224DFC6
mov r1, #1
lsl r1, r1, #0xe
tst r0, r1
beq _0224DFCC
_0224DFC6:
mov r4, #1
b _0224DFCC
_0224DFCA:
mov r4, #1
_0224DFCC:
cmp r4, #1
bne _0224DFE2
add r0, r5, #0
mov r1, #1
mov r2, #0x15
bl ReadBattleScriptFromNarc
ldr r0, [r5, #8]
str r0, [r5, #0xc]
mov r0, #0x16
str r0, [r5, #8]
_0224DFE2:
add r0, r4, #0
pop {r3, r4, r5, pc}
nop
_0224DFE8: .word 0x0000216C
thumb_func_end ov12_0224DF98
thumb_func_start ov12_0224DFEC
ov12_0224DFEC: ; 0x0224DFEC
push {r3, r4, r5, r6, r7, lr}
add r4, r1, #0
ldr r2, [r4, #0x6c]
mov r3, #0
cmp r2, #0xff
bne _0224DFFC
add r0, r3, #0
pop {r3, r4, r5, r6, r7, pc}
_0224DFFC:
mov r0, #0xc0
add r5, r2, #0
mul r5, r0
mov r1, #2
ldr r0, _0224E06C ; =0x00002DB0
add r7, r4, r5
ldr r6, [r7, r0]
lsl r1, r1, #0x16
tst r1, r6
beq _0224E066
ldr r1, _0224E070 ; =0x0000216C
mov r6, #2
lsl r6, r6, #0x16
ldr r1, [r4, r1]
lsr r6, r6, #9
tst r1, r6
bne _0224E066
ldr r1, [r4, #0x64]
cmp r2, r1
beq _0224E066
sub r0, #0x24
ldr r0, [r7, r0]
cmp r0, #0
beq _0224E066
mov r0, #0x1c
mul r0, r2
add r2, r4, r0
mov r0, #0xb6
lsl r0, r0, #2
ldr r1, [r2, r0]
cmp r1, #0
bne _0224E044
add r0, #8
ldr r0, [r2, r0]
cmp r0, #0
beq _0224E066
_0224E044:
ldr r0, _0224E074 ; =0x00002D59
add r1, r4, r0
ldrsb r0, [r1, r5]
cmp r0, #0xc
bge _0224E066
add r0, r0, #1
strb r0, [r1, r5]
add r0, r4, #0
mov r1, #1
mov r2, #0xf5
bl ReadBattleScriptFromNarc
ldr r0, [r4, #8]
mov r3, #1
str r0, [r4, #0xc]
mov r0, #0x16
str r0, [r4, #8]
_0224E066:
add r0, r3, #0
pop {r3, r4, r5, r6, r7, pc}
nop
_0224E06C: .word 0x00002DB0
_0224E070: .word 0x0000216C
_0224E074: .word 0x00002D59
thumb_func_end ov12_0224DFEC
thumb_func_start ov12_0224E078
ov12_0224E078: ; 0x0224E078
push {r3, r4, r5, r6, r7, lr}
add r5, r1, #0
ldr r1, [r5, #0x64]
str r0, [sp]
add r0, r5, #0
mov r4, #0
bl GetBattlerHeldItemEffect
add r7, r0, #0
ldr r1, [r5, #0x64]
add r0, r5, #0
add r2, r4, #0
bl GetHeldItemModifier
add r6, r0, #0
ldr r0, [r5, #0x6c]
cmp r0, #0xff
beq _0224E116
cmp r7, #0x38
bne _0224E116
ldr r1, _0224E11C ; =0x0000216C
ldr r2, [r5, r1]
ldr r1, _0224E120 ; =0x801FDA49
tst r1, r2
bne _0224E116
mov r1, #0x1c
mul r1, r0
mov r0, #0xb6
add r2, r5, r1
lsl r0, r0, #2
ldr r1, [r2, r0]
cmp r1, #0
bne _0224E0C2
add r0, #8
ldr r0, [r2, r0]
cmp r0, #0
beq _0224E116
_0224E0C2:
ldr r0, [sp]
bl BattleSystem_Random
mov r1, #0x64
bl _s32_div_f
cmp r1, r6
bge _0224E116
ldr r0, _0224E124 ; =0x00003044
ldr r0, [r5, r0]
lsl r0, r0, #4
add r1, r5, r0
ldr r0, _0224E128 ; =0x000003E9
ldrb r1, [r1, r0]
mov r0, #0x20
tst r0, r1
beq _0224E116
ldr r0, [r5, #0x6c]
mov r1, #0xc0
mul r1, r0
add r2, r5, r1
ldr r1, _0224E12C ; =0x00002D8C
ldr r1, [r2, r1]
cmp r1, #0
beq _0224E116
add r1, r5, #0
add r1, #0x94
str r0, [r1]
add r0, r5, #0
mov r1, #2
add r0, #0x88
str r1, [r0]
add r0, r5, #0
mov r1, #1
mov r2, #0xe
bl ReadBattleScriptFromNarc
ldr r0, [r5, #8]
mov r4, #1
str r0, [r5, #0xc]
mov r0, #0x16
str r0, [r5, #8]
_0224E116:
add r0, r4, #0
pop {r3, r4, r5, r6, r7, pc}
nop
_0224E11C: .word 0x0000216C
_0224E120: .word 0x801FDA49
_0224E124: .word 0x00003044
_0224E128: .word 0x000003E9
_0224E12C: .word 0x00002D8C
thumb_func_end ov12_0224E078
thumb_func_start ov12_0224E130
ov12_0224E130: ; 0x0224E130
push {r3, r4, r5, r6, r7, lr}
add r5, r1, #0
ldr r7, [r5, #0x5c]
str r0, [sp]
mov r6, #0
bl BattleSystem_GetMaxBattlers
cmp r7, r0
bge _0224E1A0
add r4, r5, #0
add r4, #0x5c
_0224E146:
mov r0, #0xc0
mul r0, r7
mov r1, #0xb7
add r0, r5, r0
lsl r1, r1, #6
ldr r2, [r0, r1]
ldr r1, _0224E1AC ; =0x200400C0
tst r1, r2
bne _0224E18A
ldr r1, _0224E1B0 ; =0x00002DC4
ldr r2, [r0, r1]
ldr r1, _0224E1AC ; =0x200400C0
tst r1, r2
beq _0224E18A
ldr r1, _0224E1B0 ; =0x00002DC4
ldr r2, [r0, r1]
ldr r1, _0224E1B4 ; =0xDFFBFF3F
and r2, r1
ldr r1, _0224E1B0 ; =0x00002DC4
str r2, [r0, r1]
ldr r2, _0224E1B8 ; =0x0000011F
add r0, r5, #0
mov r1, #1
bl ReadBattleScriptFromNarc
mov r0, #0x46
ldr r1, [r5, #0x5c]
lsl r0, r0, #2
str r1, [r5, r0]
ldr r0, [r5, #8]
mov r6, #1
str r0, [r5, #0xc]
mov r0, #0x16
str r0, [r5, #8]
_0224E18A:
ldr r0, [r4]
add r0, r0, #1
str r0, [r4]
cmp r6, #1
beq _0224E1A0
ldr r0, [sp]
ldr r7, [r5, #0x5c]
bl BattleSystem_GetMaxBattlers
cmp r7, r0
blt _0224E146
_0224E1A0:
cmp r6, #0
bne _0224E1A8
mov r0, #0
str r0, [r5, #0x5c]
_0224E1A8:
add r0, r6, #0
pop {r3, r4, r5, r6, r7, pc}
.balign 4, 0
_0224E1AC: .word 0x200400C0
_0224E1B0: .word 0x00002DC4
_0224E1B4: .word 0xDFFBFF3F
_0224E1B8: .word 0x0000011F
thumb_func_end ov12_0224E130
thumb_func_start ov12_0224E1BC
ov12_0224E1BC: ; 0x0224E1BC
push {r3, r4, r5, r6, r7, lr}
sub sp, #8
add r4, r1, #0
mov r6, #0
bl BattleSystem_GetMaxBattlers
ldr r1, [r4, #0x64]
add r0, r4, #0
bl GetBattlerHeldItemEffect
str r0, [sp, #4]
ldr r1, [r4, #0x64]
add r0, r4, #0
add r2, r6, #0
bl GetHeldItemModifier
ldr r1, [r4, #8]
str r0, [sp]
add r0, r4, #0
add r2, r1, #0
mov r3, #1
bl ov12_0224DC74
cmp r0, #1
bne _0224E1F4
add sp, #8
mov r0, #1
pop {r3, r4, r5, r6, r7, pc}
_0224E1F4:
add r5, r4, #0
add r5, #0x30
_0224E1F8:
ldr r0, [r4, #0x30]
cmp r0, #3
bls _0224E200
b _0224E350
_0224E200:
add r0, r0, r0
add r0, pc
ldrh r0, [r0, #6]
lsl r0, r0, #0x10
asr r0, r0, #0x10
add pc, r0
_0224E20C: ; jump table
.short _0224E214 - _0224E20C - 2 ; case 0
.short _0224E244 - _0224E20C - 2 ; case 1
.short _0224E2C4 - _0224E20C - 2 ; case 2
.short _0224E348 - _0224E20C - 2 ; case 3
_0224E214:
ldr r1, [r4, #0x64]
mov r0, #0xc0
mul r0, r1
ldr r1, _0224E368 ; =0x00002DB0
add r0, r4, r0
ldr r2, [r0, r1]
mov r1, #2
lsl r1, r1, #0x16
tst r1, r2
beq _0224E23C
ldr r1, _0224E36C ; =0x00003044
ldr r1, [r4, r1]
cmp r1, #0x63
beq _0224E23C
ldr r1, _0224E368 ; =0x00002DB0
ldr r2, [r0, r1]
ldr r1, _0224E370 ; =0xFF7FFFFF
and r2, r1
ldr r1, _0224E368 ; =0x00002DB0
str r2, [r0, r1]
_0224E23C:
ldr r0, [r5]
add r0, r0, #1
str r0, [r5]
b _0224E350
_0224E244:
ldr r3, [r4, #0x6c]
cmp r3, #0xff
beq _0224E2BC
ldr r0, [sp, #4]
cmp r0, #0x58
bne _0224E2BC
mov r0, #0x85
lsl r0, r0, #6
ldr r1, [r4, r0]
mov r0, #0x10
tst r0, r1
bne _0224E2BC
ldr r0, _0224E374 ; =0x0000213C
ldr r1, [r4, r0]
mov r0, #2
lsl r0, r0, #0xc
tst r0, r1
beq _0224E2BC
ldr r2, [r4, #0x64]
mov r0, #0x1c
mul r0, r2
add r1, r4, r0
mov r0, #0xbb
lsl r0, r0, #2
ldr r7, [r1, r0]
cmp r7, #0
beq _0224E2BC
cmp r2, r3
beq _0224E2BC
mov r0, #0xc0
mul r0, r2
add r2, r4, r0
ldr r0, _0224E378 ; =0x00002D8C
ldr r1, [r2, r0]
add r0, r0, #4
ldr r0, [r2, r0]
cmp r1, r0
bhs _0224E2BC
cmp r1, #0
beq _0224E2BC
ldr r1, [sp]
neg r0, r7
bl DamageDivide
ldr r1, _0224E37C ; =0x0000215C
mov r2, #0xd5
str r0, [r4, r1]
mov r0, #0x46
ldr r1, [r4, #0x64]
lsl r0, r0, #2
str r1, [r4, r0]
add r0, r4, #0
mov r1, #1
bl ReadBattleScriptFromNarc
ldr r0, [r4, #8]
mov r6, #1
str r0, [r4, #0xc]
mov r0, #0x16
str r0, [r4, #8]
_0224E2BC:
ldr r0, [r5]
add r0, r0, #1
str r0, [r5]
b _0224E350
_0224E2C4:
ldr r0, [sp, #4]
cmp r0, #0x62
bne _0224E340
ldr r1, [r4, #0x64]
add r0, r4, #0
bl GetBattlerAbility
cmp r0, #0x62
beq _0224E340
mov r0, #0x85
lsl r0, r0, #6
ldr r1, [r4, r0]
mov r0, #0x10
tst r0, r1
bne _0224E340
ldr r0, _0224E374 ; =0x0000213C
ldr r1, [r4, r0]
mov r0, #2
lsl r0, r0, #0xc
tst r0, r1
beq _0224E340
ldr r0, _0224E36C ; =0x00003044
ldr r0, [r4, r0]
lsl r0, r0, #4
add r1, r4, r0
mov r0, #0x3e
lsl r0, r0, #4
ldrb r0, [r1, r0]
cmp r0, #2
beq _0224E340
ldr r1, [r4, #0x64]
mov r0, #0xc0
mul r0, r1
ldr r1, _0224E378 ; =0x00002D8C
add r0, r4, r0
ldr r1, [r0, r1]
cmp r1, #0
beq _0224E340
ldr r1, _0224E380 ; =0x00002D90
ldr r1, [r0, r1]
mov r0, #0
mvn r0, r0
mul r0, r1
mov r1, #0xa
bl DamageDivide
ldr r1, _0224E37C ; =0x0000215C
mov r2, #0xd6
str r0, [r4, r1]
mov r0, #0x46
ldr r1, [r4, #0x64]
lsl r0, r0, #2
str r1, [r4, r0]
add r0, r4, #0
mov r1, #1
bl ReadBattleScriptFromNarc
ldr r0, [r4, #8]
mov r6, #1
str r0, [r4, #0xc]
mov r0, #0x16
str r0, [r4, #8]
_0224E340:
ldr r0, [r5]
add r0, r0, #1
str r0, [r5]
b _0224E350
_0224E348:
mov r0, #0
str r0, [r4, #0x30]
str r0, [r4, #0x34]
mov r6, #2
_0224E350:
cmp r6, #0
bne _0224E356
b _0224E1F8
_0224E356:
cmp r6, #1
bne _0224E360
add sp, #8
mov r0, #1
pop {r3, r4, r5, r6, r7, pc}
_0224E360:
mov r0, #0
add sp, #8
pop {r3, r4, r5, r6, r7, pc}
nop
_0224E368: .word 0x00002DB0
_0224E36C: .word 0x00003044
_0224E370: .word 0xFF7FFFFF
_0224E374: .word 0x0000213C
_0224E378: .word 0x00002D8C
_0224E37C: .word 0x0000215C
_0224E380: .word 0x00002D90
thumb_func_end ov12_0224E1BC
thumb_func_start ov12_0224E384
ov12_0224E384: ; 0x0224E384
push {r3, r4, r5, r6, r7, lr}
sub sp, #8
str r1, [sp, #4]
str r0, [sp]
bl BattleSystem_GetBattleType
mov r2, #0xd5
add r4, r0, #0
ldr r1, [sp, #4]
lsl r2, r2, #2
add r1, r1, r2
ldr r2, _0224E404 ; =0x00001DE0
mov r0, #0
bl MIi_CpuClear32
mov r0, #1
tst r0, r4
beq _0224E3F8
mov r0, #0xb9
lsl r0, r0, #2
tst r0, r4
bne _0224E3F8
mov r6, #0
_0224E3B2:
mov r0, #1
tst r0, r6
beq _0224E3F2
asr r2, r6, #1
ldr r0, [sp, #4]
lsl r1, r2, #3
mov r4, #0
add r7, r0, r1
add r5, r0, r2
_0224E3C4:
ldr r0, [sp]
add r1, r6, #0
add r2, r4, #0
bl BattleSystem_GetTrainerItem
cmp r0, #0
beq _0224E3EC
ldr r1, _0224E408 ; =0x000003CD
ldrb r1, [r5, r1]
lsl r1, r1, #1
add r2, r7, r1
mov r1, #0xe7
lsl r1, r1, #2
strh r0, [r2, r1]
add r0, r1, #0
add r0, #0x31
ldrb r0, [r5, r0]
add r1, r0, #1
ldr r0, _0224E408 ; =0x000003CD
strb r1, [r5, r0]
_0224E3EC:
add r4, r4, #1
cmp r4, #4
blt _0224E3C4
_0224E3F2:
add r6, r6, #1
cmp r6, #4
blt _0224E3B2
_0224E3F8:
ldr r2, _0224E40C ; =ov10_02220AAC
ldr r1, _0224E410 ; =0x00002134
ldr r0, [sp, #4]
str r2, [r0, r1]
add sp, #8
pop {r3, r4, r5, r6, r7, pc}
.balign 4, 0
_0224E404: .word 0x00001DE0
_0224E408: .word 0x000003CD
_0224E40C: .word ov10_02220AAC
_0224E410: .word 0x00002134
thumb_func_end ov12_0224E384
thumb_func_start ov12_0224E414
ov12_0224E414: ; 0x0224E414
push {r3, r4, r5, r6, r7, lr}
sub sp, #8
add r6, r0, #0
str r1, [sp]
bl BattleSystem_GetMaxBattlers
mov r4, #0
str r0, [sp, #4]
cmp r0, #0
ble _0224E4E8
ldr r5, [sp]
_0224E42A:
ldr r0, _0224E4EC ; =0x000021A8
ldr r2, [r5, r0]
cmp r2, #0x28
beq _0224E4DE
ldr r0, [sp]
add r7, r0, r4
ldr r0, _0224E4F0 ; =0x0000314C
ldrb r1, [r7, r0]
mov r0, #1
tst r0, r1
beq _0224E44E
sub r2, #0xc
lsl r2, r2, #0x18
add r0, r6, #0
add r1, r4, #0
lsr r2, r2, #0x18
bl ov12_0223BDDC
_0224E44E:
ldr r0, _0224E4EC ; =0x000021A8
ldr r0, [r5, r0]
sub r0, #0xd
cmp r0, #3
bhi _0224E4DE
add r0, r0, r0
add r0, pc
ldrh r0, [r0, #6]
lsl r0, r0, #0x10
asr r0, r0, #0x10
add pc, r0
_0224E464: ; jump table
.short _0224E46C - _0224E464 - 2 ; case 0
.short _0224E4A4 - _0224E464 - 2 ; case 1
.short _0224E4C0 - _0224E464 - 2 ; case 2
.short _0224E4D4 - _0224E464 - 2 ; case 3
_0224E46C:
ldr r0, _0224E4F0 ; =0x0000314C
ldrb r1, [r7, r0]
mov r0, #2
tst r0, r1
beq _0224E486
ldr r2, _0224E4F4 ; =0x000021B0
add r0, r6, #0
ldr r2, [r5, r2]
add r1, r4, #0
lsl r2, r2, #0x18
lsr r2, r2, #0x18
bl ov12_0223BDDC
_0224E486:
ldr r0, _0224E4F0 ; =0x0000314C
ldrb r1, [r7, r0]
mov r0, #4
tst r0, r1
beq _0224E4DE
ldr r2, _0224E4F8 ; =0x000021AC
add r0, r6, #0
ldr r2, [r5, r2]
add r1, r4, #0
add r2, r2, #1
lsl r2, r2, #0x18
lsr r2, r2, #0x18
bl ov12_0223BDDC
b _0224E4DE
_0224E4A4:
ldr r2, _0224E4F4 ; =0x000021B0
add r0, r6, #0
ldr r2, [r5, r2]
add r1, r4, #0
lsl r2, r2, #0x18
lsr r2, r2, #0x18
bl ov12_0223BDDC
add r0, r6, #0
add r1, r4, #0
mov r2, #0
bl ov12_0223BDDC
b _0224E4DE
_0224E4C0:
ldr r2, _0224E4F4 ; =0x000021B0
add r0, r6, #0
ldr r2, [r5, r2]
add r1, r4, #0
add r2, r2, #1
lsl r2, r2, #0x18
lsr r2, r2, #0x18
bl ov12_0223BDDC
b _0224E4DE
_0224E4D4:
add r0, r6, #0
add r1, r4, #0
mov r2, #1
bl ov12_0223BDDC
_0224E4DE:
ldr r0, [sp, #4]
add r4, r4, #1
add r5, #0x10
cmp r4, r0
blt _0224E42A
_0224E4E8:
add sp, #8
pop {r3, r4, r5, r6, r7, pc}
.balign 4, 0
_0224E4EC: .word 0x000021A8
_0224E4F0: .word 0x0000314C
_0224E4F4: .word 0x000021B0
_0224E4F8: .word 0x000021AC
thumb_func_end ov12_0224E414
.rodata
.public sHitChanceTable
sHitChanceTable: ; 0x0226CA74
.byte 0x21
; also part of the hit chance table
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 BattleControllerPlayer_StartEncounter
.word BattleControllerPlayer_TrainerMessage
.word BattleControllerPlayer_PokemonAppear
.word BattleControllerPlayer_SelectionScreenInit
.word BattleControllerPlayer_SelectionScreenInput
.word ov12_02249190
.word ov12_0224930C
.word ov12_02249460
.word BattleControllerPlayer_UpdateFieldCondition
.word BattleControllerPlayer_UpdateMonCondition
.word BattleControllerPlayer_UpdateFieldConditionExtra
.word BattleControllerPlayer_TurnEnd
.word BattleControllerPlayer_FightInput
.word BattleControllerPlayer_ItemInput
.word BattleControllerPlayer_PokemonInput
.word BattleControllerPlayer_RunInput
.word BattleControllerPlayer_SafariThrowBall
.word BattleControllerPlayer_SafariThrowMud
.word BattleControllerPlayer_SafariRun
.word BattleControllerPlayer_SafariWatching
.word BattleControllerPlayer_CatchingContestThrowBall
.word BattleControllerPlayer_RunScript
.word ov12_0224C38C
.word ov12_0224C4D8
.word ov12_0224C5C8
.word ov12_0224C5F8
.word ov12_0224C678
.word ov12_0224C690
.word ov12_0224CAA4
.word ov12_0224CC84
.word ov12_0224CC88
.word ov12_0224CF14
.word ov12_0224CF10
.word ov12_0224D014
.word ov12_0224D03C
.word ov12_0224D1DC
.word ov12_0224D224
.word ov12_0224D238
.word ov12_0224D23C
.word ov12_0224D368
.word ov12_0224D448
.word ov12_0224D464
.word ov12_0224D4F0
.word ov12_0224D504
.word ov12_0224D53C