From d769ec137447c52062b48153851bd2824055b6df Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Tue, 26 Sep 2017 22:39:59 +0200 Subject: [PATCH] battle 4 up to a8 --- asm/battle_1.s | 20 +- asm/battle_2.s | 124 +- asm/battle_4.s | 7498 +----------------------- asm/battle_5.s | 8 +- asm/battle_7.s | 18 +- asm/battle_9.s | 34 +- asm/battle_anim.s | 34 +- asm/battle_anim_80D51AC.s | 2 +- asm/battle_anim_80FE840.s | 202 +- asm/battle_anim_815A0D4.s | 66 +- asm/battle_anim_8170478.s | 26 +- asm/battle_controller_opponent.s | 14 +- asm/battle_controller_player.s | 18 +- asm/battle_controller_player_partner.s | 8 +- asm/battle_controller_safari.s | 6 +- asm/battle_controller_wally.s | 6 +- asm/battle_frontier_1.s | 164 +- asm/battle_frontier_2.s | 8 +- asm/battle_message.s | 24 +- asm/contest.s | 56 +- asm/contest_link_80F57C4.s | 18 +- asm/evolution_scene.s | 114 +- asm/menu.s | 4 +- asm/party_menu.s | 12 +- asm/pokeball.s | 14 +- asm/pokemon_icon.s | 16 +- asm/pokemon_item_effect.s | 2 +- asm/pokemon_storage_system.s | 2 +- asm/reshow_battle_screen.s | 12 +- asm/rom3.s | 30 +- asm/rom_80A5C6C.s | 24 +- asm/title_screen.s | 6 +- asm/unknown_task.s | 8 +- data/battle_4.s | 51 +- data/battle_scripts_1.s | 38 +- include/battle.h | 108 +- include/battle_controllers.h | 29 +- include/battle_message.h | 29 +- include/moves.h | 4 +- include/pokemon.h | 7 +- include/pokemon_icon.h | 7 + include/pokemon_item_effects.h | 8 + include/text.h | 38 +- include/window.h | 2 +- src/battle_3.c | 52 +- src/battle_4.c | 2739 ++++++++- src/battle_ai.c | 2 +- src/calculate_base_damage.c | 1 - src/pokemon_2.c | 10 +- src/pokemon_3.c | 6 +- src/window.c | 2 +- sym_ewram.txt | 8 +- 52 files changed, 3497 insertions(+), 8242 deletions(-) create mode 100644 include/pokemon_icon.h create mode 100644 include/pokemon_item_effects.h diff --git a/asm/battle_1.s b/asm/battle_1.s index 3507f6a71..e74d12046 100644 --- a/asm/battle_1.s +++ b/asm/battle_1.s @@ -2236,7 +2236,7 @@ _08035F64: ldrsh r0, [r5, r1] cmp r0, 0 beq _08035FCC - ldr r4, =gUnknown_02022E18 + ldr r4, =gBattle_BG1_X ldrh r0, [r5, 0xA] bl Sin2 lsls r0, 16 @@ -2251,7 +2251,7 @@ _08035F7E: adds r0, r2, 0 subs r0, r1 strh r0, [r4] - ldr r4, =gUnknown_02022E1C + ldr r4, =gBattle_BG2_X ldrh r0, [r5, 0xC] bl Sin2 lsls r0, 16 @@ -2266,16 +2266,16 @@ _08035F9C: adds r0, r3, 0 subs r0, r1 strh r0, [r4] - ldr r0, =gUnknown_02022E1A + ldr r0, =gBattle_BG1_Y ldr r2, =0x0000ffdc adds r1, r2, 0 strh r1, [r0] - ldr r0, =gUnknown_02022E1E + ldr r0, =gBattle_BG2_Y strh r1, [r0] b _08036038 .pool _08035FCC: - ldr r4, =gUnknown_02022E18 + ldr r4, =gBattle_BG1_X ldrh r0, [r5, 0xA] bl Sin2 lsls r0, 16 @@ -2290,7 +2290,7 @@ _08035FDE: adds r0, r3, 0 subs r0, r1 strh r0, [r4] - ldr r4, =gUnknown_02022E1A + ldr r4, =gBattle_BG1_Y ldrh r0, [r5, 0xA] bl Cos2 lsls r0, 16 @@ -2302,7 +2302,7 @@ _08035FFC: asrs r0, 5 subs r0, 0xA4 strh r0, [r4] - ldr r4, =gUnknown_02022E1C + ldr r4, =gBattle_BG2_X ldrh r0, [r5, 0xC] bl Sin2 lsls r0, 16 @@ -2317,7 +2317,7 @@ _08036014: adds r0, r2, 0 subs r0, r1 strh r0, [r4] - ldr r4, =gUnknown_02022E1E + ldr r4, =gBattle_BG2_Y ldrh r0, [r5, 0xC] bl Cos2 lsls r0, 16 @@ -2504,11 +2504,11 @@ sub_8036154: @ 8036154 movs r0, 0x4A movs r1, 0x36 bl SetGpuReg - ldr r0, =gUnknown_02022E1A + ldr r0, =gBattle_BG1_Y ldr r2, =0x0000ff5c adds r1, r2, 0 strh r1, [r0] - ldr r0, =gUnknown_02022E1E + ldr r0, =gBattle_BG2_Y strh r1, [r0] ldr r0, =gUnknown_0831AA00 bl LoadCompressedObjectPicUsingHeap diff --git a/asm/battle_2.s b/asm/battle_2.s index 14e332d7c..d1119619c 100644 --- a/asm/battle_2.s +++ b/asm/battle_2.s @@ -157,13 +157,13 @@ _080368BE: strh r1, [r0] ldr r0, =gUnknown_02022E16 strh r1, [r0] - ldr r0, =gUnknown_02022E18 + ldr r0, =gBattle_BG1_X strh r1, [r0] - ldr r0, =gUnknown_02022E1A + ldr r0, =gBattle_BG1_Y strh r1, [r0] - ldr r0, =gUnknown_02022E1C + ldr r0, =gBattle_BG2_X strh r1, [r0] - ldr r0, =gUnknown_02022E1E + ldr r0, =gBattle_BG2_Y strh r1, [r0] ldr r0, =gUnknown_02022E20 strh r1, [r0] @@ -3925,19 +3925,19 @@ _08038A3A: ldrh r1, [r0] movs r0, 0x12 bl SetGpuReg - ldr r0, =gUnknown_02022E18 + ldr r0, =gBattle_BG1_X ldrh r1, [r0] movs r0, 0x14 bl SetGpuReg - ldr r0, =gUnknown_02022E1A + ldr r0, =gBattle_BG1_Y ldrh r1, [r0] movs r0, 0x16 bl SetGpuReg - ldr r0, =gUnknown_02022E1C + ldr r0, =gBattle_BG2_X ldrh r1, [r0] movs r0, 0x18 bl SetGpuReg - ldr r0, =gUnknown_02022E1E + ldr r0, =gBattle_BG2_Y ldrh r1, [r0] movs r0, 0x1A bl SetGpuReg @@ -4371,13 +4371,13 @@ _08038E1A: strh r4, [r0] ldr r0, =gUnknown_02022E16 strh r4, [r0] - ldr r0, =gUnknown_02022E18 + ldr r0, =gBattle_BG1_X strh r4, [r0] - ldr r0, =gUnknown_02022E1A + ldr r0, =gBattle_BG1_Y strh r4, [r0] - ldr r0, =gUnknown_02022E1C + ldr r0, =gBattle_BG2_X strh r4, [r0] - ldr r0, =gUnknown_02022E1E + ldr r0, =gBattle_BG2_Y strh r4, [r0] ldr r0, =gUnknown_02022E20 strh r4, [r0] @@ -4842,13 +4842,13 @@ sub_80392A8: @ 80392A8 strh r4, [r0] ldr r0, =gUnknown_02022E16 strh r4, [r0] - ldr r0, =gUnknown_02022E18 + ldr r0, =gBattle_BG1_X strh r4, [r0] - ldr r0, =gUnknown_02022E1A + ldr r0, =gBattle_BG1_Y strh r4, [r0] - ldr r0, =gUnknown_02022E1C + ldr r0, =gBattle_BG2_X strh r4, [r0] - ldr r0, =gUnknown_02022E1E + ldr r0, =gBattle_BG2_Y strh r4, [r0] ldr r0, =gUnknown_02022E20 strh r4, [r0] @@ -5215,7 +5215,7 @@ _08039678: bl PlaySE ldr r0, =gText_BattleRecordedOnPass _08039686: - bl StrCpyDecodeToDisplayedStringBattle + bl BattleStringExpandPlaceholdersToDisplayedString ldr r0, =gDisplayedStringBattle movs r1, 0 bl sub_814F9EC @@ -7806,7 +7806,7 @@ _0803ABD4: movs r0, 0 movs r1, 0 movs r2, 0 - bl EmitGetAttributes + bl EmitGetMonData ldrb r0, [r4] bl MarkBufferBankForExecution ldrb r0, [r5] @@ -7849,7 +7849,7 @@ bc_load_battlefield: @ 803AC34 cmp r5, 0 bne _0803AC64 movs r0, 0 - bl GetBankByPlayerAI + bl GetBankByIdentity ldr r4, =gActiveBank strb r0, [r4] ldr r0, =gUnknown_02022FF0 @@ -8274,7 +8274,7 @@ _0803AFFA: cmp r7, 0x5 ble _0803AFAA movs r0, 0x1 - bl GetBankByPlayerAI + bl GetBankByIdentity ldr r4, =gActiveBank strb r0, [r4] movs r0, 0 @@ -8326,7 +8326,7 @@ _0803B072: cmp r7, 0x5 ble _0803B026 movs r0, 0 - bl GetBankByPlayerAI + bl GetBankByIdentity ldr r4, =gActiveBank strb r0, [r4] movs r0, 0 @@ -8404,7 +8404,7 @@ bc_battle_begin_message: @ 803B120 cmp r0, 0 bne _0803B142 movs r0, 0x1 - bl GetBankByPlayerAI + bl GetBankByIdentity ldr r1, =gActiveBank strb r0, [r1] ldrb r1, [r1] @@ -8468,7 +8468,7 @@ sub_803B180: @ 803B180 _0803B1B8: movs r0, 0x1 _0803B1BA: - bl GetBankByPlayerAI + bl GetBankByIdentity adds r1, r0, 0 lsls r1, 24 lsrs r1, 24 @@ -8738,7 +8738,7 @@ _0803B3F6: cmp r0, 0 bne _0803B412 adds r0, r3, 0 - bl GetBankByPlayerAI + bl GetBankByIdentity adds r1, r0, 0 lsls r1, 24 lsrs r1, 24 @@ -9241,7 +9241,7 @@ _0803B7EA: ldr r1, =gBattleMainFunc ldr r0, =sub_803BE74 str r0, [r1] - bl sub_803F988 + bl ResetSentPokesToOpponentValue ldr r1, =gBattleCommunication movs r2, 0 adds r0, r1, 0x7 @@ -9588,8 +9588,8 @@ _0803BB78: .pool thumb_func_end BattleTurnPassed - thumb_func_start sub_803BB88 -sub_803BB88: @ 803BB88 + thumb_func_start IsRunningFromBattleImpossible +IsRunningFromBattleImpossible: @ 803BB88 push {r4-r7,lr} sub sp, 0x4 ldr r1, =gBattleMons @@ -9830,7 +9830,7 @@ _0803BD92: pop {r1} bx r1 .pool - thumb_func_end sub_803BB88 + thumb_func_end IsRunningFromBattleImpossible thumb_func_start sub_803BDA0 sub_803BDA0: @ 803BDA0 @@ -10013,7 +10013,7 @@ _0803BF0C: beq _0803BF68 eors r5, r1 adds r0, r5, 0 - bl GetBankByPlayerAI + bl GetBankByIdentity ldr r1, [r4] adds r1, 0x91 ldrb r1, [r1] @@ -10027,7 +10027,7 @@ _0803BF0C: bne _0803BF68 ldr r4, =gBattleCommunication adds r0, r5, 0 - bl GetBankByPlayerAI + bl GetBankByIdentity lsls r0, 24 lsrs r0, 24 adds r0, r4 @@ -10612,7 +10612,7 @@ _0803C4B4: eors r0, r6 lsls r0, 24 lsrs r0, 24 - bl GetBankByPlayerAI + bl GetBankByIdentity lsls r0, 24 lsrs r0, 24 adds r0, r4 @@ -10625,7 +10625,7 @@ _0803C4B4: eors r0, r6 lsls r0, 24 lsrs r0, 24 - bl GetBankByPlayerAI + bl GetBankByIdentity ldr r1, =gBattleMons lsls r0, 24 lsrs r0, 24 @@ -10645,7 +10645,7 @@ _0803C4B4: eors r0, r6 lsls r0, 24 lsrs r0, 24 - bl GetBankByPlayerAI + bl GetBankByIdentity lsls r0, 24 lsrs r0, 24 muls r0, r7 @@ -10670,7 +10670,7 @@ _0803C550: eors r0, r6 lsls r0, 24 lsrs r0, 24 - bl GetBankByPlayerAI + bl GetBankByIdentity lsls r0, 24 lsrs r0, 24 adds r0, r4 @@ -10682,7 +10682,7 @@ _0803C550: eors r0, r6 lsls r0, 24 lsrs r0, 24 - bl GetBankByPlayerAI + bl GetBankByIdentity lsls r0, 24 lsrs r0, 24 movs r1, 0x2 @@ -10695,7 +10695,7 @@ _0803C590: eors r0, r6 lsls r0, 24 lsrs r0, 24 - bl GetBankByPlayerAI + bl GetBankByIdentity lsls r0, 24 lsrs r0, 24 adds r0, r4 @@ -10712,7 +10712,7 @@ _0803C5B6: eors r0, r6 lsls r0, 24 lsrs r0, 24 - bl GetBankByPlayerAI + bl GetBankByIdentity lsls r0, 24 lsrs r0, 24 adds r0, r4 @@ -10725,7 +10725,7 @@ _0803C5B6: eors r0, r6 lsls r0, 24 lsrs r0, 24 - bl GetBankByPlayerAI + bl GetBankByIdentity lsls r0, 24 lsrs r0, 20 adds r0, r4 @@ -10739,7 +10739,7 @@ _0803C5B6: eors r0, r6 lsls r0, 24 lsrs r0, 24 - bl GetBankByPlayerAI + bl GetBankByIdentity lsls r0, 24 lsrs r0, 24 lsls r1, r0, 3 @@ -10771,7 +10771,7 @@ _0803C628: eors r0, r5 lsls r0, 24 lsrs r0, 24 - bl GetBankByPlayerAI + bl GetBankByIdentity lsls r0, 24 lsrs r0, 24 adds r0, r4 @@ -10788,7 +10788,7 @@ _0803C628: _0803C668: lsls r0, 24 lsrs r0, 24 - bl GetBankByPlayerAI + bl GetBankByIdentity lsls r0, 24 lsrs r0, 24 movs r1, 0x1 @@ -10803,7 +10803,7 @@ _0803C690: eors r0, r1 lsls r0, 24 lsrs r0, 24 - bl GetBankByPlayerAI + bl GetBankByIdentity lsls r0, 24 lsrs r0, 24 movs r1, 0x3 @@ -10873,7 +10873,7 @@ _0803C720: b _0803CC20 .pool _0803C760: - bl sub_803BB88 + bl IsRunningFromBattleImpossible lsls r0, 24 cmp r0, 0 beq _0803C7C4 @@ -11271,7 +11271,7 @@ _0803CAFA: bne _0803CB3C adds r0, r5, 0 eors r0, r1 - bl GetBankByPlayerAI + bl GetBankByIdentity ldr r1, =gBattleStruct ldr r1, [r1] adds r1, 0x91 @@ -12870,7 +12870,7 @@ sub_803D8C0: @ 803D8C0 ldrb r0, [r4] strb r0, [r1] movs r0, 0 - bl GetBankByPlayerAI + bl GetBankByIdentity ldr r1, =gBankAttacker strb r0, [r1] ldr r1, =gBattlescriptCurrInstr @@ -13075,7 +13075,7 @@ _0803DB44: ldrb r0, [r4] strb r0, [r1] movs r0, 0 - bl GetBankByPlayerAI + bl GetBankByIdentity ldr r1, =gBankAttacker strb r0, [r1] ldr r1, =gBattlescriptCurrInstr @@ -14124,7 +14124,7 @@ _0803E548: _0803E558: movs r0, 0x2 _0803E55A: - bl GetBankByPlayerAI + bl GetBankByIdentity ldr r1, =gBankTarget strb r0, [r1] b _0803E578 @@ -14173,7 +14173,7 @@ _0803E5C4: eors r0, r1 lsls r0, 24 lsrs r0, 24 - bl GetBankByPlayerAI + bl GetBankByIdentity strb r0, [r5] ldrb r1, [r7] ldrb r2, [r5] @@ -14257,7 +14257,7 @@ _0803E684: _0803E694: movs r0, 0x2 _0803E696: - bl GetBankByPlayerAI + bl GetBankByIdentity ldr r1, =gBankTarget strb r0, [r1] ldr r0, =gAbsentBankFlags @@ -14323,7 +14323,7 @@ _0803E730: eors r0, r1 lsls r0, 24 lsrs r0, 24 - bl GetBankByPlayerAI + bl GetBankByIdentity strb r0, [r5] ldrb r1, [r6] ldrb r2, [r5] @@ -14341,7 +14341,7 @@ _0803E758: eors r0, r1 lsls r0, 24 lsrs r0, 24 - bl GetBankByPlayerAI + bl GetBankByIdentity strb r0, [r5] _0803E76A: ldr r0, =gBattleTypeFlags @@ -14823,8 +14823,8 @@ _0803EBF6: .pool thumb_func_end sub_803E90C - thumb_func_start sub_803EC20 -sub_803EC20: @ 803EC20 + thumb_func_start CanRunFromBattle +CanRunFromBattle: @ 803EC20 push {r4-r7,lr} mov r7, r10 mov r6, r9 @@ -15069,7 +15069,7 @@ _0803EE24: pop {r1} bx r1 .pool - thumb_func_end sub_803EC20 + thumb_func_end CanRunFromBattle thumb_func_start sub_803EE48 sub_803EE48: @ 803EE48 @@ -15157,7 +15157,7 @@ _0803EF0C: cmp r0, 0 bne _0803EF4C ldrb r0, [r4] - bl sub_803EC20 + bl CanRunFromBattle lsls r0, 24 cmp r0, 0 bne _0803EF98 @@ -15690,7 +15690,7 @@ _0803F46C: _0803F470: movs r0, 0x3 _0803F472: - bl GetBankByPlayerAI + bl GetBankByIdentity lsls r0, 24 lsrs r0, 24 _0803F47A: @@ -15786,7 +15786,7 @@ _0803F4DE: movs r0, 0 movs r2, 0 movs r3, 0x1 - bl EmitSetAttributes + bl EmitSetMonData ldrb r0, [r4] bl MarkBufferBankForExecution _0803F532: @@ -15933,7 +15933,7 @@ _0803F5F0: movs r0, 0 movs r2, 0 movs r3, 0x1 - bl EmitSetAttributes + bl EmitSetMonData ldrb r0, [r4] bl MarkBufferBankForExecution _0803F658: @@ -16065,7 +16065,7 @@ _0803F6FE: movs r0, 0 movs r2, 0 movs r3, 0x1 - bl EmitSetAttributes + bl EmitSetMonData ldrb r0, [r4] bl MarkBufferBankForExecution _0803F762: @@ -16319,8 +16319,8 @@ PrepareStringBattle: @ 803F964 .pool thumb_func_end PrepareStringBattle - thumb_func_start sub_803F988 -sub_803F988: @ 803F988 + thumb_func_start ResetSentPokesToOpponentValue +ResetSentPokesToOpponentValue: @ 803F988 push {r4-r6,lr} movs r3, 0 ldr r0, =gSentPokesToOpponent @@ -16368,7 +16368,7 @@ _0803F9D6: pop {r0} bx r0 .pool - thumb_func_end sub_803F988 + thumb_func_end ResetSentPokesToOpponentValue thumb_func_start sub_803F9EC sub_803F9EC: @ 803F9EC diff --git a/asm/battle_4.s b/asm/battle_4.s index 3a6558a86..0714a0c22 100644 --- a/asm/battle_4.s +++ b/asm/battle_4.s @@ -5,7476 +5,6 @@ .text - thumb_func_start atk6A_removeitem -atk6A_removeitem: @ 804EE58 - push {r4-r6,lr} - sub sp, 0x4 - ldr r6, =gBattlescriptCurrInstr - ldr r0, [r6] - ldrb r0, [r0, 0x1] - bl GetBattleBank - ldr r5, =gActiveBank - strb r0, [r5] - ldr r1, =gBattleStruct - ldrb r4, [r5] - lsls r0, r4, 1 - adds r0, 0xB8 - ldr r1, [r1] - adds r1, r0 - ldr r2, =gBattleMons - movs r3, 0x58 - adds r0, r4, 0 - muls r0, r3 - adds r0, r2 - ldrh r0, [r0, 0x2E] - strh r0, [r1] - ldrb r0, [r5] - muls r0, r3 - adds r0, r2 - movs r1, 0 - strh r1, [r0, 0x2E] - ldrb r0, [r5] - muls r0, r3 - adds r2, 0x2E - adds r0, r2 - str r0, [sp] - movs r0, 0 - movs r1, 0x2 - movs r2, 0 - movs r3, 0x2 - bl EmitSetAttributes - ldrb r0, [r5] - bl MarkBufferBankForExecution - ldr r0, [r6] - adds r0, 0x2 - str r0, [r6] - add sp, 0x4 - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end atk6A_removeitem - - thumb_func_start atk6B_atknameinbuff1 -atk6B_atknameinbuff1: @ 804EEC8 - ldr r1, =gBattleTextBuff1 - movs r0, 0xFD - strb r0, [r1] - movs r0, 0x7 - strb r0, [r1, 0x1] - ldr r2, =gBankAttacker - ldrb r0, [r2] - strb r0, [r1, 0x2] - ldr r3, =gBattlePartyID - ldrb r0, [r2] - lsls r0, 1 - adds r0, r3 - ldrh r0, [r0] - strb r0, [r1, 0x3] - movs r0, 0xFF - strb r0, [r1, 0x4] - ldr r1, =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x1 - str r0, [r1] - bx lr - .pool - thumb_func_end atk6B_atknameinbuff1 - - thumb_func_start atk6C_lvlbox_display -atk6C_lvlbox_display: @ 804EF04 - push {r4,lr} - sub sp, 0x4 - ldr r0, =gBattleScripting - ldrb r1, [r0, 0x1E] - adds r4, r0, 0 - cmp r1, 0 - bne _0804EF28 - bl sub_804F498 - cmp r0, 0 - beq _0804EF24 - movs r0, 0x3 - b _0804EF26 - .pool -_0804EF24: - movs r0, 0x1 -_0804EF26: - strb r0, [r4, 0x1E] -_0804EF28: - ldrb r0, [r4, 0x1E] - subs r0, 0x1 - cmp r0, 0x9 - bls _0804EF32 - b _0804F0F2 -_0804EF32: - lsls r0, 2 - ldr r1, =_0804EF40 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_0804EF40: - .4byte _0804EF68 - .4byte _0804EF94 - .4byte _0804EFAC - .4byte _0804F000 - .4byte _0804F014 - .4byte _0804F02C - .4byte _0804F014 - .4byte _0804F04C - .4byte _0804F07C - .4byte _0804F0C0 -_0804EF68: - ldr r1, =gUnknown_02022E1E - movs r0, 0x60 - strh r0, [r1] - movs r0, 0x2 - movs r1, 0x7 - movs r2, 0 - bl SetBgAttribute - movs r0, 0x2 - bl ShowBg - bl sub_804F17C - ldr r1, =gBattleScripting - movs r0, 0x2 - strb r0, [r1, 0x1E] - b _0804F0F2 - .pool -_0804EF94: - bl sub_804F1CC - lsls r0, 24 - cmp r0, 0 - beq _0804EFA0 - b _0804F0F2 -_0804EFA0: - ldr r1, =gBattleScripting - movs r0, 0x3 - strb r0, [r1, 0x1E] - b _0804F0F2 - .pool -_0804EFAC: - ldr r1, =gUnknown_02022E18 - movs r0, 0 - strh r0, [r1] - ldr r1, =gUnknown_02022E1A - movs r2, 0x80 - lsls r2, 1 - adds r0, r2, 0 - strh r0, [r1] - movs r0, 0 - movs r1, 0x7 - movs r2, 0x1 - bl SetBgAttribute - movs r0, 0x1 - movs r1, 0x7 - movs r2, 0 - bl SetBgAttribute - movs r0, 0 - bl ShowBg - movs r0, 0x1 - bl ShowBg - movs r0, 0x80 - str r0, [sp] - movs r0, 0x12 - movs r1, 0x7 - movs r2, 0x1D - movs r3, 0x13 - bl sub_8056A3C - ldr r1, =gBattleScripting - movs r0, 0x4 - strb r0, [r1, 0x1E] - b _0804F0F2 - .pool -_0804F000: - bl sub_804F100 - movs r0, 0xD - bl PutWindowTilemap - movs r0, 0xD - movs r1, 0x3 - bl CopyWindowToVram - b _0804F06A -_0804F014: - bl IsDma3ManagerBusyWithBgCopy - lsls r0, 24 - lsrs r1, r0, 24 - cmp r1, 0 - bne _0804F0F2 - ldr r0, =gUnknown_02022E1A - strh r1, [r0] - b _0804F06A - .pool -_0804F02C: - ldr r0, =gMain - ldrh r0, [r0, 0x2E] - cmp r0, 0 - beq _0804F0F2 - movs r0, 0x5 - bl PlaySE - bl sub_804F144 - movs r0, 0xD - movs r1, 0x2 - bl CopyWindowToVram - b _0804F06A - .pool -_0804F04C: - ldr r0, =gMain - ldrh r0, [r0, 0x2E] - cmp r0, 0 - beq _0804F0F2 - movs r0, 0x5 - bl PlaySE - movs r0, 0x81 - str r0, [sp] - movs r0, 0x12 - movs r1, 0x7 - movs r2, 0x1D - movs r3, 0x13 - bl sub_8056A3C -_0804F06A: - ldr r1, =gBattleScripting - ldrb r0, [r1, 0x1E] - adds r0, 0x1 - strb r0, [r1, 0x1E] - b _0804F0F2 - .pool -_0804F07C: - bl sub_804F344 - lsls r0, 24 - cmp r0, 0 - bne _0804F0F2 - movs r0, 0xE - bl ClearWindowTilemap - movs r0, 0xE - movs r1, 0x1 - bl CopyWindowToVram - movs r0, 0xD - bl ClearWindowTilemap - movs r0, 0xD - movs r1, 0x1 - bl CopyWindowToVram - movs r0, 0x2 - movs r1, 0x7 - movs r2, 0x2 - bl SetBgAttribute - movs r0, 0x2 - bl ShowBg - ldr r1, =gBattleScripting - movs r0, 0xA - strb r0, [r1, 0x1E] - b _0804F0F2 - .pool -_0804F0C0: - bl IsDma3ManagerBusyWithBgCopy - lsls r0, 24 - cmp r0, 0 - bne _0804F0F2 - movs r0, 0 - movs r1, 0x7 - movs r2, 0 - bl SetBgAttribute - movs r0, 0x1 - movs r1, 0x7 - movs r2, 0x1 - bl SetBgAttribute - movs r0, 0 - bl ShowBg - movs r0, 0x1 - bl ShowBg - ldr r1, =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x1 - str r0, [r1] -_0804F0F2: - add sp, 0x4 - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end atk6C_lvlbox_display - - thumb_func_start sub_804F100 -sub_804F100: @ 804F100 - push {lr} - sub sp, 0x14 - ldr r0, =gBattleStruct - ldr r0, [r0] - ldrb r1, [r0, 0x10] - movs r0, 0x64 - muls r0, r1 - ldr r1, =gPlayerParty - adds r0, r1 - add r1, sp, 0x8 - bl sub_81D388C - ldr r0, =gBattleResources - ldr r0, [r0] - ldr r1, [r0, 0x10] - movs r0, 0xD - str r0, [sp] - movs r0, 0xF - str r0, [sp, 0x4] - movs r0, 0xD - add r2, sp, 0x8 - movs r3, 0xE - bl sub_81D3640 - add sp, 0x14 - pop {r0} - bx r0 - .pool - thumb_func_end sub_804F100 - - thumb_func_start sub_804F144 -sub_804F144: @ 804F144 - push {lr} - sub sp, 0x10 - ldr r0, =gBattleStruct - ldr r0, [r0] - ldrb r1, [r0, 0x10] - movs r0, 0x64 - muls r0, r1 - ldr r1, =gPlayerParty - adds r0, r1 - add r1, sp, 0x4 - bl sub_81D388C - movs r0, 0xF - str r0, [sp] - movs r0, 0xD - add r1, sp, 0x4 - movs r2, 0xE - movs r3, 0xD - bl sub_81D3784 - add sp, 0x10 - pop {r0} - bx r0 - .pool - thumb_func_end sub_804F144 - - thumb_func_start sub_804F17C -sub_804F17C: @ 804F17C - push {lr} - ldr r1, =gUnknown_02022E1E - movs r0, 0 - strh r0, [r1] - ldr r1, =gUnknown_02022E1C - movs r2, 0xD0 - lsls r2, 1 - adds r0, r2, 0 - strh r0, [r1] - ldr r0, =gUnknown_0831C2C8 - movs r1, 0x60 - movs r2, 0x20 - bl LoadPalette - ldr r1, =gUnknown_0831C2E8 - movs r0, 0xE - movs r2, 0 - movs r3, 0 - bl CopyToWindowPixelBuffer - movs r0, 0xE - bl PutWindowTilemap - movs r0, 0xE - movs r1, 0x3 - bl CopyWindowToVram - bl sub_804F384 - pop {r0} - bx r0 - .pool - thumb_func_end sub_804F17C - - thumb_func_start sub_804F1CC -sub_804F1CC: @ 804F1CC - push {r4,r5,lr} - bl IsDma3ManagerBusyWithBgCopy - lsls r0, 24 - cmp r0, 0 - beq _0804F1DC - movs r0, 0x1 - b _0804F216 -_0804F1DC: - ldr r4, =gUnknown_02022E1C - ldrh r1, [r4] - movs r5, 0x80 - lsls r5, 2 - cmp r1, r5 - bne _0804F1F0 - movs r0, 0 - b _0804F216 - .pool -_0804F1F0: - movs r0, 0xD0 - lsls r0, 1 - cmp r1, r0 - bne _0804F1FC - bl sub_804F220 -_0804F1FC: - ldrh r0, [r4] - adds r0, 0x8 - strh r0, [r4] - lsls r0, 16 - ldr r1, =0x01ff0000 - cmp r0, r1 - bls _0804F20C - strh r5, [r4] -_0804F20C: - ldrh r1, [r4] - eors r1, r5 - negs r0, r1 - orrs r0, r1 - lsrs r0, 31 -_0804F216: - pop {r4,r5} - pop {r1} - bx r1 - .pool - thumb_func_end sub_804F1CC - - thumb_func_start sub_804F220 -sub_804F220: @ 804F220 - push {r4-r7,lr} - mov r7, r8 - push {r7} - sub sp, 0x10 - ldr r6, =gBattleStruct - ldr r0, [r6] - ldrb r0, [r0, 0x10] - movs r5, 0x64 - muls r0, r5 - ldr r4, =gPlayerParty - adds r0, r4 - movs r1, 0x38 - bl GetMonData - mov r8, r0 - lsls r0, 16 - lsrs r0, 16 - mov r8, r0 - ldr r0, [r6] - ldrb r0, [r0, 0x10] - muls r0, r5 - adds r0, r4 - bl GetMonGender - lsls r0, 24 - lsrs r7, r0, 24 - ldr r0, [r6] - ldrb r0, [r0, 0x10] - muls r0, r5 - adds r0, r4 - ldr r5, =gStringVar4 - adds r1, r5, 0 - bl GetMonNickname - str r5, [sp] - mov r2, sp - movs r1, 0 - movs r0, 0xE - strb r0, [r2, 0x4] - mov r0, sp - strb r1, [r0, 0x5] - movs r4, 0x20 - strb r4, [r0, 0x6] - strb r1, [r0, 0x7] - strb r4, [r0, 0x8] - strb r1, [r0, 0x9] - strb r1, [r0, 0xA] - strb r1, [r0, 0xB] - mov r3, sp - ldrb r2, [r3, 0xC] - subs r1, 0x10 - adds r0, r1, 0 - ands r0, r2 - strb r0, [r3, 0xC] - mov r2, sp - movs r0, 0x10 - strb r0, [r2, 0xC] - ldrb r0, [r2, 0xD] - ands r1, r0 - strb r1, [r2, 0xD] - mov r0, sp - strb r4, [r0, 0xD] - movs r1, 0xFF - movs r2, 0 - bl AddTextPrinter - movs r0, 0xF9 - strb r0, [r5] - adds r5, 0x1 - movs r0, 0x5 - strb r0, [r5] - adds r5, 0x1 - adds r4, r5, 0 - adds r0, r4, 0 - mov r1, r8 - movs r2, 0 - movs r3, 0x3 - bl ConvertIntToDecimalStringN - adds r5, r0, 0 - subs r4, r5, r4 - movs r2, 0x4 - subs r2, r4 - lsls r2, 16 - lsrs r2, 16 - movs r1, 0x77 - bl StringFill - adds r5, r0, 0 - cmp r7, 0xFF - beq _0804F320 - cmp r7, 0 - bne _0804F300 - movs r1, 0 - movs r2, 0xC - bl WriteColorChangeControlCode - adds r5, r0, 0 - movs r1, 0x1 - movs r2, 0xD - bl WriteColorChangeControlCode - adds r5, r0, 0 - movs r0, 0xB5 - b _0804F318 - .pool -_0804F300: - adds r0, r5, 0 - movs r1, 0 - movs r2, 0xE - bl WriteColorChangeControlCode - adds r5, r0, 0 - movs r1, 0x1 - movs r2, 0xF - bl WriteColorChangeControlCode - adds r5, r0, 0 - movs r0, 0xB6 -_0804F318: - strb r0, [r5] - adds r5, 0x1 - movs r0, 0xFF - strb r0, [r5] -_0804F320: - mov r0, sp - movs r1, 0xA - strb r1, [r0, 0x7] - strb r1, [r0, 0x9] - movs r1, 0xFF - movs r2, 0 - bl AddTextPrinter - movs r0, 0xE - movs r1, 0x2 - bl CopyWindowToVram - add sp, 0x10 - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end sub_804F220 - - thumb_func_start sub_804F344 -sub_804F344: @ 804F344 - push {lr} - ldr r0, =gUnknown_02022E1C - ldrh r1, [r0] - movs r3, 0xD0 - lsls r3, 1 - adds r2, r0, 0 - cmp r1, r3 - bne _0804F35C - movs r0, 0 - b _0804F380 - .pool -_0804F35C: - ldrh r0, [r2] - adds r1, r0, 0 - subs r1, 0x10 - ldr r0, =0x0000019f - cmp r1, r0 - bgt _0804F370 - strh r3, [r2] - b _0804F372 - .pool -_0804F370: - strh r1, [r2] -_0804F372: - ldrh r1, [r2] - movs r0, 0xD0 - lsls r0, 1 - eors r1, r0 - negs r0, r1 - orrs r0, r1 - lsrs r0, 31 -_0804F380: - pop {r1} - bx r1 - thumb_func_end sub_804F344 - - thumb_func_start sub_804F384 -sub_804F384: @ 804F384 - push {r4-r6,lr} - mov r6, r8 - push {r6} - sub sp, 0x10 - ldr r0, =gBattleStruct - mov r8, r0 - ldr r0, [r0] - ldrb r0, [r0, 0x10] - movs r6, 0x64 - muls r0, r6 - ldr r5, =gPlayerParty - adds r0, r5 - movs r1, 0xB - bl GetMonData - adds r4, r0, 0 - lsls r4, 16 - lsrs r4, 16 - mov r1, r8 - ldr r0, [r1] - ldrb r0, [r0, 0x10] - muls r0, r6 - adds r0, r5 - movs r1, 0 - bl GetMonData - adds r1, r0, 0 - adds r0, r4, 0 - movs r2, 0x1 - bl sub_80D2EDC - str r0, [sp] - ldr r5, =0xffff0000 - ldr r0, [sp, 0x4] - ands r0, r5 - movs r1, 0x80 - lsls r1, 2 - orrs r0, r1 - ldr r1, =0x0000ffff - ands r0, r1 - ldr r1, =0xd75a0000 - orrs r0, r1 - str r0, [sp, 0x4] - adds r0, r4, 0 - bl sub_80D30B0 - str r0, [sp, 0x8] - add r4, sp, 0x8 - ldr r0, [r4, 0x4] - ands r0, r5 - ldr r1, =0x0000d75a - orrs r0, r1 - str r0, [r4, 0x4] - mov r0, sp - bl LoadSpriteSheet - adds r0, r4, 0 - bl LoadSpritePalette - ldr r0, =gUnknown_0831C3C0 - movs r1, 0x80 - lsls r1, 1 - movs r2, 0xA - movs r3, 0 - bl CreateSprite - lsls r0, 24 - lsrs r0, 24 - ldr r2, =gSprites - lsls r1, r0, 4 - adds r1, r0 - lsls r1, 2 - adds r1, r2 - movs r0, 0 - strh r0, [r1, 0x2E] - ldr r0, =gUnknown_02022E1C - ldrh r0, [r0] - strh r0, [r1, 0x30] - add sp, 0x10 - pop {r3} - mov r8, r3 - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_804F384 - - thumb_func_start sub_804F450 -sub_804F450: @ 804F450 - push {r4,lr} - adds r2, r0, 0 - ldr r0, =gUnknown_02022E1C - ldrh r1, [r2, 0x30] - ldrh r0, [r0] - subs r1, r0 - strh r1, [r2, 0x24] - lsls r1, 16 - cmp r1, 0 - beq _0804F470 - movs r0, 0x1 - strh r0, [r2, 0x2E] - b _0804F48C - .pool -_0804F470: - movs r1, 0x2E - ldrsh r0, [r2, r1] - cmp r0, 0 - beq _0804F48C - adds r0, r2, 0 - bl DestroySprite - ldr r4, =0x0000d75a - adds r0, r4, 0 - bl FreeSpriteTilesByTag - adds r0, r4, 0 - bl FreeSpritePaletteByTag -_0804F48C: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_804F450 - - thumb_func_start sub_804F498 -sub_804F498: @ 804F498 - push {lr} - ldr r3, =gBattlePartyID - ldr r0, =gBattleStruct - ldr r0, [r0] - ldrh r1, [r3] - ldrb r2, [r0, 0x10] - cmp r1, r2 - beq _0804F4BA - ldr r0, =gBattleTypeFlags - ldr r0, [r0] - movs r1, 0x1 - ands r0, r1 - cmp r0, 0 - beq _0804F4CC - ldrh r0, [r3, 0x4] - cmp r0, r2 - bne _0804F4CC -_0804F4BA: - movs r0, 0x1 - b _0804F4CE - .pool -_0804F4CC: - movs r0, 0 -_0804F4CE: - pop {r1} - bx r1 - thumb_func_end sub_804F498 - - thumb_func_start atk6D_set_sentpokes_values -atk6D_set_sentpokes_values: @ 804F4D4 - push {lr} - bl sub_803F988 - ldr r1, =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x1 - str r0, [r1] - pop {r0} - bx r0 - .pool - thumb_func_end atk6D_set_sentpokes_values - - thumb_func_start atk6E_set_atk_to_player0 -atk6E_set_atk_to_player0: @ 804F4EC - push {lr} - movs r0, 0 - bl GetBankByPlayerAI - ldr r1, =gBankAttacker - strb r0, [r1] - ldr r1, =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x1 - str r0, [r1] - pop {r0} - bx r0 - .pool - thumb_func_end atk6E_set_atk_to_player0 - - thumb_func_start atk6F_set_visible -atk6F_set_visible: @ 804F50C - push {r4,r5,lr} - ldr r5, =gBattlescriptCurrInstr - ldr r0, [r5] - ldrb r0, [r0, 0x1] - bl GetBattleBank - ldr r4, =gActiveBank - strb r0, [r4] - movs r0, 0 - movs r1, 0 - bl EmitSpriteInvisibility - 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 atk6F_set_visible - - thumb_func_start atk70_record_ability -atk70_record_ability: @ 804F540 - push {r4,lr} - ldr r4, =gBattlescriptCurrInstr - ldr r0, [r4] - ldrb r0, [r0, 0x1] - bl GetBattleBank - ldr r1, =gActiveBank - strb r0, [r1] - ldrb r0, [r1] - ldr r1, =gLastUsedAbility - ldrb r1, [r1] - bl RecordAbilityBattle - ldr r0, [r4] - adds r0, 0x1 - str r0, [r4] - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end atk70_record_ability - - thumb_func_start sub_804F574 -sub_804F574: @ 804F574 - ldr r2, =gBattleTextBuff2 - movs r0, 0xFD - strb r0, [r2] - movs r0, 0x2 - strb r0, [r2, 0x1] - ldr r0, =gMoveToLearn - ldrh r1, [r0] - strb r1, [r2, 0x2] - movs r0, 0xFF - lsls r0, 8 - ands r0, r1 - lsrs r0, 8 - strb r0, [r2, 0x3] - movs r0, 0xFF - strb r0, [r2, 0x4] - bx lr - .pool - thumb_func_end sub_804F574 - - thumb_func_start atk71_buffer_move_to_learn -atk71_buffer_move_to_learn: @ 804F59C - push {lr} - bl sub_804F574 - ldr r1, =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x1 - str r0, [r1] - pop {r0} - bx r0 - .pool - thumb_func_end atk71_buffer_move_to_learn - - thumb_func_start atk72_jump_if_can_run_frombattle -atk72_jump_if_can_run_frombattle: @ 804F5B4 - push {lr} - ldr r0, =gBank1 - ldrb r0, [r0] - bl sub_803EC20 - lsls r0, 24 - cmp r0, 0 - beq _0804F5E8 - 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 _0804F5F0 - .pool -_0804F5E8: - ldr r1, =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x5 - str r0, [r1] -_0804F5F0: - pop {r0} - bx r0 - .pool - thumb_func_end atk72_jump_if_can_run_frombattle - - thumb_func_start atk73_hp_thresholds -atk73_hp_thresholds: @ 804F5F8 - push {r4-r6,lr} - ldr r0, =gBattleTypeFlags - ldr r4, [r0] - movs r6, 0x1 - ands r4, r6 - cmp r4, 0 - bne _0804F68E - ldr r0, =gBattlescriptCurrInstr - ldr r0, [r0] - ldrb r0, [r0, 0x1] - bl GetBattleBank - ldr r1, =gActiveBank - strb r0, [r1] - movs r1, 0x1 - eors r0, r1 - lsls r0, 24 - lsrs r0, 24 - ldr r2, =gBattleMons - movs r1, 0x58 - muls r1, r0 - adds r1, r2 - ldrh r5, [r1, 0x28] - movs r0, 0x64 - muls r0, r5 - ldrh r1, [r1, 0x2C] - bl __divsi3 - cmp r0, 0 - bne _0804F636 - movs r0, 0x1 -_0804F636: - cmp r0, 0x45 - bgt _0804F63E - cmp r5, 0 - bne _0804F65C -_0804F63E: - ldr r0, =gBattleStruct - ldr r0, [r0] - adds r0, 0xB1 - strb r4, [r0] - b _0804F68E - .pool -_0804F65C: - cmp r0, 0x27 - ble _0804F670 - ldr r0, =gBattleStruct - ldr r0, [r0] - adds r0, 0xB1 - strb r6, [r0] - b _0804F68E - .pool -_0804F670: - cmp r0, 0x9 - ble _0804F684 - ldr r0, =gBattleStruct - ldr r0, [r0] - adds r0, 0xB1 - movs r1, 0x2 - b _0804F68C - .pool -_0804F684: - ldr r0, =gBattleStruct - ldr r0, [r0] - adds r0, 0xB1 - movs r1, 0x3 -_0804F68C: - strb r1, [r0] -_0804F68E: - ldr r1, =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x2 - str r0, [r1] - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end atk73_hp_thresholds - - thumb_func_start atk74_hp_thresholds2 -atk74_hp_thresholds2: @ 804F6A4 - push {r4-r7,lr} - mov r7, r8 - push {r7} - ldr r0, =gBattleTypeFlags - ldr r7, [r0] - movs r0, 0x1 - mov r8, r0 - ands r7, r0 - cmp r7, 0 - bne _0804F73E - ldr r0, =gBattlescriptCurrInstr - ldr r0, [r0] - ldrb r0, [r0, 0x1] - bl GetBattleBank - adds r4, r0, 0 - ldr r0, =gActiveBank - strb r4, [r0] - movs r0, 0x1 - eors r4, r0 - lsls r4, 24 - lsrs r4, 24 - adds r0, r4, 0 - bl GetBankSide - lsls r0, 24 - ldr r1, =gBattleStruct - ldr r6, [r1] - lsrs r0, 23 - adds r0, r6 - adds r0, 0xA8 - ldrb r5, [r0] - ldr r1, =gBattleMons - movs r0, 0x58 - muls r0, r4 - adds r0, r1 - ldrh r4, [r0, 0x28] - subs r1, r5, r4 - movs r0, 0x64 - muls r0, r1 - adds r1, r5, 0 - bl __divsi3 - adds r1, r0, 0 - cmp r4, r5 - bcc _0804F71C - adds r0, r6, 0 - adds r0, 0xB1 - strb r7, [r0] - b _0804F73E - .pool -_0804F71C: - cmp r0, 0x1D - bgt _0804F72A - adds r0, r6, 0 - adds r0, 0xB1 - mov r1, r8 - strb r1, [r0] - b _0804F73E -_0804F72A: - cmp r1, 0x45 - bgt _0804F736 - adds r1, r6, 0 - adds r1, 0xB1 - movs r0, 0x2 - b _0804F73C -_0804F736: - adds r1, r6, 0 - adds r1, 0xB1 - movs r0, 0x3 -_0804F73C: - strb r0, [r1] -_0804F73E: - ldr r1, =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x2 - str r0, [r1] - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end atk74_hp_thresholds2 - - thumb_func_start atk75_8026A58 -atk75_8026A58: @ 804F754 - push {lr} - sub sp, 0x4 - ldr r2, =gBankInMenu - ldr r1, =gBankAttacker - ldrb r0, [r1] - strb r0, [r2] - ldr r2, =gBattlePartyID - ldrb r0, [r1] - lsls r0, 1 - adds r0, r2 - ldrh r2, [r0] - movs r0, 0x64 - muls r0, r2 - ldr r1, =gEnemyParty - adds r0, r1 - ldr r1, =gLastUsedItem - ldrh r1, [r1] - lsls r2, 24 - lsrs r2, 24 - movs r3, 0x1 - str r3, [sp] - movs r3, 0 - bl ExecuteTableBasedItemEffect - ldr r1, =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x1 - str r0, [r1] - add sp, 0x4 - pop {r0} - bx r0 - .pool - thumb_func_end atk75_8026A58 - - thumb_func_start atk76_various -atk76_various: @ 804F7AC - push {r4-r7,lr} - mov r7, r8 - push {r7} - ldr r4, =gBattlescriptCurrInstr - ldr r0, [r4] - ldrb r0, [r0, 0x1] - bl GetBattleBank - ldr r1, =gActiveBank - strb r0, [r1] - ldr r0, [r4] - ldrb r0, [r0, 0x2] - cmp r0, 0x1A - bls _0804F7CA - b _0804FD70 -_0804F7CA: - lsls r0, 2 - ldr r1, =_0804F7E0 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_0804F7E0: - .4byte _0804F84C - .4byte _0804F85C - .4byte _0804F8BC - .4byte _0804F8CC - .4byte _0804F8E4 - .4byte _0804F920 - .4byte _0804F958 - .4byte _0804F9E0 - .4byte _0804FA20 - .4byte _0804FACC - .4byte _0804FAE8 - .4byte _0804FB3C - .4byte _0804FB94 - .4byte _0804FC18 - .4byte _0804FC2C - .4byte _0804FC32 - .4byte _0804FC38 - .4byte _0804FC60 - .4byte _0804FC6A - .4byte _0804FC78 - .4byte _0804FC8C - .4byte _0804FCC4 - .4byte _0804FCD8 - .4byte _0804FCF0 - .4byte _0804FD1C - .4byte _0804FD30 - .4byte _0804FD5C -_0804F84C: - ldr r0, =gActiveBank - ldrb r0, [r0] - bl CancelMultiTurnMoves - b _0804FD70 - .pool -_0804F85C: - ldr r1, =gBankAttacker - ldr r4, =gBankTarget - ldrb r0, [r4] - strb r0, [r1] - ldrb r0, [r1] - bl GetBankSide - movs r1, 0x1 - eors r0, r1 - lsls r0, 24 - lsrs r0, 24 - ldr r2, =gSideTimers - lsls r1, r0, 1 - adds r1, r0 - lsls r1, 2 - adds r2, r1, r2 - ldrb r0, [r2, 0x8] - cmp r0, 0 - beq _0804F8A8 - ldr r1, =gBattleMons - ldrb r2, [r2, 0x9] - movs r0, 0x58 - muls r0, r2 - adds r0, r1 - ldrh r0, [r0, 0x28] - cmp r0, 0 - beq _0804F8A8 - strb r2, [r4] - b _0804FD70 - .pool -_0804F8A8: - ldr r0, =gBankTarget - ldr r1, =gActiveBank - ldrb r1, [r1] - strb r1, [r0] - b _0804FD70 - .pool -_0804F8BC: - bl sub_803BB88 - ldr r1, =gBattleCommunication - strb r0, [r1] - b _0804FD70 - .pool -_0804F8CC: - ldr r0, =gCurrentMove - ldrh r0, [r0] - movs r1, 0 - bl GetMoveTarget - ldr r1, =gBankTarget - strb r0, [r1] - b _0804FD70 - .pool -_0804F8E4: - ldr r2, =gHitMarker - ldr r1, =gBitTable - ldr r0, =gActiveBank - ldrb r0, [r0] - lsls r0, 2 - adds r0, r1 - ldr r0, [r0] - lsls r0, 28 - ldr r2, [r2] - ands r2, r0 - cmp r2, 0 - beq _0804F914 - ldr r1, =gBattleCommunication - movs r0, 0x1 - strb r0, [r1] - b _0804FD70 - .pool -_0804F914: - ldr r0, =gBattleCommunication - strb r2, [r0] - b _0804FD70 - .pool -_0804F920: - ldr r4, =gSpecialStatuses - ldr r3, =gActiveBank - ldrb r0, [r3] - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 2 - adds r1, r4 - ldrb r2, [r1] - movs r0, 0x9 - negs r0, r0 - ands r0, r2 - strb r0, [r1] - ldrb r0, [r3] - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 2 - adds r1, r4 - ldrb r2, [r1] - movs r0, 0x11 - negs r0, r0 - ands r0, r2 - strb r0, [r1] - b _0804FD70 - .pool -_0804F958: - ldr r4, =gBattlePartyID - ldr r1, =gBattleStruct - ldr r0, [r1] - ldrh r3, [r4] - ldrb r2, [r0, 0x10] - adds r6, r1, 0 - cmp r3, r2 - beq _0804F974 - ldrh r0, [r4, 0x4] - cmp r0, r2 - beq _0804F970 - b _0804FD70 -_0804F970: - cmp r3, r0 - bne _0804F988 -_0804F974: - ldr r1, =gActiveBank - movs r0, 0 - b _0804F98C - .pool -_0804F988: - ldr r1, =gActiveBank - movs r0, 0x2 -_0804F98C: - strb r0, [r1] - adds r5, r1, 0 - ldrb r2, [r5] - lsls r0, r2, 1 - adds r0, 0xC8 - ldr r1, [r6] - adds r4, r1, r0 - movs r3, 0 - ldr r1, =gBattleMons - movs r0, 0x58 - muls r0, r2 - adds r1, 0xC - adds r0, r1 - ldrh r0, [r0] - ldrh r2, [r4] - cmp r0, r2 - beq _0804F9CC - adds r6, r5, 0 - movs r5, 0x58 - adds r2, r1, 0 -_0804F9B4: - adds r3, 0x1 - cmp r3, 0x3 - bgt _0804F9CC - lsls r1, r3, 1 - ldrb r0, [r6] - muls r0, r5 - adds r1, r0 - adds r1, r2 - ldrh r0, [r1] - ldrh r1, [r4] - cmp r0, r1 - bne _0804F9B4 -_0804F9CC: - cmp r3, 0x4 - beq _0804F9D2 - b _0804FD70 -_0804F9D2: - movs r0, 0 - strh r0, [r4] - b _0804FD70 - .pool -_0804F9E0: - ldr r0, =gBattleTypeFlags - ldr r0, [r0] - movs r1, 0xB - ands r0, r1 - cmp r0, 0x8 - beq _0804F9EE - b _0804FD70 -_0804F9EE: - ldr r1, =gBattleMons - ldrh r0, [r1, 0x28] - cmp r0, 0 - bne _0804F9F8 - b _0804FD70 -_0804F9F8: - adds r0, r1, 0 - adds r0, 0x80 - ldrh r0, [r0] - cmp r0, 0 - bne _0804FA04 - b _0804FD70 -_0804FA04: - ldr r0, =gHitMarker - ldr r1, [r0] - ldr r2, =0xffbfffff - ands r1, r2 - str r1, [r0] - b _0804FD70 - .pool -_0804FA20: - ldr r2, =gBattleCommunication - mov r8, r2 - movs r0, 0 - strb r0, [r2] - ldr r1, =gBattleScripting - ldr r6, =gActiveBank - ldrb r0, [r2, 0x1] - strb r0, [r6] - strb r0, [r1, 0x17] - ldr r0, =gBattleStruct - ldr r0, [r0] - adds r7, r0, 0 - adds r7, 0x92 - ldrb r3, [r7] - ldr r1, =gBitTable - ldrb r2, [r6] - lsls r0, r2, 2 - adds r0, r1 - ldr r5, [r0] - adds r0, r3, 0 - ands r0, r5 - cmp r0, 0 - beq _0804FA50 - b _0804FD70 -_0804FA50: - ldr r4, =gBattleMons - movs r0, 0x58 - mov r12, r0 - mov r1, r12 - muls r1, r2 - adds r2, r1, 0 - adds r1, r2, r4 - ldrh r0, [r1, 0x2C] - lsrs r0, 1 - ldrh r1, [r1, 0x28] - cmp r0, r1 - bcs _0804FA6A - b _0804FD70 -_0804FA6A: - cmp r1, 0 - bne _0804FA70 - b _0804FD70 -_0804FA70: - adds r0, r4, 0 - adds r0, 0x4C - adds r0, r2, r0 - ldr r0, [r0] - movs r1, 0x7 - ands r0, r1 - cmp r0, 0 - beq _0804FA82 - b _0804FD70 -_0804FA82: - orrs r3, r5 - strb r3, [r7] - movs r0, 0x1 - mov r2, r8 - strb r0, [r2] - ldrb r0, [r6] - mov r1, r12 - muls r1, r0 - adds r0, r1, 0 - adds r1, r4, 0 - adds r1, 0x48 - adds r0, r1 - ldr r0, [r0] - bl GetNatureFromPersonality - ldr r1, =gUnknown_0831C4F8 - lsls r0, 24 - lsrs r0, 24 - adds r0, r1 - ldrb r0, [r0] - mov r2, r8 - strb r0, [r2, 0x5] - b _0804FD70 - .pool -_0804FACC: - ldr r4, =gBattleCommunication - adds r0, r4, 0 - bl sub_81A5258 - lsls r0, 24 - lsrs r3, r0, 24 - cmp r3, 0 - bne _0804FADE - b _0804FD78 -_0804FADE: - strb r3, [r4, 0x1] - b _0804FD70 - .pool -_0804FAE8: - ldr r0, =gBattleMons - adds r0, 0x80 - movs r1, 0 - strh r1, [r0] - ldr r2, =gHitMarker - ldr r3, =gBitTable - ldr r1, [r3, 0x4] - lsls r1, 28 - ldr r0, [r2] - orrs r0, r1 - str r0, [r2] - ldr r0, =gBattleStruct - ldr r2, [r0] - ldr r0, =0x000002a1 - adds r2, r0 - ldr r0, =gBattlePartyID - ldrh r0, [r0, 0x2] - lsls r0, 2 - adds r0, r3 - ldr r0, [r0] - ldrb r1, [r2] - orrs r0, r1 - strb r0, [r2] - ldr r1, =gDisableStructs - adds r1, 0x34 - ldrb r0, [r1] - movs r2, 0x2 - b _0804FBF4 - .pool -_0804FB3C: - ldr r1, =gBattleMons - movs r0, 0 - strh r0, [r1, 0x28] - ldr r2, =gHitMarker - ldr r3, =gBitTable - ldr r1, [r3] - lsls r1, 28 - ldr r0, [r2] - orrs r0, r1 - movs r1, 0x80 - lsls r1, 15 - orrs r0, r1 - str r0, [r2] - ldr r0, =gBattleStruct - ldr r2, [r0] - movs r1, 0xA8 - lsls r1, 2 - adds r2, r1 - ldr r0, =gBattlePartyID - ldrh r0, [r0] - lsls r0, 2 - adds r0, r3 - ldr r0, [r0] - ldrb r1, [r2] - orrs r0, r1 - strb r0, [r2] - ldr r2, =gDisableStructs - ldrb r0, [r2, 0x18] - movs r1, 0x2 - orrs r0, r1 - strb r0, [r2, 0x18] - b _0804FD70 - .pool -_0804FB94: - ldr r0, =gBattleMons - movs r1, 0 - strh r1, [r0, 0x28] - adds r0, 0x80 - strh r1, [r0] - ldr r2, =gHitMarker - ldr r3, =gBitTable - ldr r0, [r3] - lsls r0, 28 - ldr r1, [r2] - orrs r1, r0 - ldr r0, [r3, 0x4] - lsls r0, 28 - orrs r1, r0 - movs r0, 0x80 - lsls r0, 15 - orrs r1, r0 - str r1, [r2] - ldr r5, =gBattleStruct - ldr r2, [r5] - movs r0, 0xA8 - lsls r0, 2 - adds r2, r0 - ldr r4, =gBattlePartyID - ldrh r0, [r4] - lsls r0, 2 - adds r0, r3 - ldr r0, [r0] - ldrb r1, [r2] - orrs r0, r1 - strb r0, [r2] - ldr r2, [r5] - ldr r1, =0x000002a1 - adds r2, r1 - ldrh r0, [r4, 0x2] - lsls r0, 2 - adds r0, r3 - ldr r0, [r0] - ldrb r1, [r2] - orrs r0, r1 - strb r0, [r2] - ldr r1, =gDisableStructs - ldrb r0, [r1, 0x18] - movs r2, 0x2 - orrs r0, r2 - strb r0, [r1, 0x18] - adds r1, 0x34 - ldrb r0, [r1] -_0804FBF4: - orrs r0, r2 - strb r0, [r1] - b _0804FD70 - .pool -_0804FC18: - movs r0, 0 - bl sub_8033E10 - ldr r0, =gActiveBank - ldrb r0, [r0] - bl MarkBufferBankForExecution - b _0804FD70 - .pool -_0804FC2C: - bl sub_81A5BF8 - b _0804FD70 -_0804FC32: - bl sub_81A5D44 - b _0804FD70 -_0804FC38: - ldr r1, =gRefereeStringsTable - ldr r0, =gBattlescriptCurrInstr - ldr r0, [r0] - ldrb r0, [r0, 0x1] - lsls r0, 2 - adds r0, r1 - ldr r0, [r0] - bl StrCpyDecodeToDisplayedStringBattle - ldr r0, =gDisplayedStringBattle - movs r1, 0x16 - bl sub_814F9EC - b _0804FD70 - .pool -_0804FC60: - movs r0, 0x16 - bl IsTextPrinterActive - lsls r0, 16 - b _0804FD24 -_0804FC6A: - bl IsCryFinished - lsls r0, 24 - cmp r0, 0 - bne _0804FC76 - b _0804FD78 -_0804FC76: - b _0804FD70 -_0804FC78: - ldr r4, =gActiveBank - movs r0, 0x1 - strb r0, [r4] - ldr r0, =gBattleMons - adds r0, 0x58 - b _0804FCA2 - .pool -_0804FC8C: - ldr r0, =gNoOfAllBanks - ldrb r0, [r0] - cmp r0, 0x3 - bls _0804FD70 - ldr r4, =gActiveBank - movs r0, 0x3 - strb r0, [r4] - ldr r0, =gBattleMons - movs r2, 0x84 - lsls r2, 1 - adds r0, r2 -_0804FCA2: - ldrh r0, [r0, 0x28] - cmp r0, 0 - beq _0804FD70 - movs r0, 0 - movs r1, 0 - bl EmitReturnPokeToBall - ldrb r0, [r4] - bl MarkBufferBankForExecution - b _0804FD70 - .pool -_0804FCC4: - ldr r0, =gMPlay_BGM - ldr r1, =0x0000ffff - movs r2, 0x55 - bl m4aMPlayVolumeControl - b _0804FD70 - .pool -_0804FCD8: - ldr r0, =gMPlay_BGM - ldr r1, =0x0000ffff - movs r2, 0x80 - lsls r2, 1 - bl m4aMPlayVolumeControl - b _0804FD70 - .pool -_0804FCF0: - ldr r0, =gBattleStruct - ldr r2, [r0] - ldr r0, =0x000002a2 - adds r2, r0 - ldr r1, =gBitTable - ldr r0, =gActiveBank - ldrb r0, [r0] - lsls r0, 2 - adds r0, r1 - ldr r0, [r0] - ldrb r1, [r2] - orrs r0, r1 - strb r0, [r2] - b _0804FD70 - .pool -_0804FD1C: - ldr r0, =gActiveBank - ldrb r0, [r0] - bl sub_805725C -_0804FD24: - cmp r0, 0 - bne _0804FD78 - b _0804FD70 - .pool -_0804FD30: - ldr r0, =gActiveBank - ldrb r0, [r0] - bl GetBankSide - lsls r0, 24 - cmp r0, 0 - bne _0804FD50 - ldr r1, =gBattleOutcome - movs r0, 0x5 - strb r0, [r1] - b _0804FD70 - .pool -_0804FD50: - ldr r1, =gBattleOutcome - movs r0, 0xA - strb r0, [r1] - b _0804FD70 - .pool -_0804FD5C: - movs r1, 0xCE - lsls r1, 1 - movs r0, 0 - movs r2, 0x1 - bl EmitPlaySound - ldr r0, =gActiveBank - ldrb r0, [r0] - bl MarkBufferBankForExecution -_0804FD70: - ldr r1, =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x3 - str r0, [r1] -_0804FD78: - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end atk76_various - - thumb_func_start atk77_setprotect -atk77_setprotect: @ 804FD8C - push {r4-r7,lr} - mov r7, r8 - push {r7} - movs r6, 0x1 - ldr r2, =gUnknown_02024260 - ldr r1, =gBankAttacker - ldrb r3, [r1] - lsls r0, r3, 1 - adds r0, r2 - ldrh r0, [r0] - mov r8, r1 - ldr r7, =gDisableStructs - cmp r0, 0xB6 - beq _0804FDBC - cmp r0, 0xC5 - beq _0804FDBC - cmp r0, 0xCB - beq _0804FDBC - lsls r0, r3, 3 - subs r0, r3 - lsls r0, 2 - adds r0, r7 - movs r1, 0 - strb r1, [r0, 0x8] -_0804FDBC: - ldr r0, =gCurrentMoveTurn - ldrb r1, [r0] - ldr r0, =gNoOfAllBanks - ldrb r0, [r0] - subs r0, 0x1 - cmp r1, r0 - bne _0804FDCC - movs r6, 0 -_0804FDCC: - ldr r2, =sProtectSuccessRates - mov r5, r8 - ldrb r1, [r5] - lsls r0, r1, 3 - subs r0, r1 - lsls r0, 2 - adds r0, r7 - ldrb r4, [r0, 0x8] - lsls r4, 1 - adds r4, r2 - bl Random - ldrh r1, [r4] - lsls r0, 16 - lsrs r0, 16 - cmp r1, r0 - bcc _0804FE80 - cmp r6, 0 - beq _0804FE80 - ldr r4, =gBattleMoves - ldr r3, =gCurrentMove - ldrh r0, [r3] - lsls r1, r0, 1 - adds r1, r0 - lsls r1, 2 - adds r1, r4 - ldrb r0, [r1] - cmp r0, 0x6F - bne _0804FE1C - ldr r0, =gProtectStructs - ldrb r1, [r5] - lsls r1, 4 - adds r1, r0 - ldrb r0, [r1] - movs r2, 0x1 - orrs r0, r2 - strb r0, [r1] - ldr r1, =gBattleCommunication - movs r0, 0 - strb r0, [r1, 0x5] -_0804FE1C: - ldrh r0, [r3] - lsls r1, r0, 1 - adds r1, r0 - lsls r1, 2 - adds r1, r4 - ldrb r0, [r1] - cmp r0, 0x74 - bne _0804FE42 - ldr r0, =gProtectStructs - ldrb r1, [r5] - lsls r1, 4 - adds r1, r0 - ldrb r0, [r1] - movs r2, 0x2 - orrs r0, r2 - strb r0, [r1] - ldr r1, =gBattleCommunication - movs r0, 0x1 - strb r0, [r1, 0x5] -_0804FE42: - mov r1, r8 - ldrb r0, [r1] - lsls r1, r0, 3 - subs r1, r0 - lsls r1, 2 - adds r1, r7 - ldrb r0, [r1, 0x8] - adds r0, 0x1 - strb r0, [r1, 0x8] - b _0804FEA2 - .pool -_0804FE80: - ldr r2, =gDisableStructs - ldr r0, =gBankAttacker - ldrb r1, [r0] - lsls r0, r1, 3 - subs r0, r1 - lsls r0, 2 - adds r0, r2 - movs r1, 0 - strb r1, [r0, 0x8] - ldr r1, =gBattleCommunication - movs r0, 0x2 - strb r0, [r1, 0x5] - ldr r2, =gBattleMoveFlags - ldrb r0, [r2] - movs r1, 0x1 - orrs r0, r1 - strb r0, [r2] -_0804FEA2: - ldr r1, =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x1 - str r0, [r1] - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end atk77_setprotect - - thumb_func_start atk78_faintifabilitynotdamp -atk78_faintifabilitynotdamp: @ 804FEC8 - push {r4-r7,lr} - mov r7, r8 - push {r7} - ldr r0, =gBattleExecBuffer - ldr r2, [r0] - cmp r2, 0 - bne _0804FFCC - ldr r1, =gBankTarget - strb r2, [r1] - ldr r0, =gNoOfAllBanks - ldrb r3, [r0] - adds r5, r1, 0 - mov r8, r0 - ldr r6, =gBattleMons - cmp r2, r3 - bcs _0804FF14 - adds r0, r6, 0 - adds r0, 0x20 - ldrb r0, [r0] - cmp r0, 0x6 - beq _0804FF14 - adds r2, r3, 0 - adds r4, r6, 0 - movs r3, 0x58 -_0804FEF8: - ldrb r0, [r1] - adds r0, 0x1 - strb r0, [r1] - lsls r0, 24 - lsrs r0, 24 - cmp r0, r2 - bcs _0804FF14 - ldrb r0, [r5] - muls r0, r3 - adds r0, r4 - adds r0, 0x20 - ldrb r0, [r0] - cmp r0, 0x6 - bne _0804FEF8 -_0804FF14: - ldrb r0, [r5] - mov r1, r8 - ldrb r1, [r1] - cmp r0, r1 - bne _0804FFB0 - ldr r4, =gActiveBank - ldr r7, =gBankAttacker - ldrb r0, [r7] - strb r0, [r4] - ldr r2, =gBattleMoveDamage - ldrb r1, [r4] - movs r0, 0x58 - muls r0, r1 - adds r0, r6 - ldrh r0, [r0, 0x28] - str r0, [r2] - ldr r1, =0x00007fff - movs r0, 0 - bl EmitHealthBarUpdate - ldrb r0, [r4] - bl MarkBufferBankForExecution - ldr r1, =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x1 - str r0, [r1] - movs r0, 0 - strb r0, [r5] - mov r2, r8 - ldrb r0, [r2] - cmp r0, 0 - beq _0804FFCC - adds r3, r5, 0 - ldrb r5, [r7] - ldr r7, =gBitTable - adds r4, r0, 0 - ldr r6, =gAbsentBankFlags -_0804FF60: - ldrb r2, [r3] - cmp r2, r5 - beq _0804FF76 - ldrb r0, [r6] - ldrb r1, [r3] - lsls r1, 2 - adds r1, r7 - ldr r1, [r1] - ands r0, r1 - cmp r0, 0 - beq _0804FFCC -_0804FF76: - adds r0, r2, 0x1 - strb r0, [r3] - lsls r0, 24 - lsrs r0, 24 - cmp r0, r4 - bcc _0804FF60 - b _0804FFCC - .pool -_0804FFB0: - ldr r1, =gLastUsedAbility - movs r0, 0x6 - strb r0, [r1] - ldrb r0, [r5] - movs r1, 0x58 - muls r1, r0 - adds r1, r6 - adds r1, 0x20 - ldrb r1, [r1] - bl RecordAbilityBattle - ldr r1, =gBattlescriptCurrInstr - ldr r0, =gUnknown_082DB560 - str r0, [r1] -_0804FFCC: - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end atk78_faintifabilitynotdamp - - thumb_func_start atk79_setatkhptozero -atk79_setatkhptozero: @ 804FFE4 - push {r4,lr} - sub sp, 0x4 - ldr r0, =gBattleExecBuffer - ldr r3, [r0] - cmp r3, 0 - bne _08050028 - ldr r4, =gActiveBank - ldr r0, =gBankAttacker - ldrb r0, [r0] - strb r0, [r4] - ldr r1, =gBattleMons - ldrb r0, [r4] - movs r2, 0x58 - muls r0, r2 - adds r0, r1 - strh r3, [r0, 0x28] - ldrb r0, [r4] - muls r0, r2 - adds r1, 0x28 - adds r0, r1 - str r0, [sp] - movs r0, 0 - movs r1, 0x2A - movs r2, 0 - movs r3, 0x2 - bl EmitSetAttributes - ldrb r0, [r4] - bl MarkBufferBankForExecution - ldr r1, =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x1 - str r0, [r1] -_08050028: - add sp, 0x4 - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end atk79_setatkhptozero - - thumb_func_start atk7A_jumpwhiletargetvalid -atk7A_jumpwhiletargetvalid: @ 8050044 - push {r4-r7,lr} - ldr r3, =gBattlescriptCurrInstr - ldr r2, [r3] - ldrb r4, [r2, 0x1] - ldrb r0, [r2, 0x2] - lsls r0, 8 - orrs r4, r0 - ldrb r0, [r2, 0x3] - lsls r0, 16 - orrs r4, r0 - ldrb r0, [r2, 0x4] - lsls r0, 24 - orrs r4, r0 - ldr r0, =gBattleTypeFlags - ldr r0, [r0] - movs r1, 0x1 - ands r0, r1 - adds r7, r3, 0 - cmp r0, 0 - beq _080500DC - ldr r0, =gBankTarget - ldrb r1, [r0] - adds r1, 0x1 - strb r1, [r0] - ldr r2, =gBankAttacker - lsls r1, 24 - lsrs r1, 24 - adds r3, r0, 0 - ldr r6, =gAbsentBankFlags - ldr r5, =gBitTable - ldr r0, =gNoOfAllBanks - mov r12, r0 - ldrb r0, [r2] - cmp r1, r0 - bne _0805009A -_0805008A: - ldrb r0, [r3] - adds r0, 0x1 - strb r0, [r3] - lsls r0, 24 - lsrs r0, 24 - ldrb r1, [r2] - cmp r0, r1 - beq _0805008A -_0805009A: - ldrb r0, [r6] - ldrb r1, [r3] - lsls r1, 2 - adds r1, r5 - ldr r1, [r1] - ands r0, r1 - cmp r0, 0 - bne _0805008A - ldrb r0, [r3] - mov r2, r12 - ldrb r2, [r2] - cmp r0, r2 - bcc _080500D8 - ldr r0, [r7] - adds r0, 0x5 - str r0, [r7] - b _080500E0 - .pool -_080500D8: - str r4, [r7] - b _080500E0 -_080500DC: - adds r0, r2, 0x5 - str r0, [r3] -_080500E0: - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end atk7A_jumpwhiletargetvalid - - thumb_func_start atk7B_healhalfHP_if_possible -atk7B_healhalfHP_if_possible: @ 80500E8 - push {r4-r6,lr} - ldr r4, =gBattlescriptCurrInstr - ldr r1, [r4] - ldrb r2, [r1, 0x1] - ldrb r0, [r1, 0x2] - lsls r0, 8 - orrs r2, r0 - ldrb r0, [r1, 0x3] - lsls r0, 16 - orrs r2, r0 - ldrb r0, [r1, 0x4] - lsls r0, 24 - orrs r2, r0 - ldrb r0, [r1, 0x5] - ldr r3, =gBankTarget - cmp r0, 0x1 - bne _08050110 - ldr r0, =gBankAttacker - ldrb r0, [r0] - strb r0, [r3] -_08050110: - ldr r1, =gBattleMoveDamage - ldr r6, =gBattleMons - ldrb r0, [r3] - movs r5, 0x58 - muls r0, r5 - adds r0, r6 - ldrh r0, [r0, 0x2C] - lsrs r0, 1 - str r0, [r1] - cmp r0, 0 - bne _0805012A - movs r0, 0x1 - str r0, [r1] -_0805012A: - ldr r0, [r1] - negs r0, r0 - str r0, [r1] - ldrb r0, [r3] - muls r0, r5 - adds r0, r6 - ldrh r1, [r0, 0x28] - ldrh r0, [r0, 0x2C] - cmp r1, r0 - bne _08050158 - str r2, [r4] - b _0805015E - .pool -_08050158: - ldr r0, [r4] - adds r0, 0x6 - str r0, [r4] -_0805015E: - pop {r4-r6} - pop {r0} - bx r0 - thumb_func_end atk7B_healhalfHP_if_possible - - thumb_func_start atk7C_8025508 -atk7C_8025508: @ 8050164 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x8 - ldr r2, =gNoOfAllBanks - ldr r0, =gBankAttacker - mov r10, r0 - movs r1, 0 - add r0, sp, 0x4 -_0805017A: - strh r1, [r0] - subs r0, 0x2 - cmp r0, sp - bge _0805017A - movs r1, 0 - mov r8, r1 - movs r5, 0 - ldrb r1, [r2] - cmp r5, r1 - bge _080501D0 - ldr r0, =gBankAttacker - ldrb r6, [r0] - ldr r2, =0x0000ffff - mov r9, r2 - lsls r4, r6, 3 - mov r2, sp - ldr r0, =gBattleStruct - mov r12, r0 - adds r7, r1, 0 -_080501A0: - cmp r5, r6 - beq _080501C8 - mov r1, r12 - ldr r0, [r1] - adds r0, r4, r0 - adds r1, r0, 0 - adds r1, 0xE0 - ldrb r3, [r1] - adds r0, 0xE1 - ldrb r0, [r0] - lsls r0, 8 - orrs r3, r0 - cmp r3, 0 - beq _080501C8 - cmp r3, r9 - beq _080501C8 - strh r3, [r2] - adds r2, 0x2 - movs r0, 0x1 - add r8, r0 -_080501C8: - adds r4, 0x2 - adds r5, 0x1 - cmp r5, r7 - blt _080501A0 -_080501D0: - mov r1, r10 - ldrb r0, [r1] - ldr r2, =gBattleStruct - ldr r1, [r2] - lsls r0, 1 - adds r0, r1 - adds r1, r0, 0 - adds r1, 0x98 - ldrb r3, [r1] - adds r0, 0x99 - ldrb r0, [r0] - lsls r0, 8 - orrs r3, r0 - cmp r3, 0 - beq _08050220 - ldr r0, =0x0000ffff - cmp r3, r0 - beq _08050220 - ldr r2, =gHitMarker - ldr r0, [r2] - ldr r1, =0xfffffbff - ands r0, r1 - str r0, [r2] - ldr r4, =gCurrentMove - strh r3, [r4] - b _0805024A - .pool -_08050220: - mov r0, r8 - cmp r0, 0 - beq _08050290 - ldr r2, =gHitMarker - ldr r0, [r2] - ldr r1, =0xfffffbff - ands r0, r1 - str r0, [r2] - bl Random - lsls r0, 16 - lsrs r0, 16 - mov r1, r8 - bl __modsi3 - adds r5, r0, 0 - ldr r4, =gCurrentMove - lsls r0, r5, 1 - add r0, sp - ldrh r0, [r0] - strh r0, [r4] -_0805024A: - ldrh r0, [r4] - movs r1, 0 - bl GetMoveTarget - ldr r1, =gBankTarget - strb r0, [r1] - ldr r5, =gBattlescriptCurrInstr - ldr r3, =gBattleScriptsForMoveEffects - ldr r2, =gBattleMoves - ldrh r1, [r4] - lsls r0, r1, 1 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - ldrb r0, [r0] - lsls r0, 2 - adds r0, r3 - ldr r0, [r0] - str r0, [r5] - b _080502AE - .pool -_08050290: - ldr r2, =gSpecialStatuses - mov r0, r10 - ldrb r1, [r0] - lsls r0, r1, 2 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - ldrb r1, [r0] - movs r2, 0x20 - orrs r1, r2 - strb r1, [r0] - ldr r1, =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x1 - str r0, [r1] -_080502AE: - 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 atk7C_8025508 - - thumb_func_start atk7D_set_rain -atk7D_set_rain: @ 80502C8 - push {lr} - ldr r2, =gBattleWeather - ldrh r0, [r2] - movs r1, 0x7 - ands r1, r0 - cmp r1, 0 - beq _080502F4 - ldr r2, =gBattleMoveFlags - ldrb r0, [r2] - movs r1, 0x1 - orrs r0, r1 - strb r0, [r2] - ldr r1, =gBattleCommunication - movs r0, 0x2 - strb r0, [r1, 0x5] - b _08050304 - .pool -_080502F4: - movs r0, 0x1 - strh r0, [r2] - ldr r0, =gBattleCommunication - strb r1, [r0, 0x5] - ldr r0, =gWishFutureKnock - adds r0, 0x28 - movs r1, 0x5 - strb r1, [r0] -_08050304: - ldr r1, =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x1 - str r0, [r1] - pop {r0} - bx r0 - .pool - thumb_func_end atk7D_set_rain - - thumb_func_start atk7E_setreflect -atk7E_setreflect: @ 805031C - push {r4-r6,lr} - ldr r6, =gBankAttacker - ldrb r0, [r6] - bl GetBankIdentity - ldr r4, =gSideAffecting - movs r5, 0x1 - adds r1, r5, 0 - ands r1, r0 - lsls r1, 1 - adds r1, r4 - ldrh r1, [r1] - adds r0, r5, 0 - ands r0, r1 - cmp r0, 0 - beq _0805035C - ldr r2, =gBattleMoveFlags - ldrb r0, [r2] - movs r1, 0x1 - orrs r0, r1 - strb r0, [r2] - ldr r1, =gBattleCommunication - movs r0, 0 - b _080503D0 - .pool -_0805035C: - ldrb r0, [r6] - bl GetBankIdentity - adds r1, r5, 0 - ands r1, r0 - lsls r1, 1 - adds r1, r4 - ldrh r0, [r1] - movs r2, 0x1 - orrs r0, r2 - strh r0, [r1] - ldrb r0, [r6] - bl GetBankIdentity - ldr r4, =gSideTimers - adds r1, r5, 0 - ands r1, r0 - lsls r0, r1, 1 - adds r0, r1 - lsls r0, 2 - adds r0, r4 - movs r1, 0x5 - strb r1, [r0] - ldrb r0, [r6] - bl GetBankIdentity - adds r1, r5, 0 - ands r1, r0 - lsls r0, r1, 1 - adds r0, r1 - lsls r0, 2 - adds r0, r4 - ldrb r1, [r6] - strb r1, [r0, 0x1] - ldr r0, =gBattleTypeFlags - ldr r0, [r0] - ands r0, r5 - cmp r0, 0 - beq _080503CC - movs r0, 0x1 - bl CountAliveMonsInBattle - lsls r0, 24 - lsrs r1, r0, 24 - cmp r1, 0x2 - bne _080503CC - ldr r0, =gBattleCommunication - strb r1, [r0, 0x5] - b _080503D2 - .pool -_080503CC: - ldr r1, =gBattleCommunication - movs r0, 0x1 -_080503D0: - strb r0, [r1, 0x5] -_080503D2: - ldr r1, =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x1 - str r0, [r1] - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end atk7E_setreflect - - thumb_func_start atk7F_setseeded -atk7F_setseeded: @ 80503E8 - push {r4-r7,lr} - mov r7, r9 - mov r6, r8 - push {r6,r7} - ldr r7, =gBattleMoveFlags - ldrb r5, [r7] - movs r0, 0x29 - ands r0, r5 - cmp r0, 0 - bne _0805041A - ldr r0, =gStatuses3 - mov r9, r0 - ldr r1, =gBankTarget - mov r8, r1 - ldrb r4, [r1] - lsls r0, r4, 2 - mov r2, r9 - adds r6, r0, r2 - ldr r2, [r6] - movs r0, 0x4 - mov r12, r0 - adds r3, r2, 0 - ands r3, r0 - cmp r3, 0 - beq _08050438 -_0805041A: - movs r0, 0x1 - orrs r0, r5 - strb r0, [r7] - ldr r1, =gBattleCommunication - movs r0, 0x1 - strb r0, [r1, 0x5] - b _08050488 - .pool -_08050438: - ldr r1, =gBattleMons - movs r0, 0x58 - muls r0, r4 - adds r1, r0, r1 - adds r0, r1, 0 - adds r0, 0x21 - ldrb r0, [r0] - cmp r0, 0xC - beq _08050454 - adds r0, r1, 0 - adds r0, 0x22 - ldrb r0, [r0] - cmp r0, 0xC - bne _0805046C -_08050454: - movs r0, 0x1 - orrs r0, r5 - strb r0, [r7] - ldr r1, =gBattleCommunication - movs r0, 0x2 - strb r0, [r1, 0x5] - b _08050488 - .pool -_0805046C: - ldr r0, =gBankAttacker - ldrb r0, [r0] - orrs r2, r0 - str r2, [r6] - mov r2, r8 - ldrb r1, [r2] - lsls r1, 2 - add r1, r9 - ldr r0, [r1] - mov r2, r12 - orrs r0, r2 - str r0, [r1] - ldr r0, =gBattleCommunication - strb r3, [r0, 0x5] -_08050488: - ldr r1, =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x1 - str r0, [r1] - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end atk7F_setseeded - - thumb_func_start atk80_manipulatedamage -atk80_manipulatedamage: @ 80504A8 - push {r4,lr} - ldr r1, =gBattlescriptCurrInstr - ldr r0, [r1] - ldrb r2, [r0, 0x1] - adds r4, r1, 0 - cmp r2, 0x1 - beq _080504D8 - cmp r2, 0x1 - bgt _080504C4 - cmp r2, 0 - beq _080504CA - b _08050518 - .pool -_080504C4: - cmp r2, 0x2 - beq _08050510 - b _08050518 -_080504CA: - ldr r1, =gBattleMoveDamage - ldr r0, [r1] - negs r0, r0 - b _08050516 - .pool -_080504D8: - ldr r3, =gBattleMoveDamage - ldr r0, [r3] - lsrs r1, r0, 31 - adds r0, r1 - asrs r0, 1 - str r0, [r3] - cmp r0, 0 - bne _080504EA - str r2, [r3] -_080504EA: - ldr r2, =gBattleMons - ldr r0, =gBankTarget - ldrb r1, [r0] - movs r0, 0x58 - muls r0, r1 - adds r0, r2 - ldrh r0, [r0, 0x2C] - lsrs r1, r0, 1 - ldr r0, [r3] - cmp r1, r0 - bge _08050518 - str r1, [r3] - b _08050518 - .pool -_08050510: - ldr r1, =gBattleMoveDamage - ldr r0, [r1] - lsls r0, 1 -_08050516: - str r0, [r1] -_08050518: - ldr r0, [r4] - adds r0, 0x2 - str r0, [r4] - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end atk80_manipulatedamage - - thumb_func_start atk81_setrest -atk81_setrest: @ 8050528 - push {r4-r7,lr} - sub sp, 0x4 - ldr r0, =gBattlescriptCurrInstr - mov r12, r0 - ldr r1, [r0] - ldrb r6, [r1, 0x1] - ldrb r0, [r1, 0x2] - lsls r0, 8 - orrs r6, r0 - ldrb r0, [r1, 0x3] - lsls r0, 16 - orrs r6, r0 - ldrb r0, [r1, 0x4] - lsls r0, 24 - orrs r6, r0 - ldr r5, =gActiveBank - ldr r2, =gBankTarget - ldr r0, =gBankAttacker - ldrb r0, [r0] - strb r0, [r2] - strb r0, [r5] - ldr r4, =gBattleMoveDamage - ldr r1, =gBattleMons - ldrb r0, [r2] - movs r3, 0x58 - muls r0, r3 - adds r0, r1 - ldrh r0, [r0, 0x2C] - negs r0, r0 - str r0, [r4] - ldrb r0, [r2] - adds r4, r0, 0 - muls r4, r3 - adds r0, r4, r1 - ldrh r3, [r0, 0x28] - adds r7, r5, 0 - adds r5, r2, 0 - adds r2, r1, 0 - ldrh r0, [r0, 0x2C] - cmp r3, r0 - bne _08050598 - mov r0, r12 - str r6, [r0] - b _080505E8 - .pool -_08050598: - adds r0, r2, 0 - adds r0, 0x4C - adds r0, r4, r0 - ldr r1, [r0] - movs r0, 0xF8 - ands r1, r0 - cmp r1, 0 - beq _080505B4 - ldr r1, =gBattleCommunication - movs r0, 0x1 - strb r0, [r1, 0x5] - b _080505B8 - .pool -_080505B4: - ldr r0, =gBattleCommunication - strb r1, [r0, 0x5] -_080505B8: - ldrb r0, [r5] - movs r3, 0x58 - muls r0, r3 - adds r2, 0x4C - adds r0, r2 - movs r1, 0x3 - str r1, [r0] - ldrb r0, [r7] - muls r0, r3 - adds r0, r2 - str r0, [sp] - movs r0, 0 - movs r1, 0x28 - movs r2, 0 - movs r3, 0x4 - bl EmitSetAttributes - ldrb r0, [r7] - bl MarkBufferBankForExecution - ldr r1, =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x5 - str r0, [r1] -_080505E8: - add sp, 0x4 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end atk81_setrest - - thumb_func_start atk82_jumpifnotfirstturn -atk82_jumpifnotfirstturn: @ 80505F8 - push {r4,r5,lr} - ldr r5, =gBattlescriptCurrInstr - ldr r4, [r5] - ldrb r3, [r4, 0x1] - ldrb r0, [r4, 0x2] - lsls r0, 8 - orrs r3, r0 - ldrb r0, [r4, 0x3] - lsls r0, 16 - orrs r3, r0 - ldrb r0, [r4, 0x4] - lsls r0, 24 - orrs r3, r0 - ldr r2, =gDisableStructs - ldr r0, =gBankAttacker - ldrb r1, [r0] - lsls r0, r1, 3 - subs r0, r1 - lsls r0, 2 - adds r0, r2 - ldrb r0, [r0, 0x16] - cmp r0, 0 - beq _08050638 - adds r0, r4, 0x5 - str r0, [r5] - b _0805063A - .pool -_08050638: - str r3, [r5] -_0805063A: - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end atk82_jumpifnotfirstturn - - thumb_func_start atk83_nop -atk83_nop: @ 8050640 - ldr r1, =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x1 - str r0, [r1] - bx lr - .pool - thumb_func_end atk83_nop - - thumb_func_start UproarWakeUpCheck -UproarWakeUpCheck: @ 8050650 - push {r4-r7,lr} - mov r7, r8 - push {r7} - lsls r0, 24 - lsrs r3, r0, 24 - movs r2, 0 - ldr r0, =gNoOfAllBanks - ldrb r1, [r0] - mov r8, r0 - cmp r2, r1 - bge _080506C4 - ldr r0, =gBattleMons - mov r12, r0 - movs r0, 0x58 - muls r0, r3 - add r0, r12 - adds r5, r0, 0 - adds r5, 0x20 - adds r4, r1, 0 - movs r3, 0 - ldr r6, =gBattleScripting - ldr r7, =gBattleCommunication -_0805067C: - mov r0, r12 - adds r0, 0x50 - adds r0, r3, r0 - ldr r0, [r0] - movs r1, 0x70 - ands r0, r1 - cmp r0, 0 - beq _080506BC - ldrb r0, [r5] - cmp r0, 0x2B - beq _080506BC - movs r3, 0 - strb r2, [r6, 0x17] - ldr r1, =gBankTarget - ldrb r0, [r1] - cmp r0, 0xFF - beq _080506DC - cmp r0, r2 - beq _080506D0 - movs r0, 0x1 - strb r0, [r7, 0x5] - b _080506C4 - .pool -_080506BC: - adds r3, 0x58 - adds r2, 0x1 - cmp r2, r4 - blt _0805067C -_080506C4: - mov r1, r8 - ldrb r1, [r1] - cmp r2, r1 - beq _080506E0 - movs r0, 0x1 - b _080506E2 -_080506D0: - ldr r0, =gBattleCommunication - strb r3, [r0, 0x5] - b _080506C4 - .pool -_080506DC: - strb r2, [r1] - b _080506C4 -_080506E0: - movs r0, 0 -_080506E2: - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r1} - bx r1 - thumb_func_end UproarWakeUpCheck - - thumb_func_start atk84_jump_if_cant_sleep -atk84_jump_if_cant_sleep: @ 80506EC - push {r4-r6,lr} - ldr r5, =gBattlescriptCurrInstr - ldr r1, [r5] - ldrb r4, [r1, 0x1] - ldrb r0, [r1, 0x2] - lsls r0, 8 - orrs r4, r0 - ldrb r0, [r1, 0x3] - lsls r0, 16 - orrs r4, r0 - ldrb r0, [r1, 0x4] - lsls r0, 24 - orrs r4, r0 - ldr r6, =gBankTarget - ldrb r0, [r6] - bl UproarWakeUpCheck - lsls r0, 24 - cmp r0, 0 - beq _08050720 - str r4, [r5] - b _08050762 - .pool -_08050720: - ldr r1, =gBattleMons - ldrb r3, [r6] - movs r0, 0x58 - muls r0, r3 - adds r0, r1 - adds r0, 0x20 - ldrb r0, [r0] - adds r1, r0, 0 - cmp r1, 0xF - beq _08050738 - cmp r1, 0x48 - bne _0805075C -_08050738: - ldr r2, =gLastUsedAbility - strb r0, [r2] - ldr r1, =gBattleCommunication - movs r0, 0x2 - strb r0, [r1, 0x5] - str r4, [r5] - ldrb r1, [r2] - adds r0, r3, 0 - bl RecordAbilityBattle - b _08050762 - .pool -_0805075C: - ldr r0, [r5] - adds r0, 0x5 - str r0, [r5] -_08050762: - pop {r4-r6} - pop {r0} - bx r0 - thumb_func_end atk84_jump_if_cant_sleep - - thumb_func_start atk85_stockpile -atk85_stockpile: @ 8050768 - push {r4,r5,lr} - ldr r5, =gDisableStructs - ldr r4, =gBankAttacker - ldrb r1, [r4] - lsls r0, r1, 3 - subs r0, r1 - lsls r0, 2 - adds r1, r0, r5 - ldrb r0, [r1, 0x9] - cmp r0, 0x3 - bne _080507A0 - ldr r2, =gBattleMoveFlags - ldrb r0, [r2] - movs r1, 0x1 - orrs r0, r1 - strb r0, [r2] - ldr r1, =gBattleCommunication - movs r0, 0x1 - strb r0, [r1, 0x5] - b _080507CA - .pool -_080507A0: - adds r0, 0x1 - movs r3, 0 - strb r0, [r1, 0x9] - ldr r2, =gBattleTextBuff1 - movs r0, 0xFD - strb r0, [r2] - movs r0, 0x1 - strb r0, [r2, 0x1] - strb r0, [r2, 0x2] - strb r0, [r2, 0x3] - ldrb r1, [r4] - lsls r0, r1, 3 - subs r0, r1 - lsls r0, 2 - adds r0, r5 - ldrb r0, [r0, 0x9] - strb r0, [r2, 0x4] - movs r0, 0xFF - strb r0, [r2, 0x5] - ldr r0, =gBattleCommunication - strb r3, [r0, 0x5] -_080507CA: - ldr r1, =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x1 - str r0, [r1] - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end atk85_stockpile - - thumb_func_start atk86_stockpiletobasedamage -atk86_stockpiletobasedamage: @ 80507E4 - push {r4-r7,lr} - mov r7, r8 - push {r7} - sub sp, 0x10 - ldr r3, =gBattlescriptCurrInstr - ldr r1, [r3] - ldrb r2, [r1, 0x1] - ldrb r0, [r1, 0x2] - lsls r0, 8 - orrs r2, r0 - ldrb r0, [r1, 0x3] - lsls r0, 16 - orrs r2, r0 - ldrb r0, [r1, 0x4] - lsls r0, 24 - orrs r2, r0 - ldr r7, =gDisableStructs - ldr r6, =gBankAttacker - ldrb r1, [r6] - lsls r0, r1, 3 - subs r0, r1 - lsls r0, 2 - adds r0, r7 - ldrb r0, [r0, 0x9] - cmp r0, 0 - bne _08050828 - str r2, [r3] - b _080508CA - .pool -_08050828: - ldr r0, =gBattleCommunication - ldrb r0, [r0, 0x6] - cmp r0, 0x1 - beq _080508B0 - ldr r0, =gBattleMoveDamage - mov r8, r0 - ldr r4, =gSideAffecting - ldr r5, =gBankTarget - ldrb r0, [r5] - bl GetBankIdentity - movs r1, 0x1 - ands r1, r0 - lsls r1, 1 - adds r1, r4 - ldrh r3, [r1] - ldrb r0, [r6] - movs r4, 0x58 - muls r0, r4 - ldr r2, =gBattleMons - adds r0, r2 - ldrb r1, [r5] - muls r1, r4 - adds r1, r2 - ldr r2, =gCurrentMove - ldrh r2, [r2] - movs r4, 0 - str r4, [sp] - str r4, [sp, 0x4] - ldrb r4, [r6] - str r4, [sp, 0x8] - ldrb r4, [r5] - str r4, [sp, 0xC] - bl CalculateBaseDamage - ldrb r2, [r6] - lsls r1, r2, 3 - subs r1, r2 - lsls r1, 2 - adds r1, r7 - ldrb r1, [r1, 0x9] - adds r3, r0, 0 - muls r3, r1 - mov r1, r8 - str r3, [r1] - ldr r2, =gBattleScripting - ldrb r1, [r6] - lsls r0, r1, 3 - subs r0, r1 - lsls r0, 2 - adds r0, r7 - ldrb r0, [r0, 0x9] - strb r0, [r2, 0x18] - ldr r1, =gProtectStructs - ldrb r0, [r6] - lsls r0, 4 - adds r0, r1 - ldrb r0, [r0] - lsls r0, 28 - cmp r0, 0 - bge _080508B0 - lsls r0, r3, 4 - subs r0, r3 - movs r1, 0xA - bl __divsi3 - mov r1, r8 - str r0, [r1] -_080508B0: - ldr r2, =gDisableStructs - ldr r0, =gBankAttacker - ldrb r1, [r0] - lsls r0, r1, 3 - subs r0, r1 - lsls r0, 2 - adds r0, r2 - movs r1, 0 - strb r1, [r0, 0x9] - ldr r1, =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x5 - str r0, [r1] -_080508CA: - add sp, 0x10 - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end atk86_stockpiletobasedamage - - thumb_func_start atk87_stockpiletohpheal -atk87_stockpiletohpheal: @ 8050904 - push {r4-r7,lr} - mov r7, r8 - push {r7} - ldr r7, =gBattlescriptCurrInstr - ldr r1, [r7] - ldrb r2, [r1, 0x1] - ldrb r0, [r1, 0x2] - lsls r0, 8 - orrs r2, r0 - ldrb r0, [r1, 0x3] - lsls r0, 16 - orrs r2, r0 - ldrb r0, [r1, 0x4] - lsls r0, 24 - orrs r2, r0 - ldr r0, =gDisableStructs - mov r8, r0 - ldr r6, =gBankAttacker - ldrb r3, [r6] - lsls r0, r3, 3 - subs r0, r3 - lsls r0, 2 - mov r1, r8 - adds r4, r0, r1 - ldrb r1, [r4, 0x9] - cmp r1, 0 - bne _08050954 - str r2, [r7] - ldr r0, =gBattleCommunication - strb r1, [r0, 0x5] - b _080509D0 - .pool -_08050954: - ldr r1, =gBattleMons - movs r0, 0x58 - muls r0, r3 - adds r1, r0, r1 - ldrh r0, [r1, 0x2C] - ldrh r3, [r1, 0x28] - cmp r0, r3 - bne _08050984 - movs r0, 0 - strb r0, [r4, 0x9] - str r2, [r7] - ldr r1, =gBankTarget - ldrb r0, [r6] - strb r0, [r1] - ldr r1, =gBattleCommunication - movs r0, 0x1 - strb r0, [r1, 0x5] - b _080509D0 - .pool -_08050984: - ldr r5, =gBattleMoveDamage - ldrh r0, [r1, 0x2C] - ldrb r1, [r4, 0x9] - movs r2, 0x3 - subs r2, r1 - movs r4, 0x1 - adds r1, r4, 0 - lsls r1, r2 - bl __divsi3 - str r0, [r5] - cmp r0, 0 - bne _080509A0 - str r4, [r5] -_080509A0: - ldr r0, [r5] - negs r0, r0 - str r0, [r5] - ldr r3, =gBattleScripting - ldrb r1, [r6] - lsls r0, r1, 3 - subs r0, r1 - lsls r0, 2 - add r0, r8 - ldrb r0, [r0, 0x9] - movs r2, 0 - strb r0, [r3, 0x18] - ldrb r1, [r6] - lsls r0, r1, 3 - subs r0, r1 - lsls r0, 2 - add r0, r8 - strb r2, [r0, 0x9] - ldr r0, [r7] - adds r0, 0x5 - str r0, [r7] - ldr r1, =gBankTarget - ldrb r0, [r6] - strb r0, [r1] -_080509D0: - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end atk87_stockpiletohpheal - - thumb_func_start atk88_negativedamage -atk88_negativedamage: @ 80509E8 - push {lr} - ldr r2, =gBattleMoveDamage - ldr r0, =gHpDealt - ldr r0, [r0] - lsrs r1, r0, 31 - adds r0, r1 - asrs r0, 1 - negs r0, r0 - str r0, [r2] - cmp r0, 0 - bne _08050A04 - movs r0, 0x1 - negs r0, r0 - str r0, [r2] -_08050A04: - ldr r1, =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x1 - str r0, [r1] - pop {r0} - bx r0 - .pool - thumb_func_end atk88_negativedamage - - thumb_func_start ChangeStatBuffs -ChangeStatBuffs: @ 8050A1C - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - mov r8, r3 - lsls r0, 24 - lsrs r6, r0, 24 - lsls r1, 24 - lsrs r7, r1, 24 - lsls r2, 24 - lsrs r5, r2, 24 - movs r0, 0 - mov r9, r0 - mov r10, r0 - movs r0, 0x40 - ands r0, r5 - cmp r0, 0 - beq _08050A50 - ldr r0, =gActiveBank - ldr r1, =gBankAttacker - b _08050A54 - .pool -_08050A50: - ldr r0, =gActiveBank - ldr r1, =gBankTarget -_08050A54: - ldrb r1, [r1] - strb r1, [r0] - movs r0, 0xBF - ands r5, r0 - movs r0, 0x80 - ands r0, r5 - cmp r0, 0 - beq _08050A6E - mov r0, r9 - adds r0, 0x1 - lsls r0, 24 - lsrs r0, 24 - mov r9, r0 -_08050A6E: - movs r0, 0x7F - ands r5, r0 - movs r0, 0x20 - ands r0, r5 - cmp r0, 0 - beq _08050A84 - mov r0, r10 - adds r0, 0x1 - lsls r0, 24 - lsrs r0, 24 - mov r10, r0 -_08050A84: - movs r0, 0xDF - ands r5, r0 - ldr r1, =gBattleTextBuff1 - movs r4, 0 - movs r2, 0xFD - strb r2, [r1] - movs r0, 0x5 - strb r0, [r1, 0x1] - strb r7, [r1, 0x2] - movs r3, 0x1 - negs r3, r3 - mov r12, r3 - movs r0, 0xFF - strb r0, [r1, 0x3] - lsls r0, r6, 24 - cmp r0, 0 - blt _08050AA8 - b _08050D8C -_08050AA8: - ldr r4, =gSideTimers - ldr r1, =gActiveBank - ldrb r0, [r1] - bl GetBankIdentity - movs r1, 0x1 - ands r1, r0 - lsls r0, r1, 1 - adds r0, r1 - lsls r0, 2 - adds r0, r4 - ldrb r0, [r0, 0x4] - cmp r0, 0 - beq _08050B48 - mov r2, r9 - cmp r2, 0 - bne _08050B48 - ldr r0, =gCurrentMove - ldrh r0, [r0] - cmp r0, 0xAE - beq _08050B78 - cmp r5, 0x1 - bne _08050B68 - ldr r4, =gSpecialStatuses - ldr r3, =gActiveBank - ldrb r0, [r3] - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 2 - adds r1, r4 - ldrb r0, [r1] - lsls r0, 31 - cmp r0, 0 - beq _08050B10 - ldr r0, =gBattlescriptCurrInstr - mov r4, r8 - str r4, [r0] - b _08050B68 - .pool -_08050B10: - mov r0, r8 - bl BattleScriptPush - ldr r1, =gBattleScripting - ldr r6, =gActiveBank - ldrb r0, [r6] - strb r0, [r1, 0x17] - ldr r1, =gBattlescriptCurrInstr - ldr r0, =gUnknown_082DAE03 - str r0, [r1] - ldrb r1, [r6] - lsls r0, r1, 2 - adds r0, r1 - lsls r0, 2 - adds r0, r4 - ldrb r1, [r0] - movs r2, 0x1 - orrs r1, r2 - strb r1, [r0] - b _08050B68 - .pool -_08050B48: - ldr r0, =gCurrentMove - ldrh r0, [r0] - cmp r0, 0xAE - beq _08050B78 - mov r0, r10 - cmp r0, 0x1 - beq _08050B78 - movs r0, 0 - bl JumpIfMoveAffectedByProtect - lsls r0, 24 - cmp r0, 0 - beq _08050B78 - ldr r1, =gBattlescriptCurrInstr - ldr r0, =gUnknown_082D9F1C - str r0, [r1] -_08050B68: - movs r0, 0x1 - b _08050E80 - .pool -_08050B78: - ldr r2, =gBattleMons - ldr r1, =gActiveBank - ldrb r3, [r1] - movs r4, 0x58 - adds r0, r3, 0 - muls r0, r4 - adds r0, r2 - adds r0, 0x20 - ldrb r0, [r0] - mov r10, r2 - cmp r0, 0x1D - beq _08050B94 - cmp r0, 0x49 - bne _08050C2C -_08050B94: - mov r0, r9 - cmp r0, 0 - bne _08050C2C - ldr r0, =gCurrentMove - ldrh r0, [r0] - cmp r0, 0xAE - beq _08050C2C - cmp r5, 0x1 - bne _08050B68 - ldr r4, =gSpecialStatuses - lsls r0, r3, 2 - adds r0, r3 - lsls r0, 2 - adds r0, r4 - ldrb r0, [r0] - lsls r0, 31 - cmp r0, 0 - beq _08050BD4 - ldr r0, =gBattlescriptCurrInstr - mov r1, r8 - str r1, [r0] - b _08050B68 - .pool -_08050BD4: - mov r0, r8 - bl BattleScriptPush - ldr r1, =gBattleScripting - ldr r2, =gActiveBank - ldrb r0, [r2] - strb r0, [r1, 0x17] - ldr r1, =gBattlescriptCurrInstr - ldr r0, =gUnknown_082DB5C7 - str r0, [r1] - ldr r1, =gLastUsedAbility - ldrb r0, [r2] - movs r3, 0x58 - muls r0, r3 - add r0, r10 - adds r0, 0x20 - ldrb r0, [r0] - strb r0, [r1] - ldrb r0, [r2] - ldrb r1, [r1] - bl RecordAbilityBattle - ldr r6, =gActiveBank - ldrb r1, [r6] - lsls r0, r1, 2 - adds r0, r1 - lsls r0, 2 - adds r0, r4 - ldrb r1, [r0] - movs r2, 0x1 - orrs r1, r2 - strb r1, [r0] - b _08050B68 - .pool -_08050C2C: - ldr r1, =gActiveBank - ldrb r0, [r1] - movs r4, 0x58 - muls r0, r4 - add r0, r10 - adds r0, 0x20 - ldrb r0, [r0] - cmp r0, 0x33 - bne _08050C8C - mov r2, r9 - cmp r2, 0 - bne _08050C8C - cmp r7, 0x6 - bne _08050C8C - cmp r5, 0x1 - bne _08050B68 - mov r0, r8 - bl BattleScriptPush - ldr r1, =gBattleScripting - ldr r3, =gActiveBank - ldrb r0, [r3] - strb r0, [r1, 0x17] - ldr r1, =gBattlescriptCurrInstr - ldr r0, =gUnknown_082DB62F - str r0, [r1] - ldr r1, =gLastUsedAbility - ldrb r0, [r3] - muls r0, r4 - add r0, r10 - adds r0, 0x20 - ldrb r0, [r0] - strb r0, [r1] - ldrb r0, [r3] - ldrb r1, [r1] - bl RecordAbilityBattle - b _08050B68 - .pool -_08050C8C: - ldr r4, =gActiveBank - ldrb r0, [r4] - movs r4, 0x58 - muls r0, r4 - add r0, r10 - adds r0, 0x20 - ldrb r0, [r0] - cmp r0, 0x34 - bne _08050CF0 - mov r0, r9 - cmp r0, 0 - bne _08050CF0 - cmp r7, 0x1 - bne _08050CF0 - cmp r5, 0x1 - beq _08050CAE - b _08050B68 -_08050CAE: - mov r0, r8 - bl BattleScriptPush - ldr r1, =gBattleScripting - ldr r2, =gActiveBank - ldrb r0, [r2] - strb r0, [r1, 0x17] - ldr r1, =gBattlescriptCurrInstr - ldr r0, =gUnknown_082DB62F - str r0, [r1] - ldr r1, =gLastUsedAbility - ldrb r0, [r2] - muls r0, r4 - add r0, r10 - adds r0, 0x20 - ldrb r0, [r0] - strb r0, [r1] - ldrb r0, [r2] - ldrb r1, [r1] - bl RecordAbilityBattle - b _08050B68 - .pool -_08050CF0: - ldr r3, =gActiveBank - ldrb r1, [r3] - movs r0, 0x58 - muls r0, r1 - add r0, r10 - adds r0, 0x20 - ldrb r0, [r0] - cmp r0, 0x13 - bne _08050D08 - cmp r5, 0 - bne _08050D08 - b _08050B68 -_08050D08: - lsls r0, r6, 24 - asrs r0, 28 - movs r1, 0x7 - ands r0, r1 - negs r0, r0 - lsls r0, 24 - ldr r3, =gBattleTextBuff2 - movs r4, 0 - movs r1, 0xFD - strb r1, [r3] - movs r2, 0x1 - lsrs r6, r0, 24 - asrs r0, 24 - subs r1, 0xFF - cmp r0, r1 - bne _08050D32 - strb r4, [r3, 0x1] - movs r0, 0xD3 - strb r0, [r3, 0x2] - strb r4, [r3, 0x3] - movs r2, 0x4 -_08050D32: - adds r0, r2, r3 - strb r4, [r0] - adds r2, 0x1 - adds r1, r2, r3 - movs r0, 0xD4 - strb r0, [r1] - adds r2, 0x1 - adds r0, r2, r3 - strb r4, [r0] - adds r2, 0x1 - adds r1, r2, r3 - movs r0, 0xFF - strb r0, [r1] - ldr r4, =gActiveBank - ldrb r2, [r4] - movs r0, 0x58 - muls r0, r2 - adds r0, r7, r0 - mov r1, r10 - adds r1, 0x18 - adds r0, r1 - ldrb r0, [r0] - lsls r0, 24 - asrs r0, 24 - cmp r0, 0 - beq _08050DE2 - movs r1, 0 - ldr r0, =gBankTarget - ldrb r0, [r0] - ldr r3, =gBattleCommunication - mov r8, r3 - cmp r0, r2 - bne _08050D76 - movs r1, 0x1 -_08050D76: - mov r4, r8 - strb r1, [r4, 0x5] - b _08050E10 - .pool -_08050D8C: - asrs r6, r0, 28 - movs r0, 0x7 - ands r6, r0 - ldr r3, =gBattleTextBuff2 - strb r2, [r3] - movs r2, 0x1 - cmp r6, 0x2 - bne _08050DA6 - strb r4, [r3, 0x1] - movs r0, 0xD1 - strb r0, [r3, 0x2] - strb r4, [r3, 0x3] - movs r2, 0x4 -_08050DA6: - adds r0, r2, r3 - strb r4, [r0] - adds r2, 0x1 - adds r1, r2, r3 - movs r0, 0xD2 - strb r0, [r1] - adds r2, 0x1 - adds r0, r2, r3 - strb r4, [r0] - adds r2, 0x1 - adds r1, r2, r3 - ldrb r0, [r1] - mov r2, r12 - orrs r0, r2 - strb r0, [r1] - ldr r2, =gBattleMons - ldr r4, =gActiveBank - ldrb r3, [r4] - movs r0, 0x58 - muls r0, r3 - adds r0, r7, r0 - adds r1, r2, 0 - adds r1, 0x18 - adds r0, r1 - ldrb r0, [r0] - lsls r0, 24 - asrs r0, 24 - mov r10, r2 - cmp r0, 0xC - bne _08050DFC -_08050DE2: - ldr r1, =gBattleCommunication - movs r0, 0x2 - strb r0, [r1, 0x5] - mov r8, r1 - b _08050E10 - .pool -_08050DFC: - movs r1, 0 - ldr r0, =gBankTarget - ldrb r0, [r0] - ldr r2, =gBattleCommunication - mov r8, r2 - cmp r0, r3 - bne _08050E0C - movs r1, 0x1 -_08050E0C: - mov r3, r8 - strb r1, [r3, 0x5] -_08050E10: - ldr r2, =gActiveBank - ldrb r0, [r2] - movs r4, 0x58 - adds r1, r0, 0 - muls r1, r4 - adds r1, r7, r1 - mov r3, r10 - adds r3, 0x18 - adds r1, r3 - lsls r0, r6, 24 - asrs r0, 24 - ldrb r6, [r1] - adds r0, r6 - strb r0, [r1] - ldrb r0, [r2] - muls r0, r4 - adds r0, r7, r0 - adds r1, r0, r3 - movs r0, 0 - ldrsb r0, [r1, r0] - cmp r0, 0 - bge _08050E40 - movs r0, 0 - strb r0, [r1] -_08050E40: - ldr r1, =gActiveBank - ldrb r0, [r1] - muls r0, r4 - adds r0, r7, r0 - adds r1, r0, r3 - movs r0, 0 - ldrsb r0, [r1, r0] - cmp r0, 0xC - ble _08050E56 - movs r0, 0xC - strb r0, [r1] -_08050E56: - mov r2, r8 - ldrb r0, [r2, 0x5] - cmp r0, 0x2 - bne _08050E7E - movs r3, 0x1 - ands r3, r5 - cmp r3, 0 - beq _08050E70 - ldr r0, =gBattleMoveFlags - ldrb r1, [r0] - movs r2, 0x1 - orrs r1, r2 - strb r1, [r0] -_08050E70: - mov r4, r8 - ldrb r0, [r4, 0x5] - cmp r0, 0x2 - bne _08050E7E - cmp r3, 0 - bne _08050E7E - b _08050B68 -_08050E7E: - movs r0, 0 -_08050E80: - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r1} - bx r1 - .pool - thumb_func_end ChangeStatBuffs - - thumb_func_start atk89_statbuffchange -atk89_statbuffchange: @ 8050EA0 - push {r4,r5,lr} - ldr r5, =gBattlescriptCurrInstr - ldr r2, [r5] - ldrb r3, [r2, 0x2] - ldrb r0, [r2, 0x3] - lsls r0, 8 - orrs r3, r0 - ldrb r0, [r2, 0x4] - lsls r0, 16 - orrs r3, r0 - ldrb r0, [r2, 0x5] - lsls r0, 24 - orrs r3, r0 - ldr r0, =gBattleScripting - ldrb r4, [r0, 0x1A] - movs r0, 0xF0 - ands r0, r4 - lsls r0, 24 - asrs r0, 24 - movs r1, 0xF - ands r1, r4 - ldrb r2, [r2, 0x1] - bl ChangeStatBuffs - lsls r0, 24 - cmp r0, 0 - bne _08050EDC - ldr r0, [r5] - adds r0, 0x6 - str r0, [r5] -_08050EDC: - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end atk89_statbuffchange - - thumb_func_start atk8A_normalisebuffs -atk8A_normalisebuffs: @ 8050EEC - push {r4-r7,lr} - movs r2, 0 - ldr r0, =gNoOfAllBanks - ldrb r1, [r0] - ldr r0, =gBattlescriptCurrInstr - mov r12, r0 - cmp r2, r1 - bge _08050F24 - ldr r0, =gBattleMons - movs r4, 0x6 - adds r5, r1, 0 - movs r7, 0x58 - adds r6, r0, 0 - adds r6, 0x18 -_08050F08: - adds r3, r2, 0x1 - movs r1, 0x7 - adds r0, r2, 0 - muls r0, r7 - adds r0, r6 - adds r0, 0x7 -_08050F14: - strb r4, [r0] - subs r0, 0x1 - subs r1, 0x1 - cmp r1, 0 - bge _08050F14 - adds r2, r3, 0 - cmp r2, r5 - blt _08050F08 -_08050F24: - mov r1, r12 - ldr r0, [r1] - adds r0, 0x1 - str r0, [r1] - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end atk8A_normalisebuffs - - thumb_func_start atk8B_setbide -atk8B_setbide: @ 8050F40 - push {r4,r5,lr} - ldr r4, =gBattleMons - ldr r3, =gBankAttacker - ldrb r0, [r3] - movs r5, 0x58 - adds r2, r0, 0 - muls r2, r5 - adds r4, 0x50 - adds r2, r4 - ldr r0, [r2] - movs r1, 0x80 - lsls r1, 5 - orrs r0, r1 - str r0, [r2] - ldr r1, =gLockedMoves - ldrb r0, [r3] - lsls r0, 1 - adds r0, r1 - ldr r1, =gCurrentMove - ldrh r1, [r1] - movs r2, 0 - strh r1, [r0] - ldr r1, =gTakenDmg - ldrb r0, [r3] - lsls r0, 2 - adds r0, r1 - str r2, [r0] - ldrb r0, [r3] - adds r1, r0, 0 - muls r1, r5 - adds r1, r4 - ldr r0, [r1] - movs r2, 0x80 - lsls r2, 2 - orrs r0, r2 - str r0, [r1] - ldr r1, =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x1 - str r0, [r1] - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end atk8B_setbide - - thumb_func_start atk8C_confuseifrepeatingattackends -atk8C_confuseifrepeatingattackends: @ 8050FB0 - push {lr} - ldr r1, =gBattleMons - ldr r0, =gBankAttacker - ldrb r2, [r0] - movs r0, 0x58 - muls r0, r2 - adds r1, 0x50 - adds r0, r1 - ldr r0, [r0] - movs r1, 0xC0 - lsls r1, 4 - ands r0, r1 - cmp r0, 0 - bne _08050FD2 - ldr r1, =gBattleCommunication - movs r0, 0x75 - strb r0, [r1, 0x3] -_08050FD2: - ldr r1, =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x1 - str r0, [r1] - pop {r0} - bx r0 - .pool - thumb_func_end atk8C_confuseifrepeatingattackends - - thumb_func_start atk8D_setmultihit_counter -atk8D_setmultihit_counter: @ 8050FF0 - push {r4,r5,lr} - ldr r0, =gBattlescriptCurrInstr - ldr r0, [r0] - ldrb r1, [r0, 0x1] - cmp r1, 0 - beq _0805100C - ldr r0, =gMultiHitCounter - strb r1, [r0] - b _08051026 - .pool -_0805100C: - ldr r4, =gMultiHitCounter - bl Random - movs r5, 0x3 - ands r0, r5 - strb r0, [r4] - cmp r0, 0x1 - bls _08051022 - bl Random - ands r0, r5 -_08051022: - adds r0, 0x2 - strb r0, [r4] -_08051026: - ldr r1, =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x2 - str r0, [r1] - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end atk8D_setmultihit_counter - - thumb_func_start atk8E_prepare_multihit -atk8E_prepare_multihit: @ 805103C - ldr r1, =gBattleScripting - movs r2, 0 - movs r0, 0xFD - strb r0, [r1, 0x8] - movs r0, 0x1 - strb r0, [r1, 0x9] - strb r0, [r1, 0xA] - strb r0, [r1, 0xB] - strb r2, [r1, 0xC] - movs r0, 0xFF - strb r0, [r1, 0xD] - ldr r1, =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x1 - str r0, [r1] - bx lr - .pool - thumb_func_end atk8E_prepare_multihit - - thumb_func_start sub_8051064 -sub_8051064: @ 8051064 - push {r4-r7,lr} - ldr r6, =gBattleMons - ldr r7, =gBankAttacker - ldrb r0, [r7] - movs r5, 0x58 - adds r1, r0, 0 - muls r1, r5 - adds r1, r6 - adds r1, 0x2A - ldr r4, =gBankTarget - ldrb r3, [r4] - adds r0, r3, 0 - muls r0, r5 - adds r0, r6 - adds r0, 0x2A - ldrb r1, [r1] - ldrb r0, [r0] - cmp r1, r0 - bcc _080510AC - ldr r0, =gBattleStruct - ldr r1, [r0] - adds r1, r3, r1 - adds r1, 0x58 - ldr r2, =gBattlePartyID - lsls r0, r3, 1 - b _08051108 - .pool -_080510AC: - bl Random - movs r3, 0xFF - ands r3, r0 - ldrb r0, [r7] - muls r0, r5 - adds r0, r6 - adds r0, 0x2A - ldrb r2, [r0] - ldrb r4, [r4] - adds r0, r4, 0 - muls r0, r5 - adds r0, r6 - adds r0, 0x2A - ldrb r1, [r0] - adds r2, r1 - adds r0, r3, 0 - muls r0, r2 - asrs r0, 8 - adds r0, 0x1 - lsrs r1, 2 - cmp r0, r1 - bhi _080510FC - 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] - movs r0, 0 - b _08051116 - .pool -_080510FC: - ldr r0, =gBattleStruct - ldr r1, [r0] - adds r1, r4, r1 - adds r1, 0x58 - ldr r2, =gBattlePartyID - lsls r0, r4, 1 -_08051108: - adds r0, r2 - ldrh r0, [r0] - strb r0, [r1] - ldr r1, =gBattlescriptCurrInstr - ldr r0, =gUnknown_082DADD8 - str r0, [r1] - movs r0, 0x1 -_08051116: - pop {r4-r7} - pop {r1} - bx r1 - .pool - thumb_func_end sub_8051064 - - thumb_func_start atk8F_forcerandomswitch -atk8F_forcerandomswitch: @ 805112C - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0xC - movs r0, 0 - str r0, [sp, 0x4] - ldr r5, =gBattleTypeFlags - ldr r0, [r5] - movs r1, 0x8 - ands r0, r1 - cmp r0, 0 - bne _0805114A - b _08051410 -_0805114A: - ldr r4, =gBankTarget - ldrb r0, [r4] - bl GetBankSide - lsls r0, 24 - ldr r1, =gEnemyParty - str r1, [sp] - cmp r0, 0 - bne _08051160 - ldr r0, =gPlayerParty - str r0, [sp] -_08051160: - ldr r2, [r5] - movs r1, 0x81 - lsls r1, 1 - adds r0, r2, 0 - ands r0, r1 - cmp r0, r1 - beq _08051182 - ldr r1, =0x02000100 - adds r0, r2, 0 - ands r0, r1 - cmp r0, r1 - beq _08051182 - movs r0, 0x80 - lsls r0, 15 - ands r0, r2 - cmp r0, 0 - beq _080511C8 -_08051182: - ldr r2, =gBankTarget - ldrb r1, [r2] - movs r0, 0x2 - ands r0, r1 - adds r1, r2, 0 - cmp r0, 0 - beq _080511AC - movs r0, 0x3 - mov r9, r0 - movs r0, 0x6 - b _080511B2 - .pool -_080511AC: - movs r0, 0 - mov r9, r0 - movs r0, 0x3 -_080511B2: - mov r8, r0 - movs r0, 0x3 - mov r10, r0 - movs r0, 0x1 - str r0, [sp, 0x8] - ldr r2, =gBattlePartyID - ldrb r1, [r1] - b _0805128E - .pool -_080511C8: - movs r0, 0x42 - ands r0, r2 - cmp r0, 0x42 - beq _080511DA - ldr r1, =0x02000040 - adds r0, r2, 0 - ands r0, r1 - cmp r0, r1 - bne _0805121C -_080511DA: - ldrb r0, [r4] - bl sub_806D864 - lsls r0, 24 - lsrs r0, 24 - bl sub_806D82C - lsls r0, 16 - lsrs r0, 16 - cmp r0, 0x1 - bne _080511FC - movs r1, 0x3 - mov r9, r1 - movs r0, 0x6 - b _08051202 - .pool -_080511FC: - movs r1, 0 - mov r9, r1 - movs r0, 0x3 -_08051202: - mov r8, r0 - movs r1, 0x3 - mov r10, r1 - movs r0, 0x1 - str r0, [sp, 0x8] - ldr r2, =gBattlePartyID - ldr r0, =gBankTarget - ldrb r1, [r0] - b _0805128E - .pool -_0805121C: - movs r0, 0x80 - lsls r0, 8 - ands r0, r2 - cmp r0, 0 - beq _08051274 - ldrb r0, [r4] - bl GetBankSide - lsls r0, 24 - cmp r0, 0 - bne _08051240 - movs r1, 0 - mov r9, r1 - movs r0, 0x6 - mov r8, r0 - mov r10, r0 - movs r1, 0x2 - b _08051260 -_08051240: - ldrb r1, [r4] - movs r0, 0x2 - ands r0, r1 - cmp r0, 0 - beq _08051252 - movs r0, 0x3 - mov r9, r0 - movs r1, 0x6 - b _08051258 -_08051252: - movs r0, 0 - mov r9, r0 - movs r1, 0x3 -_08051258: - mov r8, r1 - movs r0, 0x3 - mov r10, r0 - movs r1, 0x1 -_08051260: - str r1, [sp, 0x8] - ldr r2, =gBattlePartyID - ldr r0, =gBankTarget - ldrb r1, [r0] - b _0805128E - .pool -_08051274: - movs r0, 0x1 - ands r2, r0 - cmp r2, 0 - beq _080512A4 - movs r0, 0 - mov r9, r0 - movs r1, 0x6 - mov r8, r1 - mov r10, r1 - movs r0, 0x2 - str r0, [sp, 0x8] - ldr r2, =gBattlePartyID - ldrb r1, [r4] -_0805128E: - lsls r0, r1, 1 - adds r0, r2 - ldrh r7, [r0] - movs r0, 0x2 - eors r1, r0 - lsls r1, 1 - adds r1, r2 - ldrh r5, [r1] - b _080512BE - .pool -_080512A4: - movs r1, 0 - mov r9, r1 - movs r0, 0x6 - mov r8, r0 - mov r10, r0 - movs r1, 0x1 - str r1, [sp, 0x8] - ldr r1, =gBattlePartyID - ldrb r0, [r4] - lsls r0, 1 - adds r0, r1 - ldrh r5, [r0] - adds r7, r5, 0 -_080512BE: - mov r6, r9 - cmp r6, r8 - bge _080512FC -_080512C4: - movs r0, 0x64 - muls r0, r6 - ldr r1, [sp] - adds r4, r1, r0 - adds r0, r4, 0 - movs r1, 0xB - bl GetMonData - cmp r0, 0 - beq _080512F6 - adds r0, r4, 0 - movs r1, 0x2D - bl GetMonData - cmp r0, 0 - bne _080512F6 - adds r0, r4, 0 - movs r1, 0x39 - bl GetMonData - cmp r0, 0 - beq _080512F6 - ldr r0, [sp, 0x4] - adds r0, 0x1 - str r0, [sp, 0x4] -_080512F6: - adds r6, 0x1 - cmp r6, r8 - blt _080512C4 -_080512FC: - ldr r1, [sp, 0x4] - ldr r0, [sp, 0x8] - cmp r1, r0 - bgt _08051328 - 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 _08051414 - .pool -_08051328: - bl sub_8051064 - lsls r0, 24 - cmp r0, 0 - beq _08051378 -_08051332: - bl Random - lsls r0, 16 - lsrs r0, 16 - mov r1, r10 - bl __modsi3 - adds r6, r0, 0 - add r6, r9 - cmp r6, r7 - beq _08051332 - cmp r6, r5 - beq _08051332 - movs r0, 0x64 - muls r0, r6 - ldr r1, [sp] - adds r4, r1, r0 - adds r0, r4, 0 - movs r1, 0xB - bl GetMonData - cmp r0, 0 - beq _08051332 - adds r0, r4, 0 - movs r1, 0x2D - bl GetMonData - cmp r0, 0x1 - beq _08051332 - adds r0, r4, 0 - movs r1, 0x39 - bl GetMonData - cmp r0, 0 - beq _08051332 -_08051378: - ldr r4, =gBankTarget - ldrb r0, [r4] - ldr r1, =gBattleStruct - ldr r1, [r1] - adds r0, r1 - adds r0, 0x5C - strb r6, [r0] - bl sub_81B1250 - lsls r0, 24 - cmp r0, 0 - bne _08051396 - ldrb r0, [r4] - bl sub_803BDA0 -_08051396: - ldr r0, =gBattleTypeFlags - ldr r2, [r0] - movs r1, 0x81 - lsls r1, 1 - adds r0, r2, 0 - ands r0, r1 - cmp r0, r1 - beq _080513C0 - movs r0, 0x42 - ands r0, r2 - cmp r0, 0x42 - beq _080513C0 - ldr r1, =0x02000100 - adds r0, r2, 0 - ands r0, r1 - cmp r0, r1 - beq _080513C0 - ldr r0, =0x02000040 - ands r2, r0 - cmp r2, r0 - bne _080513DE -_080513C0: - ldr r5, =gBankTarget - ldrb r0, [r5] - lsls r4, r6, 24 - lsrs r4, 24 - adds r1, r4, 0 - movs r2, 0 - bl sub_81B8E80 - ldrb r1, [r5] - movs r0, 0x2 - eors r0, r1 - adds r1, r4, 0 - movs r2, 0x1 - bl sub_81B8E80 -_080513DE: - ldr r0, =gBattleTypeFlags - ldr r0, [r0] - movs r1, 0x80 - lsls r1, 15 - ands r0, r1 - cmp r0, 0 - beq _08051414 - ldr r0, =gBankTarget - ldrb r0, [r0] - lsls r1, r6, 24 - lsrs r1, 24 - bl sub_80571DC - b _08051414 - .pool -_08051410: - bl sub_8051064 -_08051414: - add sp, 0xC - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end atk8F_forcerandomswitch - - thumb_func_start atk90_conversion_type_change -atk90_conversion_type_change: @ 8051424 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - movs r6, 0 - ldr r2, =gBattleMons - ldr r3, =gBankAttacker - ldrb r1, [r3] - movs r0, 0x58 - muls r0, r1 - adds r1, r2, 0 - adds r1, 0xC - adds r0, r1 - ldrh r0, [r0] - mov r8, r2 - cmp r0, 0 - beq _08051466 - movs r5, 0x58 - adds r2, r1, 0 -_0805144C: - adds r0, r6, 0x1 - lsls r0, 24 - lsrs r6, r0, 24 - cmp r6, 0x3 - bhi _08051466 - lsls r1, r6, 1 - ldrb r0, [r3] - muls r0, r5 - adds r1, r0 - adds r1, r2 - ldrh r0, [r1] - cmp r0, 0 - bne _0805144C -_08051466: - movs r3, 0 - cmp r3, r6 - bcs _080514E8 - ldr r0, =gBattleMoves - mov r10, r0 - ldr r5, =gBattleMons - mov r12, r5 - ldr r7, =gBankAttacker - ldrb r0, [r7] - movs r4, 0x58 - adds r5, r0, 0 - muls r5, r4 - movs r0, 0xC - add r0, r12 - mov r9, r0 -_08051484: - lsls r0, r3, 1 - adds r0, r5 - add r0, r9 - ldrh r1, [r0] - lsls r0, r1, 1 - adds r0, r1 - lsls r0, 2 - add r0, r10 - ldrb r2, [r0, 0x2] - cmp r2, 0x9 - bne _080514C6 - mov r0, r8 - adds r1, r5, r0 - adds r0, r1, 0 - adds r0, 0x21 - ldrb r0, [r0] - cmp r0, 0x7 - beq _080514B2 - adds r0, r1, 0 - adds r0, 0x22 - ldrb r0, [r0] - cmp r0, 0x7 - bne _080514C4 -_080514B2: - movs r2, 0x7 - b _080514C6 - .pool -_080514C4: - movs r2, 0 -_080514C6: - ldrb r0, [r7] - muls r0, r4 - add r0, r12 - adds r1, r0, 0 - adds r1, 0x21 - ldrb r1, [r1] - cmp r2, r1 - beq _080514DE - adds r0, 0x22 - ldrb r0, [r0] - cmp r2, r0 - bne _080514E8 -_080514DE: - adds r0, r3, 0x1 - lsls r0, 24 - lsrs r3, r0, 24 - cmp r3, r6 - bcc _08051484 -_080514E8: - cmp r3, r6 - bne _0805150C - 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 _080515B0 - .pool -_0805150C: - movs r7, 0x3 - ldr r5, =gBattleMoves - mov r9, r5 -_08051512: - bl Random - adds r3, r0, 0 - ands r3, r7 - cmp r3, r6 - bcs _08051512 - ldr r4, =gBattleMons - lsls r1, r3, 1 - ldr r3, =gBankAttacker - ldrb r2, [r3] - movs r0, 0x58 - adds r5, r2, 0 - muls r5, r0 - adds r1, r5 - adds r0, r4, 0 - adds r0, 0xC - adds r1, r0 - ldrh r1, [r1] - lsls r0, r1, 1 - adds r0, r1 - lsls r0, 2 - add r0, r9 - ldrb r2, [r0, 0x2] - mov r8, r4 - adds r4, r3, 0 - cmp r2, 0x9 - bne _08051572 - mov r0, r8 - adds r2, r5, r0 - adds r0, r2, 0 - adds r0, 0x21 - ldrb r0, [r0] - cmp r0, 0x7 - beq _08051560 - adds r0, r2, 0 - adds r0, 0x22 - ldrb r0, [r0] - cmp r0, 0x7 - bne _08051570 -_08051560: - movs r2, 0x7 - b _08051572 - .pool -_08051570: - movs r2, 0 -_08051572: - ldrb r0, [r4] - movs r3, 0x58 - muls r0, r3 - add r0, r8 - adds r1, r0, 0 - adds r1, 0x21 - ldrb r5, [r1] - cmp r2, r5 - beq _08051512 - adds r0, 0x22 - ldrb r0, [r0] - cmp r2, r0 - beq _08051512 - strb r2, [r1] - ldrb r0, [r4] - muls r0, r3 - add r0, r8 - adds r0, 0x22 - strb r2, [r0] - ldr r1, =gBattleTextBuff1 - movs r0, 0xFD - strb r0, [r1] - movs r0, 0x3 - strb r0, [r1, 0x1] - strb r2, [r1, 0x2] - movs r0, 0xFF - strb r0, [r1, 0x3] - ldr r1, =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x5 - str r0, [r1] -_080515B0: - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end atk90_conversion_type_change - - thumb_func_start atk91_givepaydaymoney -atk91_givepaydaymoney: @ 80515C8 - push {r4,lr} - ldr r0, =gBattleTypeFlags - ldr r0, [r0] - ldr r1, =0x02000002 - ands r0, r1 - cmp r0, 0 - bne _08051650 - ldr r1, =gPaydayMoney - ldrh r0, [r1] - cmp r0, 0 - beq _08051650 - adds r1, r0, 0 - ldr r0, =gBattleStruct - ldr r0, [r0] - adds r0, 0x4A - ldrb r0, [r0] - adds r4, r1, 0 - muls r4, r0 - ldr r0, =gSaveBlock1Ptr - ldr r0, [r0] - movs r1, 0x92 - lsls r1, 3 - adds r0, r1 - adds r1, r4, 0 - bl AddMoney - ldr r1, =gBattleTextBuff1 - movs r0, 0xFD - strb r0, [r1] - movs r0, 0x1 - strb r0, [r1, 0x1] - movs r0, 0x2 - strb r0, [r1, 0x2] - movs r0, 0x5 - strb r0, [r1, 0x3] - strb r4, [r1, 0x4] - movs r0, 0xFF - lsls r0, 8 - ands r4, r0 - lsrs r4, 8 - strb r4, [r1, 0x5] - movs r0, 0xFF - strb r0, [r1, 0x6] - ldr r4, =gBattlescriptCurrInstr - ldr r0, [r4] - adds r0, 0x1 - bl BattleScriptPush - ldr r0, =gUnknown_082DB307 - str r0, [r4] - b _08051658 - .pool -_08051650: - ldr r1, =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x1 - str r0, [r1] -_08051658: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end atk91_givepaydaymoney - - thumb_func_start atk92_setlightscreen -atk92_setlightscreen: @ 8051664 - push {r4-r6,lr} - ldr r5, =gBankAttacker - ldrb r0, [r5] - bl GetBankIdentity - ldr r4, =gSideAffecting - movs r6, 0x1 - adds r1, r6, 0 - ands r1, r0 - lsls r1, 1 - adds r1, r4 - ldrh r1, [r1] - movs r0, 0x2 - ands r0, r1 - cmp r0, 0 - beq _080516A4 - ldr r2, =gBattleMoveFlags - ldrb r0, [r2] - movs r1, 0x1 - orrs r0, r1 - strb r0, [r2] - ldr r1, =gBattleCommunication - movs r0, 0 - b _08051718 - .pool -_080516A4: - ldrb r0, [r5] - bl GetBankIdentity - adds r1, r6, 0 - ands r1, r0 - lsls r1, 1 - adds r1, r4 - ldrh r0, [r1] - movs r2, 0x2 - orrs r0, r2 - strh r0, [r1] - ldrb r0, [r5] - bl GetBankIdentity - ldr r4, =gSideTimers - adds r1, r6, 0 - ands r1, r0 - lsls r0, r1, 1 - adds r0, r1 - lsls r0, 2 - adds r0, r4 - movs r1, 0x5 - strb r1, [r0, 0x2] - ldrb r0, [r5] - bl GetBankIdentity - adds r1, r6, 0 - ands r1, r0 - lsls r0, r1, 1 - adds r0, r1 - lsls r0, 2 - adds r0, r4 - ldrb r1, [r5] - strb r1, [r0, 0x3] - ldr r0, =gBattleTypeFlags - ldr r0, [r0] - ands r0, r6 - cmp r0, 0 - beq _08051714 - movs r0, 0x1 - bl CountAliveMonsInBattle - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x2 - bne _08051714 - ldr r1, =gBattleCommunication - movs r0, 0x4 - b _08051718 - .pool -_08051714: - ldr r1, =gBattleCommunication - movs r0, 0x3 -_08051718: - strb r0, [r1, 0x5] - ldr r1, =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x1 - str r0, [r1] - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end atk92_setlightscreen - - thumb_func_start atk93_ko_move -atk93_ko_move: @ 8051730 - push {r4-r7,lr} - mov r7, r9 - mov r6, r8 - push {r6,r7} - ldr r7, =gBattleMons - ldr r6, =gBankTarget - ldrb r2, [r6] - movs r5, 0x58 - adds r0, r2, 0 - muls r0, r5 - adds r1, r0, r7 - ldrh r0, [r1, 0x2E] - cmp r0, 0xAF - bne _08051768 - ldr r1, =gEnigmaBerries - lsls r0, r2, 3 - subs r0, r2 - lsls r0, 2 - adds r0, r1 - ldrb r4, [r0, 0x7] - ldrb r6, [r0, 0x1A] - b _08051782 - .pool -_08051768: - ldrh r0, [r1, 0x2E] - bl ItemId_GetHoldEffect - lsls r0, 24 - lsrs r4, r0, 24 - ldrb r0, [r6] - muls r0, r5 - adds r0, r7 - ldrh r0, [r0, 0x2E] - bl ItemId_GetHoldEffectParam - lsls r0, 24 - lsrs r6, r0, 24 -_08051782: - ldr r1, =gStringBank - ldr r5, =gBankTarget - ldrb r0, [r5] - strb r0, [r1] - cmp r4, 0x27 - bne _080517C0 - bl Random - lsls r0, 16 - lsrs r0, 16 - movs r1, 0x64 - bl __umodsi3 - lsls r0, 16 - lsrs r0, 16 - cmp r0, r6 - bcs _080517C0 - ldrb r0, [r5] - movs r1, 0x27 - bl RecordItemEffectBattle - ldr r2, =gSpecialStatuses - ldrb r1, [r5] - lsls r0, r1, 2 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - ldrb r1, [r0] - movs r2, 0x80 - orrs r1, r2 - strb r1, [r0] -_080517C0: - ldr r1, =gBattleMons - ldr r2, =gBankTarget - ldrb r3, [r2] - movs r6, 0x58 - adds r0, r3, 0 - muls r0, r6 - adds r5, r0, r1 - adds r0, r5, 0 - adds r0, 0x20 - ldrb r4, [r0] - mov r8, r1 - mov r9, r2 - cmp r4, 0x5 - bne _0805181C - ldr r2, =gBattleMoveFlags - ldrb r0, [r2] - movs r1, 0x1 - orrs r0, r1 - strb r0, [r2] - ldr r0, =gLastUsedAbility - strb r4, [r0] - ldr r1, =gBattlescriptCurrInstr - ldr r0, =gUnknown_082DB552 - str r0, [r1] - mov r1, r9 - ldrb r0, [r1] - movs r1, 0x5 - bl RecordAbilityBattle - b _08051A70 - .pool -_0805181C: - ldr r1, =gStatuses3 - lsls r0, r3, 2 - adds r0, r1 - ldr r0, [r0] - movs r1, 0x18 - ands r0, r1 - cmp r0, 0 - bne _080518A0 - ldr r1, =gBattleMoves - ldr r0, =gCurrentMove - ldrh r0, [r0] - lsls r2, r0, 1 - adds r2, r0 - lsls r2, 2 - adds r2, r1 - ldr r7, =gBankAttacker - ldrb r0, [r7] - muls r0, r6 - add r0, r8 - adds r0, 0x2A - ldrb r0, [r0] - adds r1, r5, 0 - adds r1, 0x2A - ldrb r1, [r1] - subs r0, r1 - ldrb r2, [r2, 0x3] - adds r0, r2 - lsls r0, 16 - lsrs r4, r0, 16 - bl Random - lsls r0, 16 - lsrs r0, 16 - movs r1, 0x64 - bl __umodsi3 - lsls r0, 16 - lsrs r0, 16 - adds r0, 0x1 - cmp r0, r4 - blt _08051870 - b _08051A08 -_08051870: - ldrb r0, [r7] - adds r1, r0, 0 - muls r1, r6 - add r1, r8 - adds r1, 0x2A - mov r2, r9 - ldrb r0, [r2] - muls r0, r6 - add r0, r8 - adds r0, 0x2A - ldrb r1, [r1] - movs r4, 0x1 - ldrb r0, [r0] - cmp r1, r0 - bcs _08051936 - b _08051A08 - .pool -_080518A0: - ldr r1, =gDisableStructs - lsls r0, r3, 3 - subs r0, r3 - lsls r0, 2 - adds r0, r1 - ldr r1, =gBankAttacker - ldrb r0, [r0, 0x15] - adds r7, r1, 0 - ldrb r3, [r7] - cmp r0, r3 - bne _080518CA - ldrb r0, [r7] - muls r0, r6 - add r0, r8 - adds r0, 0x2A - adds r1, r5, 0 - adds r1, 0x2A - ldrb r0, [r0] - ldrb r1, [r1] - cmp r0, r1 - bcs _08051942 -_080518CA: - ldr r1, =gBattleMoves - ldr r0, =gCurrentMove - ldrh r0, [r0] - lsls r2, r0, 1 - adds r2, r0 - lsls r2, 2 - adds r2, r1 - ldr r6, =gBattleMons - ldrb r0, [r7] - movs r5, 0x58 - muls r0, r5 - adds r0, r6 - adds r0, 0x2A - ldrb r1, [r0] - ldr r0, =gBankTarget - mov r8, r0 - ldrb r0, [r0] - muls r0, r5 - adds r0, r6 - adds r0, 0x2A - ldrb r0, [r0] - subs r1, r0 - ldrb r2, [r2, 0x3] - adds r1, r2 - lsls r1, 16 - lsrs r4, r1, 16 - bl Random - lsls r0, 16 - lsrs r0, 16 - movs r1, 0x64 - bl __umodsi3 - lsls r0, 16 - lsrs r0, 16 - adds r0, 0x1 - cmp r0, r4 - bge _08051934 - ldrb r0, [r7] - adds r1, r0, 0 - muls r1, r5 - adds r1, r6 - adds r1, 0x2A - mov r2, r8 - ldrb r0, [r2] - muls r0, r5 - adds r0, r6 - adds r0, 0x2A - ldrb r1, [r1] - movs r4, 0x1 - ldrb r0, [r0] - cmp r1, r0 - bcs _08051936 -_08051934: - movs r4, 0 -_08051936: - ldr r3, =gBattleMons - mov r8, r3 - ldr r0, =gBankTarget - mov r9, r0 - cmp r4, 0 - beq _08051A08 -_08051942: - ldr r0, =gProtectStructs - mov r1, r9 - ldrb r2, [r1] - lsls r1, r2, 4 - adds r1, r0 - ldrb r0, [r1] - lsls r0, 30 - cmp r0, 0 - bge _08051990 - ldr r1, =gBattleMoveDamage - movs r0, 0x58 - muls r0, r2 - add r0, r8 - ldrh r0, [r0, 0x28] - subs r0, 0x1 - str r0, [r1] - ldr r2, =gBattleMoveFlags - ldrb r0, [r2] - movs r1, 0x40 - b _080519EE - .pool -_08051990: - ldr r0, =gSpecialStatuses - lsls r1, r2, 2 - adds r1, r2 - lsls r1, 2 - adds r1, r0 - ldrb r0, [r1] - lsrs r0, 7 - cmp r0, 0 - beq _080519DC - ldr r1, =gBattleMoveDamage - movs r3, 0x58 - adds r0, r2, 0 - muls r0, r3 - add r0, r8 - ldrh r0, [r0, 0x28] - subs r0, 0x1 - str r0, [r1] - ldr r2, =gBattleMoveFlags - ldrb r0, [r2] - movs r1, 0x80 - orrs r0, r1 - strb r0, [r2] - ldr r1, =gLastUsedItem - mov r2, r9 - ldrb r0, [r2] - muls r0, r3 - add r0, r8 - ldrh r0, [r0, 0x2E] - strh r0, [r1] - b _080519F2 - .pool -_080519DC: - ldr r1, =gBattleMoveDamage - movs r0, 0x58 - muls r0, r2 - add r0, r8 - ldrh r0, [r0, 0x28] - str r0, [r1] - ldr r2, =gBattleMoveFlags - ldrb r0, [r2] - movs r1, 0x10 -_080519EE: - orrs r0, r1 - strb r0, [r2] -_080519F2: - ldr r1, =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x5 - str r0, [r1] - b _08051A70 - .pool -_08051A08: - ldr r2, =gBattleMoveFlags - ldrb r0, [r2] - movs r1, 0x1 - orrs r0, r1 - strb r0, [r2] - ldr r3, =gBattleMons - ldr r0, =gBankAttacker - ldrb r0, [r0] - movs r2, 0x58 - adds r1, r0, 0 - muls r1, r2 - adds r1, r3 - adds r1, 0x2A - ldr r0, =gBankTarget - ldrb r0, [r0] - muls r0, r2 - adds r0, r3 - adds r0, 0x2A - ldrb r1, [r1] - ldrb r0, [r0] - cmp r1, r0 - bcc _08051A50 - ldr r1, =gBattleCommunication - movs r0, 0 - b _08051A54 - .pool -_08051A50: - ldr r1, =gBattleCommunication - movs r0, 0x1 -_08051A54: - strb r0, [r1, 0x5] - 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] -_08051A70: - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end atk93_ko_move - - thumb_func_start atk94_gethalfcurrentenemyhp -atk94_gethalfcurrentenemyhp: @ 8051A84 - push {lr} - ldr r3, =gBattleMoveDamage - ldr r2, =gBattleMons - ldr r0, =gBankTarget - ldrb r1, [r0] - movs r0, 0x58 - muls r0, r1 - adds r0, r2 - ldrh r0, [r0, 0x28] - lsrs r0, 1 - str r0, [r3] - cmp r0, 0 - bne _08051AA2 - movs r0, 0x1 - str r0, [r3] -_08051AA2: - ldr r1, =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x1 - str r0, [r1] - pop {r0} - bx r0 - .pool - thumb_func_end atk94_gethalfcurrentenemyhp - - thumb_func_start atk95_setsandstorm -atk95_setsandstorm: @ 8051AC0 - push {lr} - ldr r2, =gBattleWeather - ldrh r1, [r2] - movs r0, 0x18 - ands r0, r1 - cmp r0, 0 - beq _08051AEC - ldr r2, =gBattleMoveFlags - ldrb r0, [r2] - movs r1, 0x1 - orrs r0, r1 - strb r0, [r2] - ldr r1, =gBattleCommunication - movs r0, 0x2 - strb r0, [r1, 0x5] - b _08051AFE - .pool -_08051AEC: - movs r0, 0x8 - strh r0, [r2] - ldr r1, =gBattleCommunication - movs r0, 0x3 - strb r0, [r1, 0x5] - ldr r0, =gWishFutureKnock - adds r0, 0x28 - movs r1, 0x5 - strb r1, [r0] -_08051AFE: - ldr r1, =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x1 - str r0, [r1] - pop {r0} - bx r0 - .pool - thumb_func_end atk95_setsandstorm - - thumb_func_start atk96_weatherdamage -atk96_weatherdamage: @ 8051B18 - push {r4,r5,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 - beq _08051B36 - b _08051C48 -_08051B36: - str r0, [sp] - movs r0, 0x13 - movs r1, 0 - movs r2, 0x4D - movs r3, 0 - bl AbilityBattleEffects - lsls r0, 24 - cmp r0, 0 - beq _08051B4C - b _08051C48 -_08051B4C: - ldr r2, =gBattleWeather - ldrh r1, [r2] - movs r0, 0x18 - ands r0, r1 - adds r4, r2, 0 - ldr r5, =gBankAttacker - cmp r0, 0 - beq _08051BDA - ldr r0, =gBattleMons - ldrb r2, [r5] - movs r1, 0x58 - muls r1, r2 - adds r3, r1, r0 - adds r0, r3, 0 - adds r0, 0x21 - ldrb r0, [r0] - cmp r0, 0x5 - beq _08051BD4 - cmp r0, 0x8 - beq _08051BD4 - cmp r0, 0x4 - beq _08051BD4 - adds r0, r3, 0 - adds r0, 0x22 - ldrb r0, [r0] - cmp r0, 0x5 - beq _08051BD4 - cmp r0, 0x8 - beq _08051BD4 - cmp r0, 0x4 - beq _08051BD4 - adds r0, r3, 0 - adds r0, 0x20 - ldrb r0, [r0] - cmp r0, 0x8 - beq _08051BD4 - ldr r0, =gStatuses3 - lsls r1, r2, 2 - adds r1, r0 - ldr r1, [r1] - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - bne _08051BD4 - movs r0, 0x80 - lsls r0, 11 - ands r1, r0 - cmp r1, 0 - bne _08051BD4 - ldr r1, =gBattleMoveDamage - ldrh r0, [r3, 0x2C] - lsrs r0, 4 - str r0, [r1] - cmp r0, 0 - bne _08051BDA - movs r0, 0x1 - b _08051BD8 - .pool -_08051BD4: - ldr r1, =gBattleMoveDamage - movs r0, 0 -_08051BD8: - str r0, [r1] -_08051BDA: - ldrh r1, [r4] - movs r4, 0x80 - adds r0, r4, 0 - ands r0, r1 - cmp r0, 0 - beq _08051C50 - ldr r1, =gBattleMons - ldrb r3, [r5] - movs r0, 0x58 - muls r0, r3 - adds r2, r0, r1 - adds r0, r2, 0 - adds r0, 0x21 - ldrb r0, [r0] - cmp r0, 0xF - beq _08051C3C - adds r0, r2, 0 - adds r0, 0x22 - ldrb r0, [r0] - cmp r0, 0xF - beq _08051C3C - ldr r0, =gStatuses3 - lsls r1, r3, 2 - adds r1, r0 - ldr r1, [r1] - adds r0, r1, 0 - ands r0, r4 - cmp r0, 0 - bne _08051C3C - movs r0, 0x80 - lsls r0, 11 - ands r1, r0 - cmp r1, 0 - bne _08051C3C - ldr r1, =gBattleMoveDamage - ldrh r0, [r2, 0x2C] - lsrs r0, 4 - str r0, [r1] - cmp r0, 0 - bne _08051C50 - movs r0, 0x1 - str r0, [r1] - b _08051C50 - .pool -_08051C3C: - ldr r1, =gBattleMoveDamage - movs r0, 0 - str r0, [r1] - b _08051C50 - .pool -_08051C48: - ldr r1, =gBattleMoveDamage - movs r0, 0 - str r0, [r1] - ldr r5, =gBankAttacker -_08051C50: - ldr r0, =gAbsentBankFlags - ldrb r1, [r0] - ldr r2, =gBitTable - ldrb r0, [r5] - lsls r0, 2 - adds r0, r2 - ldr r0, [r0] - ands r1, r0 - cmp r1, 0 - beq _08051C6A - ldr r1, =gBattleMoveDamage - movs r0, 0 - str r0, [r1] -_08051C6A: - ldr r1, =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x1 - str r0, [r1] - add sp, 0x4 - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end atk96_weatherdamage - - thumb_func_start atk97_try_infatuation -atk97_try_infatuation: @ 8051C90 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - ldr r4, =gBankAttacker - ldrb r0, [r4] - bl GetBankSide - lsls r0, 24 - cmp r0, 0 - bne _08051CC8 - ldr r1, =gBattlePartyID - ldrb r0, [r4] - lsls r0, 1 - adds r0, r1 - ldrh r1, [r0] - movs r0, 0x64 - muls r1, r0 - ldr r0, =gPlayerParty - b _08051CD8 - .pool -_08051CC8: - ldr r1, =gBattlePartyID - ldrb r0, [r4] - lsls r0, 1 - adds r0, r1 - ldrh r1, [r0] - movs r0, 0x64 - muls r1, r0 - ldr r0, =gEnemyParty -_08051CD8: - adds r5, r1, r0 - ldr r4, =gBankTarget - ldrb r0, [r4] - bl GetBankSide - lsls r0, 24 - cmp r0, 0 - bne _08051D0C - ldr r1, =gBattlePartyID - ldrb r0, [r4] - lsls r0, 1 - adds r0, r1 - ldrh r1, [r0] - movs r0, 0x64 - muls r1, r0 - ldr r0, =gPlayerParty - b _08051D1C - .pool -_08051D0C: - ldr r1, =gBattlePartyID - ldrb r0, [r4] - lsls r0, 1 - adds r0, r1 - ldrh r1, [r0] - movs r0, 0x64 - muls r1, r0 - ldr r0, =gEnemyParty -_08051D1C: - adds r4, r1, r0 - adds r0, r5, 0 - movs r1, 0xB - bl GetMonData - lsls r0, 16 - lsrs r0, 16 - mov r10, r0 - adds r0, r5, 0 - movs r1, 0 - bl GetMonData - mov r9, r0 - adds r0, r4, 0 - movs r1, 0xB - bl GetMonData - lsls r0, 16 - lsrs r0, 16 - mov r8, r0 - adds r0, r4, 0 - movs r1, 0 - bl GetMonData - adds r7, r0, 0 - ldr r5, =gBankTarget - ldrb r0, [r5] - movs r6, 0x58 - muls r0, r6 - ldr r1, =gBattleMons - adds r0, r1 - adds r0, 0x20 - ldrb r2, [r0] - cmp r2, 0xC - bne _08051D94 - ldr r1, =gBattlescriptCurrInstr - ldr r0, =gUnknown_082DB5F5 - str r0, [r1] - ldr r0, =gLastUsedAbility - strb r2, [r0] - ldrb r0, [r5] - movs r1, 0xC - bl RecordAbilityBattle - b _08051E2C - .pool -_08051D94: - mov r0, r10 - mov r1, r9 - bl GetGenderFromSpeciesAndPersonality - adds r4, r0, 0 - mov r0, r8 - adds r1, r7, 0 - bl GetGenderFromSpeciesAndPersonality - lsls r4, 24 - lsls r0, 24 - cmp r4, r0 - beq _08051DE4 - ldrb r0, [r5] - muls r0, r6 - ldr r4, =gBattleMons - adds r4, 0x50 - adds r0, r4 - ldr r0, [r0] - movs r1, 0xF0 - lsls r1, 12 - ands r0, r1 - cmp r0, 0 - bne _08051DE4 - mov r0, r10 - mov r1, r9 - bl GetGenderFromSpeciesAndPersonality - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0xFF - beq _08051DE4 - mov r0, r8 - adds r1, r7, 0 - bl GetGenderFromSpeciesAndPersonality - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0xFF - bne _08051E08 -_08051DE4: - 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 _08051E2C - .pool -_08051E08: - ldrb r0, [r5] - adds r2, r0, 0 - muls r2, r6 - adds r2, r4 - ldr r1, =gBitTable - ldr r0, =gBankAttacker - ldrb r0, [r0] - lsls r0, 2 - adds r0, r1 - ldr r1, [r0] - lsls r1, 16 - ldr r0, [r2] - orrs r0, r1 - str r0, [r2] - ldr r1, =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x5 - str r0, [r1] -_08051E2C: - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end atk97_try_infatuation - - thumb_func_start atk98_status_icon_update -atk98_status_icon_update: @ 8051E48 - push {r4-r7,lr} - ldr r0, =gBattleExecBuffer - ldr r0, [r0] - cmp r0, 0 - bne _08051F34 - ldr r5, =gBattlescriptCurrInstr - ldr r1, [r5] - ldrb r0, [r1, 0x1] - cmp r0, 0x4 - beq _08051EA0 - bl GetBattleBank - ldr r4, =gActiveBank - strb r0, [r4] - ldr r3, =gBattleMons - ldrb r1, [r4] - movs r0, 0x58 - adds r2, r1, 0 - muls r2, r0 - adds r0, r3, 0 - adds r0, 0x4C - adds r0, r2, r0 - ldr r1, [r0] - adds r3, 0x50 - adds r2, r3 - ldr r2, [r2] - movs r0, 0 - bl dp01_build_cmdbuf_x1A_aaaa_bbbb - ldrb r0, [r4] - bl MarkBufferBankForExecution - ldr r0, [r5] - adds r0, 0x2 - str r0, [r5] - b _08051F34 - .pool -_08051EA0: - ldr r4, =gActiveBank - ldr r5, =gBankAttacker - ldrb r0, [r5] - strb r0, [r4] - ldr r6, =gAbsentBankFlags - ldrb r1, [r6] - ldr r7, =gBitTable - ldrb r2, [r4] - lsls r0, r2, 2 - adds r0, r7 - ldr r0, [r0] - ands r1, r0 - cmp r1, 0 - bne _08051EDC - ldr r3, =gBattleMons - movs r0, 0x58 - muls r2, r0 - adds r0, r3, 0 - adds r0, 0x4C - adds r0, r2, r0 - ldr r1, [r0] - adds r3, 0x50 - adds r2, r3 - ldr r2, [r2] - movs r0, 0 - bl dp01_build_cmdbuf_x1A_aaaa_bbbb - ldrb r0, [r4] - bl MarkBufferBankForExecution -_08051EDC: - ldr r0, =gBattleTypeFlags - ldr r0, [r0] - movs r1, 0x1 - ands r0, r1 - cmp r0, 0 - beq _08051F2C - ldrb r0, [r5] - bl GetBankIdentity - movs r1, 0x2 - eors r0, r1 - lsls r0, 24 - lsrs r0, 24 - bl GetBankByPlayerAI - strb r0, [r4] - ldrb r1, [r6] - ldrb r2, [r4] - lsls r0, r2, 2 - adds r0, r7 - ldr r0, [r0] - ands r1, r0 - cmp r1, 0 - bne _08051F2C - ldr r3, =gBattleMons - movs r0, 0x58 - muls r2, r0 - adds r0, r3, 0 - adds r0, 0x4C - adds r0, r2, r0 - ldr r1, [r0] - adds r3, 0x50 - adds r2, r3 - ldr r2, [r2] - movs r0, 0 - bl dp01_build_cmdbuf_x1A_aaaa_bbbb - ldrb r0, [r4] - bl MarkBufferBankForExecution -_08051F2C: - ldr r1, =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x2 - str r0, [r1] -_08051F34: - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end atk98_status_icon_update - - thumb_func_start atk99_setmist -atk99_setmist: @ 8051F58 - push {r4-r6,lr} - ldr r6, =gSideTimers - ldr r4, =gBankAttacker - ldrb r0, [r4] - bl GetBankIdentity - movs r5, 0x1 - adds r1, r5, 0 - ands r1, r0 - lsls r0, r1, 1 - adds r0, r1 - lsls r0, 2 - adds r0, r6 - ldrb r0, [r0, 0x4] - cmp r0, 0 - beq _08051F98 - ldr r2, =gBattleMoveFlags - ldrb r0, [r2] - movs r1, 0x20 - orrs r0, r1 - strb r0, [r2] - ldr r0, =gBattleCommunication - strb r5, [r0, 0x5] - b _08051FE6 - .pool -_08051F98: - ldrb r0, [r4] - bl GetBankIdentity - adds r1, r5, 0 - ands r1, r0 - lsls r0, r1, 1 - adds r0, r1 - lsls r0, 2 - adds r0, r6 - movs r1, 0x5 - strb r1, [r0, 0x4] - ldrb r0, [r4] - bl GetBankIdentity - adds r1, r5, 0 - ands r1, r0 - lsls r0, r1, 1 - adds r0, r1 - lsls r0, 2 - adds r0, r6 - ldrb r1, [r4] - strb r1, [r0, 0x5] - ldrb r0, [r4] - bl GetBankIdentity - ldr r2, =gSideAffecting - adds r1, r5, 0 - ands r1, r0 - lsls r1, 1 - adds r1, r2 - ldrh r2, [r1] - movs r3, 0x80 - lsls r3, 1 - adds r0, r3, 0 - movs r3, 0 - orrs r0, r2 - strh r0, [r1] - ldr r0, =gBattleCommunication - strb r3, [r0, 0x5] -_08051FE6: - ldr r1, =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x1 - str r0, [r1] - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end atk99_setmist - - thumb_func_start atk9A_set_focusenergy -atk9A_set_focusenergy: @ 8052000 - push {lr} - ldr r1, =gBattleMons - ldr r0, =gBankAttacker - ldrb r2, [r0] - movs r0, 0x58 - muls r0, r2 - adds r1, 0x50 - adds r0, r1 - ldr r1, [r0] - movs r3, 0x80 - lsls r3, 13 - adds r2, r1, 0 - ands r2, r3 - cmp r2, 0 - beq _08052040 - ldr r2, =gBattleMoveFlags - ldrb r0, [r2] - movs r1, 0x20 - orrs r0, r1 - strb r0, [r2] - ldr r1, =gBattleCommunication - movs r0, 0x1 - strb r0, [r1, 0x5] - b _08052048 - .pool -_08052040: - orrs r1, r3 - str r1, [r0] - ldr r0, =gBattleCommunication - strb r2, [r0, 0x5] -_08052048: - ldr r1, =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x1 - str r0, [r1] - pop {r0} - bx r0 - .pool - thumb_func_end atk9A_set_focusenergy - - thumb_func_start atk9B_transformdataexecution -atk9B_transformdataexecution: @ 805205C - push {r4-r7,lr} - mov r7, r8 - push {r7} - ldr r1, =gLastUsedMove - ldr r2, =0x0000ffff - adds r0, r2, 0 - strh r0, [r1] - ldr r1, =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x1 - str r0, [r1] - ldr r7, =gBattleMons - ldr r0, =gBankTarget - mov r12, r0 - ldrb r1, [r0] - movs r6, 0x58 - adds r0, r1, 0 - muls r0, r6 - adds r5, r7, 0 - adds r5, 0x50 - adds r0, r5 - ldr r0, [r0] - movs r4, 0x80 - lsls r4, 14 - ands r0, r4 - cmp r0, 0 - bne _080520A2 - ldr r0, =gStatuses3 - lsls r1, 2 - adds r1, r0 - ldr r2, [r1] - ldr r0, =0x000400c0 - ands r2, r0 - cmp r2, 0 - beq _080520D8 -_080520A2: - ldr r2, =gBattleMoveFlags - ldrb r0, [r2] - movs r1, 0x20 - orrs r0, r1 - strb r0, [r2] - ldr r1, =gBattleCommunication - movs r0, 0x1 - b _080521EC - .pool -_080520D8: - ldr r3, =gBankAttacker - ldrb r0, [r3] - adds r1, r0, 0 - muls r1, r6 - adds r1, r5 - ldr r0, [r1] - orrs r0, r4 - str r0, [r1] - ldr r4, =gDisableStructs - ldrb r1, [r3] - lsls r0, r1, 3 - subs r0, r1 - lsls r0, 2 - adds r0, r4 - strh r2, [r0, 0x4] - ldrb r0, [r3] - lsls r1, r0, 3 - subs r1, r0 - lsls r1, 2 - adds r1, r4 - ldrb r2, [r1, 0xB] - movs r0, 0x10 - negs r0, r0 - ands r0, r2 - strb r0, [r1, 0xB] - ldrb r1, [r3] - lsls r0, r1, 3 - subs r0, r1 - lsls r0, 2 - adds r0, r4 - mov r2, r12 - ldrb r1, [r2] - muls r1, r6 - adds r2, r7, 0 - adds r2, 0x48 - adds r1, r2 - ldr r1, [r1] - str r1, [r0] - ldrb r0, [r3] - lsls r1, r0, 3 - subs r1, r0 - lsls r1, 2 - adds r1, r4 - ldrb r2, [r1, 0x18] - movs r0, 0xF - ands r0, r2 - strb r0, [r1, 0x18] - ldr r1, =gBattleTextBuff1 - movs r0, 0xFD - strb r0, [r1] - movs r0, 0x6 - strb r0, [r1, 0x1] - mov r2, r12 - ldrb r0, [r2] - muls r0, r6 - adds r0, r7 - ldrh r0, [r0] - strb r0, [r1, 0x2] - ldrb r0, [r2] - muls r0, r6 - adds r0, r7 - ldrh r0, [r0] - lsrs r0, 8 - strb r0, [r1, 0x3] - movs r0, 0xFF - strb r0, [r1, 0x4] - ldrb r0, [r3] - muls r0, r6 - adds r5, r0, r7 - ldrb r0, [r2] - muls r0, r6 - adds r2, r0, r7 - movs r4, 0 - adds r6, r3, 0 - ldr r0, =gActiveBank - mov r8, r0 -_08052170: - adds r0, r5, r4 - adds r1, r2, r4 - ldrb r1, [r1] - strb r1, [r0] - adds r4, 0x1 - cmp r4, 0x23 - bls _08052170 - movs r4, 0 - ldr r7, =gBattleMoves - ldr r3, =gBattleMons + 0xC - adds r5, r3, 0 - adds r5, 0x18 -_08052188: - lsls r1, r4, 1 - ldrb r2, [r6] - movs r0, 0x58 - muls r2, r0 - adds r1, r2 - adds r1, r3 - ldrh r1, [r1] - lsls r0, r1, 1 - adds r0, r1 - lsls r0, 2 - adds r0, r7 - ldrb r1, [r0, 0x4] - cmp r1, 0x4 - bhi _080521C4 - adds r0, r4, r2 - adds r0, r5 - b _080521CA - .pool -_080521C4: - adds r0, r4, r2 - adds r0, r5 - movs r1, 0x5 -_080521CA: - strb r1, [r0] - adds r4, 0x1 - cmp r4, 0x3 - ble _08052188 - ldrb r0, [r6] - mov r1, r8 - strb r0, [r1] - movs r0, 0 - movs r1, 0x2 - bl dp01_build_cmdbuf_x38_a - mov r2, r8 - ldrb r0, [r2] - bl MarkBufferBankForExecution - ldr r1, =gBattleCommunication - movs r0, 0 -_080521EC: - strb r0, [r1, 0x5] - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end atk9B_transformdataexecution - - thumb_func_start atk9C_set_substitute -atk9C_set_substitute: @ 80521FC - push {r4-r7,lr} - ldr r7, =gBattleMons - ldr r6, =gBankAttacker - ldrb r0, [r6] - movs r5, 0x58 - muls r0, r5 - adds r3, r0, r7 - ldrh r0, [r3, 0x2C] - lsrs r1, r0, 2 - adds r2, r1, 0 - cmp r1, 0 - bne _08052216 - movs r2, 0x1 -_08052216: - ldrh r0, [r3, 0x28] - cmp r0, r2 - bhi _0805223C - ldr r1, =gBattleMoveDamage - movs r0, 0 - str r0, [r1] - ldr r1, =gBattleCommunication - movs r0, 0x1 - strb r0, [r1, 0x5] - b _08052290 - .pool -_0805223C: - ldr r4, =gBattleMoveDamage - str r1, [r4] - cmp r1, 0 - bne _08052248 - movs r0, 0x1 - str r0, [r4] -_08052248: - ldrb r0, [r6] - adds r2, r0, 0 - muls r2, r5 - adds r3, r7, 0 - adds r3, 0x50 - adds r2, r3 - ldr r0, [r2] - movs r1, 0x80 - lsls r1, 17 - orrs r0, r1 - str r0, [r2] - ldrb r0, [r6] - adds r1, r0, 0 - muls r1, r5 - adds r1, r3 - ldr r0, [r1] - ldr r2, =0xffff1fff - ands r0, r2 - str r0, [r1] - ldr r2, =gDisableStructs - ldrb r1, [r6] - lsls r0, r1, 3 - subs r0, r1 - lsls r0, 2 - adds r0, r2 - ldr r1, [r4] - movs r2, 0 - strb r1, [r0, 0xA] - ldr r0, =gBattleCommunication - strb r2, [r0, 0x5] - ldr r2, =gHitMarker - ldr r0, [r2] - movs r1, 0x80 - lsls r1, 1 - orrs r0, r1 - str r0, [r2] -_08052290: - ldr r1, =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x1 - str r0, [r1] - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end atk9C_set_substitute - - thumb_func_start sub_80522B8 -sub_80522B8: @ 80522B8 - push {r4,r5,lr} - lsls r0, 16 - lsrs r2, r0, 16 - movs r3, 0 - ldr r0, =gUnknown_0831C3E0 - ldrh r1, [r0] - ldr r4, =0x0000fffe - adds r5, r0, 0 - cmp r1, r4 - beq _080522E0 - cmp r1, r2 - beq _080522E0 - adds r1, r5, 0 -_080522D2: - adds r1, 0x2 - adds r3, 0x1 - ldrh r0, [r1] - cmp r0, r4 - beq _080522E0 - cmp r0, r2 - bne _080522D2 -_080522E0: - lsls r0, r3, 1 - adds r0, r5 - ldrh r1, [r0] - ldr r0, =0x0000fffe - eors r1, r0 - negs r0, r1 - orrs r0, r1 - lsrs r0, 31 - pop {r4,r5} - pop {r1} - bx r1 - .pool - thumb_func_end sub_80522B8 - - thumb_func_start atk9D_copyattack -atk9D_copyattack: @ 8052300 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - ldr r0, =gLastUsedMove - ldr r1, =0x0000ffff - adds r7, r1, 0 - strh r7, [r0] - ldr r5, =gLastUsedMovesByBanks - ldr r6, =gBankTarget - ldrb r0, [r6] - lsls r0, 1 - adds r0, r5 - ldrh r0, [r0] - bl sub_80522B8 - lsls r0, 24 - cmp r0, 0 - bne _0805235A - ldr r3, =gBattleMons - ldr r2, =gBankAttacker - ldrb r1, [r2] - movs r0, 0x58 - adds r4, r1, 0 - muls r4, r0 - adds r0, r3, 0 - adds r0, 0x50 - adds r0, r4, r0 - ldr r1, [r0] - movs r0, 0x80 - lsls r0, 14 - ands r1, r0 - mov r12, r3 - mov r9, r2 - cmp r1, 0 - bne _0805235A - ldrb r0, [r6] - lsls r0, 1 - adds r0, r5 - ldrh r1, [r0] - cmp r1, 0 - beq _0805235A - cmp r1, r7 - bne _08052394 -_0805235A: - 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 _080524CC - .pool -_08052394: - movs r2, 0 - mov r3, r12 - adds r3, 0xC - adds r0, r4, r3 - ldrh r0, [r0] - ldr r4, =gBattlescriptCurrInstr - mov r10, r4 - cmp r0, r1 - beq _080523CE - mov r8, r3 - adds r7, r5, 0 - adds r5, r6, 0 - mov r4, r9 - movs r3, 0x58 -_080523B0: - adds r2, 0x1 - cmp r2, 0x3 - bgt _080523CE - lsls r1, r2, 1 - ldrb r0, [r4] - muls r0, r3 - adds r1, r0 - add r1, r8 - ldrb r0, [r5] - lsls r0, 1 - adds r0, r7 - ldrh r1, [r1] - ldrh r0, [r0] - cmp r1, r0 - bne _080523B0 -_080523CE: - cmp r2, 0x4 - bne _080524B0 - ldr r5, =gCurrMovePos - ldrb r1, [r5] - lsls r1, 1 - mov r2, r9 - ldrb r0, [r2] - movs r6, 0x58 - muls r0, r6 - adds r1, r0 - mov r0, r12 - adds r0, 0xC - adds r1, r0 - ldr r2, =gLastUsedMovesByBanks - ldr r3, =gBankTarget - ldrb r0, [r3] - lsls r0, 1 - adds r0, r2 - ldrh r0, [r0] - strh r0, [r1] - ldr r4, =gBattleMoves - ldrb r0, [r3] - lsls r0, 1 - adds r0, r2 - ldrh r1, [r0] - lsls r0, r1, 1 - adds r0, r1 - lsls r0, 2 - adds r0, r4 - ldrb r4, [r0, 0x4] - cmp r4, 0x4 - bhi _08052438 - mov r1, r9 - ldrb r0, [r1] - muls r0, r6 - ldrb r1, [r5] - adds r0, r1 - mov r1, r12 - adds r1, 0x24 - adds r0, r1 - strb r4, [r0] - b _0805244C - .pool -_08052438: - mov r4, r9 - ldrb r0, [r4] - muls r0, r6 - ldrb r1, [r5] - adds r0, r1 - mov r1, r12 - adds r1, 0x24 - adds r0, r1 - movs r1, 0x5 - strb r1, [r0] -_0805244C: - ldr r1, =gBattleTextBuff1 - movs r0, 0xFD - strb r0, [r1] - movs r0, 0x2 - strb r0, [r1, 0x1] - ldrb r0, [r3] - lsls r0, 1 - adds r0, r2 - ldrh r0, [r0] - strb r0, [r1, 0x2] - ldrb r0, [r3] - lsls r0, 1 - adds r0, r2 - ldrh r0, [r0] - lsrs r0, 8 - strb r0, [r1, 0x3] - movs r0, 0xFF - strb r0, [r1, 0x4] - ldr r1, =gDisableStructs - mov r2, r9 - ldrb r0, [r2] - lsls r2, r0, 3 - subs r2, r0 - lsls r2, 2 - adds r2, r1 - ldrb r4, [r2, 0x18] - lsrs r3, r4, 4 - ldr r1, =gBitTable - ldrb r0, [r5] - lsls r0, 2 - adds r0, r1 - ldr r1, [r0] - orrs r1, r3 - lsls r1, 4 - movs r0, 0xF - ands r0, r4 - orrs r0, r1 - strb r0, [r2, 0x18] - mov r4, r10 - ldr r0, [r4] - adds r0, 0x5 - str r0, [r4] - b _080524CC - .pool -_080524B0: - mov r0, r10 - ldr r2, [r0] - 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 - mov r2, r10 - str r1, [r2] -_080524CC: - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end atk9D_copyattack - - thumb_func_start atk9E_metronome -atk9E_metronome: @ 80524DC - push {r4-r7,lr} - mov r7, r8 - push {r7} - ldr r7, =gCurrentMove - movs r6, 0xB1 - lsls r6, 1 - ldr r5, =gUnknown_0831C3E0 - ldr r0, =gBattlescriptCurrInstr - mov r8, r0 -_080524EE: - bl Random - ldr r2, =0x000001ff - adds r1, r2, 0 - ands r0, r1 - adds r0, 0x1 - strh r0, [r7] - cmp r0, r6 - bhi _080524EE - movs r0, 0x3 -_08052502: - subs r0, 0x1 - cmp r0, 0 - bge _08052502 - ldr r4, =gCurrentMove - ldrh r2, [r4] - ldr r3, =0x0000ffff - subs r0, r5, 0x2 -_08052510: - adds r0, 0x2 - ldrh r1, [r0] - cmp r1, r2 - beq _0805251C - cmp r1, r3 - bne _08052510 -_0805251C: - ldr r0, =0x0000ffff - cmp r1, r0 - bne _080524EE - ldr r2, =gHitMarker - ldr r0, [r2] - ldr r1, =0xfffffbff - ands r0, r1 - str r0, [r2] - ldr r3, =gBattleScriptsForMoveEffects - ldr r2, =gBattleMoves - ldrh r1, [r4] - lsls r0, r1, 1 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - ldrb r0, [r0] - lsls r0, 2 - adds r0, r3 - ldr r0, [r0] - mov r1, r8 - str r0, [r1] - ldrh r0, [r4] - movs r1, 0 - bl GetMoveTarget - ldr r1, =gBankTarget - strb r0, [r1] - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end atk9E_metronome - - thumb_func_start atk9F_dmgtolevel -atk9F_dmgtolevel: @ 8052584 - ldr r3, =gBattleMoveDamage - ldr r2, =gBattleMons - ldr r0, =gBankAttacker - ldrb r1, [r0] - movs r0, 0x58 - muls r0, r1 - adds r0, r2 - adds r0, 0x2A - ldrb r0, [r0] - str r0, [r3] - ldr r1, =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x1 - str r0, [r1] - bx lr - .pool - thumb_func_end atk9F_dmgtolevel - - thumb_func_start atkA0_psywavedamageeffect -atkA0_psywavedamageeffect: @ 80525B4 - push {r4,lr} - movs r4, 0xF -_080525B8: - bl Random - adds r3, r4, 0 - ands r3, r0 - cmp r3, 0xA - bgt _080525B8 - lsls r0, r3, 2 - adds r0, r3 - lsls r3, r0, 1 - ldr r4, =gBattleMoveDamage - ldr r2, =gBattleMons - ldr r0, =gBankAttacker - ldrb r1, [r0] - movs r0, 0x58 - muls r0, r1 - adds r0, r2 - adds r0, 0x2A - ldrb r1, [r0] - adds r0, r3, 0 - adds r0, 0x32 - muls r0, r1 - movs r1, 0x64 - bl __divsi3 - str r0, [r4] - ldr r1, =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x1 - str r0, [r1] - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end atkA0_psywavedamageeffect - - thumb_func_start atkA1_counterdamagecalculator -atkA1_counterdamagecalculator: @ 8052608 - push {r4-r6,lr} - ldr r4, =gBankAttacker - ldrb r0, [r4] - bl GetBankSide - lsls r0, 24 - lsrs r6, r0, 24 - ldr r5, =gProtectStructs - ldrb r0, [r4] - lsls r0, 4 - adds r0, r5 - ldrb r0, [r0, 0xC] - bl GetBankSide - lsls r0, 24 - lsrs r2, r0, 24 - ldrb r0, [r4] - lsls r1, r0, 4 - adds r0, r5, 0x4 - adds r0, r1, r0 - ldr r3, [r0] - cmp r3, 0 - beq _080526BC - cmp r6, r2 - beq _080526BC - ldr r6, =gBattleMons - adds r0, r1, r5 - ldrb r0, [r0, 0xC] - movs r4, 0x58 - muls r0, r4 - adds r0, r6 - ldrh r0, [r0, 0x28] - cmp r0, 0 - beq _080526BC - ldr r1, =gBattleMoveDamage - lsls r0, r3, 1 - str r0, [r1] - ldr r1, =gSideTimers - lsls r0, r2, 1 - adds r0, r2 - lsls r0, 2 - adds r1, r0, r1 - ldrb r0, [r1, 0x8] - cmp r0, 0 - beq _08052690 - ldrb r1, [r1, 0x9] - adds r0, r1, 0 - muls r0, r4 - adds r0, r6 - ldrh r0, [r0, 0x28] - cmp r0, 0 - beq _08052690 - ldr r0, =gBankTarget - strb r1, [r0] - b _080526A0 - .pool -_08052690: - ldr r2, =gBankTarget - ldr r1, =gProtectStructs - ldr r0, =gBankAttacker - ldrb r0, [r0] - lsls r0, 4 - adds r0, r1 - ldrb r0, [r0, 0xC] - strb r0, [r2] -_080526A0: - ldr r1, =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x5 - str r0, [r1] - b _080526EC - .pool -_080526BC: - ldr r2, =gSpecialStatuses - ldr r0, =gBankAttacker - ldrb r1, [r0] - lsls r0, r1, 2 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - ldrb r1, [r0] - movs r2, 0x20 - orrs r1, r2 - strb r1, [r0] - 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] -_080526EC: - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end atkA1_counterdamagecalculator - - thumb_func_start atkA2_mirrorcoatdamagecalculator -atkA2_mirrorcoatdamagecalculator: @ 8052700 - push {r4-r6,lr} - ldr r4, =gBankAttacker - ldrb r0, [r4] - bl GetBankSide - lsls r0, 24 - lsrs r6, r0, 24 - ldr r5, =gProtectStructs - ldrb r0, [r4] - lsls r0, 4 - adds r0, r5 - ldrb r0, [r0, 0xD] - bl GetBankSide - lsls r0, 24 - lsrs r2, r0, 24 - ldrb r0, [r4] - lsls r1, r0, 4 - adds r0, r5, 0 - adds r0, 0x8 - adds r0, r1, r0 - ldr r3, [r0] - cmp r3, 0 - beq _080527B4 - cmp r6, r2 - beq _080527B4 - ldr r6, =gBattleMons - adds r0, r1, r5 - ldrb r0, [r0, 0xD] - movs r4, 0x58 - muls r0, r4 - adds r0, r6 - ldrh r0, [r0, 0x28] - cmp r0, 0 - beq _080527B4 - ldr r1, =gBattleMoveDamage - lsls r0, r3, 1 - str r0, [r1] - ldr r1, =gSideTimers - lsls r0, r2, 1 - adds r0, r2 - lsls r0, 2 - adds r1, r0, r1 - ldrb r0, [r1, 0x8] - cmp r0, 0 - beq _08052788 - ldrb r1, [r1, 0x9] - adds r0, r1, 0 - muls r0, r4 - adds r0, r6 - ldrh r0, [r0, 0x28] - cmp r0, 0 - beq _08052788 - ldr r0, =gBankTarget - strb r1, [r0] - b _08052798 - .pool -_08052788: - ldr r2, =gBankTarget - ldr r1, =gProtectStructs - ldr r0, =gBankAttacker - ldrb r0, [r0] - lsls r0, 4 - adds r0, r1 - ldrb r0, [r0, 0xD] - strb r0, [r2] -_08052798: - ldr r1, =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x5 - str r0, [r1] - b _080527E4 - .pool -_080527B4: - ldr r2, =gSpecialStatuses - ldr r0, =gBankAttacker - ldrb r1, [r0] - lsls r0, r1, 2 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - ldrb r1, [r0] - movs r2, 0x20 - orrs r1, r2 - strb r1, [r0] - 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] -_080527E4: - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end atkA2_mirrorcoatdamagecalculator - - thumb_func_start atkA3_disablelastusedattack -atkA3_disablelastusedattack: @ 80527F8 - push {r4-r7,lr} - mov r7, r9 - mov r6, r8 - push {r6,r7} - movs r4, 0 - ldr r2, =gBattleMons - ldr r3, =gBankTarget - ldrb r1, [r3] - movs r0, 0x58 - muls r0, r1 - adds r7, r2, 0 - adds r7, 0xC - adds r0, r7 - ldr r5, =gLastUsedMovesByBanks - lsls r1, 1 - adds r1, r5 - ldrh r0, [r0] - mov r9, r2 - adds r6, r3, 0 - ldr r2, =gDisableStructs - mov r8, r2 - ldrh r1, [r1] - cmp r0, r1 - beq _0805284C - mov r12, r6 - movs r3, 0x58 -_0805282C: - adds r4, 0x1 - cmp r4, 0x3 - bgt _0805284C - lsls r2, r4, 1 - mov r0, r12 - ldrb r1, [r0] - adds r0, r1, 0 - muls r0, r3 - adds r2, r0 - adds r2, r7 - lsls r1, 1 - adds r1, r5 - ldrh r0, [r2] - ldrh r1, [r1] - cmp r0, r1 - bne _0805282C -_0805284C: - ldrb r1, [r6] - lsls r0, r1, 3 - subs r0, r1 - lsls r0, 2 - add r0, r8 - ldrh r0, [r0, 0x4] - cmp r0, 0 - bne _08052910 - cmp r4, 0x4 - beq _08052910 - movs r5, 0x58 - adds r0, r1, 0 - muls r0, r5 - adds r0, r4, r0 - mov r1, r9 - adds r1, 0x24 - adds r0, r1 - ldrb r0, [r0] - cmp r0, 0 - beq _08052910 - ldr r1, =gBattleTextBuff1 - movs r0, 0xFD - strb r0, [r1] - movs r0, 0x2 - strb r0, [r1, 0x1] - lsls r2, r4, 1 - ldrb r0, [r6] - muls r0, r5 - adds r0, r2, r0 - mov r3, r9 - adds r3, 0xC - adds r0, r3 - ldrh r0, [r0] - strb r0, [r1, 0x2] - ldrb r0, [r6] - muls r0, r5 - adds r0, r2, r0 - adds r0, r3 - ldrh r0, [r0] - lsrs r0, 8 - strb r0, [r1, 0x3] - movs r0, 0xFF - strb r0, [r1, 0x4] - ldrb r1, [r6] - lsls r0, r1, 3 - subs r0, r1 - lsls r0, 2 - add r0, r8 - muls r1, r5 - adds r2, r1 - adds r2, r3 - ldrh r1, [r2] - strh r1, [r0, 0x4] - bl Random - ldrb r2, [r6] - lsls r1, r2, 3 - subs r1, r2 - lsls r1, 2 - add r1, r8 - movs r2, 0x3 - ands r2, r0 - adds r2, 0x2 - ldrb r3, [r1, 0xB] - movs r0, 0x10 - negs r0, r0 - ands r0, r3 - orrs r0, r2 - strb r0, [r1, 0xB] - ldrb r0, [r6] - lsls r1, r0, 3 - subs r1, r0 - lsls r1, 2 - add r1, r8 - ldrb r3, [r1, 0xB] - lsls r2, r3, 28 - lsrs r2, 24 - movs r0, 0xF - ands r0, r3 - orrs r0, r2 - strb r0, [r1, 0xB] - ldr r1, =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x5 - str r0, [r1] - b _0805292A - .pool -_08052910: - 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] -_0805292A: - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end atkA3_disablelastusedattack - - thumb_func_start atkA4_setencore -atkA4_setencore: @ 805293C - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - movs r5, 0 - ldr r3, =gBattleMons - ldr r4, =gBankTarget - ldrb r1, [r4] - movs r0, 0x58 - muls r0, r1 - adds r6, r3, 0 - adds r6, 0xC - adds r0, r6 - ldr r2, =gLastUsedMovesByBanks - lsls r1, 1 - adds r1, r2 - ldrh r0, [r0] - mov r10, r3 - mov r8, r2 - ldr r2, =gDisableStructs - mov r9, r2 - ldrh r1, [r1] - cmp r0, r1 - beq _08052996 - mov r12, r4 - adds r7, r6, 0 - mov r6, r8 - movs r3, 0x58 -_08052976: - adds r5, 0x1 - cmp r5, 0x3 - bgt _08052996 - lsls r2, r5, 1 - mov r0, r12 - ldrb r1, [r0] - adds r0, r1, 0 - muls r0, r3 - adds r2, r0 - adds r2, r7 - lsls r1, 1 - adds r1, r6 - ldrh r0, [r2] - ldrh r1, [r1] - cmp r0, r1 - bne _08052976 -_08052996: - ldrb r0, [r4] - lsls r0, 1 - add r0, r8 - ldrh r2, [r0] - cmp r2, 0xA5 - beq _080529AA - cmp r2, 0xE3 - beq _080529AA - cmp r2, 0x77 - bne _080529AC -_080529AA: - movs r5, 0x4 -_080529AC: - ldrb r1, [r4] - lsls r0, r1, 3 - subs r0, r1 - lsls r0, 2 - mov r2, r9 - adds r3, r0, r2 - ldrh r0, [r3, 0x6] - cmp r0, 0 - bne _08052A44 - cmp r5, 0x4 - beq _08052A44 - movs r0, 0x58 - adds r2, r1, 0 - muls r2, r0 - adds r0, r5, r2 - mov r1, r10 - adds r1, 0x24 - adds r0, r1 - ldrb r0, [r0] - cmp r0, 0 - beq _08052A44 - lsls r0, r5, 1 - adds r0, r2 - subs r1, 0x18 - adds r0, r1 - ldrh r0, [r0] - strh r0, [r3, 0x6] - ldrb r1, [r4] - lsls r0, r1, 3 - subs r0, r1 - lsls r0, 2 - add r0, r9 - strb r5, [r0, 0xC] - bl Random - ldrb r2, [r4] - lsls r1, r2, 3 - subs r1, r2 - lsls r1, 2 - add r1, r9 - movs r2, 0x3 - ands r2, r0 - adds r2, 0x3 - ldrb r3, [r1, 0xE] - movs r0, 0x10 - negs r0, r0 - ands r0, r3 - orrs r0, r2 - strb r0, [r1, 0xE] - ldrb r0, [r4] - lsls r1, r0, 3 - subs r1, r0 - lsls r1, 2 - add r1, r9 - ldrb r3, [r1, 0xE] - lsls r2, r3, 28 - lsrs r2, 24 - movs r0, 0xF - ands r0, r3 - orrs r0, r2 - strb r0, [r1, 0xE] - ldr r1, =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x5 - str r0, [r1] - b _08052A5E - .pool -_08052A44: - 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] -_08052A5E: - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end atkA4_setencore - - thumb_func_start atkA5_painsplitdmgcalc -atkA5_painsplitdmgcalc: @ 8052A70 - push {r4-r7,lr} - ldr r6, =gBattleMons - ldr r0, =gBankTarget - mov r12, r0 - ldrb r0, [r0] - movs r7, 0x58 - adds r2, r0, 0 - muls r2, r7 - adds r0, r6, 0 - adds r0, 0x50 - adds r0, r2, r0 - ldr r0, [r0] - movs r1, 0x80 - lsls r1, 17 - ands r0, r1 - cmp r0, 0 - bne _08052B10 - ldr r5, =gBankAttacker - ldrb r0, [r5] - muls r0, r7 - adds r0, r6 - ldrh r3, [r0, 0x28] - adds r0, r2, r6 - ldrh r1, [r0, 0x28] - adds r3, r1 - asrs r3, 1 - ldr r4, =gBattleMoveDamage - subs r1, r3 - str r1, [r4] - ldr r2, =gBattleScripting - strb r1, [r2] - movs r0, 0xFF - lsls r0, 8 - ands r0, r1 - asrs r0, 8 - strb r0, [r2, 0x1] - movs r0, 0xFF - lsls r0, 16 - ands r0, r1 - asrs r0, 16 - strb r0, [r2, 0x2] - lsrs r1, 24 - strb r1, [r2, 0x3] - ldrb r0, [r5] - muls r0, r7 - adds r0, r6 - ldrh r0, [r0, 0x28] - subs r0, r3 - str r0, [r4] - ldr r2, =gSpecialStatuses - mov r0, r12 - ldrb r1, [r0] - lsls r0, r1, 2 - adds r0, r1 - lsls r0, 2 - adds r2, 0x4 - adds r0, r2 - ldr r1, =0x0000ffff - str r1, [r0] - ldr r1, =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x5 - str r0, [r1] - b _08052B2A - .pool -_08052B10: - 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] -_08052B2A: - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end atkA5_painsplitdmgcalc - - thumb_func_start atkA6_settypetorandomresistance -atkA6_settypetorandomresistance: @ 8052B34 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - ldr r1, =gUnknown_02024250 - ldr r4, =gBankAttacker - ldrb r0, [r4] - lsls r0, 1 - adds r2, r0, r1 - ldrh r1, [r2] - cmp r1, 0 - beq _08052B7E - ldr r0, =0x0000ffff - cmp r1, r0 - beq _08052B7E - ldrh r0, [r2] - bl IsTwoTurnsMove - lsls r0, 24 - cmp r0, 0 - beq _08052C1C - ldr r1, =gBattleMons - ldr r2, =gUnknown_02024270 - ldrb r0, [r4] - adds r0, r2 - ldrb r2, [r0] - movs r0, 0x58 - muls r0, r2 - adds r1, 0x50 - adds r0, r1 - ldr r0, [r0] - movs r1, 0x80 - lsls r1, 5 - ands r0, r1 - cmp r0, 0 - beq _08052C1C -_08052B7E: - 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 _08052D08 - .pool -_08052BB4: - mov r0, r12 - strb r5, [r0] - mov r1, r10 - ldrb r0, [r1] - muls r0, r2 - adds r0, r7 - adds r0, 0x22 - strb r5, [r0] - ldr r1, =gBattleTextBuff1 - movs r0, 0xFD - strb r0, [r1] - movs r0, 0x3 - strb r0, [r1, 0x1] - strb r5, [r1, 0x2] - movs r0, 0xFF - strb r0, [r1, 0x3] - ldr r1, =gBattlescriptCurrInstr - b _08052C0A - .pool -_08052BE0: - mov r0, r8 - adds r0, 0x1 - adds r0, r3 - ldrb r2, [r0] - strb r2, [r4] - mov r4, r10 - ldrb r0, [r4] - muls r0, r6 - ldr r7, =gBattleMons - adds r0, r7 - adds r0, 0x22 - strb r2, [r0] - ldr r1, =gBattleTextBuff1 - movs r0, 0xFD - strb r0, [r1] - movs r0, 0x3 - strb r0, [r1, 0x1] - strb r2, [r1, 0x2] - movs r0, 0xFF - strb r0, [r1, 0x3] - mov r1, r12 -_08052C0A: - ldr r0, [r1] - adds r0, 0x5 - str r0, [r1] - b _08052D08 - .pool -_08052C1C: - movs r4, 0 - mov r8, r4 - movs r7, 0x7F - mov r9, r7 -_08052C24: - bl Random - mov r4, r9 - ands r4, r0 - cmp r4, 0x70 - bhi _08052C24 - lsls r0, r4, 1 - adds r4, r0, r4 - ldr r6, =gTypeEffectiveness - adds r3, r4, r6 - ldr r1, =gUnknown_02024258 - ldr r2, =gBankAttacker - ldrb r5, [r2] - lsls r0, r5, 1 - adds r0, r1 - ldrb r1, [r3] - mov r10, r2 - ldrh r0, [r0] - cmp r1, r0 - bne _08052C80 - adds r0, r4, 0x2 - adds r0, r6 - ldrb r0, [r0] - cmp r0, 0x5 - bhi _08052C80 - ldr r7, =gBattleMons - movs r2, 0x58 - adds r0, r5, 0 - muls r0, r2 - adds r3, r0, r7 - movs r0, 0x21 - adds r0, r3 - mov r12, r0 - adds r0, r4, 0x1 - adds r0, r6 - ldrb r5, [r0] - mov r1, r12 - ldrb r0, [r1] - adds r1, r5, 0 - cmp r0, r1 - beq _08052C80 - adds r0, r3, 0 - adds r0, 0x22 - ldrb r0, [r0] - cmp r0, r1 - bne _08052BB4 -_08052C80: - movs r7, 0x1 - add r8, r7 - ldr r0, =0x000003e7 - cmp r8, r0 - ble _08052C24 - movs r0, 0 - mov r8, r0 - ldr r1, =gBattlescriptCurrInstr - mov r12, r1 - ldr r3, =gTypeEffectiveness - adds r0, r4, 0x1 - adds r0, r3 - mov r9, r0 - adds r5, r3, 0 -_08052C9C: - ldrb r1, [r5] - cmp r1, 0xFF - bgt _08052CA6 - cmp r1, 0xFE - bge _08052CE0 -_08052CA6: - mov r4, r10 - ldrb r2, [r4] - lsls r0, r2, 1 - ldr r7, =gUnknown_02024258 - adds r0, r7 - ldrh r0, [r0] - cmp r1, r0 - bne _08052CE0 - ldrb r0, [r5, 0x2] - cmp r0, 0x5 - bhi _08052CE0 - movs r6, 0x58 - adds r0, r2, 0 - muls r0, r6 - ldr r1, =gBattleMons - adds r2, r0, r1 - adds r4, r2, 0 - adds r4, 0x21 - ldrb r0, [r4] - mov r7, r9 - ldrb r1, [r7] - cmp r0, r1 - beq _08052CE0 - adds r0, r2, 0 - adds r0, 0x22 - ldrb r0, [r0] - cmp r0, r1 - beq _08052CE0 - b _08052BE0 -_08052CE0: - adds r5, 0x3 - movs r0, 0x3 - add r8, r0 - ldr r0, =0x0000014f - cmp r8, r0 - bls _08052C9C - mov r1, r12 - ldr r2, [r1] - 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 - mov r4, r12 - str r1, [r4] -_08052D08: - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end atkA6_settypetorandomresistance - - thumb_func_start atkA7_setalwayshitflag -atkA7_setalwayshitflag: @ 8052D34 - push {r4,lr} - ldr r4, =gStatuses3 - ldr r3, =gBankTarget - ldrb r1, [r3] - lsls r1, 2 - adds r1, r4 - ldr r0, [r1] - movs r2, 0x19 - negs r2, r2 - ands r0, r2 - str r0, [r1] - ldrb r1, [r3] - lsls r1, 2 - adds r1, r4 - ldr r0, [r1] - movs r2, 0x10 - orrs r0, r2 - str r0, [r1] - ldr r2, =gDisableStructs - ldrb r1, [r3] - lsls r0, r1, 3 - subs r0, r1 - lsls r0, 2 - adds r0, r2 - ldr r1, =gBankAttacker - ldrb r1, [r1] - strb r1, [r0, 0x15] - ldr r1, =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x1 - str r0, [r1] - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end atkA7_setalwayshitflag - - thumb_func_start atkA8_copymovepermanently -atkA8_copymovepermanently: @ 8052D8C - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x14 - ldr r0, =gLastUsedMove - ldr r1, =0x0000ffff - adds r5, r1, 0 - strh r5, [r0] - ldr r3, =gBattleMons - ldr r2, =gBankAttacker - ldrb r1, [r2] - movs r0, 0x58 - adds r4, r1, 0 - muls r4, r0 - adds r0, r3, 0 - adds r0, 0x50 - adds r0, r4, r0 - ldr r1, [r0] - movs r0, 0x80 - lsls r0, 14 - ands r1, r0 - mov r12, r3 - mov r10, r2 - cmp r1, 0 - beq _08052DC4 - b _08052F18 -_08052DC4: - ldr r0, =gUnknownMovesUsedByBanks - ldr r2, =gBankTarget - ldrb r1, [r2] - lsls r1, 1 - adds r1, r0 - ldrh r1, [r1] - mov r9, r0 - mov r8, r2 - cmp r1, 0xA5 - bne _08052DDA - b _08052F18 -_08052DDA: - cmp r1, 0 - bne _08052DE0 - b _08052F18 -_08052DE0: - cmp r1, r5 - bne _08052DE6 - b _08052F18 -_08052DE6: - cmp r1, 0xA6 - bne _08052DEC - b _08052F18 -_08052DEC: - movs r7, 0 - mov r5, r9 - mov r0, r12 - adds r0, 0xC - adds r1, r4, r0 - mov r3, r8 -_08052DF8: - ldrh r2, [r1] - cmp r2, 0xA6 - beq _08052E0A - ldrb r0, [r3] - lsls r0, 1 - adds r0, r5 - ldrh r0, [r0] - cmp r2, r0 - beq _08052E12 -_08052E0A: - adds r1, 0x2 - adds r7, 0x1 - cmp r7, 0x3 - ble _08052DF8 -_08052E12: - cmp r7, 0x4 - beq _08052E18 - b _08052F18 -_08052E18: - ldr r4, =gCurrMovePos - ldrb r1, [r4] - lsls r1, 1 - mov r2, r10 - ldrb r0, [r2] - movs r3, 0x58 - muls r0, r3 - adds r1, r0 - mov r6, r12 - adds r6, 0xC - adds r1, r6 - mov r2, r8 - ldrb r0, [r2] - lsls r0, 1 - add r0, r9 - ldrh r0, [r0] - strh r0, [r1] - mov r1, r10 - ldrb r0, [r1] - adds r2, r0, 0 - muls r2, r3 - ldrb r4, [r4] - adds r2, r4 - mov r5, r12 - adds r5, 0x24 - adds r2, r5 - ldr r4, =gBattleMoves - mov r1, r8 - ldrb r0, [r1] - lsls r0, 1 - add r0, r9 - ldrh r1, [r0] - lsls r0, r1, 1 - adds r0, r1 - lsls r0, 2 - adds r0, r4 - ldrb r0, [r0, 0x4] - strb r0, [r2] - ldr r1, =gActiveBank - mov r2, r10 - ldrb r0, [r2] - strb r0, [r1] - movs r7, 0 - ldrb r0, [r2] - muls r0, r3 - adds r4, r0, r5 - adds r3, r0, 0 - add r2, sp, 0x4 - add r5, sp, 0xC -_08052E7A: - adds r0, r3, r6 - ldrh r0, [r0] - strh r0, [r2] - adds r1, r5, r7 - ldrb r0, [r4] - strb r0, [r1] - adds r4, 0x1 - adds r3, 0x2 - adds r2, 0x2 - adds r7, 0x1 - cmp r7, 0x3 - ble _08052E7A - add r2, sp, 0x4 - mov r0, r10 - ldrb r1, [r0] - movs r0, 0x58 - muls r0, r1 - add r0, r12 - adds r0, 0x3B - ldrb r0, [r0] - strb r0, [r2, 0xC] - str r2, [sp] - movs r0, 0 - movs r1, 0x3 - movs r2, 0 - movs r3, 0x10 - bl EmitSetAttributes - ldr r0, =gActiveBank - ldrb r0, [r0] - bl MarkBufferBankForExecution - ldr r1, =gBattleTextBuff1 - movs r0, 0xFD - strb r0, [r1] - movs r0, 0x2 - strb r0, [r1, 0x1] - ldr r3, =gUnknownMovesUsedByBanks - ldr r2, =gBankTarget - ldrb r0, [r2] - lsls r0, 1 - adds r0, r3 - ldrh r0, [r0] - strb r0, [r1, 0x2] - ldrb r0, [r2] - lsls r0, 1 - adds r0, r3 - ldrh r0, [r0] - lsrs r0, 8 - strb r0, [r1, 0x3] - movs r0, 0xFF - strb r0, [r1, 0x4] - ldr r1, =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x5 - str r0, [r1] - b _08052F32 - .pool -_08052F18: - 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] -_08052F32: - add sp, 0x14 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end atkA8_copymovepermanently - thumb_func_start IsTwoTurnsMove IsTwoTurnsMove: @ 8052F48 push {lr} @@ -8028,7 +558,7 @@ _08053304: movs r0, 0 movs r2, 0 movs r3, 0x1 - bl EmitSetAttributes + bl EmitSetMonData ldrb r0, [r4] bl MarkBufferBankForExecution _080533B8: @@ -8155,7 +685,7 @@ _080534D4: eors r0, r1 lsls r0, 24 lsrs r0, 24 - bl GetBankByPlayerAI + bl GetBankByIdentity ldr r1, =gBattleScripting strb r0, [r1, 0x17] strb r0, [r7] @@ -8330,7 +860,7 @@ _0805363E: eors r0, r1 lsls r0, 24 lsrs r0, 24 - bl GetBankByPlayerAI + bl GetBankByIdentity ldr r4, =gActiveBank strb r0, [r4] ldr r0, =gBattleTypeFlags @@ -8373,7 +903,7 @@ _080536BC: movs r0, 0 movs r1, 0x28 movs r3, 0x4 - bl EmitSetAttributes + bl EmitSetMonData ldrb r0, [r4] bl MarkBufferBankForExecution _080536DE: @@ -9311,7 +1841,7 @@ _08053EF8: _08053F10: movs r0, 0x2 _08053F12: - bl GetBankByPlayerAI + bl GetBankByIdentity ldr r1, =gBankTarget strb r0, [r1] ldr r0, =gUnknown_0202421C @@ -10852,7 +3382,7 @@ atkCD_cureifburnedparalysedorpoisoned: @ 8054C60 movs r1, 0x28 movs r2, 0 movs r3, 0x4 - bl EmitSetAttributes + bl EmitSetMonData ldrb r0, [r4] bl MarkBufferBankForExecution b _08054CD6 @@ -11035,7 +3565,7 @@ atkD1_set_helpinghand: @ 8054E0C eors r0, r1 lsls r0, 24 lsrs r0, 24 - bl GetBankByPlayerAI + bl GetBankByIdentity ldr r3, =gBankTarget strb r0, [r3] ldr r0, =gBattleTypeFlags @@ -11283,7 +3813,7 @@ _08055010: movs r1, 0x2 movs r2, 0 movs r3, 0x2 - bl EmitSetAttributes + bl EmitSetMonData ldr r1, =gBankAttacker ldrb r0, [r1] bl MarkBufferBankForExecution @@ -11299,7 +3829,7 @@ _08055010: movs r1, 0x2 movs r2, 0 movs r3, 0x2 - bl EmitSetAttributes + bl EmitSetMonData ldrb r0, [r7] bl MarkBufferBankForExecution ldrb r0, [r7] @@ -12179,7 +4709,7 @@ _08055798: adds r1, r5, 0x1 cmp r0, 0 bne _080557EE - ldr r0, =gUnknown_0831C3E0 + ldr r0, =gMovesForbiddenToCopy ldrh r2, [r0] adds r3, r0, 0 cmp r2, r8 @@ -12525,7 +5055,7 @@ atkE2_switchout_abilities: @ 8055A78 movs r0, 0 movs r1, 0x28 movs r3, 0x4 - bl EmitSetAttributes + bl EmitSetMonData ldrb r0, [r4] bl MarkBufferBankForExecution _08055AD2: @@ -13179,7 +5709,7 @@ atkEA_recycleitem: @ 8056014 movs r1, 0x2 movs r2, 0 movs r3, 0x2 - bl EmitSetAttributes + bl EmitSetMonData ldrb r0, [r7] bl MarkBufferBankForExecution ldr r1, =gBattlescriptCurrInstr @@ -13302,7 +5832,7 @@ atkEC_pursuit_sth: @ 805616C eors r0, r1 lsls r0, 24 lsrs r0, 24 - bl GetBankByPlayerAI + bl GetBankByIdentity ldr r4, =gActiveBank strb r0, [r4] ldr r0, =gBattleTypeFlags @@ -14790,7 +7320,7 @@ sub_8056EF8: @ 8056EF8 ldr r5, =gBattlescriptCurrInstr ldr r0, [r5] ldrb r0, [r0, 0x1] - bl GetBankByPlayerAI + bl GetBankByIdentity ldr r4, =gActiveBank strb r0, [r4] movs r0, 0 diff --git a/asm/battle_5.s b/asm/battle_5.s index 9c35a8913..bb5b406e5 100644 --- a/asm/battle_5.s +++ b/asm/battle_5.s @@ -195,11 +195,11 @@ AdjustFriendshipOnBattleFaint: @ 80570F4 cmp r0, 0 beq _08057140 movs r0, 0x1 - bl GetBankByPlayerAI + bl GetBankByIdentity lsls r0, 24 lsrs r4, r0, 24 movs r0, 0x3 - bl GetBankByPlayerAI + bl GetBankByIdentity lsls r0, 24 lsrs r3, r0, 24 ldr r2, =gBattleMons @@ -220,7 +220,7 @@ AdjustFriendshipOnBattleFaint: @ 80570F4 .pool _08057140: movs r0, 0x1 - bl GetBankByPlayerAI + bl GetBankByIdentity lsls r0, 24 lsrs r4, r0, 24 _0805714A: @@ -562,7 +562,7 @@ _08057406: movs r1, 0x28 movs r2, 0 movs r3, 0x4 - bl EmitSetAttributes + bl EmitSetMonData ldrb r0, [r4] bl MarkBufferBankForExecution _08057430: diff --git a/asm/battle_7.s b/asm/battle_7.s index 10fabc389..011559819 100644 --- a/asm/battle_7.s +++ b/asm/battle_7.s @@ -428,7 +428,7 @@ _0805D470: movs r0, 0x1 ands r0, r1 eors r0, r2 - bl GetBankByPlayerAI + bl GetBankByIdentity lsls r0, 24 lsrs r0, 16 _0805D48A: @@ -579,7 +579,7 @@ sub_805D5F4: @ 805D5F4 cmp r0, 0 bne _0805D630 movs r0, 0x1 - bl GetBankByPlayerAI + bl GetBankByIdentity lsls r0, 24 lsrs r0, 24 mov r8, r0 @@ -588,13 +588,13 @@ sub_805D5F4: @ 805D5F4 .pool _0805D630: movs r0, 0 - bl GetBankByPlayerAI + bl GetBankByIdentity lsls r0, 24 lsrs r0, 24 mov r8, r0 movs r0, 0x2 _0805D63E: - bl GetBankByPlayerAI + bl GetBankByIdentity lsls r0, 24 lsrs r7, r0, 24 ldr r1, =gBattleMons @@ -2941,7 +2941,7 @@ _0805EA5A: BattleMusicStop: @ 805EA60 push {r4-r6,lr} movs r0, 0 - bl GetBankByPlayerAI + bl GetBankByIdentity lsls r0, 24 lsrs r4, r0, 24 ldr r5, =gUnknown_020244D0 @@ -3020,12 +3020,12 @@ sub_805EAE8: @ 805EAE8 cmp r0, 0 beq _0805EB7E movs r0, 0 - bl GetBankByPlayerAI + bl GetBankByIdentity lsls r0, 24 lsrs r0, 24 mov r8, r0 movs r0, 0x2 - bl GetBankByPlayerAI + bl GetBankByIdentity lsls r0, 24 lsrs r0, 24 mov r9, r0 @@ -3203,7 +3203,7 @@ sub_805EC84: @ 805EC84 ldr r0, =gUnknown_0831C6A0 bl LoadCompressedObjectPic movs r0, 0x1 - bl GetBankByPlayerAI + bl GetBankByIdentity adds r5, r0, 0 lsls r5, 24 lsrs r5, 24 @@ -3252,7 +3252,7 @@ sub_805EC84: @ 805EC84 cmp r0, 0 beq _0805ED56 movs r0, 0x3 - bl GetBankByPlayerAI + bl GetBankByIdentity adds r5, r0, 0 lsls r5, 24 lsrs r5, 24 diff --git a/asm/battle_9.s b/asm/battle_9.s index 401584bce..0dfc105ec 100644 --- a/asm/battle_9.s +++ b/asm/battle_9.s @@ -74,7 +74,7 @@ _08062C72: lsrs r0, 24 mov r10, r0 ldr r4, =gBattleMons - bl GetBankByPlayerAI + bl GetBankByIdentity lsls r0, 24 lsrs r0, 24 movs r1, 0x58 @@ -87,7 +87,7 @@ _08062C72: b _08062E2C _08062C9E: mov r0, r10 - bl GetBankByPlayerAI + bl GetBankByIdentity lsls r0, 24 lsrs r2, r0, 24 movs r6, 0 @@ -223,7 +223,7 @@ _08062D74: movs r1, 0x2E bl GetMonData mov r0, r10 - bl GetBankByPlayerAI + bl GetBankByIdentity lsls r0, 24 lsrs r2, r0, 24 movs r4, 0 @@ -347,7 +347,7 @@ _08062EB0: eors r0, r4 lsls r0, 24 lsrs r0, 24 - bl GetBankByPlayerAI + bl GetBankByIdentity ldr r1, =gAbsentBankFlags ldrb r1, [r1] ldr r2, =gBitTable @@ -367,7 +367,7 @@ _08062F04: eors r0, r4 lsls r0, 24 lsrs r0, 24 - bl GetBankByPlayerAI + bl GetBankByIdentity lsls r0, 24 lsrs r7, r0, 24 b _08062F1E @@ -705,7 +705,7 @@ ai_has_super_effective_move_on_field: @ 80631BC lsls r0, 24 lsrs r0, 24 mov r10, r0 - bl GetBankByPlayerAI + bl GetBankByIdentity lsls r0, 24 lsrs r3, r0, 24 ldr r0, =gAbsentBankFlags @@ -779,7 +779,7 @@ _0806327C: movs r1, 0x2 mov r0, r10 eors r0, r1 - bl GetBankByPlayerAI + bl GetBankByIdentity lsls r0, 24 lsrs r3, r0, 24 ldr r0, =gAbsentBankFlags @@ -951,7 +951,7 @@ _080633B8: eors r0, r4 lsls r0, 24 lsrs r0, 24 - bl GetBankByPlayerAI + bl GetBankByIdentity ldr r1, =gAbsentBankFlags ldrb r1, [r1] ldr r2, =gBitTable @@ -972,7 +972,7 @@ _08063414: eors r0, r4 lsls r0, 24 lsrs r0, 24 - bl GetBankByPlayerAI + bl GetBankByIdentity lsls r0, 24 lsrs r0, 24 mov r10, r0 @@ -1308,7 +1308,7 @@ _080636C4: eors r0, r5 lsls r0, 24 lsrs r0, 24 - bl GetBankByPlayerAI + bl GetBankByIdentity ldr r1, =gAbsentBankFlags ldrb r1, [r1] ldr r2, =gBitTable @@ -1328,7 +1328,7 @@ _08063718: eors r0, r5 lsls r0, 24 lsrs r0, 24 - bl GetBankByPlayerAI + bl GetBankByIdentity lsls r0, 24 lsrs r6, r0, 24 b _08063732 @@ -1542,7 +1542,7 @@ _080638C2: cmp r0, 0 bne _08063910 adds r0, r6, 0 - bl GetBankByPlayerAI + bl GetBankByIdentity lsls r0, 24 lsrs r5, r0, 24 adds r6, r5, 0 @@ -1550,13 +1550,13 @@ _080638C2: .pool _08063910: adds r0, r5, 0 - bl GetBankByPlayerAI + bl GetBankByIdentity lsls r0, 24 lsrs r6, r0, 24 movs r0, 0x2 eors r5, r0 adds r0, r5, 0 - bl GetBankByPlayerAI + bl GetBankByIdentity lsls r0, 24 lsrs r5, r0, 24 _08063928: @@ -1789,7 +1789,7 @@ _08063AE0: eors r0, r5 lsls r0, 24 lsrs r0, 24 - bl GetBankByPlayerAI + bl GetBankByIdentity ldr r1, =gAbsentBankFlags ldrb r1, [r1] ldr r2, =gBitTable @@ -1810,7 +1810,7 @@ _08063B20: eors r0, r5 lsls r0, 24 lsrs r0, 24 - bl GetBankByPlayerAI + bl GetBankByIdentity lsls r0, 24 lsrs r0, 24 str r0, [sp, 0x14] @@ -1844,7 +1844,7 @@ _08063B6C: eors r0, r1 lsls r0, 24 lsrs r0, 24 - bl GetBankByPlayerAI + bl GetBankByIdentity lsls r0, 24 lsrs r0, 24 str r0, [sp, 0x4] diff --git a/asm/battle_anim.s b/asm/battle_anim.s index 639be6b7d..9c0190214 100644 --- a/asm/battle_anim.s +++ b/asm/battle_anim.s @@ -949,17 +949,17 @@ _080A4148: ldrsh r0, [r6, r3] cmp r0, 0 bne _080A4190 - ldr r0, =gUnknown_02022E18 + ldr r0, =gBattle_BG1_X ldrh r0, [r0] strh r0, [r1, 0xE] - ldr r0, =gUnknown_02022E1A + ldr r0, =gBattle_BG1_Y b _080A4198 .pool _080A4190: - ldr r0, =gUnknown_02022E1C + ldr r0, =gBattle_BG2_X ldrh r0, [r0] strh r0, [r1, 0xE] - ldr r0, =gUnknown_02022E1E + ldr r0, =gBattle_BG2_Y _080A4198: ldrh r0, [r0] strh r0, [r1, 0x10] @@ -1266,7 +1266,7 @@ _080A43F8: ldr r0, =gBankSpriteIds adds r0, r6, r0 ldrb r4, [r0] - ldr r5, =gUnknown_02022E18 + ldr r5, =gBattle_BG1_X ldr r0, =gSprites lsls r1, r4, 4 adds r1, r4 @@ -1294,7 +1294,7 @@ _080A43F8: subs r0, 0x1 strh r0, [r5] _080A447A: - ldr r5, =gUnknown_02022E1A + ldr r5, =gBattle_BG1_Y ldr r2, =gSprites lsls r1, r4, 4 adds r1, r4 @@ -1322,7 +1322,7 @@ _080A447A: orrs r1, r2 strb r1, [r0] _080A44B0: - ldr r0, =gUnknown_02022E18 + ldr r0, =gBattle_BG1_X ldrh r1, [r0] movs r0, 0x14 bl SetGpuReg @@ -1431,7 +1431,7 @@ _080A455E: ldr r0, =gBankSpriteIds adds r2, r5, r0 ldrb r4, [r2] - ldr r5, =gUnknown_02022E1C + ldr r5, =gBattle_BG2_X ldr r3, =gSprites lsls r1, r4, 4 adds r1, r4 @@ -1443,7 +1443,7 @@ _080A455E: negs r0, r0 adds r0, 0x20 strh r0, [r5] - ldr r4, =gUnknown_02022E1E + ldr r4, =gBattle_BG2_Y ldrh r0, [r1, 0x26] ldrh r1, [r1, 0x22] adds r0, r1 @@ -1653,19 +1653,19 @@ sub_80A477C: @ 80A477C _080A479C: movs r0, 0x1 bl sub_80A6C68 - ldr r0, =gUnknown_02022E18 + ldr r0, =gBattle_BG1_X movs r1, 0 strh r1, [r0] - ldr r0, =gUnknown_02022E1A + ldr r0, =gBattle_BG1_Y strh r1, [r0] b _080A47C6 .pool _080A47B8: movs r0, 0x2 bl sub_80A6C68 - ldr r0, =gUnknown_02022E1C + ldr r0, =gBattle_BG2_X strh r4, [r0] - ldr r0, =gUnknown_02022E1E + ldr r0, =gBattle_BG2_Y strh r4, [r0] _080A47C6: add sp, 0x10 @@ -1714,13 +1714,13 @@ task_pA_ma0A_obj_to_bg_pal: @ 80A47D8 ldrsh r0, [r5, r1] cmp r0, 0 bne _080A4870 - ldr r1, =gUnknown_02022E18 + ldr r1, =gBattle_BG1_X lsls r0, r3, 16 asrs r0, 16 ldrh r3, [r5, 0xE] adds r0, r3 strh r0, [r1] - ldr r1, =gUnknown_02022E1A + ldr r1, =gBattle_BG1_Y lsls r0, r2, 16 asrs r0, 16 ldrh r5, [r5, 0x10] @@ -1740,13 +1740,13 @@ task_pA_ma0A_obj_to_bg_pal: @ 80A47D8 b _080A4896 .pool _080A4870: - ldr r1, =gUnknown_02022E1C + ldr r1, =gBattle_BG2_X lsls r0, r3, 16 asrs r0, 16 ldrh r3, [r5, 0xE] adds r0, r3 strh r0, [r1] - ldr r1, =gUnknown_02022E1E + ldr r1, =gBattle_BG2_Y lsls r0, r2, 16 asrs r0, 16 ldrh r5, [r5, 0x10] diff --git a/asm/battle_anim_80D51AC.s b/asm/battle_anim_80D51AC.s index c2ea27485..52b599c4c 100755 --- a/asm/battle_anim_80D51AC.s +++ b/asm/battle_anim_80D51AC.s @@ -200,7 +200,7 @@ _080D5320: _080D5324: movs r0, 0x3 _080D5326: - bl GetBankByPlayerAI + bl GetBankByIdentity lsls r0, 24 lsrs r4, r0, 24 adds r0, r4, 0 diff --git a/asm/battle_anim_80FE840.s b/asm/battle_anim_80FE840.s index f35b2f7da..78abd6a85 100644 --- a/asm/battle_anim_80FE840.s +++ b/asm/battle_anim_80FE840.s @@ -12782,14 +12782,14 @@ sub_8104E74: @ 8104E74 lsrs r0, 24 cmp r0, 0x1 bne _08104ED4 - ldr r0, =gUnknown_02022E18 + ldr r0, =gBattle_BG1_X ldrh r0, [r0] strh r0, [r5, 0x14] ldr r0, =0x04000014 b _08104EDC .pool _08104ED4: - ldr r0, =gUnknown_02022E1C + ldr r0, =gBattle_BG2_X ldrh r0, [r0] strh r0, [r5, 0x14] ldr r0, =0x04000018 @@ -15305,10 +15305,10 @@ sub_81062E8: @ 81062E8 movs r2, 0x1 bl lcd_bg_operations _0810632A: - ldr r0, =gUnknown_02022E18 + ldr r0, =gBattle_BG1_X movs r1, 0 strh r1, [r0] - ldr r4, =gUnknown_02022E1A + ldr r4, =gBattle_BG1_Y strh r1, [r4] movs r0, 0x14 movs r1, 0 @@ -15540,10 +15540,10 @@ sub_81064F8: @ 81064F8 movs r2, 0x1 bl lcd_bg_operations _0810653A: - ldr r0, =gUnknown_02022E18 + ldr r0, =gBattle_BG1_X movs r1, 0 strh r1, [r0] - ldr r4, =gUnknown_02022E1A + ldr r4, =gBattle_BG1_Y strh r1, [r4] movs r0, 0x14 movs r1, 0 @@ -18159,11 +18159,11 @@ _08107A32: beq _08107AB4 ldr r1, =0x0000ffb0 adds r0, r1, 0 - ldr r2, =gUnknown_02022E18 + ldr r2, =gBattle_BG1_X strh r0, [r2] adds r1, 0x20 adds r0, r1, 0 - ldr r2, =gUnknown_02022E1A + ldr r2, =gBattle_BG1_Y strh r0, [r2] movs r0, 0x2 strh r0, [r6, 0x8] @@ -18183,12 +18183,12 @@ _08107AB4: bne _08107AF8 ldr r2, =0x0000ff20 adds r0, r2, 0 - ldr r2, =gUnknown_02022E18 + ldr r2, =gBattle_BG1_X strh r0, [r2] movs r2, 0x80 lsls r2, 1 adds r0, r2, 0 - ldr r2, =gUnknown_02022E1A + ldr r2, =gBattle_BG1_Y strh r0, [r2] movs r0, 0x2 strh r0, [r6, 0x8] @@ -18198,11 +18198,11 @@ _08107AB4: b _08107B0E .pool _08107AF8: - ldr r0, =gUnknown_02022E18 + ldr r0, =gBattle_BG1_X strh r4, [r0] ldr r1, =0x0000ffd0 adds r0, r1, 0 - ldr r2, =gUnknown_02022E1A + ldr r2, =gBattle_BG1_Y strh r0, [r2] ldr r0, =0x0000fffe strh r0, [r6, 0x8] @@ -18210,11 +18210,11 @@ _08107AF8: strh r0, [r6, 0xA] strh r4, [r7, 0xE] _08107B0E: - ldr r0, =gUnknown_02022E18 + ldr r0, =gBattle_BG1_X ldrh r1, [r0] movs r0, 0x14 bl SetGpuReg - ldr r2, =gUnknown_02022E1A + ldr r2, =gBattle_BG1_Y ldrh r1, [r2] movs r0, 0x16 bl SetGpuReg @@ -18264,8 +18264,8 @@ sub_8107B84: @ 8107B84 sub sp, 0x10 lsls r0, 24 lsrs r5, r0, 24 - ldr r1, =gUnknown_02022E18 - ldr r2, =gUnknown_02022E1A + ldr r1, =gBattle_BG1_X + ldr r2, =gBattle_BG1_Y ldr r0, =gTasks lsls r4, r5, 2 adds r4, r5 @@ -18425,8 +18425,8 @@ sub_8107CC4: @ 8107CC4 lsls r0, 24 lsrs r0, 24 adds r5, r0, 0 - ldr r7, =gUnknown_02022E18 - ldr r0, =gUnknown_02022E1A + ldr r7, =gBattle_BG1_X + ldr r0, =gBattle_BG1_Y mov r8, r0 ldr r6, =gTasks lsls r0, r5, 2 @@ -21049,14 +21049,14 @@ sub_8109198: @ 8109198 cmp r4, r0 bne _081091DE movs r0, 0x2 - bl GetBankByPlayerAI + bl GetBankByIdentity ldrb r1, [r5] lsls r0, 24 lsrs r0, 24 cmp r1, r0 beq _081091D6 movs r0, 0x3 - bl GetBankByPlayerAI + bl GetBankByIdentity ldrb r1, [r5] lsls r0, 24 lsrs r0, 24 @@ -26948,10 +26948,10 @@ sub_810C0A0: @ 810C0A0 movs r2, 0x1 bl lcd_bg_operations _0810C0E2: - ldr r0, =gUnknown_02022E18 + ldr r0, =gBattle_BG1_X movs r1, 0 strh r1, [r0] - ldr r4, =gUnknown_02022E1A + ldr r4, =gBattle_BG1_Y strh r1, [r4] movs r0, 0x14 movs r1, 0 @@ -26999,7 +26999,7 @@ sub_810C164: @ 810C164 sub sp, 0x10 lsls r0, 24 lsrs r4, r0, 24 - ldr r1, =gUnknown_02022E18 + ldr r1, =gBattle_BG1_X ldr r2, =0x0000ffff adds r0, r2, 0 ldrh r2, [r1] @@ -27150,10 +27150,10 @@ _0810C29C: movs r2, 0 bl lcd_bg_operations _0810C2B0: - ldr r0, =gUnknown_02022E18 + ldr r0, =gBattle_BG1_X movs r1, 0 strh r1, [r0] - ldr r0, =gUnknown_02022E1A + ldr r0, =gBattle_BG1_Y strh r1, [r0] movs r0, 0x50 movs r1, 0 @@ -27230,10 +27230,10 @@ sub_810C324: @ 810C324 movs r2, 0x1 bl lcd_bg_operations _0810C366: - ldr r0, =gUnknown_02022E18 + ldr r0, =gBattle_BG1_X movs r1, 0 strh r1, [r0] - ldr r4, =gUnknown_02022E1A + ldr r4, =gBattle_BG1_Y strh r1, [r4] movs r0, 0x14 movs r1, 0 @@ -27283,7 +27283,7 @@ sub_810C3F0: @ 810C3F0 sub sp, 0x10 lsls r0, 24 lsrs r4, r0, 24 - ldr r2, =gUnknown_02022E18 + ldr r2, =gBattle_BG1_X ldr r3, =gTasks lsls r1, r4, 2 adds r1, r4 @@ -27422,10 +27422,10 @@ _0810C50C: movs r2, 0 bl lcd_bg_operations _0810C520: - ldr r0, =gUnknown_02022E18 + ldr r0, =gBattle_BG1_X movs r1, 0 strh r1, [r0] - ldr r0, =gUnknown_02022E1A + ldr r0, =gBattle_BG1_Y strh r1, [r0] movs r0, 0x50 movs r1, 0 @@ -28050,7 +28050,7 @@ sub_810C9E4: @ 810C9E4 ldrh r0, [r4, 0x2] lsls r0, 20 lsrs r0, 24 - bl GetBankByPlayerAI + bl GetBankByIdentity lsls r0, 24 lsrs r5, r0, 24 adds r0, r5, 0 @@ -33064,7 +33064,7 @@ _0810F212: bne _0810F2B8 _0810F22E: movs r0, 0x1 - bl GetBankByPlayerAI + bl GetBankByIdentity lsls r0, 24 lsrs r4, r0, 24 adds r7, r4, 0 @@ -33193,7 +33193,7 @@ sub_810F340: @ 810F340 push {r4,r5,lr} adds r5, r0, 0 movs r0, 0x1 - bl GetBankByPlayerAI + bl GetBankByIdentity lsls r0, 24 lsrs r4, r0, 24 movs r1, 0x3C @@ -33370,7 +33370,7 @@ sub_810F46C: @ 810F46C cmp r0, 0 bne _0810F502 movs r0, 0x1 - bl GetBankByPlayerAI + bl GetBankByIdentity lsls r0, 24 lsrs r4, r0, 24 adds r6, r4, 0 @@ -33441,7 +33441,7 @@ sub_810F524: @ 810F524 cmp r0, 0 bne _0810F57C movs r0, 0x1 - bl GetBankByPlayerAI + bl GetBankByIdentity lsls r0, 24 lsrs r0, 24 adds r4, r0, 0 @@ -34597,14 +34597,14 @@ _0810FE92: lsrs r0, 24 cmp r0, 0x1 bne _0810FEB8 - ldr r0, =gUnknown_02022E18 + ldr r0, =gBattle_BG1_X ldrh r0, [r0] strh r0, [r4, 0x1C] ldr r0, =0x04000014 b _0810FEC0 .pool _0810FEB8: - ldr r0, =gUnknown_02022E1C + ldr r0, =gBattle_BG2_X ldrh r0, [r0] strh r0, [r4, 0x1C] ldr r0, =0x04000018 @@ -36221,9 +36221,9 @@ sub_8110BCC: @ 8110BCC movs r2, 0x1 bl lcd_bg_operations _08110C10: - ldr r0, =gUnknown_02022E18 + ldr r0, =gBattle_BG1_X strh r5, [r0] - ldr r4, =gUnknown_02022E1A + ldr r4, =gBattle_BG1_Y strh r5, [r4] movs r0, 0x14 movs r1, 0 @@ -36293,7 +36293,7 @@ sub_8110CB0: @ 8110CB0 adds r2, r1, 0 cmp r0, 0 bne _08110CE4 - ldr r1, =gUnknown_02022E18 + ldr r1, =gBattle_BG1_X ldr r3, =0x0000fffa adds r0, r3, 0 ldrh r3, [r1] @@ -36301,12 +36301,12 @@ sub_8110CB0: @ 8110CB0 b _08110CEA .pool _08110CE4: - ldr r1, =gUnknown_02022E18 + ldr r1, =gBattle_BG1_X ldrh r0, [r1] adds r0, 0x6 _08110CEA: strh r0, [r1] - ldr r1, =gUnknown_02022E1A + ldr r1, =gBattle_BG1_Y ldr r3, =0x0000ffff adds r0, r3, 0 ldrh r3, [r1] @@ -36442,10 +36442,10 @@ _08110DFC: movs r2, 0 bl lcd_bg_operations _08110E10: - ldr r0, =gUnknown_02022E18 + ldr r0, =gBattle_BG1_X movs r1, 0 strh r1, [r0] - ldr r0, =gUnknown_02022E1A + ldr r0, =gBattle_BG1_Y strh r1, [r0] movs r0, 0x50 movs r1, 0 @@ -41115,13 +41115,13 @@ sub_81133E8: @ 81133E8 bne _08113424 ldr r0, =0x04000014 str r0, [sp] - ldr r0, =gUnknown_02022E18 + ldr r0, =gBattle_BG1_X b _0811342A .pool _08113424: ldr r0, =0x04000018 str r0, [sp] - ldr r0, =gUnknown_02022E1C + ldr r0, =gBattle_BG2_X _0811342A: ldrh r0, [r0] strh r0, [r4, 0xC] @@ -42107,7 +42107,7 @@ _08113C1E: add r4, sp, 0xC adds r0, r4, 0 bl sub_80A6B30 - ldr r0, =gUnknown_02022E1A + ldr r0, =gBattle_BG1_Y ldrh r0, [r0] strh r0, [r5, 0x1C] ldr r1, =0x00003f42 @@ -42125,11 +42125,11 @@ _08113C1E: lsls r0, 24 cmp r0, 0 bne _08113CB0 - ldr r1, =gUnknown_02022E1C + ldr r1, =gBattle_BG2_X b _08113CAA .pool _08113C80: - ldr r0, =gUnknown_02022E1E + ldr r0, =gBattle_BG2_Y ldrh r0, [r0] strh r0, [r5, 0x1C] ldr r1, =0x00003f44 @@ -42146,7 +42146,7 @@ _08113C80: lsls r0, 24 cmp r0, 0 bne _08113CB0 - ldr r1, =gUnknown_02022E18 + ldr r1, =gBattle_BG1_X _08113CAA: ldrh r0, [r1] adds r0, 0xF0 @@ -42426,14 +42426,14 @@ _08113EF8: ldr r1, =0x00003f42 movs r0, 0x50 bl SetGpuReg - ldr r1, =gUnknown_02022E1C + ldr r1, =gBattle_BG2_X b _08113F2E .pool _08113F24: ldr r1, =0x00003f44 movs r0, 0x50 bl SetGpuReg - ldr r1, =gUnknown_02022E18 + ldr r1, =gBattle_BG1_X _08113F2E: ldrh r0, [r1] adds r0, 0xF0 @@ -42447,7 +42447,7 @@ _08113F40: bne _08113F68 mov r0, sp bl sub_80A6B30 - ldr r0, =gUnknown_02022E1A + ldr r0, =gBattle_BG1_Y ldrh r0, [r0] strh r0, [r5, 0x1C] mov r0, sp @@ -42459,7 +42459,7 @@ _08113F40: b _08113F78 .pool _08113F68: - ldr r0, =gUnknown_02022E1E + ldr r0, =gBattle_BG2_Y ldrh r0, [r0] strh r0, [r5, 0x1C] movs r0, 0 @@ -43324,7 +43324,7 @@ _0811465C: lsls r1, 4 movs r2, 0x20 bl LoadCompressedPalette - ldr r2, =gUnknown_02022E18 + ldr r2, =gBattle_BG1_X ldr r0, =gSprites lsls r1, r4, 4 adds r1, r4 @@ -43334,7 +43334,7 @@ _0811465C: negs r0, r0 adds r0, 0x60 strh r0, [r2] - ldr r2, =gUnknown_02022E1A + ldr r2, =gBattle_BG1_Y ldrh r0, [r1, 0x22] negs r0, r0 adds r0, 0x20 @@ -43399,7 +43399,7 @@ sub_8114748: @ 8114748 adds r0, 0x4 movs r5, 0 strh r0, [r4, 0x1C] - ldr r2, =gUnknown_02022E18 + ldr r2, =gBattle_BG1_X ldrh r3, [r2] subs r1, r3, 0x4 strh r1, [r2] @@ -43586,7 +43586,7 @@ _08114902: beq _0811492E _08114908: adds r0, r4, 0 - bl GetBankByPlayerAI + bl GetBankByIdentity lsls r0, 24 lsrs r4, r0, 24 adds r0, r4, 0 @@ -44104,17 +44104,17 @@ _08114D3C: strh r0, [r4, 0x1E] cmp r0, 0x1 bne _08114D70 - ldr r0, =gUnknown_02022E18 + ldr r0, =gBattle_BG1_X ldrh r0, [r0] strh r0, [r4, 0x20] - ldr r0, =gUnknown_02022E1A + ldr r0, =gBattle_BG1_Y b _08114D78 .pool _08114D70: - ldr r0, =gUnknown_02022E1C + ldr r0, =gBattle_BG2_X ldrh r0, [r0] strh r0, [r4, 0x20] - ldr r0, =gUnknown_02022E1E + ldr r0, =gBattle_BG2_Y _08114D78: ldrh r0, [r0] strh r0, [r4, 0x22] @@ -44189,11 +44189,11 @@ _08114DF6: ldrsh r0, [r4, r1] cmp r0, 0x1 bne _08114E20 - ldr r1, =gUnknown_02022E1A + ldr r1, =gBattle_BG1_Y b _08114E22 .pool _08114E20: - ldr r1, =gUnknown_02022E1E + ldr r1, =gBattle_BG2_Y _08114E22: ldrh r0, [r4, 0x22] subs r0, r2 @@ -44210,11 +44210,11 @@ _08114E22: ldrsh r0, [r4, r3] cmp r0, 0x1 bne _08114E4C - ldr r1, =gUnknown_02022E1A + ldr r1, =gBattle_BG1_Y b _08114E4E .pool _08114E4C: - ldr r1, =gUnknown_02022E1E + ldr r1, =gBattle_BG2_Y _08114E4E: ldrh r0, [r4, 0x22] subs r0, r2 @@ -44296,11 +44296,11 @@ sub_8114EB4: @ 8114EB4 lsrs r0, 24 cmp r0, 0x1 bne _08114F00 - ldr r0, =gUnknown_02022E1A + ldr r0, =gBattle_BG1_Y b _08114F02 .pool _08114F00: - ldr r0, =gUnknown_02022E1E + ldr r0, =gBattle_BG2_Y _08114F02: strh r4, [r0] adds r0, r5, 0 @@ -44450,11 +44450,11 @@ _08115018: strh r0, [r4, 0x1E] cmp r0, 0x1 bne _08115044 - ldr r0, =gUnknown_02022E18 + ldr r0, =gBattle_BG1_X b _08115046 .pool _08115044: - ldr r0, =gUnknown_02022E1C + ldr r0, =gBattle_BG2_X _08115046: ldrh r0, [r0] strh r0, [r4, 0x20] @@ -44540,13 +44540,13 @@ sub_81150E0: @ 81150E0 lsrs r4, r2, 16 cmp r0, 0x1 bne _08115104 - ldr r0, =gUnknown_02022E18 + ldr r0, =gBattle_BG1_X ldrh r3, [r0] ldr r0, =0x04000014 b _0811510A .pool _08115104: - ldr r0, =gUnknown_02022E1C + ldr r0, =gBattle_BG2_X ldrh r3, [r0] ldr r0, =0x04000018 _0811510A: @@ -47996,7 +47996,7 @@ _08116CAC: adds r1, 0x1 movs r2, 0x2 bl LoadPalette - ldr r2, =gUnknown_02022E18 + ldr r2, =gBattle_BG1_X ldr r0, =gSprites lsls r1, r4, 4 adds r1, r4 @@ -48006,7 +48006,7 @@ _08116CAC: negs r0, r0 adds r0, 0x20 strh r0, [r2] - ldr r2, =gUnknown_02022E1A + ldr r2, =gBattle_BG1_Y ldrh r0, [r1, 0x22] negs r0, r0 adds r0, 0x20 @@ -48050,7 +48050,7 @@ sub_8116D64: @ 8116D64 movs r1, 0 mov r8, r1 strh r0, [r5, 0x1C] - ldr r7, =gUnknown_02022E1A + ldr r7, =gBattle_BG1_Y ldrh r2, [r7] subs r1, r2, 0x4 strh r1, [r7] @@ -48537,10 +48537,10 @@ _081171F8: movs r2, 0x20 bl LoadCompressedPalette _08117206: - ldr r3, =gUnknown_02022E18 + ldr r3, =gBattle_BG1_X movs r2, 0 strh r2, [r3] - ldr r0, =gUnknown_02022E1A + ldr r0, =gBattle_BG1_Y strh r2, [r0] ldr r1, =gUnknown_0203A110 ldr r0, [r1] @@ -48645,7 +48645,7 @@ sub_81172EC: @ 81172EC push {r4-r6,lr} lsls r0, 24 lsrs r6, r0, 24 - ldr r2, =gUnknown_02022E1A + ldr r2, =gBattle_BG1_Y ldr r1, =gTasks lsls r0, r6, 2 adds r0, r6 @@ -49497,10 +49497,10 @@ _081179CC: ldr r0, [sp, 0x5C] movs r2, 0x20 bl LoadCompressedPalette - ldr r0, =gUnknown_02022E18 + ldr r0, =gBattle_BG1_X movs r1, 0 strh r1, [r0] - ldr r0, =gUnknown_02022E1A + ldr r0, =gBattle_BG1_Y strh r1, [r0] ldr r1, =gTasks mov r2, r9 @@ -49563,7 +49563,7 @@ _08117A7E: ldrsh r0, [r3, r1] cmp r0, 0 bge _08117AA4 - ldr r2, =gUnknown_02022E1A + ldr r2, =gBattle_BG1_Y lsls r1, r4, 16 asrs r1, 24 ldrh r0, [r2] @@ -49572,7 +49572,7 @@ _08117A7E: b _08117AB0 .pool _08117AA4: - ldr r1, =gUnknown_02022E1A + ldr r1, =gBattle_BG1_Y lsls r0, r4, 16 asrs r0, 24 ldrh r2, [r1] @@ -50529,14 +50529,14 @@ sub_811828C: @ 811828C lsls r0, 24 lsrs r0, 24 bl DestroyTask - ldr r0, =gUnknown_02022E18 + ldr r0, =gBattle_BG1_X movs r1, 0 strh r1, [r0] - ldr r0, =gUnknown_02022E1A + ldr r0, =gBattle_BG1_Y strh r1, [r0] - ldr r0, =gUnknown_02022E1C + ldr r0, =gBattle_BG2_X strh r1, [r0] - ldr r0, =gUnknown_02022E1E + ldr r0, =gBattle_BG2_Y strh r1, [r0] movs r0, 0x50 movs r1, 0 @@ -50569,7 +50569,7 @@ task_battle_intro_80BC47C: @ 81182EC sub sp, 0x4 lsls r0, 24 lsrs r4, r0, 24 - ldr r1, =gUnknown_02022E18 + ldr r1, =gBattle_BG1_X ldrh r0, [r1] adds r0, 0x6 strh r0, [r1] @@ -50697,7 +50697,7 @@ _08118400: ldrsh r0, [r2, r1] cmp r0, 0x1 bne _08118420 - ldr r2, =gUnknown_02022E1A + ldr r2, =gBattle_BG1_Y ldrh r1, [r2] ldr r0, =0x0000ffb0 cmp r1, r0 @@ -50706,7 +50706,7 @@ _08118400: b _0811842C .pool _08118420: - ldr r2, =gUnknown_02022E1A + ldr r2, =gBattle_BG1_Y ldrh r1, [r2] ldr r0, =0x0000ffc8 cmp r1, r0 @@ -50861,13 +50861,13 @@ _08118568: cmp r0, 0x4 bne _08118580 _0811856C: - ldr r1, =gUnknown_02022E18 + ldr r1, =gBattle_BG1_X ldrh r0, [r1] adds r0, 0x8 b _0811857E .pool _08118578: - ldr r1, =gUnknown_02022E18 + ldr r1, =gBattle_BG1_X ldrh r0, [r1] adds r0, 0x6 _0811857E: @@ -50882,7 +50882,7 @@ _08118580: adds r6, r0, 0 cmp r1, 0x4 bne _081185E4 - ldr r7, =gUnknown_02022E1A + ldr r7, =gBattle_BG1_Y ldrh r0, [r4, 0x14] bl Cos2 lsls r0, 16 @@ -51202,7 +51202,7 @@ task_battle_intro_anim: @ 8118844 sub sp, 0x4 lsls r0, 24 lsrs r5, r0, 24 - ldr r1, =gUnknown_02022E18 + ldr r1, =gBattle_BG1_X ldrh r0, [r1] adds r0, 0x8 strh r0, [r1] @@ -51505,7 +51505,7 @@ task00_battle_intro_wireless: @ 8118AC0 ldrsh r0, [r7, r2] cmp r0, 0 bne _08118B36 - ldr r2, =gUnknown_02022E18 + ldr r2, =gBattle_BG1_X ldrh r1, [r2] movs r0, 0x80 lsls r0, 8 @@ -51519,7 +51519,7 @@ task00_battle_intro_wireless: @ 8118AC0 _08118AFE: adds r0, r1, 0x3 strh r0, [r2] - ldr r1, =gUnknown_02022E1C + ldr r1, =gBattle_BG2_X ldrh r0, [r1] subs r0, 0x3 strh r0, [r1] @@ -51878,10 +51878,10 @@ _08118DD4: ldr r2, =0x0000ffd0 adds r0, r2, 0 strh r0, [r1] - ldr r1, =gUnknown_02022E18 + ldr r1, =gBattle_BG1_X movs r0, 0xF0 strh r0, [r1] - ldr r1, =gUnknown_02022E1C + ldr r1, =gBattle_BG2_X subs r2, 0xC0 adds r0, r2, 0 strh r0, [r1] @@ -51958,10 +51958,10 @@ _08118EC2: subs r0, r1, 0x2 strh r0, [r3, 0xC] _08118ED8: - ldr r1, =gUnknown_02022E18 + ldr r1, =gBattle_BG1_X ldrh r0, [r3, 0xC] strh r0, [r1] - ldr r2, =gUnknown_02022E1C + ldr r2, =gBattle_BG2_X negs r1, r0 strh r1, [r2] lsls r0, 16 @@ -51977,7 +51977,7 @@ _08118F00: ldrh r0, [r1] adds r3, r0, 0x2 strh r3, [r1] - ldr r1, =gUnknown_02022E1E + ldr r1, =gBattle_BG2_Y ldrh r0, [r1] adds r0, 0x2 strh r0, [r1] @@ -52078,7 +52078,7 @@ sub_8118FBC: @ 8118FBC lsls r5, 16 lsrs r5, 16 adds r0, r4, 0 - bl GetBankByPlayerAI + bl GetBankByIdentity lsls r0, 24 lsrs r0, 24 ldr r1, =gBattleSpritesGfx diff --git a/asm/battle_anim_815A0D4.s b/asm/battle_anim_815A0D4.s index 46b09081d..f219c6988 100755 --- a/asm/battle_anim_815A0D4.s +++ b/asm/battle_anim_815A0D4.s @@ -1655,11 +1655,11 @@ _0815AE08: strh r2, [r5, 0x16] cmp r7, 0x1 bne _0815AE30 - ldr r0, =gUnknown_02022E18 + ldr r0, =gBattle_BG1_X b _0815AE32 .pool _0815AE30: - ldr r0, =gUnknown_02022E1C + ldr r0, =gBattle_BG2_X _0815AE32: ldrh r2, [r0] strh r2, [r5, 0x18] @@ -3385,7 +3385,7 @@ _0815BC02: lsls r0, 24 cmp r0, 0 beq _0815BC34 - ldr r1, =gUnknown_02022E18 + ldr r1, =gBattle_BG1_X ldr r3, =0x0000ffc8 b _0815BC5C .pool @@ -3396,19 +3396,19 @@ _0815BC34: lsls r0, 24 cmp r0, 0 beq _0815BC58 - ldr r1, =gUnknown_02022E18 + ldr r1, =gBattle_BG1_X ldr r2, =0x0000ff79 adds r0, r2, 0 b _0815BC5E .pool _0815BC58: - ldr r1, =gUnknown_02022E18 + ldr r1, =gBattle_BG1_X ldr r3, =0x0000fff6 _0815BC5C: adds r0, r3, 0 _0815BC5E: strh r0, [r1] - ldr r1, =gUnknown_02022E1A + ldr r1, =gBattle_BG1_Y movs r0, 0 strh r0, [r1] mov r0, sp @@ -3428,10 +3428,10 @@ _0815BC5E: adds r1, r4 lsls r1, 3 adds r1, r0 - ldr r0, =gUnknown_02022E18 + ldr r0, =gBattle_BG1_X ldrh r0, [r0] strh r0, [r1, 0x1C] - ldr r0, =gUnknown_02022E1A + ldr r0, =gBattle_BG1_Y ldrh r0, [r0] strh r0, [r1, 0x1E] ldrh r0, [r1, 0x8] @@ -3507,7 +3507,7 @@ _0815BD20: ldrsh r0, [r4, r2] cmp r0, 0 bne _0815BDF2 - ldr r2, =gUnknown_02022E18 + ldr r2, =gBattle_BG1_X ldr r1, =gUnknown_085CE460 movs r3, 0xC ldrsh r0, [r4, r3] @@ -3577,10 +3577,10 @@ _0815BDC8: movs r1, 0x4 movs r2, 0x1 bl lcd_bg_operations - ldr r0, =gUnknown_02022E18 + ldr r0, =gBattle_BG1_X movs r1, 0 strh r1, [r0] - ldr r0, =gUnknown_02022E1A + ldr r0, =gBattle_BG1_Y strh r1, [r0] movs r0, 0x50 movs r1, 0 @@ -3990,7 +3990,7 @@ _0815C124: lsls r0, 24 cmp r0, 0 beq _0815C15C - ldr r1, =gUnknown_02022E18 + ldr r1, =gBattle_BG1_X ldr r3, =0x0000ffc8 adds r0, r3, 0 b _0815C1CA @@ -4008,48 +4008,48 @@ _0815C15C: bne _0815C1B4 cmp r4, 0x1 bne _0815C180 - ldr r1, =gUnknown_02022E18 + ldr r1, =gBattle_BG1_X ldr r2, =0x0000ff65 adds r0, r2, 0 strh r0, [r1] _0815C180: cmp r4, 0x3 bne _0815C18C - ldr r1, =gUnknown_02022E18 + ldr r1, =gBattle_BG1_X ldr r3, =0x0000ff8d adds r0, r3, 0 strh r0, [r1] _0815C18C: cmp r4, 0 bne _0815C196 - ldr r1, =gUnknown_02022E18 + ldr r1, =gBattle_BG1_X movs r0, 0xE strh r0, [r1] _0815C196: cmp r4, 0x2 bne _0815C1CC - ldr r1, =gUnknown_02022E18 + ldr r1, =gBattle_BG1_X ldr r2, =0x0000ffec b _0815C1C8 .pool _0815C1B4: cmp r4, 0x1 bne _0815C1C0 - ldr r1, =gUnknown_02022E18 + ldr r1, =gBattle_BG1_X ldr r3, =0x0000ff79 adds r0, r3, 0 strh r0, [r1] _0815C1C0: cmp r4, 0 bne _0815C1CC - ldr r1, =gUnknown_02022E18 + ldr r1, =gBattle_BG1_X ldr r2, =0x0000fff6 _0815C1C8: adds r0, r2, 0 _0815C1CA: strh r0, [r1] _0815C1CC: - ldr r1, =gUnknown_02022E1A + ldr r1, =gBattle_BG1_Y movs r0, 0 strh r0, [r1] mov r0, sp @@ -4069,10 +4069,10 @@ _0815C1CC: adds r1, r6 lsls r1, 3 adds r1, r0 - ldr r0, =gUnknown_02022E18 + ldr r0, =gBattle_BG1_X ldrh r0, [r0] strh r0, [r1, 0x1C] - ldr r0, =gUnknown_02022E1A + ldr r0, =gBattle_BG1_Y ldrh r0, [r0] strh r0, [r1, 0x1E] b _0815C2A4 @@ -4092,7 +4092,7 @@ _0815C224: lsrs r0, 24 cmp r0, 0x1 bne _0815C268 - ldr r2, =gUnknown_02022E18 + ldr r2, =gBattle_BG1_X ldr r1, =gUnknown_085CE4A4 movs r3, 0xC ldrsh r0, [r5, r3] @@ -4105,7 +4105,7 @@ _0815C224: b _0815C27A .pool _0815C268: - ldr r2, =gUnknown_02022E18 + ldr r2, =gBattle_BG1_X ldr r1, =gUnknown_085CE4A4 movs r3, 0xC ldrsh r0, [r5, r3] @@ -4235,10 +4235,10 @@ _0815C36C: movs r1, 0x4 movs r2, 0x1 bl lcd_bg_operations - ldr r0, =gUnknown_02022E18 + ldr r0, =gBattle_BG1_X movs r1, 0 strh r1, [r0] - ldr r0, =gUnknown_02022E1A + ldr r0, =gBattle_BG1_Y strh r1, [r0] movs r0, 0x50 movs r1, 0 @@ -6133,9 +6133,9 @@ _0815D2B4: ldr r1, =0x00003f42 movs r0, 0x50 bl SetGpuReg - ldr r0, =gUnknown_02022E18 + ldr r0, =gBattle_BG1_X ldrh r5, [r0] - ldr r0, =gUnknown_02022E1A + ldr r0, =gBattle_BG1_Y b _0815D316 .pool _0815D304: @@ -6144,9 +6144,9 @@ _0815D304: ldr r1, =0x00003f44 movs r0, 0x50 bl SetGpuReg - ldr r0, =gUnknown_02022E1C + ldr r0, =gBattle_BG2_X ldrh r5, [r0] - ldr r0, =gUnknown_02022E1E + ldr r0, =gBattle_BG2_Y _0815D316: ldrh r3, [r0] movs r7, 0 @@ -6223,17 +6223,17 @@ sub_815D398: @ 815D398 lsrs r0, 24 cmp r0, 0x1 bne _0815D3D8 - ldr r0, =gUnknown_02022E18 + ldr r0, =gBattle_BG1_X ldrh r0, [r0] str r0, [sp, 0x4] - ldr r0, =gUnknown_02022E1A + ldr r0, =gBattle_BG1_Y b _0815D3E0 .pool _0815D3D8: - ldr r0, =gUnknown_02022E1C + ldr r0, =gBattle_BG2_X ldrh r0, [r0] str r0, [sp, 0x4] - ldr r0, =gUnknown_02022E1E + ldr r0, =gBattle_BG2_Y _0815D3E0: ldrh r0, [r0] str r0, [sp, 0x8] diff --git a/asm/battle_anim_8170478.s b/asm/battle_anim_8170478.s index abbca8ff7..85f94c20e 100644 --- a/asm/battle_anim_8170478.s +++ b/asm/battle_anim_8170478.s @@ -168,12 +168,12 @@ sub_8170478: @ 8170478 lsls r1, 4 movs r2, 0x20 bl LoadCompressedPalette - ldr r1, =gUnknown_02022E18 + ldr r1, =gBattle_BG1_X ldrh r0, [r7, 0x20] negs r0, r0 adds r0, 0x20 strh r0, [r1] - ldr r1, =gUnknown_02022E1A + ldr r1, =gBattle_BG1_Y ldrh r0, [r7, 0x22] negs r0, r0 subs r0, 0x20 @@ -225,7 +225,7 @@ sub_8170660: @ 8170660 adds r1, r0 movs r3, 0 strh r1, [r5, 0x22] - ldr r2, =gUnknown_02022E1A + ldr r2, =gBattle_BG1_Y lsls r0, r1, 16 lsrs r0, 24 ldrh r4, [r2] @@ -1283,7 +1283,7 @@ _08170F54: lsls r4, 24 lsrs r4, 24 movs r0, 0x1 - bl GetBankByPlayerAI + bl GetBankByIdentity lsls r0, 24 lsrs r0, 24 bl sub_80A82E4 @@ -1335,7 +1335,7 @@ _08170F54: ldr r0, =SpriteCallbackDummy str r0, [r4] movs r0, 0 - bl GetBankByPlayerAI + bl GetBankByIdentity ldr r1, =gBankSpriteIds lsls r0, 24 lsrs r0, 24 @@ -1371,7 +1371,7 @@ sub_8171030: @ 8171030 lsrs r5, r0, 24 ldr r6, =gSprites movs r0, 0 - bl GetBankByPlayerAI + bl GetBankByIdentity ldr r1, =gBankSpriteIds lsls r0, 24 lsrs r0, 24 @@ -1422,7 +1422,7 @@ sub_81710A8: @ 81710A8 lsrs r5, r0, 24 ldr r6, =gSprites movs r0, 0 - bl GetBankByPlayerAI + bl GetBankByIdentity ldr r4, =gBankSpriteIds lsls r0, 24 lsrs r0, 24 @@ -1438,7 +1438,7 @@ sub_81710A8: @ 81710A8 cmp r0, 0 bge _081710F4 movs r0, 0 - bl GetBankByPlayerAI + bl GetBankByIdentity lsls r0, 24 lsrs r0, 24 adds r0, r4 @@ -5575,7 +5575,7 @@ sub_817330C: @ 817330C movs r0, 0x1E strh r0, [r4, 0x2E] movs r0, 0x1 - bl GetBankByPlayerAI + bl GetBankByIdentity lsls r0, 24 lsrs r0, 24 movs r1, 0 @@ -5587,7 +5587,7 @@ sub_817330C: @ 817330C adds r0, r1 strh r0, [r4, 0x32] movs r0, 0x1 - bl GetBankByPlayerAI + bl GetBankByIdentity lsls r0, 24 lsrs r0, 24 movs r1, 0x1 @@ -5732,7 +5732,7 @@ sub_817345C: @ 817345C .pool _08173478: movs r0, 0 - bl GetBankByPlayerAI + bl GetBankByIdentity ldr r1, =gAnimationBankAttacker strb r0, [r1] movs r0, 0x1 @@ -5740,12 +5740,12 @@ _08173478: .pool _0817348C: movs r0, 0x1 - bl GetBankByPlayerAI + bl GetBankByIdentity ldr r1, =gAnimationBankAttacker strb r0, [r1] movs r0, 0 _08173498: - bl GetBankByPlayerAI + bl GetBankByIdentity ldr r1, =gAnimationBankTarget strb r0, [r1] _081734A0: diff --git a/asm/battle_controller_opponent.s b/asm/battle_controller_opponent.s index 4400217ae..69d4776d4 100644 --- a/asm/battle_controller_opponent.s +++ b/asm/battle_controller_opponent.s @@ -5323,7 +5323,7 @@ _08062062: cmp r0, 0 beq _0806209C movs r0, 0 - bl GetBankByPlayerAI + bl GetBankByIdentity ldr r5, =gBankTarget strb r0, [r5] ldr r0, =gAbsentBankFlags @@ -5337,7 +5337,7 @@ _08062062: cmp r1, 0 beq _0806209C movs r0, 0x2 - bl GetBankByPlayerAI + bl GetBankByIdentity strb r0, [r5] _0806209C: ldr r0, =gBankTarget @@ -5394,7 +5394,7 @@ _08062108: lsls r1, 24 lsrs r1, 24 adds r0, r1, 0 - bl GetBankByPlayerAI + bl GetBankByIdentity adds r2, r0, 0 lsls r2, 24 lsrs r2, 16 @@ -5406,7 +5406,7 @@ _08062108: .pool _0806213C: movs r0, 0 - bl GetBankByPlayerAI + bl GetBankByIdentity adds r2, r0, 0 lsls r2, 24 lsrs r2, 16 @@ -5468,7 +5468,7 @@ sub_8062188: @ 8062188 cmp r0, 0 bne _080621D4 movs r0, 0x1 - bl GetBankByPlayerAI + bl GetBankByIdentity lsls r0, 24 lsrs r5, r0, 24 adds r7, r5, 0 @@ -5476,11 +5476,11 @@ sub_8062188: @ 8062188 .pool _080621D4: movs r0, 0x1 - bl GetBankByPlayerAI + bl GetBankByIdentity lsls r0, 24 lsrs r7, r0, 24 movs r0, 0x3 - bl GetBankByPlayerAI + bl GetBankByIdentity lsls r0, 24 lsrs r5, r0, 24 _080621E8: diff --git a/asm/battle_controller_player.s b/asm/battle_controller_player.s index ddb739b72..5f7e1b954 100644 --- a/asm/battle_controller_player.s +++ b/asm/battle_controller_player.s @@ -358,7 +358,7 @@ _0805775A: cmp r0, 0x2 bne _080577E8 movs r0, 0 - bl GetBankByPlayerAI + bl GetBankByIdentity ldr r1, =gAbsentBankFlags ldrb r1, [r1] ldr r2, =gBitTable @@ -622,7 +622,7 @@ _080579F0: mov r1, sp adds r0, r1, r4 ldrb r0, [r0] - bl GetBankByPlayerAI + bl GetBankByIdentity strb r0, [r5] ldr r1, =gNoOfAllBanks lsls r0, 24 @@ -750,7 +750,7 @@ _08057B14: mov r1, sp adds r0, r1, r4 ldrb r0, [r0] - bl GetBankByPlayerAI + bl GetBankByIdentity strb r0, [r5] ldr r1, =gNoOfAllBanks lsls r0, 24 @@ -942,7 +942,7 @@ _08057CC4: movs r0, 0x1 ands r0, r1 eors r0, r2 - bl GetBankByPlayerAI + bl GetBankByIdentity ldr r1, =gUnknown_03005D74 strb r0, [r1] _08057CDE: @@ -1035,7 +1035,7 @@ _08057D80: .pool _08057DA8: movs r0, 0x1 - bl GetBankByPlayerAI + bl GetBankByIdentity ldr r1, =gAbsentBankFlags ldrb r1, [r1] ldr r2, =gBitTable @@ -1052,7 +1052,7 @@ _08057DA8: _08057DD0: movs r0, 0x1 _08057DD2: - bl GetBankByPlayerAI + bl GetBankByIdentity ldr r1, =gUnknown_03005D74 _08057DD8: strb r0, [r1] @@ -8024,7 +8024,7 @@ sub_805BBC4: @ 805BBC4 ldr r5, =gActiveBank ldrb r4, [r5] movs r0, 0x1 - bl GetBankByPlayerAI + bl GetBankByIdentity adds r2, r0, 0 lsls r2, 24 lsrs r2, 24 @@ -8063,7 +8063,7 @@ sub_805BC18: @ 805BC18 strb r0, [r1] ldrb r4, [r5] movs r0, 0x1 - bl GetBankByPlayerAI + bl GetBankByIdentity adds r2, r0, 0 lsls r2, 24 lsrs r2, 24 @@ -8551,7 +8551,7 @@ _0805C062: movs r1, 0 bl sub_8059CB4 ldr r0, =gText_WhatWillPkmnDo - bl StrCpyDecodeToDisplayedStringBattle + bl BattleStringExpandPlaceholdersToDisplayedString ldr r0, =gDisplayedStringBattle movs r1, 0x1 bl sub_814F9EC diff --git a/asm/battle_controller_player_partner.s b/asm/battle_controller_player_partner.s index f14b5bc51..784eacab1 100644 --- a/asm/battle_controller_player_partner.s +++ b/asm/battle_controller_player_partner.s @@ -5045,7 +5045,7 @@ _081BDB02: cmp r0, 0 beq _081BDB3C movs r0, 0x1 - bl GetBankByPlayerAI + bl GetBankByIdentity ldr r4, =gBankTarget strb r0, [r4] ldr r0, =gAbsentBankFlags @@ -5059,7 +5059,7 @@ _081BDB02: cmp r1, 0 beq _081BDB3C movs r0, 0x3 - bl GetBankByPlayerAI + bl GetBankByIdentity strb r0, [r4] _081BDB3C: ldr r0, =gBankTarget @@ -5093,11 +5093,11 @@ sub_81BDB7C: @ 81BDB7C cmp r4, 0x6 bne _081BDBD0 movs r0, 0 - bl GetBankByPlayerAI + bl GetBankByIdentity lsls r0, 24 lsrs r6, r0, 24 movs r0, 0x2 - bl GetBankByPlayerAI + bl GetBankByIdentity lsls r0, 24 lsrs r5, r0, 24 movs r4, 0x3 diff --git a/asm/battle_controller_safari.s b/asm/battle_controller_safari.s index b02f95471..cc149ea4f 100644 --- a/asm/battle_controller_safari.s +++ b/asm/battle_controller_safari.s @@ -700,7 +700,7 @@ sub_8159910: @ 8159910 ldr r5, =gActiveBank ldrb r4, [r5] movs r0, 0x1 - bl GetBankByPlayerAI + bl GetBankByIdentity adds r2, r0, 0 lsls r2, 24 lsrs r2, 24 @@ -739,7 +739,7 @@ sub_8159964: @ 8159964 strb r0, [r1] ldrb r4, [r5] movs r0, 0x1 - bl GetBankByPlayerAI + bl GetBankByIdentity adds r2, r0, 0 lsls r2, 24 lsrs r2, 24 @@ -879,7 +879,7 @@ _08159AAE: movs r1, 0 bl sub_8059CB4 ldr r0, =gText_WhatWillPkmnDo2 - bl StrCpyDecodeToDisplayedStringBattle + bl BattleStringExpandPlaceholdersToDisplayedString ldr r0, =gDisplayedStringBattle movs r1, 0x1 bl sub_814F9EC diff --git a/asm/battle_controller_wally.s b/asm/battle_controller_wally.s index e723a522b..eab717466 100644 --- a/asm/battle_controller_wally.s +++ b/asm/battle_controller_wally.s @@ -3232,7 +3232,7 @@ sub_816A084: @ 816A084 ldr r5, =gActiveBank ldrb r4, [r5] movs r0, 0x1 - bl GetBankByPlayerAI + bl GetBankByIdentity adds r2, r0, 0 lsls r2, 24 lsrs r2, 24 @@ -3271,7 +3271,7 @@ sub_816A0D8: @ 816A0D8 strb r0, [r1] ldrb r4, [r5] movs r0, 0x1 - bl GetBankByPlayerAI + bl GetBankByIdentity adds r2, r0, 0 lsls r2, 24 lsrs r2, 24 @@ -3693,7 +3693,7 @@ _0816A48A: movs r1, 0 bl sub_8059CB4 ldr r0, =gText_WhatWillWallyDo - bl StrCpyDecodeToDisplayedStringBattle + bl BattleStringExpandPlaceholdersToDisplayedString ldr r0, =gDisplayedStringBattle movs r1, 0x1 bl sub_814F9EC diff --git a/asm/battle_frontier_1.s b/asm/battle_frontier_1.s index 8d39505ed..1a0b5ae3d 100755 --- a/asm/battle_frontier_1.s +++ b/asm/battle_frontier_1.s @@ -3165,9 +3165,9 @@ _0819044E: strh r4, [r0] ldr r0, =gUnknown_02022E16 strh r4, [r0] - ldr r0, =gUnknown_02022E18 + ldr r0, =gBattle_BG1_X strh r4, [r0] - ldr r0, =gUnknown_02022E1A + ldr r0, =gBattle_BG1_Y strh r4, [r0] ldr r0, =gUnknown_02022E20 strh r4, [r0] @@ -3176,16 +3176,16 @@ _0819044E: mov r2, r9 cmp r2, 0x2 bne _081904DC - ldr r0, =gUnknown_02022E1C + ldr r0, =gBattle_BG2_X strh r4, [r0] - ldr r0, =gUnknown_02022E1E + ldr r0, =gBattle_BG2_Y strh r4, [r0] b _081904E6 .pool _081904DC: - ldr r0, =gUnknown_02022E1C + ldr r0, =gBattle_BG2_X strh r4, [r0] - ldr r1, =gUnknown_02022E1E + ldr r1, =gBattle_BG2_Y movs r0, 0xA0 strh r0, [r1] _081904E6: @@ -4371,9 +4371,9 @@ _08190E98: strh r1, [r0] ldr r0, =gUnknown_02022E16 strh r1, [r0] - ldr r0, =gUnknown_02022E18 + ldr r0, =gBattle_BG1_X strh r1, [r0] - ldr r1, =gUnknown_02022E1A + ldr r1, =gBattle_BG1_Y movs r0, 0xA0 strh r0, [r1] b _08190EE6 @@ -4384,9 +4384,9 @@ _08190ED4: ldr r1, =gUnknown_02022E16 movs r0, 0xA0 strh r0, [r1] - ldr r0, =gUnknown_02022E18 + ldr r0, =gBattle_BG1_X strh r2, [r0] - ldr r0, =gUnknown_02022E1A + ldr r0, =gBattle_BG1_Y strh r2, [r0] _08190EE6: cmp r6, 0x1 @@ -4396,9 +4396,9 @@ _08190EE6: ldrb r1, [r0, 0x10] cmp r1, 0 bne _08190F50 - ldr r0, =gUnknown_02022E1C + ldr r0, =gBattle_BG2_X strh r1, [r0] - ldr r1, =gUnknown_02022E1E + ldr r1, =gBattle_BG2_Y movs r6, 0xA0 lsls r6, 1 adds r0, r6, 0 @@ -4424,12 +4424,12 @@ _08190EE6: b _08191084 .pool _08190F50: - ldr r1, =gUnknown_02022E1C + ldr r1, =gBattle_BG2_X movs r6, 0x80 lsls r6, 1 adds r0, r6, 0 strh r0, [r1] - ldr r0, =gUnknown_02022E1E + ldr r0, =gBattle_BG2_Y movs r4, 0 strh r4, [r0] ldr r3, =gUnknown_0860D080 @@ -4473,9 +4473,9 @@ _08190F9C: lsrs r0, 24 adds r1, 0x11 bl sub_8192F08 - ldr r0, =gUnknown_02022E1C + ldr r0, =gBattle_BG2_X strh r5, [r0] - ldr r1, =gUnknown_02022E1E + ldr r1, =gBattle_BG2_Y movs r3, 0xA0 lsls r3, 1 adds r0, r3, 0 @@ -4508,10 +4508,10 @@ _08190FF8: lsrs r0, 24 adds r1, 0x11 bl sub_8192F08 - ldr r1, =gUnknown_02022E1C + ldr r1, =gBattle_BG2_X movs r0, 0 strh r0, [r1] - ldr r1, =gUnknown_02022E1E + ldr r1, =gBattle_BG2_Y movs r2, 0xA0 lsls r2, 1 adds r0, r2, 0 @@ -4529,12 +4529,12 @@ _08190FF8: b _08191084 .pool _0819104C: - ldr r1, =gUnknown_02022E1C + ldr r1, =gBattle_BG2_X movs r3, 0x80 lsls r3, 1 adds r0, r3, 0 strh r0, [r1] - ldr r1, =gUnknown_02022E1E + ldr r1, =gBattle_BG2_Y movs r0, 0xA0 strh r0, [r1] ldr r1, =gTasks @@ -4770,9 +4770,9 @@ _08191234: strh r1, [r0] ldr r0, =gUnknown_02022E16 strh r1, [r0] - ldr r0, =gUnknown_02022E18 + ldr r0, =gBattle_BG1_X strh r1, [r0] - ldr r1, =gUnknown_02022E1A + ldr r1, =gBattle_BG1_Y ldr r2, =0x0000ff60 adds r0, r2, 0 strh r0, [r1] @@ -4785,9 +4785,9 @@ _08191278: ldr r3, =0x0000ff60 adds r0, r3, 0 strh r0, [r1] - ldr r0, =gUnknown_02022E18 + ldr r0, =gBattle_BG1_X strh r2, [r0] - ldr r0, =gUnknown_02022E1A + ldr r0, =gBattle_BG1_Y strh r2, [r0] _0819128C: cmp r6, 0x2 @@ -4797,9 +4797,9 @@ _0819128C: ldrb r1, [r0, 0x10] cmp r1, 0 bne _081912F4 - ldr r0, =gUnknown_02022E1C + ldr r0, =gBattle_BG2_X strh r1, [r0] - ldr r1, =gUnknown_02022E1E + ldr r1, =gBattle_BG2_Y movs r0, 0xA0 strh r0, [r1] ldr r3, =gUnknown_0860D080 @@ -4823,10 +4823,10 @@ _0819128C: b _0819141C .pool _081912F4: - ldr r0, =gUnknown_02022E1C + ldr r0, =gBattle_BG2_X movs r4, 0 strh r4, [r0] - ldr r0, =gUnknown_02022E1E + ldr r0, =gBattle_BG2_Y strh r4, [r0] ldr r3, =gUnknown_0860D080 ldr r2, =gTasks @@ -4869,9 +4869,9 @@ _0819133C: lsrs r0, 24 adds r1, 0x11 bl sub_8192F08 - ldr r0, =gUnknown_02022E1C + ldr r0, =gBattle_BG2_X strh r5, [r0] - ldr r1, =gUnknown_02022E1E + ldr r1, =gBattle_BG2_Y movs r0, 0xA0 strh r0, [r1] ldr r2, [r6] @@ -4902,10 +4902,10 @@ _08191394: lsrs r0, 24 adds r1, 0x11 bl sub_8192F08 - ldr r1, =gUnknown_02022E1C + ldr r1, =gBattle_BG2_X movs r0, 0 strh r0, [r1] - ldr r1, =gUnknown_02022E1E + ldr r1, =gBattle_BG2_Y movs r0, 0xA0 strh r0, [r1] ldr r2, [r6] @@ -4921,12 +4921,12 @@ _08191394: b _0819141C .pool _081913E4: - ldr r1, =gUnknown_02022E1C + ldr r1, =gBattle_BG2_X movs r4, 0x80 lsls r4, 1 adds r0, r4, 0 strh r0, [r1] - ldr r1, =gUnknown_02022E1E + ldr r1, =gBattle_BG2_Y movs r0, 0 strh r0, [r1] ldr r1, =gTasks @@ -5162,12 +5162,12 @@ _081915CC: strh r1, [r0] ldr r0, =gUnknown_02022E16 strh r1, [r0] - ldr r2, =gUnknown_02022E18 + ldr r2, =gBattle_BG1_X movs r6, 0x80 lsls r6, 1 adds r0, r6, 0 strh r0, [r2] - ldr r0, =gUnknown_02022E1A + ldr r0, =gBattle_BG1_Y strh r1, [r0] b _08191622 .pool @@ -5179,9 +5179,9 @@ _0819160C: strh r0, [r1] ldr r0, =gUnknown_02022E16 strh r2, [r0] - ldr r0, =gUnknown_02022E18 + ldr r0, =gBattle_BG1_X strh r2, [r0] - ldr r0, =gUnknown_02022E1A + ldr r0, =gBattle_BG1_Y strh r2, [r0] _08191622: ldr r0, =gUnknown_0203CD78 @@ -5189,12 +5189,12 @@ _08191622: ldrb r0, [r4, 0x10] cmp r0, 0 bne _08191688 - ldr r1, =gUnknown_02022E1C + ldr r1, =gBattle_BG2_X movs r4, 0x80 lsls r4, 1 adds r0, r4, 0 strh r0, [r1] - ldr r1, =gUnknown_02022E1E + ldr r1, =gBattle_BG2_Y movs r0, 0xA0 strh r0, [r1] ldr r3, =gUnknown_0860D080 @@ -5218,12 +5218,12 @@ _08191622: b _081916C6 .pool _08191688: - ldr r1, =gUnknown_02022E1C + ldr r1, =gBattle_BG2_X movs r6, 0x80 lsls r6, 1 adds r0, r6, 0 strh r0, [r1] - ldr r1, =gUnknown_02022E1E + ldr r1, =gBattle_BG2_Y movs r0, 0 strh r0, [r1] ldr r3, =gUnknown_0860D15C @@ -5462,12 +5462,12 @@ _0819187C: strh r1, [r0] ldr r0, =gUnknown_02022E16 strh r1, [r0] - ldr r2, =gUnknown_02022E18 + ldr r2, =gBattle_BG1_X movs r6, 0x80 lsls r6, 1 adds r0, r6, 0 strh r0, [r2] - ldr r0, =gUnknown_02022E1A + ldr r0, =gBattle_BG1_Y strh r1, [r0] b _081918D2 .pool @@ -5479,9 +5479,9 @@ _081918BC: strh r0, [r1] ldr r0, =gUnknown_02022E16 strh r2, [r0] - ldr r0, =gUnknown_02022E18 + ldr r0, =gBattle_BG1_X strh r2, [r0] - ldr r0, =gUnknown_02022E1A + ldr r0, =gBattle_BG1_Y strh r2, [r0] _081918D2: ldr r0, =gUnknown_0203CD78 @@ -5489,12 +5489,12 @@ _081918D2: ldrb r0, [r2, 0x10] cmp r0, 0 bne _08191924 - ldr r1, =gUnknown_02022E1C + ldr r1, =gBattle_BG2_X movs r4, 0x80 lsls r4, 1 adds r0, r4, 0 strh r0, [r1] - ldr r1, =gUnknown_02022E1E + ldr r1, =gBattle_BG2_Y movs r0, 0xA0 strh r0, [r1] ldr r1, =gTasks @@ -5510,10 +5510,10 @@ _081918D2: b _08191958 .pool _08191924: - ldr r1, =gUnknown_02022E1C + ldr r1, =gBattle_BG2_X movs r0, 0 strh r0, [r1] - ldr r1, =gUnknown_02022E1E + ldr r1, =gBattle_BG2_Y movs r0, 0xA0 strh r0, [r1] ldr r1, =gTasks @@ -5749,12 +5749,12 @@ _08191B08: strh r1, [r0] ldr r0, =gUnknown_02022E16 strh r1, [r0] - ldr r2, =gUnknown_02022E18 + ldr r2, =gBattle_BG1_X movs r6, 0xFF lsls r6, 8 adds r0, r6, 0 strh r0, [r2] - ldr r0, =gUnknown_02022E1A + ldr r0, =gBattle_BG1_Y strh r1, [r0] b _08191B5E .pool @@ -5766,9 +5766,9 @@ _08191B48: strh r0, [r1] ldr r0, =gUnknown_02022E16 strh r2, [r0] - ldr r0, =gUnknown_02022E18 + ldr r0, =gBattle_BG1_X strh r2, [r0] - ldr r0, =gUnknown_02022E1A + ldr r0, =gBattle_BG1_Y strh r2, [r0] _08191B5E: ldr r0, =gUnknown_0203CD78 @@ -5776,19 +5776,19 @@ _08191B5E: ldrb r0, [r0, 0x10] cmp r0, 0x1 bne _08191B94 - ldr r1, =gUnknown_02022E1C + ldr r1, =gBattle_BG2_X movs r0, 0 strh r0, [r1] - ldr r1, =gUnknown_02022E1E + ldr r1, =gBattle_BG2_Y movs r0, 0xA0 strh r0, [r1] b _08191B9E .pool _08191B94: - ldr r0, =gUnknown_02022E1C + ldr r0, =gBattle_BG2_X movs r1, 0 strh r1, [r0] - ldr r0, =gUnknown_02022E1E + ldr r0, =gBattle_BG2_Y strh r1, [r0] _08191B9E: ldr r4, =gUnknown_0860D15C @@ -6016,12 +6016,12 @@ _08191D68: strh r1, [r0] ldr r0, =gUnknown_02022E16 strh r1, [r0] - ldr r2, =gUnknown_02022E18 + ldr r2, =gBattle_BG1_X movs r6, 0xFF lsls r6, 8 adds r0, r6, 0 strh r0, [r2] - ldr r0, =gUnknown_02022E1A + ldr r0, =gBattle_BG1_Y strh r1, [r0] b _08191DBE .pool @@ -6033,9 +6033,9 @@ _08191DA8: strh r0, [r1] ldr r0, =gUnknown_02022E16 strh r2, [r0] - ldr r0, =gUnknown_02022E18 + ldr r0, =gBattle_BG1_X strh r2, [r0] - ldr r0, =gUnknown_02022E1A + ldr r0, =gBattle_BG1_Y strh r2, [r0] _08191DBE: ldr r0, =gUnknown_0203CD78 @@ -6043,12 +6043,12 @@ _08191DBE: ldrb r0, [r2, 0x10] cmp r0, 0x2 bne _08191E10 - ldr r1, =gUnknown_02022E1C + ldr r1, =gBattle_BG2_X movs r4, 0x80 lsls r4, 1 adds r0, r4, 0 strh r0, [r1] - ldr r1, =gUnknown_02022E1E + ldr r1, =gBattle_BG2_Y movs r0, 0xA0 strh r0, [r1] ldr r1, =gTasks @@ -6064,10 +6064,10 @@ _08191DBE: b _08191E44 .pool _08191E10: - ldr r1, =gUnknown_02022E1C + ldr r1, =gBattle_BG2_X movs r0, 0 strh r0, [r1] - ldr r1, =gUnknown_02022E1E + ldr r1, =gBattle_BG2_Y movs r0, 0xA0 strh r0, [r1] ldr r1, =gTasks @@ -6310,11 +6310,11 @@ _08191FF8: ldrh r0, [r1] subs r0, 0x4 strh r0, [r1] - ldr r1, =gUnknown_02022E1A + ldr r1, =gBattle_BG1_Y ldrh r0, [r1] subs r0, 0x4 strh r0, [r1] - ldr r1, =gUnknown_02022E1E + ldr r1, =gBattle_BG2_Y b _081920A4 .pool _08192038: @@ -6335,11 +6335,11 @@ _08192038: ldrh r0, [r1] adds r0, 0x4 strh r0, [r1] - ldr r1, =gUnknown_02022E1A + ldr r1, =gBattle_BG1_Y ldrh r0, [r1] adds r0, 0x4 strh r0, [r1] - ldr r1, =gUnknown_02022E1E + ldr r1, =gBattle_BG2_Y b _081920E8 .pool _08192078: @@ -6360,11 +6360,11 @@ _08192078: ldrh r0, [r1] subs r0, 0x4 strh r0, [r1] - ldr r1, =gUnknown_02022E18 + ldr r1, =gBattle_BG1_X ldrh r0, [r1] subs r0, 0x4 strh r0, [r1] - ldr r1, =gUnknown_02022E1C + ldr r1, =gBattle_BG2_X _081920A4: ldrh r0, [r1] subs r0, 0x4 @@ -6389,11 +6389,11 @@ _081920BC: ldrh r0, [r1] adds r0, 0x4 strh r0, [r1] - ldr r1, =gUnknown_02022E18 + ldr r1, =gBattle_BG1_X ldrh r0, [r1] adds r0, 0x4 strh r0, [r1] - ldr r1, =gUnknown_02022E1C + ldr r1, =gBattle_BG2_X _081920E8: ldrh r0, [r1] adds r0, 0x4 @@ -10404,9 +10404,9 @@ _0819427C: strh r4, [r0] ldr r0, =gUnknown_02022E16 strh r4, [r0] - ldr r0, =gUnknown_02022E18 + ldr r0, =gBattle_BG1_X strh r4, [r0] - ldr r0, =gUnknown_02022E1A + ldr r0, =gBattle_BG1_Y strh r4, [r0] movs r0, 0x2 movs r1, 0 @@ -11366,19 +11366,19 @@ sub_8194B70: @ 8194B70 ldrh r1, [r0] movs r0, 0x12 bl SetGpuReg - ldr r0, =gUnknown_02022E18 + ldr r0, =gBattle_BG1_X ldrh r1, [r0] movs r0, 0x14 bl SetGpuReg - ldr r0, =gUnknown_02022E1A + ldr r0, =gBattle_BG1_Y ldrh r1, [r0] movs r0, 0x16 bl SetGpuReg - ldr r0, =gUnknown_02022E1C + ldr r0, =gBattle_BG2_X ldrh r1, [r0] movs r0, 0x18 bl SetGpuReg - ldr r0, =gUnknown_02022E1E + ldr r0, =gBattle_BG2_Y ldrh r1, [r0] movs r0, 0x1A bl SetGpuReg @@ -11494,11 +11494,11 @@ sub_8194CE4: @ 8194CE4 ldrh r1, [r0] movs r0, 0x12 bl SetGpuReg - ldr r0, =gUnknown_02022E18 + ldr r0, =gBattle_BG1_X ldrh r1, [r0] movs r0, 0x14 bl SetGpuReg - ldr r0, =gUnknown_02022E1A + ldr r0, =gBattle_BG1_Y ldrh r1, [r0] movs r0, 0x16 bl SetGpuReg diff --git a/asm/battle_frontier_2.s b/asm/battle_frontier_2.s index bea4972e3..2e48fdd72 100755 --- a/asm/battle_frontier_2.s +++ b/asm/battle_frontier_2.s @@ -20578,7 +20578,7 @@ _081A5328: negs r0, r0 strb r0, [r1, 0x1] ldr r0, =gText_JapaneseHonorific - bl StrCpyDecodeToDisplayedStringBattle + bl BattleStringExpandPlaceholdersToDisplayedString ldr r4, =gDisplayedStringBattle adds r0, r4, 0 movs r1, 0xF @@ -20587,7 +20587,7 @@ _081A5328: movs r1, 0x10 bl sub_814F9EC ldr r0, =gText_RivalBuffer - bl StrCpyDecodeToDisplayedStringBattle + bl BattleStringExpandPlaceholdersToDisplayedString adds r0, r4, 0 movs r1, 0x11 bl sub_814F9EC @@ -20601,7 +20601,7 @@ _081A5328: movs r1, 0x14 bl sub_814F9EC ldr r0, =gText_Judgement - bl StrCpyDecodeToDisplayedStringBattle + bl BattleStringExpandPlaceholdersToDisplayedString adds r0, r4, 0 movs r1, 0x15 bl sub_814F9EC @@ -20685,7 +20685,7 @@ _081A5464: movs r3, 0x1 bl sub_81A5558 ldr r0, =gText_Judgement - bl StrCpyDecodeToDisplayedStringBattle + bl BattleStringExpandPlaceholdersToDisplayedString ldr r0, =gDisplayedStringBattle movs r1, 0x15 bl sub_814F9EC diff --git a/asm/battle_message.s b/asm/battle_message.s index f1f2447aa..96869a350 100644 --- a/asm/battle_message.s +++ b/asm/battle_message.s @@ -687,7 +687,7 @@ _0814E6CC: ldr r7, [r0] _0814E6D8: adds r0, r7, 0 - bl StrCpyDecodeToDisplayedStringBattle + bl BattleStringExpandPlaceholdersToDisplayedString _0814E6DE: pop {r3-r5} mov r8, r3 @@ -699,15 +699,15 @@ _0814E6DE: .pool thumb_func_end BufferStringBattle - thumb_func_start StrCpyDecodeToDisplayedStringBattle -StrCpyDecodeToDisplayedStringBattle: @ 814E6F0 + thumb_func_start BattleStringExpandPlaceholdersToDisplayedString +BattleStringExpandPlaceholdersToDisplayedString: @ 814E6F0 push {lr} ldr r1, =gDisplayedStringBattle bl BattleStringExpandPlaceholders pop {r1} bx r1 .pool - thumb_func_end StrCpyDecodeToDisplayedStringBattle + thumb_func_end BattleStringExpandPlaceholdersToDisplayedString thumb_func_start AppendStatusString AppendStatusString: @ 814E700 @@ -924,7 +924,7 @@ _0814E920: .pool _0814E92C: movs r0, 0 - bl GetBankByPlayerAI + bl GetBankByIdentity ldr r1, =gBattlePartyID lsls r0, 24 lsrs r0, 23 @@ -943,7 +943,7 @@ _0814E92C: .pool _0814E960: movs r0, 0x1 - bl GetBankByPlayerAI + bl GetBankByIdentity ldr r1, =gBattlePartyID lsls r0, 24 lsrs r0, 23 @@ -962,7 +962,7 @@ _0814E960: .pool _0814E994: movs r0, 0x2 - bl GetBankByPlayerAI + bl GetBankByIdentity ldr r1, =gBattlePartyID lsls r0, 24 lsrs r0, 23 @@ -981,7 +981,7 @@ _0814E994: .pool _0814E9C8: movs r0, 0x3 - bl GetBankByPlayerAI + bl GetBankByIdentity ldr r1, =gBattlePartyID lsls r0, 24 lsrs r0, 23 @@ -1126,7 +1126,7 @@ _0814EB36: adds r1, r0, 0 movs r0, 0x1 ands r0, r1 - bl GetBankByPlayerAI + bl GetBankByIdentity ldr r1, =gBattlePartyID lsls r0, 24 lsrs r0, 23 @@ -1147,7 +1147,7 @@ _0814EB74: adds r1, r0, 0 movs r0, 0x1 ands r0, r1 - bl GetBankByPlayerAI + bl GetBankByIdentity ldr r1, =gBattlePartyID lsls r0, 24 lsrs r0, 23 @@ -1177,7 +1177,7 @@ _0814EBB0: adds r1, r0, 0 movs r0, 0x1 ands r0, r1 - bl GetBankByPlayerAI + bl GetBankByIdentity ldr r1, =gBattlePartyID lsls r0, 24 lsrs r0, 23 @@ -1199,7 +1199,7 @@ _0814EBF8: adds r1, r0, 0 movs r0, 0x1 ands r0, r1 - bl GetBankByPlayerAI + bl GetBankByIdentity ldr r1, =gBattlePartyID lsls r0, 24 lsrs r0, 23 diff --git a/asm/contest.s b/asm/contest.s index 71e8ab058..7e0652222 100644 --- a/asm/contest.s +++ b/asm/contest.s @@ -50,13 +50,13 @@ sub_80D7678: @ 80D7678 strh r1, [r0] ldr r0, =gUnknown_02022E16 strh r1, [r0] - ldr r0, =gUnknown_02022E18 + ldr r0, =gBattle_BG1_X strh r1, [r0] - ldr r0, =gUnknown_02022E1A + ldr r0, =gBattle_BG1_Y strh r1, [r0] - ldr r0, =gUnknown_02022E1C + ldr r0, =gBattle_BG2_X strh r1, [r0] - ldr r0, =gUnknown_02022E1E + ldr r0, =gBattle_BG2_Y strh r1, [r0] ldr r0, =gUnknown_02022E20 strh r1, [r0] @@ -611,10 +611,10 @@ _080D7BF6: .pool _080D7C04: bl sub_80DE224 - ldr r0, =gUnknown_02022E18 + ldr r0, =gBattle_BG1_X movs r1, 0 strh r1, [r0] - ldr r0, =gUnknown_02022E1A + ldr r0, =gBattle_BG1_Y strh r1, [r0] movs r0, 0x2 bl BeginFastPaletteFade @@ -1190,7 +1190,7 @@ _080D814C: strh r0, [r4, 0x8] b _080D822C _080D8176: - ldr r1, =gUnknown_02022E1A + ldr r1, =gBattle_BG1_Y ldrh r0, [r1] adds r0, 0x7 strh r0, [r1] @@ -1324,19 +1324,19 @@ vblank_cb_battle: @ 80D827C ldrh r1, [r0] movs r0, 0x12 bl SetGpuReg - ldr r0, =gUnknown_02022E18 + ldr r0, =gBattle_BG1_X ldrh r1, [r0] movs r0, 0x14 bl SetGpuReg - ldr r0, =gUnknown_02022E1A + ldr r0, =gBattle_BG1_Y ldrh r1, [r0] movs r0, 0x16 bl SetGpuReg - ldr r0, =gUnknown_02022E1C + ldr r0, =gBattle_BG2_X ldrh r1, [r0] movs r0, 0x18 bl SetGpuReg - ldr r0, =gUnknown_02022E1E + ldr r0, =gBattle_BG2_Y ldrh r1, [r0] movs r0, 0x1A bl SetGpuReg @@ -1389,7 +1389,7 @@ sub_80D833C: @ 80D833C bne _080D840C ldr r0, =gUnknown_02022E16 strh r1, [r0] - ldr r0, =gUnknown_02022E1E + ldr r0, =gBattle_BG2_Y strh r1, [r0] bl sub_80DCD48 ldr r1, =gPlttBufferUnfaded @@ -1520,7 +1520,7 @@ sub_80D8490: @ 80D8490 ldr r0, =gUnknown_02022E16 movs r1, 0xA0 strh r1, [r0] - ldr r0, =gUnknown_02022E1E + ldr r0, =gBattle_BG2_Y strh r1, [r0] movs r6, 0 ldr r0, =gUnknown_02039F25 @@ -1773,7 +1773,7 @@ _080D86E4: ldr r0, =gUnknown_02022E16 movs r1, 0 strh r1, [r0] - ldr r0, =gUnknown_02022E1E + ldr r0, =gBattle_BG2_Y strh r1, [r0] ldr r1, =gTasks lsls r0, r7, 2 @@ -2044,7 +2044,7 @@ sub_80D895C: @ 80D895C ldr r0, =gUnknown_02022E16 movs r1, 0 strh r1, [r0] - ldr r0, =gUnknown_02022E1E + ldr r0, =gBattle_BG2_Y strh r1, [r0] movs r0, 0 bl sub_80DC490 @@ -5325,7 +5325,7 @@ sub_80DA5E8: @ 80DA5E8 ldr r0, =gUnknown_02022E16 movs r1, 0 strh r1, [r0] - ldr r0, =gUnknown_02022E1E + ldr r0, =gBattle_BG2_Y strh r1, [r0] ldr r4, =gUnknown_02039F34 movs r3, 0 @@ -5404,9 +5404,9 @@ sub_80DA6B4: @ 80DA6B4 cmp r4, 0 bne _080DA6EA bl sub_80DE224 - ldr r0, =gUnknown_02022E18 + ldr r0, =gBattle_BG1_X strh r4, [r0] - ldr r1, =gUnknown_02022E1A + ldr r1, =gBattle_BG1_Y movs r0, 0xA0 strh r0, [r1] movs r0, 0x62 @@ -5432,7 +5432,7 @@ sub_80DA700: @ 80DA700 push {lr} lsls r0, 24 lsrs r3, r0, 24 - ldr r1, =gUnknown_02022E1A + ldr r1, =gBattle_BG1_Y ldrh r0, [r1] subs r0, 0x7 strh r0, [r1] @@ -8519,7 +8519,7 @@ sub_80DBF68: @ 80DBF68 ldr r0, =gUnknown_02022E16 movs r1, 0 strh r1, [r0] - ldr r0, =gUnknown_02022E1E + ldr r0, =gBattle_BG2_Y strh r1, [r0] bl sub_80DB89C ldr r0, =gUnknown_0827E8DA @@ -12881,10 +12881,10 @@ sub_80DE224: @ 80DE224 ldrh r1, [r5] movs r0, 0xC bl SetGpuReg - ldr r1, =gUnknown_02022E18 + ldr r1, =gBattle_BG1_X movs r0, 0xF0 strh r0, [r1] - ldr r4, =gUnknown_02022E1A + ldr r4, =gBattle_BG1_Y movs r0, 0xA0 strh r0, [r4] movs r0, 0x14 @@ -13004,9 +13004,9 @@ sub_80DE350: @ 80DE350 ldrh r1, [r3] movs r0, 0xA bl SetGpuReg - ldr r0, =gUnknown_02022E18 + ldr r0, =gBattle_BG1_X strh r5, [r0] - ldr r0, =gUnknown_02022E1A + ldr r0, =gBattle_BG1_Y strh r5, [r0] ldr r7, =gSprites _080DE3CA: @@ -13051,10 +13051,10 @@ sub_80DE424: @ 80DE424 adds r4, r0, 0 lsls r4, 24 lsrs r4, 24 - ldr r1, =gUnknown_02022E18 + ldr r1, =gBattle_BG1_X movs r0, 0 strh r0, [r1] - ldr r1, =gUnknown_02022E1A + ldr r1, =gBattle_BG1_Y movs r0, 0xA0 strh r0, [r1] movs r0, 0x62 @@ -13078,7 +13078,7 @@ sub_80DE464: @ 80DE464 push {lr} lsls r0, 24 lsrs r3, r0, 24 - ldr r1, =gUnknown_02022E1A + ldr r1, =gBattle_BG1_Y ldrh r0, [r1] subs r0, 0x7 strh r0, [r1] @@ -13233,7 +13233,7 @@ sub_80DE5C0: @ 80DE5C0 push {lr} lsls r0, 24 lsrs r2, r0, 24 - ldr r1, =gUnknown_02022E1A + ldr r1, =gBattle_BG1_Y ldrh r0, [r1] adds r0, 0x7 strh r0, [r1] diff --git a/asm/contest_link_80F57C4.s b/asm/contest_link_80F57C4.s index 864f16c5e..8da1eccba 100644 --- a/asm/contest_link_80F57C4.s +++ b/asm/contest_link_80F57C4.s @@ -97,13 +97,13 @@ _080F57E0: strh r1, [r0] ldr r0, =gUnknown_02022E16 strh r1, [r0] - ldr r0, =gUnknown_02022E18 + ldr r0, =gBattle_BG1_X strh r1, [r0] - ldr r0, =gUnknown_02022E1A + ldr r0, =gBattle_BG1_Y strh r1, [r0] - ldr r0, =gUnknown_02022E1C + ldr r0, =gBattle_BG2_X strh r1, [r0] - ldr r0, =gUnknown_02022E1E + ldr r0, =gBattle_BG2_Y strh r1, [r0] ldr r0, =gUnknown_02022E20 strh r1, [r0] @@ -449,19 +449,19 @@ sub_80F5C24: @ 80F5C24 ldrh r1, [r0] movs r0, 0x12 bl SetGpuReg - ldr r0, =gUnknown_02022E18 + ldr r0, =gBattle_BG1_X ldrh r1, [r0] movs r0, 0x14 bl SetGpuReg - ldr r0, =gUnknown_02022E1A + ldr r0, =gBattle_BG1_Y ldrh r1, [r0] movs r0, 0x16 bl SetGpuReg - ldr r0, =gUnknown_02022E1C + ldr r0, =gBattle_BG2_X ldrh r1, [r0] movs r0, 0x18 bl SetGpuReg - ldr r0, =gUnknown_02022E1E + ldr r0, =gBattle_BG2_Y ldrh r1, [r0] movs r0, 0x1A bl SetGpuReg @@ -1989,7 +1989,7 @@ sub_80F69B8: @ 80F69B8 _080F69DE: adds r0, r7, 0 ldr r1, [sp, 0x28] - bl sub_80D2EDC + bl GetMonIconPtr adds r3, r0, 0 lsls r0, r5, 9 adds r0, 0x80 diff --git a/asm/evolution_scene.s b/asm/evolution_scene.s index afc3c843b..f96a7355a 100644 --- a/asm/evolution_scene.s +++ b/asm/evolution_scene.s @@ -170,13 +170,13 @@ evolution_cutscene: @ 813DA8C strh r2, [r0] ldr r0, =gUnknown_02022E16 strh r2, [r0] - ldr r0, =gUnknown_02022E18 + ldr r0, =gBattle_BG1_X strh r2, [r0] - ldr r0, =gUnknown_02022E1A + ldr r0, =gBattle_BG1_Y strh r2, [r0] - ldr r0, =gUnknown_02022E1C + ldr r0, =gBattle_BG2_X strh r2, [r0] - ldr r0, =gUnknown_02022E1E + ldr r0, =gBattle_BG2_Y strh r2, [r0] ldr r1, =gUnknown_02022E20 movs r2, 0x80 @@ -464,13 +464,13 @@ sub_813DD7C: @ 813DD7C strh r4, [r0] ldr r0, =gUnknown_02022E16 strh r4, [r0] - ldr r0, =gUnknown_02022E18 + ldr r0, =gBattle_BG1_X strh r4, [r0] - ldr r0, =gUnknown_02022E1A + ldr r0, =gBattle_BG1_Y strh r4, [r0] - ldr r0, =gUnknown_02022E1C + ldr r0, =gBattle_BG2_X strh r4, [r0] - ldr r0, =gUnknown_02022E1E + ldr r0, =gBattle_BG2_Y strh r4, [r0] ldr r1, =gUnknown_02022E20 movs r2, 0x80 @@ -634,13 +634,13 @@ _0813DFE0: strh r1, [r0] ldr r0, =gUnknown_02022E16 strh r1, [r0] - ldr r0, =gUnknown_02022E18 + ldr r0, =gBattle_BG1_X strh r1, [r0] - ldr r0, =gUnknown_02022E1A + ldr r0, =gBattle_BG1_Y strh r1, [r0] - ldr r0, =gUnknown_02022E1C + ldr r0, =gBattle_BG2_X strh r1, [r0] - ldr r0, =gUnknown_02022E1E + ldr r0, =gBattle_BG2_Y strh r1, [r0] ldr r2, =gUnknown_02022E20 movs r3, 0x80 @@ -945,13 +945,13 @@ sub_813E1D4: @ 813E1D4 strh r4, [r0] ldr r0, =gUnknown_02022E16 strh r4, [r0] - ldr r0, =gUnknown_02022E18 + ldr r0, =gBattle_BG1_X strh r4, [r0] - ldr r0, =gUnknown_02022E1A + ldr r0, =gBattle_BG1_Y strh r4, [r0] - ldr r0, =gUnknown_02022E1C + ldr r0, =gBattle_BG2_X strh r4, [r0] - ldr r0, =gUnknown_02022E1E + ldr r0, =gBattle_BG2_Y strh r4, [r0] ldr r1, =gUnknown_02022E20 movs r2, 0x80 @@ -1892,12 +1892,12 @@ _0813EC1E: beq _0813EC2A b _0813F1A4 _0813EC2A: - bl sub_804F574 + bl BufferMoveToLearnIntoBattleTextBuff2 ldr r0, =0x0000016f bl PlayFanfare ldr r0, =gBattleStringsTable ldr r0, [r0, 0xC] - bl StrCpyDecodeToDisplayedStringBattle + bl BattleStringExpandPlaceholdersToDisplayedString ldr r0, =gDisplayedStringBattle movs r1, 0 bl sub_814F9EC @@ -1991,10 +1991,10 @@ _0813ED0A: beq _0813ED16 b _0813F1A4 _0813ED16: - bl sub_804F574 + bl BufferMoveToLearnIntoBattleTextBuff2 ldr r0, =gBattleStringsTable ldr r0, [r0, 0x10] - bl StrCpyDecodeToDisplayedStringBattle + bl BattleStringExpandPlaceholdersToDisplayedString ldr r0, =gDisplayedStringBattle movs r1, 0 bl sub_814F9EC @@ -2023,7 +2023,7 @@ _0813ED56: _0813ED62: ldr r0, =gBattleStringsTable ldr r0, [r0, 0x14] - bl StrCpyDecodeToDisplayedStringBattle + bl BattleStringExpandPlaceholdersToDisplayedString ldr r0, =gDisplayedStringBattle movs r1, 0 bl sub_814F9EC @@ -2048,7 +2048,7 @@ _0813ED90: bne _0813EDCE ldr r0, =gBattleStringsTable ldr r0, [r0, 0x18] - bl StrCpyDecodeToDisplayedStringBattle + bl BattleStringExpandPlaceholdersToDisplayedString ldr r0, =gDisplayedStringBattle movs r1, 0 bl sub_814F9EC @@ -2289,7 +2289,7 @@ _0813EFC8: ldr r3, =0x000004cc adds r0, r3 ldr r0, [r0] - bl StrCpyDecodeToDisplayedStringBattle + bl BattleStringExpandPlaceholdersToDisplayedString ldr r0, =gDisplayedStringBattle movs r1, 0 bl sub_814F9EC @@ -2338,7 +2338,7 @@ _0813F05C: lsls r1, 2 adds r0, r1 ldr r0, [r0] - bl StrCpyDecodeToDisplayedStringBattle + bl BattleStringExpandPlaceholdersToDisplayedString ldr r0, =gDisplayedStringBattle movs r1, 0 bl sub_814F9EC @@ -2367,7 +2367,7 @@ _0813F09E: _0813F0AA: ldr r0, =gBattleStringsTable ldr r0, [r0, 0x1C] - bl StrCpyDecodeToDisplayedStringBattle + bl BattleStringExpandPlaceholdersToDisplayedString ldr r0, =gDisplayedStringBattle movs r1, 0 bl sub_814F9EC @@ -2395,7 +2395,7 @@ _0813F0D8: lsls r1, 2 adds r0, r1 ldr r0, [r0] - bl StrCpyDecodeToDisplayedStringBattle + bl BattleStringExpandPlaceholdersToDisplayedString ldr r0, =gDisplayedStringBattle movs r1, 0 bl sub_814F9EC @@ -2411,7 +2411,7 @@ _0813F0D8: _0813F120: ldr r0, =gBattleStringsTable ldr r0, [r0, 0x20] - bl StrCpyDecodeToDisplayedStringBattle + bl BattleStringExpandPlaceholdersToDisplayedString ldr r0, =gDisplayedStringBattle movs r1, 0 bl sub_814F9EC @@ -2431,7 +2431,7 @@ _0813F120: _0813F154: ldr r0, =gBattleStringsTable ldr r0, [r0, 0x24] - bl StrCpyDecodeToDisplayedStringBattle + bl BattleStringExpandPlaceholdersToDisplayedString ldr r0, =gDisplayedStringBattle movs r1, 0 bl sub_814F9EC @@ -3059,12 +3059,12 @@ _0813F756: beq _0813F762 b _0813FCC4 _0813F762: - bl sub_804F574 + bl BufferMoveToLearnIntoBattleTextBuff2 ldr r0, =0x0000016f bl PlayFanfare ldr r0, =gBattleStringsTable ldr r0, [r0, 0xC] - bl StrCpyDecodeToDisplayedStringBattle + bl BattleStringExpandPlaceholdersToDisplayedString ldr r1, =gDisplayedStringBattle movs r0, 0 movs r2, 0x1 @@ -3160,10 +3160,10 @@ _0813F846: beq _0813F852 b _0813FCC4 _0813F852: - bl sub_804F574 + bl BufferMoveToLearnIntoBattleTextBuff2 ldr r0, =gBattleStringsTable ldr r0, [r0, 0x10] - bl StrCpyDecodeToDisplayedStringBattle + bl BattleStringExpandPlaceholdersToDisplayedString ldr r1, =gDisplayedStringBattle movs r0, 0 movs r2, 0x1 @@ -3193,7 +3193,7 @@ _0813F892: _0813F89E: ldr r0, =gBattleStringsTable ldr r0, [r0, 0x14] - bl StrCpyDecodeToDisplayedStringBattle + bl BattleStringExpandPlaceholdersToDisplayedString ldr r1, =gDisplayedStringBattle movs r0, 0 movs r2, 0x1 @@ -3219,7 +3219,7 @@ _0813F8CC: bne _0813F90C ldr r0, =gBattleStringsTable ldr r0, [r0, 0x18] - bl StrCpyDecodeToDisplayedStringBattle + bl BattleStringExpandPlaceholdersToDisplayedString ldr r1, =gDisplayedStringBattle movs r0, 0 movs r2, 0x1 @@ -3299,7 +3299,7 @@ _0813F98C: lsls r1, 3 adds r0, r1 ldr r0, [r0] - bl StrCpyDecodeToDisplayedStringBattle + bl BattleStringExpandPlaceholdersToDisplayedString ldr r1, =gDisplayedStringBattle movs r0, 0 movs r2, 0x1 @@ -3336,7 +3336,7 @@ _0813F9E4: lsls r1, 3 adds r0, r1 ldr r0, [r0] - bl StrCpyDecodeToDisplayedStringBattle + bl BattleStringExpandPlaceholdersToDisplayedString ldr r1, =gDisplayedStringBattle movs r0, 0 movs r2, 0x1 @@ -3441,7 +3441,7 @@ _0813FAEC: ldr r1, =0x000004cc adds r0, r1 ldr r0, [r0] - bl StrCpyDecodeToDisplayedStringBattle + bl BattleStringExpandPlaceholdersToDisplayedString ldr r1, =gDisplayedStringBattle movs r0, 0 movs r2, 0x1 @@ -3481,7 +3481,7 @@ _0813FB3C: lsls r1, 2 adds r0, r1 ldr r0, [r0] - bl StrCpyDecodeToDisplayedStringBattle + bl BattleStringExpandPlaceholdersToDisplayedString ldr r1, =gDisplayedStringBattle movs r0, 0 movs r2, 0x1 @@ -3511,7 +3511,7 @@ _0813FBB2: _0813FBBE: ldr r0, =gBattleStringsTable ldr r0, [r0, 0x1C] - bl StrCpyDecodeToDisplayedStringBattle + bl BattleStringExpandPlaceholdersToDisplayedString ldr r1, =gDisplayedStringBattle movs r0, 0 movs r2, 0x1 @@ -3540,7 +3540,7 @@ _0813FBEC: lsls r1, 2 adds r0, r1 ldr r0, [r0] - bl StrCpyDecodeToDisplayedStringBattle + bl BattleStringExpandPlaceholdersToDisplayedString ldr r1, =gDisplayedStringBattle movs r0, 0 movs r2, 0x1 @@ -3557,7 +3557,7 @@ _0813FBEC: _0813FC38: ldr r0, =gBattleStringsTable ldr r0, [r0, 0x20] - bl StrCpyDecodeToDisplayedStringBattle + bl BattleStringExpandPlaceholdersToDisplayedString ldr r1, =gDisplayedStringBattle movs r0, 0 movs r2, 0x1 @@ -3578,7 +3578,7 @@ _0813FC38: _0813FC70: ldr r0, =gBattleStringsTable ldr r0, [r0, 0x24] - bl StrCpyDecodeToDisplayedStringBattle + bl BattleStringExpandPlaceholdersToDisplayedString ldr r1, =gDisplayedStringBattle movs r0, 0 movs r2, 0x1 @@ -3638,19 +3638,19 @@ sub_813FCDC: @ 813FCDC ldrh r1, [r0] movs r0, 0x12 bl SetGpuReg - ldr r0, =gUnknown_02022E18 + ldr r0, =gBattle_BG1_X ldrh r1, [r0] movs r0, 0x14 bl SetGpuReg - ldr r0, =gUnknown_02022E1A + ldr r0, =gBattle_BG1_Y ldrh r1, [r0] movs r0, 0x16 bl SetGpuReg - ldr r0, =gUnknown_02022E1C + ldr r0, =gBattle_BG2_X ldrh r1, [r0] movs r0, 0x18 bl SetGpuReg - ldr r0, =gUnknown_02022E1E + ldr r0, =gBattle_BG2_Y ldrh r1, [r0] movs r0, 0x1A bl SetGpuReg @@ -3682,19 +3682,19 @@ sub_813FD64: @ 813FD64 ldrh r1, [r0] movs r0, 0x12 bl SetGpuReg - ldr r0, =gUnknown_02022E18 + ldr r0, =gBattle_BG1_X ldrh r1, [r0] movs r0, 0x14 bl SetGpuReg - ldr r0, =gUnknown_02022E1A + ldr r0, =gBattle_BG1_Y ldrh r1, [r0] movs r0, 0x16 bl SetGpuReg - ldr r0, =gUnknown_02022E1C + ldr r0, =gBattle_BG2_X ldrh r1, [r0] movs r0, 0x18 bl SetGpuReg - ldr r0, =gUnknown_02022E1E + ldr r0, =gBattle_BG2_Y ldrh r1, [r0] movs r0, 0x1A bl SetGpuReg @@ -3852,9 +3852,9 @@ sub_813FEE8: @ 813FEE8 push {r6,r7} lsls r0, 24 lsrs r5, r0, 24 - ldr r0, =gUnknown_02022E18 + ldr r0, =gBattle_BG1_X mov r8, r0 - ldr r1, =gUnknown_02022E1A + ldr r1, =gBattle_BG1_Y mov r9, r1 ldr r1, =gTasks lsls r0, r5, 2 @@ -3865,8 +3865,8 @@ sub_813FEE8: @ 813FEE8 ldrsh r0, [r0, r2] cmp r0, 0 bne _0813FF28 - ldr r7, =gUnknown_02022E1C - ldr r6, =gUnknown_02022E1E + ldr r7, =gBattle_BG2_X + ldr r6, =gBattle_BG2_Y b _0813FF2C .pool _0813FF28: @@ -4130,12 +4130,12 @@ sub_8140174: @ 8140174 movs r0, 0x50 movs r1, 0 bl SetGpuReg - ldr r0, =gUnknown_02022E18 + ldr r0, =gBattle_BG1_X movs r1, 0 strh r1, [r0] - ldr r0, =gUnknown_02022E1A + ldr r0, =gBattle_BG1_Y strh r1, [r0] - ldr r0, =gUnknown_02022E1C + ldr r0, =gBattle_BG2_X strh r1, [r0] movs r0, 0x1 movs r1, 0x5 diff --git a/asm/menu.s b/asm/menu.s index 8bb9dc436..71ff9218c 100755 --- a/asm/menu.s +++ b/asm/menu.s @@ -5201,7 +5201,7 @@ sub_819A25C: @ 819A25C lsrs r4, 24 lsls r0, 16 lsrs r0, 16 - bl sub_80D30B0 + bl GetValidMonIconPalettePtr adds r1, r4, 0 movs r2, 0x20 bl LoadPalette @@ -5228,7 +5228,7 @@ sub_819A27C: @ 819A27C lsls r5, 16 lsrs r5, 16 movs r2, 0x1 - bl sub_80D2EDC + bl GetMonIconPtr adds r1, r0, 0 movs r0, 0x20 str r0, [sp] diff --git a/asm/party_menu.s b/asm/party_menu.s index 1e47701ae..2b320f86e 100755 --- a/asm/party_menu.s +++ b/asm/party_menu.s @@ -16228,7 +16228,7 @@ _081B8CBE: bne _081B8CFC movs r5, 0x1 movs r0, 0 - bl GetBankByPlayerAI + bl GetBankByIdentity mov r2, sp ldr r1, =gBattlePartyID lsls r0, 24 @@ -16255,7 +16255,7 @@ _081B8CF0: _081B8CFC: movs r5, 0x2 movs r0, 0 - bl GetBankByPlayerAI + bl GetBankByIdentity mov r1, sp ldr r4, =gBattlePartyID lsls r0, 24 @@ -16264,7 +16264,7 @@ _081B8CFC: ldrh r0, [r0] strb r0, [r1] movs r0, 0x2 - bl GetBankByPlayerAI + bl GetBankByIdentity mov r1, sp lsls r0, 24 lsrs r0, 23 @@ -16344,19 +16344,19 @@ sub_81B8D88: @ 81B8D88 cmp r0, 0 bne _081B8DB0 movs r0, 0 - bl GetBankByPlayerAI + bl GetBankByIdentity lsls r0, 24 lsrs r4, r0, 24 movs r0, 0x2 b _081B8DBC _081B8DB0: movs r0, 0x1 - bl GetBankByPlayerAI + bl GetBankByIdentity lsls r0, 24 lsrs r4, r0, 24 movs r0, 0x3 _081B8DBC: - bl GetBankByPlayerAI + bl GetBankByIdentity lsls r0, 24 lsrs r6, r0, 24 bl sub_81B1250 diff --git a/asm/pokeball.s b/asm/pokeball.s index 06958d7d2..557813c19 100755 --- a/asm/pokeball.s +++ b/asm/pokeball.s @@ -185,7 +185,7 @@ _08075548: .pool _08075584: movs r0, 0x1 - bl GetBankByPlayerAI + bl GetBankByIdentity ldr r1, =gBankTarget strb r0, [r1] movs r0, 0x1 @@ -1199,13 +1199,13 @@ _08075DD4: lsrs r0, 16 mov r9, r0 movs r0, 0 - bl GetBankByPlayerAI + bl GetBankByIdentity lsls r0, 24 lsrs r0, 24 cmp r5, r0 beq _08075E00 movs r0, 0x1 - bl GetBankByPlayerAI + bl GetBankByIdentity lsls r0, 24 lsrs r0, 24 cmp r5, r0 @@ -1261,13 +1261,13 @@ _08075E70: .pool _08075E80: movs r0, 0 - bl GetBankByPlayerAI + bl GetBankByIdentity lsls r0, 24 lsrs r0, 24 cmp r5, r0 beq _08075E9C movs r0, 0x1 - bl GetBankByPlayerAI + bl GetBankByIdentity lsls r0, 24 lsrs r0, 24 cmp r5, r0 @@ -1830,7 +1830,7 @@ _080762F8: movs r0, 0x3A ldrsh r4, [r5, r0] movs r0, 0x2 - bl GetBankByPlayerAI + bl GetBankByIdentity lsls r0, 24 lsrs r0, 24 cmp r4, r0 @@ -1903,7 +1903,7 @@ sub_8076398: @ 8076398 movs r0, 0x3A ldrsh r4, [r5, r0] movs r0, 0x3 - bl GetBankByPlayerAI + bl GetBankByIdentity lsls r0, 24 lsrs r0, 24 cmp r4, r0 diff --git a/asm/pokemon_icon.s b/asm/pokemon_icon.s index e90253ab0..6009bd3f3 100755 --- a/asm/pokemon_icon.s +++ b/asm/pokemon_icon.s @@ -32,7 +32,7 @@ sub_80D2CC4: @ 80D2CC4 str r0, [sp, 0x18] adds r0, r4, 0 adds r2, r5, 0 - bl sub_80D2EDC + bl GetMonIconPtr str r0, [sp, 0x1C] ldr r0, =gUnknown_0857C5B4 str r0, [sp, 0x20] @@ -271,9 +271,9 @@ _080D2ED2: bx r1 thumb_func_end sub_80D2E84 - thumb_func_start sub_80D2EDC -@ void *sub_80D2EDC(u16 speciesId, u32 personality, bool32) -sub_80D2EDC: @ 80D2EDC + thumb_func_start GetMonIconPtr +@ void *GetMonIconPtr(u16 speciesId, u32 personality, bool32) +GetMonIconPtr: @ 80D2EDC push {r4,lr} adds r4, r2, 0 lsls r0, 16 @@ -286,7 +286,7 @@ sub_80D2EDC: @ 80D2EDC pop {r4} pop {r1} bx r1 - thumb_func_end sub_80D2EDC + thumb_func_end GetMonIconPtr thumb_func_start sub_80D2EF8 sub_80D2EF8: @ 80D2EF8 @@ -534,8 +534,8 @@ sub_80D30A0: @ 80D30A0 .pool thumb_func_end sub_80D30A0 - thumb_func_start sub_80D30B0 -sub_80D30B0: @ 80D30B0 + thumb_func_start GetValidMonIconPalettePtr +GetValidMonIconPalettePtr: @ 80D30B0 push {lr} lsls r0, 16 lsrs r2, r0, 16 @@ -556,7 +556,7 @@ _080D30C2: pop {r1} bx r1 .pool - thumb_func_end sub_80D30B0 + thumb_func_end GetValidMonIconPalettePtr thumb_func_start sub_80D30DC sub_80D30DC: @ 80D30DC diff --git a/asm/pokemon_item_effect.s b/asm/pokemon_item_effect.s index 69895d5d0..5dc6452e9 100644 --- a/asm/pokemon_item_effect.s +++ b/asm/pokemon_item_effect.s @@ -1155,7 +1155,7 @@ _0806C6AE: movs r0, 0 movs r1, 0 movs r2, 0 - bl EmitGetAttributes + bl EmitGetMonData ldrb r0, [r4] bl MarkBufferBankForExecution strb r5, [r4] diff --git a/asm/pokemon_storage_system.s b/asm/pokemon_storage_system.s index 6cca9c144..d94da87b1 100755 --- a/asm/pokemon_storage_system.s +++ b/asm/pokemon_storage_system.s @@ -17910,7 +17910,7 @@ sub_80D07B0: @ 80D07B0 beq _080D0828 adds r0, r5, 0 movs r2, 0x1 - bl sub_80D2EDC + bl GetMonIconPtr adds r4, r0, 0 adds r0, r5, 0 bl sub_80D3080 diff --git a/asm/reshow_battle_screen.s b/asm/reshow_battle_screen.s index 97cc16c77..77d107f3d 100644 --- a/asm/reshow_battle_screen.s +++ b/asm/reshow_battle_screen.s @@ -103,13 +103,13 @@ _080A93B0: strh r1, [r0] ldr r0, =gUnknown_02022E16 strh r1, [r0] - ldr r0, =gUnknown_02022E18 + ldr r0, =gBattle_BG1_X strh r1, [r0] - ldr r0, =gUnknown_02022E1A + ldr r0, =gBattle_BG1_Y strh r1, [r0] - ldr r0, =gUnknown_02022E1C + ldr r0, =gBattle_BG2_X strh r1, [r0] - ldr r0, =gUnknown_02022E1E + ldr r0, =gBattle_BG2_Y strh r1, [r0] ldr r0, =gUnknown_02022E20 strh r1, [r0] @@ -223,7 +223,7 @@ _080A94F0: _080A94F8: bl sub_805EC84 movs r0, 0x1 - bl GetBankByPlayerAI + bl GetBankByIdentity adds r4, r0, 0 lsls r4, 24 lsrs r4, 24 @@ -247,7 +247,7 @@ _080A94F8: cmp r0, 0 beq _080A955C movs r0, 0x3 - bl GetBankByPlayerAI + bl GetBankByIdentity adds r4, r0, 0 lsls r4, 24 lsrs r4, 24 diff --git a/asm/rom3.s b/asm/rom3.s index bf68c86c8..131721493 100644 --- a/asm/rom3.s +++ b/asm/rom3.s @@ -2134,8 +2134,8 @@ _0803389C: .pool thumb_func_end sub_803375C - thumb_func_start EmitGetAttributes -EmitGetAttributes: @ 80338B4 + thumb_func_start EmitGetMonData +EmitGetMonData: @ 80338B4 push {r4,lr} adds r4, r1, 0 lsls r0, 24 @@ -2152,7 +2152,7 @@ EmitGetAttributes: @ 80338B4 pop {r0} bx r0 .pool - thumb_func_end EmitGetAttributes + thumb_func_end EmitGetMonData thumb_func_start dp01_build_cmdbuf_x01_a_b_0 dp01_build_cmdbuf_x01_a_b_0: @ 80338D8 @@ -2175,8 +2175,8 @@ dp01_build_cmdbuf_x01_a_b_0: @ 80338D8 .pool thumb_func_end dp01_build_cmdbuf_x01_a_b_0 - thumb_func_start EmitSetAttributes -EmitSetAttributes: @ 8033900 + thumb_func_start EmitSetMonData +EmitSetMonData: @ 8033900 push {r4-r6,lr} ldr r4, [sp, 0x10] lsls r0, 24 @@ -2209,7 +2209,7 @@ _0803392E: pop {r0} bx r0 .pool - thumb_func_end EmitSetAttributes + thumb_func_end EmitSetMonData thumb_func_start sub_8033940 sub_8033940: @ 8033940 @@ -2809,8 +2809,8 @@ dp01_build_cmdbuf_x12_a_bb: @ 8033DE4 .pool thumb_func_end dp01_build_cmdbuf_x12_a_bb - thumb_func_start sub_8033E10 -sub_8033E10: @ 8033E10 + thumb_func_start EmitCmd13 +EmitCmd13: @ 8033E10 push {lr} lsls r0, 24 lsrs r0, 24 @@ -2825,7 +2825,7 @@ sub_8033E10: @ 8033E10 pop {r0} bx r0 .pool - thumb_func_end sub_8033E10 + thumb_func_end EmitCmd13 thumb_func_start sub_8033E30 sub_8033E30: @ 8033E30 @@ -2995,8 +2995,8 @@ EmitExpUpdate: @ 8033F34 .pool thumb_func_end EmitExpUpdate - thumb_func_start dp01_build_cmdbuf_x1A_aaaa_bbbb -dp01_build_cmdbuf_x1A_aaaa_bbbb: @ 8033F68 + thumb_func_start EmitStatusIconUpdate +EmitStatusIconUpdate: @ 8033F68 push {r4-r6,lr} adds r4, r1, 0 lsls r0, 24 @@ -3036,7 +3036,7 @@ dp01_build_cmdbuf_x1A_aaaa_bbbb: @ 8033F68 pop {r0} bx r0 .pool - thumb_func_end dp01_build_cmdbuf_x1A_aaaa_bbbb + thumb_func_end EmitStatusIconUpdate thumb_func_start EmitStatusAnimation EmitStatusAnimation: @ 8033FBC @@ -3718,8 +3718,8 @@ _08034490: .pool thumb_func_end EmitLinkStandbyMsg - thumb_func_start dp01_build_cmdbuf_x38_a -dp01_build_cmdbuf_x38_a: @ 80344A8 + thumb_func_start EmitResetActionMoveSelection +EmitResetActionMoveSelection: @ 80344A8 push {lr} adds r3, r1, 0 lsls r0, 24 @@ -3733,7 +3733,7 @@ dp01_build_cmdbuf_x38_a: @ 80344A8 pop {r0} bx r0 .pool - thumb_func_end dp01_build_cmdbuf_x38_a + thumb_func_end EmitResetActionMoveSelection thumb_func_start Emit_x37 Emit_x37: @ 80344C8 diff --git a/asm/rom_80A5C6C.s b/asm/rom_80A5C6C.s index ea75d4e2b..267045179 100644 --- a/asm/rom_80A5C6C.s +++ b/asm/rom_80A5C6C.s @@ -1830,8 +1830,8 @@ GetBankIdentity: @ 80A6A44 .pool thumb_func_end GetBankIdentity - thumb_func_start GetBankByPlayerAI -GetBankByPlayerAI: @ 80A6A54 + thumb_func_start GetBankByIdentity +GetBankByIdentity: @ 80A6A54 push {r4,lr} lsls r0, 24 lsrs r3, r0, 24 @@ -1860,7 +1860,7 @@ _080A6A7E: pop {r1} bx r1 .pool - thumb_func_end GetBankByPlayerAI + thumb_func_end GetBankByIdentity thumb_func_start sub_80A6A90 sub_80A6A90: @ 80A6A90 @@ -3496,7 +3496,7 @@ _080A76F2: cmp r5, 0 beq _080A771A movs r0, 0 - bl GetBankByPlayerAI + bl GetBankByIdentity lsls r0, 24 lsrs r0, 24 bl b_side_obj__get_some_boolean @@ -3504,7 +3504,7 @@ _080A76F2: cmp r0, 0 beq _080A771A movs r0, 0 - bl GetBankByPlayerAI + bl GetBankByIdentity lsls r0, 24 lsrs r0, 24 adds r0, 0x10 @@ -3514,7 +3514,7 @@ _080A771A: cmp r6, 0 beq _080A7746 movs r0, 0x2 - bl GetBankByPlayerAI + bl GetBankByIdentity lsls r0, 24 lsrs r0, 24 bl b_side_obj__get_some_boolean @@ -3522,7 +3522,7 @@ _080A771A: cmp r0, 0 beq _080A7746 movs r0, 0x2 - bl GetBankByPlayerAI + bl GetBankByIdentity lsls r0, 24 lsrs r0, 24 adds r1, r0, 0 @@ -3534,7 +3534,7 @@ _080A7746: cmp r7, 0 beq _080A7772 movs r0, 0x1 - bl GetBankByPlayerAI + bl GetBankByIdentity lsls r0, 24 lsrs r0, 24 bl b_side_obj__get_some_boolean @@ -3542,7 +3542,7 @@ _080A7746: cmp r0, 0 beq _080A7772 movs r0, 0x1 - bl GetBankByPlayerAI + bl GetBankByIdentity lsls r0, 24 lsrs r0, 24 adds r1, r0, 0 @@ -3555,7 +3555,7 @@ _080A7772: cmp r0, 0 beq _080A77A0 movs r0, 0x3 - bl GetBankByPlayerAI + bl GetBankByIdentity lsls r0, 24 lsrs r0, 24 bl b_side_obj__get_some_boolean @@ -3563,7 +3563,7 @@ _080A7772: cmp r0, 0 beq _080A77A0 movs r0, 0x3 - bl GetBankByPlayerAI + bl GetBankByIdentity lsls r0, 24 lsrs r0, 24 adds r1, r0, 0 @@ -3592,7 +3592,7 @@ sub_80A77B4: @ 80A77B4 push {lr} lsls r0, 24 lsrs r0, 24 - bl GetBankByPlayerAI + bl GetBankByIdentity lsls r0, 24 lsrs r0, 24 pop {r1} diff --git a/asm/title_screen.s b/asm/title_screen.s index 15037e80d..be102343b 100644 --- a/asm/title_screen.s +++ b/asm/title_screen.s @@ -468,7 +468,7 @@ title_screen_vblank_callback: @ 80AA780 bl LoadOam bl ProcessSpriteCopyRequests bl TransferPlttBuffer - ldr r0, =gUnknown_02022E1A + ldr r0, =gBattle_BG1_Y ldrh r1, [r0] movs r0, 0x16 bl SetGpuReg @@ -1156,14 +1156,14 @@ _080AAE30: ldrh r0, [r3, 0x10] adds r0, 0x1 strh r0, [r3, 0x10] - ldr r2, =gUnknown_02022E1A + ldr r2, =gBattle_BG1_Y movs r1, 0x10 ldrsh r0, [r3, r1] lsrs r1, r0, 31 adds r0, r1 asrs r0, 1 strh r0, [r2] - ldr r1, =gUnknown_02022E18 + ldr r1, =gBattle_BG1_X movs r0, 0 strh r0, [r1] _080AAE72: diff --git a/asm/unknown_task.s b/asm/unknown_task.s index e3526c809..9c01afe93 100644 --- a/asm/unknown_task.s +++ b/asm/unknown_task.s @@ -275,19 +275,19 @@ _080BA21C: b _080BA24E .pool _080BA224: - ldr r0, =gUnknown_02022E18 + ldr r0, =gBattle_BG1_X b _080BA24E .pool _080BA22C: - ldr r0, =gUnknown_02022E1A + ldr r0, =gBattle_BG1_Y b _080BA24E .pool _080BA234: - ldr r0, =gUnknown_02022E1C + ldr r0, =gBattle_BG2_X b _080BA24E .pool _080BA23C: - ldr r0, =gUnknown_02022E1E + ldr r0, =gBattle_BG2_Y b _080BA24E .pool _080BA244: diff --git a/data/battle_4.s b/data/battle_4.s index 3300b25ee..8f1872733 100644 --- a/data/battle_4.s +++ b/data/battle_4.s @@ -5,51 +5,6 @@ .section .rodata - -gMoveEffectBS_Ptrs:: @ 831C224 - .4byte gUnknown_082DB36A - .4byte gUnknown_082DB36A - .4byte gUnknown_082DB386 - .4byte gUnknown_082DB395 - .4byte gUnknown_082DB3A4 - .4byte gUnknown_082DB3B3 - .4byte gUnknown_082DB3C9 - .4byte gUnknown_082DB3E6 - .4byte gUnknown_082DB36A - .4byte gUnknown_082DB36A - .4byte gUnknown_082DB3C2 - .4byte gUnknown_082DB3D6 - .4byte gUnknown_082DB36A - .4byte gUnknown_082DB3DD - .4byte gUnknown_082DB3F4 - .4byte gUnknown_082DB36A - .4byte gUnknown_082DB36A - .4byte gUnknown_082DB36A - .4byte gUnknown_082DB36A - .4byte gUnknown_082DB36A - .4byte gUnknown_082DB36A - .4byte gUnknown_082DB36A - .4byte gUnknown_082DB36A - .4byte gUnknown_082DB36A - .4byte gUnknown_082DB36A - .4byte gUnknown_082DB36A - .4byte gUnknown_082DB36A - .4byte gUnknown_082DB36A - .4byte gUnknown_082DB36A - .4byte gUnknown_082DB36A - .4byte gUnknown_082DB36A - .4byte gUnknown_082DB36A - .4byte gUnknown_082DB36A - .4byte gUnknown_082DB36A - .4byte gUnknown_082DB36A - .4byte gUnknown_082DB36A - .4byte gUnknown_082DB36A - .4byte gUnknown_082DB36A - .4byte gUnknown_082DB3F4 - - .align 2 - window_template 0x00, 0x01, 0x03, 0x07, 0x0f, 0x1f, 0x003f - .align 2 gUnknown_0831C2C8:: @ 831C2C8 .incbin "graphics/battle_interface/unk_battlebox.gbapal" @@ -66,21 +21,21 @@ gUnknown_0831C3B8:: @ 831C3B8 .byte 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00 .align 2 -gUnknown_0831C3C0:: @ 831C3C0 +SpriteTemplate_MonIconOnLvlUpBox:: @ 831C3C0 .2byte 0xd75a @ tileTag .2byte 0xd75a @ paletteTag .4byte gUnknown_0831C3B8 .4byte gDummySpriteAnimTable .4byte NULL .4byte gDummySpriteAffineAnimTable - .4byte sub_804F450 + .4byte SpriteCB_MonIconOnLvlUpBox .align 2 sProtectSuccessRates:: @ 831C3D8 .2byte 0xffff, 0x7fff, 0x3fff, 0x1fff .align 2 -gUnknown_0831C3E0:: @ 831C3E0 +gMovesForbiddenToCopy:: @ 831C3E0 .2byte MOVE_METRONOME, MOVE_STRUGGLE, MOVE_SKETCH, MOVE_MIMIC .2byte 0xfffe, MOVE_COUNTER, MOVE_MIRROR_COAT, MOVE_PROTECT .2byte MOVE_DETECT, MOVE_ENDURE, MOVE_DESTINY_BOND, MOVE_SLEEP_TALK diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 44d0e7ed5..1fb6b8189 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -30,7 +30,7 @@ gUnknown_082D9EE1:: @ 82D9EE1 gUnknown_082D9EFB:: @ 82D9EFB .incbin "baserom.gba", 0x2d9efb, 0x21 -gUnknown_082D9F1C:: @ 82D9F1C +BattleScript_ButItFailed:: @ 82D9F1C .incbin "baserom.gba", 0x2d9f1c, 0x88e BattleScript_FaintAttacker:: @ 82DA7AA @@ -135,7 +135,7 @@ BattleScript_BideNoEnergyToAttack:: @ 82DADC4 gUnknown_082DADD8:: @ 82DADD8 .incbin "baserom.gba", 0x2dadd8, 0x2b -gUnknown_082DAE03:: @ 82DAE03 +BattleScript_MistProtected:: @ 82DAE03 .incbin "baserom.gba", 0x2dae03, 0xa BattleScript_RageIsBuilding:: @ 82DAE0D @@ -300,7 +300,7 @@ BattleScript_MoveUsedIsConfused:: @ 82DB2BD BattleScript_MoveUsedIsConfusedNoMore:: @ 82DB300 .incbin "baserom.gba", 0x2db300, 0x7 -gUnknown_082DB307:: @ 82DB307 +BattleScript_PrintPayDayMoneyString:: @ 82DB307 .incbin "baserom.gba", 0x2db307, 0x7 BattleScript_WrapTurnDmg:: @ 82DB30E @@ -324,40 +324,40 @@ BattleScript_CurseTurnDmg:: @ 82DB350 BattleScript_TargetPRLZHeal:: @ 82DB361 .incbin "baserom.gba", 0x2db361, 0x9 -gUnknown_082DB36A:: @ 82DB36A +BattleScript_MoveEffectSleep:: @ 82DB36A .incbin "baserom.gba", 0x2db36A, 0xE BattleScript_YawnMakesAsleep:: @ 82DB378 .incbin "baserom.gba", 0x2db378, 0xE -gUnknown_082DB386:: @ 82DB386 +BattleScript_MoveEffectPoison:: @ 82DB386 .incbin "baserom.gba", 0x2db386, 0xF -gUnknown_082DB395:: @ 82DB395 +BattleScript_MoveEffectBurn:: @ 82DB395 .incbin "baserom.gba", 0x2db395, 0xF -gUnknown_082DB3A4:: @ 82DB3A4 +BattleScript_MoveEffectFreeze:: @ 82DB3A4 .incbin "baserom.gba", 0x2db3A4, 0xF -gUnknown_082DB3B3:: @ 82DB3B3 +BattleScript_MoveEffectParalysis:: @ 82DB3B3 .incbin "baserom.gba", 0x2db3B3, 0xF -gUnknown_082DB3C2:: @ 82DB3C2 +BattleScript_MoveEffectUproar:: @ 82DB3C2 .incbin "baserom.gba", 0x2db3C2, 0x7 -gUnknown_082DB3C9:: @ 82DB3C9 +BattleScript_MoveEffectToxic:: @ 82DB3C9 .incbin "baserom.gba", 0x2db3C9, 0xD -gUnknown_082DB3D6:: @ 82DB3D6 +BattleScript_MoveEffectPayDay:: @ 82DB3D6 .incbin "baserom.gba", 0x2db3D6, 0x7 -gUnknown_082DB3DD:: @ 82DB3DD +BattleScript_MoveEffectWrap:: @ 82DB3DD .incbin "baserom.gba", 0x2db3DD, 0x9 -gUnknown_082DB3E6:: @ 82DB3E6 +BattleScript_MoveEffectConfusion:: @ 82DB3E6 .incbin "baserom.gba", 0x2db3E6, 0xE -gUnknown_082DB3F4:: @ 82DB3F4 +BattleScript_MoveEffectRecoil33:: @ 82DB3F4 .incbin "baserom.gba", 0x2db3F4, 0x2e BattleScript_ItemSteal:: @ 82DB422 @@ -396,10 +396,10 @@ BattleScript_DroughtActivates:: @ 82DB52A BattleScript_TookAttack:: @ 82DB53E .incbin "baserom.gba", 0x2db53e, 0x14 -gUnknown_082DB552:: @ 82DB552 +BattleScript_SturdyPreventsOHKO:: @ 82DB552 .incbin "baserom.gba", 0x2db552, 0xe -gUnknown_082DB560:: @ 82DB560 +BattleScript_DampStopsExplosion:: @ 82DB560 .incbin "baserom.gba", 0x2db560, 0xe BattleScript_MoveHPDrain_PPLoss:: @ 82DB56E @@ -420,7 +420,7 @@ BattleScript_FlashFireBoost_PPLoss:: @ 82DB5A7 BattleScript_FlashFireBoost:: @ 82DB5A8 .incbin "baserom.gba", 0x2db5a8, 0x1f -gUnknown_082DB5C7:: @ 82DB5C7 +BattleScript_AbilityNoStatLoss:: @ 82DB5C7 .incbin "baserom.gba", 0x2db5c7, 0xa BattleScript_BRNPrevention:: @ 82DB5D1 @@ -432,7 +432,7 @@ BattleScript_PRLZPrevention:: @ 82DB5DD BattleScript_PSNPrevention:: @ 82DB5E9 .incbin "baserom.gba", 0x2db5e9, 0xc -gUnknown_082DB5F5:: @ 82DB5F5 +BattleScript_ObliviousPreventsAttraction:: @ 82DB5F5 .incbin "baserom.gba", 0x2db5f5, 0xe BattleScript_FlinchPrevention:: @ 82DB603 @@ -441,7 +441,7 @@ BattleScript_FlinchPrevention:: @ 82DB603 BattleScript_SoundproofProtected:: @ 82DB61F .incbin "baserom.gba", 0x2db61f, 0x10 -gUnknown_082DB62F:: @ 82DB62F +BattleScript_AbilityNoSpecificStatLoss:: @ 82DB62F .incbin "baserom.gba", 0x2db62f, 0x10 BattleScript_StickyHoldOnKnockOff:: @ 82DB63F diff --git a/include/battle.h b/include/battle.h index d45944274..f84a75cba 100644 --- a/include/battle.h +++ b/include/battle.h @@ -1,8 +1,28 @@ #ifndef GUARD_BATTLE_H #define GUARD_BATTLE_H +/* + Banks are a name given to what could be called a 'battlerId' or 'monControllerId'. + Each bank has a value consisting of two bits. + 0x1 bit is responsible for the side, 0 = player's side, 1 = opponent's side. + 0x2 bit is responsible for the id of sent out pokemon. 0 means it's the first sent out pokemon, 1 it's the second one. (Triple battle didn't exist at the time yet.) +*/ + #define BATTLE_BANKS_COUNT 4 +#define IDENTITY_PLAYER_MON1 0 +#define IDENTITY_OPPONENT_MON1 1 +#define IDENTITY_PLAYER_MON2 2 +#define IDENTITY_OPPONENT_MON2 3 + +#define SIDE_PLAYER 0x0 +#define SIDE_OPPONENT 0x1 + +#define BIT_SIDE 0x1 +#define BIT_MON 0x2 + +#define GET_BANK_SIDE(bank)((GetBankIdentity(bank) & BIT_SIDE)) + #define BATTLE_TYPE_DOUBLE 0x0001 #define BATTLE_TYPE_LINK 0x0002 #define BATTLE_TYPE_WILD 0x0004 @@ -40,9 +60,6 @@ #define BATTLE_TYPE_FRONTIER (BATTLE_TYPE_BATTLE_TOWER | BATTLE_TYPE_DOME | BATTLE_TYPE_PALACE | BATTLE_TYPE_ARENA | BATTLE_TYPE_FACTORY | BATTLE_TYPE_x100000 | BATTLE_TYPE_PYRAMID) -#define SIDE_PLAYER 0x0 -#define SIDE_OPPONENT 0x1 - #define BATTLE_WON 0x1 #define BATTLE_LOST 0x2 #define BATTLE_DREW 0x3 @@ -66,11 +83,12 @@ #define STATUS2_CONFUSION 0x00000007 #define STATUS2_FLINCHED 0x00000008 #define STATUS2_UPROAR 0x00000070 -#define STATUS2_BIDE 0x00000300 //two bits 0x100 0x200 +#define STATUS2_BIDE 0x00000300 // two bits 0x100, 0x200 #define STATUS2_LOCK_CONFUSE 0x00000C00 #define STATUS2_MULTIPLETURNS 0x00001000 #define STATUS2_WRAPPED 0x0000E000 -#define STATUS2_INFATUATION 0x000F0000 +#define STATUS2_INFATUATION 0x000F0000 // 4 bits, one for every bank +#define STATUS2_INFATUATED_WITH(bank)((gBitTable[bank] << 16)) #define STATUS2_FOCUS_ENERGY 0x00100000 #define STATUS2_TRANSFORMED 0x00200000 #define STATUS2_RECHARGE 0x00400000 @@ -86,7 +104,7 @@ #define STATUS3_LEECHSEED_BANK 0x3 #define STATUS3_LEECHSEED 0x4 -#define STATUS3_ALWAYS_HITS 0x18 //two bits +#define STATUS3_ALWAYS_HITS 0x18 // two bits #define STATUS3_PERISH_SONG 0x20 #define STATUS3_ON_AIR 0x40 #define STATUS3_UNDERGROUND 0x80 @@ -188,17 +206,6 @@ #define WEATHER_HAIL (1 << 7) #define WEATHER_HAIL_ANY ((WEATHER_HAIL)) -#define REQUEST_ALL_BATTLE 0x0 -#define REQUEST_SPECIES_BATTLE 0x1 -#define REQUEST_HELDITEM_BATTLE 0x2 -#define REQUEST_MOVES_PP_BATTLE 0x3 -#define REQUEST_PPMOVE1_BATTLE 0x9 -#define REQUEST_PPMOVE2_BATTLE 0xA -#define REQUEST_PPMOVE3_BATTLE 0xB -#define REQUEST_PPMOVE4_BATTLE 0xC -#define REQUEST_STATUS_BATTLE 0x28 -#define REQUEST_HP_BATTLE 0x2A - // array entries for battle communication #define CURSOR_POSITION 0x1 #define MOVE_EFFECT_BYTE 0x3 @@ -222,6 +229,7 @@ #define BS_GET_TARGET 0 #define BS_GET_ATTACKER 1 #define BS_GET_EFFECT_BANK 2 +#define BS_ATTACKER_WITH_PARTNER 4 // for atk98_status_icon_update #define BS_GET_ATTACKER_SIDE 8 // for atk1E_jumpifability #define BS_GET_NOT_ATTACKER_SIDE 9 // for atk1E_jumpifability #define BS_GET_SCRIPTING_BANK 10 @@ -384,11 +392,11 @@ extern struct ProtectStruct gProtectStructs[BATTLE_BANKS_COUNT]; struct SpecialStatus { - u8 statLowered : 1; - u8 lightningRodRedirected : 1; - u8 restoredBankSprite: 1; - u8 intimidatedPoke : 1; - u8 traced : 1; + u8 statLowered : 1; // 0x1 + u8 lightningRodRedirected : 1; // 0x2 + u8 restoredBankSprite: 1; // 0x4 + u8 intimidatedPoke : 1; // 0x8 + u8 traced : 1; // 0x10 u8 flag20 : 1; u8 flag40 : 1; u8 focusBanded : 1; @@ -690,6 +698,7 @@ struct BattleStruct u8 field_298[8]; u8 field_2A0; u8 field_2A1; + u8 field_2A2; }; extern struct BattleStruct* gBattleStruct; @@ -709,6 +718,13 @@ extern struct BattleStruct* gBattleStruct; varName = (u16*)(((void*)(*memes1) + (u32)(memes2))); \ } +#define GET_USED_ITEM_PTR_VIA_MEME_ACCESS(bank, varName) \ +{ \ + void** memes1 = (void**)(&gBattleStruct); \ + void* memes2 = (void*)((u32)(bank * 2 + offsetof(struct BattleStruct, usedHeldItems))); \ + varName = (u16*)(((void*)(*memes1) + (u32)(memes2))); \ +} + #define GET_HP_SWITCHOUT_PTR_VIA_MEME_ACCESS(bank, varName) \ { \ void** memes1 = (void**)(&gBattleStruct); \ @@ -724,8 +740,6 @@ extern struct BattleStruct* gBattleStruct; typeArg = gBattleMoves[move].type; \ } -#define GET_BANK_SIDE(bank)((GetBankIdentity(bank) & 1)) - #define MOVE_EFFECT_SLEEP 0x1 #define MOVE_EFFECT_POISON 0x2 #define MOVE_EFFECT_BURN 0x3 @@ -832,26 +846,39 @@ extern struct BattleStruct* gBattleStruct; #define ATK4F_DONT_CHECK_STATUSES 0x80 +#define VARIOUS_CANCEL_MULTI_TURN_MOVES 0 +#define VARIOUS_SET_MAGIC_COAT_TARGET 1 +#define VARIOUS_GET_MOVE_TARGET 3 +#define VARIOUS_RESET_INTIMIDATE_TRACE_BITS 5 +#define VARIOUS_UPDATE_CHOICE_MOVE_ON_LVL_UP 6 +#define VARIOUS_WAIT_CRY 18 +#define VARIOUS_RETURN_OPPONENT_MON1 19 +#define VARIOUS_RETURN_OPPONENT_MON2 20 +#define VARIOUS_SET_TELEPORT_OUTCOME 25 +#define VARIOUS_PLAY_TRAINER_DEFEATED_MUSIC 26 + +#define ATK80_DMG_CHANGE_SIGN 0 +#define ATK80_DMG_HALF_BY_TWO_NOT_MORE_THAN_HALF_MAX_HP 1 +#define ATK80_DMG_DOUBLED 2 + #define GET_STAT_BUFF_ID(n)((n & 0xF)) // first four bits 0x1, 0x2, 0x4, 0x8 -#define GET_STAT_BUFF_VALUE(n)((n & 0xF0) >> 4) // 0x10, 0x20, 0x40 +#define GET_STAT_BUFF_VALUE(n)(((n >> 4) & 7)) // 0x10, 0x20, 0x40 #define STAT_BUFF_NEGATIVE 0x80 // 0x80, the sign bit +#define STAT_CHANGE_BS_PTR 0x1 +#define STAT_CHANGE_NOT_PROTECT_AFFECTED 0x20 + +#define STAT_CHANGE_WORKED 0 +#define STAT_CHANGE_DIDNT_WORK 1 + #define SET_STAT_BUFF_ID(n)((n & 0xF)) #define SET_STAT_BUFF_VALUE(n)(((s8)(((s8)(n) << 4)) & 0xF0)) struct BattleScripting { - u8 field_0; - u8 field_1; - u8 field_2; - u8 field_3; - u32 bideDmg; - u8 field_8; - u8 field_9; - u8 field_A; - u8 field_B; - u8 field_C; - u8 field_D; + s32 painSplitHp; + s32 bideDmg; + u8 multihitString[6]; u8 dmgMultiplier; u8 field_F; u8 animArg1; @@ -868,7 +895,7 @@ struct BattleScripting u8 field_1B; u8 atk23_state; u8 field_1D; - u8 field_1E; + u8 atk6C_state; u8 learnMoveState; }; @@ -887,6 +914,9 @@ void SwitchInClearStructs(void); void sub_803BDA0(u8 bank); void sub_803FA70(u8 bank); void BattleMainCB2(void); +void ResetSentPokesToOpponentValue(void); +bool8 CanRunFromBattle(u8 bank); +bool8 IsRunningFromBattleImpossible(void); // battle_3 void BattleScriptPush(const u8* bsPtr); @@ -920,10 +950,12 @@ u8 AI_TypeCalc(u16 move, u16 species, u8 ability); u8 BankGetTurnOrder(u8 bank); void BattleDestroyCursorAt(u8 cursorPosition); void BattleCreateCursorAt(u8 cursorPosition); +void BufferMoveToLearnIntoBattleTextBuff2(void); // battle_5 void AdjustFriendshipOnBattleFaint(u8 bank); void sub_80571DC(u8 bank, u8 arg1); +u32 sub_805725C(u8 bank); // battle 7 void BattleMusicStop(void); @@ -932,7 +964,7 @@ void sub_805E990(struct Pokemon* mon, u8 bank); // rom_80A5C6C u8 GetBankSide(u8 bank); u8 GetBankIdentity(u8 bank); -u8 GetBankByPlayerAI(u8 bank); +u8 GetBankByIdentity(u8 bank); // Move this somewhere else diff --git a/include/battle_controllers.h b/include/battle_controllers.h index b24aa9cc5..bb58cb699 100644 --- a/include/battle_controllers.h +++ b/include/battle_controllers.h @@ -7,8 +7,26 @@ struct HpAndStatus u32 status; }; +struct MovePpInfo +{ + u16 move[4]; + u8 pp[4]; + u8 ppBonuses; +}; + +#define REQUEST_ALL_BATTLE 0x0 +#define REQUEST_SPECIES_BATTLE 0x1 +#define REQUEST_HELDITEM_BATTLE 0x2 +#define REQUEST_MOVES_PP_BATTLE 0x3 +#define REQUEST_PPMOVE1_BATTLE 0x9 +#define REQUEST_PPMOVE2_BATTLE 0xA +#define REQUEST_PPMOVE3_BATTLE 0xB +#define REQUEST_PPMOVE4_BATTLE 0xC +#define REQUEST_STATUS_BATTLE 0x28 +#define REQUEST_HP_BATTLE 0x2A + // rom3.s, emitters -void EmitSetAttributes(u8 bufferId, u8 request, u8 c, u8 bytes, void *data); +void EmitSetMonData(u8 bufferId, u8 request, u8 c, u8 bytes, void *data); void EmitMoveAnimation(u8 bufferId, u16 move, u8 turnOfMove, u16 movePower, s32 dmg, u8 friendship, struct DisableStruct* disableStructPtr, u8 multihit); void EmitHealthBarUpdate(u8 bufferId, u16 hpValue); void EmitEffectivenessSound(u8 bufferId, u16 songId); @@ -20,7 +38,7 @@ void EmitExpUpdate(u8 bufferId, u8 partyId, u16 expPoints); void EmitBattleAnimation(u8 bufferId, u8 animationId, u16 argument); void EmitSpriteInvisibility(u8 bufferId, bool8 isInvisible); void EmitReturnPokeToBall(u8 bufferId, u8 arg1); -void EmitGetAttributes(u8 bufferId, u8 arg1, u8 arg2); +void EmitGetMonData(u8 bufferId, u8 arg1, u8 arg2); 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); @@ -31,6 +49,13 @@ void EmitHitAnimation(u8 bufferId); void EmitCmd48(u8 bufferId, struct HpAndStatus* hpAndStatus, u8 arg2); 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 MarkBufferBankForExecution(u8 bank); diff --git a/include/battle_message.h b/include/battle_message.h index ad1ce3455..3e28fa5e5 100644 --- a/include/battle_message.h +++ b/include/battle_message.h @@ -74,6 +74,22 @@ #define B_BUFF_PLACEHOLDER_BEGIN 0xFD #define B_BUFF_EOS 0xFF +#define PREPARE_STAT_BUFFER(textVar, statId) \ +{ \ + textVar[0] = B_BUFF_PLACEHOLDER_BEGIN; \ + textVar[1] = B_BUFF_STAT; \ + textVar[2] = statId; \ + textVar[3] = B_BUFF_EOS; \ +} + +#define PREPARE_TYPE_BUFFER(textVar, typeId) \ +{ \ + textVar[0] = B_BUFF_PLACEHOLDER_BEGIN; \ + textVar[1] = B_BUFF_TYPE; \ + textVar[2] = typeId; \ + textVar[3] = B_BUFF_EOS; \ +} + #define PREPARE_BYTE_NUMBER_BUFFER(textVar, maxDigits, number) \ { \ textVar[0] = B_BUFF_PLACEHOLDER_BEGIN; \ @@ -84,6 +100,17 @@ textVar[5] = B_BUFF_EOS; \ } +#define PREPARE_HWORD_NUMBER_BUFFER(textVar, maxDigits, number) \ +{ \ + textVar[0] = B_BUFF_PLACEHOLDER_BEGIN; \ + textVar[1] = B_BUFF_NUMBER; \ + textVar[2] = 2; \ + textVar[3] = maxDigits; \ + textVar[4] = (number); \ + textVar[5] = (number & 0x0000FF00) >> 8; \ + textVar[6] = B_BUFF_EOS; \ +} + #define PREPARE_WORD_NUMBER_BUFFER(textVar, maxDigits, number) \ { \ textVar[0] = B_BUFF_PLACEHOLDER_BEGIN; \ @@ -158,7 +185,7 @@ struct StringInfoBattle }; void BufferStringBattle(u16 stringID); -u32 StrCpyDecodeToDisplayedStringBattle(const u8* src); +u32 BattleStringExpandPlaceholdersToDisplayedString(const u8* src); u32 BattleStringExpandPlaceholders(const u8* src, u8* dst); void sub_814F9EC(const u8* text, u8 arg1); diff --git a/include/moves.h b/include/moves.h index e3b6d3113..bc213cbc7 100644 --- a/include/moves.h +++ b/include/moves.h @@ -360,4 +360,6 @@ enum MOVE_PSYCHO_BOOST, }; -#endif // GUARD_MOVES_H \ No newline at end of file +#define LAST_MOVE_INDEX MOVE_PSYCHO_BOOST + +#endif // GUARD_MOVES_H diff --git a/include/pokemon.h b/include/pokemon.h index 518d28e58..20e904f39 100644 --- a/include/pokemon.h +++ b/include/pokemon.h @@ -126,6 +126,8 @@ #define TYPE_DRAGON 0x10 #define TYPE_DARK 0x11 +#define NUMBER_OF_MON_TYPES 0x12 + #define PARTY_SIZE 6 #define MAX_TOTAL_EVS 510 #define NUM_STATS 6 @@ -333,6 +335,8 @@ struct UnknownPokemonStruct u8 friendship; }; +#define BATTLE_STATS_NO 8 + struct BattlePokemon { /*0x00*/ u16 species; @@ -350,7 +354,7 @@ struct BattlePokemon /*0x17*/ u32 spDefenseIV:5; /*0x17*/ u32 isEgg:1; /*0x17*/ u32 altAbility:1; - /*0x18*/ s8 statStages[8]; + /*0x18*/ s8 statStages[BATTLE_STATS_NO]; /*0x20*/ u8 ability; /*0x21*/ u8 type1; /*0x22*/ u8 type2; @@ -521,6 +525,7 @@ extern struct PokemonStorage* gPokemonStoragePtr; extern const u32 gExperienceTables[][MAX_MON_LEVEL + 1]; extern const u16 *const gLevelUpLearnsets[]; +u8 CountAliveMonsInBattle(u8 caseId); #define BATTLE_ALIVE_EXCEPT_ACTIVE 0 #define BATTLE_ALIVE_ATK_SIDE 1 #define BATTLE_ALIVE_DEF_SIDE 2 diff --git a/include/pokemon_icon.h b/include/pokemon_icon.h new file mode 100644 index 000000000..b82334355 --- /dev/null +++ b/include/pokemon_icon.h @@ -0,0 +1,7 @@ +#ifndef GUARD_POKEMON_ICON_H +#define GUARD_POKEMON_ICON_H + +const u8 *GetMonIconPtr(u16 speciesId, u32 personality, u32 frameNo); +const u16 *GetValidMonIconPalettePtr(u16 speciesId); + +#endif // GUARD_POKEMON_ICON_H diff --git a/include/pokemon_item_effects.h b/include/pokemon_item_effects.h new file mode 100644 index 000000000..88f341317 --- /dev/null +++ b/include/pokemon_item_effects.h @@ -0,0 +1,8 @@ +#ifndef GUARD_POKEMON_ITEM_EFFECTS +#define GUARD_POKEMON_ITEM_EFFECTS + +#include "pokemon.h" + +bool8 ExecuteTableBasedItemEffect(struct Pokemon *mon, u16 itemId, u8 partyId, u8 monMoveIndex, u8 a5); + +#endif // GUARD_POKEMON_ITEM_EFFECTS diff --git a/include/text.h b/include/text.h index f0c85b978..88f2cc0e2 100644 --- a/include/text.h +++ b/include/text.h @@ -65,6 +65,7 @@ #define CHAR_x 0xEC #define CHAR_y 0xED #define CHAR_z 0xEE +#define CHAR_SPECIAL_F9 0xF9 #define CHAR_COLON 0xF0 #define CHAR_PROMPT_SCROLL 0xFA // waits for button press and scrolls dialog #define CHAR_PROMPT_CLEAR 0xFB // waits for button press and clears dialog @@ -73,6 +74,10 @@ #define CHAR_NEWLINE 0xFE #define EOS 0xFF // end of string +#define TEXT_COLOR_TRANSPARENT 0x0 +#define TEXT_COLOR_WHITE 0x1 +#define TEXT_COLOR_DARK_GREY 0x2 + // battle placeholders are located in battle_message.h #define EXT_CTRL_CODE_JPN 0x15 @@ -80,23 +85,26 @@ #define NUM_TEXT_PRINTERS 32 +struct TextSubPrinter // TODO: Better name +{ + u8* current_text_offset; + u8 windowId; + u8 fontId; + u8 x; + u8 y; + u8 currentX; // 0x8 + u8 currentY; + u8 letterSpacing; + u8 lineSpacing; + u8 fontColor_l:4; // 0xC + u8 fontColor_h:4; + u8 bgColor:4; + u8 shadowColor:4; +}; + struct TextPrinter { - struct TextSubPrinter { // TODO: Better name - u8* current_text_offset; - u8 windowId; - u8 fontId; - u8 x; - u8 y; - u8 currentX; // 0x8 - u8 currentY; - u8 letterSpacing; - u8 lineSpacing; - u8 fontColor_l:4; // 0xC - u8 fontColor_h:4; - u8 bgColor:4; - u8 shadowColor:4; - } subPrinter; + struct TextSubPrinter subPrinter; void (*callback)(struct TextSubPrinter *, u16); // 0x10 diff --git a/include/window.h b/include/window.h index e8af82e81..4e814ebc6 100644 --- a/include/window.h +++ b/include/window.h @@ -55,7 +55,7 @@ void PutWindowRectTilemap(u8 windowId, u8 x, u8 y, u8 width, u8 height); void BlitBitmapToWindow(u8 windowId, u8 *pixels, u16 x, u16 y, u16 width, u16 height); void BlitBitmapRectToWindow(u8 windowId, const u8 *pixels, u16 srcX, u16 srcY, u16 srcWidth, int srcHeight, u16 destX, u16 destY, u16 rectWidth, u16 rectHeight); void FillWindowPixelRect(u8 windowId, u8 fillValue, u16 x, u16 y, u16 width, u16 height); -void CopyToWindowPixelBuffer(u8 windowId, u8 *src, u16 size, u16 tileOffset); +void CopyToWindowPixelBuffer(u8 windowId, const u8 *src, u16 size, u16 tileOffset); void FillWindowPixelBuffer(u8 windowId, u8 fillValue); void ScrollWindow(u8 windowId, u8 direction, u8 distance, u8 fillValue); void CallWindowFunction(u8 windowId, void ( *func)(u8, u8, u8, u8, u8, u8)); diff --git a/src/battle_3.c b/src/battle_3.c index 1b443118d..1fd84a61b 100644 --- a/src/battle_3.c +++ b/src/battle_3.c @@ -831,7 +831,7 @@ u8 TurnBasedEffects(void) gBattleCommunication[MULTISTRING_CHOOSER] = 1; b_call_bc_move_exec(gUnknown_082DB234); gActiveBank = gBankAttacker; - EmitSetAttributes(0, REQUEST_STATUS_BATTLE, 0, 4, &gBattleMons[gActiveBank].status1); + EmitSetMonData(0, REQUEST_STATUS_BATTLE, 0, 4, &gBattleMons[gActiveBank].status1); MarkBufferBankForExecution(gActiveBank); break; } @@ -956,7 +956,7 @@ u8 TurnBasedEffects(void) { CancelMultiTurnMoves(gActiveBank); gBattleMons[gActiveBank].status1 |= (Random() & 3) + 2; - EmitSetAttributes(0, REQUEST_STATUS_BATTLE, 0, 4, &gBattleMons[gActiveBank].status1); + EmitSetMonData(0, REQUEST_STATUS_BATTLE, 0, 4, &gBattleMons[gActiveBank].status1); MarkBufferBankForExecution(gActiveBank); gEffectBank = gActiveBank; b_call_bc_move_exec(BattleScript_YawnMakesAsleep); @@ -1446,7 +1446,7 @@ u8 AtkCanceller_UnableToUseMove(void) if (effect == 2) { gActiveBank = gBankAttacker; - EmitSetAttributes(0, REQUEST_STATUS_BATTLE, 0, 4, &gBattleMons[gActiveBank].status1); + EmitSetMonData(0, REQUEST_STATUS_BATTLE, 0, 4, &gBattleMons[gActiveBank].status1); MarkBufferBankForExecution(gActiveBank); } return effect; @@ -1539,14 +1539,14 @@ bool8 sub_80423F4(u8 bank, u8 r1, u8 r2) { if (GetBankSide(bank) == SIDE_OPPONENT) { - r7 = GetBankByPlayerAI(1); - r6 = GetBankByPlayerAI(3); + r7 = GetBankByIdentity(1); + r6 = GetBankByIdentity(3); party = gEnemyParty; } else { - r7 = GetBankByPlayerAI(0); - r6 = GetBankByPlayerAI(2); + r7 = GetBankByIdentity(0); + r6 = GetBankByIdentity(2); party = gPlayerParty; } if (r1 == 6) @@ -1835,7 +1835,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) gBattleMons[bank].status2 &= ~(STATUS2_NIGHTMARE); // fix nighmare glitch gBattleScripting.bank = gActiveBank = bank; b_push_move_exec(BattleScript_ShedSkinActivates); - EmitSetAttributes(0, REQUEST_STATUS_BATTLE, 0, 4, &gBattleMons[bank].status1); + EmitSetMonData(0, REQUEST_STATUS_BATTLE, 0, 4, &gBattleMons[bank].status1); MarkBufferBankForExecution(gActiveBank); effect++; } @@ -2156,7 +2156,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) gBattlescriptCurrInstr = gUnknown_082DB68C; gBattleScripting.bank = i; gActiveBank = i; - EmitSetAttributes(0, REQUEST_STATUS_BATTLE, 0, 4, &gBattleMons[gActiveBank].status1); + EmitSetMonData(0, REQUEST_STATUS_BATTLE, 0, 4, &gBattleMons[gActiveBank].status1); MarkBufferBankForExecution(gActiveBank); return effect; } @@ -2235,14 +2235,14 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) if (gBattleMons[i].ability == ABILITY_TRACE && (gStatuses3[i] & STATUS3_TRACE)) { u8 opposite = (GetBankIdentity(i) ^ 1) & 1; - u8 target1 = GetBankByPlayerAI(opposite); - u8 target2 = GetBankByPlayerAI(opposite + 2); + u8 target1 = GetBankByIdentity(opposite); + u8 target2 = GetBankByIdentity(opposite + 2); if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE) { if (gBattleMons[target1].ability != 0 && gBattleMons[target1].hp != 0 && gBattleMons[target2].ability != 0 && gBattleMons[target2].hp != 0) { - gActiveBank = GetBankByPlayerAI(((Random() & 1) * 2) | opposite); + gActiveBank = GetBankByIdentity(((Random() & 1) * 2) | opposite); gBattleMons[i].ability = gBattleMons[gActiveBank].ability; gLastUsedAbility = gBattleMons[gActiveBank].ability; effect++; @@ -3106,7 +3106,7 @@ _08042E24:\n\ movs r1, 0x28\n\ movs r2, 0\n\ movs r3, 0x4\n\ - bl EmitSetAttributes\n\ + bl EmitSetMonData\n\ ldrb r0, [r4]\n\ bl MarkBufferBankForExecution\n\ bl _080443D0\n\ @@ -4500,7 +4500,7 @@ _08043BFC:\n\ movs r1, 0x28\n\ movs r2, 0\n\ movs r3, 0x4\n\ - bl EmitSetAttributes\n\ + bl EmitSetMonData\n\ ldrb r0, [r4]\n\ bl MarkBufferBankForExecution\n\ bl _0804443A\n\ @@ -4744,11 +4744,11 @@ _08043E42:\n\ eors r5, r1\n\ ands r5, r1\n\ adds r0, r5, 0\n\ - bl GetBankByPlayerAI\n\ + bl GetBankByIdentity\n\ lsls r0, 24\n\ lsrs r6, r0, 24\n\ adds r0, r5, 0x2\n\ - bl GetBankByPlayerAI\n\ + bl GetBankByIdentity\n\ lsls r0, 24\n\ lsrs r7, r0, 24\n\ ldr r0, =gBattleTypeFlags\n\ @@ -4792,7 +4792,7 @@ _08043E74:\n\ lsls r1, 1\n\ orrs r5, r1\n\ adds r0, r5, 0\n\ - bl GetBankByPlayerAI\n\ + bl GetBankByIdentity\n\ mov r2, r8\n\ strb r0, [r2]\n\ ldrb r0, [r2]\n\ @@ -5609,7 +5609,7 @@ u8 ItemBattleEffects(u8 caseID, u8 bank, bool8 moveTurn) gBattleTextBuff1[3] = move >> 8; gBattleTextBuff1[4] = 0xFF; b_call_bc_move_exec(BattleScript_BerryPPHealEnd2); - EmitSetAttributes(0, i + REQUEST_PPMOVE1_BATTLE, 0, 1, &changedPP); + EmitSetMonData(0, i + REQUEST_PPMOVE1_BATTLE, 0, 1, &changedPP); MarkBufferBankForExecution(gActiveBank); effect = ITEM_PP_CHANGE; } @@ -5993,7 +5993,7 @@ u8 ItemBattleEffects(u8 caseID, u8 bank, bool8 moveTurn) switch (effect) { case ITEM_STATUS_CHANGE: - EmitSetAttributes(0, REQUEST_STATUS_BATTLE, 0, 4, &gBattleMons[bank].status1); + EmitSetMonData(0, REQUEST_STATUS_BATTLE, 0, 4, &gBattleMons[bank].status1); MarkBufferBankForExecution(gActiveBank); break; case ITEM_PP_CHANGE: @@ -6148,7 +6148,7 @@ u8 ItemBattleEffects(u8 caseID, u8 bank, bool8 moveTurn) gBattleScripting.bank = bank; gStringBank = bank; gActiveBank = bank; - EmitSetAttributes(0, REQUEST_STATUS_BATTLE, 0, 4, &gBattleMons[gActiveBank].status1); + EmitSetMonData(0, REQUEST_STATUS_BATTLE, 0, 4, &gBattleMons[gActiveBank].status1); MarkBufferBankForExecution(gActiveBank); break; } @@ -6251,7 +6251,7 @@ u8 GetMoveTarget(u16 move, u8 useMoveTarget) case MOVE_TARGET_BOTH: case MOVE_TARGET_FOES_AND_ALLY: case MOVE_TARGET_OPPONENTS_FIELD: - targetBank = GetBankByPlayerAI((GetBankIdentity(gBankAttacker) & 1) ^ 1); + targetBank = GetBankByIdentity((GetBankIdentity(gBankAttacker) & 1) ^ 1); if (gAbsentBankFlags & gBitTable[targetBank]) targetBank ^= 2; break; @@ -6264,22 +6264,22 @@ u8 GetMoveTarget(u16 move, u8 useMoveTarget) if (GetBankSide(gBankAttacker) == SIDE_PLAYER) { if (Random() & 1) - targetBank = GetBankByPlayerAI(1); + targetBank = GetBankByIdentity(1); else - targetBank = GetBankByPlayerAI(3); + targetBank = GetBankByIdentity(3); } else { if (Random() & 1) - targetBank = GetBankByPlayerAI(0); + targetBank = GetBankByIdentity(0); else - targetBank = GetBankByPlayerAI(2); + targetBank = GetBankByIdentity(2); } if (gAbsentBankFlags & gBitTable[targetBank]) targetBank ^= 2; } else - targetBank = GetBankByPlayerAI((GetBankIdentity(gBankAttacker) & 1) ^ 1); + targetBank = GetBankByIdentity((GetBankIdentity(gBankAttacker) & 1) ^ 1); break; case MOVE_TARGET_USER: case MOVE_TARGET_x10: diff --git a/src/battle_4.c b/src/battle_4.c index 77a4393c4..0f52ee0dd 100644 --- a/src/battle_4.c +++ b/src/battle_4.c @@ -24,6 +24,11 @@ #include "main.h" #include "palette.h" #include "money.h" +#include "bg.h" +#include "string_util.h" +#include "pokemon_icon.h" +#include "pokemon_item_effects.h" +#include "m4a.h" // variables @@ -91,6 +96,7 @@ extern u16 gUnknownMovesUsedByBanks[BATTLE_BANKS_COUNT]; extern u16 gLastUsedMovesByBanks[BATTLE_BANKS_COUNT]; extern u16 gTrainerBattleOpponent_A; extern u16 gTrainerBattleOpponent_B; +extern struct MusicPlayerInfo gMPlay_BGM; struct TrainerMoney { @@ -112,6 +118,15 @@ extern void sub_81A56B4(void); // battle frontier 2 extern void sub_81BFA38(struct Pokemon* party, u8 monPartyId, u8 monCount, void (*callback)(void), u16 move); // pokemon summary screen extern u8 sub_81C1B94(void); // pokemon summary screen extern void IncrementGameStat(u8 statId); // rom_4 +extern void sub_81D388C(struct Pokemon* mon, void* statStoreLocation); // pokenav.s +extern void sub_81D3640(u8 arg0, void* statStoreLocation1, void* statStoreLocation2, u8 arg3, u8 arg4, u8 arg5); // pokenav.s +extern void sub_81D3784(u8 arg0, void* statStoreLocation1, u8 arg2, u8 arg3, u8 arg4); // pokenav.s +extern u8* GetMonNickname(struct Pokemon* mon, u8* dst); // party_menu +extern u8 sub_81A5258(u8* arg0); // battle frontier 2 +extern void sub_81A5BF8(void); // battle frontier 2 +extern void sub_81A5D44(void); // battle frontier 2 +extern void sub_81B8E80(u8 bank, u8, u8); // party menu +extern bool8 sub_81B1250(void); // ? // BattleScripts extern const u8 BattleScript_MoveEnd[]; @@ -162,6 +177,26 @@ extern const u8 gUnknown_082DB87D[]; extern const u8 gUnknown_082DAE90[]; extern const u8 gUnknown_082DAE59[]; extern const u8 gUnknown_082DAEC7[]; +extern const u8 BattleScript_MoveEffectSleep[]; +extern const u8 BattleScript_MoveEffectPoison[]; +extern const u8 BattleScript_MoveEffectBurn[]; +extern const u8 BattleScript_MoveEffectFreeze[]; +extern const u8 BattleScript_MoveEffectParalysis[]; +extern const u8 BattleScript_MoveEffectToxic[]; +extern const u8 BattleScript_MoveEffectConfusion[]; +extern const u8 BattleScript_MoveEffectUproar[]; +extern const u8 BattleScript_MoveEffectPayDay[]; +extern const u8 BattleScript_MoveEffectWrap[]; +extern const u8 BattleScript_MoveEffectRecoil33[]; +extern const u8 BattleScript_DampStopsExplosion[]; +extern const u8 BattleScript_MistProtected[]; +extern const u8 BattleScript_AbilityNoStatLoss[]; +extern const u8 BattleScript_AbilityNoSpecificStatLoss[]; +extern const u8 BattleScript_ButItFailed[]; +extern const u8 gUnknown_082DADD8[]; +extern const u8 BattleScript_PrintPayDayMoneyString[]; +extern const u8 BattleScript_SturdyPreventsOHKO[]; +extern const u8 BattleScript_ObliviousPreventsAttraction[]; // strings extern const u8 gText_BattleYesNoChoice[]; @@ -187,6 +222,14 @@ u8 AttacksThisTurn(u8 bank, u16 move); // Note: returns 1 if it's a charging tur 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); void atk00_attackcanceler(void); void atk01_accuracycheck(void); @@ -296,23 +339,23 @@ void atk68_80246A0(void); void atk69_dmg_adjustment3(void); void atk6A_removeitem(void); void atk6B_atknameinbuff1(void); -void atk6C_lvlbox_display(void); -void atk6D_set_sentpokes_values(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_ability(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_8026A58(void); +void atk75_item_effect_on_opponent(void); void atk76_various(void); -void atk77_setprotect(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_8025508(void); +void atk7C_trymirrormove(void); void atk7D_set_rain(void); void atk7E_setreflect(void); void atk7F_setseeded(void); @@ -330,13 +373,13 @@ void atk8A_normalisebuffs(void); void atk8B_setbide(void); void atk8C_confuseifrepeatingattackends(void); void atk8D_setmultihit_counter(void); -void atk8E_prepare_multihit(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_gethalfcurrentenemyhp(void); +void atk94_damagetohalftargethp(void); void atk95_setsandstorm(void); void atk96_weatherdamage(void); void atk97_try_infatuation(void); @@ -345,7 +388,7 @@ void atk99_setmist(void); void atk9A_set_focusenergy(void); void atk9B_transformdataexecution(void); void atk9C_set_substitute(void); -void atk9D_copyattack(void); +void atk9D_mimicattackcopy(void); void atk9E_metronome(void); void atk9F_dmgtolevel(void); void atkA0_psywavedamageeffect(void); @@ -548,23 +591,23 @@ void (* const gBattleScriptingCommandsTable[])(void) = atk69_dmg_adjustment3, atk6A_removeitem, atk6B_atknameinbuff1, - atk6C_lvlbox_display, - atk6D_set_sentpokes_values, + atk6C_draw_lvlupbox, + atk6D_reset_sentpokes_value, atk6E_set_atk_to_player0, atk6F_set_visible, - atk70_record_ability, + atk70_record_last_used_ability, atk71_buffer_move_to_learn, atk72_jump_if_can_run_frombattle, atk73_hp_thresholds, atk74_hp_thresholds2, - atk75_8026A58, + atk75_item_effect_on_opponent, atk76_various, - atk77_setprotect, + atk77_set_protect_like, atk78_faintifabilitynotdamp, atk79_setatkhptozero, atk7A_jumpwhiletargetvalid, atk7B_healhalfHP_if_possible, - atk7C_8025508, + atk7C_trymirrormove, atk7D_set_rain, atk7E_setreflect, atk7F_setseeded, @@ -582,13 +625,13 @@ void (* const gBattleScriptingCommandsTable[])(void) = atk8B_setbide, atk8C_confuseifrepeatingattackends, atk8D_setmultihit_counter, - atk8E_prepare_multihit, + atk8E_init_multihit_string, atk8F_forcerandomswitch, atk90_conversion_type_change, atk91_givepaydaymoney, atk92_setlightscreen, atk93_ko_move, - atk94_gethalfcurrentenemyhp, + atk94_damagetohalftargethp, atk95_setsandstorm, atk96_weatherdamage, atk97_try_infatuation, @@ -597,7 +640,7 @@ void (* const gBattleScriptingCommandsTable[])(void) = atk9A_set_focusenergy, atk9B_transformdataexecution, atk9C_set_substitute, - atk9D_copyattack, + atk9D_mimicattackcopy, atk9E_metronome, atk9F_dmgtolevel, atkA0_psywavedamageeffect, @@ -781,7 +824,53 @@ const u32 gStatusFlagsForMoveEffects[] = 0x00000000 }; -extern const u8* const gMoveEffectBS_Ptrs[]; +const u8* const gMoveEffectBS_Ptrs[] = +{ + BattleScript_MoveEffectSleep, // 0 + BattleScript_MoveEffectSleep, // MOVE_EFFECT_SLEEP + BattleScript_MoveEffectPoison, // MOVE_EFFECT_POISON + BattleScript_MoveEffectBurn, // MOVE_EFFECT_BURN + BattleScript_MoveEffectFreeze, // MOVE_EFFECT_FREEZE + BattleScript_MoveEffectParalysis, // MOVE_EFFECT_PARALYSIS + BattleScript_MoveEffectToxic, // MOVE_EFFECT_TOXIC + BattleScript_MoveEffectConfusion, // MOVE_EFFECT_CONFUSION + BattleScript_MoveEffectSleep, // MOVE_EFFECT_FLINCH + BattleScript_MoveEffectSleep, // MOVE_EFFECT_TRI_ATTACK + BattleScript_MoveEffectUproar, // MOVE_EFFECT_UPROAR + BattleScript_MoveEffectPayDay, // MOVE_EFFECT_PAYDAY + BattleScript_MoveEffectSleep, // MOVE_EFFECT_CHARGING + BattleScript_MoveEffectWrap, // MOVE_EFFECT_WRAP + BattleScript_MoveEffectRecoil33, // MOVE_EFFECT_RECOIL_25 + BattleScript_MoveEffectSleep, // MOVE_EFFECT_ATK_PLUS_1 + BattleScript_MoveEffectSleep, // MOVE_EFFECT_DEF_PLUS_1 + BattleScript_MoveEffectSleep, // MOVE_EFFECT_SPD_PLUS_1 + BattleScript_MoveEffectSleep, // MOVE_EFFECT_SP_ATK_PLUS_1 + BattleScript_MoveEffectSleep, // MOVE_EFFECT_SP_DEF_PLUS_1 + BattleScript_MoveEffectSleep, // MOVE_EFFECT_ACC_PLUS_1 + BattleScript_MoveEffectSleep, // MOVE_EFFECT_EVS_PLUS_1 + BattleScript_MoveEffectSleep, // MOVE_EFFECT_ATK_MINUS_1 + BattleScript_MoveEffectSleep, // MOVE_EFFECT_DEF_MINUS_1 + BattleScript_MoveEffectSleep, // MOVE_EFFECT_SPD_MINUS_1 + BattleScript_MoveEffectSleep, // MOVE_EFFECT_SP_ATK_MINUS_1 + BattleScript_MoveEffectSleep, // MOVE_EFFECT_SP_DEF_MINUS_1 + BattleScript_MoveEffectSleep, // MOVE_EFFECT_ACC_MINUS_1 + BattleScript_MoveEffectSleep, // MOVE_EFFECT_EVS_MINUS_1 + BattleScript_MoveEffectSleep, // MOVE_EFFECT_RECHARGE + BattleScript_MoveEffectSleep, // MOVE_EFFECT_RAGE + BattleScript_MoveEffectSleep, // MOVE_EFFECT_STEAL_ITEM + BattleScript_MoveEffectSleep, // MOVE_EFFECT_PREVENT_ESCAPE + BattleScript_MoveEffectSleep, // MOVE_EFFECT_NIGHTMARE + BattleScript_MoveEffectSleep, // MOVE_EFFECT_ALL_STATS_UP + BattleScript_MoveEffectSleep, // MOVE_EFFECT_RAPIDSPIN + BattleScript_MoveEffectSleep, // MOVE_EFFECT_REMOVE_PARALYSIS + BattleScript_MoveEffectSleep, // MOVE_EFFECT_ATK_DEF_DOWN + BattleScript_MoveEffectRecoil33, // MOVE_EFFECT_RECOIL_33_PARALYSIS +}; + +static const struct WindowTemplate sUnusedWinTemplate = {0, 1, 3, 7, 0xF, 0x1F, 0x3F}; + +extern const struct SpriteTemplate SpriteTemplate_MonIconOnLvlUpBox; +extern const u16 sProtectSuccessRates[]; void atk00_attackcanceler(void) { @@ -1110,7 +1199,7 @@ void atk03_ppreduce(void) && !((gDisableStructs[gBankAttacker].unk18_b) & gBitTable[gCurrMovePos])) { gActiveBank = gBankAttacker; - EmitSetAttributes(0, REQUEST_PPMOVE1_BATTLE + gCurrMovePos, 0, 1, &gBattleMons[gBankAttacker].pp[gCurrMovePos]); + EmitSetMonData(0, REQUEST_PPMOVE1_BATTLE + gCurrMovePos, 0, 1, &gBattleMons[gBankAttacker].pp[gCurrMovePos]); MarkBufferBankForExecution(gBankAttacker); } } @@ -1828,7 +1917,7 @@ void atk0C_datahpupdate(void) } } gHitMarker &= ~(HITMARKER_x100000); - EmitSetAttributes(0, REQUEST_HP_BATTLE, 0, 2, &gBattleMons[gActiveBank].hp); + EmitSetMonData(0, REQUEST_HP_BATTLE, 0, 2, &gBattleMons[gActiveBank].hp); MarkBufferBankForExecution(gActiveBank); } } @@ -2351,7 +2440,7 @@ void SetMoveEffect(bool8 primary, u8 certain) gBattlescriptCurrInstr = gMoveEffectBS_Ptrs[gBattleCommunication[MOVE_EFFECT_BYTE]]; gActiveBank = gEffectBank; - EmitSetAttributes(0, REQUEST_STATUS_BATTLE, 0, 4, &gBattleMons[gEffectBank].status1); + EmitSetMonData(0, REQUEST_STATUS_BATTLE, 0, 4, &gBattleMons[gEffectBank].status1); MarkBufferBankForExecution(gActiveBank); if (gHitMarker & HITMARKER_IGNORE_SAFEGUARD) @@ -2660,11 +2749,11 @@ void SetMoveEffect(bool8 primary, u8 certain) gBattleMons[gBankTarget].item = 0; gActiveBank = gBankAttacker; - EmitSetAttributes(0, REQUEST_HELDITEM_BATTLE, 0, 2, &gLastUsedItem); + EmitSetMonData(0, REQUEST_HELDITEM_BATTLE, 0, 2, &gLastUsedItem); MarkBufferBankForExecution(gBankAttacker); gActiveBank = gBankTarget; - EmitSetAttributes(0, REQUEST_HELDITEM_BATTLE, 0, 2, &gBattleMons[gBankTarget].item); + EmitSetMonData(0, REQUEST_HELDITEM_BATTLE, 0, 2, &gBattleMons[gBankTarget].item); MarkBufferBankForExecution(gBankTarget); BattleScriptPush(gBattlescriptCurrInstr + 1); @@ -2703,7 +2792,7 @@ void SetMoveEffect(bool8 primary, u8 certain) gBattleMons[gBankTarget].status1 &= ~(STATUS_PARALYSIS); gActiveBank = gBankTarget; - EmitSetAttributes(0, REQUEST_STATUS_BATTLE, 0, 4, &gBattleMons[gActiveBank].status1); + EmitSetMonData(0, REQUEST_STATUS_BATTLE, 0, 4, &gBattleMons[gActiveBank].status1); MarkBufferBankForExecution(gActiveBank); BattleScriptPush(gBattlescriptCurrInstr + 1); @@ -2910,7 +2999,7 @@ void atk19_faint_pokemon(void) BattleScriptPush(gBattlescriptCurrInstr); gBattlescriptCurrInstr = BattleScript_GrudgeTakesPp; gActiveBank = gBankAttacker; - EmitSetAttributes(0, moveIndex + REQUEST_PPMOVE1_BATTLE, 0, 1, &gBattleMons[gActiveBank].pp[moveIndex]); + EmitSetMonData(0, moveIndex + REQUEST_PPMOVE1_BATTLE, 0, 1, &gBattleMons[gActiveBank].pp[moveIndex]); MarkBufferBankForExecution(gActiveBank); PREPARE_MOVE_BUFFER(gBattleTextBuff1, gBattleMons[gBankAttacker].moves[moveIndex]) @@ -2943,7 +3032,7 @@ void atk1B_faint_effects_clear(void) if (!(gBattleTypeFlags & BATTLE_TYPE_ARENA) || gBattleMons[gActiveBank].hp == 0) { gBattleMons[gActiveBank].status1 = 0; - EmitSetAttributes(0, REQUEST_STATUS_BATTLE, 0, 0x4, &gBattleMons[gActiveBank].status1); + EmitSetMonData(0, REQUEST_STATUS_BATTLE, 0, 0x4, &gBattleMons[gActiveBank].status1); MarkBufferBankForExecution(gActiveBank); } @@ -4672,7 +4761,7 @@ void atk49_moveend(void) { gBattleMons[gBankTarget].status1 &= ~(STATUS_FREEZE); gActiveBank = gBankTarget; - EmitSetAttributes(0, REQUEST_STATUS_BATTLE, 0, 4, &gBattleMons[gBankTarget].status1); + EmitSetMonData(0, REQUEST_STATUS_BATTLE, 0, 4, &gBattleMons[gBankTarget].status1); MarkBufferBankForExecution(gActiveBank); BattleScriptPushCursor(); gBattlescriptCurrInstr = BattleScript_DefrostedViaFireMove; @@ -4871,7 +4960,7 @@ void atk49_moveend(void) && !gProtectStructs[gBankAttacker].chargingTurn && gBattleMoves[gCurrentMove].target == MOVE_TARGET_BOTH && !(gHitMarker & HITMARKER_NO_ATTACKSTRING)) { - u8 bank = GetBankByPlayerAI(GetBankIdentity(gBankTarget) ^ 2); + u8 bank = GetBankByIdentity(GetBankIdentity(gBankTarget) ^ BIT_MON); if (gBattleMons[bank].hp != 0) { gBankTarget = bank; @@ -5019,7 +5108,7 @@ void atk4C_copy_poke_data(void) gBattlePartyID[gActiveBank] = *(gBattleStruct->field_5C + gActiveBank); - EmitGetAttributes(0, 0, gBitTable[gBattlePartyID[gActiveBank]]); + EmitGetMonData(0, 0, gBitTable[gBattlePartyID[gActiveBank]]); MarkBufferBankForExecution(gActiveBank); gBattlescriptCurrInstr += 2; @@ -5225,10 +5314,10 @@ void atk4F_jump_if_cannot_switch(void) { if (GetBankSide(gActiveBank) == SIDE_OPPONENT) { - r7 = GetBankByPlayerAI(1); + r7 = GetBankByIdentity(1); if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE) - compareVar = GetBankByPlayerAI(3); + compareVar = GetBankByIdentity(3); else compareVar = r7; @@ -5236,10 +5325,10 @@ void atk4F_jump_if_cannot_switch(void) } else { - r7 = GetBankByPlayerAI(0); + r7 = GetBankByIdentity(0); if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE) - compareVar = GetBankByPlayerAI(2); + compareVar = GetBankByIdentity(2); else compareVar = r7; @@ -5550,9 +5639,9 @@ void atk50_openpartyscreen(void) } else { - gActiveBank = GetBankByPlayerAI(GetBankIdentity(bank) ^ 1); + gActiveBank = GetBankByIdentity(GetBankIdentity(bank) ^ BIT_SIDE); if (gAbsentBankFlags & gBitTable[gActiveBank]) - gActiveBank ^= 2; + gActiveBank ^= BIT_MON; EmitLinkStandbyMsg(0, 2, 0); MarkBufferBankForExecution(gActiveBank); @@ -5712,7 +5801,7 @@ void atk52_switch_in_effects(void) void atk53_trainer_slide(void) { - gActiveBank = GetBankByPlayerAI(gBattlescriptCurrInstr[1]); + gActiveBank = GetBankByIdentity(gBattlescriptCurrInstr[1]); EmitTrainerSlide(0); MarkBufferBankForExecution(gActiveBank); @@ -5748,7 +5837,7 @@ void atk56_fainting_cry(void) void atk57(void) { - gActiveBank = GetBankByPlayerAI(0); + gActiveBank = GetBankByIdentity(0); Emit_x37(0, gBattleOutcome); MarkBufferBankForExecution(gActiveBank); @@ -5783,7 +5872,7 @@ void atk59_learnmove_inbattle(void) } else { - gActiveBank = GetBankByPlayerAI(0); + gActiveBank = GetBankByIdentity(0); if (gBattlePartyID[gActiveBank] == gBattleStruct->expGetterId && !(gBattleMons[gActiveBank].status2 & STATUS2_TRANSFORMED)) @@ -5792,7 +5881,7 @@ void atk59_learnmove_inbattle(void) } if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE) { - gActiveBank = GetBankByPlayerAI(2); + gActiveBank = GetBankByIdentity(2); if (gBattlePartyID[gActiveBank] == gBattleStruct->expGetterId && !(gBattleMons[gActiveBank].status2 & STATUS2_TRANSFORMED)) { @@ -6067,7 +6156,7 @@ void atk5E_8025A70(void) switch (gBattleCommunication[0]) { case 0: - EmitGetAttributes(0, REQUEST_ALL_BATTLE, 0); + EmitGetMonData(0, REQUEST_ALL_BATTLE, 0); MarkBufferBankForExecution(gActiveBank); gBattleCommunication[0]++; break; @@ -6317,3 +6406,2571 @@ void atk69_dmg_adjustment3(void) // The same as 0x7, except there's no random da END: gBattlescriptCurrInstr++; } + +void atk6A_removeitem(void) +{ + u16* usedHeldItem; + + gActiveBank = GetBattleBank(BSScriptRead8(gBattlescriptCurrInstr + 1)); + + GET_USED_ITEM_PTR_VIA_MEME_ACCESS(gActiveBank, usedHeldItem) + *usedHeldItem = gBattleMons[gActiveBank].item; + gBattleMons[gActiveBank].item = 0; + + EmitSetMonData(0, REQUEST_HELDITEM_BATTLE, 0, 2, &gBattleMons[gActiveBank].item); + MarkBufferBankForExecution(gActiveBank); + + gBattlescriptCurrInstr += 2; +} + +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) +{ + if (gBattleScripting.atk6C_state == 0) + { + if (IsMonGettingExpSentOut()) + gBattleScripting.atk6C_state = 3; + else + gBattleScripting.atk6C_state = 1; + } + + switch (gBattleScripting.atk6C_state) + { + case 1: + gBattle_BG2_Y = 0x60; + SetBgAttribute(2, BG_CTRL_ATTR_MOSAIC, 0); + ShowBg(2); + sub_804F17C(); + gBattleScripting.atk6C_state = 2; + break; + case 2: + if (!sub_804F1CC()) + gBattleScripting.atk6C_state = 3; + break; + case 3: + gBattle_BG1_X = 0; + gBattle_BG1_Y = 0x100; + SetBgAttribute(0, BG_CTRL_ATTR_MOSAIC, 1); + SetBgAttribute(1, BG_CTRL_ATTR_MOSAIC, 0); + ShowBg(0); + ShowBg(1); + sub_8056A3C(0x12, 7, 0x1D, 0x13, 0x80); + gBattleScripting.atk6C_state = 4; + break; + case 4: + sub_804F100(); + PutWindowTilemap(13); + CopyWindowToVram(13, 3); + gBattleScripting.atk6C_state++; + break; + case 5: + case 7: + if (!IsDma3ManagerBusyWithBgCopy()) + { + gBattle_BG1_Y = 0; + gBattleScripting.atk6C_state++; + } + break; + case 6: + if (gMain.newKeys != 0) + { + PlaySE(SE_SELECT); + sub_804F144(); + CopyWindowToVram(13, 2); + gBattleScripting.atk6C_state++; + } + break; + case 8: + if (gMain.newKeys != 0) + { + PlaySE(SE_SELECT); + sub_8056A3C(0x12, 7, 0x1D, 0x13, 0x81); + gBattleScripting.atk6C_state++; + } + break; + case 9: + if (!sub_804F344()) + { + ClearWindowTilemap(14); + CopyWindowToVram(14, 1); + + ClearWindowTilemap(13); + CopyWindowToVram(13, 1); + + SetBgAttribute(2, BG_CTRL_ATTR_MOSAIC, 2); + ShowBg(2); + + gBattleScripting.atk6C_state = 10; + } + break; + case 10: + if (!IsDma3ManagerBusyWithBgCopy()) + { + SetBgAttribute(0, BG_CTRL_ATTR_MOSAIC, 0); + SetBgAttribute(1, BG_CTRL_ATTR_MOSAIC, 1); + ShowBg(0); + ShowBg(1); + gBattlescriptCurrInstr++; + } + break; + } +} + +void sub_804F100(void) +{ + struct StatsArray currentStats; + + sub_81D388C(&gPlayerParty[gBattleStruct->expGetterId], ¤tStats); + sub_81D3640(0xD, gBattleResources->statsBeforeLvlUp, ¤tStats, 0xE, 0xD, 0xF); +} + +void sub_804F144(void) +{ + struct StatsArray currentStats; + + sub_81D388C(&gPlayerParty[gBattleStruct->expGetterId], ¤tStats); + sub_81D3784(0xD, ¤tStats, 0xE, 0xD, 0xF); +} + +extern const u16 gUnknown_0831C2C8[]; +extern const u8 gUnknown_0831C2E8[]; + +void sub_804F17C(void) +{ + gBattle_BG2_Y = 0; + gBattle_BG2_X = 0x1A0; + + LoadPalette(gUnknown_0831C2C8, 0x60, 0x20); + CopyToWindowPixelBuffer(14, gUnknown_0831C2E8, 0, 0); + PutWindowTilemap(14); + CopyWindowToVram(14, 3); + + PutMonIconOnLvlUpBox(); +} + +bool8 sub_804F1CC(void) +{ + if (IsDma3ManagerBusyWithBgCopy()) + return TRUE; + + if (gBattle_BG2_X == 0x200) + return FALSE; + + if (gBattle_BG2_X == 0x1A0) + PutLevelAndGenderOnLvlUpBox(); + + gBattle_BG2_X += 8; + if (gBattle_BG2_X >= 0x200) + gBattle_BG2_X = 0x200; + + return (gBattle_BG2_X != 0x200); +} + +void PutLevelAndGenderOnLvlUpBox(void) +{ + u16 monLevel; + u8 monGender; + struct TextSubPrinter subPrinter; + u8 *txtPtr; + u32 var; + + monLevel = GetMonData(&gPlayerParty[gBattleStruct->expGetterId], MON_DATA_LEVEL); + monGender = GetMonGender(&gPlayerParty[gBattleStruct->expGetterId]); + GetMonNickname(&gPlayerParty[gBattleStruct->expGetterId], gStringVar4); + + subPrinter.current_text_offset = gStringVar4; + subPrinter.windowId = 14; + subPrinter.fontId = 0; + subPrinter.x = 32; + subPrinter.y = 0; + subPrinter.currentX = 32; + subPrinter.currentY = 0; + subPrinter.letterSpacing = 0; + subPrinter.lineSpacing = 0; + subPrinter.fontColor_l = TEXT_COLOR_TRANSPARENT; + subPrinter.fontColor_h = TEXT_COLOR_WHITE; + subPrinter.bgColor = TEXT_COLOR_TRANSPARENT; + subPrinter.shadowColor = TEXT_COLOR_DARK_GREY; + + AddTextPrinter(&subPrinter, 0xFF, NULL); + + txtPtr = gStringVar4; + gStringVar4[0] = CHAR_SPECIAL_F9; + txtPtr++; + txtPtr[0] = 5; + txtPtr++; + + var = (u32)(txtPtr); + txtPtr = ConvertIntToDecimalStringN(txtPtr, monLevel, STR_CONV_MODE_LEFT_ALIGN, 3); + var = (u32)(txtPtr) - var; + txtPtr = StringFill(txtPtr, 0x77, 4 - var); + + if (monGender != MON_GENDERLESS) + { + if (monGender == MON_MALE) + { + txtPtr = WriteColorChangeControlCode(txtPtr, 0, 0xC); + txtPtr = WriteColorChangeControlCode(txtPtr, 1, 0xD); + *(txtPtr++) = CHAR_MALE; + } + else + { + txtPtr = WriteColorChangeControlCode(txtPtr, 0, 0xE); + txtPtr = WriteColorChangeControlCode(txtPtr, 1, 0xF); + *(txtPtr++) = CHAR_FEMALE; + } + *(txtPtr++) = EOS; + } + + subPrinter.y = 10; + subPrinter.currentY = 10; + AddTextPrinter(&subPrinter, 0xFF, NULL); + + CopyWindowToVram(14, 2); +} + +bool8 sub_804F344(void) +{ + if (gBattle_BG2_X == 0x1A0) + return FALSE; + + if (gBattle_BG2_X - 16 < 0x1A0) + gBattle_BG2_X = 0x1A0; + else + gBattle_BG2_X -= 16; + + return (gBattle_BG2_X != 0x1A0); +} + +#define MON_ICON_LVLUP_BOX_TAG 0xD75A + +#define sDestroy data0 +#define sSavedLvlUpBoxXPosition data1 + +void PutMonIconOnLvlUpBox(void) +{ + u8 spriteId; + const u16* iconPal; + struct SpriteSheet iconSheet; + struct SpritePalette iconPalSheet; + + u16 species = GetMonData(&gPlayerParty[gBattleStruct->expGetterId], MON_DATA_SPECIES); + u32 personality = GetMonData(&gPlayerParty[gBattleStruct->expGetterId], MON_DATA_PERSONALITY); + + const u8* iconPtr = GetMonIconPtr(species, personality, 1); + iconSheet.data = iconPtr; + iconSheet.size = 0x200; + iconSheet.tag = MON_ICON_LVLUP_BOX_TAG; + + iconPal = GetValidMonIconPalettePtr(species); + iconPalSheet.data = iconPal; + iconPalSheet.tag = MON_ICON_LVLUP_BOX_TAG; + + LoadSpriteSheet(&iconSheet); + LoadSpritePalette(&iconPalSheet); + + spriteId = CreateSprite(&SpriteTemplate_MonIconOnLvlUpBox, 256, 10, 0); + gSprites[spriteId].sDestroy = FALSE; + gSprites[spriteId].sSavedLvlUpBoxXPosition = gBattle_BG2_X; +} + +void SpriteCB_MonIconOnLvlUpBox(struct Sprite* sprite) +{ + sprite->pos2.x = sprite->sSavedLvlUpBoxXPosition - gBattle_BG2_X; + + if (sprite->pos2.x != 0) + { + sprite->sDestroy = TRUE; + } + else if (sprite->sDestroy) + { + DestroySprite(sprite); + FreeSpriteTilesByTag(MON_ICON_LVLUP_BOX_TAG); + FreeSpritePaletteByTag(MON_ICON_LVLUP_BOX_TAG); + } +} + +#undef sDestroy +#undef sSavedLvlUpBoxXPosition + +bool32 IsMonGettingExpSentOut(void) +{ + if (gBattlePartyID[0] == gBattleStruct->expGetterId) + return TRUE; + if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE && gBattlePartyID[2] == gBattleStruct->expGetterId) + return TRUE; + + return FALSE; +} + +void atk6D_reset_sentpokes_value(void) +{ + ResetSentPokesToOpponentValue(); + gBattlescriptCurrInstr++; +} + +void atk6E_set_atk_to_player0(void) +{ + gBankAttacker = GetBankByIdentity(0); + gBattlescriptCurrInstr++; +} + +void atk6F_set_visible(void) +{ + gActiveBank = GetBattleBank(BSScriptRead8(gBattlescriptCurrInstr + 1)); + EmitSpriteInvisibility(0, FALSE); + MarkBufferBankForExecution(gActiveBank); + + gBattlescriptCurrInstr += 2; +} + +void atk70_record_last_used_ability(void) +{ + gActiveBank = GetBattleBank(BSScriptRead8(gBattlescriptCurrInstr + 1)); + RecordAbilityBattle(gActiveBank, gLastUsedAbility); + gBattlescriptCurrInstr += 1; // UB: Should be + 2, one byte for command and one byte for bank argument. +} + +void BufferMoveToLearnIntoBattleTextBuff2(void) +{ + PREPARE_MOVE_BUFFER(gBattleTextBuff2, gMoveToLearn); +} + +void atk71_buffer_move_to_learn(void) +{ + BufferMoveToLearnIntoBattleTextBuff2(); + gBattlescriptCurrInstr++; +} + +void atk72_jump_if_can_run_frombattle(void) +{ + if (CanRunFromBattle(gBank1)) + gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); + else + gBattlescriptCurrInstr += 5; +} + +void atk73_hp_thresholds(void) +{ + u8 opposingBank; + s32 result; + + if (!(gBattleTypeFlags & BATTLE_TYPE_DOUBLE)) + { + gActiveBank = GetBattleBank(BSScriptRead8(gBattlescriptCurrInstr + 1)); + opposingBank = gActiveBank ^ BIT_SIDE; + + result = gBattleMons[opposingBank].hp * 100 / gBattleMons[opposingBank].maxHP; + if (result == 0) + result = 1; + + if (result > 69 || !gBattleMons[opposingBank].hp) + gBattleStruct->hpScale = 0; + else if (result > 39) + gBattleStruct->hpScale = 1; + else if (result > 9) + gBattleStruct->hpScale = 2; + else + gBattleStruct->hpScale = 3; + } + + gBattlescriptCurrInstr += 2; +} + +void atk74_hp_thresholds2(void) +{ + u8 opposingBank; + s32 result; + u8 hpSwitchout; + + if (!(gBattleTypeFlags & BATTLE_TYPE_DOUBLE)) + { + gActiveBank = GetBattleBank(BSScriptRead8(gBattlescriptCurrInstr + 1)); + opposingBank = gActiveBank ^ BIT_SIDE; + hpSwitchout = *(gBattleStruct->hpOnSwitchout + GetBankSide(opposingBank)); + result = (hpSwitchout - gBattleMons[opposingBank].hp) * 100 / hpSwitchout; + + if (gBattleMons[opposingBank].hp >= hpSwitchout) + gBattleStruct->hpScale = 0; + else if (result <= 29) + gBattleStruct->hpScale = 1; + else if (result <= 69) + gBattleStruct->hpScale = 2; + else + gBattleStruct->hpScale = 3; + } + + gBattlescriptCurrInstr += 2; +} + +void atk75_item_effect_on_opponent(void) +{ + gBankInMenu = gBankAttacker; + ExecuteTableBasedItemEffect(&gEnemyParty[gBattlePartyID[gBankAttacker]], gLastUsedItem, gBattlePartyID[gBankAttacker], 0, 1); + + gBattlescriptCurrInstr += 1; +} + +extern const u8 gUnknown_0831C4F8[]; +extern const u8* const gRefereeStringsTable[]; + +void atk76_various(void) +{ + u8 side; + s32 i; + + gActiveBank = GetBattleBank(gBattlescriptCurrInstr[1]); + + switch (gBattlescriptCurrInstr[2]) + { + case VARIOUS_CANCEL_MULTI_TURN_MOVES: + CancelMultiTurnMoves(gActiveBank); + break; + case VARIOUS_SET_MAGIC_COAT_TARGET: + gBankAttacker = gBankTarget; + side = GetBankSide(gBankAttacker) ^ 1; + if (gSideTimers[side].followmeTimer != 0 && gBattleMons[gSideTimers[side].followmeTarget].hp != 0) + gBankTarget = gSideTimers[side].followmeTarget; + else + gBankTarget = gActiveBank; + break; + case 2: + gBattleCommunication[0] = IsRunningFromBattleImpossible(); + break; + case VARIOUS_GET_MOVE_TARGET: + gBankTarget = GetMoveTarget(gCurrentMove, 0); + break; + case 4: + if (gHitMarker & HITMARKER_FAINTED(gActiveBank)) + gBattleCommunication[0] = 1; + else + gBattleCommunication[0] = 0; + break; + case VARIOUS_RESET_INTIMIDATE_TRACE_BITS: + gSpecialStatuses[gActiveBank].intimidatedPoke = 0; + gSpecialStatuses[gActiveBank].traced = 0; + break; + case VARIOUS_UPDATE_CHOICE_MOVE_ON_LVL_UP: + if (gBattlePartyID[0] == gBattleStruct->expGetterId || gBattlePartyID[2] == gBattleStruct->expGetterId) + { + u16 *choicedMove; + + if (gBattlePartyID[0] == gBattleStruct->expGetterId) + gActiveBank = 0; + else + gActiveBank = 2; + + choicedMove = &gBattleStruct->choicedMove[gActiveBank]; + + for (i = 0; i < 4; i++) + { + if (gBattleMons[gActiveBank].moves[i] == *choicedMove) + break; + } + if (i == 4) + *choicedMove = 0; + } + break; + case 7: + if (!(gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_DOUBLE)) + && gBattleTypeFlags & BATTLE_TYPE_TRAINER + && gBattleMons[0].hp != 0 + && gBattleMons[1].hp != 0) + { + gHitMarker &= ~(HITMARKER_x400000); + } + break; + case 8: + gBattleCommunication[0] = 0; + gBattleScripting.bank = gActiveBank = gBattleCommunication[1]; + if (!(gBattleStruct->field_92 & gBitTable[gActiveBank]) + && gBattleMons[gActiveBank].maxHP / 2 >= gBattleMons[gActiveBank].hp + && gBattleMons[gActiveBank].hp != 0 + && !(gBattleMons[gActiveBank].status1 & STATUS_SLEEP)) + { + gBattleStruct->field_92 |= gBitTable[gActiveBank]; + gBattleCommunication[0] = 1; + gBattleCommunication[MULTISTRING_CHOOSER] = gUnknown_0831C4F8[GetNatureFromPersonality(gBattleMons[gActiveBank].personality)]; + } + break; + case 9: + i = sub_81A5258(gBattleCommunication); + if (i == 0) + return; + + gBattleCommunication[1] = i; + break; + case 10: + gBattleMons[1].hp = 0; + gHitMarker |= HITMARKER_FAINTED(1); + gBattleStruct->field_2A1 |= gBitTable[gBattlePartyID[1]]; + gDisableStructs[1].truantUnknownBit = 1; + break; + case 11: + gBattleMons[0].hp = 0; + gHitMarker |= HITMARKER_FAINTED(0); + gHitMarker |= HITMARKER_x400000; + gBattleStruct->field_2A0 |= gBitTable[gBattlePartyID[0]]; + gDisableStructs[0].truantUnknownBit = 1; + break; + case 12: + gBattleMons[0].hp = 0; + gBattleMons[1].hp = 0; + gHitMarker |= HITMARKER_FAINTED(0); + gHitMarker |= HITMARKER_FAINTED(1); + gHitMarker |= HITMARKER_x400000; + gBattleStruct->field_2A0 |= gBitTable[gBattlePartyID[0]]; + gBattleStruct->field_2A1 |= gBitTable[gBattlePartyID[1]]; + gDisableStructs[0].truantUnknownBit = 1; + gDisableStructs[1].truantUnknownBit = 1; + break; + case 13: + EmitCmd13(0); + MarkBufferBankForExecution(gActiveBank); + break; + case 14: + sub_81A5BF8(); + break; + case 15: + sub_81A5D44(); + break; + case 16: + BattleStringExpandPlaceholdersToDisplayedString(gRefereeStringsTable[gBattlescriptCurrInstr[1]]); + sub_814F9EC(gDisplayedStringBattle, 0x16); + break; + case 17: + if (IsTextPrinterActive(0x16)) + return; + break; + case VARIOUS_WAIT_CRY: + if (!IsCryFinished()) + return; + break; + case VARIOUS_RETURN_OPPONENT_MON1: + gActiveBank = 1; + if (gBattleMons[gActiveBank].hp != 0) + { + EmitReturnPokeToBall(0, 0); + MarkBufferBankForExecution(gActiveBank); + } + break; + case VARIOUS_RETURN_OPPONENT_MON2: + if (gNoOfAllBanks > 3) + { + gActiveBank = 3; + if (gBattleMons[gActiveBank].hp != 0) + { + EmitReturnPokeToBall(0, 0); + MarkBufferBankForExecution(gActiveBank); + } + } + break; + case 21: + m4aMPlayVolumeControl(&gMPlay_BGM, 0xFFFF, 0x55); + break; + case 22: + m4aMPlayVolumeControl(&gMPlay_BGM, 0xFFFF, 0x100); + break; + case 23: + gBattleStruct->field_2A2 |= gBitTable[gActiveBank]; + break; + case 24: + if (sub_805725C(gActiveBank)) + return; + break; + case VARIOUS_SET_TELEPORT_OUTCOME: + if (GetBankSide(gActiveBank) == SIDE_PLAYER) + gBattleOutcome = BATTLE_PLAYER_TELEPORTED; + else + gBattleOutcome = BATTLE_OPPONENT_TELEPORTED; + break; + case VARIOUS_PLAY_TRAINER_DEFEATED_MUSIC: + EmitPlaySound(0, 0x19C, 1); + MarkBufferBankForExecution(gActiveBank); + break; + } + + gBattlescriptCurrInstr += 3; +} + +void atk77_set_protect_like(void) // protect and endure +{ + bool8 notLastTurn = TRUE; + u16 lastMove = gUnknown_02024260[gBankAttacker]; + + if (lastMove != MOVE_PROTECT && lastMove != MOVE_DETECT && lastMove != MOVE_ENDURE) + gDisableStructs[gBankAttacker].protectUses = 0; + + if (gCurrentMoveTurn == (gNoOfAllBanks - 1)) + notLastTurn = FALSE; + + if (sProtectSuccessRates[gDisableStructs[gBankAttacker].protectUses] >= Random() && notLastTurn) + { + if (gBattleMoves[gCurrentMove].effect == EFFECT_PROTECT) + { + gProtectStructs[gBankAttacker].protected = 1; + gBattleCommunication[MULTISTRING_CHOOSER] = 0; + } + if (gBattleMoves[gCurrentMove].effect == EFFECT_ENDURE) + { + gProtectStructs[gBankAttacker].endured = 1; + gBattleCommunication[MULTISTRING_CHOOSER] = 1; + } + gDisableStructs[gBankAttacker].protectUses++; + } + else + { + gDisableStructs[gBankAttacker].protectUses = 0; + gBattleCommunication[MULTISTRING_CHOOSER] = 2; + gBattleMoveFlags |= MOVESTATUS_MISSED; + } + + gBattlescriptCurrInstr++; +} + +void atk78_faintifabilitynotdamp(void) +{ + if (gBattleExecBuffer) + return; + + for (gBankTarget = 0; gBankTarget < gNoOfAllBanks; gBankTarget++) + { + if (gBattleMons[gBankTarget].ability == ABILITY_DAMP) + break; + } + + if (gBankTarget == gNoOfAllBanks) + { + gActiveBank = gBankAttacker; + gBattleMoveDamage = gBattleMons[gActiveBank].hp; + EmitHealthBarUpdate(0, 0x7FFF); + MarkBufferBankForExecution(gActiveBank); + gBattlescriptCurrInstr++; + + for (gBankTarget = 0; gBankTarget < gNoOfAllBanks; gBankTarget++) + { + if (gBankTarget == gBankAttacker) + continue; + if (!(gAbsentBankFlags & gBitTable[gBankTarget])) + break; + } + } + else + { + gLastUsedAbility = ABILITY_DAMP; + RecordAbilityBattle(gBankTarget, gBattleMons[gBankTarget].ability); + gBattlescriptCurrInstr = BattleScript_DampStopsExplosion; + } +} + +void atk79_setatkhptozero(void) +{ + if (gBattleExecBuffer) + return; + + gActiveBank = gBankAttacker; + gBattleMons[gActiveBank].hp = 0; + EmitSetMonData(0, REQUEST_HP_BATTLE, 0, 2, &gBattleMons[gActiveBank].hp); + MarkBufferBankForExecution(gActiveBank); + + gBattlescriptCurrInstr++; +} + +void atk7A_jumpwhiletargetvalid(void) // Used by intimidate to loop through all targets. +{ + const u8* jumpPtr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); + + if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE) + { + for (gBankTarget++; ; gBankTarget++) + { + if (gBankTarget == gBankAttacker) + continue; + if (!(gAbsentBankFlags & gBitTable[gBankTarget])) + break; + } + + if (gBankTarget >= gNoOfAllBanks) + gBattlescriptCurrInstr += 5; + else + gBattlescriptCurrInstr = jumpPtr; + } + else + gBattlescriptCurrInstr += 5; +} + +void atk7B_healhalfHP_if_possible(void) +{ + const u8* failPtr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); + + if (BSScriptRead8(gBattlescriptCurrInstr + 5) == BS_GET_ATTACKER) + gBankTarget = gBankAttacker; + + gBattleMoveDamage = gBattleMons[gBankTarget].maxHP / 2; + if (gBattleMoveDamage == 0) + gBattleMoveDamage = 1; + gBattleMoveDamage *= -1; + + if (gBattleMons[gBankTarget].hp == gBattleMons[gBankTarget].maxHP) + gBattlescriptCurrInstr = failPtr; + else + gBattlescriptCurrInstr += 6; +} + +void atk7C_trymirrormove(void) +{ + s32 validMovesCount; + s32 i; + u16 move; + u16 movesArray[4]; + + for (i = 0; i < 3; i++) + movesArray[i] = 0; + + for (validMovesCount = 0, i = 0; i < gNoOfAllBanks; i++) + { + if (i != gBankAttacker) + { + move = *(i * 2 + gBankAttacker * 8 + (u8*)(gBattleStruct->mirrorMoveArrays) + 0) + | (*(i * 2 + gBankAttacker * 8 + (u8*)(gBattleStruct->mirrorMoveArrays) + 1) << 8); + + if (move != 0 && move != 0xFFFF) + { + movesArray[validMovesCount] = move; + validMovesCount++; + } + } + } + + move = *(gBattleStruct->mirrorMoves + gBankAttacker * 2 + 0) + | (*(gBattleStruct->mirrorMoves + gBankAttacker * 2 + 1) << 8); + + if (move != 0 && move != 0xFFFF) + { + gHitMarker &= ~(HITMARKER_ATTACKSTRING_PRINTED); + gCurrentMove = move; + gBankTarget = GetMoveTarget(gCurrentMove, 0); + gBattlescriptCurrInstr = gBattleScriptsForMoveEffects[gBattleMoves[gCurrentMove].effect]; + } + else if (validMovesCount) + { + gHitMarker &= ~(HITMARKER_ATTACKSTRING_PRINTED); + i = Random() % validMovesCount; + gCurrentMove = movesArray[i]; + gBankTarget = GetMoveTarget(gCurrentMove, 0); + gBattlescriptCurrInstr = gBattleScriptsForMoveEffects[gBattleMoves[gCurrentMove].effect]; + } + else + { + gSpecialStatuses[gBankAttacker].flag20 = 1; + gBattlescriptCurrInstr++; + } +} + +void atk7D_set_rain(void) +{ + if (gBattleWeather & WEATHER_RAIN_ANY) + { + gBattleMoveFlags |= MOVESTATUS_MISSED; + gBattleCommunication[MULTISTRING_CHOOSER] = 2; + } + else + { + gBattleWeather = WEATHER_RAIN_TEMPORARY; + gBattleCommunication[MULTISTRING_CHOOSER] = 0; + gWishFutureKnock.weatherDuration = 5; + } + gBattlescriptCurrInstr++; +} + +void atk7E_setreflect(void) +{ + if (gSideAffecting[GET_BANK_SIDE(gBankAttacker)] & SIDE_STATUS_REFLECT) + { + gBattleMoveFlags |= MOVESTATUS_MISSED; + gBattleCommunication[MULTISTRING_CHOOSER] = 0; + } + else + { + gSideAffecting[GET_BANK_SIDE(gBankAttacker)] |= SIDE_STATUS_REFLECT; + gSideTimers[GET_BANK_SIDE(gBankAttacker)].reflectTimer = 5; + gSideTimers[GET_BANK_SIDE(gBankAttacker)].reflectBank = gBankAttacker; + + if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE && CountAliveMonsInBattle(BATTLE_ALIVE_ATK_SIDE) == 2) + gBattleCommunication[MULTISTRING_CHOOSER] = 2; + else + gBattleCommunication[MULTISTRING_CHOOSER] = 1; + } + gBattlescriptCurrInstr++; +} + +void atk7F_setseeded(void) +{ + if (gBattleMoveFlags & MOVESTATUS_NOEFFECT || gStatuses3[gBankTarget] & STATUS3_LEECHSEED) + { + gBattleMoveFlags |= MOVESTATUS_MISSED; + gBattleCommunication[MULTISTRING_CHOOSER] = 1; + } + else if (gBattleMons[gBankTarget].type1 == TYPE_GRASS || gBattleMons[gBankTarget].type2 == TYPE_GRASS) + { + gBattleMoveFlags |= MOVESTATUS_MISSED; + gBattleCommunication[MULTISTRING_CHOOSER] = 2; + } + else + { + gStatuses3[gBankTarget] |= gBankAttacker; + gStatuses3[gBankTarget] |= STATUS3_LEECHSEED; + gBattleCommunication[MULTISTRING_CHOOSER] = 0; + } + + gBattlescriptCurrInstr++; +} + +void atk80_manipulatedamage(void) +{ + switch (BSScriptRead8(gBattlescriptCurrInstr + 1)) + { + case ATK80_DMG_CHANGE_SIGN: + gBattleMoveDamage *= -1; + break; + case ATK80_DMG_HALF_BY_TWO_NOT_MORE_THAN_HALF_MAX_HP: + gBattleMoveDamage /= 2; + if (gBattleMoveDamage == 0) + gBattleMoveDamage = 1; + if ((gBattleMons[gBankTarget].maxHP / 2) < gBattleMoveDamage) + gBattleMoveDamage = gBattleMons[gBankTarget].maxHP / 2; + break; + case ATK80_DMG_DOUBLED: + gBattleMoveDamage *= 2; + break; + } + + gBattlescriptCurrInstr += 2; +} + +void atk81_setrest(void) +{ + const u8* failJump = BSScriptReadPtr(gBattlescriptCurrInstr + 1); + gActiveBank = gBankTarget = gBankAttacker; + gBattleMoveDamage = gBattleMons[gBankTarget].maxHP * (-1); + + if (gBattleMons[gBankTarget].hp == gBattleMons[gBankTarget].maxHP) + { + gBattlescriptCurrInstr = failJump; + } + else + { + if (gBattleMons[gBankTarget].status1 & ((u8)(~STATUS_SLEEP))) + gBattleCommunication[MULTISTRING_CHOOSER] = 1; + else + gBattleCommunication[MULTISTRING_CHOOSER] = 0; + + gBattleMons[gBankTarget].status1 = 3; + EmitSetMonData(0, REQUEST_STATUS_BATTLE, 0, 4, &gBattleMons[gActiveBank].status1); + MarkBufferBankForExecution(gActiveBank); + gBattlescriptCurrInstr += 5; + } +} + +void atk82_jumpifnotfirstturn(void) +{ + const u8* failJump = BSScriptReadPtr(gBattlescriptCurrInstr + 1); + + if (gDisableStructs[gBankAttacker].isFirstTurn) + gBattlescriptCurrInstr += 5; + else + gBattlescriptCurrInstr = failJump; +} + +void atk83_nop(void) +{ + gBattlescriptCurrInstr++; +} + +bool8 UproarWakeUpCheck(u8 bank) +{ + s32 i; + + for (i = 0; i < gNoOfAllBanks; i++) + { + if (!(gBattleMons[i].status2 & STATUS2_UPROAR) || gBattleMons[bank].ability == ABILITY_SOUNDPROOF) + continue; + + gBattleScripting.bank = i; + + if (gBankTarget == 0xFF) + gBankTarget = i; + else if (gBankTarget == i) + gBattleCommunication[MULTISTRING_CHOOSER] = 0; + else + gBattleCommunication[MULTISTRING_CHOOSER] = 1; + + break; + } + + if (i == gNoOfAllBanks) + return FALSE; + else + return TRUE; +} + +void atk84_jump_if_cant_sleep(void) +{ + const u8* jumpPtr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); + + if (UproarWakeUpCheck(gBankTarget)) + { + gBattlescriptCurrInstr = jumpPtr; + } + else if (gBattleMons[gBankTarget].ability == ABILITY_INSOMNIA + || gBattleMons[gBankTarget].ability == ABILITY_VITAL_SPIRIT) + { + gLastUsedAbility = gBattleMons[gBankTarget].ability; + gBattleCommunication[MULTISTRING_CHOOSER] = 2; + gBattlescriptCurrInstr = jumpPtr; + RecordAbilityBattle(gBankTarget, gLastUsedAbility); + } + else + { + gBattlescriptCurrInstr += 5; + } +} + +void atk85_stockpile(void) +{ + if (gDisableStructs[gBankAttacker].stockpileCounter == 3) + { + gBattleMoveFlags |= MOVESTATUS_MISSED; + gBattleCommunication[MULTISTRING_CHOOSER] = 1; + } + else + { + gDisableStructs[gBankAttacker].stockpileCounter++; + + PREPARE_BYTE_NUMBER_BUFFER(gBattleTextBuff1, 1, gDisableStructs[gBankAttacker].stockpileCounter) + + gBattleCommunication[MULTISTRING_CHOOSER] = 0; + } + gBattlescriptCurrInstr++; +} + +void atk86_stockpiletobasedamage(void) +{ + const u8* jumpPtr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); + if (gDisableStructs[gBankAttacker].stockpileCounter == 0) + { + gBattlescriptCurrInstr = jumpPtr; + } + else + { + if (gBattleCommunication[6] != 1) + { + gBattleMoveDamage = CalculateBaseDamage(&gBattleMons[gBankAttacker], &gBattleMons[gBankTarget], gCurrentMove, + gSideAffecting[GET_BANK_SIDE(gBankTarget)], 0, + 0, gBankAttacker, gBankTarget) + * gDisableStructs[gBankAttacker].stockpileCounter; + gBattleScripting.animTurn = gDisableStructs[gBankAttacker].stockpileCounter; + + if (gProtectStructs[gBankAttacker].helpingHand) + gBattleMoveDamage = gBattleMoveDamage * 15 / 10; + } + + gDisableStructs[gBankAttacker].stockpileCounter = 0; + gBattlescriptCurrInstr += 5; + } +} + +void atk87_stockpiletohpheal(void) +{ + const u8* jumpPtr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); + + if (gDisableStructs[gBankAttacker].stockpileCounter == 0) + { + gBattlescriptCurrInstr = jumpPtr; + gBattleCommunication[MULTISTRING_CHOOSER] = 0; + } + else if (gBattleMons[gBankAttacker].maxHP == gBattleMons[gBankAttacker].hp) + { + gDisableStructs[gBankAttacker].stockpileCounter = 0; + gBattlescriptCurrInstr = jumpPtr; + gBankTarget = gBankAttacker; + gBattleCommunication[MULTISTRING_CHOOSER] = 1; + } + else + { + gBattleMoveDamage = gBattleMons[gBankAttacker].maxHP / (1 << (3 - gDisableStructs[gBankAttacker].stockpileCounter)); + + if (gBattleMoveDamage == 0) + gBattleMoveDamage = 1; + gBattleMoveDamage *= -1; + + gBattleScripting.animTurn = gDisableStructs[gBankAttacker].stockpileCounter; + gDisableStructs[gBankAttacker].stockpileCounter = 0; + gBattlescriptCurrInstr += 5; + gBankTarget = gBankAttacker; + } +} + +void atk88_negativedamage(void) +{ + gBattleMoveDamage = -(gHpDealt / 2); + if (gBattleMoveDamage == 0) + gBattleMoveDamage = -1; + + gBattlescriptCurrInstr++; +} + +u8 ChangeStatBuffs(s8 statValue, u8 statId, u8 flags, const u8* BS_ptr) +{ + bool8 certain = 0; + bool8 notProtectAffected = FALSE; + u32 index; + + if (flags & MOVE_EFFECT_AFFECTS_USER) + gActiveBank = gBankAttacker; + else + gActiveBank = gBankTarget; + + flags &= ~(MOVE_EFFECT_AFFECTS_USER); + + if (flags & MOVE_EFFECT_CERTAIN) + certain++; + flags &= ~(MOVE_EFFECT_CERTAIN); + + if (flags & STAT_CHANGE_NOT_PROTECT_AFFECTED) + notProtectAffected++; + flags &= ~(STAT_CHANGE_NOT_PROTECT_AFFECTED); + + PREPARE_STAT_BUFFER(gBattleTextBuff1, statId) + + if ((statValue << 0x18) < 0) // stat decrease + { + if (gSideTimers[GET_BANK_SIDE(gActiveBank)].mistTimer + && !certain && gCurrentMove != MOVE_CURSE) + { + if (flags == STAT_CHANGE_BS_PTR) + { + if (gSpecialStatuses[gActiveBank].statLowered) + { + gBattlescriptCurrInstr = BS_ptr; + } + else + { + BattleScriptPush(BS_ptr); + gBattleScripting.bank = gActiveBank; + gBattlescriptCurrInstr = BattleScript_MistProtected; + gSpecialStatuses[gActiveBank].statLowered = 1; + } + } + return STAT_CHANGE_DIDNT_WORK; + } + else if (gCurrentMove != MOVE_CURSE + && notProtectAffected != TRUE && JumpIfMoveAffectedByProtect(0)) + { + gBattlescriptCurrInstr = BattleScript_ButItFailed; + return STAT_CHANGE_DIDNT_WORK; + } + else if ((gBattleMons[gActiveBank].ability == ABILITY_CLEAR_BODY + || gBattleMons[gActiveBank].ability == ABILITY_WHITE_SMOKE) + && !certain && gCurrentMove != MOVE_CURSE) + { + if (flags == STAT_CHANGE_BS_PTR) + { + if (gSpecialStatuses[gActiveBank].statLowered) + { + gBattlescriptCurrInstr = BS_ptr; + } + else + { + BattleScriptPush(BS_ptr); + gBattleScripting.bank = gActiveBank; + gBattlescriptCurrInstr = BattleScript_AbilityNoStatLoss; + gLastUsedAbility = gBattleMons[gActiveBank].ability; + RecordAbilityBattle(gActiveBank, gLastUsedAbility); + gSpecialStatuses[gActiveBank].statLowered = 1; + } + } + return STAT_CHANGE_DIDNT_WORK; + } + else if (gBattleMons[gActiveBank].ability == ABILITY_KEEN_EYE + && !certain && statId == STAT_STAGE_ACC) + { + if (flags == STAT_CHANGE_BS_PTR) + { + BattleScriptPush(BS_ptr); + gBattleScripting.bank = gActiveBank; + gBattlescriptCurrInstr = BattleScript_AbilityNoSpecificStatLoss; + gLastUsedAbility = gBattleMons[gActiveBank].ability; + RecordAbilityBattle(gActiveBank, gLastUsedAbility); + } + return STAT_CHANGE_DIDNT_WORK; + } + else if (gBattleMons[gActiveBank].ability == ABILITY_HYPER_CUTTER + && !certain && statId == STAT_STAGE_ATK) + { + if (flags == STAT_CHANGE_BS_PTR) + { + BattleScriptPush(BS_ptr); + gBattleScripting.bank = gActiveBank; + gBattlescriptCurrInstr = BattleScript_AbilityNoSpecificStatLoss; + gLastUsedAbility = gBattleMons[gActiveBank].ability; + RecordAbilityBattle(gActiveBank, gLastUsedAbility); + } + return STAT_CHANGE_DIDNT_WORK; + } + else if (gBattleMons[gActiveBank].ability == ABILITY_SHIELD_DUST && flags == 0) + { + return STAT_CHANGE_DIDNT_WORK; + } + else // try to decrease + { + statValue = -GET_STAT_BUFF_VALUE(statValue); + gBattleTextBuff2[0] = B_BUFF_PLACEHOLDER_BEGIN; + index = 1; + if (statValue == -2) + { + gBattleTextBuff2[1] = B_BUFF_STRING; + gBattleTextBuff2[2] = 0xD3; // harshly + gBattleTextBuff2[3] = 0xD3 >> 8; + index = 4; + } + gBattleTextBuff2[index] = B_BUFF_STRING; + index++; + gBattleTextBuff2[index] = 0xD4; // fell + index++; + gBattleTextBuff2[index] = 0xD4 >> 8; + index++; + gBattleTextBuff2[index] = B_BUFF_EOS; + + if (gBattleMons[gActiveBank].statStages[statId] == 0) + gBattleCommunication[MULTISTRING_CHOOSER] = 2; + else + gBattleCommunication[MULTISTRING_CHOOSER] = (gBankTarget == gActiveBank); + + } + } + else // stat increase + { + statValue = GET_STAT_BUFF_VALUE(statValue); + gBattleTextBuff2[0] = B_BUFF_PLACEHOLDER_BEGIN; + index = 1; + if (statValue == 2) + { + gBattleTextBuff2[1] = B_BUFF_STRING; + gBattleTextBuff2[2] = 0xD1; // sharply + gBattleTextBuff2[3] = 0xD1 >> 8; + index = 4; + } + gBattleTextBuff2[index] = B_BUFF_STRING; + index++; + gBattleTextBuff2[index] = 0xD2; // rose + index++; + gBattleTextBuff2[index] = 0xD2 >> 8; + index++; + gBattleTextBuff2[index] = B_BUFF_EOS; + + if (gBattleMons[gActiveBank].statStages[statId] == 0xC) + gBattleCommunication[MULTISTRING_CHOOSER] = 2; + else + gBattleCommunication[MULTISTRING_CHOOSER] = (gBankTarget == gActiveBank); + } + + gBattleMons[gActiveBank].statStages[statId] += statValue; + if (gBattleMons[gActiveBank].statStages[statId] < 0) + gBattleMons[gActiveBank].statStages[statId] = 0; + if (gBattleMons[gActiveBank].statStages[statId] > 0xC) + gBattleMons[gActiveBank].statStages[statId] = 0xC; + + if (gBattleCommunication[MULTISTRING_CHOOSER] == 2 && flags & STAT_CHANGE_BS_PTR) + gBattleMoveFlags |= MOVESTATUS_MISSED; + + if (gBattleCommunication[MULTISTRING_CHOOSER] == 2 && !(flags & STAT_CHANGE_BS_PTR)) + return STAT_CHANGE_DIDNT_WORK; + + return STAT_CHANGE_WORKED; +} + +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) + gBattlescriptCurrInstr += 6; +} + +void atk8A_normalisebuffs(void) // haze +{ + s32 i, j; + + for (i = 0; i < gNoOfAllBanks; i++) + { + for (j = 0; j < BATTLE_STATS_NO; j++) + gBattleMons[i].statStages[j] = 6; + } + + gBattlescriptCurrInstr++; +} + +void atk8B_setbide(void) +{ + gBattleMons[gBankAttacker].status2 |= STATUS2_MULTIPLETURNS; + gLockedMoves[gBankAttacker] = gCurrentMove; + gTakenDmg[gBankAttacker] = 0; + gBattleMons[gBankAttacker].status2 |= (STATUS2_BIDE - 0x100); // 2 turns + + gBattlescriptCurrInstr++; +} + +void atk8C_confuseifrepeatingattackends(void) +{ + if (!(gBattleMons[gBankAttacker].status2 & STATUS2_LOCK_CONFUSE)) + gBattleCommunication[MOVE_EFFECT_BYTE] = (MOVE_EFFECT_THRASH | MOVE_EFFECT_AFFECTS_USER); + + gBattlescriptCurrInstr++; +} + +void atk8D_setmultihit_counter(void) +{ + if (BSScriptRead8(gBattlescriptCurrInstr + 1)) + { + gMultiHitCounter = BSScriptRead8(gBattlescriptCurrInstr + 1); + } + else + { + gMultiHitCounter = Random() & 3; + if (gMultiHitCounter > 1) + gMultiHitCounter = (Random() & 3) + 2; + else + gMultiHitCounter += 2; + } + + gBattlescriptCurrInstr += 2; +} + +void atk8E_init_multihit_string(void) +{ + PREPARE_BYTE_NUMBER_BUFFER(gBattleScripting.multihitString, 1, 0) + + gBattlescriptCurrInstr++; +} + +bool8 sub_8051064(void) +{ + if (gBattleMons[gBankAttacker].level >= gBattleMons[gBankTarget].level) + { + *(gBattleStruct->field_58 + gBankTarget) = gBattlePartyID[gBankTarget]; + } + else + { + u16 random = Random() & 0xFF; + if ((u32)((random * (gBattleMons[gBankAttacker].level + gBattleMons[gBankTarget].level) >> 8) + 1) <= (gBattleMons[gBankTarget].level / 4)) + { + gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); + return FALSE; + } + *(gBattleStruct->field_58 + gBankTarget) = gBattlePartyID[gBankTarget]; + } + + gBattlescriptCurrInstr = gUnknown_082DADD8; + return TRUE; +} + +void atk8F_forcerandomswitch(void) +{ + s32 i; + s32 bank1PartyId = 0; + s32 bank2PartyId = 0; + + #ifdef NONMATCHING + s32 lastMonId = 0; // + 1 + #else + register s32 lastMonId asm("r8") = 0; // + 1 + #endif // NONMATCHING + + s32 firstMonId = 0; + s32 monsCount = 0; + struct Pokemon* party = NULL; + s32 validMons = 0; + s32 minNeeded = 0; + + if ((gBattleTypeFlags & BATTLE_TYPE_TRAINER)) + { + if (GetBankSide(gBankTarget) == SIDE_PLAYER) + party = gPlayerParty; + else + party = gEnemyParty; + + if ((gBattleTypeFlags & BATTLE_TYPE_BATTLE_TOWER && gBattleTypeFlags & BATTLE_TYPE_LINK) + || (gBattleTypeFlags & BATTLE_TYPE_BATTLE_TOWER && gBattleTypeFlags & BATTLE_TYPE_x2000000) + || (gBattleTypeFlags & BATTLE_TYPE_INGAME_PARTNER)) + { + if ((gBankTarget & BIT_MON) != 0) + { + firstMonId = 3; + lastMonId = 6; + } + else + { + firstMonId = 0; + lastMonId = 3; + } + monsCount = 3; + minNeeded = 1; + bank2PartyId = gBattlePartyID[gBankTarget]; + bank1PartyId = gBattlePartyID[gBankTarget ^ BIT_MON]; + } + else if ((gBattleTypeFlags & BATTLE_TYPE_MULTI && gBattleTypeFlags & BATTLE_TYPE_LINK) + || (gBattleTypeFlags & BATTLE_TYPE_MULTI && gBattleTypeFlags & BATTLE_TYPE_x2000000)) + { + if (sub_806D82C(sub_806D864(gBankTarget)) == 1) + { + firstMonId = 3; + lastMonId = 6; + } + else + { + firstMonId = 0; + lastMonId = 3; + } + monsCount = 3; + minNeeded = 1; + bank2PartyId = gBattlePartyID[gBankTarget]; + bank1PartyId = gBattlePartyID[gBankTarget ^ BIT_MON]; + } + else if (gBattleTypeFlags & BATTLE_TYPE_TWO_OPPONENTS) + { + if (GetBankSide(gBankTarget) == SIDE_PLAYER) + { + firstMonId = 0; + lastMonId = 6; + monsCount = 6; + minNeeded = 2; // since there are two opponents, it has to be a double battle + } + else + { + if ((gBankTarget & BIT_MON) != 0) + { + firstMonId = 3; + lastMonId = 6; + } + else + { + firstMonId = 0; + lastMonId = 3; + } + monsCount = 3; + minNeeded = 1; + } + bank2PartyId = gBattlePartyID[gBankTarget]; + bank1PartyId = gBattlePartyID[gBankTarget ^ BIT_MON]; + } + else if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE) + { + firstMonId = 0; + lastMonId = 6; + monsCount = 6; + minNeeded = 2; + bank2PartyId = gBattlePartyID[gBankTarget]; + bank1PartyId = gBattlePartyID[gBankTarget ^ BIT_MON]; + } + else + { + firstMonId = 0; + lastMonId = 6; + monsCount = 6; + minNeeded = 1; + bank2PartyId = gBattlePartyID[gBankTarget]; // there is only one pokemon out in single battles + bank1PartyId = gBattlePartyID[gBankTarget]; + } + + for (i = firstMonId; i < lastMonId; i++) + { + if (GetMonData(&party[i], MON_DATA_SPECIES) != SPECIES_NONE + && !GetMonData(&party[i], MON_DATA_IS_EGG) + && GetMonData(&party[i], MON_DATA_HP) != 0) + { + validMons++; + } + } + + if (validMons <= minNeeded) + { + gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); + } + else + { + if (sub_8051064()) + { + do + { + i = Random() % monsCount; + i += firstMonId; + } + while (i == bank2PartyId + || i == bank1PartyId + || GetMonData(&party[i], MON_DATA_SPECIES) == SPECIES_NONE + || GetMonData(&party[i], MON_DATA_IS_EGG) == TRUE + || GetMonData(&party[i], MON_DATA_HP) == 0); + } + *(gBattleStruct->field_5C + gBankTarget) = i; + + if (!sub_81B1250()) + sub_803BDA0(gBankTarget); + + if ((gBattleTypeFlags & BATTLE_TYPE_LINK && gBattleTypeFlags & BATTLE_TYPE_BATTLE_TOWER) + || (gBattleTypeFlags & BATTLE_TYPE_LINK && gBattleTypeFlags & BATTLE_TYPE_MULTI) + || (gBattleTypeFlags & BATTLE_TYPE_x2000000 && gBattleTypeFlags & BATTLE_TYPE_BATTLE_TOWER) + || (gBattleTypeFlags & BATTLE_TYPE_x2000000 && gBattleTypeFlags & BATTLE_TYPE_MULTI)) + { + sub_81B8E80(gBankTarget, i, 0); + sub_81B8E80(gBankTarget ^ BIT_MON, i, 1); + } + + if (gBattleTypeFlags & BATTLE_TYPE_INGAME_PARTNER) + sub_80571DC(gBankTarget, i); + } + } + else + { + sub_8051064(); + } +} + +void atk90_conversion_type_change(void) // randomly changes user's type to one of its moves' type +{ + u8 validMoves = 0; + u8 moveChecked; + u8 moveType; + + while (validMoves < 4) + { + if (gBattleMons[gBankAttacker].moves[validMoves] == 0) + break; + + validMoves++; + } + + for (moveChecked = 0; moveChecked < validMoves; moveChecked++) + { + moveType = gBattleMoves[gBattleMons[gBankAttacker].moves[moveChecked]].type; + + if (moveType == TYPE_MYSTERY) + { + if (gBattleMons[gBankAttacker].type1 == TYPE_GHOST || gBattleMons[gBankAttacker].type2 == TYPE_GHOST) + moveType = TYPE_GHOST; + else + moveType = TYPE_NORMAL; + } + if (moveType != gBattleMons[gBankAttacker].type1 + && moveType != gBattleMons[gBankAttacker].type2) + { + break; + } + } + + if (moveChecked == validMoves) + { + gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); + } + else + { + do + { + + while ((moveChecked = Random() & 3) >= validMoves); + + moveType = gBattleMoves[gBattleMons[gBankAttacker].moves[moveChecked]].type; + + if (moveType == TYPE_MYSTERY) + { + if (gBattleMons[gBankAttacker].type1 == TYPE_GHOST || gBattleMons[gBankAttacker].type2 == TYPE_GHOST) + moveType = TYPE_GHOST; + else + moveType = TYPE_NORMAL; + } + } + while (moveType == gBattleMons[gBankAttacker].type1 || moveType == gBattleMons[gBankAttacker].type2); + + gBattleMons[gBankAttacker].type1 = moveType; + gBattleMons[gBankAttacker].type2 = moveType; + + PREPARE_TYPE_BUFFER(gBattleTextBuff1, moveType) + + gBattlescriptCurrInstr += 5; + } +} + +void atk91_givepaydaymoney(void) +{ + if (!(gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_x2000000)) && gPaydayMoney != 0) + { + u32 bonusMoney = gPaydayMoney * gBattleStruct->moneyMultiplier; + AddMoney(&gSaveBlock1Ptr->money, bonusMoney); + + PREPARE_HWORD_NUMBER_BUFFER(gBattleTextBuff1, 5, bonusMoney) + + BattleScriptPush(gBattlescriptCurrInstr + 1); + gBattlescriptCurrInstr = BattleScript_PrintPayDayMoneyString; + } + else + { + gBattlescriptCurrInstr++; + } +} + +void atk92_setlightscreen(void) +{ + if (gSideAffecting[GET_BANK_SIDE(gBankAttacker)] & SIDE_STATUS_LIGHTSCREEN) + { + gBattleMoveFlags |= MOVESTATUS_MISSED; + gBattleCommunication[MULTISTRING_CHOOSER] = 0; + } + else + { + gSideAffecting[GET_BANK_SIDE(gBankAttacker)] |= SIDE_STATUS_LIGHTSCREEN; + gSideTimers[GET_BANK_SIDE(gBankAttacker)].lightscreenTimer = 5; + gSideTimers[GET_BANK_SIDE(gBankAttacker)].lightscreenBank = gBankAttacker; + + if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE && CountAliveMonsInBattle(BATTLE_ALIVE_ATK_SIDE) == 2) + gBattleCommunication[MULTISTRING_CHOOSER] = 4; + else + gBattleCommunication[MULTISTRING_CHOOSER] = 3; + } + + gBattlescriptCurrInstr++; +} + +void atk93_ko_move(void) +{ + u8 holdEffect, param; + + if (gBattleMons[gBankTarget].item == ITEM_ENIGMA_BERRY) + { + holdEffect = gEnigmaBerries[gBankTarget].holdEffect; + param = gEnigmaBerries[gBankTarget].holdEffectParam; + } + else + { + holdEffect = ItemId_GetHoldEffect(gBattleMons[gBankTarget].item); + param = ItemId_GetHoldEffectParam(gBattleMons[gBankTarget].item); + } + + gStringBank = gBankTarget; + + if (holdEffect == HOLD_EFFECT_FOCUS_BAND && (Random() % 100) < param) + { + RecordItemEffectBattle(gBankTarget, HOLD_EFFECT_FOCUS_BAND); + gSpecialStatuses[gBankTarget].focusBanded = 1; + } + + if (gBattleMons[gBankTarget].ability == ABILITY_STURDY) + { + gBattleMoveFlags |= MOVESTATUS_MISSED; + gLastUsedAbility = ABILITY_STURDY; + gBattlescriptCurrInstr = BattleScript_SturdyPreventsOHKO; + RecordAbilityBattle(gBankTarget, ABILITY_STURDY); + } + else + { + u16 chance; + if (!(gStatuses3[gBankTarget] & STATUS3_ALWAYS_HITS)) + { + chance = gBattleMoves[gCurrentMove].accuracy + (gBattleMons[gBankAttacker].level - gBattleMons[gBankTarget].level); + if (Random() % 100 + 1 < chance && gBattleMons[gBankAttacker].level >= gBattleMons[gBankTarget].level) + chance = TRUE; + else + chance = FALSE; + } + else if (gDisableStructs[gBankTarget].bankWithSureHit == gBankAttacker + && gBattleMons[gBankAttacker].level >= gBattleMons[gBankTarget].level) + { + chance = TRUE; + } + else + { + chance = gBattleMoves[gCurrentMove].accuracy + (gBattleMons[gBankAttacker].level - gBattleMons[gBankTarget].level); + if (Random() % 100 + 1 < chance && gBattleMons[gBankAttacker].level >= gBattleMons[gBankTarget].level) + chance = TRUE; + else + chance = FALSE; + } + if (chance) + { + if (gProtectStructs[gBankTarget].endured) + { + gBattleMoveDamage = gBattleMons[gBankTarget].hp - 1; + gBattleMoveFlags |= MOVESTATUS_ENDURED; + } + else if (gSpecialStatuses[gBankTarget].focusBanded) + { + gBattleMoveDamage = gBattleMons[gBankTarget].hp - 1; + gBattleMoveFlags |= MOVESTATUS_HUNGON; + gLastUsedItem = gBattleMons[gBankTarget].item; + } + else + { + gBattleMoveDamage = gBattleMons[gBankTarget].hp; + gBattleMoveFlags |= MOVESTATUS_ONEHITKO; + } + gBattlescriptCurrInstr += 5; + } + else + { + gBattleMoveFlags |= MOVESTATUS_MISSED; + if (gBattleMons[gBankAttacker].level >= gBattleMons[gBankTarget].level) + gBattleCommunication[MULTISTRING_CHOOSER] = 0; + else + gBattleCommunication[MULTISTRING_CHOOSER] = 1; + gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); + } + } +} + +void atk94_damagetohalftargethp(void) // super fang +{ + gBattleMoveDamage = gBattleMons[gBankTarget].hp / 2; + if (gBattleMoveDamage == 0) + gBattleMoveDamage = 1; + + gBattlescriptCurrInstr++; +} + +void atk95_setsandstorm(void) +{ + if (gBattleWeather & WEATHER_SANDSTORM_ANY) + { + gBattleMoveFlags |= MOVESTATUS_MISSED; + gBattleCommunication[MULTISTRING_CHOOSER] = 2; + } + else + { + gBattleWeather = WEATHER_SANDSTORM_TEMPORARY; + gBattleCommunication[MULTISTRING_CHOOSER] = 3; + gWishFutureKnock.weatherDuration = 5; + } + gBattlescriptCurrInstr++; +} + +void atk96_weatherdamage(void) +{ + if (WEATHER_HAS_EFFECT) + { + if (gBattleWeather & WEATHER_SANDSTORM_ANY) + { + if (gBattleMons[gBankAttacker].type1 != TYPE_ROCK + && gBattleMons[gBankAttacker].type1 != TYPE_STEEL + && gBattleMons[gBankAttacker].type1 != TYPE_GROUND + && gBattleMons[gBankAttacker].type2 != TYPE_ROCK + && gBattleMons[gBankAttacker].type2 != TYPE_STEEL + && gBattleMons[gBankAttacker].type2 != TYPE_GROUND + && gBattleMons[gBankAttacker].ability != ABILITY_SAND_VEIL + && !(gStatuses3[gBankAttacker] & STATUS3_UNDERGROUND) + && !(gStatuses3[gBankAttacker] & STATUS3_UNDERWATER)) + { + gBattleMoveDamage = gBattleMons[gBankAttacker].maxHP / 16; + if (gBattleMoveDamage == 0) + gBattleMoveDamage = 1; + } + else + { + gBattleMoveDamage = 0; + } + } + if (gBattleWeather & WEATHER_HAIL) + { + if (gBattleMons[gBankAttacker].type1 != TYPE_ICE + && gBattleMons[gBankAttacker].type2 != TYPE_ICE + && !(gStatuses3[gBankAttacker] & STATUS3_UNDERGROUND) + && !(gStatuses3[gBankAttacker] & STATUS3_UNDERWATER)) + { + gBattleMoveDamage = gBattleMons[gBankAttacker].maxHP / 16; + if (gBattleMoveDamage == 0) + gBattleMoveDamage = 1; + } + else + { + gBattleMoveDamage = 0; + } + } + } + else + { + gBattleMoveDamage = 0; + } + + if (gAbsentBankFlags & gBitTable[gBankAttacker]) + gBattleMoveDamage = 0; + + gBattlescriptCurrInstr++; +} + +void atk97_try_infatuation(void) +{ + struct Pokemon *monAttacker, *monTarget; + u16 speciesAttacker, speciesTarget; + u32 personalityAttacker, personalityTarget; + + if (GetBankSide(gBankAttacker) == SIDE_PLAYER) + monAttacker = &gPlayerParty[gBattlePartyID[gBankAttacker]]; + else + monAttacker = &gEnemyParty[gBattlePartyID[gBankAttacker]]; + + if (GetBankSide(gBankTarget) == SIDE_PLAYER) + monTarget = &gPlayerParty[gBattlePartyID[gBankTarget]]; + else + monTarget = &gEnemyParty[gBattlePartyID[gBankTarget]]; + + speciesAttacker = GetMonData(monAttacker, MON_DATA_SPECIES); + personalityAttacker = GetMonData(monAttacker, MON_DATA_PERSONALITY); + + speciesTarget = GetMonData(monTarget, MON_DATA_SPECIES); + personalityTarget = GetMonData(monTarget, MON_DATA_PERSONALITY); + + if (gBattleMons[gBankTarget].ability == ABILITY_OBLIVIOUS) + { + gBattlescriptCurrInstr = BattleScript_ObliviousPreventsAttraction; + gLastUsedAbility = ABILITY_OBLIVIOUS; + RecordAbilityBattle(gBankTarget, ABILITY_OBLIVIOUS); + } + else + { + if (GetGenderFromSpeciesAndPersonality(speciesAttacker, personalityAttacker) == GetGenderFromSpeciesAndPersonality(speciesTarget, personalityTarget) + || gBattleMons[gBankTarget].status2 & STATUS2_INFATUATION + || GetGenderFromSpeciesAndPersonality(speciesAttacker, personalityAttacker) == MON_GENDERLESS + || GetGenderFromSpeciesAndPersonality(speciesTarget, personalityTarget) == MON_GENDERLESS) + { + gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); + } + else + { + gBattleMons[gBankTarget].status2 |= STATUS2_INFATUATED_WITH(gBankAttacker); + gBattlescriptCurrInstr += 5; + } + } +} + +void atk98_status_icon_update(void) +{ + if (gBattleExecBuffer) + return; + + if (BSScriptRead8(gBattlescriptCurrInstr + 1) != BS_ATTACKER_WITH_PARTNER) + { + gActiveBank = GetBattleBank(BSScriptRead8(gBattlescriptCurrInstr + 1)); + EmitStatusIconUpdate(0, gBattleMons[gActiveBank].status1, gBattleMons[gActiveBank].status2); + MarkBufferBankForExecution(gActiveBank); + gBattlescriptCurrInstr += 2; + } + else + { + gActiveBank = gBankAttacker; + if (!(gAbsentBankFlags & gBitTable[gActiveBank])) + { + EmitStatusIconUpdate(0, gBattleMons[gActiveBank].status1, gBattleMons[gActiveBank].status2); + MarkBufferBankForExecution(gActiveBank); + } + if ((gBattleTypeFlags & BATTLE_TYPE_DOUBLE)) + { + gActiveBank = GetBankByIdentity(GetBankIdentity(gBankAttacker) ^ BIT_MON); + if (!(gAbsentBankFlags & gBitTable[gActiveBank])) + { + EmitStatusIconUpdate(0, gBattleMons[gActiveBank].status1, gBattleMons[gActiveBank].status2); + MarkBufferBankForExecution(gActiveBank); + } + } + gBattlescriptCurrInstr += 2; + } +} + +void atk99_setmist(void) +{ + if (gSideTimers[GET_BANK_SIDE(gBankAttacker)].mistTimer) + { + gBattleMoveFlags |= MOVESTATUS_FAILED; + gBattleCommunication[MULTISTRING_CHOOSER] = 1; + } + else + { + gSideTimers[GET_BANK_SIDE(gBankAttacker)].mistTimer = 5; + gSideTimers[GET_BANK_SIDE(gBankAttacker)].mistBank = gBankAttacker; + gSideAffecting[GET_BANK_SIDE(gBankAttacker)] |= SIDE_STATUS_MIST; + gBattleCommunication[MULTISTRING_CHOOSER] = 0; + } + gBattlescriptCurrInstr++; +} + +void atk9A_set_focusenergy(void) +{ + if (gBattleMons[gBankAttacker].status2 & STATUS2_FOCUS_ENERGY) + { + gBattleMoveFlags |= MOVESTATUS_FAILED; + gBattleCommunication[MULTISTRING_CHOOSER] = 1; + } + else + { + gBattleMons[gBankAttacker].status2 |= STATUS2_FOCUS_ENERGY; + gBattleCommunication[MULTISTRING_CHOOSER] = 0; + } + gBattlescriptCurrInstr++; +} + +void atk9B_transformdataexecution(void) +{ + gLastUsedMove = 0xFFFF; + gBattlescriptCurrInstr++; + if (gBattleMons[gBankTarget].status2 & STATUS2_TRANSFORMED + || gStatuses3[gBankTarget] & STATUS3_SEMI_INVULNERABLE) + { + gBattleMoveFlags |= MOVESTATUS_FAILED; + gBattleCommunication[MULTISTRING_CHOOSER] = 1; + } + else + { + s32 i; + u8 *battleMonAttacker, *battleMonTarget; + + gBattleMons[gBankAttacker].status2 |= STATUS2_TRANSFORMED; + gDisableStructs[gBankAttacker].disabledMove = 0; + gDisableStructs[gBankAttacker].disableTimer1 = 0; + gDisableStructs[gBankAttacker].unk0 = gBattleMons[gBankTarget].personality; + gDisableStructs[gBankAttacker].unk18_b = 0; + + PREPARE_SPECIES_BUFFER(gBattleTextBuff1, gBattleMons[gBankTarget].species) + + battleMonAttacker = (u8*)(&gBattleMons[gBankAttacker]); + battleMonTarget = (u8*)(&gBattleMons[gBankTarget]); + + for (i = 0; i < offsetof(struct BattlePokemon, pp); i++) + battleMonAttacker[i] = battleMonTarget[i]; + + for (i = 0; i < 4; i++) + { + if (gBattleMoves[gBattleMons[gBankAttacker].moves[i]].pp < 5) + gBattleMons[gBankAttacker].pp[i] = gBattleMoves[gBattleMons[gBankAttacker].moves[i]].pp; + else + gBattleMons[gBankAttacker].pp[i] = 5; + } + + gActiveBank = gBankAttacker; + EmitResetActionMoveSelection(0, RESET_MOVE_SELECTION); + MarkBufferBankForExecution(gActiveBank); + gBattleCommunication[MULTISTRING_CHOOSER] = 0; + } +} + +void atk9C_set_substitute(void) +{ + u32 hp = gBattleMons[gBankAttacker].maxHP / 4; + if (gBattleMons[gBankAttacker].maxHP / 4 == 0) + hp = 1; + + if (gBattleMons[gBankAttacker].hp <= hp) + { + gBattleMoveDamage = 0; + gBattleCommunication[MULTISTRING_CHOOSER] = 1; + } + else + { + gBattleMoveDamage = gBattleMons[gBankAttacker].maxHP / 4; // one bit value will only work for pokemon which max hp can go to 1020(which is more than possible in games) + if (gBattleMoveDamage == 0) + gBattleMoveDamage = 1; + + gBattleMons[gBankAttacker].status2 |= STATUS2_SUBSTITUTE; + gBattleMons[gBankAttacker].status2 &= ~(STATUS2_WRAPPED); + gDisableStructs[gBankAttacker].substituteHP = gBattleMoveDamage; + gBattleCommunication[MULTISTRING_CHOOSER] = 0; + gHitMarker |= HITMARKER_IGNORE_SUBSTITUTE; + } + + gBattlescriptCurrInstr++; +} + +extern const u16 gMovesForbiddenToCopy[]; +#define MIMIC_FORBIDDEN_END 0xFFFE +#define METRONOME_SLEEPTALK_FORBIDDEN_END 0xFFFF + +static bool8 IsMoveUncopyableByMimic(u16 move) +{ + s32 i; + for (i = 0; gMovesForbiddenToCopy[i] != MIMIC_FORBIDDEN_END + && gMovesForbiddenToCopy[i] != move; i++); + + return (gMovesForbiddenToCopy[i] != MIMIC_FORBIDDEN_END); +} + +void atk9D_mimicattackcopy(void) +{ + gLastUsedMove = 0xFFFF; + + if (IsMoveUncopyableByMimic(gLastUsedMovesByBanks[gBankTarget]) + || gBattleMons[gBankAttacker].status2 & STATUS2_TRANSFORMED + || gLastUsedMovesByBanks[gBankTarget] == 0 + || gLastUsedMovesByBanks[gBankTarget] == 0xFFFF) + { + gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); + } + else + { + s32 i; + + for (i = 0; i < 4; i++) + { + if (gBattleMons[gBankAttacker].moves[i] == gLastUsedMovesByBanks[gBankTarget]) + break; + } + + if (i == 4) + { + gBattleMons[gBankAttacker].moves[gCurrMovePos] = gLastUsedMovesByBanks[gBankTarget]; + if (gBattleMoves[gLastUsedMovesByBanks[gBankTarget]].pp < 5) + gBattleMons[gBankAttacker].pp[gCurrMovePos] = gBattleMoves[gLastUsedMovesByBanks[gBankTarget]].pp; + else + gBattleMons[gBankAttacker].pp[gCurrMovePos] = 5; + + + PREPARE_MOVE_BUFFER(gBattleTextBuff1, gLastUsedMovesByBanks[gBankTarget]) + + gDisableStructs[gBankAttacker].unk18_b |= gBitTable[gCurrMovePos]; + gBattlescriptCurrInstr += 5; + } + else + { + gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); + } + } +} + +#ifdef NONMATCHING +void atk9E_metronome(void) +{ + while (1) + { + const u16 *move; + s32 i, j; + + gCurrentMove = (Random() & 0x1FF) + 1; + if (gCurrentMove > LAST_MOVE_INDEX) + continue; + + for (i = 0; i < 4; i++); // ? + + for (move = gMovesForbiddenToCopy; ; move++) + { + if (*move == gCurrentMove) + break; + if (*move == METRONOME_SLEEPTALK_FORBIDDEN_END) + break; + } + + if (*move == METRONOME_SLEEPTALK_FORBIDDEN_END) + break; + } + + gHitMarker &= ~(HITMARKER_ATTACKSTRING_PRINTED); + gBattlescriptCurrInstr = gBattleScriptsForMoveEffects[gBattleMoves[gCurrentMove].effect]; + gBankTarget = GetMoveTarget(gCurrentMove, 0); +} + +#else +__attribute__((naked)) +void atk9E_metronome(void) +{ + asm( + "\n\ + .syntax unified\n\ + push {r4-r7,lr}\n\ + mov r7, r8\n\ + push {r7}\n\ + ldr r7, =gCurrentMove\n\ + movs r6, 0xB1\n\ + lsls r6, 1\n\ + ldr r5, =gMovesForbiddenToCopy\n\ + ldr r0, =gBattlescriptCurrInstr\n\ + mov r8, r0\n\ +_080524EE:\n\ + bl Random\n\ + ldr r2, =0x000001ff\n\ + adds r1, r2, 0\n\ + ands r0, r1\n\ + adds r0, 0x1\n\ + strh r0, [r7]\n\ + cmp r0, r6\n\ + bhi _080524EE\n\ + movs r0, 0x3\n\ +_08052502:\n\ + subs r0, 0x1\n\ + cmp r0, 0\n\ + bge _08052502\n\ + ldr r4, =gCurrentMove\n\ + ldrh r2, [r4]\n\ + ldr r3, =0x0000ffff\n\ + subs r0, r5, 0x2\n\ +_08052510:\n\ + adds r0, 0x2\n\ + ldrh r1, [r0]\n\ + cmp r1, r2\n\ + beq _0805251C\n\ + cmp r1, r3\n\ + bne _08052510\n\ +_0805251C:\n\ + ldr r0, =0x0000ffff\n\ + cmp r1, r0\n\ + bne _080524EE\n\ + ldr r2, =gHitMarker\n\ + ldr r0, [r2]\n\ + ldr r1, =0xfffffbff\n\ + ands r0, r1\n\ + str r0, [r2]\n\ + ldr r3, =gBattleScriptsForMoveEffects\n\ + ldr r2, =gBattleMoves\n\ + ldrh r1, [r4]\n\ + lsls r0, r1, 1\n\ + adds r0, r1\n\ + lsls r0, 2\n\ + adds r0, r2\n\ + ldrb r0, [r0]\n\ + lsls r0, 2\n\ + adds r0, r3\n\ + ldr r0, [r0]\n\ + mov r1, r8\n\ + str r0, [r1]\n\ + ldrh r0, [r4]\n\ + movs r1, 0\n\ + bl GetMoveTarget\n\ + ldr r1, =gBankTarget\n\ + strb r0, [r1]\n\ + pop {r3}\n\ + mov r8, r3\n\ + pop {r4-r7}\n\ + pop {r0}\n\ + bx r0\n\ + .pool\n\ + .syntax divided"); +} + +#endif // NONMATCHING + +void atk9F_dmgtolevel(void) +{ + gBattleMoveDamage = gBattleMons[gBankAttacker].level; + gBattlescriptCurrInstr++; +} + +void atkA0_psywavedamageeffect(void) +{ + s32 randDamage; + + while ((randDamage = (Random() & 0xF)) > 10); + + randDamage *= 10; + gBattleMoveDamage = gBattleMons[gBankAttacker].level * (randDamage + 50) / 100; + gBattlescriptCurrInstr++; +} + +void atkA1_counterdamagecalculator(void) +{ + u8 sideAttacker = GetBankSide(gBankAttacker); + u8 sideTarget = GetBankSide(gProtectStructs[gBankAttacker].physicalBank); + + if (gProtectStructs[gBankAttacker].physicalDmg + && sideAttacker != sideTarget + && gBattleMons[gProtectStructs[gBankAttacker].physicalBank].hp) + { + gBattleMoveDamage = gProtectStructs[gBankAttacker].physicalDmg * 2; + + if (gSideTimers[sideTarget].followmeTimer && gBattleMons[gSideTimers[sideTarget].followmeTarget].hp) + gBankTarget = gSideTimers[sideTarget].followmeTarget; + else + gBankTarget = gProtectStructs[gBankAttacker].physicalBank; + + gBattlescriptCurrInstr += 5; + } + else + { + gSpecialStatuses[gBankAttacker].flag20 = 1; + gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); + } +} + +void atkA2_mirrorcoatdamagecalculator(void) // a copy of atkA1 with the physical -> special field changes +{ + u8 sideAttacker = GetBankSide(gBankAttacker); + u8 sideTarget = GetBankSide(gProtectStructs[gBankAttacker].specialBank); + + if (gProtectStructs[gBankAttacker].specialDmg && sideAttacker != sideTarget && gBattleMons[gProtectStructs[gBankAttacker].specialBank].hp) + { + gBattleMoveDamage = gProtectStructs[gBankAttacker].specialDmg * 2; + + if (gSideTimers[sideTarget].followmeTimer && gBattleMons[gSideTimers[sideTarget].followmeTarget].hp) + gBankTarget = gSideTimers[sideTarget].followmeTarget; + else + gBankTarget = gProtectStructs[gBankAttacker].specialBank; + + gBattlescriptCurrInstr += 5; + } + else + { + gSpecialStatuses[gBankAttacker].flag20 = 1; + gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); + } +} + +void atkA3_disablelastusedattack(void) +{ + s32 i; + + for (i = 0; i < 4; i++) + { + if (gBattleMons[gBankTarget].moves[i] == gLastUsedMovesByBanks[gBankTarget]) + break; + } + if (gDisableStructs[gBankTarget].disabledMove == 0 + && i != 4 && gBattleMons[gBankTarget].pp[i] != 0) + { + PREPARE_MOVE_BUFFER(gBattleTextBuff1, gBattleMons[gBankTarget].moves[i]) + + gDisableStructs[gBankTarget].disabledMove = gBattleMons[gBankTarget].moves[i]; + gDisableStructs[gBankTarget].disableTimer1 = (Random() & 3) + 2; + gDisableStructs[gBankTarget].disableTimer2 = gDisableStructs[gBankTarget].disableTimer1; // used to save the random amount of turns? + gBattlescriptCurrInstr += 5; + } + else + { + gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); + } +} + +void atkA4_setencore(void) +{ + s32 i; + + for (i = 0; i < 4; i++) + { + if (gBattleMons[gBankTarget].moves[i] == gLastUsedMovesByBanks[gBankTarget]) + break; + } + + if (gLastUsedMovesByBanks[gBankTarget] == MOVE_STRUGGLE + || gLastUsedMovesByBanks[gBankTarget] == MOVE_ENCORE + || gLastUsedMovesByBanks[gBankTarget] == MOVE_MIRROR_MOVE) + { + i = 4; + } + + if (gDisableStructs[gBankTarget].encoredMove == 0 + && i != 4 && gBattleMons[gBankTarget].pp[i] != 0) + { + gDisableStructs[gBankTarget].encoredMove = gBattleMons[gBankTarget].moves[i]; + gDisableStructs[gBankTarget].encoredMovePos = i; + gDisableStructs[gBankTarget].encoreTimer1 = (Random() & 3) + 3; + gDisableStructs[gBankTarget].encoreTimer2 = gDisableStructs[gBankTarget].encoreTimer1; + gBattlescriptCurrInstr += 5; + } + else + { + gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); + } +} + +void atkA5_painsplitdmgcalc(void) +{ + if (!(gBattleMons[gBankTarget].status2 & STATUS2_SUBSTITUTE)) + { + s32 hpDiff = (gBattleMons[gBankAttacker].hp + gBattleMons[gBankTarget].hp) / 2; + s32 painSplitHp = gBattleMoveDamage = gBattleMons[gBankTarget].hp - hpDiff; + u8* storeLoc = (void*)(&gBattleScripting.painSplitHp); + + storeLoc[0] = (painSplitHp); + storeLoc[1] = (painSplitHp & 0x0000FF00) >> 8; + storeLoc[2] = (painSplitHp & 0x00FF0000) >> 16; + storeLoc[3] = (painSplitHp & 0xFF000000) >> 24; + + gBattleMoveDamage = gBattleMons[gBankAttacker].hp - hpDiff; + gSpecialStatuses[gBankTarget].moveturnLostHP = 0xFFFF; + + gBattlescriptCurrInstr += 5; + } + else + { + gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); + } +} + +#ifdef NONMATCHING +void atkA6_settypetorandomresistance(void) // conversion 2 +{ + if (gUnknown_02024250[gBankAttacker] == 0 + || gUnknown_02024250[gBankAttacker] == 0xFFFF) + { + gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); + } + else if (IsTwoTurnsMove(gUnknown_02024250[gBankAttacker]) + && gBattleMons[gUnknown_02024270[gBankAttacker]].status2 & STATUS2_MULTIPLETURNS) + { + gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); + } + else + { + s32 type = 0, rands = 0; + do + { + while (((type = (Random() & 0x7F)) > 0x70)); + + type *= 3; + + if (gTypeEffectiveness[type] == gUnknown_02024258[gBankAttacker] + && gTypeEffectiveness[type + 2] <= 5 + && gBattleMons[gBankAttacker].type1 != gTypeEffectiveness[type + 1] + && gBattleMons[gBankAttacker].type2 != gTypeEffectiveness[type + 1]) + { + gBattleMons[gBankAttacker].type1 = type; + gBattleMons[gBankAttacker].type2 = type; + + PREPARE_TYPE_BUFFER(gBattleTextBuff1, type) + + gBattlescriptCurrInstr += 5; + return; + } + + rands++; + } while (rands <= 999); + + type = 0, rands = 0; + do + { + s8 var = (s8)(gTypeEffectiveness[type]); + if (var > -1 || var < -2) + { + if (gTypeEffectiveness[type] == gUnknown_02024258[gBankAttacker] + && gTypeEffectiveness[type + 2] <= 5 + && gBattleMons[gBankAttacker].type1 != gTypeEffectiveness[type + 1] + && gBattleMons[gBankAttacker].type2 != gTypeEffectiveness[type + 1]) + { + gBattleMons[gBankAttacker].type1 = gTypeEffectiveness[rands + 1]; + gBattleMons[gBankAttacker].type2 = gTypeEffectiveness[rands + 1]; + + PREPARE_TYPE_BUFFER(gBattleTextBuff1, gTypeEffectiveness[rands + 1]) + + gBattlescriptCurrInstr += 5; + return; + } + } + type += 3, rands += 3; + } while (rands < 336); + + gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); + } +} + +#else +__attribute__((naked)) +void atkA6_settypetorandomresistance(void) // conversion 2 +{ + asm(".syntax unified\n\ + push {r4-r7,lr}\n\ + mov r7, r10\n\ + mov r6, r9\n\ + mov r5, r8\n\ + push {r5-r7}\n\ + ldr r1, =gUnknown_02024250\n\ + ldr r4, =gBankAttacker\n\ + ldrb r0, [r4]\n\ + lsls r0, 1\n\ + adds r2, r0, r1\n\ + ldrh r1, [r2]\n\ + cmp r1, 0\n\ + beq _08052B7E\n\ + ldr r0, =0x0000ffff\n\ + cmp r1, r0\n\ + beq _08052B7E\n\ + ldrh r0, [r2]\n\ + bl IsTwoTurnsMove\n\ + lsls r0, 24\n\ + cmp r0, 0\n\ + beq _08052C1C\n\ + ldr r1, =gBattleMons\n\ + ldr r2, =gUnknown_02024270\n\ + ldrb r0, [r4]\n\ + adds r0, r2\n\ + ldrb r2, [r0]\n\ + movs r0, 0x58\n\ + muls r0, r2\n\ + adds r1, 0x50\n\ + adds r0, r1\n\ + ldr r0, [r0]\n\ + movs r1, 0x80\n\ + lsls r1, 5\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + beq _08052C1C\n\ +_08052B7E:\n\ + ldr r3, =gBattlescriptCurrInstr\n\ + ldr r2, [r3]\n\ + ldrb r1, [r2, 0x1]\n\ + ldrb r0, [r2, 0x2]\n\ + lsls r0, 8\n\ + orrs r1, r0\n\ + ldrb r0, [r2, 0x3]\n\ + lsls r0, 16\n\ + orrs r1, r0\n\ + ldrb r0, [r2, 0x4]\n\ + lsls r0, 24\n\ + orrs r1, r0\n\ + str r1, [r3]\n\ + b _08052D08\n\ + .pool\n\ +_08052BB4:\n\ + mov r0, r12\n\ + strb r5, [r0]\n\ + mov r1, r10\n\ + ldrb r0, [r1]\n\ + muls r0, r2\n\ + adds r0, r7\n\ + adds r0, 0x22\n\ + strb r5, [r0]\n\ + ldr r1, =gBattleTextBuff1\n\ + movs r0, 0xFD\n\ + strb r0, [r1]\n\ + movs r0, 0x3\n\ + strb r0, [r1, 0x1]\n\ + strb r5, [r1, 0x2]\n\ + movs r0, 0xFF\n\ + strb r0, [r1, 0x3]\n\ + ldr r1, =gBattlescriptCurrInstr\n\ + b _08052C0A\n\ + .pool\n\ +_08052BE0:\n\ + mov r0, r8\n\ + adds r0, 0x1\n\ + adds r0, r3\n\ + ldrb r2, [r0]\n\ + strb r2, [r4]\n\ + mov r4, r10\n\ + ldrb r0, [r4]\n\ + muls r0, r6\n\ + ldr r7, =gBattleMons\n\ + adds r0, r7\n\ + adds r0, 0x22\n\ + strb r2, [r0]\n\ + ldr r1, =gBattleTextBuff1\n\ + movs r0, 0xFD\n\ + strb r0, [r1]\n\ + movs r0, 0x3\n\ + strb r0, [r1, 0x1]\n\ + strb r2, [r1, 0x2]\n\ + movs r0, 0xFF\n\ + strb r0, [r1, 0x3]\n\ + mov r1, r12\n\ +_08052C0A:\n\ + ldr r0, [r1]\n\ + adds r0, 0x5\n\ + str r0, [r1]\n\ + b _08052D08\n\ + .pool\n\ +_08052C1C:\n\ + movs r4, 0\n\ + mov r8, r4\n\ + movs r7, 0x7F\n\ + mov r9, r7\n\ +_08052C24:\n\ + bl Random\n\ + mov r4, r9\n\ + ands r4, r0\n\ + cmp r4, 0x70\n\ + bhi _08052C24\n\ + lsls r0, r4, 1\n\ + adds r4, r0, r4\n\ + ldr r6, =gTypeEffectiveness\n\ + adds r3, r4, r6\n\ + ldr r1, =gUnknown_02024258\n\ + ldr r2, =gBankAttacker\n\ + ldrb r5, [r2]\n\ + lsls r0, r5, 1\n\ + adds r0, r1\n\ + ldrb r1, [r3]\n\ + mov r10, r2\n\ + ldrh r0, [r0]\n\ + cmp r1, r0\n\ + bne _08052C80\n\ + adds r0, r4, 0x2\n\ + adds r0, r6\n\ + ldrb r0, [r0]\n\ + cmp r0, 0x5\n\ + bhi _08052C80\n\ + ldr r7, =gBattleMons\n\ + movs r2, 0x58\n\ + adds r0, r5, 0\n\ + muls r0, r2\n\ + adds r3, r0, r7\n\ + movs r0, 0x21\n\ + adds r0, r3\n\ + mov r12, r0\n\ + adds r0, r4, 0x1\n\ + adds r0, r6\n\ + ldrb r5, [r0]\n\ + mov r1, r12\n\ + ldrb r0, [r1]\n\ + adds r1, r5, 0\n\ + cmp r0, r1\n\ + beq _08052C80\n\ + adds r0, r3, 0\n\ + adds r0, 0x22\n\ + ldrb r0, [r0]\n\ + cmp r0, r1\n\ + bne _08052BB4\n\ +_08052C80:\n\ + movs r7, 0x1\n\ + add r8, r7\n\ + ldr r0, =0x000003e7\n\ + cmp r8, r0\n\ + ble _08052C24\n\ + movs r0, 0\n\ + mov r8, r0\n\ + ldr r1, =gBattlescriptCurrInstr\n\ + mov r12, r1\n\ + ldr r3, =gTypeEffectiveness\n\ + adds r0, r4, 0x1\n\ + adds r0, r3\n\ + mov r9, r0\n\ + adds r5, r3, 0\n\ +_08052C9C:\n\ + ldrb r1, [r5]\n\ + cmp r1, 0xFF\n\ + bgt _08052CA6\n\ + cmp r1, 0xFE\n\ + bge _08052CE0\n\ +_08052CA6:\n\ + mov r4, r10\n\ + ldrb r2, [r4]\n\ + lsls r0, r2, 1\n\ + ldr r7, =gUnknown_02024258\n\ + adds r0, r7\n\ + ldrh r0, [r0]\n\ + cmp r1, r0\n\ + bne _08052CE0\n\ + ldrb r0, [r5, 0x2]\n\ + cmp r0, 0x5\n\ + bhi _08052CE0\n\ + movs r6, 0x58\n\ + adds r0, r2, 0\n\ + muls r0, r6\n\ + ldr r1, =gBattleMons\n\ + adds r2, r0, r1\n\ + adds r4, r2, 0\n\ + adds r4, 0x21\n\ + ldrb r0, [r4]\n\ + mov r7, r9\n\ + ldrb r1, [r7]\n\ + cmp r0, r1\n\ + beq _08052CE0\n\ + adds r0, r2, 0\n\ + adds r0, 0x22\n\ + ldrb r0, [r0]\n\ + cmp r0, r1\n\ + beq _08052CE0\n\ + b _08052BE0\n\ +_08052CE0:\n\ + adds r5, 0x3\n\ + movs r0, 0x3\n\ + add r8, r0\n\ + ldr r0, =0x0000014f\n\ + cmp r8, r0\n\ + bls _08052C9C\n\ + mov r1, r12\n\ + ldr r2, [r1]\n\ + ldrb r1, [r2, 0x1]\n\ + ldrb r0, [r2, 0x2]\n\ + lsls r0, 8\n\ + orrs r1, r0\n\ + ldrb r0, [r2, 0x3]\n\ + lsls r0, 16\n\ + orrs r1, r0\n\ + ldrb r0, [r2, 0x4]\n\ + lsls r0, 24\n\ + orrs r1, r0\n\ + mov r4, r12\n\ + str r1, [r4]\n\ +_08052D08:\n\ + pop {r3-r5}\n\ + mov r8, r3\n\ + mov r9, r4\n\ + mov r10, r5\n\ + pop {r4-r7}\n\ + pop {r0}\n\ + bx r0\n\ + .pool\n\ + .syntax divided"); +} +#endif // NONMATCHING + +void atkA7_setalwayshitflag(void) +{ + gStatuses3[gBankTarget] &= ~(STATUS3_ALWAYS_HITS); + gStatuses3[gBankTarget] |= 0x10; + gDisableStructs[gBankTarget].bankWithSureHit = gBankAttacker; + gBattlescriptCurrInstr++; +} + +void atkA8_copymovepermanently(void) // sketch +{ + gLastUsedMove = 0xFFFF; + + if (!(gBattleMons[gBankAttacker].status2 & STATUS2_TRANSFORMED) + && gUnknownMovesUsedByBanks[gBankTarget] != MOVE_STRUGGLE + && gUnknownMovesUsedByBanks[gBankTarget] != 0 + && gUnknownMovesUsedByBanks[gBankTarget] != 0xFFFF + && gUnknownMovesUsedByBanks[gBankTarget] != MOVE_SKETCH) + { + s32 i; + + for (i = 0; i < 4; i++) + { + if (gBattleMons[gBankAttacker].moves[i] == MOVE_SKETCH) + continue; + if (gBattleMons[gBankAttacker].moves[i] == gUnknownMovesUsedByBanks[gBankTarget]) + break; + } + + if (i != 4) + { + gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); + } + else // sketch worked + { + struct MovePpInfo movePpData; + + gBattleMons[gBankAttacker].moves[gCurrMovePos] = gUnknownMovesUsedByBanks[gBankTarget]; + gBattleMons[gBankAttacker].pp[gCurrMovePos] = gBattleMoves[gUnknownMovesUsedByBanks[gBankTarget]].pp; + gActiveBank = gBankAttacker; + + for (i = 0; i < 4; i++) + { + movePpData.move[i] = gBattleMons[gBankAttacker].moves[i]; + movePpData.pp[i] = gBattleMons[gBankAttacker].pp[i]; + } + movePpData.ppBonuses = gBattleMons[gBankAttacker].ppBonuses; + + EmitSetMonData(0, REQUEST_MOVES_PP_BATTLE, 0, sizeof(struct MovePpInfo), &movePpData); + MarkBufferBankForExecution(gActiveBank); + + PREPARE_MOVE_BUFFER(gBattleTextBuff1, gUnknownMovesUsedByBanks[gBankTarget]) + + gBattlescriptCurrInstr += 5; + } + } + else + { + gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); + } +} + diff --git a/src/battle_ai.c b/src/battle_ai.c index 75b5eb2ed..8590b0f03 100644 --- a/src/battle_ai.c +++ b/src/battle_ai.c @@ -1802,7 +1802,7 @@ static void BattleAICmd_count_alive_pokemon(void) u32 status; bankOnField1 = gBattlePartyID[index]; status = GetBankIdentity(index) ^ 2; - bankOnField2 = gBattlePartyID[GetBankByPlayerAI(status)]; + bankOnField2 = gBattlePartyID[GetBankByIdentity(status)]; } else // in singles there's only one bank by side { diff --git a/src/calculate_base_damage.c b/src/calculate_base_damage.c index 105b334f2..8996059f9 100644 --- a/src/calculate_base_damage.c +++ b/src/calculate_base_damage.c @@ -19,7 +19,6 @@ extern struct BattleEnigmaBerry gEnigmaBerries[]; extern u16 gBattleMovePower; extern u16 gTrainerBattleOpponent_A; -u8 CountAliveMonsInBattle(u8); bool8 ShouldGetStatBadgeBoost(u16 flagId, u8 bank); extern const struct BattleMove gBattleMoves[]; diff --git a/src/pokemon_2.c b/src/pokemon_2.c index cf073570d..b6359f76a 100644 --- a/src/pokemon_2.c +++ b/src/pokemon_2.c @@ -35,7 +35,7 @@ extern const u8 gText_BadEgg[]; extern const u8 gText_EggNickname[]; extern u8 GetBankSide(u8 bank); -extern u8 GetBankByPlayerAI(u8 bank); +extern u8 GetBankByIdentity(u8 bank); extern u8 GetBankIdentity(u8 bank); u8 CountAliveMonsInBattle(u8 caseId) @@ -90,7 +90,7 @@ u8 sub_8069F34(u8 bank) status ^= 1; if (!(gBattleTypeFlags & BATTLE_TYPE_DOUBLE)) - return GetBankByPlayerAI(status); + return GetBankByIdentity(status); if (CountAliveMonsInBattle(BATTLE_ALIVE_EXCEPT_ACTIVE) > 1) { u8 val; @@ -99,14 +99,14 @@ u8 sub_8069F34(u8 bank) val = status ^ 2; else val = status; - return GetBankByPlayerAI(val); + return GetBankByIdentity(val); } else { if ((gAbsentBankFlags & gBitTable[status])) - return GetBankByPlayerAI(status ^ 2); + return GetBankByIdentity(status ^ 2); else - return GetBankByPlayerAI(status); + return GetBankByIdentity(status); } } diff --git a/src/pokemon_3.c b/src/pokemon_3.c index aaa02c5d4..d381c7544 100644 --- a/src/pokemon_3.c +++ b/src/pokemon_3.c @@ -216,7 +216,7 @@ void sub_806CF24(s32 stat) gBankTarget = gBankInMenu; StringCopy(gBattleTextBuff1, gStatNamesTable[gUnknown_08329EC8[stat]]); StringCopy(gBattleTextBuff2, gText_StatRose); - StrCpyDecodeToDisplayedStringBattle(gText_PkmnsStatChanged2); + BattleStringExpandPlaceholdersToDisplayedString(gText_PkmnsStatChanged2); } u8 *sub_806CF78(u16 itemId) @@ -251,7 +251,7 @@ u8 *sub_806CF78(u16 itemId) else { gBankAttacker = gBankInMenu; - StrCpyDecodeToDisplayedStringBattle(gText_PkmnGettingPumped); + BattleStringExpandPlaceholdersToDisplayedString(gText_PkmnGettingPumped); } } } @@ -259,7 +259,7 @@ u8 *sub_806CF78(u16 itemId) if (itemEffect[3] & 0x80) { gBankAttacker = gBankInMenu; - StrCpyDecodeToDisplayedStringBattle(gText_PkmnShroudedInMist); + BattleStringExpandPlaceholdersToDisplayedString(gText_PkmnShroudedInMist); } return gDisplayedStringBattle; diff --git a/src/window.c b/src/window.c index 164031bee..704060b9d 100644 --- a/src/window.c +++ b/src/window.c @@ -451,7 +451,7 @@ void FillWindowPixelRect(u8 windowId, u8 fillValue, u16 x, u16 y, u16 width, u16 FillBitmapRect4Bit(&pixelRect, x, y, width, height, fillValue); } -void CopyToWindowPixelBuffer(u8 windowId, u8 *src, u16 size, u16 tileOffset) +void CopyToWindowPixelBuffer(u8 windowId, const u8 *src, u16 size, u16 tileOffset) { if (size != 0) CpuCopy16(src, gWindows[windowId].tileData + (0x20 * tileOffset), size); diff --git a/sym_ewram.txt b/sym_ewram.txt index ef2080e22..7c18d8225 100644 --- a/sym_ewram.txt +++ b/sym_ewram.txt @@ -211,16 +211,16 @@ gUnknown_02022E14: @ 2022E14 gUnknown_02022E16: @ 2022E16 .space 0x2 -gUnknown_02022E18: @ 2022E18 +gBattle_BG1_X: @ 2022E18 .space 0x2 -gUnknown_02022E1A: @ 2022E1A +gBattle_BG1_Y: @ 2022E1A .space 0x2 -gUnknown_02022E1C: @ 2022E1C +gBattle_BG2_X: @ 2022E1C .space 0x2 -gUnknown_02022E1E: @ 2022E1E +gBattle_BG2_Y: @ 2022E1E .space 0x2 gUnknown_02022E20: @ 2022E20