more renaming

This commit is contained in:
camthesaxman 2018-02-06 13:48:02 -06:00
parent f78fa6aabf
commit 6a4967689e
51 changed files with 5105 additions and 5108 deletions

View File

@ -5,8 +5,8 @@
.text .text
thumb_func_start GetBankCoord thumb_func_start GetBattlerSpriteCoord
GetBankCoord: @ 80A5C6C GetBattlerSpriteCoord: @ 80A5C6C
push {r4,r5,lr} push {r4,r5,lr}
lsls r0, 24 lsls r0, 24
lsrs r5, r0, 24 lsrs r5, r0, 24
@ -102,7 +102,7 @@ _080A5D28:
ldrh r0, [r1, 0x2] ldrh r0, [r1, 0x2]
cmp r0, 0 cmp r0, 0
bne _080A5D98 bne _080A5D98
ldr r1, =gBattlePartyID ldr r1, =gBattlerPartyIndexes
lsls r0, r5, 1 lsls r0, r5, 1
adds r0, r1 adds r0, r1
ldrh r1, [r0] ldrh r1, [r0]
@ -120,7 +120,7 @@ _080A5D60:
ldrh r0, [r1, 0x2] ldrh r0, [r1, 0x2]
cmp r0, 0 cmp r0, 0
bne _080A5D98 bne _080A5D98
ldr r1, =gBattlePartyID ldr r1, =gBattlerPartyIndexes
lsls r0, r5, 1 lsls r0, r5, 1
adds r0, r1 adds r0, r1
ldrh r1, [r0] ldrh r1, [r0]
@ -154,7 +154,7 @@ _080A5DB0:
pop {r4,r5} pop {r4,r5}
pop {r1} pop {r1}
bx r1 bx r1
thumb_func_end GetBankCoord thumb_func_end GetBattlerSpriteCoord
thumb_func_start sub_80A5DB8 thumb_func_start sub_80A5DB8
sub_80A5DB8: @ 80A5DB8 sub_80A5DB8: @ 80A5DB8
@ -203,7 +203,7 @@ _080A5E04:
ldrh r0, [r0, 0x2] ldrh r0, [r0, 0x2]
cmp r0, 0 cmp r0, 0
bne _080A5E3C bne _080A5E3C
ldr r1, =gBattlePartyID ldr r1, =gBattlerPartyIndexes
lsls r0, r4, 1 lsls r0, r4, 1
adds r0, r1 adds r0, r1
ldrh r1, [r0] ldrh r1, [r0]
@ -293,7 +293,7 @@ _080A5EC8:
ldrh r0, [r0, 0x2] ldrh r0, [r0, 0x2]
cmp r0, 0 cmp r0, 0
bne _080A5F04 bne _080A5F04
ldr r1, =gBattlePartyID ldr r1, =gBattlerPartyIndexes
lsls r0, r4, 1 lsls r0, r4, 1
adds r0, r1 adds r0, r1
ldrh r1, [r0] ldrh r1, [r0]
@ -577,7 +577,7 @@ _080A611C:
_080A6126: _080A6126:
adds r0, r4, 0 adds r0, r4, 0
adds r1, r5, 0 adds r1, r5, 0
bl GetBankCoord bl GetBattlerSpriteCoord
_080A612E: _080A612E:
lsls r0, 24 lsls r0, 24
lsrs r0, 24 lsrs r0, 24
@ -586,18 +586,18 @@ _080A612E:
bx r1 bx r1
thumb_func_end sub_80A60AC thumb_func_end sub_80A60AC
thumb_func_start GetBankSpriteDefault_Y thumb_func_start GetBattlerSpriteDefault_Y
GetBankSpriteDefault_Y: @ 80A6138 GetBattlerSpriteDefault_Y: @ 80A6138
push {lr} push {lr}
lsls r0, 24 lsls r0, 24
lsrs r0, 24 lsrs r0, 24
movs r1, 0x4 movs r1, 0x4
bl GetBankCoord bl GetBattlerSpriteCoord
lsls r0, 24 lsls r0, 24
lsrs r0, 24 lsrs r0, 24
pop {r1} pop {r1}
bx r1 bx r1
thumb_func_end GetBankSpriteDefault_Y thumb_func_end GetBattlerSpriteDefault_Y
thumb_func_start GetSubstituteSpriteDefault_Y thumb_func_start GetSubstituteSpriteDefault_Y
GetSubstituteSpriteDefault_Y: @ 80A614C GetSubstituteSpriteDefault_Y: @ 80A614C
@ -611,7 +611,7 @@ GetSubstituteSpriteDefault_Y: @ 80A614C
beq _080A6170 beq _080A6170
adds r0, r4, 0 adds r0, r4, 0
movs r1, 0x1 movs r1, 0x1
bl GetBankCoord bl GetBattlerSpriteCoord
lsls r0, 24 lsls r0, 24
lsrs r0, 8 lsrs r0, 8
movs r1, 0x80 movs r1, 0x80
@ -620,7 +620,7 @@ GetSubstituteSpriteDefault_Y: @ 80A614C
_080A6170: _080A6170:
adds r0, r4, 0 adds r0, r4, 0
movs r1, 0x1 movs r1, 0x1
bl GetBankCoord bl GetBattlerSpriteCoord
lsls r0, 24 lsls r0, 24
lsrs r0, 8 lsrs r0, 8
movs r1, 0x88 movs r1, 0x88
@ -642,7 +642,7 @@ sub_80A6190: @ 80A6190
lsrs r5, r0, 24 lsrs r5, r0, 24
adds r0, r5, 0 adds r0, r5, 0
movs r1, 0x1 movs r1, 0x1
bl GetBankCoord bl GetBattlerSpriteCoord
lsls r0, 24 lsls r0, 24
lsrs r6, r0, 24 lsrs r6, r0, 24
bl IsContest bl IsContest
@ -662,7 +662,7 @@ sub_80A6190: @ 80A6190
ldrh r0, [r1, 0x2] ldrh r0, [r1, 0x2]
cmp r0, 0 cmp r0, 0
bne _080A621C bne _080A621C
ldr r1, =gBattlePartyID ldr r1, =gBattlerPartyIndexes
lsls r0, r5, 1 lsls r0, r5, 1
adds r0, r1 adds r0, r1
ldrh r1, [r0] ldrh r1, [r0]
@ -680,7 +680,7 @@ _080A61E4:
ldrh r0, [r1, 0x2] ldrh r0, [r1, 0x2]
cmp r0, 0 cmp r0, 0
bne _080A621C bne _080A621C
ldr r1, =gBattlePartyID ldr r1, =gBattlerPartyIndexes
lsls r0, r5, 1 lsls r0, r5, 1
adds r0, r1 adds r0, r1
ldrh r1, [r0] ldrh r1, [r0]
@ -716,56 +716,56 @@ _080A6238:
bx r1 bx r1
thumb_func_end sub_80A6190 thumb_func_end sub_80A6190
thumb_func_start GetAnimBankSpriteId thumb_func_start GetBattlerSpriteId
GetAnimBankSpriteId: @ 80A6240 GetBattlerSpriteId: @ 80A6240
push {r4,r5,lr} push {r4,r5,lr}
lsls r0, 24 lsls r0, 24
lsrs r0, 24 lsrs r0, 24
adds r1, r0, 0 adds r1, r0, 0
cmp r0, 0 cmp r0, 0
bne _080A6268 bne _080A6268
ldr r4, =gAnimBankAttacker ldr r4, =gBattleAnimAttacker
ldrb r0, [r4] ldrb r0, [r4]
bl IsBankSpritePresent bl IsBattlerSpritePresent
lsls r0, 24 lsls r0, 24
cmp r0, 0 cmp r0, 0
beq _080A62B6 beq _080A62B6
ldr r1, =gBankSpriteIds ldr r1, =gBattlerSpriteIds
ldrb r0, [r4] ldrb r0, [r4]
b _080A62C6 b _080A62C6
.pool .pool
_080A6268: _080A6268:
cmp r0, 0x1 cmp r0, 0x1
bne _080A6288 bne _080A6288
ldr r4, =gAnimBankTarget ldr r4, =gBattleAnimTarget
ldrb r0, [r4] ldrb r0, [r4]
bl IsBankSpritePresent bl IsBattlerSpritePresent
lsls r0, 24 lsls r0, 24
cmp r0, 0 cmp r0, 0
beq _080A62B6 beq _080A62B6
ldr r1, =gBankSpriteIds ldr r1, =gBattlerSpriteIds
ldrb r0, [r4] ldrb r0, [r4]
b _080A62C6 b _080A62C6
.pool .pool
_080A6288: _080A6288:
cmp r1, 0x2 cmp r1, 0x2
bne _080A62A4 bne _080A62A4
ldr r5, =gAnimBankAttacker ldr r5, =gBattleAnimAttacker
ldrb r0, [r5] ldrb r0, [r5]
movs r4, 0x2 movs r4, 0x2
eors r0, r4 eors r0, r4
bl IsAnimBankSpriteVisible bl IsBattlerSpriteVisible
lsls r0, 24 lsls r0, 24
cmp r0, 0 cmp r0, 0
beq _080A62B6 beq _080A62B6
b _080A62C0 b _080A62C0
.pool .pool
_080A62A4: _080A62A4:
ldr r5, =gAnimBankTarget ldr r5, =gBattleAnimTarget
ldrb r0, [r5] ldrb r0, [r5]
movs r4, 0x2 movs r4, 0x2
eors r0, r4 eors r0, r4
bl IsAnimBankSpriteVisible bl IsBattlerSpriteVisible
lsls r0, 24 lsls r0, 24
cmp r0, 0 cmp r0, 0
bne _080A62C0 bne _080A62C0
@ -774,7 +774,7 @@ _080A62B6:
b _080A62CA b _080A62CA
.pool .pool
_080A62C0: _080A62C0:
ldr r1, =gBankSpriteIds ldr r1, =gBattlerSpriteIds
ldrb r0, [r5] ldrb r0, [r5]
eors r0, r4 eors r0, r4
_080A62C6: _080A62C6:
@ -785,7 +785,7 @@ _080A62CA:
pop {r1} pop {r1}
bx r1 bx r1
.pool .pool
thumb_func_end GetAnimBankSpriteId thumb_func_end GetBattlerSpriteId
thumb_func_start StoreSpriteCallbackInData6 thumb_func_start StoreSpriteCallbackInData6
StoreSpriteCallbackInData6: @ 80A62D4 StoreSpriteCallbackInData6: @ 80A62D4
@ -1242,16 +1242,16 @@ sub_80A65EC: @ 80A65EC
ldrh r1, [r4, 0x22] ldrh r1, [r4, 0x22]
adds r0, r1 adds r0, r1
strh r0, [r4, 0x34] strh r0, [r4, 0x34]
ldr r5, =gAnimBankTarget ldr r5, =gBattleAnimTarget
ldrb r0, [r5] ldrb r0, [r5]
movs r1, 0x2 movs r1, 0x2
bl GetBankCoord bl GetBattlerSpriteCoord
lsls r0, 24 lsls r0, 24
lsrs r0, 24 lsrs r0, 24
strh r0, [r4, 0x32] strh r0, [r4, 0x32]
ldrb r0, [r5] ldrb r0, [r5]
movs r1, 0x3 movs r1, 0x3
bl GetBankCoord bl GetBattlerSpriteCoord
lsls r0, 24 lsls r0, 24
lsrs r0, 24 lsrs r0, 24
strh r0, [r4, 0x36] strh r0, [r4, 0x36]
@ -1439,16 +1439,16 @@ sub_80A6760: @ 80A6760
ldrh r1, [r4, 0x22] ldrh r1, [r4, 0x22]
adds r0, r1 adds r0, r1
strh r0, [r4, 0x34] strh r0, [r4, 0x34]
ldr r5, =gAnimBankAttacker ldr r5, =gBattleAnimAttacker
ldrb r0, [r5] ldrb r0, [r5]
movs r1, 0x2 movs r1, 0x2
bl GetBankCoord bl GetBattlerSpriteCoord
lsls r0, 24 lsls r0, 24
lsrs r0, 24 lsrs r0, 24
strh r0, [r4, 0x32] strh r0, [r4, 0x32]
ldrb r0, [r5] ldrb r0, [r5]
movs r1, 0x3 movs r1, 0x3
bl GetBankCoord bl GetBattlerSpriteCoord
lsls r0, 24 lsls r0, 24
lsrs r0, 24 lsrs r0, 24
strh r0, [r4, 0x36] strh r0, [r4, 0x36]
@ -1547,16 +1547,16 @@ sub_80A6814: @ 80A6814
sub_80A6838: @ 80A6838 sub_80A6838: @ 80A6838
push {r4,r5,lr} push {r4,r5,lr}
adds r5, r0, 0 adds r5, r0, 0
ldr r4, =gAnimBankAttacker ldr r4, =gBattleAnimAttacker
ldrb r0, [r4] ldrb r0, [r4]
movs r1, 0x2 movs r1, 0x2
bl GetBankCoord bl GetBattlerSpriteCoord
lsls r0, 24 lsls r0, 24
lsrs r0, 24 lsrs r0, 24
strh r0, [r5, 0x20] strh r0, [r5, 0x20]
ldrb r0, [r4] ldrb r0, [r4]
movs r1, 0x3 movs r1, 0x3
bl GetBankCoord bl GetBattlerSpriteCoord
lsls r0, 24 lsls r0, 24
lsrs r0, 24 lsrs r0, 24
strh r0, [r5, 0x22] strh r0, [r5, 0x22]
@ -1575,16 +1575,16 @@ sub_80A6864: @ 80A6864
lsls r1, 16 lsls r1, 16
lsrs r5, r1, 16 lsrs r5, r1, 16
mov r8, r5 mov r8, r5
ldr r7, =gAnimBankAttacker ldr r7, =gBattleAnimAttacker
ldrb r0, [r7] ldrb r0, [r7]
movs r1, 0 movs r1, 0
bl GetBankCoord bl GetBattlerSpriteCoord
lsls r0, 24 lsls r0, 24
lsrs r6, r0, 24 lsrs r6, r0, 24
ldr r0, =gAnimBankTarget ldr r0, =gBattleAnimTarget
ldrb r0, [r0] ldrb r0, [r0]
movs r1, 0 movs r1, 0
bl GetBankCoord bl GetBattlerSpriteCoord
lsls r0, 24 lsls r0, 24
lsrs r0, 24 lsrs r0, 24
cmp r6, r0 cmp r6, r0
@ -1729,7 +1729,7 @@ sub_80A6980: @ 80A6980
lsls r1, 24 lsls r1, 24
cmp r1, 0 cmp r1, 0
bne _080A69A8 bne _080A69A8
ldr r4, =gAnimBankTarget ldr r4, =gBattleAnimTarget
ldrb r0, [r4] ldrb r0, [r4]
movs r1, 0 movs r1, 0
bl sub_80A60AC bl sub_80A60AC
@ -1765,7 +1765,7 @@ sub_80A69CC: @ 80A69CC
lsls r1, 24 lsls r1, 24
cmp r1, 0 cmp r1, 0
bne _080A69F0 bne _080A69F0
ldr r4, =gAnimBankAttacker ldr r4, =gBattleAnimAttacker
ldrb r0, [r4] ldrb r0, [r4]
movs r1, 0 movs r1, 0
bl sub_80A60AC bl sub_80A60AC
@ -1777,7 +1777,7 @@ sub_80A69CC: @ 80A69CC
b _080A6A04 b _080A6A04
.pool .pool
_080A69F0: _080A69F0:
ldr r4, =gAnimBankAttacker ldr r4, =gBattleAnimAttacker
ldrb r0, [r4] ldrb r0, [r4]
movs r1, 0x2 movs r1, 0x2
bl sub_80A60AC bl sub_80A60AC
@ -1862,8 +1862,8 @@ _080A6A7E:
.pool .pool
thumb_func_end GetBattlerAtPosition thumb_func_end GetBattlerAtPosition
thumb_func_start IsBankSpritePresent thumb_func_start IsBattlerSpritePresent
IsBankSpritePresent: @ 80A6A90 IsBattlerSpritePresent: @ 80A6A90
push {r4,r5,lr} push {r4,r5,lr}
lsls r0, 24 lsls r0, 24
lsrs r4, r0, 24 lsrs r4, r0, 24
@ -1872,11 +1872,11 @@ IsBankSpritePresent: @ 80A6A90
lsls r0, 24 lsls r0, 24
cmp r0, 0 cmp r0, 0
beq _080A6ABC beq _080A6ABC
ldr r0, =gAnimBankAttacker ldr r0, =gBattleAnimAttacker
ldrb r0, [r0] ldrb r0, [r0]
cmp r0, r4 cmp r0, r4
beq _080A6B0A beq _080A6B0A
ldr r0, =gAnimBankTarget ldr r0, =gBattleAnimTarget
ldrb r0, [r0] ldrb r0, [r0]
cmp r0, r4 cmp r0, r4
beq _080A6B0A beq _080A6B0A
@ -1893,7 +1893,7 @@ _080A6ABC:
lsls r0, 24 lsls r0, 24
cmp r0, 0 cmp r0, 0
beq _080A6AF0 beq _080A6AF0
ldr r1, =gBattlePartyID ldr r1, =gBattlerPartyIndexes
lsls r0, r4, 1 lsls r0, r4, 1
adds r0, r1 adds r0, r1
ldrh r1, [r0] ldrh r1, [r0]
@ -1903,7 +1903,7 @@ _080A6ABC:
b _080A6AFE b _080A6AFE
.pool .pool
_080A6AF0: _080A6AF0:
ldr r1, =gBattlePartyID ldr r1, =gBattlerPartyIndexes
lsls r0, r5, 1 lsls r0, r5, 1
adds r0, r1 adds r0, r1
ldrh r1, [r0] ldrh r1, [r0]
@ -1926,7 +1926,7 @@ _080A6B1A:
pop {r4,r5} pop {r4,r5}
pop {r1} pop {r1}
bx r1 bx r1
thumb_func_end IsBankSpritePresent thumb_func_end IsBattlerSpritePresent
thumb_func_start IsDoubleBattle thumb_func_start IsDoubleBattle
IsDoubleBattle: @ 80A6B20 IsDoubleBattle: @ 80A6B20
@ -2061,7 +2061,7 @@ sub_80A6BFC: @ 80A6BFC
b _080A6C60 b _080A6C60
.pool .pool
_080A6C30: _080A6C30:
ldr r0, =gAnimBankAttacker ldr r0, =gBattleAnimAttacker
ldrb r0, [r0] ldrb r0, [r0]
bl sub_80A8364 bl sub_80A8364
lsls r0, 24 lsls r0, 24
@ -2889,7 +2889,7 @@ sub_80A7238: @ 80A7238
beq _080A7268 beq _080A7268
ldr r4, =gSprites ldr r4, =gSprites
movs r0, 0 movs r0, 0
bl GetAnimBankSpriteId bl GetBattlerSpriteId
lsls r0, 24 lsls r0, 24
lsrs r0, 24 lsrs r0, 24
lsls r1, r0, 4 lsls r1, r0, 4
@ -2934,7 +2934,7 @@ sub_80A7270: @ 80A7270
cmp r0, 0 cmp r0, 0
bne _080A72A6 bne _080A72A6
adds r0, r7, 0 adds r0, r7, 0
bl IsAnimBankSpriteVisible bl IsBattlerSpriteVisible
lsls r0, 24 lsls r0, 24
cmp r0, 0 cmp r0, 0
beq _080A72B4 beq _080A72B4
@ -3372,7 +3372,7 @@ _080A75F6:
_080A7602: _080A7602:
cmp r7, 0 cmp r7, 0
beq _080A7614 beq _080A7614
ldr r0, =gAnimBankAttacker ldr r0, =gBattleAnimAttacker
ldrb r0, [r0] ldrb r0, [r0]
adds r1, r0, 0 adds r1, r0, 0
adds r1, 0x10 adds r1, 0x10
@ -3383,7 +3383,7 @@ _080A7614:
mov r0, r8 mov r0, r8
cmp r0, 0 cmp r0, 0
beq _080A7628 beq _080A7628
ldr r0, =gAnimBankTarget ldr r0, =gBattleAnimTarget
ldrb r0, [r0] ldrb r0, [r0]
adds r1, r0, 0 adds r1, r0, 0
adds r1, 0x10 adds r1, 0x10
@ -3394,11 +3394,11 @@ _080A7628:
mov r0, r9 mov r0, r9
cmp r0, 0 cmp r0, 0
beq _080A764E beq _080A764E
ldr r6, =gAnimBankAttacker ldr r6, =gBattleAnimAttacker
ldrb r0, [r6] ldrb r0, [r6]
movs r5, 0x2 movs r5, 0x2
eors r0, r5 eors r0, r5
bl IsAnimBankSpriteVisible bl IsBattlerSpriteVisible
lsls r0, 24 lsls r0, 24
cmp r0, 0 cmp r0, 0
beq _080A764E beq _080A764E
@ -3413,11 +3413,11 @@ _080A764E:
mov r0, r10 mov r0, r10
cmp r0, 0 cmp r0, 0
beq _080A7674 beq _080A7674
ldr r6, =gAnimBankTarget ldr r6, =gBattleAnimTarget
ldrb r0, [r6] ldrb r0, [r6]
movs r5, 0x2 movs r5, 0x2
eors r0, r5 eors r0, r5
bl IsAnimBankSpriteVisible bl IsBattlerSpriteVisible
lsls r0, 24 lsls r0, 24
cmp r0, 0 cmp r0, 0
beq _080A7674 beq _080A7674
@ -3499,7 +3499,7 @@ _080A76F2:
bl GetBattlerAtPosition bl GetBattlerAtPosition
lsls r0, 24 lsls r0, 24
lsrs r0, 24 lsrs r0, 24
bl IsAnimBankSpriteVisible bl IsBattlerSpriteVisible
lsls r0, 24 lsls r0, 24
cmp r0, 0 cmp r0, 0
beq _080A771A beq _080A771A
@ -3517,7 +3517,7 @@ _080A771A:
bl GetBattlerAtPosition bl GetBattlerAtPosition
lsls r0, 24 lsls r0, 24
lsrs r0, 24 lsrs r0, 24
bl IsAnimBankSpriteVisible bl IsBattlerSpriteVisible
lsls r0, 24 lsls r0, 24
cmp r0, 0 cmp r0, 0
beq _080A7746 beq _080A7746
@ -3537,7 +3537,7 @@ _080A7746:
bl GetBattlerAtPosition bl GetBattlerAtPosition
lsls r0, 24 lsls r0, 24
lsrs r0, 24 lsrs r0, 24
bl IsAnimBankSpriteVisible bl IsBattlerSpriteVisible
lsls r0, 24 lsls r0, 24
cmp r0, 0 cmp r0, 0
beq _080A7772 beq _080A7772
@ -3558,7 +3558,7 @@ _080A7772:
bl GetBattlerAtPosition bl GetBattlerAtPosition
lsls r0, 24 lsls r0, 24
lsrs r0, 24 lsrs r0, 24
bl IsAnimBankSpriteVisible bl IsBattlerSpriteVisible
lsls r0, 24 lsls r0, 24
cmp r0, 0 cmp r0, 0
beq _080A77A0 beq _080A77A0
@ -3670,7 +3670,7 @@ _080A7838:
_080A7842: _080A7842:
adds r0, r5, 0 adds r0, r5, 0
bl sub_80A69CC bl sub_80A69CC
ldr r0, =gAnimBankAttacker ldr r0, =gBattleAnimAttacker
ldrb r0, [r0] ldrb r0, [r0]
bl GetBattlerSide bl GetBattlerSide
lsls r0, 24 lsls r0, 24
@ -3682,10 +3682,10 @@ _080A7842:
_080A785C: _080A785C:
ldrh r0, [r6, 0x8] ldrh r0, [r6, 0x8]
strh r0, [r5, 0x2E] strh r0, [r5, 0x2E]
ldr r4, =gAnimBankTarget ldr r4, =gBattleAnimTarget
ldrb r0, [r4] ldrb r0, [r4]
movs r1, 0x2 movs r1, 0x2
bl GetBankCoord bl GetBattlerSpriteCoord
lsls r0, 24 lsls r0, 24
lsrs r0, 24 lsrs r0, 24
ldrh r1, [r6, 0x4] ldrh r1, [r6, 0x4]
@ -3693,7 +3693,7 @@ _080A785C:
strh r0, [r5, 0x32] strh r0, [r5, 0x32]
ldrb r0, [r4] ldrb r0, [r4]
adds r1, r7, 0 adds r1, r7, 0
bl GetBankCoord bl GetBattlerSpriteCoord
lsls r0, 24 lsls r0, 24
lsrs r0, 24 lsrs r0, 24
ldrh r6, [r6, 0x6] ldrh r6, [r6, 0x6]
@ -3716,7 +3716,7 @@ sub_80A78AC: @ 80A78AC
adds r6, r0, 0 adds r6, r0, 0
movs r1, 0x1 movs r1, 0x1
bl sub_80A69CC bl sub_80A69CC
ldr r0, =gAnimBankAttacker ldr r0, =gBattleAnimAttacker
ldrb r0, [r0] ldrb r0, [r0]
bl GetBattlerSide bl GetBattlerSide
lsls r0, 24 lsls r0, 24
@ -3730,10 +3730,10 @@ _080A78CC:
ldr r4, =gBattleAnimArgs ldr r4, =gBattleAnimArgs
ldrh r0, [r4, 0x8] ldrh r0, [r4, 0x8]
strh r0, [r6, 0x2E] strh r0, [r6, 0x2E]
ldr r5, =gAnimBankTarget ldr r5, =gBattleAnimTarget
ldrb r0, [r5] ldrb r0, [r5]
movs r1, 0x2 movs r1, 0x2
bl GetBankCoord bl GetBattlerSpriteCoord
lsls r0, 24 lsls r0, 24
lsrs r0, 24 lsrs r0, 24
ldrh r1, [r4, 0x4] ldrh r1, [r4, 0x4]
@ -3741,7 +3741,7 @@ _080A78CC:
strh r0, [r6, 0x32] strh r0, [r6, 0x32]
ldrb r0, [r5] ldrb r0, [r5]
movs r1, 0x3 movs r1, 0x3
bl GetBankCoord bl GetBattlerSpriteCoord
lsls r0, 24 lsls r0, 24
lsrs r0, 24 lsrs r0, 24
ldrh r1, [r4, 0x6] ldrh r1, [r4, 0x6]
@ -3799,17 +3799,17 @@ _080A7954:
adds r0, r5, 0 adds r0, r5, 0
adds r1, r4, 0 adds r1, r4, 0
bl sub_80A69CC bl sub_80A69CC
ldr r0, =gAnimBankAttacker ldr r0, =gBattleAnimAttacker
b _080A7976 b _080A7976
.pool .pool
_080A796C: _080A796C:
adds r0, r5, 0 adds r0, r5, 0
adds r1, r4, 0 adds r1, r4, 0
bl sub_80A6980 bl sub_80A6980
ldr r0, =gAnimBankTarget ldr r0, =gBattleAnimTarget
_080A7976: _080A7976:
ldrb r6, [r0] ldrb r6, [r0]
ldr r0, =gAnimBankAttacker ldr r0, =gBattleAnimAttacker
ldrb r0, [r0] ldrb r0, [r0]
bl GetBattlerSide bl GetBattlerSide
lsls r0, 24 lsls r0, 24
@ -3828,7 +3828,7 @@ _080A798E:
strh r0, [r5, 0x2E] strh r0, [r5, 0x2E]
adds r0, r6, 0 adds r0, r6, 0
movs r1, 0x2 movs r1, 0x2
bl GetBankCoord bl GetBattlerSpriteCoord
lsls r0, 24 lsls r0, 24
lsrs r0, 24 lsrs r0, 24
ldrh r2, [r4, 0x4] ldrh r2, [r4, 0x4]
@ -3836,7 +3836,7 @@ _080A798E:
strh r0, [r5, 0x32] strh r0, [r5, 0x32]
adds r0, r6, 0 adds r0, r6, 0
adds r1, r7, 0 adds r1, r7, 0
bl GetBankCoord bl GetBattlerSpriteCoord
lsls r0, 24 lsls r0, 24
lsrs r0, 24 lsrs r0, 24
ldrh r4, [r4, 0x6] ldrh r4, [r4, 0x6]
@ -3858,7 +3858,7 @@ duplicate_obj_of_side_rel2move_in_transparent_mode: @ 80A79E8
push {r4-r6,lr} push {r4-r6,lr}
lsls r0, 24 lsls r0, 24
lsrs r0, 24 lsrs r0, 24
bl GetAnimBankSpriteId bl GetBattlerSpriteId
lsls r0, 24 lsls r0, 24
lsrs r1, r0, 24 lsrs r1, r0, 24
cmp r1, 0xFF cmp r1, 0xFF
@ -4084,7 +4084,7 @@ sub_80A7B98: @ 80A7B98
lsrs r4, r0, 24 lsrs r4, r0, 24
ldr r0, =gBattleAnimArgs ldr r0, =gBattleAnimArgs
ldrb r0, [r0] ldrb r0, [r0]
bl GetAnimBankSpriteId bl GetBattlerSpriteId
lsls r0, 24 lsls r0, 24
lsrs r3, r0, 24 lsrs r3, r0, 24
cmp r3, 0xFF cmp r3, 0xFF
@ -4539,7 +4539,7 @@ sub_80A7F18: @ 80A7F18
lsls r0, 24 lsls r0, 24
lsrs r5, r0, 24 lsrs r5, r0, 24
movs r4, 0 movs r4, 0
ldr r1, =gBankSpriteIds ldr r1, =gBattlerSpriteIds
ldr r7, =0x00000181 ldr r7, =0x00000181
ldr r0, =gBattleMonForms ldr r0, =gBattleMonForms
adds r6, r5, r0 adds r6, r5, r0
@ -4579,7 +4579,7 @@ _080A7F78:
ldrh r0, [r1, 0x2] ldrh r0, [r1, 0x2]
cmp r0, 0 cmp r0, 0
bne _080A7FC0 bne _080A7FC0
ldr r1, =gBattlePartyID ldr r1, =gBattlerPartyIndexes
lsls r0, r4, 1 lsls r0, r4, 1
adds r0, r1 adds r0, r1
ldrh r1, [r0] ldrh r1, [r0]
@ -4614,7 +4614,7 @@ _080A7FD8:
ldrh r0, [r1, 0x2] ldrh r0, [r1, 0x2]
cmp r0, 0 cmp r0, 0
bne _080A8010 bne _080A8010
ldr r1, =gBattlePartyID ldr r1, =gBattlerPartyIndexes
lsls r0, r4, 1 lsls r0, r4, 1
adds r0, r1 adds r0, r1
ldrh r1, [r0] ldrh r1, [r0]
@ -4837,14 +4837,14 @@ sub_80A8174: @ 80A8174
lsls r0, 24 lsls r0, 24
lsrs r4, r0, 24 lsrs r4, r0, 24
adds r7, r4, 0 adds r7, r4, 0
ldr r6, =gAnimBankTarget ldr r6, =gBattleAnimTarget
ldrb r0, [r6] ldrb r0, [r6]
bl IsAnimBankSpriteVisible bl IsBattlerSpriteVisible
lsls r0, 24 lsls r0, 24
cmp r0, 0 cmp r0, 0
beq _080A81B4 beq _080A81B4
ldr r2, =gSprites ldr r2, =gSprites
ldr r1, =gBankSpriteIds ldr r1, =gBattlerSpriteIds
ldrb r0, [r6] ldrb r0, [r6]
adds r0, r1 adds r0, r1
ldrb r0, [r0] ldrb r0, [r0]
@ -4863,15 +4863,15 @@ sub_80A8174: @ 80A8174
orrs r0, r2 orrs r0, r2
strb r0, [r1, 0x5] strb r0, [r1, 0x5]
_080A81B4: _080A81B4:
ldr r0, =gAnimBankAttacker ldr r0, =gBattleAnimAttacker
mov r8, r0 mov r8, r0
ldrb r0, [r0] ldrb r0, [r0]
bl IsAnimBankSpriteVisible bl IsBattlerSpriteVisible
lsls r0, 24 lsls r0, 24
cmp r0, 0 cmp r0, 0
beq _080A81EC beq _080A81EC
ldr r2, =gSprites ldr r2, =gSprites
ldr r1, =gBankSpriteIds ldr r1, =gBattlerSpriteIds
mov r3, r8 mov r3, r8
ldrb r0, [r3] ldrb r0, [r3]
adds r0, r1 adds r0, r1
@ -4894,12 +4894,12 @@ _080A81EC:
ldrb r0, [r6] ldrb r0, [r6]
movs r5, 0x2 movs r5, 0x2
eors r0, r5 eors r0, r5
bl IsAnimBankSpriteVisible bl IsBattlerSpriteVisible
lsls r0, 24 lsls r0, 24
cmp r0, 0 cmp r0, 0
beq _080A8224 beq _080A8224
ldr r2, =gSprites ldr r2, =gSprites
ldr r1, =gBankSpriteIds ldr r1, =gBattlerSpriteIds
ldrb r0, [r6] ldrb r0, [r6]
eors r0, r5 eors r0, r5
adds r0, r1 adds r0, r1
@ -4922,12 +4922,12 @@ _080A8224:
mov r1, r8 mov r1, r8
ldrb r0, [r1] ldrb r0, [r1]
eors r0, r5 eors r0, r5
bl IsAnimBankSpriteVisible bl IsBattlerSpriteVisible
lsls r0, 24 lsls r0, 24
cmp r0, 0 cmp r0, 0
beq _080A825C beq _080A825C
ldr r2, =gSprites ldr r2, =gSprites
ldr r1, =gBankSpriteIds ldr r1, =gBattlerSpriteIds
mov r3, r8 mov r3, r8
ldrb r0, [r3] ldrb r0, [r3]
eors r0, r5 eors r0, r5
@ -4968,13 +4968,13 @@ _080A8286:
lsls r0, r5, 24 lsls r0, r5, 24
lsrs r4, r0, 24 lsrs r4, r0, 24
adds r0, r4, 0 adds r0, r4, 0
bl IsAnimBankSpriteVisible bl IsBattlerSpriteVisible
lsls r0, 24 lsls r0, 24
cmp r0, 0 cmp r0, 0
beq _080A82C8 beq _080A82C8
adds r0, r4, 0 adds r0, r4, 0
bl sub_80A82E4 bl sub_80A82E4
ldr r3, =gBankSpriteIds ldr r3, =gBattlerSpriteIds
adds r3, r5, r3 adds r3, r5, r3
ldrb r2, [r3] ldrb r2, [r3]
lsls r1, r2, 4 lsls r1, r2, 4
@ -5499,7 +5499,7 @@ _080A86C4:
ldrh r0, [r1, 0x2] ldrh r0, [r1, 0x2]
cmp r0, 0 cmp r0, 0
bne _080A871C bne _080A871C
ldr r0, =gBattlePartyID ldr r0, =gBattlerPartyIndexes
mov r1, r8 mov r1, r8
lsls r4, r1, 1 lsls r4, r1, 1
adds r4, r0 adds r4, r0
@ -5589,7 +5589,7 @@ _080A8790:
ldrh r0, [r1, 0x2] ldrh r0, [r1, 0x2]
cmp r0, 0 cmp r0, 0
bne _080A87DC bne _080A87DC
ldr r0, =gBattlePartyID ldr r0, =gBattlerPartyIndexes
mov r1, r8 mov r1, r8
lsls r4, r1, 1 lsls r4, r1, 1
adds r4, r0 adds r4, r0
@ -5713,7 +5713,7 @@ _080A88A6:
_080A88AE: _080A88AE:
mov r0, r8 mov r0, r8
movs r1, 0x2 movs r1, 0x2
bl GetBankCoord bl GetBattlerSpriteCoord
lsls r0, 24 lsls r0, 24
lsrs r0, 24 lsrs r0, 24
ldrb r1, [r4] ldrb r1, [r4]
@ -5722,7 +5722,7 @@ _080A88AE:
_080A88C0: _080A88C0:
mov r0, r8 mov r0, r8
movs r1, 0x2 movs r1, 0x2
bl GetBankCoord bl GetBattlerSpriteCoord
lsls r0, 24 lsls r0, 24
lsrs r0, 24 lsrs r0, 24
ldrb r1, [r4] ldrb r1, [r4]
@ -5731,7 +5731,7 @@ _080A88C0:
_080A88D2: _080A88D2:
mov r0, r8 mov r0, r8
movs r1, 0x3 movs r1, 0x3
bl GetBankCoord bl GetBattlerSpriteCoord
lsls r0, 24 lsls r0, 24
lsrs r0, 24 lsrs r0, 24
ldrb r2, [r4] ldrb r2, [r4]
@ -5744,7 +5744,7 @@ _080A88E4:
_080A88EA: _080A88EA:
mov r0, r8 mov r0, r8
movs r1, 0x3 movs r1, 0x3
bl GetBankCoord bl GetBattlerSpriteCoord
lsls r0, 24 lsls r0, 24
lsrs r0, 24 lsrs r0, 24
ldrb r2, [r4] ldrb r2, [r4]
@ -5757,7 +5757,7 @@ _080A88FC:
_080A8902: _080A8902:
mov r0, r8 mov r0, r8
movs r1, 0x1 movs r1, 0x1
bl GetBankCoord bl GetBattlerSpriteCoord
lsls r0, 24 lsls r0, 24
lsrs r0, 24 lsrs r0, 24
adds r0, 0x1F adds r0, 0x1F
@ -5798,13 +5798,13 @@ _080A8942:
_080A8946: _080A8946:
adds r0, r4, 0 adds r0, r4, 0
adds r1, r5, 0 adds r1, r5, 0
bl GetBankCoord bl GetBattlerSpriteCoord
lsls r0, 24 lsls r0, 24
lsrs r0, 24 lsrs r0, 24
mov r8, r0 mov r8, r0
adds r0, r4, 0 adds r0, r4, 0
adds r1, r6, 0 adds r1, r6, 0
bl GetBankCoord bl GetBattlerSpriteCoord
lsls r0, 24 lsls r0, 24
lsrs r7, r0, 24 lsrs r7, r0, 24
bl IsDoubleBattle bl IsDoubleBattle
@ -5819,12 +5819,12 @@ _080A8946:
eors r4, r0 eors r4, r0
adds r0, r4, 0 adds r0, r4, 0
adds r1, r5, 0 adds r1, r5, 0
bl GetBankCoord bl GetBattlerSpriteCoord
lsls r0, 24 lsls r0, 24
lsrs r5, r0, 24 lsrs r5, r0, 24
adds r0, r4, 0 adds r0, r4, 0
adds r1, r6, 0 adds r1, r6, 0
bl GetBankCoord bl GetBattlerSpriteCoord
lsls r0, 24 lsls r0, 24
lsrs r3, r0, 24 lsrs r3, r0, 24
mov r0, r8 mov r0, r8
@ -5941,7 +5941,7 @@ sub_80A8A6C: @ 80A8A6C
push {r4,lr} push {r4,lr}
adds r4, r0, 0 adds r4, r0, 0
bl sub_80A6838 bl sub_80A6838
ldr r0, =gAnimBankAttacker ldr r0, =gBattleAnimAttacker
ldrb r0, [r0] ldrb r0, [r0]
bl GetBattlerSide bl GetBattlerSide
lsls r0, 24 lsls r0, 24
@ -5998,7 +5998,7 @@ _080A8AB6:
sub_80A8AEC: @ 80A8AEC sub_80A8AEC: @ 80A8AEC
push {r4,lr} push {r4,lr}
adds r4, r0, 0 adds r4, r0, 0
ldr r0, =gAnimBankAttacker ldr r0, =gBattleAnimAttacker
ldrb r0, [r0] ldrb r0, [r0]
bl GetBattlerSide bl GetBattlerSide
lsls r0, 24 lsls r0, 24
@ -6054,7 +6054,7 @@ sub_80A8B64: @ 80A8B64
push {r4,lr} push {r4,lr}
adds r4, r0, 0 adds r4, r0, 0
bl sub_80A6838 bl sub_80A6838
ldr r0, =gAnimBankAttacker ldr r0, =gBattleAnimAttacker
ldrb r0, [r0] ldrb r0, [r0]
bl GetBattlerSide bl GetBattlerSide
lsls r0, 24 lsls r0, 24
@ -6101,12 +6101,12 @@ sub_80A8BC4: @ 80A8BC4
ldr r0, =gTasks ldr r0, =gTasks
adds r5, r1, r0 adds r5, r1, r0
movs r0, 0 movs r0, 0
bl GetAnimBankSpriteId bl GetBattlerSpriteId
lsls r0, 24 lsls r0, 24
lsrs r0, 24 lsrs r0, 24
movs r6, 0 movs r6, 0
strh r0, [r5, 0x8] strh r0, [r5, 0x8]
ldr r7, =gAnimBankAttacker ldr r7, =gBattleAnimAttacker
ldrb r0, [r7] ldrb r0, [r7]
bl GetBattlerSide bl GetBattlerSide
lsls r0, 24 lsls r0, 24
@ -6389,16 +6389,16 @@ _080A8E26:
sub_80A8E30: @ 80A8E30 sub_80A8E30: @ 80A8E30
push {r4,r5,lr} push {r4,r5,lr}
adds r5, r0, 0 adds r5, r0, 0
ldr r4, =gAnimBankAttacker ldr r4, =gBattleAnimAttacker
ldrb r0, [r4] ldrb r0, [r4]
movs r1, 0x2 movs r1, 0x2
bl GetBankCoord bl GetBattlerSpriteCoord
lsls r0, 24 lsls r0, 24
lsrs r0, 24 lsrs r0, 24
strh r0, [r5, 0x20] strh r0, [r5, 0x20]
ldrb r0, [r4] ldrb r0, [r4]
movs r1, 0x3 movs r1, 0x3
bl GetBankCoord bl GetBattlerSpriteCoord
lsls r0, 24 lsls r0, 24
lsrs r0, 24 lsrs r0, 24
strh r0, [r5, 0x22] strh r0, [r5, 0x22]
@ -6487,7 +6487,7 @@ sub_80A8EE4: @ 80A8EE4
ldrh r1, [r4, 0x22] ldrh r1, [r4, 0x22]
adds r0, r1 adds r0, r1
strh r0, [r4, 0x36] strh r0, [r4, 0x36]
ldr r0, =gAnimBankTarget ldr r0, =gBattleAnimTarget
ldrb r0, [r0] ldrb r0, [r0]
bl GetBattlerSide bl GetBattlerSide
lsls r0, 24 lsls r0, 24

View File

@ -17,7 +17,7 @@ sub_80A9C70: @ 80A9C70
lsrs r4, 24 lsrs r4, 24
lsls r5, 24 lsls r5, 24
lsrs r5, 24 lsrs r5, 24
ldr r0, =gBankSpriteIds ldr r0, =gBattlerSpriteIds
adds r0, r4, r0 adds r0, r4, r0
ldrb r6, [r0] ldrb r6, [r0]
ldr r0, =sub_80A9DB4 ldr r0, =sub_80A9DB4
@ -331,10 +331,10 @@ sub_80A9EF4: @ 80A9EF4
push {r4-r6,lr} push {r4-r6,lr}
lsls r0, 24 lsls r0, 24
lsrs r6, r0, 24 lsrs r6, r0, 24
ldr r4, =gAnimBankTarget ldr r4, =gBattleAnimTarget
ldrb r0, [r4] ldrb r0, [r4]
movs r1, 0x2 movs r1, 0x2
bl GetBankCoord bl GetBattlerSpriteCoord
lsls r0, 24 lsls r0, 24
lsrs r0, 8 lsrs r0, 8
ldr r1, =0xffe00000 ldr r1, =0xffe00000
@ -342,7 +342,7 @@ sub_80A9EF4: @ 80A9EF4
lsrs r5, r0, 16 lsrs r5, r0, 16
ldrb r0, [r4] ldrb r0, [r4]
movs r1, 0x3 movs r1, 0x3
bl GetBankCoord bl GetBattlerSpriteCoord
lsls r0, 24 lsls r0, 24
lsrs r0, 8 lsrs r0, 8
ldr r1, =0xffdc0000 ldr r1, =0xffdc0000
@ -863,9 +863,9 @@ LaunchStatusAnimation: @ 80AA364
lsrs r4, 24 lsrs r4, 24
lsls r1, 24 lsls r1, 24
lsrs r1, 24 lsrs r1, 24
ldr r0, =gAnimBankAttacker ldr r0, =gBattleAnimAttacker
strb r4, [r0] strb r4, [r0]
ldr r0, =gAnimBankTarget ldr r0, =gBattleAnimTarget
strb r4, [r0] strb r4, [r0]
ldr r0, =gBattleAnims_Statuses ldr r0, =gBattleAnims_Statuses
movs r2, 0 movs r2, 0

View File

@ -12,7 +12,7 @@ sub_80D51AC: @ 80D51AC
lsrs r5, r0, 24 lsrs r5, r0, 24
ldr r4, =gBattleAnimArgs ldr r4, =gBattleAnimArgs
ldrb r0, [r4] ldrb r0, [r4]
bl GetAnimBankSpriteId bl GetBattlerSpriteId
lsls r0, 24 lsls r0, 24
lsrs r2, r0, 24 lsrs r2, r0, 24
cmp r2, 0xFF cmp r2, 0xFF
@ -165,7 +165,7 @@ sub_80D52D0: @ 80D52D0
bgt _080D52FC bgt _080D52FC
lsls r0, 24 lsls r0, 24
lsrs r0, 24 lsrs r0, 24
bl GetAnimBankSpriteId bl GetBattlerSpriteId
lsls r0, 24 lsls r0, 24
lsrs r3, r0, 24 lsrs r3, r0, 24
cmp r3, 0xFF cmp r3, 0xFF
@ -204,19 +204,19 @@ _080D5326:
lsls r0, 24 lsls r0, 24
lsrs r4, r0, 24 lsrs r4, r0, 24
adds r0, r4, 0 adds r0, r4, 0
bl IsAnimBankSpriteVisible bl IsBattlerSpriteVisible
lsls r0, 24 lsls r0, 24
cmp r0, 0 cmp r0, 0
bne _080D533C bne _080D533C
movs r6, 0x1 movs r6, 0x1
_080D533C: _080D533C:
ldr r0, =gBankSpriteIds ldr r0, =gBattlerSpriteIds
adds r0, r4, r0 adds r0, r4, r0
b _080D5350 b _080D5350
.pool .pool
_080D5348: _080D5348:
ldr r1, =gBankSpriteIds ldr r1, =gBattlerSpriteIds
ldr r0, =gAnimBankAttacker ldr r0, =gBattleAnimAttacker
ldrb r0, [r0] ldrb r0, [r0]
adds r0, r1 adds r0, r1
_080D5350: _080D5350:
@ -379,7 +379,7 @@ sub_80D5484: @ 80D5484
lsrs r5, r0, 24 lsrs r5, r0, 24
ldr r4, =gBattleAnimArgs ldr r4, =gBattleAnimArgs
ldrb r0, [r4] ldrb r0, [r4]
bl GetAnimBankSpriteId bl GetBattlerSpriteId
lsls r0, 24 lsls r0, 24
lsrs r3, r0, 24 lsrs r3, r0, 24
cmp r3, 0xFF cmp r3, 0xFF
@ -603,7 +603,7 @@ sub_80D5644: @ 80D5644
lsrs r4, 24 lsrs r4, 24
ldr r5, =gBattleAnimArgs ldr r5, =gBattleAnimArgs
ldrb r0, [r5] ldrb r0, [r5]
bl GetAnimBankSpriteId bl GetBattlerSpriteId
lsls r0, 24 lsls r0, 24
lsrs r0, 24 lsrs r0, 24
ldr r2, =gSprites ldr r2, =gSprites
@ -723,7 +723,7 @@ sub_80D5738: @ 80D5738
movs r6, 0x1 movs r6, 0x1
ldr r4, =gBattleAnimArgs ldr r4, =gBattleAnimArgs
ldrb r0, [r4] ldrb r0, [r4]
bl GetAnimBankSpriteId bl GetBattlerSpriteId
lsls r0, 24 lsls r0, 24
lsrs r7, r0, 24 lsrs r7, r0, 24
movs r1, 0x8 movs r1, 0x8
@ -842,7 +842,7 @@ sub_80D5830: @ 80D5830
push {r4,lr} push {r4,lr}
lsls r0, 24 lsls r0, 24
lsrs r4, r0, 24 lsrs r4, r0, 24
ldr r0, =gAnimBankAttacker ldr r0, =gBattleAnimAttacker
ldrb r0, [r0] ldrb r0, [r0]
bl GetBattlerSide bl GetBattlerSide
lsls r0, 24 lsls r0, 24
@ -871,7 +871,7 @@ sub_80D5860: @ 80D5860
movs r1, 0x4 movs r1, 0x4
orrs r0, r1 orrs r0, r1
strb r0, [r2] strb r0, [r2]
ldr r0, =gAnimBankAttacker ldr r0, =gBattleAnimAttacker
ldrb r0, [r0] ldrb r0, [r0]
bl GetBattlerSide bl GetBattlerSide
lsls r0, 24 lsls r0, 24
@ -891,8 +891,8 @@ _080D5894:
movs r0, 0 movs r0, 0
strh r2, [r4, 0x2E] strh r2, [r4, 0x2E]
strh r0, [r4, 0x32] strh r0, [r4, 0x32]
ldr r1, =gBankSpriteIds ldr r1, =gBattlerSpriteIds
ldr r0, =gAnimBankAttacker ldr r0, =gBattleAnimAttacker
ldrb r0, [r0] ldrb r0, [r0]
adds r0, r1 adds r0, r1
ldrb r0, [r0] ldrb r0, [r0]
@ -938,7 +938,7 @@ sub_80D58F8: @ 80D58F8
strb r0, [r2] strb r0, [r2]
ldr r5, =gBattleAnimArgs ldr r5, =gBattleAnimArgs
ldrb r0, [r5, 0x4] ldrb r0, [r5, 0x4]
bl GetAnimBankSpriteId bl GetBattlerSpriteId
lsls r0, 24 lsls r0, 24
lsrs r0, 24 lsrs r0, 24
ldrh r2, [r5] ldrh r2, [r5]
@ -987,13 +987,13 @@ sub_80D5968: @ 80D5968
ldrsh r0, [r0, r1] ldrsh r0, [r0, r1]
cmp r0, 0 cmp r0, 0
bne _080D598C bne _080D598C
ldr r1, =gBankSpriteIds ldr r1, =gBattlerSpriteIds
ldr r0, =gAnimBankAttacker ldr r0, =gBattleAnimAttacker
b _080D5990 b _080D5990
.pool .pool
_080D598C: _080D598C:
ldr r1, =gBankSpriteIds ldr r1, =gBattlerSpriteIds
ldr r0, =gAnimBankTarget ldr r0, =gBattleAnimTarget
_080D5990: _080D5990:
ldrb r0, [r0] ldrb r0, [r0]
adds r0, r1 adds r0, r1
@ -1133,14 +1133,14 @@ sub_80D5A94: @ 80D5A94
ldrsh r0, [r0, r1] ldrsh r0, [r0, r1]
cmp r0, 0 cmp r0, 0
bne _080D5AB0 bne _080D5AB0
ldr r0, =gAnimBankAttacker ldr r0, =gBattleAnimAttacker
b _080D5AB2 b _080D5AB2
.pool .pool
_080D5AB0: _080D5AB0:
ldr r0, =gAnimBankTarget ldr r0, =gBattleAnimTarget
_080D5AB2: _080D5AB2:
ldrb r2, [r0] ldrb r2, [r0]
ldr r0, =gBankSpriteIds ldr r0, =gBattlerSpriteIds
adds r0, r2, r0 adds r0, r2, r0
ldrb r6, [r0] ldrb r6, [r0]
adds r0, r2, 0 adds r0, r2, 0
@ -1218,14 +1218,14 @@ sub_80D5B48: @ 80D5B48
ldrsh r0, [r0, r1] ldrsh r0, [r0, r1]
cmp r0, 0 cmp r0, 0
bne _080D5B70 bne _080D5B70
ldr r0, =gAnimBankAttacker ldr r0, =gBattleAnimAttacker
b _080D5B72 b _080D5B72
.pool .pool
_080D5B70: _080D5B70:
ldr r0, =gAnimBankTarget ldr r0, =gBattleAnimTarget
_080D5B72: _080D5B72:
ldrb r1, [r0] ldrb r1, [r0]
ldr r0, =gBankSpriteIds ldr r0, =gBattlerSpriteIds
adds r0, r1, r0 adds r0, r1, r0
ldrb r7, [r0] ldrb r7, [r0]
adds r0, r1, 0 adds r0, r1, 0
@ -1338,7 +1338,7 @@ sub_80D5C50: @ 80D5C50
bl __divsi3 bl __divsi3
lsls r0, 16 lsls r0, 16
lsrs r7, r0, 16 lsrs r7, r0, 16
ldr r0, =gAnimBankAttacker ldr r0, =gBattleAnimAttacker
ldrb r0, [r0] ldrb r0, [r0]
bl GetBattlerSide bl GetBattlerSide
lsls r0, 24 lsls r0, 24
@ -1352,7 +1352,7 @@ sub_80D5C50: @ 80D5C50
strh r0, [r5, 0xA] strh r0, [r5, 0xA]
_080D5C82: _080D5C82:
ldrb r0, [r5] ldrb r0, [r5]
bl GetAnimBankSpriteId bl GetBattlerSpriteId
ldr r1, =gTasks ldr r1, =gTasks
lsls r4, r6, 2 lsls r4, r6, 2
adds r4, r6 adds r4, r6
@ -1508,7 +1508,7 @@ sub_80D5DB0: @ 80D5DB0
cmp r0, 0 cmp r0, 0
blt _080D5E10 blt _080D5E10
ldrb r0, [r1] ldrb r0, [r1]
bl GetAnimBankSpriteId bl GetBattlerSpriteId
lsls r0, 24 lsls r0, 24
lsrs r2, r0, 24 lsrs r2, r0, 24
b _080D5E18 b _080D5E18
@ -1518,20 +1518,20 @@ _080D5DD8:
beq _080D5DE8 beq _080D5DE8
b _080D5E10 b _080D5E10
_080D5DDE: _080D5DDE:
ldr r5, =gAnimBankAttacker ldr r5, =gBattleAnimAttacker
b _080D5DEA b _080D5DEA
.pool .pool
_080D5DE8: _080D5DE8:
ldr r5, =gAnimBankTarget ldr r5, =gBattleAnimTarget
_080D5DEA: _080D5DEA:
ldrb r0, [r5] ldrb r0, [r5]
movs r4, 0x2 movs r4, 0x2
eors r0, r4 eors r0, r4
bl IsAnimBankSpriteVisible bl IsBattlerSpriteVisible
lsls r0, 24 lsls r0, 24
cmp r0, 0 cmp r0, 0
beq _080D5E10 beq _080D5E10
ldr r1, =gBankSpriteIds ldr r1, =gBattlerSpriteIds
ldrb r0, [r5] ldrb r0, [r5]
eors r0, r4 eors r0, r4
adds r0, r1 adds r0, r1
@ -1549,7 +1549,7 @@ _080D5E18:
lsls r0, 3 lsls r0, 3
adds r5, r0, r1 adds r5, r0, r1
strh r2, [r5, 0x8] strh r2, [r5, 0x8]
ldr r0, =gAnimBankTarget ldr r0, =gBattleAnimTarget
ldrb r0, [r0] ldrb r0, [r0]
bl GetBattlerSide bl GetBattlerSide
lsls r0, 24 lsls r0, 24
@ -1622,7 +1622,7 @@ sub_80D5EB8: @ 80D5EB8
push {r4-r6,lr} push {r4-r6,lr}
lsls r0, 24 lsls r0, 24
lsrs r5, r0, 24 lsrs r5, r0, 24
ldr r6, =gAnimBankAttacker ldr r6, =gBattleAnimAttacker
ldrb r0, [r6] ldrb r0, [r6]
bl GetBattlerSide bl GetBattlerSide
lsls r0, 24 lsls r0, 24
@ -1635,7 +1635,7 @@ sub_80D5EB8: @ 80D5EB8
_080D5ED4: _080D5ED4:
ldr r4, =gBattleAnimArgs ldr r4, =gBattleAnimArgs
ldrb r0, [r4, 0x8] ldrb r0, [r4, 0x8]
bl GetAnimBankSpriteId bl GetBattlerSpriteId
lsls r0, 24 lsls r0, 24
lsrs r0, 24 lsrs r0, 24
ldr r2, =gTasks ldr r2, =gTasks
@ -1660,7 +1660,7 @@ _080D5ED4:
b _080D5F18 b _080D5F18
.pool .pool
_080D5F14: _080D5F14:
ldr r0, =gAnimBankTarget ldr r0, =gBattleAnimTarget
ldrb r0, [r0] ldrb r0, [r0]
_080D5F18: _080D5F18:
strh r0, [r2, 0x12] strh r0, [r2, 0x12]
@ -1836,7 +1836,7 @@ sub_80D6064: @ 80D6064
lsrs r4, 24 lsrs r4, 24
ldr r6, =gBattleAnimArgs ldr r6, =gBattleAnimArgs
ldrb r0, [r6, 0x6] ldrb r0, [r6, 0x6]
bl GetAnimBankSpriteId bl GetBattlerSpriteId
adds r5, r0, 0 adds r5, r0, 0
lsls r5, 24 lsls r5, 24
lsrs r5, 24 lsrs r5, 24
@ -1939,7 +1939,7 @@ sub_80D6134: @ 80D6134
lsrs r7, r0, 24 lsrs r7, r0, 24
ldr r4, =gBattleAnimArgs ldr r4, =gBattleAnimArgs
ldrb r0, [r4, 0x4] ldrb r0, [r4, 0x4]
bl GetAnimBankSpriteId bl GetBattlerSpriteId
lsls r0, 24 lsls r0, 24
lsrs r0, 24 lsrs r0, 24
mov r8, r0 mov r8, r0
@ -1995,11 +1995,11 @@ _080D61B8:
ldrsh r0, [r6, r1] ldrsh r0, [r6, r1]
cmp r0, 0 cmp r0, 0
bne _080D61C8 bne _080D61C8
ldr r0, =gAnimBankAttacker ldr r0, =gBattleAnimAttacker
b _080D61CA b _080D61CA
.pool .pool
_080D61C8: _080D61C8:
ldr r0, =gAnimBankTarget ldr r0, =gBattleAnimTarget
_080D61CA: _080D61CA:
ldrb r0, [r0] ldrb r0, [r0]
bl GetBattlerSide bl GetBattlerSide
@ -2057,7 +2057,7 @@ sub_80D622C: @ 80D622C
lsrs r5, r0, 24 lsrs r5, r0, 24
ldr r4, =gBattleAnimArgs ldr r4, =gBattleAnimArgs
ldrb r0, [r4, 0x4] ldrb r0, [r4, 0x4]
bl GetAnimBankSpriteId bl GetBattlerSpriteId
lsls r0, 24 lsls r0, 24
lsrs r0, 24 lsrs r0, 24
mov r8, r0 mov r8, r0
@ -2076,11 +2076,11 @@ sub_80D622C: @ 80D622C
ldrsh r0, [r4, r1] ldrsh r0, [r4, r1]
cmp r0, 0 cmp r0, 0
bne _080D6274 bne _080D6274
ldr r0, =gAnimBankAttacker ldr r0, =gBattleAnimAttacker
b _080D6276 b _080D6276
.pool .pool
_080D6274: _080D6274:
ldr r0, =gAnimBankTarget ldr r0, =gBattleAnimTarget
_080D6276: _080D6276:
ldrb r0, [r0] ldrb r0, [r0]
bl GetBattlerSide bl GetBattlerSide
@ -2290,7 +2290,7 @@ _080D63EE:
ldrh r0, [r1, 0x8] ldrh r0, [r1, 0x8]
strh r0, [r4, 0x1E] strh r0, [r4, 0x1E]
movs r0, 0x1 movs r0, 0x1
bl GetAnimBankSpriteId bl GetBattlerSpriteId
lsls r0, 24 lsls r0, 24
lsrs r0, 24 lsrs r0, 24
strh r0, [r4, 0x16] strh r0, [r4, 0x16]

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -16,7 +16,7 @@ sub_8170478: @ 8170478
lsls r0, 24 lsls r0, 24
lsrs r0, 24 lsrs r0, 24
str r0, [sp, 0x10] str r0, [sp, 0x10]
ldr r0, =gAnimBankAttacker ldr r0, =gBattleAnimAttacker
ldrb r4, [r0] ldrb r4, [r0]
ldr r0, =gBattle_WIN0H ldr r0, =gBattle_WIN0H
movs r1, 0 movs r1, 0
@ -56,7 +56,7 @@ sub_8170478: @ 8170478
movs r1, 0x3 movs r1, 0x3
movs r2, 0x1 movs r2, 0x1
bl SetAnimBgAttribute bl SetAnimBgAttribute
ldr r0, =gHealthBoxesIds ldr r0, =gHealthboxSpriteIds
adds r4, r0 adds r4, r0
ldrb r0, [r4] ldrb r0, [r4]
ldr r1, =gSprites ldr r1, =gSprites
@ -212,7 +212,7 @@ sub_8170660: @ 8170660
push {r7} push {r7}
lsls r0, 24 lsls r0, 24
lsrs r7, r0, 24 lsrs r7, r0, 24
ldr r0, =gAnimBankAttacker ldr r0, =gBattleAnimAttacker
ldrb r0, [r0] ldrb r0, [r0]
mov r8, r0 mov r8, r0
ldr r1, =gTasks ldr r1, =gTasks
@ -373,7 +373,7 @@ _0817076C:
movs r1, 0x1 movs r1, 0x1
movs r2, 0 movs r2, 0
bl SetAnimBgAttribute bl SetAnimBgAttribute
ldr r0, =gHealthBoxesIds ldr r0, =gHealthboxSpriteIds
add r0, r8 add r0, r8
ldrb r0, [r0] ldrb r0, [r0]
lsls r1, r0, 4 lsls r1, r0, 4
@ -434,7 +434,7 @@ sub_8170834: @ 8170834
adds r7, r1, 0 adds r7, r1, 0
lsls r2, 24 lsls r2, 24
lsrs r2, 24 lsrs r2, 24
ldr r0, =gHealthBoxesIds ldr r0, =gHealthboxSpriteIds
adds r2, r0 adds r2, r0
ldrb r0, [r2] ldrb r0, [r2]
lsls r5, r0, 4 lsls r5, r0, 4
@ -540,7 +540,7 @@ sub_8170920: @ 8170920
lsrs r4, 24 lsrs r4, 24
mov r1, sp mov r1, sp
adds r1, 0x1 adds r1, 0x1
ldr r0, =gAnimBankAttacker ldr r0, =gBattleAnimAttacker
ldrb r2, [r0] ldrb r2, [r0]
mov r0, sp mov r0, sp
bl sub_8170834 bl sub_8170834
@ -561,7 +561,7 @@ sub_817094C: @ 817094C
push {r5,r6} push {r5,r6}
lsls r0, 24 lsls r0, 24
lsrs r0, 24 lsrs r0, 24
ldr r1, =gHealthBoxesIds ldr r1, =gHealthboxSpriteIds
adds r0, r1 adds r0, r1
ldrb r0, [r0] ldrb r0, [r0]
ldr r1, =gSprites ldr r1, =gSprites
@ -628,7 +628,7 @@ sub_81709EC: @ 81709EC
adds r4, r0, 0 adds r4, r0, 0
lsls r4, 24 lsls r4, 24
lsrs r4, 24 lsrs r4, 24
ldr r0, =gAnimBankAttacker ldr r0, =gBattleAnimAttacker
ldrb r0, [r0] ldrb r0, [r0]
bl sub_817094C bl sub_817094C
adds r0, r4, 0 adds r0, r4, 0
@ -765,8 +765,8 @@ sub_8170B04: @ 8170B04
push {r4-r6,lr} push {r4-r6,lr}
lsls r0, 24 lsls r0, 24
lsrs r6, r0, 24 lsrs r6, r0, 24
ldr r1, =gBankSpriteIds ldr r1, =gBattlerSpriteIds
ldr r0, =gAnimBankAttacker ldr r0, =gBattleAnimAttacker
ldrb r0, [r0] ldrb r0, [r0]
adds r0, r1 adds r0, r1
ldrb r5, [r0] ldrb r5, [r0]
@ -851,8 +851,8 @@ sub_8170BB0: @ 8170BB0
sub sp, 0xC sub sp, 0xC
lsls r0, 24 lsls r0, 24
lsrs r5, r0, 24 lsrs r5, r0, 24
ldr r1, =gBankSpriteIds ldr r1, =gBattlerSpriteIds
ldr r4, =gAnimBankAttacker ldr r4, =gBattleAnimAttacker
ldrb r0, [r4] ldrb r0, [r4]
adds r1, r0, r1 adds r1, r0, r1
ldrb r1, [r1] ldrb r1, [r1]
@ -861,7 +861,7 @@ sub_8170BB0: @ 8170BB0
lsls r0, 24 lsls r0, 24
cmp r0, 0 cmp r0, 0
bne _08170BF8 bne _08170BF8
ldr r1, =gBattlePartyID ldr r1, =gBattlerPartyIndexes
ldrb r0, [r4] ldrb r0, [r4]
lsls r0, 1 lsls r0, 1
adds r0, r1 adds r0, r1
@ -872,7 +872,7 @@ sub_8170BB0: @ 8170BB0
b _08170C08 b _08170C08
.pool .pool
_08170BF8: _08170BF8:
ldr r1, =gBattlePartyID ldr r1, =gBattlerPartyIndexes
ldrb r0, [r4] ldrb r0, [r4]
lsls r0, 1 lsls r0, 1
adds r0, r1 adds r0, r1
@ -904,16 +904,16 @@ _08170C08:
b _08170CEE b _08170CEE
.pool .pool
_08170C44: _08170C44:
ldr r5, =gAnimBankAttacker ldr r5, =gBattleAnimAttacker
ldrb r0, [r5] ldrb r0, [r5]
movs r1, 0 movs r1, 0
bl GetBankCoord bl GetBattlerSpriteCoord
adds r4, r0, 0 adds r4, r0, 0
lsls r4, 24 lsls r4, 24
lsrs r4, 24 lsrs r4, 24
ldrb r0, [r5] ldrb r0, [r5]
movs r1, 0x1 movs r1, 0x1
bl GetBankCoord bl GetBattlerSpriteCoord
adds r1, r0, 0 adds r1, r0, 0
lsls r1, 24 lsls r1, 24
ldr r2, =gSprites ldr r2, =gSprites
@ -1162,18 +1162,18 @@ sub_8170E04: @ 8170E04
adds r6, r4, r1 adds r6, r4, r1
movs r0, 0x22 movs r0, 0x22
strh r0, [r6, 0x2E] strh r0, [r6, 0x2E]
ldr r2, =gAnimBankTarget ldr r2, =gBattleAnimTarget
mov r8, r2 mov r8, r2
ldrb r0, [r2] ldrb r0, [r2]
movs r1, 0 movs r1, 0
bl GetBankCoord bl GetBattlerSpriteCoord
lsls r0, 24 lsls r0, 24
lsrs r0, 24 lsrs r0, 24
strh r0, [r6, 0x30] strh r0, [r6, 0x30]
mov r1, r8 mov r1, r8
ldrb r0, [r1] ldrb r0, [r1]
movs r1, 0x1 movs r1, 0x1
bl GetBankCoord bl GetBattlerSpriteCoord
lsls r0, 24 lsls r0, 24
lsrs r0, 24 lsrs r0, 24
subs r0, 0x10 subs r0, 0x10
@ -1186,7 +1186,7 @@ sub_8170E04: @ 8170E04
ldr r0, =gBattleSpritesDataPtr ldr r0, =gBattleSpritesDataPtr
ldr r0, [r0] ldr r0, [r0]
ldr r3, [r0, 0x8] ldr r3, [r0, 0x8]
ldr r1, =gBankSpriteIds ldr r1, =gBattlerSpriteIds
mov r2, r8 mov r2, r8
ldrb r0, [r2] ldrb r0, [r2]
adds r0, r1 adds r0, r1
@ -1313,18 +1313,18 @@ _08170F54:
adds r6, r4, r0 adds r6, r4, r0
movs r0, 0x22 movs r0, 0x22
strh r0, [r6, 0x2E] strh r0, [r6, 0x2E]
ldr r1, =gAnimBankTarget ldr r1, =gBattleAnimTarget
mov r8, r1 mov r8, r1
ldrb r0, [r1] ldrb r0, [r1]
movs r1, 0 movs r1, 0
bl GetBankCoord bl GetBattlerSpriteCoord
lsls r0, 24 lsls r0, 24
lsrs r0, 24 lsrs r0, 24
strh r0, [r6, 0x30] strh r0, [r6, 0x30]
mov r1, r8 mov r1, r8
ldrb r0, [r1] ldrb r0, [r1]
movs r1, 0x1 movs r1, 0x1
bl GetBankCoord bl GetBattlerSpriteCoord
lsls r0, 24 lsls r0, 24
lsrs r0, 24 lsrs r0, 24
subs r0, 0x10 subs r0, 0x10
@ -1336,7 +1336,7 @@ _08170F54:
str r0, [r4] str r0, [r4]
movs r0, 0 movs r0, 0
bl GetBattlerAtPosition bl GetBattlerAtPosition
ldr r1, =gBankSpriteIds ldr r1, =gBattlerSpriteIds
lsls r0, 24 lsls r0, 24
lsrs r0, 24 lsrs r0, 24
adds r0, r1 adds r0, r1
@ -1372,7 +1372,7 @@ sub_8171030: @ 8171030
ldr r6, =gSprites ldr r6, =gSprites
movs r0, 0 movs r0, 0
bl GetBattlerAtPosition bl GetBattlerAtPosition
ldr r1, =gBankSpriteIds ldr r1, =gBattlerSpriteIds
lsls r0, 24 lsls r0, 24
lsrs r0, 24 lsrs r0, 24
adds r0, r1 adds r0, r1
@ -1423,7 +1423,7 @@ sub_81710A8: @ 81710A8
ldr r6, =gSprites ldr r6, =gSprites
movs r0, 0 movs r0, 0
bl GetBattlerAtPosition bl GetBattlerAtPosition
ldr r4, =gBankSpriteIds ldr r4, =gBattlerSpriteIds
lsls r0, 24 lsls r0, 24
lsrs r0, 24 lsrs r0, 24
adds r0, r4 adds r0, r4
@ -1550,7 +1550,7 @@ _08171188:
movs r2, 0x1 movs r2, 0x1
movs r3, 0x1C movs r3, 0x1C
bl LaunchBallStarsTask bl LaunchBallStarsTask
ldr r0, =gAnimBankTarget ldr r0, =gBattleAnimTarget
ldrb r1, [r0] ldrb r1, [r0]
movs r0, 0 movs r0, 0
movs r2, 0xE movs r2, 0xE
@ -1584,8 +1584,8 @@ sub_81711E8: @ 81711E8
ldr r0, =sub_8171240 ldr r0, =sub_8171240
str r0, [r4, 0x1C] str r0, [r4, 0x1C]
ldr r2, =gSprites ldr r2, =gSprites
ldr r1, =gBankSpriteIds ldr r1, =gBattlerSpriteIds
ldr r0, =gAnimBankTarget ldr r0, =gBattleAnimTarget
ldrb r0, [r0] ldrb r0, [r0]
adds r0, r1 adds r0, r1
ldrb r1, [r0] ldrb r1, [r0]
@ -1606,8 +1606,8 @@ _08171224:
sub_8171240: @ 8171240 sub_8171240: @ 8171240
push {r4-r7,lr} push {r4-r7,lr}
adds r7, r0, 0 adds r7, r0, 0
ldr r1, =gBankSpriteIds ldr r1, =gBattlerSpriteIds
ldr r0, =gAnimBankTarget ldr r0, =gBattleAnimTarget
ldrb r0, [r0] ldrb r0, [r0]
adds r0, r1 adds r0, r1
ldrb r4, [r0] ldrb r4, [r0]
@ -2333,7 +2333,7 @@ sub_81717F8: @ 81717F8
push {r7} push {r7}
sub sp, 0x4 sub sp, 0x4
adds r6, r0, 0 adds r6, r0, 0
ldr r7, =gAnimBankTarget ldr r7, =gBattleAnimTarget
ldrh r0, [r6, 0x36] ldrh r0, [r6, 0x36]
adds r0, 0x1 adds r0, 0x1
movs r1, 0 movs r1, 0
@ -2390,7 +2390,7 @@ _08171880:
cmp r1, r0 cmp r1, r0
bne _081718BC bne _081718BC
ldr r5, =gSprites ldr r5, =gSprites
ldr r4, =gBankSpriteIds ldr r4, =gBattlerSpriteIds
ldrb r0, [r7] ldrb r0, [r7]
adds r0, r4 adds r0, r4
ldrb r1, [r0] ldrb r1, [r0]
@ -2715,7 +2715,7 @@ sub_8171AE4: @ 8171AE4
movs r2, 0x1 movs r2, 0x1
movs r3, 0x1C movs r3, 0x1C
bl LaunchBallStarsTask bl LaunchBallStarsTask
ldr r0, =gAnimBankTarget ldr r0, =gBattleAnimTarget
ldrb r1, [r0] ldrb r1, [r0]
movs r0, 0x1 movs r0, 0x1
movs r2, 0xE movs r2, 0xE
@ -2723,8 +2723,8 @@ sub_8171AE4: @ 8171AE4
bl LaunchBallFadeMonTask bl LaunchBallFadeMonTask
_08171B36: _08171B36:
ldr r6, =gSprites ldr r6, =gSprites
ldr r5, =gBankSpriteIds ldr r5, =gBattlerSpriteIds
ldr r4, =gAnimBankTarget ldr r4, =gBattleAnimTarget
ldrb r0, [r4] ldrb r0, [r4]
adds r0, r5 adds r0, r5
ldrb r1, [r0] ldrb r1, [r0]
@ -2791,8 +2791,8 @@ sub_8171BAC: @ 8171BAC
strb r0, [r2] strb r0, [r2]
_08171BCA: _08171BCA:
ldr r4, =gSprites ldr r4, =gSprites
ldr r3, =gBankSpriteIds ldr r3, =gBattlerSpriteIds
ldr r2, =gAnimBankTarget ldr r2, =gBattleAnimTarget
ldrb r0, [r2] ldrb r0, [r2]
adds r0, r3 adds r0, r3
ldrb r1, [r0] ldrb r1, [r0]
@ -2840,8 +2840,8 @@ _08171C24:
cmp r5, 0 cmp r5, 0
beq _08171C8A beq _08171C8A
ldr r4, =gSprites ldr r4, =gSprites
ldr r3, =gBankSpriteIds ldr r3, =gBattlerSpriteIds
ldr r2, =gAnimBankTarget ldr r2, =gBattleAnimTarget
ldrb r0, [r2] ldrb r0, [r2]
adds r0, r3 adds r0, r3
ldrb r1, [r0] ldrb r1, [r0]
@ -4729,8 +4729,8 @@ sub_8172BF0: @ 8172BF0
lsrs r7, r0, 24 lsrs r7, r0, 24
movs r0, 0 movs r0, 0
mov r8, r0 mov r8, r0
ldr r0, =gBankSpriteIds ldr r0, =gBattlerSpriteIds
ldr r3, =gAnimBankAttacker ldr r3, =gBattleAnimAttacker
ldrb r2, [r3] ldrb r2, [r3]
adds r0, r2, r0 adds r0, r2, r0
ldrb r6, [r0] ldrb r6, [r0]
@ -4877,7 +4877,7 @@ _08172D28:
adds r0, r1 adds r0, r1
ldrb r1, [r0, 0x8] ldrb r1, [r0, 0x8]
strh r1, [r0, 0x8] strh r1, [r0, 0x8]
ldr r0, =gAnimBankAttacker ldr r0, =gBattleAnimAttacker
ldrb r0, [r0] ldrb r0, [r0]
bl GetBattlerSide bl GetBattlerSide
lsls r0, 24 lsls r0, 24
@ -4949,7 +4949,7 @@ _08172DC0:
beq _08172E4E beq _08172E4E
b _08172E84 b _08172E84
_08172DC6: _08172DC6:
ldr r0, =gAnimBankAttacker ldr r0, =gBattleAnimAttacker
ldrb r0, [r0] ldrb r0, [r0]
bl sub_80A8364 bl sub_80A8364
lsls r0, 24 lsls r0, 24
@ -5009,8 +5009,8 @@ _08172E14:
strh r0, [r4, 0x26] strh r0, [r4, 0x26]
b _08172E84 b _08172E84
_08172E4E: _08172E4E:
ldr r1, =gBankSpriteIds ldr r1, =gBattlerSpriteIds
ldr r4, =gAnimBankAttacker ldr r4, =gBattleAnimAttacker
ldrb r0, [r4] ldrb r0, [r4]
adds r0, r1 adds r0, r1
ldrb r1, [r0] ldrb r1, [r0]
@ -5048,7 +5048,7 @@ sub_8172E9C: @ 8172E9C
ldr r3, =gBattleAnimArgs ldr r3, =gBattleAnimArgs
ldr r1, =gBattleSpritesDataPtr ldr r1, =gBattleSpritesDataPtr
ldr r2, [r1] ldr r2, [r1]
ldr r1, =gAnimBankAttacker ldr r1, =gBattleAnimAttacker
ldrb r1, [r1] ldrb r1, [r1]
ldr r2, [r2] ldr r2, [r2]
lsls r1, 2 lsls r1, 2
@ -5068,7 +5068,7 @@ sub_8172ED0: @ 8172ED0
push {lr} push {lr}
lsls r0, 24 lsls r0, 24
lsrs r0, 24 lsrs r0, 24
ldr r2, =gAnimBankTarget ldr r2, =gBattleAnimTarget
ldr r1, =gEffectBank ldr r1, =gEffectBank
ldrb r1, [r1] ldrb r1, [r1]
strb r1, [r2] strb r1, [r2]
@ -5108,7 +5108,7 @@ sub_8172EF0: @ 8172EF0
bl GetMonData bl GetMonData
adds r4, r0, 0 adds r4, r0, 0
adds r0, r6, 0 adds r0, r6, 0
bl IsAnimBankSpriteVisible bl IsBattlerSpriteVisible
lsls r0, 24 lsls r0, 24
cmp r0, 0 cmp r0, 0
beq _08172FC8 beq _08172FC8
@ -5234,12 +5234,12 @@ _0817303A:
ldrb r0, [r4, 0x8] ldrb r0, [r4, 0x8]
mov r8, r0 mov r8, r0
movs r1, 0 movs r1, 0
bl GetBankCoord bl GetBattlerSpriteCoord
lsls r0, 24 lsls r0, 24
lsrs r5, r0, 24 lsrs r5, r0, 24
mov r0, r8 mov r0, r8
movs r1, 0x1 movs r1, 0x1
bl GetBankCoord bl GetBattlerSpriteCoord
lsls r0, 24 lsls r0, 24
lsrs r2, r0, 24 lsrs r2, r0, 24
movs r1, 0x1E movs r1, 0x1E
@ -5579,7 +5579,7 @@ sub_817330C: @ 817330C
lsls r0, 24 lsls r0, 24
lsrs r0, 24 lsrs r0, 24
movs r1, 0 movs r1, 0
bl GetBankCoord bl GetBattlerSpriteCoord
lsls r0, 24 lsls r0, 24
ldr r5, =gBattleAnimArgs ldr r5, =gBattleAnimArgs
lsrs r0, 24 lsrs r0, 24
@ -5591,7 +5591,7 @@ sub_817330C: @ 817330C
lsls r0, 24 lsls r0, 24
lsrs r0, 24 lsrs r0, 24
movs r1, 0x1 movs r1, 0x1
bl GetBankCoord bl GetBattlerSpriteCoord
lsls r0, 24 lsls r0, 24
lsrs r0, 24 lsrs r0, 24
ldrh r5, [r5, 0x6] ldrh r5, [r5, 0x6]
@ -5602,8 +5602,8 @@ sub_817330C: @ 817330C
adds r0, r4, 0 adds r0, r4, 0
bl sub_80A68D4 bl sub_80A68D4
ldr r2, =gSprites ldr r2, =gSprites
ldr r1, =gBankSpriteIds ldr r1, =gBattlerSpriteIds
ldr r0, =gAnimBankAttacker ldr r0, =gBattleAnimAttacker
ldrb r0, [r0] ldrb r0, [r0]
adds r0, r1 adds r0, r1
ldrb r1, [r0] ldrb r1, [r0]
@ -5627,8 +5627,8 @@ sub_817339C: @ 817339C
push {lr} push {lr}
adds r3, r0, 0 adds r3, r0, 0
ldr r2, =gSprites ldr r2, =gSprites
ldr r1, =gBankSpriteIds ldr r1, =gBattlerSpriteIds
ldr r0, =gAnimBankAttacker ldr r0, =gBattleAnimAttacker
ldrb r0, [r0] ldrb r0, [r0]
adds r0, r1 adds r0, r1
ldrb r1, [r0] ldrb r1, [r0]
@ -5678,8 +5678,8 @@ sub_8173400: @ 8173400
push {r4,r5,lr} push {r4,r5,lr}
adds r4, r0, 0 adds r4, r0, 0
ldr r5, =gSprites ldr r5, =gSprites
ldr r3, =gBankSpriteIds ldr r3, =gBattlerSpriteIds
ldr r2, =gAnimBankAttacker ldr r2, =gBattleAnimAttacker
ldrb r0, [r2] ldrb r0, [r2]
adds r0, r3 adds r0, r3
ldrb r1, [r0] ldrb r1, [r0]
@ -5733,7 +5733,7 @@ sub_817345C: @ 817345C
_08173478: _08173478:
movs r0, 0 movs r0, 0
bl GetBattlerAtPosition bl GetBattlerAtPosition
ldr r1, =gAnimBankAttacker ldr r1, =gBattleAnimAttacker
strb r0, [r1] strb r0, [r1]
movs r0, 0x1 movs r0, 0x1
b _08173498 b _08173498
@ -5741,12 +5741,12 @@ _08173478:
_0817348C: _0817348C:
movs r0, 0x1 movs r0, 0x1
bl GetBattlerAtPosition bl GetBattlerAtPosition
ldr r1, =gAnimBankAttacker ldr r1, =gBattleAnimAttacker
strb r0, [r1] strb r0, [r1]
movs r0, 0 movs r0, 0
_08173498: _08173498:
bl GetBattlerAtPosition bl GetBattlerAtPosition
ldr r1, =gAnimBankTarget ldr r1, =gBattleAnimTarget
strb r0, [r1] strb r0, [r1]
_081734A0: _081734A0:
adds r0, r4, 0 adds r0, r4, 0
@ -5812,13 +5812,13 @@ sub_817351C: @ 817351C
push {lr} push {lr}
lsls r0, 24 lsls r0, 24
lsrs r0, 24 lsrs r0, 24
ldr r3, =gAnimBankAttacker ldr r3, =gBattleAnimAttacker
ldr r1, =gBattleSpritesDataPtr ldr r1, =gBattleSpritesDataPtr
ldr r2, [r1] ldr r2, [r1]
ldr r1, [r2, 0x8] ldr r1, [r2, 0x8]
ldrh r1, [r1] ldrh r1, [r1]
strb r1, [r3] strb r1, [r3]
ldr r3, =gAnimBankTarget ldr r3, =gBattleAnimTarget
ldr r1, [r2, 0x8] ldr r1, [r2, 0x8]
ldrh r1, [r1] ldrh r1, [r1]
lsrs r1, 8 lsrs r1, 8

View File

@ -336,25 +336,25 @@ _08158DD0:
adds r2, r0, 0 adds r2, r0, 0
cmp r1, 0 cmp r1, 0
bne _08158DEC bne _08158DEC
ldr r0, =gAnimBankAttacker ldr r0, =gBattleAnimAttacker
ldrb r4, [r0] ldrb r4, [r0]
b _08158E12 b _08158E12
.pool .pool
_08158DEC: _08158DEC:
cmp r1, 0x1 cmp r1, 0x1
bne _08158DFC bne _08158DFC
ldr r0, =gAnimBankTarget ldr r0, =gBattleAnimTarget
ldrb r4, [r0] ldrb r4, [r0]
b _08158E12 b _08158E12
.pool .pool
_08158DFC: _08158DFC:
cmp r1, 0x2 cmp r1, 0x2
bne _08158E08 bne _08158E08
ldr r0, =gAnimBankAttacker ldr r0, =gBattleAnimAttacker
b _08158E0A b _08158E0A
.pool .pool
_08158E08: _08158E08:
ldr r0, =gAnimBankTarget ldr r0, =gBattleAnimTarget
_08158E0A: _08158E0A:
ldrb r1, [r0] ldrb r1, [r0]
movs r0, 0x2 movs r0, 0x2
@ -369,7 +369,7 @@ _08158E12:
bne _08158E38 bne _08158E38
_08158E1E: _08158E1E:
adds r0, r4, 0 adds r0, r4, 0
bl IsAnimBankSpriteVisible bl IsBattlerSpriteVisible
lsls r0, 24 lsls r0, 24
cmp r0, 0 cmp r0, 0
bne _08158E38 bne _08158E38
@ -383,7 +383,7 @@ _08158E38:
lsls r0, 24 lsls r0, 24
cmp r0, 0 cmp r0, 0
beq _08158E5C beq _08158E5C
ldr r1, =gBattlePartyID ldr r1, =gBattlerPartyIndexes
lsls r0, r4, 1 lsls r0, r4, 1
adds r0, r1 adds r0, r1
ldrh r1, [r0] ldrh r1, [r0]
@ -393,7 +393,7 @@ _08158E38:
b _08158E6A b _08158E6A
.pool .pool
_08158E5C: _08158E5C:
ldr r1, =gBattlePartyID ldr r1, =gBattlerPartyIndexes
lsls r0, r4, 1 lsls r0, r4, 1
adds r0, r1 adds r0, r1
ldrh r1, [r0] ldrh r1, [r0]
@ -461,25 +461,25 @@ _08158EE0:
adds r2, r0, 0 adds r2, r0, 0
cmp r1, 0 cmp r1, 0
bne _08158EFC bne _08158EFC
ldr r0, =gAnimBankAttacker ldr r0, =gBattleAnimAttacker
ldrb r4, [r0] ldrb r4, [r0]
b _08158F22 b _08158F22
.pool .pool
_08158EFC: _08158EFC:
cmp r1, 0x1 cmp r1, 0x1
bne _08158F0C bne _08158F0C
ldr r0, =gAnimBankTarget ldr r0, =gBattleAnimTarget
ldrb r4, [r0] ldrb r4, [r0]
b _08158F22 b _08158F22
.pool .pool
_08158F0C: _08158F0C:
cmp r1, 0x2 cmp r1, 0x2
bne _08158F18 bne _08158F18
ldr r0, =gAnimBankAttacker ldr r0, =gBattleAnimAttacker
b _08158F1A b _08158F1A
.pool .pool
_08158F18: _08158F18:
ldr r0, =gAnimBankTarget ldr r0, =gBattleAnimTarget
_08158F1A: _08158F1A:
ldrb r1, [r0] ldrb r1, [r0]
movs r0, 0x2 movs r0, 0x2
@ -494,7 +494,7 @@ _08158F22:
bne _08158F48 bne _08158F48
_08158F2E: _08158F2E:
adds r0, r4, 0 adds r0, r4, 0
bl IsAnimBankSpriteVisible bl IsBattlerSpriteVisible
lsls r0, 24 lsls r0, 24
cmp r0, 0 cmp r0, 0
bne _08158F48 bne _08158F48
@ -508,7 +508,7 @@ _08158F48:
lsls r0, 24 lsls r0, 24
cmp r0, 0 cmp r0, 0
beq _08158F6C beq _08158F6C
ldr r1, =gBattlePartyID ldr r1, =gBattlerPartyIndexes
lsls r0, r4, 1 lsls r0, r4, 1
adds r0, r1 adds r0, r1
ldrh r1, [r0] ldrh r1, [r0]
@ -518,7 +518,7 @@ _08158F48:
b _08158F7A b _08158F7A
.pool .pool
_08158F6C: _08158F6C:
ldr r1, =gBattlePartyID ldr r1, =gBattlerPartyIndexes
lsls r0, r4, 1 lsls r0, r4, 1
adds r0, r1 adds r0, r1
ldrh r1, [r0] ldrh r1, [r0]
@ -705,7 +705,7 @@ sub_81590B8: @ 81590B8
.pool .pool
_081590F8: _081590F8:
ldr r1, =gAnimSpeciesByBanks ldr r1, =gAnimSpeciesByBanks
ldr r0, =gAnimBankAttacker ldr r0, =gBattleAnimAttacker
ldrb r0, [r0] ldrb r0, [r0]
lsls r0, 1 lsls r0, 1
adds r0, r1 adds r0, r1

View File

@ -34,12 +34,12 @@ _0817C988:
movs r1, 0x81 movs r1, 0x81
lsls r1, 2 lsls r1, 2
adds r7, r0, r1 adds r7, r0, r1
ldr r5, =gBattleAttacker ldr r5, =gBattleMoveAttacker
ldrb r0, [r5] ldrb r0, [r5]
bl GetBattlerSide bl GetBattlerSide
lsls r0, 24 lsls r0, 24
lsrs r4, r0, 24 lsrs r4, r0, 24
ldr r0, =gBattleDefender ldr r0, =gBattleMoveTarget
ldrb r0, [r0] ldrb r0, [r0]
bl GetBattlerSide bl GetBattlerSide
lsls r0, 24 lsls r0, 24
@ -59,7 +59,7 @@ _0817C988:
str r0, [sp, 0x4] str r0, [sp, 0x4]
cmp r4, 0 cmp r4, 0
bne _0817CA00 bne _0817CA00
ldr r2, =gBattlePartyID ldr r2, =gBattlerPartyIndexes
ldrb r0, [r5] ldrb r0, [r5]
lsls r0, 1 lsls r0, 1
adds r0, r2 adds r0, r2
@ -70,7 +70,7 @@ _0817C988:
b _0817CA10 b _0817CA10
.pool .pool
_0817CA00: _0817CA00:
ldr r2, =gBattlePartyID ldr r2, =gBattlerPartyIndexes
ldrb r0, [r5] ldrb r0, [r5]
lsls r0, 1 lsls r0, 1
adds r0, r2 adds r0, r2
@ -83,7 +83,7 @@ _0817CA10:
str r1, [sp, 0x8] str r1, [sp, 0x8]
cmp r6, 0 cmp r6, 0
bne _0817CA3C bne _0817CA3C
ldr r0, =gBattleDefender ldr r0, =gBattleMoveTarget
ldrb r0, [r0] ldrb r0, [r0]
lsls r0, 1 lsls r0, 1
adds r0, r2 adds r0, r2
@ -94,7 +94,7 @@ _0817CA10:
b _0817CA4C b _0817CA4C
.pool .pool
_0817CA3C: _0817CA3C:
ldr r0, =gBattleDefender ldr r0, =gBattleMoveTarget
ldrb r0, [r0] ldrb r0, [r0]
lsls r0, 1 lsls r0, 1
adds r0, r2 adds r0, r2
@ -105,12 +105,12 @@ _0817CA3C:
_0817CA4C: _0817CA4C:
adds r1, r0 adds r1, r0
str r1, [sp, 0xC] str r1, [sp, 0xC]
ldr r0, =gBattleAttacker ldr r0, =gBattleMoveAttacker
ldrb r0, [r0] ldrb r0, [r0]
ldr r1, =gStringInfo ldr r1, =gStringInfo
ldr r1, [r1] ldr r1, [r1]
ldrh r1, [r1] ldrh r1, [r1]
bl GetBankMoveSlotId bl GetBattlerMoveSlotId
lsls r0, 24 lsls r0, 24
lsrs r0, 24 lsrs r0, 24
mov r10, r0 mov r10, r0
@ -134,13 +134,13 @@ _0817CA4C:
bl _0817E0A2 bl _0817E0A2
.pool .pool
_0817CA9C: _0817CA9C:
ldr r0, =gBattleAttacker ldr r0, =gBattleMoveAttacker
ldrb r0, [r0] ldrb r0, [r0]
bl GetBattlerPosition bl GetBattlerPosition
lsls r0, 24 lsls r0, 24
lsrs r0, 25 lsrs r0, 25
mov r8, r0 mov r8, r0
ldr r0, =gBattleDefender ldr r0, =gBattleMoveTarget
ldrb r0, [r0] ldrb r0, [r0]
bl GetBattlerPosition bl GetBattlerPosition
lsls r0, 24 lsls r0, 24
@ -571,8 +571,8 @@ _0817D0DC:
adds r3, r4 adds r3, r4
lsls r3, 2 lsls r3, 2
adds r3, r7, r3 adds r3, r7, r3
ldr r1, =gBattlePartyID ldr r1, =gBattlerPartyIndexes
ldr r0, =gBattleAttacker ldr r0, =gBattleMoveAttacker
ldrb r0, [r0] ldrb r0, [r0]
lsls r0, 1 lsls r0, 1
adds r0, r1 adds r0, r1
@ -601,8 +601,8 @@ _0817D124:
adds r2, r4 adds r2, r4
lsls r2, 2 lsls r2, 2
adds r2, r7, r2 adds r2, r7, r2
ldr r1, =gBattlePartyID ldr r1, =gBattlerPartyIndexes
ldr r0, =gBattleAttacker ldr r0, =gBattleMoveAttacker
ldrb r0, [r0] ldrb r0, [r0]
lsls r0, 1 lsls r0, 1
adds r0, r1 adds r0, r1
@ -634,8 +634,8 @@ _0817D16C:
adds r0, r4 adds r0, r4
lsls r0, 2 lsls r0, 2
adds r5, r7, r0 adds r5, r7, r0
ldr r1, =gBattlePartyID ldr r1, =gBattlerPartyIndexes
ldr r0, =gBattleAttacker ldr r0, =gBattleMoveAttacker
ldrb r0, [r0] ldrb r0, [r0]
lsls r0, 1 lsls r0, 1
adds r0, r1 adds r0, r1
@ -715,8 +715,8 @@ _0817D216:
adds r2, r4 adds r2, r4
lsls r2, 2 lsls r2, 2
adds r2, r7, r2 adds r2, r7, r2
ldr r1, =gBattlePartyID ldr r1, =gBattlerPartyIndexes
ldr r0, =gBattleAttacker ldr r0, =gBattleMoveAttacker
ldrb r0, [r0] ldrb r0, [r0]
lsls r0, 1 lsls r0, 1
adds r0, r1 adds r0, r1
@ -775,8 +775,8 @@ _0817D296:
adds r2, r4 adds r2, r4
lsls r2, 2 lsls r2, 2
adds r2, r7, r2 adds r2, r7, r2
ldr r1, =gBattlePartyID ldr r1, =gBattlerPartyIndexes
ldr r0, =gBattleAttacker ldr r0, =gBattleMoveAttacker
ldrb r0, [r0] ldrb r0, [r0]
lsls r0, 1 lsls r0, 1
adds r0, r1 adds r0, r1
@ -833,8 +833,8 @@ _0817D314:
lsls r0, r4, 4 lsls r0, r4, 4
adds r3, r0 adds r3, r0
adds r3, r7, r3 adds r3, r7, r3
ldr r1, =gBattlePartyID ldr r1, =gBattlerPartyIndexes
ldr r0, =gBattleAttacker ldr r0, =gBattleMoveAttacker
ldrb r0, [r0] ldrb r0, [r0]
lsls r0, 1 lsls r0, 1
adds r0, r1 adds r0, r1
@ -940,8 +940,8 @@ _0817D3F2:
bne _0817D3FE bne _0817D3FE
bl _0817E0A6 bl _0817E0A6
_0817D3FE: _0817D3FE:
ldr r0, =gBattleAttacker ldr r0, =gBattleMoveAttacker
ldr r1, =gBattleDefender ldr r1, =gBattleMoveTarget
ldrb r0, [r0] ldrb r0, [r0]
ldrb r1, [r1] ldrb r1, [r1]
cmp r0, r1 cmp r0, r1
@ -1014,8 +1014,8 @@ _0817D498:
lsls r0, r6, 4 lsls r0, r6, 4
adds r2, r0 adds r2, r0
adds r2, r7, r2 adds r2, r7, r2
ldr r1, =gBattlePartyID ldr r1, =gBattlerPartyIndexes
ldr r0, =gBattleAttacker ldr r0, =gBattleMoveAttacker
ldrb r0, [r0] ldrb r0, [r0]
lsls r0, 1 lsls r0, 1
adds r0, r1 adds r0, r1
@ -1091,8 +1091,8 @@ _0817D53C:
lsls r0, r6, 4 lsls r0, r6, 4
adds r2, r0 adds r2, r0
adds r2, r7, r2 adds r2, r7, r2
ldr r1, =gBattlePartyID ldr r1, =gBattlerPartyIndexes
ldr r0, =gBattleAttacker ldr r0, =gBattleMoveAttacker
ldrb r0, [r0] ldrb r0, [r0]
lsls r0, 1 lsls r0, 1
adds r0, r1 adds r0, r1
@ -1161,8 +1161,8 @@ _0817D5CE:
lsls r0, r6, 4 lsls r0, r6, 4
adds r2, r0 adds r2, r0
adds r2, r7, r2 adds r2, r7, r2
ldr r1, =gBattlePartyID ldr r1, =gBattlerPartyIndexes
ldr r0, =gBattleAttacker ldr r0, =gBattleMoveAttacker
ldrb r0, [r0] ldrb r0, [r0]
lsls r0, 1 lsls r0, 1
adds r0, r1 adds r0, r1
@ -1226,8 +1226,8 @@ _0817D65E:
lsls r0, r6, 4 lsls r0, r6, 4
adds r2, r0 adds r2, r0
adds r2, r7, r2 adds r2, r7, r2
ldr r1, =gBattlePartyID ldr r1, =gBattlerPartyIndexes
ldr r0, =gBattleAttacker ldr r0, =gBattleMoveAttacker
ldrb r0, [r0] ldrb r0, [r0]
lsls r0, 1 lsls r0, 1
adds r0, r1 adds r0, r1
@ -1301,7 +1301,7 @@ _0817D6F2:
strb r0, [r1] strb r0, [r1]
bl _0817E0A6 bl _0817E0A6
_0817D704: _0817D704:
ldr r5, =gBattlePartyID ldr r5, =gBattlerPartyIndexes
ldr r6, =gEffectBank ldr r6, =gEffectBank
ldrb r0, [r6] ldrb r0, [r6]
lsls r0, 1 lsls r0, 1
@ -1314,7 +1314,7 @@ _0817D704:
lsls r4, 3 lsls r4, 3
adds r2, r4 adds r2, r4
adds r2, r7, r2 adds r2, r7, r2
ldr r0, =gBattleAttacker ldr r0, =gBattleMoveAttacker
ldrb r0, [r0] ldrb r0, [r0]
lsls r0, 1 lsls r0, 1
adds r0, r5 adds r0, r5
@ -1353,8 +1353,8 @@ _0817D76C:
bne _0817D77E bne _0817D77E
bl _0817E0A6 bl _0817E0A6
_0817D77E: _0817D77E:
ldr r6, =gBattlePartyID ldr r6, =gBattlerPartyIndexes
ldr r5, =gBattleAttacker ldr r5, =gBattleMoveAttacker
ldrb r0, [r5] ldrb r0, [r5]
lsls r0, 1 lsls r0, 1
adds r0, r6 adds r0, r6
@ -1395,7 +1395,7 @@ _0817D7B2:
b _0817D934 b _0817D934
.pool .pool
_0817D7D8: _0817D7D8:
ldr r5, =gBattlePartyID ldr r5, =gBattlerPartyIndexes
ldr r6, =gEffectBank ldr r6, =gEffectBank
ldrb r0, [r6] ldrb r0, [r6]
lsls r0, 1 lsls r0, 1
@ -1408,7 +1408,7 @@ _0817D7D8:
lsls r4, 3 lsls r4, 3
adds r2, r4 adds r2, r4
adds r2, r7, r2 adds r2, r7, r2
ldr r0, =gBattleAttacker ldr r0, =gBattleMoveAttacker
ldrb r0, [r0] ldrb r0, [r0]
lsls r0, 1 lsls r0, 1
adds r0, r5 adds r0, r5
@ -1439,7 +1439,7 @@ _0817D7D8:
b _0817D88C b _0817D88C
.pool .pool
_0817D838: _0817D838:
ldr r5, =gBattlePartyID ldr r5, =gBattlerPartyIndexes
ldr r6, =gEffectBank ldr r6, =gEffectBank
ldrb r0, [r6] ldrb r0, [r6]
lsls r0, 1 lsls r0, 1
@ -1452,7 +1452,7 @@ _0817D838:
lsls r4, 3 lsls r4, 3
adds r2, r4 adds r2, r4
adds r2, r7, r2 adds r2, r7, r2
ldr r0, =gBattleAttacker ldr r0, =gBattleMoveAttacker
ldrb r0, [r0] ldrb r0, [r0]
lsls r0, 1 lsls r0, 1
adds r0, r5 adds r0, r5
@ -1496,9 +1496,9 @@ _0817D8A4:
bne _0817D8B6 bne _0817D8B6
bl _0817E0A6 bl _0817E0A6
_0817D8B6: _0817D8B6:
ldr r2, =gBattlePartyID ldr r2, =gBattlerPartyIndexes
mov r8, r2 mov r8, r2
ldr r6, =gBattleAttacker ldr r6, =gBattleMoveAttacker
ldrb r0, [r6] ldrb r0, [r6]
lsls r0, 1 lsls r0, 1
add r0, r8 add r0, r8
@ -1573,8 +1573,8 @@ _0817D94C:
lsls r0, r6, 4 lsls r0, r6, 4
adds r2, r0 adds r2, r0
adds r2, r7, r2 adds r2, r7, r2
ldr r1, =gBattlePartyID ldr r1, =gBattlerPartyIndexes
ldr r0, =gBattleAttacker ldr r0, =gBattleMoveAttacker
ldrb r0, [r0] ldrb r0, [r0]
lsls r0, 1 lsls r0, 1
adds r0, r1 adds r0, r1
@ -1627,7 +1627,7 @@ _0817D9AE:
movs r0, 0x9 movs r0, 0x9
b _0817E086 b _0817E086
_0817D9C2: _0817D9C2:
ldr r5, =gBattlePartyID ldr r5, =gBattlerPartyIndexes
ldr r6, =gEffectBank ldr r6, =gEffectBank
ldrb r0, [r6] ldrb r0, [r6]
lsls r0, 1 lsls r0, 1
@ -1640,7 +1640,7 @@ _0817D9C2:
lsls r4, 3 lsls r4, 3
adds r2, r4 adds r2, r4
adds r2, r7, r2 adds r2, r7, r2
ldr r0, =gBattleAttacker ldr r0, =gBattleMoveAttacker
ldrb r0, [r0] ldrb r0, [r0]
lsls r0, 1 lsls r0, 1
adds r0, r5 adds r0, r5
@ -1671,8 +1671,8 @@ _0817D9C2:
b _0817DB76 b _0817DB76
.pool .pool
_0817DA24: _0817DA24:
ldr r1, =gBattlePartyID ldr r1, =gBattlerPartyIndexes
ldr r0, =gBattleAttacker ldr r0, =gBattleMoveAttacker
ldrb r0, [r0] ldrb r0, [r0]
lsls r0, 1 lsls r0, 1
adds r0, r1 adds r0, r1
@ -1702,7 +1702,7 @@ _0817DA48:
b _0817E0A6 b _0817E0A6
.pool .pool
_0817DA68: _0817DA68:
ldr r5, =gBattlePartyID ldr r5, =gBattlerPartyIndexes
ldr r6, =gEffectBank ldr r6, =gEffectBank
ldrb r0, [r6] ldrb r0, [r6]
lsls r0, 1 lsls r0, 1
@ -1715,7 +1715,7 @@ _0817DA68:
lsls r4, 3 lsls r4, 3
adds r2, r4 adds r2, r4
adds r2, r7, r2 adds r2, r7, r2
ldr r0, =gBattleAttacker ldr r0, =gBattleMoveAttacker
ldrb r0, [r0] ldrb r0, [r0]
lsls r0, 1 lsls r0, 1
adds r0, r5 adds r0, r5
@ -1747,8 +1747,8 @@ _0817DA68:
b _0817DB76 b _0817DB76
.pool .pool
_0817DACC: _0817DACC:
ldr r1, =gBattlePartyID ldr r1, =gBattlerPartyIndexes
ldr r0, =gBattleAttacker ldr r0, =gBattleMoveAttacker
ldrb r0, [r0] ldrb r0, [r0]
lsls r0, 1 lsls r0, 1
adds r0, r1 adds r0, r1
@ -1790,7 +1790,7 @@ _0817DB10:
b _0817E0A6 b _0817E0A6
.pool .pool
_0817DB24: _0817DB24:
ldr r5, =gBattlePartyID ldr r5, =gBattlerPartyIndexes
ldr r6, =gEffectBank ldr r6, =gEffectBank
ldrb r0, [r6] ldrb r0, [r6]
lsls r0, 1 lsls r0, 1
@ -1803,7 +1803,7 @@ _0817DB24:
lsls r4, 3 lsls r4, 3
adds r3, r4 adds r3, r4
adds r3, r7, r3 adds r3, r7, r3
ldr r0, =gBattleAttacker ldr r0, =gBattleMoveAttacker
ldrb r0, [r0] ldrb r0, [r0]
lsls r0, 1 lsls r0, 1
adds r0, r5 adds r0, r5
@ -1838,8 +1838,8 @@ _0817DB76:
b _0817E0A6 b _0817E0A6
.pool .pool
_0817DB90: _0817DB90:
ldr r1, =gBattlePartyID ldr r1, =gBattlerPartyIndexes
ldr r0, =gBattleAttacker ldr r0, =gBattleMoveAttacker
ldrb r0, [r0] ldrb r0, [r0]
lsls r0, 1 lsls r0, 1
adds r0, r1 adds r0, r1
@ -1875,8 +1875,8 @@ _0817DBD4:
lsls r0, r1, 4 lsls r0, r1, 4
adds r3, r0 adds r3, r0
adds r3, r7, r3 adds r3, r7, r3
ldr r1, =gBattlePartyID ldr r1, =gBattlerPartyIndexes
ldr r0, =gBattleAttacker ldr r0, =gBattleMoveAttacker
ldrb r0, [r0] ldrb r0, [r0]
lsls r0, 1 lsls r0, 1
adds r0, r1 adds r0, r1
@ -1943,8 +1943,8 @@ _0817DC62:
adds r2, r6 adds r2, r6
lsls r2, 2 lsls r2, 2
adds r2, r7, r2 adds r2, r7, r2
ldr r1, =gBattlePartyID ldr r1, =gBattlerPartyIndexes
ldr r0, =gBattleAttacker ldr r0, =gBattleMoveAttacker
ldrb r0, [r0] ldrb r0, [r0]
lsls r0, 1 lsls r0, 1
adds r0, r1 adds r0, r1
@ -2021,8 +2021,8 @@ _0817DCFC:
lsls r0, r4, 4 lsls r0, r4, 4
adds r2, r0 adds r2, r0
adds r2, r7, r2 adds r2, r7, r2
ldr r1, =gBattlePartyID ldr r1, =gBattlerPartyIndexes
ldr r0, =gBattleAttacker ldr r0, =gBattleMoveAttacker
ldrb r0, [r0] ldrb r0, [r0]
lsls r0, 1 lsls r0, 1
adds r0, r1 adds r0, r1
@ -2049,8 +2049,8 @@ _0817DD38:
lsls r0, r4, 4 lsls r0, r4, 4
adds r2, r0 adds r2, r0
adds r2, r7, r2 adds r2, r7, r2
ldr r1, =gBattlePartyID ldr r1, =gBattlerPartyIndexes
ldr r0, =gBattleAttacker ldr r0, =gBattleMoveAttacker
ldrb r0, [r0] ldrb r0, [r0]
lsls r0, 1 lsls r0, 1
adds r0, r1 adds r0, r1
@ -2121,8 +2121,8 @@ _0817DDC8:
adds r2, r4 adds r2, r4
lsls r2, 2 lsls r2, 2
adds r2, r7, r2 adds r2, r7, r2
ldr r1, =gBattlePartyID ldr r1, =gBattlerPartyIndexes
ldr r0, =gBattleAttacker ldr r0, =gBattleMoveAttacker
ldrb r0, [r0] ldrb r0, [r0]
lsls r0, 1 lsls r0, 1
adds r0, r1 adds r0, r1
@ -2154,8 +2154,8 @@ _0817DE10:
adds r2, r4 adds r2, r4
lsls r2, 2 lsls r2, 2
adds r2, r7, r2 adds r2, r7, r2
ldr r1, =gBattlePartyID ldr r1, =gBattlerPartyIndexes
ldr r0, =gBattleAttacker ldr r0, =gBattleMoveAttacker
ldrb r0, [r0] ldrb r0, [r0]
lsls r0, 1 lsls r0, 1
adds r0, r1 adds r0, r1
@ -2253,8 +2253,8 @@ _0817DEDC:
adds r2, r4 adds r2, r4
lsls r2, 2 lsls r2, 2
adds r2, r7, r2 adds r2, r7, r2
ldr r1, =gBattlePartyID ldr r1, =gBattlerPartyIndexes
ldr r0, =gBattleAttacker ldr r0, =gBattleMoveAttacker
ldrb r0, [r0] ldrb r0, [r0]
lsls r0, 1 lsls r0, 1
adds r0, r1 adds r0, r1
@ -2331,8 +2331,8 @@ _0817DF70:
adds r2, r4 adds r2, r4
lsls r2, 2 lsls r2, 2
adds r2, r7, r2 adds r2, r7, r2
ldr r1, =gBattlePartyID ldr r1, =gBattlerPartyIndexes
ldr r0, =gBattleAttacker ldr r0, =gBattleMoveAttacker
ldrb r0, [r0] ldrb r0, [r0]
lsls r0, 1 lsls r0, 1
adds r0, r1 adds r0, r1
@ -2413,8 +2413,8 @@ _0817DFE6:
negs r0, r0 negs r0, r0
ands r0, r2 ands r0, r2
strb r0, [r1] strb r0, [r1]
ldr r1, =gBattlePartyID ldr r1, =gBattlerPartyIndexes
ldr r0, =gBattleAttacker ldr r0, =gBattleMoveAttacker
ldrb r0, [r0] ldrb r0, [r0]
lsls r0, 1 lsls r0, 1
adds r0, r1 adds r0, r1
@ -2557,14 +2557,14 @@ _0817E122:
lsls r1, 2 lsls r1, 2
adds r1, r0, r1 adds r1, r0, r1
str r1, [sp, 0x8] str r1, [sp, 0x8]
ldr r2, =gBattleAttacker ldr r2, =gBattleMoveAttacker
mov r10, r2 mov r10, r2
ldrb r0, [r2] ldrb r0, [r2]
bl GetBattlerSide bl GetBattlerSide
lsls r0, 24 lsls r0, 24
lsrs r0, 24 lsrs r0, 24
mov r9, r0 mov r9, r0
ldr r0, =gBattleDefender ldr r0, =gBattleMoveTarget
ldrb r0, [r0] ldrb r0, [r0]
bl GetBattlerSide bl GetBattlerSide
lsls r0, 24 lsls r0, 24
@ -2572,7 +2572,7 @@ _0817E122:
mov r1, r10 mov r1, r10
ldrb r0, [r1] ldrb r0, [r1]
adds r1, r7, 0 adds r1, r7, 0
bl GetBankMoveSlotId bl GetBattlerMoveSlotId
lsls r0, 24 lsls r0, 24
lsrs r6, r0, 24 lsrs r6, r0, 24
cmp r6, 0x3 cmp r6, 0x3
@ -2604,7 +2604,7 @@ _0817E184:
mov r2, r10 mov r2, r10
ldrb r1, [r2] ldrb r1, [r2]
lsls r1, 1 lsls r1, 1
ldr r2, =gBattlePartyID ldr r2, =gBattlerPartyIndexes
adds r1, r2 adds r1, r2
ldrh r2, [r1] ldrh r2, [r1]
adds r2, 0x1 adds r2, 0x1
@ -2685,7 +2685,7 @@ _0817E23C:
mov r1, r10 mov r1, r10
ldrb r0, [r1] ldrb r0, [r1]
lsls r0, 1 lsls r0, 1
ldr r2, =gBattlePartyID ldr r2, =gBattlerPartyIndexes
adds r0, r2 adds r0, r2
ldrh r1, [r0] ldrh r1, [r0]
adds r1, 0x1 adds r1, 0x1
@ -2723,7 +2723,7 @@ _0817E27A:
mov r1, r10 mov r1, r10
ldrb r0, [r1] ldrb r0, [r1]
lsls r0, 1 lsls r0, 1
ldr r1, =gBattlePartyID ldr r1, =gBattlerPartyIndexes
adds r0, r1 adds r0, r1
ldrh r1, [r0] ldrh r1, [r0]
adds r1, 0x1 adds r1, 0x1
@ -2812,7 +2812,7 @@ sub_817E32C: @ 817E32C
movs r1, 0x81 movs r1, 0x81
lsls r1, 2 lsls r1, 2
adds r4, r0, r1 adds r4, r0, r1
ldr r0, =gBattleAttacker ldr r0, =gBattleMoveAttacker
ldrb r0, [r0] ldrb r0, [r0]
bl GetBattlerSide bl GetBattlerSide
lsls r0, 24 lsls r0, 24
@ -3244,12 +3244,12 @@ sub_817E684: @ 817E684
movs r2, 0x81 movs r2, 0x81
lsls r2, 2 lsls r2, 2
adds r7, r0, r2 adds r7, r0, r2
ldr r0, =gBattleAttacker ldr r0, =gBattleMoveAttacker
ldrb r0, [r0] ldrb r0, [r0]
bl GetBattlerSide bl GetBattlerSide
lsls r0, 24 lsls r0, 24
lsrs r4, r0, 24 lsrs r4, r0, 24
ldr r0, =gBattleDefender ldr r0, =gBattleMoveTarget
ldrb r0, [r0] ldrb r0, [r0]
bl GetBattlerSide bl GetBattlerSide
lsls r0, 24 lsls r0, 24
@ -3297,8 +3297,8 @@ _0817E6F0:
.4byte _0817E760 .4byte _0817E760
.4byte _0817E760 .4byte _0817E760
_0817E760: _0817E760:
ldr r1, =gBattlePartyID ldr r1, =gBattlerPartyIndexes
ldr r0, =gBattleAttacker ldr r0, =gBattleMoveAttacker
ldrb r0, [r0] ldrb r0, [r0]
lsls r0, 1 lsls r0, 1
adds r0, r1 adds r0, r1
@ -3324,13 +3324,13 @@ _0817E760:
_0817E79C: _0817E79C:
ldr r1, =gUnknown_0860A834 ldr r1, =gUnknown_0860A834
add r1, r12 add r1, r12
ldr r7, =gBattlePartyID ldr r7, =gBattlerPartyIndexes
lsls r0, r4, 1 lsls r0, r4, 1
adds r0, r4 adds r0, r4
lsls r2, r0, 4 lsls r2, r0, 4
ldr r4, =0x0000ffff ldr r4, =0x0000ffff
ldr r1, [r1] ldr r1, [r1]
ldr r3, =gBattleAttacker ldr r3, =gBattleMoveAttacker
ldrh r0, [r1] ldrh r0, [r1]
cmp r6, r0 cmp r6, r0
bne _0817E7E0 bne _0817E7E0
@ -3708,13 +3708,13 @@ sub_817EA80: @ 817EA80
movs r1, 0x81 movs r1, 0x81
lsls r1, 2 lsls r1, 2
adds r5, r0, r1 adds r5, r0, r1
ldr r3, =gBattleAttacker ldr r3, =gBattleMoveAttacker
mov r8, r3 mov r8, r3
ldrb r0, [r3] ldrb r0, [r3]
bl GetBattlerSide bl GetBattlerSide
lsls r0, 24 lsls r0, 24
lsrs r4, r0, 24 lsrs r4, r0, 24
ldr r0, =gBattleDefender ldr r0, =gBattleMoveTarget
ldrb r0, [r0] ldrb r0, [r0]
bl GetBattlerSide bl GetBattlerSide
lsls r0, 24 lsls r0, 24
@ -4005,8 +4005,8 @@ _0817ECCC:
ldrb r0, [r0] ldrb r0, [r0]
lsrs r0, 5 lsrs r0, 5
subs r6, r0, 0x1 subs r6, r0, 0x1
ldr r1, =gBattlePartyID ldr r1, =gBattlerPartyIndexes
ldr r0, =gBattleAttacker ldr r0, =gBattleMoveAttacker
ldrb r0, [r0] ldrb r0, [r0]
lsls r0, 1 lsls r0, 1
adds r0, r1 adds r0, r1
@ -4164,8 +4164,8 @@ _0817EE1C:
cmp r7, 0x1 cmp r7, 0x1
bne _0817EEBC bne _0817EEBC
adds r2, r4, 0 adds r2, r4, 0
ldr r1, =gBattlePartyID ldr r1, =gBattlerPartyIndexes
ldr r0, =gBattleAttacker ldr r0, =gBattleMoveAttacker
ldrb r0, [r0] ldrb r0, [r0]
lsls r0, 1 lsls r0, 1
adds r0, r1 adds r0, r1
@ -4227,7 +4227,7 @@ _0817EE8E:
b _0817EEBC b _0817EEBC
_0817EE96: _0817EE96:
adds r2, r4, 0 adds r2, r4, 0
ldr r1, =gBattlePartyID ldr r1, =gBattlerPartyIndexes
mov r3, r8 mov r3, r8
ldrb r0, [r3] ldrb r0, [r3]
lsls r0, 1 lsls r0, 1
@ -4269,7 +4269,7 @@ sub_817EECC: @ 817EECC
beq _0817EEE6 beq _0817EEE6
b _0817F1FA b _0817F1FA
_0817EEE6: _0817EEE6:
ldr r4, =gBattleAttacker ldr r4, =gBattleMoveAttacker
ldrb r0, [r4] ldrb r0, [r4]
bl GetBattlerSide bl GetBattlerSide
lsls r0, 24 lsls r0, 24
@ -4291,7 +4291,7 @@ _0817EEF8:
bgt _0817EF10 bgt _0817EF10
b _0817F1FA b _0817F1FA
_0817EF10: _0817EF10:
ldr r0, =gBattleDefender ldr r0, =gBattleMoveTarget
ldrb r0, [r0] ldrb r0, [r0]
muls r0, r1 muls r0, r1
adds r0, r5 adds r0, r5
@ -4367,7 +4367,7 @@ _0817EF8A:
beq _0817EF98 beq _0817EF98
b _0817F1FA b _0817F1FA
_0817EF98: _0817EF98:
ldr r2, =gBattleAttacker ldr r2, =gBattleMoveAttacker
ldrb r0, [r2] ldrb r0, [r2]
adds r0, r6 adds r0, r6
ldrb r0, [r0] ldrb r0, [r0]
@ -4386,11 +4386,11 @@ _0817EF98:
mov r10, r3 mov r10, r3
mov r8, r0 mov r8, r0
add r7, sp, 0x10 add r7, sp, 0x10
ldr r4, =gBattleDefender ldr r4, =gBattleMoveTarget
mov r9, r4 mov r9, r4
_0817EFC2: _0817EFC2:
lsls r1, r5, 1 lsls r1, r5, 1
ldr r6, =gBattleAttacker ldr r6, =gBattleMoveAttacker
ldrb r0, [r6] ldrb r0, [r6]
movs r2, 0x58 movs r2, 0x58
muls r0, r2 muls r0, r2
@ -4420,7 +4420,7 @@ _0817EFC2:
lsls r1, 1 lsls r1, 1
adds r1, r4 adds r1, r4
ldrh r3, [r1] ldrh r3, [r1]
ldr r2, =gBattleAttacker ldr r2, =gBattleMoveAttacker
ldrb r0, [r2] ldrb r0, [r2]
movs r4, 0x58 movs r4, 0x58
muls r0, r4 muls r0, r4
@ -4437,7 +4437,7 @@ _0817EFC2:
str r4, [sp] str r4, [sp]
movs r4, 0 movs r4, 0
str r4, [sp, 0x4] str r4, [sp, 0x4]
ldr r6, =gBattleAttacker ldr r6, =gBattleMoveAttacker
ldrb r4, [r6] ldrb r4, [r6]
str r4, [sp, 0x8] str r4, [sp, 0x8]
mov r6, r9 mov r6, r9
@ -4448,7 +4448,7 @@ _0817EFC2:
ldr r4, =gBattleMoveDamage ldr r4, =gBattleMoveDamage
str r3, [r4] str r3, [r4]
ldr r1, =gStatuses3 ldr r1, =gStatuses3
ldr r2, =gBattleAttacker ldr r2, =gBattleMoveAttacker
ldrb r0, [r2] ldrb r0, [r2]
lsls r0, 2 lsls r0, 2
adds r0, r1 adds r0, r1
@ -4472,7 +4472,7 @@ _0817EFC2:
str r0, [r4] str r0, [r4]
_0817F06A: _0817F06A:
ldr r0, =gProtectStructs ldr r0, =gProtectStructs
ldr r6, =gBattleAttacker ldr r6, =gBattleMoveAttacker
ldrb r1, [r6] ldrb r1, [r6]
lsls r1, 4 lsls r1, 4
adds r1, r0 adds r1, r0
@ -4513,9 +4513,9 @@ _0817F0B4:
cmp r5, 0x3 cmp r5, 0x3
ble _0817EFC2 ble _0817EFC2
movs r5, 0 movs r5, 0
ldr r3, =gBattleAttacker ldr r3, =gBattleMoveAttacker
ldr r6, =gMoveSelectionCursor ldr r6, =gMoveSelectionCursor
ldr r4, =gBattlePartyID ldr r4, =gBattlerPartyIndexes
mov r8, r4 mov r8, r4
movs r7, 0x64 movs r7, 0x64
mov r9, r7 mov r9, r7
@ -4545,9 +4545,9 @@ _0817F0D8:
movs r7, 0 movs r7, 0
_0817F0F6: _0817F0F6:
movs r5, 0 movs r5, 0
ldr r4, =gBattleDefender ldr r4, =gBattleMoveTarget
ldr r6, =gEnemyParty ldr r6, =gEnemyParty
ldr r0, =gBattleAttacker ldr r0, =gBattleMoveAttacker
ldrb r0, [r0] ldrb r0, [r0]
add r0, r10 add r0, r10
ldrb r3, [r0] ldrb r3, [r0]
@ -4582,7 +4582,7 @@ _0817F11A:
adds r6, r0, 0 adds r6, r0, 0
lsls r6, 16 lsls r6, 16
lsrs r6, 16 lsrs r6, 16
ldr r2, =gBattleAttacker ldr r2, =gBattleMoveAttacker
ldrb r0, [r2] ldrb r0, [r2]
lsls r0, 1 lsls r0, 1
add r0, r8 add r0, r8
@ -4598,7 +4598,7 @@ _0817F11A:
adds r1, r0, 0 adds r1, r0, 0
lsls r1, 16 lsls r1, 16
lsrs r1, 16 lsrs r1, 16
ldr r4, =gBattleAttacker ldr r4, =gBattleMoveAttacker
ldrb r3, [r4] ldrb r3, [r4]
mov r2, r10 mov r2, r10
adds r0, r3, r2 adds r0, r3, r2
@ -4625,7 +4625,7 @@ _0817F1D4:
_0817F1DC: _0817F1DC:
ldr r2, =gBattleMoveDamage ldr r2, =gBattleMoveDamage
ldr r1, =gMoveSelectionCursor ldr r1, =gMoveSelectionCursor
ldr r0, =gBattleAttacker ldr r0, =gBattleMoveAttacker
ldrb r0, [r0] ldrb r0, [r0]
adds r0, r1 adds r0, r1
ldrb r0, [r0] ldrb r0, [r0]
@ -4695,7 +4695,7 @@ _0817F270:
cmp r2, 0x95 cmp r2, 0x95
bne _0817F294 bne _0817F294
ldr r2, =gBattleMons ldr r2, =gBattleMons
ldr r0, =gBattleAttacker ldr r0, =gBattleMoveAttacker
ldrb r1, [r0] ldrb r1, [r0]
movs r0, 0x58 movs r0, 0x58
muls r0, r1 muls r0, r1
@ -4793,8 +4793,8 @@ _0817F324:
.pool .pool
thumb_func_end sub_817F2A8 thumb_func_end sub_817F2A8
thumb_func_start GetBankMoveSlotId thumb_func_start GetBattlerMoveSlotId
GetBankMoveSlotId: @ 817F33C GetBattlerMoveSlotId: @ 817F33C
push {r4-r7,lr} push {r4-r7,lr}
lsls r0, 24 lsls r0, 24
lsrs r5, r0, 24 lsrs r5, r0, 24
@ -4809,7 +4809,7 @@ GetBankMoveSlotId: @ 817F33C
ldr r6, =gPlayerParty ldr r6, =gPlayerParty
_0817F356: _0817F356:
movs r4, 0 movs r4, 0
ldr r1, =gBattlePartyID ldr r1, =gBattlerPartyIndexes
lsls r0, r5, 1 lsls r0, r5, 1
adds r5, r0, r1 adds r5, r0, r1
b _0817F36E b _0817F36E
@ -4835,7 +4835,7 @@ _0817F388:
pop {r4-r7} pop {r4-r7}
pop {r1} pop {r1}
bx r1 bx r1
thumb_func_end GetBankMoveSlotId thumb_func_end GetBattlerMoveSlotId
thumb_func_start sub_817F394 thumb_func_start sub_817F394
sub_817F394: @ 817F394 sub_817F394: @ 817F394

View File

@ -5354,7 +5354,7 @@ sub_8164E04: @ 8164E04
adds r0, r2 adds r0, r2
ldrh r1, [r5] ldrh r1, [r5]
bl sub_8165B88 bl sub_8165B88
ldr r6, =gBattlePartyID ldr r6, =gBattlerPartyIndexes
ldrh r0, [r6, 0x2] ldrh r0, [r6, 0x2]
movs r5, 0x64 movs r5, 0x64
muls r0, r5 muls r0, r5

View File

@ -1058,12 +1058,12 @@ _080D8004:
strb r2, [r1, 0x3] strb r2, [r1, 0x3]
ldr r0, =gBattleTypeFlags ldr r0, =gBattleTypeFlags
str r4, [r0] str r4, [r0]
ldr r4, =gBattleAttacker ldr r4, =gBattleMoveAttacker
strb r2, [r4] strb r2, [r4]
ldr r0, =gBattleDefender ldr r0, =gBattleMoveTarget
strb r3, [r0] strb r3, [r0]
bl sub_80DB0C4 bl sub_80DB0C4
ldr r2, =gBankSpriteIds ldr r2, =gBattlerSpriteIds
ldrb r1, [r4] ldrb r1, [r4]
adds r1, r2 adds r1, r2
strb r0, [r1] strb r0, [r1]
@ -2547,8 +2547,8 @@ _080D8DD0:
lsls r4, 3 lsls r4, 3
adds r4, r0 adds r4, r0
strh r5, [r4, 0xC] strh r5, [r4, 0xC]
ldr r1, =gBankSpriteIds ldr r1, =gBattlerSpriteIds
ldr r0, =gBattleAttacker ldr r0, =gBattleMoveAttacker
ldrb r0, [r0] ldrb r0, [r0]
adds r0, r1 adds r0, r1
strb r5, [r0] strb r5, [r0]
@ -13796,9 +13796,9 @@ sub_80DEA20: @ 80DEA20
push {lr} push {lr}
ldr r0, =SpriteCallbackDummy ldr r0, =SpriteCallbackDummy
bl CreateInvisibleSpriteWithCallback bl CreateInvisibleSpriteWithCallback
ldr r1, =gBankSpriteIds ldr r1, =gBattlerSpriteIds
strb r0, [r1, 0x3] strb r0, [r1, 0x3]
ldr r0, =gBattleDefender ldr r0, =gBattleMoveTarget
ldrb r0, [r0] ldrb r0, [r0]
adds r0, r1 adds r0, r1
ldrb r1, [r0] ldrb r1, [r0]
@ -13817,7 +13817,7 @@ sub_80DEA20: @ 80DEA20
thumb_func_start sub_80DEA5C thumb_func_start sub_80DEA5C
sub_80DEA5C: @ 80DEA5C sub_80DEA5C: @ 80DEA5C
push {r4,lr} push {r4,lr}
ldr r0, =gBankSpriteIds ldr r0, =gBattlerSpriteIds
ldrb r0, [r0, 0x3] ldrb r0, [r0, 0x3]
lsls r4, r0, 4 lsls r4, r0, 4
adds r4, r0 adds r4, r0
@ -13829,13 +13829,13 @@ sub_80DEA5C: @ 80DEA5C
strh r0, [r4, 0x26] strh r0, [r4, 0x26]
movs r0, 0x3 movs r0, 0x3
movs r1, 0 movs r1, 0
bl GetBankCoord bl GetBattlerSpriteCoord
lsls r0, 24 lsls r0, 24
lsrs r0, 24 lsrs r0, 24
strh r0, [r4, 0x20] strh r0, [r4, 0x20]
movs r0, 0x3 movs r0, 0x3
movs r1, 0x1 movs r1, 0x1
bl GetBankCoord bl GetBattlerSpriteCoord
lsls r0, 24 lsls r0, 24
lsrs r0, 24 lsrs r0, 24
strh r0, [r4, 0x22] strh r0, [r4, 0x22]
@ -13905,12 +13905,12 @@ _080DEAD0:
.4byte _080DEB60 .4byte _080DEB60
.4byte _080DEB60 .4byte _080DEB60
_080DEB54: _080DEB54:
ldr r1, =gBattleDefender ldr r1, =gBattleMoveTarget
movs r0, 0x2 movs r0, 0x2
b _080DEB64 b _080DEB64
.pool .pool
_080DEB60: _080DEB60:
ldr r1, =gBattleDefender ldr r1, =gBattleMoveTarget
movs r0, 0x3 movs r0, 0x3
_080DEB64: _080DEB64:
strb r0, [r1] strb r0, [r1]

View File

@ -16048,7 +16048,7 @@ _081B8AFC:
adds r0, r5, 0 adds r0, r5, 0
bl sub_81B8F38 bl sub_81B8F38
lsls r0, 24 lsls r0, 24
ldr r2, =gBattlePartyID ldr r2, =gBattlerPartyIndexes
lsls r1, r4, 1 lsls r1, r4, 1
adds r1, r2 adds r1, r2
lsrs r0, 24 lsrs r0, 24
@ -16115,7 +16115,7 @@ _081B8BA8:
ldr r1, =gUnknown_0203CEE8 ldr r1, =gUnknown_0203CEE8
movs r0, 0x1 movs r0, 0x1
strb r0, [r1] strb r0, [r1]
ldr r1, =gBattlePartyID ldr r1, =gBattlerPartyIndexes
ldr r0, =gBankInMenu ldr r0, =gBankInMenu
ldrb r0, [r0] ldrb r0, [r0]
lsls r0, 1 lsls r0, 1
@ -16150,7 +16150,7 @@ _081B8BFC:
_081B8C20: _081B8C20:
ldr r0, =gBankInMenu ldr r0, =gBankInMenu
ldrb r0, [r0] ldrb r0, [r0]
ldr r1, =gBattlePartyID ldr r1, =gBattlerPartyIndexes
lsls r0, 1 lsls r0, 1
adds r0, r1 adds r0, r1
ldrb r0, [r0] ldrb r0, [r0]
@ -16230,7 +16230,7 @@ _081B8CBE:
movs r0, 0 movs r0, 0
bl GetBattlerAtPosition bl GetBattlerAtPosition
mov r2, sp mov r2, sp
ldr r1, =gBattlePartyID ldr r1, =gBattlerPartyIndexes
lsls r0, 24 lsls r0, 24
lsrs r0, 23 lsrs r0, 23
adds r0, r1 adds r0, r1
@ -16257,7 +16257,7 @@ _081B8CFC:
movs r0, 0 movs r0, 0
bl GetBattlerAtPosition bl GetBattlerAtPosition
mov r1, sp mov r1, sp
ldr r4, =gBattlePartyID ldr r4, =gBattlerPartyIndexes
lsls r0, 24 lsls r0, 24
lsrs r0, 23 lsrs r0, 23
adds r0, r4 adds r0, r4
@ -16388,7 +16388,7 @@ _081B8DF0:
bne _081B8E28 bne _081B8E28
movs r3, 0x1 movs r3, 0x1
mov r2, sp mov r2, sp
ldr r1, =gBattlePartyID ldr r1, =gBattlerPartyIndexes
lsls r0, r4, 1 lsls r0, r4, 1
adds r0, r1 adds r0, r1
ldrh r0, [r0] ldrh r0, [r0]
@ -16412,7 +16412,7 @@ _081B8E1A:
_081B8E28: _081B8E28:
movs r3, 0x2 movs r3, 0x2
mov r1, sp mov r1, sp
ldr r2, =gBattlePartyID ldr r2, =gBattlerPartyIndexes
lsls r0, r4, 1 lsls r0, r4, 1
adds r0, r2 adds r0, r2
ldrh r0, [r0] ldrh r0, [r0]

View File

@ -130,7 +130,7 @@ _0806BDC4:
ldrb r0, [r0] ldrb r0, [r0]
cmp r1, r0 cmp r1, r0
bge _0806BE70 bge _0806BE70
ldr r2, =gBattlePartyID ldr r2, =gBattlerPartyIndexes
lsls r0, r1, 1 lsls r0, r1, 1
adds r0, r2 adds r0, r2
ldrh r3, [r0] ldrh r3, [r0]
@ -973,7 +973,7 @@ _0806C4FC:
ldrb r0, [r2] ldrb r0, [r2]
bics r0, r1 bics r0, r1
strb r0, [r2] strb r0, [r2]
ldr r1, =gBattlePartyID ldr r1, =gBattlerPartyIndexes
lsls r0, r3, 1 lsls r0, r3, 1
adds r0, r1 adds r0, r1
ldrb r0, [r0] ldrb r0, [r0]
@ -1155,9 +1155,9 @@ _0806C6AE:
movs r0, 0 movs r0, 0
movs r1, 0 movs r1, 0
movs r2, 0 movs r2, 0
bl EmitGetMonData bl BtlController_EmitGetMonData
ldrb r0, [r4] ldrb r0, [r4]
bl MarkBufferBankForExecution bl MarkBattlerForControllerExec
strb r5, [r4] strb r5, [r4]
b _0806C6EC b _0806C6EC
.pool .pool

View File

@ -735,7 +735,7 @@ BattleScript_AlreadyPoisoned::
goto BattleScript_MoveEnd goto BattleScript_MoveEnd
BattleScript_ImmunityProtected:: BattleScript_ImmunityProtected::
copybyte gEffectBank, gBattleDefender copybyte gEffectBank, gBattleMoveTarget
setbyte cMULTISTRING_CHOOSER, 0x0 setbyte cMULTISTRING_CHOOSER, 0x0
call BattleScript_PSNPrevention call BattleScript_PSNPrevention
goto BattleScript_MoveEnd goto BattleScript_MoveEnd
@ -1055,7 +1055,7 @@ BattleScript_AlreadyParalyzed::
goto BattleScript_MoveEnd goto BattleScript_MoveEnd
BattleScript_LimberProtected:: BattleScript_LimberProtected::
copybyte gEffectBank, gBattleDefender copybyte gEffectBank, gBattleMoveTarget
setbyte cMULTISTRING_CHOOSER, 0x0 setbyte cMULTISTRING_CHOOSER, 0x0
call BattleScript_PRLZPrevention call BattleScript_PRLZPrevention
goto BattleScript_MoveEnd goto BattleScript_MoveEnd
@ -1513,7 +1513,7 @@ BattleScript_EffectCurse::
jumpifstat ATTACKER, NOT_EQUAL, ATK, 0xC, BattleScript_CurseTrySpeed jumpifstat ATTACKER, NOT_EQUAL, ATK, 0xC, BattleScript_CurseTrySpeed
jumpifstat ATTACKER, EQUAL, DEF, 0xC, BattleScript_ButItFailed jumpifstat ATTACKER, EQUAL, DEF, 0xC, BattleScript_ButItFailed
BattleScript_CurseTrySpeed:: BattleScript_CurseTrySpeed::
copybyte gBattleDefender, gBattleAttacker copybyte gBattleMoveTarget, gBattleMoveAttacker
setbyte sANIM_TURN, 0x1 setbyte sANIM_TURN, 0x1
attackanimation attackanimation
waitanimation waitanimation
@ -1534,7 +1534,7 @@ BattleScript_CurseTryDefence::
BattleScript_CurseEnd:: BattleScript_CurseEnd::
goto BattleScript_MoveEnd goto BattleScript_MoveEnd
BattleScript_GhostCurse:: BattleScript_GhostCurse::
jumpifbytenotequal gBattleAttacker, gBattleDefender, BattleScript_DoGhostCurse jumpifbytenotequal gBattleMoveAttacker, gBattleMoveTarget, BattleScript_DoGhostCurse
getmovetarget ATTACKER getmovetarget ATTACKER
BattleScript_DoGhostCurse:: BattleScript_DoGhostCurse::
attackcanceler attackcanceler
@ -2217,7 +2217,7 @@ BattleScript_EffectWillOWisp::
goto BattleScript_MoveEnd goto BattleScript_MoveEnd
BattleScript_WaterVeilPrevents:: BattleScript_WaterVeilPrevents::
copybyte gEffectBank, gBattleDefender copybyte gEffectBank, gBattleMoveTarget
setbyte cMULTISTRING_CHOOSER, 0x0 setbyte cMULTISTRING_CHOOSER, 0x0
call BattleScript_BRNPrevention call BattleScript_BRNPrevention
goto BattleScript_MoveEnd goto BattleScript_MoveEnd
@ -2598,11 +2598,11 @@ BattleScript_EffectTeeterDance::
attackcanceler attackcanceler
attackstring attackstring
ppreduce ppreduce
setbyte gBattleDefender, 0x0 setbyte gBattleMoveTarget, 0x0
BattleScript_TeeterDanceLoop:: BattleScript_TeeterDanceLoop::
movevaluescleanup movevaluescleanup
setmoveeffect EFFECT_CONFUSION setmoveeffect EFFECT_CONFUSION
jumpifbyteequal gBattleAttacker, gBattleDefender, BattleScript_TeeterDanceLoopIncrement jumpifbyteequal gBattleMoveAttacker, gBattleMoveTarget, BattleScript_TeeterDanceLoopIncrement
jumpifability TARGET, ABILITY_OWN_TEMPO, BattleScript_TeeterDanceOwnTempoPrevents jumpifability TARGET, ABILITY_OWN_TEMPO, BattleScript_TeeterDanceOwnTempoPrevents
jumpifstatus2 TARGET, STATUS2_SUBSTITUTE, BattleScript_TeeterDanceSubstitutePrevents jumpifstatus2 TARGET, STATUS2_SUBSTITUTE, BattleScript_TeeterDanceSubstitutePrevents
jumpifstatus2 TARGET, STATUS2_CONFUSION, BattleScript_TeeterDanceAlreadyConfused jumpifstatus2 TARGET, STATUS2_CONFUSION, BattleScript_TeeterDanceAlreadyConfused
@ -2618,8 +2618,8 @@ BattleScript_TeeterDanceDoMoveEndIncrement::
setbyte sMOVEEND_STATE, 0x0 setbyte sMOVEEND_STATE, 0x0
moveend 0x2, 0x10 moveend 0x2, 0x10
BattleScript_TeeterDanceLoopIncrement:: BattleScript_TeeterDanceLoopIncrement::
addbyte gBattleDefender, 0x1 addbyte gBattleMoveTarget, 0x1
jumpifbytenotequal gBattleDefender, gBattlersCount, BattleScript_TeeterDanceLoop jumpifbytenotequal gBattleMoveTarget, gBattlersCount, BattleScript_TeeterDanceLoop
end end
BattleScript_TeeterDanceOwnTempoPrevents:: BattleScript_TeeterDanceOwnTempoPrevents::
@ -3228,7 +3228,7 @@ BattleScript_DamagingWeatherContinues::
playanimation2 ATTACKER, sANIM_ARG1, NULL playanimation2 ATTACKER, sANIM_ARG1, NULL
setbyte gBattleCommunication, 0x0 setbyte gBattleCommunication, 0x0
BattleScript_DamagingWeatherLoop:: BattleScript_DamagingWeatherLoop::
copyarraywithindex gBattleAttacker, gBattleTurnOrder, gBattleCommunication, 0x1 copyarraywithindex gBattleMoveAttacker, gBattleTurnOrder, gBattleCommunication, 0x1
weatherdamage weatherdamage
jumpifword EQUAL, gBattleMoveDamage, 0x0, BattleScript_DamagingWeatherLoopIncrement jumpifword EQUAL, gBattleMoveDamage, 0x0, BattleScript_DamagingWeatherLoopIncrement
printfromtable gSandStormHailDmgStringIds printfromtable gSandStormHailDmgStringIds
@ -3521,7 +3521,7 @@ BattleScript_RapidSpinAway::
BattleScript_WrapFree:: BattleScript_WrapFree::
printstring STRINGID_PKMNGOTFREE printstring STRINGID_PKMNGOTFREE
waitmessage 0x40 waitmessage 0x40
copybyte gBattleDefender, sBANK copybyte gBattleMoveTarget, sBANK
return return
BattleScript_LeechSeedFree:: BattleScript_LeechSeedFree::
@ -4053,7 +4053,7 @@ BattleScript_82DB4B8::
BattleScript_82DB4BE:: BattleScript_82DB4BE::
pause 0x20 pause 0x20
BattleScript_82DB4C1:: BattleScript_82DB4C1::
setbyte gBattleDefender, 0x0 setbyte gBattleMoveTarget, 0x0
setstatchanger ATK, 1, TRUE setstatchanger ATK, 1, TRUE
BattleScript_82DB4CD:: BattleScript_82DB4CD::
trygetintimidatetarget BattleScript_82DB51B trygetintimidatetarget BattleScript_82DB51B
@ -4068,7 +4068,7 @@ BattleScript_82DB4CD::
printstring STRINGID_PKMNCUTSATTACKWITH printstring STRINGID_PKMNCUTSATTACKWITH
waitmessage 0x40 waitmessage 0x40
BattleScript_82DB510:: BattleScript_82DB510::
addbyte gBattleDefender, 0x1 addbyte gBattleMoveTarget, 0x1
goto BattleScript_82DB4CD goto BattleScript_82DB4CD
BattleScript_82DB51B:: BattleScript_82DB51B::
return return

View File

@ -45,8 +45,8 @@ extern u8 gAnimFriendship;
extern u16 gWeatherMoveAnim; extern u16 gWeatherMoveAnim;
extern s16 gBattleAnimArgs[ANIM_ARGS_COUNT]; extern s16 gBattleAnimArgs[ANIM_ARGS_COUNT];
extern u8 gAnimMoveTurn; extern u8 gAnimMoveTurn;
extern u8 gAnimBankAttacker; extern u8 gBattleAnimAttacker;
extern u8 gAnimBankTarget; extern u8 gBattleAnimTarget;
extern u16 gAnimSpeciesByBanks[MAX_BATTLERS_COUNT]; extern u16 gAnimSpeciesByBanks[MAX_BATTLERS_COUNT];
extern u8 gUnknown_02038440; extern u8 gUnknown_02038440;
@ -56,7 +56,7 @@ void LaunchBattleAnimation(const u8 *const animsTable[], u16 tableId, bool8 isMo
void DestroyAnimSprite(struct Sprite *sprite); void DestroyAnimSprite(struct Sprite *sprite);
void DestroyAnimVisualTask(u8 taskId); void DestroyAnimVisualTask(u8 taskId);
void DestroyAnimSoundTask(u8 taskId); void DestroyAnimSoundTask(u8 taskId);
bool8 IsAnimBankSpriteVisible(u8 bank); bool8 IsBattlerSpriteVisible(u8 bank);
void sub_80A438C(u8 bank, bool8 toBG_2, bool8 setSpriteInvisible); void sub_80A438C(u8 bank, bool8 toBG_2, bool8 setSpriteInvisible);
bool8 IsContest(void); bool8 IsContest(void);
s8 BattleAnimAdjustPanning(s8 pan); s8 BattleAnimAdjustPanning(s8 pan);
@ -85,17 +85,17 @@ enum
BANK_Y_POS, BANK_Y_POS,
}; };
u8 GetBankCoord(u8 bank, u8 attributeId); u8 GetBattlerSpriteCoord(u8 bank, u8 attributeId);
bool8 IsBankSpritePresent(u8 bank); bool8 IsBattlerSpritePresent(u8 bank);
void sub_80A6C68(u8 arg0); void sub_80A6C68(u8 arg0);
u8 GetAnimBankSpriteId(u8 wantedBank); u8 GetBattlerSpriteId(u8 wantedBank);
bool8 IsDoubleBattle(void); bool8 IsDoubleBattle(void);
u8 sub_80A6D94(void); u8 sub_80A6D94(void);
u8 sub_80A8364(u8); u8 sub_80A8364(u8);
void StoreSpriteCallbackInData6(struct Sprite *sprite, void (*spriteCallback)(struct Sprite*)); void StoreSpriteCallbackInData6(struct Sprite *sprite, void (*spriteCallback)(struct Sprite*));
void oamt_add_pos2_onto_pos1(struct Sprite *sprite); void oamt_add_pos2_onto_pos1(struct Sprite *sprite);
u8 GetBankSpriteDefault_Y(u8 bank); u8 GetBattlerSpriteDefault_Y(u8 bank);
u8 sub_80A82E4(u8 bank); u8 sub_80A82E4(u8 bank);
u8 GetSubstituteSpriteDefault_Y(u8 bank); u8 GetSubstituteSpriteDefault_Y(u8 bank);

View File

@ -181,62 +181,62 @@ void sub_8033648(void);
void PrepareBufferDataTransferLink(u8 bufferId, u16 size, u8 *data); void PrepareBufferDataTransferLink(u8 bufferId, u16 size, u8 *data);
// emitters // emitters
void EmitGetMonData(u8 bufferId, u8 requestId, u8 monToCheck); void BtlController_EmitGetMonData(u8 bufferId, u8 requestId, u8 monToCheck);
void EmitGetRawMonData(u8 bufferId, u8 monId, u8 bytes); // unused void BtlController_EmitGetRawMonData(u8 bufferId, u8 monId, u8 bytes); // unused
void EmitSetMonData(u8 bufferId, u8 requestId, u8 monToCheck, u8 bytes, void *data); void BtlController_EmitSetMonData(u8 bufferId, u8 requestId, u8 monToCheck, u8 bytes, void *data);
void EmitSetRawMonData(u8 bufferId, u8 monId, u8 bytes, void *data); // unused void BtlController_EmitSetRawMonData(u8 bufferId, u8 monId, u8 bytes, void *data); // unused
void EmitLoadMonSprite(u8 bufferId); void BtlController_EmitLoadMonSprite(u8 bufferId);
void EmitSwitchInAnim(u8 bufferId, u8 partyId, bool8 dontClearSubstituteBit); void BtlController_EmitSwitchInAnim(u8 bufferId, u8 partyId, bool8 dontClearSubstituteBit);
void EmitReturnMonToBall(u8 bufferId, u8 arg1); void BtlController_EmitReturnMonToBall(u8 bufferId, u8 arg1);
void EmitDrawTrainerPic(u8 bufferId); void BtlController_EmitDrawTrainerPic(u8 bufferId);
void EmitTrainerSlide(u8 bufferId); void BtlController_EmitTrainerSlide(u8 bufferId);
void EmitTrainerSlideBack(u8 bufferId); void BtlController_EmitTrainerSlideBack(u8 bufferId);
void EmitFaintAnimation(u8 bufferId); void BtlController_EmitFaintAnimation(u8 bufferId);
void EmitPaletteFade(u8 bufferId); // unused void BtlController_EmitPaletteFade(u8 bufferId); // unused
void EmitSuccessBallThrowAnim(u8 bufferId); // unused void BtlController_EmitSuccessBallThrowAnim(u8 bufferId); // unused
void EmitBallThrowAnim(u8 bufferId, u8 caseId); void BtlController_EmitBallThrowAnim(u8 bufferId, u8 caseId);
void EmitPause(u8 bufferId, u8 toWait, void *data); // unused void BtlController_EmitPause(u8 bufferId, u8 toWait, void *data); // unused
void EmitMoveAnimation(u8 bufferId, u16 move, u8 turnOfMove, u16 movePower, s32 dmg, u8 friendship, struct DisableStruct *disableStructPtr, u8 multihit); void BtlController_EmitMoveAnimation(u8 bufferId, u16 move, u8 turnOfMove, u16 movePower, s32 dmg, u8 friendship, struct DisableStruct *disableStructPtr, u8 multihit);
void EmitPrintString(u8 bufferId, u16 stringId); void BtlController_EmitPrintString(u8 bufferId, u16 stringId);
void EmitPrintSelectionString(u8 bufferId, u16 stringId); void BtlController_EmitPrintSelectionString(u8 bufferId, u16 stringId);
void EmitChooseAction(u8 bufferId, u8 arg1, u16 arg2); void BtlController_EmitChooseAction(u8 bufferId, u8 arg1, u16 arg2);
void EmitUnknownYesNoBox(u8 bufferId); void BtlController_EmitUnknownYesNoBox(u8 bufferId);
void EmitChooseMove(u8 bufferId, bool8 isDoubleBattle, bool8 NoPpNumber, struct ChooseMoveStruct *movePpData); void BtlController_EmitChooseMove(u8 bufferId, bool8 isDoubleBattle, bool8 NoPpNumber, struct ChooseMoveStruct *movePpData);
void EmitChooseItem(u8 bufferId, u8* arg1); void BtlController_EmitChooseItem(u8 bufferId, u8* arg1);
void EmitChoosePokemon(u8 bufferId, u8 caseId, u8 arg2, u8 abilityId, u8* arg4); void BtlController_EmitChoosePokemon(u8 bufferId, u8 caseId, u8 arg2, u8 abilityId, u8* arg4);
void EmitCmd23(u8 bufferId); // unused void BtlController_EmitCmd23(u8 bufferId); // unused
void EmitHealthBarUpdate(u8 bufferId, u16 hpValue); void BtlController_EmitHealthBarUpdate(u8 bufferId, u16 hpValue);
void EmitExpUpdate(u8 bufferId, u8 partyId, u16 expPoints); void BtlController_EmitExpUpdate(u8 bufferId, u8 partyId, u16 expPoints);
void EmitStatusIconUpdate(u8 bufferId, u32 status1, u32 status2); void BtlController_EmitStatusIconUpdate(u8 bufferId, u32 status1, u32 status2);
void EmitStatusAnimation(u8 bufferId, bool8 status2, u32 status); void BtlController_EmitStatusAnimation(u8 bufferId, bool8 status2, u32 status);
void EmitStatusXor(u8 bufferId, u8 b); // unused void BtlController_EmitStatusXor(u8 bufferId, u8 b); // unused
void EmitDataTransfer(u8 bufferId, u16 size, void *data); void BtlController_EmitDataTransfer(u8 bufferId, u16 size, void *data);
void EmitDMA3Transfer(u8 bufferId, void *dst, u16 size, void *data); // unused void BtlController_EmitDMA3Transfer(u8 bufferId, void *dst, u16 size, void *data); // unused
void EmitPlayBGM(u8 bufferId, u16 songId, void *unusedDumbDataParameter); // unused void BtlController_EmitPlayBGM(u8 bufferId, u16 songId, void *unusedDumbDataParameter); // unused
void EmitCmd32(u8 bufferId, u16 size, void *c); // unused void BtlController_EmitCmd32(u8 bufferId, u16 size, void *c); // unused
void EmitTwoReturnValues(u8 bufferId, u8 arg1, u16 arg2); void BtlController_EmitTwoReturnValues(u8 bufferId, u8 arg1, u16 arg2);
void EmitChosenMonReturnValue(u8 bufferId, u8 b, u8 *c); void BtlController_EmitChosenMonReturnValue(u8 bufferId, u8 b, u8 *c);
void EmitOneReturnValue(u8 bufferId, u16 arg1); void BtlController_EmitOneReturnValue(u8 bufferId, u16 arg1);
void EmitOneReturnValue_Duplicate(u8 bufferId, u16 b); void BtlController_EmitOneReturnValue_Duplicate(u8 bufferId, u16 b);
void EmitCmd37(u8 bufferId); // unused void BtlController_EmitCmd37(u8 bufferId); // unused
void EmitCmd38(u8 bufferId, u8 b); // unused void BtlController_EmitCmd38(u8 bufferId, u8 b); // unused
void EmitCmd39(u8 bufferId); // unused void BtlController_EmitCmd39(u8 bufferId); // unused
void EmitCmd40(u8 bufferId); // unused void BtlController_EmitCmd40(u8 bufferId); // unused
void EmitHitAnimation(u8 bufferId); void BtlController_EmitHitAnimation(u8 bufferId);
void EmitCmd42(u8 bufferId); void BtlController_EmitCmd42(u8 bufferId);
void EmitPlaySE(u8 bufferId, u16 songId); void BtlController_EmitPlaySE(u8 bufferId, u16 songId);
void EmitPlayFanfareOrBGM(u8 bufferId, u16 songId, bool8 playBGM); void BtlController_EmitPlayFanfareOrBGM(u8 bufferId, u16 songId, bool8 playBGM);
void EmitFaintingCry(u8 bufferId); void BtlController_EmitFaintingCry(u8 bufferId);
void EmitIntroSlide(u8 bufferId, u8 terrainId); void BtlController_EmitIntroSlide(u8 bufferId, u8 terrainId);
void EmitIntroTrainerBallThrow(u8 bufferId); void BtlController_EmitIntroTrainerBallThrow(u8 bufferId);
void EmitDrawPartyStatusSummary(u8 bufferId, struct HpAndStatus* hpAndStatus, u8 arg2); void BtlController_EmitDrawPartyStatusSummary(u8 bufferId, struct HpAndStatus* hpAndStatus, u8 arg2);
void EmitCmd49(u8 bufferId); void BtlController_EmitCmd49(u8 bufferId);
void EmitCmd50(u8 bufferId); void BtlController_EmitCmd50(u8 bufferId);
void EmitSpriteInvisibility(u8 bufferId, bool8 isInvisible); void BtlController_EmitSpriteInvisibility(u8 bufferId, bool8 isInvisible);
void EmitBattleAnimation(u8 bufferId, u8 animationId, u16 argument); void BtlController_EmitBattleAnimation(u8 bufferId, u8 animationId, u16 argument);
void EmitLinkStandbyMsg(u8 bufferId, u8 arg1, bool32 arg2); void BtlController_EmitLinkStandbyMsg(u8 bufferId, u8 arg1, bool32 arg2);
void EmitResetActionMoveSelection(u8 bufferId, u8 caseId); void BtlController_EmitResetActionMoveSelection(u8 bufferId, u8 caseId);
void EmitCmd55(u8 bufferId, u8 arg1); void BtlController_EmitCmd55(u8 bufferId, u8 arg1);
// player controller // player controller
void SetControllerToPlayer(void); void SetControllerToPlayer(void);

View File

@ -39,8 +39,8 @@ void sub_805EAE8(void);
void sub_805EB9C(u8 affineMode); void sub_805EB9C(u8 affineMode);
void LoadAndCreateEnemyShadowSprites(void); void LoadAndCreateEnemyShadowSprites(void);
void SpriteCB_SetInvisible(struct Sprite *sprite); void SpriteCB_SetInvisible(struct Sprite *sprite);
void SetBankEnemyShadowSpriteCallback(u8 bank, u16 species); void SetBattlerShadowSpriteCallback(u8 bank, u16 species);
void EnemyShadowCallbackToSetInvisible(u8 bank); void HideBattlerShadowSprite(u8 bank);
void sub_805EF14(void); void sub_805EF14(void);
void ClearTemporarySpeciesSpriteData(u8 bank, bool8 dontClearSubstitute); void ClearTemporarySpeciesSpriteData(u8 bank, bool8 dontClearSubstitute);
void AllocateMonSpritesGfx(void); void AllocateMonSpritesGfx(void);

View File

@ -54,7 +54,7 @@ enum
HEALTHBOX_SAFARI_BALLS_TEXT HEALTHBOX_SAFARI_BALLS_TEXT
}; };
u8 CreateBankHealthboxSprites(u8 bank); u8 CreateHealthboxSprites(u8 bank);
u8 CreateSafariPlayerHealthboxSprites(void); u8 CreateSafariPlayerHealthboxSprites(void);
void SetBattleBarStruct(u8 bank, u8 healthboxSpriteId, s32 maxVal, s32 currVal, s32 receivedValue); void SetBattleBarStruct(u8 bank, u8 healthboxSpriteId, s32 maxVal, s32 currVal, s32 receivedValue);
void SetHealthboxSpriteInvisible(u8 healthboxSpriteId); void SetHealthboxSpriteInvisible(u8 healthboxSpriteId);
@ -62,7 +62,7 @@ void SetHealthboxSpriteVisible(u8 healthboxSpriteId);
void DestoryHealthboxSprite(u8 healthboxSpriteId); void DestoryHealthboxSprite(u8 healthboxSpriteId);
void DummyBattleInterfaceFunc(u8 healthboxSpriteId, bool8 isDoubleBattleBankOnly); void DummyBattleInterfaceFunc(u8 healthboxSpriteId, bool8 isDoubleBattleBankOnly);
void UpdateOamPriorityInAllHealthboxes(u8 priority); void UpdateOamPriorityInAllHealthboxes(u8 priority);
void SetBankHealthboxSpritePos(u8 bank); void InitBattlerHealthboxCoords(u8 bank);
void UpdateHpTextInHealthbox(u8 healthboxSpriteId, s16 value, u8 maxOrCurrent); void UpdateHpTextInHealthbox(u8 healthboxSpriteId, s16 value, u8 maxOrCurrent);
void SwapHpBarsWithHpText(void); void SwapHpBarsWithHpText(void);
u8 CreatePartyStatusSummarySprites(u8 bank, struct HpAndStatus *partyInfo, u8 arg2, bool8 isBattleStart); u8 CreatePartyStatusSummarySprites(u8 bank, struct HpAndStatus *partyInfo, u8 arg2, bool8 isBattleStart);

View File

@ -6,6 +6,6 @@ void sub_817E0FC(u16 move, u16 weatherFlags, struct DisableStruct *disableStruct
void sub_817E32C(u8 animationId); void sub_817E32C(u8 animationId);
void sub_817E3F4(void); void sub_817E3F4(void);
void sub_817F2A8(void); void sub_817F2A8(void);
u8 GetBankMoveSlotId(u8 bank, u16 move); u8 GetBattlerMoveSlotId(u8 bank, u16 move);
#endif // GUARD_BATTLE_LINK_817C95C_H #endif // GUARD_BATTLE_LINK_817C95C_H

View File

@ -52,7 +52,7 @@
void AI_CalcDmg(u8 bankAtk, u8 bankDef); void AI_CalcDmg(u8 bankAtk, u8 bankDef);
u8 TypeCalc(u16 move, u8 bankAtk, u8 bankDef); u8 TypeCalc(u16 move, u8 bankAtk, u8 bankDef);
u8 AI_TypeCalc(u16 move, u16 targetSpecies, u8 targetAbility); u8 AI_TypeCalc(u16 move, u16 targetSpecies, u8 targetAbility);
u8 BankGetTurnOrder(u8 bank); u8 GetBattlerTurnOrderNum(u8 bank);
void SetMoveEffect(bool8 primary, u8 certain); void SetMoveEffect(bool8 primary, u8 certain);
void BattleDestroyYesNoCursorAt(u8 cursorPosition); void BattleDestroyYesNoCursorAt(u8 cursorPosition);
void BattleCreateYesNoCursorAt(u8 cursorPosition); void BattleCreateYesNoCursorAt(u8 cursorPosition);

View File

@ -48,8 +48,8 @@ u8 GetBattleBank(u8 caseId);
void PressurePPLose(u8 bankDef, u8 bankAtk, u16 move); void PressurePPLose(u8 bankDef, u8 bankAtk, u16 move);
void PressurePPLoseOnUsingPerishSong(u8 bankAtk); void PressurePPLoseOnUsingPerishSong(u8 bankAtk);
void PressurePPLoseOnUsingImprision(u8 bankAtk); void PressurePPLoseOnUsingImprision(u8 bankAtk);
void MarkAllBufferBanksForExecution(void); // unused void MarkAllBattlersForControllerExec(void); // unused
void MarkBufferBankForExecution(u8 bank); void MarkBattlerForControllerExec(u8 bank);
void sub_803F850(u8 arg0); void sub_803F850(u8 arg0);
void CancelMultiTurnMoves(u8 bank); void CancelMultiTurnMoves(u8 bank);
bool8 WasUnableToUseMove(u8 bank); bool8 WasUnableToUseMove(u8 bank);

View File

@ -631,7 +631,7 @@ bool8 IsShinyOtIdPersonality(u32 otId, u32 personality);
void MonGainEVs(struct Pokemon *mon, u16 defeatedSpecies); void MonGainEVs(struct Pokemon *mon, u16 defeatedSpecies);
bool8 IsTradedMon(struct Pokemon *mon); bool8 IsTradedMon(struct Pokemon *mon);
void HandleSetPokedexFlag(u16 nationalNum, u8 caseId, u32 personality); void HandleSetPokedexFlag(u16 nationalNum, u8 caseId, u32 personality);
s32 GetBankMultiplayerId(u16 a1); s32 GetBattlerMultiplayerId(u16 a1);
bool16 sub_806D82C(u8 id); bool16 sub_806D82C(u8 id);
u16 MonTryLearningNewMove(struct Pokemon* mon, bool8); u16 MonTryLearningNewMove(struct Pokemon* mon, bool8);
void sub_8068AA4(void); // sets stats for deoxys void sub_8068AA4(void); // sets stats for deoxys

View File

@ -7,9 +7,9 @@ extern u8 gUnknown_0203C7B4;
void sub_8184DA4(u8 arg0); void sub_8184DA4(u8 arg0);
void sub_8184E58(void); void sub_8184E58(void);
void RecordedBattle_SetBankAction(u8 bank, u8 action); void RecordedBattle_SetBattlerAction(u8 bank, u8 action);
void RecordedBattle_ClearBankAction(u8 bank, u8 bytesToClear); void RecordedBattle_ClearBattlerAction(u8 bank, u8 bytesToClear);
u8 RecordedBattle_ReadBankAction(u8 bank); u8 RecordedBattle_GetBankAction(u8 bank);
u8 sub_81850D0(void); u8 sub_81850D0(void);
u8 sub_81850DC(u8 *arg0); u8 sub_81850DC(u8 *arg0);
void sub_81851A8(u8 *arg0); void sub_81851A8(u8 *arg0);

View File

@ -48,14 +48,14 @@ extern u32 gBattleTypeFlags;
extern u8 gActiveBattler; extern u8 gActiveBattler;
extern struct BattlePokemon gBattleMons[MAX_BATTLERS_COUNT]; extern struct BattlePokemon gBattleMons[MAX_BATTLERS_COUNT];
extern u16 gCurrentMove; extern u16 gCurrentMove;
extern u8 gBattleDefender; extern u8 gBattleMoveTarget;
extern u8 gAbsentBattlerFlags; extern u8 gAbsentBattlerFlags;
extern u16 gLastMoves[MAX_BATTLERS_COUNT]; extern u16 gLastMoves[MAX_BATTLERS_COUNT];
extern u16 gTrainerBattleOpponent_A; extern u16 gTrainerBattleOpponent_A;
extern u16 gTrainerBattleOpponent_B; extern u16 gTrainerBattleOpponent_B;
extern u32 gStatuses3[MAX_BATTLERS_COUNT]; extern u32 gStatuses3[MAX_BATTLERS_COUNT];
extern u16 gSideStatuses[2]; extern u16 gSideStatuses[2];
extern u16 gBattlePartyID[MAX_BATTLERS_COUNT]; extern u16 gBattlerPartyIndexes[MAX_BATTLERS_COUNT];
extern u16 gDynamicBasePower; extern u16 gDynamicBasePower;
extern u8 gMoveResultFlags; extern u8 gMoveResultFlags;
extern s32 gBattleMoveDamage; extern s32 gBattleMoveDamage;
@ -367,14 +367,14 @@ void BattleAI_SetupAIData(u8 defaultScoreMoves)
// decide a random target bank in doubles // decide a random target bank in doubles
if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE) if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE)
{ {
gBattleDefender = (Random() & BIT_FLANK) + (GetBattlerSide(gActiveBattler) ^ BIT_SIDE); gBattleMoveTarget = (Random() & BIT_FLANK) + (GetBattlerSide(gActiveBattler) ^ BIT_SIDE);
if (gAbsentBattlerFlags & gBitTable[gBattleDefender]) if (gAbsentBattlerFlags & gBitTable[gBattleMoveTarget])
gBattleDefender ^= BIT_FLANK; gBattleMoveTarget ^= BIT_FLANK;
} }
// in singles there's only one choice // in singles there's only one choice
else else
{ {
gBattleDefender = sBank_AI ^ BIT_SIDE; gBattleMoveTarget = sBank_AI ^ BIT_SIDE;
} }
if (gBattleTypeFlags & BATTLE_TYPE_RECORDED) if (gBattleTypeFlags & BATTLE_TYPE_RECORDED)
@ -491,7 +491,7 @@ static u8 BattleAI_ChooseMoveOrAction_Doubles(void)
else else
BattleAI_SetupAIData(0xF); BattleAI_SetupAIData(0xF);
gBattleDefender = i; gBattleMoveTarget = i;
if ((i & BIT_SIDE) != (sBank_AI & BIT_SIDE)) if ((i & BIT_SIDE) != (sBank_AI & BIT_SIDE))
RecordLastUsedMoveByTarget(); RecordLastUsedMoveByTarget();
@ -573,8 +573,8 @@ static u8 BattleAI_ChooseMoveOrAction_Doubles(void)
} }
} }
gBattleDefender = mostViableTargetsArray[Random() % mostViableTargetsNo]; gBattleMoveTarget = mostViableTargetsArray[Random() % mostViableTargetsNo];
return actionOrMoveIndex[gBattleDefender]; return actionOrMoveIndex[gBattleMoveTarget];
} }
static void BattleAI_DoAIProcessing(void) static void BattleAI_DoAIProcessing(void)
@ -627,12 +627,12 @@ static void RecordLastUsedMoveByTarget(void)
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
{ {
if (gBattleResources->battleHistory->usedMoves[gBattleDefender].moves[i] == gLastMoves[gBattleDefender]) if (gBattleResources->battleHistory->usedMoves[gBattleMoveTarget].moves[i] == gLastMoves[gBattleMoveTarget])
break; break;
if (gBattleResources->battleHistory->usedMoves[gBattleDefender].moves[i] != gLastMoves[gBattleDefender] // HACK: This redundant condition is a hack to make the asm match. if (gBattleResources->battleHistory->usedMoves[gBattleMoveTarget].moves[i] != gLastMoves[gBattleMoveTarget] // HACK: This redundant condition is a hack to make the asm match.
&& gBattleResources->battleHistory->usedMoves[gBattleDefender].moves[i] == 0) && gBattleResources->battleHistory->usedMoves[gBattleMoveTarget].moves[i] == 0)
{ {
gBattleResources->battleHistory->usedMoves[gBattleDefender].moves[i] = gLastMoves[gBattleDefender]; gBattleResources->battleHistory->usedMoves[gBattleMoveTarget].moves[i] = gLastMoves[gBattleMoveTarget];
break; break;
} }
} }
@ -723,7 +723,7 @@ static void BattleAICmd_if_hp_less_than(void)
if (gAIScriptPtr[1] == AI_USER) if (gAIScriptPtr[1] == AI_USER)
bank = sBank_AI; bank = sBank_AI;
else else
bank = gBattleDefender; bank = gBattleMoveTarget;
if ((u32)(100 * gBattleMons[bank].hp / gBattleMons[bank].maxHP) < gAIScriptPtr[2]) if ((u32)(100 * gBattleMons[bank].hp / gBattleMons[bank].maxHP) < gAIScriptPtr[2])
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 3); gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 3);
@ -738,7 +738,7 @@ static void BattleAICmd_if_hp_more_than(void)
if (gAIScriptPtr[1] == AI_USER) if (gAIScriptPtr[1] == AI_USER)
bank = sBank_AI; bank = sBank_AI;
else else
bank = gBattleDefender; bank = gBattleMoveTarget;
if ((u32)(100 * gBattleMons[bank].hp / gBattleMons[bank].maxHP) > gAIScriptPtr[2]) if ((u32)(100 * gBattleMons[bank].hp / gBattleMons[bank].maxHP) > gAIScriptPtr[2])
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 3); gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 3);
@ -753,7 +753,7 @@ static void BattleAICmd_if_hp_equal(void)
if (gAIScriptPtr[1] == AI_USER) if (gAIScriptPtr[1] == AI_USER)
bank = sBank_AI; bank = sBank_AI;
else else
bank = gBattleDefender; bank = gBattleMoveTarget;
if ((u32)(100 * gBattleMons[bank].hp / gBattleMons[bank].maxHP) == gAIScriptPtr[2]) if ((u32)(100 * gBattleMons[bank].hp / gBattleMons[bank].maxHP) == gAIScriptPtr[2])
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 3); gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 3);
@ -768,7 +768,7 @@ static void BattleAICmd_if_hp_not_equal(void)
if (gAIScriptPtr[1] == AI_USER) if (gAIScriptPtr[1] == AI_USER)
bank = sBank_AI; bank = sBank_AI;
else else
bank = gBattleDefender; bank = gBattleMoveTarget;
if ((u32)(100 * gBattleMons[bank].hp / gBattleMons[bank].maxHP) != gAIScriptPtr[2]) if ((u32)(100 * gBattleMons[bank].hp / gBattleMons[bank].maxHP) != gAIScriptPtr[2])
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 3); gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 3);
@ -784,7 +784,7 @@ static void BattleAICmd_if_status(void)
if (gAIScriptPtr[1] == AI_USER) if (gAIScriptPtr[1] == AI_USER)
bank = sBank_AI; bank = sBank_AI;
else else
bank = gBattleDefender; bank = gBattleMoveTarget;
status = AIScriptRead32(gAIScriptPtr + 2); status = AIScriptRead32(gAIScriptPtr + 2);
@ -802,7 +802,7 @@ static void BattleAICmd_if_not_status(void)
if (gAIScriptPtr[1] == AI_USER) if (gAIScriptPtr[1] == AI_USER)
bank = sBank_AI; bank = sBank_AI;
else else
bank = gBattleDefender; bank = gBattleMoveTarget;
status = AIScriptRead32(gAIScriptPtr + 2); status = AIScriptRead32(gAIScriptPtr + 2);
@ -820,7 +820,7 @@ static void BattleAICmd_if_status2(void)
if (gAIScriptPtr[1] == AI_USER) if (gAIScriptPtr[1] == AI_USER)
bank = sBank_AI; bank = sBank_AI;
else else
bank = gBattleDefender; bank = gBattleMoveTarget;
status = AIScriptRead32(gAIScriptPtr + 2); status = AIScriptRead32(gAIScriptPtr + 2);
@ -838,7 +838,7 @@ static void BattleAICmd_if_not_status2(void)
if (gAIScriptPtr[1] == AI_USER) if (gAIScriptPtr[1] == AI_USER)
bank = sBank_AI; bank = sBank_AI;
else else
bank = gBattleDefender; bank = gBattleMoveTarget;
status = AIScriptRead32(gAIScriptPtr + 2); status = AIScriptRead32(gAIScriptPtr + 2);
@ -856,7 +856,7 @@ static void BattleAICmd_if_status3(void)
if (gAIScriptPtr[1] == AI_USER) if (gAIScriptPtr[1] == AI_USER)
bank = sBank_AI; bank = sBank_AI;
else else
bank = gBattleDefender; bank = gBattleMoveTarget;
status = AIScriptRead32(gAIScriptPtr + 2); status = AIScriptRead32(gAIScriptPtr + 2);
@ -874,7 +874,7 @@ static void BattleAICmd_if_not_status3(void)
if (gAIScriptPtr[1] == AI_USER) if (gAIScriptPtr[1] == AI_USER)
bank = sBank_AI; bank = sBank_AI;
else else
bank = gBattleDefender; bank = gBattleMoveTarget;
status = AIScriptRead32(gAIScriptPtr + 2); status = AIScriptRead32(gAIScriptPtr + 2);
@ -892,7 +892,7 @@ static void BattleAICmd_if_side_affecting(void)
if (gAIScriptPtr[1] == AI_USER) if (gAIScriptPtr[1] == AI_USER)
bank = sBank_AI; bank = sBank_AI;
else else
bank = gBattleDefender; bank = gBattleMoveTarget;
side = GET_BATTLER_SIDE(bank); side = GET_BATTLER_SIDE(bank);
status = AIScriptRead32(gAIScriptPtr + 2); status = AIScriptRead32(gAIScriptPtr + 2);
@ -911,7 +911,7 @@ static void BattleAICmd_if_not_side_affecting(void)
if (gAIScriptPtr[1] == AI_USER) if (gAIScriptPtr[1] == AI_USER)
bank = sBank_AI; bank = sBank_AI;
else else
bank = gBattleDefender; bank = gBattleMoveTarget;
side = GET_BATTLER_SIDE(bank); side = GET_BATTLER_SIDE(bank);
status = AIScriptRead32(gAIScriptPtr + 2); status = AIScriptRead32(gAIScriptPtr + 2);
@ -1126,13 +1126,13 @@ static void BattleAICmd_get_type(void)
AI_THINKING_STRUCT->funcResult = gBattleMons[sBank_AI].type1; AI_THINKING_STRUCT->funcResult = gBattleMons[sBank_AI].type1;
break; break;
case AI_TYPE1_TARGET: // target primary type case AI_TYPE1_TARGET: // target primary type
AI_THINKING_STRUCT->funcResult = gBattleMons[gBattleDefender].type1; AI_THINKING_STRUCT->funcResult = gBattleMons[gBattleMoveTarget].type1;
break; break;
case AI_TYPE2_USER: // AI user secondary type case AI_TYPE2_USER: // AI user secondary type
AI_THINKING_STRUCT->funcResult = gBattleMons[sBank_AI].type2; AI_THINKING_STRUCT->funcResult = gBattleMons[sBank_AI].type2;
break; break;
case AI_TYPE2_TARGET: // target secondary type case AI_TYPE2_TARGET: // target secondary type
AI_THINKING_STRUCT->funcResult = gBattleMons[gBattleDefender].type2; AI_THINKING_STRUCT->funcResult = gBattleMons[gBattleMoveTarget].type2;
break; break;
case AI_TYPE_MOVE: // type of move being pointed to case AI_TYPE_MOVE: // type of move being pointed to
AI_THINKING_STRUCT->funcResult = gBattleMoves[AI_THINKING_STRUCT->moveConsidered].type; AI_THINKING_STRUCT->funcResult = gBattleMoves[AI_THINKING_STRUCT->moveConsidered].type;
@ -1149,11 +1149,11 @@ static u8 BattleAI_GetWantedBank(u8 bank)
return sBank_AI; return sBank_AI;
case AI_TARGET: case AI_TARGET:
default: default:
return gBattleDefender; return gBattleMoveTarget;
case AI_USER_PARTNER: case AI_USER_PARTNER:
return sBank_AI ^ BIT_FLANK; return sBank_AI ^ BIT_FLANK;
case AI_TARGET_PARTNER: case AI_TARGET_PARTNER:
return gBattleDefender ^ BIT_FLANK; return gBattleMoveTarget ^ BIT_FLANK;
} }
} }
@ -1212,8 +1212,8 @@ static void BattleAICmd_get_how_powerful_move_is(void)
&& gBattleMoves[gBattleMons[sBank_AI].moves[checkedMove]].power > 1) && gBattleMoves[gBattleMons[sBank_AI].moves[checkedMove]].power > 1)
{ {
gCurrentMove = gBattleMons[sBank_AI].moves[checkedMove]; gCurrentMove = gBattleMons[sBank_AI].moves[checkedMove];
AI_CalcDmg(sBank_AI, gBattleDefender); AI_CalcDmg(sBank_AI, gBattleMoveTarget);
TypeCalc(gCurrentMove, sBank_AI, gBattleDefender); TypeCalc(gCurrentMove, sBank_AI, gBattleMoveTarget);
moveDmgs[checkedMove] = gBattleMoveDamage * AI_THINKING_STRUCT->simulatedRNG[checkedMove] / 100; moveDmgs[checkedMove] = gBattleMoveDamage * AI_THINKING_STRUCT->simulatedRNG[checkedMove] / 100;
if (moveDmgs[checkedMove] == 0) if (moveDmgs[checkedMove] == 0)
moveDmgs[checkedMove] = 1; moveDmgs[checkedMove] = 1;
@ -1248,7 +1248,7 @@ static void BattleAICmd_get_last_used_bank_move(void)
if (gAIScriptPtr[1] == AI_USER) if (gAIScriptPtr[1] == AI_USER)
AI_THINKING_STRUCT->funcResult = gLastMoves[sBank_AI]; AI_THINKING_STRUCT->funcResult = gLastMoves[sBank_AI];
else else
AI_THINKING_STRUCT->funcResult = gLastMoves[gBattleDefender]; AI_THINKING_STRUCT->funcResult = gLastMoves[gBattleMoveTarget];
gAIScriptPtr += 2; gAIScriptPtr += 2;
} }
@ -1271,7 +1271,7 @@ static void BattleAICmd_if_not_equal_(void) // same as if_not_equal
static void BattleAICmd_if_user_goes(void) static void BattleAICmd_if_user_goes(void)
{ {
if (GetWhoStrikesFirst(sBank_AI, gBattleDefender, TRUE) == gAIScriptPtr[1]) if (GetWhoStrikesFirst(sBank_AI, gBattleMoveTarget, TRUE) == gAIScriptPtr[1])
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2); gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2);
else else
gAIScriptPtr += 6; gAIScriptPtr += 6;
@ -1279,7 +1279,7 @@ static void BattleAICmd_if_user_goes(void)
static void BattleAICmd_if_user_doesnt_go(void) static void BattleAICmd_if_user_doesnt_go(void)
{ {
if (GetWhoStrikesFirst(sBank_AI, gBattleDefender, TRUE) != gAIScriptPtr[1]) if (GetWhoStrikesFirst(sBank_AI, gBattleMoveTarget, TRUE) != gAIScriptPtr[1])
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2); gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2);
else else
gAIScriptPtr += 6; gAIScriptPtr += 6;
@ -1305,7 +1305,7 @@ static void BattleAICmd_count_usable_party_mons(void)
if (gAIScriptPtr[1] == AI_USER) if (gAIScriptPtr[1] == AI_USER)
bank = sBank_AI; bank = sBank_AI;
else else
bank = gBattleDefender; bank = gBattleMoveTarget;
if (GetBattlerSide(bank) == B_SIDE_PLAYER) if (GetBattlerSide(bank) == B_SIDE_PLAYER)
party = gPlayerParty; party = gPlayerParty;
@ -1315,14 +1315,14 @@ static void BattleAICmd_count_usable_party_mons(void)
if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE) if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE)
{ {
u32 position; u32 position;
bankOnField1 = gBattlePartyID[bank]; bankOnField1 = gBattlerPartyIndexes[bank];
position = GetBattlerPosition(bank) ^ BIT_FLANK; position = GetBattlerPosition(bank) ^ BIT_FLANK;
bankOnField2 = gBattlePartyID[GetBattlerAtPosition(position)]; bankOnField2 = gBattlerPartyIndexes[GetBattlerAtPosition(position)];
} }
else // in singles there's only one bank by side else // in singles there's only one bank by side
{ {
bankOnField1 = gBattlePartyID[bank]; bankOnField1 = gBattlerPartyIndexes[bank];
bankOnField2 = gBattlePartyID[bank]; bankOnField2 = gBattlerPartyIndexes[bank];
} }
for (i = 0; i < PARTY_SIZE; i++) for (i = 0; i < PARTY_SIZE; i++)
@ -1358,7 +1358,7 @@ static void BattleAICmd_get_ability(void)
if (gAIScriptPtr[1] == AI_USER) if (gAIScriptPtr[1] == AI_USER)
bank = sBank_AI; bank = sBank_AI;
else else
bank = gBattleDefender; bank = gBattleMoveTarget;
if (gActiveBattler != bank) if (gActiveBattler != bank)
{ {
@ -1493,7 +1493,7 @@ static void BattleAICmd_get_highest_type_effectiveness(void)
if (gCurrentMove) if (gCurrentMove)
{ {
TypeCalc(gCurrentMove, sBank_AI, gBattleDefender); TypeCalc(gCurrentMove, sBank_AI, gBattleMoveTarget);
// reduce by 1/3. // reduce by 1/3.
if (gBattleMoveDamage == 120) if (gBattleMoveDamage == 120)
@ -1528,7 +1528,7 @@ static void BattleAICmd_if_type_effectiveness(void)
gBattleMoveDamage = AI_EFFECTIVENESS_x1; gBattleMoveDamage = AI_EFFECTIVENESS_x1;
gCurrentMove = AI_THINKING_STRUCT->moveConsidered; gCurrentMove = AI_THINKING_STRUCT->moveConsidered;
TypeCalc(gCurrentMove, sBank_AI, gBattleDefender); TypeCalc(gCurrentMove, sBank_AI, gBattleMoveTarget);
if (gBattleMoveDamage == 120) if (gBattleMoveDamage == 120)
gBattleMoveDamage = AI_EFFECTIVENESS_x2; gBattleMoveDamage = AI_EFFECTIVENESS_x2;
@ -1572,7 +1572,7 @@ static void BattleAICmd_if_status_in_party(void)
bank = sBank_AI; bank = sBank_AI;
break; break;
default: default:
bank = gBattleDefender; bank = gBattleMoveTarget;
break; break;
} }
@ -1609,7 +1609,7 @@ static void BattleAICmd_if_status_not_in_party(void)
bank = sBank_AI; bank = sBank_AI;
break; break;
default: default:
bank = gBattleDefender; bank = gBattleMoveTarget;
break; break;
} }
@ -1669,7 +1669,7 @@ static void BattleAICmd_if_stat_level_less_than(void)
if (gAIScriptPtr[1] == AI_USER) if (gAIScriptPtr[1] == AI_USER)
bank = sBank_AI; bank = sBank_AI;
else else
bank = gBattleDefender; bank = gBattleMoveTarget;
if (gBattleMons[bank].statStages[gAIScriptPtr[2]] < gAIScriptPtr[3]) if (gBattleMons[bank].statStages[gAIScriptPtr[2]] < gAIScriptPtr[3])
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 4); gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 4);
@ -1684,7 +1684,7 @@ static void BattleAICmd_if_stat_level_more_than(void)
if (gAIScriptPtr[1] == AI_USER) if (gAIScriptPtr[1] == AI_USER)
bank = sBank_AI; bank = sBank_AI;
else else
bank = gBattleDefender; bank = gBattleMoveTarget;
if (gBattleMons[bank].statStages[gAIScriptPtr[2]] > gAIScriptPtr[3]) if (gBattleMons[bank].statStages[gAIScriptPtr[2]] > gAIScriptPtr[3])
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 4); gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 4);
@ -1699,7 +1699,7 @@ static void BattleAICmd_if_stat_level_equal(void)
if (gAIScriptPtr[1] == AI_USER) if (gAIScriptPtr[1] == AI_USER)
bank = sBank_AI; bank = sBank_AI;
else else
bank = gBattleDefender; bank = gBattleMoveTarget;
if (gBattleMons[bank].statStages[gAIScriptPtr[2]] == gAIScriptPtr[3]) if (gBattleMons[bank].statStages[gAIScriptPtr[2]] == gAIScriptPtr[3])
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 4); gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 4);
@ -1714,7 +1714,7 @@ static void BattleAICmd_if_stat_level_not_equal(void)
if (gAIScriptPtr[1] == AI_USER) if (gAIScriptPtr[1] == AI_USER)
bank = sBank_AI; bank = sBank_AI;
else else
bank = gBattleDefender; bank = gBattleMoveTarget;
if (gBattleMons[bank].statStages[gAIScriptPtr[2]] != gAIScriptPtr[3]) if (gBattleMons[bank].statStages[gAIScriptPtr[2]] != gAIScriptPtr[3])
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 4); gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 4);
@ -1736,8 +1736,8 @@ static void BattleAICmd_if_can_faint(void)
gMoveResultFlags = 0; gMoveResultFlags = 0;
gCritMultiplier = 1; gCritMultiplier = 1;
gCurrentMove = AI_THINKING_STRUCT->moveConsidered; gCurrentMove = AI_THINKING_STRUCT->moveConsidered;
AI_CalcDmg(sBank_AI, gBattleDefender); AI_CalcDmg(sBank_AI, gBattleMoveTarget);
TypeCalc(gCurrentMove, sBank_AI, gBattleDefender); TypeCalc(gCurrentMove, sBank_AI, gBattleMoveTarget);
gBattleMoveDamage = gBattleMoveDamage * AI_THINKING_STRUCT->simulatedRNG[AI_THINKING_STRUCT->movesetIndex] / 100; gBattleMoveDamage = gBattleMoveDamage * AI_THINKING_STRUCT->simulatedRNG[AI_THINKING_STRUCT->movesetIndex] / 100;
@ -1745,7 +1745,7 @@ static void BattleAICmd_if_can_faint(void)
if (gBattleMoveDamage == 0) if (gBattleMoveDamage == 0)
gBattleMoveDamage = 1; gBattleMoveDamage = 1;
if (gBattleMons[gBattleDefender].hp <= gBattleMoveDamage) if (gBattleMons[gBattleMoveTarget].hp <= gBattleMoveDamage)
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 1); gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 1);
else else
gAIScriptPtr += 5; gAIScriptPtr += 5;
@ -1765,14 +1765,14 @@ static void BattleAICmd_if_cant_faint(void)
gMoveResultFlags = 0; gMoveResultFlags = 0;
gCritMultiplier = 1; gCritMultiplier = 1;
gCurrentMove = AI_THINKING_STRUCT->moveConsidered; gCurrentMove = AI_THINKING_STRUCT->moveConsidered;
AI_CalcDmg(sBank_AI, gBattleDefender); AI_CalcDmg(sBank_AI, gBattleMoveTarget);
TypeCalc(gCurrentMove, sBank_AI, gBattleDefender); TypeCalc(gCurrentMove, sBank_AI, gBattleMoveTarget);
gBattleMoveDamage = gBattleMoveDamage * AI_THINKING_STRUCT->simulatedRNG[AI_THINKING_STRUCT->movesetIndex] / 100; gBattleMoveDamage = gBattleMoveDamage * AI_THINKING_STRUCT->simulatedRNG[AI_THINKING_STRUCT->movesetIndex] / 100;
// this macro is missing the damage 0 = 1 assumption. // this macro is missing the damage 0 = 1 assumption.
if (gBattleMons[gBattleDefender].hp > gBattleMoveDamage) if (gBattleMons[gBattleMoveTarget].hp > gBattleMoveDamage)
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 1); gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 1);
else else
gAIScriptPtr += 5; gAIScriptPtr += 5;
@ -1829,7 +1829,7 @@ static void BattleAICmd_if_has_move(void)
case AI_TARGET_PARTNER: case AI_TARGET_PARTNER:
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
{ {
if (BATTLE_HISTORY->usedMoves[gBattleDefender].moves[i] == *movePtr) if (BATTLE_HISTORY->usedMoves[gBattleMoveTarget].moves[i] == *movePtr)
break; break;
} }
if (i == 4) if (i == 4)
@ -1873,7 +1873,7 @@ static void BattleAICmd_if_doesnt_have_move(void)
case AI_TARGET_PARTNER: case AI_TARGET_PARTNER:
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
{ {
if (BATTLE_HISTORY->usedMoves[gBattleDefender].moves[i] == *movePtr) if (BATTLE_HISTORY->usedMoves[gBattleMoveTarget].moves[i] == *movePtr)
break; break;
} }
if (i != 4) if (i != 4)
@ -1911,8 +1911,8 @@ static void BattleAICmd_if_has_move_with_effect(void)
case AI_TARGET_PARTNER: case AI_TARGET_PARTNER:
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
{ {
// UB: checks sBank_AI instead of gBattleDefender // UB: checks sBank_AI instead of gBattleMoveTarget
if (gBattleMons[sBank_AI].moves[i] != 0 && gBattleMoves[BATTLE_HISTORY->usedMoves[gBattleDefender].moves[i]].effect == gAIScriptPtr[2]) if (gBattleMons[sBank_AI].moves[i] != 0 && gBattleMoves[BATTLE_HISTORY->usedMoves[gBattleMoveTarget].moves[i]].effect == gAIScriptPtr[2])
break; break;
} }
if (i == 4) if (i == 4)
@ -1945,7 +1945,7 @@ static void BattleAICmd_if_doesnt_have_move_with_effect(void)
case AI_TARGET_PARTNER: case AI_TARGET_PARTNER:
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
{ {
if (BATTLE_HISTORY->usedMoves[gBattleDefender].moves[i] && gBattleMoves[BATTLE_HISTORY->usedMoves[gBattleDefender].moves[i]].effect == gAIScriptPtr[2]) if (BATTLE_HISTORY->usedMoves[gBattleMoveTarget].moves[i] && gBattleMoves[BATTLE_HISTORY->usedMoves[gBattleMoveTarget].moves[i]].effect == gAIScriptPtr[2])
break; break;
} }
if (i != 4) if (i != 4)
@ -1963,7 +1963,7 @@ static void BattleAICmd_if_any_move_disabled_or_encored(void)
if (gAIScriptPtr[1] == AI_USER) if (gAIScriptPtr[1] == AI_USER)
bank = sBank_AI; bank = sBank_AI;
else else
bank = gBattleDefender; bank = gBattleMoveTarget;
if (gAIScriptPtr[2] == 0) if (gAIScriptPtr[2] == 0)
{ {
@ -2041,7 +2041,7 @@ static void BattleAICmd_get_hold_effect(void)
if (gAIScriptPtr[1] == AI_USER) if (gAIScriptPtr[1] == AI_USER)
bank = sBank_AI; bank = sBank_AI;
else else
bank = gBattleDefender; bank = gBattleMoveTarget;
if (gActiveBattler != bank) if (gActiveBattler != bank)
AI_THINKING_STRUCT->funcResult = ItemId_GetHoldEffect(BATTLE_HISTORY->itemEffects[bank]); AI_THINKING_STRUCT->funcResult = ItemId_GetHoldEffect(BATTLE_HISTORY->itemEffects[bank]);
@ -2079,7 +2079,7 @@ static void BattleAICmd_get_gender(void)
if (gAIScriptPtr[1] == AI_USER) if (gAIScriptPtr[1] == AI_USER)
bank = sBank_AI; bank = sBank_AI;
else else
bank = gBattleDefender; bank = gBattleMoveTarget;
AI_THINKING_STRUCT->funcResult = GetGenderFromSpeciesAndPersonality(gBattleMons[bank].species, gBattleMons[bank].personality); AI_THINKING_STRUCT->funcResult = GetGenderFromSpeciesAndPersonality(gBattleMons[bank].species, gBattleMons[bank].personality);
@ -2093,7 +2093,7 @@ static void BattleAICmd_is_first_turn_for(void)
if (gAIScriptPtr[1] == AI_USER) if (gAIScriptPtr[1] == AI_USER)
bank = sBank_AI; bank = sBank_AI;
else else
bank = gBattleDefender; bank = gBattleMoveTarget;
AI_THINKING_STRUCT->funcResult = gDisableStructs[bank].isFirstTurn; AI_THINKING_STRUCT->funcResult = gDisableStructs[bank].isFirstTurn;
@ -2107,7 +2107,7 @@ static void BattleAICmd_get_stockpile_count(void)
if (gAIScriptPtr[1] == AI_USER) if (gAIScriptPtr[1] == AI_USER)
bank = sBank_AI; bank = sBank_AI;
else else
bank = gBattleDefender; bank = gBattleMoveTarget;
AI_THINKING_STRUCT->funcResult = gDisableStructs[bank].stockpileCounter; AI_THINKING_STRUCT->funcResult = gDisableStructs[bank].stockpileCounter;
@ -2128,7 +2128,7 @@ static void BattleAICmd_get_used_held_item(void)
if (gAIScriptPtr[1] == AI_USER) if (gAIScriptPtr[1] == AI_USER)
bank = sBank_AI; bank = sBank_AI;
else else
bank = gBattleDefender; bank = gBattleMoveTarget;
// This is likely a leftover from Ruby's code and its ugly ewram access // This is likely a leftover from Ruby's code and its ugly ewram access
#ifdef NONMATCHING #ifdef NONMATCHING
@ -2168,7 +2168,7 @@ static void BattleAICmd_get_protect_count(void)
if (gAIScriptPtr[1] == AI_USER) if (gAIScriptPtr[1] == AI_USER)
bank = sBank_AI; bank = sBank_AI;
else else
bank = gBattleDefender; bank = gBattleMoveTarget;
AI_THINKING_STRUCT->funcResult = gDisableStructs[bank].protectUses; AI_THINKING_STRUCT->funcResult = gDisableStructs[bank].protectUses;
@ -2221,7 +2221,7 @@ static void BattleAICmd_if_level_cond(void)
switch (gAIScriptPtr[1]) switch (gAIScriptPtr[1])
{ {
case 0: // greater than case 0: // greater than
if (gBattleMons[sBank_AI].level > gBattleMons[gBattleDefender].level) if (gBattleMons[sBank_AI].level > gBattleMons[gBattleMoveTarget].level)
{ {
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2); gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2);
return; return;
@ -2229,7 +2229,7 @@ static void BattleAICmd_if_level_cond(void)
gAIScriptPtr += 6; gAIScriptPtr += 6;
return; return;
case 1: // less than case 1: // less than
if (gBattleMons[sBank_AI].level < gBattleMons[gBattleDefender].level) if (gBattleMons[sBank_AI].level < gBattleMons[gBattleMoveTarget].level)
{ {
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2); gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2);
return; return;
@ -2237,7 +2237,7 @@ static void BattleAICmd_if_level_cond(void)
gAIScriptPtr += 6; gAIScriptPtr += 6;
return; return;
case 2: // equal case 2: // equal
if (gBattleMons[sBank_AI].level == gBattleMons[gBattleDefender].level) if (gBattleMons[sBank_AI].level == gBattleMons[gBattleMoveTarget].level)
{ {
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2); gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2);
return; return;
@ -2249,7 +2249,7 @@ static void BattleAICmd_if_level_cond(void)
static void BattleAICmd_if_target_taunted(void) static void BattleAICmd_if_target_taunted(void)
{ {
if (gDisableStructs[gBattleDefender].tauntTimer1 != 0) if (gDisableStructs[gBattleMoveTarget].tauntTimer1 != 0)
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 1); gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 1);
else else
gAIScriptPtr += 5; gAIScriptPtr += 5;
@ -2257,7 +2257,7 @@ static void BattleAICmd_if_target_taunted(void)
static void BattleAICmd_if_target_not_taunted(void) static void BattleAICmd_if_target_not_taunted(void)
{ {
if (gDisableStructs[gBattleDefender].tauntTimer1 == 0) if (gDisableStructs[gBattleMoveTarget].tauntTimer1 == 0)
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 1); gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 1);
else else
gAIScriptPtr += 5; gAIScriptPtr += 5;
@ -2265,7 +2265,7 @@ static void BattleAICmd_if_target_not_taunted(void)
static void BattleAICmd_if_target_is_ally(void) static void BattleAICmd_if_target_is_ally(void)
{ {
if ((sBank_AI & BIT_SIDE) == (gBattleDefender & BIT_SIDE)) if ((sBank_AI & BIT_SIDE) == (gBattleMoveTarget & BIT_SIDE))
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 1); gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 1);
else else
gAIScriptPtr += 5; gAIScriptPtr += 5;

View File

@ -15,7 +15,7 @@ extern u8 gAbsentBattlerFlags;
extern u32 gBattleTypeFlags; extern u32 gBattleTypeFlags;
extern u32 gStatuses3[MAX_BATTLERS_COUNT]; extern u32 gStatuses3[MAX_BATTLERS_COUNT];
extern struct BattlePokemon gBattleMons[MAX_BATTLERS_COUNT]; extern struct BattlePokemon gBattleMons[MAX_BATTLERS_COUNT];
extern u16 gBattlePartyID[MAX_BATTLERS_COUNT]; extern u16 gBattlerPartyIndexes[MAX_BATTLERS_COUNT];
extern u16 gLastLandedMoves[MAX_BATTLERS_COUNT]; extern u16 gLastLandedMoves[MAX_BATTLERS_COUNT];
extern u8 gLastHitBy[MAX_BATTLERS_COUNT]; extern u8 gLastHitBy[MAX_BATTLERS_COUNT];
extern u16 gDynamicBasePower; extern u16 gDynamicBasePower;
@ -39,7 +39,7 @@ static bool8 ShouldSwitchIfPerishSong(void)
&& gDisableStructs[gActiveBattler].perishSongTimer1 == 0) && gDisableStructs[gActiveBattler].perishSongTimer1 == 0)
{ {
*(gBattleStruct->AI_monToSwitchIntoId + gActiveBattler) = 6; *(gBattleStruct->AI_monToSwitchIntoId + gActiveBattler) = 6;
EmitTwoReturnValues(1, ACTION_SWITCH, 0); BtlController_EmitTwoReturnValues(1, ACTION_SWITCH, 0);
return TRUE; return TRUE;
} }
@ -104,7 +104,7 @@ static bool8 ShouldSwitchIfWonderGuard(void)
continue; continue;
if (GetMonData(&party[i], MON_DATA_SPECIES2) == SPECIES_EGG) if (GetMonData(&party[i], MON_DATA_SPECIES2) == SPECIES_EGG)
continue; continue;
if (i == gBattlePartyID[gActiveBattler]) if (i == gBattlerPartyIndexes[gActiveBattler])
continue; continue;
GetMonData(&party[i], MON_DATA_SPECIES); // unused return value GetMonData(&party[i], MON_DATA_SPECIES); // unused return value
@ -121,7 +121,7 @@ static bool8 ShouldSwitchIfWonderGuard(void)
{ {
// we found a mon // we found a mon
*(gBattleStruct->AI_monToSwitchIntoId + gActiveBattler) = i; *(gBattleStruct->AI_monToSwitchIntoId + gActiveBattler) = i;
EmitTwoReturnValues(1, ACTION_SWITCH, 0); BtlController_EmitTwoReturnValues(1, ACTION_SWITCH, 0);
return TRUE; return TRUE;
} }
} }
@ -202,9 +202,9 @@ static bool8 FindMonThatAbsorbsOpponentsMove(void)
continue; continue;
if (GetMonData(&party[i], MON_DATA_SPECIES2) == SPECIES_EGG) if (GetMonData(&party[i], MON_DATA_SPECIES2) == SPECIES_EGG)
continue; continue;
if (i == gBattlePartyID[bankIn1]) if (i == gBattlerPartyIndexes[bankIn1])
continue; continue;
if (i == gBattlePartyID[bankIn2]) if (i == gBattlerPartyIndexes[bankIn2])
continue; continue;
if (i == *(gBattleStruct->monToSwitchIntoId + bankIn1)) if (i == *(gBattleStruct->monToSwitchIntoId + bankIn1))
continue; continue;
@ -221,7 +221,7 @@ static bool8 FindMonThatAbsorbsOpponentsMove(void)
{ {
// we found a mon // we found a mon
*(gBattleStruct->AI_monToSwitchIntoId + gActiveBattler) = i; *(gBattleStruct->AI_monToSwitchIntoId + gActiveBattler) = i;
EmitTwoReturnValues(1, ACTION_SWITCH, 0); BtlController_EmitTwoReturnValues(1, ACTION_SWITCH, 0);
return TRUE; return TRUE;
} }
} }
@ -241,13 +241,13 @@ static bool8 ShouldSwitchIfNaturalCure(void)
if ((gLastLandedMoves[gActiveBattler] == 0 || gLastLandedMoves[gActiveBattler] == 0xFFFF) && Random() & 1) if ((gLastLandedMoves[gActiveBattler] == 0 || gLastLandedMoves[gActiveBattler] == 0xFFFF) && Random() & 1)
{ {
*(gBattleStruct->AI_monToSwitchIntoId + gActiveBattler) = 6; *(gBattleStruct->AI_monToSwitchIntoId + gActiveBattler) = 6;
EmitTwoReturnValues(1, ACTION_SWITCH, 0); BtlController_EmitTwoReturnValues(1, ACTION_SWITCH, 0);
return TRUE; return TRUE;
} }
else if (gBattleMoves[gLastLandedMoves[gActiveBattler]].power == 0 && Random() & 1) else if (gBattleMoves[gLastLandedMoves[gActiveBattler]].power == 0 && Random() & 1)
{ {
*(gBattleStruct->AI_monToSwitchIntoId + gActiveBattler) = 6; *(gBattleStruct->AI_monToSwitchIntoId + gActiveBattler) = 6;
EmitTwoReturnValues(1, ACTION_SWITCH, 0); BtlController_EmitTwoReturnValues(1, ACTION_SWITCH, 0);
return TRUE; return TRUE;
} }
@ -258,7 +258,7 @@ static bool8 ShouldSwitchIfNaturalCure(void)
if (Random() & 1) if (Random() & 1)
{ {
*(gBattleStruct->AI_monToSwitchIntoId + gActiveBattler) = 6; *(gBattleStruct->AI_monToSwitchIntoId + gActiveBattler) = 6;
EmitTwoReturnValues(1, ACTION_SWITCH, 0); BtlController_EmitTwoReturnValues(1, ACTION_SWITCH, 0);
return TRUE; return TRUE;
} }
@ -396,9 +396,9 @@ static bool8 FindMonWithFlagsAndSuperEffective(u8 flags, u8 moduloPercent)
continue; continue;
if (GetMonData(&party[i], MON_DATA_SPECIES2) == SPECIES_EGG) if (GetMonData(&party[i], MON_DATA_SPECIES2) == SPECIES_EGG)
continue; continue;
if (i == gBattlePartyID[bankIn1]) if (i == gBattlerPartyIndexes[bankIn1])
continue; continue;
if (i == gBattlePartyID[bankIn2]) if (i == gBattlerPartyIndexes[bankIn2])
continue; continue;
if (i == *(gBattleStruct->monToSwitchIntoId + bankIn1)) if (i == *(gBattleStruct->monToSwitchIntoId + bankIn1))
continue; continue;
@ -426,7 +426,7 @@ static bool8 FindMonWithFlagsAndSuperEffective(u8 flags, u8 moduloPercent)
if (moveFlags & MOVE_RESULT_SUPER_EFFECTIVE && Random() % moduloPercent == 0) if (moveFlags & MOVE_RESULT_SUPER_EFFECTIVE && Random() % moduloPercent == 0)
{ {
*(gBattleStruct->AI_monToSwitchIntoId + gActiveBattler) = i; *(gBattleStruct->AI_monToSwitchIntoId + gActiveBattler) = i;
EmitTwoReturnValues(1, ACTION_SWITCH, 0); BtlController_EmitTwoReturnValues(1, ACTION_SWITCH, 0);
return TRUE; return TRUE;
} }
} }
@ -504,9 +504,9 @@ static bool8 ShouldSwitch(void)
continue; continue;
if (GetMonData(&party[i], MON_DATA_SPECIES2) == SPECIES_EGG) if (GetMonData(&party[i], MON_DATA_SPECIES2) == SPECIES_EGG)
continue; continue;
if (i == gBattlePartyID[bankIn1]) if (i == gBattlerPartyIndexes[bankIn1])
continue; continue;
if (i == gBattlePartyID[bankIn2]) if (i == gBattlerPartyIndexes[bankIn2])
continue; continue;
if (i == *(gBattleStruct->monToSwitchIntoId + bankIn1)) if (i == *(gBattleStruct->monToSwitchIntoId + bankIn1))
continue; continue;
@ -586,9 +586,9 @@ void AI_TrySwitchOrUseItem(void)
{ {
if (GetMonData(&party[monToSwitchId], MON_DATA_HP) == 0) if (GetMonData(&party[monToSwitchId], MON_DATA_HP) == 0)
continue; continue;
if (monToSwitchId == gBattlePartyID[bankIn1]) if (monToSwitchId == gBattlerPartyIndexes[bankIn1])
continue; continue;
if (monToSwitchId == gBattlePartyID[bankIn2]) if (monToSwitchId == gBattlerPartyIndexes[bankIn2])
continue; continue;
if (monToSwitchId == *(gBattleStruct->monToSwitchIntoId + bankIn1)) if (monToSwitchId == *(gBattleStruct->monToSwitchIntoId + bankIn1))
continue; continue;
@ -611,7 +611,7 @@ void AI_TrySwitchOrUseItem(void)
} }
} }
EmitTwoReturnValues(1, ACTION_USE_MOVE, (gActiveBattler ^ BIT_SIDE) << 8); BtlController_EmitTwoReturnValues(1, ACTION_USE_MOVE, (gActiveBattler ^ BIT_SIDE) << 8);
} }
static void ModulateByTypeEffectiveness(u8 atkType, u8 defType1, u8 defType2, u8 *var) static void ModulateByTypeEffectiveness(u8 atkType, u8 defType1, u8 defType2, u8 *var)
@ -654,7 +654,7 @@ u8 GetMostSuitableMonToSwitchInto(void)
if (*(gBattleStruct->monToSwitchIntoId + gActiveBattler) != 6) if (*(gBattleStruct->monToSwitchIntoId + gActiveBattler) != 6)
return *(gBattleStruct->monToSwitchIntoId + gActiveBattler); return *(gBattleStruct->monToSwitchIntoId + gActiveBattler);
if (gBattleTypeFlags & BATTLE_TYPE_ARENA) if (gBattleTypeFlags & BATTLE_TYPE_ARENA)
return gBattlePartyID[gActiveBattler] + 1; return gBattlerPartyIndexes[gActiveBattler] + 1;
if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE) if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE)
{ {
@ -706,8 +706,8 @@ u8 GetMostSuitableMonToSwitchInto(void)
if (species != SPECIES_NONE if (species != SPECIES_NONE
&& GetMonData(&party[i], MON_DATA_HP) != 0 && GetMonData(&party[i], MON_DATA_HP) != 0
&& !(gBitTable[i] & invalidMons) && !(gBitTable[i] & invalidMons)
&& gBattlePartyID[bankIn1] != i && gBattlerPartyIndexes[bankIn1] != i
&& gBattlePartyID[bankIn2] != i && gBattlerPartyIndexes[bankIn2] != i
&& i != *(gBattleStruct->monToSwitchIntoId + bankIn1) && i != *(gBattleStruct->monToSwitchIntoId + bankIn1)
&& i != *(gBattleStruct->monToSwitchIntoId + bankIn2)) && i != *(gBattleStruct->monToSwitchIntoId + bankIn2))
{ {
@ -764,9 +764,9 @@ u8 GetMostSuitableMonToSwitchInto(void)
continue; continue;
if (GetMonData(&party[i], MON_DATA_HP) == 0) if (GetMonData(&party[i], MON_DATA_HP) == 0)
continue; continue;
if (gBattlePartyID[bankIn1] == i) if (gBattlerPartyIndexes[bankIn1] == i)
continue; continue;
if (gBattlePartyID[bankIn2] == i) if (gBattlerPartyIndexes[bankIn2] == i)
continue; continue;
if (i == *(gBattleStruct->monToSwitchIntoId + bankIn1)) if (i == *(gBattleStruct->monToSwitchIntoId + bankIn1))
continue; continue;
@ -937,7 +937,7 @@ static bool8 ShouldUseItem(void)
if (shouldUse) if (shouldUse)
{ {
EmitTwoReturnValues(1, ACTION_USE_ITEM, 0); BtlController_EmitTwoReturnValues(1, ACTION_USE_ITEM, 0);
*(gBattleStruct->chosenItem + (gActiveBattler / 2) * 2) = item; *(gBattleStruct->chosenItem + (gActiveBattler / 2) * 2) = item;
gBattleResources->battleHistory->trainerItems[i] = 0; gBattleResources->battleHistory->trainerItems[i] = 0;
return shouldUse; return shouldUse;

View File

@ -25,8 +25,8 @@
#define ANIM_SPRITE_INDEX_COUNT 8 #define ANIM_SPRITE_INDEX_COUNT 8
extern u8 gBattleAttacker; extern u8 gBattleMoveAttacker;
extern u8 gBattleDefender; extern u8 gBattleMoveTarget;
extern u16 gBattle_WIN0H; extern u16 gBattle_WIN0H;
extern u16 gBattle_WIN0V; extern u16 gBattle_WIN0V;
extern u16 gBattle_WIN1H; extern u16 gBattle_WIN1H;
@ -35,8 +35,8 @@ extern u16 gBattle_BG1_X;
extern u16 gBattle_BG1_Y; extern u16 gBattle_BG1_Y;
extern u16 gBattle_BG2_X; extern u16 gBattle_BG2_X;
extern u16 gBattle_BG2_Y; extern u16 gBattle_BG2_Y;
extern u16 gBattlePartyID[MAX_BATTLERS_COUNT]; extern u16 gBattlerPartyIndexes[MAX_BATTLERS_COUNT];
extern u8 gBankSpriteIds[MAX_BATTLERS_COUNT]; extern u8 gBattlerSpriteIds[MAX_BATTLERS_COUNT];
extern struct MusicPlayerInfo gMPlayInfo_BGM; extern struct MusicPlayerInfo gMPlayInfo_BGM;
extern struct MusicPlayerInfo gMPlayInfo_SE1; extern struct MusicPlayerInfo gMPlayInfo_SE1;
extern struct MusicPlayerInfo gMPlayInfo_SE2; extern struct MusicPlayerInfo gMPlayInfo_SE2;
@ -130,8 +130,8 @@ EWRAM_DATA static u8 sMonAnimTaskIdArray[2] = {0};
EWRAM_DATA u8 gAnimMoveTurn = 0; EWRAM_DATA u8 gAnimMoveTurn = 0;
EWRAM_DATA static u8 sAnimBackgroundFadeState = 0; EWRAM_DATA static u8 sAnimBackgroundFadeState = 0;
EWRAM_DATA static u16 sAnimMoveIndex = 0; // set but unused. EWRAM_DATA static u16 sAnimMoveIndex = 0; // set but unused.
EWRAM_DATA u8 gAnimBankAttacker = 0; EWRAM_DATA u8 gBattleAnimAttacker = 0;
EWRAM_DATA u8 gAnimBankTarget = 0; EWRAM_DATA u8 gBattleAnimTarget = 0;
EWRAM_DATA u16 gAnimSpeciesByBanks[MAX_BATTLERS_COUNT] = {0}; EWRAM_DATA u16 gAnimSpeciesByBanks[MAX_BATTLERS_COUNT] = {0};
EWRAM_DATA u8 gUnknown_02038440 = 0; EWRAM_DATA u8 gUnknown_02038440 = 0;
@ -214,15 +214,15 @@ void ClearBattleAnimationVars(void)
gAnimMoveTurn = 0; gAnimMoveTurn = 0;
sAnimBackgroundFadeState = 0; sAnimBackgroundFadeState = 0;
sAnimMoveIndex = 0; sAnimMoveIndex = 0;
gAnimBankAttacker = 0; gBattleAnimAttacker = 0;
gAnimBankTarget = 0; gBattleAnimTarget = 0;
gUnknown_02038440 = 0; gUnknown_02038440 = 0;
} }
void DoMoveAnim(u16 move) void DoMoveAnim(u16 move)
{ {
gAnimBankAttacker = gBattleAttacker; gBattleAnimAttacker = gBattleMoveAttacker;
gAnimBankTarget = gBattleDefender; gBattleAnimTarget = gBattleMoveTarget;
LaunchBattleAnimation(gBattleAnims_Moves, move, TRUE); LaunchBattleAnimation(gBattleAnims_Moves, move, TRUE);
} }
@ -237,9 +237,9 @@ void LaunchBattleAnimation(const u8 *const animsTable[], u16 tableId, bool8 isMo
for (i = 0; i < MAX_BATTLERS_COUNT; i++) for (i = 0; i < MAX_BATTLERS_COUNT; i++)
{ {
if (GetBattlerSide(i) != 0) if (GetBattlerSide(i) != 0)
gAnimSpeciesByBanks[i] = GetMonData(&gEnemyParty[gBattlePartyID[i]], MON_DATA_SPECIES); gAnimSpeciesByBanks[i] = GetMonData(&gEnemyParty[gBattlerPartyIndexes[i]], MON_DATA_SPECIES);
else else
gAnimSpeciesByBanks[i] = GetMonData(&gPlayerParty[gBattlePartyID[i]], MON_DATA_SPECIES); gAnimSpeciesByBanks[i] = GetMonData(&gPlayerParty[gBattlerPartyIndexes[i]], MON_DATA_SPECIES);
} }
} }
else else
@ -409,7 +409,7 @@ static void ScriptCmd_createsprite(void)
else else
argVar *= -1; argVar *= -1;
subpriority = sub_80A82E4(gAnimBankTarget) + (s8)(argVar); subpriority = sub_80A82E4(gBattleAnimTarget) + (s8)(argVar);
} }
else else
{ {
@ -418,13 +418,13 @@ static void ScriptCmd_createsprite(void)
else else
argVar *= -1; argVar *= -1;
subpriority = sub_80A82E4(gAnimBankAttacker) + (s8)(argVar); subpriority = sub_80A82E4(gBattleAnimAttacker) + (s8)(argVar);
} }
if (subpriority < 3) if (subpriority < 3)
subpriority = 3; subpriority = 3;
CreateSpriteAndAnimate(template, GetBankCoord(gAnimBankTarget, 2), GetBankCoord(gAnimBankTarget, 3), subpriority); CreateSpriteAndAnimate(template, GetBattlerSpriteCoord(gBattleAnimTarget, 2), GetBattlerSpriteCoord(gBattleAnimTarget, 3), subpriority);
gAnimVisualTaskCount++; gAnimVisualTaskCount++;
} }
@ -565,7 +565,7 @@ static void sub_80A40F4(u8 taskId)
u8 newTaskId; u8 newTaskId;
s16 *selfData = gTasks[taskId].data; s16 *selfData = gTasks[taskId].data;
u8 bankSpriteId = gBankSpriteIds[selfData[t1_MONBG_BANK]]; u8 bankSpriteId = gBattlerSpriteIds[selfData[t1_MONBG_BANK]];
gSprites[bankSpriteId].invisible = 1; gSprites[bankSpriteId].invisible = 1;
if (!selfData[t1_CREATE_ANOTHER_TASK]) if (!selfData[t1_CREATE_ANOTHER_TASK])
@ -607,11 +607,11 @@ static void ScriptCmd_monbg(void)
animBank = sBattleAnimScriptPtr[0]; animBank = sBattleAnimScriptPtr[0];
if (animBank & ANIM_TARGET) if (animBank & ANIM_TARGET)
bank = gAnimBankTarget; bank = gBattleAnimTarget;
else else
bank = gAnimBankAttacker; bank = gBattleAnimAttacker;
if (IsAnimBankSpriteVisible(bank)) if (IsBattlerSpriteVisible(bank))
{ {
u8 position = GetBattlerPosition(bank); u8 position = GetBattlerPosition(bank);
if (position == B_POSITION_OPPONENT_LEFT || position == B_POSITION_PLAYER_RIGHT || IsContest()) if (position == B_POSITION_OPPONENT_LEFT || position == B_POSITION_PLAYER_RIGHT || IsContest())
@ -630,7 +630,7 @@ static void ScriptCmd_monbg(void)
} }
bank ^= BIT_FLANK; bank ^= BIT_FLANK;
if (IsAnimBankSpriteVisible(bank)) if (IsBattlerSpriteVisible(bank))
{ {
u8 position = GetBattlerPosition(bank); u8 position = GetBattlerPosition(bank);
if (position == B_POSITION_OPPONENT_LEFT || position == B_POSITION_PLAYER_RIGHT || IsContest()) if (position == B_POSITION_OPPONENT_LEFT || position == B_POSITION_PLAYER_RIGHT || IsContest())
@ -652,20 +652,20 @@ static void ScriptCmd_monbg(void)
gAnimScriptCallback = WaitAnimFrameCount; gAnimScriptCallback = WaitAnimFrameCount;
} }
bool8 IsAnimBankSpriteVisible(u8 bank) bool8 IsBattlerSpriteVisible(u8 bank)
{ {
if (IsContest()) if (IsContest())
{ {
if (bank == gAnimBankAttacker) if (bank == gBattleAnimAttacker)
return TRUE; return TRUE;
else else
return FALSE; return FALSE;
} }
if (!IsBankSpritePresent(bank)) if (!IsBattlerSpritePresent(bank))
return FALSE; return FALSE;
if (IsContest()) if (IsContest())
return TRUE; // this line wont ever be reached. return TRUE; // this line wont ever be reached.
if (!gBattleSpritesDataPtr->bankData[bank].invisible || !gSprites[gBankSpriteIds[bank]].invisible) if (!gBattleSpritesDataPtr->bankData[bank].invisible || !gSprites[gBattlerSpriteIds[bank]].invisible)
return TRUE; return TRUE;
return FALSE; return FALSE;
@ -699,7 +699,7 @@ void sub_80A438C(u8 bank, bool8 toBG_2, bool8 setSpriteInvisible)
SetAnimBgAttribute(1, BG_ANIM_SCREEN_SIZE, 1); SetAnimBgAttribute(1, BG_ANIM_SCREEN_SIZE, 1);
SetAnimBgAttribute(1, BG_ANIM_AREA_OVERFLOW_MODE, 0); SetAnimBgAttribute(1, BG_ANIM_AREA_OVERFLOW_MODE, 0);
bankSpriteId = gBankSpriteIds[bank]; bankSpriteId = gBattlerSpriteIds[bank];
gBattle_BG1_X = -(gSprites[bankSpriteId].pos1.x + gSprites[bankSpriteId].pos2.x) + 0x20; gBattle_BG1_X = -(gSprites[bankSpriteId].pos1.x + gSprites[bankSpriteId].pos2.x) + 0x20;
if (IsContest() && IsSpeciesNotUnown(gContestResources->field_18->field_0)) if (IsContest() && IsSpeciesNotUnown(gContestResources->field_18->field_0))
@ -707,7 +707,7 @@ void sub_80A438C(u8 bank, bool8 toBG_2, bool8 setSpriteInvisible)
gBattle_BG1_Y = -(gSprites[bankSpriteId].pos1.y + gSprites[bankSpriteId].pos2.y) + 0x20; gBattle_BG1_Y = -(gSprites[bankSpriteId].pos1.y + gSprites[bankSpriteId].pos2.y) + 0x20;
if (setSpriteInvisible) if (setSpriteInvisible)
gSprites[gBankSpriteIds[bank]].invisible = 1; gSprites[gBattlerSpriteIds[bank]].invisible = 1;
SetGpuReg(REG_OFFSET_BG1HOFS, gBattle_BG1_X); SetGpuReg(REG_OFFSET_BG1HOFS, gBattle_BG1_X);
SetGpuReg(REG_OFFSET_BG1VOFS, gBattle_BG1_Y); SetGpuReg(REG_OFFSET_BG1VOFS, gBattle_BG1_Y);
@ -736,13 +736,13 @@ void sub_80A438C(u8 bank, bool8 toBG_2, bool8 setSpriteInvisible)
SetAnimBgAttribute(2, BG_ANIM_SCREEN_SIZE, 1); SetAnimBgAttribute(2, BG_ANIM_SCREEN_SIZE, 1);
SetAnimBgAttribute(2, BG_ANIM_AREA_OVERFLOW_MODE, 0); SetAnimBgAttribute(2, BG_ANIM_AREA_OVERFLOW_MODE, 0);
bankSpriteId = gBankSpriteIds[bank]; bankSpriteId = gBattlerSpriteIds[bank];
gBattle_BG2_X = -(gSprites[bankSpriteId].pos1.x + gSprites[bankSpriteId].pos2.x) + 0x20; gBattle_BG2_X = -(gSprites[bankSpriteId].pos1.x + gSprites[bankSpriteId].pos2.x) + 0x20;
gBattle_BG2_Y = -(gSprites[bankSpriteId].pos1.y + gSprites[bankSpriteId].pos2.y) + 0x20; gBattle_BG2_Y = -(gSprites[bankSpriteId].pos1.y + gSprites[bankSpriteId].pos2.y) + 0x20;
if (setSpriteInvisible) if (setSpriteInvisible)
gSprites[gBankSpriteIds[bank]].invisible = 1; gSprites[gBattlerSpriteIds[bank]].invisible = 1;
SetGpuReg(REG_OFFSET_BG2HOFS, gBattle_BG2_X); SetGpuReg(REG_OFFSET_BG2HOFS, gBattle_BG2_X);
SetGpuReg(REG_OFFSET_BG2VOFS, gBattle_BG2_Y); SetGpuReg(REG_OFFSET_BG2VOFS, gBattle_BG2_Y);
@ -869,14 +869,14 @@ static void ScriptCmd_clearmonbg(void)
animBankId = ANIM_DEF_PARTNER; animBankId = ANIM_DEF_PARTNER;
if (animBankId == ANIM_ATTACKER || animBankId == ANIM_ATK_PARTNER) if (animBankId == ANIM_ATTACKER || animBankId == ANIM_ATK_PARTNER)
bank = gAnimBankAttacker; bank = gBattleAnimAttacker;
else else
bank = gAnimBankTarget; bank = gBattleAnimTarget;
if (sMonAnimTaskIdArray[0] != 0xFF) if (sMonAnimTaskIdArray[0] != 0xFF)
gSprites[gBankSpriteIds[bank]].invisible = 0; gSprites[gBattlerSpriteIds[bank]].invisible = 0;
if (animBankId > 1 && sMonAnimTaskIdArray[1] != 0xFF) if (animBankId > 1 && sMonAnimTaskIdArray[1] != 0xFF)
gSprites[gBankSpriteIds[bank ^ BIT_FLANK]].invisible = 0; gSprites[gBattlerSpriteIds[bank ^ BIT_FLANK]].invisible = 0;
else else
animBankId = 0; animBankId = 0;
@ -931,11 +931,11 @@ static void ScriptCmd_monbg_22(void)
animBankId = ANIM_DEF_PARTNER; animBankId = ANIM_DEF_PARTNER;
if (animBankId == ANIM_ATTACKER || animBankId == ANIM_ATK_PARTNER) if (animBankId == ANIM_ATTACKER || animBankId == ANIM_ATK_PARTNER)
bank = gAnimBankAttacker; bank = gBattleAnimAttacker;
else else
bank = gAnimBankTarget; bank = gBattleAnimTarget;
if (IsAnimBankSpriteVisible(bank)) if (IsBattlerSpriteVisible(bank))
{ {
u8 position = GetBattlerPosition(bank); u8 position = GetBattlerPosition(bank);
if (position == B_POSITION_OPPONENT_LEFT || position == B_POSITION_PLAYER_RIGHT || IsContest()) if (position == B_POSITION_OPPONENT_LEFT || position == B_POSITION_PLAYER_RIGHT || IsContest())
@ -947,7 +947,7 @@ static void ScriptCmd_monbg_22(void)
} }
bank ^= BIT_FLANK; bank ^= BIT_FLANK;
if (animBankId > 1 && IsAnimBankSpriteVisible(bank)) if (animBankId > 1 && IsBattlerSpriteVisible(bank))
{ {
u8 position = GetBattlerPosition(bank); u8 position = GetBattlerPosition(bank);
if (position == B_POSITION_OPPONENT_LEFT || position == B_POSITION_PLAYER_RIGHT || IsContest()) if (position == B_POSITION_OPPONENT_LEFT || position == B_POSITION_PLAYER_RIGHT || IsContest())
@ -976,14 +976,14 @@ static void ScriptCmd_clearmonbg_23(void)
animBankId = ANIM_DEF_PARTNER; animBankId = ANIM_DEF_PARTNER;
if (animBankId == ANIM_ATTACKER || animBankId == ANIM_ATK_PARTNER) if (animBankId == ANIM_ATTACKER || animBankId == ANIM_ATK_PARTNER)
bank = gAnimBankAttacker; bank = gBattleAnimAttacker;
else else
bank = gAnimBankTarget; bank = gBattleAnimTarget;
if (IsAnimBankSpriteVisible(bank)) if (IsBattlerSpriteVisible(bank))
gSprites[gBankSpriteIds[bank]].invisible = 0; gSprites[gBattlerSpriteIds[bank]].invisible = 0;
if (animBankId > 1 && IsAnimBankSpriteVisible(bank ^ BIT_FLANK)) if (animBankId > 1 && IsBattlerSpriteVisible(bank ^ BIT_FLANK))
gSprites[gBankSpriteIds[bank ^ BIT_FLANK]].invisible = 0; gSprites[gBattlerSpriteIds[bank ^ BIT_FLANK]].invisible = 0;
else else
animBankId = 0; animBankId = 0;
@ -1007,9 +1007,9 @@ static void sub_80A4BB0(u8 taskId)
else else
toBG_2 = TRUE; toBG_2 = TRUE;
if (IsAnimBankSpriteVisible(bank)) if (IsBattlerSpriteVisible(bank))
sub_80A477C(toBG_2); sub_80A477C(toBG_2);
if (gTasks[taskId].data[0] > 1 && IsAnimBankSpriteVisible(bank ^ BIT_FLANK)) if (gTasks[taskId].data[0] > 1 && IsBattlerSpriteVisible(bank ^ BIT_FLANK))
sub_80A477C(toBG_2 ^ 1); sub_80A477C(toBG_2 ^ 1);
DestroyTask(taskId); DestroyTask(taskId);
@ -1145,7 +1145,7 @@ static void ScriptCmd_fadetobgfromset(void)
if (IsContest()) if (IsContest())
gTasks[taskId].tBackgroundId = bg3; gTasks[taskId].tBackgroundId = bg3;
else if (GetBattlerSide(gAnimBankTarget) == B_SIDE_PLAYER) else if (GetBattlerSide(gBattleAnimTarget) == B_SIDE_PLAYER)
gTasks[taskId].tBackgroundId = bg2; gTasks[taskId].tBackgroundId = bg2;
else else
gTasks[taskId].tBackgroundId = bg1; gTasks[taskId].tBackgroundId = bg1;
@ -1270,21 +1270,21 @@ static void ScriptCmd_changebg(void)
s8 BattleAnimAdjustPanning(s8 pan) s8 BattleAnimAdjustPanning(s8 pan)
{ {
if (!IsContest() && gBattleSpritesDataPtr->healthBoxesData[gAnimBankAttacker].statusAnimActive) if (!IsContest() && gBattleSpritesDataPtr->healthBoxesData[gBattleAnimAttacker].statusAnimActive)
{ {
if (GetBattlerSide(gAnimBankAttacker) != B_SIDE_PLAYER) if (GetBattlerSide(gBattleAnimAttacker) != B_SIDE_PLAYER)
pan = PAN_SIDE_OPPONENT; pan = PAN_SIDE_OPPONENT;
else else
pan = PAN_SIDE_PLAYER; pan = PAN_SIDE_PLAYER;
} }
else if (IsContest()) else if (IsContest())
{ {
if (gAnimBankAttacker != gAnimBankTarget || gAnimBankAttacker != 2 || pan != PAN_SIDE_OPPONENT) if (gBattleAnimAttacker != gBattleAnimTarget || gBattleAnimAttacker != 2 || pan != PAN_SIDE_OPPONENT)
pan *= -1; pan *= -1;
} }
else if (GetBattlerSide(gAnimBankAttacker) == B_SIDE_PLAYER) else if (GetBattlerSide(gBattleAnimAttacker) == B_SIDE_PLAYER)
{ {
if (GetBattlerSide(gAnimBankTarget) == B_SIDE_PLAYER) if (GetBattlerSide(gBattleAnimTarget) == B_SIDE_PLAYER)
{ {
if (pan == PAN_SIDE_OPPONENT) if (pan == PAN_SIDE_OPPONENT)
pan = PAN_SIDE_PLAYER; pan = PAN_SIDE_PLAYER;
@ -1292,7 +1292,7 @@ s8 BattleAnimAdjustPanning(s8 pan)
pan *= -1; pan *= -1;
} }
} }
else if (GetBattlerSide(gAnimBankTarget) == B_SIDE_OPPONENT) else if (GetBattlerSide(gBattleAnimTarget) == B_SIDE_OPPONENT)
{ {
if (pan == PAN_SIDE_PLAYER) if (pan == PAN_SIDE_PLAYER)
pan = PAN_SIDE_OPPONENT; pan = PAN_SIDE_OPPONENT;
@ -1312,16 +1312,16 @@ s8 BattleAnimAdjustPanning(s8 pan)
s8 BattleAnimAdjustPanning2(s8 pan) s8 BattleAnimAdjustPanning2(s8 pan)
{ {
if (!IsContest() && gBattleSpritesDataPtr->healthBoxesData[gAnimBankAttacker].statusAnimActive) if (!IsContest() && gBattleSpritesDataPtr->healthBoxesData[gBattleAnimAttacker].statusAnimActive)
{ {
if (GetBattlerSide(gAnimBankAttacker) != B_SIDE_PLAYER) if (GetBattlerSide(gBattleAnimAttacker) != B_SIDE_PLAYER)
pan = PAN_SIDE_OPPONENT; pan = PAN_SIDE_OPPONENT;
else else
pan = PAN_SIDE_PLAYER; pan = PAN_SIDE_PLAYER;
} }
else else
{ {
if (GetBattlerSide(gAnimBankAttacker) != B_SIDE_PLAYER || IsContest()) if (GetBattlerSide(gBattleAnimAttacker) != B_SIDE_PLAYER || IsContest())
pan = -pan; pan = -pan;
} }
return pan; return pan;
@ -1701,9 +1701,9 @@ static void ScriptCmd_monbgprio_28(void)
sBattleAnimScriptPtr += 2; sBattleAnimScriptPtr += 2;
if (wantedBank != ANIM_ATTACKER) if (wantedBank != ANIM_ATTACKER)
bank = gAnimBankTarget; bank = gBattleAnimTarget;
else else
bank = gAnimBankAttacker; bank = gBattleAnimAttacker;
bankIdentity = GetBattlerPosition(bank); bankIdentity = GetBattlerPosition(bank);
if (!IsContest() && (bankIdentity == B_POSITION_PLAYER_LEFT || bankIdentity == B_POSITION_OPPONENT_RIGHT)) if (!IsContest() && (bankIdentity == B_POSITION_PLAYER_LEFT || bankIdentity == B_POSITION_OPPONENT_RIGHT))
@ -1731,12 +1731,12 @@ static void ScriptCmd_monbgprio_2A(void)
wantedBank = sBattleAnimScriptPtr[1]; wantedBank = sBattleAnimScriptPtr[1];
sBattleAnimScriptPtr += 2; sBattleAnimScriptPtr += 2;
if (GetBattlerSide(gAnimBankAttacker) != GetBattlerSide(gAnimBankTarget)) if (GetBattlerSide(gBattleAnimAttacker) != GetBattlerSide(gBattleAnimTarget))
{ {
if (wantedBank != ANIM_ATTACKER) if (wantedBank != ANIM_ATTACKER)
bank = gAnimBankTarget; bank = gBattleAnimTarget;
else else
bank = gAnimBankAttacker; bank = gBattleAnimAttacker;
bankIdentity = GetBattlerPosition(bank); bankIdentity = GetBattlerPosition(bank);
if (!IsContest() && (bankIdentity == B_POSITION_PLAYER_LEFT || bankIdentity == B_POSITION_OPPONENT_RIGHT)) if (!IsContest() && (bankIdentity == B_POSITION_PLAYER_LEFT || bankIdentity == B_POSITION_OPPONENT_RIGHT))
@ -1751,7 +1751,7 @@ static void ScriptCmd_invisible(void)
{ {
u8 spriteId; u8 spriteId;
spriteId = GetAnimBankSpriteId(sBattleAnimScriptPtr[1]); spriteId = GetBattlerSpriteId(sBattleAnimScriptPtr[1]);
if (spriteId != 0xFF) if (spriteId != 0xFF)
gSprites[spriteId].invisible = 1; gSprites[spriteId].invisible = 1;
@ -1762,7 +1762,7 @@ static void ScriptCmd_visible(void)
{ {
u8 spriteId; u8 spriteId;
spriteId = GetAnimBankSpriteId(sBattleAnimScriptPtr[1]); spriteId = GetBattlerSpriteId(sBattleAnimScriptPtr[1]);
if (spriteId != 0xFF) if (spriteId != 0xFF)
gSprites[spriteId].invisible = 0; gSprites[spriteId].invisible = 0;
@ -1778,17 +1778,17 @@ static void ScriptCmd_doublebattle_2D(void)
wantedBank = sBattleAnimScriptPtr[1]; wantedBank = sBattleAnimScriptPtr[1];
sBattleAnimScriptPtr += 2; sBattleAnimScriptPtr += 2;
if (!IsContest() && IsDoubleBattle() if (!IsContest() && IsDoubleBattle()
&& GetBattlerSide(gAnimBankAttacker) == GetBattlerSide(gAnimBankTarget)) && GetBattlerSide(gBattleAnimAttacker) == GetBattlerSide(gBattleAnimTarget))
{ {
if (wantedBank == ANIM_ATTACKER) if (wantedBank == ANIM_ATTACKER)
{ {
r4 = sub_80A8364(gAnimBankAttacker); r4 = sub_80A8364(gBattleAnimAttacker);
spriteId = GetAnimBankSpriteId(ANIM_ATTACKER); spriteId = GetBattlerSpriteId(ANIM_ATTACKER);
} }
else else
{ {
r4 = sub_80A8364(gAnimBankTarget); r4 = sub_80A8364(gBattleAnimTarget);
spriteId = GetAnimBankSpriteId(ANIM_TARGET); spriteId = GetBattlerSpriteId(ANIM_TARGET);
} }
if (spriteId != 0xFF) if (spriteId != 0xFF)
{ {
@ -1813,17 +1813,17 @@ static void ScriptCmd_doublebattle_2E(void)
wantedBank = sBattleAnimScriptPtr[1]; wantedBank = sBattleAnimScriptPtr[1];
sBattleAnimScriptPtr += 2; sBattleAnimScriptPtr += 2;
if (!IsContest() && IsDoubleBattle() if (!IsContest() && IsDoubleBattle()
&& GetBattlerSide(gAnimBankAttacker) == GetBattlerSide(gAnimBankTarget)) && GetBattlerSide(gBattleAnimAttacker) == GetBattlerSide(gBattleAnimTarget))
{ {
if (wantedBank == ANIM_ATTACKER) if (wantedBank == ANIM_ATTACKER)
{ {
r4 = sub_80A8364(gAnimBankAttacker); r4 = sub_80A8364(gBattleAnimAttacker);
spriteId = GetAnimBankSpriteId(ANIM_ATTACKER); spriteId = GetBattlerSpriteId(ANIM_ATTACKER);
} }
else else
{ {
r4 = sub_80A8364(gAnimBankTarget); r4 = sub_80A8364(gBattleAnimTarget);
spriteId = GetAnimBankSpriteId(ANIM_TARGET); spriteId = GetBattlerSpriteId(ANIM_TARGET);
} }
if (spriteId != 0xFF && r4 == 2) if (spriteId != 0xFF && r4 == 2)

View File

@ -24,21 +24,21 @@
#include "pokeball.h" #include "pokeball.h"
#include "data2.h" #include "data2.h"
extern u32 gBattleExecBuffer; extern u32 gBattleControllerExecFlags;
extern u8 gActiveBattler; extern u8 gActiveBattler;
extern u8 gBankSpriteIds[MAX_BATTLERS_COUNT]; extern u8 gBattlerSpriteIds[MAX_BATTLERS_COUNT];
extern u8 gActionSelectionCursor[MAX_BATTLERS_COUNT]; extern u8 gActionSelectionCursor[MAX_BATTLERS_COUNT];
extern u8 gBattlersCount; extern u8 gBattlersCount;
extern bool8 gDoingBattleAnim; extern bool8 gDoingBattleAnim;
extern void (*gBattlerFuncs[MAX_BATTLERS_COUNT])(void); extern void (*gBattlerControllerFuncs[MAX_BATTLERS_COUNT])(void);
extern void (*gPreBattleCallback1)(void); extern void (*gPreBattleCallback1)(void);
extern u16 gBattlePartyID[MAX_BATTLERS_COUNT]; extern u16 gBattlerPartyIndexes[MAX_BATTLERS_COUNT];
extern u8 gBattleBufferA[MAX_BATTLERS_COUNT][0x200]; extern u8 gBattleBufferA[MAX_BATTLERS_COUNT][0x200];
extern u8 gBattleBufferB[MAX_BATTLERS_COUNT][0x200]; extern u8 gBattleBufferB[MAX_BATTLERS_COUNT][0x200];
extern struct BattlePokemon gBattleMons[MAX_BATTLERS_COUNT]; extern struct BattlePokemon gBattleMons[MAX_BATTLERS_COUNT];
extern struct SpriteTemplate gUnknown_0202499C; extern struct SpriteTemplate gUnknown_0202499C;
extern u16 gSpecialVar_ItemId; extern u16 gSpecialVar_ItemId;
extern u8 gHealthBoxesIds[MAX_BATTLERS_COUNT]; extern u8 gHealthboxSpriteIds[MAX_BATTLERS_COUNT];
extern u8 gBattleOutcome; extern u8 gBattleOutcome;
extern u16 gBattle_BG0_X; extern u16 gBattle_BG0_X;
extern u16 gBattle_BG0_Y; extern u16 gBattle_BG0_Y;
@ -47,7 +47,7 @@ extern u8 gUnknown_03005D7C[MAX_BATTLERS_COUNT];
extern u8 gBattleMonForms[MAX_BATTLERS_COUNT]; extern u8 gBattleMonForms[MAX_BATTLERS_COUNT];
extern u16 gPartnerTrainerId; extern u16 gPartnerTrainerId;
extern u8 GetFrontierTrainerFrontSpriteId(u16 trainerId); extern u8 GetFrontierTrainerFrontSpriteId(u16 trainerId);
extern u8 gBattleDefender; extern u8 gBattleMoveTarget;
extern u8 gAbsentBattlerFlags; extern u8 gAbsentBattlerFlags;
extern u8 gUnknown_020244B4[]; extern u8 gUnknown_020244B4[];
extern u32 gTransformedPersonalities[MAX_BATTLERS_COUNT]; extern u32 gTransformedPersonalities[MAX_BATTLERS_COUNT];
@ -203,12 +203,12 @@ static void nullsub_28(void)
void SetControllerToLinkOpponent(void) void SetControllerToLinkOpponent(void)
{ {
gBattlerFuncs[gActiveBattler] = LinkOpponentBufferRunCommand; gBattlerControllerFuncs[gActiveBattler] = LinkOpponentBufferRunCommand;
} }
static void LinkOpponentBufferRunCommand(void) static void LinkOpponentBufferRunCommand(void)
{ {
if (gBattleExecBuffer & gBitTable[gActiveBattler]) if (gBattleControllerExecFlags & gBitTable[gActiveBattler])
{ {
if (gBattleBufferA[gActiveBattler][0] < ARRAY_COUNT(sLinkOpponentBufferCommands)) if (gBattleBufferA[gActiveBattler][0] < ARRAY_COUNT(sLinkOpponentBufferCommands))
sLinkOpponentBufferCommands[gBattleBufferA[gActiveBattler][0]](); sLinkOpponentBufferCommands[gBattleBufferA[gActiveBattler][0]]();
@ -219,23 +219,23 @@ static void LinkOpponentBufferRunCommand(void)
static void CompleteOnBankSpriteCallbackDummy(void) static void CompleteOnBankSpriteCallbackDummy(void)
{ {
if (gSprites[gBankSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy) if (gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
LinkOpponentBufferExecCompleted(); LinkOpponentBufferExecCompleted();
} }
static void CompleteOnBankSpriteCallbackDummy2(void) static void CompleteOnBankSpriteCallbackDummy2(void)
{ {
if (gSprites[gBankSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy) if (gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
LinkOpponentBufferExecCompleted(); LinkOpponentBufferExecCompleted();
} }
static void sub_8064470(void) static void sub_8064470(void)
{ {
if (gSprites[gBankSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy) if (gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
{ {
FreeTrainerFrontPicPalette(gSprites[gBankSpriteIds[gActiveBattler]].oam.affineParam); FreeTrainerFrontPicPalette(gSprites[gBattlerSpriteIds[gActiveBattler]].oam.affineParam);
FreeSpriteOamMatrix(&gSprites[gBankSpriteIds[gActiveBattler]]); FreeSpriteOamMatrix(&gSprites[gBattlerSpriteIds[gActiveBattler]]);
DestroySprite(&gSprites[gBankSpriteIds[gActiveBattler]]); DestroySprite(&gSprites[gBattlerSpriteIds[gActiveBattler]]);
LinkOpponentBufferExecCompleted(); LinkOpponentBufferExecCompleted();
} }
} }
@ -256,13 +256,13 @@ static void sub_8064520(void)
if (!IsDoubleBattle() || (IsDoubleBattle() && (gBattleTypeFlags & BATTLE_TYPE_MULTI))) if (!IsDoubleBattle() || (IsDoubleBattle() && (gBattleTypeFlags & BATTLE_TYPE_MULTI)))
{ {
if (gSprites[gHealthBoxesIds[gActiveBattler]].callback == SpriteCallbackDummy) if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
r8 = TRUE; r8 = TRUE;
} }
else else
{ {
if (gSprites[gHealthBoxesIds[gActiveBattler]].callback == SpriteCallbackDummy if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy
&& gSprites[gHealthBoxesIds[gActiveBattler ^ BIT_FLANK]].callback == SpriteCallbackDummy) && gSprites[gHealthboxSpriteIds[gActiveBattler ^ BIT_FLANK]].callback == SpriteCallbackDummy)
{ {
r8 = TRUE; r8 = TRUE;
} }
@ -271,7 +271,7 @@ static void sub_8064520(void)
if (r8) if (r8)
{ {
if (r4 || !IsAnimBankSpriteVisible(gActiveBattler ^ BIT_FLANK)) if (r4 || !IsBattlerSpriteVisible(gActiveBattler ^ BIT_FLANK))
{ {
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x1) if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x1)
return; return;
@ -303,7 +303,7 @@ static void sub_8064520(void)
} }
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_9 = 3; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_9 = 3;
gBattlerFuncs[gActiveBattler] = sub_80644D8; gBattlerControllerFuncs[gActiveBattler] = sub_80644D8;
} }
} }
@ -315,14 +315,14 @@ static void sub_8064734(void)
&& !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].flag_x80 && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].flag_x80
&& !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x1) && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x1)
{ {
sub_8172EF0(gActiveBattler, &gEnemyParty[gBattlePartyID[gActiveBattler]]); sub_8172EF0(gActiveBattler, &gEnemyParty[gBattlerPartyIndexes[gActiveBattler]]);
} }
if (!(gBattleTypeFlags & BATTLE_TYPE_MULTI) if (!(gBattleTypeFlags & BATTLE_TYPE_MULTI)
&& !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].ballAnimActive && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].ballAnimActive
&& !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].flag_x80 && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].flag_x80
&& !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].field_1_x1) && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].field_1_x1)
{ {
sub_8172EF0(gActiveBattler ^ BIT_FLANK, &gEnemyParty[gBattlePartyID[gActiveBattler ^ BIT_FLANK]]); sub_8172EF0(gActiveBattler ^ BIT_FLANK, &gEnemyParty[gBattlerPartyIndexes[gActiveBattler ^ BIT_FLANK]]);
} }
@ -332,13 +332,13 @@ static void sub_8064734(void)
{ {
if (IsDoubleBattle() && !(gBattleTypeFlags & BATTLE_TYPE_MULTI)) if (IsDoubleBattle() && !(gBattleTypeFlags & BATTLE_TYPE_MULTI))
{ {
UpdateHealthboxAttribute(gHealthBoxesIds[gActiveBattler ^ BIT_FLANK], &gEnemyParty[gBattlePartyID[gActiveBattler ^ BIT_FLANK]], HEALTHBOX_ALL); UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler ^ BIT_FLANK], &gEnemyParty[gBattlerPartyIndexes[gActiveBattler ^ BIT_FLANK]], HEALTHBOX_ALL);
sub_8076918(gActiveBattler ^ BIT_FLANK); sub_8076918(gActiveBattler ^ BIT_FLANK);
SetHealthboxSpriteVisible(gHealthBoxesIds[gActiveBattler ^ BIT_FLANK]); SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler ^ BIT_FLANK]);
} }
UpdateHealthboxAttribute(gHealthBoxesIds[gActiveBattler], &gEnemyParty[gBattlePartyID[gActiveBattler]], HEALTHBOX_ALL); UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler], &gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], HEALTHBOX_ALL);
sub_8076918(gActiveBattler); sub_8076918(gActiveBattler);
SetHealthboxSpriteVisible(gHealthBoxesIds[gActiveBattler]); SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]);
} }
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x80 = 1; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x80 = 1;
} }
@ -368,7 +368,7 @@ static void sub_8064734(void)
if (r10) if (r10)
{ {
if (gSprites[gUnknown_03005D7C[gActiveBattler]].callback == SpriteCallbackDummy if (gSprites[gUnknown_03005D7C[gActiveBattler]].callback == SpriteCallbackDummy
&& gSprites[gBankSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy) && gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
{ {
if (gBattleTypeFlags & BATTLE_TYPE_MULTI && GetBattlerPosition(gActiveBattler) == B_POSITION_OPPONENT_RIGHT) if (gBattleTypeFlags & BATTLE_TYPE_MULTI && GetBattlerPosition(gActiveBattler) == B_POSITION_OPPONENT_RIGHT)
{ {
@ -380,30 +380,30 @@ static void sub_8064734(void)
if (IsDoubleBattle() && !(gBattleTypeFlags & BATTLE_TYPE_MULTI)) if (IsDoubleBattle() && !(gBattleTypeFlags & BATTLE_TYPE_MULTI))
{ {
DestroySprite(&gSprites[gUnknown_03005D7C[gActiveBattler ^ BIT_FLANK]]); DestroySprite(&gSprites[gUnknown_03005D7C[gActiveBattler ^ BIT_FLANK]]);
SetBankEnemyShadowSpriteCallback(gActiveBattler ^ BIT_FLANK, GetMonData(&gEnemyParty[gBattlePartyID[gActiveBattler ^ BIT_FLANK]], MON_DATA_SPECIES)); SetBattlerShadowSpriteCallback(gActiveBattler ^ BIT_FLANK, GetMonData(&gEnemyParty[gBattlerPartyIndexes[gActiveBattler ^ BIT_FLANK]], MON_DATA_SPECIES));
} }
DestroySprite(&gSprites[gUnknown_03005D7C[gActiveBattler]]); DestroySprite(&gSprites[gUnknown_03005D7C[gActiveBattler]]);
SetBankEnemyShadowSpriteCallback(gActiveBattler, GetMonData(&gEnemyParty[gBattlePartyID[gActiveBattler]], MON_DATA_SPECIES)); SetBattlerShadowSpriteCallback(gActiveBattler, GetMonData(&gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_SPECIES));
gBattleSpritesDataPtr->animationData->field_9_x1 = 0; gBattleSpritesDataPtr->animationData->field_9_x1 = 0;
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x20 = 0; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x20 = 0;
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x80 = 0; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x80 = 0;
gBattlerFuncs[gActiveBattler] = sub_8064520; gBattlerControllerFuncs[gActiveBattler] = sub_8064520;
} }
} }
} }
static void sub_8064B04(void) static void sub_8064B04(void)
{ {
if (gSprites[gBankSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy if (gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy
&& gSprites[gBankSpriteIds[gActiveBattler]].pos2.x == 0) && gSprites[gBattlerSpriteIds[gActiveBattler]].pos2.x == 0)
{ {
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].flag_x80) if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].flag_x80)
{ {
sub_8172EF0(gActiveBattler, &gEnemyParty[gBattlePartyID[gActiveBattler]]); sub_8172EF0(gActiveBattler, &gEnemyParty[gBattlerPartyIndexes[gActiveBattler]]);
} }
else else
{ {
@ -421,13 +421,13 @@ static void sub_8064B04(void)
static void CompleteOnHealthbarDone(void) static void CompleteOnHealthbarDone(void)
{ {
s16 hpValue = sub_8074AA0(gActiveBattler, gHealthBoxesIds[gActiveBattler], HEALTH_BAR, 0); s16 hpValue = sub_8074AA0(gActiveBattler, gHealthboxSpriteIds[gActiveBattler], HEALTH_BAR, 0);
SetHealthboxSpriteVisible(gHealthBoxesIds[gActiveBattler]); SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]);
if (hpValue != -1) if (hpValue != -1)
{ {
UpdateHpTextInHealthbox(gHealthBoxesIds[gActiveBattler], hpValue, HP_CURRENT); UpdateHpTextInHealthbox(gHealthboxSpriteIds[gActiveBattler], hpValue, HP_CURRENT);
} }
else else
{ {
@ -437,9 +437,9 @@ static void CompleteOnHealthbarDone(void)
static void sub_8064C14(void) static void sub_8064C14(void)
{ {
if (!gSprites[gBankSpriteIds[gActiveBattler]].inUse) if (!gSprites[gBattlerSpriteIds[gActiveBattler]].inUse)
{ {
SetHealthboxSpriteInvisible(gHealthBoxesIds[gActiveBattler]); SetHealthboxSpriteInvisible(gHealthboxSpriteIds[gActiveBattler]);
LinkOpponentBufferExecCompleted(); LinkOpponentBufferExecCompleted();
} }
} }
@ -448,10 +448,10 @@ static void sub_8064C58(void)
{ {
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive) if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive)
{ {
FreeSpriteOamMatrix(&gSprites[gBankSpriteIds[gActiveBattler]]); FreeSpriteOamMatrix(&gSprites[gBattlerSpriteIds[gActiveBattler]]);
DestroySprite(&gSprites[gBankSpriteIds[gActiveBattler]]); DestroySprite(&gSprites[gBattlerSpriteIds[gActiveBattler]]);
EnemyShadowCallbackToSetInvisible(gActiveBattler); HideBattlerShadowSprite(gActiveBattler);
SetHealthboxSpriteInvisible(gHealthBoxesIds[gActiveBattler]); SetHealthboxSpriteInvisible(gHealthboxSpriteIds[gActiveBattler]);
LinkOpponentBufferExecCompleted(); LinkOpponentBufferExecCompleted();
} }
} }
@ -464,7 +464,7 @@ static void CompleteOnInactiveTextPrinter(void)
static void DoHitAnimBlinkSpriteEffect(void) static void DoHitAnimBlinkSpriteEffect(void)
{ {
u8 spriteId = gBankSpriteIds[gActiveBattler]; u8 spriteId = gBattlerSpriteIds[gActiveBattler];
if (gSprites[spriteId].data[1] == 32) if (gSprites[spriteId].data[1] == 32)
{ {
@ -483,12 +483,12 @@ static void DoHitAnimBlinkSpriteEffect(void)
static void sub_8064D60(void) static void sub_8064D60(void)
{ {
if (gSprites[gHealthBoxesIds[gActiveBattler]].callback == SpriteCallbackDummy) if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
{ {
if (gBattleSpritesDataPtr->bankData[gActiveBattler].behindSubstitute) if (gBattleSpritesDataPtr->bankData[gActiveBattler].behindSubstitute)
InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_MON_TO_SUBSTITUTE); InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_MON_TO_SUBSTITUTE);
gBattlerFuncs[gActiveBattler] = sub_8064DD0; gBattlerControllerFuncs[gActiveBattler] = sub_8064DD0;
} }
} }
@ -496,8 +496,8 @@ static void sub_8064DD0(void)
{ {
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive && !IsCryPlayingOrClearCrySongs()) if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive && !IsCryPlayingOrClearCrySongs())
{ {
if (gSprites[gBankSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy if (gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy
|| gSprites[gBankSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy_2) || gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy_2)
{ {
m4aMPlayVolumeControl(&gMPlayInfo_BGM, 0xFFFF, 0x100); m4aMPlayVolumeControl(&gMPlayInfo_BGM, 0xFFFF, 0x100);
LinkOpponentBufferExecCompleted(); LinkOpponentBufferExecCompleted();
@ -508,7 +508,7 @@ static void sub_8064DD0(void)
static void sub_8064E50(void) static void sub_8064E50(void)
{ {
if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x1 if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x1
&& gSprites[gBankSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy) && gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
{ {
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].flag_x80 = 0; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].flag_x80 = 0;
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x1 = 0; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x1 = 0;
@ -516,13 +516,13 @@ static void sub_8064E50(void)
FreeSpriteTilesByTag(0x27F9); FreeSpriteTilesByTag(0x27F9);
FreeSpritePaletteByTag(0x27F9); FreeSpritePaletteByTag(0x27F9);
StartSpriteAnim(&gSprites[gBankSpriteIds[gActiveBattler]], 0); StartSpriteAnim(&gSprites[gBattlerSpriteIds[gActiveBattler]], 0);
UpdateHealthboxAttribute(gHealthBoxesIds[gActiveBattler], &gEnemyParty[gBattlePartyID[gActiveBattler]], HEALTHBOX_ALL); UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler], &gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], HEALTHBOX_ALL);
sub_8076918(gActiveBattler); sub_8076918(gActiveBattler);
SetHealthboxSpriteVisible(gHealthBoxesIds[gActiveBattler]); SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]);
CopyBattleSpriteInvisibility(gActiveBattler); CopyBattleSpriteInvisibility(gActiveBattler);
gBattlerFuncs[gActiveBattler] = sub_8064D60; gBattlerControllerFuncs[gActiveBattler] = sub_8064D60;
} }
} }
@ -531,15 +531,15 @@ static void sub_8064F40(void)
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive
&& !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].flag_x80) && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].flag_x80)
{ {
sub_8172EF0(gActiveBattler, &gEnemyParty[gBattlePartyID[gActiveBattler]]); sub_8172EF0(gActiveBattler, &gEnemyParty[gBattlerPartyIndexes[gActiveBattler]]);
} }
if (gSprites[gUnknown_03005D7C[gActiveBattler]].callback == SpriteCallbackDummy if (gSprites[gUnknown_03005D7C[gActiveBattler]].callback == SpriteCallbackDummy
&& !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive) && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive)
{ {
DestroySprite(&gSprites[gUnknown_03005D7C[gActiveBattler]]); DestroySprite(&gSprites[gUnknown_03005D7C[gActiveBattler]]);
SetBankEnemyShadowSpriteCallback(gActiveBattler, GetMonData(&gEnemyParty[gBattlePartyID[gActiveBattler]], MON_DATA_SPECIES)); SetBattlerShadowSpriteCallback(gActiveBattler, GetMonData(&gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_SPECIES));
gBattlerFuncs[gActiveBattler] = sub_8064E50; gBattlerControllerFuncs[gActiveBattler] = sub_8064E50;
} }
} }
@ -557,7 +557,7 @@ static void CompleteOnFinishedBattleAnimation(void)
static void LinkOpponentBufferExecCompleted(void) static void LinkOpponentBufferExecCompleted(void)
{ {
gBattlerFuncs[gActiveBattler] = LinkOpponentBufferRunCommand; gBattlerControllerFuncs[gActiveBattler] = LinkOpponentBufferRunCommand;
if (gBattleTypeFlags & BATTLE_TYPE_LINK) if (gBattleTypeFlags & BATTLE_TYPE_LINK)
{ {
u8 playerId = GetMultiplayerId(); u8 playerId = GetMultiplayerId();
@ -567,7 +567,7 @@ static void LinkOpponentBufferExecCompleted(void)
} }
else else
{ {
gBattleExecBuffer &= ~gBitTable[gActiveBattler]; gBattleControllerExecFlags &= ~gBitTable[gActiveBattler];
} }
} }
@ -580,7 +580,7 @@ static void LinkOpponentHandleGetMonData(void)
if (gBattleBufferA[gActiveBattler][2] == 0) if (gBattleBufferA[gActiveBattler][2] == 0)
{ {
size += CopyLinkOpponentMonData(gBattlePartyID[gActiveBattler], monData); size += CopyLinkOpponentMonData(gBattlerPartyIndexes[gActiveBattler], monData);
} }
else else
{ {
@ -592,7 +592,7 @@ static void LinkOpponentHandleGetMonData(void)
monToCheck >>= 1; monToCheck >>= 1;
} }
} }
EmitDataTransfer(1, size, monData); BtlController_EmitDataTransfer(1, size, monData);
LinkOpponentBufferExecCompleted(); LinkOpponentBufferExecCompleted();
} }
@ -914,7 +914,7 @@ static void LinkOpponentHandleSetMonData(void)
if (gBattleBufferA[gActiveBattler][2] == 0) if (gBattleBufferA[gActiveBattler][2] == 0)
{ {
SetLinkOpponentMonData(gBattlePartyID[gActiveBattler]); SetLinkOpponentMonData(gBattlerPartyIndexes[gActiveBattler]);
} }
else else
{ {
@ -1147,7 +1147,7 @@ static void SetLinkOpponentMonData(u8 monId)
static void LinkOpponentHandleSetRawMonData(void) static void LinkOpponentHandleSetRawMonData(void)
{ {
u8 *dst = (u8 *)&gEnemyParty[gBattlePartyID[gActiveBattler]] + gBattleBufferA[gActiveBattler][1]; u8 *dst = (u8 *)&gEnemyParty[gBattlerPartyIndexes[gActiveBattler]] + gBattleBufferA[gActiveBattler][1];
u8 i; u8 i;
for (i = 0; i < gBattleBufferA[gActiveBattler][2]; i++) for (i = 0; i < gBattleBufferA[gActiveBattler][2]; i++)
@ -1158,31 +1158,31 @@ static void LinkOpponentHandleSetRawMonData(void)
static void LinkOpponentHandleLoadMonSprite(void) static void LinkOpponentHandleLoadMonSprite(void)
{ {
u16 species = GetMonData(&gEnemyParty[gBattlePartyID[gActiveBattler]], MON_DATA_SPECIES); u16 species = GetMonData(&gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_SPECIES);
BattleLoadOpponentMonSpriteGfx(&gEnemyParty[gBattlePartyID[gActiveBattler]], gActiveBattler); BattleLoadOpponentMonSpriteGfx(&gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler);
sub_806A068(species, GetBattlerPosition(gActiveBattler)); sub_806A068(species, GetBattlerPosition(gActiveBattler));
gBankSpriteIds[gActiveBattler] = CreateSprite(&gUnknown_0202499C, gBattlerSpriteIds[gActiveBattler] = CreateSprite(&gUnknown_0202499C,
GetBankCoord(gActiveBattler, 2), GetBattlerSpriteCoord(gActiveBattler, 2),
GetBankSpriteDefault_Y(gActiveBattler), GetBattlerSpriteDefault_Y(gActiveBattler),
sub_80A82E4(gActiveBattler)); sub_80A82E4(gActiveBattler));
gSprites[gBankSpriteIds[gActiveBattler]].pos2.x = -240; gSprites[gBattlerSpriteIds[gActiveBattler]].pos2.x = -240;
gSprites[gBankSpriteIds[gActiveBattler]].data[0] = gActiveBattler; gSprites[gBattlerSpriteIds[gActiveBattler]].data[0] = gActiveBattler;
gSprites[gBankSpriteIds[gActiveBattler]].oam.paletteNum = gActiveBattler; gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = gActiveBattler;
StartSpriteAnim(&gSprites[gBankSpriteIds[gActiveBattler]], gBattleMonForms[gActiveBattler]); StartSpriteAnim(&gSprites[gBattlerSpriteIds[gActiveBattler]], gBattleMonForms[gActiveBattler]);
SetBankEnemyShadowSpriteCallback(gActiveBattler, GetMonData(&gEnemyParty[gBattlePartyID[gActiveBattler]], MON_DATA_SPECIES)); SetBattlerShadowSpriteCallback(gActiveBattler, GetMonData(&gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_SPECIES));
gBattlerFuncs[gActiveBattler] = sub_8064B04; gBattlerControllerFuncs[gActiveBattler] = sub_8064B04;
} }
static void LinkOpponentHandleSwitchInAnim(void) static void LinkOpponentHandleSwitchInAnim(void)
{ {
gBattlePartyID[gActiveBattler] = gBattleBufferA[gActiveBattler][1]; gBattlerPartyIndexes[gActiveBattler] = gBattleBufferA[gActiveBattler][1];
sub_8066494(gActiveBattler, gBattleBufferA[gActiveBattler][2]); sub_8066494(gActiveBattler, gBattleBufferA[gActiveBattler][2]);
gBattlerFuncs[gActiveBattler] = sub_8064F40; gBattlerControllerFuncs[gActiveBattler] = sub_8064F40;
} }
static void sub_8066494(u8 bank, bool8 dontClearSubstituteBit) static void sub_8066494(u8 bank, bool8 dontClearSubstituteBit)
@ -1190,29 +1190,29 @@ static void sub_8066494(u8 bank, bool8 dontClearSubstituteBit)
u16 species; u16 species;
ClearTemporarySpeciesSpriteData(bank, dontClearSubstituteBit); ClearTemporarySpeciesSpriteData(bank, dontClearSubstituteBit);
gBattlePartyID[bank] = gBattleBufferA[bank][1]; gBattlerPartyIndexes[bank] = gBattleBufferA[bank][1];
species = GetMonData(&gEnemyParty[gBattlePartyID[bank]], MON_DATA_SPECIES); species = GetMonData(&gEnemyParty[gBattlerPartyIndexes[bank]], MON_DATA_SPECIES);
gUnknown_03005D7C[bank] = CreateInvisibleSpriteWithCallback(sub_805D714); gUnknown_03005D7C[bank] = CreateInvisibleSpriteWithCallback(sub_805D714);
BattleLoadOpponentMonSpriteGfx(&gEnemyParty[gBattlePartyID[bank]], bank); BattleLoadOpponentMonSpriteGfx(&gEnemyParty[gBattlerPartyIndexes[bank]], bank);
sub_806A068(species, GetBattlerPosition(bank)); sub_806A068(species, GetBattlerPosition(bank));
gBankSpriteIds[bank] = CreateSprite( gBattlerSpriteIds[bank] = CreateSprite(
&gUnknown_0202499C, &gUnknown_0202499C,
GetBankCoord(bank, 2), GetBattlerSpriteCoord(bank, 2),
GetBankSpriteDefault_Y(bank), GetBattlerSpriteDefault_Y(bank),
sub_80A82E4(bank)); sub_80A82E4(bank));
gSprites[gUnknown_03005D7C[bank]].data[1] = gBankSpriteIds[bank]; gSprites[gUnknown_03005D7C[bank]].data[1] = gBattlerSpriteIds[bank];
gSprites[gUnknown_03005D7C[bank]].data[2] = bank; gSprites[gUnknown_03005D7C[bank]].data[2] = bank;
gSprites[gBankSpriteIds[bank]].data[0] = bank; gSprites[gBattlerSpriteIds[bank]].data[0] = bank;
gSprites[gBankSpriteIds[bank]].data[2] = species; gSprites[gBattlerSpriteIds[bank]].data[2] = species;
gSprites[gBankSpriteIds[bank]].oam.paletteNum = bank; gSprites[gBattlerSpriteIds[bank]].oam.paletteNum = bank;
StartSpriteAnim(&gSprites[gBankSpriteIds[bank]], gBattleMonForms[bank]); StartSpriteAnim(&gSprites[gBattlerSpriteIds[bank]], gBattleMonForms[bank]);
gSprites[gBankSpriteIds[bank]].invisible = TRUE; gSprites[gBattlerSpriteIds[bank]].invisible = TRUE;
gSprites[gBankSpriteIds[bank]].callback = SpriteCallbackDummy; gSprites[gBattlerSpriteIds[bank]].callback = SpriteCallbackDummy;
gSprites[gUnknown_03005D7C[bank]].data[0] = DoPokeballSendOutAnimation(0, POKEBALL_OPPONENT_SENDOUT); gSprites[gUnknown_03005D7C[bank]].data[0] = DoPokeballSendOutAnimation(0, POKEBALL_OPPONENT_SENDOUT);
} }
@ -1222,14 +1222,14 @@ static void LinkOpponentHandleReturnMonToBall(void)
if (gBattleBufferA[gActiveBattler][1] == 0) if (gBattleBufferA[gActiveBattler][1] == 0)
{ {
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0;
gBattlerFuncs[gActiveBattler] = DoSwitchOutAnimation; gBattlerControllerFuncs[gActiveBattler] = DoSwitchOutAnimation;
} }
else else
{ {
FreeSpriteOamMatrix(&gSprites[gBankSpriteIds[gActiveBattler]]); FreeSpriteOamMatrix(&gSprites[gBattlerSpriteIds[gActiveBattler]]);
DestroySprite(&gSprites[gBankSpriteIds[gActiveBattler]]); DestroySprite(&gSprites[gBattlerSpriteIds[gActiveBattler]]);
EnemyShadowCallbackToSetInvisible(gActiveBattler); HideBattlerShadowSprite(gActiveBattler);
SetHealthboxSpriteInvisible(gHealthBoxesIds[gActiveBattler]); SetHealthboxSpriteInvisible(gHealthboxSpriteIds[gActiveBattler]);
LinkOpponentBufferExecCompleted(); LinkOpponentBufferExecCompleted();
} }
} }
@ -1249,7 +1249,7 @@ static void DoSwitchOutAnimation(void)
{ {
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0;
InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SWITCH_OUT_OPPONENT_MON); InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SWITCH_OUT_OPPONENT_MON);
gBattlerFuncs[gActiveBattler] = sub_8064C58; gBattlerControllerFuncs[gActiveBattler] = sub_8064C58;
} }
break; break;
} }
@ -1276,25 +1276,25 @@ static void LinkOpponentHandleDrawTrainerPic(void)
} }
else else
{ {
if ((gLinkPlayers[GetBankMultiplayerId(gActiveBattler)].version & 0xFF) == VERSION_FIRE_RED if ((gLinkPlayers[GetBattlerMultiplayerId(gActiveBattler)].version & 0xFF) == VERSION_FIRE_RED
|| (gLinkPlayers[GetBankMultiplayerId(gActiveBattler)].version & 0xFF) == VERSION_LEAF_GREEN) || (gLinkPlayers[GetBattlerMultiplayerId(gActiveBattler)].version & 0xFF) == VERSION_LEAF_GREEN)
{ {
if (gLinkPlayers[GetBankMultiplayerId(gActiveBattler)].gender != 0) if (gLinkPlayers[GetBattlerMultiplayerId(gActiveBattler)].gender != 0)
trainerPicId = gUnknown_0831F578[0x4F]; trainerPicId = gUnknown_0831F578[0x4F];
else else
trainerPicId = gUnknown_0831F578[0x4E]; trainerPicId = gUnknown_0831F578[0x4E];
} }
else if ((gLinkPlayers[GetBankMultiplayerId(gActiveBattler)].version & 0xFF) == VERSION_RUBY else if ((gLinkPlayers[GetBattlerMultiplayerId(gActiveBattler)].version & 0xFF) == VERSION_RUBY
|| (gLinkPlayers[GetBankMultiplayerId(gActiveBattler)].version & 0xFF) == VERSION_SAPPHIRE) || (gLinkPlayers[GetBattlerMultiplayerId(gActiveBattler)].version & 0xFF) == VERSION_SAPPHIRE)
{ {
if (gLinkPlayers[GetBankMultiplayerId(gActiveBattler)].gender != 0) if (gLinkPlayers[GetBattlerMultiplayerId(gActiveBattler)].gender != 0)
trainerPicId = gUnknown_0831F578[0x51]; trainerPicId = gUnknown_0831F578[0x51];
else else
trainerPicId = gUnknown_0831F578[0x50]; trainerPicId = gUnknown_0831F578[0x50];
} }
else else
{ {
trainerPicId = PlayerGenderToFrontTrainerPicId(gLinkPlayers[GetBankMultiplayerId(gActiveBattler)].gender); trainerPicId = PlayerGenderToFrontTrainerPicId(gLinkPlayers[GetBattlerMultiplayerId(gActiveBattler)].gender);
} }
} }
} }
@ -1329,18 +1329,18 @@ static void LinkOpponentHandleDrawTrainerPic(void)
DecompressTrainerFrontPic(trainerPicId, gActiveBattler); DecompressTrainerFrontPic(trainerPicId, gActiveBattler);
sub_806A12C(trainerPicId, GetBattlerPosition(gActiveBattler)); sub_806A12C(trainerPicId, GetBattlerPosition(gActiveBattler));
gBankSpriteIds[gActiveBattler] = CreateSprite(&gUnknown_0202499C, gBattlerSpriteIds[gActiveBattler] = CreateSprite(&gUnknown_0202499C,
xPos, xPos,
(8 - gTrainerFrontPicCoords[trainerPicId].coords) * 4 + 40, (8 - gTrainerFrontPicCoords[trainerPicId].coords) * 4 + 40,
sub_80A82E4(gActiveBattler)); sub_80A82E4(gActiveBattler));
gSprites[gBankSpriteIds[gActiveBattler]].pos2.x = -240; gSprites[gBattlerSpriteIds[gActiveBattler]].pos2.x = -240;
gSprites[gBankSpriteIds[gActiveBattler]].data[0] = 2; gSprites[gBattlerSpriteIds[gActiveBattler]].data[0] = 2;
gSprites[gBankSpriteIds[gActiveBattler]].oam.paletteNum = IndexOfSpritePaletteTag(gTrainerFrontPicPaletteTable[trainerPicId].tag); gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = IndexOfSpritePaletteTag(gTrainerFrontPicPaletteTable[trainerPicId].tag);
gSprites[gBankSpriteIds[gActiveBattler]].oam.affineParam = trainerPicId; gSprites[gBattlerSpriteIds[gActiveBattler]].oam.affineParam = trainerPicId;
gSprites[gBankSpriteIds[gActiveBattler]].callback = sub_805D7AC; gSprites[gBattlerSpriteIds[gActiveBattler]].callback = sub_805D7AC;
gBattlerFuncs[gActiveBattler] = CompleteOnBankSpriteCallbackDummy; gBattlerControllerFuncs[gActiveBattler] = CompleteOnBankSpriteCallbackDummy;
} }
static void LinkOpponentHandleTrainerSlide(void) static void LinkOpponentHandleTrainerSlide(void)
@ -1354,28 +1354,28 @@ static void LinkOpponentHandleTrainerSlide(void)
DecompressTrainerFrontPic(trainerPicId, gActiveBattler); DecompressTrainerFrontPic(trainerPicId, gActiveBattler);
sub_806A12C(trainerPicId, GetBattlerPosition(gActiveBattler)); sub_806A12C(trainerPicId, GetBattlerPosition(gActiveBattler));
gBankSpriteIds[gActiveBattler] = CreateSprite(&gUnknown_0202499C, 176, (8 - gTrainerFrontPicCoords[trainerPicId].coords) * 4 + 40, 0x1E); gBattlerSpriteIds[gActiveBattler] = CreateSprite(&gUnknown_0202499C, 176, (8 - gTrainerFrontPicCoords[trainerPicId].coords) * 4 + 40, 0x1E);
gSprites[gBankSpriteIds[gActiveBattler]].pos2.x = 96; gSprites[gBattlerSpriteIds[gActiveBattler]].pos2.x = 96;
gSprites[gBankSpriteIds[gActiveBattler]].pos1.x += 32; gSprites[gBattlerSpriteIds[gActiveBattler]].pos1.x += 32;
gSprites[gBankSpriteIds[gActiveBattler]].data[0] = -2; gSprites[gBattlerSpriteIds[gActiveBattler]].data[0] = -2;
gSprites[gBankSpriteIds[gActiveBattler]].oam.paletteNum = IndexOfSpritePaletteTag(gTrainerFrontPicPaletteTable[trainerPicId].tag); gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = IndexOfSpritePaletteTag(gTrainerFrontPicPaletteTable[trainerPicId].tag);
gSprites[gBankSpriteIds[gActiveBattler]].oam.affineParam = trainerPicId; gSprites[gBattlerSpriteIds[gActiveBattler]].oam.affineParam = trainerPicId;
gSprites[gBankSpriteIds[gActiveBattler]].callback = sub_805D7AC; gSprites[gBattlerSpriteIds[gActiveBattler]].callback = sub_805D7AC;
gBattlerFuncs[gActiveBattler] = CompleteOnBankSpriteCallbackDummy2; // this line is redundant, because LinkOpponentBufferExecCompleted changes the battle bank function gBattlerControllerFuncs[gActiveBattler] = CompleteOnBankSpriteCallbackDummy2; // this line is redundant, because LinkOpponentBufferExecCompleted changes the battle bank function
LinkOpponentBufferExecCompleted(); LinkOpponentBufferExecCompleted();
} }
static void LinkOpponentHandleTrainerSlideBack(void) static void LinkOpponentHandleTrainerSlideBack(void)
{ {
oamt_add_pos2_onto_pos1(&gSprites[gBankSpriteIds[gActiveBattler]]); oamt_add_pos2_onto_pos1(&gSprites[gBattlerSpriteIds[gActiveBattler]]);
gSprites[gBankSpriteIds[gActiveBattler]].data[0] = 35; gSprites[gBattlerSpriteIds[gActiveBattler]].data[0] = 35;
gSprites[gBankSpriteIds[gActiveBattler]].data[2] = 280; gSprites[gBattlerSpriteIds[gActiveBattler]].data[2] = 280;
gSprites[gBankSpriteIds[gActiveBattler]].data[4] = gSprites[gBankSpriteIds[gActiveBattler]].pos1.y; gSprites[gBattlerSpriteIds[gActiveBattler]].data[4] = gSprites[gBattlerSpriteIds[gActiveBattler]].pos1.y;
gSprites[gBankSpriteIds[gActiveBattler]].callback = sub_80A6EEC; gSprites[gBattlerSpriteIds[gActiveBattler]].callback = sub_80A6EEC;
StoreSpriteCallbackInData6(&gSprites[gBankSpriteIds[gActiveBattler]], SpriteCallbackDummy); StoreSpriteCallbackInData6(&gSprites[gBattlerSpriteIds[gActiveBattler]], SpriteCallbackDummy);
gBattlerFuncs[gActiveBattler] = sub_8064470; gBattlerControllerFuncs[gActiveBattler] = sub_8064470;
} }
static void LinkOpponentHandleFaintAnimation(void) static void LinkOpponentHandleFaintAnimation(void)
@ -1392,8 +1392,8 @@ static void LinkOpponentHandleFaintAnimation(void)
{ {
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0;
PlaySE12WithPanning(SE_POKE_DEAD, PAN_SIDE_OPPONENT); PlaySE12WithPanning(SE_POKE_DEAD, PAN_SIDE_OPPONENT);
gSprites[gBankSpriteIds[gActiveBattler]].callback = sub_8039934; gSprites[gBattlerSpriteIds[gActiveBattler]].callback = sub_8039934;
gBattlerFuncs[gActiveBattler] = sub_8064C14; gBattlerControllerFuncs[gActiveBattler] = sub_8064C14;
} }
} }
} }
@ -1438,7 +1438,7 @@ static void LinkOpponentHandleMoveAnimation(void)
else else
{ {
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0;
gBattlerFuncs[gActiveBattler] = LinkOpponentDoMoveAnimation; gBattlerControllerFuncs[gActiveBattler] = LinkOpponentDoMoveAnimation;
sub_817E0FC(move, gWeatherMoveAnim, gAnimDisableStructPtr); sub_817E0FC(move, gWeatherMoveAnim, gAnimDisableStructPtr);
} }
} }
@ -1502,7 +1502,7 @@ static void LinkOpponentHandlePrintString(void)
stringId = (u16*)(&gBattleBufferA[gActiveBattler][2]); stringId = (u16*)(&gBattleBufferA[gActiveBattler][2]);
BufferStringBattle(*stringId); BufferStringBattle(*stringId);
BattleHandleAddTextPrinter(gDisplayedStringBattle, 0); BattleHandleAddTextPrinter(gDisplayedStringBattle, 0);
gBattlerFuncs[gActiveBattler] = CompleteOnInactiveTextPrinter; gBattlerControllerFuncs[gActiveBattler] = CompleteOnInactiveTextPrinter;
sub_817C95C(*stringId); sub_817C95C(*stringId);
} }
@ -1550,19 +1550,19 @@ static void LinkOpponentHandleHealthBarUpdate(void)
if (hpVal != INSTANT_HP_BAR_DROP) if (hpVal != INSTANT_HP_BAR_DROP)
{ {
u32 maxHP = GetMonData(&gEnemyParty[gBattlePartyID[gActiveBattler]], MON_DATA_MAX_HP); u32 maxHP = GetMonData(&gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_MAX_HP);
u32 curHP = GetMonData(&gEnemyParty[gBattlePartyID[gActiveBattler]], MON_DATA_HP); u32 curHP = GetMonData(&gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_HP);
SetBattleBarStruct(gActiveBattler, gHealthBoxesIds[gActiveBattler], maxHP, curHP, hpVal); SetBattleBarStruct(gActiveBattler, gHealthboxSpriteIds[gActiveBattler], maxHP, curHP, hpVal);
} }
else else
{ {
u32 maxHP = GetMonData(&gEnemyParty[gBattlePartyID[gActiveBattler]], MON_DATA_MAX_HP); u32 maxHP = GetMonData(&gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_MAX_HP);
SetBattleBarStruct(gActiveBattler, gHealthBoxesIds[gActiveBattler], maxHP, 0, hpVal); SetBattleBarStruct(gActiveBattler, gHealthboxSpriteIds[gActiveBattler], maxHP, 0, hpVal);
} }
gBattlerFuncs[gActiveBattler] = CompleteOnHealthbarDone; gBattlerControllerFuncs[gActiveBattler] = CompleteOnHealthbarDone;
} }
static void LinkOpponentHandleExpUpdate(void) static void LinkOpponentHandleExpUpdate(void)
@ -1576,10 +1576,10 @@ static void LinkOpponentHandleStatusIconUpdate(void)
{ {
u8 bank; u8 bank;
UpdateHealthboxAttribute(gHealthBoxesIds[gActiveBattler], &gEnemyParty[gBattlePartyID[gActiveBattler]], HEALTHBOX_STATUS_ICON); UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler], &gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], HEALTHBOX_STATUS_ICON);
bank = gActiveBattler; bank = gActiveBattler;
gBattleSpritesDataPtr->healthBoxesData[bank].statusAnimActive = 0; gBattleSpritesDataPtr->healthBoxesData[bank].statusAnimActive = 0;
gBattlerFuncs[gActiveBattler] = CompleteOnFinishedStatusAnimation; gBattlerControllerFuncs[gActiveBattler] = CompleteOnFinishedStatusAnimation;
} }
} }
@ -1589,7 +1589,7 @@ static void LinkOpponentHandleStatusAnimation(void)
{ {
InitAndLaunchChosenStatusAnimation(gBattleBufferA[gActiveBattler][1], InitAndLaunchChosenStatusAnimation(gBattleBufferA[gActiveBattler][1],
gBattleBufferA[gActiveBattler][2] | (gBattleBufferA[gActiveBattler][3] << 8) | (gBattleBufferA[gActiveBattler][4] << 16) | (gBattleBufferA[gActiveBattler][5] << 24)); gBattleBufferA[gActiveBattler][2] | (gBattleBufferA[gActiveBattler][3] << 8) | (gBattleBufferA[gActiveBattler][4] << 16) | (gBattleBufferA[gActiveBattler][5] << 24));
gBattlerFuncs[gActiveBattler] = CompleteOnFinishedStatusAnimation; gBattlerControllerFuncs[gActiveBattler] = CompleteOnFinishedStatusAnimation;
} }
} }
@ -1664,16 +1664,16 @@ static void LinkOpponentHandleCmd40(void)
static void LinkOpponentHandleHitAnimation(void) static void LinkOpponentHandleHitAnimation(void)
{ {
if (gSprites[gBankSpriteIds[gActiveBattler]].invisible == TRUE) if (gSprites[gBattlerSpriteIds[gActiveBattler]].invisible == TRUE)
{ {
LinkOpponentBufferExecCompleted(); LinkOpponentBufferExecCompleted();
} }
else else
{ {
gDoingBattleAnim = TRUE; gDoingBattleAnim = TRUE;
gSprites[gBankSpriteIds[gActiveBattler]].data[1] = 0; gSprites[gBattlerSpriteIds[gActiveBattler]].data[1] = 0;
DoHitAnimHealthboxEffect(gActiveBattler); DoHitAnimHealthboxEffect(gActiveBattler);
gBattlerFuncs[gActiveBattler] = DoHitAnimBlinkSpriteEffect; gBattlerControllerFuncs[gActiveBattler] = DoHitAnimBlinkSpriteEffect;
} }
} }
@ -1712,7 +1712,7 @@ static void LinkOpponentHandlePlayFanfareOrBGM(void)
static void LinkOpponentHandleFaintingCry(void) static void LinkOpponentHandleFaintingCry(void)
{ {
u16 species = GetMonData(&gEnemyParty[gBattlePartyID[gActiveBattler]], MON_DATA_SPECIES); u16 species = GetMonData(&gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_SPECIES);
PlayCry3(species, 25, 5); PlayCry3(species, 25, 5);
LinkOpponentBufferExecCompleted(); LinkOpponentBufferExecCompleted();
@ -1730,14 +1730,14 @@ static void LinkOpponentHandleIntroTrainerBallThrow(void)
u8 paletteNum; u8 paletteNum;
u8 taskId; u8 taskId;
oamt_add_pos2_onto_pos1(&gSprites[gBankSpriteIds[gActiveBattler]]); oamt_add_pos2_onto_pos1(&gSprites[gBattlerSpriteIds[gActiveBattler]]);
gSprites[gBankSpriteIds[gActiveBattler]].data[0] = 35; gSprites[gBattlerSpriteIds[gActiveBattler]].data[0] = 35;
gSprites[gBankSpriteIds[gActiveBattler]].data[2] = 280; gSprites[gBattlerSpriteIds[gActiveBattler]].data[2] = 280;
gSprites[gBankSpriteIds[gActiveBattler]].data[4] = gSprites[gBankSpriteIds[gActiveBattler]].pos1.y; gSprites[gBattlerSpriteIds[gActiveBattler]].data[4] = gSprites[gBattlerSpriteIds[gActiveBattler]].pos1.y;
gSprites[gBankSpriteIds[gActiveBattler]].callback = sub_80A6EEC; gSprites[gBattlerSpriteIds[gActiveBattler]].callback = sub_80A6EEC;
StoreSpriteCallbackInData6(&gSprites[gBankSpriteIds[gActiveBattler]], sub_80676FC); StoreSpriteCallbackInData6(&gSprites[gBattlerSpriteIds[gActiveBattler]], sub_80676FC);
taskId = CreateTask(sub_8067618, 5); taskId = CreateTask(sub_8067618, 5);
gTasks[taskId].data[0] = gActiveBattler; gTasks[taskId].data[0] = gActiveBattler;
@ -1746,7 +1746,7 @@ static void LinkOpponentHandleIntroTrainerBallThrow(void)
gTasks[gUnknown_020244B4[gActiveBattler]].func = sub_8073C30; gTasks[gUnknown_020244B4[gActiveBattler]].func = sub_8073C30;
gBattleSpritesDataPtr->animationData->field_9_x1 = 1; gBattleSpritesDataPtr->animationData->field_9_x1 = 1;
gBattlerFuncs[gActiveBattler] = nullsub_28; gBattlerControllerFuncs[gActiveBattler] = nullsub_28;
} }
static void sub_8067618(u8 taskId) static void sub_8067618(u8 taskId)
@ -1756,19 +1756,19 @@ static void sub_8067618(u8 taskId)
gActiveBattler = gTasks[taskId].data[0]; gActiveBattler = gTasks[taskId].data[0];
if (!IsDoubleBattle() || (gBattleTypeFlags & BATTLE_TYPE_MULTI)) if (!IsDoubleBattle() || (gBattleTypeFlags & BATTLE_TYPE_MULTI))
{ {
gBattleBufferA[gActiveBattler][1] = gBattlePartyID[gActiveBattler]; gBattleBufferA[gActiveBattler][1] = gBattlerPartyIndexes[gActiveBattler];
sub_8066494(gActiveBattler, FALSE); sub_8066494(gActiveBattler, FALSE);
} }
else else
{ {
gBattleBufferA[gActiveBattler][1] = gBattlePartyID[gActiveBattler]; gBattleBufferA[gActiveBattler][1] = gBattlerPartyIndexes[gActiveBattler];
sub_8066494(gActiveBattler, FALSE); sub_8066494(gActiveBattler, FALSE);
gActiveBattler ^= BIT_FLANK; gActiveBattler ^= BIT_FLANK;
gBattleBufferA[gActiveBattler][1] = gBattlePartyID[gActiveBattler]; gBattleBufferA[gActiveBattler][1] = gBattlerPartyIndexes[gActiveBattler];
sub_8066494(gActiveBattler, FALSE); sub_8066494(gActiveBattler, FALSE);
gActiveBattler ^= BIT_FLANK; gActiveBattler ^= BIT_FLANK;
} }
gBattlerFuncs[gActiveBattler] = sub_8064734; gBattlerControllerFuncs[gActiveBattler] = sub_8064734;
gActiveBattler = savedActiveBank; gActiveBattler = savedActiveBank;
DestroyTask(taskId); DestroyTask(taskId);
} }
@ -1809,7 +1809,7 @@ static void LinkOpponentHandleDrawPartyStatusSummary(void)
if (gBattleBufferA[gActiveBattler][2] != 0) if (gBattleBufferA[gActiveBattler][2] != 0)
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_5 = 0x5D; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_5 = 0x5D;
gBattlerFuncs[gActiveBattler] = sub_806782C; gBattlerControllerFuncs[gActiveBattler] = sub_806782C;
} }
} }
@ -1836,9 +1836,9 @@ static void LinkOpponentHandleCmd50(void)
static void LinkOpponentHandleSpriteInvisibility(void) static void LinkOpponentHandleSpriteInvisibility(void)
{ {
if (IsBankSpritePresent(gActiveBattler)) if (IsBattlerSpritePresent(gActiveBattler))
{ {
gSprites[gBankSpriteIds[gActiveBattler]].invisible = gBattleBufferA[gActiveBattler][1]; gSprites[gBattlerSpriteIds[gActiveBattler]].invisible = gBattleBufferA[gActiveBattler][1];
CopyBattleSpriteInvisibility(gActiveBattler); CopyBattleSpriteInvisibility(gActiveBattler);
} }
LinkOpponentBufferExecCompleted(); LinkOpponentBufferExecCompleted();
@ -1854,7 +1854,7 @@ static void LinkOpponentHandleBattleAnimation(void)
if (TryHandleLaunchBattleTableAnimation(gActiveBattler, gActiveBattler, gActiveBattler, animationId, argument)) if (TryHandleLaunchBattleTableAnimation(gActiveBattler, gActiveBattler, gActiveBattler, animationId, argument))
LinkOpponentBufferExecCompleted(); LinkOpponentBufferExecCompleted();
else else
gBattlerFuncs[gActiveBattler] = CompleteOnFinishedBattleAnimation; gBattlerControllerFuncs[gActiveBattler] = CompleteOnFinishedBattleAnimation;
sub_817E32C(animationId); sub_817E32C(animationId);
} }
@ -1884,7 +1884,7 @@ static void LinkOpponentHandleCmd55(void)
FadeOutMapMusic(5); FadeOutMapMusic(5);
BeginFastPaletteFade(3); BeginFastPaletteFade(3);
LinkOpponentBufferExecCompleted(); LinkOpponentBufferExecCompleted();
gBattlerFuncs[gActiveBattler] = sub_80587B0; gBattlerControllerFuncs[gActiveBattler] = sub_80587B0;
} }
static void nullsub_92(void) static void nullsub_92(void)

View File

@ -24,21 +24,21 @@
#include "pokeball.h" #include "pokeball.h"
#include "data2.h" #include "data2.h"
extern u32 gBattleExecBuffer; extern u32 gBattleControllerExecFlags;
extern u8 gActiveBattler; extern u8 gActiveBattler;
extern u8 gBankSpriteIds[MAX_BATTLERS_COUNT]; extern u8 gBattlerSpriteIds[MAX_BATTLERS_COUNT];
extern u8 gActionSelectionCursor[MAX_BATTLERS_COUNT]; extern u8 gActionSelectionCursor[MAX_BATTLERS_COUNT];
extern u8 gBattlersCount; extern u8 gBattlersCount;
extern bool8 gDoingBattleAnim; extern bool8 gDoingBattleAnim;
extern void (*gBattlerFuncs[MAX_BATTLERS_COUNT])(void); extern void (*gBattlerControllerFuncs[MAX_BATTLERS_COUNT])(void);
extern void (*gPreBattleCallback1)(void); extern void (*gPreBattleCallback1)(void);
extern u16 gBattlePartyID[MAX_BATTLERS_COUNT]; extern u16 gBattlerPartyIndexes[MAX_BATTLERS_COUNT];
extern u8 gBattleBufferA[MAX_BATTLERS_COUNT][0x200]; extern u8 gBattleBufferA[MAX_BATTLERS_COUNT][0x200];
extern u8 gBattleBufferB[MAX_BATTLERS_COUNT][0x200]; extern u8 gBattleBufferB[MAX_BATTLERS_COUNT][0x200];
extern struct BattlePokemon gBattleMons[MAX_BATTLERS_COUNT]; extern struct BattlePokemon gBattleMons[MAX_BATTLERS_COUNT];
extern struct SpriteTemplate gUnknown_0202499C; extern struct SpriteTemplate gUnknown_0202499C;
extern u16 gSpecialVar_ItemId; extern u16 gSpecialVar_ItemId;
extern u8 gHealthBoxesIds[MAX_BATTLERS_COUNT]; extern u8 gHealthboxSpriteIds[MAX_BATTLERS_COUNT];
extern u8 gBattleOutcome; extern u8 gBattleOutcome;
extern u16 gBattle_BG0_X; extern u16 gBattle_BG0_X;
extern u16 gBattle_BG0_Y; extern u16 gBattle_BG0_Y;
@ -47,7 +47,7 @@ extern u8 gUnknown_03005D7C[MAX_BATTLERS_COUNT];
extern u8 gBattleMonForms[MAX_BATTLERS_COUNT]; extern u8 gBattleMonForms[MAX_BATTLERS_COUNT];
extern u16 gPartnerTrainerId; extern u16 gPartnerTrainerId;
extern u8 GetFrontierTrainerFrontSpriteId(u16 trainerId); extern u8 GetFrontierTrainerFrontSpriteId(u16 trainerId);
extern u8 gBattleDefender; extern u8 gBattleMoveTarget;
extern u8 gAbsentBattlerFlags; extern u8 gAbsentBattlerFlags;
extern u8 gUnknown_020244B4[]; extern u8 gUnknown_020244B4[];
extern u32 gTransformedPersonalities[MAX_BATTLERS_COUNT]; extern u32 gTransformedPersonalities[MAX_BATTLERS_COUNT];
@ -198,12 +198,12 @@ static void nullsub_112(void)
void SetControllerToLinkPartner(void) void SetControllerToLinkPartner(void)
{ {
gBattlerFuncs[gActiveBattler] = LinkPartnerBufferRunCommand; gBattlerControllerFuncs[gActiveBattler] = LinkPartnerBufferRunCommand;
} }
static void LinkPartnerBufferRunCommand(void) static void LinkPartnerBufferRunCommand(void)
{ {
if (gBattleExecBuffer & gBitTable[gActiveBattler]) if (gBattleControllerExecFlags & gBitTable[gActiveBattler])
{ {
if (gBattleBufferA[gActiveBattler][0] < ARRAY_COUNT(sLinkPartnerBufferCommands)) if (gBattleBufferA[gActiveBattler][0] < ARRAY_COUNT(sLinkPartnerBufferCommands))
sLinkPartnerBufferCommands[gBattleBufferA[gActiveBattler][0]](); sLinkPartnerBufferCommands[gBattleBufferA[gActiveBattler][0]]();
@ -214,17 +214,17 @@ static void LinkPartnerBufferRunCommand(void)
static void CompleteOnBankSpriteCallbackDummy(void) static void CompleteOnBankSpriteCallbackDummy(void)
{ {
if (gSprites[gBankSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy) if (gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
LinkPartnerBufferExecCompleted(); LinkPartnerBufferExecCompleted();
} }
static void sub_814AF54(void) static void sub_814AF54(void)
{ {
if (gSprites[gBankSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy) if (gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
{ {
nullsub_25(0); nullsub_25(0);
FreeSpriteOamMatrix(&gSprites[gBankSpriteIds[gActiveBattler]]); FreeSpriteOamMatrix(&gSprites[gBattlerSpriteIds[gActiveBattler]]);
DestroySprite(&gSprites[gBankSpriteIds[gActiveBattler]]); DestroySprite(&gSprites[gBattlerSpriteIds[gActiveBattler]]);
LinkPartnerBufferExecCompleted(); LinkPartnerBufferExecCompleted();
} }
} }
@ -244,13 +244,13 @@ static void sub_814B004(void)
if (!IsDoubleBattle() || (IsDoubleBattle() && (gBattleTypeFlags & BATTLE_TYPE_MULTI))) if (!IsDoubleBattle() || (IsDoubleBattle() && (gBattleTypeFlags & BATTLE_TYPE_MULTI)))
{ {
if (gSprites[gHealthBoxesIds[gActiveBattler]].callback == SpriteCallbackDummy) if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
r6 = TRUE; r6 = TRUE;
} }
else else
{ {
if (gSprites[gHealthBoxesIds[gActiveBattler]].callback == SpriteCallbackDummy if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy
&& gSprites[gHealthBoxesIds[gActiveBattler ^ BIT_FLANK]].callback == SpriteCallbackDummy) && gSprites[gHealthboxSpriteIds[gActiveBattler ^ BIT_FLANK]].callback == SpriteCallbackDummy)
{ {
r6 = TRUE; r6 = TRUE;
} }
@ -262,7 +262,7 @@ static void sub_814B004(void)
if (r6) if (r6)
{ {
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_9 = 3; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_9 = 3;
gBattlerFuncs[gActiveBattler] = sub_814AFBC; gBattlerControllerFuncs[gActiveBattler] = sub_814AFBC;
} }
} }
@ -271,7 +271,7 @@ static void sub_814B0E8(void)
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive
&& !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].ballAnimActive && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].ballAnimActive
&& gSprites[gUnknown_03005D7C[gActiveBattler]].callback == SpriteCallbackDummy && gSprites[gUnknown_03005D7C[gActiveBattler]].callback == SpriteCallbackDummy
&& gSprites[gBankSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy && gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy
&& ++gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_9 != 1) && ++gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_9 != 1)
{ {
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_9 = 0; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_9 = 0;
@ -279,55 +279,55 @@ static void sub_814B0E8(void)
if (IsDoubleBattle() && !(gBattleTypeFlags & BATTLE_TYPE_MULTI)) if (IsDoubleBattle() && !(gBattleTypeFlags & BATTLE_TYPE_MULTI))
{ {
DestroySprite(&gSprites[gUnknown_03005D7C[gActiveBattler ^ BIT_FLANK]]); DestroySprite(&gSprites[gUnknown_03005D7C[gActiveBattler ^ BIT_FLANK]]);
UpdateHealthboxAttribute(gHealthBoxesIds[gActiveBattler ^ BIT_FLANK], &gPlayerParty[gBattlePartyID[gActiveBattler ^ BIT_FLANK]], HEALTHBOX_ALL); UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler ^ BIT_FLANK], &gPlayerParty[gBattlerPartyIndexes[gActiveBattler ^ BIT_FLANK]], HEALTHBOX_ALL);
sub_8076918(gActiveBattler ^ BIT_FLANK); sub_8076918(gActiveBattler ^ BIT_FLANK);
SetHealthboxSpriteVisible(gHealthBoxesIds[gActiveBattler ^ BIT_FLANK]); SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler ^ BIT_FLANK]);
} }
DestroySprite(&gSprites[gUnknown_03005D7C[gActiveBattler]]); DestroySprite(&gSprites[gUnknown_03005D7C[gActiveBattler]]);
UpdateHealthboxAttribute(gHealthBoxesIds[gActiveBattler], &gPlayerParty[gBattlePartyID[gActiveBattler]], HEALTHBOX_ALL); UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler], &gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], HEALTHBOX_ALL);
sub_8076918(gActiveBattler); sub_8076918(gActiveBattler);
SetHealthboxSpriteVisible(gHealthBoxesIds[gActiveBattler]); SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]);
gBattleSpritesDataPtr->animationData->field_9_x1 = 0; gBattleSpritesDataPtr->animationData->field_9_x1 = 0;
gBattlerFuncs[gActiveBattler] = sub_814B004; gBattlerControllerFuncs[gActiveBattler] = sub_814B004;
} }
} }
static void sub_814B290(void) static void sub_814B290(void)
{ {
if (gSprites[gBankSpriteIds[gActiveBattler]].animEnded && gSprites[gBankSpriteIds[gActiveBattler]].pos2.x == 0) if (gSprites[gBattlerSpriteIds[gActiveBattler]].animEnded && gSprites[gBattlerSpriteIds[gActiveBattler]].pos2.x == 0)
LinkPartnerBufferExecCompleted(); LinkPartnerBufferExecCompleted();
} }
static void CompleteOnHealthbarDone(void) static void CompleteOnHealthbarDone(void)
{ {
s16 hpValue = sub_8074AA0(gActiveBattler, gHealthBoxesIds[gActiveBattler], HEALTH_BAR, 0); s16 hpValue = sub_8074AA0(gActiveBattler, gHealthboxSpriteIds[gActiveBattler], HEALTH_BAR, 0);
SetHealthboxSpriteVisible(gHealthBoxesIds[gActiveBattler]); SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]);
if (hpValue != -1) if (hpValue != -1)
{ {
UpdateHpTextInHealthbox(gHealthBoxesIds[gActiveBattler], hpValue, HP_CURRENT); UpdateHpTextInHealthbox(gHealthboxSpriteIds[gActiveBattler], hpValue, HP_CURRENT);
} }
else else
{ {
HandleLowHpMusicChange(&gPlayerParty[gBattlePartyID[gActiveBattler]], gActiveBattler); HandleLowHpMusicChange(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler);
LinkPartnerBufferExecCompleted(); LinkPartnerBufferExecCompleted();
} }
} }
static void sub_814B340(void) static void sub_814B340(void)
{ {
if (gSprites[gBankSpriteIds[gActiveBattler]].pos1.y + gSprites[gBankSpriteIds[gActiveBattler]].pos2.y > DISPLAY_HEIGHT) if (gSprites[gBattlerSpriteIds[gActiveBattler]].pos1.y + gSprites[gBattlerSpriteIds[gActiveBattler]].pos2.y > DISPLAY_HEIGHT)
{ {
u16 species = GetMonData(&gPlayerParty[gBattlePartyID[gActiveBattler]], MON_DATA_SPECIES); u16 species = GetMonData(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_SPECIES);
nullsub_24(species); nullsub_24(species);
FreeOamMatrix(gSprites[gBankSpriteIds[gActiveBattler]].oam.matrixNum); FreeOamMatrix(gSprites[gBattlerSpriteIds[gActiveBattler]].oam.matrixNum);
DestroySprite(&gSprites[gBankSpriteIds[gActiveBattler]]); DestroySprite(&gSprites[gBattlerSpriteIds[gActiveBattler]]);
SetHealthboxSpriteInvisible(gHealthBoxesIds[gActiveBattler]); SetHealthboxSpriteInvisible(gHealthboxSpriteIds[gActiveBattler]);
LinkPartnerBufferExecCompleted(); LinkPartnerBufferExecCompleted();
} }
} }
@ -336,9 +336,9 @@ static void sub_814B3DC(void)
{ {
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive) if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive)
{ {
FreeSpriteOamMatrix(&gSprites[gBankSpriteIds[gActiveBattler]]); FreeSpriteOamMatrix(&gSprites[gBattlerSpriteIds[gActiveBattler]]);
DestroySprite(&gSprites[gBankSpriteIds[gActiveBattler]]); DestroySprite(&gSprites[gBattlerSpriteIds[gActiveBattler]]);
SetHealthboxSpriteInvisible(gHealthBoxesIds[gActiveBattler]); SetHealthboxSpriteInvisible(gHealthboxSpriteIds[gActiveBattler]);
LinkPartnerBufferExecCompleted(); LinkPartnerBufferExecCompleted();
} }
} }
@ -351,7 +351,7 @@ static void CompleteOnInactiveTextPrinter(void)
static void DoHitAnimBlinkSpriteEffect(void) static void DoHitAnimBlinkSpriteEffect(void)
{ {
u8 spriteId = gBankSpriteIds[gActiveBattler]; u8 spriteId = gBattlerSpriteIds[gActiveBattler];
if (gSprites[spriteId].data[1] == 32) if (gSprites[spriteId].data[1] == 32)
{ {
@ -370,20 +370,20 @@ static void DoHitAnimBlinkSpriteEffect(void)
static void sub_814B4E0(void) static void sub_814B4E0(void)
{ {
if (gSprites[gHealthBoxesIds[gActiveBattler]].callback == SpriteCallbackDummy) if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
{ {
CopyBattleSpriteInvisibility(gActiveBattler); CopyBattleSpriteInvisibility(gActiveBattler);
if (gBattleSpritesDataPtr->bankData[gActiveBattler].behindSubstitute) if (gBattleSpritesDataPtr->bankData[gActiveBattler].behindSubstitute)
InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_MON_TO_SUBSTITUTE); InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_MON_TO_SUBSTITUTE);
gBattlerFuncs[gActiveBattler] = sub_814B554; gBattlerControllerFuncs[gActiveBattler] = sub_814B554;
} }
} }
static void sub_814B554(void) static void sub_814B554(void)
{ {
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive
&& gSprites[gBankSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy) && gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
{ {
LinkPartnerBufferExecCompleted(); LinkPartnerBufferExecCompleted();
} }
@ -400,13 +400,13 @@ static void sub_814B5A8(void)
FreeSpritePaletteByTag(0x27F9); FreeSpritePaletteByTag(0x27F9);
CreateTask(c3_0802FDF4, 10); CreateTask(c3_0802FDF4, 10);
HandleLowHpMusicChange(&gPlayerParty[gBattlePartyID[gActiveBattler]], gActiveBattler); HandleLowHpMusicChange(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler);
StartSpriteAnim(&gSprites[gBankSpriteIds[gActiveBattler]], 0); StartSpriteAnim(&gSprites[gBattlerSpriteIds[gActiveBattler]], 0);
UpdateHealthboxAttribute(gHealthBoxesIds[gActiveBattler], &gPlayerParty[gBattlePartyID[gActiveBattler]], HEALTHBOX_ALL); UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler], &gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], HEALTHBOX_ALL);
sub_8076918(gActiveBattler); sub_8076918(gActiveBattler);
SetHealthboxSpriteVisible(gHealthBoxesIds[gActiveBattler]); SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]);
gBattlerFuncs[gActiveBattler] = sub_814B4E0; gBattlerControllerFuncs[gActiveBattler] = sub_814B4E0;
} }
} }
@ -415,20 +415,20 @@ static void sub_814B69C(void)
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].flag_x80 if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].flag_x80
&& !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive) && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive)
{ {
sub_8172EF0(gActiveBattler, &gPlayerParty[gBattlePartyID[gActiveBattler]]); sub_8172EF0(gActiveBattler, &gPlayerParty[gBattlerPartyIndexes[gActiveBattler]]);
} }
if (gSprites[gUnknown_03005D7C[gActiveBattler]].callback == SpriteCallbackDummy if (gSprites[gUnknown_03005D7C[gActiveBattler]].callback == SpriteCallbackDummy
&& !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive) && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive)
{ {
DestroySprite(&gSprites[gUnknown_03005D7C[gActiveBattler]]); DestroySprite(&gSprites[gUnknown_03005D7C[gActiveBattler]]);
gBattlerFuncs[gActiveBattler] = sub_814B5A8; gBattlerControllerFuncs[gActiveBattler] = sub_814B5A8;
} }
} }
static void LinkPartnerBufferExecCompleted(void) static void LinkPartnerBufferExecCompleted(void)
{ {
gBattlerFuncs[gActiveBattler] = LinkPartnerBufferRunCommand; gBattlerControllerFuncs[gActiveBattler] = LinkPartnerBufferRunCommand;
if (gBattleTypeFlags & BATTLE_TYPE_LINK) if (gBattleTypeFlags & BATTLE_TYPE_LINK)
{ {
u8 playerId = GetMultiplayerId(); u8 playerId = GetMultiplayerId();
@ -438,7 +438,7 @@ static void LinkPartnerBufferExecCompleted(void)
} }
else else
{ {
gBattleExecBuffer &= ~gBitTable[gActiveBattler]; gBattleControllerExecFlags &= ~gBitTable[gActiveBattler];
} }
} }
@ -463,7 +463,7 @@ static void LinkPartnerHandleGetMonData(void)
if (gBattleBufferA[gActiveBattler][2] == 0) if (gBattleBufferA[gActiveBattler][2] == 0)
{ {
size += CopyLinkPartnerMonData(gBattlePartyID[gActiveBattler], monData); size += CopyLinkPartnerMonData(gBattlerPartyIndexes[gActiveBattler], monData);
} }
else else
{ {
@ -475,7 +475,7 @@ static void LinkPartnerHandleGetMonData(void)
monToCheck >>= 1; monToCheck >>= 1;
} }
} }
EmitDataTransfer(1, size, monData); BtlController_EmitDataTransfer(1, size, monData);
LinkPartnerBufferExecCompleted(); LinkPartnerBufferExecCompleted();
} }
@ -797,7 +797,7 @@ static void LinkPartnerHandleSetMonData(void)
if (gBattleBufferA[gActiveBattler][2] == 0) if (gBattleBufferA[gActiveBattler][2] == 0)
{ {
SetLinkPartnerMonData(gBattlePartyID[gActiveBattler]); SetLinkPartnerMonData(gBattlerPartyIndexes[gActiveBattler]);
} }
else else
{ {
@ -1027,12 +1027,12 @@ static void SetLinkPartnerMonData(u8 monId)
break; break;
} }
HandleLowHpMusicChange(&gPlayerParty[gBattlePartyID[gActiveBattler]], gActiveBattler); HandleLowHpMusicChange(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler);
} }
static void LinkPartnerHandleSetRawMonData(void) static void LinkPartnerHandleSetRawMonData(void)
{ {
u8 *dst = (u8 *)&gPlayerParty[gBattlePartyID[gActiveBattler]] + gBattleBufferA[gActiveBattler][1]; u8 *dst = (u8 *)&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]] + gBattleBufferA[gActiveBattler][1];
u8 i; u8 i;
for (i = 0; i < gBattleBufferA[gActiveBattler][2]; i++) for (i = 0; i < gBattleBufferA[gActiveBattler][2]; i++)
@ -1045,28 +1045,28 @@ static void LinkPartnerHandleLoadMonSprite(void)
{ {
u16 species; u16 species;
BattleLoadPlayerMonSpriteGfx(&gPlayerParty[gBattlePartyID[gActiveBattler]], gActiveBattler); BattleLoadPlayerMonSpriteGfx(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler);
species = GetMonData(&gPlayerParty[gBattlePartyID[gActiveBattler]], MON_DATA_SPECIES); species = GetMonData(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_SPECIES);
sub_806A068(species, GetBattlerPosition(gActiveBattler)); sub_806A068(species, GetBattlerPosition(gActiveBattler));
gBankSpriteIds[gActiveBattler] = CreateSprite(&gUnknown_0202499C, gBattlerSpriteIds[gActiveBattler] = CreateSprite(&gUnknown_0202499C,
GetBankCoord(gActiveBattler, 2), GetBattlerSpriteCoord(gActiveBattler, 2),
GetBankSpriteDefault_Y(gActiveBattler), GetBattlerSpriteDefault_Y(gActiveBattler),
sub_80A82E4(gActiveBattler)); sub_80A82E4(gActiveBattler));
gSprites[gBankSpriteIds[gActiveBattler]].pos2.x = -240; gSprites[gBattlerSpriteIds[gActiveBattler]].pos2.x = -240;
gSprites[gBankSpriteIds[gActiveBattler]].data[0] = gActiveBattler; gSprites[gBattlerSpriteIds[gActiveBattler]].data[0] = gActiveBattler;
gSprites[gBankSpriteIds[gActiveBattler]].oam.paletteNum = gActiveBattler; gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = gActiveBattler;
StartSpriteAnim(&gSprites[gBankSpriteIds[gActiveBattler]], gBattleMonForms[gActiveBattler]); StartSpriteAnim(&gSprites[gBattlerSpriteIds[gActiveBattler]], gBattleMonForms[gActiveBattler]);
gBattlerFuncs[gActiveBattler] = sub_814B290; gBattlerControllerFuncs[gActiveBattler] = sub_814B290;
} }
static void LinkPartnerHandleSwitchInAnim(void) static void LinkPartnerHandleSwitchInAnim(void)
{ {
ClearTemporarySpeciesSpriteData(gActiveBattler, gBattleBufferA[gActiveBattler][2]); ClearTemporarySpeciesSpriteData(gActiveBattler, gBattleBufferA[gActiveBattler][2]);
gBattlePartyID[gActiveBattler] = gBattleBufferA[gActiveBattler][1]; gBattlerPartyIndexes[gActiveBattler] = gBattleBufferA[gActiveBattler][1];
BattleLoadPlayerMonSpriteGfx(&gPlayerParty[gBattlePartyID[gActiveBattler]], gActiveBattler); BattleLoadPlayerMonSpriteGfx(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler);
sub_814CC98(gActiveBattler, gBattleBufferA[gActiveBattler][2]); sub_814CC98(gActiveBattler, gBattleBufferA[gActiveBattler][2]);
gBattlerFuncs[gActiveBattler] = sub_814B69C; gBattlerControllerFuncs[gActiveBattler] = sub_814B69C;
} }
static void sub_814CC98(u8 bank, bool8 dontClearSubstituteBit) static void sub_814CC98(u8 bank, bool8 dontClearSubstituteBit)
@ -1074,28 +1074,28 @@ static void sub_814CC98(u8 bank, bool8 dontClearSubstituteBit)
u16 species; u16 species;
ClearTemporarySpeciesSpriteData(bank, dontClearSubstituteBit); ClearTemporarySpeciesSpriteData(bank, dontClearSubstituteBit);
gBattlePartyID[bank] = gBattleBufferA[bank][1]; gBattlerPartyIndexes[bank] = gBattleBufferA[bank][1];
species = GetMonData(&gPlayerParty[gBattlePartyID[bank]], MON_DATA_SPECIES); species = GetMonData(&gPlayerParty[gBattlerPartyIndexes[bank]], MON_DATA_SPECIES);
gUnknown_03005D7C[bank] = CreateInvisibleSpriteWithCallback(sub_805D714); gUnknown_03005D7C[bank] = CreateInvisibleSpriteWithCallback(sub_805D714);
sub_806A068(species, GetBattlerPosition(bank)); sub_806A068(species, GetBattlerPosition(bank));
gBankSpriteIds[bank] = CreateSprite( gBattlerSpriteIds[bank] = CreateSprite(
&gUnknown_0202499C, &gUnknown_0202499C,
GetBankCoord(bank, 2), GetBattlerSpriteCoord(bank, 2),
GetBankSpriteDefault_Y(bank), GetBattlerSpriteDefault_Y(bank),
sub_80A82E4(bank)); sub_80A82E4(bank));
gSprites[gUnknown_03005D7C[bank]].data[1] = gBankSpriteIds[bank]; gSprites[gUnknown_03005D7C[bank]].data[1] = gBattlerSpriteIds[bank];
gSprites[gUnknown_03005D7C[bank]].data[2] = bank; gSprites[gUnknown_03005D7C[bank]].data[2] = bank;
gSprites[gBankSpriteIds[bank]].data[0] = bank; gSprites[gBattlerSpriteIds[bank]].data[0] = bank;
gSprites[gBankSpriteIds[bank]].data[2] = species; gSprites[gBattlerSpriteIds[bank]].data[2] = species;
gSprites[gBankSpriteIds[bank]].oam.paletteNum = bank; gSprites[gBattlerSpriteIds[bank]].oam.paletteNum = bank;
StartSpriteAnim(&gSprites[gBankSpriteIds[bank]], gBattleMonForms[bank]); StartSpriteAnim(&gSprites[gBattlerSpriteIds[bank]], gBattleMonForms[bank]);
gSprites[gBankSpriteIds[bank]].invisible = TRUE; gSprites[gBattlerSpriteIds[bank]].invisible = TRUE;
gSprites[gBankSpriteIds[bank]].callback = SpriteCallbackDummy; gSprites[gBattlerSpriteIds[bank]].callback = SpriteCallbackDummy;
gSprites[gUnknown_03005D7C[bank]].data[0] = DoPokeballSendOutAnimation(0, POKEBALL_PLAYER_SENDOUT); gSprites[gUnknown_03005D7C[bank]].data[0] = DoPokeballSendOutAnimation(0, POKEBALL_PLAYER_SENDOUT);
} }
@ -1105,13 +1105,13 @@ static void LinkPartnerHandleReturnMonToBall(void)
if (gBattleBufferA[gActiveBattler][1] == 0) if (gBattleBufferA[gActiveBattler][1] == 0)
{ {
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0;
gBattlerFuncs[gActiveBattler] = DoSwitchOutAnimation; gBattlerControllerFuncs[gActiveBattler] = DoSwitchOutAnimation;
} }
else else
{ {
FreeSpriteOamMatrix(&gSprites[gBankSpriteIds[gActiveBattler]]); FreeSpriteOamMatrix(&gSprites[gBattlerSpriteIds[gActiveBattler]]);
DestroySprite(&gSprites[gBankSpriteIds[gActiveBattler]]); DestroySprite(&gSprites[gBattlerSpriteIds[gActiveBattler]]);
SetHealthboxSpriteInvisible(gHealthBoxesIds[gActiveBattler]); SetHealthboxSpriteInvisible(gHealthboxSpriteIds[gActiveBattler]);
LinkPartnerBufferExecCompleted(); LinkPartnerBufferExecCompleted();
} }
} }
@ -1131,7 +1131,7 @@ static void DoSwitchOutAnimation(void)
{ {
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0;
InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SWITCH_OUT_PLAYER_MON); InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SWITCH_OUT_PLAYER_MON);
gBattlerFuncs[gActiveBattler] = sub_814B3DC; gBattlerControllerFuncs[gActiveBattler] = sub_814B3DC;
} }
break; break;
} }
@ -1154,31 +1154,31 @@ static void LinkPartnerHandleDrawTrainerPic(void)
xPos = 80; xPos = 80;
} }
if ((gLinkPlayers[GetBankMultiplayerId(gActiveBattler)].version & 0xFF) == VERSION_FIRE_RED if ((gLinkPlayers[GetBattlerMultiplayerId(gActiveBattler)].version & 0xFF) == VERSION_FIRE_RED
|| (gLinkPlayers[GetBankMultiplayerId(gActiveBattler)].version & 0xFF) == VERSION_LEAF_GREEN) || (gLinkPlayers[GetBattlerMultiplayerId(gActiveBattler)].version & 0xFF) == VERSION_LEAF_GREEN)
{ {
trainerPicId = gLinkPlayers[GetBankMultiplayerId(gActiveBattler)].gender + BACK_PIC_RED; trainerPicId = gLinkPlayers[GetBattlerMultiplayerId(gActiveBattler)].gender + BACK_PIC_RED;
} }
else if ((gLinkPlayers[GetBankMultiplayerId(gActiveBattler)].version & 0xFF) == VERSION_RUBY else if ((gLinkPlayers[GetBattlerMultiplayerId(gActiveBattler)].version & 0xFF) == VERSION_RUBY
|| (gLinkPlayers[GetBankMultiplayerId(gActiveBattler)].version & 0xFF) == VERSION_SAPPHIRE) || (gLinkPlayers[GetBattlerMultiplayerId(gActiveBattler)].version & 0xFF) == VERSION_SAPPHIRE)
{ {
trainerPicId = gLinkPlayers[GetBankMultiplayerId(gActiveBattler)].gender + BACK_PIC_RS_BRENDAN; trainerPicId = gLinkPlayers[GetBattlerMultiplayerId(gActiveBattler)].gender + BACK_PIC_RS_BRENDAN;
} }
else else
{ {
trainerPicId = gLinkPlayers[GetBankMultiplayerId(gActiveBattler)].gender; trainerPicId = gLinkPlayers[GetBattlerMultiplayerId(gActiveBattler)].gender;
} }
DecompressTrainerBackPic(trainerPicId, gActiveBattler); DecompressTrainerBackPic(trainerPicId, gActiveBattler);
sub_806A12C(trainerPicId, GetBattlerPosition(gActiveBattler)); sub_806A12C(trainerPicId, GetBattlerPosition(gActiveBattler));
gBankSpriteIds[gActiveBattler] = CreateSprite(&gUnknown_0202499C, xPos, (8 - gTrainerBackPicCoords[trainerPicId].coords) * 4 + 80, sub_80A82E4(gActiveBattler)); gBattlerSpriteIds[gActiveBattler] = CreateSprite(&gUnknown_0202499C, xPos, (8 - gTrainerBackPicCoords[trainerPicId].coords) * 4 + 80, sub_80A82E4(gActiveBattler));
gSprites[gBankSpriteIds[gActiveBattler]].oam.paletteNum = gActiveBattler; gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = gActiveBattler;
gSprites[gBankSpriteIds[gActiveBattler]].pos2.x = 240; gSprites[gBattlerSpriteIds[gActiveBattler]].pos2.x = 240;
gSprites[gBankSpriteIds[gActiveBattler]].data[0] = -2; gSprites[gBattlerSpriteIds[gActiveBattler]].data[0] = -2;
gSprites[gBankSpriteIds[gActiveBattler]].callback = sub_805D7AC; gSprites[gBattlerSpriteIds[gActiveBattler]].callback = sub_805D7AC;
gBattlerFuncs[gActiveBattler] = CompleteOnBankSpriteCallbackDummy; gBattlerControllerFuncs[gActiveBattler] = CompleteOnBankSpriteCallbackDummy;
} }
static void LinkPartnerHandleTrainerSlide(void) static void LinkPartnerHandleTrainerSlide(void)
@ -1188,13 +1188,13 @@ static void LinkPartnerHandleTrainerSlide(void)
static void LinkPartnerHandleTrainerSlideBack(void) static void LinkPartnerHandleTrainerSlideBack(void)
{ {
oamt_add_pos2_onto_pos1(&gSprites[gBankSpriteIds[gActiveBattler]]); oamt_add_pos2_onto_pos1(&gSprites[gBattlerSpriteIds[gActiveBattler]]);
gSprites[gBankSpriteIds[gActiveBattler]].data[0] = 35; gSprites[gBattlerSpriteIds[gActiveBattler]].data[0] = 35;
gSprites[gBankSpriteIds[gActiveBattler]].data[2] = -40; gSprites[gBattlerSpriteIds[gActiveBattler]].data[2] = -40;
gSprites[gBankSpriteIds[gActiveBattler]].data[4] = gSprites[gBankSpriteIds[gActiveBattler]].pos1.y; gSprites[gBattlerSpriteIds[gActiveBattler]].data[4] = gSprites[gBattlerSpriteIds[gActiveBattler]].pos1.y;
gSprites[gBankSpriteIds[gActiveBattler]].callback = sub_80A6EEC; gSprites[gBattlerSpriteIds[gActiveBattler]].callback = sub_80A6EEC;
StoreSpriteCallbackInData6(&gSprites[gBankSpriteIds[gActiveBattler]], SpriteCallbackDummy); StoreSpriteCallbackInData6(&gSprites[gBattlerSpriteIds[gActiveBattler]], SpriteCallbackDummy);
gBattlerFuncs[gActiveBattler] = sub_814AF54; gBattlerControllerFuncs[gActiveBattler] = sub_814AF54;
} }
static void LinkPartnerHandleFaintAnimation(void) static void LinkPartnerHandleFaintAnimation(void)
@ -1210,12 +1210,12 @@ static void LinkPartnerHandleFaintAnimation(void)
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive) if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive)
{ {
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0;
HandleLowHpMusicChange(&gPlayerParty[gBattlePartyID[gActiveBattler]], gActiveBattler); HandleLowHpMusicChange(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler);
PlaySE12WithPanning(SE_POKE_DEAD, PAN_SIDE_PLAYER); PlaySE12WithPanning(SE_POKE_DEAD, PAN_SIDE_PLAYER);
gSprites[gBankSpriteIds[gActiveBattler]].data[1] = 0; gSprites[gBattlerSpriteIds[gActiveBattler]].data[1] = 0;
gSprites[gBankSpriteIds[gActiveBattler]].data[2] = 5; gSprites[gBattlerSpriteIds[gActiveBattler]].data[2] = 5;
gSprites[gBankSpriteIds[gActiveBattler]].callback = sub_8039C00; gSprites[gBattlerSpriteIds[gActiveBattler]].callback = sub_8039C00;
gBattlerFuncs[gActiveBattler] = sub_814B340; gBattlerControllerFuncs[gActiveBattler] = sub_814B340;
} }
} }
} }
@ -1260,7 +1260,7 @@ static void LinkPartnerHandleMoveAnimation(void)
else else
{ {
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0;
gBattlerFuncs[gActiveBattler] = LinkPartnerDoMoveAnimation; gBattlerControllerFuncs[gActiveBattler] = LinkPartnerDoMoveAnimation;
sub_817E0FC(move, gWeatherMoveAnim, gAnimDisableStructPtr); sub_817E0FC(move, gWeatherMoveAnim, gAnimDisableStructPtr);
} }
} }
@ -1324,7 +1324,7 @@ static void LinkPartnerHandlePrintString(void)
stringId = (u16*)(&gBattleBufferA[gActiveBattler][2]); stringId = (u16*)(&gBattleBufferA[gActiveBattler][2]);
BufferStringBattle(*stringId); BufferStringBattle(*stringId);
BattleHandleAddTextPrinter(gDisplayedStringBattle, 0); BattleHandleAddTextPrinter(gDisplayedStringBattle, 0);
gBattlerFuncs[gActiveBattler] = CompleteOnInactiveTextPrinter; gBattlerControllerFuncs[gActiveBattler] = CompleteOnInactiveTextPrinter;
sub_817C95C(*stringId); sub_817C95C(*stringId);
} }
@ -1372,19 +1372,19 @@ static void LinkPartnerHandleHealthBarUpdate(void)
if (hpVal != INSTANT_HP_BAR_DROP) if (hpVal != INSTANT_HP_BAR_DROP)
{ {
u32 maxHP = GetMonData(&gPlayerParty[gBattlePartyID[gActiveBattler]], MON_DATA_MAX_HP); u32 maxHP = GetMonData(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_MAX_HP);
u32 curHP = GetMonData(&gPlayerParty[gBattlePartyID[gActiveBattler]], MON_DATA_HP); u32 curHP = GetMonData(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_HP);
SetBattleBarStruct(gActiveBattler, gHealthBoxesIds[gActiveBattler], maxHP, curHP, hpVal); SetBattleBarStruct(gActiveBattler, gHealthboxSpriteIds[gActiveBattler], maxHP, curHP, hpVal);
} }
else else
{ {
u32 maxHP = GetMonData(&gPlayerParty[gBattlePartyID[gActiveBattler]], MON_DATA_MAX_HP); u32 maxHP = GetMonData(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_MAX_HP);
SetBattleBarStruct(gActiveBattler, gHealthBoxesIds[gActiveBattler], maxHP, 0, hpVal); SetBattleBarStruct(gActiveBattler, gHealthboxSpriteIds[gActiveBattler], maxHP, 0, hpVal);
} }
gBattlerFuncs[gActiveBattler] = CompleteOnHealthbarDone; gBattlerControllerFuncs[gActiveBattler] = CompleteOnHealthbarDone;
} }
static void LinkPartnerHandleExpUpdate(void) static void LinkPartnerHandleExpUpdate(void)
@ -1398,10 +1398,10 @@ static void LinkPartnerHandleStatusIconUpdate(void)
{ {
u8 bank; u8 bank;
UpdateHealthboxAttribute(gHealthBoxesIds[gActiveBattler], &gPlayerParty[gBattlePartyID[gActiveBattler]], HEALTHBOX_STATUS_ICON); UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler], &gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], HEALTHBOX_STATUS_ICON);
bank = gActiveBattler; bank = gActiveBattler;
gBattleSpritesDataPtr->healthBoxesData[bank].statusAnimActive = 0; gBattleSpritesDataPtr->healthBoxesData[bank].statusAnimActive = 0;
gBattlerFuncs[gActiveBattler] = CompleteOnFinishedStatusAnimation; gBattlerControllerFuncs[gActiveBattler] = CompleteOnFinishedStatusAnimation;
} }
} }
@ -1411,7 +1411,7 @@ static void LinkPartnerHandleStatusAnimation(void)
{ {
InitAndLaunchChosenStatusAnimation(gBattleBufferA[gActiveBattler][1], InitAndLaunchChosenStatusAnimation(gBattleBufferA[gActiveBattler][1],
gBattleBufferA[gActiveBattler][2] | (gBattleBufferA[gActiveBattler][3] << 8) | (gBattleBufferA[gActiveBattler][4] << 16) | (gBattleBufferA[gActiveBattler][5] << 24)); gBattleBufferA[gActiveBattler][2] | (gBattleBufferA[gActiveBattler][3] << 8) | (gBattleBufferA[gActiveBattler][4] << 16) | (gBattleBufferA[gActiveBattler][5] << 24));
gBattlerFuncs[gActiveBattler] = CompleteOnFinishedStatusAnimation; gBattlerControllerFuncs[gActiveBattler] = CompleteOnFinishedStatusAnimation;
} }
} }
@ -1486,16 +1486,16 @@ static void LinkPartnerHandleCmd40(void)
static void LinkPartnerHandleHitAnimation(void) static void LinkPartnerHandleHitAnimation(void)
{ {
if (gSprites[gBankSpriteIds[gActiveBattler]].invisible == TRUE) if (gSprites[gBattlerSpriteIds[gActiveBattler]].invisible == TRUE)
{ {
LinkPartnerBufferExecCompleted(); LinkPartnerBufferExecCompleted();
} }
else else
{ {
gDoingBattleAnim = TRUE; gDoingBattleAnim = TRUE;
gSprites[gBankSpriteIds[gActiveBattler]].data[1] = 0; gSprites[gBattlerSpriteIds[gActiveBattler]].data[1] = 0;
DoHitAnimHealthboxEffect(gActiveBattler); DoHitAnimHealthboxEffect(gActiveBattler);
gBattlerFuncs[gActiveBattler] = DoHitAnimBlinkSpriteEffect; gBattlerControllerFuncs[gActiveBattler] = DoHitAnimBlinkSpriteEffect;
} }
} }
@ -1534,7 +1534,7 @@ static void LinkPartnerHandlePlayFanfareOrBGM(void)
static void LinkPartnerHandleFaintingCry(void) static void LinkPartnerHandleFaintingCry(void)
{ {
u16 species = GetMonData(&gPlayerParty[gBattlePartyID[gActiveBattler]], MON_DATA_SPECIES); u16 species = GetMonData(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_SPECIES);
PlayCry3(species, -25, 5); PlayCry3(species, -25, 5);
LinkPartnerBufferExecCompleted(); LinkPartnerBufferExecCompleted();
@ -1553,37 +1553,37 @@ static void LinkPartnerHandleIntroTrainerBallThrow(void)
u8 taskId; u8 taskId;
u32 trainerPicId; u32 trainerPicId;
oamt_add_pos2_onto_pos1(&gSprites[gBankSpriteIds[gActiveBattler]]); oamt_add_pos2_onto_pos1(&gSprites[gBattlerSpriteIds[gActiveBattler]]);
gSprites[gBankSpriteIds[gActiveBattler]].data[0] = 50; gSprites[gBattlerSpriteIds[gActiveBattler]].data[0] = 50;
gSprites[gBankSpriteIds[gActiveBattler]].data[2] = -40; gSprites[gBattlerSpriteIds[gActiveBattler]].data[2] = -40;
gSprites[gBankSpriteIds[gActiveBattler]].data[4] = gSprites[gBankSpriteIds[gActiveBattler]].pos1.y; gSprites[gBattlerSpriteIds[gActiveBattler]].data[4] = gSprites[gBattlerSpriteIds[gActiveBattler]].pos1.y;
gSprites[gBankSpriteIds[gActiveBattler]].callback = sub_80A6EEC; gSprites[gBattlerSpriteIds[gActiveBattler]].callback = sub_80A6EEC;
gSprites[gBankSpriteIds[gActiveBattler]].data[5] = gActiveBattler; gSprites[gBattlerSpriteIds[gActiveBattler]].data[5] = gActiveBattler;
StoreSpriteCallbackInData6(&gSprites[gBankSpriteIds[gActiveBattler]], sub_805CC00); StoreSpriteCallbackInData6(&gSprites[gBattlerSpriteIds[gActiveBattler]], sub_805CC00);
StartSpriteAnim(&gSprites[gBankSpriteIds[gActiveBattler]], 1); StartSpriteAnim(&gSprites[gBattlerSpriteIds[gActiveBattler]], 1);
paletteNum = AllocSpritePalette(0xD6F9); paletteNum = AllocSpritePalette(0xD6F9);
if ((gLinkPlayers[GetBankMultiplayerId(gActiveBattler)].version & 0xFF) == VERSION_FIRE_RED if ((gLinkPlayers[GetBattlerMultiplayerId(gActiveBattler)].version & 0xFF) == VERSION_FIRE_RED
|| (gLinkPlayers[GetBankMultiplayerId(gActiveBattler)].version & 0xFF) == VERSION_LEAF_GREEN) || (gLinkPlayers[GetBattlerMultiplayerId(gActiveBattler)].version & 0xFF) == VERSION_LEAF_GREEN)
{ {
trainerPicId = gLinkPlayers[GetBankMultiplayerId(gActiveBattler)].gender + BACK_PIC_RED; trainerPicId = gLinkPlayers[GetBattlerMultiplayerId(gActiveBattler)].gender + BACK_PIC_RED;
} }
else if ((gLinkPlayers[GetBankMultiplayerId(gActiveBattler)].version & 0xFF) == VERSION_RUBY else if ((gLinkPlayers[GetBattlerMultiplayerId(gActiveBattler)].version & 0xFF) == VERSION_RUBY
|| (gLinkPlayers[GetBankMultiplayerId(gActiveBattler)].version & 0xFF) == VERSION_SAPPHIRE) || (gLinkPlayers[GetBattlerMultiplayerId(gActiveBattler)].version & 0xFF) == VERSION_SAPPHIRE)
{ {
trainerPicId = gLinkPlayers[GetBankMultiplayerId(gActiveBattler)].gender + BACK_PIC_RS_BRENDAN; trainerPicId = gLinkPlayers[GetBattlerMultiplayerId(gActiveBattler)].gender + BACK_PIC_RS_BRENDAN;
} }
else else
{ {
trainerPicId = gLinkPlayers[GetBankMultiplayerId(gActiveBattler)].gender; trainerPicId = gLinkPlayers[GetBattlerMultiplayerId(gActiveBattler)].gender;
} }
LoadCompressedPalette(gTrainerBackPicPaletteTable[trainerPicId].data, 0x100 + paletteNum * 16, 32); LoadCompressedPalette(gTrainerBackPicPaletteTable[trainerPicId].data, 0x100 + paletteNum * 16, 32);
gSprites[gBankSpriteIds[gActiveBattler]].oam.paletteNum = paletteNum; gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = paletteNum;
taskId = CreateTask(sub_814DCCC, 5); taskId = CreateTask(sub_814DCCC, 5);
gTasks[taskId].data[0] = gActiveBattler; gTasks[taskId].data[0] = gActiveBattler;
@ -1592,7 +1592,7 @@ static void LinkPartnerHandleIntroTrainerBallThrow(void)
gTasks[gUnknown_020244B4[gActiveBattler]].func = sub_8073C30; gTasks[gUnknown_020244B4[gActiveBattler]].func = sub_8073C30;
gBattleSpritesDataPtr->animationData->field_9_x1 = 1; gBattleSpritesDataPtr->animationData->field_9_x1 = 1;
gBattlerFuncs[gActiveBattler] = nullsub_112; gBattlerControllerFuncs[gActiveBattler] = nullsub_112;
} }
static void sub_814DCCC(u8 taskId) static void sub_814DCCC(u8 taskId)
@ -1608,20 +1608,20 @@ static void sub_814DCCC(u8 taskId)
gActiveBattler = gTasks[taskId].data[0]; gActiveBattler = gTasks[taskId].data[0];
if (!IsDoubleBattle() || (gBattleTypeFlags & BATTLE_TYPE_MULTI)) if (!IsDoubleBattle() || (gBattleTypeFlags & BATTLE_TYPE_MULTI))
{ {
gBattleBufferA[gActiveBattler][1] = gBattlePartyID[gActiveBattler]; gBattleBufferA[gActiveBattler][1] = gBattlerPartyIndexes[gActiveBattler];
sub_814CC98(gActiveBattler, FALSE); sub_814CC98(gActiveBattler, FALSE);
} }
else else
{ {
gBattleBufferA[gActiveBattler][1] = gBattlePartyID[gActiveBattler]; gBattleBufferA[gActiveBattler][1] = gBattlerPartyIndexes[gActiveBattler];
sub_814CC98(gActiveBattler, FALSE); sub_814CC98(gActiveBattler, FALSE);
gActiveBattler ^= BIT_FLANK; gActiveBattler ^= BIT_FLANK;
gBattleBufferA[gActiveBattler][1] = gBattlePartyID[gActiveBattler]; gBattleBufferA[gActiveBattler][1] = gBattlerPartyIndexes[gActiveBattler];
BattleLoadPlayerMonSpriteGfx(&gPlayerParty[gBattlePartyID[gActiveBattler]], gActiveBattler); BattleLoadPlayerMonSpriteGfx(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler);
sub_814CC98(gActiveBattler, FALSE); sub_814CC98(gActiveBattler, FALSE);
gActiveBattler ^= BIT_FLANK; gActiveBattler ^= BIT_FLANK;
} }
gBattlerFuncs[gActiveBattler] = sub_814B0E8; gBattlerControllerFuncs[gActiveBattler] = sub_814B0E8;
gActiveBattler = savedActiveBank; gActiveBattler = savedActiveBank;
DestroyTask(taskId); DestroyTask(taskId);
} }
@ -1642,7 +1642,7 @@ static void LinkPartnerHandleDrawPartyStatusSummary(void)
if (gBattleBufferA[gActiveBattler][2] != 0) if (gBattleBufferA[gActiveBattler][2] != 0)
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_5 = 0x5D; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_5 = 0x5D;
gBattlerFuncs[gActiveBattler] = sub_814DE9C; gBattlerControllerFuncs[gActiveBattler] = sub_814DE9C;
} }
} }
@ -1669,9 +1669,9 @@ static void LinkPartnerHandleCmd50(void)
static void LinkPartnerHandleSpriteInvisibility(void) static void LinkPartnerHandleSpriteInvisibility(void)
{ {
if (IsBankSpritePresent(gActiveBattler)) if (IsBattlerSpritePresent(gActiveBattler))
{ {
gSprites[gBankSpriteIds[gActiveBattler]].invisible = gBattleBufferA[gActiveBattler][1]; gSprites[gBattlerSpriteIds[gActiveBattler]].invisible = gBattleBufferA[gActiveBattler][1];
CopyBattleSpriteInvisibility(gActiveBattler); CopyBattleSpriteInvisibility(gActiveBattler);
} }
LinkPartnerBufferExecCompleted(); LinkPartnerBufferExecCompleted();
@ -1687,7 +1687,7 @@ static void LinkPartnerHandleBattleAnimation(void)
if (TryHandleLaunchBattleTableAnimation(gActiveBattler, gActiveBattler, gActiveBattler, animationId, argument)) if (TryHandleLaunchBattleTableAnimation(gActiveBattler, gActiveBattler, gActiveBattler, animationId, argument))
LinkPartnerBufferExecCompleted(); LinkPartnerBufferExecCompleted();
else else
gBattlerFuncs[gActiveBattler] = CompleteOnFinishedBattleAnimation; gBattlerControllerFuncs[gActiveBattler] = CompleteOnFinishedBattleAnimation;
sub_817E32C(animationId); sub_817E32C(animationId);
} }
@ -1712,7 +1712,7 @@ static void LinkPartnerHandleCmd55(void)
FadeOutMapMusic(5); FadeOutMapMusic(5);
BeginFastPaletteFade(3); BeginFastPaletteFade(3);
LinkPartnerBufferExecCompleted(); LinkPartnerBufferExecCompleted();
gBattlerFuncs[gActiveBattler] = sub_80587B0; gBattlerControllerFuncs[gActiveBattler] = sub_80587B0;
} }
static void nullsub_113(void) static void nullsub_113(void)

View File

@ -28,19 +28,19 @@
#include "pokeball.h" #include "pokeball.h"
#include "data2.h" #include "data2.h"
extern u32 gBattleExecBuffer; extern u32 gBattleControllerExecFlags;
extern u8 gActiveBattler; extern u8 gActiveBattler;
extern u8 gBattleDefender; extern u8 gBattleMoveTarget;
extern u8 gAbsentBattlerFlags; extern u8 gAbsentBattlerFlags;
extern bool8 gDoingBattleAnim; extern bool8 gDoingBattleAnim;
extern u16 gBattlePartyID[MAX_BATTLERS_COUNT]; extern u16 gBattlerPartyIndexes[MAX_BATTLERS_COUNT];
extern u8 gBankSpriteIds[MAX_BATTLERS_COUNT]; extern u8 gBattlerSpriteIds[MAX_BATTLERS_COUNT];
extern u8 gBattleBufferA[MAX_BATTLERS_COUNT][0x200]; extern u8 gBattleBufferA[MAX_BATTLERS_COUNT][0x200];
extern u8 gBattleBufferB[MAX_BATTLERS_COUNT][0x200]; extern u8 gBattleBufferB[MAX_BATTLERS_COUNT][0x200];
extern u8 gHealthBoxesIds[MAX_BATTLERS_COUNT]; extern u8 gHealthboxSpriteIds[MAX_BATTLERS_COUNT];
extern struct MusicPlayerInfo gMPlayInfo_BGM; extern struct MusicPlayerInfo gMPlayInfo_BGM;
extern u8 gUnknown_03005D7C[MAX_BATTLERS_COUNT]; extern u8 gUnknown_03005D7C[MAX_BATTLERS_COUNT];
extern void (*gBattlerFuncs[MAX_BATTLERS_COUNT])(void); extern void (*gBattlerControllerFuncs[MAX_BATTLERS_COUNT])(void);
extern void *gUnknown_020244D8; extern void *gUnknown_020244D8;
extern void *gUnknown_020244DC; extern void *gUnknown_020244DC;
extern u8 gBattleMonForms[MAX_BATTLERS_COUNT]; extern u8 gBattleMonForms[MAX_BATTLERS_COUNT];
@ -207,12 +207,12 @@ static void nullsub_26(void)
void SetControllerToOpponent(void) void SetControllerToOpponent(void)
{ {
gBattlerFuncs[gActiveBattler] = OpponentBufferRunCommand; gBattlerControllerFuncs[gActiveBattler] = OpponentBufferRunCommand;
} }
static void OpponentBufferRunCommand(void) static void OpponentBufferRunCommand(void)
{ {
if (gBattleExecBuffer & gBitTable[gActiveBattler]) if (gBattleControllerExecFlags & gBitTable[gActiveBattler])
{ {
if (gBattleBufferA[gActiveBattler][0] < ARRAY_COUNT(sOpponentBufferCommands)) if (gBattleBufferA[gActiveBattler][0] < ARRAY_COUNT(sOpponentBufferCommands))
sOpponentBufferCommands[gBattleBufferA[gActiveBattler][0]](); sOpponentBufferCommands[gBattleBufferA[gActiveBattler][0]]();
@ -223,23 +223,23 @@ static void OpponentBufferRunCommand(void)
static void CompleteOnBankSpriteCallbackDummy(void) static void CompleteOnBankSpriteCallbackDummy(void)
{ {
if (gSprites[gBankSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy) if (gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
OpponentBufferExecCompleted(); OpponentBufferExecCompleted();
} }
static void CompleteOnBankSpriteCallbackDummy2(void) static void CompleteOnBankSpriteCallbackDummy2(void)
{ {
if (gSprites[gBankSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy) if (gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
OpponentBufferExecCompleted(); OpponentBufferExecCompleted();
} }
static void sub_805F240(void) static void sub_805F240(void)
{ {
if (gSprites[gBankSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy) if (gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
{ {
FreeTrainerFrontPicPalette(gSprites[gBankSpriteIds[gActiveBattler]].oam.affineParam); FreeTrainerFrontPicPalette(gSprites[gBattlerSpriteIds[gActiveBattler]].oam.affineParam);
FreeSpriteOamMatrix(&gSprites[gBankSpriteIds[gActiveBattler]]); FreeSpriteOamMatrix(&gSprites[gBattlerSpriteIds[gActiveBattler]]);
DestroySprite(&gSprites[gBankSpriteIds[gActiveBattler]]); DestroySprite(&gSprites[gBattlerSpriteIds[gActiveBattler]]);
OpponentBufferExecCompleted(); OpponentBufferExecCompleted();
} }
} }
@ -260,14 +260,14 @@ static void sub_805F2F0(void)
if (!IsDoubleBattle() || ((IsDoubleBattle() && (gBattleTypeFlags & BATTLE_TYPE_MULTI)) || (gBattleTypeFlags & BATTLE_TYPE_TWO_OPPONENTS))) if (!IsDoubleBattle() || ((IsDoubleBattle() && (gBattleTypeFlags & BATTLE_TYPE_MULTI)) || (gBattleTypeFlags & BATTLE_TYPE_TWO_OPPONENTS)))
{ {
if (gSprites[gHealthBoxesIds[gActiveBattler]].callback == SpriteCallbackDummy) if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
var = TRUE; var = TRUE;
var2 = FALSE; var2 = FALSE;
} }
else else
{ {
if (gSprites[gHealthBoxesIds[gActiveBattler]].callback == SpriteCallbackDummy if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy
&& gSprites[gHealthBoxesIds[gActiveBattler ^ BIT_FLANK]].callback == SpriteCallbackDummy) && gSprites[gHealthboxSpriteIds[gActiveBattler ^ BIT_FLANK]].callback == SpriteCallbackDummy)
var = TRUE; var = TRUE;
var2 = TRUE; var2 = TRUE;
} }
@ -310,7 +310,7 @@ static void sub_805F2F0(void)
return; return;
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_9 = 3; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_9 = 3;
gBattlerFuncs[gActiveBattler] = sub_805F2A8; gBattlerControllerFuncs[gActiveBattler] = sub_805F2A8;
} }
} }
@ -320,22 +320,22 @@ static void sub_805F560(void)
bool32 r10 = FALSE; bool32 r10 = FALSE;
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].flag_x80 && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x1) if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].flag_x80 && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x1)
sub_8172EF0(gActiveBattler, &gEnemyParty[gBattlePartyID[gActiveBattler]]); sub_8172EF0(gActiveBattler, &gEnemyParty[gBattlerPartyIndexes[gActiveBattler]]);
if (!(gBattleTypeFlags & BATTLE_TYPE_TWO_OPPONENTS) && !(gBattleTypeFlags & BATTLE_TYPE_MULTI) && IsDoubleBattle() && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].flag_x80 && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].ballAnimActive && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].field_1_x1) if (!(gBattleTypeFlags & BATTLE_TYPE_TWO_OPPONENTS) && !(gBattleTypeFlags & BATTLE_TYPE_MULTI) && IsDoubleBattle() && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].flag_x80 && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].ballAnimActive && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].field_1_x1)
sub_8172EF0(gActiveBattler ^ BIT_FLANK, &gEnemyParty[gBattlePartyID[gActiveBattler ^ BIT_FLANK]]); sub_8172EF0(gActiveBattler ^ BIT_FLANK, &gEnemyParty[gBattlerPartyIndexes[gActiveBattler ^ BIT_FLANK]]);
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].ballAnimActive) if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].ballAnimActive)
{ {
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x80) if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x80)
{ {
if (IsDoubleBattle() && !(gBattleTypeFlags & BATTLE_TYPE_MULTI)) if (IsDoubleBattle() && !(gBattleTypeFlags & BATTLE_TYPE_MULTI))
{ {
UpdateHealthboxAttribute(gHealthBoxesIds[gActiveBattler ^ BIT_FLANK], &gEnemyParty[gBattlePartyID[gActiveBattler ^ BIT_FLANK]], HEALTHBOX_ALL); UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler ^ BIT_FLANK], &gEnemyParty[gBattlerPartyIndexes[gActiveBattler ^ BIT_FLANK]], HEALTHBOX_ALL);
sub_8076918(gActiveBattler ^ BIT_FLANK); sub_8076918(gActiveBattler ^ BIT_FLANK);
SetHealthboxSpriteVisible(gHealthBoxesIds[gActiveBattler ^ BIT_FLANK]); SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler ^ BIT_FLANK]);
} }
UpdateHealthboxAttribute(gHealthBoxesIds[gActiveBattler], &gEnemyParty[gBattlePartyID[gActiveBattler]], HEALTHBOX_ALL); UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler], &gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], HEALTHBOX_ALL);
sub_8076918(gActiveBattler); sub_8076918(gActiveBattler);
SetHealthboxSpriteVisible(gHealthBoxesIds[gActiveBattler]); SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]);
} }
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x80 = 1; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x80 = 1;
} }
@ -362,7 +362,7 @@ static void sub_805F560(void)
if (!IsDoubleBattle() || (IsDoubleBattle() && (gBattleTypeFlags & BATTLE_TYPE_MULTI))) if (!IsDoubleBattle() || (IsDoubleBattle() && (gBattleTypeFlags & BATTLE_TYPE_MULTI)))
{ {
if (gSprites[gUnknown_03005D7C[gActiveBattler]].callback == SpriteCallbackDummy if (gSprites[gUnknown_03005D7C[gActiveBattler]].callback == SpriteCallbackDummy
&& gSprites[gBankSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy) && gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
{ {
r10 = TRUE; r10 = TRUE;
} }
@ -370,9 +370,9 @@ static void sub_805F560(void)
else else
{ {
if (gSprites[gUnknown_03005D7C[gActiveBattler]].callback == SpriteCallbackDummy if (gSprites[gUnknown_03005D7C[gActiveBattler]].callback == SpriteCallbackDummy
&& gSprites[gBankSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy && gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy
&& gSprites[gUnknown_03005D7C[gActiveBattler ^ BIT_FLANK]].callback == SpriteCallbackDummy && gSprites[gUnknown_03005D7C[gActiveBattler ^ BIT_FLANK]].callback == SpriteCallbackDummy
&& gSprites[gBankSpriteIds[gActiveBattler ^ BIT_FLANK]].callback == SpriteCallbackDummy) && gSprites[gBattlerSpriteIds[gActiveBattler ^ BIT_FLANK]].callback == SpriteCallbackDummy)
{ {
r10 = TRUE; r10 = TRUE;
} }
@ -383,25 +383,25 @@ static void sub_805F560(void)
if (IsDoubleBattle() && !(gBattleTypeFlags & BATTLE_TYPE_MULTI)) if (IsDoubleBattle() && !(gBattleTypeFlags & BATTLE_TYPE_MULTI))
{ {
DestroySprite(&gSprites[gUnknown_03005D7C[gActiveBattler ^ BIT_FLANK]]); DestroySprite(&gSprites[gUnknown_03005D7C[gActiveBattler ^ BIT_FLANK]]);
SetBankEnemyShadowSpriteCallback(gActiveBattler ^ BIT_FLANK, GetMonData(&gEnemyParty[gBattlePartyID[gActiveBattler ^ BIT_FLANK]], MON_DATA_SPECIES)); SetBattlerShadowSpriteCallback(gActiveBattler ^ BIT_FLANK, GetMonData(&gEnemyParty[gBattlerPartyIndexes[gActiveBattler ^ BIT_FLANK]], MON_DATA_SPECIES));
} }
DestroySprite(&gSprites[gUnknown_03005D7C[gActiveBattler]]); DestroySprite(&gSprites[gUnknown_03005D7C[gActiveBattler]]);
SetBankEnemyShadowSpriteCallback(gActiveBattler, GetMonData(&gEnemyParty[gBattlePartyID[gActiveBattler]], MON_DATA_SPECIES)); SetBattlerShadowSpriteCallback(gActiveBattler, GetMonData(&gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_SPECIES));
gBattleSpritesDataPtr->animationData->field_9_x1 = 0; gBattleSpritesDataPtr->animationData->field_9_x1 = 0;
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x20 = 0; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x20 = 0;
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x80 = 0; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x80 = 0;
gBattlerFuncs[gActiveBattler] = sub_805F2F0; gBattlerControllerFuncs[gActiveBattler] = sub_805F2F0;
} }
} }
static void sub_805F994(void) static void sub_805F994(void)
{ {
if (gSprites[gBankSpriteIds[gActiveBattler]].pos2.x == 0 && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].flag_x80 && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x1) if (gSprites[gBattlerSpriteIds[gActiveBattler]].pos2.x == 0 && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].flag_x80 && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x1)
sub_8172EF0(gActiveBattler, &gEnemyParty[gBattlePartyID[gActiveBattler]]); sub_8172EF0(gActiveBattler, &gEnemyParty[gBattlerPartyIndexes[gActiveBattler]]);
if (gSprites[gBankSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy && gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x1) if (gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy && gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x1)
{ {
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].flag_x80 = 0; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].flag_x80 = 0;
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x1 = 0; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x1 = 0;
@ -413,11 +413,11 @@ static void sub_805F994(void)
static void CompleteOnHealthbarDone(void) static void CompleteOnHealthbarDone(void)
{ {
s16 hpValue = sub_8074AA0(gActiveBattler, gHealthBoxesIds[gActiveBattler], HEALTH_BAR, 0); s16 hpValue = sub_8074AA0(gActiveBattler, gHealthboxSpriteIds[gActiveBattler], HEALTH_BAR, 0);
SetHealthboxSpriteVisible(gHealthBoxesIds[gActiveBattler]); SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]);
if (hpValue != -1) if (hpValue != -1)
{ {
UpdateHpTextInHealthbox(gHealthBoxesIds[gActiveBattler], hpValue, HP_CURRENT); UpdateHpTextInHealthbox(gHealthboxSpriteIds[gActiveBattler], hpValue, HP_CURRENT);
} }
else else
OpponentBufferExecCompleted(); OpponentBufferExecCompleted();
@ -425,9 +425,9 @@ static void CompleteOnHealthbarDone(void)
static void sub_805FAC4(void) static void sub_805FAC4(void)
{ {
if (!gSprites[gBankSpriteIds[gActiveBattler]].inUse) if (!gSprites[gBattlerSpriteIds[gActiveBattler]].inUse)
{ {
SetHealthboxSpriteInvisible(gHealthBoxesIds[gActiveBattler]); SetHealthboxSpriteInvisible(gHealthboxSpriteIds[gActiveBattler]);
OpponentBufferExecCompleted(); OpponentBufferExecCompleted();
} }
} }
@ -436,10 +436,10 @@ static void sub_805FB08(void)
{ {
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive) if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive)
{ {
FreeSpriteOamMatrix(&gSprites[gBankSpriteIds[gActiveBattler]]); FreeSpriteOamMatrix(&gSprites[gBattlerSpriteIds[gActiveBattler]]);
DestroySprite(&gSprites[gBankSpriteIds[gActiveBattler]]); DestroySprite(&gSprites[gBattlerSpriteIds[gActiveBattler]]);
EnemyShadowCallbackToSetInvisible(gActiveBattler); HideBattlerShadowSprite(gActiveBattler);
SetHealthboxSpriteInvisible(gHealthBoxesIds[gActiveBattler]); SetHealthboxSpriteInvisible(gHealthboxSpriteIds[gActiveBattler]);
OpponentBufferExecCompleted(); OpponentBufferExecCompleted();
} }
} }
@ -452,7 +452,7 @@ static void CompleteOnInactiveTextPrinter(void)
static void DoHitAnimBlinkSpriteEffect(void) static void DoHitAnimBlinkSpriteEffect(void)
{ {
u8 spriteId = gBankSpriteIds[gActiveBattler]; u8 spriteId = gBattlerSpriteIds[gActiveBattler];
if (gSprites[spriteId].data[1] == 32) if (gSprites[spriteId].data[1] == 32)
{ {
@ -471,11 +471,11 @@ static void DoHitAnimBlinkSpriteEffect(void)
static void sub_805FC10(void) static void sub_805FC10(void)
{ {
if (gSprites[gHealthBoxesIds[gActiveBattler]].callback == SpriteCallbackDummy) if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
{ {
if (gBattleSpritesDataPtr->bankData[gActiveBattler].behindSubstitute) if (gBattleSpritesDataPtr->bankData[gActiveBattler].behindSubstitute)
InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_MON_TO_SUBSTITUTE); InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_MON_TO_SUBSTITUTE);
gBattlerFuncs[gActiveBattler] = sub_805FC80; gBattlerControllerFuncs[gActiveBattler] = sub_805FC80;
} }
} }
@ -483,7 +483,7 @@ static void sub_805FC80(void)
{ {
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive && !IsCryPlayingOrClearCrySongs()) if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive && !IsCryPlayingOrClearCrySongs())
{ {
if (gSprites[gBankSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy || gSprites[gBankSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy_2) if (gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy || gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy_2)
{ {
m4aMPlayVolumeControl(&gMPlayInfo_BGM, 0xFFFF, 0x100); m4aMPlayVolumeControl(&gMPlayInfo_BGM, 0xFFFF, 0x100);
OpponentBufferExecCompleted(); OpponentBufferExecCompleted();
@ -493,32 +493,32 @@ static void sub_805FC80(void)
static void sub_805FD00(void) static void sub_805FD00(void)
{ {
if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x1 && gSprites[gBankSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy) if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x1 && gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
{ {
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].flag_x80 = 0; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].flag_x80 = 0;
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x1 = 0; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x1 = 0;
FreeSpriteTilesByTag(0x27F9); FreeSpriteTilesByTag(0x27F9);
FreeSpritePaletteByTag(0x27F9); FreeSpritePaletteByTag(0x27F9);
StartSpriteAnim(&gSprites[gBankSpriteIds[gActiveBattler]], 0); StartSpriteAnim(&gSprites[gBattlerSpriteIds[gActiveBattler]], 0);
UpdateHealthboxAttribute(gHealthBoxesIds[gActiveBattler], &gEnemyParty[gBattlePartyID[gActiveBattler]], HEALTHBOX_ALL); UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler], &gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], HEALTHBOX_ALL);
sub_8076918(gActiveBattler); sub_8076918(gActiveBattler);
SetHealthboxSpriteVisible(gHealthBoxesIds[gActiveBattler]); SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]);
CopyBattleSpriteInvisibility(gActiveBattler); CopyBattleSpriteInvisibility(gActiveBattler);
gBattlerFuncs[gActiveBattler] = sub_805FC10; gBattlerControllerFuncs[gActiveBattler] = sub_805FC10;
} }
} }
static void sub_805FDF0(void) static void sub_805FDF0(void)
{ {
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].flag_x80 && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive) if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].flag_x80 && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive)
sub_8172EF0(gActiveBattler, &gEnemyParty[gBattlePartyID[gActiveBattler]]); sub_8172EF0(gActiveBattler, &gEnemyParty[gBattlerPartyIndexes[gActiveBattler]]);
if (gSprites[gUnknown_03005D7C[gActiveBattler]].callback == SpriteCallbackDummy if (gSprites[gUnknown_03005D7C[gActiveBattler]].callback == SpriteCallbackDummy
&& !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive) && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive)
{ {
DestroySprite(&gSprites[gUnknown_03005D7C[gActiveBattler]]); DestroySprite(&gSprites[gUnknown_03005D7C[gActiveBattler]]);
SetBankEnemyShadowSpriteCallback(gActiveBattler, GetMonData(&gEnemyParty[gBattlePartyID[gActiveBattler]], MON_DATA_SPECIES)); SetBattlerShadowSpriteCallback(gActiveBattler, GetMonData(&gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_SPECIES));
gBattlerFuncs[gActiveBattler] = sub_805FD00; gBattlerControllerFuncs[gActiveBattler] = sub_805FD00;
} }
} }
@ -536,7 +536,7 @@ static void CompleteOnFinishedBattleAnimation(void)
static void OpponentBufferExecCompleted(void) static void OpponentBufferExecCompleted(void)
{ {
gBattlerFuncs[gActiveBattler] = OpponentBufferRunCommand; gBattlerControllerFuncs[gActiveBattler] = OpponentBufferRunCommand;
if (gBattleTypeFlags & BATTLE_TYPE_LINK) if (gBattleTypeFlags & BATTLE_TYPE_LINK)
{ {
u8 playerId = GetMultiplayerId(); u8 playerId = GetMultiplayerId();
@ -546,7 +546,7 @@ static void OpponentBufferExecCompleted(void)
} }
else else
{ {
gBattleExecBuffer &= ~gBitTable[gActiveBattler]; gBattleControllerExecFlags &= ~gBitTable[gActiveBattler];
} }
} }
@ -559,7 +559,7 @@ static void OpponentHandleGetMonData(void)
if (gBattleBufferA[gActiveBattler][2] == 0) if (gBattleBufferA[gActiveBattler][2] == 0)
{ {
size += GetOpponentMonData(gBattlePartyID[gActiveBattler], monData); size += GetOpponentMonData(gBattlerPartyIndexes[gActiveBattler], monData);
} }
else else
{ {
@ -571,7 +571,7 @@ static void OpponentHandleGetMonData(void)
monToCheck >>= 1; monToCheck >>= 1;
} }
} }
EmitDataTransfer(1, size, monData); BtlController_EmitDataTransfer(1, size, monData);
OpponentBufferExecCompleted(); OpponentBufferExecCompleted();
} }
@ -884,14 +884,14 @@ static u32 GetOpponentMonData(u8 monId, u8 *dst)
static void OpponentHandleGetRawMonData(void) static void OpponentHandleGetRawMonData(void)
{ {
struct BattlePokemon battleMon; struct BattlePokemon battleMon;
u8 *src = (u8 *)&gEnemyParty[gBattlePartyID[gActiveBattler]] + gBattleBufferA[gActiveBattler][1]; u8 *src = (u8 *)&gEnemyParty[gBattlerPartyIndexes[gActiveBattler]] + gBattleBufferA[gActiveBattler][1];
u8 *dst = (u8 *)&battleMon + gBattleBufferA[gActiveBattler][1]; u8 *dst = (u8 *)&battleMon + gBattleBufferA[gActiveBattler][1];
u8 i; u8 i;
for (i = 0; i < gBattleBufferA[gActiveBattler][2]; i++) for (i = 0; i < gBattleBufferA[gActiveBattler][2]; i++)
dst[i] = src[i]; dst[i] = src[i];
EmitDataTransfer(1, gBattleBufferA[gActiveBattler][2], dst); BtlController_EmitDataTransfer(1, gBattleBufferA[gActiveBattler][2], dst);
OpponentBufferExecCompleted(); OpponentBufferExecCompleted();
} }
@ -902,7 +902,7 @@ static void OpponentHandleSetMonData(void)
if (gBattleBufferA[gActiveBattler][2] == 0) if (gBattleBufferA[gActiveBattler][2] == 0)
{ {
SetOpponentMonData(gBattlePartyID[gActiveBattler]); SetOpponentMonData(gBattlerPartyIndexes[gActiveBattler]);
} }
else else
{ {
@ -1135,7 +1135,7 @@ static void SetOpponentMonData(u8 monId)
static void OpponentHandleSetRawMonData(void) static void OpponentHandleSetRawMonData(void)
{ {
u8 *dst = (u8 *)&gEnemyParty[gBattlePartyID[gActiveBattler]] + gBattleBufferA[gActiveBattler][1]; u8 *dst = (u8 *)&gEnemyParty[gBattlerPartyIndexes[gActiveBattler]] + gBattleBufferA[gActiveBattler][1];
u8 i; u8 i;
for (i = 0; i < gBattleBufferA[gActiveBattler][2]; i++) for (i = 0; i < gBattleBufferA[gActiveBattler][2]; i++)
@ -1146,33 +1146,33 @@ static void OpponentHandleSetRawMonData(void)
static void OpponentHandleLoadMonSprite(void) static void OpponentHandleLoadMonSprite(void)
{ {
u16 species = GetMonData(&gEnemyParty[gBattlePartyID[gActiveBattler]], MON_DATA_SPECIES); u16 species = GetMonData(&gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_SPECIES);
BattleLoadOpponentMonSpriteGfx(&gEnemyParty[gBattlePartyID[gActiveBattler]], gActiveBattler); BattleLoadOpponentMonSpriteGfx(&gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler);
sub_806A068(species, GetBattlerPosition(gActiveBattler)); sub_806A068(species, GetBattlerPosition(gActiveBattler));
gBankSpriteIds[gActiveBattler] = CreateSprite(&gUnknown_0202499C, gBattlerSpriteIds[gActiveBattler] = CreateSprite(&gUnknown_0202499C,
GetBankCoord(gActiveBattler, 2), GetBattlerSpriteCoord(gActiveBattler, 2),
GetBankSpriteDefault_Y(gActiveBattler), GetBattlerSpriteDefault_Y(gActiveBattler),
sub_80A82E4(gActiveBattler)); sub_80A82E4(gActiveBattler));
gSprites[gBankSpriteIds[gActiveBattler]].pos2.x = -240; gSprites[gBattlerSpriteIds[gActiveBattler]].pos2.x = -240;
gSprites[gBankSpriteIds[gActiveBattler]].data[0] = gActiveBattler; gSprites[gBattlerSpriteIds[gActiveBattler]].data[0] = gActiveBattler;
gSprites[gBankSpriteIds[gActiveBattler]].data[2] = species; gSprites[gBattlerSpriteIds[gActiveBattler]].data[2] = species;
gSprites[gBankSpriteIds[gActiveBattler]].oam.paletteNum = gActiveBattler; gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = gActiveBattler;
StartSpriteAnim(&gSprites[gBankSpriteIds[gActiveBattler]], gBattleMonForms[gActiveBattler]); StartSpriteAnim(&gSprites[gBattlerSpriteIds[gActiveBattler]], gBattleMonForms[gActiveBattler]);
SetBankEnemyShadowSpriteCallback(gActiveBattler, GetMonData(&gEnemyParty[gBattlePartyID[gActiveBattler]], MON_DATA_SPECIES)); SetBattlerShadowSpriteCallback(gActiveBattler, GetMonData(&gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_SPECIES));
gBattlerFuncs[gActiveBattler] = sub_805F994; gBattlerControllerFuncs[gActiveBattler] = sub_805F994;
} }
static void OpponentHandleSwitchInAnim(void) static void OpponentHandleSwitchInAnim(void)
{ {
*(gBattleStruct->monToSwitchIntoId + gActiveBattler) = 6; *(gBattleStruct->monToSwitchIntoId + gActiveBattler) = 6;
gBattlePartyID[gActiveBattler] = gBattleBufferA[gActiveBattler][1]; gBattlerPartyIndexes[gActiveBattler] = gBattleBufferA[gActiveBattler][1];
sub_80613DC(gActiveBattler, gBattleBufferA[gActiveBattler][2]); sub_80613DC(gActiveBattler, gBattleBufferA[gActiveBattler][2]);
gBattlerFuncs[gActiveBattler] = sub_805FDF0; gBattlerControllerFuncs[gActiveBattler] = sub_805FDF0;
} }
static void sub_80613DC(u8 bank, bool8 dontClearSubstituteBit) static void sub_80613DC(u8 bank, bool8 dontClearSubstituteBit)
@ -1180,29 +1180,29 @@ static void sub_80613DC(u8 bank, bool8 dontClearSubstituteBit)
u16 species; u16 species;
ClearTemporarySpeciesSpriteData(bank, dontClearSubstituteBit); ClearTemporarySpeciesSpriteData(bank, dontClearSubstituteBit);
gBattlePartyID[bank] = gBattleBufferA[bank][1]; gBattlerPartyIndexes[bank] = gBattleBufferA[bank][1];
species = GetMonData(&gEnemyParty[gBattlePartyID[bank]], MON_DATA_SPECIES); species = GetMonData(&gEnemyParty[gBattlerPartyIndexes[bank]], MON_DATA_SPECIES);
gUnknown_03005D7C[bank] = CreateInvisibleSpriteWithCallback(sub_805D714); gUnknown_03005D7C[bank] = CreateInvisibleSpriteWithCallback(sub_805D714);
BattleLoadOpponentMonSpriteGfx(&gEnemyParty[gBattlePartyID[bank]], bank); BattleLoadOpponentMonSpriteGfx(&gEnemyParty[gBattlerPartyIndexes[bank]], bank);
sub_806A068(species, GetBattlerPosition(bank)); sub_806A068(species, GetBattlerPosition(bank));
gBankSpriteIds[bank] = CreateSprite(&gUnknown_0202499C, gBattlerSpriteIds[bank] = CreateSprite(&gUnknown_0202499C,
GetBankCoord(bank, 2), GetBattlerSpriteCoord(bank, 2),
GetBankSpriteDefault_Y(bank), GetBattlerSpriteDefault_Y(bank),
sub_80A82E4(bank)); sub_80A82E4(bank));
gSprites[gBankSpriteIds[bank]].data[0] = bank; gSprites[gBattlerSpriteIds[bank]].data[0] = bank;
gSprites[gBankSpriteIds[bank]].data[2] = species; gSprites[gBattlerSpriteIds[bank]].data[2] = species;
gSprites[gUnknown_03005D7C[bank]].data[1] = gBankSpriteIds[bank]; gSprites[gUnknown_03005D7C[bank]].data[1] = gBattlerSpriteIds[bank];
gSprites[gUnknown_03005D7C[bank]].data[2] = bank; gSprites[gUnknown_03005D7C[bank]].data[2] = bank;
gSprites[gBankSpriteIds[bank]].oam.paletteNum = bank; gSprites[gBattlerSpriteIds[bank]].oam.paletteNum = bank;
StartSpriteAnim(&gSprites[gBankSpriteIds[bank]], gBattleMonForms[bank]); StartSpriteAnim(&gSprites[gBattlerSpriteIds[bank]], gBattleMonForms[bank]);
gSprites[gBankSpriteIds[bank]].invisible = TRUE; gSprites[gBattlerSpriteIds[bank]].invisible = TRUE;
gSprites[gBankSpriteIds[bank]].callback = SpriteCallbackDummy; gSprites[gBattlerSpriteIds[bank]].callback = SpriteCallbackDummy;
gSprites[gUnknown_03005D7C[bank]].data[0] = DoPokeballSendOutAnimation(0, POKEBALL_OPPONENT_SENDOUT); gSprites[gUnknown_03005D7C[bank]].data[0] = DoPokeballSendOutAnimation(0, POKEBALL_OPPONENT_SENDOUT);
} }
@ -1212,14 +1212,14 @@ static void OpponentHandleReturnMonToBall(void)
if (gBattleBufferA[gActiveBattler][1] == 0) if (gBattleBufferA[gActiveBattler][1] == 0)
{ {
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0;
gBattlerFuncs[gActiveBattler] = DoSwitchOutAnimation; gBattlerControllerFuncs[gActiveBattler] = DoSwitchOutAnimation;
} }
else else
{ {
FreeSpriteOamMatrix(&gSprites[gBankSpriteIds[gActiveBattler]]); FreeSpriteOamMatrix(&gSprites[gBattlerSpriteIds[gActiveBattler]]);
DestroySprite(&gSprites[gBankSpriteIds[gActiveBattler]]); DestroySprite(&gSprites[gBattlerSpriteIds[gActiveBattler]]);
EnemyShadowCallbackToSetInvisible(gActiveBattler); HideBattlerShadowSprite(gActiveBattler);
SetHealthboxSpriteInvisible(gHealthBoxesIds[gActiveBattler]); SetHealthboxSpriteInvisible(gHealthboxSpriteIds[gActiveBattler]);
OpponentBufferExecCompleted(); OpponentBufferExecCompleted();
} }
} }
@ -1239,7 +1239,7 @@ static void DoSwitchOutAnimation(void)
{ {
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0;
InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SWITCH_OUT_OPPONENT_MON); InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SWITCH_OUT_OPPONENT_MON);
gBattlerFuncs[gActiveBattler] = sub_805FB08; gBattlerControllerFuncs[gActiveBattler] = sub_805FB08;
} }
break; break;
} }
@ -1316,18 +1316,18 @@ static void OpponentHandleDrawTrainerPic(void)
DecompressTrainerFrontPic(trainerPicId, gActiveBattler); DecompressTrainerFrontPic(trainerPicId, gActiveBattler);
sub_806A12C(trainerPicId, GetBattlerPosition(gActiveBattler)); sub_806A12C(trainerPicId, GetBattlerPosition(gActiveBattler));
gBankSpriteIds[gActiveBattler] = CreateSprite(&gUnknown_0202499C, gBattlerSpriteIds[gActiveBattler] = CreateSprite(&gUnknown_0202499C,
xPos, xPos,
(8 - gTrainerFrontPicCoords[trainerPicId].coords) * 4 + 40, (8 - gTrainerFrontPicCoords[trainerPicId].coords) * 4 + 40,
sub_80A82E4(gActiveBattler)); sub_80A82E4(gActiveBattler));
gSprites[gBankSpriteIds[gActiveBattler]].pos2.x = -240; gSprites[gBattlerSpriteIds[gActiveBattler]].pos2.x = -240;
gSprites[gBankSpriteIds[gActiveBattler]].data[0] = 2; gSprites[gBattlerSpriteIds[gActiveBattler]].data[0] = 2;
gSprites[gBankSpriteIds[gActiveBattler]].oam.paletteNum = IndexOfSpritePaletteTag(gTrainerFrontPicPaletteTable[trainerPicId].tag); gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = IndexOfSpritePaletteTag(gTrainerFrontPicPaletteTable[trainerPicId].tag);
gSprites[gBankSpriteIds[gActiveBattler]].oam.affineParam = trainerPicId; gSprites[gBattlerSpriteIds[gActiveBattler]].oam.affineParam = trainerPicId;
gSprites[gBankSpriteIds[gActiveBattler]].callback = sub_805D7AC; gSprites[gBattlerSpriteIds[gActiveBattler]].callback = sub_805D7AC;
gBattlerFuncs[gActiveBattler] = CompleteOnBankSpriteCallbackDummy; gBattlerControllerFuncs[gActiveBattler] = CompleteOnBankSpriteCallbackDummy;
} }
static void OpponentHandleTrainerSlide(void) static void OpponentHandleTrainerSlide(void)
@ -1388,27 +1388,27 @@ static void OpponentHandleTrainerSlide(void)
DecompressTrainerFrontPic(trainerPicId, gActiveBattler); DecompressTrainerFrontPic(trainerPicId, gActiveBattler);
sub_806A12C(trainerPicId, GetBattlerPosition(gActiveBattler)); sub_806A12C(trainerPicId, GetBattlerPosition(gActiveBattler));
gBankSpriteIds[gActiveBattler] = CreateSprite(&gUnknown_0202499C, 176, (8 - gTrainerFrontPicCoords[trainerPicId].coords) * 4 + 40, 0x1E); gBattlerSpriteIds[gActiveBattler] = CreateSprite(&gUnknown_0202499C, 176, (8 - gTrainerFrontPicCoords[trainerPicId].coords) * 4 + 40, 0x1E);
gSprites[gBankSpriteIds[gActiveBattler]].pos2.x = 96; gSprites[gBattlerSpriteIds[gActiveBattler]].pos2.x = 96;
gSprites[gBankSpriteIds[gActiveBattler]].pos1.x += 32; gSprites[gBattlerSpriteIds[gActiveBattler]].pos1.x += 32;
gSprites[gBankSpriteIds[gActiveBattler]].data[0] = -2; gSprites[gBattlerSpriteIds[gActiveBattler]].data[0] = -2;
gSprites[gBankSpriteIds[gActiveBattler]].oam.paletteNum = IndexOfSpritePaletteTag(gTrainerFrontPicPaletteTable[trainerPicId].tag); gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = IndexOfSpritePaletteTag(gTrainerFrontPicPaletteTable[trainerPicId].tag);
gSprites[gBankSpriteIds[gActiveBattler]].oam.affineParam = trainerPicId; gSprites[gBattlerSpriteIds[gActiveBattler]].oam.affineParam = trainerPicId;
gSprites[gBankSpriteIds[gActiveBattler]].callback = sub_805D7AC; gSprites[gBattlerSpriteIds[gActiveBattler]].callback = sub_805D7AC;
gBattlerFuncs[gActiveBattler] = CompleteOnBankSpriteCallbackDummy2; gBattlerControllerFuncs[gActiveBattler] = CompleteOnBankSpriteCallbackDummy2;
} }
static void OpponentHandleTrainerSlideBack(void) static void OpponentHandleTrainerSlideBack(void)
{ {
oamt_add_pos2_onto_pos1(&gSprites[gBankSpriteIds[gActiveBattler]]); oamt_add_pos2_onto_pos1(&gSprites[gBattlerSpriteIds[gActiveBattler]]);
gSprites[gBankSpriteIds[gActiveBattler]].data[0] = 35; gSprites[gBattlerSpriteIds[gActiveBattler]].data[0] = 35;
gSprites[gBankSpriteIds[gActiveBattler]].data[2] = 280; gSprites[gBattlerSpriteIds[gActiveBattler]].data[2] = 280;
gSprites[gBankSpriteIds[gActiveBattler]].data[4] = gSprites[gBankSpriteIds[gActiveBattler]].pos1.y; gSprites[gBattlerSpriteIds[gActiveBattler]].data[4] = gSprites[gBattlerSpriteIds[gActiveBattler]].pos1.y;
gSprites[gBankSpriteIds[gActiveBattler]].callback = sub_80A6EEC; gSprites[gBattlerSpriteIds[gActiveBattler]].callback = sub_80A6EEC;
StoreSpriteCallbackInData6(&gSprites[gBankSpriteIds[gActiveBattler]], SpriteCallbackDummy); StoreSpriteCallbackInData6(&gSprites[gBattlerSpriteIds[gActiveBattler]], SpriteCallbackDummy);
gBattlerFuncs[gActiveBattler] = sub_805F240; gBattlerControllerFuncs[gActiveBattler] = sub_805F240;
} }
static void OpponentHandleFaintAnimation(void) static void OpponentHandleFaintAnimation(void)
@ -1425,8 +1425,8 @@ static void OpponentHandleFaintAnimation(void)
{ {
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0;
PlaySE12WithPanning(SE_POKE_DEAD, PAN_SIDE_OPPONENT); PlaySE12WithPanning(SE_POKE_DEAD, PAN_SIDE_OPPONENT);
gSprites[gBankSpriteIds[gActiveBattler]].callback = sub_8039934; gSprites[gBattlerSpriteIds[gActiveBattler]].callback = sub_8039934;
gBattlerFuncs[gActiveBattler] = sub_805FAC4; gBattlerControllerFuncs[gActiveBattler] = sub_805FAC4;
} }
} }
} }
@ -1471,7 +1471,7 @@ static void OpponentHandleMoveAnimation(void)
else else
{ {
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0;
gBattlerFuncs[gActiveBattler] = OpponentDoMoveAnimation; gBattlerControllerFuncs[gActiveBattler] = OpponentDoMoveAnimation;
} }
} }
} }
@ -1534,7 +1534,7 @@ static void OpponentHandlePrintString(void)
stringId = (u16*)(&gBattleBufferA[gActiveBattler][2]); stringId = (u16*)(&gBattleBufferA[gActiveBattler][2]);
BufferStringBattle(*stringId); BufferStringBattle(*stringId);
BattleHandleAddTextPrinter(gDisplayedStringBattle, 0); BattleHandleAddTextPrinter(gDisplayedStringBattle, 0);
gBattlerFuncs[gActiveBattler] = CompleteOnInactiveTextPrinter; gBattlerControllerFuncs[gActiveBattler] = CompleteOnInactiveTextPrinter;
sub_81A57E4(gActiveBattler, *stringId); sub_81A57E4(gActiveBattler, *stringId);
} }
@ -1558,7 +1558,7 @@ static void OpponentHandleChooseMove(void)
{ {
if (gBattleTypeFlags & BATTLE_TYPE_PALACE) if (gBattleTypeFlags & BATTLE_TYPE_PALACE)
{ {
EmitTwoReturnValues(1, 10, ChooseMoveAndTargetInBattlePalace()); BtlController_EmitTwoReturnValues(1, 10, ChooseMoveAndTargetInBattlePalace());
OpponentBufferExecCompleted(); OpponentBufferExecCompleted();
} }
else else
@ -1575,24 +1575,24 @@ static void OpponentHandleChooseMove(void)
switch (chosenMoveId) switch (chosenMoveId)
{ {
case 5: case 5:
EmitTwoReturnValues(1, ACTION_WATCHES_CAREFULLY, 0); BtlController_EmitTwoReturnValues(1, ACTION_WATCHES_CAREFULLY, 0);
break; break;
case 4: case 4:
EmitTwoReturnValues(1, ACTION_RUN, 0); BtlController_EmitTwoReturnValues(1, ACTION_RUN, 0);
break; break;
case 6: case 6:
EmitTwoReturnValues(1, 15, gBattleDefender); BtlController_EmitTwoReturnValues(1, 15, gBattleMoveTarget);
break; break;
default: default:
if (gBattleMoves[moveInfo->moves[chosenMoveId]].target & (MOVE_TARGET_USER | MOVE_TARGET_x10)) if (gBattleMoves[moveInfo->moves[chosenMoveId]].target & (MOVE_TARGET_USER | MOVE_TARGET_x10))
gBattleDefender = gActiveBattler; gBattleMoveTarget = gActiveBattler;
if (gBattleMoves[moveInfo->moves[chosenMoveId]].target & MOVE_TARGET_BOTH) if (gBattleMoves[moveInfo->moves[chosenMoveId]].target & MOVE_TARGET_BOTH)
{ {
gBattleDefender = GetBattlerAtPosition(B_POSITION_PLAYER_LEFT); gBattleMoveTarget = GetBattlerAtPosition(B_POSITION_PLAYER_LEFT);
if (gAbsentBattlerFlags & gBitTable[gBattleDefender]) if (gAbsentBattlerFlags & gBitTable[gBattleMoveTarget])
gBattleDefender = GetBattlerAtPosition(B_POSITION_PLAYER_RIGHT); gBattleMoveTarget = GetBattlerAtPosition(B_POSITION_PLAYER_RIGHT);
} }
EmitTwoReturnValues(1, 10, (chosenMoveId) | (gBattleDefender << 8)); BtlController_EmitTwoReturnValues(1, 10, (chosenMoveId) | (gBattleMoveTarget << 8));
break; break;
} }
OpponentBufferExecCompleted(); OpponentBufferExecCompleted();
@ -1607,11 +1607,11 @@ static void OpponentHandleChooseMove(void)
} while (move == MOVE_NONE); } while (move == MOVE_NONE);
if (gBattleMoves[move].target & (MOVE_TARGET_USER | MOVE_TARGET_x10)) if (gBattleMoves[move].target & (MOVE_TARGET_USER | MOVE_TARGET_x10))
EmitTwoReturnValues(1, 10, (chosenMoveId) | (gActiveBattler << 8)); BtlController_EmitTwoReturnValues(1, 10, (chosenMoveId) | (gActiveBattler << 8));
else if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE) else if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE)
EmitTwoReturnValues(1, 10, (chosenMoveId) | (GetBattlerAtPosition(Random() & 2) << 8)); BtlController_EmitTwoReturnValues(1, 10, (chosenMoveId) | (GetBattlerAtPosition(Random() & 2) << 8));
else else
EmitTwoReturnValues(1, 10, (chosenMoveId) | (GetBattlerAtPosition(B_POSITION_PLAYER_LEFT) << 8)); BtlController_EmitTwoReturnValues(1, 10, (chosenMoveId) | (GetBattlerAtPosition(B_POSITION_PLAYER_LEFT) << 8));
OpponentBufferExecCompleted(); OpponentBufferExecCompleted();
} }
@ -1620,7 +1620,7 @@ static void OpponentHandleChooseMove(void)
static void OpponentHandleChooseItem(void) static void OpponentHandleChooseItem(void)
{ {
EmitOneReturnValue(1, *(gBattleStruct->chosenItem + (gActiveBattler / 2) * 2)); BtlController_EmitOneReturnValue(1, *(gBattleStruct->chosenItem + (gActiveBattler / 2) * 2));
OpponentBufferExecCompleted(); OpponentBufferExecCompleted();
} }
@ -1661,8 +1661,8 @@ static void OpponentHandleChoosePokemon(void)
for (chosenMonId = firstId; chosenMonId < lastId; chosenMonId++) for (chosenMonId = firstId; chosenMonId < lastId; chosenMonId++)
{ {
if (GetMonData(&gEnemyParty[chosenMonId], MON_DATA_HP) != 0 if (GetMonData(&gEnemyParty[chosenMonId], MON_DATA_HP) != 0
&& chosenMonId != gBattlePartyID[bank1] && chosenMonId != gBattlerPartyIndexes[bank1]
&& chosenMonId != gBattlePartyID[bank2]) && chosenMonId != gBattlerPartyIndexes[bank2])
{ {
break; break;
} }
@ -1677,7 +1677,7 @@ static void OpponentHandleChoosePokemon(void)
*(gBattleStruct->monToSwitchIntoId + gActiveBattler) = chosenMonId; *(gBattleStruct->monToSwitchIntoId + gActiveBattler) = chosenMonId;
EmitChosenMonReturnValue(1, chosenMonId, NULL); BtlController_EmitChosenMonReturnValue(1, chosenMonId, NULL);
OpponentBufferExecCompleted(); OpponentBufferExecCompleted();
} }
@ -1695,19 +1695,19 @@ static void OpponentHandleHealthBarUpdate(void)
if (hpVal != INSTANT_HP_BAR_DROP) if (hpVal != INSTANT_HP_BAR_DROP)
{ {
u32 maxHP = GetMonData(&gEnemyParty[gBattlePartyID[gActiveBattler]], MON_DATA_MAX_HP); u32 maxHP = GetMonData(&gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_MAX_HP);
u32 curHP = GetMonData(&gEnemyParty[gBattlePartyID[gActiveBattler]], MON_DATA_HP); u32 curHP = GetMonData(&gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_HP);
SetBattleBarStruct(gActiveBattler, gHealthBoxesIds[gActiveBattler], maxHP, curHP, hpVal); SetBattleBarStruct(gActiveBattler, gHealthboxSpriteIds[gActiveBattler], maxHP, curHP, hpVal);
} }
else else
{ {
u32 maxHP = GetMonData(&gEnemyParty[gBattlePartyID[gActiveBattler]], MON_DATA_MAX_HP); u32 maxHP = GetMonData(&gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_MAX_HP);
SetBattleBarStruct(gActiveBattler, gHealthBoxesIds[gActiveBattler], maxHP, 0, hpVal); SetBattleBarStruct(gActiveBattler, gHealthboxSpriteIds[gActiveBattler], maxHP, 0, hpVal);
} }
gBattlerFuncs[gActiveBattler] = CompleteOnHealthbarDone; gBattlerControllerFuncs[gActiveBattler] = CompleteOnHealthbarDone;
} }
static void OpponentHandleExpUpdate(void) static void OpponentHandleExpUpdate(void)
@ -1721,10 +1721,10 @@ static void OpponentHandleStatusIconUpdate(void)
{ {
u8 bank; u8 bank;
UpdateHealthboxAttribute(gHealthBoxesIds[gActiveBattler], &gEnemyParty[gBattlePartyID[gActiveBattler]], HEALTHBOX_STATUS_ICON); UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler], &gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], HEALTHBOX_STATUS_ICON);
bank = gActiveBattler; bank = gActiveBattler;
gBattleSpritesDataPtr->healthBoxesData[bank].statusAnimActive = 0; gBattleSpritesDataPtr->healthBoxesData[bank].statusAnimActive = 0;
gBattlerFuncs[gActiveBattler] = CompleteOnFinishedStatusAnimation; gBattlerControllerFuncs[gActiveBattler] = CompleteOnFinishedStatusAnimation;
} }
} }
@ -1734,7 +1734,7 @@ static void OpponentHandleStatusAnimation(void)
{ {
InitAndLaunchChosenStatusAnimation(gBattleBufferA[gActiveBattler][1], InitAndLaunchChosenStatusAnimation(gBattleBufferA[gActiveBattler][1],
gBattleBufferA[gActiveBattler][2] | (gBattleBufferA[gActiveBattler][3] << 8) | (gBattleBufferA[gActiveBattler][4] << 16) | (gBattleBufferA[gActiveBattler][5] << 24)); gBattleBufferA[gActiveBattler][2] | (gBattleBufferA[gActiveBattler][3] << 8) | (gBattleBufferA[gActiveBattler][4] << 16) | (gBattleBufferA[gActiveBattler][5] << 24));
gBattlerFuncs[gActiveBattler] = CompleteOnFinishedStatusAnimation; gBattlerControllerFuncs[gActiveBattler] = CompleteOnFinishedStatusAnimation;
} }
} }
@ -1809,16 +1809,16 @@ static void OpponentHandleCmd40(void)
static void OpponentHandleHitAnimation(void) static void OpponentHandleHitAnimation(void)
{ {
if (gSprites[gBankSpriteIds[gActiveBattler]].invisible == TRUE) if (gSprites[gBattlerSpriteIds[gActiveBattler]].invisible == TRUE)
{ {
OpponentBufferExecCompleted(); OpponentBufferExecCompleted();
} }
else else
{ {
gDoingBattleAnim = TRUE; gDoingBattleAnim = TRUE;
gSprites[gBankSpriteIds[gActiveBattler]].data[1] = 0; gSprites[gBattlerSpriteIds[gActiveBattler]].data[1] = 0;
DoHitAnimHealthboxEffect(gActiveBattler); DoHitAnimHealthboxEffect(gActiveBattler);
gBattlerFuncs[gActiveBattler] = DoHitAnimBlinkSpriteEffect; gBattlerControllerFuncs[gActiveBattler] = DoHitAnimBlinkSpriteEffect;
} }
} }
@ -1857,7 +1857,7 @@ static void OpponentHandlePlayFanfareOrBGM(void)
static void OpponentHandleFaintingCry(void) static void OpponentHandleFaintingCry(void)
{ {
u16 species = GetMonData(&gEnemyParty[gBattlePartyID[gActiveBattler]], MON_DATA_SPECIES); u16 species = GetMonData(&gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_SPECIES);
PlayCry3(species, 25, 5); PlayCry3(species, 25, 5);
OpponentBufferExecCompleted(); OpponentBufferExecCompleted();
@ -1875,14 +1875,14 @@ static void OpponentHandleIntroTrainerBallThrow(void)
u8 paletteNum; u8 paletteNum;
u8 taskId; u8 taskId;
oamt_add_pos2_onto_pos1(&gSprites[gBankSpriteIds[gActiveBattler]]); oamt_add_pos2_onto_pos1(&gSprites[gBattlerSpriteIds[gActiveBattler]]);
gSprites[gBankSpriteIds[gActiveBattler]].data[0] = 35; gSprites[gBattlerSpriteIds[gActiveBattler]].data[0] = 35;
gSprites[gBankSpriteIds[gActiveBattler]].data[2] = 280; gSprites[gBattlerSpriteIds[gActiveBattler]].data[2] = 280;
gSprites[gBankSpriteIds[gActiveBattler]].data[4] = gSprites[gBankSpriteIds[gActiveBattler]].pos1.y; gSprites[gBattlerSpriteIds[gActiveBattler]].data[4] = gSprites[gBattlerSpriteIds[gActiveBattler]].pos1.y;
gSprites[gBankSpriteIds[gActiveBattler]].callback = sub_80A6EEC; gSprites[gBattlerSpriteIds[gActiveBattler]].callback = sub_80A6EEC;
StoreSpriteCallbackInData6(&gSprites[gBankSpriteIds[gActiveBattler]], sub_806280C); StoreSpriteCallbackInData6(&gSprites[gBattlerSpriteIds[gActiveBattler]], sub_806280C);
taskId = CreateTask(sub_8062828, 5); taskId = CreateTask(sub_8062828, 5);
gTasks[taskId].data[0] = gActiveBattler; gTasks[taskId].data[0] = gActiveBattler;
@ -1891,7 +1891,7 @@ static void OpponentHandleIntroTrainerBallThrow(void)
gTasks[gUnknown_020244B4[gActiveBattler]].func = sub_8073C30; gTasks[gUnknown_020244B4[gActiveBattler]].func = sub_8073C30;
gBattleSpritesDataPtr->animationData->field_9_x1 = 1; gBattleSpritesDataPtr->animationData->field_9_x1 = 1;
gBattlerFuncs[gActiveBattler] = nullsub_26; gBattlerControllerFuncs[gActiveBattler] = nullsub_26;
} }
static void sub_806280C(struct Sprite *sprite) static void sub_806280C(struct Sprite *sprite)
@ -1908,24 +1908,24 @@ static void sub_8062828(u8 taskId)
gActiveBattler = gTasks[taskId].data[0]; gActiveBattler = gTasks[taskId].data[0];
if (!IsDoubleBattle() || (gBattleTypeFlags & BATTLE_TYPE_MULTI)) if (!IsDoubleBattle() || (gBattleTypeFlags & BATTLE_TYPE_MULTI))
{ {
gBattleBufferA[gActiveBattler][1] = gBattlePartyID[gActiveBattler]; gBattleBufferA[gActiveBattler][1] = gBattlerPartyIndexes[gActiveBattler];
sub_80613DC(gActiveBattler, FALSE); sub_80613DC(gActiveBattler, FALSE);
} }
else if ((gBattleTypeFlags & BATTLE_TYPE_TWO_OPPONENTS)) else if ((gBattleTypeFlags & BATTLE_TYPE_TWO_OPPONENTS))
{ {
gBattleBufferA[gActiveBattler][1] = gBattlePartyID[gActiveBattler]; gBattleBufferA[gActiveBattler][1] = gBattlerPartyIndexes[gActiveBattler];
sub_80613DC(gActiveBattler, FALSE); sub_80613DC(gActiveBattler, FALSE);
} }
else else
{ {
gBattleBufferA[gActiveBattler][1] = gBattlePartyID[gActiveBattler]; gBattleBufferA[gActiveBattler][1] = gBattlerPartyIndexes[gActiveBattler];
sub_80613DC(gActiveBattler, FALSE); sub_80613DC(gActiveBattler, FALSE);
gActiveBattler ^= BIT_FLANK; gActiveBattler ^= BIT_FLANK;
gBattleBufferA[gActiveBattler][1] = gBattlePartyID[gActiveBattler]; gBattleBufferA[gActiveBattler][1] = gBattlerPartyIndexes[gActiveBattler];
sub_80613DC(gActiveBattler, FALSE); sub_80613DC(gActiveBattler, FALSE);
gActiveBattler ^= BIT_FLANK; gActiveBattler ^= BIT_FLANK;
} }
gBattlerFuncs[gActiveBattler] = sub_805F560; gBattlerControllerFuncs[gActiveBattler] = sub_805F560;
gActiveBattler = savedActiveBank; gActiveBattler = savedActiveBank;
DestroyTask(taskId); DestroyTask(taskId);
} }
@ -1959,7 +1959,7 @@ static void OpponentHandleDrawPartyStatusSummary(void)
if (gBattleBufferA[gActiveBattler][2] != 0) if (gBattleBufferA[gActiveBattler][2] != 0)
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_5 = 0x5D; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_5 = 0x5D;
gBattlerFuncs[gActiveBattler] = sub_8062A2C; gBattlerControllerFuncs[gActiveBattler] = sub_8062A2C;
} }
} }
@ -1986,9 +1986,9 @@ static void OpponentHandleCmd50(void)
static void OpponentHandleSpriteInvisibility(void) static void OpponentHandleSpriteInvisibility(void)
{ {
if (IsBankSpritePresent(gActiveBattler)) if (IsBattlerSpritePresent(gActiveBattler))
{ {
gSprites[gBankSpriteIds[gActiveBattler]].invisible = gBattleBufferA[gActiveBattler][1]; gSprites[gBattlerSpriteIds[gActiveBattler]].invisible = gBattleBufferA[gActiveBattler][1];
CopyBattleSpriteInvisibility(gActiveBattler); CopyBattleSpriteInvisibility(gActiveBattler);
} }
OpponentBufferExecCompleted(); OpponentBufferExecCompleted();
@ -2004,7 +2004,7 @@ static void OpponentHandleBattleAnimation(void)
if (TryHandleLaunchBattleTableAnimation(gActiveBattler, gActiveBattler, gActiveBattler, animationId, argument)) if (TryHandleLaunchBattleTableAnimation(gActiveBattler, gActiveBattler, gActiveBattler, animationId, argument))
OpponentBufferExecCompleted(); OpponentBufferExecCompleted();
else else
gBattlerFuncs[gActiveBattler] = CompleteOnFinishedBattleAnimation; gBattlerControllerFuncs[gActiveBattler] = CompleteOnFinishedBattleAnimation;
} }
} }

File diff suppressed because it is too large Load Diff

View File

@ -23,21 +23,21 @@
#include "pokeball.h" #include "pokeball.h"
#include "data2.h" #include "data2.h"
extern u32 gBattleExecBuffer; extern u32 gBattleControllerExecFlags;
extern u8 gActiveBattler; extern u8 gActiveBattler;
extern u8 gBankSpriteIds[MAX_BATTLERS_COUNT]; extern u8 gBattlerSpriteIds[MAX_BATTLERS_COUNT];
extern u8 gActionSelectionCursor[MAX_BATTLERS_COUNT]; extern u8 gActionSelectionCursor[MAX_BATTLERS_COUNT];
extern u8 gBattlersCount; extern u8 gBattlersCount;
extern bool8 gDoingBattleAnim; extern bool8 gDoingBattleAnim;
extern void (*gBattlerFuncs[MAX_BATTLERS_COUNT])(void); extern void (*gBattlerControllerFuncs[MAX_BATTLERS_COUNT])(void);
extern void (*gPreBattleCallback1)(void); extern void (*gPreBattleCallback1)(void);
extern u16 gBattlePartyID[MAX_BATTLERS_COUNT]; extern u16 gBattlerPartyIndexes[MAX_BATTLERS_COUNT];
extern u8 gBattleBufferA[MAX_BATTLERS_COUNT][0x200]; extern u8 gBattleBufferA[MAX_BATTLERS_COUNT][0x200];
extern u8 gBattleBufferB[MAX_BATTLERS_COUNT][0x200]; extern u8 gBattleBufferB[MAX_BATTLERS_COUNT][0x200];
extern struct BattlePokemon gBattleMons[MAX_BATTLERS_COUNT]; extern struct BattlePokemon gBattleMons[MAX_BATTLERS_COUNT];
extern struct SpriteTemplate gUnknown_0202499C; extern struct SpriteTemplate gUnknown_0202499C;
extern u16 gSpecialVar_ItemId; extern u16 gSpecialVar_ItemId;
extern u8 gHealthBoxesIds[MAX_BATTLERS_COUNT]; extern u8 gHealthboxSpriteIds[MAX_BATTLERS_COUNT];
extern u8 gBattleOutcome; extern u8 gBattleOutcome;
extern u16 gBattle_BG0_X; extern u16 gBattle_BG0_X;
extern u16 gBattle_BG0_Y; extern u16 gBattle_BG0_Y;
@ -47,7 +47,7 @@ extern u8 gUnknown_03005D7C[MAX_BATTLERS_COUNT];
extern u8 gBattleMonForms[MAX_BATTLERS_COUNT]; extern u8 gBattleMonForms[MAX_BATTLERS_COUNT];
extern u16 gPartnerTrainerId; extern u16 gPartnerTrainerId;
extern u8 GetFrontierTrainerFrontSpriteId(u16 trainerId); extern u8 GetFrontierTrainerFrontSpriteId(u16 trainerId);
extern u8 gBattleDefender; extern u8 gBattleMoveTarget;
extern u8 gAbsentBattlerFlags; extern u8 gAbsentBattlerFlags;
extern u8 gUnknown_020244B4[]; extern u8 gUnknown_020244B4[];
extern u32 gTransformedPersonalities[MAX_BATTLERS_COUNT]; extern u32 gTransformedPersonalities[MAX_BATTLERS_COUNT];
@ -213,12 +213,12 @@ static void nullsub_77(void)
void SetControllerToPlayerPartner(void) void SetControllerToPlayerPartner(void)
{ {
gBattlerFuncs[gActiveBattler] = PlayerPartnerBufferRunCommand; gBattlerControllerFuncs[gActiveBattler] = PlayerPartnerBufferRunCommand;
} }
static void PlayerPartnerBufferRunCommand(void) static void PlayerPartnerBufferRunCommand(void)
{ {
if (gBattleExecBuffer & gBitTable[gActiveBattler]) if (gBattleControllerExecFlags & gBitTable[gActiveBattler])
{ {
if (gBattleBufferA[gActiveBattler][0] < ARRAY_COUNT(sPlayerPartnerBufferCommands)) if (gBattleBufferA[gActiveBattler][0] < ARRAY_COUNT(sPlayerPartnerBufferCommands))
sPlayerPartnerBufferCommands[gBattleBufferA[gActiveBattler][0]](); sPlayerPartnerBufferCommands[gBattleBufferA[gActiveBattler][0]]();
@ -229,17 +229,17 @@ static void PlayerPartnerBufferRunCommand(void)
static void CompleteOnBankSpriteCallbackDummy(void) static void CompleteOnBankSpriteCallbackDummy(void)
{ {
if (gSprites[gBankSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy) if (gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
PlayerPartnerBufferExecCompleted(); PlayerPartnerBufferExecCompleted();
} }
static void sub_81BAE98(void) static void sub_81BAE98(void)
{ {
if (gSprites[gBankSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy) if (gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
{ {
nullsub_25(0); nullsub_25(0);
FreeSpriteOamMatrix(&gSprites[gBankSpriteIds[gActiveBattler]]); FreeSpriteOamMatrix(&gSprites[gBattlerSpriteIds[gActiveBattler]]);
DestroySprite(&gSprites[gBankSpriteIds[gActiveBattler]]); DestroySprite(&gSprites[gBattlerSpriteIds[gActiveBattler]]);
PlayerPartnerBufferExecCompleted(); PlayerPartnerBufferExecCompleted();
} }
} }
@ -259,13 +259,13 @@ static void sub_81BAF48(void)
if (!IsDoubleBattle() || (IsDoubleBattle() && (gBattleTypeFlags & BATTLE_TYPE_MULTI))) if (!IsDoubleBattle() || (IsDoubleBattle() && (gBattleTypeFlags & BATTLE_TYPE_MULTI)))
{ {
if (gSprites[gHealthBoxesIds[gActiveBattler]].callback == SpriteCallbackDummy) if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
r6 = TRUE; r6 = TRUE;
} }
else else
{ {
if (gSprites[gHealthBoxesIds[gActiveBattler]].callback == SpriteCallbackDummy if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy
&& gSprites[gHealthBoxesIds[gActiveBattler ^ BIT_FLANK]].callback == SpriteCallbackDummy) && gSprites[gHealthboxSpriteIds[gActiveBattler ^ BIT_FLANK]].callback == SpriteCallbackDummy)
{ {
r6 = TRUE; r6 = TRUE;
} }
@ -277,7 +277,7 @@ static void sub_81BAF48(void)
if (r6) if (r6)
{ {
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_9 = 3; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_9 = 3;
gBattlerFuncs[gActiveBattler] = sub_81BAF00; gBattlerControllerFuncs[gActiveBattler] = sub_81BAF00;
} }
} }
@ -286,7 +286,7 @@ static void sub_81BB02C(void)
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive
&& !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].ballAnimActive && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].ballAnimActive
&& gSprites[gUnknown_03005D7C[gActiveBattler]].callback == SpriteCallbackDummy && gSprites[gUnknown_03005D7C[gActiveBattler]].callback == SpriteCallbackDummy
&& gSprites[gBankSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy && gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy
&& ++gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_9 != 1) && ++gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_9 != 1)
{ {
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_9 = 0; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_9 = 0;
@ -294,41 +294,41 @@ static void sub_81BB02C(void)
if (IsDoubleBattle() && !(gBattleTypeFlags & BATTLE_TYPE_MULTI)) if (IsDoubleBattle() && !(gBattleTypeFlags & BATTLE_TYPE_MULTI))
{ {
DestroySprite(&gSprites[gUnknown_03005D7C[gActiveBattler ^ BIT_FLANK]]); DestroySprite(&gSprites[gUnknown_03005D7C[gActiveBattler ^ BIT_FLANK]]);
UpdateHealthboxAttribute(gHealthBoxesIds[gActiveBattler ^ BIT_FLANK], &gPlayerParty[gBattlePartyID[gActiveBattler ^ BIT_FLANK]], HEALTHBOX_ALL); UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler ^ BIT_FLANK], &gPlayerParty[gBattlerPartyIndexes[gActiveBattler ^ BIT_FLANK]], HEALTHBOX_ALL);
sub_8076918(gActiveBattler ^ BIT_FLANK); sub_8076918(gActiveBattler ^ BIT_FLANK);
SetHealthboxSpriteVisible(gHealthBoxesIds[gActiveBattler ^ BIT_FLANK]); SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler ^ BIT_FLANK]);
} }
DestroySprite(&gSprites[gUnknown_03005D7C[gActiveBattler]]); DestroySprite(&gSprites[gUnknown_03005D7C[gActiveBattler]]);
UpdateHealthboxAttribute(gHealthBoxesIds[gActiveBattler], &gPlayerParty[gBattlePartyID[gActiveBattler]], HEALTHBOX_ALL); UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler], &gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], HEALTHBOX_ALL);
sub_8076918(gActiveBattler); sub_8076918(gActiveBattler);
SetHealthboxSpriteVisible(gHealthBoxesIds[gActiveBattler]); SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]);
gBattleSpritesDataPtr->animationData->field_9_x1 = 0; gBattleSpritesDataPtr->animationData->field_9_x1 = 0;
gBattlerFuncs[gActiveBattler] = sub_81BAF48; gBattlerControllerFuncs[gActiveBattler] = sub_81BAF48;
} }
} }
static void sub_81BB1D4(void) static void sub_81BB1D4(void)
{ {
if (gSprites[gBankSpriteIds[gActiveBattler]].animEnded && gSprites[gBankSpriteIds[gActiveBattler]].pos2.x == 0) if (gSprites[gBattlerSpriteIds[gActiveBattler]].animEnded && gSprites[gBattlerSpriteIds[gActiveBattler]].pos2.x == 0)
PlayerPartnerBufferExecCompleted(); PlayerPartnerBufferExecCompleted();
} }
static void CompleteOnHealthbarDone(void) static void CompleteOnHealthbarDone(void)
{ {
s16 hpValue = sub_8074AA0(gActiveBattler, gHealthBoxesIds[gActiveBattler], HEALTH_BAR, 0); s16 hpValue = sub_8074AA0(gActiveBattler, gHealthboxSpriteIds[gActiveBattler], HEALTH_BAR, 0);
SetHealthboxSpriteVisible(gHealthBoxesIds[gActiveBattler]); SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]);
if (hpValue != -1) if (hpValue != -1)
{ {
UpdateHpTextInHealthbox(gHealthBoxesIds[gActiveBattler], hpValue, HP_CURRENT); UpdateHpTextInHealthbox(gHealthboxSpriteIds[gActiveBattler], hpValue, HP_CURRENT);
} }
else else
{ {
HandleLowHpMusicChange(&gPlayerParty[gBattlePartyID[gActiveBattler]], gActiveBattler); HandleLowHpMusicChange(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler);
PlayerPartnerBufferExecCompleted(); PlayerPartnerBufferExecCompleted();
} }
} }
@ -351,7 +351,7 @@ static void Task_GiveExpToMon(u8 taskId)
u8 bank = gTasks[taskId].tExpTask_bank; u8 bank = gTasks[taskId].tExpTask_bank;
s16 gainedExp = gTasks[taskId].tExpTask_gainedExp; s16 gainedExp = gTasks[taskId].tExpTask_gainedExp;
if (IsDoubleBattle() == TRUE || monId != gBattlePartyID[bank]) // give exp without the expbar if (IsDoubleBattle() == TRUE || monId != gBattlerPartyIndexes[bank]) // give exp without the expbar
{ {
struct Pokemon *mon = &gPlayerParty[monId]; struct Pokemon *mon = &gPlayerParty[monId];
u16 species = GetMonData(mon, MON_DATA_SPECIES); u16 species = GetMonData(mon, MON_DATA_SPECIES);
@ -368,11 +368,11 @@ static void Task_GiveExpToMon(u8 taskId)
gainedExp -= nextLvlExp - currExp; gainedExp -= nextLvlExp - currExp;
savedActiveBank = gActiveBattler; savedActiveBank = gActiveBattler;
gActiveBattler = bank; gActiveBattler = bank;
EmitTwoReturnValues(1, RET_VALUE_LEVELLED_UP, gainedExp); BtlController_EmitTwoReturnValues(1, RET_VALUE_LEVELLED_UP, gainedExp);
gActiveBattler = savedActiveBank; gActiveBattler = savedActiveBank;
if (IsDoubleBattle() == TRUE if (IsDoubleBattle() == TRUE
&& ((u16)(monId) == gBattlePartyID[bank] || (u16)(monId) == gBattlePartyID[bank ^ BIT_FLANK])) && ((u16)(monId) == gBattlerPartyIndexes[bank] || (u16)(monId) == gBattlerPartyIndexes[bank ^ BIT_FLANK]))
gTasks[taskId].func = sub_81BB628; gTasks[taskId].func = sub_81BB628;
else else
gTasks[taskId].func = DestroyExpTaskAndCompleteOnInactiveTextPrinter; gTasks[taskId].func = DestroyExpTaskAndCompleteOnInactiveTextPrinter;
@ -381,7 +381,7 @@ static void Task_GiveExpToMon(u8 taskId)
{ {
currExp += gainedExp; currExp += gainedExp;
SetMonData(mon, MON_DATA_EXP, &currExp); SetMonData(mon, MON_DATA_EXP, &currExp);
gBattlerFuncs[bank] = CompleteOnInactiveTextPrinter; gBattlerControllerFuncs[bank] = CompleteOnInactiveTextPrinter;
DestroyTask(taskId); DestroyTask(taskId);
} }
} }
@ -405,7 +405,7 @@ static void Task_PrepareToGiveExpWithExpBar(u8 taskId)
exp -= currLvlExp; exp -= currLvlExp;
expToNextLvl = gExperienceTables[gBaseStats[species].growthRate][level + 1] - currLvlExp; expToNextLvl = gExperienceTables[gBaseStats[species].growthRate][level + 1] - currLvlExp;
SetBattleBarStruct(bank, gHealthBoxesIds[bank], expToNextLvl, exp, -gainedExp); SetBattleBarStruct(bank, gHealthboxSpriteIds[bank], expToNextLvl, exp, -gainedExp);
PlaySE(SE_EXP); PlaySE(SE_EXP);
gTasks[taskId].func = sub_81BB4E4; gTasks[taskId].func = sub_81BB4E4;
} }
@ -423,8 +423,8 @@ static void sub_81BB4E4(u8 taskId)
u8 bank = gTasks[taskId].tExpTask_bank; u8 bank = gTasks[taskId].tExpTask_bank;
s16 r4; s16 r4;
r4 = sub_8074AA0(bank, gHealthBoxesIds[bank], EXP_BAR, 0); r4 = sub_8074AA0(bank, gHealthboxSpriteIds[bank], EXP_BAR, 0);
SetHealthboxSpriteVisible(gHealthBoxesIds[bank]); SetHealthboxSpriteVisible(gHealthboxSpriteIds[bank]);
if (r4 == -1) if (r4 == -1)
{ {
u8 level; u8 level;
@ -447,7 +447,7 @@ static void sub_81BB4E4(u8 taskId)
gainedExp -= expOnNextLvl - currExp; gainedExp -= expOnNextLvl - currExp;
savedActiveBank = gActiveBattler; savedActiveBank = gActiveBattler;
gActiveBattler = bank; gActiveBattler = bank;
EmitTwoReturnValues(1, RET_VALUE_LEVELLED_UP, gainedExp); BtlController_EmitTwoReturnValues(1, RET_VALUE_LEVELLED_UP, gainedExp);
gActiveBattler = savedActiveBank; gActiveBattler = savedActiveBank;
gTasks[taskId].func = sub_81BB628; gTasks[taskId].func = sub_81BB628;
} }
@ -455,7 +455,7 @@ static void sub_81BB4E4(u8 taskId)
{ {
currExp += gainedExp; currExp += gainedExp;
SetMonData(&gPlayerParty[monId], MON_DATA_EXP, &currExp); SetMonData(&gPlayerParty[monId], MON_DATA_EXP, &currExp);
gBattlerFuncs[bank] = CompleteOnInactiveTextPrinter; gBattlerControllerFuncs[bank] = CompleteOnInactiveTextPrinter;
DestroyTask(taskId); DestroyTask(taskId);
} }
} }
@ -467,7 +467,7 @@ static void sub_81BB628(u8 taskId)
u8 bank = gTasks[taskId].tExpTask_bank; u8 bank = gTasks[taskId].tExpTask_bank;
u8 monIndex = gTasks[taskId].tExpTask_monId; u8 monIndex = gTasks[taskId].tExpTask_monId;
if (IsDoubleBattle() == TRUE && monIndex == gBattlePartyID[bank ^ BIT_FLANK]) if (IsDoubleBattle() == TRUE && monIndex == gBattlerPartyIndexes[bank ^ BIT_FLANK])
bank ^= BIT_FLANK; bank ^= BIT_FLANK;
InitAndLaunchSpecialAnimation(bank, bank, bank, B_ANIM_LVL_UP); InitAndLaunchSpecialAnimation(bank, bank, bank, B_ANIM_LVL_UP);
@ -484,10 +484,10 @@ static void sub_81BB688(u8 taskId)
GetMonData(&gPlayerParty[monIndex], MON_DATA_LEVEL); // Unused return value GetMonData(&gPlayerParty[monIndex], MON_DATA_LEVEL); // Unused return value
if (IsDoubleBattle() == TRUE && monIndex == gBattlePartyID[bank ^ BIT_FLANK]) if (IsDoubleBattle() == TRUE && monIndex == gBattlerPartyIndexes[bank ^ BIT_FLANK])
UpdateHealthboxAttribute(gHealthBoxesIds[bank ^ BIT_FLANK], &gPlayerParty[monIndex], HEALTHBOX_ALL); UpdateHealthboxAttribute(gHealthboxSpriteIds[bank ^ BIT_FLANK], &gPlayerParty[monIndex], HEALTHBOX_ALL);
else else
UpdateHealthboxAttribute(gHealthBoxesIds[bank], &gPlayerParty[monIndex], HEALTHBOX_ALL); UpdateHealthboxAttribute(gHealthboxSpriteIds[bank], &gPlayerParty[monIndex], HEALTHBOX_ALL);
gTasks[taskId].func = DestroyExpTaskAndCompleteOnInactiveTextPrinter; gTasks[taskId].func = DestroyExpTaskAndCompleteOnInactiveTextPrinter;
} }
@ -501,20 +501,20 @@ static void DestroyExpTaskAndCompleteOnInactiveTextPrinter(u8 taskId)
monIndex = gTasks[taskId].tExpTask_monId; monIndex = gTasks[taskId].tExpTask_monId;
GetMonData(&gPlayerParty[monIndex], MON_DATA_LEVEL); // Unused return value GetMonData(&gPlayerParty[monIndex], MON_DATA_LEVEL); // Unused return value
bank = gTasks[taskId].tExpTask_bank; bank = gTasks[taskId].tExpTask_bank;
gBattlerFuncs[bank] = CompleteOnInactiveTextPrinter; gBattlerControllerFuncs[bank] = CompleteOnInactiveTextPrinter;
DestroyTask(taskId); DestroyTask(taskId);
} }
static void sub_81BB78C(void) static void sub_81BB78C(void)
{ {
if (gSprites[gBankSpriteIds[gActiveBattler]].pos1.y + gSprites[gBankSpriteIds[gActiveBattler]].pos2.y > DISPLAY_HEIGHT) if (gSprites[gBattlerSpriteIds[gActiveBattler]].pos1.y + gSprites[gBattlerSpriteIds[gActiveBattler]].pos2.y > DISPLAY_HEIGHT)
{ {
u16 species = GetMonData(&gPlayerParty[gBattlePartyID[gActiveBattler]], MON_DATA_SPECIES); u16 species = GetMonData(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_SPECIES);
nullsub_24(species); nullsub_24(species);
FreeOamMatrix(gSprites[gBankSpriteIds[gActiveBattler]].oam.matrixNum); FreeOamMatrix(gSprites[gBattlerSpriteIds[gActiveBattler]].oam.matrixNum);
DestroySprite(&gSprites[gBankSpriteIds[gActiveBattler]]); DestroySprite(&gSprites[gBattlerSpriteIds[gActiveBattler]]);
SetHealthboxSpriteInvisible(gHealthBoxesIds[gActiveBattler]); SetHealthboxSpriteInvisible(gHealthboxSpriteIds[gActiveBattler]);
PlayerPartnerBufferExecCompleted(); PlayerPartnerBufferExecCompleted();
} }
} }
@ -523,9 +523,9 @@ static void sub_81BB828(void)
{ {
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive) if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive)
{ {
FreeSpriteOamMatrix(&gSprites[gBankSpriteIds[gActiveBattler]]); FreeSpriteOamMatrix(&gSprites[gBattlerSpriteIds[gActiveBattler]]);
DestroySprite(&gSprites[gBankSpriteIds[gActiveBattler]]); DestroySprite(&gSprites[gBattlerSpriteIds[gActiveBattler]]);
SetHealthboxSpriteInvisible(gHealthBoxesIds[gActiveBattler]); SetHealthboxSpriteInvisible(gHealthboxSpriteIds[gActiveBattler]);
PlayerPartnerBufferExecCompleted(); PlayerPartnerBufferExecCompleted();
} }
} }
@ -538,7 +538,7 @@ static void CompleteOnInactiveTextPrinter2(void)
static void DoHitAnimBlinkSpriteEffect(void) static void DoHitAnimBlinkSpriteEffect(void)
{ {
u8 spriteId = gBankSpriteIds[gActiveBattler]; u8 spriteId = gBattlerSpriteIds[gActiveBattler];
if (gSprites[spriteId].data[1] == 32) if (gSprites[spriteId].data[1] == 32)
{ {
@ -557,20 +557,20 @@ static void DoHitAnimBlinkSpriteEffect(void)
static void sub_81BB92C(void) static void sub_81BB92C(void)
{ {
if (gSprites[gHealthBoxesIds[gActiveBattler]].callback == SpriteCallbackDummy) if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
{ {
CopyBattleSpriteInvisibility(gActiveBattler); CopyBattleSpriteInvisibility(gActiveBattler);
if (gBattleSpritesDataPtr->bankData[gActiveBattler].behindSubstitute) if (gBattleSpritesDataPtr->bankData[gActiveBattler].behindSubstitute)
InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_MON_TO_SUBSTITUTE); InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_MON_TO_SUBSTITUTE);
gBattlerFuncs[gActiveBattler] = sub_81BB9A0; gBattlerControllerFuncs[gActiveBattler] = sub_81BB9A0;
} }
} }
static void sub_81BB9A0(void) static void sub_81BB9A0(void)
{ {
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive
&& gSprites[gBankSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy) && gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
{ {
PlayerPartnerBufferExecCompleted(); PlayerPartnerBufferExecCompleted();
} }
@ -587,13 +587,13 @@ static void sub_81BB9F4(void)
FreeSpritePaletteByTag(0x27F9); FreeSpritePaletteByTag(0x27F9);
CreateTask(c3_0802FDF4, 10); CreateTask(c3_0802FDF4, 10);
HandleLowHpMusicChange(&gPlayerParty[gBattlePartyID[gActiveBattler]], gActiveBattler); HandleLowHpMusicChange(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler);
StartSpriteAnim(&gSprites[gBankSpriteIds[gActiveBattler]], 0); StartSpriteAnim(&gSprites[gBattlerSpriteIds[gActiveBattler]], 0);
UpdateHealthboxAttribute(gHealthBoxesIds[gActiveBattler], &gPlayerParty[gBattlePartyID[gActiveBattler]], HEALTHBOX_ALL); UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler], &gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], HEALTHBOX_ALL);
sub_8076918(gActiveBattler); sub_8076918(gActiveBattler);
SetHealthboxSpriteVisible(gHealthBoxesIds[gActiveBattler]); SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]);
gBattlerFuncs[gActiveBattler] = sub_81BB92C; gBattlerControllerFuncs[gActiveBattler] = sub_81BB92C;
} }
} }
@ -602,20 +602,20 @@ static void sub_81BBAE8(void)
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].flag_x80 if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].flag_x80
&& !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive) && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive)
{ {
sub_8172EF0(gActiveBattler, &gPlayerParty[gBattlePartyID[gActiveBattler]]); sub_8172EF0(gActiveBattler, &gPlayerParty[gBattlerPartyIndexes[gActiveBattler]]);
} }
if (gSprites[gUnknown_03005D7C[gActiveBattler]].callback == SpriteCallbackDummy if (gSprites[gUnknown_03005D7C[gActiveBattler]].callback == SpriteCallbackDummy
&& !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive) && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive)
{ {
DestroySprite(&gSprites[gUnknown_03005D7C[gActiveBattler]]); DestroySprite(&gSprites[gUnknown_03005D7C[gActiveBattler]]);
gBattlerFuncs[gActiveBattler] = sub_81BB9F4; gBattlerControllerFuncs[gActiveBattler] = sub_81BB9F4;
} }
} }
static void PlayerPartnerBufferExecCompleted(void) static void PlayerPartnerBufferExecCompleted(void)
{ {
gBattlerFuncs[gActiveBattler] = PlayerPartnerBufferRunCommand; gBattlerControllerFuncs[gActiveBattler] = PlayerPartnerBufferRunCommand;
if (gBattleTypeFlags & BATTLE_TYPE_LINK) if (gBattleTypeFlags & BATTLE_TYPE_LINK)
{ {
u8 playerId = GetMultiplayerId(); u8 playerId = GetMultiplayerId();
@ -625,7 +625,7 @@ static void PlayerPartnerBufferExecCompleted(void)
} }
else else
{ {
gBattleExecBuffer &= ~gBitTable[gActiveBattler]; gBattleControllerExecFlags &= ~gBitTable[gActiveBattler];
} }
} }
@ -650,7 +650,7 @@ static void PlayerPartnerHandleGetMonData(void)
if (gBattleBufferA[gActiveBattler][2] == 0) if (gBattleBufferA[gActiveBattler][2] == 0)
{ {
size += CopyPlayerPartnerMonData(gBattlePartyID[gActiveBattler], monData); size += CopyPlayerPartnerMonData(gBattlerPartyIndexes[gActiveBattler], monData);
} }
else else
{ {
@ -662,7 +662,7 @@ static void PlayerPartnerHandleGetMonData(void)
monToCheck >>= 1; monToCheck >>= 1;
} }
} }
EmitDataTransfer(1, size, monData); BtlController_EmitDataTransfer(1, size, monData);
PlayerPartnerBufferExecCompleted(); PlayerPartnerBufferExecCompleted();
} }
@ -984,7 +984,7 @@ static void PlayerPartnerHandleSetMonData(void)
if (gBattleBufferA[gActiveBattler][2] == 0) if (gBattleBufferA[gActiveBattler][2] == 0)
{ {
SetPlayerPartnerMonData(gBattlePartyID[gActiveBattler]); SetPlayerPartnerMonData(gBattlerPartyIndexes[gActiveBattler]);
} }
else else
{ {
@ -1214,12 +1214,12 @@ static void SetPlayerPartnerMonData(u8 monId)
break; break;
} }
HandleLowHpMusicChange(&gPlayerParty[gBattlePartyID[gActiveBattler]], gActiveBattler); HandleLowHpMusicChange(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler);
} }
static void PlayerPartnerHandleSetRawMonData(void) static void PlayerPartnerHandleSetRawMonData(void)
{ {
u8 *dst = (u8 *)&gPlayerParty[gBattlePartyID[gActiveBattler]] + gBattleBufferA[gActiveBattler][1]; u8 *dst = (u8 *)&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]] + gBattleBufferA[gActiveBattler][1];
u8 i; u8 i;
for (i = 0; i < gBattleBufferA[gActiveBattler][2]; i++) for (i = 0; i < gBattleBufferA[gActiveBattler][2]; i++)
@ -1232,28 +1232,28 @@ static void PlayerPartnerHandleLoadMonSprite(void)
{ {
u16 species; u16 species;
BattleLoadPlayerMonSpriteGfx(&gPlayerParty[gBattlePartyID[gActiveBattler]], gActiveBattler); BattleLoadPlayerMonSpriteGfx(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler);
species = GetMonData(&gPlayerParty[gBattlePartyID[gActiveBattler]], MON_DATA_SPECIES); species = GetMonData(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_SPECIES);
sub_806A068(species, GetBattlerPosition(gActiveBattler)); sub_806A068(species, GetBattlerPosition(gActiveBattler));
gBankSpriteIds[gActiveBattler] = CreateSprite(&gUnknown_0202499C, gBattlerSpriteIds[gActiveBattler] = CreateSprite(&gUnknown_0202499C,
GetBankCoord(gActiveBattler, 2), GetBattlerSpriteCoord(gActiveBattler, 2),
GetBankSpriteDefault_Y(gActiveBattler), GetBattlerSpriteDefault_Y(gActiveBattler),
sub_80A82E4(gActiveBattler)); sub_80A82E4(gActiveBattler));
gSprites[gBankSpriteIds[gActiveBattler]].pos2.x = -240; gSprites[gBattlerSpriteIds[gActiveBattler]].pos2.x = -240;
gSprites[gBankSpriteIds[gActiveBattler]].data[0] = gActiveBattler; gSprites[gBattlerSpriteIds[gActiveBattler]].data[0] = gActiveBattler;
gSprites[gBankSpriteIds[gActiveBattler]].oam.paletteNum = gActiveBattler; gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = gActiveBattler;
StartSpriteAnim(&gSprites[gBankSpriteIds[gActiveBattler]], gBattleMonForms[gActiveBattler]); StartSpriteAnim(&gSprites[gBattlerSpriteIds[gActiveBattler]], gBattleMonForms[gActiveBattler]);
gBattlerFuncs[gActiveBattler] = sub_81BB1D4; gBattlerControllerFuncs[gActiveBattler] = sub_81BB1D4;
} }
static void PlayerPartnerHandleSwitchInAnim(void) static void PlayerPartnerHandleSwitchInAnim(void)
{ {
ClearTemporarySpeciesSpriteData(gActiveBattler, gBattleBufferA[gActiveBattler][2]); ClearTemporarySpeciesSpriteData(gActiveBattler, gBattleBufferA[gActiveBattler][2]);
gBattlePartyID[gActiveBattler] = gBattleBufferA[gActiveBattler][1]; gBattlerPartyIndexes[gActiveBattler] = gBattleBufferA[gActiveBattler][1];
BattleLoadPlayerMonSpriteGfx(&gPlayerParty[gBattlePartyID[gActiveBattler]], gActiveBattler); BattleLoadPlayerMonSpriteGfx(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler);
sub_81BD0E4(gActiveBattler, gBattleBufferA[gActiveBattler][2]); sub_81BD0E4(gActiveBattler, gBattleBufferA[gActiveBattler][2]);
gBattlerFuncs[gActiveBattler] = sub_81BBAE8; gBattlerControllerFuncs[gActiveBattler] = sub_81BBAE8;
} }
static void sub_81BD0E4(u8 bank, bool8 dontClearSubstituteBit) static void sub_81BD0E4(u8 bank, bool8 dontClearSubstituteBit)
@ -1261,28 +1261,28 @@ static void sub_81BD0E4(u8 bank, bool8 dontClearSubstituteBit)
u16 species; u16 species;
ClearTemporarySpeciesSpriteData(bank, dontClearSubstituteBit); ClearTemporarySpeciesSpriteData(bank, dontClearSubstituteBit);
gBattlePartyID[bank] = gBattleBufferA[bank][1]; gBattlerPartyIndexes[bank] = gBattleBufferA[bank][1];
species = GetMonData(&gPlayerParty[gBattlePartyID[bank]], MON_DATA_SPECIES); species = GetMonData(&gPlayerParty[gBattlerPartyIndexes[bank]], MON_DATA_SPECIES);
gUnknown_03005D7C[bank] = CreateInvisibleSpriteWithCallback(sub_805D714); gUnknown_03005D7C[bank] = CreateInvisibleSpriteWithCallback(sub_805D714);
sub_806A068(species, GetBattlerPosition(bank)); sub_806A068(species, GetBattlerPosition(bank));
gBankSpriteIds[bank] = CreateSprite( gBattlerSpriteIds[bank] = CreateSprite(
&gUnknown_0202499C, &gUnknown_0202499C,
GetBankCoord(bank, 2), GetBattlerSpriteCoord(bank, 2),
GetBankSpriteDefault_Y(bank), GetBattlerSpriteDefault_Y(bank),
sub_80A82E4(bank)); sub_80A82E4(bank));
gSprites[gUnknown_03005D7C[bank]].data[1] = gBankSpriteIds[bank]; gSprites[gUnknown_03005D7C[bank]].data[1] = gBattlerSpriteIds[bank];
gSprites[gUnknown_03005D7C[bank]].data[2] = bank; gSprites[gUnknown_03005D7C[bank]].data[2] = bank;
gSprites[gBankSpriteIds[bank]].data[0] = bank; gSprites[gBattlerSpriteIds[bank]].data[0] = bank;
gSprites[gBankSpriteIds[bank]].data[2] = species; gSprites[gBattlerSpriteIds[bank]].data[2] = species;
gSprites[gBankSpriteIds[bank]].oam.paletteNum = bank; gSprites[gBattlerSpriteIds[bank]].oam.paletteNum = bank;
StartSpriteAnim(&gSprites[gBankSpriteIds[bank]], gBattleMonForms[bank]); StartSpriteAnim(&gSprites[gBattlerSpriteIds[bank]], gBattleMonForms[bank]);
gSprites[gBankSpriteIds[bank]].invisible = TRUE; gSprites[gBattlerSpriteIds[bank]].invisible = TRUE;
gSprites[gBankSpriteIds[bank]].callback = SpriteCallbackDummy; gSprites[gBattlerSpriteIds[bank]].callback = SpriteCallbackDummy;
gSprites[gUnknown_03005D7C[bank]].data[0] = DoPokeballSendOutAnimation(0, POKEBALL_PLAYER_SENDOUT); gSprites[gUnknown_03005D7C[bank]].data[0] = DoPokeballSendOutAnimation(0, POKEBALL_PLAYER_SENDOUT);
} }
@ -1292,13 +1292,13 @@ static void PlayerPartnerHandleReturnMonToBall(void)
if (gBattleBufferA[gActiveBattler][1] == 0) if (gBattleBufferA[gActiveBattler][1] == 0)
{ {
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0;
gBattlerFuncs[gActiveBattler] = DoSwitchOutAnimation; gBattlerControllerFuncs[gActiveBattler] = DoSwitchOutAnimation;
} }
else else
{ {
FreeSpriteOamMatrix(&gSprites[gBankSpriteIds[gActiveBattler]]); FreeSpriteOamMatrix(&gSprites[gBattlerSpriteIds[gActiveBattler]]);
DestroySprite(&gSprites[gBankSpriteIds[gActiveBattler]]); DestroySprite(&gSprites[gBattlerSpriteIds[gActiveBattler]]);
SetHealthboxSpriteInvisible(gHealthBoxesIds[gActiveBattler]); SetHealthboxSpriteInvisible(gHealthboxSpriteIds[gActiveBattler]);
PlayerPartnerBufferExecCompleted(); PlayerPartnerBufferExecCompleted();
} }
} }
@ -1318,7 +1318,7 @@ static void DoSwitchOutAnimation(void)
{ {
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0;
InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SWITCH_OUT_PLAYER_MON); InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SWITCH_OUT_PLAYER_MON);
gBattlerFuncs[gActiveBattler] = sub_81BB828; gBattlerControllerFuncs[gActiveBattler] = sub_81BB828;
} }
break; break;
} }
@ -1350,29 +1350,29 @@ static void PlayerPartnerHandleDrawTrainerPic(void)
{ {
DecompressTrainerBackPic(trainerPicId, gActiveBattler); DecompressTrainerBackPic(trainerPicId, gActiveBattler);
sub_806A12C(trainerPicId, GetBattlerPosition(gActiveBattler)); sub_806A12C(trainerPicId, GetBattlerPosition(gActiveBattler));
gBankSpriteIds[gActiveBattler] = CreateSprite(&gUnknown_0202499C, xPos, yPos, sub_80A82E4(gActiveBattler)); gBattlerSpriteIds[gActiveBattler] = CreateSprite(&gUnknown_0202499C, xPos, yPos, sub_80A82E4(gActiveBattler));
gSprites[gBankSpriteIds[gActiveBattler]].oam.paletteNum = gActiveBattler; gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = gActiveBattler;
gSprites[gBankSpriteIds[gActiveBattler]].pos2.x = 240; gSprites[gBattlerSpriteIds[gActiveBattler]].pos2.x = 240;
gSprites[gBankSpriteIds[gActiveBattler]].data[0] = -2; gSprites[gBattlerSpriteIds[gActiveBattler]].data[0] = -2;
gSprites[gBankSpriteIds[gActiveBattler]].callback = sub_805D7AC; gSprites[gBattlerSpriteIds[gActiveBattler]].callback = sub_805D7AC;
} }
else // otherwise use front sprite else // otherwise use front sprite
{ {
DecompressTrainerFrontPic(trainerPicId, gActiveBattler); DecompressTrainerFrontPic(trainerPicId, gActiveBattler);
sub_806A1C0(trainerPicId, GetBattlerPosition(gActiveBattler)); sub_806A1C0(trainerPicId, GetBattlerPosition(gActiveBattler));
gBankSpriteIds[gActiveBattler] = CreateSprite(&gUnknown_0202499C, xPos, yPos, sub_80A82E4(gActiveBattler)); gBattlerSpriteIds[gActiveBattler] = CreateSprite(&gUnknown_0202499C, xPos, yPos, sub_80A82E4(gActiveBattler));
gSprites[gBankSpriteIds[gActiveBattler]].oam.paletteNum = IndexOfSpritePaletteTag(gTrainerFrontPicPaletteTable[trainerPicId].tag); gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = IndexOfSpritePaletteTag(gTrainerFrontPicPaletteTable[trainerPicId].tag);
gSprites[gBankSpriteIds[gActiveBattler]].pos2.x = 240; gSprites[gBattlerSpriteIds[gActiveBattler]].pos2.x = 240;
gSprites[gBankSpriteIds[gActiveBattler]].pos2.y = 48; gSprites[gBattlerSpriteIds[gActiveBattler]].pos2.y = 48;
gSprites[gBankSpriteIds[gActiveBattler]].data[0] = -2; gSprites[gBattlerSpriteIds[gActiveBattler]].data[0] = -2;
gSprites[gBankSpriteIds[gActiveBattler]].callback = sub_805D7AC; gSprites[gBattlerSpriteIds[gActiveBattler]].callback = sub_805D7AC;
gSprites[gBankSpriteIds[gActiveBattler]].oam.affineMode = 0; gSprites[gBattlerSpriteIds[gActiveBattler]].oam.affineMode = 0;
gSprites[gBankSpriteIds[gActiveBattler]].hFlip = 1; gSprites[gBattlerSpriteIds[gActiveBattler]].hFlip = 1;
} }
gBattlerFuncs[gActiveBattler] = CompleteOnBankSpriteCallbackDummy; gBattlerControllerFuncs[gActiveBattler] = CompleteOnBankSpriteCallbackDummy;
} }
static void PlayerPartnerHandleTrainerSlide(void) static void PlayerPartnerHandleTrainerSlide(void)
@ -1382,13 +1382,13 @@ static void PlayerPartnerHandleTrainerSlide(void)
static void PlayerPartnerHandleTrainerSlideBack(void) static void PlayerPartnerHandleTrainerSlideBack(void)
{ {
oamt_add_pos2_onto_pos1(&gSprites[gBankSpriteIds[gActiveBattler]]); oamt_add_pos2_onto_pos1(&gSprites[gBattlerSpriteIds[gActiveBattler]]);
gSprites[gBankSpriteIds[gActiveBattler]].data[0] = 35; gSprites[gBattlerSpriteIds[gActiveBattler]].data[0] = 35;
gSprites[gBankSpriteIds[gActiveBattler]].data[2] = -40; gSprites[gBattlerSpriteIds[gActiveBattler]].data[2] = -40;
gSprites[gBankSpriteIds[gActiveBattler]].data[4] = gSprites[gBankSpriteIds[gActiveBattler]].pos1.y; gSprites[gBattlerSpriteIds[gActiveBattler]].data[4] = gSprites[gBattlerSpriteIds[gActiveBattler]].pos1.y;
gSprites[gBankSpriteIds[gActiveBattler]].callback = sub_80A6EEC; gSprites[gBattlerSpriteIds[gActiveBattler]].callback = sub_80A6EEC;
StoreSpriteCallbackInData6(&gSprites[gBankSpriteIds[gActiveBattler]], SpriteCallbackDummy); StoreSpriteCallbackInData6(&gSprites[gBattlerSpriteIds[gActiveBattler]], SpriteCallbackDummy);
gBattlerFuncs[gActiveBattler] = sub_81BAE98; gBattlerControllerFuncs[gActiveBattler] = sub_81BAE98;
} }
static void PlayerPartnerHandleFaintAnimation(void) static void PlayerPartnerHandleFaintAnimation(void)
@ -1404,12 +1404,12 @@ static void PlayerPartnerHandleFaintAnimation(void)
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive) if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive)
{ {
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0;
HandleLowHpMusicChange(&gPlayerParty[gBattlePartyID[gActiveBattler]], gActiveBattler); HandleLowHpMusicChange(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler);
PlaySE12WithPanning(SE_POKE_DEAD, PAN_SIDE_PLAYER); PlaySE12WithPanning(SE_POKE_DEAD, PAN_SIDE_PLAYER);
gSprites[gBankSpriteIds[gActiveBattler]].data[1] = 0; gSprites[gBattlerSpriteIds[gActiveBattler]].data[1] = 0;
gSprites[gBankSpriteIds[gActiveBattler]].data[2] = 5; gSprites[gBattlerSpriteIds[gActiveBattler]].data[2] = 5;
gSprites[gBankSpriteIds[gActiveBattler]].callback = sub_8039C00; gSprites[gBattlerSpriteIds[gActiveBattler]].callback = sub_8039C00;
gBattlerFuncs[gActiveBattler] = sub_81BB78C; gBattlerControllerFuncs[gActiveBattler] = sub_81BB78C;
} }
} }
} }
@ -1454,7 +1454,7 @@ static void PlayerPartnerHandleMoveAnimation(void)
else else
{ {
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0;
gBattlerFuncs[gActiveBattler] = PlayerPartnerDoMoveAnimation; gBattlerControllerFuncs[gActiveBattler] = PlayerPartnerDoMoveAnimation;
} }
} }
} }
@ -1517,7 +1517,7 @@ static void PlayerPartnerHandlePrintString(void)
stringId = (u16*)(&gBattleBufferA[gActiveBattler][2]); stringId = (u16*)(&gBattleBufferA[gActiveBattler][2]);
BufferStringBattle(*stringId); BufferStringBattle(*stringId);
BattleHandleAddTextPrinter(gDisplayedStringBattle, 0); BattleHandleAddTextPrinter(gDisplayedStringBattle, 0);
gBattlerFuncs[gActiveBattler] = CompleteOnInactiveTextPrinter2; gBattlerControllerFuncs[gActiveBattler] = CompleteOnInactiveTextPrinter2;
} }
static void PlayerPartnerHandlePrintSelectionString(void) static void PlayerPartnerHandlePrintSelectionString(void)
@ -1545,15 +1545,15 @@ static void PlayerPartnerHandleChooseMove(void)
chosenMoveId = BattleAI_ChooseMoveOrAction(); chosenMoveId = BattleAI_ChooseMoveOrAction();
if (gBattleMoves[moveInfo->moves[chosenMoveId]].target & (MOVE_TARGET_x10 | MOVE_TARGET_USER)) if (gBattleMoves[moveInfo->moves[chosenMoveId]].target & (MOVE_TARGET_x10 | MOVE_TARGET_USER))
gBattleDefender = gActiveBattler; gBattleMoveTarget = gActiveBattler;
if (gBattleMoves[moveInfo->moves[chosenMoveId]].target & MOVE_TARGET_BOTH) if (gBattleMoves[moveInfo->moves[chosenMoveId]].target & MOVE_TARGET_BOTH)
{ {
gBattleDefender = GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT); gBattleMoveTarget = GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT);
if (gAbsentBattlerFlags & gBitTable[gBattleDefender]) if (gAbsentBattlerFlags & gBitTable[gBattleMoveTarget])
gBattleDefender = GetBattlerAtPosition(B_POSITION_OPPONENT_RIGHT); gBattleMoveTarget = GetBattlerAtPosition(B_POSITION_OPPONENT_RIGHT);
} }
EmitTwoReturnValues(1, 10, chosenMoveId | (gBattleDefender << 8)); BtlController_EmitTwoReturnValues(1, 10, chosenMoveId | (gBattleMoveTarget << 8));
PlayerPartnerBufferExecCompleted(); PlayerPartnerBufferExecCompleted();
} }
@ -1574,8 +1574,8 @@ static void PlayerPartnerHandleChoosePokemon(void)
for (chosenMonId = 3; chosenMonId < 6; chosenMonId++) for (chosenMonId = 3; chosenMonId < 6; chosenMonId++)
{ {
if (GetMonData(&gPlayerParty[chosenMonId], MON_DATA_HP) != 0 if (GetMonData(&gPlayerParty[chosenMonId], MON_DATA_HP) != 0
&& chosenMonId != gBattlePartyID[playerMonIdentity] && chosenMonId != gBattlerPartyIndexes[playerMonIdentity]
&& chosenMonId != gBattlePartyID[selfIdentity]) && chosenMonId != gBattlerPartyIndexes[selfIdentity])
{ {
break; break;
} }
@ -1583,7 +1583,7 @@ static void PlayerPartnerHandleChoosePokemon(void)
} }
*(gBattleStruct->monToSwitchIntoId + gActiveBattler) = chosenMonId; *(gBattleStruct->monToSwitchIntoId + gActiveBattler) = chosenMonId;
EmitChosenMonReturnValue(1, chosenMonId, NULL); BtlController_EmitChosenMonReturnValue(1, chosenMonId, NULL);
PlayerPartnerBufferExecCompleted(); PlayerPartnerBufferExecCompleted();
} }
@ -1601,19 +1601,19 @@ static void PlayerPartnerHandleHealthBarUpdate(void)
if (hpVal != INSTANT_HP_BAR_DROP) if (hpVal != INSTANT_HP_BAR_DROP)
{ {
u32 maxHP = GetMonData(&gPlayerParty[gBattlePartyID[gActiveBattler]], MON_DATA_MAX_HP); u32 maxHP = GetMonData(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_MAX_HP);
u32 curHP = GetMonData(&gPlayerParty[gBattlePartyID[gActiveBattler]], MON_DATA_HP); u32 curHP = GetMonData(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_HP);
SetBattleBarStruct(gActiveBattler, gHealthBoxesIds[gActiveBattler], maxHP, curHP, hpVal); SetBattleBarStruct(gActiveBattler, gHealthboxSpriteIds[gActiveBattler], maxHP, curHP, hpVal);
} }
else else
{ {
u32 maxHP = GetMonData(&gPlayerParty[gBattlePartyID[gActiveBattler]], MON_DATA_MAX_HP); u32 maxHP = GetMonData(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_MAX_HP);
SetBattleBarStruct(gActiveBattler, gHealthBoxesIds[gActiveBattler], maxHP, 0, hpVal); SetBattleBarStruct(gActiveBattler, gHealthboxSpriteIds[gActiveBattler], maxHP, 0, hpVal);
} }
gBattlerFuncs[gActiveBattler] = CompleteOnHealthbarDone; gBattlerControllerFuncs[gActiveBattler] = CompleteOnHealthbarDone;
} }
static void PlayerPartnerHandleExpUpdate(void) static void PlayerPartnerHandleExpUpdate(void)
@ -1636,7 +1636,7 @@ static void PlayerPartnerHandleExpUpdate(void)
gTasks[taskId].tExpTask_monId = monId; gTasks[taskId].tExpTask_monId = monId;
gTasks[taskId].tExpTask_gainedExp = expPointsToGive; gTasks[taskId].tExpTask_gainedExp = expPointsToGive;
gTasks[taskId].tExpTask_bank = gActiveBattler; gTasks[taskId].tExpTask_bank = gActiveBattler;
gBattlerFuncs[gActiveBattler] = nullsub_21; gBattlerControllerFuncs[gActiveBattler] = nullsub_21;
} }
} }
@ -1651,10 +1651,10 @@ static void PlayerPartnerHandleStatusIconUpdate(void)
{ {
u8 bank; u8 bank;
UpdateHealthboxAttribute(gHealthBoxesIds[gActiveBattler], &gPlayerParty[gBattlePartyID[gActiveBattler]], HEALTHBOX_STATUS_ICON); UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler], &gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], HEALTHBOX_STATUS_ICON);
bank = gActiveBattler; bank = gActiveBattler;
gBattleSpritesDataPtr->healthBoxesData[bank].statusAnimActive = 0; gBattleSpritesDataPtr->healthBoxesData[bank].statusAnimActive = 0;
gBattlerFuncs[gActiveBattler] = CompleteOnFinishedStatusAnimation; gBattlerControllerFuncs[gActiveBattler] = CompleteOnFinishedStatusAnimation;
} }
} }
@ -1664,7 +1664,7 @@ static void PlayerPartnerHandleStatusAnimation(void)
{ {
InitAndLaunchChosenStatusAnimation(gBattleBufferA[gActiveBattler][1], InitAndLaunchChosenStatusAnimation(gBattleBufferA[gActiveBattler][1],
gBattleBufferA[gActiveBattler][2] | (gBattleBufferA[gActiveBattler][3] << 8) | (gBattleBufferA[gActiveBattler][4] << 16) | (gBattleBufferA[gActiveBattler][5] << 24)); gBattleBufferA[gActiveBattler][2] | (gBattleBufferA[gActiveBattler][3] << 8) | (gBattleBufferA[gActiveBattler][4] << 16) | (gBattleBufferA[gActiveBattler][5] << 24));
gBattlerFuncs[gActiveBattler] = CompleteOnFinishedStatusAnimation; gBattlerControllerFuncs[gActiveBattler] = CompleteOnFinishedStatusAnimation;
} }
} }
@ -1739,16 +1739,16 @@ static void PlayerPartnerHandleCmd40(void)
static void PlayerPartnerHandleHitAnimation(void) static void PlayerPartnerHandleHitAnimation(void)
{ {
if (gSprites[gBankSpriteIds[gActiveBattler]].invisible == TRUE) if (gSprites[gBattlerSpriteIds[gActiveBattler]].invisible == TRUE)
{ {
PlayerPartnerBufferExecCompleted(); PlayerPartnerBufferExecCompleted();
} }
else else
{ {
gDoingBattleAnim = TRUE; gDoingBattleAnim = TRUE;
gSprites[gBankSpriteIds[gActiveBattler]].data[1] = 0; gSprites[gBattlerSpriteIds[gActiveBattler]].data[1] = 0;
DoHitAnimHealthboxEffect(gActiveBattler); DoHitAnimHealthboxEffect(gActiveBattler);
gBattlerFuncs[gActiveBattler] = DoHitAnimBlinkSpriteEffect; gBattlerControllerFuncs[gActiveBattler] = DoHitAnimBlinkSpriteEffect;
} }
} }
@ -1787,7 +1787,7 @@ static void PlayerPartnerHandlePlayFanfareOrBGM(void)
static void PlayerPartnerHandleFaintingCry(void) static void PlayerPartnerHandleFaintingCry(void)
{ {
u16 species = GetMonData(&gPlayerParty[gBattlePartyID[gActiveBattler]], MON_DATA_SPECIES); u16 species = GetMonData(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_SPECIES);
PlayCry3(species, -25, 5); PlayCry3(species, -25, 5);
PlayerPartnerBufferExecCompleted(); PlayerPartnerBufferExecCompleted();
@ -1805,16 +1805,16 @@ static void PlayerPartnerHandleIntroTrainerBallThrow(void)
u8 paletteNum; u8 paletteNum;
u8 taskId; u8 taskId;
oamt_add_pos2_onto_pos1(&gSprites[gBankSpriteIds[gActiveBattler]]); oamt_add_pos2_onto_pos1(&gSprites[gBattlerSpriteIds[gActiveBattler]]);
gSprites[gBankSpriteIds[gActiveBattler]].data[0] = 50; gSprites[gBattlerSpriteIds[gActiveBattler]].data[0] = 50;
gSprites[gBankSpriteIds[gActiveBattler]].data[2] = -40; gSprites[gBattlerSpriteIds[gActiveBattler]].data[2] = -40;
gSprites[gBankSpriteIds[gActiveBattler]].data[4] = gSprites[gBankSpriteIds[gActiveBattler]].pos1.y; gSprites[gBattlerSpriteIds[gActiveBattler]].data[4] = gSprites[gBattlerSpriteIds[gActiveBattler]].pos1.y;
gSprites[gBankSpriteIds[gActiveBattler]].callback = sub_80A6EEC; gSprites[gBattlerSpriteIds[gActiveBattler]].callback = sub_80A6EEC;
gSprites[gBankSpriteIds[gActiveBattler]].data[5] = gActiveBattler; gSprites[gBattlerSpriteIds[gActiveBattler]].data[5] = gActiveBattler;
StoreSpriteCallbackInData6(&gSprites[gBankSpriteIds[gActiveBattler]], sub_805CC00); StoreSpriteCallbackInData6(&gSprites[gBattlerSpriteIds[gActiveBattler]], sub_805CC00);
StartSpriteAnim(&gSprites[gBankSpriteIds[gActiveBattler]], 1); StartSpriteAnim(&gSprites[gBattlerSpriteIds[gActiveBattler]], 1);
paletteNum = AllocSpritePalette(0xD6F9); paletteNum = AllocSpritePalette(0xD6F9);
if (gPartnerTrainerId == STEVEN_PARTNER_ID) if (gPartnerTrainerId == STEVEN_PARTNER_ID)
@ -1829,7 +1829,7 @@ static void PlayerPartnerHandleIntroTrainerBallThrow(void)
} }
gSprites[gBankSpriteIds[gActiveBattler]].oam.paletteNum = paletteNum; gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = paletteNum;
taskId = CreateTask(sub_81BE2C8, 5); taskId = CreateTask(sub_81BE2C8, 5);
gTasks[taskId].data[0] = gActiveBattler; gTasks[taskId].data[0] = gActiveBattler;
@ -1838,7 +1838,7 @@ static void PlayerPartnerHandleIntroTrainerBallThrow(void)
gTasks[gUnknown_020244B4[gActiveBattler]].func = sub_8073C30; gTasks[gUnknown_020244B4[gActiveBattler]].func = sub_8073C30;
gBattleSpritesDataPtr->animationData->field_9_x1 = 1; gBattleSpritesDataPtr->animationData->field_9_x1 = 1;
gBattlerFuncs[gActiveBattler] = nullsub_77; gBattlerControllerFuncs[gActiveBattler] = nullsub_77;
} }
static void sub_81BE2C8(u8 taskId) static void sub_81BE2C8(u8 taskId)
@ -1854,20 +1854,20 @@ static void sub_81BE2C8(u8 taskId)
gActiveBattler = gTasks[taskId].data[0]; gActiveBattler = gTasks[taskId].data[0];
if (!IsDoubleBattle() || (gBattleTypeFlags & BATTLE_TYPE_MULTI)) if (!IsDoubleBattle() || (gBattleTypeFlags & BATTLE_TYPE_MULTI))
{ {
gBattleBufferA[gActiveBattler][1] = gBattlePartyID[gActiveBattler]; gBattleBufferA[gActiveBattler][1] = gBattlerPartyIndexes[gActiveBattler];
sub_81BD0E4(gActiveBattler, FALSE); sub_81BD0E4(gActiveBattler, FALSE);
} }
else else
{ {
gBattleBufferA[gActiveBattler][1] = gBattlePartyID[gActiveBattler]; gBattleBufferA[gActiveBattler][1] = gBattlerPartyIndexes[gActiveBattler];
sub_81BD0E4(gActiveBattler, FALSE); sub_81BD0E4(gActiveBattler, FALSE);
gActiveBattler ^= BIT_FLANK; gActiveBattler ^= BIT_FLANK;
gBattleBufferA[gActiveBattler][1] = gBattlePartyID[gActiveBattler]; gBattleBufferA[gActiveBattler][1] = gBattlerPartyIndexes[gActiveBattler];
BattleLoadPlayerMonSpriteGfx(&gPlayerParty[gBattlePartyID[gActiveBattler]], gActiveBattler); BattleLoadPlayerMonSpriteGfx(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler);
sub_81BD0E4(gActiveBattler, FALSE); sub_81BD0E4(gActiveBattler, FALSE);
gActiveBattler ^= BIT_FLANK; gActiveBattler ^= BIT_FLANK;
} }
gBattlerFuncs[gActiveBattler] = sub_81BB02C; gBattlerControllerFuncs[gActiveBattler] = sub_81BB02C;
gActiveBattler = savedActiveBank; gActiveBattler = savedActiveBank;
DestroyTask(taskId); DestroyTask(taskId);
} }
@ -1888,7 +1888,7 @@ static void PlayerPartnerHandleDrawPartyStatusSummary(void)
if (gBattleBufferA[gActiveBattler][2] != 0) if (gBattleBufferA[gActiveBattler][2] != 0)
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_5 = 0x5D; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_5 = 0x5D;
gBattlerFuncs[gActiveBattler] = sub_81BE498; gBattlerControllerFuncs[gActiveBattler] = sub_81BE498;
} }
} }
@ -1915,9 +1915,9 @@ static void PlayerPartnerHandleCmd50(void)
static void PlayerPartnerHandleSpriteInvisibility(void) static void PlayerPartnerHandleSpriteInvisibility(void)
{ {
if (IsBankSpritePresent(gActiveBattler)) if (IsBattlerSpritePresent(gActiveBattler))
{ {
gSprites[gBankSpriteIds[gActiveBattler]].invisible = gBattleBufferA[gActiveBattler][1]; gSprites[gBattlerSpriteIds[gActiveBattler]].invisible = gBattleBufferA[gActiveBattler][1];
CopyBattleSpriteInvisibility(gActiveBattler); CopyBattleSpriteInvisibility(gActiveBattler);
} }
PlayerPartnerBufferExecCompleted(); PlayerPartnerBufferExecCompleted();
@ -1933,7 +1933,7 @@ static void PlayerPartnerHandleBattleAnimation(void)
if (TryHandleLaunchBattleTableAnimation(gActiveBattler, gActiveBattler, gActiveBattler, animationId, argument)) if (TryHandleLaunchBattleTableAnimation(gActiveBattler, gActiveBattler, gActiveBattler, animationId, argument))
PlayerPartnerBufferExecCompleted(); PlayerPartnerBufferExecCompleted();
else else
gBattlerFuncs[gActiveBattler] = CompleteOnFinishedBattleAnimation; gBattlerControllerFuncs[gActiveBattler] = CompleteOnFinishedBattleAnimation;
} }
} }
@ -1953,7 +1953,7 @@ static void PlayerPartnerHandleCmd55(void)
FadeOutMapMusic(5); FadeOutMapMusic(5);
BeginFastPaletteFade(3); BeginFastPaletteFade(3);
PlayerPartnerBufferExecCompleted(); PlayerPartnerBufferExecCompleted();
gBattlerFuncs[gActiveBattler] = sub_80587B0; gBattlerControllerFuncs[gActiveBattler] = sub_80587B0;
} }
static void nullsub_128(void) static void nullsub_128(void)

View File

@ -25,21 +25,21 @@
#include "pokeball.h" #include "pokeball.h"
#include "data2.h" #include "data2.h"
extern u32 gBattleExecBuffer; extern u32 gBattleControllerExecFlags;
extern u8 gActiveBattler; extern u8 gActiveBattler;
extern u8 gBankSpriteIds[MAX_BATTLERS_COUNT]; extern u8 gBattlerSpriteIds[MAX_BATTLERS_COUNT];
extern u8 gActionSelectionCursor[MAX_BATTLERS_COUNT]; extern u8 gActionSelectionCursor[MAX_BATTLERS_COUNT];
extern u8 gBattlersCount; extern u8 gBattlersCount;
extern bool8 gDoingBattleAnim; extern bool8 gDoingBattleAnim;
extern void (*gBattlerFuncs[MAX_BATTLERS_COUNT])(void); extern void (*gBattlerControllerFuncs[MAX_BATTLERS_COUNT])(void);
extern void (*gPreBattleCallback1)(void); extern void (*gPreBattleCallback1)(void);
extern u16 gBattlePartyID[MAX_BATTLERS_COUNT]; extern u16 gBattlerPartyIndexes[MAX_BATTLERS_COUNT];
extern u8 gBattleBufferA[MAX_BATTLERS_COUNT][0x200]; extern u8 gBattleBufferA[MAX_BATTLERS_COUNT][0x200];
extern u8 gBattleBufferB[MAX_BATTLERS_COUNT][0x200]; extern u8 gBattleBufferB[MAX_BATTLERS_COUNT][0x200];
extern struct BattlePokemon gBattleMons[MAX_BATTLERS_COUNT]; extern struct BattlePokemon gBattleMons[MAX_BATTLERS_COUNT];
extern struct SpriteTemplate gUnknown_0202499C; extern struct SpriteTemplate gUnknown_0202499C;
extern u16 gSpecialVar_ItemId; extern u16 gSpecialVar_ItemId;
extern u8 gHealthBoxesIds[MAX_BATTLERS_COUNT]; extern u8 gHealthboxSpriteIds[MAX_BATTLERS_COUNT];
extern u8 gBattleOutcome; extern u8 gBattleOutcome;
extern u16 gBattle_BG0_X; extern u16 gBattle_BG0_X;
extern u16 gBattle_BG0_Y; extern u16 gBattle_BG0_Y;
@ -48,7 +48,7 @@ extern u8 gUnknown_03005D7C[MAX_BATTLERS_COUNT];
extern u8 gBattleMonForms[MAX_BATTLERS_COUNT]; extern u8 gBattleMonForms[MAX_BATTLERS_COUNT];
extern u16 gPartnerTrainerId; extern u16 gPartnerTrainerId;
extern u8 GetFrontierTrainerFrontSpriteId(u16 trainerId); extern u8 GetFrontierTrainerFrontSpriteId(u16 trainerId);
extern u8 gBattleDefender; extern u8 gBattleMoveTarget;
extern u8 gAbsentBattlerFlags; extern u8 gAbsentBattlerFlags;
extern u8 gUnknown_020244B4[]; extern u8 gUnknown_020244B4[];
extern u32 gTransformedPersonalities[MAX_BATTLERS_COUNT]; extern u32 gTransformedPersonalities[MAX_BATTLERS_COUNT];
@ -202,12 +202,12 @@ static void nullsub_70(void)
void SetControllerToRecordedOpponent(void) void SetControllerToRecordedOpponent(void)
{ {
gBattlerFuncs[gActiveBattler] = RecordedOpponentBufferRunCommand; gBattlerControllerFuncs[gActiveBattler] = RecordedOpponentBufferRunCommand;
} }
static void RecordedOpponentBufferRunCommand(void) static void RecordedOpponentBufferRunCommand(void)
{ {
if (gBattleExecBuffer & gBitTable[gActiveBattler]) if (gBattleControllerExecFlags & gBitTable[gActiveBattler])
{ {
if (gBattleBufferA[gActiveBattler][0] < ARRAY_COUNT(sRecordedOpponentBufferCommands)) if (gBattleBufferA[gActiveBattler][0] < ARRAY_COUNT(sRecordedOpponentBufferCommands))
sRecordedOpponentBufferCommands[gBattleBufferA[gActiveBattler][0]](); sRecordedOpponentBufferCommands[gBattleBufferA[gActiveBattler][0]]();
@ -218,23 +218,23 @@ static void RecordedOpponentBufferRunCommand(void)
static void CompleteOnBankSpriteCallbackDummy(void) static void CompleteOnBankSpriteCallbackDummy(void)
{ {
if (gSprites[gBankSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy) if (gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
RecordedOpponentBufferExecCompleted(); RecordedOpponentBufferExecCompleted();
} }
static void CompleteOnBankSpriteCallbackDummy2(void) static void CompleteOnBankSpriteCallbackDummy2(void)
{ {
if (gSprites[gBankSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy) if (gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
RecordedOpponentBufferExecCompleted(); RecordedOpponentBufferExecCompleted();
} }
static void sub_81865C8(void) static void sub_81865C8(void)
{ {
if (gSprites[gBankSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy) if (gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
{ {
FreeTrainerFrontPicPalette(gSprites[gBankSpriteIds[gActiveBattler]].oam.affineParam); FreeTrainerFrontPicPalette(gSprites[gBattlerSpriteIds[gActiveBattler]].oam.affineParam);
FreeSpriteOamMatrix(&gSprites[gBankSpriteIds[gActiveBattler]]); FreeSpriteOamMatrix(&gSprites[gBattlerSpriteIds[gActiveBattler]]);
DestroySprite(&gSprites[gBankSpriteIds[gActiveBattler]]); DestroySprite(&gSprites[gBattlerSpriteIds[gActiveBattler]]);
RecordedOpponentBufferExecCompleted(); RecordedOpponentBufferExecCompleted();
} }
} }
@ -254,8 +254,8 @@ static void sub_8186678(void)
if (!IsDoubleBattle() || (IsDoubleBattle() && (gBattleTypeFlags & BATTLE_TYPE_MULTI))) if (!IsDoubleBattle() || (IsDoubleBattle() && (gBattleTypeFlags & BATTLE_TYPE_MULTI)))
{ {
if (gSprites[gHealthBoxesIds[gActiveBattler]].callback == SpriteCallbackDummy if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy
&& gSprites[gBankSpriteIds[gActiveBattler]].animEnded) && gSprites[gBattlerSpriteIds[gActiveBattler]].animEnded)
{ {
var = TRUE; var = TRUE;
} }
@ -263,10 +263,10 @@ static void sub_8186678(void)
} }
else else
{ {
if (gSprites[gHealthBoxesIds[gActiveBattler]].callback == SpriteCallbackDummy if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy
&& gSprites[gHealthBoxesIds[gActiveBattler ^ BIT_FLANK]].callback == SpriteCallbackDummy && gSprites[gHealthboxSpriteIds[gActiveBattler ^ BIT_FLANK]].callback == SpriteCallbackDummy
&& gSprites[gBankSpriteIds[gActiveBattler]].animEnded && gSprites[gBattlerSpriteIds[gActiveBattler]].animEnded
&& gSprites[gBankSpriteIds[gActiveBattler ^ BIT_FLANK]].animEnded) && gSprites[gBattlerSpriteIds[gActiveBattler ^ BIT_FLANK]].animEnded)
{ {
var = TRUE; var = TRUE;
} }
@ -290,7 +290,7 @@ static void sub_8186678(void)
} }
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_9 = 3; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_9 = 3;
gBattlerFuncs[gActiveBattler] = sub_8186630; gBattlerControllerFuncs[gActiveBattler] = sub_8186630;
} }
} }
@ -300,9 +300,9 @@ static void sub_818686C(void)
bool32 r8 = FALSE; bool32 r8 = FALSE;
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].flag_x80 && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive) if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].flag_x80 && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive)
sub_8172EF0(gActiveBattler, &gEnemyParty[gBattlePartyID[gActiveBattler]]); sub_8172EF0(gActiveBattler, &gEnemyParty[gBattlerPartyIndexes[gActiveBattler]]);
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].flag_x80 && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].ballAnimActive) if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].flag_x80 && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].ballAnimActive)
sub_8172EF0(gActiveBattler ^ BIT_FLANK, &gEnemyParty[gBattlePartyID[gActiveBattler ^ BIT_FLANK]]); sub_8172EF0(gActiveBattler ^ BIT_FLANK, &gEnemyParty[gBattlerPartyIndexes[gActiveBattler ^ BIT_FLANK]]);
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].ballAnimActive) if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].ballAnimActive)
{ {
@ -310,13 +310,13 @@ static void sub_818686C(void)
{ {
if (IsDoubleBattle() && !(gBattleTypeFlags & BATTLE_TYPE_MULTI)) if (IsDoubleBattle() && !(gBattleTypeFlags & BATTLE_TYPE_MULTI))
{ {
UpdateHealthboxAttribute(gHealthBoxesIds[gActiveBattler ^ BIT_FLANK], &gEnemyParty[gBattlePartyID[gActiveBattler ^ BIT_FLANK]], HEALTHBOX_ALL); UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler ^ BIT_FLANK], &gEnemyParty[gBattlerPartyIndexes[gActiveBattler ^ BIT_FLANK]], HEALTHBOX_ALL);
sub_8076918(gActiveBattler ^ BIT_FLANK); sub_8076918(gActiveBattler ^ BIT_FLANK);
SetHealthboxSpriteVisible(gHealthBoxesIds[gActiveBattler ^ BIT_FLANK]); SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler ^ BIT_FLANK]);
} }
UpdateHealthboxAttribute(gHealthBoxesIds[gActiveBattler], &gEnemyParty[gBattlePartyID[gActiveBattler]], HEALTHBOX_ALL); UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler], &gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], HEALTHBOX_ALL);
sub_8076918(gActiveBattler); sub_8076918(gActiveBattler);
SetHealthboxSpriteVisible(gHealthBoxesIds[gActiveBattler]); SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]);
} }
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x80 = 1; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x80 = 1;
} }
@ -345,7 +345,7 @@ static void sub_818686C(void)
if (!IsDoubleBattle()) if (!IsDoubleBattle())
{ {
if (gSprites[gUnknown_03005D7C[gActiveBattler]].callback == SpriteCallbackDummy if (gSprites[gUnknown_03005D7C[gActiveBattler]].callback == SpriteCallbackDummy
&& gSprites[gBankSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy) && gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
{ {
r8 = TRUE; r8 = TRUE;
} }
@ -353,9 +353,9 @@ static void sub_818686C(void)
else else
{ {
if (gSprites[gUnknown_03005D7C[gActiveBattler]].callback == SpriteCallbackDummy if (gSprites[gUnknown_03005D7C[gActiveBattler]].callback == SpriteCallbackDummy
&& gSprites[gBankSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy && gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy
&& gSprites[gUnknown_03005D7C[gActiveBattler ^ BIT_FLANK]].callback == SpriteCallbackDummy && gSprites[gUnknown_03005D7C[gActiveBattler ^ BIT_FLANK]].callback == SpriteCallbackDummy
&& gSprites[gBankSpriteIds[gActiveBattler ^ BIT_FLANK]].callback == SpriteCallbackDummy) && gSprites[gBattlerSpriteIds[gActiveBattler ^ BIT_FLANK]].callback == SpriteCallbackDummy)
{ {
r8 = TRUE; r8 = TRUE;
} }
@ -366,28 +366,28 @@ static void sub_818686C(void)
if (IsDoubleBattle() && !(gBattleTypeFlags & BATTLE_TYPE_MULTI)) if (IsDoubleBattle() && !(gBattleTypeFlags & BATTLE_TYPE_MULTI))
{ {
DestroySprite(&gSprites[gUnknown_03005D7C[gActiveBattler ^ BIT_FLANK]]); DestroySprite(&gSprites[gUnknown_03005D7C[gActiveBattler ^ BIT_FLANK]]);
SetBankEnemyShadowSpriteCallback(gActiveBattler ^ BIT_FLANK, GetMonData(&gEnemyParty[gBattlePartyID[gActiveBattler ^ BIT_FLANK]], MON_DATA_SPECIES)); SetBattlerShadowSpriteCallback(gActiveBattler ^ BIT_FLANK, GetMonData(&gEnemyParty[gBattlerPartyIndexes[gActiveBattler ^ BIT_FLANK]], MON_DATA_SPECIES));
} }
DestroySprite(&gSprites[gUnknown_03005D7C[gActiveBattler]]); DestroySprite(&gSprites[gUnknown_03005D7C[gActiveBattler]]);
SetBankEnemyShadowSpriteCallback(gActiveBattler, GetMonData(&gEnemyParty[gBattlePartyID[gActiveBattler]], MON_DATA_SPECIES)); SetBattlerShadowSpriteCallback(gActiveBattler, GetMonData(&gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_SPECIES));
gBattleSpritesDataPtr->animationData->field_9_x1 = 0; gBattleSpritesDataPtr->animationData->field_9_x1 = 0;
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x20 = 0; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x20 = 0;
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x80 = 0; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x80 = 0;
gBattlerFuncs[gActiveBattler] = sub_8186678; gBattlerControllerFuncs[gActiveBattler] = sub_8186678;
} }
} }
static void sub_8186C48(void) static void sub_8186C48(void)
{ {
if (gSprites[gBankSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy if (gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy
&& gSprites[gBankSpriteIds[gActiveBattler]].pos2.x == 0) && gSprites[gBattlerSpriteIds[gActiveBattler]].pos2.x == 0)
{ {
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].flag_x80) if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].flag_x80)
{ {
sub_8172EF0(gActiveBattler, &gEnemyParty[gBattlePartyID[gActiveBattler]]); sub_8172EF0(gActiveBattler, &gEnemyParty[gBattlerPartyIndexes[gActiveBattler]]);
} }
else else
{ {
@ -405,13 +405,13 @@ static void sub_8186C48(void)
static void CompleteOnHealthbarDone(void) static void CompleteOnHealthbarDone(void)
{ {
s16 hpValue = sub_8074AA0(gActiveBattler, gHealthBoxesIds[gActiveBattler], HEALTH_BAR, 0); s16 hpValue = sub_8074AA0(gActiveBattler, gHealthboxSpriteIds[gActiveBattler], HEALTH_BAR, 0);
SetHealthboxSpriteVisible(gHealthBoxesIds[gActiveBattler]); SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]);
if (hpValue != -1) if (hpValue != -1)
{ {
UpdateHpTextInHealthbox(gHealthBoxesIds[gActiveBattler], hpValue, HP_CURRENT); UpdateHpTextInHealthbox(gHealthboxSpriteIds[gActiveBattler], hpValue, HP_CURRENT);
} }
else else
{ {
@ -421,9 +421,9 @@ static void CompleteOnHealthbarDone(void)
static void sub_8186D58(void) static void sub_8186D58(void)
{ {
if (!gSprites[gBankSpriteIds[gActiveBattler]].inUse) if (!gSprites[gBattlerSpriteIds[gActiveBattler]].inUse)
{ {
SetHealthboxSpriteInvisible(gHealthBoxesIds[gActiveBattler]); SetHealthboxSpriteInvisible(gHealthboxSpriteIds[gActiveBattler]);
RecordedOpponentBufferExecCompleted(); RecordedOpponentBufferExecCompleted();
} }
} }
@ -432,10 +432,10 @@ static void sub_8186D9C(void)
{ {
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive) if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive)
{ {
FreeSpriteOamMatrix(&gSprites[gBankSpriteIds[gActiveBattler]]); FreeSpriteOamMatrix(&gSprites[gBattlerSpriteIds[gActiveBattler]]);
DestroySprite(&gSprites[gBankSpriteIds[gActiveBattler]]); DestroySprite(&gSprites[gBattlerSpriteIds[gActiveBattler]]);
EnemyShadowCallbackToSetInvisible(gActiveBattler); HideBattlerShadowSprite(gActiveBattler);
SetHealthboxSpriteInvisible(gHealthBoxesIds[gActiveBattler]); SetHealthboxSpriteInvisible(gHealthboxSpriteIds[gActiveBattler]);
RecordedOpponentBufferExecCompleted(); RecordedOpponentBufferExecCompleted();
} }
} }
@ -448,7 +448,7 @@ static void CompleteOnInactiveTextPrinter(void)
static void DoHitAnimBlinkSpriteEffect(void) static void DoHitAnimBlinkSpriteEffect(void)
{ {
u8 spriteId = gBankSpriteIds[gActiveBattler]; u8 spriteId = gBattlerSpriteIds[gActiveBattler];
if (gSprites[spriteId].data[1] == 32) if (gSprites[spriteId].data[1] == 32)
{ {
@ -467,12 +467,12 @@ static void DoHitAnimBlinkSpriteEffect(void)
static void sub_8186EA4(void) static void sub_8186EA4(void)
{ {
if (gSprites[gHealthBoxesIds[gActiveBattler]].callback == SpriteCallbackDummy) if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
{ {
if (gBattleSpritesDataPtr->bankData[gActiveBattler].behindSubstitute) if (gBattleSpritesDataPtr->bankData[gActiveBattler].behindSubstitute)
InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_MON_TO_SUBSTITUTE); InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_MON_TO_SUBSTITUTE);
gBattlerFuncs[gActiveBattler] = sub_8186F14; gBattlerControllerFuncs[gActiveBattler] = sub_8186F14;
} }
} }
@ -481,8 +481,8 @@ static void sub_8186F14(void)
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive
&& !IsCryPlayingOrClearCrySongs()) && !IsCryPlayingOrClearCrySongs())
{ {
if (gSprites[gBankSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy if (gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy
|| gSprites[gBankSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy_2) || gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy_2)
{ {
m4aMPlayVolumeControl(&gMPlayInfo_BGM, 0xFFFF, 0x100); m4aMPlayVolumeControl(&gMPlayInfo_BGM, 0xFFFF, 0x100);
RecordedOpponentBufferExecCompleted(); RecordedOpponentBufferExecCompleted();
@ -493,7 +493,7 @@ static void sub_8186F14(void)
static void sub_8186F94(void) static void sub_8186F94(void)
{ {
if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x1 if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x1
&& gSprites[gBankSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy) && gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
{ {
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].flag_x80 = 0; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].flag_x80 = 0;
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x1 = 0; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x1 = 0;
@ -501,13 +501,13 @@ static void sub_8186F94(void)
FreeSpriteTilesByTag(0x27F9); FreeSpriteTilesByTag(0x27F9);
FreeSpritePaletteByTag(0x27F9); FreeSpritePaletteByTag(0x27F9);
StartSpriteAnim(&gSprites[gBankSpriteIds[gActiveBattler]], 0); StartSpriteAnim(&gSprites[gBattlerSpriteIds[gActiveBattler]], 0);
UpdateHealthboxAttribute(gHealthBoxesIds[gActiveBattler], &gEnemyParty[gBattlePartyID[gActiveBattler]], HEALTHBOX_ALL); UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler], &gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], HEALTHBOX_ALL);
sub_8076918(gActiveBattler); sub_8076918(gActiveBattler);
SetHealthboxSpriteVisible(gHealthBoxesIds[gActiveBattler]); SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]);
CopyBattleSpriteInvisibility(gActiveBattler); CopyBattleSpriteInvisibility(gActiveBattler);
gBattlerFuncs[gActiveBattler] = sub_8186EA4; gBattlerControllerFuncs[gActiveBattler] = sub_8186EA4;
} }
} }
@ -516,15 +516,15 @@ static void sub_8187084(void)
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive
&& !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].flag_x80) && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].flag_x80)
{ {
sub_8172EF0(gActiveBattler, &gEnemyParty[gBattlePartyID[gActiveBattler]]); sub_8172EF0(gActiveBattler, &gEnemyParty[gBattlerPartyIndexes[gActiveBattler]]);
} }
if (gSprites[gUnknown_03005D7C[gActiveBattler]].callback == SpriteCallbackDummy if (gSprites[gUnknown_03005D7C[gActiveBattler]].callback == SpriteCallbackDummy
&& !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive) && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive)
{ {
DestroySprite(&gSprites[gUnknown_03005D7C[gActiveBattler]]); DestroySprite(&gSprites[gUnknown_03005D7C[gActiveBattler]]);
SetBankEnemyShadowSpriteCallback(gActiveBattler, GetMonData(&gEnemyParty[gBattlePartyID[gActiveBattler]], MON_DATA_SPECIES)); SetBattlerShadowSpriteCallback(gActiveBattler, GetMonData(&gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_SPECIES));
gBattlerFuncs[gActiveBattler] = sub_8186F94; gBattlerControllerFuncs[gActiveBattler] = sub_8186F94;
} }
} }
@ -542,7 +542,7 @@ static void CompleteOnFinishedBattleAnimation(void)
static void RecordedOpponentBufferExecCompleted(void) static void RecordedOpponentBufferExecCompleted(void)
{ {
gBattlerFuncs[gActiveBattler] = RecordedOpponentBufferRunCommand; gBattlerControllerFuncs[gActiveBattler] = RecordedOpponentBufferRunCommand;
if (gBattleTypeFlags & BATTLE_TYPE_LINK) if (gBattleTypeFlags & BATTLE_TYPE_LINK)
{ {
u8 playerId = GetMultiplayerId(); u8 playerId = GetMultiplayerId();
@ -552,7 +552,7 @@ static void RecordedOpponentBufferExecCompleted(void)
} }
else else
{ {
gBattleExecBuffer &= ~gBitTable[gActiveBattler]; gBattleControllerExecFlags &= ~gBitTable[gActiveBattler];
} }
} }
@ -565,7 +565,7 @@ static void RecordedOpponentHandleGetMonData(void)
if (gBattleBufferA[gActiveBattler][2] == 0) if (gBattleBufferA[gActiveBattler][2] == 0)
{ {
size += CopyRecordedOpponentMonData(gBattlePartyID[gActiveBattler], monData); size += CopyRecordedOpponentMonData(gBattlerPartyIndexes[gActiveBattler], monData);
} }
else else
{ {
@ -577,7 +577,7 @@ static void RecordedOpponentHandleGetMonData(void)
monToCheck >>= 1; monToCheck >>= 1;
} }
} }
EmitDataTransfer(1, size, monData); BtlController_EmitDataTransfer(1, size, monData);
RecordedOpponentBufferExecCompleted(); RecordedOpponentBufferExecCompleted();
} }
@ -899,7 +899,7 @@ static void RecordedOpponentHandleSetMonData(void)
if (gBattleBufferA[gActiveBattler][2] == 0) if (gBattleBufferA[gActiveBattler][2] == 0)
{ {
SetRecordedOpponentMonData(gBattlePartyID[gActiveBattler]); SetRecordedOpponentMonData(gBattlerPartyIndexes[gActiveBattler]);
} }
else else
{ {
@ -1132,7 +1132,7 @@ static void SetRecordedOpponentMonData(u8 monId)
static void RecordedOpponentHandleSetRawMonData(void) static void RecordedOpponentHandleSetRawMonData(void)
{ {
u8 *dst = (u8 *)&gEnemyParty[gBattlePartyID[gActiveBattler]] + gBattleBufferA[gActiveBattler][1]; u8 *dst = (u8 *)&gEnemyParty[gBattlerPartyIndexes[gActiveBattler]] + gBattleBufferA[gActiveBattler][1];
u8 i; u8 i;
for (i = 0; i < gBattleBufferA[gActiveBattler][2]; i++) for (i = 0; i < gBattleBufferA[gActiveBattler][2]; i++)
@ -1143,33 +1143,33 @@ static void RecordedOpponentHandleSetRawMonData(void)
static void RecordedOpponentHandleLoadMonSprite(void) static void RecordedOpponentHandleLoadMonSprite(void)
{ {
u16 species = GetMonData(&gEnemyParty[gBattlePartyID[gActiveBattler]], MON_DATA_SPECIES); u16 species = GetMonData(&gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_SPECIES);
BattleLoadOpponentMonSpriteGfx(&gEnemyParty[gBattlePartyID[gActiveBattler]], gActiveBattler); BattleLoadOpponentMonSpriteGfx(&gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler);
sub_806A068(species, GetBattlerPosition(gActiveBattler)); sub_806A068(species, GetBattlerPosition(gActiveBattler));
gBankSpriteIds[gActiveBattler] = CreateSprite(&gUnknown_0202499C, gBattlerSpriteIds[gActiveBattler] = CreateSprite(&gUnknown_0202499C,
GetBankCoord(gActiveBattler, 2), GetBattlerSpriteCoord(gActiveBattler, 2),
GetBankSpriteDefault_Y(gActiveBattler), GetBattlerSpriteDefault_Y(gActiveBattler),
sub_80A82E4(gActiveBattler)); sub_80A82E4(gActiveBattler));
gSprites[gBankSpriteIds[gActiveBattler]].pos2.x = -240; gSprites[gBattlerSpriteIds[gActiveBattler]].pos2.x = -240;
gSprites[gBankSpriteIds[gActiveBattler]].data[0] = gActiveBattler; gSprites[gBattlerSpriteIds[gActiveBattler]].data[0] = gActiveBattler;
gSprites[gBankSpriteIds[gActiveBattler]].oam.paletteNum = gActiveBattler; gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = gActiveBattler;
StartSpriteAnim(&gSprites[gBankSpriteIds[gActiveBattler]], gBattleMonForms[gActiveBattler]); StartSpriteAnim(&gSprites[gBattlerSpriteIds[gActiveBattler]], gBattleMonForms[gActiveBattler]);
SetBankEnemyShadowSpriteCallback(gActiveBattler, GetMonData(&gEnemyParty[gBattlePartyID[gActiveBattler]], MON_DATA_SPECIES)); SetBattlerShadowSpriteCallback(gActiveBattler, GetMonData(&gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_SPECIES));
gBattlerFuncs[gActiveBattler] = sub_8186C48; gBattlerControllerFuncs[gActiveBattler] = sub_8186C48;
} }
static void RecordedOpponentHandleSwitchInAnim(void) static void RecordedOpponentHandleSwitchInAnim(void)
{ {
gBattlePartyID[gActiveBattler] = gBattleBufferA[gActiveBattler][1]; gBattlerPartyIndexes[gActiveBattler] = gBattleBufferA[gActiveBattler][1];
sub_81885D8(gActiveBattler, gBattleBufferA[gActiveBattler][2]); sub_81885D8(gActiveBattler, gBattleBufferA[gActiveBattler][2]);
gBattlerFuncs[gActiveBattler] = sub_8187084; gBattlerControllerFuncs[gActiveBattler] = sub_8187084;
} }
static void sub_81885D8(u8 bank, bool8 dontClearSubstituteBit) static void sub_81885D8(u8 bank, bool8 dontClearSubstituteBit)
@ -1177,28 +1177,28 @@ static void sub_81885D8(u8 bank, bool8 dontClearSubstituteBit)
u16 species; u16 species;
ClearTemporarySpeciesSpriteData(bank, dontClearSubstituteBit); ClearTemporarySpeciesSpriteData(bank, dontClearSubstituteBit);
gBattlePartyID[bank] = gBattleBufferA[bank][1]; gBattlerPartyIndexes[bank] = gBattleBufferA[bank][1];
species = GetMonData(&gEnemyParty[gBattlePartyID[bank]], MON_DATA_SPECIES); species = GetMonData(&gEnemyParty[gBattlerPartyIndexes[bank]], MON_DATA_SPECIES);
gUnknown_03005D7C[bank] = CreateInvisibleSpriteWithCallback(sub_805D714); gUnknown_03005D7C[bank] = CreateInvisibleSpriteWithCallback(sub_805D714);
BattleLoadOpponentMonSpriteGfx(&gEnemyParty[gBattlePartyID[bank]], bank); BattleLoadOpponentMonSpriteGfx(&gEnemyParty[gBattlerPartyIndexes[bank]], bank);
sub_806A068(species, GetBattlerPosition(bank)); sub_806A068(species, GetBattlerPosition(bank));
gBankSpriteIds[bank] = CreateSprite(&gUnknown_0202499C, gBattlerSpriteIds[bank] = CreateSprite(&gUnknown_0202499C,
GetBankCoord(bank, 2), GetBattlerSpriteCoord(bank, 2),
GetBankSpriteDefault_Y(bank), GetBattlerSpriteDefault_Y(bank),
sub_80A82E4(bank)); sub_80A82E4(bank));
gSprites[gUnknown_03005D7C[bank]].data[1] = gBankSpriteIds[bank]; gSprites[gUnknown_03005D7C[bank]].data[1] = gBattlerSpriteIds[bank];
gSprites[gUnknown_03005D7C[bank]].data[2] = bank; gSprites[gUnknown_03005D7C[bank]].data[2] = bank;
gSprites[gBankSpriteIds[bank]].data[0] = bank; gSprites[gBattlerSpriteIds[bank]].data[0] = bank;
gSprites[gBankSpriteIds[bank]].data[2] = species; gSprites[gBattlerSpriteIds[bank]].data[2] = species;
gSprites[gBankSpriteIds[bank]].oam.paletteNum = bank; gSprites[gBattlerSpriteIds[bank]].oam.paletteNum = bank;
StartSpriteAnim(&gSprites[gBankSpriteIds[bank]], gBattleMonForms[bank]); StartSpriteAnim(&gSprites[gBattlerSpriteIds[bank]], gBattleMonForms[bank]);
gSprites[gBankSpriteIds[bank]].invisible = TRUE; gSprites[gBattlerSpriteIds[bank]].invisible = TRUE;
gSprites[gBankSpriteIds[bank]].callback = SpriteCallbackDummy; gSprites[gBattlerSpriteIds[bank]].callback = SpriteCallbackDummy;
gSprites[gUnknown_03005D7C[bank]].data[0] = DoPokeballSendOutAnimation(0, POKEBALL_OPPONENT_SENDOUT); gSprites[gUnknown_03005D7C[bank]].data[0] = DoPokeballSendOutAnimation(0, POKEBALL_OPPONENT_SENDOUT);
} }
@ -1208,14 +1208,14 @@ static void RecordedOpponentHandleReturnMonToBall(void)
if (gBattleBufferA[gActiveBattler][1] == 0) if (gBattleBufferA[gActiveBattler][1] == 0)
{ {
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0;
gBattlerFuncs[gActiveBattler] = DoSwitchOutAnimation; gBattlerControllerFuncs[gActiveBattler] = DoSwitchOutAnimation;
} }
else else
{ {
FreeSpriteOamMatrix(&gSprites[gBankSpriteIds[gActiveBattler]]); FreeSpriteOamMatrix(&gSprites[gBattlerSpriteIds[gActiveBattler]]);
DestroySprite(&gSprites[gBankSpriteIds[gActiveBattler]]); DestroySprite(&gSprites[gBattlerSpriteIds[gActiveBattler]]);
EnemyShadowCallbackToSetInvisible(gActiveBattler); HideBattlerShadowSprite(gActiveBattler);
SetHealthboxSpriteInvisible(gHealthBoxesIds[gActiveBattler]); SetHealthboxSpriteInvisible(gHealthboxSpriteIds[gActiveBattler]);
RecordedOpponentBufferExecCompleted(); RecordedOpponentBufferExecCompleted();
} }
} }
@ -1235,7 +1235,7 @@ static void DoSwitchOutAnimation(void)
{ {
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0;
InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SWITCH_OUT_OPPONENT_MON); InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SWITCH_OUT_OPPONENT_MON);
gBattlerFuncs[gActiveBattler] = sub_8186D9C; gBattlerControllerFuncs[gActiveBattler] = sub_8186D9C;
} }
break; break;
} }
@ -1280,18 +1280,18 @@ static void RecordedOpponentHandleDrawTrainerPic(void)
DecompressTrainerFrontPic(trainerPicId, gActiveBattler); DecompressTrainerFrontPic(trainerPicId, gActiveBattler);
sub_806A12C(trainerPicId, GetBattlerPosition(gActiveBattler)); sub_806A12C(trainerPicId, GetBattlerPosition(gActiveBattler));
gBankSpriteIds[gActiveBattler] = CreateSprite(&gUnknown_0202499C, gBattlerSpriteIds[gActiveBattler] = CreateSprite(&gUnknown_0202499C,
xPos, xPos,
(8 - gTrainerFrontPicCoords[trainerPicId].coords) * 4 + 40, (8 - gTrainerFrontPicCoords[trainerPicId].coords) * 4 + 40,
sub_80A82E4(gActiveBattler)); sub_80A82E4(gActiveBattler));
gSprites[gBankSpriteIds[gActiveBattler]].pos2.x = -240; gSprites[gBattlerSpriteIds[gActiveBattler]].pos2.x = -240;
gSprites[gBankSpriteIds[gActiveBattler]].data[0] = 2; gSprites[gBattlerSpriteIds[gActiveBattler]].data[0] = 2;
gSprites[gBankSpriteIds[gActiveBattler]].oam.paletteNum = IndexOfSpritePaletteTag(gTrainerFrontPicPaletteTable[trainerPicId].tag); gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = IndexOfSpritePaletteTag(gTrainerFrontPicPaletteTable[trainerPicId].tag);
gSprites[gBankSpriteIds[gActiveBattler]].oam.affineParam = trainerPicId; gSprites[gBattlerSpriteIds[gActiveBattler]].oam.affineParam = trainerPicId;
gSprites[gBankSpriteIds[gActiveBattler]].callback = sub_805D7AC; gSprites[gBattlerSpriteIds[gActiveBattler]].callback = sub_805D7AC;
gBattlerFuncs[gActiveBattler] = CompleteOnBankSpriteCallbackDummy; gBattlerControllerFuncs[gActiveBattler] = CompleteOnBankSpriteCallbackDummy;
} }
static void RecordedOpponentHandleTrainerSlide(void) static void RecordedOpponentHandleTrainerSlide(void)
@ -1301,13 +1301,13 @@ static void RecordedOpponentHandleTrainerSlide(void)
static void RecordedOpponentHandleTrainerSlideBack(void) static void RecordedOpponentHandleTrainerSlideBack(void)
{ {
oamt_add_pos2_onto_pos1(&gSprites[gBankSpriteIds[gActiveBattler]]); oamt_add_pos2_onto_pos1(&gSprites[gBattlerSpriteIds[gActiveBattler]]);
gSprites[gBankSpriteIds[gActiveBattler]].data[0] = 35; gSprites[gBattlerSpriteIds[gActiveBattler]].data[0] = 35;
gSprites[gBankSpriteIds[gActiveBattler]].data[2] = 280; gSprites[gBattlerSpriteIds[gActiveBattler]].data[2] = 280;
gSprites[gBankSpriteIds[gActiveBattler]].data[4] = gSprites[gBankSpriteIds[gActiveBattler]].pos1.y; gSprites[gBattlerSpriteIds[gActiveBattler]].data[4] = gSprites[gBattlerSpriteIds[gActiveBattler]].pos1.y;
gSprites[gBankSpriteIds[gActiveBattler]].callback = sub_80A6EEC; gSprites[gBattlerSpriteIds[gActiveBattler]].callback = sub_80A6EEC;
StoreSpriteCallbackInData6(&gSprites[gBankSpriteIds[gActiveBattler]], SpriteCallbackDummy); StoreSpriteCallbackInData6(&gSprites[gBattlerSpriteIds[gActiveBattler]], SpriteCallbackDummy);
gBattlerFuncs[gActiveBattler] = sub_81865C8; gBattlerControllerFuncs[gActiveBattler] = sub_81865C8;
} }
static void RecordedOpponentHandleFaintAnimation(void) static void RecordedOpponentHandleFaintAnimation(void)
@ -1324,8 +1324,8 @@ static void RecordedOpponentHandleFaintAnimation(void)
{ {
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0;
PlaySE12WithPanning(SE_POKE_DEAD, PAN_SIDE_OPPONENT); PlaySE12WithPanning(SE_POKE_DEAD, PAN_SIDE_OPPONENT);
gSprites[gBankSpriteIds[gActiveBattler]].callback = sub_8039934; gSprites[gBattlerSpriteIds[gActiveBattler]].callback = sub_8039934;
gBattlerFuncs[gActiveBattler] = sub_8186D58; gBattlerControllerFuncs[gActiveBattler] = sub_8186D58;
} }
} }
} }
@ -1370,7 +1370,7 @@ static void RecordedOpponentHandleMoveAnimation(void)
else else
{ {
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0;
gBattlerFuncs[gActiveBattler] = RecordedOpponentDoMoveAnimation; gBattlerControllerFuncs[gActiveBattler] = RecordedOpponentDoMoveAnimation;
} }
} }
} }
@ -1433,7 +1433,7 @@ static void RecordedOpponentHandlePrintString(void)
stringId = (u16*)(&gBattleBufferA[gActiveBattler][2]); stringId = (u16*)(&gBattleBufferA[gActiveBattler][2]);
BufferStringBattle(*stringId); BufferStringBattle(*stringId);
BattleHandleAddTextPrinter(gDisplayedStringBattle, 0); BattleHandleAddTextPrinter(gDisplayedStringBattle, 0);
gBattlerFuncs[gActiveBattler] = CompleteOnInactiveTextPrinter; gBattlerControllerFuncs[gActiveBattler] = CompleteOnInactiveTextPrinter;
} }
static void RecordedOpponentHandlePrintSelectionString(void) static void RecordedOpponentHandlePrintSelectionString(void)
@ -1443,7 +1443,7 @@ static void RecordedOpponentHandlePrintSelectionString(void)
static void RecordedOpponentHandleChooseAction(void) static void RecordedOpponentHandleChooseAction(void)
{ {
EmitTwoReturnValues(1, RecordedBattle_ReadBankAction(gActiveBattler), 0); BtlController_EmitTwoReturnValues(1, RecordedBattle_GetBankAction(gActiveBattler), 0);
RecordedOpponentBufferExecCompleted(); RecordedOpponentBufferExecCompleted();
} }
@ -1456,13 +1456,13 @@ static void RecordedOpponentHandleChooseMove(void)
{ {
if (gBattleTypeFlags & BATTLE_TYPE_PALACE) if (gBattleTypeFlags & BATTLE_TYPE_PALACE)
{ {
EmitTwoReturnValues(1, 10, ChooseMoveAndTargetInBattlePalace()); BtlController_EmitTwoReturnValues(1, 10, ChooseMoveAndTargetInBattlePalace());
} }
else else
{ {
u8 moveId = RecordedBattle_ReadBankAction(gActiveBattler); u8 moveId = RecordedBattle_GetBankAction(gActiveBattler);
u8 target = RecordedBattle_ReadBankAction(gActiveBattler); u8 target = RecordedBattle_GetBankAction(gActiveBattler);
EmitTwoReturnValues(1, 10, moveId | (target << 8)); BtlController_EmitTwoReturnValues(1, 10, moveId | (target << 8));
} }
RecordedOpponentBufferExecCompleted(); RecordedOpponentBufferExecCompleted();
@ -1475,8 +1475,8 @@ static void RecordedOpponentHandleChooseItem(void)
static void RecordedOpponentHandleChoosePokemon(void) static void RecordedOpponentHandleChoosePokemon(void)
{ {
*(gBattleStruct->monToSwitchIntoId + gActiveBattler) = RecordedBattle_ReadBankAction(gActiveBattler); *(gBattleStruct->monToSwitchIntoId + gActiveBattler) = RecordedBattle_GetBankAction(gActiveBattler);
EmitChosenMonReturnValue(1, *(gBattleStruct->monToSwitchIntoId + gActiveBattler), NULL); BtlController_EmitChosenMonReturnValue(1, *(gBattleStruct->monToSwitchIntoId + gActiveBattler), NULL);
RecordedOpponentBufferExecCompleted(); RecordedOpponentBufferExecCompleted();
} }
@ -1494,19 +1494,19 @@ static void RecordedOpponentHandleHealthBarUpdate(void)
if (hpVal != INSTANT_HP_BAR_DROP) if (hpVal != INSTANT_HP_BAR_DROP)
{ {
u32 maxHP = GetMonData(&gEnemyParty[gBattlePartyID[gActiveBattler]], MON_DATA_MAX_HP); u32 maxHP = GetMonData(&gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_MAX_HP);
u32 curHP = GetMonData(&gEnemyParty[gBattlePartyID[gActiveBattler]], MON_DATA_HP); u32 curHP = GetMonData(&gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_HP);
SetBattleBarStruct(gActiveBattler, gHealthBoxesIds[gActiveBattler], maxHP, curHP, hpVal); SetBattleBarStruct(gActiveBattler, gHealthboxSpriteIds[gActiveBattler], maxHP, curHP, hpVal);
} }
else else
{ {
u32 maxHP = GetMonData(&gEnemyParty[gBattlePartyID[gActiveBattler]], MON_DATA_MAX_HP); u32 maxHP = GetMonData(&gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_MAX_HP);
SetBattleBarStruct(gActiveBattler, gHealthBoxesIds[gActiveBattler], maxHP, 0, hpVal); SetBattleBarStruct(gActiveBattler, gHealthboxSpriteIds[gActiveBattler], maxHP, 0, hpVal);
} }
gBattlerFuncs[gActiveBattler] = CompleteOnHealthbarDone; gBattlerControllerFuncs[gActiveBattler] = CompleteOnHealthbarDone;
} }
static void RecordedOpponentHandleExpUpdate(void) static void RecordedOpponentHandleExpUpdate(void)
@ -1520,10 +1520,10 @@ static void RecordedOpponentHandleStatusIconUpdate(void)
{ {
u8 bank; u8 bank;
UpdateHealthboxAttribute(gHealthBoxesIds[gActiveBattler], &gEnemyParty[gBattlePartyID[gActiveBattler]], HEALTHBOX_STATUS_ICON); UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler], &gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], HEALTHBOX_STATUS_ICON);
bank = gActiveBattler; bank = gActiveBattler;
gBattleSpritesDataPtr->healthBoxesData[bank].statusAnimActive = 0; gBattleSpritesDataPtr->healthBoxesData[bank].statusAnimActive = 0;
gBattlerFuncs[gActiveBattler] = CompleteOnFinishedStatusAnimation; gBattlerControllerFuncs[gActiveBattler] = CompleteOnFinishedStatusAnimation;
} }
} }
@ -1533,7 +1533,7 @@ static void RecordedOpponentHandleStatusAnimation(void)
{ {
InitAndLaunchChosenStatusAnimation(gBattleBufferA[gActiveBattler][1], InitAndLaunchChosenStatusAnimation(gBattleBufferA[gActiveBattler][1],
gBattleBufferA[gActiveBattler][2] | (gBattleBufferA[gActiveBattler][3] << 8) | (gBattleBufferA[gActiveBattler][4] << 16) | (gBattleBufferA[gActiveBattler][5] << 24)); gBattleBufferA[gActiveBattler][2] | (gBattleBufferA[gActiveBattler][3] << 8) | (gBattleBufferA[gActiveBattler][4] << 16) | (gBattleBufferA[gActiveBattler][5] << 24));
gBattlerFuncs[gActiveBattler] = CompleteOnFinishedStatusAnimation; gBattlerControllerFuncs[gActiveBattler] = CompleteOnFinishedStatusAnimation;
} }
} }
@ -1608,16 +1608,16 @@ static void RecordedOpponentHandleCmd40(void)
static void RecordedOpponentHandleHitAnimation(void) static void RecordedOpponentHandleHitAnimation(void)
{ {
if (gSprites[gBankSpriteIds[gActiveBattler]].invisible == TRUE) if (gSprites[gBattlerSpriteIds[gActiveBattler]].invisible == TRUE)
{ {
RecordedOpponentBufferExecCompleted(); RecordedOpponentBufferExecCompleted();
} }
else else
{ {
gDoingBattleAnim = TRUE; gDoingBattleAnim = TRUE;
gSprites[gBankSpriteIds[gActiveBattler]].data[1] = 0; gSprites[gBattlerSpriteIds[gActiveBattler]].data[1] = 0;
DoHitAnimHealthboxEffect(gActiveBattler); DoHitAnimHealthboxEffect(gActiveBattler);
gBattlerFuncs[gActiveBattler] = DoHitAnimBlinkSpriteEffect; gBattlerControllerFuncs[gActiveBattler] = DoHitAnimBlinkSpriteEffect;
} }
} }
@ -1656,7 +1656,7 @@ static void RecordedOpponentHandlePlayFanfareOrBGM(void)
static void RecordedOpponentHandleFaintingCry(void) static void RecordedOpponentHandleFaintingCry(void)
{ {
u16 species = GetMonData(&gEnemyParty[gBattlePartyID[gActiveBattler]], MON_DATA_SPECIES); u16 species = GetMonData(&gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_SPECIES);
PlayCry3(species, 25, 5); PlayCry3(species, 25, 5);
RecordedOpponentBufferExecCompleted(); RecordedOpponentBufferExecCompleted();
@ -1674,14 +1674,14 @@ static void RecordedOpponentHandleIntroTrainerBallThrow(void)
u8 paletteNum; u8 paletteNum;
u8 taskId; u8 taskId;
oamt_add_pos2_onto_pos1(&gSprites[gBankSpriteIds[gActiveBattler]]); oamt_add_pos2_onto_pos1(&gSprites[gBattlerSpriteIds[gActiveBattler]]);
gSprites[gBankSpriteIds[gActiveBattler]].data[0] = 35; gSprites[gBattlerSpriteIds[gActiveBattler]].data[0] = 35;
gSprites[gBankSpriteIds[gActiveBattler]].data[2] = 280; gSprites[gBattlerSpriteIds[gActiveBattler]].data[2] = 280;
gSprites[gBankSpriteIds[gActiveBattler]].data[4] = gSprites[gBankSpriteIds[gActiveBattler]].pos1.y; gSprites[gBattlerSpriteIds[gActiveBattler]].data[4] = gSprites[gBattlerSpriteIds[gActiveBattler]].pos1.y;
gSprites[gBankSpriteIds[gActiveBattler]].callback = sub_80A6EEC; gSprites[gBattlerSpriteIds[gActiveBattler]].callback = sub_80A6EEC;
StoreSpriteCallbackInData6(&gSprites[gBankSpriteIds[gActiveBattler]], sub_818962C); StoreSpriteCallbackInData6(&gSprites[gBattlerSpriteIds[gActiveBattler]], sub_818962C);
taskId = CreateTask(sub_8189548, 5); taskId = CreateTask(sub_8189548, 5);
gTasks[taskId].data[0] = gActiveBattler; gTasks[taskId].data[0] = gActiveBattler;
@ -1690,7 +1690,7 @@ static void RecordedOpponentHandleIntroTrainerBallThrow(void)
gTasks[gUnknown_020244B4[gActiveBattler]].func = sub_8073C30; gTasks[gUnknown_020244B4[gActiveBattler]].func = sub_8073C30;
gBattleSpritesDataPtr->animationData->field_9_x1 = 1; gBattleSpritesDataPtr->animationData->field_9_x1 = 1;
gBattlerFuncs[gActiveBattler] = nullsub_70; gBattlerControllerFuncs[gActiveBattler] = nullsub_70;
} }
static void sub_8189548(u8 taskId) static void sub_8189548(u8 taskId)
@ -1700,19 +1700,19 @@ static void sub_8189548(u8 taskId)
gActiveBattler = gTasks[taskId].data[0]; gActiveBattler = gTasks[taskId].data[0];
if (!IsDoubleBattle() || (gBattleTypeFlags & BATTLE_TYPE_MULTI)) if (!IsDoubleBattle() || (gBattleTypeFlags & BATTLE_TYPE_MULTI))
{ {
gBattleBufferA[gActiveBattler][1] = gBattlePartyID[gActiveBattler]; gBattleBufferA[gActiveBattler][1] = gBattlerPartyIndexes[gActiveBattler];
sub_81885D8(gActiveBattler, FALSE); sub_81885D8(gActiveBattler, FALSE);
} }
else else
{ {
gBattleBufferA[gActiveBattler][1] = gBattlePartyID[gActiveBattler]; gBattleBufferA[gActiveBattler][1] = gBattlerPartyIndexes[gActiveBattler];
sub_81885D8(gActiveBattler, FALSE); sub_81885D8(gActiveBattler, FALSE);
gActiveBattler ^= BIT_FLANK; gActiveBattler ^= BIT_FLANK;
gBattleBufferA[gActiveBattler][1] = gBattlePartyID[gActiveBattler]; gBattleBufferA[gActiveBattler][1] = gBattlerPartyIndexes[gActiveBattler];
sub_81885D8(gActiveBattler, FALSE); sub_81885D8(gActiveBattler, FALSE);
gActiveBattler ^= BIT_FLANK; gActiveBattler ^= BIT_FLANK;
} }
gBattlerFuncs[gActiveBattler] = sub_818686C; gBattlerControllerFuncs[gActiveBattler] = sub_818686C;
gActiveBattler = savedActiveBank; gActiveBattler = savedActiveBank;
DestroyTask(taskId); DestroyTask(taskId);
} }
@ -1753,7 +1753,7 @@ static void RecordedOpponentHandleDrawPartyStatusSummary(void)
if (gBattleBufferA[gActiveBattler][2] != 0) if (gBattleBufferA[gActiveBattler][2] != 0)
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_5 = 0x5D; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_5 = 0x5D;
gBattlerFuncs[gActiveBattler] = sub_818975C; gBattlerControllerFuncs[gActiveBattler] = sub_818975C;
} }
} }
@ -1780,9 +1780,9 @@ static void RecordedOpponentHandleCmd50(void)
static void RecordedOpponentHandleSpriteInvisibility(void) static void RecordedOpponentHandleSpriteInvisibility(void)
{ {
if (IsBankSpritePresent(gActiveBattler)) if (IsBattlerSpritePresent(gActiveBattler))
{ {
gSprites[gBankSpriteIds[gActiveBattler]].invisible = gBattleBufferA[gActiveBattler][1]; gSprites[gBattlerSpriteIds[gActiveBattler]].invisible = gBattleBufferA[gActiveBattler][1];
CopyBattleSpriteInvisibility(gActiveBattler); CopyBattleSpriteInvisibility(gActiveBattler);
} }
RecordedOpponentBufferExecCompleted(); RecordedOpponentBufferExecCompleted();
@ -1798,7 +1798,7 @@ static void RecordedOpponentHandleBattleAnimation(void)
if (TryHandleLaunchBattleTableAnimation(gActiveBattler, gActiveBattler, gActiveBattler, animationId, argument)) if (TryHandleLaunchBattleTableAnimation(gActiveBattler, gActiveBattler, gActiveBattler, animationId, argument))
RecordedOpponentBufferExecCompleted(); RecordedOpponentBufferExecCompleted();
else else
gBattlerFuncs[gActiveBattler] = CompleteOnFinishedBattleAnimation; gBattlerControllerFuncs[gActiveBattler] = CompleteOnFinishedBattleAnimation;
} }
} }
@ -1822,7 +1822,7 @@ static void RecordedOpponentHandleCmd55(void)
FadeOutMapMusic(5); FadeOutMapMusic(5);
BeginFastPaletteFade(3); BeginFastPaletteFade(3);
RecordedOpponentBufferExecCompleted(); RecordedOpponentBufferExecCompleted();
gBattlerFuncs[gActiveBattler] = sub_80587B0; gBattlerControllerFuncs[gActiveBattler] = sub_80587B0;
} }
static void nullsub_119(void) static void nullsub_119(void)

View File

@ -24,21 +24,21 @@
#include "pokeball.h" #include "pokeball.h"
#include "data2.h" #include "data2.h"
extern u32 gBattleExecBuffer; extern u32 gBattleControllerExecFlags;
extern u8 gActiveBattler; extern u8 gActiveBattler;
extern u8 gBankSpriteIds[MAX_BATTLERS_COUNT]; extern u8 gBattlerSpriteIds[MAX_BATTLERS_COUNT];
extern u8 gActionSelectionCursor[MAX_BATTLERS_COUNT]; extern u8 gActionSelectionCursor[MAX_BATTLERS_COUNT];
extern u8 gBattlersCount; extern u8 gBattlersCount;
extern bool8 gDoingBattleAnim; extern bool8 gDoingBattleAnim;
extern void (*gBattlerFuncs[MAX_BATTLERS_COUNT])(void); extern void (*gBattlerControllerFuncs[MAX_BATTLERS_COUNT])(void);
extern void (*gPreBattleCallback1)(void); extern void (*gPreBattleCallback1)(void);
extern u16 gBattlePartyID[MAX_BATTLERS_COUNT]; extern u16 gBattlerPartyIndexes[MAX_BATTLERS_COUNT];
extern u8 gBattleBufferA[MAX_BATTLERS_COUNT][0x200]; extern u8 gBattleBufferA[MAX_BATTLERS_COUNT][0x200];
extern u8 gBattleBufferB[MAX_BATTLERS_COUNT][0x200]; extern u8 gBattleBufferB[MAX_BATTLERS_COUNT][0x200];
extern struct BattlePokemon gBattleMons[MAX_BATTLERS_COUNT]; extern struct BattlePokemon gBattleMons[MAX_BATTLERS_COUNT];
extern struct SpriteTemplate gUnknown_0202499C; extern struct SpriteTemplate gUnknown_0202499C;
extern u16 gSpecialVar_ItemId; extern u16 gSpecialVar_ItemId;
extern u8 gHealthBoxesIds[MAX_BATTLERS_COUNT]; extern u8 gHealthboxSpriteIds[MAX_BATTLERS_COUNT];
extern u8 gBattleOutcome; extern u8 gBattleOutcome;
extern u16 gBattle_BG0_X; extern u16 gBattle_BG0_X;
extern u16 gBattle_BG0_Y; extern u16 gBattle_BG0_Y;
@ -48,7 +48,7 @@ extern u8 gUnknown_03005D7C[MAX_BATTLERS_COUNT];
extern u8 gBattleMonForms[MAX_BATTLERS_COUNT]; extern u8 gBattleMonForms[MAX_BATTLERS_COUNT];
extern u16 gPartnerTrainerId; extern u16 gPartnerTrainerId;
extern u8 GetFrontierTrainerFrontSpriteId(u16 trainerId); extern u8 GetFrontierTrainerFrontSpriteId(u16 trainerId);
extern u8 gBattleDefender; extern u8 gBattleMoveTarget;
extern u8 gAbsentBattlerFlags; extern u8 gAbsentBattlerFlags;
extern u8 gUnknown_020244B4[]; extern u8 gUnknown_020244B4[];
extern u32 gTransformedPersonalities[MAX_BATTLERS_COUNT]; extern u32 gTransformedPersonalities[MAX_BATTLERS_COUNT];
@ -201,12 +201,12 @@ static void nullsub_120(void)
void SetControllerToRecordedPlayer(void) void SetControllerToRecordedPlayer(void)
{ {
gBattlerFuncs[gActiveBattler] = RecordedPlayerBufferRunCommand; gBattlerControllerFuncs[gActiveBattler] = RecordedPlayerBufferRunCommand;
} }
static void RecordedPlayerBufferRunCommand(void) static void RecordedPlayerBufferRunCommand(void)
{ {
if (gBattleExecBuffer & gBitTable[gActiveBattler]) if (gBattleControllerExecFlags & gBitTable[gActiveBattler])
{ {
if (gBattleBufferA[gActiveBattler][0] < ARRAY_COUNT(sRecordedPlayerBufferCommands)) if (gBattleBufferA[gActiveBattler][0] < ARRAY_COUNT(sRecordedPlayerBufferCommands))
sRecordedPlayerBufferCommands[gBattleBufferA[gActiveBattler][0]](); sRecordedPlayerBufferCommands[gBattleBufferA[gActiveBattler][0]]();
@ -217,17 +217,17 @@ static void RecordedPlayerBufferRunCommand(void)
static void CompleteOnBankSpriteCallbackDummy(void) static void CompleteOnBankSpriteCallbackDummy(void)
{ {
if (gSprites[gBankSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy) if (gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
RecordedPlayerBufferExecCompleted(); RecordedPlayerBufferExecCompleted();
} }
static void sub_81899F0(void) static void sub_81899F0(void)
{ {
if (gSprites[gBankSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy) if (gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
{ {
nullsub_25(0); nullsub_25(0);
FreeSpriteOamMatrix(&gSprites[gBankSpriteIds[gActiveBattler]]); FreeSpriteOamMatrix(&gSprites[gBattlerSpriteIds[gActiveBattler]]);
DestroySprite(&gSprites[gBankSpriteIds[gActiveBattler]]); DestroySprite(&gSprites[gBattlerSpriteIds[gActiveBattler]]);
RecordedPlayerBufferExecCompleted(); RecordedPlayerBufferExecCompleted();
} }
} }
@ -249,13 +249,13 @@ static void sub_8189AA0(void)
{ {
if (!IsDoubleBattle() || (IsDoubleBattle() && (gBattleTypeFlags & BATTLE_TYPE_MULTI))) if (!IsDoubleBattle() || (IsDoubleBattle() && (gBattleTypeFlags & BATTLE_TYPE_MULTI)))
{ {
if (gSprites[gHealthBoxesIds[gActiveBattler]].callback == SpriteCallbackDummy) if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
r6 = TRUE; r6 = TRUE;
} }
else else
{ {
if (gSprites[gHealthBoxesIds[gActiveBattler]].callback == SpriteCallbackDummy if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy
&& gSprites[gHealthBoxesIds[gActiveBattler ^ BIT_FLANK]].callback == SpriteCallbackDummy) && gSprites[gHealthboxSpriteIds[gActiveBattler ^ BIT_FLANK]].callback == SpriteCallbackDummy)
{ {
r6 = TRUE; r6 = TRUE;
} }
@ -273,25 +273,25 @@ static void sub_8189AA0(void)
FreeSpriteTilesByTag(0x27F9); FreeSpriteTilesByTag(0x27F9);
FreeSpritePaletteByTag(0x27F9); FreeSpritePaletteByTag(0x27F9);
HandleLowHpMusicChange(&gPlayerParty[gBattlePartyID[gActiveBattler]], gActiveBattler); HandleLowHpMusicChange(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler);
if (IsDoubleBattle()) if (IsDoubleBattle())
HandleLowHpMusicChange(&gPlayerParty[gBattlePartyID[gActiveBattler ^ BIT_FLANK]], gActiveBattler ^ BIT_FLANK); HandleLowHpMusicChange(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler ^ BIT_FLANK]], gActiveBattler ^ BIT_FLANK);
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_9 = 3; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_9 = 3;
gBattlerFuncs[gActiveBattler] = sub_8189A58; gBattlerControllerFuncs[gActiveBattler] = sub_8189A58;
} }
} }
else else
{ {
if (!IsDoubleBattle() || (IsDoubleBattle() && (gBattleTypeFlags & BATTLE_TYPE_MULTI))) if (!IsDoubleBattle() || (IsDoubleBattle() && (gBattleTypeFlags & BATTLE_TYPE_MULTI)))
{ {
if (gSprites[gHealthBoxesIds[gActiveBattler]].callback == SpriteCallbackDummy) if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
r6 = TRUE; r6 = TRUE;
} }
else else
{ {
if (gSprites[gHealthBoxesIds[gActiveBattler]].callback == SpriteCallbackDummy if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy
&& gSprites[gHealthBoxesIds[gActiveBattler ^ BIT_FLANK]].callback == SpriteCallbackDummy) && gSprites[gHealthboxSpriteIds[gActiveBattler ^ BIT_FLANK]].callback == SpriteCallbackDummy)
{ {
r6 = TRUE; r6 = TRUE;
} }
@ -303,7 +303,7 @@ static void sub_8189AA0(void)
if (r6) if (r6)
{ {
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_9 = 3; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_9 = 3;
gBattlerFuncs[gActiveBattler] = sub_8189A58; gBattlerControllerFuncs[gActiveBattler] = sub_8189A58;
} }
} }
} }
@ -317,12 +317,12 @@ static void sub_8189D40(void)
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].flag_x80 if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].flag_x80
&& !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive) && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive)
{ {
sub_8172EF0(gActiveBattler, &gPlayerParty[gBattlePartyID[gActiveBattler]]); sub_8172EF0(gActiveBattler, &gPlayerParty[gBattlerPartyIndexes[gActiveBattler]]);
} }
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].flag_x80 if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].flag_x80
&& !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].ballAnimActive) && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].ballAnimActive)
{ {
sub_8172EF0(gActiveBattler ^ BIT_FLANK, &gPlayerParty[gBattlePartyID[gActiveBattler ^ BIT_FLANK]]); sub_8172EF0(gActiveBattler ^ BIT_FLANK, &gPlayerParty[gBattlerPartyIndexes[gActiveBattler ^ BIT_FLANK]]);
} }
} }
@ -333,13 +333,13 @@ static void sub_8189D40(void)
{ {
if (IsDoubleBattle() && !(gBattleTypeFlags & BATTLE_TYPE_MULTI)) if (IsDoubleBattle() && !(gBattleTypeFlags & BATTLE_TYPE_MULTI))
{ {
UpdateHealthboxAttribute(gHealthBoxesIds[gActiveBattler ^ BIT_FLANK], &gPlayerParty[gBattlePartyID[gActiveBattler ^ BIT_FLANK]], HEALTHBOX_ALL); UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler ^ BIT_FLANK], &gPlayerParty[gBattlerPartyIndexes[gActiveBattler ^ BIT_FLANK]], HEALTHBOX_ALL);
sub_8076918(gActiveBattler ^ BIT_FLANK); sub_8076918(gActiveBattler ^ BIT_FLANK);
SetHealthboxSpriteVisible(gHealthBoxesIds[gActiveBattler ^ BIT_FLANK]); SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler ^ BIT_FLANK]);
} }
UpdateHealthboxAttribute(gHealthBoxesIds[gActiveBattler], &gPlayerParty[gBattlePartyID[gActiveBattler]], HEALTHBOX_ALL); UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler], &gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], HEALTHBOX_ALL);
sub_8076918(gActiveBattler); sub_8076918(gActiveBattler);
SetHealthboxSpriteVisible(gHealthBoxesIds[gActiveBattler]); SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]);
} }
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x80 = 1; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x80 = 1;
} }
@ -367,7 +367,7 @@ static void sub_8189D40(void)
} }
if (r10 && gSprites[gUnknown_03005D7C[gActiveBattler]].callback == SpriteCallbackDummy if (r10 && gSprites[gUnknown_03005D7C[gActiveBattler]].callback == SpriteCallbackDummy
&& gSprites[gBankSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy) && gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
{ {
if (IsDoubleBattle() && !(gBattleTypeFlags & BATTLE_TYPE_MULTI)) if (IsDoubleBattle() && !(gBattleTypeFlags & BATTLE_TYPE_MULTI))
DestroySprite(&gSprites[gUnknown_03005D7C[gActiveBattler ^ BIT_FLANK]]); DestroySprite(&gSprites[gUnknown_03005D7C[gActiveBattler ^ BIT_FLANK]]);
@ -376,43 +376,43 @@ static void sub_8189D40(void)
gBattleSpritesDataPtr->animationData->field_9_x1 = 0; gBattleSpritesDataPtr->animationData->field_9_x1 = 0;
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x20 = 0; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x20 = 0;
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x80 = 0; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x80 = 0;
gBattlerFuncs[gActiveBattler] = sub_8189AA0; gBattlerControllerFuncs[gActiveBattler] = sub_8189AA0;
} }
} }
static void sub_818A064(void) static void sub_818A064(void)
{ {
if (gSprites[gBankSpriteIds[gActiveBattler]].animEnded && gSprites[gBankSpriteIds[gActiveBattler]].pos2.x == 0) if (gSprites[gBattlerSpriteIds[gActiveBattler]].animEnded && gSprites[gBattlerSpriteIds[gActiveBattler]].pos2.x == 0)
RecordedPlayerBufferExecCompleted(); RecordedPlayerBufferExecCompleted();
} }
static void CompleteOnHealthbarDone(void) static void CompleteOnHealthbarDone(void)
{ {
s16 hpValue = sub_8074AA0(gActiveBattler, gHealthBoxesIds[gActiveBattler], HEALTH_BAR, 0); s16 hpValue = sub_8074AA0(gActiveBattler, gHealthboxSpriteIds[gActiveBattler], HEALTH_BAR, 0);
SetHealthboxSpriteVisible(gHealthBoxesIds[gActiveBattler]); SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]);
if (hpValue != -1) if (hpValue != -1)
{ {
UpdateHpTextInHealthbox(gHealthBoxesIds[gActiveBattler], hpValue, HP_CURRENT); UpdateHpTextInHealthbox(gHealthboxSpriteIds[gActiveBattler], hpValue, HP_CURRENT);
} }
else else
{ {
HandleLowHpMusicChange(&gPlayerParty[gBattlePartyID[gActiveBattler]], gActiveBattler); HandleLowHpMusicChange(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler);
RecordedPlayerBufferExecCompleted(); RecordedPlayerBufferExecCompleted();
} }
} }
static void sub_818A114(void) static void sub_818A114(void)
{ {
if (gSprites[gBankSpriteIds[gActiveBattler]].pos1.y + gSprites[gBankSpriteIds[gActiveBattler]].pos2.y > DISPLAY_HEIGHT) if (gSprites[gBattlerSpriteIds[gActiveBattler]].pos1.y + gSprites[gBattlerSpriteIds[gActiveBattler]].pos2.y > DISPLAY_HEIGHT)
{ {
u16 species = GetMonData(&gPlayerParty[gBattlePartyID[gActiveBattler]], MON_DATA_SPECIES); u16 species = GetMonData(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_SPECIES);
nullsub_24(species); nullsub_24(species);
FreeOamMatrix(gSprites[gBankSpriteIds[gActiveBattler]].oam.matrixNum); FreeOamMatrix(gSprites[gBattlerSpriteIds[gActiveBattler]].oam.matrixNum);
DestroySprite(&gSprites[gBankSpriteIds[gActiveBattler]]); DestroySprite(&gSprites[gBattlerSpriteIds[gActiveBattler]]);
SetHealthboxSpriteInvisible(gHealthBoxesIds[gActiveBattler]); SetHealthboxSpriteInvisible(gHealthboxSpriteIds[gActiveBattler]);
RecordedPlayerBufferExecCompleted(); RecordedPlayerBufferExecCompleted();
} }
} }
@ -421,9 +421,9 @@ static void sub_818A1B0(void)
{ {
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive) if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive)
{ {
FreeSpriteOamMatrix(&gSprites[gBankSpriteIds[gActiveBattler]]); FreeSpriteOamMatrix(&gSprites[gBattlerSpriteIds[gActiveBattler]]);
DestroySprite(&gSprites[gBankSpriteIds[gActiveBattler]]); DestroySprite(&gSprites[gBattlerSpriteIds[gActiveBattler]]);
SetHealthboxSpriteInvisible(gHealthBoxesIds[gActiveBattler]); SetHealthboxSpriteInvisible(gHealthboxSpriteIds[gActiveBattler]);
RecordedPlayerBufferExecCompleted(); RecordedPlayerBufferExecCompleted();
} }
} }
@ -436,7 +436,7 @@ static void CompleteOnInactiveTextPrinter(void)
static void DoHitAnimBlinkSpriteEffect(void) static void DoHitAnimBlinkSpriteEffect(void)
{ {
u8 spriteId = gBankSpriteIds[gActiveBattler]; u8 spriteId = gBattlerSpriteIds[gActiveBattler];
if (gSprites[spriteId].data[1] == 32) if (gSprites[spriteId].data[1] == 32)
{ {
@ -455,20 +455,20 @@ static void DoHitAnimBlinkSpriteEffect(void)
static void sub_818A2B4(void) static void sub_818A2B4(void)
{ {
if (gSprites[gHealthBoxesIds[gActiveBattler]].callback == SpriteCallbackDummy) if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
{ {
CopyBattleSpriteInvisibility(gActiveBattler); CopyBattleSpriteInvisibility(gActiveBattler);
if (gBattleSpritesDataPtr->bankData[gActiveBattler].behindSubstitute) if (gBattleSpritesDataPtr->bankData[gActiveBattler].behindSubstitute)
InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_MON_TO_SUBSTITUTE); InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_MON_TO_SUBSTITUTE);
gBattlerFuncs[gActiveBattler] = sub_818A328; gBattlerControllerFuncs[gActiveBattler] = sub_818A328;
} }
} }
static void sub_818A328(void) static void sub_818A328(void)
{ {
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive
&& gSprites[gBankSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy) && gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
{ {
RecordedPlayerBufferExecCompleted(); RecordedPlayerBufferExecCompleted();
} }
@ -485,13 +485,13 @@ static void sub_818A37C(void)
FreeSpritePaletteByTag(0x27F9); FreeSpritePaletteByTag(0x27F9);
CreateTask(c3_0802FDF4, 10); CreateTask(c3_0802FDF4, 10);
HandleLowHpMusicChange(&gPlayerParty[gBattlePartyID[gActiveBattler]], gActiveBattler); HandleLowHpMusicChange(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler);
StartSpriteAnim(&gSprites[gBankSpriteIds[gActiveBattler]], 0); StartSpriteAnim(&gSprites[gBattlerSpriteIds[gActiveBattler]], 0);
UpdateHealthboxAttribute(gHealthBoxesIds[gActiveBattler], &gPlayerParty[gBattlePartyID[gActiveBattler]], HEALTHBOX_ALL); UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler], &gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], HEALTHBOX_ALL);
sub_8076918(gActiveBattler); sub_8076918(gActiveBattler);
SetHealthboxSpriteVisible(gHealthBoxesIds[gActiveBattler]); SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]);
gBattlerFuncs[gActiveBattler] = sub_818A2B4; gBattlerControllerFuncs[gActiveBattler] = sub_818A2B4;
} }
} }
@ -500,20 +500,20 @@ static void sub_818A470(void)
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].flag_x80 if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].flag_x80
&& !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive) && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive)
{ {
sub_8172EF0(gActiveBattler, &gPlayerParty[gBattlePartyID[gActiveBattler]]); sub_8172EF0(gActiveBattler, &gPlayerParty[gBattlerPartyIndexes[gActiveBattler]]);
} }
if (gSprites[gUnknown_03005D7C[gActiveBattler]].callback == SpriteCallbackDummy if (gSprites[gUnknown_03005D7C[gActiveBattler]].callback == SpriteCallbackDummy
&& !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive) && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive)
{ {
DestroySprite(&gSprites[gUnknown_03005D7C[gActiveBattler]]); DestroySprite(&gSprites[gUnknown_03005D7C[gActiveBattler]]);
gBattlerFuncs[gActiveBattler] = sub_818A37C; gBattlerControllerFuncs[gActiveBattler] = sub_818A37C;
} }
} }
static void RecordedPlayerBufferExecCompleted(void) static void RecordedPlayerBufferExecCompleted(void)
{ {
gBattlerFuncs[gActiveBattler] = RecordedPlayerBufferRunCommand; gBattlerControllerFuncs[gActiveBattler] = RecordedPlayerBufferRunCommand;
if (gBattleTypeFlags & BATTLE_TYPE_LINK) if (gBattleTypeFlags & BATTLE_TYPE_LINK)
{ {
u8 playerId = GetMultiplayerId(); u8 playerId = GetMultiplayerId();
@ -523,7 +523,7 @@ static void RecordedPlayerBufferExecCompleted(void)
} }
else else
{ {
gBattleExecBuffer &= ~gBitTable[gActiveBattler]; gBattleControllerExecFlags &= ~gBitTable[gActiveBattler];
} }
} }
@ -548,7 +548,7 @@ static void RecordedPlayerHandleGetMonData(void)
if (gBattleBufferA[gActiveBattler][2] == 0) if (gBattleBufferA[gActiveBattler][2] == 0)
{ {
size += CopyRecordedPlayerMonData(gBattlePartyID[gActiveBattler], monData); size += CopyRecordedPlayerMonData(gBattlerPartyIndexes[gActiveBattler], monData);
} }
else else
{ {
@ -560,7 +560,7 @@ static void RecordedPlayerHandleGetMonData(void)
monToCheck >>= 1; monToCheck >>= 1;
} }
} }
EmitDataTransfer(1, size, monData); BtlController_EmitDataTransfer(1, size, monData);
RecordedPlayerBufferExecCompleted(); RecordedPlayerBufferExecCompleted();
} }
@ -882,7 +882,7 @@ static void RecordedPlayerHandleSetMonData(void)
if (gBattleBufferA[gActiveBattler][2] == 0) if (gBattleBufferA[gActiveBattler][2] == 0)
{ {
SetRecordedPlayerMonData(gBattlePartyID[gActiveBattler]); SetRecordedPlayerMonData(gBattlerPartyIndexes[gActiveBattler]);
} }
else else
{ {
@ -1112,12 +1112,12 @@ static void SetRecordedPlayerMonData(u8 monId)
break; break;
} }
HandleLowHpMusicChange(&gPlayerParty[gBattlePartyID[gActiveBattler]], gActiveBattler); HandleLowHpMusicChange(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler);
} }
static void RecordedPlayerHandleSetRawMonData(void) static void RecordedPlayerHandleSetRawMonData(void)
{ {
u8 *dst = (u8 *)&gPlayerParty[gBattlePartyID[gActiveBattler]] + gBattleBufferA[gActiveBattler][1]; u8 *dst = (u8 *)&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]] + gBattleBufferA[gActiveBattler][1];
u8 i; u8 i;
for (i = 0; i < gBattleBufferA[gActiveBattler][2]; i++) for (i = 0; i < gBattleBufferA[gActiveBattler][2]; i++)
@ -1130,28 +1130,28 @@ static void RecordedPlayerHandleLoadMonSprite(void)
{ {
u16 species; u16 species;
BattleLoadPlayerMonSpriteGfx(&gPlayerParty[gBattlePartyID[gActiveBattler]], gActiveBattler); BattleLoadPlayerMonSpriteGfx(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler);
species = GetMonData(&gPlayerParty[gBattlePartyID[gActiveBattler]], MON_DATA_SPECIES); species = GetMonData(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_SPECIES);
sub_806A068(species, GetBattlerPosition(gActiveBattler)); sub_806A068(species, GetBattlerPosition(gActiveBattler));
gBankSpriteIds[gActiveBattler] = CreateSprite(&gUnknown_0202499C, gBattlerSpriteIds[gActiveBattler] = CreateSprite(&gUnknown_0202499C,
GetBankCoord(gActiveBattler, 2), GetBattlerSpriteCoord(gActiveBattler, 2),
GetBankSpriteDefault_Y(gActiveBattler), GetBattlerSpriteDefault_Y(gActiveBattler),
sub_80A82E4(gActiveBattler)); sub_80A82E4(gActiveBattler));
gSprites[gBankSpriteIds[gActiveBattler]].pos2.x = -240; gSprites[gBattlerSpriteIds[gActiveBattler]].pos2.x = -240;
gSprites[gBankSpriteIds[gActiveBattler]].data[0] = gActiveBattler; gSprites[gBattlerSpriteIds[gActiveBattler]].data[0] = gActiveBattler;
gSprites[gBankSpriteIds[gActiveBattler]].oam.paletteNum = gActiveBattler; gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = gActiveBattler;
StartSpriteAnim(&gSprites[gBankSpriteIds[gActiveBattler]], gBattleMonForms[gActiveBattler]); StartSpriteAnim(&gSprites[gBattlerSpriteIds[gActiveBattler]], gBattleMonForms[gActiveBattler]);
gBattlerFuncs[gActiveBattler] = sub_818A064; gBattlerControllerFuncs[gActiveBattler] = sub_818A064;
} }
static void RecordedPlayerHandleSwitchInAnim(void) static void RecordedPlayerHandleSwitchInAnim(void)
{ {
ClearTemporarySpeciesSpriteData(gActiveBattler, gBattleBufferA[gActiveBattler][2]); ClearTemporarySpeciesSpriteData(gActiveBattler, gBattleBufferA[gActiveBattler][2]);
gBattlePartyID[gActiveBattler] = gBattleBufferA[gActiveBattler][1]; gBattlerPartyIndexes[gActiveBattler] = gBattleBufferA[gActiveBattler][1];
BattleLoadPlayerMonSpriteGfx(&gPlayerParty[gBattlePartyID[gActiveBattler]], gActiveBattler); BattleLoadPlayerMonSpriteGfx(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler);
sub_818BA6C(gActiveBattler, gBattleBufferA[gActiveBattler][2]); sub_818BA6C(gActiveBattler, gBattleBufferA[gActiveBattler][2]);
gBattlerFuncs[gActiveBattler] = sub_818A470; gBattlerControllerFuncs[gActiveBattler] = sub_818A470;
} }
static void sub_818BA6C(u8 bank, bool8 dontClearSubstituteBit) static void sub_818BA6C(u8 bank, bool8 dontClearSubstituteBit)
@ -1159,28 +1159,28 @@ static void sub_818BA6C(u8 bank, bool8 dontClearSubstituteBit)
u16 species; u16 species;
ClearTemporarySpeciesSpriteData(bank, dontClearSubstituteBit); ClearTemporarySpeciesSpriteData(bank, dontClearSubstituteBit);
gBattlePartyID[bank] = gBattleBufferA[bank][1]; gBattlerPartyIndexes[bank] = gBattleBufferA[bank][1];
species = GetMonData(&gPlayerParty[gBattlePartyID[bank]], MON_DATA_SPECIES); species = GetMonData(&gPlayerParty[gBattlerPartyIndexes[bank]], MON_DATA_SPECIES);
gUnknown_03005D7C[bank] = CreateInvisibleSpriteWithCallback(sub_805D714); gUnknown_03005D7C[bank] = CreateInvisibleSpriteWithCallback(sub_805D714);
sub_806A068(species, GetBattlerPosition(bank)); sub_806A068(species, GetBattlerPosition(bank));
gBankSpriteIds[bank] = CreateSprite( gBattlerSpriteIds[bank] = CreateSprite(
&gUnknown_0202499C, &gUnknown_0202499C,
GetBankCoord(bank, 2), GetBattlerSpriteCoord(bank, 2),
GetBankSpriteDefault_Y(bank), GetBattlerSpriteDefault_Y(bank),
sub_80A82E4(bank)); sub_80A82E4(bank));
gSprites[gUnknown_03005D7C[bank]].data[1] = gBankSpriteIds[bank]; gSprites[gUnknown_03005D7C[bank]].data[1] = gBattlerSpriteIds[bank];
gSprites[gUnknown_03005D7C[bank]].data[2] = bank; gSprites[gUnknown_03005D7C[bank]].data[2] = bank;
gSprites[gBankSpriteIds[bank]].data[0] = bank; gSprites[gBattlerSpriteIds[bank]].data[0] = bank;
gSprites[gBankSpriteIds[bank]].data[2] = species; gSprites[gBattlerSpriteIds[bank]].data[2] = species;
gSprites[gBankSpriteIds[bank]].oam.paletteNum = bank; gSprites[gBattlerSpriteIds[bank]].oam.paletteNum = bank;
StartSpriteAnim(&gSprites[gBankSpriteIds[bank]], gBattleMonForms[bank]); StartSpriteAnim(&gSprites[gBattlerSpriteIds[bank]], gBattleMonForms[bank]);
gSprites[gBankSpriteIds[bank]].invisible = TRUE; gSprites[gBattlerSpriteIds[bank]].invisible = TRUE;
gSprites[gBankSpriteIds[bank]].callback = SpriteCallbackDummy; gSprites[gBattlerSpriteIds[bank]].callback = SpriteCallbackDummy;
gSprites[gUnknown_03005D7C[bank]].data[0] = DoPokeballSendOutAnimation(0, POKEBALL_PLAYER_SENDOUT); gSprites[gUnknown_03005D7C[bank]].data[0] = DoPokeballSendOutAnimation(0, POKEBALL_PLAYER_SENDOUT);
} }
@ -1190,13 +1190,13 @@ static void RecordedPlayerHandleReturnMonToBall(void)
if (gBattleBufferA[gActiveBattler][1] == 0) if (gBattleBufferA[gActiveBattler][1] == 0)
{ {
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0;
gBattlerFuncs[gActiveBattler] = DoSwitchOutAnimation; gBattlerControllerFuncs[gActiveBattler] = DoSwitchOutAnimation;
} }
else else
{ {
FreeSpriteOamMatrix(&gSprites[gBankSpriteIds[gActiveBattler]]); FreeSpriteOamMatrix(&gSprites[gBattlerSpriteIds[gActiveBattler]]);
DestroySprite(&gSprites[gBankSpriteIds[gActiveBattler]]); DestroySprite(&gSprites[gBattlerSpriteIds[gActiveBattler]]);
SetHealthboxSpriteInvisible(gHealthBoxesIds[gActiveBattler]); SetHealthboxSpriteInvisible(gHealthboxSpriteIds[gActiveBattler]);
RecordedPlayerBufferExecCompleted(); RecordedPlayerBufferExecCompleted();
} }
} }
@ -1216,7 +1216,7 @@ static void DoSwitchOutAnimation(void)
{ {
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0;
InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SWITCH_OUT_PLAYER_MON); InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SWITCH_OUT_PLAYER_MON);
gBattlerFuncs[gActiveBattler] = sub_818A1B0; gBattlerControllerFuncs[gActiveBattler] = sub_818A1B0;
} }
break; break;
} }
@ -1268,29 +1268,29 @@ static void RecordedPlayerHandleDrawTrainerPic(void)
trainerPicId = PlayerGenderToFrontTrainerPicId(gSaveBlock2Ptr->playerGender); trainerPicId = PlayerGenderToFrontTrainerPicId(gSaveBlock2Ptr->playerGender);
DecompressTrainerFrontPic(trainerPicId, gActiveBattler); DecompressTrainerFrontPic(trainerPicId, gActiveBattler);
sub_806A1C0(trainerPicId, GetBattlerPosition(gActiveBattler)); sub_806A1C0(trainerPicId, GetBattlerPosition(gActiveBattler));
gBankSpriteIds[gActiveBattler] = CreateSprite(&gUnknown_0202499C, xPos, yPos, sub_80A82E4(gActiveBattler)); gBattlerSpriteIds[gActiveBattler] = CreateSprite(&gUnknown_0202499C, xPos, yPos, sub_80A82E4(gActiveBattler));
gSprites[gBankSpriteIds[gActiveBattler]].oam.paletteNum = IndexOfSpritePaletteTag(gTrainerFrontPicPaletteTable[trainerPicId].tag); gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = IndexOfSpritePaletteTag(gTrainerFrontPicPaletteTable[trainerPicId].tag);
gSprites[gBankSpriteIds[gActiveBattler]].pos2.x = 240; gSprites[gBattlerSpriteIds[gActiveBattler]].pos2.x = 240;
gSprites[gBankSpriteIds[gActiveBattler]].pos2.y = 48; gSprites[gBattlerSpriteIds[gActiveBattler]].pos2.y = 48;
gSprites[gBankSpriteIds[gActiveBattler]].data[0] = -2; gSprites[gBattlerSpriteIds[gActiveBattler]].data[0] = -2;
gSprites[gBankSpriteIds[gActiveBattler]].callback = sub_805D7AC; gSprites[gBattlerSpriteIds[gActiveBattler]].callback = sub_805D7AC;
gSprites[gBankSpriteIds[gActiveBattler]].oam.affineMode = 0; gSprites[gBattlerSpriteIds[gActiveBattler]].oam.affineMode = 0;
gSprites[gBankSpriteIds[gActiveBattler]].hFlip = 1; gSprites[gBattlerSpriteIds[gActiveBattler]].hFlip = 1;
} }
else else
{ {
DecompressTrainerBackPic(trainerPicId, gActiveBattler); DecompressTrainerBackPic(trainerPicId, gActiveBattler);
sub_806A12C(trainerPicId, GetBattlerPosition(gActiveBattler)); sub_806A12C(trainerPicId, GetBattlerPosition(gActiveBattler));
gBankSpriteIds[gActiveBattler] = CreateSprite(&gUnknown_0202499C, xPos, yPos, sub_80A82E4(gActiveBattler)); gBattlerSpriteIds[gActiveBattler] = CreateSprite(&gUnknown_0202499C, xPos, yPos, sub_80A82E4(gActiveBattler));
gSprites[gBankSpriteIds[gActiveBattler]].oam.paletteNum = gActiveBattler; gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = gActiveBattler;
gSprites[gBankSpriteIds[gActiveBattler]].pos2.x = 240; gSprites[gBattlerSpriteIds[gActiveBattler]].pos2.x = 240;
gSprites[gBankSpriteIds[gActiveBattler]].data[0] = -2; gSprites[gBattlerSpriteIds[gActiveBattler]].data[0] = -2;
gSprites[gBankSpriteIds[gActiveBattler]].callback = sub_805D7AC; gSprites[gBattlerSpriteIds[gActiveBattler]].callback = sub_805D7AC;
} }
gBattlerFuncs[gActiveBattler] = CompleteOnBankSpriteCallbackDummy; gBattlerControllerFuncs[gActiveBattler] = CompleteOnBankSpriteCallbackDummy;
} }
static void RecordedPlayerHandleTrainerSlide(void) static void RecordedPlayerHandleTrainerSlide(void)
@ -1300,13 +1300,13 @@ static void RecordedPlayerHandleTrainerSlide(void)
static void RecordedPlayerHandleTrainerSlideBack(void) static void RecordedPlayerHandleTrainerSlideBack(void)
{ {
oamt_add_pos2_onto_pos1(&gSprites[gBankSpriteIds[gActiveBattler]]); oamt_add_pos2_onto_pos1(&gSprites[gBattlerSpriteIds[gActiveBattler]]);
gSprites[gBankSpriteIds[gActiveBattler]].data[0] = 35; gSprites[gBattlerSpriteIds[gActiveBattler]].data[0] = 35;
gSprites[gBankSpriteIds[gActiveBattler]].data[2] = -40; gSprites[gBattlerSpriteIds[gActiveBattler]].data[2] = -40;
gSprites[gBankSpriteIds[gActiveBattler]].data[4] = gSprites[gBankSpriteIds[gActiveBattler]].pos1.y; gSprites[gBattlerSpriteIds[gActiveBattler]].data[4] = gSprites[gBattlerSpriteIds[gActiveBattler]].pos1.y;
gSprites[gBankSpriteIds[gActiveBattler]].callback = sub_80A6EEC; gSprites[gBattlerSpriteIds[gActiveBattler]].callback = sub_80A6EEC;
StoreSpriteCallbackInData6(&gSprites[gBankSpriteIds[gActiveBattler]], SpriteCallbackDummy); StoreSpriteCallbackInData6(&gSprites[gBattlerSpriteIds[gActiveBattler]], SpriteCallbackDummy);
gBattlerFuncs[gActiveBattler] = sub_81899F0; gBattlerControllerFuncs[gActiveBattler] = sub_81899F0;
} }
static void RecordedPlayerHandleFaintAnimation(void) static void RecordedPlayerHandleFaintAnimation(void)
@ -1322,12 +1322,12 @@ static void RecordedPlayerHandleFaintAnimation(void)
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive) if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive)
{ {
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0;
HandleLowHpMusicChange(&gPlayerParty[gBattlePartyID[gActiveBattler]], gActiveBattler); HandleLowHpMusicChange(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler);
PlaySE12WithPanning(SE_POKE_DEAD, -64); PlaySE12WithPanning(SE_POKE_DEAD, -64);
gSprites[gBankSpriteIds[gActiveBattler]].data[1] = 0; gSprites[gBattlerSpriteIds[gActiveBattler]].data[1] = 0;
gSprites[gBankSpriteIds[gActiveBattler]].data[2] = 5; gSprites[gBattlerSpriteIds[gActiveBattler]].data[2] = 5;
gSprites[gBankSpriteIds[gActiveBattler]].callback = sub_8039C00; gSprites[gBattlerSpriteIds[gActiveBattler]].callback = sub_8039C00;
gBattlerFuncs[gActiveBattler] = sub_818A114; gBattlerControllerFuncs[gActiveBattler] = sub_818A114;
} }
} }
} }
@ -1372,7 +1372,7 @@ static void RecordedPlayerHandleMoveAnimation(void)
else else
{ {
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0;
gBattlerFuncs[gActiveBattler] = RecordedPlayerDoMoveAnimation; gBattlerControllerFuncs[gActiveBattler] = RecordedPlayerDoMoveAnimation;
} }
} }
} }
@ -1435,7 +1435,7 @@ static void RecordedPlayerHandlePrintString(void)
stringId = (u16*)(&gBattleBufferA[gActiveBattler][2]); stringId = (u16*)(&gBattleBufferA[gActiveBattler][2]);
BufferStringBattle(*stringId); BufferStringBattle(*stringId);
BattleHandleAddTextPrinter(gDisplayedStringBattle, 0); BattleHandleAddTextPrinter(gDisplayedStringBattle, 0);
gBattlerFuncs[gActiveBattler] = CompleteOnInactiveTextPrinter; gBattlerControllerFuncs[gActiveBattler] = CompleteOnInactiveTextPrinter;
} }
static void RecordedPlayerHandlePrintSelectionString(void) static void RecordedPlayerHandlePrintSelectionString(void)
@ -1447,7 +1447,7 @@ static void ChooseActionInBattlePalace(void)
{ {
if (gBattleCommunication[4] >= gBattlersCount / 2) if (gBattleCommunication[4] >= gBattlersCount / 2)
{ {
EmitTwoReturnValues(1, RecordedBattle_ReadBankAction(gActiveBattler), 0); BtlController_EmitTwoReturnValues(1, RecordedBattle_GetBankAction(gActiveBattler), 0);
RecordedPlayerBufferExecCompleted(); RecordedPlayerBufferExecCompleted();
} }
} }
@ -1456,11 +1456,11 @@ static void RecordedPlayerHandleChooseAction(void)
{ {
if (gBattleTypeFlags & BATTLE_TYPE_PALACE) if (gBattleTypeFlags & BATTLE_TYPE_PALACE)
{ {
gBattlerFuncs[gActiveBattler] = ChooseActionInBattlePalace; gBattlerControllerFuncs[gActiveBattler] = ChooseActionInBattlePalace;
} }
else else
{ {
EmitTwoReturnValues(1, RecordedBattle_ReadBankAction(gActiveBattler), 0); BtlController_EmitTwoReturnValues(1, RecordedBattle_GetBankAction(gActiveBattler), 0);
RecordedPlayerBufferExecCompleted(); RecordedPlayerBufferExecCompleted();
} }
} }
@ -1474,13 +1474,13 @@ static void RecordedPlayerHandleChooseMove(void)
{ {
if (gBattleTypeFlags & BATTLE_TYPE_PALACE) if (gBattleTypeFlags & BATTLE_TYPE_PALACE)
{ {
EmitTwoReturnValues(1, 10, ChooseMoveAndTargetInBattlePalace()); BtlController_EmitTwoReturnValues(1, 10, ChooseMoveAndTargetInBattlePalace());
} }
else else
{ {
u8 moveId = RecordedBattle_ReadBankAction(gActiveBattler); u8 moveId = RecordedBattle_GetBankAction(gActiveBattler);
u8 target = RecordedBattle_ReadBankAction(gActiveBattler); u8 target = RecordedBattle_GetBankAction(gActiveBattler);
EmitTwoReturnValues(1, 10, moveId | (target << 8)); BtlController_EmitTwoReturnValues(1, 10, moveId | (target << 8));
} }
RecordedPlayerBufferExecCompleted(); RecordedPlayerBufferExecCompleted();
@ -1493,8 +1493,8 @@ static void RecordedPlayerHandleChooseItem(void)
static void RecordedPlayerHandleChoosePokemon(void) static void RecordedPlayerHandleChoosePokemon(void)
{ {
*(gBattleStruct->monToSwitchIntoId + gActiveBattler) = RecordedBattle_ReadBankAction(gActiveBattler); *(gBattleStruct->monToSwitchIntoId + gActiveBattler) = RecordedBattle_GetBankAction(gActiveBattler);
EmitChosenMonReturnValue(1, *(gBattleStruct->monToSwitchIntoId + gActiveBattler), NULL); BtlController_EmitChosenMonReturnValue(1, *(gBattleStruct->monToSwitchIntoId + gActiveBattler), NULL);
RecordedPlayerBufferExecCompleted(); RecordedPlayerBufferExecCompleted();
} }
@ -1512,20 +1512,20 @@ static void RecordedPlayerHandleHealthBarUpdate(void)
if (hpVal != INSTANT_HP_BAR_DROP) if (hpVal != INSTANT_HP_BAR_DROP)
{ {
u32 maxHP = GetMonData(&gPlayerParty[gBattlePartyID[gActiveBattler]], MON_DATA_MAX_HP); u32 maxHP = GetMonData(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_MAX_HP);
u32 curHP = GetMonData(&gPlayerParty[gBattlePartyID[gActiveBattler]], MON_DATA_HP); u32 curHP = GetMonData(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_HP);
SetBattleBarStruct(gActiveBattler, gHealthBoxesIds[gActiveBattler], maxHP, curHP, hpVal); SetBattleBarStruct(gActiveBattler, gHealthboxSpriteIds[gActiveBattler], maxHP, curHP, hpVal);
} }
else else
{ {
u32 maxHP = GetMonData(&gPlayerParty[gBattlePartyID[gActiveBattler]], MON_DATA_MAX_HP); u32 maxHP = GetMonData(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_MAX_HP);
SetBattleBarStruct(gActiveBattler, gHealthBoxesIds[gActiveBattler], maxHP, 0, hpVal); SetBattleBarStruct(gActiveBattler, gHealthboxSpriteIds[gActiveBattler], maxHP, 0, hpVal);
UpdateHpTextInHealthbox(gHealthBoxesIds[gActiveBattler], 0, HP_CURRENT); UpdateHpTextInHealthbox(gHealthboxSpriteIds[gActiveBattler], 0, HP_CURRENT);
} }
gBattlerFuncs[gActiveBattler] = CompleteOnHealthbarDone; gBattlerControllerFuncs[gActiveBattler] = CompleteOnHealthbarDone;
} }
static void RecordedPlayerHandleExpUpdate(void) static void RecordedPlayerHandleExpUpdate(void)
@ -1539,10 +1539,10 @@ static void RecordedPlayerHandleStatusIconUpdate(void)
{ {
u8 bank; u8 bank;
UpdateHealthboxAttribute(gHealthBoxesIds[gActiveBattler], &gPlayerParty[gBattlePartyID[gActiveBattler]], HEALTHBOX_STATUS_ICON); UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler], &gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], HEALTHBOX_STATUS_ICON);
bank = gActiveBattler; bank = gActiveBattler;
gBattleSpritesDataPtr->healthBoxesData[bank].statusAnimActive = 0; gBattleSpritesDataPtr->healthBoxesData[bank].statusAnimActive = 0;
gBattlerFuncs[gActiveBattler] = CompleteOnFinishedStatusAnimation; gBattlerControllerFuncs[gActiveBattler] = CompleteOnFinishedStatusAnimation;
} }
} }
@ -1552,7 +1552,7 @@ static void RecordedPlayerHandleStatusAnimation(void)
{ {
InitAndLaunchChosenStatusAnimation(gBattleBufferA[gActiveBattler][1], InitAndLaunchChosenStatusAnimation(gBattleBufferA[gActiveBattler][1],
gBattleBufferA[gActiveBattler][2] | (gBattleBufferA[gActiveBattler][3] << 8) | (gBattleBufferA[gActiveBattler][4] << 16) | (gBattleBufferA[gActiveBattler][5] << 24)); gBattleBufferA[gActiveBattler][2] | (gBattleBufferA[gActiveBattler][3] << 8) | (gBattleBufferA[gActiveBattler][4] << 16) | (gBattleBufferA[gActiveBattler][5] << 24));
gBattlerFuncs[gActiveBattler] = CompleteOnFinishedStatusAnimation; gBattlerControllerFuncs[gActiveBattler] = CompleteOnFinishedStatusAnimation;
} }
} }
@ -1627,16 +1627,16 @@ static void RecordedPlayerHandleCmd40(void)
static void RecordedPlayerHandleHitAnimation(void) static void RecordedPlayerHandleHitAnimation(void)
{ {
if (gSprites[gBankSpriteIds[gActiveBattler]].invisible == TRUE) if (gSprites[gBattlerSpriteIds[gActiveBattler]].invisible == TRUE)
{ {
RecordedPlayerBufferExecCompleted(); RecordedPlayerBufferExecCompleted();
} }
else else
{ {
gDoingBattleAnim = TRUE; gDoingBattleAnim = TRUE;
gSprites[gBankSpriteIds[gActiveBattler]].data[1] = 0; gSprites[gBattlerSpriteIds[gActiveBattler]].data[1] = 0;
DoHitAnimHealthboxEffect(gActiveBattler); DoHitAnimHealthboxEffect(gActiveBattler);
gBattlerFuncs[gActiveBattler] = DoHitAnimBlinkSpriteEffect; gBattlerControllerFuncs[gActiveBattler] = DoHitAnimBlinkSpriteEffect;
} }
} }
@ -1675,7 +1675,7 @@ static void RecordedPlayerHandlePlayFanfareOrBGM(void)
static void RecordedPlayerHandleFaintingCry(void) static void RecordedPlayerHandleFaintingCry(void)
{ {
u16 species = GetMonData(&gPlayerParty[gBattlePartyID[gActiveBattler]], MON_DATA_SPECIES); u16 species = GetMonData(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_SPECIES);
PlayCry3(species, -25, 5); PlayCry3(species, -25, 5);
RecordedPlayerBufferExecCompleted(); RecordedPlayerBufferExecCompleted();
@ -1694,26 +1694,26 @@ static void RecordedPlayerHandleIntroTrainerBallThrow(void)
u8 taskId; u8 taskId;
u32 trainerPicId; u32 trainerPicId;
oamt_add_pos2_onto_pos1(&gSprites[gBankSpriteIds[gActiveBattler]]); oamt_add_pos2_onto_pos1(&gSprites[gBattlerSpriteIds[gActiveBattler]]);
gSprites[gBankSpriteIds[gActiveBattler]].data[0] = 50; gSprites[gBattlerSpriteIds[gActiveBattler]].data[0] = 50;
gSprites[gBankSpriteIds[gActiveBattler]].data[2] = -40; gSprites[gBattlerSpriteIds[gActiveBattler]].data[2] = -40;
gSprites[gBankSpriteIds[gActiveBattler]].data[4] = gSprites[gBankSpriteIds[gActiveBattler]].pos1.y; gSprites[gBattlerSpriteIds[gActiveBattler]].data[4] = gSprites[gBattlerSpriteIds[gActiveBattler]].pos1.y;
gSprites[gBankSpriteIds[gActiveBattler]].callback = sub_80A6EEC; gSprites[gBattlerSpriteIds[gActiveBattler]].callback = sub_80A6EEC;
gSprites[gBankSpriteIds[gActiveBattler]].data[5] = gActiveBattler; gSprites[gBattlerSpriteIds[gActiveBattler]].data[5] = gActiveBattler;
StoreSpriteCallbackInData6(&gSprites[gBankSpriteIds[gActiveBattler]], sub_805CC00); StoreSpriteCallbackInData6(&gSprites[gBattlerSpriteIds[gActiveBattler]], sub_805CC00);
StartSpriteAnim(&gSprites[gBankSpriteIds[gActiveBattler]], 1); StartSpriteAnim(&gSprites[gBattlerSpriteIds[gActiveBattler]], 1);
paletteNum = AllocSpritePalette(0xD6F9); paletteNum = AllocSpritePalette(0xD6F9);
if (gBattleTypeFlags & BATTLE_TYPE_x2000000) if (gBattleTypeFlags & BATTLE_TYPE_x2000000)
trainerPicId = gLinkPlayers[GetBankMultiplayerId(gActiveBattler)].gender; trainerPicId = gLinkPlayers[GetBattlerMultiplayerId(gActiveBattler)].gender;
else else
trainerPicId = gSaveBlock2Ptr->playerGender; trainerPicId = gSaveBlock2Ptr->playerGender;
LoadCompressedPalette(gTrainerBackPicPaletteTable[trainerPicId].data, 0x100 + paletteNum * 16, 32); LoadCompressedPalette(gTrainerBackPicPaletteTable[trainerPicId].data, 0x100 + paletteNum * 16, 32);
gSprites[gBankSpriteIds[gActiveBattler]].oam.paletteNum = paletteNum; gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = paletteNum;
taskId = CreateTask(sub_818CC24, 5); taskId = CreateTask(sub_818CC24, 5);
gTasks[taskId].data[0] = gActiveBattler; gTasks[taskId].data[0] = gActiveBattler;
@ -1722,7 +1722,7 @@ static void RecordedPlayerHandleIntroTrainerBallThrow(void)
gTasks[gUnknown_020244B4[gActiveBattler]].func = sub_8073C30; gTasks[gUnknown_020244B4[gActiveBattler]].func = sub_8073C30;
gBattleSpritesDataPtr->animationData->field_9_x1 = 1; gBattleSpritesDataPtr->animationData->field_9_x1 = 1;
gBattlerFuncs[gActiveBattler] = nullsub_120; gBattlerControllerFuncs[gActiveBattler] = nullsub_120;
} }
static void sub_818CC24(u8 taskId) static void sub_818CC24(u8 taskId)
@ -1738,20 +1738,20 @@ static void sub_818CC24(u8 taskId)
gActiveBattler = gTasks[taskId].data[0]; gActiveBattler = gTasks[taskId].data[0];
if (!IsDoubleBattle() || (gBattleTypeFlags & BATTLE_TYPE_MULTI)) if (!IsDoubleBattle() || (gBattleTypeFlags & BATTLE_TYPE_MULTI))
{ {
gBattleBufferA[gActiveBattler][1] = gBattlePartyID[gActiveBattler]; gBattleBufferA[gActiveBattler][1] = gBattlerPartyIndexes[gActiveBattler];
sub_818BA6C(gActiveBattler, FALSE); sub_818BA6C(gActiveBattler, FALSE);
} }
else else
{ {
gBattleBufferA[gActiveBattler][1] = gBattlePartyID[gActiveBattler]; gBattleBufferA[gActiveBattler][1] = gBattlerPartyIndexes[gActiveBattler];
sub_818BA6C(gActiveBattler, FALSE); sub_818BA6C(gActiveBattler, FALSE);
gActiveBattler ^= BIT_FLANK; gActiveBattler ^= BIT_FLANK;
gBattleBufferA[gActiveBattler][1] = gBattlePartyID[gActiveBattler]; gBattleBufferA[gActiveBattler][1] = gBattlerPartyIndexes[gActiveBattler];
BattleLoadPlayerMonSpriteGfx(&gPlayerParty[gBattlePartyID[gActiveBattler]], gActiveBattler); BattleLoadPlayerMonSpriteGfx(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler);
sub_818BA6C(gActiveBattler, FALSE); sub_818BA6C(gActiveBattler, FALSE);
gActiveBattler ^= BIT_FLANK; gActiveBattler ^= BIT_FLANK;
} }
gBattlerFuncs[gActiveBattler] = sub_8189D40; gBattlerControllerFuncs[gActiveBattler] = sub_8189D40;
gActiveBattler = savedActiveBank; gActiveBattler = savedActiveBank;
DestroyTask(taskId); DestroyTask(taskId);
} }
@ -1772,7 +1772,7 @@ static void RecordedPlayerHandleDrawPartyStatusSummary(void)
if (gBattleBufferA[gActiveBattler][2] != 0) if (gBattleBufferA[gActiveBattler][2] != 0)
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_5 = 0x5D; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_5 = 0x5D;
gBattlerFuncs[gActiveBattler] = sub_818CDF4; gBattlerControllerFuncs[gActiveBattler] = sub_818CDF4;
} }
} }
@ -1799,9 +1799,9 @@ static void RecordedPlayerHandleCmd50(void)
static void RecordedPlayerHandleSpriteInvisibility(void) static void RecordedPlayerHandleSpriteInvisibility(void)
{ {
if (IsBankSpritePresent(gActiveBattler)) if (IsBattlerSpritePresent(gActiveBattler))
{ {
gSprites[gBankSpriteIds[gActiveBattler]].invisible = gBattleBufferA[gActiveBattler][1]; gSprites[gBattlerSpriteIds[gActiveBattler]].invisible = gBattleBufferA[gActiveBattler][1];
CopyBattleSpriteInvisibility(gActiveBattler); CopyBattleSpriteInvisibility(gActiveBattler);
} }
RecordedPlayerBufferExecCompleted(); RecordedPlayerBufferExecCompleted();
@ -1817,7 +1817,7 @@ static void RecordedPlayerHandleBattleAnimation(void)
if (TryHandleLaunchBattleTableAnimation(gActiveBattler, gActiveBattler, gActiveBattler, animationId, argument)) if (TryHandleLaunchBattleTableAnimation(gActiveBattler, gActiveBattler, gActiveBattler, animationId, argument))
RecordedPlayerBufferExecCompleted(); RecordedPlayerBufferExecCompleted();
else else
gBattlerFuncs[gActiveBattler] = CompleteOnFinishedBattleAnimation; gBattlerControllerFuncs[gActiveBattler] = CompleteOnFinishedBattleAnimation;
} }
} }
@ -1837,7 +1837,7 @@ static void RecordedPlayerHandleCmd55(void)
FadeOutMapMusic(5); FadeOutMapMusic(5);
BeginFastPaletteFade(3); BeginFastPaletteFade(3);
RecordedPlayerBufferExecCompleted(); RecordedPlayerBufferExecCompleted();
gBattlerFuncs[gActiveBattler] = sub_80587B0; gBattlerControllerFuncs[gActiveBattler] = sub_80587B0;
} }
static void nullsub_121(void) static void nullsub_121(void)

View File

@ -22,21 +22,21 @@
#include "data2.h" #include "data2.h"
#include "pokeblock.h" #include "pokeblock.h"
extern u32 gBattleExecBuffer; extern u32 gBattleControllerExecFlags;
extern u8 gActiveBattler; extern u8 gActiveBattler;
extern u8 gBankSpriteIds[MAX_BATTLERS_COUNT]; extern u8 gBattlerSpriteIds[MAX_BATTLERS_COUNT];
extern u8 gActionSelectionCursor[MAX_BATTLERS_COUNT]; extern u8 gActionSelectionCursor[MAX_BATTLERS_COUNT];
extern u8 gBattlersCount; extern u8 gBattlersCount;
extern bool8 gDoingBattleAnim; extern bool8 gDoingBattleAnim;
extern void (*gBattlerFuncs[MAX_BATTLERS_COUNT])(void); extern void (*gBattlerControllerFuncs[MAX_BATTLERS_COUNT])(void);
extern void (*gPreBattleCallback1)(void); extern void (*gPreBattleCallback1)(void);
extern u16 gBattlePartyID[MAX_BATTLERS_COUNT]; extern u16 gBattlerPartyIndexes[MAX_BATTLERS_COUNT];
extern u8 gBattleBufferA[MAX_BATTLERS_COUNT][0x200]; extern u8 gBattleBufferA[MAX_BATTLERS_COUNT][0x200];
extern u8 gBattleBufferB[MAX_BATTLERS_COUNT][0x200]; extern u8 gBattleBufferB[MAX_BATTLERS_COUNT][0x200];
extern struct BattlePokemon gBattleMons[MAX_BATTLERS_COUNT]; extern struct BattlePokemon gBattleMons[MAX_BATTLERS_COUNT];
extern struct SpriteTemplate gUnknown_0202499C; extern struct SpriteTemplate gUnknown_0202499C;
extern u16 gSpecialVar_ItemId; extern u16 gSpecialVar_ItemId;
extern u8 gHealthBoxesIds[MAX_BATTLERS_COUNT]; extern u8 gHealthboxSpriteIds[MAX_BATTLERS_COUNT];
extern u8 gBattleOutcome; extern u8 gBattleOutcome;
extern u16 gBattle_BG0_X; extern u16 gBattle_BG0_X;
extern u16 gBattle_BG0_Y; extern u16 gBattle_BG0_Y;
@ -180,12 +180,12 @@ static void nullsub_114(void)
void SetControllerToSafari(void) void SetControllerToSafari(void)
{ {
gBattlerFuncs[gActiveBattler] = SafariBufferRunCommand; gBattlerControllerFuncs[gActiveBattler] = SafariBufferRunCommand;
} }
static void SafariBufferRunCommand(void) static void SafariBufferRunCommand(void)
{ {
if (gBattleExecBuffer & gBitTable[gActiveBattler]) if (gBattleControllerExecFlags & gBitTable[gActiveBattler])
{ {
if (gBattleBufferA[gActiveBattler][0] < ARRAY_COUNT(sSafariBufferCommands)) if (gBattleBufferA[gActiveBattler][0] < ARRAY_COUNT(sSafariBufferCommands))
sSafariBufferCommands[gBattleBufferA[gActiveBattler][0]](); sSafariBufferCommands[gBattleBufferA[gActiveBattler][0]]();
@ -203,16 +203,16 @@ static void HandleInputChooseAction(void)
switch (gActionSelectionCursor[gActiveBattler]) switch (gActionSelectionCursor[gActiveBattler])
{ {
case 0: case 0:
EmitTwoReturnValues(1, ACTION_SAFARI_ZONE_BALL, 0); BtlController_EmitTwoReturnValues(1, ACTION_SAFARI_ZONE_BALL, 0);
break; break;
case 1: case 1:
EmitTwoReturnValues(1, ACTION_POKEBLOCK_CASE, 0); BtlController_EmitTwoReturnValues(1, ACTION_POKEBLOCK_CASE, 0);
break; break;
case 2: case 2:
EmitTwoReturnValues(1, ACTION_GO_NEAR, 0); BtlController_EmitTwoReturnValues(1, ACTION_GO_NEAR, 0);
break; break;
case 3: case 3:
EmitTwoReturnValues(1, ACTION_SAFARI_ZONE_RUN, 0); BtlController_EmitTwoReturnValues(1, ACTION_SAFARI_ZONE_RUN, 0);
break; break;
} }
SafariBufferExecCompleted(); SafariBufferExecCompleted();
@ -261,7 +261,7 @@ static void HandleInputChooseAction(void)
static void CompleteOnBankSpriteCallbackDummy(void) static void CompleteOnBankSpriteCallbackDummy(void)
{ {
if (gSprites[gBankSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy) if (gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
SafariBufferExecCompleted(); SafariBufferExecCompleted();
} }
@ -273,7 +273,7 @@ static void CompleteOnInactiveTextPrinter(void)
static void CompleteOnHealthboxSpriteCallbackDummy(void) static void CompleteOnHealthboxSpriteCallbackDummy(void)
{ {
if (gSprites[gHealthBoxesIds[gActiveBattler]].callback == SpriteCallbackDummy) if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
SafariBufferExecCompleted(); SafariBufferExecCompleted();
} }
@ -297,7 +297,7 @@ static void SafariOpenPokeblockCase(void)
{ {
if (!gPaletteFade.active) if (!gPaletteFade.active)
{ {
gBattlerFuncs[gActiveBattler] = CompleteWhenChosePokeblock; gBattlerControllerFuncs[gActiveBattler] = CompleteWhenChosePokeblock;
FreeAllWindowBuffers(); FreeAllWindowBuffers();
OpenPokeblockCaseInBattle(); OpenPokeblockCaseInBattle();
} }
@ -307,7 +307,7 @@ static void CompleteWhenChosePokeblock(void)
{ {
if (gMain.callback2 == BattleMainCB2 && !gPaletteFade.active) if (gMain.callback2 == BattleMainCB2 && !gPaletteFade.active)
{ {
EmitOneReturnValue(1, gSpecialVar_ItemId); BtlController_EmitOneReturnValue(1, gSpecialVar_ItemId);
SafariBufferExecCompleted(); SafariBufferExecCompleted();
} }
} }
@ -320,7 +320,7 @@ static void CompleteOnFinishedBattleAnimation(void)
static void SafariBufferExecCompleted(void) static void SafariBufferExecCompleted(void)
{ {
gBattlerFuncs[gActiveBattler] = SafariBufferRunCommand; gBattlerControllerFuncs[gActiveBattler] = SafariBufferRunCommand;
if (gBattleTypeFlags & BATTLE_TYPE_LINK) if (gBattleTypeFlags & BATTLE_TYPE_LINK)
{ {
u8 playerId = GetMultiplayerId(); u8 playerId = GetMultiplayerId();
@ -330,7 +330,7 @@ static void SafariBufferExecCompleted(void)
} }
else else
{ {
gBattleExecBuffer &= ~gBitTable[gActiveBattler]; gBattleControllerExecFlags &= ~gBitTable[gActiveBattler];
} }
} }
@ -379,16 +379,16 @@ static void SafariHandleDrawTrainerPic(void)
{ {
DecompressTrainerBackPic(gSaveBlock2Ptr->playerGender, gActiveBattler); DecompressTrainerBackPic(gSaveBlock2Ptr->playerGender, gActiveBattler);
sub_806A12C(gSaveBlock2Ptr->playerGender, GetBattlerPosition(gActiveBattler)); sub_806A12C(gSaveBlock2Ptr->playerGender, GetBattlerPosition(gActiveBattler));
gBankSpriteIds[gActiveBattler] = CreateSprite( gBattlerSpriteIds[gActiveBattler] = CreateSprite(
&gUnknown_0202499C, &gUnknown_0202499C,
80, 80,
(8 - gTrainerBackPicCoords[gSaveBlock2Ptr->playerGender].coords) * 4 + 80, (8 - gTrainerBackPicCoords[gSaveBlock2Ptr->playerGender].coords) * 4 + 80,
30); 30);
gSprites[gBankSpriteIds[gActiveBattler]].oam.paletteNum = gActiveBattler; gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = gActiveBattler;
gSprites[gBankSpriteIds[gActiveBattler]].pos2.x = 240; gSprites[gBattlerSpriteIds[gActiveBattler]].pos2.x = 240;
gSprites[gBankSpriteIds[gActiveBattler]].data[0] = -2; gSprites[gBattlerSpriteIds[gActiveBattler]].data[0] = -2;
gSprites[gBankSpriteIds[gActiveBattler]].callback = sub_805D7AC; gSprites[gBattlerSpriteIds[gActiveBattler]].callback = sub_805D7AC;
gBattlerFuncs[gActiveBattler] = CompleteOnBankSpriteCallbackDummy; gBattlerControllerFuncs[gActiveBattler] = CompleteOnBankSpriteCallbackDummy;
} }
static void SafariHandleTrainerSlide(void) static void SafariHandleTrainerSlide(void)
@ -416,7 +416,7 @@ static void SafariHandleSuccessBallThrowAnim(void)
gBattleSpritesDataPtr->animationData->ballThrowCaseId = BALL_3_SHAKES_SUCCESS; gBattleSpritesDataPtr->animationData->ballThrowCaseId = BALL_3_SHAKES_SUCCESS;
gDoingBattleAnim = TRUE; gDoingBattleAnim = TRUE;
InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT), B_ANIM_SAFARI_BALL_THROW); InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT), B_ANIM_SAFARI_BALL_THROW);
gBattlerFuncs[gActiveBattler] = CompleteOnSpecialAnimDone; gBattlerControllerFuncs[gActiveBattler] = CompleteOnSpecialAnimDone;
} }
static void SafariHandleBallThrowAnim(void) static void SafariHandleBallThrowAnim(void)
@ -426,7 +426,7 @@ static void SafariHandleBallThrowAnim(void)
gBattleSpritesDataPtr->animationData->ballThrowCaseId = ballThrowCaseId; gBattleSpritesDataPtr->animationData->ballThrowCaseId = ballThrowCaseId;
gDoingBattleAnim = TRUE; gDoingBattleAnim = TRUE;
InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT), B_ANIM_SAFARI_BALL_THROW); InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT), B_ANIM_SAFARI_BALL_THROW);
gBattlerFuncs[gActiveBattler] = CompleteOnSpecialAnimDone; gBattlerControllerFuncs[gActiveBattler] = CompleteOnSpecialAnimDone;
} }
static void SafariHandlePause(void) static void SafariHandlePause(void)
@ -448,7 +448,7 @@ static void SafariHandlePrintString(void)
stringId = (u16*)(&gBattleBufferA[gActiveBattler][2]); stringId = (u16*)(&gBattleBufferA[gActiveBattler][2]);
BufferStringBattle(*stringId); BufferStringBattle(*stringId);
BattleHandleAddTextPrinter(gDisplayedStringBattle, 0); BattleHandleAddTextPrinter(gDisplayedStringBattle, 0);
gBattlerFuncs[gActiveBattler] = CompleteOnInactiveTextPrinter; gBattlerControllerFuncs[gActiveBattler] = CompleteOnInactiveTextPrinter;
} }
static void SafariHandlePrintSelectionString(void) static void SafariHandlePrintSelectionString(void)
@ -465,7 +465,7 @@ static void HandleChooseActionAfterDma3(void)
{ {
gBattle_BG0_X = 0; gBattle_BG0_X = 0;
gBattle_BG0_Y = 160; gBattle_BG0_Y = 160;
gBattlerFuncs[gActiveBattler] = HandleInputChooseAction; gBattlerControllerFuncs[gActiveBattler] = HandleInputChooseAction;
} }
} }
@ -473,7 +473,7 @@ static void SafariHandleChooseAction(void)
{ {
s32 i; s32 i;
gBattlerFuncs[gActiveBattler] = HandleChooseActionAfterDma3; gBattlerControllerFuncs[gActiveBattler] = HandleChooseActionAfterDma3;
BattleHandleAddTextPrinter(gText_SafariZoneMenu, 2); BattleHandleAddTextPrinter(gText_SafariZoneMenu, 2);
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
@ -499,7 +499,7 @@ static void SafariHandleChooseItem(void)
s32 i; s32 i;
BeginNormalPaletteFade(-1, 0, 0, 0x10, 0); BeginNormalPaletteFade(-1, 0, 0, 0x10, 0);
gBattlerFuncs[gActiveBattler] = SafariOpenPokeblockCase; gBattlerControllerFuncs[gActiveBattler] = SafariOpenPokeblockCase;
gBankInMenu = gActiveBattler; gBankInMenu = gActiveBattler;
} }
@ -525,7 +525,7 @@ static void SafariHandleExpUpdate(void)
static void SafariHandleStatusIconUpdate(void) static void SafariHandleStatusIconUpdate(void)
{ {
UpdateHealthboxAttribute(gHealthBoxesIds[gActiveBattler], &gPlayerParty[gBattlePartyID[gActiveBattler]], HEALTHBOX_SAFARI_BALLS_TEXT); UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler], &gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], HEALTHBOX_SAFARI_BALLS_TEXT);
SafariBufferExecCompleted(); SafariBufferExecCompleted();
} }
@ -639,7 +639,7 @@ static void SafariHandlePlayFanfareOrBGM(void)
static void SafariHandleFaintingCry(void) static void SafariHandleFaintingCry(void)
{ {
u16 species = GetMonData(&gPlayerParty[gBattlePartyID[gActiveBattler]], MON_DATA_SPECIES); u16 species = GetMonData(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_SPECIES);
PlayCry1(species, 25); PlayCry1(species, 25);
SafariBufferExecCompleted(); SafariBufferExecCompleted();
@ -654,10 +654,10 @@ static void SafariHandleIntroSlide(void)
static void SafariHandleIntroTrainerBallThrow(void) static void SafariHandleIntroTrainerBallThrow(void)
{ {
UpdateHealthboxAttribute(gHealthBoxesIds[gActiveBattler], &gPlayerParty[gBattlePartyID[gActiveBattler]], HEALTHBOX_SAFARI_ALL_TEXT); UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler], &gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], HEALTHBOX_SAFARI_ALL_TEXT);
sub_8076918(gActiveBattler); sub_8076918(gActiveBattler);
SetHealthboxSpriteVisible(gHealthBoxesIds[gActiveBattler]); SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]);
gBattlerFuncs[gActiveBattler] = CompleteOnHealthboxSpriteCallbackDummy; gBattlerControllerFuncs[gActiveBattler] = CompleteOnHealthboxSpriteCallbackDummy;
} }
static void SafariHandleDrawPartyStatusSummary(void) static void SafariHandleDrawPartyStatusSummary(void)
@ -688,7 +688,7 @@ static void SafariHandleBattleAnimation(void)
if (TryHandleLaunchBattleTableAnimation(gActiveBattler, gActiveBattler, gActiveBattler, animationId, argument)) if (TryHandleLaunchBattleTableAnimation(gActiveBattler, gActiveBattler, gActiveBattler, animationId, argument))
SafariBufferExecCompleted(); SafariBufferExecCompleted();
else else
gBattlerFuncs[gActiveBattler] = CompleteOnFinishedBattleAnimation; gBattlerControllerFuncs[gActiveBattler] = CompleteOnFinishedBattleAnimation;
} }
static void SafariHandleLinkStandbyMsg(void) static void SafariHandleLinkStandbyMsg(void)
@ -708,7 +708,7 @@ static void SafariHandleCmd55(void)
BeginFastPaletteFade(3); BeginFastPaletteFade(3);
SafariBufferExecCompleted(); SafariBufferExecCompleted();
if ((gBattleTypeFlags & BATTLE_TYPE_LINK) && !(gBattleTypeFlags & BATTLE_TYPE_WILD)) if ((gBattleTypeFlags & BATTLE_TYPE_LINK) && !(gBattleTypeFlags & BATTLE_TYPE_WILD))
gBattlerFuncs[gActiveBattler] = sub_81595E4; gBattlerControllerFuncs[gActiveBattler] = sub_81595E4;
} }
static void nullsub_115(void) static void nullsub_115(void)

View File

@ -28,16 +28,16 @@
#include "data2.h" #include "data2.h"
#include "party_menu.h" #include "party_menu.h"
extern u32 gBattleExecBuffer; extern u32 gBattleControllerExecFlags;
extern u8 gActiveBattler; extern u8 gActiveBattler;
extern u8 gBankSpriteIds[MAX_BATTLERS_COUNT]; extern u8 gBattlerSpriteIds[MAX_BATTLERS_COUNT];
extern u8 gActionSelectionCursor[MAX_BATTLERS_COUNT]; extern u8 gActionSelectionCursor[MAX_BATTLERS_COUNT];
extern u8 gMoveSelectionCursor[MAX_BATTLERS_COUNT]; extern u8 gMoveSelectionCursor[MAX_BATTLERS_COUNT];
extern u8 gAbsentBattlerFlags; extern u8 gAbsentBattlerFlags;
extern u8 gBattlersCount; extern u8 gBattlersCount;
extern bool8 gDoingBattleAnim; extern bool8 gDoingBattleAnim;
extern void (*gBattlerFuncs[MAX_BATTLERS_COUNT])(void); extern void (*gBattlerControllerFuncs[MAX_BATTLERS_COUNT])(void);
extern u16 gBattlePartyID[MAX_BATTLERS_COUNT]; extern u16 gBattlerPartyIndexes[MAX_BATTLERS_COUNT];
extern u8 gBattleBufferA[MAX_BATTLERS_COUNT][0x200]; extern u8 gBattleBufferA[MAX_BATTLERS_COUNT][0x200];
extern u8 gBattleBufferB[MAX_BATTLERS_COUNT][0x200]; extern u8 gBattleBufferB[MAX_BATTLERS_COUNT][0x200];
extern u8 gMultiUsePlayerCursor; extern u8 gMultiUsePlayerCursor;
@ -48,7 +48,7 @@ extern struct SpriteTemplate gUnknown_0202499C;
extern u8 gBattleMonForms[MAX_BATTLERS_COUNT]; extern u8 gBattleMonForms[MAX_BATTLERS_COUNT];
extern u16 gSpecialVar_ItemId; extern u16 gSpecialVar_ItemId;
extern u8 gUnknown_03005D7C[MAX_BATTLERS_COUNT]; extern u8 gUnknown_03005D7C[MAX_BATTLERS_COUNT];
extern u8 gHealthBoxesIds[MAX_BATTLERS_COUNT]; extern u8 gHealthboxSpriteIds[MAX_BATTLERS_COUNT];
extern u8 gBattleOutcome; extern u8 gBattleOutcome;
extern u8 gNumberOfMovesToChoose; extern u8 gNumberOfMovesToChoose;
extern u16 gBattle_BG0_X; extern u16 gBattle_BG0_X;
@ -204,7 +204,7 @@ static void nullsub_117(void)
void SetControllerToWally(void) void SetControllerToWally(void)
{ {
gBattlerFuncs[gActiveBattler] = WallyBufferRunCommand; gBattlerControllerFuncs[gActiveBattler] = WallyBufferRunCommand;
gBattleStruct->wallyBattleState = 0; gBattleStruct->wallyBattleState = 0;
gBattleStruct->wallyMovesState = 0; gBattleStruct->wallyMovesState = 0;
gBattleStruct->wallyWaitFrames = 0; gBattleStruct->wallyWaitFrames = 0;
@ -213,7 +213,7 @@ void SetControllerToWally(void)
static void WallyBufferRunCommand(void) static void WallyBufferRunCommand(void)
{ {
if (gBattleExecBuffer & gBitTable[gActiveBattler]) if (gBattleControllerExecFlags & gBitTable[gActiveBattler])
{ {
if (gBattleBufferA[gActiveBattler][0] < ARRAY_COUNT(sWallyBufferCommands)) if (gBattleBufferA[gActiveBattler][0] < ARRAY_COUNT(sWallyBufferCommands))
sWallyBufferCommands[gBattleBufferA[gActiveBattler][0]](); sWallyBufferCommands[gBattleBufferA[gActiveBattler][0]]();
@ -233,7 +233,7 @@ static void WallyHandleActions(void)
if (--gBattleStruct->wallyWaitFrames == 0) if (--gBattleStruct->wallyWaitFrames == 0)
{ {
PlaySE(SE_SELECT); PlaySE(SE_SELECT);
EmitTwoReturnValues(1, ACTION_USE_MOVE, 0); BtlController_EmitTwoReturnValues(1, ACTION_USE_MOVE, 0);
WallyBufferExecCompleted(); WallyBufferExecCompleted();
gBattleStruct->wallyBattleState++; gBattleStruct->wallyBattleState++;
gBattleStruct->wallyMovesState = 0; gBattleStruct->wallyMovesState = 0;
@ -244,7 +244,7 @@ static void WallyHandleActions(void)
if (--gBattleStruct->wallyWaitFrames == 0) if (--gBattleStruct->wallyWaitFrames == 0)
{ {
PlaySE(SE_SELECT); PlaySE(SE_SELECT);
EmitTwoReturnValues(1, ACTION_USE_MOVE, 0); BtlController_EmitTwoReturnValues(1, ACTION_USE_MOVE, 0);
WallyBufferExecCompleted(); WallyBufferExecCompleted();
gBattleStruct->wallyBattleState++; gBattleStruct->wallyBattleState++;
gBattleStruct->wallyMovesState = 0; gBattleStruct->wallyMovesState = 0;
@ -254,7 +254,7 @@ static void WallyHandleActions(void)
case 3: case 3:
if (--gBattleStruct->wallyWaitFrames == 0) if (--gBattleStruct->wallyWaitFrames == 0)
{ {
EmitTwoReturnValues(1, 9, 0); BtlController_EmitTwoReturnValues(1, 9, 0);
WallyBufferExecCompleted(); WallyBufferExecCompleted();
gBattleStruct->wallyBattleState++; gBattleStruct->wallyBattleState++;
gBattleStruct->wallyMovesState = 0; gBattleStruct->wallyMovesState = 0;
@ -275,7 +275,7 @@ static void WallyHandleActions(void)
if (--gBattleStruct->wallyWaitFrames == 0) if (--gBattleStruct->wallyWaitFrames == 0)
{ {
PlaySE(SE_SELECT); PlaySE(SE_SELECT);
EmitTwoReturnValues(1, ACTION_USE_ITEM, 0); BtlController_EmitTwoReturnValues(1, ACTION_USE_ITEM, 0);
WallyBufferExecCompleted(); WallyBufferExecCompleted();
} }
break; break;
@ -284,7 +284,7 @@ static void WallyHandleActions(void)
static void CompleteOnBankSpriteCallbackDummy(void) static void CompleteOnBankSpriteCallbackDummy(void)
{ {
if (gSprites[gBankSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy) if (gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
WallyBufferExecCompleted(); WallyBufferExecCompleted();
} }
@ -304,7 +304,7 @@ static void OpenBagAfterPaletteFade(void)
{ {
if (!gPaletteFade.active) if (!gPaletteFade.active)
{ {
gBattlerFuncs[gActiveBattler] = CompleteOnChosenItem; gBattlerControllerFuncs[gActiveBattler] = CompleteOnChosenItem;
nullsub_35(); nullsub_35();
FreeAllWindowBuffers(); FreeAllWindowBuffers();
DoWallyTutorialBagMenu(); DoWallyTutorialBagMenu();
@ -315,7 +315,7 @@ static void CompleteOnChosenItem(void)
{ {
if (gMain.callback2 == BattleMainCB2 && !gPaletteFade.active) if (gMain.callback2 == BattleMainCB2 && !gPaletteFade.active)
{ {
EmitOneReturnValue(1, gSpecialVar_ItemId); BtlController_EmitOneReturnValue(1, gSpecialVar_ItemId);
WallyBufferExecCompleted(); WallyBufferExecCompleted();
} }
} }
@ -323,29 +323,29 @@ static void CompleteOnChosenItem(void)
static void sub_816864C(void) static void sub_816864C(void)
{ {
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].flag_x80 && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive) if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].flag_x80 && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive)
sub_8172EF0(gActiveBattler, &gPlayerParty[gBattlePartyID[gActiveBattler]]); sub_8172EF0(gActiveBattler, &gPlayerParty[gBattlerPartyIndexes[gActiveBattler]]);
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].flag_x80 && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].ballAnimActive) if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].flag_x80 && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].ballAnimActive)
sub_8172EF0(gActiveBattler ^ BIT_FLANK, &gPlayerParty[gBattlePartyID[gActiveBattler ^ BIT_FLANK]]); sub_8172EF0(gActiveBattler ^ BIT_FLANK, &gPlayerParty[gBattlerPartyIndexes[gActiveBattler ^ BIT_FLANK]]);
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive
&& !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].ballAnimActive && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].ballAnimActive
&& gSprites[gUnknown_03005D7C[gActiveBattler]].callback == SpriteCallbackDummy && gSprites[gUnknown_03005D7C[gActiveBattler]].callback == SpriteCallbackDummy
&& gSprites[gBankSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy) && gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
{ {
if (IsDoubleBattle() && !(gBattleTypeFlags & BATTLE_TYPE_MULTI)) if (IsDoubleBattle() && !(gBattleTypeFlags & BATTLE_TYPE_MULTI))
{ {
DestroySprite(&gSprites[gUnknown_03005D7C[gActiveBattler ^ BIT_FLANK]]); DestroySprite(&gSprites[gUnknown_03005D7C[gActiveBattler ^ BIT_FLANK]]);
UpdateHealthboxAttribute(gHealthBoxesIds[gActiveBattler ^ BIT_FLANK], &gPlayerParty[gBattlePartyID[gActiveBattler ^ BIT_FLANK]], HEALTHBOX_ALL); UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler ^ BIT_FLANK], &gPlayerParty[gBattlerPartyIndexes[gActiveBattler ^ BIT_FLANK]], HEALTHBOX_ALL);
sub_8076918(gActiveBattler ^ BIT_FLANK); sub_8076918(gActiveBattler ^ BIT_FLANK);
SetHealthboxSpriteVisible(gHealthBoxesIds[gActiveBattler ^ BIT_FLANK]); SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler ^ BIT_FLANK]);
} }
DestroySprite(&gSprites[gUnknown_03005D7C[gActiveBattler]]); DestroySprite(&gSprites[gUnknown_03005D7C[gActiveBattler]]);
UpdateHealthboxAttribute(gHealthBoxesIds[gActiveBattler], &gPlayerParty[gBattlePartyID[gActiveBattler]], HEALTHBOX_ALL); UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler], &gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], HEALTHBOX_ALL);
sub_8076918(gActiveBattler); sub_8076918(gActiveBattler);
SetHealthboxSpriteVisible(gHealthBoxesIds[gActiveBattler]); SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]);
gBattleSpritesDataPtr->animationData->field_9_x1 = 0; gBattleSpritesDataPtr->animationData->field_9_x1 = 0;
gBattlerFuncs[gActiveBattler] = sub_8168818; gBattlerControllerFuncs[gActiveBattler] = sub_8168818;
} }
} }
@ -354,7 +354,7 @@ static void sub_8168818(void)
{ {
bool32 r4 = FALSE; bool32 r4 = FALSE;
if (gSprites[gHealthBoxesIds[gActiveBattler]].callback == SpriteCallbackDummy) if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
r4 = TRUE; r4 = TRUE;
if (r4 && gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x1 if (r4 && gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x1
@ -370,7 +370,7 @@ static void sub_8168818(void)
FreeSpritePaletteByTag(0x27F9); FreeSpritePaletteByTag(0x27F9);
CreateTask(c3_0802FDF4, 10); CreateTask(c3_0802FDF4, 10);
HandleLowHpMusicChange(&gPlayerParty[gBattlePartyID[gActiveBattler]], gActiveBattler); HandleLowHpMusicChange(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler);
WallyBufferExecCompleted(); WallyBufferExecCompleted();
} }
@ -378,24 +378,24 @@ static void sub_8168818(void)
static void CompleteOnHealthbarDone(void) static void CompleteOnHealthbarDone(void)
{ {
s16 hpValue = sub_8074AA0(gActiveBattler, gHealthBoxesIds[gActiveBattler], HEALTH_BAR, 0); s16 hpValue = sub_8074AA0(gActiveBattler, gHealthboxSpriteIds[gActiveBattler], HEALTH_BAR, 0);
SetHealthboxSpriteVisible(gHealthBoxesIds[gActiveBattler]); SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]);
if (hpValue != -1) if (hpValue != -1)
{ {
UpdateHpTextInHealthbox(gHealthBoxesIds[gActiveBattler], hpValue, HP_CURRENT); UpdateHpTextInHealthbox(gHealthboxSpriteIds[gActiveBattler], hpValue, HP_CURRENT);
} }
else else
{ {
HandleLowHpMusicChange(&gPlayerParty[gBattlePartyID[gActiveBattler]], gActiveBattler); HandleLowHpMusicChange(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler);
WallyBufferExecCompleted(); WallyBufferExecCompleted();
} }
} }
static void DoHitAnimBlinkSpriteEffect(void) static void DoHitAnimBlinkSpriteEffect(void)
{ {
u8 spriteId = gBankSpriteIds[gActiveBattler]; u8 spriteId = gBattlerSpriteIds[gActiveBattler];
if (gSprites[spriteId].data[1] == 32) if (gSprites[spriteId].data[1] == 32)
{ {
@ -416,16 +416,16 @@ static void sub_8168A20(void)
{ {
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive) if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive)
{ {
FreeSpriteOamMatrix(&gSprites[gBankSpriteIds[gActiveBattler]]); FreeSpriteOamMatrix(&gSprites[gBattlerSpriteIds[gActiveBattler]]);
DestroySprite(&gSprites[gBankSpriteIds[gActiveBattler]]); DestroySprite(&gSprites[gBattlerSpriteIds[gActiveBattler]]);
SetHealthboxSpriteInvisible(gHealthBoxesIds[gActiveBattler]); SetHealthboxSpriteInvisible(gHealthboxSpriteIds[gActiveBattler]);
WallyBufferExecCompleted(); WallyBufferExecCompleted();
} }
} }
static void CompleteOnBankSpriteCallbackDummy2(void) static void CompleteOnBankSpriteCallbackDummy2(void)
{ {
if (gSprites[gBankSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy) if (gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
WallyBufferExecCompleted(); WallyBufferExecCompleted();
} }
@ -437,7 +437,7 @@ static void CompleteOnFinishedBattleAnimation(void)
static void WallyBufferExecCompleted(void) static void WallyBufferExecCompleted(void)
{ {
gBattlerFuncs[gActiveBattler] = WallyBufferRunCommand; gBattlerControllerFuncs[gActiveBattler] = WallyBufferRunCommand;
if (gBattleTypeFlags & BATTLE_TYPE_LINK) if (gBattleTypeFlags & BATTLE_TYPE_LINK)
{ {
u8 playerId = GetMultiplayerId(); u8 playerId = GetMultiplayerId();
@ -447,7 +447,7 @@ static void WallyBufferExecCompleted(void)
} }
else else
{ {
gBattleExecBuffer &= ~gBitTable[gActiveBattler]; gBattleControllerExecFlags &= ~gBitTable[gActiveBattler];
} }
} }
@ -466,7 +466,7 @@ static void WallyHandleGetMonData(void)
if (gBattleBufferA[gActiveBattler][2] == 0) if (gBattleBufferA[gActiveBattler][2] == 0)
{ {
size += CopyWallyMonData(gBattlePartyID[gActiveBattler], monData); size += CopyWallyMonData(gBattlerPartyIndexes[gActiveBattler], monData);
} }
else else
{ {
@ -478,7 +478,7 @@ static void WallyHandleGetMonData(void)
monToCheck >>= 1; monToCheck >>= 1;
} }
} }
EmitDataTransfer(1, size, monData); BtlController_EmitDataTransfer(1, size, monData);
WallyBufferExecCompleted(); WallyBufferExecCompleted();
} }
@ -800,7 +800,7 @@ static void WallyHandleSetMonData(void)
if (gBattleBufferA[gActiveBattler][2] == 0) if (gBattleBufferA[gActiveBattler][2] == 0)
{ {
SetWallyMonData(gBattlePartyID[gActiveBattler]); SetWallyMonData(gBattlerPartyIndexes[gActiveBattler]);
} }
else else
{ {
@ -1030,7 +1030,7 @@ static void SetWallyMonData(u8 monId)
break; break;
} }
HandleLowHpMusicChange(&gPlayerParty[gBattlePartyID[gActiveBattler]], gActiveBattler); HandleLowHpMusicChange(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler);
} }
static void WallyHandleSetRawMonData(void) static void WallyHandleSetRawMonData(void)
@ -1053,13 +1053,13 @@ static void WallyHandleReturnMonToBall(void)
if (gBattleBufferA[gActiveBattler][1] == 0) if (gBattleBufferA[gActiveBattler][1] == 0)
{ {
InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SWITCH_OUT_PLAYER_MON); InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SWITCH_OUT_PLAYER_MON);
gBattlerFuncs[gActiveBattler] = sub_8168A20; gBattlerControllerFuncs[gActiveBattler] = sub_8168A20;
} }
else else
{ {
FreeSpriteOamMatrix(&gSprites[gBankSpriteIds[gActiveBattler]]); FreeSpriteOamMatrix(&gSprites[gBattlerSpriteIds[gActiveBattler]]);
DestroySprite(&gSprites[gBankSpriteIds[gActiveBattler]]); DestroySprite(&gSprites[gBattlerSpriteIds[gActiveBattler]]);
SetHealthboxSpriteInvisible(gHealthBoxesIds[gActiveBattler]); SetHealthboxSpriteInvisible(gHealthboxSpriteIds[gActiveBattler]);
WallyBufferExecCompleted(); WallyBufferExecCompleted();
} }
} }
@ -1068,30 +1068,30 @@ static void WallyHandleDrawTrainerPic(void)
{ {
DecompressTrainerBackPic(BACK_PIC_WALLY, gActiveBattler); DecompressTrainerBackPic(BACK_PIC_WALLY, gActiveBattler);
sub_806A12C(BACK_PIC_WALLY, GetBattlerPosition(gActiveBattler)); sub_806A12C(BACK_PIC_WALLY, GetBattlerPosition(gActiveBattler));
gBankSpriteIds[gActiveBattler] = CreateSprite(&gUnknown_0202499C, gBattlerSpriteIds[gActiveBattler] = CreateSprite(&gUnknown_0202499C,
80, 80,
80 + 4 * (8 - gTrainerBackPicCoords[BACK_PIC_WALLY].coords), 80 + 4 * (8 - gTrainerBackPicCoords[BACK_PIC_WALLY].coords),
30); 30);
gSprites[gBankSpriteIds[gActiveBattler]].oam.paletteNum = gActiveBattler; gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = gActiveBattler;
gSprites[gBankSpriteIds[gActiveBattler]].pos2.x = 240; gSprites[gBattlerSpriteIds[gActiveBattler]].pos2.x = 240;
gSprites[gBankSpriteIds[gActiveBattler]].data[0] = -2; gSprites[gBattlerSpriteIds[gActiveBattler]].data[0] = -2;
gSprites[gBankSpriteIds[gActiveBattler]].callback = sub_805D7AC; gSprites[gBattlerSpriteIds[gActiveBattler]].callback = sub_805D7AC;
gBattlerFuncs[gActiveBattler] = CompleteOnBankSpriteCallbackDummy; gBattlerControllerFuncs[gActiveBattler] = CompleteOnBankSpriteCallbackDummy;
} }
static void WallyHandleTrainerSlide(void) static void WallyHandleTrainerSlide(void)
{ {
DecompressTrainerBackPic(BACK_PIC_WALLY, gActiveBattler); DecompressTrainerBackPic(BACK_PIC_WALLY, gActiveBattler);
sub_806A12C(BACK_PIC_WALLY, GetBattlerPosition(gActiveBattler)); sub_806A12C(BACK_PIC_WALLY, GetBattlerPosition(gActiveBattler));
gBankSpriteIds[gActiveBattler] = CreateSprite(&gUnknown_0202499C, gBattlerSpriteIds[gActiveBattler] = CreateSprite(&gUnknown_0202499C,
80, 80,
80 + 4 * (8 - gTrainerBackPicCoords[BACK_PIC_WALLY].coords), 80 + 4 * (8 - gTrainerBackPicCoords[BACK_PIC_WALLY].coords),
30); 30);
gSprites[gBankSpriteIds[gActiveBattler]].oam.paletteNum = gActiveBattler; gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = gActiveBattler;
gSprites[gBankSpriteIds[gActiveBattler]].pos2.x = -96; gSprites[gBattlerSpriteIds[gActiveBattler]].pos2.x = -96;
gSprites[gBankSpriteIds[gActiveBattler]].data[0] = 2; gSprites[gBattlerSpriteIds[gActiveBattler]].data[0] = 2;
gSprites[gBankSpriteIds[gActiveBattler]].callback = sub_805D7AC; gSprites[gBattlerSpriteIds[gActiveBattler]].callback = sub_805D7AC;
gBattlerFuncs[gActiveBattler] = CompleteOnBankSpriteCallbackDummy2; gBattlerControllerFuncs[gActiveBattler] = CompleteOnBankSpriteCallbackDummy2;
} }
static void WallyHandleTrainerSlideBack(void) static void WallyHandleTrainerSlideBack(void)
@ -1114,7 +1114,7 @@ static void WallyHandleSuccessBallThrowAnim(void)
gBattleSpritesDataPtr->animationData->ballThrowCaseId = BALL_3_SHAKES_SUCCESS; gBattleSpritesDataPtr->animationData->ballThrowCaseId = BALL_3_SHAKES_SUCCESS;
gDoingBattleAnim = TRUE; gDoingBattleAnim = TRUE;
InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT), B_ANIM_SAFARI_BALL_THROW); InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT), B_ANIM_SAFARI_BALL_THROW);
gBattlerFuncs[gActiveBattler] = CompleteOnFinishedAnimation; gBattlerControllerFuncs[gActiveBattler] = CompleteOnFinishedAnimation;
} }
static void WallyHandleBallThrowAnim(void) static void WallyHandleBallThrowAnim(void)
@ -1124,7 +1124,7 @@ static void WallyHandleBallThrowAnim(void)
gBattleSpritesDataPtr->animationData->ballThrowCaseId = ballThrowCaseId; gBattleSpritesDataPtr->animationData->ballThrowCaseId = ballThrowCaseId;
gDoingBattleAnim = TRUE; gDoingBattleAnim = TRUE;
InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT), B_ANIM_SAFARI_BALL_THROW); InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT), B_ANIM_SAFARI_BALL_THROW);
gBattlerFuncs[gActiveBattler] = CompleteOnFinishedAnimation; gBattlerControllerFuncs[gActiveBattler] = CompleteOnFinishedAnimation;
} }
static void WallyHandlePause(void) static void WallyHandlePause(void)
@ -1150,7 +1150,7 @@ static void WallyHandleMoveAnimation(void)
else else
{ {
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0;
gBattlerFuncs[gActiveBattler] = WallyDoMoveAnimation; gBattlerControllerFuncs[gActiveBattler] = WallyDoMoveAnimation;
} }
} }
@ -1209,7 +1209,7 @@ static void WallyHandlePrintString(void)
stringId = (u16*)(&gBattleBufferA[gActiveBattler][2]); stringId = (u16*)(&gBattleBufferA[gActiveBattler][2]);
BufferStringBattle(*stringId); BufferStringBattle(*stringId);
BattleHandleAddTextPrinter(gDisplayedStringBattle, 0); BattleHandleAddTextPrinter(gDisplayedStringBattle, 0);
gBattlerFuncs[gActiveBattler] = CompleteOnInactiveTextPrinter; gBattlerControllerFuncs[gActiveBattler] = CompleteOnInactiveTextPrinter;
} }
static void WallyHandlePrintSelectionString(void) static void WallyHandlePrintSelectionString(void)
@ -1226,7 +1226,7 @@ static void HandleChooseActionAfterDma3(void)
{ {
gBattle_BG0_X = 0; gBattle_BG0_X = 0;
gBattle_BG0_Y = 160; gBattle_BG0_Y = 160;
gBattlerFuncs[gActiveBattler] = WallyHandleActions; gBattlerControllerFuncs[gActiveBattler] = WallyHandleActions;
} }
} }
@ -1234,7 +1234,7 @@ static void WallyHandleChooseAction(void)
{ {
s32 i; s32 i;
gBattlerFuncs[gActiveBattler] = HandleChooseActionAfterDma3; gBattlerControllerFuncs[gActiveBattler] = HandleChooseActionAfterDma3;
BattleHandleAddTextPrinter(gText_BattleMenu, 2); BattleHandleAddTextPrinter(gText_BattleMenu, 2);
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
@ -1271,7 +1271,7 @@ static void WallyHandleChooseMove(void)
if (--gBattleStruct->wallyMoveFrames == 0) if (--gBattleStruct->wallyMoveFrames == 0)
{ {
PlaySE(SE_SELECT); PlaySE(SE_SELECT);
EmitTwoReturnValues(1, 10, 0x100); BtlController_EmitTwoReturnValues(1, 10, 0x100);
WallyBufferExecCompleted(); WallyBufferExecCompleted();
} }
break; break;
@ -1281,7 +1281,7 @@ static void WallyHandleChooseMove(void)
static void WallyHandleChooseItem(void) static void WallyHandleChooseItem(void)
{ {
BeginNormalPaletteFade(-1, 0, 0, 0x10, 0); BeginNormalPaletteFade(-1, 0, 0, 0x10, 0);
gBattlerFuncs[gActiveBattler] = OpenBagAfterPaletteFade; gBattlerControllerFuncs[gActiveBattler] = OpenBagAfterPaletteFade;
gBankInMenu = gActiveBattler; gBankInMenu = gActiveBattler;
} }
@ -1304,20 +1304,20 @@ static void WallyHandleHealthBarUpdate(void)
if (hpVal != INSTANT_HP_BAR_DROP) if (hpVal != INSTANT_HP_BAR_DROP)
{ {
u32 maxHP = GetMonData(&gPlayerParty[gBattlePartyID[gActiveBattler]], MON_DATA_MAX_HP); u32 maxHP = GetMonData(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_MAX_HP);
u32 curHP = GetMonData(&gPlayerParty[gBattlePartyID[gActiveBattler]], MON_DATA_HP); u32 curHP = GetMonData(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_HP);
SetBattleBarStruct(gActiveBattler, gHealthBoxesIds[gActiveBattler], maxHP, curHP, hpVal); SetBattleBarStruct(gActiveBattler, gHealthboxSpriteIds[gActiveBattler], maxHP, curHP, hpVal);
} }
else else
{ {
u32 maxHP = GetMonData(&gPlayerParty[gBattlePartyID[gActiveBattler]], MON_DATA_MAX_HP); u32 maxHP = GetMonData(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_MAX_HP);
SetBattleBarStruct(gActiveBattler, gHealthBoxesIds[gActiveBattler], maxHP, 0, hpVal); SetBattleBarStruct(gActiveBattler, gHealthboxSpriteIds[gActiveBattler], maxHP, 0, hpVal);
UpdateHpTextInHealthbox(gHealthBoxesIds[gActiveBattler], 0, HP_CURRENT); UpdateHpTextInHealthbox(gHealthboxSpriteIds[gActiveBattler], 0, HP_CURRENT);
} }
gBattlerFuncs[gActiveBattler] = CompleteOnHealthbarDone; gBattlerControllerFuncs[gActiveBattler] = CompleteOnHealthbarDone;
} }
static void WallyHandleExpUpdate(void) static void WallyHandleExpUpdate(void)
@ -1402,16 +1402,16 @@ static void WallyHandleCmd40(void)
static void WallyHandleHitAnimation(void) static void WallyHandleHitAnimation(void)
{ {
if (gSprites[gBankSpriteIds[gActiveBattler]].invisible == TRUE) if (gSprites[gBattlerSpriteIds[gActiveBattler]].invisible == TRUE)
{ {
WallyBufferExecCompleted(); WallyBufferExecCompleted();
} }
else else
{ {
gDoingBattleAnim = TRUE; gDoingBattleAnim = TRUE;
gSprites[gBankSpriteIds[gActiveBattler]].data[1] = 0; gSprites[gBattlerSpriteIds[gActiveBattler]].data[1] = 0;
DoHitAnimHealthboxEffect(gActiveBattler); DoHitAnimHealthboxEffect(gActiveBattler);
gBattlerFuncs[gActiveBattler] = DoHitAnimBlinkSpriteEffect; gBattlerControllerFuncs[gActiveBattler] = DoHitAnimBlinkSpriteEffect;
} }
} }
@ -1443,7 +1443,7 @@ static void WallyHandlePlayFanfareOrBGM(void)
static void WallyHandleFaintingCry(void) static void WallyHandleFaintingCry(void)
{ {
u16 species = GetMonData(&gPlayerParty[gBattlePartyID[gActiveBattler]], MON_DATA_SPECIES); u16 species = GetMonData(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_SPECIES);
PlayCry1(species, 25); PlayCry1(species, 25);
WallyBufferExecCompleted(); WallyBufferExecCompleted();
@ -1461,20 +1461,20 @@ static void WallyHandleIntroTrainerBallThrow(void)
u8 paletteNum; u8 paletteNum;
u8 taskId; u8 taskId;
oamt_add_pos2_onto_pos1(&gSprites[gBankSpriteIds[gActiveBattler]]); oamt_add_pos2_onto_pos1(&gSprites[gBattlerSpriteIds[gActiveBattler]]);
gSprites[gBankSpriteIds[gActiveBattler]].data[0] = 50; gSprites[gBattlerSpriteIds[gActiveBattler]].data[0] = 50;
gSprites[gBankSpriteIds[gActiveBattler]].data[2] = -40; gSprites[gBattlerSpriteIds[gActiveBattler]].data[2] = -40;
gSprites[gBankSpriteIds[gActiveBattler]].data[4] = gSprites[gBankSpriteIds[gActiveBattler]].pos1.y; gSprites[gBattlerSpriteIds[gActiveBattler]].data[4] = gSprites[gBattlerSpriteIds[gActiveBattler]].pos1.y;
gSprites[gBankSpriteIds[gActiveBattler]].callback = sub_80A6EEC; gSprites[gBattlerSpriteIds[gActiveBattler]].callback = sub_80A6EEC;
gSprites[gBankSpriteIds[gActiveBattler]].data[5] = gActiveBattler; gSprites[gBattlerSpriteIds[gActiveBattler]].data[5] = gActiveBattler;
StoreSpriteCallbackInData6(&gSprites[gBankSpriteIds[gActiveBattler]], sub_805CC00); StoreSpriteCallbackInData6(&gSprites[gBattlerSpriteIds[gActiveBattler]], sub_805CC00);
StartSpriteAnim(&gSprites[gBankSpriteIds[gActiveBattler]], 1); StartSpriteAnim(&gSprites[gBattlerSpriteIds[gActiveBattler]], 1);
paletteNum = AllocSpritePalette(0xD6F8); paletteNum = AllocSpritePalette(0xD6F8);
LoadCompressedPalette(gTrainerBackPicPaletteTable[BACK_PIC_WALLY].data, 0x100 + paletteNum * 16, 32); LoadCompressedPalette(gTrainerBackPicPaletteTable[BACK_PIC_WALLY].data, 0x100 + paletteNum * 16, 32);
gSprites[gBankSpriteIds[gActiveBattler]].oam.paletteNum = paletteNum; gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = paletteNum;
taskId = CreateTask(sub_816AC04, 5); taskId = CreateTask(sub_816AC04, 5);
gTasks[taskId].data[0] = gActiveBattler; gTasks[taskId].data[0] = gActiveBattler;
@ -1483,7 +1483,7 @@ static void WallyHandleIntroTrainerBallThrow(void)
gTasks[gUnknown_020244B4[gActiveBattler]].func = sub_8073C30; gTasks[gUnknown_020244B4[gActiveBattler]].func = sub_8073C30;
gBattleSpritesDataPtr->animationData->field_9_x1 = 1; gBattleSpritesDataPtr->animationData->field_9_x1 = 1;
gBattlerFuncs[gActiveBattler] = nullsub_21; gBattlerControllerFuncs[gActiveBattler] = nullsub_21;
} }
static void sub_816AA80(u8 bank) static void sub_816AA80(u8 bank)
@ -1491,25 +1491,25 @@ static void sub_816AA80(u8 bank)
u16 species; u16 species;
gBattleSpritesDataPtr->bankData[bank].transformSpecies = 0; gBattleSpritesDataPtr->bankData[bank].transformSpecies = 0;
gBattlePartyID[bank] = gBattleBufferA[bank][1]; gBattlerPartyIndexes[bank] = gBattleBufferA[bank][1];
species = GetMonData(&gPlayerParty[gBattlePartyID[bank]], MON_DATA_SPECIES); species = GetMonData(&gPlayerParty[gBattlerPartyIndexes[bank]], MON_DATA_SPECIES);
gUnknown_03005D7C[bank] = CreateInvisibleSpriteWithCallback(sub_805D714); gUnknown_03005D7C[bank] = CreateInvisibleSpriteWithCallback(sub_805D714);
sub_806A068(species, GetBattlerPosition(bank)); sub_806A068(species, GetBattlerPosition(bank));
gBankSpriteIds[bank] = CreateSprite(&gUnknown_0202499C, gBattlerSpriteIds[bank] = CreateSprite(&gUnknown_0202499C,
GetBankCoord(bank, 2), GetBattlerSpriteCoord(bank, 2),
GetBankSpriteDefault_Y(bank), GetBattlerSpriteDefault_Y(bank),
sub_80A82E4(bank)); sub_80A82E4(bank));
gSprites[gUnknown_03005D7C[bank]].data[1] = gBankSpriteIds[bank]; gSprites[gUnknown_03005D7C[bank]].data[1] = gBattlerSpriteIds[bank];
gSprites[gUnknown_03005D7C[bank]].data[2] = bank; gSprites[gUnknown_03005D7C[bank]].data[2] = bank;
gSprites[gBankSpriteIds[bank]].data[0] = bank; gSprites[gBattlerSpriteIds[bank]].data[0] = bank;
gSprites[gBankSpriteIds[bank]].data[2] = species; gSprites[gBattlerSpriteIds[bank]].data[2] = species;
gSprites[gBankSpriteIds[bank]].oam.paletteNum = bank; gSprites[gBattlerSpriteIds[bank]].oam.paletteNum = bank;
StartSpriteAnim(&gSprites[gBankSpriteIds[bank]], gBattleMonForms[bank]); StartSpriteAnim(&gSprites[gBattlerSpriteIds[bank]], gBattleMonForms[bank]);
gSprites[gBankSpriteIds[bank]].invisible = TRUE; gSprites[gBattlerSpriteIds[bank]].invisible = TRUE;
gSprites[gBankSpriteIds[bank]].callback = SpriteCallbackDummy; gSprites[gBattlerSpriteIds[bank]].callback = SpriteCallbackDummy;
gSprites[gUnknown_03005D7C[bank]].data[0] = DoPokeballSendOutAnimation(0, POKEBALL_PLAYER_SENDOUT); gSprites[gUnknown_03005D7C[bank]].data[0] = DoPokeballSendOutAnimation(0, POKEBALL_PLAYER_SENDOUT);
} }
@ -1524,9 +1524,9 @@ static void sub_816AC04(u8 taskId)
u8 savedActiveBank = gActiveBattler; u8 savedActiveBank = gActiveBattler;
gActiveBattler = gTasks[taskId].data[0]; gActiveBattler = gTasks[taskId].data[0];
gBattleBufferA[gActiveBattler][1] = gBattlePartyID[gActiveBattler]; gBattleBufferA[gActiveBattler][1] = gBattlerPartyIndexes[gActiveBattler];
sub_816AA80(gActiveBattler); sub_816AA80(gActiveBattler);
gBattlerFuncs[gActiveBattler] = sub_816864C; gBattlerControllerFuncs[gActiveBattler] = sub_816864C;
gActiveBattler = savedActiveBank; gActiveBattler = savedActiveBank;
DestroyTask(taskId); DestroyTask(taskId);
} }
@ -1569,7 +1569,7 @@ static void WallyHandleBattleAnimation(void)
if (TryHandleLaunchBattleTableAnimation(gActiveBattler, gActiveBattler, gActiveBattler, animationId, argument)) if (TryHandleLaunchBattleTableAnimation(gActiveBattler, gActiveBattler, gActiveBattler, animationId, argument))
WallyBufferExecCompleted(); WallyBufferExecCompleted();
else else
gBattlerFuncs[gActiveBattler] = CompleteOnFinishedBattleAnimation; gBattlerControllerFuncs[gActiveBattler] = CompleteOnFinishedBattleAnimation;
} }
static void WallyHandleLinkStandbyMsg(void) static void WallyHandleLinkStandbyMsg(void)
@ -1590,7 +1590,7 @@ static void WallyHandleCmd55(void)
WallyBufferExecCompleted(); WallyBufferExecCompleted();
if (!(gBattleTypeFlags & BATTLE_TYPE_WILD) && gBattleTypeFlags & BATTLE_TYPE_LINK) if (!(gBattleTypeFlags & BATTLE_TYPE_WILD) && gBattleTypeFlags & BATTLE_TYPE_LINK)
gBattlerFuncs[gActiveBattler] = sub_80587B0; gBattlerControllerFuncs[gActiveBattler] = sub_80587B0;
} }
static void nullsub_118(void) static void nullsub_118(void)

File diff suppressed because it is too large Load Diff

View File

@ -27,11 +27,11 @@ extern u8 gBattleBufferA[MAX_BATTLERS_COUNT][0x200];
extern u8 gActiveBattler; extern u8 gActiveBattler;
extern u8 gBattlersCount; extern u8 gBattlersCount;
extern u16 gUnknown_020243FC; extern u16 gUnknown_020243FC;
extern u16 gBattlePartyID[MAX_BATTLERS_COUNT]; extern u16 gBattlerPartyIndexes[MAX_BATTLERS_COUNT];
extern struct BattlePokemon gBattleMons[MAX_BATTLERS_COUNT]; extern struct BattlePokemon gBattleMons[MAX_BATTLERS_COUNT];
extern u8 gBattlerPositions[MAX_BATTLERS_COUNT]; extern u8 gBattlerPositions[MAX_BATTLERS_COUNT];
extern u8 gBankSpriteIds[MAX_BATTLERS_COUNT]; extern u8 gBattlerSpriteIds[MAX_BATTLERS_COUNT];
extern u8 gHealthBoxesIds[MAX_BATTLERS_COUNT]; extern u8 gHealthboxSpriteIds[MAX_BATTLERS_COUNT];
extern u8 gBattleMonForms[MAX_BATTLERS_COUNT]; extern u8 gBattleMonForms[MAX_BATTLERS_COUNT];
extern u32 gTransformedPersonalities[MAX_BATTLERS_COUNT]; extern u32 gTransformedPersonalities[MAX_BATTLERS_COUNT];
extern struct MusicPlayerInfo gMPlayInfo_SE1; extern struct MusicPlayerInfo gMPlayInfo_SE1;
@ -439,15 +439,15 @@ bool8 TryHandleLaunchBattleTableAnimation(u8 activeBank, u8 atkBank, u8 defBank,
} }
if (gBattleSpritesDataPtr->bankData[activeBank].behindSubstitute if (gBattleSpritesDataPtr->bankData[activeBank].behindSubstitute
&& tableId == B_ANIM_SUBSTITUTE_FADE && tableId == B_ANIM_SUBSTITUTE_FADE
&& gSprites[gBankSpriteIds[activeBank]].invisible) && gSprites[gBattlerSpriteIds[activeBank]].invisible)
{ {
LoadBattleMonGfxAndAnimate(activeBank, TRUE, gBankSpriteIds[activeBank]); LoadBattleMonGfxAndAnimate(activeBank, TRUE, gBattlerSpriteIds[activeBank]);
ClearBehindSubstituteBit(activeBank); ClearBehindSubstituteBit(activeBank);
return TRUE; return TRUE;
} }
gAnimBankAttacker = atkBank; gBattleAnimAttacker = atkBank;
gAnimBankTarget = defBank; gBattleAnimTarget = defBank;
gBattleSpritesDataPtr->animationData->animArg = argument; gBattleSpritesDataPtr->animationData->animArg = argument;
LaunchBattleAnimation(gBattleAnims_VariousTable, tableId, FALSE); LaunchBattleAnimation(gBattleAnims_VariousTable, tableId, FALSE);
taskId = CreateTask(Task_ClearBitWhenBattleTableAnimDone, 10); taskId = CreateTask(Task_ClearBitWhenBattleTableAnimDone, 10);
@ -491,8 +491,8 @@ void InitAndLaunchSpecialAnimation(u8 activeBank, u8 atkBank, u8 defBank, u8 tab
{ {
u8 taskId; u8 taskId;
gAnimBankAttacker = atkBank; gBattleAnimAttacker = atkBank;
gAnimBankTarget = defBank; gBattleAnimTarget = defBank;
LaunchBattleAnimation(gBattleAnims_Special, tableId, FALSE); LaunchBattleAnimation(gBattleAnims_Special, tableId, FALSE);
taskId = CreateTask(Task_ClearBitWhenSpecialAnimDone, 10); taskId = CreateTask(Task_ClearBitWhenSpecialAnimDone, 10);
gTasks[taskId].tBank = activeBank; gTasks[taskId].tBank = activeBank;
@ -802,9 +802,9 @@ bool8 BattleInitAllSprites(u8 *state1, u8 *bank)
break; break;
case 3: case 3:
if ((gBattleTypeFlags & BATTLE_TYPE_SAFARI) && *bank == 0) if ((gBattleTypeFlags & BATTLE_TYPE_SAFARI) && *bank == 0)
gHealthBoxesIds[*bank] = CreateSafariPlayerHealthboxSprites(); gHealthboxSpriteIds[*bank] = CreateSafariPlayerHealthboxSprites();
else else
gHealthBoxesIds[*bank] = CreateBankHealthboxSprites(*bank); gHealthboxSpriteIds[*bank] = CreateHealthboxSprites(*bank);
(*bank)++; (*bank)++;
if (*bank == gBattlersCount) if (*bank == gBattlersCount)
@ -814,11 +814,11 @@ bool8 BattleInitAllSprites(u8 *state1, u8 *bank)
} }
break; break;
case 4: case 4:
SetBankHealthboxSpritePos(*bank); InitBattlerHealthboxCoords(*bank);
if (gBattlerPositions[*bank] <= 1) if (gBattlerPositions[*bank] <= 1)
DummyBattleInterfaceFunc(gHealthBoxesIds[*bank], FALSE); DummyBattleInterfaceFunc(gHealthboxSpriteIds[*bank], FALSE);
else else
DummyBattleInterfaceFunc(gHealthBoxesIds[*bank], TRUE); DummyBattleInterfaceFunc(gHealthboxSpriteIds[*bank], TRUE);
(*bank)++; (*bank)++;
if (*bank == gBattlersCount) if (*bank == gBattlersCount)
@ -831,13 +831,13 @@ bool8 BattleInitAllSprites(u8 *state1, u8 *bank)
if (GetBattlerSide(*bank) == B_SIDE_PLAYER) if (GetBattlerSide(*bank) == B_SIDE_PLAYER)
{ {
if (!(gBattleTypeFlags & BATTLE_TYPE_SAFARI)) if (!(gBattleTypeFlags & BATTLE_TYPE_SAFARI))
UpdateHealthboxAttribute(gHealthBoxesIds[*bank], &gPlayerParty[gBattlePartyID[*bank]], HEALTHBOX_ALL); UpdateHealthboxAttribute(gHealthboxSpriteIds[*bank], &gPlayerParty[gBattlerPartyIndexes[*bank]], HEALTHBOX_ALL);
} }
else else
{ {
UpdateHealthboxAttribute(gHealthBoxesIds[*bank], &gEnemyParty[gBattlePartyID[*bank]], HEALTHBOX_ALL); UpdateHealthboxAttribute(gHealthboxSpriteIds[*bank], &gEnemyParty[gBattlerPartyIndexes[*bank]], HEALTHBOX_ALL);
} }
SetHealthboxSpriteInvisible(gHealthBoxesIds[*bank]); SetHealthboxSpriteInvisible(gHealthboxSpriteIds[*bank]);
(*bank)++; (*bank)++;
if (*bank == gBattlersCount) if (*bank == gBattlersCount)
{ {
@ -872,12 +872,12 @@ void CopyAllBattleSpritesInvisibilities(void)
s32 i; s32 i;
for (i = 0; i < gBattlersCount; i++) for (i = 0; i < gBattlersCount; i++)
gBattleSpritesDataPtr->bankData[i].invisible = gSprites[gBankSpriteIds[i]].invisible; gBattleSpritesDataPtr->bankData[i].invisible = gSprites[gBattlerSpriteIds[i]].invisible;
} }
void CopyBattleSpriteInvisibility(u8 bank) void CopyBattleSpriteInvisibility(u8 bank)
{ {
gBattleSpritesDataPtr->bankData[bank].invisible = gSprites[gBankSpriteIds[bank]].invisible; gBattleSpritesDataPtr->bankData[bank].invisible = gSprites[gBattlerSpriteIds[bank]].invisible;
} }
void HandleSpeciesGfxDataChange(u8 bankAtk, u8 bankDef, bool8 notTransform) void HandleSpeciesGfxDataChange(u8 bankAtk, u8 bankDef, bool8 notTransform)
@ -890,7 +890,7 @@ void HandleSpeciesGfxDataChange(u8 bankAtk, u8 bankDef, bool8 notTransform)
if (notTransform) if (notTransform)
{ {
StartSpriteAnim(&gSprites[gBankSpriteIds[bankAtk]], gBattleSpritesDataPtr->animationData->animArg); StartSpriteAnim(&gSprites[gBattlerSpriteIds[bankAtk]], gBattleSpritesDataPtr->animationData->animArg);
paletteOffset = 0x100 + bankAtk * 16; paletteOffset = 0x100 + bankAtk * 16;
LoadPalette(gBattleStruct->castformPalette[gBattleSpritesDataPtr->animationData->animArg], paletteOffset, 32); LoadPalette(gBattleStruct->castformPalette[gBattleSpritesDataPtr->animationData->animArg], paletteOffset, 32);
gBattleMonForms[bankAtk] = gBattleSpritesDataPtr->animationData->animArg; gBattleMonForms[bankAtk] = gBattleSpritesDataPtr->animationData->animArg;
@ -899,7 +899,7 @@ void HandleSpeciesGfxDataChange(u8 bankAtk, u8 bankDef, bool8 notTransform)
BlendPalette(paletteOffset, 16, 6, 0x7FFF); BlendPalette(paletteOffset, 16, 6, 0x7FFF);
CpuCopy32(gPlttBufferFaded + paletteOffset, gPlttBufferUnfaded + paletteOffset, 32); CpuCopy32(gPlttBufferFaded + paletteOffset, gPlttBufferUnfaded + paletteOffset, 32);
} }
gSprites[gBankSpriteIds[bankAtk]].pos1.y = GetBankSpriteDefault_Y(bankAtk); gSprites[gBattlerSpriteIds[bankAtk]].pos1.y = GetBattlerSpriteDefault_Y(bankAtk);
} }
else else
{ {
@ -924,14 +924,14 @@ void HandleSpeciesGfxDataChange(u8 bankAtk, u8 bankDef, bool8 notTransform)
position = GetBattlerPosition(bankAtk); position = GetBattlerPosition(bankAtk);
if (GetBattlerSide(bankDef) == B_SIDE_OPPONENT) if (GetBattlerSide(bankDef) == B_SIDE_OPPONENT)
targetSpecies = GetMonData(&gEnemyParty[gBattlePartyID[bankDef]], MON_DATA_SPECIES); targetSpecies = GetMonData(&gEnemyParty[gBattlerPartyIndexes[bankDef]], MON_DATA_SPECIES);
else else
targetSpecies = GetMonData(&gPlayerParty[gBattlePartyID[bankDef]], MON_DATA_SPECIES); targetSpecies = GetMonData(&gPlayerParty[gBattlerPartyIndexes[bankDef]], MON_DATA_SPECIES);
if (GetBattlerSide(bankAtk) == B_SIDE_PLAYER) if (GetBattlerSide(bankAtk) == B_SIDE_PLAYER)
{ {
personalityValue = GetMonData(&gPlayerParty[gBattlePartyID[bankAtk]], MON_DATA_PERSONALITY); personalityValue = GetMonData(&gPlayerParty[gBattlerPartyIndexes[bankAtk]], MON_DATA_PERSONALITY);
otId = GetMonData(&gPlayerParty[gBattlePartyID[bankAtk]], MON_DATA_OT_ID); otId = GetMonData(&gPlayerParty[gBattlerPartyIndexes[bankAtk]], MON_DATA_OT_ID);
HandleLoadSpecialPokePic_DontHandleDeoxys(&gMonBackPicTable[targetSpecies], HandleLoadSpecialPokePic_DontHandleDeoxys(&gMonBackPicTable[targetSpecies],
gMonSpritesGfxPtr->sprites[position], gMonSpritesGfxPtr->sprites[position],
@ -940,8 +940,8 @@ void HandleSpeciesGfxDataChange(u8 bankAtk, u8 bankDef, bool8 notTransform)
} }
else else
{ {
personalityValue = GetMonData(&gEnemyParty[gBattlePartyID[bankAtk]], MON_DATA_PERSONALITY); personalityValue = GetMonData(&gEnemyParty[gBattlerPartyIndexes[bankAtk]], MON_DATA_PERSONALITY);
otId = GetMonData(&gEnemyParty[gBattlePartyID[bankAtk]], MON_DATA_OT_ID); otId = GetMonData(&gEnemyParty[gBattlerPartyIndexes[bankAtk]], MON_DATA_OT_ID);
HandleLoadSpecialPokePic_DontHandleDeoxys(&gMonFrontPicTable[targetSpecies], HandleLoadSpecialPokePic_DontHandleDeoxys(&gMonFrontPicTable[targetSpecies],
gMonSpritesGfxPtr->sprites[position], gMonSpritesGfxPtr->sprites[position],
@ -951,7 +951,7 @@ void HandleSpeciesGfxDataChange(u8 bankAtk, u8 bankDef, bool8 notTransform)
} }
src = gMonSpritesGfxPtr->sprites[position]; src = gMonSpritesGfxPtr->sprites[position];
dst = (void *)(VRAM + 0x10000 + gSprites[gBankSpriteIds[bankAtk]].oam.tileNum * 32); dst = (void *)(VRAM + 0x10000 + gSprites[gBattlerSpriteIds[bankAtk]].oam.tileNum * 32);
DmaCopy32(3, src, dst, 0x800); DmaCopy32(3, src, dst, 0x800);
paletteOffset = 0x100 + bankAtk * 16; paletteOffset = 0x100 + bankAtk * 16;
lzPaletteData = GetFrontSpritePalFromSpeciesAndPersonality(targetSpecies, otId, personalityValue); lzPaletteData = GetFrontSpritePalFromSpeciesAndPersonality(targetSpecies, otId, personalityValue);
@ -960,7 +960,7 @@ void HandleSpeciesGfxDataChange(u8 bankAtk, u8 bankDef, bool8 notTransform)
if (targetSpecies == SPECIES_CASTFORM) if (targetSpecies == SPECIES_CASTFORM)
{ {
gSprites[gBankSpriteIds[bankAtk]].anims = gMonAnimationsSpriteAnimsPtrTable[targetSpecies]; gSprites[gBattlerSpriteIds[bankAtk]].anims = gMonAnimationsSpriteAnimsPtrTable[targetSpecies];
LZDecompressWram(lzPaletteData, gBattleStruct->castformPalette[0]); LZDecompressWram(lzPaletteData, gBattleStruct->castformPalette[0]);
LoadPalette(gBattleStruct->castformPalette[0] + gBattleMonForms[bankDef] * 16, paletteOffset, 32); LoadPalette(gBattleStruct->castformPalette[0] + gBattleMonForms[bankDef] * 16, paletteOffset, 32);
} }
@ -974,8 +974,8 @@ void HandleSpeciesGfxDataChange(u8 bankAtk, u8 bankDef, bool8 notTransform)
gBattleMonForms[bankAtk] = gBattleMonForms[bankDef]; gBattleMonForms[bankAtk] = gBattleMonForms[bankDef];
} }
gSprites[gBankSpriteIds[bankAtk]].pos1.y = GetBankSpriteDefault_Y(bankAtk); gSprites[gBattlerSpriteIds[bankAtk]].pos1.y = GetBattlerSpriteDefault_Y(bankAtk);
StartSpriteAnim(&gSprites[gBankSpriteIds[bankAtk]], gBattleMonForms[bankAtk]); StartSpriteAnim(&gSprites[gBattlerSpriteIds[bankAtk]], gBattleMonForms[bankAtk]);
} }
} }
@ -1019,9 +1019,9 @@ void BattleLoadSubstituteOrMonSpriteGfx(u8 bank, bool8 loadMonSprite)
if (!IsContest()) if (!IsContest())
{ {
if (GetBattlerSide(bank) != B_SIDE_PLAYER) if (GetBattlerSide(bank) != B_SIDE_PLAYER)
BattleLoadOpponentMonSpriteGfx(&gEnemyParty[gBattlePartyID[bank]], bank); BattleLoadOpponentMonSpriteGfx(&gEnemyParty[gBattlerPartyIndexes[bank]], bank);
else else
BattleLoadPlayerMonSpriteGfx(&gPlayerParty[gBattlePartyID[bank]], bank); BattleLoadPlayerMonSpriteGfx(&gPlayerParty[gBattlerPartyIndexes[bank]], bank);
} }
} }
} }
@ -1034,7 +1034,7 @@ void LoadBattleMonGfxAndAnimate(u8 bank, bool8 loadMonSprite, u8 spriteId)
if (!loadMonSprite) if (!loadMonSprite)
gSprites[spriteId].pos1.y = GetSubstituteSpriteDefault_Y(bank); gSprites[spriteId].pos1.y = GetSubstituteSpriteDefault_Y(bank);
else else
gSprites[spriteId].pos1.y = GetBankSpriteDefault_Y(bank); gSprites[spriteId].pos1.y = GetBattlerSpriteDefault_Y(bank);
} }
void TrySetBehindSubstituteSpriteBit(u8 bank, u16 move) void TrySetBehindSubstituteSpriteBit(u8 bank, u16 move)
@ -1103,8 +1103,8 @@ void sub_805EAE8(void)
{ {
u8 playerBank1 = GetBattlerAtPosition(B_POSITION_PLAYER_LEFT); u8 playerBank1 = GetBattlerAtPosition(B_POSITION_PLAYER_LEFT);
u8 playerBank2 = GetBattlerAtPosition(B_POSITION_PLAYER_RIGHT); u8 playerBank2 = GetBattlerAtPosition(B_POSITION_PLAYER_RIGHT);
u8 bank1PartyId = pokemon_order_func(gBattlePartyID[playerBank1]); u8 bank1PartyId = pokemon_order_func(gBattlerPartyIndexes[playerBank1]);
u8 bank2PartyId = pokemon_order_func(gBattlePartyID[playerBank2]); u8 bank2PartyId = pokemon_order_func(gBattlerPartyIndexes[playerBank2]);
if (GetMonData(&gPlayerParty[bank1PartyId], MON_DATA_HP) != 0) if (GetMonData(&gPlayerParty[bank1PartyId], MON_DATA_HP) != 0)
HandleLowHpMusicChange(&gPlayerParty[bank1PartyId], playerBank1); HandleLowHpMusicChange(&gPlayerParty[bank1PartyId], playerBank1);
@ -1119,17 +1119,17 @@ void sub_805EB9C(u8 affineMode)
for (i = 0; i < gBattlersCount; i++) for (i = 0; i < gBattlersCount; i++)
{ {
if (IsBankSpritePresent(i)) if (IsBattlerSpritePresent(i))
{ {
gSprites[gBankSpriteIds[i]].oam.affineMode = affineMode; gSprites[gBattlerSpriteIds[i]].oam.affineMode = affineMode;
if (affineMode == 0) if (affineMode == 0)
{ {
gBattleSpritesDataPtr->healthBoxesData[i].field_6 = gSprites[gBankSpriteIds[i]].oam.matrixNum; gBattleSpritesDataPtr->healthBoxesData[i].field_6 = gSprites[gBattlerSpriteIds[i]].oam.matrixNum;
gSprites[gBankSpriteIds[i]].oam.matrixNum = 0; gSprites[gBattlerSpriteIds[i]].oam.matrixNum = 0;
} }
else else
{ {
gSprites[gBankSpriteIds[i]].oam.matrixNum = gBattleSpritesDataPtr->healthBoxesData[i].field_6; gSprites[gBattlerSpriteIds[i]].oam.matrixNum = gBattleSpritesDataPtr->healthBoxesData[i].field_6;
} }
} }
} }
@ -1144,13 +1144,13 @@ void LoadAndCreateEnemyShadowSprites(void)
LoadCompressedObjectPic(&gSpriteSheet_EnemyShadow); LoadCompressedObjectPic(&gSpriteSheet_EnemyShadow);
bank = GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT); bank = GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT);
gBattleSpritesDataPtr->healthBoxesData[bank].shadowSpriteId = CreateSprite(&gSpriteTemplate_EnemyShadow, GetBankCoord(bank, 0), GetBankCoord(bank, 1) + 29, 0xC8); gBattleSpritesDataPtr->healthBoxesData[bank].shadowSpriteId = CreateSprite(&gSpriteTemplate_EnemyShadow, GetBattlerSpriteCoord(bank, 0), GetBattlerSpriteCoord(bank, 1) + 29, 0xC8);
gSprites[gBattleSpritesDataPtr->healthBoxesData[bank].shadowSpriteId].data[0] = bank; gSprites[gBattleSpritesDataPtr->healthBoxesData[bank].shadowSpriteId].data[0] = bank;
if (IsDoubleBattle()) if (IsDoubleBattle())
{ {
bank = GetBattlerAtPosition(B_POSITION_OPPONENT_RIGHT); bank = GetBattlerAtPosition(B_POSITION_OPPONENT_RIGHT);
gBattleSpritesDataPtr->healthBoxesData[bank].shadowSpriteId = CreateSprite(&gSpriteTemplate_EnemyShadow, GetBankCoord(bank, 0), GetBankCoord(bank, 1) + 29, 0xC8); gBattleSpritesDataPtr->healthBoxesData[bank].shadowSpriteId = CreateSprite(&gSpriteTemplate_EnemyShadow, GetBattlerSpriteCoord(bank, 0), GetBattlerSpriteCoord(bank, 1) + 29, 0xC8);
gSprites[gBattleSpritesDataPtr->healthBoxesData[bank].shadowSpriteId].data[0] = bank; gSprites[gBattleSpritesDataPtr->healthBoxesData[bank].shadowSpriteId].data[0] = bank;
} }
} }
@ -1159,9 +1159,9 @@ void SpriteCB_EnemyShadow(struct Sprite *shadowSprite)
{ {
bool8 invisible = FALSE; bool8 invisible = FALSE;
u8 bank = shadowSprite->tBank; u8 bank = shadowSprite->tBank;
struct Sprite *bankSprite = &gSprites[gBankSpriteIds[bank]]; struct Sprite *bankSprite = &gSprites[gBattlerSpriteIds[bank]];
if (!bankSprite->inUse || !IsBankSpritePresent(bank)) if (!bankSprite->inUse || !IsBattlerSpritePresent(bank))
{ {
shadowSprite->callback = SpriteCB_SetInvisible; shadowSprite->callback = SpriteCB_SetInvisible;
return; return;
@ -1187,8 +1187,9 @@ void SpriteCB_SetInvisible(struct Sprite *sprite)
sprite->invisible = 1; sprite->invisible = 1;
} }
void SetBankEnemyShadowSpriteCallback(u8 bank, u16 species) void SetBattlerShadowSpriteCallback(u8 bank, u16 species)
{ {
// The player's shadow is never seen
if (GetBattlerSide(bank) == B_SIDE_PLAYER) if (GetBattlerSide(bank) == B_SIDE_PLAYER)
return; return;
@ -1201,7 +1202,7 @@ void SetBankEnemyShadowSpriteCallback(u8 bank, u16 species)
gSprites[gBattleSpritesDataPtr->healthBoxesData[bank].shadowSpriteId].callback = SpriteCB_SetInvisible; gSprites[gBattleSpritesDataPtr->healthBoxesData[bank].shadowSpriteId].callback = SpriteCB_SetInvisible;
} }
void EnemyShadowCallbackToSetInvisible(u8 bank) void HideBattlerShadowSprite(u8 bank)
{ {
gSprites[gBattleSpritesDataPtr->healthBoxesData[bank].shadowSpriteId].callback = SpriteCB_SetInvisible; gSprites[gBattleSpritesDataPtr->healthBoxesData[bank].shadowSpriteId].callback = SpriteCB_SetInvisible;
} }

View File

@ -154,9 +154,9 @@ enum
}; };
extern u8 gBattlerPositions[MAX_BATTLERS_COUNT]; extern u8 gBattlerPositions[MAX_BATTLERS_COUNT];
extern u16 gBattlePartyID[MAX_BATTLERS_COUNT]; extern u16 gBattlerPartyIndexes[MAX_BATTLERS_COUNT];
extern u8 gBattlersCount; extern u8 gBattlersCount;
extern u8 gHealthBoxesIds[MAX_BATTLERS_COUNT]; extern u8 gHealthboxSpriteIds[MAX_BATTLERS_COUNT];
extern const u8 * const gNatureNamePointers[]; extern const u8 * const gNatureNamePointers[];
extern const u8 gSpeciesNames[][POKEMON_NAME_LENGTH + 1]; extern const u8 gSpeciesNames[][POKEMON_NAME_LENGTH + 1];
@ -898,7 +898,7 @@ void sub_80724A8(s16 arg0, s16 arg1, u16 *arg2)
// healthboxSpriteId_2 refers to the other part // healthboxSpriteId_2 refers to the other part
// there's also one other sprite that appears to be a black square? dont fully understand its role // there's also one other sprite that appears to be a black square? dont fully understand its role
u8 CreateBankHealthboxSprites(u8 bank) u8 CreateHealthboxSprites(u8 bank)
{ {
s16 data6 = 0; s16 data6 = 0;
u8 healthboxSpriteId_1, healthboxSpriteId_2; u8 healthboxSpriteId_1, healthboxSpriteId_2;
@ -1089,9 +1089,9 @@ void UpdateOamPriorityInAllHealthboxes(u8 priority)
for (i = 0; i < gBattlersCount; i++) for (i = 0; i < gBattlersCount; i++)
{ {
u8 healthboxSpriteId_1 = gHealthBoxesIds[i]; u8 healthboxSpriteId_1 = gHealthboxSpriteIds[i];
u8 healthboxSpriteId_2 = gSprites[gHealthBoxesIds[i]].oam.affineParam; u8 healthboxSpriteId_2 = gSprites[gHealthboxSpriteIds[i]].oam.affineParam;
u8 healthboxSpriteId_3 = gSprites[gHealthBoxesIds[i]].data[5]; u8 healthboxSpriteId_3 = gSprites[gHealthboxSpriteIds[i]].data[5];
gSprites[healthboxSpriteId_1].oam.priority = priority; gSprites[healthboxSpriteId_1].oam.priority = priority;
gSprites[healthboxSpriteId_2].oam.priority = priority; gSprites[healthboxSpriteId_2].oam.priority = priority;
@ -1099,7 +1099,7 @@ void UpdateOamPriorityInAllHealthboxes(u8 priority)
} }
} }
void SetBankHealthboxSpritePos(u8 bank) void InitBattlerHealthboxCoords(u8 bank)
{ {
s16 x = 0, y = 0; s16 x = 0, y = 0;
@ -1129,7 +1129,7 @@ void SetBankHealthboxSpritePos(u8 bank)
} }
} }
UpdateSpritePos(gHealthBoxesIds[bank], x, y); UpdateSpritePos(gHealthboxSpriteIds[bank], x, y);
} }
static void UpdateLvlInHealthbox(u8 healthboxSpriteId, u8 lvl) static void UpdateLvlInHealthbox(u8 healthboxSpriteId, u8 lvl)
@ -1417,7 +1417,7 @@ void SwapHpBarsWithHpText(void)
for (i = 0; i < gBattlersCount; i++) for (i = 0; i < gBattlersCount; i++)
{ {
if (gSprites[gHealthBoxesIds[i]].callback == SpriteCallbackDummy if (gSprites[gHealthboxSpriteIds[i]].callback == SpriteCallbackDummy
&& GetBattlerSide(i) != B_SIDE_OPPONENT && GetBattlerSide(i) != B_SIDE_OPPONENT
&& (IsDoubleBattle() || GetBattlerSide(i) != B_SIDE_PLAYER)) && (IsDoubleBattle() || GetBattlerSide(i) != B_SIDE_PLAYER))
{ {
@ -1434,17 +1434,17 @@ void SwapHpBarsWithHpText(void)
if (noBars == TRUE) // bars to text if (noBars == TRUE) // bars to text
{ {
spriteId = gSprites[gHealthBoxesIds[i]].data[5]; spriteId = gSprites[gHealthboxSpriteIds[i]].data[5];
CpuFill32(0, (void*)(OBJ_VRAM0 + gSprites[spriteId].oam.tileNum * 32), 0x100); CpuFill32(0, (void*)(OBJ_VRAM0 + gSprites[spriteId].oam.tileNum * 32), 0x100);
UpdateHpTextInHealthboxInDoubles(gHealthBoxesIds[i], GetMonData(&gPlayerParty[gBattlePartyID[i]], MON_DATA_HP), HP_CURRENT); UpdateHpTextInHealthboxInDoubles(gHealthboxSpriteIds[i], GetMonData(&gPlayerParty[gBattlerPartyIndexes[i]], MON_DATA_HP), HP_CURRENT);
UpdateHpTextInHealthboxInDoubles(gHealthBoxesIds[i], GetMonData(&gPlayerParty[gBattlePartyID[i]], MON_DATA_MAX_HP), HP_MAX); UpdateHpTextInHealthboxInDoubles(gHealthboxSpriteIds[i], GetMonData(&gPlayerParty[gBattlerPartyIndexes[i]], MON_DATA_MAX_HP), HP_MAX);
} }
else // text to bars else // text to bars
{ {
UpdateStatusIconInHealthbox(gHealthBoxesIds[i]); UpdateStatusIconInHealthbox(gHealthboxSpriteIds[i]);
UpdateHealthboxAttribute(gHealthBoxesIds[i], &gPlayerParty[gBattlePartyID[i]], HEALTHBOX_HEALTH_BAR); UpdateHealthboxAttribute(gHealthboxSpriteIds[i], &gPlayerParty[gBattlerPartyIndexes[i]], HEALTHBOX_HEALTH_BAR);
CpuCopy32(GetHealthboxElementGfxPtr(HEALTHBOX_GFX_117), (void*)(OBJ_VRAM0 + 0x680 + gSprites[gHealthBoxesIds[i]].oam.tileNum * 32), 32); CpuCopy32(GetHealthboxElementGfxPtr(HEALTHBOX_GFX_117), (void*)(OBJ_VRAM0 + 0x680 + gSprites[gHealthboxSpriteIds[i]].oam.tileNum * 32), 32);
} }
} }
else else
@ -1453,26 +1453,26 @@ void SwapHpBarsWithHpText(void)
{ {
if (gBattleTypeFlags & BATTLE_TYPE_SAFARI) if (gBattleTypeFlags & BATTLE_TYPE_SAFARI)
{ {
sub_80730D4(gHealthBoxesIds[i], &gEnemyParty[gBattlePartyID[i]]); sub_80730D4(gHealthboxSpriteIds[i], &gEnemyParty[gBattlerPartyIndexes[i]]);
} }
else else
{ {
spriteId = gSprites[gHealthBoxesIds[i]].data[5]; spriteId = gSprites[gHealthboxSpriteIds[i]].data[5];
CpuFill32(0, (void *)(OBJ_VRAM0 + gSprites[spriteId].oam.tileNum * 32), 0x100); CpuFill32(0, (void *)(OBJ_VRAM0 + gSprites[spriteId].oam.tileNum * 32), 0x100);
UpdateHpTextInHealthboxInDoubles(gHealthBoxesIds[i], GetMonData(&gEnemyParty[gBattlePartyID[i]], MON_DATA_HP), HP_CURRENT); UpdateHpTextInHealthboxInDoubles(gHealthboxSpriteIds[i], GetMonData(&gEnemyParty[gBattlerPartyIndexes[i]], MON_DATA_HP), HP_CURRENT);
UpdateHpTextInHealthboxInDoubles(gHealthBoxesIds[i], GetMonData(&gEnemyParty[gBattlePartyID[i]], MON_DATA_MAX_HP), HP_MAX); UpdateHpTextInHealthboxInDoubles(gHealthboxSpriteIds[i], GetMonData(&gEnemyParty[gBattlerPartyIndexes[i]], MON_DATA_MAX_HP), HP_MAX);
} }
} }
else // text to bars else // text to bars
{ {
UpdateStatusIconInHealthbox(gHealthBoxesIds[i]); UpdateStatusIconInHealthbox(gHealthboxSpriteIds[i]);
UpdateHealthboxAttribute(gHealthBoxesIds[i], &gEnemyParty[gBattlePartyID[i]], HEALTHBOX_HEALTH_BAR); UpdateHealthboxAttribute(gHealthboxSpriteIds[i], &gEnemyParty[gBattlerPartyIndexes[i]], HEALTHBOX_HEALTH_BAR);
if (gBattleTypeFlags & BATTLE_TYPE_SAFARI) if (gBattleTypeFlags & BATTLE_TYPE_SAFARI)
UpdateHealthboxAttribute(gHealthBoxesIds[i], &gEnemyParty[gBattlePartyID[i]], HEALTHBOX_NICK); UpdateHealthboxAttribute(gHealthboxSpriteIds[i], &gEnemyParty[gBattlerPartyIndexes[i]], HEALTHBOX_NICK);
} }
} }
gSprites[gHealthBoxesIds[i]].data[7] ^= 1; gSprites[gHealthboxSpriteIds[i]].data[7] ^= 1;
} }
} }
} }
@ -1994,7 +1994,7 @@ static void TryAddPokeballIconToHealthbox(u8 healthboxSpriteId, bool8 noStatus)
bank = gSprites[healthboxSpriteId].data[6]; bank = gSprites[healthboxSpriteId].data[6];
if (GetBattlerSide(bank) == B_SIDE_PLAYER) if (GetBattlerSide(bank) == B_SIDE_PLAYER)
return; return;
if (!GetSetPokedexFlag(SpeciesToNationalPokedexNum(GetMonData(&gEnemyParty[gBattlePartyID[bank]], MON_DATA_SPECIES)), FLAG_GET_CAUGHT)) if (!GetSetPokedexFlag(SpeciesToNationalPokedexNum(GetMonData(&gEnemyParty[gBattlerPartyIndexes[bank]], MON_DATA_SPECIES)), FLAG_GET_CAUGHT))
return; return;
healthboxSpriteId_2 = gSprites[healthboxSpriteId].data[5]; healthboxSpriteId_2 = gSprites[healthboxSpriteId].data[5];
@ -2018,7 +2018,7 @@ static void UpdateStatusIconInHealthbox(u8 healthboxSpriteId)
healthboxSpriteId_2 = gSprites[healthboxSpriteId].data[5]; healthboxSpriteId_2 = gSprites[healthboxSpriteId].data[5];
if (GetBattlerSide(bank) == B_SIDE_PLAYER) if (GetBattlerSide(bank) == B_SIDE_PLAYER)
{ {
status = GetMonData(&gPlayerParty[gBattlePartyID[bank]], MON_DATA_STATUS); status = GetMonData(&gPlayerParty[gBattlerPartyIndexes[bank]], MON_DATA_STATUS);
if (!IsDoubleBattle()) if (!IsDoubleBattle())
tileNumAdder = 0x1A; tileNumAdder = 0x1A;
else else
@ -2026,7 +2026,7 @@ static void UpdateStatusIconInHealthbox(u8 healthboxSpriteId)
} }
else else
{ {
status = GetMonData(&gEnemyParty[gBattlePartyID[bank]], MON_DATA_STATUS); status = GetMonData(&gEnemyParty[gBattlerPartyIndexes[bank]], MON_DATA_STATUS);
tileNumAdder = 0x11; tileNumAdder = 0x11;
} }
@ -2323,7 +2323,7 @@ static void sub_8074B9C(u8 bank, u8 whichBar)
gBattleSpritesDataPtr->battleBars[bank].receivedValue, gBattleSpritesDataPtr->battleBars[bank].receivedValue,
&gBattleSpritesDataPtr->battleBars[bank].field_10, &gBattleSpritesDataPtr->battleBars[bank].field_10,
array, 8); array, 8);
level = GetMonData(&gPlayerParty[gBattlePartyID[bank]], MON_DATA_LEVEL); level = GetMonData(&gPlayerParty[gBattlerPartyIndexes[bank]], MON_DATA_LEVEL);
if (level == MAX_MON_LEVEL) if (level == MAX_MON_LEVEL)
{ {
for (i = 0; i < 8; i++) for (i = 0; i < 8; i++)

File diff suppressed because it is too large Load Diff

View File

@ -17,8 +17,8 @@
extern u16 gLastUsedItem; extern u16 gLastUsedItem;
extern u8 gLastUsedAbility; extern u8 gLastUsedAbility;
extern u8 gActiveBattler; extern u8 gActiveBattler;
extern u8 gBattleAttacker; extern u8 gBattleMoveAttacker;
extern u8 gBattleDefender; extern u8 gBattleMoveTarget;
extern u8 gStringBank; extern u8 gStringBank;
extern u8 gEffectBank; extern u8 gEffectBank;
extern u8 gAbilitiesPerBank[MAX_BATTLERS_COUNT]; extern u8 gAbilitiesPerBank[MAX_BATTLERS_COUNT];
@ -26,7 +26,7 @@ extern u32 gBattleTypeFlags;
extern u16 gTrainerBattleOpponent_A; extern u16 gTrainerBattleOpponent_A;
extern u16 gTrainerBattleOpponent_B; extern u16 gTrainerBattleOpponent_B;
extern u16 gPartnerTrainerId; extern u16 gPartnerTrainerId;
extern u16 gBattlePartyID[MAX_BATTLERS_COUNT]; extern u16 gBattlerPartyIndexes[MAX_BATTLERS_COUNT];
extern struct BattleEnigmaBerry gEnigmaBerries[MAX_BATTLERS_COUNT]; extern struct BattleEnigmaBerry gEnigmaBerries[MAX_BATTLERS_COUNT];
extern u8 gBattleBufferA[MAX_BATTLERS_COUNT][0x200]; extern u8 gBattleBufferA[MAX_BATTLERS_COUNT][0x200];
extern u8 gMoveSelectionCursor[MAX_BATTLERS_COUNT]; extern u8 gMoveSelectionCursor[MAX_BATTLERS_COUNT];
@ -1836,80 +1836,80 @@ u32 BattleStringExpandPlaceholders(const u8* src, u8* dst)
toCpy = gStringVar3; toCpy = gStringVar3;
break; break;
case B_TXT_PLAYER_MON1_NAME: // first player poke name case B_TXT_PLAYER_MON1_NAME: // first player poke name
GetMonData(&gPlayerParty[gBattlePartyID[GetBattlerAtPosition(B_POSITION_PLAYER_LEFT)]], GetMonData(&gPlayerParty[gBattlerPartyIndexes[GetBattlerAtPosition(B_POSITION_PLAYER_LEFT)]],
MON_DATA_NICKNAME, text); MON_DATA_NICKNAME, text);
StringGetEnd10(text); StringGetEnd10(text);
toCpy = text; toCpy = text;
break; break;
case B_TXT_OPPONENT_MON1_NAME: // first enemy poke name case B_TXT_OPPONENT_MON1_NAME: // first enemy poke name
GetMonData(&gEnemyParty[gBattlePartyID[GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT)]], GetMonData(&gEnemyParty[gBattlerPartyIndexes[GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT)]],
MON_DATA_NICKNAME, text); MON_DATA_NICKNAME, text);
StringGetEnd10(text); StringGetEnd10(text);
toCpy = text; toCpy = text;
break; break;
case B_TXT_PLAYER_MON2_NAME: // second player poke name case B_TXT_PLAYER_MON2_NAME: // second player poke name
GetMonData(&gPlayerParty[gBattlePartyID[GetBattlerAtPosition(B_POSITION_PLAYER_RIGHT)]], GetMonData(&gPlayerParty[gBattlerPartyIndexes[GetBattlerAtPosition(B_POSITION_PLAYER_RIGHT)]],
MON_DATA_NICKNAME, text); MON_DATA_NICKNAME, text);
StringGetEnd10(text); StringGetEnd10(text);
toCpy = text; toCpy = text;
break; break;
case B_TXT_OPPONENT_MON2_NAME: // second enemy poke name case B_TXT_OPPONENT_MON2_NAME: // second enemy poke name
GetMonData(&gEnemyParty[gBattlePartyID[GetBattlerAtPosition(B_POSITION_OPPONENT_RIGHT)]], GetMonData(&gEnemyParty[gBattlerPartyIndexes[GetBattlerAtPosition(B_POSITION_OPPONENT_RIGHT)]],
MON_DATA_NICKNAME, text); MON_DATA_NICKNAME, text);
StringGetEnd10(text); StringGetEnd10(text);
toCpy = text; toCpy = text;
break; break;
case B_TXT_LINK_PLAYER_MON1_NAME: // link first player poke name case B_TXT_LINK_PLAYER_MON1_NAME: // link first player poke name
GetMonData(&gPlayerParty[gBattlePartyID[gLinkPlayers[multiplayerID].lp_field_18]], GetMonData(&gPlayerParty[gBattlerPartyIndexes[gLinkPlayers[multiplayerID].lp_field_18]],
MON_DATA_NICKNAME, text); MON_DATA_NICKNAME, text);
StringGetEnd10(text); StringGetEnd10(text);
toCpy = text; toCpy = text;
break; break;
case B_TXT_LINK_OPPONENT_MON1_NAME: // link first opponent poke name case B_TXT_LINK_OPPONENT_MON1_NAME: // link first opponent poke name
GetMonData(&gEnemyParty[gBattlePartyID[gLinkPlayers[multiplayerID].lp_field_18 ^ 1]], GetMonData(&gEnemyParty[gBattlerPartyIndexes[gLinkPlayers[multiplayerID].lp_field_18 ^ 1]],
MON_DATA_NICKNAME, text); MON_DATA_NICKNAME, text);
StringGetEnd10(text); StringGetEnd10(text);
toCpy = text; toCpy = text;
break; break;
case B_TXT_LINK_PLAYER_MON2_NAME: // link second player poke name case B_TXT_LINK_PLAYER_MON2_NAME: // link second player poke name
GetMonData(&gPlayerParty[gBattlePartyID[gLinkPlayers[multiplayerID].lp_field_18 ^ 2]], GetMonData(&gPlayerParty[gBattlerPartyIndexes[gLinkPlayers[multiplayerID].lp_field_18 ^ 2]],
MON_DATA_NICKNAME, text); MON_DATA_NICKNAME, text);
StringGetEnd10(text); StringGetEnd10(text);
toCpy = text; toCpy = text;
break; break;
case B_TXT_LINK_OPPONENT_MON2_NAME: // link second opponent poke name case B_TXT_LINK_OPPONENT_MON2_NAME: // link second opponent poke name
GetMonData(&gEnemyParty[gBattlePartyID[gLinkPlayers[multiplayerID].lp_field_18 ^ 3]], GetMonData(&gEnemyParty[gBattlerPartyIndexes[gLinkPlayers[multiplayerID].lp_field_18 ^ 3]],
MON_DATA_NICKNAME, text); MON_DATA_NICKNAME, text);
StringGetEnd10(text); StringGetEnd10(text);
toCpy = text; toCpy = text;
break; break;
case B_TXT_ATK_NAME_WITH_PREFIX_MON1: // attacker name with prefix, only bank 0/1 case B_TXT_ATK_NAME_WITH_PREFIX_MON1: // attacker name with prefix, only bank 0/1
HANDLE_NICKNAME_STRING_CASE(gBattleAttacker, HANDLE_NICKNAME_STRING_CASE(gBattleMoveAttacker,
gBattlePartyID[GetBattlerAtPosition(GET_BATTLER_SIDE(gBattleAttacker))]) gBattlerPartyIndexes[GetBattlerAtPosition(GET_BATTLER_SIDE(gBattleMoveAttacker))])
break; break;
case B_TXT_ATK_PARTNER_NAME: // attacker partner name case B_TXT_ATK_PARTNER_NAME: // attacker partner name
if (GetBattlerSide(gBattleAttacker) == B_SIDE_PLAYER) if (GetBattlerSide(gBattleMoveAttacker) == B_SIDE_PLAYER)
GetMonData(&gPlayerParty[gBattlePartyID[GetBattlerAtPosition(GET_BATTLER_SIDE(gBattleAttacker)) + 2]], MON_DATA_NICKNAME, text); GetMonData(&gPlayerParty[gBattlerPartyIndexes[GetBattlerAtPosition(GET_BATTLER_SIDE(gBattleMoveAttacker)) + 2]], MON_DATA_NICKNAME, text);
else else
GetMonData(&gEnemyParty[gBattlePartyID[GetBattlerAtPosition(GET_BATTLER_SIDE(gBattleAttacker)) + 2]], MON_DATA_NICKNAME, text); GetMonData(&gEnemyParty[gBattlerPartyIndexes[GetBattlerAtPosition(GET_BATTLER_SIDE(gBattleMoveAttacker)) + 2]], MON_DATA_NICKNAME, text);
StringGetEnd10(text); StringGetEnd10(text);
toCpy = text; toCpy = text;
break; break;
case B_TXT_ATK_NAME_WITH_PREFIX: // attacker name with prefix case B_TXT_ATK_NAME_WITH_PREFIX: // attacker name with prefix
HANDLE_NICKNAME_STRING_CASE(gBattleAttacker, gBattlePartyID[gBattleAttacker]) HANDLE_NICKNAME_STRING_CASE(gBattleMoveAttacker, gBattlerPartyIndexes[gBattleMoveAttacker])
break; break;
case B_TXT_DEF_NAME_WITH_PREFIX: // target name with prefix case B_TXT_DEF_NAME_WITH_PREFIX: // target name with prefix
HANDLE_NICKNAME_STRING_CASE(gBattleDefender, gBattlePartyID[gBattleDefender]) HANDLE_NICKNAME_STRING_CASE(gBattleMoveTarget, gBattlerPartyIndexes[gBattleMoveTarget])
break; break;
case B_TXT_EFF_NAME_WITH_PREFIX: // effect bank name with prefix case B_TXT_EFF_NAME_WITH_PREFIX: // effect bank name with prefix
HANDLE_NICKNAME_STRING_CASE(gEffectBank, gBattlePartyID[gEffectBank]) HANDLE_NICKNAME_STRING_CASE(gEffectBank, gBattlerPartyIndexes[gEffectBank])
break; break;
case B_TXT_ACTIVE_NAME_WITH_PREFIX: // active bank name with prefix case B_TXT_ACTIVE_NAME_WITH_PREFIX: // active bank name with prefix
HANDLE_NICKNAME_STRING_CASE(gActiveBattler, gBattlePartyID[gActiveBattler]) HANDLE_NICKNAME_STRING_CASE(gActiveBattler, gBattlerPartyIndexes[gActiveBattler])
break; break;
case B_TXT_SCR_ACTIVE_NAME_WITH_PREFIX: // scripting active bank name with prefix case B_TXT_SCR_ACTIVE_NAME_WITH_PREFIX: // scripting active bank name with prefix
HANDLE_NICKNAME_STRING_CASE(gBattleScripting.battler, gBattlePartyID[gBattleScripting.battler]) HANDLE_NICKNAME_STRING_CASE(gBattleScripting.battler, gBattlerPartyIndexes[gBattleScripting.battler])
break; break;
case B_TXT_CURRENT_MOVE: // current move name case B_TXT_CURRENT_MOVE: // current move name
if (gStringInfo->currentMove > LAST_MOVE_INDEX) if (gStringInfo->currentMove > LAST_MOVE_INDEX)
@ -1970,10 +1970,10 @@ u32 BattleStringExpandPlaceholders(const u8* src, u8* dst)
toCpy = gAbilityNames[gLastUsedAbility]; toCpy = gAbilityNames[gLastUsedAbility];
break; break;
case B_TXT_ATK_ABILITY: // attacker ability case B_TXT_ATK_ABILITY: // attacker ability
toCpy = gAbilityNames[gAbilitiesPerBank[gBattleAttacker]]; toCpy = gAbilityNames[gAbilitiesPerBank[gBattleMoveAttacker]];
break; break;
case B_TXT_DEF_ABILITY: // target ability case B_TXT_DEF_ABILITY: // target ability
toCpy = gAbilityNames[gAbilitiesPerBank[gBattleDefender]]; toCpy = gAbilityNames[gAbilitiesPerBank[gBattleMoveTarget]];
break; break;
case B_TXT_SCR_ACTIVE_ABILITY: // scripting active ability case B_TXT_SCR_ACTIVE_ABILITY: // scripting active ability
toCpy = gAbilityNames[gAbilitiesPerBank[gBattleScripting.battler]]; toCpy = gAbilityNames[gAbilitiesPerBank[gBattleScripting.battler]];
@ -2039,16 +2039,16 @@ u32 BattleStringExpandPlaceholders(const u8* src, u8* dst)
toCpy = gLinkPlayers[multiplayerID].name; toCpy = gLinkPlayers[multiplayerID].name;
break; break;
case B_TXT_1F: // link partner name? case B_TXT_1F: // link partner name?
toCpy = gLinkPlayers[GetBankMultiplayerId(2 ^ gLinkPlayers[multiplayerID].lp_field_18)].name; toCpy = gLinkPlayers[GetBattlerMultiplayerId(2 ^ gLinkPlayers[multiplayerID].lp_field_18)].name;
break; break;
case B_TXT_20: // link opponent 1 name? case B_TXT_20: // link opponent 1 name?
toCpy = gLinkPlayers[GetBankMultiplayerId(1 ^ gLinkPlayers[multiplayerID].lp_field_18)].name; toCpy = gLinkPlayers[GetBattlerMultiplayerId(1 ^ gLinkPlayers[multiplayerID].lp_field_18)].name;
break; break;
case B_TXT_21: // link opponent 2 name? case B_TXT_21: // link opponent 2 name?
toCpy = gLinkPlayers[GetBankMultiplayerId(3 ^ gLinkPlayers[multiplayerID].lp_field_18)].name; toCpy = gLinkPlayers[GetBattlerMultiplayerId(3 ^ gLinkPlayers[multiplayerID].lp_field_18)].name;
break; break;
case B_TXT_22: // link scripting active name case B_TXT_22: // link scripting active name
toCpy = gLinkPlayers[GetBankMultiplayerId(gBattleScripting.battler)].name; toCpy = gLinkPlayers[GetBattlerMultiplayerId(gBattleScripting.battler)].name;
break; break;
case B_TXT_PLAYER_NAME: // player name case B_TXT_PLAYER_NAME: // player name
if (gBattleTypeFlags & BATTLE_TYPE_RECORDED) if (gBattleTypeFlags & BATTLE_TYPE_RECORDED)
@ -2094,37 +2094,37 @@ u32 BattleStringExpandPlaceholders(const u8* src, u8* dst)
toCpy = gText_Someones; toCpy = gText_Someones;
break; break;
case B_TXT_ATK_PREFIX2: case B_TXT_ATK_PREFIX2:
if (GetBattlerSide(gBattleAttacker) == B_SIDE_PLAYER) if (GetBattlerSide(gBattleMoveAttacker) == B_SIDE_PLAYER)
toCpy = gText_AllyPkmnPrefix2; toCpy = gText_AllyPkmnPrefix2;
else else
toCpy = gText_FoePkmnPrefix3; toCpy = gText_FoePkmnPrefix3;
break; break;
case B_TXT_DEF_PREFIX2: case B_TXT_DEF_PREFIX2:
if (GetBattlerSide(gBattleDefender) == B_SIDE_PLAYER) if (GetBattlerSide(gBattleMoveTarget) == B_SIDE_PLAYER)
toCpy = gText_AllyPkmnPrefix2; toCpy = gText_AllyPkmnPrefix2;
else else
toCpy = gText_FoePkmnPrefix3; toCpy = gText_FoePkmnPrefix3;
break; break;
case B_TXT_ATK_PREFIX1: case B_TXT_ATK_PREFIX1:
if (GetBattlerSide(gBattleAttacker) == B_SIDE_PLAYER) if (GetBattlerSide(gBattleMoveAttacker) == B_SIDE_PLAYER)
toCpy = gText_AllyPkmnPrefix; toCpy = gText_AllyPkmnPrefix;
else else
toCpy = gText_FoePkmnPrefix2; toCpy = gText_FoePkmnPrefix2;
break; break;
case B_TXT_DEF_PREFIX1: case B_TXT_DEF_PREFIX1:
if (GetBattlerSide(gBattleDefender) == B_SIDE_PLAYER) if (GetBattlerSide(gBattleMoveTarget) == B_SIDE_PLAYER)
toCpy = gText_AllyPkmnPrefix; toCpy = gText_AllyPkmnPrefix;
else else
toCpy = gText_FoePkmnPrefix2; toCpy = gText_FoePkmnPrefix2;
break; break;
case B_TXT_ATK_PREFIX3: case B_TXT_ATK_PREFIX3:
if (GetBattlerSide(gBattleAttacker) == B_SIDE_PLAYER) if (GetBattlerSide(gBattleMoveAttacker) == B_SIDE_PLAYER)
toCpy = gText_AllyPkmnPrefix3; toCpy = gText_AllyPkmnPrefix3;
else else
toCpy = gText_FoePkmnPrefix4; toCpy = gText_FoePkmnPrefix4;
break; break;
case B_TXT_DEF_PREFIX3: case B_TXT_DEF_PREFIX3:
if (GetBattlerSide(gBattleDefender) == B_SIDE_PLAYER) if (GetBattlerSide(gBattleMoveTarget) == B_SIDE_PLAYER)
toCpy = gText_AllyPkmnPrefix3; toCpy = gText_AllyPkmnPrefix3;
else else
toCpy = gText_FoePkmnPrefix4; toCpy = gText_FoePkmnPrefix4;

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -9,7 +9,7 @@
#include "battle_scripts.h" #include "battle_scripts.h"
extern struct BattlePokemon gBattleMons[MAX_BATTLERS_COUNT]; extern struct BattlePokemon gBattleMons[MAX_BATTLERS_COUNT];
extern u16 gBattlePartyID[MAX_BATTLERS_COUNT]; extern u16 gBattlerPartyIndexes[MAX_BATTLERS_COUNT];
extern u8 gUnknown_0203CF00[]; extern u8 gUnknown_0203CF00[];
extern const u8 *gBattlescriptCurrInstr; extern const u8 *gBattlescriptCurrInstr;
extern u8 gBattleCommunication[]; extern u8 gBattleCommunication[];
@ -101,13 +101,13 @@ void AdjustFriendshipOnBattleFaint(u8 bank)
if (gBattleMons[opposingBank].level > gBattleMons[bank].level) if (gBattleMons[opposingBank].level > gBattleMons[bank].level)
{ {
if (gBattleMons[opposingBank].level - gBattleMons[bank].level > 29) if (gBattleMons[opposingBank].level - gBattleMons[bank].level > 29)
AdjustFriendship(&gPlayerParty[gBattlePartyID[bank]], 8); AdjustFriendship(&gPlayerParty[gBattlerPartyIndexes[bank]], 8);
else else
AdjustFriendship(&gPlayerParty[gBattlePartyID[bank]], 6); AdjustFriendship(&gPlayerParty[gBattlerPartyIndexes[bank]], 6);
} }
else else
{ {
AdjustFriendship(&gPlayerParty[gBattlePartyID[bank]], 6); AdjustFriendship(&gPlayerParty[gBattlerPartyIndexes[bank]], 6);
} }
} }
@ -122,7 +122,7 @@ void sub_80571DC(u8 bank, u8 arg1)
for (i = 0; i < 3; i++) for (i = 0; i < 3; i++)
gUnknown_0203CF00[i] = *(0 * 3 + i + (u8*)(gBattleStruct->field_60)); gUnknown_0203CF00[i] = *(0 * 3 + i + (u8*)(gBattleStruct->field_60));
sub_81B8FB0(pokemon_order_func(gBattlePartyID[bank]), pokemon_order_func(arg1)); sub_81B8FB0(pokemon_order_func(gBattlerPartyIndexes[bank]), pokemon_order_func(arg1));
for (i = 0; i < 3; i++) for (i = 0; i < 3; i++)
*(0 * 3 + i + (u8*)(gBattleStruct->field_60)) = gUnknown_0203CF00[i]; *(0 * 3 + i + (u8*)(gBattleStruct->field_60)) = gUnknown_0203CF00[i];
@ -207,8 +207,8 @@ u32 sub_805725C(u8 bank)
if (effect == 2) if (effect == 2)
{ {
gActiveBattler = bank; gActiveBattler = bank;
EmitSetMonData(0, REQUEST_STATUS_BATTLE, 0, 4, &gBattleMons[gActiveBattler].status1); BtlController_EmitSetMonData(0, REQUEST_STATUS_BATTLE, 0, 4, &gBattleMons[gActiveBattler].status1);
MarkBufferBankForExecution(gActiveBattler); MarkBattlerForControllerExec(gActiveBattler);
} }
return effect; return effect;

View File

@ -89,7 +89,7 @@ extern void flagmods_08054D70(void);
extern u8* sub_806CF78(u16); extern u8* sub_806CF78(u16);
extern bool8 ExecuteTableBasedItemEffect_(struct Pokemon*, u16, u8, u8); extern bool8 ExecuteTableBasedItemEffect_(struct Pokemon*, u16, u8, u8);
extern u8 gBankInMenu; extern u8 gBankInMenu;
extern u16 gBattlePartyID[]; extern u16 gBattlerPartyIndexes[];
extern void sub_81B89F0(void); extern void sub_81B89F0(void);
extern u8 GetItemEffectType(u16); extern u8 GetItemEffectType(u16);
@ -1131,7 +1131,7 @@ void sub_80FE440(u8 taskId)
void ItemUseInBattle_StatIncrease(u8 taskId) void ItemUseInBattle_StatIncrease(u8 taskId)
{ {
u16 partyId = gBattlePartyID[gBankInMenu]; u16 partyId = gBattlerPartyIndexes[gBankInMenu];
if (ExecuteTableBasedItemEffect_(&gPlayerParty[partyId], gSpecialVar_ItemId, partyId, 0) != FALSE) if (ExecuteTableBasedItemEffect_(&gPlayerParty[partyId], gSpecialVar_ItemId, partyId, 0) != FALSE)
{ {

View File

@ -17,10 +17,10 @@
extern bool8 gDoingBattleAnim; extern bool8 gDoingBattleAnim;
extern u8 gActiveBattler; extern u8 gActiveBattler;
extern u8 gBattleDefender; extern u8 gBattleMoveTarget;
extern u16 gBattlePartyID[]; extern u16 gBattlerPartyIndexes[];
extern u8 gBankSpriteIds[]; extern u8 gBattlerSpriteIds[];
extern u8 gHealthBoxesIds[]; extern u8 gHealthboxSpriteIds[];
extern struct MusicPlayerInfo gMPlayInfo_BGM; extern struct MusicPlayerInfo gMPlayInfo_BGM;
// this file's functions // this file's functions
@ -364,9 +364,9 @@ static void Task_DoPokeballSendOutAnim(u8 taskId)
bank = gTasks[taskId].tBank; bank = gTasks[taskId].tBank;
if (GetBattlerSide(bank) != B_SIDE_PLAYER) if (GetBattlerSide(bank) != B_SIDE_PLAYER)
itemId = GetMonData(&gEnemyParty[gBattlePartyID[bank]], MON_DATA_POKEBALL); itemId = GetMonData(&gEnemyParty[gBattlerPartyIndexes[bank]], MON_DATA_POKEBALL);
else else
itemId = GetMonData(&gPlayerParty[gBattlePartyID[bank]], MON_DATA_POKEBALL); itemId = GetMonData(&gPlayerParty[gBattlerPartyIndexes[bank]], MON_DATA_POKEBALL);
ballId = ItemIdToBallId(itemId); ballId = ItemIdToBallId(itemId);
LoadBallGfx(ballId); LoadBallGfx(ballId);
@ -378,25 +378,25 @@ static void Task_DoPokeballSendOutAnim(u8 taskId)
switch (throwCaseId) switch (throwCaseId)
{ {
case POKEBALL_PLAYER_SENDOUT: case POKEBALL_PLAYER_SENDOUT:
gBattleDefender = bank; gBattleMoveTarget = bank;
gSprites[ballSpriteId].pos1.x = 24; gSprites[ballSpriteId].pos1.x = 24;
gSprites[ballSpriteId].pos1.y = 68; gSprites[ballSpriteId].pos1.y = 68;
gSprites[ballSpriteId].callback = SpriteCB_PlayerMonSendOut_1; gSprites[ballSpriteId].callback = SpriteCB_PlayerMonSendOut_1;
break; break;
case POKEBALL_OPPONENT_SENDOUT: case POKEBALL_OPPONENT_SENDOUT:
gSprites[ballSpriteId].pos1.x = GetBankCoord(bank, BANK_X_POS); gSprites[ballSpriteId].pos1.x = GetBattlerSpriteCoord(bank, BANK_X_POS);
gSprites[ballSpriteId].pos1.y = GetBankCoord(bank, BANK_Y_POS) + 24; gSprites[ballSpriteId].pos1.y = GetBattlerSpriteCoord(bank, BANK_Y_POS) + 24;
gBattleDefender = bank; gBattleMoveTarget = bank;
gSprites[ballSpriteId].data[0] = 0; gSprites[ballSpriteId].data[0] = 0;
gSprites[ballSpriteId].callback = SpriteCB_OpponentMonSendOut; gSprites[ballSpriteId].callback = SpriteCB_OpponentMonSendOut;
break; break;
default: default:
gBattleDefender = GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT); gBattleMoveTarget = GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT);
notSendOut = TRUE; notSendOut = TRUE;
break; break;
} }
gSprites[ballSpriteId].sBank = gBattleDefender; gSprites[ballSpriteId].sBank = gBattleMoveTarget;
if (!notSendOut) if (!notSendOut)
{ {
DestroyTask(taskId); DestroyTask(taskId);
@ -405,12 +405,12 @@ static void Task_DoPokeballSendOutAnim(u8 taskId)
// this will perform an unused ball throw animation // this will perform an unused ball throw animation
gSprites[ballSpriteId].data[0] = 0x22; gSprites[ballSpriteId].data[0] = 0x22;
gSprites[ballSpriteId].data[2] = GetBankCoord(gBattleDefender, BANK_X_POS); gSprites[ballSpriteId].data[2] = GetBattlerSpriteCoord(gBattleMoveTarget, BANK_X_POS);
gSprites[ballSpriteId].data[4] = GetBankCoord(gBattleDefender, BANK_Y_POS) - 16; gSprites[ballSpriteId].data[4] = GetBattlerSpriteCoord(gBattleMoveTarget, BANK_Y_POS) - 16;
gSprites[ballSpriteId].data[5] = -40; gSprites[ballSpriteId].data[5] = -40;
sub_80A68D4(&gSprites[ballSpriteId]); sub_80A68D4(&gSprites[ballSpriteId]);
gSprites[ballSpriteId].oam.affineParam = taskId; gSprites[ballSpriteId].oam.affineParam = taskId;
gTasks[taskId].tOpponentBank = gBattleDefender; gTasks[taskId].tOpponentBank = gBattleMoveTarget;
gTasks[taskId].func = TaskDummy; gTasks[taskId].func = TaskDummy;
PlaySE(SE_NAGERU); PlaySE(SE_NAGERU);
} }
@ -458,9 +458,9 @@ static void sub_80756E0(struct Sprite *sprite)
{ {
sprite->data[5] = 0; sprite->data[5] = 0;
sprite->callback = sub_807574C; sprite->callback = sub_807574C;
StartSpriteAffineAnim(&gSprites[gBankSpriteIds[sprite->sBank]], 2); StartSpriteAffineAnim(&gSprites[gBattlerSpriteIds[sprite->sBank]], 2);
AnimateSprite(&gSprites[gBankSpriteIds[sprite->sBank]]); AnimateSprite(&gSprites[gBattlerSpriteIds[sprite->sBank]]);
gSprites[gBankSpriteIds[sprite->sBank]].data[1] = 0; gSprites[gBattlerSpriteIds[sprite->sBank]].data[1] = 0;
} }
} }
@ -469,17 +469,17 @@ static void sub_807574C(struct Sprite *sprite)
sprite->data[5]++; sprite->data[5]++;
if (sprite->data[5] == 11) if (sprite->data[5] == 11)
PlaySE(SE_SUIKOMU); PlaySE(SE_SUIKOMU);
if (gSprites[gBankSpriteIds[sprite->sBank]].affineAnimEnded) if (gSprites[gBattlerSpriteIds[sprite->sBank]].affineAnimEnded)
{ {
StartSpriteAnim(sprite, 2); StartSpriteAnim(sprite, 2);
gSprites[gBankSpriteIds[sprite->sBank]].invisible = TRUE; gSprites[gBattlerSpriteIds[sprite->sBank]].invisible = TRUE;
sprite->data[5] = 0; sprite->data[5] = 0;
sprite->callback = sub_80757E4; sprite->callback = sub_80757E4;
} }
else else
{ {
gSprites[gBankSpriteIds[sprite->sBank]].data[1] += 0x60; gSprites[gBattlerSpriteIds[sprite->sBank]].data[1] += 0x60;
gSprites[gBankSpriteIds[sprite->sBank]].pos2.y = -gSprites[gBankSpriteIds[sprite->sBank]].data[1] >> 8; gSprites[gBattlerSpriteIds[sprite->sBank]].pos2.y = -gSprites[gBattlerSpriteIds[sprite->sBank]].data[1] >> 8;
} }
} }
@ -757,12 +757,12 @@ static void SpriteCB_ReleaseMonFromBall(struct Sprite *sprite)
if (GetBattlerSide(bank) != B_SIDE_PLAYER) if (GetBattlerSide(bank) != B_SIDE_PLAYER)
{ {
mon = &gEnemyParty[gBattlePartyID[bank]]; mon = &gEnemyParty[gBattlerPartyIndexes[bank]];
pan = 25; pan = 25;
} }
else else
{ {
mon = &gPlayerParty[gBattlePartyID[bank]]; mon = &gPlayerParty[gBattlerPartyIndexes[bank]];
pan = -25; pan = -25;
} }
@ -795,21 +795,21 @@ static void SpriteCB_ReleaseMonFromBall(struct Sprite *sprite)
gTasks[taskId].tCryTaskPan = pan; gTasks[taskId].tCryTaskPan = pan;
gTasks[taskId].tCryTaskWantedCry = wantedCryCase; gTasks[taskId].tCryTaskWantedCry = wantedCryCase;
gTasks[taskId].tCryTaskBank = bank; gTasks[taskId].tCryTaskBank = bank;
gTasks[taskId].tCryTaskMonSpriteId = gBankSpriteIds[sprite->sBank]; gTasks[taskId].tCryTaskMonSpriteId = gBattlerSpriteIds[sprite->sBank];
gTasks[taskId].tCryTaskMonPtr1 = (u32)(mon) >> 0x10; gTasks[taskId].tCryTaskMonPtr1 = (u32)(mon) >> 0x10;
gTasks[taskId].tCryTaskMonPtr2 = (u32)(mon); gTasks[taskId].tCryTaskMonPtr2 = (u32)(mon);
gTasks[taskId].tCryTaskState = 0; gTasks[taskId].tCryTaskState = 0;
} }
StartSpriteAffineAnim(&gSprites[gBankSpriteIds[sprite->sBank]], 1); StartSpriteAffineAnim(&gSprites[gBattlerSpriteIds[sprite->sBank]], 1);
if (GetBattlerSide(sprite->sBank) == B_SIDE_OPPONENT) if (GetBattlerSide(sprite->sBank) == B_SIDE_OPPONENT)
gSprites[gBankSpriteIds[sprite->sBank]].callback = sub_8039B58; gSprites[gBattlerSpriteIds[sprite->sBank]].callback = sub_8039B58;
else else
gSprites[gBankSpriteIds[sprite->sBank]].callback = sub_8039E44; gSprites[gBattlerSpriteIds[sprite->sBank]].callback = sub_8039E44;
AnimateSprite(&gSprites[gBankSpriteIds[sprite->sBank]]); AnimateSprite(&gSprites[gBattlerSpriteIds[sprite->sBank]]);
gSprites[gBankSpriteIds[sprite->sBank]].data[1] = 0x1000; gSprites[gBattlerSpriteIds[sprite->sBank]].data[1] = 0x1000;
} }
#undef tCryTaskSpecies #undef tCryTaskSpecies
@ -836,24 +836,24 @@ static void HandleBallAnimEnd(struct Sprite *sprite)
bool8 affineAnimEnded = FALSE; bool8 affineAnimEnded = FALSE;
u8 bank = sprite->sBank; u8 bank = sprite->sBank;
gSprites[gBankSpriteIds[bank]].invisible = FALSE; gSprites[gBattlerSpriteIds[bank]].invisible = FALSE;
if (sprite->animEnded) if (sprite->animEnded)
sprite->invisible = TRUE; sprite->invisible = TRUE;
if (gSprites[gBankSpriteIds[bank]].affineAnimEnded) if (gSprites[gBattlerSpriteIds[bank]].affineAnimEnded)
{ {
StartSpriteAffineAnim(&gSprites[gBankSpriteIds[bank]], 0); StartSpriteAffineAnim(&gSprites[gBattlerSpriteIds[bank]], 0);
affineAnimEnded = TRUE; affineAnimEnded = TRUE;
} }
else else
{ {
gSprites[gBankSpriteIds[bank]].data[1] -= 288; gSprites[gBattlerSpriteIds[bank]].data[1] -= 288;
gSprites[gBankSpriteIds[bank]].pos2.y = gSprites[gBankSpriteIds[bank]].data[1] >> 8; gSprites[gBattlerSpriteIds[bank]].pos2.y = gSprites[gBattlerSpriteIds[bank]].data[1] >> 8;
} }
if (sprite->animEnded && affineAnimEnded) if (sprite->animEnded && affineAnimEnded)
{ {
s32 i, doneBanks; s32 i, doneBanks;
gSprites[gBankSpriteIds[bank]].pos2.y = 0; gSprites[gBattlerSpriteIds[bank]].pos2.y = 0;
gDoingBattleAnim = FALSE; gDoingBattleAnim = FALSE;
gBattleSpritesDataPtr->healthBoxesData[bank].ballAnimActive = 0; gBattleSpritesDataPtr->healthBoxesData[bank].ballAnimActive = 0;
FreeSpriteOamMatrix(sprite); FreeSpriteOamMatrix(sprite);
@ -889,8 +889,8 @@ static void sub_80760F8(struct Sprite *sprite)
} }
else if (sprite->data[4] == 315) else if (sprite->data[4] == 315)
{ {
FreeOamMatrix(gSprites[gBankSpriteIds[sprite->sBank]].oam.matrixNum); FreeOamMatrix(gSprites[gBattlerSpriteIds[sprite->sBank]].oam.matrixNum);
DestroySprite(&gSprites[gBankSpriteIds[sprite->sBank]]); DestroySprite(&gSprites[gBattlerSpriteIds[sprite->sBank]]);
DestroySpriteAndFreeResources(sprite); DestroySpriteAndFreeResources(sprite);
if (gMain.inBattle) if (gMain.inBattle)
gBattleSpritesDataPtr->healthBoxesData[bank].ballAnimActive = 0; gBattleSpritesDataPtr->healthBoxesData[bank].ballAnimActive = 0;
@ -900,8 +900,8 @@ static void sub_80760F8(struct Sprite *sprite)
static void SpriteCB_PlayerMonSendOut_1(struct Sprite *sprite) static void SpriteCB_PlayerMonSendOut_1(struct Sprite *sprite)
{ {
sprite->data[0] = 25; sprite->data[0] = 25;
sprite->data[2] = GetBankCoord(sprite->sBank, 2); sprite->data[2] = GetBattlerSpriteCoord(sprite->sBank, 2);
sprite->data[4] = GetBankCoord(sprite->sBank, 3) + 24; sprite->data[4] = GetBattlerSpriteCoord(sprite->sBank, 3) + 24;
sprite->data[5] = -30; sprite->data[5] = -30;
sprite->oam.affineParam = sprite->sBank; sprite->oam.affineParam = sprite->sBank;
sub_80A68D4(sprite); sub_80A68D4(sprite);
@ -1183,7 +1183,7 @@ static void DestroySpriteAndFreeResources_(struct Sprite *sprite)
void sub_8076918(u8 bank) void sub_8076918(u8 bank)
{ {
struct Sprite *healthboxSprite = &gSprites[gHealthBoxesIds[bank]]; struct Sprite *healthboxSprite = &gSprites[gHealthboxSpriteIds[bank]];
healthboxSprite->data[0] = 5; healthboxSprite->data[0] = 5;
healthboxSprite->data[1] = 0; healthboxSprite->data[1] = 0;
@ -1226,7 +1226,7 @@ void DoHitAnimHealthboxEffect(u8 bank)
spriteId = CreateInvisibleSpriteWithCallback(SpriteCB_HitAnimHealthoxEffect); spriteId = CreateInvisibleSpriteWithCallback(SpriteCB_HitAnimHealthoxEffect);
gSprites[spriteId].data[0] = 1; gSprites[spriteId].data[0] = 1;
gSprites[spriteId].data[1] = gHealthBoxesIds[bank]; gSprites[spriteId].data[1] = gHealthboxSpriteIds[bank];
gSprites[spriteId].callback = SpriteCB_HitAnimHealthoxEffect; gSprites[spriteId].callback = SpriteCB_HitAnimHealthoxEffect;
} }
@ -1276,7 +1276,7 @@ void FreeBallGfx(u8 ballId)
static u16 GetBankPokeballItemId(u8 bank) static u16 GetBankPokeballItemId(u8 bank)
{ {
if (GetBattlerSide(bank) == B_SIDE_PLAYER) if (GetBattlerSide(bank) == B_SIDE_PLAYER)
return GetMonData(&gPlayerParty[gBattlePartyID[bank]], MON_DATA_POKEBALL); return GetMonData(&gPlayerParty[gBattlerPartyIndexes[bank]], MON_DATA_POKEBALL);
else else
return GetMonData(&gEnemyParty[gBattlePartyID[bank]], MON_DATA_POKEBALL); return GetMonData(&gEnemyParty[gBattlerPartyIndexes[bank]], MON_DATA_POKEBALL);
} }

View File

@ -16,8 +16,8 @@ struct Unknown_020249B4
extern u8 gAbsentBattlerFlags; extern u8 gAbsentBattlerFlags;
extern u8 gActiveBattler; extern u8 gActiveBattler;
extern u8 gBattleAttacker; extern u8 gBattleMoveAttacker;
extern u8 gBattleDefender; extern u8 gBattleMoveTarget;
extern u8 gLastUsedAbility; extern u8 gLastUsedAbility;
extern u16 gTrainerBattleOpponent_A; extern u16 gTrainerBattleOpponent_A;
extern u32 gBattleTypeFlags; extern u32 gBattleTypeFlags;
@ -55,14 +55,14 @@ u8 CountAliveMonsInBattle(u8 caseId)
case BATTLE_ALIVE_ATK_SIDE: case BATTLE_ALIVE_ATK_SIDE:
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
{ {
if (GetBattlerSide(i) == GetBattlerSide(gBattleAttacker) && !(gAbsentBattlerFlags & gBitTable[i])) if (GetBattlerSide(i) == GetBattlerSide(gBattleMoveAttacker) && !(gAbsentBattlerFlags & gBitTable[i]))
retVal++; retVal++;
} }
break; break;
case BATTLE_ALIVE_DEF_SIDE: case BATTLE_ALIVE_DEF_SIDE:
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
{ {
if (GetBattlerSide(i) == GetBattlerSide(gBattleDefender) && !(gAbsentBattlerFlags & gBitTable[i])) if (GetBattlerSide(i) == GetBattlerSide(gBattleMoveTarget) && !(gAbsentBattlerFlags & gBitTable[i]))
retVal++; retVal++;
} }
break; break;

View File

@ -27,13 +27,13 @@ extern struct BattlePokemon gBattleMons[4];
extern struct BattleEnigmaBerry gEnigmaBerries[4]; extern struct BattleEnigmaBerry gEnigmaBerries[4];
extern u8 gActiveBattler; extern u8 gActiveBattler;
extern u8 gBankInMenu; extern u8 gBankInMenu;
extern u8 gBattleDefender; extern u8 gBattleMoveTarget;
extern u8 gBattleAttacker; extern u8 gBattleMoveAttacker;
extern u8 gStringBank; extern u8 gStringBank;
extern u16 gTrainerBattleOpponent_A; extern u16 gTrainerBattleOpponent_A;
extern u32 gBattleTypeFlags; extern u32 gBattleTypeFlags;
extern u8 gBattleMonForms[4]; extern u8 gBattleMonForms[4];
extern u16 gBattlePartyID[4]; extern u16 gBattlerPartyIndexes[4];
extern u8 gLastUsedAbility; extern u8 gLastUsedAbility;
extern u16 gPartnerTrainerId; extern u16 gPartnerTrainerId;
extern u32 gHitMarker; extern u32 gHitMarker;
@ -210,7 +210,7 @@ u8 GetItemEffectParamOffset(u16 itemId, u8 effectByte, u8 effectBit)
void sub_806CF24(s32 stat) void sub_806CF24(s32 stat)
{ {
gBattleDefender = gBankInMenu; gBattleMoveTarget = gBankInMenu;
StringCopy(gBattleTextBuff1, gStatNamesTable[gUnknown_08329EC8[stat]]); StringCopy(gBattleTextBuff1, gStatNamesTable[gUnknown_08329EC8[stat]]);
StringCopy(gBattleTextBuff2, gText_StatRose); StringCopy(gBattleTextBuff2, gText_StatRose);
BattleStringExpandPlaceholdersToDisplayedString(gText_PkmnsStatChanged2); BattleStringExpandPlaceholdersToDisplayedString(gText_PkmnsStatChanged2);
@ -247,7 +247,7 @@ u8 *sub_806CF78(u16 itemId)
} }
else else
{ {
gBattleAttacker = gBankInMenu; gBattleMoveAttacker = gBankInMenu;
BattleStringExpandPlaceholdersToDisplayedString(gText_PkmnGettingPumped); BattleStringExpandPlaceholdersToDisplayedString(gText_PkmnGettingPumped);
} }
} }
@ -255,7 +255,7 @@ u8 *sub_806CF78(u16 itemId)
if (itemEffect[3] & 0x80) if (itemEffect[3] & 0x80)
{ {
gBattleAttacker = gBankInMenu; gBattleMoveAttacker = gBankInMenu;
BattleStringExpandPlaceholdersToDisplayedString(gText_PkmnShroudedInMist); BattleStringExpandPlaceholdersToDisplayedString(gText_PkmnShroudedInMist);
} }
@ -615,7 +615,7 @@ bool16 sub_806D82C(u8 id)
return retVal; return retVal;
} }
s32 GetBankMultiplayerId(u16 a1) s32 GetBattlerMultiplayerId(u16 a1)
{ {
s32 id; s32 id;
for (id = 0; id < MAX_LINK_PLAYERS; id++) for (id = 0; id < MAX_LINK_PLAYERS; id++)
@ -1367,11 +1367,11 @@ void sub_806E994(void)
gBattleTextBuff1[4] = B_BUFF_EOS; gBattleTextBuff1[4] = B_BUFF_EOS;
if (!GetBattlerSide(gBattleStruct->field_49)) if (!GetBattlerSide(gBattleStruct->field_49))
gBattleTextBuff1[3] = pokemon_order_func(gBattlePartyID[gBattleStruct->field_49]); gBattleTextBuff1[3] = pokemon_order_func(gBattlerPartyIndexes[gBattleStruct->field_49]);
else else
gBattleTextBuff1[3] = gBattlePartyID[gBattleStruct->field_49]; gBattleTextBuff1[3] = gBattlerPartyIndexes[gBattleStruct->field_49];
PREPARE_MON_NICK_WITH_PREFIX_BUFFER(gBattleTextBuff2, gBankInMenu, pokemon_order_func(gBattlePartyID[gBankInMenu])) PREPARE_MON_NICK_WITH_PREFIX_BUFFER(gBattleTextBuff2, gBankInMenu, pokemon_order_func(gBattlerPartyIndexes[gBankInMenu]))
BattleStringExpandPlaceholders(gText_PkmnsXPreventsSwitching, gStringVar4); BattleStringExpandPlaceholders(gText_PkmnsXPreventsSwitching, gStringVar4);
} }
@ -1478,7 +1478,7 @@ const u8 *GetTrainerPartnerName(void)
else else
{ {
u8 id = GetMultiplayerId(); u8 id = GetMultiplayerId();
return gLinkPlayers[GetBankMultiplayerId(gLinkPlayers[id].lp_field_18 ^ 2)].name; return gLinkPlayers[GetBattlerMultiplayerId(gLinkPlayers[id].lp_field_18 ^ 2)].name;
} }
} }

View File

@ -16,7 +16,7 @@ struct UnkAnimStruct
s16 field_8; s16 field_8;
}; };
extern u16 gBattlePartyID[]; extern u16 gBattlerPartyIndexes[];
// this file's functions // this file's functions
static void pokemonanimfunc_00(struct Sprite *sprite); static void pokemonanimfunc_00(struct Sprite *sprite);
@ -945,7 +945,7 @@ void LaunchAnimationTaskForBackSprite(struct Sprite *sprite, u8 backAnimSet)
gTasks[taskId].tPtrHI = (u32)(sprite); gTasks[taskId].tPtrHI = (u32)(sprite);
bank = sprite->data[0]; bank = sprite->data[0];
nature = GetNature(&gPlayerParty[gBattlePartyID[bank]]); nature = GetNature(&gPlayerParty[gBattlerPartyIndexes[bank]]);
animId = 3 * backAnimSet + sBackAnimNatureModTable[nature]; animId = 3 * backAnimSet + sBackAnimNatureModTable[nature];
gTasks[taskId].tAnimId = sBackAnimationIds[animId]; gTasks[taskId].tAnimId = sBackAnimationIds[animId];

View File

@ -27,7 +27,7 @@ extern u16 gTrainerBattleOpponent_B;
extern u16 gPartnerTrainerId; extern u16 gPartnerTrainerId;
extern u8 gActiveBattler; extern u8 gActiveBattler;
extern u8 gBattlersCount; extern u8 gBattlersCount;
extern u16 gBattlePartyID[MAX_BATTLERS_COUNT]; extern u16 gBattlerPartyIndexes[MAX_BATTLERS_COUNT];
extern struct BattlePokemon gBattleMons[MAX_BATTLERS_COUNT]; extern struct BattlePokemon gBattleMons[MAX_BATTLERS_COUNT];
extern u16 gChosenMovesByBanks[MAX_BATTLERS_COUNT]; extern u16 gChosenMovesByBanks[MAX_BATTLERS_COUNT];
extern u8 gUnknown_03001278; extern u8 gUnknown_03001278;
@ -200,7 +200,7 @@ void sub_8184E58(void)
} }
} }
void RecordedBattle_SetBankAction(u8 bank, u8 action) void RecordedBattle_SetBattlerAction(u8 bank, u8 action)
{ {
if (sRecordedBytesNo[bank] < BANK_RECORD_SIZE && sUnknown_0203C7AC != 2) if (sRecordedBytesNo[bank] < BANK_RECORD_SIZE && sUnknown_0203C7AC != 2)
{ {
@ -208,7 +208,7 @@ void RecordedBattle_SetBankAction(u8 bank, u8 action)
} }
} }
void RecordedBattle_ClearBankAction(u8 bank, u8 bytesToClear) void RecordedBattle_ClearBattlerAction(u8 bank, u8 bytesToClear)
{ {
s32 i; s32 i;
@ -221,7 +221,7 @@ void RecordedBattle_ClearBankAction(u8 bank, u8 bytesToClear)
} }
} }
u8 RecordedBattle_ReadBankAction(u8 bank) u8 RecordedBattle_GetBankAction(u8 bank)
{ {
// trying to read past array or invalid action byte, battle is over // trying to read past array or invalid action byte, battle is over
if (sRecordedBytesNo[bank] >= BANK_RECORD_SIZE || sBattleRecords[bank][sRecordedBytesNo[bank]] == 0xFF) if (sRecordedBytesNo[bank] >= BANK_RECORD_SIZE || sBattleRecords[bank][sRecordedBytesNo[bank]] == 0xFF)
@ -1536,14 +1536,14 @@ void sub_818603C(u8 arg0)
} }
if (j != 4) // player's mon's move has been changed if (j != 4) // player's mon's move has been changed
{ {
RecordedBattle_SetBankAction(bank, ACTION_MOVE_CHANGE); RecordedBattle_SetBattlerAction(bank, ACTION_MOVE_CHANGE);
for (j = 0; j < 4; j++) for (j = 0; j < 4; j++)
{ {
for (k = 0; k < 4; k++) for (k = 0; k < 4; k++)
{ {
if (gBattleMons[bank].moves[j] == sRecordedBattle_PlayerMonMoves[bank / 2][k]) if (gBattleMons[bank].moves[j] == sRecordedBattle_PlayerMonMoves[bank / 2][k])
{ {
RecordedBattle_SetBankAction(bank, k); RecordedBattle_SetBattlerAction(bank, k);
break; break;
} }
} }
@ -1561,14 +1561,14 @@ void sub_818603C(u8 arg0)
u8 array3[8]; u8 array3[8];
u8 var; u8 var;
RecordedBattle_ReadBankAction(bank); RecordedBattle_GetBankAction(bank);
for (j = 0; j < 4; j++) for (j = 0; j < 4; j++)
{ {
ppBonuses[j] = ((gBattleMons[bank].ppBonuses & ((3 << (j << 1)))) >> (j << 1)); ppBonuses[j] = ((gBattleMons[bank].ppBonuses & ((3 << (j << 1)))) >> (j << 1));
} }
for (j = 0; j < 4; j++) for (j = 0; j < 4; j++)
{ {
array1[j] = RecordedBattle_ReadBankAction(bank); array1[j] = RecordedBattle_GetBankAction(bank);
movePp.moves[j] = gBattleMons[bank].moves[array1[j]]; movePp.moves[j] = gBattleMons[bank].moves[array1[j]];
movePp.pp[j] = gBattleMons[bank].pp[array1[j]]; movePp.pp[j] = gBattleMons[bank].pp[array1[j]];
array3[j] = ppBonuses[array1[j]]; array3[j] = ppBonuses[array1[j]];
@ -1591,25 +1591,25 @@ void sub_818603C(u8 arg0)
{ {
for (j = 0; j < 4; j++) for (j = 0; j < 4; j++)
{ {
ppBonuses[j] = ((GetMonData(&gPlayerParty[gBattlePartyID[bank]], MON_DATA_PP_BONUSES, NULL) & ((3 << (j << 1)))) >> (j << 1)); ppBonuses[j] = ((GetMonData(&gPlayerParty[gBattlerPartyIndexes[bank]], MON_DATA_PP_BONUSES, NULL) & ((3 << (j << 1)))) >> (j << 1));
} }
for (j = 0; j < 4; j++) for (j = 0; j < 4; j++)
{ {
movePp.moves[j] = GetMonData(&gPlayerParty[gBattlePartyID[bank]], MON_DATA_MOVE1 + array1[j], NULL); movePp.moves[j] = GetMonData(&gPlayerParty[gBattlerPartyIndexes[bank]], MON_DATA_MOVE1 + array1[j], NULL);
movePp.pp[j] = GetMonData(&gPlayerParty[gBattlePartyID[bank]], MON_DATA_PP1 + array1[j], NULL); movePp.pp[j] = GetMonData(&gPlayerParty[gBattlerPartyIndexes[bank]], MON_DATA_PP1 + array1[j], NULL);
array3[j] = ppBonuses[array1[j]]; array3[j] = ppBonuses[array1[j]];
} }
for (j = 0; j < 4; j++) for (j = 0; j < 4; j++)
{ {
SetMonData(&gPlayerParty[gBattlePartyID[bank]], MON_DATA_MOVE1 + j, &movePp.moves[j]); SetMonData(&gPlayerParty[gBattlerPartyIndexes[bank]], MON_DATA_MOVE1 + j, &movePp.moves[j]);
SetMonData(&gPlayerParty[gBattlePartyID[bank]], MON_DATA_PP1 + j, &movePp.pp[j]); SetMonData(&gPlayerParty[gBattlerPartyIndexes[bank]], MON_DATA_PP1 + j, &movePp.pp[j]);
} }
var = 0; var = 0;
for (j = 0; j < 4; j++) for (j = 0; j < 4; j++)
{ {
var |= (array3[j]) << (j << 1); var |= (array3[j]) << (j << 1);
} }
SetMonData(&gPlayerParty[gBattlePartyID[bank]], MON_DATA_PP_BONUSES, &var); SetMonData(&gPlayerParty[gBattlerPartyIndexes[bank]], MON_DATA_PP_BONUSES, &var);
} }
gChosenMovesByBanks[bank] = gBattleMons[bank].moves[*(gBattleStruct->chosenMovePositions + bank)]; gChosenMovesByBanks[bank] = gBattleMons[bank].moves[*(gBattleStruct->chosenMovePositions + bank)];

View File

@ -24,12 +24,12 @@ extern u16 gBattle_BG3_Y;
extern u8 gReservedSpritePaletteCount; extern u8 gReservedSpritePaletteCount;
extern u8 gActionSelectionCursor[MAX_BATTLERS_COUNT]; extern u8 gActionSelectionCursor[MAX_BATTLERS_COUNT];
extern u8 gBankInMenu; extern u8 gBankInMenu;
extern u16 gBattlePartyID[MAX_BATTLERS_COUNT]; extern u16 gBattlerPartyIndexes[MAX_BATTLERS_COUNT];
extern u8 gBattlersCount; extern u8 gBattlersCount;
extern u32 gBattleTypeFlags; extern u32 gBattleTypeFlags;
extern u8 gBankSpriteIds[MAX_BATTLERS_COUNT]; extern u8 gBattlerSpriteIds[MAX_BATTLERS_COUNT];
extern u8 gBattleMonForms[MAX_BATTLERS_COUNT]; extern u8 gBattleMonForms[MAX_BATTLERS_COUNT];
extern u8 gHealthBoxesIds[MAX_BATTLERS_COUNT]; extern u8 gHealthboxSpriteIds[MAX_BATTLERS_COUNT];
extern struct SpriteTemplate gUnknown_0202499C; extern struct SpriteTemplate gUnknown_0202499C;
extern const union AnimCmd * const * const gMonAnimationsSpriteAnimsPtrTable[]; extern const union AnimCmd * const * const gMonAnimationsSpriteAnimsPtrTable[];
@ -38,11 +38,11 @@ extern void ScanlineEffect_Clear(void);
extern void sub_8035658(void); extern void sub_8035658(void);
extern bool8 IsDoubleBattle(void); extern bool8 IsDoubleBattle(void);
extern u8 GetSubstituteSpriteDefault_Y(u8 bank); extern u8 GetSubstituteSpriteDefault_Y(u8 bank);
extern u8 GetBankSpriteDefault_Y(u8 bank); extern u8 GetBattlerSpriteDefault_Y(u8 bank);
extern u8 sub_80A82E4(u8 bank); extern u8 sub_80A82E4(u8 bank);
extern void sub_806A068(u16 species, u8 bankIdentity); extern void sub_806A068(u16 species, u8 bankIdentity);
extern void sub_806A12C(u16 backPicId, u8 bankIdentity); extern void sub_806A12C(u16 backPicId, u8 bankIdentity);
extern u8 GetBankCoord(u8 bank, u8 caseId); extern u8 GetBattlerSpriteCoord(u8 bank, u8 caseId);
// this file's functions // this file's functions
static void CB2_ReshowBattleScreenAfterMenu(void); static void CB2_ReshowBattleScreenAfterMenu(void);
@ -165,14 +165,14 @@ static void CB2_ReshowBattleScreenAfterMenu(void)
LoadAndCreateEnemyShadowSprites(); LoadAndCreateEnemyShadowSprites();
opponentBank = GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT); opponentBank = GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT);
species = GetMonData(&gEnemyParty[gBattlePartyID[opponentBank]], MON_DATA_SPECIES); species = GetMonData(&gEnemyParty[gBattlerPartyIndexes[opponentBank]], MON_DATA_SPECIES);
SetBankEnemyShadowSpriteCallback(opponentBank, species); SetBattlerShadowSpriteCallback(opponentBank, species);
if (IsDoubleBattle()) if (IsDoubleBattle())
{ {
opponentBank = GetBattlerAtPosition(B_POSITION_OPPONENT_RIGHT); opponentBank = GetBattlerAtPosition(B_POSITION_OPPONENT_RIGHT);
species = GetMonData(&gEnemyParty[gBattlePartyID[opponentBank]], MON_DATA_SPECIES); species = GetMonData(&gEnemyParty[gBattlerPartyIndexes[opponentBank]], MON_DATA_SPECIES);
SetBankEnemyShadowSpriteCallback(opponentBank, species); SetBattlerShadowSpriteCallback(opponentBank, species);
} }
ActionSelectionCreateCursorAt(gActionSelectionCursor[gBankInMenu], 0); ActionSelectionCreateCursorAt(gActionSelectionCursor[gBankInMenu], 0);
@ -215,7 +215,7 @@ static bool8 LoadBankSpriteGfx(u8 bank)
if (GetBattlerSide(bank) != B_SIDE_PLAYER) if (GetBattlerSide(bank) != B_SIDE_PLAYER)
{ {
if (!gBattleSpritesDataPtr->bankData[bank].behindSubstitute) if (!gBattleSpritesDataPtr->bankData[bank].behindSubstitute)
BattleLoadOpponentMonSpriteGfx(&gEnemyParty[gBattlePartyID[bank]], bank); BattleLoadOpponentMonSpriteGfx(&gEnemyParty[gBattlerPartyIndexes[bank]], bank);
else else
BattleLoadSubstituteOrMonSpriteGfx(bank, FALSE); BattleLoadSubstituteOrMonSpriteGfx(bank, FALSE);
} }
@ -224,7 +224,7 @@ static bool8 LoadBankSpriteGfx(u8 bank)
else if (gBattleTypeFlags & BATTLE_TYPE_WALLY_TUTORIAL && bank == 0) else if (gBattleTypeFlags & BATTLE_TYPE_WALLY_TUTORIAL && bank == 0)
DecompressTrainerBackPic(BACK_PIC_WALLY, bank); DecompressTrainerBackPic(BACK_PIC_WALLY, bank);
else if (!gBattleSpritesDataPtr->bankData[bank].behindSubstitute) else if (!gBattleSpritesDataPtr->bankData[bank].behindSubstitute)
BattleLoadPlayerMonSpriteGfx(&gPlayerParty[gBattlePartyID[bank]], bank); BattleLoadPlayerMonSpriteGfx(&gPlayerParty[gBattlerPartyIndexes[bank]], bank);
else else
BattleLoadSubstituteOrMonSpriteGfx(bank, FALSE); BattleLoadSubstituteOrMonSpriteGfx(bank, FALSE);
@ -252,62 +252,62 @@ static void CreateBankSprite(u8 bank)
if (gBattleSpritesDataPtr->bankData[bank].behindSubstitute) if (gBattleSpritesDataPtr->bankData[bank].behindSubstitute)
posY = GetSubstituteSpriteDefault_Y(bank); posY = GetSubstituteSpriteDefault_Y(bank);
else else
posY = GetBankSpriteDefault_Y(bank); posY = GetBattlerSpriteDefault_Y(bank);
if (GetBattlerSide(bank) != B_SIDE_PLAYER) if (GetBattlerSide(bank) != B_SIDE_PLAYER)
{ {
if (GetMonData(&gEnemyParty[gBattlePartyID[bank]], MON_DATA_HP) == 0) if (GetMonData(&gEnemyParty[gBattlerPartyIndexes[bank]], MON_DATA_HP) == 0)
return; return;
sub_806A068(GetMonData(&gEnemyParty[gBattlePartyID[bank]], MON_DATA_SPECIES), GetBattlerPosition(bank)); sub_806A068(GetMonData(&gEnemyParty[gBattlerPartyIndexes[bank]], MON_DATA_SPECIES), GetBattlerPosition(bank));
gBankSpriteIds[bank] = CreateSprite(&gUnknown_0202499C, GetBankCoord(bank, 2), posY, sub_80A82E4(bank)); gBattlerSpriteIds[bank] = CreateSprite(&gUnknown_0202499C, GetBattlerSpriteCoord(bank, 2), posY, sub_80A82E4(bank));
gSprites[gBankSpriteIds[bank]].oam.paletteNum = bank; gSprites[gBattlerSpriteIds[bank]].oam.paletteNum = bank;
gSprites[gBankSpriteIds[bank]].callback = SpriteCallbackDummy; gSprites[gBattlerSpriteIds[bank]].callback = SpriteCallbackDummy;
gSprites[gBankSpriteIds[bank]].data[0] = bank; gSprites[gBattlerSpriteIds[bank]].data[0] = bank;
gSprites[gBankSpriteIds[bank]].data[2] = GetMonData(&gEnemyParty[gBattlePartyID[bank]], MON_DATA_SPECIES); gSprites[gBattlerSpriteIds[bank]].data[2] = GetMonData(&gEnemyParty[gBattlerPartyIndexes[bank]], MON_DATA_SPECIES);
StartSpriteAnim(&gSprites[gBankSpriteIds[bank]], gBattleMonForms[bank]); StartSpriteAnim(&gSprites[gBattlerSpriteIds[bank]], gBattleMonForms[bank]);
if (gBattleSpritesDataPtr->bankData[bank].transformSpecies == SPECIES_CASTFORM) if (gBattleSpritesDataPtr->bankData[bank].transformSpecies == SPECIES_CASTFORM)
gSprites[gBankSpriteIds[bank]].anims = gMonAnimationsSpriteAnimsPtrTable[SPECIES_CASTFORM]; gSprites[gBattlerSpriteIds[bank]].anims = gMonAnimationsSpriteAnimsPtrTable[SPECIES_CASTFORM];
} }
else if (gBattleTypeFlags & BATTLE_TYPE_SAFARI && bank == 0) else if (gBattleTypeFlags & BATTLE_TYPE_SAFARI && bank == 0)
{ {
sub_806A12C(gSaveBlock2Ptr->playerGender, GetBattlerPosition(B_POSITION_PLAYER_LEFT)); sub_806A12C(gSaveBlock2Ptr->playerGender, GetBattlerPosition(B_POSITION_PLAYER_LEFT));
gBankSpriteIds[bank] = CreateSprite(&gUnknown_0202499C, 0x50, gBattlerSpriteIds[bank] = CreateSprite(&gUnknown_0202499C, 0x50,
(8 - gTrainerBackPicCoords[gSaveBlock2Ptr->playerGender].coords) * 4 + 80, (8 - gTrainerBackPicCoords[gSaveBlock2Ptr->playerGender].coords) * 4 + 80,
sub_80A82E4(0)); sub_80A82E4(0));
gSprites[gBankSpriteIds[bank]].oam.paletteNum = bank; gSprites[gBattlerSpriteIds[bank]].oam.paletteNum = bank;
gSprites[gBankSpriteIds[bank]].callback = SpriteCallbackDummy; gSprites[gBattlerSpriteIds[bank]].callback = SpriteCallbackDummy;
gSprites[gBankSpriteIds[bank]].data[0] = bank; gSprites[gBattlerSpriteIds[bank]].data[0] = bank;
} }
else if (gBattleTypeFlags & BATTLE_TYPE_WALLY_TUTORIAL && bank == 0) else if (gBattleTypeFlags & BATTLE_TYPE_WALLY_TUTORIAL && bank == 0)
{ {
sub_806A12C(BACK_PIC_WALLY, GetBattlerPosition(0)); sub_806A12C(BACK_PIC_WALLY, GetBattlerPosition(0));
gBankSpriteIds[bank] = CreateSprite(&gUnknown_0202499C, 0x50, gBattlerSpriteIds[bank] = CreateSprite(&gUnknown_0202499C, 0x50,
(8 - gTrainerBackPicCoords[BACK_PIC_WALLY].coords) * 4 + 80, (8 - gTrainerBackPicCoords[BACK_PIC_WALLY].coords) * 4 + 80,
sub_80A82E4(0)); sub_80A82E4(0));
gSprites[gBankSpriteIds[bank]].oam.paletteNum = bank; gSprites[gBattlerSpriteIds[bank]].oam.paletteNum = bank;
gSprites[gBankSpriteIds[bank]].callback = SpriteCallbackDummy; gSprites[gBattlerSpriteIds[bank]].callback = SpriteCallbackDummy;
gSprites[gBankSpriteIds[bank]].data[0] = bank; gSprites[gBattlerSpriteIds[bank]].data[0] = bank;
} }
else else
{ {
if (GetMonData(&gPlayerParty[gBattlePartyID[bank]], MON_DATA_HP) == 0) if (GetMonData(&gPlayerParty[gBattlerPartyIndexes[bank]], MON_DATA_HP) == 0)
return; return;
sub_806A068(GetMonData(&gPlayerParty[gBattlePartyID[bank]], MON_DATA_SPECIES), GetBattlerPosition(bank)); sub_806A068(GetMonData(&gPlayerParty[gBattlerPartyIndexes[bank]], MON_DATA_SPECIES), GetBattlerPosition(bank));
gBankSpriteIds[bank] = CreateSprite(&gUnknown_0202499C, GetBankCoord(bank, 2), posY, sub_80A82E4(bank)); gBattlerSpriteIds[bank] = CreateSprite(&gUnknown_0202499C, GetBattlerSpriteCoord(bank, 2), posY, sub_80A82E4(bank));
gSprites[gBankSpriteIds[bank]].oam.paletteNum = bank; gSprites[gBattlerSpriteIds[bank]].oam.paletteNum = bank;
gSprites[gBankSpriteIds[bank]].callback = SpriteCallbackDummy; gSprites[gBattlerSpriteIds[bank]].callback = SpriteCallbackDummy;
gSprites[gBankSpriteIds[bank]].data[0] = bank; gSprites[gBattlerSpriteIds[bank]].data[0] = bank;
gSprites[gBankSpriteIds[bank]].data[2] = GetMonData(&gPlayerParty[gBattlePartyID[bank]], MON_DATA_SPECIES); gSprites[gBattlerSpriteIds[bank]].data[2] = GetMonData(&gPlayerParty[gBattlerPartyIndexes[bank]], MON_DATA_SPECIES);
StartSpriteAnim(&gSprites[gBankSpriteIds[bank]], gBattleMonForms[bank]); StartSpriteAnim(&gSprites[gBattlerSpriteIds[bank]], gBattleMonForms[bank]);
if (gBattleSpritesDataPtr->bankData[bank].transformSpecies == SPECIES_CASTFORM) if (gBattleSpritesDataPtr->bankData[bank].transformSpecies == SPECIES_CASTFORM)
gSprites[gBankSpriteIds[bank]].anims = gMonAnimationsSpriteAnimsPtrTable[SPECIES_CASTFORM]; gSprites[gBattlerSpriteIds[bank]].anims = gMonAnimationsSpriteAnimsPtrTable[SPECIES_CASTFORM];
} }
gSprites[gBankSpriteIds[bank]].invisible = gBattleSpritesDataPtr->bankData[bank].invisible; gSprites[gBattlerSpriteIds[bank]].invisible = gBattleSpritesDataPtr->bankData[bank].invisible;
} }
} }
@ -322,32 +322,32 @@ static void CreateHealthboxSprite(u8 bank)
else if (gBattleTypeFlags & BATTLE_TYPE_WALLY_TUTORIAL && bank == 0) else if (gBattleTypeFlags & BATTLE_TYPE_WALLY_TUTORIAL && bank == 0)
return; return;
else else
healthboxSpriteId = CreateBankHealthboxSprites(bank); healthboxSpriteId = CreateHealthboxSprites(bank);
gHealthBoxesIds[bank] = healthboxSpriteId; gHealthboxSpriteIds[bank] = healthboxSpriteId;
SetBankHealthboxSpritePos(bank); InitBattlerHealthboxCoords(bank);
SetHealthboxSpriteVisible(healthboxSpriteId); SetHealthboxSpriteVisible(healthboxSpriteId);
if (GetBattlerSide(bank) != B_SIDE_PLAYER) if (GetBattlerSide(bank) != B_SIDE_PLAYER)
UpdateHealthboxAttribute(gHealthBoxesIds[bank], &gEnemyParty[gBattlePartyID[bank]], HEALTHBOX_ALL); UpdateHealthboxAttribute(gHealthboxSpriteIds[bank], &gEnemyParty[gBattlerPartyIndexes[bank]], HEALTHBOX_ALL);
else if (gBattleTypeFlags & BATTLE_TYPE_SAFARI) else if (gBattleTypeFlags & BATTLE_TYPE_SAFARI)
UpdateHealthboxAttribute(gHealthBoxesIds[bank], &gPlayerParty[gBattlePartyID[bank]], HEALTHBOX_SAFARI_ALL_TEXT); UpdateHealthboxAttribute(gHealthboxSpriteIds[bank], &gPlayerParty[gBattlerPartyIndexes[bank]], HEALTHBOX_SAFARI_ALL_TEXT);
else else
UpdateHealthboxAttribute(gHealthBoxesIds[bank], &gPlayerParty[gBattlePartyID[bank]], HEALTHBOX_ALL); UpdateHealthboxAttribute(gHealthboxSpriteIds[bank], &gPlayerParty[gBattlerPartyIndexes[bank]], HEALTHBOX_ALL);
if (GetBattlerPosition(bank) == B_POSITION_OPPONENT_RIGHT || GetBattlerPosition(bank) == B_POSITION_PLAYER_RIGHT) if (GetBattlerPosition(bank) == B_POSITION_OPPONENT_RIGHT || GetBattlerPosition(bank) == B_POSITION_PLAYER_RIGHT)
DummyBattleInterfaceFunc(gHealthBoxesIds[bank], TRUE); DummyBattleInterfaceFunc(gHealthboxSpriteIds[bank], TRUE);
else else
DummyBattleInterfaceFunc(gHealthBoxesIds[bank], FALSE); DummyBattleInterfaceFunc(gHealthboxSpriteIds[bank], FALSE);
if (GetBattlerSide(bank) != B_SIDE_PLAYER) if (GetBattlerSide(bank) != B_SIDE_PLAYER)
{ {
if (GetMonData(&gEnemyParty[gBattlePartyID[bank]], MON_DATA_HP) == 0) if (GetMonData(&gEnemyParty[gBattlerPartyIndexes[bank]], MON_DATA_HP) == 0)
SetHealthboxSpriteInvisible(healthboxSpriteId); SetHealthboxSpriteInvisible(healthboxSpriteId);
} }
else if (!(gBattleTypeFlags & BATTLE_TYPE_SAFARI)) else if (!(gBattleTypeFlags & BATTLE_TYPE_SAFARI))
{ {
if (GetMonData(&gPlayerParty[gBattlePartyID[bank]], MON_DATA_HP) == 0) if (GetMonData(&gPlayerParty[gBattlerPartyIndexes[bank]], MON_DATA_HP) == 0)
SetHealthboxSpriteInvisible(healthboxSpriteId); SetHealthboxSpriteInvisible(healthboxSpriteId);
} }
} }

View File

@ -215,10 +215,10 @@ gBattleResults: @ 3005D10
gLeveledUpInBattle: @ 3005D54 gLeveledUpInBattle: @ 3005D54
.space 0xC .space 0xC
gBattlerFuncs: @ 3005D60 gBattlerControllerFuncs: @ 3005D60
.space 0x10 .space 0x10
gHealthBoxesIds: @ 3005D70 gHealthboxSpriteIds: @ 3005D70
.space 0x4 .space 0x4
gMultiUsePlayerCursor: @ 3005D74 gMultiUsePlayerCursor: @ 3005D74

View File

@ -273,13 +273,13 @@ gBattleBufferB: @ 2023864
gActiveBattler: @ 2024064 gActiveBattler: @ 2024064
.space 0x4 .space 0x4
gBattleExecBuffer: @ 2024068 gBattleControllerExecFlags: @ 2024068
.space 0x4 .space 0x4
gBattlersCount: @ 202406C gBattlersCount: @ 202406C
.space 0x2 .space 0x2
gBattlePartyID: @ 202406E gBattlerPartyIndexes: @ 202406E
.space 0x8 .space 0x8
gBattlerPositions: @ 2024076 gBattlerPositions: @ 2024076
@ -300,7 +300,7 @@ gCurrentActionFuncId: @ 2024083
gBattleMons: @ 2024084 gBattleMons: @ 2024084
.space 0x160 .space 0x160
gBankSpriteIds: @ 20241E4 gBattlerSpriteIds: @ 20241E4
.space 0x4 .space 0x4
gCurrMovePos: @ 20241E8 gCurrMovePos: @ 20241E8
@ -333,10 +333,10 @@ gLastUsedItem: @ 2024208
gLastUsedAbility: @ 202420A gLastUsedAbility: @ 202420A
.space 0x1 .space 0x1
gBattleAttacker: @ 202420B gBattleMoveAttacker: @ 202420B
.space 0x1 .space 0x1
gBattleDefender: @ 202420C gBattleMoveTarget: @ 202420C
.space 0x1 .space 0x1
gBank1: @ 202420D gBank1: @ 202420D