From bc3b4b4d9ae6ab59c9ce3892b7d287ebd0ee13fa Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Thu, 28 Sep 2017 15:34:21 +0200 Subject: [PATCH] battle 4 commands are decompiled --- asm/battle_2.s | 30 +- asm/battle_4.s | 1923 ------------------------------ asm/battle_anim_80FE840.s | 30 +- asm/battle_frontier_1.s | 2 +- asm/contest.s | 4 +- asm/contest_link_80F57C4.s | 6 +- asm/evolution_scene.s | 14 +- asm/naming_screen.s | 6 +- asm/pokedex.s | 6 +- asm/pokemon_storage_system.s | 20 +- asm/pokenav.s | 4 +- asm/reshow_battle_screen.s | 4 +- asm/rom3.s | 12 +- asm/scrcmd.s | 2 +- asm/unknown_task.s | 2 +- data/battle_scripts_2.s | 8 +- include/battle.h | 33 +- include/battle_controllers.h | 13 +- include/battle_message.h | 2 + include/naming_screen.h | 12 + include/pokedex.h | 1 + include/pokemon_storage_system.h | 6 + ld_script.txt | 1 - src/battle_3.c | 172 ++- src/battle_4.c | 1888 +++++++++++++++++++---------- sym_ewram.txt | 2 +- 26 files changed, 1456 insertions(+), 2747 deletions(-) delete mode 100644 asm/battle_4.s create mode 100644 include/naming_screen.h create mode 100644 include/pokemon_storage_system.h diff --git a/asm/battle_2.s b/asm/battle_2.s index c96b80b1c..996579313 100644 --- a/asm/battle_2.s +++ b/asm/battle_2.s @@ -165,7 +165,7 @@ _080368BE: strh r1, [r0] ldr r0, =gBattle_BG2_Y strh r1, [r0] - ldr r0, =gUnknown_02022E20 + ldr r0, =gBattle_BG3_X strh r1, [r0] ldr r0, =gUnknown_02022E22 strh r1, [r0] @@ -191,7 +191,7 @@ _080368FE: ldr r1, =gReservedSpritePaletteCount movs r0, 0x4 strb r0, [r1] - ldr r0, =vblank_cb_08078BB4 + ldr r0, =VBlankCB_Battle bl SetVBlankCallback bl sub_803269C ldr r2, [r4] @@ -3906,8 +3906,8 @@ _08038A1E: .pool thumb_func_end sub_8038A04 - thumb_func_start vblank_cb_08078BB4 -vblank_cb_08078BB4: @ 8038A28 + thumb_func_start VBlankCB_Battle +VBlankCB_Battle: @ 8038A28 push {lr} ldr r0, =gBattleTypeFlags ldr r0, [r0] @@ -3941,7 +3941,7 @@ _08038A3A: ldrh r1, [r0] movs r0, 0x1A bl SetGpuReg - ldr r0, =gUnknown_02022E20 + ldr r0, =gBattle_BG3_X ldrh r1, [r0] movs r0, 0x1C bl SetGpuReg @@ -3972,7 +3972,7 @@ _08038A3A: pop {r0} bx r0 .pool - thumb_func_end vblank_cb_08078BB4 + thumb_func_end VBlankCB_Battle thumb_func_start nullsub_17 nullsub_17: @ 8038B00 @@ -4379,7 +4379,7 @@ _08038E1A: strh r4, [r0] ldr r0, =gBattle_BG2_Y strh r4, [r0] - ldr r0, =gUnknown_02022E20 + ldr r0, =gBattle_BG3_X strh r4, [r0] ldr r0, =gUnknown_02022E22 strh r4, [r0] @@ -4399,7 +4399,7 @@ _08038E1A: ldr r1, =gReservedSpritePaletteCount movs r0, 0x4 strb r0, [r1] - ldr r0, =vblank_cb_08078BB4 + ldr r0, =VBlankCB_Battle bl SetVBlankCallback ldr r0, =task00_0800F6FC movs r1, 0 @@ -4850,7 +4850,7 @@ sub_80392A8: @ 80392A8 strh r4, [r0] ldr r0, =gBattle_BG2_Y strh r4, [r0] - ldr r0, =gUnknown_02022E20 + ldr r0, =gBattle_BG3_X strh r4, [r0] ldr r0, =gUnknown_02022E22 strh r4, [r0] @@ -4873,7 +4873,7 @@ _080392FE: ldr r1, =gReservedSpritePaletteCount movs r0, 0x4 strb r0, [r1] - ldr r0, =vblank_cb_08078BB4 + ldr r0, =VBlankCB_Battle bl SetVBlankCallback ldr r0, =sub_803937C bl SetMainCallback2 @@ -9307,7 +9307,7 @@ _0803B866: beq _0803B8B2 bl StopCryAndClearCrySongs ldr r0, =gUnknown_082DB8BE - bl b_call_bc_move_exec + bl BattleScriptExecute _0803B8B2: add sp, 0x4 pop {r3-r5} @@ -9561,7 +9561,7 @@ _0803BAE6: cmp r0, 0 beq _0803BB5C ldr r0, =gUnknown_082DB881 - bl b_call_bc_move_exec + bl BattleScriptExecute b _0803BB78 .pool _0803BB5C: @@ -9577,7 +9577,7 @@ _0803BB5C: cmp r0, 0 bne _0803BB78 ldr r0, =gUnknown_082DB8BE - bl b_call_bc_move_exec + bl BattleScriptExecute _0803BB78: pop {r3,r4} mov r8, r3 @@ -10866,7 +10866,7 @@ _0803C720: cmp r0, 0x3 bne _0803C760 ldr r0, =gUnknown_082DAAFE - bl b_call_bc_move_exec + bl BattleScriptExecute ldr r1, =gBattleCommunication ldrb r0, [r4] adds r0, r1 @@ -12739,7 +12739,7 @@ _0803D71C: cmp r0, 0 blt _0803D7A0 ldr r0, =gUnknown_082DB1FF - bl b_call_bc_move_exec + bl BattleScriptExecute b _0803D7E8 .pool _0803D7A0: diff --git a/asm/battle_4.s b/asm/battle_4.s deleted file mode 100644 index 096c195b0..000000000 --- a/asm/battle_4.s +++ /dev/null @@ -1,1923 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .syntax unified - - .text - - thumb_func_start atkE6_castform_change_animation -atkE6_castform_change_animation: @ 8055DFC - push {r4,lr} - ldr r4, =gActiveBank - ldr r0, =gBattleScripting - ldrb r0, [r0, 0x17] - strb r0, [r4] - ldr r1, =gBattleMons - ldrb r2, [r4] - movs r0, 0x58 - muls r0, r2 - adds r1, 0x50 - adds r0, r1 - ldr r0, [r0] - movs r1, 0x80 - lsls r1, 17 - ands r0, r1 - ldr r3, =gBattleStruct - cmp r0, 0 - beq _08055E2C - ldr r0, [r3] - adds r0, 0x7F - ldrb r1, [r0] - movs r2, 0x80 - orrs r1, r2 - strb r1, [r0] -_08055E2C: - ldr r0, [r3] - adds r0, 0x7F - ldrb r2, [r0] - movs r0, 0 - movs r1, 0 - bl EmitBattleAnimation - ldrb r0, [r4] - bl MarkBufferBankForExecution - ldr r1, =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x1 - str r0, [r1] - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end atkE6_castform_change_animation - - thumb_func_start atkE7_castform_data_change -atkE7_castform_data_change: @ 8055E64 - push {r4,lr} - ldr r1, =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x1 - str r0, [r1] - ldr r0, =gBattleScripting - ldrb r0, [r0, 0x17] - bl CastformDataTypeChange - lsls r0, 24 - lsrs r4, r0, 24 - cmp r4, 0 - beq _08055E8E - ldr r0, =BattleScript_CastformChange - bl b_push_move_exec - ldr r0, =gBattleStruct - ldr r0, [r0] - adds r0, 0x7F - subs r1, r4, 0x1 - strb r1, [r0] -_08055E8E: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end atkE7_castform_data_change - - thumb_func_start atkE8_settypebasedhalvers -atkE8_settypebasedhalvers: @ 8055EA4 - push {r4,lr} - movs r4, 0 - 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] - cmp r0, 0xC9 - bne _08055EF4 - ldr r1, =gStatuses3 - ldr r0, =gBankAttacker - ldrb r0, [r0] - lsls r0, 2 - adds r2, r0, r1 - ldr r1, [r2] - movs r3, 0x80 - lsls r3, 9 - adds r0, r1, 0 - ands r0, r3 - cmp r0, 0 - bne _08055F18 - orrs r1, r3 - str r1, [r2] - ldr r0, =gBattleCommunication - strb r4, [r0, 0x5] - b _08055F1C - .pool -_08055EF4: - ldr r1, =gStatuses3 - ldr r0, =gBankAttacker - ldrb r0, [r0] - lsls r0, 2 - adds r2, r0, r1 - ldr r1, [r2] - movs r3, 0x80 - lsls r3, 10 - adds r0, r1, 0 - ands r0, r3 - cmp r0, 0 - bne _08055F18 - orrs r1, r3 - str r1, [r2] - ldr r1, =gBattleCommunication - movs r0, 0x1 - strb r0, [r1, 0x5] - movs r4, 0x1 -_08055F18: - cmp r4, 0 - beq _08055F38 -_08055F1C: - ldr r1, =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x5 - str r0, [r1] - b _08055F52 - .pool -_08055F38: - ldr r3, =gBattlescriptCurrInstr - ldr r2, [r3] - 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, [r3] -_08055F52: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end atkE8_settypebasedhalvers - - thumb_func_start atkE9_setweatherballtype -atkE9_setweatherballtype: @ 8055F5C - push {lr} - sub sp, 0x4 - 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 _08055FFC - str r0, [sp] - movs r0, 0x13 - movs r1, 0 - movs r2, 0x4D - movs r3, 0 - bl AbilityBattleEffects - lsls r0, 24 - cmp r0, 0 - bne _08055FFC - ldr r2, =gBattleWeather - ldrb r0, [r2] - cmp r0, 0 - beq _08055F9A - ldr r1, =gBattleScripting - movs r0, 0x2 - strb r0, [r1, 0xE] -_08055F9A: - ldrh r1, [r2] - movs r0, 0x7 - ands r0, r1 - cmp r0, 0 - beq _08055FB8 - ldr r0, =gBattleStruct - ldr r1, [r0] - movs r0, 0x8B - b _08055FFA - .pool -_08055FB8: - movs r0, 0x18 - ands r0, r1 - cmp r0, 0 - beq _08055FCC - ldr r0, =gBattleStruct - ldr r1, [r0] - movs r0, 0x85 - b _08055FFA - .pool -_08055FCC: - movs r0, 0x60 - ands r0, r1 - cmp r0, 0 - beq _08055FE0 - ldr r0, =gBattleStruct - ldr r1, [r0] - movs r0, 0x8A - b _08055FFA - .pool -_08055FE0: - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - beq _08055FF4 - ldr r0, =gBattleStruct - ldr r1, [r0] - movs r0, 0x8F - b _08055FFA - .pool -_08055FF4: - ldr r0, =gBattleStruct - ldr r1, [r0] - movs r0, 0x80 -_08055FFA: - strb r0, [r1, 0x13] -_08055FFC: - ldr r1, =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x1 - str r0, [r1] - add sp, 0x4 - pop {r0} - bx r0 - .pool - thumb_func_end atkE9_setweatherballtype - - thumb_func_start atkEA_recycleitem -atkEA_recycleitem: @ 8056014 - push {r4-r7,lr} - sub sp, 0x4 - ldr r7, =gActiveBank - ldr r0, =gBankAttacker - ldrb r0, [r0] - strb r0, [r7] - ldr r1, =gBattleStruct - ldrb r2, [r7] - lsls r0, r2, 1 - adds r0, 0xB8 - ldr r1, [r1] - adds r6, r1, r0 - ldrh r5, [r6] - cmp r5, 0 - beq _08056094 - ldr r4, =gBattleMons - movs r3, 0x58 - adds r0, r2, 0 - muls r0, r3 - adds r0, r4 - ldrh r0, [r0, 0x2E] - cmp r0, 0 - bne _08056094 - ldr r1, =gLastUsedItem - strh r5, [r1] - strh r0, [r6] - ldrb r0, [r7] - muls r0, r3 - adds r0, r4 - ldrh r1, [r1] - strh r1, [r0, 0x2E] - ldrb r0, [r7] - muls r0, r3 - adds r1, r4, 0 - adds r1, 0x2E - adds r0, r1 - str r0, [sp] - movs r0, 0 - movs r1, 0x2 - movs r2, 0 - movs r3, 0x2 - bl EmitSetMonData - ldrb r0, [r7] - bl MarkBufferBankForExecution - ldr r1, =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x5 - str r0, [r1] - b _080560AE - .pool -_08056094: - ldr r3, =gBattlescriptCurrInstr - ldr r2, [r3] - 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, [r3] -_080560AE: - add sp, 0x4 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end atkEA_recycleitem - - thumb_func_start atkEB_settypetoterrain -atkEB_settypetoterrain: @ 80560BC - push {r4-r7,lr} - mov r7, r8 - push {r7} - ldr r0, =gBattleMons - mov r8, r0 - ldr r7, =gBankAttacker - ldrb r0, [r7] - movs r6, 0x58 - muls r0, r6 - mov r1, r8 - adds r3, r0, r1 - movs r0, 0x21 - adds r0, r3 - mov r12, r0 - ldr r5, =sTerrainToType - ldr r4, =gBattleTerrain - ldrb r0, [r4] - adds r0, r5 - ldrb r2, [r0] - mov r1, r12 - ldrb r0, [r1] - adds r1, r2, 0 - cmp r0, r1 - beq _08056144 - adds r0, r3, 0 - adds r0, 0x22 - ldrb r0, [r0] - cmp r0, r1 - beq _08056144 - mov r0, r12 - strb r2, [r0] - ldrb r0, [r7] - adds r1, r0, 0 - muls r1, r6 - add r1, r8 - ldrb r0, [r4] - adds r0, r5 - ldrb r0, [r0] - adds r1, 0x22 - strb r0, [r1] - ldr r1, =gBattleTextBuff1 - movs r0, 0xFD - strb r0, [r1] - movs r0, 0x3 - strb r0, [r1, 0x1] - ldrb r0, [r4] - adds r0, r5 - ldrb r0, [r0] - strb r0, [r1, 0x2] - movs r0, 0xFF - strb r0, [r1, 0x3] - ldr r1, =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x5 - str r0, [r1] - b _0805615E - .pool -_08056144: - ldr r3, =gBattlescriptCurrInstr - ldr r2, [r3] - 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, [r3] -_0805615E: - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end atkEB_settypetoterrain - - thumb_func_start atkEC_pursuit_sth -atkEC_pursuit_sth: @ 805616C - push {r4-r6,lr} - ldr r5, =gBankAttacker - ldrb r0, [r5] - bl GetBankIdentity - movs r1, 0x2 - eors r0, r1 - lsls r0, 24 - lsrs r0, 24 - bl GetBankByIdentity - ldr r4, =gActiveBank - strb r0, [r4] - ldr r0, =gBattleTypeFlags - ldr r0, [r0] - movs r6, 0x1 - ands r0, r6 - cmp r0, 0 - beq _0805620C - ldr r0, =gAbsentBankFlags - ldrb r1, [r0] - ldr r2, =gBitTable - ldrb r3, [r4] - lsls r0, r3, 2 - adds r0, r2 - ldr r0, [r0] - ands r1, r0 - cmp r1, 0 - bne _0805620C - ldr r0, =gActionForBanks - adds r0, r3, r0 - ldrb r0, [r0] - cmp r0, 0 - bne _0805620C - ldr r1, =gChosenMovesByBanks - lsls r0, r3, 1 - adds r0, r1 - ldrh r2, [r0] - cmp r2, 0xE4 - bne _0805620C - ldr r0, =gUnknown_0202407A - adds r0, r3, r0 - movs r1, 0xB - strb r1, [r0] - ldr r0, =gCurrentMove - strh r2, [r0] - ldr r1, =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x5 - str r0, [r1] - ldr r0, =gBattleScripting - strb r6, [r0, 0x18] - ldrb r1, [r5] - adds r0, 0x20 - strb r1, [r0] - ldrb r0, [r4] - strb r0, [r5] - b _08056226 - .pool -_0805620C: - ldr r3, =gBattlescriptCurrInstr - ldr r2, [r3] - 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, [r3] -_08056226: - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end atkEC_pursuit_sth - - thumb_func_start atkED_802B4B4 -atkED_802B4B4: @ 8056230 - push {r4,lr} - ldr r1, =gEffectBank - ldr r3, =gBankAttacker - ldrb r0, [r3] - strb r0, [r1] - ldr r2, =gBankTarget - lsls r0, 24 - lsrs r0, 24 - adds r4, r1, 0 - ldrb r1, [r2] - cmp r0, r1 - bne _08056264 - ldr r1, =gBattleScripting - ldrb r0, [r1, 0x17] - strb r0, [r2] - strb r0, [r3] - b _0805626A - .pool -_08056264: - ldr r1, =gBattleScripting - ldrb r0, [r1, 0x17] - strb r0, [r2] -_0805626A: - ldrb r0, [r4] - strb r0, [r1, 0x17] - ldr r1, =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x1 - str r0, [r1] - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end atkED_802B4B4 - - thumb_func_start atkEE_removelightscreenreflect -atkEE_removelightscreenreflect: @ 8056284 - push {r4,lr} - ldr r0, =gBankAttacker - ldrb r0, [r0] - bl GetBankSide - movs r1, 0x1 - eors r0, r1 - lsls r0, 24 - lsrs r0, 24 - ldr r1, =gSideTimers - lsls r3, r0, 1 - adds r0, r3, r0 - lsls r0, 2 - adds r4, r0, r1 - ldrb r0, [r4] - cmp r0, 0 - bne _080562AC - ldrb r1, [r4, 0x2] - cmp r1, 0 - beq _080562E4 -_080562AC: - ldr r2, =gSideAffecting - adds r2, r3, r2 - ldrh r1, [r2] - ldr r0, =0x0000fffe - ands r0, r1 - movs r3, 0 - ldr r1, =0x0000fffd - ands r0, r1 - strh r0, [r2] - strb r3, [r4] - strb r3, [r4, 0x2] - ldr r1, =gBattleScripting - movs r0, 0x1 - strb r0, [r1, 0x18] - strb r0, [r1, 0x19] - b _080562EA - .pool -_080562E4: - ldr r0, =gBattleScripting - strb r1, [r0, 0x18] - strb r1, [r0, 0x19] -_080562EA: - ldr r1, =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x1 - str r0, [r1] - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end atkEE_removelightscreenreflect - - thumb_func_start atkEF_pokeball_catch_calculation -atkEF_pokeball_catch_calculation: @ 8056300 - push {r4-r6,lr} - movs r4, 0 - ldr r0, =gBattleExecBuffer - ldr r0, [r0] - cmp r0, 0 - beq _0805630E - b _08056696 -_0805630E: - ldr r5, =gActiveBank - ldr r0, =gBankAttacker - ldrb r0, [r0] - strb r0, [r5] - ldr r6, =gBankTarget - movs r1, 0x1 - eors r0, r1 - strb r0, [r6] - ldr r0, =gBattleTypeFlags - ldr r1, [r0] - movs r0, 0x8 - ands r0, r1 - cmp r0, 0 - beq _0805635C - movs r0, 0 - movs r1, 0x5 - bl dp01_build_cmdbuf_x0D_a - ldrb r0, [r5] - bl MarkBufferBankForExecution - ldr r1, =gBattlescriptCurrInstr - ldr r0, =gUnknown_082DBE02 - b _08056694 - .pool -_0805635C: - movs r0, 0x80 - lsls r0, 2 - ands r1, r0 - cmp r1, 0 - beq _08056384 - movs r0, 0 - movs r1, 0x4 - bl dp01_build_cmdbuf_x0D_a - ldrb r0, [r5] - bl MarkBufferBankForExecution - ldr r1, =gBattlescriptCurrInstr - ldr r0, =gUnknown_082DBDCA - b _08056694 - .pool -_08056384: - ldr r0, =gLastUsedItem - ldrh r0, [r0] - cmp r0, 0x5 - bne _080563B0 - ldr r0, =gBattleStruct - ldr r0, [r0] - adds r0, 0x7C - ldrb r0, [r0] - lsls r1, r0, 2 - adds r1, r0 - lsls r0, r1, 8 - subs r0, r1 - movs r1, 0x64 - bl __divsi3 - lsls r0, 24 - lsrs r5, r0, 24 - b _080563C8 - .pool -_080563B0: - ldr r3, =gBaseStats - ldr r2, =gBattleMons - ldrb r1, [r6] - movs r0, 0x58 - muls r0, r1 - adds r0, r2 - ldrh r1, [r0] - lsls r0, r1, 3 - subs r0, r1 - lsls r0, 2 - adds r0, r3 - ldrb r5, [r0, 0x8] -_080563C8: - ldr r2, =gLastUsedItem - ldrh r0, [r2] - cmp r0, 0x5 - bhi _080563D2 - b _080564C8 -_080563D2: - subs r0, 0x6 - cmp r0, 0x6 - bls _080563DA - b _080564D2 -_080563DA: - lsls r0, 2 - ldr r1, =_080563F4 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_080563F4: - .4byte _08056410 - .4byte _08056440 - .4byte _08056452 - .4byte _08056480 - .4byte _080564B0 - .4byte _08056472 - .4byte _08056472 -_08056410: - ldr r2, =gBattleMons - ldr r0, =gBankTarget - ldrb r1, [r0] - movs r0, 0x58 - muls r0, r1 - adds r0, r2 - adds r1, r0, 0 - adds r1, 0x21 - ldrb r1, [r1] - cmp r1, 0xB - beq _080564A4 - adds r0, 0x22 - ldrb r0, [r0] - cmp r0, 0xB - beq _080564A4 - cmp r1, 0x6 - beq _080564A4 - cmp r0, 0x6 - beq _080564A4 - b _08056472 - .pool -_08056440: - bl sav1_map_get_light_level - lsls r0, 24 - lsrs r0, 24 - movs r4, 0xA - cmp r0, 0x5 - bne _080564D2 - movs r4, 0x23 - b _080564D2 -_08056452: - ldr r2, =gBattleMons - ldr r0, =gBankTarget - ldrb r1, [r0] - movs r0, 0x58 - muls r0, r1 - adds r0, r2 - adds r0, 0x2A - ldrb r1, [r0] - cmp r1, 0x27 - bhi _08056472 - movs r0, 0x28 - subs r0, r1 - lsls r0, 24 - lsrs r4, r0, 24 - cmp r4, 0x9 - bhi _080564D2 -_08056472: - movs r4, 0xA - b _080564D2 - .pool -_08056480: - ldr r2, =gBattleMons - ldr r0, =gBankTarget - ldrb r1, [r0] - movs r0, 0x58 - muls r0, r1 - adds r0, r2 - ldrh r0, [r0] - bl SpeciesToNationalPokedexNum - lsls r0, 16 - lsrs r0, 16 - movs r1, 0x1 - bl GetSetPokedexFlag - lsls r0, 24 - movs r4, 0xA - cmp r0, 0 - beq _080564D2 -_080564A4: - movs r4, 0x1E - b _080564D2 - .pool -_080564B0: - ldr r0, =gBattleResults - ldrb r0, [r0, 0x13] - adds r0, 0xA - lsls r0, 24 - lsrs r4, r0, 24 - cmp r4, 0x28 - bls _080564D2 - movs r4, 0x28 - b _080564D2 - .pool -_080564C8: - ldr r1, =sBallCatchBonuses - ldrh r0, [r2] - subs r0, 0x2 - adds r0, r1 - ldrb r4, [r0] -_080564D2: - adds r0, r5, 0 - muls r0, r4 - movs r1, 0xA - bl __divsi3 - ldr r5, =gBattleMons - ldr r1, =gBankTarget - ldrb r2, [r1] - movs r1, 0x58 - adds r4, r2, 0 - muls r4, r1 - adds r3, r4, r5 - ldrh r2, [r3, 0x2C] - lsls r1, r2, 1 - adds r1, r2 - ldrh r2, [r3, 0x28] - lsls r2, 1 - subs r2, r1, r2 - muls r0, r2 - bl __divsi3 - adds r6, r0, 0 - adds r5, 0x4C - adds r4, r5 - ldr r4, [r4] - movs r0, 0x27 - ands r0, r4 - cmp r0, 0 - beq _0805650E - lsls r6, 1 -_0805650E: - movs r0, 0xD8 - ands r4, r0 - cmp r4, 0 - beq _08056522 - lsls r0, r6, 4 - subs r0, r6 - movs r1, 0xA - bl __udivsi3 - adds r6, r0, 0 -_08056522: - ldr r1, =gLastUsedItem - ldrh r0, [r1] - cmp r0, 0x5 - beq _08056564 - cmp r0, 0x1 - bne _08056550 - ldr r0, =gBattleResults - ldrb r1, [r0, 0x5] - movs r2, 0x2 - orrs r1, r2 - strb r1, [r0, 0x5] - b _08056564 - .pool -_08056550: - ldr r0, =gBattleResults - ldrh r1, [r1] - adds r0, r1 - adds r1, r0, 0 - adds r1, 0x34 - ldrb r0, [r1] - cmp r0, 0xFE - bhi _08056564 - adds r0, 0x1 - strb r0, [r1] -_08056564: - cmp r6, 0xFE - bls _080565C8 - movs r0, 0 - movs r1, 0x4 - bl dp01_build_cmdbuf_x0D_a - ldr r0, =gActiveBank - ldrb r0, [r0] - bl MarkBufferBankForExecution - ldr r1, =gBattlescriptCurrInstr - ldr r0, =gUnknown_082DBD84 - str r0, [r1] - ldr r1, =gBattlePartyID - ldr r0, =gBankTarget - ldrb r0, [r0] - lsls r0, 1 - adds r0, r1 - ldrh r1, [r0] - movs r0, 0x64 - muls r0, r1 - ldr r1, =gEnemyParty - adds r0, r1 - ldr r2, =gLastUsedItem - movs r1, 0x26 - bl SetMonData - bl CalculatePlayerPartyCount - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x6 - beq _08056656 - b _08056680 - .pool -_080565C8: - movs r0, 0xFF - lsls r0, 16 - adds r1, r6, 0 - bl __udivsi3 - bl Sqrt - lsls r0, 16 - lsrs r0, 16 - bl Sqrt - lsls r0, 16 - lsrs r6, r0, 16 - ldr r0, =0x000ffff0 - adds r1, r6, 0 - bl __udivsi3 - adds r6, r0, 0 - movs r4, 0 - b _080565FA - .pool -_080565F4: - adds r0, r4, 0x1 - lsls r0, 24 - lsrs r4, r0, 24 -_080565FA: - cmp r4, 0x3 - bhi _0805660A - bl Random - lsls r0, 16 - lsrs r0, 16 - cmp r0, r6 - bcc _080565F4 -_0805660A: - ldr r5, =gLastUsedItem - ldrh r0, [r5] - cmp r0, 0x1 - bne _08056614 - movs r4, 0x4 -_08056614: - movs r0, 0 - adds r1, r4, 0 - bl dp01_build_cmdbuf_x0D_a - ldr r0, =gActiveBank - ldrb r0, [r0] - bl MarkBufferBankForExecution - cmp r4, 0x4 - bne _0805668C - ldr r1, =gBattlescriptCurrInstr - ldr r0, =gUnknown_082DBD84 - str r0, [r1] - ldr r1, =gBattlePartyID - ldr r0, =gBankTarget - ldrb r0, [r0] - lsls r0, 1 - adds r0, r1 - ldrh r1, [r0] - movs r0, 0x64 - muls r0, r1 - ldr r1, =gEnemyParty - adds r0, r1 - movs r1, 0x26 - adds r2, r5, 0 - bl SetMonData - bl CalculatePlayerPartyCount - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x6 - bne _08056680 -_08056656: - ldr r1, =gBattleCommunication - movs r0, 0 - strb r0, [r1, 0x5] - b _08056696 - .pool -_08056680: - ldr r1, =gBattleCommunication - movs r0, 0x1 - strb r0, [r1, 0x5] - b _08056696 - .pool -_0805668C: - ldr r0, =gBattleCommunication - strb r4, [r0, 0x5] - ldr r1, =gBattlescriptCurrInstr - ldr r0, =gUnknown_082DBDD4 -_08056694: - str r0, [r1] -_08056696: - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end atkEF_pokeball_catch_calculation - - thumb_func_start atkF0_copy_caught_poke -atkF0_copy_caught_poke: @ 80566A8 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - ldr r0, =gBattlePartyID - mov r9, r0 - ldr r5, =gBankAttacker - ldrb r0, [r5] - movs r6, 0x1 - eors r0, r6 - lsls r0, 1 - add r0, r9 - ldrh r0, [r0] - movs r7, 0x64 - muls r0, r7 - ldr r1, =gEnemyParty - mov r8, r1 - add r0, r8 - bl GiveMonToPlayer - lsls r0, 24 - cmp r0, 0 - beq _08056792 - bl sub_813B21C - lsls r0, 24 - lsrs r1, r0, 24 - cmp r1, 0 - bne _08056734 - ldr r0, =gBattleCommunication - strb r1, [r0, 0x5] - ldr r4, =gStringVar1 - ldr r0, =0x00004036 - bl VarGet - lsls r0, 24 - lsrs r0, 24 - bl sav3_get_box_name - adds r1, r0, 0 - adds r0, r4, 0 - bl StringCopy - ldrb r0, [r5] - eors r0, r6 - lsls r0, 1 - add r0, r9 - ldrh r0, [r0] - muls r0, r7 - add r0, r8 - ldr r2, =gStringVar2 - movs r1, 0x2 - bl GetMonData - b _0805677E - .pool -_08056734: - ldr r4, =gStringVar1 - ldr r0, =0x00004036 - bl VarGet - lsls r0, 24 - lsrs r0, 24 - bl sav3_get_box_name - adds r1, r0, 0 - adds r0, r4, 0 - bl StringCopy - ldrb r0, [r5] - eors r0, r6 - lsls r0, 1 - add r0, r9 - ldrh r0, [r0] - muls r0, r7 - add r0, r8 - ldr r2, =gStringVar2 - movs r1, 0x2 - bl GetMonData - ldr r4, =gStringVar3 - bl get_unknown_box_id - lsls r0, 24 - lsrs r0, 24 - bl sav3_get_box_name - adds r1, r0, 0 - adds r0, r4, 0 - bl StringCopy - ldr r1, =gBattleCommunication - movs r0, 0x2 - strb r0, [r1, 0x5] -_0805677E: - ldr r0, =0x000008ab - bl FlagGet - lsls r0, 24 - cmp r0, 0 - beq _08056792 - ldr r1, =gBattleCommunication - ldrb r0, [r1, 0x5] - adds r0, 0x1 - strb r0, [r1, 0x5] -_08056792: - ldr r0, =gBattlePartyID - mov r10, r0 - ldr r1, =gBankAttacker - mov r9, r1 - ldrb r0, [r1] - movs r4, 0x1 - eors r0, r4 - lsls r0, 1 - add r0, r10 - ldrh r0, [r0] - movs r1, 0x64 - mov r8, r1 - mov r1, r8 - muls r1, r0 - adds r0, r1, 0 - ldr r6, =gEnemyParty - adds r0, r6 - movs r1, 0xB - movs r2, 0 - bl GetMonData - ldr r5, =gBattleResults - strh r0, [r5, 0x28] - mov r1, r9 - ldrb r0, [r1] - eors r0, r4 - lsls r0, 1 - add r0, r10 - ldrh r0, [r0] - mov r1, r8 - muls r1, r0 - adds r0, r1, 0 - adds r0, r6 - adds r2, r5, 0 - adds r2, 0x2A - movs r1, 0x2 - bl GetMonData - mov r1, r9 - ldrb r0, [r1] - eors r4, r0 - lsls r4, 1 - add r4, r10 - ldrh r0, [r4] - mov r1, r8 - muls r1, r0 - adds r0, r1, 0 - adds r0, r6 - movs r1, 0x26 - movs r2, 0 - bl GetMonData - movs r1, 0xF - ands r0, r1 - lsls r0, 2 - ldrb r2, [r5, 0x5] - movs r1, 0x3D - negs r1, r1 - ands r1, r2 - orrs r1, r0 - strb r1, [r5, 0x5] - ldr r1, =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x1 - str r0, [r1] - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end atkF0_copy_caught_poke - - thumb_func_start atkF1_setpoke_as_caught -atkF1_setpoke_as_caught: @ 8056850 - push {r4,r5,lr} - ldr r4, =gEnemyParty - adds r0, r4, 0 - movs r1, 0xB - movs r2, 0 - bl GetMonData - lsls r0, 16 - lsrs r5, r0, 16 - adds r0, r4, 0 - movs r1, 0 - movs r2, 0 - bl GetMonData - adds r4, r0, 0 - adds r0, r5, 0 - bl SpeciesToNationalPokedexNum - lsls r0, 16 - lsrs r0, 16 - movs r1, 0x1 - bl GetSetPokedexFlag - lsls r0, 24 - cmp r0, 0 - beq _080568A8 - ldr r3, =gBattlescriptCurrInstr - ldr r2, [r3] - 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, [r3] - b _080568C2 - .pool -_080568A8: - adds r0, r5, 0 - bl SpeciesToNationalPokedexNum - lsls r0, 16 - lsrs r0, 16 - movs r1, 0x3 - adds r2, r4, 0 - bl HandleSetPokedexFlag - ldr r1, =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x5 - str r0, [r1] -_080568C2: - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end atkF1_setpoke_as_caught - - thumb_func_start atkF2_display_dex_info -atkF2_display_dex_info: @ 80568CC - push {r4,lr} - sub sp, 0x4 - ldr r0, =gEnemyParty - movs r1, 0xB - movs r2, 0 - bl GetMonData - lsls r0, 16 - lsrs r4, r0, 16 - ldr r0, =gBattleCommunication - ldrb r0, [r0] - cmp r0, 0x5 - bls _080568E8 - b _08056A2C -_080568E8: - lsls r0, 2 - ldr r1, =_08056900 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_08056900: - .4byte _08056918 - .4byte _0805692A - .4byte _08056978 - .4byte _080569C8 - .4byte _080569E0 - .4byte _08056A18 -_08056918: - movs r0, 0x1 - negs r0, r0 - movs r1, 0 - str r1, [sp] - movs r2, 0 - movs r3, 0x10 - bl BeginNormalPaletteFade - b _08056A06 -_0805692A: - ldr r0, =gPaletteFade - ldrb r1, [r0, 0x7] - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - beq _08056938 - b _08056A2C -_08056938: - bl FreeAllWindowBuffers - adds r0, r4, 0 - bl SpeciesToNationalPokedexNum - lsls r0, 16 - lsrs r0, 16 - ldr r3, =gBattleMons - ldr r1, =gBankTarget - ldrb r2, [r1] - movs r1, 0x58 - muls r2, r1 - adds r1, r3, 0 - adds r1, 0x54 - adds r1, r2, r1 - ldr r1, [r1] - adds r3, 0x48 - adds r2, r3 - ldr r2, [r2] - bl sub_80BFDF4 - ldr r1, =gBattleCommunication - strb r0, [r1, 0x1] - b _08056A08 - .pool -_08056978: - ldr r0, =gPaletteFade - ldrb r1, [r0, 0x7] - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - bne _08056A2C - ldr r0, =gMain - ldr r1, [r0, 0x4] - ldr r0, =BattleMainCB2 - cmp r1, r0 - bne _08056A2C - ldr r2, =gTasks - ldr r4, =gBattleCommunication - ldrb r1, [r4, 0x1] - lsls r0, r1, 2 - adds r0, r1 - lsls r0, 3 - adds r0, r2 - ldrb r0, [r0, 0x4] - cmp r0, 0 - bne _08056A2C - ldr r0, =vblank_cb_08078BB4 - bl SetVBlankCallback - ldrb r0, [r4] - adds r0, 0x1 - strb r0, [r4] - b _08056A2C - .pool -_080569C8: - bl c2_berry_program_update_menu - bl sub_8035AA4 - ldr r1, =gUnknown_02022E20 - movs r2, 0x80 - lsls r2, 1 - adds r0, r2, 0 - strh r0, [r1] - b _08056A06 - .pool -_080569E0: - bl IsDma3ManagerBusyWithBgCopy - lsls r0, 24 - lsrs r1, r0, 24 - cmp r1, 0 - bne _08056A2C - ldr r0, =0x0000ffff - str r1, [sp] - movs r1, 0 - movs r2, 0x10 - movs r3, 0 - bl BeginNormalPaletteFade - movs r0, 0 - bl ShowBg - movs r0, 0x3 - bl ShowBg -_08056A06: - ldr r1, =gBattleCommunication -_08056A08: - ldrb r0, [r1] - adds r0, 0x1 - strb r0, [r1] - b _08056A2C - .pool -_08056A18: - ldr r0, =gPaletteFade - ldrb r1, [r0, 0x7] - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - bne _08056A2C - ldr r1, =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x1 - str r0, [r1] -_08056A2C: - add sp, 0x4 - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end atkF2_display_dex_info - - thumb_func_start sub_8056A3C -sub_8056A3C: @ 8056A3C - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x20 - ldr r4, [sp, 0x40] - lsls r0, 24 - lsrs r0, 24 - mov r8, r0 - lsls r1, 24 - lsrs r1, 24 - str r1, [sp, 0x10] - lsls r2, 24 - lsrs r2, 24 - str r2, [sp, 0x1C] - lsls r3, 24 - lsrs r3, 24 - str r3, [sp, 0x14] - lsls r4, 24 - lsrs r4, 24 - mov r10, r4 - movs r1, 0 - add r0, sp, 0xC - strh r1, [r0] - ldr r6, [sp, 0x10] - cmp r6, r3 - ble _08056A76 - b _08056B62 -_08056A76: - mov r4, r8 - adds r0, r6, 0x1 - str r0, [sp, 0x18] - ldr r2, [sp, 0x1C] - cmp r4, r2 - bgt _08056B58 - add r5, sp, 0xC - lsls r7, r6, 24 - mov r9, r7 -_08056A88: - ldr r0, [sp, 0x10] - cmp r6, r0 - bne _08056AB4 - cmp r4, r8 - bne _08056A9C - ldr r0, =0x00001022 - b _08056AFE - .pool -_08056A9C: - ldr r2, [sp, 0x1C] - cmp r4, r2 - bne _08056AAC - ldr r0, =0x00001024 - b _08056AFE - .pool -_08056AAC: - ldr r0, =0x00001023 - b _08056AFE - .pool -_08056AB4: - ldr r7, [sp, 0x14] - cmp r6, r7 - bne _08056AE0 - cmp r4, r8 - bne _08056AC8 - ldr r0, =0x00001028 - b _08056AFE - .pool -_08056AC8: - ldr r0, [sp, 0x1C] - cmp r4, r0 - bne _08056AD8 - ldr r0, =0x0000102a - b _08056AFE - .pool -_08056AD8: - ldr r0, =0x00001029 - b _08056AFE - .pool -_08056AE0: - cmp r4, r8 - bne _08056AEC - ldr r0, =0x00001025 - b _08056AFE - .pool -_08056AEC: - ldr r2, [sp, 0x1C] - cmp r4, r2 - bne _08056AFC - ldr r0, =0x00001027 - b _08056AFE - .pool -_08056AFC: - ldr r0, =0x00001026 -_08056AFE: - strh r0, [r5] - movs r1, 0x1 - mov r0, r10 - ands r0, r1 - cmp r0, 0 - beq _08056B0E - movs r0, 0 - strh r0, [r5] -_08056B0E: - movs r0, 0x80 - mov r7, r10 - ands r0, r7 - cmp r0, 0 - beq _08056B38 - lsls r2, r4, 24 - lsrs r2, 24 - str r1, [sp] - str r1, [sp, 0x4] - movs r0, 0x11 - str r0, [sp, 0x8] - movs r0, 0x1 - add r1, sp, 0xC - mov r7, r9 - lsrs r3, r7, 24 - bl CopyToBgTilemapBufferRect_ChangePalette - b _08056B50 - .pool -_08056B38: - lsls r2, r4, 24 - lsrs r2, 24 - str r1, [sp] - str r1, [sp, 0x4] - movs r0, 0x11 - str r0, [sp, 0x8] - movs r0, 0 - add r1, sp, 0xC - mov r7, r9 - lsrs r3, r7, 24 - bl CopyToBgTilemapBufferRect_ChangePalette -_08056B50: - adds r4, 0x1 - ldr r0, [sp, 0x1C] - cmp r4, r0 - ble _08056A88 -_08056B58: - ldr r6, [sp, 0x18] - ldr r2, [sp, 0x14] - cmp r6, r2 - bgt _08056B62 - b _08056A76 -_08056B62: - add sp, 0x20 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end sub_8056A3C - - thumb_func_start BattleCreateCursorAt -BattleCreateCursorAt: @ 8056B74 - push {lr} - sub sp, 0x10 - adds r3, r0, 0 - add r0, sp, 0xC - movs r2, 0x1 - strh r2, [r0] - movs r1, 0x2 - strh r1, [r0, 0x2] - lsls r3, 25 - movs r0, 0x90 - lsls r0, 20 - adds r3, r0 - lsrs r3, 24 - str r2, [sp] - str r1, [sp, 0x4] - movs r0, 0x11 - str r0, [sp, 0x8] - movs r0, 0 - add r1, sp, 0xC - movs r2, 0x19 - bl CopyToBgTilemapBufferRect_ChangePalette - movs r0, 0 - bl CopyBgTilemapBufferToVram - add sp, 0x10 - pop {r0} - bx r0 - thumb_func_end BattleCreateCursorAt - - thumb_func_start BattleDestroyCursorAt -BattleDestroyCursorAt: @ 8056BAC - push {lr} - sub sp, 0x10 - adds r3, r0, 0 - add r0, sp, 0xC - ldr r1, =0x00001016 - strh r1, [r0] - strh r1, [r0, 0x2] - lsls r3, 25 - movs r0, 0x90 - lsls r0, 20 - adds r3, r0 - lsrs r3, 24 - movs r0, 0x1 - str r0, [sp] - movs r0, 0x2 - str r0, [sp, 0x4] - movs r0, 0x11 - str r0, [sp, 0x8] - movs r0, 0 - add r1, sp, 0xC - movs r2, 0x19 - bl CopyToBgTilemapBufferRect_ChangePalette - movs r0, 0 - bl CopyBgTilemapBufferToVram - add sp, 0x10 - pop {r0} - bx r0 - .pool - thumb_func_end BattleDestroyCursorAt - - thumb_func_start atkF3_nickname_caught_poke -atkF3_nickname_caught_poke: @ 8056BEC - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x8 - ldr r0, =gBattleCommunication - ldrb r1, [r0] - adds r4, r0, 0 - cmp r1, 0x4 - bls _08056C04 - b _08056E62 -_08056C04: - lsls r0, r1, 2 - ldr r1, =_08056C18 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_08056C18: - .4byte _08056C2C - .4byte _08056C60 - .4byte _08056CFC - .4byte _08056DD4 - .4byte _08056E2C -_08056C2C: - movs r4, 0 - str r4, [sp] - movs r0, 0x18 - movs r1, 0x8 - movs r2, 0x1D - movs r3, 0xD - bl sub_8056A3C - ldr r0, =gText_BattleYesNoChoice - movs r1, 0xC - bl sub_814F9EC - ldr r1, =gBattleCommunication - ldrb r0, [r1] - adds r0, 0x1 - strb r0, [r1] - strb r4, [r1, 0x1] - movs r0, 0 - bl BattleCreateCursorAt - b _08056E62 - .pool -_08056C60: - ldr r0, =gMain - ldrh r1, [r0, 0x2E] - movs r0, 0x40 - ands r0, r1 - cmp r0, 0 - beq _08056C86 - ldrb r0, [r4, 0x1] - cmp r0, 0 - beq _08056C86 - movs r0, 0x5 - bl PlaySE - ldrb r0, [r4, 0x1] - bl BattleDestroyCursorAt - movs r0, 0 - strb r0, [r4, 0x1] - bl BattleCreateCursorAt -_08056C86: - ldr r0, =gMain - ldrh r1, [r0, 0x2E] - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - beq _08056CAE - ldr r4, =gBattleCommunication - ldrb r0, [r4, 0x1] - cmp r0, 0 - bne _08056CAE - movs r0, 0x5 - bl PlaySE - ldrb r0, [r4, 0x1] - bl BattleDestroyCursorAt - movs r0, 0x1 - strb r0, [r4, 0x1] - bl BattleCreateCursorAt -_08056CAE: - ldr r0, =gMain - ldrh r1, [r0, 0x2E] - movs r0, 0x1 - ands r0, r1 - cmp r0, 0 - beq _08056CE0 - movs r0, 0x5 - bl PlaySE - ldr r1, =gBattleCommunication - ldrb r0, [r1, 0x1] - cmp r0, 0 - bne _08056CF2 - ldrb r0, [r1] - adds r0, 0x1 - strb r0, [r1] - movs r0, 0x3 - bl BeginFastPaletteFade - b _08056E62 - .pool -_08056CE0: - movs r0, 0x2 - ands r0, r1 - cmp r0, 0 - bne _08056CEA - b _08056E62 -_08056CEA: - movs r0, 0x5 - bl PlaySE - ldr r1, =gBattleCommunication -_08056CF2: - movs r0, 0x4 - strb r0, [r1] - b _08056E62 - .pool -_08056CFC: - ldr r0, =gPaletteFade - ldrb r1, [r0, 0x7] - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - beq _08056D0A - b _08056E62 -_08056D0A: - ldr r7, =gBattlePartyID - ldr r0, =gBankAttacker - mov r10, r0 - ldrb r0, [r0] - movs r4, 0x1 - eors r0, r4 - lsls r0, 1 - adds r0, r7 - ldrh r0, [r0] - movs r1, 0x64 - mov r9, r1 - mov r2, r9 - muls r2, r0 - adds r0, r2, 0 - ldr r1, =gEnemyParty - mov r8, r1 - add r0, r8 - ldr r1, =gBattleStruct - ldr r2, [r1] - adds r2, 0x6D - movs r1, 0x2 - bl GetMonData - bl FreeAllWindowBuffers - mov r2, r10 - ldrb r0, [r2] - eors r0, r4 - lsls r0, 1 - adds r0, r7 - ldrh r0, [r0] - mov r1, r9 - muls r1, r0 - adds r0, r1, 0 - add r0, r8 - movs r1, 0xB - bl GetMonData - adds r6, r0, 0 - lsls r6, 16 - lsrs r6, 16 - mov r2, r10 - ldrb r0, [r2] - eors r0, r4 - lsls r0, 1 - adds r0, r7 - ldrh r0, [r0] - mov r1, r9 - muls r1, r0 - adds r0, r1, 0 - add r0, r8 - bl GetMonGender - adds r5, r0, 0 - lsls r5, 24 - lsrs r5, 24 - mov r2, r10 - ldrb r0, [r2] - eors r4, r0 - lsls r4, 1 - adds r4, r7 - ldrh r0, [r4] - mov r1, r9 - muls r1, r0 - adds r0, r1, 0 - add r0, r8 - movs r1, 0 - movs r2, 0 - bl GetMonData - ldr r2, =gBattleStruct - ldr r1, [r2] - adds r1, 0x6D - str r0, [sp] - ldr r0, =BattleMainCB2 - str r0, [sp, 0x4] - movs r0, 0x2 - adds r2, r6, 0 - adds r3, r5, 0 - bl DoNamingScreen - ldr r1, =gBattleCommunication - ldrb r0, [r1] - adds r0, 0x1 - strb r0, [r1] - b _08056E62 - .pool -_08056DD4: - ldr r0, =gMain - ldr r1, [r0, 0x4] - ldr r0, =BattleMainCB2 - cmp r1, r0 - bne _08056E62 - ldr r0, =gPaletteFade - ldrb r1, [r0, 0x7] - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - bne _08056E62 - ldr r2, =gBattlePartyID - ldr r0, =gBankAttacker - ldrb r1, [r0] - movs r0, 0x1 - eors r0, r1 - lsls r0, 1 - adds r0, r2 - ldrh r1, [r0] - movs r0, 0x64 - muls r0, r1 - ldr r1, =gEnemyParty - adds r0, r1 - ldr r1, =gBattleStruct - ldr r2, [r1] - adds r2, 0x6D - movs r1, 0x2 - bl SetMonData - b _08056E48 - .pool -_08056E2C: - bl CalculatePlayerPartyCount - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x6 - bne _08056E48 - ldr r1, =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x5 - str r0, [r1] - b _08056E62 - .pool -_08056E48: - ldr r3, =gBattlescriptCurrInstr - ldr r2, [r3] - 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, [r3] -_08056E62: - 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 atkF3_nickname_caught_poke - - thumb_func_start atkF4_802BEF0 -atkF4_802BEF0: @ 8056E78 - ldr r2, =gBattleMons - ldr r0, =gBankAttacker - ldrb r1, [r0] - movs r0, 0x58 - muls r1, r0 - adds r1, r2 - ldr r0, =gBattleMoveDamage - ldr r2, [r0] - ldrh r0, [r1, 0x28] - subs r0, r2 - strh r0, [r1, 0x28] - ldr r1, =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x1 - str r0, [r1] - bx lr - .pool - thumb_func_end atkF4_802BEF0 - - thumb_func_start atkF5_removeattackerstatus1 -atkF5_removeattackerstatus1: @ 8056EA8 - ldr r1, =gBattleMons - ldr r0, =gBankAttacker - ldrb r2, [r0] - movs r0, 0x58 - muls r0, r2 - adds r1, 0x4C - adds r0, r1 - movs r1, 0 - str r1, [r0] - ldr r1, =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x1 - str r0, [r1] - bx lr - .pool - thumb_func_end atkF5_removeattackerstatus1 - - thumb_func_start atkF6_802BF48 -atkF6_802BF48: @ 8056ED0 - ldr r1, =gFightStateTracker - movs r0, 0xC - strb r0, [r1] - bx lr - .pool - thumb_func_end atkF6_802BF48 - - thumb_func_start atkF7_802BF54 -atkF7_802BF54: @ 8056EDC - ldr r1, =gFightStateTracker - movs r0, 0xC - strb r0, [r1] - ldr r1, =gCurrentMoveTurn - ldr r0, =gNoOfAllBanks - ldrb r0, [r0] - strb r0, [r1] - bx lr - .pool - thumb_func_end atkF7_802BF54 - - thumb_func_start sub_8056EF8 -sub_8056EF8: @ 8056EF8 - push {r4,r5,lr} - ldr r5, =gBattlescriptCurrInstr - ldr r0, [r5] - ldrb r0, [r0, 0x1] - bl GetBankByIdentity - ldr r4, =gActiveBank - strb r0, [r4] - movs r0, 0 - bl dp01_build_cmdbuf_x09_9_9_9 - ldrb r0, [r4] - bl MarkBufferBankForExecution - ldr r0, [r5] - adds r0, 0x2 - str r0, [r5] - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8056EF8 - - - .align 2, 0 @ Don't pad with nop. diff --git a/asm/battle_anim_80FE840.s b/asm/battle_anim_80FE840.s index c6761bd9a..24a553f94 100644 --- a/asm/battle_anim_80FE840.s +++ b/asm/battle_anim_80FE840.s @@ -30134,7 +30134,7 @@ _0810DB1A: lsls r0, 24 cmp r0, 0 bne _0810DB50 - ldr r1, =gUnknown_02022E20 + ldr r1, =gBattle_BG3_X ldrh r0, [r4, 0x1A] lsls r0, 16 asrs r0, 24 @@ -30145,7 +30145,7 @@ _0810DB1A: b _0810DB60 .pool _0810DB50: - ldr r2, =gUnknown_02022E20 + ldr r2, =gBattle_BG3_X ldrh r1, [r4, 0x1A] lsls r1, 16 asrs r1, 24 @@ -44805,7 +44805,7 @@ _08115314: beq _08115340 cmp r0, 0x5 bne _08115380 - ldr r0, =gUnknown_02022E20 + ldr r0, =gBattle_BG3_X ldrh r0, [r0] strh r0, [r4, 0x22] ldr r0, =sub_81153AC @@ -44907,7 +44907,7 @@ _081153DA: ands r0, r1 cmp r0, 0 bne _08115404 - ldr r1, =gUnknown_02022E20 + ldr r1, =gBattle_BG3_X ldrh r0, [r3, 0x26] ldrh r2, [r3, 0x22] adds r0, r2 @@ -44915,7 +44915,7 @@ _081153DA: b _0811540E .pool _08115404: - ldr r0, =gUnknown_02022E20 + ldr r0, =gBattle_BG3_X ldrh r1, [r3, 0x22] ldrh r2, [r3, 0x26] subs r1, r2 @@ -44951,7 +44951,7 @@ _08115430: ands r1, r0 cmp r1, 0 bne _0811545C - ldr r1, =gUnknown_02022E20 + ldr r1, =gBattle_BG3_X ldrh r0, [r3, 0x24] ldrh r2, [r3, 0x22] adds r0, r2 @@ -44959,7 +44959,7 @@ _08115430: b _08115466 .pool _0811545C: - ldr r0, =gUnknown_02022E20 + ldr r0, =gBattle_BG3_X ldrh r1, [r3, 0x22] ldrh r2, [r3, 0x24] subs r1, r2 @@ -44987,7 +44987,7 @@ _08115484: b _0811549C .pool _08115490: - ldr r1, =gUnknown_02022E20 + ldr r1, =gBattle_BG3_X ldrh r0, [r3, 0x22] strh r0, [r1] adds r0, r2, 0 @@ -45263,7 +45263,7 @@ _0811565A: movs r0, 0xFF ands r1, r0 strh r1, [r4, 0xC] - ldr r2, =gUnknown_02022E20 + ldr r2, =gBattle_BG3_X ldrh r0, [r4, 0xA] strh r0, [r2] ldr r0, =gUnknown_02022E22 @@ -45295,7 +45295,7 @@ sub_81156D0: @ 81156D0 ldrsh r0, [r2, r4] cmp r1, r0 bne _08115710 - ldr r0, =gUnknown_02022E20 + ldr r0, =gBattle_BG3_X movs r1, 0 strh r1, [r0] ldr r0, =gUnknown_02022E22 @@ -45305,7 +45305,7 @@ sub_81156D0: @ 81156D0 b _0811571C .pool _08115710: - ldr r1, =gUnknown_02022E20 + ldr r1, =gBattle_BG3_X ldrh r0, [r2, 0xA] strh r0, [r1] ldr r1, =gUnknown_02022E22 @@ -46553,7 +46553,7 @@ _081160DC: beq _081160F4 b _08116104 _081160E2: - ldr r1, =gUnknown_02022E20 + ldr r1, =gBattle_BG3_X b _081160F6 .pool _081160EC: @@ -46793,7 +46793,7 @@ sub_81162A4: @ 81162A4 strh r1, [r2, 0xE] ldrh r1, [r3, 0x6] strh r1, [r2, 0x18] - ldr r4, =gUnknown_02022E20 + ldr r4, =gBattle_BG3_X ldrh r1, [r3] strh r1, [r4] ldr r4, =gUnknown_02022E22 @@ -46824,7 +46824,7 @@ sub_81162F8: @ 81162F8 mov r12, r1 cmp r0, 0 bne _0811637E - ldr r0, =gUnknown_02022E20 + ldr r0, =gBattle_BG3_X ldrh r2, [r0] movs r7, 0x8 ldrsh r1, [r3, r7] @@ -49152,7 +49152,7 @@ sub_81176D8: @ 81176D8 ldrh r7, [r1, 0x1E] adds r2, r7 strh r2, [r1, 0x1E] - ldr r6, =gUnknown_02022E20 + ldr r6, =gBattle_BG3_X lsls r0, r3, 16 asrs r0, 24 ldrh r4, [r6] diff --git a/asm/battle_frontier_1.s b/asm/battle_frontier_1.s index 1a0b5ae3d..e870c8798 100755 --- a/asm/battle_frontier_1.s +++ b/asm/battle_frontier_1.s @@ -3169,7 +3169,7 @@ _0819044E: strh r4, [r0] ldr r0, =gBattle_BG1_Y strh r4, [r0] - ldr r0, =gUnknown_02022E20 + ldr r0, =gBattle_BG3_X strh r4, [r0] ldr r0, =gUnknown_02022E22 strh r4, [r0] diff --git a/asm/contest.s b/asm/contest.s index 7e0652222..023c6ebef 100644 --- a/asm/contest.s +++ b/asm/contest.s @@ -58,7 +58,7 @@ sub_80D7678: @ 80D7678 strh r1, [r0] ldr r0, =gBattle_BG2_Y strh r1, [r0] - ldr r0, =gUnknown_02022E20 + ldr r0, =gBattle_BG3_X strh r1, [r0] ldr r0, =gUnknown_02022E22 strh r1, [r0] @@ -1340,7 +1340,7 @@ vblank_cb_battle: @ 80D827C ldrh r1, [r0] movs r0, 0x1A bl SetGpuReg - ldr r0, =gUnknown_02022E20 + ldr r0, =gBattle_BG3_X ldrh r1, [r0] movs r0, 0x1C bl SetGpuReg diff --git a/asm/contest_link_80F57C4.s b/asm/contest_link_80F57C4.s index 8da1eccba..8e2e2c61c 100644 --- a/asm/contest_link_80F57C4.s +++ b/asm/contest_link_80F57C4.s @@ -105,7 +105,7 @@ _080F57E0: strh r1, [r0] ldr r0, =gBattle_BG2_Y strh r1, [r0] - ldr r0, =gUnknown_02022E20 + ldr r0, =gBattle_BG3_X strh r1, [r0] ldr r0, =gUnknown_02022E22 strh r1, [r0] @@ -465,7 +465,7 @@ sub_80F5C24: @ 80F5C24 ldrh r1, [r0] movs r0, 0x1A bl SetGpuReg - ldr r0, =gUnknown_02022E20 + ldr r0, =gBattle_BG3_X ldrh r1, [r0] movs r0, 0x1C bl SetGpuReg @@ -1838,7 +1838,7 @@ _080F68A8: thumb_func_start sub_80F68B4 sub_80F68B4: @ 80F68B4 push {r4,r5,lr} - ldr r2, =gUnknown_02022E20 + ldr r2, =gBattle_BG3_X ldrh r3, [r2] adds r0, r3, 0x2 strh r0, [r2] diff --git a/asm/evolution_scene.s b/asm/evolution_scene.s index 55a843b92..5d0268173 100644 --- a/asm/evolution_scene.s +++ b/asm/evolution_scene.s @@ -178,7 +178,7 @@ evolution_cutscene: @ 813DA8C strh r2, [r0] ldr r0, =gBattle_BG2_Y strh r2, [r0] - ldr r1, =gUnknown_02022E20 + ldr r1, =gBattle_BG3_X movs r2, 0x80 lsls r2, 1 adds r0, r2, 0 @@ -472,7 +472,7 @@ sub_813DD7C: @ 813DD7C strh r4, [r0] ldr r0, =gBattle_BG2_Y strh r4, [r0] - ldr r1, =gUnknown_02022E20 + ldr r1, =gBattle_BG3_X movs r2, 0x80 lsls r2, 1 adds r0, r2, 0 @@ -642,7 +642,7 @@ _0813DFE0: strh r1, [r0] ldr r0, =gBattle_BG2_Y strh r1, [r0] - ldr r2, =gUnknown_02022E20 + ldr r2, =gBattle_BG3_X movs r3, 0x80 lsls r3, 1 adds r0, r3, 0 @@ -953,7 +953,7 @@ sub_813E1D4: @ 813E1D4 strh r4, [r0] ldr r0, =gBattle_BG2_Y strh r4, [r0] - ldr r1, =gUnknown_02022E20 + ldr r1, =gBattle_BG3_X movs r2, 0x80 lsls r2, 1 adds r0, r2, 0 @@ -3654,7 +3654,7 @@ sub_813FCDC: @ 813FCDC ldrh r1, [r0] movs r0, 0x1A bl SetGpuReg - ldr r0, =gUnknown_02022E20 + ldr r0, =gBattle_BG3_X ldrh r1, [r0] movs r0, 0x1C bl SetGpuReg @@ -3698,7 +3698,7 @@ sub_813FD64: @ 813FD64 ldrh r1, [r0] movs r0, 0x1A bl SetGpuReg - ldr r0, =gUnknown_02022E20 + ldr r0, =gBattle_BG3_X ldrh r1, [r0] movs r0, 0x1C bl SetGpuReg @@ -3870,7 +3870,7 @@ sub_813FEE8: @ 813FEE8 b _0813FF2C .pool _0813FF28: - ldr r7, =gUnknown_02022E20 + ldr r7, =gBattle_BG3_X ldr r6, =gUnknown_02022E22 _0813FF2C: lsls r4, r5, 2 diff --git a/asm/naming_screen.s b/asm/naming_screen.s index 1839a7568..22d7b260e 100644 --- a/asm/naming_screen.s +++ b/asm/naming_screen.s @@ -840,7 +840,7 @@ pokemon_transfer_to_pc_with_message: @ 80E34E4 bl VarGet lsls r0, 24 lsrs r0, 24 - bl sav3_get_box_name + bl GetBoxNamePtr adds r1, r0, 0 adds r0, r4, 0 bl StringCopy @@ -859,7 +859,7 @@ _080E3534: bl VarGet lsls r0, 24 lsrs r0, 24 - bl sav3_get_box_name + bl GetBoxNamePtr adds r1, r0, 0 adds r0, r4, 0 bl StringCopy @@ -874,7 +874,7 @@ _080E3534: bl get_unknown_box_id lsls r0, 24 lsrs r0, 24 - bl sav3_get_box_name + bl GetBoxNamePtr adds r1, r0, 0 adds r0, r4, 0 bl StringCopy diff --git a/asm/pokedex.s b/asm/pokedex.s index fdaacde2c..f9ee0eeab 100644 --- a/asm/pokedex.s +++ b/asm/pokedex.s @@ -8429,8 +8429,8 @@ _080BFDB4: .pool thumb_func_end sub_80BFD7C - thumb_func_start sub_80BFDF4 -sub_80BFDF4: @ 80BFDF4 + thumb_func_start CreateDexDisplayMonDataTask +CreateDexDisplayMonDataTask: @ 80BFDF4 push {r4-r6,lr} adds r4, r0, 0 adds r5, r1, 0 @@ -8460,7 +8460,7 @@ sub_80BFDF4: @ 80BFDF4 pop {r1} bx r1 .pool - thumb_func_end sub_80BFDF4 + thumb_func_end CreateDexDisplayMonDataTask thumb_func_start sub_80BFE38 sub_80BFE38: @ 80BFE38 diff --git a/asm/pokemon_storage_system.s b/asm/pokemon_storage_system.s index d94da87b1..6c4c7ff13 100755 --- a/asm/pokemon_storage_system.s +++ b/asm/pokemon_storage_system.s @@ -1019,7 +1019,7 @@ _080C777E: _080C779E: lsls r0, r5, 24 lsrs r0, 24 - bl sav3_get_box_name + bl GetBoxNamePtr ldr r1, =gText_Box bl StringCopy adds r4, r5, 0x1 @@ -1566,7 +1566,7 @@ sub_80C7BE4: @ 80C7BE4 lsls r4, 2 adds r0, r4 ldrb r0, [r0] - bl sav3_get_box_name + bl GetBoxNamePtr mov r10, r0 mov r1, r9 ldr r0, [r1] @@ -5424,7 +5424,7 @@ _080C9F1C: bl StorageGetCurrentBox lsls r0, 24 lsrs r0, 24 - bl sav3_get_box_name + bl GetBoxNamePtr adds r1, r0, 0 movs r0, 0 str r0, [sp] @@ -10831,7 +10831,7 @@ sub_80CCB50: @ 80CCB50 ldr r5, =0x000021b8 adds r4, r5 mov r0, r8 - bl sav3_get_box_name + bl GetBoxNamePtr adds r1, r0, 0 adds r0, r4, 0 movs r2, 0 @@ -10852,7 +10852,7 @@ sub_80CCB50: @ 80CCB50 ldr r0, [sp, 0x2C] bl LoadSpriteSheet mov r0, r8 - bl sav3_get_box_name + bl GetBoxNamePtr bl sub_80CD00C movs r4, 0 lsls r0, 16 @@ -10997,7 +10997,7 @@ _080CCDB0: ldr r5, =0x000021b8 adds r4, r5 ldr r0, [sp, 0x28] - bl sav3_get_box_name + bl GetBoxNamePtr adds r1, r0, 0 adds r0, r4, 0 movs r2, 0 @@ -11027,7 +11027,7 @@ _080CCDB0: movs r2, 0x4 bl LoadPalette ldr r0, [sp, 0x28] - bl sav3_get_box_name + bl GetBoxNamePtr bl sub_80CD00C lsls r0, 16 mov r1, r10 @@ -21085,8 +21085,8 @@ _080D20CA: bx r1 thumb_func_end GetBoxedMonPtr - thumb_func_start sav3_get_box_name -sav3_get_box_name: @ 80D20D0 + thumb_func_start GetBoxNamePtr +GetBoxNamePtr: @ 80D20D0 push {lr} lsls r0, 24 lsrs r2, r0, 24 @@ -21106,7 +21106,7 @@ _080D20EC: pop {r1} bx r1 .pool - thumb_func_end sav3_get_box_name + thumb_func_end GetBoxNamePtr thumb_func_start sub_80D20F8 sub_80D20F8: @ 80D20F8 diff --git a/asm/pokenav.s b/asm/pokenav.s index 6ae25b362..6f47df54c 100755 --- a/asm/pokenav.s +++ b/asm/pokenav.s @@ -13136,7 +13136,7 @@ _081CD8E4: ldr r2, =0x00006325 adds r4, r2 adds r0, r3, 0 - bl sav3_get_box_name + bl GetBoxNamePtr adds r1, r0, 0 adds r0, r4, 0 _081CD8F4: @@ -24164,7 +24164,7 @@ _081D2F2C: adds r4, r5, 0x5 lsls r0, r7, 24 lsrs r0, 24 - bl sav3_get_box_name + bl GetBoxNamePtr adds r1, r0, 0 adds r0, r4, 0 _081D2F3A: diff --git a/asm/reshow_battle_screen.s b/asm/reshow_battle_screen.s index 77d107f3d..42ba43ec0 100644 --- a/asm/reshow_battle_screen.s +++ b/asm/reshow_battle_screen.s @@ -111,7 +111,7 @@ _080A93B0: strh r1, [r0] ldr r0, =gBattle_BG2_Y strh r1, [r0] - ldr r0, =gUnknown_02022E20 + ldr r0, =gBattle_BG3_X strh r1, [r0] ldr r0, =gUnknown_02022E22 strh r1, [r0] @@ -286,7 +286,7 @@ _080A955C: b _080A95D2 .pool _080A95A4: - ldr r0, =vblank_cb_08078BB4 + ldr r0, =VBlankCB_Battle bl SetVBlankCallback bl sub_80A95F4 movs r0, 0x1 diff --git a/asm/rom3.s b/asm/rom3.s index 131721493..9bd95c252 100644 --- a/asm/rom3.s +++ b/asm/rom3.s @@ -2337,8 +2337,8 @@ EmitTrainerSlide: @ 8033A04 .pool thumb_func_end EmitTrainerSlide - thumb_func_start dp01_build_cmdbuf_x09_9_9_9 -dp01_build_cmdbuf_x09_9_9_9: @ 8033A24 + thumb_func_start EmitTrainerSlideBack +EmitTrainerSlideBack: @ 8033A24 push {lr} lsls r0, 24 lsrs r0, 24 @@ -2353,7 +2353,7 @@ dp01_build_cmdbuf_x09_9_9_9: @ 8033A24 pop {r0} bx r0 .pool - thumb_func_end dp01_build_cmdbuf_x09_9_9_9 + thumb_func_end EmitTrainerSlideBack thumb_func_start EmitFaintAnimation EmitFaintAnimation: @ 8033A44 @@ -2409,8 +2409,8 @@ dp01_build_cmdbuf_x0C_C_C_C: @ 8033A84 .pool thumb_func_end dp01_build_cmdbuf_x0C_C_C_C - thumb_func_start dp01_build_cmdbuf_x0D_a -dp01_build_cmdbuf_x0D_a: @ 8033AA4 + thumb_func_start EmitBallThrow +EmitBallThrow: @ 8033AA4 push {lr} adds r3, r1, 0 lsls r0, 24 @@ -2424,7 +2424,7 @@ dp01_build_cmdbuf_x0D_a: @ 8033AA4 pop {r0} bx r0 .pool - thumb_func_end dp01_build_cmdbuf_x0D_a + thumb_func_end EmitBallThrow thumb_func_start sub_8033AC4 sub_8033AC4: @ 8033AC4 diff --git a/asm/scrcmd.s b/asm/scrcmd.s index 39366d29f..9a3505b4f 100644 --- a/asm/scrcmd.s +++ b/asm/scrcmd.s @@ -4183,7 +4183,7 @@ sC6_load_textvar_box_label: @ 809B2C8 ldr r4, [r4] lsls r0, 24 lsrs r0, 24 - bl sav3_get_box_name + bl GetBoxNamePtr adds r1, r0, 0 adds r0, r4, 0 bl StringCopy diff --git a/asm/unknown_task.s b/asm/unknown_task.s index 9c01afe93..99a614e37 100644 --- a/asm/unknown_task.s +++ b/asm/unknown_task.s @@ -291,7 +291,7 @@ _080BA23C: b _080BA24E .pool _080BA244: - ldr r0, =gUnknown_02022E20 + ldr r0, =gBattle_BG3_X b _080BA24E .pool _080BA24C: diff --git a/data/battle_scripts_2.s b/data/battle_scripts_2.s index e76bb397b..938531a57 100644 --- a/data/battle_scripts_2.s +++ b/data/battle_scripts_2.s @@ -16,14 +16,14 @@ gUnknown_082DBD54:: @ 82DBD54 gUnknown_082DBD58:: @ 82DBD58 .incbin "baserom.gba", 0x2dbd58, 0x2c -gUnknown_082DBD84:: @ 82DBD84 +BattleScript_SuccessBallThrow:: @ 82DBD84 .incbin "baserom.gba", 0x2dbd84, 0x46 -gUnknown_082DBDCA:: @ 82DBDCA +BattleScript_WallyBallThrow:: @ 82DBDCA .incbin "baserom.gba", 0x2dbdca, 0xa -gUnknown_082DBDD4:: @ 82DBDD4 +BattleScript_ShakeBallThrow:: @ 82DBDD4 .incbin "baserom.gba", 0x2dbdd4, 0x2e -gUnknown_082DBE02:: @ 82DBE02 +BattleScript_TrainerBallBlock:: @ 82DBE02 .incbin "baserom.gba", 0x2dbe02, 0xf6 diff --git a/include/battle.h b/include/battle.h index a0a50faf7..7b164caf4 100644 --- a/include/battle.h +++ b/include/battle.h @@ -205,6 +205,7 @@ #define WEATHER_SUN_ANY ((WEATHER_SUN_TEMPORARY | WEATHER_SUN_PERMANENT)) #define WEATHER_HAIL (1 << 7) #define WEATHER_HAIL_ANY ((WEATHER_HAIL)) +#define WEATHER_ANY ((WEATHER_RAIN_ANY | WEATHER_SANDSTORM_ANY | WEATHER_SUN_ANY | WEATHER_HAIL_ANY)) #define BATTLE_TERRAIN_GRASS 0 #define BATTLE_TERRAIN_LONG_GRASS 1 @@ -216,7 +217,9 @@ #define BATTLE_TERRAIN_CAVE 7 // array entries for battle communication +#define MULTIUSE_STATE 0x0 #define CURSOR_POSITION 0x1 +#define TASK_ID 0x1 // task Id and cursor position share the same field #define MOVE_EFFECT_BYTE 0x3 #define MULTISTRING_CHOOSER 0x5 #define MSG_DISPLAY 0x7 @@ -531,6 +534,9 @@ struct BattleResults u8 unk4; // 0x4 u8 unk5_0:1; // 0x5 u8 unk5_1:1; // 0x5 + u8 caughtMonBall:4; // 0x5 + u8 unk5_6:1; // 0x5 + u8 unk5_7:1; // 0x5 u16 poke1Species; // 0x6 u8 pokeString1[10]; // 0x8 u8 unk12; @@ -542,10 +548,10 @@ struct BattleResults u16 lastUsedMove; // 0x22 u16 opponentMove; // 0x24 u16 opponentSpecies; // 0x26 - u16 caughtPoke; // 0x28 - u8 caughtNick[10]; // 0x2A + u16 caughtMonSpecies; // 0x28 + u8 caughtMonNick[10]; // 0x2A u8 filler34[2]; - u8 unk36[10]; // usedBalls? + u8 catchAttempts[10]; // 0x36 }; extern struct BattleResults gBattleResults; @@ -588,17 +594,7 @@ struct BattleStruct u8 field_5C[4]; u8 field_60[4][3]; u8 field_6C; - u8 field_6D; - u8 field_6E; - u8 field_6F; - u8 field_70; - u8 field_71; - u8 field_72; - u8 field_73; - u8 field_74; - u8 field_75; - u8 field_76; - u8 field_77; + u8 caughtMonNick[11]; u8 field_78; u8 field_79; u8 field_7A; @@ -845,6 +841,7 @@ struct BattleScripting u8 field_1D; u8 atk6C_state; u8 learnMoveState; + u8 field_20; }; extern struct BattleScripting gBattleScripting; @@ -862,6 +859,7 @@ void SwitchInClearStructs(void); void sub_803BDA0(u8 bank); void sub_803FA70(u8 bank); void BattleMainCB2(void); +void VBlankCB_Battle(void); void ResetSentPokesToOpponentValue(void); bool8 CanRunFromBattle(u8 bank); bool8 IsRunningFromBattleImpossible(void); @@ -892,8 +890,8 @@ u8 AtkCanceller_UnableToUseMove(void); bool8 sub_80423F4(u8 bank, u8 r1, u8 r2); u8 CastformDataTypeChange(u8 bank); u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg); -void b_call_bc_move_exec(const u8* BS_ptr); -void b_push_move_exec(const u8* BS_ptr); +void BattleScriptExecute(const u8* BS_ptr); +void BattleScriptPushCursorAndCallback(const u8* BS_ptr); u8 ItemBattleEffects(u8 caseID, u8 bank, bool8 moveTurn); void sub_8045868(u8 bank); void sub_80458B4(void); @@ -905,9 +903,12 @@ void AI_CalcDmg(u8 bankAtk, u8 bankDef); u8 TypeCalc(u16 move, u8 bankAtk, u8 bankDef); u8 AI_TypeCalc(u16 move, u16 species, u8 ability); u8 BankGetTurnOrder(u8 bank); +void SetMoveEffect(bool8 primary, u8 certain); void BattleDestroyCursorAt(u8 cursorPosition); void BattleCreateCursorAt(u8 cursorPosition); void BufferMoveToLearnIntoBattleTextBuff2(void); +void sub_8056A3C(u8 xStart, u8 yStart, u8 xEnd, u8 yEnd, u8 flags); +bool8 UproarWakeUpCheck(u8 bank); // battle_5 void AdjustFriendshipOnBattleFaint(u8 bank); diff --git a/include/battle_controllers.h b/include/battle_controllers.h index bb58cb699..b2846d7cf 100644 --- a/include/battle_controllers.h +++ b/include/battle_controllers.h @@ -43,6 +43,7 @@ void EmitSwitchInAnim(u8 bufferId, u8 partyId, bool8 dontClearSubstituteBit); void EmitChoosePokemon(u8 bufferId, u8 caseId, u8 arg2, u8 abilityId, const u8* arg4); void EmitLinkStandbyMsg(u8 bufferId, u8 arg1, u8 arg2); void EmitTrainerSlide(u8 bufferId); +void EmitTrainerSlideBack(u8 bufferId); void EmitFaintingCry(u8 bufferId); void Emit_x37(u8 bufferId, u8 arg1); void EmitHitAnimation(u8 bufferId); @@ -51,12 +52,22 @@ void EmitCmd49(u8 bufferId); void EmitStatusAnimation(u8 bufferId, bool8 status2, u32 status); void EmitCmd13(u8 bufferId); void EmitStatusIconUpdate(u8 bufferId, u32 status1, u32 status2); -void EmitResetActionMoveSelection(u8 bufferId, u8 caseId); #define RESET_ACTION_MOVE_SELECTION 0 #define RESET_ACTION_SELECTION 1 #define RESET_MOVE_SELECTION 2 +void EmitResetActionMoveSelection(u8 bufferId, u8 caseId); + +#define BALL_NO_SHAKES 0 +#define BALL_1_SHAKE 1 +#define BALL_2_SHAKES 2 +#define BALL_3_SHAKES_FAIL 3 +#define BALL_3_SHAKES_SUCCESS 4 +#define BALL_TRAINER_BLOCK 5 + +void EmitBallThrow(u8 bufferId, u8 caseId); + void MarkBufferBankForExecution(u8 bank); #endif // GUARD_BATTLE_CONTROLLERS_H diff --git a/include/battle_message.h b/include/battle_message.h index 6e6616cf0..3bc7117bb 100644 --- a/include/battle_message.h +++ b/include/battle_message.h @@ -211,4 +211,6 @@ extern u8 gBattleTextBuff2[]; extern u8 gBattleTextBuff3[]; extern u8 gDisplayedStringBattle[]; +extern const u8* const gRefereeStringsTable[]; + #endif // GUARD_BATTLE_MESSAGE_H diff --git a/include/naming_screen.h b/include/naming_screen.h new file mode 100644 index 000000000..55a8e75a3 --- /dev/null +++ b/include/naming_screen.h @@ -0,0 +1,12 @@ +#ifndef GUARD_NAMING_SCREEN_H +#define GUARD_NAMING_SCREEN_H + +#define NAMING_SCREEN_PLAYER 0 +#define NAMING_SCREEN_BOX 1 +#define NAMING_SCREEN_CAUGHT_MON 2 +#define NAMING_SCREEN_3 3 +#define NAMING_SCREEN_WANDA 4 + +void DoNamingScreen(u8 caseId, u8* dst, u16 monSpecies, u8 monGender, u32 monPersonality, void (*callback)(void)); + +#endif // GUARD_NAMING_SCREEN_H diff --git a/include/pokedex.h b/include/pokedex.h index 15f819a2a..38aca0915 100644 --- a/include/pokedex.h +++ b/include/pokedex.h @@ -6,6 +6,7 @@ const u8 *GetPokemonCategory(u16); u16 GetPokedexHeightWeight(u16 dexNum, u8 data); u16 GetNationalPokedexCount(u8); u16 GetHoennPokedexCount(u8); +u8 CreateDexDisplayMonDataTask(u16 dexNum, u32 trainerId, u32 personality); enum { diff --git a/include/pokemon_storage_system.h b/include/pokemon_storage_system.h new file mode 100644 index 000000000..5216e8450 --- /dev/null +++ b/include/pokemon_storage_system.h @@ -0,0 +1,6 @@ +#ifndef GUARD_POKEMON_STORAGE_SYSTEM_H +#define GUARD_POKEMON_STORAGE_SYSTEM_H + +u8* GetBoxNamePtr(u8 boxNumber); + +#endif // GUARD_POKEMON_STORAGE_SYSTEM_H diff --git a/ld_script.txt b/ld_script.txt index b2e996ff5..ffa8baba6 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -60,7 +60,6 @@ SECTIONS { asm/battle_2.o(.text); src/battle_3.o(.text); src/battle_4.o(.text); - asm/battle_4.o(.text); asm/battle_5.o(.text); asm/battle_controller_player.o(.text); asm/battle_7.o(.text); diff --git a/src/battle_3.c b/src/battle_3.c index 9ac439390..e81d527d0 100644 --- a/src/battle_3.c +++ b/src/battle_3.c @@ -179,13 +179,9 @@ extern const u8 gStatusConditionString_ConfusionJpn[]; extern const u8 gStatusConditionString_LoveJpn[]; extern const u16 gSoundMovesTable[]; -extern void CancelMultiTurnMoves(u8 bank); extern u8 b_first_side(u8, u8, u8); extern void sub_803CEDC(u8, u8); -extern void b_call_bc_move_exec(const u8 *); extern void BattleTurnPassed(void); -extern void SetMoveEffect(bool8 primary, u8 certainArg); -extern bool8 UproarWakeUpCheck(u8 bank); extern void sub_803F9EC(); extern bool8 sub_80423F4(u8 bank, u8, u8); extern u8 weather_get_current(void); @@ -441,7 +437,7 @@ u8 UpdateTurnCounters(void) if (--gSideTimers[sideBank].reflectTimer == 0) { gSideAffecting[sideBank] &= ~SIDE_STATUS_REFLECT; - b_call_bc_move_exec(gUnknown_082DACFA); + BattleScriptExecute(gUnknown_082DACFA); gBattleTextBuff1[0] = 0xFD; gBattleTextBuff1[1] = 2; gBattleTextBuff1[2] = MOVE_REFLECT; @@ -470,7 +466,7 @@ u8 UpdateTurnCounters(void) if (--gSideTimers[sideBank].lightscreenTimer == 0) { gSideAffecting[sideBank] &= ~SIDE_STATUS_LIGHTSCREEN; - b_call_bc_move_exec(gUnknown_082DACFA); + BattleScriptExecute(gUnknown_082DACFA); gBattleCommunication[MULTISTRING_CHOOSER] = sideBank; gBattleTextBuff1[0] = 0xFD; gBattleTextBuff1[1] = 2; @@ -499,7 +495,7 @@ u8 UpdateTurnCounters(void) && --gSideTimers[sideBank].mistTimer == 0) { gSideAffecting[sideBank] &= ~SIDE_STATUS_MIST; - b_call_bc_move_exec(gUnknown_082DACFA); + BattleScriptExecute(gUnknown_082DACFA); gBattleCommunication[MULTISTRING_CHOOSER] = sideBank; gBattleTextBuff1[0] = 0xFD; gBattleTextBuff1[1] = 2; @@ -528,7 +524,7 @@ u8 UpdateTurnCounters(void) if (--gSideTimers[sideBank].safeguardTimer == 0) { gSideAffecting[sideBank] &= ~SIDE_STATUS_SAFEGUARD; - b_call_bc_move_exec(gUnknown_082DAD0B); + BattleScriptExecute(gUnknown_082DAD0B); effect++; } } @@ -551,7 +547,7 @@ u8 UpdateTurnCounters(void) && gBattleMons[gActiveBank].hp != 0) { gBankTarget = gActiveBank; - b_call_bc_move_exec(BattleScript_WishComesTrue); + BattleScriptExecute(BattleScript_WishComesTrue); effect++; } gBattleStruct->turnSideTracker++; @@ -583,7 +579,7 @@ u8 UpdateTurnCounters(void) gBattleCommunication[MULTISTRING_CHOOSER] = 1; else gBattleCommunication[MULTISTRING_CHOOSER] = 0; - b_call_bc_move_exec(gUnknown_082DAC2C); + BattleScriptExecute(gUnknown_082DAC2C); effect++; } gBattleStruct->turncountersTracker++; @@ -601,7 +597,7 @@ u8 UpdateTurnCounters(void) gBattleScripting.animArg1 = 0xC; gBattleCommunication[MULTISTRING_CHOOSER] = 0; - b_call_bc_move_exec(gBattlescriptCurrInstr); + BattleScriptExecute(gBattlescriptCurrInstr); effect++; } gBattleStruct->turncountersTracker++; @@ -617,7 +613,7 @@ u8 UpdateTurnCounters(void) else gBattlescriptCurrInstr = gUnknown_082DACD2; - b_call_bc_move_exec(gBattlescriptCurrInstr); + BattleScriptExecute(gBattlescriptCurrInstr); effect++; } gBattleStruct->turncountersTracker++; @@ -635,7 +631,7 @@ u8 UpdateTurnCounters(void) gBattleScripting.animArg1 = 0xD; gBattleCommunication[MULTISTRING_CHOOSER] = 1; - b_call_bc_move_exec(gBattlescriptCurrInstr); + BattleScriptExecute(gBattlescriptCurrInstr); effect++; } gBattleStruct->turncountersTracker++; @@ -675,7 +671,7 @@ u8 TurnBasedEffects(void) if (gBattleMoveDamage == 0) gBattleMoveDamage = 1; gBattleMoveDamage *= -1; - b_call_bc_move_exec(BattleScript_IngrainTurnHeal); + BattleScriptExecute(BattleScript_IngrainTurnHeal); effect++; } gBattleStruct->turnEffectsTracker++; @@ -706,7 +702,7 @@ u8 TurnBasedEffects(void) gBattleMoveDamage = 1; gBattleScripting.animArg1 = gBankTarget; gBattleScripting.animArg2 = gBankAttacker; - b_call_bc_move_exec(BattleScript_LeechSeedTurnDrain); + BattleScriptExecute(BattleScript_LeechSeedTurnDrain); effect++; } gBattleStruct->turnEffectsTracker++; @@ -717,7 +713,7 @@ u8 TurnBasedEffects(void) gBattleMoveDamage = gBattleMons[gActiveBank].maxHP / 8; if (gBattleMoveDamage == 0) gBattleMoveDamage = 1; - b_call_bc_move_exec(BattleScript_PoisonTurnDmg); + BattleScriptExecute(BattleScript_PoisonTurnDmg); effect++; } gBattleStruct->turnEffectsTracker++; @@ -731,7 +727,7 @@ u8 TurnBasedEffects(void) if ((gBattleMons[gActiveBank].status1 & 0xF00) != 0xF00) //not 16 turns gBattleMons[gActiveBank].status1 += 0x100; gBattleMoveDamage *= (gBattleMons[gActiveBank].status1 & 0xF00) >> 8; - b_call_bc_move_exec(BattleScript_PoisonTurnDmg); + BattleScriptExecute(BattleScript_PoisonTurnDmg); effect++; } gBattleStruct->turnEffectsTracker++; @@ -742,7 +738,7 @@ u8 TurnBasedEffects(void) gBattleMoveDamage = gBattleMons[gActiveBank].maxHP / 8; if (gBattleMoveDamage == 0) gBattleMoveDamage = 1; - b_call_bc_move_exec(BattleScript_BurnTurnDmg); + BattleScriptExecute(BattleScript_BurnTurnDmg); effect++; } gBattleStruct->turnEffectsTracker++; @@ -757,7 +753,7 @@ u8 TurnBasedEffects(void) gBattleMoveDamage = gBattleMons[gActiveBank].maxHP / 4; if (gBattleMoveDamage == 0) gBattleMoveDamage = 1; - b_call_bc_move_exec(BattleScript_NightmareTurnDmg); + BattleScriptExecute(BattleScript_NightmareTurnDmg); effect++; } else @@ -773,7 +769,7 @@ u8 TurnBasedEffects(void) gBattleMoveDamage = gBattleMons[gActiveBank].maxHP / 4; if (gBattleMoveDamage == 0) gBattleMoveDamage = 1; - b_call_bc_move_exec(BattleScript_CurseTurnDmg); + BattleScriptExecute(BattleScript_CurseTurnDmg); effect++; } gBattleStruct->turnEffectsTracker++; @@ -806,7 +802,7 @@ u8 TurnBasedEffects(void) gBattleTextBuff1[4] = EOS; gBattlescriptCurrInstr = BattleScript_WrapEnds; } - b_call_bc_move_exec(gBattlescriptCurrInstr); + BattleScriptExecute(gBattlescriptCurrInstr); effect++; } gBattleStruct->turnEffectsTracker++; @@ -822,7 +818,7 @@ u8 TurnBasedEffects(void) gBattleMons[gBankAttacker].status1 &= ~(STATUS_SLEEP); gBattleMons[gBankAttacker].status2 &= ~(STATUS2_NIGHTMARE); gBattleCommunication[MULTISTRING_CHOOSER] = 1; - b_call_bc_move_exec(gUnknown_082DB234); + BattleScriptExecute(gUnknown_082DB234); gActiveBank = gBankAttacker; EmitSetMonData(0, REQUEST_STATUS_BATTLE, 0, 4, &gBattleMons[gActiveBank].status1); MarkBufferBankForExecution(gActiveBank); @@ -853,7 +849,7 @@ u8 TurnBasedEffects(void) gBattleCommunication[MULTISTRING_CHOOSER] = 1; CancelMultiTurnMoves(gActiveBank); } - b_call_bc_move_exec(gUnknown_082DB2A6); + BattleScriptExecute(gUnknown_082DB2A6); effect = 1; } } @@ -875,7 +871,7 @@ u8 TurnBasedEffects(void) gBattleCommunication[MOVE_EFFECT_BYTE] = 0x47; SetMoveEffect(1, 0); if (gBattleMons[gActiveBank].status2 & STATUS2_CONFUSION) - b_call_bc_move_exec(BattleScript_ThrashConfuses); + BattleScriptExecute(BattleScript_ThrashConfuses); effect++; } } @@ -899,7 +895,7 @@ u8 TurnBasedEffects(void) else if (--gDisableStructs[gActiveBank].disableTimer1 == 0) // disable ends { gDisableStructs[gActiveBank].disabledMove = 0; - b_call_bc_move_exec(BattleScript_DisabledNoMore); + BattleScriptExecute(BattleScript_DisabledNoMore); effect++; } } @@ -918,7 +914,7 @@ u8 TurnBasedEffects(void) { gDisableStructs[gActiveBank].encoredMove = 0; gDisableStructs[gActiveBank].encoreTimer1 = 0; - b_call_bc_move_exec(BattleScript_EncoredNoMore); + BattleScriptExecute(BattleScript_EncoredNoMore); effect++; } } @@ -952,7 +948,7 @@ u8 TurnBasedEffects(void) EmitSetMonData(0, REQUEST_STATUS_BATTLE, 0, 4, &gBattleMons[gActiveBank].status1); MarkBufferBankForExecution(gActiveBank); gEffectBank = gActiveBank; - b_call_bc_move_exec(BattleScript_YawnMakesAsleep); + BattleScriptExecute(BattleScript_YawnMakesAsleep); effect++; } } @@ -1006,7 +1002,7 @@ bool8 sub_8041364(void) gBankAttacker = gWishFutureKnock.futureSightAttacker[gActiveBank]; gBattleMoveDamage = gWishFutureKnock.futureSightDmg[gActiveBank]; gSpecialStatuses[gBankTarget].moveturnLostHP = 0xFFFF; - b_call_bc_move_exec(gUnknown_082DAFE4); + BattleScriptExecute(gUnknown_082DAFE4); if (gWishFutureKnock.futureSightCounter[gActiveBank] == 0 && gWishFutureKnock.futureSightCounter[gActiveBank ^ 2] == 0) @@ -1052,7 +1048,7 @@ bool8 sub_8041364(void) gDisableStructs[gActiveBank].perishSong1--; gBattlescriptCurrInstr = gUnknown_082DAF20; } - b_call_bc_move_exec(gBattlescriptCurrInstr); + BattleScriptExecute(gBattlescriptCurrInstr); return 1; } } @@ -1074,7 +1070,7 @@ bool8 sub_8041364(void) CancelMultiTurnMoves(i); gBattlescriptCurrInstr = gUnknown_082DB8F3; - b_call_bc_move_exec(gUnknown_082DB8F3); + BattleScriptExecute(gUnknown_082DB8F3); gBattleStruct->field_1A0++; return 1; } @@ -1114,7 +1110,7 @@ bool8 sub_8041728(void) && !(gBattleStruct->field_DF & gBitTable[gBattlePartyID[gBattleStruct->field_4E]]) && !(gAbsentBankFlags & gBitTable[gBattleStruct->field_4E])) { - b_call_bc_move_exec(gUnknown_082DA7C4); + BattleScriptExecute(gUnknown_082DA7C4); gBattleStruct->field_4D = 2; return TRUE; } @@ -1139,7 +1135,7 @@ bool8 sub_8041728(void) if (gBattleMons[gBattleStruct->field_4E].hp == 0 && !(gAbsentBankFlags & gBitTable[gBattleStruct->field_4E])) { - b_call_bc_move_exec(gUnknown_082DA7CD); + BattleScriptExecute(gUnknown_082DA7CD); gBattleStruct->field_4D = 5; return TRUE; } @@ -1709,7 +1705,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) if (effect) { gBattleCommunication[MULTISTRING_CHOOSER] = weather_get_current(); - b_push_move_exec(gUnknown_082DACE7); + BattleScriptPushCursorAndCallback(gUnknown_082DACE7); } break; case ABILITY_DRIZZLE: @@ -1717,7 +1713,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) if (!(gBattleWeather & WEATHER_RAIN_PERMANENT)) { gBattleWeather = (WEATHER_RAIN_PERMANENT | WEATHER_RAIN_TEMPORARY); - b_push_move_exec(BattleScript_DrizzleActivates); + BattleScriptPushCursorAndCallback(BattleScript_DrizzleActivates); gBattleScripting.bank = bank; effect++; } @@ -1727,7 +1723,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) if (!(gBattleWeather & WEATHER_SANDSTORM_PERMANENT)) { gBattleWeather = (WEATHER_SANDSTORM_PERMANENT | WEATHER_SANDSTORM_TEMPORARY); - b_push_move_exec(BattleScript_SandstreamActivates); + BattleScriptPushCursorAndCallback(BattleScript_SandstreamActivates); gBattleScripting.bank = bank; effect++; } @@ -1737,7 +1733,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) if (!(gBattleWeather & WEATHER_SUN_PERMANENT)) { gBattleWeather = (WEATHER_SUN_PERMANENT | WEATHER_SUN_TEMPORARY); - b_push_move_exec(BattleScript_DroughtActivates); + BattleScriptPushCursorAndCallback(BattleScript_DroughtActivates); gBattleScripting.bank = bank; effect++; } @@ -1755,7 +1751,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) effect = CastformDataTypeChange(bank); if (effect != 0) { - b_push_move_exec(BattleScript_CastformChange); + BattleScriptPushCursorAndCallback(BattleScript_CastformChange); gBattleScripting.bank = bank; gBattleStruct->formToChangeInto = effect - 1; } @@ -1779,7 +1775,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) effect = CastformDataTypeChange(i); if (effect != 0) { - b_push_move_exec(BattleScript_CastformChange); + BattleScriptPushCursorAndCallback(BattleScript_CastformChange); gBattleScripting.bank = i; gBattleStruct->formToChangeInto = effect - 1; break; @@ -1802,7 +1798,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) && gBattleMons[bank].maxHP > gBattleMons[bank].hp) { gLastUsedAbility = ABILITY_RAIN_DISH; //why - b_push_move_exec(BattleScript_RainDishActivates); + BattleScriptPushCursorAndCallback(BattleScript_RainDishActivates); gBattleMoveDamage = gBattleMons[bank].maxHP / 16; if (gBattleMoveDamage == 0) gBattleMoveDamage = 1; @@ -1827,7 +1823,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) gBattleMons[bank].status1 = 0; gBattleMons[bank].status2 &= ~(STATUS2_NIGHTMARE); // fix nighmare glitch gBattleScripting.bank = gActiveBank = bank; - b_push_move_exec(BattleScript_ShedSkinActivates); + BattleScriptPushCursorAndCallback(BattleScript_ShedSkinActivates); EmitSetMonData(0, REQUEST_STATUS_BATTLE, 0, 4, &gBattleMons[bank].status1); MarkBufferBankForExecution(gActiveBank); effect++; @@ -1840,7 +1836,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) gBattleMons[bank].statStages[STAT_STAGE_SPEED]++; gBattleScripting.animArg1 = 0x11; gBattleScripting.animArg2 = 0; - b_push_move_exec(BattleScript_SpeedBoostActivates); + BattleScriptPushCursorAndCallback(BattleScript_SpeedBoostActivates); gBattleScripting.bank = bank; effect++; } @@ -2167,7 +2163,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) effect = CastformDataTypeChange(i); if (effect) { - b_push_move_exec(BattleScript_CastformChange); + BattleScriptPushCursorAndCallback(BattleScript_CastformChange); gBattleScripting.bank = i; gBattleStruct->formToChangeInto = effect - 1; return effect; @@ -2215,7 +2211,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) { gLastUsedAbility = ABILITY_INTIMIDATE; gStatuses3[i] &= ~(STATUS3_INTIMIDATE_POKES); - b_push_move_exec(gUnknown_082DB4B8); + BattleScriptPushCursorAndCallback(gUnknown_082DB4B8); gBattleStruct->intimidateBank = i; effect++; break; @@ -2267,7 +2263,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) } if (effect) { - b_push_move_exec(BattleScript_TraceActivates); + BattleScriptPushCursorAndCallback(BattleScript_TraceActivates); gStatuses3[i] &= ~(STATUS3_TRACE); gBattleScripting.bank = i; @@ -2774,7 +2770,7 @@ _08042B56:\n\ ldr r1, =gBattleCommunication\n\ strb r0, [r1, 0x5]\n\ ldr r0, =gUnknown_082DACE7\n\ - bl b_push_move_exec\n\ + bl BattleScriptPushCursorAndCallback\n\ bl _0804441E\n\ .pool\n\ _08042B78:\n\ @@ -2789,7 +2785,7 @@ _08042B88:\n\ movs r0, 0x5\n\ strh r0, [r2]\n\ ldr r0, =BattleScript_DrizzleActivates\n\ - bl b_push_move_exec\n\ + bl BattleScriptPushCursorAndCallback\n\ ldr r0, =gBattleScripting\n\ mov r1, r10\n\ strb r1, [r0, 0x17]\n\ @@ -2807,7 +2803,7 @@ _08042BB8:\n\ movs r0, 0x18\n\ strh r0, [r2]\n\ ldr r0, =BattleScript_SandstreamActivates\n\ - bl b_push_move_exec\n\ + bl BattleScriptPushCursorAndCallback\n\ ldr r0, =gBattleScripting\n\ mov r2, r10\n\ strb r2, [r0, 0x17]\n\ @@ -2825,7 +2821,7 @@ _08042BE8:\n\ movs r0, 0x60\n\ strh r0, [r2]\n\ ldr r0, =BattleScript_DroughtActivates\n\ - bl b_push_move_exec\n\ + bl BattleScriptPushCursorAndCallback\n\ ldr r0, =gBattleScripting\n\ mov r3, r10\n\ strb r3, [r0, 0x17]\n\ @@ -2866,7 +2862,7 @@ _08042C3C:\n\ bl _0804443A\n\ _08042C50:\n\ ldr r0, =BattleScript_CastformChange\n\ - bl b_push_move_exec\n\ + bl BattleScriptPushCursorAndCallback\n\ ldr r0, =gBattleScripting\n\ mov r1, r10\n\ strb r1, [r0, 0x17]\n\ @@ -2999,7 +2995,7 @@ _08042D66:\n\ _08042D72:\n\ strb r5, [r7]\n\ ldr r0, =BattleScript_RainDishActivates\n\ - bl b_push_move_exec\n\ + bl BattleScriptPushCursorAndCallback\n\ ldr r1, =gBattleMoveDamage\n\ ldrh r0, [r4, 0x2C]\n\ lsrs r0, 4\n\ @@ -3093,7 +3089,7 @@ _08042E24:\n\ strb r3, [r4]\n\ strb r3, [r0, 0x17]\n\ ldr r0, =BattleScript_ShedSkinActivates\n\ - bl b_push_move_exec\n\ + bl BattleScriptPushCursorAndCallback\n\ str r5, [sp]\n\ movs r0, 0\n\ movs r1, 0x28\n\ @@ -3131,7 +3127,7 @@ _08042EA8:\n\ strb r0, [r4, 0x10]\n\ strb r1, [r4, 0x11]\n\ ldr r0, =BattleScript_SpeedBoostActivates\n\ - bl b_push_move_exec\n\ + bl BattleScriptPushCursorAndCallback\n\ strb r5, [r4, 0x17]\n\ bl _080443D0\n\ .pool\n\ @@ -5288,7 +5284,7 @@ _080442C0:\n\ .pool\n\ _080442D8:\n\ ldr r0, =BattleScript_CastformChange\n\ - bl b_push_move_exec\n\ + bl BattleScriptPushCursorAndCallback\n\ ldr r0, =gBattleScripting\n\ strb r6, [r0, 0x17]\n\ _080442E2:\n\ @@ -5302,7 +5298,7 @@ _080442E2:\n\ .pool\n\ _080442FC:\n\ ldr r0, =BattleScript_CastformChange\n\ - bl b_push_move_exec\n\ + bl BattleScriptPushCursorAndCallback\n\ ldr r0, =gBattleScripting\n\ mov r5, r10\n\ strb r5, [r0, 0x17]\n\ @@ -5321,12 +5317,12 @@ _08044324:\n\ ands r0, r1\n\ str r0, [r2]\n\ ldr r0, =gUnknown_082DB4B8\n\ - bl b_push_move_exec\n\ + bl BattleScriptPushCursorAndCallback\n\ b _080443C8\n\ .pool\n\ _08044340:\n\ ldr r0, =BattleScript_TraceActivates\n\ - bl b_push_move_exec\n\ + bl BattleScriptPushCursorAndCallback\n\ ldr r1, =gStatuses3\n\ ldr r0, [sp, 0x18]\n\ adds r1, r0, r1\n\ @@ -5445,7 +5441,7 @@ _0804443A:\n\ } #endif // NONMATCHING -void b_call_bc_move_exec(const u8* BS_ptr) +void BattleScriptExecute(const u8* BS_ptr) { gBattlescriptCurrInstr = BS_ptr; BATTLE_CALLBACKS_STACK->function[BATTLE_CALLBACKS_STACK->size++] = gBattleMainFunc; @@ -5453,7 +5449,7 @@ void b_call_bc_move_exec(const u8* BS_ptr) gFightStateTracker = 0; } -void b_push_move_exec(const u8* BS_ptr) +void BattleScriptPushCursorAndCallback(const u8* BS_ptr) { BattleScriptPushCursor(); gBattlescriptCurrInstr = BS_ptr; @@ -5549,7 +5545,7 @@ u8 ItemBattleEffects(u8 caseID, u8 bank, bool8 moveTurn) gBattleScripting.bank = bank; gStringBank = bank; gActiveBank = gBankAttacker = bank; - b_call_bc_move_exec(BattleScript_WhiteHerbEnd2); + BattleScriptExecute(BattleScript_WhiteHerbEnd2); } break; } @@ -5566,7 +5562,7 @@ u8 ItemBattleEffects(u8 caseID, u8 bank, bool8 moveTurn) if (gBattleMons[bank].hp + bankQuality > gBattleMons[bank].maxHP) gBattleMoveDamage = gBattleMons[bank].maxHP - gBattleMons[bank].hp; gBattleMoveDamage *= -1; - b_call_bc_move_exec(BattleScript_ItemHealHP_RemoveItem); + BattleScriptExecute(BattleScript_ItemHealHP_RemoveItem); effect = 4; } break; @@ -5601,7 +5597,7 @@ u8 ItemBattleEffects(u8 caseID, u8 bank, bool8 moveTurn) gBattleTextBuff1[2] = move; gBattleTextBuff1[3] = move >> 8; gBattleTextBuff1[4] = 0xFF; - b_call_bc_move_exec(BattleScript_BerryPPHealEnd2); + BattleScriptExecute(BattleScript_BerryPPHealEnd2); EmitSetMonData(0, i + REQUEST_PPMOVE1_BATTLE, 0, 1, &changedPP); MarkBufferBankForExecution(gActiveBank); effect = ITEM_PP_CHANGE; @@ -5622,7 +5618,7 @@ u8 ItemBattleEffects(u8 caseID, u8 bank, bool8 moveTurn) gBattleScripting.bank = bank; gStringBank = bank; gActiveBank = gBankAttacker = bank; - b_call_bc_move_exec(BattleScript_WhiteHerbEnd2); + BattleScriptExecute(BattleScript_WhiteHerbEnd2); } break; case HOLD_EFFECT_LEFTOVERS: @@ -5634,7 +5630,7 @@ u8 ItemBattleEffects(u8 caseID, u8 bank, bool8 moveTurn) if (gBattleMons[bank].hp + gBattleMoveDamage > gBattleMons[bank].maxHP) gBattleMoveDamage = gBattleMons[bank].maxHP - gBattleMons[bank].hp; gBattleMoveDamage *= -1; - b_call_bc_move_exec(BattleScript_ItemHealHP_End2); + BattleScriptExecute(BattleScript_ItemHealHP_End2); effect = ITEM_HP_CHANGE; RecordItemEffectBattle(bank, bankHoldEffect); } @@ -5654,9 +5650,9 @@ u8 ItemBattleEffects(u8 caseID, u8 bank, bool8 moveTurn) gBattleMoveDamage = gBattleMons[bank].maxHP - gBattleMons[bank].hp; gBattleMoveDamage *= -1; if (GetFlavourRelationByPersonality(gBattleMons[bank].personality, FLAVOR_SPICY) < 0) - b_call_bc_move_exec(BattleScript_BerryConfuseHealEnd2); + BattleScriptExecute(BattleScript_BerryConfuseHealEnd2); else - b_call_bc_move_exec(BattleScript_ItemHealHP_RemoveItem); + BattleScriptExecute(BattleScript_ItemHealHP_RemoveItem); effect = ITEM_HP_CHANGE; } break; @@ -5674,9 +5670,9 @@ u8 ItemBattleEffects(u8 caseID, u8 bank, bool8 moveTurn) gBattleMoveDamage = gBattleMons[bank].maxHP - gBattleMons[bank].hp; gBattleMoveDamage *= -1; if (GetFlavourRelationByPersonality(gBattleMons[bank].personality, FLAVOR_DRY) < 0) - b_call_bc_move_exec(BattleScript_BerryConfuseHealEnd2); + BattleScriptExecute(BattleScript_BerryConfuseHealEnd2); else - b_call_bc_move_exec(BattleScript_ItemHealHP_RemoveItem); + BattleScriptExecute(BattleScript_ItemHealHP_RemoveItem); effect = ITEM_HP_CHANGE; } break; @@ -5694,9 +5690,9 @@ u8 ItemBattleEffects(u8 caseID, u8 bank, bool8 moveTurn) gBattleMoveDamage = gBattleMons[bank].maxHP - gBattleMons[bank].hp; gBattleMoveDamage *= -1; if (GetFlavourRelationByPersonality(gBattleMons[bank].personality, FLAVOR_SWEET) < 0) - b_call_bc_move_exec(BattleScript_BerryConfuseHealEnd2); + BattleScriptExecute(BattleScript_BerryConfuseHealEnd2); else - b_call_bc_move_exec(BattleScript_ItemHealHP_RemoveItem); + BattleScriptExecute(BattleScript_ItemHealHP_RemoveItem); effect = ITEM_HP_CHANGE; } break; @@ -5714,9 +5710,9 @@ u8 ItemBattleEffects(u8 caseID, u8 bank, bool8 moveTurn) gBattleMoveDamage = gBattleMons[bank].maxHP - gBattleMons[bank].hp; gBattleMoveDamage *= -1; if (GetFlavourRelationByPersonality(gBattleMons[bank].personality, FLAVOR_BITTER) < 0) - b_call_bc_move_exec(BattleScript_BerryConfuseHealEnd2); + BattleScriptExecute(BattleScript_BerryConfuseHealEnd2); else - b_call_bc_move_exec(BattleScript_ItemHealHP_RemoveItem); + BattleScriptExecute(BattleScript_ItemHealHP_RemoveItem); effect = ITEM_HP_CHANGE; } break; @@ -5734,9 +5730,9 @@ u8 ItemBattleEffects(u8 caseID, u8 bank, bool8 moveTurn) gBattleMoveDamage = gBattleMons[bank].maxHP - gBattleMons[bank].hp; gBattleMoveDamage *= -1; if (GetFlavourRelationByPersonality(gBattleMons[bank].personality, FLAVOR_SOUR) < 0) - b_call_bc_move_exec(BattleScript_BerryConfuseHealEnd2); + BattleScriptExecute(BattleScript_BerryConfuseHealEnd2); else - b_call_bc_move_exec(BattleScript_ItemHealHP_RemoveItem); + BattleScriptExecute(BattleScript_ItemHealHP_RemoveItem); effect = ITEM_HP_CHANGE; } break; @@ -5759,7 +5755,7 @@ u8 ItemBattleEffects(u8 caseID, u8 bank, bool8 moveTurn) gBattleScripting.statChanger = 0x10 + STAT_STAGE_ATK; gBattleScripting.animArg1 = 0xE + STAT_STAGE_ATK; gBattleScripting.animArg2 = 0; - b_call_bc_move_exec(BattleScript_BerryStatRaiseEnd2); + BattleScriptExecute(BattleScript_BerryStatRaiseEnd2); effect = ITEM_STATS_CHANGE; } break; @@ -5775,7 +5771,7 @@ u8 ItemBattleEffects(u8 caseID, u8 bank, bool8 moveTurn) gBattleScripting.statChanger = 0x10 + STAT_STAGE_DEF; gBattleScripting.animArg1 = 0xE + STAT_STAGE_DEF; gBattleScripting.animArg2 = 0; - b_call_bc_move_exec(BattleScript_BerryStatRaiseEnd2); + BattleScriptExecute(BattleScript_BerryStatRaiseEnd2); effect = ITEM_STATS_CHANGE; } break; @@ -5791,7 +5787,7 @@ u8 ItemBattleEffects(u8 caseID, u8 bank, bool8 moveTurn) gBattleScripting.statChanger = 0x10 + STAT_STAGE_SPEED; gBattleScripting.animArg1 = 0xE + STAT_STAGE_SPEED; gBattleScripting.animArg2 = 0; - b_call_bc_move_exec(BattleScript_BerryStatRaiseEnd2); + BattleScriptExecute(BattleScript_BerryStatRaiseEnd2); effect = ITEM_STATS_CHANGE; } break; @@ -5807,7 +5803,7 @@ u8 ItemBattleEffects(u8 caseID, u8 bank, bool8 moveTurn) gBattleScripting.statChanger = 0x10 + STAT_STAGE_SPATK; gBattleScripting.animArg1 = 0xE + STAT_STAGE_SPATK; gBattleScripting.animArg2 = 0; - b_call_bc_move_exec(BattleScript_BerryStatRaiseEnd2); + BattleScriptExecute(BattleScript_BerryStatRaiseEnd2); effect = ITEM_STATS_CHANGE; } break; @@ -5823,7 +5819,7 @@ u8 ItemBattleEffects(u8 caseID, u8 bank, bool8 moveTurn) gBattleScripting.statChanger = 0x10 + STAT_STAGE_SPDEF; gBattleScripting.animArg1 = 0xE + STAT_STAGE_SPDEF; gBattleScripting.animArg2 = 0; - b_call_bc_move_exec(BattleScript_BerryStatRaiseEnd2); + BattleScriptExecute(BattleScript_BerryStatRaiseEnd2); effect = ITEM_STATS_CHANGE; } break; @@ -5831,7 +5827,7 @@ u8 ItemBattleEffects(u8 caseID, u8 bank, bool8 moveTurn) if (gBattleMons[bank].hp <= gBattleMons[bank].maxHP / bankQuality && !moveTurn && !(gBattleMons[bank].status2 & STATUS2_FOCUS_ENERGY)) { gBattleMons[bank].status2 |= STATUS2_FOCUS_ENERGY; - b_call_bc_move_exec(BattleScript_BerryFocusEnergyEnd2); + BattleScriptExecute(BattleScript_BerryFocusEnergyEnd2); effect = ITEM_EFFECT_OTHER; } break; @@ -5868,7 +5864,7 @@ u8 ItemBattleEffects(u8 caseID, u8 bank, bool8 moveTurn) gBattleScripting.statChanger = 0x21 + i; gBattleScripting.animArg1 = 0x21 + i + 6; gBattleScripting.animArg2 = 0; - b_call_bc_move_exec(BattleScript_BerryStatRaiseEnd2); + BattleScriptExecute(BattleScript_BerryStatRaiseEnd2); effect = ITEM_STATS_CHANGE; } } @@ -5877,7 +5873,7 @@ u8 ItemBattleEffects(u8 caseID, u8 bank, bool8 moveTurn) if (gBattleMons[bank].status1 & STATUS_PARALYSIS) { gBattleMons[bank].status1 &= ~(STATUS_PARALYSIS); - b_call_bc_move_exec(BattleScript_BerryCurePrlzEnd2); + BattleScriptExecute(BattleScript_BerryCurePrlzEnd2); effect = ITEM_STATUS_CHANGE; } break; @@ -5885,7 +5881,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_call_bc_move_exec(BattleScript_BerryCurePsnEnd2); + BattleScriptExecute(BattleScript_BerryCurePsnEnd2); effect = ITEM_STATUS_CHANGE; } break; @@ -5893,7 +5889,7 @@ u8 ItemBattleEffects(u8 caseID, u8 bank, bool8 moveTurn) if (gBattleMons[bank].status1 & STATUS_BURN) { gBattleMons[bank].status1 &= ~(STATUS_BURN); - b_call_bc_move_exec(BattleScript_BerryCureBrnEnd2); + BattleScriptExecute(BattleScript_BerryCureBrnEnd2); effect = ITEM_STATUS_CHANGE; } break; @@ -5901,7 +5897,7 @@ u8 ItemBattleEffects(u8 caseID, u8 bank, bool8 moveTurn) if (gBattleMons[bank].status1 & STATUS_FREEZE) { gBattleMons[bank].status1 &= ~(STATUS_FREEZE); - b_call_bc_move_exec(BattleScript_BerryCureFrzEnd2); + BattleScriptExecute(BattleScript_BerryCureFrzEnd2); effect = ITEM_STATUS_CHANGE; } break; @@ -5910,7 +5906,7 @@ u8 ItemBattleEffects(u8 caseID, u8 bank, bool8 moveTurn) { gBattleMons[bank].status1 &= ~(STATUS_SLEEP); gBattleMons[bank].status2 &= ~(STATUS2_NIGHTMARE); - b_call_bc_move_exec(BattleScript_BerryCureSlpEnd2); + BattleScriptExecute(BattleScript_BerryCureSlpEnd2); effect = ITEM_STATUS_CHANGE; } break; @@ -5918,7 +5914,7 @@ u8 ItemBattleEffects(u8 caseID, u8 bank, bool8 moveTurn) if (gBattleMons[bank].status2 & STATUS2_CONFUSION) { gBattleMons[bank].status2 &= ~(STATUS2_CONFUSION); - b_call_bc_move_exec(BattleScript_BerryCureConfusionEnd2); + BattleScriptExecute(BattleScript_BerryCureConfusionEnd2); effect = ITEM_EFFECT_OTHER; } break; @@ -5963,7 +5959,7 @@ u8 ItemBattleEffects(u8 caseID, u8 bank, bool8 moveTurn) gBattleCommunication[MULTISTRING_CHOOSER] = 1; gBattleMons[bank].status1 = 0; gBattleMons[bank].status2 &= ~(STATUS2_CONFUSION); - b_call_bc_move_exec(BattleScript_BerryCureChosenStatusEnd2); + BattleScriptExecute(BattleScript_BerryCureChosenStatusEnd2); effect = ITEM_STATUS_CHANGE; } break; @@ -5972,7 +5968,7 @@ u8 ItemBattleEffects(u8 caseID, u8 bank, bool8 moveTurn) { gBattleMons[bank].status2 &= ~(STATUS2_INFATUATION); StringCopy(gBattleTextBuff1, gStatusConditionString_LoveJpn); - b_call_bc_move_exec(BattleScript_BerryCureChosenStatusEnd2); + BattleScriptExecute(BattleScript_BerryCureChosenStatusEnd2); gBattleCommunication[MULTISTRING_CHOOSER] = 0; effect = ITEM_EFFECT_OTHER; } diff --git a/src/battle_4.c b/src/battle_4.c index 9ef443b70..33ac48261 100644 --- a/src/battle_4.c +++ b/src/battle_4.c @@ -30,6 +30,10 @@ #include "pokemon_item_effects.h" #include "m4a.h" #include "mail.h" +#include "event_data.h" +#include "pokemon_storage_system.h" +#include "task.h" +#include "naming_screen.h" // variables @@ -98,6 +102,11 @@ extern u16 gLastUsedMovesByBanks[BATTLE_BANKS_COUNT]; extern u16 gTrainerBattleOpponent_A; extern u16 gTrainerBattleOpponent_B; extern u8 gUnknown_020241E9; +extern u16 gBattle_BG1_X; +extern u16 gBattle_BG1_Y; +extern u16 gBattle_BG2_X; +extern u16 gBattle_BG2_Y; +extern u16 gBattle_BG3_X; extern struct MusicPlayerInfo gMPlay_BGM; struct TrainerMoney @@ -130,6 +139,14 @@ extern void sub_81A5D44(void); // battle frontier 2 extern void sub_81B8E80(u8 bank, u8, u8); // party menu extern bool8 sub_81B1250(void); // ? extern u8 GetScaledHPFraction(s16 hp, s16 maxhp, u8 scale); // battle interface +extern bool8 InBattlePike(void); +extern bool8 InBattlePyramid(void); +extern u16 GetBattlePyramidPickupItemId(void); +extern u8 sav1_map_get_light_level(void); +extern u8 sub_813B21C(void); +extern u16 get_unknown_box_id(void); +extern void c2_berry_program_update_menu(void); +extern void sub_8035AA4(void); // BattleScripts extern const u8 BattleScript_MoveEnd[]; @@ -201,13 +218,24 @@ extern const u8 BattleScript_PrintPayDayMoneyString[]; extern const u8 BattleScript_SturdyPreventsOHKO[]; extern const u8 BattleScript_ObliviousPreventsAttraction[]; extern const u8 BattleScript_PauseEffectivenessSoundResultMsgEndMove[]; +extern const u8 BattleScript_CastformChange[]; +extern const u8 BattleScript_TrainerBallBlock[]; +extern const u8 BattleScript_WallyBallThrow[]; +extern const u8 BattleScript_SuccessBallThrow[]; +extern const u8 BattleScript_ShakeBallThrow[]; +extern const u8 BattleScript_PresentDamageTarget[]; +extern const u8 BattleScript_AlreadyAtFullHp[]; +extern const u8 BattleScript_PresentHealTarget[]; +extern const u8 BattleScript_WrapFree[]; +extern const u8 BattleScript_LeechSeedFree[]; +extern const u8 BattleScript_SpikesFree[]; // strings extern const u8 gText_BattleYesNoChoice[]; // read via orr #define BSScriptRead32(ptr) ((ptr)[0] | (ptr)[1] << 8 | (ptr)[2] << 16 | (ptr)[3] << 24) -#define BSScriptRead8(ptr) (((u8)((ptr)[0]))) +#define BSScriptRead16(ptr) ((ptr)[0] | ((ptr)[1] << 8)) #define BSScriptReadPtr(ptr) ((void *)BSScriptRead32(ptr)) // read via add @@ -220,270 +248,269 @@ extern const u8 gText_BattleYesNoChoice[]; #define TARGET_TURN_DAMAGED (((gSpecialStatuses[gBankTarget].moveturnLostHP_physical || gSpecialStatuses[gBankTarget].moveturnLostHP_special))) // this file's functions -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 bool8 IsTwoTurnsMove(u16 move); +static void DestinyBondFlagUpdate(void); +static u8 AttacksThisTurn(u8 bank, u16 move); // Note: returns 1 if it's a charging turn, otherwise 2. static void CheckWonderGuardAndLevitate(void); -u8 ChangeStatBuffs(s8 statValue, u8 statId, u8, const u8* BS_ptr); -void sub_8056A3C(u8 arg0, u8 arg1, u8 arg2, u8 arg3, u8 arg4); -bool32 IsMonGettingExpSentOut(void); -void sub_804F17C(void); -bool8 sub_804F1CC(void); -void sub_804F100(void); -void sub_804F144(void); -bool8 sub_804F344(void); -void PutMonIconOnLvlUpBox(void); -void PutLevelAndGenderOnLvlUpBox(void); +static u8 ChangeStatBuffs(s8 statValue, u8 statId, u8, const u8* BS_ptr); +static bool32 IsMonGettingExpSentOut(void); +static void sub_804F17C(void); +static bool8 sub_804F1CC(void); +static void sub_804F100(void); +static void sub_804F144(void); +static bool8 sub_804F344(void); +static void PutMonIconOnLvlUpBox(void); +static void PutLevelAndGenderOnLvlUpBox(void); -void atk00_attackcanceler(void); -void atk01_accuracycheck(void); -void atk02_attackstring(void); -void atk03_ppreduce(void); -void atk04_critcalc(void); -void atk05_damagecalc1(void); -void atk06_typecalc(void); -void atk07_dmg_adjustment(void); -void atk08_dmg_adjustment2(void); -void atk09_attackanimation(void); -void atk0A_waitanimation(void); -void atk0B_healthbarupdate(void); -void atk0C_datahpupdate(void); -void atk0D_critmessage(void); -void atk0E_effectiveness_sound(void); -void atk0F_resultmessage(void); -void atk10_printstring(void); -void atk11_printstring_playeronly(void); -void atk12_waitmessage(void); -void atk13_printfromtable(void); -void atk14_printfromtable_playeronly(void); -void atk15_seteffectwithchance(void); -void atk16_seteffectprimary(void); -void atk17_seteffectsecondary(void); -void atk18_status_effect_clear(void); -void atk19_faint_pokemon(void); -void atk1A_faint_animation(void); -void atk1B_faint_effects_clear(void); -void atk1C_jumpifstatus(void); -void atk1D_jumpifstatus2(void); -void atk1E_jumpifability(void); -void atk1F_jumpifsideaffecting(void); -void atk20_jumpifstat(void); -void atk21_jumpifstatus3(void); -void atk22_jumpiftype(void); -void atk23_getexp(void); -void atk24(void); -void atk25_move_values_cleanup(void); -void atk26_set_multihit(void); -void atk27_decrement_multihit(void); -void atk28_goto(void); -void atk29_jumpifbyte(void); -void atk2A_jumpifhalfword(void); -void atk2B_jumpifword(void); -void atk2C_jumpifarrayequal(void); -void atk2D_jumpifarraynotequal(void); -void atk2E_setbyte(void); -void atk2F_addbyte(void); -void atk30_subbyte(void); -void atk31_copyarray(void); -void atk32_copyarray_withindex(void); -void atk33_orbyte(void); -void atk34_orhalfword(void); -void atk35_orword(void); -void atk36_bicbyte(void); -void atk37_bichalfword(void); -void atk38_bicword(void); -void atk39_pause(void); -void atk3A_waitstate(void); -void atk3B_healthbar_update(void); -void atk3C_return(void); -void atk3D_end(void); -void atk3E_end2(void); -void atk3F_end3(void); -void atk40_jump_if_move_affected_by_protect(void); -void atk41_call(void); -void atk42_jumpiftype2(void); -void atk43_jumpifabilitypresent(void); -void atk44(void); -void atk45_playanimation(void); -void atk46_playanimation2(void); -void atk47_setgraphicalstatchangevalues(void); -void atk48_playstatchangeanimation(void); -void atk49_moveend(void); -void atk4A_typecalc2(void); -void atk4B_return_atk_to_ball(void); -void atk4C_copy_poke_data(void); -void atk4D_switch_data_update(void); -void atk4E_switchin_anim(void); -void atk4F_jump_if_cannot_switch(void); -void atk50_openpartyscreen(void); -void atk51_switch_handle_order(void); -void atk52_switch_in_effects(void); -void atk53_trainer_slide(void); -void atk54_effectiveness_sound(void); -void atk55_play_sound(void); -void atk56_fainting_cry(void); -void atk57(void); -void atk58_return_to_ball(void); -void atk59_learnmove_inbattle(void); -void atk5A_yesnoboxlearnmove(void); -void atk5B_yesnoboxstoplearningmove(void); -void atk5C_hitanimation(void); -void atk5D_getmoneyreward(void); -void atk5E_8025A70(void); -void atk5F_8025B24(void); -void atk60_increment_gamestat(void); -void atk61_8025BA4(void); -void atk62_08025C6C(void); -void atk63_jumptorandomattack(void); -void atk64_statusanimation(void); -void atk65_status2animation(void); -void atk66_chosenstatusanimation(void); -void atk67_yesnobox(void); -void atk68_80246A0(void); -void atk69_dmg_adjustment3(void); -void atk6A_removeitem(void); -void atk6B_atknameinbuff1(void); -void atk6C_draw_lvlupbox(void); -void atk6D_reset_sentpokes_value(void); -void atk6E_set_atk_to_player0(void); -void atk6F_set_visible(void); -void atk70_record_last_used_ability(void); -void atk71_buffer_move_to_learn(void); -void atk72_jump_if_can_run_frombattle(void); -void atk73_hp_thresholds(void); -void atk74_hp_thresholds2(void); -void atk75_item_effect_on_opponent(void); -void atk76_various(void); -void atk77_set_protect_like(void); -void atk78_faintifabilitynotdamp(void); -void atk79_setatkhptozero(void); -void atk7A_jumpwhiletargetvalid(void); -void atk7B_healhalfHP_if_possible(void); -void atk7C_trymirrormove(void); -void atk7D_set_rain(void); -void atk7E_setreflect(void); -void atk7F_setseeded(void); -void atk80_manipulatedamage(void); -void atk81_setrest(void); -void atk82_jumpifnotfirstturn(void); -void atk83_nop(void); -void atk84_jump_if_cant_sleep(void); -void atk85_stockpile(void); -void atk86_stockpiletobasedamage(void); -void atk87_stockpiletohpheal(void); -void atk88_negativedamage(void); -void atk89_statbuffchange(void); -void atk8A_normalisebuffs(void); -void atk8B_setbide(void); -void atk8C_confuseifrepeatingattackends(void); -void atk8D_setmultihit_counter(void); -void atk8E_init_multihit_string(void); -void atk8F_forcerandomswitch(void); -void atk90_conversion_type_change(void); -void atk91_givepaydaymoney(void); -void atk92_setlightscreen(void); -void atk93_ko_move(void); -void atk94_damagetohalftargethp(void); -void atk95_setsandstorm(void); -void atk96_weatherdamage(void); -void atk97_try_infatuation(void); -void atk98_status_icon_update(void); -void atk99_setmist(void); -void atk9A_set_focusenergy(void); -void atk9B_transformdataexecution(void); -void atk9C_set_substitute(void); -void atk9D_mimicattackcopy(void); -void atk9E_metronome(void); -void atk9F_dmgtolevel(void); -void atkA0_psywavedamageeffect(void); -void atkA1_counterdamagecalculator(void); -void atkA2_mirrorcoatdamagecalculator(void); -void atkA3_disablelastusedattack(void); -void atkA4_setencore(void); -void atkA5_painsplitdmgcalc(void); -void atkA6_settypetorandomresistance(void); -void atkA7_setalwayshitflag(void); -void atkA8_copymovepermanently(void); -void atkA9_sleeptalk_choose_move(void); -void atkAA_set_destinybond(void); -void atkAB_DestinyBondFlagUpdate(void); -void atkAC_remaininghptopower(void); -void atkAD_spite_ppreduce(void); -void atkAE_heal_party_status(void); -void atkAF_cursetarget(void); -void atkB0_set_spikes(void); -void atkB1_set_foresight(void); -void atkB2_setperishsong(void); -void atkB3_rolloutdamagecalculation(void); -void atkB4_jumpifconfusedandstatmaxed(void); -void atkB5_furycuttercalc(void); -void atkB6_happinesstodamagecalculation(void); -void atkB7_presentdamagecalculation(void); -void atkB8_set_safeguard(void); -void atkB9_magnitudedamagecalculation(void); -void atkBA_jumpifnopursuitswitchdmg(void); -void atkBB_setsunny(void); -void atkBC_maxattackhalvehp(void); -void atkBD_copyfoestats(void); -void atkBE_rapidspinfree(void); -void atkBF_set_defense_curl(void); -void atkC0_recoverbasedonsunlight(void); -void atkC1_hidden_power(void); -void atkC2_selectnexttarget(void); -void atkC3_setfutureattack(void); -void atkC4_beat_up(void); -void atkC5_setsemiinvulnerablebit(void); -void atkC6_clearsemiinvulnerablebit(void); -void atkC7_setminimize(void); -void atkC8_sethail(void); -void atkC9_jumpifattackandspecialattackcannotfall(void); -void atkCA_setforcedtarget(void); -void atkCB_setcharge(void); -void atkCC_callterrainattack(void); -void atkCD_cureifburnedparalysedorpoisoned(void); -void atkCE_settorment(void); -void atkCF_jumpifnodamage(void); -void atkD0_settaunt(void); -void atkD1_set_helpinghand(void); -void atkD2_swap_items(void); -void atkD3_copy_ability(void); -void atkD4_wish_effect(void); -void atkD5_setroots(void); -void atkD6_doubledamagedealtifdamaged(void); -void atkD7_setyawn(void); -void atkD8_setdamagetohealthdifference(void); -void atkD9_scaledamagebyhealthratio(void); -void atkDA_abilityswap(void); -void atkDB_imprisoneffect(void); -void atkDC_setgrudge(void); -void atkDD_weightdamagecalculation(void); -void atkDE_asistattackselect(void); -void atkDF_setmagiccoat(void); -void atkE0_setstealstatchange(void); -void atkE1_intimidate_string_loader(void); -void atkE2_switchout_abilities(void); -void atkE3_jumpifhasnohp(void); -void atkE4_getsecretpowereffect(void); -void atkE5_pickup(void); -void atkE6_castform_change_animation(void); -void atkE7_castform_data_change(void); -void atkE8_settypebasedhalvers(void); -void atkE9_setweatherballtype(void); -void atkEA_recycleitem(void); -void atkEB_settypetoterrain(void); -void atkEC_pursuit_sth(void); -void atkED_802B4B4(void); -void atkEE_removelightscreenreflect(void); -void atkEF_pokeball_catch_calculation(void); -void atkF0_copy_caught_poke(void); -void atkF1_setpoke_as_caught(void); -void atkF2_display_dex_info(void); -void atkF3_nickname_caught_poke(void); -void atkF4_802BEF0(void); -void atkF5_removeattackerstatus1(void); -void atkF6_802BF48(void); -void atkF7_802BF54(void); -void sub_8056EF8(void); +static void atk00_attackcanceler(void); +static void atk01_accuracycheck(void); +static void atk02_attackstring(void); +static void atk03_ppreduce(void); +static void atk04_critcalc(void); +static void atk05_damagecalc1(void); +static void atk06_typecalc(void); +static void atk07_dmg_adjustment(void); +static void atk08_dmg_adjustment2(void); +static void atk09_attackanimation(void); +static void atk0A_waitanimation(void); +static void atk0B_healthbarupdate(void); +static void atk0C_datahpupdate(void); +static void atk0D_critmessage(void); +static void atk0E_effectiveness_sound(void); +static void atk0F_resultmessage(void); +static void atk10_printstring(void); +static void atk11_printstring_playeronly(void); +static void atk12_waitmessage(void); +static void atk13_printfromtable(void); +static void atk14_printfromtable_playeronly(void); +static void atk15_seteffectwithchance(void); +static void atk16_seteffectprimary(void); +static void atk17_seteffectsecondary(void); +static void atk18_status_effect_clear(void); +static void atk19_faint_pokemon(void); +static void atk1A_faint_animation(void); +static void atk1B_faint_effects_clear(void); +static void atk1C_jumpifstatus(void); +static void atk1D_jumpifstatus2(void); +static void atk1E_jumpifability(void); +static void atk1F_jumpifsideaffecting(void); +static void atk20_jumpifstat(void); +static void atk21_jumpifstatus3(void); +static void atk22_jumpiftype(void); +static void atk23_getexp(void); +static void atk24(void); +static void atk25_move_values_cleanup(void); +static void atk26_set_multihit(void); +static void atk27_decrement_multihit(void); +static void atk28_goto(void); +static void atk29_jumpifbyte(void); +static void atk2A_jumpifhalfword(void); +static void atk2B_jumpifword(void); +static void atk2C_jumpifarrayequal(void); +static void atk2D_jumpifarraynotequal(void); +static void atk2E_setbyte(void); +static void atk2F_addbyte(void); +static void atk30_subbyte(void); +static void atk31_copyarray(void); +static void atk32_copyarray_withindex(void); +static void atk33_orbyte(void); +static void atk34_orhalfword(void); +static void atk35_orword(void); +static void atk36_bicbyte(void); +static void atk37_bichalfword(void); +static void atk38_bicword(void); +static void atk39_pause(void); +static void atk3A_waitstate(void); +static void atk3B_healthbar_update(void); +static void atk3C_return(void); +static void atk3D_end(void); +static void atk3E_end2(void); +static void atk3F_end3(void); +static void atk40_jump_if_move_affected_by_protect(void); +static void atk41_call(void); +static void atk42_jumpiftype2(void); +static void atk43_jumpifabilitypresent(void); +static void atk44(void); +static void atk45_playanimation(void); +static void atk46_playanimation2(void); +static void atk47_setgraphicalstatchangevalues(void); +static void atk48_playstatchangeanimation(void); +static void atk49_moveend(void); +static void atk4A_typecalc2(void); +static void atk4B_return_atk_to_ball(void); +static void atk4C_copy_poke_data(void); +static void atk4D_switch_data_update(void); +static void atk4E_switchin_anim(void); +static void atk4F_jump_if_cannot_switch(void); +static void atk50_openpartyscreen(void); +static void atk51_switch_handle_order(void); +static void atk52_switch_in_effects(void); +static void atk53_trainer_slide(void); +static void atk54_effectiveness_sound(void); +static void atk55_play_sound(void); +static void atk56_fainting_cry(void); +static void atk57(void); +static void atk58_return_to_ball(void); +static void atk59_learnmove_inbattle(void); +static void atk5A_yesnoboxlearnmove(void); +static void atk5B_yesnoboxstoplearningmove(void); +static void atk5C_hitanimation(void); +static void atk5D_getmoneyreward(void); +static void atk5E_8025A70(void); +static void atk5F_8025B24(void); +static void atk60_increment_gamestat(void); +static void atk61_8025BA4(void); +static void atk62_08025C6C(void); +static void atk63_jumptorandomattack(void); +static void atk64_statusanimation(void); +static void atk65_status2animation(void); +static void atk66_chosenstatusanimation(void); +static void atk67_yesnobox(void); +static void atk68_80246A0(void); +static void atk69_dmg_adjustment3(void); +static void atk6A_removeitem(void); +static void atk6B_atknameinbuff1(void); +static void atk6C_draw_lvlupbox(void); +static void atk6D_reset_sentpokes_value(void); +static void atk6E_set_atk_to_player0(void); +static void atk6F_set_visible(void); +static void atk70_record_last_used_ability(void); +static void atk71_buffer_move_to_learn(void); +static void atk72_jump_if_can_run_frombattle(void); +static void atk73_hp_thresholds(void); +static void atk74_hp_thresholds2(void); +static void atk75_item_effect_on_opponent(void); +static void atk76_various(void); +static void atk77_set_protect_like(void); +static void atk78_faintifabilitynotdamp(void); +static void atk79_setatkhptozero(void); +static void atk7A_jumpwhiletargetvalid(void); +static void atk7B_healhalfHP_if_possible(void); +static void atk7C_trymirrormove(void); +static void atk7D_set_rain(void); +static void atk7E_setreflect(void); +static void atk7F_setseeded(void); +static void atk80_manipulatedamage(void); +static void atk81_setrest(void); +static void atk82_jumpifnotfirstturn(void); +static void atk83_nop(void); +static void atk84_jump_if_cant_sleep(void); +static void atk85_stockpile(void); +static void atk86_stockpiletobasedamage(void); +static void atk87_stockpiletohpheal(void); +static void atk88_negativedamage(void); +static void atk89_statbuffchange(void); +static void atk8A_normalisebuffs(void); +static void atk8B_setbide(void); +static void atk8C_confuseifrepeatingattackends(void); +static void atk8D_setmultihit_counter(void); +static void atk8E_init_multihit_string(void); +static void atk8F_forcerandomswitch(void); +static void atk90_conversion_type_change(void); +static void atk91_givepaydaymoney(void); +static void atk92_setlightscreen(void); +static void atk93_ko_move(void); +static void atk94_damagetohalftargethp(void); +static void atk95_setsandstorm(void); +static void atk96_weatherdamage(void); +static void atk97_try_infatuation(void); +static void atk98_status_icon_update(void); +static void atk99_setmist(void); +static void atk9A_set_focusenergy(void); +static void atk9B_transformdataexecution(void); +static void atk9C_set_substitute(void); +static void atk9D_mimicattackcopy(void); +static void atk9E_metronome(void); +static void atk9F_dmgtolevel(void); +static void atkA0_psywavedamageeffect(void); +static void atkA1_counterdamagecalculator(void); +static void atkA2_mirrorcoatdamagecalculator(void); +static void atkA3_disablelastusedattack(void); +static void atkA4_setencore(void); +static void atkA5_painsplitdmgcalc(void); +static void atkA6_settypetorandomresistance(void); +static void atkA7_setalwayshitflag(void); +static void atkA8_copymovepermanently(void); +static void atkA9_sleeptalk_choose_move(void); +static void atkAA_set_destinybond(void); +static void atkAB_DestinyBondFlagUpdate(void); +static void atkAC_remaininghptopower(void); +static void atkAD_spite_ppreduce(void); +static void atkAE_heal_party_status(void); +static void atkAF_cursetarget(void); +static void atkB0_set_spikes(void); +static void atkB1_set_foresight(void); +static void atkB2_setperishsong(void); +static void atkB3_rolloutdamagecalculation(void); +static void atkB4_jumpifconfusedandstatmaxed(void); +static void atkB5_furycuttercalc(void); +static void atkB6_happinesstodamagecalculation(void); +static void atkB7_presentdamagecalculation(void); +static void atkB8_set_safeguard(void); +static void atkB9_magnitudedamagecalculation(void); +static void atkBA_jumpifnopursuitswitchdmg(void); +static void atkBB_setsunny(void); +static void atkBC_maxattackhalvehp(void); +static void atkBD_copyfoestats(void); +static void atkBE_rapidspinfree(void); +static void atkBF_set_defense_curl(void); +static void atkC0_recoverbasedonsunlight(void); +static void atkC1_hidden_power(void); +static void atkC2_selectnexttarget(void); +static void atkC3_setfutureattack(void); +static void atkC4_beat_up(void); +static void atkC5_setsemiinvulnerablebit(void); +static void atkC6_clearsemiinvulnerablebit(void); +static void atkC7_setminimize(void); +static void atkC8_sethail(void); +static void atkC9_jumpifattackandspecialattackcannotfall(void); +static void atkCA_setforcedtarget(void); +static void atkCB_setcharge(void); +static void atkCC_callterrainattack(void); +static void atkCD_cureifburnedparalysedorpoisoned(void); +static void atkCE_settorment(void); +static void atkCF_jumpifnodamage(void); +static void atkD0_settaunt(void); +static void atkD1_set_helpinghand(void); +static void atkD2_swap_items(void); +static void atkD3_copy_ability(void); +static void atkD4_wish_effect(void); +static void atkD5_setroots(void); +static void atkD6_doubledamagedealtifdamaged(void); +static void atkD7_setyawn(void); +static void atkD8_setdamagetohealthdifference(void); +static void atkD9_scaledamagebyhealthratio(void); +static void atkDA_abilityswap(void); +static void atkDB_imprisoneffect(void); +static void atkDC_setgrudge(void); +static void atkDD_weightdamagecalculation(void); +static void atkDE_asistattackselect(void); +static void atkDF_setmagiccoat(void); +static void atkE0_setstealstatchange(void); +static void atkE1_intimidate_string_loader(void); +static void atkE2_switchout_abilities(void); +static void atkE3_jumpifhasnohp(void); +static void atkE4_getsecretpowereffect(void); +static void atkE5_pickup(void); +static void atkE6_castform_change_animation(void); +static void atkE7_castform_data_change(void); +static void atkE8_settypebasedhalvers(void); +static void atkE9_setweatherballtype(void); +static void atkEA_recycleitem(void); +static void atkEB_settypetoterrain(void); +static void atkEC_pursuit_sth(void); +static void atkED_802B4B4(void); +static void atkEE_removelightscreenreflect(void); +static void atkEF_pokeball_catch_calculation(void); +static void atkF0_give_caught_mon(void); +static void atkF1_set_caught_mon_dex_flags(void); +static void atkF2_display_dex_info(void); +static void atkF3_nickname_caught_poke(void); +static void atkF4_subattackerhpbydmg(void); +static void atkF5_removeattackerstatus1(void); +static void atkF6_802BF48(void); +static void atkF7_802BF54(void); +static void atkF8_trainer_slide_back(void); void (* const gBattleScriptingCommandsTable[])(void) = { @@ -727,15 +754,15 @@ void (* const gBattleScriptingCommandsTable[])(void) = atkED_802B4B4, atkEE_removelightscreenreflect, atkEF_pokeball_catch_calculation, - atkF0_copy_caught_poke, - atkF1_setpoke_as_caught, + atkF0_give_caught_mon, + atkF1_set_caught_mon_dex_flags, atkF2_display_dex_info, atkF3_nickname_caught_poke, - atkF4_802BEF0, + atkF4_subattackerhpbydmg, atkF5_removeattackerstatus1, atkF6_802BF48, atkF7_802BF54, - sub_8056EF8 + atkF8_trainer_slide_back }; struct StatFractions @@ -877,8 +904,22 @@ extern const struct SpriteTemplate SpriteTemplate_MonIconOnLvlUpBox; extern const u16 sProtectSuccessRates[]; extern const u16 sNaturePowerMoves[]; extern const u16 sWeightToDamageTable[]; +extern const u8 sTerrainToType[]; +extern const u8 sBallCatchBonuses[]; +extern const u16 gUnknown_0831C2C8[]; +extern const u8 gUnknown_0831C2E8[]; +extern const u8 gUnknown_0831C4F8[]; +extern const u8 sFlailHpScaleToPowerTable[12]; +extern const u16 gRarePickupItems[]; +extern const u16 gPickupItems[]; +extern const u8 gPickupProbabilities[]; -void atk00_attackcanceler(void) +extern const u16 gMovesForbiddenToCopy[]; +#define MIMIC_FORBIDDEN_END 0xFFFE +#define METRONOME_FORBIDDEN_END 0xFFFF +#define ASSIST_FORBIDDEN_END 0xFFFF + +static void atk00_attackcanceler(void) { s32 i; @@ -972,7 +1013,7 @@ void atk00_attackcanceler(void) } } -void JumpIfMoveFailed(u8 adder, u16 move) +static void JumpIfMoveFailed(u8 adder, u16 move) { const void* BS_ptr = gBattlescriptCurrInstr + adder; if (gBattleMoveFlags & MOVESTATUS_NOEFFECT) @@ -990,7 +1031,7 @@ void JumpIfMoveFailed(u8 adder, u16 move) gBattlescriptCurrInstr = BS_ptr; } -void atk40_jump_if_move_affected_by_protect(void) +static void atk40_jump_if_move_affected_by_protect(void) { if (TARGET_PROTECT_AFFECTED) { @@ -1062,7 +1103,7 @@ bool8 AccuracyCalcHelper(u16 move) return FALSE; } -void atk01_accuracycheck(void) +static void atk01_accuracycheck(void) { u16 move = BS2ScriptRead16(gBattlescriptCurrInstr + 5); @@ -1154,7 +1195,7 @@ void atk01_accuracycheck(void) } } -void atk02_attackstring(void) +static void atk02_attackstring(void) { if (gBattleExecBuffer) return; @@ -1167,7 +1208,7 @@ void atk02_attackstring(void) gBattleCommunication[MSG_DISPLAY] = 0; } -void atk03_ppreduce(void) +static void atk03_ppreduce(void) { s32 ppToDeduct = 1; @@ -1214,7 +1255,7 @@ void atk03_ppreduce(void) gBattlescriptCurrInstr++; } -void atk04_critcalc(void) +static void atk04_critcalc(void) { u8 holdEffect; u16 item, critChance; @@ -1251,7 +1292,7 @@ void atk04_critcalc(void) gBattlescriptCurrInstr++; } -void atk05_damagecalc1(void) +static void atk05_damagecalc1(void) { u16 sideStatus = gSideAffecting[GET_BANK_SIDE(gBankTarget)]; gBattleMoveDamage = CalculateBaseDamage(&gBattleMons[gBankAttacker], &gBattleMons[gBankTarget], gCurrentMove, @@ -1282,7 +1323,7 @@ void AI_CalcDmg(u8 bankAtk, u8 bankDef) gBattleMoveDamage = gBattleMoveDamage * 15 / 10; } -void ModulateDmgByType(u8 multiplier) +static void ModulateDmgByType(u8 multiplier) { gBattleMoveDamage = gBattleMoveDamage * multiplier / 10; if (gBattleMoveDamage == 0 && multiplier != 0) @@ -1319,7 +1360,7 @@ void ModulateDmgByType(u8 multiplier) #define TYPE_FORESIGHT 0xFE #define TYPE_ENDTABLE 0xFF -void atk06_typecalc(void) +static void atk06_typecalc(void) { s32 i = 0; u8 moveType; @@ -1464,7 +1505,7 @@ static void CheckWonderGuardAndLevitate(void) } } -void ModulateDmgByType2(u8 multiplier, u16 move, u8* flags) // same as ModulateDmgByType except different arguments +static void ModulateDmgByType2(u8 multiplier, u16 move, u8* flags) // same as ModulateDmgByType except different arguments { gBattleMoveDamage = gBattleMoveDamage * multiplier / 10; if (gBattleMoveDamage == 0 && multiplier != 0) @@ -1615,12 +1656,12 @@ static inline void ApplyRandomDmgMultiplier(void) } } -void Unused_ApplyRandomDmgMultiplier(void) +static void Unused_ApplyRandomDmgMultiplier(void) { ApplyRandomDmgMultiplier(); } -void atk07_dmg_adjustment(void) +static void atk07_dmg_adjustment(void) { u8 holdEffect, quality; @@ -1668,7 +1709,7 @@ void atk07_dmg_adjustment(void) gBattlescriptCurrInstr++; } -void atk08_dmg_adjustment2(void) // The same as 0x7 except it doesn't check for false swipe move effect. +static void atk08_dmg_adjustment2(void) // The same as 0x7 except it doesn't check for false swipe move effect. { u8 holdEffect, quality; @@ -1714,7 +1755,7 @@ void atk08_dmg_adjustment2(void) // The same as 0x7 except it doesn't check for gBattlescriptCurrInstr++; } -void atk09_attackanimation(void) +static void atk09_attackanimation(void) { if (gBattleExecBuffer) return; @@ -1768,20 +1809,20 @@ void atk09_attackanimation(void) } } -void atk0A_waitanimation(void) +static void atk0A_waitanimation(void) { if (gBattleExecBuffer == 0) gBattlescriptCurrInstr++; } -void atk0B_healthbarupdate(void) +static void atk0B_healthbarupdate(void) { if (gBattleExecBuffer) return; if (!(gBattleMoveFlags & MOVESTATUS_NOEFFECT)) { - gActiveBank = GetBattleBank(BSScriptRead8(gBattlescriptCurrInstr + 1)); + gActiveBank = GetBattleBank(gBattlescriptCurrInstr[1]); if (gBattleMons[gActiveBank].status2 & STATUS2_SUBSTITUTE && gDisableStructs[gActiveBank].substituteHP && !(gHitMarker & HITMARKER_IGNORE_SUBSTITUTE)) { @@ -1810,7 +1851,7 @@ void atk0B_healthbarupdate(void) gBattlescriptCurrInstr += 2; } -void atk0C_datahpupdate(void) +static void atk0C_datahpupdate(void) { u32 moveType; @@ -1826,7 +1867,7 @@ void atk0C_datahpupdate(void) if (!(gBattleMoveFlags & MOVESTATUS_NOEFFECT)) { - gActiveBank = GetBattleBank(BSScriptRead8(gBattlescriptCurrInstr + 1)); + gActiveBank = GetBattleBank(gBattlescriptCurrInstr[1]); if (gBattleMons[gActiveBank].status2 & STATUS2_SUBSTITUTE && gDisableStructs[gActiveBank].substituteHP && !(gHitMarker & HITMARKER_IGNORE_SUBSTITUTE)) { if (gDisableStructs[gActiveBank].substituteHP >= gBattleMoveDamage) @@ -1871,7 +1912,7 @@ void atk0C_datahpupdate(void) else { gTakenDmg[gActiveBank] += gBattleMoveDamage; - if (BSScriptRead8(gBattlescriptCurrInstr + 1) == BS_GET_TARGET) + if (gBattlescriptCurrInstr[1] == BS_GET_TARGET) gTakenDmgBanks[gActiveBank] = gBankAttacker; else gTakenDmgBanks[gActiveBank] = gBankTarget; @@ -1895,7 +1936,7 @@ void atk0C_datahpupdate(void) { gProtectStructs[gActiveBank].physicalDmg = gHpDealt; gSpecialStatuses[gActiveBank].moveturnLostHP_physical = gHpDealt; - if (BSScriptRead8(gBattlescriptCurrInstr + 1) == BS_GET_TARGET) + if (gBattlescriptCurrInstr[1] == BS_GET_TARGET) { gProtectStructs[gActiveBank].physicalBank = gBankAttacker; gSpecialStatuses[gActiveBank].moveturnPhysicalBank = gBankAttacker; @@ -1910,7 +1951,7 @@ void atk0C_datahpupdate(void) { gProtectStructs[gActiveBank].specialDmg = gHpDealt; gSpecialStatuses[gActiveBank].moveturnLostHP_special = gHpDealt; - if (BSScriptRead8(gBattlescriptCurrInstr + 1) == BS_GET_TARGET) + if (gBattlescriptCurrInstr[1] == BS_GET_TARGET) { gProtectStructs[gActiveBank].specialBank = gBankAttacker; gSpecialStatuses[gActiveBank].moveturnSpecialBank = gBankAttacker; @@ -1929,14 +1970,14 @@ void atk0C_datahpupdate(void) } else { - gActiveBank = GetBattleBank(BSScriptRead8(gBattlescriptCurrInstr + 1)); + gActiveBank = GetBattleBank(gBattlescriptCurrInstr[1]); if (gSpecialStatuses[gActiveBank].moveturnLostHP == 0) gSpecialStatuses[gActiveBank].moveturnLostHP = 0xFFFF; } gBattlescriptCurrInstr += 2; } -void atk0D_critmessage(void) +static void atk0D_critmessage(void) { if (gBattleExecBuffer == 0) { @@ -1949,7 +1990,7 @@ void atk0D_critmessage(void) } } -void atk0E_effectiveness_sound(void) +static void atk0E_effectiveness_sound(void) { if (gBattleExecBuffer) return; @@ -1996,7 +2037,7 @@ void atk0E_effectiveness_sound(void) gBattlescriptCurrInstr++; } -void atk0F_resultmessage(void) +static void atk0F_resultmessage(void) { u32 stringId = 0; @@ -2085,7 +2126,7 @@ void atk0F_resultmessage(void) gBattlescriptCurrInstr++; } -void atk10_printstring(void) +static void atk10_printstring(void) { if (gBattleExecBuffer == 0) { @@ -2096,7 +2137,7 @@ void atk10_printstring(void) } } -void atk11_printstring_playeronly(void) +static void atk11_printstring_playeronly(void) { gActiveBank = gBankAttacker; @@ -2107,7 +2148,7 @@ void atk11_printstring_playeronly(void) gBattleCommunication[MSG_DISPLAY] = 1; } -void atk12_waitmessage(void) +static void atk12_waitmessage(void) { if (gBattleExecBuffer == 0) { @@ -2128,7 +2169,7 @@ void atk12_waitmessage(void) } } -void atk13_printfromtable(void) +static void atk13_printfromtable(void) { if (gBattleExecBuffer == 0) { @@ -2142,7 +2183,7 @@ void atk13_printfromtable(void) } } -void atk14_printfromtable_playeronly(void) +static void atk14_printfromtable_playeronly(void) { if (gBattleExecBuffer == 0) { @@ -2868,7 +2909,7 @@ void SetMoveEffect(bool8 primary, u8 certain) gBattleCommunication[MOVE_EFFECT_BYTE] = 0; } -void atk15_seteffectwithchance(void) +static void atk15_seteffectwithchance(void) { u32 percentChance; @@ -2901,19 +2942,19 @@ void atk15_seteffectwithchance(void) gBattleScripting.field_16 = 0; } -void atk16_seteffectprimary(void) +static void atk16_seteffectprimary(void) { SetMoveEffect(TRUE, 0); } -void atk17_seteffectsecondary(void) +static void atk17_seteffectsecondary(void) { SetMoveEffect(FALSE, 0); } -void atk18_status_effect_clear(void) +static void atk18_status_effect_clear(void) { - gActiveBank = GetBattleBank(BSScriptRead8(gBattlescriptCurrInstr + 1)); + gActiveBank = GetBattleBank(gBattlescriptCurrInstr[1]); if (gBattleCommunication[MOVE_EFFECT_BYTE] <= MOVE_EFFECT_TOXIC) gBattleMons[gActiveBank].status1 &= (~gStatusFlagsForMoveEffects[gBattleCommunication[MOVE_EFFECT_BYTE]]); @@ -2925,7 +2966,7 @@ void atk18_status_effect_clear(void) gBattleScripting.field_16 = 0; } -void atk19_faint_pokemon(void) +static void atk19_faint_pokemon(void) { const u8 *BS_ptr; @@ -3012,22 +3053,22 @@ void atk19_faint_pokemon(void) } } -void atk1A_faint_animation(void) +static void atk1A_faint_animation(void) { if (gBattleExecBuffer == 0) { - gActiveBank = GetBattleBank(BSScriptRead8(gBattlescriptCurrInstr + 1)); + gActiveBank = GetBattleBank(gBattlescriptCurrInstr[1]); EmitFaintAnimation(0); MarkBufferBankForExecution(gActiveBank); gBattlescriptCurrInstr += 2; } } -void atk1B_faint_effects_clear(void) +static void atk1B_faint_effects_clear(void) { if (gBattleExecBuffer == 0) { - gActiveBank = GetBattleBank(BSScriptRead8(gBattlescriptCurrInstr + 1)); + gActiveBank = GetBattleBank(gBattlescriptCurrInstr[1]); if (!(gBattleTypeFlags & BATTLE_TYPE_ARENA) || gBattleMons[gActiveBank].hp == 0) { @@ -3041,9 +3082,9 @@ void atk1B_faint_effects_clear(void) } } -void atk1C_jumpifstatus(void) +static void atk1C_jumpifstatus(void) { - u8 bank = GetBattleBank(BSScriptRead8(gBattlescriptCurrInstr + 1)); + u8 bank = GetBattleBank(gBattlescriptCurrInstr[1]); u32 flags = BS2ScriptRead32(gBattlescriptCurrInstr + 2); const u8* jumpPtr = BS2ScriptReadPtr(gBattlescriptCurrInstr + 6); @@ -3053,9 +3094,9 @@ void atk1C_jumpifstatus(void) gBattlescriptCurrInstr += 10; } -void atk1D_jumpifstatus2(void) +static void atk1D_jumpifstatus2(void) { - u8 bank = GetBattleBank(BSScriptRead8(gBattlescriptCurrInstr + 1)); + u8 bank = GetBattleBank(gBattlescriptCurrInstr[1]); u32 flags = BS2ScriptRead32(gBattlescriptCurrInstr + 2); const u8* jumpPtr = BS2ScriptReadPtr(gBattlescriptCurrInstr + 6); @@ -3065,13 +3106,13 @@ void atk1D_jumpifstatus2(void) gBattlescriptCurrInstr += 10; } -void atk1E_jumpifability(void) +static void atk1E_jumpifability(void) { u8 bank; - u8 ability = BSScriptRead8(gBattlescriptCurrInstr + 2); + u8 ability = gBattlescriptCurrInstr[2]; const u8* jumpPtr = BS2ScriptReadPtr(gBattlescriptCurrInstr + 3); - if (BSScriptRead8(gBattlescriptCurrInstr + 1) == BS_GET_ATTACKER_SIDE) + if (gBattlescriptCurrInstr[1] == BS_GET_ATTACKER_SIDE) { bank = AbilityBattleEffects(ABILITYEFFECT_CHECK_BANK_SIDE, gBankAttacker, ability, 0, 0); if (bank) @@ -3084,7 +3125,7 @@ void atk1E_jumpifability(void) else gBattlescriptCurrInstr += 7; } - else if (BSScriptRead8(gBattlescriptCurrInstr + 1) == BS_GET_NOT_ATTACKER_SIDE) + else if (gBattlescriptCurrInstr[1] == BS_GET_NOT_ATTACKER_SIDE) { bank = AbilityBattleEffects(ABILITYEFFECT_CHECK_OTHER_SIDE, gBankAttacker, ability, 0, 0); if (bank) @@ -3099,7 +3140,7 @@ void atk1E_jumpifability(void) } else { - bank = GetBattleBank(BSScriptRead8(gBattlescriptCurrInstr + 1)); + bank = GetBattleBank(gBattlescriptCurrInstr[1]); if (gBattleMons[bank].ability == ability) { gLastUsedAbility = ability; @@ -3112,13 +3153,13 @@ void atk1E_jumpifability(void) } } -void atk1F_jumpifsideaffecting(void) +static void atk1F_jumpifsideaffecting(void) { u8 side; u16 flags; const u8* jumpPtr; - if (BSScriptRead8(gBattlescriptCurrInstr + 1) == BS_GET_ATTACKER) + if (gBattlescriptCurrInstr[1] == BS_GET_ATTACKER) side = GET_BANK_SIDE(gBankAttacker); else side = GET_BANK_SIDE(gBankTarget); @@ -3132,36 +3173,36 @@ void atk1F_jumpifsideaffecting(void) gBattlescriptCurrInstr += 8; } -void atk20_jumpifstat(void) +static void atk20_jumpifstat(void) { u8 ret = 0; - u8 bank = GetBattleBank(BSScriptRead8(gBattlescriptCurrInstr + 1)); - u8 value = gBattleMons[bank].statStages[BSScriptRead8(gBattlescriptCurrInstr + 3)]; + u8 bank = GetBattleBank(gBattlescriptCurrInstr[1]); + u8 value = gBattleMons[bank].statStages[gBattlescriptCurrInstr[3]]; - switch (BSScriptRead8(gBattlescriptCurrInstr + 2)) + switch (gBattlescriptCurrInstr[2]) { case CMP_EQUAL: - if (value == BSScriptRead8(gBattlescriptCurrInstr + 4)) + if (value == gBattlescriptCurrInstr[4]) ret++; break; case CMP_NOT_EQUAL: - if (value != BSScriptRead8(gBattlescriptCurrInstr + 4)) + if (value != gBattlescriptCurrInstr[4]) ret++; break; case CMP_GREATER_THAN: - if (value > BSScriptRead8(gBattlescriptCurrInstr + 4)) + if (value > gBattlescriptCurrInstr[4]) ret++; break; case CMP_LESS_THAN: - if (value < BSScriptRead8(gBattlescriptCurrInstr + 4)) + if (value < gBattlescriptCurrInstr[4]) ret++; break; case CMP_COMMON_BITS: - if (value & BSScriptRead8(gBattlescriptCurrInstr + 4)) + if (value & gBattlescriptCurrInstr[4]) ret++; break; case CMP_NO_COMMON_BITS: - if (!(value & BSScriptRead8(gBattlescriptCurrInstr + 4))) + if (!(value & gBattlescriptCurrInstr[4])) ret++; break; } @@ -3172,16 +3213,16 @@ void atk20_jumpifstat(void) gBattlescriptCurrInstr += 9; } -void atk21_jumpifstatus3(void) +static void atk21_jumpifstatus3(void) { u32 flags; const u8* jumpPtr; - gActiveBank = GetBattleBank(BSScriptRead8(gBattlescriptCurrInstr + 1)); + gActiveBank = GetBattleBank(gBattlescriptCurrInstr[1]); flags = BS2ScriptRead32(gBattlescriptCurrInstr + 2); jumpPtr = BS2ScriptReadPtr(gBattlescriptCurrInstr + 7); - if (BSScriptRead8(gBattlescriptCurrInstr + 6)) + if (gBattlescriptCurrInstr[6]) { if ((gStatuses3[gActiveBank] & flags) != 0) gBattlescriptCurrInstr += 11; @@ -3197,10 +3238,10 @@ void atk21_jumpifstatus3(void) } } -void atk22_jumpiftype(void) +static void atk22_jumpiftype(void) { - u8 bank = GetBattleBank(BSScriptRead8(gBattlescriptCurrInstr + 1)); - u8 type = BSScriptRead8(gBattlescriptCurrInstr + 2); + u8 bank = GetBattleBank(gBattlescriptCurrInstr[1]); + u8 type = gBattlescriptCurrInstr[2]; const u8* jumpPtr = BS2ScriptReadPtr(gBattlescriptCurrInstr + 3); if (gBattleMons[bank].type1 == type || gBattleMons[bank].type2 == type) @@ -3209,7 +3250,7 @@ void atk22_jumpiftype(void) gBattlescriptCurrInstr += 7; } -void atk23_getexp(void) +static void atk23_getexp(void) { u16 item; s32 i; // also used as stringId @@ -3219,7 +3260,7 @@ void atk23_getexp(void) s32 viaExpShare = 0; u16* exp = &gBattleStruct->expValue; - gBank1 = GetBattleBank(BSScriptRead8(gBattlescriptCurrInstr + 1)); + gBank1 = GetBattleBank(gBattlescriptCurrInstr[1]); sentIn = gSentPokesToOpponent[(gBank1 & 2) >> 1]; switch (gBattleScripting.atk23_state) @@ -3487,7 +3528,7 @@ void atk23_getexp(void) } #ifdef NONMATCHING -void atk24(void) +static void atk24(void) { u16 HP_count = 0; s32 i; @@ -3570,7 +3611,7 @@ void atk24(void) } #else __attribute__((naked)) -void atk24(void) +static void atk24(void) { asm("\n\ .syntax unified\n\ @@ -3864,7 +3905,7 @@ void atk24(void) #endif // NONMATCHING -void MoveValuesCleanUp(void) +static void MoveValuesCleanUp(void) { gBattleMoveFlags = 0; gBattleScripting.dmgMultiplier = 1; @@ -3875,19 +3916,19 @@ void MoveValuesCleanUp(void) gHitMarker &= ~(HITMARKER_SYNCHRONISE_EFFECT); } -void atk25_move_values_cleanup(void) +static void atk25_move_values_cleanup(void) { MoveValuesCleanUp(); gBattlescriptCurrInstr += 1; } -void atk26_set_multihit(void) +static void atk26_set_multihit(void) { - gMultiHitCounter = BSScriptRead8(gBattlescriptCurrInstr + 1); + gMultiHitCounter = gBattlescriptCurrInstr[1]; gBattlescriptCurrInstr += 2; } -void atk27_decrement_multihit(void) +static void atk27_decrement_multihit(void) { if (--gMultiHitCounter == 0) gBattlescriptCurrInstr += 5; @@ -3895,16 +3936,16 @@ void atk27_decrement_multihit(void) gBattlescriptCurrInstr = BS2ScriptReadPtr(gBattlescriptCurrInstr + 1); } -void atk28_goto(void) +static void atk28_goto(void) { gBattlescriptCurrInstr = BS2ScriptReadPtr(gBattlescriptCurrInstr + 1); } -void atk29_jumpifbyte(void) +static void atk29_jumpifbyte(void) { - u8 caseID = BSScriptRead8(gBattlescriptCurrInstr + 1); + u8 caseID = gBattlescriptCurrInstr[1]; const u8* memByte = BS2ScriptReadPtr(gBattlescriptCurrInstr + 2); - u8 value = BSScriptRead8(gBattlescriptCurrInstr + 6); + u8 value = gBattlescriptCurrInstr[6]; const u8* jumpPtr = BS2ScriptReadPtr(gBattlescriptCurrInstr + 7); gBattlescriptCurrInstr += 11; @@ -3938,9 +3979,9 @@ void atk29_jumpifbyte(void) } } -void atk2A_jumpifhalfword(void) +static void atk2A_jumpifhalfword(void) { - u8 caseID = BSScriptRead8(gBattlescriptCurrInstr + 1); + u8 caseID = gBattlescriptCurrInstr[1]; const u16* memHword = BS2ScriptReadPtr(gBattlescriptCurrInstr + 2); u16 value = BS2ScriptRead16(gBattlescriptCurrInstr + 6); const u8* jumpPtr = BS2ScriptReadPtr(gBattlescriptCurrInstr + 8); @@ -3976,9 +4017,9 @@ void atk2A_jumpifhalfword(void) } } -void atk2B_jumpifword(void) +static void atk2B_jumpifword(void) { - u8 caseID = BSScriptRead8(gBattlescriptCurrInstr + 1); + u8 caseID = gBattlescriptCurrInstr[1]; const u32* memWord = BS2ScriptReadPtr(gBattlescriptCurrInstr + 2); u32 value = BSScriptRead32(gBattlescriptCurrInstr + 6); const u8* jumpPtr = BS2ScriptReadPtr(gBattlescriptCurrInstr + 10); @@ -4014,11 +4055,11 @@ void atk2B_jumpifword(void) } } -void atk2C_jumpifarrayequal(void) +static void atk2C_jumpifarrayequal(void) { const u8* mem1 = BS2ScriptReadPtr(gBattlescriptCurrInstr + 1); const u8* mem2 = BS2ScriptReadPtr(gBattlescriptCurrInstr + 5); - u32 size = BSScriptRead8(gBattlescriptCurrInstr + 9); + u32 size = gBattlescriptCurrInstr[9]; const u8* jumpPtr = BS2ScriptReadPtr(gBattlescriptCurrInstr + 10); u8 i; @@ -4036,12 +4077,12 @@ void atk2C_jumpifarrayequal(void) gBattlescriptCurrInstr = jumpPtr; } -void atk2D_jumpifarraynotequal(void) +static void atk2D_jumpifarraynotequal(void) { u8 equalBytes = 0; const u8* mem1 = BS2ScriptReadPtr(gBattlescriptCurrInstr + 1); const u8* mem2 = BS2ScriptReadPtr(gBattlescriptCurrInstr + 5); - u32 size = BSScriptRead8(gBattlescriptCurrInstr + 9); + u32 size = gBattlescriptCurrInstr[9]; const u8* jumpPtr = BS2ScriptReadPtr(gBattlescriptCurrInstr + 10); u8 i; @@ -4060,33 +4101,33 @@ void atk2D_jumpifarraynotequal(void) gBattlescriptCurrInstr += 14; } -void atk2E_setbyte(void) +static void atk2E_setbyte(void) { u8* memByte = BS2ScriptReadPtr(gBattlescriptCurrInstr + 1); - *memByte = BSScriptRead8(gBattlescriptCurrInstr + 5); + *memByte = gBattlescriptCurrInstr[5]; gBattlescriptCurrInstr += 6; } -void atk2F_addbyte(void) +static void atk2F_addbyte(void) { u8* memByte = BS2ScriptReadPtr(gBattlescriptCurrInstr + 1); - *memByte += BSScriptRead8(gBattlescriptCurrInstr + 5); + *memByte += gBattlescriptCurrInstr[5]; gBattlescriptCurrInstr += 6; } -void atk30_subbyte(void) +static void atk30_subbyte(void) { u8* memByte = BS2ScriptReadPtr(gBattlescriptCurrInstr + 1); - *memByte -= BSScriptRead8(gBattlescriptCurrInstr + 5); + *memByte -= gBattlescriptCurrInstr[5]; gBattlescriptCurrInstr += 6; } -void atk31_copyarray(void) +static void atk31_copyarray(void) { u8* dest = BS2ScriptReadPtr(gBattlescriptCurrInstr + 1); const u8* src = BS2ScriptReadPtr(gBattlescriptCurrInstr + 5); - s32 size = BSScriptRead8(gBattlescriptCurrInstr + 9); + s32 size = gBattlescriptCurrInstr[9]; s32 i; for (i = 0; i < size; i++) @@ -4097,12 +4138,12 @@ void atk31_copyarray(void) gBattlescriptCurrInstr += 10; } -void atk32_copyarray_withindex(void) +static 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 size = gBattlescriptCurrInstr[13]; s32 i; for (i = 0; i < size; i++) @@ -4113,14 +4154,14 @@ void atk32_copyarray_withindex(void) gBattlescriptCurrInstr += 14; } -void atk33_orbyte(void) +static void atk33_orbyte(void) { u8* memByte = BS2ScriptReadPtr(gBattlescriptCurrInstr + 1); - *memByte |= BSScriptRead8(gBattlescriptCurrInstr + 5); + *memByte |= gBattlescriptCurrInstr[5]; gBattlescriptCurrInstr += 6; } -void atk34_orhalfword(void) +static void atk34_orhalfword(void) { u16* memHword = BS2ScriptReadPtr(gBattlescriptCurrInstr + 1); u16 val = BS2ScriptRead16(gBattlescriptCurrInstr + 5); @@ -4129,7 +4170,7 @@ void atk34_orhalfword(void) gBattlescriptCurrInstr += 7; } -void atk35_orword(void) +static void atk35_orword(void) { u32* memWord = BS2ScriptReadPtr(gBattlescriptCurrInstr + 1); u32 val = BS2ScriptRead32(gBattlescriptCurrInstr + 5); @@ -4138,14 +4179,14 @@ void atk35_orword(void) gBattlescriptCurrInstr += 9; } -void atk36_bicbyte(void) +static void atk36_bicbyte(void) { u8* memByte = BS2ScriptReadPtr(gBattlescriptCurrInstr + 1); - *memByte &= ~(BSScriptRead8(gBattlescriptCurrInstr + 5)); + *memByte &= ~(gBattlescriptCurrInstr[5]); gBattlescriptCurrInstr += 6; } -void atk37_bichalfword(void) +static void atk37_bichalfword(void) { u16* memHword = BS2ScriptReadPtr(gBattlescriptCurrInstr + 1); u16 val = BS2ScriptRead16(gBattlescriptCurrInstr + 5); @@ -4154,7 +4195,7 @@ void atk37_bichalfword(void) gBattlescriptCurrInstr += 7; } -void atk38_bicword(void) +static void atk38_bicword(void) { u32* memWord = BS2ScriptReadPtr(gBattlescriptCurrInstr + 1); u32 val = BS2ScriptRead32(gBattlescriptCurrInstr + 5); @@ -4163,7 +4204,7 @@ void atk38_bicword(void) gBattlescriptCurrInstr += 9; } -void atk39_pause(void) +static void atk39_pause(void) { if (gBattleExecBuffer == 0) { @@ -4176,15 +4217,15 @@ void atk39_pause(void) } } -void atk3A_waitstate(void) +static void atk3A_waitstate(void) { if (gBattleExecBuffer == 0) gBattlescriptCurrInstr++; } -void atk3B_healthbar_update(void) +static void atk3B_healthbar_update(void) { - if (BSScriptRead8(gBattlescriptCurrInstr + 1) == BS_GET_TARGET) + if (gBattlescriptCurrInstr[1] == BS_GET_TARGET) gActiveBank = gBankTarget; else gActiveBank = gBankAttacker; @@ -4194,12 +4235,12 @@ void atk3B_healthbar_update(void) gBattlescriptCurrInstr += 2; } -void atk3C_return(void) +static void atk3C_return(void) { BattleScriptPop(); } -void atk3D_end(void) +static void atk3D_end(void) { if (gBattleTypeFlags & BATTLE_TYPE_ARENA) sub_81A5718(gBankAttacker); @@ -4209,13 +4250,13 @@ void atk3D_end(void) gFightStateTracker = 0xB; } -void atk3E_end2(void) +static void atk3E_end2(void) { gActiveBank = 0; gFightStateTracker = 0xB; } -void atk3F_end3(void) // pops the main function stack +static void atk3F_end3(void) // pops the main function stack { BattleScriptPop(); if (BATTLE_CALLBACKS_STACK->size) @@ -4223,40 +4264,40 @@ void atk3F_end3(void) // pops the main function stack gBattleMainFunc = BATTLE_CALLBACKS_STACK->function[BATTLE_CALLBACKS_STACK->size]; } -void atk41_call(void) +static void atk41_call(void) { BattleScriptPush(gBattlescriptCurrInstr + 5); gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); } -void atk42_jumpiftype2(void) +static void atk42_jumpiftype2(void) { - u8 bank = GetBattleBank(BSScriptRead8(gBattlescriptCurrInstr + 1)); + u8 bank = GetBattleBank(gBattlescriptCurrInstr[1]); - if (BSScriptRead8(gBattlescriptCurrInstr + 2) == gBattleMons[bank].type1 || BSScriptRead8(gBattlescriptCurrInstr + 2) == gBattleMons[bank].type2) + if (gBattlescriptCurrInstr[2] == gBattleMons[bank].type1 || gBattlescriptCurrInstr[2] == gBattleMons[bank].type2) gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 3); else gBattlescriptCurrInstr += 7; } -void atk43_jumpifabilitypresent(void) +static void atk43_jumpifabilitypresent(void) { - if (AbilityBattleEffects(ABILITYEFFECT_CHECK_ON_FIELD, 0, BSScriptRead8(gBattlescriptCurrInstr + 1), 0, 0)) + if (AbilityBattleEffects(ABILITYEFFECT_CHECK_ON_FIELD, 0, gBattlescriptCurrInstr[1], 0, 0)) gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 2); else gBattlescriptCurrInstr += 6; } -void atk44(void) +static void atk44(void) { *(gBankAttacker + gBattleStruct->field_54) = 1; } -void atk45_playanimation(void) +static void atk45_playanimation(void) { const u16* argumentPtr; - gActiveBank = GetBattleBank(BSScriptRead8(gBattlescriptCurrInstr + 1)); + gActiveBank = GetBattleBank(gBattlescriptCurrInstr[1]); argumentPtr = BS2ScriptReadPtr(gBattlescriptCurrInstr + 3); if (gBattlescriptCurrInstr[2] == B_ANIM_STATS_CHANGE @@ -4293,12 +4334,12 @@ void atk45_playanimation(void) } } -void atk46_playanimation2(void) // animation Id is stored in the first pointer +static void atk46_playanimation2(void) // animation Id is stored in the first pointer { const u16* argumentPtr; const u8* animationIdPtr; - gActiveBank = GetBattleBank(BSScriptRead8(gBattlescriptCurrInstr + 1)); + gActiveBank = GetBattleBank(gBattlescriptCurrInstr[1]); animationIdPtr = BS2ScriptReadPtr(gBattlescriptCurrInstr + 2); argumentPtr = BS2ScriptReadPtr(gBattlescriptCurrInstr + 6); @@ -4335,7 +4376,7 @@ void atk46_playanimation2(void) // animation Id is stored in the first pointer } } -void atk47_setgraphicalstatchangevalues(void) +static void atk47_setgraphicalstatchangevalues(void) { u8 value = 0; switch (gBattleScripting.statChanger & 0xF0) @@ -4359,7 +4400,7 @@ void atk47_setgraphicalstatchangevalues(void) } #ifdef NONMATCHING -void atk48_playstatchangeanimation(void) +static void atk48_playstatchangeanimation(void) { u32 currStat = 0; s16 statAnimId = 0; @@ -4450,7 +4491,7 @@ void atk48_playstatchangeanimation(void) } #else __attribute__((naked)) -void atk48_playstatchangeanimation(void) +static void atk48_playstatchangeanimation(void) { asm("\n\ .syntax unified\n\ @@ -4706,7 +4747,7 @@ _0804BBBA:\n\ #define ATK49_LAST_CASE 17 -void atk49_moveend(void) +static void atk49_moveend(void) { s32 i; bool32 effect; @@ -4992,7 +5033,7 @@ void atk49_moveend(void) gBattlescriptCurrInstr += 3; } -void atk4A_typecalc2(void) +static void atk4A_typecalc2(void) { u8 flags = 0; s32 i = 0; @@ -5087,7 +5128,7 @@ void atk4A_typecalc2(void) gBattlescriptCurrInstr++; } -void atk4B_return_atk_to_ball(void) +static void atk4B_return_atk_to_ball(void) { gActiveBank = gBankAttacker; if (!(gHitMarker & HITMARKER_FAINTED(gActiveBank))) @@ -5098,12 +5139,12 @@ void atk4B_return_atk_to_ball(void) gBattlescriptCurrInstr++; } -void atk4C_copy_poke_data(void) +static void atk4C_copy_poke_data(void) { if (gBattleExecBuffer) return; - gActiveBank = GetBattleBank(BSScriptRead8(gBattlescriptCurrInstr + 1)); + gActiveBank = GetBattleBank(gBattlescriptCurrInstr[1]); gBattlePartyID[gActiveBank] = *(gBattleStruct->field_5C + gActiveBank); @@ -5113,7 +5154,7 @@ void atk4C_copy_poke_data(void) gBattlescriptCurrInstr += 2; } -void atk4D_switch_data_update(void) +static void atk4D_switch_data_update(void) { struct BattlePokemon oldData; s32 i; @@ -5122,7 +5163,7 @@ void atk4D_switch_data_update(void) if (gBattleExecBuffer) return; - gActiveBank = GetBattleBank(BSScriptRead8(gBattlescriptCurrInstr + 1)); + gActiveBank = GetBattleBank(gBattlescriptCurrInstr[1]); oldData = gBattleMons[gActiveBank]; monData = (u8*)(&gBattleMons[gActiveBank]); @@ -5169,12 +5210,12 @@ void atk4D_switch_data_update(void) gBattlescriptCurrInstr += 2; } -void atk4E_switchin_anim(void) +static void atk4E_switchin_anim(void) { if (gBattleExecBuffer) return; - gActiveBank = GetBattleBank(BSScriptRead8(gBattlescriptCurrInstr + 1)); + gActiveBank = GetBattleBank(gBattlescriptCurrInstr[1]); if (GetBankSide(gActiveBank) == SIDE_OPPONENT && !(gBattleTypeFlags & (BATTLE_TYPE_LINK @@ -5195,7 +5236,7 @@ void atk4E_switchin_anim(void) sub_81A56B4(); } -void atk4F_jump_if_cannot_switch(void) +static void atk4F_jump_if_cannot_switch(void) { s32 val = 0; s32 compareVar = 0; @@ -5349,7 +5390,7 @@ void atk4F_jump_if_cannot_switch(void) } } -void sub_804CF10(u8 arg0) +static void sub_804CF10(u8 arg0) { *(gBattleStruct->field_58 + gActiveBank) = gBattlePartyID[gActiveBank]; *(gBattleStruct->field_5C + gActiveBank) = 6; @@ -5359,7 +5400,7 @@ void sub_804CF10(u8 arg0) MarkBufferBankForExecution(gActiveBank); } -void atk50_openpartyscreen(void) +static void atk50_openpartyscreen(void) { u32 flags; u8 hitmarkerFaintBits; @@ -5649,15 +5690,15 @@ void atk50_openpartyscreen(void) } } -void atk51_switch_handle_order(void) +static void atk51_switch_handle_order(void) { s32 i; if (gBattleExecBuffer) return; - gActiveBank = GetBattleBank(BSScriptRead8(gBattlescriptCurrInstr + 1)); + gActiveBank = GetBattleBank(gBattlescriptCurrInstr[1]); - switch (BSScriptRead8(gBattlescriptCurrInstr + 2)) + switch (gBattlescriptCurrInstr[2]) { case 0: for (i = 0; i < gNoOfAllBanks; i++) @@ -5716,11 +5757,11 @@ void atk51_switch_handle_order(void) gBattlescriptCurrInstr += 3; } -void atk52_switch_in_effects(void) +static void atk52_switch_in_effects(void) { s32 i; - gActiveBank = GetBattleBank(BSScriptRead8(gBattlescriptCurrInstr + 1)); + gActiveBank = GetBattleBank(gBattlescriptCurrInstr[1]); sub_803FA70(gActiveBank); gHitMarker &= ~(HITMARKER_FAINTED(gActiveBank)); @@ -5747,9 +5788,9 @@ void atk52_switch_in_effects(void) gBattleScripting.bank = gActiveBank; BattleScriptPushCursor(); - if (BSScriptRead8(gBattlescriptCurrInstr + 1) == 0) + if (gBattlescriptCurrInstr[1] == 0) gBattlescriptCurrInstr = gUnknown_082DAE90; - else if (BSScriptRead8(gBattlescriptCurrInstr + 1) == 1) + else if (gBattlescriptCurrInstr[1] == 1) gBattlescriptCurrInstr = gUnknown_082DAE59; else gBattlescriptCurrInstr = gUnknown_082DAEC7; @@ -5778,7 +5819,7 @@ void atk52_switch_in_effects(void) *hpOnSwitchout = gBattleMons[i].hp; } - if (BSScriptRead8(gBattlescriptCurrInstr + 1) == 5) + if (gBattlescriptCurrInstr[1] == 5) { u32 hitmarkerFaintBits = gHitMarker >> 0x1C; @@ -5797,7 +5838,7 @@ void atk52_switch_in_effects(void) } } -void atk53_trainer_slide(void) +static void atk53_trainer_slide(void) { gActiveBank = GetBankByIdentity(gBattlescriptCurrInstr[1]); EmitTrainerSlide(0); @@ -5806,7 +5847,7 @@ void atk53_trainer_slide(void) gBattlescriptCurrInstr += 2; } -void atk54_effectiveness_sound(void) +static void atk54_effectiveness_sound(void) { gActiveBank = gBankAttacker; EmitEffectivenessSound(0, BS2ScriptRead16(gBattlescriptCurrInstr + 1)); @@ -5815,7 +5856,7 @@ void atk54_effectiveness_sound(void) gBattlescriptCurrInstr += 3; } -void atk55_play_sound(void) +static void atk55_play_sound(void) { gActiveBank = gBankAttacker; EmitPlaySound(0, BS2ScriptRead16(gBattlescriptCurrInstr + 1), 0); @@ -5824,16 +5865,16 @@ void atk55_play_sound(void) gBattlescriptCurrInstr += 3; } -void atk56_fainting_cry(void) +static void atk56_fainting_cry(void) { - gActiveBank = GetBattleBank(BSScriptRead8(gBattlescriptCurrInstr + 1)); + gActiveBank = GetBattleBank(gBattlescriptCurrInstr[1]); EmitFaintingCry(0); MarkBufferBankForExecution(gActiveBank); gBattlescriptCurrInstr += 2; } -void atk57(void) +static void atk57(void) { gActiveBank = GetBankByIdentity(0); Emit_x37(0, gBattleOutcome); @@ -5842,21 +5883,21 @@ void atk57(void) gBattlescriptCurrInstr += 1; } -void atk58_return_to_ball(void) +static void atk58_return_to_ball(void) { - gActiveBank = GetBattleBank(BSScriptRead8(gBattlescriptCurrInstr + 1)); + gActiveBank = GetBattleBank(gBattlescriptCurrInstr[1]); EmitReturnPokeToBall(0, 1); MarkBufferBankForExecution(gActiveBank); gBattlescriptCurrInstr += 2; } -void atk59_learnmove_inbattle(void) +static void atk59_learnmove_inbattle(void) { const u8* jumpPtr1 = BSScriptReadPtr(gBattlescriptCurrInstr + 1); const u8* jumpPtr2 = BSScriptReadPtr(gBattlescriptCurrInstr + 5); - u16 ret = MonTryLearningNewMove(&gPlayerParty[gBattleStruct->expGetterId], BSScriptRead8(gBattlescriptCurrInstr + 9)); + u16 ret = MonTryLearningNewMove(&gPlayerParty[gBattleStruct->expGetterId], gBattlescriptCurrInstr[9]); while (ret == 0xFFFE) ret = MonTryLearningNewMove(&gPlayerParty[gBattleStruct->expGetterId], 0); @@ -5891,7 +5932,7 @@ void atk59_learnmove_inbattle(void) } } -void atk5A_yesnoboxlearnmove(void) +static void atk5A_yesnoboxlearnmove(void) { gActiveBank = 0; @@ -6010,7 +6051,7 @@ void atk5A_yesnoboxlearnmove(void) } } -void atk5B_yesnoboxstoplearningmove(void) +static void atk5B_yesnoboxstoplearningmove(void) { switch (gBattleScripting.learnMoveState) { @@ -6057,9 +6098,9 @@ void atk5B_yesnoboxstoplearningmove(void) } } -void atk5C_hitanimation(void) +static void atk5C_hitanimation(void) { - gActiveBank = GetBattleBank(BSScriptRead8(gBattlescriptCurrInstr + 1)); + gActiveBank = GetBattleBank(gBattlescriptCurrInstr[1]); if (gBattleMoveFlags & MOVESTATUS_NOEFFECT) { @@ -6134,7 +6175,7 @@ static u32 GetTrainerMoneyToGive(u16 trainerId) return moneyReward; } -void atk5D_getmoneyreward(void) +static void atk5D_getmoneyreward(void) { u32 moneyReward = GetTrainerMoneyToGive(gTrainerBattleOpponent_A); if (gBattleTypeFlags & BATTLE_TYPE_TWO_OPPONENTS) @@ -6147,9 +6188,9 @@ void atk5D_getmoneyreward(void) gBattlescriptCurrInstr++; } -void atk5E_8025A70(void) +static void atk5E_8025A70(void) { - gActiveBank = GetBattleBank(BSScriptRead8(gBattlescriptCurrInstr + 1)); + gActiveBank = GetBattleBank(gBattlescriptCurrInstr[1]); switch (gBattleCommunication[0]) { @@ -6174,7 +6215,7 @@ void atk5E_8025A70(void) } } -void atk5F_8025B24(void) +static void atk5F_8025B24(void) { gActiveBank = gBankAttacker; gBankAttacker = gBankTarget; @@ -6188,15 +6229,15 @@ void atk5F_8025B24(void) gBattlescriptCurrInstr++; } -void atk60_increment_gamestat(void) +static void atk60_increment_gamestat(void) { if (GetBankSide(gBankAttacker) == SIDE_PLAYER) - IncrementGameStat(BSScriptRead8(gBattlescriptCurrInstr + 1)); + IncrementGameStat(gBattlescriptCurrInstr[1]); gBattlescriptCurrInstr += 2; } -void atk61_8025BA4(void) +static void atk61_8025BA4(void) { s32 i; struct Pokemon* party; @@ -6205,7 +6246,7 @@ void atk61_8025BA4(void) if (gBattleExecBuffer) return; - gActiveBank = GetBattleBank(BSScriptRead8(gBattlescriptCurrInstr + 1)); + gActiveBank = GetBattleBank(gBattlescriptCurrInstr[1]); if (GetBankSide(gActiveBank) == SIDE_PLAYER) party = gPlayerParty; @@ -6233,18 +6274,18 @@ void atk61_8025BA4(void) gBattlescriptCurrInstr += 2; } -void atk62_08025C6C(void) +static void atk62_08025C6C(void) { - gActiveBank = GetBattleBank(BSScriptRead8(gBattlescriptCurrInstr + 1)); + gActiveBank = GetBattleBank(gBattlescriptCurrInstr[1]); EmitCmd49(0); MarkBufferBankForExecution(gActiveBank); gBattlescriptCurrInstr += 2; } -void atk63_jumptorandomattack(void) +static void atk63_jumptorandomattack(void) { - if (BSScriptRead8(gBattlescriptCurrInstr + 1) != 0) + if (gBattlescriptCurrInstr[1] != 0) gCurrentMove = gRandomMove; else gLastUsedMove = gCurrentMove = gRandomMove; @@ -6252,11 +6293,11 @@ void atk63_jumptorandomattack(void) gBattlescriptCurrInstr = gBattleScriptsForMoveEffects[gBattleMoves[gCurrentMove].effect]; } -void atk64_statusanimation(void) +static void atk64_statusanimation(void) { if (gBattleExecBuffer == 0) { - gActiveBank = GetBattleBank(BSScriptRead8(gBattlescriptCurrInstr + 1)); + gActiveBank = GetBattleBank(gBattlescriptCurrInstr[1]); if (!(gStatuses3[gActiveBank] & STATUS3_SEMI_INVULNERABLE) && gDisableStructs[gActiveBank].substituteHP == 0 && !(gHitMarker & HITMARKER_NO_ANIMATIONS)) @@ -6268,13 +6309,13 @@ void atk64_statusanimation(void) } } -void atk65_status2animation(void) +static void atk65_status2animation(void) { u32 wantedToAnimate; if (gBattleExecBuffer == 0) { - gActiveBank = GetBattleBank(BSScriptRead8(gBattlescriptCurrInstr + 1)); + gActiveBank = GetBattleBank(gBattlescriptCurrInstr[1]); wantedToAnimate = BSScriptRead32(gBattlescriptCurrInstr + 2); if (!(gStatuses3[gActiveBank] & STATUS3_SEMI_INVULNERABLE) && gDisableStructs[gActiveBank].substituteHP == 0 @@ -6287,26 +6328,26 @@ void atk65_status2animation(void) } } -void atk66_chosenstatusanimation(void) +static void atk66_chosenstatusanimation(void) { u32 wantedStatus; if (gBattleExecBuffer == 0) { - gActiveBank = GetBattleBank(BSScriptRead8(gBattlescriptCurrInstr + 1)); + gActiveBank = GetBattleBank(gBattlescriptCurrInstr[1]); wantedStatus = BSScriptRead32(gBattlescriptCurrInstr + 3); if (!(gStatuses3[gActiveBank] & STATUS3_SEMI_INVULNERABLE) && gDisableStructs[gActiveBank].substituteHP == 0 && !(gHitMarker & HITMARKER_NO_ANIMATIONS)) { - EmitStatusAnimation(0, BSScriptRead8(gBattlescriptCurrInstr + 2), wantedStatus); + EmitStatusAnimation(0, gBattlescriptCurrInstr[2], wantedStatus); MarkBufferBankForExecution(gActiveBank); } gBattlescriptCurrInstr += 7; } } -void atk67_yesnobox(void) +static void atk67_yesnobox(void) { switch (gBattleCommunication[0]) { @@ -6349,7 +6390,7 @@ void atk67_yesnobox(void) } } -void atk68_80246A0(void) +static void atk68_80246A0(void) { s32 i; @@ -6359,7 +6400,7 @@ void atk68_80246A0(void) gBattlescriptCurrInstr++; } -void atk69_dmg_adjustment3(void) // The same as 0x7, except there's no random damage multiplier. +static void atk69_dmg_adjustment3(void) // The same as 0x7, except there's no random damage multiplier. { u8 holdEffect, quality; @@ -6405,11 +6446,11 @@ void atk69_dmg_adjustment3(void) // The same as 0x7, except there's no random da gBattlescriptCurrInstr++; } -void atk6A_removeitem(void) +static void atk6A_removeitem(void) { u16* usedHeldItem; - gActiveBank = GetBattleBank(BSScriptRead8(gBattlescriptCurrInstr + 1)); + gActiveBank = GetBattleBank(gBattlescriptCurrInstr[1]); usedHeldItem = &gBattleStruct->usedHeldItems[gActiveBank]; *usedHeldItem = gBattleMons[gActiveBank].item; @@ -6421,19 +6462,14 @@ void atk6A_removeitem(void) gBattlescriptCurrInstr += 2; } -void atk6B_atknameinbuff1(void) +static void atk6B_atknameinbuff1(void) { PREPARE_MON_NICK_BUFFER(gBattleTextBuff1, gBankAttacker, gBattlePartyID[gBankAttacker]) gBattlescriptCurrInstr++; } -extern u16 gBattle_BG1_X; -extern u16 gBattle_BG1_Y; -extern u16 gBattle_BG2_X; -extern u16 gBattle_BG2_Y; - -void atk6C_draw_lvlupbox(void) +static void atk6C_draw_lvlupbox(void) { if (gBattleScripting.atk6C_state == 0) { @@ -6525,7 +6561,7 @@ void atk6C_draw_lvlupbox(void) } } -void sub_804F100(void) +static void sub_804F100(void) { struct StatsArray currentStats; @@ -6533,7 +6569,7 @@ void sub_804F100(void) sub_81D3640(0xD, gBattleResources->statsBeforeLvlUp, ¤tStats, 0xE, 0xD, 0xF); } -void sub_804F144(void) +static void sub_804F144(void) { struct StatsArray currentStats; @@ -6541,10 +6577,7 @@ void sub_804F144(void) sub_81D3784(0xD, ¤tStats, 0xE, 0xD, 0xF); } -extern const u16 gUnknown_0831C2C8[]; -extern const u8 gUnknown_0831C2E8[]; - -void sub_804F17C(void) +static void sub_804F17C(void) { gBattle_BG2_Y = 0; gBattle_BG2_X = 0x1A0; @@ -6557,7 +6590,7 @@ void sub_804F17C(void) PutMonIconOnLvlUpBox(); } -bool8 sub_804F1CC(void) +static bool8 sub_804F1CC(void) { if (IsDma3ManagerBusyWithBgCopy()) return TRUE; @@ -6575,7 +6608,7 @@ bool8 sub_804F1CC(void) return (gBattle_BG2_X != 0x200); } -void PutLevelAndGenderOnLvlUpBox(void) +static void PutLevelAndGenderOnLvlUpBox(void) { u16 monLevel; u8 monGender; @@ -6638,7 +6671,7 @@ void PutLevelAndGenderOnLvlUpBox(void) CopyWindowToVram(14, 2); } -bool8 sub_804F344(void) +static bool8 sub_804F344(void) { if (gBattle_BG2_X == 0x1A0) return FALSE; @@ -6656,7 +6689,7 @@ bool8 sub_804F344(void) #define sDestroy data0 #define sSavedLvlUpBoxXPosition data1 -void PutMonIconOnLvlUpBox(void) +static void PutMonIconOnLvlUpBox(void) { u8 spriteId; const u16* iconPal; @@ -6702,7 +6735,7 @@ void SpriteCB_MonIconOnLvlUpBox(struct Sprite* sprite) #undef sDestroy #undef sSavedLvlUpBoxXPosition -bool32 IsMonGettingExpSentOut(void) +static bool32 IsMonGettingExpSentOut(void) { if (gBattlePartyID[0] == gBattleStruct->expGetterId) return TRUE; @@ -6712,30 +6745,30 @@ bool32 IsMonGettingExpSentOut(void) return FALSE; } -void atk6D_reset_sentpokes_value(void) +static void atk6D_reset_sentpokes_value(void) { ResetSentPokesToOpponentValue(); gBattlescriptCurrInstr++; } -void atk6E_set_atk_to_player0(void) +static void atk6E_set_atk_to_player0(void) { gBankAttacker = GetBankByIdentity(0); gBattlescriptCurrInstr++; } -void atk6F_set_visible(void) +static void atk6F_set_visible(void) { - gActiveBank = GetBattleBank(BSScriptRead8(gBattlescriptCurrInstr + 1)); + gActiveBank = GetBattleBank(gBattlescriptCurrInstr[1]); EmitSpriteInvisibility(0, FALSE); MarkBufferBankForExecution(gActiveBank); gBattlescriptCurrInstr += 2; } -void atk70_record_last_used_ability(void) +static void atk70_record_last_used_ability(void) { - gActiveBank = GetBattleBank(BSScriptRead8(gBattlescriptCurrInstr + 1)); + gActiveBank = GetBattleBank(gBattlescriptCurrInstr[1]); RecordAbilityBattle(gActiveBank, gLastUsedAbility); gBattlescriptCurrInstr += 1; // UB: Should be + 2, one byte for command and one byte for bank argument. } @@ -6745,13 +6778,13 @@ void BufferMoveToLearnIntoBattleTextBuff2(void) PREPARE_MOVE_BUFFER(gBattleTextBuff2, gMoveToLearn); } -void atk71_buffer_move_to_learn(void) +static void atk71_buffer_move_to_learn(void) { BufferMoveToLearnIntoBattleTextBuff2(); gBattlescriptCurrInstr++; } -void atk72_jump_if_can_run_frombattle(void) +static void atk72_jump_if_can_run_frombattle(void) { if (CanRunFromBattle(gBank1)) gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); @@ -6759,14 +6792,14 @@ void atk72_jump_if_can_run_frombattle(void) gBattlescriptCurrInstr += 5; } -void atk73_hp_thresholds(void) +static void atk73_hp_thresholds(void) { u8 opposingBank; s32 result; if (!(gBattleTypeFlags & BATTLE_TYPE_DOUBLE)) { - gActiveBank = GetBattleBank(BSScriptRead8(gBattlescriptCurrInstr + 1)); + gActiveBank = GetBattleBank(gBattlescriptCurrInstr[1]); opposingBank = gActiveBank ^ BIT_SIDE; result = gBattleMons[opposingBank].hp * 100 / gBattleMons[opposingBank].maxHP; @@ -6786,7 +6819,7 @@ void atk73_hp_thresholds(void) gBattlescriptCurrInstr += 2; } -void atk74_hp_thresholds2(void) +static void atk74_hp_thresholds2(void) { u8 opposingBank; s32 result; @@ -6794,7 +6827,7 @@ void atk74_hp_thresholds2(void) if (!(gBattleTypeFlags & BATTLE_TYPE_DOUBLE)) { - gActiveBank = GetBattleBank(BSScriptRead8(gBattlescriptCurrInstr + 1)); + gActiveBank = GetBattleBank(gBattlescriptCurrInstr[1]); opposingBank = gActiveBank ^ BIT_SIDE; hpSwitchout = *(gBattleStruct->hpOnSwitchout + GetBankSide(opposingBank)); result = (hpSwitchout - gBattleMons[opposingBank].hp) * 100 / hpSwitchout; @@ -6812,7 +6845,7 @@ void atk74_hp_thresholds2(void) gBattlescriptCurrInstr += 2; } -void atk75_item_effect_on_opponent(void) +static void atk75_item_effect_on_opponent(void) { gBankInMenu = gBankAttacker; ExecuteTableBasedItemEffect(&gEnemyParty[gBattlePartyID[gBankAttacker]], gLastUsedItem, gBattlePartyID[gBankAttacker], 0, 1); @@ -6820,10 +6853,7 @@ void atk75_item_effect_on_opponent(void) gBattlescriptCurrInstr += 1; } -extern const u8 gUnknown_0831C4F8[]; -extern const u8* const gRefereeStringsTable[]; - -void atk76_various(void) +static void atk76_various(void) { u8 side; s32 i; @@ -7002,7 +7032,7 @@ void atk76_various(void) gBattlescriptCurrInstr += 3; } -void atk77_set_protect_like(void) // protect and endure +static void atk77_set_protect_like(void) // protect and endure { bool8 notLastTurn = TRUE; u16 lastMove = gUnknown_02024260[gBankAttacker]; @@ -7037,7 +7067,7 @@ void atk77_set_protect_like(void) // protect and endure gBattlescriptCurrInstr++; } -void atk78_faintifabilitynotdamp(void) +static void atk78_faintifabilitynotdamp(void) { if (gBattleExecBuffer) return; @@ -7072,7 +7102,7 @@ void atk78_faintifabilitynotdamp(void) } } -void atk79_setatkhptozero(void) +static void atk79_setatkhptozero(void) { if (gBattleExecBuffer) return; @@ -7085,7 +7115,7 @@ void atk79_setatkhptozero(void) gBattlescriptCurrInstr++; } -void atk7A_jumpwhiletargetvalid(void) // Used by intimidate to loop through all targets. +static void atk7A_jumpwhiletargetvalid(void) // Used by intimidate to loop through all targets. { const u8* jumpPtr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); @@ -7108,11 +7138,11 @@ void atk7A_jumpwhiletargetvalid(void) // Used by intimidate to loop through all gBattlescriptCurrInstr += 5; } -void atk7B_healhalfHP_if_possible(void) +static void atk7B_healhalfHP_if_possible(void) { const u8* failPtr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); - if (BSScriptRead8(gBattlescriptCurrInstr + 5) == BS_GET_ATTACKER) + if (gBattlescriptCurrInstr[5] == BS_GET_ATTACKER) gBankTarget = gBankAttacker; gBattleMoveDamage = gBattleMons[gBankTarget].maxHP / 2; @@ -7126,7 +7156,7 @@ void atk7B_healhalfHP_if_possible(void) gBattlescriptCurrInstr += 6; } -void atk7C_trymirrormove(void) +static void atk7C_trymirrormove(void) { s32 validMovesCount; s32 i; @@ -7176,7 +7206,7 @@ void atk7C_trymirrormove(void) } } -void atk7D_set_rain(void) +static void atk7D_set_rain(void) { if (gBattleWeather & WEATHER_RAIN_ANY) { @@ -7192,7 +7222,7 @@ void atk7D_set_rain(void) gBattlescriptCurrInstr++; } -void atk7E_setreflect(void) +static void atk7E_setreflect(void) { if (gSideAffecting[GET_BANK_SIDE(gBankAttacker)] & SIDE_STATUS_REFLECT) { @@ -7213,7 +7243,7 @@ void atk7E_setreflect(void) gBattlescriptCurrInstr++; } -void atk7F_setseeded(void) +static void atk7F_setseeded(void) { if (gBattleMoveFlags & MOVESTATUS_NOEFFECT || gStatuses3[gBankTarget] & STATUS3_LEECHSEED) { @@ -7235,9 +7265,9 @@ void atk7F_setseeded(void) gBattlescriptCurrInstr++; } -void atk80_manipulatedamage(void) +static void atk80_manipulatedamage(void) { - switch (BSScriptRead8(gBattlescriptCurrInstr + 1)) + switch (gBattlescriptCurrInstr[1]) { case ATK80_DMG_CHANGE_SIGN: gBattleMoveDamage *= -1; @@ -7257,7 +7287,7 @@ void atk80_manipulatedamage(void) gBattlescriptCurrInstr += 2; } -void atk81_setrest(void) +static void atk81_setrest(void) { const u8* failJump = BSScriptReadPtr(gBattlescriptCurrInstr + 1); gActiveBank = gBankTarget = gBankAttacker; @@ -7281,7 +7311,7 @@ void atk81_setrest(void) } } -void atk82_jumpifnotfirstturn(void) +static void atk82_jumpifnotfirstturn(void) { const u8* failJump = BSScriptReadPtr(gBattlescriptCurrInstr + 1); @@ -7291,7 +7321,7 @@ void atk82_jumpifnotfirstturn(void) gBattlescriptCurrInstr = failJump; } -void atk83_nop(void) +static void atk83_nop(void) { gBattlescriptCurrInstr++; } @@ -7323,7 +7353,7 @@ bool8 UproarWakeUpCheck(u8 bank) return TRUE; } -void atk84_jump_if_cant_sleep(void) +static void atk84_jump_if_cant_sleep(void) { const u8* jumpPtr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); @@ -7345,7 +7375,7 @@ void atk84_jump_if_cant_sleep(void) } } -void atk85_stockpile(void) +static void atk85_stockpile(void) { if (gDisableStructs[gBankAttacker].stockpileCounter == 3) { @@ -7363,7 +7393,7 @@ void atk85_stockpile(void) gBattlescriptCurrInstr++; } -void atk86_stockpiletobasedamage(void) +static void atk86_stockpiletobasedamage(void) { const u8* jumpPtr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); if (gDisableStructs[gBankAttacker].stockpileCounter == 0) @@ -7389,7 +7419,7 @@ void atk86_stockpiletobasedamage(void) } } -void atk87_stockpiletohpheal(void) +static void atk87_stockpiletohpheal(void) { const u8* jumpPtr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); @@ -7420,7 +7450,7 @@ void atk87_stockpiletohpheal(void) } } -void atk88_negativedamage(void) +static void atk88_negativedamage(void) { gBattleMoveDamage = -(gHpDealt / 2); if (gBattleMoveDamage == 0) @@ -7429,7 +7459,7 @@ void atk88_negativedamage(void) gBattlescriptCurrInstr++; } -u8 ChangeStatBuffs(s8 statValue, u8 statId, u8 flags, const u8* BS_ptr) +static u8 ChangeStatBuffs(s8 statValue, u8 statId, u8 flags, const u8* BS_ptr) { bool8 certain = 0; bool8 notProtectAffected = FALSE; @@ -7599,14 +7629,14 @@ u8 ChangeStatBuffs(s8 statValue, u8 statId, u8 flags, const u8* BS_ptr) return STAT_CHANGE_WORKED; } -void atk89_statbuffchange(void) +static void atk89_statbuffchange(void) { const u8* jumpPtr = BSScriptReadPtr(gBattlescriptCurrInstr + 2); - if (ChangeStatBuffs(gBattleScripting.statChanger & 0xF0, GET_STAT_BUFF_ID(gBattleScripting.statChanger), BSScriptRead8(gBattlescriptCurrInstr + 1), jumpPtr) == STAT_CHANGE_WORKED) + if (ChangeStatBuffs(gBattleScripting.statChanger & 0xF0, GET_STAT_BUFF_ID(gBattleScripting.statChanger), gBattlescriptCurrInstr[1], jumpPtr) == STAT_CHANGE_WORKED) gBattlescriptCurrInstr += 6; } -void atk8A_normalisebuffs(void) // haze +static void atk8A_normalisebuffs(void) // haze { s32 i, j; @@ -7619,7 +7649,7 @@ void atk8A_normalisebuffs(void) // haze gBattlescriptCurrInstr++; } -void atk8B_setbide(void) +static void atk8B_setbide(void) { gBattleMons[gBankAttacker].status2 |= STATUS2_MULTIPLETURNS; gLockedMoves[gBankAttacker] = gCurrentMove; @@ -7629,7 +7659,7 @@ void atk8B_setbide(void) gBattlescriptCurrInstr++; } -void atk8C_confuseifrepeatingattackends(void) +static void atk8C_confuseifrepeatingattackends(void) { if (!(gBattleMons[gBankAttacker].status2 & STATUS2_LOCK_CONFUSE)) gBattleCommunication[MOVE_EFFECT_BYTE] = (MOVE_EFFECT_THRASH | MOVE_EFFECT_AFFECTS_USER); @@ -7637,11 +7667,11 @@ void atk8C_confuseifrepeatingattackends(void) gBattlescriptCurrInstr++; } -void atk8D_setmultihit_counter(void) +static void atk8D_setmultihit_counter(void) { - if (BSScriptRead8(gBattlescriptCurrInstr + 1)) + if (gBattlescriptCurrInstr[1]) { - gMultiHitCounter = BSScriptRead8(gBattlescriptCurrInstr + 1); + gMultiHitCounter = gBattlescriptCurrInstr[1]; } else { @@ -7655,14 +7685,14 @@ void atk8D_setmultihit_counter(void) gBattlescriptCurrInstr += 2; } -void atk8E_init_multihit_string(void) +static void atk8E_init_multihit_string(void) { PREPARE_BYTE_NUMBER_BUFFER(gBattleScripting.multihitString, 1, 0) gBattlescriptCurrInstr++; } -bool8 sub_8051064(void) +static bool8 sub_8051064(void) { if (gBattleMons[gBankAttacker].level >= gBattleMons[gBankTarget].level) { @@ -7683,7 +7713,7 @@ bool8 sub_8051064(void) return TRUE; } -void atk8F_forcerandomswitch(void) +static void atk8F_forcerandomswitch(void) { s32 i; s32 bank1PartyId = 0; @@ -7844,7 +7874,7 @@ void atk8F_forcerandomswitch(void) } } -void atk90_conversion_type_change(void) // randomly changes user's type to one of its moves' type +static void atk90_conversion_type_change(void) // randomly changes user's type to one of its moves' type { u8 validMoves = 0; u8 moveChecked; @@ -7908,7 +7938,7 @@ void atk90_conversion_type_change(void) // randomly changes user's type to one o } } -void atk91_givepaydaymoney(void) +static void atk91_givepaydaymoney(void) { if (!(gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_x2000000)) && gPaydayMoney != 0) { @@ -7926,7 +7956,7 @@ void atk91_givepaydaymoney(void) } } -void atk92_setlightscreen(void) +static void atk92_setlightscreen(void) { if (gSideAffecting[GET_BANK_SIDE(gBankAttacker)] & SIDE_STATUS_LIGHTSCREEN) { @@ -7948,7 +7978,7 @@ void atk92_setlightscreen(void) gBattlescriptCurrInstr++; } -void atk93_ko_move(void) +static void atk93_ko_move(void) { u8 holdEffect, param; @@ -8034,7 +8064,7 @@ void atk93_ko_move(void) } } -void atk94_damagetohalftargethp(void) // super fang +static void atk94_damagetohalftargethp(void) // super fang { gBattleMoveDamage = gBattleMons[gBankTarget].hp / 2; if (gBattleMoveDamage == 0) @@ -8043,7 +8073,7 @@ void atk94_damagetohalftargethp(void) // super fang gBattlescriptCurrInstr++; } -void atk95_setsandstorm(void) +static void atk95_setsandstorm(void) { if (gBattleWeather & WEATHER_SANDSTORM_ANY) { @@ -8059,7 +8089,7 @@ void atk95_setsandstorm(void) gBattlescriptCurrInstr++; } -void atk96_weatherdamage(void) +static void atk96_weatherdamage(void) { if (WEATHER_HAS_EFFECT) { @@ -8112,7 +8142,7 @@ void atk96_weatherdamage(void) gBattlescriptCurrInstr++; } -void atk97_try_infatuation(void) +static void atk97_try_infatuation(void) { struct Pokemon *monAttacker, *monTarget; u16 speciesAttacker, speciesTarget; @@ -8157,14 +8187,14 @@ void atk97_try_infatuation(void) } } -void atk98_status_icon_update(void) +static void atk98_status_icon_update(void) { if (gBattleExecBuffer) return; - if (BSScriptRead8(gBattlescriptCurrInstr + 1) != BS_ATTACKER_WITH_PARTNER) + if (gBattlescriptCurrInstr[1] != BS_ATTACKER_WITH_PARTNER) { - gActiveBank = GetBattleBank(BSScriptRead8(gBattlescriptCurrInstr + 1)); + gActiveBank = GetBattleBank(gBattlescriptCurrInstr[1]); EmitStatusIconUpdate(0, gBattleMons[gActiveBank].status1, gBattleMons[gActiveBank].status2); MarkBufferBankForExecution(gActiveBank); gBattlescriptCurrInstr += 2; @@ -8190,7 +8220,7 @@ void atk98_status_icon_update(void) } } -void atk99_setmist(void) +static void atk99_setmist(void) { if (gSideTimers[GET_BANK_SIDE(gBankAttacker)].mistTimer) { @@ -8207,7 +8237,7 @@ void atk99_setmist(void) gBattlescriptCurrInstr++; } -void atk9A_set_focusenergy(void) +static void atk9A_set_focusenergy(void) { if (gBattleMons[gBankAttacker].status2 & STATUS2_FOCUS_ENERGY) { @@ -8222,7 +8252,7 @@ void atk9A_set_focusenergy(void) gBattlescriptCurrInstr++; } -void atk9B_transformdataexecution(void) +static void atk9B_transformdataexecution(void) { gLastUsedMove = 0xFFFF; gBattlescriptCurrInstr++; @@ -8266,7 +8296,7 @@ void atk9B_transformdataexecution(void) } } -void atk9C_set_substitute(void) +static void atk9C_set_substitute(void) { u32 hp = gBattleMons[gBankAttacker].maxHP / 4; if (gBattleMons[gBankAttacker].maxHP / 4 == 0) @@ -8293,11 +8323,6 @@ void atk9C_set_substitute(void) gBattlescriptCurrInstr++; } -extern const u16 gMovesForbiddenToCopy[]; -#define MIMIC_FORBIDDEN_END 0xFFFE -#define METRONOME_FORBIDDEN_END 0xFFFF -#define ASSIST_FORBIDDEN_END 0xFFFF - static bool8 IsMoveUncopyableByMimic(u16 move) { s32 i; @@ -8307,7 +8332,7 @@ static bool8 IsMoveUncopyableByMimic(u16 move) return (gMovesForbiddenToCopy[i] != MIMIC_FORBIDDEN_END); } -void atk9D_mimicattackcopy(void) +static void atk9D_mimicattackcopy(void) { gLastUsedMove = 0xFFFF; @@ -8350,7 +8375,7 @@ void atk9D_mimicattackcopy(void) } #ifdef NONMATCHING -void atk9E_metronome(void) +static void atk9E_metronome(void) { while (1) { @@ -8382,7 +8407,7 @@ void atk9E_metronome(void) #else __attribute__((naked)) -void atk9E_metronome(void) +static void atk9E_metronome(void) { asm( "\n\ @@ -8459,13 +8484,13 @@ _0805251C:\n\ #endif // NONMATCHING -void atk9F_dmgtolevel(void) +static void atk9F_dmgtolevel(void) { gBattleMoveDamage = gBattleMons[gBankAttacker].level; gBattlescriptCurrInstr++; } -void atkA0_psywavedamageeffect(void) +static void atkA0_psywavedamageeffect(void) { s32 randDamage; @@ -8476,7 +8501,7 @@ void atkA0_psywavedamageeffect(void) gBattlescriptCurrInstr++; } -void atkA1_counterdamagecalculator(void) +static void atkA1_counterdamagecalculator(void) { u8 sideAttacker = GetBankSide(gBankAttacker); u8 sideTarget = GetBankSide(gProtectStructs[gBankAttacker].physicalBank); @@ -8501,7 +8526,7 @@ void atkA1_counterdamagecalculator(void) } } -void atkA2_mirrorcoatdamagecalculator(void) // a copy of atkA1 with the physical -> special field changes +static void atkA2_mirrorcoatdamagecalculator(void) // a copy of atkA1 with the physical -> special field changes { u8 sideAttacker = GetBankSide(gBankAttacker); u8 sideTarget = GetBankSide(gProtectStructs[gBankAttacker].specialBank); @@ -8524,7 +8549,7 @@ void atkA2_mirrorcoatdamagecalculator(void) // a copy of atkA1 with the physical } } -void atkA3_disablelastusedattack(void) +static void atkA3_disablelastusedattack(void) { s32 i; @@ -8549,7 +8574,7 @@ void atkA3_disablelastusedattack(void) } } -void atkA4_setencore(void) +static void atkA4_setencore(void) { s32 i; @@ -8581,7 +8606,7 @@ void atkA4_setencore(void) } } -void atkA5_painsplitdmgcalc(void) +static void atkA5_painsplitdmgcalc(void) { if (!(gBattleMons[gBankTarget].status2 & STATUS2_SUBSTITUTE)) { @@ -8606,7 +8631,7 @@ void atkA5_painsplitdmgcalc(void) } #ifdef NONMATCHING -void atkA6_settypetorandomresistance(void) // conversion 2 +static void atkA6_settypetorandomresistance(void) // conversion 2 { if (gUnknown_02024250[gBankAttacker] == 0 || gUnknown_02024250[gBankAttacker] == 0xFFFF) @@ -8673,7 +8698,7 @@ void atkA6_settypetorandomresistance(void) // conversion 2 #else __attribute__((naked)) -void atkA6_settypetorandomresistance(void) // conversion 2 +static void atkA6_settypetorandomresistance(void) // conversion 2 { asm(".syntax unified\n\ push {r4-r7,lr}\n\ @@ -8912,7 +8937,7 @@ _08052D08:\n\ } #endif // NONMATCHING -void atkA7_setalwayshitflag(void) +static void atkA7_setalwayshitflag(void) { gStatuses3[gBankTarget] &= ~(STATUS3_ALWAYS_HITS); gStatuses3[gBankTarget] |= 0x10; @@ -8920,7 +8945,7 @@ void atkA7_setalwayshitflag(void) gBattlescriptCurrInstr++; } -void atkA8_copymovepermanently(void) // sketch +static void atkA8_copymovepermanently(void) // sketch { gLastUsedMove = 0xFFFF; @@ -8973,7 +8998,7 @@ void atkA8_copymovepermanently(void) // sketch } } -bool8 IsTwoTurnsMove(u16 move) +static bool8 IsTwoTurnsMove(u16 move) { if (gBattleMoves[move].effect == EFFECT_SKULL_BASH || gBattleMoves[move].effect == EFFECT_RAZOR_WIND @@ -8995,7 +9020,7 @@ static bool8 IsInvalidForSleepTalkOrAssist(u16 move) return FALSE; } -u8 AttacksThisTurn(u8 bank, u16 move) // Note: returns 1 if it's a charging turn, otherwise 2 +static u8 AttacksThisTurn(u8 bank, u16 move) // Note: returns 1 if it's a charging turn, otherwise 2 { // first argument is unused if (gBattleMoves[move].effect == EFFECT_SOLARBEAM @@ -9015,7 +9040,7 @@ u8 AttacksThisTurn(u8 bank, u16 move) // Note: returns 1 if it's a charging turn return 2; } -void atkA9_sleeptalk_choose_move(void) +static void atkA9_sleeptalk_choose_move(void) { s32 i; u8 unusableMovesBits = 0; @@ -9054,13 +9079,13 @@ void atkA9_sleeptalk_choose_move(void) } } -void atkAA_set_destinybond(void) +static void atkAA_set_destinybond(void) { gBattleMons[gBankAttacker].status2 |= STATUS2_DESTINY_BOND; gBattlescriptCurrInstr++; } -void DestinyBondFlagUpdate(void) +static void DestinyBondFlagUpdate(void) { u8 sideAttacker = GetBankSide(gBankAttacker); u8 sideTarget = GetBankSide(gBankTarget); @@ -9072,15 +9097,13 @@ void DestinyBondFlagUpdate(void) } } -void atkAB_DestinyBondFlagUpdate(void) +static void atkAB_DestinyBondFlagUpdate(void) { DestinyBondFlagUpdate(); gBattlescriptCurrInstr++; } -extern const u8 sFlailHpScaleToPowerTable[12]; - -void atkAC_remaininghptopower(void) +static void atkAC_remaininghptopower(void) { s32 i; s32 hpFraction = GetScaledHPFraction(gBattleMons[gBankAttacker].hp, gBattleMons[gBankAttacker].maxHP, 48); @@ -9095,7 +9118,7 @@ void atkAC_remaininghptopower(void) gBattlescriptCurrInstr++; } -void atkAD_spite_ppreduce(void) +static void atkAD_spite_ppreduce(void) { if (gLastUsedMovesByBanks[gBankTarget] != 0 && gLastUsedMovesByBanks[gBankTarget] != 0xFFFF) @@ -9146,7 +9169,7 @@ void atkAD_spite_ppreduce(void) } } -void atkAE_heal_party_status(void) +static void atkAE_heal_party_status(void) { u32 zero = 0; u8 toHeal = 0; @@ -9242,7 +9265,7 @@ void atkAE_heal_party_status(void) gBattlescriptCurrInstr++; } -void atkAF_cursetarget(void) +static void atkAF_cursetarget(void) { if (gBattleMons[gBankTarget].status2 & STATUS2_CURSED) { @@ -9259,7 +9282,7 @@ void atkAF_cursetarget(void) } } -void atkB0_set_spikes(void) +static void atkB0_set_spikes(void) { u8 targetSide = GetBankSide(gBankAttacker) ^ BIT_SIDE; @@ -9276,13 +9299,13 @@ void atkB0_set_spikes(void) } } -void atkB1_set_foresight(void) +static void atkB1_set_foresight(void) { gBattleMons[gBankTarget].status2 |= STATUS2_FORESIGHT; gBattlescriptCurrInstr++; } -void atkB2_setperishsong(void) +static void atkB2_setperishsong(void) { s32 i; s32 notAffectedCount = 0; @@ -9310,7 +9333,7 @@ void atkB2_setperishsong(void) gBattlescriptCurrInstr += 5; } -void atkB3_rolloutdamagecalculation(void) +static void atkB3_rolloutdamagecalculation(void) { if (gBattleMoveFlags & MOVESTATUS_NOEFFECT) { @@ -9345,7 +9368,7 @@ void atkB3_rolloutdamagecalculation(void) } } -void atkB4_jumpifconfusedandstatmaxed(void) +static void atkB4_jumpifconfusedandstatmaxed(void) { if (gBattleMons[gBankTarget].status2 & STATUS2_CONFUSION && gBattleMons[gBankTarget].statStages[gBattlescriptCurrInstr[1]] == 0xC) @@ -9354,7 +9377,7 @@ void atkB4_jumpifconfusedandstatmaxed(void) gBattlescriptCurrInstr += 6; } -void atkB5_furycuttercalc(void) +static void atkB5_furycuttercalc(void) { if (gBattleMoveFlags & MOVESTATUS_NOEFFECT) { @@ -9377,7 +9400,7 @@ void atkB5_furycuttercalc(void) } } -void atkB6_happinesstodamagecalculation(void) +static void atkB6_happinesstodamagecalculation(void) { if (gBattleMoves[gCurrentMove].effect == EFFECT_RETURN) gDynamicBasePower = 10 * (gBattleMons[gBankAttacker].friendship) / 25; @@ -9387,11 +9410,7 @@ void atkB6_happinesstodamagecalculation(void) gBattlescriptCurrInstr++; } -extern const u8 BattleScript_PresentDamageTarget[]; -extern const u8 BattleScript_AlreadyAtFullHp[]; -extern const u8 BattleScript_PresentHealTarget[]; - -void atkB7_presentdamagecalculation(void) +static void atkB7_presentdamagecalculation(void) { s32 rand = Random() & 0xFF; @@ -9419,7 +9438,7 @@ void atkB7_presentdamagecalculation(void) } } -void atkB8_set_safeguard(void) +static void atkB8_set_safeguard(void) { if (gSideAffecting[GET_BANK_SIDE(gBankAttacker)] & SIDE_STATUS_SAFEGUARD) { @@ -9437,7 +9456,7 @@ void atkB8_set_safeguard(void) gBattlescriptCurrInstr++; } -void atkB9_magnitudedamagecalculation(void) +static void atkB9_magnitudedamagecalculation(void) { s32 magnitude = Random() % 100; @@ -9491,7 +9510,7 @@ void atkB9_magnitudedamagecalculation(void) gBattlescriptCurrInstr++; } -void atkBA_jumpifnopursuitswitchdmg(void) +static void atkBA_jumpifnopursuitswitchdmg(void) { if (gMultiHitCounter == 1) { @@ -9535,7 +9554,7 @@ void atkBA_jumpifnopursuitswitchdmg(void) } } -void atkBB_setsunny(void) +static void atkBB_setsunny(void) { if (gBattleWeather & WEATHER_SUN_ANY) { @@ -9552,7 +9571,7 @@ void atkBB_setsunny(void) gBattlescriptCurrInstr++; } -void atkBC_maxattackhalvehp(void) // belly drum +static void atkBC_maxattackhalvehp(void) // belly drum { u32 halfHp = gBattleMons[gBankAttacker].maxHP / 2; @@ -9575,7 +9594,7 @@ void atkBC_maxattackhalvehp(void) // belly drum } } -void atkBD_copyfoestats(void) // psych up +static void atkBD_copyfoestats(void) // psych up { s32 i; @@ -9587,11 +9606,7 @@ void atkBD_copyfoestats(void) // psych up gBattlescriptCurrInstr += 5; // Has an unused jump ptr(possibly for a failed attempt) parameter. } -extern const u8 BattleScript_WrapFree[]; -extern const u8 BattleScript_LeechSeedFree[]; -extern const u8 BattleScript_SpikesFree[]; - -void atkBE_rapidspinfree(void) +static void atkBE_rapidspinfree(void) { if (gBattleMons[gBankAttacker].status2 & STATUS2_WRAPPED) { @@ -9628,13 +9643,13 @@ void atkBE_rapidspinfree(void) } } -void atkBF_set_defense_curl(void) +static void atkBF_set_defense_curl(void) { gBattleMons[gBankAttacker].status2 |= STATUS2_DEFENSE_CURL; gBattlescriptCurrInstr++; } -void atkC0_recoverbasedonsunlight(void) +static void atkC0_recoverbasedonsunlight(void) { gBankTarget = gBankAttacker; @@ -9660,7 +9675,7 @@ void atkC0_recoverbasedonsunlight(void) } #ifdef NONMATCHING -void atkC1_hidden_power(void) +static void atkC1_hidden_power(void) { s32 powerBits; s32 typeBits; @@ -9691,7 +9706,7 @@ void atkC1_hidden_power(void) #else __attribute__((naked)) -void atkC1_hidden_power(void) +static void atkC1_hidden_power(void) { asm(".syntax unified\n\ push {r4-r7,lr}\n\ @@ -9834,7 +9849,7 @@ _080544F0:\n\ } #endif // NONMATCHING -void atkC2_selectnexttarget(void) +static void atkC2_selectnexttarget(void) { for (gBankTarget = 0; gBankTarget < gNoOfAllBanks; gBankTarget++) { @@ -9846,7 +9861,7 @@ void atkC2_selectnexttarget(void) gBattlescriptCurrInstr++; } -void atkC3_setfutureattack(void) +static void atkC3_setfutureattack(void) { if (gWishFutureKnock.futureSightCounter[gBankTarget] != 0) { @@ -9874,7 +9889,7 @@ void atkC3_setfutureattack(void) } } -void atkC4_beat_up(void) +static void atkC4_beat_up(void) { struct Pokemon* party; @@ -9921,7 +9936,7 @@ void atkC4_beat_up(void) } } -void atkC5_setsemiinvulnerablebit(void) +static void atkC5_setsemiinvulnerablebit(void) { switch (gCurrentMove) { @@ -9940,7 +9955,7 @@ void atkC5_setsemiinvulnerablebit(void) gBattlescriptCurrInstr++; } -void atkC6_clearsemiinvulnerablebit(void) +static void atkC6_clearsemiinvulnerablebit(void) { switch (gCurrentMove) { @@ -9959,7 +9974,7 @@ void atkC6_clearsemiinvulnerablebit(void) gBattlescriptCurrInstr++; } -void atkC7_setminimize(void) +static void atkC7_setminimize(void) { if (gHitMarker & HITMARKER_OBEYS) gStatuses3[gBankAttacker] |= STATUS3_MINIMIZED; @@ -9967,7 +9982,7 @@ void atkC7_setminimize(void) gBattlescriptCurrInstr++; } -void atkC8_sethail(void) +static void atkC8_sethail(void) { if (gBattleWeather & WEATHER_HAIL_ANY) { @@ -9984,7 +9999,7 @@ void atkC8_sethail(void) gBattlescriptCurrInstr++; } -void atkC9_jumpifattackandspecialattackcannotfall(void) // memento +static void atkC9_jumpifattackandspecialattackcannotfall(void) // memento { if (gBattleMons[gBankTarget].statStages[STAT_STAGE_ATK] == 0 && gBattleMons[gBankTarget].statStages[STAT_STAGE_SPATK] == 0 @@ -10002,14 +10017,14 @@ void atkC9_jumpifattackandspecialattackcannotfall(void) // memento } } -void atkCA_setforcedtarget(void) // follow me +static void atkCA_setforcedtarget(void) // follow me { gSideTimers[GetBankSide(gBankAttacker)].followmeTimer = 1; gSideTimers[GetBankSide(gBankAttacker)].followmeTarget = gBankAttacker; gBattlescriptCurrInstr++; } -void atkCB_setcharge(void) +static void atkCB_setcharge(void) { gStatuses3[gBankAttacker] |= STATUS3_CHARGED_UP; gDisableStructs[gBankAttacker].chargeTimer1 = 2; @@ -10017,7 +10032,7 @@ void atkCB_setcharge(void) gBattlescriptCurrInstr++; } -void atkCC_callterrainattack(void) // nature power +static void atkCC_callterrainattack(void) // nature power { gHitMarker &= ~(HITMARKER_ATTACKSTRING_PRINTED); gCurrentMove = sNaturePowerMoves[gBattleTerrain]; @@ -10026,7 +10041,7 @@ void atkCC_callterrainattack(void) // nature power gBattlescriptCurrInstr++; } -void atkCD_cureifburnedparalysedorpoisoned(void) // refresh +static void atkCD_cureifburnedparalysedorpoisoned(void) // refresh { if (gBattleMons[gBankAttacker].status1 & (STATUS_POISON | STATUS_BURN | STATUS_PARALYSIS | STATUS_TOXIC_POISON)) { @@ -10042,7 +10057,7 @@ void atkCD_cureifburnedparalysedorpoisoned(void) // refresh } } -void atkCE_settorment(void) +static void atkCE_settorment(void) { if (gBattleMons[gBankTarget].status2 & STATUS2_TORMENT) { @@ -10055,7 +10070,7 @@ void atkCE_settorment(void) } } -void atkCF_jumpifnodamage(void) +static void atkCF_jumpifnodamage(void) { if (gProtectStructs[gBankAttacker].physicalDmg || gProtectStructs[gBankAttacker].specialDmg) gBattlescriptCurrInstr += 5; @@ -10063,7 +10078,7 @@ void atkCF_jumpifnodamage(void) gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); } -void atkD0_settaunt(void) +static void atkD0_settaunt(void) { if (gDisableStructs[gBankTarget].tauntTimer1 == 0) { @@ -10077,7 +10092,7 @@ void atkD0_settaunt(void) } } -void atkD1_set_helpinghand(void) +static void atkD1_set_helpinghand(void) { gBankTarget = GetBankByIdentity(GetBankIdentity(gBankAttacker) ^ BIT_MON); @@ -10095,7 +10110,7 @@ void atkD1_set_helpinghand(void) } } -void atkD2_swap_items(void) // trick +static void atkD2_swap_items(void) // trick { // opponent can't swap items with player in regular battles if (gBattleTypeFlags & BATTLE_TYPE_x4000000 @@ -10182,7 +10197,7 @@ void atkD2_swap_items(void) // trick } } -void atkD3_copy_ability(void) // role play +static void atkD3_copy_ability(void) // role play { if (gBattleMons[gBankTarget].ability != 0 && gBattleMons[gBankTarget].ability != ABILITY_WONDER_GUARD) @@ -10197,9 +10212,9 @@ void atkD3_copy_ability(void) // role play } } -void atkD4_wish_effect(void) +static void atkD4_wish_effect(void) { - switch (BSScriptRead8(gBattlescriptCurrInstr + 1)) + switch (gBattlescriptCurrInstr[1]) { case 0: // use wish if (gWishFutureKnock.wishCounter[gBankAttacker] == 0) @@ -10230,7 +10245,7 @@ void atkD4_wish_effect(void) } } -void atkD5_setroots(void) // ingrain +static void atkD5_setroots(void) // ingrain { if (gStatuses3[gBankAttacker] & STATUS3_ROOTED) { @@ -10243,7 +10258,7 @@ void atkD5_setroots(void) // ingrain } } -void atkD6_doubledamagedealtifdamaged(void) +static void atkD6_doubledamagedealtifdamaged(void) { if ((gProtectStructs[gBankAttacker].physicalDmg && gProtectStructs[gBankAttacker].physicalBank == gBankTarget) @@ -10256,7 +10271,7 @@ void atkD6_doubledamagedealtifdamaged(void) gBattlescriptCurrInstr++; } -void atkD7_setyawn(void) +static void atkD7_setyawn(void) { if (gStatuses3[gBankTarget] & STATUS3_YAWN || gBattleMons[gBankTarget].status1 & STATUS_ANY) @@ -10270,7 +10285,7 @@ void atkD7_setyawn(void) } } -void atkD8_setdamagetohealthdifference(void) +static void atkD8_setdamagetohealthdifference(void) { if (gBattleMons[gBankTarget].hp <= gBattleMons[gBankAttacker].hp) { @@ -10283,7 +10298,7 @@ void atkD8_setdamagetohealthdifference(void) } } -void atkD9_scaledamagebyhealthratio(void) +static void atkD9_scaledamagebyhealthratio(void) { if (gDynamicBasePower == 0) { @@ -10295,7 +10310,7 @@ void atkD9_scaledamagebyhealthratio(void) gBattlescriptCurrInstr++; } -void atkDA_abilityswap(void) // skill swap +static void atkDA_abilityswap(void) // skill swap { if ((gBattleMons[gBankAttacker].ability == 0 && gBattleMons[gBankTarget].ability == 0) @@ -10315,7 +10330,7 @@ void atkDA_abilityswap(void) // skill swap } } -void atkDB_imprisoneffect(void) +static void atkDB_imprisoneffect(void) { if ((gStatuses3[gBankAttacker] & STATUS3_IMPRISONED_OTHERS)) { @@ -10357,7 +10372,7 @@ void atkDB_imprisoneffect(void) } } -void atkDC_setgrudge(void) +static void atkDC_setgrudge(void) { if (gStatuses3[gBankAttacker] & STATUS3_GRUDGE) { @@ -10370,7 +10385,7 @@ void atkDC_setgrudge(void) } } -void atkDD_weightdamagecalculation(void) +static void atkDD_weightdamagecalculation(void) { s32 i; for (i = 0; sWeightToDamageTable[i] != 0xFFFF; i += 2) @@ -10387,7 +10402,7 @@ void atkDD_weightdamagecalculation(void) gBattlescriptCurrInstr++; } -void atkDE_asistattackselect(void) +static void atkDE_asistattackselect(void) { s32 chooseableMovesNo = 0; struct Pokemon* party; @@ -10440,7 +10455,7 @@ void atkDE_asistattackselect(void) } } -void atkDF_setmagiccoat(void) +static void atkDF_setmagiccoat(void) { gBankTarget = gBankAttacker; gSpecialStatuses[gBankAttacker].flag20 = 1; @@ -10455,7 +10470,7 @@ void atkDF_setmagiccoat(void) } } -void atkE0_setstealstatchange(void) // snatch +static void atkE0_setstealstatchange(void) // snatch { gSpecialStatuses[gBankAttacker].flag20 = 1; if (gCurrentMoveTurn == gNoOfAllBanks - 1) // moves last turn @@ -10469,7 +10484,7 @@ void atkE0_setstealstatchange(void) // snatch } } -void atkE1_intimidate_string_loader(void) +static void atkE1_intimidate_string_loader(void) { u8 side; @@ -10492,9 +10507,9 @@ void atkE1_intimidate_string_loader(void) gBattlescriptCurrInstr += 5; } -void atkE2_switchout_abilities(void) +static void atkE2_switchout_abilities(void) { - gActiveBank = GetBattleBank(BSScriptRead8(gBattlescriptCurrInstr + 1)); + gActiveBank = GetBattleBank(gBattlescriptCurrInstr[1]); switch (gBattleMons[gActiveBank].ability) { @@ -10508,9 +10523,9 @@ void atkE2_switchout_abilities(void) gBattlescriptCurrInstr += 2; } -void atkE3_jumpifhasnohp(void) +static void atkE3_jumpifhasnohp(void) { - gActiveBank = GetBattleBank(BSScriptRead8(gBattlescriptCurrInstr + 1)); + gActiveBank = GetBattleBank(gBattlescriptCurrInstr[1]); if (gBattleMons[gActiveBank].hp == 0) gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 2); @@ -10518,7 +10533,7 @@ void atkE3_jumpifhasnohp(void) gBattlescriptCurrInstr += 6; } -void atkE4_getsecretpowereffect(void) +static void atkE4_getsecretpowereffect(void) { switch (gBattleTerrain) { @@ -10553,15 +10568,7 @@ void atkE4_getsecretpowereffect(void) gBattlescriptCurrInstr++; } -extern bool8 InBattlePike(void); -extern bool8 InBattlePyramid(void); -extern u16 GetBattlePyramidPickupItemId(void); - -extern const u16 gRarePickupItems[]; -extern const u16 gPickupItems[]; -extern const u8 gPickupProbabilities[]; - -void atkE5_pickup(void) +static void atkE5_pickup(void) { if (!InBattlePike()) { @@ -10636,3 +10643,600 @@ void atkE5_pickup(void) gBattlescriptCurrInstr++; } + +static void atkE6_castform_change_animation(void) +{ + gActiveBank = gBattleScripting.bank; + + if (gBattleMons[gActiveBank].status2 & STATUS2_SUBSTITUTE) + *(&gBattleStruct->formToChangeInto) |= 0x80; + + EmitBattleAnimation(0, B_ANIM_CASTFORM_CHANGE, gBattleStruct->formToChangeInto); + MarkBufferBankForExecution(gActiveBank); + + gBattlescriptCurrInstr++; +} + +static void atkE7_castform_data_change(void) +{ + u8 form; + + gBattlescriptCurrInstr++; + form = CastformDataTypeChange(gBattleScripting.bank); + if (form) + { + BattleScriptPushCursorAndCallback(BattleScript_CastformChange); + *(&gBattleStruct->formToChangeInto) = form - 1; + } +} + +static void atkE8_settypebasedhalvers(void) // water and mud sport +{ + bool8 worked = FALSE; + + if (gBattleMoves[gCurrentMove].effect == EFFECT_MUD_SPORT) + { + if (!(gStatuses3[gBankAttacker] & STATUS3_MUDSPORT)) + { + gStatuses3[gBankAttacker] |= STATUS3_MUDSPORT; + gBattleCommunication[MULTISTRING_CHOOSER] = 0; + worked = TRUE; + } + } + else // water sport + { + if (!(gStatuses3[gBankAttacker] & STATUS3_WATERSPORT)) + { + gStatuses3[gBankAttacker] |= STATUS3_WATERSPORT; + gBattleCommunication[MULTISTRING_CHOOSER] = 1; + worked = TRUE; + } + } + + if (worked) + gBattlescriptCurrInstr += 5; + else + gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); +} + +static void atkE9_setweatherballtype(void) +{ + if (WEATHER_HAS_EFFECT) + { + if (gBattleWeather & WEATHER_ANY) + gBattleScripting.dmgMultiplier = 2; + if (gBattleWeather & WEATHER_RAIN_ANY) + *(&gBattleStruct->dynamicMoveType) = TYPE_WATER | 0x80; + else if (gBattleWeather & WEATHER_SANDSTORM_ANY) + *(&gBattleStruct->dynamicMoveType) = TYPE_ROCK | 0x80; + else if (gBattleWeather & WEATHER_SUN_ANY) + *(&gBattleStruct->dynamicMoveType) = TYPE_FIRE | 0x80; + else if (gBattleWeather & WEATHER_HAIL_ANY) + *(&gBattleStruct->dynamicMoveType) = TYPE_ICE | 0x80; + else + *(&gBattleStruct->dynamicMoveType) = TYPE_NORMAL | 0x80; + } + + gBattlescriptCurrInstr++; +} + +static void atkEA_recycleitem(void) +{ + u16 *usedHeldItem; + + gActiveBank = gBankAttacker; + usedHeldItem = &gBattleStruct->usedHeldItems[gActiveBank]; + if (*usedHeldItem != 0 && gBattleMons[gActiveBank].item == 0) + { + gLastUsedItem = *usedHeldItem; + *usedHeldItem = 0; + gBattleMons[gActiveBank].item = gLastUsedItem; + + EmitSetMonData(0, REQUEST_HELDITEM_BATTLE, 0, 2, &gBattleMons[gActiveBank].item); + MarkBufferBankForExecution(gActiveBank); + + gBattlescriptCurrInstr += 5; + } + else + { + gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); + } +} + +static void atkEB_settypetoterrain(void) +{ + if (gBattleMons[gBankAttacker].type1 != sTerrainToType[gBattleTerrain] + && gBattleMons[gBankAttacker].type2 != sTerrainToType[gBattleTerrain]) + { + gBattleMons[gBankAttacker].type1 = sTerrainToType[gBattleTerrain]; + gBattleMons[gBankAttacker].type2 = sTerrainToType[gBattleTerrain]; + + PREPARE_TYPE_BUFFER(gBattleTextBuff1, sTerrainToType[gBattleTerrain]) + + gBattlescriptCurrInstr += 5; + } + else + { + gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); + } +} + +static void atkEC_pursuit_sth(void) +{ + gActiveBank = GetBankByIdentity(GetBankIdentity(gBankAttacker) ^ BIT_MON); + + if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE + && !(gAbsentBankFlags & gBitTable[gActiveBank]) + && gActionForBanks[gActiveBank] == 0 + && gChosenMovesByBanks[gActiveBank] == MOVE_PURSUIT) + { + gUnknown_0202407A[gActiveBank] = 11; + gCurrentMove = MOVE_PURSUIT; + gBattlescriptCurrInstr += 5; + gBattleScripting.animTurn = 1; + gBattleScripting.field_20 = gBankAttacker; + gBankAttacker = gActiveBank; + } + else + { + gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); + } +} + +static void atkED_802B4B4(void) +{ + gEffectBank = gBankAttacker; + + if (gBankAttacker == gBankTarget) + gBankAttacker = gBankTarget = gBattleScripting.bank; + else + gBankTarget = gBattleScripting.bank; + + gBattleScripting.bank = gEffectBank; + gBattlescriptCurrInstr++; +} + +static void atkEE_removelightscreenreflect(void) // brick break +{ + u8 opposingSide = GetBankSide(gBankAttacker) ^ BIT_SIDE; + + if (gSideTimers[opposingSide].reflectTimer || gSideTimers[opposingSide].lightscreenTimer) + { + gSideAffecting[opposingSide] &= ~(SIDE_STATUS_REFLECT); + gSideAffecting[opposingSide] &= ~(SIDE_STATUS_LIGHTSCREEN); + gSideTimers[opposingSide].reflectTimer = 0; + gSideTimers[opposingSide].lightscreenTimer = 0; + gBattleScripting.animTurn = 1; + gBattleScripting.animTargetsHit = 1; + } + else + { + gBattleScripting.animTurn = 0; + gBattleScripting.animTargetsHit = 0; + } + + gBattlescriptCurrInstr++; +} + +static void atkEF_pokeball_catch_calculation(void) +{ + u8 ballMultiplier = 0; + + if (gBattleExecBuffer) + return; + + gActiveBank = gBankAttacker; + gBankTarget = gBankAttacker ^ BIT_SIDE; + + if (gBattleTypeFlags & BATTLE_TYPE_TRAINER) + { + EmitBallThrow(0, BALL_TRAINER_BLOCK); + MarkBufferBankForExecution(gActiveBank); + gBattlescriptCurrInstr = BattleScript_TrainerBallBlock; + } + else if (gBattleTypeFlags & BATTLE_TYPE_WALLY_TUTORIAL) + { + EmitBallThrow(0, BALL_3_SHAKES_SUCCESS); + MarkBufferBankForExecution(gActiveBank); + gBattlescriptCurrInstr = BattleScript_WallyBallThrow; + } + else + { + u32 odds; + u8 catchRate; + + if (gLastUsedItem == ITEM_SAFARI_BALL) + catchRate = gBattleStruct->field_7C * 1275 / 100; + else + catchRate = gBaseStats[gBattleMons[gBankTarget].species].catchRate; + + if (gLastUsedItem > ITEM_SAFARI_BALL) + { + switch (gLastUsedItem) + { + case ITEM_NET_BALL: + if (gBattleMons[gBankTarget].type1 == TYPE_WATER + || gBattleMons[gBankTarget].type2 == TYPE_WATER + || gBattleMons[gBankTarget].type1 == TYPE_BUG + || gBattleMons[gBankTarget].type2 == TYPE_BUG) + ballMultiplier = 30; + else + ballMultiplier = 10; + break; + case ITEM_DIVE_BALL: + if (sav1_map_get_light_level() == 5) + ballMultiplier = 35; + else + ballMultiplier = 10; + break; + case ITEM_NEST_BALL: + if (gBattleMons[gBankTarget].level <= 39) + { + ballMultiplier = 40 - gBattleMons[gBankTarget].level; + if (ballMultiplier <= 9) + ballMultiplier = 10; + } + else + { + ballMultiplier = 10; + } + break; + case ITEM_REPEAT_BALL: + if (GetSetPokedexFlag(SpeciesToNationalPokedexNum(gBattleMons[gBankTarget].species), FLAG_GET_CAUGHT)) + ballMultiplier = 30; + else + ballMultiplier = 10; + break; + case ITEM_TIMER_BALL: + ballMultiplier = gBattleResults.battleTurnCounter + 10; + if (ballMultiplier > 40) + ballMultiplier = 40; + break; + case ITEM_LUXURY_BALL: + case ITEM_PREMIER_BALL: + ballMultiplier = 10; + break; + } + } + else + ballMultiplier = sBallCatchBonuses[gLastUsedItem - 2]; + + odds = (catchRate * ballMultiplier / 10) + * (gBattleMons[gBankTarget].maxHP * 3 - gBattleMons[gBankTarget].hp * 2) + / (3 * gBattleMons[gBankTarget].maxHP); + + if (gBattleMons[gBankTarget].status1 & (STATUS_SLEEP | STATUS_FREEZE)) + odds *= 2; + if (gBattleMons[gBankTarget].status1 & (STATUS_POISON | STATUS_BURN | STATUS_PARALYSIS | STATUS_TOXIC_POISON)) + odds = (odds * 15) / 10; + + if (gLastUsedItem != ITEM_SAFARI_BALL) + { + if (gLastUsedItem == ITEM_MASTER_BALL) + { + gBattleResults.unk5_1 = 1; + } + else + { + if (gBattleResults.catchAttempts[gLastUsedItem - ITEM_ULTRA_BALL] < 0xFF) + gBattleResults.catchAttempts[gLastUsedItem - ITEM_ULTRA_BALL]++; + } + } + + if (odds > 254) // mon caught + { + EmitBallThrow(0, BALL_3_SHAKES_SUCCESS); + MarkBufferBankForExecution(gActiveBank); + gBattlescriptCurrInstr = BattleScript_SuccessBallThrow; + SetMonData(&gEnemyParty[gBattlePartyID[gBankTarget]], MON_DATA_POKEBALL, &gLastUsedItem); + + if (CalculatePlayerPartyCount() == 6) + gBattleCommunication[MULTISTRING_CHOOSER] = 0; + else + gBattleCommunication[MULTISTRING_CHOOSER] = 1; + } + else // mon may be caught, calculate shakes + { + u8 shakes; + + odds = Sqrt(Sqrt(16711680 / odds)); + odds = 1048560 / odds; + + for (shakes = 0; shakes < 4 && Random() < odds; shakes++); + + if (gLastUsedItem == ITEM_MASTER_BALL) + shakes = BALL_3_SHAKES_SUCCESS; // why calculate the shakes before that check? + + EmitBallThrow(0, shakes); + MarkBufferBankForExecution(gActiveBank); + + if (shakes == BALL_3_SHAKES_SUCCESS) // mon caught, copy of the code above + { + gBattlescriptCurrInstr = BattleScript_SuccessBallThrow; + SetMonData(&gEnemyParty[gBattlePartyID[gBankTarget]], MON_DATA_POKEBALL, &gLastUsedItem); + + if (CalculatePlayerPartyCount() == 6) + gBattleCommunication[MULTISTRING_CHOOSER] = 0; + else + gBattleCommunication[MULTISTRING_CHOOSER] = 1; + } + else // not caught + { + gBattleCommunication[MULTISTRING_CHOOSER] = shakes; + gBattlescriptCurrInstr = BattleScript_ShakeBallThrow; + } + } + } +} + +static void atkF0_give_caught_mon(void) +{ + if (GiveMonToPlayer(&gEnemyParty[gBattlePartyID[gBankAttacker ^ BIT_SIDE]]) != MON_GIVEN_TO_PARTY) + { + if (!sub_813B21C()) + { + gBattleCommunication[MULTISTRING_CHOOSER] = 0; + StringCopy(gStringVar1, GetBoxNamePtr(VarGet(VAR_STORAGE_UNKNOWN))); + GetMonData(&gEnemyParty[gBattlePartyID[gBankAttacker ^ BIT_SIDE]], MON_DATA_NICKNAME, gStringVar2); + } + else + { + StringCopy(gStringVar1, GetBoxNamePtr(VarGet(VAR_STORAGE_UNKNOWN))); + GetMonData(&gEnemyParty[gBattlePartyID[gBankAttacker ^ BIT_SIDE]], MON_DATA_NICKNAME, gStringVar2); + StringCopy(gStringVar3, GetBoxNamePtr(get_unknown_box_id())); + gBattleCommunication[MULTISTRING_CHOOSER] = 2; + } + + if (FlagGet(SYS_PC_LANETTE)) + gBattleCommunication[MULTISTRING_CHOOSER]++; + } + + gBattleResults.caughtMonSpecies = GetMonData(&gEnemyParty[gBattlePartyID[gBankAttacker ^ BIT_SIDE]], MON_DATA_SPECIES, NULL); + GetMonData(&gEnemyParty[gBattlePartyID[gBankAttacker ^ BIT_SIDE]], MON_DATA_NICKNAME, gBattleResults.caughtMonNick); + gBattleResults.caughtMonBall = GetMonData(&gEnemyParty[gBattlePartyID[gBankAttacker ^ BIT_SIDE]], MON_DATA_POKEBALL, NULL); + + gBattlescriptCurrInstr++; +} + +static void atkF1_set_caught_mon_dex_flags(void) +{ + u16 species = GetMonData(&gEnemyParty[0], MON_DATA_SPECIES, NULL); + u32 personality = GetMonData(&gEnemyParty[0], MON_DATA_PERSONALITY, NULL); + + if (GetSetPokedexFlag(SpeciesToNationalPokedexNum(species), FLAG_GET_CAUGHT)) + { + gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); + } + else + { + HandleSetPokedexFlag(SpeciesToNationalPokedexNum(species), FLAG_SET_CAUGHT, personality); + gBattlescriptCurrInstr += 5; + } +} + +static void atkF2_display_dex_info(void) +{ + u16 species = GetMonData(&gEnemyParty[0], MON_DATA_SPECIES, NULL); + + switch (gBattleCommunication[0]) + { + case 0: + BeginNormalPaletteFade(-1, 0, 0, 0x10, 0); + gBattleCommunication[0]++; + break; + case 1: + if (!gPaletteFade.active) + { + FreeAllWindowBuffers(); + gBattleCommunication[TASK_ID] = CreateDexDisplayMonDataTask(SpeciesToNationalPokedexNum(species), + gBattleMons[gBankTarget].otId, + gBattleMons[gBankTarget].personality); + gBattleCommunication[0]++; + } + break; + case 2: + if (!gPaletteFade.active + && gMain.callback2 == BattleMainCB2 + && !gTasks[gBattleCommunication[TASK_ID]].isActive) + { + SetVBlankCallback(VBlankCB_Battle); + gBattleCommunication[0]++; + } + break; + case 3: + c2_berry_program_update_menu(); + sub_8035AA4(); + gBattle_BG3_X = 0x100; + gBattleCommunication[0]++; + break; + case 4: + if (!IsDma3ManagerBusyWithBgCopy()) + { + BeginNormalPaletteFade(0xFFFF, 0, 0x10, 0, 0); + ShowBg(0); + ShowBg(3); + gBattleCommunication[0]++; + } + break; + case 5: + if (!gPaletteFade.active) + gBattlescriptCurrInstr++; + break; + } +} + +void sub_8056A3C(u8 xStart, u8 yStart, u8 xEnd, u8 yEnd, u8 flags) +{ + s32 destY, destX; + u16 var = 0; + + for (destY = yStart; destY <= yEnd; destY++) + { + for (destX = xStart; destX <= xEnd; destX++) + { + if (destY == yStart) + { + if (destX == xStart) + var = 0x1022; + else if (destX == xEnd) + var = 0x1024; + else + var = 0x1023; + } + else if (destY == yEnd) + { + if (destX == xStart) + var = 0x1028; + else if (destX == xEnd) + var = 0x102A; + else + var = 0x1029; + } + else + { + if (destX == xStart) + var = 0x1025; + else if (destX == xEnd) + var = 0x1027; + else + var = 0x1026; + } + + if (flags & 1) + var = 0; + + if (flags & 0x80) + CopyToBgTilemapBufferRect_ChangePalette(1, &var, destX, destY, 1, 1, 0x11); + else + CopyToBgTilemapBufferRect_ChangePalette(0, &var, destX, destY, 1, 1, 0x11); + } + } +} + +void BattleCreateCursorAt(u8 cursorPosition) +{ + u16 src[2]; + src[0] = 1; + src[1] = 2; + + CopyToBgTilemapBufferRect_ChangePalette(0, src, 0x19, 9 + (2 * cursorPosition), 1, 2, 0x11); + CopyBgTilemapBufferToVram(0); +} + +void BattleDestroyCursorAt(u8 cursorPosition) +{ + u16 src[2]; + src[0] = 0x1016; + src[1] = 0x1016; + + CopyToBgTilemapBufferRect_ChangePalette(0, src, 0x19, 9 + (2 * cursorPosition), 1, 2, 0x11); + CopyBgTilemapBufferToVram(0); +} + +static void atkF3_nickname_caught_poke(void) +{ + switch (gBattleCommunication[MULTIUSE_STATE]) + { + case 0: + sub_8056A3C(0x18, 8, 0x1D, 0xD, 0); + sub_814F9EC(gText_BattleYesNoChoice, 0xC); + gBattleCommunication[MULTIUSE_STATE]++; + gBattleCommunication[CURSOR_POSITION] = 0; + BattleCreateCursorAt(0); + break; + case 1: + if (gMain.newKeys & DPAD_UP && gBattleCommunication[CURSOR_POSITION] != 0) + { + PlaySE(SE_SELECT); + BattleDestroyCursorAt(gBattleCommunication[CURSOR_POSITION]); + gBattleCommunication[CURSOR_POSITION] = 0; + BattleCreateCursorAt(0); + } + if (gMain.newKeys & DPAD_DOWN && gBattleCommunication[CURSOR_POSITION] == 0) + { + PlaySE(SE_SELECT); + BattleDestroyCursorAt(gBattleCommunication[CURSOR_POSITION]); + gBattleCommunication[CURSOR_POSITION] = 1; + BattleCreateCursorAt(1); + } + if (gMain.newKeys & A_BUTTON) + { + PlaySE(SE_SELECT); + if (gBattleCommunication[CURSOR_POSITION] == 0) + { + gBattleCommunication[MULTIUSE_STATE]++; + BeginFastPaletteFade(3); + } + else + { + gBattleCommunication[MULTIUSE_STATE] = 4; + } + } + else if (gMain.newKeys & B_BUTTON) + { + PlaySE(SE_SELECT); + gBattleCommunication[MULTIUSE_STATE] = 4; + } + break; + case 2: + if (!gPaletteFade.active) + { + GetMonData(&gEnemyParty[gBattlePartyID[gBankAttacker ^ BIT_SIDE]], MON_DATA_NICKNAME, gBattleStruct->caughtMonNick); + FreeAllWindowBuffers(); + + DoNamingScreen(NAMING_SCREEN_CAUGHT_MON, gBattleStruct->caughtMonNick, + GetMonData(&gEnemyParty[gBattlePartyID[gBankAttacker ^ BIT_SIDE]], MON_DATA_SPECIES), + GetMonGender(&gEnemyParty[gBattlePartyID[gBankAttacker ^ BIT_SIDE]]), + GetMonData(&gEnemyParty[gBattlePartyID[gBankAttacker ^ BIT_SIDE]], MON_DATA_PERSONALITY, NULL), + BattleMainCB2); + + gBattleCommunication[MULTIUSE_STATE]++; + } + break; + case 3: + if (gMain.callback2 == BattleMainCB2 && !gPaletteFade.active ) + { + SetMonData(&gEnemyParty[gBattlePartyID[gBankAttacker ^ BIT_SIDE]], MON_DATA_NICKNAME, gBattleStruct->caughtMonNick); + gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); + } + break; + case 4: + if (CalculatePlayerPartyCount() == 6) + gBattlescriptCurrInstr += 5; + else + gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); + break; + } +} + +static void atkF4_subattackerhpbydmg(void) +{ + gBattleMons[gBankAttacker].hp -= gBattleMoveDamage; + gBattlescriptCurrInstr++; +} + +static void atkF5_removeattackerstatus1(void) +{ + gBattleMons[gBankAttacker].status1 = 0; + gBattlescriptCurrInstr++; +} + +static void atkF6_802BF48(void) +{ + gFightStateTracker = 0xC; +} + +static void atkF7_802BF54(void) +{ + gFightStateTracker = 0xC; + gCurrentMoveTurn = gNoOfAllBanks; +} + +static void atkF8_trainer_slide_back(void) +{ + gActiveBank = GetBankByIdentity(gBattlescriptCurrInstr[1]); + EmitTrainerSlideBack(0); + MarkBufferBankForExecution(gActiveBank); + + gBattlescriptCurrInstr += 2; +} diff --git a/sym_ewram.txt b/sym_ewram.txt index 227f83385..fa655f5ea 100644 --- a/sym_ewram.txt +++ b/sym_ewram.txt @@ -223,7 +223,7 @@ gBattle_BG2_X: @ 2022E1C gBattle_BG2_Y: @ 2022E1E .space 0x2 -gUnknown_02022E20: @ 2022E20 +gBattle_BG3_X: @ 2022E20 .space 0x2 gUnknown_02022E22: @ 2022E22