summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--asm/battle_2.s26
-rw-r--r--asm/battle_4.s5876
-rw-r--r--asm/battle_5.s12
-rw-r--r--asm/battle_7.s6
-rw-r--r--asm/battle_controller_linkopponent.s2
-rw-r--r--asm/battle_controller_linkpartner.s2
-rw-r--r--asm/battle_controller_opponent.s2
-rw-r--r--asm/battle_controller_player.s4
-rw-r--r--asm/battle_controller_player_partner.s2
-rw-r--r--asm/battle_controller_recorded_opponent.s2
-rw-r--r--asm/battle_controller_recorded_player.s2
-rw-r--r--asm/battle_controller_safari.s2
-rw-r--r--asm/battle_controller_wally.s2
-rw-r--r--asm/rom3.s18
-rw-r--r--data/battle_scripts_1.s12
-rw-r--r--include/battle.h144
-rw-r--r--include/battle_controllers.h3
-rw-r--r--include/pokemon.h3
-rw-r--r--src/battle_3.c92
-rw-r--r--src/battle_4.c1884
-rw-r--r--sym_common.txt2
-rw-r--r--sym_ewram.txt4
22 files changed, 2010 insertions, 6092 deletions
diff --git a/asm/battle_2.s b/asm/battle_2.s
index ad449bfdf..47db7e082 100644
--- a/asm/battle_2.s
+++ b/asm/battle_2.s
@@ -6513,7 +6513,7 @@ _0803A0AE:
ldr r5, =gPauseCounterBattle
ldr r6, =gBattleMoveDamage
ldr r7, =gUnknown_020243FC
- ldr r0, =gUnknown_03005D54
+ ldr r0, =gLeveledUpInBattle
mov r8, r0
ldr r1, =gAbsentBankFlags
mov r9, r1
@@ -7256,8 +7256,8 @@ _0803A6B4:
.pool
thumb_func_end sub_803A284
- thumb_func_start sub_803A75C
-sub_803A75C: @ 803A75C
+ thumb_func_start UndoEffectsAfterFainting
+UndoEffectsAfterFainting: @ 803A75C
push {r4-r7,lr}
mov r7, r10
mov r6, r9
@@ -7786,7 +7786,7 @@ _0803AB6C:
pop {r0}
bx r0
.pool
- thumb_func_end sub_803A75C
+ thumb_func_end UndoEffectsAfterFainting
thumb_func_start bc_8012FAC
bc_8012FAC: @ 803ABC0
@@ -12891,7 +12891,7 @@ _0803D920:
ands r2, r0
cmp r2, 0
beq _0803D95C
- bl sub_805EA60
+ bl BattleMusicStop
ldr r1, =gBattlescriptCurrInstr
ldr r0, =gUnknown_082DAA87
str r0, [r1]
@@ -12912,7 +12912,7 @@ _0803D95C:
beq _0803D968
b _0803DA9E
_0803D968:
- bl sub_805EA60
+ bl BattleMusicStop
ldr r1, =gBattlescriptCurrInstr
ldr r0, =gUnknown_082DA92D
str r0, [r1]
@@ -13371,7 +13371,7 @@ sub_803DE40: @ 803DE40
cmp r0, 0
bne _0803DE86
bl ResetSpriteData
- ldr r0, =gUnknown_03005D54
+ ldr r0, =gLeveledUpInBattle
ldrb r0, [r0]
cmp r0, 0
beq _0803DE62
@@ -13409,7 +13409,7 @@ _0803DEA2:
thumb_func_start bc_evolution_cutscene
bc_evolution_cutscene: @ 803DEB4
push {r4-r6,lr}
- ldr r0, =gUnknown_03005D54
+ ldr r0, =gLeveledUpInBattle
ldrb r1, [r0]
adds r3, r0, 0
cmp r1, 0
@@ -13454,7 +13454,7 @@ _0803DEC2:
.pool
_0803DF20:
adds r6, 0x1
- ldr r3, =gUnknown_03005D54
+ ldr r3, =gLeveledUpInBattle
cmp r6, 0x5
ble _0803DEC2
ldrb r0, [r3]
@@ -16323,7 +16323,7 @@ PrepareStringBattle: @ 803F964
sub_803F988: @ 803F988
push {r4-r6,lr}
movs r3, 0
- ldr r0, =gUnknown_020243FE
+ ldr r0, =gSentPokesToOpponent
strb r3, [r0]
strb r3, [r0, 0x1]
movs r1, 0
@@ -16351,7 +16351,7 @@ _0803F9B6:
ldrb r0, [r2]
cmp r1, r0
bge _0803F9D6
- ldr r5, =gUnknown_020243FE
+ ldr r5, =gSentPokesToOpponent
movs r4, 0x2
_0803F9C4:
adds r0, r1, 0
@@ -16389,7 +16389,7 @@ sub_803F9EC: @ 803F9EC
lsls r0, 24
lsrs r0, 25
mov r12, r0
- ldr r1, =gUnknown_020243FE
+ ldr r1, =gSentPokesToOpponent
adds r0, r1
strb r4, [r0]
adds r5, r4, 0
@@ -16453,7 +16453,7 @@ _0803FA8C:
ldrb r0, [r5]
cmp r3, r0
bge _0803FAC2
- ldr r0, =gUnknown_020243FE
+ ldr r0, =gSentPokesToOpponent
mov r12, r0
movs r7, 0x2
ldr r6, =gBitTable
diff --git a/asm/battle_4.s b/asm/battle_4.s
index 667b93ec8..ddde05c1d 100644
--- a/asm/battle_4.s
+++ b/asm/battle_4.s
@@ -6,5848 +6,6 @@
.text
- thumb_func_start SetMoveEffect
-SetMoveEffect: @ 8048760
- push {r4-r7,lr}
- mov r7, r10
- mov r6, r9
- mov r5, r8
- push {r5-r7}
- sub sp, 0x8
- lsls r0, 24
- lsrs r5, r0, 24
- lsls r1, 24
- lsrs r6, r1, 24
- movs r0, 0
- mov r10, r0
- movs r7, 0
- movs r1, 0x1
- str r1, [sp, 0x4]
- ldr r1, =gBattleCommunication
- ldrb r3, [r1, 0x3]
- movs r0, 0x40
- ands r0, r3
- cmp r0, 0
- beq _080487B8
- ldr r2, =gEffectBank
- ldr r0, =gBankAttacker
- ldrb r0, [r0]
- strb r0, [r2]
- movs r0, 0xBF
- ands r0, r3
- adds r3, r1, 0
- strb r0, [r3, 0x3]
- movs r7, 0x40
- ldr r1, =gBattleScripting
- ldr r0, =gBankTarget
- b _080487C4
- .pool
-_080487B8:
- ldr r2, =gEffectBank
- ldr r0, =gBankTarget
- ldrb r0, [r0]
- strb r0, [r2]
- ldr r1, =gBattleScripting
- ldr r0, =gBankAttacker
-_080487C4:
- ldrb r0, [r0]
- strb r0, [r1, 0x17]
- mov r9, r2
- ldr r2, =gBattleMons
- mov r4, r9
- ldrb r1, [r4]
- movs r0, 0x58
- muls r0, r1
- adds r0, r2
- adds r0, 0x20
- ldrb r0, [r0]
- cmp r0, 0x13
- bne _08048828
- ldr r0, =gHitMarker
- ldr r0, [r0]
- movs r1, 0x80
- lsls r1, 6
- ands r0, r1
- cmp r0, 0
- bne _08048828
- cmp r5, 0
- bne _08048828
- ldr r1, =gBattleCommunication
- ldrb r0, [r1, 0x3]
- cmp r0, 0x9
- bhi _08048828
- ldr r1, =gBattlescriptCurrInstr
- ldr r0, [r1]
- adds r0, 0x1
- str r0, [r1]
- ldr r2, =gBattleCommunication
- strb r5, [r2, 0x3]
- bl _080499B8
- .pool
-_08048828:
- mov r3, r9
- ldrb r0, [r3]
- bl GetBankIdentity
- ldr r2, =gSideAffecting
- movs r1, 0x1
- ands r1, r0
- lsls r1, 1
- adds r1, r2
- ldrh r1, [r1]
- movs r0, 0x20
- ands r0, r1
- cmp r0, 0
- beq _08048880
- ldr r0, =gHitMarker
- ldr r0, [r0]
- movs r1, 0x80
- lsls r1, 6
- ands r0, r1
- cmp r0, 0
- bne _08048880
- cmp r5, 0
- bne _08048880
- ldr r0, =gBattleCommunication
- ldrb r1, [r0, 0x3]
- cmp r1, 0x7
- bhi _08048880
- ldr r1, =gBattlescriptCurrInstr
- ldr r0, [r1]
- adds r0, 0x1
- str r0, [r1]
- ldr r4, =gBattleCommunication
- strb r5, [r4, 0x3]
- bl _080499B8
- .pool
-_08048880:
- ldr r3, =gBattleMons
- ldr r2, =gEffectBank
- ldrb r1, [r2]
- movs r0, 0x58
- muls r0, r1
- adds r0, r3
- ldrh r4, [r0, 0x28]
- mov r9, r2
- mov r8, r3
- cmp r4, 0
- bne _080488C4
- ldr r1, =gBattleCommunication
- ldrb r0, [r1, 0x3]
- cmp r0, 0xB
- beq _080488C4
- cmp r0, 0x1F
- beq _080488C4
- ldr r1, =gBattlescriptCurrInstr
- ldr r0, [r1]
- adds r0, 0x1
- str r0, [r1]
- ldr r2, =gBattleCommunication
- strb r4, [r2, 0x3]
- bl _080499B8
- .pool
-_080488C4:
- mov r3, r9
- ldrb r1, [r3]
- movs r0, 0x58
- muls r0, r1
- mov r1, r8
- adds r1, 0x50
- adds r0, r1
- ldr r0, [r0]
- movs r1, 0x80
- lsls r1, 17
- ands r0, r1
- cmp r0, 0
- beq _080488FC
- cmp r7, 0x40
- beq _080488FC
- ldr r0, =gBattlescriptCurrInstr
- ldr r1, [r0]
- adds r1, 0x1
- str r1, [r0]
- movs r0, 0
- ldr r4, =gBattleCommunication
- strb r0, [r4, 0x3]
- bl _080499B8
- .pool
-_080488FC:
- ldr r1, =gBattleCommunication
- ldrb r0, [r1, 0x3]
- cmp r0, 0x6
- bls _08048906
- b _08048F40
-_08048906:
- ldr r1, =gStatusFlagsForMoveEffects
- ldr r2, =gBattleCommunication
- ldrb r0, [r2, 0x3]
- lsls r0, 2
- adds r0, r1
- ldr r0, [r0]
- cmp r0, 0x10
- bne _08048918
- b _08048AFC
-_08048918:
- cmp r0, 0x10
- bhi _08048930
- cmp r0, 0x7
- beq _0804894A
- cmp r0, 0x8
- beq _08048A00
- b _08048DF4
- .pool
-_08048930:
- cmp r0, 0x40
- bne _08048936
- b _08048C84
-_08048936:
- cmp r0, 0x40
- bhi _08048942
- cmp r0, 0x20
- bne _08048940
- b _08048BEA
-_08048940:
- b _08048DF4
-_08048942:
- cmp r0, 0x80
- bne _08048948
- b _08048D02
-_08048948:
- b _08048DF4
-_0804894A:
- mov r3, r9
- ldrb r1, [r3]
- movs r0, 0x58
- muls r0, r1
- add r0, r8
- adds r0, 0x20
- ldrb r0, [r0]
- cmp r0, 0x2B
- beq _080489AC
- ldr r0, =gActiveBank
- movs r1, 0
- strb r1, [r0]
- ldr r1, =gNoOfAllBanks
- ldrb r3, [r1]
- adds r7, r0, 0
- mov r12, r1
- cmp r3, 0
- beq _080489B8
- mov r4, r8
- ldr r0, [r4, 0x50]
- movs r1, 0x70
- ands r0, r1
- cmp r0, 0
- bne _080489B8
- adds r1, r7, 0
- mov r6, r8
- adds r6, 0x50
- movs r5, 0x58
- movs r4, 0x70
-_08048984:
- ldrb r0, [r1]
- adds r0, 0x1
- strb r0, [r1]
- lsls r0, 24
- lsrs r0, 24
- cmp r0, r3
- bcs _080489B8
- ldrb r0, [r7]
- muls r0, r5
- adds r0, r6
- ldr r0, [r0]
- ands r0, r4
- cmp r0, 0
- beq _08048984
- b _080489B8
- .pool
-_080489AC:
- ldr r0, =gActiveBank
- ldr r2, =gNoOfAllBanks
- ldrb r1, [r2]
- strb r1, [r0]
- adds r7, r0, 0
- mov r12, r2
-_080489B8:
- mov r0, r9
- ldrb r2, [r0]
- movs r0, 0x58
- adds r1, r2, 0
- muls r1, r0
- mov r0, r8
- adds r0, 0x4C
- adds r0, r1, r0
- ldr r0, [r0]
- cmp r0, 0
- beq _080489D0
- b _08048DF4
-_080489D0:
- ldrb r0, [r7]
- mov r3, r12
- ldrb r3, [r3]
- cmp r0, r3
- beq _080489DC
- b _08048DF4
-_080489DC:
- mov r4, r8
- adds r0, r1, r4
- adds r0, 0x20
- ldrb r0, [r0]
- cmp r0, 0x48
- bne _080489EA
- b _08048DF4
-_080489EA:
- cmp r0, 0xF
- bne _080489F0
- b _08048DF4
-_080489F0:
- adds r0, r2, 0
- bl CancelMultiTurnMoves
- b _08048DE4
- .pool
-_08048A00:
- mov r2, r9
- ldrb r1, [r2]
- movs r0, 0x58
- muls r0, r1
- add r0, r8
- adds r0, 0x20
- ldrb r1, [r0]
- cmp r1, 0x11
- bne _08048A70
- cmp r5, 0x1
- beq _08048A1A
- cmp r6, 0x80
- bne _08048A70
-_08048A1A:
- ldr r0, =gLastUsedAbility
- strb r1, [r0]
- mov r3, r9
- ldrb r0, [r3]
- movs r1, 0x11
- bl RecordAbilityBattle
- ldr r4, =gBattlescriptCurrInstr
- ldr r0, [r4]
- adds r0, 0x1
- bl b_movescr_stack_push
- ldr r0, =BattleScript_PSNPrevention
- str r0, [r4]
- ldr r2, =gHitMarker
- ldr r1, [r2]
- movs r0, 0x80
- lsls r0, 6
- ands r0, r1
- cmp r0, 0
- bne _08048A46
- b _08048D20
-_08048A46:
- movs r0, 0x1
- ldr r4, =gBattleCommunication
- strb r0, [r4, 0x5]
-_08048A4C:
- ldr r0, =0xffffdfff
- ands r1, r0
- str r1, [r2]
- bl _080499B2
- .pool
-_08048A70:
- mov r2, r9
- ldrb r0, [r2]
- movs r1, 0x58
- muls r0, r1
- add r0, r8
- adds r1, r0, 0
- adds r1, 0x21
- ldrb r1, [r1]
- cmp r1, 0x3
- beq _08048A94
- adds r0, 0x22
- ldrb r0, [r0]
- cmp r0, 0x3
- beq _08048A94
- cmp r1, 0x8
- beq _08048A94
- cmp r0, 0x8
- bne _08048AAE
-_08048A94:
- ldr r0, =gHitMarker
- ldr r0, [r0]
- movs r1, 0x80
- lsls r1, 6
- ands r0, r1
- cmp r0, 0
- beq _08048AAE
- cmp r5, 0x1
- bne _08048AA8
- b _08048D66
-_08048AA8:
- cmp r6, 0x80
- bne _08048AAE
- b _08048D66
-_08048AAE:
- mov r3, r9
- ldrb r1, [r3]
- movs r0, 0x58
- muls r1, r0
- mov r4, r8
- adds r3, r1, r4
- adds r0, r3, 0
- adds r0, 0x21
- ldrb r4, [r0]
- cmp r4, 0x3
- bne _08048AC6
- b _08048DF4
-_08048AC6:
- adds r0, 0x1
- ldrb r0, [r0]
- cmp r0, 0x3
- bne _08048AD0
- b _08048DF4
-_08048AD0:
- cmp r4, 0x8
- bne _08048AD6
- b _08048DF4
-_08048AD6:
- cmp r0, 0x8
- bne _08048ADC
- b _08048DF4
-_08048ADC:
- mov r0, r8
- adds r0, 0x4C
- adds r0, r1, r0
- ldr r0, [r0]
- cmp r0, 0
- beq _08048AEA
- b _08048DF4
-_08048AEA:
- adds r0, r3, 0
- adds r0, 0x20
- ldrb r0, [r0]
- cmp r0, 0x11
- bne _08048AF6
- b _08048DF4
-_08048AF6:
- b _08048DE4
- .pool
-_08048AFC:
- mov r2, r9
- ldrb r1, [r2]
- movs r0, 0x58
- muls r0, r1
- add r0, r8
- adds r0, 0x20
- ldrb r1, [r0]
- cmp r1, 0x29
- bne _08048B54
- cmp r5, 0x1
- beq _08048B16
- cmp r6, 0x80
- bne _08048B54
-_08048B16:
- ldr r0, =gLastUsedAbility
- strb r1, [r0]
- mov r3, r9
- ldrb r0, [r3]
- movs r1, 0x29
- bl RecordAbilityBattle
- ldr r4, =gBattlescriptCurrInstr
- ldr r0, [r4]
- adds r0, 0x1
- bl b_movescr_stack_push
- ldr r0, =BattleScript_BRNPrevention
- str r0, [r4]
- ldr r2, =gHitMarker
- ldr r1, [r2]
- movs r0, 0x80
- lsls r0, 6
- ands r0, r1
- cmp r0, 0
- beq _08048B42
- b _08048A46
-_08048B42:
- b _08048D20
- .pool
-_08048B54:
- mov r2, r9
- ldrb r1, [r2]
- movs r0, 0x58
- muls r0, r1
- mov r3, r8
- adds r1, r0, r3
- adds r0, r1, 0
- adds r0, 0x21
- ldrb r0, [r0]
- cmp r0, 0xA
- beq _08048B74
- adds r0, r1, 0
- adds r0, 0x22
- ldrb r0, [r0]
- cmp r0, 0xA
- bne _08048BA4
-_08048B74:
- ldr r0, =gHitMarker
- ldr r0, [r0]
- movs r1, 0x80
- lsls r1, 6
- ands r0, r1
- cmp r0, 0
- beq _08048BA4
- cmp r5, 0x1
- beq _08048B8A
- cmp r6, 0x80
- bne _08048BA4
-_08048B8A:
- ldr r4, =gBattlescriptCurrInstr
- ldr r0, [r4]
- adds r0, 0x1
- bl b_movescr_stack_push
- ldr r0, =BattleScript_BRNPrevention
- b _08048D72
- .pool
-_08048BA4:
- mov r4, r9
- ldrb r0, [r4]
- movs r1, 0x58
- adds r2, r0, 0
- muls r2, r1
- mov r0, r8
- adds r1, r2, r0
- adds r0, r1, 0
- adds r0, 0x21
- ldrb r0, [r0]
- cmp r0, 0xA
- bne _08048BBE
- b _08048DF4
-_08048BBE:
- adds r0, r1, 0
- adds r0, 0x22
- ldrb r0, [r0]
- cmp r0, 0xA
- bne _08048BCA
- b _08048DF4
-_08048BCA:
- adds r0, r1, 0
- adds r0, 0x20
- ldrb r0, [r0]
- cmp r0, 0x29
- bne _08048BD6
- b _08048DF4
-_08048BD6:
- mov r0, r8
- adds r0, 0x4C
- adds r0, r2, r0
- ldr r0, [r0]
- cmp r0, 0
- beq _08048BE4
- b _08048DF4
-_08048BE4:
- movs r1, 0x1
- mov r10, r1
- b _08048DF4
-_08048BEA:
- movs r0, 0
- str r0, [sp]
- movs r0, 0x13
- movs r1, 0
- movs r2, 0xD
- movs r3, 0
- bl AbilityBattleEffects
- lsls r0, 24
- lsrs r0, 24
- cmp r0, 0
- bne _08048C26
- str r0, [sp]
- movs r0, 0x13
- movs r1, 0
- movs r2, 0x4D
- movs r3, 0
- bl AbilityBattleEffects
- lsls r0, 24
- cmp r0, 0
- bne _08048C26
- ldr r0, =gBattleWeather
- ldrh r1, [r0]
- movs r0, 0x60
- ands r0, r1
- cmp r0, 0
- beq _08048C26
- movs r2, 0
- str r2, [sp, 0x4]
-_08048C26:
- ldr r4, =gBattleMons
- ldr r0, =gEffectBank
- ldrb r3, [r0]
- movs r0, 0x58
- adds r2, r3, 0
- muls r2, r0
- adds r1, r2, r4
- adds r0, r1, 0
- adds r0, 0x21
- ldrb r0, [r0]
- cmp r0, 0xF
- bne _08048C40
- b _08048DF4
-_08048C40:
- adds r0, r1, 0
- adds r0, 0x22
- ldrb r0, [r0]
- cmp r0, 0xF
- bne _08048C4C
- b _08048DF4
-_08048C4C:
- adds r0, r4, 0
- adds r0, 0x4C
- adds r0, r2, r0
- ldr r0, [r0]
- cmp r0, 0
- beq _08048C5A
- b _08048DF4
-_08048C5A:
- ldr r4, [sp, 0x4]
- cmp r4, 0
- bne _08048C62
- b _08048DF4
-_08048C62:
- adds r0, r1, 0
- adds r0, 0x20
- ldrb r0, [r0]
- cmp r0, 0x28
- bne _08048C6E
- b _08048DF4
-_08048C6E:
- adds r0, r3, 0
- bl CancelMultiTurnMoves
- b _08048DE4
- .pool
-_08048C84:
- mov r2, r9
- ldrb r1, [r2]
- movs r0, 0x58
- muls r1, r0
- mov r3, r8
- adds r0, r1, r3
- adds r0, 0x20
- ldrb r2, [r0]
- cmp r2, 0x7
- bne _08048CF4
- cmp r5, 0x1
- beq _08048CA2
- cmp r6, 0x80
- beq _08048CA2
- b _08048DF4
-_08048CA2:
- ldr r0, =gLastUsedAbility
- strb r2, [r0]
- mov r4, r9
- ldrb r0, [r4]
- movs r1, 0x7
- bl RecordAbilityBattle
- ldr r4, =gBattlescriptCurrInstr
- ldr r0, [r4]
- adds r0, 0x1
- bl b_movescr_stack_push
- ldr r0, =BattleScript_PRLZPrevention
- str r0, [r4]
- ldr r2, =gHitMarker
- ldr r1, [r2]
- movs r0, 0x80
- lsls r0, 6
- ands r0, r1
- cmp r0, 0
- beq _08048CE8
- movs r0, 0x1
- ldr r3, =gBattleCommunication
- strb r0, [r3, 0x5]
- b _08048A4C
- .pool
-_08048CE8:
- ldr r4, =gBattleCommunication
- strb r0, [r4, 0x5]
- bl _080499B2
- .pool
-_08048CF4:
- mov r0, r8
- adds r0, 0x4C
- adds r0, r1, r0
- ldr r0, [r0]
- cmp r0, 0
- bne _08048DF4
- b _08048DE4
-_08048D02:
- mov r2, r9
- ldrb r1, [r2]
- movs r0, 0x58
- muls r0, r1
- add r0, r8
- adds r0, 0x20
- ldrb r1, [r0]
- cmp r1, 0x11
- bne _08048D2C
- cmp r5, 0x1
- bne _08048D1A
- b _08048A1A
-_08048D1A:
- cmp r6, 0x80
- bne _08048D2C
- b _08048A1A
-_08048D20:
- ldr r1, =gBattleCommunication
- strb r0, [r1, 0x5]
- bl _080499B2
- .pool
-_08048D2C:
- mov r2, r9
- ldrb r0, [r2]
- movs r1, 0x58
- muls r0, r1
- add r0, r8
- adds r1, r0, 0
- adds r1, 0x21
- ldrb r1, [r1]
- cmp r1, 0x3
- beq _08048D50
- adds r0, 0x22
- ldrb r0, [r0]
- cmp r0, 0x3
- beq _08048D50
- cmp r1, 0x8
- beq _08048D50
- cmp r0, 0x8
- bne _08048D94
-_08048D50:
- ldr r0, =gHitMarker
- ldr r0, [r0]
- movs r1, 0x80
- lsls r1, 6
- ands r0, r1
- cmp r0, 0
- beq _08048D94
- cmp r5, 0x1
- beq _08048D66
- cmp r6, 0x80
- bne _08048D94
-_08048D66:
- ldr r4, =gBattlescriptCurrInstr
- ldr r0, [r4]
- adds r0, 0x1
- bl b_movescr_stack_push
- ldr r0, =BattleScript_PSNPrevention
-_08048D72:
- str r0, [r4]
- ldr r1, =gBattleCommunication
- movs r2, 0
- movs r0, 0x2
- strb r0, [r1, 0x5]
- strb r2, [r1, 0x3]
- bl _080499B8
- .pool
-_08048D94:
- mov r3, r9
- ldrb r0, [r3]
- movs r6, 0x58
- muls r0, r6
- mov r2, r8
- adds r2, 0x4C
- adds r5, r0, r2
- ldr r4, [r5]
- cmp r4, 0
- bne _08048DF4
- mov r3, r8
- adds r1, r0, r3
- adds r0, r1, 0
- adds r0, 0x21
- ldrb r3, [r0]
- cmp r3, 0x3
- beq _08048DEA
- adds r0, 0x1
- ldrb r0, [r0]
- cmp r0, 0x3
- beq _08048DEA
- cmp r3, 0x8
- beq _08048DEA
- cmp r0, 0x8
- beq _08048DEA
- adds r0, r1, 0
- adds r0, 0x20
- ldrb r0, [r0]
- cmp r0, 0x11
- beq _08048DF4
- mov r4, r9
- ldrb r0, [r4]
- adds r1, r0, 0
- muls r1, r6
- adds r1, r2
- ldr r0, [r1]
- movs r2, 0x9
- negs r2, r2
- ands r0, r2
- str r0, [r1]
-_08048DE4:
- movs r0, 0x1
- mov r10, r0
- b _08048DF4
-_08048DEA:
- ldr r0, =gBattleMoveFlags
- ldrb r1, [r0]
- movs r2, 0x8
- orrs r1, r2
- strb r1, [r0]
-_08048DF4:
- mov r1, r10
- cmp r1, 0x1
- beq _08048DFC
- b _08048F1C
-_08048DFC:
- ldr r0, =gBattlescriptCurrInstr
- ldr r0, [r0]
- adds r0, 0x1
- bl b_movescr_stack_push
- ldr r1, =gStatusFlagsForMoveEffects
- ldr r0, =gBattleCommunication
- ldrb r0, [r0, 0x3]
- lsls r0, 2
- adds r0, r1
- ldr r3, [r0]
- cmp r3, 0x7
- bne _08048E50
- bl Random
- ldr r2, =gBattleMons
- ldr r1, =gEffectBank
- ldrb r3, [r1]
- movs r1, 0x58
- muls r3, r1
- adds r2, 0x4C
- adds r3, r2
- movs r1, 0x3
- ands r1, r0
- adds r1, 0x2
- ldr r0, [r3]
- orrs r0, r1
- str r0, [r3]
- b _08048E64
- .pool
-_08048E50:
- ldr r2, =gBattleMons
- ldr r0, =gEffectBank
- ldrb r1, [r0]
- movs r0, 0x58
- muls r1, r0
- adds r2, 0x4C
- adds r1, r2
- ldr r0, [r1]
- orrs r0, r3
- str r0, [r1]
-_08048E64:
- ldr r2, =gBattlescriptCurrInstr
- ldr r1, =gMoveEffectBS_Ptrs
- ldr r5, =gBattleCommunication
- ldrb r0, [r5, 0x3]
- lsls r0, 2
- adds r0, r1
- ldr r0, [r0]
- str r0, [r2]
- ldr r4, =gActiveBank
- ldr r1, =gEffectBank
- ldrb r0, [r1]
- strb r0, [r4]
- ldrb r1, [r1]
- movs r0, 0x58
- muls r0, r1
- ldr r1, =gBattleMons + 0x4C
- adds r0, r1
- str r0, [sp]
- movs r0, 0
- movs r1, 0x28
- movs r2, 0
- movs r3, 0x4
- bl EmitSetAttributes
- ldrb r0, [r4]
- bl MarkBufferBankForExecution
- ldr r2, =gHitMarker
- ldr r1, [r2]
- movs r0, 0x80
- lsls r0, 6
- ands r0, r1
- cmp r0, 0
- beq _08048ED8
- movs r0, 0x1
- strb r0, [r5, 0x5]
- ldr r0, =0xffffdfff
- ands r1, r0
- str r1, [r2]
- b _08048EDA
- .pool
-_08048ED8:
- strb r0, [r5, 0x5]
-_08048EDA:
- ldr r0, =gBattleCommunication
- ldrb r2, [r0, 0x3]
- cmp r2, 0x2
- beq _08048EF2
- cmp r2, 0x6
- beq _08048EF2
- cmp r2, 0x5
- beq _08048EF2
- cmp r2, 0x3
- beq _08048EF2
- bl _080499B8
-_08048EF2:
- ldr r0, =gBattleStruct
- ldr r0, [r0]
- adds r0, 0xB2
- ldr r2, =gBattleCommunication
- ldrb r1, [r2, 0x3]
- strb r1, [r0]
- ldr r2, =gHitMarker
- ldr r0, [r2]
- movs r1, 0x80
- lsls r1, 7
- orrs r0, r1
- str r0, [r2]
- bl _080499B8
- .pool
-_08048F1C:
- mov r3, r10
- cmp r3, 0
- beq _08048F26
- bl _080499B8
-_08048F26:
- ldr r0, =gBattleCommunication
- strb r3, [r0, 0x3]
- ldr r1, =gBattlescriptCurrInstr
- ldr r0, [r1]
- adds r0, 0x1
- str r0, [r1]
- bl _080499B8
- .pool
-_08048F40:
- mov r4, r9
- ldrb r1, [r4]
- movs r0, 0x58
- muls r1, r0
- mov r0, r8
- adds r0, 0x50
- adds r1, r0
- ldr r2, =gStatusFlagsForMoveEffects
- ldr r0, =gBattleCommunication
- ldrb r3, [r0, 0x3]
- lsls r0, r3, 2
- adds r0, r2
- ldr r1, [r1]
- ldr r0, [r0]
- ands r1, r0
- cmp r1, 0
- beq _08048F66
- bl _08049994
-_08048F66:
- subs r0, r3, 0x7
- cmp r0, 0x34
- bls _08048F70
- bl _080499B2
-_08048F70:
- lsls r0, 2
- ldr r1, =_08048F88
- adds r0, r1
- ldr r0, [r0]
- mov pc, r0
- .pool
- .align 2, 0
-_08048F88:
- .4byte _0804905C
- .4byte _080490D0
- .4byte _08049244
- .4byte _0804915C
- .4byte _080491D8
- .4byte _0804927C
- .4byte _080492C4
- .4byte _08049390
- .4byte _080493D4
- .4byte _080493D4
- .4byte _080493D4
- .4byte _080493D4
- .4byte _080493D4
- .4byte _080493D4
- .4byte _080493D4
- .4byte _0804941C
- .4byte _0804941C
- .4byte _0804941C
- .4byte _0804941C
- .4byte _0804941C
- .4byte _0804941C
- .4byte _0804941C
- .4byte _080494FC
- .4byte _08049544
- .4byte _08049564
- .4byte _08049720
- .4byte _0804975C
- .4byte _08049778
- .4byte _08049790
- .4byte _080497A8
- .4byte _08049808
- .4byte _08049820
- .4byte _08049468
- .4byte _08049468
- .4byte _08049468
- .4byte _08049468
- .4byte _08049468
- .4byte _08049468
- .4byte _08049468
- .4byte _080494B0
- .4byte _080494B0
- .4byte _080494B0
- .4byte _080494B0
- .4byte _080494B0
- .4byte _080494B0
- .4byte _080494B0
- .4byte _08049864
- .4byte _080498C0
- .4byte _080499B2
- .4byte _080499B2
- .4byte _080499B2
- .4byte _080499B2
- .4byte _080499A4
-_0804905C:
- mov r1, r9
- ldrb r0, [r1]
- movs r5, 0x58
- adds r1, r0, 0
- muls r1, r5
- mov r2, r8
- adds r0, r1, r2
- adds r0, 0x20
- ldrb r0, [r0]
- cmp r0, 0x14
- bne _08049076
- bl _08049994
-_08049076:
- mov r4, r8
- adds r4, 0x50
- adds r0, r1, r4
- ldr r0, [r0]
- movs r1, 0x7
- ands r0, r1
- cmp r0, 0
- beq _0804908A
- bl _08049994
-_0804908A:
- bl Random
- mov r3, r9
- ldrb r1, [r3]
- adds r2, r1, 0
- muls r2, r5
- adds r2, r4
- lsls r0, 16
- movs r1, 0xC0
- lsls r1, 10
- ands r1, r0
- lsrs r1, 16
- adds r1, 0x2
- ldr r0, [r2]
- orrs r0, r1
- str r0, [r2]
- ldr r4, =gBattlescriptCurrInstr
- ldr r0, [r4]
- adds r0, 0x1
- bl b_movescr_stack_push
- ldr r1, =gMoveEffectBS_Ptrs
- ldr r0, =gBattleCommunication
- ldrb r0, [r0, 0x3]
- lsls r0, 2
- adds r0, r1
- ldr r0, [r0]
- bl _080499B0
- .pool
-_080490D0:
- mov r4, r9
- ldrb r2, [r4]
- movs r4, 0x58
- adds r0, r2, 0
- muls r0, r4
- add r0, r8
- adds r0, 0x20
- ldrb r1, [r0]
- cmp r1, 0x27
- bne _08049114
- cmp r5, 0x1
- beq _080490F0
- cmp r6, 0x80
- beq _080490F0
- bl _08049994
-_080490F0:
- ldr r0, =gLastUsedAbility
- strb r1, [r0]
- mov r1, r9
- ldrb r0, [r1]
- movs r1, 0x27
- bl RecordAbilityBattle
- ldr r1, =gBattlescriptCurrInstr
- ldr r0, =BattleScript_FlinchPrevention
- str r0, [r1]
- bl _080499B2
- .pool
-_08049114:
- adds r0, r2, 0
- bl BankGetTurnOrder
- ldr r1, =gCurrentMoveTurn
- lsls r0, 24
- lsrs r0, 24
- ldrb r1, [r1]
- cmp r0, r1
- bhi _0804912A
- bl _08049994
-_0804912A:
- mov r2, r9
- ldrb r0, [r2]
- adds r2, r0, 0
- muls r2, r4
- mov r0, r8
- adds r0, 0x50
- adds r2, r0
- ldr r1, =gStatusFlagsForMoveEffects
- ldr r0, =gBattleCommunication
- ldrb r0, [r0, 0x3]
- lsls r0, 2
- adds r0, r1
- ldr r1, [r2]
- ldr r0, [r0]
- orrs r1, r0
- str r1, [r2]
- bl _08049994
- .pool
-_0804915C:
- mov r3, r9
- ldrb r0, [r3]
- movs r5, 0x58
- muls r0, r5
- mov r4, r8
- adds r4, 0x50
- adds r2, r0, r4
- ldr r1, [r2]
- movs r0, 0x70
- ands r0, r1
- cmp r0, 0
- beq _08049178
- bl _08049994
-_08049178:
- movs r0, 0x80
- lsls r0, 5
- orrs r1, r0
- str r1, [r2]
- ldr r1, =gLockedMoves
- ldrb r0, [r3]
- lsls r0, 1
- adds r0, r1
- ldr r1, =gCurrentMove
- ldrh r1, [r1]
- strh r1, [r0]
- bl Random
- mov r2, r9
- ldrb r1, [r2]
- adds r2, r1, 0
- muls r2, r5
- adds r2, r4
- movs r1, 0x3
- ands r1, r0
- adds r1, 0x2
- lsls r1, 4
- ldr r0, [r2]
- orrs r0, r1
- str r0, [r2]
- ldr r4, =gBattlescriptCurrInstr
- ldr r0, [r4]
- adds r0, 0x1
- bl b_movescr_stack_push
- ldr r1, =gMoveEffectBS_Ptrs
- ldr r0, =gBattleCommunication
- ldrb r0, [r0, 0x3]
- lsls r0, 2
- adds r0, r1
- ldr r0, [r0]
- bl _080499B0
- .pool
-_080491D8:
- ldr r5, =gBankAttacker
- ldrb r0, [r5]
- bl GetBankIdentity
- movs r1, 0x1
- ands r1, r0
- cmp r1, 0
- bne _08049210
- ldr r4, =gPaydayMoney
- ldrh r3, [r4]
- ldr r2, =gBattleMons
- ldrb r1, [r5]
- movs r0, 0x58
- muls r0, r1
- adds r0, r2
- adds r0, 0x2A
- ldrb r1, [r0]
- lsls r0, r1, 2
- adds r0, r1
- adds r0, r3, r0
- strh r0, [r4]
- lsls r0, 16
- lsrs r0, 16
- cmp r3, r0
- bls _08049210
- ldr r3, =0x0000ffff
- adds r0, r3, 0
- strh r0, [r4]
-_08049210:
- ldr r4, =gBattlescriptCurrInstr
- ldr r0, [r4]
- adds r0, 0x1
- bl b_movescr_stack_push
- ldr r1, =gMoveEffectBS_Ptrs
- ldr r0, =gBattleCommunication
- ldrb r0, [r0, 0x3]
- lsls r0, 2
- adds r0, r1
- ldr r0, [r0]
- b _080499B0
- .pool
-_08049244:
- mov r4, r9
- ldrb r1, [r4]
- movs r0, 0x58
- muls r0, r1
- mov r1, r8
- adds r1, 0x4C
- adds r0, r1
- ldr r0, [r0]
- cmp r0, 0
- beq _0804925A
- b _08049994
-_0804925A:
- bl Random
- ldr r4, =gBattleCommunication
- lsls r0, 16
- lsrs r0, 16
- movs r1, 0x3
- bl __umodsi3
- adds r0, 0x3
- strb r0, [r4, 0x3]
- movs r0, 0
- movs r1, 0
- bl SetMoveEffect
- b _080499B2
- .pool
-_0804927C:
- mov r0, r9
- ldrb r1, [r0]
- movs r0, 0x58
- adds r2, r1, 0
- muls r2, r0
- mov r0, r8
- adds r0, 0x50
- adds r2, r0
- ldr r0, [r2]
- movs r1, 0x80
- lsls r1, 5
- orrs r0, r1
- str r0, [r2]
- ldr r1, =gLockedMoves
- mov r2, r9
- ldrb r0, [r2]
- lsls r0, 1
- adds r0, r1
- ldr r1, =gCurrentMove
- ldrh r1, [r1]
- strh r1, [r0]
- ldr r0, =gProtectStructs
- ldrb r1, [r2]
- lsls r1, 4
- adds r1, r0
- ldrb r0, [r1, 0x1]
- movs r2, 0x4
- orrs r0, r2
- strb r0, [r1, 0x1]
- b _08049994
- .pool
-_080492C4:
- mov r3, r9
- ldrb r0, [r3]
- movs r6, 0x58
- muls r0, r6
- mov r4, r8
- adds r4, 0x50
- adds r0, r4
- ldr r5, [r0]
- movs r0, 0xE0
- lsls r0, 8
- ands r5, r0
- cmp r5, 0
- beq _080492E0
- b _08049994
-_080492E0:
- bl Random
- mov r2, r9
- ldrb r1, [r2]
- adds r2, r1, 0
- muls r2, r6
- adds r2, r4
- movs r1, 0x3
- ands r1, r0
- adds r1, 0x3
- lsls r1, 13
- ldr r0, [r2]
- orrs r0, r1
- str r0, [r2]
- mov r3, r9
- ldrb r1, [r3]
- ldr r2, =gBattleStruct
- ldr r0, [r2]
- lsls r1, 1
- adds r1, r0
- ldr r6, =gCurrentMove
- ldrh r0, [r6]
- strb r0, [r1, 0x4]
- ldrb r1, [r3]
- ldr r0, [r2]
- lsls r1, 1
- adds r1, r0
- ldrh r0, [r6]
- lsrs r0, 8
- strb r0, [r1, 0x5]
- ldrb r1, [r3]
- ldr r0, [r2]
- adds r1, r0
- ldr r0, =gBankAttacker
- ldrb r0, [r0]
- strb r0, [r1, 0x14]
- ldr r4, =gBattlescriptCurrInstr
- ldr r0, [r4]
- adds r0, 0x1
- bl b_movescr_stack_push
- ldr r1, =gMoveEffectBS_Ptrs
- ldr r2, =gBattleCommunication
- ldrb r0, [r2, 0x3]
- lsls r0, 2
- adds r0, r1
- ldr r0, [r0]
- str r0, [r4]
- strb r5, [r2, 0x5]
- ldr r3, =gTrappingMoves
- ldrh r0, [r3]
- ldrh r4, [r6]
- cmp r0, r4
- bne _0804934E
- b _080499B2
-_0804934E:
- adds r1, r2, 0
- adds r2, r6, 0
-_08049352:
- ldrb r0, [r1, 0x5]
- adds r0, 0x1
- strb r0, [r1, 0x5]
- lsls r0, 24
- lsrs r0, 24
- cmp r0, 0x4
- bls _08049362
- b _080499B2
-_08049362:
- ldrb r0, [r1, 0x5]
- lsls r0, 1
- adds r0, r3
- ldrh r0, [r0]
- ldrh r4, [r2]
- cmp r0, r4
- bne _08049352
- b _080499B2
- .pool
-_08049390:
- ldr r1, =gBattleMoveDamage
- ldr r0, =gHpDealt
- ldr r0, [r0]
- cmp r0, 0
- bge _0804939C
- adds r0, 0x3
-_0804939C:
- asrs r0, 2
- str r0, [r1]
- cmp r0, 0
- bne _080493A8
- movs r0, 0x1
- str r0, [r1]
-_080493A8:
- ldr r4, =gBattlescriptCurrInstr
- ldr r0, [r4]
- adds r0, 0x1
- bl b_movescr_stack_push
- ldr r1, =gMoveEffectBS_Ptrs
- ldr r0, =gBattleCommunication
- ldrb r0, [r0, 0x3]
- lsls r0, 2
- adds r0, r1
- ldr r0, [r0]
- b _080499B0
- .pool
-_080493D4:
- ldr r4, =gBattleCommunication
- ldrb r1, [r4, 0x3]
- adds r1, 0xF2
- lsls r1, 24
- lsrs r1, 24
- movs r0, 0x10
- adds r2, r7, 0
- movs r3, 0
- bl ChangeStatBuffs
- lsls r0, 24
- lsrs r3, r0, 24
- cmp r3, 0
- beq _080493F2
- b _08049994
-_080493F2:
- ldr r2, =gBattleScripting
- ldrb r1, [r4, 0x3]
- movs r0, 0x3F
- ands r0, r1
- strb r0, [r2, 0x10]
- strb r3, [r2, 0x11]
- ldr r4, =gBattlescriptCurrInstr
- ldr r0, [r4]
- adds r0, 0x1
- bl b_movescr_stack_push
- ldr r0, =BattleScript_StatUp
- b _080499B0
- .pool
-_0804941C:
- movs r0, 0x70
- negs r0, r0
- ldr r4, =gBattleCommunication
- ldrb r1, [r4, 0x3]
- adds r1, 0xEB
- lsls r1, 24
- lsrs r1, 24
- adds r2, r7, 0
- movs r3, 0
- bl ChangeStatBuffs
- lsls r0, 24
- lsrs r3, r0, 24
- cmp r3, 0
- beq _0804943C
- b _08049994
-_0804943C:
- ldr r2, =gBattleScripting
- ldrb r1, [r4, 0x3]
- movs r0, 0x3F
- ands r0, r1
- strb r0, [r2, 0x10]
- strb r3, [r2, 0x11]
- ldr r4, =gBattlescriptCurrInstr
- ldr r0, [r4]
- adds r0, 0x1
- bl b_movescr_stack_push
- ldr r0, =BattleScript_StatDown
- b _080499B0
- .pool
-_08049468:
- ldr r4, =gBattleCommunication
- ldrb r1, [r4, 0x3]
- adds r1, 0xDA
- lsls r1, 24
- lsrs r1, 24
- movs r0, 0x20
- adds r2, r7, 0
- movs r3, 0
- bl ChangeStatBuffs
- lsls r0, 24
- lsrs r3, r0, 24
- cmp r3, 0
- beq _08049486
- b _08049994
-_08049486:
- ldr r2, =gBattleScripting
- ldrb r1, [r4, 0x3]
- movs r0, 0x3F
- ands r0, r1
- strb r0, [r2, 0x10]
- strb r3, [r2, 0x11]
- ldr r4, =gBattlescriptCurrInstr
- ldr r0, [r4]
- adds r0, 0x1
- bl b_movescr_stack_push
- ldr r0, =BattleScript_StatUp
- b _080499B0
- .pool
-_080494B0:
- movs r0, 0x60
- negs r0, r0
- ldr r4, =gBattleCommunication
- ldrb r1, [r4, 0x3]
- adds r1, 0xD3
- lsls r1, 24
- lsrs r1, 24
- adds r2, r7, 0
- movs r3, 0
- bl ChangeStatBuffs
- lsls r0, 24
- lsrs r3, r0, 24
- cmp r3, 0
- beq _080494D0
- b _08049994
-_080494D0:
- ldr r2, =gBattleScripting
- ldrb r1, [r4, 0x3]
- movs r0, 0x3F
- ands r0, r1
- strb r0, [r2, 0x10]
- strb r3, [r2, 0x11]
- ldr r4, =gBattlescriptCurrInstr
- ldr r0, [r4]
- adds r0, 0x1
- bl b_movescr_stack_push
- ldr r0, =BattleScript_StatDown
- b _080499B0
- .pool
-_080494FC:
- mov r0, r9
- ldrb r1, [r0]
- movs r0, 0x58
- adds r2, r1, 0
- muls r2, r0
- mov r0, r8
- adds r0, 0x50
- adds r2, r0
- ldr r0, [r2]
- movs r1, 0x80
- lsls r1, 15
- orrs r0, r1
- str r0, [r2]
- ldr r2, =gDisableStructs
- mov r3, r9
- ldrb r1, [r3]
- lsls r0, r1, 3
- subs r0, r1
- lsls r0, 2
- adds r0, r2
- movs r1, 0x2
- strb r1, [r0, 0x19]
- ldr r1, =gLockedMoves
- ldrb r0, [r3]
- lsls r0, 1
- adds r0, r1
- ldr r1, =gCurrentMove
- ldrh r1, [r1]
- strh r1, [r0]
- b _08049994
- .pool
-_08049544:
- ldr r0, =gBankAttacker
- ldrb r1, [r0]
- movs r0, 0x58
- adds r2, r1, 0
- muls r2, r0
- mov r0, r8
- adds r0, 0x50
- adds r2, r0
- ldr r0, [r2]
- movs r1, 0x80
- lsls r1, 16
-_0804955A:
- orrs r0, r1
- str r0, [r2]
- b _08049994
- .pool
-_08049564:
- ldr r5, =gBattleTypeFlags
- ldr r0, [r5]
- movs r1, 0x80
- lsls r1, 19
- ands r0, r1
- cmp r0, 0
- beq _08049574
- b _08049994
-_08049574:
- ldr r6, =gBankAttacker
- ldrb r0, [r6]
- bl GetBankSide
- lsls r0, 24
- lsrs r4, r0, 24
- ldrb r0, [r6]
- bl GetBankSide
- lsls r0, 24
- lsrs r0, 24
- cmp r0, 0x1
- bne _080495A8
- ldr r0, [r5]
- ldr r1, =0x0a3f0902
- ands r0, r1
- cmp r0, 0
- bne _080495D4
- b _08049994
- .pool
-_080495A8:
- ldr r0, [r5]
- ldr r1, =0x0a3f0902
- ands r0, r1
- cmp r0, 0
- bne _080495D4
- ldr r0, =gWishFutureKnock
- adds r0, 0x29
- adds r0, r4, r0
- ldrb r1, [r0]
- ldr r3, =gBitTable
- ldr r2, =gBattlePartyID
- ldrb r0, [r6]
- lsls r0, 1
- adds r0, r2
- ldrh r0, [r0]
- lsls r0, 2
- adds r0, r3
- ldr r0, [r0]
- ands r1, r0
- cmp r1, 0
- beq _080495D4
- b _08049994
-_080495D4:
- ldr r2, =gBattleMons
- ldr r1, =gBankTarget
- ldrb r0, [r1]
- movs r5, 0x58
- muls r0, r5
- adds r4, r0, r2
- ldrh r0, [r4, 0x2E]
- adds r7, r1, 0
- mov r8, r2
- cmp r0, 0
- beq _0804963C
- adds r0, r4, 0
- adds r0, 0x20
- ldrb r0, [r0]
- cmp r0, 0x3C
- bne _0804963C
- bl b_movescr_stack_push_cursor
- ldr r1, =gBattlescriptCurrInstr
- ldr r0, =BattleScript_NoItemSteal
- str r0, [r1]
- ldr r1, =gLastUsedAbility
- ldrb r0, [r7]
- muls r0, r5
- add r0, r8
- adds r0, 0x20
- ldrb r0, [r0]
- strb r0, [r1]
- ldrb r0, [r7]
- ldrb r1, [r1]
- bl RecordAbilityBattle
- b _080499B2
- .pool
-_0804963C:
- ldr r4, =gBankAttacker
- mov r10, r4
- ldrb r2, [r4]
- movs r0, 0x58
- mov r9, r0
- mov r0, r9
- muls r0, r2
- add r0, r8
- ldrh r4, [r0, 0x2E]
- cmp r4, 0
- beq _08049654
- b _08049994
-_08049654:
- ldrb r0, [r7]
- mov r1, r9
- muls r1, r0
- adds r0, r1, 0
- add r0, r8
- ldrh r3, [r0, 0x2E]
- adds r1, r3, 0
- cmp r1, 0xAF
- bne _08049668
- b _08049994
-_08049668:
- adds r0, r3, 0
- subs r0, 0x79
- lsls r0, 16
- lsrs r0, 16
- cmp r0, 0xB
- bhi _08049676
- b _08049994
-_08049676:
- cmp r1, 0
- bne _0804967C
- b _08049994
-_0804967C:
- ldr r5, =gBattleStruct
- lsls r0, r2, 1
- adds r0, 0xD0
- ldr r1, [r5]
- adds r1, r0
- ldr r2, =gLastUsedItem
- strh r3, [r1]
- strh r3, [r2]
- ldrb r0, [r7]
- mov r3, r9
- muls r3, r0
- adds r0, r3, 0
- add r0, r8
- movs r6, 0
- strh r4, [r0, 0x2E]
- ldr r4, =gActiveBank
- mov r1, r10
- ldrb r0, [r1]
- strb r0, [r4]
- str r2, [sp]
- movs r0, 0
- movs r1, 0x2
- movs r2, 0
- movs r3, 0x2
- bl EmitSetAttributes
- mov r2, r10
- ldrb r0, [r2]
- bl MarkBufferBankForExecution
- ldrb r0, [r7]
- strb r0, [r4]
- ldrb r0, [r7]
- mov r3, r9
- muls r3, r0
- adds r0, r3, 0
- mov r1, r8
- adds r1, 0x2E
- adds r0, r1
- str r0, [sp]
- movs r0, 0
- movs r1, 0x2
- movs r2, 0
- movs r3, 0x2
- bl EmitSetAttributes
- ldrb r0, [r7]
- bl MarkBufferBankForExecution
- ldr r4, =gBattlescriptCurrInstr
- ldr r0, [r4]
- adds r0, 0x1
- bl b_movescr_stack_push
- ldr r0, =BattleScript_ItemSteal
- str r0, [r4]
- ldrb r0, [r7]
- ldr r1, [r5]
- lsls r0, 1
- adds r0, r1
- adds r0, 0xC8
- strb r6, [r0]
- ldrb r0, [r7]
- ldr r1, [r5]
- lsls r0, 1
- adds r0, r1
- adds r0, 0xC9
- strb r6, [r0]
- b _080499B2
- .pool
-_08049720:
- ldr r3, =gBankTarget
- ldrb r1, [r3]
- movs r0, 0x58
- adds r2, r1, 0
- muls r2, r0
- mov r0, r8
- adds r0, 0x50
- adds r2, r0
- ldr r0, [r2]
- movs r1, 0x80
- lsls r1, 19
- orrs r0, r1
- str r0, [r2]
- ldr r2, =gDisableStructs
- ldrb r1, [r3]
- lsls r0, r1, 3
- subs r0, r1
- lsls r0, 2
- adds r0, r2
- ldr r1, =gBankAttacker
- ldrb r1, [r1]
- strb r1, [r0, 0x14]
- b _08049994
- .pool
-_0804975C:
- ldr r0, =gBankTarget
- ldrb r1, [r0]
- movs r0, 0x58
- adds r2, r1, 0
- muls r2, r0
- mov r0, r8
- adds r0, 0x50
- adds r2, r0
- ldr r0, [r2]
- movs r1, 0x80
- lsls r1, 20
- b _0804955A
- .pool
-_08049778:
- ldr r4, =gBattlescriptCurrInstr
- ldr r0, [r4]
- adds r0, 0x1
- bl b_movescr_stack_push
- ldr r0, =BattleScript_AllStatsUp
- b _080499B0
- .pool
-_08049790:
- ldr r4, =gBattlescriptCurrInstr
- ldr r0, [r4]
- adds r0, 0x1
- bl b_movescr_stack_push
- ldr r0, =BattleScript_RapidSpinAway
- b _080499B0
- .pool
-_080497A8:
- ldr r6, =gBankTarget
- ldrb r0, [r6]
- movs r2, 0x58
- muls r0, r2
- mov r1, r8
- adds r1, 0x4C
- adds r5, r0, r1
- ldr r4, [r5]
- movs r0, 0x40
- ands r0, r4
- cmp r0, 0
- bne _080497C2
- b _08049994
-_080497C2:
- movs r0, 0x41
- negs r0, r0
- ands r4, r0
- str r4, [r5]
- ldr r4, =gActiveBank
- ldrb r0, [r6]
- strb r0, [r4]
- ldrb r0, [r4]
- muls r0, r2
- adds r0, r1
- str r0, [sp]
- movs r0, 0
- movs r1, 0x28
- movs r2, 0
- movs r3, 0x4
- bl EmitSetAttributes
- ldrb r0, [r4]
- bl MarkBufferBankForExecution
- ldr r4, =gBattlescriptCurrInstr
- ldr r0, [r4]
- adds r0, 0x1
- bl b_movescr_stack_push
- ldr r0, =BattleScript_TargetPRLZHeal
- b _080499B0
- .pool
-_08049808:
- ldr r4, =gBattlescriptCurrInstr
- ldr r0, [r4]
- adds r0, 0x1
- bl b_movescr_stack_push
- ldr r0, =BattleScript_AtkDefDown
- b _080499B0
- .pool
-_08049820:
- ldr r4, =gBattleMoveDamage
- ldr r0, =gHpDealt
- ldr r0, [r0]
- movs r1, 0x3
- bl __divsi3
- str r0, [r4]
- cmp r0, 0
- bne _08049836
- movs r0, 0x1
- str r0, [r4]
-_08049836:
- ldr r4, =gBattlescriptCurrInstr
- ldr r0, [r4]
- adds r0, 0x1
- bl b_movescr_stack_push
- ldr r1, =gMoveEffectBS_Ptrs
- ldr r0, =gBattleCommunication
- ldrb r0, [r0, 0x3]
- lsls r0, 2
- adds r0, r1
- ldr r0, [r0]
- b _080499B0
- .pool
-_08049864:
- mov r4, r9
- ldrb r0, [r4]
- movs r5, 0x58
- muls r0, r5
- mov r4, r8
- adds r4, 0x50
- adds r2, r0, r4
- ldr r1, [r2]
- movs r0, 0xC0
- lsls r0, 4
- ands r0, r1
- cmp r0, 0
- beq _08049880
- b _08049994
-_08049880:
- movs r0, 0x80
- lsls r0, 5
- orrs r1, r0
- str r1, [r2]
- ldr r1, =gLockedMoves
- mov r2, r9
- ldrb r0, [r2]
- lsls r0, 1
- adds r0, r1
- ldr r1, =gCurrentMove
- ldrh r1, [r1]
- strh r1, [r0]
- bl Random
- mov r3, r9
- ldrb r1, [r3]
- adds r2, r1, 0
- muls r2, r5
- adds r2, r4
- movs r1, 0x1
- ands r1, r0
- adds r1, 0x2
- lsls r1, 10
- ldr r0, [r2]
- orrs r0, r1
- str r0, [r2]
- b _080499B2
- .pool
-_080498C0:
- mov r4, r9
- ldrb r3, [r4]
- movs r5, 0x58
- adds r0, r3, 0
- muls r0, r5
- mov r2, r8
- adds r1, r0, r2
- adds r0, r1, 0
- adds r0, 0x20
- ldrb r2, [r0]
- cmp r2, 0x3C
- bne _08049900
- ldrh r0, [r1, 0x2E]
- cmp r0, 0
- beq _08049994
- ldr r0, =gLastUsedAbility
- strb r2, [r0]
- ldr r1, =gBattlescriptCurrInstr
- ldr r0, =gUnknown_082DB63F
- str r0, [r1]
- ldrb r0, [r4]
- movs r1, 0x3C
- bl RecordAbilityBattle
- b _080499B2
- .pool
-_08049900:
- ldrh r0, [r1, 0x2E]
- cmp r0, 0
- beq _08049994
- adds r0, r3, 0
- bl GetBankSide
- lsls r0, 24
- lsrs r4, r0, 24
- ldr r1, =gLastUsedItem
- mov r3, r9
- ldrb r0, [r3]
- muls r0, r5
- add r0, r8
- ldrh r0, [r0, 0x2E]
- strh r0, [r1]
- ldrb r0, [r3]
- muls r0, r5
- add r0, r8
- movs r5, 0
- movs r1, 0
- strh r1, [r0, 0x2E]
- ldr r2, =gWishFutureKnock
- adds r2, 0x29
- adds r2, r4, r2
- ldr r3, =gBitTable
- ldr r1, =gBattlePartyID
- mov r4, r9
- ldrb r0, [r4]
- lsls r0, 1
- adds r0, r1
- ldrh r0, [r0]
- lsls r0, 2
- adds r0, r3
- ldr r0, [r0]
- ldrb r1, [r2]
- orrs r0, r1
- strb r0, [r2]
- ldr r4, =gBattlescriptCurrInstr
- ldr r0, [r4]
- adds r0, 0x1
- bl b_movescr_stack_push
- ldr r0, =BattleScript_KnockedOff
- str r0, [r4]
- mov r1, r9
- ldrb r0, [r1]
- ldr r2, =gBattleStruct
- ldr r1, [r2]
- lsls r0, 1
- adds r0, r1
- adds r0, 0xC8
- strb r5, [r0]
- mov r3, r9
- ldrb r0, [r3]
- ldr r1, [r2]
- lsls r0, 1
- adds r0, r1
- adds r0, 0xC9
- strb r5, [r0]
- b _080499B2
- .pool
-_08049994:
- ldr r1, =gBattlescriptCurrInstr
- ldr r0, [r1]
- adds r0, 0x1
- str r0, [r1]
- b _080499B2
- .pool
-_080499A4:
- ldr r4, =gBattlescriptCurrInstr
- ldr r0, [r4]
- adds r0, 0x1
- bl b_movescr_stack_push
- ldr r0, =BattleScript_SAtkDown2
-_080499B0:
- str r0, [r4]
-_080499B2:
- ldr r1, =gBattleCommunication
- movs r0, 0
- strb r0, [r1, 0x3]
-_080499B8:
- add sp, 0x8
- pop {r3-r5}
- mov r8, r3
- mov r9, r4
- mov r10, r5
- pop {r4-r7}
- pop {r0}
- bx r0
- .pool
- thumb_func_end SetMoveEffect
-
- thumb_func_start atk15_seteffectwithchancetarget
-atk15_seteffectwithchancetarget: @ 80499D4
- push {r4,lr}
- ldr r2, =gBattleMons
- ldr r0, =gBankAttacker
- ldrb r1, [r0]
- movs r0, 0x58
- muls r0, r1
- adds r0, r2
- adds r0, 0x20
- ldrb r0, [r0]
- cmp r0, 0x20
- bne _08049A10
- ldr r2, =gBattleMoves
- ldr r0, =gCurrentMove
- ldrh r1, [r0]
- lsls r0, r1, 1
- adds r0, r1
- lsls r0, 2
- adds r0, r2
- ldrb r0, [r0, 0x5]
- lsls r4, r0, 1
- b _08049A20
- .pool
-_08049A10:
- ldr r2, =gBattleMoves
- ldr r0, =gCurrentMove
- ldrh r1, [r0]
- lsls r0, r1, 1
- adds r0, r1
- lsls r0, 2
- adds r0, r2
- ldrb r4, [r0, 0x5]
-_08049A20:
- ldr r3, =gBattleCommunication
- ldrb r2, [r3, 0x3]
- movs r0, 0x80
- ands r0, r2
- cmp r0, 0
- beq _08049A50
- ldr r0, =gBattleMoveFlags
- ldrb r1, [r0]
- movs r0, 0x29
- ands r0, r1
- cmp r0, 0
- bne _08049A50
- movs r0, 0x7F
- ands r0, r2
- strb r0, [r3, 0x3]
- b _08049A7E
- .pool
-_08049A50:
- bl Random
- lsls r0, 16
- lsrs r0, 16
- movs r1, 0x64
- bl __umodsi3
- lsls r0, 16
- lsrs r0, 16
- cmp r0, r4
- bcs _08049A9A
- ldr r0, =gBattleCommunication
- ldrb r0, [r0, 0x3]
- cmp r0, 0
- beq _08049A9A
- ldr r0, =gBattleMoveFlags
- ldrb r1, [r0]
- movs r0, 0x29
- ands r0, r1
- cmp r0, 0
- bne _08049A9A
- cmp r4, 0x63
- bls _08049A90
-_08049A7E:
- movs r0, 0
- movs r1, 0x80
- bl SetMoveEffect
- b _08049AA2
- .pool
-_08049A90:
- movs r0, 0
- movs r1, 0
- bl SetMoveEffect
- b _08049AA2
-_08049A9A:
- ldr r1, =gBattlescriptCurrInstr
- ldr r0, [r1]
- adds r0, 0x1
- str r0, [r1]
-_08049AA2:
- ldr r0, =gBattleCommunication
- movs r1, 0
- strb r1, [r0, 0x3]
- ldr r0, =gBattleScripting
- strb r1, [r0, 0x16]
- pop {r4}
- pop {r0}
- bx r0
- .pool
- thumb_func_end atk15_seteffectwithchancetarget
-
- thumb_func_start atk16_seteffectprimary
-atk16_seteffectprimary: @ 8049AC0
- push {lr}
- movs r0, 0x1
- movs r1, 0
- bl SetMoveEffect
- pop {r0}
- bx r0
- thumb_func_end atk16_seteffectprimary
-
- thumb_func_start atk17_seteffectsecondary
-atk17_seteffectsecondary: @ 8049AD0
- push {lr}
- movs r0, 0
- movs r1, 0
- bl SetMoveEffect
- pop {r0}
- bx r0
- thumb_func_end atk17_seteffectsecondary
-
- thumb_func_start atk18_status_effect_clear
-atk18_status_effect_clear: @ 8049AE0
- push {lr}
- ldr r0, =gBattlescriptCurrInstr
- ldr r0, [r0]
- ldrb r0, [r0, 0x1]
- bl GetBattleBank
- ldr r2, =gActiveBank
- strb r0, [r2]
- ldr r3, =gBattleCommunication
- ldrb r0, [r3, 0x3]
- cmp r0, 0x6
- bhi _08049B14
- ldr r1, =gBattleMons
- ldrb r2, [r2]
- movs r0, 0x58
- muls r2, r0
- adds r1, 0x4C
- b _08049B1E
- .pool
-_08049B14:
- ldr r1, =gBattleMons
- ldrb r2, [r2]
- movs r0, 0x58
- muls r2, r0
- adds r1, 0x50
-_08049B1E:
- adds r2, r1
- ldr r1, =gStatusFlagsForMoveEffects
- ldrb r0, [r3, 0x3]
- lsls r0, 2
- adds r0, r1
- ldr r1, [r0]
- ldr r0, [r2]
- bics r0, r1
- str r0, [r2]
- ldr r0, =gBattleCommunication
- movs r2, 0
- strb r2, [r0, 0x3]
- ldr r1, =gBattlescriptCurrInstr
- ldr r0, [r1]
- adds r0, 0x2
- str r0, [r1]
- ldr r0, =gBattleScripting
- strb r2, [r0, 0x16]
- pop {r0}
- bx r0
- .pool
- thumb_func_end atk18_status_effect_clear
-
- thumb_func_start atk19_faint_pokemon
-atk19_faint_pokemon: @ 8049B5C
- push {r4-r7,lr}
- mov r7, r9
- mov r6, r8
- push {r6,r7}
- sub sp, 0x4
- ldr r0, =gBattlescriptCurrInstr
- ldr r2, [r0]
- ldrb r1, [r2, 0x2]
- adds r6, r0, 0
- cmp r1, 0
- beq _08049BE0
- ldrb r0, [r2, 0x1]
- bl GetBattleBank
- ldr r5, =gActiveBank
- strb r0, [r5]
- ldr r2, =gHitMarker
- ldr r1, =gBitTable
- ldrb r0, [r5]
- lsls r0, 2
- adds r0, r1
- ldr r1, [r0]
- lsls r1, 28
- ldr r0, [r2]
- ands r0, r1
- cmp r0, 0
- bne _08049B94
- b _08049E2C
-_08049B94:
- ldr r1, [r6]
- ldrb r4, [r1, 0x3]
- ldrb r0, [r1, 0x4]
- lsls r0, 8
- orrs r4, r0
- ldrb r0, [r1, 0x5]
- lsls r0, 16
- orrs r4, r0
- ldrb r0, [r1, 0x6]
- lsls r0, 24
- orrs r4, r0
- bl b_movescr_stack_pop_cursor
- str r4, [r6]
- ldrb r0, [r5]
- bl GetBankSide
- ldr r1, =gSideAffecting
- lsls r0, 24
- lsrs r0, 23
- adds r0, r1
- ldrh r2, [r0]
- ldr r1, =0x0000fdff
- ands r1, r2
- strh r1, [r0]
- b _08049E32
- .pool
-_08049BE0:
- ldrb r0, [r2, 0x1]
- cmp r0, 0x1
- bne _08049C08
- ldr r1, =gActiveBank
- ldr r0, =gBankAttacker
- ldrb r0, [r0]
- strb r0, [r1]
- ldr r0, =gBankTarget
- ldrb r0, [r0]
- mov r9, r0
- ldr r4, =gUnknown_082DA7AA
- b _08049C18
- .pool
-_08049C08:
- ldr r1, =gActiveBank
- ldr r0, =gBankTarget
- ldrb r0, [r0]
- strb r0, [r1]
- ldr r0, =gBankAttacker
- ldrb r0, [r0]
- mov r9, r0
- ldr r4, =gUnknown_082DA7B7
-_08049C18:
- mov r8, r1
- ldr r0, =gAbsentBankFlags
- ldrb r1, [r0]
- ldr r2, =gBitTable
- mov r7, r8
- ldrb r3, [r7]
- lsls r0, r3, 2
- adds r0, r2
- ldr r2, [r0]
- ands r1, r2
- cmp r1, 0
- beq _08049C32
- b _08049E2C
-_08049C32:
- ldr r1, =gBattleMons
- movs r0, 0x58
- muls r0, r3
- adds r0, r1
- ldrh r0, [r0, 0x28]
- cmp r0, 0
- beq _08049C42
- b _08049E2C
-_08049C42:
- ldr r5, =gHitMarker
- lsls r1, r2, 28
- ldr r0, [r5]
- orrs r0, r1
- str r0, [r5]
- ldr r0, [r6]
- adds r0, 0x7
- bl b_movescr_stack_push
- str r4, [r6]
- ldrb r0, [r7]
- bl GetBankSide
- lsls r0, 24
- cmp r0, 0
- bne _08049CA4
- ldr r0, [r5]
- movs r1, 0x80
- lsls r1, 15
- orrs r0, r1
- str r0, [r5]
- ldr r1, =gBattleResults
- ldrb r0, [r1]
- cmp r0, 0xFE
- bhi _08049C78
- adds r0, 0x1
- strb r0, [r1]
-_08049C78:
- ldrb r0, [r7]
- bl sub_80570F4
- b _08049CCE
- .pool
-_08049CA4:
- ldr r4, =gBattleResults
- ldrb r0, [r4, 0x1]
- cmp r0, 0xFE
- bhi _08049CB0
- adds r0, 0x1
- strb r0, [r4, 0x1]
-_08049CB0:
- ldr r1, =gBattlePartyID
- mov r2, r8
- ldrb r0, [r2]
- lsls r0, 1
- adds r0, r1
- ldrh r1, [r0]
- movs r0, 0x64
- muls r0, r1
- ldr r1, =gEnemyParty
- adds r0, r1
- movs r1, 0xB
- movs r2, 0
- bl GetMonData
- strh r0, [r4, 0x20]
-_08049CCE:
- ldr r2, =gHitMarker
- ldr r1, [r2]
- movs r0, 0x40
- ands r0, r1
- cmp r0, 0
- beq _08049D0C
- ldr r6, =gBattleMons
- ldr r0, =gBankAttacker
- ldrb r0, [r0]
- movs r5, 0x58
- muls r0, r5
- adds r0, r6
- ldrh r0, [r0, 0x28]
- cmp r0, 0
- beq _08049D0C
- movs r0, 0x41
- negs r0, r0
- ands r1, r0
- str r1, [r2]
- ldr r4, =gBattlescriptCurrInstr
- ldr r0, [r4]
- bl b_movescr_stack_push
- ldr r1, =gBattleMoveDamage
- mov r0, r9
- muls r0, r5
- adds r0, r6
- ldrh r0, [r0, 0x28]
- str r0, [r1]
- ldr r0, =gUnknown_082DAE3E
- str r0, [r4]
-_08049D0C:
- ldr r1, =gStatuses3
- ldr r6, =gBankTarget
- ldrb r0, [r6]
- lsls r0, 2
- adds r0, r1
- ldr r0, [r0]
- movs r1, 0x80
- lsls r1, 7
- ands r0, r1
- cmp r0, 0
- bne _08049D24
- b _08049E32
-_08049D24:
- ldr r0, =gHitMarker
- ldr r5, [r0]
- movs r0, 0x80
- lsls r0, 17
- ands r5, r0
- cmp r5, 0
- beq _08049D34
- b _08049E32
-_08049D34:
- ldr r3, =gBankAttacker
- mov r8, r3
- ldrb r0, [r3]
- bl GetBankSide
- adds r4, r0, 0
- ldrb r0, [r6]
- bl GetBankSide
- lsls r4, 24
- lsls r0, 24
- cmp r4, r0
- beq _08049E32
- ldr r0, =gBattleMons
- mov r9, r0
- mov r2, r8
- ldrb r1, [r2]
- movs r7, 0x58
- adds r2, r1, 0
- muls r2, r7
- adds r0, r2, r0
- ldrh r0, [r0, 0x28]
- cmp r0, 0
- beq _08049E32
- ldr r0, =gCurrentMove
- ldrh r0, [r0]
- cmp r0, 0xA5
- beq _08049E32
- ldr r0, =gBattleStruct
- ldr r0, [r0]
- adds r0, r1, r0
- adds r0, 0x80
- ldrb r4, [r0]
- adds r0, r4, r2
- mov r6, r9
- adds r6, 0x24
- adds r0, r6
- strb r5, [r0]
- ldr r5, =gBattlescriptCurrInstr
- ldr r0, [r5]
- bl b_movescr_stack_push
- ldr r0, =gUnknown_082DB18D
- str r0, [r5]
- ldr r5, =gActiveBank
- mov r3, r8
- ldrb r0, [r3]
- strb r0, [r5]
- adds r1, r4, 0
- adds r1, 0x9
- lsls r1, 24
- lsrs r1, 24
- ldrb r0, [r5]
- muls r0, r7
- adds r0, r6
- adds r0, r4
- str r0, [sp]
- movs r0, 0
- movs r2, 0
- movs r3, 0x1
- bl EmitSetAttributes
- ldrb r0, [r5]
- bl MarkBufferBankForExecution
- ldr r1, =gBattleTextBuff1
- movs r0, 0xFD
- strb r0, [r1]
- movs r0, 0x2
- strb r0, [r1, 0x1]
- lsls r4, 1
- mov r2, r8
- ldrb r0, [r2]
- muls r0, r7
- adds r0, r4, r0
- mov r2, r9
- adds r2, 0xC
- adds r0, r2
- ldrh r0, [r0]
- strb r0, [r1, 0x2]
- mov r3, r8
- ldrb r0, [r3]
- muls r0, r7
- adds r4, r0
- adds r4, r2
- ldrh r0, [r4]
- lsrs r0, 8
- strb r0, [r1, 0x3]
- movs r0, 0xFF
- strb r0, [r1, 0x4]
- b _08049E32
- .pool
-_08049E2C:
- ldr r0, [r6]
- adds r0, 0x7
- str r0, [r6]
-_08049E32:
- add sp, 0x4
- pop {r3,r4}
- mov r8, r3
- mov r9, r4
- pop {r4-r7}
- pop {r0}
- bx r0
- thumb_func_end atk19_faint_pokemon
-
- thumb_func_start atk1A_faint_animation
-atk1A_faint_animation: @ 8049E40
- push {r4,r5,lr}
- ldr r0, =gBattleExecBuffer
- ldr r0, [r0]
- cmp r0, 0
- bne _08049E6A
- ldr r5, =gBattlescriptCurrInstr
- ldr r0, [r5]
- ldrb r0, [r0, 0x1]
- bl GetBattleBank
- ldr r4, =gActiveBank
- strb r0, [r4]
- movs r0, 0
- bl dp01_build_cmdbuf_x0A_A_A_A
- ldrb r0, [r4]
- bl MarkBufferBankForExecution
- ldr r0, [r5]
- adds r0, 0x2
- str r0, [r5]
-_08049E6A:
- pop {r4,r5}
- pop {r0}
- bx r0
- .pool
- thumb_func_end atk1A_faint_animation
-
- thumb_func_start atk1B_faint_effects_clear
-atk1B_faint_effects_clear: @ 8049E7C
- push {r4,r5,lr}
- sub sp, 0x4
- ldr r0, =gBattleExecBuffer
- ldr r5, [r0]
- cmp r5, 0
- bne _08049EE8
- ldr r0, =gBattlescriptCurrInstr
- ldr r0, [r0]
- ldrb r0, [r0, 0x1]
- bl GetBattleBank
- ldr r4, =gActiveBank
- strb r0, [r4]
- ldr r0, =gBattleTypeFlags
- ldr r0, [r0]
- movs r1, 0x80
- lsls r1, 11
- ands r0, r1
- cmp r0, 0
- beq _08049EB4
- ldr r2, =gBattleMons
- ldrb r1, [r4]
- movs r0, 0x58
- muls r0, r1
- adds r0, r2
- ldrh r0, [r0, 0x28]
- cmp r0, 0
- bne _08049EDC
-_08049EB4:
- ldr r1, =gBattleMons
- ldrb r0, [r4]
- movs r2, 0x58
- muls r0, r2
- adds r1, 0x4C
- adds r0, r1
- str r5, [r0]
- ldrb r0, [r4]
- muls r0, r2
- adds r0, r1
- str r0, [sp]
- movs r0, 0
- movs r1, 0x28
- movs r2, 0
- movs r3, 0x4
- bl EmitSetAttributes
- ldrb r0, [r4]
- bl MarkBufferBankForExecution
-_08049EDC:
- bl sub_803A75C
- ldr r1, =gBattlescriptCurrInstr
- ldr r0, [r1]
- adds r0, 0x2
- str r0, [r1]
-_08049EE8:
- add sp, 0x4
- pop {r4,r5}
- pop {r0}
- bx r0
- .pool
- thumb_func_end atk1B_faint_effects_clear
-
- thumb_func_start atk1C_jumpifstatus
-atk1C_jumpifstatus: @ 8049F04
- push {r4,r5,lr}
- ldr r5, =gBattlescriptCurrInstr
- ldr r0, [r5]
- ldrb r0, [r0, 0x1]
- bl GetBattleBank
- lsls r0, 24
- lsrs r0, 24
- ldr r2, [r5]
- ldrb r4, [r2, 0x2]
- ldrb r1, [r2, 0x3]
- lsls r1, 8
- adds r4, r1
- ldrb r1, [r2, 0x4]
- lsls r1, 16
- adds r4, r1
- ldrb r1, [r2, 0x5]
- lsls r1, 24
- adds r4, r1
- ldrb r3, [r2, 0x6]
- ldrb r1, [r2, 0x7]
- lsls r1, 8
- adds r3, r1
- ldrb r1, [r2, 0x8]
- lsls r1, 16
- adds r3, r1
- ldrb r1, [r2, 0x9]
- lsls r1, 24
- adds r3, r1
- ldr r2, =gBattleMons
- movs r1, 0x58
- muls r1, r0
- adds r0, r2, 0
- adds r0, 0x4C
- adds r0, r1, r0
- ldr r0, [r0]
- ands r0, r4
- cmp r0, 0
- beq _08049F68
- adds r0, r1, r2
- ldrh r0, [r0, 0x28]
- cmp r0, 0
- beq _08049F68
- str r3, [r5]
- b _08049F70
- .pool
-_08049F68:
- ldr r1, =gBattlescriptCurrInstr
- ldr r0, [r1]
- adds r0, 0xA
- str r0, [r1]
-_08049F70:
- pop {r4,r5}
- pop {r0}
- bx r0
- .pool
- thumb_func_end atk1C_jumpifstatus
-
- thumb_func_start atk1D_jumpifstatus2
-atk1D_jumpifstatus2: @ 8049F7C
- push {r4,r5,lr}
- ldr r5, =gBattlescriptCurrInstr
- ldr r0, [r5]
- ldrb r0, [r0, 0x1]
- bl GetBattleBank
- lsls r0, 24
- lsrs r0, 24
- ldr r2, [r5]
- ldrb r4, [r2, 0x2]
- ldrb r1, [r2, 0x3]
- lsls r1, 8
- adds r4, r1
- ldrb r1, [r2, 0x4]
- lsls r1, 16
- adds r4, r1
- ldrb r1, [r2, 0x5]
- lsls r1, 24
- adds r4, r1
- ldrb r3, [r2, 0x6]
- ldrb r1, [r2, 0x7]
- lsls r1, 8
- adds r3, r1
- ldrb r1, [r2, 0x8]
- lsls r1, 16
- adds r3, r1
- ldrb r1, [r2, 0x9]
- lsls r1, 24
- adds r3, r1
- ldr r2, =gBattleMons
- movs r1, 0x58
- muls r1, r0
- adds r0, r2, 0
- adds r0, 0x50
- adds r0, r1, r0
- ldr r0, [r0]
- ands r0, r4
- cmp r0, 0
- beq _08049FE0
- adds r0, r1, r2
- ldrh r0, [r0, 0x28]
- cmp r0, 0
- beq _08049FE0
- str r3, [r5]
- b _08049FE8
- .pool
-_08049FE0:
- ldr r1, =gBattlescriptCurrInstr
- ldr r0, [r1]
- adds r0, 0xA
- str r0, [r1]
-_08049FE8:
- pop {r4,r5}
- pop {r0}
- bx r0
- .pool
- thumb_func_end atk1D_jumpifstatus2
-
- thumb_func_start atk1E_jumpifability
-atk1E_jumpifability: @ 8049FF4
- push {r4-r7,lr}
- mov r7, r8
- push {r7}
- sub sp, 0x4
- ldr r6, =gBattlescriptCurrInstr
- ldr r2, [r6]
- ldrb r5, [r2, 0x2]
- mov r8, r5
- ldrb r1, [r2, 0x3]
- ldrb r0, [r2, 0x4]
- lsls r0, 8
- adds r1, r0
- ldrb r0, [r2, 0x5]
- lsls r0, 16
- adds r1, r0
- ldrb r0, [r2, 0x6]
- lsls r0, 24
- adds r7, r1, r0
- ldrb r0, [r2, 0x1]
- cmp r0, 0x8
- bne _0804A054
- ldr r0, =gBankAttacker
- ldrb r1, [r0]
- movs r0, 0
- str r0, [sp]
- movs r0, 0xD
- adds r2, r5, 0
- movs r3, 0
- bl AbilityBattleEffects
- lsls r0, 24
- lsrs r4, r0, 24
- cmp r4, 0
- beq _0804A0C8
- ldr r1, =gLastUsedAbility
- strb r5, [r1]
- str r7, [r6]
- subs r4, 0x1
- lsls r0, r4, 24
- lsrs r0, 24
- ldrb r1, [r1]
- b _0804A0B0
- .pool
-_0804A054:
- cmp r0, 0x9
- bne _0804A08C
- ldr r0, =gBankAttacker
- ldrb r1, [r0]
- movs r0, 0
- str r0, [sp]
- movs r0, 0xC
- adds r2, r5, 0
- movs r3, 0
- bl AbilityBattleEffects
- lsls r0, 24
- lsrs r4, r0, 24
- cmp r4, 0
- beq _0804A0C8
- ldr r1, =gLastUsedAbility
- strb r5, [r1]
- str r7, [r6]
- subs r4, 0x1
- lsls r0, r4, 24
- lsrs r0, 24
- ldrb r1, [r1]
- b _0804A0B0
- .pool
-_0804A08C:
- ldrb r0, [r2, 0x1]
- bl GetBattleBank
- lsls r0, 24
- lsrs r4, r0, 24
- ldr r1, =gBattleMons
- movs r0, 0x58
- muls r0, r4
- adds r0, r1
- adds r0, 0x20
- ldrb r1, [r0]
- cmp r1, r8
- bne _0804A0C8
- ldr r0, =gLastUsedAbility
- strb r1, [r0]
- str r7, [r6]
- ldrb r1, [r0]
- adds r0, r4, 0
-_0804A0B0:
- bl RecordAbilityBattle
- ldr r0, =gBattleScripting
- strb r4, [r0, 0x15]
- b _0804A0CE
- .pool
-_0804A0C8:
- ldr r0, [r6]
- adds r0, 0x7
- str r0, [r6]
-_0804A0CE:
- add sp, 0x4
- pop {r3}
- mov r8, r3
- pop {r4-r7}
- pop {r0}
- bx r0
- thumb_func_end atk1E_jumpifability
-
- thumb_func_start atk1F_jumpifsideaffecting
-atk1F_jumpifsideaffecting: @ 804A0DC
- push {r4-r6,lr}
- ldr r0, =gBattlescriptCurrInstr
- ldr r0, [r0]
- ldrb r4, [r0, 0x1]
- cmp r4, 0x1
- bne _0804A0FC
- ldr r0, =gBankAttacker
- ldrb r0, [r0]
- bl GetBankIdentity
- b _0804A106
- .pool
-_0804A0FC:
- ldr r0, =gBankTarget
- ldrb r0, [r0]
- bl GetBankIdentity
- movs r4, 0x1
-_0804A106:
- ands r4, r0
- ldr r6, =gBattlescriptCurrInstr
- ldr r3, [r6]
- ldrb r2, [r3, 0x2]
- ldrb r0, [r3, 0x3]
- lsls r0, 8
- orrs r2, r0
- ldrb r1, [r3, 0x4]
- ldrb r0, [r3, 0x5]
- lsls r0, 8
- adds r1, r0
- ldrb r0, [r3, 0x6]
- lsls r0, 16
- adds r1, r0
- ldrb r0, [r3, 0x7]
- lsls r0, 24
- adds r5, r1, r0
- ldr r1, =gSideAffecting
- lsls r0, r4, 1
- adds r0, r1
- ldrh r0, [r0]
- ands r2, r0
- cmp r2, 0
- beq _0804A148
- str r5, [r6]
- b _0804A14E
- .pool
-_0804A148:
- adds r0, r3, 0
- adds r0, 0x8
- str r0, [r6]
-_0804A14E:
- pop {r4-r6}
- pop {r0}
- bx r0
- thumb_func_end atk1F_jumpifsideaffecting
-
- thumb_func_start atk20_jumpifstat
-atk20_jumpifstat: @ 804A154
- push {r4,r5,lr}
- movs r5, 0
- ldr r4, =gBattlescriptCurrInstr
- ldr r0, [r4]
- ldrb r0, [r0, 0x1]
- bl GetBattleBank
- lsls r0, 24
- lsrs r0, 24
- ldr r2, =gBattleMons
- ldr r3, [r4]
- movs r1, 0x58
- muls r0, r1
- ldrb r1, [r3, 0x3]
- adds r0, r1
- adds r2, 0x18
- adds r0, r2
- ldrb r2, [r0]
- ldrb r0, [r3, 0x2]
- cmp r0, 0x5
- bhi _0804A212
- lsls r0, 2
- ldr r1, =_0804A194
- adds r0, r1
- ldr r0, [r0]
- mov pc, r0
- .pool
- .align 2, 0
-_0804A194:
- .4byte _0804A1AC
- .4byte _0804A1BC
- .4byte _0804A1CC
- .4byte _0804A1DC
- .4byte _0804A1EC
- .4byte _0804A200
-_0804A1AC:
- ldr r0, =gBattlescriptCurrInstr
- ldr r0, [r0]
- ldrb r0, [r0, 0x4]
- cmp r2, r0
- bne _0804A212
- b _0804A20C
- .pool
-_0804A1BC:
- ldr r0, =gBattlescriptCurrInstr
- ldr r0, [r0]
- ldrb r0, [r0, 0x4]
- cmp r2, r0
- beq _0804A212
- b _0804A20C
- .pool
-_0804A1CC:
- ldr r0, =gBattlescriptCurrInstr
- ldr r0, [r0]
- ldrb r0, [r0, 0x4]
- cmp r2, r0
- bls _0804A212
- b _0804A20C
- .pool
-_0804A1DC:
- ldr r0, =gBattlescriptCurrInstr
- ldr r0, [r0]
- ldrb r0, [r0, 0x4]
- cmp r2, r0
- bcs _0804A212
- b _0804A20C
- .pool
-_0804A1EC:
- ldr r0, =gBattlescriptCurrInstr
- ldr r0, [r0]
- ldrb r0, [r0, 0x4]
- ands r2, r0
- cmp r2, 0
- beq _0804A212
- b _0804A20C
- .pool
-_0804A200:
- ldr r0, =gBattlescriptCurrInstr
- ldr r0, [r0]
- ldrb r0, [r0, 0x4]
- ands r2, r0
- cmp r2, 0
- bne _0804A212
-_0804A20C:
- adds r0, r5, 0x1
- lsls r0, 24
- lsrs r5, r0, 24
-_0804A212:
- cmp r5, 0
- beq _0804A238
- ldr r3, =gBattlescriptCurrInstr
- ldr r2, [r3]
- ldrb r1, [r2, 0x5]
- ldrb r0, [r2, 0x6]
- lsls r0, 8
- adds r1, r0
- ldrb r0, [r2, 0x7]
- lsls r0, 16
- adds r1, r0
- ldrb r0, [r2, 0x8]
- lsls r0, 24
- adds r1, r0
- str r1, [r3]
- b _0804A240
- .pool
-_0804A238:
- ldr r1, =gBattlescriptCurrInstr
- ldr r0, [r1]
- adds r0, 0x9
- str r0, [r1]
-_0804A240:
- pop {r4,r5}
- pop {r0}
- bx r0
- .pool
- thumb_func_end atk20_jumpifstat
-
- thumb_func_start atk21_jumpifstatus3
-atk21_jumpifstatus3: @ 804A24C
- push {r4-r6,lr}
- ldr r4, =gBattlescriptCurrInstr
- ldr r0, [r4]
- ldrb r0, [r0, 0x1]
- bl GetBattleBank
- ldr r5, =gActiveBank
- strb r0, [r5]
- ldr r2, [r4]
- ldrb r1, [r2, 0x2]
- ldrb r0, [r2, 0x3]
- lsls r0, 8
- adds r1, r0
- ldrb r0, [r2, 0x4]
- lsls r0, 16
- adds r1, r0
- ldrb r0, [r2, 0x5]
- lsls r0, 24
- adds r6, r1, r0
- ldrb r1, [r2, 0x7]
- ldrb r0, [r2, 0x8]
- lsls r0, 8
- adds r1, r0
- ldrb r0, [r2, 0x9]
- lsls r0, 16
- adds r1, r0
- ldrb r0, [r2, 0xA]
- lsls r0, 24
- adds r3, r1, r0
- ldrb r0, [r2, 0x6]
- cmp r0, 0
- beq _0804A2AC
- ldr r0, =gStatuses3
- ldrb r1, [r5]
- lsls r1, 2
- adds r1, r0
- ldr r0, [r1]
- ands r0, r6
- cmp r0, 0
- bne _0804A2C4
- b _0804A2BC
- .pool
-_0804A2AC:
- ldr r0, =gStatuses3
- ldrb r1, [r5]
- lsls r1, 2
- adds r1, r0
- ldr r0, [r1]
- ands r0, r6
- cmp r0, 0
- beq _0804A2C4
-_0804A2BC:
- str r3, [r4]
- b _0804A2CA
- .pool
-_0804A2C4:
- adds r0, r2, 0
- adds r0, 0xB
- str r0, [r4]
-_0804A2CA:
- pop {r4-r6}
- pop {r0}
- bx r0
- thumb_func_end atk21_jumpifstatus3
-
- thumb_func_start atk22_jumpiftype
-atk22_jumpiftype: @ 804A2D0
- push {r4-r6,lr}
- ldr r4, =gBattlescriptCurrInstr
- ldr r0, [r4]
- ldrb r0, [r0, 0x1]
- bl GetBattleBank
- lsls r0, 24
- lsrs r0, 24
- ldr r3, [r4]
- ldrb r5, [r3, 0x2]
- ldrb r2, [r3, 0x3]
- ldrb r1, [r3, 0x4]
- lsls r1, 8
- adds r2, r1
- ldrb r1, [r3, 0x5]
- lsls r1, 16
- adds r2, r1
- ldrb r1, [r3, 0x6]
- lsls r1, 24
- adds r6, r2, r1
- ldr r2, =gBattleMons
- movs r1, 0x58
- muls r0, r1
- adds r1, r0, r2
- adds r0, r1, 0
- adds r0, 0x21
- ldrb r0, [r0]
- cmp r0, r5
- beq _0804A314
- adds r0, r1, 0
- adds r0, 0x22
- ldrb r0, [r0]
- cmp r0, r5
- bne _0804A320
-_0804A314:
- str r6, [r4]
- b _0804A324
- .pool
-_0804A320:
- adds r0, r3, 0x7
- str r0, [r4]
-_0804A324:
- pop {r4-r6}
- pop {r0}
- bx r0
- thumb_func_end atk22_jumpiftype
-
- thumb_func_start atk23_getexp
-atk23_getexp: @ 804A32C
- push {r4-r7,lr}
- mov r7, r9
- mov r6, r8
- push {r6,r7}
- movs r6, 0
- ldr r0, =gBattleStruct
- ldr r0, [r0]
- adds r0, 0x50
- mov r9, r0
- ldr r0, =gBattlescriptCurrInstr
- ldr r0, [r0]
- ldrb r0, [r0, 0x1]
- bl GetBattleBank
- ldr r1, =gBank1
- strb r0, [r1]
- ldr r2, =gUnknown_020243FE
- movs r1, 0x2
- ands r1, r0
- lsls r1, 24
- lsrs r1, 25
- adds r1, r2
- ldrb r1, [r1]
- mov r8, r1
- ldr r0, =gBattleScripting
- ldrb r0, [r0, 0x1C]
- cmp r0, 0x6
- bls _0804A368
- bl _0804ACB2
-_0804A368:
- lsls r0, 2
- ldr r1, =_0804A38C
- adds r0, r1
- ldr r0, [r0]
- mov pc, r0
- .pool
- .align 2, 0
-_0804A38C:
- .4byte _0804A3A8
- .4byte _0804A414
- .4byte _0804A52E
- .4byte _0804A850
- .4byte _0804A954
- .4byte _0804AC40
- .4byte _0804AC88
-_0804A3A8:
- ldr r4, =gBank1
- ldrb r0, [r4]
- bl GetBankSide
- lsls r0, 24
- lsrs r0, 24
- cmp r0, 0x1
- beq _0804A3BC
- bl _0804AC7C
-_0804A3BC:
- ldr r0, =gBattleTypeFlags
- ldr r0, [r0]
- ldr r1, =0x063f0982
- ands r0, r1
- cmp r0, 0
- beq _0804A3CC
- bl _0804AC7C
-_0804A3CC:
- ldr r1, =gBattleScripting
- ldrb r0, [r1, 0x1C]
- adds r0, 0x1
- strb r0, [r1, 0x1C]
- ldr r0, =gBattleStruct
- ldr r2, [r0]
- adds r2, 0xDF
- ldr r3, =gBitTable
- ldr r1, =gBattlePartyID
- ldrb r0, [r4]
- lsls r0, 1
- adds r0, r1
- ldrh r0, [r0]
- lsls r0, 2
- adds r0, r3
- ldr r0, [r0]
- ldrb r1, [r2]
- orrs r0, r1
- strb r0, [r2]
- bl _0804ACB2
- .pool
-_0804A414:
- movs r5, 0
- movs r7, 0
-_0804A418:
- movs r0, 0x64
- adds r1, r7, 0
- muls r1, r0
- ldr r0, =gPlayerParty
- adds r4, r1, r0
- adds r0, r4, 0
- movs r1, 0xB
- bl GetMonData
- cmp r0, 0
- beq _0804A486
- adds r0, r4, 0
- movs r1, 0x39
- bl GetMonData
- cmp r0, 0
- beq _0804A486
- ldr r0, =gBitTable
- lsls r1, r7, 2
- adds r1, r0
- ldr r0, [r1]
- mov r1, r8
- ands r0, r1
- cmp r0, 0
- beq _0804A44C
- adds r5, 0x1
-_0804A44C:
- adds r0, r4, 0
- movs r1, 0xC
- bl GetMonData
- lsls r0, 16
- lsrs r0, 16
- cmp r0, 0xAF
- bne _0804A478
- ldr r0, =gSaveBlock1Ptr
- ldr r0, [r0]
- ldr r2, =0x00003226
- adds r0, r2
- ldrb r4, [r0]
- b _0804A480
- .pool
-_0804A478:
- bl ItemId_GetHoldEffect
- lsls r0, 24
- lsrs r4, r0, 24
-_0804A480:
- cmp r4, 0x19
- bne _0804A486
- adds r6, 0x1
-_0804A486:
- adds r7, 0x1
- cmp r7, 0x5
- ble _0804A418
- ldr r3, =gBaseStats
- ldr r2, =gBattleMons
- ldr r0, =gBank1
- ldrb r1, [r0]
- movs r0, 0x58
- muls r1, r0
- adds r1, r2
- ldrh r2, [r1]
- lsls r0, r2, 3
- subs r0, r2
- lsls r0, 2
- adds r0, r3
- ldrb r2, [r0, 0x9]
- adds r1, 0x2A
- ldrb r0, [r1]
- muls r0, r2
- movs r1, 0x7
- bl __divsi3
- lsls r0, 16
- lsrs r1, r0, 16
- cmp r6, 0
- beq _0804A4FC
- lsrs r4, r0, 17
- adds r0, r4, 0
- adds r1, r5, 0
- bl __divsi3
- mov r1, r9
- strh r0, [r1]
- lsls r0, 16
- cmp r0, 0
- bne _0804A4D2
- movs r0, 0x1
- strh r0, [r1]
-_0804A4D2:
- ldr r5, =gUnknown_02024402
- adds r0, r4, 0
- adds r1, r6, 0
- bl __divsi3
- strh r0, [r5]
- lsls r0, 16
- cmp r0, 0
- bne _0804A516
- movs r0, 0x1
- strh r0, [r5]
- b _0804A516
- .pool
-_0804A4FC:
- adds r0, r1, 0
- adds r1, r5, 0
- bl __divsi3
- mov r2, r9
- strh r0, [r2]
- lsls r0, 16
- cmp r0, 0
- bne _0804A512
- movs r0, 0x1
- strh r0, [r2]
-_0804A512:
- ldr r0, =gUnknown_02024402
- strh r6, [r0]
-_0804A516:
- ldr r1, =gBattleScripting
- ldrb r0, [r1, 0x1C]
- adds r0, 0x1
- movs r2, 0
- strb r0, [r1, 0x1C]
- ldr r1, =gBattleStruct
- ldr r0, [r1]
- strb r2, [r0, 0x10]
- ldr r0, [r1]
- adds r0, 0x53
- mov r4, r8
- strb r4, [r0]
-_0804A52E:
- ldr r0, =gBattleExecBuffer
- ldr r0, [r0]
- cmp r0, 0
- beq _0804A538
- b _0804ACB2
-_0804A538:
- ldr r0, =gBattleStruct
- ldr r0, [r0]
- ldrb r1, [r0, 0x10]
- movs r0, 0x64
- muls r0, r1
- ldr r1, =gPlayerParty
- adds r0, r1
- movs r1, 0xC
- bl GetMonData
- lsls r0, 16
- lsrs r0, 16
- cmp r0, 0xAF
- bne _0804A57C
- ldr r0, =gSaveBlock1Ptr
- ldr r0, [r0]
- ldr r1, =0x00003226
- adds r0, r1
- ldrb r4, [r0]
- b _0804A584
- .pool
-_0804A57C:
- bl ItemId_GetHoldEffect
- lsls r0, 24
- lsrs r4, r0, 24
-_0804A584:
- ldr r5, =gBattleStruct
- cmp r4, 0x19
- beq _0804A5AC
- ldr r0, [r5]
- adds r1, r0, 0
- adds r1, 0x53
- ldrb r0, [r1]
- movs r2, 0x1
- ands r2, r0
- cmp r2, 0
- bne _0804A5AC
- lsrs r0, 1
- strb r0, [r1]
- ldr r1, =gBattleScripting
- b _0804A5D0
- .pool
-_0804A5AC:
- ldr r0, [r5]
- ldrb r1, [r0, 0x10]
- movs r0, 0x64
- muls r0, r1
- ldr r1, =gPlayerParty
- adds r0, r1
- movs r1, 0x38
- bl GetMonData
- cmp r0, 0x64
- bne _0804A5E8
- ldr r1, [r5]
- adds r1, 0x53
- ldrb r0, [r1]
- lsrs r0, 1
- strb r0, [r1]
- ldr r1, =gBattleScripting
- movs r2, 0
-_0804A5D0:
- movs r0, 0x5
- strb r0, [r1, 0x1C]
- ldr r0, =gBattleMoveDamage
- str r2, [r0]
- b _0804ACB2
- .pool
-_0804A5E8:
- ldr r0, =gBattleTypeFlags
- ldr r0, [r0]
- movs r1, 0x8
- ands r0, r1
- cmp r0, 0
- bne _0804A616
- ldr r0, =gBattleMons
- ldrh r0, [r0, 0x28]
- cmp r0, 0
- beq _0804A616
- ldr r0, [r5]
- ldrb r0, [r0, 0x12]
- cmp r0, 0
- bne _0804A616
- bl sub_805EA60
- ldr r0, =0x00000161
- bl PlayBGM
- ldr r1, [r5]
- ldrb r0, [r1, 0x12]
- adds r0, 0x1
- strb r0, [r1, 0x12]
-_0804A616:
- ldr r5, =gBattleStruct
- ldr r0, [r5]
- ldrb r1, [r0, 0x10]
- movs r0, 0x64
- muls r0, r1
- ldr r1, =gPlayerParty
- adds r0, r1
- movs r1, 0x39
- bl GetMonData
- cmp r0, 0
- bne _0804A630
- b _0804A824
-_0804A630:
- ldr r0, [r5]
- adds r0, 0x53
- ldrb r0, [r0]
- movs r3, 0x1
- ands r3, r0
- cmp r3, 0
- beq _0804A664
- ldr r1, =gBattleMoveDamage
- mov r2, r9
- ldrh r0, [r2]
- str r0, [r1]
- mov r9, r1
- b _0804A66A
- .pool
-_0804A664:
- ldr r0, =gBattleMoveDamage
- str r3, [r0]
- mov r9, r0
-_0804A66A:
- cmp r4, 0x19
- bne _0804A67A
- ldr r0, =gUnknown_02024402
- ldrh r1, [r0]
- mov r2, r9
- ldr r0, [r2]
- adds r0, r1
- str r0, [r2]
-_0804A67A:
- cmp r4, 0x28
- bne _0804A68E
- mov r4, r9
- ldr r1, [r4]
- movs r0, 0x96
- muls r0, r1
- movs r1, 0x64
- bl __divsi3
- str r0, [r4]
-_0804A68E:
- ldr r5, =gBattleTypeFlags
- ldr r0, [r5]
- movs r1, 0x8
- ands r0, r1
- cmp r0, 0
- beq _0804A6AA
- ldr r4, =gBattleMoveDamage
- ldr r1, [r4]
- movs r0, 0x96
- muls r0, r1
- movs r1, 0x64
- bl __divsi3
- str r0, [r4]
-_0804A6AA:
- ldr r4, =gBattleStruct
- ldr r0, [r4]
- ldrb r1, [r0, 0x10]
- movs r0, 0x64
- muls r0, r1
- ldr r1, =gPlayerParty
- adds r0, r1
- bl IsTradedMon
- lsls r0, 24
- cmp r0, 0
- beq _0804A714
- ldr r0, [r5]
- movs r1, 0x80
- lsls r1, 15
- ands r0, r1
- cmp r0, 0
- beq _0804A6F8
- ldr r0, [r4]
- ldrb r0, [r0, 0x10]
- cmp r0, 0x2
- bls _0804A6F8
- ldr r7, =0x00000149
- ldr r0, =gBattleMoveDamage
- mov r9, r0
- b _0804A71A
- .pool
-_0804A6F8:
- ldr r4, =gBattleMoveDamage
- ldr r1, [r4]
- movs r0, 0x96
- muls r0, r1
- movs r1, 0x64
- bl __divsi3
- str r0, [r4]
- movs r7, 0xA5
- lsls r7, 1
- mov r9, r4
- b _0804A71A
- .pool
-_0804A714:
- ldr r7, =0x00000149
- ldr r1, =gBattleMoveDamage
- mov r9, r1
-_0804A71A:
- ldr r0, =gBattleTypeFlags
- ldr r1, [r0]
- movs r0, 0x1
- ands r1, r0
- cmp r1, 0
- beq _0804A786
- ldr r0, =gBattlePartyID
- ldr r1, =gBattleStruct
- ldr r4, [r1]
- ldrh r0, [r0, 0x4]
- adds r5, r1, 0
- ldr r3, =gBitTable
- ldr r2, =gAbsentBankFlags
- ldrb r1, [r4, 0x10]
- cmp r0, r1
- bne _0804A76C
- ldrb r1, [r2]
- ldr r0, [r3, 0x8]
- ands r1, r0
- cmp r1, 0
- bne _0804A76C
- adds r1, r4, 0
- adds r1, 0x8F
- movs r0, 0x2
- strb r0, [r1]
- b _0804A78E
- .pool
-_0804A76C:
- ldrb r2, [r2]
- ldr r0, [r3]
- ands r2, r0
- cmp r2, 0
- bne _0804A77E
- ldr r0, [r5]
- adds r0, 0x8F
- strb r2, [r0]
- b _0804A78E
-_0804A77E:
- ldr r0, [r5]
- adds r0, 0x8F
- movs r1, 0x2
- b _0804A78C
-_0804A786:
- ldr r0, =gBattleStruct
- ldr r0, [r0]
- adds r0, 0x8F
-_0804A78C:
- strb r1, [r0]
-_0804A78E:
- ldr r1, =gBattleTextBuff1
- movs r2, 0
- mov r12, r2
- movs r3, 0xFD
- strb r3, [r1]
- movs r5, 0x4
- strb r5, [r1, 0x1]
- ldr r6, =gBattleStruct
- ldr r2, [r6]
- movs r4, 0x8F
- adds r4, r2
- mov r8, r4
- ldrb r0, [r4]
- strb r0, [r1, 0x2]
- ldrb r0, [r2, 0x10]
- strb r0, [r1, 0x3]
- movs r0, 0xFF
- strb r0, [r1, 0x4]
- ldr r1, =gBattleTextBuff2
- strb r3, [r1]
- mov r0, r12
- strb r0, [r1, 0x1]
- strb r7, [r1, 0x2]
- movs r4, 0xFF
- lsls r4, 8
- ands r7, r4
- asrs r0, r7, 8
- strb r0, [r1, 0x3]
- movs r0, 0x1
- negs r0, r0
- strb r0, [r1, 0x4]
- ldr r1, =gBattleTextBuff3
- strb r3, [r1]
- movs r0, 0x1
- strb r0, [r1, 0x1]
- strb r5, [r1, 0x2]
- movs r0, 0x5
- strb r0, [r1, 0x3]
- mov r0, r9
- ldr r2, [r0]
- strb r2, [r1, 0x4]
- adds r0, r2, 0
- ands r0, r4
- asrs r0, 8
- strb r0, [r1, 0x5]
- movs r0, 0xFF
- lsls r0, 16
- ands r0, r2
- asrs r0, 16
- strb r0, [r1, 0x6]
- lsrs r2, 24
- strb r2, [r1, 0x7]
- movs r0, 0x1
- negs r0, r0
- strb r0, [r1, 0x8]
- mov r2, r8
- ldrb r1, [r2]
- movs r0, 0xD
- bl PrepareStringBattle
- ldr r0, [r6]
- ldrb r1, [r0, 0x10]
- movs r0, 0x64
- muls r0, r1
- ldr r1, =gPlayerParty
- adds r0, r1
- ldr r3, =gBattleMons
- ldr r1, =gBank1
- ldrb r2, [r1]
- movs r1, 0x58
- muls r1, r2
- adds r1, r3
- ldrh r1, [r1]
- bl MonGainEVs
-_0804A824:
- ldr r0, =gBattleStruct
- ldr r1, [r0]
- adds r1, 0x53
- ldrb r0, [r1]
- lsrs r0, 1
- strb r0, [r1]
- b _0804A92A
- .pool
-_0804A850:
- ldr r0, =gBattleExecBuffer
- ldr r2, [r0]
- cmp r2, 0
- beq _0804A85A
- b _0804ACB2
-_0804A85A:
- ldr r1, =gBattleBufferB
- ldr r7, =gBattleStruct
- ldr r0, [r7]
- adds r0, 0x8F
- ldrb r0, [r0]
- lsls r0, 9
- adds r0, r1
- strb r2, [r0]
- ldr r0, [r7]
- ldrb r0, [r0, 0x10]
- movs r6, 0x64
- muls r0, r6
- ldr r5, =gPlayerParty
- adds r0, r5
- movs r1, 0x39
- bl GetMonData
- cmp r0, 0
- beq _0804A92A
- ldr r0, [r7]
- ldrb r0, [r0, 0x10]
- muls r0, r6
- adds r0, r5
- movs r1, 0x38
- bl GetMonData
- cmp r0, 0x64
- beq _0804A92A
- ldr r0, [r7]
- ldrb r0, [r0, 0x10]
- muls r0, r6
- adds r0, r5
- movs r1, 0x3A
- bl GetMonData
- ldr r4, =gBattleResources
- ldr r1, [r4]
- ldr r1, [r1, 0x10]
- strh r0, [r1]
- ldr r0, [r7]
- ldrb r0, [r0, 0x10]
- muls r0, r6
- adds r0, r5
- movs r1, 0x3B
- bl GetMonData
- ldr r1, [r4]
- ldr r1, [r1, 0x10]
- strh r0, [r1, 0x2]
- ldr r0, [r7]
- ldrb r0, [r0, 0x10]
- muls r0, r6
- adds r0, r5
- movs r1, 0x3C
- bl GetMonData
- ldr r1, [r4]
- ldr r1, [r1, 0x10]
- strh r0, [r1, 0x4]
- ldr r0, [r7]
- ldrb r0, [r0, 0x10]
- muls r0, r6
- adds r0, r5
- movs r1, 0x3D
- bl GetMonData
- ldr r1, [r4]
- ldr r1, [r1, 0x10]
- strh r0, [r1, 0x6]
- ldr r0, [r7]
- ldrb r0, [r0, 0x10]
- muls r0, r6
- adds r0, r5
- movs r1, 0x3E
- bl GetMonData
- ldr r1, [r4]
- ldr r1, [r1, 0x10]
- strh r0, [r1, 0x8]
- ldr r0, [r7]
- ldrb r0, [r0, 0x10]
- muls r0, r6
- adds r0, r5
- movs r1, 0x3F
- bl GetMonData
- ldr r1, [r4]
- ldr r1, [r1, 0x10]
- strh r0, [r1, 0xA]
- ldr r4, =gActiveBank
- ldr r1, [r7]
- adds r0, r1, 0
- adds r0, 0x8F
- ldrb r0, [r0]
- strb r0, [r4]
- ldrb r1, [r1, 0x10]
- ldr r0, =gBattleMoveDamage
- ldrh r2, [r0]
- movs r0, 0
- bl dp01_build_cmdbuf_x19_a_bb
- ldrb r0, [r4]
- bl MarkBufferBankForExecution
-_0804A92A:
- ldr r1, =gBattleScripting
- ldrb r0, [r1, 0x1C]
- adds r0, 0x1
- strb r0, [r1, 0x1C]
- b _0804ACB2
- .pool
-_0804A954:
- ldr r0, =gBattleExecBuffer
- ldr r0, [r0]
- cmp r0, 0
- beq _0804A95E
- b _0804ACB2
-_0804A95E:
- ldr r1, =gActiveBank
- ldr r0, =gBattleStruct
- ldr r4, [r0]
- adds r0, r4, 0
- adds r0, 0x8F
- ldrb r0, [r0]
- strb r0, [r1]
- ldr r3, =gBattleBufferB
- ldrb r2, [r1]
- lsls r1, r2, 9
- adds r0, r1, r3
- ldrb r0, [r0]
- cmp r0, 0x21
- beq _0804A97C
- b _0804AC28
-_0804A97C:
- adds r0, r3, 0x1
- adds r0, r1, r0
- ldrb r0, [r0]
- cmp r0, 0xB
- beq _0804A988
- b _0804AC28
-_0804A988:
- ldr r0, =gBattleTypeFlags
- ldr r0, [r0]
- movs r1, 0x8
- ands r0, r1
- cmp r0, 0
- beq _0804A9B2
- ldr r0, =gBattlePartyID
- lsls r1, r2, 1
- adds r1, r0
- ldrh r0, [r1]
- ldrb r4, [r4, 0x10]
- cmp r0, r4
- bne _0804A9B2
- adds r1, r0, 0
- movs r0, 0x64
- muls r0, r1
- ldr r1, =gPlayerParty
- adds r0, r1
- adds r1, r2, 0
- bl sub_805E990
-_0804A9B2:
- ldr r1, =gBattleTextBuff1
- movs r3, 0xFD
- strb r3, [r1]
- movs r0, 0x4
- strb r0, [r1, 0x1]
- ldr r6, =gActiveBank
- ldrb r0, [r6]
- strb r0, [r1, 0x2]
- ldr r4, =gBattleStruct
- mov r9, r4
- ldr r2, [r4]
- ldrb r0, [r2, 0x10]
- strb r0, [r1, 0x3]
- movs r0, 0xFF
- strb r0, [r1, 0x4]
- ldr r4, =gBattleTextBuff2
- strb r3, [r4]
- movs r0, 0x1
- strb r0, [r4, 0x1]
- strb r0, [r4, 0x2]
- movs r0, 0x3
- strb r0, [r4, 0x3]
- ldrb r0, [r2, 0x10]
- movs r1, 0x64
- mov r8, r1
- mov r2, r8
- muls r2, r0
- adds r0, r2, 0
- ldr r7, =gPlayerParty
- adds r0, r7
- movs r1, 0x38
- bl GetMonData
- strb r0, [r4, 0x4]
- movs r0, 0x1
- negs r0, r0
- strb r0, [r4, 0x5]
- bl b_movescr_stack_push_cursor
- ldr r2, =gUnknown_03005D54
- ldr r1, =gBitTable
- mov r4, r9
- ldr r5, [r4]
- ldrb r0, [r5, 0x10]
- lsls r0, 2
- adds r0, r1
- ldr r0, [r0]
- ldrb r1, [r2]
- orrs r0, r1
- strb r0, [r2]
- ldr r1, =gBattlescriptCurrInstr
- ldr r0, =gUnknown_082DABBD
- str r0, [r1]
- ldr r4, =gBattleMoveDamage
- ldr r2, =gBattleBufferB
- ldrb r1, [r6]
- lsls r1, 9
- adds r0, r2, 0x2
- adds r0, r1, r0
- ldrb r3, [r0]
- adds r2, 0x3
- adds r1, r2
- ldrb r0, [r1]
- lsls r0, 8
- orrs r3, r0
- str r3, [r4]
- ldrb r0, [r5, 0x10]
- mov r1, r8
- muls r1, r0
- adds r0, r1, 0
- adds r0, r7
- movs r1, 0
- bl AdjustFriendship
- ldr r1, =gBattlePartyID
- mov r2, r9
- ldr r0, [r2]
- ldrb r2, [r0, 0x10]
- ldrh r0, [r1]
- cmp r0, r2
- bne _0804AB1E
- ldr r4, =gBattleMons
- ldrh r0, [r4, 0x28]
- cmp r0, 0
- beq _0804AB1E
- mov r0, r8
- muls r0, r2
- adds r0, r7
- movs r1, 0x38
- bl GetMonData
- adds r1, r4, 0
- adds r1, 0x2A
- strb r0, [r1]
- mov r1, r9
- ldr r0, [r1]
- ldrb r0, [r0, 0x10]
- mov r2, r8
- muls r2, r0
- adds r0, r2, 0
- adds r0, r7
- movs r1, 0x39
- bl GetMonData
- strh r0, [r4, 0x28]
- mov r1, r9
- ldr r0, [r1]
- ldrb r0, [r0, 0x10]
- mov r2, r8
- muls r2, r0
- adds r0, r2, 0
- adds r0, r7
- movs r1, 0x3A
- bl GetMonData
- strh r0, [r4, 0x2C]
- mov r1, r9
- ldr r0, [r1]
- ldrb r0, [r0, 0x10]
- mov r2, r8
- muls r2, r0
- adds r0, r2, 0
- adds r0, r7
- movs r1, 0x3B
- bl GetMonData
- strh r0, [r4, 0x2]
- mov r1, r9
- ldr r0, [r1]
- ldrb r0, [r0, 0x10]
- mov r2, r8
- muls r2, r0
- adds r0, r2, 0
- adds r0, r7
- movs r1, 0x3C
- bl GetMonData
- strh r0, [r4, 0x4]
- mov r1, r9
- ldr r0, [r1]
- ldrb r0, [r0, 0x10]
- mov r2, r8
- muls r2, r0
- adds r0, r2, 0
- adds r0, r7
- movs r1, 0x3D
- bl GetMonData
- strh r0, [r4, 0x6]
- mov r1, r9
- ldr r0, [r1]
- ldrb r0, [r0, 0x10]
- mov r2, r8
- muls r2, r0
- adds r0, r2, 0
- adds r0, r7
- movs r1, 0x3D
- bl GetMonData
- strh r0, [r4, 0x6]
- mov r1, r9
- ldr r0, [r1]
- ldrb r0, [r0, 0x10]
- mov r2, r8
- muls r2, r0
- adds r0, r2, 0
- adds r0, r7
- movs r1, 0x3E
- bl GetMonData
- strh r0, [r4, 0x8]
- mov r1, r9
- ldr r0, [r1]
- ldrb r0, [r0, 0x10]
- mov r2, r8
- muls r2, r0
- adds r0, r2, 0
- adds r0, r7
- movs r1, 0x3F
- bl GetMonData
- strh r0, [r4, 0xA]
-_0804AB1E:
- ldr r0, =gBattlePartyID
- ldr r7, =gBattleStruct
- ldr r1, [r7]
- ldrb r2, [r1, 0x10]
- ldrh r0, [r0, 0x4]
- cmp r0, r2
- beq _0804AB2E
- b _0804AC2E
-_0804AB2E:
- ldr r6, =gBattleMons
- movs r4, 0xD8
- adds r4, r6
- mov r8, r4
- ldrh r0, [r4]
- cmp r0, 0
- beq _0804AC2E
- ldr r0, =gBattleTypeFlags
- ldr r0, [r0]
- movs r1, 0x1
- ands r0, r1
- cmp r0, 0
- beq _0804AC2E
- movs r5, 0x64
- adds r0, r2, 0
- muls r0, r5
- ldr r4, =gPlayerParty
- adds r0, r4
- movs r1, 0x38
- bl GetMonData
- adds r1, r6, 0
- adds r1, 0xDA
- strb r0, [r1]
- ldr r0, [r7]
- ldrb r0, [r0, 0x10]
- muls r0, r5
- adds r0, r4
- movs r1, 0x39
- bl GetMonData
- mov r1, r8
- strh r0, [r1]
- ldr r0, [r7]
- ldrb r0, [r0, 0x10]
- muls r0, r5
- adds r0, r4
- movs r1, 0x3A
- bl GetMonData
- adds r1, r6, 0
- adds r1, 0xDC
- strh r0, [r1]
- ldr r0, [r7]
- ldrb r0, [r0, 0x10]
- muls r0, r5
- adds r0, r4
- movs r1, 0x3B
- bl GetMonData
- adds r1, r6, 0
- adds r1, 0xB2
- strh r0, [r1]
- ldr r0, [r7]
- ldrb r0, [r0, 0x10]
- muls r0, r5
- adds r0, r4
- movs r1, 0x3C
- bl GetMonData
- adds r1, r6, 0
- adds r1, 0xB4
- strh r0, [r1]
- ldr r0, [r7]
- ldrb r0, [r0, 0x10]
- muls r0, r5
- adds r0, r4
- movs r1, 0x3D
- bl GetMonData
- movs r2, 0xB6
- adds r2, r6
- mov r8, r2
- strh r0, [r2]
- ldr r0, [r7]
- ldrb r0, [r0, 0x10]
- muls r0, r5
- adds r0, r4
- movs r1, 0x3D
- bl GetMonData
- mov r1, r8
- strh r0, [r1]
- ldr r0, [r7]
- ldrb r0, [r0, 0x10]
- muls r0, r5
- adds r0, r4
- movs r1, 0x3E
- bl GetMonData
- adds r1, r6, 0
- adds r1, 0xB8
- strh r0, [r1]
- b _0804AC2E
- .pool
-_0804AC28:
- ldr r1, =gBattleMoveDamage
- movs r0, 0
- str r0, [r1]
-_0804AC2E:
- ldr r1, =gBattleScripting
- movs r0, 0x5
- strb r0, [r1, 0x1C]
- b _0804ACB2
- .pool
-_0804AC40:
- ldr r0, =gBattleMoveDamage
- ldr r0, [r0]
- cmp r0, 0
- beq _0804AC58
- ldr r1, =gBattleScripting
- movs r0, 0x3
- strb r0, [r1, 0x1C]
- b _0804ACB2
- .pool
-_0804AC58:
- ldr r2, =gBattleStruct
- ldr r1, [r2]
- ldrb r0, [r1, 0x10]
- adds r0, 0x1
- strb r0, [r1, 0x10]
- ldr r0, [r2]
- ldrb r0, [r0, 0x10]
- cmp r0, 0x5
- bhi _0804AC7C
- ldr r1, =gBattleScripting
- movs r0, 0x2
- strb r0, [r1, 0x1C]
- b _0804ACB2
- .pool
-_0804AC7C:
- ldr r1, =gBattleScripting
- movs r0, 0x6
- strb r0, [r1, 0x1C]
- b _0804ACB2
- .pool
-_0804AC88:
- ldr r0, =gBattleExecBuffer
- ldr r5, [r0]
- cmp r5, 0
- bne _0804ACB2
- ldr r4, =gBattleMons
- ldr r2, =gBank1
- ldrb r0, [r2]
- movs r1, 0x58
- muls r0, r1
- adds r0, r4
- movs r3, 0
- strh r5, [r0, 0x2E]
- ldrb r0, [r2]
- muls r0, r1
- adds r0, r4
- adds r0, 0x20
- strb r3, [r0]
- ldr r1, =gBattlescriptCurrInstr
- ldr r0, [r1]
- adds r0, 0x2
- str r0, [r1]
-_0804ACB2:
- pop {r3,r4}
- mov r8, r3
- mov r9, r4
- pop {r4-r7}
- pop {r0}
- bx r0
- .pool
- thumb_func_end atk23_getexp
-
- thumb_func_start atk24
-atk24: @ 804ACD0
- push {r4-r7,lr}
- mov r7, r8
- push {r7}
- movs r6, 0
- ldr r0, =gBattleExecBuffer
- ldr r0, [r0]
- cmp r0, 0
- beq _0804ACE2
- b _0804AF22
-_0804ACE2:
- ldr r0, =gBattleTypeFlags
- ldr r0, [r0]
- movs r1, 0x80
- lsls r1, 15
- ands r0, r1
- cmp r0, 0
- beq _0804AD48
- ldr r0, =gPartnerTrainerId
- ldrh r1, [r0]
- ldr r0, =0x00000c03
- cmp r1, r0
- bne _0804AD48
- movs r5, 0
-_0804ACFC:
- movs r0, 0x64
- adds r1, r5, 0
- muls r1, r0
- ldr r0, =gPlayerParty
- adds r4, r1, r0
- adds r0, r4, 0
- movs r1, 0xB
- bl GetMonData
- cmp r0, 0
- beq _0804AD2C
- adds r0, r4, 0
- movs r1, 0x2D
- bl GetMonData
- cmp r0, 0
- bne _0804AD2C
- adds r0, r4, 0
- movs r1, 0x39
- bl GetMonData
- adds r0, r6, r0
- lsls r0, 16
- lsrs r6, r0, 16
-_0804AD2C:
- adds r5, 0x1
- cmp r5, 0x2
- ble _0804ACFC
- b _0804ADA8
- .pool
-_0804AD48:
- movs r5, 0
-_0804AD4A:
- movs r0, 0x64
- adds r1, r5, 0
- muls r1, r0
- ldr r0, =gPlayerParty
- adds r4, r1, r0
- adds r0, r4, 0
- movs r1, 0xB
- bl GetMonData
- cmp r0, 0
- beq _0804ADA2
- adds r0, r4, 0
- movs r1, 0x2D
- bl GetMonData
- cmp r0, 0
- bne _0804ADA2
- ldr r0, =gBattleTypeFlags
- ldr r0, [r0]
- movs r1, 0x80
- lsls r1, 11
- ands r0, r1
- cmp r0, 0
- beq _0804AD94
- ldr r0, =gBattleStruct
- ldr r0, [r0]
- movs r1, 0xA8
- lsls r1, 2
- adds r0, r1
- ldrb r1, [r0]
- ldr r2, =gBitTable
- lsls r0, r5, 2
- adds r0, r2
- ldr r0, [r0]
- ands r1, r0
- cmp r1, 0
- bne _0804ADA2
-_0804AD94:
- adds r0, r4, 0
- movs r1, 0x39
- bl GetMonData
- adds r0, r6, r0
- lsls r0, 16
- lsrs r6, r0, 16
-_0804ADA2:
- adds r5, 0x1
- cmp r5, 0x5
- ble _0804AD4A
-_0804ADA8:
- cmp r6, 0
- bne _0804ADB6
- ldr r0, =gBattleOutcome
- ldrb r1, [r0]
- movs r2, 0x2
- orrs r1, r2
- strb r1, [r0]
-_0804ADB6:
- movs r6, 0
- movs r5, 0
-_0804ADBA:
- movs r0, 0x64
- adds r1, r5, 0
- muls r1, r0
- ldr r0, =gEnemyParty
- adds r4, r1, r0
- adds r0, r4, 0
- movs r1, 0xB
- bl GetMonData
- cmp r0, 0
- beq _0804AE10
- adds r0, r4, 0
- movs r1, 0x2D
- bl GetMonData
- cmp r0, 0
- bne _0804AE10
- ldr r0, =gBattleTypeFlags
- ldr r0, [r0]
- movs r1, 0x80
- lsls r1, 11
- ands r0, r1
- cmp r0, 0
- beq _0804AE02
- ldr r0, =gBattleStruct
- ldr r0, [r0]
- ldr r1, =0x000002a1
- adds r0, r1
- ldrb r1, [r0]
- ldr r2, =gBitTable
- lsls r0, r5, 2
- adds r0, r2
- ldr r0, [r0]
- ands r1, r0
- cmp r1, 0
- bne _0804AE10
-_0804AE02:
- adds r0, r4, 0
- movs r1, 0x39
- bl GetMonData
- adds r0, r6, r0
- lsls r0, 16
- lsrs r6, r0, 16
-_0804AE10:
- adds r5, 0x1
- cmp r5, 0x5
- ble _0804ADBA
- ldr r2, =gBattleOutcome
- cmp r6, 0
- bne _0804AE24
- ldrb r0, [r2]
- movs r1, 0x1
- orrs r0, r1
- strb r0, [r2]
-_0804AE24:
- ldrb r0, [r2]
- cmp r0, 0
- bne _0804AF1A
- ldr r0, =gBattleTypeFlags
- ldr r1, [r0]
- ldr r2, =0x02000002
- ands r1, r2
- mov r8, r0
- cmp r1, 0
- beq _0804AF1A
- movs r3, 0
- movs r5, 0
- ldr r0, =gNoOfAllBanks
- ldrb r1, [r0]
- mov r12, r0
- ldr r7, =gBattlescriptCurrInstr
- cmp r3, r1
- bge _0804AE70
- ldr r0, =gHitMarker
- movs r6, 0x80
- lsls r6, 21
- ldr r4, [r0]
- adds r2, r1, 0
- ldr r1, =gSpecialStatuses
-_0804AE54:
- adds r0, r6, 0
- lsls r0, r5
- ands r0, r4
- cmp r0, 0
- beq _0804AE68
- ldrb r0, [r1]
- lsls r0, 25
- cmp r0, 0
- blt _0804AE68
- adds r3, 0x1
-_0804AE68:
- adds r1, 0x28
- adds r5, 0x2
- cmp r5, r2
- blt _0804AE54
-_0804AE70:
- movs r2, 0
- movs r5, 0x1
- mov r4, r12
- ldrb r1, [r4]
- cmp r5, r1
- bge _0804AEAA
- ldr r0, =gHitMarker
- movs r4, 0x80
- lsls r4, 21
- mov r12, r4
- ldr r6, [r0]
- ldr r0, =gSpecialStatuses
- adds r4, r1, 0
- adds r1, r0, 0
- adds r1, 0x14
-_0804AE8E:
- mov r0, r12
- lsls r0, r5
- ands r0, r6
- cmp r0, 0
- beq _0804AEA2
- ldrb r0, [r1]
- lsls r0, 25
- cmp r0, 0
- blt _0804AEA2
- adds r2, 0x1
-_0804AEA2:
- adds r1, 0x28
- adds r5, 0x2
- cmp r5, r4
- blt _0804AE8E
-_0804AEAA:
- mov r1, r8
- ldr r0, [r1]
- movs r1, 0x40
- ands r0, r1
- cmp r0, 0
- beq _0804AEF0
- adds r0, r2, r3
- cmp r0, 0x1
- bgt _0804AEF8
- b _0804AF12
- .pool
-_0804AEF0:
- cmp r2, 0
- beq _0804AF12
- cmp r3, 0
- beq _0804AF12
-_0804AEF8:
- ldr r2, [r7]
- ldrb r1, [r2, 0x1]
- ldrb r0, [r2, 0x2]
- lsls r0, 8
- adds r1, r0
- ldrb r0, [r2, 0x3]
- lsls r0, 16
- adds r1, r0
- ldrb r0, [r2, 0x4]
- lsls r0, 24
- adds r1, r0
- str r1, [r7]
- b _0804AF22
-_0804AF12:
- ldr r0, [r7]
- adds r0, 0x5
- str r0, [r7]
- b _0804AF22
-_0804AF1A:
- ldr r1, =gBattlescriptCurrInstr
- ldr r0, [r1]
- adds r0, 0x5
- str r0, [r1]
-_0804AF22:
- pop {r3}
- mov r8, r3
- pop {r4-r7}
- pop {r0}
- bx r0
- .pool
- thumb_func_end atk24
-
- thumb_func_start sub_804AF30
-sub_804AF30: @ 804AF30
- ldr r1, =gBattleMoveFlags
- movs r0, 0
- strb r0, [r1]
- ldr r0, =gBattleScripting
- movs r2, 0
- movs r1, 0x1
- strb r1, [r0, 0xE]
- ldr r0, =gCritMultiplier
- strb r1, [r0]
- ldr r0, =gBattleCommunication
- strb r2, [r0, 0x3]
- strb r2, [r0, 0x6]
- ldr r2, =gHitMarker
- ldr r0, [r2]
- subs r1, 0x42
- ands r0, r1
- ldr r1, =0xffffbfff
- ands r0, r1
- str r0, [r2]
- bx lr
- .pool
- thumb_func_end sub_804AF30
-
- thumb_func_start atk25_move_values_cleanup
-atk25_move_values_cleanup: @ 804AF70
- push {lr}
- bl sub_804AF30
- ldr r1, =gBattlescriptCurrInstr
- ldr r0, [r1]
- adds r0, 0x1
- str r0, [r1]
- pop {r0}
- bx r0
- .pool
- thumb_func_end atk25_move_values_cleanup
-
- thumb_func_start atk26_set_multihit
-atk26_set_multihit: @ 804AF88
- ldr r3, =gMultiHitCounter
- ldr r2, =gBattlescriptCurrInstr
- ldr r0, [r2]
- ldrb r1, [r0, 0x1]
- strb r1, [r3]
- adds r0, 0x2
- str r0, [r2]
- bx lr
- .pool
- thumb_func_end atk26_set_multihit
-
- thumb_func_start atk27_decrement_multihit
-atk27_decrement_multihit: @ 804AFA0
- push {lr}
- ldr r1, =gMultiHitCounter
- ldrb r0, [r1]
- subs r0, 0x1
- strb r0, [r1]
- lsls r0, 24
- cmp r0, 0
- bne _0804AFC4
- ldr r1, =gBattlescriptCurrInstr
- ldr r0, [r1]
- adds r0, 0x5
- str r0, [r1]
- b _0804AFDE
- .pool
-_0804AFC4:
- ldr r3, =gBattlescriptCurrInstr
- ldr r2, [r3]
- ldrb r1, [r2, 0x1]
- ldrb r0, [r2, 0x2]
- lsls r0, 8
- adds r1, r0
- ldrb r0, [r2, 0x3]
- lsls r0, 16
- adds r1, r0
- ldrb r0, [r2, 0x4]
- lsls r0, 24
- adds r1, r0
- str r1, [r3]
-_0804AFDE:
- pop {r0}
- bx r0
- .pool
- thumb_func_end atk27_decrement_multihit
-
- thumb_func_start atk28_goto
-atk28_goto: @ 804AFE8
- ldr r3, =gBattlescriptCurrInstr
- ldr r2, [r3]
- ldrb r1, [r2, 0x1]
- ldrb r0, [r2, 0x2]
- lsls r0, 8
- adds r1, r0
- ldrb r0, [r2, 0x3]
- lsls r0, 16
- adds r1, r0
- ldrb r0, [r2, 0x4]
- lsls r0, 24
- adds r1, r0
- str r1, [r3]
- bx lr
- .pool
- thumb_func_end atk28_goto
-
- thumb_func_start atk29_jumpifbyte
-atk29_jumpifbyte: @ 804B008
- push {r4-r6,lr}
- ldr r3, =gBattlescriptCurrInstr
- ldr r1, [r3]
- ldrb r6, [r1, 0x1]
- ldrb r2, [r1, 0x2]
- ldrb r0, [r1, 0x3]
- lsls r0, 8
- adds r2, r0
- ldrb r0, [r1, 0x4]
- lsls r0, 16
- adds r2, r0
- ldrb r0, [r1, 0x5]
- lsls r0, 24
- adds r5, r2, r0
- ldrb r4, [r1, 0x6]
- ldrb r2, [r1, 0x7]
- ldrb r0, [r1, 0x8]
- lsls r0, 8
- adds r2, r0
- ldrb r0, [r1, 0x9]
- lsls r0, 16
- adds r2, r0
- ldrb r0, [r1, 0xA]
- lsls r0, 24
- adds r2, r0
- adds r1, 0xB
- str r1, [r3]
- cmp r6, 0x5
- bhi _0804B0A0
- lsls r0, r6, 2
- ldr r1, =_0804B054
- adds r0, r1
- ldr r0, [r0]
- mov pc, r0
- .pool
- .align 2, 0
-_0804B054:
- .4byte _0804B06C
- .4byte _0804B074
- .4byte _0804B07C
- .4byte _0804B084
- .4byte _0804B08C
- .4byte _0804B096
-_0804B06C:
- ldrb r0, [r5]
- cmp r0, r4
- bne _0804B0A0
- b _0804B09E
-_0804B074:
- ldrb r0, [r5]
- cmp r0, r4
- beq _0804B0A0
- b _0804B09E
-_0804B07C:
- ldrb r0, [r5]
- cmp r0, r4
- bls _0804B0A0
- b _0804B09E
-_0804B084:
- ldrb r0, [r5]
- cmp r0, r4
- bcs _0804B0A0
- b _0804B09E
-_0804B08C:
- ldrb r0, [r5]
- ands r4, r0
- cmp r4, 0
- beq _0804B0A0
- b _0804B09E
-_0804B096:
- ldrb r0, [r5]
- ands r4, r0
- cmp r4, 0
- bne _0804B0A0
-_0804B09E:
- str r2, [r3]
-_0804B0A0:
- pop {r4-r6}
- pop {r0}
- bx r0
- thumb_func_end atk29_jumpifbyte
-
- thumb_func_start atk2A_jumpifhalfword
-atk2A_jumpifhalfword: @ 804B0A8
- push {r4-r6,lr}
- ldr r3, =gBattlescriptCurrInstr
- ldr r1, [r3]
- ldrb r6, [r1, 0x1]
- ldrb r2, [r1, 0x2]
- ldrb r0, [r1, 0x3]
- lsls r0, 8
- adds r2, r0
- ldrb r0, [r1, 0x4]
- lsls r0, 16
- adds r2, r0
- ldrb r0, [r1, 0x5]
- lsls r0, 24
- adds r5, r2, r0
- ldrb r4, [r1, 0x6]
- ldrb r0, [r1, 0x7]
- lsls r0, 8
- orrs r4, r0
- ldrb r2, [r1, 0x8]
- ldrb r0, [r1, 0x9]
- lsls r0, 8
- adds r2, r0
- ldrb r0, [r1, 0xA]
- lsls r0, 16
- adds r2, r0
- ldrb r0, [r1, 0xB]
- lsls r0, 24
- adds r2, r0
- adds r1, 0xC
- str r1, [r3]
- cmp r6, 0x5
- bhi _0804B148
- lsls r0, r6, 2
- ldr r1, =_0804B0FC
- adds r0, r1
- ldr r0, [r0]
- mov pc, r0
- .pool
- .align 2, 0
-_0804B0FC:
- .4byte _0804B114
- .4byte _0804B11C
- .4byte _0804B124
- .4byte _0804B12C
- .4byte _0804B134
- .4byte _0804B13E
-_0804B114:
- ldrh r0, [r5]
- cmp r0, r4
- bne _0804B148
- b _0804B146
-_0804B11C:
- ldrh r0, [r5]
- cmp r0, r4
- beq _0804B148
- b _0804B146
-_0804B124:
- ldrh r0, [r5]
- cmp r0, r4
- bls _0804B148
- b _0804B146
-_0804B12C:
- ldrh r0, [r5]
- cmp r0, r4
- bcs _0804B148
- b _0804B146
-_0804B134:
- ldrh r0, [r5]
- ands r4, r0
- cmp r4, 0
- beq _0804B148
- b _0804B146
-_0804B13E:
- ldrh r0, [r5]
- ands r4, r0
- cmp r4, 0
- bne _0804B148
-_0804B146:
- str r2, [r3]
-_0804B148:
- pop {r4-r6}
- pop {r0}
- bx r0
- thumb_func_end atk2A_jumpifhalfword
-
- thumb_func_start atk2B_jumpifword
-atk2B_jumpifword: @ 804B150
- push {r4-r6,lr}
- ldr r3, =gBattlescriptCurrInstr
- ldr r1, [r3]
- ldrb r6, [r1, 0x1]
- ldrb r2, [r1, 0x2]
- ldrb r0, [r1, 0x3]
- lsls r0, 8
- adds r2, r0
- ldrb r0, [r1, 0x4]
- lsls r0, 16
- adds r2, r0
- ldrb r0, [r1, 0x5]
- lsls r0, 24
- adds r5, r2, r0
- ldrb r4, [r1, 0x6]
- ldrb r0, [r1, 0x7]
- lsls r0, 8
- orrs r4, r0
- ldrb r0, [r1, 0x8]
- lsls r0, 16
- orrs r4, r0
- ldrb r0, [r1, 0x9]
- lsls r0, 24
- orrs r4, r0
- ldrb r2, [r1, 0xA]
- ldrb r0, [r1, 0xB]
- lsls r0, 8
- adds r2, r0
- ldrb r0, [r1, 0xC]
- lsls r0, 16
- adds r2, r0
- ldrb r0, [r1, 0xD]
- lsls r0, 24
- adds r2, r0
- adds r1, 0xE
- str r1, [r3]
- cmp r6, 0x5
- bhi _0804B1FC
- lsls r0, r6, 2
- ldr r1, =_0804B1B0
- adds r0, r1
- ldr r0, [r0]
- mov pc, r0
- .pool
- .align 2, 0
-_0804B1B0:
- .4byte _0804B1C8
- .4byte _0804B1D0
- .4byte _0804B1D8
- .4byte _0804B1E0
- .4byte _0804B1E8
- .4byte _0804B1F2
-_0804B1C8:
- ldr r0, [r5]
- cmp r0, r4
- bne _0804B1FC
- b _0804B1FA
-_0804B1D0:
- ldr r0, [r5]
- cmp r0, r4
- beq _0804B1FC
- b _0804B1FA
-_0804B1D8:
- ldr r0, [r5]
- cmp r0, r4
- bls _0804B1FC
- b _0804B1FA
-_0804B1E0:
- ldr r0, [r5]
- cmp r0, r4
- bcs _0804B1FC
- b _0804B1FA
-_0804B1E8:
- ldr r0, [r5]
- ands r0, r4
- cmp r0, 0
- beq _0804B1FC
- b _0804B1FA
-_0804B1F2:
- ldr r0, [r5]
- ands r0, r4
- cmp r0, 0
- bne _0804B1FC
-_0804B1FA:
- str r2, [r3]
-_0804B1FC:
- pop {r4-r6}
- pop {r0}
- bx r0
- thumb_func_end atk2B_jumpifword
-
- thumb_func_start atk2C_jumpifarrayequal
-atk2C_jumpifarrayequal: @ 804B204
- push {r4-r7,lr}
- ldr r2, =gBattlescriptCurrInstr
- ldr r3, [r2]
- ldrb r1, [r3, 0x1]
- ldrb r0, [r3, 0x2]
- lsls r0, 8
- adds r1, r0
- ldrb r0, [r3, 0x3]
- lsls r0, 16
- adds r1, r0
- ldrb r0, [r3, 0x4]
- lsls r0, 24
- adds r5, r1, r0
- ldrb r1, [r3, 0x5]
- ldrb r0, [r3, 0x6]
- lsls r0, 8
- adds r1, r0
- ldrb r0, [r3, 0x7]
- lsls r0, 16
- adds r1, r0
- ldrb r0, [r3, 0x8]
- lsls r0, 24
- adds r4, r1, r0
- ldrb r6, [r3, 0x9]
- ldrb r1, [r3, 0xA]
- ldrb r0, [r3, 0xB]
- lsls r0, 8
- adds r1, r0
- ldrb r0, [r3, 0xC]
- lsls r0, 16
- adds r1, r0
- ldrb r0, [r3, 0xD]
- lsls r0, 24
- adds r1, r0
- mov r12, r1
- movs r1, 0
- cmp r1, r6
- bcs _0804B27C
- ldrb r0, [r5]
- ldrb r7, [r4]
- cmp r0, r7
- beq _0804B260
- adds r0, r3, 0
- b _0804B278
- .pool
-_0804B260:
- adds r5, 0x1
- adds r4, 0x1
- adds r0, r1, 0x1
- lsls r0, 24
- lsrs r1, r0, 24
- cmp r1, r6
- bcs _0804B27C
- ldrb r0, [r5]
- ldrb r3, [r4]
- cmp r0, r3
- beq _0804B260
- ldr r0, [r2]
-_0804B278:
- adds r0, 0xE
- str r0, [r2]
-_0804B27C:
- cmp r1, r6
- bne _0804B284
- mov r7, r12
- str r7, [r2]
-_0804B284:
- pop {r4-r7}
- pop {r0}
- bx r0
- thumb_func_end atk2C_jumpifarrayequal
-
- thumb_func_start atk2D_jumpifarraynotequal
-atk2D_jumpifarraynotequal: @ 804B28C
- push {r4-r7,lr}
- movs r7, 0
- ldr r3, =gBattlescriptCurrInstr
- ldr r1, [r3]
- ldrb r2, [r1, 0x1]
- ldrb r0, [r1, 0x2]
- lsls r0, 8
- adds r2, r0
- ldrb r0, [r1, 0x3]
- lsls r0, 16
- adds r2, r0
- ldrb r0, [r1, 0x4]
- lsls r0, 24
- adds r5, r2, r0
- ldrb r2, [r1, 0x5]
- ldrb r0, [r1, 0x6]
- lsls r0, 8
- adds r2, r0
- ldrb r0, [r1, 0x7]
- lsls r0, 16
- adds r2, r0
- ldrb r0, [r1, 0x8]
- lsls r0, 24
- adds r4, r2, r0
- ldrb r6, [r1, 0x9]
- ldrb r2, [r1, 0xA]
- ldrb r0, [r1, 0xB]
- lsls r0, 8
- adds r2, r0
- ldrb r0, [r1, 0xC]
- lsls r0, 16
- adds r2, r0
- ldrb r0, [r1, 0xD]
- lsls r0, 24
- adds r2, r0
- mov r12, r2
- movs r1, 0
- cmp r7, r6
- bcs _0804B2F6
-_0804B2DA:
- ldrb r0, [r5]
- ldrb r2, [r4]
- cmp r0, r2
- bne _0804B2E8
- adds r0, r7, 0x1
- lsls r0, 24
- lsrs r7, r0, 24
-_0804B2E8:
- adds r5, 0x1
- adds r4, 0x1
- adds r0, r1, 0x1
- lsls r0, 24
- lsrs r1, r0, 24
- cmp r1, r6
- bcc _0804B2DA
-_0804B2F6:
- cmp r7, r6
- beq _0804B304
- mov r0, r12
- b _0804B308
- .pool
-_0804B304:
- ldr r0, [r3]
- adds r0, 0xE
-_0804B308:
- str r0, [r3]
- pop {r4-r7}
- pop {r0}
- bx r0
- thumb_func_end atk2D_jumpifarraynotequal
-
- thumb_func_start atk2E_setbyte
-atk2E_setbyte: @ 804B310
- ldr r3, =gBattlescriptCurrInstr
- ldr r2, [r3]
- ldrb r1, [r2, 0x1]
- ldrb r0, [r2, 0x2]
- lsls r0, 8
- adds r1, r0
- ldrb r0, [r2, 0x3]
- lsls r0, 16
- adds r1, r0
- ldrb r0, [r2, 0x4]
- lsls r0, 24
- adds r1, r0
- ldrb r0, [r2, 0x5]
- strb r0, [r1]
- ldr r0, [r3]
- adds r0, 0x6
- str r0, [r3]
- bx lr
- .pool
- thumb_func_end atk2E_setbyte
-
- thumb_func_start atk2F_addbyte
-atk2F_addbyte: @ 804B338
- ldr r3, =gBattlescriptCurrInstr
- ldr r2, [r3]
- ldrb r1, [r2, 0x1]
- ldrb r0, [r2, 0x2]
- lsls r0, 8
- adds r1, r0
- ldrb r0, [r2, 0x3]
- lsls r0, 16
- adds r1, r0
- ldrb r0, [r2, 0x4]
- lsls r0, 24
- adds r1, r0
- ldrb r0, [r2, 0x5]
- ldrb r2, [r1]
- adds r0, r2
- strb r0, [r1]
- ldr r0, [r3]
- adds r0, 0x6
- str r0, [r3]
- bx lr
- .pool
- thumb_func_end atk2F_addbyte
-
- thumb_func_start atk30_subbyte
-atk30_subbyte: @ 804B364
- ldr r3, =gBattlescriptCurrInstr
- ldr r2, [r3]
- ldrb r1, [r2, 0x1]
- ldrb r0, [r2, 0x2]
- lsls r0, 8
- adds r1, r0
- ldrb r0, [r2, 0x3]
- lsls r0, 16
- adds r1, r0
- ldrb r0, [r2, 0x4]
- lsls r0, 24
- adds r1, r0
- ldrb r0, [r1]
- ldrb r2, [r2, 0x5]
- subs r0, r2
- strb r0, [r1]
- ldr r0, [r3]
- adds r0, 0x6
- str r0, [r3]
- bx lr
- .pool
- thumb_func_end atk30_subbyte
-
- thumb_func_start atk31_copyarray
-atk31_copyarray: @ 804B390
- push {r4-r6,lr}
- ldr r3, =gBattlescriptCurrInstr
- ldr r1, [r3]
- ldrb r2, [r1, 0x1]
- ldrb r0, [r1, 0x2]
- lsls r0, 8
- adds r2, r0
- ldrb r0, [r1, 0x3]
- lsls r0, 16
- adds r2, r0
- ldrb r0, [r1, 0x4]
- lsls r0, 24
- adds r6, r2, r0
- ldrb r2, [r1, 0x5]
- ldrb r0, [r1, 0x6]
- lsls r0, 8
- adds r2, r0
- ldrb r0, [r1, 0x7]
- lsls r0, 16
- adds r2, r0
- ldrb r0, [r1, 0x8]
- lsls r0, 24
- adds r5, r2, r0
- ldrb r4, [r1, 0x9]
- movs r2, 0
- cmp r2, r4
- bge _0804B3D4
-_0804B3C6:
- adds r0, r6, r2
- adds r1, r5, r2
- ldrb r1, [r1]
- strb r1, [r0]
- adds r2, 0x1
- cmp r2, r4
- blt _0804B3C6
-_0804B3D4:
- ldr r0, [r3]
- adds r0, 0xA
- str r0, [r3]
- pop {r4-r6}
- pop {r0}
- bx r0
- .pool
- thumb_func_end atk31_copyarray
-
- thumb_func_start atk32_copyarray_withindex
-atk32_copyarray_withindex: @ 804B3E4
- push {r4-r7,lr}
- ldr r3, =gBattlescriptCurrInstr
- ldr r1, [r3]
- ldrb r2, [r1, 0x1]
- ldrb r0, [r1, 0x2]
- lsls r0, 8
- adds r2, r0
- ldrb r0, [r1, 0x3]
- lsls r0, 16
- adds r2, r0
- ldrb r0, [r1, 0x4]
- lsls r0, 24
- adds r7, r2, r0
- ldrb r2, [r1, 0x5]
- ldrb r0, [r1, 0x6]
- lsls r0, 8
- adds r2, r0
- ldrb r0, [r1, 0x7]
- lsls r0, 16
- adds r2, r0
- ldrb r0, [r1, 0x8]
- lsls r0, 24
- adds r6, r2, r0
- ldrb r2, [r1, 0x9]
- ldrb r0, [r1, 0xA]
- lsls r0, 8
- adds r2, r0
- ldrb r0, [r1, 0xB]
- lsls r0, 16
- adds r2, r0
- ldrb r0, [r1, 0xC]
- lsls r0, 24
- adds r5, r2, r0
- ldrb r4, [r1, 0xD]
- movs r2, 0
- cmp r2, r4
- bge _0804B440
-_0804B42E:
- adds r0, r7, r2
- ldrb r1, [r5]
- adds r1, r2, r1
- adds r1, r6, r1
- ldrb r1, [r1]
- strb r1, [r0]
- adds r2, 0x1
- cmp r2, r4
- blt _0804B42E
-_0804B440:
- ldr r0, [r3]
- adds r0, 0xE
- str r0, [r3]
- pop {r4-r7}
- pop {r0}
- bx r0
- .pool
- thumb_func_end atk32_copyarray_withindex
-
- thumb_func_start atk33_orbyte
-atk33_orbyte: @ 804B450
- ldr r3, =gBattlescriptCurrInstr
- ldr r2, [r3]
- ldrb r1, [r2, 0x1]
- ldrb r0, [r2, 0x2]
- lsls r0, 8
- adds r1, r0
- ldrb r0, [r2, 0x3]
- lsls r0, 16
- adds r1, r0
- ldrb r0, [r2, 0x4]
- lsls r0, 24
- adds r1, r0
- ldrb r0, [r1]
- ldrb r2, [r2, 0x5]
- orrs r0, r2
- strb r0, [r1]
- ldr r0, [r3]
- adds r0, 0x6
- str r0, [r3]
- bx lr
- .pool
- thumb_func_end atk33_orbyte
-
- thumb_func_start atk34_orhalfword
-atk34_orhalfword: @ 804B47C
- push {r4,lr}
- ldr r4, =gBattlescriptCurrInstr
- ldr r3, [r4]
- ldrb r2, [r3, 0x1]
- ldrb r0, [r3, 0x2]
- lsls r0, 8
- adds r2, r0
- ldrb r0, [r3, 0x3]
- lsls r0, 16
- adds r2, r0
- ldrb r0, [r3, 0x4]
- lsls r0, 24
- adds r2, r0
- ldrb r1, [r3, 0x5]
- ldrb r0, [r3, 0x6]
- lsls r0, 8
- orrs r1, r0
- ldrh r0, [r2]
- orrs r1, r0
- strh r1, [r2]
- ldr r0, [r4]
- adds r0, 0x7
- str r0, [r4]
- pop {r4}
- pop {r0}
- bx r0
- .pool
- thumb_func_end atk34_orhalfword
-
- thumb_func_start atk35_orword
-atk35_orword: @ 804B4B4
- push {r4,lr}
- ldr r4, =gBattlescriptCurrInstr
- ldr r2, [r4]
- ldrb r3, [r2, 0x1]
- ldrb r0, [r2, 0x2]
- lsls r0, 8
- adds r3, r0
- ldrb r0, [r2, 0x3]
- lsls r0, 16
- adds r3, r0
- ldrb r0, [r2, 0x4]
- lsls r0, 24
- adds r3, r0
- ldrb r1, [r2, 0x5]
- ldrb r0, [r2, 0x6]
- lsls r0, 8
- adds r1, r0
- ldrb r0, [r2, 0x7]
- lsls r0, 16
- adds r1, r0
- ldrb r0, [r2, 0x8]
- lsls r0, 24
- adds r1, r0
- ldr r0, [r3]
- orrs r0, r1
- str r0, [r3]
- ldr r0, [r4]
- adds r0, 0x9
- str r0, [r4]
- pop {r4}
- pop {r0}
- bx r0
- .pool
- thumb_func_end atk35_orword
-
- thumb_func_start atk36_bicbyte
-atk36_bicbyte: @ 804B4F8
- ldr r3, =gBattlescriptCurrInstr
- ldr r2, [r3]
- ldrb r1, [r2, 0x1]
- ldrb r0, [r2, 0x2]
- lsls r0, 8
- adds r1, r0
- ldrb r0, [r2, 0x3]
- lsls r0, 16
- adds r1, r0
- ldrb r0, [r2, 0x4]
- lsls r0, 24
- adds r1, r0
- ldrb r2, [r2, 0x5]
- ldrb r0, [r1]
- bics r0, r2
- strb r0, [r1]
- ldr r0, [r3]
- adds r0, 0x6
- str r0, [r3]
- bx lr
- .pool
- thumb_func_end atk36_bicbyte
-
- thumb_func_start atk37_bichalfword
-atk37_bichalfword: @ 804B524
- push {r4,lr}
- ldr r4, =gBattlescriptCurrInstr
- ldr r3, [r4]
- ldrb r1, [r3, 0x1]
- ldrb r0, [r3, 0x2]
- lsls r0, 8
- adds r1, r0
- ldrb r0, [r3, 0x3]
- lsls r0, 16
- adds r1, r0
- ldrb r0, [r3, 0x4]
- lsls r0, 24
- adds r1, r0
- ldrb r2, [r3, 0x5]
- ldrb r0, [r3, 0x6]
- lsls r0, 8
- orrs r2, r0
- ldrh r0, [r1]
- bics r0, r2
- strh r0, [r1]
- ldr r0, [r4]
- adds r0, 0x7
- str r0, [r4]
- pop {r4}
- pop {r0}
- bx r0
- .pool
- thumb_func_end atk37_bichalfword
-
- thumb_func_start atk38_bicword
-atk38_bicword: @ 804B55C
- push {r4,lr}
- ldr r4, =gBattlescriptCurrInstr
- ldr r2, [r4]
- ldrb r3, [r2, 0x1]
- ldrb r0, [r2, 0x2]
- lsls r0, 8
- adds r3, r0
- ldrb r0, [r2, 0x3]
- lsls r0, 16
- adds r3, r0
- ldrb r0, [r2, 0x4]
- lsls r0, 24
- adds r3, r0
- ldrb r1, [r2, 0x5]
- ldrb r0, [r2, 0x6]
- lsls r0, 8
- adds r1, r0
- ldrb r0, [r2, 0x7]
- lsls r0, 16
- adds r1, r0
- ldrb r0, [r2, 0x8]
- lsls r0, 24
- adds r1, r0
- ldr r0, [r3]
- bics r0, r1
- str r0, [r3]
- ldr r0, [r4]
- adds r0, 0x9
- str r0, [r4]
- pop {r4}
- pop {r0}
- bx r0
- .pool
- thumb_func_end atk38_bicword
-
- thumb_func_start atk39_pause
-atk39_pause: @ 804B5A0
- push {r4,r5,lr}
- ldr r0, =gBattleExecBuffer
- ldr r4, [r0]
- cmp r4, 0
- bne _0804B5CC
- ldr r5, =gBattlescriptCurrInstr
- ldr r2, [r5]
- ldrb r1, [r2, 0x1]
- ldrb r0, [r2, 0x2]
- lsls r0, 8
- orrs r1, r0
- ldr r3, =gPauseCounterBattle
- ldrh r0, [r3]
- adds r0, 0x1
- strh r0, [r3]
- lsls r0, 16
- lsrs r0, 16
- cmp r0, r1
- bcc _0804B5CC
- strh r4, [r3]
- adds r0, r2, 0x3
- str r0, [r5]
-_0804B5CC:
- pop {r4,r5}
- pop {r0}
- bx r0
- .pool
- thumb_func_end atk39_pause
-
- thumb_func_start atk3A_waitstate
-atk3A_waitstate: @ 804B5E0
- push {lr}
- ldr r0, =gBattleExecBuffer
- ldr r0, [r0]
- cmp r0, 0
- bne _0804B5F2
- ldr r1, =gBattlescriptCurrInstr
- ldr r0, [r1]
- adds r0, 0x1
- str r0, [r1]
-_0804B5F2:
- pop {r0}
- bx r0
- .pool
- thumb_func_end atk3A_waitstate
-
- thumb_func_start atk3B_healthbar_update
-atk3B_healthbar_update: @ 804B600
- push {lr}
- ldr r0, =gBattlescriptCurrInstr
- ldr r0, [r0]
- ldrb r0, [r0, 0x1]
- cmp r0, 0
- bne _0804B620
- ldr r0, =gActiveBank
- ldr r1, =gBankTarget
- b _0804B624
- .pool
-_0804B620:
- ldr r0, =gActiveBank
- ldr r1, =gBankAttacker
-_0804B624:
- ldrb r1, [r1]
- strb r1, [r0]
- ldr r0, =gBattleMoveDamage
- ldrh r1, [r0]
- movs r0, 0
- bl EmitHealthBarUpdate
- ldr r0, =gActiveBank
- ldrb r0, [r0]
- bl MarkBufferBankForExecution
- ldr r1, =gBattlescriptCurrInstr
- ldr r0, [r1]
- adds r0, 0x2
- str r0, [r1]
- pop {r0}
- bx r0
- .pool
- thumb_func_end atk3B_healthbar_update
-
- thumb_func_start atk3C_return
-atk3C_return: @ 804B658
- push {lr}
- bl b_movescr_stack_pop_cursor
- pop {r0}
- bx r0
- thumb_func_end atk3C_return
-
- thumb_func_start atk3D_end
-atk3D_end: @ 804B664
- push {lr}
- ldr r0, =gBattleTypeFlags
- ldr r0, [r0]
- movs r1, 0x80
- lsls r1, 11
- ands r0, r1
- cmp r0, 0
- beq _0804B67C
- ldr r0, =gBankAttacker
- ldrb r0, [r0]
- bl sub_81A5718
-_0804B67C:
- ldr r0, =gBattleMoveFlags
- movs r1, 0
- strb r1, [r0]
- ldr r0, =gActiveBank
- strb r1, [r0]
- ldr r1, =gFightStateTracker
- movs r0, 0xB
- strb r0, [r1]
- pop {r0}
- bx r0
- .pool
- thumb_func_end atk3D_end
-
- thumb_func_start atk3E_end2
-atk3E_end2: @ 804B6A4
- ldr r1, =gActiveBank
- movs r0, 0
- strb r0, [r1]
- ldr r1, =gFightStateTracker
- movs r0, 0xB
- strb r0, [r1]
- bx lr
- .pool
- thumb_func_end atk3E_end2
-
- thumb_func_start atk3F_end3
-atk3F_end3: @ 804B6BC
- push {lr}
- bl b_movescr_stack_pop_cursor
- ldr r3, =gBattleResources
- ldr r0, [r3]
- ldr r0, [r0, 0xC]
- adds r1, r0, 0
- adds r1, 0x20
- ldrb r0, [r1]
- cmp r0, 0
- beq _0804B6D6
- subs r0, 0x1
- strb r0, [r1]
-_0804B6D6:
- ldr r2, =gBattleMainFunc
- ldr r0, [r3]
- ldr r1, [r0, 0xC]
- adds r0, r1, 0
- adds r0, 0x20
- ldrb r0, [r0]
- lsls r0, 2
- adds r1, r0
- ldr r0, [r1]
- str r0, [r2]
- pop {r0}
- bx r0
- .pool
- thumb_func_end atk3F_end3
-
- thumb_func_start atk41_call
-atk41_call: @ 804B6F8
- push {r4,lr}
- ldr r4, =gBattlescriptCurrInstr
- ldr r0, [r4]
- adds r0, 0x5
- bl b_movescr_stack_push
- ldr r2, [r4]
- ldrb r1, [r2, 0x1]
- ldrb r0, [r2, 0x2]
- lsls r0, 8
- orrs r1, r0
- ldrb r0, [r2, 0x3]
- lsls r0, 16
- orrs r1, r0
- ldrb r0, [r2, 0x4]
- lsls r0, 24
- orrs r1, r0
- str r1, [r4]
- pop {r4}
- pop {r0}
- bx r0
- .pool
- thumb_func_end atk41_call
-
- thumb_func_start atk42_jumpiftype2
-atk42_jumpiftype2: @ 804B728
- push {r4,lr}
- ldr r4, =gBattlescriptCurrInstr
- ldr r0, [r4]
- ldrb r0, [r0, 0x1]
- bl GetBattleBank
- lsls r0, 24
- lsrs r0, 24
- ldr r3, [r4]
- ldr r2, =gBattleMons
- movs r1, 0x58
- muls r0, r1
- adds r0, r2
- adds r1, r0, 0
- adds r1, 0x21
- ldrb r2, [r3, 0x2]
- ldrb r1, [r1]
- cmp r2, r1
- beq _0804B756
- adds r0, 0x22
- ldrb r0, [r0]
- cmp r2, r0
- bne _0804B778
-_0804B756:
- ldrb r1, [r3, 0x3]
- ldrb r0, [r3, 0x4]
- lsls r0, 8
- orrs r1, r0
- ldrb r0, [r3, 0x5]
- lsls r0, 16
- orrs r1, r0
- ldrb r0, [r3, 0x6]
- lsls r0, 24
- orrs r1, r0
- str r1, [r4]
- b _0804B77C
- .pool
-_0804B778:
- adds r0, r3, 0x7
- str r0, [r4]
-_0804B77C:
- pop {r4}
- pop {r0}
- bx r0
- thumb_func_end atk42_jumpiftype2
-
- thumb_func_start atk43_jumpifabilitypresent
-atk43_jumpifabilitypresent: @ 804B784
- push {r4,lr}
- sub sp, 0x4
- ldr r4, =gBattlescriptCurrInstr
- ldr r0, [r4]
- ldrb r2, [r0, 0x1]
- movs r0, 0
- str r0, [sp]
- movs r0, 0x13
- movs r1, 0
- movs r3, 0
- bl AbilityBattleEffects
- lsls r0, 24
- cmp r0, 0
- beq _0804B7C0
- ldr r2, [r4]
- ldrb r1, [r2, 0x2]
- ldrb r0, [r2, 0x3]
- lsls r0, 8
- orrs r1, r0
- ldrb r0, [r2, 0x4]
- lsls r0, 16
- orrs r1, r0
- ldrb r0, [r2, 0x5]
- lsls r0, 24
- orrs r1, r0
- str r1, [r4]
- b _0804B7C6
- .pool
-_0804B7C0:
- ldr r0, [r4]
- adds r0, 0x6
- str r0, [r4]
-_0804B7C6:
- add sp, 0x4
- pop {r4}
- pop {r0}
- bx r0
- thumb_func_end atk43_jumpifabilitypresent
-
- thumb_func_start atk44
-atk44: @ 804B7D0
- ldr r0, =gBankAttacker
- ldrb r0, [r0]
- ldr r1, =gBattleStruct
- ldr r1, [r1]
- adds r0, r1
- adds r0, 0x54
- movs r1, 0x1
- strb r1, [r0]
- bx lr
- .pool
- thumb_func_end atk44
-
- thumb_func_start atk45_playanimation
-atk45_playanimation: @ 804B7EC
- push {r4-r6,lr}
- ldr r5, =gBattlescriptCurrInstr
- ldr r0, [r5]
- ldrb r0, [r0, 0x1]
- bl GetBattleBank
- ldr r6, =gActiveBank
- strb r0, [r6]
- ldr r2, [r5]
- ldrb r1, [r2, 0x3]
- ldrb r0, [r2, 0x4]
- lsls r0, 8
- adds r1, r0
- ldrb r0, [r2, 0x5]
- lsls r0, 16
- adds r1, r0
- ldrb r0, [r2, 0x6]
- lsls r0, 24
- adds r3, r1, r0
- ldrb r4, [r2, 0x2]
- adds r0, r4, 0
- cmp r0, 0x1
- beq _0804B822
- cmp r0, 0x11
- beq _0804B822
- cmp r0, 0x2
- bne _0804B848
-_0804B822:
- ldr r4, =gBattlescriptCurrInstr
- ldr r0, [r4]
- ldrb r1, [r0, 0x2]
- ldrh r2, [r3]
- movs r0, 0
- bl dp01_build_cmdbuf_x34_a_bb_aka_battle_anim
- ldr r0, =gActiveBank
- ldrb r0, [r0]
- bl MarkBufferBankForExecution
- ldr r0, [r4]
- adds r0, 0x7
- str r0, [r4]
- b _0804B8AA
- .pool
-_0804B848:
- ldr r0, =gHitMarker
- ldr r0, [r0]
- movs r1, 0x80
- ands r0, r1
- cmp r0, 0
- beq _0804B868
- adds r0, r2, 0x7
- bl b_movescr_stack_push
- ldr r0, =BattleScript_Pausex20
- b _0804B8A8
- .pool
-_0804B868:
- adds r0, r4, 0
- subs r0, 0xA
- lsls r0, 24
- lsrs r0, 24
- cmp r0, 0x3
- bls _0804B894
- ldr r1, =gStatuses3
- ldrb r0, [r6]
- lsls r0, 2
- adds r0, r1
- ldr r0, [r0]
- ldr r1, =0x000400c0
- ands r0, r1
- cmp r0, 0
- beq _0804B894
- adds r0, r2, 0x7
- b _0804B8A8
- .pool
-_0804B894:
- ldrb r1, [r2, 0x2]
- ldrh r2, [r3]
- movs r0, 0
- bl dp01_build_cmdbuf_x34_a_bb_aka_battle_anim
- ldrb r0, [r6]
- bl MarkBufferBankForExecution
- ldr r0, [r5]
- adds r0, 0x7
-_0804B8A8:
- str r0, [r5]
-_0804B8AA:
- pop {r4-r6}
- pop {r0}
- bx r0
- thumb_func_end atk45_playanimation
-
- thumb_func_start atk46_playanimation2
-atk46_playanimation2: @ 804B8B0
- push {r4-r7,lr}
- ldr r6, =gBattlescriptCurrInstr
- ldr r0, [r6]
- ldrb r0, [r0, 0x1]
- bl GetBattleBank
- ldr r7, =gActiveBank
- strb r0, [r7]
- ldr r2, [r6]
- ldrb r1, [r2, 0x2]
- ldrb r0, [r2, 0x3]
- lsls r0, 8
- adds r1, r0
- ldrb r0, [r2, 0x4]
- lsls r0, 16
- adds r1, r0
- ldrb r0, [r2, 0x5]
- lsls r0, 24
- adds r3, r1, r0
- ldrb r1, [r2, 0x6]
- ldrb r0, [r2, 0x7]
- lsls r0, 8
- adds r1, r0
- ldrb r0, [r2, 0x8]
- lsls r0, 16
- adds r1, r0
- ldrb r0, [r2, 0x9]
- lsls r0, 24
- adds r4, r1, r0
- ldrb r5, [r3]
- adds r0, r5, 0
- cmp r0, 0x1
- beq _0804B8FA
- cmp r0, 0x11
- beq _0804B8FA
- cmp r0, 0x2
- bne _0804B920
-_0804B8FA:
- ldrb r1, [r3]
- ldrh r2, [r4]
- movs r0, 0
- bl dp01_build_cmdbuf_x34_a_bb_aka_battle_anim
- ldr r0, =gActiveBank
- ldrb r0, [r0]
- bl MarkBufferBankForExecution
- ldr r1, =gBattlescriptCurrInstr
- ldr r0, [r1]
- adds r0, 0xA
- str r0, [r1]
- b _0804B976
- .pool
-_0804B920:
- ldr r0, =gHitMarker
- ldr r0, [r0]
- movs r1, 0x80
- ands r0, r1
- cmp r0, 0
- beq _0804B934
- adds r0, r2, 0
- b _0804B972
- .pool
-_0804B934:
- adds r0, r5, 0
- subs r0, 0xA
- lsls r0, 24
- lsrs r0, 24
- cmp r0, 0x3
- bls _0804B960
- ldr r1, =gStatuses3
- ldrb r0, [r7]
- lsls r0, 2
- adds r0, r1
- ldr r0, [r0]
- ldr r1, =0x000400c0
- ands r0, r1
- cmp r0, 0
- beq _0804B960
- adds r0, r2, 0
- b _0804B972
- .pool
-_0804B960:
- ldrb r1, [r3]
- ldrh r2, [r4]
- movs r0, 0
- bl dp01_build_cmdbuf_x34_a_bb_aka_battle_anim
- ldrb r0, [r7]
- bl MarkBufferBankForExecution
- ldr r0, [r6]
-_0804B972:
- adds r0, 0xA
- str r0, [r6]
-_0804B976:
- pop {r4-r7}
- pop {r0}
- bx r0
- thumb_func_end atk46_playanimation2
-
- thumb_func_start atk47_setgraphicalstatchangevalues
-atk47_setgraphicalstatchangevalues: @ 804B97C
- push {r4,lr}
- movs r3, 0
- ldr r1, =gBattleScripting
- ldrb r0, [r1, 0x1A]
- movs r2, 0xF0
- ands r2, r0
- adds r4, r1, 0
- cmp r2, 0x20
- beq _0804B9AA
- cmp r2, 0x20
- bgt _0804B99C
- cmp r2, 0x10
- beq _0804B9A6
- b _0804B9B4
- .pool
-_0804B99C:
- cmp r2, 0x90
- beq _0804B9AE
- cmp r2, 0xA0
- beq _0804B9B2
- b _0804B9B4
-_0804B9A6:
- movs r3, 0xF
- b _0804B9B4
-_0804B9AA:
- movs r3, 0x27
- b _0804B9B4
-_0804B9AE:
- movs r3, 0x16
- b _0804B9B4
-_0804B9B2:
- movs r3, 0x2E
-_0804B9B4:
- ldrb r1, [r4, 0x1A]
- movs r0, 0xF
- ands r0, r1
- adds r0, r3, r0
- subs r0, 0x1
- movs r1, 0
- strb r0, [r4, 0x10]
- strb r1, [r4, 0x11]
- ldr r1, =gBattlescriptCurrInstr
- ldr r0, [r1]
- adds r0, 0x1
- str r0, [r1]
- pop {r4}
- pop {r0}
- bx r0
- .pool
- thumb_func_end atk47_setgraphicalstatchangevalues
-
thumb_func_start atk48_playstatchangeanimation
atk48_playstatchangeanimation: @ 804B9D8
push {r4-r7,lr}
@@ -6061,7 +219,7 @@ _0804BB6C:
movs r1, 0x1
mov r2, r8
str r3, [sp]
- bl dp01_build_cmdbuf_x34_a_bb_aka_battle_anim
+ bl EmitBattleAnimation
ldr r0, =gActiveBank
ldrb r0, [r0]
bl MarkBufferBankForExecution
@@ -6198,7 +356,7 @@ _0804BCAC:
str r0, [r5]
ldr r0, =gBattleScripting
strb r4, [r0, 0x14]
- bl sub_804AF30
+ bl MoveValuesCleanUp
ldr r2, =gUnknown_082D86A8
mov r0, r8
ldrh r1, [r0]
@@ -6210,7 +368,7 @@ _0804BCAC:
lsls r0, 2
adds r0, r2
ldr r0, [r0]
- bl b_movescr_stack_push
+ bl BattleScriptPush
ldr r1, =gBattlescriptCurrInstr
ldr r0, =gUnknown_082DB87D
bl _0804C5B8
@@ -6360,7 +518,7 @@ _0804BE14:
_0804BE26:
adds r0, r2, 0x1
strb r0, [r1, 0x19]
- bl b_movescr_stack_push_cursor
+ bl BattleScriptPushCursor
ldr r1, =gBattlescriptCurrInstr
ldr r0, =gUnknown_082DAE0D
str r0, [r1]
@@ -6440,7 +598,7 @@ _0804BEBA:
bl EmitSetAttributes
ldrb r0, [r4]
bl MarkBufferBankForExecution
- bl b_movescr_stack_push_cursor
+ bl BattleScriptPushCursor
ldr r1, =gBattlescriptCurrInstr
ldr r0, =gUnknown_082DB282
str r0, [r1]
@@ -9718,7 +3876,7 @@ _0804DBC8:
ldr r0, =gBattleScripting
ldrb r1, [r4]
strb r1, [r0, 0x17]
- bl b_movescr_stack_push_cursor
+ bl BattleScriptPushCursor
mov r7, r9
ldr r0, [r7]
ldrb r0, [r0, 0x1]
@@ -15079,7 +9237,7 @@ _08050AA8:
.pool
_08050B10:
mov r0, r8
- bl b_movescr_stack_push
+ bl BattleScriptPush
ldr r1, =gBattleScripting
ldr r6, =gActiveBank
ldrb r0, [r6]
@@ -15159,7 +9317,7 @@ _08050B94:
.pool
_08050BD4:
mov r0, r8
- bl b_movescr_stack_push
+ bl BattleScriptPush
ldr r1, =gBattleScripting
ldr r2, =gActiveBank
ldrb r0, [r2]
@@ -15208,7 +9366,7 @@ _08050C2C:
cmp r5, 0x1
bne _08050B68
mov r0, r8
- bl b_movescr_stack_push
+ bl BattleScriptPush
ldr r1, =gBattleScripting
ldr r3, =gActiveBank
ldrb r0, [r3]
@@ -15248,7 +9406,7 @@ _08050C8C:
b _08050B68
_08050CAE:
mov r0, r8
- bl b_movescr_stack_push
+ bl BattleScriptPush
ldr r1, =gBattleScripting
ldr r2, =gActiveBank
ldrb r0, [r2]
@@ -16403,7 +10561,7 @@ atk91_givepaydaymoney: @ 80515C8
ldr r4, =gBattlescriptCurrInstr
ldr r0, [r4]
adds r0, 0x1
- bl b_movescr_stack_push
+ bl BattleScriptPush
ldr r0, =gUnknown_082DB307
str r0, [r4]
b _08051658
@@ -21438,7 +15596,7 @@ atkBE_breakfree: @ 805417C
strb r0, [r1, 0x3]
movs r0, 0xFF
strb r0, [r1, 0x4]
- bl b_movescr_stack_push_cursor
+ bl BattleScriptPushCursor
ldr r1, =gBattlescriptCurrInstr
ldr r0, =gUnknown_082DAFC5
b _080542BA
@@ -21464,7 +15622,7 @@ _08054210:
negs r2, r2
ands r0, r2
str r0, [r1]
- bl b_movescr_stack_push_cursor
+ bl BattleScriptPushCursor
ldr r1, =gBattlescriptCurrInstr
ldr r0, =gUnknown_082DAFD6
b _080542BA
@@ -21501,7 +15659,7 @@ _08054250:
lsls r1, 2
adds r1, r2
strb r4, [r1, 0xA]
- bl b_movescr_stack_push_cursor
+ bl BattleScriptPushCursor
ldr r1, =gBattlescriptCurrInstr
ldr r0, =gUnknown_082DAFDD
b _080542BA
@@ -22608,7 +16766,7 @@ atkCC_callterrainattack: @ 8054BEC
lsls r0, 2
adds r0, r3
ldr r0, [r0]
- bl b_movescr_stack_push
+ bl BattleScriptPush
ldr r1, =gBattlescriptCurrInstr
ldr r0, [r1]
adds r0, 0x1
@@ -23039,7 +17197,7 @@ _08054FDC:
cmp r0, 0x3C
bne _08055010
ldr r1, =gBattlescriptCurrInstr
- ldr r0, =gUnknown_082DB63F
+ ldr r0, =BattleScript_StickyHoldOnKnockOff
str r0, [r1]
ldr r1, =gLastUsedAbility
ldrb r0, [r7]
@@ -24725,7 +18883,7 @@ _08055E2C:
ldrb r2, [r0]
movs r0, 0
movs r1, 0
- bl dp01_build_cmdbuf_x34_a_bb_aka_battle_anim
+ bl EmitBattleAnimation
ldrb r0, [r4]
bl MarkBufferBankForExecution
ldr r1, =gBattlescriptCurrInstr
diff --git a/asm/battle_5.s b/asm/battle_5.s
index 3db603531..9c35a8913 100644
--- a/asm/battle_5.s
+++ b/asm/battle_5.s
@@ -183,8 +183,8 @@ _080570D0:
.pool
thumb_func_end sub_8057028
- thumb_func_start sub_80570F4
-sub_80570F4: @ 80570F4
+ thumb_func_start AdjustFriendshipOnBattleFaint
+AdjustFriendshipOnBattleFaint: @ 80570F4
push {r4,r5,lr}
lsls r0, 24
lsrs r5, r0, 24
@@ -285,7 +285,7 @@ _080571CE:
pop {r0}
bx r0
.pool
- thumb_func_end sub_80570F4
+ thumb_func_end AdjustFriendshipOnBattleFaint
thumb_func_start sub_80571DC
sub_80571DC: @ 80571DC
@@ -414,7 +414,7 @@ _0805729A:
ldr r1, =0xf7ffffff
ands r0, r1
str r0, [r2]
- bl b_movescr_stack_push_cursor
+ bl BattleScriptPushCursor
movs r0, 0x1
mov r2, r10
strb r0, [r2, 0x5]
@@ -474,7 +474,7 @@ _08057354:
ldr r1, =0xf7ffffff
ands r0, r1
str r0, [r2]
- bl b_movescr_stack_push_cursor
+ bl BattleScriptPushCursor
ldr r0, =gBattleCommunication
strb r4, [r0, 0x5]
ldr r1, =gBattlescriptCurrInstr
@@ -523,7 +523,7 @@ _080573D4:
negs r1, r1
ands r0, r1
str r0, [r4]
- bl b_movescr_stack_push_cursor
+ bl BattleScriptPushCursor
ldr r1, =gBattlescriptCurrInstr
ldr r0, =BattleScript_MoveUsedUnfroze
str r0, [r1]
diff --git a/asm/battle_7.s b/asm/battle_7.s
index fd8c3b4a5..10fabc389 100644
--- a/asm/battle_7.s
+++ b/asm/battle_7.s
@@ -2937,8 +2937,8 @@ _0805EA5A:
bx r0
thumb_func_end sub_805E990
- thumb_func_start sub_805EA60
-sub_805EA60: @ 805EA60
+ thumb_func_start BattleMusicStop
+BattleMusicStop: @ 805EA60
push {r4-r6,lr}
movs r0, 0
bl GetBankByPlayerAI
@@ -2977,7 +2977,7 @@ _0805EAA2:
pop {r0}
bx r0
.pool
- thumb_func_end sub_805EA60
+ thumb_func_end BattleMusicStop
thumb_func_start sub_805EAB4
sub_805EAB4: @ 805EAB4
diff --git a/asm/battle_controller_linkopponent.s b/asm/battle_controller_linkopponent.s
index d28823a8b..e8975a7aa 100644
--- a/asm/battle_controller_linkopponent.s
+++ b/asm/battle_controller_linkopponent.s
@@ -5565,7 +5565,7 @@ sub_806743C: @ 806743C
ldrb r0, [r0]
cmp r0, 0
beq _08067478
- bl sub_805EA60
+ bl BattleMusicStop
ldrb r1, [r5]
lsls r1, 9
adds r0, r4, 0x1
diff --git a/asm/battle_controller_linkpartner.s b/asm/battle_controller_linkpartner.s
index 881228279..e02a967d0 100644
--- a/asm/battle_controller_linkpartner.s
+++ b/asm/battle_controller_linkpartner.s
@@ -4874,7 +4874,7 @@ sub_814D9D8: @ 814D9D8
ldrb r0, [r0]
cmp r0, 0
beq _0814DA14
- bl sub_805EA60
+ bl BattleMusicStop
ldrb r1, [r5]
lsls r1, 9
adds r0, r4, 0x1
diff --git a/asm/battle_controller_opponent.s b/asm/battle_controller_opponent.s
index 639ef0ce6..1bfa3ff12 100644
--- a/asm/battle_controller_opponent.s
+++ b/asm/battle_controller_opponent.s
@@ -6015,7 +6015,7 @@ sub_8062630: @ 8062630
ldrb r0, [r0]
cmp r0, 0
beq _0806266C
- bl sub_805EA60
+ bl BattleMusicStop
ldrb r1, [r5]
lsls r1, 9
adds r0, r4, 0x1
diff --git a/asm/battle_controller_player.s b/asm/battle_controller_player.s
index 0e9318dc9..d9d5c5e6a 100644
--- a/asm/battle_controller_player.s
+++ b/asm/battle_controller_player.s
@@ -8913,7 +8913,7 @@ _0805C3BC:
sub_805C3EC: @ 805C3EC
push {lr}
sub sp, 0x4
- bl sub_805EA60
+ bl BattleMusicStop
movs r0, 0x1
negs r0, r0
movs r1, 0
@@ -9595,7 +9595,7 @@ sub_805C9B0: @ 805C9B0
ldrb r0, [r0]
cmp r0, 0
beq _0805C9EC
- bl sub_805EA60
+ bl BattleMusicStop
ldrb r1, [r5]
lsls r1, 9
adds r0, r4, 0x1
diff --git a/asm/battle_controller_player_partner.s b/asm/battle_controller_player_partner.s
index 6b5a14f95..f77dc2c33 100644
--- a/asm/battle_controller_player_partner.s
+++ b/asm/battle_controller_player_partner.s
@@ -5661,7 +5661,7 @@ sub_81BE03C: @ 81BE03C
ldrb r0, [r0]
cmp r0, 0
beq _081BE078
- bl sub_805EA60
+ bl BattleMusicStop
ldrb r1, [r5]
lsls r1, 9
adds r0, r4, 0x1
diff --git a/asm/battle_controller_recorded_opponent.s b/asm/battle_controller_recorded_opponent.s
index dc7fe7de5..6f047a4ef 100644
--- a/asm/battle_controller_recorded_opponent.s
+++ b/asm/battle_controller_recorded_opponent.s
@@ -5304,7 +5304,7 @@ sub_818936C: @ 818936C
ldrb r0, [r0]
cmp r0, 0
beq _081893A8
- bl sub_805EA60
+ bl BattleMusicStop
ldrb r1, [r5]
lsls r1, 9
adds r0, r4, 0x1
diff --git a/asm/battle_controller_recorded_player.s b/asm/battle_controller_recorded_player.s
index b2769671c..7b0cd6d41 100644
--- a/asm/battle_controller_recorded_player.s
+++ b/asm/battle_controller_recorded_player.s
@@ -5455,7 +5455,7 @@ sub_818C994: @ 818C994
ldrb r0, [r0]
cmp r0, 0
beq _0818C9D0
- bl sub_805EA60
+ bl BattleMusicStop
ldrb r1, [r5]
lsls r1, 9
adds r0, r4, 0x1
diff --git a/asm/battle_controller_safari.s b/asm/battle_controller_safari.s
index 1aff72176..13111e08d 100644
--- a/asm/battle_controller_safari.s
+++ b/asm/battle_controller_safari.s
@@ -1161,7 +1161,7 @@ dp01t_34_6_move_anim_start_t3: @ 8159CC4
ldrb r0, [r0]
cmp r0, 0
beq _08159D00
- bl sub_805EA60
+ bl BattleMusicStop
ldrb r1, [r5]
lsls r1, 9
adds r0, r4, 0x1
diff --git a/asm/battle_controller_wally.s b/asm/battle_controller_wally.s
index ddb97f927..6f59c4104 100644
--- a/asm/battle_controller_wally.s
+++ b/asm/battle_controller_wally.s
@@ -4150,7 +4150,7 @@ sub_816A840: @ 816A840
ldrb r0, [r0]
cmp r0, 0
beq _0816A87C
- bl sub_805EA60
+ bl BattleMusicStop
ldrb r1, [r5]
lsls r1, 9
adds r0, r4, 0x1
diff --git a/asm/rom3.s b/asm/rom3.s
index f6b6f2d03..84dec85e5 100644
--- a/asm/rom3.s
+++ b/asm/rom3.s
@@ -2355,8 +2355,8 @@ dp01_build_cmdbuf_x09_9_9_9: @ 8033A24
.pool
thumb_func_end dp01_build_cmdbuf_x09_9_9_9
- thumb_func_start dp01_build_cmdbuf_x0A_A_A_A
-dp01_build_cmdbuf_x0A_A_A_A: @ 8033A44
+ thumb_func_start EmitFaintAnimation
+EmitFaintAnimation: @ 8033A44
push {lr}
lsls r0, 24
lsrs r0, 24
@@ -2371,7 +2371,7 @@ dp01_build_cmdbuf_x0A_A_A_A: @ 8033A44
pop {r0}
bx r0
.pool
- thumb_func_end dp01_build_cmdbuf_x0A_A_A_A
+ thumb_func_end EmitFaintAnimation
thumb_func_start dp01_build_cmdbuf_x0B_B_B_B
dp01_build_cmdbuf_x0B_B_B_B: @ 8033A64
@@ -2967,8 +2967,8 @@ EmitHealthBarUpdate: @ 8033EFC
.pool
thumb_func_end EmitHealthBarUpdate
- thumb_func_start dp01_build_cmdbuf_x19_a_bb
-dp01_build_cmdbuf_x19_a_bb: @ 8033F34
+ thumb_func_start EmitExpUpdate
+EmitExpUpdate: @ 8033F34
push {r4,lr}
adds r4, r1, 0
lsls r0, 24
@@ -2993,7 +2993,7 @@ dp01_build_cmdbuf_x19_a_bb: @ 8033F34
pop {r0}
bx r0
.pool
- thumb_func_end dp01_build_cmdbuf_x19_a_bb
+ thumb_func_end EmitExpUpdate
thumb_func_start dp01_build_cmdbuf_x1A_aaaa_bbbb
dp01_build_cmdbuf_x1A_aaaa_bbbb: @ 8033F68
@@ -3661,8 +3661,8 @@ dp01_build_cmdbuf_x33_a_33_33: @ 8034414
.pool
thumb_func_end dp01_build_cmdbuf_x33_a_33_33
- thumb_func_start dp01_build_cmdbuf_x34_a_bb_aka_battle_anim
-dp01_build_cmdbuf_x34_a_bb_aka_battle_anim: @ 8034438
+ thumb_func_start EmitBattleAnimation
+EmitBattleAnimation: @ 8034438
push {r4,lr}
adds r4, r1, 0
lsls r0, 24
@@ -3682,7 +3682,7 @@ dp01_build_cmdbuf_x34_a_bb_aka_battle_anim: @ 8034438
pop {r0}
bx r0
.pool
- thumb_func_end dp01_build_cmdbuf_x34_a_bb_aka_battle_anim
+ thumb_func_end EmitBattleAnimation
thumb_func_start sub_8034464
sub_8034464: @ 8034464
diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s
index 7a013c51c..0d94d31b0 100644
--- a/data/battle_scripts_1.s
+++ b/data/battle_scripts_1.s
@@ -33,10 +33,10 @@ gUnknown_082D9EFB:: @ 82D9EFB
gUnknown_082D9F1C:: @ 82D9F1C
.incbin "baserom.gba", 0x2d9f1c, 0x88e
-gUnknown_082DA7AA:: @ 82DA7AA
+BattleScript_FaintAttacker:: @ 82DA7AA
.incbin "baserom.gba", 0x2da7aa, 0xd
-gUnknown_082DA7B7:: @ 82DA7B7
+BattleScript_FaintTarget:: @ 82DA7B7
.incbin "baserom.gba", 0x2da7b7, 0xd
gUnknown_082DA7C4:: @ 82DA7C4
@@ -93,7 +93,7 @@ gUnknown_082DAB15:: @ 82DAB15
BattleScript_Pausex20:: @ 82DABB9
.incbin "baserom.gba", 0x2dabb9, 0x4
-gUnknown_082DABBD:: @ 82DABBD
+BattleScript_LevelUp:: @ 82DABBD
.incbin "baserom.gba", 0x2dabbd, 0x6f
gUnknown_082DAC2C:: @ 82DAC2C
@@ -156,7 +156,7 @@ gUnknown_082DAE2A:: @ 82DAE2A
BattleScript_EncoredNoMore:: @ 82DAE37
.incbin "baserom.gba", 0x2dae37, 0x7
-gUnknown_082DAE3E:: @ 82DAE3E
+BattleScript_DestinyBondTakesLife:: @ 82DAE3E
.incbin "baserom.gba", 0x2dae3e, 0x1b
gUnknown_082DAE59:: @ 82DAE59
@@ -237,7 +237,7 @@ gUnknown_082DB181:: @ 82DB181
gUnknown_082DB185:: @ 82DB185
.incbin "baserom.gba", 0x2db185, 0x8
-gUnknown_082DB18D:: @ 82DB18D
+BattleScript_GrudgeTakesPp:: @ 82DB18D
.incbin "baserom.gba", 0x2db18d, 0x7
BattleScript_MagicCoatBounce:: @ 82DB194
@@ -411,7 +411,7 @@ BattleScript_SoundproofProtected:: @ 82DB61F
gUnknown_082DB62F:: @ 82DB62F
.incbin "baserom.gba", 0x2db62f, 0x10
-gUnknown_082DB63F:: @ 82DB63F
+BattleScript_StickyHoldOnKnockOff:: @ 82DB63F
.incbin "baserom.gba", 0x2db63f, 0xe
BattleScript_ColorChangeActivates:: @ 82DB64D
diff --git a/include/battle.h b/include/battle.h
index 56b74aa62..920a60060 100644
--- a/include/battle.h
+++ b/include/battle.h
@@ -218,13 +218,23 @@
#define TYPE_MUL_NORMAL 10
#define TYPE_MUL_SUPER_EFFECTIVE 20
-#define BS_GET_TARGET 0
-#define BS_GET_ATTACKER 1
-#define BS_GET_EFFECT_BANK 2
-#define BS_GET_SCRIPTING_BANK 10
-#define BS_GET_OPPONENT1 12
-#define BS_GET_PLAYER2 13
-#define BS_GET_OPPONENT2 14
+#define BS_GET_TARGET 0
+#define BS_GET_ATTACKER 1
+#define BS_GET_EFFECT_BANK 2
+#define BS_GET_ATTACKER_SIDE 8 // for atk1E_jumpifability
+#define BS_GET_NOT_ATTACKER_SIDE 9 // for atk1E_jumpifability
+#define BS_GET_SCRIPTING_BANK 10
+#define BS_GET_OPPONENT1 12
+#define BS_GET_PLAYER2 13
+#define BS_GET_OPPONENT2 14
+
+// for battle script commands
+#define CMP_EQUAL 0x0
+#define CMP_NOT_EQUAL 0x1
+#define CMP_GREATER_THAN 0x2
+#define CMP_LESS_THAN 0x3
+#define CMP_COMMON_BITS 0x4
+#define CMP_NO_COMMON_BITS 0x5
struct Trainer
{
@@ -422,13 +432,23 @@ struct BattleCallbacksStack
u8 size;
};
+struct StatsArray
+{
+ u16 hp;
+ u16 atk;
+ u16 def;
+ u16 spd;
+ u16 spAtk;
+ u16 spDef;
+};
+
struct BattleResources
{
struct SecretBaseRecord* secretBase;
struct UnknownFlags *flags;
struct BattleScriptsStack* battleScriptsStack;
struct BattleCallbacksStack* battleCallbackStack;
- void* statsBeforeLvlUp;
+ struct StatsArray* statsBeforeLvlUp;
struct AI_ThinkingStruct *ai;
struct BattleHistory *battleHistory;
struct BattleScriptsStack *AI_ScriptsStack;
@@ -438,6 +458,7 @@ extern struct BattleResources* gBattleResources;
#define BATTLESCRIPTS_STACK (gBattleResources->battleScriptsStack)
#define BATTLE_CALLBACKS_STACK (gBattleResources->battleCallbackStack)
+#define BATTLE_LVLUP_STATS (gBattleResources->statsBeforeLvlUp)
struct BattleResults
{
@@ -536,14 +557,10 @@ struct BattleStruct
u8 field_4D;
u8 field_4E;
u8 field_4F;
- u8 field_50;
- u8 field_51;
+ u16 expValue;
u8 field_52;
- u8 field_53;
- u8 field_54;
- u8 field_55;
- u8 field_56;
- u8 field_57;
+ u8 sentInPokes;
+ u8 field_54[4];
u8 field_58;
u8 field_59;
u8 field_5A;
@@ -642,6 +659,11 @@ struct BattleStruct
u8 field_1A1;
u8 filler1A2;
u8 atkCancellerTracker;
+ u8 field_1A4[240];
+ u8 field_294[4];
+ u8 field_298[8];
+ u8 field_2A0;
+ u8 field_2A1;
};
extern struct BattleStruct* gBattleStruct;
@@ -677,6 +699,20 @@ extern struct BattleStruct* gBattleStruct;
#define MOVE_EFFECT_CHARGING 0xC
#define MOVE_EFFECT_WRAP 0xD
#define MOVE_EFFECT_RECOIL_25 0xE
+#define MOVE_EFFECT_ATK_PLUS_1 0xF
+#define MOVE_EFFECT_DEF_PLUS_1 0x10
+#define MOVE_EFFECT_SPD_PLUS_1 0x11
+#define MOVE_EFFECT_SP_ATK_PLUS_1 0x12
+#define MOVE_EFFECT_SP_DEF_PLUS_1 0x13
+#define MOVE_EFFECT_ACC_PLUS_1 0x14
+#define MOVE_EFFECT_EVS_PLUS_1 0x15
+#define MOVE_EFFECT_ATK_MINUS_1 0x16
+#define MOVE_EFFECT_DEF_MINUS_1 0x17
+#define MOVE_EFFECT_SPD_MINUS_1 0x18
+#define MOVE_EFFECT_SP_ATK_MINUS_1 0x19
+#define MOVE_EFFECT_SP_DEF_MINUS_1 0x1A
+#define MOVE_EFFECT_ACC_MINUS_1 0x1B
+#define MOVE_EFFECT_EVS_MINUS_1 0x1C
#define MOVE_EFFECT_RECHARGE 0x1D
#define MOVE_EFFECT_RAGE 0x1E
#define MOVE_EFFECT_STEAL_ITEM 0x1F
@@ -687,10 +723,73 @@ extern struct BattleStruct* gBattleStruct;
#define MOVE_EFFECT_REMOVE_PARALYSIS 0x24
#define MOVE_EFFECT_ATK_DEF_DOWN 0x25
#define MOVE_EFFECT_RECOIL_33_PARALYSIS 0x26
+#define MOVE_EFFECT_ATK_PLUS_2 0x27
+#define MOVE_EFFECT_DEF_PLUS_2 0x28
+#define MOVE_EFFECT_SPD_PLUS_2 0x29
+#define MOVE_EFFECT_SP_ATK_PLUS_2 0x2A
+#define MOVE_EFFECT_SP_DEF_PLUS_2 0x2B
+#define MOVE_EFFECT_ACC_PLUS_2 0x2C
+#define MOVE_EFFECT_EVS_PLUS_2 0x2D
+#define MOVE_EFFECT_ATK_MINUS_2 0x2E
+#define MOVE_EFFECT_DEF_MINUS_2 0x2F
+#define MOVE_EFFECT_SPD_MINUS_2 0x30
+#define MOVE_EFFECT_SP_ATK_MINUS_2 0x31
+#define MOVE_EFFECT_SP_DEF_MINUS_2 0x32
+#define MOVE_EFFECT_ACC_MINUS_2 0x33
+#define MOVE_EFFECT_EVS_MINUS_2 0x34
#define MOVE_EFFECT_THRASH 0x35
#define MOVE_EFFECT_KNOCK_OFF 0x36
+#define MOVE_EFFECT_NOTHING_37 0x37
+#define MOVE_EFFECT_NOTHING_38 0x38
+#define MOVE_EFFECT_NOTHING_39 0x39
+#define MOVE_EFFECT_NOTHING_3A 0x3A
#define MOVE_EFFECT_SP_ATK_TWO_DOWN 0x3B
+#define MOVE_EFFECT_NOTHING_3C 0x3C
+#define MOVE_EFFECT_NOTHING_3D 0x3D
+#define MOVE_EFFECT_NOTHING_3E 0x3E
+#define MOVE_EFFECT_NOTHING_3F 0x3F
#define MOVE_EFFECT_AFFECTS_USER 0x40
+#define MOVE_EFFECT_CERTAIN 0x80
+
+// battle animations ids
+
+#define B_ANIM_CASTFORM_CHANGE 0x0
+#define B_ANIM_STATS_CHANGE 0x1
+#define B_ANIM_SUBSTITUTE_FADE 0x2
+#define B_ANIM_SUBSTITUTE_APPEAR 0x3
+#define B_ANIM_x4 0x4
+#define B_ANIM_ITEM_KNOCKOFF 0x5
+#define B_ANIM_TURN_TRAP 0x6
+#define B_ANIM_ITEM_EFFECT 0x7
+#define B_ANIM_SMOKEBALL_ESCAPE 0x8
+#define B_ANIM_HANGED_ON 0x9
+#define B_ANIM_RAIN_CONTINUES 0xA
+#define B_ANIM_SUN_CONTINUES 0xB
+#define B_ANIM_SANDSTORM_CONTINUES 0xC
+#define B_ANIM_HAIL_CONTINUES 0xD
+#define B_ANIM_LEECH_SEED_DRAIN 0xE
+#define B_ANIM_MON_HIT 0xF
+#define B_ANIM_ITEM_STEAL 0x10
+#define B_ANIM_SNATCH_MOVE 0x11
+#define B_ANIM_FUTURE_SIGHT_HIT 0x12
+#define B_ANIM_x13 0x13
+#define B_ANIM_x14 0x14
+#define B_ANIM_INGRAIN_HEAL 0x15
+#define B_ANIM_WISH_HEAL 0x16
+#define B_ANIM_x17 0x17
+#define B_ANIM_x18 0x18
+#define B_ANIM_x19 0x19
+#define B_ANIM_x1A 0x1A
+#define B_ANIM_x1B 0x1B
+#define B_ANIM_x1C 0x1C
+#define B_ANIM_x1D 0x1D
+
+#define GET_STAT_BUFF_ID(n)((n & 0xF)) // first four bits 0x1, 0x2, 0x4, 0x8
+#define GET_STAT_BUFF_VALUE(n)((n & 0xF0) >> 4) // 0x10, 0x20, 0x40
+#define STAT_BUFF_NEGATIVE 0x80 // 0x80, the sign bit
+
+#define SET_STAT_BUFF_ID(n)((n & 0xF))
+#define SET_STAT_BUFF_VALUE(n)(((s8)(((s8)(n) << 4)) & 0xF0))
struct BattleScripting
{
@@ -718,6 +817,8 @@ struct BattleScripting
u8 animTurn;
u8 animTargetsHit;
u8 statChanger;
+ u8 field_1B;
+ u8 atk23_state;
};
extern struct BattleScripting gBattleScripting;
@@ -729,10 +830,12 @@ void CancelMultiTurnMoves(u8 bank);
void PressurePPLose(u8 bankAtk, u8 bankDef, u16 move);
void PrepareStringBattle(u16 stringId, u8 bank);
u8 GetBattleBank(u8 caseId);
+void UndoEffectsAfterFainting(void);
// battle_3
-void b_movescr_stack_push(const u8* bsPtr);
-void b_movescr_stack_push_cursor(void);
+void BattleScriptPush(const u8* bsPtr);
+void BattleScriptPushCursor(void);
+void BattleScriptPop(void);
u8 sub_803FB4C(void); // msg, can't select a move
u8 CheckMoveLimitations(u8 bank, u8 unusableMoves, u8 check);
bool8 AreAllMovesUnusable(void);
@@ -760,6 +863,13 @@ u8 TypeCalc(u16 move, u8 bankAtk, u8 bankDef);
u8 AI_TypeCalc(u16 move, u16 species, u8 ability);
u8 BankGetTurnOrder(u8 bank);
+// battle_5
+void AdjustFriendshipOnBattleFaint(u8 bank);
+
+// battle 7
+void BattleMusicStop(void);
+void sub_805E990(struct Pokemon* mon, u8 bank);
+
// rom_80A5C6C
u8 GetBankSide(u8 bank);
u8 GetBankIdentity(u8 bank);
diff --git a/include/battle_controllers.h b/include/battle_controllers.h
index b23649192..bfa1bd507 100644
--- a/include/battle_controllers.h
+++ b/include/battle_controllers.h
@@ -7,6 +7,9 @@ void EmitMoveAnimation(u8 bufferId, u16 move, u8 turnOfMove, u16 movePower, s32
void EmitHealthBarUpdate(u8 bufferId, u16 hpValue);
void EmitEffectivenessSound(u8 bufferId, u16 songId);
void EmitPrintStringPlayerOnly(u8 bufferId, u16 stringId);
+void EmitFaintAnimation(u8 bufferId);
+void EmitExpUpdate(u8 bufferId, u8 partyId, u16 expPoints);
+void EmitBattleAnimation(u8 bufferId, u8 animationId, u16 argument);
void MarkBufferBankForExecution(u8 bank);
diff --git a/include/pokemon.h b/include/pokemon.h
index 9d01c051e..674e6dbf4 100644
--- a/include/pokemon.h
+++ b/include/pokemon.h
@@ -620,6 +620,9 @@ bool8 IsPokeSpriteNotFlipped(u16 species);
bool8 IsMonShiny(struct Pokemon *mon);
bool8 IsShinyOtIdPersonality(u32 otId, u32 personality);
+void MonGainEVs(struct Pokemon *mon, u16 defeatedSpecies);
+bool8 IsTradedMon(struct Pokemon *mon);
+
#include "sprite.h"
void DoMonFrontSpriteAnimation(struct Sprite* sprite, u16 species, bool8 noCry, u8 arg3);
diff --git a/src/battle_3.c b/src/battle_3.c
index 4f0997aa0..1b62e3bb8 100644
--- a/src/battle_3.c
+++ b/src/battle_3.c
@@ -196,17 +196,17 @@ extern void sub_803E08C(void);
extern void bc_move_exec_returning(void);
extern s8 GetFlavourRelationByPersonality(u32 personality, u8 flavor);
-void b_movescr_stack_push(const u8* bsPtr)
+void BattleScriptPush(const u8* bsPtr)
{
BATTLESCRIPTS_STACK->ptr[BATTLESCRIPTS_STACK->size++] = bsPtr;
}
-void b_movescr_stack_push_cursor(void)
+void BattleScriptPushCursor(void)
{
BATTLESCRIPTS_STACK->ptr[BATTLESCRIPTS_STACK->size++] = gBattlescriptCurrInstr;
}
-void b_movescr_stack_pop_cursor(void)
+void BattleScriptPop(void)
{
gBattlescriptCurrInstr = BATTLESCRIPTS_STACK->ptr[--BATTLESCRIPTS_STACK->size];
}
@@ -1206,7 +1206,7 @@ u8 AtkCanceller_UnableToUseMove(void)
{
gBattleMons[gBankAttacker].status1 &= ~(STATUS_SLEEP);
gBattleMons[gBankAttacker].status2 &= ~(STATUS2_NIGHTMARE);
- b_movescr_stack_push_cursor();
+ BattleScriptPushCursor();
gBattleCommunication[MULTISTRING_CHOOSER] = 1;
gBattlescriptCurrInstr = BattleScript_MoveUsedWokeUp;
effect = 2;
@@ -1234,7 +1234,7 @@ u8 AtkCanceller_UnableToUseMove(void)
else
{
gBattleMons[gBankAttacker].status2 &= ~(STATUS2_NIGHTMARE);
- b_movescr_stack_push_cursor();
+ BattleScriptPushCursor();
gBattleCommunication[MULTISTRING_CHOOSER] = 0;
gBattlescriptCurrInstr = BattleScript_MoveUsedWokeUp;
effect = 2;
@@ -1262,7 +1262,7 @@ u8 AtkCanceller_UnableToUseMove(void)
else // unfreeze
{
gBattleMons[gBankAttacker].status1 &= ~(STATUS_FREEZE);
- b_movescr_stack_push_cursor();
+ BattleScriptPushCursor();
gBattlescriptCurrInstr = BattleScript_MoveUsedUnfroze;
gBattleCommunication[MULTISTRING_CHOOSER] = 0;
}
@@ -1349,7 +1349,7 @@ u8 AtkCanceller_UnableToUseMove(void)
if (Random() & 1)
{
gBattleCommunication[MULTISTRING_CHOOSER] = 0;
- b_movescr_stack_push_cursor();
+ BattleScriptPushCursor();
}
else // confusion dmg
{
@@ -1363,7 +1363,7 @@ u8 AtkCanceller_UnableToUseMove(void)
}
else // snapped out of confusion
{
- b_movescr_stack_push_cursor();
+ BattleScriptPushCursor();
gBattlescriptCurrInstr = BattleScript_MoveUsedIsConfusedNoMore;
}
effect = 1;
@@ -1387,10 +1387,10 @@ u8 AtkCanceller_UnableToUseMove(void)
{
gBattleScripting.bank = CountTrailingZeroBits((gBattleMons[gBankAttacker].status2 & STATUS2_INFATUATION) >> 0x10);
if (Random() & 1)
- b_movescr_stack_push_cursor();
+ BattleScriptPushCursor();
else
{
- b_movescr_stack_push(BattleScript_MoveUsedIsParalyzedCantAttack);
+ BattleScriptPush(BattleScript_MoveUsedIsParalyzedCantAttack);
gHitMarker |= HITMARKER_UNABLE_TO_USE_MOVE;
gProtectStructs[gBankAttacker].loveImmobility = 1;
CancelMultiTurnMoves(gBankAttacker);
@@ -1432,7 +1432,7 @@ u8 AtkCanceller_UnableToUseMove(void)
if (gBattleMoves[gCurrentMove].effect == EFFECT_THAW_HIT)
{
gBattleMons[gBankAttacker].status1 &= ~(STATUS_FREEZE);
- b_movescr_stack_push_cursor();
+ BattleScriptPushCursor();
gBattlescriptCurrInstr = BattleScript_MoveUsedUnfroze;
gBattleCommunication[MULTISTRING_CHOOSER] = 1;
}
@@ -1969,7 +1969,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg)
gBattleTextBuff1[1] = 3;
gBattleTextBuff1[2] = moveType;
gBattleTextBuff1[3] = 0xFF;
- b_movescr_stack_push_cursor();
+ BattleScriptPushCursor();
gBattlescriptCurrInstr = BattleScript_ColorChangeActivates;
effect++;
}
@@ -1985,7 +1985,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg)
gBattleMoveDamage = gBattleMons[gBankAttacker].maxHP / 16;
if (gBattleMoveDamage == 0)
gBattleMoveDamage = 1;
- b_movescr_stack_push_cursor();
+ BattleScriptPushCursor();
gBattlescriptCurrInstr = BattleScript_RoughSkinActivates;
effect++;
}
@@ -2006,7 +2006,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg)
if (gBattleCommunication[MOVE_EFFECT_BYTE] == 3)
gBattleCommunication[MOVE_EFFECT_BYTE] += 2;
gBattleCommunication[MOVE_EFFECT_BYTE] += 0x40;
- b_movescr_stack_push_cursor();
+ BattleScriptPushCursor();
gBattlescriptCurrInstr = BattleScript_ApplySecondaryEffect;
gHitMarker |= HITMARKER_IGNORE_SAFEGUARD;
effect++;
@@ -2021,7 +2021,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg)
&& (Random() % 3) == 0)
{
gBattleCommunication[MOVE_EFFECT_BYTE] = 0x42;
- b_movescr_stack_push_cursor();
+ BattleScriptPushCursor();
gBattlescriptCurrInstr = BattleScript_ApplySecondaryEffect;
gHitMarker |= HITMARKER_IGNORE_SAFEGUARD;
effect++;
@@ -2036,7 +2036,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg)
&& (Random() % 3) == 0)
{
gBattleCommunication[MOVE_EFFECT_BYTE] = 0x45;
- b_movescr_stack_push_cursor();
+ BattleScriptPushCursor();
gBattlescriptCurrInstr = BattleScript_ApplySecondaryEffect;
gHitMarker |= HITMARKER_IGNORE_SAFEGUARD;
effect++;
@@ -2051,7 +2051,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg)
&& (Random() % 3) == 0)
{
gBattleCommunication[MOVE_EFFECT_BYTE] = 0x43;
- b_movescr_stack_push_cursor();
+ BattleScriptPushCursor();
gBattlescriptCurrInstr = BattleScript_ApplySecondaryEffect;
gHitMarker |= HITMARKER_IGNORE_SAFEGUARD;
effect++;
@@ -2073,7 +2073,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg)
&& GetGenderFromSpeciesAndPersonality(speciesDef, pidDef) != 0xFF)
{
gBattleMons[gBankAttacker].status2 |= (gBitTable[gBankTarget] << 0x10);
- b_movescr_stack_push_cursor();
+ BattleScriptPushCursor();
gBattlescriptCurrInstr = BattleScript_CuteCharmActivates;
effect++;
}
@@ -2155,7 +2155,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg)
gBattleMons[i].status2 &= ~(STATUS2_INFATUATION);
break;
}
- b_movescr_stack_push_cursor();
+ BattleScriptPushCursor();
gBattlescriptCurrInstr = gUnknown_082DB68C;
gBattleScripting.bank = i;
gActiveBank = i;
@@ -2197,7 +2197,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg)
gBattleStruct->synchronizeMoveEffect = 2;
gBattleCommunication[MOVE_EFFECT_BYTE] = gBattleStruct->synchronizeMoveEffect + 0x40;
gBattleScripting.bank = gBankTarget;
- b_movescr_stack_push_cursor();
+ BattleScriptPushCursor();
gBattlescriptCurrInstr = BattleScript_SynchronizeActivates;
gHitMarker |= HITMARKER_IGNORE_SAFEGUARD;
effect++;
@@ -2212,7 +2212,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg)
gBattleStruct->synchronizeMoveEffect = 2;
gBattleCommunication[MOVE_EFFECT_BYTE] = gBattleStruct->synchronizeMoveEffect;
gBattleScripting.bank = gBankAttacker;
- b_movescr_stack_push_cursor();
+ BattleScriptPushCursor();
gBattlescriptCurrInstr = BattleScript_SynchronizeActivates;
gHitMarker |= HITMARKER_IGNORE_SAFEGUARD;
effect++;
@@ -2303,7 +2303,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg)
{
gLastUsedAbility = ABILITY_INTIMIDATE;
gStatuses3[i] &= ~(STATUS3_INTIMIDATE_POKES);
- b_movescr_stack_push_cursor();
+ BattleScriptPushCursor();
gBattlescriptCurrInstr = gUnknown_082DB4C1;
gBattleStruct->intimidateBank = i;
effect++;
@@ -3592,7 +3592,7 @@ _0804330E:\n\
strb r3, [r1, 0x2]\n\
movs r0, 0xFF\n\
strb r0, [r1, 0x3]\n\
- bl b_movescr_stack_push_cursor\n\
+ bl BattleScriptPushCursor\n\
ldr r1, =gBattlescriptCurrInstr\n\
ldr r0, =BattleScript_ColorChangeActivates\n\
str r0, [r1]\n\
@@ -3668,7 +3668,7 @@ _080433CA:\n\
bne _080433D8\n\
str r2, [r1]\n\
_080433D8:\n\
- bl b_movescr_stack_push_cursor\n\
+ bl BattleScriptPushCursor\n\
ldr r1, =gBattlescriptCurrInstr\n\
ldr r0, =BattleScript_RoughSkinActivates\n\
str r0, [r1]\n\
@@ -3763,7 +3763,7 @@ _080434BC:\n\
ldrb r0, [r1, 0x3]\n\
adds r0, 0x40\n\
strb r0, [r1, 0x3]\n\
- bl b_movescr_stack_push_cursor\n\
+ bl BattleScriptPushCursor\n\
ldr r1, =gBattlescriptCurrInstr\n\
ldr r0, =BattleScript_ApplySecondaryEffect\n\
str r0, [r1]\n\
@@ -3849,7 +3849,7 @@ _08043598:\n\
ldr r1, =gBattleCommunication\n\
movs r0, 0x42\n\
strb r0, [r1, 0x3]\n\
- bl b_movescr_stack_push_cursor\n\
+ bl BattleScriptPushCursor\n\
ldr r1, =gBattlescriptCurrInstr\n\
ldr r0, =BattleScript_ApplySecondaryEffect\n\
str r0, [r1]\n\
@@ -3935,7 +3935,7 @@ _08043674:\n\
ldr r1, =gBattleCommunication\n\
movs r0, 0x45\n\
strb r0, [r1, 0x3]\n\
- bl b_movescr_stack_push_cursor\n\
+ bl BattleScriptPushCursor\n\
ldr r1, =gBattlescriptCurrInstr\n\
ldr r0, =BattleScript_ApplySecondaryEffect\n\
str r0, [r1]\n\
@@ -4021,7 +4021,7 @@ _08043750:\n\
ldr r1, =gBattleCommunication\n\
movs r0, 0x43\n\
strb r0, [r1, 0x3]\n\
- bl b_movescr_stack_push_cursor\n\
+ bl BattleScriptPushCursor\n\
ldr r1, =gBattlescriptCurrInstr\n\
ldr r0, =BattleScript_ApplySecondaryEffect\n\
str r0, [r1]\n\
@@ -4183,7 +4183,7 @@ _080438B6:\n\
ldr r0, [r2]\n\
orrs r0, r1\n\
str r0, [r2]\n\
- bl b_movescr_stack_push_cursor\n\
+ bl BattleScriptPushCursor\n\
ldr r1, =gBattlescriptCurrInstr\n\
ldr r0, =BattleScript_CuteCharmActivates\n\
str r0, [r1]\n\
@@ -4484,7 +4484,7 @@ _08043BF8:\n\
_08043BFA:\n\
str r0, [r2]\n\
_08043BFC:\n\
- bl b_movescr_stack_push_cursor\n\
+ bl BattleScriptPushCursor\n\
ldr r1, =gBattlescriptCurrInstr\n\
ldr r0, =gUnknown_082DB68C\n\
str r0, [r1]\n\
@@ -4607,7 +4607,7 @@ _08043CF8:\n\
ldr r0, =gBankTarget\n\
ldrb r0, [r0]\n\
strb r0, [r1, 0x17]\n\
- bl b_movescr_stack_push_cursor\n\
+ bl BattleScriptPushCursor\n\
ldr r1, =gBattlescriptCurrInstr\n\
ldr r0, =BattleScript_SynchronizeActivates\n\
str r0, [r1]\n\
@@ -4662,7 +4662,7 @@ _08043D7C:\n\
ldr r0, =gBankAttacker\n\
ldrb r0, [r0]\n\
strb r0, [r1, 0x17]\n\
- bl b_movescr_stack_push_cursor\n\
+ bl BattleScriptPushCursor\n\
ldr r1, =gBattlescriptCurrInstr\n\
ldr r0, =BattleScript_SynchronizeActivates\n\
str r0, [r1]\n\
@@ -5380,7 +5380,7 @@ _080443B4:\n\
ldr r1, =0xfff7ffff\n\
ands r0, r1\n\
str r0, [r2]\n\
- bl b_movescr_stack_push_cursor\n\
+ bl BattleScriptPushCursor\n\
ldr r1, =gBattlescriptCurrInstr\n\
ldr r0, =gUnknown_082DB4C1\n\
str r0, [r1]\n\
@@ -5465,7 +5465,7 @@ void b_call_bc_move_exec(const u8* BS_ptr)
void b_push_move_exec(const u8* BS_ptr)
{
- b_movescr_stack_push_cursor();
+ BattleScriptPushCursor();
gBattlescriptCurrInstr = BS_ptr;
BATTLE_CALLBACKS_STACK->function[BATTLE_CALLBACKS_STACK->size++] = gBattleMainFunc;
gBattleMainFunc = sub_803E08C;
@@ -6029,7 +6029,7 @@ u8 ItemBattleEffects(u8 caseID, u8 bank, bool8 moveTurn)
if (gBattleMons[bank].status1 & STATUS_PARALYSIS)
{
gBattleMons[bank].status1 &= ~(STATUS_PARALYSIS);
- b_movescr_stack_push_cursor();
+ BattleScriptPushCursor();
gBattlescriptCurrInstr = BattleScript_BerryCureParRet;
effect = ITEM_STATUS_CHANGE;
}
@@ -6038,7 +6038,7 @@ u8 ItemBattleEffects(u8 caseID, u8 bank, bool8 moveTurn)
if (gBattleMons[bank].status1 & STATUS_PSN_ANY)
{
gBattleMons[bank].status1 &= ~(STATUS_PSN_ANY | STATUS_TOXIC_COUNTER);
- b_movescr_stack_push_cursor();
+ BattleScriptPushCursor();
gBattlescriptCurrInstr = BattleScript_BerryCurePsnRet;
effect = ITEM_STATUS_CHANGE;
}
@@ -6047,7 +6047,7 @@ u8 ItemBattleEffects(u8 caseID, u8 bank, bool8 moveTurn)
if (gBattleMons[bank].status1 & STATUS_BURN)
{
gBattleMons[bank].status1 &= ~(STATUS_BURN);
- b_movescr_stack_push_cursor();
+ BattleScriptPushCursor();
gBattlescriptCurrInstr = BattleScript_BerryCureBrnRet;
effect = ITEM_STATUS_CHANGE;
}
@@ -6056,7 +6056,7 @@ u8 ItemBattleEffects(u8 caseID, u8 bank, bool8 moveTurn)
if (gBattleMons[bank].status1 & STATUS_FREEZE)
{
gBattleMons[bank].status1 &= ~(STATUS_FREEZE);
- b_movescr_stack_push_cursor();
+ BattleScriptPushCursor();
gBattlescriptCurrInstr = BattleScript_BerryCureFrzRet;
effect = ITEM_STATUS_CHANGE;
}
@@ -6066,7 +6066,7 @@ u8 ItemBattleEffects(u8 caseID, u8 bank, bool8 moveTurn)
{
gBattleMons[bank].status1 &= ~(STATUS_SLEEP);
gBattleMons[bank].status2 &= ~(STATUS2_NIGHTMARE);
- b_movescr_stack_push_cursor();
+ BattleScriptPushCursor();
gBattlescriptCurrInstr = BattleScript_BerryCureSlpRet;
effect = ITEM_STATUS_CHANGE;
}
@@ -6075,7 +6075,7 @@ u8 ItemBattleEffects(u8 caseID, u8 bank, bool8 moveTurn)
if (gBattleMons[bank].status2 & STATUS2_CONFUSION)
{
gBattleMons[bank].status2 &= ~(STATUS2_CONFUSION);
- b_movescr_stack_push_cursor();
+ BattleScriptPushCursor();
gBattlescriptCurrInstr = BattleScript_BerryCureConfusionRet;
effect = ITEM_EFFECT_OTHER;
}
@@ -6085,7 +6085,7 @@ u8 ItemBattleEffects(u8 caseID, u8 bank, bool8 moveTurn)
{
gBattleMons[bank].status2 &= ~(STATUS2_INFATUATION);
StringCopy(gBattleTextBuff1, gStatusConditionString_LoveJpn);
- b_movescr_stack_push_cursor();
+ BattleScriptPushCursor();
gBattleCommunication[MULTISTRING_CHOOSER] = 0;
gBattlescriptCurrInstr = BattleScript_BerryCureChosenStatusRet;
effect = ITEM_EFFECT_OTHER;
@@ -6121,7 +6121,7 @@ u8 ItemBattleEffects(u8 caseID, u8 bank, bool8 moveTurn)
}
gBattleMons[bank].status1 = 0;
gBattleMons[bank].status2 &= ~(STATUS2_CONFUSION);
- b_movescr_stack_push_cursor();
+ BattleScriptPushCursor();
gBattleCommunication[MULTISTRING_CHOOSER] = 0;
gBattlescriptCurrInstr = BattleScript_BerryCureChosenStatusRet;
effect = ITEM_STATUS_CHANGE;
@@ -6140,7 +6140,7 @@ u8 ItemBattleEffects(u8 caseID, u8 bank, bool8 moveTurn)
{
gBattleScripting.bank = bank;
gStringBank = bank;
- b_movescr_stack_push_cursor();
+ BattleScriptPushCursor();
gBattlescriptCurrInstr = BattleScript_WhiteHerbRet;
return effect; // unnecessary return
}
@@ -6170,9 +6170,9 @@ u8 ItemBattleEffects(u8 caseID, u8 bank, bool8 moveTurn)
&& gBattleMons[gBankTarget].hp)
{
gBattleCommunication[MOVE_EFFECT_BYTE] = 8;
- b_movescr_stack_push_cursor();
+ BattleScriptPushCursor();
SetMoveEffect(0, 0);
- b_movescr_stack_pop_cursor();
+ BattleScriptPop();
}
break;
case HOLD_EFFECT_SHELL_BELL:
@@ -6190,7 +6190,7 @@ u8 ItemBattleEffects(u8 caseID, u8 bank, bool8 moveTurn)
if (gBattleMoveDamage == 0)
gBattleMoveDamage = -1;
gSpecialStatuses[gBankTarget].moveturnLostHP = 0;
- b_movescr_stack_push_cursor();
+ BattleScriptPushCursor();
gBattlescriptCurrInstr = BattleScript_ItemHealHP_Ret;
effect++;
}
diff --git a/src/battle_4.c b/src/battle_4.c
index 6e71a6a57..8e0be22c2 100644
--- a/src/battle_4.c
+++ b/src/battle_4.c
@@ -15,6 +15,8 @@
#include "battle_controllers.h"
#include "species.h"
#include "songs.h"
+#include "text.h"
+#include "sound.h"
// variables
@@ -75,6 +77,7 @@ extern u8 gActionForBanks[BATTLE_BANKS_COUNT];
extern u8 gCurrentMoveTurn;
extern u8 gBattleBufferB[BATTLE_BANKS_COUNT][0x200];
extern u16 gLockedMoves[BATTLE_BANKS_COUNT];
+extern u16 gPartnerTrainerId;
extern const struct BattleMove gBattleMoves[];
extern const struct BaseStats gBaseStats[];
@@ -84,7 +87,7 @@ extern const u16 gTrappingMoves[];
extern const u8 gTrainerMoney[];
// functions
-
+extern void sub_81A5718(u8 bank); // battle frontier 2
// BattleScripts
extern const u8 BattleScript_MoveEnd[];
@@ -108,6 +111,7 @@ extern const u8 BattleScript_ItemSteal[];
extern const u8 BattleScript_RapidSpinAway[];
extern const u8 BattleScript_TargetPRLZHeal[];
extern const u8 BattleScript_KnockedOff[];
+extern const u8 BattleScript_StickyHoldOnKnockOff[];
extern const u8 BattleScript_AllStatsUp[];
extern const u8 BattleScript_AtkDefDown[];
extern const u8 BattleScript_SAtkDown2[];
@@ -124,6 +128,10 @@ extern const u8 BattleScript_TrainerBallBlock[];
extern const u8 BattleScript_WallyBallThrow[];
extern const u8 BattleScript_SuccessBallThrow[];
extern const u8 BattleScript_ShakeBallThrow[];
+extern const u8 BattleScript_FaintAttacker[];
+extern const u8 BattleScript_FaintTarget[];
+extern const u8 BattleScript_DestinyBondTakesLife[];
+extern const u8 BattleScript_GrudgeTakesPp[];
// read via orr
#define BSScriptRead32(ptr) ((ptr)[0] | (ptr)[1] << 8 | (ptr)[2] << 16 | (ptr)[3] << 24)
@@ -144,7 +152,7 @@ bool8 IsTwoTurnsMove(u16 move);
void DestinyBondFlagUpdate(void);
u8 AttacksThisTurn(u8 bank, u16 move); // Note: returns 1 if it's a charging turn, otherwise 2.
static void CheckWonderGuardAndLevitate(void);
-u8 ChangeStatBuffs(s8, u8 statId, u8, const u8* BS_ptr);
+u8 ChangeStatBuffs(s8 statValue, u8 statId, u8, const u8* BS_ptr);
void atk00_attackcanceler(void);
void atk01_accuracycheck(void);
@@ -687,10 +695,10 @@ const u32 gStatusFlagsForMoveEffects[] =
STATUS2_CONFUSION,
STATUS2_FLINCHED,
0x00000000,
- 0x00000070,
+ STATUS2_UPROAR,
0x00000000,
- 0x00001000,
- 0x0000E000,
+ STATUS2_MULTIPLETURNS,
+ STATUS2_WRAPPED,
0x00000000,
0x00000000,
0x00000000,
@@ -706,10 +714,10 @@ const u32 gStatusFlagsForMoveEffects[] =
0x00000000,
0x00000000,
0x00000000,
- 0x00400000,
+ STATUS2_RECHARGE,
0x00000000,
0x00000000,
- 0x04000000,
+ STATUS2_ESCAPE_PREVENTION,
0x08000000,
0x00000000,
0x00000000,
@@ -730,7 +738,7 @@ const u32 gStatusFlagsForMoveEffects[] =
0x00000000,
0x00000000,
0x00000000,
- 0x00000C00,
+ STATUS2_LOCK_CONFUSE,
0x00000000,
0x00000000,
0x00000000,
@@ -792,7 +800,7 @@ void atk00_attackcanceler(void)
{
PressurePPLose(gBankAttacker, gBankTarget, MOVE_MAGIC_COAT);
gProtectStructs[gBankTarget].bounceMove = 0;
- b_movescr_stack_push_cursor();
+ BattleScriptPushCursor();
gBattlescriptCurrInstr = BattleScript_MagicCoatBounce;
return;
}
@@ -804,7 +812,7 @@ void atk00_attackcanceler(void)
PressurePPLose(gBankAttacker, gTurnOrder[i], MOVE_SNATCH);
gProtectStructs[gTurnOrder[i]].stealMove = 0;
gBattleScripting.bank = gTurnOrder[i];
- b_movescr_stack_push_cursor();
+ BattleScriptPushCursor();
gBattlescriptCurrInstr = BattleScript_SnatchedMove;
return;
}
@@ -814,7 +822,7 @@ void atk00_attackcanceler(void)
{
gSpecialStatuses[gBankTarget].lightningRodRedirected = 0;
gLastUsedAbility = ABILITY_LIGHTNING_ROD;
- b_movescr_stack_push_cursor();
+ BattleScriptPushCursor();
gBattlescriptCurrInstr = BattleScript_TookAttack;
RecordAbilityBattle(gBankTarget, gLastUsedAbility);
}
@@ -1584,7 +1592,7 @@ void atk09_attackanimation(void)
if ((gHitMarker & HITMARKER_NO_ANIMATIONS) && (gCurrentMove != MOVE_TRANSFORM && gCurrentMove != MOVE_SUBSTITUTE))
{
- b_movescr_stack_push(gBattlescriptCurrInstr + 1);
+ BattleScriptPush(gBattlescriptCurrInstr + 1);
gBattlescriptCurrInstr = BattleScript_Pausex20;
gBattleScripting.animTurn++;
gBattleScripting.animTargetsHit++;
@@ -1625,7 +1633,7 @@ void atk09_attackanimation(void)
}
else
{
- b_movescr_stack_push(gBattlescriptCurrInstr + 1);
+ BattleScriptPush(gBattlescriptCurrInstr + 1);
gBattlescriptCurrInstr = BattleScript_Pausex20;
}
}
@@ -1710,7 +1718,7 @@ void atk0C_datahpupdate(void)
if (gDisableStructs[gActiveBank].substituteHP == 0)
{
gBattlescriptCurrInstr += 2;
- b_movescr_stack_push_cursor();
+ BattleScriptPushCursor();
gBattlescriptCurrInstr = BattleScript_SubstituteFade;
return;
}
@@ -1898,7 +1906,7 @@ void atk0F_resultmessage(void)
gLastUsedItem = gBattleMons[gBankTarget].item;
gStringBank = gBankTarget;
gBattleMoveFlags &= ~(MOVESTATUS_ENDURED | MOVESTATUS_HUNGON);
- b_movescr_stack_push_cursor();
+ BattleScriptPushCursor();
gBattlescriptCurrInstr = BattleScript_HangedOnMsg;
return;
default:
@@ -1911,14 +1919,14 @@ void atk0F_resultmessage(void)
gBattleMoveFlags &= ~(MOVESTATUS_ONEHITKO);
gBattleMoveFlags &= ~(MOVESTATUS_SUPEREFFECTIVE);
gBattleMoveFlags &= ~(MOVESTATUS_NOTVERYEFFECTIVE);
- b_movescr_stack_push_cursor();
+ BattleScriptPushCursor();
gBattlescriptCurrInstr = BattleScript_OneHitKOMsg;
return;
}
else if (gBattleMoveFlags & MOVESTATUS_ENDURED)
{
gBattleMoveFlags &= ~(MOVESTATUS_ENDURED | MOVESTATUS_HUNGON);
- b_movescr_stack_push_cursor();
+ BattleScriptPushCursor();
gBattlescriptCurrInstr = BattleScript_EnduredMsg;
return;
}
@@ -1927,7 +1935,7 @@ void atk0F_resultmessage(void)
gLastUsedItem = gBattleMons[gBankTarget].item;
gStringBank = gBankTarget;
gBattleMoveFlags &= ~(MOVESTATUS_ENDURED | MOVESTATUS_HUNGON);
- b_movescr_stack_push_cursor();
+ BattleScriptPushCursor();
gBattlescriptCurrInstr = BattleScript_HangedOnMsg;
return;
}
@@ -2110,12 +2118,12 @@ void SetMoveEffect(bool8 primary, u8 certain)
break;
case STATUS_POISON:
if (gBattleMons[gEffectBank].ability == ABILITY_IMMUNITY
- && (primary == TRUE || certain == 0x80))
+ && (primary == TRUE || certain == MOVE_EFFECT_CERTAIN))
{
gLastUsedAbility = ABILITY_IMMUNITY;
RecordAbilityBattle(gEffectBank, ABILITY_IMMUNITY);
- b_movescr_stack_push(gBattlescriptCurrInstr + 1);
+ BattleScriptPush(gBattlescriptCurrInstr + 1);
gBattlescriptCurrInstr = BattleScript_PSNPrevention;
if (gHitMarker & HITMARKER_IGNORE_SAFEGUARD)
@@ -2132,9 +2140,9 @@ void SetMoveEffect(bool8 primary, u8 certain)
if ((gBattleMons[gEffectBank].type1 == TYPE_POISON || gBattleMons[gEffectBank].type2 == TYPE_POISON
|| gBattleMons[gEffectBank].type1 == TYPE_STEEL || gBattleMons[gEffectBank].type2 == TYPE_STEEL)
&& (gHitMarker & HITMARKER_IGNORE_SAFEGUARD)
- && (primary == 1 || certain == 0x80))
+ && (primary == TRUE || certain == MOVE_EFFECT_CERTAIN))
{
- b_movescr_stack_push(gBattlescriptCurrInstr + 1);
+ BattleScriptPush(gBattlescriptCurrInstr + 1);
gBattlescriptCurrInstr = BattleScript_PSNPrevention;
gBattleCommunication[MULTISTRING_CHOOSER] = 2;
@@ -2157,12 +2165,12 @@ void SetMoveEffect(bool8 primary, u8 certain)
break;
case STATUS_BURN:
if (gBattleMons[gEffectBank].ability == ABILITY_WATER_VEIL
- && (primary == 1 || certain == 0x80))
+ && (primary == TRUE || certain == MOVE_EFFECT_CERTAIN))
{
gLastUsedAbility = ABILITY_WATER_VEIL;
RecordAbilityBattle(gEffectBank, ABILITY_WATER_VEIL);
- b_movescr_stack_push(gBattlescriptCurrInstr + 1);
+ BattleScriptPush(gBattlescriptCurrInstr + 1);
gBattlescriptCurrInstr = BattleScript_BRNPrevention;
if (gHitMarker & HITMARKER_IGNORE_SAFEGUARD)
{
@@ -2178,9 +2186,9 @@ void SetMoveEffect(bool8 primary, u8 certain)
if ((gBattleMons[gEffectBank].type1 == TYPE_FIRE
|| gBattleMons[gEffectBank].type2 == TYPE_FIRE)
&& (gHitMarker & HITMARKER_IGNORE_SAFEGUARD)
- && (primary == 1 || certain == 0x80))
+ && (primary == TRUE || certain == MOVE_EFFECT_CERTAIN))
{
- b_movescr_stack_push(gBattlescriptCurrInstr + 1);
+ BattleScriptPush(gBattlescriptCurrInstr + 1);
gBattlescriptCurrInstr = BattleScript_BRNPrevention;
gBattleCommunication[MULTISTRING_CHOOSER] = 2;
@@ -2217,12 +2225,12 @@ void SetMoveEffect(bool8 primary, u8 certain)
case STATUS_PARALYSIS:
if (gBattleMons[gEffectBank].ability == ABILITY_LIMBER)
{
- if (primary == TRUE || certain == 0x80)
+ if (primary == TRUE || certain == MOVE_EFFECT_CERTAIN)
{
gLastUsedAbility = ABILITY_LIMBER;
RecordAbilityBattle(gEffectBank, ABILITY_LIMBER);
- b_movescr_stack_push(gBattlescriptCurrInstr + 1);
+ BattleScriptPush(gBattlescriptCurrInstr + 1);
gBattlescriptCurrInstr = BattleScript_PRLZPrevention;
if (gHitMarker & HITMARKER_IGNORE_SAFEGUARD)
@@ -2245,12 +2253,12 @@ void SetMoveEffect(bool8 primary, u8 certain)
statusChanged = TRUE;
break;
case STATUS_TOXIC_POISON:
- if (gBattleMons[gEffectBank].ability == ABILITY_IMMUNITY && (primary == 1 || certain == 0x80))
+ if (gBattleMons[gEffectBank].ability == ABILITY_IMMUNITY && (primary == TRUE || certain == MOVE_EFFECT_CERTAIN))
{
gLastUsedAbility = ABILITY_IMMUNITY;
RecordAbilityBattle(gEffectBank, ABILITY_IMMUNITY);
- b_movescr_stack_push(gBattlescriptCurrInstr + 1);
+ BattleScriptPush(gBattlescriptCurrInstr + 1);
gBattlescriptCurrInstr = BattleScript_PSNPrevention;
if (gHitMarker & HITMARKER_IGNORE_SAFEGUARD)
@@ -2267,9 +2275,9 @@ void SetMoveEffect(bool8 primary, u8 certain)
if ((gBattleMons[gEffectBank].type1 == TYPE_POISON || gBattleMons[gEffectBank].type2 == TYPE_POISON
|| gBattleMons[gEffectBank].type1 == TYPE_STEEL || gBattleMons[gEffectBank].type2 == TYPE_STEEL)
&& (gHitMarker & HITMARKER_IGNORE_SAFEGUARD)
- && (primary == TRUE || certain == 0x80))
+ && (primary == TRUE || certain == MOVE_EFFECT_CERTAIN))
{
- b_movescr_stack_push(gBattlescriptCurrInstr + 1);
+ BattleScriptPush(gBattlescriptCurrInstr + 1);
gBattlescriptCurrInstr = BattleScript_PSNPrevention;
gBattleCommunication[MULTISTRING_CHOOSER] = 2;
@@ -2299,7 +2307,7 @@ void SetMoveEffect(bool8 primary, u8 certain)
}
if (statusChanged == TRUE)
{
- b_movescr_stack_push(gBattlescriptCurrInstr + 1);
+ BattleScriptPush(gBattlescriptCurrInstr + 1);
if (gStatusFlagsForMoveEffects[gBattleCommunication[MOVE_EFFECT_BYTE]] == STATUS_SLEEP)
gBattleMons[gEffectBank].status1 |= ((Random() & 3) + 2);
@@ -2341,6 +2349,7 @@ void SetMoveEffect(bool8 primary, u8 certain)
gBattlescriptCurrInstr++;
return;
}
+ return;
}
else
{
@@ -2351,7 +2360,7 @@ void SetMoveEffect(bool8 primary, u8 certain)
else
{
u8 side;
- switch (gStatusFlagsForMoveEffects[gBattleCommunication[MOVE_EFFECT_BYTE]])
+ switch (gBattleCommunication[MOVE_EFFECT_BYTE])
{
case MOVE_EFFECT_CONFUSION:
if (gBattleMons[gEffectBank].ability == ABILITY_OWN_TEMPO
@@ -2363,47 +2372,46 @@ void SetMoveEffect(bool8 primary, u8 certain)
{
gBattleMons[gEffectBank].status2 |= (((Random()) % 0x4)) + 2;
- b_movescr_stack_push(gBattlescriptCurrInstr + 1);
+ BattleScriptPush(gBattlescriptCurrInstr + 1);
gBattlescriptCurrInstr = gMoveEffectBS_Ptrs[gBattleCommunication[MOVE_EFFECT_BYTE]];
}
break;
case MOVE_EFFECT_FLINCH:
if (gBattleMons[gEffectBank].ability == ABILITY_INNER_FOCUS)
{
- if (primary == 1 || certain == 0x80)
+ if (primary == TRUE || certain == MOVE_EFFECT_CERTAIN)
{
gLastUsedAbility = ABILITY_INNER_FOCUS;
RecordAbilityBattle(gEffectBank, ABILITY_INNER_FOCUS);
gBattlescriptCurrInstr = BattleScript_FlinchPrevention;
- RESET_RETURN
}
else
{
gBattlescriptCurrInstr++;
- break;
}
}
else
{
if (BankGetTurnOrder(gEffectBank) > gCurrentMoveTurn)
gBattleMons[gEffectBank].status2 |= gStatusFlagsForMoveEffects[gBattleCommunication[MOVE_EFFECT_BYTE]];
- INCREMENT_RESET_RETURN
+ gBattlescriptCurrInstr++;
}
break;
case MOVE_EFFECT_UPROAR:
- if (gBattleMons[gEffectBank].status2 & STATUS2_UPROAR)
- {
- gBattlescriptCurrInstr++;
- }
- else
+ if (!(gBattleMons[gEffectBank].status2 & STATUS2_UPROAR))
{
+
gBattleMons[gEffectBank].status2 |= STATUS2_MULTIPLETURNS;
gLockedMoves[gEffectBank] = gCurrentMove;
gBattleMons[gEffectBank].status2 |= ((Random() & 3) + 2) << 4;
- b_movescr_stack_push(gBattlescriptCurrInstr + 1);
+ BattleScriptPush(gBattlescriptCurrInstr + 1);
gBattlescriptCurrInstr = gMoveEffectBS_Ptrs[gBattleCommunication[MOVE_EFFECT_BYTE]];
}
+ else
+ {
+ gBattlescriptCurrInstr++;
+ }
break;
case MOVE_EFFECT_PAYDAY:
if (GET_BANK_SIDE(gBankAttacker) == SIDE_PLAYER)
@@ -2413,7 +2421,7 @@ void SetMoveEffect(bool8 primary, u8 certain)
if (PayDay > gPaydayMoney)
gPaydayMoney = 0xFFFF;
}
- b_movescr_stack_push(gBattlescriptCurrInstr + 1);
+ BattleScriptPush(gBattlescriptCurrInstr + 1);
gBattlescriptCurrInstr = gMoveEffectBS_Ptrs[gBattleCommunication[MOVE_EFFECT_BYTE]];
break;
case MOVE_EFFECT_TRI_ATTACK:
@@ -2440,18 +2448,20 @@ void SetMoveEffect(bool8 primary, u8 certain)
}
else
{
- gBattleMons[gEffectBank].status2 |= ((Random() & 3) + 2) << 0xD;
+ gBattleMons[gEffectBank].status2 |= ((Random() & 3) + 3) << 0xD;
*(gBattleStruct->wrappedMove + gEffectBank * 2 + 0) = gCurrentMove;
*(gBattleStruct->wrappedMove + gEffectBank * 2 + 1) = gCurrentMove >> 8;
*(gBattleStruct->wrappedBy + gEffectBank) = gBankAttacker;
- b_movescr_stack_push(gBattlescriptCurrInstr + 1);
+ BattleScriptPush(gBattlescriptCurrInstr + 1);
gBattlescriptCurrInstr = gMoveEffectBS_Ptrs[gBattleCommunication[MOVE_EFFECT_BYTE]];
- for (gBattleCommunication[MULTISTRING_CHOOSER] = 0; gBattleCommunication[MULTISTRING_CHOOSER] <= 4; gBattleCommunication[MULTISTRING_CHOOSER]++)
+ for (gBattleCommunication[MULTISTRING_CHOOSER] = 0; ; gBattleCommunication[MULTISTRING_CHOOSER]++)
{
- if (gCurrentMove == gTrappingMoves[gBattleCommunication[MULTISTRING_CHOOSER]])
+ if (gBattleCommunication[MULTISTRING_CHOOSER] > 4)
+ break;
+ if (gTrappingMoves[gBattleCommunication[MULTISTRING_CHOOSER]] == gCurrentMove)
break;
}
}
@@ -2461,58 +2471,90 @@ void SetMoveEffect(bool8 primary, u8 certain)
if (gBattleMoveDamage == 0)
gBattleMoveDamage = 1;
- b_movescr_stack_push(gBattlescriptCurrInstr + 1);
+ BattleScriptPush(gBattlescriptCurrInstr + 1);
gBattlescriptCurrInstr = gMoveEffectBS_Ptrs[gBattleCommunication[MOVE_EFFECT_BYTE]];
break;
- case 15 ... 21: // stat + 1
- if (ChangeStatBuffs(0x10, gBattleCommunication[MOVE_EFFECT_BYTE] + 0xF2, affectsUser, 0))
+ case MOVE_EFFECT_ATK_PLUS_1:
+ case MOVE_EFFECT_DEF_PLUS_1:
+ case MOVE_EFFECT_SPD_PLUS_1:
+ case MOVE_EFFECT_SP_ATK_PLUS_1:
+ case MOVE_EFFECT_SP_DEF_PLUS_1:
+ case MOVE_EFFECT_ACC_PLUS_1:
+ case MOVE_EFFECT_EVS_PLUS_1:
+ if (ChangeStatBuffs(SET_STAT_BUFF_VALUE(1),
+ gBattleCommunication[MOVE_EFFECT_BYTE] - MOVE_EFFECT_ATK_PLUS_1 + 1,
+ affectsUser, 0))
{
gBattlescriptCurrInstr++;
}
else
{
- gBattleScripting.animArg1 = gBattleCommunication[MOVE_EFFECT_BYTE] & 0x3F;
+ gBattleScripting.animArg1 = gBattleCommunication[MOVE_EFFECT_BYTE] & ~(MOVE_EFFECT_AFFECTS_USER | MOVE_EFFECT_CERTAIN);
gBattleScripting.animArg2 = 0;
- b_movescr_stack_push(gBattlescriptCurrInstr + 1);
+ BattleScriptPush(gBattlescriptCurrInstr + 1);
gBattlescriptCurrInstr = BattleScript_StatUp;
}
break;
- case 22 ... 28: // stat - 1
- if (ChangeStatBuffs(~(0x6f), gBattleCommunication[MOVE_EFFECT_BYTE] + 0xEB, affectsUser, 0))
+ case MOVE_EFFECT_ATK_MINUS_1:
+ case MOVE_EFFECT_DEF_MINUS_1:
+ case MOVE_EFFECT_SPD_MINUS_1:
+ case MOVE_EFFECT_SP_ATK_MINUS_1:
+ case MOVE_EFFECT_SP_DEF_MINUS_1:
+ case MOVE_EFFECT_ACC_MINUS_1:
+ case MOVE_EFFECT_EVS_MINUS_1:
+ if (ChangeStatBuffs(SET_STAT_BUFF_VALUE(1) | STAT_BUFF_NEGATIVE,
+ gBattleCommunication[MOVE_EFFECT_BYTE] - MOVE_EFFECT_ATK_MINUS_1 + 1,
+ affectsUser, 0))
{
gBattlescriptCurrInstr++;
}
else
{
- gBattleScripting.animArg1 = gBattleCommunication[MOVE_EFFECT_BYTE] & 0x3F;
+ gBattleScripting.animArg1 = gBattleCommunication[MOVE_EFFECT_BYTE] & ~(MOVE_EFFECT_AFFECTS_USER | MOVE_EFFECT_CERTAIN);
gBattleScripting.animArg2 = 0;
- b_movescr_stack_push(gBattlescriptCurrInstr + 1);
+ BattleScriptPush(gBattlescriptCurrInstr + 1);
gBattlescriptCurrInstr = BattleScript_StatDown;
}
break;
- case 39 ... 45: // stat + 2
- if (ChangeStatBuffs(0x20, gBattleCommunication[MOVE_EFFECT_BYTE] + 0xDA, affectsUser, 0))
+ case MOVE_EFFECT_ATK_PLUS_2:
+ case MOVE_EFFECT_DEF_PLUS_2:
+ case MOVE_EFFECT_SPD_PLUS_2:
+ case MOVE_EFFECT_SP_ATK_PLUS_2:
+ case MOVE_EFFECT_SP_DEF_PLUS_2:
+ case MOVE_EFFECT_ACC_PLUS_2:
+ case MOVE_EFFECT_EVS_PLUS_2:
+ if (ChangeStatBuffs(SET_STAT_BUFF_VALUE(2),
+ gBattleCommunication[MOVE_EFFECT_BYTE] - MOVE_EFFECT_ATK_PLUS_2 + 1,
+ affectsUser, 0))
{
gBattlescriptCurrInstr++;
}
else
{
- gBattleScripting.animArg1 = gBattleCommunication[MOVE_EFFECT_BYTE] & 0x3F;
+ gBattleScripting.animArg1 = gBattleCommunication[MOVE_EFFECT_BYTE] & ~(MOVE_EFFECT_AFFECTS_USER | MOVE_EFFECT_CERTAIN);
gBattleScripting.animArg2 = 0;
- b_movescr_stack_push(gBattlescriptCurrInstr + 1);
+ BattleScriptPush(gBattlescriptCurrInstr + 1);
gBattlescriptCurrInstr = BattleScript_StatUp;
}
break;
- case 46 ... 52: // stat - 2
- if (ChangeStatBuffs(~(0x5f), gBattleCommunication[MOVE_EFFECT_BYTE] + 0xD3, affectsUser, 0))
+ case MOVE_EFFECT_ATK_MINUS_2:
+ case MOVE_EFFECT_DEF_MINUS_2:
+ case MOVE_EFFECT_SPD_MINUS_2:
+ case MOVE_EFFECT_SP_ATK_MINUS_2:
+ case MOVE_EFFECT_SP_DEF_MINUS_2:
+ case MOVE_EFFECT_ACC_MINUS_2:
+ case MOVE_EFFECT_EVS_MINUS_2:
+ if (ChangeStatBuffs(SET_STAT_BUFF_VALUE(2) | STAT_BUFF_NEGATIVE,
+ gBattleCommunication[MOVE_EFFECT_BYTE] - MOVE_EFFECT_ATK_MINUS_2 + 1,
+ affectsUser, 0))
{
gBattlescriptCurrInstr++;
}
else
{
- gBattleScripting.animArg1 = gBattleCommunication[MOVE_EFFECT_BYTE] & 0x3F;
+ gBattleScripting.animArg1 = gBattleCommunication[MOVE_EFFECT_BYTE] & ~(MOVE_EFFECT_AFFECTS_USER | MOVE_EFFECT_CERTAIN);
gBattleScripting.animArg2 = 0;
- b_movescr_stack_push(gBattlescriptCurrInstr + 1);
+ BattleScriptPush(gBattlescriptCurrInstr + 1);
gBattlescriptCurrInstr = BattleScript_StatDown;
}
break;
@@ -2544,9 +2586,8 @@ void SetMoveEffect(bool8 primary, u8 certain)
| BATTLE_TYPE_SECRET_BASE)))
{
gBattlescriptCurrInstr++;
- break;
}
- if (!(gBattleTypeFlags &
+ else if (!(gBattleTypeFlags &
(BATTLE_TYPE_EREADER_TRAINER
| BATTLE_TYPE_FRONTIER
| BATTLE_TYPE_LINK
@@ -2555,57 +2596,51 @@ void SetMoveEffect(bool8 primary, u8 certain)
&& (gWishFutureKnock.knockedOffPokes[side] & gBitTable[gBattlePartyID[gBankAttacker]]))
{
gBattlescriptCurrInstr++;
- break;
}
- if (gBattleMons[gBankTarget].item
+ else if (gBattleMons[gBankTarget].item
&& gBattleMons[gBankTarget].ability == ABILITY_STICKY_HOLD)
{
- b_movescr_stack_push_cursor();
+ BattleScriptPushCursor();
gBattlescriptCurrInstr = BattleScript_NoItemSteal;
gLastUsedAbility = gBattleMons[gBankTarget].ability;
RecordAbilityBattle(gBankTarget, gLastUsedAbility);
-
- break;
}
- if (gBattleMons[gBankAttacker].item)
+ else if (gBattleMons[gBankAttacker].item
+ || gBattleMons[gBankTarget].item == ITEM_ENIGMA_BERRY
+ || (gBattleMons[gBankTarget].item > 0x78 && gBattleMons[gBankTarget].item < 0x85)
+ || gBattleMons[gBankTarget].item == 0)
{
gBattlescriptCurrInstr++;
- break;
}
- if (gBattleMons[gBankTarget].item == ITEM_ENIGMA_BERRY)
- {
- gBattlescriptCurrInstr++;
- break;
- }
- if (gBattleMons[gBankTarget].item > 0x78
- && gBattleMons[gBankTarget].item < (0x79 + 12))
- {
- gBattlescriptCurrInstr++;
- break;
- }
- if (gBattleMons[gBankTarget].item == 0)
+ else
{
- gBattlescriptCurrInstr++;
- break;
- }
+ // This is a leftover from R/S direct use of ewram addresses
+ void** memes1 = (void**)(&gBattleStruct);
+ void* memes2 = (void*)((u32)(gBankAttacker * 2 + offsetof(struct BattleStruct, field_D0)));
+ u16* memes3 = (u16*)(((void*)(*memes1) + (u32)(memes2)));
+ gLastUsedItem = *memes3 = gBattleMons[gBankTarget].item;
- *(u16*)((u8*)((gBattleStruct->field_D0) + gBankAttacker * 2)) = gLastUsedItem = gBattleMons[gBankTarget].item;
- gBattleMons[gBankTarget].item = 0;
+ // A sane representation of this would simply be:
+ // gLastUsedItem = gBattleStruct->field_D0[gBankAttacker] = gBattleMons[gBankTarget].item;
- gActiveBank = gBankAttacker;
- EmitSetAttributes(0, REQUEST_HELDITEM_BATTLE, 0, 2, &gLastUsedItem);
- MarkBufferBankForExecution(gBankAttacker);
+ gBattleMons[gBankTarget].item = 0;
- gActiveBank = gBankTarget;
- EmitSetAttributes(0, REQUEST_HELDITEM_BATTLE, 0, 2, &gBattleMons[gBankTarget].item);
- MarkBufferBankForExecution(gBankTarget);
+ gActiveBank = gBankAttacker;
+ EmitSetAttributes(0, REQUEST_HELDITEM_BATTLE, 0, 2, &gLastUsedItem);
+ MarkBufferBankForExecution(gBankAttacker);
+
+ gActiveBank = gBankTarget;
+ EmitSetAttributes(0, REQUEST_HELDITEM_BATTLE, 0, 2, &gBattleMons[gBankTarget].item);
+ MarkBufferBankForExecution(gBankTarget);
- b_movescr_stack_push(gBattlescriptCurrInstr + 1);
- gBattlescriptCurrInstr = BattleScript_ItemSteal;
+ BattleScriptPush(gBattlescriptCurrInstr + 1);
+ gBattlescriptCurrInstr = BattleScript_ItemSteal;
+
+ *(u8*)((u8*)(&gBattleStruct->choicedMove[gBankTarget]) + 0) = 0;
+ *(u8*)((u8*)(&gBattleStruct->choicedMove[gBankTarget]) + 1) = 0;
+ }
- *(u8*)((u8*)(&gBattleStruct->choicedMove[gBankTarget]) + 0) = 0;
- *(u8*)((u8*)(&gBattleStruct->choicedMove[gBankTarget]) + 1) = 0;
}
break;
case MOVE_EFFECT_PREVENT_ESCAPE:
@@ -2618,11 +2653,11 @@ void SetMoveEffect(bool8 primary, u8 certain)
gBattlescriptCurrInstr++;
break;
case MOVE_EFFECT_ALL_STATS_UP:
- b_movescr_stack_push(gBattlescriptCurrInstr + 1);
+ BattleScriptPush(gBattlescriptCurrInstr + 1);
gBattlescriptCurrInstr = BattleScript_AllStatsUp;
break;
case MOVE_EFFECT_RAPIDSPIN:
- b_movescr_stack_push(gBattlescriptCurrInstr + 1);
+ BattleScriptPush(gBattlescriptCurrInstr + 1);
gBattlescriptCurrInstr = BattleScript_RapidSpinAway;
break;
case MOVE_EFFECT_REMOVE_PARALYSIS: // Smelling salts
@@ -2635,15 +2670,15 @@ void SetMoveEffect(bool8 primary, u8 certain)
gBattleMons[gBankTarget].status1 &= ~(STATUS_PARALYSIS);
gActiveBank = gBankTarget;
- EmitSetAttributes(0, REQUEST_STATUS_BATTLE, 0, 4, &gBattleMons[gBankTarget].status1);
+ EmitSetAttributes(0, REQUEST_STATUS_BATTLE, 0, 4, &gBattleMons[gActiveBank].status1);
MarkBufferBankForExecution(gActiveBank);
- b_movescr_stack_push(gBattlescriptCurrInstr + 1);
+ BattleScriptPush(gBattlescriptCurrInstr + 1);
gBattlescriptCurrInstr = BattleScript_TargetPRLZHeal;
}
break;
case MOVE_EFFECT_ATK_DEF_DOWN: // SuperPower
- b_movescr_stack_push(gBattlescriptCurrInstr + 1);
+ BattleScriptPush(gBattlescriptCurrInstr + 1);
gBattlescriptCurrInstr = BattleScript_AtkDefDown;
break;
case MOVE_EFFECT_RECOIL_33_PARALYSIS: // Volt Tackle
@@ -2651,7 +2686,7 @@ void SetMoveEffect(bool8 primary, u8 certain)
if (gBattleMoveDamage == 0)
gBattleMoveDamage = 1;
- b_movescr_stack_push(gBattlescriptCurrInstr + 1);
+ BattleScriptPush(gBattlescriptCurrInstr + 1);
gBattlescriptCurrInstr = gMoveEffectBS_Ptrs[gBattleCommunication[MOVE_EFFECT_BYTE]];
break;
case MOVE_EFFECT_THRASH:
@@ -2676,16 +2711,12 @@ void SetMoveEffect(bool8 primary, u8 certain)
else
{
gLastUsedAbility = ABILITY_STICKY_HOLD;
- gBattlescriptCurrInstr = BattleScript_NoItemSteal;
+ gBattlescriptCurrInstr = BattleScript_StickyHoldOnKnockOff;
RecordAbilityBattle(gEffectBank, ABILITY_STICKY_HOLD);
}
break;
}
- if (gBattleMons[gEffectBank].item == 0)
- {
- gBattlescriptCurrInstr++;
- }
- else
+ if (gBattleMons[gEffectBank].item)
{
side = GetBankSide(gEffectBank);
@@ -2693,18 +2724,19 @@ void SetMoveEffect(bool8 primary, u8 certain)
gBattleMons[gEffectBank].item = 0;
gWishFutureKnock.knockedOffPokes[side] |= gBitTable[gBattlePartyID[gEffectBank]];
- b_movescr_stack_push(gBattlescriptCurrInstr + 1);
+ BattleScriptPush(gBattlescriptCurrInstr + 1);
gBattlescriptCurrInstr = BattleScript_KnockedOff;
*(u8*)((u8*)(&gBattleStruct->choicedMove[gEffectBank]) + 0) = 0;
*(u8*)((u8*)(&gBattleStruct->choicedMove[gEffectBank]) + 1) = 0;
}
- break;
- default:
- gBattlescriptCurrInstr++;
+ else
+ {
+ gBattlescriptCurrInstr++;
+ }
break;
case MOVE_EFFECT_SP_ATK_TWO_DOWN: // Overheat
- b_movescr_stack_push(gBattlescriptCurrInstr + 1);
+ BattleScriptPush(gBattlescriptCurrInstr + 1);
gBattlescriptCurrInstr = BattleScript_SAtkDown2;
break;
}
@@ -2713,3 +2745,1615 @@ void SetMoveEffect(bool8 primary, u8 certain)
gBattleCommunication[MOVE_EFFECT_BYTE] = 0;
}
+
+void atk15_seteffectwithchancetarget(void)
+{
+ u32 percentChance;
+
+ if (gBattleMons[gBankAttacker].ability == ABILITY_SERENE_GRACE)
+ percentChance = gBattleMoves[gCurrentMove].secondaryEffectChance * 2;
+ else
+ percentChance = gBattleMoves[gCurrentMove].secondaryEffectChance;
+
+ if (gBattleCommunication[MOVE_EFFECT_BYTE] & MOVE_EFFECT_CERTAIN
+ && !(gBattleMoveFlags & MOVESTATUS_NOEFFECT))
+ {
+ gBattleCommunication[MOVE_EFFECT_BYTE] &= ~(MOVE_EFFECT_CERTAIN);
+ SetMoveEffect(0, MOVE_EFFECT_CERTAIN);
+ }
+ else if (Random() % 100 < percentChance
+ && gBattleCommunication[MOVE_EFFECT_BYTE]
+ && !(gBattleMoveFlags & MOVESTATUS_NOEFFECT))
+ {
+ if (percentChance >= 100)
+ SetMoveEffect(0, MOVE_EFFECT_CERTAIN);
+ else
+ SetMoveEffect(0, 0);
+ }
+ else
+ {
+ gBattlescriptCurrInstr++;
+ }
+
+ gBattleCommunication[MOVE_EFFECT_BYTE] = 0;
+ gBattleScripting.field_16 = 0;
+}
+
+void atk16_seteffectprimary(void)
+{
+ SetMoveEffect(TRUE, 0);
+}
+
+void atk17_seteffectsecondary(void)
+{
+ SetMoveEffect(FALSE, 0);
+}
+
+void atk18_status_effect_clear(void)
+{
+ gActiveBank = GetBattleBank(BSScriptRead8(gBattlescriptCurrInstr + 1));
+
+ if (gBattleCommunication[MOVE_EFFECT_BYTE] <= MOVE_EFFECT_TOXIC)
+ gBattleMons[gActiveBank].status1 &= (~gStatusFlagsForMoveEffects[gBattleCommunication[MOVE_EFFECT_BYTE]]);
+ else
+ gBattleMons[gActiveBank].status2 &= (~gStatusFlagsForMoveEffects[gBattleCommunication[MOVE_EFFECT_BYTE]]);
+
+ gBattleCommunication[MOVE_EFFECT_BYTE] = 0;
+ gBattlescriptCurrInstr += 2;
+ gBattleScripting.field_16 = 0;
+}
+
+void atk19_faint_pokemon(void)
+{
+ const u8 *BS_ptr;
+
+ if (gBattlescriptCurrInstr[2] != 0)
+ {
+ gActiveBank = GetBattleBank(gBattlescriptCurrInstr[1]);
+ if (gHitMarker & HITMARKER_FAINTED(gActiveBank))
+ {
+ BS_ptr = BSScriptReadPtr(gBattlescriptCurrInstr + 3);
+
+ BattleScriptPop();
+ gBattlescriptCurrInstr = BS_ptr;
+ gSideAffecting[GetBankSide(gActiveBank)] &= ~(SIDE_STATUS_SPIKES_DAMAGED);
+ }
+ else
+ {
+ gBattlescriptCurrInstr += 7;
+ }
+ }
+ else
+ {
+ u8 bank;
+
+ if (gBattlescriptCurrInstr[1] == BS_GET_ATTACKER)
+ {
+ gActiveBank = gBankAttacker;
+ bank = gBankTarget;
+ BS_ptr = BattleScript_FaintAttacker;
+ }
+ else
+ {
+ gActiveBank = gBankTarget;
+ bank = gBankAttacker;
+ BS_ptr = BattleScript_FaintTarget;
+ }
+ if (!(gAbsentBankFlags & gBitTable[gActiveBank])
+ && gBattleMons[gActiveBank].hp == 0)
+ {
+ gHitMarker |= HITMARKER_FAINTED(gActiveBank);
+ BattleScriptPush(gBattlescriptCurrInstr + 7);
+ gBattlescriptCurrInstr = BS_ptr;
+ if (GetBankSide(gActiveBank) == SIDE_PLAYER)
+ {
+ gHitMarker |= HITMARKER_x400000;
+ if (gBattleResults.playerFaintCounter < 0xFF)
+ gBattleResults.playerFaintCounter++;
+ AdjustFriendshipOnBattleFaint(gActiveBank);
+ }
+ else
+ {
+ if (gBattleResults.opponentFaintCounter < 0xFF)
+ gBattleResults.opponentFaintCounter++;
+ gBattleResults.lastOpponentSpecies = GetMonData(&gEnemyParty[gBattlePartyID[gActiveBank]], MON_DATA_SPECIES, NULL);
+ }
+ if ((gHitMarker & HITMARKER_DESTINYBOND) && gBattleMons[gBankAttacker].hp != 0)
+ {
+ gHitMarker &= ~(HITMARKER_DESTINYBOND);
+ BattleScriptPush(gBattlescriptCurrInstr);
+ gBattleMoveDamage = gBattleMons[bank].hp;
+ gBattlescriptCurrInstr = BattleScript_DestinyBondTakesLife;
+ }
+ if ((gStatuses3[gBankTarget] & STATUS3_GRUDGE)
+ && !(gHitMarker & HITMARKER_GRUDGE)
+ && GetBankSide(gBankAttacker) != GetBankSide(gBankTarget)
+ && gBattleMons[gBankAttacker].hp != 0
+ && gCurrentMove != MOVE_STRUGGLE)
+ {
+ u8 moveIndex = *(gBattleStruct->chosenMovesIds + gBankAttacker);
+
+ gBattleMons[gBankAttacker].pp[moveIndex] = 0;
+ BattleScriptPush(gBattlescriptCurrInstr);
+ gBattlescriptCurrInstr = BattleScript_GrudgeTakesPp;
+ gActiveBank = gBankAttacker;
+ EmitSetAttributes(0, moveIndex + REQUEST_PPMOVE1_BATTLE, 0, 1, &gBattleMons[gActiveBank].pp[moveIndex]);
+ MarkBufferBankForExecution(gActiveBank);
+
+ gBattleTextBuff1[0] = PLACEHOLDER_BEGIN;
+ gBattleTextBuff1[1] = 2;
+ gBattleTextBuff1[2] = gBattleMons[gBankAttacker].moves[moveIndex];
+ gBattleTextBuff1[3] = gBattleMons[gBankAttacker].moves[moveIndex] >> 8;
+ gBattleTextBuff1[4] = EOS;
+ }
+ }
+ else
+ {
+ gBattlescriptCurrInstr += 7;
+ }
+ }
+}
+
+void atk1A_faint_animation(void)
+{
+ if (gBattleExecBuffer == 0)
+ {
+ gActiveBank = GetBattleBank(BSScriptRead8(gBattlescriptCurrInstr + 1));
+ EmitFaintAnimation(0);
+ MarkBufferBankForExecution(gActiveBank);
+ gBattlescriptCurrInstr += 2;
+ }
+}
+
+void atk1B_faint_effects_clear(void)
+{
+ if (gBattleExecBuffer == 0)
+ {
+ gActiveBank = GetBattleBank(BSScriptRead8(gBattlescriptCurrInstr + 1));
+
+ if (!(gBattleTypeFlags & BATTLE_TYPE_ARENA) || gBattleMons[gActiveBank].hp == 0)
+ {
+ gBattleMons[gActiveBank].status1 = 0;
+ EmitSetAttributes(0, REQUEST_STATUS_BATTLE, 0, 0x4, &gBattleMons[gActiveBank].status1);
+ MarkBufferBankForExecution(gActiveBank);
+ }
+
+ UndoEffectsAfterFainting(); // Effects like attractions, trapping, etc.
+ gBattlescriptCurrInstr += 2;
+ }
+}
+
+void atk1C_jumpifstatus(void)
+{
+ u8 bank = GetBattleBank(BSScriptRead8(gBattlescriptCurrInstr + 1));
+ u32 flags = BS2ScriptRead32(gBattlescriptCurrInstr + 2);
+ const u8* jumpPtr = BS2ScriptReadPtr(gBattlescriptCurrInstr + 6);
+
+ if (gBattleMons[bank].status1 & flags && gBattleMons[bank].hp)
+ gBattlescriptCurrInstr = jumpPtr;
+ else
+ gBattlescriptCurrInstr += 10;
+}
+
+void atk1D_jumpifstatus2(void)
+{
+ u8 bank = GetBattleBank(BSScriptRead8(gBattlescriptCurrInstr + 1));
+ u32 flags = BS2ScriptRead32(gBattlescriptCurrInstr + 2);
+ const u8* jumpPtr = BS2ScriptReadPtr(gBattlescriptCurrInstr + 6);
+
+ if (gBattleMons[bank].status2 & flags && gBattleMons[bank].hp)
+ gBattlescriptCurrInstr = jumpPtr;
+ else
+ gBattlescriptCurrInstr += 10;
+}
+
+void atk1E_jumpifability(void)
+{
+ u8 bank;
+ u8 ability = BSScriptRead8(gBattlescriptCurrInstr + 2);
+ const u8* jumpPtr = BS2ScriptReadPtr(gBattlescriptCurrInstr + 3);
+
+ if (BSScriptRead8(gBattlescriptCurrInstr + 1) == BS_GET_ATTACKER_SIDE)
+ {
+ bank = AbilityBattleEffects(ABILITYEFFECT_CHECK_BANK_SIDE, gBankAttacker, ability, 0, 0);
+ if (bank)
+ {
+ gLastUsedAbility = ability;
+ gBattlescriptCurrInstr = jumpPtr;
+ RecordAbilityBattle(bank - 1, gLastUsedAbility);
+ gBattleScripting.field_15 = bank - 1;
+ }
+ else
+ gBattlescriptCurrInstr += 7;
+ }
+ else if (BSScriptRead8(gBattlescriptCurrInstr + 1) == BS_GET_NOT_ATTACKER_SIDE)
+ {
+ bank = AbilityBattleEffects(ABILITYEFFECT_CHECK_OTHER_SIDE, gBankAttacker, ability, 0, 0);
+ if (bank)
+ {
+ gLastUsedAbility = ability;
+ gBattlescriptCurrInstr = jumpPtr;
+ RecordAbilityBattle(bank - 1, gLastUsedAbility);
+ gBattleScripting.field_15 = bank - 1;
+ }
+ else
+ gBattlescriptCurrInstr += 7;
+ }
+ else
+ {
+ bank = GetBattleBank(BSScriptRead8(gBattlescriptCurrInstr + 1));
+ if (gBattleMons[bank].ability == ability)
+ {
+ gLastUsedAbility = ability;
+ gBattlescriptCurrInstr = jumpPtr;
+ RecordAbilityBattle(bank, gLastUsedAbility);
+ gBattleScripting.field_15 = bank;
+ }
+ else
+ gBattlescriptCurrInstr += 7;
+ }
+}
+
+void atk1F_jumpifsideaffecting(void)
+{
+ u8 side;
+ u16 flags;
+ const u8* jumpPtr;
+
+ if (BSScriptRead8(gBattlescriptCurrInstr + 1) == BS_GET_ATTACKER)
+ side = GET_BANK_SIDE(gBankAttacker);
+ else
+ side = GET_BANK_SIDE(gBankTarget);
+
+ flags = BS2ScriptRead16(gBattlescriptCurrInstr + 2);
+ jumpPtr = BS2ScriptReadPtr(gBattlescriptCurrInstr + 4);
+
+ if (gSideAffecting[side] & flags)
+ gBattlescriptCurrInstr = jumpPtr;
+ else
+ gBattlescriptCurrInstr += 8;
+}
+
+void atk20_jumpifstat(void)
+{
+ u8 ret = 0;
+ u8 bank = GetBattleBank(BSScriptRead8(gBattlescriptCurrInstr + 1));
+ u8 value = gBattleMons[bank].statStages[BSScriptRead8(gBattlescriptCurrInstr + 3)];
+
+ switch (BSScriptRead8(gBattlescriptCurrInstr + 2))
+ {
+ case CMP_EQUAL:
+ if (value == BSScriptRead8(gBattlescriptCurrInstr + 4))
+ ret++;
+ break;
+ case CMP_NOT_EQUAL:
+ if (value != BSScriptRead8(gBattlescriptCurrInstr + 4))
+ ret++;
+ break;
+ case CMP_GREATER_THAN:
+ if (value > BSScriptRead8(gBattlescriptCurrInstr + 4))
+ ret++;
+ break;
+ case CMP_LESS_THAN:
+ if (value < BSScriptRead8(gBattlescriptCurrInstr + 4))
+ ret++;
+ break;
+ case CMP_COMMON_BITS:
+ if (value & BSScriptRead8(gBattlescriptCurrInstr + 4))
+ ret++;
+ break;
+ case CMP_NO_COMMON_BITS:
+ if (!(value & BSScriptRead8(gBattlescriptCurrInstr + 4)))
+ ret++;
+ break;
+ }
+
+ if (ret)
+ gBattlescriptCurrInstr = BS2ScriptReadPtr(gBattlescriptCurrInstr + 5);
+ else
+ gBattlescriptCurrInstr += 9;
+}
+
+void atk21_jumpifstatus3(void)
+{
+ u32 flags;
+ const u8* jumpPtr;
+
+ gActiveBank = GetBattleBank(BSScriptRead8(gBattlescriptCurrInstr + 1));
+ flags = BS2ScriptRead32(gBattlescriptCurrInstr + 2);
+ jumpPtr = BS2ScriptReadPtr(gBattlescriptCurrInstr + 7);
+
+ if (BSScriptRead8(gBattlescriptCurrInstr + 6))
+ {
+ if ((gStatuses3[gActiveBank] & flags) != 0)
+ gBattlescriptCurrInstr += 11;
+ else
+ gBattlescriptCurrInstr = jumpPtr;
+ }
+ else
+ {
+ if ((gStatuses3[gActiveBank] & flags) != 0)
+ gBattlescriptCurrInstr = jumpPtr;
+ else
+ gBattlescriptCurrInstr += 11;
+ }
+}
+
+void atk22_jumpiftype(void)
+{
+ u8 bank = GetBattleBank(BSScriptRead8(gBattlescriptCurrInstr + 1));
+ u8 type = BSScriptRead8(gBattlescriptCurrInstr + 2);
+ const u8* jumpPtr = BS2ScriptReadPtr(gBattlescriptCurrInstr + 3);
+
+ if (gBattleMons[bank].type1 == type || gBattleMons[bank].type2 == type)
+ gBattlescriptCurrInstr = jumpPtr;
+ else
+ gBattlescriptCurrInstr += 7;
+}
+
+void atk23_getexp(void)
+{
+ u16 item;
+ s32 i; // also used as stringId
+ u8 holdEffect;
+ s32 sentIn;
+
+ s32 viaExpShare = 0;
+ u16* exp = &gBattleStruct->expValue;
+
+ gBank1 = GetBattleBank(BSScriptRead8(gBattlescriptCurrInstr + 1));
+ sentIn = gSentPokesToOpponent[(gBank1 & 2) >> 1];
+
+ switch (gBattleScripting.atk23_state)
+ {
+ case 0: // check if should receive exp at all
+ if (GetBankSide(gBank1) != SIDE_OPPONENT || (gBattleTypeFlags &
+ (BATTLE_TYPE_LINK
+ | BATTLE_TYPE_x2000000
+ | BATTLE_TYPE_x4000000
+ | BATTLE_TYPE_FRONTIER
+ | BATTLE_TYPE_SAFARI
+ | BATTLE_TYPE_BATTLE_TOWER
+ | BATTLE_TYPE_EREADER_TRAINER)))
+ {
+ gBattleScripting.atk23_state = 6; // goto last case
+ }
+ else
+ {
+ gBattleScripting.atk23_state++;
+ gBattleStruct->field_DF |= gBitTable[gBattlePartyID[gBank1]];
+ }
+ break;
+ case 1: // calculate experience points to redistribute
+ {
+ u16 calculatedExp;
+ s32 viaSentIn;
+
+ for (viaSentIn = 0, i = 0; i < 6; i++)
+ {
+ if (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES) == SPECIES_NONE || GetMonData(&gPlayerParty[i], MON_DATA_HP) == 0)
+ continue;
+ if (gBitTable[i] & sentIn)
+ viaSentIn++;
+
+ item = GetMonData(&gPlayerParty[i], MON_DATA_HELD_ITEM);
+
+ if (item == ITEM_ENIGMA_BERRY)
+ holdEffect = gSaveBlock1Ptr->enigmaBerry.holdEffect;
+ else
+ holdEffect = ItemId_GetHoldEffect(item);
+
+ if (holdEffect == HOLD_EFFECT_EXP_SHARE)
+ viaExpShare++;
+ }
+
+ calculatedExp = gBaseStats[gBattleMons[gBank1].species].expYield * gBattleMons[gBank1].level / 7;
+
+ if (viaExpShare) // at least one mon is getting exp via exp share
+ {
+ *exp = calculatedExp / 2 / viaSentIn;
+ if (*exp == 0)
+ *exp = 1;
+
+ gExpShareExp = calculatedExp / 2 / viaExpShare;
+ if (gExpShareExp == 0)
+ gExpShareExp = 1;
+ }
+ else
+ {
+ *exp = calculatedExp / viaSentIn;
+ if (*exp == 0)
+ *exp = 1;
+ gExpShareExp = 0;
+ }
+
+ gBattleScripting.atk23_state++;
+ gBattleStruct->expGetterId = 0;
+ gBattleStruct->sentInPokes = sentIn;
+ }
+ // fall through
+ case 2: // set exp value to the poke in expgetter_id and print message
+ if (gBattleExecBuffer == 0)
+ {
+ item = GetMonData(&gPlayerParty[gBattleStruct->expGetterId], MON_DATA_HELD_ITEM);
+
+ if (item == ITEM_ENIGMA_BERRY)
+ holdEffect = gSaveBlock1Ptr->enigmaBerry.holdEffect;
+ else
+ holdEffect = ItemId_GetHoldEffect(item);
+
+ if (holdEffect != HOLD_EFFECT_EXP_SHARE && !(gBattleStruct->sentInPokes & 1))
+ {
+ *(&gBattleStruct->sentInPokes) >>= 1;
+ gBattleScripting.atk23_state = 5;
+ gBattleMoveDamage = 0; // used for exp
+ }
+ else if (GetMonData(&gPlayerParty[gBattleStruct->expGetterId], MON_DATA_LEVEL) == MAX_MON_LEVEL)
+ {
+ *(&gBattleStruct->sentInPokes) >>= 1;
+ gBattleScripting.atk23_state = 5;
+ gBattleMoveDamage = 0; // used for exp
+ }
+ else
+ {
+ // music change in wild battle after fainting a poke
+ if (!(gBattleTypeFlags & BATTLE_TYPE_TRAINER) && gBattleMons[0].hp && !gBattleStruct->wildVictorySong)
+ {
+ BattleMusicStop();
+ PlayBGM(0x161);
+ gBattleStruct->wildVictorySong++;
+ }
+
+ if (GetMonData(&gPlayerParty[gBattleStruct->expGetterId], MON_DATA_HP))
+ {
+ if (gBattleStruct->sentInPokes & 1)
+ gBattleMoveDamage = *exp;
+ else
+ gBattleMoveDamage = 0;
+
+ if (holdEffect == HOLD_EFFECT_EXP_SHARE)
+ gBattleMoveDamage += gExpShareExp;
+ if (holdEffect == HOLD_EFFECT_LUCKY_EGG)
+ gBattleMoveDamage = (gBattleMoveDamage * 150) / 100;
+ if (gBattleTypeFlags & BATTLE_TYPE_TRAINER)
+ gBattleMoveDamage = (gBattleMoveDamage * 150) / 100;
+
+ if (IsTradedMon(&gPlayerParty[gBattleStruct->expGetterId]))
+ {
+ // check if the pokemon doesn't belong to the player
+ if (gBattleTypeFlags & BATTLE_TYPE_INGAME_PARTNER && gBattleStruct->expGetterId >= 3)
+ {
+ i = 0x149;
+ }
+ else
+ {
+ gBattleMoveDamage = (gBattleMoveDamage * 150) / 100;
+ i = 0x14A;
+ }
+ }
+ else
+ {
+ i = 0x149;
+ }
+
+ // get exp getter bank
+ if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE)
+ {
+ if (!(gBattlePartyID[2] != gBattleStruct->expGetterId) && !(gAbsentBankFlags & gBitTable[2]))
+ gBattleStruct->expGetterBank = 2;
+ else
+ {
+ if (!(gAbsentBankFlags & gBitTable[0]))
+ gBattleStruct->expGetterBank = 0;
+ else
+ gBattleStruct->expGetterBank = 2;
+ }
+ }
+ else
+ gBattleStruct->expGetterBank = 0;
+
+ // buffer poke name
+ gBattleTextBuff1[0] = PLACEHOLDER_BEGIN;
+ gBattleTextBuff1[1] = 4;
+ gBattleTextBuff1[2] = gBattleStruct->expGetterBank;
+ gBattleTextBuff1[3] = gBattleStruct->expGetterId;
+ gBattleTextBuff1[4] = EOS;
+
+ // buffer 'gained' or 'gained a boosted'
+ gBattleTextBuff2[0] = PLACEHOLDER_BEGIN;
+ gBattleTextBuff2[1] = 0;
+ gBattleTextBuff2[2] = i;
+ gBattleTextBuff2[3] = (i & 0xFF00) >> 8;
+ gBattleTextBuff2[4] = EOS;
+
+ // buffer exp number
+ gBattleTextBuff3[0] = PLACEHOLDER_BEGIN;
+ gBattleTextBuff3[1] = 1;
+ gBattleTextBuff3[2] = 4; // word
+ gBattleTextBuff3[3] = 5; // max digits
+ gBattleTextBuff3[4] = gBattleMoveDamage;
+ gBattleTextBuff3[5] = (gBattleMoveDamage & 0x0000FF00) >> 8;
+ gBattleTextBuff3[6] = (gBattleMoveDamage & 0x00FF0000) >> 16;
+ gBattleTextBuff3[7] = (gBattleMoveDamage & 0xFF000000) >> 24;
+ gBattleTextBuff3[8] = EOS;
+
+ PrepareStringBattle(0xD, gBattleStruct->expGetterBank);
+ MonGainEVs(&gPlayerParty[gBattleStruct->expGetterId], gBattleMons[gBank1].species);
+ }
+ gBattleStruct->sentInPokes >>= 1;
+ gBattleScripting.atk23_state++;
+ }
+ }
+ break;
+ case 3: // Set stats and give exp
+ if (gBattleExecBuffer == 0)
+ {
+ gBattleBufferB[gBattleStruct->expGetterBank][0] = 0;
+ if (GetMonData(&gPlayerParty[gBattleStruct->expGetterId], MON_DATA_HP) && GetMonData(&gPlayerParty[gBattleStruct->expGetterId], MON_DATA_LEVEL) != MAX_MON_LEVEL)
+ {
+ BATTLE_LVLUP_STATS->hp = GetMonData(&gPlayerParty[gBattleStruct->expGetterId], MON_DATA_MAX_HP);
+ BATTLE_LVLUP_STATS->atk = GetMonData(&gPlayerParty[gBattleStruct->expGetterId], MON_DATA_ATK);
+ BATTLE_LVLUP_STATS->def = GetMonData(&gPlayerParty[gBattleStruct->expGetterId], MON_DATA_DEF);
+ BATTLE_LVLUP_STATS->spd = GetMonData(&gPlayerParty[gBattleStruct->expGetterId], MON_DATA_SPD);
+ BATTLE_LVLUP_STATS->spAtk = GetMonData(&gPlayerParty[gBattleStruct->expGetterId], MON_DATA_SPATK);
+ BATTLE_LVLUP_STATS->spDef = GetMonData(&gPlayerParty[gBattleStruct->expGetterId], MON_DATA_SPDEF);
+
+ gActiveBank = gBattleStruct->expGetterBank;
+ EmitExpUpdate(0, gBattleStruct->expGetterId, gBattleMoveDamage);
+ MarkBufferBankForExecution(gActiveBank);
+ }
+ gBattleScripting.atk23_state++;
+ }
+ break;
+ case 4: // lvl up if necessary
+ if (gBattleExecBuffer == 0)
+ {
+ gActiveBank = gBattleStruct->expGetterBank;
+ if (gBattleBufferB[gActiveBank][0] == 0x21 && gBattleBufferB[gActiveBank][1] == 0xB)
+ {
+ if (gBattleTypeFlags & BATTLE_TYPE_TRAINER && gBattlePartyID[gActiveBank] == gBattleStruct->expGetterId)
+ sub_805E990(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank);
+
+ // buff poke name
+ gBattleTextBuff1[0] = PLACEHOLDER_BEGIN;
+ gBattleTextBuff1[1] = 4;
+ gBattleTextBuff1[2] = gActiveBank;
+ gBattleTextBuff1[3] = gBattleStruct->expGetterId;
+ gBattleTextBuff1[4] = EOS;
+
+ // buff level
+ gBattleTextBuff2[0] = PLACEHOLDER_BEGIN;
+ gBattleTextBuff2[1] = 1;
+ gBattleTextBuff2[2] = 1;
+ gBattleTextBuff2[3] = 3;
+ gBattleTextBuff2[4] = GetMonData(&gPlayerParty[gBattleStruct->expGetterId], MON_DATA_LEVEL);
+ gBattleTextBuff2[5] = EOS;
+
+ BattleScriptPushCursor();
+ gLeveledUpInBattle |= gBitTable[gBattleStruct->expGetterId];
+ gBattlescriptCurrInstr = BattleScript_LevelUp;
+ gBattleMoveDamage = (gBattleBufferB[gActiveBank][2] | (gBattleBufferB[gActiveBank][3] << 8));
+ AdjustFriendship(&gPlayerParty[gBattleStruct->expGetterId], 0);
+
+ // update battle mon structure after level up
+ if (gBattlePartyID[0] == gBattleStruct->expGetterId && gBattleMons[0].hp)
+ {
+ gBattleMons[0].level = GetMonData(&gPlayerParty[gBattleStruct->expGetterId], MON_DATA_LEVEL);
+ gBattleMons[0].hp = GetMonData(&gPlayerParty[gBattleStruct->expGetterId], MON_DATA_HP);
+ gBattleMons[0].maxHP = GetMonData(&gPlayerParty[gBattleStruct->expGetterId], MON_DATA_MAX_HP);
+ gBattleMons[0].attack = GetMonData(&gPlayerParty[gBattleStruct->expGetterId], MON_DATA_ATK);
+ gBattleMons[0].defense = GetMonData(&gPlayerParty[gBattleStruct->expGetterId], MON_DATA_DEF);
+ // Why is this duplicated?
+ gBattleMons[0].speed = GetMonData(&gPlayerParty[gBattleStruct->expGetterId], MON_DATA_SPD);
+ gBattleMons[0].speed = GetMonData(&gPlayerParty[gBattleStruct->expGetterId], MON_DATA_SPD);
+
+ gBattleMons[0].spAttack = GetMonData(&gPlayerParty[gBattleStruct->expGetterId], MON_DATA_SPATK);
+ gBattleMons[0].spDefense = GetMonData(&gPlayerParty[gBattleStruct->expGetterId], MON_DATA_SPDEF);
+ }
+ // What is else if?
+ if (gBattlePartyID[2] == gBattleStruct->expGetterId && gBattleMons[2].hp && (gBattleTypeFlags & BATTLE_TYPE_DOUBLE))
+ {
+ gBattleMons[2].level = GetMonData(&gPlayerParty[gBattleStruct->expGetterId], MON_DATA_LEVEL);
+ gBattleMons[2].hp = GetMonData(&gPlayerParty[gBattleStruct->expGetterId], MON_DATA_HP);
+ gBattleMons[2].maxHP = GetMonData(&gPlayerParty[gBattleStruct->expGetterId], MON_DATA_MAX_HP);
+ gBattleMons[2].attack = GetMonData(&gPlayerParty[gBattleStruct->expGetterId], MON_DATA_ATK);
+ gBattleMons[2].defense = GetMonData(&gPlayerParty[gBattleStruct->expGetterId], MON_DATA_DEF);
+ // Duplicated again, but this time there's no Sp Defense
+ gBattleMons[2].speed = GetMonData(&gPlayerParty[gBattleStruct->expGetterId], MON_DATA_SPD);
+ gBattleMons[2].speed = GetMonData(&gPlayerParty[gBattleStruct->expGetterId], MON_DATA_SPD);
+
+ gBattleMons[2].spAttack = GetMonData(&gPlayerParty[gBattleStruct->expGetterId], MON_DATA_SPATK);
+ }
+ gBattleScripting.atk23_state = 5;
+ }
+ else
+ {
+ gBattleMoveDamage = 0;
+ gBattleScripting.atk23_state = 5;
+ }
+ }
+ break;
+ case 5: // looper increment
+ if (gBattleMoveDamage) // there is exp to give, goto case 3 that gives exp
+ gBattleScripting.atk23_state = 3;
+ else
+ {
+ gBattleStruct->expGetterId++;
+ if (gBattleStruct->expGetterId <= 5)
+ gBattleScripting.atk23_state = 2; // loop again
+ else
+ gBattleScripting.atk23_state = 6; // we're done
+ }
+ break;
+ case 6: // increment instruction
+ if (gBattleExecBuffer == 0)
+ {
+ // not sure why gf clears the item and ability here
+ gBattleMons[gBank1].item = 0;
+ gBattleMons[gBank1].ability = 0;
+ gBattlescriptCurrInstr += 2;
+ }
+ break;
+ }
+}
+
+#ifdef NONMATCHING
+void atk24(void)
+{
+ u16 HP_count = 0;
+ s32 i;
+
+ if (gBattleExecBuffer)
+ return;
+
+ if (gBattleTypeFlags & BATTLE_TYPE_INGAME_PARTNER && gPartnerTrainerId == STEVEN_PARTNER_ID)
+ {
+ for (i = 0; i < 3; i++)
+ {
+ if (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES) && !GetMonData(&gPlayerParty[i], MON_DATA_IS_EGG))
+ HP_count += GetMonData(&gPlayerParty[i], MON_DATA_HP);
+ }
+ }
+ else
+ {
+ for (i = 0; i < 6; i++)
+ {
+ if (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES) && !GetMonData(&gPlayerParty[i], MON_DATA_IS_EGG)
+ && (!(gBattleTypeFlags & BATTLE_TYPE_ARENA) || !(gBattleStruct->field_2A0 & gBitTable[i])))
+ {
+ HP_count += GetMonData(&gPlayerParty[i], MON_DATA_HP);
+ }
+ }
+ }
+
+ if (HP_count == 0)
+ gBattleOutcome |= BATTLE_LOST;
+
+ for (HP_count = 0, i = 0; i < 6; i++)
+ {
+ if (GetMonData(&gEnemyParty[i], MON_DATA_SPECIES) && !GetMonData(&gEnemyParty[i], MON_DATA_IS_EGG)
+ && (!(gBattleTypeFlags & BATTLE_TYPE_ARENA) || !(gBattleStruct->field_2A1 & gBitTable[i])))
+ {
+ HP_count += GetMonData(&gEnemyParty[i], MON_DATA_HP);
+ }
+ }
+
+ if (HP_count == 0)
+ gBattleOutcome |= BATTLE_WON;
+
+ if (gBattleOutcome == 0 && (gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_x2000000)))
+ {
+ s32 foundPlayer;
+ s32 foundOpponent;
+
+ // Impossible to decompile loops.
+ for (foundPlayer = 0, i = 0; i < gNoOfAllBanks; i += 2)
+ {
+ if (HITMARKER_UNK(i) & gHitMarker && !gSpecialStatuses[i].flag40)
+ foundPlayer++;
+ }
+
+ for (foundOpponent = 0, i = 1; i < gNoOfAllBanks; i += 2)
+ {
+ if (HITMARKER_UNK(i) & gHitMarker && !gSpecialStatuses[i].flag40)
+ foundOpponent++;
+ }
+
+ if (gBattleTypeFlags & BATTLE_TYPE_MULTI)
+ {
+ if (foundOpponent + foundPlayer > 1)
+ gBattlescriptCurrInstr = BS2ScriptReadPtr(gBattlescriptCurrInstr + 1);
+ else
+ gBattlescriptCurrInstr += 5;
+ }
+ else
+ {
+ if (foundOpponent != 0 && foundPlayer != 0)
+ gBattlescriptCurrInstr = BS2ScriptReadPtr(gBattlescriptCurrInstr + 1);
+ else
+ gBattlescriptCurrInstr += 5;
+ }
+ }
+ else
+ {
+ gBattlescriptCurrInstr += 5;
+ }
+}
+#else
+__attribute__((naked))
+void atk24(void)
+{
+ asm("\n\
+ .syntax unified\n\
+ push {r4-r7,lr}\n\
+ mov r7, r8\n\
+ push {r7}\n\
+ movs r6, 0\n\
+ ldr r0, =gBattleExecBuffer\n\
+ ldr r0, [r0]\n\
+ cmp r0, 0\n\
+ beq _0804ACE2\n\
+ b _0804AF22\n\
+ _0804ACE2:\n\
+ ldr r0, =gBattleTypeFlags\n\
+ ldr r0, [r0]\n\
+ movs r1, 0x80\n\
+ lsls r1, 15\n\
+ ands r0, r1\n\
+ cmp r0, 0\n\
+ beq _0804AD48\n\
+ ldr r0, =gPartnerTrainerId\n\
+ ldrh r1, [r0]\n\
+ ldr r0, =0x00000c03\n\
+ cmp r1, r0\n\
+ bne _0804AD48\n\
+ movs r5, 0\n\
+ _0804ACFC:\n\
+ movs r0, 0x64\n\
+ adds r1, r5, 0\n\
+ muls r1, r0\n\
+ ldr r0, =gPlayerParty\n\
+ adds r4, r1, r0\n\
+ adds r0, r4, 0\n\
+ movs r1, 0xB\n\
+ bl GetMonData\n\
+ cmp r0, 0\n\
+ beq _0804AD2C\n\
+ adds r0, r4, 0\n\
+ movs r1, 0x2D\n\
+ bl GetMonData\n\
+ cmp r0, 0\n\
+ bne _0804AD2C\n\
+ adds r0, r4, 0\n\
+ movs r1, 0x39\n\
+ bl GetMonData\n\
+ adds r0, r6, r0\n\
+ lsls r0, 16\n\
+ lsrs r6, r0, 16\n\
+ _0804AD2C:\n\
+ adds r5, 0x1\n\
+ cmp r5, 0x2\n\
+ ble _0804ACFC\n\
+ b _0804ADA8\n\
+ .pool\n\
+ _0804AD48:\n\
+ movs r5, 0\n\
+ _0804AD4A:\n\
+ movs r0, 0x64\n\
+ adds r1, r5, 0\n\
+ muls r1, r0\n\
+ ldr r0, =gPlayerParty\n\
+ adds r4, r1, r0\n\
+ adds r0, r4, 0\n\
+ movs r1, 0xB\n\
+ bl GetMonData\n\
+ cmp r0, 0\n\
+ beq _0804ADA2\n\
+ adds r0, r4, 0\n\
+ movs r1, 0x2D\n\
+ bl GetMonData\n\
+ cmp r0, 0\n\
+ bne _0804ADA2\n\
+ ldr r0, =gBattleTypeFlags\n\
+ ldr r0, [r0]\n\
+ movs r1, 0x80\n\
+ lsls r1, 11\n\
+ ands r0, r1\n\
+ cmp r0, 0\n\
+ beq _0804AD94\n\
+ ldr r0, =gBattleStruct\n\
+ ldr r0, [r0]\n\
+ movs r1, 0xA8\n\
+ lsls r1, 2\n\
+ adds r0, r1\n\
+ ldrb r1, [r0]\n\
+ ldr r2, =gBitTable\n\
+ lsls r0, r5, 2\n\
+ adds r0, r2\n\
+ ldr r0, [r0]\n\
+ ands r1, r0\n\
+ cmp r1, 0\n\
+ bne _0804ADA2\n\
+ _0804AD94:\n\
+ adds r0, r4, 0\n\
+ movs r1, 0x39\n\
+ bl GetMonData\n\
+ adds r0, r6, r0\n\
+ lsls r0, 16\n\
+ lsrs r6, r0, 16\n\
+ _0804ADA2:\n\
+ adds r5, 0x1\n\
+ cmp r5, 0x5\n\
+ ble _0804AD4A\n\
+ _0804ADA8:\n\
+ cmp r6, 0\n\
+ bne _0804ADB6\n\
+ ldr r0, =gBattleOutcome\n\
+ ldrb r1, [r0]\n\
+ movs r2, 0x2\n\
+ orrs r1, r2\n\
+ strb r1, [r0]\n\
+ _0804ADB6:\n\
+ movs r6, 0\n\
+ movs r5, 0\n\
+ _0804ADBA:\n\
+ movs r0, 0x64\n\
+ adds r1, r5, 0\n\
+ muls r1, r0\n\
+ ldr r0, =gEnemyParty\n\
+ adds r4, r1, r0\n\
+ adds r0, r4, 0\n\
+ movs r1, 0xB\n\
+ bl GetMonData\n\
+ cmp r0, 0\n\
+ beq _0804AE10\n\
+ adds r0, r4, 0\n\
+ movs r1, 0x2D\n\
+ bl GetMonData\n\
+ cmp r0, 0\n\
+ bne _0804AE10\n\
+ ldr r0, =gBattleTypeFlags\n\
+ ldr r0, [r0]\n\
+ movs r1, 0x80\n\
+ lsls r1, 11\n\
+ ands r0, r1\n\
+ cmp r0, 0\n\
+ beq _0804AE02\n\
+ ldr r0, =gBattleStruct\n\
+ ldr r0, [r0]\n\
+ ldr r1, =0x000002a1\n\
+ adds r0, r1\n\
+ ldrb r1, [r0]\n\
+ ldr r2, =gBitTable\n\
+ lsls r0, r5, 2\n\
+ adds r0, r2\n\
+ ldr r0, [r0]\n\
+ ands r1, r0\n\
+ cmp r1, 0\n\
+ bne _0804AE10\n\
+ _0804AE02:\n\
+ adds r0, r4, 0\n\
+ movs r1, 0x39\n\
+ bl GetMonData\n\
+ adds r0, r6, r0\n\
+ lsls r0, 16\n\
+ lsrs r6, r0, 16\n\
+ _0804AE10:\n\
+ adds r5, 0x1\n\
+ cmp r5, 0x5\n\
+ ble _0804ADBA\n\
+ ldr r2, =gBattleOutcome\n\
+ cmp r6, 0\n\
+ bne _0804AE24\n\
+ ldrb r0, [r2]\n\
+ movs r1, 0x1\n\
+ orrs r0, r1\n\
+ strb r0, [r2]\n\
+ _0804AE24:\n\
+ ldrb r0, [r2]\n\
+ cmp r0, 0\n\
+ bne _0804AF1A\n\
+ ldr r0, =gBattleTypeFlags\n\
+ ldr r1, [r0]\n\
+ ldr r2, =0x02000002\n\
+ ands r1, r2\n\
+ mov r8, r0\n\
+ cmp r1, 0\n\
+ beq _0804AF1A\n\
+ movs r3, 0\n\
+ movs r5, 0\n\
+ ldr r0, =gNoOfAllBanks\n\
+ ldrb r1, [r0]\n\
+ mov r12, r0\n\
+ ldr r7, =gBattlescriptCurrInstr\n\
+ cmp r3, r1\n\
+ bge _0804AE70\n\
+ ldr r0, =gHitMarker\n\
+ movs r6, 0x80\n\
+ lsls r6, 21\n\
+ ldr r4, [r0]\n\
+ adds r2, r1, 0\n\
+ ldr r1, =gSpecialStatuses\n\
+ _0804AE54:\n\
+ adds r0, r6, 0\n\
+ lsls r0, r5\n\
+ ands r0, r4\n\
+ cmp r0, 0\n\
+ beq _0804AE68\n\
+ ldrb r0, [r1]\n\
+ lsls r0, 25\n\
+ cmp r0, 0\n\
+ blt _0804AE68\n\
+ adds r3, 0x1\n\
+ _0804AE68:\n\
+ adds r1, 0x28\n\
+ adds r5, 0x2\n\
+ cmp r5, r2\n\
+ blt _0804AE54\n\
+ _0804AE70:\n\
+ movs r2, 0\n\
+ movs r5, 0x1\n\
+ mov r4, r12\n\
+ ldrb r1, [r4]\n\
+ cmp r5, r1\n\
+ bge _0804AEAA\n\
+ ldr r0, =gHitMarker\n\
+ movs r4, 0x80\n\
+ lsls r4, 21\n\
+ mov r12, r4\n\
+ ldr r6, [r0]\n\
+ ldr r0, =gSpecialStatuses\n\
+ adds r4, r1, 0\n\
+ adds r1, r0, 0\n\
+ adds r1, 0x14\n\
+ _0804AE8E:\n\
+ mov r0, r12\n\
+ lsls r0, r5\n\
+ ands r0, r6\n\
+ cmp r0, 0\n\
+ beq _0804AEA2\n\
+ ldrb r0, [r1]\n\
+ lsls r0, 25\n\
+ cmp r0, 0\n\
+ blt _0804AEA2\n\
+ adds r2, 0x1\n\
+ _0804AEA2:\n\
+ adds r1, 0x28\n\
+ adds r5, 0x2\n\
+ cmp r5, r4\n\
+ blt _0804AE8E\n\
+ _0804AEAA:\n\
+ mov r1, r8\n\
+ ldr r0, [r1]\n\
+ movs r1, 0x40\n\
+ ands r0, r1\n\
+ cmp r0, 0\n\
+ beq _0804AEF0\n\
+ adds r0, r2, r3\n\
+ cmp r0, 0x1\n\
+ bgt _0804AEF8\n\
+ b _0804AF12\n\
+ .pool\n\
+ _0804AEF0:\n\
+ cmp r2, 0\n\
+ beq _0804AF12\n\
+ cmp r3, 0\n\
+ beq _0804AF12\n\
+ _0804AEF8:\n\
+ ldr r2, [r7]\n\
+ ldrb r1, [r2, 0x1]\n\
+ ldrb r0, [r2, 0x2]\n\
+ lsls r0, 8\n\
+ adds r1, r0\n\
+ ldrb r0, [r2, 0x3]\n\
+ lsls r0, 16\n\
+ adds r1, r0\n\
+ ldrb r0, [r2, 0x4]\n\
+ lsls r0, 24\n\
+ adds r1, r0\n\
+ str r1, [r7]\n\
+ b _0804AF22\n\
+ _0804AF12:\n\
+ ldr r0, [r7]\n\
+ adds r0, 0x5\n\
+ str r0, [r7]\n\
+ b _0804AF22\n\
+ _0804AF1A:\n\
+ ldr r1, =gBattlescriptCurrInstr\n\
+ ldr r0, [r1]\n\
+ adds r0, 0x5\n\
+ str r0, [r1]\n\
+ _0804AF22:\n\
+ pop {r3}\n\
+ mov r8, r3\n\
+ pop {r4-r7}\n\
+ pop {r0}\n\
+ bx r0\n\
+ .pool\n\
+ .syntax divided");
+}
+
+#endif // NONMATCHING
+
+void MoveValuesCleanUp(void)
+{
+ gBattleMoveFlags = 0;
+ gBattleScripting.dmgMultiplier = 1;
+ gCritMultiplier = 1;
+ gBattleCommunication[MOVE_EFFECT_BYTE] = 0;
+ gBattleCommunication[6] = 0;
+ gHitMarker &= ~(HITMARKER_DESTINYBOND);
+ gHitMarker &= ~(HITMARKER_SYNCHRONISE_EFFECT);
+}
+
+void atk25_move_values_cleanup(void)
+{
+ MoveValuesCleanUp();
+ gBattlescriptCurrInstr += 1;
+}
+
+void atk26_set_multihit(void)
+{
+ gMultiHitCounter = BSScriptRead8(gBattlescriptCurrInstr + 1);
+ gBattlescriptCurrInstr += 2;
+}
+
+void atk27_decrement_multihit(void)
+{
+ if (--gMultiHitCounter == 0)
+ gBattlescriptCurrInstr += 5;
+ else
+ gBattlescriptCurrInstr = BS2ScriptReadPtr(gBattlescriptCurrInstr + 1);
+}
+
+void atk28_goto(void)
+{
+ gBattlescriptCurrInstr = BS2ScriptReadPtr(gBattlescriptCurrInstr + 1);
+}
+
+void atk29_jumpifbyte(void)
+{
+ u8 caseID = BSScriptRead8(gBattlescriptCurrInstr + 1);
+ const u8* memByte = BS2ScriptReadPtr(gBattlescriptCurrInstr + 2);
+ u8 value = BSScriptRead8(gBattlescriptCurrInstr + 6);
+ const u8* jumpPtr = BS2ScriptReadPtr(gBattlescriptCurrInstr + 7);
+
+ gBattlescriptCurrInstr += 11;
+
+ switch (caseID)
+ {
+ case CMP_EQUAL:
+ if (*memByte == value)
+ gBattlescriptCurrInstr = jumpPtr;
+ break;
+ case CMP_NOT_EQUAL:
+ if (*memByte != value)
+ gBattlescriptCurrInstr = jumpPtr;
+ break;
+ case CMP_GREATER_THAN:
+ if (*memByte > value)
+ gBattlescriptCurrInstr = jumpPtr;
+ break;
+ case CMP_LESS_THAN:
+ if (*memByte < value)
+ gBattlescriptCurrInstr = jumpPtr;
+ break;
+ case CMP_COMMON_BITS:
+ if (*memByte & value)
+ gBattlescriptCurrInstr = jumpPtr;
+ break;
+ case CMP_NO_COMMON_BITS:
+ if (!(*memByte & value))
+ gBattlescriptCurrInstr = jumpPtr;
+ break;
+ }
+}
+
+void atk2A_jumpifhalfword(void)
+{
+ u8 caseID = BSScriptRead8(gBattlescriptCurrInstr + 1);
+ const u16* memHword = BS2ScriptReadPtr(gBattlescriptCurrInstr + 2);
+ u16 value = BS2ScriptRead16(gBattlescriptCurrInstr + 6);
+ const u8* jumpPtr = BS2ScriptReadPtr(gBattlescriptCurrInstr + 8);
+
+ gBattlescriptCurrInstr += 12;
+
+ switch (caseID)
+ {
+ case CMP_EQUAL:
+ if (*memHword == value)
+ gBattlescriptCurrInstr = jumpPtr;
+ break;
+ case CMP_NOT_EQUAL:
+ if (*memHword != value)
+ gBattlescriptCurrInstr = jumpPtr;
+ break;
+ case CMP_GREATER_THAN:
+ if (*memHword > value)
+ gBattlescriptCurrInstr = jumpPtr;
+ break;
+ case CMP_LESS_THAN:
+ if (*memHword < value)
+ gBattlescriptCurrInstr = jumpPtr;
+ break;
+ case CMP_COMMON_BITS:
+ if (*memHword & value)
+ gBattlescriptCurrInstr = jumpPtr;
+ break;
+ case CMP_NO_COMMON_BITS:
+ if (!(*memHword & value))
+ gBattlescriptCurrInstr = jumpPtr;
+ break;
+ }
+}
+
+void atk2B_jumpifword(void)
+{
+ u8 caseID = BSScriptRead8(gBattlescriptCurrInstr + 1);
+ const u32* memWord = BS2ScriptReadPtr(gBattlescriptCurrInstr + 2);
+ u32 value = BSScriptRead32(gBattlescriptCurrInstr + 6);
+ const u8* jumpPtr = BS2ScriptReadPtr(gBattlescriptCurrInstr + 10);
+
+ gBattlescriptCurrInstr += 14;
+
+ switch (caseID)
+ {
+ case CMP_EQUAL:
+ if (*memWord == value)
+ gBattlescriptCurrInstr = jumpPtr;
+ break;
+ case CMP_NOT_EQUAL:
+ if (*memWord != value)
+ gBattlescriptCurrInstr = jumpPtr;
+ break;
+ case CMP_GREATER_THAN:
+ if (*memWord > value)
+ gBattlescriptCurrInstr = jumpPtr;
+ break;
+ case CMP_LESS_THAN:
+ if (*memWord < value)
+ gBattlescriptCurrInstr = jumpPtr;
+ break;
+ case CMP_COMMON_BITS:
+ if (*memWord & value)
+ gBattlescriptCurrInstr = jumpPtr;
+ break;
+ case CMP_NO_COMMON_BITS:
+ if (!(*memWord & value))
+ gBattlescriptCurrInstr = jumpPtr;
+ break;
+ }
+}
+
+void atk2C_jumpifarrayequal(void)
+{
+ const u8* mem1 = BS2ScriptReadPtr(gBattlescriptCurrInstr + 1);
+ const u8* mem2 = BS2ScriptReadPtr(gBattlescriptCurrInstr + 5);
+ u32 size = BSScriptRead8(gBattlescriptCurrInstr + 9);
+ const u8* jumpPtr = BS2ScriptReadPtr(gBattlescriptCurrInstr + 10);
+
+ u8 i;
+ for (i = 0; i < size; i++)
+ {
+ if (*mem1 != *mem2)
+ {
+ gBattlescriptCurrInstr += 14;
+ break;
+ }
+ mem1++, mem2++;
+ }
+
+ if (i == size)
+ gBattlescriptCurrInstr = jumpPtr;
+}
+
+void atk2D_jumpifarraynotequal(void)
+{
+ u8 equalBytes = 0;
+ const u8* mem1 = BS2ScriptReadPtr(gBattlescriptCurrInstr + 1);
+ const u8* mem2 = BS2ScriptReadPtr(gBattlescriptCurrInstr + 5);
+ u32 size = BSScriptRead8(gBattlescriptCurrInstr + 9);
+ const u8* jumpPtr = BS2ScriptReadPtr(gBattlescriptCurrInstr + 10);
+
+ u8 i;
+ for (i = 0; i < size; i++)
+ {
+ if (*mem1 == *mem2)
+ {
+ equalBytes++;
+ }
+ mem1++, mem2++;
+ }
+
+ if (equalBytes != size)
+ gBattlescriptCurrInstr = jumpPtr;
+ else
+ gBattlescriptCurrInstr += 14;
+}
+
+void atk2E_setbyte(void)
+{
+ u8* memByte = BS2ScriptReadPtr(gBattlescriptCurrInstr + 1);
+ *memByte = BSScriptRead8(gBattlescriptCurrInstr + 5);
+
+ gBattlescriptCurrInstr += 6;
+}
+
+void atk2F_addbyte(void)
+{
+ u8* memByte = BS2ScriptReadPtr(gBattlescriptCurrInstr + 1);
+ *memByte += BSScriptRead8(gBattlescriptCurrInstr + 5);
+ gBattlescriptCurrInstr += 6;
+}
+
+void atk30_subbyte(void)
+{
+ u8* memByte = BS2ScriptReadPtr(gBattlescriptCurrInstr + 1);
+ *memByte -= BSScriptRead8(gBattlescriptCurrInstr + 5);
+ gBattlescriptCurrInstr += 6;
+}
+
+void atk31_copyarray(void)
+{
+ u8* dest = BS2ScriptReadPtr(gBattlescriptCurrInstr + 1);
+ const u8* src = BS2ScriptReadPtr(gBattlescriptCurrInstr + 5);
+ s32 size = BSScriptRead8(gBattlescriptCurrInstr + 9);
+
+ s32 i;
+ for (i = 0; i < size; i++)
+ {
+ dest[i] = src[i];
+ }
+
+ gBattlescriptCurrInstr += 10;
+}
+
+void atk32_copyarray_withindex(void)
+{
+ u8* dest = BS2ScriptReadPtr(gBattlescriptCurrInstr + 1);
+ const u8* src = BS2ScriptReadPtr(gBattlescriptCurrInstr + 5);
+ const u8* index = BS2ScriptReadPtr(gBattlescriptCurrInstr + 9);
+ s32 size = BSScriptRead8(gBattlescriptCurrInstr + 13);
+
+ s32 i;
+ for (i = 0; i < size; i++)
+ {
+ dest[i] = src[i + *index];
+ }
+
+ gBattlescriptCurrInstr += 14;
+}
+
+void atk33_orbyte(void)
+{
+ u8* memByte = BS2ScriptReadPtr(gBattlescriptCurrInstr + 1);
+ *memByte |= BSScriptRead8(gBattlescriptCurrInstr + 5);
+ gBattlescriptCurrInstr += 6;
+}
+
+void atk34_orhalfword(void)
+{
+ u16* memHword = BS2ScriptReadPtr(gBattlescriptCurrInstr + 1);
+ u16 val = BS2ScriptRead16(gBattlescriptCurrInstr + 5);
+
+ *memHword |= val;
+ gBattlescriptCurrInstr += 7;
+}
+
+void atk35_orword(void)
+{
+ u32* memWord = BS2ScriptReadPtr(gBattlescriptCurrInstr + 1);
+ u32 val = BS2ScriptRead32(gBattlescriptCurrInstr + 5);
+
+ *memWord |= val;
+ gBattlescriptCurrInstr += 9;
+}
+
+void atk36_bicbyte(void)
+{
+ u8* memByte = BS2ScriptReadPtr(gBattlescriptCurrInstr + 1);
+ *memByte &= ~(BSScriptRead8(gBattlescriptCurrInstr + 5));
+ gBattlescriptCurrInstr += 6;
+}
+
+void atk37_bichalfword(void)
+{
+ u16* memHword = BS2ScriptReadPtr(gBattlescriptCurrInstr + 1);
+ u16 val = BS2ScriptRead16(gBattlescriptCurrInstr + 5);
+
+ *memHword &= ~val;
+ gBattlescriptCurrInstr += 7;
+}
+
+void atk38_bicword(void)
+{
+ u32* memWord = BS2ScriptReadPtr(gBattlescriptCurrInstr + 1);
+ u32 val = BS2ScriptRead32(gBattlescriptCurrInstr + 5);
+
+ *memWord &= ~val;
+ gBattlescriptCurrInstr += 9;
+}
+
+void atk39_pause(void)
+{
+ if (gBattleExecBuffer == 0)
+ {
+ u16 value = BS2ScriptRead16(gBattlescriptCurrInstr + 1);
+ if (++gPauseCounterBattle >= value)
+ {
+ gPauseCounterBattle = 0;
+ gBattlescriptCurrInstr += 3;
+ }
+ }
+}
+
+void atk3A_waitstate(void)
+{
+ if (gBattleExecBuffer == 0)
+ gBattlescriptCurrInstr++;
+}
+
+void atk3B_healthbar_update(void)
+{
+ if (BSScriptRead8(gBattlescriptCurrInstr + 1) == BS_GET_TARGET)
+ gActiveBank = gBankTarget;
+ else
+ gActiveBank = gBankAttacker;
+
+ EmitHealthBarUpdate(0, gBattleMoveDamage);
+ MarkBufferBankForExecution(gActiveBank);
+ gBattlescriptCurrInstr += 2;
+}
+
+void atk3C_return(void)
+{
+ BattleScriptPop();
+}
+
+void atk3D_end(void)
+{
+ if (gBattleTypeFlags & BATTLE_TYPE_ARENA)
+ sub_81A5718(gBankAttacker);
+
+ gBattleMoveFlags = 0;
+ gActiveBank = 0;
+ gFightStateTracker = 0xB;
+}
+
+void atk3E_end2(void)
+{
+ gActiveBank = 0;
+ gFightStateTracker = 0xB;
+}
+
+void atk3F_end3(void) // pops the main function stack
+{
+ BattleScriptPop();
+ if (BATTLE_CALLBACKS_STACK->size)
+ BATTLE_CALLBACKS_STACK->size--;
+ gBattleMainFunc = BATTLE_CALLBACKS_STACK->function[BATTLE_CALLBACKS_STACK->size];
+}
+
+void atk41_call(void)
+{
+ BattleScriptPush(gBattlescriptCurrInstr + 5);
+ gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1);
+}
+
+void atk42_jumpiftype2(void)
+{
+ u8 bank = GetBattleBank(BSScriptRead8(gBattlescriptCurrInstr + 1));
+
+ if (BSScriptRead8(gBattlescriptCurrInstr + 2) == gBattleMons[bank].type1 || BSScriptRead8(gBattlescriptCurrInstr + 2) == gBattleMons[bank].type2)
+ gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 3);
+ else
+ gBattlescriptCurrInstr += 7;
+}
+
+void atk43_jumpifabilitypresent(void)
+{
+ if (AbilityBattleEffects(ABILITYEFFECT_CHECK_ON_FIELD, 0, BSScriptRead8(gBattlescriptCurrInstr + 1), 0, 0))
+ gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 2);
+ else
+ gBattlescriptCurrInstr += 6;
+}
+
+void atk44(void)
+{
+ *(gBankAttacker + gBattleStruct->field_54) = 1;
+}
+
+void atk45_playanimation(void)
+{
+ const u16* argumentPtr;
+
+ gActiveBank = GetBattleBank(BSScriptRead8(gBattlescriptCurrInstr + 1));
+ argumentPtr = BS2ScriptReadPtr(gBattlescriptCurrInstr + 3);
+
+ if (gBattlescriptCurrInstr[2] == B_ANIM_STATS_CHANGE
+ || gBattlescriptCurrInstr[2] == B_ANIM_SNATCH_MOVE
+ || gBattlescriptCurrInstr[2] == B_ANIM_SUBSTITUTE_FADE)
+ {
+ EmitBattleAnimation(0, gBattlescriptCurrInstr[2], *argumentPtr);
+ MarkBufferBankForExecution(gActiveBank);
+ gBattlescriptCurrInstr += 7;
+ }
+ else if (gHitMarker & HITMARKER_NO_ANIMATIONS)
+ {
+ BattleScriptPush(gBattlescriptCurrInstr + 7);
+ gBattlescriptCurrInstr = BattleScript_Pausex20;
+ }
+ else if (gBattlescriptCurrInstr[2] == B_ANIM_RAIN_CONTINUES
+ || gBattlescriptCurrInstr[2] == B_ANIM_SUN_CONTINUES
+ || gBattlescriptCurrInstr[2] == B_ANIM_SANDSTORM_CONTINUES
+ || gBattlescriptCurrInstr[2] == B_ANIM_HAIL_CONTINUES)
+ {
+ EmitBattleAnimation(0, gBattlescriptCurrInstr[2], *argumentPtr);
+ MarkBufferBankForExecution(gActiveBank);
+ gBattlescriptCurrInstr += 7;
+ }
+ else if (gStatuses3[gActiveBank] & STATUS3_SEMI_INVULNERABLE)
+ {
+ gBattlescriptCurrInstr += 7;
+ }
+ else
+ {
+ EmitBattleAnimation(0, gBattlescriptCurrInstr[2], *argumentPtr);
+ MarkBufferBankForExecution(gActiveBank);
+ gBattlescriptCurrInstr += 7;
+ }
+}
+
+void atk46_playanimation2(void) // animation Id is stored in the first pointer
+{
+ const u16* argumentPtr;
+ const u8* animationIdPtr;
+
+ gActiveBank = GetBattleBank(BSScriptRead8(gBattlescriptCurrInstr + 1));
+ animationIdPtr = BS2ScriptReadPtr(gBattlescriptCurrInstr + 2);
+ argumentPtr = BS2ScriptReadPtr(gBattlescriptCurrInstr + 6);
+
+ if (*animationIdPtr == B_ANIM_STATS_CHANGE
+ || *animationIdPtr == B_ANIM_SNATCH_MOVE
+ || *animationIdPtr == B_ANIM_SUBSTITUTE_FADE)
+ {
+ EmitBattleAnimation(0, *animationIdPtr, *argumentPtr);
+ MarkBufferBankForExecution(gActiveBank);
+ gBattlescriptCurrInstr += 10;
+ }
+ else if (gHitMarker & HITMARKER_NO_ANIMATIONS)
+ {
+ gBattlescriptCurrInstr += 10;
+ }
+ else if (*animationIdPtr == B_ANIM_RAIN_CONTINUES
+ || *animationIdPtr == B_ANIM_SUN_CONTINUES
+ || *animationIdPtr == B_ANIM_SANDSTORM_CONTINUES
+ || *animationIdPtr == B_ANIM_HAIL_CONTINUES)
+ {
+ EmitBattleAnimation(0, *animationIdPtr, *argumentPtr);
+ MarkBufferBankForExecution(gActiveBank);
+ gBattlescriptCurrInstr += 10;
+ }
+ else if (gStatuses3[gActiveBank] & STATUS3_SEMI_INVULNERABLE)
+ {
+ gBattlescriptCurrInstr += 10;
+ }
+ else
+ {
+ EmitBattleAnimation(0, *animationIdPtr, *argumentPtr);
+ MarkBufferBankForExecution(gActiveBank);
+ gBattlescriptCurrInstr += 10;
+ }
+}
+
+void atk47_setgraphicalstatchangevalues(void)
+{
+ u8 value = 0;
+ switch (gBattleScripting.statChanger & 0xF0)
+ {
+ case 0x10: // +1
+ value = 0xF;
+ break;
+ case 0x20: // +2
+ value = 0x27;
+ break;
+ case 0x90: // -1
+ value = 0x16;
+ break;
+ case 0xA0: // -2
+ value = 0x2E;
+ break;
+ }
+ gBattleScripting.animArg1 = (gBattleScripting.statChanger & 0xF) + value - 1;
+ gBattleScripting.animArg2 = 0;
+ gBattlescriptCurrInstr++;
+}
+
+void atk48_playstatchangeanimation(void)
+{
+ s32 currStat = 0;
+ s16 statAnimId = 0;
+ s32 checkingStatAnimId = 0;
+ s32 changeableStats = 0;
+ u32 statsToCheck = 0;
+
+ gActiveBank = GetBattleBank(BSScriptRead8(gBattlescriptCurrInstr + 1));
+ statsToCheck = BSScriptRead8(gBattlescriptCurrInstr + 2);
+
+ if (gBattlescriptCurrInstr[3] & 1) // goes down
+ {
+ for (checkingStatAnimId = (gBattlescriptCurrInstr[3] & 0x2) ? 0x2D : 0x15;
+ statsToCheck != 0;
+ statsToCheck >>= 1, checkingStatAnimId += 1, currStat++)
+ {
+ if (!(statsToCheck & 1))
+ continue;
+ if (!(gBattlescriptCurrInstr[3] & 8))
+ {
+ if (gBattleMons[gActiveBank].statStages[currStat] > 0)
+ {
+ statAnimId = checkingStatAnimId;
+ changeableStats++;
+ }
+ }
+ else if (!gSideTimers[GET_BANK_SIDE(gActiveBank)].mistTimer
+ && gBattleMons[gActiveBank].ability != ABILITY_CLEAR_BODY
+ && gBattleMons[gActiveBank].ability != ABILITY_WHITE_SMOKE
+ && !(gBattleMons[gActiveBank].ability == ABILITY_KEEN_EYE && currStat == STAT_STAGE_ACC)
+ && !(gBattleMons[gActiveBank].ability == ABILITY_HYPER_CUTTER && currStat == STAT_STAGE_ATK))
+ {
+ if (gBattleMons[gActiveBank].statStages[currStat] > 0)
+ {
+ statAnimId = checkingStatAnimId;
+ changeableStats++;
+ }
+ }
+ }
+
+ if (changeableStats > 1) // more than one stat, so the color is gray
+ {
+ if (gBattlescriptCurrInstr[3] & 2)
+ statAnimId = 0x3A;
+ else
+ statAnimId = 0x39;
+ }
+ }
+ else // goes up
+ {
+ for (checkingStatAnimId = (gBattlescriptCurrInstr[3] & 0x2) ? 0x26 : 0xE;
+ statsToCheck != 0;
+ statsToCheck >>= 1, checkingStatAnimId += 1, currStat++)
+ {
+ if (statsToCheck & 1 && gBattleMons[gActiveBank].statStages[currStat] < 0xC)
+ {
+ statAnimId = checkingStatAnimId;
+ changeableStats++;
+ }
+ }
+
+ if (changeableStats > 1) // more than one stat, so the color is gray
+ {
+ if (gBattlescriptCurrInstr[3] & 2)
+ statAnimId = 0x38;
+ else
+ statAnimId = 0x37;
+ }
+ }
+
+ if (gBattlescriptCurrInstr[3] & 4 && changeableStats < 2)
+ {
+ gBattlescriptCurrInstr += 4;
+ }
+ else if (changeableStats != 0 && gBattleScripting.field_1B == 0)
+ {
+ EmitBattleAnimation(0, B_ANIM_STATS_CHANGE, statAnimId);
+ MarkBufferBankForExecution(gActiveBank);
+ if (gBattlescriptCurrInstr[3] & 4 && changeableStats > 1)
+ gBattleScripting.field_1B = 1;
+ gBattlescriptCurrInstr += 4;
+ }
+ else
+ {
+ gBattlescriptCurrInstr += 4;
+ }
+}
diff --git a/sym_common.txt b/sym_common.txt
index 23809c1a7..834f23918 100644
--- a/sym_common.txt
+++ b/sym_common.txt
@@ -218,7 +218,7 @@ gUnknown_03005D3A: @ 3005D3A
gUnknown_03005D46: @ 3005D46
.space 0xE
-gUnknown_03005D54: @ 3005D54
+gLeveledUpInBattle: @ 3005D54
.space 0xC
gBattleBankFunc: @ 3005D60
diff --git a/sym_ewram.txt b/sym_ewram.txt
index e1238a0cf..616b1ca80 100644
--- a/sym_ewram.txt
+++ b/sym_ewram.txt
@@ -475,13 +475,13 @@ gWishFutureKnock: @ 20243D0
gUnknown_020243FC: @ 20243FC
.space 0x2
-gUnknown_020243FE: @ 20243FE
+gSentPokesToOpponent: @ 20243FE
.space 0x2
gDynamicBasePower: @ 2024400
.space 0x2
-gUnknown_02024402: @ 2024402
+gExpShareExp: @ 2024402
.space 0x2
gEnigmaBerries: @ 2024404