From 551339599934103779bc81b4f258a5d611cf4f80 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Sun, 23 Jul 2017 23:56:42 +0200 Subject: [PATCH 1/8] start decompiling battle_3 git sucks --- asm/battle_2.s | 2 +- asm/battle_3.s | 750 +--------------------------------------- data/battle_scripts_1.s | 16 +- include/battle.h | 112 +++++- ld_script.txt | 1 + src/battle_3.c | 450 ++++++++++++++++++++++++ src/battle_4.c | 8 +- src/battle_ai.c | 2 +- 8 files changed, 568 insertions(+), 773 deletions(-) create mode 100644 src/battle_3.c diff --git a/asm/battle_2.s b/asm/battle_2.s index 4e8d16c7e..0fea1dc77 100644 --- a/asm/battle_2.s +++ b/asm/battle_2.s @@ -262,7 +262,7 @@ _08012538: .4byte _08012968 .4byte _0801292C _0801256C: - bl sub_8015C90 + bl AreAllMovesUnusable lsls r0, 24 cmp r0, 0 beq _080125D0 diff --git a/asm/battle_3.s b/asm/battle_3.s index 7fc14545c..222a4c8b2 100644 --- a/asm/battle_3.s +++ b/asm/battle_3.s @@ -6,747 +6,7 @@ .text - thumb_func_start b_movescr_stack_push -b_movescr_stack_push: @ 801582C - push {r4,lr} - ldr r4, _08015848 @ =0x02017110 - adds r3, r4, 0 - adds r3, 0x20 - ldrb r1, [r3] - adds r2, r1, 0x1 - strb r2, [r3] - lsls r1, 24 - lsrs r1, 22 - adds r1, r4 - str r0, [r1] - pop {r4} - pop {r0} - bx r0 - .align 2, 0 -_08015848: .4byte 0x02017110 - thumb_func_end b_movescr_stack_push - - thumb_func_start b_movescr_stack_push_cursor -b_movescr_stack_push_cursor: @ 801584C - ldr r3, _08015868 @ =0x02017110 - adds r2, r3, 0 - adds r2, 0x20 - ldrb r0, [r2] - adds r1, r0, 0x1 - strb r1, [r2] - lsls r0, 24 - lsrs r0, 22 - adds r0, r3 - ldr r1, _0801586C @ =gBattlescriptCurrInstr - ldr r1, [r1] - str r1, [r0] - bx lr - .align 2, 0 -_08015868: .4byte 0x02017110 -_0801586C: .4byte gBattlescriptCurrInstr - thumb_func_end b_movescr_stack_push_cursor - - thumb_func_start b_movescr_stack_pop_cursor -b_movescr_stack_pop_cursor: @ 8015870 - ldr r3, _0801588C @ =gBattlescriptCurrInstr - ldr r2, _08015890 @ =0x02017110 - adds r1, r2, 0 - adds r1, 0x20 - ldrb r0, [r1] - subs r0, 0x1 - strb r0, [r1] - lsls r0, 24 - lsrs r0, 22 - adds r0, r2 - ldr r0, [r0] - str r0, [r3] - bx lr - .align 2, 0 -_0801588C: .4byte gBattlescriptCurrInstr -_08015890: .4byte 0x02017110 - thumb_func_end b_movescr_stack_pop_cursor - - thumb_func_start sub_8015894 -sub_8015894: @ 8015894 - push {r4-r7,lr} - mov r7, r8 - push {r7} - movs r6, 0 - ldr r2, _080159AC @ =gBattleMons - ldr r1, _080159B0 @ =gBattleBufferB - ldr r5, _080159B4 @ =gActiveBank - ldrb r3, [r5] - lsls r0, r3, 9 - adds r1, 0x2 - adds r0, r1 - ldrb r0, [r0] - lsls r0, 1 - movs r1, 0x58 - muls r1, r3 - adds r0, r1 - adds r2, 0xC - adds r0, r2 - ldrh r4, [r0] - lsls r0, r3, 1 - ldr r2, _080159B8 @ =0x020160e8 - adds r0, r2 - mov r8, r0 - ldr r1, _080159BC @ =gDisableStructs - lsls r0, r3, 3 - subs r0, r3 - lsls r0, 2 - adds r0, r1 - ldrh r0, [r0, 0x4] - cmp r0, r4 - bne _080158EE - cmp r4, 0 - beq _080158EE - adds r0, r2, 0 - subs r0, 0xE5 - strb r3, [r0] - ldr r0, _080159C0 @ =gCurrentMove - strh r4, [r0] - ldr r1, _080159C4 @ =gUnknown_02024C1C - ldrb r0, [r5] - lsls r0, 2 - adds r0, r1 - ldr r1, _080159C8 @ =gUnknown_081D9144 - str r1, [r0] - movs r6, 0x1 -_080158EE: - ldr r1, _080159CC @ =gLastUsedMove - ldr r5, _080159B4 @ =gActiveBank - ldrb r2, [r5] - lsls r0, r2, 1 - adds r0, r1 - ldrh r0, [r0] - cmp r4, r0 - bne _0801592A - cmp r4, 0xA5 - beq _0801592A - ldr r1, _080159AC @ =gBattleMons - movs r0, 0x58 - muls r0, r2 - adds r1, 0x50 - adds r0, r1 - ldr r0, [r0] - cmp r0, 0 - bge _0801592A - adds r0, r2, 0 - bl CancelMultiTurnMoves - ldr r1, _080159C4 @ =gUnknown_02024C1C - ldrb r0, [r5] - lsls r0, 2 - adds r0, r1 - ldr r1, _080159D0 @ =gUnknown_081D937C - str r1, [r0] - adds r0, r6, 0x1 - lsls r0, 24 - lsrs r6, r0, 24 -_0801592A: - ldr r2, _080159BC @ =gDisableStructs - ldr r3, _080159B4 @ =gActiveBank - ldrb r1, [r3] - lsls r0, r1, 3 - subs r0, r1 - lsls r0, 2 - adds r0, r2 - ldrb r0, [r0, 0x13] - lsls r0, 28 - cmp r0, 0 - beq _08015966 - ldr r0, _080159D4 @ =gBattleMoves - lsls r1, r4, 1 - adds r1, r4 - lsls r1, 2 - adds r1, r0 - ldrb r0, [r1, 0x1] - cmp r0, 0 - bne _08015966 - ldr r0, _080159C0 @ =gCurrentMove - strh r4, [r0] - ldr r1, _080159C4 @ =gUnknown_02024C1C - ldrb r0, [r3] - lsls r0, 2 - adds r0, r1 - ldr r1, _080159D8 @ =gUnknown_081D938B - str r1, [r0] - adds r0, r6, 0x1 - lsls r0, 24 - lsrs r6, r0, 24 -_08015966: - ldr r5, _080159B4 @ =gActiveBank - ldrb r0, [r5] - adds r1, r4, 0 - bl sub_8015D5C - lsls r0, 24 - cmp r0, 0 - beq _0801598C - ldr r0, _080159C0 @ =gCurrentMove - strh r4, [r0] - ldr r1, _080159C4 @ =gUnknown_02024C1C - ldrb r0, [r5] - lsls r0, 2 - adds r0, r1 - ldr r1, _080159DC @ =gUnknown_081D9464 - str r1, [r0] - adds r0, r6, 0x1 - lsls r0, 24 - lsrs r6, r0, 24 -_0801598C: - ldr r1, _080159AC @ =gBattleMons - ldrb r2, [r5] - movs r0, 0x58 - muls r0, r2 - adds r1, r0, r1 - ldrh r0, [r1, 0x2E] - cmp r0, 0xAF - bne _080159E4 - ldr r1, _080159E0 @ =gEnigmaBerries - lsls r0, r2, 3 - subs r0, r2 - lsls r0, 2 - adds r0, r1 - ldrb r3, [r0, 0x7] - b _080159EE - .align 2, 0 -_080159AC: .4byte gBattleMons -_080159B0: .4byte gBattleBufferB -_080159B4: .4byte gActiveBank -_080159B8: .4byte 0x020160e8 -_080159BC: .4byte gDisableStructs -_080159C0: .4byte gCurrentMove -_080159C4: .4byte gUnknown_02024C1C -_080159C8: .4byte gUnknown_081D9144 -_080159CC: .4byte gLastUsedMove -_080159D0: .4byte gUnknown_081D937C -_080159D4: .4byte gBattleMoves -_080159D8: .4byte gUnknown_081D938B -_080159DC: .4byte gUnknown_081D9464 -_080159E0: .4byte gEnigmaBerries -_080159E4: - ldrh r0, [r1, 0x2E] - bl ItemId_GetHoldEffect - lsls r0, 24 - lsrs r3, r0, 24 -_080159EE: - ldr r2, _08015A70 @ =gStringBank - ldr r1, _08015A74 @ =gActiveBank - ldrb r0, [r1] - strb r0, [r2] - ldr r7, _08015A78 @ =gBattleMons - adds r5, r1, 0 - cmp r3, 0x1D - bne _08015A36 - mov r0, r8 - ldrh r2, [r0] - adds r1, r2, 0 - cmp r1, 0 - beq _08015A36 - ldr r0, _08015A7C @ =0x0000ffff - cmp r1, r0 - beq _08015A36 - cmp r1, r4 - beq _08015A36 - ldr r0, _08015A80 @ =gCurrentMove - strh r2, [r0] - ldr r2, _08015A84 @ =gLastUsedItem - ldrb r1, [r5] - movs r0, 0x58 - muls r0, r1 - adds r0, r7 - ldrh r0, [r0, 0x2E] - strh r0, [r2] - ldr r1, _08015A88 @ =gUnknown_02024C1C - ldrb r0, [r5] - lsls r0, 2 - adds r0, r1 - ldr r1, _08015A8C @ =gUnknown_081D9AC2 - str r1, [r0] - adds r0, r6, 0x1 - lsls r0, 24 - lsrs r6, r0, 24 -_08015A36: - ldr r0, _08015A90 @ =gBattleBufferB - ldrb r2, [r5] - lsls r1, r2, 9 - adds r0, 0x2 - adds r1, r0 - movs r0, 0x58 - muls r0, r2 - ldrb r1, [r1] - adds r0, r1 - adds r1, r7, 0 - adds r1, 0x24 - adds r0, r1 - ldrb r0, [r0] - cmp r0, 0 - bne _08015A64 - ldr r1, _08015A88 @ =gUnknown_02024C1C - lsls r0, r2, 2 - adds r0, r1 - ldr r1, _08015A94 @ =gUnknown_081D9369 - str r1, [r0] - adds r0, r6, 0x1 - lsls r0, 24 - lsrs r6, r0, 24 -_08015A64: - adds r0, r6, 0 - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r1} - bx r1 - .align 2, 0 -_08015A70: .4byte gStringBank -_08015A74: .4byte gActiveBank -_08015A78: .4byte gBattleMons -_08015A7C: .4byte 0x0000ffff -_08015A80: .4byte gCurrentMove -_08015A84: .4byte gLastUsedItem -_08015A88: .4byte gUnknown_02024C1C -_08015A8C: .4byte gUnknown_081D9AC2 -_08015A90: .4byte gBattleBufferB -_08015A94: .4byte gUnknown_081D9369 - thumb_func_end sub_8015894 - - thumb_func_start sub_8015A98 -sub_8015A98: @ 8015A98 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x1C - lsls r0, 24 - lsrs r7, r0, 24 - lsls r1, 24 - lsrs r4, r1, 24 - lsls r2, 24 - lsrs r3, r2, 24 - lsls r1, r7, 1 - ldr r0, _08015AD8 @ =0x020160e8 - adds r1, r0 - str r1, [sp, 0x4] - ldr r1, _08015ADC @ =gBattleMons - movs r0, 0x58 - muls r0, r7 - adds r1, r0, r1 - ldrh r0, [r1, 0x2E] - cmp r0, 0xAF - bne _08015AE4 - ldr r2, _08015AE0 @ =gEnigmaBerries - lsls r1, r7, 3 - subs r0, r1, r7 - lsls r0, 2 - adds r0, r2 - ldrb r0, [r0, 0x7] - str r0, [sp] - b _08015AF6 - .align 2, 0 -_08015AD8: .4byte 0x020160e8 -_08015ADC: .4byte gBattleMons -_08015AE0: .4byte gEnigmaBerries -_08015AE4: - ldrh r0, [r1, 0x2E] - str r3, [sp, 0x14] - bl ItemId_GetHoldEffect - lsls r0, 24 - lsrs r0, 24 - str r0, [sp] - lsls r1, r7, 3 - ldr r3, [sp, 0x14] -_08015AF6: - ldr r0, _08015C70 @ =gStringBank - strb r7, [r0] - movs r0, 0 - mov r9, r0 - lsls r2, r7, 1 - str r2, [sp, 0xC] - ldr r5, _08015C74 @ =gDisableStructs - mov r12, r5 - ldr r0, _08015C78 @ =gBattleMons - movs r2, 0x58 - adds r6, r7, 0 - muls r6, r2 - str r6, [sp, 0x8] - ldr r2, _08015C7C @ =gUnknown_02024A8C - adds r5, r6, r2 - movs r6, 0 - str r6, [sp, 0x10] - mov r10, r0 - subs r0, r1, r7 - lsls r0, 2 - mov r8, r0 - ldr r6, _08015C80 @ =gBitTable -_08015B22: - ldrh r0, [r5] - cmp r0, 0 - bne _08015B38 - movs r0, 0x1 - ands r0, r3 - cmp r0, 0 - beq _08015B38 - ldr r0, [r6] - orrs r4, r0 - lsls r0, r4, 24 - lsrs r4, r0, 24 -_08015B38: - ldr r0, [sp, 0x8] - add r0, r9 - mov r1, r10 - adds r1, 0x24 - adds r0, r1 - ldrb r0, [r0] - cmp r0, 0 - bne _08015B58 - movs r0, 0x2 - ands r0, r3 - cmp r0, 0 - beq _08015B58 - ldr r0, [r6] - orrs r4, r0 - lsls r0, r4, 24 - lsrs r4, r0, 24 -_08015B58: - mov r1, r8 - add r1, r12 - ldrh r0, [r5] - ldrh r1, [r1, 0x4] - cmp r0, r1 - bne _08015B74 - movs r0, 0x4 - ands r0, r3 - cmp r0, 0 - beq _08015B74 - ldr r0, [r6] - orrs r4, r0 - lsls r0, r4, 24 - lsrs r4, r0, 24 -_08015B74: - movs r0, 0x58 - adds r2, r7, 0 - muls r2, r0 - ldr r1, [sp, 0x10] - adds r0, r1, r2 - ldr r1, _08015C7C @ =gUnknown_02024A8C - adds r0, r1 - mov r12, r0 - ldr r1, _08015C84 @ =gLastUsedMove - ldr r0, [sp, 0xC] - adds r1, r0, r1 - str r1, [sp, 0x18] - mov r1, r12 - ldrh r1, [r1] - mov r12, r1 - ldr r0, [sp, 0x18] - ldrh r0, [r0] - cmp r12, r0 - bne _08015BB6 - movs r0, 0x8 - ands r0, r3 - cmp r0, 0 - beq _08015BB6 - mov r0, r10 - adds r0, 0x50 - adds r0, r2, r0 - ldr r0, [r0] - cmp r0, 0 - bge _08015BB6 - ldr r0, [r6] - orrs r4, r0 - lsls r0, r4, 24 - lsrs r4, r0, 24 -_08015BB6: - ldr r0, _08015C74 @ =gDisableStructs - add r0, r8 - ldrb r0, [r0, 0x13] - lsls r0, 28 - cmp r0, 0 - beq _08015BE4 - movs r0, 0x10 - ands r0, r3 - cmp r0, 0 - beq _08015BE4 - ldr r2, _08015C88 @ =gBattleMoves - ldrh r1, [r5] - lsls r0, r1, 1 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - ldrb r0, [r0, 0x1] - cmp r0, 0 - bne _08015BE4 - ldr r0, [r6] - orrs r4, r0 - lsls r0, r4, 24 - lsrs r4, r0, 24 -_08015BE4: - ldrh r1, [r5] - adds r0, r7, 0 - str r3, [sp, 0x14] - bl sub_8015D5C - lsls r0, 24 - ldr r3, [sp, 0x14] - cmp r0, 0 - beq _08015C06 - movs r0, 0x20 - ands r0, r3 - cmp r0, 0 - beq _08015C06 - ldr r0, [r6] - orrs r4, r0 - lsls r0, r4, 24 - lsrs r4, r0, 24 -_08015C06: - ldr r1, _08015C74 @ =gDisableStructs - mov r0, r8 - adds r2, r0, r1 - ldrb r0, [r2, 0xE] - lsls r0, 28 - mov r12, r1 - cmp r0, 0 - beq _08015C26 - ldrh r0, [r2, 0x6] - ldrh r1, [r5] - cmp r0, r1 - beq _08015C26 - ldr r0, [r6] - orrs r4, r0 - lsls r0, r4, 24 - lsrs r4, r0, 24 -_08015C26: - ldr r2, [sp] - cmp r2, 0x1D - bne _08015C48 - ldr r0, [sp, 0x4] - ldrh r1, [r0] - cmp r1, 0 - beq _08015C48 - ldr r0, _08015C8C @ =0x0000ffff - cmp r1, r0 - beq _08015C48 - ldrh r2, [r5] - cmp r1, r2 - beq _08015C48 - ldr r0, [r6] - orrs r4, r0 - lsls r0, r4, 24 - lsrs r4, r0, 24 -_08015C48: - adds r6, 0x4 - adds r5, 0x2 - ldr r0, [sp, 0x10] - adds r0, 0x2 - str r0, [sp, 0x10] - movs r1, 0x1 - add r9, r1 - mov r2, r9 - cmp r2, 0x3 - bgt _08015C5E - b _08015B22 -_08015C5E: - adds r0, r4, 0 - add sp, 0x1C - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r1} - bx r1 - .align 2, 0 -_08015C70: .4byte gStringBank -_08015C74: .4byte gDisableStructs -_08015C78: .4byte gBattleMons -_08015C7C: .4byte gUnknown_02024A8C -_08015C80: .4byte gBitTable -_08015C84: .4byte gLastUsedMove -_08015C88: .4byte gBattleMoves -_08015C8C: .4byte 0x0000ffff - thumb_func_end sub_8015A98 - - thumb_func_start sub_8015C90 -sub_8015C90: @ 8015C90 - push {r4-r6,lr} - ldr r5, _08015CFC @ =gActiveBank - ldrb r0, [r5] - movs r1, 0 - movs r2, 0xFF - bl sub_8015A98 - lsls r0, 24 - lsrs r6, r0, 24 - cmp r6, 0xF - bne _08015D38 - ldr r0, _08015D00 @ =gProtectStructs - ldrb r1, [r5] - lsls r1, 4 - adds r1, r0 - ldrb r0, [r1] - movs r2, 0x4 - orrs r0, r2 - strb r0, [r1] - ldr r1, _08015D04 @ =gUnknown_02024C1C - ldrb r0, [r5] - lsls r0, 2 - adds r0, r1 - ldr r1, _08015D08 @ =gUnknown_081D9365 - str r1, [r0] - ldr r0, _08015D0C @ =gBattleTypeFlags - ldrh r1, [r0] - movs r0, 0x1 - ands r0, r1 - cmp r0, 0 - beq _08015D14 - ldrb r0, [r5] - bl GetBankIdentity - adds r4, r0, 0 - bl Random - movs r1, 0x1 - eors r4, r1 - movs r1, 0x2 - ands r1, r0 - orrs r4, r1 - lsls r4, 24 - lsrs r4, 24 - adds r0, r4, 0 - bl GetBankByPlayerAI - ldr r2, _08015D10 @ =gBattleBufferB - ldrb r1, [r5] - lsls r1, 9 - adds r2, 0x3 - adds r1, r2 - b _08015D48 - .align 2, 0 -_08015CFC: .4byte gActiveBank -_08015D00: .4byte gProtectStructs -_08015D04: .4byte gUnknown_02024C1C -_08015D08: .4byte gUnknown_081D9365 -_08015D0C: .4byte gBattleTypeFlags -_08015D10: .4byte gBattleBufferB -_08015D14: - ldrb r0, [r5] - bl GetBankIdentity - movs r1, 0x1 - eors r0, r1 - lsls r0, 24 - lsrs r0, 24 - bl GetBankByPlayerAI - ldr r2, _08015D34 @ =gBattleBufferB - ldrb r1, [r5] - lsls r1, 9 - adds r2, 0x3 - adds r1, r2 - b _08015D48 - .align 2, 0 -_08015D34: .4byte gBattleBufferB -_08015D38: - ldr r0, _08015D58 @ =gProtectStructs - ldrb r1, [r5] - lsls r1, 4 - adds r1, r0 - ldrb r2, [r1] - movs r0, 0x5 - negs r0, r0 - ands r0, r2 -_08015D48: - strb r0, [r1] - movs r0, 0 - cmp r6, 0xF - bne _08015D52 - movs r0, 0x1 -_08015D52: - pop {r4-r6} - pop {r1} - bx r1 - .align 2, 0 -_08015D58: .4byte gProtectStructs - thumb_func_end sub_8015C90 - - thumb_func_start sub_8015D5C -sub_8015D5C: @ 8015D5C - push {r4-r7,lr} - mov r7, r9 - mov r6, r8 - push {r6,r7} - lsls r0, 24 - lsrs r0, 24 - lsls r1, 16 - lsrs r5, r1, 16 - movs r6, 0 - bl GetBankSide - lsls r0, 24 - lsrs r0, 24 - mov r9, r0 - movs r4, 0 - ldr r0, _08015DF0 @ =gNoOfAllBanks - ldrb r0, [r0] - cmp r6, r0 - bge _08015DE0 - ldr r7, _08015DF4 @ =gUnknown_02024A8C - mov r8, r7 -_08015D86: - lsls r0, r4, 24 - lsrs r0, 24 - bl GetBankSide - lsls r0, 24 - lsrs r0, 24 - adds r3, r4, 0x1 - cmp r9, r0 - beq _08015DD6 - ldr r1, _08015DF8 @ =gStatuses3 - lsls r0, r4, 2 - adds r0, r1 - ldr r0, [r0] - movs r1, 0x80 - lsls r1, 6 - ands r0, r1 - cmp r0, 0 - beq _08015DD6 - movs r2, 0 - movs r0, 0x58 - adds r1, r4, 0 - muls r1, r0 - adds r0, r1, r7 - ldrh r0, [r0] - cmp r5, r0 - beq _08015DCC - mov r4, r8 - adds r0, r1, r4 -_08015DBE: - adds r0, 0x2 - adds r2, 0x1 - cmp r2, 0x3 - bgt _08015DD6 - ldrh r1, [r0] - cmp r5, r1 - bne _08015DBE -_08015DCC: - cmp r2, 0x3 - bgt _08015DD6 - adds r0, r6, 0x1 - lsls r0, 24 - lsrs r6, r0, 24 -_08015DD6: - adds r4, r3, 0 - ldr r0, _08015DF0 @ =gNoOfAllBanks - ldrb r0, [r0] - cmp r4, r0 - blt _08015D86 -_08015DE0: - adds r0, r6, 0 - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r7} - pop {r1} - bx r1 - .align 2, 0 -_08015DF0: .4byte gNoOfAllBanks -_08015DF4: .4byte gUnknown_02024A8C -_08015DF8: .4byte gStatuses3 - thumb_func_end sub_8015D5C - + thumb_func_start UpdateTurnCounters UpdateTurnCounters: @ 8015DFC push {r4-r7,lr} @@ -1331,7 +591,7 @@ _08016288: beq _080162CA ldr r0, _08016314 @ =gBankTarget strb r2, [r0] - ldr r0, _08016318 @ =gUnknown_081D939A + ldr r0, _08016318 @ =BattleScript_WishComesTrue bl b_call_bc_move_exec mov r0, r9 adds r0, 0x1 @@ -1375,7 +635,7 @@ _08016308: .4byte gUnknown_02024DDC _0801630C: .4byte gTurnOrder _08016310: .4byte gBattleMons _08016314: .4byte gBankTarget -_08016318: .4byte gUnknown_081D939A +_08016318: .4byte BattleScript_WishComesTrue _0801631C: .4byte 0x02000000 _08016320: .4byte 0x0001600e _08016324: @@ -4404,7 +3664,7 @@ _08017C1C: ldrb r0, [r4] ldr r1, _08017C50 @ =gCurrentMove ldrh r1, [r1] - bl sub_8015D5C + bl IsImprisoned lsls r0, 24 cmp r0, 0 bne _08017C30 @@ -11802,7 +11062,7 @@ _0801BA4C: ldrb r1, [r0] adds r0, r3, 0 movs r2, 0xFF - bl sub_8015A98 + bl CheckMoveLimitations lsls r0, 24 lsrs r4, r0, 24 cmp r4, 0xF diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 853760b4a..43c3e77d7 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -3401,7 +3401,7 @@ gUnknown_081D9139:: @ 81D9139 waitmessage 64 jump BattleScript_EndTurn -gUnknown_081D9144:: @ 81D9144 +BattleScript_MoveSelectionDisabledMove:: @ 81D9144 printstring2 BATTLE_TEXT_MoveIsDisabled atk44 @@ -3593,11 +3593,11 @@ BattleScript_1D934B: @ 81D934B setbyte 0x2024c68, 0 end2 -gUnknown_081D9365:: @ 81D9365 +BattleScript_NoMovesLeft:: @ 81D9365 printstring2 BATTLE_TEXT_NoMovesLeft atk44 -gUnknown_081D9369:: @ 81D9369 +BattleScript_MoveSelectionNoPP:: @ 81D9369 printstring2 BATTLE_TEXT_NoPP1 atk44 @@ -3608,14 +3608,14 @@ BattleScript_NoPPForMove:: @ 81D936D waitmessage 64 jump BattleScript_EndTurn -gUnknown_081D937C:: @ 81D937C +BattleScript_MoveSelectionTormented:: @ 81D937C printstring2 BATTLE_TEXT_TormentNoUse atk44 printstring BATTLE_TEXT_TormentNoUse waitmessage 64 jump BattleScript_EndTurn -gUnknown_081D938B:: @ 81D938B +BattleScript_MoveSelectionTaunted:: @ 81D938B printstring2 BATTLE_TEXT_TauntNoUse atk44 @@ -3624,7 +3624,7 @@ gUnknown_081D938F:: @ 81D938F waitmessage 64 jump BattleScript_EndTurn -gUnknown_081D939A:: @ 81D939A +BattleScript_WishComesTrue:: @ 81D939A atkd4 1, BattleScript_1D93C1 playanimation TARGET, 22, 0x0 printstring BATTLE_TEXT_WishTrue @@ -3691,7 +3691,7 @@ gUnknown_081D9459:: @ 81D9459 waitmessage 64 jump BattleScript_EndTurn -gUnknown_081D9464:: @ 81D9464 +BattleScript_MoveSelectionImprisoned:: @ 81D9464 printstring2 BATTLE_TEXT_SealedNoUse atk44 @@ -4425,7 +4425,7 @@ gUnknown_081D9AA7:: @ 81D9AA7 datahpupdate USER return -gUnknown_081D9AC2:: @ 81D9AC2 +BattleScript_MoveSelectionChoiceBanded:: @ 81D9AC2 printstring2 BATTLE_TEXT_ChoiceBand atk44 diff --git a/include/battle.h b/include/battle.h index 12faee537..92e2242b7 100644 --- a/include/battle.h +++ b/include/battle.h @@ -179,7 +179,7 @@ struct BattleStruct /* 0x2000000 */ /*0x16008*/ u8 wrappedMove2[4]; /*0x1600C*/ u8 cmd49StateTracker; /*0x1600D*/ u8 unk1600D; - /*0x1600E*/ u8 unk1600E; + /*0x1600E*/ u8 turncountersTracker; /*0x1600F*/ u8 cmd23StateTracker; /*0x16010*/ u8 moveTarget[4]; /*0x16014*/ u8 unk16014; @@ -327,7 +327,84 @@ struct BattleStruct /* 0x2000000 */ /*0x160CA*/ u8 synchroniseEffect; /*0x160CB*/ u8 linkPlayerIndex; /*0x160CC*/ u16 usedHeldItems[4]; - u8 filler2[0x72E]; + /*0x160D4*/ u8 unk160D4; + /*0x160D5*/ u8 unk160D5; + /*0x160D6*/ u8 unk160D6; + /*0x160D7*/ u8 unk160D7; + /*0x160D8*/ u8 unk160D8; + /*0x160D9*/ u8 unk160D9; + /*0x160DA*/ u8 unk160DA; + /*0x160DB*/ u8 unk160DB; + /*0x160DC*/ u8 unk160DC; + /*0x160DD*/ u8 unk160DD; + /*0x160DE*/ u8 unk160DE; + /*0x160DF*/ u8 unk160DF; + /*0x160E0*/ u8 unk160E0; + /*0x160E1*/ u8 unk160E1; + /*0x160E2*/ u8 unk160E2; + /*0x160E3*/ u8 unk160E3; + /*0x160E4*/ u8 unk160E4; + /*0x160E5*/ u8 unk160E5; + /*0x160E6*/ u8 unk160E6; + /*0x160E7*/ u8 unk160E7; + /*0x160E8*/ u8 unk160E8; + /*0x160E9*/ u8 unk160E9; + /*0x160EA*/ u8 unk160EA; + /*0x160EB*/ u8 unk160EB; + /*0x160EC*/ u8 unk160EC; + /*0x160ED*/ u8 unk160ED; + /*0x160EE*/ u8 unk160EE; + /*0x160EF*/ u8 unk160EF; + /*0x160F0*/ u8 unk160F0; + /*0x160F1*/ u8 unk160F1; + /*0x160F2*/ u8 unk160F2; + /*0x160F3*/ u8 unk160F3; + /*0x160F4*/ u8 unk160F4; + /*0x160F5*/ u8 unk160F5; + /*0x160F6*/ u8 unk160F6; + /*0x160F7*/ u8 unk160F7; + /*0x160F8*/ u8 unk160F8; + /*0x160F9*/ u8 unk160F9; + /*0x160FA*/ u8 unk160FA; + /*0x160FB*/ u8 unk160FB; + /*0x160FC*/ u8 turnSideTracker; + /*0x160FD*/ u8 unk160FD; + /*0x160FE*/ u8 unk160FE; + /*0x160FF*/ u8 unk160FF; + /*0x16100*/ u8 unk16100; + /*0x16101*/ u8 unk16101; + /*0x16102*/ u8 unk16102; + /*0x16103*/ u8 unk16103; + /*0x16104*/ u8 unk16104; + /*0x16105*/ u8 unk16105; + /*0x16106*/ u8 unk16106; + /*0x16107*/ u8 unk16107; + /*0x16108*/ u8 unk16108; + /*0x16109*/ u8 unk16109; + /*0x1610A*/ u8 unk1610A; + /*0x1610B*/ u8 unk1610B; + /*0x1610C*/ u8 unk1610C; + /*0x1610D*/ u8 unk1610D; + /*0x1610E*/ u8 unk1610E; + /*0x1610F*/ u8 unk1610F; + /*0x16110*/ u8 unk16110; + /*0x16111*/ u8 unk16111; + /*0x16112*/ u8 unk16112; + /*0x16113*/ u8 unk16113; + /*0x16114*/ u8 unk16114; + /*0x16115*/ u8 unk16115; + /*0x16116*/ u8 unk16116; + /*0x16117*/ u8 unk16117; + /*0x16118*/ u8 unk16118; + /*0x16119*/ u8 unk16119; + /*0x1611A*/ u8 unk1611A; + /*0x1611B*/ u8 unk1611B; + /*0x1611C*/ u8 unk1611C; + /*0x1611D*/ u8 unk1611D; + /*0x1611E*/ u8 unk1611E; + /*0x1611F*/ u8 unk1611F; + + //u8 filler2[0x72E]; /* 0x16A00 */ struct UnkBattleStruct1 unk_2016A00_2; }; @@ -532,15 +609,16 @@ extern struct Struct20238C8 gUnknown_020238C8; // TODO: move ewram to global.h extern u8 ewram[]; -#define BATTLE_STRUCT ((struct BattleStruct *) (ewram + 0x00000)) -#define AI_THINKING_STRUCT ((struct AI_ThinkingStruct *)(ewram + 0x16800)) -#define UNK_2016A00_STRUCT ((struct UnkBattleStruct1 *) (ewram + 0x16A00)) -#define AI_STACK ((struct AI_Stack *) (ewram + 0x16C00)) -#define AI_ARRAY_160CC ((struct SmallItemStruct *) (ewram + 0x160CC)) -#define B_FUNCTION_STACK ((struct funcStack *) (ewram + 0x17140)) -#define ewram17800 ((struct Struct2017800 *) (ewram + 0x17800)) -#define ewram17810 ((struct Struct2017810 *) (ewram + 0x17810)) -#define ewram17840 (*(struct Struct2017840 *) (ewram + 0x17840)) +#define BATTLE_STRUCT ((struct BattleStruct *) (ewram + 0x00000)) +#define AI_THINKING_STRUCT ((struct AI_ThinkingStruct *)(ewram + 0x16800)) +#define UNK_2016A00_STRUCT ((struct UnkBattleStruct1 *) (ewram + 0x16A00)) +#define AI_STACK ((struct AI_Stack *) (ewram + 0x16C00)) +#define AI_ARRAY_160CC ((struct SmallItemStruct *) (ewram + 0x160CC)) +#define B_BATTLESCRIPTS_STACK ((struct scriptsStack *) (ewram + 0x17110)) +#define B_FUNCTION_STACK ((struct funcStack *) (ewram + 0x17140)) +#define ewram17800 ((struct Struct2017800 *) (ewram + 0x17800)) +#define ewram17810 ((struct Struct2017810 *) (ewram + 0x17810)) +#define ewram17840 (*(struct Struct2017840 *) (ewram + 0x17840)) struct funcStack { @@ -548,6 +626,12 @@ struct funcStack u8 size; }; +struct scriptsStack +{ + u8* ptr[8]; + u8 size; +}; + extern u8 gBattleTextBuff1[]; //function declarations of buffer emits @@ -650,14 +734,14 @@ void TurnValuesCleanUp(u8); void SpecialStatusesClear(void); void sub_80138F0(void); void sub_80155A4(); -void CancelMultiTurnMoves(u8); +void CancelMultiTurnMoves(u8 bank); void PrepareStringBattle(); void sub_80156DC(); void sub_80157C4(u8 index); // asm/battle_3.o -u8 sub_8015A98(u8, u8, u8); -u8 UpdateTurnCounters(); +u8 CheckMoveLimitations(u8 bank, u8 unusableMoves, u8 check); +u8 UpdateTurnCounters(void); u8 TurnBasedEffects(); u8 sub_80170DC(); u8 sub_80173A4(); diff --git a/ld_script.txt b/ld_script.txt index c895c4d06..e6b31a528 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -53,6 +53,7 @@ SECTIONS { asm/battle_1.o(.text_800DC24); src/battle_2.o(.text); asm/battle_2.o(.text); + src/battle_3.o(.text); asm/battle_3.o(.text); src/battle_4.o(.text); asm/battle_5.o(.text); diff --git a/src/battle_3.c b/src/battle_3.c new file mode 100644 index 000000000..b1c6d9016 --- /dev/null +++ b/src/battle_3.c @@ -0,0 +1,450 @@ +#include "global.h" +#include "abilities.h" +#include "battle.h" +#include "moves.h" +#include "item.h" +#include "items.h" +#include "hold_effects.h" +#include "species.h" +#include "pokemon.h" +#include "data2.h" +#include "rng.h" +#include "text.h" + +extern u8* gBattlescriptCurrInstr; +extern u8 gActiveBank; +extern u8 gBattleBufferB[4][0x200]; +extern u8* gUnknown_02024C1C[4]; //battlescript location when you try to use a move you're not allowed to +extern u16 gLastUsedMove[4]; +extern struct BattlePokemon gBattleMons[4]; +extern struct BattleEnigmaBerry gEnigmaBerries[4]; +extern u8 gStringBank; +extern u16 gLastUsedItem; +extern u16 gCurrentMove; +extern const u32 gBitTable[]; +extern u16 gBattleTypeFlags; +extern u8 gNoOfAllBanks; +extern u32 gStatuses3[4]; +extern u8 gBankAttacker; +extern u8 gBankTarget; +extern u8 gTurnOrder[4]; +extern u16 gSideAffecting[2]; +extern u16 gBattleWeather; +extern void (*gBattleMainFunc)(void); +extern u8 gAbsentBankFlags; +extern u8 gBattleCommunication[]; + +u8 IsImprisoned(u8 bank, u16 move); +u8 GetBankByPlayerAI(u8 ID); +u8 GetBankIdentity(u8 bank); +u8 GetBankSide(u8 bank); +void b_call_bc_move_exec(u8* BS_ptr); + +extern u8 BattleScript_MoveSelectionDisabledMove[]; +extern u8 BattleScript_MoveSelectionTormented[]; +extern u8 BattleScript_MoveSelectionTaunted[]; +extern u8 BattleScript_MoveSelectionImprisoned[]; +extern u8 BattleScript_MoveSelectionChoiceBanded[]; +extern u8 BattleScript_MoveSelectionNoPP[]; +extern u8 BattleScript_NoMovesLeft[]; +extern u8 BattleScript_WishComesTrue[]; +extern u8 gUnknown_081D9030[]; +extern u8 gUnknown_081D8F62[]; +extern u8 gUnknown_081D8FFF[]; +extern u8 gUnknown_081D8F7D[]; +extern u8 gUnknown_081D9016[]; +extern u8 gUnknown_081D9008[]; +extern u8 gUnknown_081D9041[]; + +#define CHOICED_MOVE(bank)(((u16*)(&ewram[bank * 2 + 0x160e8]))) + +//array entries for battle communication +#define MOVE_EFFECT_BYTE 0x3 +#define MULTISTRING_CHOOSER 0x5 +#define MSG_DISPLAY 0x7 + +void b_movescr_stack_push(u8* BS_ptr) +{ + B_BATTLESCRIPTS_STACK->ptr[B_BATTLESCRIPTS_STACK->size++] = BS_ptr; +} + +void b_movescr_stack_push_cursor(void) +{ + B_BATTLESCRIPTS_STACK->ptr[B_BATTLESCRIPTS_STACK->size++] = gBattlescriptCurrInstr; +} + +void b_movescr_stack_pop_cursor(void) +{ + gBattlescriptCurrInstr = B_BATTLESCRIPTS_STACK->ptr[--B_BATTLESCRIPTS_STACK->size]; +} + +u8 sub_8015894(void) //msg can't select a move +{ + u8 limitations = 0; + u16 move = gBattleMons[gActiveBank].moves[gBattleBufferB[gActiveBank][2]]; + u8 holdEffect; + u16* choicedMove = CHOICED_MOVE(gActiveBank); + if (gDisableStructs[gActiveBank].disabledMove == move && move) + { + BATTLE_STRUCT->scriptingActive = gActiveBank; + gCurrentMove = move; + gUnknown_02024C1C[gActiveBank] = BattleScript_MoveSelectionDisabledMove; + limitations++; + } + if (move == gLastUsedMove[gActiveBank] && move != MOVE_STRUGGLE && gBattleMons[gActiveBank].status2 & STATUS2_TORMENT) + { + CancelMultiTurnMoves(gActiveBank); + gUnknown_02024C1C[gActiveBank] = BattleScript_MoveSelectionTormented; + limitations++; + } + if (gDisableStructs[gActiveBank].tauntTimer1 && gBattleMoves[move].power == 0) + { + gCurrentMove = move; + gUnknown_02024C1C[gActiveBank] = BattleScript_MoveSelectionTaunted; + limitations++; + } + if (IsImprisoned(gActiveBank, move)) + { + gCurrentMove = move; + gUnknown_02024C1C[gActiveBank] = BattleScript_MoveSelectionImprisoned; + limitations++; + } + if (gBattleMons[gActiveBank].item == ITEM_ENIGMA_BERRY) + holdEffect = gEnigmaBerries[gActiveBank].holdEffect; + else + holdEffect = ItemId_GetHoldEffect(gBattleMons[gActiveBank].item); + gStringBank = gActiveBank; + if (holdEffect == HOLD_EFFECT_CHOICE_BAND && *choicedMove != 0 && *choicedMove != 0xFFFF && *choicedMove != move) + { + gCurrentMove = *choicedMove; + gLastUsedItem = gBattleMons[gActiveBank].item; + gUnknown_02024C1C[gActiveBank] = BattleScript_MoveSelectionChoiceBanded; + limitations++; + } + if (gBattleMons[gActiveBank].pp[gBattleBufferB[gActiveBank][2]] == 0) + { + gUnknown_02024C1C[gActiveBank] = BattleScript_MoveSelectionNoPP; + limitations++; + } + return limitations; +} + +#define MOVE_LIMITATION_ZEROMOVE (1 << 0) +#define MOVE_LIMITATION_PP (1 << 1) +#define MOVE_LIMITATION_DISABLED (1 << 2) +#define MOVE_LIMITATION_TORMENTED (1 << 3) +#define MOVE_LIMITATION_TAUNT (1 << 4) +#define MOVE_LIMITATION_IMPRISION (1 << 5) + +u8 CheckMoveLimitations(u8 bank, u8 unusableMoves, u8 check) +{ + u8 holdEffect; + u16* choicedMove = CHOICED_MOVE(bank); + s32 i; + if (gBattleMons[bank].item == ITEM_ENIGMA_BERRY) + holdEffect = gEnigmaBerries[bank].holdEffect; + else + holdEffect = ItemId_GetHoldEffect(gBattleMons[bank].item); + gStringBank = bank; + for (i = 0; i < 4; i++) + { + if (gBattleMons[bank].moves[i] == 0 && check & MOVE_LIMITATION_ZEROMOVE) + unusableMoves |= gBitTable[i]; + if (gBattleMons[bank].pp[i] == 0 && check & MOVE_LIMITATION_PP) + unusableMoves |= gBitTable[i]; + if (gBattleMons[bank].moves[i] == gDisableStructs[bank].disabledMove && check & MOVE_LIMITATION_DISABLED) + unusableMoves |= gBitTable[i]; + if (gBattleMons[bank].moves[i] == gLastUsedMove[bank] && check & MOVE_LIMITATION_TORMENTED && gBattleMons[bank].status2 & STATUS2_TORMENT) + unusableMoves |= gBitTable[i]; + if (gDisableStructs[bank].tauntTimer1 && check & MOVE_LIMITATION_TAUNT && gBattleMoves[gBattleMons[bank].moves[i]].power == 0) + unusableMoves |= gBitTable[i]; + if (IsImprisoned(bank, gBattleMons[bank].moves[i]) && check & MOVE_LIMITATION_IMPRISION) + unusableMoves |= gBitTable[i]; + if (gDisableStructs[bank].encoreTimer1 && gDisableStructs[bank].encoredMove != gBattleMons[bank].moves[i]) + unusableMoves |= gBitTable[i]; + if (holdEffect == HOLD_EFFECT_CHOICE_BAND && *choicedMove != 0 && *choicedMove != 0xFFFF && *choicedMove != gBattleMons[bank].moves[i]) + unusableMoves |= gBitTable[i]; + } + return unusableMoves; +} + +bool8 AreAllMovesUnusable(void) +{ + u8 unusable; + unusable = CheckMoveLimitations(gActiveBank, 0, 0xFF); + if (unusable == 0xF) //all moves are unusable + { + gProtectStructs[gActiveBank].onlyStruggle = 1; + gUnknown_02024C1C[gActiveBank] = BattleScript_NoMovesLeft; + if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE) + gBattleBufferB[gActiveBank][3] = GetBankByPlayerAI((GetBankIdentity(gActiveBank) ^ 1) | (Random() & 2)); + else + gBattleBufferB[gActiveBank][3] = GetBankByPlayerAI(GetBankIdentity(gActiveBank) ^ 1); + } + else + gProtectStructs[gActiveBank].onlyStruggle = 0; + return (unusable == 0xF); +} + +u8 IsImprisoned(u8 bank, u16 move) +{ + u8 imprisionedMoves = 0; + u8 bankSide = GetBankSide(bank); + s32 i; + for (i = 0; i < gNoOfAllBanks; i++) + { + if (bankSide != GetBankSide(i) && gStatuses3[i] & STATUS3_IMPRISIONED) + { + s32 j; + for (j = 0; j < 4; j++) + { + if (move == gBattleMons[i].moves[j]) + break; + } + if (j < 4) + imprisionedMoves++; + } + } + return imprisionedMoves; +} +/* +u8 UpdateTurnCounters(void) +{ + u8 effect = 0; + s32 i; + for (gBankAttacker = 0; gBankAttacker < gNoOfAllBanks && gAbsentBankFlags & gBitTable[gBankAttacker]; gBankAttacker++) {} + for (gBankTarget = 0; gBankTarget < gNoOfAllBanks && gAbsentBankFlags & gBitTable[gBankTarget]; gBankTarget++) {} + do + { + switch (BATTLE_STRUCT->turncountersTracker) + { + case 0: + for (i = 0; i < gNoOfAllBanks; i++) + { + gTurnOrder[i] = i; + } + for (i = 0; i < gNoOfAllBanks - 1; i++) + { + s32 j; + for (j = i + 1; j < gNoOfAllBanks; j++) + { + if (b_first_side(gTurnOrder[i], gTurnOrder[j], 0)) + sub_8012FBC(i, j); + } + } + BATTLE_STRUCT->turncountersTracker++; + BATTLE_STRUCT->turnSideTracker = 0; + case 1: + while (BATTLE_STRUCT->turnSideTracker < 2) + { + gBankAttacker = BATTLE_STRUCT->turnSideTracker; + gActiveBank = BATTLE_STRUCT->turnSideTracker; + if (gSideAffecting[BATTLE_STRUCT->turnSideTracker] & SIDE_STATUS_REFLECT) + { + if (--gSideTimer[BATTLE_STRUCT->turnSideTracker].reflectTimer == 0) + { + gSideAffecting[BATTLE_STRUCT->turnSideTracker] &= ~SIDE_STATUS_REFLECT; + b_call_bc_move_exec(gUnknown_081D9030); + gBattleTextBuff1[0] = 0xFD; + gBattleTextBuff1[1] = 2; + gBattleTextBuff1[2] = MOVE_REFLECT; + gBattleTextBuff1[3] = MOVE_REFLECT >> 8; + gBattleTextBuff1[4] = EOS; + effect++; + } + } + BATTLE_STRUCT->turnSideTracker++; + if (effect) + break; + } + if (!effect) + { + BATTLE_STRUCT->turncountersTracker++; + BATTLE_STRUCT->turnSideTracker = 0; + } + break; + case 2: + while (BATTLE_STRUCT->turnSideTracker < 2) + { + gBankAttacker = BATTLE_STRUCT->turnSideTracker; + gActiveBank = BATTLE_STRUCT->turnSideTracker; + if (gSideAffecting[BATTLE_STRUCT->turnSideTracker] & SIDE_STATUS_LIGHTSCREEN) + { + if (--gSideTimer[BATTLE_STRUCT->turnSideTracker].lightscreenTimer == 0) + { + gSideAffecting[BATTLE_STRUCT->turnSideTracker] &= ~SIDE_STATUS_LIGHTSCREEN; + b_call_bc_move_exec(gUnknown_081D9030); + gBattleCommunication[MULTISTRING_CHOOSER] = BATTLE_STRUCT->turnSideTracker; + gBattleTextBuff1[0] = 0xFD; + gBattleTextBuff1[1] = 2; + gBattleTextBuff1[2] = MOVE_LIGHT_SCREEN; + gBattleTextBuff1[3] = MOVE_LIGHT_SCREEN >> 8; + gBattleTextBuff1[4] = EOS; + effect++; + } + } + BATTLE_STRUCT->turnSideTracker++; + if (effect) + break; + } + if (!effect) + { + BATTLE_STRUCT->turncountersTracker++; + BATTLE_STRUCT->turnSideTracker = 0; + } + break; + case 3: + while (BATTLE_STRUCT->turnSideTracker < 2) + { + gBankAttacker = BATTLE_STRUCT->turnSideTracker; + gActiveBank = BATTLE_STRUCT->turnSideTracker; + if (gSideTimer[BATTLE_STRUCT->turnSideTracker].mistTimer && --gSideTimer[BATTLE_STRUCT->turnSideTracker].mistTimer == 0) + { + gSideAffecting[BATTLE_STRUCT->turnSideTracker] &= ~SIDE_STATUS_MIST; + b_call_bc_move_exec(gUnknown_081D9030); + gBattleCommunication[MULTISTRING_CHOOSER] = BATTLE_STRUCT->turnSideTracker; + gBattleTextBuff1[0] = 0xFD; + gBattleTextBuff1[1] = 2; + gBattleTextBuff1[2] = MOVE_MIST; + gBattleTextBuff1[3] = MOVE_MIST >> 8; + gBattleTextBuff1[4] = EOS; + effect++; + } + BATTLE_STRUCT->turnSideTracker++; + if (effect) + break; + } + if (!effect) + { + BATTLE_STRUCT->turncountersTracker++; + BATTLE_STRUCT->turnSideTracker = 0; + } + break; + case 4: + while (BATTLE_STRUCT->turnSideTracker < 2) + { + gBankAttacker = BATTLE_STRUCT->turnSideTracker; + gActiveBank = BATTLE_STRUCT->turnSideTracker; + if (gSideAffecting[BATTLE_STRUCT->turnSideTracker] & SIDE_STATUS_SAFEGUARD) + { + if (--gSideTimer[BATTLE_STRUCT->turnSideTracker].safeguardTimer == 0) + { + gSideAffecting[BATTLE_STRUCT->turnSideTracker] &= ~SIDE_STATUS_SAFEGUARD; + b_call_bc_move_exec(gUnknown_081D9041); + effect++; + } + } + BATTLE_STRUCT->turnSideTracker++; + if (effect) + break; + } + if (!effect) + { + BATTLE_STRUCT->turncountersTracker++; + BATTLE_STRUCT->turnSideTracker = 0; + } + break; + case 5: + while (BATTLE_STRUCT->turnSideTracker < gNoOfAllBanks) + { + gActiveBank = gTurnOrder[BATTLE_STRUCT->turnSideTracker]; + if (gWishFutureKnock.wishCounter[BATTLE_STRUCT->turnSideTracker] && --gWishFutureKnock.wishCounter[BATTLE_STRUCT->turnSideTracker] == 0 && gBattleMons[BATTLE_STRUCT->turnSideTracker].hp) + { + gBankTarget = BATTLE_STRUCT->turnSideTracker; + b_call_bc_move_exec(BattleScript_WishComesTrue); + effect++; + } + BATTLE_STRUCT->turnSideTracker++; + if (effect) + break; + } + if (!effect) + { + BATTLE_STRUCT->turncountersTracker++; + } + break; + case 6: + if (gBattleWeather & WEATHER_RAIN_ANY) + { + if (!(gBattleWeather & WEATHER_RAIN_PERMANENT)) + { + if (--gWishFutureKnock.weatherDuration == 0) + { + gBattleWeather &= ~WEATHER_RAIN_TEMPORARY; + gBattleWeather &= ~WEATHER_RAIN_DOWNPOUR; + gBattleCommunication[MULTISTRING_CHOOSER] = 2; + } + else if (gBattleWeather & WEATHER_RAIN_DOWNPOUR) + gBattleCommunication[MULTISTRING_CHOOSER] = 1; + else + gBattleCommunication[MULTISTRING_CHOOSER] = 0; + } + else if (gBattleWeather & WEATHER_RAIN_DOWNPOUR) + gBattleCommunication[MULTISTRING_CHOOSER] = 1; + else + gBattleCommunication[MULTISTRING_CHOOSER] = 0; + b_call_bc_move_exec(gUnknown_081D8F62); + effect++; + } + BATTLE_STRUCT->turncountersTracker++; + break; + case 7: + if (gBattleWeather & WEATHER_SANDSTORM_ANY) + { + if (!(gBattleWeather & WEATHER_SANDSTORM_PERMANENT) && --gWishFutureKnock.weatherDuration == 0) + { + gBattleWeather &= ~WEATHER_SANDSTORM_TEMPORARY; + gBattlescriptCurrInstr = gUnknown_081D8FFF; + } + else + gBattlescriptCurrInstr = gUnknown_081D8F7D; + } + BATTLE_STRUCT->animArg1 = 0xD; + gBattleCommunication[MULTISTRING_CHOOSER] = 1; + b_call_bc_move_exec(gBattlescriptCurrInstr); + effect++; + BATTLE_STRUCT->turncountersTracker++; + break; + case 8: + if (gBattleWeather & WEATHER_SUN_ANY) + { + if (!(gBattleWeather & WEATHER_SUN_PERMANENT) && --gWishFutureKnock.weatherDuration == 0) + { + gBattleWeather &= ~WEATHER_SUN_TEMPORARY; + gBattlescriptCurrInstr = gUnknown_081D9016; + } + else + gBattlescriptCurrInstr = gUnknown_081D9008; + } + BATTLE_STRUCT->animArg1 = 0xD; + gBattleCommunication[MULTISTRING_CHOOSER] = 1; + b_call_bc_move_exec(gBattlescriptCurrInstr); + effect++; + BATTLE_STRUCT->turncountersTracker++; + break; + case 9: + if (gBattleWeather & WEATHER_HAIL) + { + if (--gWishFutureKnock.weatherDuration == 0) + { + gBattleWeather &= ~WEATHER_HAIL; + gBattlescriptCurrInstr = gUnknown_081D8FFF; + } + else + gBattlescriptCurrInstr = gUnknown_081D8F7D; + } + BATTLE_STRUCT->animArg1 = 0xD; + gBattleCommunication[MULTISTRING_CHOOSER] = 1; + b_call_bc_move_exec(gBattlescriptCurrInstr); + effect++; + BATTLE_STRUCT->turncountersTracker++; + break; + case 10: + effect++; + break; + } + } while (!effect); + return (gBattleMainFunc != BattleTurnPassed); +} + +*/ diff --git a/src/battle_4.c b/src/battle_4.c index d58ae4145..027a3f4f9 100644 --- a/src/battle_4.c +++ b/src/battle_4.c @@ -159,7 +159,7 @@ u8 CalculatePlayerPartyCount(void); u16 Sqrt(u32 num); u8 sub_809070C(u16 nationalNum, u32 TiD, u32 PiD); //task prepare poke dex display void sub_814A880(u8 a1, u8 a2); -u8 sub_8015A98(u8 bank, u8 unusable_moves, u8 flags); //choose move limitations +u8 CheckMoveLimitations(u8 bank, u8 unusable_moves, u8 flags); //choose move limitations void sub_801529C(u8 bank); bool8 IsLinkDoubleBattle(void); void sub_8094B6C(u8 bank, u8 partyID, u8 r2); @@ -5217,7 +5217,7 @@ static void atk15_seteffectwithchancetarget(void) else gBattlescriptCurrInstr++; gBattleCommunication[MOVE_EFFECT_BYTE] = 0; - BATTLE_STRUCT->filler2[0x3E] = 0; //TODO: to fix this later + BATTLE_STRUCT->unk16112 = 0; } static void atk16_seteffectprimary(void) @@ -5240,7 +5240,7 @@ static void atk18_status_effect_clear(void) gBattleCommunication[MOVE_EFFECT_BYTE] = 0; gBattlescriptCurrInstr += 2; - BATTLE_STRUCT->filler2[0x3E] = 0; //TODO: to fix this later + BATTLE_STRUCT->unk16112 = 0; } //Fuck this, Maybe later @@ -15582,7 +15582,7 @@ static void atkA9_sleeptalk_choose_move(void) || gBattleMons[gBankAttacker].moves[i] == MOVE_UPROAR || IsTwoTurnsMove(gBattleMons[gBankAttacker].moves[i])) unusable_moves |= gBitTable[i]; } - unusable_moves = sub_8015A98(gBankAttacker, unusable_moves, 0xFD); + unusable_moves = CheckMoveLimitations(gBankAttacker, unusable_moves, 0xFD); if (unusable_moves == 0xF) //all 4 moves cannot be chosen gBattlescriptCurrInstr += 5; else //at least one move can be chosen diff --git a/src/battle_ai.c b/src/battle_ai.c index a1cb805d9..0e20c6b05 100644 --- a/src/battle_ai.c +++ b/src/battle_ai.c @@ -301,7 +301,7 @@ void BattleAI_SetupAIData(void) for (i = 0; i < MAX_MON_MOVES; i++) AI_THINKING_STRUCT->score[i] = 100; - r7 = sub_8015A98(gActiveBank, 0, 0xFF); + r7 = CheckMoveLimitations(gActiveBank, 0, 0xFF); // probably sets up the moves to consider and ignores non-valid moves such as NO_MOVE or glitch moves. for (i = 0; i < MAX_MON_MOVES; i++) From 7b5f9c3d5e63dbb83d43515f16b718a1579e1624 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Mon, 24 Jul 2017 18:24:06 +0200 Subject: [PATCH 2/8] a loop problem --- asm/battle_3.s | 2303 ---------------------------------------------- include/battle.h | 24 +- src/battle_3.c | 415 ++++++++- src/battle_4.c | 15 +- 4 files changed, 396 insertions(+), 2361 deletions(-) diff --git a/asm/battle_3.s b/asm/battle_3.s index 222a4c8b2..a42fdcf00 100644 --- a/asm/battle_3.s +++ b/asm/battle_3.s @@ -7,2310 +7,7 @@ .text - thumb_func_start UpdateTurnCounters -UpdateTurnCounters: @ 8015DFC - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - movs r0, 0 - mov r9, r0 - ldr r1, _08015EA0 @ =gBankAttacker - mov r2, r9 - strb r2, [r1] - ldr r0, _08015EA4 @ =gNoOfAllBanks - ldrb r4, [r0] - adds r6, r1, 0 - mov r10, r0 - ldr r7, _08015EA8 @ =gBankTarget - ldr r3, _08015EAC @ =0x02000000 - mov r12, r3 - cmp r9, r4 - bcs _08015E50 - ldr r2, _08015EB0 @ =gAbsentBankFlags - ldrb r1, [r2] - ldr r5, _08015EB4 @ =gBitTable - ldr r0, [r5] - ands r1, r0 - cmp r1, 0 - beq _08015E50 - adds r3, r6, 0 -_08015E32: - ldrb r0, [r3] - adds r0, 0x1 - strb r0, [r3] - lsls r0, 24 - lsrs r0, 24 - cmp r0, r4 - bcs _08015E50 - ldrb r0, [r2] - ldrb r1, [r6] - lsls r1, 2 - adds r1, r5 - ldr r1, [r1] - ands r0, r1 - cmp r0, 0 - bne _08015E32 -_08015E50: - movs r0, 0 - strb r0, [r7] - mov r0, r10 - ldrb r4, [r0] - cmp r4, 0 - beq _08015E8A - ldr r2, _08015EB0 @ =gAbsentBankFlags - ldrb r1, [r2] - ldr r5, _08015EB4 @ =gBitTable - ldr r0, [r5] - ands r1, r0 - cmp r1, 0 - beq _08015E8A - adds r3, r7, 0 -_08015E6C: - ldrb r0, [r3] - adds r0, 0x1 - strb r0, [r3] - lsls r0, 24 - lsrs r0, 24 - cmp r0, r4 - bcs _08015E8A - ldrb r0, [r2] - ldrb r1, [r7] - lsls r1, 2 - adds r1, r5 - ldr r1, [r1] - ands r0, r1 - cmp r0, 0 - bne _08015E6C -_08015E8A: - ldr r0, _08015EB8 @ =0x0001600e - add r0, r12 - ldrb r0, [r0] - cmp r0, 0xA - bls _08015E96 - b _0801652A -_08015E96: - lsls r0, 2 - ldr r1, _08015EBC @ =_08015EC0 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .align 2, 0 -_08015EA0: .4byte gBankAttacker -_08015EA4: .4byte gNoOfAllBanks -_08015EA8: .4byte gBankTarget -_08015EAC: .4byte 0x02000000 -_08015EB0: .4byte gAbsentBankFlags -_08015EB4: .4byte gBitTable -_08015EB8: .4byte 0x0001600e -_08015EBC: .4byte _08015EC0 - .align 2, 0 -_08015EC0: - .4byte _08015EEC - .4byte _08015F74 - .4byte _08016034 - .4byte _080160F4 - .4byte _080161C8 - .4byte _08016274 - .4byte _08016324 - .4byte _080163A8 - .4byte _08016420 - .4byte _08016494 - .4byte _08016520 -_08015EEC: - movs r5, 0 - ldr r1, _08015F0C @ =gNoOfAllBanks - mov r10, r1 - ldrb r2, [r1] - cmp r5, r2 - bge _08015F06 - ldr r2, _08015F10 @ =gTurnOrder -_08015EFA: - adds r0, r5, r2 - strb r5, [r0] - adds r5, 0x1 - ldrb r3, [r1] - cmp r5, r3 - blt _08015EFA -_08015F06: - movs r5, 0 - b _08015F54 - .align 2, 0 -_08015F0C: .4byte gNoOfAllBanks -_08015F10: .4byte gTurnOrder -_08015F14: - adds r4, r5, 0x1 - adds r6, r4, 0 - ldrb r1, [r1] - cmp r6, r1 - bge _08015F52 - ldr r7, _08016004 @ =gTurnOrder - ldr r0, _08016008 @ =gNoOfAllBanks - mov r10, r0 - lsls r1, r5, 24 - mov r8, r1 -_08015F28: - adds r0, r5, r7 - ldrb r0, [r0] - adds r1, r4, r7 - ldrb r1, [r1] - movs r2, 0 - bl b_first_side - lsls r0, 24 - cmp r0, 0 - beq _08015F48 - lsls r1, r4, 24 - lsrs r1, 24 - mov r2, r8 - lsrs r0, r2, 24 - bl sub_8012FBC -_08015F48: - adds r4, 0x1 - ldr r0, _08016008 @ =gNoOfAllBanks - ldrb r0, [r0] - cmp r4, r0 - blt _08015F28 -_08015F52: - adds r5, r6, 0 -_08015F54: - mov r1, r10 - ldrb r0, [r1] - subs r0, 0x1 - cmp r5, r0 - blt _08015F14 - ldr r1, _0801600C @ =0x02000000 - ldr r3, _08016010 @ =0x0001600e - adds r2, r1, r3 - ldrb r0, [r2] - adds r0, 0x1 - movs r3, 0 - strb r0, [r2] - ldr r2, _08016014 @ =0x000160fc - adds r0, r1, r2 - strb r3, [r0] - mov r12, r1 -_08015F74: - ldr r1, _08016014 @ =0x000160fc - add r1, r12 - ldrb r0, [r1] - cmp r0, 0x1 - bls _08015F80 - b _08016236 -_08015F80: - ldr r3, _08016018 @ =gActiveBank - mov r8, r3 - adds r6, r1, 0 - movs r7, 0 - ldr r5, _0801601C @ =gBattleTextBuff1 -_08015F8A: - ldr r0, _08016020 @ =gBankAttacker - ldrb r4, [r6] - strb r4, [r0] - mov r0, r8 - strb r4, [r0] - ldr r0, _08016024 @ =gSideAffecting - lsls r2, r4, 1 - adds r3, r2, r0 - ldrh r1, [r3] - movs r0, 0x1 - ands r0, r1 - cmp r0, 0 - beq _08015FE8 - ldr r0, _08016028 @ =gSideTimer - adds r1, r2, r4 - lsls r1, 2 - adds r1, r0 - ldrb r0, [r1] - subs r0, 0x1 - strb r0, [r1] - movs r4, 0xFF - lsls r0, 24 - cmp r0, 0 - bne _08015FE8 - ldrh r0, [r3] - ldr r2, _0801602C @ =0x0000fffe - adds r1, r2, 0 - ands r0, r1 - strh r0, [r3] - ldr r0, _08016030 @ =gUnknown_081D9030 - bl b_call_bc_move_exec - movs r0, 0xFD - strb r0, [r5] - movs r0, 0x2 - strb r0, [r5, 0x1] - movs r0, 0x73 - strb r0, [r5, 0x2] - strb r7, [r5, 0x3] - ldrb r0, [r5, 0x4] - orrs r0, r4 - strb r0, [r5, 0x4] - mov r0, r9 - adds r0, 0x1 - lsls r0, 24 - lsrs r0, 24 - mov r9, r0 -_08015FE8: - ldrb r0, [r6] - adds r0, 0x1 - strb r0, [r6] - ldr r3, _0801600C @ =0x02000000 - mov r12, r3 - mov r1, r9 - cmp r1, 0 - beq _08015FFA - b _08016532 -_08015FFA: - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bls _08015F8A - b _08016236 - .align 2, 0 -_08016004: .4byte gTurnOrder -_08016008: .4byte gNoOfAllBanks -_0801600C: .4byte 0x02000000 -_08016010: .4byte 0x0001600e -_08016014: .4byte 0x000160fc -_08016018: .4byte gActiveBank -_0801601C: .4byte gBattleTextBuff1 -_08016020: .4byte gBankAttacker -_08016024: .4byte gSideAffecting -_08016028: .4byte gSideTimer -_0801602C: .4byte 0x0000fffe -_08016030: .4byte gUnknown_081D9030 -_08016034: - ldr r1, _080160CC @ =0x000160fc - add r1, r12 - ldrb r0, [r1] - cmp r0, 0x1 - bls _08016040 - b _08016182 -_08016040: - adds r7, r1, 0 - movs r3, 0x2 - mov r10, r3 - movs r0, 0 - mov r8, r0 - ldr r5, _080160D0 @ =gBattleTextBuff1 -_0801604C: - ldr r0, _080160D4 @ =gBankAttacker - ldrb r4, [r7] - strb r4, [r0] - ldr r1, _080160D8 @ =gActiveBank - strb r4, [r1] - ldr r0, _080160DC @ =gSideAffecting - lsls r2, r4, 1 - adds r3, r2, r0 - ldrh r1, [r3] - movs r0, 0x2 - ands r0, r1 - cmp r0, 0 - beq _080160B0 - ldr r0, _080160E0 @ =gSideTimer - adds r1, r2, r4 - lsls r1, 2 - adds r1, r0 - ldrb r0, [r1, 0x1] - subs r0, 0x1 - strb r0, [r1, 0x1] - movs r6, 0xFF - lsls r0, 24 - cmp r0, 0 - bne _080160B0 - ldrh r0, [r3] - ldr r2, _080160E4 @ =0x0000fffd - adds r1, r2, 0 - ands r0, r1 - strh r0, [r3] - ldr r0, _080160E8 @ =gUnknown_081D9030 - bl b_call_bc_move_exec - ldr r0, _080160EC @ =gBattleCommunication - strb r4, [r0, 0x5] - movs r0, 0xFD - strb r0, [r5] - mov r3, r10 - strb r3, [r5, 0x1] - movs r0, 0x71 - strb r0, [r5, 0x2] - mov r0, r8 - strb r0, [r5, 0x3] - ldrb r0, [r5, 0x4] - orrs r0, r6 - strb r0, [r5, 0x4] - mov r0, r9 - adds r0, 0x1 - lsls r0, 24 - lsrs r0, 24 - mov r9, r0 -_080160B0: - ldrb r0, [r7] - adds r0, 0x1 - strb r0, [r7] - ldr r1, _080160F0 @ =0x02000000 - mov r12, r1 - mov r2, r9 - cmp r2, 0 - beq _080160C2 - b _08016532 -_080160C2: - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bls _0801604C - b _08016182 - .align 2, 0 -_080160CC: .4byte 0x000160fc -_080160D0: .4byte gBattleTextBuff1 -_080160D4: .4byte gBankAttacker -_080160D8: .4byte gActiveBank -_080160DC: .4byte gSideAffecting -_080160E0: .4byte gSideTimer -_080160E4: .4byte 0x0000fffd -_080160E8: .4byte gUnknown_081D9030 -_080160EC: .4byte gBattleCommunication -_080160F0: .4byte 0x02000000 -_080160F4: - ldr r1, _0801619C @ =0x000160fc - add r1, r12 - ldrb r0, [r1] - cmp r0, 0x1 - bhi _08016182 - ldr r0, _080161A0 @ =gActiveBank - mov r10, r0 - adds r7, r1, 0 - movs r1, 0 - mov r8, r1 - ldr r5, _080161A4 @ =gBattleTextBuff1 -_0801610A: - ldr r0, _080161A8 @ =gBankAttacker - ldrb r4, [r7] - strb r4, [r0] - mov r2, r10 - strb r4, [r2] - ldr r1, _080161AC @ =gSideTimer - lsls r3, r4, 1 - adds r0, r3, r4 - lsls r0, 2 - adds r1, r0, r1 - ldrb r0, [r1, 0x2] - cmp r0, 0 - beq _08016168 - subs r0, 0x1 - strb r0, [r1, 0x2] - movs r6, 0xFF - lsls r0, 24 - cmp r0, 0 - bne _08016168 - ldr r2, _080161B0 @ =gSideAffecting - adds r2, r3, r2 - ldrh r0, [r2] - ldr r3, _080161B4 @ =0x0000feff - adds r1, r3, 0 - ands r0, r1 - strh r0, [r2] - ldr r0, _080161B8 @ =gUnknown_081D9030 - bl b_call_bc_move_exec - ldr r0, _080161BC @ =gBattleCommunication - strb r4, [r0, 0x5] - movs r0, 0xFD - strb r0, [r5] - movs r0, 0x2 - strb r0, [r5, 0x1] - movs r0, 0x36 - strb r0, [r5, 0x2] - mov r0, r8 - strb r0, [r5, 0x3] - ldrb r0, [r5, 0x4] - orrs r0, r6 - strb r0, [r5, 0x4] - mov r0, r9 - adds r0, 0x1 - lsls r0, 24 - lsrs r0, 24 - mov r9, r0 -_08016168: - ldrb r0, [r7] - adds r0, 0x1 - strb r0, [r7] - ldr r1, _080161C0 @ =0x02000000 - mov r12, r1 - mov r2, r9 - cmp r2, 0 - beq _0801617A - b _08016532 -_0801617A: - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bls _0801610A -_08016182: - mov r3, r9 - cmp r3, 0 - beq _0801618A - b _08016532 -_0801618A: - ldr r0, _080161C4 @ =0x0001600e - add r0, r12 - ldrb r1, [r0] - adds r1, 0x1 - strb r1, [r0] - ldr r0, _0801619C @ =0x000160fc - add r0, r12 - strb r3, [r0] - b _0801652A - .align 2, 0 -_0801619C: .4byte 0x000160fc -_080161A0: .4byte gActiveBank -_080161A4: .4byte gBattleTextBuff1 -_080161A8: .4byte gBankAttacker -_080161AC: .4byte gSideTimer -_080161B0: .4byte gSideAffecting -_080161B4: .4byte 0x0000feff -_080161B8: .4byte gUnknown_081D9030 -_080161BC: .4byte gBattleCommunication -_080161C0: .4byte 0x02000000 -_080161C4: .4byte 0x0001600e -_080161C8: - ldr r1, _08016250 @ =0x000160fc - add r1, r12 - ldrb r0, [r1] - cmp r0, 0x1 - bhi _08016236 - ldr r7, _08016254 @ =gActiveBank - adds r5, r1, 0 - ldr r6, _08016258 @ =gBankAttacker -_080161D8: - ldrb r4, [r5] - strb r4, [r6] - strb r4, [r7] - ldr r0, _0801625C @ =gSideAffecting - lsls r2, r4, 1 - adds r3, r2, r0 - ldrh r1, [r3] - movs r0, 0x20 - ands r0, r1 - cmp r0, 0 - beq _0801621C - ldr r0, _08016260 @ =gSideTimer - adds r1, r2, r4 - lsls r1, 2 - adds r1, r0 - ldrb r0, [r1, 0x7] - subs r0, 0x1 - strb r0, [r1, 0x7] - lsls r0, 24 - cmp r0, 0 - bne _0801621C - ldrh r0, [r3] - ldr r2, _08016264 @ =0x0000ffdf - adds r1, r2, 0 - ands r0, r1 - strh r0, [r3] - ldr r0, _08016268 @ =gUnknown_081D9041 - bl b_call_bc_move_exec - mov r0, r9 - adds r0, 0x1 - lsls r0, 24 - lsrs r0, 24 - mov r9, r0 -_0801621C: - ldrb r0, [r5] - adds r0, 0x1 - strb r0, [r5] - ldr r3, _0801626C @ =0x02000000 - mov r12, r3 - mov r1, r9 - cmp r1, 0 - beq _0801622E - b _08016532 -_0801622E: - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bls _080161D8 -_08016236: - mov r2, r9 - cmp r2, 0 - beq _0801623E - b _08016532 -_0801623E: - ldr r0, _08016270 @ =0x0001600e - add r0, r12 - ldrb r1, [r0] - adds r1, 0x1 - strb r1, [r0] - ldr r0, _08016250 @ =0x000160fc - add r0, r12 - strb r2, [r0] - b _0801652A - .align 2, 0 -_08016250: .4byte 0x000160fc -_08016254: .4byte gActiveBank -_08016258: .4byte gBankAttacker -_0801625C: .4byte gSideAffecting -_08016260: .4byte gSideTimer -_08016264: .4byte 0x0000ffdf -_08016268: .4byte gUnknown_081D9041 -_0801626C: .4byte 0x02000000 -_08016270: .4byte 0x0001600e -_08016274: - ldr r2, _080162FC @ =0x000160fc - add r2, r12 - ldr r1, _08016300 @ =gNoOfAllBanks - ldrb r0, [r2] - ldrb r1, [r1] - cmp r0, r1 - bcs _080162E8 - ldr r5, _08016304 @ =gActiveBank - adds r4, r2, 0 - ldr r6, _08016308 @ =gUnknown_02024DDC -_08016288: - ldr r1, _0801630C @ =gTurnOrder - ldrb r0, [r4] - adds r0, r1 - ldrb r0, [r0] - strb r0, [r5] - ldrb r0, [r5] - adds r1, r0, r6 - ldrb r0, [r1] - cmp r0, 0 - beq _080162CA - subs r0, 0x1 - strb r0, [r1] - lsls r0, 24 - cmp r0, 0 - bne _080162CA - ldr r1, _08016310 @ =gBattleMons - ldrb r2, [r5] - movs r0, 0x58 - muls r0, r2 - adds r0, r1 - ldrh r0, [r0, 0x28] - cmp r0, 0 - beq _080162CA - ldr r0, _08016314 @ =gBankTarget - strb r2, [r0] - ldr r0, _08016318 @ =BattleScript_WishComesTrue - bl b_call_bc_move_exec - mov r0, r9 - adds r0, 0x1 - lsls r0, 24 - lsrs r0, 24 - mov r9, r0 -_080162CA: - ldrb r0, [r4] - adds r0, 0x1 - strb r0, [r4] - ldr r3, _0801631C @ =0x02000000 - mov r12, r3 - mov r1, r9 - cmp r1, 0 - beq _080162DC - b _08016532 -_080162DC: - ldr r1, _08016300 @ =gNoOfAllBanks - lsls r0, 24 - lsrs r0, 24 - ldrb r1, [r1] - cmp r0, r1 - bcc _08016288 -_080162E8: - mov r2, r9 - cmp r2, 0 - beq _080162F0 - b _08016532 -_080162F0: - ldr r1, _08016320 @ =0x0001600e - add r1, r12 - ldrb r0, [r1] - adds r0, 0x1 - strb r0, [r1] - b _0801652A - .align 2, 0 -_080162FC: .4byte 0x000160fc -_08016300: .4byte gNoOfAllBanks -_08016304: .4byte gActiveBank -_08016308: .4byte gUnknown_02024DDC -_0801630C: .4byte gTurnOrder -_08016310: .4byte gBattleMons -_08016314: .4byte gBankTarget -_08016318: .4byte BattleScript_WishComesTrue -_0801631C: .4byte 0x02000000 -_08016320: .4byte 0x0001600e -_08016324: - ldr r3, _0801635C @ =gBattleWeather - ldrh r2, [r3] - movs r0, 0x7 - ands r0, r2 - cmp r0, 0 - bne _08016332 - b _080164F8 -_08016332: - movs r0, 0x4 - ands r0, r2 - cmp r0, 0 - bne _0801637E - ldr r1, _08016360 @ =gWishFutureKnock - adds r1, 0x28 - ldrb r0, [r1] - subs r0, 0x1 - strb r0, [r1] - lsls r0, 24 - cmp r0, 0 - bne _08016370 - ldr r0, _08016364 @ =0x0000fffe - ands r0, r2 - ldr r1, _08016368 @ =0x0000fffd - ands r0, r1 - strh r0, [r3] - ldr r1, _0801636C @ =gBattleCommunication - movs r0, 0x2 - strb r0, [r1, 0x5] - b _0801639C - .align 2, 0 -_0801635C: .4byte gBattleWeather -_08016360: .4byte gWishFutureKnock -_08016364: .4byte 0x0000fffe -_08016368: .4byte 0x0000fffd -_0801636C: .4byte gBattleCommunication -_08016370: - movs r0, 0x2 - ands r0, r2 - lsls r0, 16 - lsrs r1, r0, 16 - cmp r1, 0 - bne _0801638A - b _08016398 -_0801637E: - movs r0, 0x2 - ands r0, r2 - lsls r0, 16 - lsrs r1, r0, 16 - cmp r1, 0 - beq _08016398 -_0801638A: - ldr r1, _08016394 @ =gBattleCommunication - movs r0, 0x1 - strb r0, [r1, 0x5] - b _0801639C - .align 2, 0 -_08016394: .4byte gBattleCommunication -_08016398: - ldr r0, _080163A0 @ =gBattleCommunication - strb r1, [r0, 0x5] -_0801639C: - ldr r0, _080163A4 @ =gUnknown_081D8F62 - b _080164EA - .align 2, 0 -_080163A0: .4byte gBattleCommunication -_080163A4: .4byte gUnknown_081D8F62 -_080163A8: - ldr r3, _080163DC @ =gBattleWeather - ldrh r2, [r3] - movs r0, 0x18 - ands r0, r2 - cmp r0, 0 - bne _080163B6 - b _080164F8 -_080163B6: - movs r0, 0x10 - ands r0, r2 - cmp r0, 0 - bne _080163F0 - ldr r1, _080163E0 @ =gWishFutureKnock - adds r1, 0x28 - ldrb r0, [r1] - subs r0, 0x1 - strb r0, [r1] - lsls r0, 24 - cmp r0, 0 - bne _080163F0 - ldr r0, _080163E4 @ =0x0000fff7 - ands r0, r2 - strh r0, [r3] - ldr r1, _080163E8 @ =gBattlescriptCurrInstr - ldr r0, _080163EC @ =gUnknown_081D8FFF - b _080163F4 - .align 2, 0 -_080163DC: .4byte gBattleWeather -_080163E0: .4byte gWishFutureKnock -_080163E4: .4byte 0x0000fff7 -_080163E8: .4byte gBattlescriptCurrInstr -_080163EC: .4byte gUnknown_081D8FFF -_080163F0: - ldr r1, _0801640C @ =gBattlescriptCurrInstr - ldr r0, _08016410 @ =gUnknown_081D8F7D -_080163F4: - str r0, [r1] - adds r3, r1, 0 - ldr r1, _08016414 @ =0x02000000 - ldr r0, _08016418 @ =0x000160a4 - adds r1, r0 - movs r2, 0 - movs r0, 0xC - strb r0, [r1] - ldr r0, _0801641C @ =gBattleCommunication - strb r2, [r0, 0x5] - b _080164E8 - .align 2, 0 -_0801640C: .4byte gBattlescriptCurrInstr -_08016410: .4byte gUnknown_081D8F7D -_08016414: .4byte 0x02000000 -_08016418: .4byte 0x000160a4 -_0801641C: .4byte gBattleCommunication -_08016420: - ldr r3, _08016450 @ =gBattleWeather - ldrh r2, [r3] - movs r0, 0x60 - ands r0, r2 - cmp r0, 0 - beq _0801647C - movs r0, 0x40 - ands r0, r2 - cmp r0, 0 - bne _08016464 - ldr r1, _08016454 @ =gWishFutureKnock - adds r1, 0x28 - ldrb r0, [r1] - subs r0, 0x1 - strb r0, [r1] - lsls r0, 24 - cmp r0, 0 - bne _08016464 - ldr r0, _08016458 @ =0x0000ffdf - ands r0, r2 - strh r0, [r3] - ldr r1, _0801645C @ =gBattlescriptCurrInstr - ldr r0, _08016460 @ =gUnknown_081D9016 - b _08016468 - .align 2, 0 -_08016450: .4byte gBattleWeather -_08016454: .4byte gWishFutureKnock -_08016458: .4byte 0x0000ffdf -_0801645C: .4byte gBattlescriptCurrInstr -_08016460: .4byte gUnknown_081D9016 -_08016464: - ldr r1, _08016484 @ =gBattlescriptCurrInstr - ldr r0, _08016488 @ =gUnknown_081D9008 -_08016468: - str r0, [r1] - adds r3, r1, 0 - ldr r0, [r3] - bl b_call_bc_move_exec - mov r0, r9 - adds r0, 0x1 - lsls r0, 24 - lsrs r0, 24 - mov r9, r0 -_0801647C: - ldr r2, _0801648C @ =0x02000000 - ldr r0, _08016490 @ =0x0001600e - adds r1, r2, r0 - b _080164FE - .align 2, 0 -_08016484: .4byte gBattlescriptCurrInstr -_08016488: .4byte gUnknown_081D9008 -_0801648C: .4byte 0x02000000 -_08016490: .4byte 0x0001600e -_08016494: - ldr r3, _080164BC @ =gBattleWeather - ldrh r2, [r3] - movs r0, 0x80 - ands r0, r2 - cmp r0, 0 - beq _080164F8 - ldr r1, _080164C0 @ =gWishFutureKnock - adds r1, 0x28 - ldrb r0, [r1] - subs r0, 0x1 - strb r0, [r1] - lsls r0, 24 - cmp r0, 0 - bne _080164D0 - ldr r0, _080164C4 @ =0x0000ff7f - ands r0, r2 - strh r0, [r3] - ldr r1, _080164C8 @ =gBattlescriptCurrInstr - ldr r0, _080164CC @ =gUnknown_081D8FFF - b _080164D4 - .align 2, 0 -_080164BC: .4byte gBattleWeather -_080164C0: .4byte gWishFutureKnock -_080164C4: .4byte 0x0000ff7f -_080164C8: .4byte gBattlescriptCurrInstr -_080164CC: .4byte gUnknown_081D8FFF -_080164D0: - ldr r1, _08016508 @ =gBattlescriptCurrInstr - ldr r0, _0801650C @ =gUnknown_081D8F7D -_080164D4: - str r0, [r1] - adds r3, r1, 0 - ldr r0, _08016510 @ =0x02000000 - ldr r1, _08016514 @ =0x000160a4 - adds r0, r1 - movs r1, 0xD - strb r1, [r0] - ldr r1, _08016518 @ =gBattleCommunication - movs r0, 0x1 - strb r0, [r1, 0x5] -_080164E8: - ldr r0, [r3] -_080164EA: - bl b_call_bc_move_exec - mov r0, r9 - adds r0, 0x1 - lsls r0, 24 - lsrs r0, 24 - mov r9, r0 -_080164F8: - ldr r2, _08016510 @ =0x02000000 - ldr r3, _0801651C @ =0x0001600e - adds r1, r2, r3 -_080164FE: - ldrb r0, [r1] - adds r0, 0x1 - strb r0, [r1] - mov r12, r2 - b _0801652A - .align 2, 0 -_08016508: .4byte gBattlescriptCurrInstr -_0801650C: .4byte gUnknown_081D8F7D -_08016510: .4byte 0x02000000 -_08016514: .4byte 0x000160a4 -_08016518: .4byte gBattleCommunication -_0801651C: .4byte 0x0001600e -_08016520: - mov r0, r9 - adds r0, 0x1 - lsls r0, 24 - lsrs r0, 24 - mov r9, r0 -_0801652A: - mov r0, r9 - cmp r0, 0 - bne _08016532 - b _08015E8A -_08016532: - ldr r0, _08016550 @ =gBattleMainFunc - ldr r1, [r0] - ldr r0, _08016554 @ =BattleTurnPassed - eors r1, r0 - negs r0, r1 - orrs r0, r1 - lsrs r0, 31 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r1} - bx r1 - .align 2, 0 -_08016550: .4byte gBattleMainFunc -_08016554: .4byte BattleTurnPassed - thumb_func_end UpdateTurnCounters - thumb_func_start TurnBasedEffects -TurnBasedEffects: @ 8016558 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x8 - movs r0, 0 - mov r9, r0 - ldr r2, _08016578 @ =gHitMarker - ldr r0, [r2] - ldr r1, _0801657C @ =0x01000020 - orrs r0, r1 - str r0, [r2] - bl _08017088 - .align 2, 0 -_08016578: .4byte gHitMarker -_0801657C: .4byte 0x01000020 -_08016580: - ldr r3, _080165B4 @ =gActiveBank - ldr r4, _080165B8 @ =gBankAttacker - ldr r1, _080165BC @ =gTurnOrder - adds r5, r7, r2 - ldrb r0, [r5] - adds r0, r1 - ldrb r0, [r0] - strb r0, [r4] - strb r0, [r3] - ldr r0, _080165C0 @ =gAbsentBankFlags - ldrb r1, [r0] - ldr r2, _080165C4 @ =gBitTable - ldrb r0, [r3] - lsls r0, 2 - adds r0, r2 - ldr r0, [r0] - ands r1, r0 - adds r6, r3, 0 - cmp r1, 0 - beq _080165C8 - ldrb r0, [r5] - adds r0, 0x1 - strb r0, [r5] - bl _08017088 - .align 2, 0 -_080165B4: .4byte gActiveBank -_080165B8: .4byte gBankAttacker -_080165BC: .4byte gTurnOrder -_080165C0: .4byte gAbsentBankFlags -_080165C4: .4byte gBitTable -_080165C8: - movs r5, 0xB0 - lsls r5, 9 - adds r0, r7, r5 - ldrb r0, [r0] - cmp r0, 0x13 - bls _080165D8 - bl _08017078 -_080165D8: - lsls r0, 2 - ldr r1, _080165E4 @ =_080165E8 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .align 2, 0 -_080165E4: .4byte _080165E8 - .align 2, 0 -_080165E8: - .4byte _08016638 - .4byte _080166A8 - .4byte _080166D8 - .4byte _08016730 - .4byte _080167C8 - .4byte _08016828 - .4byte _080168C0 - .4byte _0801691C - .4byte _0801697C - .4byte _080169DC - .4byte _08016B78 - .4byte _08016CA0 - .4byte _08016D58 - .4byte _08016E30 - .4byte _08016EFC - .4byte _08016F20 - .4byte _08016F6C - .4byte _08016F9C - .4byte _08016704 - .4byte _08017064 -_08016638: - ldr r1, _08016694 @ =gStatuses3 - ldrb r3, [r6] - lsls r0, r3, 2 - adds r0, r1 - ldr r0, [r0] - movs r1, 0x80 - lsls r1, 3 - ands r0, r1 - cmp r0, 0 - beq _08016686 - ldr r0, _08016698 @ =gBattleMons - movs r1, 0x58 - muls r1, r3 - adds r0, r1, r0 - ldrh r2, [r0, 0x28] - ldrh r7, [r0, 0x2C] - cmp r2, r7 - beq _08016686 - cmp r2, 0 - beq _08016686 - ldr r1, _0801669C @ =gBattleMoveDamage - ldrh r0, [r0, 0x2C] - lsrs r0, 4 - str r0, [r1] - cmp r0, 0 - bne _08016670 - movs r0, 0x1 - str r0, [r1] -_08016670: - ldr r0, [r1] - negs r0, r0 - str r0, [r1] - ldr r0, _080166A0 @ =gUnknown_081D93D1 - bl b_call_bc_move_exec - mov r0, r9 - adds r0, 0x1 - lsls r0, 24 - lsrs r0, 24 - mov r9, r0 -_08016686: - ldr r1, _080166A4 @ =0x02000000 - movs r0, 0xB0 - lsls r0, 9 - adds r1, r0 - bl _08017072 - .align 2, 0 -_08016694: .4byte gStatuses3 -_08016698: .4byte gBattleMons -_0801669C: .4byte gBattleMoveDamage -_080166A0: .4byte gUnknown_081D93D1 -_080166A4: .4byte 0x02000000 -_080166A8: - ldrb r1, [r6] - movs r0, 0 - str r0, [sp] - movs r0, 0x1 - movs r2, 0 - movs r3, 0 - bl AbilityBattleEffects - lsls r0, 24 - cmp r0, 0 - beq _080166C8 - mov r0, r9 - adds r0, 0x1 - lsls r0, 24 - lsrs r0, 24 - mov r9, r0 -_080166C8: - ldr r1, _080166D4 @ =0x02000000 - movs r2, 0xB0 - lsls r2, 9 - adds r1, r2 - bl _08017072 - .align 2, 0 -_080166D4: .4byte 0x02000000 -_080166D8: - ldrb r1, [r6] - movs r0, 0x1 - movs r2, 0 - bl ItemBattleEffects - lsls r0, 24 - cmp r0, 0 - beq _080166F2 - mov r0, r9 - adds r0, 0x1 - lsls r0, 24 - lsrs r0, 24 - mov r9, r0 -_080166F2: - ldr r1, _08016700 @ =0x02000000 - movs r3, 0xB0 - lsls r3, 9 - adds r1, r3 - bl _08017072 - .align 2, 0 -_08016700: .4byte 0x02000000 -_08016704: - ldrb r1, [r6] - movs r0, 0x1 - movs r2, 0x1 - bl ItemBattleEffects - lsls r0, 24 - cmp r0, 0 - beq _0801671E - mov r0, r9 - adds r0, 0x1 - lsls r0, 24 - lsrs r0, 24 - mov r9, r0 -_0801671E: - ldr r1, _0801672C @ =0x02000000 - movs r5, 0xB0 - lsls r5, 9 - adds r1, r5 - bl _08017072 - .align 2, 0 -_0801672C: .4byte 0x02000000 -_08016730: - ldr r0, _080167A8 @ =gStatuses3 - ldrb r2, [r6] - lsls r1, r2, 2 - adds r1, r0 - ldr r1, [r1] - movs r0, 0x4 - ands r0, r1 - cmp r0, 0 - beq _0801679C - ldr r3, _080167AC @ =gBattleMons - movs r5, 0x3 - ands r5, r1 - movs r1, 0x58 - adds r0, r5, 0 - muls r0, r1 - adds r0, r3 - ldrh r0, [r0, 0x28] - cmp r0, 0 - beq _0801679C - adds r0, r2, 0 - muls r0, r1 - adds r0, r3 - ldrh r0, [r0, 0x28] - cmp r0, 0 - beq _0801679C - ldr r0, _080167B0 @ =gBankTarget - strb r5, [r0] - ldr r2, _080167B4 @ =gBattleMoveDamage - ldrb r0, [r6] - muls r0, r1 - adds r0, r3 - ldrh r0, [r0, 0x2C] - lsrs r0, 3 - str r0, [r2] - cmp r0, 0 - bne _0801677C - movs r0, 0x1 - str r0, [r2] -_0801677C: - ldr r1, _080167B8 @ =0x02000000 - ldr r7, _080167BC @ =0x000160a4 - adds r0, r1, r7 - strb r5, [r0] - ldrb r0, [r4] - ldr r2, _080167C0 @ =0x000160a5 - adds r1, r2 - strb r0, [r1] - ldr r0, _080167C4 @ =gUnknown_081D904B - bl b_call_bc_move_exec - mov r0, r9 - adds r0, 0x1 - lsls r0, 24 - lsrs r0, 24 - mov r9, r0 -_0801679C: - ldr r1, _080167B8 @ =0x02000000 - movs r3, 0xB0 - lsls r3, 9 - adds r1, r3 - bl _08017072 - .align 2, 0 -_080167A8: .4byte gStatuses3 -_080167AC: .4byte gBattleMons -_080167B0: .4byte gBankTarget -_080167B4: .4byte gBattleMoveDamage -_080167B8: .4byte 0x02000000 -_080167BC: .4byte 0x000160a4 -_080167C0: .4byte 0x000160a5 -_080167C4: .4byte gUnknown_081D904B -_080167C8: - ldr r2, _08016818 @ =gBattleMons - ldrb r1, [r6] - movs r0, 0x58 - adds r3, r1, 0 - muls r3, r0 - adds r0, r2, 0 - adds r0, 0x4C - adds r0, r3, r0 - ldr r0, [r0] - movs r1, 0x8 - ands r0, r1 - cmp r0, 0 - beq _0801680A - adds r1, r3, r2 - ldrh r0, [r1, 0x28] - cmp r0, 0 - beq _0801680A - ldr r2, _0801681C @ =gBattleMoveDamage - ldrh r0, [r1, 0x2C] - lsrs r0, 3 - str r0, [r2] - cmp r0, 0 - bne _080167FA - movs r0, 0x1 - str r0, [r2] -_080167FA: - ldr r0, _08016820 @ =gUnknown_081D9518 - bl b_call_bc_move_exec - mov r0, r9 - adds r0, 0x1 - lsls r0, 24 - lsrs r0, 24 - mov r9, r0 -_0801680A: - ldr r1, _08016824 @ =0x02000000 - movs r5, 0xB0 - lsls r5, 9 - adds r1, r5 - bl _08017072 - .align 2, 0 -_08016818: .4byte gBattleMons -_0801681C: .4byte gBattleMoveDamage -_08016820: .4byte gUnknown_081D9518 -_08016824: .4byte 0x02000000 -_08016828: - ldr r4, _080168B0 @ =gBattleMons - ldrb r0, [r6] - movs r7, 0x58 - mov r8, r7 - mov r2, r8 - muls r2, r0 - adds r3, r4, 0 - adds r3, 0x4C - adds r0, r2, r3 - ldr r0, [r0] - movs r1, 0x80 - ands r0, r1 - cmp r0, 0 - beq _080168A2 - adds r1, r2, r4 - ldrh r0, [r1, 0x28] - cmp r0, 0 - beq _080168A2 - ldr r5, _080168B4 @ =gBattleMoveDamage - ldrh r0, [r1, 0x2C] - lsrs r0, 4 - str r0, [r5] - cmp r0, 0 - bne _0801685C - movs r0, 0x1 - str r0, [r5] -_0801685C: - ldrb r0, [r6] - mov r1, r8 - muls r1, r0 - adds r0, r1, 0 - adds r2, r0, r3 - ldr r1, [r2] - movs r4, 0xF0 - lsls r4, 4 - adds r0, r1, 0 - ands r0, r4 - cmp r0, r4 - beq _0801687C - movs r7, 0x80 - lsls r7, 1 - adds r0, r1, r7 - str r0, [r2] -_0801687C: - ldrb r0, [r6] - mov r1, r8 - muls r1, r0 - adds r0, r1, 0 - adds r0, r3 - ldr r0, [r0] - ands r0, r4 - lsrs r0, 8 - ldr r1, [r5] - muls r0, r1 - str r0, [r5] - ldr r0, _080168B8 @ =gUnknown_081D9518 - bl b_call_bc_move_exec - mov r0, r9 - adds r0, 0x1 - lsls r0, 24 - lsrs r0, 24 - mov r9, r0 -_080168A2: - ldr r1, _080168BC @ =0x02000000 - movs r2, 0xB0 - lsls r2, 9 - adds r1, r2 - bl _08017072 - .align 2, 0 -_080168B0: .4byte gBattleMons -_080168B4: .4byte gBattleMoveDamage -_080168B8: .4byte gUnknown_081D9518 -_080168BC: .4byte 0x02000000 -_080168C0: - ldr r2, _0801690C @ =gBattleMons - ldrb r1, [r6] - movs r0, 0x58 - adds r3, r1, 0 - muls r3, r0 - adds r0, r2, 0 - adds r0, 0x4C - adds r0, r3, r0 - ldr r0, [r0] - movs r1, 0x10 - ands r0, r1 - cmp r0, 0 - beq _08016902 - adds r1, r3, r2 - ldrh r0, [r1, 0x28] - cmp r0, 0 - beq _08016902 - ldr r2, _08016910 @ =gBattleMoveDamage - ldrh r0, [r1, 0x2C] - lsrs r0, 3 - str r0, [r2] - cmp r0, 0 - bne _080168F2 - movs r0, 0x1 - str r0, [r2] -_080168F2: - ldr r0, _08016914 @ =gUnknown_081D953A - bl b_call_bc_move_exec - mov r0, r9 - adds r0, 0x1 - lsls r0, 24 - lsrs r0, 24 - mov r9, r0 -_08016902: - ldr r1, _08016918 @ =0x02000000 - movs r3, 0xB0 - lsls r3, 9 - adds r1, r3 - b _08017072 - .align 2, 0 -_0801690C: .4byte gBattleMons -_08016910: .4byte gBattleMoveDamage -_08016914: .4byte gUnknown_081D953A -_08016918: .4byte 0x02000000 -_0801691C: - ldr r2, _0801696C @ =gBattleMons - ldrb r1, [r6] - movs r0, 0x58 - adds r3, r1, 0 - muls r3, r0 - adds r0, r2, 0 - adds r0, 0x50 - adds r0, r3, r0 - ldr r0, [r0] - movs r1, 0x80 - lsls r1, 20 - ands r0, r1 - cmp r0, 0 - beq _08016960 - adds r1, r3, r2 - ldrh r0, [r1, 0x28] - cmp r0, 0 - beq _08016960 - ldr r2, _08016970 @ =gBattleMoveDamage - ldrh r0, [r1, 0x2C] - lsrs r0, 2 - str r0, [r2] - cmp r0, 0 - bne _08016950 - movs r0, 0x1 - str r0, [r2] -_08016950: - ldr r0, _08016974 @ =gUnknown_081D9613 - bl b_call_bc_move_exec - mov r0, r9 - adds r0, 0x1 - lsls r0, 24 - lsrs r0, 24 - mov r9, r0 -_08016960: - ldr r1, _08016978 @ =0x02000000 - movs r5, 0xB0 - lsls r5, 9 - adds r1, r5 - b _08017072 - .align 2, 0 -_0801696C: .4byte gBattleMons -_08016970: .4byte gBattleMoveDamage -_08016974: .4byte gUnknown_081D9613 -_08016978: .4byte 0x02000000 -_0801697C: - ldr r2, _080169CC @ =gBattleMons - ldrb r1, [r6] - movs r0, 0x58 - adds r3, r1, 0 - muls r3, r0 - adds r0, r2, 0 - adds r0, 0x50 - adds r0, r3, r0 - ldr r0, [r0] - movs r1, 0x80 - lsls r1, 21 - ands r0, r1 - cmp r0, 0 - beq _080169C0 - adds r1, r3, r2 - ldrh r0, [r1, 0x28] - cmp r0, 0 - beq _080169C0 - ldr r2, _080169D0 @ =gBattleMoveDamage - ldrh r0, [r1, 0x2C] - lsrs r0, 2 - str r0, [r2] - cmp r0, 0 - bne _080169B0 - movs r0, 0x1 - str r0, [r2] -_080169B0: - ldr r0, _080169D4 @ =gUnknown_081D9624 - bl b_call_bc_move_exec - mov r0, r9 - adds r0, 0x1 - lsls r0, 24 - lsrs r0, 24 - mov r9, r0 -_080169C0: - ldr r1, _080169D8 @ =0x02000000 - movs r7, 0xB0 - lsls r7, 9 - adds r1, r7 - b _08017072 - .align 2, 0 -_080169CC: .4byte gBattleMons -_080169D0: .4byte gBattleMoveDamage -_080169D4: .4byte gUnknown_081D9624 -_080169D8: .4byte 0x02000000 -_080169DC: - ldr r0, _08016A8C @ =gBattleMons - mov r8, r0 - ldrb r0, [r6] - movs r1, 0x58 - mov r10, r1 - mov r1, r10 - muls r1, r0 - mov r5, r8 - adds r5, 0x50 - adds r3, r1, r5 - ldr r2, [r3] - movs r4, 0xE0 - lsls r4, 8 - adds r0, r2, 0 - ands r0, r4 - cmp r0, 0 - beq _08016AF6 - mov r7, r8 - adds r0, r1, r7 - ldrh r0, [r0, 0x28] - cmp r0, 0 - beq _08016AF6 - ldr r1, _08016A90 @ =0xffffe000 - adds r0, r2, r1 - str r0, [r3] - ldrb r1, [r6] - mov r0, r10 - muls r0, r1 - adds r0, r5 - ldr r0, [r0] - ands r0, r4 - cmp r0, 0 - beq _08016AB4 - ldr r2, _08016A94 @ =0x02000000 - lsls r0, r1, 1 - ldr r4, _08016A98 @ =0x00016004 - adds r0, r4 - adds r0, r2 - ldrb r1, [r0] - ldr r3, _08016A9C @ =0x000160a4 - adds r0, r2, r3 - strb r1, [r0] - ldrb r0, [r6] - lsls r0, 1 - subs r3, 0x9F - adds r0, r3 - adds r0, r2 - ldrb r1, [r0] - ldr r5, _08016AA0 @ =0x000160a5 - adds r0, r2, r5 - strb r1, [r0] - ldr r1, _08016AA4 @ =gBattleTextBuff1 - movs r0, 0xFD - strb r0, [r1] - movs r0, 0x2 - strb r0, [r1, 0x1] - ldrb r0, [r6] - lsls r0, 1 - adds r0, r4 - adds r0, r2 - ldrb r0, [r0] - strb r0, [r1, 0x2] - ldrb r0, [r6] - lsls r0, 1 - adds r0, r3 - adds r0, r2 - ldrb r0, [r0] - strb r0, [r1, 0x3] - movs r0, 0xFF - strb r0, [r1, 0x4] - ldr r1, _08016AA8 @ =gBattlescriptCurrInstr - ldr r0, _08016AAC @ =gUnknown_081D95E2 - str r0, [r1] - ldr r2, _08016AB0 @ =gBattleMoveDamage - ldrb r0, [r6] - mov r7, r10 - muls r7, r0 - adds r0, r7, 0 - add r0, r8 - ldrh r0, [r0, 0x2C] - lsrs r0, 4 - str r0, [r2] - cmp r0, 0 - bne _08016AE6 - movs r0, 0x1 - str r0, [r2] - b _08016AE6 - .align 2, 0 -_08016A8C: .4byte gBattleMons -_08016A90: .4byte 0xffffe000 -_08016A94: .4byte 0x02000000 -_08016A98: .4byte 0x00016004 -_08016A9C: .4byte 0x000160a4 -_08016AA0: .4byte 0x000160a5 -_08016AA4: .4byte gBattleTextBuff1 -_08016AA8: .4byte gBattlescriptCurrInstr -_08016AAC: .4byte gUnknown_081D95E2 -_08016AB0: .4byte gBattleMoveDamage -_08016AB4: - ldr r1, _08016B00 @ =gBattleTextBuff1 - movs r0, 0xFD - strb r0, [r1] - movs r0, 0x2 - strb r0, [r1, 0x1] - ldr r2, _08016B04 @ =0x02000000 - ldrb r0, [r6] - lsls r0, 1 - ldr r3, _08016B08 @ =0x00016004 - adds r0, r3 - adds r0, r2 - ldrb r0, [r0] - strb r0, [r1, 0x2] - ldrb r0, [r6] - lsls r0, 1 - ldr r5, _08016B0C @ =0x00016005 - adds r0, r5 - adds r0, r2 - ldrb r0, [r0] - strb r0, [r1, 0x3] - movs r0, 0xFF - strb r0, [r1, 0x4] - ldr r1, _08016B10 @ =gBattlescriptCurrInstr - ldr r0, _08016B14 @ =gUnknown_081D95F4 - str r0, [r1] -_08016AE6: - ldr r0, [r1] - bl b_call_bc_move_exec - mov r0, r9 - adds r0, 0x1 - lsls r0, 24 - lsrs r0, 24 - mov r9, r0 -_08016AF6: - ldr r1, _08016B04 @ =0x02000000 - movs r7, 0xB0 - lsls r7, 9 - adds r1, r7 - b _08017072 - .align 2, 0 -_08016B00: .4byte gBattleTextBuff1 -_08016B04: .4byte 0x02000000 -_08016B08: .4byte 0x00016004 -_08016B0C: .4byte 0x00016005 -_08016B10: .4byte gBattlescriptCurrInstr -_08016B14: .4byte gUnknown_081D95F4 -_08016B18: - movs r0, 0x8 - negs r0, r0 - ands r4, r0 - str r4, [r2] - ldrb r0, [r6] - mov r2, r8 - muls r2, r0 - mov r0, r10 - adds r0, 0x50 - adds r2, r0 - ldr r0, [r2] - ldr r1, _08016B68 @ =0xf7ffffff - ands r0, r1 - str r0, [r2] - ldr r1, _08016B6C @ =gBattleCommunication - movs r0, 0x1 - strb r0, [r1, 0x5] - ldr r0, _08016B70 @ =gUnknown_081D950F - bl b_call_bc_move_exec - ldr r4, _08016B74 @ =gActiveBank - ldrb r0, [r6] - strb r0, [r4] - ldrb r0, [r4] - mov r1, r8 - muls r1, r0 - adds r0, r1, 0 - add r0, r9 - str r0, [sp] - movs r0, 0 - movs r1, 0x28 - movs r2, 0 - movs r3, 0x4 - bl EmitSetAttributes - ldrb r0, [r4] - bl MarkBufferBankForExecution - b _08016BE0 - .align 2, 0 -_08016B68: .4byte 0xf7ffffff -_08016B6C: .4byte gBattleCommunication -_08016B70: .4byte gUnknown_081D950F -_08016B74: .4byte gActiveBank -_08016B78: - ldr r2, _08016BF4 @ =gBattleMons - ldrb r1, [r6] - movs r0, 0x58 - muls r0, r1 - adds r1, r2, 0 - adds r1, 0x50 - adds r0, r1 - ldr r1, [r0] - movs r0, 0x70 - ands r1, r0 - adds r7, r2, 0 - cmp r1, 0 - beq _08016C82 - movs r0, 0 - strb r0, [r4] - mov r2, r8 - ldrb r1, [r2] - cmp r1, 0 - beq _08016BE0 - mov r10, r7 - adds r6, r4, 0 - movs r3, 0x58 - mov r8, r3 - movs r5, 0x4C - adds r5, r7 - mov r9, r5 - str r1, [sp, 0x4] - movs r0, 0x7 - mov r12, r0 -_08016BB2: - ldrb r1, [r6] - mov r3, r8 - muls r3, r1 - mov r5, r9 - adds r2, r3, r5 - ldr r4, [r2] - adds r0, r4, 0 - mov r5, r12 - ands r0, r5 - cmp r0, 0 - beq _08016BD2 - adds r0, r3, r7 - adds r0, 0x20 - ldrb r0, [r0] - cmp r0, 0x2B - bne _08016B18 -_08016BD2: - adds r0, r1, 0x1 - strb r0, [r6] - lsls r0, 24 - lsrs r0, 24 - ldr r1, [sp, 0x4] - cmp r0, r1 - bcc _08016BB2 -_08016BE0: - ldr r2, _08016BF8 @ =gBankAttacker - ldr r1, _08016BFC @ =gNoOfAllBanks - ldrb r0, [r2] - ldrb r1, [r1] - cmp r0, r1 - beq _08016C00 - movs r2, 0x2 - mov r9, r2 - b _0801707E - .align 2, 0 -_08016BF4: .4byte gBattleMons -_08016BF8: .4byte gBankAttacker -_08016BFC: .4byte gNoOfAllBanks -_08016C00: - ldr r5, _08016C38 @ =gActiveBank - ldrb r0, [r5] - strb r0, [r2] - ldr r2, _08016C3C @ =gBattleMons - ldrb r0, [r5] - movs r7, 0x58 - adds r1, r0, 0 - muls r1, r7 - adds r6, r2, 0 - adds r6, 0x50 - adds r1, r6 - ldr r0, [r1] - subs r0, 0x10 - str r0, [r1] - ldrb r0, [r5] - bl sub_8015660 - lsls r0, 24 - lsrs r4, r0, 24 - cmp r4, 0 - beq _08016C44 - ldrb r0, [r5] - bl CancelMultiTurnMoves - ldr r1, _08016C40 @ =gBattleCommunication - movs r0, 0x1 - strb r0, [r1, 0x5] - b _08016C78 - .align 2, 0 -_08016C38: .4byte gActiveBank -_08016C3C: .4byte gBattleMons -_08016C40: .4byte gBattleCommunication -_08016C44: - ldrb r3, [r5] - adds r0, r3, 0 - muls r0, r7 - adds r2, r0, r6 - ldr r0, [r2] - movs r1, 0x70 - ands r0, r1 - cmp r0, 0 - beq _08016C6C - ldr r0, _08016C68 @ =gBattleCommunication - strb r4, [r0, 0x5] - ldr r0, [r2] - movs r1, 0x80 - lsls r1, 5 - orrs r0, r1 - str r0, [r2] - b _08016C78 - .align 2, 0 -_08016C68: .4byte gBattleCommunication -_08016C6C: - ldr r1, _08016C94 @ =gBattleCommunication - movs r0, 0x1 - strb r0, [r1, 0x5] - adds r0, r3, 0 - bl CancelMultiTurnMoves -_08016C78: - ldr r0, _08016C98 @ =gUnknown_081D957E - bl b_call_bc_move_exec - movs r3, 0x1 - mov r9, r3 -_08016C82: - mov r5, r9 - cmp r5, 0x2 - bne _08016C8A - b _08017078 -_08016C8A: - ldr r1, _08016C9C @ =0x02000000 - movs r7, 0xB0 - lsls r7, 9 - adds r1, r7 - b _08017072 - .align 2, 0 -_08016C94: .4byte gBattleCommunication -_08016C98: .4byte gUnknown_081D957E -_08016C9C: .4byte 0x02000000 -_08016CA0: - ldr r1, _08016CD8 @ =gBattleMons - ldrb r0, [r6] - movs r7, 0x58 - muls r0, r7 - adds r5, r1, 0 - adds r5, 0x50 - adds r2, r0, r5 - ldr r1, [r2] - movs r4, 0xC0 - lsls r4, 4 - adds r0, r1, 0 - ands r0, r4 - cmp r0, 0 - beq _08016D3C - ldr r3, _08016CDC @ =0xfffffc00 - adds r0, r1, r3 - str r0, [r2] - ldrb r0, [r6] - bl sub_8015660 - lsls r0, 24 - cmp r0, 0 - beq _08016CE0 - ldrb r0, [r6] - bl CancelMultiTurnMoves - b _08016D3C - .align 2, 0 -_08016CD8: .4byte gBattleMons -_08016CDC: .4byte 0xfffffc00 -_08016CE0: - ldrb r0, [r6] - muls r0, r7 - adds r2, r0, r5 - ldr r1, [r2] - adds r0, r1, 0 - ands r0, r4 - cmp r0, 0 - bne _08016D3C - movs r0, 0x80 - lsls r0, 5 - ands r0, r1 - cmp r0, 0 - beq _08016D3C - ldr r0, _08016D48 @ =0xffffefff - ands r1, r0 - str r1, [r2] - ldrb r0, [r6] - muls r0, r7 - adds r0, r5 - ldr r0, [r0] - movs r4, 0x7 - ands r0, r4 - cmp r0, 0 - bne _08016D3C - ldr r1, _08016D4C @ =gBattleCommunication - movs r0, 0x47 - strb r0, [r1, 0x3] - movs r0, 0x1 - movs r1, 0 - bl SetMoveEffect - ldrb r0, [r6] - muls r0, r7 - adds r0, r5 - ldr r0, [r0] - ands r0, r4 - cmp r0, 0 - beq _08016D32 - ldr r0, _08016D50 @ =gUnknown_081D9587 - bl b_call_bc_move_exec -_08016D32: - mov r0, r9 - adds r0, 0x1 - lsls r0, 24 - lsrs r0, 24 - mov r9, r0 -_08016D3C: - ldr r1, _08016D54 @ =0x02000000 - movs r5, 0xB0 - lsls r5, 9 - adds r1, r5 - b _08017072 - .align 2, 0 -_08016D48: .4byte 0xffffefff -_08016D4C: .4byte gBattleCommunication -_08016D50: .4byte gUnknown_081D9587 -_08016D54: .4byte 0x02000000 -_08016D58: - ldr r0, _08016DD4 @ =gDisableStructs - ldrb r3, [r6] - lsls r1, r3, 3 - subs r1, r3 - lsls r1, 2 - adds r5, r1, r0 - ldrb r1, [r5, 0xB] - lsls r1, 28 - adds r7, r0, 0 - cmp r1, 0 - beq _08016E1E - movs r4, 0 - ldr r2, _08016DD8 @ =gBattleMons - movs r0, 0x58 - adds r1, r3, 0 - muls r1, r0 - adds r2, 0xC - adds r1, r2 - ldrh r0, [r5, 0x4] - ldrh r1, [r1] - cmp r0, r1 - beq _08016DAC - mov r12, r7 - mov r8, r2 - adds r5, r6, 0 - movs r3, 0x58 -_08016D8C: - adds r4, 0x1 - cmp r4, 0x3 - bgt _08016DAC - ldrb r2, [r5] - lsls r1, r2, 3 - subs r1, r2 - lsls r1, 2 - add r1, r12 - lsls r0, r4, 1 - muls r2, r3 - adds r0, r2 - add r0, r8 - ldrh r1, [r1, 0x4] - ldrh r0, [r0] - cmp r1, r0 - bne _08016D8C -_08016DAC: - cmp r4, 0x4 - bne _08016DDC - ldrb r1, [r6] - lsls r0, r1, 3 - subs r0, r1 - lsls r0, 2 - adds r0, r7 - movs r1, 0 - strh r1, [r0, 0x4] - ldrb r0, [r6] - lsls r1, r0, 3 - subs r1, r0 - lsls r1, 2 - adds r1, r7 - ldrb r2, [r1, 0xB] - movs r0, 0x10 - negs r0, r0 - ands r0, r2 - strb r0, [r1, 0xB] - b _08016E1E - .align 2, 0 -_08016DD4: .4byte gDisableStructs -_08016DD8: .4byte gBattleMons -_08016DDC: - ldrb r0, [r6] - lsls r2, r0, 3 - subs r2, r0 - lsls r2, 2 - adds r2, r7 - ldrb r3, [r2, 0xB] - lsls r1, r3, 28 - lsrs r1, 28 - subs r1, 0x1 - movs r0, 0xF - ands r1, r0 - movs r0, 0x10 - negs r0, r0 - ands r0, r3 - orrs r0, r1 - strb r0, [r2, 0xB] - adds r2, r1, 0 - cmp r2, 0 - bne _08016E1E - ldrb r1, [r6] - lsls r0, r1, 3 - subs r0, r1 - lsls r0, 2 - adds r0, r7 - strh r2, [r0, 0x4] - ldr r0, _08016E28 @ =gUnknown_081D9148 - bl b_call_bc_move_exec - mov r0, r9 - adds r0, 0x1 - lsls r0, 24 - lsrs r0, 24 - mov r9, r0 -_08016E1E: - ldr r1, _08016E2C @ =0x02000000 - movs r7, 0xB0 - lsls r7, 9 - adds r1, r7 - b _08017072 - .align 2, 0 -_08016E28: .4byte gUnknown_081D9148 -_08016E2C: .4byte 0x02000000 -_08016E30: - ldr r3, _08016E7C @ =gDisableStructs - ldrb r1, [r6] - lsls r0, r1, 3 - subs r0, r1 - lsls r0, 2 - adds r2, r0, r3 - ldrb r5, [r2, 0xE] - lsls r4, r5, 28 - cmp r4, 0 - beq _08016EE8 - ldr r0, _08016E80 @ =gBattleMons - mov r8, r0 - ldrb r0, [r2, 0xC] - lsls r0, 1 - movs r7, 0x58 - muls r1, r7 - adds r0, r1 - mov r1, r8 - adds r1, 0xC - adds r0, r1 - ldrh r0, [r0] - ldrh r1, [r2, 0x6] - cmp r0, r1 - beq _08016E84 - movs r0, 0 - strh r0, [r2, 0x6] - ldrb r0, [r6] - lsls r1, r0, 3 - subs r1, r0 - lsls r1, 2 - adds r1, r3 - ldrb r2, [r1, 0xE] - movs r0, 0x10 - negs r0, r0 - ands r0, r2 - strb r0, [r1, 0xE] - b _08016EE8 - .align 2, 0 -_08016E7C: .4byte gDisableStructs -_08016E80: .4byte gBattleMons -_08016E84: - lsrs r1, r4, 28 - subs r1, 0x1 - movs r0, 0xF - ands r1, r0 - movs r4, 0x10 - negs r4, r4 - adds r0, r4, 0 - ands r0, r5 - orrs r0, r1 - strb r0, [r2, 0xE] - cmp r1, 0 - beq _08016EB8 - ldrb r1, [r6] - lsls r0, r1, 3 - subs r0, r1 - lsls r0, 2 - adds r0, r3 - muls r1, r7 - ldrb r0, [r0, 0xC] - adds r1, r0 - mov r0, r8 - adds r0, 0x24 - adds r1, r0 - ldrb r0, [r1] - cmp r0, 0 - bne _08016EE8 -_08016EB8: - ldrb r1, [r6] - lsls r0, r1, 3 - subs r0, r1 - lsls r0, 2 - adds r0, r3 - movs r1, 0 - strh r1, [r0, 0x6] - ldrb r0, [r6] - lsls r1, r0, 3 - subs r1, r0 - lsls r1, 2 - adds r1, r3 - ldrb r2, [r1, 0xE] - adds r0, r4, 0 - ands r0, r2 - strb r0, [r1, 0xE] - ldr r0, _08016EF4 @ =gUnknown_081D914F - bl b_call_bc_move_exec - mov r0, r9 - adds r0, 0x1 - lsls r0, 24 - lsrs r0, 24 - mov r9, r0 -_08016EE8: - ldr r1, _08016EF8 @ =0x02000000 - movs r2, 0xB0 - lsls r2, 9 - adds r1, r2 - b _08017072 - .align 2, 0 -_08016EF4: .4byte gUnknown_081D914F -_08016EF8: .4byte 0x02000000 -_08016EFC: - ldr r0, _08016F1C @ =gStatuses3 - ldrb r1, [r6] - lsls r1, 2 - adds r1, r0 - ldr r2, [r1] - movs r0, 0x18 - ands r0, r2 - cmp r0, 0 - beq _08016F14 - adds r0, r2, 0 - subs r0, 0x8 - str r0, [r1] -_08016F14: - movs r1, 0xB0 - lsls r1, 9 - b _08017070 - .align 2, 0 -_08016F1C: .4byte gStatuses3 -_08016F20: - ldr r2, _08016F60 @ =gDisableStructs - ldrb r1, [r6] - lsls r0, r1, 3 - subs r0, r1 - lsls r0, 2 - adds r3, r0, r2 - ldrb r2, [r3, 0x12] - lsls r1, r2, 28 - cmp r1, 0 - beq _08016F5A - lsrs r1, 28 - subs r1, 0x1 - movs r0, 0xF - ands r1, r0 - movs r0, 0x10 - negs r0, r0 - ands r0, r2 - orrs r0, r1 - strb r0, [r3, 0x12] - cmp r1, 0 - bne _08016F5A - ldr r0, _08016F64 @ =gStatuses3 - ldrb r2, [r6] - lsls r2, 2 - adds r2, r0 - ldr r0, [r2] - ldr r1, _08016F68 @ =0xfffffdff - ands r0, r1 - str r0, [r2] -_08016F5A: - movs r1, 0xB0 - lsls r1, 9 - b _08017070 - .align 2, 0 -_08016F60: .4byte gDisableStructs -_08016F64: .4byte gStatuses3 -_08016F68: .4byte 0xfffffdff -_08016F6C: - ldr r2, _08016F98 @ =gDisableStructs - ldrb r1, [r6] - lsls r0, r1, 3 - subs r0, r1 - lsls r0, 2 - adds r3, r0, r2 - ldrb r2, [r3, 0x13] - lsls r1, r2, 28 - cmp r1, 0 - beq _08016F92 - lsrs r1, 28 - subs r1, 0x1 - movs r0, 0xF - ands r1, r0 - movs r0, 0x10 - negs r0, r0 - ands r0, r2 - orrs r0, r1 - strb r0, [r3, 0x13] -_08016F92: - movs r1, 0xB0 - lsls r1, 9 - b _08017070 - .align 2, 0 -_08016F98: .4byte gDisableStructs -_08016F9C: - ldr r4, _0801704C @ =gStatuses3 - ldrb r0, [r6] - lsls r0, 2 - adds r2, r0, r4 - ldr r1, [r2] - movs r3, 0xC0 - lsls r3, 5 - adds r0, r1, 0 - ands r0, r3 - cmp r0, 0 - beq _08017042 - ldr r5, _08017050 @ =0xfffff800 - adds r0, r1, r5 - str r0, [r2] - ldrb r2, [r6] - lsls r0, r2, 2 - adds r0, r4 - ldr r0, [r0] - ands r0, r3 - cmp r0, 0 - bne _08017042 - ldr r3, _08017054 @ =gBattleMons - movs r5, 0x58 - adds r1, r2, 0 - muls r1, r5 - adds r4, r3, 0 - adds r4, 0x4C - adds r0, r1, r4 - ldrb r0, [r0] - cmp r0, 0 - bne _08017042 - adds r0, r1, r3 - adds r0, 0x20 - ldrb r0, [r0] - cmp r0, 0x48 - beq _08017042 - cmp r0, 0xF - beq _08017042 - adds r0, r2, 0 - bl sub_8025A44 - lsls r0, 24 - cmp r0, 0 - bne _08017042 - ldrb r0, [r6] - bl CancelMultiTurnMoves - bl Random - ldrb r1, [r6] - adds r2, r1, 0 - muls r2, r5 - adds r2, r4 - movs r1, 0x3 - ands r1, r0 - adds r1, 0x2 - ldr r0, [r2] - orrs r0, r1 - str r0, [r2] - ldrb r0, [r6] - muls r0, r5 - adds r0, r4 - str r0, [sp] - movs r0, 0 - movs r1, 0x28 - movs r2, 0 - movs r3, 0x4 - bl EmitSetAttributes - ldrb r0, [r6] - bl MarkBufferBankForExecution - ldr r1, _08017058 @ =gEffectBank - ldrb r0, [r6] - strb r0, [r1] - ldr r0, _0801705C @ =gUnknown_081D964C - bl b_call_bc_move_exec - mov r0, r9 - adds r0, 0x1 - lsls r0, 24 - lsrs r0, 24 - mov r9, r0 -_08017042: - ldr r1, _08017060 @ =0x02000000 - movs r7, 0xB0 - lsls r7, 9 - adds r1, r7 - b _08017072 - .align 2, 0 -_0801704C: .4byte gStatuses3 -_08017050: .4byte 0xfffff800 -_08017054: .4byte gBattleMons -_08017058: .4byte gEffectBank -_0801705C: .4byte gUnknown_081D964C -_08017060: .4byte 0x02000000 -_08017064: - movs r1, 0xB0 - lsls r1, 9 - add r1, r10 - movs r0, 0 - strb r0, [r1] - ldr r1, _08017084 @ =0x00016001 -_08017070: - add r1, r10 -_08017072: - ldrb r0, [r1] - adds r0, 0x1 - strb r0, [r1] -_08017078: - mov r0, r9 - cmp r0, 0 - beq _08017088 -_0801707E: - mov r0, r9 - b _080170B8 - .align 2, 0 -_08017084: .4byte 0x00016001 -_08017088: - ldr r7, _080170C8 @ =0x02000000 - ldr r2, _080170CC @ =0x00016001 - adds r0, r7, r2 - ldr r1, _080170D0 @ =gNoOfAllBanks - ldrb r0, [r0] - mov r10, r7 - mov r8, r1 - ldrb r1, [r1] - cmp r0, r1 - bcs _080170AC - movs r3, 0xB0 - lsls r3, 9 - adds r0, r7, r3 - ldrb r0, [r0] - cmp r0, 0x13 - bhi _080170AC - bl _08016580 -_080170AC: - ldr r0, _080170D4 @ =gHitMarker - ldr r1, [r0] - ldr r2, _080170D8 @ =0xfeffffdf - ands r1, r2 - str r1, [r0] - movs r0, 0 -_080170B8: - add sp, 0x8 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r1} - bx r1 - .align 2, 0 -_080170C8: .4byte 0x02000000 -_080170CC: .4byte 0x00016001 -_080170D0: .4byte gNoOfAllBanks -_080170D4: .4byte gHitMarker -_080170D8: .4byte 0xfeffffdf - thumb_func_end TurnBasedEffects thumb_func_start sub_80170DC sub_80170DC: @ 80170DC diff --git a/include/battle.h b/include/battle.h index 92e2242b7..0aadd148f 100644 --- a/include/battle.h +++ b/include/battle.h @@ -105,6 +105,18 @@ #define SIDE_STATUS_MIST (1 << 8) #define SIDE_STATUS_SPIKES_DAMAGED (1 << 9) +#define ABILITYEFFECT_ENDTURN 0x1 +#define ABILITYEFFECT_CONTACT 0x4 +#define ABILITYEFFECT_IMMUNITY 0x5 +#define ABILITYEFFECT_SYNCHRONIZE 0x7 +#define ABILITYEFFECT_ATK_SYNCHRONIZE 0x8 +#define ABILITYEFFECT_CHECK_OTHER_SIDE 0xC +#define ABILITYEFFECT_CHECK_BANK_SIDE 0xD +#define ABILITYEFFECT_COUNT_OTHER_SIZE 0x10 +#define ABILITYEFFECT_COUNT_BANK_SIDE 0x11 +#define ABILITYEFFECT_COUNT_ON_FIELD 0x12 +#define ABILITYEFFECT_CHECK_ON_FIELD 0x13 + #define MAX_TRAINER_ITEMS 4 #define MAX_MON_MOVES 4 #define MAX_BANKS_BATTLE 4 @@ -172,7 +184,9 @@ struct BattleStruct /* 0x2000000 */ u8 filler0[0x15DDE]; /*0x15DDE*/ u8 unk15DDE; /*0x15DDF*/ u8 unk15DDF; - /*0x15DE0*/ u8 filler15DE0[0x222]; + /*0x15DE0*/ u8 filler15DE0[0x220]; + /*0x16000*/ u8 turnEffectsTracker; + /*0x16001*/ u8 turnEffectsBank; /*0x16002*/ u8 animTurn; /*0x16003*/ u8 scriptingActive; /*0x16004*/ u8 wrappedMove1[4]; @@ -403,7 +417,7 @@ struct BattleStruct /* 0x2000000 */ /*0x1611D*/ u8 unk1611D; /*0x1611E*/ u8 unk1611E; /*0x1611F*/ u8 unk1611F; - + //u8 filler2[0x72E]; /* 0x16A00 */ struct UnkBattleStruct1 unk_2016A00_2; }; @@ -593,7 +607,7 @@ struct WishFutureKnock u8 wishCounter[MAX_BANKS_BATTLE]; u8 wishUserID[MAX_BANKS_BATTLE]; u8 weatherDuration; - u8 knockedOffPokes[2]; + u16 knockedOffPokes; }; extern struct UnkBattleStruct1 unk_2016A00; @@ -745,8 +759,8 @@ u8 UpdateTurnCounters(void); u8 TurnBasedEffects(); u8 sub_80170DC(); u8 sub_80173A4(); -u8 AbilityBattleEffects(u8, u8, u8, u8, u16); -u8 ItemBattleEffects(); +u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 move); +u8 ItemBattleEffects(u8 caseID, u8 bank, bool8 moveTurn); // asm/battle_4.o void AI_CalcDmg(u8, u8); diff --git a/src/battle_3.c b/src/battle_3.c index b1c6d9016..5c6bc8b07 100644 --- a/src/battle_3.c +++ b/src/battle_3.c @@ -33,12 +33,18 @@ extern u16 gBattleWeather; extern void (*gBattleMainFunc)(void); extern u8 gAbsentBankFlags; extern u8 gBattleCommunication[]; +extern u32 gHitMarker; +extern u8 gEffectBank; +extern s32 gBattleMoveDamage; u8 IsImprisoned(u8 bank, u16 move); u8 GetBankByPlayerAI(u8 ID); u8 GetBankIdentity(u8 bank); u8 GetBankSide(u8 bank); void b_call_bc_move_exec(u8* BS_ptr); +bool8 sub_8015660(u8 bank); //check if a move failed +void SetMoveEffect(bool8 primary, u8 certainArg); +bool8 sub_8025A44(u8 bank); //uproar wakeup check extern u8 BattleScript_MoveSelectionDisabledMove[]; extern u8 BattleScript_MoveSelectionTormented[]; @@ -56,6 +62,21 @@ extern u8 gUnknown_081D9016[]; extern u8 gUnknown_081D9008[]; extern u8 gUnknown_081D9041[]; +extern u8 gUnknown_081D93D1[]; //ingrain bs +extern u8 gUnknown_081D904B[]; //leech seed BS +extern u8 gUnknown_081D9518[]; //poison dmg BS +extern u8 gUnknown_081D953A[]; //burn dmg BS +extern u8 gUnknown_081D9613[]; //nightmare dmg BS +extern u8 gUnknown_081D9624[]; //curse dmg BS +extern u8 gUnknown_081D95E2[]; //wrap dmg BS +extern u8 gUnknown_081D95F4[]; //wrap ends BS +extern u8 gUnknown_081D950F[]; //uproar wakeup BS +extern u8 gUnknown_081D957E[]; //uproar BS +extern u8 gUnknown_081D9587[]; //thrash confusion BS +extern u8 gUnknown_081D9148[]; //disabled no more BS +extern u8 gUnknown_081D914F[]; //encored no more BS +extern u8 gUnknown_081D964C[]; //yawn sleep BS + #define CHOICED_MOVE(bank)(((u16*)(&ewram[bank * 2 + 0x160e8]))) //array entries for battle communication @@ -207,15 +228,23 @@ u8 IsImprisoned(u8 bank, u16 move) } return imprisionedMoves; } -/* + u8 UpdateTurnCounters(void) { u8 effect = 0; s32 i; - for (gBankAttacker = 0; gBankAttacker < gNoOfAllBanks && gAbsentBankFlags & gBitTable[gBankAttacker]; gBankAttacker++) {} - for (gBankTarget = 0; gBankTarget < gNoOfAllBanks && gAbsentBankFlags & gBitTable[gBankTarget]; gBankTarget++) {} + + for (gBankAttacker = 0; gBankAttacker < gNoOfAllBanks && gAbsentBankFlags & gBitTable[gBankAttacker]; gBankAttacker++) + { + } + for (gBankTarget = 0; gBankTarget < gNoOfAllBanks && gAbsentBankFlags & gBitTable[gBankTarget]; gBankTarget++) + { + } + do { + u8 sideBank; + switch (BATTLE_STRUCT->turncountersTracker) { case 0: @@ -237,13 +266,14 @@ u8 UpdateTurnCounters(void) case 1: while (BATTLE_STRUCT->turnSideTracker < 2) { - gBankAttacker = BATTLE_STRUCT->turnSideTracker; - gActiveBank = BATTLE_STRUCT->turnSideTracker; - if (gSideAffecting[BATTLE_STRUCT->turnSideTracker] & SIDE_STATUS_REFLECT) + gActiveBank = gBankAttacker = sideBank = BATTLE_STRUCT->turnSideTracker; + + if (gSideAffecting[sideBank] & SIDE_STATUS_REFLECT) { - if (--gSideTimer[BATTLE_STRUCT->turnSideTracker].reflectTimer == 0) + if (--gSideTimer[sideBank].reflectTimer == 0) { - gSideAffecting[BATTLE_STRUCT->turnSideTracker] &= ~SIDE_STATUS_REFLECT; + + gSideAffecting[sideBank] &= ~SIDE_STATUS_REFLECT; b_call_bc_move_exec(gUnknown_081D9030); gBattleTextBuff1[0] = 0xFD; gBattleTextBuff1[1] = 2; @@ -266,15 +296,14 @@ u8 UpdateTurnCounters(void) case 2: while (BATTLE_STRUCT->turnSideTracker < 2) { - gBankAttacker = BATTLE_STRUCT->turnSideTracker; - gActiveBank = BATTLE_STRUCT->turnSideTracker; - if (gSideAffecting[BATTLE_STRUCT->turnSideTracker] & SIDE_STATUS_LIGHTSCREEN) + gActiveBank = gBankAttacker = sideBank = BATTLE_STRUCT->turnSideTracker; + if (gSideAffecting[sideBank] & SIDE_STATUS_LIGHTSCREEN) { - if (--gSideTimer[BATTLE_STRUCT->turnSideTracker].lightscreenTimer == 0) + if (--gSideTimer[sideBank].lightscreenTimer == 0) { - gSideAffecting[BATTLE_STRUCT->turnSideTracker] &= ~SIDE_STATUS_LIGHTSCREEN; + gSideAffecting[sideBank] &= ~SIDE_STATUS_LIGHTSCREEN; b_call_bc_move_exec(gUnknown_081D9030); - gBattleCommunication[MULTISTRING_CHOOSER] = BATTLE_STRUCT->turnSideTracker; + gBattleCommunication[MULTISTRING_CHOOSER] = sideBank; gBattleTextBuff1[0] = 0xFD; gBattleTextBuff1[1] = 2; gBattleTextBuff1[2] = MOVE_LIGHT_SCREEN; @@ -296,13 +325,12 @@ u8 UpdateTurnCounters(void) case 3: while (BATTLE_STRUCT->turnSideTracker < 2) { - gBankAttacker = BATTLE_STRUCT->turnSideTracker; - gActiveBank = BATTLE_STRUCT->turnSideTracker; - if (gSideTimer[BATTLE_STRUCT->turnSideTracker].mistTimer && --gSideTimer[BATTLE_STRUCT->turnSideTracker].mistTimer == 0) + gActiveBank = gBankAttacker = sideBank = BATTLE_STRUCT->turnSideTracker; + if (gSideTimer[sideBank].mistTimer && --gSideTimer[sideBank].mistTimer == 0) { - gSideAffecting[BATTLE_STRUCT->turnSideTracker] &= ~SIDE_STATUS_MIST; + gSideAffecting[sideBank] &= ~SIDE_STATUS_MIST; b_call_bc_move_exec(gUnknown_081D9030); - gBattleCommunication[MULTISTRING_CHOOSER] = BATTLE_STRUCT->turnSideTracker; + gBattleCommunication[MULTISTRING_CHOOSER] = sideBank; gBattleTextBuff1[0] = 0xFD; gBattleTextBuff1[1] = 2; gBattleTextBuff1[2] = MOVE_MIST; @@ -323,13 +351,12 @@ u8 UpdateTurnCounters(void) case 4: while (BATTLE_STRUCT->turnSideTracker < 2) { - gBankAttacker = BATTLE_STRUCT->turnSideTracker; - gActiveBank = BATTLE_STRUCT->turnSideTracker; - if (gSideAffecting[BATTLE_STRUCT->turnSideTracker] & SIDE_STATUS_SAFEGUARD) + gActiveBank = gBankAttacker = sideBank = BATTLE_STRUCT->turnSideTracker; + if (gSideAffecting[sideBank] & SIDE_STATUS_SAFEGUARD) { - if (--gSideTimer[BATTLE_STRUCT->turnSideTracker].safeguardTimer == 0) + if (--gSideTimer[sideBank].safeguardTimer == 0) { - gSideAffecting[BATTLE_STRUCT->turnSideTracker] &= ~SIDE_STATUS_SAFEGUARD; + gSideAffecting[sideBank] &= ~SIDE_STATUS_SAFEGUARD; b_call_bc_move_exec(gUnknown_081D9041); effect++; } @@ -348,9 +375,9 @@ u8 UpdateTurnCounters(void) while (BATTLE_STRUCT->turnSideTracker < gNoOfAllBanks) { gActiveBank = gTurnOrder[BATTLE_STRUCT->turnSideTracker]; - if (gWishFutureKnock.wishCounter[BATTLE_STRUCT->turnSideTracker] && --gWishFutureKnock.wishCounter[BATTLE_STRUCT->turnSideTracker] == 0 && gBattleMons[BATTLE_STRUCT->turnSideTracker].hp) + if (gWishFutureKnock.wishCounter[gActiveBank] && --gWishFutureKnock.wishCounter[gActiveBank] == 0 && gBattleMons[gActiveBank].hp) { - gBankTarget = BATTLE_STRUCT->turnSideTracker; + gBankTarget = gActiveBank; b_call_bc_move_exec(BattleScript_WishComesTrue); effect++; } @@ -398,11 +425,12 @@ u8 UpdateTurnCounters(void) } else gBattlescriptCurrInstr = gUnknown_081D8F7D; + + BATTLE_STRUCT->animArg1 = 0xC; + gBattleCommunication[MULTISTRING_CHOOSER] = 0; + b_call_bc_move_exec(gBattlescriptCurrInstr); + effect++; } - BATTLE_STRUCT->animArg1 = 0xD; - gBattleCommunication[MULTISTRING_CHOOSER] = 1; - b_call_bc_move_exec(gBattlescriptCurrInstr); - effect++; BATTLE_STRUCT->turncountersTracker++; break; case 8: @@ -415,11 +443,10 @@ u8 UpdateTurnCounters(void) } else gBattlescriptCurrInstr = gUnknown_081D9008; + + b_call_bc_move_exec(gBattlescriptCurrInstr); + effect++; } - BATTLE_STRUCT->animArg1 = 0xD; - gBattleCommunication[MULTISTRING_CHOOSER] = 1; - b_call_bc_move_exec(gBattlescriptCurrInstr); - effect++; BATTLE_STRUCT->turncountersTracker++; break; case 9: @@ -432,19 +459,327 @@ u8 UpdateTurnCounters(void) } else gBattlescriptCurrInstr = gUnknown_081D8F7D; + + BATTLE_STRUCT->animArg1 = 0xD; + gBattleCommunication[MULTISTRING_CHOOSER] = 1; + b_call_bc_move_exec(gBattlescriptCurrInstr); + effect++; } - BATTLE_STRUCT->animArg1 = 0xD; - gBattleCommunication[MULTISTRING_CHOOSER] = 1; - b_call_bc_move_exec(gBattlescriptCurrInstr); - effect++; BATTLE_STRUCT->turncountersTracker++; break; case 10: effect++; break; } - } while (!effect); + } while (effect == 0); return (gBattleMainFunc != BattleTurnPassed); } -*/ +#define TURNBASED_MAX_CASE 19 + +bool8 TurnBasedEffects(void) +{ + u8 effect = 0; + gHitMarker |= (HITMARKER_GRUDGE | HITMARKER_x20); + while (BATTLE_STRUCT->turnEffectsBank < gNoOfAllBanks && BATTLE_STRUCT->turnEffectsTracker <= TURNBASED_MAX_CASE) + { + gActiveBank = gBankAttacker = gTurnOrder[BATTLE_STRUCT->turnEffectsBank]; + if (gAbsentBankFlags & gBitTable[gActiveBank]) + { + BATTLE_STRUCT->turnEffectsBank++; + } + else + { + int i; + switch (BATTLE_STRUCT->turnEffectsTracker) + { + case 0: //ingrain + if (gStatuses3[gActiveBank] & STATUS3_ROOTED && gBattleMons[gActiveBank].hp != gBattleMons[gActiveBank].maxHP && gBattleMons[gActiveBank].hp != 0) + { + gBattleMoveDamage = gBattleMons[gActiveBank].maxHP / 16; + if (gBattleMoveDamage == 0) + gBattleMoveDamage = 1; + gBattleMoveDamage *= -1; + b_call_bc_move_exec(gUnknown_081D93D1); + effect++; + } + BATTLE_STRUCT->turnEffectsTracker++; + break; + case 1: //end turn abilities + if (AbilityBattleEffects(ABILITYEFFECT_ENDTURN, gActiveBank, 0, 0, 0)) + effect++; + BATTLE_STRUCT->turnEffectsTracker++; + break; + case 2: //item effects + if (ItemBattleEffects(0, gActiveBank, 0)) + effect++; + BATTLE_STRUCT->turnEffectsTracker++; + break; + case 18: //item effects again + if (ItemBattleEffects(1, gActiveBank, 1)) + effect++; + BATTLE_STRUCT->turnEffectsTracker++; + break; + case 3: //leech seed + { + u8 leecher; + if (gStatuses3[gActiveBank] & STATUS3_LEECHSEED && gBattleMons[leecher = (gStatuses3[gActiveBank] & STATUS3_LEECHSEED_BANK)].hp && gBattleMons[gActiveBank].hp) //wont match without this ugly leecher assignment + { + //u8 leecher = gStatuses3[gActiveBank] & STATUS3_LEECHSEED_BANK; + gBankTarget = leecher; //funny how the 'target' is actually the bank that receives HP + gBattleMoveDamage = gBattleMons[gActiveBank].maxHP / 8; + if (gBattleMoveDamage == 0) + gBattleMoveDamage = 1; + BATTLE_STRUCT->animArg1 = leecher; + BATTLE_STRUCT->animArg2 = gBankAttacker; + b_call_bc_move_exec(gUnknown_081D904B); + effect++; + } + BATTLE_STRUCT->turnEffectsTracker++; + } + break; + case 4: //poison + if (gBattleMons[gActiveBank].status1 & STATUS_POISON && gBattleMons[gActiveBank].hp) + { + gBattleMoveDamage = gBattleMons[gActiveBank].maxHP / 8; + if (gBattleMoveDamage == 0) + gBattleMoveDamage = 1; + b_call_bc_move_exec(gUnknown_081D9518); + effect++; + } + BATTLE_STRUCT->turnEffectsTracker++; + break; + case 5: //toxic poison + if (gBattleMons[gActiveBank].status1 & STATUS_TOXIC_POISON && gBattleMons[gActiveBank].hp) + { + gBattleMoveDamage = gBattleMons[gActiveBank].maxHP / 16; + if (gBattleMoveDamage == 0) + gBattleMoveDamage = 1; + if ((gBattleMons[gActiveBank].status1 & 0xF00) != 0xF00) //not 16 turns + gBattleMons[gActiveBank].status1 += 0x100; + gBattleMoveDamage *= (gBattleMons[gActiveBank].status1 & 0xF00) >> 8; + b_call_bc_move_exec(gUnknown_081D9518); + effect++; + } + BATTLE_STRUCT->turnEffectsTracker++; + break; + case 6: //burn + if (gBattleMons[gActiveBank].status1 & STATUS_BURN && gBattleMons[gActiveBank].hp) + { + gBattleMoveDamage = gBattleMons[gActiveBank].maxHP / 8; + if (gBattleMoveDamage == 0) + gBattleMoveDamage = 1; + b_call_bc_move_exec(gUnknown_081D953A); + effect++; + } + BATTLE_STRUCT->turnEffectsTracker++; + break; + case 7: //spooky nightmares + if (gBattleMons[gActiveBank].status2 & STATUS2_NIGHTMARE && gBattleMons[gActiveBank].hp) + { + //missing sleep check + gBattleMoveDamage = gBattleMons[gActiveBank].maxHP / 4; + if (gBattleMoveDamage == 0) + gBattleMoveDamage = 1; + b_call_bc_move_exec(gUnknown_081D9613); + effect++; + } + BATTLE_STRUCT->turnEffectsTracker++; + break; + case 8: //curse + if (gBattleMons[gActiveBank].status2 & STATUS2_CURSED && gBattleMons[gActiveBank].hp) + { + gBattleMoveDamage = gBattleMons[gActiveBank].maxHP / 4; + if (gBattleMoveDamage == 0) + gBattleMoveDamage = 1; + b_call_bc_move_exec(gUnknown_081D9624); + effect++; + } + BATTLE_STRUCT->turnEffectsTracker++; + break; + case 9: //wrap + if (gBattleMons[gActiveBank].status2 & STATUS2_WRAPPED && gBattleMons[gActiveBank].hp) + { + gBattleMons[gActiveBank].status2 &= 0xFFFFE000; //hmmm + if (gBattleMons[gActiveBank].status2 & STATUS2_WRAPPED) //damaged by wrap + { + BATTLE_STRUCT->animArg1 = ewram[gActiveBank * 2 + 0x16004]; + BATTLE_STRUCT->animArg2 = ewram[gActiveBank * 2 + 0x16005]; + gBattleTextBuff1[0] = 0xFD; + gBattleTextBuff1[1] = 2; + gBattleTextBuff1[2] = ewram[gActiveBank * 2 + 0x16004]; + gBattleTextBuff1[3] = ewram[gActiveBank * 2 + 0x16005]; + gBattleTextBuff1[4] = 0xFF; + gBattlescriptCurrInstr = gUnknown_081D95E2; + gBattleMoveDamage = gBattleMons[gActiveBank].maxHP / 16; + if (gBattleMoveDamage == 0) + gBattleMoveDamage = 1; + } + else //broke free + { + gBattleTextBuff1[0] = 0xFD; + gBattleTextBuff1[1] = 2; + gBattleTextBuff1[2] = ewram[gActiveBank * 2 + 0x16004]; + gBattleTextBuff1[3] = ewram[gActiveBank * 2 + 0x16005]; + gBattleTextBuff1[4] = 0xFF; + gBattlescriptCurrInstr = gUnknown_081D95F4; + } + b_call_bc_move_exec(gBattlescriptCurrInstr); + effect++; + } + BATTLE_STRUCT->turnEffectsTracker++; + break; + case 10: //uproar + if (gBattleMons[gActiveBank].status2 & STATUS2_UPROAR) + { + for (gBankAttacker = 0; gBankAttacker < gNoOfAllBanks; gBankAttacker++) + { + if (gBattleMons[gBankAttacker].status1 & STATUS_SLEEP && gBattleMons[gBankAttacker].ability != ABILITY_SOUNDPROOF) + { + gBattleMons[gBankAttacker].status1 &= ~(STATUS_SLEEP); + gBattleMons[gBankAttacker].status2 &= ~(STATUS2_NIGHTMARE); + gBattleCommunication[MULTISTRING_CHOOSER] = 1; + b_call_bc_move_exec(gUnknown_081D950F); + gActiveBank = gBankAttacker; + EmitSetAttributes(0, REQUEST_STATUS_BATTLE, 0, 4, &gBattleMons[gBankAttacker].status1); + MarkBufferBankForExecution(gActiveBank); + break; + } + } + if (gBankAttacker != gNoOfAllBanks) + { + effect = 2; //a pokemon was awaken + break; + } + else + { + gBankAttacker = gActiveBank; + gBattleMons[gActiveBank].status2 -= 0x10; //uproar timer goes down + if (sub_8015660(gActiveBank)) + { + CancelMultiTurnMoves(gActiveBank); + gBattleCommunication[MULTISTRING_CHOOSER] = 1; + } + else if (gBattleMons[gActiveBank].status2 & STATUS2_UPROAR) + { + gBattleCommunication[MULTISTRING_CHOOSER] = 0; + gBattleMons[gActiveBank].status2 |= STATUS2_MULTIPLETURNS; + } + else + { + gBattleCommunication[MULTISTRING_CHOOSER] = 1; + CancelMultiTurnMoves(gActiveBank); + } + b_call_bc_move_exec(gUnknown_081D957E); + effect = 1; + } + } + if (effect != 2) + BATTLE_STRUCT->turnEffectsTracker++; + break; + case 11: //thrash + if (gBattleMons[gActiveBank].status2 & STATUS2_LOCK_CONFUSE) + { + gBattleMons[gActiveBank].status2 &= 0xFFFFFC00; + if (sub_8015660(gActiveBank)) + CancelMultiTurnMoves(gActiveBank); + else if (!(gBattleMons[gActiveBank].status2 & STATUS2_LOCK_CONFUSE) && gBattleMons[gActiveBank].status2 & STATUS2_MULTIPLETURNS) + { + gBattleMons[gActiveBank].status2 &= 0xFFFFEFFF; + if (!(gBattleMons[gActiveBank].status2 & STATUS2_CONFUSION)) + { + gBattleCommunication[MOVE_EFFECT_BYTE] = 0x47; + SetMoveEffect(1, 0); + if (gBattleMons[gActiveBank].status2 & STATUS2_CONFUSION) + b_call_bc_move_exec(gUnknown_081D9587); + effect++; + } + } + } + BATTLE_STRUCT->turnEffectsTracker++; + break; + case 12: //disable + if (gDisableStructs[gActiveBank].disableTimer1) + { + for (i = 0; i < 4; i++) + { + if (gDisableStructs[gActiveBank].disabledMove == gBattleMons[gActiveBank].moves[i]) + break; + } + if (i == 4) //pokemon does not have the disabled move anymore + { + gDisableStructs[gActiveBank].disabledMove = 0; + gDisableStructs[gActiveBank].disableTimer1 = 0; + } + else if (--gDisableStructs[gActiveBank].disableTimer1 == 0) //disable ends + { + gDisableStructs[gActiveBank].disabledMove = 0; + b_call_bc_move_exec(gUnknown_081D9148); + effect++; + } + } + BATTLE_STRUCT->turnEffectsTracker++; + break; + case 13: //encore + if (gDisableStructs[gActiveBank].encoreTimer1) + { + if (gBattleMons[gActiveBank].moves[gDisableStructs[gActiveBank].encoredMovePos] != gDisableStructs[gActiveBank].encoredMove) //pokemon does not have the encored move anymore + { + gDisableStructs[gActiveBank].encoredMove = 0; + gDisableStructs[gActiveBank].encoreTimer1 = 0; + } + else if (--gDisableStructs[gActiveBank].encoreTimer1 == 0 || gBattleMons[gActiveBank].pp[gDisableStructs[gActiveBank].encoredMovePos] == 0) + { + gDisableStructs[gActiveBank].encoredMove = 0; + gDisableStructs[gActiveBank].encoreTimer1 = 0; + b_call_bc_move_exec(gUnknown_081D914F); + effect++; + } + } + BATTLE_STRUCT->turnEffectsTracker++; + break; + case 14: //lock-on decrement + if (gStatuses3[gActiveBank] & STATUS3_ALWAYS_HITS) + gStatuses3[gActiveBank] -= 0x8; + BATTLE_STRUCT->turnEffectsTracker++; + break; + case 15: //charge + if (gDisableStructs[gActiveBank].chargeTimer1 && --gDisableStructs[gActiveBank].chargeTimer1 == 0) + gStatuses3[gActiveBank] &= ~STATUS3_CHARGED_UP; + BATTLE_STRUCT->turnEffectsTracker++; + break; + case 16: //taunt + if (gDisableStructs[gActiveBank].tauntTimer1) + gDisableStructs[gActiveBank].tauntTimer1--; + BATTLE_STRUCT->turnEffectsTracker++; + break; + case 17: //yawn + if (gStatuses3[gActiveBank] & STATUS3_YAWN) + { + gStatuses3[gActiveBank] &= 0xFFFFF800; + if (!(gStatuses3[gActiveBank] & STATUS3_YAWN) && !gBattleMons[gActiveBank].status1 && gBattleMons[gActiveBank].ability != ABILITY_VITAL_SPIRIT + && gBattleMons[gActiveBank].ability != ABILITY_INSOMNIA && !sub_8025A44(gActiveBank)) + { + CancelMultiTurnMoves(gActiveBank); + gBattleMons[gActiveBank].status1 |= (Random() & 3) + 2; + EmitSetAttributes(0, REQUEST_STATUS_BATTLE, 0, 4, &gBattleMons[gActiveBank].status1); + MarkBufferBankForExecution(gActiveBank); + gEffectBank = gActiveBank; + b_call_bc_move_exec(gUnknown_081D964C); + effect++; + } + } + BATTLE_STRUCT->turnEffectsTracker++; + break; + case 19: //done + BATTLE_STRUCT->turnEffectsTracker = 0; + BATTLE_STRUCT->turnEffectsBank++; + break; + } + if (effect) + return effect; + } + } + gHitMarker &= ~(HITMARKER_GRUDGE | HITMARKER_x20); + return 0; +} diff --git a/src/battle_4.c b/src/battle_4.c index 027a3f4f9..ced5b9b8c 100644 --- a/src/battle_4.c +++ b/src/battle_4.c @@ -159,7 +159,7 @@ u8 CalculatePlayerPartyCount(void); u16 Sqrt(u32 num); u8 sub_809070C(u16 nationalNum, u32 TiD, u32 PiD); //task prepare poke dex display void sub_814A880(u8 a1, u8 a2); -u8 CheckMoveLimitations(u8 bank, u8 unusable_moves, u8 flags); //choose move limitations +u8 CheckMoveLimitations(u8 bank, u8 unusable_moves, u8 flags); void sub_801529C(u8 bank); bool8 IsLinkDoubleBattle(void); void sub_8094B6C(u8 bank, u8 partyID, u8 r2); @@ -237,17 +237,6 @@ extern u8 gUnknown_081D95DB[]; //bs payday money give #define TargetProtectAffected ((gProtectStructs[gBankTarget].protected && gBattleMoves[gCurrentMove].flags & FLAG_PROTECT_AFFECTED)) -#define ABILITYEFFECT_CONTACT 0x4 -#define ABILITYEFFECT_IMMUNITY 0x5 -#define ABILITYEFFECT_SYNCHRONIZE 0x7 -#define ABILITYEFFECT_ATK_SYNCHRONIZE 0x8 -#define ABILITYEFFECT_CHECK_OTHER_SIDE 0xC -#define ABILITYEFFECT_CHECK_BANK_SIDE 0xD -#define ABILITYEFFECT_COUNT_OTHER_SIZE 0x10 -#define ABILITYEFFECT_COUNT_BANK_SIDE 0x11 -#define ABILITYEFFECT_COUNT_ON_FIELD 0x12 -#define ABILITYEFFECT_CHECK_ON_FIELD 0x13 - //array entries for battle communication #define MOVE_EFFECT_BYTE 0x3 #define MULTISTRING_CHOOSER 0x5 @@ -10144,7 +10133,7 @@ static void atk4D_switch_data_update(void) gBattleTextBuff1[1] = 7; gBattleTextBuff1[2] = gActiveBank; gBattleTextBuff1[3] = gBattlePartyID[gActiveBank]; - gBattleTextBuff1[4] = 0xFF; + gBattleTextBuff1[4] = EOS; gBattlescriptCurrInstr += 2; } From d101fa39be37634689bd06713ba117b827f2c7c4 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Tue, 25 Jul 2017 17:09:47 +0200 Subject: [PATCH 3/8] attack canceller troubles --- asm/battle_3.s | 780 +--------------------------------------- data/battle_scripts_1.s | 20 +- include/battle.h | 29 +- src/battle_3.c | 646 ++++++++++++++++++++++++++++----- src/battle_4.c | 18 +- 5 files changed, 591 insertions(+), 902 deletions(-) diff --git a/asm/battle_3.s b/asm/battle_3.s index a42fdcf00..13660f368 100644 --- a/asm/battle_3.s +++ b/asm/battle_3.s @@ -6,782 +6,8 @@ .text - - - - thumb_func_start sub_80170DC -sub_80170DC: @ 80170DC - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - ldr r2, _08017108 @ =gHitMarker - ldr r0, [r2] - ldr r1, _0801710C @ =0x01000020 - orrs r0, r1 - str r0, [r2] - ldr r1, _08017110 @ =0x02000000 - ldr r3, _08017114 @ =0x00016110 - adds r0, r1, r3 - ldrb r0, [r0] - mov r8, r1 - cmp r0, 0 - beq _08017118 - cmp r0, 0x1 - bne _08017104 - b _08017258 -_08017104: - b _08017380 - .align 2, 0 -_08017108: .4byte gHitMarker -_0801710C: .4byte 0x01000020 -_08017110: .4byte 0x02000000 -_08017114: .4byte 0x00016110 -_08017118: - ldr r2, _0801715C @ =0x00016111 - add r2, r8 - ldr r0, _08017160 @ =gNoOfAllBanks - ldrb r1, [r2] - mov r9, r0 - ldrb r0, [r0] - cmp r1, r0 - bcc _0801712A - b _08017248 -_0801712A: - ldr r4, _08017164 @ =gActiveBank - adds r5, r2, 0 - ldr r1, _08017168 @ =gWishFutureKnock - mov r12, r1 - movs r2, 0x8 - add r2, r12 - mov r10, r2 - mov r7, r12 - adds r7, 0x18 - ldr r6, _0801716C @ =gBattleTextBuff1 -_0801713E: - ldrb r3, [r5] - strb r3, [r4] - ldr r0, _08017170 @ =gAbsentBankFlags - ldrb r1, [r0] - ldr r2, _08017174 @ =gBitTable - ldrb r0, [r4] - lsls r0, 2 - adds r0, r2 - ldr r0, [r0] - ands r1, r0 - cmp r1, 0 - beq _08017178 - adds r0, r3, 0x1 - strb r0, [r5] - b _0801723C - .align 2, 0 -_0801715C: .4byte 0x00016111 -_08017160: .4byte gNoOfAllBanks -_08017164: .4byte gActiveBank -_08017168: .4byte gWishFutureKnock -_0801716C: .4byte gBattleTextBuff1 -_08017170: .4byte gAbsentBankFlags -_08017174: .4byte gBitTable -_08017178: - adds r0, r3, 0x1 - strb r0, [r5] - ldr r1, _080171B4 @ =gWishFutureKnock - ldrb r0, [r4] - adds r1, r0, r1 - ldrb r0, [r1] - cmp r0, 0 - beq _0801723C - subs r0, 0x1 - strb r0, [r1] - lsls r0, 24 - lsrs r3, r0, 24 - cmp r3, 0 - bne _0801723C - ldr r1, _080171B8 @ =gBattleMons - ldrb r2, [r4] - movs r0, 0x58 - muls r0, r2 - adds r0, r1 - ldrh r0, [r0, 0x28] - cmp r0, 0 - beq _0801723C - lsls r0, r2, 1 - adds r0, r7 - ldrh r0, [r0] - cmp r0, 0xF8 - bne _080171C0 - ldr r0, _080171BC @ =gBattleCommunication - strb r3, [r0, 0x5] - b _080171C6 - .align 2, 0 -_080171B4: .4byte gWishFutureKnock -_080171B8: .4byte gBattleMons -_080171BC: .4byte gBattleCommunication -_080171C0: - ldr r1, _08017220 @ =gBattleCommunication - movs r0, 0x1 - strb r0, [r1, 0x5] -_080171C6: - movs r0, 0xFD - strb r0, [r6] - movs r0, 0x2 - strb r0, [r6, 0x1] - ldrb r0, [r4] - lsls r0, 1 - adds r0, r7 - ldrh r0, [r0] - strb r0, [r6, 0x2] - ldrb r0, [r4] - lsls r0, 1 - adds r0, r7 - ldrh r0, [r0] - lsrs r0, 8 - strb r0, [r6, 0x3] - movs r0, 0xFF - strb r0, [r6, 0x4] - ldr r3, _08017224 @ =gBankTarget - ldrb r0, [r4] - strb r0, [r3] - ldr r1, _08017228 @ =gBankAttacker - mov r0, r12 - adds r0, 0x4 - ldrb r2, [r4] - adds r0, r2 - ldrb r0, [r0] - strb r0, [r1] - ldr r1, _0801722C @ =gBattleMoveDamage - ldrb r0, [r4] - lsls r0, 2 - add r0, r10 - ldr r0, [r0] - str r0, [r1] - ldr r2, _08017230 @ =gSpecialStatuses - ldrb r1, [r3] - lsls r0, r1, 2 - adds r0, r1 - lsls r0, 2 - adds r2, 0x4 - adds r0, r2 - ldr r1, _08017234 @ =0x0000ffff - str r1, [r0] - ldr r0, _08017238 @ =gUnknown_081D92D7 - b _08017364 - .align 2, 0 -_08017220: .4byte gBattleCommunication -_08017224: .4byte gBankTarget -_08017228: .4byte gBankAttacker -_0801722C: .4byte gBattleMoveDamage -_08017230: .4byte gSpecialStatuses -_08017234: .4byte 0x0000ffff -_08017238: .4byte gUnknown_081D92D7 -_0801723C: - ldrb r0, [r5] - mov r3, r9 - ldrb r3, [r3] - cmp r0, r3 - bcs _08017248 - b _0801713E -_08017248: - ldr r1, _0801729C @ =0x00016110 - add r1, r8 - movs r2, 0 - movs r0, 0x1 - strb r0, [r1] - ldr r0, _080172A0 @ =0x00016111 - add r0, r8 - strb r2, [r0] -_08017258: - ldr r2, _080172A0 @ =0x00016111 - add r2, r8 - ldr r0, _080172A4 @ =gNoOfAllBanks - ldrb r1, [r2] - mov r9, r0 - ldrb r0, [r0] - cmp r1, r0 - bcc _0801726A - b _08017380 -_0801726A: - ldr r5, _080172A8 @ =gActiveBank - adds r3, r2, 0 - ldr r4, _080172AC @ =gBattleTextBuff1 - ldr r7, _080172B0 @ =gDisableStructs -_08017272: - ldr r2, _080172B4 @ =gBankAttacker - ldr r1, _080172B8 @ =gTurnOrder - ldrb r0, [r3] - adds r0, r1 - ldrb r0, [r0] - strb r0, [r2] - strb r0, [r5] - ldr r0, _080172BC @ =gAbsentBankFlags - ldrb r1, [r0] - ldr r2, _080172C0 @ =gBitTable - ldrb r0, [r5] - lsls r0, 2 - adds r0, r2 - ldr r0, [r0] - ands r1, r0 - cmp r1, 0 - beq _080172C4 - ldrb r0, [r3] - adds r0, 0x1 - strb r0, [r3] - b _08017374 - .align 2, 0 -_0801729C: .4byte 0x00016110 -_080172A0: .4byte 0x00016111 -_080172A4: .4byte gNoOfAllBanks -_080172A8: .4byte gActiveBank -_080172AC: .4byte gBattleTextBuff1 -_080172B0: .4byte gDisableStructs -_080172B4: .4byte gBankAttacker -_080172B8: .4byte gTurnOrder -_080172BC: .4byte gAbsentBankFlags -_080172C0: .4byte gBitTable -_080172C4: - ldrb r0, [r3] - adds r0, 0x1 - strb r0, [r3] - ldr r6, _08017334 @ =gStatuses3 - ldrb r2, [r5] - lsls r0, r2, 2 - adds r0, r6 - ldr r0, [r0] - movs r1, 0x20 - ands r0, r1 - cmp r0, 0 - beq _08017374 - movs r0, 0xFD - strb r0, [r4] - movs r0, 0x1 - strb r0, [r4, 0x1] - strb r0, [r4, 0x2] - strb r0, [r4, 0x3] - lsls r0, r2, 3 - subs r0, r2 - lsls r0, 2 - adds r0, r7 - ldrb r0, [r0, 0xF] - lsls r0, 28 - lsrs r0, 28 - strb r0, [r4, 0x4] - movs r0, 0xFF - strb r0, [r4, 0x5] - ldrb r2, [r5] - lsls r0, r2, 3 - subs r0, r2 - lsls r0, 2 - adds r4, r0, r7 - ldrb r3, [r4, 0xF] - lsls r1, r3, 28 - cmp r1, 0 - bne _08017348 - lsls r2, 2 - adds r2, r6 - ldr r0, [r2] - movs r1, 0x21 - negs r1, r1 - ands r0, r1 - str r0, [r2] - ldr r3, _08017338 @ =gBattleMoveDamage - ldr r2, _0801733C @ =gBattleMons - ldrb r1, [r5] - movs r0, 0x58 - muls r0, r1 - adds r0, r2 - ldrh r0, [r0, 0x28] - str r0, [r3] - ldr r1, _08017340 @ =gBattlescriptCurrInstr - ldr r0, _08017344 @ =gUnknown_081D9202 - b _08017360 - .align 2, 0 -_08017334: .4byte gStatuses3 -_08017338: .4byte gBattleMoveDamage -_0801733C: .4byte gBattleMons -_08017340: .4byte gBattlescriptCurrInstr -_08017344: .4byte gUnknown_081D9202 -_08017348: - lsrs r1, 28 - subs r1, 0x1 - movs r0, 0xF - ands r1, r0 - movs r2, 0x10 - negs r2, r2 - adds r0, r2, 0 - ands r0, r3 - orrs r0, r1 - strb r0, [r4, 0xF] - ldr r1, _0801736C @ =gBattlescriptCurrInstr - ldr r0, _08017370 @ =gUnknown_081D921D -_08017360: - str r0, [r1] - ldr r0, [r1] -_08017364: - bl b_call_bc_move_exec - movs r0, 0x1 - b _0801738C - .align 2, 0 -_0801736C: .4byte gBattlescriptCurrInstr -_08017370: .4byte gUnknown_081D921D -_08017374: - ldrb r0, [r3] - mov r1, r9 - ldrb r1, [r1] - cmp r0, r1 - bcs _08017380 - b _08017272 -_08017380: - ldr r2, _0801739C @ =gHitMarker - ldr r0, [r2] - ldr r1, _080173A0 @ =0xfeffffdf - ands r0, r1 - str r0, [r2] - movs r0, 0 -_0801738C: - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r1} - bx r1 - .align 2, 0 -_0801739C: .4byte gHitMarker -_080173A0: .4byte 0xfeffffdf - thumb_func_end sub_80170DC - - thumb_func_start sub_80173A4 -sub_80173A4: @ 80173A4 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x4 - ldr r0, _080173C0 @ =gBattleTypeFlags - ldrh r1, [r0] - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - beq _080173F8 - b _080176AC - .align 2, 0 -_080173C0: .4byte gBattleTypeFlags -_080173C4: - ldr r0, _080173D4 @ =gUnknown_081D8C72 - bl b_call_bc_move_exec - ldr r1, _080173D8 @ =0x00016059 - add r1, r10 - movs r0, 0x2 - b _080173E8 - .align 2, 0 -_080173D4: .4byte gUnknown_081D8C72 -_080173D8: .4byte 0x00016059 -_080173DC: - ldr r0, _080173F0 @ =gUnknown_081D8C7B - bl b_call_bc_move_exec - ldr r1, _080173F4 @ =0x00016059 - add r1, r8 - movs r0, 0x5 -_080173E8: - strb r0, [r1] -_080173EA: - movs r0, 0x1 - b _080176AE - .align 2, 0 -_080173F0: .4byte gUnknown_081D8C7B -_080173F4: .4byte 0x00016059 -_080173F8: - ldr r0, _08017414 @ =0x02000000 - mov r9, r0 -_080173FC: - ldr r0, _08017418 @ =0x00016059 - add r0, r9 - ldrb r0, [r0] - cmp r0, 0x7 - bls _08017408 - b _080176A0 -_08017408: - lsls r0, 2 - ldr r1, _0801741C @ =_08017420 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .align 2, 0 -_08017414: .4byte 0x02000000 -_08017418: .4byte 0x00016059 -_0801741C: .4byte _08017420 - .align 2, 0 -_08017420: - .4byte _08017440 - .4byte _08017490 - .4byte _08017534 - .4byte _0801757C - .4byte _0801758E - .4byte _080175FC - .4byte _08017638 - .4byte _080176A0 -_08017440: - ldr r1, _08017508 @ =0x0001605a - add r1, r9 - movs r0, 0 - strb r0, [r1] - ldr r1, _0801750C @ =0x00016059 - add r1, r9 - ldrb r0, [r1] - adds r0, 0x1 - strb r0, [r1] - movs r5, 0 - ldr r0, _08017510 @ =gNoOfAllBanks - ldrb r0, [r0] - cmp r5, r0 - bge _08017490 - ldr r6, _08017514 @ =gAbsentBankFlags -_0801745E: - ldrb r0, [r6] - ldr r2, _08017518 @ =gBitTable - lsls r1, r5, 2 - adds r1, r2 - ldr r4, [r1] - ands r0, r4 - cmp r0, 0 - beq _08017486 - lsls r0, r5, 24 - lsrs r0, 24 - movs r1, 0x6 - movs r2, 0x6 - bl sub_8018018 - lsls r0, 24 - cmp r0, 0 - bne _08017486 - ldrb r0, [r6] - bics r0, r4 - strb r0, [r6] -_08017486: - adds r5, 0x1 - ldr r0, _08017510 @ =gNoOfAllBanks - ldrb r0, [r0] - cmp r5, r0 - blt _0801745E -_08017490: - ldr r1, _0801751C @ =0x02000000 - mov r9, r1 - ldr r0, _08017520 @ =gBank1 - mov r12, r0 - ldr r1, _08017524 @ =gBankTarget - mov r8, r1 - mov r10, r9 - ldr r5, _08017508 @ =0x0001605a - add r5, r9 - ldr r7, _08017528 @ =gBattleMons - ldr r6, _0801752C @ =0x00016113 - add r6, r9 -_080174A8: - ldrb r0, [r5] - mov r1, r8 - strb r0, [r1] - mov r1, r12 - strb r0, [r1] - ldrb r3, [r5] - movs r0, 0x58 - muls r0, r3 - adds r0, r7 - ldrh r0, [r0, 0x28] - cmp r0, 0 - bne _080174EA - ldrb r2, [r6] - ldr r4, _08017518 @ =gBitTable - ldr r1, _08017530 @ =gBattlePartyID - lsls r0, r3, 1 - adds r0, r1 - ldrh r0, [r0] - lsls r0, 2 - adds r0, r4 - ldr r0, [r0] - ands r2, r0 - cmp r2, 0 - bne _080174EA - ldr r0, _08017514 @ =gAbsentBankFlags - ldrb r1, [r0] - lsls r0, r3, 2 - adds r0, r4 - ldr r0, [r0] - ands r1, r0 - cmp r1, 0 - bne _080174EA - b _080173C4 -_080174EA: - ldrb r0, [r5] - adds r0, 0x1 - strb r0, [r5] - ldr r1, _08017510 @ =gNoOfAllBanks - lsls r0, 24 - lsrs r0, 24 - ldrb r1, [r1] - cmp r0, r1 - bne _080174A8 - ldr r1, _0801750C @ =0x00016059 - add r1, r9 - movs r0, 0x3 - strb r0, [r1] - b _080176A0 - .align 2, 0 -_08017508: .4byte 0x0001605a -_0801750C: .4byte 0x00016059 -_08017510: .4byte gNoOfAllBanks -_08017514: .4byte gAbsentBankFlags -_08017518: .4byte gBitTable -_0801751C: .4byte 0x02000000 -_08017520: .4byte gBank1 -_08017524: .4byte gBankTarget -_08017528: .4byte gBattleMons -_0801752C: .4byte 0x00016113 -_08017530: .4byte gBattlePartyID -_08017534: - ldr r0, _0801755C @ =gBank1 - ldrb r0, [r0] - bl sub_8015740 - ldr r2, _08017560 @ =0x02000000 - ldr r0, _08017564 @ =0x0001605a - adds r1, r2, r0 - ldrb r0, [r1] - adds r0, 0x1 - strb r0, [r1] - ldr r1, _08017568 @ =gNoOfAllBanks - lsls r0, 24 - lsrs r0, 24 - ldrb r1, [r1] - cmp r0, r1 - bne _08017570 - ldr r0, _0801756C @ =0x00016059 - adds r1, r2, r0 - movs r0, 0x3 - b _0801769C - .align 2, 0 -_0801755C: .4byte gBank1 -_08017560: .4byte 0x02000000 -_08017564: .4byte 0x0001605a -_08017568: .4byte gNoOfAllBanks -_0801756C: .4byte 0x00016059 -_08017570: - ldr r0, _08017578 @ =0x00016059 - adds r1, r2, r0 - movs r0, 0x1 - b _0801769C - .align 2, 0 -_08017578: .4byte 0x00016059 -_0801757C: - ldr r1, _080175D8 @ =0x0001605a - add r1, r9 - movs r0, 0 - strb r0, [r1] - ldr r1, _080175DC @ =0x00016059 - add r1, r9 - ldrb r0, [r1] - adds r0, 0x1 - strb r0, [r1] -_0801758E: - ldr r7, _080175E0 @ =gBank1 - ldr r6, _080175E4 @ =gBankTarget - ldr r1, _080175E8 @ =0x02000000 - mov r8, r1 - ldr r3, _080175D8 @ =0x0001605a - add r3, r8 - ldr r5, _080175EC @ =gBattleMons - ldr r4, _080175F0 @ =gBitTable -_0801759E: - ldrb r0, [r3] - strb r0, [r6] - strb r0, [r7] - ldrb r2, [r3] - movs r0, 0x58 - muls r0, r2 - adds r0, r5 - ldrh r0, [r0, 0x28] - cmp r0, 0 - bne _080175C4 - ldr r0, _080175F4 @ =gAbsentBankFlags - ldrb r1, [r0] - lsls r0, r2, 2 - adds r0, r4 - ldr r0, [r0] - ands r1, r0 - cmp r1, 0 - bne _080175C4 - b _080173DC -_080175C4: - adds r0, r2, 0x1 - strb r0, [r3] - ldr r1, _080175F8 @ =gNoOfAllBanks - lsls r0, 24 - lsrs r0, 24 - ldrb r1, [r1] - cmp r0, r1 - bne _0801759E - b _08017612 - .align 2, 0 -_080175D8: .4byte 0x0001605a -_080175DC: .4byte 0x00016059 -_080175E0: .4byte gBank1 -_080175E4: .4byte gBankTarget -_080175E8: .4byte 0x02000000 -_080175EC: .4byte gBattleMons -_080175F0: .4byte gBitTable -_080175F4: .4byte gAbsentBankFlags -_080175F8: .4byte gNoOfAllBanks -_080175FC: - ldr r0, _0801761C @ =0x0001605a - add r0, r9 - ldrb r1, [r0] - adds r1, 0x1 - strb r1, [r0] - ldr r0, _08017620 @ =gNoOfAllBanks - lsls r1, 24 - lsrs r1, 24 - ldrb r0, [r0] - cmp r1, r0 - bne _08017628 -_08017612: - ldr r1, _08017624 @ =0x00016059 - add r1, r9 - movs r0, 0x6 - strb r0, [r1] - b _080176A0 - .align 2, 0 -_0801761C: .4byte 0x0001605a -_08017620: .4byte gNoOfAllBanks -_08017624: .4byte 0x00016059 -_08017628: - ldr r1, _08017634 @ =0x00016059 - add r1, r9 - movs r0, 0x4 - strb r0, [r1] - b _080176A0 - .align 2, 0 -_08017634: .4byte 0x00016059 -_08017638: - movs r0, 0 - str r0, [sp] - movs r0, 0x9 - movs r1, 0 - movs r2, 0 - movs r3, 0 - bl AbilityBattleEffects - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0 - beq _08017652 - b _080173EA -_08017652: - str r0, [sp] - movs r0, 0xB - movs r1, 0 - movs r2, 0 - movs r3, 0 - bl AbilityBattleEffects - lsls r0, 24 - cmp r0, 0 - beq _08017668 - b _080173EA -_08017668: - movs r0, 0x1 - movs r1, 0 - movs r2, 0x1 - bl ItemBattleEffects - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0 - beq _0801767C - b _080173EA -_0801767C: - str r0, [sp] - movs r0, 0x6 - movs r1, 0 - movs r2, 0 - movs r3, 0 - bl AbilityBattleEffects - lsls r0, 24 - cmp r0, 0 - beq _08017692 - b _080173EA -_08017692: - ldr r2, _080176C0 @ =0x02000000 - ldr r0, _080176C4 @ =0x00016059 - adds r1, r2, r0 - ldrb r0, [r1] - adds r0, 0x1 -_0801769C: - strb r0, [r1] - mov r9, r2 -_080176A0: - ldr r0, _080176C4 @ =0x00016059 - add r0, r9 - ldrb r0, [r0] - cmp r0, 0x7 - beq _080176AC - b _080173FC -_080176AC: - movs r0, 0 -_080176AE: - add sp, 0x4 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r1} - bx r1 - .align 2, 0 -_080176C0: .4byte 0x02000000 -_080176C4: .4byte 0x00016059 - thumb_func_end sub_80173A4 - - thumb_func_start b_clear_atk_up_if_hit_flag_unless_enraged -b_clear_atk_up_if_hit_flag_unless_enraged: @ 80176C8 - push {r4-r6,lr} - movs r3, 0 - ldr r0, _08017708 @ =gNoOfAllBanks - adds r5, r0, 0 - ldrb r0, [r5] - cmp r3, r0 - bge _08017700 - ldr r4, _0801770C @ =gChosenMovesByBanks - movs r6, 0x80 - lsls r6, 16 - ldr r2, _08017710 @ =gUnknown_02024AD0 -_080176DE: - ldr r1, [r2] - adds r0, r1, 0 - ands r0, r6 - cmp r0, 0 - beq _080176F4 - ldrh r0, [r4] - cmp r0, 0x63 - beq _080176F4 - ldr r0, _08017714 @ =0xff7fffff - ands r1, r0 - str r1, [r2] -_080176F4: - adds r4, 0x2 - adds r2, 0x58 - adds r3, 0x1 - ldrb r0, [r5] - cmp r3, r0 - blt _080176DE -_08017700: - pop {r4-r6} - pop {r0} - bx r0 - .align 2, 0 -_08017708: .4byte gNoOfAllBanks -_0801770C: .4byte gChosenMovesByBanks -_08017710: .4byte gUnknown_02024AD0 -_08017714: .4byte 0xff7fffff - thumb_func_end b_clear_atk_up_if_hit_flag_unless_enraged - - thumb_func_start CantUseMove -CantUseMove: @ 8017718 + thumb_func_start AtkCanceller_UnableToUseMove +AtkCanceller_UnableToUseMove: @ 8017718 push {r4-r7,lr} mov r7, r10 mov r6, r9 @@ -1823,7 +1049,7 @@ _08018008: .4byte 0x02000000 _0801800C: .4byte 0x000160e7 _08018010: .4byte gActiveBank _08018014: .4byte gUnknown_02024ACC - thumb_func_end CantUseMove + thumb_func_end AtkCanceller_UnableToUseMove thumb_func_start sub_8018018 sub_8018018: @ 8018018 diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 43c3e77d7..3d5397842 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -3311,7 +3311,7 @@ gUnknown_081D9041:: @ 81D9041 waitmessage 64 end2 -gUnknown_081D904B:: @ 81D904B +BattleScript_LeechSeedTurnDrain:: @ 81D904B playanimation USER, 14, 0x20160a4 orword 0x2024c6c, 0x100100 graphicalhpupdate USER @@ -3405,12 +3405,12 @@ BattleScript_MoveSelectionDisabledMove:: @ 81D9144 printstring2 BATTLE_TEXT_MoveIsDisabled atk44 -gUnknown_081D9148:: @ 81D9148 +BattleScript_DisabledNoMore:: @ 81D9148 printstring BATTLE_TEXT_DisabledNoMore waitmessage 64 end2 -gUnknown_081D914F:: @ 81D914F +BattleScript_EncoredNoMore:: @ 81D914F printstring BATTLE_TEXT_EncoreEnded waitmessage 64 end2 @@ -3644,7 +3644,7 @@ BattleScript_1D93C1: @ 81D93C1 waitmessage 64 end2 -gUnknown_081D93D1:: @ 81D93D1 +BattleScript_IngrainTurnHeal:: @ 81D93D1 playanimation USER, 21, 0x0 printstring BATTLE_TEXT_AbsorbNutrients waitmessage 64 @@ -3770,7 +3770,7 @@ gUnknown_081D950F:: @ 81D950F atk98 1 end2 -gUnknown_081D9518:: @ 81D9518 +BattleScript_PoisonTurnDmg:: @ 81D9518 printstring BATTLE_TEXT_PoisonHurt waitmessage 64 @@ -3787,7 +3787,7 @@ BattleScript_1D9520: @ 81D9520 BattleScript_1D9539: @ 81D9539 end2 -gUnknown_081D953A:: @ 81D953A +BattleScript_BurnTurnDmg:: @ 81D953A printstring BATTLE_TEXT_BurnHurt waitmessage 64 jump BattleScript_1D951E @@ -3865,13 +3865,13 @@ gUnknown_081D95DB:: @ 81D95DB waitmessage 64 return -gUnknown_081D95E2:: @ 81D95E2 +BattleScript_WrapTurnDmg:: @ 81D95E2 playanimation USER, 6, 0x20160a4 printstring BATTLE_TEXT_HurtBy waitmessage 64 jump BattleScript_1D9520 -gUnknown_081D95F4:: @ 81D95F4 +BattleScript_WrapEnds:: @ 81D95F4 printstring BATTLE_TEXT_FreedFrom waitmessage 64 end2 @@ -3887,13 +3887,13 @@ gUnknown_081D9608:: @ 81D9608 waitmessage 64 jump BattleScript_EndTurn -gUnknown_081D9613:: @ 81D9613 +BattleScript_NightmareTurnDmg:: @ 81D9613 printstring BATTLE_TEXT_NightmareLock waitmessage 64 atk65 1, Start jump BattleScript_1D9520 -gUnknown_081D9624:: @ 81D9624 +BattleScript_CurseTurnDmg:: @ 81D9624 printstring BATTLE_TEXT_CurseAfflict waitmessage 64 atk65 1, 0x10000000 diff --git a/include/battle.h b/include/battle.h index 0aadd148f..a7ea7c6da 100644 --- a/include/battle.h +++ b/include/battle.h @@ -35,7 +35,10 @@ #define STATUS_PARALYSIS 0x40 #define STATUS_TOXIC_POISON 0x80 +#define STATUS_ANY ((STATUS_SLEEP | STATUS_POISON | STATUS_BURN | STATUS_FREEZE | STATUS_PARALYSIS | STATUS_TOXIC_POISON)) + #define STATUS2_CONFUSION 0x00000007 +#define STATUS2_FLINCHED 0x00000008 #define STATUS2_UPROAR 0x00000070 #define STATUS2_BIDE 0x00000300 //two bits 0x100 0x200 #define STATUS2_LOCK_CONFUSE 0x00000C00 @@ -87,7 +90,7 @@ #define HITMARKER_IGNORE_ON_AIR 0x00010000 #define HITMARKER_IGNORE_UNDERGROUND 0x00020000 #define HITMARKER_IGNORE_UNDERWATER 0x00040000 -#define HITMARKER_x80000 0x00080000 +#define HITMARKER_UNABLE_TO_USE_MOVE 0x00080000 #define HITMARKER_x100000 0x00100000 #define HITMARKER_x400000 0x00400000 #define HITMARKER_x800000 0x00800000 @@ -117,6 +120,17 @@ #define ABILITYEFFECT_COUNT_ON_FIELD 0x12 #define ABILITYEFFECT_CHECK_ON_FIELD 0x13 +#define MOVESTATUS_MISSED (1 << 0) +#define MOVESTATUS_SUPEREFFECTIVE (1 << 1) +#define MOVESTATUS_NOTVERYEFFECTIVE (1 << 2) +#define MOVESTATUS_NOTAFFECTED (1 << 3) +#define MOVESTATUS_ONEHITKO (1 << 4) +#define MOVESTATUS_FAILED (1 << 5) +#define MOVESTATUS_ENDURED (1 << 6) +#define MOVESTATUS_HUNGON (1 << 7) + +#define MOVESTATUS_NOEFFECT ((MOVESTATUS_MISSED | MOVESTATUS_NOTAFFECTED | MOVESTATUS_FAILED)) + #define MAX_TRAINER_ITEMS 4 #define MAX_MON_MOVES 4 #define MAX_BANKS_BATTLE 4 @@ -262,7 +276,7 @@ struct BattleStruct /* 0x2000000 */ /*0x16056*/ u8 moneyMultiplier; /*0x16057*/ u8 unk16057; /*0x16058*/ u8 unk16058; - /*0x16059*/ u8 unk16059; + /*0x16059*/ u8 sub80173A4_Tracker; /*0x1605A*/ u8 unk1605A; /*0x1605B*/ u8 unk1605B; /*0x1605C*/ u16 exp; @@ -283,10 +297,7 @@ struct BattleStruct /* 0x2000000 */ /*0x1608A*/ u8 unk1608A; /*0x1608B*/ u8 unk1608B; /*0x1608C*/ u8 ChosenMoveID[4]; - /*0x16090*/ u8 unk16090; - /*0x16091*/ u8 unk16091; - /*0x16092*/ u8 unk16092; - /*0x16093*/ u8 unk16093; + /*0x16090*/ s32 bideDmg; /*0x16094*/ u8 unk16094; /*0x16095*/ u8 unk16095; /*0x16096*/ u8 unk16096; @@ -360,7 +371,7 @@ struct BattleStruct /* 0x2000000 */ /*0x160E4*/ u8 unk160E4; /*0x160E5*/ u8 unk160E5; /*0x160E6*/ u8 unk160E6; - /*0x160E7*/ u8 unk160E7; + /*0x160E7*/ u8 atkCancellerTracker; /*0x160E8*/ u8 unk160E8; /*0x160E9*/ u8 unk160E9; /*0x160EA*/ u8 unk160EA; @@ -401,8 +412,8 @@ struct BattleStruct /* 0x2000000 */ /*0x1610D*/ u8 unk1610D; /*0x1610E*/ u8 unk1610E; /*0x1610F*/ u8 unk1610F; - /*0x16110*/ u8 unk16110; - /*0x16111*/ u8 unk16111; + /*0x16110*/ u8 sub80170DC_Tracker; + /*0x16111*/ u8 sub80170DC_Bank; /*0x16112*/ u8 unk16112; /*0x16113*/ u8 unk16113; /*0x16114*/ u8 unk16114; diff --git a/src/battle_3.c b/src/battle_3.c index 5c6bc8b07..cb0812034 100644 --- a/src/battle_3.c +++ b/src/battle_3.c @@ -10,6 +10,7 @@ #include "data2.h" #include "rng.h" #include "text.h" +#include "battle_move_effects.h" extern u8* gBattlescriptCurrInstr; extern u8 gActiveBank; @@ -35,7 +36,13 @@ extern u8 gAbsentBankFlags; extern u8 gBattleCommunication[]; extern u32 gHitMarker; extern u8 gEffectBank; +extern u8 gBank1; extern s32 gBattleMoveDamage; +extern u16 gBattlePartyID[4]; +extern u16 gChosenMovesByBanks[4]; +extern s32 gTakenDmg[4]; +extern u8 gTakenDmgBanks[4]; +extern u8 gBattleMoveFlags; u8 IsImprisoned(u8 bank, u16 move); u8 GetBankByPlayerAI(u8 ID); @@ -45,6 +52,11 @@ void b_call_bc_move_exec(u8* BS_ptr); bool8 sub_8015660(u8 bank); //check if a move failed void SetMoveEffect(bool8 primary, u8 certainArg); bool8 sub_8025A44(u8 bank); //uproar wakeup check +bool8 sub_8018018(u8 bank, u8, u8); +void sub_8015740(u8 bank); +s32 CalculateBaseDamage(struct BattlePokemon *attacker, struct BattlePokemon *defender, u32 move, u16 a4, u16 powerOverride, u8 typeOverride, u8 bank_atk, u8 bank_def); +u8 CountTrailingZeroBits(u32 a); +u8 sub_801B5C0(u16 move, u8 targetbyte); //get target of move extern u8 BattleScript_MoveSelectionDisabledMove[]; extern u8 BattleScript_MoveSelectionTormented[]; @@ -54,6 +66,17 @@ extern u8 BattleScript_MoveSelectionChoiceBanded[]; extern u8 BattleScript_MoveSelectionNoPP[]; extern u8 BattleScript_NoMovesLeft[]; extern u8 BattleScript_WishComesTrue[]; +extern u8 BattleScript_IngrainTurnHeal[]; +extern u8 BattleScript_LeechSeedTurnDrain[]; +extern u8 BattleScript_PoisonTurnDmg[]; +extern u8 BattleScript_BurnTurnDmg[]; +extern u8 BattleScript_NightmareTurnDmg[]; +extern u8 BattleScript_CurseTurnDmg[]; +extern u8 BattleScript_WrapTurnDmg[]; +extern u8 BattleScript_WrapEnds[]; +extern u8 BattleScript_DisabledNoMore[]; +extern u8 BattleScript_EncoredNoMore[]; + extern u8 gUnknown_081D9030[]; extern u8 gUnknown_081D8F62[]; extern u8 gUnknown_081D8FFF[]; @@ -61,21 +84,34 @@ extern u8 gUnknown_081D8F7D[]; extern u8 gUnknown_081D9016[]; extern u8 gUnknown_081D9008[]; extern u8 gUnknown_081D9041[]; - -extern u8 gUnknown_081D93D1[]; //ingrain bs -extern u8 gUnknown_081D904B[]; //leech seed BS -extern u8 gUnknown_081D9518[]; //poison dmg BS -extern u8 gUnknown_081D953A[]; //burn dmg BS -extern u8 gUnknown_081D9613[]; //nightmare dmg BS -extern u8 gUnknown_081D9624[]; //curse dmg BS -extern u8 gUnknown_081D95E2[]; //wrap dmg BS -extern u8 gUnknown_081D95F4[]; //wrap ends BS extern u8 gUnknown_081D950F[]; //uproar wakeup BS extern u8 gUnknown_081D957E[]; //uproar BS extern u8 gUnknown_081D9587[]; //thrash confusion BS -extern u8 gUnknown_081D9148[]; //disabled no more BS -extern u8 gUnknown_081D914F[]; //encored no more BS extern u8 gUnknown_081D964C[]; //yawn sleep BS +extern u8 gUnknown_081D92D7[]; //future sight hit +extern u8 gUnknown_081D9202[]; //perish song hit +extern u8 gUnknown_081D921D[]; //perish song timer goes down +extern u8 gUnknown_081D8C72[]; +extern u8 gUnknown_081D8C7B[]; +extern u8 gUnknown_081D94FB[]; //uproar wakes you up when trying to use a move +extern u8 gUnknown_081D94EE[]; //poke is asleep +extern u8 gUnknown_081D94FB[]; //poke woke up +extern u8 gUnknown_081D9545[]; //poke is frozen +extern u8 gUnknown_081D9552[]; //poke is no longer frozen +extern u8 gUnknown_081D9977[]; //poke is loafing around +extern u8 gUnknown_081D7956[]; //poke must recharge +extern u8 gUnknown_081D9573[]; //poke flinched +extern u8 gUnknown_081D9139[]; //poke tries to use a disabled move +extern u8 gUnknown_081D938F[]; //taunt prevents from using the chosen move +extern u8 gUnknown_081D9459[]; //using imprisoned move +extern u8 gUnknown_081D9595[]; //poke is confused +extern u8 gUnknown_081D95D4[]; //poke is confused no more +extern u8 gUnknown_081D9566[]; //poke is paralyzed +extern u8 gUnknown_081D9608[]; //poke is infatuated, won't attack +extern u8 gUnknown_081D95FB[]; //poke is infatuated +extern u8 gUnknown_081D90A7[]; //bide storing energy +extern u8 gUnknown_081D90B2[]; //bide attack +extern u8 gUnknown_081D90F1[]; //bide no energy to attack #define CHOICED_MOVE(bank)(((u16*)(&ewram[bank * 2 + 0x160e8]))) @@ -477,9 +513,10 @@ u8 UpdateTurnCounters(void) #define TURNBASED_MAX_CASE 19 -bool8 TurnBasedEffects(void) +u8 TurnBasedEffects(void) { u8 effect = 0; + gHitMarker |= (HITMARKER_GRUDGE | HITMARKER_x20); while (BATTLE_STRUCT->turnEffectsBank < gNoOfAllBanks && BATTLE_STRUCT->turnEffectsTracker <= TURNBASED_MAX_CASE) { @@ -490,67 +527,64 @@ bool8 TurnBasedEffects(void) } else { - int i; switch (BATTLE_STRUCT->turnEffectsTracker) { - case 0: //ingrain - if (gStatuses3[gActiveBank] & STATUS3_ROOTED && gBattleMons[gActiveBank].hp != gBattleMons[gActiveBank].maxHP && gBattleMons[gActiveBank].hp != 0) + case 0: // ingrain + if ((gStatuses3[gActiveBank] & STATUS3_ROOTED) + && gBattleMons[gActiveBank].hp != gBattleMons[gActiveBank].maxHP + && gBattleMons[gActiveBank].hp != 0) { gBattleMoveDamage = gBattleMons[gActiveBank].maxHP / 16; if (gBattleMoveDamage == 0) gBattleMoveDamage = 1; gBattleMoveDamage *= -1; - b_call_bc_move_exec(gUnknown_081D93D1); + b_call_bc_move_exec(BattleScript_IngrainTurnHeal); effect++; } BATTLE_STRUCT->turnEffectsTracker++; break; - case 1: //end turn abilities + case 1: // end turn abilities if (AbilityBattleEffects(ABILITYEFFECT_ENDTURN, gActiveBank, 0, 0, 0)) effect++; BATTLE_STRUCT->turnEffectsTracker++; break; - case 2: //item effects - if (ItemBattleEffects(0, gActiveBank, 0)) + case 2: // item effects + if (ItemBattleEffects(1, gActiveBank, 0)) effect++; BATTLE_STRUCT->turnEffectsTracker++; break; - case 18: //item effects again + case 18: // item effects again if (ItemBattleEffects(1, gActiveBank, 1)) effect++; BATTLE_STRUCT->turnEffectsTracker++; break; - case 3: //leech seed - { - u8 leecher; - if (gStatuses3[gActiveBank] & STATUS3_LEECHSEED && gBattleMons[leecher = (gStatuses3[gActiveBank] & STATUS3_LEECHSEED_BANK)].hp && gBattleMons[gActiveBank].hp) //wont match without this ugly leecher assignment - { - //u8 leecher = gStatuses3[gActiveBank] & STATUS3_LEECHSEED_BANK; - gBankTarget = leecher; //funny how the 'target' is actually the bank that receives HP - gBattleMoveDamage = gBattleMons[gActiveBank].maxHP / 8; - if (gBattleMoveDamage == 0) - gBattleMoveDamage = 1; - BATTLE_STRUCT->animArg1 = leecher; - BATTLE_STRUCT->animArg2 = gBankAttacker; - b_call_bc_move_exec(gUnknown_081D904B); - effect++; - } - BATTLE_STRUCT->turnEffectsTracker++; - } - break; - case 4: //poison - if (gBattleMons[gActiveBank].status1 & STATUS_POISON && gBattleMons[gActiveBank].hp) + case 3: // leech seed + if (gStatuses3[gActiveBank] & STATUS3_LEECHSEED && gBattleMons[gStatuses3[gActiveBank] & STATUS3_LEECHSEED_BANK].hp != 0 && gBattleMons[gActiveBank].hp != 0) { + gBankTarget = gStatuses3[gActiveBank] & STATUS3_LEECHSEED_BANK; //funny how the 'target' is actually the bank that receives HP gBattleMoveDamage = gBattleMons[gActiveBank].maxHP / 8; if (gBattleMoveDamage == 0) gBattleMoveDamage = 1; - b_call_bc_move_exec(gUnknown_081D9518); + BATTLE_STRUCT->animArg1 = gBankTarget; + BATTLE_STRUCT->animArg2 = gBankAttacker; + b_call_bc_move_exec(BattleScript_LeechSeedTurnDrain); effect++; } BATTLE_STRUCT->turnEffectsTracker++; break; - case 5: //toxic poison - if (gBattleMons[gActiveBank].status1 & STATUS_TOXIC_POISON && gBattleMons[gActiveBank].hp) + case 4: // poison + if ((gBattleMons[gActiveBank].status1 & STATUS_POISON) && gBattleMons[gActiveBank].hp != 0) + { + gBattleMoveDamage = gBattleMons[gActiveBank].maxHP / 8; + if (gBattleMoveDamage == 0) + gBattleMoveDamage = 1; + b_call_bc_move_exec(BattleScript_PoisonTurnDmg); + effect++; + } + BATTLE_STRUCT->turnEffectsTracker++; + break; + case 5: // toxic poison + if ((gBattleMons[gActiveBank].status1 & STATUS_TOXIC_POISON) && gBattleMons[gActiveBank].hp != 0) { gBattleMoveDamage = gBattleMons[gActiveBank].maxHP / 16; if (gBattleMoveDamage == 0) @@ -558,50 +592,50 @@ bool8 TurnBasedEffects(void) if ((gBattleMons[gActiveBank].status1 & 0xF00) != 0xF00) //not 16 turns gBattleMons[gActiveBank].status1 += 0x100; gBattleMoveDamage *= (gBattleMons[gActiveBank].status1 & 0xF00) >> 8; - b_call_bc_move_exec(gUnknown_081D9518); + b_call_bc_move_exec(BattleScript_PoisonTurnDmg); effect++; } BATTLE_STRUCT->turnEffectsTracker++; break; - case 6: //burn - if (gBattleMons[gActiveBank].status1 & STATUS_BURN && gBattleMons[gActiveBank].hp) + case 6: // burn + if ((gBattleMons[gActiveBank].status1 & STATUS_BURN) && gBattleMons[gActiveBank].hp != 0) { gBattleMoveDamage = gBattleMons[gActiveBank].maxHP / 8; if (gBattleMoveDamage == 0) gBattleMoveDamage = 1; - b_call_bc_move_exec(gUnknown_081D953A); + b_call_bc_move_exec(BattleScript_BurnTurnDmg); effect++; } BATTLE_STRUCT->turnEffectsTracker++; break; - case 7: //spooky nightmares - if (gBattleMons[gActiveBank].status2 & STATUS2_NIGHTMARE && gBattleMons[gActiveBank].hp) + case 7: // spooky nightmares + if ((gBattleMons[gActiveBank].status2 & STATUS2_NIGHTMARE) && gBattleMons[gActiveBank].hp != 0) { - //missing sleep check + // missing sleep check gBattleMoveDamage = gBattleMons[gActiveBank].maxHP / 4; if (gBattleMoveDamage == 0) gBattleMoveDamage = 1; - b_call_bc_move_exec(gUnknown_081D9613); + b_call_bc_move_exec(BattleScript_NightmareTurnDmg); effect++; } BATTLE_STRUCT->turnEffectsTracker++; break; - case 8: //curse - if (gBattleMons[gActiveBank].status2 & STATUS2_CURSED && gBattleMons[gActiveBank].hp) + case 8: // curse + if ((gBattleMons[gActiveBank].status2 & STATUS2_CURSED) && gBattleMons[gActiveBank].hp != 0) { gBattleMoveDamage = gBattleMons[gActiveBank].maxHP / 4; if (gBattleMoveDamage == 0) gBattleMoveDamage = 1; - b_call_bc_move_exec(gUnknown_081D9624); + b_call_bc_move_exec(BattleScript_CurseTurnDmg); effect++; } BATTLE_STRUCT->turnEffectsTracker++; break; - case 9: //wrap - if (gBattleMons[gActiveBank].status2 & STATUS2_WRAPPED && gBattleMons[gActiveBank].hp) + case 9: // wrap + if ((gBattleMons[gActiveBank].status2 & STATUS2_WRAPPED) && gBattleMons[gActiveBank].hp != 0) { - gBattleMons[gActiveBank].status2 &= 0xFFFFE000; //hmmm - if (gBattleMons[gActiveBank].status2 & STATUS2_WRAPPED) //damaged by wrap + gBattleMons[gActiveBank].status2 -= 0x2000; + if (gBattleMons[gActiveBank].status2 & STATUS2_WRAPPED) // damaged by wrap { BATTLE_STRUCT->animArg1 = ewram[gActiveBank * 2 + 0x16004]; BATTLE_STRUCT->animArg2 = ewram[gActiveBank * 2 + 0x16005]; @@ -609,52 +643,53 @@ bool8 TurnBasedEffects(void) gBattleTextBuff1[1] = 2; gBattleTextBuff1[2] = ewram[gActiveBank * 2 + 0x16004]; gBattleTextBuff1[3] = ewram[gActiveBank * 2 + 0x16005]; - gBattleTextBuff1[4] = 0xFF; - gBattlescriptCurrInstr = gUnknown_081D95E2; + gBattleTextBuff1[4] = EOS; + gBattlescriptCurrInstr = BattleScript_WrapTurnDmg; gBattleMoveDamage = gBattleMons[gActiveBank].maxHP / 16; if (gBattleMoveDamage == 0) gBattleMoveDamage = 1; } - else //broke free + else // broke free { gBattleTextBuff1[0] = 0xFD; gBattleTextBuff1[1] = 2; gBattleTextBuff1[2] = ewram[gActiveBank * 2 + 0x16004]; gBattleTextBuff1[3] = ewram[gActiveBank * 2 + 0x16005]; - gBattleTextBuff1[4] = 0xFF; - gBattlescriptCurrInstr = gUnknown_081D95F4; + gBattleTextBuff1[4] = EOS; + gBattlescriptCurrInstr = BattleScript_WrapEnds; } b_call_bc_move_exec(gBattlescriptCurrInstr); effect++; } BATTLE_STRUCT->turnEffectsTracker++; break; - case 10: //uproar + case 10: // uproar if (gBattleMons[gActiveBank].status2 & STATUS2_UPROAR) { for (gBankAttacker = 0; gBankAttacker < gNoOfAllBanks; gBankAttacker++) { - if (gBattleMons[gBankAttacker].status1 & STATUS_SLEEP && gBattleMons[gBankAttacker].ability != ABILITY_SOUNDPROOF) + if ((gBattleMons[gBankAttacker].status1 & STATUS_SLEEP) + && gBattleMons[gBankAttacker].ability != ABILITY_SOUNDPROOF) { gBattleMons[gBankAttacker].status1 &= ~(STATUS_SLEEP); gBattleMons[gBankAttacker].status2 &= ~(STATUS2_NIGHTMARE); gBattleCommunication[MULTISTRING_CHOOSER] = 1; b_call_bc_move_exec(gUnknown_081D950F); gActiveBank = gBankAttacker; - EmitSetAttributes(0, REQUEST_STATUS_BATTLE, 0, 4, &gBattleMons[gBankAttacker].status1); + EmitSetAttributes(0, REQUEST_STATUS_BATTLE, 0, 4, &gBattleMons[gActiveBank].status1); MarkBufferBankForExecution(gActiveBank); break; } } if (gBankAttacker != gNoOfAllBanks) { - effect = 2; //a pokemon was awaken + effect = 2; // a pokemon was awaken break; } else { gBankAttacker = gActiveBank; - gBattleMons[gActiveBank].status2 -= 0x10; //uproar timer goes down + gBattleMons[gActiveBank].status2 -= 0x10; // uproar timer goes down if (sub_8015660(gActiveBank)) { CancelMultiTurnMoves(gActiveBank); @@ -677,15 +712,16 @@ bool8 TurnBasedEffects(void) if (effect != 2) BATTLE_STRUCT->turnEffectsTracker++; break; - case 11: //thrash + case 11: // thrash if (gBattleMons[gActiveBank].status2 & STATUS2_LOCK_CONFUSE) { - gBattleMons[gActiveBank].status2 &= 0xFFFFFC00; + gBattleMons[gActiveBank].status2 -= 0x400; if (sub_8015660(gActiveBank)) CancelMultiTurnMoves(gActiveBank); - else if (!(gBattleMons[gActiveBank].status2 & STATUS2_LOCK_CONFUSE) && gBattleMons[gActiveBank].status2 & STATUS2_MULTIPLETURNS) + else if (!(gBattleMons[gActiveBank].status2 & STATUS2_LOCK_CONFUSE) + && (gBattleMons[gActiveBank].status2 & STATUS2_MULTIPLETURNS)) { - gBattleMons[gActiveBank].status2 &= 0xFFFFEFFF; + gBattleMons[gActiveBank].status2 &= ~(STATUS2_MULTIPLETURNS); if (!(gBattleMons[gActiveBank].status2 & STATUS2_CONFUSION)) { gBattleCommunication[MOVE_EFFECT_BYTE] = 0x47; @@ -698,67 +734,70 @@ bool8 TurnBasedEffects(void) } BATTLE_STRUCT->turnEffectsTracker++; break; - case 12: //disable - if (gDisableStructs[gActiveBank].disableTimer1) + case 12: // disable + if (gDisableStructs[gActiveBank].disableTimer1 != 0) { + int i; for (i = 0; i < 4; i++) { if (gDisableStructs[gActiveBank].disabledMove == gBattleMons[gActiveBank].moves[i]) break; } - if (i == 4) //pokemon does not have the disabled move anymore + if (i == 4) // pokemon does not have the disabled move anymore { gDisableStructs[gActiveBank].disabledMove = 0; gDisableStructs[gActiveBank].disableTimer1 = 0; } - else if (--gDisableStructs[gActiveBank].disableTimer1 == 0) //disable ends + else if (--gDisableStructs[gActiveBank].disableTimer1 == 0) // disable ends { gDisableStructs[gActiveBank].disabledMove = 0; - b_call_bc_move_exec(gUnknown_081D9148); + b_call_bc_move_exec(BattleScript_DisabledNoMore); effect++; } } BATTLE_STRUCT->turnEffectsTracker++; break; - case 13: //encore - if (gDisableStructs[gActiveBank].encoreTimer1) + case 13: // encore + if (gDisableStructs[gActiveBank].encoreTimer1 != 0) { - if (gBattleMons[gActiveBank].moves[gDisableStructs[gActiveBank].encoredMovePos] != gDisableStructs[gActiveBank].encoredMove) //pokemon does not have the encored move anymore + if (gBattleMons[gActiveBank].moves[gDisableStructs[gActiveBank].encoredMovePos] != gDisableStructs[gActiveBank].encoredMove) // pokemon does not have the encored move anymore { gDisableStructs[gActiveBank].encoredMove = 0; gDisableStructs[gActiveBank].encoreTimer1 = 0; } - else if (--gDisableStructs[gActiveBank].encoreTimer1 == 0 || gBattleMons[gActiveBank].pp[gDisableStructs[gActiveBank].encoredMovePos] == 0) + else if (--gDisableStructs[gActiveBank].encoreTimer1 == 0 + || gBattleMons[gActiveBank].pp[gDisableStructs[gActiveBank].encoredMovePos] == 0) { gDisableStructs[gActiveBank].encoredMove = 0; gDisableStructs[gActiveBank].encoreTimer1 = 0; - b_call_bc_move_exec(gUnknown_081D914F); + b_call_bc_move_exec(BattleScript_EncoredNoMore); effect++; } } BATTLE_STRUCT->turnEffectsTracker++; break; - case 14: //lock-on decrement + case 14: // lock-on decrement if (gStatuses3[gActiveBank] & STATUS3_ALWAYS_HITS) gStatuses3[gActiveBank] -= 0x8; BATTLE_STRUCT->turnEffectsTracker++; break; - case 15: //charge + case 15: // charge if (gDisableStructs[gActiveBank].chargeTimer1 && --gDisableStructs[gActiveBank].chargeTimer1 == 0) gStatuses3[gActiveBank] &= ~STATUS3_CHARGED_UP; BATTLE_STRUCT->turnEffectsTracker++; break; - case 16: //taunt + case 16: // taunt if (gDisableStructs[gActiveBank].tauntTimer1) gDisableStructs[gActiveBank].tauntTimer1--; BATTLE_STRUCT->turnEffectsTracker++; break; - case 17: //yawn + case 17: // yawn if (gStatuses3[gActiveBank] & STATUS3_YAWN) { - gStatuses3[gActiveBank] &= 0xFFFFF800; - if (!(gStatuses3[gActiveBank] & STATUS3_YAWN) && !gBattleMons[gActiveBank].status1 && gBattleMons[gActiveBank].ability != ABILITY_VITAL_SPIRIT - && gBattleMons[gActiveBank].ability != ABILITY_INSOMNIA && !sub_8025A44(gActiveBank)) + gStatuses3[gActiveBank] -= 0x800; + if (!(gStatuses3[gActiveBank] & STATUS3_YAWN) && !(gBattleMons[gActiveBank].status1 & STATUS_ANY) + && gBattleMons[gActiveBank].ability != ABILITY_VITAL_SPIRIT + && gBattleMons[gActiveBank].ability != ABILITY_INSOMNIA && !sub_8025A44(gActiveBank)) { CancelMultiTurnMoves(gActiveBank); gBattleMons[gActiveBank].status1 |= (Random() & 3) + 2; @@ -771,15 +810,440 @@ bool8 TurnBasedEffects(void) } BATTLE_STRUCT->turnEffectsTracker++; break; - case 19: //done + case 19: // done BATTLE_STRUCT->turnEffectsTracker = 0; BATTLE_STRUCT->turnEffectsBank++; break; } - if (effect) + if (effect != 0) return effect; } } gHitMarker &= ~(HITMARKER_GRUDGE | HITMARKER_x20); return 0; } + +bool8 sub_80170DC(void) // handle future sight and perish song +{ + gHitMarker |= (HITMARKER_GRUDGE | HITMARKER_x20); + switch (BATTLE_STRUCT->sub80170DC_Tracker) + { + case 0: // future sight + while (BATTLE_STRUCT->sub80170DC_Bank < gNoOfAllBanks) + { + gActiveBank = BATTLE_STRUCT->sub80170DC_Bank; + if (gAbsentBankFlags & gBitTable[gActiveBank]) + BATTLE_STRUCT->sub80170DC_Bank++; + else + { + BATTLE_STRUCT->sub80170DC_Bank++; + if (gWishFutureKnock.futureSightCounter[gActiveBank] && --gWishFutureKnock.futureSightCounter[gActiveBank] == 0 && gBattleMons[gActiveBank].hp) + { + if (gWishFutureKnock.futureSightMove[gActiveBank] == MOVE_FUTURE_SIGHT) + gBattleCommunication[MULTISTRING_CHOOSER] = 0; + else //Doom Desire + gBattleCommunication[MULTISTRING_CHOOSER] = 1; + gBattleTextBuff1[0] = 0xFD; + gBattleTextBuff1[1] = 2; + gBattleTextBuff1[2] = gWishFutureKnock.futureSightMove[gActiveBank]; + gBattleTextBuff1[3] = gWishFutureKnock.futureSightMove[gActiveBank] >> 8; + gBattleTextBuff1[4] = 0xFF; + gBankTarget = gActiveBank; + gBankAttacker = gWishFutureKnock.futureSightAttacker[gActiveBank]; + gBattleMoveDamage = gWishFutureKnock.futureSightDmg[gActiveBank]; + gSpecialStatuses[gBankTarget].moveturnLostHP = 0xFFFF; + b_call_bc_move_exec(gUnknown_081D92D7); + return 1; + } + } + } + BATTLE_STRUCT->sub80170DC_Tracker = 1; + BATTLE_STRUCT->sub80170DC_Bank = 0; + case 1: // perish song + while (BATTLE_STRUCT->sub80170DC_Bank < gNoOfAllBanks) + { + gActiveBank = gBankAttacker = gTurnOrder[BATTLE_STRUCT->sub80170DC_Bank]; + if (gAbsentBankFlags & gBitTable[gActiveBank]) + BATTLE_STRUCT->sub80170DC_Bank++; + else + { + BATTLE_STRUCT->sub80170DC_Bank++; + if (gStatuses3[gActiveBank] & STATUS3_PERISH_SONG) + { + gBattleTextBuff1[0] = 0xFD; + gBattleTextBuff1[1] = 1; + gBattleTextBuff1[2] = 1; + gBattleTextBuff1[3] = 1; + gBattleTextBuff1[4] = gDisableStructs[gActiveBank].perishSong1; + gBattleTextBuff1[5] = 0xFF; + if (gDisableStructs[gActiveBank].perishSong1 == 0) + { + gStatuses3[gActiveBank] &= ~(STATUS3_PERISH_SONG); + gBattleMoveDamage = gBattleMons[gActiveBank].hp; + gBattlescriptCurrInstr = gUnknown_081D9202; + } + else + { + gDisableStructs[gActiveBank].perishSong1--; + gBattlescriptCurrInstr = gUnknown_081D921D; + } + b_call_bc_move_exec(gBattlescriptCurrInstr); + return 1; + } + } + } + break; + } + gHitMarker &= ~(HITMARKER_GRUDGE | HITMARKER_x20); + return 0; +} + +#define sub_80173A4_MAX_CASE 7 + +bool8 sub_80173A4(void) +{ + if (gBattleTypeFlags & BATTLE_TYPE_SAFARI) + return 0; + do + { + int i; + switch (BATTLE_STRUCT->sub80173A4_Tracker) + { + case 0: + BATTLE_STRUCT->unk1605A = 0; + BATTLE_STRUCT->sub80173A4_Tracker++; + for (i = 0; i < gNoOfAllBanks; i++) + { + if (gAbsentBankFlags & gBitTable[i] && !sub_8018018(i, 6, 6)) + gAbsentBankFlags &= ~(gBitTable[i]); + } + case 1: + do + { + gBank1 = gBankTarget = BATTLE_STRUCT->unk1605A; + if (gBattleMons[BATTLE_STRUCT->unk1605A].hp == 0 && !(BATTLE_STRUCT->unk16113 & gBitTable[gBattlePartyID[BATTLE_STRUCT->unk1605A]]) && !(gAbsentBankFlags & gBitTable[BATTLE_STRUCT->unk1605A])) + { + b_call_bc_move_exec(gUnknown_081D8C72); + BATTLE_STRUCT->sub80173A4_Tracker = 2; + return 1; + } + } while (++BATTLE_STRUCT->unk1605A != gNoOfAllBanks); + BATTLE_STRUCT->sub80173A4_Tracker = 3; + break; + case 2: + sub_8015740(gBank1); + if (++BATTLE_STRUCT->unk1605A == gNoOfAllBanks) + BATTLE_STRUCT->sub80173A4_Tracker = 3; + else + BATTLE_STRUCT->sub80173A4_Tracker = 1; + break; + case 3: + BATTLE_STRUCT->unk1605A = 0; + BATTLE_STRUCT->sub80173A4_Tracker++; + case 4: + do + { + gBank1 = gBankTarget = BATTLE_STRUCT->unk1605A; //or should banks be switched? + if (gBattleMons[BATTLE_STRUCT->unk1605A].hp == 0 && !(gAbsentBankFlags & gBitTable[BATTLE_STRUCT->unk1605A])) + { + b_call_bc_move_exec(gUnknown_081D8C7B); + BATTLE_STRUCT->sub80173A4_Tracker = 5; + return 1; + } + } while (++BATTLE_STRUCT->unk1605A != gNoOfAllBanks); + BATTLE_STRUCT->sub80173A4_Tracker = 6; + break; + case 5: + if (++BATTLE_STRUCT->unk1605A == gNoOfAllBanks) + BATTLE_STRUCT->sub80173A4_Tracker = 6; + else + BATTLE_STRUCT->sub80173A4_Tracker = 4; + break; + case 6: + if (AbilityBattleEffects(9, 0, 0, 0, 0) || AbilityBattleEffects(0xB, 0, 0, 0, 0) || ItemBattleEffects(1, 0, 1) || AbilityBattleEffects(6, 0, 0, 0, 0)) + return 1; + BATTLE_STRUCT->sub80173A4_Tracker++; + break; + case 7: + break; + } + } while (BATTLE_STRUCT->sub80173A4_Tracker != sub_80173A4_MAX_CASE); + return 0; +} + +void b_clear_atk_up_if_hit_flag_unless_enraged(void) +{ + int i; + for (i = 0; i < gNoOfAllBanks; i++) + { + if (gBattleMons[i].status2 & STATUS2_RAGE && gChosenMovesByBanks[i] != MOVE_RAGE) + gBattleMons[i].status2 &= ~(STATUS2_RAGE); + } +} + +#define ATKCANCELLER_MAX_CASE 14 +/* +u8 AtkCanceller_UnableToUseMove(void) +{ + u8 effect = 0; + s32* bideDmg = &BATTLE_STRUCT->bideDmg; + do + { + switch (BATTLE_STRUCT->atkCancellerTracker) + { + case 0: // flags clear + gBattleMons[gBankAttacker].status2 &= ~(STATUS2_DESTINY_BOND); + gStatuses3[gBankAttacker] &= ~(STATUS3_GRUDGE); + BATTLE_STRUCT->atkCancellerTracker++; + break; + case 1: // check being asleep + if (gBattleMons[gBankAttacker].status1 & STATUS_SLEEP) + { + if (sub_8025A44(gBankAttacker)) + { + gBattleMons[gBankAttacker].status1 &= ~(STATUS_SLEEP); + gBattleMons[gBankAttacker].status2 &= ~(STATUS2_NIGHTMARE); + b_movescr_stack_push_cursor(); + gBattleCommunication[MULTISTRING_CHOOSER] = 1; + gBattlescriptCurrInstr = gUnknown_081D94FB; + effect = 2; + } + else + { + u8 toSub; + if (gBattleMons[gBankAttacker].ability == ABILITY_EARLY_BIRD) + toSub = 2; + else + toSub = 1; + if ((gBattleMons[gBankAttacker].status1 & STATUS_SLEEP) < toSub) + gBattleMons[gBankAttacker].status1 &= ~(STATUS_SLEEP); + else + gBattleMons[gBankAttacker].status1 -= toSub; + if (gBattleMons[gBankAttacker].status1 & STATUS_SLEEP) + { + if (gCurrentMove != MOVE_SNORE && gCurrentMove != MOVE_SLEEP_TALK) + { + gBattlescriptCurrInstr = gUnknown_081D94EE; + gHitMarker |= HITMARKER_UNABLE_TO_USE_MOVE; + effect = 2; + } + } + else + { + gBattleMons[gBankAttacker].status2 &= ~(STATUS2_NIGHTMARE); + b_movescr_stack_push_cursor(); + gBattleCommunication[MULTISTRING_CHOOSER] = 0; + gBattlescriptCurrInstr = gUnknown_081D94FB; + effect = 2; + } + } + } + BATTLE_STRUCT->atkCancellerTracker++; + break; + case 2: // check being frozen + if (gBattleMons[gBankAttacker].status1 & STATUS_FREEZE) + { + if (Random() % 5) + { + if (gBattleMoves[gCurrentMove].effect != EFFECT_THAW_HIT) // unfreezing via a move effect happens in case 13 + { + gBattlescriptCurrInstr = gUnknown_081D9545; + gHitMarker |= HITMARKER_NO_ATTACKSTRING; + effect = 2; + } + } + else // unfreeze + { + gBattleMons[gBankAttacker].status1 &= ~(STATUS_FREEZE); + b_movescr_stack_push_cursor(); + gBattlescriptCurrInstr = gUnknown_081D9552; + gBattleCommunication[MULTISTRING_CHOOSER] = 0; + effect = 2; + } + } + BATTLE_STRUCT->atkCancellerTracker++; + break; + case 3: // truant + if (gBattleMons[gBankAttacker].ability == ABILITY_TRUANT && gDisableStructs[gBankAttacker].truantCounter) + { + CancelMultiTurnMoves(gBankAttacker); + gHitMarker |= HITMARKER_UNABLE_TO_USE_MOVE; + gBattleCommunication[MULTISTRING_CHOOSER] = 0; + gBattlescriptCurrInstr = gUnknown_081D9977; + gBattleMoveFlags |= MOVESTATUS_MISSED; + effect = 1; + } + BATTLE_STRUCT->atkCancellerTracker++; + break; + case 4: // recharge + if (gBattleMons[gBankAttacker].status2 & STATUS2_RECHARGE) + { + gBattleMons[gBankAttacker].status2 &= ~(STATUS2_RECHARGE); + gDisableStructs[gBankAttacker].rechargeCounter = 0; + CancelMultiTurnMoves(gBankAttacker); + gBattlescriptCurrInstr = gUnknown_081D7956; + gHitMarker |= HITMARKER_UNABLE_TO_USE_MOVE; + effect = 1; + } + BATTLE_STRUCT->atkCancellerTracker++; + break; + case 5: // flinch + if (gBattleMons[gBankAttacker].status2 & STATUS2_FLINCHED) + { + gBattleMons[gBankAttacker].status2 &= ~(STATUS2_FLINCHED); + gProtectStructs[gBankAttacker].flinchImmobility = 1; + CancelMultiTurnMoves(gBankAttacker); + gBattlescriptCurrInstr = gUnknown_081D9573; + gHitMarker |= HITMARKER_UNABLE_TO_USE_MOVE; + effect = 1; + } + BATTLE_STRUCT->atkCancellerTracker++; + break; + case 6: // disabled move + if (gDisableStructs[gBankAttacker].disabledMove == gCurrentMove && gDisableStructs[gBankAttacker].disabledMove != 0) + { + gProtectStructs[gBankAttacker].usedDisabledMove = 1; + BATTLE_STRUCT->scriptingActive = gBankAttacker; + CancelMultiTurnMoves(gBankAttacker); + gBattlescriptCurrInstr = gUnknown_081D9139; + gHitMarker |= HITMARKER_UNABLE_TO_USE_MOVE; + effect = 1; + } + BATTLE_STRUCT->atkCancellerTracker++; + break; + case 7: // taunt + if (gDisableStructs[gBankAttacker].tauntTimer1 && gBattleMoves[gCurrentMove].power == 0) + { + gProtectStructs[gBankAttacker].usedTauntedMove = 1; + CancelMultiTurnMoves(gBankAttacker); + gBattlescriptCurrInstr = gUnknown_081D938F; + gHitMarker |= HITMARKER_UNABLE_TO_USE_MOVE; + effect = 1; + } + BATTLE_STRUCT->atkCancellerTracker++; + break; + case 8: // imprisoned + if (IsImprisoned(gBankAttacker, gCurrentMove)) + { + gProtectStructs[gBankAttacker].usedImprisionedMove = 1; + CancelMultiTurnMoves(gBankAttacker); + gBattlescriptCurrInstr = gUnknown_081D9459; + gHitMarker |= HITMARKER_UNABLE_TO_USE_MOVE; + effect = 1; + } + BATTLE_STRUCT->atkCancellerTracker++; + break; + case 9: // confusion + if (gBattleMons[gBankAttacker].status2 & STATUS2_CONFUSION) + { + gBattleMons[gBankAttacker].status2--; + if (gBattleMons[gBankAttacker].status2 & STATUS2_CONFUSION) + { + if (Random() & 1) + { + gBattleCommunication[MULTISTRING_CHOOSER] = 0; + b_movescr_stack_push_cursor(); + } + else // confusion dmg + { + gBattleCommunication[MULTISTRING_CHOOSER] = 1; + gBankTarget = gBankAttacker; + gBattleMoveDamage = CalculateBaseDamage(&gBattleMons[gBankAttacker], &gBattleMons[gBankAttacker], MOVE_POUND, 0, 40, 0, gBankAttacker, gBankAttacker); + gProtectStructs[gBankAttacker].confusionSelfDmg = 1; + gHitMarker |= HITMARKER_UNABLE_TO_USE_MOVE; + } + gBattlescriptCurrInstr = gUnknown_081D9595; + } + else // snapped out of confusion + { + b_movescr_stack_push_cursor(); + gBattlescriptCurrInstr = gUnknown_081D95D4; + } + effect = 1; + } + BATTLE_STRUCT->atkCancellerTracker++; + break; + case 10: // paralysis + if (gBattleMons[gBankAttacker].status1 & STATUS_PARALYSIS && (Random() % 4) == 0) + { + gProtectStructs[gBankAttacker].prlzImmobility = 1; + CancelMultiTurnMoves(gBankAttacker); + gBattlescriptCurrInstr = gUnknown_081D9566; + gHitMarker |= HITMARKER_UNABLE_TO_USE_MOVE; + effect = 1; + } + BATTLE_STRUCT->atkCancellerTracker++; + break; + case 11: // infatuation + if (gBattleMons[gBankAttacker].status2 & STATUS2_INFATUATION) + { + BATTLE_STRUCT->scriptingActive = CountTrailingZeroBits(gBattleMons[gBankAttacker].status2 >> 0x10); + if (Random() & 1) + b_movescr_stack_push_cursor(); + else + { + b_movescr_stack_push(gUnknown_081D9608); + gHitMarker |= HITMARKER_UNABLE_TO_USE_MOVE; + gProtectStructs[gBankAttacker].loveImmobility = 1; + CancelMultiTurnMoves(gBankAttacker); + } + gBattlescriptCurrInstr = gUnknown_081D95FB; + effect = 1; + } + BATTLE_STRUCT->atkCancellerTracker++; + break; + case 12: // bide + if (gBattleMons[gBankAttacker].status2 & STATUS2_BIDE) + { + gBattleMons[gBankAttacker].status2 -= 0x100; + if (gBattleMons[gBankAttacker].status2 & STATUS2_BIDE) + gBattlescriptCurrInstr = gUnknown_081D90A7; + else + { + gBattleMons[gBankAttacker].status2 &= ~(STATUS2_BIDE); + if (gTakenDmg[gBankAttacker]) + { + gCurrentMove = MOVE_BIDE; + *bideDmg = gTakenDmg[gBankAttacker] * 2; + gBankTarget = gTakenDmgBanks[gBankAttacker]; + if (gAbsentBankFlags & gBitTable[gBankTarget]) + gBankTarget = sub_801B5C0(MOVE_BIDE, 1); + gBattlescriptCurrInstr = gUnknown_081D90B2; + } + else + gBattlescriptCurrInstr = gUnknown_081D90F1; + } + effect = 1; + } + BATTLE_STRUCT->atkCancellerTracker++; + break; + case 13: // move thawing + if (gBattleMons[gBankAttacker].status1 & STATUS_FREEZE) + { + if (gBattleMoves[gCurrentMove].effect == EFFECT_THAW_HIT) + { + gBattleMons[gBankAttacker].status1 &= ~(STATUS_FREEZE); + b_movescr_stack_push_cursor(); + gBattlescriptCurrInstr = gUnknown_081D9552; + gBattleCommunication[MULTISTRING_CHOOSER] = 1; + } + effect = 2; + } + BATTLE_STRUCT->atkCancellerTracker++; + break; + case 14: // last case + break; + } + + } while (BATTLE_STRUCT->atkCancellerTracker != ATKCANCELLER_MAX_CASE && effect == 0); + + if (effect == 2) + { + gActiveBank = gBankAttacker; + EmitSetAttributes(0, REQUEST_STATUS_BATTLE, 0, 4, &gBattleMons[gActiveBank].status1); + MarkBufferBankForExecution(gActiveBank); + } + return effect; +} + +*/ diff --git a/src/battle_4.c b/src/battle_4.c index ced5b9b8c..eb21d5e0f 100644 --- a/src/battle_4.c +++ b/src/battle_4.c @@ -95,7 +95,7 @@ extern u16 gUnknown_02024C4C[4]; //last used moves by banks, another one extern u8 gCurrentMoveTurn; //extern functions -bool8 CantUseMove(void); +u8 AtkCanceller_UnableToUseMove(void); void PressurePPLose(u8 bank_atk, u8 bank_def, u16 move); void CancelMultiTurnMoves(u8 bank); void b_movescr_stack_push(u8* BS_ptr); @@ -223,18 +223,6 @@ extern u8 gUnknown_081D95DB[]; //bs payday money give #define BS2ScriptRead16(ptr) ((ptr)[0] + ((ptr)[1] << 8)) #define BS2ScriptReadPtr(ptr) ((void *)BS2ScriptRead32(ptr)) - -#define MOVESTATUS_MISSED (1 << 0) -#define MOVESTATUS_SUPEREFFECTIVE (1 << 1) -#define MOVESTATUS_NOTVERYEFFECTIVE (1 << 2) -#define MOVESTATUS_NOTAFFECTED (1 << 3) -#define MOVESTATUS_ONEHITKO (1 << 4) -#define MOVESTATUS_FAILED (1 << 5) -#define MOVESTATUS_ENDURED (1 << 6) -#define MOVESTATUS_HUNGON (1 << 7) - -#define MOVESTATUS_NOEFFECT ((MOVESTATUS_MISSED | MOVESTATUS_NOTAFFECTED | MOVESTATUS_FAILED)) - #define TargetProtectAffected ((gProtectStructs[gBankTarget].protected && gBattleMoves[gCurrentMove].flags & FLAG_PROTECT_AFFECTED)) //array entries for battle communication @@ -1050,11 +1038,11 @@ static void atk00_attackcanceler(void) } if (gBattleMons[gBankAttacker].hp == 0 && !(gHitMarker & HITMARKER_NO_ATTACKSTRING)) { - gHitMarker |= HITMARKER_x80000; + gHitMarker |= HITMARKER_UNABLE_TO_USE_MOVE; gBattlescriptCurrInstr = BattleScript_EndTurn; return; } - if (CantUseMove()) + if (AtkCanceller_UnableToUseMove()) return; if (AbilityBattleEffects(2, gBankTarget, 0, 0, 0)) return; From 1416c0c79d9fd6903f1d13f2a7740df4bad100d3 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Wed, 26 Jul 2017 18:23:41 +0200 Subject: [PATCH 4/8] the ultimate challenge --- asm/battle_3.s | 4783 --------------------------------------------- include/battle.h | 18 +- include/pokemon.h | 1 + src/battle_3.c | 900 ++++++++- src/battle_4.c | 5 +- 5 files changed, 913 insertions(+), 4794 deletions(-) diff --git a/asm/battle_3.s b/asm/battle_3.s index 13660f368..57ed0b8f4 100644 --- a/asm/battle_3.s +++ b/asm/battle_3.s @@ -6,4789 +6,6 @@ .text - thumb_func_start AtkCanceller_UnableToUseMove -AtkCanceller_UnableToUseMove: @ 8017718 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x10 - movs r0, 0 - mov r9, r0 - ldr r1, _08017734 @ =0x02016090 - mov r10, r1 - ldr r2, _08017738 @ =0xfffe9f70 - add r2, r10 - mov r8, r2 - b _08017746 - .align 2, 0 -_08017734: .4byte 0x02016090 -_08017738: .4byte 0xfffe9f70 -_0801773C: - mov r4, r9 - cmp r4, 0 - beq _08017746 - bl _08017FAC -_08017746: - ldr r0, _08017760 @ =0x000160e7 - add r0, r8 - ldrb r0, [r0] - cmp r0, 0xE - bls _08017754 - bl _08017F9E -_08017754: - lsls r0, 2 - ldr r1, _08017764 @ =_08017768 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .align 2, 0 -_08017760: .4byte 0x000160e7 -_08017764: .4byte _08017768 - .align 2, 0 -_08017768: - .4byte _080177A4 - .4byte _080177E4 - .4byte _08017920 - .4byte _080179D8 - .4byte _08017A50 - .4byte _08017AC8 - .4byte _08017B1C - .4byte _08017B98 - .4byte _08017C1C - .4byte _08017C60 - .4byte _08017D3C - .4byte _08017DC0 - .4byte _08017E5C - .4byte _08017F48 - .4byte _08017F9E -_080177A4: - ldr r1, _080177D0 @ =gBattleMons - ldr r3, _080177D4 @ =gBankAttacker - ldrb r2, [r3] - movs r0, 0x58 - muls r2, r0 - adds r1, 0x50 - adds r2, r1 - ldr r0, [r2] - ldr r1, _080177D8 @ =0xfdffffff - ands r0, r1 - str r0, [r2] - ldr r0, _080177DC @ =gStatuses3 - ldrb r2, [r3] - lsls r2, 2 - adds r2, r0 - ldr r0, [r2] - ldr r1, _080177E0 @ =0xffffbfff - ands r0, r1 - str r0, [r2] - bl _08017F94 - .align 2, 0 -_080177D0: .4byte gBattleMons -_080177D4: .4byte gBankAttacker -_080177D8: .4byte 0xfdffffff -_080177DC: .4byte gStatuses3 -_080177E0: .4byte 0xffffbfff -_080177E4: - ldr r7, _0801784C @ =gBattleMons - ldr r4, _08017850 @ =gBankAttacker - ldrb r1, [r4] - movs r5, 0x58 - adds r0, r1, 0 - muls r0, r5 - adds r6, r7, 0 - adds r6, 0x4C - adds r0, r6 - ldr r0, [r0] - movs r2, 0x7 - mov r8, r2 - ands r0, r2 - cmp r0, 0 - bne _08017804 - b _08017D90 -_08017804: - adds r0, r1, 0 - bl sub_8025A44 - lsls r0, 24 - cmp r0, 0 - beq _08017864 - ldrb r0, [r4] - adds r2, r0, 0 - muls r2, r5 - adds r2, r6 - ldr r0, [r2] - movs r1, 0x8 - negs r1, r1 - ands r0, r1 - str r0, [r2] - ldrb r0, [r4] - adds r2, r0, 0 - muls r2, r5 - adds r0, r7, 0 - adds r0, 0x50 - adds r2, r0 - ldr r0, [r2] - ldr r1, _08017854 @ =0xf7ffffff - ands r0, r1 - str r0, [r2] - bl b_movescr_stack_push_cursor - ldr r1, _08017858 @ =gBattleCommunication - movs r0, 0x1 - strb r0, [r1, 0x5] - ldr r1, _0801785C @ =gBattlescriptCurrInstr - ldr r0, _08017860 @ =gUnknown_081D94FB - str r0, [r1] - movs r4, 0x2 - mov r9, r4 - b _08017D90 - .align 2, 0 -_0801784C: .4byte gBattleMons -_08017850: .4byte gBankAttacker -_08017854: .4byte 0xf7ffffff -_08017858: .4byte gBattleCommunication -_0801785C: .4byte gBattlescriptCurrInstr -_08017860: .4byte gUnknown_081D94FB -_08017864: - ldrb r0, [r4] - adds r1, r0, 0 - muls r1, r5 - adds r0, r1, r7 - adds r0, 0x20 - ldrb r0, [r0] - movs r3, 0x1 - cmp r0, 0x30 - bne _08017878 - movs r3, 0x2 -_08017878: - adds r2, r1, r6 - ldr r1, [r2] - adds r0, r1, 0 - mov r7, r8 - ands r0, r7 - cmp r0, r3 - bcs _08017890 - movs r0, 0x8 - negs r0, r0 - ands r1, r0 - str r1, [r2] - b _08017894 -_08017890: - subs r0, r1, r3 - str r0, [r2] -_08017894: - ldr r2, _080178D8 @ =gBattleMons - ldr r0, _080178DC @ =gBankAttacker - ldrb r1, [r0] - movs r0, 0x58 - muls r1, r0 - adds r0, r2, 0 - adds r0, 0x4C - adds r0, r1, r0 - ldr r4, [r0] - movs r0, 0x7 - ands r4, r0 - cmp r4, 0 - beq _080178F0 - ldr r0, _080178E0 @ =gCurrentMove - ldrh r0, [r0] - cmp r0, 0xAD - bne _080178B8 - b _08017D90 -_080178B8: - cmp r0, 0xD6 - bne _080178BE - b _08017D90 -_080178BE: - ldr r1, _080178E4 @ =gBattlescriptCurrInstr - ldr r0, _080178E8 @ =gUnknown_081D94EE - str r0, [r1] - ldr r2, _080178EC @ =gHitMarker - ldr r0, [r2] - movs r1, 0x80 - lsls r1, 12 - orrs r0, r1 - str r0, [r2] - movs r0, 0x2 - mov r9, r0 - b _08017D90 - .align 2, 0 -_080178D8: .4byte gBattleMons -_080178DC: .4byte gBankAttacker -_080178E0: .4byte gCurrentMove -_080178E4: .4byte gBattlescriptCurrInstr -_080178E8: .4byte gUnknown_081D94EE -_080178EC: .4byte gHitMarker -_080178F0: - adds r2, 0x50 - adds r2, r1, r2 - ldr r0, [r2] - ldr r1, _08017910 @ =0xf7ffffff - ands r0, r1 - str r0, [r2] - bl b_movescr_stack_push_cursor - ldr r0, _08017914 @ =gBattleCommunication - strb r4, [r0, 0x5] - ldr r1, _08017918 @ =gBattlescriptCurrInstr - ldr r0, _0801791C @ =gUnknown_081D94FB - str r0, [r1] - movs r1, 0x2 - b _08017D8E - .align 2, 0 -_08017910: .4byte 0xf7ffffff -_08017914: .4byte gBattleCommunication -_08017918: .4byte gBattlescriptCurrInstr -_0801791C: .4byte gUnknown_081D94FB -_08017920: - ldr r1, _0801797C @ =gBattleMons - ldr r7, _08017980 @ =gBankAttacker - ldrb r0, [r7] - movs r6, 0x58 - muls r0, r6 - adds r5, r1, 0 - adds r5, 0x4C - adds r0, r5 - ldr r0, [r0] - movs r1, 0x20 - ands r0, r1 - cmp r0, 0 - bne _0801793C - b _08017F94 -_0801793C: - bl Random - lsls r0, 16 - lsrs r0, 16 - movs r1, 0x5 - bl __umodsi3 - lsls r0, 16 - lsrs r4, r0, 16 - cmp r4, 0 - beq _080179A8 - ldr r2, _08017984 @ =gBattleMoves - ldr r0, _08017988 @ =gCurrentMove - ldrh r1, [r0] - lsls r0, r1, 1 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - ldrb r0, [r0] - cmp r0, 0x7D - beq _08017998 - ldr r1, _0801798C @ =gBattlescriptCurrInstr - ldr r0, _08017990 @ =gUnknown_081D9545 - str r0, [r1] - ldr r2, _08017994 @ =gHitMarker - ldr r0, [r2] - movs r1, 0x80 - lsls r1, 2 - orrs r0, r1 - str r0, [r2] - b _080179C8 - .align 2, 0 -_0801797C: .4byte gBattleMons -_08017980: .4byte gBankAttacker -_08017984: .4byte gBattleMoves -_08017988: .4byte gCurrentMove -_0801798C: .4byte gBattlescriptCurrInstr -_08017990: .4byte gUnknown_081D9545 -_08017994: .4byte gHitMarker -_08017998: - ldr r2, _080179A0 @ =0x02000000 - ldr r7, _080179A4 @ =0x000160e7 - adds r1, r2, r7 - b _08017D96 - .align 2, 0 -_080179A0: .4byte 0x02000000 -_080179A4: .4byte 0x000160e7 -_080179A8: - ldrb r0, [r7] - adds r2, r0, 0 - muls r2, r6 - adds r2, r5 - ldr r0, [r2] - movs r1, 0x21 - negs r1, r1 - ands r0, r1 - str r0, [r2] - bl b_movescr_stack_push_cursor - ldr r1, _080179CC @ =gBattlescriptCurrInstr - ldr r0, _080179D0 @ =gUnknown_081D9552 - str r0, [r1] - ldr r0, _080179D4 @ =gBattleCommunication - strb r4, [r0, 0x5] -_080179C8: - movs r0, 0x2 - b _08017E3C - .align 2, 0 -_080179CC: .4byte gBattlescriptCurrInstr -_080179D0: .4byte gUnknown_081D9552 -_080179D4: .4byte gBattleCommunication -_080179D8: - ldr r1, _08017A30 @ =gBattleMons - ldr r0, _08017A34 @ =gBankAttacker - ldrb r2, [r0] - movs r0, 0x58 - muls r0, r2 - adds r0, r1 - adds r0, 0x20 - ldrb r0, [r0] - cmp r0, 0x36 - beq _080179EE - b _08017D90 -_080179EE: - ldr r0, _08017A38 @ =gDisableStructs - lsls r1, r2, 3 - subs r1, r2 - lsls r1, 2 - adds r1, r0 - ldrb r0, [r1, 0x18] - lsls r0, 31 - cmp r0, 0 - bne _08017A02 - b _08017D90 -_08017A02: - adds r0, r2, 0 - bl CancelMultiTurnMoves - ldr r2, _08017A3C @ =gHitMarker - ldr r0, [r2] - movs r1, 0x80 - lsls r1, 12 - orrs r0, r1 - str r0, [r2] - ldr r1, _08017A40 @ =gBattleCommunication - movs r0, 0 - strb r0, [r1, 0x5] - ldr r1, _08017A44 @ =gBattlescriptCurrInstr - ldr r0, _08017A48 @ =gUnknown_081D9977 - str r0, [r1] - ldr r2, _08017A4C @ =gBattleMoveFlags - ldrb r0, [r2] - movs r1, 0x1 - orrs r0, r1 - strb r0, [r2] - movs r2, 0x1 - mov r9, r2 - b _08017D90 - .align 2, 0 -_08017A30: .4byte gBattleMons -_08017A34: .4byte gBankAttacker -_08017A38: .4byte gDisableStructs -_08017A3C: .4byte gHitMarker -_08017A40: .4byte gBattleCommunication -_08017A44: .4byte gBattlescriptCurrInstr -_08017A48: .4byte gUnknown_081D9977 -_08017A4C: .4byte gBattleMoveFlags -_08017A50: - ldr r1, _08017AA4 @ =gBattleMons - ldr r3, _08017AA8 @ =gBankAttacker - ldrb r2, [r3] - movs r0, 0x58 - muls r0, r2 - adds r1, 0x50 - adds r2, r0, r1 - ldr r1, [r2] - movs r0, 0x80 - lsls r0, 15 - ands r0, r1 - cmp r0, 0 - beq _08017A9C - ldr r0, _08017AAC @ =0xffbfffff - ands r1, r0 - str r1, [r2] - ldr r2, _08017AB0 @ =gDisableStructs - ldrb r1, [r3] - lsls r0, r1, 3 - subs r0, r1 - lsls r0, 2 - adds r0, r2 - movs r1, 0 - strb r1, [r0, 0x19] - ldrb r0, [r3] - bl CancelMultiTurnMoves - ldr r1, _08017AB4 @ =gBattlescriptCurrInstr - ldr r0, _08017AB8 @ =gUnknown_081D7956 - str r0, [r1] - ldr r2, _08017ABC @ =gHitMarker - ldr r0, [r2] - movs r1, 0x80 - lsls r1, 12 - orrs r0, r1 - str r0, [r2] - movs r7, 0x1 - mov r9, r7 -_08017A9C: - ldr r2, _08017AC0 @ =0x02000000 - ldr r0, _08017AC4 @ =0x000160e7 - adds r1, r2, r0 - b _08017D96 - .align 2, 0 -_08017AA4: .4byte gBattleMons -_08017AA8: .4byte gBankAttacker -_08017AAC: .4byte 0xffbfffff -_08017AB0: .4byte gDisableStructs -_08017AB4: .4byte gBattlescriptCurrInstr -_08017AB8: .4byte gUnknown_081D7956 -_08017ABC: .4byte gHitMarker -_08017AC0: .4byte 0x02000000 -_08017AC4: .4byte 0x000160e7 -_08017AC8: - ldr r1, _08017B08 @ =gBattleMons - ldr r3, _08017B0C @ =gBankAttacker - ldrb r2, [r3] - movs r0, 0x58 - muls r0, r2 - adds r1, 0x50 - adds r2, r0, r1 - ldr r1, [r2] - movs r0, 0x8 - ands r0, r1 - cmp r0, 0 - bne _08017AE2 - b _08017D90 -_08017AE2: - movs r0, 0x9 - negs r0, r0 - ands r1, r0 - str r1, [r2] - ldr r0, _08017B10 @ =gProtectStructs - ldrb r2, [r3] - lsls r2, 4 - adds r2, r0 - ldrb r0, [r2, 0x2] - movs r1, 0x4 - orrs r0, r1 - strb r0, [r2, 0x2] - ldrb r0, [r3] - bl CancelMultiTurnMoves - ldr r1, _08017B14 @ =gBattlescriptCurrInstr - ldr r0, _08017B18 @ =gUnknown_081D9573 - b _08017D7E - .align 2, 0 -_08017B08: .4byte gBattleMons -_08017B0C: .4byte gBankAttacker -_08017B10: .4byte gProtectStructs -_08017B14: .4byte gBattlescriptCurrInstr -_08017B18: .4byte gUnknown_081D9573 -_08017B1C: - ldr r0, _08017B74 @ =gDisableStructs - ldr r3, _08017B78 @ =gBankAttacker - ldrb r2, [r3] - lsls r1, r2, 3 - subs r1, r2 - lsls r1, 2 - adds r1, r0 - ldr r0, _08017B7C @ =gCurrentMove - ldrh r1, [r1, 0x4] - ldrh r0, [r0] - cmp r1, r0 - beq _08017B36 - b _08017D90 -_08017B36: - cmp r1, 0 - bne _08017B3C - b _08017D90 -_08017B3C: - ldr r0, _08017B80 @ =gProtectStructs - lsls r2, 4 - adds r2, r0 - ldrb r0, [r2, 0x1] - movs r1, 0x80 - orrs r0, r1 - strb r0, [r2, 0x1] - ldr r0, _08017B84 @ =0x02000000 - ldrb r1, [r3] - ldr r7, _08017B88 @ =0x00016003 - adds r0, r7 - strb r1, [r0] - ldrb r0, [r3] - bl CancelMultiTurnMoves - ldr r1, _08017B8C @ =gBattlescriptCurrInstr - ldr r0, _08017B90 @ =gUnknown_081D9139 - str r0, [r1] - ldr r2, _08017B94 @ =gHitMarker - ldr r0, [r2] - movs r1, 0x80 - lsls r1, 12 - orrs r0, r1 - str r0, [r2] - movs r0, 0x1 - mov r9, r0 - b _08017D90 - .align 2, 0 -_08017B74: .4byte gDisableStructs -_08017B78: .4byte gBankAttacker -_08017B7C: .4byte gCurrentMove -_08017B80: .4byte gProtectStructs -_08017B84: .4byte 0x02000000 -_08017B88: .4byte 0x00016003 -_08017B8C: .4byte gBattlescriptCurrInstr -_08017B90: .4byte gUnknown_081D9139 -_08017B94: .4byte gHitMarker -_08017B98: - ldr r0, _08017BF4 @ =gDisableStructs - ldr r4, _08017BF8 @ =gBankAttacker - ldrb r3, [r4] - lsls r1, r3, 3 - subs r1, r3 - lsls r1, 2 - adds r1, r0 - ldrb r0, [r1, 0x13] - lsls r0, 28 - cmp r0, 0 - beq _08017BEC - ldr r2, _08017BFC @ =gBattleMoves - ldr r0, _08017C00 @ =gCurrentMove - ldrh r1, [r0] - lsls r0, r1, 1 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - ldrb r0, [r0, 0x1] - cmp r0, 0 - bne _08017BEC - ldr r0, _08017C04 @ =gProtectStructs - lsls r2, r3, 4 - adds r2, r0 - ldrb r0, [r2, 0x2] - movs r1, 0x1 - orrs r0, r1 - strb r0, [r2, 0x2] - ldrb r0, [r4] - bl CancelMultiTurnMoves - ldr r1, _08017C08 @ =gBattlescriptCurrInstr - ldr r0, _08017C0C @ =gUnknown_081D938F - str r0, [r1] - ldr r2, _08017C10 @ =gHitMarker - ldr r0, [r2] - movs r1, 0x80 - lsls r1, 12 - orrs r0, r1 - str r0, [r2] - movs r7, 0x1 - mov r9, r7 -_08017BEC: - ldr r2, _08017C14 @ =0x02000000 - ldr r0, _08017C18 @ =0x000160e7 - adds r1, r2, r0 - b _08017D96 - .align 2, 0 -_08017BF4: .4byte gDisableStructs -_08017BF8: .4byte gBankAttacker -_08017BFC: .4byte gBattleMoves -_08017C00: .4byte gCurrentMove -_08017C04: .4byte gProtectStructs -_08017C08: .4byte gBattlescriptCurrInstr -_08017C0C: .4byte gUnknown_081D938F -_08017C10: .4byte gHitMarker -_08017C14: .4byte 0x02000000 -_08017C18: .4byte 0x000160e7 -_08017C1C: - ldr r4, _08017C4C @ =gBankAttacker - ldrb r0, [r4] - ldr r1, _08017C50 @ =gCurrentMove - ldrh r1, [r1] - bl IsImprisoned - lsls r0, 24 - cmp r0, 0 - bne _08017C30 - b _08017D90 -_08017C30: - ldr r0, _08017C54 @ =gProtectStructs - ldrb r2, [r4] - lsls r2, 4 - adds r2, r0 - ldrb r0, [r2, 0x1] - movs r1, 0x20 - orrs r0, r1 - strb r0, [r2, 0x1] - ldrb r0, [r4] - bl CancelMultiTurnMoves - ldr r1, _08017C58 @ =gBattlescriptCurrInstr - ldr r0, _08017C5C @ =gUnknown_081D9459 - b _08017D7E - .align 2, 0 -_08017C4C: .4byte gBankAttacker -_08017C50: .4byte gCurrentMove -_08017C54: .4byte gProtectStructs -_08017C58: .4byte gBattlescriptCurrInstr -_08017C5C: .4byte gUnknown_081D9459 -_08017C60: - ldr r7, _08017CAC @ =gBattleMons - ldr r5, _08017CB0 @ =gBankAttacker - ldrb r0, [r5] - movs r6, 0x58 - muls r0, r6 - adds r4, r7, 0 - adds r4, 0x50 - adds r2, r0, r4 - ldr r1, [r2] - movs r3, 0x7 - adds r0, r1, 0 - ands r0, r3 - cmp r0, 0 - bne _08017C7E - b _08017F94 -_08017C7E: - subs r0, r1, 0x1 - str r0, [r2] - ldrb r0, [r5] - muls r0, r6 - adds r0, r4 - ldr r0, [r0] - ands r0, r3 - cmp r0, 0 - beq _08017D24 - bl Random - movs r1, 0x1 - movs r2, 0x1 - ands r2, r0 - cmp r2, 0 - beq _08017CB8 - ldr r1, _08017CB4 @ =gBattleCommunication - movs r0, 0 - strb r0, [r1, 0x5] - bl b_movescr_stack_push_cursor - b _08017D02 - .align 2, 0 -_08017CAC: .4byte gBattleMons -_08017CB0: .4byte gBankAttacker -_08017CB4: .4byte gBattleCommunication -_08017CB8: - ldr r0, _08017D08 @ =gBattleCommunication - movs r4, 0x1 - strb r1, [r0, 0x5] - ldr r1, _08017D0C @ =gBankTarget - ldrb r0, [r5] - strb r0, [r1] - ldrb r0, [r5] - adds r1, r0, 0 - muls r1, r6 - adds r1, r7 - movs r0, 0x28 - str r0, [sp] - str r2, [sp, 0x4] - ldrb r0, [r5] - str r0, [sp, 0x8] - ldrb r0, [r5] - str r0, [sp, 0xC] - adds r0, r1, 0 - movs r2, 0x1 - movs r3, 0 - bl CalculateBaseDamage - ldr r1, _08017D10 @ =gBattleMoveDamage - str r0, [r1] - ldr r0, _08017D14 @ =gProtectStructs - ldrb r1, [r5] - lsls r1, 4 - adds r1, r0 - ldrb r0, [r1, 0x1] - orrs r0, r4 - strb r0, [r1, 0x1] - ldr r2, _08017D18 @ =gHitMarker - ldr r0, [r2] - movs r1, 0x80 - lsls r1, 12 - orrs r0, r1 - str r0, [r2] -_08017D02: - ldr r1, _08017D1C @ =gBattlescriptCurrInstr - ldr r0, _08017D20 @ =gUnknown_081D9595 - b _08017D2C - .align 2, 0 -_08017D08: .4byte gBattleCommunication -_08017D0C: .4byte gBankTarget -_08017D10: .4byte gBattleMoveDamage -_08017D14: .4byte gProtectStructs -_08017D18: .4byte gHitMarker -_08017D1C: .4byte gBattlescriptCurrInstr -_08017D20: .4byte gUnknown_081D9595 -_08017D24: - bl b_movescr_stack_push_cursor - ldr r1, _08017D34 @ =gBattlescriptCurrInstr - ldr r0, _08017D38 @ =gUnknown_081D95D4 -_08017D2C: - str r0, [r1] - movs r7, 0x1 - b _08017F8E - .align 2, 0 -_08017D34: .4byte gBattlescriptCurrInstr -_08017D38: .4byte gUnknown_081D95D4 -_08017D3C: - ldr r1, _08017DA0 @ =gBattleMons - ldr r4, _08017DA4 @ =gBankAttacker - ldrb r2, [r4] - movs r0, 0x58 - muls r0, r2 - adds r1, 0x4C - adds r0, r1 - ldr r0, [r0] - movs r1, 0x40 - ands r0, r1 - cmp r0, 0 - beq _08017D90 - bl Random - lsls r0, 16 - movs r1, 0xC0 - lsls r1, 10 - ands r1, r0 - cmp r1, 0 - bne _08017D90 - ldr r0, _08017DA8 @ =gProtectStructs - ldrb r2, [r4] - lsls r2, 4 - adds r2, r0 - ldrb r0, [r2] - movs r1, 0x80 - orrs r0, r1 - strb r0, [r2] - ldrb r0, [r4] - bl CancelMultiTurnMoves - ldr r1, _08017DAC @ =gBattlescriptCurrInstr - ldr r0, _08017DB0 @ =gUnknown_081D9566 -_08017D7E: - str r0, [r1] - ldr r2, _08017DB4 @ =gHitMarker - ldr r0, [r2] - movs r1, 0x80 - lsls r1, 12 - orrs r0, r1 - str r0, [r2] - movs r1, 0x1 -_08017D8E: - mov r9, r1 -_08017D90: - ldr r2, _08017DB8 @ =0x02000000 - ldr r4, _08017DBC @ =0x000160e7 - adds r1, r2, r4 -_08017D96: - ldrb r0, [r1] - adds r0, 0x1 - strb r0, [r1] - mov r8, r2 - b _08017F9E - .align 2, 0 -_08017DA0: .4byte gBattleMons -_08017DA4: .4byte gBankAttacker -_08017DA8: .4byte gProtectStructs -_08017DAC: .4byte gBattlescriptCurrInstr -_08017DB0: .4byte gUnknown_081D9566 -_08017DB4: .4byte gHitMarker -_08017DB8: .4byte 0x02000000 -_08017DBC: .4byte 0x000160e7 -_08017DC0: - ldr r1, _08017DFC @ =gBattleMons - ldr r4, _08017E00 @ =gBankAttacker - ldrb r2, [r4] - movs r0, 0x58 - muls r0, r2 - adds r1, 0x50 - adds r0, r1 - ldr r1, [r0] - movs r0, 0xF0 - lsls r0, 12 - ands r1, r0 - cmp r1, 0 - bne _08017DDC - b _08017F94 -_08017DDC: - lsrs r0, r1, 16 - bl CountTrailingZeroBits - ldr r1, _08017E04 @ =0x02000000 - ldr r7, _08017E08 @ =0x00016003 - adds r1, r7 - strb r0, [r1] - bl Random - movs r1, 0x1 - ands r1, r0 - cmp r1, 0 - beq _08017E0C - bl b_movescr_stack_push_cursor - b _08017E34 - .align 2, 0 -_08017DFC: .4byte gBattleMons -_08017E00: .4byte gBankAttacker -_08017E04: .4byte 0x02000000 -_08017E08: .4byte 0x00016003 -_08017E0C: - ldr r0, _08017E44 @ =gUnknown_081D9608 - bl b_movescr_stack_push - ldr r2, _08017E48 @ =gHitMarker - ldr r0, [r2] - movs r1, 0x80 - lsls r1, 12 - orrs r0, r1 - str r0, [r2] - ldr r0, _08017E4C @ =gProtectStructs - ldrb r2, [r4] - lsls r2, 4 - adds r2, r0 - ldrb r0, [r2, 0x1] - movs r1, 0x40 - orrs r0, r1 - strb r0, [r2, 0x1] - ldrb r0, [r4] - bl CancelMultiTurnMoves -_08017E34: - ldr r1, _08017E50 @ =gBattlescriptCurrInstr - ldr r0, _08017E54 @ =gUnknown_081D95FB - str r0, [r1] - movs r0, 0x1 -_08017E3C: - mov r9, r0 - ldr r1, _08017E58 @ =0x02000000 - mov r8, r1 - b _08017F94 - .align 2, 0 -_08017E44: .4byte gUnknown_081D9608 -_08017E48: .4byte gHitMarker -_08017E4C: .4byte gProtectStructs -_08017E50: .4byte gBattlescriptCurrInstr -_08017E54: .4byte gUnknown_081D95FB -_08017E58: .4byte 0x02000000 -_08017E5C: - ldr r1, _08017E98 @ =gBattleMons - ldr r6, _08017E9C @ =gBankAttacker - ldrb r0, [r6] - movs r5, 0x58 - muls r0, r5 - adds r1, 0x50 - adds r3, r0, r1 - ldr r2, [r3] - movs r4, 0xC0 - lsls r4, 2 - adds r0, r2, 0 - ands r0, r4 - cmp r0, 0 - bne _08017E7A - b _08017F94 -_08017E7A: - ldr r7, _08017EA0 @ =0xffffff00 - adds r0, r2, r7 - str r0, [r3] - ldrb r0, [r6] - muls r0, r5 - adds r1, r0, r1 - ldr r2, [r1] - adds r0, r2, 0 - ands r0, r4 - cmp r0, 0 - beq _08017EAC - ldr r1, _08017EA4 @ =gBattlescriptCurrInstr - ldr r0, _08017EA8 @ =gUnknown_081D90A7 - b _08017F38 - .align 2, 0 -_08017E98: .4byte gBattleMons -_08017E9C: .4byte gBankAttacker -_08017EA0: .4byte 0xffffff00 -_08017EA4: .4byte gBattlescriptCurrInstr -_08017EA8: .4byte gUnknown_081D90A7 -_08017EAC: - ldr r0, _08017F0C @ =0xffffefff - ands r2, r0 - str r2, [r1] - ldr r2, _08017F10 @ =gTakenDmg - ldrb r0, [r6] - lsls r0, 2 - adds r0, r2 - ldr r0, [r0] - cmp r0, 0 - beq _08017F34 - ldr r1, _08017F14 @ =gCurrentMove - movs r0, 0x75 - strh r0, [r1] - ldrb r0, [r6] - lsls r0, 2 - adds r0, r2 - ldr r0, [r0] - lsls r0, 1 - mov r1, r10 - str r0, [r1] - ldr r4, _08017F18 @ =gBankTarget - ldr r1, _08017F1C @ =gTakenDmgBanks - ldrb r0, [r6] - adds r0, r1 - ldrb r0, [r0] - strb r0, [r4] - ldr r0, _08017F20 @ =gAbsentBankFlags - ldrb r1, [r0] - ldr r2, _08017F24 @ =gBitTable - ldrb r0, [r4] - lsls r0, 2 - adds r0, r2 - ldr r0, [r0] - ands r1, r0 - cmp r1, 0 - beq _08017EFE - movs r0, 0x75 - movs r1, 0x1 - bl sub_801B5C0 - strb r0, [r4] -_08017EFE: - ldr r1, _08017F28 @ =gBattlescriptCurrInstr - ldr r0, _08017F2C @ =gUnknown_081D90B2 - str r0, [r1] - ldr r2, _08017F30 @ =0x02000000 - mov r8, r2 - b _08017F3A - .align 2, 0 -_08017F0C: .4byte 0xffffefff -_08017F10: .4byte gTakenDmg -_08017F14: .4byte gCurrentMove -_08017F18: .4byte gBankTarget -_08017F1C: .4byte gTakenDmgBanks -_08017F20: .4byte gAbsentBankFlags -_08017F24: .4byte gBitTable -_08017F28: .4byte gBattlescriptCurrInstr -_08017F2C: .4byte gUnknown_081D90B2 -_08017F30: .4byte 0x02000000 -_08017F34: - ldr r1, _08017F40 @ =gBattlescriptCurrInstr - ldr r0, _08017F44 @ =gUnknown_081D90F1 -_08017F38: - str r0, [r1] -_08017F3A: - movs r4, 0x1 - mov r9, r4 - b _08017F94 - .align 2, 0 -_08017F40: .4byte gBattlescriptCurrInstr -_08017F44: .4byte gUnknown_081D90F1 -_08017F48: - ldr r1, _08017FEC @ =gBattleMons - ldr r0, _08017FF0 @ =gBankAttacker - ldrb r2, [r0] - movs r0, 0x58 - muls r0, r2 - adds r1, 0x4C - adds r4, r0, r1 - ldr r3, [r4] - movs r0, 0x20 - ands r0, r3 - cmp r0, 0 - beq _08017F94 - ldr r2, _08017FF4 @ =gBattleMoves - ldr r0, _08017FF8 @ =gCurrentMove - ldrh r1, [r0] - lsls r0, r1, 1 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - ldrb r0, [r0] - cmp r0, 0x7D - bne _08017F8C - movs r0, 0x21 - negs r0, r0 - ands r3, r0 - str r3, [r4] - bl b_movescr_stack_push_cursor - ldr r1, _08017FFC @ =gBattlescriptCurrInstr - ldr r0, _08018000 @ =gUnknown_081D9552 - str r0, [r1] - ldr r1, _08018004 @ =gBattleCommunication - movs r0, 0x1 - strb r0, [r1, 0x5] -_08017F8C: - movs r7, 0x2 -_08017F8E: - mov r9, r7 - ldr r0, _08018008 @ =0x02000000 - mov r8, r0 -_08017F94: - ldr r1, _0801800C @ =0x000160e7 - add r1, r8 - ldrb r0, [r1] - adds r0, 0x1 - strb r0, [r1] -_08017F9E: - ldr r0, _0801800C @ =0x000160e7 - add r0, r8 - ldrb r0, [r0] - cmp r0, 0xE - beq _08017FAC - bl _0801773C -_08017FAC: - mov r1, r9 - cmp r1, 0x2 - bne _08017FD8 - ldr r4, _08018010 @ =gActiveBank - ldr r0, _08017FF0 @ =gBankAttacker - ldrb r0, [r0] - strb r0, [r4] - ldrb r1, [r4] - movs r0, 0x58 - muls r0, r1 - ldr r1, _08018014 @ =gUnknown_02024ACC - adds r0, r1 - str r0, [sp] - movs r0, 0 - movs r1, 0x28 - movs r2, 0 - movs r3, 0x4 - bl EmitSetAttributes - ldrb r0, [r4] - bl MarkBufferBankForExecution -_08017FD8: - mov r0, r9 - add sp, 0x10 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r1} - bx r1 - .align 2, 0 -_08017FEC: .4byte gBattleMons -_08017FF0: .4byte gBankAttacker -_08017FF4: .4byte gBattleMoves -_08017FF8: .4byte gCurrentMove -_08017FFC: .4byte gBattlescriptCurrInstr -_08018000: .4byte gUnknown_081D9552 -_08018004: .4byte gBattleCommunication -_08018008: .4byte 0x02000000 -_0801800C: .4byte 0x000160e7 -_08018010: .4byte gActiveBank -_08018014: .4byte gUnknown_02024ACC - thumb_func_end AtkCanceller_UnableToUseMove - - thumb_func_start sub_8018018 -sub_8018018: @ 8018018 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - lsls r0, 24 - lsrs r4, r0, 24 - adds r3, r4, 0 - lsls r1, 24 - lsrs r1, 24 - mov r10, r1 - lsls r2, 24 - lsrs r2, 24 - mov r9, r2 - ldr r0, _08018044 @ =gBattleTypeFlags - ldrh r1, [r0] - movs r0, 0x1 - ands r0, r1 - cmp r0, 0 - bne _08018048 - movs r0, 0 - b _08018198 - .align 2, 0 -_08018044: .4byte gBattleTypeFlags -_08018048: - movs r0, 0x40 - ands r0, r1 - cmp r0, 0 - beq _080180D4 - adds r0, r4, 0 - bl sub_803FC34 - lsls r0, 24 - lsrs r7, r0, 24 - adds r0, r4, 0 - bl GetBankSide - lsls r0, 24 - ldr r1, _080180CC @ =gEnemyParty - mov r8, r1 - cmp r0, 0 - bne _0801806E - ldr r2, _080180D0 @ =gPlayerParty - mov r8, r2 -_0801806E: - adds r0, r7, 0 - bl sub_803FBFC - lsls r0, 24 - lsrs r6, r0, 24 - lsls r0, r6, 1 - adds r5, r0, r6 - adds r0, r5, 0x3 - cmp r5, r0 - bge _080180BA - adds r7, r0, 0 -_08018084: - movs r0, 0x64 - muls r0, r5 - mov r1, r8 - adds r4, r1, r0 - adds r0, r4, 0 - movs r1, 0x39 - bl GetMonData - cmp r0, 0 - beq _080180B4 - adds r0, r4, 0 - movs r1, 0x41 - bl GetMonData - cmp r0, 0 - beq _080180B4 - adds r0, r4, 0 - movs r1, 0x41 - bl GetMonData - movs r1, 0xCE - lsls r1, 1 - cmp r0, r1 - bne _080180BA -_080180B4: - adds r5, 0x1 - cmp r5, r7 - blt _08018084 -_080180BA: - movs r1, 0 - lsls r0, r6, 1 - adds r0, r6 - adds r0, 0x3 - cmp r5, r0 - bne _080180C8 - movs r1, 0x1 -_080180C8: - adds r0, r1, 0 - b _08018198 - .align 2, 0 -_080180CC: .4byte gEnemyParty -_080180D0: .4byte gPlayerParty -_080180D4: - adds r0, r3, 0 - bl GetBankSide - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _08018100 - movs r0, 0x1 - bl GetBankByPlayerAI - lsls r0, 24 - lsrs r7, r0, 24 - movs r0, 0x3 - bl GetBankByPlayerAI - lsls r0, 24 - lsrs r6, r0, 24 - ldr r2, _080180FC @ =gEnemyParty - mov r8, r2 - b _08018118 - .align 2, 0 -_080180FC: .4byte gEnemyParty -_08018100: - movs r0, 0 - bl GetBankByPlayerAI - lsls r0, 24 - lsrs r7, r0, 24 - movs r0, 0x2 - bl GetBankByPlayerAI - lsls r0, 24 - lsrs r6, r0, 24 - ldr r0, _080181A8 @ =gPlayerParty - mov r8, r0 -_08018118: - mov r1, r10 - cmp r1, 0x6 - bne _08018128 - ldr r1, _080181AC @ =gBattlePartyID - lsls r0, r7, 1 - adds r0, r1 - ldrb r0, [r0] - mov r10, r0 -_08018128: - mov r2, r9 - cmp r2, 0x6 - bne _08018138 - ldr r1, _080181AC @ =gBattlePartyID - lsls r0, r6, 1 - adds r0, r1 - ldrb r0, [r0] - mov r9, r0 -_08018138: - movs r5, 0 -_0801813A: - movs r0, 0x64 - muls r0, r5 - mov r1, r8 - adds r4, r1, r0 - adds r0, r4, 0 - movs r1, 0x39 - bl GetMonData - cmp r0, 0 - beq _0801818A - adds r0, r4, 0 - movs r1, 0x41 - bl GetMonData - cmp r0, 0 - beq _0801818A - adds r0, r4, 0 - movs r1, 0x41 - bl GetMonData - movs r1, 0xCE - lsls r1, 1 - cmp r0, r1 - beq _0801818A - cmp r5, r10 - beq _0801818A - cmp r5, r9 - beq _0801818A - ldr r1, _080181B0 @ =0x02000000 - ldr r2, _080181B4 @ =0x00016068 - adds r0, r7, r2 - adds r0, r1 - ldrb r0, [r0] - cmp r5, r0 - beq _0801818A - adds r0, r6, r2 - adds r0, r1 - ldrb r0, [r0] - cmp r5, r0 - bne _08018190 -_0801818A: - adds r5, 0x1 - cmp r5, 0x5 - ble _0801813A -_08018190: - movs r0, 0 - cmp r5, 0x6 - bne _08018198 - movs r0, 0x1 -_08018198: - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r1} - bx r1 - .align 2, 0 -_080181A8: .4byte gPlayerParty -_080181AC: .4byte gBattlePartyID -_080181B0: .4byte 0x02000000 -_080181B4: .4byte 0x00016068 - thumb_func_end sub_8018018 - - thumb_func_start castform_switch -castform_switch: @ 80181B8 - push {r4-r6,lr} - sub sp, 0x4 - lsls r0, 24 - lsrs r6, r0, 24 - movs r5, 0 - ldr r1, _08018228 @ =gBattleMons - movs r0, 0x58 - muls r0, r6 - adds r4, r0, r1 - ldrh r1, [r4] - ldr r0, _0801822C @ =SPECIES_CASTFORM - cmp r1, r0 - bne _0801825C - adds r0, r4, 0 - adds r0, 0x20 - ldrb r0, [r0] - cmp r0, 0x3B - bne _0801825C - ldrh r0, [r4, 0x28] - cmp r0, 0 - beq _0801825C - str r5, [sp] - movs r0, 0x13 - movs r1, 0 - movs r2, 0xD - movs r3, 0 - bl AbilityBattleEffects - lsls r0, 24 - cmp r0, 0 - bne _0801820A - str r5, [sp] - movs r0, 0x13 - movs r1, 0 - movs r2, 0x4D - movs r3, 0 - bl AbilityBattleEffects - lsls r0, 24 - cmp r0, 0 - beq _08018230 -_0801820A: - adds r2, r4, 0 - adds r2, 0x21 - ldrb r0, [r2] - cmp r0, 0 - beq _08018230 - adds r1, r4, 0 - adds r1, 0x22 - ldrb r0, [r1] - cmp r0, 0 - beq _08018230 - strb r5, [r2] - strb r5, [r1] - movs r0, 0x1 - b _08018314 - .align 2, 0 -_08018228: .4byte gBattleMons -_0801822C: .4byte SPECIES_CASTFORM -_08018230: - movs r0, 0 - str r0, [sp] - movs r0, 0x13 - movs r1, 0 - movs r2, 0xD - movs r3, 0 - bl AbilityBattleEffects - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0 - bne _0801825C - str r0, [sp] - movs r0, 0x13 - movs r1, 0 - movs r2, 0x4D - movs r3, 0 - bl AbilityBattleEffects - lsls r0, 24 - cmp r0, 0 - beq _08018260 -_0801825C: - movs r0, 0 - b _08018314 -_08018260: - ldr r1, _0801831C @ =gBattleWeather - ldrh r0, [r1] - movs r2, 0xE7 - ands r2, r0 - adds r4, r1, 0 - cmp r2, 0 - bne _0801828E - ldr r1, _08018320 @ =gBattleMons - movs r0, 0x58 - muls r0, r6 - adds r1, r0, r1 - adds r3, r1, 0 - adds r3, 0x21 - ldrb r0, [r3] - cmp r0, 0 - beq _0801828E - adds r1, 0x22 - ldrb r0, [r1] - cmp r0, 0 - beq _0801828E - strb r2, [r3] - strb r2, [r1] - movs r5, 0x1 -_0801828E: - ldrh r1, [r4] - movs r0, 0x60 - ands r0, r1 - cmp r0, 0 - beq _080182BA - ldr r1, _08018320 @ =gBattleMons - movs r0, 0x58 - muls r0, r6 - adds r1, r0, r1 - adds r2, r1, 0 - adds r2, 0x21 - ldrb r0, [r2] - cmp r0, 0xA - beq _080182BA - adds r1, 0x22 - ldrb r0, [r1] - cmp r0, 0xA - beq _080182BA - movs r0, 0xA - strb r0, [r2] - strb r0, [r1] - movs r5, 0x2 -_080182BA: - ldrh r1, [r4] - movs r0, 0x7 - ands r0, r1 - cmp r0, 0 - beq _080182E6 - ldr r1, _08018320 @ =gBattleMons - movs r0, 0x58 - muls r0, r6 - adds r1, r0, r1 - adds r2, r1, 0 - adds r2, 0x21 - ldrb r0, [r2] - cmp r0, 0xB - beq _080182E6 - adds r1, 0x22 - ldrb r0, [r1] - cmp r0, 0xB - beq _080182E6 - movs r0, 0xB - strb r0, [r2] - strb r0, [r1] - movs r5, 0x3 -_080182E6: - ldrh r1, [r4] - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - beq _08018312 - ldr r1, _08018320 @ =gBattleMons - movs r0, 0x58 - muls r0, r6 - adds r1, r0, r1 - adds r2, r1, 0 - adds r2, 0x21 - ldrb r0, [r2] - cmp r0, 0xF - beq _08018312 - adds r1, 0x22 - ldrb r0, [r1] - cmp r0, 0xF - beq _08018312 - movs r0, 0xF - strb r0, [r2] - strb r0, [r1] - movs r5, 0x4 -_08018312: - adds r0, r5, 0 -_08018314: - add sp, 0x4 - pop {r4-r6} - pop {r1} - bx r1 - .align 2, 0 -_0801831C: .4byte gBattleWeather -_08018320: .4byte gBattleMons - thumb_func_end castform_switch - - thumb_func_start AbilityBattleEffects -AbilityBattleEffects: @ 8018324 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x28 - ldr r4, [sp, 0x48] - lsls r0, 24 - lsrs r0, 24 - str r0, [sp, 0x4] - lsls r1, 24 - lsrs r1, 24 - mov r10, r1 - lsls r2, 24 - lsrs r6, r2, 24 - lsls r3, 24 - lsrs r3, 24 - mov r8, r3 - lsls r4, 16 - lsrs r4, 16 - movs r0, 0 - mov r9, r0 - ldr r5, _08018380 @ =gBankAttacker - ldr r1, _08018384 @ =gNoOfAllBanks - ldrb r0, [r5] - ldrb r1, [r1] - cmp r0, r1 - bcc _08018360 - mov r1, r10 - strb r1, [r5] -_08018360: - ldrb r0, [r5] - bl GetBankSide - lsls r0, 24 - cmp r0, 0 - bne _08018390 - ldr r1, _08018388 @ =gBattlePartyID - ldrb r0, [r5] - lsls r0, 1 - adds r0, r1 - ldrh r1, [r0] - movs r0, 0x64 - muls r1, r0 - ldr r0, _0801838C @ =gPlayerParty - b _080183A0 - .align 2, 0 -_08018380: .4byte gBankAttacker -_08018384: .4byte gNoOfAllBanks -_08018388: .4byte gBattlePartyID -_0801838C: .4byte gPlayerParty -_08018390: - ldr r1, _080183D0 @ =gBattlePartyID - ldrb r0, [r5] - lsls r0, 1 - adds r0, r1 - ldrh r1, [r0] - movs r0, 0x64 - muls r1, r0 - ldr r0, _080183D4 @ =gEnemyParty -_080183A0: - adds r7, r1, r0 - ldr r5, _080183D8 @ =gBankTarget - ldr r1, _080183DC @ =gNoOfAllBanks - ldrb r0, [r5] - ldrb r1, [r1] - cmp r0, r1 - bcc _080183B2 - mov r2, r10 - strb r2, [r5] -_080183B2: - ldrb r0, [r5] - bl GetBankSide - lsls r0, 24 - cmp r0, 0 - bne _080183E4 - ldr r1, _080183D0 @ =gBattlePartyID - ldrb r0, [r5] - lsls r0, 1 - adds r0, r1 - ldrh r1, [r0] - movs r0, 0x64 - muls r1, r0 - ldr r0, _080183E0 @ =gPlayerParty - b _080183F4 - .align 2, 0 -_080183D0: .4byte gBattlePartyID -_080183D4: .4byte gEnemyParty -_080183D8: .4byte gBankTarget -_080183DC: .4byte gNoOfAllBanks -_080183E0: .4byte gPlayerParty -_080183E4: - ldr r1, _08018444 @ =gBattlePartyID - ldrb r0, [r5] - lsls r0, 1 - adds r0, r1 - ldrh r1, [r0] - movs r0, 0x64 - muls r1, r0 - ldr r0, _08018448 @ =gEnemyParty -_080183F4: - adds r5, r1, r0 - adds r0, r7, 0 - movs r1, 0xB - bl GetMonData - lsls r0, 16 - lsrs r0, 16 - str r0, [sp, 0x8] - adds r0, r7, 0 - movs r1, 0 - bl GetMonData - str r0, [sp, 0x10] - adds r0, r5, 0 - movs r1, 0xB - bl GetMonData - lsls r0, 16 - lsrs r0, 16 - str r0, [sp, 0xC] - adds r0, r5, 0 - movs r1, 0 - bl GetMonData - str r0, [sp, 0x14] - ldr r0, _0801844C @ =gBattleTypeFlags - ldrh r1, [r0] - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - beq _08018436 - bl _08019F92 -_08018436: - mov r3, r8 - cmp r3, 0 - beq _08018454 - ldr r0, _08018450 @ =gLastUsedAbility - strb r3, [r0] - mov r8, r0 - b _0801846A - .align 2, 0 -_08018444: .4byte gBattlePartyID -_08018448: .4byte gEnemyParty -_0801844C: .4byte gBattleTypeFlags -_08018450: .4byte gLastUsedAbility -_08018454: - ldr r2, _08018474 @ =gLastUsedAbility - ldr r1, _08018478 @ =gBattleMons - movs r0, 0x58 - mov r5, r10 - muls r5, r0 - adds r0, r5, 0 - adds r0, r1 - adds r0, 0x20 - ldrb r0, [r0] - strb r0, [r2] - mov r8, r2 -_0801846A: - cmp r4, 0 - beq _0801847C - adds r3, r4, 0 - b _08018480 - .align 2, 0 -_08018474: .4byte gLastUsedAbility -_08018478: .4byte gBattleMons -_0801847C: - ldr r0, _08018494 @ =gCurrentMove - ldrh r3, [r0] -_08018480: - ldr r1, _08018498 @ =0x02000000 - ldr r2, _0801849C @ =0x0001601c - adds r0, r1, r2 - ldrb r0, [r0] - adds r7, r1, 0 - cmp r0, 0 - beq _080184A0 - movs r4, 0x3F - ands r4, r0 - b _080184AC - .align 2, 0 -_08018494: .4byte gCurrentMove -_08018498: .4byte 0x02000000 -_0801849C: .4byte 0x0001601c -_080184A0: - ldr r1, _080184C0 @ =gBattleMoves - lsls r0, r3, 1 - adds r0, r3 - lsls r0, 2 - adds r0, r1 - ldrb r4, [r0, 0x2] -_080184AC: - ldr r5, [sp, 0x4] - cmp r5, 0x13 - bls _080184B6 - bl _08019F76 -_080184B6: - lsls r0, r5, 2 - ldr r1, _080184C4 @ =_080184C8 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .align 2, 0 -_080184C0: .4byte gBattleMoves -_080184C4: .4byte _080184C8 - .align 2, 0 -_080184C8: - .4byte _08018518 - .4byte _08018814 - .4byte _08018A40 - .4byte _08018AD8 - .4byte _08018CF0 - .4byte _08019448 - .4byte _080197B4 - .4byte _08019804 - .4byte _08019880 - .4byte _080198FC - .4byte _08019B1C - .4byte _08019940 - .4byte _08019B60 - .4byte _08019BBC - .4byte _08019C18 - .4byte _08019D18 - .4byte _08019D5C - .4byte _08019DB8 - .4byte _08019F44 - .4byte _08019CD4 -_08018518: - ldr r2, _0801854C @ =gBankAttacker - ldr r0, _08018550 @ =gNoOfAllBanks - ldrb r1, [r2] - adds r5, r0, 0 - ldrb r0, [r5] - cmp r1, r0 - bcc _0801852A - mov r1, r10 - strb r1, [r2] -_0801852A: - mov r2, r8 - ldrb r0, [r2] - cmp r0, 0x2D - bne _08018534 - b _080186B8 -_08018534: - cmp r0, 0x2D - bgt _08018564 - cmp r0, 0xD - bne _0801853E - b _080187DC -_0801853E: - cmp r0, 0xD - bgt _08018554 - cmp r0, 0x2 - bne _08018548 - b _08018680 -_08018548: - bl _08019F76 - .align 2, 0 -_0801854C: .4byte gBankAttacker -_08018550: .4byte gNoOfAllBanks -_08018554: - cmp r0, 0x16 - bne _0801855A - b _08018728 -_0801855A: - cmp r0, 0x24 - bne _08018560 - b _080187A0 -_08018560: - bl _08019F76 -_08018564: - cmp r0, 0x46 - bne _0801856A - b _080186F0 -_0801856A: - cmp r0, 0x46 - bgt _08018578 - cmp r0, 0x3B - bne _08018574 - b _0801875C -_08018574: - bl _08019F76 -_08018578: - cmp r0, 0x4D - bne _0801857E - b _080187DC -_0801857E: - cmp r0, 0xFF - beq _08018586 - bl _08019F76 -_08018586: - bl weather_get_current - lsls r0, 24 - lsrs r0, 24 - subs r0, 0x3 - cmp r0, 0xA - bhi _0801864C - lsls r0, 2 - ldr r1, _080185A0 @ =_080185A4 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .align 2, 0 -_080185A0: .4byte _080185A4 - .align 2, 0 -_080185A4: - .4byte _080185D0 - .4byte _0801864C - .4byte _080185D0 - .4byte _0801864C - .4byte _0801864C - .4byte _080185F8 - .4byte _0801864C - .4byte _0801864C - .4byte _0801864C - .4byte _08018620 - .4byte _080185D0 -_080185D0: - ldr r2, _080185EC @ =gBattleWeather - ldrh r1, [r2] - movs r0, 0x7 - ands r0, r1 - cmp r0, 0 - bne _0801864C - movs r0, 0x5 - strh r0, [r2] - ldr r0, _080185F0 @ =0x02000000 - ldr r3, _080185F4 @ =0x000160a4 - adds r2, r0, r3 - movs r1, 0xA - b _08018638 - .align 2, 0 -_080185EC: .4byte gBattleWeather -_080185F0: .4byte 0x02000000 -_080185F4: .4byte 0x000160a4 -_080185F8: - ldr r3, _08018614 @ =gBattleWeather - ldrh r1, [r3] - movs r2, 0x18 - adds r0, r2, 0 - ands r0, r1 - cmp r0, 0 - bne _0801864C - strh r2, [r3] - ldr r0, _08018618 @ =0x02000000 - ldr r3, _0801861C @ =0x000160a4 - adds r2, r0, r3 - movs r1, 0xC - b _08018638 - .align 2, 0 -_08018614: .4byte gBattleWeather -_08018618: .4byte 0x02000000 -_0801861C: .4byte 0x000160a4 -_08018620: - ldr r3, _08018668 @ =gBattleWeather - ldrh r1, [r3] - movs r2, 0x60 - adds r0, r2, 0 - ands r0, r1 - cmp r0, 0 - bne _0801864C - strh r2, [r3] - ldr r0, _0801866C @ =0x02000000 - ldr r3, _08018670 @ =0x000160a4 - adds r2, r0, r3 - movs r1, 0xB -_08018638: - strb r1, [r2] - ldr r5, _08018674 @ =0x00016003 - adds r0, r5 - mov r1, r10 - strb r1, [r0] - mov r0, r9 - adds r0, 0x1 - lsls r0, 24 - lsrs r0, 24 - mov r9, r0 -_0801864C: - mov r2, r9 - cmp r2, 0 - bne _08018656 - bl _08019F92 -_08018656: - bl weather_get_current - ldr r1, _08018678 @ =gBattleCommunication - strb r0, [r1, 0x5] - ldr r0, _0801867C @ =gUnknown_081D901D - bl b_push_move_exec - bl _08019F76 - .align 2, 0 -_08018668: .4byte gBattleWeather -_0801866C: .4byte 0x02000000 -_08018670: .4byte 0x000160a4 -_08018674: .4byte 0x00016003 -_08018678: .4byte gBattleCommunication -_0801867C: .4byte gUnknown_081D901D -_08018680: - ldr r2, _080186A8 @ =gBattleWeather - ldrh r1, [r2] - movs r0, 0x4 - ands r0, r1 - cmp r0, 0 - beq _08018690 - bl _08019F76 -_08018690: - movs r0, 0x5 - strh r0, [r2] - ldr r0, _080186AC @ =gUnknown_081D9704 - bl b_push_move_exec - ldr r0, _080186B0 @ =0x02000000 - ldr r3, _080186B4 @ =0x00016003 - adds r0, r3 - mov r5, r10 - strb r5, [r0] - bl _08019F22 - .align 2, 0 -_080186A8: .4byte gBattleWeather -_080186AC: .4byte gUnknown_081D9704 -_080186B0: .4byte 0x02000000 -_080186B4: .4byte 0x00016003 -_080186B8: - ldr r2, _080186E0 @ =gBattleWeather - ldrh r1, [r2] - movs r0, 0x10 - ands r0, r1 - cmp r0, 0 - beq _080186C8 - bl _08019F76 -_080186C8: - movs r0, 0x18 - strh r0, [r2] - ldr r0, _080186E4 @ =gUnknown_081D9744 - bl b_push_move_exec - ldr r0, _080186E8 @ =0x02000000 - ldr r1, _080186EC @ =0x00016003 - adds r0, r1 - mov r2, r10 - strb r2, [r0] - bl _08019F22 - .align 2, 0 -_080186E0: .4byte gBattleWeather -_080186E4: .4byte gUnknown_081D9744 -_080186E8: .4byte 0x02000000 -_080186EC: .4byte 0x00016003 -_080186F0: - ldr r2, _08018718 @ =gBattleWeather - ldrh r1, [r2] - movs r0, 0x40 - ands r0, r1 - cmp r0, 0 - beq _08018700 - bl _08019F76 -_08018700: - movs r0, 0x60 - strh r0, [r2] - ldr r0, _0801871C @ =gUnknown_081D97FE - bl b_push_move_exec - ldr r0, _08018720 @ =0x02000000 - ldr r3, _08018724 @ =0x00016003 - adds r0, r3 - mov r5, r10 - strb r5, [r0] - bl _08019F22 - .align 2, 0 -_08018718: .4byte gBattleWeather -_0801871C: .4byte gUnknown_081D97FE -_08018720: .4byte 0x02000000 -_08018724: .4byte 0x00016003 -_08018728: - ldr r0, _08018754 @ =gSpecialStatuses - mov r1, r10 - lsls r2, r1, 2 - adds r1, r2, r1 - lsls r1, 2 - adds r3, r1, r0 - ldrb r0, [r3] - lsls r0, 28 - cmp r0, 0 - bge _08018740 - bl _08019F76 -_08018740: - ldr r1, _08018758 @ =gStatuses3 - adds r1, r2, r1 - ldr r0, [r1] - movs r2, 0x80 - lsls r2, 12 - orrs r0, r2 - str r0, [r1] - ldrb r0, [r3] - movs r1, 0x8 - b _080187CA - .align 2, 0 -_08018754: .4byte gSpecialStatuses -_08018758: .4byte gStatuses3 -_0801875C: - mov r0, r10 - bl castform_switch - lsls r0, 24 - lsrs r0, 24 - mov r9, r0 - cmp r0, 0 - bne _08018770 - bl _08019F92 -_08018770: - ldr r0, _08018790 @ =gUnknown_081D977D - bl b_push_move_exec - ldr r0, _08018794 @ =0x02000000 - ldr r2, _08018798 @ =0x00016003 - adds r1, r0, r2 - mov r3, r10 - strb r3, [r1] - mov r1, r9 - subs r1, 0x1 - ldr r5, _0801879C @ =0x0001609b - adds r0, r5 - strb r1, [r0] - bl _08019F76 - .align 2, 0 -_08018790: .4byte gUnknown_081D977D -_08018794: .4byte 0x02000000 -_08018798: .4byte 0x00016003 -_0801879C: .4byte 0x0001609b -_080187A0: - ldr r0, _080187D4 @ =gSpecialStatuses - mov r1, r10 - lsls r2, r1, 2 - adds r1, r2, r1 - lsls r1, 2 - adds r3, r1, r0 - ldrb r0, [r3] - lsls r0, 27 - cmp r0, 0 - bge _080187B8 - bl _08019F76 -_080187B8: - ldr r1, _080187D8 @ =gStatuses3 - adds r1, r2, r1 - ldr r0, [r1] - movs r2, 0x80 - lsls r2, 13 - orrs r0, r2 - str r0, [r1] - ldrb r0, [r3] - movs r1, 0x10 -_080187CA: - orrs r0, r1 - strb r0, [r3] - bl _08019F76 - .align 2, 0 -_080187D4: .4byte gSpecialStatuses -_080187D8: .4byte gStatuses3 -_080187DC: - movs r6, 0 - ldrb r5, [r5] - cmp r6, r5 - bcc _080187E8 - bl _08019F76 -_080187E8: - adds r0, r6, 0 - bl castform_switch - lsls r0, 24 - lsrs r0, 24 - mov r9, r0 - cmp r0, 0 - beq _080187FC - bl _08019E14 -_080187FC: - adds r0, r6, 0x1 - lsls r0, 24 - lsrs r6, r0, 24 - ldr r0, _08018810 @ =gNoOfAllBanks - ldrb r0, [r0] - cmp r6, r0 - bcc _080187E8 - bl _08019F76 - .align 2, 0 -_08018810: .4byte gNoOfAllBanks -_08018814: - ldr r2, _08018844 @ =gBattleMons - movs r0, 0x58 - mov r1, r10 - muls r1, r0 - adds r4, r1, r2 - ldrh r0, [r4, 0x28] - cmp r0, 0 - bne _08018828 - bl _08019F76 -_08018828: - ldr r0, _08018848 @ =gBankAttacker - mov r3, r10 - strb r3, [r0] - mov r3, r8 - ldrb r5, [r3] - cmp r5, 0x2C - beq _0801885A - cmp r5, 0x2C - bgt _0801884C - cmp r5, 0x3 - bne _08018840 - b _080189B8 -_08018840: - bl _08019F76 - .align 2, 0 -_08018844: .4byte gBattleMons -_08018848: .4byte gBankAttacker -_0801884C: - cmp r5, 0x36 - bne _08018852 - b _08018A18 -_08018852: - cmp r5, 0x3D - beq _080188DC - bl _08019F76 -_0801885A: - 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 _08018876 - bl _08019F76 -_08018876: - str r0, [sp] - movs r0, 0x13 - movs r1, 0 - movs r2, 0x4D - movs r3, 0 - bl AbilityBattleEffects - lsls r0, 24 - cmp r0, 0 - beq _0801888E - bl _08019F76 -_0801888E: - ldr r0, _080188D0 @ =gBattleWeather - ldrh r1, [r0] - movs r0, 0x7 - ands r0, r1 - cmp r0, 0 - bne _0801889E - bl _08019F76 -_0801889E: - ldrh r0, [r4, 0x2C] - ldrh r1, [r4, 0x28] - cmp r0, r1 - bhi _080188AA - bl _08019F76 -_080188AA: - mov r2, r8 - strb r5, [r2] - ldr r0, _080188D4 @ =gUnknown_081D9730 - bl b_push_move_exec - ldr r1, _080188D8 @ =gBattleMoveDamage - ldrh r0, [r4, 0x2C] - lsrs r0, 4 - str r0, [r1] - cmp r0, 0 - bne _080188C4 - movs r0, 0x1 - str r0, [r1] -_080188C4: - ldr r0, [r1] - negs r0, r0 - str r0, [r1] - bl _08019F22 - .align 2, 0 -_080188D0: .4byte gBattleWeather -_080188D4: .4byte gUnknown_081D9730 -_080188D8: .4byte gBattleMoveDamage -_080188DC: - adds r0, r2, 0 - adds r0, 0x4C - adds r5, r1, r0 - ldrb r0, [r5] - cmp r0, 0 - bne _080188EC - bl _08019F76 -_080188EC: - bl Random - lsls r0, 16 - lsrs r0, 16 - movs r1, 0x3 - bl __umodsi3 - lsls r0, 16 - lsrs r4, r0, 16 - cmp r4, 0 - beq _08018906 - bl _08019F76 -_08018906: - ldr r0, [r5] - movs r1, 0x88 - ands r0, r1 - cmp r0, 0 - beq _08018918 - ldr r0, _08018990 @ =gBattleTextBuff1 - ldr r1, _08018994 @ =gStatusConditionString_PoisonJpn - bl StringCopy -_08018918: - ldr r0, [r5] - movs r1, 0x7 - ands r0, r1 - cmp r0, 0 - beq _0801892A - ldr r0, _08018990 @ =gBattleTextBuff1 - ldr r1, _08018998 @ =gStatusConditionString_SleepJpn - bl StringCopy -_0801892A: - ldr r0, [r5] - movs r1, 0x40 - ands r0, r1 - cmp r0, 0 - beq _0801893C - ldr r0, _08018990 @ =gBattleTextBuff1 - ldr r1, _0801899C @ =gStatusConditionString_ParalysisJpn - bl StringCopy -_0801893C: - ldr r0, [r5] - movs r1, 0x10 - ands r0, r1 - cmp r0, 0 - beq _0801894E - ldr r0, _08018990 @ =gBattleTextBuff1 - ldr r1, _080189A0 @ =gStatusConditionString_BurnJpn - bl StringCopy -_0801894E: - ldr r0, [r5] - movs r1, 0x20 - ands r0, r1 - cmp r0, 0 - beq _08018960 - ldr r0, _08018990 @ =gBattleTextBuff1 - ldr r1, _080189A4 @ =gStatusConditionString_IceJpn - bl StringCopy -_08018960: - str r4, [r5] - ldr r0, _080189A8 @ =0x02000000 - ldr r4, _080189AC @ =gActiveBank - mov r3, r10 - strb r3, [r4] - ldr r1, _080189B0 @ =0x00016003 - adds r0, r1 - strb r3, [r0] - ldr r0, _080189B4 @ =gUnknown_081D9758 - bl b_push_move_exec - str r5, [sp] - movs r0, 0 - movs r1, 0x28 - movs r2, 0 - movs r3, 0x4 - bl EmitSetAttributes - ldrb r0, [r4] - bl MarkBufferBankForExecution - bl _08019F22 - .align 2, 0 -_08018990: .4byte gBattleTextBuff1 -_08018994: .4byte gStatusConditionString_PoisonJpn -_08018998: .4byte gStatusConditionString_SleepJpn -_0801899C: .4byte gStatusConditionString_ParalysisJpn -_080189A0: .4byte gStatusConditionString_BurnJpn -_080189A4: .4byte gStatusConditionString_IceJpn -_080189A8: .4byte 0x02000000 -_080189AC: .4byte gActiveBank -_080189B0: .4byte 0x00016003 -_080189B4: .4byte gUnknown_081D9758 -_080189B8: - ldrb r2, [r4, 0x1B] - movs r0, 0x1B - ldrsb r0, [r4, r0] - cmp r0, 0xB - ble _080189C6 - bl _08019F76 -_080189C6: - ldr r0, _08018A04 @ =gDisableStructs - mov r3, r10 - lsls r1, r3, 3 - subs r1, r3 - lsls r1, 2 - adds r1, r0 - ldrb r0, [r1, 0x16] - cmp r0, 0x2 - bne _080189DC - bl _08019F76 -_080189DC: - adds r0, r2, 0x1 - movs r2, 0 - strb r0, [r4, 0x1B] - ldr r5, _08018A08 @ =0x000160a4 - adds r1, r7, r5 - movs r0, 0x11 - strb r0, [r1] - ldr r1, _08018A0C @ =0x000160a5 - adds r0, r7, r1 - strb r2, [r0] - ldr r0, _08018A10 @ =gUnknown_081D9718 - bl b_push_move_exec - ldr r2, _08018A14 @ =0x00016003 - adds r0, r7, r2 - mov r3, r10 - strb r3, [r0] - bl _08019F22 - .align 2, 0 -_08018A04: .4byte gDisableStructs -_08018A08: .4byte 0x000160a4 -_08018A0C: .4byte 0x000160a5 -_08018A10: .4byte gUnknown_081D9718 -_08018A14: .4byte 0x00016003 -_08018A18: - ldr r2, _08018A3C @ =gDisableStructs - ldrb r0, [r0] - lsls r1, r0, 3 - subs r1, r0 - lsls r1, 2 - adds r1, r2 - ldrb r3, [r1, 0x18] - lsls r0, r3, 31 - lsrs r0, 31 - movs r2, 0x1 - eors r2, r0 - movs r0, 0x2 - negs r0, r0 - ands r0, r3 - orrs r0, r2 - strb r0, [r1, 0x18] - bl _08019F76 - .align 2, 0 -_08018A3C: .4byte gDisableStructs -_08018A40: - mov r5, r8 - ldrb r0, [r5] - cmp r0, 0x2B - beq _08018A4C - bl _08019F76 -_08018A4C: - movs r4, 0 - ldr r0, _08018ABC @ =gUnknown_081FA724 - ldrh r2, [r0] - ldr r5, _08018AC0 @ =0x0000ffff - adds r1, r0, 0 - cmp r2, r5 - bne _08018A5E - bl _08019F76 -_08018A5E: - cmp r2, r3 - beq _08018A76 - adds r2, r1, 0 -_08018A64: - adds r2, 0x2 - adds r4, 0x1 - ldrh r0, [r2] - cmp r0, r5 - bne _08018A72 - bl _08019F76 -_08018A72: - cmp r0, r3 - bne _08018A64 -_08018A76: - lsls r0, r4, 1 - adds r0, r1 - ldrh r1, [r0] - ldr r0, _08018AC0 @ =0x0000ffff - cmp r1, r0 - bne _08018A86 - bl _08019F76 -_08018A86: - ldr r1, _08018AC4 @ =gBattleMons - ldr r0, _08018AC8 @ =gBankAttacker - 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 _08018AAC - ldr r0, _08018ACC @ =gHitMarker - ldr r1, [r0] - movs r2, 0x80 - lsls r2, 4 - orrs r1, r2 - str r1, [r0] -_08018AAC: - ldr r1, _08018AD0 @ =gBattlescriptCurrInstr - ldr r0, _08018AD4 @ =gUnknown_081D98F3 - str r0, [r1] - movs r0, 0x1 - mov r9, r0 - bl _08019F7C - .align 2, 0 -_08018ABC: .4byte gUnknown_081FA724 -_08018AC0: .4byte 0x0000ffff -_08018AC4: .4byte gBattleMons -_08018AC8: .4byte gBankAttacker -_08018ACC: .4byte gHitMarker -_08018AD0: .4byte gBattlescriptCurrInstr -_08018AD4: .4byte gUnknown_081D98F3 -_08018AD8: - cmp r3, 0 - bne _08018AE0 - bl _08019F76 -_08018AE0: - mov r1, r8 - ldrb r0, [r1] - cmp r0, 0xB - beq _08018B50 - cmp r0, 0xB - bgt _08018AF2 - cmp r0, 0xA - beq _08018AF8 - b _08018C6A -_08018AF2: - cmp r0, 0x12 - beq _08018BA8 - b _08018C6A -_08018AF8: - cmp r4, 0xD - beq _08018AFE - b _08018C6A -_08018AFE: - ldr r0, _08018B28 @ =gBattleMoves - lsls r1, r3, 1 - adds r1, r3 - lsls r1, 2 - adds r1, r0 - ldrb r0, [r1, 0x1] - cmp r0, 0 - bne _08018B10 - b _08018C6A -_08018B10: - ldr r1, _08018B2C @ =gProtectStructs - ldr r0, _08018B30 @ =gBankAttacker - ldrb r0, [r0] - lsls r0, 4 - adds r0, r1 - ldrb r0, [r0, 0x2] - lsls r0, 28 - cmp r0, 0 - bge _08018B3C - ldr r1, _08018B34 @ =gBattlescriptCurrInstr - ldr r0, _08018B38 @ =gUnknown_081D9843 - b _08018B40 - .align 2, 0 -_08018B28: .4byte gBattleMoves -_08018B2C: .4byte gProtectStructs -_08018B30: .4byte gBankAttacker -_08018B34: .4byte gBattlescriptCurrInstr -_08018B38: .4byte gUnknown_081D9843 -_08018B3C: - ldr r1, _08018B48 @ =gBattlescriptCurrInstr - ldr r0, _08018B4C @ =gUnknown_081D9842 -_08018B40: - str r0, [r1] - movs r2, 0x1 - b _08018C68 - .align 2, 0 -_08018B48: .4byte gBattlescriptCurrInstr -_08018B4C: .4byte gUnknown_081D9842 -_08018B50: - cmp r4, 0xB - beq _08018B56 - b _08018C6A -_08018B56: - ldr r0, _08018B80 @ =gBattleMoves - lsls r1, r3, 1 - adds r1, r3 - lsls r1, 2 - adds r1, r0 - ldrb r0, [r1, 0x1] - cmp r0, 0 - bne _08018B68 - b _08018C6A -_08018B68: - ldr r1, _08018B84 @ =gProtectStructs - ldr r0, _08018B88 @ =gBankAttacker - ldrb r0, [r0] - lsls r0, 4 - adds r0, r1 - ldrb r0, [r0, 0x2] - lsls r0, 28 - cmp r0, 0 - bge _08018B94 - ldr r1, _08018B8C @ =gBattlescriptCurrInstr - ldr r0, _08018B90 @ =gUnknown_081D9843 - b _08018B98 - .align 2, 0 -_08018B80: .4byte gBattleMoves -_08018B84: .4byte gProtectStructs -_08018B88: .4byte gBankAttacker -_08018B8C: .4byte gBattlescriptCurrInstr -_08018B90: .4byte gUnknown_081D9843 -_08018B94: - ldr r1, _08018BA0 @ =gBattlescriptCurrInstr - ldr r0, _08018BA4 @ =gUnknown_081D9842 -_08018B98: - str r0, [r1] - movs r3, 0x1 - mov r9, r3 - b _08018C6A - .align 2, 0 -_08018BA0: .4byte gBattlescriptCurrInstr -_08018BA4: .4byte gUnknown_081D9842 -_08018BA8: - cmp r4, 0xA - bne _08018C6A - ldr r1, _08018BF4 @ =gBattleMons - movs r0, 0x58 - mov r5, r10 - muls r5, r0 - adds r0, r5, 0 - adds r1, 0x4C - adds r0, r1 - ldr r0, [r0] - movs r1, 0x20 - ands r0, r1 - cmp r0, 0 - bne _08018C6A - ldr r2, _08018BF8 @ =0x02017100 - mov r0, r10 - lsls r1, r0, 2 - adds r0, r1, r2 - ldr r3, [r0] - movs r4, 0x1 - ands r3, r4 - adds r5, r1, 0 - cmp r3, 0 - bne _08018C30 - ldr r0, _08018BFC @ =gBattleCommunication - strb r3, [r0, 0x5] - ldr r1, _08018C00 @ =gProtectStructs - ldr r0, _08018C04 @ =gBankAttacker - ldrb r0, [r0] - lsls r0, 4 - adds r0, r1 - ldrb r0, [r0, 0x2] - lsls r0, 28 - cmp r0, 0 - bge _08018C10 - ldr r1, _08018C08 @ =gBattlescriptCurrInstr - ldr r0, _08018C0C @ =gUnknown_081D987C - b _08018C14 - .align 2, 0 -_08018BF4: .4byte gBattleMons -_08018BF8: .4byte 0x02017100 -_08018BFC: .4byte gBattleCommunication -_08018C00: .4byte gProtectStructs -_08018C04: .4byte gBankAttacker -_08018C08: .4byte gBattlescriptCurrInstr -_08018C0C: .4byte gUnknown_081D987C -_08018C10: - ldr r1, _08018C28 @ =gBattlescriptCurrInstr - ldr r0, _08018C2C @ =gUnknown_081D987B -_08018C14: - str r0, [r1] - adds r0, r5, r2 - ldr r1, [r0] - movs r2, 0x1 - orrs r1, r2 - str r1, [r0] - movs r1, 0x2 - mov r9, r1 - b _08018C6A - .align 2, 0 -_08018C28: .4byte gBattlescriptCurrInstr -_08018C2C: .4byte gUnknown_081D987B -_08018C30: - ldr r0, _08018C4C @ =gBattleCommunication - strb r4, [r0, 0x5] - ldr r1, _08018C50 @ =gProtectStructs - ldr r0, _08018C54 @ =gBankAttacker - ldrb r0, [r0] - lsls r0, 4 - adds r0, r1 - ldrb r0, [r0, 0x2] - lsls r0, 28 - cmp r0, 0 - bge _08018C60 - ldr r1, _08018C58 @ =gBattlescriptCurrInstr - ldr r0, _08018C5C @ =gUnknown_081D987C - b _08018C64 - .align 2, 0 -_08018C4C: .4byte gBattleCommunication -_08018C50: .4byte gProtectStructs -_08018C54: .4byte gBankAttacker -_08018C58: .4byte gBattlescriptCurrInstr -_08018C5C: .4byte gUnknown_081D987C -_08018C60: - ldr r1, _08018CA4 @ =gBattlescriptCurrInstr - ldr r0, _08018CA8 @ =gUnknown_081D987B -_08018C64: - str r0, [r1] - movs r2, 0x2 -_08018C68: - mov r9, r2 -_08018C6A: - mov r3, r9 - cmp r3, 0x1 - beq _08018C74 - bl _08019F76 -_08018C74: - ldr r1, _08018CAC @ =gBattleMons - movs r0, 0x58 - mov r5, r10 - muls r5, r0 - adds r0, r5, 0 - adds r1, r0, r1 - ldrh r0, [r1, 0x2C] - ldrh r2, [r1, 0x28] - cmp r0, r2 - bne _08018CD0 - ldr r1, _08018CB0 @ =gProtectStructs - ldr r0, _08018CB4 @ =gBankAttacker - ldrb r0, [r0] - lsls r0, 4 - adds r0, r1 - ldrb r0, [r0, 0x2] - lsls r0, 28 - cmp r0, 0 - bge _08018CBC - ldr r1, _08018CA4 @ =gBattlescriptCurrInstr - ldr r0, _08018CB8 @ =gUnknown_081D9866 - str r0, [r1] - bl _08019F76 - .align 2, 0 -_08018CA4: .4byte gBattlescriptCurrInstr -_08018CA8: .4byte gUnknown_081D987B -_08018CAC: .4byte gBattleMons -_08018CB0: .4byte gProtectStructs -_08018CB4: .4byte gBankAttacker -_08018CB8: .4byte gUnknown_081D9866 -_08018CBC: - ldr r1, _08018CC8 @ =gBattlescriptCurrInstr - ldr r0, _08018CCC @ =gUnknown_081D9865 - str r0, [r1] - bl _08019F76 - .align 2, 0 -_08018CC8: .4byte gBattlescriptCurrInstr -_08018CCC: .4byte gUnknown_081D9865 -_08018CD0: - ldr r2, _08018CEC @ =gBattleMoveDamage - ldrh r0, [r1, 0x2C] - lsrs r0, 2 - str r0, [r2] - cmp r0, 0 - bne _08018CE0 - mov r3, r9 - str r3, [r2] -_08018CE0: - ldr r0, [r2] - negs r0, r0 - str r0, [r2] - bl _08019F76 - .align 2, 0 -_08018CEC: .4byte gBattleMoveDamage -_08018CF0: - mov r5, r8 - ldrb r0, [r5] - subs r0, 0x9 - cmp r0, 0x2F - bls _08018CFE - bl _08019F76 -_08018CFE: - lsls r0, 2 - ldr r1, _08018D08 @ =_08018D0C - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .align 2, 0 -_08018D08: .4byte _08018D0C - .align 2, 0 -_08018D0C: - .4byte _08019128 - .4byte _08019F76 - .4byte _08019F76 - .4byte _08019F76 - .4byte _08019F76 - .4byte _08019F76 - .4byte _08019F76 - .4byte _08018DCC - .4byte _08019F76 - .4byte _08019F76 - .4byte _08019F76 - .4byte _08019F76 - .4byte _08019F76 - .4byte _08019F76 - .4byte _08019F76 - .4byte _08018E94 - .4byte _08019F76 - .4byte _08019F76 - .4byte _08018F54 - .4byte _08019F76 - .4byte _08019F76 - .4byte _08019F76 - .4byte _08019F76 - .4byte _08019F76 - .4byte _08019F76 - .4byte _08019F76 - .4byte _08019F76 - .4byte _08019F76 - .4byte _08019F76 - .4byte _0801904C - .4byte _08019F76 - .4byte _08019F76 - .4byte _08019F76 - .4byte _08019F76 - .4byte _08019F76 - .4byte _08019F76 - .4byte _08019F76 - .4byte _08019F76 - .4byte _08019F76 - .4byte _08019F76 - .4byte _08019204 - .4byte _08019F76 - .4byte _08019F76 - .4byte _08019F76 - .4byte _08019F76 - .4byte _08019F76 - .4byte _08019F76 - .4byte _080192E0 -_08018DCC: - ldr r0, _08018E74 @ =gBattleMoveFlags - ldrb r1, [r0] - movs r0, 0x29 - ands r0, r1 - cmp r0, 0 - beq _08018DDC - bl _08019F76 -_08018DDC: - cmp r3, 0xA5 - bne _08018DE4 - bl _08019F76 -_08018DE4: - ldr r0, _08018E78 @ =gBattleMoves - lsls r1, r3, 1 - adds r1, r3 - lsls r1, 2 - adds r1, r0 - ldrb r0, [r1, 0x1] - cmp r0, 0 - bne _08018DF8 - bl _08019F76 -_08018DF8: - ldr r2, _08018E7C @ =gSpecialStatuses - ldr r0, _08018E80 @ =gBankTarget - ldrb r1, [r0] - lsls r0, r1, 2 - adds r0, r1 - lsls r1, r0, 2 - adds r0, r2, 0 - adds r0, 0x8 - adds r0, r1, r0 - ldr r0, [r0] - cmp r0, 0 - bne _08018E20 - adds r0, r2, 0 - adds r0, 0xC - adds r0, r1, r0 - ldr r0, [r0] - cmp r0, 0 - bne _08018E20 - bl _08019F76 -_08018E20: - ldr r1, _08018E84 @ =gBattleMons - movs r0, 0x58 - mov r2, r10 - muls r2, r0 - adds r0, r2, 0 - adds r1, r0, r1 - adds r3, r1, 0 - adds r3, 0x21 - ldrb r0, [r3] - cmp r0, r4 - bne _08018E3A - bl _08019F76 -_08018E3A: - adds r2, r1, 0 - adds r2, 0x22 - ldrb r0, [r2] - cmp r0, r4 - bne _08018E48 - bl _08019F76 -_08018E48: - ldrh r0, [r1, 0x28] - cmp r0, 0 - bne _08018E52 - bl _08019F76 -_08018E52: - strb r4, [r3] - strb r4, [r2] - ldr r1, _08018E88 @ =gBattleTextBuff1 - movs r0, 0xFD - strb r0, [r1] - movs r0, 0x3 - strb r0, [r1, 0x1] - strb r4, [r1, 0x2] - movs r0, 0xFF - strb r0, [r1, 0x3] - bl b_movescr_stack_push_cursor - ldr r1, _08018E8C @ =gBattlescriptCurrInstr - ldr r0, _08018E90 @ =gUnknown_081D9921 - str r0, [r1] - bl _08019F22 - .align 2, 0 -_08018E74: .4byte gBattleMoveFlags -_08018E78: .4byte gBattleMoves -_08018E7C: .4byte gSpecialStatuses -_08018E80: .4byte gBankTarget -_08018E84: .4byte gBattleMons -_08018E88: .4byte gBattleTextBuff1 -_08018E8C: .4byte gBattlescriptCurrInstr -_08018E90: .4byte gUnknown_081D9921 -_08018E94: - ldr r0, _08018F2C @ =gBattleMoveFlags - ldrb r1, [r0] - movs r0, 0x29 - ands r0, r1 - cmp r0, 0 - beq _08018EA4 - bl _08019F76 -_08018EA4: - ldr r1, _08018F30 @ =gBattleMons - ldr r0, _08018F34 @ =gBankAttacker - ldrb r2, [r0] - movs r0, 0x58 - muls r0, r2 - adds r4, r0, r1 - ldrh r0, [r4, 0x28] - cmp r0, 0 - bne _08018EBA - bl _08019F76 -_08018EBA: - ldr r0, _08018F38 @ =gProtectStructs - lsls r1, r2, 4 - adds r1, r0 - ldrb r0, [r1, 0x1] - lsls r0, 31 - cmp r0, 0 - beq _08018ECC - bl _08019F76 -_08018ECC: - ldr r2, _08018F3C @ =gSpecialStatuses - ldr r0, _08018F40 @ =gBankTarget - ldrb r1, [r0] - lsls r0, r1, 2 - adds r0, r1 - lsls r1, r0, 2 - adds r0, r2, 0 - adds r0, 0x8 - adds r0, r1, r0 - ldr r0, [r0] - cmp r0, 0 - bne _08018EF4 - adds r0, r2, 0 - adds r0, 0xC - adds r0, r1, r0 - ldr r0, [r0] - cmp r0, 0 - bne _08018EF4 - bl _08019F76 -_08018EF4: - ldr r1, _08018F44 @ =gBattleMoves - lsls r0, r3, 1 - adds r0, r3 - lsls r0, 2 - adds r0, r1 - ldrb r1, [r0, 0x8] - movs r2, 0x1 - adds r0, r2, 0 - ands r0, r1 - cmp r0, 0 - bne _08018F0E - bl _08019F76 -_08018F0E: - ldr r1, _08018F48 @ =gBattleMoveDamage - ldrh r0, [r4, 0x2C] - lsrs r0, 4 - str r0, [r1] - cmp r0, 0 - bne _08018F1C - str r2, [r1] -_08018F1C: - bl b_movescr_stack_push_cursor - ldr r1, _08018F4C @ =gBattlescriptCurrInstr - ldr r0, _08018F50 @ =gUnknown_081D9928 - str r0, [r1] - bl _08019F22 - .align 2, 0 -_08018F2C: .4byte gBattleMoveFlags -_08018F30: .4byte gBattleMons -_08018F34: .4byte gBankAttacker -_08018F38: .4byte gProtectStructs -_08018F3C: .4byte gSpecialStatuses -_08018F40: .4byte gBankTarget -_08018F44: .4byte gBattleMoves -_08018F48: .4byte gBattleMoveDamage -_08018F4C: .4byte gBattlescriptCurrInstr -_08018F50: .4byte gUnknown_081D9928 -_08018F54: - ldr r0, _08019020 @ =gBattleMoveFlags - ldrb r1, [r0] - movs r0, 0x29 - ands r0, r1 - cmp r0, 0 - beq _08018F64 - bl _08019F76 -_08018F64: - ldr r1, _08019024 @ =gBattleMons - ldr r0, _08019028 @ =gBankAttacker - ldrb r2, [r0] - movs r0, 0x58 - muls r0, r2 - adds r0, r1 - ldrh r0, [r0, 0x28] - cmp r0, 0 - bne _08018F7A - bl _08019F76 -_08018F7A: - ldr r0, _0801902C @ =gProtectStructs - lsls r1, r2, 4 - adds r1, r0 - ldrb r0, [r1, 0x1] - lsls r0, 31 - cmp r0, 0 - beq _08018F8C - bl _08019F76 -_08018F8C: - ldr r2, _08019030 @ =gSpecialStatuses - ldr r0, _08019034 @ =gBankTarget - ldrb r1, [r0] - lsls r0, r1, 2 - adds r0, r1 - lsls r1, r0, 2 - adds r0, r2, 0 - adds r0, 0x8 - adds r0, r1, r0 - ldr r0, [r0] - cmp r0, 0 - bne _08018FB4 - adds r0, r2, 0 - adds r0, 0xC - adds r0, r1, r0 - ldr r0, [r0] - cmp r0, 0 - bne _08018FB4 - bl _08019F76 -_08018FB4: - ldr r1, _08019038 @ =gBattleMoves - lsls r0, r3, 1 - adds r0, r3 - lsls r0, 2 - adds r0, r1 - ldrb r1, [r0, 0x8] - movs r0, 0x1 - ands r0, r1 - cmp r0, 0 - bne _08018FCC - bl _08019F76 -_08018FCC: - bl Random - lsls r0, 16 - lsrs r0, 16 - movs r1, 0xA - bl __umodsi3 - lsls r0, 16 - cmp r0, 0 - beq _08018FE4 - bl _08019F76 -_08018FE4: - ldr r5, _0801903C @ =gBattleCommunication - movs r4, 0x3 -_08018FE8: - bl Random - ands r0, r4 - strb r0, [r5, 0x3] - cmp r0, 0 - beq _08018FE8 - ldr r1, _0801903C @ =gBattleCommunication - ldrb r0, [r1, 0x3] - cmp r0, 0x3 - bne _08019000 - adds r0, 0x2 - strb r0, [r1, 0x3] -_08019000: - ldrb r0, [r1, 0x3] - adds r0, 0x40 - strb r0, [r1, 0x3] - bl b_movescr_stack_push_cursor - ldr r1, _08019040 @ =gBattlescriptCurrInstr - ldr r0, _08019044 @ =gUnknown_081D9950 - str r0, [r1] - ldr r2, _08019048 @ =gHitMarker - ldr r0, [r2] - movs r1, 0x80 - lsls r1, 6 - orrs r0, r1 - str r0, [r2] - bl _08019F22 - .align 2, 0 -_08019020: .4byte gBattleMoveFlags -_08019024: .4byte gBattleMons -_08019028: .4byte gBankAttacker -_0801902C: .4byte gProtectStructs -_08019030: .4byte gSpecialStatuses -_08019034: .4byte gBankTarget -_08019038: .4byte gBattleMoves -_0801903C: .4byte gBattleCommunication -_08019040: .4byte gBattlescriptCurrInstr -_08019044: .4byte gUnknown_081D9950 -_08019048: .4byte gHitMarker -_0801904C: - ldr r0, _080190FC @ =gBattleMoveFlags - ldrb r1, [r0] - movs r0, 0x29 - ands r0, r1 - cmp r0, 0 - beq _0801905C - bl _08019F76 -_0801905C: - ldr r1, _08019100 @ =gBattleMons - ldr r0, _08019104 @ =gBankAttacker - ldrb r2, [r0] - movs r0, 0x58 - muls r0, r2 - adds r0, r1 - ldrh r0, [r0, 0x28] - cmp r0, 0 - bne _08019072 - bl _08019F76 -_08019072: - ldr r0, _08019108 @ =gProtectStructs - lsls r1, r2, 4 - adds r1, r0 - ldrb r0, [r1, 0x1] - lsls r0, 31 - cmp r0, 0 - beq _08019084 - bl _08019F76 -_08019084: - ldr r2, _0801910C @ =gSpecialStatuses - ldr r0, _08019110 @ =gBankTarget - ldrb r1, [r0] - lsls r0, r1, 2 - adds r0, r1 - lsls r1, r0, 2 - adds r0, r2, 0 - adds r0, 0x8 - adds r0, r1, r0 - ldr r0, [r0] - cmp r0, 0 - bne _080190AC - adds r0, r2, 0 - adds r0, 0xC - adds r0, r1, r0 - ldr r0, [r0] - cmp r0, 0 - bne _080190AC - bl _08019F76 -_080190AC: - ldr r1, _08019114 @ =gBattleMoves - lsls r0, r3, 1 - adds r0, r3 - lsls r0, 2 - adds r0, r1 - ldrb r1, [r0, 0x8] - movs r0, 0x1 - ands r0, r1 - cmp r0, 0 - bne _080190C4 - bl _08019F76 -_080190C4: - bl Random - lsls r0, 16 - lsrs r0, 16 - movs r1, 0x3 - bl __umodsi3 - lsls r0, 16 - cmp r0, 0 - beq _080190DC - bl _08019F76 -_080190DC: - ldr r1, _08019118 @ =gBattleCommunication - movs r0, 0x42 - strb r0, [r1, 0x3] - bl b_movescr_stack_push_cursor - ldr r1, _0801911C @ =gBattlescriptCurrInstr - ldr r0, _08019120 @ =gUnknown_081D9950 - str r0, [r1] - ldr r2, _08019124 @ =gHitMarker - ldr r0, [r2] - movs r1, 0x80 - lsls r1, 6 - orrs r0, r1 - str r0, [r2] - bl _08019F22 - .align 2, 0 -_080190FC: .4byte gBattleMoveFlags -_08019100: .4byte gBattleMons -_08019104: .4byte gBankAttacker -_08019108: .4byte gProtectStructs -_0801910C: .4byte gSpecialStatuses -_08019110: .4byte gBankTarget -_08019114: .4byte gBattleMoves -_08019118: .4byte gBattleCommunication -_0801911C: .4byte gBattlescriptCurrInstr -_08019120: .4byte gUnknown_081D9950 -_08019124: .4byte gHitMarker -_08019128: - ldr r0, _080191D8 @ =gBattleMoveFlags - ldrb r1, [r0] - movs r0, 0x29 - ands r0, r1 - cmp r0, 0 - beq _08019138 - bl _08019F76 -_08019138: - ldr r1, _080191DC @ =gBattleMons - ldr r0, _080191E0 @ =gBankAttacker - ldrb r2, [r0] - movs r0, 0x58 - muls r0, r2 - adds r0, r1 - ldrh r0, [r0, 0x28] - cmp r0, 0 - bne _0801914E - bl _08019F76 -_0801914E: - ldr r0, _080191E4 @ =gProtectStructs - lsls r1, r2, 4 - adds r1, r0 - ldrb r0, [r1, 0x1] - lsls r0, 31 - cmp r0, 0 - beq _08019160 - bl _08019F76 -_08019160: - ldr r2, _080191E8 @ =gSpecialStatuses - ldr r0, _080191EC @ =gBankTarget - ldrb r1, [r0] - lsls r0, r1, 2 - adds r0, r1 - lsls r1, r0, 2 - adds r0, r2, 0 - adds r0, 0x8 - adds r0, r1, r0 - ldr r0, [r0] - cmp r0, 0 - bne _08019188 - adds r0, r2, 0 - adds r0, 0xC - adds r0, r1, r0 - ldr r0, [r0] - cmp r0, 0 - bne _08019188 - bl _08019F76 -_08019188: - ldr r1, _080191F0 @ =gBattleMoves - lsls r0, r3, 1 - adds r0, r3 - lsls r0, 2 - adds r0, r1 - ldrb r1, [r0, 0x8] - movs r0, 0x1 - ands r0, r1 - cmp r0, 0 - bne _080191A0 - bl _08019F76 -_080191A0: - bl Random - lsls r0, 16 - lsrs r0, 16 - movs r1, 0x3 - bl __umodsi3 - lsls r0, 16 - cmp r0, 0 - beq _080191B8 - bl _08019F76 -_080191B8: - ldr r1, _080191F4 @ =gBattleCommunication - movs r0, 0x45 - strb r0, [r1, 0x3] - bl b_movescr_stack_push_cursor - ldr r1, _080191F8 @ =gBattlescriptCurrInstr - ldr r0, _080191FC @ =gUnknown_081D9950 - str r0, [r1] - ldr r2, _08019200 @ =gHitMarker - ldr r0, [r2] - movs r1, 0x80 - lsls r1, 6 - orrs r0, r1 - str r0, [r2] - bl _08019F22 - .align 2, 0 -_080191D8: .4byte gBattleMoveFlags -_080191DC: .4byte gBattleMons -_080191E0: .4byte gBankAttacker -_080191E4: .4byte gProtectStructs -_080191E8: .4byte gSpecialStatuses -_080191EC: .4byte gBankTarget -_080191F0: .4byte gBattleMoves -_080191F4: .4byte gBattleCommunication -_080191F8: .4byte gBattlescriptCurrInstr -_080191FC: .4byte gUnknown_081D9950 -_08019200: .4byte gHitMarker -_08019204: - ldr r0, _080192B4 @ =gBattleMoveFlags - ldrb r1, [r0] - movs r0, 0x29 - ands r0, r1 - cmp r0, 0 - beq _08019214 - bl _08019F76 -_08019214: - ldr r1, _080192B8 @ =gBattleMons - ldr r0, _080192BC @ =gBankAttacker - ldrb r2, [r0] - movs r0, 0x58 - muls r0, r2 - adds r0, r1 - ldrh r0, [r0, 0x28] - cmp r0, 0 - bne _0801922A - bl _08019F76 -_0801922A: - ldr r0, _080192C0 @ =gProtectStructs - lsls r1, r2, 4 - adds r1, r0 - ldrb r0, [r1, 0x1] - lsls r0, 31 - cmp r0, 0 - beq _0801923C - bl _08019F76 -_0801923C: - ldr r1, _080192C4 @ =gBattleMoves - lsls r0, r3, 1 - adds r0, r3 - lsls r0, 2 - adds r0, r1 - ldrb r1, [r0, 0x8] - movs r0, 0x1 - ands r0, r1 - cmp r0, 0 - bne _08019254 - bl _08019F76 -_08019254: - ldr r2, _080192C8 @ =gSpecialStatuses - ldr r0, _080192CC @ =gBankTarget - ldrb r1, [r0] - lsls r0, r1, 2 - adds r0, r1 - lsls r1, r0, 2 - adds r0, r2, 0 - adds r0, 0x8 - adds r0, r1, r0 - ldr r0, [r0] - cmp r0, 0 - bne _0801927C - adds r0, r2, 0 - adds r0, 0xC - adds r0, r1, r0 - ldr r0, [r0] - cmp r0, 0 - bne _0801927C - bl _08019F76 -_0801927C: - bl Random - lsls r0, 16 - lsrs r0, 16 - movs r1, 0x3 - bl __umodsi3 - lsls r0, 16 - cmp r0, 0 - beq _08019294 - bl _08019F76 -_08019294: - ldr r1, _080192D0 @ =gBattleCommunication - movs r0, 0x43 - strb r0, [r1, 0x3] - bl b_movescr_stack_push_cursor - ldr r1, _080192D4 @ =gBattlescriptCurrInstr - ldr r0, _080192D8 @ =gUnknown_081D9950 - str r0, [r1] - ldr r2, _080192DC @ =gHitMarker - ldr r0, [r2] - movs r1, 0x80 - lsls r1, 6 - orrs r0, r1 - str r0, [r2] - bl _08019F22 - .align 2, 0 -_080192B4: .4byte gBattleMoveFlags -_080192B8: .4byte gBattleMons -_080192BC: .4byte gBankAttacker -_080192C0: .4byte gProtectStructs -_080192C4: .4byte gBattleMoves -_080192C8: .4byte gSpecialStatuses -_080192CC: .4byte gBankTarget -_080192D0: .4byte gBattleCommunication -_080192D4: .4byte gBattlescriptCurrInstr -_080192D8: .4byte gUnknown_081D9950 -_080192DC: .4byte gHitMarker -_080192E0: - ldr r0, _08019420 @ =gBattleMoveFlags - ldrb r1, [r0] - movs r0, 0x29 - ands r0, r1 - cmp r0, 0 - beq _080192F0 - bl _08019F76 -_080192F0: - ldr r5, _08019424 @ =gBattleMons - ldr r7, _08019428 @ =gBankAttacker - ldrb r1, [r7] - movs r6, 0x58 - adds r0, r1, 0 - muls r0, r6 - adds r0, r5 - ldrh r0, [r0, 0x28] - cmp r0, 0 - bne _08019308 - bl _08019F76 -_08019308: - ldr r0, _0801942C @ =gProtectStructs - lsls r1, 4 - adds r1, r0 - ldrb r0, [r1, 0x1] - lsls r0, 31 - cmp r0, 0 - beq _0801931A - bl _08019F76 -_0801931A: - ldr r1, _08019430 @ =gBattleMoves - lsls r0, r3, 1 - adds r0, r3 - lsls r0, 2 - adds r0, r1 - ldrb r1, [r0, 0x8] - movs r0, 0x1 - ands r0, r1 - cmp r0, 0 - bne _08019332 - bl _08019F76 -_08019332: - ldr r3, _08019434 @ =gSpecialStatuses - ldr r0, _08019438 @ =gBankTarget - mov r8, r0 - ldrb r1, [r0] - lsls r0, r1, 2 - adds r0, r1 - lsls r2, r0, 2 - adds r0, r3, 0 - adds r0, 0x8 - adds r0, r2, r0 - ldr r0, [r0] - cmp r0, 0 - bne _0801935C - adds r0, r3, 0 - adds r0, 0xC - adds r0, r2, r0 - ldr r0, [r0] - cmp r0, 0 - bne _0801935C - bl _08019F76 -_0801935C: - adds r0, r1, 0 - muls r0, r6 - adds r0, r5 - ldrh r0, [r0, 0x28] - cmp r0, 0 - bne _0801936C - bl _08019F76 -_0801936C: - bl Random - lsls r0, 16 - lsrs r0, 16 - movs r1, 0x3 - bl __umodsi3 - lsls r0, 16 - cmp r0, 0 - beq _08019384 - bl _08019F76 -_08019384: - ldrb r0, [r7] - muls r0, r6 - adds r0, r5 - adds r0, 0x20 - ldrb r0, [r0] - cmp r0, 0xC - bne _08019396 - bl _08019F76 -_08019396: - ldr r0, [sp, 0x8] - ldr r1, [sp, 0x10] - bl GetGenderFromSpeciesAndPersonality - adds r4, r0, 0 - ldr r0, [sp, 0xC] - ldr r1, [sp, 0x14] - bl GetGenderFromSpeciesAndPersonality - lsls r4, 24 - lsls r0, 24 - cmp r4, r0 - bne _080193B4 - bl _08019F76 -_080193B4: - ldrb r0, [r7] - muls r0, r6 - adds r4, r5, 0 - adds r4, 0x50 - adds r0, r4 - ldr r0, [r0] - movs r1, 0xF0 - lsls r1, 12 - ands r0, r1 - cmp r0, 0 - beq _080193CE - bl _08019F76 -_080193CE: - ldr r0, [sp, 0x8] - ldr r1, [sp, 0x10] - bl GetGenderFromSpeciesAndPersonality - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0xFF - bne _080193E2 - bl _08019F76 -_080193E2: - ldr r0, [sp, 0xC] - ldr r1, [sp, 0x14] - bl GetGenderFromSpeciesAndPersonality - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0xFF - bne _080193F6 - bl _08019F76 -_080193F6: - ldrb r0, [r7] - adds r2, r0, 0 - muls r2, r6 - adds r2, r4 - ldr r1, _0801943C @ =gBitTable - mov r3, r8 - ldrb r0, [r3] - lsls r0, 2 - adds r0, r1 - ldr r1, [r0] - lsls r1, 16 - ldr r0, [r2] - orrs r0, r1 - str r0, [r2] - bl b_movescr_stack_push_cursor - ldr r1, _08019440 @ =gBattlescriptCurrInstr - ldr r0, _08019444 @ =gUnknown_081D9943 - str r0, [r1] - bl _08019F22 - .align 2, 0 -_08019420: .4byte gBattleMoveFlags -_08019424: .4byte gBattleMons -_08019428: .4byte gBankAttacker -_0801942C: .4byte gProtectStructs -_08019430: .4byte gBattleMoves -_08019434: .4byte gSpecialStatuses -_08019438: .4byte gBankTarget -_0801943C: .4byte gBitTable -_08019440: .4byte gBattlescriptCurrInstr -_08019444: .4byte gUnknown_081D9943 -_08019448: - movs r5, 0 - mov r10, r5 - ldr r0, _0801947C @ =gNoOfAllBanks - ldrb r0, [r0] - cmp r10, r0 - bcc _08019458 - bl _08019F76 -_08019458: - ldr r1, _08019480 @ =gBattleMons - movs r0, 0x58 - mov r2, r10 - muls r2, r0 - adds r0, r2, 0 - adds r0, r1 - adds r0, 0x20 - ldrb r0, [r0] - subs r0, 0x7 - adds r2, r1, 0 - cmp r0, 0x41 - bls _08019472 - b _080196D6 -_08019472: - lsls r0, 2 - ldr r1, _08019484 @ =_08019488 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .align 2, 0 -_0801947C: .4byte gNoOfAllBanks -_08019480: .4byte gBattleMons -_08019484: .4byte _08019488 - .align 2, 0 -_08019488: - .4byte _080195EC - .4byte _080196D6 - .4byte _080196D6 - .4byte _080196D6 - .4byte _080196D6 - .4byte _080196B0 - .4byte _080196D6 - .4byte _080196D6 - .4byte _08019614 - .4byte _080196D6 - .4byte _08019590 - .4byte _080196D6 - .4byte _080196D6 - .4byte _080195BC - .4byte _080196D6 - .4byte _080196D6 - .4byte _080196D6 - .4byte _080196D6 - .4byte _080196D6 - .4byte _080196D6 - .4byte _080196D6 - .4byte _080196D6 - .4byte _080196D6 - .4byte _080196D6 - .4byte _080196D6 - .4byte _080196D6 - .4byte _080196D6 - .4byte _080196D6 - .4byte _080196D6 - .4byte _080196D6 - .4byte _080196D6 - .4byte _080196D6 - .4byte _080196D6 - .4byte _08019680 - .4byte _08019650 - .4byte _080196D6 - .4byte _080196D6 - .4byte _080196D6 - .4byte _080196D6 - .4byte _080196D6 - .4byte _080196D6 - .4byte _080196D6 - .4byte _080196D6 - .4byte _080196D6 - .4byte _080196D6 - .4byte _080196D6 - .4byte _080196D6 - .4byte _080196D6 - .4byte _080196D6 - .4byte _080196D6 - .4byte _080196D6 - .4byte _080196D6 - .4byte _080196D6 - .4byte _080196D6 - .4byte _080196D6 - .4byte _080196D6 - .4byte _080196D6 - .4byte _080196D6 - .4byte _080196D6 - .4byte _080196D6 - .4byte _080196D6 - .4byte _080196D6 - .4byte _080196D6 - .4byte _080196D6 - .4byte _080196D6 - .4byte _08019614 -_08019590: - movs r0, 0x58 - mov r3, r10 - muls r3, r0 - adds r0, r3, 0 - adds r1, r2, 0 - adds r1, 0x4C - adds r0, r1 - ldr r0, [r0] - ldr r1, _080195B0 @ =0x00000f88 - ands r0, r1 - cmp r0, 0 - bne _080195AA - b _080196D6 -_080195AA: - ldr r0, _080195B4 @ =gBattleTextBuff1 - ldr r1, _080195B8 @ =gStatusConditionString_PoisonJpn - b _0801969C - .align 2, 0 -_080195B0: .4byte 0x00000f88 -_080195B4: .4byte gBattleTextBuff1 -_080195B8: .4byte gStatusConditionString_PoisonJpn -_080195BC: - movs r0, 0x58 - mov r1, r10 - muls r1, r0 - adds r0, r1, 0 - adds r1, r2, 0 - adds r1, 0x50 - adds r0, r1 - ldr r0, [r0] - movs r1, 0x7 - ands r0, r1 - cmp r0, 0 - bne _080195D6 - b _080196D6 -_080195D6: - ldr r0, _080195E4 @ =gBattleTextBuff1 - ldr r1, _080195E8 @ =gStatusConditionString_ConfusionJpn - bl StringCopy - movs r2, 0x2 - mov r9, r2 - b _080196DC - .align 2, 0 -_080195E4: .4byte gBattleTextBuff1 -_080195E8: .4byte gStatusConditionString_ConfusionJpn -_080195EC: - movs r0, 0x58 - mov r3, r10 - muls r3, r0 - adds r0, r3, 0 - adds r1, r2, 0 - adds r1, 0x4C - adds r0, r1 - ldr r0, [r0] - movs r1, 0x40 - ands r0, r1 - cmp r0, 0 - beq _080196D6 - ldr r0, _0801960C @ =gBattleTextBuff1 - ldr r1, _08019610 @ =gStatusConditionString_ParalysisJpn - b _0801969C - .align 2, 0 -_0801960C: .4byte gBattleTextBuff1 -_08019610: .4byte gStatusConditionString_ParalysisJpn -_08019614: - movs r0, 0x58 - mov r3, r10 - muls r3, r0 - adds r0, r2, 0 - adds r0, 0x4C - adds r0, r3, r0 - ldr r0, [r0] - movs r1, 0x7 - ands r0, r1 - cmp r0, 0 - beq _080196D6 - adds r2, 0x50 - adds r2, r3, r2 - ldr r0, [r2] - ldr r1, _08019644 @ =0xf7ffffff - ands r0, r1 - str r0, [r2] - ldr r0, _08019648 @ =gBattleTextBuff1 - ldr r1, _0801964C @ =gStatusConditionString_SleepJpn - bl StringCopy - movs r0, 0x1 - mov r9, r0 - b _080196DC - .align 2, 0 -_08019644: .4byte 0xf7ffffff -_08019648: .4byte gBattleTextBuff1 -_0801964C: .4byte gStatusConditionString_SleepJpn -_08019650: - movs r0, 0x58 - mov r1, r10 - muls r1, r0 - adds r0, r1, 0 - adds r1, r2, 0 - adds r1, 0x4C - adds r0, r1 - ldr r0, [r0] - movs r1, 0x10 - ands r0, r1 - cmp r0, 0 - beq _080196D6 - ldr r0, _08019678 @ =gBattleTextBuff1 - ldr r1, _0801967C @ =gStatusConditionString_BurnJpn - bl StringCopy - movs r2, 0x1 - mov r9, r2 - b _080196DC - .align 2, 0 -_08019678: .4byte gBattleTextBuff1 -_0801967C: .4byte gStatusConditionString_BurnJpn -_08019680: - movs r0, 0x58 - mov r3, r10 - muls r3, r0 - adds r0, r3, 0 - adds r1, r2, 0 - adds r1, 0x4C - adds r0, r1 - ldr r0, [r0] - movs r1, 0x20 - ands r0, r1 - cmp r0, 0 - beq _080196D6 - ldr r0, _080196A8 @ =gBattleTextBuff1 - ldr r1, _080196AC @ =gStatusConditionString_IceJpn -_0801969C: - bl StringCopy - movs r5, 0x1 - mov r9, r5 - b _080196DC - .align 2, 0 -_080196A8: .4byte gBattleTextBuff1 -_080196AC: .4byte gStatusConditionString_IceJpn -_080196B0: - movs r0, 0x58 - mov r1, r10 - muls r1, r0 - adds r0, r1, 0 - adds r1, r2, 0 - adds r1, 0x50 - adds r0, r1 - ldr r0, [r0] - movs r1, 0xF0 - lsls r1, 12 - ands r0, r1 - cmp r0, 0 - beq _080196D6 - ldr r0, _080196EC @ =gBattleTextBuff1 - ldr r1, _080196F0 @ =gStatusConditionString_LoveJpn - bl StringCopy - movs r2, 0x3 - mov r9, r2 -_080196D6: - mov r3, r9 - cmp r3, 0 - beq _08019798 -_080196DC: - mov r5, r9 - cmp r5, 0x2 - beq _08019710 - cmp r5, 0x2 - bgt _080196F4 - cmp r5, 0x1 - beq _080196FC - b _0801973C - .align 2, 0 -_080196EC: .4byte gBattleTextBuff1 -_080196F0: .4byte gStatusConditionString_LoveJpn -_080196F4: - mov r0, r9 - cmp r0, 0x3 - beq _08019728 - b _0801973C -_080196FC: - ldr r1, _0801970C @ =gBattleMons - movs r0, 0x58 - mov r2, r10 - muls r2, r0 - adds r1, 0x4C - adds r2, r1 - movs r0, 0 - b _0801973A - .align 2, 0 -_0801970C: .4byte gBattleMons -_08019710: - ldr r1, _08019724 @ =gBattleMons - movs r0, 0x58 - mov r2, r10 - muls r2, r0 - adds r1, 0x50 - adds r2, r1 - ldr r0, [r2] - movs r1, 0x8 - negs r1, r1 - b _08019738 - .align 2, 0 -_08019724: .4byte gBattleMons -_08019728: - ldr r1, _08019778 @ =gBattleMons - movs r0, 0x58 - mov r2, r10 - muls r2, r0 - adds r1, 0x50 - adds r2, r1 - ldr r0, [r2] - ldr r1, _0801977C @ =0xfff0ffff -_08019738: - ands r0, r1 -_0801973A: - str r0, [r2] -_0801973C: - bl b_movescr_stack_push_cursor - ldr r1, _08019780 @ =gBattlescriptCurrInstr - ldr r0, _08019784 @ =gUnknown_081D9956 - str r0, [r1] - ldr r0, _08019788 @ =0x02000000 - ldr r1, _0801978C @ =0x00016003 - adds r0, r1 - mov r2, r10 - strb r2, [r0] - ldr r4, _08019790 @ =gActiveBank - strb r2, [r4] - ldrb r1, [r4] - movs r0, 0x58 - muls r0, r1 - ldr r1, _08019794 @ =gUnknown_02024ACC - adds r0, r1 - str r0, [sp] - movs r0, 0 - movs r1, 0x28 - movs r2, 0 - movs r3, 0x4 - bl EmitSetAttributes - ldrb r0, [r4] - bl MarkBufferBankForExecution - bl _08019F92 - .align 2, 0 -_08019778: .4byte gBattleMons -_0801977C: .4byte 0xfff0ffff -_08019780: .4byte gBattlescriptCurrInstr -_08019784: .4byte gUnknown_081D9956 -_08019788: .4byte 0x02000000 -_0801978C: .4byte 0x00016003 -_08019790: .4byte gActiveBank -_08019794: .4byte gUnknown_02024ACC -_08019798: - mov r0, r10 - adds r0, 0x1 - lsls r0, 24 - lsrs r0, 24 - mov r10, r0 - ldr r0, _080197B0 @ =gNoOfAllBanks - ldrb r0, [r0] - cmp r10, r0 - bcs _080197AC - b _08019458 -_080197AC: - bl _08019F76 - .align 2, 0 -_080197B0: .4byte gNoOfAllBanks -_080197B4: - movs r3, 0 - mov r10, r3 - ldr r0, _080197FC @ =gNoOfAllBanks - ldrb r0, [r0] - cmp r10, r0 - bcc _080197C2 - b _08019F76 -_080197C2: - ldr r4, _08019800 @ =gBattleMons -_080197C4: - movs r0, 0x58 - mov r5, r10 - muls r5, r0 - adds r0, r5, 0 - adds r0, r4 - adds r0, 0x20 - ldrb r0, [r0] - cmp r0, 0x3B - bne _080197E8 - mov r0, r10 - bl castform_switch - lsls r0, 24 - lsrs r0, 24 - mov r9, r0 - cmp r0, 0 - beq _080197E8 - b _08019E40 -_080197E8: - mov r0, r10 - adds r0, 0x1 - lsls r0, 24 - lsrs r0, 24 - mov r10, r0 - ldr r0, _080197FC @ =gNoOfAllBanks - ldrb r0, [r0] - cmp r10, r0 - bcc _080197C4 - b _08019F76 - .align 2, 0 -_080197FC: .4byte gNoOfAllBanks -_08019800: .4byte gBattleMons -_08019804: - mov r1, r8 - ldrb r0, [r1] - cmp r0, 0x1C - beq _0801980E - b _08019F76 -_0801980E: - ldr r4, _08019860 @ =gHitMarker - ldr r1, [r4] - movs r0, 0x80 - lsls r0, 7 - ands r0, r1 - cmp r0, 0 - bne _0801981E - b _08019F76 -_0801981E: - ldr r0, _08019864 @ =0xffffbfff - ands r1, r0 - str r1, [r4] - ldr r3, _08019868 @ =0x000160ca - adds r2, r7, r3 - ldrb r1, [r2] - movs r0, 0x3F - ands r0, r1 - strb r0, [r2] - cmp r0, 0x6 - bne _08019838 - movs r0, 0x2 - strb r0, [r2] -_08019838: - ldr r1, _0801986C @ =gBattleCommunication - ldrb r0, [r2] - adds r0, 0x40 - strb r0, [r1, 0x3] - ldr r0, _08019870 @ =gBankTarget - ldrb r1, [r0] - ldr r5, _08019874 @ =0x00016003 - adds r0, r7, r5 - strb r1, [r0] - bl b_movescr_stack_push_cursor - ldr r1, _08019878 @ =gBattlescriptCurrInstr - ldr r0, _0801987C @ =gUnknown_081D9953 - str r0, [r1] - ldr r0, [r4] - movs r1, 0x80 - lsls r1, 6 - orrs r0, r1 - str r0, [r4] - b _08019F22 - .align 2, 0 -_08019860: .4byte gHitMarker -_08019864: .4byte 0xffffbfff -_08019868: .4byte 0x000160ca -_0801986C: .4byte gBattleCommunication -_08019870: .4byte gBankTarget -_08019874: .4byte 0x00016003 -_08019878: .4byte gBattlescriptCurrInstr -_0801987C: .4byte gUnknown_081D9953 -_08019880: - mov r1, r8 - ldrb r0, [r1] - cmp r0, 0x1C - beq _0801988A - b _08019F76 -_0801988A: - ldr r4, _080198DC @ =gHitMarker - ldr r1, [r4] - movs r0, 0x80 - lsls r0, 7 - ands r0, r1 - cmp r0, 0 - bne _0801989A - b _08019F76 -_0801989A: - ldr r0, _080198E0 @ =0xffffbfff - ands r1, r0 - str r1, [r4] - ldr r3, _080198E4 @ =0x000160ca - adds r2, r7, r3 - ldrb r1, [r2] - movs r0, 0x3F - ands r0, r1 - strb r0, [r2] - cmp r0, 0x6 - bne _080198B4 - movs r0, 0x2 - strb r0, [r2] -_080198B4: - ldr r1, _080198E8 @ =gBattleCommunication - ldrb r0, [r2] - strb r0, [r1, 0x3] - ldr r0, _080198EC @ =gBankAttacker - ldrb r1, [r0] - ldr r5, _080198F0 @ =0x00016003 - adds r0, r7, r5 - strb r1, [r0] - bl b_movescr_stack_push_cursor - ldr r1, _080198F4 @ =gBattlescriptCurrInstr - ldr r0, _080198F8 @ =gUnknown_081D9953 - str r0, [r1] - ldr r0, [r4] - movs r1, 0x80 - lsls r1, 6 - orrs r0, r1 - str r0, [r4] - b _08019F22 - .align 2, 0 -_080198DC: .4byte gHitMarker -_080198E0: .4byte 0xffffbfff -_080198E4: .4byte 0x000160ca -_080198E8: .4byte gBattleCommunication -_080198EC: .4byte gBankAttacker -_080198F0: .4byte 0x00016003 -_080198F4: .4byte gBattlescriptCurrInstr -_080198F8: .4byte gUnknown_081D9953 -_080198FC: - movs r4, 0 - ldr r0, _08019934 @ =gNoOfAllBanks - ldrb r1, [r0] - cmp r4, r1 - blt _08019908 - b _08019F76 -_08019908: - ldr r0, _08019938 @ =gBattleMons - adds r5, r1, 0 - ldr r2, _0801993C @ =gStatuses3 - adds r3, r0, 0 - adds r3, 0x20 - movs r6, 0x80 - lsls r6, 12 -_08019916: - ldrb r1, [r3] - cmp r1, 0x16 - bne _08019926 - ldr r0, [r2] - ands r0, r6 - cmp r0, 0 - beq _08019926 - b _08019E6C -_08019926: - adds r2, 0x4 - adds r3, 0x58 - adds r4, 0x1 - cmp r4, r5 - blt _08019916 - b _08019F76 - .align 2, 0 -_08019934: .4byte gNoOfAllBanks -_08019938: .4byte gBattleMons -_0801993C: .4byte gStatuses3 -_08019940: - movs r4, 0 - ldr r0, _08019A1C @ =gNoOfAllBanks - ldrb r0, [r0] - cmp r4, r0 - blt _0801994C - b _08019F76 -_0801994C: - ldr r0, _08019A20 @ =gActiveBank - mov r8, r0 - ldr r1, _08019A24 @ =gBattleMons - adds r1, 0x20 - str r1, [sp, 0x1C] - movs r2, 0 - str r2, [sp, 0x20] -_0801995A: - ldr r3, [sp, 0x1C] - ldrb r0, [r3] - cmp r0, 0x24 - beq _08019964 - b _08019AF6 -_08019964: - ldr r0, _08019A28 @ =gStatuses3 - ldr r5, [sp, 0x20] - adds r0, r5, r0 - ldr r1, [r0] - movs r0, 0x80 - lsls r0, 13 - ands r1, r0 - str r5, [sp, 0x18] - cmp r1, 0 - bne _0801997A - b _08019AF6 -_0801997A: - lsls r0, r4, 24 - lsrs r0, 24 - bl GetBankIdentity - movs r1, 0x1 - adds r5, r0, 0 - eors r5, r1 - ands r5, r1 - adds r0, r5, 0 - bl GetBankByPlayerAI - lsls r0, 24 - lsrs r6, r0, 24 - adds r0, r5, 0x2 - bl GetBankByPlayerAI - lsls r0, 24 - lsrs r7, r0, 24 - ldr r0, _08019A2C @ =gBattleTypeFlags - ldrh r1, [r0] - movs r2, 0x1 - adds r0, r2, 0 - ands r0, r1 - cmp r0, 0 - bne _080199AE - b _08019ABC -_080199AE: - movs r1, 0x58 - adds r0, r6, 0 - muls r0, r1 - ldr r3, _08019A24 @ =gBattleMons - adds r1, r0, r3 - adds r0, r1, 0 - adds r0, 0x20 - ldrb r0, [r0] - cmp r0, 0 - beq _08019A78 - ldrh r0, [r1, 0x28] - cmp r0, 0 - beq _08019A34 - movs r1, 0x58 - adds r0, r7, 0 - muls r0, r1 - adds r1, r0, r3 - adds r0, r1, 0 - adds r0, 0x20 - ldrb r0, [r0] - cmp r0, 0 - beq _08019A34 - ldrh r0, [r1, 0x28] - cmp r0, 0 - beq _08019A34 - str r2, [sp, 0x24] - bl Random - ldr r2, [sp, 0x24] - adds r1, r2, 0 - ands r1, r0 - lsls r1, 1 - orrs r5, r1 - adds r0, r5, 0 - bl GetBankByPlayerAI - mov r2, r8 - strb r0, [r2] - ldrb r0, [r2] - movs r3, 0x58 - muls r0, r3 - ldr r5, _08019A24 @ =gBattleMons - adds r0, r5 - adds r0, 0x20 - ldrb r0, [r0] - ldr r1, [sp, 0x1C] - strb r0, [r1] - ldrb r0, [r2] - muls r0, r3 - adds r0, r5 - adds r0, 0x20 - ldrb r0, [r0] - ldr r2, _08019A30 @ =gLastUsedAbility - strb r0, [r2] - b _08019AE4 - .align 2, 0 -_08019A1C: .4byte gNoOfAllBanks -_08019A20: .4byte gActiveBank -_08019A24: .4byte gBattleMons -_08019A28: .4byte gStatuses3 -_08019A2C: .4byte gBattleTypeFlags -_08019A30: .4byte gLastUsedAbility -_08019A34: - ldr r3, _08019A74 @ =gBattleMons - movs r2, 0x58 - adds r0, r6, 0 - muls r0, r2 - adds r1, r0, r3 - adds r0, r1, 0 - adds r0, 0x20 - ldrb r0, [r0] - cmp r0, 0 - beq _08019A78 - ldrh r0, [r1, 0x28] - cmp r0, 0 - beq _08019A78 - mov r5, r8 - strb r6, [r5] - adds r1, r4, 0 - muls r1, r2 - adds r1, r3 - ldrb r0, [r5] - muls r0, r2 - adds r0, r3 - adds r0, 0x20 - ldrb r0, [r0] - adds r1, 0x20 - strb r0, [r1] - ldrb r0, [r5] - muls r0, r2 - adds r0, r3 - adds r0, 0x20 - ldrb r0, [r0] - b _08019AE0 - .align 2, 0 -_08019A74: .4byte gBattleMons -_08019A78: - ldr r3, _08019AB8 @ =gBattleMons - movs r2, 0x58 - adds r0, r7, 0 - muls r0, r2 - adds r1, r0, r3 - adds r0, r1, 0 - adds r0, 0x20 - ldrb r0, [r0] - cmp r0, 0 - beq _08019AEE - ldrh r0, [r1, 0x28] - cmp r0, 0 - beq _08019AEE - mov r5, r8 - strb r7, [r5] - adds r1, r4, 0 - muls r1, r2 - adds r1, r3 - ldrb r0, [r5] - muls r0, r2 - adds r0, r3 - adds r0, 0x20 - ldrb r0, [r0] - adds r1, 0x20 - strb r0, [r1] - ldrb r0, [r5] - muls r0, r2 - adds r0, r3 - adds r0, 0x20 - ldrb r0, [r0] - b _08019AE0 - .align 2, 0 -_08019AB8: .4byte gBattleMons -_08019ABC: - mov r2, r8 - strb r6, [r2] - movs r3, 0x58 - adds r0, r6, 0 - muls r0, r3 - ldr r5, _08019B10 @ =gBattleMons - adds r0, r5 - adds r2, r0, 0 - adds r2, 0x20 - ldrb r1, [r2] - cmp r1, 0 - beq _08019AEE - ldrh r0, [r0, 0x28] - cmp r0, 0 - beq _08019AEE - ldr r0, [sp, 0x1C] - strb r1, [r0] - ldrb r0, [r2] -_08019AE0: - ldr r1, _08019B14 @ =gLastUsedAbility - strb r0, [r1] -_08019AE4: - mov r0, r9 - adds r0, 0x1 - lsls r0, 24 - lsrs r0, 24 - mov r9, r0 -_08019AEE: - mov r2, r9 - cmp r2, 0 - beq _08019AF6 - b _08019E88 -_08019AF6: - ldr r3, [sp, 0x1C] - adds r3, 0x58 - str r3, [sp, 0x1C] - ldr r5, [sp, 0x20] - adds r5, 0x4 - str r5, [sp, 0x20] - adds r4, 0x1 - ldr r0, _08019B18 @ =gNoOfAllBanks - ldrb r0, [r0] - cmp r4, r0 - bge _08019B0E - b _0801995A -_08019B0E: - b _08019F76 - .align 2, 0 -_08019B10: .4byte gBattleMons -_08019B14: .4byte gLastUsedAbility -_08019B18: .4byte gNoOfAllBanks -_08019B1C: - movs r4, 0 - ldr r0, _08019B54 @ =gNoOfAllBanks - ldrb r1, [r0] - cmp r4, r1 - blt _08019B28 - b _08019F76 -_08019B28: - ldr r0, _08019B58 @ =gBattleMons - adds r5, r1, 0 - ldr r2, _08019B5C @ =gStatuses3 - adds r3, r0, 0 - adds r3, 0x20 - movs r6, 0x80 - lsls r6, 12 -_08019B36: - ldrb r1, [r3] - cmp r1, 0x16 - bne _08019B46 - ldr r0, [r2] - ands r0, r6 - cmp r0, 0 - beq _08019B46 - b _08019F04 -_08019B46: - adds r2, 0x4 - adds r3, 0x58 - adds r4, 0x1 - cmp r4, r5 - blt _08019B36 - b _08019F76 - .align 2, 0 -_08019B54: .4byte gNoOfAllBanks -_08019B58: .4byte gBattleMons -_08019B5C: .4byte gStatuses3 -_08019B60: - mov r0, r10 - bl GetBankSide - lsls r0, 24 - lsrs r5, r0, 24 - movs r4, 0 - ldr r0, _08019BB0 @ =gNoOfAllBanks - ldrb r0, [r0] - cmp r4, r0 - blt _08019B76 - b _08019F76 -_08019B76: - ldr r7, _08019BB4 @ =gBattleMons -_08019B78: - lsls r0, r4, 24 - lsrs r0, 24 - bl GetBankSide - lsls r0, 24 - lsrs r0, 24 - adds r3, r4, 0x1 - cmp r0, r5 - beq _08019BA2 - movs r0, 0x58 - muls r0, r4 - adds r0, r7 - adds r0, 0x20 - ldrb r0, [r0] - cmp r0, r6 - bne _08019BA2 - ldr r0, _08019BB8 @ =gLastUsedAbility - strb r6, [r0] - lsls r0, r3, 24 - lsrs r0, 24 - mov r9, r0 -_08019BA2: - adds r4, r3, 0 - ldr r0, _08019BB0 @ =gNoOfAllBanks - ldrb r0, [r0] - cmp r4, r0 - blt _08019B78 - b _08019F76 - .align 2, 0 -_08019BB0: .4byte gNoOfAllBanks -_08019BB4: .4byte gBattleMons -_08019BB8: .4byte gLastUsedAbility -_08019BBC: - mov r0, r10 - bl GetBankSide - lsls r0, 24 - lsrs r5, r0, 24 - movs r4, 0 - ldr r0, _08019C0C @ =gNoOfAllBanks - ldrb r0, [r0] - cmp r4, r0 - blt _08019BD2 - b _08019F76 -_08019BD2: - ldr r7, _08019C10 @ =gBattleMons -_08019BD4: - lsls r0, r4, 24 - lsrs r0, 24 - bl GetBankSide - lsls r0, 24 - lsrs r0, 24 - adds r3, r4, 0x1 - cmp r0, r5 - bne _08019BFE - movs r0, 0x58 - muls r0, r4 - adds r0, r7 - adds r0, 0x20 - ldrb r0, [r0] - cmp r0, r6 - bne _08019BFE - ldr r0, _08019C14 @ =gLastUsedAbility - strb r6, [r0] - lsls r0, r3, 24 - lsrs r0, 24 - mov r9, r0 -_08019BFE: - adds r4, r3, 0 - ldr r0, _08019C0C @ =gNoOfAllBanks - ldrb r0, [r0] - cmp r4, r0 - blt _08019BD4 - b _08019F76 - .align 2, 0 -_08019C0C: .4byte gNoOfAllBanks -_08019C10: .4byte gBattleMons -_08019C14: .4byte gLastUsedAbility -_08019C18: - mov r1, r8 - ldrb r0, [r1] - cmp r0, 0xFD - beq _08019C40 - cmp r0, 0xFE - beq _08019C78 - movs r4, 0 - ldr r0, _08019C38 @ =gNoOfAllBanks - adds r5, r0, 0 - ldrb r2, [r5] - cmp r4, r2 - blt _08019C32 - b _08019F76 -_08019C32: - ldr r2, _08019C3C @ =gBattleMons - b _08019CB0 - .align 2, 0 -_08019C38: .4byte gNoOfAllBanks -_08019C3C: .4byte gBattleMons -_08019C40: - movs r4, 0 - ldr r0, _08019C70 @ =gNoOfAllBanks - ldrb r0, [r0] - cmp r4, r0 - blt _08019C4C - b _08019F76 -_08019C4C: - ldr r5, _08019C74 @ =gStatuses3 - movs r2, 0x80 - lsls r2, 9 - adds r1, r0, 0 -_08019C54: - lsls r0, r4, 2 - adds r0, r5 - ldr r0, [r0] - ands r0, r2 - adds r3, r4, 0x1 - cmp r0, 0 - beq _08019C68 - lsls r0, r3, 24 - lsrs r0, 24 - mov r9, r0 -_08019C68: - adds r4, r3, 0 - cmp r4, r1 - blt _08019C54 - b _08019F76 - .align 2, 0 -_08019C70: .4byte gNoOfAllBanks -_08019C74: .4byte gStatuses3 -_08019C78: - movs r4, 0 - ldr r0, _08019CA8 @ =gNoOfAllBanks - ldrb r0, [r0] - cmp r4, r0 - blt _08019C84 - b _08019F76 -_08019C84: - ldr r5, _08019CAC @ =gStatuses3 - movs r2, 0x80 - lsls r2, 10 - adds r1, r0, 0 -_08019C8C: - lsls r0, r4, 2 - adds r0, r5 - ldr r0, [r0] - ands r0, r2 - adds r3, r4, 0x1 - cmp r0, 0 - beq _08019CA0 - lsls r0, r3, 24 - lsrs r0, 24 - mov r9, r0 -_08019CA0: - adds r4, r3, 0 - cmp r4, r1 - blt _08019C8C - b _08019F76 - .align 2, 0 -_08019CA8: .4byte gNoOfAllBanks -_08019CAC: .4byte gStatuses3 -_08019CB0: - movs r0, 0x58 - muls r0, r4 - adds r0, r2 - adds r0, 0x20 - ldrb r0, [r0] - adds r3, r4, 0x1 - cmp r0, r6 - bne _08019CCA - mov r0, r8 - strb r6, [r0] - lsls r0, r3, 24 - lsrs r0, 24 - mov r9, r0 -_08019CCA: - adds r4, r3, 0 - ldrb r1, [r5] - cmp r4, r1 - blt _08019CB0 - b _08019F76 -_08019CD4: - movs r4, 0 - ldr r0, _08019D10 @ =gNoOfAllBanks - ldrb r0, [r0] - cmp r4, r0 - blt _08019CE0 - b _08019F76 -_08019CE0: - ldr r7, _08019D14 @ =gBattleMons - adds r2, r0, 0 - movs r5, 0x58 -_08019CE6: - adds r0, r4, 0 - muls r0, r5 - adds r1, r0, r7 - adds r0, r1, 0 - adds r0, 0x20 - ldrb r0, [r0] - adds r3, r4, 0x1 - cmp r0, r6 - bne _08019D08 - ldrh r0, [r1, 0x28] - cmp r0, 0 - beq _08019D08 - mov r0, r8 - strb r6, [r0] - lsls r0, r3, 24 - lsrs r0, 24 - mov r9, r0 -_08019D08: - adds r4, r3, 0 - cmp r4, r2 - blt _08019CE6 - b _08019F76 - .align 2, 0 -_08019D10: .4byte gNoOfAllBanks -_08019D14: .4byte gBattleMons -_08019D18: - movs r4, 0 - ldr r0, _08019D50 @ =gNoOfAllBanks - ldrb r0, [r0] - cmp r4, r0 - blt _08019D24 - b _08019F76 -_08019D24: - ldr r7, _08019D54 @ =gBattleMons - adds r1, r0, 0 - movs r5, 0x58 - ldr r2, _08019D58 @ =gLastUsedAbility -_08019D2C: - adds r0, r4, 0 - muls r0, r5 - adds r0, r7 - adds r0, 0x20 - ldrb r0, [r0] - adds r3, r4, 0x1 - cmp r0, r6 - bne _08019D48 - cmp r4, r10 - beq _08019D48 - strb r6, [r2] - lsls r0, r3, 24 - lsrs r0, 24 - mov r9, r0 -_08019D48: - adds r4, r3, 0 - cmp r4, r1 - blt _08019D2C - b _08019F76 - .align 2, 0 -_08019D50: .4byte gNoOfAllBanks -_08019D54: .4byte gBattleMons -_08019D58: .4byte gLastUsedAbility -_08019D5C: - mov r0, r10 - bl GetBankSide - lsls r0, 24 - lsrs r5, r0, 24 - movs r4, 0 - ldr r0, _08019DAC @ =gNoOfAllBanks - ldrb r0, [r0] - cmp r4, r0 - blt _08019D72 - b _08019F76 -_08019D72: - ldr r7, _08019DB0 @ =gBattleMons -_08019D74: - lsls r0, r4, 24 - lsrs r0, 24 - bl GetBankSide - lsls r0, 24 - lsrs r0, 24 - cmp r0, r5 - beq _08019DA0 - movs r0, 0x58 - muls r0, r4 - adds r0, r7 - adds r0, 0x20 - ldrb r0, [r0] - cmp r0, r6 - bne _08019DA0 - ldr r0, _08019DB4 @ =gLastUsedAbility - strb r6, [r0] - mov r0, r9 - adds r0, 0x1 - lsls r0, 24 - lsrs r0, 24 - mov r9, r0 -_08019DA0: - adds r4, 0x1 - ldr r0, _08019DAC @ =gNoOfAllBanks - ldrb r0, [r0] - cmp r4, r0 - blt _08019D74 - b _08019F76 - .align 2, 0 -_08019DAC: .4byte gNoOfAllBanks -_08019DB0: .4byte gBattleMons -_08019DB4: .4byte gLastUsedAbility -_08019DB8: - mov r0, r10 - bl GetBankSide - lsls r0, 24 - lsrs r5, r0, 24 - movs r4, 0 - ldr r0, _08019E08 @ =gNoOfAllBanks - ldrb r0, [r0] - cmp r4, r0 - blt _08019DCE - b _08019F76 -_08019DCE: - ldr r7, _08019E0C @ =gBattleMons -_08019DD0: - lsls r0, r4, 24 - lsrs r0, 24 - bl GetBankSide - lsls r0, 24 - lsrs r0, 24 - cmp r0, r5 - bne _08019DFC - movs r0, 0x58 - muls r0, r4 - adds r0, r7 - adds r0, 0x20 - ldrb r0, [r0] - cmp r0, r6 - bne _08019DFC - ldr r0, _08019E10 @ =gLastUsedAbility - strb r6, [r0] - mov r0, r9 - adds r0, 0x1 - lsls r0, 24 - lsrs r0, 24 - mov r9, r0 -_08019DFC: - adds r4, 0x1 - ldr r0, _08019E08 @ =gNoOfAllBanks - ldrb r0, [r0] - cmp r4, r0 - blt _08019DD0 - b _08019F76 - .align 2, 0 -_08019E08: .4byte gNoOfAllBanks -_08019E0C: .4byte gBattleMons -_08019E10: .4byte gLastUsedAbility -_08019E14: - ldr r0, _08019E30 @ =gUnknown_081D977D - bl b_push_move_exec - ldr r0, _08019E34 @ =0x02000000 - ldr r2, _08019E38 @ =0x00016003 - adds r1, r0, r2 - strb r6, [r1] - mov r1, r9 - subs r1, 0x1 - ldr r3, _08019E3C @ =0x0001609b - adds r0, r3 - strb r1, [r0] - b _08019F76 - .align 2, 0 -_08019E30: .4byte gUnknown_081D977D -_08019E34: .4byte 0x02000000 -_08019E38: .4byte 0x00016003 -_08019E3C: .4byte 0x0001609b -_08019E40: - ldr r0, _08019E5C @ =gUnknown_081D977D - bl b_push_move_exec - ldr r0, _08019E60 @ =0x02000000 - ldr r5, _08019E64 @ =0x00016003 - adds r1, r0, r5 - mov r2, r10 - strb r2, [r1] - mov r1, r9 - subs r1, 0x1 - ldr r3, _08019E68 @ =0x0001609b - adds r0, r3 - strb r1, [r0] - b _08019F92 - .align 2, 0 -_08019E5C: .4byte gUnknown_081D977D -_08019E60: .4byte 0x02000000 -_08019E64: .4byte 0x00016003 -_08019E68: .4byte 0x0001609b -_08019E6C: - mov r5, r8 - strb r1, [r5] - ldr r0, [r2] - ldr r1, _08019E80 @ =0xfff7ffff - ands r0, r1 - str r0, [r2] - ldr r0, _08019E84 @ =gUnknown_081D978C - bl b_push_move_exec - b _08019F1A - .align 2, 0 -_08019E80: .4byte 0xfff7ffff -_08019E84: .4byte gUnknown_081D978C -_08019E88: - ldr r0, _08019EDC @ =gUnknown_081D9726 - bl b_push_move_exec - ldr r1, _08019EE0 @ =gStatuses3 - ldr r2, [sp, 0x18] - adds r1, r2, r1 - ldr r0, [r1] - ldr r2, _08019EE4 @ =0xffefffff - ands r0, r2 - str r0, [r1] - ldr r0, _08019EE8 @ =0x02000000 - ldr r3, _08019EEC @ =0x00016003 - adds r0, r3 - strb r4, [r0] - ldr r1, _08019EF0 @ =gBattleTextBuff1 - movs r4, 0xFD - strb r4, [r1] - movs r0, 0x4 - strb r0, [r1, 0x1] - ldr r2, _08019EF4 @ =gActiveBank - ldrb r0, [r2] - strb r0, [r1, 0x2] - ldr r3, _08019EF8 @ =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, _08019EFC @ =gBattleTextBuff2 - strb r4, [r1] - movs r0, 0x9 - strb r0, [r1, 0x1] - ldr r0, _08019F00 @ =gLastUsedAbility - ldrb r0, [r0] - strb r0, [r1, 0x2] - movs r0, 0x1 - negs r0, r0 - strb r0, [r1, 0x3] - b _08019F76 - .align 2, 0 -_08019EDC: .4byte gUnknown_081D9726 -_08019EE0: .4byte gStatuses3 -_08019EE4: .4byte 0xffefffff -_08019EE8: .4byte 0x02000000 -_08019EEC: .4byte 0x00016003 -_08019EF0: .4byte gBattleTextBuff1 -_08019EF4: .4byte gActiveBank -_08019EF8: .4byte gBattlePartyID -_08019EFC: .4byte gBattleTextBuff2 -_08019F00: .4byte gLastUsedAbility -_08019F04: - mov r5, r8 - strb r1, [r5] - ldr r0, [r2] - ldr r1, _08019F30 @ =0xfff7ffff - ands r0, r1 - str r0, [r2] - bl b_movescr_stack_push_cursor - ldr r1, _08019F34 @ =gBattlescriptCurrInstr - ldr r0, _08019F38 @ =gUnknown_081D9795 - str r0, [r1] -_08019F1A: - ldr r0, _08019F3C @ =0x02000000 - ldr r1, _08019F40 @ =0x000160dd - adds r0, r1 - strb r4, [r0] -_08019F22: - mov r0, r9 - adds r0, 0x1 - lsls r0, 24 - lsrs r0, 24 - mov r9, r0 - b _08019F76 - .align 2, 0 -_08019F30: .4byte 0xfff7ffff -_08019F34: .4byte gBattlescriptCurrInstr -_08019F38: .4byte gUnknown_081D9795 -_08019F3C: .4byte 0x02000000 -_08019F40: .4byte 0x000160dd -_08019F44: - movs r4, 0 - ldr r0, _08019FA4 @ =gNoOfAllBanks - ldrb r1, [r0] - cmp r4, r1 - bge _08019F76 - ldr r0, _08019FA8 @ =gBattleMons - adds r2, r1, 0 - adds r1, r0, 0 - adds r1, 0x20 - ldr r3, _08019FAC @ =gLastUsedAbility -_08019F58: - ldrb r0, [r1] - cmp r0, r6 - bne _08019F6E - cmp r4, r10 - beq _08019F6E - strb r6, [r3] - mov r0, r9 - adds r0, 0x1 - lsls r0, 24 - lsrs r0, 24 - mov r9, r0 -_08019F6E: - adds r1, 0x58 - adds r4, 0x1 - cmp r4, r2 - blt _08019F58 -_08019F76: - mov r2, r9 - cmp r2, 0 - beq _08019F92 -_08019F7C: - ldr r3, [sp, 0x4] - cmp r3, 0xB - bhi _08019F92 - ldr r1, _08019FAC @ =gLastUsedAbility - ldrb r0, [r1] - cmp r0, 0xFF - beq _08019F92 - adds r1, r0, 0 - mov r0, r10 - bl RecordAbilityBattle -_08019F92: - mov r0, r9 - add sp, 0x28 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r1} - bx r1 - .align 2, 0 -_08019FA4: .4byte gNoOfAllBanks -_08019FA8: .4byte gBattleMons -_08019FAC: .4byte gLastUsedAbility - thumb_func_end AbilityBattleEffects thumb_func_start b_call_bc_move_exec b_call_bc_move_exec: @ 8019FB0 diff --git a/include/battle.h b/include/battle.h index a7ea7c6da..44b7c048a 100644 --- a/include/battle.h +++ b/include/battle.h @@ -74,6 +74,8 @@ #define STATUS3_MUDSPORT 0x10000 #define STATUS3_WATERSPORT 0x20000 #define STATUS3_UNDERWATER 0x40000 +#define STATUS3_INTIMIDATE_POKES 0x80000 +#define STATUS3_TRACE 0x100000 #define STATUS3_SEMI_INVULNERABLE ((STATUS3_UNDERGROUND | STATUS3_ON_AIR | STATUS3_UNDERWATER)) @@ -108,18 +110,29 @@ #define SIDE_STATUS_MIST (1 << 8) #define SIDE_STATUS_SPIKES_DAMAGED (1 << 9) +#define ABILITYEFFECT_ON_SWITCHIN 0x0 #define ABILITYEFFECT_ENDTURN 0x1 +#define ABILITYEFFECT_MOVES_BLOCK 0x2 +#define ABILITYEFFECT_ABSORBING 0x3 #define ABILITYEFFECT_CONTACT 0x4 #define ABILITYEFFECT_IMMUNITY 0x5 +#define ABILITYEFFECT_FORECAST 0x6 #define ABILITYEFFECT_SYNCHRONIZE 0x7 #define ABILITYEFFECT_ATK_SYNCHRONIZE 0x8 +#define ABILITYEFFECT_INTIMIDATE1 0x9 +#define ABILITYEFFECT_INTIMIDATE2 0xA +#define ABILITYEFFECT_TRACE 0xB #define ABILITYEFFECT_CHECK_OTHER_SIDE 0xC #define ABILITYEFFECT_CHECK_BANK_SIDE 0xD +#define ABILITYEFFECT_FIELD_SPORT 0xE +#define ABILITYEFFECT_CHECK_FIELD_EXCEPT_BANK 0xF #define ABILITYEFFECT_COUNT_OTHER_SIZE 0x10 #define ABILITYEFFECT_COUNT_BANK_SIDE 0x11 #define ABILITYEFFECT_COUNT_ON_FIELD 0x12 #define ABILITYEFFECT_CHECK_ON_FIELD 0x13 +#define WEATHER_HAS_EFFECT ((!AbilityBattleEffects(ABILITYEFFECT_CHECK_ON_FIELD, 0, ABILITY_CLOUD_NINE, 0, 0) && !AbilityBattleEffects(ABILITYEFFECT_CHECK_ON_FIELD, 0, ABILITY_AIR_LOCK, 0, 0))) + #define MOVESTATUS_MISSED (1 << 0) #define MOVESTATUS_SUPEREFFECTIVE (1 << 1) #define MOVESTATUS_NOTVERYEFFECTIVE (1 << 2) @@ -361,7 +374,7 @@ struct BattleStruct /* 0x2000000 */ /*0x160DA*/ u8 unk160DA; /*0x160DB*/ u8 unk160DB; /*0x160DC*/ u8 unk160DC; - /*0x160DD*/ u8 unk160DD; + /*0x160DD*/ u8 intimidateBank; /*0x160DE*/ u8 unk160DE; /*0x160DF*/ u8 unk160DF; /*0x160E0*/ u8 unk160E0; @@ -644,6 +657,7 @@ extern u8 ewram[]; #define ewram17800 ((struct Struct2017800 *) (ewram + 0x17800)) #define ewram17810 ((struct Struct2017810 *) (ewram + 0x17810)) #define ewram17840 (*(struct Struct2017840 *) (ewram + 0x17840)) +#define ewram17000 ((u32 *) (ewram + 0x17100)) struct funcStack { @@ -767,7 +781,7 @@ void sub_80157C4(u8 index); // asm/battle_3.o u8 CheckMoveLimitations(u8 bank, u8 unusableMoves, u8 check); u8 UpdateTurnCounters(void); -u8 TurnBasedEffects(); +u8 TurnBasedEffects(void); u8 sub_80170DC(); u8 sub_80173A4(); u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 move); diff --git a/include/pokemon.h b/include/pokemon.h index be6ccfe74..242d62029 100644 --- a/include/pokemon.h +++ b/include/pokemon.h @@ -408,6 +408,7 @@ struct BattleMove u8 pad[3]; }; +#define FLAG_MAKES_CONTACT 0x1 #define FLAG_PROTECT_AFFECTED 0x2 #define FLAG_MAGICCOAT_AFFECTED 0x4 #define FLAG_SNATCH_AFFECTED 0x8 diff --git a/src/battle_3.c b/src/battle_3.c index cb0812034..d08e760a6 100644 --- a/src/battle_3.c +++ b/src/battle_3.c @@ -11,6 +11,7 @@ #include "rng.h" #include "text.h" #include "battle_move_effects.h" +#include "string_util.h" extern u8* gBattlescriptCurrInstr; extern u8 gActiveBank; @@ -43,6 +44,8 @@ extern u16 gChosenMovesByBanks[4]; extern s32 gTakenDmg[4]; extern u8 gTakenDmgBanks[4]; extern u8 gBattleMoveFlags; +extern u8 gLastUsedAbility; +extern u8 gBattleTextBuff2[]; u8 IsImprisoned(u8 bank, u16 move); u8 GetBankByPlayerAI(u8 ID); @@ -57,6 +60,11 @@ void sub_8015740(u8 bank); s32 CalculateBaseDamage(struct BattlePokemon *attacker, struct BattlePokemon *defender, u32 move, u16 a4, u16 powerOverride, u8 typeOverride, u8 bank_atk, u8 bank_def); u8 CountTrailingZeroBits(u32 a); u8 sub_801B5C0(u16 move, u8 targetbyte); //get target of move +u8 sub_803FC34(u8 bank); +u16 sub_803FBFC(u8 a); +u8 weather_get_current(void); +void b_push_move_exec(u8* BS_ptr); +void RecordAbilityBattle(u8 bank, u8 ability); extern u8 BattleScript_MoveSelectionDisabledMove[]; extern u8 BattleScript_MoveSelectionTormented[]; @@ -113,6 +121,8 @@ extern u8 gUnknown_081D90A7[]; //bide storing energy extern u8 gUnknown_081D90B2[]; //bide attack extern u8 gUnknown_081D90F1[]; //bide no energy to attack + + #define CHOICED_MOVE(bank)(((u16*)(&ewram[bank * 2 + 0x160e8]))) //array entries for battle communication @@ -982,7 +992,7 @@ void b_clear_atk_up_if_hit_flag_unless_enraged(void) } #define ATKCANCELLER_MAX_CASE 14 -/* + u8 AtkCanceller_UnableToUseMove(void) { u8 effect = 0; @@ -1049,7 +1059,11 @@ u8 AtkCanceller_UnableToUseMove(void) { gBattlescriptCurrInstr = gUnknown_081D9545; gHitMarker |= HITMARKER_NO_ATTACKSTRING; - effect = 2; + } + else + { + BATTLE_STRUCT->atkCancellerTracker++; + break; } } else // unfreeze @@ -1058,8 +1072,8 @@ u8 AtkCanceller_UnableToUseMove(void) b_movescr_stack_push_cursor(); gBattlescriptCurrInstr = gUnknown_081D9552; gBattleCommunication[MULTISTRING_CHOOSER] = 0; - effect = 2; } + effect = 2; } BATTLE_STRUCT->atkCancellerTracker++; break; @@ -1177,7 +1191,7 @@ u8 AtkCanceller_UnableToUseMove(void) case 11: // infatuation if (gBattleMons[gBankAttacker].status2 & STATUS2_INFATUATION) { - BATTLE_STRUCT->scriptingActive = CountTrailingZeroBits(gBattleMons[gBankAttacker].status2 >> 0x10); + BATTLE_STRUCT->scriptingActive = CountTrailingZeroBits((gBattleMons[gBankAttacker].status2 & STATUS2_INFATUATION) >> 0x10); if (Random() & 1) b_movescr_stack_push_cursor(); else @@ -1200,7 +1214,7 @@ u8 AtkCanceller_UnableToUseMove(void) gBattlescriptCurrInstr = gUnknown_081D90A7; else { - gBattleMons[gBankAttacker].status2 &= ~(STATUS2_BIDE); + gBattleMons[gBankAttacker].status2 &= ~(STATUS2_MULTIPLETURNS); if (gTakenDmg[gBankAttacker]) { gCurrentMove = MOVE_BIDE; @@ -1246,4 +1260,878 @@ u8 AtkCanceller_UnableToUseMove(void) return effect; } -*/ +bool8 sub_8018018(u8 bank, u8 r1, u8 r2) +{ + struct Pokemon* party; + u8 r7; + u8 r6; + s32 i; + if (!(gBattleTypeFlags & BATTLE_TYPE_DOUBLE)) + return 0; + if (gBattleTypeFlags & BATTLE_TYPE_MULTI) + { + r7 = sub_803FC34(bank); + if (GetBankSide(bank) == 0) + party = gPlayerParty; + else + party = gEnemyParty; + r6 = sub_803FBFC(r7); + for (i = r6 * 3; i < r6 * 3 + 3; i++) + { + if (GetMonData(&party[i], MON_DATA_HP) && GetMonData(&party[i], MON_DATA_SPECIES2) && GetMonData(&party[i], MON_DATA_SPECIES2) != SPECIES_EGG) + break; + } + return (i == r6 * 3 + 3); + } + else + { + if (GetBankSide(bank) == 1) + { + r7 = GetBankByPlayerAI(1); + r6 = GetBankByPlayerAI(3); + party = gEnemyParty; + } + else + { + r7 = GetBankByPlayerAI(0); + r6 = GetBankByPlayerAI(2); + party = gPlayerParty; + } + if (r1 == 6) + r1 = gBattlePartyID[r7]; + if (r2 == 6) + r2 = gBattlePartyID[r6]; + for (i = 0; i < 6; i++) + { + if (GetMonData(&party[i], MON_DATA_HP) && GetMonData(&party[i], MON_DATA_SPECIES2) && GetMonData(&party[i], MON_DATA_SPECIES2) != SPECIES_EGG && i != r1 && i != r2 && i != ewram[r7 + 0x16068] && i != ewram[r6 + 0x16068]) + break; + } + return (i == 6); + } +} + +enum +{ + CASTFORM_NO_CHANGE, //0 + CASTFORM_TO_NORMAL, //1 + CASTFORM_TO_FIRE, //2 + CASTFORM_TO_WATER, //3 + CASTFORM_TO_ICE, //4 +}; + +u8 CastformDataTypeChange(u8 bank) +{ + u8 formChange = 0; + if (gBattleMons[bank].species != SPECIES_CASTFORM || gBattleMons[bank].ability != ABILITY_FORECAST || gBattleMons[bank].hp == 0) + return CASTFORM_NO_CHANGE; + if (!WEATHER_HAS_EFFECT && gBattleMons[bank].type1 != TYPE_NORMAL && gBattleMons[bank].type2 != TYPE_NORMAL) + { + gBattleMons[bank].type1 = TYPE_NORMAL; + gBattleMons[bank].type2 = TYPE_NORMAL; + return CASTFORM_TO_NORMAL; + } + if (!WEATHER_HAS_EFFECT) + return CASTFORM_NO_CHANGE; + if (!(gBattleWeather & (WEATHER_RAIN_ANY | WEATHER_SUN_ANY | WEATHER_HAIL)) && gBattleMons[bank].type1 != TYPE_NORMAL && gBattleMons[bank].type2 != TYPE_NORMAL) + { + gBattleMons[bank].type1 = TYPE_NORMAL; + gBattleMons[bank].type2 = TYPE_NORMAL; + formChange = CASTFORM_TO_NORMAL; + } + if (gBattleWeather & WEATHER_SUN_ANY && gBattleMons[bank].type1 != TYPE_FIRE && gBattleMons[bank].type2 != TYPE_FIRE) + { + gBattleMons[bank].type1 = TYPE_FIRE; + gBattleMons[bank].type2 = TYPE_FIRE; + formChange = CASTFORM_TO_FIRE; + } + if (gBattleWeather & WEATHER_RAIN_ANY && gBattleMons[bank].type1 != TYPE_WATER && gBattleMons[bank].type2 != TYPE_WATER) + { + gBattleMons[bank].type1 = TYPE_WATER; + gBattleMons[bank].type2 = TYPE_WATER; + formChange = CASTFORM_TO_WATER; + } + if (gBattleWeather & WEATHER_HAIL && gBattleMons[bank].type1 != TYPE_ICE && gBattleMons[bank].type2 != TYPE_ICE) + { + gBattleMons[bank].type1 = TYPE_ICE; + gBattleMons[bank].type2 = TYPE_ICE; + formChange = CASTFORM_TO_ICE; + } + return formChange; +} + +extern const u8 gStatusConditionString_PoisonJpn[]; +extern const u8 gStatusConditionString_SleepJpn[]; +extern const u8 gStatusConditionString_ParalysisJpn[]; +extern const u8 gStatusConditionString_BurnJpn[]; +extern const u8 gStatusConditionString_IceJpn[]; +extern const u8 gStatusConditionString_ConfusionJpn[]; +extern const u8 gStatusConditionString_LoveJpn[]; + +extern const u16 gUnknown_081FA724[]; //sound moves table + +extern u8 gUnknown_081D901D[]; //load weather from overworld +extern u8 gUnknown_081D9704[]; //Drizzle activates +extern u8 gUnknown_081D9744[]; //Sandstream activates +extern u8 gUnknown_081D97FE[]; //Drought activates +extern u8 gUnknown_081D977D[]; //castform change +extern u8 gUnknown_081D9730[]; //rain dish hp heal +extern u8 gUnknown_081D9758[]; //shed skin status heal +extern u8 gUnknown_081D9718[]; //speed boost bs +extern u8 gUnknown_081D98F3[]; //soundproof protection +extern u8 gUnknown_081D9843[]; //volt/water absorb no pp loss +extern u8 gUnknown_081D9842[]; //volt/water absorb pp loss +extern u8 gUnknown_081D987C[]; //flash fire boost no pp loss +extern u8 gUnknown_081D987B[]; //flash fire boost pp loss +extern u8 gUnknown_081D9866[]; //volt/water absorb no pp loss full hp +extern u8 gUnknown_081D9865[]; //volt/water absorb pp loss full hp +extern u8 gUnknown_081D9921[]; //color change type change +extern u8 gUnknown_081D9928[]; //rough skin damage +extern u8 gUnknown_081D9950[]; //secondary effect applier +extern u8 gUnknown_081D9943[]; //cute charm activates +extern u8 gUnknown_081D9956[]; //ability status clear +extern u8 gUnknown_081D9953[]; //synchronize effect +extern u8 gUnknown_081D978C[]; //intimidate1 +extern u8 gUnknown_081D9795[]; //intimidate2 +extern u8 gUnknown_081D9726[]; //trace effect + +u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) +{ + u8 effect = 0; + struct Pokemon* pokeAtk; + struct Pokemon* pokeDef; + u16 speciesAtk; + u16 speciesDef; + u32 pidAtk; + u32 pidDef; + + if (gBankAttacker >= gNoOfAllBanks) + gBankAttacker = bank; + if (GetBankSide(gBankAttacker) == 0) + pokeAtk = &gPlayerParty[gBattlePartyID[gBankAttacker]]; + else + pokeAtk = &gEnemyParty[gBattlePartyID[gBankAttacker]]; + + if (gBankTarget >= gNoOfAllBanks) + gBankTarget = bank; + if (GetBankSide(gBankTarget) == 0) + pokeDef = &gPlayerParty[gBattlePartyID[gBankTarget]]; + else + pokeDef = &gEnemyParty[gBattlePartyID[gBankTarget]]; + + speciesAtk = GetMonData(pokeAtk, MON_DATA_SPECIES); + pidAtk = GetMonData(pokeAtk, MON_DATA_PERSONALITY); + + speciesDef = GetMonData(pokeDef, MON_DATA_SPECIES); + pidDef = GetMonData(pokeDef, MON_DATA_PERSONALITY); + + if (!(gBattleTypeFlags & BATTLE_TYPE_SAFARI)) // why isn't that check done at the beginning? + { + u16 move; + u8 moveType; + int i; + u8 side; + + if (special) + gLastUsedAbility = special; + else + gLastUsedAbility = gBattleMons[bank].ability; + + move = moveArg ? moveArg : gCurrentMove; + + if (BATTLE_STRUCT->dynamicMoveType) + moveType = BATTLE_STRUCT->dynamicMoveType & 0x3F; + else + moveType = gBattleMoves[move].type; + + switch (caseID) + { + case ABILITYEFFECT_ON_SWITCHIN: // 0 + if (gBankAttacker >= gNoOfAllBanks) + gBankAttacker = bank; + switch (gLastUsedAbility) + { + case 0xFF: //weather from overworld + switch (weather_get_current()) + { + case 3: + case 5: + case 13: + if (!(gBattleWeather & WEATHER_RAIN_ANY)) + { + gBattleWeather = (WEATHER_RAIN_TEMPORARY | WEATHER_RAIN_PERMANENT); + BATTLE_STRUCT->animArg1 = 0xA; + BATTLE_STRUCT->scriptingActive = bank; + effect++; + } + break; + case 8: + if (!(gBattleWeather & WEATHER_SANDSTORM_ANY)) + { + gBattleWeather = (WEATHER_SANDSTORM_PERMANENT | WEATHER_SANDSTORM_TEMPORARY); + BATTLE_STRUCT->animArg1 = 0xC; + BATTLE_STRUCT->scriptingActive = bank; + effect++; + } + break; + case 12: + if (!(gBattleWeather & WEATHER_SUN_ANY)) + { + gBattleWeather = (WEATHER_SUN_PERMANENT | WEATHER_SUN_TEMPORARY); + BATTLE_STRUCT->animArg1 = 0xB; + BATTLE_STRUCT->scriptingActive = bank; + effect++; + } + break; + } + if (effect) + { + gBattleCommunication[MULTISTRING_CHOOSER] = weather_get_current(); + b_push_move_exec(gUnknown_081D901D); + } + break; + case ABILITY_DRIZZLE: + if (!(gBattleWeather & WEATHER_RAIN_PERMANENT)) + { + gBattleWeather = (WEATHER_RAIN_PERMANENT | WEATHER_RAIN_TEMPORARY); + b_push_move_exec(gUnknown_081D9704); + BATTLE_STRUCT->scriptingActive = bank; + effect++; + } + break; + case ABILITY_SAND_STREAM: + if (!(gBattleWeather & WEATHER_SANDSTORM_PERMANENT)) + { + gBattleWeather = (WEATHER_SANDSTORM_PERMANENT | WEATHER_SANDSTORM_TEMPORARY); + b_push_move_exec(gUnknown_081D9744); + BATTLE_STRUCT->scriptingActive = bank; + effect++; + } + break; + case ABILITY_DROUGHT: + if (!(gBattleWeather & WEATHER_SUN_PERMANENT)) + { + gBattleWeather = (WEATHER_SUN_PERMANENT | WEATHER_SUN_TEMPORARY); + b_push_move_exec(gUnknown_081D97FE); + BATTLE_STRUCT->scriptingActive = bank; + effect++; + } + break; + case ABILITY_INTIMIDATE: + if (!(gSpecialStatuses[bank].intimidatedPoke)) + { + gStatuses3[bank] |= STATUS3_INTIMIDATE_POKES; + gSpecialStatuses[bank].intimidatedPoke = 1; + } + break; + case ABILITY_FORECAST: + if ((effect = CastformDataTypeChange(bank))) + { + b_push_move_exec(gUnknown_081D977D); + BATTLE_STRUCT->scriptingActive = bank; + BATTLE_STRUCT->castformToChangeInto = effect - 1; + } + break; + case ABILITY_TRACE: + if (!(gSpecialStatuses[bank].traced)) + { + gStatuses3[bank] |= STATUS3_TRACE; + gSpecialStatuses[bank].traced = 1; + } + break; + case ABILITY_CLOUD_NINE: + case ABILITY_AIR_LOCK: + { + u8 i; + for (i = 0; i < gNoOfAllBanks; i++) + { + if ((effect = CastformDataTypeChange(i))) + { + b_push_move_exec(gUnknown_081D977D); + BATTLE_STRUCT->scriptingActive = i; + BATTLE_STRUCT->castformToChangeInto = effect - 1; + break; + } + } + } + break; + } + break; + case ABILITYEFFECT_ENDTURN: // 1 + if (gBattleMons[bank].hp) + { + gBankAttacker = bank; + switch (gLastUsedAbility) + { + case ABILITY_RAIN_DISH: + if (WEATHER_HAS_EFFECT && gBattleWeather & WEATHER_RAIN_ANY && gBattleMons[bank].maxHP > gBattleMons[bank].hp) + { + gLastUsedAbility = ABILITY_RAIN_DISH; //why + b_push_move_exec(gUnknown_081D9730); + gBattleMoveDamage = gBattleMons[bank].hp / 16; + if (gBattleMoveDamage == 0) + gBattleMoveDamage = 1; + gBattleMoveDamage *= -1; + effect++; + } + break; + case ABILITY_SHED_SKIN: + if (gBattleMons[bank].status1 & STATUS_ANY && (Random() % 3) == 0) + { + if (gBattleMons[bank].status1 & (STATUS_POISON | STATUS_TOXIC_POISON)) + StringCopy(gBattleTextBuff1, gStatusConditionString_PoisonJpn); + if (gBattleMons[bank].status1 & STATUS_SLEEP) + StringCopy(gBattleTextBuff1, gStatusConditionString_SleepJpn); + if (gBattleMons[bank].status1 & STATUS_PARALYSIS) + StringCopy(gBattleTextBuff1, gStatusConditionString_ParalysisJpn); + if (gBattleMons[bank].status1 & STATUS_BURN) + StringCopy(gBattleTextBuff1, gStatusConditionString_BurnJpn); + if (gBattleMons[bank].status1 & STATUS_FREEZE) + StringCopy(gBattleTextBuff1, gStatusConditionString_IceJpn); + gBattleMons[bank].status1 = 0; + //gBattleMons[bank].status2 &= ~(STATUS2_NIGHTMARE); fixed in Emerald + BATTLE_STRUCT->scriptingActive = gActiveBank = bank; + b_push_move_exec(gUnknown_081D9758); + EmitSetAttributes(0, REQUEST_STATUS_BATTLE, 0, 4, &gBattleMons[bank].status1); + MarkBufferBankForExecution(gActiveBank); + effect++; + } + break; + case ABILITY_SPEED_BOOST: + if (gBattleMons[bank].statStages[STAT_STAGE_SPEED] < 0xC && gDisableStructs[bank].isFirstTurn != 2) + { + gBattleMons[bank].statStages[STAT_STAGE_SPEED]++; + BATTLE_STRUCT->animArg1 = 0x11; + BATTLE_STRUCT->animArg2 = 0; + b_push_move_exec(gUnknown_081D9718); + BATTLE_STRUCT->scriptingActive = bank; + effect++; + } + break; + case ABILITY_TRUANT: + gDisableStructs[gBankAttacker].truantCounter ^= 1; + break; + } + } + break; + case ABILITYEFFECT_MOVES_BLOCK: // 2 + switch (gLastUsedAbility) + { + case ABILITY_SOUNDPROOF: + for (i = 0; gUnknown_081FA724[i] != 0xFFFF; i++) + { + if (gUnknown_081FA724[i] == move) + break; + } + if (gUnknown_081FA724[i] != 0xFFFF) + { + if (gBattleMons[gBankAttacker].status2 & STATUS2_MULTIPLETURNS) + gHitMarker |= HITMARKER_NO_PPDEDUCT; + gBattlescriptCurrInstr = gUnknown_081D98F3; + effect = 1; + } + break; + } + break; + case ABILITYEFFECT_ABSORBING: // 3 + if (move) + { + switch (gLastUsedAbility) + { + case ABILITY_VOLT_ABSORB: + if (moveType == TYPE_ELECTRIC && gBattleMoves[move].power != 0) + { + if (gProtectStructs[gBankAttacker].notFirstStrike) + gBattlescriptCurrInstr = gUnknown_081D9843; + else + gBattlescriptCurrInstr = gUnknown_081D9842; + effect = 1; + } + break; + case ABILITY_WATER_ABSORB: + if (moveType == TYPE_WATER && gBattleMoves[move].power != 0) + { + if (gProtectStructs[gBankAttacker].notFirstStrike) + gBattlescriptCurrInstr = gUnknown_081D9843; + else + gBattlescriptCurrInstr = gUnknown_081D9842; + effect = 1; + } + break; + case ABILITY_FLASH_FIRE: + if (moveType == TYPE_FIRE && !(gBattleMons[bank].status1 & STATUS_FREEZE)) + { + if (!(ewram17000[bank] & 1)) + { + gBattleCommunication[MULTISTRING_CHOOSER] = 0; + if (gProtectStructs[gBankAttacker].notFirstStrike) + gBattlescriptCurrInstr = gUnknown_081D987C; + else + gBattlescriptCurrInstr = gUnknown_081D987B; + ewram17000[bank] |= 1; + effect = 2; + } + else + { + gBattleCommunication[MULTISTRING_CHOOSER] = 1; + if (!(gProtectStructs[gBankAttacker].notFirstStrike)) + gBattlescriptCurrInstr = gUnknown_081D987C; + else + gBattlescriptCurrInstr = gUnknown_081D987B; + effect = 2; + } + } + break; + } + if (effect == 1) + { + if (gBattleMons[bank].maxHP == gBattleMons[bank].hp) + { + if (!(gProtectStructs[gBankAttacker].notFirstStrike)) + gBattlescriptCurrInstr = gUnknown_081D9843; + else + gBattlescriptCurrInstr = gUnknown_081D9842; + } + else + { + gBattleMoveDamage = gBattleMons[bank].maxHP / 4; + if (gBattleMoveDamage == 0) + gBattleMoveDamage = 1; + gBattleMoveDamage *= -1; + } + } + } + break; + case ABILITYEFFECT_CONTACT: // 4 + switch (gLastUsedAbility) + { + case ABILITY_COLOR_CHANGE: + if (!(gBattleMoveFlags & MOVESTATUS_NOEFFECT) && move != MOVE_STRUGGLE && gBattleMoves[move].power != 0 + && (gSpecialStatuses[gBankTarget].moveturnLostHP_physical || gSpecialStatuses[gBankTarget].moveturnLostHP_special) + && gBattleMons[bank].type1 != moveType && gBattleMons[bank].type2 != moveType && gBattleMons[bank].hp) + { + gBattleMons[bank].type1 = moveType; + gBattleMons[bank].type2 = moveType; + gBattleTextBuff1[0] = 0xFD; + gBattleTextBuff1[1] = 3; + gBattleTextBuff1[2] = moveType; + gBattleTextBuff1[3] = 0xFF; + b_movescr_stack_push_cursor(); + gBattlescriptCurrInstr = gUnknown_081D9921; + effect++; + } + break; + case ABILITY_ROUGH_SKIN: + if (!(gBattleMoveFlags & MOVESTATUS_NOEFFECT) && gBattleMons[gBankAttacker].hp && !gProtectStructs[gBankAttacker].confusionSelfDmg + && (gSpecialStatuses[gBankTarget].moveturnLostHP_physical || gSpecialStatuses[gBankTarget].moveturnLostHP_special) + && gBattleMoves[move].flags & FLAG_MAKES_CONTACT) + { + gBattleMoveDamage = gBattleMons[gBankAttacker].maxHP / 16; + if (gBattleMoveDamage == 0) + gBattleMoveDamage = 1; + b_movescr_stack_push_cursor(); + gBattlescriptCurrInstr = gUnknown_081D9928; + effect++; + } + break; + case ABILITY_EFFECT_SPORE: + if (!(gBattleMoveFlags & MOVESTATUS_NOEFFECT) && gBattleMons[gBankAttacker].hp && !gProtectStructs[gBankAttacker].confusionSelfDmg + && (gSpecialStatuses[gBankTarget].moveturnLostHP_physical || gSpecialStatuses[gBankTarget].moveturnLostHP_special) + && gBattleMoves[move].flags & FLAG_MAKES_CONTACT && (Random() % 10) == 0) + { + do + { + gBattleCommunication[MOVE_EFFECT_BYTE] = Random() & 3; + } while (gBattleCommunication[MOVE_EFFECT_BYTE] == 0); + if (gBattleCommunication[MOVE_EFFECT_BYTE] == 3) + gBattleCommunication[MOVE_EFFECT_BYTE] += 2; + gBattleCommunication[MOVE_EFFECT_BYTE] += 0x40; + b_movescr_stack_push_cursor(); + gBattlescriptCurrInstr = gUnknown_081D9950; + gHitMarker |= HITMARKER_IGNORE_SAFEGUARD; + effect++; + } + break; + case ABILITY_POISON_POINT: + if (!(gBattleMoveFlags & MOVESTATUS_NOEFFECT) && gBattleMons[gBankAttacker].hp && !gProtectStructs[gBankAttacker].confusionSelfDmg + && (gSpecialStatuses[gBankTarget].moveturnLostHP_physical || gSpecialStatuses[gBankTarget].moveturnLostHP_special) + && gBattleMoves[move].flags & FLAG_MAKES_CONTACT && (Random() % 3) == 0) + { + gBattleCommunication[MOVE_EFFECT_BYTE] += 0x42; + b_movescr_stack_push_cursor(); + gBattlescriptCurrInstr = gUnknown_081D9950; + gHitMarker |= HITMARKER_IGNORE_SAFEGUARD; + effect++; + } + break; + case ABILITY_STATIC: + if (!(gBattleMoveFlags & MOVESTATUS_NOEFFECT) && gBattleMons[gBankAttacker].hp && !gProtectStructs[gBankAttacker].confusionSelfDmg + && (gSpecialStatuses[gBankTarget].moveturnLostHP_physical || gSpecialStatuses[gBankTarget].moveturnLostHP_special) + && gBattleMoves[move].flags & FLAG_MAKES_CONTACT && (Random() % 3) == 0) + { + gBattleCommunication[MOVE_EFFECT_BYTE] += 0x45; + b_movescr_stack_push_cursor(); + gBattlescriptCurrInstr = gUnknown_081D9950; + gHitMarker |= HITMARKER_IGNORE_SAFEGUARD; + effect++; + } + break; + case ABILITY_FLAME_BODY: + if (!(gBattleMoveFlags & MOVESTATUS_NOEFFECT) && gBattleMons[gBankAttacker].hp && !gProtectStructs[gBankAttacker].confusionSelfDmg && gBattleMoves[move].flags & FLAG_MAKES_CONTACT + && (gSpecialStatuses[gBankTarget].moveturnLostHP_physical || gSpecialStatuses[gBankTarget].moveturnLostHP_special) + && (Random() % 3) == 0) + { + gBattleCommunication[MOVE_EFFECT_BYTE] += 0x43; + b_movescr_stack_push_cursor(); + gBattlescriptCurrInstr = gUnknown_081D9950; + gHitMarker |= HITMARKER_IGNORE_SAFEGUARD; + effect++; + } + break; + case ABILITY_CUTE_CHARM: + if (!(gBattleMoveFlags & MOVESTATUS_NOEFFECT) && gBattleMons[gBankAttacker].hp && !gProtectStructs[gBankAttacker].confusionSelfDmg && gBattleMoves[move].flags & FLAG_MAKES_CONTACT + && (gSpecialStatuses[gBankTarget].moveturnLostHP_physical || gSpecialStatuses[gBankTarget].moveturnLostHP_special) + && gBattleMons[gBankTarget].hp && (Random() % 3) == 0 && gBattleMons[gBankTarget].ability != ABILITY_OBLIVIOUS + && GetGenderFromSpeciesAndPersonality(speciesAtk, pidAtk) != GetGenderFromSpeciesAndPersonality(speciesDef, pidDef) + && !(gBattleMons[gBankTarget].status2 & STATUS2_INFATUATION) && GetGenderFromSpeciesAndPersonality(speciesAtk, pidAtk) != 0xFF + && GetGenderFromSpeciesAndPersonality(speciesDef, pidDef) != 0xFF) + { + gBattleMons[gBankAttacker].status2 |= (gBitTable[gBankTarget] << 0x10); + b_movescr_stack_push_cursor(); + gBattlescriptCurrInstr = gUnknown_081D9943; + effect++; + } + break; + } + break; + case ABILITYEFFECT_IMMUNITY: // 5 + { + u8 i; + for (i = 0; i < gNoOfAllBanks; i++) + { + switch (gBattleMons[i].ability) + { + case ABILITY_IMMUNITY: + if (gBattleMons[i].status1 & (STATUS_POISON | STATUS_TOXIC_POISON)) + { + StringCopy(gBattleTextBuff1, gStatusConditionString_PoisonJpn); + effect = 1; + } + break; + case ABILITY_OWN_TEMPO: + if (gBattleMons[i].status2 & STATUS2_CONFUSION) + { + StringCopy(gBattleTextBuff1, gStatusConditionString_ConfusionJpn); + effect = 2; + } + break; + case ABILITY_LIMBER: + if (gBattleMons[i].status1 & STATUS_PARALYSIS) + { + StringCopy(gBattleTextBuff1, gStatusConditionString_ParalysisJpn); + effect = 1; + } + break; + case ABILITY_INSOMNIA: + case ABILITY_VITAL_SPIRIT: + if (gBattleMons[i].status1 & STATUS_SLEEP) + { + gBattleMons[i].status2 &= ~(STATUS2_NIGHTMARE); + StringCopy(gBattleTextBuff1, gStatusConditionString_SleepJpn); + effect = 1; + } + break; + case ABILITY_WATER_VEIL: + if (gBattleMons[i].status1 & STATUS_BURN) + { + StringCopy(gBattleTextBuff1, gStatusConditionString_BurnJpn); + effect = 1; + } + break; + case ABILITY_MAGMA_ARMOR: + if (gBattleMons[i].status1 & STATUS_FREEZE) + { + StringCopy(gBattleTextBuff1, gStatusConditionString_IceJpn); + effect = 1; + } + break; + case ABILITY_OBLIVIOUS: + if (gBattleMons[i].status2 & STATUS2_INFATUATION) + { + StringCopy(gBattleTextBuff1, gStatusConditionString_LoveJpn); + effect = 3; + } + break; + } + if (effect) + { + switch (effect) + { + case 1: // status cleared + gBattleMons[i].status1 = 0; + break; + case 2: // get rid of confusion + gBattleMons[i].status2 &= ~(STATUS2_CONFUSION); + break; + case 3: // get rid of infatuation + gBattleMons[i].status2 &= ~(STATUS2_INFATUATION); + break; + } + b_movescr_stack_push_cursor(); + gBattlescriptCurrInstr = gUnknown_081D9956; + BATTLE_STRUCT->scriptingActive = i; + gActiveBank = i; + EmitSetAttributes(0, REQUEST_STATUS_BATTLE, 0, 4, &gBattleMons[i].status1); + MarkBufferBankForExecution(gActiveBank); + return effect; + } + } + } + break; + case ABILITYEFFECT_FORECAST: // 6 + { + u8 i; + for (i = 0; i < gNoOfAllBanks; i++) + { + if (gBattleMons[i].ability == ABILITY_FORECAST && (effect = CastformDataTypeChange(i))) + { + b_push_move_exec(gUnknown_081D977D); + BATTLE_STRUCT->scriptingActive = i; + BATTLE_STRUCT->castformToChangeInto = effect - 1; + return effect; + } + } + } + break; + case ABILITYEFFECT_SYNCHRONIZE: // 7 + if (gLastUsedAbility == ABILITY_SYNCHRONIZE && (gHitMarker & HITMARKER_SYNCHRONISE_EFFECT)) + { + gHitMarker &= ~(HITMARKER_SYNCHRONISE_EFFECT); + BATTLE_STRUCT->synchroniseEffect &= 0x3F; + if (BATTLE_STRUCT->synchroniseEffect == 6) + BATTLE_STRUCT->synchroniseEffect = 2; + gBattleCommunication[MOVE_EFFECT_BYTE] = BATTLE_STRUCT->synchroniseEffect + 0x40; + BATTLE_STRUCT->scriptingActive = gBankTarget; + b_movescr_stack_pop_cursor(); + gBattlescriptCurrInstr = gUnknown_081D9953; + gHitMarker |= HITMARKER_IGNORE_SAFEGUARD; + effect++; + } + break; + case ABILITYEFFECT_ATK_SYNCHRONIZE: // 8 + if (gLastUsedAbility == ABILITY_SYNCHRONIZE && (gHitMarker & HITMARKER_SYNCHRONISE_EFFECT)) + { + gHitMarker &= ~(HITMARKER_SYNCHRONISE_EFFECT); + BATTLE_STRUCT->synchroniseEffect &= 0x3F; + if (BATTLE_STRUCT->synchroniseEffect == 6) + BATTLE_STRUCT->synchroniseEffect = 2; + gBattleCommunication[MOVE_EFFECT_BYTE] = BATTLE_STRUCT->synchroniseEffect; + BATTLE_STRUCT->scriptingActive = gBankAttacker; + b_movescr_stack_pop_cursor(); + gBattlescriptCurrInstr = gUnknown_081D9953; + gHitMarker |= HITMARKER_IGNORE_SAFEGUARD; + effect++; + } + break; + case ABILITYEFFECT_INTIMIDATE1: // 9 + for (i = 0; i < gNoOfAllBanks; i++) + { + if (gBattleMons[i].ability == ABILITY_INTIMIDATE && gStatuses3[i] & STATUS3_INTIMIDATE_POKES) + { + gLastUsedAbility = ABILITY_INTIMIDATE; + gStatuses3[i] &= ~(STATUS3_INTIMIDATE_POKES); + b_push_move_exec(gUnknown_081D978C); + BATTLE_STRUCT->intimidateBank = i; + effect++; + break; + } + } + break; + case ABILITYEFFECT_TRACE: // 11 + for (i = 0; i < gNoOfAllBanks; i++) + { + 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); + if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE) + { + if (gBattleMons[target1].ability && gBattleMons[target1].hp && gBattleMons[target2].ability && gBattleMons[target2].hp) + { + //random target + gActiveBank = GetBankByPlayerAI(((Random() & 1) * 2) | opposite); + gBattleMons[i].ability = gBattleMons[gActiveBank].ability; + gLastUsedAbility = gBattleMons[gActiveBank].ability; + effect++; + } + else if (gBattleMons[target1].ability && gBattleMons[target1].hp) + { + gActiveBank = target1; + gBattleMons[i].ability = gBattleMons[gActiveBank].ability; + gLastUsedAbility = gBattleMons[gActiveBank].ability; + effect++; + } + else if (gBattleMons[target2].ability && gBattleMons[target2].hp) + { + gActiveBank = target2; + gBattleMons[i].ability = gBattleMons[gActiveBank].ability; + gLastUsedAbility = gBattleMons[gActiveBank].ability; + effect++; + } + } + else + { + gActiveBank = target1; + if (gBattleMons[target1].ability && gBattleMons[target1].hp) + { + gBattleMons[i].ability = gBattleMons[gActiveBank].ability; + gLastUsedAbility = gBattleMons[gActiveBank].ability; + effect++; + } + } + if (effect) + { + b_push_move_exec(gUnknown_081D9726); + gStatuses3[i] &= ~(STATUS3_TRACE); + BATTLE_STRUCT->scriptingActive = i; + + gBattleTextBuff1[0] = 0xFD; + gBattleTextBuff1[1] = 4; + gBattleTextBuff1[2] = gActiveBank; + gBattleTextBuff1[3] = gBattlePartyID[gActiveBank]; + gBattleTextBuff1[4] = EOS; + + gBattleTextBuff2[0] = 0xFD; + gBattleTextBuff2[1] = 9; + gBattleTextBuff2[2] = gLastUsedAbility; + gBattleTextBuff2[3] = EOS; + break; + } + } + } + break; + case ABILITYEFFECT_INTIMIDATE2: // 10 + for (i = 0; i < gNoOfAllBanks; i++) + { + if (gBattleMons[i].ability == ABILITY_INTIMIDATE && gStatuses3[i] & STATUS3_INTIMIDATE_POKES) + { + gLastUsedAbility = ABILITY_INTIMIDATE; + gStatuses3[i] &= ~(STATUS3_INTIMIDATE_POKES); + b_movescr_stack_push_cursor(); + gBattlescriptCurrInstr = gUnknown_081D9795; + BATTLE_STRUCT->intimidateBank = i; + effect++; + break; + } + } + break; + case ABILITYEFFECT_CHECK_OTHER_SIDE: // 12 + side = GetBankSide(bank); + for (i = 0; i < gNoOfAllBanks; i++) + { + if (GetBankSide(i) != side && gBattleMons[i].ability == ability) + { + gLastUsedAbility = ability; + effect = i + 1; + } + } + break; + case ABILITYEFFECT_CHECK_BANK_SIDE: // 13 + side = GetBankSide(bank); + for (i = 0; i < gNoOfAllBanks; i++) + { + if (GetBankSide(i) == side && gBattleMons[i].ability == ability) + { + gLastUsedAbility = ability; + effect = i + 1; + } + } + break; + case ABILITYEFFECT_FIELD_SPORT: // 14 + if (gLastUsedAbility == 0xFD) + { + for (i = 0; i < gNoOfAllBanks; i++) + { + if (gStatuses3[i] & STATUS3_MUDSPORT) + effect = i + 1; + } + } + else if (gLastUsedAbility == 0xFE) + { + for (i = 0; i < gNoOfAllBanks; i++) + { + if (gStatuses3[i] & STATUS3_WATERSPORT) + effect = i + 1; + } + } + else + { + for (i = 0; i < gNoOfAllBanks; i++) + { + if (gBattleMons[i].ability == ability) + { + gLastUsedAbility = ability; + effect = i + 1; + } + } + } + break; + case ABILITYEFFECT_CHECK_ON_FIELD: // 19 + for (i = 0; i < gNoOfAllBanks; i++) + { + if (gBattleMons[i].ability == ability && gBattleMons[i].hp) + { + gLastUsedAbility = ability; + effect = i + 1; + } + } + break; + case ABILITYEFFECT_CHECK_FIELD_EXCEPT_BANK: // 15 + for (i = 0; i < gNoOfAllBanks; i++) + { + if (gBattleMons[i].ability == ability && i != bank) + { + gLastUsedAbility = ability; + effect = i + 1; + } + } + break; + case ABILITYEFFECT_COUNT_OTHER_SIZE: // 16 + side = GetBankSide(bank); + for (i = 0; i < gNoOfAllBanks; i++) + { + if (GetBankSide(i) != side && gBattleMons[i].ability == ability) + { + gLastUsedAbility = ability; + effect++; + } + } + break; + case ABILITYEFFECT_COUNT_BANK_SIDE: // 17 + side = GetBankSide(bank); + for (i = 0; i < gNoOfAllBanks; i++) + { + if (GetBankSide(i) == side && gBattleMons[i].ability == ability) + { + gLastUsedAbility = ability; + effect++; + } + } + break; + case ABILITYEFFECT_COUNT_ON_FIELD: // 18 + for (i = 0; i < gNoOfAllBanks; i++) + { + if (gBattleMons[i].ability == ability && i != bank) + { + gLastUsedAbility = ability; + effect++; + } + } + break; + } + if (effect && caseID < 0xC && gLastUsedAbility != 0xFF) + RecordAbilityBattle(bank, gLastUsedAbility); + } + + return effect; +} diff --git a/src/battle_4.c b/src/battle_4.c index eb21d5e0f..bbc3bfa33 100644 --- a/src/battle_4.c +++ b/src/battle_4.c @@ -152,7 +152,7 @@ void sub_803E1B0(struct Pokemon*, u16 item, u8 partyID, u8 r3, u8 sp); u8 CanRunFromBattle(void); u8 sub_801B5C0(u16 move, u8 targetbyte); //get target of move void sub_80153D0(u8 atk); //pressure perish song pp decrement -u8 castform_switch(u8 bank); +u8 CastformDataTypeChange(u8 bank); void b_push_move_exec(u8* bs_ptr); u8 sav1_map_get_light_level(void); u8 CalculatePlayerPartyCount(void); @@ -276,7 +276,6 @@ extern u8 gUnknown_081D95DB[]; //bs payday money give #define RecordAbilitySetField6(ability, fieldValue) \ (gLastUsedAbility = ability, gBattleCommunication[6] = fieldValue, RecordAbilityBattle(gBankTarget, ability)) -#define WEATHER_HAS_EFFECT ((!AbilityBattleEffects(ABILITYEFFECT_CHECK_ON_FIELD, 0, ABILITY_CLOUD_NINE, 0, 0) && !AbilityBattleEffects(ABILITYEFFECT_CHECK_ON_FIELD, 0, ABILITY_AIR_LOCK, 0, 0))) #define TARGET_TURN_DAMAGED (((gSpecialStatuses[gBankTarget].moveturnLostHP_physical || gSpecialStatuses[gBankTarget].moveturnLostHP_physical.moveturnLostHP_special))) #define HP_ON_SWITCHOUT (((u16*)(0x020160bc))) @@ -17655,7 +17654,7 @@ static void atkE7_castform_data_change(void) { u8 form; gBattlescriptCurrInstr++; - form = castform_switch(BATTLE_STRUCT->scriptingActive); + form = CastformDataTypeChange(BATTLE_STRUCT->scriptingActive); if (form) { b_push_move_exec(gUnknown_081D977D); From dddca2951a2619d98e5008473408a83d69d8c99e Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Fri, 28 Jul 2017 18:02:08 +0200 Subject: [PATCH 5/8] IBE matches --- asm/battle_3.s | 2445 ------------------------- include/battle.h | 8 +- include/pokemon.h | 1 + src/battle_3.c | 4360 ++++++++++++++++++++++++++++++++++++++++++++- src/battle_4.c | 2 +- 5 files changed, 4296 insertions(+), 2520 deletions(-) diff --git a/asm/battle_3.s b/asm/battle_3.s index 57ed0b8f4..af09ddf57 100644 --- a/asm/battle_3.s +++ b/asm/battle_3.s @@ -6,2451 +6,6 @@ .text - - thumb_func_start b_call_bc_move_exec -b_call_bc_move_exec: @ 8019FB0 - ldr r1, _08019FD8 @ =gBattlescriptCurrInstr - str r0, [r1] - ldr r3, _08019FDC @ =0x02017140 - adds r2, r3, 0 - adds r2, 0x20 - ldrb r0, [r2] - adds r1, r0, 0x1 - strb r1, [r2] - lsls r0, 24 - lsrs r0, 22 - adds r0, r3 - ldr r2, _08019FE0 @ =gBattleMainFunc - ldr r1, [r2] - str r1, [r0] - ldr r0, _08019FE4 @ =sub_8013F54 - str r0, [r2] - ldr r1, _08019FE8 @ =gFightStateTracker - movs r0, 0 - strb r0, [r1] - bx lr - .align 2, 0 -_08019FD8: .4byte gBattlescriptCurrInstr -_08019FDC: .4byte 0x02017140 -_08019FE0: .4byte gBattleMainFunc -_08019FE4: .4byte sub_8013F54 -_08019FE8: .4byte gFightStateTracker - thumb_func_end b_call_bc_move_exec - - thumb_func_start b_push_move_exec -b_push_move_exec: @ 8019FEC - push {r4,lr} - adds r4, r0, 0 - bl b_movescr_stack_push_cursor - ldr r0, _0801A01C @ =gBattlescriptCurrInstr - str r4, [r0] - ldr r3, _0801A020 @ =0x02017140 - adds r2, r3, 0 - adds r2, 0x20 - ldrb r0, [r2] - adds r1, r0, 0x1 - strb r1, [r2] - lsls r0, 24 - lsrs r0, 22 - adds r0, r3 - ldr r2, _0801A024 @ =gBattleMainFunc - ldr r1, [r2] - str r1, [r0] - ldr r0, _0801A028 @ =sub_8013FBC - str r0, [r2] - pop {r4} - pop {r0} - bx r0 - .align 2, 0 -_0801A01C: .4byte gBattlescriptCurrInstr -_0801A020: .4byte 0x02017140 -_0801A024: .4byte gBattleMainFunc -_0801A028: .4byte sub_8013FBC - thumb_func_end b_push_move_exec - - thumb_func_start ItemBattleEffects -ItemBattleEffects: @ 801A02C - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x2C - lsls r0, 24 - lsrs r0, 24 - str r0, [sp, 0x8] - lsls r1, 24 - lsrs r7, r1, 24 - lsls r2, 24 - lsrs r6, r2, 24 - movs r0, 0 - mov r10, r0 - movs r1, 0 - str r1, [sp, 0xC] - add r0, sp, 0x4 - strb r1, [r0] - ldr r4, _0801A078 @ =gLastUsedItem - ldr r1, _0801A07C @ =gBattleMons - movs r0, 0x58 - muls r0, r7 - adds r0, r1 - ldrh r0, [r0, 0x2E] - strh r0, [r4] - lsls r0, 16 - lsrs r0, 16 - cmp r0, 0xAF - bne _0801A084 - ldr r1, _0801A080 @ =gEnigmaBerries - lsls r0, r7, 3 - subs r0, r7 - lsls r0, 2 - adds r0, r1 - ldrb r5, [r0, 0x7] - ldrb r0, [r0, 0x1A] - b _0801A098 - .align 2, 0 -_0801A078: .4byte gLastUsedItem -_0801A07C: .4byte gBattleMons -_0801A080: .4byte gEnigmaBerries -_0801A084: - ldrh r0, [r4] - bl ItemId_GetHoldEffect - lsls r0, 24 - lsrs r5, r0, 24 - ldrh r0, [r4] - bl ItemId_GetHoldEffectParam - lsls r0, 24 - lsrs r0, 24 -_0801A098: - mov r9, r0 - ldr r1, _0801A0C0 @ =gBattleMons - ldr r0, _0801A0C4 @ =gBankAttacker - ldrb r2, [r0] - movs r0, 0x58 - muls r0, r2 - adds r0, r1 - ldrh r0, [r0, 0x2E] - str r0, [sp, 0x14] - cmp r0, 0xAF - bne _0801A0CC - ldr r1, _0801A0C8 @ =gEnigmaBerries - lsls r0, r2, 3 - subs r0, r2 - lsls r0, 2 - adds r0, r1 - ldrb r3, [r0, 0x7] - mov r8, r3 - ldrb r0, [r0, 0x1A] - b _0801A0E2 - .align 2, 0 -_0801A0C0: .4byte gBattleMons -_0801A0C4: .4byte gBankAttacker -_0801A0C8: .4byte gEnigmaBerries -_0801A0CC: - ldr r0, [sp, 0x14] - bl ItemId_GetHoldEffect - lsls r0, 24 - lsrs r0, 24 - mov r8, r0 - ldr r0, [sp, 0x14] - bl ItemId_GetHoldEffectParam - lsls r0, 24 - lsrs r0, 24 -_0801A0E2: - str r0, [sp, 0x10] - ldr r2, _0801A118 @ =gBattleMons - ldr r0, _0801A11C @ =gBankTarget - ldrb r1, [r0] - movs r0, 0x58 - muls r0, r1 - adds r0, r2 - ldrh r4, [r0, 0x2E] - cmp r4, 0xAF - beq _0801A102 - adds r0, r4, 0 - bl ItemId_GetHoldEffect - adds r0, r4, 0 - bl ItemId_GetHoldEffectParam -_0801A102: - ldr r4, [sp, 0x8] - cmp r4, 0x4 - bls _0801A10C - bl _0801B3CA -_0801A10C: - lsls r0, r4, 2 - ldr r1, _0801A120 @ =_0801A124 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .align 2, 0 -_0801A118: .4byte gBattleMons -_0801A11C: .4byte gBankTarget -_0801A120: .4byte _0801A124 - .align 2, 0 -_0801A124: - .4byte _0801A138 - .4byte _0801A1D4 - .4byte _0801B3CA - .4byte _0801AE0C - .4byte _0801B26C -_0801A138: - cmp r5, 0x17 - beq _0801A15C - cmp r5, 0x20 - beq _0801A144 - bl _0801B3CA -_0801A144: - ldr r0, _0801A154 @ =0x02000000 - ldr r5, _0801A158 @ =0x00016056 - adds r0, r5 - movs r1, 0x2 - strb r1, [r0] - bl _0801B3CA - .align 2, 0 -_0801A154: .4byte 0x02000000 -_0801A158: .4byte 0x00016056 -_0801A15C: - ldr r0, _0801A1B8 @ =gBattleMons - mov r8, r0 - movs r0, 0x58 - adds r1, r7, 0 - muls r1, r0 - mov r0, r8 - adds r0, 0x18 - adds r1, r0 - movs r2, 0x6 - movs r3, 0x7 - mov r10, r3 -_0801A172: - movs r0, 0 - ldrsb r0, [r1, r0] - cmp r0, 0x5 - bgt _0801A180 - strb r2, [r1] - movs r4, 0x5 - str r4, [sp, 0xC] -_0801A180: - adds r1, 0x1 - movs r5, 0x1 - negs r5, r5 - add r10, r5 - mov r0, r10 - cmp r0, 0 - bge _0801A172 - ldr r1, [sp, 0xC] - cmp r1, 0 - bne _0801A198 - bl _0801B3CA -_0801A198: - ldr r0, _0801A1BC @ =0x02000000 - ldr r2, _0801A1C0 @ =0x00016003 - adds r0, r2 - strb r7, [r0] - ldr r0, _0801A1C4 @ =gStringBank - strb r7, [r0] - ldr r1, _0801A1C8 @ =gActiveBank - ldr r0, _0801A1CC @ =gBankAttacker - strb r7, [r0] - strb r7, [r1] - ldr r0, _0801A1D0 @ =gUnknown_081D9A5E - bl b_call_bc_move_exec - bl _0801B3CA - .align 2, 0 -_0801A1B8: .4byte gBattleMons -_0801A1BC: .4byte 0x02000000 -_0801A1C0: .4byte 0x00016003 -_0801A1C4: .4byte gStringBank -_0801A1C8: .4byte gActiveBank -_0801A1CC: .4byte gBankAttacker -_0801A1D0: .4byte gUnknown_081D9A5E -_0801A1D4: - ldr r1, _0801A1FC @ =gBattleMons - movs r0, 0x58 - muls r0, r7 - adds r0, r1 - ldrh r0, [r0, 0x28] - mov r8, r1 - cmp r0, 0 - bne _0801A1E8 - bl _0801B3CA -_0801A1E8: - subs r0, r5, 0x1 - cmp r0, 0x2A - bls _0801A1F2 - bl _0801AD5A -_0801A1F2: - lsls r0, 2 - ldr r1, _0801A200 @ =_0801A204 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .align 2, 0 -_0801A1FC: .4byte gBattleMons -_0801A200: .4byte _0801A204 - .align 2, 0 -_0801A204: - .4byte _0801A2B0 - .4byte _0801AAC8 - .4byte _0801AB84 - .4byte _0801AAF8 - .4byte _0801AB2C - .4byte _0801AB5C - .4byte _0801A2F8 - .4byte _0801ABC8 - .4byte _0801ABF8 - .4byte _0801A4CC - .4byte _0801A548 - .4byte _0801A5C4 - .4byte _0801A634 - .4byte _0801A6C8 - .4byte _0801A75C - .4byte _0801A7D4 - .4byte _0801A838 - .4byte _0801A89C - .4byte _0801A900 - .4byte _0801A97C - .4byte _0801A9C8 - .4byte _0801AD5A - .4byte _0801A3F8 - .4byte _0801AD5A - .4byte _0801AD5A - .4byte _0801AD5A - .4byte _0801AD5A - .4byte _0801AD24 - .4byte _0801AD5A - .4byte _0801AD5A - .4byte _0801AD5A - .4byte _0801AD5A - .4byte _0801AD5A - .4byte _0801AD5A - .4byte _0801AD5A - .4byte _0801AD5A - .4byte _0801AD5A - .4byte _0801AD5A - .4byte _0801AD5A - .4byte _0801AD5A - .4byte _0801AD5A - .4byte _0801AD5A - .4byte _0801A46C -_0801A2B0: - movs r0, 0x58 - muls r0, r7 - mov r3, r8 - adds r2, r0, r3 - ldrh r0, [r2, 0x2C] - ldrh r1, [r2, 0x28] - lsrs r0, 1 - cmp r1, r0 - bls _0801A2C6 - bl _0801AD5A -_0801A2C6: - cmp r6, 0 - beq _0801A2CE - bl _0801AD5A -_0801A2CE: - ldr r4, _0801A2F0 @ =gBattleMoveDamage - mov r5, r9 - str r5, [r4] - ldrh r3, [r2, 0x28] - adds r0, r3, r5 - ldrh r1, [r2, 0x2C] - cmp r0, r1 - ble _0801A2E2 - subs r0, r1, r3 - str r0, [r4] -_0801A2E2: - ldr r0, [r4] - negs r0, r0 - str r0, [r4] - ldr r0, _0801A2F4 @ =gUnknown_081D9A74 - bl b_call_bc_move_exec - b _0801A752 - .align 2, 0 -_0801A2F0: .4byte gBattleMoveDamage -_0801A2F4: .4byte gUnknown_081D9A74 -_0801A2F8: - cmp r6, 0 - beq _0801A300 - bl _0801AD5A -_0801A300: - adds r0, r7, 0 - bl GetBankSide - lsls r0, 24 - cmp r0, 0 - bne _0801A324 - ldr r1, _0801A31C @ =gBattlePartyID - lsls r0, r7, 1 - adds r0, r1 - ldrh r1, [r0] - movs r0, 0x64 - muls r1, r0 - ldr r0, _0801A320 @ =gPlayerParty - b _0801A332 - .align 2, 0 -_0801A31C: .4byte gBattlePartyID -_0801A320: .4byte gPlayerParty -_0801A324: - ldr r1, _0801A3A0 @ =gBattlePartyID - lsls r0, r7, 1 - adds r0, r1 - ldrh r1, [r0] - movs r0, 0x64 - muls r1, r0 - ldr r0, _0801A3A4 @ =gEnemyParty -_0801A332: - adds r4, r1, r0 - movs r1, 0 - mov r10, r1 - add r5, sp, 0x4 -_0801A33A: - mov r1, r10 - adds r1, 0xD - adds r0, r4, 0 - bl GetMonData - lsls r0, 16 - lsrs r6, r0, 16 - mov r1, r10 - adds r1, 0x11 - adds r0, r4, 0 - bl GetMonData - strb r0, [r5] - adds r0, r4, 0 - movs r1, 0x15 - bl GetMonData - lsls r0, 24 - lsrs r1, r0, 24 - cmp r6, 0 - beq _0801A36A - ldrb r0, [r5] - cmp r0, 0 - beq _0801A374 -_0801A36A: - movs r2, 0x1 - add r10, r2 - mov r3, r10 - cmp r3, 0x3 - ble _0801A33A -_0801A374: - mov r4, r10 - cmp r4, 0x4 - bne _0801A37E - bl _0801AD5A -_0801A37E: - lsls r2, r4, 24 - lsrs r2, 24 - adds r0, r6, 0 - bl CalculatePPWithBonus - lsls r0, 24 - lsrs r2, r0, 24 - add r0, sp, 0x4 - ldrb r0, [r0] - mov r5, r9 - adds r1, r0, r5 - cmp r1, r2 - ble _0801A3A8 - add r0, sp, 0x4 - strb r2, [r0] - b _0801A3AC - .align 2, 0 -_0801A3A0: .4byte gBattlePartyID -_0801A3A4: .4byte gEnemyParty -_0801A3A8: - add r0, sp, 0x4 - strb r1, [r0] -_0801A3AC: - ldr r1, _0801A3EC @ =gBattleTextBuff1 - movs r0, 0xFD - strb r0, [r1] - movs r0, 0x2 - strb r0, [r1, 0x1] - strb r6, [r1, 0x2] - lsrs r0, r6, 8 - strb r0, [r1, 0x3] - movs r0, 0xFF - strb r0, [r1, 0x4] - ldr r0, _0801A3F0 @ =gUnknown_081D9A91 - bl b_call_bc_move_exec - mov r1, r10 - adds r1, 0x9 - lsls r1, 24 - lsrs r1, 24 - add r0, sp, 0x4 - str r0, [sp] - movs r0, 0 - movs r2, 0 - movs r3, 0x1 - bl EmitSetAttributes - ldr r0, _0801A3F4 @ =gActiveBank - ldrb r0, [r0] - bl MarkBufferBankForExecution - movs r1, 0x3 - str r1, [sp, 0xC] - bl _0801AD62 - .align 2, 0 -_0801A3EC: .4byte gBattleTextBuff1 -_0801A3F0: .4byte gUnknown_081D9A91 -_0801A3F4: .4byte gActiveBank -_0801A3F8: - ldr r0, _0801A450 @ =gBattleMons - movs r1, 0x58 - muls r1, r7 - adds r0, 0x18 - adds r1, r0 - movs r2, 0x6 - movs r3, 0x7 - mov r10, r3 -_0801A408: - movs r0, 0 - ldrsb r0, [r1, r0] - cmp r0, 0x5 - bgt _0801A416 - strb r2, [r1] - movs r4, 0x5 - str r4, [sp, 0xC] -_0801A416: - adds r1, 0x1 - movs r5, 0x1 - negs r5, r5 - add r10, r5 - mov r0, r10 - cmp r0, 0 - bge _0801A408 - movs r1, 0x8 - mov r10, r1 - ldr r2, [sp, 0xC] - cmp r2, 0 - bne _0801A432 - bl _0801B3CA -_0801A432: - ldr r0, _0801A454 @ =0x02000000 - ldr r3, _0801A458 @ =0x00016003 - adds r0, r3 - strb r7, [r0] - ldr r0, _0801A45C @ =gStringBank - strb r7, [r0] - ldr r1, _0801A460 @ =gActiveBank - ldr r0, _0801A464 @ =gBankAttacker - strb r7, [r0] - strb r7, [r1] - ldr r0, _0801A468 @ =gUnknown_081D9A5E - bl b_call_bc_move_exec - bl _0801AD5A - .align 2, 0 -_0801A450: .4byte gBattleMons -_0801A454: .4byte 0x02000000 -_0801A458: .4byte 0x00016003 -_0801A45C: .4byte gStringBank -_0801A460: .4byte gActiveBank -_0801A464: .4byte gBankAttacker -_0801A468: .4byte gUnknown_081D9A5E -_0801A46C: - movs r0, 0x58 - muls r0, r7 - mov r4, r8 - adds r1, r0, r4 - ldrh r0, [r1, 0x28] - ldrh r2, [r1, 0x2C] - cmp r0, r2 - bcc _0801A480 - bl _0801AD5A -_0801A480: - cmp r6, 0 - beq _0801A488 - bl _0801AD5A -_0801A488: - ldr r3, _0801A4C4 @ =gBattleMoveDamage - ldrh r0, [r1, 0x2C] - lsrs r0, 4 - str r0, [r3] - cmp r0, 0 - bne _0801A498 - movs r0, 0x1 - str r0, [r3] -_0801A498: - ldrh r2, [r1, 0x28] - ldr r0, [r3] - adds r0, r2, r0 - ldrh r1, [r1, 0x2C] - cmp r0, r1 - ble _0801A4A8 - subs r0, r1, r2 - str r0, [r3] -_0801A4A8: - ldr r0, [r3] - negs r0, r0 - str r0, [r3] - ldr r0, _0801A4C8 @ =gUnknown_081D9AA1 - bl b_call_bc_move_exec - movs r3, 0x4 - str r3, [sp, 0xC] - adds r0, r7, 0 - adds r1, r5, 0 - bl RecordItemBattle - bl _0801AD5A - .align 2, 0 -_0801A4C4: .4byte gBattleMoveDamage -_0801A4C8: .4byte gUnknown_081D9AA1 -_0801A4CC: - movs r0, 0x58 - adds r4, r7, 0 - muls r4, r0 - str r4, [sp, 0x18] - add r4, r8 - ldrh r0, [r4, 0x2C] - ldrh r1, [r4, 0x28] - lsrs r0, 1 - cmp r1, r0 - bls _0801A4E4 - bl _0801AD5A -_0801A4E4: - cmp r6, 0 - beq _0801A4EC - bl _0801AD5A -_0801A4EC: - ldr r1, _0801A540 @ =gBattleTextBuff1 - movs r0, 0xFD - strb r0, [r1] - movs r0, 0x8 - strb r0, [r1, 0x1] - strb r6, [r1, 0x2] - movs r0, 0xFF - strb r0, [r1, 0x3] - ldr r5, _0801A544 @ =gBattleMoveDamage - ldrh r0, [r4, 0x2C] - mov r1, r9 - bl __divsi3 - str r0, [r5] - cmp r0, 0 - bne _0801A510 - movs r0, 0x1 - str r0, [r5] -_0801A510: - ldrh r2, [r4, 0x28] - ldr r0, [r5] - adds r0, r2, r0 - ldrh r1, [r4, 0x2C] - cmp r0, r1 - ble _0801A520 - subs r0, r1, r2 - str r0, [r5] -_0801A520: - ldr r0, [r5] - negs r0, r0 - str r0, [r5] - mov r0, r8 - adds r0, 0x48 - ldr r5, [sp, 0x18] - adds r0, r5, r0 - ldr r0, [r0] - movs r1, 0 -_0801A532: - bl sub_8040A7C - lsls r0, 24 - cmp r0, 0 - bge _0801A53E - b _0801A738 -_0801A53E: - b _0801A74C - .align 2, 0 -_0801A540: .4byte gBattleTextBuff1 -_0801A544: .4byte gBattleMoveDamage -_0801A548: - movs r0, 0x58 - adds r1, r7, 0 - muls r1, r0 - str r1, [sp, 0x1C] - adds r5, r1, 0 - add r5, r8 - ldrh r0, [r5, 0x2C] - ldrh r1, [r5, 0x28] - lsrs r0, 1 - cmp r1, r0 - bls _0801A562 - bl _0801AD5A -_0801A562: - cmp r6, 0 - beq _0801A56A - bl _0801AD5A -_0801A56A: - ldr r1, _0801A5BC @ =gBattleTextBuff1 - movs r0, 0xFD - strb r0, [r1] - movs r0, 0x8 - strb r0, [r1, 0x1] - movs r6, 0x1 - strb r6, [r1, 0x2] - movs r0, 0xFF - strb r0, [r1, 0x3] - ldr r4, _0801A5C0 @ =gBattleMoveDamage - ldrh r0, [r5, 0x2C] - mov r1, r9 - bl __divsi3 - str r0, [r4] - cmp r0, 0 - bne _0801A58E - str r6, [r4] -_0801A58E: - ldrh r2, [r5, 0x28] - ldr r0, [r4] - adds r0, r2, r0 - ldrh r1, [r5, 0x2C] - cmp r0, r1 - ble _0801A59E - subs r0, r1, r2 - str r0, [r4] -_0801A59E: - ldr r0, [r4] - negs r0, r0 - str r0, [r4] - mov r0, r8 - adds r0, 0x48 - ldr r2, [sp, 0x1C] - adds r0, r2, r0 - ldr r0, [r0] - movs r1, 0x1 - bl sub_8040A7C - lsls r0, 24 - cmp r0, 0 - blt _0801A6A4 - b _0801A6B8 - .align 2, 0 -_0801A5BC: .4byte gBattleTextBuff1 -_0801A5C0: .4byte gBattleMoveDamage -_0801A5C4: - movs r0, 0x58 - adds r4, r7, 0 - muls r4, r0 - str r4, [sp, 0x20] - adds r5, r4, 0 - add r5, r8 - ldrh r0, [r5, 0x2C] - ldrh r1, [r5, 0x28] - lsrs r0, 1 - cmp r1, r0 - bls _0801A5DC - b _0801AD5A -_0801A5DC: - cmp r6, 0 - beq _0801A5E2 - b _0801AD5A -_0801A5E2: - ldr r1, _0801A62C @ =gBattleTextBuff1 - movs r0, 0xFD - strb r0, [r1] - movs r0, 0x8 - strb r0, [r1, 0x1] - movs r0, 0x2 - strb r0, [r1, 0x2] - movs r0, 0xFF - strb r0, [r1, 0x3] - ldr r4, _0801A630 @ =gBattleMoveDamage - ldrh r0, [r5, 0x2C] - mov r1, r9 - bl __divsi3 - str r0, [r4] - cmp r0, 0 - bne _0801A608 - movs r0, 0x1 - str r0, [r4] -_0801A608: - ldrh r2, [r5, 0x28] - ldr r0, [r4] - adds r0, r2, r0 - ldrh r1, [r5, 0x2C] - cmp r0, r1 - ble _0801A618 - subs r0, r1, r2 - str r0, [r4] -_0801A618: - ldr r0, [r4] - negs r0, r0 - str r0, [r4] - mov r0, r8 - adds r0, 0x48 - ldr r5, [sp, 0x20] - adds r0, r5, r0 - ldr r0, [r0] - movs r1, 0x2 - b _0801A532 - .align 2, 0 -_0801A62C: .4byte gBattleTextBuff1 -_0801A630: .4byte gBattleMoveDamage -_0801A634: - movs r0, 0x58 - adds r1, r7, 0 - muls r1, r0 - str r1, [sp, 0x24] - adds r5, r1, 0 - add r5, r8 - ldrh r0, [r5, 0x2C] - ldrh r1, [r5, 0x28] - lsrs r0, 1 - cmp r1, r0 - bls _0801A64C - b _0801AD5A -_0801A64C: - cmp r6, 0 - beq _0801A652 - b _0801AD5A -_0801A652: - ldr r1, _0801A6AC @ =gBattleTextBuff1 - movs r0, 0xFD - strb r0, [r1] - movs r0, 0x8 - strb r0, [r1, 0x1] - movs r0, 0x3 - strb r0, [r1, 0x2] - movs r0, 0xFF - strb r0, [r1, 0x3] - ldr r4, _0801A6B0 @ =gBattleMoveDamage - ldrh r0, [r5, 0x2C] - mov r1, r9 - bl __divsi3 - str r0, [r4] - cmp r0, 0 - bne _0801A678 - movs r0, 0x1 - str r0, [r4] -_0801A678: - ldrh r2, [r5, 0x28] - ldr r0, [r4] - adds r0, r2, r0 - ldrh r1, [r5, 0x2C] - cmp r0, r1 - ble _0801A688 - subs r0, r1, r2 - str r0, [r4] -_0801A688: - ldr r0, [r4] - negs r0, r0 - str r0, [r4] - mov r0, r8 - adds r0, 0x48 - ldr r2, [sp, 0x24] - adds r0, r2, r0 - ldr r0, [r0] - movs r1, 0x3 - bl sub_8040A7C - lsls r0, 24 - cmp r0, 0 - bge _0801A6B8 -_0801A6A4: - ldr r0, _0801A6B4 @ =gUnknown_081D9AD4 - bl b_call_bc_move_exec - b _0801A6BE - .align 2, 0 -_0801A6AC: .4byte gBattleTextBuff1 -_0801A6B0: .4byte gBattleMoveDamage -_0801A6B4: .4byte gUnknown_081D9AD4 -_0801A6B8: - ldr r0, _0801A6C4 @ =gUnknown_081D9A74 - bl b_call_bc_move_exec -_0801A6BE: - movs r3, 0x4 - str r3, [sp, 0xC] - b _0801AD62 - .align 2, 0 -_0801A6C4: .4byte gUnknown_081D9A74 -_0801A6C8: - movs r0, 0x58 - adds r4, r7, 0 - muls r4, r0 - str r4, [sp, 0x28] - adds r5, r4, 0 - add r5, r8 - ldrh r0, [r5, 0x2C] - ldrh r1, [r5, 0x28] - lsrs r0, 1 - cmp r1, r0 - bls _0801A6E0 - b _0801AD5A -_0801A6E0: - cmp r6, 0 - beq _0801A6E6 - b _0801AD5A -_0801A6E6: - ldr r1, _0801A740 @ =gBattleTextBuff1 - movs r0, 0xFD - strb r0, [r1] - movs r0, 0x8 - strb r0, [r1, 0x1] - movs r0, 0x4 - strb r0, [r1, 0x2] - movs r0, 0xFF - strb r0, [r1, 0x3] - ldr r4, _0801A744 @ =gBattleMoveDamage - ldrh r0, [r5, 0x2C] - mov r1, r9 - bl __divsi3 - str r0, [r4] - cmp r0, 0 - bne _0801A70C - movs r0, 0x1 - str r0, [r4] -_0801A70C: - ldrh r2, [r5, 0x28] - ldr r0, [r4] - adds r0, r2, r0 - ldrh r1, [r5, 0x2C] - cmp r0, r1 - ble _0801A71C - subs r0, r1, r2 - str r0, [r4] -_0801A71C: - ldr r0, [r4] - negs r0, r0 - str r0, [r4] - mov r0, r8 - adds r0, 0x48 - ldr r5, [sp, 0x28] - adds r0, r5, r0 - ldr r0, [r0] - movs r1, 0x4 - bl sub_8040A7C - lsls r0, 24 - cmp r0, 0 - bge _0801A74C -_0801A738: - ldr r0, _0801A748 @ =gUnknown_081D9AD4 - bl b_call_bc_move_exec - b _0801A752 - .align 2, 0 -_0801A740: .4byte gBattleTextBuff1 -_0801A744: .4byte gBattleMoveDamage -_0801A748: .4byte gUnknown_081D9AD4 -_0801A74C: - ldr r0, _0801A758 @ =gUnknown_081D9A74 - bl b_call_bc_move_exec -_0801A752: - movs r0, 0x4 - str r0, [sp, 0xC] - b _0801AD62 - .align 2, 0 -_0801A758: .4byte gUnknown_081D9A74 -_0801A75C: - movs r0, 0x58 - muls r0, r7 - mov r1, r8 - adds r5, r0, r1 - ldrh r4, [r5, 0x28] - ldrh r0, [r5, 0x2C] - mov r1, r9 - bl __divsi3 - cmp r4, r0 - ble _0801A774 - b _0801AD5A -_0801A774: - cmp r6, 0 - beq _0801A77A - b _0801AD5A -_0801A77A: - movs r0, 0x19 - ldrsb r0, [r5, r0] - cmp r0, 0xB - ble _0801A784 - b _0801AD5A -_0801A784: - ldr r1, _0801A7BC @ =gBattleTextBuff1 - movs r2, 0xFD - strb r2, [r1] - movs r0, 0x5 - strb r0, [r1, 0x1] - movs r0, 0x1 - strb r0, [r1, 0x2] - movs r0, 0xFF - strb r0, [r1, 0x3] - ldr r1, _0801A7C0 @ =gBattleTextBuff2 - strb r2, [r1] - strb r6, [r1, 0x1] - movs r0, 0xD2 - strb r0, [r1, 0x2] - strb r6, [r1, 0x3] - subs r0, 0xD3 - strb r0, [r1, 0x4] - ldr r0, _0801A7C4 @ =gEffectBank - strb r7, [r0] - ldr r1, _0801A7C8 @ =0x02000000 - ldr r3, _0801A7CC @ =0x0001601e - adds r2, r1, r3 - movs r0, 0x11 - strb r0, [r2] - ldr r4, _0801A7D0 @ =0x000160a4 - adds r2, r1, r4 - movs r0, 0xF - b _0801A94C - .align 2, 0 -_0801A7BC: .4byte gBattleTextBuff1 -_0801A7C0: .4byte gBattleTextBuff2 -_0801A7C4: .4byte gEffectBank -_0801A7C8: .4byte 0x02000000 -_0801A7CC: .4byte 0x0001601e -_0801A7D0: .4byte 0x000160a4 -_0801A7D4: - movs r0, 0x58 - muls r0, r7 - mov r1, r8 - adds r5, r0, r1 - ldrh r4, [r5, 0x28] - ldrh r0, [r5, 0x2C] - mov r1, r9 - bl __divsi3 - cmp r4, r0 - ble _0801A7EC - b _0801AD5A -_0801A7EC: - cmp r6, 0 - beq _0801A7F2 - b _0801AD5A -_0801A7F2: - movs r0, 0x1A - ldrsb r0, [r5, r0] - cmp r0, 0xB - ble _0801A7FC - b _0801AD5A -_0801A7FC: - ldr r1, _0801A824 @ =gBattleTextBuff1 - movs r0, 0xFD - strb r0, [r1] - movs r0, 0x5 - strb r0, [r1, 0x1] - movs r0, 0x2 - strb r0, [r1, 0x2] - movs r0, 0xFF - strb r0, [r1, 0x3] - ldr r0, _0801A828 @ =gEffectBank - strb r7, [r0] - ldr r1, _0801A82C @ =0x02000000 - ldr r3, _0801A830 @ =0x0001601e - adds r2, r1, r3 - movs r0, 0x12 - strb r0, [r2] - ldr r4, _0801A834 @ =0x000160a4 - adds r2, r1, r4 - movs r0, 0x10 - b _0801A94C - .align 2, 0 -_0801A824: .4byte gBattleTextBuff1 -_0801A828: .4byte gEffectBank -_0801A82C: .4byte 0x02000000 -_0801A830: .4byte 0x0001601e -_0801A834: .4byte 0x000160a4 -_0801A838: - movs r0, 0x58 - muls r0, r7 - mov r1, r8 - adds r5, r0, r1 - ldrh r4, [r5, 0x28] - ldrh r0, [r5, 0x2C] - mov r1, r9 - bl __divsi3 - cmp r4, r0 - ble _0801A850 - b _0801AD5A -_0801A850: - cmp r6, 0 - beq _0801A856 - b _0801AD5A -_0801A856: - movs r0, 0x1B - ldrsb r0, [r5, r0] - cmp r0, 0xB - ble _0801A860 - b _0801AD5A -_0801A860: - ldr r1, _0801A888 @ =gBattleTextBuff1 - movs r0, 0xFD - strb r0, [r1] - movs r0, 0x5 - strb r0, [r1, 0x1] - movs r0, 0x3 - strb r0, [r1, 0x2] - movs r0, 0xFF - strb r0, [r1, 0x3] - ldr r0, _0801A88C @ =gEffectBank - strb r7, [r0] - ldr r1, _0801A890 @ =0x02000000 - ldr r3, _0801A894 @ =0x0001601e - adds r2, r1, r3 - movs r0, 0x13 - strb r0, [r2] - ldr r4, _0801A898 @ =0x000160a4 - adds r2, r1, r4 - movs r0, 0x11 - b _0801A94C - .align 2, 0 -_0801A888: .4byte gBattleTextBuff1 -_0801A88C: .4byte gEffectBank -_0801A890: .4byte 0x02000000 -_0801A894: .4byte 0x0001601e -_0801A898: .4byte 0x000160a4 -_0801A89C: - movs r0, 0x58 - muls r0, r7 - mov r1, r8 - adds r5, r0, r1 - ldrh r4, [r5, 0x28] - ldrh r0, [r5, 0x2C] - mov r1, r9 - bl __divsi3 - cmp r4, r0 - ble _0801A8B4 - b _0801AD5A -_0801A8B4: - cmp r6, 0 - beq _0801A8BA - b _0801AD5A -_0801A8BA: - movs r0, 0x1C - ldrsb r0, [r5, r0] - cmp r0, 0xB - ble _0801A8C4 - b _0801AD5A -_0801A8C4: - ldr r1, _0801A8EC @ =gBattleTextBuff1 - movs r0, 0xFD - strb r0, [r1] - movs r0, 0x5 - strb r0, [r1, 0x1] - movs r0, 0x4 - strb r0, [r1, 0x2] - movs r0, 0xFF - strb r0, [r1, 0x3] - ldr r0, _0801A8F0 @ =gEffectBank - strb r7, [r0] - ldr r1, _0801A8F4 @ =0x02000000 - ldr r3, _0801A8F8 @ =0x0001601e - adds r2, r1, r3 - movs r0, 0x14 - strb r0, [r2] - ldr r4, _0801A8FC @ =0x000160a4 - adds r2, r1, r4 - movs r0, 0x12 - b _0801A94C - .align 2, 0 -_0801A8EC: .4byte gBattleTextBuff1 -_0801A8F0: .4byte gEffectBank -_0801A8F4: .4byte 0x02000000 -_0801A8F8: .4byte 0x0001601e -_0801A8FC: .4byte 0x000160a4 -_0801A900: - movs r0, 0x58 - muls r0, r7 - mov r1, r8 - adds r5, r0, r1 - ldrh r4, [r5, 0x28] - ldrh r0, [r5, 0x2C] - mov r1, r9 - bl __divsi3 - cmp r4, r0 - ble _0801A918 - b _0801AD5A -_0801A918: - cmp r6, 0 - beq _0801A91E - b _0801AD5A -_0801A91E: - movs r0, 0x1D - ldrsb r0, [r5, r0] - cmp r0, 0xB - ble _0801A928 - b _0801AD5A -_0801A928: - ldr r1, _0801A960 @ =gBattleTextBuff1 - movs r0, 0xFD - strb r0, [r1] - movs r0, 0x5 - strb r0, [r1, 0x1] - strb r0, [r1, 0x2] - movs r0, 0xFF - strb r0, [r1, 0x3] - ldr r0, _0801A964 @ =gEffectBank - strb r7, [r0] - ldr r1, _0801A968 @ =0x02000000 - ldr r3, _0801A96C @ =0x0001601e - adds r2, r1, r3 - movs r0, 0x15 - strb r0, [r2] - ldr r4, _0801A970 @ =0x000160a4 - adds r2, r1, r4 - movs r0, 0x13 -_0801A94C: - strb r0, [r2] - ldr r5, _0801A974 @ =0x000160a5 - adds r1, r5 - strb r6, [r1] - ldr r0, _0801A978 @ =gUnknown_081D9AFE - bl b_call_bc_move_exec - movs r0, 0x5 - str r0, [sp, 0xC] - b _0801AD62 - .align 2, 0 -_0801A960: .4byte gBattleTextBuff1 -_0801A964: .4byte gEffectBank -_0801A968: .4byte 0x02000000 -_0801A96C: .4byte 0x0001601e -_0801A970: .4byte 0x000160a4 -_0801A974: .4byte 0x000160a5 -_0801A978: .4byte gUnknown_081D9AFE -_0801A97C: - movs r0, 0x58 - adds r5, r7, 0 - muls r5, r0 - mov r1, r8 - adds r0, r5, r1 - ldrh r4, [r0, 0x28] - ldrh r0, [r0, 0x2C] - mov r1, r9 - bl __divsi3 - cmp r4, r0 - ble _0801A996 - b _0801AD5A -_0801A996: - cmp r6, 0 - beq _0801A99C - b _0801AD5A -_0801A99C: - mov r0, r8 - adds r0, 0x50 - adds r1, r5, r0 - ldr r2, [r1] - movs r3, 0x80 - lsls r3, 13 - adds r0, r2, 0 - ands r0, r3 - cmp r0, 0 - beq _0801A9B2 - b _0801AD5A -_0801A9B2: - orrs r2, r3 - str r2, [r1] - ldr r0, _0801A9C4 @ =gUnknown_081D9B19 - bl b_call_bc_move_exec - movs r2, 0x2 - str r2, [sp, 0xC] - b _0801AD62 - .align 2, 0 -_0801A9C4: .4byte gUnknown_081D9B19 -_0801A9C8: - cmp r6, 0 - beq _0801A9CE - b _0801AD5A -_0801A9CE: - movs r0, 0x58 - adds r5, r7, 0 - muls r5, r0 - mov r3, r8 - adds r0, r5, r3 - ldrh r4, [r0, 0x28] - ldrh r0, [r0, 0x2C] - mov r1, r9 - bl __divsi3 - cmp r4, r0 - ble _0801A9E8 - b _0801AD5A -_0801A9E8: - movs r4, 0 - mov r10, r4 - adds r0, r5, 0x1 - mov r1, r8 - adds r1, 0x18 - adds r0, r1 - ldrb r0, [r0] - lsls r0, 24 - asrs r0, 24 - cmp r0, 0xB - ble _0801AA18 - mov r0, r8 - adds r0, 0x19 - adds r1, r5, r0 -_0801AA04: - adds r1, 0x1 - movs r5, 0x1 - add r10, r5 - mov r0, r10 - cmp r0, 0x4 - bgt _0801AA18 - movs r0, 0 - ldrsb r0, [r1, r0] - cmp r0, 0xB - bgt _0801AA04 -_0801AA18: - mov r1, r10 - cmp r1, 0x5 - bne _0801AA20 - b _0801AD5A -_0801AA20: - movs r0, 0x58 - muls r0, r7 - adds r4, r0, 0x1 - ldr r5, _0801AAA4 @ =gUnknown_02024A98 -_0801AA28: - bl Random - lsls r0, 16 - lsrs r0, 16 - movs r1, 0x5 - bl __umodsi3 - lsls r0, 16 - lsrs r0, 16 - mov r10, r0 - adds r0, r4 - adds r0, r5 - ldrb r0, [r0] - lsls r0, 24 - asrs r0, 24 - cmp r0, 0xC - beq _0801AA28 - ldr r1, _0801AAA8 @ =gBattleTextBuff1 - movs r3, 0 - movs r2, 0xFD - strb r2, [r1] - movs r0, 0x5 - strb r0, [r1, 0x1] - mov r0, r10 - adds r0, 0x1 - strb r0, [r1, 0x2] - movs r0, 0xFF - strb r0, [r1, 0x3] - ldr r0, _0801AAAC @ =gBattleTextBuff2 - strb r2, [r0] - strb r3, [r0, 0x1] - movs r1, 0xD1 - strb r1, [r0, 0x2] - strb r3, [r0, 0x3] - strb r3, [r0, 0x4] - movs r1, 0xD2 - strb r1, [r0, 0x5] - strb r3, [r0, 0x6] - subs r1, 0xD3 - strb r1, [r0, 0x7] - ldr r0, _0801AAB0 @ =gEffectBank - strb r7, [r0] - ldr r1, _0801AAB4 @ =0x02000000 - mov r2, r10 - adds r2, 0x21 - ldr r4, _0801AAB8 @ =0x0001601e - adds r0, r1, r4 - strb r2, [r0] - adds r2, 0x6 - ldr r5, _0801AABC @ =0x000160a4 - adds r0, r1, r5 - strb r2, [r0] - ldr r0, _0801AAC0 @ =0x000160a5 - adds r1, r0 - strb r3, [r1] - ldr r0, _0801AAC4 @ =gUnknown_081D9AFE - bl b_call_bc_move_exec - movs r1, 0x5 - str r1, [sp, 0xC] - b _0801AD62 - .align 2, 0 -_0801AAA4: .4byte gUnknown_02024A98 -_0801AAA8: .4byte gBattleTextBuff1 -_0801AAAC: .4byte gBattleTextBuff2 -_0801AAB0: .4byte gEffectBank -_0801AAB4: .4byte 0x02000000 -_0801AAB8: .4byte 0x0001601e -_0801AABC: .4byte 0x000160a4 -_0801AAC0: .4byte 0x000160a5 -_0801AAC4: .4byte gUnknown_081D9AFE -_0801AAC8: - movs r0, 0x58 - adds r1, r7, 0 - muls r1, r0 - mov r0, r8 - adds r0, 0x4C - adds r1, r0 - ldr r2, [r1] - movs r0, 0x40 - ands r0, r2 - cmp r0, 0 - bne _0801AAE0 - b _0801AD5A -_0801AAE0: - movs r0, 0x41 - negs r0, r0 - ands r2, r0 - str r2, [r1] - ldr r0, _0801AAF4 @ =gUnknown_081D99B6 - bl b_call_bc_move_exec - movs r2, 0x1 - str r2, [sp, 0xC] - b _0801AD62 - .align 2, 0 -_0801AAF4: .4byte gUnknown_081D99B6 -_0801AAF8: - movs r0, 0x58 - adds r1, r7, 0 - muls r1, r0 - mov r0, r8 - adds r0, 0x4C - adds r1, r0 - ldr r2, [r1] - movs r0, 0x88 - ands r0, r2 - cmp r0, 0 - bne _0801AB10 - b _0801AD5A -_0801AB10: - ldr r0, _0801AB24 @ =0xfffff077 - ands r2, r0 - str r2, [r1] - ldr r0, _0801AB28 @ =gUnknown_081D99CE - bl b_call_bc_move_exec - movs r3, 0x1 - str r3, [sp, 0xC] - b _0801AD62 - .align 2, 0 -_0801AB24: .4byte 0xfffff077 -_0801AB28: .4byte gUnknown_081D99CE -_0801AB2C: - movs r0, 0x58 - adds r1, r7, 0 - muls r1, r0 - mov r0, r8 - adds r0, 0x4C - adds r1, r0 - ldr r2, [r1] - movs r0, 0x10 - ands r0, r2 - cmp r0, 0 - bne _0801AB44 - b _0801AD5A -_0801AB44: - movs r0, 0x11 - negs r0, r0 - ands r2, r0 - str r2, [r1] - ldr r0, _0801AB58 @ =gUnknown_081D99E6 - bl b_call_bc_move_exec - movs r4, 0x1 - str r4, [sp, 0xC] - b _0801AD62 - .align 2, 0 -_0801AB58: .4byte gUnknown_081D99E6 -_0801AB5C: - movs r0, 0x58 - adds r1, r7, 0 - muls r1, r0 - mov r0, r8 - adds r0, 0x4C - adds r1, r0 - ldr r2, [r1] - movs r0, 0x20 - ands r0, r2 - cmp r0, 0 - bne _0801AB74 - b _0801AD5A -_0801AB74: - movs r0, 0x21 - negs r0, r0 - ands r2, r0 - str r2, [r1] - ldr r0, _0801AB80 @ =gUnknown_081D99FE - b _0801AD0E - .align 2, 0 -_0801AB80: .4byte gUnknown_081D99FE -_0801AB84: - movs r0, 0x58 - adds r3, r7, 0 - muls r3, r0 - mov r0, r8 - adds r0, 0x4C - adds r2, r3, r0 - ldr r1, [r2] - movs r0, 0x7 - ands r0, r1 - cmp r0, 0 - bne _0801AB9C - b _0801AD5A -_0801AB9C: - movs r0, 0x8 - negs r0, r0 - ands r1, r0 - str r1, [r2] - mov r1, r8 - adds r1, 0x50 - adds r1, r3, r1 - ldr r0, [r1] - ldr r2, _0801ABC0 @ =0xf7ffffff - ands r0, r2 - str r0, [r1] - ldr r0, _0801ABC4 @ =gUnknown_081D9A16 - bl b_call_bc_move_exec - movs r0, 0x1 - str r0, [sp, 0xC] - b _0801AD62 - .align 2, 0 -_0801ABC0: .4byte 0xf7ffffff -_0801ABC4: .4byte gUnknown_081D9A16 -_0801ABC8: - movs r0, 0x58 - adds r1, r7, 0 - muls r1, r0 - mov r0, r8 - adds r0, 0x50 - adds r1, r0 - ldr r2, [r1] - movs r0, 0x7 - ands r0, r2 - cmp r0, 0 - bne _0801ABE0 - b _0801AD5A -_0801ABE0: - movs r0, 0x8 - negs r0, r0 - ands r2, r0 - str r2, [r1] - ldr r0, _0801ABF4 @ =gUnknown_081D9A2E - bl b_call_bc_move_exec - movs r1, 0x2 - str r1, [sp, 0xC] - b _0801AD62 - .align 2, 0 -_0801ABF4: .4byte gUnknown_081D9A2E -_0801ABF8: - movs r0, 0x58 - adds r5, r7, 0 - muls r5, r0 - mov r0, r8 - adds r0, 0x4C - adds r4, r5, r0 - ldr r2, [r4] - ldrb r0, [r4] - cmp r0, 0 - bne _0801AC1E - mov r0, r8 - adds r0, 0x50 - adds r0, r5, r0 - ldr r0, [r0] - movs r1, 0x7 - ands r0, r1 - cmp r0, 0 - bne _0801AC1E - b _0801AD5A -_0801AC1E: - movs r3, 0 - mov r10, r3 - movs r0, 0x88 - ands r2, r0 - cmp r2, 0 - beq _0801AC36 - ldr r0, _0801ACC4 @ =gBattleTextBuff1 - ldr r1, _0801ACC8 @ =gStatusConditionString_PoisonJpn - bl StringCopy - movs r0, 0x1 - mov r10, r0 -_0801AC36: - ldr r0, [r4] - movs r1, 0x7 - mov r9, r1 - ands r0, r1 - mov r6, r8 - adds r6, 0x50 - cmp r0, 0 - beq _0801AC5C - adds r2, r5, r6 - ldr r0, [r2] - ldr r1, _0801ACCC @ =0xf7ffffff - ands r0, r1 - str r0, [r2] - ldr r0, _0801ACC4 @ =gBattleTextBuff1 - ldr r1, _0801ACD0 @ =gStatusConditionString_SleepJpn - bl StringCopy - movs r2, 0x1 - add r10, r2 -_0801AC5C: - ldr r0, [r4] - movs r1, 0x40 - ands r0, r1 - cmp r0, 0 - beq _0801AC72 - ldr r0, _0801ACC4 @ =gBattleTextBuff1 - ldr r1, _0801ACD4 @ =gStatusConditionString_ParalysisJpn - bl StringCopy - movs r3, 0x1 - add r10, r3 -_0801AC72: - ldr r0, [r4] - movs r1, 0x10 - ands r0, r1 - cmp r0, 0 - beq _0801AC88 - ldr r0, _0801ACC4 @ =gBattleTextBuff1 - ldr r1, _0801ACD8 @ =gStatusConditionString_BurnJpn - bl StringCopy - movs r0, 0x1 - add r10, r0 -_0801AC88: - ldr r0, [r4] - movs r1, 0x20 - ands r0, r1 - cmp r0, 0 - beq _0801AC9E - ldr r0, _0801ACC4 @ =gBattleTextBuff1 - ldr r1, _0801ACDC @ =gStatusConditionString_IceJpn - bl StringCopy - movs r1, 0x1 - add r10, r1 -_0801AC9E: - adds r0, r5, r6 - ldr r0, [r0] - mov r2, r9 - ands r0, r2 - cmp r0, 0 - beq _0801ACB6 - ldr r0, _0801ACC4 @ =gBattleTextBuff1 - ldr r1, _0801ACE0 @ =gStatusConditionString_ConfusionJpn - bl StringCopy - movs r3, 0x1 - add r10, r3 -_0801ACB6: - mov r4, r10 - cmp r4, 0x1 - bgt _0801ACE8 - ldr r1, _0801ACE4 @ =gBattleCommunication - movs r0, 0 - b _0801ACEC - .align 2, 0 -_0801ACC4: .4byte gBattleTextBuff1 -_0801ACC8: .4byte gStatusConditionString_PoisonJpn -_0801ACCC: .4byte 0xf7ffffff -_0801ACD0: .4byte gStatusConditionString_SleepJpn -_0801ACD4: .4byte gStatusConditionString_ParalysisJpn -_0801ACD8: .4byte gStatusConditionString_BurnJpn -_0801ACDC: .4byte gStatusConditionString_IceJpn -_0801ACE0: .4byte gStatusConditionString_ConfusionJpn -_0801ACE4: .4byte gBattleCommunication -_0801ACE8: - ldr r1, _0801AD18 @ =gBattleCommunication - movs r0, 0x1 -_0801ACEC: - strb r0, [r1, 0x5] - ldr r2, _0801AD1C @ =gBattleMons - movs r0, 0x58 - adds r3, r7, 0 - muls r3, r0 - adds r0, r2, 0 - adds r0, 0x4C - adds r0, r3, r0 - movs r1, 0 - str r1, [r0] - adds r2, 0x50 - adds r3, r2 - ldr r0, [r3] - subs r1, 0x8 - ands r0, r1 - str r0, [r3] - ldr r0, _0801AD20 @ =gUnknown_081D9A44 -_0801AD0E: - bl b_call_bc_move_exec - movs r5, 0x1 - str r5, [sp, 0xC] - b _0801AD62 - .align 2, 0 -_0801AD18: .4byte gBattleCommunication -_0801AD1C: .4byte gBattleMons -_0801AD20: .4byte gUnknown_081D9A44 -_0801AD24: - movs r0, 0x58 - adds r1, r7, 0 - muls r1, r0 - mov r0, r8 - adds r0, 0x50 - adds r1, r0 - ldr r2, [r1] - movs r0, 0xF0 - lsls r0, 12 - ands r0, r2 - cmp r0, 0 - beq _0801AD5A - ldr r0, _0801AD84 @ =0xfff0ffff - ands r2, r0 - str r2, [r1] - ldr r0, _0801AD88 @ =gBattleTextBuff1 - ldr r1, _0801AD8C @ =gStatusConditionString_LoveJpn - bl StringCopy - ldr r0, _0801AD90 @ =gUnknown_081D9A44 - bl b_call_bc_move_exec - ldr r1, _0801AD94 @ =gBattleCommunication - movs r0, 0 - strb r0, [r1, 0x5] - movs r0, 0x2 - str r0, [sp, 0xC] -_0801AD5A: - ldr r1, [sp, 0xC] - cmp r1, 0 - bne _0801AD62 - b _0801B3CA -_0801AD62: - ldr r0, _0801AD98 @ =0x02000000 - ldr r2, _0801AD9C @ =0x00016003 - adds r0, r2 - strb r7, [r0] - ldr r0, _0801ADA0 @ =gStringBank - strb r7, [r0] - ldr r4, _0801ADA4 @ =gActiveBank - ldr r0, _0801ADA8 @ =gBankAttacker - strb r7, [r0] - strb r7, [r4] - ldr r3, [sp, 0xC] - cmp r3, 0x1 - beq _0801ADAC - cmp r3, 0x3 - beq _0801ADB2 - b _0801B3CA - .align 2, 0 -_0801AD84: .4byte 0xfff0ffff -_0801AD88: .4byte gBattleTextBuff1 -_0801AD8C: .4byte gStatusConditionString_LoveJpn -_0801AD90: .4byte gUnknown_081D9A44 -_0801AD94: .4byte gBattleCommunication -_0801AD98: .4byte 0x02000000 -_0801AD9C: .4byte 0x00016003 -_0801ADA0: .4byte gStringBank -_0801ADA4: .4byte gActiveBank -_0801ADA8: .4byte gBankAttacker -_0801ADAC: - movs r0, 0x58 - muls r0, r7 - b _0801B224 -_0801ADB2: - ldr r4, _0801AE00 @ =gBattleMons - movs r0, 0x58 - adds r3, r7, 0 - muls r3, r0 - adds r0, r4, 0 - adds r0, 0x50 - adds r0, r3, r0 - ldr r0, [r0] - movs r1, 0x80 - lsls r1, 14 - ands r0, r1 - cmp r0, 0 - beq _0801ADCE - b _0801B3CA -_0801ADCE: - ldr r1, _0801AE04 @ =gDisableStructs - lsls r0, r7, 3 - subs r0, r7 - lsls r0, 2 - adds r0, r1 - ldrb r1, [r0, 0x18] - lsrs r1, 4 - ldr r2, _0801AE08 @ =gBitTable - mov r5, r10 - lsls r0, r5, 2 - adds r0, r2 - ldr r0, [r0] - ands r1, r0 - cmp r1, 0 - beq _0801ADEE - b _0801B3CA -_0801ADEE: - adds r1, r5, r3 - adds r0, r4, 0 - adds r0, 0x24 - adds r1, r0 - add r0, sp, 0x4 - ldrb r0, [r0] - strb r0, [r1] - b _0801B3CA - .align 2, 0 -_0801AE00: .4byte gBattleMons -_0801AE04: .4byte gDisableStructs -_0801AE08: .4byte gBitTable -_0801AE0C: - movs r7, 0 - ldr r0, _0801AE3C @ =gNoOfAllBanks - ldrb r0, [r0] - cmp r7, r0 - bcc _0801AE18 - b _0801B3CA -_0801AE18: - ldr r4, _0801AE40 @ =gLastUsedItem - ldr r1, _0801AE44 @ =gBattleMons - movs r0, 0x58 - muls r0, r7 - adds r0, r1 - ldrh r0, [r0, 0x2E] - strh r0, [r4] - lsls r0, 16 - lsrs r0, 16 - cmp r0, 0xAF - bne _0801AE4C - ldr r1, _0801AE48 @ =gEnigmaBerries - lsls r0, r7, 3 - subs r0, r7 - lsls r0, 2 - adds r0, r1 - ldrb r5, [r0, 0x7] - b _0801AE5C - .align 2, 0 -_0801AE3C: .4byte gNoOfAllBanks -_0801AE40: .4byte gLastUsedItem -_0801AE44: .4byte gBattleMons -_0801AE48: .4byte gEnigmaBerries -_0801AE4C: - ldrh r0, [r4] - bl ItemId_GetHoldEffect - lsls r0, 24 - lsrs r5, r0, 24 - ldrh r0, [r4] - bl ItemId_GetHoldEffectParam -_0801AE5C: - subs r0, r5, 0x2 - cmp r0, 0x1A - bls _0801AE64 - b _0801B208 -_0801AE64: - lsls r0, 2 - ldr r1, _0801AE70 @ =_0801AE74 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .align 2, 0 -_0801AE70: .4byte _0801AE74 - .align 2, 0 -_0801AE74: - .4byte _0801AEE0 - .4byte _0801AFC8 - .4byte _0801AF1C - .4byte _0801AF58 - .4byte _0801AF94 - .4byte _0801B208 - .4byte _0801B018 - .4byte _0801B0AC - .4byte _0801B208 - .4byte _0801B208 - .4byte _0801B208 - .4byte _0801B208 - .4byte _0801B208 - .4byte _0801B208 - .4byte _0801B208 - .4byte _0801B208 - .4byte _0801B208 - .4byte _0801B208 - .4byte _0801B208 - .4byte _0801B208 - .4byte _0801B208 - .4byte _0801B1A0 - .4byte _0801B208 - .4byte _0801B208 - .4byte _0801B208 - .4byte _0801B208 - .4byte _0801B054 -_0801AEE0: - ldr r1, _0801AF10 @ =gBattleMons - movs r0, 0x58 - muls r0, r7 - adds r1, 0x4C - adds r2, r0, r1 - ldr r1, [r2] - movs r0, 0x40 - ands r0, r1 - cmp r0, 0 - bne _0801AEF6 - b _0801B208 -_0801AEF6: - movs r0, 0x41 - negs r0, r0 - ands r1, r0 - str r1, [r2] - bl b_movescr_stack_push_cursor - ldr r1, _0801AF14 @ =gBattlescriptCurrInstr - ldr r0, _0801AF18 @ =gUnknown_081D99BC - str r0, [r1] - movs r0, 0x1 - str r0, [sp, 0xC] - b _0801B20E - .align 2, 0 -_0801AF10: .4byte gBattleMons -_0801AF14: .4byte gBattlescriptCurrInstr -_0801AF18: .4byte gUnknown_081D99BC -_0801AF1C: - ldr r1, _0801AF48 @ =gBattleMons - movs r0, 0x58 - muls r0, r7 - adds r1, 0x4C - adds r2, r0, r1 - ldr r1, [r2] - movs r0, 0x88 - ands r0, r1 - cmp r0, 0 - bne _0801AF32 - b _0801B208 -_0801AF32: - ldr r0, _0801AF4C @ =0xfffff077 - ands r1, r0 - str r1, [r2] - bl b_movescr_stack_push_cursor - ldr r1, _0801AF50 @ =gBattlescriptCurrInstr - ldr r0, _0801AF54 @ =gUnknown_081D99D4 - str r0, [r1] - movs r1, 0x1 - str r1, [sp, 0xC] - b _0801B20E - .align 2, 0 -_0801AF48: .4byte gBattleMons -_0801AF4C: .4byte 0xfffff077 -_0801AF50: .4byte gBattlescriptCurrInstr -_0801AF54: .4byte gUnknown_081D99D4 -_0801AF58: - ldr r1, _0801AF88 @ =gBattleMons - movs r0, 0x58 - muls r0, r7 - adds r1, 0x4C - adds r2, r0, r1 - ldr r1, [r2] - movs r0, 0x10 - ands r0, r1 - cmp r0, 0 - bne _0801AF6E - b _0801B208 -_0801AF6E: - movs r0, 0x11 - negs r0, r0 - ands r1, r0 - str r1, [r2] - bl b_movescr_stack_push_cursor - ldr r1, _0801AF8C @ =gBattlescriptCurrInstr - ldr r0, _0801AF90 @ =gUnknown_081D99EC - str r0, [r1] - movs r2, 0x1 - str r2, [sp, 0xC] - b _0801B20E - .align 2, 0 -_0801AF88: .4byte gBattleMons -_0801AF8C: .4byte gBattlescriptCurrInstr -_0801AF90: .4byte gUnknown_081D99EC -_0801AF94: - ldr r1, _0801AFBC @ =gBattleMons - movs r0, 0x58 - muls r0, r7 - adds r1, 0x4C - adds r2, r0, r1 - ldr r1, [r2] - movs r0, 0x20 - ands r0, r1 - cmp r0, 0 - bne _0801AFAA - b _0801B208 -_0801AFAA: - movs r0, 0x21 - negs r0, r0 - ands r1, r0 - str r1, [r2] - bl b_movescr_stack_push_cursor - ldr r1, _0801AFC0 @ =gBattlescriptCurrInstr - ldr r0, _0801AFC4 @ =gUnknown_081D9A04 - b _0801B168 - .align 2, 0 -_0801AFBC: .4byte gBattleMons -_0801AFC0: .4byte gBattlescriptCurrInstr -_0801AFC4: .4byte gUnknown_081D9A04 -_0801AFC8: - ldr r2, _0801B008 @ =gBattleMons - movs r0, 0x58 - adds r4, r7, 0 - muls r4, r0 - adds r0, r2, 0 - adds r0, 0x4C - adds r3, r4, r0 - ldr r1, [r3] - movs r0, 0x7 - ands r0, r1 - cmp r0, 0 - bne _0801AFE2 - b _0801B208 -_0801AFE2: - movs r0, 0x8 - negs r0, r0 - ands r1, r0 - str r1, [r3] - adds r2, 0x50 - adds r2, r4, r2 - ldr r0, [r2] - ldr r1, _0801B00C @ =0xf7ffffff - ands r0, r1 - str r0, [r2] - bl b_movescr_stack_push_cursor - ldr r1, _0801B010 @ =gBattlescriptCurrInstr - ldr r0, _0801B014 @ =gUnknown_081D9A1C - str r0, [r1] - movs r4, 0x1 - str r4, [sp, 0xC] - b _0801B20E - .align 2, 0 -_0801B008: .4byte gBattleMons -_0801B00C: .4byte 0xf7ffffff -_0801B010: .4byte gBattlescriptCurrInstr -_0801B014: .4byte gUnknown_081D9A1C -_0801B018: - ldr r1, _0801B048 @ =gBattleMons - movs r0, 0x58 - muls r0, r7 - adds r1, 0x50 - adds r2, r0, r1 - ldr r1, [r2] - movs r0, 0x7 - ands r0, r1 - cmp r0, 0 - bne _0801B02E - b _0801B208 -_0801B02E: - movs r0, 0x8 - negs r0, r0 - ands r1, r0 - str r1, [r2] - bl b_movescr_stack_push_cursor - ldr r1, _0801B04C @ =gBattlescriptCurrInstr - ldr r0, _0801B050 @ =gUnknown_081D9A34 - str r0, [r1] - movs r5, 0x2 - str r5, [sp, 0xC] - b _0801B20E - .align 2, 0 -_0801B048: .4byte gBattleMons -_0801B04C: .4byte gBattlescriptCurrInstr -_0801B050: .4byte gUnknown_081D9A34 -_0801B054: - ldr r1, _0801B090 @ =gBattleMons - movs r0, 0x58 - muls r0, r7 - adds r1, 0x50 - adds r2, r0, r1 - ldr r1, [r2] - movs r0, 0xF0 - lsls r0, 12 - ands r0, r1 - cmp r0, 0 - bne _0801B06C - b _0801B208 -_0801B06C: - ldr r0, _0801B094 @ =0xfff0ffff - ands r1, r0 - str r1, [r2] - ldr r0, _0801B098 @ =gBattleTextBuff1 - ldr r1, _0801B09C @ =gStatusConditionString_LoveJpn - bl StringCopy - bl b_movescr_stack_push_cursor - ldr r1, _0801B0A0 @ =gBattleCommunication - movs r0, 0 - strb r0, [r1, 0x5] - ldr r1, _0801B0A4 @ =gBattlescriptCurrInstr - ldr r0, _0801B0A8 @ =gUnknown_081D9A4A - str r0, [r1] - movs r0, 0x2 - str r0, [sp, 0xC] - b _0801B20E - .align 2, 0 -_0801B090: .4byte gBattleMons -_0801B094: .4byte 0xfff0ffff -_0801B098: .4byte gBattleTextBuff1 -_0801B09C: .4byte gStatusConditionString_LoveJpn -_0801B0A0: .4byte gBattleCommunication -_0801B0A4: .4byte gBattlescriptCurrInstr -_0801B0A8: .4byte gUnknown_081D9A4A -_0801B0AC: - ldr r4, _0801B170 @ =gBattleMons - movs r0, 0x58 - adds r5, r7, 0 - muls r5, r0 - adds r0, r4, 0 - adds r0, 0x4C - adds r6, r5, r0 - ldr r2, [r6] - ldrb r0, [r6] - cmp r0, 0 - bne _0801B0D4 - adds r0, r4, 0 - adds r0, 0x50 - adds r0, r5, r0 - ldr r0, [r0] - movs r1, 0x7 - ands r0, r1 - cmp r0, 0 - bne _0801B0D4 - b _0801B208 -_0801B0D4: - movs r0, 0x88 - ands r2, r0 - cmp r2, 0 - beq _0801B0E4 - ldr r0, _0801B174 @ =gBattleTextBuff1 - ldr r1, _0801B178 @ =gStatusConditionString_PoisonJpn - bl StringCopy -_0801B0E4: - ldr r0, [r6] - movs r1, 0x7 - mov r8, r1 - ands r0, r1 - adds r4, 0x50 - cmp r0, 0 - beq _0801B104 - adds r2, r5, r4 - ldr r0, [r2] - ldr r1, _0801B17C @ =0xf7ffffff - ands r0, r1 - str r0, [r2] - ldr r0, _0801B174 @ =gBattleTextBuff1 - ldr r1, _0801B180 @ =gStatusConditionString_SleepJpn - bl StringCopy -_0801B104: - ldr r0, [r6] - movs r1, 0x40 - ands r0, r1 - cmp r0, 0 - beq _0801B116 - ldr r0, _0801B174 @ =gBattleTextBuff1 - ldr r1, _0801B184 @ =gStatusConditionString_ParalysisJpn - bl StringCopy -_0801B116: - ldr r0, [r6] - movs r1, 0x10 - ands r0, r1 - cmp r0, 0 - beq _0801B128 - ldr r0, _0801B174 @ =gBattleTextBuff1 - ldr r1, _0801B188 @ =gStatusConditionString_BurnJpn - bl StringCopy -_0801B128: - ldr r0, [r6] - movs r1, 0x20 - ands r0, r1 - cmp r0, 0 - beq _0801B13A - ldr r0, _0801B174 @ =gBattleTextBuff1 - ldr r1, _0801B18C @ =gStatusConditionString_IceJpn - bl StringCopy -_0801B13A: - adds r5, r4 - ldr r0, [r5] - mov r2, r8 - ands r0, r2 - cmp r0, 0 - beq _0801B14E - ldr r0, _0801B174 @ =gBattleTextBuff1 - ldr r1, _0801B190 @ =gStatusConditionString_ConfusionJpn - bl StringCopy -_0801B14E: - movs r4, 0 - str r4, [r6] - ldr r0, [r5] - movs r1, 0x8 - negs r1, r1 - ands r0, r1 - str r0, [r5] - bl b_movescr_stack_push_cursor - ldr r0, _0801B194 @ =gBattleCommunication - strb r4, [r0, 0x5] - ldr r1, _0801B198 @ =gBattlescriptCurrInstr - ldr r0, _0801B19C @ =gUnknown_081D9A4A -_0801B168: - str r0, [r1] - movs r3, 0x1 - str r3, [sp, 0xC] - b _0801B20E - .align 2, 0 -_0801B170: .4byte gBattleMons -_0801B174: .4byte gBattleTextBuff1 -_0801B178: .4byte gStatusConditionString_PoisonJpn -_0801B17C: .4byte 0xf7ffffff -_0801B180: .4byte gStatusConditionString_SleepJpn -_0801B184: .4byte gStatusConditionString_ParalysisJpn -_0801B188: .4byte gStatusConditionString_BurnJpn -_0801B18C: .4byte gStatusConditionString_IceJpn -_0801B190: .4byte gStatusConditionString_ConfusionJpn -_0801B194: .4byte gBattleCommunication -_0801B198: .4byte gBattlescriptCurrInstr -_0801B19C: .4byte gUnknown_081D9A4A -_0801B1A0: - ldr r4, _0801B1F0 @ =gBattleMons - mov r8, r4 - movs r0, 0x58 - adds r1, r7, 0 - muls r1, r0 - mov r0, r8 - adds r0, 0x18 - adds r1, r0 - movs r2, 0x6 - movs r5, 0x7 - mov r10, r5 -_0801B1B6: - movs r0, 0 - ldrsb r0, [r1, r0] - cmp r0, 0x5 - bgt _0801B1C4 - strb r2, [r1] - movs r0, 0x5 - str r0, [sp, 0xC] -_0801B1C4: - adds r1, 0x1 - movs r3, 0x1 - negs r3, r3 - add r10, r3 - mov r4, r10 - cmp r4, 0 - bge _0801B1B6 - ldr r5, [sp, 0xC] - cmp r5, 0 - beq _0801B254 - ldr r0, _0801B1F4 @ =0x02000000 - ldr r1, _0801B1F8 @ =0x00016003 - adds r0, r1 - strb r7, [r0] - ldr r0, _0801B1FC @ =gStringBank - strb r7, [r0] - bl b_movescr_stack_push_cursor - ldr r1, _0801B200 @ =gBattlescriptCurrInstr - ldr r0, _0801B204 @ =gUnknown_081D9A64 - str r0, [r1] - b _0801B3CA - .align 2, 0 -_0801B1F0: .4byte gBattleMons -_0801B1F4: .4byte 0x02000000 -_0801B1F8: .4byte 0x00016003 -_0801B1FC: .4byte gStringBank -_0801B200: .4byte gBattlescriptCurrInstr -_0801B204: .4byte gUnknown_081D9A64 -_0801B208: - ldr r2, [sp, 0xC] - cmp r2, 0 - beq _0801B254 -_0801B20E: - ldr r0, _0801B240 @ =0x02000000 - ldr r3, _0801B244 @ =0x00016003 - adds r0, r3 - strb r7, [r0] - ldr r0, _0801B248 @ =gStringBank - strb r7, [r0] - ldr r4, _0801B24C @ =gActiveBank - strb r7, [r4] - ldrb r1, [r4] - movs r0, 0x58 - muls r0, r1 -_0801B224: - ldr r1, _0801B250 @ =gUnknown_02024ACC - adds r0, r1 - str r0, [sp] - movs r0, 0 - movs r1, 0x28 - movs r2, 0 - movs r3, 0x4 - bl EmitSetAttributes - ldrb r0, [r4] - bl MarkBufferBankForExecution - b _0801B3CA - .align 2, 0 -_0801B240: .4byte 0x02000000 -_0801B244: .4byte 0x00016003 -_0801B248: .4byte gStringBank -_0801B24C: .4byte gActiveBank -_0801B250: .4byte gUnknown_02024ACC -_0801B254: - adds r0, r7, 0x1 - lsls r0, 24 - lsrs r7, r0, 24 - ldr r0, _0801B268 @ =gNoOfAllBanks - ldrb r0, [r0] - cmp r7, r0 - bcs _0801B264 - b _0801AE18 -_0801B264: - b _0801B3CA - .align 2, 0 -_0801B268: .4byte gNoOfAllBanks -_0801B26C: - ldr r7, _0801B284 @ =gBattleMoveDamage - ldr r0, [r7] - cmp r0, 0 - bne _0801B276 - b _0801B3CA -_0801B276: - mov r4, r8 - cmp r4, 0x1E - beq _0801B288 - cmp r4, 0x3E - beq _0801B330 - b _0801B3CA - .align 2, 0 -_0801B284: .4byte gBattleMoveDamage -_0801B288: - ldr r0, _0801B314 @ =gBattleMoveFlags - ldrb r1, [r0] - movs r0, 0x29 - ands r0, r1 - cmp r0, 0 - beq _0801B296 - b _0801B3CA -_0801B296: - ldr r2, _0801B318 @ =gSpecialStatuses - ldr r4, _0801B31C @ =gBankTarget - ldrb r1, [r4] - lsls r0, r1, 2 - adds r0, r1 - lsls r1, r0, 2 - adds r0, r2, 0 - adds r0, 0x8 - adds r0, r1, r0 - ldr r0, [r0] - cmp r0, 0 - bne _0801B2BC - adds r0, r2, 0 - adds r0, 0xC - adds r0, r1, r0 - ldr r0, [r0] - cmp r0, 0 - bne _0801B2BC - b _0801B3CA -_0801B2BC: - bl Random - lsls r0, 16 - lsrs r0, 16 - movs r1, 0x64 - bl __umodsi3 - lsls r0, 16 - lsrs r0, 16 - cmp r0, r9 - bcs _0801B3CA - ldr r2, _0801B320 @ =gBattleMoves - ldr r0, _0801B324 @ =gCurrentMove - ldrh r1, [r0] - lsls r0, r1, 1 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - ldrb r1, [r0, 0x8] - movs r0, 0x20 - ands r0, r1 - cmp r0, 0 - beq _0801B3CA - ldr r2, _0801B328 @ =gBattleMons - ldrb r1, [r4] - movs r0, 0x58 - muls r0, r1 - adds r0, r2 - ldrh r0, [r0, 0x28] - cmp r0, 0 - beq _0801B3CA - ldr r1, _0801B32C @ =gBattleCommunication - movs r0, 0x8 - strb r0, [r1, 0x3] - bl b_movescr_stack_push_cursor - movs r0, 0 - movs r1, 0 - bl SetMoveEffect - bl b_movescr_stack_pop_cursor - b _0801B3CA - .align 2, 0 -_0801B314: .4byte gBattleMoveFlags -_0801B318: .4byte gSpecialStatuses -_0801B31C: .4byte gBankTarget -_0801B320: .4byte gBattleMoves -_0801B324: .4byte gCurrentMove -_0801B328: .4byte gBattleMons -_0801B32C: .4byte gBattleCommunication -_0801B330: - ldr r0, _0801B3DC @ =gBattleMoveFlags - ldrb r0, [r0] - movs r4, 0x29 - ands r4, r0 - cmp r4, 0 - bne _0801B3CA - ldr r1, _0801B3E0 @ =gSpecialStatuses - ldr r5, _0801B3E4 @ =gBankTarget - ldrb r2, [r5] - lsls r0, r2, 2 - adds r0, r2 - lsls r0, 2 - adds r6, r1, 0x4 - adds r0, r6 - ldr r1, [r0] - cmp r1, 0 - beq _0801B3CA - ldr r0, _0801B3E8 @ =0x0000ffff - cmp r1, r0 - beq _0801B3CA - ldr r0, _0801B3EC @ =gBankAttacker - ldrb r3, [r0] - cmp r3, r2 - beq _0801B3CA - ldr r2, _0801B3F0 @ =gBattleMons - ldrb r1, [r0] - movs r0, 0x58 - muls r0, r1 - adds r0, r2 - ldrh r1, [r0, 0x28] - ldrh r0, [r0, 0x2C] - cmp r1, r0 - beq _0801B3CA - cmp r1, 0 - beq _0801B3CA - ldr r0, _0801B3F4 @ =gLastUsedItem - mov r1, sp - ldrh r1, [r1, 0x14] - strh r1, [r0] - ldr r0, _0801B3F8 @ =gStringBank - strb r3, [r0] - ldr r0, _0801B3FC @ =0x02000000 - ldr r2, _0801B400 @ =0x00016003 - adds r0, r2 - strb r3, [r0] - ldrb r1, [r5] - lsls r0, r1, 2 - adds r0, r1 - lsls r0, 2 - adds r0, r6 - ldr r0, [r0] - ldr r1, [sp, 0x10] - bl __divsi3 - negs r0, r0 - str r0, [r7] - ldrb r1, [r5] - cmp r0, 0 - bne _0801B3AC - movs r0, 0x1 - negs r0, r0 - str r0, [r7] -_0801B3AC: - lsls r0, r1, 2 - adds r0, r1 - lsls r0, 2 - adds r0, r6 - str r4, [r0] - bl b_movescr_stack_push_cursor - ldr r1, _0801B404 @ =gBattlescriptCurrInstr - ldr r0, _0801B408 @ =gUnknown_081D9AA7 - str r0, [r1] - ldr r0, [sp, 0xC] - adds r0, 0x1 - lsls r0, 24 - lsrs r0, 24 - str r0, [sp, 0xC] -_0801B3CA: - ldr r0, [sp, 0xC] - add sp, 0x2C - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r1} - bx r1 - .align 2, 0 -_0801B3DC: .4byte gBattleMoveFlags -_0801B3E0: .4byte gSpecialStatuses -_0801B3E4: .4byte gBankTarget -_0801B3E8: .4byte 0x0000ffff -_0801B3EC: .4byte gBankAttacker -_0801B3F0: .4byte gBattleMons -_0801B3F4: .4byte gLastUsedItem -_0801B3F8: .4byte gStringBank -_0801B3FC: .4byte 0x02000000 -_0801B400: .4byte 0x00016003 -_0801B404: .4byte gBattlescriptCurrInstr -_0801B408: .4byte gUnknown_081D9AA7 - thumb_func_end ItemBattleEffects - thumb_func_start unref_sub_801B40C unref_sub_801B40C: @ 801B40C push {r4-r7,lr} diff --git a/include/battle.h b/include/battle.h index 44b7c048a..0f1a5f26b 100644 --- a/include/battle.h +++ b/include/battle.h @@ -34,7 +34,9 @@ #define STATUS_FREEZE 0x20 #define STATUS_PARALYSIS 0x40 #define STATUS_TOXIC_POISON 0x80 +#define STATUS_TOXIC_COUNTER 0xF00 +#define STATUS_PSN_ANY ((STATUS_POISON | STATUS_TOXIC_POISON)) #define STATUS_ANY ((STATUS_SLEEP | STATUS_POISON | STATUS_BURN | STATUS_FREEZE | STATUS_PARALYSIS | STATUS_TOXIC_POISON)) #define STATUS2_CONFUSION 0x00000007 @@ -597,9 +599,9 @@ struct SpecialStatus u8 flag40 : 1; u8 focusBanded : 1; u8 field1[3]; - u32 moveturnLostHP; - u32 moveturnLostHP_physical; - u32 moveturnLostHP_special; + s32 moveturnLostHP; + s32 moveturnLostHP_physical; + s32 moveturnLostHP_special; u8 moveturnPhysicalBank; u8 moveturnSpecialBank; u8 field12; diff --git a/include/pokemon.h b/include/pokemon.h index 242d62029..21173d503 100644 --- a/include/pokemon.h +++ b/include/pokemon.h @@ -412,6 +412,7 @@ struct BattleMove #define FLAG_PROTECT_AFFECTED 0x2 #define FLAG_MAGICCOAT_AFFECTED 0x4 #define FLAG_SNATCH_AFFECTED 0x8 +#define FLAG_KINGSROCK_AFFECTED 0x20 struct PokemonStorage { diff --git a/src/battle_3.c b/src/battle_3.c index d08e760a6..d86b11fb9 100644 --- a/src/battle_3.c +++ b/src/battle_3.c @@ -16,7 +16,7 @@ extern u8* gBattlescriptCurrInstr; extern u8 gActiveBank; extern u8 gBattleBufferB[4][0x200]; -extern u8* gUnknown_02024C1C[4]; //battlescript location when you try to use a move you're not allowed to +extern u8* gUnknown_02024C1C[4]; //battlescript location when you try to choose a move you're not allowed to extern u16 gLastUsedMove[4]; extern struct BattlePokemon gBattleMons[4]; extern struct BattleEnigmaBerry gEnigmaBerries[4]; @@ -46,6 +46,8 @@ extern u8 gTakenDmgBanks[4]; extern u8 gBattleMoveFlags; extern u8 gLastUsedAbility; extern u8 gBattleTextBuff2[]; +extern u8 gFightStateTracker; +extern struct BattleEnigmaBerry gEnigmaBerries[4]; u8 IsImprisoned(u8 bank, u16 move); u8 GetBankByPlayerAI(u8 ID); @@ -65,6 +67,9 @@ u16 sub_803FBFC(u8 a); u8 weather_get_current(void); void b_push_move_exec(u8* BS_ptr); void RecordAbilityBattle(u8 bank, u8 ability); +void RecordItemBattle(u8 bank, u8 holdEffect); +void sub_8013F54(void); +void sub_8013FBC(void); extern u8 BattleScript_MoveSelectionDisabledMove[]; extern u8 BattleScript_MoveSelectionTormented[]; @@ -1394,6 +1399,40 @@ extern u8 gUnknown_081D978C[]; //intimidate1 extern u8 gUnknown_081D9795[]; //intimidate2 extern u8 gUnknown_081D9726[]; //trace effect +extern u8 gUnknown_081D9A5E[]; //white herb end2 +extern u8 gUnknown_081D9A64[]; //white herb return +extern u8 gUnknown_081D9A74[]; //item hp heal end2 +extern u8 gUnknown_081D9A91[]; //berry pp heal end2 +extern u8 gUnknown_081D9AA1[]; //leftovers heal end2 +extern u8 gUnknown_081D9AD4[]; //berry heal/confuse end2 +extern u8 gUnknown_081D9AFE[]; //berry stat raise end2 +extern u8 gUnknown_081D9B19[]; //berry focus energy end2 +extern u8 gUnknown_081D99B6[]; //berry cure par end2 +extern u8 gUnknown_081D99CE[]; //berry cure psn end2 +extern u8 gUnknown_081D99E6[]; //berry cure brn end2 +extern u8 gUnknown_081D99FE[]; //berry cure frz end2 +extern u8 gUnknown_081D9A16[]; //berry cure slp end2 +extern u8 gUnknown_081D9A2E[]; //berry cure confusion end2 +extern u8 gUnknown_081D9A44[]; //berry cure any status end2 +extern u8 gUnknown_081D99BC[]; //berry cure par return +extern u8 gUnknown_081D99D4[]; //berry cure psn return +extern u8 gUnknown_081D99EC[]; //berry cure brn return +extern u8 gUnknown_081D9A04[]; //berry cure frz return +extern u8 gUnknown_081D9A1C[]; //berry cure slp return +extern u8 gUnknown_081D9A34[]; //berry cure confusion return +extern u8 gUnknown_081D9A4A[]; //berry cure any status return + +extern u8 gUnknown_081D9AA7[]; //shell bell hp heal + +#ifdef NONMATCHING + +struct Struct2017100 +{ + u32 arr[4]; +}; + +#define ewram17100 (*(struct Struct2017100 *)(ewram + 0x17100)) + u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) { u8 effect = 0; @@ -1426,9 +1465,12 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) if (!(gBattleTypeFlags & BATTLE_TYPE_SAFARI)) // why isn't that check done at the beginning? { + //_08018436 + int i; // r4 u16 move; - u8 moveType; - int i; + // Hmm... + #define moveType moveArg + //u16 moveType; u8 side; if (special) @@ -1436,21 +1478,27 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) else gLastUsedAbility = gBattleMons[bank].ability; - move = moveArg ? moveArg : gCurrentMove; + if (moveArg) + move = moveArg; + else + move = gCurrentMove; if (BATTLE_STRUCT->dynamicMoveType) moveType = BATTLE_STRUCT->dynamicMoveType & 0x3F; else moveType = gBattleMoves[move].type; + //_080184AC switch (caseID) { case ABILITYEFFECT_ON_SWITCHIN: // 0 + //_08018518 if (gBankAttacker >= gNoOfAllBanks) gBankAttacker = bank; switch (gLastUsedAbility) { case 0xFF: //weather from overworld + //_08018586 switch (weather_get_current()) { case 3: @@ -1490,6 +1538,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) } break; case ABILITY_DRIZZLE: + //_08018680 if (!(gBattleWeather & WEATHER_RAIN_PERMANENT)) { gBattleWeather = (WEATHER_RAIN_PERMANENT | WEATHER_RAIN_TEMPORARY); @@ -1499,6 +1548,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) } break; case ABILITY_SAND_STREAM: + //_080186B8 if (!(gBattleWeather & WEATHER_SANDSTORM_PERMANENT)) { gBattleWeather = (WEATHER_SANDSTORM_PERMANENT | WEATHER_SANDSTORM_TEMPORARY); @@ -1508,6 +1558,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) } break; case ABILITY_DROUGHT: + //_080186F0 if (!(gBattleWeather & WEATHER_SUN_PERMANENT)) { gBattleWeather = (WEATHER_SUN_PERMANENT | WEATHER_SUN_TEMPORARY); @@ -1517,6 +1568,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) } break; case ABILITY_INTIMIDATE: + //_08018728 if (!(gSpecialStatuses[bank].intimidatedPoke)) { gStatuses3[bank] |= STATUS3_INTIMIDATE_POKES; @@ -1524,7 +1576,9 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) } break; case ABILITY_FORECAST: - if ((effect = CastformDataTypeChange(bank))) + //_0801875C + effect = CastformDataTypeChange(bank); + if (effect != 0) { b_push_move_exec(gUnknown_081D977D); BATTLE_STRUCT->scriptingActive = bank; @@ -1532,6 +1586,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) } break; case ABILITY_TRACE: + //_080187A0 if (!(gSpecialStatuses[bank].traced)) { gStatuses3[bank] |= STATUS3_TRACE; @@ -1540,11 +1595,16 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) break; case ABILITY_CLOUD_NINE: case ABILITY_AIR_LOCK: + //_080187DC { u8 i; + for (i = 0; i < gNoOfAllBanks; i++) { - if ((effect = CastformDataTypeChange(i))) + // TODO: i should be in r6 here + //asm("":::"r4","r5"); + effect = CastformDataTypeChange(i); + if (effect != 0) { b_push_move_exec(gUnknown_081D977D); BATTLE_STRUCT->scriptingActive = i; @@ -1557,17 +1617,19 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) } break; case ABILITYEFFECT_ENDTURN: // 1 - if (gBattleMons[bank].hp) + //_08018814 + if (gBattleMons[bank].hp != 0) { gBankAttacker = bank; switch (gLastUsedAbility) { case ABILITY_RAIN_DISH: - if (WEATHER_HAS_EFFECT && gBattleWeather & WEATHER_RAIN_ANY && gBattleMons[bank].maxHP > gBattleMons[bank].hp) + if (WEATHER_HAS_EFFECT && (gBattleWeather & WEATHER_RAIN_ANY) + && gBattleMons[bank].maxHP > gBattleMons[bank].hp) { gLastUsedAbility = ABILITY_RAIN_DISH; //why b_push_move_exec(gUnknown_081D9730); - gBattleMoveDamage = gBattleMons[bank].hp / 16; + gBattleMoveDamage = gBattleMons[bank].maxHP / 16; if (gBattleMoveDamage == 0) gBattleMoveDamage = 1; gBattleMoveDamage *= -1; @@ -1575,7 +1637,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) } break; case ABILITY_SHED_SKIN: - if (gBattleMons[bank].status1 & STATUS_ANY && (Random() % 3) == 0) + if ((gBattleMons[bank].status1 & STATUS_ANY) && (Random() % 3) == 0) { if (gBattleMons[bank].status1 & (STATUS_POISON | STATUS_TOXIC_POISON)) StringCopy(gBattleTextBuff1, gStatusConditionString_PoisonJpn); @@ -1614,9 +1676,9 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) } break; case ABILITYEFFECT_MOVES_BLOCK: // 2 - switch (gLastUsedAbility) + //_08018A40 + if (gLastUsedAbility == ABILITY_SOUNDPROOF) { - case ABILITY_SOUNDPROOF: for (i = 0; gUnknown_081FA724[i] != 0xFFFF; i++) { if (gUnknown_081FA724[i] == move) @@ -1629,10 +1691,10 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) gBattlescriptCurrInstr = gUnknown_081D98F3; effect = 1; } - break; } break; case ABILITYEFFECT_ABSORBING: // 3 + //_08018AD8 if (move) { switch (gLastUsedAbility) @@ -1660,20 +1722,20 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) case ABILITY_FLASH_FIRE: if (moveType == TYPE_FIRE && !(gBattleMons[bank].status1 & STATUS_FREEZE)) { - if (!(ewram17000[bank] & 1)) + if (!(ewram17100.arr[bank] & 1)) { gBattleCommunication[MULTISTRING_CHOOSER] = 0; if (gProtectStructs[gBankAttacker].notFirstStrike) gBattlescriptCurrInstr = gUnknown_081D987C; else gBattlescriptCurrInstr = gUnknown_081D987B; - ewram17000[bank] |= 1; + ewram17100.arr[bank] |= 1; effect = 2; } else { gBattleCommunication[MULTISTRING_CHOOSER] = 1; - if (!(gProtectStructs[gBankAttacker].notFirstStrike)) + if (gProtectStructs[gBankAttacker].notFirstStrike) gBattlescriptCurrInstr = gUnknown_081D987C; else gBattlescriptCurrInstr = gUnknown_081D987B; @@ -1686,7 +1748,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) { if (gBattleMons[bank].maxHP == gBattleMons[bank].hp) { - if (!(gProtectStructs[gBankAttacker].notFirstStrike)) + if ((gProtectStructs[gBankAttacker].notFirstStrike)) gBattlescriptCurrInstr = gUnknown_081D9843; else gBattlescriptCurrInstr = gUnknown_081D9842; @@ -1702,12 +1764,18 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) } break; case ABILITYEFFECT_CONTACT: // 4 + //_08018CF0 switch (gLastUsedAbility) { case ABILITY_COLOR_CHANGE: - if (!(gBattleMoveFlags & MOVESTATUS_NOEFFECT) && move != MOVE_STRUGGLE && gBattleMoves[move].power != 0 - && (gSpecialStatuses[gBankTarget].moveturnLostHP_physical || gSpecialStatuses[gBankTarget].moveturnLostHP_special) - && gBattleMons[bank].type1 != moveType && gBattleMons[bank].type2 != moveType && gBattleMons[bank].hp) + //_08018DCC + if (!(gBattleMoveFlags & MOVESTATUS_NOEFFECT) + && move != MOVE_STRUGGLE + && gBattleMoves[move].power != 0 + && (gSpecialStatuses[gBankTarget].moveturnLostHP_physical || gSpecialStatuses[gBankTarget].moveturnLostHP_special) + && gBattleMons[bank].type1 != moveType + && gBattleMons[bank].type2 != moveType + && gBattleMons[bank].hp != 0) { gBattleMons[bank].type1 = moveType; gBattleMons[bank].type2 = moveType; @@ -1721,9 +1789,12 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) } break; case ABILITY_ROUGH_SKIN: - if (!(gBattleMoveFlags & MOVESTATUS_NOEFFECT) && gBattleMons[gBankAttacker].hp && !gProtectStructs[gBankAttacker].confusionSelfDmg - && (gSpecialStatuses[gBankTarget].moveturnLostHP_physical || gSpecialStatuses[gBankTarget].moveturnLostHP_special) - && gBattleMoves[move].flags & FLAG_MAKES_CONTACT) + //_08018E94 + if (!(gBattleMoveFlags & MOVESTATUS_NOEFFECT) + && gBattleMons[gBankAttacker].hp != 0 + && !gProtectStructs[gBankAttacker].confusionSelfDmg + && (gSpecialStatuses[gBankTarget].moveturnLostHP_physical || gSpecialStatuses[gBankTarget].moveturnLostHP_special) + && (gBattleMoves[move].flags & FLAG_MAKES_CONTACT)) { gBattleMoveDamage = gBattleMons[gBankAttacker].maxHP / 16; if (gBattleMoveDamage == 0) @@ -1734,9 +1805,13 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) } break; case ABILITY_EFFECT_SPORE: - if (!(gBattleMoveFlags & MOVESTATUS_NOEFFECT) && gBattleMons[gBankAttacker].hp && !gProtectStructs[gBankAttacker].confusionSelfDmg - && (gSpecialStatuses[gBankTarget].moveturnLostHP_physical || gSpecialStatuses[gBankTarget].moveturnLostHP_special) - && gBattleMoves[move].flags & FLAG_MAKES_CONTACT && (Random() % 10) == 0) + //_08018F54 + if (!(gBattleMoveFlags & MOVESTATUS_NOEFFECT) + && gBattleMons[gBankAttacker].hp != 0 + && !gProtectStructs[gBankAttacker].confusionSelfDmg + && (gSpecialStatuses[gBankTarget].moveturnLostHP_physical || gSpecialStatuses[gBankTarget].moveturnLostHP_special) + && (gBattleMoves[move].flags & FLAG_MAKES_CONTACT) + && (Random() % 10) == 0) { do { @@ -1752,11 +1827,15 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) } break; case ABILITY_POISON_POINT: - if (!(gBattleMoveFlags & MOVESTATUS_NOEFFECT) && gBattleMons[gBankAttacker].hp && !gProtectStructs[gBankAttacker].confusionSelfDmg - && (gSpecialStatuses[gBankTarget].moveturnLostHP_physical || gSpecialStatuses[gBankTarget].moveturnLostHP_special) - && gBattleMoves[move].flags & FLAG_MAKES_CONTACT && (Random() % 3) == 0) + //_0801904C + if (!(gBattleMoveFlags & MOVESTATUS_NOEFFECT) + && gBattleMons[gBankAttacker].hp != 0 + && !gProtectStructs[gBankAttacker].confusionSelfDmg + && (gSpecialStatuses[gBankTarget].moveturnLostHP_physical || gSpecialStatuses[gBankTarget].moveturnLostHP_special) + && (gBattleMoves[move].flags & FLAG_MAKES_CONTACT) + && (Random() % 3) == 0) { - gBattleCommunication[MOVE_EFFECT_BYTE] += 0x42; + gBattleCommunication[MOVE_EFFECT_BYTE] = 0x42; b_movescr_stack_push_cursor(); gBattlescriptCurrInstr = gUnknown_081D9950; gHitMarker |= HITMARKER_IGNORE_SAFEGUARD; @@ -1764,11 +1843,15 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) } break; case ABILITY_STATIC: - if (!(gBattleMoveFlags & MOVESTATUS_NOEFFECT) && gBattleMons[gBankAttacker].hp && !gProtectStructs[gBankAttacker].confusionSelfDmg - && (gSpecialStatuses[gBankTarget].moveturnLostHP_physical || gSpecialStatuses[gBankTarget].moveturnLostHP_special) - && gBattleMoves[move].flags & FLAG_MAKES_CONTACT && (Random() % 3) == 0) + //_08019128 + if (!(gBattleMoveFlags & MOVESTATUS_NOEFFECT) + && gBattleMons[gBankAttacker].hp != 0 + && !gProtectStructs[gBankAttacker].confusionSelfDmg + && (gSpecialStatuses[gBankTarget].moveturnLostHP_physical || gSpecialStatuses[gBankTarget].moveturnLostHP_special) + && (gBattleMoves[move].flags & FLAG_MAKES_CONTACT) + && (Random() % 3) == 0) { - gBattleCommunication[MOVE_EFFECT_BYTE] += 0x45; + gBattleCommunication[MOVE_EFFECT_BYTE] = 0x45; b_movescr_stack_push_cursor(); gBattlescriptCurrInstr = gUnknown_081D9950; gHitMarker |= HITMARKER_IGNORE_SAFEGUARD; @@ -1776,11 +1859,15 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) } break; case ABILITY_FLAME_BODY: - if (!(gBattleMoveFlags & MOVESTATUS_NOEFFECT) && gBattleMons[gBankAttacker].hp && !gProtectStructs[gBankAttacker].confusionSelfDmg && gBattleMoves[move].flags & FLAG_MAKES_CONTACT - && (gSpecialStatuses[gBankTarget].moveturnLostHP_physical || gSpecialStatuses[gBankTarget].moveturnLostHP_special) - && (Random() % 3) == 0) + //_08019204 + if (!(gBattleMoveFlags & MOVESTATUS_NOEFFECT) + && gBattleMons[gBankAttacker].hp != 0 + && !gProtectStructs[gBankAttacker].confusionSelfDmg + && (gBattleMoves[move].flags & FLAG_MAKES_CONTACT) + && (gSpecialStatuses[gBankTarget].moveturnLostHP_physical || gSpecialStatuses[gBankTarget].moveturnLostHP_special) + && (Random() % 3) == 0) { - gBattleCommunication[MOVE_EFFECT_BYTE] += 0x43; + gBattleCommunication[MOVE_EFFECT_BYTE] = 0x43; b_movescr_stack_push_cursor(); gBattlescriptCurrInstr = gUnknown_081D9950; gHitMarker |= HITMARKER_IGNORE_SAFEGUARD; @@ -1788,12 +1875,19 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) } break; case ABILITY_CUTE_CHARM: - if (!(gBattleMoveFlags & MOVESTATUS_NOEFFECT) && gBattleMons[gBankAttacker].hp && !gProtectStructs[gBankAttacker].confusionSelfDmg && gBattleMoves[move].flags & FLAG_MAKES_CONTACT - && (gSpecialStatuses[gBankTarget].moveturnLostHP_physical || gSpecialStatuses[gBankTarget].moveturnLostHP_special) - && gBattleMons[gBankTarget].hp && (Random() % 3) == 0 && gBattleMons[gBankTarget].ability != ABILITY_OBLIVIOUS - && GetGenderFromSpeciesAndPersonality(speciesAtk, pidAtk) != GetGenderFromSpeciesAndPersonality(speciesDef, pidDef) - && !(gBattleMons[gBankTarget].status2 & STATUS2_INFATUATION) && GetGenderFromSpeciesAndPersonality(speciesAtk, pidAtk) != 0xFF - && GetGenderFromSpeciesAndPersonality(speciesDef, pidDef) != 0xFF) + //_080192E0 + if (!(gBattleMoveFlags & MOVESTATUS_NOEFFECT) + && gBattleMons[gBankAttacker].hp != 0 + && !gProtectStructs[gBankAttacker].confusionSelfDmg + && (gBattleMoves[move].flags & FLAG_MAKES_CONTACT) + && (gSpecialStatuses[gBankTarget].moveturnLostHP_physical || gSpecialStatuses[gBankTarget].moveturnLostHP_special) + && gBattleMons[gBankTarget].hp != 0 + && (Random() % 3) == 0 + && gBattleMons[gBankAttacker].ability != ABILITY_OBLIVIOUS + && GetGenderFromSpeciesAndPersonality(speciesAtk, pidAtk) != GetGenderFromSpeciesAndPersonality(speciesDef, pidDef) + && !(gBattleMons[gBankAttacker].status2 & STATUS2_INFATUATION) + && GetGenderFromSpeciesAndPersonality(speciesAtk, pidAtk) != 0xFF + && GetGenderFromSpeciesAndPersonality(speciesDef, pidDef) != 0xFF) { gBattleMons[gBankAttacker].status2 |= (gBitTable[gBankTarget] << 0x10); b_movescr_stack_push_cursor(); @@ -1804,14 +1898,15 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) } break; case ABILITYEFFECT_IMMUNITY: // 5 + //_08019448 { - u8 i; + #define i bank for (i = 0; i < gNoOfAllBanks; i++) { switch (gBattleMons[i].ability) { case ABILITY_IMMUNITY: - if (gBattleMons[i].status1 & (STATUS_POISON | STATUS_TOXIC_POISON)) + if (gBattleMons[i].status1 & (STATUS_POISON | STATUS_TOXIC_POISON | 0xF00)) // TODO: what is 0xF00? { StringCopy(gBattleTextBuff1, gStatusConditionString_PoisonJpn); effect = 1; @@ -1880,29 +1975,37 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) gBattlescriptCurrInstr = gUnknown_081D9956; BATTLE_STRUCT->scriptingActive = i; gActiveBank = i; - EmitSetAttributes(0, REQUEST_STATUS_BATTLE, 0, 4, &gBattleMons[i].status1); + EmitSetAttributes(0, REQUEST_STATUS_BATTLE, 0, 4, &gBattleMons[gActiveBank].status1); MarkBufferBankForExecution(gActiveBank); return effect; } } + #undef i } break; case ABILITYEFFECT_FORECAST: // 6 + //_080197B4 { - u8 i; + #define i bank for (i = 0; i < gNoOfAllBanks; i++) { - if (gBattleMons[i].ability == ABILITY_FORECAST && (effect = CastformDataTypeChange(i))) + if (gBattleMons[i].ability == ABILITY_FORECAST) { - b_push_move_exec(gUnknown_081D977D); - BATTLE_STRUCT->scriptingActive = i; - BATTLE_STRUCT->castformToChangeInto = effect - 1; - return effect; + effect = CastformDataTypeChange(i); + if (effect) + { + b_push_move_exec(gUnknown_081D977D); + BATTLE_STRUCT->scriptingActive = i; + BATTLE_STRUCT->castformToChangeInto = effect - 1; + return effect; + } } } + #undef i } break; case ABILITYEFFECT_SYNCHRONIZE: // 7 + //_08019804 if (gLastUsedAbility == ABILITY_SYNCHRONIZE && (gHitMarker & HITMARKER_SYNCHRONISE_EFFECT)) { gHitMarker &= ~(HITMARKER_SYNCHRONISE_EFFECT); @@ -1911,13 +2014,14 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) BATTLE_STRUCT->synchroniseEffect = 2; gBattleCommunication[MOVE_EFFECT_BYTE] = BATTLE_STRUCT->synchroniseEffect + 0x40; BATTLE_STRUCT->scriptingActive = gBankTarget; - b_movescr_stack_pop_cursor(); + b_movescr_stack_push_cursor(); gBattlescriptCurrInstr = gUnknown_081D9953; gHitMarker |= HITMARKER_IGNORE_SAFEGUARD; effect++; } break; case ABILITYEFFECT_ATK_SYNCHRONIZE: // 8 + //_08019880 if (gLastUsedAbility == ABILITY_SYNCHRONIZE && (gHitMarker & HITMARKER_SYNCHRONISE_EFFECT)) { gHitMarker &= ~(HITMARKER_SYNCHRONISE_EFFECT); @@ -1926,13 +2030,14 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) BATTLE_STRUCT->synchroniseEffect = 2; gBattleCommunication[MOVE_EFFECT_BYTE] = BATTLE_STRUCT->synchroniseEffect; BATTLE_STRUCT->scriptingActive = gBankAttacker; - b_movescr_stack_pop_cursor(); + b_movescr_stack_push_cursor(); gBattlescriptCurrInstr = gUnknown_081D9953; gHitMarker |= HITMARKER_IGNORE_SAFEGUARD; effect++; } break; case ABILITYEFFECT_INTIMIDATE1: // 9 + //_080198FC for (i = 0; i < gNoOfAllBanks; i++) { if (gBattleMons[i].ability == ABILITY_INTIMIDATE && gStatuses3[i] & STATUS3_INTIMIDATE_POKES) @@ -1947,32 +2052,36 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) } break; case ABILITYEFFECT_TRACE: // 11 + //_08019940 for (i = 0; i < gNoOfAllBanks; i++) { - if (gBattleMons[i].ability == ABILITY_TRACE && gStatuses3[i] & STATUS3_TRACE) + 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); if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE) { - if (gBattleMons[target1].ability && gBattleMons[target1].hp && gBattleMons[target2].ability && gBattleMons[target2].hp) + if (gBattleMons[target1].ability != 0 && gBattleMons[target1].hp != 0 + && gBattleMons[target2].ability != 0 && gBattleMons[target2].hp != 0) { - //random target + //_080199AE gActiveBank = GetBankByPlayerAI(((Random() & 1) * 2) | opposite); gBattleMons[i].ability = gBattleMons[gActiveBank].ability; gLastUsedAbility = gBattleMons[gActiveBank].ability; effect++; } - else if (gBattleMons[target1].ability && gBattleMons[target1].hp) + else if (gBattleMons[target1].ability != 0 && gBattleMons[target1].hp != 0) { + //_08019A34 gActiveBank = target1; gBattleMons[i].ability = gBattleMons[gActiveBank].ability; gLastUsedAbility = gBattleMons[gActiveBank].ability; effect++; } - else if (gBattleMons[target2].ability && gBattleMons[target2].hp) + else if (gBattleMons[target2].ability != 0 && gBattleMons[target2].hp != 0) { + //_08019A78 gActiveBank = target2; gBattleMons[i].ability = gBattleMons[gActiveBank].ability; gLastUsedAbility = gBattleMons[gActiveBank].ability; @@ -1980,12 +2089,13 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) } } else + //_08019ABC { gActiveBank = target1; if (gBattleMons[target1].ability && gBattleMons[target1].hp) { - gBattleMons[i].ability = gBattleMons[gActiveBank].ability; - gLastUsedAbility = gBattleMons[gActiveBank].ability; + gBattleMons[i].ability = gBattleMons[target1].ability; + gLastUsedAbility = gBattleMons[target1].ability; effect++; } } @@ -2011,9 +2121,10 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) } break; case ABILITYEFFECT_INTIMIDATE2: // 10 + //_08019B1C for (i = 0; i < gNoOfAllBanks; i++) { - if (gBattleMons[i].ability == ABILITY_INTIMIDATE && gStatuses3[i] & STATUS3_INTIMIDATE_POKES) + if (gBattleMons[i].ability == ABILITY_INTIMIDATE && (gStatuses3[i] & STATUS3_INTIMIDATE_POKES)) { gLastUsedAbility = ABILITY_INTIMIDATE; gStatuses3[i] &= ~(STATUS3_INTIMIDATE_POKES); @@ -2026,6 +2137,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) } break; case ABILITYEFFECT_CHECK_OTHER_SIDE: // 12 + //_08019B60 side = GetBankSide(bank); for (i = 0; i < gNoOfAllBanks; i++) { @@ -2037,6 +2149,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) } break; case ABILITYEFFECT_CHECK_BANK_SIDE: // 13 + //_08019BBC side = GetBankSide(bank); for (i = 0; i < gNoOfAllBanks; i++) { @@ -2048,24 +2161,24 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) } break; case ABILITYEFFECT_FIELD_SPORT: // 14 - if (gLastUsedAbility == 0xFD) + //_08019C18 + switch (gLastUsedAbility) { + case 0xFD: for (i = 0; i < gNoOfAllBanks; i++) { if (gStatuses3[i] & STATUS3_MUDSPORT) effect = i + 1; } - } - else if (gLastUsedAbility == 0xFE) - { + break; + case 0xFE: for (i = 0; i < gNoOfAllBanks; i++) { if (gStatuses3[i] & STATUS3_WATERSPORT) effect = i + 1; } - } - else - { + break; + default: for (i = 0; i < gNoOfAllBanks; i++) { if (gBattleMons[i].ability == ability) @@ -2074,12 +2187,14 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) effect = i + 1; } } + break; } break; case ABILITYEFFECT_CHECK_ON_FIELD: // 19 + //_08019CD4 for (i = 0; i < gNoOfAllBanks; i++) { - if (gBattleMons[i].ability == ability && gBattleMons[i].hp) + if (gBattleMons[i].ability == ability && gBattleMons[i].hp != 0) { gLastUsedAbility = ability; effect = i + 1; @@ -2087,6 +2202,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) } break; case ABILITYEFFECT_CHECK_FIELD_EXCEPT_BANK: // 15 + //_08019D18 for (i = 0; i < gNoOfAllBanks; i++) { if (gBattleMons[i].ability == ability && i != bank) @@ -2097,6 +2213,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) } break; case ABILITYEFFECT_COUNT_OTHER_SIZE: // 16 + //_08019D5C side = GetBankSide(bank); for (i = 0; i < gNoOfAllBanks; i++) { @@ -2108,6 +2225,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) } break; case ABILITYEFFECT_COUNT_BANK_SIDE: // 17 + //_08019DB8 side = GetBankSide(bank); for (i = 0; i < gNoOfAllBanks; i++) { @@ -2119,6 +2237,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) } break; case ABILITYEFFECT_COUNT_ON_FIELD: // 18 + //_08019F44 for (i = 0; i < gNoOfAllBanks; i++) { if (gBattleMons[i].ability == ability && i != bank) @@ -2129,9 +2248,4108 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) } break; } + //_08019F76 if (effect && caseID < 0xC && gLastUsedAbility != 0xFF) RecordAbilityBattle(bank, gLastUsedAbility); } return effect; } + +#else +__attribute__((naked)) +u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) +{ + 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\ + sub sp, 0x28\n\ + ldr r4, [sp, 0x48]\n\ + lsls r0, 24\n\ + lsrs r0, 24\n\ + str r0, [sp, 0x4]\n\ + lsls r1, 24\n\ + lsrs r1, 24\n\ + mov r10, r1\n\ + lsls r2, 24\n\ + lsrs r6, r2, 24\n\ + lsls r3, 24\n\ + lsrs r3, 24\n\ + mov r8, r3\n\ + lsls r4, 16\n\ + lsrs r4, 16\n\ + movs r0, 0\n\ + mov r9, r0\n\ + ldr r5, _08018380 @ =gBankAttacker\n\ + ldr r1, _08018384 @ =gNoOfAllBanks\n\ + ldrb r0, [r5]\n\ + ldrb r1, [r1]\n\ + cmp r0, r1\n\ + bcc _08018360\n\ + mov r1, r10\n\ + strb r1, [r5]\n\ +_08018360:\n\ + ldrb r0, [r5]\n\ + bl GetBankSide\n\ + lsls r0, 24\n\ + cmp r0, 0\n\ + bne _08018390\n\ + ldr r1, _08018388 @ =gBattlePartyID\n\ + ldrb r0, [r5]\n\ + lsls r0, 1\n\ + adds r0, r1\n\ + ldrh r1, [r0]\n\ + movs r0, 0x64\n\ + muls r1, r0\n\ + ldr r0, _0801838C @ =gPlayerParty\n\ + b _080183A0\n\ + .align 2, 0\n\ +_08018380: .4byte gBankAttacker\n\ +_08018384: .4byte gNoOfAllBanks\n\ +_08018388: .4byte gBattlePartyID\n\ +_0801838C: .4byte gPlayerParty\n\ +_08018390:\n\ + ldr r1, _080183D0 @ =gBattlePartyID\n\ + ldrb r0, [r5]\n\ + lsls r0, 1\n\ + adds r0, r1\n\ + ldrh r1, [r0]\n\ + movs r0, 0x64\n\ + muls r1, r0\n\ + ldr r0, _080183D4 @ =gEnemyParty\n\ +_080183A0:\n\ + adds r7, r1, r0\n\ + ldr r5, _080183D8 @ =gBankTarget\n\ + ldr r1, _080183DC @ =gNoOfAllBanks\n\ + ldrb r0, [r5]\n\ + ldrb r1, [r1]\n\ + cmp r0, r1\n\ + bcc _080183B2\n\ + mov r2, r10\n\ + strb r2, [r5]\n\ +_080183B2:\n\ + ldrb r0, [r5]\n\ + bl GetBankSide\n\ + lsls r0, 24\n\ + cmp r0, 0\n\ + bne _080183E4\n\ + ldr r1, _080183D0 @ =gBattlePartyID\n\ + ldrb r0, [r5]\n\ + lsls r0, 1\n\ + adds r0, r1\n\ + ldrh r1, [r0]\n\ + movs r0, 0x64\n\ + muls r1, r0\n\ + ldr r0, _080183E0 @ =gPlayerParty\n\ + b _080183F4\n\ + .align 2, 0\n\ +_080183D0: .4byte gBattlePartyID\n\ +_080183D4: .4byte gEnemyParty\n\ +_080183D8: .4byte gBankTarget\n\ +_080183DC: .4byte gNoOfAllBanks\n\ +_080183E0: .4byte gPlayerParty\n\ +_080183E4:\n\ + ldr r1, _08018444 @ =gBattlePartyID\n\ + ldrb r0, [r5]\n\ + lsls r0, 1\n\ + adds r0, r1\n\ + ldrh r1, [r0]\n\ + movs r0, 0x64\n\ + muls r1, r0\n\ + ldr r0, _08018448 @ =gEnemyParty\n\ +_080183F4:\n\ + adds r5, r1, r0\n\ + adds r0, r7, 0\n\ + movs r1, 0xB\n\ + bl GetMonData\n\ + lsls r0, 16\n\ + lsrs r0, 16\n\ + str r0, [sp, 0x8]\n\ + adds r0, r7, 0\n\ + movs r1, 0\n\ + bl GetMonData\n\ + str r0, [sp, 0x10]\n\ + adds r0, r5, 0\n\ + movs r1, 0xB\n\ + bl GetMonData\n\ + lsls r0, 16\n\ + lsrs r0, 16\n\ + str r0, [sp, 0xC]\n\ + adds r0, r5, 0\n\ + movs r1, 0\n\ + bl GetMonData\n\ + str r0, [sp, 0x14]\n\ + ldr r0, _0801844C @ =gBattleTypeFlags\n\ + ldrh r1, [r0]\n\ + movs r0, 0x80\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + beq _08018436\n\ + bl _08019F92\n\ +_08018436:\n\ + mov r3, r8\n\ + cmp r3, 0\n\ + beq _08018454\n\ + ldr r0, _08018450 @ =gLastUsedAbility\n\ + strb r3, [r0]\n\ + mov r8, r0\n\ + b _0801846A\n\ + .align 2, 0\n\ +_08018444: .4byte gBattlePartyID\n\ +_08018448: .4byte gEnemyParty\n\ +_0801844C: .4byte gBattleTypeFlags\n\ +_08018450: .4byte gLastUsedAbility\n\ +_08018454:\n\ + ldr r2, _08018474 @ =gLastUsedAbility\n\ + ldr r1, _08018478 @ =gBattleMons\n\ + movs r0, 0x58\n\ + mov r5, r10\n\ + muls r5, r0\n\ + adds r0, r5, 0\n\ + adds r0, r1\n\ + adds r0, 0x20\n\ + ldrb r0, [r0]\n\ + strb r0, [r2]\n\ + mov r8, r2\n\ +_0801846A:\n\ + cmp r4, 0\n\ + beq _0801847C\n\ + adds r3, r4, 0\n\ + b _08018480\n\ + .align 2, 0\n\ +_08018474: .4byte gLastUsedAbility\n\ +_08018478: .4byte gBattleMons\n\ +_0801847C:\n\ + ldr r0, _08018494 @ =gCurrentMove\n\ + ldrh r3, [r0]\n\ +_08018480:\n\ + ldr r1, _08018498 @ =0x02000000\n\ + ldr r2, _0801849C @ =0x0001601c\n\ + adds r0, r1, r2\n\ + ldrb r0, [r0]\n\ + adds r7, r1, 0\n\ + cmp r0, 0\n\ + beq _080184A0\n\ + movs r4, 0x3F\n\ + ands r4, r0\n\ + b _080184AC\n\ + .align 2, 0\n\ +_08018494: .4byte gCurrentMove\n\ +_08018498: .4byte 0x02000000\n\ +_0801849C: .4byte 0x0001601c\n\ +_080184A0:\n\ + ldr r1, _080184C0 @ =gBattleMoves\n\ + lsls r0, r3, 1\n\ + adds r0, r3\n\ + lsls r0, 2\n\ + adds r0, r1\n\ + ldrb r4, [r0, 0x2]\n\ +_080184AC:\n\ + ldr r5, [sp, 0x4]\n\ + cmp r5, 0x13\n\ + bls _080184B6\n\ + bl _08019F76\n\ +_080184B6:\n\ + lsls r0, r5, 2\n\ + ldr r1, _080184C4 @ =_080184C8\n\ + adds r0, r1\n\ + ldr r0, [r0]\n\ + mov pc, r0\n\ + .align 2, 0\n\ +_080184C0: .4byte gBattleMoves\n\ +_080184C4: .4byte _080184C8\n\ + .align 2, 0\n\ +_080184C8:\n\ + .4byte _08018518\n\ + .4byte _08018814\n\ + .4byte _08018A40\n\ + .4byte _08018AD8\n\ + .4byte _08018CF0\n\ + .4byte _08019448\n\ + .4byte _080197B4\n\ + .4byte _08019804\n\ + .4byte _08019880\n\ + .4byte _080198FC\n\ + .4byte _08019B1C\n\ + .4byte _08019940\n\ + .4byte _08019B60\n\ + .4byte _08019BBC\n\ + .4byte _08019C18\n\ + .4byte _08019D18\n\ + .4byte _08019D5C\n\ + .4byte _08019DB8\n\ + .4byte _08019F44\n\ + .4byte _08019CD4\n\ +_08018518:\n\ + ldr r2, _0801854C @ =gBankAttacker\n\ + ldr r0, _08018550 @ =gNoOfAllBanks\n\ + ldrb r1, [r2]\n\ + adds r5, r0, 0\n\ + ldrb r0, [r5]\n\ + cmp r1, r0\n\ + bcc _0801852A\n\ + mov r1, r10\n\ + strb r1, [r2]\n\ +_0801852A:\n\ + mov r2, r8\n\ + ldrb r0, [r2]\n\ + cmp r0, 0x2D\n\ + bne _08018534\n\ + b _080186B8\n\ +_08018534:\n\ + cmp r0, 0x2D\n\ + bgt _08018564\n\ + cmp r0, 0xD\n\ + bne _0801853E\n\ + b _080187DC\n\ +_0801853E:\n\ + cmp r0, 0xD\n\ + bgt _08018554\n\ + cmp r0, 0x2\n\ + bne _08018548\n\ + b _08018680\n\ +_08018548:\n\ + bl _08019F76\n\ + .align 2, 0\n\ +_0801854C: .4byte gBankAttacker\n\ +_08018550: .4byte gNoOfAllBanks\n\ +_08018554:\n\ + cmp r0, 0x16\n\ + bne _0801855A\n\ + b _08018728\n\ +_0801855A:\n\ + cmp r0, 0x24\n\ + bne _08018560\n\ + b _080187A0\n\ +_08018560:\n\ + bl _08019F76\n\ +_08018564:\n\ + cmp r0, 0x46\n\ + bne _0801856A\n\ + b _080186F0\n\ +_0801856A:\n\ + cmp r0, 0x46\n\ + bgt _08018578\n\ + cmp r0, 0x3B\n\ + bne _08018574\n\ + b _0801875C\n\ +_08018574:\n\ + bl _08019F76\n\ +_08018578:\n\ + cmp r0, 0x4D\n\ + bne _0801857E\n\ + b _080187DC\n\ +_0801857E:\n\ + cmp r0, 0xFF\n\ + beq _08018586\n\ + bl _08019F76\n\ +_08018586:\n\ + bl weather_get_current\n\ + lsls r0, 24\n\ + lsrs r0, 24\n\ + subs r0, 0x3\n\ + cmp r0, 0xA\n\ + bhi _0801864C\n\ + lsls r0, 2\n\ + ldr r1, _080185A0 @ =_080185A4\n\ + adds r0, r1\n\ + ldr r0, [r0]\n\ + mov pc, r0\n\ + .align 2, 0\n\ +_080185A0: .4byte _080185A4\n\ + .align 2, 0\n\ +_080185A4:\n\ + .4byte _080185D0\n\ + .4byte _0801864C\n\ + .4byte _080185D0\n\ + .4byte _0801864C\n\ + .4byte _0801864C\n\ + .4byte _080185F8\n\ + .4byte _0801864C\n\ + .4byte _0801864C\n\ + .4byte _0801864C\n\ + .4byte _08018620\n\ + .4byte _080185D0\n\ +_080185D0:\n\ + ldr r2, _080185EC @ =gBattleWeather\n\ + ldrh r1, [r2]\n\ + movs r0, 0x7\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + bne _0801864C\n\ + movs r0, 0x5\n\ + strh r0, [r2]\n\ + ldr r0, _080185F0 @ =0x02000000\n\ + ldr r3, _080185F4 @ =0x000160a4\n\ + adds r2, r0, r3\n\ + movs r1, 0xA\n\ + b _08018638\n\ + .align 2, 0\n\ +_080185EC: .4byte gBattleWeather\n\ +_080185F0: .4byte 0x02000000\n\ +_080185F4: .4byte 0x000160a4\n\ +_080185F8:\n\ + ldr r3, _08018614 @ =gBattleWeather\n\ + ldrh r1, [r3]\n\ + movs r2, 0x18\n\ + adds r0, r2, 0\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + bne _0801864C\n\ + strh r2, [r3]\n\ + ldr r0, _08018618 @ =0x02000000\n\ + ldr r3, _0801861C @ =0x000160a4\n\ + adds r2, r0, r3\n\ + movs r1, 0xC\n\ + b _08018638\n\ + .align 2, 0\n\ +_08018614: .4byte gBattleWeather\n\ +_08018618: .4byte 0x02000000\n\ +_0801861C: .4byte 0x000160a4\n\ +_08018620:\n\ + ldr r3, _08018668 @ =gBattleWeather\n\ + ldrh r1, [r3]\n\ + movs r2, 0x60\n\ + adds r0, r2, 0\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + bne _0801864C\n\ + strh r2, [r3]\n\ + ldr r0, _0801866C @ =0x02000000\n\ + ldr r3, _08018670 @ =0x000160a4\n\ + adds r2, r0, r3\n\ + movs r1, 0xB\n\ +_08018638:\n\ + strb r1, [r2]\n\ + ldr r5, _08018674 @ =0x00016003\n\ + adds r0, r5\n\ + mov r1, r10\n\ + strb r1, [r0]\n\ + mov r0, r9\n\ + adds r0, 0x1\n\ + lsls r0, 24\n\ + lsrs r0, 24\n\ + mov r9, r0\n\ +_0801864C:\n\ + mov r2, r9\n\ + cmp r2, 0\n\ + bne _08018656\n\ + bl _08019F92\n\ +_08018656:\n\ + bl weather_get_current\n\ + ldr r1, _08018678 @ =gBattleCommunication\n\ + strb r0, [r1, 0x5]\n\ + ldr r0, _0801867C @ =gUnknown_081D901D\n\ + bl b_push_move_exec\n\ + bl _08019F76\n\ + .align 2, 0\n\ +_08018668: .4byte gBattleWeather\n\ +_0801866C: .4byte 0x02000000\n\ +_08018670: .4byte 0x000160a4\n\ +_08018674: .4byte 0x00016003\n\ +_08018678: .4byte gBattleCommunication\n\ +_0801867C: .4byte gUnknown_081D901D\n\ +_08018680:\n\ + ldr r2, _080186A8 @ =gBattleWeather\n\ + ldrh r1, [r2]\n\ + movs r0, 0x4\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + beq _08018690\n\ + bl _08019F76\n\ +_08018690:\n\ + movs r0, 0x5\n\ + strh r0, [r2]\n\ + ldr r0, _080186AC @ =gUnknown_081D9704\n\ + bl b_push_move_exec\n\ + ldr r0, _080186B0 @ =0x02000000\n\ + ldr r3, _080186B4 @ =0x00016003\n\ + adds r0, r3\n\ + mov r5, r10\n\ + strb r5, [r0]\n\ + bl _08019F22\n\ + .align 2, 0\n\ +_080186A8: .4byte gBattleWeather\n\ +_080186AC: .4byte gUnknown_081D9704\n\ +_080186B0: .4byte 0x02000000\n\ +_080186B4: .4byte 0x00016003\n\ +_080186B8:\n\ + ldr r2, _080186E0 @ =gBattleWeather\n\ + ldrh r1, [r2]\n\ + movs r0, 0x10\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + beq _080186C8\n\ + bl _08019F76\n\ +_080186C8:\n\ + movs r0, 0x18\n\ + strh r0, [r2]\n\ + ldr r0, _080186E4 @ =gUnknown_081D9744\n\ + bl b_push_move_exec\n\ + ldr r0, _080186E8 @ =0x02000000\n\ + ldr r1, _080186EC @ =0x00016003\n\ + adds r0, r1\n\ + mov r2, r10\n\ + strb r2, [r0]\n\ + bl _08019F22\n\ + .align 2, 0\n\ +_080186E0: .4byte gBattleWeather\n\ +_080186E4: .4byte gUnknown_081D9744\n\ +_080186E8: .4byte 0x02000000\n\ +_080186EC: .4byte 0x00016003\n\ +_080186F0:\n\ + ldr r2, _08018718 @ =gBattleWeather\n\ + ldrh r1, [r2]\n\ + movs r0, 0x40\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + beq _08018700\n\ + bl _08019F76\n\ +_08018700:\n\ + movs r0, 0x60\n\ + strh r0, [r2]\n\ + ldr r0, _0801871C @ =gUnknown_081D97FE\n\ + bl b_push_move_exec\n\ + ldr r0, _08018720 @ =0x02000000\n\ + ldr r3, _08018724 @ =0x00016003\n\ + adds r0, r3\n\ + mov r5, r10\n\ + strb r5, [r0]\n\ + bl _08019F22\n\ + .align 2, 0\n\ +_08018718: .4byte gBattleWeather\n\ +_0801871C: .4byte gUnknown_081D97FE\n\ +_08018720: .4byte 0x02000000\n\ +_08018724: .4byte 0x00016003\n\ +_08018728:\n\ + ldr r0, _08018754 @ =gSpecialStatuses\n\ + mov r1, r10\n\ + lsls r2, r1, 2\n\ + adds r1, r2, r1\n\ + lsls r1, 2\n\ + adds r3, r1, r0\n\ + ldrb r0, [r3]\n\ + lsls r0, 28\n\ + cmp r0, 0\n\ + bge _08018740\n\ + bl _08019F76\n\ +_08018740:\n\ + ldr r1, _08018758 @ =gStatuses3\n\ + adds r1, r2, r1\n\ + ldr r0, [r1]\n\ + movs r2, 0x80\n\ + lsls r2, 12\n\ + orrs r0, r2\n\ + str r0, [r1]\n\ + ldrb r0, [r3]\n\ + movs r1, 0x8\n\ + b _080187CA\n\ + .align 2, 0\n\ +_08018754: .4byte gSpecialStatuses\n\ +_08018758: .4byte gStatuses3\n\ +_0801875C:\n\ + mov r0, r10\n\ + bl CastformDataTypeChange\n\ + lsls r0, 24\n\ + lsrs r0, 24\n\ + mov r9, r0\n\ + cmp r0, 0\n\ + bne _08018770\n\ + bl _08019F92\n\ +_08018770:\n\ + ldr r0, _08018790 @ =gUnknown_081D977D\n\ + bl b_push_move_exec\n\ + ldr r0, _08018794 @ =0x02000000\n\ + ldr r2, _08018798 @ =0x00016003\n\ + adds r1, r0, r2\n\ + mov r3, r10\n\ + strb r3, [r1]\n\ + mov r1, r9\n\ + subs r1, 0x1\n\ + ldr r5, _0801879C @ =0x0001609b\n\ + adds r0, r5\n\ + strb r1, [r0]\n\ + bl _08019F76\n\ + .align 2, 0\n\ +_08018790: .4byte gUnknown_081D977D\n\ +_08018794: .4byte 0x02000000\n\ +_08018798: .4byte 0x00016003\n\ +_0801879C: .4byte 0x0001609b\n\ +_080187A0:\n\ + ldr r0, _080187D4 @ =gSpecialStatuses\n\ + mov r1, r10\n\ + lsls r2, r1, 2\n\ + adds r1, r2, r1\n\ + lsls r1, 2\n\ + adds r3, r1, r0\n\ + ldrb r0, [r3]\n\ + lsls r0, 27\n\ + cmp r0, 0\n\ + bge _080187B8\n\ + bl _08019F76\n\ +_080187B8:\n\ + ldr r1, _080187D8 @ =gStatuses3\n\ + adds r1, r2, r1\n\ + ldr r0, [r1]\n\ + movs r2, 0x80\n\ + lsls r2, 13\n\ + orrs r0, r2\n\ + str r0, [r1]\n\ + ldrb r0, [r3]\n\ + movs r1, 0x10\n\ +_080187CA:\n\ + orrs r0, r1\n\ + strb r0, [r3]\n\ + bl _08019F76\n\ + .align 2, 0\n\ +_080187D4: .4byte gSpecialStatuses\n\ +_080187D8: .4byte gStatuses3\n\ +_080187DC:\n\ + movs r6, 0\n\ + ldrb r5, [r5]\n\ + cmp r6, r5\n\ + bcc _080187E8\n\ + bl _08019F76\n\ +_080187E8:\n\ + adds r0, r6, 0\n\ + bl CastformDataTypeChange\n\ + lsls r0, 24\n\ + lsrs r0, 24\n\ + mov r9, r0\n\ + cmp r0, 0\n\ + beq _080187FC\n\ + bl _08019E14\n\ +_080187FC:\n\ + adds r0, r6, 0x1\n\ + lsls r0, 24\n\ + lsrs r6, r0, 24\n\ + ldr r0, _08018810 @ =gNoOfAllBanks\n\ + ldrb r0, [r0]\n\ + cmp r6, r0\n\ + bcc _080187E8\n\ + bl _08019F76\n\ + .align 2, 0\n\ +_08018810: .4byte gNoOfAllBanks\n\ +_08018814:\n\ + ldr r2, _08018844 @ =gBattleMons\n\ + movs r0, 0x58\n\ + mov r1, r10\n\ + muls r1, r0\n\ + adds r4, r1, r2\n\ + ldrh r0, [r4, 0x28]\n\ + cmp r0, 0\n\ + bne _08018828\n\ + bl _08019F76\n\ +_08018828:\n\ + ldr r0, _08018848 @ =gBankAttacker\n\ + mov r3, r10\n\ + strb r3, [r0]\n\ + mov r3, r8\n\ + ldrb r5, [r3]\n\ + cmp r5, 0x2C\n\ + beq _0801885A\n\ + cmp r5, 0x2C\n\ + bgt _0801884C\n\ + cmp r5, 0x3\n\ + bne _08018840\n\ + b _080189B8\n\ +_08018840:\n\ + bl _08019F76\n\ + .align 2, 0\n\ +_08018844: .4byte gBattleMons\n\ +_08018848: .4byte gBankAttacker\n\ +_0801884C:\n\ + cmp r5, 0x36\n\ + bne _08018852\n\ + b _08018A18\n\ +_08018852:\n\ + cmp r5, 0x3D\n\ + beq _080188DC\n\ + bl _08019F76\n\ +_0801885A:\n\ + movs r0, 0\n\ + str r0, [sp]\n\ + movs r0, 0x13\n\ + movs r1, 0\n\ + movs r2, 0xD\n\ + movs r3, 0\n\ + bl AbilityBattleEffects\n\ + lsls r0, 24\n\ + lsrs r0, 24\n\ + cmp r0, 0\n\ + beq _08018876\n\ + bl _08019F76\n\ +_08018876:\n\ + str r0, [sp]\n\ + movs r0, 0x13\n\ + movs r1, 0\n\ + movs r2, 0x4D\n\ + movs r3, 0\n\ + bl AbilityBattleEffects\n\ + lsls r0, 24\n\ + cmp r0, 0\n\ + beq _0801888E\n\ + bl _08019F76\n\ +_0801888E:\n\ + ldr r0, _080188D0 @ =gBattleWeather\n\ + ldrh r1, [r0]\n\ + movs r0, 0x7\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + bne _0801889E\n\ + bl _08019F76\n\ +_0801889E:\n\ + ldrh r0, [r4, 0x2C]\n\ + ldrh r1, [r4, 0x28]\n\ + cmp r0, r1\n\ + bhi _080188AA\n\ + bl _08019F76\n\ +_080188AA:\n\ + mov r2, r8\n\ + strb r5, [r2]\n\ + ldr r0, _080188D4 @ =gUnknown_081D9730\n\ + bl b_push_move_exec\n\ + ldr r1, _080188D8 @ =gBattleMoveDamage\n\ + ldrh r0, [r4, 0x2C]\n\ + lsrs r0, 4\n\ + str r0, [r1]\n\ + cmp r0, 0\n\ + bne _080188C4\n\ + movs r0, 0x1\n\ + str r0, [r1]\n\ +_080188C4:\n\ + ldr r0, [r1]\n\ + negs r0, r0\n\ + str r0, [r1]\n\ + bl _08019F22\n\ + .align 2, 0\n\ +_080188D0: .4byte gBattleWeather\n\ +_080188D4: .4byte gUnknown_081D9730\n\ +_080188D8: .4byte gBattleMoveDamage\n\ +_080188DC:\n\ + adds r0, r2, 0\n\ + adds r0, 0x4C\n\ + adds r5, r1, r0\n\ + ldrb r0, [r5]\n\ + cmp r0, 0\n\ + bne _080188EC\n\ + bl _08019F76\n\ +_080188EC:\n\ + bl Random\n\ + lsls r0, 16\n\ + lsrs r0, 16\n\ + movs r1, 0x3\n\ + bl __umodsi3\n\ + lsls r0, 16\n\ + lsrs r4, r0, 16\n\ + cmp r4, 0\n\ + beq _08018906\n\ + bl _08019F76\n\ +_08018906:\n\ + ldr r0, [r5]\n\ + movs r1, 0x88\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + beq _08018918\n\ + ldr r0, _08018990 @ =gBattleTextBuff1\n\ + ldr r1, _08018994 @ =gStatusConditionString_PoisonJpn\n\ + bl StringCopy\n\ +_08018918:\n\ + ldr r0, [r5]\n\ + movs r1, 0x7\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + beq _0801892A\n\ + ldr r0, _08018990 @ =gBattleTextBuff1\n\ + ldr r1, _08018998 @ =gStatusConditionString_SleepJpn\n\ + bl StringCopy\n\ +_0801892A:\n\ + ldr r0, [r5]\n\ + movs r1, 0x40\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + beq _0801893C\n\ + ldr r0, _08018990 @ =gBattleTextBuff1\n\ + ldr r1, _0801899C @ =gStatusConditionString_ParalysisJpn\n\ + bl StringCopy\n\ +_0801893C:\n\ + ldr r0, [r5]\n\ + movs r1, 0x10\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + beq _0801894E\n\ + ldr r0, _08018990 @ =gBattleTextBuff1\n\ + ldr r1, _080189A0 @ =gStatusConditionString_BurnJpn\n\ + bl StringCopy\n\ +_0801894E:\n\ + ldr r0, [r5]\n\ + movs r1, 0x20\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + beq _08018960\n\ + ldr r0, _08018990 @ =gBattleTextBuff1\n\ + ldr r1, _080189A4 @ =gStatusConditionString_IceJpn\n\ + bl StringCopy\n\ +_08018960:\n\ + str r4, [r5]\n\ + ldr r0, _080189A8 @ =0x02000000\n\ + ldr r4, _080189AC @ =gActiveBank\n\ + mov r3, r10\n\ + strb r3, [r4]\n\ + ldr r1, _080189B0 @ =0x00016003\n\ + adds r0, r1\n\ + strb r3, [r0]\n\ + ldr r0, _080189B4 @ =gUnknown_081D9758\n\ + bl b_push_move_exec\n\ + str r5, [sp]\n\ + movs r0, 0\n\ + movs r1, 0x28\n\ + movs r2, 0\n\ + movs r3, 0x4\n\ + bl EmitSetAttributes\n\ + ldrb r0, [r4]\n\ + bl MarkBufferBankForExecution\n\ + bl _08019F22\n\ + .align 2, 0\n\ +_08018990: .4byte gBattleTextBuff1\n\ +_08018994: .4byte gStatusConditionString_PoisonJpn\n\ +_08018998: .4byte gStatusConditionString_SleepJpn\n\ +_0801899C: .4byte gStatusConditionString_ParalysisJpn\n\ +_080189A0: .4byte gStatusConditionString_BurnJpn\n\ +_080189A4: .4byte gStatusConditionString_IceJpn\n\ +_080189A8: .4byte 0x02000000\n\ +_080189AC: .4byte gActiveBank\n\ +_080189B0: .4byte 0x00016003\n\ +_080189B4: .4byte gUnknown_081D9758\n\ +_080189B8:\n\ + ldrb r2, [r4, 0x1B]\n\ + movs r0, 0x1B\n\ + ldrsb r0, [r4, r0]\n\ + cmp r0, 0xB\n\ + ble _080189C6\n\ + bl _08019F76\n\ +_080189C6:\n\ + ldr r0, _08018A04 @ =gDisableStructs\n\ + mov r3, r10\n\ + lsls r1, r3, 3\n\ + subs r1, r3\n\ + lsls r1, 2\n\ + adds r1, r0\n\ + ldrb r0, [r1, 0x16]\n\ + cmp r0, 0x2\n\ + bne _080189DC\n\ + bl _08019F76\n\ +_080189DC:\n\ + adds r0, r2, 0x1\n\ + movs r2, 0\n\ + strb r0, [r4, 0x1B]\n\ + ldr r5, _08018A08 @ =0x000160a4\n\ + adds r1, r7, r5\n\ + movs r0, 0x11\n\ + strb r0, [r1]\n\ + ldr r1, _08018A0C @ =0x000160a5\n\ + adds r0, r7, r1\n\ + strb r2, [r0]\n\ + ldr r0, _08018A10 @ =gUnknown_081D9718\n\ + bl b_push_move_exec\n\ + ldr r2, _08018A14 @ =0x00016003\n\ + adds r0, r7, r2\n\ + mov r3, r10\n\ + strb r3, [r0]\n\ + bl _08019F22\n\ + .align 2, 0\n\ +_08018A04: .4byte gDisableStructs\n\ +_08018A08: .4byte 0x000160a4\n\ +_08018A0C: .4byte 0x000160a5\n\ +_08018A10: .4byte gUnknown_081D9718\n\ +_08018A14: .4byte 0x00016003\n\ +_08018A18:\n\ + ldr r2, _08018A3C @ =gDisableStructs\n\ + ldrb r0, [r0]\n\ + lsls r1, r0, 3\n\ + subs r1, r0\n\ + lsls r1, 2\n\ + adds r1, r2\n\ + ldrb r3, [r1, 0x18]\n\ + lsls r0, r3, 31\n\ + lsrs r0, 31\n\ + movs r2, 0x1\n\ + eors r2, r0\n\ + movs r0, 0x2\n\ + negs r0, r0\n\ + ands r0, r3\n\ + orrs r0, r2\n\ + strb r0, [r1, 0x18]\n\ + bl _08019F76\n\ + .align 2, 0\n\ +_08018A3C: .4byte gDisableStructs\n\ +_08018A40:\n\ + mov r5, r8\n\ + ldrb r0, [r5]\n\ + cmp r0, 0x2B\n\ + beq _08018A4C\n\ + bl _08019F76\n\ +_08018A4C:\n\ + movs r4, 0\n\ + ldr r0, _08018ABC @ =gUnknown_081FA724\n\ + ldrh r2, [r0]\n\ + ldr r5, _08018AC0 @ =0x0000ffff\n\ + adds r1, r0, 0\n\ + cmp r2, r5\n\ + bne _08018A5E\n\ + bl _08019F76\n\ +_08018A5E:\n\ + cmp r2, r3\n\ + beq _08018A76\n\ + adds r2, r1, 0\n\ +_08018A64:\n\ + adds r2, 0x2\n\ + adds r4, 0x1\n\ + ldrh r0, [r2]\n\ + cmp r0, r5\n\ + bne _08018A72\n\ + bl _08019F76\n\ +_08018A72:\n\ + cmp r0, r3\n\ + bne _08018A64\n\ +_08018A76:\n\ + lsls r0, r4, 1\n\ + adds r0, r1\n\ + ldrh r1, [r0]\n\ + ldr r0, _08018AC0 @ =0x0000ffff\n\ + cmp r1, r0\n\ + bne _08018A86\n\ + bl _08019F76\n\ +_08018A86:\n\ + ldr r1, _08018AC4 @ =gBattleMons\n\ + ldr r0, _08018AC8 @ =gBankAttacker\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 _08018AAC\n\ + ldr r0, _08018ACC @ =gHitMarker\n\ + ldr r1, [r0]\n\ + movs r2, 0x80\n\ + lsls r2, 4\n\ + orrs r1, r2\n\ + str r1, [r0]\n\ +_08018AAC:\n\ + ldr r1, _08018AD0 @ =gBattlescriptCurrInstr\n\ + ldr r0, _08018AD4 @ =gUnknown_081D98F3\n\ + str r0, [r1]\n\ + movs r0, 0x1\n\ + mov r9, r0\n\ + bl _08019F7C\n\ + .align 2, 0\n\ +_08018ABC: .4byte gUnknown_081FA724\n\ +_08018AC0: .4byte 0x0000ffff\n\ +_08018AC4: .4byte gBattleMons\n\ +_08018AC8: .4byte gBankAttacker\n\ +_08018ACC: .4byte gHitMarker\n\ +_08018AD0: .4byte gBattlescriptCurrInstr\n\ +_08018AD4: .4byte gUnknown_081D98F3\n\ +_08018AD8:\n\ + cmp r3, 0\n\ + bne _08018AE0\n\ + bl _08019F76\n\ +_08018AE0:\n\ + mov r1, r8\n\ + ldrb r0, [r1]\n\ + cmp r0, 0xB\n\ + beq _08018B50\n\ + cmp r0, 0xB\n\ + bgt _08018AF2\n\ + cmp r0, 0xA\n\ + beq _08018AF8\n\ + b _08018C6A\n\ +_08018AF2:\n\ + cmp r0, 0x12\n\ + beq _08018BA8\n\ + b _08018C6A\n\ +_08018AF8:\n\ + cmp r4, 0xD\n\ + beq _08018AFE\n\ + b _08018C6A\n\ +_08018AFE:\n\ + ldr r0, _08018B28 @ =gBattleMoves\n\ + lsls r1, r3, 1\n\ + adds r1, r3\n\ + lsls r1, 2\n\ + adds r1, r0\n\ + ldrb r0, [r1, 0x1]\n\ + cmp r0, 0\n\ + bne _08018B10\n\ + b _08018C6A\n\ +_08018B10:\n\ + ldr r1, _08018B2C @ =gProtectStructs\n\ + ldr r0, _08018B30 @ =gBankAttacker\n\ + ldrb r0, [r0]\n\ + lsls r0, 4\n\ + adds r0, r1\n\ + ldrb r0, [r0, 0x2]\n\ + lsls r0, 28\n\ + cmp r0, 0\n\ + bge _08018B3C\n\ + ldr r1, _08018B34 @ =gBattlescriptCurrInstr\n\ + ldr r0, _08018B38 @ =gUnknown_081D9843\n\ + b _08018B40\n\ + .align 2, 0\n\ +_08018B28: .4byte gBattleMoves\n\ +_08018B2C: .4byte gProtectStructs\n\ +_08018B30: .4byte gBankAttacker\n\ +_08018B34: .4byte gBattlescriptCurrInstr\n\ +_08018B38: .4byte gUnknown_081D9843\n\ +_08018B3C:\n\ + ldr r1, _08018B48 @ =gBattlescriptCurrInstr\n\ + ldr r0, _08018B4C @ =gUnknown_081D9842\n\ +_08018B40:\n\ + str r0, [r1]\n\ + movs r2, 0x1\n\ + b _08018C68\n\ + .align 2, 0\n\ +_08018B48: .4byte gBattlescriptCurrInstr\n\ +_08018B4C: .4byte gUnknown_081D9842\n\ +_08018B50:\n\ + cmp r4, 0xB\n\ + beq _08018B56\n\ + b _08018C6A\n\ +_08018B56:\n\ + ldr r0, _08018B80 @ =gBattleMoves\n\ + lsls r1, r3, 1\n\ + adds r1, r3\n\ + lsls r1, 2\n\ + adds r1, r0\n\ + ldrb r0, [r1, 0x1]\n\ + cmp r0, 0\n\ + bne _08018B68\n\ + b _08018C6A\n\ +_08018B68:\n\ + ldr r1, _08018B84 @ =gProtectStructs\n\ + ldr r0, _08018B88 @ =gBankAttacker\n\ + ldrb r0, [r0]\n\ + lsls r0, 4\n\ + adds r0, r1\n\ + ldrb r0, [r0, 0x2]\n\ + lsls r0, 28\n\ + cmp r0, 0\n\ + bge _08018B94\n\ + ldr r1, _08018B8C @ =gBattlescriptCurrInstr\n\ + ldr r0, _08018B90 @ =gUnknown_081D9843\n\ + b _08018B98\n\ + .align 2, 0\n\ +_08018B80: .4byte gBattleMoves\n\ +_08018B84: .4byte gProtectStructs\n\ +_08018B88: .4byte gBankAttacker\n\ +_08018B8C: .4byte gBattlescriptCurrInstr\n\ +_08018B90: .4byte gUnknown_081D9843\n\ +_08018B94:\n\ + ldr r1, _08018BA0 @ =gBattlescriptCurrInstr\n\ + ldr r0, _08018BA4 @ =gUnknown_081D9842\n\ +_08018B98:\n\ + str r0, [r1]\n\ + movs r3, 0x1\n\ + mov r9, r3\n\ + b _08018C6A\n\ + .align 2, 0\n\ +_08018BA0: .4byte gBattlescriptCurrInstr\n\ +_08018BA4: .4byte gUnknown_081D9842\n\ +_08018BA8:\n\ + cmp r4, 0xA\n\ + bne _08018C6A\n\ + ldr r1, _08018BF4 @ =gBattleMons\n\ + movs r0, 0x58\n\ + mov r5, r10\n\ + muls r5, r0\n\ + adds r0, r5, 0\n\ + adds r1, 0x4C\n\ + adds r0, r1\n\ + ldr r0, [r0]\n\ + movs r1, 0x20\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + bne _08018C6A\n\ + ldr r2, _08018BF8 @ =0x02017100\n\ + mov r0, r10\n\ + lsls r1, r0, 2\n\ + adds r0, r1, r2\n\ + ldr r3, [r0]\n\ + movs r4, 0x1\n\ + ands r3, r4\n\ + adds r5, r1, 0\n\ + cmp r3, 0\n\ + bne _08018C30\n\ + ldr r0, _08018BFC @ =gBattleCommunication\n\ + strb r3, [r0, 0x5]\n\ + ldr r1, _08018C00 @ =gProtectStructs\n\ + ldr r0, _08018C04 @ =gBankAttacker\n\ + ldrb r0, [r0]\n\ + lsls r0, 4\n\ + adds r0, r1\n\ + ldrb r0, [r0, 0x2]\n\ + lsls r0, 28\n\ + cmp r0, 0\n\ + bge _08018C10\n\ + ldr r1, _08018C08 @ =gBattlescriptCurrInstr\n\ + ldr r0, _08018C0C @ =gUnknown_081D987C\n\ + b _08018C14\n\ + .align 2, 0\n\ +_08018BF4: .4byte gBattleMons\n\ +_08018BF8: .4byte 0x02017100\n\ +_08018BFC: .4byte gBattleCommunication\n\ +_08018C00: .4byte gProtectStructs\n\ +_08018C04: .4byte gBankAttacker\n\ +_08018C08: .4byte gBattlescriptCurrInstr\n\ +_08018C0C: .4byte gUnknown_081D987C\n\ +_08018C10:\n\ + ldr r1, _08018C28 @ =gBattlescriptCurrInstr\n\ + ldr r0, _08018C2C @ =gUnknown_081D987B\n\ +_08018C14:\n\ + str r0, [r1]\n\ + adds r0, r5, r2\n\ + ldr r1, [r0]\n\ + movs r2, 0x1\n\ + orrs r1, r2\n\ + str r1, [r0]\n\ + movs r1, 0x2\n\ + mov r9, r1\n\ + b _08018C6A\n\ + .align 2, 0\n\ +_08018C28: .4byte gBattlescriptCurrInstr\n\ +_08018C2C: .4byte gUnknown_081D987B\n\ +_08018C30:\n\ + ldr r0, _08018C4C @ =gBattleCommunication\n\ + strb r4, [r0, 0x5]\n\ + ldr r1, _08018C50 @ =gProtectStructs\n\ + ldr r0, _08018C54 @ =gBankAttacker\n\ + ldrb r0, [r0]\n\ + lsls r0, 4\n\ + adds r0, r1\n\ + ldrb r0, [r0, 0x2]\n\ + lsls r0, 28\n\ + cmp r0, 0\n\ + bge _08018C60\n\ + ldr r1, _08018C58 @ =gBattlescriptCurrInstr\n\ + ldr r0, _08018C5C @ =gUnknown_081D987C\n\ + b _08018C64\n\ + .align 2, 0\n\ +_08018C4C: .4byte gBattleCommunication\n\ +_08018C50: .4byte gProtectStructs\n\ +_08018C54: .4byte gBankAttacker\n\ +_08018C58: .4byte gBattlescriptCurrInstr\n\ +_08018C5C: .4byte gUnknown_081D987C\n\ +_08018C60:\n\ + ldr r1, _08018CA4 @ =gBattlescriptCurrInstr\n\ + ldr r0, _08018CA8 @ =gUnknown_081D987B\n\ +_08018C64:\n\ + str r0, [r1]\n\ + movs r2, 0x2\n\ +_08018C68:\n\ + mov r9, r2\n\ +_08018C6A:\n\ + mov r3, r9\n\ + cmp r3, 0x1\n\ + beq _08018C74\n\ + bl _08019F76\n\ +_08018C74:\n\ + ldr r1, _08018CAC @ =gBattleMons\n\ + movs r0, 0x58\n\ + mov r5, r10\n\ + muls r5, r0\n\ + adds r0, r5, 0\n\ + adds r1, r0, r1\n\ + ldrh r0, [r1, 0x2C]\n\ + ldrh r2, [r1, 0x28]\n\ + cmp r0, r2\n\ + bne _08018CD0\n\ + ldr r1, _08018CB0 @ =gProtectStructs\n\ + ldr r0, _08018CB4 @ =gBankAttacker\n\ + ldrb r0, [r0]\n\ + lsls r0, 4\n\ + adds r0, r1\n\ + ldrb r0, [r0, 0x2]\n\ + lsls r0, 28\n\ + cmp r0, 0\n\ + bge _08018CBC\n\ + ldr r1, _08018CA4 @ =gBattlescriptCurrInstr\n\ + ldr r0, _08018CB8 @ =gUnknown_081D9866\n\ + str r0, [r1]\n\ + bl _08019F76\n\ + .align 2, 0\n\ +_08018CA4: .4byte gBattlescriptCurrInstr\n\ +_08018CA8: .4byte gUnknown_081D987B\n\ +_08018CAC: .4byte gBattleMons\n\ +_08018CB0: .4byte gProtectStructs\n\ +_08018CB4: .4byte gBankAttacker\n\ +_08018CB8: .4byte gUnknown_081D9866\n\ +_08018CBC:\n\ + ldr r1, _08018CC8 @ =gBattlescriptCurrInstr\n\ + ldr r0, _08018CCC @ =gUnknown_081D9865\n\ + str r0, [r1]\n\ + bl _08019F76\n\ + .align 2, 0\n\ +_08018CC8: .4byte gBattlescriptCurrInstr\n\ +_08018CCC: .4byte gUnknown_081D9865\n\ +_08018CD0:\n\ + ldr r2, _08018CEC @ =gBattleMoveDamage\n\ + ldrh r0, [r1, 0x2C]\n\ + lsrs r0, 2\n\ + str r0, [r2]\n\ + cmp r0, 0\n\ + bne _08018CE0\n\ + mov r3, r9\n\ + str r3, [r2]\n\ +_08018CE0:\n\ + ldr r0, [r2]\n\ + negs r0, r0\n\ + str r0, [r2]\n\ + bl _08019F76\n\ + .align 2, 0\n\ +_08018CEC: .4byte gBattleMoveDamage\n\ +_08018CF0:\n\ + mov r5, r8\n\ + ldrb r0, [r5]\n\ + subs r0, 0x9\n\ + cmp r0, 0x2F\n\ + bls _08018CFE\n\ + bl _08019F76\n\ +_08018CFE:\n\ + lsls r0, 2\n\ + ldr r1, _08018D08 @ =_08018D0C\n\ + adds r0, r1\n\ + ldr r0, [r0]\n\ + mov pc, r0\n\ + .align 2, 0\n\ +_08018D08: .4byte _08018D0C\n\ + .align 2, 0\n\ +_08018D0C:\n\ + .4byte _08019128\n\ + .4byte _08019F76\n\ + .4byte _08019F76\n\ + .4byte _08019F76\n\ + .4byte _08019F76\n\ + .4byte _08019F76\n\ + .4byte _08019F76\n\ + .4byte _08018DCC\n\ + .4byte _08019F76\n\ + .4byte _08019F76\n\ + .4byte _08019F76\n\ + .4byte _08019F76\n\ + .4byte _08019F76\n\ + .4byte _08019F76\n\ + .4byte _08019F76\n\ + .4byte _08018E94\n\ + .4byte _08019F76\n\ + .4byte _08019F76\n\ + .4byte _08018F54\n\ + .4byte _08019F76\n\ + .4byte _08019F76\n\ + .4byte _08019F76\n\ + .4byte _08019F76\n\ + .4byte _08019F76\n\ + .4byte _08019F76\n\ + .4byte _08019F76\n\ + .4byte _08019F76\n\ + .4byte _08019F76\n\ + .4byte _08019F76\n\ + .4byte _0801904C\n\ + .4byte _08019F76\n\ + .4byte _08019F76\n\ + .4byte _08019F76\n\ + .4byte _08019F76\n\ + .4byte _08019F76\n\ + .4byte _08019F76\n\ + .4byte _08019F76\n\ + .4byte _08019F76\n\ + .4byte _08019F76\n\ + .4byte _08019F76\n\ + .4byte _08019204\n\ + .4byte _08019F76\n\ + .4byte _08019F76\n\ + .4byte _08019F76\n\ + .4byte _08019F76\n\ + .4byte _08019F76\n\ + .4byte _08019F76\n\ + .4byte _080192E0\n\ +_08018DCC:\n\ + ldr r0, _08018E74 @ =gBattleMoveFlags\n\ + ldrb r1, [r0]\n\ + movs r0, 0x29\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + beq _08018DDC\n\ + bl _08019F76\n\ +_08018DDC:\n\ + cmp r3, 0xA5\n\ + bne _08018DE4\n\ + bl _08019F76\n\ +_08018DE4:\n\ + ldr r0, _08018E78 @ =gBattleMoves\n\ + lsls r1, r3, 1\n\ + adds r1, r3\n\ + lsls r1, 2\n\ + adds r1, r0\n\ + ldrb r0, [r1, 0x1]\n\ + cmp r0, 0\n\ + bne _08018DF8\n\ + bl _08019F76\n\ +_08018DF8:\n\ + ldr r2, _08018E7C @ =gSpecialStatuses\n\ + ldr r0, _08018E80 @ =gBankTarget\n\ + ldrb r1, [r0]\n\ + lsls r0, r1, 2\n\ + adds r0, r1\n\ + lsls r1, r0, 2\n\ + adds r0, r2, 0\n\ + adds r0, 0x8\n\ + adds r0, r1, r0\n\ + ldr r0, [r0]\n\ + cmp r0, 0\n\ + bne _08018E20\n\ + adds r0, r2, 0\n\ + adds r0, 0xC\n\ + adds r0, r1, r0\n\ + ldr r0, [r0]\n\ + cmp r0, 0\n\ + bne _08018E20\n\ + bl _08019F76\n\ +_08018E20:\n\ + ldr r1, _08018E84 @ =gBattleMons\n\ + movs r0, 0x58\n\ + mov r2, r10\n\ + muls r2, r0\n\ + adds r0, r2, 0\n\ + adds r1, r0, r1\n\ + adds r3, r1, 0\n\ + adds r3, 0x21\n\ + ldrb r0, [r3]\n\ + cmp r0, r4\n\ + bne _08018E3A\n\ + bl _08019F76\n\ +_08018E3A:\n\ + adds r2, r1, 0\n\ + adds r2, 0x22\n\ + ldrb r0, [r2]\n\ + cmp r0, r4\n\ + bne _08018E48\n\ + bl _08019F76\n\ +_08018E48:\n\ + ldrh r0, [r1, 0x28]\n\ + cmp r0, 0\n\ + bne _08018E52\n\ + bl _08019F76\n\ +_08018E52:\n\ + strb r4, [r3]\n\ + strb r4, [r2]\n\ + ldr r1, _08018E88 @ =gBattleTextBuff1\n\ + movs r0, 0xFD\n\ + strb r0, [r1]\n\ + movs r0, 0x3\n\ + strb r0, [r1, 0x1]\n\ + strb r4, [r1, 0x2]\n\ + movs r0, 0xFF\n\ + strb r0, [r1, 0x3]\n\ + bl b_movescr_stack_push_cursor\n\ + ldr r1, _08018E8C @ =gBattlescriptCurrInstr\n\ + ldr r0, _08018E90 @ =gUnknown_081D9921\n\ + str r0, [r1]\n\ + bl _08019F22\n\ + .align 2, 0\n\ +_08018E74: .4byte gBattleMoveFlags\n\ +_08018E78: .4byte gBattleMoves\n\ +_08018E7C: .4byte gSpecialStatuses\n\ +_08018E80: .4byte gBankTarget\n\ +_08018E84: .4byte gBattleMons\n\ +_08018E88: .4byte gBattleTextBuff1\n\ +_08018E8C: .4byte gBattlescriptCurrInstr\n\ +_08018E90: .4byte gUnknown_081D9921\n\ +_08018E94:\n\ + ldr r0, _08018F2C @ =gBattleMoveFlags\n\ + ldrb r1, [r0]\n\ + movs r0, 0x29\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + beq _08018EA4\n\ + bl _08019F76\n\ +_08018EA4:\n\ + ldr r1, _08018F30 @ =gBattleMons\n\ + ldr r0, _08018F34 @ =gBankAttacker\n\ + ldrb r2, [r0]\n\ + movs r0, 0x58\n\ + muls r0, r2\n\ + adds r4, r0, r1\n\ + ldrh r0, [r4, 0x28]\n\ + cmp r0, 0\n\ + bne _08018EBA\n\ + bl _08019F76\n\ +_08018EBA:\n\ + ldr r0, _08018F38 @ =gProtectStructs\n\ + lsls r1, r2, 4\n\ + adds r1, r0\n\ + ldrb r0, [r1, 0x1]\n\ + lsls r0, 31\n\ + cmp r0, 0\n\ + beq _08018ECC\n\ + bl _08019F76\n\ +_08018ECC:\n\ + ldr r2, _08018F3C @ =gSpecialStatuses\n\ + ldr r0, _08018F40 @ =gBankTarget\n\ + ldrb r1, [r0]\n\ + lsls r0, r1, 2\n\ + adds r0, r1\n\ + lsls r1, r0, 2\n\ + adds r0, r2, 0\n\ + adds r0, 0x8\n\ + adds r0, r1, r0\n\ + ldr r0, [r0]\n\ + cmp r0, 0\n\ + bne _08018EF4\n\ + adds r0, r2, 0\n\ + adds r0, 0xC\n\ + adds r0, r1, r0\n\ + ldr r0, [r0]\n\ + cmp r0, 0\n\ + bne _08018EF4\n\ + bl _08019F76\n\ +_08018EF4:\n\ + ldr r1, _08018F44 @ =gBattleMoves\n\ + lsls r0, r3, 1\n\ + adds r0, r3\n\ + lsls r0, 2\n\ + adds r0, r1\n\ + ldrb r1, [r0, 0x8]\n\ + movs r2, 0x1\n\ + adds r0, r2, 0\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + bne _08018F0E\n\ + bl _08019F76\n\ +_08018F0E:\n\ + ldr r1, _08018F48 @ =gBattleMoveDamage\n\ + ldrh r0, [r4, 0x2C]\n\ + lsrs r0, 4\n\ + str r0, [r1]\n\ + cmp r0, 0\n\ + bne _08018F1C\n\ + str r2, [r1]\n\ +_08018F1C:\n\ + bl b_movescr_stack_push_cursor\n\ + ldr r1, _08018F4C @ =gBattlescriptCurrInstr\n\ + ldr r0, _08018F50 @ =gUnknown_081D9928\n\ + str r0, [r1]\n\ + bl _08019F22\n\ + .align 2, 0\n\ +_08018F2C: .4byte gBattleMoveFlags\n\ +_08018F30: .4byte gBattleMons\n\ +_08018F34: .4byte gBankAttacker\n\ +_08018F38: .4byte gProtectStructs\n\ +_08018F3C: .4byte gSpecialStatuses\n\ +_08018F40: .4byte gBankTarget\n\ +_08018F44: .4byte gBattleMoves\n\ +_08018F48: .4byte gBattleMoveDamage\n\ +_08018F4C: .4byte gBattlescriptCurrInstr\n\ +_08018F50: .4byte gUnknown_081D9928\n\ +_08018F54:\n\ + ldr r0, _08019020 @ =gBattleMoveFlags\n\ + ldrb r1, [r0]\n\ + movs r0, 0x29\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + beq _08018F64\n\ + bl _08019F76\n\ +_08018F64:\n\ + ldr r1, _08019024 @ =gBattleMons\n\ + ldr r0, _08019028 @ =gBankAttacker\n\ + ldrb r2, [r0]\n\ + movs r0, 0x58\n\ + muls r0, r2\n\ + adds r0, r1\n\ + ldrh r0, [r0, 0x28]\n\ + cmp r0, 0\n\ + bne _08018F7A\n\ + bl _08019F76\n\ +_08018F7A:\n\ + ldr r0, _0801902C @ =gProtectStructs\n\ + lsls r1, r2, 4\n\ + adds r1, r0\n\ + ldrb r0, [r1, 0x1]\n\ + lsls r0, 31\n\ + cmp r0, 0\n\ + beq _08018F8C\n\ + bl _08019F76\n\ +_08018F8C:\n\ + ldr r2, _08019030 @ =gSpecialStatuses\n\ + ldr r0, _08019034 @ =gBankTarget\n\ + ldrb r1, [r0]\n\ + lsls r0, r1, 2\n\ + adds r0, r1\n\ + lsls r1, r0, 2\n\ + adds r0, r2, 0\n\ + adds r0, 0x8\n\ + adds r0, r1, r0\n\ + ldr r0, [r0]\n\ + cmp r0, 0\n\ + bne _08018FB4\n\ + adds r0, r2, 0\n\ + adds r0, 0xC\n\ + adds r0, r1, r0\n\ + ldr r0, [r0]\n\ + cmp r0, 0\n\ + bne _08018FB4\n\ + bl _08019F76\n\ +_08018FB4:\n\ + ldr r1, _08019038 @ =gBattleMoves\n\ + lsls r0, r3, 1\n\ + adds r0, r3\n\ + lsls r0, 2\n\ + adds r0, r1\n\ + ldrb r1, [r0, 0x8]\n\ + movs r0, 0x1\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + bne _08018FCC\n\ + bl _08019F76\n\ +_08018FCC:\n\ + bl Random\n\ + lsls r0, 16\n\ + lsrs r0, 16\n\ + movs r1, 0xA\n\ + bl __umodsi3\n\ + lsls r0, 16\n\ + cmp r0, 0\n\ + beq _08018FE4\n\ + bl _08019F76\n\ +_08018FE4:\n\ + ldr r5, _0801903C @ =gBattleCommunication\n\ + movs r4, 0x3\n\ +_08018FE8:\n\ + bl Random\n\ + ands r0, r4\n\ + strb r0, [r5, 0x3]\n\ + cmp r0, 0\n\ + beq _08018FE8\n\ + ldr r1, _0801903C @ =gBattleCommunication\n\ + ldrb r0, [r1, 0x3]\n\ + cmp r0, 0x3\n\ + bne _08019000\n\ + adds r0, 0x2\n\ + strb r0, [r1, 0x3]\n\ +_08019000:\n\ + ldrb r0, [r1, 0x3]\n\ + adds r0, 0x40\n\ + strb r0, [r1, 0x3]\n\ + bl b_movescr_stack_push_cursor\n\ + ldr r1, _08019040 @ =gBattlescriptCurrInstr\n\ + ldr r0, _08019044 @ =gUnknown_081D9950\n\ + str r0, [r1]\n\ + ldr r2, _08019048 @ =gHitMarker\n\ + ldr r0, [r2]\n\ + movs r1, 0x80\n\ + lsls r1, 6\n\ + orrs r0, r1\n\ + str r0, [r2]\n\ + bl _08019F22\n\ + .align 2, 0\n\ +_08019020: .4byte gBattleMoveFlags\n\ +_08019024: .4byte gBattleMons\n\ +_08019028: .4byte gBankAttacker\n\ +_0801902C: .4byte gProtectStructs\n\ +_08019030: .4byte gSpecialStatuses\n\ +_08019034: .4byte gBankTarget\n\ +_08019038: .4byte gBattleMoves\n\ +_0801903C: .4byte gBattleCommunication\n\ +_08019040: .4byte gBattlescriptCurrInstr\n\ +_08019044: .4byte gUnknown_081D9950\n\ +_08019048: .4byte gHitMarker\n\ +_0801904C:\n\ + ldr r0, _080190FC @ =gBattleMoveFlags\n\ + ldrb r1, [r0]\n\ + movs r0, 0x29\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + beq _0801905C\n\ + bl _08019F76\n\ +_0801905C:\n\ + ldr r1, _08019100 @ =gBattleMons\n\ + ldr r0, _08019104 @ =gBankAttacker\n\ + ldrb r2, [r0]\n\ + movs r0, 0x58\n\ + muls r0, r2\n\ + adds r0, r1\n\ + ldrh r0, [r0, 0x28]\n\ + cmp r0, 0\n\ + bne _08019072\n\ + bl _08019F76\n\ +_08019072:\n\ + ldr r0, _08019108 @ =gProtectStructs\n\ + lsls r1, r2, 4\n\ + adds r1, r0\n\ + ldrb r0, [r1, 0x1]\n\ + lsls r0, 31\n\ + cmp r0, 0\n\ + beq _08019084\n\ + bl _08019F76\n\ +_08019084:\n\ + ldr r2, _0801910C @ =gSpecialStatuses\n\ + ldr r0, _08019110 @ =gBankTarget\n\ + ldrb r1, [r0]\n\ + lsls r0, r1, 2\n\ + adds r0, r1\n\ + lsls r1, r0, 2\n\ + adds r0, r2, 0\n\ + adds r0, 0x8\n\ + adds r0, r1, r0\n\ + ldr r0, [r0]\n\ + cmp r0, 0\n\ + bne _080190AC\n\ + adds r0, r2, 0\n\ + adds r0, 0xC\n\ + adds r0, r1, r0\n\ + ldr r0, [r0]\n\ + cmp r0, 0\n\ + bne _080190AC\n\ + bl _08019F76\n\ +_080190AC:\n\ + ldr r1, _08019114 @ =gBattleMoves\n\ + lsls r0, r3, 1\n\ + adds r0, r3\n\ + lsls r0, 2\n\ + adds r0, r1\n\ + ldrb r1, [r0, 0x8]\n\ + movs r0, 0x1\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + bne _080190C4\n\ + bl _08019F76\n\ +_080190C4:\n\ + bl Random\n\ + lsls r0, 16\n\ + lsrs r0, 16\n\ + movs r1, 0x3\n\ + bl __umodsi3\n\ + lsls r0, 16\n\ + cmp r0, 0\n\ + beq _080190DC\n\ + bl _08019F76\n\ +_080190DC:\n\ + ldr r1, _08019118 @ =gBattleCommunication\n\ + movs r0, 0x42\n\ + strb r0, [r1, 0x3]\n\ + bl b_movescr_stack_push_cursor\n\ + ldr r1, _0801911C @ =gBattlescriptCurrInstr\n\ + ldr r0, _08019120 @ =gUnknown_081D9950\n\ + str r0, [r1]\n\ + ldr r2, _08019124 @ =gHitMarker\n\ + ldr r0, [r2]\n\ + movs r1, 0x80\n\ + lsls r1, 6\n\ + orrs r0, r1\n\ + str r0, [r2]\n\ + bl _08019F22\n\ + .align 2, 0\n\ +_080190FC: .4byte gBattleMoveFlags\n\ +_08019100: .4byte gBattleMons\n\ +_08019104: .4byte gBankAttacker\n\ +_08019108: .4byte gProtectStructs\n\ +_0801910C: .4byte gSpecialStatuses\n\ +_08019110: .4byte gBankTarget\n\ +_08019114: .4byte gBattleMoves\n\ +_08019118: .4byte gBattleCommunication\n\ +_0801911C: .4byte gBattlescriptCurrInstr\n\ +_08019120: .4byte gUnknown_081D9950\n\ +_08019124: .4byte gHitMarker\n\ +_08019128:\n\ + ldr r0, _080191D8 @ =gBattleMoveFlags\n\ + ldrb r1, [r0]\n\ + movs r0, 0x29\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + beq _08019138\n\ + bl _08019F76\n\ +_08019138:\n\ + ldr r1, _080191DC @ =gBattleMons\n\ + ldr r0, _080191E0 @ =gBankAttacker\n\ + ldrb r2, [r0]\n\ + movs r0, 0x58\n\ + muls r0, r2\n\ + adds r0, r1\n\ + ldrh r0, [r0, 0x28]\n\ + cmp r0, 0\n\ + bne _0801914E\n\ + bl _08019F76\n\ +_0801914E:\n\ + ldr r0, _080191E4 @ =gProtectStructs\n\ + lsls r1, r2, 4\n\ + adds r1, r0\n\ + ldrb r0, [r1, 0x1]\n\ + lsls r0, 31\n\ + cmp r0, 0\n\ + beq _08019160\n\ + bl _08019F76\n\ +_08019160:\n\ + ldr r2, _080191E8 @ =gSpecialStatuses\n\ + ldr r0, _080191EC @ =gBankTarget\n\ + ldrb r1, [r0]\n\ + lsls r0, r1, 2\n\ + adds r0, r1\n\ + lsls r1, r0, 2\n\ + adds r0, r2, 0\n\ + adds r0, 0x8\n\ + adds r0, r1, r0\n\ + ldr r0, [r0]\n\ + cmp r0, 0\n\ + bne _08019188\n\ + adds r0, r2, 0\n\ + adds r0, 0xC\n\ + adds r0, r1, r0\n\ + ldr r0, [r0]\n\ + cmp r0, 0\n\ + bne _08019188\n\ + bl _08019F76\n\ +_08019188:\n\ + ldr r1, _080191F0 @ =gBattleMoves\n\ + lsls r0, r3, 1\n\ + adds r0, r3\n\ + lsls r0, 2\n\ + adds r0, r1\n\ + ldrb r1, [r0, 0x8]\n\ + movs r0, 0x1\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + bne _080191A0\n\ + bl _08019F76\n\ +_080191A0:\n\ + bl Random\n\ + lsls r0, 16\n\ + lsrs r0, 16\n\ + movs r1, 0x3\n\ + bl __umodsi3\n\ + lsls r0, 16\n\ + cmp r0, 0\n\ + beq _080191B8\n\ + bl _08019F76\n\ +_080191B8:\n\ + ldr r1, _080191F4 @ =gBattleCommunication\n\ + movs r0, 0x45\n\ + strb r0, [r1, 0x3]\n\ + bl b_movescr_stack_push_cursor\n\ + ldr r1, _080191F8 @ =gBattlescriptCurrInstr\n\ + ldr r0, _080191FC @ =gUnknown_081D9950\n\ + str r0, [r1]\n\ + ldr r2, _08019200 @ =gHitMarker\n\ + ldr r0, [r2]\n\ + movs r1, 0x80\n\ + lsls r1, 6\n\ + orrs r0, r1\n\ + str r0, [r2]\n\ + bl _08019F22\n\ + .align 2, 0\n\ +_080191D8: .4byte gBattleMoveFlags\n\ +_080191DC: .4byte gBattleMons\n\ +_080191E0: .4byte gBankAttacker\n\ +_080191E4: .4byte gProtectStructs\n\ +_080191E8: .4byte gSpecialStatuses\n\ +_080191EC: .4byte gBankTarget\n\ +_080191F0: .4byte gBattleMoves\n\ +_080191F4: .4byte gBattleCommunication\n\ +_080191F8: .4byte gBattlescriptCurrInstr\n\ +_080191FC: .4byte gUnknown_081D9950\n\ +_08019200: .4byte gHitMarker\n\ +_08019204:\n\ + ldr r0, _080192B4 @ =gBattleMoveFlags\n\ + ldrb r1, [r0]\n\ + movs r0, 0x29\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + beq _08019214\n\ + bl _08019F76\n\ +_08019214:\n\ + ldr r1, _080192B8 @ =gBattleMons\n\ + ldr r0, _080192BC @ =gBankAttacker\n\ + ldrb r2, [r0]\n\ + movs r0, 0x58\n\ + muls r0, r2\n\ + adds r0, r1\n\ + ldrh r0, [r0, 0x28]\n\ + cmp r0, 0\n\ + bne _0801922A\n\ + bl _08019F76\n\ +_0801922A:\n\ + ldr r0, _080192C0 @ =gProtectStructs\n\ + lsls r1, r2, 4\n\ + adds r1, r0\n\ + ldrb r0, [r1, 0x1]\n\ + lsls r0, 31\n\ + cmp r0, 0\n\ + beq _0801923C\n\ + bl _08019F76\n\ +_0801923C:\n\ + ldr r1, _080192C4 @ =gBattleMoves\n\ + lsls r0, r3, 1\n\ + adds r0, r3\n\ + lsls r0, 2\n\ + adds r0, r1\n\ + ldrb r1, [r0, 0x8]\n\ + movs r0, 0x1\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + bne _08019254\n\ + bl _08019F76\n\ +_08019254:\n\ + ldr r2, _080192C8 @ =gSpecialStatuses\n\ + ldr r0, _080192CC @ =gBankTarget\n\ + ldrb r1, [r0]\n\ + lsls r0, r1, 2\n\ + adds r0, r1\n\ + lsls r1, r0, 2\n\ + adds r0, r2, 0\n\ + adds r0, 0x8\n\ + adds r0, r1, r0\n\ + ldr r0, [r0]\n\ + cmp r0, 0\n\ + bne _0801927C\n\ + adds r0, r2, 0\n\ + adds r0, 0xC\n\ + adds r0, r1, r0\n\ + ldr r0, [r0]\n\ + cmp r0, 0\n\ + bne _0801927C\n\ + bl _08019F76\n\ +_0801927C:\n\ + bl Random\n\ + lsls r0, 16\n\ + lsrs r0, 16\n\ + movs r1, 0x3\n\ + bl __umodsi3\n\ + lsls r0, 16\n\ + cmp r0, 0\n\ + beq _08019294\n\ + bl _08019F76\n\ +_08019294:\n\ + ldr r1, _080192D0 @ =gBattleCommunication\n\ + movs r0, 0x43\n\ + strb r0, [r1, 0x3]\n\ + bl b_movescr_stack_push_cursor\n\ + ldr r1, _080192D4 @ =gBattlescriptCurrInstr\n\ + ldr r0, _080192D8 @ =gUnknown_081D9950\n\ + str r0, [r1]\n\ + ldr r2, _080192DC @ =gHitMarker\n\ + ldr r0, [r2]\n\ + movs r1, 0x80\n\ + lsls r1, 6\n\ + orrs r0, r1\n\ + str r0, [r2]\n\ + bl _08019F22\n\ + .align 2, 0\n\ +_080192B4: .4byte gBattleMoveFlags\n\ +_080192B8: .4byte gBattleMons\n\ +_080192BC: .4byte gBankAttacker\n\ +_080192C0: .4byte gProtectStructs\n\ +_080192C4: .4byte gBattleMoves\n\ +_080192C8: .4byte gSpecialStatuses\n\ +_080192CC: .4byte gBankTarget\n\ +_080192D0: .4byte gBattleCommunication\n\ +_080192D4: .4byte gBattlescriptCurrInstr\n\ +_080192D8: .4byte gUnknown_081D9950\n\ +_080192DC: .4byte gHitMarker\n\ +_080192E0:\n\ + ldr r0, _08019420 @ =gBattleMoveFlags\n\ + ldrb r1, [r0]\n\ + movs r0, 0x29\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + beq _080192F0\n\ + bl _08019F76\n\ +_080192F0:\n\ + ldr r5, _08019424 @ =gBattleMons\n\ + ldr r7, _08019428 @ =gBankAttacker\n\ + ldrb r1, [r7]\n\ + movs r6, 0x58\n\ + adds r0, r1, 0\n\ + muls r0, r6\n\ + adds r0, r5\n\ + ldrh r0, [r0, 0x28]\n\ + cmp r0, 0\n\ + bne _08019308\n\ + bl _08019F76\n\ +_08019308:\n\ + ldr r0, _0801942C @ =gProtectStructs\n\ + lsls r1, 4\n\ + adds r1, r0\n\ + ldrb r0, [r1, 0x1]\n\ + lsls r0, 31\n\ + cmp r0, 0\n\ + beq _0801931A\n\ + bl _08019F76\n\ +_0801931A:\n\ + ldr r1, _08019430 @ =gBattleMoves\n\ + lsls r0, r3, 1\n\ + adds r0, r3\n\ + lsls r0, 2\n\ + adds r0, r1\n\ + ldrb r1, [r0, 0x8]\n\ + movs r0, 0x1\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + bne _08019332\n\ + bl _08019F76\n\ +_08019332:\n\ + ldr r3, _08019434 @ =gSpecialStatuses\n\ + ldr r0, _08019438 @ =gBankTarget\n\ + mov r8, r0\n\ + ldrb r1, [r0]\n\ + lsls r0, r1, 2\n\ + adds r0, r1\n\ + lsls r2, r0, 2\n\ + adds r0, r3, 0\n\ + adds r0, 0x8\n\ + adds r0, r2, r0\n\ + ldr r0, [r0]\n\ + cmp r0, 0\n\ + bne _0801935C\n\ + adds r0, r3, 0\n\ + adds r0, 0xC\n\ + adds r0, r2, r0\n\ + ldr r0, [r0]\n\ + cmp r0, 0\n\ + bne _0801935C\n\ + bl _08019F76\n\ +_0801935C:\n\ + adds r0, r1, 0\n\ + muls r0, r6\n\ + adds r0, r5\n\ + ldrh r0, [r0, 0x28]\n\ + cmp r0, 0\n\ + bne _0801936C\n\ + bl _08019F76\n\ +_0801936C:\n\ + bl Random\n\ + lsls r0, 16\n\ + lsrs r0, 16\n\ + movs r1, 0x3\n\ + bl __umodsi3\n\ + lsls r0, 16\n\ + cmp r0, 0\n\ + beq _08019384\n\ + bl _08019F76\n\ +_08019384:\n\ + ldrb r0, [r7]\n\ + muls r0, r6\n\ + adds r0, r5\n\ + adds r0, 0x20\n\ + ldrb r0, [r0]\n\ + cmp r0, 0xC\n\ + bne _08019396\n\ + bl _08019F76\n\ +_08019396:\n\ + ldr r0, [sp, 0x8]\n\ + ldr r1, [sp, 0x10]\n\ + bl GetGenderFromSpeciesAndPersonality\n\ + adds r4, r0, 0\n\ + ldr r0, [sp, 0xC]\n\ + ldr r1, [sp, 0x14]\n\ + bl GetGenderFromSpeciesAndPersonality\n\ + lsls r4, 24\n\ + lsls r0, 24\n\ + cmp r4, r0\n\ + bne _080193B4\n\ + bl _08019F76\n\ +_080193B4:\n\ + ldrb r0, [r7]\n\ + muls r0, r6\n\ + adds r4, r5, 0\n\ + adds r4, 0x50\n\ + adds r0, r4\n\ + ldr r0, [r0]\n\ + movs r1, 0xF0\n\ + lsls r1, 12\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + beq _080193CE\n\ + bl _08019F76\n\ +_080193CE:\n\ + ldr r0, [sp, 0x8]\n\ + ldr r1, [sp, 0x10]\n\ + bl GetGenderFromSpeciesAndPersonality\n\ + lsls r0, 24\n\ + lsrs r0, 24\n\ + cmp r0, 0xFF\n\ + bne _080193E2\n\ + bl _08019F76\n\ +_080193E2:\n\ + ldr r0, [sp, 0xC]\n\ + ldr r1, [sp, 0x14]\n\ + bl GetGenderFromSpeciesAndPersonality\n\ + lsls r0, 24\n\ + lsrs r0, 24\n\ + cmp r0, 0xFF\n\ + bne _080193F6\n\ + bl _08019F76\n\ +_080193F6:\n\ + ldrb r0, [r7]\n\ + adds r2, r0, 0\n\ + muls r2, r6\n\ + adds r2, r4\n\ + ldr r1, _0801943C @ =gBitTable\n\ + mov r3, r8\n\ + ldrb r0, [r3]\n\ + lsls r0, 2\n\ + adds r0, r1\n\ + ldr r1, [r0]\n\ + lsls r1, 16\n\ + ldr r0, [r2]\n\ + orrs r0, r1\n\ + str r0, [r2]\n\ + bl b_movescr_stack_push_cursor\n\ + ldr r1, _08019440 @ =gBattlescriptCurrInstr\n\ + ldr r0, _08019444 @ =gUnknown_081D9943\n\ + str r0, [r1]\n\ + bl _08019F22\n\ + .align 2, 0\n\ +_08019420: .4byte gBattleMoveFlags\n\ +_08019424: .4byte gBattleMons\n\ +_08019428: .4byte gBankAttacker\n\ +_0801942C: .4byte gProtectStructs\n\ +_08019430: .4byte gBattleMoves\n\ +_08019434: .4byte gSpecialStatuses\n\ +_08019438: .4byte gBankTarget\n\ +_0801943C: .4byte gBitTable\n\ +_08019440: .4byte gBattlescriptCurrInstr\n\ +_08019444: .4byte gUnknown_081D9943\n\ +_08019448:\n\ + movs r5, 0\n\ + mov r10, r5\n\ + ldr r0, _0801947C @ =gNoOfAllBanks\n\ + ldrb r0, [r0]\n\ + cmp r10, r0\n\ + bcc _08019458\n\ + bl _08019F76\n\ +_08019458:\n\ + ldr r1, _08019480 @ =gBattleMons\n\ + movs r0, 0x58\n\ + mov r2, r10\n\ + muls r2, r0\n\ + adds r0, r2, 0\n\ + adds r0, r1\n\ + adds r0, 0x20\n\ + ldrb r0, [r0]\n\ + subs r0, 0x7\n\ + adds r2, r1, 0\n\ + cmp r0, 0x41\n\ + bls _08019472\n\ + b _080196D6\n\ +_08019472:\n\ + lsls r0, 2\n\ + ldr r1, _08019484 @ =_08019488\n\ + adds r0, r1\n\ + ldr r0, [r0]\n\ + mov pc, r0\n\ + .align 2, 0\n\ +_0801947C: .4byte gNoOfAllBanks\n\ +_08019480: .4byte gBattleMons\n\ +_08019484: .4byte _08019488\n\ + .align 2, 0\n\ +_08019488:\n\ + .4byte _080195EC\n\ + .4byte _080196D6\n\ + .4byte _080196D6\n\ + .4byte _080196D6\n\ + .4byte _080196D6\n\ + .4byte _080196B0\n\ + .4byte _080196D6\n\ + .4byte _080196D6\n\ + .4byte _08019614\n\ + .4byte _080196D6\n\ + .4byte _08019590\n\ + .4byte _080196D6\n\ + .4byte _080196D6\n\ + .4byte _080195BC\n\ + .4byte _080196D6\n\ + .4byte _080196D6\n\ + .4byte _080196D6\n\ + .4byte _080196D6\n\ + .4byte _080196D6\n\ + .4byte _080196D6\n\ + .4byte _080196D6\n\ + .4byte _080196D6\n\ + .4byte _080196D6\n\ + .4byte _080196D6\n\ + .4byte _080196D6\n\ + .4byte _080196D6\n\ + .4byte _080196D6\n\ + .4byte _080196D6\n\ + .4byte _080196D6\n\ + .4byte _080196D6\n\ + .4byte _080196D6\n\ + .4byte _080196D6\n\ + .4byte _080196D6\n\ + .4byte _08019680\n\ + .4byte _08019650\n\ + .4byte _080196D6\n\ + .4byte _080196D6\n\ + .4byte _080196D6\n\ + .4byte _080196D6\n\ + .4byte _080196D6\n\ + .4byte _080196D6\n\ + .4byte _080196D6\n\ + .4byte _080196D6\n\ + .4byte _080196D6\n\ + .4byte _080196D6\n\ + .4byte _080196D6\n\ + .4byte _080196D6\n\ + .4byte _080196D6\n\ + .4byte _080196D6\n\ + .4byte _080196D6\n\ + .4byte _080196D6\n\ + .4byte _080196D6\n\ + .4byte _080196D6\n\ + .4byte _080196D6\n\ + .4byte _080196D6\n\ + .4byte _080196D6\n\ + .4byte _080196D6\n\ + .4byte _080196D6\n\ + .4byte _080196D6\n\ + .4byte _080196D6\n\ + .4byte _080196D6\n\ + .4byte _080196D6\n\ + .4byte _080196D6\n\ + .4byte _080196D6\n\ + .4byte _080196D6\n\ + .4byte _08019614\n\ +_08019590:\n\ + movs r0, 0x58\n\ + mov r3, r10\n\ + muls r3, r0\n\ + adds r0, r3, 0\n\ + adds r1, r2, 0\n\ + adds r1, 0x4C\n\ + adds r0, r1\n\ + ldr r0, [r0]\n\ + ldr r1, _080195B0 @ =0x00000f88\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + bne _080195AA\n\ + b _080196D6\n\ +_080195AA:\n\ + ldr r0, _080195B4 @ =gBattleTextBuff1\n\ + ldr r1, _080195B8 @ =gStatusConditionString_PoisonJpn\n\ + b _0801969C\n\ + .align 2, 0\n\ +_080195B0: .4byte 0x00000f88\n\ +_080195B4: .4byte gBattleTextBuff1\n\ +_080195B8: .4byte gStatusConditionString_PoisonJpn\n\ +_080195BC:\n\ + movs r0, 0x58\n\ + mov r1, r10\n\ + muls r1, r0\n\ + adds r0, r1, 0\n\ + adds r1, r2, 0\n\ + adds r1, 0x50\n\ + adds r0, r1\n\ + ldr r0, [r0]\n\ + movs r1, 0x7\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + bne _080195D6\n\ + b _080196D6\n\ +_080195D6:\n\ + ldr r0, _080195E4 @ =gBattleTextBuff1\n\ + ldr r1, _080195E8 @ =gStatusConditionString_ConfusionJpn\n\ + bl StringCopy\n\ + movs r2, 0x2\n\ + mov r9, r2\n\ + b _080196DC\n\ + .align 2, 0\n\ +_080195E4: .4byte gBattleTextBuff1\n\ +_080195E8: .4byte gStatusConditionString_ConfusionJpn\n\ +_080195EC:\n\ + movs r0, 0x58\n\ + mov r3, r10\n\ + muls r3, r0\n\ + adds r0, r3, 0\n\ + adds r1, r2, 0\n\ + adds r1, 0x4C\n\ + adds r0, r1\n\ + ldr r0, [r0]\n\ + movs r1, 0x40\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + beq _080196D6\n\ + ldr r0, _0801960C @ =gBattleTextBuff1\n\ + ldr r1, _08019610 @ =gStatusConditionString_ParalysisJpn\n\ + b _0801969C\n\ + .align 2, 0\n\ +_0801960C: .4byte gBattleTextBuff1\n\ +_08019610: .4byte gStatusConditionString_ParalysisJpn\n\ +_08019614:\n\ + movs r0, 0x58\n\ + mov r3, r10\n\ + muls r3, r0\n\ + adds r0, r2, 0\n\ + adds r0, 0x4C\n\ + adds r0, r3, r0\n\ + ldr r0, [r0]\n\ + movs r1, 0x7\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + beq _080196D6\n\ + adds r2, 0x50\n\ + adds r2, r3, r2\n\ + ldr r0, [r2]\n\ + ldr r1, _08019644 @ =0xf7ffffff\n\ + ands r0, r1\n\ + str r0, [r2]\n\ + ldr r0, _08019648 @ =gBattleTextBuff1\n\ + ldr r1, _0801964C @ =gStatusConditionString_SleepJpn\n\ + bl StringCopy\n\ + movs r0, 0x1\n\ + mov r9, r0\n\ + b _080196DC\n\ + .align 2, 0\n\ +_08019644: .4byte 0xf7ffffff\n\ +_08019648: .4byte gBattleTextBuff1\n\ +_0801964C: .4byte gStatusConditionString_SleepJpn\n\ +_08019650:\n\ + movs r0, 0x58\n\ + mov r1, r10\n\ + muls r1, r0\n\ + adds r0, r1, 0\n\ + adds r1, r2, 0\n\ + adds r1, 0x4C\n\ + adds r0, r1\n\ + ldr r0, [r0]\n\ + movs r1, 0x10\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + beq _080196D6\n\ + ldr r0, _08019678 @ =gBattleTextBuff1\n\ + ldr r1, _0801967C @ =gStatusConditionString_BurnJpn\n\ + bl StringCopy\n\ + movs r2, 0x1\n\ + mov r9, r2\n\ + b _080196DC\n\ + .align 2, 0\n\ +_08019678: .4byte gBattleTextBuff1\n\ +_0801967C: .4byte gStatusConditionString_BurnJpn\n\ +_08019680:\n\ + movs r0, 0x58\n\ + mov r3, r10\n\ + muls r3, r0\n\ + adds r0, r3, 0\n\ + adds r1, r2, 0\n\ + adds r1, 0x4C\n\ + adds r0, r1\n\ + ldr r0, [r0]\n\ + movs r1, 0x20\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + beq _080196D6\n\ + ldr r0, _080196A8 @ =gBattleTextBuff1\n\ + ldr r1, _080196AC @ =gStatusConditionString_IceJpn\n\ +_0801969C:\n\ + bl StringCopy\n\ + movs r5, 0x1\n\ + mov r9, r5\n\ + b _080196DC\n\ + .align 2, 0\n\ +_080196A8: .4byte gBattleTextBuff1\n\ +_080196AC: .4byte gStatusConditionString_IceJpn\n\ +_080196B0:\n\ + movs r0, 0x58\n\ + mov r1, r10\n\ + muls r1, r0\n\ + adds r0, r1, 0\n\ + adds r1, r2, 0\n\ + adds r1, 0x50\n\ + adds r0, r1\n\ + ldr r0, [r0]\n\ + movs r1, 0xF0\n\ + lsls r1, 12\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + beq _080196D6\n\ + ldr r0, _080196EC @ =gBattleTextBuff1\n\ + ldr r1, _080196F0 @ =gStatusConditionString_LoveJpn\n\ + bl StringCopy\n\ + movs r2, 0x3\n\ + mov r9, r2\n\ +_080196D6:\n\ + mov r3, r9\n\ + cmp r3, 0\n\ + beq _08019798\n\ +_080196DC:\n\ + mov r5, r9\n\ + cmp r5, 0x2\n\ + beq _08019710\n\ + cmp r5, 0x2\n\ + bgt _080196F4\n\ + cmp r5, 0x1\n\ + beq _080196FC\n\ + b _0801973C\n\ + .align 2, 0\n\ +_080196EC: .4byte gBattleTextBuff1\n\ +_080196F0: .4byte gStatusConditionString_LoveJpn\n\ +_080196F4:\n\ + mov r0, r9\n\ + cmp r0, 0x3\n\ + beq _08019728\n\ + b _0801973C\n\ +_080196FC:\n\ + ldr r1, _0801970C @ =gBattleMons\n\ + movs r0, 0x58\n\ + mov r2, r10\n\ + muls r2, r0\n\ + adds r1, 0x4C\n\ + adds r2, r1\n\ + movs r0, 0\n\ + b _0801973A\n\ + .align 2, 0\n\ +_0801970C: .4byte gBattleMons\n\ +_08019710:\n\ + ldr r1, _08019724 @ =gBattleMons\n\ + movs r0, 0x58\n\ + mov r2, r10\n\ + muls r2, r0\n\ + adds r1, 0x50\n\ + adds r2, r1\n\ + ldr r0, [r2]\n\ + movs r1, 0x8\n\ + negs r1, r1\n\ + b _08019738\n\ + .align 2, 0\n\ +_08019724: .4byte gBattleMons\n\ +_08019728:\n\ + ldr r1, _08019778 @ =gBattleMons\n\ + movs r0, 0x58\n\ + mov r2, r10\n\ + muls r2, r0\n\ + adds r1, 0x50\n\ + adds r2, r1\n\ + ldr r0, [r2]\n\ + ldr r1, _0801977C @ =0xfff0ffff\n\ +_08019738:\n\ + ands r0, r1\n\ +_0801973A:\n\ + str r0, [r2]\n\ +_0801973C:\n\ + bl b_movescr_stack_push_cursor\n\ + ldr r1, _08019780 @ =gBattlescriptCurrInstr\n\ + ldr r0, _08019784 @ =gUnknown_081D9956\n\ + str r0, [r1]\n\ + ldr r0, _08019788 @ =0x02000000\n\ + ldr r1, _0801978C @ =0x00016003\n\ + adds r0, r1\n\ + mov r2, r10\n\ + strb r2, [r0]\n\ + ldr r4, _08019790 @ =gActiveBank\n\ + strb r2, [r4]\n\ + ldrb r1, [r4]\n\ + movs r0, 0x58\n\ + muls r0, r1\n\ + ldr r1, _08019794 @ =gUnknown_02024ACC\n\ + adds r0, r1\n\ + str r0, [sp]\n\ + movs r0, 0\n\ + movs r1, 0x28\n\ + movs r2, 0\n\ + movs r3, 0x4\n\ + bl EmitSetAttributes\n\ + ldrb r0, [r4]\n\ + bl MarkBufferBankForExecution\n\ + bl _08019F92\n\ + .align 2, 0\n\ +_08019778: .4byte gBattleMons\n\ +_0801977C: .4byte 0xfff0ffff\n\ +_08019780: .4byte gBattlescriptCurrInstr\n\ +_08019784: .4byte gUnknown_081D9956\n\ +_08019788: .4byte 0x02000000\n\ +_0801978C: .4byte 0x00016003\n\ +_08019790: .4byte gActiveBank\n\ +_08019794: .4byte gUnknown_02024ACC\n\ +_08019798:\n\ + mov r0, r10\n\ + adds r0, 0x1\n\ + lsls r0, 24\n\ + lsrs r0, 24\n\ + mov r10, r0\n\ + ldr r0, _080197B0 @ =gNoOfAllBanks\n\ + ldrb r0, [r0]\n\ + cmp r10, r0\n\ + bcs _080197AC\n\ + b _08019458\n\ +_080197AC:\n\ + bl _08019F76\n\ + .align 2, 0\n\ +_080197B0: .4byte gNoOfAllBanks\n\ +_080197B4:\n\ + movs r3, 0\n\ + mov r10, r3\n\ + ldr r0, _080197FC @ =gNoOfAllBanks\n\ + ldrb r0, [r0]\n\ + cmp r10, r0\n\ + bcc _080197C2\n\ + b _08019F76\n\ +_080197C2:\n\ + ldr r4, _08019800 @ =gBattleMons\n\ +_080197C4:\n\ + movs r0, 0x58\n\ + mov r5, r10\n\ + muls r5, r0\n\ + adds r0, r5, 0\n\ + adds r0, r4\n\ + adds r0, 0x20\n\ + ldrb r0, [r0]\n\ + cmp r0, 0x3B\n\ + bne _080197E8\n\ + mov r0, r10\n\ + bl CastformDataTypeChange\n\ + lsls r0, 24\n\ + lsrs r0, 24\n\ + mov r9, r0\n\ + cmp r0, 0\n\ + beq _080197E8\n\ + b _08019E40\n\ +_080197E8:\n\ + mov r0, r10\n\ + adds r0, 0x1\n\ + lsls r0, 24\n\ + lsrs r0, 24\n\ + mov r10, r0\n\ + ldr r0, _080197FC @ =gNoOfAllBanks\n\ + ldrb r0, [r0]\n\ + cmp r10, r0\n\ + bcc _080197C4\n\ + b _08019F76\n\ + .align 2, 0\n\ +_080197FC: .4byte gNoOfAllBanks\n\ +_08019800: .4byte gBattleMons\n\ +_08019804:\n\ + mov r1, r8\n\ + ldrb r0, [r1]\n\ + cmp r0, 0x1C\n\ + beq _0801980E\n\ + b _08019F76\n\ +_0801980E:\n\ + ldr r4, _08019860 @ =gHitMarker\n\ + ldr r1, [r4]\n\ + movs r0, 0x80\n\ + lsls r0, 7\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + bne _0801981E\n\ + b _08019F76\n\ +_0801981E:\n\ + ldr r0, _08019864 @ =0xffffbfff\n\ + ands r1, r0\n\ + str r1, [r4]\n\ + ldr r3, _08019868 @ =0x000160ca\n\ + adds r2, r7, r3\n\ + ldrb r1, [r2]\n\ + movs r0, 0x3F\n\ + ands r0, r1\n\ + strb r0, [r2]\n\ + cmp r0, 0x6\n\ + bne _08019838\n\ + movs r0, 0x2\n\ + strb r0, [r2]\n\ +_08019838:\n\ + ldr r1, _0801986C @ =gBattleCommunication\n\ + ldrb r0, [r2]\n\ + adds r0, 0x40\n\ + strb r0, [r1, 0x3]\n\ + ldr r0, _08019870 @ =gBankTarget\n\ + ldrb r1, [r0]\n\ + ldr r5, _08019874 @ =0x00016003\n\ + adds r0, r7, r5\n\ + strb r1, [r0]\n\ + bl b_movescr_stack_push_cursor\n\ + ldr r1, _08019878 @ =gBattlescriptCurrInstr\n\ + ldr r0, _0801987C @ =gUnknown_081D9953\n\ + str r0, [r1]\n\ + ldr r0, [r4]\n\ + movs r1, 0x80\n\ + lsls r1, 6\n\ + orrs r0, r1\n\ + str r0, [r4]\n\ + b _08019F22\n\ + .align 2, 0\n\ +_08019860: .4byte gHitMarker\n\ +_08019864: .4byte 0xffffbfff\n\ +_08019868: .4byte 0x000160ca\n\ +_0801986C: .4byte gBattleCommunication\n\ +_08019870: .4byte gBankTarget\n\ +_08019874: .4byte 0x00016003\n\ +_08019878: .4byte gBattlescriptCurrInstr\n\ +_0801987C: .4byte gUnknown_081D9953\n\ +_08019880:\n\ + mov r1, r8\n\ + ldrb r0, [r1]\n\ + cmp r0, 0x1C\n\ + beq _0801988A\n\ + b _08019F76\n\ +_0801988A:\n\ + ldr r4, _080198DC @ =gHitMarker\n\ + ldr r1, [r4]\n\ + movs r0, 0x80\n\ + lsls r0, 7\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + bne _0801989A\n\ + b _08019F76\n\ +_0801989A:\n\ + ldr r0, _080198E0 @ =0xffffbfff\n\ + ands r1, r0\n\ + str r1, [r4]\n\ + ldr r3, _080198E4 @ =0x000160ca\n\ + adds r2, r7, r3\n\ + ldrb r1, [r2]\n\ + movs r0, 0x3F\n\ + ands r0, r1\n\ + strb r0, [r2]\n\ + cmp r0, 0x6\n\ + bne _080198B4\n\ + movs r0, 0x2\n\ + strb r0, [r2]\n\ +_080198B4:\n\ + ldr r1, _080198E8 @ =gBattleCommunication\n\ + ldrb r0, [r2]\n\ + strb r0, [r1, 0x3]\n\ + ldr r0, _080198EC @ =gBankAttacker\n\ + ldrb r1, [r0]\n\ + ldr r5, _080198F0 @ =0x00016003\n\ + adds r0, r7, r5\n\ + strb r1, [r0]\n\ + bl b_movescr_stack_push_cursor\n\ + ldr r1, _080198F4 @ =gBattlescriptCurrInstr\n\ + ldr r0, _080198F8 @ =gUnknown_081D9953\n\ + str r0, [r1]\n\ + ldr r0, [r4]\n\ + movs r1, 0x80\n\ + lsls r1, 6\n\ + orrs r0, r1\n\ + str r0, [r4]\n\ + b _08019F22\n\ + .align 2, 0\n\ +_080198DC: .4byte gHitMarker\n\ +_080198E0: .4byte 0xffffbfff\n\ +_080198E4: .4byte 0x000160ca\n\ +_080198E8: .4byte gBattleCommunication\n\ +_080198EC: .4byte gBankAttacker\n\ +_080198F0: .4byte 0x00016003\n\ +_080198F4: .4byte gBattlescriptCurrInstr\n\ +_080198F8: .4byte gUnknown_081D9953\n\ +_080198FC:\n\ + movs r4, 0\n\ + ldr r0, _08019934 @ =gNoOfAllBanks\n\ + ldrb r1, [r0]\n\ + cmp r4, r1\n\ + blt _08019908\n\ + b _08019F76\n\ +_08019908:\n\ + ldr r0, _08019938 @ =gBattleMons\n\ + adds r5, r1, 0\n\ + ldr r2, _0801993C @ =gStatuses3\n\ + adds r3, r0, 0\n\ + adds r3, 0x20\n\ + movs r6, 0x80\n\ + lsls r6, 12\n\ +_08019916:\n\ + ldrb r1, [r3]\n\ + cmp r1, 0x16\n\ + bne _08019926\n\ + ldr r0, [r2]\n\ + ands r0, r6\n\ + cmp r0, 0\n\ + beq _08019926\n\ + b _08019E6C\n\ +_08019926:\n\ + adds r2, 0x4\n\ + adds r3, 0x58\n\ + adds r4, 0x1\n\ + cmp r4, r5\n\ + blt _08019916\n\ + b _08019F76\n\ + .align 2, 0\n\ +_08019934: .4byte gNoOfAllBanks\n\ +_08019938: .4byte gBattleMons\n\ +_0801993C: .4byte gStatuses3\n\ +_08019940:\n\ + movs r4, 0\n\ + ldr r0, _08019A1C @ =gNoOfAllBanks\n\ + ldrb r0, [r0]\n\ + cmp r4, r0\n\ + blt _0801994C\n\ + b _08019F76\n\ +_0801994C:\n\ + ldr r0, _08019A20 @ =gActiveBank\n\ + mov r8, r0\n\ + ldr r1, _08019A24 @ =gBattleMons\n\ + adds r1, 0x20\n\ + str r1, [sp, 0x1C]\n\ + movs r2, 0\n\ + str r2, [sp, 0x20]\n\ +_0801995A:\n\ + ldr r3, [sp, 0x1C]\n\ + ldrb r0, [r3]\n\ + cmp r0, 0x24\n\ + beq _08019964\n\ + b _08019AF6\n\ +_08019964:\n\ + ldr r0, _08019A28 @ =gStatuses3\n\ + ldr r5, [sp, 0x20]\n\ + adds r0, r5, r0\n\ + ldr r1, [r0]\n\ + movs r0, 0x80\n\ + lsls r0, 13\n\ + ands r1, r0\n\ + str r5, [sp, 0x18]\n\ + cmp r1, 0\n\ + bne _0801997A\n\ + b _08019AF6\n\ +_0801997A:\n\ + lsls r0, r4, 24\n\ + lsrs r0, 24\n\ + bl GetBankIdentity\n\ + movs r1, 0x1\n\ + adds r5, r0, 0\n\ + eors r5, r1\n\ + ands r5, r1\n\ + adds r0, r5, 0\n\ + bl GetBankByPlayerAI\n\ + lsls r0, 24\n\ + lsrs r6, r0, 24\n\ + adds r0, r5, 0x2\n\ + bl GetBankByPlayerAI\n\ + lsls r0, 24\n\ + lsrs r7, r0, 24\n\ + ldr r0, _08019A2C @ =gBattleTypeFlags\n\ + ldrh r1, [r0]\n\ + movs r2, 0x1\n\ + adds r0, r2, 0\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + bne _080199AE\n\ + b _08019ABC\n\ +_080199AE:\n\ + movs r1, 0x58\n\ + adds r0, r6, 0\n\ + muls r0, r1\n\ + ldr r3, _08019A24 @ =gBattleMons\n\ + adds r1, r0, r3\n\ + adds r0, r1, 0\n\ + adds r0, 0x20\n\ + ldrb r0, [r0]\n\ + cmp r0, 0\n\ + beq _08019A78\n\ + ldrh r0, [r1, 0x28]\n\ + cmp r0, 0\n\ + beq _08019A34\n\ + movs r1, 0x58\n\ + adds r0, r7, 0\n\ + muls r0, r1\n\ + adds r1, r0, r3\n\ + adds r0, r1, 0\n\ + adds r0, 0x20\n\ + ldrb r0, [r0]\n\ + cmp r0, 0\n\ + beq _08019A34\n\ + ldrh r0, [r1, 0x28]\n\ + cmp r0, 0\n\ + beq _08019A34\n\ + str r2, [sp, 0x24]\n\ + bl Random\n\ + ldr r2, [sp, 0x24]\n\ + adds r1, r2, 0\n\ + ands r1, r0\n\ + lsls r1, 1\n\ + orrs r5, r1\n\ + adds r0, r5, 0\n\ + bl GetBankByPlayerAI\n\ + mov r2, r8\n\ + strb r0, [r2]\n\ + ldrb r0, [r2]\n\ + movs r3, 0x58\n\ + muls r0, r3\n\ + ldr r5, _08019A24 @ =gBattleMons\n\ + adds r0, r5\n\ + adds r0, 0x20\n\ + ldrb r0, [r0]\n\ + ldr r1, [sp, 0x1C]\n\ + strb r0, [r1]\n\ + ldrb r0, [r2]\n\ + muls r0, r3\n\ + adds r0, r5\n\ + adds r0, 0x20\n\ + ldrb r0, [r0]\n\ + ldr r2, _08019A30 @ =gLastUsedAbility\n\ + strb r0, [r2]\n\ + b _08019AE4\n\ + .align 2, 0\n\ +_08019A1C: .4byte gNoOfAllBanks\n\ +_08019A20: .4byte gActiveBank\n\ +_08019A24: .4byte gBattleMons\n\ +_08019A28: .4byte gStatuses3\n\ +_08019A2C: .4byte gBattleTypeFlags\n\ +_08019A30: .4byte gLastUsedAbility\n\ +_08019A34:\n\ + ldr r3, _08019A74 @ =gBattleMons\n\ + movs r2, 0x58\n\ + adds r0, r6, 0\n\ + muls r0, r2\n\ + adds r1, r0, r3\n\ + adds r0, r1, 0\n\ + adds r0, 0x20\n\ + ldrb r0, [r0]\n\ + cmp r0, 0\n\ + beq _08019A78\n\ + ldrh r0, [r1, 0x28]\n\ + cmp r0, 0\n\ + beq _08019A78\n\ + mov r5, r8\n\ + strb r6, [r5]\n\ + adds r1, r4, 0\n\ + muls r1, r2\n\ + adds r1, r3\n\ + ldrb r0, [r5]\n\ + muls r0, r2\n\ + adds r0, r3\n\ + adds r0, 0x20\n\ + ldrb r0, [r0]\n\ + adds r1, 0x20\n\ + strb r0, [r1]\n\ + ldrb r0, [r5]\n\ + muls r0, r2\n\ + adds r0, r3\n\ + adds r0, 0x20\n\ + ldrb r0, [r0]\n\ + b _08019AE0\n\ + .align 2, 0\n\ +_08019A74: .4byte gBattleMons\n\ +_08019A78:\n\ + ldr r3, _08019AB8 @ =gBattleMons\n\ + movs r2, 0x58\n\ + adds r0, r7, 0\n\ + muls r0, r2\n\ + adds r1, r0, r3\n\ + adds r0, r1, 0\n\ + adds r0, 0x20\n\ + ldrb r0, [r0]\n\ + cmp r0, 0\n\ + beq _08019AEE\n\ + ldrh r0, [r1, 0x28]\n\ + cmp r0, 0\n\ + beq _08019AEE\n\ + mov r5, r8\n\ + strb r7, [r5]\n\ + adds r1, r4, 0\n\ + muls r1, r2\n\ + adds r1, r3\n\ + ldrb r0, [r5]\n\ + muls r0, r2\n\ + adds r0, r3\n\ + adds r0, 0x20\n\ + ldrb r0, [r0]\n\ + adds r1, 0x20\n\ + strb r0, [r1]\n\ + ldrb r0, [r5]\n\ + muls r0, r2\n\ + adds r0, r3\n\ + adds r0, 0x20\n\ + ldrb r0, [r0]\n\ + b _08019AE0\n\ + .align 2, 0\n\ +_08019AB8: .4byte gBattleMons\n\ +_08019ABC:\n\ + mov r2, r8\n\ + strb r6, [r2]\n\ + movs r3, 0x58\n\ + adds r0, r6, 0\n\ + muls r0, r3\n\ + ldr r5, _08019B10 @ =gBattleMons\n\ + adds r0, r5\n\ + adds r2, r0, 0\n\ + adds r2, 0x20\n\ + ldrb r1, [r2]\n\ + cmp r1, 0\n\ + beq _08019AEE\n\ + ldrh r0, [r0, 0x28]\n\ + cmp r0, 0\n\ + beq _08019AEE\n\ + ldr r0, [sp, 0x1C]\n\ + strb r1, [r0]\n\ + ldrb r0, [r2]\n\ +_08019AE0:\n\ + ldr r1, _08019B14 @ =gLastUsedAbility\n\ + strb r0, [r1]\n\ +_08019AE4:\n\ + mov r0, r9\n\ + adds r0, 0x1\n\ + lsls r0, 24\n\ + lsrs r0, 24\n\ + mov r9, r0\n\ +_08019AEE:\n\ + mov r2, r9\n\ + cmp r2, 0\n\ + beq _08019AF6\n\ + b _08019E88\n\ +_08019AF6:\n\ + ldr r3, [sp, 0x1C]\n\ + adds r3, 0x58\n\ + str r3, [sp, 0x1C]\n\ + ldr r5, [sp, 0x20]\n\ + adds r5, 0x4\n\ + str r5, [sp, 0x20]\n\ + adds r4, 0x1\n\ + ldr r0, _08019B18 @ =gNoOfAllBanks\n\ + ldrb r0, [r0]\n\ + cmp r4, r0\n\ + bge _08019B0E\n\ + b _0801995A\n\ +_08019B0E:\n\ + b _08019F76\n\ + .align 2, 0\n\ +_08019B10: .4byte gBattleMons\n\ +_08019B14: .4byte gLastUsedAbility\n\ +_08019B18: .4byte gNoOfAllBanks\n\ +_08019B1C:\n\ + movs r4, 0\n\ + ldr r0, _08019B54 @ =gNoOfAllBanks\n\ + ldrb r1, [r0]\n\ + cmp r4, r1\n\ + blt _08019B28\n\ + b _08019F76\n\ +_08019B28:\n\ + ldr r0, _08019B58 @ =gBattleMons\n\ + adds r5, r1, 0\n\ + ldr r2, _08019B5C @ =gStatuses3\n\ + adds r3, r0, 0\n\ + adds r3, 0x20\n\ + movs r6, 0x80\n\ + lsls r6, 12\n\ +_08019B36:\n\ + ldrb r1, [r3]\n\ + cmp r1, 0x16\n\ + bne _08019B46\n\ + ldr r0, [r2]\n\ + ands r0, r6\n\ + cmp r0, 0\n\ + beq _08019B46\n\ + b _08019F04\n\ +_08019B46:\n\ + adds r2, 0x4\n\ + adds r3, 0x58\n\ + adds r4, 0x1\n\ + cmp r4, r5\n\ + blt _08019B36\n\ + b _08019F76\n\ + .align 2, 0\n\ +_08019B54: .4byte gNoOfAllBanks\n\ +_08019B58: .4byte gBattleMons\n\ +_08019B5C: .4byte gStatuses3\n\ +_08019B60:\n\ + mov r0, r10\n\ + bl GetBankSide\n\ + lsls r0, 24\n\ + lsrs r5, r0, 24\n\ + movs r4, 0\n\ + ldr r0, _08019BB0 @ =gNoOfAllBanks\n\ + ldrb r0, [r0]\n\ + cmp r4, r0\n\ + blt _08019B76\n\ + b _08019F76\n\ +_08019B76:\n\ + ldr r7, _08019BB4 @ =gBattleMons\n\ +_08019B78:\n\ + lsls r0, r4, 24\n\ + lsrs r0, 24\n\ + bl GetBankSide\n\ + lsls r0, 24\n\ + lsrs r0, 24\n\ + adds r3, r4, 0x1\n\ + cmp r0, r5\n\ + beq _08019BA2\n\ + movs r0, 0x58\n\ + muls r0, r4\n\ + adds r0, r7\n\ + adds r0, 0x20\n\ + ldrb r0, [r0]\n\ + cmp r0, r6\n\ + bne _08019BA2\n\ + ldr r0, _08019BB8 @ =gLastUsedAbility\n\ + strb r6, [r0]\n\ + lsls r0, r3, 24\n\ + lsrs r0, 24\n\ + mov r9, r0\n\ +_08019BA2:\n\ + adds r4, r3, 0\n\ + ldr r0, _08019BB0 @ =gNoOfAllBanks\n\ + ldrb r0, [r0]\n\ + cmp r4, r0\n\ + blt _08019B78\n\ + b _08019F76\n\ + .align 2, 0\n\ +_08019BB0: .4byte gNoOfAllBanks\n\ +_08019BB4: .4byte gBattleMons\n\ +_08019BB8: .4byte gLastUsedAbility\n\ +_08019BBC:\n\ + mov r0, r10\n\ + bl GetBankSide\n\ + lsls r0, 24\n\ + lsrs r5, r0, 24\n\ + movs r4, 0\n\ + ldr r0, _08019C0C @ =gNoOfAllBanks\n\ + ldrb r0, [r0]\n\ + cmp r4, r0\n\ + blt _08019BD2\n\ + b _08019F76\n\ +_08019BD2:\n\ + ldr r7, _08019C10 @ =gBattleMons\n\ +_08019BD4:\n\ + lsls r0, r4, 24\n\ + lsrs r0, 24\n\ + bl GetBankSide\n\ + lsls r0, 24\n\ + lsrs r0, 24\n\ + adds r3, r4, 0x1\n\ + cmp r0, r5\n\ + bne _08019BFE\n\ + movs r0, 0x58\n\ + muls r0, r4\n\ + adds r0, r7\n\ + adds r0, 0x20\n\ + ldrb r0, [r0]\n\ + cmp r0, r6\n\ + bne _08019BFE\n\ + ldr r0, _08019C14 @ =gLastUsedAbility\n\ + strb r6, [r0]\n\ + lsls r0, r3, 24\n\ + lsrs r0, 24\n\ + mov r9, r0\n\ +_08019BFE:\n\ + adds r4, r3, 0\n\ + ldr r0, _08019C0C @ =gNoOfAllBanks\n\ + ldrb r0, [r0]\n\ + cmp r4, r0\n\ + blt _08019BD4\n\ + b _08019F76\n\ + .align 2, 0\n\ +_08019C0C: .4byte gNoOfAllBanks\n\ +_08019C10: .4byte gBattleMons\n\ +_08019C14: .4byte gLastUsedAbility\n\ +_08019C18:\n\ + mov r1, r8\n\ + ldrb r0, [r1]\n\ + cmp r0, 0xFD\n\ + beq _08019C40\n\ + cmp r0, 0xFE\n\ + beq _08019C78\n\ + movs r4, 0\n\ + ldr r0, _08019C38 @ =gNoOfAllBanks\n\ + adds r5, r0, 0\n\ + ldrb r2, [r5]\n\ + cmp r4, r2\n\ + blt _08019C32\n\ + b _08019F76\n\ +_08019C32:\n\ + ldr r2, _08019C3C @ =gBattleMons\n\ + b _08019CB0\n\ + .align 2, 0\n\ +_08019C38: .4byte gNoOfAllBanks\n\ +_08019C3C: .4byte gBattleMons\n\ +_08019C40:\n\ + movs r4, 0\n\ + ldr r0, _08019C70 @ =gNoOfAllBanks\n\ + ldrb r0, [r0]\n\ + cmp r4, r0\n\ + blt _08019C4C\n\ + b _08019F76\n\ +_08019C4C:\n\ + ldr r5, _08019C74 @ =gStatuses3\n\ + movs r2, 0x80\n\ + lsls r2, 9\n\ + adds r1, r0, 0\n\ +_08019C54:\n\ + lsls r0, r4, 2\n\ + adds r0, r5\n\ + ldr r0, [r0]\n\ + ands r0, r2\n\ + adds r3, r4, 0x1\n\ + cmp r0, 0\n\ + beq _08019C68\n\ + lsls r0, r3, 24\n\ + lsrs r0, 24\n\ + mov r9, r0\n\ +_08019C68:\n\ + adds r4, r3, 0\n\ + cmp r4, r1\n\ + blt _08019C54\n\ + b _08019F76\n\ + .align 2, 0\n\ +_08019C70: .4byte gNoOfAllBanks\n\ +_08019C74: .4byte gStatuses3\n\ +_08019C78:\n\ + movs r4, 0\n\ + ldr r0, _08019CA8 @ =gNoOfAllBanks\n\ + ldrb r0, [r0]\n\ + cmp r4, r0\n\ + blt _08019C84\n\ + b _08019F76\n\ +_08019C84:\n\ + ldr r5, _08019CAC @ =gStatuses3\n\ + movs r2, 0x80\n\ + lsls r2, 10\n\ + adds r1, r0, 0\n\ +_08019C8C:\n\ + lsls r0, r4, 2\n\ + adds r0, r5\n\ + ldr r0, [r0]\n\ + ands r0, r2\n\ + adds r3, r4, 0x1\n\ + cmp r0, 0\n\ + beq _08019CA0\n\ + lsls r0, r3, 24\n\ + lsrs r0, 24\n\ + mov r9, r0\n\ +_08019CA0:\n\ + adds r4, r3, 0\n\ + cmp r4, r1\n\ + blt _08019C8C\n\ + b _08019F76\n\ + .align 2, 0\n\ +_08019CA8: .4byte gNoOfAllBanks\n\ +_08019CAC: .4byte gStatuses3\n\ +_08019CB0:\n\ + movs r0, 0x58\n\ + muls r0, r4\n\ + adds r0, r2\n\ + adds r0, 0x20\n\ + ldrb r0, [r0]\n\ + adds r3, r4, 0x1\n\ + cmp r0, r6\n\ + bne _08019CCA\n\ + mov r0, r8\n\ + strb r6, [r0]\n\ + lsls r0, r3, 24\n\ + lsrs r0, 24\n\ + mov r9, r0\n\ +_08019CCA:\n\ + adds r4, r3, 0\n\ + ldrb r1, [r5]\n\ + cmp r4, r1\n\ + blt _08019CB0\n\ + b _08019F76\n\ +_08019CD4:\n\ + movs r4, 0\n\ + ldr r0, _08019D10 @ =gNoOfAllBanks\n\ + ldrb r0, [r0]\n\ + cmp r4, r0\n\ + blt _08019CE0\n\ + b _08019F76\n\ +_08019CE0:\n\ + ldr r7, _08019D14 @ =gBattleMons\n\ + adds r2, r0, 0\n\ + movs r5, 0x58\n\ +_08019CE6:\n\ + adds r0, r4, 0\n\ + muls r0, r5\n\ + adds r1, r0, r7\n\ + adds r0, r1, 0\n\ + adds r0, 0x20\n\ + ldrb r0, [r0]\n\ + adds r3, r4, 0x1\n\ + cmp r0, r6\n\ + bne _08019D08\n\ + ldrh r0, [r1, 0x28]\n\ + cmp r0, 0\n\ + beq _08019D08\n\ + mov r0, r8\n\ + strb r6, [r0]\n\ + lsls r0, r3, 24\n\ + lsrs r0, 24\n\ + mov r9, r0\n\ +_08019D08:\n\ + adds r4, r3, 0\n\ + cmp r4, r2\n\ + blt _08019CE6\n\ + b _08019F76\n\ + .align 2, 0\n\ +_08019D10: .4byte gNoOfAllBanks\n\ +_08019D14: .4byte gBattleMons\n\ +_08019D18:\n\ + movs r4, 0\n\ + ldr r0, _08019D50 @ =gNoOfAllBanks\n\ + ldrb r0, [r0]\n\ + cmp r4, r0\n\ + blt _08019D24\n\ + b _08019F76\n\ +_08019D24:\n\ + ldr r7, _08019D54 @ =gBattleMons\n\ + adds r1, r0, 0\n\ + movs r5, 0x58\n\ + ldr r2, _08019D58 @ =gLastUsedAbility\n\ +_08019D2C:\n\ + adds r0, r4, 0\n\ + muls r0, r5\n\ + adds r0, r7\n\ + adds r0, 0x20\n\ + ldrb r0, [r0]\n\ + adds r3, r4, 0x1\n\ + cmp r0, r6\n\ + bne _08019D48\n\ + cmp r4, r10\n\ + beq _08019D48\n\ + strb r6, [r2]\n\ + lsls r0, r3, 24\n\ + lsrs r0, 24\n\ + mov r9, r0\n\ +_08019D48:\n\ + adds r4, r3, 0\n\ + cmp r4, r1\n\ + blt _08019D2C\n\ + b _08019F76\n\ + .align 2, 0\n\ +_08019D50: .4byte gNoOfAllBanks\n\ +_08019D54: .4byte gBattleMons\n\ +_08019D58: .4byte gLastUsedAbility\n\ +_08019D5C:\n\ + mov r0, r10\n\ + bl GetBankSide\n\ + lsls r0, 24\n\ + lsrs r5, r0, 24\n\ + movs r4, 0\n\ + ldr r0, _08019DAC @ =gNoOfAllBanks\n\ + ldrb r0, [r0]\n\ + cmp r4, r0\n\ + blt _08019D72\n\ + b _08019F76\n\ +_08019D72:\n\ + ldr r7, _08019DB0 @ =gBattleMons\n\ +_08019D74:\n\ + lsls r0, r4, 24\n\ + lsrs r0, 24\n\ + bl GetBankSide\n\ + lsls r0, 24\n\ + lsrs r0, 24\n\ + cmp r0, r5\n\ + beq _08019DA0\n\ + movs r0, 0x58\n\ + muls r0, r4\n\ + adds r0, r7\n\ + adds r0, 0x20\n\ + ldrb r0, [r0]\n\ + cmp r0, r6\n\ + bne _08019DA0\n\ + ldr r0, _08019DB4 @ =gLastUsedAbility\n\ + strb r6, [r0]\n\ + mov r0, r9\n\ + adds r0, 0x1\n\ + lsls r0, 24\n\ + lsrs r0, 24\n\ + mov r9, r0\n\ +_08019DA0:\n\ + adds r4, 0x1\n\ + ldr r0, _08019DAC @ =gNoOfAllBanks\n\ + ldrb r0, [r0]\n\ + cmp r4, r0\n\ + blt _08019D74\n\ + b _08019F76\n\ + .align 2, 0\n\ +_08019DAC: .4byte gNoOfAllBanks\n\ +_08019DB0: .4byte gBattleMons\n\ +_08019DB4: .4byte gLastUsedAbility\n\ +_08019DB8:\n\ + mov r0, r10\n\ + bl GetBankSide\n\ + lsls r0, 24\n\ + lsrs r5, r0, 24\n\ + movs r4, 0\n\ + ldr r0, _08019E08 @ =gNoOfAllBanks\n\ + ldrb r0, [r0]\n\ + cmp r4, r0\n\ + blt _08019DCE\n\ + b _08019F76\n\ +_08019DCE:\n\ + ldr r7, _08019E0C @ =gBattleMons\n\ +_08019DD0:\n\ + lsls r0, r4, 24\n\ + lsrs r0, 24\n\ + bl GetBankSide\n\ + lsls r0, 24\n\ + lsrs r0, 24\n\ + cmp r0, r5\n\ + bne _08019DFC\n\ + movs r0, 0x58\n\ + muls r0, r4\n\ + adds r0, r7\n\ + adds r0, 0x20\n\ + ldrb r0, [r0]\n\ + cmp r0, r6\n\ + bne _08019DFC\n\ + ldr r0, _08019E10 @ =gLastUsedAbility\n\ + strb r6, [r0]\n\ + mov r0, r9\n\ + adds r0, 0x1\n\ + lsls r0, 24\n\ + lsrs r0, 24\n\ + mov r9, r0\n\ +_08019DFC:\n\ + adds r4, 0x1\n\ + ldr r0, _08019E08 @ =gNoOfAllBanks\n\ + ldrb r0, [r0]\n\ + cmp r4, r0\n\ + blt _08019DD0\n\ + b _08019F76\n\ + .align 2, 0\n\ +_08019E08: .4byte gNoOfAllBanks\n\ +_08019E0C: .4byte gBattleMons\n\ +_08019E10: .4byte gLastUsedAbility\n\ +_08019E14:\n\ + ldr r0, _08019E30 @ =gUnknown_081D977D\n\ + bl b_push_move_exec\n\ + ldr r0, _08019E34 @ =0x02000000\n\ + ldr r2, _08019E38 @ =0x00016003\n\ + adds r1, r0, r2\n\ + strb r6, [r1]\n\ + mov r1, r9\n\ + subs r1, 0x1\n\ + ldr r3, _08019E3C @ =0x0001609b\n\ + adds r0, r3\n\ + strb r1, [r0]\n\ + b _08019F76\n\ + .align 2, 0\n\ +_08019E30: .4byte gUnknown_081D977D\n\ +_08019E34: .4byte 0x02000000\n\ +_08019E38: .4byte 0x00016003\n\ +_08019E3C: .4byte 0x0001609b\n\ +_08019E40:\n\ + ldr r0, _08019E5C @ =gUnknown_081D977D\n\ + bl b_push_move_exec\n\ + ldr r0, _08019E60 @ =0x02000000\n\ + ldr r5, _08019E64 @ =0x00016003\n\ + adds r1, r0, r5\n\ + mov r2, r10\n\ + strb r2, [r1]\n\ + mov r1, r9\n\ + subs r1, 0x1\n\ + ldr r3, _08019E68 @ =0x0001609b\n\ + adds r0, r3\n\ + strb r1, [r0]\n\ + b _08019F92\n\ + .align 2, 0\n\ +_08019E5C: .4byte gUnknown_081D977D\n\ +_08019E60: .4byte 0x02000000\n\ +_08019E64: .4byte 0x00016003\n\ +_08019E68: .4byte 0x0001609b\n\ +_08019E6C:\n\ + mov r5, r8\n\ + strb r1, [r5]\n\ + ldr r0, [r2]\n\ + ldr r1, _08019E80 @ =0xfff7ffff\n\ + ands r0, r1\n\ + str r0, [r2]\n\ + ldr r0, _08019E84 @ =gUnknown_081D978C\n\ + bl b_push_move_exec\n\ + b _08019F1A\n\ + .align 2, 0\n\ +_08019E80: .4byte 0xfff7ffff\n\ +_08019E84: .4byte gUnknown_081D978C\n\ +_08019E88:\n\ + ldr r0, _08019EDC @ =gUnknown_081D9726\n\ + bl b_push_move_exec\n\ + ldr r1, _08019EE0 @ =gStatuses3\n\ + ldr r2, [sp, 0x18]\n\ + adds r1, r2, r1\n\ + ldr r0, [r1]\n\ + ldr r2, _08019EE4 @ =0xffefffff\n\ + ands r0, r2\n\ + str r0, [r1]\n\ + ldr r0, _08019EE8 @ =0x02000000\n\ + ldr r3, _08019EEC @ =0x00016003\n\ + adds r0, r3\n\ + strb r4, [r0]\n\ + ldr r1, _08019EF0 @ =gBattleTextBuff1\n\ + movs r4, 0xFD\n\ + strb r4, [r1]\n\ + movs r0, 0x4\n\ + strb r0, [r1, 0x1]\n\ + ldr r2, _08019EF4 @ =gActiveBank\n\ + ldrb r0, [r2]\n\ + strb r0, [r1, 0x2]\n\ + ldr r3, _08019EF8 @ =gBattlePartyID\n\ + ldrb r0, [r2]\n\ + lsls r0, 1\n\ + adds r0, r3\n\ + ldrh r0, [r0]\n\ + strb r0, [r1, 0x3]\n\ + movs r0, 0xFF\n\ + strb r0, [r1, 0x4]\n\ + ldr r1, _08019EFC @ =gBattleTextBuff2\n\ + strb r4, [r1]\n\ + movs r0, 0x9\n\ + strb r0, [r1, 0x1]\n\ + ldr r0, _08019F00 @ =gLastUsedAbility\n\ + ldrb r0, [r0]\n\ + strb r0, [r1, 0x2]\n\ + movs r0, 0x1\n\ + negs r0, r0\n\ + strb r0, [r1, 0x3]\n\ + b _08019F76\n\ + .align 2, 0\n\ +_08019EDC: .4byte gUnknown_081D9726\n\ +_08019EE0: .4byte gStatuses3\n\ +_08019EE4: .4byte 0xffefffff\n\ +_08019EE8: .4byte 0x02000000\n\ +_08019EEC: .4byte 0x00016003\n\ +_08019EF0: .4byte gBattleTextBuff1\n\ +_08019EF4: .4byte gActiveBank\n\ +_08019EF8: .4byte gBattlePartyID\n\ +_08019EFC: .4byte gBattleTextBuff2\n\ +_08019F00: .4byte gLastUsedAbility\n\ +_08019F04:\n\ + mov r5, r8\n\ + strb r1, [r5]\n\ + ldr r0, [r2]\n\ + ldr r1, _08019F30 @ =0xfff7ffff\n\ + ands r0, r1\n\ + str r0, [r2]\n\ + bl b_movescr_stack_push_cursor\n\ + ldr r1, _08019F34 @ =gBattlescriptCurrInstr\n\ + ldr r0, _08019F38 @ =gUnknown_081D9795\n\ + str r0, [r1]\n\ +_08019F1A:\n\ + ldr r0, _08019F3C @ =0x02000000\n\ + ldr r1, _08019F40 @ =0x000160dd\n\ + adds r0, r1\n\ + strb r4, [r0]\n\ +_08019F22:\n\ + mov r0, r9\n\ + adds r0, 0x1\n\ + lsls r0, 24\n\ + lsrs r0, 24\n\ + mov r9, r0\n\ + b _08019F76\n\ + .align 2, 0\n\ +_08019F30: .4byte 0xfff7ffff\n\ +_08019F34: .4byte gBattlescriptCurrInstr\n\ +_08019F38: .4byte gUnknown_081D9795\n\ +_08019F3C: .4byte 0x02000000\n\ +_08019F40: .4byte 0x000160dd\n\ +_08019F44:\n\ + movs r4, 0\n\ + ldr r0, _08019FA4 @ =gNoOfAllBanks\n\ + ldrb r1, [r0]\n\ + cmp r4, r1\n\ + bge _08019F76\n\ + ldr r0, _08019FA8 @ =gBattleMons\n\ + adds r2, r1, 0\n\ + adds r1, r0, 0\n\ + adds r1, 0x20\n\ + ldr r3, _08019FAC @ =gLastUsedAbility\n\ +_08019F58:\n\ + ldrb r0, [r1]\n\ + cmp r0, r6\n\ + bne _08019F6E\n\ + cmp r4, r10\n\ + beq _08019F6E\n\ + strb r6, [r3]\n\ + mov r0, r9\n\ + adds r0, 0x1\n\ + lsls r0, 24\n\ + lsrs r0, 24\n\ + mov r9, r0\n\ +_08019F6E:\n\ + adds r1, 0x58\n\ + adds r4, 0x1\n\ + cmp r4, r2\n\ + blt _08019F58\n\ +_08019F76:\n\ + mov r2, r9\n\ + cmp r2, 0\n\ + beq _08019F92\n\ +_08019F7C:\n\ + ldr r3, [sp, 0x4]\n\ + cmp r3, 0xB\n\ + bhi _08019F92\n\ + ldr r1, _08019FAC @ =gLastUsedAbility\n\ + ldrb r0, [r1]\n\ + cmp r0, 0xFF\n\ + beq _08019F92\n\ + adds r1, r0, 0\n\ + mov r0, r10\n\ + bl RecordAbilityBattle\n\ +_08019F92:\n\ + mov r0, r9\n\ + add sp, 0x28\n\ + pop {r3-r5}\n\ + mov r8, r3\n\ + mov r9, r4\n\ + mov r10, r5\n\ + pop {r4-r7}\n\ + pop {r1}\n\ + bx r1\n\ + .align 2, 0\n\ +_08019FA4: .4byte gNoOfAllBanks\n\ +_08019FA8: .4byte gBattleMons\n\ +_08019FAC: .4byte gLastUsedAbility\n\ + .syntax divided"); +} + +#endif // NONMATCHING + +void b_call_bc_move_exec(u8* BS_ptr) +{ + gBattlescriptCurrInstr = BS_ptr; + B_FUNCTION_STACK->ptr[B_FUNCTION_STACK->size++] = gBattleMainFunc; + gBattleMainFunc = sub_8013F54; + gFightStateTracker = 0; +} + +void b_push_move_exec(u8* BS_ptr) +{ + b_movescr_stack_push_cursor(); + gBattlescriptCurrInstr = BS_ptr; + B_FUNCTION_STACK->ptr[B_FUNCTION_STACK->size++] = gBattleMainFunc; + gBattleMainFunc = sub_8013FBC; +} + +enum +{ + ITEM_NO_EFFECT, // 0 + ITEM_STATUS_CHANGE, // 1 + ITEM_EFFECT_OTHER, // 2 + ITEM_PP_CHANGE, // 3 + ITEM_HP_CHANGE, // 4 + ITEM_STATS_CHANGE, // 5 +}; + +enum +{ + FLAVOR_SPICY, // 0 + FLAVOR_DRY, // 1 + FLAVOR_SWEET, // 2 + FLAVOR_BITTER, // 3 + FLAVOR_SOUR, // 4 +}; + +s8 sub_8040A7C(u32 pid, u8 flavor); // get poke flavor relation + +u8 ItemBattleEffects(u8 caseID, u8 bank, bool8 moveTurn) +{ + int i = 0; + u8 effect = ITEM_NO_EFFECT; + u8 changedPP = 0; + u8 bankHoldEffect, atkHoldEffect, defHoldEffect; + u8 bankQuality, atkQuality, defQuality; + u16 atkItem, defItem; + + gLastUsedItem = gBattleMons[bank].item; + if (gLastUsedItem == ITEM_ENIGMA_BERRY) + { + bankHoldEffect = gEnigmaBerries[bank].holdEffect; + bankQuality = gEnigmaBerries[bank].holdEffectParam; + } + else + { + bankHoldEffect = ItemId_GetHoldEffect(gLastUsedItem); + bankQuality = ItemId_GetHoldEffectParam(gLastUsedItem); + } + + atkItem = gBattleMons[gBankAttacker].item; + if (atkItem == ITEM_ENIGMA_BERRY) + { + atkHoldEffect = gEnigmaBerries[gBankAttacker].holdEffect; + atkQuality = gEnigmaBerries[gBankAttacker].holdEffectParam; + } + else + { + atkHoldEffect = ItemId_GetHoldEffect(atkItem); + atkQuality = ItemId_GetHoldEffectParam(atkItem); + } + + // def variables are unused + defItem = gBattleMons[gBankTarget].item; + if (defItem == ITEM_ENIGMA_BERRY) + { + defHoldEffect = gEnigmaBerries[gBankTarget].holdEffect; + defQuality = gEnigmaBerries[gBankTarget].holdEffectParam; + } + else + { + defHoldEffect = ItemId_GetHoldEffect(defItem); + defQuality = ItemId_GetHoldEffectParam(defItem); + } + + switch (caseID) + { + case 0: + switch (bankHoldEffect) + { + case HOLD_EFFECT_DOUBLE_PRIZE: + BATTLE_STRUCT->moneyMultiplier = 2; + break; + case HOLD_EFFECT_RESTORE_STATS: + for (i = 0; i < 8; i++) + { + if (gBattleMons[bank].statStages[i] < 6) + { + gBattleMons[bank].statStages[i] = 6; + effect = ITEM_STATS_CHANGE; + } + } + if (effect) + { + BATTLE_STRUCT->scriptingActive = bank; + gStringBank = bank; + gActiveBank = gBankAttacker = bank; + b_call_bc_move_exec(gUnknown_081D9A5E); + } + break; + } + break; + case 1: + if (gBattleMons[bank].hp) + { + switch (bankHoldEffect) + { + case HOLD_EFFECT_RESTORE_HP: + if (gBattleMons[bank].hp <= gBattleMons[bank].maxHP / 2 && !moveTurn) + { + gBattleMoveDamage = bankQuality; + if (gBattleMons[bank].hp + bankQuality > gBattleMons[bank].maxHP) + gBattleMoveDamage = gBattleMons[bank].maxHP - gBattleMons[bank].hp; + gBattleMoveDamage *= -1; + b_call_bc_move_exec(gUnknown_081D9A74); + effect = 4; + } + break; + case HOLD_EFFECT_RESTORE_PP: + if (!moveTurn) + { + struct Pokemon* poke; + u8 ppBonuses; + u16 move; + + if (GetBankSide(bank) == 0) + poke = &gPlayerParty[gBattlePartyID[bank]]; + else + poke = &gEnemyParty[gBattlePartyID[bank]]; + for (i = 0; i < 4; i++) + { + move = GetMonData(poke, MON_DATA_MOVE1 + i); + changedPP = GetMonData(poke, MON_DATA_PP1 + i); + ppBonuses = GetMonData(poke, MON_DATA_PP_BONUSES); + if (move && changedPP == 0) + break; + } + if (i != 4) + { + u8 maxPP = CalculatePPWithBonus(move, ppBonuses, i); + if (changedPP + bankQuality > maxPP) + changedPP = maxPP; + else + changedPP = changedPP + bankQuality; + gBattleTextBuff1[0] = 0xFD; + gBattleTextBuff1[1] = 2; + gBattleTextBuff1[2] = move; + gBattleTextBuff1[3] = move >> 8; + gBattleTextBuff1[4] = 0xFF; + b_call_bc_move_exec(gUnknown_081D9A91); + EmitSetAttributes(0, i + REQUEST_PPMOVE1_BATTLE, 0, 1, &changedPP); + MarkBufferBankForExecution(gActiveBank); + effect = ITEM_PP_CHANGE; + } + } + break; + case HOLD_EFFECT_RESTORE_STATS: + for (i = 0; i < 8; i++) + { + if (gBattleMons[bank].statStages[i] < 6) + { + gBattleMons[bank].statStages[i] = 6; + effect = ITEM_STATS_CHANGE; + } + } + if (effect) + { + BATTLE_STRUCT->scriptingActive = bank; + gStringBank = bank; + gActiveBank = gBankAttacker = bank; + b_call_bc_move_exec(gUnknown_081D9A5E); + } + break; + case HOLD_EFFECT_LEFTOVERS: + if (gBattleMons[bank].hp < gBattleMons[bank].maxHP && !moveTurn) + { + gBattleMoveDamage = gBattleMons[bank].maxHP / 16; + if (gBattleMoveDamage == 0) + gBattleMoveDamage = 1; + if (gBattleMons[bank].hp + gBattleMoveDamage > gBattleMons[bank].maxHP) + gBattleMoveDamage = gBattleMons[bank].maxHP - gBattleMons[bank].hp; + gBattleMoveDamage *= -1; + b_call_bc_move_exec(gUnknown_081D9AA1); + effect = ITEM_HP_CHANGE; + RecordItemBattle(bank, bankHoldEffect); + } + break; + // nice copy/paste there gamefreak, making a function for confuse berries was too much eh? + case HOLD_EFFECT_CONFUSE_SPICY: + if (gBattleMons[bank].hp <= gBattleMons[bank].maxHP / 2 && !moveTurn) + { + gBattleTextBuff1[0] = 0xFD; + gBattleTextBuff1[1] = 8; + gBattleTextBuff1[2] = FLAVOR_SPICY; + gBattleTextBuff1[3] = EOS; + gBattleMoveDamage = gBattleMons[bank].maxHP / bankQuality; + if (gBattleMoveDamage == 0) + gBattleMoveDamage = 1; + if (gBattleMons[bank].hp + gBattleMoveDamage > gBattleMons[bank].maxHP) + gBattleMoveDamage = gBattleMons[bank].maxHP - gBattleMons[bank].hp; + gBattleMoveDamage *= -1; + if (sub_8040A7C(gBattleMons[bank].personality, FLAVOR_SPICY) < 0) + b_call_bc_move_exec(gUnknown_081D9AD4); + else + b_call_bc_move_exec(gUnknown_081D9A74); + effect = ITEM_HP_CHANGE; + } + break; + case HOLD_EFFECT_CONFUSE_DRY: + if (gBattleMons[bank].hp <= gBattleMons[bank].maxHP / 2 && !moveTurn) + { + gBattleTextBuff1[0] = 0xFD; + gBattleTextBuff1[1] = 8; + gBattleTextBuff1[2] = FLAVOR_DRY; + gBattleTextBuff1[3] = EOS; + gBattleMoveDamage = gBattleMons[bank].maxHP / bankQuality; + if (gBattleMoveDamage == 0) + gBattleMoveDamage = 1; + if (gBattleMons[bank].hp + gBattleMoveDamage > gBattleMons[bank].maxHP) + gBattleMoveDamage = gBattleMons[bank].maxHP - gBattleMons[bank].hp; + gBattleMoveDamage *= -1; + if (sub_8040A7C(gBattleMons[bank].personality, FLAVOR_DRY) < 0) + b_call_bc_move_exec(gUnknown_081D9AD4); + else + b_call_bc_move_exec(gUnknown_081D9A74); + effect = ITEM_HP_CHANGE; + } + break; + case HOLD_EFFECT_CONFUSE_SWEET: + if (gBattleMons[bank].hp <= gBattleMons[bank].maxHP / 2 && !moveTurn) + { + gBattleTextBuff1[0] = 0xFD; + gBattleTextBuff1[1] = 8; + gBattleTextBuff1[2] = FLAVOR_SWEET; + gBattleTextBuff1[3] = EOS; + gBattleMoveDamage = gBattleMons[bank].maxHP / bankQuality; + if (gBattleMoveDamage == 0) + gBattleMoveDamage = 1; + if (gBattleMons[bank].hp + gBattleMoveDamage > gBattleMons[bank].maxHP) + gBattleMoveDamage = gBattleMons[bank].maxHP - gBattleMons[bank].hp; + gBattleMoveDamage *= -1; + if (sub_8040A7C(gBattleMons[bank].personality, FLAVOR_SWEET) < 0) + b_call_bc_move_exec(gUnknown_081D9AD4); + else + b_call_bc_move_exec(gUnknown_081D9A74); + effect = ITEM_HP_CHANGE; + } + break; + case HOLD_EFFECT_CONFUSE_BITTER: + if (gBattleMons[bank].hp <= gBattleMons[bank].maxHP / 2 && !moveTurn) + { + gBattleTextBuff1[0] = 0xFD; + gBattleTextBuff1[1] = 8; + gBattleTextBuff1[2] = FLAVOR_BITTER; + gBattleTextBuff1[3] = EOS; + gBattleMoveDamage = gBattleMons[bank].maxHP / bankQuality; + if (gBattleMoveDamage == 0) + gBattleMoveDamage = 1; + if (gBattleMons[bank].hp + gBattleMoveDamage > gBattleMons[bank].maxHP) + gBattleMoveDamage = gBattleMons[bank].maxHP - gBattleMons[bank].hp; + gBattleMoveDamage *= -1; + if (sub_8040A7C(gBattleMons[bank].personality, FLAVOR_BITTER) < 0) + b_call_bc_move_exec(gUnknown_081D9AD4); + else + b_call_bc_move_exec(gUnknown_081D9A74); + effect = ITEM_HP_CHANGE; + } + break; + case HOLD_EFFECT_CONFUSE_SOUR: + if (gBattleMons[bank].hp <= gBattleMons[bank].maxHP / 2 && !moveTurn) + { + gBattleTextBuff1[0] = 0xFD; + gBattleTextBuff1[1] = 8; + gBattleTextBuff1[2] = FLAVOR_SOUR; + gBattleTextBuff1[3] = EOS; + gBattleMoveDamage = gBattleMons[bank].maxHP / bankQuality; + if (gBattleMoveDamage == 0) + gBattleMoveDamage = 1; + if (gBattleMons[bank].hp + gBattleMoveDamage > gBattleMons[bank].maxHP) + gBattleMoveDamage = gBattleMons[bank].maxHP - gBattleMons[bank].hp; + gBattleMoveDamage *= -1; + if (sub_8040A7C(gBattleMons[bank].personality, FLAVOR_SOUR) < 0) + b_call_bc_move_exec(gUnknown_081D9AD4); + else + b_call_bc_move_exec(gUnknown_081D9A74); + effect = ITEM_HP_CHANGE; + } + break; + // copy/paste again, smh + case HOLD_EFFECT_ATTACK_UP: + if (gBattleMons[bank].hp <= gBattleMons[bank].maxHP / bankQuality && !moveTurn && gBattleMons[bank].statStages[STAT_STAGE_ATK] < 0xC) + { + gBattleTextBuff1[0] = 0xFD; + gBattleTextBuff1[1] = 5; + gBattleTextBuff1[2] = STAT_STAGE_ATK; + gBattleTextBuff1[3] = EOS; + + gBattleTextBuff2[0] = 0xFD; + gBattleTextBuff2[1] = 0; + gBattleTextBuff2[2] = 0xD2; + gBattleTextBuff2[3] = 0xD2 >> 8; + gBattleTextBuff2[4] = EOS; + + gEffectBank = bank; + BATTLE_STRUCT->statChanger = 0x10 + STAT_STAGE_ATK; + BATTLE_STRUCT->animArg1 = 0xE + STAT_STAGE_ATK; + BATTLE_STRUCT->animArg2 = 0; + b_call_bc_move_exec(gUnknown_081D9AFE); + effect = ITEM_STATS_CHANGE; + } + break; + case HOLD_EFFECT_DEFENSE_UP: + if (gBattleMons[bank].hp <= gBattleMons[bank].maxHP / bankQuality && !moveTurn && gBattleMons[bank].statStages[STAT_STAGE_DEF] < 0xC) + { + gBattleTextBuff1[0] = 0xFD; + gBattleTextBuff1[1] = 5; + gBattleTextBuff1[2] = STAT_STAGE_DEF; + gBattleTextBuff1[3] = EOS; + + gEffectBank = bank; + BATTLE_STRUCT->statChanger = 0x10 + STAT_STAGE_DEF; + BATTLE_STRUCT->animArg1 = 0xE + STAT_STAGE_DEF; + BATTLE_STRUCT->animArg2 = 0; + b_call_bc_move_exec(gUnknown_081D9AFE); + effect = ITEM_STATS_CHANGE; + } + break; + case HOLD_EFFECT_SPEED_UP: + if (gBattleMons[bank].hp <= gBattleMons[bank].maxHP / bankQuality && !moveTurn && gBattleMons[bank].statStages[STAT_STAGE_SPEED] < 0xC) + { + gBattleTextBuff1[0] = 0xFD; + gBattleTextBuff1[1] = 5; + gBattleTextBuff1[2] = STAT_STAGE_SPEED; + gBattleTextBuff1[3] = EOS; + + gEffectBank = bank; + BATTLE_STRUCT->statChanger = 0x10 + STAT_STAGE_SPEED; + BATTLE_STRUCT->animArg1 = 0xE + STAT_STAGE_SPEED; + BATTLE_STRUCT->animArg2 = 0; + b_call_bc_move_exec(gUnknown_081D9AFE); + effect = ITEM_STATS_CHANGE; + } + break; + case HOLD_EFFECT_SP_ATTACK_UP: + if (gBattleMons[bank].hp <= gBattleMons[bank].maxHP / bankQuality && !moveTurn && gBattleMons[bank].statStages[STAT_STAGE_SPATK] < 0xC) + { + gBattleTextBuff1[0] = 0xFD; + gBattleTextBuff1[1] = 5; + gBattleTextBuff1[2] = STAT_STAGE_SPATK; + gBattleTextBuff1[3] = EOS; + + gEffectBank = bank; + BATTLE_STRUCT->statChanger = 0x10 + STAT_STAGE_SPATK; + BATTLE_STRUCT->animArg1 = 0xE + STAT_STAGE_SPATK; + BATTLE_STRUCT->animArg2 = 0; + b_call_bc_move_exec(gUnknown_081D9AFE); + effect = ITEM_STATS_CHANGE; + } + break; + case HOLD_EFFECT_SP_DEFENSE_UP: + if (gBattleMons[bank].hp <= gBattleMons[bank].maxHP / bankQuality && !moveTurn && gBattleMons[bank].statStages[STAT_STAGE_SPDEF] < 0xC) + { + gBattleTextBuff1[0] = 0xFD; + gBattleTextBuff1[1] = 5; + gBattleTextBuff1[2] = STAT_STAGE_SPDEF; + gBattleTextBuff1[3] = EOS; + + gEffectBank = bank; + BATTLE_STRUCT->statChanger = 0x10 + STAT_STAGE_SPDEF; + BATTLE_STRUCT->animArg1 = 0xE + STAT_STAGE_SPDEF; + BATTLE_STRUCT->animArg2 = 0; + b_call_bc_move_exec(gUnknown_081D9AFE); + effect = ITEM_STATS_CHANGE; + } + break; + case HOLD_EFFECT_CRITICAL_UP: + if (gBattleMons[bank].hp <= gBattleMons[bank].maxHP / bankQuality && !moveTurn && !(gBattleMons[bank].status2 & STATUS2_FOCUS_ENERGY)) + { + gBattleMons[bank].status2 |= STATUS2_FOCUS_ENERGY; + b_call_bc_move_exec(gUnknown_081D9B19); + effect = ITEM_EFFECT_OTHER; + } + break; + case HOLD_EFFECT_RANDOM_STAT_UP: + if (!moveTurn && gBattleMons[bank].hp <= gBattleMons[bank].maxHP / bankQuality) + { + for (i = 0; i < 5; i++) + { + if (gBattleMons[bank].statStages[STAT_STAGE_ATK + i] < 0xC) + break; + } + if (i != 5) + { + do + { + i = Random() % 5; + } while (gBattleMons[bank].statStages[STAT_STAGE_ATK + i] == 0xC); + + gBattleTextBuff1[0] = 0xFD; + gBattleTextBuff1[1] = 5; + gBattleTextBuff1[2] = i + 1; + gBattleTextBuff1[3] = EOS; + + gBattleTextBuff2[0] = 0xFD; + gBattleTextBuff2[1] = 0; + gBattleTextBuff2[2] = 0xD1; + gBattleTextBuff2[3] = 0xD1 >> 8; + gBattleTextBuff2[4] = 0; + gBattleTextBuff2[5] = 0xD2; + gBattleTextBuff2[6] = 0xD2 >> 8; + gBattleTextBuff2[7] = EOS; + + gEffectBank = bank; + BATTLE_STRUCT->statChanger = 0x21 + i; + BATTLE_STRUCT->animArg1 = 0x21 + i + 6; + BATTLE_STRUCT->animArg2 = 0; + b_call_bc_move_exec(gUnknown_081D9AFE); + effect = ITEM_STATS_CHANGE; + } + } + break; + case HOLD_EFFECT_CURE_PAR: + if (gBattleMons[bank].status1 & STATUS_PARALYSIS) + { + gBattleMons[bank].status1 &= ~(STATUS_PARALYSIS); + b_call_bc_move_exec(gUnknown_081D99B6); + effect = ITEM_STATUS_CHANGE; + } + break; + case HOLD_EFFECT_CURE_PSN: + if (gBattleMons[bank].status1 & STATUS_PSN_ANY) + { + gBattleMons[bank].status1 &= ~(STATUS_PSN_ANY | STATUS_TOXIC_COUNTER); + b_call_bc_move_exec(gUnknown_081D99CE); + effect = ITEM_STATUS_CHANGE; + } + break; + case HOLD_EFFECT_CURE_BRN: + if (gBattleMons[bank].status1 & STATUS_BURN) + { + gBattleMons[bank].status1 &= ~(STATUS_BURN); + b_call_bc_move_exec(gUnknown_081D99E6); + effect = ITEM_STATUS_CHANGE; + } + break; + case HOLD_EFFECT_CURE_FRZ: + if (gBattleMons[bank].status1 & STATUS_FREEZE) + { + gBattleMons[bank].status1 &= ~(STATUS_FREEZE); + b_call_bc_move_exec(gUnknown_081D99FE); + effect = ITEM_STATUS_CHANGE; + } + break; + case HOLD_EFFECT_CURE_SLP: + if (gBattleMons[bank].status1 & STATUS_SLEEP) + { + gBattleMons[bank].status1 &= ~(STATUS_SLEEP); + gBattleMons[bank].status2 &= ~(STATUS2_NIGHTMARE); + b_call_bc_move_exec(gUnknown_081D9A16); + effect = ITEM_STATUS_CHANGE; + } + break; + case HOLD_EFFECT_CURE_CONFUSION: + if (gBattleMons[bank].status2 & STATUS2_CONFUSION) + { + gBattleMons[bank].status2 &= ~(STATUS2_CONFUSION); + b_call_bc_move_exec(gUnknown_081D9A2E); + effect = ITEM_EFFECT_OTHER; + } + break; + case HOLD_EFFECT_CURE_STATUS: + if (gBattleMons[bank].status1 & STATUS_ANY || gBattleMons[bank].status2 & STATUS2_CONFUSION) + { + i = 0; + if (gBattleMons[bank].status1 & STATUS_PSN_ANY) + { + StringCopy(gBattleTextBuff1, gStatusConditionString_PoisonJpn); + i++; + } + if (gBattleMons[bank].status1 & STATUS_SLEEP) + { + gBattleMons[bank].status2 &= ~(STATUS2_NIGHTMARE); + StringCopy(gBattleTextBuff1, gStatusConditionString_SleepJpn); + i++; + } + if (gBattleMons[bank].status1 & STATUS_PARALYSIS) + { + StringCopy(gBattleTextBuff1, gStatusConditionString_ParalysisJpn); + i++; + } + if (gBattleMons[bank].status1 & STATUS_BURN) + { + StringCopy(gBattleTextBuff1, gStatusConditionString_BurnJpn); + i++; + } + if (gBattleMons[bank].status1 & STATUS_FREEZE) + { + StringCopy(gBattleTextBuff1, gStatusConditionString_IceJpn); + i++; + } + if (gBattleMons[bank].status2 & STATUS2_CONFUSION) + { + StringCopy(gBattleTextBuff1, gStatusConditionString_ConfusionJpn); + i++; + } + if (!(i > 1)) + gBattleCommunication[MULTISTRING_CHOOSER] = 0; + else + gBattleCommunication[MULTISTRING_CHOOSER] = 1; + gBattleMons[bank].status1 = 0; + gBattleMons[bank].status2 &= ~(STATUS2_CONFUSION); + b_call_bc_move_exec(gUnknown_081D9A44); + effect = ITEM_STATUS_CHANGE; + } + break; + case HOLD_EFFECT_CURE_ATTRACT: + if (gBattleMons[bank].status2 & STATUS2_INFATUATION) + { + gBattleMons[bank].status2 &= ~(STATUS2_INFATUATION); + StringCopy(gBattleTextBuff1, gStatusConditionString_LoveJpn); + b_call_bc_move_exec(gUnknown_081D9A44); + gBattleCommunication[MULTISTRING_CHOOSER] = 0; + effect = ITEM_EFFECT_OTHER; + } + break; + } + if (effect) + { + BATTLE_STRUCT->scriptingActive = bank; + gStringBank = bank; + gActiveBank = gBankAttacker = bank; + switch (effect) + { + case ITEM_STATUS_CHANGE: + EmitSetAttributes(0, REQUEST_STATUS_BATTLE, 0, 4, &gBattleMons[bank].status1); + MarkBufferBankForExecution(gActiveBank); + break; + case ITEM_PP_CHANGE: + if (!(gBattleMons[bank].status2 & STATUS2_TRANSFORMED) && !(gDisableStructs[bank].unk18_b & gBitTable[i])) + gBattleMons[bank].pp[i] = changedPP; + break; + } + } + } + break; + case 2: + break; + case 3: + for (bank = 0; bank < gNoOfAllBanks; bank++) + { + gLastUsedItem = gBattleMons[bank].item; + if (gBattleMons[bank].item == ITEM_ENIGMA_BERRY) + { + bankHoldEffect = gEnigmaBerries[bank].holdEffect; + bankQuality = gEnigmaBerries[bank].holdEffectParam; + } + else + { + bankHoldEffect = ItemId_GetHoldEffect(gLastUsedItem); + bankQuality = ItemId_GetHoldEffectParam(gLastUsedItem); + } + switch (bankHoldEffect) + { + case HOLD_EFFECT_CURE_PAR: + if (gBattleMons[bank].status1 & STATUS_PARALYSIS) + { + gBattleMons[bank].status1 &= ~(STATUS_PARALYSIS); + b_movescr_stack_push_cursor(); + gBattlescriptCurrInstr = gUnknown_081D99BC; + effect = ITEM_STATUS_CHANGE; + } + break; + case HOLD_EFFECT_CURE_PSN: + if (gBattleMons[bank].status1 & STATUS_PSN_ANY) + { + gBattleMons[bank].status1 &= ~(STATUS_PSN_ANY | STATUS_TOXIC_COUNTER); + b_movescr_stack_push_cursor(); + gBattlescriptCurrInstr = gUnknown_081D99D4; + effect = ITEM_STATUS_CHANGE; + } + break; + case HOLD_EFFECT_CURE_BRN: + if (gBattleMons[bank].status1 & STATUS_BURN) + { + gBattleMons[bank].status1 &= ~(STATUS_BURN); + b_movescr_stack_push_cursor(); + gBattlescriptCurrInstr = gUnknown_081D99EC; + effect = ITEM_STATUS_CHANGE; + } + break; + case HOLD_EFFECT_CURE_FRZ: + if (gBattleMons[bank].status1 & STATUS_FREEZE) + { + gBattleMons[bank].status1 &= ~(STATUS_FREEZE); + b_movescr_stack_push_cursor(); + gBattlescriptCurrInstr = gUnknown_081D9A04; + effect = ITEM_STATUS_CHANGE; + } + break; + case HOLD_EFFECT_CURE_SLP: + if (gBattleMons[bank].status1 & STATUS_SLEEP) + { + gBattleMons[bank].status1 &= ~(STATUS_SLEEP); + gBattleMons[bank].status2 &= ~(STATUS2_NIGHTMARE); + b_movescr_stack_push_cursor(); + gBattlescriptCurrInstr = gUnknown_081D9A1C; + effect = ITEM_STATUS_CHANGE; + } + break; + case HOLD_EFFECT_CURE_CONFUSION: + if (gBattleMons[bank].status2 & STATUS2_CONFUSION) + { + gBattleMons[bank].status2 &= ~(STATUS2_CONFUSION); + b_movescr_stack_push_cursor(); + gBattlescriptCurrInstr = gUnknown_081D9A34; + effect = ITEM_EFFECT_OTHER; + } + break; + case HOLD_EFFECT_CURE_ATTRACT: + if (gBattleMons[bank].status2 & STATUS2_INFATUATION) + { + gBattleMons[bank].status2 &= ~(STATUS2_INFATUATION); + StringCopy(gBattleTextBuff1, gStatusConditionString_LoveJpn); + b_movescr_stack_push_cursor(); + gBattleCommunication[MULTISTRING_CHOOSER] = 0; + gBattlescriptCurrInstr = gUnknown_081D9A4A; + effect = ITEM_EFFECT_OTHER; + } + break; + case HOLD_EFFECT_CURE_STATUS: + if (gBattleMons[bank].status1 & STATUS_ANY || gBattleMons[bank].status2 & STATUS2_CONFUSION) + { + if (gBattleMons[bank].status1 & STATUS_PSN_ANY) + { + StringCopy(gBattleTextBuff1, gStatusConditionString_PoisonJpn); + } + if (gBattleMons[bank].status1 & STATUS_SLEEP) + { + gBattleMons[bank].status2 &= ~(STATUS2_NIGHTMARE); + StringCopy(gBattleTextBuff1, gStatusConditionString_SleepJpn); + } + if (gBattleMons[bank].status1 & STATUS_PARALYSIS) + { + StringCopy(gBattleTextBuff1, gStatusConditionString_ParalysisJpn); + } + if (gBattleMons[bank].status1 & STATUS_BURN) + { + StringCopy(gBattleTextBuff1, gStatusConditionString_BurnJpn); + } + if (gBattleMons[bank].status1 & STATUS_FREEZE) + { + StringCopy(gBattleTextBuff1, gStatusConditionString_IceJpn); + } + if (gBattleMons[bank].status2 & STATUS2_CONFUSION) + { + StringCopy(gBattleTextBuff1, gStatusConditionString_ConfusionJpn); + } + gBattleMons[bank].status1 = 0; + gBattleMons[bank].status2 &= ~(STATUS2_CONFUSION); + b_movescr_stack_push_cursor(); + gBattleCommunication[MULTISTRING_CHOOSER] = 0; + gBattlescriptCurrInstr = gUnknown_081D9A4A; + effect = ITEM_STATUS_CHANGE; + } + break; + case HOLD_EFFECT_RESTORE_STATS: + for (i = 0; i < 8; i++) + { + if (gBattleMons[bank].statStages[i] < 6) + { + gBattleMons[bank].statStages[i] = 6; + effect = ITEM_STATS_CHANGE; + } + } + if (effect) + { + BATTLE_STRUCT->scriptingActive = bank; + gStringBank = bank; + b_movescr_stack_push_cursor(); + gBattlescriptCurrInstr = gUnknown_081D9A64; + return effect; // unnecessary return + } + break; + } + if (effect) + { + BATTLE_STRUCT->scriptingActive = bank; + gStringBank = bank; + gActiveBank = bank; + EmitSetAttributes(0, REQUEST_STATUS_BATTLE, 0, 4, &gBattleMons[gActiveBank].status1); + MarkBufferBankForExecution(gActiveBank); + break; + } + } + break; + case 4: + if (gBattleMoveDamage) + { + switch (atkHoldEffect) + { + case HOLD_EFFECT_FLINCH: + if (!(gBattleMoveFlags & MOVESTATUS_NOEFFECT) + && (gSpecialStatuses[gBankTarget].moveturnLostHP_physical || gSpecialStatuses[gBankTarget].moveturnLostHP_special) + && (Random() % 100) < bankQuality + && gBattleMoves[gCurrentMove].flags & FLAG_KINGSROCK_AFFECTED + && gBattleMons[gBankTarget].hp) + { + gBattleCommunication[MOVE_EFFECT_BYTE] = 8; + b_movescr_stack_push_cursor(); + SetMoveEffect(0, 0); + b_movescr_stack_pop_cursor(); + } + break; + case HOLD_EFFECT_SHELL_BELL: + if (!(gBattleMoveFlags & MOVESTATUS_NOEFFECT) + && gSpecialStatuses[gBankTarget].moveturnLostHP != 0 + && gSpecialStatuses[gBankTarget].moveturnLostHP != 0xFFFF + && gBankAttacker != gBankTarget + && gBattleMons[gBankAttacker].hp != gBattleMons[gBankAttacker].maxHP + && gBattleMons[gBankAttacker].hp != 0) + { + gLastUsedItem = atkItem; + gStringBank = gBankAttacker; + BATTLE_STRUCT->scriptingActive = gBankAttacker; + gBattleMoveDamage = (gSpecialStatuses[gBankTarget].moveturnLostHP / atkQuality) * -1; + if (gBattleMoveDamage == 0) + gBattleMoveDamage = -1; + gSpecialStatuses[gBankTarget].moveturnLostHP = 0; + b_movescr_stack_push_cursor(); + gBattlescriptCurrInstr = gUnknown_081D9AA7; + effect++; + } + break; + } + } + break; + } + + return effect; +} diff --git a/src/battle_4.c b/src/battle_4.c index bbc3bfa33..c4ffc4786 100644 --- a/src/battle_4.c +++ b/src/battle_4.c @@ -101,7 +101,7 @@ void CancelMultiTurnMoves(u8 bank); void b_movescr_stack_push(u8* BS_ptr); void b_movescr_stack_push_cursor(void); void RecordAbilityBattle(u8 bank, u8 ability); -void RecordItemBattle(u8 bank, u8 item); +void RecordItemBattle(u8 bank, u8 holdEffect); int IsPokeDisobedient(void); static bool8 IsTwoTurnsMove(u16 move); static void DestinyBondFlagUpdate(void); From 3d0adf41579297b670238259f1b73046267a68be Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Fri, 28 Jul 2017 19:24:11 +0200 Subject: [PATCH 6/8] Unreferenced move merger --- include/battle.h | 4 ++-- src/battle_3.c | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 2 deletions(-) diff --git a/include/battle.h b/include/battle.h index 0f1a5f26b..d68c8280e 100644 --- a/include/battle.h +++ b/include/battle.h @@ -106,6 +106,7 @@ #define SIDE_STATUS_REFLECT (1 << 0) #define SIDE_STATUS_LIGHTSCREEN (1 << 1) +#define SIDE_STATUS_X4 (1 << 2) #define SIDE_STATUS_SPIKES (1 << 4) #define SIDE_STATUS_SAFEGUARD (1 << 5) #define SIDE_STATUS_FUTUREATTACK (1 << 6) @@ -614,8 +615,7 @@ struct sideTimer u8 lightscreenTimer; //0x1 u8 mistTimer; //0x2 u8 field3; //0x3 - u8 field4; //0x4 - u8 field5; //0x5 + u16 field4; //0x4 u8 spikesAmount; //0x6 u8 safeguardTimer; //0x7 u8 followmeTimer; //0x8 diff --git a/src/battle_3.c b/src/battle_3.c index d86b11fb9..be6460ec1 100644 --- a/src/battle_3.c +++ b/src/battle_3.c @@ -6353,3 +6353,42 @@ u8 ItemBattleEffects(u8 caseID, u8 bank, bool8 moveTurn) return effect; } + +extern const u16 gUnknown_081FC1D0[]; + +/* +void unref_sub_801B40C(void) +{ + int i = 0; + if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE) + { + do + { + u8 bank = 0; + do + { + u8 absent = gAbsentBankFlags; + if (gBitTable[bank] & absent || absent & gBitTable[bank + 2]) + bank++; + else + { + if (gUnknown_081FC1D0[i * 4 + 0] == gChosenMovesByBanks[bank] && gUnknown_081FC1D0[i * 4 + 1] == gChosenMovesByBanks[bank + 2]) + { + gSideTimer[GetBankIdentity(bank) & 1].field3 = (bank) | ((bank + 2) << 4); + gSideTimer[GetBankIdentity(bank) & 1].field4 = gUnknown_081FC1D0[i * 4 + 2]; + gSideAffecting[GetBankIdentity(bank) & 1] |= SIDE_STATUS_X4; + } + if (gUnknown_081FC1D0[i * 4 + 0] == gChosenMovesByBanks[bank + 2] && gUnknown_081FC1D0[i * 4 + 1] == gChosenMovesByBanks[bank]) + { + gSideTimer[GetBankIdentity(bank) & 1].field3 = (bank + 2) | ((bank) << 4); + gSideTimer[GetBankIdentity(bank) & 1].field4 = gUnknown_081FC1D0[i * 4 + 2]; + gSideAffecting[GetBankIdentity(bank) & 1] |= SIDE_STATUS_X4; + } + bank++; + } + } while (bank < 2); + i++; + } while (gUnknown_081FC1D0[i * 4] != 0xFFFF); + } +} +*/ From 6785868132dbebc8dd9fa95cc47189ccd7b8d3b7 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Fri, 28 Jul 2017 23:42:03 +0200 Subject: [PATCH 7/8] last function IsPokeDisobedient --- asm/battle_3.s | 583 ----------------------------------------------- data/data2b.s | 8 - include/battle.h | 3 + ld_script.txt | 1 + src/battle_3.c | 224 +++++++++++++++++- src/battle_4.c | 2 - 6 files changed, 220 insertions(+), 601 deletions(-) diff --git a/asm/battle_3.s b/asm/battle_3.s index af09ddf57..40bded11d 100644 --- a/asm/battle_3.s +++ b/asm/battle_3.s @@ -6,590 +6,7 @@ .text - thumb_func_start unref_sub_801B40C -unref_sub_801B40C: @ 801B40C - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x8 - movs r0, 0 - str r0, [sp] - ldr r0, _0801B464 @ =gBattleTypeFlags - ldrh r1, [r0] - movs r0, 0x1 - ands r0, r1 - cmp r0, 0 - bne _0801B42A - b _0801B56E -_0801B42A: - movs r1, 0x1 - mov r9, r1 -_0801B42E: - movs r5, 0 - ldr r4, _0801B468 @ =gUnknown_081FC1D0 - ldr r2, [sp] - adds r2, 0x1 - str r2, [sp, 0x4] -_0801B438: - ldr r0, _0801B46C @ =gAbsentBankFlags - ldrb r2, [r0] - ldr r3, _0801B470 @ =gBitTable - lsls r0, r5, 2 - adds r0, r3 - ldr r0, [r0] - ands r0, r2 - cmp r0, 0 - bne _0801B45A - adds r0, r5, 0x2 - lsls r1, r0, 2 - adds r1, r3 - ldr r1, [r1] - ands r2, r1 - adds r7, r0, 0 - cmp r2, 0 - beq _0801B474 -_0801B45A: - adds r0, r5, 0x1 - lsls r0, 24 - lsrs r5, r0, 24 - b _0801B556 - .align 2, 0 -_0801B464: .4byte gBattleTypeFlags -_0801B468: .4byte gUnknown_081FC1D0 -_0801B46C: .4byte gAbsentBankFlags -_0801B470: .4byte gBitTable -_0801B474: - ldr r0, _0801B580 @ =gUnknown_081FC1D0 - ldr r2, [sp] - lsls r1, r2, 3 - adds r6, r1, r0 - ldr r4, _0801B584 @ =gChosenMovesByBanks - lsls r0, r5, 1 - adds r3, r0, r4 - ldrh r2, [r6] - mov r8, r1 - mov r10, r0 - ldrh r3, [r3] - cmp r2, r3 - bne _0801B4E4 - lsls r0, r7, 1 - adds r0, r4 - ldrh r1, [r6, 0x2] - ldrh r0, [r0] - cmp r1, r0 - bne _0801B4E4 - adds r0, r5, 0 - bl GetBankIdentity - mov r2, r9 - ands r2, r0 - lsls r1, r2, 1 - adds r1, r2 - lsls r1, 2 - ldr r0, _0801B588 @ =gSideTimer - adds r1, r0 - lsls r0, r7, 4 - orrs r0, r5 - strb r0, [r1, 0x3] - adds r0, r5, 0 - bl GetBankIdentity - mov r1, r9 - ands r1, r0 - lsls r0, r1, 1 - adds r0, r1 - lsls r0, 2 - ldr r1, _0801B588 @ =gSideTimer - adds r0, r1 - ldrh r1, [r6, 0x4] - strh r1, [r0, 0x4] - adds r0, r5, 0 - bl GetBankIdentity - mov r1, r9 - ands r1, r0 - lsls r1, 1 - ldr r2, _0801B58C @ =gSideAffecting - adds r1, r2 - ldrh r0, [r1] - movs r2, 0x4 - orrs r0, r2 - strh r0, [r1] -_0801B4E4: - ldr r0, _0801B580 @ =gUnknown_081FC1D0 - mov r1, r8 - adds r4, r1, r0 - ldr r2, _0801B584 @ =gChosenMovesByBanks - lsls r0, r7, 1 - adds r0, r2 - ldrh r1, [r4] - ldrh r0, [r0] - cmp r1, r0 - bne _0801B54E - mov r0, r10 - adds r1, r0, r2 - ldrh r0, [r4, 0x2] - ldrh r1, [r1] - cmp r0, r1 - bne _0801B54E - adds r0, r5, 0 - bl GetBankIdentity - mov r2, r9 - ands r2, r0 - lsls r1, r2, 1 - adds r1, r2 - lsls r1, 2 - ldr r2, _0801B588 @ =gSideTimer - adds r1, r2 - lsls r0, r5, 4 - orrs r0, r7 - strb r0, [r1, 0x3] - adds r0, r5, 0 - bl GetBankIdentity - mov r1, r9 - ands r1, r0 - lsls r0, r1, 1 - adds r0, r1 - lsls r0, 2 - ldr r1, _0801B588 @ =gSideTimer - adds r0, r1 - ldrh r1, [r4, 0x4] - strh r1, [r0, 0x4] - adds r0, r5, 0 - bl GetBankIdentity - mov r1, r9 - ands r1, r0 - lsls r1, 1 - ldr r2, _0801B58C @ =gSideAffecting - adds r1, r2 - ldrh r0, [r1] - movs r2, 0x4 - orrs r0, r2 - strh r0, [r1] -_0801B54E: - adds r0, r5, 0x1 - lsls r0, 24 - lsrs r5, r0, 24 - ldr r4, _0801B580 @ =gUnknown_081FC1D0 -_0801B556: - cmp r5, 0x1 - bhi _0801B55C - b _0801B438 -_0801B55C: - ldr r0, [sp, 0x4] - str r0, [sp] - lsls r0, 3 - adds r0, r4 - ldrh r1, [r0] - ldr r0, _0801B590 @ =0x0000ffff - cmp r1, r0 - beq _0801B56E - b _0801B42E -_0801B56E: - add sp, 0x8 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .align 2, 0 -_0801B580: .4byte gUnknown_081FC1D0 -_0801B584: .4byte gChosenMovesByBanks -_0801B588: .4byte gSideTimer -_0801B58C: .4byte gSideAffecting -_0801B590: .4byte 0x0000ffff - thumb_func_end unref_sub_801B40C - thumb_func_start sub_801B594 -sub_801B594: @ 801B594 - push {lr} - ldr r0, _0801B5B4 @ =gBattleExecBuffer - ldr r0, [r0] - cmp r0, 0 - bne _0801B5B0 - ldr r1, _0801B5B8 @ =gBattleScriptingCommandsTable - ldr r0, _0801B5BC @ =gBattlescriptCurrInstr - ldr r0, [r0] - ldrb r0, [r0] - lsls r0, 2 - adds r0, r1 - ldr r0, [r0] - bl _call_via_r0 -_0801B5B0: - pop {r0} - bx r0 - .align 2, 0 -_0801B5B4: .4byte gBattleExecBuffer -_0801B5B8: .4byte gBattleScriptingCommandsTable -_0801B5BC: .4byte gBattlescriptCurrInstr - thumb_func_end sub_801B594 - - thumb_func_start sub_801B5C0 -sub_801B5C0: @ 801B5C0 - push {r4-r7,lr} - mov r7, r8 - push {r7} - sub sp, 0x4 - lsls r0, 16 - lsrs r7, r0, 16 - lsls r1, 24 - lsrs r0, r1, 24 - movs r5, 0 - cmp r0, 0 - beq _0801B5DE - subs r0, 0x1 - lsls r0, 24 - lsrs r6, r0, 24 - b _0801B5EA -_0801B5DE: - ldr r1, _0801B5FC @ =gBattleMoves - lsls r0, r7, 1 - adds r0, r7 - lsls r0, 2 - adds r0, r1 - ldrb r6, [r0, 0x6] -_0801B5EA: - cmp r6, 0x40 - bls _0801B5F0 - b _0801B900 -_0801B5F0: - lsls r0, r6, 2 - ldr r1, _0801B600 @ =_0801B604 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .align 2, 0 -_0801B5FC: .4byte gBattleMoves -_0801B600: .4byte _0801B604 - .align 2, 0 -_0801B604: - .4byte _0801B708 - .4byte _0801B808 - .4byte _0801B8FC - .4byte _0801B900 - .4byte _0801B820 - .4byte _0801B900 - .4byte _0801B900 - .4byte _0801B900 - .4byte _0801B808 - .4byte _0801B900 - .4byte _0801B900 - .4byte _0801B900 - .4byte _0801B900 - .4byte _0801B900 - .4byte _0801B900 - .4byte _0801B900 - .4byte _0801B8FC - .4byte _0801B900 - .4byte _0801B900 - .4byte _0801B900 - .4byte _0801B900 - .4byte _0801B900 - .4byte _0801B900 - .4byte _0801B900 - .4byte _0801B900 - .4byte _0801B900 - .4byte _0801B900 - .4byte _0801B900 - .4byte _0801B900 - .4byte _0801B900 - .4byte _0801B900 - .4byte _0801B900 - .4byte _0801B808 - .4byte _0801B900 - .4byte _0801B900 - .4byte _0801B900 - .4byte _0801B900 - .4byte _0801B900 - .4byte _0801B900 - .4byte _0801B900 - .4byte _0801B900 - .4byte _0801B900 - .4byte _0801B900 - .4byte _0801B900 - .4byte _0801B900 - .4byte _0801B900 - .4byte _0801B900 - .4byte _0801B900 - .4byte _0801B900 - .4byte _0801B900 - .4byte _0801B900 - .4byte _0801B900 - .4byte _0801B900 - .4byte _0801B900 - .4byte _0801B900 - .4byte _0801B900 - .4byte _0801B900 - .4byte _0801B900 - .4byte _0801B900 - .4byte _0801B900 - .4byte _0801B900 - .4byte _0801B900 - .4byte _0801B900 - .4byte _0801B900 - .4byte _0801B808 -_0801B708: - ldr r0, _0801B7E8 @ =gBankAttacker - ldrb r0, [r0] - bl GetBankSide - movs r1, 0x1 - eors r0, r1 - lsls r0, 24 - lsrs r4, r0, 24 - ldr r1, _0801B7EC @ =gSideTimer - lsls r0, r4, 1 - adds r0, r4 - lsls r0, 2 - adds r2, r0, r1 - ldrb r0, [r2, 0x8] - cmp r0, 0 - beq _0801B73A - ldr r1, _0801B7F0 @ =gBattleMons - ldrb r4, [r2, 0x9] - movs r0, 0x58 - muls r0, r4 - adds r0, r1 - ldrh r0, [r0, 0x28] - cmp r0, 0 - beq _0801B73A - b _0801B850 -_0801B73A: - ldr r0, _0801B7E8 @ =gBankAttacker - ldrb r0, [r0] - bl GetBankSide - lsls r0, 24 - lsrs r4, r0, 24 - lsls r0, r7, 1 - mov r8, r0 -_0801B74A: - bl Random - lsls r0, 16 - lsrs r0, 16 - ldr r1, _0801B7F4 @ =gNoOfAllBanks - ldrb r1, [r1] - bl __modsi3 - lsls r0, 24 - lsrs r5, r0, 24 - ldr r6, _0801B7E8 @ =gBankAttacker - ldrb r2, [r6] - cmp r5, r2 - beq _0801B74A - adds r0, r5, 0 - bl GetBankSide - lsls r0, 24 - lsrs r0, 24 - cmp r4, r0 - beq _0801B74A - ldr r0, _0801B7F8 @ =gAbsentBankFlags - ldrb r2, [r0] - ldr r1, _0801B7FC @ =gBitTable - lsls r0, r5, 2 - adds r0, r1 - ldr r0, [r0] - ands r2, r0 - cmp r2, 0 - bne _0801B74A - ldr r0, _0801B800 @ =gBattleMoves - mov r3, r8 - adds r1, r3, r7 - lsls r1, 2 - adds r1, r0 - ldrb r0, [r1, 0x2] - cmp r0, 0xD - beq _0801B798 - b _0801B900 -_0801B798: - ldrb r1, [r6] - str r2, [sp] - movs r0, 0x10 - movs r2, 0x1F - movs r3, 0 - bl AbilityBattleEffects - lsls r0, 24 - cmp r0, 0 - bne _0801B7AE - b _0801B900 -_0801B7AE: - ldr r2, _0801B7F0 @ =gBattleMons - movs r1, 0x58 - adds r0, r5, 0 - muls r0, r1 - adds r0, r2 - adds r0, 0x20 - ldrb r0, [r0] - cmp r0, 0x1F - bne _0801B7C2 - b _0801B900 -_0801B7C2: - movs r4, 0x2 - eors r5, r4 - adds r0, r5, 0 - muls r0, r1 - adds r0, r2 - adds r0, 0x20 - ldrb r1, [r0] - adds r0, r5, 0 - bl RecordAbilityBattle - ldr r1, _0801B804 @ =gSpecialStatuses - lsls r0, r5, 2 - adds r0, r5 - lsls r0, 2 - adds r0, r1 - ldrb r1, [r0] - orrs r1, r4 - strb r1, [r0] - b _0801B900 - .align 2, 0 -_0801B7E8: .4byte gBankAttacker -_0801B7EC: .4byte gSideTimer -_0801B7F0: .4byte gBattleMons -_0801B7F4: .4byte gNoOfAllBanks -_0801B7F8: .4byte gAbsentBankFlags -_0801B7FC: .4byte gBitTable -_0801B800: .4byte gBattleMoves -_0801B804: .4byte gSpecialStatuses -_0801B808: - ldr r0, _0801B81C @ =gBankAttacker - ldrb r0, [r0] - bl GetBankIdentity - adds r1, r0, 0 - movs r2, 0x1 - movs r0, 0x1 - ands r0, r1 - eors r0, r2 - b _0801B8B2 - .align 2, 0 -_0801B81C: .4byte gBankAttacker -_0801B820: - ldr r0, _0801B854 @ =gBankAttacker - ldrb r0, [r0] - bl GetBankSide - movs r1, 0x1 - eors r0, r1 - lsls r0, 24 - lsrs r4, r0, 24 - ldr r1, _0801B858 @ =gSideTimer - lsls r0, r4, 1 - adds r0, r4 - lsls r0, 2 - adds r2, r0, r1 - ldrb r0, [r2, 0x8] - cmp r0, 0 - beq _0801B860 - ldr r1, _0801B85C @ =gBattleMons - ldrb r4, [r2, 0x9] - movs r0, 0x58 - muls r0, r4 - adds r0, r1 - ldrh r0, [r0, 0x28] - cmp r0, 0 - beq _0801B860 -_0801B850: - adds r5, r4, 0 - b _0801B900 - .align 2, 0 -_0801B854: .4byte gBankAttacker -_0801B858: .4byte gSideTimer -_0801B85C: .4byte gBattleMons -_0801B860: - ldr r0, _0801B894 @ =gBattleTypeFlags - ldrh r1, [r0] - movs r4, 0x1 - adds r0, r4, 0 - ands r0, r1 - cmp r0, 0 - beq _0801B8DC - movs r0, 0x4 - ands r6, r0 - cmp r6, 0 - beq _0801B8DC - ldr r0, _0801B898 @ =gBankAttacker - ldrb r0, [r0] - bl GetBankSide - lsls r0, 24 - cmp r0, 0 - bne _0801B8A0 - bl Random - adds r1, r4, 0 - ands r1, r0 - cmp r1, 0 - beq _0801B89C - movs r0, 0x1 - b _0801B8B2 - .align 2, 0 -_0801B894: .4byte gBattleTypeFlags -_0801B898: .4byte gBankAttacker -_0801B89C: - movs r0, 0x3 - b _0801B8B2 -_0801B8A0: - bl Random - adds r1, r4, 0 - ands r1, r0 - cmp r1, 0 - beq _0801B8B0 - movs r0, 0 - b _0801B8B2 -_0801B8B0: - movs r0, 0x2 -_0801B8B2: - bl GetBankByPlayerAI - lsls r0, 24 - lsrs r5, r0, 24 - ldr r0, _0801B8D4 @ =gAbsentBankFlags - ldrb r1, [r0] - ldr r2, _0801B8D8 @ =gBitTable - lsls r0, r5, 2 - adds r0, r2 - ldr r0, [r0] - ands r1, r0 - cmp r1, 0 - beq _0801B900 - movs r0, 0x2 - eors r5, r0 - b _0801B900 - .align 2, 0 -_0801B8D4: .4byte gAbsentBankFlags -_0801B8D8: .4byte gBitTable -_0801B8DC: - ldr r0, _0801B8F8 @ =gBankAttacker - ldrb r0, [r0] - bl GetBankIdentity - adds r1, r0, 0 - movs r2, 0x1 - movs r0, 0x1 - ands r0, r1 - eors r0, r2 - bl GetBankByPlayerAI - lsls r0, 24 - lsrs r5, r0, 24 - b _0801B900 - .align 2, 0 -_0801B8F8: .4byte gBankAttacker -_0801B8FC: - ldr r0, _0801B91C @ =gBankAttacker - ldrb r5, [r0] -_0801B900: - ldr r1, _0801B920 @ =0x02000000 - ldr r0, _0801B91C @ =gBankAttacker - ldrb r0, [r0] - ldr r2, _0801B924 @ =0x00016010 - adds r0, r2 - adds r0, r1 - strb r5, [r0] - adds r0, r5, 0 - add sp, 0x4 - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r1} - bx r1 - .align 2, 0 -_0801B91C: .4byte gBankAttacker -_0801B920: .4byte 0x02000000 -_0801B924: .4byte 0x00016010 - thumb_func_end sub_801B5C0 thumb_func_start IsPokeDisobedient IsPokeDisobedient: @ 801B928 diff --git a/data/data2b.s b/data/data2b.s index ef16eaa25..5fb3fa982 100644 --- a/data/data2b.s +++ b/data/data2b.s @@ -286,11 +286,3 @@ gLinkOpponentBufferCommands:: @ 81FB048 @ 81FB12C .include "data/battle_moves.inc" - - .align 2 -gUnknown_081FC1D0:: @ 81FC1D0 - .2byte 0x34, 0x10, 0x101 - .space 2 - - .2byte -1, -1, -1 - .space 2 diff --git a/include/battle.h b/include/battle.h index d68c8280e..4b2542017 100644 --- a/include/battle.h +++ b/include/battle.h @@ -96,6 +96,7 @@ #define HITMARKER_IGNORE_UNDERWATER 0x00040000 #define HITMARKER_UNABLE_TO_USE_MOVE 0x00080000 #define HITMARKER_x100000 0x00100000 +#define HITMARKER_x200000 0x00200000 #define HITMARKER_x400000 0x00400000 #define HITMARKER_x800000 0x00800000 #define HITMARKER_GRUDGE 0x01000000 @@ -661,6 +662,8 @@ extern u8 ewram[]; #define ewram17840 (*(struct Struct2017840 *) (ewram + 0x17840)) #define ewram17000 ((u32 *) (ewram + 0x17100)) +typedef void (*BattleCmdFunc)(void); + struct funcStack { void* ptr[8]; diff --git a/ld_script.txt b/ld_script.txt index e0b03cdf3..7f06efcf7 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -333,6 +333,7 @@ SECTIONS { data/data2a.o(.rodata); src/battle_4.o(.rodata); data/data2b.o(.rodata); + src/battle_3.o(.rodata); src/pokemon_data.o(.rodata); . = ALIGN(4); src/trig.o(.rodata); diff --git a/src/battle_3.c b/src/battle_3.c index be6460ec1..cbad8ab45 100644 --- a/src/battle_3.c +++ b/src/battle_3.c @@ -12,6 +12,7 @@ #include "text.h" #include "battle_move_effects.h" #include "string_util.h" +#include "flags.h" extern u8* gBattlescriptCurrInstr; extern u8 gActiveBank; @@ -61,7 +62,7 @@ bool8 sub_8018018(u8 bank, u8, u8); void sub_8015740(u8 bank); s32 CalculateBaseDamage(struct BattlePokemon *attacker, struct BattlePokemon *defender, u32 move, u16 a4, u16 powerOverride, u8 typeOverride, u8 bank_atk, u8 bank_def); u8 CountTrailingZeroBits(u32 a); -u8 sub_801B5C0(u16 move, u8 targetbyte); //get target of move +u8 sub_801B5C0(u16 move, u8 useMoveTarget); //get target of move u8 sub_803FC34(u8 bank); u16 sub_803FBFC(u8 a); u8 weather_get_current(void); @@ -6354,9 +6355,19 @@ u8 ItemBattleEffects(u8 caseID, u8 bank, bool8 moveTurn) return effect; } -extern const u16 gUnknown_081FC1D0[]; +struct CombinedMove +{ + u16 move1; + u16 move2; + u16 newMove; +}; + +const struct CombinedMove sCombinedMoves[2] = +{ + {MOVE_EMBER, MOVE_GUST, MOVE_HEAT_WAVE}, + {0xFFFF, 0xFFFF, 0xFFFF} +}; -/* void unref_sub_801B40C(void) { int i = 0; @@ -6372,23 +6383,220 @@ void unref_sub_801B40C(void) bank++; else { - if (gUnknown_081FC1D0[i * 4 + 0] == gChosenMovesByBanks[bank] && gUnknown_081FC1D0[i * 4 + 1] == gChosenMovesByBanks[bank + 2]) + if (sCombinedMoves[i].move1 == gChosenMovesByBanks[bank] && sCombinedMoves[i].move2 == gChosenMovesByBanks[bank + 2]) { gSideTimer[GetBankIdentity(bank) & 1].field3 = (bank) | ((bank + 2) << 4); - gSideTimer[GetBankIdentity(bank) & 1].field4 = gUnknown_081FC1D0[i * 4 + 2]; + gSideTimer[GetBankIdentity(bank) & 1].field4 = sCombinedMoves[i].newMove; gSideAffecting[GetBankIdentity(bank) & 1] |= SIDE_STATUS_X4; } - if (gUnknown_081FC1D0[i * 4 + 0] == gChosenMovesByBanks[bank + 2] && gUnknown_081FC1D0[i * 4 + 1] == gChosenMovesByBanks[bank]) + if (sCombinedMoves[i].move1 == gChosenMovesByBanks[bank + 2] && sCombinedMoves[i].move2 == gChosenMovesByBanks[bank]) { gSideTimer[GetBankIdentity(bank) & 1].field3 = (bank + 2) | ((bank) << 4); - gSideTimer[GetBankIdentity(bank) & 1].field4 = gUnknown_081FC1D0[i * 4 + 2]; + gSideTimer[GetBankIdentity(bank) & 1].field4 = sCombinedMoves[i].newMove; gSideAffecting[GetBankIdentity(bank) & 1] |= SIDE_STATUS_X4; } bank++; } } while (bank < 2); i++; - } while (gUnknown_081FC1D0[i * 4] != 0xFFFF); + } while (sCombinedMoves[i].move1 != 0xFFFF); + } +} + +extern const BattleCmdFunc gBattleScriptingCommandsTable[]; +extern u32 gBattleExecBuffer; + +void sub_801B594(void) +{ + if (gBattleExecBuffer == 0) + gBattleScriptingCommandsTable[*gBattlescriptCurrInstr](); +} + +u8 sub_801B5C0(u16 move, u8 useMoveTarget) //get move target +{ + u8 targetBank = 0; + u8 moveTarget; + u8 side; + + if (useMoveTarget) + moveTarget = useMoveTarget - 1; + else + moveTarget = gBattleMoves[move].target; + + switch (moveTarget) + { + case 0: + side = GetBankSide(gBankAttacker) ^ 1; + if (gSideTimer[side].followmeTimer && gBattleMons[gSideTimer[side].followmeTarget].hp) + targetBank = gSideTimer[side].followmeTarget; + else + { + side = GetBankSide(gBankAttacker); + do + { + targetBank = Random() % gNoOfAllBanks; + } while (targetBank == gBankAttacker || side == GetBankSide(targetBank) || gAbsentBankFlags & gBitTable[targetBank]); + if (gBattleMoves[move].type == TYPE_ELECTRIC + && AbilityBattleEffects(ABILITYEFFECT_COUNT_OTHER_SIZE, gBankAttacker, ABILITY_LIGHTNING_ROD, 0, 0) + && gBattleMons[targetBank].ability != ABILITY_LIGHTNING_ROD) + { + targetBank ^= 2; + RecordAbilityBattle(targetBank, gBattleMons[targetBank].ability); + gSpecialStatuses[targetBank].lightningRodRedirected = 1; + } + } + break; + case 1: + case 8: + case 32: + case 64: + targetBank = GetBankByPlayerAI((GetBankIdentity(gBankAttacker) & 1) ^ 1); + if (gAbsentBankFlags & gBitTable[targetBank]) + targetBank ^= 2; + break; + case 4: + side = GetBankSide(gBankAttacker) ^ 1; + if (gSideTimer[side].followmeTimer && gBattleMons[gSideTimer[side].followmeTarget].hp) + targetBank = gSideTimer[side].followmeTarget; + else if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE && moveTarget & 4) + { + if (GetBankSide(gBankAttacker) == 0) + { + if (Random() & 1) + targetBank = GetBankByPlayerAI(1); + else + targetBank = GetBankByPlayerAI(3); + } + else + { + if (Random() & 1) + targetBank = GetBankByPlayerAI(0); + else + targetBank = GetBankByPlayerAI(2); + } + if (gAbsentBankFlags & gBitTable[targetBank]) + targetBank ^= 2; + } + else + targetBank = GetBankByPlayerAI((GetBankIdentity(gBankAttacker) & 1) ^ 1); + break; + case 2: + case 16: + targetBank = gBankAttacker; + break; + } + ewram[gBankAttacker + 0x16010] = targetBank; + return targetBank; +} + +extern u8 gUnknown_081D995F[]; //disobedient while asleep +extern u8 gUnknown_081D9977[]; //disobedient no possible moves to use +extern u8 gUnknown_081D996F[]; //disobedient, uses a random move +extern u8 gUnknown_081D9989[]; //disobedient, went to sleep +extern u8 gUnknown_081D99A0[]; //disobedient, hits itself + +extern u8 gUnknown_02024BE5; +extern u8 gCurrMovePos; +extern u16 gRandomMove; +extern s32 gBattleMoveDamage; +extern u16 gDynamicBasePower; + +/* +u8 IsPokeDisobedient(void) +{ + u8 obedienceLevel; + register s32 calc asm("r4"); + + if (gBattleTypeFlags & BATTLE_TYPE_LINK + || GetBankSide(gBankAttacker) == 1 + || !IsOtherTrainer(gBattleMons[gBankAttacker].otId, gBattleMons[gBankAttacker].otName) + || FlagGet(BADGE08_GET)) + return 0; + + obedienceLevel = 10; + if (FlagGet(BADGE02_GET)) + obedienceLevel = 30; + if (FlagGet(BADGE04_GET)) + obedienceLevel = 50; + if (FlagGet(BADGE06_GET)) + obedienceLevel = 70; + + if (gBattleMons[gBankAttacker].level <= obedienceLevel) + return 0; + calc = (Random() & 255); + calc = (gBattleMons[gBankAttacker].level + obedienceLevel) * calc / 256; + if (calc < obedienceLevel) + return 0; + + // is not obedient + if (gCurrentMove == MOVE_RAGE) + gBattleMons[gBankAttacker].status2 &= ~(STATUS2_RAGE); + if (gBattleMons[gBankAttacker].status1 & STATUS_SLEEP && (gCurrentMove == MOVE_SNORE || gCurrentMove == MOVE_SLEEP_TALK)) + { + gBattlescriptCurrInstr = gUnknown_081D995F; + return 1; + } + calc = (Random() & 255); + calc = (gBattleMons[gBankAttacker].level + obedienceLevel) * calc / 256; + if (calc < obedienceLevel) + { + u8 moveLimitations = CheckMoveLimitations(gBankAttacker, gBitTable[gCurrMovePos], 0xFF); + if (moveLimitations == 0xF) // all moves cannot be used + { + gBattleCommunication[MULTISTRING_CHOOSER] = Random() & 3; + gBattlescriptCurrInstr = gUnknown_081D9977; + return 1; + } + else // use a random move + { + do + { + gCurrMovePos = gUnknown_02024BE5 = Random() & 3; + } while (gBitTable[gCurrMovePos] & moveLimitations); + gRandomMove = gBattleMons[gBankAttacker].moves[gCurrMovePos]; + gBattleCommunication[3] = 0; + gDynamicBasePower = 0; + BATTLE_STRUCT->dynamicMoveType = 0; + gBattlescriptCurrInstr = gUnknown_081D996F; + gBankTarget = sub_801B5C0(gRandomMove, 0); + gHitMarker |= HITMARKER_x200000; + return 2; + } + } + else + { + obedienceLevel = gBattleMons[gBankAttacker].level - obedienceLevel; + calc = (Random() & 255); + if (calc < obedienceLevel && !(gBattleMons[gBankAttacker].status1 & STATUS_ANY) && gBattleMons[gBankAttacker].ability != ABILITY_VITAL_SPIRIT && gBattleMons[gBankAttacker].ability != ABILITY_INSOMNIA) + { + // try putting asleep + int i; + for (i = 0; i < gNoOfAllBanks; i++) + { + if (gBattleMons[i].status2 & STATUS2_UPROAR) + break; + } + if (i == gNoOfAllBanks) + { + gBattlescriptCurrInstr = gUnknown_081D9989; + return 1; + } + } + calc -= obedienceLevel; + if (calc < obedienceLevel) + { + gBattleMoveDamage = CalculateBaseDamage(&gBattleMons[gBankAttacker], &gBattleMons[gBankAttacker], MOVE_POUND, 0, 40, 0, gBankAttacker, gBankAttacker); + gBankTarget = gBankAttacker; + gBattlescriptCurrInstr = gUnknown_081D99A0; + gHitMarker |= HITMARKER_UNABLE_TO_USE_MOVE; + return 2; + } + else + { + gBattleCommunication[MULTISTRING_CHOOSER] = Random() & 3; + gBattlescriptCurrInstr = gUnknown_081D9977; + return 1; + } } } */ diff --git a/src/battle_4.c b/src/battle_4.c index c4ffc4786..3912c3426 100644 --- a/src/battle_4.c +++ b/src/battle_4.c @@ -529,8 +529,6 @@ static void atkF5_removeattackerstatus1(void); static void atkF6_802BF48(void); static void atkF7_802BF54(void); -typedef void (*BattleCmdFunc)(void); - const BattleCmdFunc gBattleScriptingCommandsTable[] = { atk00_attackcanceler, From 9b73817c9015b91ecad0c5d1f4e7e57524f203d6 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Sat, 29 Jul 2017 21:21:31 +0200 Subject: [PATCH 8/8] Battle3 is done. Except ABE. --- asm/battle_2.s | 8 +- asm/battle_3.s | 389 --------------------------- data/battle_scripts_1.s | 144 +++++----- data/data2a.s | 2 +- ld_script.txt | 1 - src/battle_3.c | 563 ++++++++++++++++++++-------------------- src/battle_4.c | 32 +-- src/pokemon_3.c | 2 +- 8 files changed, 372 insertions(+), 769 deletions(-) delete mode 100644 asm/battle_3.s diff --git a/asm/battle_2.s b/asm/battle_2.s index 0fea1dc77..804cefa76 100644 --- a/asm/battle_2.s +++ b/asm/battle_2.s @@ -3558,7 +3558,7 @@ _08014044: str r0, [r2] movs r0, 0xA5 movs r1, 0 - bl sub_801B5C0 + bl GetMoveTarget ldrb r1, [r7] ldr r2, _080140EC @ =0x00016010 adds r1, r2 @@ -3646,7 +3646,7 @@ _08014138: strb r0, [r3] ldrh r0, [r1] movs r1, 0 - bl sub_801B5C0 + bl GetMoveTarget ldrb r1, [r7] ldr r4, _0801419C @ =0x00016010 adds r1, r4 @@ -3702,7 +3702,7 @@ _080141A0: strb r0, [r1, 0xE] ldrh r0, [r3] movs r1, 0 - bl sub_801B5C0 + bl GetMoveTarget ldrb r1, [r7] ldr r3, _08014214 @ =0x00016010 adds r1, r3 @@ -3740,7 +3740,7 @@ _08014218: strh r3, [r1] ldrh r0, [r1] movs r1, 0 - bl sub_801B5C0 + bl GetMoveTarget ldr r2, _08014270 @ =0x02000000 ldrb r1, [r4] ldr r3, _08014274 @ =0x00016010 diff --git a/asm/battle_3.s b/asm/battle_3.s deleted file mode 100644 index 40bded11d..000000000 --- a/asm/battle_3.s +++ /dev/null @@ -1,389 +0,0 @@ - .include "constants/gba_constants.inc" - .include "constants/species_constants.inc" - .include "asm/macros.inc" - - .syntax unified - - .text - - - - thumb_func_start IsPokeDisobedient -IsPokeDisobedient: @ 801B928 - push {r4-r7,lr} - mov r7, r9 - mov r6, r8 - push {r6,r7} - sub sp, 0x10 - ldr r0, _0801B9E0 @ =gBattleTypeFlags - ldrh r1, [r0] - movs r0, 0x2 - ands r0, r1 - cmp r0, 0 - bne _0801B9DA - ldr r7, _0801B9E4 @ =gBankAttacker - ldrb r0, [r7] - bl GetBankSide - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - beq _0801B9DA - ldr r5, _0801B9E8 @ =gBattleMons - ldrb r0, [r7] - movs r1, 0x58 - mov r8, r1 - mov r1, r8 - muls r1, r0 - adds r0, r5, 0 - adds r0, 0x54 - adds r0, r1, r0 - ldr r0, [r0] - adds r2, r5, 0 - adds r2, 0x3C - adds r1, r2 - bl IsOtherTrainer - lsls r0, 24 - cmp r0, 0 - beq _0801B9DA - ldr r0, _0801B9EC @ =0x0000080e - bl FlagGet - lsls r0, 24 - cmp r0, 0 - bne _0801B9DA - movs r6, 0xA - ldr r0, _0801B9F0 @ =0x00000808 - bl FlagGet - lsls r0, 24 - cmp r0, 0 - beq _0801B98E - movs r6, 0x1E -_0801B98E: - ldr r0, _0801B9F4 @ =0x0000080a - bl FlagGet - lsls r0, 24 - cmp r0, 0 - beq _0801B99C - movs r6, 0x32 -_0801B99C: - ldr r0, _0801B9F8 @ =0x0000080c - bl FlagGet - lsls r0, 24 - cmp r0, 0 - beq _0801B9AA - movs r6, 0x46 -_0801B9AA: - ldrb r0, [r7] - mov r2, r8 - muls r2, r0 - adds r0, r2, 0 - adds r0, r5 - adds r0, 0x2A - ldrb r0, [r0] - cmp r0, r6 - bls _0801B9DA - bl Random - movs r1, 0xFF - ands r1, r0 - ldrb r0, [r7] - mov r2, r8 - muls r2, r0 - adds r0, r2, r5 - adds r0, 0x2A - ldrb r0, [r0] - adds r0, r6 - muls r0, r1 - asrs r4, r0, 8 - cmp r4, r6 - bge _0801B9FC -_0801B9DA: - movs r0, 0 - b _0801BC24 - .align 2, 0 -_0801B9E0: .4byte gBattleTypeFlags -_0801B9E4: .4byte gBankAttacker -_0801B9E8: .4byte gBattleMons -_0801B9EC: .4byte 0x0000080e -_0801B9F0: .4byte 0x00000808 -_0801B9F4: .4byte 0x0000080a -_0801B9F8: .4byte 0x0000080c -_0801B9FC: - ldr r3, _0801BA3C @ =gCurrentMove - ldrh r0, [r3] - cmp r0, 0x63 - bne _0801BA12 - adds r0, r5, 0 - adds r0, 0x50 - adds r0, r2, r0 - ldr r1, [r0] - ldr r2, _0801BA40 @ =0xff7fffff - ands r1, r2 - str r1, [r0] -_0801BA12: - ldrb r0, [r7] - mov r1, r8 - muls r1, r0 - adds r0, r1, 0 - adds r1, r5, 0 - adds r1, 0x4C - adds r0, r1 - ldr r0, [r0] - movs r1, 0x7 - ands r0, r1 - cmp r0, 0 - beq _0801BA4C - ldrh r0, [r3] - cmp r0, 0xAD - beq _0801BA34 - cmp r0, 0xD6 - bne _0801BA4C -_0801BA34: - ldr r1, _0801BA44 @ =gBattlescriptCurrInstr - ldr r0, _0801BA48 @ =gUnknown_081D995F - b _0801BBCE - .align 2, 0 -_0801BA3C: .4byte gCurrentMove -_0801BA40: .4byte 0xff7fffff -_0801BA44: .4byte gBattlescriptCurrInstr -_0801BA48: .4byte gUnknown_081D995F -_0801BA4C: - bl Random - movs r5, 0xFF - adds r1, r5, 0 - ands r1, r0 - ldr r7, _0801BB04 @ =gBattleMons - ldr r2, _0801BB08 @ =gBankAttacker - mov r9, r2 - ldrb r3, [r2] - movs r0, 0x58 - mov r8, r0 - mov r0, r8 - muls r0, r3 - adds r0, r7 - adds r0, 0x2A - ldrb r2, [r0] - adds r0, r2, r6 - muls r0, r1 - asrs r4, r0, 8 - cmp r4, r6 - bge _0801BB3C - ldr r7, _0801BB0C @ =gBitTable - ldr r5, _0801BB10 @ =gCurrMovePos - ldrb r0, [r5] - lsls r0, 2 - adds r0, r7 - ldrb r1, [r0] - adds r0, r3, 0 - movs r2, 0xFF - bl CheckMoveLimitations - lsls r0, 24 - lsrs r4, r0, 24 - cmp r4, 0xF - bne _0801BA94 - b _0801BBBE -_0801BA94: - adds r6, r5, 0 - ldr r1, _0801BB14 @ =gUnknown_02024BE5 - mov r9, r1 - movs r2, 0x3 - mov r8, r2 -_0801BA9E: - bl Random - mov r1, r8 - ands r0, r1 - mov r2, r9 - strb r0, [r2] - strb r0, [r6] - ldrb r0, [r6] - lsls r0, 2 - adds r0, r7 - ldr r5, [r0] - ands r5, r4 - cmp r5, 0 - bne _0801BA9E - ldr r4, _0801BB18 @ =gRandomMove - ldr r3, _0801BB04 @ =gBattleMons - ldr r0, _0801BB10 @ =gCurrMovePos - ldrb r0, [r0] - lsls r0, 1 - ldr r1, _0801BB08 @ =gBankAttacker - ldrb r2, [r1] - movs r1, 0x58 - muls r1, r2 - adds r0, r1 - adds r3, 0xC - adds r0, r3 - ldrh r0, [r0] - strh r0, [r4] - ldr r0, _0801BB1C @ =gBattleCommunication - strb r5, [r0, 0x3] - ldr r0, _0801BB20 @ =gDynamicBasePower - movs r1, 0 - strh r5, [r0] - ldr r0, _0801BB24 @ =0x02000000 - ldr r2, _0801BB28 @ =0x0001601c - adds r0, r2 - strb r1, [r0] - ldr r1, _0801BB2C @ =gBattlescriptCurrInstr - ldr r0, _0801BB30 @ =gUnknown_081D996F - str r0, [r1] - ldrh r0, [r4] - movs r1, 0 - bl sub_801B5C0 - ldr r1, _0801BB34 @ =gBankTarget - strb r0, [r1] - ldr r2, _0801BB38 @ =gHitMarker - ldr r0, [r2] - movs r1, 0x80 - lsls r1, 14 - b _0801BC1E - .align 2, 0 -_0801BB04: .4byte gBattleMons -_0801BB08: .4byte gBankAttacker -_0801BB0C: .4byte gBitTable -_0801BB10: .4byte gCurrMovePos -_0801BB14: .4byte gUnknown_02024BE5 -_0801BB18: .4byte gRandomMove -_0801BB1C: .4byte gBattleCommunication -_0801BB20: .4byte gDynamicBasePower -_0801BB24: .4byte 0x02000000 -_0801BB28: .4byte 0x0001601c -_0801BB2C: .4byte gBattlescriptCurrInstr -_0801BB30: .4byte gUnknown_081D996F -_0801BB34: .4byte gBankTarget -_0801BB38: .4byte gHitMarker -_0801BB3C: - subs r0, r2, r6 - lsls r0, 24 - lsrs r6, r0, 24 - bl Random - adds r4, r5, 0 - ands r4, r0 - cmp r4, r6 - bge _0801BBB8 - mov r1, r9 - ldrb r0, [r1] - mov r1, r8 - muls r1, r0 - adds r0, r7, 0 - adds r0, 0x4C - adds r0, r1, r0 - ldr r0, [r0] - ands r0, r5 - cmp r0, 0 - bne _0801BBB8 - adds r0, r1, r7 - adds r0, 0x20 - ldrb r0, [r0] - cmp r0, 0x48 - beq _0801BBB8 - cmp r0, 0xF - beq _0801BBB8 - movs r2, 0 - ldr r0, _0801BBAC @ =gNoOfAllBanks - ldrb r3, [r0] - mov r8, r0 - cmp r2, r3 - bge _0801BB9E - ldr r0, [r7, 0x50] - movs r1, 0x70 - ands r0, r1 - cmp r0, 0 - bne _0801BB9E - adds r1, r7, 0 - adds r1, 0x50 - movs r5, 0x70 -_0801BB8E: - adds r1, 0x58 - adds r2, 0x1 - cmp r2, r3 - bge _0801BB9E - ldr r0, [r1] - ands r0, r5 - cmp r0, 0 - beq _0801BB8E -_0801BB9E: - mov r0, r8 - ldrb r0, [r0] - cmp r2, r0 - bne _0801BBB8 - ldr r1, _0801BBB0 @ =gBattlescriptCurrInstr - ldr r0, _0801BBB4 @ =gUnknown_081D9989 - b _0801BBCE - .align 2, 0 -_0801BBAC: .4byte gNoOfAllBanks -_0801BBB0: .4byte gBattlescriptCurrInstr -_0801BBB4: .4byte gUnknown_081D9989 -_0801BBB8: - subs r4, r6 - cmp r4, r6 - blt _0801BBE0 -_0801BBBE: - bl Random - ldr r2, _0801BBD4 @ =gBattleCommunication - movs r1, 0x3 - ands r1, r0 - strb r1, [r2, 0x5] - ldr r1, _0801BBD8 @ =gBattlescriptCurrInstr - ldr r0, _0801BBDC @ =gUnknown_081D9977 -_0801BBCE: - str r0, [r1] - movs r0, 0x1 - b _0801BC24 - .align 2, 0 -_0801BBD4: .4byte gBattleCommunication -_0801BBD8: .4byte gBattlescriptCurrInstr -_0801BBDC: .4byte gUnknown_081D9977 -_0801BBE0: - ldr r4, _0801BC34 @ =gBankAttacker - ldrb r1, [r4] - movs r0, 0x58 - muls r1, r0 - ldr r0, _0801BC38 @ =gBattleMons - adds r1, r0 - movs r0, 0x28 - str r0, [sp] - movs r0, 0 - str r0, [sp, 0x4] - ldrb r0, [r4] - str r0, [sp, 0x8] - ldrb r0, [r4] - str r0, [sp, 0xC] - adds r0, r1, 0 - movs r2, 0x1 - movs r3, 0 - bl CalculateBaseDamage - ldr r1, _0801BC3C @ =gBattleMoveDamage - str r0, [r1] - ldr r1, _0801BC40 @ =gBankTarget - ldrb r0, [r4] - strb r0, [r1] - ldr r1, _0801BC44 @ =gBattlescriptCurrInstr - ldr r0, _0801BC48 @ =gUnknown_081D99A0 - str r0, [r1] - ldr r2, _0801BC4C @ =gHitMarker - ldr r0, [r2] - movs r1, 0x80 - lsls r1, 12 -_0801BC1E: - orrs r0, r1 - str r0, [r2] - movs r0, 0x2 -_0801BC24: - add sp, 0x10 - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r7} - pop {r1} - bx r1 - .align 2, 0 -_0801BC34: .4byte gBankAttacker -_0801BC38: .4byte gBattleMons -_0801BC3C: .4byte gBattleMoveDamage -_0801BC40: .4byte gBankTarget -_0801BC44: .4byte gBattlescriptCurrInstr -_0801BC48: .4byte gUnknown_081D99A0 -_0801BC4C: .4byte gHitMarker - thumb_func_end IsPokeDisobedient - - .align 2, 0 @ Don't pad with nop. diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 3d5397842..0945d75c8 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -1168,7 +1168,7 @@ MoveEffect_Recharge: @ 81D7943 setbyte 0x2024d21, 221 jump BattleScript_1D6F42 -gUnknown_081D7956:: @ 81D7956 +BattleScript_MoveUsedMustRecharge:: @ 81D7956 printstring BATTLE_TEXT_MustRecharge waitmessage 64 jump BattleScript_EndTurn @@ -3335,12 +3335,12 @@ BattleScript_1D9083: @ 81D9083 faintpokemon TARGET, 0, 0x0 end2 -gUnknown_081D90A7:: @ 81D90A7 +BattleScript_BideStoringEnergy:: @ 81D90A7 printstring BATTLE_TEXT_StoringEnergy waitmessage 64 jump BattleScript_EndTurn -gUnknown_081D90B2:: @ 81D90B2 +BattleScript_BideAttack:: @ 81D90B2 printstring BATTLE_TEXT_UnleashedEnergy waitmessage 64 accuracycheck BattleScript_1D6F77, 0 @@ -3361,7 +3361,7 @@ gUnknown_081D90B2:: @ 81D90B2 faintpokemon TARGET, 0, 0x0 jump BattleScript_EndTurn -gUnknown_081D90F1:: @ 81D90F1 +BattleScript_BideNoEnergyToAttack:: @ 81D90F1 printstring BATTLE_TEXT_UnleashedEnergy waitmessage 64 jump BattleScript_ButItFailed @@ -3396,7 +3396,7 @@ gUnknown_081D9132:: @ 81D9132 waitmessage 64 return -gUnknown_081D9139:: @ 81D9139 +BattleScript_MoveUsedIsDisabled:: @ 81D9139 printstring BATTLE_TEXT_MoveIsDisabled waitmessage 64 jump BattleScript_EndTurn @@ -3471,7 +3471,7 @@ BattleScript_1D91FB: @ 81D91FB waitmessage 64 return -gUnknown_081D9202:: @ 81D9202 +BattleScript_PerishSongHits:: @ 81D9202 printstring BATTLE_TEXT_PerishSongFell waitmessage 64 orword 0x2024c6c, 0x100100 @@ -3480,7 +3480,7 @@ gUnknown_081D9202:: @ 81D9202 faintpokemon USER, 0, 0x0 end2 -gUnknown_081D921D:: @ 81D921D +BattleScript_PerishSongTimerGoesDown:: @ 81D921D printstring BATTLE_TEXT_PerishSongFell waitmessage 64 end2 @@ -3546,7 +3546,7 @@ BattleScript_SpikesFree:: @ 81D92D0 waitmessage 64 return -gUnknown_081D92D7:: @ 81D92D7 +BattleScript_FutureSightHits:: @ 81D92D7 printstring BATTLE_TEXT_TookAttack waitmessage 64 jumpifbyte 1, 0x2024d23, 0, BattleScript_1D92F4 @@ -3619,7 +3619,7 @@ BattleScript_MoveSelectionTaunted:: @ 81D938B printstring2 BATTLE_TEXT_TauntNoUse atk44 -gUnknown_081D938F:: @ 81D938F +BattleScript_MoveUsedIsTaunted:: @ 81D938F printstring BATTLE_TEXT_TauntNoUse waitmessage 64 jump BattleScript_EndTurn @@ -3686,7 +3686,7 @@ BattleScript_KnockedOff:: @ 81D944B waitmessage 64 return -gUnknown_081D9459:: @ 81D9459 +BattleScript_MoveUsedIsImprisoned:: @ 81D9459 printstring BATTLE_TEXT_SealedNoUse waitmessage 64 jump BattleScript_EndTurn @@ -3751,13 +3751,13 @@ gUnknown_081D94DA:: @ 81D94DA waitmessage 64 end2 -gUnknown_081D94EE:: @ 81D94EE +BattleScript_MoveUsedIsAsleep:: @ 81D94EE printstring BATTLE_TEXT_FastAsleep waitmessage 64 statusanimation USER jump BattleScript_EndTurn -gUnknown_081D94FB:: @ 81D94FB +BattleScript_MoveUsedWokeUp:: @ 81D94FB bicword 0x2024c6c, 0x10 printfromtable BattleTextList_401562 waitmessage 64 @@ -3792,13 +3792,13 @@ BattleScript_BurnTurnDmg:: @ 81D953A waitmessage 64 jump BattleScript_1D951E -gUnknown_081D9545:: @ 81D9545 +BattleScript_MoveUsedIsFrozen:: @ 81D9545 printstring BATTLE_TEXT_FrozenSolid waitmessage 64 statusanimation USER jump BattleScript_EndTurn -gUnknown_081D9552:: @ 81D9552 +BattleScript_MoveUsedUnfroze:: @ 81D9552 printfromtable BattleTextList_4015C4 waitmessage 64 atk98 1 @@ -3810,13 +3810,13 @@ gUnknown_081D955D:: @ 81D955D atk98 0 return -gUnknown_081D9566:: @ 81D9566 +BattleScript_MoveUsedIsParalyzed:: @ 81D9566 printstring BATTLE_TEXT_Paralyzed3 waitmessage 64 statusanimation USER jump BattleScript_EndTurn -gUnknown_081D9573:: @ 81D9573 +BattleScript_MoveUsedFlinched:: @ 81D9573 printstring BATTLE_TEXT_Flinched waitmessage 64 jump BattleScript_EndTurn @@ -3826,13 +3826,13 @@ gUnknown_081D957E:: @ 81D957E waitmessage 64 end2 -gUnknown_081D9587:: @ 81D9587 +BattleScript_ThrashConfuses:: @ 81D9587 atk66 1, 1, S_CONFUSED printstring BATTLE_TEXT_FatigueConfuse waitmessage 64 end2 -gUnknown_081D9595:: @ 81D9595 +BattleScript_MoveUsedIsConfused:: @ 81D9595 printstring BATTLE_TEXT_Confused waitmessage 64 atk65 1, 0x7 @@ -3855,7 +3855,7 @@ BattleScript_1D95AC: @ 81D95AC BattleScript_1D95D3: @ 81D95D3 return -gUnknown_081D95D4:: @ 81D95D4 +BattleScript_MoveUsedIsConfusedNoMore:: @ 81D95D4 printstring BATTLE_TEXT_ConfusionSnapOut waitmessage 64 return @@ -3876,13 +3876,13 @@ BattleScript_WrapEnds:: @ 81D95F4 waitmessage 64 end2 -gUnknown_081D95FB:: @ 81D95FB +BattleScript_MoveUsedIsInLove:: @ 81D95FB printstring BATTLE_TEXT_InLoveWith waitmessage 64 atk65 1, 0xf0000 return -gUnknown_081D9608:: @ 81D9608 +BattleScript_MoveUsedIsParalyzedCantAttack:: @ 81D9608 printstring BATTLE_TEXT_ImmobilizedBy waitmessage 64 jump BattleScript_EndTurn @@ -3915,7 +3915,7 @@ BattleScript_1D9648: @ 81D9648 waitstateatk return -gUnknown_081D964C:: @ 81D964C +BattleScript_YawnMakesAsleep:: @ 81D964C statusanimation 2 printstring BATTLE_TEXT_FellAsleep waitmessage 64 @@ -3996,7 +3996,7 @@ BattleScript_ItemSteal:: @ 81D96F6 waitmessage 64 return -gUnknown_081D9704:: @ 81D9704 +BattleScript_DrizzleActivates:: @ 81D9704 pause 32 printstring BATTLE_TEXT_RainMade waitstateatk @@ -4004,19 +4004,19 @@ gUnknown_081D9704:: @ 81D9704 callatk BattleScript_1D9761 end3 -gUnknown_081D9718:: @ 81D9718 +BattleScript_SpeedBoostActivates:: @ 81D9718 playanimation USER, 1, 0x20160a4 printstring BATTLE_TEXT_SpeedRisen waitmessage 64 end3 -gUnknown_081D9726:: @ 81D9726 +BattleScript_TraceActivates:: @ 81D9726 pause 32 printstring BATTLE_TEXT_Traced waitmessage 64 end3 -gUnknown_081D9730:: @ 81D9730 +BattleScript_RainDishActivates:: @ 81D9730 printstring BATTLE_TEXT_RestoredHPByItem waitmessage 64 orword 0x2024c6c, 0x100 @@ -4024,7 +4024,7 @@ gUnknown_081D9730:: @ 81D9730 datahpupdate USER end3 -gUnknown_081D9744:: @ 81D9744 +BattleScript_SandstreamActivates:: @ 81D9744 pause 32 printstring BATTLE_TEXT_WhipSandstorm waitstateatk @@ -4032,7 +4032,7 @@ gUnknown_081D9744:: @ 81D9744 callatk BattleScript_1D9761 end3 -gUnknown_081D9758:: @ 81D9758 +BattleScript_ShedSkinActivates:: @ 81D9758 printstring BATTLE_TEXT_CuredProblem waitmessage 64 atk98 1 @@ -4047,7 +4047,7 @@ BattleScript_1D9767: @ 81D9767 jumpifarraynotequal 0x2016003, 0x2024a68, 1, BattleScript_1D9767 return -gUnknown_081D977D:: @ 81D977D +BattleScript_CastformChange:: @ 81D977D callatk BattleScript_1D9783 end3 @@ -4095,7 +4095,7 @@ BattleScript_1D97F0: @ 81D97F0 waitmessage 64 jump BattleScript_1D97E4 -gUnknown_081D97FE:: @ 81D97FE +BattleScript_DroughtActivates:: @ 81D97FE pause 32 printstring BATTLE_TEXT_SunIntensified waitstateatk @@ -4123,10 +4123,10 @@ gUnknown_081D9834:: @ 81D9834 pause 64 jump BattleScript_EndTurn -gUnknown_081D9842:: @ 81D9842 +BattleScript_MoveHPDrain_PPLoss:: @ 81D9842 ppreduce -gUnknown_081D9843:: @ 81D9843 +BattleScript_MoveHPDrain:: @ 81D9843 attackstring pause 32 orword 0x2024c6c, 0x100 @@ -4137,10 +4137,10 @@ gUnknown_081D9843:: @ 81D9843 orbyte 0x2024c68, 8 jump BattleScript_EndTurn -gUnknown_081D9865:: @ 81D9865 +BattleScript_MoveHPDrain_FullHP_PPLoss:: @ 81D9865 ppreduce -gUnknown_081D9866:: @ 81D9866 +BattleScript_MoveHPDrain_FullHP:: @ 81D9866 attackstring pause 32 printstring BATTLE_TEXT_MadeUseless @@ -4148,10 +4148,10 @@ gUnknown_081D9866:: @ 81D9866 orbyte 0x2024c68, 8 jump BattleScript_EndTurn -gUnknown_081D987B:: @ 81D987B +BattleScript_FlashFireBoost_PPLoss:: @ 81D987B ppreduce -gUnknown_081D987C:: @ 81D987C +BattleScript_FlashFireBoost:: @ 81D987C attackstring pause 32 printfromtable BattleTextList_401648 @@ -4206,7 +4206,7 @@ BattleScript_1D98E5: @ 81D98E5 waitmessage 64 jump BattleScript_EndTurn -gUnknown_081D98F3:: @ 81D98F3 +BattleScript_SoundproofProtected:: @ 81D98F3 attackstring ppreduce pause 32 @@ -4227,12 +4227,12 @@ BattleScript_NoItemSteal:: @ 81D9913 waitmessage 64 jump BattleScript_EndTurn -gUnknown_081D9921:: @ 81D9921 +BattleScript_ColorChangeActivates:: @ 81D9921 printstring BATTLE_TEXT_MadeType waitmessage 64 return -gUnknown_081D9928:: @ 81D9928 +BattleScript_RoughSkinActivates:: @ 81D9928 orword 0x2024c6c, 0x100100 graphicalhpupdate USER datahpupdate USER @@ -4241,18 +4241,18 @@ gUnknown_081D9928:: @ 81D9928 faintpokemon USER, 0, 0x0 return -gUnknown_081D9943:: @ 81D9943 +BattleScript_CuteCharmActivates:: @ 81D9943 atk65 1, 0xf0000 printstring BATTLE_TEXT_InfatuatedPoke waitmessage 64 return -gUnknown_081D9950:: @ 81D9950 +BattleScript_ApplySecondaryEffect:: @ 81D9950 waitstateatk seteffectuser return -gUnknown_081D9953:: @ 81D9953 +BattleScript_SynchronizeActivates:: @ 81D9953 waitstateatk seteffecttarget return @@ -4275,7 +4275,7 @@ gUnknown_081D996F:: @ 81D996F waitmessage 64 jumptoattack TARGET -gUnknown_081D9977:: @ 81D9977 +BattleScript_MoveUsedLoafingAround:: @ 81D9977 printfromtable BattleTextList_40160E waitmessage 64 setbyte 0x201600c, 0 @@ -4301,11 +4301,11 @@ BattleScript_SubstituteFade:: @ 81D99AB printstring BATTLE_TEXT_SubFaded return -gUnknown_081D99B6:: @ 81D99B6 - callatk gUnknown_081D99BC +BattleScript_BerryCurePrlzEnd2:: @ 81D99B6 + callatk BattleScript_BerryCureParRet end2 -gUnknown_081D99BC:: @ 81D99BC +BattleScript_BerryCureParRet:: @ 81D99BC playanimation 10, 7, 0x0 printstring BATTLE_TEXT_CuredParalysis waitmessage 64 @@ -4313,11 +4313,11 @@ gUnknown_081D99BC:: @ 81D99BC removeitem 10 return -gUnknown_081D99CE:: @ 81D99CE - callatk gUnknown_081D99D4 +BattleScript_BerryCurePsnEnd2:: @ 81D99CE + callatk BattleScript_BerryCurePsnRet end2 -gUnknown_081D99D4:: @ 81D99D4 +BattleScript_BerryCurePsnRet:: @ 81D99D4 playanimation 10, 7, 0x0 printstring BATTLE_TEXT_CuredPoison waitmessage 64 @@ -4325,11 +4325,11 @@ gUnknown_081D99D4:: @ 81D99D4 removeitem 10 return -gUnknown_081D99E6:: @ 81D99E6 - callatk gUnknown_081D99EC +BattleScript_BerryCureBrnEnd2:: @ 81D99E6 + callatk BattleScript_BerryCureBrnRet end2 -gUnknown_081D99EC:: @ 81D99EC +BattleScript_BerryCureBrnRet:: @ 81D99EC playanimation 10, 7, 0x0 printstring BATTLE_TEXT_CuredBurn waitmessage 64 @@ -4337,11 +4337,11 @@ gUnknown_081D99EC:: @ 81D99EC removeitem 10 return -gUnknown_081D99FE:: @ 81D99FE - callatk gUnknown_081D9A04 +BattleScript_BerryCureFrzEnd2:: @ 81D99FE + callatk BattleScript_BerryCureFrzRet end2 -gUnknown_081D9A04:: @ 81D9A04 +BattleScript_BerryCureFrzRet:: @ 81D9A04 playanimation 10, 7, 0x0 printstring BATTLE_TEXT_CuredFreeze waitmessage 64 @@ -4349,11 +4349,11 @@ gUnknown_081D9A04:: @ 81D9A04 removeitem 10 return -gUnknown_081D9A16:: @ 81D9A16 - callatk gUnknown_081D9A1C +BattleScript_BerryCureSlpEnd2:: @ 81D9A16 + callatk BattleScript_BerryCureSlpRet end2 -gUnknown_081D9A1C:: @ 81D9A1C +BattleScript_BerryCureSlpRet:: @ 81D9A1C playanimation 10, 7, 0x0 printstring BATTLE_TEXT_CuredSleep waitmessage 64 @@ -4361,11 +4361,11 @@ gUnknown_081D9A1C:: @ 81D9A1C removeitem 10 return -gUnknown_081D9A2E:: @ 81D9A2E - callatk gUnknown_081D9A34 +BattleScript_BerryCureConfusionEnd2:: @ 81D9A2E + callatk BattleScript_BerryCureConfusionRet end2 -gUnknown_081D9A34:: @ 81D9A34 +BattleScript_BerryCureConfusionRet:: @ 81D9A34 playanimation 10, 7, 0x0 printstring BATTLE_TEXT_CuredConfusion waitmessage 64 @@ -4384,18 +4384,18 @@ gUnknown_081D9A4A:: @ 81D9A4A removeitem 10 return -gUnknown_081D9A5E:: @ 81D9A5E - callatk gUnknown_081D9A64 +BattleScript_WhiteHerbEnd2:: @ 81D9A5E + callatk BattleScript_WhiteHerbRet end2 -gUnknown_081D9A64:: @ 81D9A64 +BattleScript_WhiteHerbRet:: @ 81D9A64 playanimation 10, 7, 0x0 printstring BATTLE_TEXT_RestoredStatus waitmessage 64 removeitem 10 return -gUnknown_081D9A74:: @ 81D9A74 +BattleScript_ItemHealHP_RemoveItem:: @ 81D9A74 playanimation USER, 7, 0x0 printstring BATTLE_TEXT_RestoredHealth waitmessage 64 @@ -4405,18 +4405,18 @@ gUnknown_081D9A74:: @ 81D9A74 removeitem USER end2 -gUnknown_081D9A91:: @ 81D9A91 +BattleScript_BerryPPHealEnd2:: @ 81D9A91 playanimation USER, 7, 0x0 printstring BATTLE_TEXT_RestoredPP waitmessage 64 removeitem USER end2 -gUnknown_081D9AA1:: @ 81D9AA1 - callatk gUnknown_081D9AA7 +BattleScript_ItemHealHP_End2:: @ 81D9AA1 + callatk BattleScript_ItemHealHP_Ret end2 -gUnknown_081D9AA7:: @ 81D9AA7 +BattleScript_ItemHealHP_Ret:: @ 81D9AA7 playanimation USER, 7, 0x0 printstring BATTLE_TEXT_RestoredHPLittle waitmessage 64 @@ -4435,7 +4435,7 @@ BattleScript_HangedOnMsg:: @ 81D9AC6 waitmessage 64 return -gUnknown_081D9AD4:: @ 81D9AD4 +BattleScript_BerryConfuseHealEnd2:: @ 81D9AD4 playanimation USER, 7, 0x0 printstring BATTLE_TEXT_RestoredHealth waitmessage 64 @@ -4449,7 +4449,7 @@ gUnknown_081D9AD4:: @ 81D9AD4 removeitem USER end2 -gUnknown_081D9AFE:: @ 81D9AFE +BattleScript_BerryStatRaiseEnd2:: @ 81D9AFE playanimation USER, 7, 0x0 statbuffchange 65, BattleScript_1D9B0B @@ -4459,7 +4459,7 @@ BattleScript_1D9B0B: @ 81D9B0B removeitem USER end2 -gUnknown_081D9B19:: @ 81D9B19 +BattleScript_BerryFocusEnergyEnd2:: @ 81D9B19 playanimation USER, 7, 0x0 printstring BATTLE_TEXT_HustleUse waitmessage 64 diff --git a/data/data2a.s b/data/data2a.s index db2158fc7..657fc6908 100644 --- a/data/data2a.s +++ b/data/data2a.s @@ -1015,7 +1015,7 @@ gUnknown_081FA71F:: @ 81FA71F .byte 4, 4, 4, 4 .align 1 -gUnknown_081FA724:: @ 81FA724 +gSoundMovesTable:: @ 81FA724 .2byte 0x2D .2byte 0x2E .2byte 0x2F diff --git a/ld_script.txt b/ld_script.txt index 7f06efcf7..a0054668e 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -54,7 +54,6 @@ SECTIONS { src/battle_2.o(.text); asm/battle_2.o(.text); src/battle_3.o(.text); - asm/battle_3.o(.text); src/battle_4.o(.text); asm/battle_5.o(.text); src/battle_6.o(.text); diff --git a/src/battle_3.c b/src/battle_3.c index cbad8ab45..9bb9e333f 100644 --- a/src/battle_3.c +++ b/src/battle_3.c @@ -49,6 +49,21 @@ extern u8 gLastUsedAbility; extern u8 gBattleTextBuff2[]; extern u8 gFightStateTracker; extern struct BattleEnigmaBerry gEnigmaBerries[4]; +extern u8 gUnknown_02024BE5; +extern u8 gCurrMovePos; +extern u16 gRandomMove; +extern s32 gBattleMoveDamage; +extern u16 gDynamicBasePower; +extern u32 gBattleExecBuffer; +extern const u16 gSoundMovesTable[]; +extern const u8 gStatusConditionString_PoisonJpn[]; +extern const u8 gStatusConditionString_SleepJpn[]; +extern const u8 gStatusConditionString_ParalysisJpn[]; +extern const u8 gStatusConditionString_BurnJpn[]; +extern const u8 gStatusConditionString_IceJpn[]; +extern const u8 gStatusConditionString_ConfusionJpn[]; +extern const u8 gStatusConditionString_LoveJpn[]; +extern const BattleCmdFunc gBattleScriptingCommandsTable[]; u8 IsImprisoned(u8 bank, u16 move); u8 GetBankByPlayerAI(u8 ID); @@ -57,12 +72,12 @@ u8 GetBankSide(u8 bank); void b_call_bc_move_exec(u8* BS_ptr); bool8 sub_8015660(u8 bank); //check if a move failed void SetMoveEffect(bool8 primary, u8 certainArg); -bool8 sub_8025A44(u8 bank); //uproar wakeup check +bool8 UproarWakeUpCheck(u8 bank); bool8 sub_8018018(u8 bank, u8, u8); void sub_8015740(u8 bank); s32 CalculateBaseDamage(struct BattlePokemon *attacker, struct BattlePokemon *defender, u32 move, u16 a4, u16 powerOverride, u8 typeOverride, u8 bank_atk, u8 bank_def); u8 CountTrailingZeroBits(u32 a); -u8 sub_801B5C0(u16 move, u8 useMoveTarget); //get target of move +u8 GetMoveTarget(u16 move, u8 useMoveTarget); u8 sub_803FC34(u8 bank); u16 sub_803FBFC(u8 a); u8 weather_get_current(void); @@ -71,6 +86,7 @@ void RecordAbilityBattle(u8 bank, u8 ability); void RecordItemBattle(u8 bank, u8 holdEffect); void sub_8013F54(void); void sub_8013FBC(void); +s8 GetPokeFlavourRelation(u32 pid, u8 flavor); extern u8 BattleScript_MoveSelectionDisabledMove[]; extern u8 BattleScript_MoveSelectionTormented[]; @@ -100,34 +116,87 @@ extern u8 gUnknown_081D9008[]; extern u8 gUnknown_081D9041[]; extern u8 gUnknown_081D950F[]; //uproar wakeup BS extern u8 gUnknown_081D957E[]; //uproar BS -extern u8 gUnknown_081D9587[]; //thrash confusion BS -extern u8 gUnknown_081D964C[]; //yawn sleep BS -extern u8 gUnknown_081D92D7[]; //future sight hit -extern u8 gUnknown_081D9202[]; //perish song hit -extern u8 gUnknown_081D921D[]; //perish song timer goes down +extern u8 BattleScript_ThrashConfuses[]; +extern u8 BattleScript_YawnMakesAsleep[]; +extern u8 BattleScript_FutureSightHits[]; +extern u8 BattleScript_PerishSongHits[]; +extern u8 BattleScript_PerishSongTimerGoesDown[]; extern u8 gUnknown_081D8C72[]; extern u8 gUnknown_081D8C7B[]; -extern u8 gUnknown_081D94FB[]; //uproar wakes you up when trying to use a move -extern u8 gUnknown_081D94EE[]; //poke is asleep -extern u8 gUnknown_081D94FB[]; //poke woke up -extern u8 gUnknown_081D9545[]; //poke is frozen -extern u8 gUnknown_081D9552[]; //poke is no longer frozen -extern u8 gUnknown_081D9977[]; //poke is loafing around -extern u8 gUnknown_081D7956[]; //poke must recharge -extern u8 gUnknown_081D9573[]; //poke flinched -extern u8 gUnknown_081D9139[]; //poke tries to use a disabled move -extern u8 gUnknown_081D938F[]; //taunt prevents from using the chosen move -extern u8 gUnknown_081D9459[]; //using imprisoned move -extern u8 gUnknown_081D9595[]; //poke is confused -extern u8 gUnknown_081D95D4[]; //poke is confused no more -extern u8 gUnknown_081D9566[]; //poke is paralyzed -extern u8 gUnknown_081D9608[]; //poke is infatuated, won't attack -extern u8 gUnknown_081D95FB[]; //poke is infatuated -extern u8 gUnknown_081D90A7[]; //bide storing energy -extern u8 gUnknown_081D90B2[]; //bide attack -extern u8 gUnknown_081D90F1[]; //bide no energy to attack +extern u8 BattleScript_MoveUsedIsAsleep[]; +extern u8 BattleScript_MoveUsedWokeUp[]; +extern u8 BattleScript_MoveUsedIsFrozen[]; +extern u8 BattleScript_MoveUsedUnfroze[]; +extern u8 BattleScript_MoveUsedLoafingAround[]; +extern u8 BattleScript_MoveUsedMustRecharge[]; +extern u8 BattleScript_MoveUsedFlinched[]; +extern u8 BattleScript_MoveUsedIsDisabled[]; +extern u8 BattleScript_MoveUsedIsTaunted[]; +extern u8 BattleScript_MoveUsedIsImprisoned[]; +extern u8 BattleScript_MoveUsedIsConfused[]; +extern u8 BattleScript_MoveUsedIsConfusedNoMore[]; +extern u8 BattleScript_MoveUsedIsParalyzed[]; +extern u8 BattleScript_MoveUsedIsParalyzedCantAttack[]; +extern u8 BattleScript_MoveUsedIsInLove[]; +extern u8 BattleScript_BideStoringEnergy[]; +extern u8 BattleScript_BideAttack[]; +extern u8 BattleScript_BideNoEnergyToAttack[]; +extern u8 gUnknown_081D901D[]; //load weather from overworld +extern u8 BattleScript_DrizzleActivates[]; +extern u8 BattleScript_SandstreamActivates[]; +extern u8 BattleScript_DroughtActivates[]; +extern u8 BattleScript_CastformChange[]; +extern u8 BattleScript_RainDishActivates[]; +extern u8 BattleScript_ShedSkinActivates[]; +extern u8 BattleScript_SpeedBoostActivates[]; +extern u8 BattleScript_SoundproofProtected[]; +extern u8 BattleScript_MoveHPDrain[]; +extern u8 BattleScript_MoveHPDrain_PPLoss[]; +extern u8 BattleScript_FlashFireBoost[]; +extern u8 BattleScript_FlashFireBoost_PPLoss[]; +extern u8 BattleScript_MoveHPDrain_FullHP[]; +extern u8 BattleScript_MoveHPDrain_FullHP_PPLoss[]; +extern u8 BattleScript_ColorChangeActivates[]; +extern u8 BattleScript_RoughSkinActivates[]; +extern u8 BattleScript_ApplySecondaryEffect[]; +extern u8 BattleScript_CuteCharmActivates[]; +extern u8 gUnknown_081D9956[]; //ability status clear +extern u8 BattleScript_SynchronizeActivates[]; +extern u8 gUnknown_081D978C[]; //intimidate1 +extern u8 gUnknown_081D9795[]; //intimidate2 +extern u8 BattleScript_TraceActivates[]; + +extern u8 BattleScript_WhiteHerbEnd2[]; +extern u8 BattleScript_WhiteHerbRet[]; +extern u8 BattleScript_ItemHealHP_RemoveItem[]; +extern u8 BattleScript_BerryPPHealEnd2[]; +extern u8 BattleScript_ItemHealHP_End2[]; +extern u8 BattleScript_BerryConfuseHealEnd2[]; +extern u8 BattleScript_BerryStatRaiseEnd2[]; +extern u8 BattleScript_BerryFocusEnergyEnd2[]; +extern u8 BattleScript_BerryCurePrlzEnd2[]; +extern u8 BattleScript_BerryCurePsnEnd2[]; +extern u8 BattleScript_BerryCureBrnEnd2[]; +extern u8 BattleScript_BerryCureFrzEnd2[]; +extern u8 BattleScript_BerryCureSlpEnd2[]; +extern u8 BattleScript_BerryCureConfusionEnd2[]; +extern u8 gUnknown_081D9A44[]; //berry cure any status end2 +extern u8 BattleScript_BerryCureParRet[]; +extern u8 BattleScript_BerryCurePsnRet[]; +extern u8 BattleScript_BerryCureBrnRet[]; +extern u8 BattleScript_BerryCureFrzRet[]; +extern u8 BattleScript_BerryCureSlpRet[]; +extern u8 BattleScript_BerryCureConfusionRet[]; +extern u8 gUnknown_081D9A4A[]; //berry cure any status return + +extern u8 BattleScript_ItemHealHP_Ret[]; + +extern u8 gUnknown_081D995F[]; //disobedient while asleep +extern u8 gUnknown_081D996F[]; //disobedient, uses a random move +extern u8 gUnknown_081D9989[]; //disobedient, went to sleep +extern u8 gUnknown_081D99A0[]; //disobedient, hits itself #define CHOICED_MOVE(bank)(((u16*)(&ewram[bank * 2 + 0x160e8]))) @@ -743,7 +812,7 @@ u8 TurnBasedEffects(void) gBattleCommunication[MOVE_EFFECT_BYTE] = 0x47; SetMoveEffect(1, 0); if (gBattleMons[gActiveBank].status2 & STATUS2_CONFUSION) - b_call_bc_move_exec(gUnknown_081D9587); + b_call_bc_move_exec(BattleScript_ThrashConfuses); effect++; } } @@ -813,14 +882,14 @@ u8 TurnBasedEffects(void) gStatuses3[gActiveBank] -= 0x800; if (!(gStatuses3[gActiveBank] & STATUS3_YAWN) && !(gBattleMons[gActiveBank].status1 & STATUS_ANY) && gBattleMons[gActiveBank].ability != ABILITY_VITAL_SPIRIT - && gBattleMons[gActiveBank].ability != ABILITY_INSOMNIA && !sub_8025A44(gActiveBank)) + && gBattleMons[gActiveBank].ability != ABILITY_INSOMNIA && !UproarWakeUpCheck(gActiveBank)) { CancelMultiTurnMoves(gActiveBank); gBattleMons[gActiveBank].status1 |= (Random() & 3) + 2; EmitSetAttributes(0, REQUEST_STATUS_BATTLE, 0, 4, &gBattleMons[gActiveBank].status1); MarkBufferBankForExecution(gActiveBank); gEffectBank = gActiveBank; - b_call_bc_move_exec(gUnknown_081D964C); + b_call_bc_move_exec(BattleScript_YawnMakesAsleep); effect++; } } @@ -868,7 +937,7 @@ bool8 sub_80170DC(void) // handle future sight and perish song gBankAttacker = gWishFutureKnock.futureSightAttacker[gActiveBank]; gBattleMoveDamage = gWishFutureKnock.futureSightDmg[gActiveBank]; gSpecialStatuses[gBankTarget].moveturnLostHP = 0xFFFF; - b_call_bc_move_exec(gUnknown_081D92D7); + b_call_bc_move_exec(BattleScript_FutureSightHits); return 1; } } @@ -896,12 +965,12 @@ bool8 sub_80170DC(void) // handle future sight and perish song { gStatuses3[gActiveBank] &= ~(STATUS3_PERISH_SONG); gBattleMoveDamage = gBattleMons[gActiveBank].hp; - gBattlescriptCurrInstr = gUnknown_081D9202; + gBattlescriptCurrInstr = BattleScript_PerishSongHits; } else { gDisableStructs[gActiveBank].perishSong1--; - gBattlescriptCurrInstr = gUnknown_081D921D; + gBattlescriptCurrInstr = BattleScript_PerishSongTimerGoesDown; } b_call_bc_move_exec(gBattlescriptCurrInstr); return 1; @@ -1015,13 +1084,13 @@ u8 AtkCanceller_UnableToUseMove(void) case 1: // check being asleep if (gBattleMons[gBankAttacker].status1 & STATUS_SLEEP) { - if (sub_8025A44(gBankAttacker)) + if (UproarWakeUpCheck(gBankAttacker)) { gBattleMons[gBankAttacker].status1 &= ~(STATUS_SLEEP); gBattleMons[gBankAttacker].status2 &= ~(STATUS2_NIGHTMARE); b_movescr_stack_push_cursor(); gBattleCommunication[MULTISTRING_CHOOSER] = 1; - gBattlescriptCurrInstr = gUnknown_081D94FB; + gBattlescriptCurrInstr = BattleScript_MoveUsedWokeUp; effect = 2; } else @@ -1039,7 +1108,7 @@ u8 AtkCanceller_UnableToUseMove(void) { if (gCurrentMove != MOVE_SNORE && gCurrentMove != MOVE_SLEEP_TALK) { - gBattlescriptCurrInstr = gUnknown_081D94EE; + gBattlescriptCurrInstr = BattleScript_MoveUsedIsAsleep; gHitMarker |= HITMARKER_UNABLE_TO_USE_MOVE; effect = 2; } @@ -1049,7 +1118,7 @@ u8 AtkCanceller_UnableToUseMove(void) gBattleMons[gBankAttacker].status2 &= ~(STATUS2_NIGHTMARE); b_movescr_stack_push_cursor(); gBattleCommunication[MULTISTRING_CHOOSER] = 0; - gBattlescriptCurrInstr = gUnknown_081D94FB; + gBattlescriptCurrInstr = BattleScript_MoveUsedWokeUp; effect = 2; } } @@ -1063,7 +1132,7 @@ u8 AtkCanceller_UnableToUseMove(void) { if (gBattleMoves[gCurrentMove].effect != EFFECT_THAW_HIT) // unfreezing via a move effect happens in case 13 { - gBattlescriptCurrInstr = gUnknown_081D9545; + gBattlescriptCurrInstr = BattleScript_MoveUsedIsFrozen; gHitMarker |= HITMARKER_NO_ATTACKSTRING; } else @@ -1076,7 +1145,7 @@ u8 AtkCanceller_UnableToUseMove(void) { gBattleMons[gBankAttacker].status1 &= ~(STATUS_FREEZE); b_movescr_stack_push_cursor(); - gBattlescriptCurrInstr = gUnknown_081D9552; + gBattlescriptCurrInstr = BattleScript_MoveUsedUnfroze; gBattleCommunication[MULTISTRING_CHOOSER] = 0; } effect = 2; @@ -1089,7 +1158,7 @@ u8 AtkCanceller_UnableToUseMove(void) CancelMultiTurnMoves(gBankAttacker); gHitMarker |= HITMARKER_UNABLE_TO_USE_MOVE; gBattleCommunication[MULTISTRING_CHOOSER] = 0; - gBattlescriptCurrInstr = gUnknown_081D9977; + gBattlescriptCurrInstr = BattleScript_MoveUsedLoafingAround; gBattleMoveFlags |= MOVESTATUS_MISSED; effect = 1; } @@ -1101,7 +1170,7 @@ u8 AtkCanceller_UnableToUseMove(void) gBattleMons[gBankAttacker].status2 &= ~(STATUS2_RECHARGE); gDisableStructs[gBankAttacker].rechargeCounter = 0; CancelMultiTurnMoves(gBankAttacker); - gBattlescriptCurrInstr = gUnknown_081D7956; + gBattlescriptCurrInstr = BattleScript_MoveUsedMustRecharge; gHitMarker |= HITMARKER_UNABLE_TO_USE_MOVE; effect = 1; } @@ -1113,7 +1182,7 @@ u8 AtkCanceller_UnableToUseMove(void) gBattleMons[gBankAttacker].status2 &= ~(STATUS2_FLINCHED); gProtectStructs[gBankAttacker].flinchImmobility = 1; CancelMultiTurnMoves(gBankAttacker); - gBattlescriptCurrInstr = gUnknown_081D9573; + gBattlescriptCurrInstr = BattleScript_MoveUsedFlinched; gHitMarker |= HITMARKER_UNABLE_TO_USE_MOVE; effect = 1; } @@ -1125,7 +1194,7 @@ u8 AtkCanceller_UnableToUseMove(void) gProtectStructs[gBankAttacker].usedDisabledMove = 1; BATTLE_STRUCT->scriptingActive = gBankAttacker; CancelMultiTurnMoves(gBankAttacker); - gBattlescriptCurrInstr = gUnknown_081D9139; + gBattlescriptCurrInstr = BattleScript_MoveUsedIsDisabled; gHitMarker |= HITMARKER_UNABLE_TO_USE_MOVE; effect = 1; } @@ -1136,7 +1205,7 @@ u8 AtkCanceller_UnableToUseMove(void) { gProtectStructs[gBankAttacker].usedTauntedMove = 1; CancelMultiTurnMoves(gBankAttacker); - gBattlescriptCurrInstr = gUnknown_081D938F; + gBattlescriptCurrInstr = BattleScript_MoveUsedIsTaunted; gHitMarker |= HITMARKER_UNABLE_TO_USE_MOVE; effect = 1; } @@ -1147,7 +1216,7 @@ u8 AtkCanceller_UnableToUseMove(void) { gProtectStructs[gBankAttacker].usedImprisionedMove = 1; CancelMultiTurnMoves(gBankAttacker); - gBattlescriptCurrInstr = gUnknown_081D9459; + gBattlescriptCurrInstr = BattleScript_MoveUsedIsImprisoned; gHitMarker |= HITMARKER_UNABLE_TO_USE_MOVE; effect = 1; } @@ -1172,12 +1241,12 @@ u8 AtkCanceller_UnableToUseMove(void) gProtectStructs[gBankAttacker].confusionSelfDmg = 1; gHitMarker |= HITMARKER_UNABLE_TO_USE_MOVE; } - gBattlescriptCurrInstr = gUnknown_081D9595; + gBattlescriptCurrInstr = BattleScript_MoveUsedIsConfused; } else // snapped out of confusion { b_movescr_stack_push_cursor(); - gBattlescriptCurrInstr = gUnknown_081D95D4; + gBattlescriptCurrInstr = BattleScript_MoveUsedIsConfusedNoMore; } effect = 1; } @@ -1188,7 +1257,7 @@ u8 AtkCanceller_UnableToUseMove(void) { gProtectStructs[gBankAttacker].prlzImmobility = 1; CancelMultiTurnMoves(gBankAttacker); - gBattlescriptCurrInstr = gUnknown_081D9566; + gBattlescriptCurrInstr = BattleScript_MoveUsedIsParalyzed; gHitMarker |= HITMARKER_UNABLE_TO_USE_MOVE; effect = 1; } @@ -1202,12 +1271,12 @@ u8 AtkCanceller_UnableToUseMove(void) b_movescr_stack_push_cursor(); else { - b_movescr_stack_push(gUnknown_081D9608); + b_movescr_stack_push(BattleScript_MoveUsedIsParalyzedCantAttack); gHitMarker |= HITMARKER_UNABLE_TO_USE_MOVE; gProtectStructs[gBankAttacker].loveImmobility = 1; CancelMultiTurnMoves(gBankAttacker); } - gBattlescriptCurrInstr = gUnknown_081D95FB; + gBattlescriptCurrInstr = BattleScript_MoveUsedIsInLove; effect = 1; } BATTLE_STRUCT->atkCancellerTracker++; @@ -1217,7 +1286,7 @@ u8 AtkCanceller_UnableToUseMove(void) { gBattleMons[gBankAttacker].status2 -= 0x100; if (gBattleMons[gBankAttacker].status2 & STATUS2_BIDE) - gBattlescriptCurrInstr = gUnknown_081D90A7; + gBattlescriptCurrInstr = BattleScript_BideStoringEnergy; else { gBattleMons[gBankAttacker].status2 &= ~(STATUS2_MULTIPLETURNS); @@ -1227,11 +1296,11 @@ u8 AtkCanceller_UnableToUseMove(void) *bideDmg = gTakenDmg[gBankAttacker] * 2; gBankTarget = gTakenDmgBanks[gBankAttacker]; if (gAbsentBankFlags & gBitTable[gBankTarget]) - gBankTarget = sub_801B5C0(MOVE_BIDE, 1); - gBattlescriptCurrInstr = gUnknown_081D90B2; + gBankTarget = GetMoveTarget(MOVE_BIDE, 1); + gBattlescriptCurrInstr = BattleScript_BideAttack; } else - gBattlescriptCurrInstr = gUnknown_081D90F1; + gBattlescriptCurrInstr = BattleScript_BideNoEnergyToAttack; } effect = 1; } @@ -1244,7 +1313,7 @@ u8 AtkCanceller_UnableToUseMove(void) { gBattleMons[gBankAttacker].status1 &= ~(STATUS_FREEZE); b_movescr_stack_push_cursor(); - gBattlescriptCurrInstr = gUnknown_081D9552; + gBattlescriptCurrInstr = BattleScript_MoveUsedUnfroze; gBattleCommunication[MULTISTRING_CHOOSER] = 1; } effect = 2; @@ -1365,66 +1434,6 @@ u8 CastformDataTypeChange(u8 bank) return formChange; } -extern const u8 gStatusConditionString_PoisonJpn[]; -extern const u8 gStatusConditionString_SleepJpn[]; -extern const u8 gStatusConditionString_ParalysisJpn[]; -extern const u8 gStatusConditionString_BurnJpn[]; -extern const u8 gStatusConditionString_IceJpn[]; -extern const u8 gStatusConditionString_ConfusionJpn[]; -extern const u8 gStatusConditionString_LoveJpn[]; - -extern const u16 gUnknown_081FA724[]; //sound moves table - -extern u8 gUnknown_081D901D[]; //load weather from overworld -extern u8 gUnknown_081D9704[]; //Drizzle activates -extern u8 gUnknown_081D9744[]; //Sandstream activates -extern u8 gUnknown_081D97FE[]; //Drought activates -extern u8 gUnknown_081D977D[]; //castform change -extern u8 gUnknown_081D9730[]; //rain dish hp heal -extern u8 gUnknown_081D9758[]; //shed skin status heal -extern u8 gUnknown_081D9718[]; //speed boost bs -extern u8 gUnknown_081D98F3[]; //soundproof protection -extern u8 gUnknown_081D9843[]; //volt/water absorb no pp loss -extern u8 gUnknown_081D9842[]; //volt/water absorb pp loss -extern u8 gUnknown_081D987C[]; //flash fire boost no pp loss -extern u8 gUnknown_081D987B[]; //flash fire boost pp loss -extern u8 gUnknown_081D9866[]; //volt/water absorb no pp loss full hp -extern u8 gUnknown_081D9865[]; //volt/water absorb pp loss full hp -extern u8 gUnknown_081D9921[]; //color change type change -extern u8 gUnknown_081D9928[]; //rough skin damage -extern u8 gUnknown_081D9950[]; //secondary effect applier -extern u8 gUnknown_081D9943[]; //cute charm activates -extern u8 gUnknown_081D9956[]; //ability status clear -extern u8 gUnknown_081D9953[]; //synchronize effect -extern u8 gUnknown_081D978C[]; //intimidate1 -extern u8 gUnknown_081D9795[]; //intimidate2 -extern u8 gUnknown_081D9726[]; //trace effect - -extern u8 gUnknown_081D9A5E[]; //white herb end2 -extern u8 gUnknown_081D9A64[]; //white herb return -extern u8 gUnknown_081D9A74[]; //item hp heal end2 -extern u8 gUnknown_081D9A91[]; //berry pp heal end2 -extern u8 gUnknown_081D9AA1[]; //leftovers heal end2 -extern u8 gUnknown_081D9AD4[]; //berry heal/confuse end2 -extern u8 gUnknown_081D9AFE[]; //berry stat raise end2 -extern u8 gUnknown_081D9B19[]; //berry focus energy end2 -extern u8 gUnknown_081D99B6[]; //berry cure par end2 -extern u8 gUnknown_081D99CE[]; //berry cure psn end2 -extern u8 gUnknown_081D99E6[]; //berry cure brn end2 -extern u8 gUnknown_081D99FE[]; //berry cure frz end2 -extern u8 gUnknown_081D9A16[]; //berry cure slp end2 -extern u8 gUnknown_081D9A2E[]; //berry cure confusion end2 -extern u8 gUnknown_081D9A44[]; //berry cure any status end2 -extern u8 gUnknown_081D99BC[]; //berry cure par return -extern u8 gUnknown_081D99D4[]; //berry cure psn return -extern u8 gUnknown_081D99EC[]; //berry cure brn return -extern u8 gUnknown_081D9A04[]; //berry cure frz return -extern u8 gUnknown_081D9A1C[]; //berry cure slp return -extern u8 gUnknown_081D9A34[]; //berry cure confusion return -extern u8 gUnknown_081D9A4A[]; //berry cure any status return - -extern u8 gUnknown_081D9AA7[]; //shell bell hp heal - #ifdef NONMATCHING struct Struct2017100 @@ -1543,7 +1552,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) if (!(gBattleWeather & WEATHER_RAIN_PERMANENT)) { gBattleWeather = (WEATHER_RAIN_PERMANENT | WEATHER_RAIN_TEMPORARY); - b_push_move_exec(gUnknown_081D9704); + b_push_move_exec(BattleScript_DrizzleActivates); BATTLE_STRUCT->scriptingActive = bank; effect++; } @@ -1553,7 +1562,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) if (!(gBattleWeather & WEATHER_SANDSTORM_PERMANENT)) { gBattleWeather = (WEATHER_SANDSTORM_PERMANENT | WEATHER_SANDSTORM_TEMPORARY); - b_push_move_exec(gUnknown_081D9744); + b_push_move_exec(BattleScript_SandstreamActivates); BATTLE_STRUCT->scriptingActive = bank; effect++; } @@ -1563,7 +1572,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) if (!(gBattleWeather & WEATHER_SUN_PERMANENT)) { gBattleWeather = (WEATHER_SUN_PERMANENT | WEATHER_SUN_TEMPORARY); - b_push_move_exec(gUnknown_081D97FE); + b_push_move_exec(BattleScript_DroughtActivates); BATTLE_STRUCT->scriptingActive = bank; effect++; } @@ -1581,7 +1590,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) effect = CastformDataTypeChange(bank); if (effect != 0) { - b_push_move_exec(gUnknown_081D977D); + b_push_move_exec(BattleScript_CastformChange); BATTLE_STRUCT->scriptingActive = bank; BATTLE_STRUCT->castformToChangeInto = effect - 1; } @@ -1607,7 +1616,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) effect = CastformDataTypeChange(i); if (effect != 0) { - b_push_move_exec(gUnknown_081D977D); + b_push_move_exec(BattleScript_CastformChange); BATTLE_STRUCT->scriptingActive = i; BATTLE_STRUCT->castformToChangeInto = effect - 1; break; @@ -1629,7 +1638,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) && gBattleMons[bank].maxHP > gBattleMons[bank].hp) { gLastUsedAbility = ABILITY_RAIN_DISH; //why - b_push_move_exec(gUnknown_081D9730); + b_push_move_exec(BattleScript_RainDishActivates); gBattleMoveDamage = gBattleMons[bank].maxHP / 16; if (gBattleMoveDamage == 0) gBattleMoveDamage = 1; @@ -1653,7 +1662,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) gBattleMons[bank].status1 = 0; //gBattleMons[bank].status2 &= ~(STATUS2_NIGHTMARE); fixed in Emerald BATTLE_STRUCT->scriptingActive = gActiveBank = bank; - b_push_move_exec(gUnknown_081D9758); + b_push_move_exec(BattleScript_ShedSkinActivates); EmitSetAttributes(0, REQUEST_STATUS_BATTLE, 0, 4, &gBattleMons[bank].status1); MarkBufferBankForExecution(gActiveBank); effect++; @@ -1665,7 +1674,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) gBattleMons[bank].statStages[STAT_STAGE_SPEED]++; BATTLE_STRUCT->animArg1 = 0x11; BATTLE_STRUCT->animArg2 = 0; - b_push_move_exec(gUnknown_081D9718); + b_push_move_exec(BattleScript_SpeedBoostActivates); BATTLE_STRUCT->scriptingActive = bank; effect++; } @@ -1680,16 +1689,16 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) //_08018A40 if (gLastUsedAbility == ABILITY_SOUNDPROOF) { - for (i = 0; gUnknown_081FA724[i] != 0xFFFF; i++) + for (i = 0; gSoundMovesTable[i] != 0xFFFF; i++) { - if (gUnknown_081FA724[i] == move) + if (gSoundMovesTable[i] == move) break; } - if (gUnknown_081FA724[i] != 0xFFFF) + if (gSoundMovesTable[i] != 0xFFFF) { if (gBattleMons[gBankAttacker].status2 & STATUS2_MULTIPLETURNS) gHitMarker |= HITMARKER_NO_PPDEDUCT; - gBattlescriptCurrInstr = gUnknown_081D98F3; + gBattlescriptCurrInstr = BattleScript_SoundproofProtected; effect = 1; } } @@ -1704,9 +1713,9 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) if (moveType == TYPE_ELECTRIC && gBattleMoves[move].power != 0) { if (gProtectStructs[gBankAttacker].notFirstStrike) - gBattlescriptCurrInstr = gUnknown_081D9843; + gBattlescriptCurrInstr = BattleScript_MoveHPDrain; else - gBattlescriptCurrInstr = gUnknown_081D9842; + gBattlescriptCurrInstr = BattleScript_MoveHPDrain_PPLoss; effect = 1; } break; @@ -1714,9 +1723,9 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) if (moveType == TYPE_WATER && gBattleMoves[move].power != 0) { if (gProtectStructs[gBankAttacker].notFirstStrike) - gBattlescriptCurrInstr = gUnknown_081D9843; + gBattlescriptCurrInstr = BattleScript_MoveHPDrain; else - gBattlescriptCurrInstr = gUnknown_081D9842; + gBattlescriptCurrInstr = BattleScript_MoveHPDrain_PPLoss; effect = 1; } break; @@ -1727,9 +1736,9 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) { gBattleCommunication[MULTISTRING_CHOOSER] = 0; if (gProtectStructs[gBankAttacker].notFirstStrike) - gBattlescriptCurrInstr = gUnknown_081D987C; + gBattlescriptCurrInstr = BattleScript_FlashFireBoost; else - gBattlescriptCurrInstr = gUnknown_081D987B; + gBattlescriptCurrInstr = BattleScript_FlashFireBoost_PPLoss; ewram17100.arr[bank] |= 1; effect = 2; } @@ -1737,9 +1746,9 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) { gBattleCommunication[MULTISTRING_CHOOSER] = 1; if (gProtectStructs[gBankAttacker].notFirstStrike) - gBattlescriptCurrInstr = gUnknown_081D987C; + gBattlescriptCurrInstr = BattleScript_FlashFireBoost; else - gBattlescriptCurrInstr = gUnknown_081D987B; + gBattlescriptCurrInstr = BattleScript_FlashFireBoost_PPLoss; effect = 2; } } @@ -1750,9 +1759,9 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) if (gBattleMons[bank].maxHP == gBattleMons[bank].hp) { if ((gProtectStructs[gBankAttacker].notFirstStrike)) - gBattlescriptCurrInstr = gUnknown_081D9843; + gBattlescriptCurrInstr = BattleScript_MoveHPDrain; else - gBattlescriptCurrInstr = gUnknown_081D9842; + gBattlescriptCurrInstr = BattleScript_MoveHPDrain_PPLoss; } else { @@ -1785,7 +1794,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) gBattleTextBuff1[2] = moveType; gBattleTextBuff1[3] = 0xFF; b_movescr_stack_push_cursor(); - gBattlescriptCurrInstr = gUnknown_081D9921; + gBattlescriptCurrInstr = BattleScript_ColorChangeActivates; effect++; } break; @@ -1801,7 +1810,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) if (gBattleMoveDamage == 0) gBattleMoveDamage = 1; b_movescr_stack_push_cursor(); - gBattlescriptCurrInstr = gUnknown_081D9928; + gBattlescriptCurrInstr = BattleScript_RoughSkinActivates; effect++; } break; @@ -1822,7 +1831,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) gBattleCommunication[MOVE_EFFECT_BYTE] += 2; gBattleCommunication[MOVE_EFFECT_BYTE] += 0x40; b_movescr_stack_push_cursor(); - gBattlescriptCurrInstr = gUnknown_081D9950; + gBattlescriptCurrInstr = BattleScript_ApplySecondaryEffect; gHitMarker |= HITMARKER_IGNORE_SAFEGUARD; effect++; } @@ -1838,7 +1847,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) { gBattleCommunication[MOVE_EFFECT_BYTE] = 0x42; b_movescr_stack_push_cursor(); - gBattlescriptCurrInstr = gUnknown_081D9950; + gBattlescriptCurrInstr = BattleScript_ApplySecondaryEffect; gHitMarker |= HITMARKER_IGNORE_SAFEGUARD; effect++; } @@ -1854,7 +1863,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) { gBattleCommunication[MOVE_EFFECT_BYTE] = 0x45; b_movescr_stack_push_cursor(); - gBattlescriptCurrInstr = gUnknown_081D9950; + gBattlescriptCurrInstr = BattleScript_ApplySecondaryEffect; gHitMarker |= HITMARKER_IGNORE_SAFEGUARD; effect++; } @@ -1870,7 +1879,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) { gBattleCommunication[MOVE_EFFECT_BYTE] = 0x43; b_movescr_stack_push_cursor(); - gBattlescriptCurrInstr = gUnknown_081D9950; + gBattlescriptCurrInstr = BattleScript_ApplySecondaryEffect; gHitMarker |= HITMARKER_IGNORE_SAFEGUARD; effect++; } @@ -1892,7 +1901,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) { gBattleMons[gBankAttacker].status2 |= (gBitTable[gBankTarget] << 0x10); b_movescr_stack_push_cursor(); - gBattlescriptCurrInstr = gUnknown_081D9943; + gBattlescriptCurrInstr = BattleScript_CuteCharmActivates; effect++; } break; @@ -1995,7 +2004,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) effect = CastformDataTypeChange(i); if (effect) { - b_push_move_exec(gUnknown_081D977D); + b_push_move_exec(BattleScript_CastformChange); BATTLE_STRUCT->scriptingActive = i; BATTLE_STRUCT->castformToChangeInto = effect - 1; return effect; @@ -2016,7 +2025,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) gBattleCommunication[MOVE_EFFECT_BYTE] = BATTLE_STRUCT->synchroniseEffect + 0x40; BATTLE_STRUCT->scriptingActive = gBankTarget; b_movescr_stack_push_cursor(); - gBattlescriptCurrInstr = gUnknown_081D9953; + gBattlescriptCurrInstr = BattleScript_SynchronizeActivates; gHitMarker |= HITMARKER_IGNORE_SAFEGUARD; effect++; } @@ -2032,7 +2041,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) gBattleCommunication[MOVE_EFFECT_BYTE] = BATTLE_STRUCT->synchroniseEffect; BATTLE_STRUCT->scriptingActive = gBankAttacker; b_movescr_stack_push_cursor(); - gBattlescriptCurrInstr = gUnknown_081D9953; + gBattlescriptCurrInstr = BattleScript_SynchronizeActivates; gHitMarker |= HITMARKER_IGNORE_SAFEGUARD; effect++; } @@ -2102,7 +2111,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) } if (effect) { - b_push_move_exec(gUnknown_081D9726); + b_push_move_exec(BattleScript_TraceActivates); gStatuses3[i] &= ~(STATUS3_TRACE); BATTLE_STRUCT->scriptingActive = i; @@ -2664,7 +2673,7 @@ _08018680:\n\ _08018690:\n\ movs r0, 0x5\n\ strh r0, [r2]\n\ - ldr r0, _080186AC @ =gUnknown_081D9704\n\ + ldr r0, _080186AC @ =BattleScript_DrizzleActivates\n\ bl b_push_move_exec\n\ ldr r0, _080186B0 @ =0x02000000\n\ ldr r3, _080186B4 @ =0x00016003\n\ @@ -2674,7 +2683,7 @@ _08018690:\n\ bl _08019F22\n\ .align 2, 0\n\ _080186A8: .4byte gBattleWeather\n\ -_080186AC: .4byte gUnknown_081D9704\n\ +_080186AC: .4byte BattleScript_DrizzleActivates\n\ _080186B0: .4byte 0x02000000\n\ _080186B4: .4byte 0x00016003\n\ _080186B8:\n\ @@ -2688,7 +2697,7 @@ _080186B8:\n\ _080186C8:\n\ movs r0, 0x18\n\ strh r0, [r2]\n\ - ldr r0, _080186E4 @ =gUnknown_081D9744\n\ + ldr r0, _080186E4 @ =BattleScript_SandstreamActivates\n\ bl b_push_move_exec\n\ ldr r0, _080186E8 @ =0x02000000\n\ ldr r1, _080186EC @ =0x00016003\n\ @@ -2698,7 +2707,7 @@ _080186C8:\n\ bl _08019F22\n\ .align 2, 0\n\ _080186E0: .4byte gBattleWeather\n\ -_080186E4: .4byte gUnknown_081D9744\n\ +_080186E4: .4byte BattleScript_SandstreamActivates\n\ _080186E8: .4byte 0x02000000\n\ _080186EC: .4byte 0x00016003\n\ _080186F0:\n\ @@ -2712,7 +2721,7 @@ _080186F0:\n\ _08018700:\n\ movs r0, 0x60\n\ strh r0, [r2]\n\ - ldr r0, _0801871C @ =gUnknown_081D97FE\n\ + ldr r0, _0801871C @ =BattleScript_DroughtActivates\n\ bl b_push_move_exec\n\ ldr r0, _08018720 @ =0x02000000\n\ ldr r3, _08018724 @ =0x00016003\n\ @@ -2722,7 +2731,7 @@ _08018700:\n\ bl _08019F22\n\ .align 2, 0\n\ _08018718: .4byte gBattleWeather\n\ -_0801871C: .4byte gUnknown_081D97FE\n\ +_0801871C: .4byte BattleScript_DroughtActivates\n\ _08018720: .4byte 0x02000000\n\ _08018724: .4byte 0x00016003\n\ _08018728:\n\ @@ -2761,7 +2770,7 @@ _0801875C:\n\ bne _08018770\n\ bl _08019F92\n\ _08018770:\n\ - ldr r0, _08018790 @ =gUnknown_081D977D\n\ + ldr r0, _08018790 @ =BattleScript_CastformChange\n\ bl b_push_move_exec\n\ ldr r0, _08018794 @ =0x02000000\n\ ldr r2, _08018798 @ =0x00016003\n\ @@ -2775,7 +2784,7 @@ _08018770:\n\ strb r1, [r0]\n\ bl _08019F76\n\ .align 2, 0\n\ -_08018790: .4byte gUnknown_081D977D\n\ +_08018790: .4byte BattleScript_CastformChange\n\ _08018794: .4byte 0x02000000\n\ _08018798: .4byte 0x00016003\n\ _0801879C: .4byte 0x0001609b\n\ @@ -2911,7 +2920,7 @@ _0801889E:\n\ _080188AA:\n\ mov r2, r8\n\ strb r5, [r2]\n\ - ldr r0, _080188D4 @ =gUnknown_081D9730\n\ + ldr r0, _080188D4 @ =BattleScript_RainDishActivates\n\ bl b_push_move_exec\n\ ldr r1, _080188D8 @ =gBattleMoveDamage\n\ ldrh r0, [r4, 0x2C]\n\ @@ -2928,7 +2937,7 @@ _080188C4:\n\ bl _08019F22\n\ .align 2, 0\n\ _080188D0: .4byte gBattleWeather\n\ -_080188D4: .4byte gUnknown_081D9730\n\ +_080188D4: .4byte BattleScript_RainDishActivates\n\ _080188D8: .4byte gBattleMoveDamage\n\ _080188DC:\n\ adds r0, r2, 0\n\ @@ -3003,7 +3012,7 @@ _08018960:\n\ ldr r1, _080189B0 @ =0x00016003\n\ adds r0, r1\n\ strb r3, [r0]\n\ - ldr r0, _080189B4 @ =gUnknown_081D9758\n\ + ldr r0, _080189B4 @ =BattleScript_ShedSkinActivates\n\ bl b_push_move_exec\n\ str r5, [sp]\n\ movs r0, 0\n\ @@ -3024,7 +3033,7 @@ _080189A4: .4byte gStatusConditionString_IceJpn\n\ _080189A8: .4byte 0x02000000\n\ _080189AC: .4byte gActiveBank\n\ _080189B0: .4byte 0x00016003\n\ -_080189B4: .4byte gUnknown_081D9758\n\ +_080189B4: .4byte BattleScript_ShedSkinActivates\n\ _080189B8:\n\ ldrb r2, [r4, 0x1B]\n\ movs r0, 0x1B\n\ @@ -3054,7 +3063,7 @@ _080189DC:\n\ ldr r1, _08018A0C @ =0x000160a5\n\ adds r0, r7, r1\n\ strb r2, [r0]\n\ - ldr r0, _08018A10 @ =gUnknown_081D9718\n\ + ldr r0, _08018A10 @ =BattleScript_SpeedBoostActivates\n\ bl b_push_move_exec\n\ ldr r2, _08018A14 @ =0x00016003\n\ adds r0, r7, r2\n\ @@ -3065,7 +3074,7 @@ _080189DC:\n\ _08018A04: .4byte gDisableStructs\n\ _08018A08: .4byte 0x000160a4\n\ _08018A0C: .4byte 0x000160a5\n\ -_08018A10: .4byte gUnknown_081D9718\n\ +_08018A10: .4byte BattleScript_SpeedBoostActivates\n\ _08018A14: .4byte 0x00016003\n\ _08018A18:\n\ ldr r2, _08018A3C @ =gDisableStructs\n\ @@ -3095,7 +3104,7 @@ _08018A40:\n\ bl _08019F76\n\ _08018A4C:\n\ movs r4, 0\n\ - ldr r0, _08018ABC @ =gUnknown_081FA724\n\ + ldr r0, _08018ABC @ =gSoundMovesTable\n\ ldrh r2, [r0]\n\ ldr r5, _08018AC0 @ =0x0000ffff\n\ adds r1, r0, 0\n\ @@ -3146,19 +3155,19 @@ _08018A86:\n\ str r1, [r0]\n\ _08018AAC:\n\ ldr r1, _08018AD0 @ =gBattlescriptCurrInstr\n\ - ldr r0, _08018AD4 @ =gUnknown_081D98F3\n\ + ldr r0, _08018AD4 @ =BattleScript_SoundproofProtected\n\ str r0, [r1]\n\ movs r0, 0x1\n\ mov r9, r0\n\ bl _08019F7C\n\ .align 2, 0\n\ -_08018ABC: .4byte gUnknown_081FA724\n\ +_08018ABC: .4byte gSoundMovesTable\n\ _08018AC0: .4byte 0x0000ffff\n\ _08018AC4: .4byte gBattleMons\n\ _08018AC8: .4byte gBankAttacker\n\ _08018ACC: .4byte gHitMarker\n\ _08018AD0: .4byte gBattlescriptCurrInstr\n\ -_08018AD4: .4byte gUnknown_081D98F3\n\ +_08018AD4: .4byte BattleScript_SoundproofProtected\n\ _08018AD8:\n\ cmp r3, 0\n\ bne _08018AE0\n\ @@ -3202,24 +3211,24 @@ _08018B10:\n\ cmp r0, 0\n\ bge _08018B3C\n\ ldr r1, _08018B34 @ =gBattlescriptCurrInstr\n\ - ldr r0, _08018B38 @ =gUnknown_081D9843\n\ + ldr r0, _08018B38 @ =BattleScript_MoveHPDrain\n\ b _08018B40\n\ .align 2, 0\n\ _08018B28: .4byte gBattleMoves\n\ _08018B2C: .4byte gProtectStructs\n\ _08018B30: .4byte gBankAttacker\n\ _08018B34: .4byte gBattlescriptCurrInstr\n\ -_08018B38: .4byte gUnknown_081D9843\n\ +_08018B38: .4byte BattleScript_MoveHPDrain\n\ _08018B3C:\n\ ldr r1, _08018B48 @ =gBattlescriptCurrInstr\n\ - ldr r0, _08018B4C @ =gUnknown_081D9842\n\ + ldr r0, _08018B4C @ =BattleScript_MoveHPDrain_PPLoss\n\ _08018B40:\n\ str r0, [r1]\n\ movs r2, 0x1\n\ b _08018C68\n\ .align 2, 0\n\ _08018B48: .4byte gBattlescriptCurrInstr\n\ -_08018B4C: .4byte gUnknown_081D9842\n\ +_08018B4C: .4byte BattleScript_MoveHPDrain_PPLoss\n\ _08018B50:\n\ cmp r4, 0xB\n\ beq _08018B56\n\ @@ -3245,17 +3254,17 @@ _08018B68:\n\ cmp r0, 0\n\ bge _08018B94\n\ ldr r1, _08018B8C @ =gBattlescriptCurrInstr\n\ - ldr r0, _08018B90 @ =gUnknown_081D9843\n\ + ldr r0, _08018B90 @ =BattleScript_MoveHPDrain\n\ b _08018B98\n\ .align 2, 0\n\ _08018B80: .4byte gBattleMoves\n\ _08018B84: .4byte gProtectStructs\n\ _08018B88: .4byte gBankAttacker\n\ _08018B8C: .4byte gBattlescriptCurrInstr\n\ -_08018B90: .4byte gUnknown_081D9843\n\ +_08018B90: .4byte BattleScript_MoveHPDrain\n\ _08018B94:\n\ ldr r1, _08018BA0 @ =gBattlescriptCurrInstr\n\ - ldr r0, _08018BA4 @ =gUnknown_081D9842\n\ + ldr r0, _08018BA4 @ =BattleScript_MoveHPDrain_PPLoss\n\ _08018B98:\n\ str r0, [r1]\n\ movs r3, 0x1\n\ @@ -3263,7 +3272,7 @@ _08018B98:\n\ b _08018C6A\n\ .align 2, 0\n\ _08018BA0: .4byte gBattlescriptCurrInstr\n\ -_08018BA4: .4byte gUnknown_081D9842\n\ +_08018BA4: .4byte BattleScript_MoveHPDrain_PPLoss\n\ _08018BA8:\n\ cmp r4, 0xA\n\ bne _08018C6A\n\ @@ -3301,7 +3310,7 @@ _08018BA8:\n\ cmp r0, 0\n\ bge _08018C10\n\ ldr r1, _08018C08 @ =gBattlescriptCurrInstr\n\ - ldr r0, _08018C0C @ =gUnknown_081D987C\n\ + ldr r0, _08018C0C @ =BattleScript_FlashFireBoost\n\ b _08018C14\n\ .align 2, 0\n\ _08018BF4: .4byte gBattleMons\n\ @@ -3310,10 +3319,10 @@ _08018BFC: .4byte gBattleCommunication\n\ _08018C00: .4byte gProtectStructs\n\ _08018C04: .4byte gBankAttacker\n\ _08018C08: .4byte gBattlescriptCurrInstr\n\ -_08018C0C: .4byte gUnknown_081D987C\n\ +_08018C0C: .4byte BattleScript_FlashFireBoost\n\ _08018C10:\n\ ldr r1, _08018C28 @ =gBattlescriptCurrInstr\n\ - ldr r0, _08018C2C @ =gUnknown_081D987B\n\ + ldr r0, _08018C2C @ =BattleScript_FlashFireBoost_PPLoss\n\ _08018C14:\n\ str r0, [r1]\n\ adds r0, r5, r2\n\ @@ -3326,7 +3335,7 @@ _08018C14:\n\ b _08018C6A\n\ .align 2, 0\n\ _08018C28: .4byte gBattlescriptCurrInstr\n\ -_08018C2C: .4byte gUnknown_081D987B\n\ +_08018C2C: .4byte BattleScript_FlashFireBoost_PPLoss\n\ _08018C30:\n\ ldr r0, _08018C4C @ =gBattleCommunication\n\ strb r4, [r0, 0x5]\n\ @@ -3340,17 +3349,17 @@ _08018C30:\n\ cmp r0, 0\n\ bge _08018C60\n\ ldr r1, _08018C58 @ =gBattlescriptCurrInstr\n\ - ldr r0, _08018C5C @ =gUnknown_081D987C\n\ + ldr r0, _08018C5C @ =BattleScript_FlashFireBoost\n\ b _08018C64\n\ .align 2, 0\n\ _08018C4C: .4byte gBattleCommunication\n\ _08018C50: .4byte gProtectStructs\n\ _08018C54: .4byte gBankAttacker\n\ _08018C58: .4byte gBattlescriptCurrInstr\n\ -_08018C5C: .4byte gUnknown_081D987C\n\ +_08018C5C: .4byte BattleScript_FlashFireBoost\n\ _08018C60:\n\ ldr r1, _08018CA4 @ =gBattlescriptCurrInstr\n\ - ldr r0, _08018CA8 @ =gUnknown_081D987B\n\ + ldr r0, _08018CA8 @ =BattleScript_FlashFireBoost_PPLoss\n\ _08018C64:\n\ str r0, [r1]\n\ movs r2, 0x2\n\ @@ -3382,24 +3391,24 @@ _08018C74:\n\ cmp r0, 0\n\ bge _08018CBC\n\ ldr r1, _08018CA4 @ =gBattlescriptCurrInstr\n\ - ldr r0, _08018CB8 @ =gUnknown_081D9866\n\ + ldr r0, _08018CB8 @ =BattleScript_MoveHPDrain_FullHP\n\ str r0, [r1]\n\ bl _08019F76\n\ .align 2, 0\n\ _08018CA4: .4byte gBattlescriptCurrInstr\n\ -_08018CA8: .4byte gUnknown_081D987B\n\ +_08018CA8: .4byte BattleScript_FlashFireBoost_PPLoss\n\ _08018CAC: .4byte gBattleMons\n\ _08018CB0: .4byte gProtectStructs\n\ _08018CB4: .4byte gBankAttacker\n\ -_08018CB8: .4byte gUnknown_081D9866\n\ +_08018CB8: .4byte BattleScript_MoveHPDrain_FullHP\n\ _08018CBC:\n\ ldr r1, _08018CC8 @ =gBattlescriptCurrInstr\n\ - ldr r0, _08018CCC @ =gUnknown_081D9865\n\ + ldr r0, _08018CCC @ =BattleScript_MoveHPDrain_FullHP_PPLoss\n\ str r0, [r1]\n\ bl _08019F76\n\ .align 2, 0\n\ _08018CC8: .4byte gBattlescriptCurrInstr\n\ -_08018CCC: .4byte gUnknown_081D9865\n\ +_08018CCC: .4byte BattleScript_MoveHPDrain_FullHP_PPLoss\n\ _08018CD0:\n\ ldr r2, _08018CEC @ =gBattleMoveDamage\n\ ldrh r0, [r1, 0x2C]\n\ @@ -3561,7 +3570,7 @@ _08018E52:\n\ strb r0, [r1, 0x3]\n\ bl b_movescr_stack_push_cursor\n\ ldr r1, _08018E8C @ =gBattlescriptCurrInstr\n\ - ldr r0, _08018E90 @ =gUnknown_081D9921\n\ + ldr r0, _08018E90 @ =BattleScript_ColorChangeActivates\n\ str r0, [r1]\n\ bl _08019F22\n\ .align 2, 0\n\ @@ -3572,7 +3581,7 @@ _08018E80: .4byte gBankTarget\n\ _08018E84: .4byte gBattleMons\n\ _08018E88: .4byte gBattleTextBuff1\n\ _08018E8C: .4byte gBattlescriptCurrInstr\n\ -_08018E90: .4byte gUnknown_081D9921\n\ +_08018E90: .4byte BattleScript_ColorChangeActivates\n\ _08018E94:\n\ ldr r0, _08018F2C @ =gBattleMoveFlags\n\ ldrb r1, [r0]\n\ @@ -3645,7 +3654,7 @@ _08018F0E:\n\ _08018F1C:\n\ bl b_movescr_stack_push_cursor\n\ ldr r1, _08018F4C @ =gBattlescriptCurrInstr\n\ - ldr r0, _08018F50 @ =gUnknown_081D9928\n\ + ldr r0, _08018F50 @ =BattleScript_RoughSkinActivates\n\ str r0, [r1]\n\ bl _08019F22\n\ .align 2, 0\n\ @@ -3658,7 +3667,7 @@ _08018F40: .4byte gBankTarget\n\ _08018F44: .4byte gBattleMoves\n\ _08018F48: .4byte gBattleMoveDamage\n\ _08018F4C: .4byte gBattlescriptCurrInstr\n\ -_08018F50: .4byte gUnknown_081D9928\n\ +_08018F50: .4byte BattleScript_RoughSkinActivates\n\ _08018F54:\n\ ldr r0, _08019020 @ =gBattleMoveFlags\n\ ldrb r1, [r0]\n\ @@ -3750,7 +3759,7 @@ _08019000:\n\ strb r0, [r1, 0x3]\n\ bl b_movescr_stack_push_cursor\n\ ldr r1, _08019040 @ =gBattlescriptCurrInstr\n\ - ldr r0, _08019044 @ =gUnknown_081D9950\n\ + ldr r0, _08019044 @ =BattleScript_ApplySecondaryEffect\n\ str r0, [r1]\n\ ldr r2, _08019048 @ =gHitMarker\n\ ldr r0, [r2]\n\ @@ -3769,7 +3778,7 @@ _08019034: .4byte gBankTarget\n\ _08019038: .4byte gBattleMoves\n\ _0801903C: .4byte gBattleCommunication\n\ _08019040: .4byte gBattlescriptCurrInstr\n\ -_08019044: .4byte gUnknown_081D9950\n\ +_08019044: .4byte BattleScript_ApplySecondaryEffect\n\ _08019048: .4byte gHitMarker\n\ _0801904C:\n\ ldr r0, _080190FC @ =gBattleMoveFlags\n\ @@ -3847,7 +3856,7 @@ _080190DC:\n\ strb r0, [r1, 0x3]\n\ bl b_movescr_stack_push_cursor\n\ ldr r1, _0801911C @ =gBattlescriptCurrInstr\n\ - ldr r0, _08019120 @ =gUnknown_081D9950\n\ + ldr r0, _08019120 @ =BattleScript_ApplySecondaryEffect\n\ str r0, [r1]\n\ ldr r2, _08019124 @ =gHitMarker\n\ ldr r0, [r2]\n\ @@ -3866,7 +3875,7 @@ _08019110: .4byte gBankTarget\n\ _08019114: .4byte gBattleMoves\n\ _08019118: .4byte gBattleCommunication\n\ _0801911C: .4byte gBattlescriptCurrInstr\n\ -_08019120: .4byte gUnknown_081D9950\n\ +_08019120: .4byte BattleScript_ApplySecondaryEffect\n\ _08019124: .4byte gHitMarker\n\ _08019128:\n\ ldr r0, _080191D8 @ =gBattleMoveFlags\n\ @@ -3944,7 +3953,7 @@ _080191B8:\n\ strb r0, [r1, 0x3]\n\ bl b_movescr_stack_push_cursor\n\ ldr r1, _080191F8 @ =gBattlescriptCurrInstr\n\ - ldr r0, _080191FC @ =gUnknown_081D9950\n\ + ldr r0, _080191FC @ =BattleScript_ApplySecondaryEffect\n\ str r0, [r1]\n\ ldr r2, _08019200 @ =gHitMarker\n\ ldr r0, [r2]\n\ @@ -3963,7 +3972,7 @@ _080191EC: .4byte gBankTarget\n\ _080191F0: .4byte gBattleMoves\n\ _080191F4: .4byte gBattleCommunication\n\ _080191F8: .4byte gBattlescriptCurrInstr\n\ -_080191FC: .4byte gUnknown_081D9950\n\ +_080191FC: .4byte BattleScript_ApplySecondaryEffect\n\ _08019200: .4byte gHitMarker\n\ _08019204:\n\ ldr r0, _080192B4 @ =gBattleMoveFlags\n\ @@ -4041,7 +4050,7 @@ _08019294:\n\ strb r0, [r1, 0x3]\n\ bl b_movescr_stack_push_cursor\n\ ldr r1, _080192D4 @ =gBattlescriptCurrInstr\n\ - ldr r0, _080192D8 @ =gUnknown_081D9950\n\ + ldr r0, _080192D8 @ =BattleScript_ApplySecondaryEffect\n\ str r0, [r1]\n\ ldr r2, _080192DC @ =gHitMarker\n\ ldr r0, [r2]\n\ @@ -4060,7 +4069,7 @@ _080192C8: .4byte gSpecialStatuses\n\ _080192CC: .4byte gBankTarget\n\ _080192D0: .4byte gBattleCommunication\n\ _080192D4: .4byte gBattlescriptCurrInstr\n\ -_080192D8: .4byte gUnknown_081D9950\n\ +_080192D8: .4byte BattleScript_ApplySecondaryEffect\n\ _080192DC: .4byte gHitMarker\n\ _080192E0:\n\ ldr r0, _08019420 @ =gBattleMoveFlags\n\ @@ -4212,7 +4221,7 @@ _080193F6:\n\ str r0, [r2]\n\ bl b_movescr_stack_push_cursor\n\ ldr r1, _08019440 @ =gBattlescriptCurrInstr\n\ - ldr r0, _08019444 @ =gUnknown_081D9943\n\ + ldr r0, _08019444 @ =BattleScript_CuteCharmActivates\n\ str r0, [r1]\n\ bl _08019F22\n\ .align 2, 0\n\ @@ -4225,7 +4234,7 @@ _08019434: .4byte gSpecialStatuses\n\ _08019438: .4byte gBankTarget\n\ _0801943C: .4byte gBitTable\n\ _08019440: .4byte gBattlescriptCurrInstr\n\ -_08019444: .4byte gUnknown_081D9943\n\ +_08019444: .4byte BattleScript_CuteCharmActivates\n\ _08019448:\n\ movs r5, 0\n\ mov r10, r5\n\ @@ -4674,7 +4683,7 @@ _08019838:\n\ strb r1, [r0]\n\ bl b_movescr_stack_push_cursor\n\ ldr r1, _08019878 @ =gBattlescriptCurrInstr\n\ - ldr r0, _0801987C @ =gUnknown_081D9953\n\ + ldr r0, _0801987C @ =BattleScript_SynchronizeActivates\n\ str r0, [r1]\n\ ldr r0, [r4]\n\ movs r1, 0x80\n\ @@ -4690,7 +4699,7 @@ _0801986C: .4byte gBattleCommunication\n\ _08019870: .4byte gBankTarget\n\ _08019874: .4byte 0x00016003\n\ _08019878: .4byte gBattlescriptCurrInstr\n\ -_0801987C: .4byte gUnknown_081D9953\n\ +_0801987C: .4byte BattleScript_SynchronizeActivates\n\ _08019880:\n\ mov r1, r8\n\ ldrb r0, [r1]\n\ @@ -4731,7 +4740,7 @@ _080198B4:\n\ strb r1, [r0]\n\ bl b_movescr_stack_push_cursor\n\ ldr r1, _080198F4 @ =gBattlescriptCurrInstr\n\ - ldr r0, _080198F8 @ =gUnknown_081D9953\n\ + ldr r0, _080198F8 @ =BattleScript_SynchronizeActivates\n\ str r0, [r1]\n\ ldr r0, [r4]\n\ movs r1, 0x80\n\ @@ -4747,7 +4756,7 @@ _080198E8: .4byte gBattleCommunication\n\ _080198EC: .4byte gBankAttacker\n\ _080198F0: .4byte 0x00016003\n\ _080198F4: .4byte gBattlescriptCurrInstr\n\ -_080198F8: .4byte gUnknown_081D9953\n\ +_080198F8: .4byte BattleScript_SynchronizeActivates\n\ _080198FC:\n\ movs r4, 0\n\ ldr r0, _08019934 @ =gNoOfAllBanks\n\ @@ -5414,7 +5423,7 @@ _08019E08: .4byte gNoOfAllBanks\n\ _08019E0C: .4byte gBattleMons\n\ _08019E10: .4byte gLastUsedAbility\n\ _08019E14:\n\ - ldr r0, _08019E30 @ =gUnknown_081D977D\n\ + ldr r0, _08019E30 @ =BattleScript_CastformChange\n\ bl b_push_move_exec\n\ ldr r0, _08019E34 @ =0x02000000\n\ ldr r2, _08019E38 @ =0x00016003\n\ @@ -5427,12 +5436,12 @@ _08019E14:\n\ strb r1, [r0]\n\ b _08019F76\n\ .align 2, 0\n\ -_08019E30: .4byte gUnknown_081D977D\n\ +_08019E30: .4byte BattleScript_CastformChange\n\ _08019E34: .4byte 0x02000000\n\ _08019E38: .4byte 0x00016003\n\ _08019E3C: .4byte 0x0001609b\n\ _08019E40:\n\ - ldr r0, _08019E5C @ =gUnknown_081D977D\n\ + ldr r0, _08019E5C @ =BattleScript_CastformChange\n\ bl b_push_move_exec\n\ ldr r0, _08019E60 @ =0x02000000\n\ ldr r5, _08019E64 @ =0x00016003\n\ @@ -5446,7 +5455,7 @@ _08019E40:\n\ strb r1, [r0]\n\ b _08019F92\n\ .align 2, 0\n\ -_08019E5C: .4byte gUnknown_081D977D\n\ +_08019E5C: .4byte BattleScript_CastformChange\n\ _08019E60: .4byte 0x02000000\n\ _08019E64: .4byte 0x00016003\n\ _08019E68: .4byte 0x0001609b\n\ @@ -5464,7 +5473,7 @@ _08019E6C:\n\ _08019E80: .4byte 0xfff7ffff\n\ _08019E84: .4byte gUnknown_081D978C\n\ _08019E88:\n\ - ldr r0, _08019EDC @ =gUnknown_081D9726\n\ + ldr r0, _08019EDC @ =BattleScript_TraceActivates\n\ bl b_push_move_exec\n\ ldr r1, _08019EE0 @ =gStatuses3\n\ ldr r2, [sp, 0x18]\n\ @@ -5505,7 +5514,7 @@ _08019E88:\n\ strb r0, [r1, 0x3]\n\ b _08019F76\n\ .align 2, 0\n\ -_08019EDC: .4byte gUnknown_081D9726\n\ +_08019EDC: .4byte BattleScript_TraceActivates\n\ _08019EE0: .4byte gStatuses3\n\ _08019EE4: .4byte 0xffefffff\n\ _08019EE8: .4byte 0x02000000\n\ @@ -5641,8 +5650,6 @@ enum FLAVOR_SOUR, // 4 }; -s8 sub_8040A7C(u32 pid, u8 flavor); // get poke flavor relation - u8 ItemBattleEffects(u8 caseID, u8 bank, bool8 moveTurn) { int i = 0; @@ -5711,7 +5718,7 @@ u8 ItemBattleEffects(u8 caseID, u8 bank, bool8 moveTurn) BATTLE_STRUCT->scriptingActive = bank; gStringBank = bank; gActiveBank = gBankAttacker = bank; - b_call_bc_move_exec(gUnknown_081D9A5E); + b_call_bc_move_exec(BattleScript_WhiteHerbEnd2); } break; } @@ -5728,7 +5735,7 @@ u8 ItemBattleEffects(u8 caseID, u8 bank, bool8 moveTurn) if (gBattleMons[bank].hp + bankQuality > gBattleMons[bank].maxHP) gBattleMoveDamage = gBattleMons[bank].maxHP - gBattleMons[bank].hp; gBattleMoveDamage *= -1; - b_call_bc_move_exec(gUnknown_081D9A74); + b_call_bc_move_exec(BattleScript_ItemHealHP_RemoveItem); effect = 4; } break; @@ -5763,7 +5770,7 @@ u8 ItemBattleEffects(u8 caseID, u8 bank, bool8 moveTurn) gBattleTextBuff1[2] = move; gBattleTextBuff1[3] = move >> 8; gBattleTextBuff1[4] = 0xFF; - b_call_bc_move_exec(gUnknown_081D9A91); + b_call_bc_move_exec(BattleScript_BerryPPHealEnd2); EmitSetAttributes(0, i + REQUEST_PPMOVE1_BATTLE, 0, 1, &changedPP); MarkBufferBankForExecution(gActiveBank); effect = ITEM_PP_CHANGE; @@ -5784,7 +5791,7 @@ u8 ItemBattleEffects(u8 caseID, u8 bank, bool8 moveTurn) BATTLE_STRUCT->scriptingActive = bank; gStringBank = bank; gActiveBank = gBankAttacker = bank; - b_call_bc_move_exec(gUnknown_081D9A5E); + b_call_bc_move_exec(BattleScript_WhiteHerbEnd2); } break; case HOLD_EFFECT_LEFTOVERS: @@ -5796,7 +5803,7 @@ u8 ItemBattleEffects(u8 caseID, u8 bank, bool8 moveTurn) if (gBattleMons[bank].hp + gBattleMoveDamage > gBattleMons[bank].maxHP) gBattleMoveDamage = gBattleMons[bank].maxHP - gBattleMons[bank].hp; gBattleMoveDamage *= -1; - b_call_bc_move_exec(gUnknown_081D9AA1); + b_call_bc_move_exec(BattleScript_ItemHealHP_End2); effect = ITEM_HP_CHANGE; RecordItemBattle(bank, bankHoldEffect); } @@ -5815,10 +5822,10 @@ u8 ItemBattleEffects(u8 caseID, u8 bank, bool8 moveTurn) if (gBattleMons[bank].hp + gBattleMoveDamage > gBattleMons[bank].maxHP) gBattleMoveDamage = gBattleMons[bank].maxHP - gBattleMons[bank].hp; gBattleMoveDamage *= -1; - if (sub_8040A7C(gBattleMons[bank].personality, FLAVOR_SPICY) < 0) - b_call_bc_move_exec(gUnknown_081D9AD4); + if (GetPokeFlavourRelation(gBattleMons[bank].personality, FLAVOR_SPICY) < 0) + b_call_bc_move_exec(BattleScript_BerryConfuseHealEnd2); else - b_call_bc_move_exec(gUnknown_081D9A74); + b_call_bc_move_exec(BattleScript_ItemHealHP_RemoveItem); effect = ITEM_HP_CHANGE; } break; @@ -5835,10 +5842,10 @@ u8 ItemBattleEffects(u8 caseID, u8 bank, bool8 moveTurn) if (gBattleMons[bank].hp + gBattleMoveDamage > gBattleMons[bank].maxHP) gBattleMoveDamage = gBattleMons[bank].maxHP - gBattleMons[bank].hp; gBattleMoveDamage *= -1; - if (sub_8040A7C(gBattleMons[bank].personality, FLAVOR_DRY) < 0) - b_call_bc_move_exec(gUnknown_081D9AD4); + if (GetPokeFlavourRelation(gBattleMons[bank].personality, FLAVOR_DRY) < 0) + b_call_bc_move_exec(BattleScript_BerryConfuseHealEnd2); else - b_call_bc_move_exec(gUnknown_081D9A74); + b_call_bc_move_exec(BattleScript_ItemHealHP_RemoveItem); effect = ITEM_HP_CHANGE; } break; @@ -5855,10 +5862,10 @@ u8 ItemBattleEffects(u8 caseID, u8 bank, bool8 moveTurn) if (gBattleMons[bank].hp + gBattleMoveDamage > gBattleMons[bank].maxHP) gBattleMoveDamage = gBattleMons[bank].maxHP - gBattleMons[bank].hp; gBattleMoveDamage *= -1; - if (sub_8040A7C(gBattleMons[bank].personality, FLAVOR_SWEET) < 0) - b_call_bc_move_exec(gUnknown_081D9AD4); + if (GetPokeFlavourRelation(gBattleMons[bank].personality, FLAVOR_SWEET) < 0) + b_call_bc_move_exec(BattleScript_BerryConfuseHealEnd2); else - b_call_bc_move_exec(gUnknown_081D9A74); + b_call_bc_move_exec(BattleScript_ItemHealHP_RemoveItem); effect = ITEM_HP_CHANGE; } break; @@ -5875,10 +5882,10 @@ u8 ItemBattleEffects(u8 caseID, u8 bank, bool8 moveTurn) if (gBattleMons[bank].hp + gBattleMoveDamage > gBattleMons[bank].maxHP) gBattleMoveDamage = gBattleMons[bank].maxHP - gBattleMons[bank].hp; gBattleMoveDamage *= -1; - if (sub_8040A7C(gBattleMons[bank].personality, FLAVOR_BITTER) < 0) - b_call_bc_move_exec(gUnknown_081D9AD4); + if (GetPokeFlavourRelation(gBattleMons[bank].personality, FLAVOR_BITTER) < 0) + b_call_bc_move_exec(BattleScript_BerryConfuseHealEnd2); else - b_call_bc_move_exec(gUnknown_081D9A74); + b_call_bc_move_exec(BattleScript_ItemHealHP_RemoveItem); effect = ITEM_HP_CHANGE; } break; @@ -5895,10 +5902,10 @@ u8 ItemBattleEffects(u8 caseID, u8 bank, bool8 moveTurn) if (gBattleMons[bank].hp + gBattleMoveDamage > gBattleMons[bank].maxHP) gBattleMoveDamage = gBattleMons[bank].maxHP - gBattleMons[bank].hp; gBattleMoveDamage *= -1; - if (sub_8040A7C(gBattleMons[bank].personality, FLAVOR_SOUR) < 0) - b_call_bc_move_exec(gUnknown_081D9AD4); + if (GetPokeFlavourRelation(gBattleMons[bank].personality, FLAVOR_SOUR) < 0) + b_call_bc_move_exec(BattleScript_BerryConfuseHealEnd2); else - b_call_bc_move_exec(gUnknown_081D9A74); + b_call_bc_move_exec(BattleScript_ItemHealHP_RemoveItem); effect = ITEM_HP_CHANGE; } break; @@ -5921,7 +5928,7 @@ u8 ItemBattleEffects(u8 caseID, u8 bank, bool8 moveTurn) BATTLE_STRUCT->statChanger = 0x10 + STAT_STAGE_ATK; BATTLE_STRUCT->animArg1 = 0xE + STAT_STAGE_ATK; BATTLE_STRUCT->animArg2 = 0; - b_call_bc_move_exec(gUnknown_081D9AFE); + b_call_bc_move_exec(BattleScript_BerryStatRaiseEnd2); effect = ITEM_STATS_CHANGE; } break; @@ -5937,7 +5944,7 @@ u8 ItemBattleEffects(u8 caseID, u8 bank, bool8 moveTurn) BATTLE_STRUCT->statChanger = 0x10 + STAT_STAGE_DEF; BATTLE_STRUCT->animArg1 = 0xE + STAT_STAGE_DEF; BATTLE_STRUCT->animArg2 = 0; - b_call_bc_move_exec(gUnknown_081D9AFE); + b_call_bc_move_exec(BattleScript_BerryStatRaiseEnd2); effect = ITEM_STATS_CHANGE; } break; @@ -5953,7 +5960,7 @@ u8 ItemBattleEffects(u8 caseID, u8 bank, bool8 moveTurn) BATTLE_STRUCT->statChanger = 0x10 + STAT_STAGE_SPEED; BATTLE_STRUCT->animArg1 = 0xE + STAT_STAGE_SPEED; BATTLE_STRUCT->animArg2 = 0; - b_call_bc_move_exec(gUnknown_081D9AFE); + b_call_bc_move_exec(BattleScript_BerryStatRaiseEnd2); effect = ITEM_STATS_CHANGE; } break; @@ -5969,7 +5976,7 @@ u8 ItemBattleEffects(u8 caseID, u8 bank, bool8 moveTurn) BATTLE_STRUCT->statChanger = 0x10 + STAT_STAGE_SPATK; BATTLE_STRUCT->animArg1 = 0xE + STAT_STAGE_SPATK; BATTLE_STRUCT->animArg2 = 0; - b_call_bc_move_exec(gUnknown_081D9AFE); + b_call_bc_move_exec(BattleScript_BerryStatRaiseEnd2); effect = ITEM_STATS_CHANGE; } break; @@ -5985,7 +5992,7 @@ u8 ItemBattleEffects(u8 caseID, u8 bank, bool8 moveTurn) BATTLE_STRUCT->statChanger = 0x10 + STAT_STAGE_SPDEF; BATTLE_STRUCT->animArg1 = 0xE + STAT_STAGE_SPDEF; BATTLE_STRUCT->animArg2 = 0; - b_call_bc_move_exec(gUnknown_081D9AFE); + b_call_bc_move_exec(BattleScript_BerryStatRaiseEnd2); effect = ITEM_STATS_CHANGE; } break; @@ -5993,7 +6000,7 @@ u8 ItemBattleEffects(u8 caseID, u8 bank, bool8 moveTurn) if (gBattleMons[bank].hp <= gBattleMons[bank].maxHP / bankQuality && !moveTurn && !(gBattleMons[bank].status2 & STATUS2_FOCUS_ENERGY)) { gBattleMons[bank].status2 |= STATUS2_FOCUS_ENERGY; - b_call_bc_move_exec(gUnknown_081D9B19); + b_call_bc_move_exec(BattleScript_BerryFocusEnergyEnd2); effect = ITEM_EFFECT_OTHER; } break; @@ -6030,7 +6037,7 @@ u8 ItemBattleEffects(u8 caseID, u8 bank, bool8 moveTurn) BATTLE_STRUCT->statChanger = 0x21 + i; BATTLE_STRUCT->animArg1 = 0x21 + i + 6; BATTLE_STRUCT->animArg2 = 0; - b_call_bc_move_exec(gUnknown_081D9AFE); + b_call_bc_move_exec(BattleScript_BerryStatRaiseEnd2); effect = ITEM_STATS_CHANGE; } } @@ -6039,7 +6046,7 @@ u8 ItemBattleEffects(u8 caseID, u8 bank, bool8 moveTurn) if (gBattleMons[bank].status1 & STATUS_PARALYSIS) { gBattleMons[bank].status1 &= ~(STATUS_PARALYSIS); - b_call_bc_move_exec(gUnknown_081D99B6); + b_call_bc_move_exec(BattleScript_BerryCurePrlzEnd2); effect = ITEM_STATUS_CHANGE; } break; @@ -6047,7 +6054,7 @@ u8 ItemBattleEffects(u8 caseID, u8 bank, bool8 moveTurn) if (gBattleMons[bank].status1 & STATUS_PSN_ANY) { gBattleMons[bank].status1 &= ~(STATUS_PSN_ANY | STATUS_TOXIC_COUNTER); - b_call_bc_move_exec(gUnknown_081D99CE); + b_call_bc_move_exec(BattleScript_BerryCurePsnEnd2); effect = ITEM_STATUS_CHANGE; } break; @@ -6055,7 +6062,7 @@ u8 ItemBattleEffects(u8 caseID, u8 bank, bool8 moveTurn) if (gBattleMons[bank].status1 & STATUS_BURN) { gBattleMons[bank].status1 &= ~(STATUS_BURN); - b_call_bc_move_exec(gUnknown_081D99E6); + b_call_bc_move_exec(BattleScript_BerryCureBrnEnd2); effect = ITEM_STATUS_CHANGE; } break; @@ -6063,7 +6070,7 @@ u8 ItemBattleEffects(u8 caseID, u8 bank, bool8 moveTurn) if (gBattleMons[bank].status1 & STATUS_FREEZE) { gBattleMons[bank].status1 &= ~(STATUS_FREEZE); - b_call_bc_move_exec(gUnknown_081D99FE); + b_call_bc_move_exec(BattleScript_BerryCureFrzEnd2); effect = ITEM_STATUS_CHANGE; } break; @@ -6072,7 +6079,7 @@ u8 ItemBattleEffects(u8 caseID, u8 bank, bool8 moveTurn) { gBattleMons[bank].status1 &= ~(STATUS_SLEEP); gBattleMons[bank].status2 &= ~(STATUS2_NIGHTMARE); - b_call_bc_move_exec(gUnknown_081D9A16); + b_call_bc_move_exec(BattleScript_BerryCureSlpEnd2); effect = ITEM_STATUS_CHANGE; } break; @@ -6080,7 +6087,7 @@ u8 ItemBattleEffects(u8 caseID, u8 bank, bool8 moveTurn) if (gBattleMons[bank].status2 & STATUS2_CONFUSION) { gBattleMons[bank].status2 &= ~(STATUS2_CONFUSION); - b_call_bc_move_exec(gUnknown_081D9A2E); + b_call_bc_move_exec(BattleScript_BerryCureConfusionEnd2); effect = ITEM_EFFECT_OTHER; } break; @@ -6182,7 +6189,7 @@ u8 ItemBattleEffects(u8 caseID, u8 bank, bool8 moveTurn) { gBattleMons[bank].status1 &= ~(STATUS_PARALYSIS); b_movescr_stack_push_cursor(); - gBattlescriptCurrInstr = gUnknown_081D99BC; + gBattlescriptCurrInstr = BattleScript_BerryCureParRet; effect = ITEM_STATUS_CHANGE; } break; @@ -6191,7 +6198,7 @@ u8 ItemBattleEffects(u8 caseID, u8 bank, bool8 moveTurn) { gBattleMons[bank].status1 &= ~(STATUS_PSN_ANY | STATUS_TOXIC_COUNTER); b_movescr_stack_push_cursor(); - gBattlescriptCurrInstr = gUnknown_081D99D4; + gBattlescriptCurrInstr = BattleScript_BerryCurePsnRet; effect = ITEM_STATUS_CHANGE; } break; @@ -6200,7 +6207,7 @@ u8 ItemBattleEffects(u8 caseID, u8 bank, bool8 moveTurn) { gBattleMons[bank].status1 &= ~(STATUS_BURN); b_movescr_stack_push_cursor(); - gBattlescriptCurrInstr = gUnknown_081D99EC; + gBattlescriptCurrInstr = BattleScript_BerryCureBrnRet; effect = ITEM_STATUS_CHANGE; } break; @@ -6209,7 +6216,7 @@ u8 ItemBattleEffects(u8 caseID, u8 bank, bool8 moveTurn) { gBattleMons[bank].status1 &= ~(STATUS_FREEZE); b_movescr_stack_push_cursor(); - gBattlescriptCurrInstr = gUnknown_081D9A04; + gBattlescriptCurrInstr = BattleScript_BerryCureFrzRet; effect = ITEM_STATUS_CHANGE; } break; @@ -6219,7 +6226,7 @@ u8 ItemBattleEffects(u8 caseID, u8 bank, bool8 moveTurn) gBattleMons[bank].status1 &= ~(STATUS_SLEEP); gBattleMons[bank].status2 &= ~(STATUS2_NIGHTMARE); b_movescr_stack_push_cursor(); - gBattlescriptCurrInstr = gUnknown_081D9A1C; + gBattlescriptCurrInstr = BattleScript_BerryCureSlpRet; effect = ITEM_STATUS_CHANGE; } break; @@ -6228,7 +6235,7 @@ u8 ItemBattleEffects(u8 caseID, u8 bank, bool8 moveTurn) { gBattleMons[bank].status2 &= ~(STATUS2_CONFUSION); b_movescr_stack_push_cursor(); - gBattlescriptCurrInstr = gUnknown_081D9A34; + gBattlescriptCurrInstr = BattleScript_BerryCureConfusionRet; effect = ITEM_EFFECT_OTHER; } break; @@ -6293,7 +6300,7 @@ u8 ItemBattleEffects(u8 caseID, u8 bank, bool8 moveTurn) BATTLE_STRUCT->scriptingActive = bank; gStringBank = bank; b_movescr_stack_push_cursor(); - gBattlescriptCurrInstr = gUnknown_081D9A64; + gBattlescriptCurrInstr = BattleScript_WhiteHerbRet; return effect; // unnecessary return } break; @@ -6343,7 +6350,7 @@ u8 ItemBattleEffects(u8 caseID, u8 bank, bool8 moveTurn) gBattleMoveDamage = -1; gSpecialStatuses[gBankTarget].moveturnLostHP = 0; b_movescr_stack_push_cursor(); - gBattlescriptCurrInstr = gUnknown_081D9AA7; + gBattlescriptCurrInstr = BattleScript_ItemHealHP_Ret; effect++; } break; @@ -6362,7 +6369,7 @@ struct CombinedMove u16 newMove; }; -const struct CombinedMove sCombinedMoves[2] = +static const struct CombinedMove sCombinedMoves[2] = { {MOVE_EMBER, MOVE_GUST, MOVE_HEAT_WAVE}, {0xFFFF, 0xFFFF, 0xFFFF} @@ -6403,16 +6410,13 @@ void unref_sub_801B40C(void) } } -extern const BattleCmdFunc gBattleScriptingCommandsTable[]; -extern u32 gBattleExecBuffer; - void sub_801B594(void) { if (gBattleExecBuffer == 0) gBattleScriptingCommandsTable[*gBattlescriptCurrInstr](); } -u8 sub_801B5C0(u16 move, u8 useMoveTarget) //get move target +u8 GetMoveTarget(u16 move, u8 useMoveTarget) //get move target { u8 targetBank = 0; u8 moveTarget; @@ -6489,28 +6493,16 @@ u8 sub_801B5C0(u16 move, u8 useMoveTarget) //get move target return targetBank; } -extern u8 gUnknown_081D995F[]; //disobedient while asleep -extern u8 gUnknown_081D9977[]; //disobedient no possible moves to use -extern u8 gUnknown_081D996F[]; //disobedient, uses a random move -extern u8 gUnknown_081D9989[]; //disobedient, went to sleep -extern u8 gUnknown_081D99A0[]; //disobedient, hits itself - -extern u8 gUnknown_02024BE5; -extern u8 gCurrMovePos; -extern u16 gRandomMove; -extern s32 gBattleMoveDamage; -extern u16 gDynamicBasePower; - -/* u8 IsPokeDisobedient(void) { u8 obedienceLevel; - register s32 calc asm("r4"); + s32 rnd; + s32 calc; if (gBattleTypeFlags & BATTLE_TYPE_LINK - || GetBankSide(gBankAttacker) == 1 - || !IsOtherTrainer(gBattleMons[gBankAttacker].otId, gBattleMons[gBankAttacker].otName) - || FlagGet(BADGE08_GET)) + || GetBankSide(gBankAttacker) == 1 + || !IsOtherTrainer(gBattleMons[gBankAttacker].otId, gBattleMons[gBankAttacker].otName) + || FlagGet(BADGE08_GET)) return 0; obedienceLevel = 10; @@ -6523,8 +6515,8 @@ u8 IsPokeDisobedient(void) if (gBattleMons[gBankAttacker].level <= obedienceLevel) return 0; - calc = (Random() & 255); - calc = (gBattleMons[gBankAttacker].level + obedienceLevel) * calc / 256; + rnd = (Random() & 255); + calc = (gBattleMons[gBankAttacker].level + obedienceLevel) * rnd >> 8; if (calc < obedienceLevel) return 0; @@ -6536,15 +6528,16 @@ u8 IsPokeDisobedient(void) gBattlescriptCurrInstr = gUnknown_081D995F; return 1; } - calc = (Random() & 255); - calc = (gBattleMons[gBankAttacker].level + obedienceLevel) * calc / 256; + + rnd = (Random() & 255); + calc = (gBattleMons[gBankAttacker].level + obedienceLevel) * rnd >> 8; if (calc < obedienceLevel) { - u8 moveLimitations = CheckMoveLimitations(gBankAttacker, gBitTable[gCurrMovePos], 0xFF); - if (moveLimitations == 0xF) // all moves cannot be used + calc = CheckMoveLimitations(gBankAttacker, gBitTable[gCurrMovePos], 0xFF); + if (calc == 0xF) // all moves cannot be used { gBattleCommunication[MULTISTRING_CHOOSER] = Random() & 3; - gBattlescriptCurrInstr = gUnknown_081D9977; + gBattlescriptCurrInstr = BattleScript_MoveUsedLoafingAround; return 1; } else // use a random move @@ -6552,13 +6545,13 @@ u8 IsPokeDisobedient(void) do { gCurrMovePos = gUnknown_02024BE5 = Random() & 3; - } while (gBitTable[gCurrMovePos] & moveLimitations); + } while (gBitTable[gCurrMovePos] & calc); gRandomMove = gBattleMons[gBankAttacker].moves[gCurrMovePos]; gBattleCommunication[3] = 0; gDynamicBasePower = 0; BATTLE_STRUCT->dynamicMoveType = 0; gBattlescriptCurrInstr = gUnknown_081D996F; - gBankTarget = sub_801B5C0(gRandomMove, 0); + gBankTarget = GetMoveTarget(gRandomMove, 0); gHitMarker |= HITMARKER_x200000; return 2; } @@ -6566,6 +6559,7 @@ u8 IsPokeDisobedient(void) else { obedienceLevel = gBattleMons[gBankAttacker].level - obedienceLevel; + calc = (Random() & 255); if (calc < obedienceLevel && !(gBattleMons[gBankAttacker].status1 & STATUS_ANY) && gBattleMons[gBankAttacker].ability != ABILITY_VITAL_SPIRIT && gBattleMons[gBankAttacker].ability != ABILITY_INSOMNIA) { @@ -6594,9 +6588,8 @@ u8 IsPokeDisobedient(void) else { gBattleCommunication[MULTISTRING_CHOOSER] = Random() & 3; - gBattlescriptCurrInstr = gUnknown_081D9977; + gBattlescriptCurrInstr = BattleScript_MoveUsedLoafingAround; return 1; } } } -*/ diff --git a/src/battle_4.c b/src/battle_4.c index 3912c3426..31d6c76dc 100644 --- a/src/battle_4.c +++ b/src/battle_4.c @@ -150,7 +150,7 @@ bool8 sub_8014AB8(u8 bank); //can run from battle u8 CountAliveMons(u8 caseID); void sub_803E1B0(struct Pokemon*, u16 item, u8 partyID, u8 r3, u8 sp); u8 CanRunFromBattle(void); -u8 sub_801B5C0(u16 move, u8 targetbyte); //get target of move +u8 GetMoveTarget(u16 move, u8 targetbyte); //get target of move void sub_80153D0(u8 atk); //pressure perish song pp decrement u8 CastformDataTypeChange(u8 bank); void b_push_move_exec(u8* bs_ptr); @@ -207,7 +207,7 @@ extern u8 BattleScript_1D6F44[]; //present dmg extern u8 BattleScript_1D83B5[]; //present full hp extern u8 BattleScript_1D839B[]; //present hp heal extern u8 BattleScript_1D6F74[]; -extern u8 gUnknown_081D977D[]; //castform change bs +extern u8 BattleScript_CastformChange[]; extern u8 gUnknown_081D9834[]; extern u8 gUnknown_081D90FC[]; //bs random switchout extern u8 gUnknown_081D95DB[]; //bs payday money give @@ -12762,7 +12762,7 @@ static void atk76_various(void) gBattleCommunication[0] = CanRunFromBattle(); break; case 3: - gBankTarget = sub_801B5C0(gCurrentMove, 0); + gBankTarget = GetMoveTarget(gCurrentMove, 0); break; case 4: if (gHitMarker & HITMARKER_FAINTED(gActiveBank)) @@ -12938,7 +12938,7 @@ static void atk7C_8025508(void) { gHitMarker &= ~(HITMARKER_ATTACKSTRING_PRINTED); gCurrentMove = r7; - gBankTarget = sub_801B5C0(gCurrentMove, 0); + gBankTarget = GetMoveTarget(gCurrentMove, 0); gBattlescriptCurrInstr = gBattleScriptsEffectsTable[gBattleMoves[gCurrentMove].effect]; } else if (r6 != 0 && r5 != 0 && r6 != 0xFFFF && r5 != 0xFFFF) @@ -12948,21 +12948,21 @@ static void atk7C_8025508(void) gCurrentMove = r6; else gCurrentMove = r5; - gBankTarget = sub_801B5C0(gCurrentMove, 0); + gBankTarget = GetMoveTarget(gCurrentMove, 0); gBattlescriptCurrInstr = gBattleScriptsEffectsTable[gBattleMoves[gCurrentMove].effect]; } else if (r6 != 0 && r6 != 0xFFFF) { gHitMarker &= ~(HITMARKER_ATTACKSTRING_PRINTED); gCurrentMove = r6; - gBankTarget = sub_801B5C0(gCurrentMove, 0); + gBankTarget = GetMoveTarget(gCurrentMove, 0); gBattlescriptCurrInstr = gBattleScriptsEffectsTable[gBattleMoves[gCurrentMove].effect]; } else if (r5 != 0 && r5 != 0xFFFF) { gHitMarker &= ~(HITMARKER_ATTACKSTRING_PRINTED); gCurrentMove = r5; - gBankTarget = sub_801B5C0(gCurrentMove, 0); + gBankTarget = GetMoveTarget(gCurrentMove, 0); gBattlescriptCurrInstr = gBattleScriptsEffectsTable[gBattleMoves[gCurrentMove].effect]; } else @@ -13087,7 +13087,7 @@ static void atk83_nop(void) gBattlescriptCurrInstr++; } -bool8 sub_8025A44(u8 bank) //uproar wakeup check +bool8 UproarWakeUpCheck(u8 bank) { int i; for (i = 0; i < gNoOfAllBanks; i++) @@ -13112,7 +13112,7 @@ bool8 sub_8025A44(u8 bank) //uproar wakeup check static void atk84_jump_if_cant_sleep(void) { u8* jump_loc = BSScriptReadPtr(gBattlescriptCurrInstr + 1); - if (sub_8025A44(gBankTarget)) + if (UproarWakeUpCheck(gBankTarget)) gBattlescriptCurrInstr = jump_loc; else if (gBattleMons[gBankTarget].ability == ABILITY_INSOMNIA || gBattleMons[gBankTarget].ability == ABILITY_VITAL_SPIRIT) { @@ -14936,7 +14936,7 @@ static void atk9E_metronome(void) gHitMarker &= ~(HITMARKER_ATTACKSTRING_PRINTED); gBattlescriptCurrInstr = gBattleScriptsEffectsTable[gBattleMoves[gCurrentMove].effect]; - gBankTarget = sub_801B5C0(gCurrentMove, 0); + gBankTarget = GetMoveTarget(gCurrentMove, 0); } #else @@ -15002,7 +15002,7 @@ _080278F8:\n\ str r0, [r1]\n\ ldrh r0, [r4]\n\ movs r1, 0\n\ - bl sub_801B5C0\n\ + bl GetMoveTarget\n\ ldr r1, _0802795C @ =gBankTarget\n\ strb r0, [r1]\n\ pop {r3}\n\ @@ -15570,7 +15570,7 @@ static void atkA9_sleeptalk_choose_move(void) gRandomMove = gBattleMons[gBankAttacker].moves[random_pos]; gCurrMovePos = random_pos; gHitMarker &= ~(HITMARKER_ATTACKSTRING_PRINTED); - gBankTarget = sub_801B5C0(gRandomMove, 0); + gBankTarget = GetMoveTarget(gRandomMove, 0); gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); } } @@ -16684,7 +16684,7 @@ static void atkCC_callterrainattack(void) //nature power { gHitMarker &= ~(HITMARKER_ATTACKSTRING_PRINTED); gCurrentMove = sNaturePowerMoves[gBattleTerrain]; - gBankTarget = sub_801B5C0(gCurrentMove, 0); + gBankTarget = GetMoveTarget(gCurrentMove, 0); b_movescr_stack_push(gBattleScriptsEffectsTable[gBattleMoves[gCurrentMove].effect]); gBattlescriptCurrInstr++; } @@ -17307,7 +17307,7 @@ static void atkDE_asistattackselect(void) { gHitMarker &= ~(HITMARKER_ATTACKSTRING_PRINTED); gRandomMove = BATTLE_STRUCT->assistMove[Random() % chooseable_moves_no]; - gBankTarget = sub_801B5C0(gRandomMove, 0); + gBankTarget = GetMoveTarget(gRandomMove, 0); gBattlescriptCurrInstr += 5; } else @@ -17451,7 +17451,7 @@ _0802AB54:\n\ strh r0, [r4]\n\ ldrh r0, [r4]\n\ movs r1, 0\n\ - bl sub_801B5C0\n\ + bl GetMoveTarget\n\ ldr r1, _0802ABC4 @ =gBankTarget\n\ strb r0, [r1]\n\ ldr r1, _0802ABC8 @ =gBattlescriptCurrInstr\n\ @@ -17655,7 +17655,7 @@ static void atkE7_castform_data_change(void) form = CastformDataTypeChange(BATTLE_STRUCT->scriptingActive); if (form) { - b_push_move_exec(gUnknown_081D977D); + b_push_move_exec(BattleScript_CastformChange); BATTLE_STRUCT->castformToChangeInto = form - 1; } } diff --git a/src/pokemon_3.c b/src/pokemon_3.c index 3d85a1c8f..e449af0a1 100644 --- a/src/pokemon_3.c +++ b/src/pokemon_3.c @@ -1219,7 +1219,7 @@ s8 sub_8040A54(struct Pokemon *mon, u8 a2) return gPokeblockFlavorCompatibilityTable[nature * 5 + a2]; } -s8 sub_8040A7C(u32 personality, u8 a2) +s8 GetPokeFlavourRelation(u32 personality, u8 a2) { u8 nature = GetNatureFromPersonality(personality); return gPokeblockFlavorCompatibilityTable[nature * 5 + a2];