diff --git a/asm/battle_1.s b/asm/battle_1.s index d1a4e6ea0..3507f6a71 100644 --- a/asm/battle_1.s +++ b/asm/battle_1.s @@ -1888,7 +1888,7 @@ sub_8035C4C: @ 8035C4C bne _08035C68 ldr r0, =gText_Draw movs r1, 0x15 - bl battle_show_message_maybe + bl sub_814F9EC b _08035D68 .pool _08035C68: @@ -1964,10 +1964,10 @@ _08035CE2: _08035CFC: ldr r0, =gText_Win movs r1, 0x17 - bl battle_show_message_maybe + bl sub_814F9EC ldr r0, =gText_Loss movs r1, 0x16 - bl battle_show_message_maybe + bl sub_814F9EC b _08035D68 .pool _08035D20: @@ -1985,19 +1985,19 @@ _08035D20: _08035D36: ldr r0, =gText_Win movs r1, 0x16 - bl battle_show_message_maybe + bl sub_814F9EC ldr r0, =gText_Loss movs r1, 0x17 - bl battle_show_message_maybe + bl sub_814F9EC b _08035D68 .pool _08035D58: ldr r0, =gText_Win movs r1, 0x17 - bl battle_show_message_maybe + bl sub_814F9EC ldr r0, =gText_Loss movs r1, 0x16 - bl battle_show_message_maybe + bl sub_814F9EC _08035D68: pop {r0} bx r0 @@ -2068,14 +2068,14 @@ _08035DDC: _08035DE6: adds r0, r1, 0 movs r1, 0x11 - bl battle_show_message_maybe + bl sub_814F9EC ldrb r1, [r4, 0x18] movs r0, 0x4 b _08035E14 _08035DF4: adds r0, r1, 0 movs r1, 0x12 - bl battle_show_message_maybe + bl sub_814F9EC ldrb r1, [r4, 0x18] movs r0, 0x4 str r0, [sp] @@ -2085,7 +2085,7 @@ _08035DF4: _08035E08: adds r0, r1, 0 movs r1, 0x13 - bl battle_show_message_maybe + bl sub_814F9EC ldrb r1, [r4, 0x18] movs r0, 0x8 _08035E14: @@ -2099,7 +2099,7 @@ _08035E1A: _08035E22: adds r0, r1, 0 movs r1, 0x14 - bl battle_show_message_maybe + bl sub_814F9EC ldrb r1, [r4, 0x18] movs r0, 0x8 str r0, [sp] @@ -2139,14 +2139,14 @@ _08035E66: adds r1, r0, r4 adds r0, r1, 0 movs r1, 0xF - bl battle_show_message_maybe + bl sub_814F9EC lsls r0, r6, 3 subs r0, r6 lsls r0, 2 adds r1, r0, r4 adds r0, r1, 0 movs r1, 0x10 - bl battle_show_message_maybe + bl sub_814F9EC movs r4, 0x7 str r4, [sp] adds r0, r7, 0 diff --git a/asm/battle_2.s b/asm/battle_2.s index cc387f1a8..14e332d7c 100644 --- a/asm/battle_2.s +++ b/asm/battle_2.s @@ -1399,7 +1399,7 @@ _080373E0: str r0, [r2] ldr r0, =sub_8039EF0 str r0, [r1] - ldr r0, =sub_8038420 + ldr r0, =BattleMainCB2 bl SetMainCallback2 ldr r2, =gBattleTypeFlags ldr r1, [r2] @@ -1999,7 +1999,7 @@ _080379A0: str r0, [r2] ldr r0, =sub_8039EF0 str r0, [r1] - ldr r0, =sub_8038420 + ldr r0, =BattleMainCB2 bl SetMainCallback2 ldr r2, =gBattleTypeFlags ldr r1, [r2] @@ -3130,7 +3130,7 @@ _080383BC: str r0, [r2] ldr r0, =sub_8039EF0 str r0, [r1] - ldr r0, =sub_8038420 + ldr r0, =BattleMainCB2 bl SetMainCallback2 ldr r3, =gBattleTypeFlags ldr r2, [r3] @@ -3156,8 +3156,8 @@ _080383F8: .pool thumb_func_end sub_8037DF4 - thumb_func_start sub_8038420 -sub_8038420: @ 8038420 + thumb_func_start BattleMainCB2 +BattleMainCB2: @ 8038420 push {lr} sub sp, 0x4 bl AnimateSprites @@ -3203,7 +3203,7 @@ _08038482: pop {r0} bx r0 .pool - thumb_func_end sub_8038420 + thumb_func_end BattleMainCB2 thumb_func_start sub_803849C sub_803849C: @ 803849C @@ -4662,7 +4662,7 @@ _0803912C: bl sub_800ADF8 ldr r0, =gUnknown_0824978D movs r1, 0 - bl battle_show_message_maybe + bl sub_814F9EC b _08039172 .pool _0803914C: @@ -4997,7 +4997,7 @@ _08039470: _0803947E: ldr r0, =gText_RecordBattleToPass movs r1, 0 - bl battle_show_message_maybe + bl sub_814F9EC ldr r1, =gBattleCommunication ldrb r0, [r1] adds r0, 0x1 @@ -5020,11 +5020,11 @@ _080394AC: bl sub_8056A3C ldr r0, =gText_BattleYesNoChoice movs r1, 0xC - bl battle_show_message_maybe + bl sub_814F9EC ldr r4, =gBattleCommunication movs r0, 0x1 strb r0, [r4, 0x1] - bl sub_8056B74 + bl BattleCreateCursorAt b _080396EA .pool _080394D8: @@ -5042,7 +5042,7 @@ _080394EC: movs r0, 0x5 bl PlaySE ldrb r0, [r4, 0x1] - bl sub_8056BAC + bl BattleDestroyCursorAt movs r0, 0 b _0803951E .pool @@ -5059,11 +5059,11 @@ _08039510: movs r0, 0x5 bl PlaySE ldrb r0, [r4, 0x1] - bl sub_8056BAC + bl BattleDestroyCursorAt movs r0, 0x1 _0803951E: strb r0, [r4, 0x1] - bl sub_8056B74 + bl BattleCreateCursorAt b _0803975E _08039526: movs r5, 0x1 @@ -5130,7 +5130,7 @@ _0803958A: bl sub_800ADF8 ldr r0, =gUnknown_0824978D movs r1, 0 - bl battle_show_message_maybe + bl sub_814F9EC _080395B4: ldr r1, =gBattleCommunication ldrb r0, [r1] @@ -5218,7 +5218,7 @@ _08039686: bl StrCpyDecodeToDisplayedStringBattle ldr r0, =gDisplayedStringBattle movs r1, 0 - bl battle_show_message_maybe + bl sub_814F9EC movs r0, 0x80 strb r0, [r4, 0x1] b _080396EA @@ -5256,7 +5256,7 @@ _080396A8: bl sub_800ADF8 ldr r0, =gUnknown_0824978D movs r1, 0 - bl battle_show_message_maybe + bl sub_814F9EC _080396EA: ldrb r0, [r4] adds r0, 0x1 @@ -8280,7 +8280,7 @@ _0803AFFA: movs r0, 0 mov r1, sp movs r2, 0x80 - bl dp01_build_cmdbuf_x30_TODO + bl EmitCmd48 ldrb r0, [r4] bl MarkBufferBankForExecution movs r7, 0 @@ -8332,7 +8332,7 @@ _0803B072: movs r0, 0 mov r1, sp movs r2, 0x80 - bl dp01_build_cmdbuf_x30_TODO + bl EmitCmd48 ldrb r0, [r4] bl MarkBufferBankForExecution ldr r1, =gBattleMainFunc @@ -9237,7 +9237,7 @@ _0803B7EA: strb r1, [r0] ldr r0, =gText_EmptyString3 movs r1, 0 - bl battle_show_message_maybe + bl sub_814F9EC ldr r1, =gBattleMainFunc ldr r0, =sub_803BE74 str r0, [r1] @@ -9546,7 +9546,7 @@ _0803BAE6: strb r1, [r0] mov r0, r9 movs r1, 0 - bl battle_show_message_maybe + bl sub_814F9EC ldr r1, =gBattleMainFunc ldr r0, =sub_803BE74 str r0, [r1] @@ -10140,7 +10140,7 @@ _0803C058: adds r0, r4 ldrb r1, [r0] adds r0, r5, 0 - bl sub_8184FBC + bl RecordedBattle_SetBankAction ldr r1, =gUnknown_0202421C ldrb r0, [r6] adds r1, r0, r1 @@ -11067,12 +11067,12 @@ _0803C91C: lsls r1, r0, 9 adds r1, r5 ldrb r1, [r1] - bl sub_8184FBC + bl RecordedBattle_SetBankAction ldrb r0, [r6] lsls r1, r0, 9 adds r1, r7 ldrb r1, [r1] - bl sub_8184FBC + bl RecordedBattle_SetBankAction _0803C942: ldrb r0, [r6] ldr r4, =gBattleStruct @@ -11602,7 +11602,7 @@ sub_803CDF8: @ 803CDF8 lsls r1, r0, 9 adds r1, r2 ldrb r1, [r1] - bl sub_8184FBC + bl RecordedBattle_SetBankAction ldr r0, =gBattleTypeFlags ldr r0, [r0] movs r1, 0x42 @@ -13335,7 +13335,7 @@ _0803DDD2: ldr r0, =sub_803DE40 str r0, [r1] ldr r1, =gUnknown_030061E8 - ldr r0, =sub_8038420 + ldr r0, =BattleMainCB2 str r0, [r1] b _0803DE2A .pool @@ -13476,7 +13476,7 @@ sub_803DF48: @ 803DF48 push {lr} ldr r0, =gMain ldr r1, [r0, 0x4] - ldr r0, =sub_8038420 + ldr r0, =BattleMainCB2 cmp r1, r0 bne _0803DF5A ldr r1, =gBattleMainFunc diff --git a/asm/battle_4.s b/asm/battle_4.s index 8c3a0ea7e..3a6558a86 100644 --- a/asm/battle_4.s +++ b/asm/battle_4.s @@ -5,3489 +5,6 @@ .text - thumb_func_start atk50_openpartyscreen -atk50_openpartyscreen: @ 804CF88 - push {r4-r7,lr} - mov r7, r9 - mov r6, r8 - push {r6,r7} - sub sp, 0x4 - movs r7, 0 - movs r0, 0 - mov r9, r0 - ldr r6, =gBattlescriptCurrInstr - ldr r2, [r6] - ldrb r1, [r2, 0x2] - ldrb r0, [r2, 0x3] - lsls r0, 8 - orrs r1, r0 - ldrb r0, [r2, 0x4] - lsls r0, 16 - orrs r1, r0 - ldrb r0, [r2, 0x5] - lsls r0, 24 - orrs r1, r0 - mov r8, r1 - ldrb r1, [r2, 0x1] - adds r0, r1, 0 - mov r12, r6 - cmp r0, 0x5 - beq _0804CFBE - b _0804D464 -_0804CFBE: - ldr r0, =gBattleTypeFlags - ldr r0, [r0] - movs r1, 0x41 - ands r1, r0 - cmp r1, 0x1 - beq _0804D0B0 - ldr r1, =gActiveBank - strb r7, [r1] - ldr r0, =gNoOfAllBanks - ldrb r0, [r0] - cmp r7, r0 - bcc _0804CFD8 - b _0804D450 -_0804CFD8: - ldr r7, =gHitMarker - ldr r6, =gBitTable - adds r4, r1, 0 - ldr r2, =gAbsentBankFlags - mov r8, r2 -_0804CFE2: - ldrb r2, [r4] - lsls r0, r2, 2 - adds r0, r6 - ldr r1, [r0] - lsls r1, 28 - ldr r0, [r7] - ands r0, r1 - cmp r0, 0 - beq _0804D088 - adds r0, r2, 0 - movs r1, 0x6 - movs r2, 0x6 - bl sub_80423F4 - lsls r0, 24 - cmp r0, 0 - beq _0804D054 - ldrb r0, [r4] - lsls r0, 2 - adds r0, r6 - ldr r0, [r0] - mov r2, r8 - ldrb r1, [r2] - orrs r0, r1 - strb r0, [r2] - ldrb r0, [r4] - lsls r0, 2 - adds r0, r6 - ldr r1, [r0] - lsls r1, 28 - ldr r0, [r7] - bics r0, r1 - str r0, [r7] - movs r0, 0 - movs r1, 0x2 - movs r2, 0 - bl EmitLinkStandbyMsg - ldrb r0, [r4] - bl MarkBufferBankForExecution - b _0804D098 - .pool -_0804D054: - ldr r5, =gSpecialStatuses - ldrb r0, [r4] - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 2 - adds r1, r5 - ldrb r0, [r1] - lsls r0, 25 - cmp r0, 0 - blt _0804D098 - movs r0, 0x6 - bl sub_804CF10 - ldrb r1, [r4] - lsls r0, r1, 2 - adds r0, r1 - lsls r0, 2 - adds r0, r5 - ldrb r1, [r0] - movs r2, 0x40 - orrs r1, r2 - strb r1, [r0] - b _0804D098 - .pool -_0804D088: - movs r0, 0 - movs r1, 0x2 - movs r2, 0 - bl EmitLinkStandbyMsg - ldrb r0, [r4] - bl MarkBufferBankForExecution -_0804D098: - ldrb r0, [r4] - adds r0, 0x1 - strb r0, [r4] - ldr r1, =gNoOfAllBanks - lsls r0, 24 - lsrs r0, 24 - ldrb r1, [r1] - cmp r0, r1 - bcc _0804CFE2 - b _0804D450 - .pool -_0804D0B0: - ands r0, r1 - cmp r0, 0 - bne _0804D0B8 - b _0804D450 -_0804D0B8: - ldr r0, =gHitMarker - mov r8, r0 - ldr r0, [r0] - lsrs r5, r0, 28 - ldr r6, =gBitTable - ldr r0, [r6] - ands r0, r5 - cmp r0, 0 - beq _0804D170 - ldr r4, =gActiveBank - strb r7, [r4] - movs r0, 0 - movs r1, 0x6 - movs r2, 0x6 - bl sub_80423F4 - lsls r0, 24 - cmp r0, 0 - beq _0804D120 - ldr r2, =gAbsentBankFlags - ldrb r0, [r4] - lsls r0, 2 - adds r0, r6 - ldr r0, [r0] - ldrb r1, [r2] - orrs r0, r1 - strb r0, [r2] - ldrb r0, [r4] - lsls r0, 2 - adds r0, r6 - ldr r1, [r0] - lsls r1, 28 - mov r2, r8 - ldr r0, [r2] - bics r0, r1 - str r0, [r2] - movs r0, 0 - bl dp01_build_cmdbuf_x2A_2A_2A_2A - ldrb r0, [r4] - bl MarkBufferBankForExecution - b _0804D170 - .pool -_0804D120: - ldr r6, =gSpecialStatuses - ldrb r0, [r4] - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 2 - adds r1, r6 - ldrb r0, [r1] - lsls r0, 25 - cmp r0, 0 - blt _0804D15C - ldr r0, =gBattleStruct - ldr r0, [r0] - adds r0, 0x5E - ldrb r0, [r0] - bl sub_804CF10 - ldrb r1, [r4] - lsls r0, r1, 2 - adds r0, r1 - lsls r0, 2 - adds r0, r6 - ldrb r1, [r0] - movs r2, 0x40 - orrs r1, r2 - strb r1, [r0] - b _0804D170 - .pool -_0804D15C: - movs r0, 0 - movs r1, 0x2 - movs r2, 0 - bl EmitLinkStandbyMsg - ldrb r0, [r4] - bl MarkBufferBankForExecution - movs r0, 0x1 - mov r9, r0 -_0804D170: - ldr r6, =gBitTable - ldr r0, [r6, 0x8] - ands r0, r5 - cmp r0, 0 - beq _0804D22E - ldr r0, [r6] - ands r0, r5 - cmp r0, 0 - bne _0804D22E - ldr r4, =gActiveBank - movs r0, 0x2 - strb r0, [r4] - movs r0, 0x2 - movs r1, 0x6 - movs r2, 0x6 - bl sub_80423F4 - lsls r0, 24 - cmp r0, 0 - beq _0804D1D8 - ldr r2, =gAbsentBankFlags - ldrb r0, [r4] - lsls r0, 2 - adds r0, r6 - ldr r0, [r0] - ldrb r1, [r2] - orrs r0, r1 - strb r0, [r2] - ldr r2, =gHitMarker - ldrb r0, [r4] - lsls r0, 2 - adds r0, r6 - ldr r1, [r0] - lsls r1, 28 - ldr r0, [r2] - bics r0, r1 - str r0, [r2] - movs r0, 0 - bl dp01_build_cmdbuf_x2A_2A_2A_2A - ldrb r0, [r4] - bl MarkBufferBankForExecution - b _0804D22E - .pool -_0804D1D8: - ldr r6, =gSpecialStatuses - ldrb r0, [r4] - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 2 - adds r1, r6 - ldrb r0, [r1] - lsls r0, 25 - cmp r0, 0 - blt _0804D214 - ldr r0, =gBattleStruct - ldr r0, [r0] - adds r0, 0x5C - ldrb r0, [r0] - bl sub_804CF10 - ldrb r1, [r4] - lsls r0, r1, 2 - adds r0, r1 - lsls r0, 2 - adds r0, r6 - ldrb r1, [r0] - movs r2, 0x40 - orrs r1, r2 - strb r1, [r0] - b _0804D22E - .pool -_0804D214: - movs r0, 0x1 - mov r1, r9 - ands r0, r1 - cmp r0, 0 - bne _0804D22E - movs r0, 0 - movs r1, 0x2 - movs r2, 0 - bl EmitLinkStandbyMsg - ldrb r0, [r4] - bl MarkBufferBankForExecution -_0804D22E: - ldr r6, =gBitTable - ldr r0, [r6, 0x4] - ands r0, r5 - cmp r0, 0 - beq _0804D2E4 - ldr r4, =gActiveBank - movs r0, 0x1 - strb r0, [r4] - movs r0, 0x1 - movs r1, 0x6 - movs r2, 0x6 - bl sub_80423F4 - lsls r0, 24 - cmp r0, 0 - beq _0804D290 - ldr r2, =gAbsentBankFlags - ldrb r0, [r4] - lsls r0, 2 - adds r0, r6 - ldr r0, [r0] - ldrb r1, [r2] - orrs r0, r1 - strb r0, [r2] - ldr r2, =gHitMarker - ldrb r0, [r4] - lsls r0, 2 - adds r0, r6 - ldr r1, [r0] - lsls r1, 28 - ldr r0, [r2] - bics r0, r1 - str r0, [r2] - movs r0, 0 - bl dp01_build_cmdbuf_x2A_2A_2A_2A - ldrb r0, [r4] - bl MarkBufferBankForExecution - b _0804D2E4 - .pool -_0804D290: - ldr r6, =gSpecialStatuses - ldrb r0, [r4] - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 2 - adds r1, r6 - ldrb r0, [r1] - lsls r0, 25 - cmp r0, 0 - blt _0804D2CC - ldr r0, =gBattleStruct - ldr r0, [r0] - adds r0, 0x5F - ldrb r0, [r0] - bl sub_804CF10 - ldrb r1, [r4] - lsls r0, r1, 2 - adds r0, r1 - lsls r0, 2 - adds r0, r6 - ldrb r1, [r0] - movs r2, 0x40 - orrs r1, r2 - strb r1, [r0] - b _0804D2E4 - .pool -_0804D2CC: - movs r0, 0 - movs r1, 0x2 - movs r2, 0 - bl EmitLinkStandbyMsg - ldrb r0, [r4] - bl MarkBufferBankForExecution - movs r0, 0x2 - mov r2, r9 - orrs r2, r0 - mov r9, r2 -_0804D2E4: - ldr r6, =gBitTable - ldr r0, [r6, 0xC] - ands r0, r5 - cmp r0, 0 - beq _0804D3A2 - ldr r0, [r6, 0x4] - ands r0, r5 - cmp r0, 0 - bne _0804D3A2 - ldr r4, =gActiveBank - movs r0, 0x3 - strb r0, [r4] - movs r0, 0x3 - movs r1, 0x6 - movs r2, 0x6 - bl sub_80423F4 - lsls r0, 24 - cmp r0, 0 - beq _0804D34C - ldr r2, =gAbsentBankFlags - ldrb r0, [r4] - lsls r0, 2 - adds r0, r6 - ldr r0, [r0] - ldrb r1, [r2] - orrs r0, r1 - strb r0, [r2] - ldr r2, =gHitMarker - ldrb r0, [r4] - lsls r0, 2 - adds r0, r6 - ldr r1, [r0] - lsls r1, 28 - ldr r0, [r2] - bics r0, r1 - str r0, [r2] - movs r0, 0 - bl dp01_build_cmdbuf_x2A_2A_2A_2A - ldrb r0, [r4] - bl MarkBufferBankForExecution - b _0804D3A2 - .pool -_0804D34C: - ldr r6, =gSpecialStatuses - ldrb r0, [r4] - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 2 - adds r1, r6 - ldrb r0, [r1] - lsls r0, 25 - cmp r0, 0 - blt _0804D388 - ldr r0, =gBattleStruct - ldr r0, [r0] - adds r0, 0x5D - ldrb r0, [r0] - bl sub_804CF10 - ldrb r1, [r4] - lsls r0, r1, 2 - adds r0, r1 - lsls r0, 2 - adds r0, r6 - ldrb r1, [r0] - movs r2, 0x40 - orrs r1, r2 - strb r1, [r0] - b _0804D3A2 - .pool -_0804D388: - movs r0, 0x2 - mov r1, r9 - ands r1, r0 - cmp r1, 0 - bne _0804D3A2 - movs r0, 0 - movs r1, 0x2 - movs r2, 0 - bl EmitLinkStandbyMsg - ldrb r0, [r4] - bl MarkBufferBankForExecution -_0804D3A2: - ldr r1, =gSpecialStatuses - ldrb r0, [r1] - lsls r0, 25 - cmp r0, 0 - blt _0804D3FA - adds r0, r1, 0 - adds r0, 0x28 - ldrb r0, [r0] - lsls r0, 25 - cmp r0, 0 - blt _0804D3FA - cmp r5, 0 - beq _0804D3FA - ldr r0, =gAbsentBankFlags - ldrb r1, [r0] - ldr r0, =gBitTable - ldr r0, [r0] - ands r1, r0 - cmp r1, 0 - beq _0804D3E4 - ldr r1, =gActiveBank - movs r0, 0x2 - strb r0, [r1] - b _0804D3E8 - .pool -_0804D3E4: - ldr r0, =gActiveBank - strb r1, [r0] -_0804D3E8: - movs r0, 0 - movs r1, 0x2 - movs r2, 0 - bl EmitLinkStandbyMsg - ldr r0, =gActiveBank - ldrb r0, [r0] - bl MarkBufferBankForExecution -_0804D3FA: - ldr r1, =gSpecialStatuses - ldrb r0, [r1, 0x14] - lsls r0, 25 - cmp r0, 0 - blt _0804D450 - adds r0, r1, 0 - adds r0, 0x3C - ldrb r0, [r0] - lsls r0, 25 - cmp r0, 0 - blt _0804D450 - cmp r5, 0 - beq _0804D450 - ldr r0, =gAbsentBankFlags - ldrb r0, [r0] - ldr r1, =gBitTable - ldr r1, [r1, 0x4] - ands r0, r1 - cmp r0, 0 - beq _0804D438 - ldr r1, =gActiveBank - movs r0, 0x3 - b _0804D43C - .pool -_0804D438: - ldr r1, =gActiveBank - movs r0, 0x1 -_0804D43C: - strb r0, [r1] - movs r0, 0 - movs r1, 0x2 - movs r2, 0 - bl EmitLinkStandbyMsg - ldr r0, =gActiveBank - ldrb r0, [r0] - bl MarkBufferBankForExecution -_0804D450: - ldr r1, =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x6 - str r0, [r1] - b _0804D804 - .pool -_0804D464: - cmp r0, 0x6 - beq _0804D46A - b _0804D658 -_0804D46A: - ldr r0, =gBattleTypeFlags - ldr r1, [r0] - movs r0, 0x40 - ands r0, r1 - cmp r0, 0 - beq _0804D478 - b _0804D5F4 -_0804D478: - movs r0, 0x1 - ands r1, r0 - cmp r1, 0 - bne _0804D482 - b _0804D5F4 -_0804D482: - ldr r7, =gHitMarker - ldr r0, [r7] - lsrs r5, r0, 28 - ldr r4, =gBitTable - ldr r0, [r4, 0x8] - ands r0, r5 - cmp r0, 0 - beq _0804D52A - ldr r0, [r4] - ands r0, r5 - cmp r0, 0 - beq _0804D52A - ldr r6, =gActiveBank - movs r0, 0x2 - strb r0, [r6] - ldr r0, =gBattleBufferB - ldrb r1, [r0, 0x1] - movs r0, 0x2 - movs r2, 0x6 - bl sub_80423F4 - lsls r0, 24 - cmp r0, 0 - beq _0804D4F8 - ldr r2, =gAbsentBankFlags - ldrb r0, [r6] - lsls r0, 2 - adds r0, r4 - ldr r0, [r0] - ldrb r1, [r2] - orrs r0, r1 - strb r0, [r2] - ldrb r0, [r6] - lsls r0, 2 - adds r0, r4 - ldr r1, [r0] - lsls r1, 28 - ldr r0, [r7] - bics r0, r1 - str r0, [r7] - movs r0, 0 - bl dp01_build_cmdbuf_x2A_2A_2A_2A - ldrb r0, [r6] - bl MarkBufferBankForExecution - b _0804D52A - .pool -_0804D4F8: - ldr r4, =gSpecialStatuses - ldrb r0, [r6] - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 2 - adds r1, r4 - ldrb r0, [r1] - lsls r0, 25 - cmp r0, 0 - blt _0804D52A - ldr r0, =gBattleStruct - ldr r0, [r0] - adds r0, 0x5C - ldrb r0, [r0] - bl sub_804CF10 - ldrb r1, [r6] - lsls r0, r1, 2 - adds r0, r1 - lsls r0, 2 - adds r0, r4 - ldrb r1, [r0] - movs r2, 0x40 - orrs r1, r2 - strb r1, [r0] -_0804D52A: - ldr r4, =gBitTable - ldr r0, [r4, 0xC] - ands r0, r5 - cmp r0, 0 - beq _0804D5DA - ldr r0, [r4, 0x4] - ands r5, r0 - cmp r5, 0 - beq _0804D5DA - ldr r5, =gActiveBank - movs r0, 0x3 - strb r0, [r5] - ldr r0, =gBattleBufferB - ldr r2, =0x00000201 - adds r0, r2 - ldrb r1, [r0] - movs r0, 0x3 - movs r2, 0x6 - bl sub_80423F4 - lsls r0, 24 - cmp r0, 0 - beq _0804D5A8 - ldr r2, =gAbsentBankFlags - ldrb r0, [r5] - lsls r0, 2 - adds r0, r4 - ldr r0, [r0] - ldrb r1, [r2] - orrs r0, r1 - strb r0, [r2] - ldr r2, =gHitMarker - ldrb r0, [r5] - lsls r0, 2 - adds r0, r4 - ldr r1, [r0] - lsls r1, 28 - ldr r0, [r2] - bics r0, r1 - str r0, [r2] - movs r0, 0 - bl dp01_build_cmdbuf_x2A_2A_2A_2A - ldrb r0, [r5] - bl MarkBufferBankForExecution - b _0804D5DA - .pool -_0804D5A8: - ldr r4, =gSpecialStatuses - ldrb r0, [r5] - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 2 - adds r1, r4 - ldrb r0, [r1] - lsls r0, 25 - cmp r0, 0 - blt _0804D5DA - ldr r0, =gBattleStruct - ldr r0, [r0] - adds r0, 0x5D - ldrb r0, [r0] - bl sub_804CF10 - ldrb r1, [r5] - lsls r0, r1, 2 - adds r0, r1 - lsls r0, 2 - adds r0, r4 - ldrb r1, [r0] - movs r2, 0x40 - orrs r1, r2 - strb r1, [r0] -_0804D5DA: - ldr r1, =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x6 - str r0, [r1] - mov r12, r1 - b _0804D5F8 - .pool -_0804D5F4: - adds r0, r2, 0x6 - str r0, [r6] -_0804D5F8: - ldr r0, =gHitMarker - ldr r0, [r0] - lsrs r5, r0, 28 - ldr r1, =gBank1 - movs r0, 0 - strb r0, [r1] - ldr r4, =gBitTable - ldr r2, [r4] - ands r2, r5 - ldr r6, =gNoOfAllBanks - cmp r2, 0 - bne _0804D634 - adds r7, r6, 0 - ldrb r0, [r6] - cmp r2, r0 - bcs _0804D634 - adds r3, r1, 0 -_0804D61A: - ldrb r0, [r3] - adds r0, 0x1 - strb r0, [r3] - ldrb r2, [r3] - lsls r0, r2, 2 - adds r0, r4 - ldr r0, [r0] - ands r0, r5 - cmp r0, 0 - bne _0804D634 - ldrb r0, [r7] - cmp r2, r0 - bcc _0804D61A -_0804D634: - ldrb r0, [r1] - ldrb r6, [r6] - cmp r0, r6 - beq _0804D63E - b _0804D804 -_0804D63E: - mov r1, r8 - mov r2, r12 - str r1, [r2] - b _0804D804 - .pool -_0804D658: - movs r0, 0x80 - ands r0, r1 - movs r5, 0x1 - cmp r0, 0 - beq _0804D664 - movs r5, 0 -_0804D664: - movs r0, 0x7F - ands r0, r1 - bl GetBattleBank - lsls r0, 24 - lsrs r7, r0, 24 - ldr r1, =gSpecialStatuses - lsls r0, r7, 2 - adds r0, r7 - lsls r0, 2 - adds r0, r1 - ldrb r0, [r0] - lsls r0, 25 - cmp r0, 0 - bge _0804D690 - ldr r0, [r6] - adds r0, 0x6 - str r0, [r6] - b _0804D804 - .pool -_0804D690: - adds r0, r7, 0 - movs r1, 0x6 - movs r2, 0x6 - bl sub_80423F4 - lsls r0, 24 - cmp r0, 0 - beq _0804D6E0 - ldr r2, =gActiveBank - strb r7, [r2] - ldr r3, =gAbsentBankFlags - ldr r4, =gBitTable - ldrb r0, [r2] - lsls r0, 2 - adds r0, r4 - ldr r0, [r0] - ldrb r1, [r3] - orrs r0, r1 - strb r0, [r3] - ldr r3, =gHitMarker - ldrb r0, [r2] - lsls r0, 2 - adds r0, r4 - ldr r1, [r0] - lsls r1, 28 - ldr r0, [r3] - bics r0, r1 - str r0, [r3] - mov r0, r8 - str r0, [r6] - b _0804D804 - .pool -_0804D6E0: - ldr r4, =gActiveBank - strb r7, [r4] - ldrb r0, [r4] - ldr r3, =gBattleStruct - ldr r1, [r3] - adds r1, r0, r1 - adds r1, 0x58 - ldr r2, =gBattlePartyID - lsls r0, 1 - adds r0, r2 - ldrh r0, [r0] - strb r0, [r1] - ldrb r0, [r4] - ldr r1, [r3] - adds r0, r1 - adds r0, 0x5C - movs r1, 0x6 - strb r1, [r0] - ldr r1, [r3] - adds r1, 0x93 - ldr r2, =gBitTable - ldrb r0, [r4] - lsls r0, 2 - adds r0, r2 - ldr r2, [r0] - ldrb r0, [r1] - bics r0, r2 - strb r0, [r1] - ldrb r1, [r4] - movs r0, 0x2 - eors r0, r1 - ldr r3, [r3] - adds r0, r3 - adds r0, 0x5C - ldrb r2, [r0] - ldrb r1, [r4] - lsls r0, r1, 1 - adds r0, r1 - adds r0, 0x60 - adds r3, r0 - str r3, [sp] - movs r0, 0 - adds r1, r5, 0 - movs r3, 0 - bl EmitChoosePokemon - ldrb r0, [r4] - bl MarkBufferBankForExecution - ldr r0, [r6] - adds r0, 0x6 - str r0, [r6] - ldrb r0, [r4] - bl GetBankIdentity - lsls r0, 24 - cmp r0, 0 - bne _0804D760 - ldr r1, =gBattleResults - ldrb r0, [r1, 0x2] - cmp r0, 0xFE - bhi _0804D760 - adds r0, 0x1 - strb r0, [r1, 0x2] -_0804D760: - ldr r0, =gBattleTypeFlags - ldr r0, [r0] - movs r1, 0x40 - ands r0, r1 - cmp r0, 0 - beq _0804D7C4 - ldr r1, =gActiveBank - movs r0, 0 - strb r0, [r1] - ldr r0, =gNoOfAllBanks - ldrb r0, [r0] - cmp r0, 0 - beq _0804D804 - adds r4, r1, 0 -_0804D77C: - ldrb r0, [r4] - cmp r0, r7 - beq _0804D792 - movs r0, 0 - movs r1, 0x2 - movs r2, 0 - bl EmitLinkStandbyMsg - ldrb r0, [r4] - bl MarkBufferBankForExecution -_0804D792: - ldrb r0, [r4] - adds r0, 0x1 - strb r0, [r4] - ldr r1, =gNoOfAllBanks - lsls r0, 24 - lsrs r0, 24 - ldrb r1, [r1] - cmp r0, r1 - bcc _0804D77C - b _0804D804 - .pool -_0804D7C4: - adds r0, r7, 0 - bl GetBankIdentity - movs r1, 0x1 - eors r0, r1 - lsls r0, 24 - lsrs r0, 24 - bl GetBankByPlayerAI - ldr r4, =gActiveBank - strb r0, [r4] - ldr r0, =gAbsentBankFlags - ldrb r1, [r0] - ldr r2, =gBitTable - ldrb r3, [r4] - lsls r0, r3, 2 - adds r0, r2 - ldr r0, [r0] - ands r1, r0 - cmp r1, 0 - beq _0804D7F4 - movs r0, 0x2 - eors r3, r0 - strb r3, [r4] -_0804D7F4: - movs r0, 0 - movs r1, 0x2 - movs r2, 0 - bl EmitLinkStandbyMsg - ldrb r0, [r4] - bl MarkBufferBankForExecution -_0804D804: - add sp, 0x4 - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end atk50_openpartyscreen - - thumb_func_start atk51_switch_handle_order -atk51_switch_handle_order: @ 804D820 - push {r4-r7,lr} - ldr r0, =gBattleExecBuffer - ldr r0, [r0] - cmp r0, 0 - beq _0804D82C - b _0804DA8A -_0804D82C: - ldr r4, =gBattlescriptCurrInstr - ldr r0, [r4] - ldrb r0, [r0, 0x1] - bl GetBattleBank - ldr r5, =gActiveBank - strb r0, [r5] - ldr r0, [r4] - ldrb r0, [r0, 0x2] - cmp r0, 0x1 - beq _0804D8CC - cmp r0, 0x1 - bgt _0804D858 - cmp r0, 0 - beq _0804D862 - b _0804DA82 - .pool -_0804D858: - cmp r0, 0x2 - beq _0804D8E8 - cmp r0, 0x3 - beq _0804D922 - b _0804DA82 -_0804D862: - movs r6, 0 - ldr r0, =gNoOfAllBanks - ldrb r0, [r0] - cmp r6, r0 - blt _0804D86E - b _0804DA82 -_0804D86E: - ldr r7, =gBattleBufferB -_0804D870: - ldrb r0, [r7] - cmp r0, 0x22 - bne _0804D8AA - ldr r5, =gBattleStruct - ldr r0, [r5] - adds r0, r6, r0 - adds r0, 0x5C - ldrb r1, [r7, 0x1] - strb r1, [r0] - ldr r0, [r5] - adds r0, 0x93 - ldrb r1, [r0] - ldr r2, =gBitTable - lsls r0, r6, 2 - adds r0, r2 - ldr r4, [r0] - ands r1, r4 - cmp r1, 0 - bne _0804D8AA - lsls r0, r6, 24 - lsrs r0, 24 - ldrb r1, [r7, 0x1] - bl sub_8184FBC - ldr r1, [r5] - adds r1, 0x93 - ldrb r0, [r1] - orrs r4, r0 - strb r4, [r1] -_0804D8AA: - movs r0, 0x80 - lsls r0, 2 - adds r7, r0 - adds r6, 0x1 - ldr r0, =gNoOfAllBanks - ldrb r0, [r0] - cmp r6, r0 - blt _0804D870 - b _0804DA82 - .pool -_0804D8CC: - ldr r0, =gBattleTypeFlags - ldr r0, [r0] - movs r1, 0x40 - ands r0, r1 - cmp r0, 0 - beq _0804D8DA - b _0804DA82 -_0804D8DA: - ldrb r0, [r5] - bl sub_803BDA0 - b _0804DA82 - .pool -_0804D8E8: - ldr r4, =gBattleStruct - ldr r0, [r4] - adds r0, 0x93 - ldrb r1, [r0] - ldr r6, =gBitTable - ldrb r2, [r5] - lsls r0, r2, 2 - adds r0, r6 - ldr r0, [r0] - ands r1, r0 - cmp r1, 0 - bne _0804D922 - ldr r0, =gBattleBufferB - lsls r1, r2, 9 - adds r0, 0x1 - adds r1, r0 - ldrb r1, [r1] - adds r0, r2, 0 - bl sub_8184FBC - ldr r2, [r4] - adds r2, 0x93 - ldrb r0, [r5] - lsls r0, 2 - adds r0, r6 - ldr r0, [r0] - ldrb r1, [r2] - orrs r0, r1 - strb r0, [r2] -_0804D922: - ldr r1, =gBattleCommunication - ldr r6, =gBattleBufferB - ldr r7, =gActiveBank - ldrb r0, [r7] - lsls r0, 9 - adds r2, r6, 0x1 - adds r0, r2 - ldrb r0, [r0] - strb r0, [r1] - ldrb r0, [r7] - ldr r1, =gBattleStruct - mov r12, r1 - ldr r1, [r1] - adds r1, r0, r1 - adds r1, 0x5C - lsls r0, 9 - adds r0, r2 - ldrb r0, [r0] - strb r0, [r1] - ldr r0, =gBattleTypeFlags - ldr r1, [r0] - movs r0, 0x42 - ands r0, r1 - cmp r0, 0x42 - bne _0804DA14 - ldrb r0, [r7] - mov r3, r12 - ldr r2, [r3] - lsls r1, r0, 1 - adds r1, r0 - adds r1, r2 - adds r1, 0x60 - ldrb r2, [r1] - movs r0, 0xF - ands r0, r2 - strb r0, [r1] - ldrb r0, [r7] - ldr r2, [r3] - lsls r1, r0, 1 - adds r1, r0 - adds r1, r2 - adds r1, 0x60 - lsls r0, 9 - adds r5, r6, 0x2 - adds r0, r5 - ldrb r2, [r0] - movs r3, 0xF0 - adds r0, r3, 0 - ands r0, r2 - ldrb r2, [r1] - orrs r0, r2 - strb r0, [r1] - ldrb r1, [r7] - mov r0, r12 - ldr r2, [r0] - lsls r0, r1, 1 - adds r0, r1 - adds r0, r2 - adds r0, 0x61 - lsls r1, 9 - adds r6, 0x3 - adds r1, r6 - ldrb r1, [r1] - strb r1, [r0] - ldrb r0, [r7] - movs r4, 0x2 - eors r0, r4 - mov r1, r12 - ldr r2, [r1] - lsls r1, r0, 1 - adds r1, r0 - adds r1, r2 - adds r1, 0x60 - ldrb r2, [r1] - adds r0, r3, 0 - ands r0, r2 - strb r0, [r1] - ldrb r0, [r7] - eors r0, r4 - mov r1, r12 - ldr r2, [r1] - lsls r1, r0, 1 - adds r1, r0 - adds r1, r2 - adds r1, 0x60 - ldrb r0, [r7] - lsls r0, 9 - adds r0, r5 - ldrb r0, [r0] - ands r3, r0 - lsrs r3, 4 - ldrb r0, [r1] - orrs r3, r0 - strb r3, [r1] - ldrb r0, [r7] - eors r4, r0 - mov r2, r12 - ldr r0, [r2] - lsls r1, r4, 1 - adds r1, r4 - adds r1, r0 - adds r1, 0x62 - ldrb r0, [r7] - lsls r0, 9 - adds r0, r6 - ldrb r0, [r0] - strb r0, [r1] - b _0804DA36 - .pool -_0804DA14: - movs r0, 0x80 - lsls r0, 15 - ands r1, r0 - cmp r1, 0 - beq _0804DA30 - ldrb r0, [r7] - mov r3, r12 - ldr r1, [r3] - adds r1, r0, r1 - adds r1, 0x5C - ldrb r1, [r1] - bl sub_80571DC - b _0804DA36 -_0804DA30: - ldrb r0, [r7] - bl sub_803BDA0 -_0804DA36: - ldr r1, =gBattleTextBuff1 - movs r5, 0xFD - strb r5, [r1] - movs r0, 0x6 - strb r0, [r1, 0x1] - ldr r4, =gBattleMons - ldr r3, =gBankAttacker - ldrb r0, [r3] - movs r2, 0x58 - muls r0, r2 - adds r0, r4 - ldrh r0, [r0] - strb r0, [r1, 0x2] - ldrb r0, [r3] - muls r0, r2 - adds r0, r4 - ldrh r0, [r0] - lsrs r0, 8 - strb r0, [r1, 0x3] - movs r0, 0xFF - strb r0, [r1, 0x4] - ldr r2, =gBattleTextBuff2 - strb r5, [r2] - movs r0, 0x7 - strb r0, [r2, 0x1] - ldr r3, =gActiveBank - ldrb r0, [r3] - strb r0, [r2, 0x2] - ldr r1, =gBattleBufferB - ldrb r0, [r3] - lsls r0, 9 - adds r1, 0x1 - adds r0, r1 - ldrb r0, [r0] - strb r0, [r2, 0x3] - movs r0, 0x1 - negs r0, r0 - strb r0, [r2, 0x4] -_0804DA82: - ldr r1, =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x3 - str r0, [r1] -_0804DA8A: - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end atk51_switch_handle_order - - thumb_func_start atk52_switch_in_effects -atk52_switch_in_effects: @ 804DAAC - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x4 - ldr r0, =gBattlescriptCurrInstr - mov r9, r0 - ldr r0, [r0] - ldrb r0, [r0, 0x1] - bl GetBattleBank - ldr r4, =gActiveBank - strb r0, [r4] - ldrb r0, [r4] - bl sub_803FA70 - ldr r1, =gHitMarker - mov r8, r1 - ldr r1, =gBitTable - ldrb r0, [r4] - lsls r0, 2 - adds r0, r1 - ldr r1, [r0] - lsls r1, 28 - mov r2, r8 - ldr r0, [r2] - bics r0, r1 - str r0, [r2] - ldr r2, =gSpecialStatuses - ldrb r0, [r4] - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 2 - adds r1, r2 - ldrb r2, [r1] - movs r0, 0x41 - negs r0, r0 - ands r0, r2 - strb r0, [r1] - ldrb r0, [r4] - bl GetBankSide - ldr r5, =gSideAffecting - lsls r0, 24 - lsrs r0, 23 - adds r0, r5 - ldrh r1, [r0] - movs r7, 0x80 - lsls r7, 2 - mov r10, r7 - mov r0, r10 - ands r0, r1 - cmp r0, 0 - beq _0804DB1C - b _0804DC30 -_0804DB1C: - ldrb r0, [r4] - bl GetBankSide - lsls r0, 24 - lsrs r0, 23 - adds r0, r5 - ldrh r1, [r0] - movs r0, 0x10 - ands r0, r1 - cmp r0, 0 - bne _0804DB34 - b _0804DC30 -_0804DB34: - ldr r7, =gBattleMons - ldrb r2, [r4] - movs r6, 0x58 - adds r0, r2, 0 - muls r0, r6 - adds r1, r0, r7 - adds r0, r1, 0 - adds r0, 0x21 - ldrb r0, [r0] - cmp r0, 0x2 - beq _0804DC30 - adds r0, r1, 0 - adds r0, 0x22 - ldrb r0, [r0] - cmp r0, 0x2 - beq _0804DC30 - adds r0, r1, 0 - adds r0, 0x20 - ldrb r0, [r0] - cmp r0, 0x1A - beq _0804DC30 - adds r0, r2, 0 - bl GetBankSide - lsls r0, 24 - lsrs r0, 23 - adds r0, r5 - ldrh r2, [r0] - mov r1, r10 - orrs r1, r2 - strh r1, [r0] - ldrb r0, [r4] - adds r2, r0, 0 - muls r2, r6 - adds r0, r7, 0 - adds r0, 0x50 - adds r2, r0 - ldr r0, [r2] - ldr r1, =0xfdffffff - ands r0, r1 - str r0, [r2] - mov r1, r8 - ldr r0, [r1] - movs r2, 0x41 - negs r2, r2 - ands r0, r2 - str r0, [r1] - ldrb r0, [r4] - bl GetBankSide - ldr r2, =gSideTimers - lsls r0, 24 - lsrs r0, 24 - lsls r1, r0, 1 - adds r1, r0 - lsls r1, 2 - adds r1, r2 - ldrb r0, [r1, 0xA] - movs r1, 0x5 - subs r1, r0 - lsls r1, 25 - lsrs r1, 24 - ldr r5, =gBattleMoveDamage - ldrb r0, [r4] - muls r0, r6 - adds r0, r7 - ldrh r0, [r0, 0x2C] - bl __divsi3 - str r0, [r5] - cmp r0, 0 - bne _0804DBC8 - movs r0, 0x1 - str r0, [r5] -_0804DBC8: - ldr r0, =gBattleScripting - ldrb r1, [r4] - strb r1, [r0, 0x17] - bl BattleScriptPushCursor - mov r7, r9 - ldr r0, [r7] - ldrb r0, [r0, 0x1] - cmp r0, 0 - bne _0804DC14 - ldr r0, =gUnknown_082DAE90 - str r0, [r7] - b _0804DD8E - .pool -_0804DC14: - cmp r0, 0x1 - bne _0804DC24 - ldr r0, =gUnknown_082DAE59 - mov r1, r9 - str r0, [r1] - b _0804DD8E - .pool -_0804DC24: - ldr r0, =gUnknown_082DAEC7 - mov r2, r9 - str r0, [r2] - b _0804DD8E - .pool -_0804DC30: - ldr r2, =gBattleMons - ldr r1, =gActiveBank - ldrb r3, [r1] - movs r0, 0x58 - muls r0, r3 - adds r0, r2 - adds r0, 0x20 - ldrb r0, [r0] - adds r5, r1, 0 - ldr r4, =gDisableStructs - cmp r0, 0x36 - bne _0804DC5E - lsls r0, r3, 3 - subs r0, r3 - lsls r0, 2 - adds r2, r0, r4 - ldrb r1, [r2, 0x18] - lsls r0, r1, 30 - cmp r0, 0 - blt _0804DC5E - movs r0, 0x1 - orrs r0, r1 - strb r0, [r2, 0x18] -_0804DC5E: - ldrb r0, [r5] - lsls r1, r0, 3 - subs r1, r0 - lsls r1, 2 - adds r1, r4 - ldrb r2, [r1, 0x18] - movs r0, 0x3 - negs r0, r0 - ands r0, r2 - strb r0, [r1, 0x18] - ldrb r1, [r5] - movs r0, 0 - str r0, [sp] - movs r2, 0 - movs r3, 0 - bl AbilityBattleEffects - lsls r0, 24 - cmp r0, 0 - beq _0804DC88 - b _0804DD8E -_0804DC88: - ldrb r1, [r5] - movs r0, 0 - movs r2, 0 - bl ItemBattleEffects - lsls r0, 24 - cmp r0, 0 - bne _0804DD8E - ldrb r0, [r5] - bl GetBankSide - ldr r1, =gSideAffecting - lsls r0, 24 - lsrs r0, 23 - adds r0, r1 - ldrh r2, [r0] - ldr r1, =0x0000fdff - ands r1, r2 - strh r1, [r0] - movs r4, 0 - ldr r0, =gNoOfAllBanks - ldrb r7, [r0] - cmp r4, r7 - bge _0804DCD8 - ldr r6, =gTurnOrder - adds r1, r5, 0 - ldr r5, =gUnknown_0202407A - movs r3, 0xC - adds r2, r0, 0 -_0804DCC2: - adds r0, r4, r6 - ldrb r0, [r0] - ldrb r7, [r1] - cmp r0, r7 - bne _0804DCD0 - adds r0, r4, r5 - strb r3, [r0] -_0804DCD0: - adds r4, 0x1 - ldrb r0, [r2] - cmp r4, r0 - blt _0804DCC2 -_0804DCD8: - movs r4, 0 - ldr r0, =gNoOfAllBanks - ldrb r0, [r0] - cmp r4, r0 - bge _0804DD0C - ldr r6, =gBattleStruct - ldr r5, =gBattleMons -_0804DCE6: - lsls r0, r4, 24 - lsrs r0, 24 - bl GetBankSide - lsls r0, 24 - lsrs r0, 23 - adds r0, 0xA8 - ldr r1, [r6] - adds r1, r0 - movs r0, 0x58 - muls r0, r4 - adds r0, r5 - ldrh r0, [r0, 0x28] - strh r0, [r1] - adds r4, 0x1 - ldr r0, =gNoOfAllBanks - ldrb r0, [r0] - cmp r4, r0 - blt _0804DCE6 -_0804DD0C: - ldr r0, =gBattlescriptCurrInstr - ldr r1, [r0] - ldrb r1, [r1, 0x1] - adds r5, r0, 0 - cmp r1, 0x5 - bne _0804DD88 - ldr r0, =gHitMarker - ldr r0, [r0] - lsrs r4, r0, 28 - ldr r1, =gBank1 - ldrb r0, [r1] - adds r0, 0x1 - strb r0, [r1] - ldr r2, =gBitTable - b _0804DD6E - .pool -_0804DD60: - ldr r0, =gNoOfAllBanks - ldrb r3, [r1] - ldrb r0, [r0] - cmp r3, r0 - bcs _0804DD88 - adds r0, r3, 0x1 - strb r0, [r1] -_0804DD6E: - ldrb r0, [r1] - lsls r0, 2 - adds r0, r2 - ldr r3, [r0] - adds r0, r4, 0 - ands r0, r3 - cmp r0, 0 - beq _0804DD60 - ldr r0, =gAbsentBankFlags - ldrb r0, [r0] - ands r0, r3 - cmp r0, 0 - bne _0804DD60 -_0804DD88: - ldr r0, [r5] - adds r0, 0x2 - str r0, [r5] -_0804DD8E: - add sp, 0x4 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end atk52_switch_in_effects - - thumb_func_start atk53_trainer_slide -atk53_trainer_slide: @ 804DDA8 - push {r4,r5,lr} - ldr r5, =gBattlescriptCurrInstr - ldr r0, [r5] - ldrb r0, [r0, 0x1] - bl GetBankByPlayerAI - ldr r4, =gActiveBank - strb r0, [r4] - movs r0, 0 - bl dp01_build_cmdbuf_x08_8_8_8 - ldrb r0, [r4] - bl MarkBufferBankForExecution - ldr r0, [r5] - adds r0, 0x2 - str r0, [r5] - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end atk53_trainer_slide - - thumb_func_start atk54_effectiveness_sound -atk54_effectiveness_sound: @ 804DDD8 - push {r4,r5,lr} - ldr r5, =gActiveBank - ldr r0, =gBankAttacker - ldrb r0, [r0] - strb r0, [r5] - ldr r4, =gBattlescriptCurrInstr - ldr r0, [r4] - ldrb r1, [r0, 0x1] - ldrb r0, [r0, 0x2] - lsls r0, 8 - orrs r1, r0 - movs r0, 0 - bl EmitEffectivenessSound - ldrb r0, [r5] - bl MarkBufferBankForExecution - ldr r0, [r4] - adds r0, 0x3 - str r0, [r4] - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end atk54_effectiveness_sound - - thumb_func_start atk55_play_sound -atk55_play_sound: @ 804DE14 - push {r4,r5,lr} - ldr r5, =gActiveBank - ldr r0, =gBankAttacker - ldrb r0, [r0] - strb r0, [r5] - ldr r4, =gBattlescriptCurrInstr - ldr r0, [r4] - ldrb r1, [r0, 0x1] - ldrb r0, [r0, 0x2] - lsls r0, 8 - orrs r1, r0 - movs r0, 0 - movs r2, 0 - bl sub_8034300 - ldrb r0, [r5] - bl MarkBufferBankForExecution - ldr r0, [r4] - adds r0, 0x3 - str r0, [r4] - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end atk55_play_sound - - thumb_func_start atk56_fainting_cry -atk56_fainting_cry: @ 804DE50 - push {r4,r5,lr} - ldr r5, =gBattlescriptCurrInstr - ldr r0, [r5] - ldrb r0, [r0, 0x1] - bl GetBattleBank - ldr r4, =gActiveBank - strb r0, [r4] - movs r0, 0 - bl dp01_build_cmdbuf_x2D_2D_2D_2D - ldrb r0, [r4] - bl MarkBufferBankForExecution - ldr r0, [r5] - adds r0, 0x2 - str r0, [r5] - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end atk56_fainting_cry - - thumb_func_start atk57 -atk57: @ 804DE80 - push {r4,lr} - movs r0, 0 - bl GetBankByPlayerAI - ldr r4, =gActiveBank - strb r0, [r4] - ldr r0, =gBattleOutcome - ldrb r1, [r0] - movs r0, 0 - bl dp01_build_cmdbuf_x37_a - ldrb r0, [r4] - bl MarkBufferBankForExecution - ldr r1, =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x1 - str r0, [r1] - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end atk57 - - thumb_func_start atk58_return_to_ball -atk58_return_to_ball: @ 804DEB8 - push {r4,r5,lr} - ldr r5, =gBattlescriptCurrInstr - ldr r0, [r5] - ldrb r0, [r0, 0x1] - bl GetBattleBank - ldr r4, =gActiveBank - strb r0, [r4] - movs r0, 0 - movs r1, 0x1 - bl EmitReturnPokeToBall - ldrb r0, [r4] - bl MarkBufferBankForExecution - ldr r0, [r5] - adds r0, 0x2 - str r0, [r5] - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end atk58_return_to_ball - - thumb_func_start atk59_learnmove_inbattle -atk59_learnmove_inbattle: @ 804DEEC - push {r4-r7,lr} - ldr r0, =gBattlescriptCurrInstr - ldr r2, [r0] - ldrb r6, [r2, 0x1] - ldrb r0, [r2, 0x2] - lsls r0, 8 - orrs r6, r0 - ldrb r0, [r2, 0x3] - lsls r0, 16 - orrs r6, r0 - ldrb r0, [r2, 0x4] - lsls r0, 24 - orrs r6, r0 - ldrb r4, [r2, 0x5] - ldrb r0, [r2, 0x6] - lsls r0, 8 - orrs r4, r0 - ldrb r0, [r2, 0x7] - lsls r0, 16 - orrs r4, r0 - ldrb r0, [r2, 0x8] - lsls r0, 24 - orrs r4, r0 - ldr r0, =gBattleStruct - ldr r0, [r0] - ldrb r1, [r0, 0x10] - movs r0, 0x64 - muls r0, r1 - ldr r1, =gPlayerParty - adds r0, r1 - ldrb r1, [r2, 0x9] - bl MonTryLearningNewMove - lsls r0, 16 - lsrs r5, r0, 16 - ldr r0, =0x0000fffe - cmp r5, r0 - bne _0804DF56 - adds r7, r5, 0 -_0804DF3A: - ldr r0, =gBattleStruct - ldr r0, [r0] - ldrb r1, [r0, 0x10] - movs r0, 0x64 - muls r0, r1 - ldr r1, =gPlayerParty - adds r0, r1 - movs r1, 0 - bl MonTryLearningNewMove - lsls r0, 16 - lsrs r5, r0, 16 - cmp r5, r7 - beq _0804DF3A -_0804DF56: - cmp r5, 0 - bne _0804DF70 - ldr r0, =gBattlescriptCurrInstr - str r4, [r0] - b _0804E018 - .pool -_0804DF70: - ldr r0, =0x0000ffff - cmp r5, r0 - bne _0804DF88 - ldr r1, =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0xA - str r0, [r1] - b _0804E018 - .pool -_0804DF88: - movs r0, 0 - bl GetBankByPlayerAI - ldr r1, =gActiveBank - strb r0, [r1] - ldr r2, =gBattlePartyID - ldrb r3, [r1] - lsls r0, r3, 1 - adds r0, r2 - ldr r1, =gBattleStruct - ldr r1, [r1] - ldrh r0, [r0] - ldrb r1, [r1, 0x10] - cmp r0, r1 - bne _0804DFC8 - ldr r4, =gBattleMons - movs r0, 0x58 - adds r2, r3, 0 - muls r2, r0 - adds r0, r4, 0 - adds r0, 0x50 - adds r0, r2, r0 - ldr r0, [r0] - movs r1, 0x80 - lsls r1, 14 - ands r0, r1 - cmp r0, 0 - bne _0804DFC8 - adds r0, r2, r4 - adds r1, r5, 0 - bl GiveMoveToBattleMon -_0804DFC8: - ldr r0, =gBattleTypeFlags - ldr r0, [r0] - movs r1, 0x1 - ands r0, r1 - cmp r0, 0 - beq _0804E014 - movs r0, 0x2 - bl GetBankByPlayerAI - ldr r1, =gActiveBank - strb r0, [r1] - ldr r2, =gBattlePartyID - ldrb r3, [r1] - lsls r0, r3, 1 - adds r0, r2 - ldr r1, =gBattleStruct - ldr r1, [r1] - ldrh r0, [r0] - ldrb r1, [r1, 0x10] - cmp r0, r1 - bne _0804E014 - ldr r4, =gBattleMons - movs r0, 0x58 - adds r2, r3, 0 - muls r2, r0 - adds r0, r4, 0 - adds r0, 0x50 - adds r0, r2, r0 - ldr r0, [r0] - movs r1, 0x80 - lsls r1, 14 - ands r0, r1 - cmp r0, 0 - bne _0804E014 - adds r0, r2, r4 - adds r1, r5, 0 - bl GiveMoveToBattleMon -_0804E014: - ldr r0, =gBattlescriptCurrInstr - str r6, [r0] -_0804E018: - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end atk59_learnmove_inbattle - - thumb_func_start atk5A -atk5A: @ 804E038 - push {r4-r7,lr} - mov r7, r8 - push {r7} - sub sp, 0x4 - ldr r0, =gActiveBank - movs r1, 0 - strb r1, [r0] - ldr r0, =gBattleScripting - ldrb r1, [r0, 0x1F] - adds r2, r0, 0 - cmp r1, 0x6 - bls _0804E052 - b _0804E3B8 -_0804E052: - lsls r0, r1, 2 - ldr r1, =_0804E068 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_0804E068: - .4byte _0804E084 - .4byte _0804E0BC - .4byte _0804E162 - .4byte _0804E1B8 - .4byte _0804E1E4 - .4byte _0804E38C - .4byte _0804E3AC -_0804E084: - movs r4, 0 - str r4, [sp] - movs r0, 0x18 - movs r1, 0x8 - movs r2, 0x1D - movs r3, 0xD - bl sub_8056A3C - ldr r0, =gText_BattleYesNoChoice - movs r1, 0xC - bl battle_show_message_maybe - ldr r1, =gBattleScripting - ldrb r0, [r1, 0x1F] - adds r0, 0x1 - strb r0, [r1, 0x1F] - ldr r0, =gBattleCommunication - strb r4, [r0, 0x1] - movs r0, 0 - bl sub_8056B74 - b _0804E3B8 - .pool -_0804E0BC: - ldr r0, =gMain - ldrh r1, [r0, 0x2E] - movs r0, 0x40 - ands r0, r1 - cmp r0, 0 - beq _0804E0E4 - ldr r4, =gBattleCommunication - ldrb r0, [r4, 0x1] - cmp r0, 0 - beq _0804E0E4 - movs r0, 0x5 - bl PlaySE - ldrb r0, [r4, 0x1] - bl sub_8056BAC - movs r0, 0 - strb r0, [r4, 0x1] - bl sub_8056B74 -_0804E0E4: - ldr r0, =gMain - ldrh r1, [r0, 0x2E] - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - beq _0804E10C - ldr r4, =gBattleCommunication - ldrb r0, [r4, 0x1] - cmp r0, 0 - bne _0804E10C - movs r0, 0x5 - bl PlaySE - ldrb r0, [r4, 0x1] - bl sub_8056BAC - movs r0, 0x1 - strb r0, [r4, 0x1] - bl sub_8056B74 -_0804E10C: - ldr r0, =gMain - ldrh r1, [r0, 0x2E] - movs r5, 0x1 - adds r0, r5, 0 - ands r0, r1 - cmp r0, 0 - beq _0804E150 - movs r0, 0x5 - bl PlaySE - ldr r0, =gBattleCommunication - ldrb r4, [r0, 0x1] - cmp r4, 0 - bne _0804E20A - str r5, [sp] - movs r0, 0x18 - movs r1, 0x8 - movs r2, 0x1D - movs r3, 0xD - bl sub_8056A3C - movs r0, 0x1 - negs r0, r0 - str r4, [sp] - movs r1, 0 - movs r2, 0 - movs r3, 0x10 - bl BeginNormalPaletteFade - b _0804E192 - .pool -_0804E150: - movs r0, 0x2 - ands r0, r1 - cmp r0, 0 - bne _0804E15A - b _0804E3B8 -_0804E15A: - movs r0, 0x5 - bl PlaySE - b _0804E20A -_0804E162: - ldr r0, =gPaletteFade - ldrb r1, [r0, 0x7] - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - beq _0804E170 - b _0804E3B8 -_0804E170: - bl FreeAllWindowBuffers - ldr r0, =gPlayerParty - ldr r1, =gBattleStruct - ldr r1, [r1] - ldrb r1, [r1, 0x10] - ldr r2, =gPlayerPartyCount - ldrb r2, [r2] - subs r2, 0x1 - lsls r2, 24 - lsrs r2, 24 - ldr r3, =sub_80A92F8 - ldr r4, =gMoveToLearn - ldrh r4, [r4] - str r4, [sp] - bl sub_81BFA38 -_0804E192: - ldr r1, =gBattleScripting - ldrb r0, [r1, 0x1F] - adds r0, 0x1 - strb r0, [r1, 0x1F] - b _0804E3B8 - .pool -_0804E1B8: - ldr r0, =gPaletteFade - ldrb r1, [r0, 0x7] - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - beq _0804E1C6 - b _0804E3B8 -_0804E1C6: - ldr r0, =gMain - ldr r1, [r0, 0x4] - ldr r0, =sub_8038420 - cmp r1, r0 - beq _0804E1D2 - b _0804E3B8 -_0804E1D2: - ldrb r0, [r2, 0x1F] - adds r0, 0x1 - b _0804E3B6 - .pool -_0804E1E4: - ldr r0, =gPaletteFade - ldrb r1, [r0, 0x7] - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - beq _0804E1F2 - b _0804E3B8 -_0804E1F2: - ldr r0, =gMain - ldr r1, [r0, 0x4] - ldr r0, =sub_8038420 - cmp r1, r0 - beq _0804E1FE - b _0804E3B8 -_0804E1FE: - bl sub_81C1B94 - lsls r0, 24 - lsrs r5, r0, 24 - cmp r5, 0x4 - bne _0804E224 -_0804E20A: - ldr r1, =gBattleScripting - movs r0, 0x5 - strb r0, [r1, 0x1F] - b _0804E3B8 - .pool -_0804E224: - ldr r6, =gBattleStruct - ldr r0, [r6] - ldrb r0, [r0, 0x10] - movs r1, 0x64 - mov r8, r1 - mov r1, r8 - muls r1, r0 - adds r0, r1, 0 - ldr r7, =gPlayerParty - adds r0, r7 - adds r1, r5, 0 - adds r1, 0xD - bl GetMonData - lsls r0, 16 - lsrs r4, r0, 16 - adds r0, r4, 0 - bl IsHMMove2 - cmp r0, 0 - beq _0804E274 - ldr r0, =0x0000013f - ldr r1, =gActiveBank - ldrb r1, [r1] - bl PrepareStringBattle - ldr r1, =gBattleScripting - movs r0, 0x6 - strb r0, [r1, 0x1F] - b _0804E3B8 - .pool -_0804E274: - ldr r3, =gBattlescriptCurrInstr - ldr r2, [r3] - ldrb r1, [r2, 0x1] - ldrb r0, [r2, 0x2] - lsls r0, 8 - orrs r1, r0 - ldrb r0, [r2, 0x3] - lsls r0, 16 - orrs r1, r0 - ldrb r0, [r2, 0x4] - lsls r0, 24 - orrs r1, r0 - str r1, [r3] - ldr r1, =gBattleTextBuff2 - movs r0, 0xFD - strb r0, [r1] - movs r0, 0x2 - strb r0, [r1, 0x1] - strb r4, [r1, 0x2] - lsrs r0, r4, 8 - strb r0, [r1, 0x3] - movs r0, 0xFF - strb r0, [r1, 0x4] - ldr r0, [r6] - ldrb r0, [r0, 0x10] - mov r1, r8 - muls r1, r0 - adds r0, r1, 0 - adds r0, r7 - adds r1, r5, 0 - bl RemoveMonPPBonus - ldr r0, [r6] - ldrb r0, [r0, 0x10] - mov r1, r8 - muls r1, r0 - adds r0, r1, 0 - adds r0, r7 - ldr r7, =gMoveToLearn - ldrh r1, [r7] - adds r2, r5, 0 - bl SetMonMoveSlot - ldr r0, =gBattlePartyID - ldr r1, [r6] - ldrh r0, [r0] - ldrb r1, [r1, 0x10] - cmp r0, r1 - bne _0804E30A - ldr r4, =gBattleMons - ldr r0, [r4, 0x50] - movs r1, 0x80 - lsls r1, 14 - ands r0, r1 - cmp r0, 0 - bne _0804E30A - ldr r0, =gDisableStructs - ldrb r1, [r0, 0x18] - lsrs r1, 4 - ldr r2, =gBitTable - lsls r0, r5, 2 - adds r0, r2 - ldr r0, [r0] - ands r1, r0 - cmp r1, 0 - bne _0804E30A - adds r0, r4, 0 - adds r1, r5, 0 - bl RemoveBattleMonPPBonus - ldrh r1, [r7] - adds r0, r4, 0 - adds r2, r5, 0 - bl SetBattleMonMoveSlot -_0804E30A: - ldr r0, =gBattleTypeFlags - ldr r0, [r0] - movs r1, 0x1 - ands r0, r1 - cmp r0, 0 - beq _0804E3B8 - ldr r2, =gBattlePartyID - ldr r0, =gBattleStruct - ldr r1, [r0] - ldrh r0, [r2, 0x4] - ldrb r1, [r1, 0x10] - cmp r0, r1 - bne _0804E3B8 - ldr r4, =gBattleMons - movs r1, 0x80 - lsls r1, 1 - adds r0, r4, r1 - ldr r0, [r0] - movs r1, 0x80 - lsls r1, 14 - ands r0, r1 - cmp r0, 0 - bne _0804E3B8 - ldr r0, =gDisableStructs - adds r0, 0x50 - ldrb r1, [r0] - lsrs r1, 4 - ldr r2, =gBitTable - lsls r0, r5, 2 - adds r0, r2 - ldr r0, [r0] - ands r1, r0 - cmp r1, 0 - bne _0804E3B8 - adds r4, 0xB0 - adds r0, r4, 0 - adds r1, r5, 0 - bl RemoveBattleMonPPBonus - ldr r0, =gMoveToLearn - ldrh r1, [r0] - adds r0, r4, 0 - adds r2, r5, 0 - bl SetBattleMonMoveSlot - b _0804E3B8 - .pool -_0804E38C: - movs r0, 0x1 - str r0, [sp] - movs r0, 0x18 - movs r1, 0x8 - movs r2, 0x1D - movs r3, 0xD - bl sub_8056A3C - ldr r1, =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x5 - str r0, [r1] - b _0804E3B8 - .pool -_0804E3AC: - ldr r0, =gBattleExecBuffer - ldr r0, [r0] - cmp r0, 0 - bne _0804E3B8 - movs r0, 0x2 -_0804E3B6: - strb r0, [r2, 0x1F] -_0804E3B8: - add sp, 0x4 - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end atk5A - - thumb_func_start atk5B_80256E0 -atk5B_80256E0: @ 804E3C8 - push {r4,r5,lr} - sub sp, 0x4 - ldr r5, =gBattleScripting - ldrb r4, [r5, 0x1F] - cmp r4, 0 - beq _0804E3E0 - cmp r4, 0x1 - beq _0804E410 - b _0804E4FA - .pool -_0804E3E0: - str r4, [sp] - movs r0, 0x18 - movs r1, 0x8 - movs r2, 0x1D - movs r3, 0xD - bl sub_8056A3C - ldr r0, =gText_BattleYesNoChoice - movs r1, 0xC - bl battle_show_message_maybe - ldrb r0, [r5, 0x1F] - adds r0, 0x1 - strb r0, [r5, 0x1F] - ldr r0, =gBattleCommunication - strb r4, [r0, 0x1] - movs r0, 0 - bl sub_8056B74 - b _0804E4FA - .pool -_0804E410: - ldr r0, =gMain - ldrh r1, [r0, 0x2E] - movs r0, 0x40 - ands r0, r1 - cmp r0, 0 - beq _0804E438 - ldr r4, =gBattleCommunication - ldrb r0, [r4, 0x1] - cmp r0, 0 - beq _0804E438 - movs r0, 0x5 - bl PlaySE - ldrb r0, [r4, 0x1] - bl sub_8056BAC - movs r0, 0 - strb r0, [r4, 0x1] - bl sub_8056B74 -_0804E438: - ldr r0, =gMain - ldrh r1, [r0, 0x2E] - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - beq _0804E460 - ldr r4, =gBattleCommunication - ldrb r0, [r4, 0x1] - cmp r0, 0 - bne _0804E460 - movs r0, 0x5 - bl PlaySE - ldrb r0, [r4, 0x1] - bl sub_8056BAC - movs r0, 0x1 - strb r0, [r4, 0x1] - bl sub_8056B74 -_0804E460: - ldr r0, =gMain - ldrh r1, [r0, 0x2E] - movs r4, 0x1 - adds r0, r4, 0 - ands r0, r1 - cmp r0, 0 - beq _0804E4C4 - movs r0, 0x5 - bl PlaySE - ldr r0, =gBattleCommunication - ldrb r0, [r0, 0x1] - cmp r0, 0 - beq _0804E4A4 - ldr r3, =gBattlescriptCurrInstr - ldr r2, [r3] - ldrb r1, [r2, 0x1] - ldrb r0, [r2, 0x2] - lsls r0, 8 - orrs r1, r0 - ldrb r0, [r2, 0x3] - lsls r0, 16 - orrs r1, r0 - ldrb r0, [r2, 0x4] - lsls r0, 24 - orrs r1, r0 - str r1, [r3] - b _0804E4AC - .pool -_0804E4A4: - ldr r1, =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x5 - str r0, [r1] -_0804E4AC: - movs r0, 0x1 - str r0, [sp] - movs r0, 0x18 - movs r1, 0x8 - movs r2, 0x1D - movs r3, 0xD - bl sub_8056A3C - b _0804E4FA - .pool -_0804E4C4: - movs r0, 0x2 - ands r0, r1 - cmp r0, 0 - beq _0804E4FA - movs r0, 0x5 - bl PlaySE - ldr r3, =gBattlescriptCurrInstr - ldr r2, [r3] - ldrb r1, [r2, 0x1] - ldrb r0, [r2, 0x2] - lsls r0, 8 - orrs r1, r0 - ldrb r0, [r2, 0x3] - lsls r0, 16 - orrs r1, r0 - ldrb r0, [r2, 0x4] - lsls r0, 24 - orrs r1, r0 - str r1, [r3] - str r4, [sp] - movs r0, 0x18 - movs r1, 0x8 - movs r2, 0x1D - movs r3, 0xD - bl sub_8056A3C -_0804E4FA: - add sp, 0x4 - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end atk5B_80256E0 - - thumb_func_start atk5C_hitanimation -atk5C_hitanimation: @ 804E508 - push {r4,lr} - ldr r4, =gBattlescriptCurrInstr - ldr r0, [r4] - ldrb r0, [r0, 0x1] - bl GetBattleBank - ldr r2, =gActiveBank - strb r0, [r2] - ldr r0, =gBattleMoveFlags - ldrb r1, [r0] - movs r0, 0x29 - ands r0, r1 - cmp r0, 0 - bne _0804E58C - ldr r0, =gHitMarker - ldr r0, [r0] - movs r1, 0x80 - lsls r1, 1 - ands r0, r1 - cmp r0, 0 - beq _0804E55A - ldr r1, =gBattleMons - ldrb r2, [r2] - movs r0, 0x58 - muls r0, r2 - adds r1, 0x50 - adds r0, r1 - ldr r0, [r0] - movs r1, 0x80 - lsls r1, 17 - ands r0, r1 - cmp r0, 0 - beq _0804E55A - ldr r0, =gDisableStructs - lsls r1, r2, 3 - subs r1, r2 - lsls r1, 2 - adds r1, r0 - ldrb r0, [r1, 0xA] - cmp r0, 0 - bne _0804E58C -_0804E55A: - movs r0, 0 - bl dp01_build_cmdbuf_x29_29_29_29 - ldr r0, =gActiveBank - ldrb r0, [r0] - bl MarkBufferBankForExecution - ldr r1, =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x2 - str r0, [r1] - b _0804E592 - .pool -_0804E58C: - ldr r0, [r4] - adds r0, 0x2 - str r0, [r4] -_0804E592: - pop {r4} - pop {r0} - bx r0 - thumb_func_end atk5C_hitanimation - - thumb_func_start sub_804E598 -sub_804E598: @ 804E598 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - lsls r0, 16 - lsrs r6, r0, 16 - movs r7, 0 - movs r5, 0 - movs r0, 0x80 - lsls r0, 3 - cmp r6, r0 - bne _0804E5D8 - ldr r0, =gBattleResources - ldr r0, [r0] - ldr r0, [r0] - adds r0, 0x94 - ldrb r2, [r0] - ldr r0, =gBattleStruct - ldr r0, [r0] - adds r0, 0x4A - ldrb r1, [r0] - lsls r0, r1, 2 - adds r0, r1 - lsls r0, 2 - muls r0, r2 - b _0804E6CA - .pool -_0804E5D8: - ldr r0, =gTrainers - lsls r2, r6, 2 - adds r1, r2, r6 - lsls r1, 3 - adds r4, r1, r0 - ldrb r3, [r4] - mov r12, r0 - cmp r3, 0x1 - beq _0804E62E - cmp r3, 0x1 - bgt _0804E5F8 - cmp r3, 0 - beq _0804E602 - b _0804E644 - .pool -_0804E5F8: - cmp r3, 0x2 - beq _0804E618 - cmp r3, 0x3 - beq _0804E62E - b _0804E644 -_0804E602: - mov r0, r12 - adds r0, 0x24 - adds r0, r1, r0 - ldr r1, [r0] - adds r0, r4, 0 - adds r0, 0x20 - ldrb r0, [r0] - lsls r0, 3 - adds r0, r1 - subs r0, 0x8 - b _0804E642 -_0804E618: - mov r0, r12 - adds r0, 0x24 - adds r0, r1, r0 - ldr r1, [r0] - adds r0, r4, 0 - adds r0, 0x20 - ldrb r0, [r0] - lsls r0, 3 - adds r0, r1 - subs r0, 0x8 - b _0804E642 -_0804E62E: - mov r0, r12 - adds r0, 0x24 - adds r0, r1, r0 - ldr r1, [r0] - adds r0, r4, 0 - adds r0, 0x20 - ldrb r0, [r0] - lsls r0, 4 - adds r0, r1 - subs r0, 0x10 -_0804E642: - ldrb r5, [r0, 0x2] -_0804E644: - ldr r1, =gUnknown_0831AEB8 - lsls r0, r7, 2 - adds r4, r0, r1 - ldrb r3, [r4] - ldr r0, =gBattleStruct - mov r8, r0 - mov r9, r1 - ldr r1, =gBattleTypeFlags - mov r10, r1 - cmp r3, 0xFF - beq _0804E67A - adds r0, r2, r6 - lsls r0, 3 - add r0, r12 - ldrb r1, [r0, 0x1] - cmp r3, r1 - beq _0804E67A - adds r2, r0, 0 - adds r0, r4, 0 -_0804E66A: - adds r0, 0x4 - adds r7, 0x1 - ldrb r1, [r0] - cmp r1, 0xFF - beq _0804E67A - ldrb r3, [r2, 0x1] - cmp r1, r3 - bne _0804E66A -_0804E67A: - mov r0, r10 - ldr r1, [r0] - movs r0, 0x80 - lsls r0, 8 - ands r0, r1 - cmp r0, 0 - bne _0804E6B4 - movs r0, 0x1 - ands r1, r0 - cmp r1, 0 - beq _0804E6B4 - mov r3, r8 - ldr r0, [r3] - adds r0, 0x4A - ldrb r0, [r0] - lsls r0, 2 - adds r1, r5, 0 - muls r1, r0 - lsls r0, r7, 2 - add r0, r9 - ldrb r0, [r0, 0x1] - lsls r0, 1 - b _0804E6C8 - .pool -_0804E6B4: - mov r1, r8 - ldr r0, [r1] - adds r0, 0x4A - ldrb r0, [r0] - lsls r0, 2 - adds r1, r5, 0 - muls r1, r0 - lsls r0, r7, 2 - add r0, r9 - ldrb r0, [r0, 0x1] -_0804E6C8: - muls r0, r1 -_0804E6CA: - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r1} - bx r1 - thumb_func_end sub_804E598 - - thumb_func_start atk5D_getmoneyreward -atk5D_getmoneyreward: @ 804E6D8 - push {r4,lr} - ldr r0, =gTrainerBattleOpponent_A - ldrh r0, [r0] - bl sub_804E598 - adds r4, r0, 0 - ldr r0, =gBattleTypeFlags - ldr r0, [r0] - movs r1, 0x80 - lsls r1, 8 - ands r0, r1 - cmp r0, 0 - beq _0804E6FC - ldr r0, =gTrainerBattleOpponent_B - ldrh r0, [r0] - bl sub_804E598 - adds r4, r0 -_0804E6FC: - ldr r0, =gSaveBlock1Ptr - ldr r0, [r0] - movs r1, 0x92 - lsls r1, 3 - adds r0, r1 - adds r1, r4, 0 - bl AddMoney - ldr r1, =gBattleTextBuff1 - movs r0, 0xFD - strb r0, [r1] - movs r0, 0x1 - strb r0, [r1, 0x1] - movs r0, 0x4 - strb r0, [r1, 0x2] - movs r0, 0x5 - strb r0, [r1, 0x3] - strb r4, [r1, 0x4] - movs r0, 0xFF - lsls r0, 8 - ands r0, r4 - lsrs r0, 8 - strb r0, [r1, 0x5] - movs r0, 0xFF - lsls r0, 16 - ands r0, r4 - lsrs r0, 16 - strb r0, [r1, 0x6] - lsrs r0, r4, 24 - strb r0, [r1, 0x7] - movs r0, 0xFF - strb r0, [r1, 0x8] - ldr r1, =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x1 - str r0, [r1] - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end atk5D_getmoneyreward - - thumb_func_start atk5E_8025A70 -atk5E_8025A70: @ 804E764 - push {r4-r7,lr} - mov r7, r8 - push {r7} - ldr r4, =gBattlescriptCurrInstr - ldr r0, [r4] - ldrb r0, [r0, 0x1] - bl GetBattleBank - ldr r6, =gActiveBank - strb r0, [r6] - ldr r5, =gBattleCommunication - ldrb r0, [r5] - mov r8, r4 - cmp r0, 0 - beq _0804E794 - cmp r0, 0x1 - beq _0804E7AC - b _0804E800 - .pool -_0804E794: - movs r0, 0 - movs r1, 0 - movs r2, 0 - bl EmitGetAttributes - ldrb r0, [r6] - bl MarkBufferBankForExecution - ldrb r0, [r5] - adds r0, 0x1 - strb r0, [r5] - b _0804E800 -_0804E7AC: - ldr r0, =gBattleExecBuffer - ldr r0, [r0] - cmp r0, 0 - bne _0804E800 - ldrb r0, [r6] - lsls r0, 9 - ldr r1, =gBattleBufferB + 4 - adds r0, r1 - mov r12, r0 - movs r2, 0 - adds r4, r6, 0 - movs r5, 0x58 - ldr r6, =gBattleMons + 0x24 - adds r7, r6, 0 - subs r7, 0x18 - mov r3, r12 - adds r3, 0xC -_0804E7CE: - lsls r1, r2, 1 - ldrb r0, [r4] - muls r0, r5 - adds r1, r0 - adds r1, r7 - ldrh r0, [r3] - strh r0, [r1] - ldrb r0, [r4] - adds r1, r0, 0 - muls r1, r5 - adds r1, r2, r1 - adds r1, r6 - mov r0, r12 - adds r0, 0x24 - adds r0, r2 - ldrb r0, [r0] - strb r0, [r1] - adds r3, 0x2 - adds r2, 0x1 - cmp r2, 0x3 - ble _0804E7CE - mov r1, r8 - ldr r0, [r1] - adds r0, 0x2 - str r0, [r1] -_0804E800: - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end atk5E_8025A70 - - thumb_func_start atk5F_8025B24 -atk5F_8025B24: @ 804E818 - push {lr} - ldr r0, =gActiveBank - ldr r2, =gBankAttacker - ldrb r3, [r2] - strb r3, [r0] - ldr r1, =gBankTarget - ldrb r0, [r1] - strb r0, [r2] - strb r3, [r1] - ldr r2, =gHitMarker - ldr r1, [r2] - movs r3, 0x80 - lsls r3, 5 - adds r0, r1, 0 - ands r0, r3 - cmp r0, 0 - beq _0804E854 - ldr r0, =0xffffefff - ands r1, r0 - b _0804E856 - .pool -_0804E854: - orrs r1, r3 -_0804E856: - str r1, [r2] - ldr r1, =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x1 - str r0, [r1] - pop {r0} - bx r0 - .pool - thumb_func_end atk5F_8025B24 - - thumb_func_start atk60_increment_gamestat -atk60_increment_gamestat: @ 804E868 - push {lr} - ldr r0, =gBankAttacker - ldrb r0, [r0] - bl GetBankSide - lsls r0, 24 - cmp r0, 0 - bne _0804E882 - ldr r0, =gBattlescriptCurrInstr - ldr r0, [r0] - ldrb r0, [r0, 0x1] - bl IncrementGameStat -_0804E882: - ldr r1, =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x2 - str r0, [r1] - pop {r0} - bx r0 - .pool - thumb_func_end atk60_increment_gamestat - - thumb_func_start atk61_8025BA4 -atk61_8025BA4: @ 804E898 - push {r4-r7,lr} - mov r7, r8 - push {r7} - sub sp, 0x30 - ldr r0, =gBattleExecBuffer - ldr r0, [r0] - cmp r0, 0 - bne _0804E94C - ldr r0, =gBattlescriptCurrInstr - ldr r0, [r0] - ldrb r0, [r0, 0x1] - bl GetBattleBank - ldr r1, =gActiveBank - strb r0, [r1] - ldrb r0, [r1] - bl GetBankSide - lsls r0, 24 - ldr r1, =gEnemyParty - mov r8, r1 - cmp r0, 0 - bne _0804E8CA - ldr r0, =gPlayerParty - mov r8, r0 -_0804E8CA: - movs r7, 0 - add r6, sp, 0x4 - mov r5, sp -_0804E8D0: - movs r0, 0x64 - muls r0, r7 - mov r1, r8 - adds r4, r1, r0 - adds r0, r4, 0 - movs r1, 0x41 - bl GetMonData - cmp r0, 0 - beq _0804E8F4 - adds r0, r4, 0 - movs r1, 0x41 - bl GetMonData - movs r1, 0xCE - lsls r1, 1 - cmp r0, r1 - bne _0804E914 -_0804E8F4: - ldr r0, =0x0000ffff - strh r0, [r5] - movs r0, 0 - b _0804E926 - .pool -_0804E914: - adds r0, r4, 0 - movs r1, 0x39 - bl GetMonData - strh r0, [r5] - adds r0, r4, 0 - movs r1, 0x37 - bl GetMonData -_0804E926: - str r0, [r6] - adds r6, 0x8 - adds r5, 0x8 - adds r7, 0x1 - cmp r7, 0x5 - ble _0804E8D0 - movs r0, 0 - mov r1, sp - movs r2, 0x1 - bl dp01_build_cmdbuf_x30_TODO - ldr r0, =gActiveBank - ldrb r0, [r0] - bl MarkBufferBankForExecution - ldr r1, =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x2 - str r0, [r1] -_0804E94C: - add sp, 0x30 - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end atk61_8025BA4 - - thumb_func_start atk62_08025C6C -atk62_08025C6C: @ 804E960 - push {r4,r5,lr} - ldr r5, =gBattlescriptCurrInstr - ldr r0, [r5] - ldrb r0, [r0, 0x1] - bl GetBattleBank - ldr r4, =gActiveBank - strb r0, [r4] - movs r0, 0 - bl dp01_build_cmdbuf_x31_31_31_31 - ldrb r0, [r4] - bl MarkBufferBankForExecution - ldr r0, [r5] - adds r0, 0x2 - str r0, [r5] - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end atk62_08025C6C - - thumb_func_start atk63_jumptorandomattack -atk63_jumptorandomattack: @ 804E990 - push {r4,lr} - ldr r0, =gBattlescriptCurrInstr - ldr r1, [r0] - ldrb r1, [r1, 0x1] - adds r4, r0, 0 - cmp r1, 0 - beq _0804E9B4 - ldr r0, =gCurrentMove - ldr r1, =gRandomMove - ldrh r1, [r1] - strh r1, [r0] - b _0804E9C2 - .pool -_0804E9B4: - ldr r2, =gLastUsedMove - ldr r1, =gCurrentMove - ldr r0, =gRandomMove - ldrh r0, [r0] - strh r0, [r1] - strh r0, [r2] - adds r0, r1, 0 -_0804E9C2: - ldr r3, =gBattleScriptsForMoveEffects - ldr r2, =gBattleMoves - ldrh r1, [r0] - lsls r0, r1, 1 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - ldrb r0, [r0] - lsls r0, 2 - adds r0, r3 - ldr r0, [r0] - str r0, [r4] - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end atk63_jumptorandomattack - - thumb_func_start atk64_statusanimation -atk64_statusanimation: @ 804E9F4 - push {r4,lr} - ldr r0, =gBattleExecBuffer - ldr r0, [r0] - cmp r0, 0 - bne _0804EA5C - ldr r0, =gBattlescriptCurrInstr - ldr r0, [r0] - ldrb r0, [r0, 0x1] - bl GetBattleBank - ldr r4, =gActiveBank - strb r0, [r4] - ldr r1, =gStatuses3 - ldrb r2, [r4] - lsls r0, r2, 2 - adds r0, r1 - ldr r0, [r0] - ldr r1, =0x000400c0 - ands r0, r1 - cmp r0, 0 - bne _0804EA54 - ldr r0, =gDisableStructs - lsls r1, r2, 3 - subs r1, r2 - lsls r1, 2 - adds r1, r0 - ldrb r0, [r1, 0xA] - cmp r0, 0 - bne _0804EA54 - ldr r0, =gHitMarker - ldr r0, [r0] - movs r1, 0x80 - ands r0, r1 - cmp r0, 0 - bne _0804EA54 - ldr r1, =gBattleMons - movs r0, 0x58 - muls r0, r2 - adds r1, 0x4C - adds r0, r1 - ldr r2, [r0] - movs r0, 0 - movs r1, 0 - bl dp01_build_cmdbuf_x1B_aaaa_b - ldrb r0, [r4] - bl MarkBufferBankForExecution -_0804EA54: - ldr r1, =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x2 - str r0, [r1] -_0804EA5C: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end atk64_statusanimation - - thumb_func_start atk65_status2animation -atk65_status2animation: @ 804EA84 - push {r4,r5,lr} - ldr r0, =gBattleExecBuffer - ldr r0, [r0] - cmp r0, 0 - bne _0804EB04 - ldr r4, =gBattlescriptCurrInstr - ldr r0, [r4] - ldrb r0, [r0, 0x1] - bl GetBattleBank - ldr r5, =gActiveBank - strb r0, [r5] - ldr r1, [r4] - ldrb r3, [r1, 0x2] - ldrb r0, [r1, 0x3] - lsls r0, 8 - orrs r3, r0 - ldrb r0, [r1, 0x4] - lsls r0, 16 - orrs r3, r0 - ldrb r0, [r1, 0x5] - lsls r0, 24 - orrs r3, r0 - ldr r1, =gStatuses3 - ldrb r2, [r5] - lsls r0, r2, 2 - adds r0, r1 - ldr r0, [r0] - ldr r1, =0x000400c0 - ands r0, r1 - cmp r0, 0 - bne _0804EAFC - ldr r0, =gDisableStructs - lsls r1, r2, 3 - subs r1, r2 - lsls r1, 2 - adds r1, r0 - ldrb r0, [r1, 0xA] - cmp r0, 0 - bne _0804EAFC - ldr r0, =gHitMarker - ldr r0, [r0] - movs r1, 0x80 - ands r0, r1 - cmp r0, 0 - bne _0804EAFC - ldr r1, =gBattleMons - movs r0, 0x58 - muls r0, r2 - adds r1, 0x50 - adds r0, r1 - ldr r2, [r0] - ands r2, r3 - movs r0, 0 - movs r1, 0x1 - bl dp01_build_cmdbuf_x1B_aaaa_b - ldrb r0, [r5] - bl MarkBufferBankForExecution -_0804EAFC: - ldr r1, =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x6 - str r0, [r1] -_0804EB04: - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end atk65_status2animation - - thumb_func_start atk66_chosenstatusanimation -atk66_chosenstatusanimation: @ 804EB2C - push {r4,r5,lr} - ldr r0, =gBattleExecBuffer - ldr r0, [r0] - cmp r0, 0 - bne _0804EB9E - ldr r4, =gBattlescriptCurrInstr - ldr r0, [r4] - ldrb r0, [r0, 0x1] - bl GetBattleBank - ldr r5, =gActiveBank - strb r0, [r5] - ldr r4, [r4] - ldrb r2, [r4, 0x3] - ldrb r0, [r4, 0x4] - lsls r0, 8 - orrs r2, r0 - ldrb r0, [r4, 0x5] - lsls r0, 16 - orrs r2, r0 - ldrb r0, [r4, 0x6] - lsls r0, 24 - orrs r2, r0 - ldr r1, =gStatuses3 - ldrb r3, [r5] - lsls r0, r3, 2 - adds r0, r1 - ldr r0, [r0] - ldr r1, =0x000400c0 - ands r0, r1 - cmp r0, 0 - bne _0804EB96 - ldr r0, =gDisableStructs - lsls r1, r3, 3 - subs r1, r3 - lsls r1, 2 - adds r1, r0 - ldrb r0, [r1, 0xA] - cmp r0, 0 - bne _0804EB96 - ldr r0, =gHitMarker - ldr r0, [r0] - movs r1, 0x80 - ands r0, r1 - cmp r0, 0 - bne _0804EB96 - ldrb r1, [r4, 0x2] - movs r0, 0 - bl dp01_build_cmdbuf_x1B_aaaa_b - ldrb r0, [r5] - bl MarkBufferBankForExecution -_0804EB96: - ldr r1, =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x7 - str r0, [r1] -_0804EB9E: - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end atk66_chosenstatusanimation - - thumb_func_start atk67_8025ECC -atk67_8025ECC: @ 804EBC0 - push {r4,r5,lr} - sub sp, 0x4 - ldr r5, =gBattleCommunication - ldrb r4, [r5] - cmp r4, 0 - beq _0804EBD8 - cmp r4, 0x1 - beq _0804EC04 - b _0804EC96 - .pool -_0804EBD8: - str r4, [sp] - movs r0, 0x18 - movs r1, 0x8 - movs r2, 0x1D - movs r3, 0xD - bl sub_8056A3C - ldr r0, =gText_BattleYesNoChoice - movs r1, 0xC - bl battle_show_message_maybe - ldrb r0, [r5] - adds r0, 0x1 - strb r0, [r5] - strb r4, [r5, 0x1] - movs r0, 0 - bl sub_8056B74 - b _0804EC96 - .pool -_0804EC04: - ldr r0, =gMain - ldrh r1, [r0, 0x2E] - movs r0, 0x40 - ands r0, r1 - cmp r0, 0 - beq _0804EC2A - ldrb r0, [r5, 0x1] - cmp r0, 0 - beq _0804EC2A - movs r0, 0x5 - bl PlaySE - ldrb r0, [r5, 0x1] - bl sub_8056BAC - movs r0, 0 - strb r0, [r5, 0x1] - bl sub_8056B74 -_0804EC2A: - ldr r0, =gMain - ldrh r1, [r0, 0x2E] - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - beq _0804EC52 - ldr r4, =gBattleCommunication - ldrb r0, [r4, 0x1] - cmp r0, 0 - bne _0804EC52 - movs r0, 0x5 - bl PlaySE - ldrb r0, [r4, 0x1] - bl sub_8056BAC - movs r0, 0x1 - strb r0, [r4, 0x1] - bl sub_8056B74 -_0804EC52: - ldr r0, =gMain - ldrh r1, [r0, 0x2E] - movs r0, 0x2 - ands r0, r1 - cmp r0, 0 - beq _0804EC70 - ldr r0, =gBattleCommunication - movs r4, 0x1 - strb r4, [r0, 0x1] - b _0804EC7A - .pool -_0804EC70: - movs r4, 0x1 - adds r0, r4, 0 - ands r0, r1 - cmp r0, 0 - beq _0804EC96 -_0804EC7A: - movs r0, 0x5 - bl PlaySE - str r4, [sp] - movs r0, 0x18 - movs r1, 0x8 - movs r2, 0x1D - movs r3, 0xD - bl sub_8056A3C - ldr r1, =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x1 - str r0, [r1] -_0804EC96: - add sp, 0x4 - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end atk67_8025ECC - - thumb_func_start atk68_80246A0 -atk68_80246A0: @ 804ECA4 - push {r4,r5,lr} - movs r1, 0 - ldr r2, =gNoOfAllBanks - ldr r5, =gBattlescriptCurrInstr - ldrb r0, [r2] - cmp r1, r0 - bge _0804ECC2 - ldr r4, =gUnknown_0202407A - movs r3, 0xC -_0804ECB6: - adds r0, r1, r4 - strb r3, [r0] - adds r1, 0x1 - ldrb r0, [r2] - cmp r1, r0 - blt _0804ECB6 -_0804ECC2: - ldr r0, [r5] - adds r0, 0x1 - str r0, [r5] - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end atk68_80246A0 - - thumb_func_start atk69_dmg_adjustment2 -atk69_dmg_adjustment2: @ 804ECDC - push {r4-r7,lr} - ldr r7, =gBattleMons - ldr r6, =gBankTarget - ldrb r2, [r6] - movs r5, 0x58 - adds r0, r2, 0 - muls r0, r5 - adds r1, r0, r7 - ldrh r0, [r1, 0x2E] - cmp r0, 0xAF - bne _0804ED10 - ldr r1, =gEnigmaBerries - lsls r0, r2, 3 - subs r0, r2 - lsls r0, 2 - adds r0, r1 - ldrb r4, [r0, 0x7] - ldrb r6, [r0, 0x1A] - b _0804ED2A - .pool -_0804ED10: - ldrh r0, [r1, 0x2E] - bl ItemId_GetHoldEffect - lsls r0, 24 - lsrs r4, r0, 24 - ldrb r0, [r6] - muls r0, r5 - adds r0, r7 - ldrh r0, [r0, 0x2E] - bl ItemId_GetHoldEffectParam - lsls r0, 24 - lsrs r6, r0, 24 -_0804ED2A: - ldr r1, =gStringBank - ldr r5, =gBankTarget - ldrb r0, [r5] - strb r0, [r1] - cmp r4, 0x27 - bne _0804ED68 - bl Random - lsls r0, 16 - lsrs r0, 16 - movs r1, 0x64 - bl __umodsi3 - lsls r0, 16 - lsrs r0, 16 - cmp r0, r6 - bcs _0804ED68 - ldrb r0, [r5] - movs r1, 0x27 - bl RecordItemEffectBattle - ldr r2, =gSpecialStatuses - ldrb r1, [r5] - lsls r0, r1, 2 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - ldrb r1, [r0] - movs r2, 0x80 - orrs r1, r2 - strb r1, [r0] -_0804ED68: - ldr r2, =gBattleMons - ldr r3, =gBankTarget - ldrb r4, [r3] - movs r0, 0x58 - muls r0, r4 - adds r1, r2, 0 - adds r1, 0x50 - adds r0, r1 - ldr r1, [r0] - movs r0, 0x80 - lsls r0, 17 - ands r1, r0 - adds r5, r2, 0 - cmp r1, 0 - bne _0804EE38 - ldr r2, =gBattleMoves - ldr r0, =gCurrentMove - ldrh r1, [r0] - lsls r0, r1, 1 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - ldrb r0, [r0] - cmp r0, 0x65 - beq _0804EDBA - ldr r0, =gProtectStructs - lsls r1, r4, 4 - adds r1, r0 - ldrb r0, [r1] - lsls r0, 30 - cmp r0, 0 - blt _0804EDBA - ldr r0, =gSpecialStatuses - lsls r1, r4, 2 - adds r1, r4 - lsls r1, 2 - adds r1, r0 - ldrb r0, [r1] - lsrs r0, 7 - cmp r0, 0 - beq _0804EE38 -_0804EDBA: - ldrb r0, [r3] - movs r4, 0x58 - muls r0, r4 - adds r0, r5 - ldrh r1, [r0, 0x28] - ldr r2, =gBattleMoveDamage - ldr r0, [r2] - cmp r1, r0 - bgt _0804EE38 - subs r0, r1, 0x1 - str r0, [r2] - ldr r1, =gProtectStructs - ldrb r3, [r3] - lsls r0, r3, 4 - adds r0, r1 - ldrb r0, [r0] - lsls r0, 30 - cmp r0, 0 - bge _0804EE10 - ldr r0, =gBattleMoveFlags - ldrb r1, [r0] - movs r2, 0x40 - orrs r1, r2 - strb r1, [r0] - b _0804EE38 - .pool -_0804EE10: - ldr r0, =gSpecialStatuses - lsls r1, r3, 2 - adds r1, r3 - lsls r1, 2 - adds r1, r0 - ldrb r0, [r1] - lsrs r0, 7 - cmp r0, 0 - beq _0804EE38 - ldr r2, =gBattleMoveFlags - ldrb r0, [r2] - movs r1, 0x80 - orrs r0, r1 - strb r0, [r2] - ldr r1, =gLastUsedItem - adds r0, r3, 0 - muls r0, r4 - adds r0, r5 - ldrh r0, [r0, 0x2E] - strh r0, [r1] -_0804EE38: - ldr r1, =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x1 - str r0, [r1] - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end atk69_dmg_adjustment2 - thumb_func_start atk6A_removeitem atk6A_removeitem: @ 804EE58 push {r4-r6,lr} @@ -5058,7 +1575,7 @@ _0804FC38: bl StrCpyDecodeToDisplayedStringBattle ldr r0, =gDisplayedStringBattle movs r1, 0x16 - bl battle_show_message_maybe + bl sub_814F9EC b _0804FD70 .pool _0804FC60: @@ -5168,7 +1685,7 @@ _0804FD5C: lsls r1, 1 movs r0, 0 movs r2, 0x1 - bl sub_8034300 + bl EmitPlaySound ldr r0, =gActiveBank ldrb r0, [r0] bl MarkBufferBankForExecution @@ -17635,7 +14152,7 @@ _08056978: bne _08056A2C ldr r0, =gMain ldr r1, [r0, 0x4] - ldr r0, =sub_8038420 + ldr r0, =BattleMainCB2 cmp r1, r0 bne _08056A2C ldr r2, =gTasks @@ -17866,8 +14383,8 @@ _08056B62: bx r0 thumb_func_end sub_8056A3C - thumb_func_start sub_8056B74 -sub_8056B74: @ 8056B74 + thumb_func_start BattleCreateCursorAt +BattleCreateCursorAt: @ 8056B74 push {lr} sub sp, 0x10 adds r3, r0, 0 @@ -17894,10 +14411,10 @@ sub_8056B74: @ 8056B74 add sp, 0x10 pop {r0} bx r0 - thumb_func_end sub_8056B74 + thumb_func_end BattleCreateCursorAt - thumb_func_start sub_8056BAC -sub_8056BAC: @ 8056BAC + thumb_func_start BattleDestroyCursorAt +BattleDestroyCursorAt: @ 8056BAC push {lr} sub sp, 0x10 adds r3, r0, 0 @@ -17926,7 +14443,7 @@ sub_8056BAC: @ 8056BAC pop {r0} bx r0 .pool - thumb_func_end sub_8056BAC + thumb_func_end BattleDestroyCursorAt thumb_func_start atkF3_nickname_caught_poke atkF3_nickname_caught_poke: @ 8056BEC @@ -17966,14 +14483,14 @@ _08056C2C: bl sub_8056A3C ldr r0, =gText_BattleYesNoChoice movs r1, 0xC - bl battle_show_message_maybe + bl sub_814F9EC ldr r1, =gBattleCommunication ldrb r0, [r1] adds r0, 0x1 strb r0, [r1] strb r4, [r1, 0x1] movs r0, 0 - bl sub_8056B74 + bl BattleCreateCursorAt b _08056E62 .pool _08056C60: @@ -17989,10 +14506,10 @@ _08056C60: movs r0, 0x5 bl PlaySE ldrb r0, [r4, 0x1] - bl sub_8056BAC + bl BattleDestroyCursorAt movs r0, 0 strb r0, [r4, 0x1] - bl sub_8056B74 + bl BattleCreateCursorAt _08056C86: ldr r0, =gMain ldrh r1, [r0, 0x2E] @@ -18007,10 +14524,10 @@ _08056C86: movs r0, 0x5 bl PlaySE ldrb r0, [r4, 0x1] - bl sub_8056BAC + bl BattleDestroyCursorAt movs r0, 0x1 strb r0, [r4, 0x1] - bl sub_8056B74 + bl BattleCreateCursorAt _08056CAE: ldr r0, =gMain ldrh r1, [r0, 0x2E] @@ -18124,7 +14641,7 @@ _08056D0A: ldr r1, [r2] adds r1, 0x6D str r0, [sp] - ldr r0, =sub_8038420 + ldr r0, =BattleMainCB2 str r0, [sp, 0x4] movs r0, 0x2 adds r2, r6, 0 @@ -18139,7 +14656,7 @@ _08056D0A: _08056DD4: ldr r0, =gMain ldr r1, [r0, 0x4] - ldr r0, =sub_8038420 + ldr r0, =BattleMainCB2 cmp r1, r0 bne _08056E62 ldr r0, =gPaletteFade diff --git a/asm/battle_controller_linkopponent.s b/asm/battle_controller_linkopponent.s index e8975a7aa..5a762a174 100644 --- a/asm/battle_controller_linkopponent.s +++ b/asm/battle_controller_linkopponent.s @@ -5045,7 +5045,7 @@ sub_8066FF4: @ 8066FF4 bl BufferStringBattle ldr r0, =gDisplayedStringBattle movs r1, 0 - bl battle_show_message_maybe + bl sub_814F9EC ldr r1, =gBattleBankFunc ldrb r0, [r5] lsls r0, 2 diff --git a/asm/battle_controller_linkpartner.s b/asm/battle_controller_linkpartner.s index e02a967d0..3a1b21ed7 100644 --- a/asm/battle_controller_linkpartner.s +++ b/asm/battle_controller_linkpartner.s @@ -4354,7 +4354,7 @@ sub_814D590: @ 814D590 bl BufferStringBattle ldr r0, =gDisplayedStringBattle movs r1, 0 - bl battle_show_message_maybe + bl sub_814F9EC ldr r1, =gBattleBankFunc ldrb r0, [r5] lsls r0, 2 diff --git a/asm/battle_controller_opponent.s b/asm/battle_controller_opponent.s index 1bfa3ff12..4400217ae 100644 --- a/asm/battle_controller_opponent.s +++ b/asm/battle_controller_opponent.s @@ -5185,7 +5185,7 @@ sub_8061F34: @ 8061F34 bl BufferStringBattle ldr r0, =gDisplayedStringBattle movs r1, 0 - bl battle_show_message_maybe + bl sub_814F9EC ldr r1, =gBattleBankFunc ldrb r0, [r5] lsls r0, 2 diff --git a/asm/battle_controller_player.s b/asm/battle_controller_player.s index cbfad9c9f..ddb739b72 100644 --- a/asm/battle_controller_player.s +++ b/asm/battle_controller_player.s @@ -1247,7 +1247,7 @@ _08057F80: bl battle_menu_cursor_related_2 ldr r0, =gText_BattleSwitchWhich movs r1, 0xB - bl battle_show_message_maybe + bl sub_814F9EC ldr r1, =gBattleBankFunc ldr r0, =gActiveBank ldrb r0, [r0] @@ -4042,7 +4042,7 @@ sub_8059828: @ 8059828 push {lr} ldr r0, =gMain ldr r1, [r0, 0x4] - ldr r0, =sub_8038420 + ldr r0, =BattleMainCB2 cmp r1, r0 bne _08059898 ldr r0, =gPaletteFade @@ -4118,7 +4118,7 @@ sub_80598E0: @ 80598E0 push {lr} ldr r0, =gMain ldr r1, [r0, 0x4] - ldr r0, =sub_8038420 + ldr r0, =BattleMainCB2 cmp r1, r0 bne _08059906 ldr r0, =gPaletteFade @@ -4244,11 +4244,11 @@ sub_80599D4: @ 80599D4 movs r0, 0x5 bl PlaySE ldrb r0, [r4] - bl sub_8056BAC + bl BattleDestroyCursorAt movs r0, 0 strb r0, [r4] movs r0, 0 - bl sub_8056B74 + bl BattleCreateCursorAt _08059A02: ldr r0, =gMain ldrh r1, [r0, 0x2E] @@ -4263,11 +4263,11 @@ _08059A02: movs r0, 0x5 bl PlaySE ldrb r0, [r4] - bl sub_8056BAC + bl BattleDestroyCursorAt movs r0, 0x1 strb r0, [r4] movs r0, 0x1 - bl sub_8056B74 + bl BattleCreateCursorAt _08059A2C: ldr r0, =gMain ldrh r1, [r0, 0x2E] @@ -4355,7 +4355,7 @@ _08059AC4: lsls r1, 24 lsrs r1, 24 adds r0, r7, 0 - bl battle_show_message_maybe + bl sub_814F9EC ldrh r0, [r4] cmp r0, 0 beq _08059AF4 @@ -4382,7 +4382,7 @@ sub_8059B18: @ 8059B18 bl StringCopy adds r0, r4, 0 movs r1, 0x7 - bl battle_show_message_maybe + bl sub_814F9EC pop {r4} pop {r0} bx r0 @@ -4432,7 +4432,7 @@ sub_8059B3C: @ 8059B3C bl ConvertIntToDecimalStringN adds r0, r6, 0 movs r1, 0x9 - bl battle_show_message_maybe + bl sub_814F9EC _08059B98: pop {r4-r7} pop {r0} @@ -4481,7 +4481,7 @@ sub_8059BB0: @ 8059BB0 bl StringCopy adds r0, r6, 0 movs r1, 0xA - bl battle_show_message_maybe + bl sub_814F9EC pop {r4-r6} pop {r0} bx r0 @@ -4637,7 +4637,7 @@ sub_8059CF8: @ 8059CF8 thumb_func_start sub_8059D40 sub_8059D40: @ 8059D40 push {lr} - ldr r0, =sub_80A92F8 + ldr r0, =ReshowBattleScreenAfterMenu bl SetMainCallback2 pop {r0} bx r0 @@ -4647,7 +4647,7 @@ sub_8059D40: @ 8059D40 thumb_func_start sub_8059D50 sub_8059D50: @ 8059D50 push {lr} - ldr r0, =sub_80A92F8 + ldr r0, =ReshowBattleScreenAfterMenu bl SetMainCallback2 pop {r0} bx r0 @@ -4718,7 +4718,7 @@ b_link_standby_message: @ 8059DC0 strh r1, [r0] ldr r0, =gText_LinkStandby movs r1, 0 - bl battle_show_message_maybe + bl sub_814F9EC _08059DE0: pop {r0} bx r0 @@ -8458,7 +8458,7 @@ sub_805BF80: @ 805BF80 bl BufferStringBattle ldr r0, =gDisplayedStringBattle movs r1, 0 - bl battle_show_message_maybe + bl sub_814F9EC ldr r1, =gBattleBankFunc ldrb r0, [r5] lsls r0, 2 @@ -8534,7 +8534,7 @@ dp01t_12_6_battle_menu: @ 805C044 bl sub_817F2A8 ldr r0, =gText_BattleMenu movs r1, 0x2 - bl battle_show_message_maybe + bl sub_814F9EC movs r4, 0 _0805C062: lsls r0, r4, 24 @@ -8554,7 +8554,7 @@ _0805C062: bl StrCpyDecodeToDisplayedStringBattle ldr r0, =gDisplayedStringBattle movs r1, 0x1 - bl battle_show_message_maybe + bl sub_814F9EC pop {r4} pop {r0} bx r0 @@ -8580,12 +8580,12 @@ sub_805C0B0: @ 805C0B0 bl sub_8056A3C ldr r0, =gText_BattleYesNoChoice movs r1, 0xC - bl battle_show_message_maybe + bl sub_814F9EC ldr r1, =gUnknown_03005D74 movs r0, 0x1 strb r0, [r1] movs r0, 0x1 - bl sub_8056B74 + bl BattleCreateCursorAt ldr r1, =gBattleBankFunc ldrb r0, [r4] lsls r0, 2 diff --git a/asm/battle_controller_player_partner.s b/asm/battle_controller_player_partner.s index f77dc2c33..f14b5bc51 100644 --- a/asm/battle_controller_player_partner.s +++ b/asm/battle_controller_player_partner.s @@ -4966,7 +4966,7 @@ sub_81BDA4C: @ 81BDA4C bl BufferStringBattle ldr r0, =gDisplayedStringBattle movs r1, 0 - bl battle_show_message_maybe + bl sub_814F9EC ldr r1, =gBattleBankFunc ldrb r0, [r4] lsls r0, 2 diff --git a/asm/battle_controller_recorded_opponent.s b/asm/battle_controller_recorded_opponent.s index 6f047a4ef..90928e7d4 100644 --- a/asm/battle_controller_recorded_opponent.s +++ b/asm/battle_controller_recorded_opponent.s @@ -4722,7 +4722,7 @@ sub_8188E90: @ 8188E90 bl BufferStringBattle ldr r0, =gDisplayedStringBattle movs r1, 0 - bl battle_show_message_maybe + bl sub_814F9EC ldr r1, =gBattleBankFunc ldrb r0, [r4] lsls r0, 2 diff --git a/asm/battle_controller_recorded_player.s b/asm/battle_controller_recorded_player.s index 7b0cd6d41..534f34068 100644 --- a/asm/battle_controller_recorded_player.s +++ b/asm/battle_controller_recorded_player.s @@ -4822,7 +4822,7 @@ sub_818C43C: @ 818C43C bl BufferStringBattle ldr r0, =gDisplayedStringBattle movs r1, 0 - bl battle_show_message_maybe + bl sub_814F9EC ldr r1, =gBattleBankFunc ldrb r0, [r4] lsls r0, 2 diff --git a/asm/battle_controller_safari.s b/asm/battle_controller_safari.s index 2db6fa613..b02f95471 100644 --- a/asm/battle_controller_safari.s +++ b/asm/battle_controller_safari.s @@ -387,7 +387,7 @@ sub_8159698: @ 8159698 push {lr} ldr r0, =gMain ldr r1, [r0, 0x4] - ldr r0, =sub_8038420 + ldr r0, =BattleMainCB2 cmp r1, r0 bne _081596BE ldr r0, =gPaletteFade @@ -792,7 +792,7 @@ dp01t_10_6_message: @ 81599DC bl BufferStringBattle ldr r0, =gDisplayedStringBattle movs r1, 0 - bl battle_show_message_maybe + bl sub_814F9EC ldr r1, =gBattleBankFunc ldrb r0, [r4] lsls r0, 2 @@ -862,7 +862,7 @@ sub_8159A94: @ 8159A94 str r1, [r0] ldr r0, =gText_SafariZoneMenu movs r1, 0x2 - bl battle_show_message_maybe + bl sub_814F9EC movs r4, 0 _08159AAE: lsls r0, r4, 24 @@ -882,7 +882,7 @@ _08159AAE: bl StrCpyDecodeToDisplayedStringBattle ldr r0, =gDisplayedStringBattle movs r1, 0x1 - bl battle_show_message_maybe + bl sub_814F9EC pop {r4} pop {r0} bx r0 diff --git a/asm/battle_controller_wally.s b/asm/battle_controller_wally.s index f67a21499..e723a522b 100644 --- a/asm/battle_controller_wally.s +++ b/asm/battle_controller_wally.s @@ -299,7 +299,7 @@ sub_8168610: @ 8168610 push {lr} ldr r0, =gMain ldr r1, [r0, 0x4] - ldr r0, =sub_8038420 + ldr r0, =BattleMainCB2 cmp r1, r0 bne _08168636 ldr r0, =gPaletteFade @@ -3606,7 +3606,7 @@ sub_816A3B8: @ 816A3B8 bl BufferStringBattle ldr r0, =gDisplayedStringBattle movs r1, 0 - bl battle_show_message_maybe + bl sub_814F9EC ldr r1, =gBattleBankFunc ldrb r0, [r4] lsls r0, 2 @@ -3676,7 +3676,7 @@ dp01t_12_1_battle_menu: @ 816A470 str r1, [r0] ldr r0, =gText_BattleMenu movs r1, 0x2 - bl battle_show_message_maybe + bl sub_814F9EC movs r4, 0 _0816A48A: lsls r0, r4, 24 @@ -3696,7 +3696,7 @@ _0816A48A: bl StrCpyDecodeToDisplayedStringBattle ldr r0, =gDisplayedStringBattle movs r1, 0x1 - bl battle_show_message_maybe + bl sub_814F9EC pop {r4} pop {r0} bx r0 diff --git a/asm/battle_frontier_2.s b/asm/battle_frontier_2.s index 8a9b0ba24..bea4972e3 100755 --- a/asm/battle_frontier_2.s +++ b/asm/battle_frontier_2.s @@ -20582,29 +20582,29 @@ _081A5328: ldr r4, =gDisplayedStringBattle adds r0, r4, 0 movs r1, 0xF - bl battle_show_message_maybe + bl sub_814F9EC ldr r0, =gText_Vs movs r1, 0x10 - bl battle_show_message_maybe + bl sub_814F9EC ldr r0, =gText_RivalBuffer bl StrCpyDecodeToDisplayedStringBattle adds r0, r4, 0 movs r1, 0x11 - bl battle_show_message_maybe + bl sub_814F9EC ldr r0, =gText_Mind movs r1, 0x12 - bl battle_show_message_maybe + bl sub_814F9EC ldr r0, =gText_Skill movs r1, 0x13 - bl battle_show_message_maybe + bl sub_814F9EC ldr r0, =gText_Body movs r1, 0x14 - bl battle_show_message_maybe + bl sub_814F9EC ldr r0, =gText_Judgement bl StrCpyDecodeToDisplayedStringBattle adds r0, r4, 0 movs r1, 0x15 - bl battle_show_message_maybe + bl sub_814F9EC b _081A553E .pool _081A53B4: @@ -20688,7 +20688,7 @@ _081A5464: bl StrCpyDecodeToDisplayedStringBattle ldr r0, =gDisplayedStringBattle movs r1, 0x15 - bl battle_show_message_maybe + bl sub_814F9EC ldrb r0, [r5] adds r0, 0x1 strb r0, [r5] diff --git a/asm/battle_message.s b/asm/battle_message.s index dfbf069b3..f1f2447aa 100644 --- a/asm/battle_message.s +++ b/asm/battle_message.s @@ -703,7 +703,7 @@ _0814E6DE: StrCpyDecodeToDisplayedStringBattle: @ 814E6F0 push {lr} ldr r1, =gDisplayedStringBattle - bl StrCpyDecodeBattle + bl BattleStringExpandPlaceholders pop {r1} bx r1 .pool @@ -763,8 +763,8 @@ _0814E75A: bx r1 thumb_func_end AppendStatusString - thumb_func_start StrCpyDecodeBattle -StrCpyDecodeBattle: @ 814E764 + thumb_func_start BattleStringExpandPlaceholders + BattleStringExpandPlaceholders: @ 814E764 push {r4-r7,lr} mov r7, r9 mov r6, r8 @@ -904,7 +904,7 @@ _0814E8EE: adds r0, r1, 0 _0814E8F0: adds r1, r4, 0 - bl StrCpyDecodeBattleTextBuff + bl ExpandBattleTextBuffPlaceholders bl _0814F5C0 .pool _0814E904: @@ -2335,10 +2335,10 @@ _0814F62A: pop {r4-r7} pop {r1} bx r1 - thumb_func_end StrCpyDecodeBattle + thumb_func_end BattleStringExpandPlaceholders - thumb_func_start StrCpyDecodeBattleTextBuff -StrCpyDecodeBattleTextBuff: @ 814F648 + thumb_func_start ExpandBattleTextBuffPlaceholders +ExpandBattleTextBuffPlaceholders: @ 814F648 push {r4-r7,lr} mov r7, r8 push {r7} @@ -2652,7 +2652,7 @@ _0814F8EA: pop {r4-r7} pop {r0} bx r0 - thumb_func_end StrCpyDecodeBattleTextBuff + thumb_func_end ExpandBattleTextBuffPlaceholders thumb_func_start sub_814F8F8 sub_814F8F8: @ 814F8F8 @@ -2773,8 +2773,8 @@ _0814F9E0: .pool thumb_func_end sub_814F950 - thumb_func_start battle_show_message_maybe -battle_show_message_maybe: @ 814F9EC + thumb_func_start sub_814F9EC +sub_814F9EC: @ 814F9EC push {r4-r7,lr} mov r7, r9 mov r6, r8 @@ -2987,7 +2987,7 @@ _0814FB9C: pop {r4-r7} pop {r0} bx r0 - thumb_func_end battle_show_message_maybe + thumb_func_end sub_814F9EC thumb_func_start sub_814FBAC sub_814FBAC: @ 814FBAC diff --git a/asm/evolution_scene.s b/asm/evolution_scene.s index efae2f07c..afc3c843b 100644 --- a/asm/evolution_scene.s +++ b/asm/evolution_scene.s @@ -1338,7 +1338,7 @@ _0813E6E4: bl StringExpandPlaceholders adds r0, r4, 0 movs r1, 0 - bl battle_show_message_maybe + bl sub_814F9EC ldr r0, =gTasks mov r2, r8 adds r1, r2, r7 @@ -1626,7 +1626,7 @@ _0813E99E: bl StringExpandPlaceholders adds r0, r4, 0 movs r1, 0 - bl battle_show_message_maybe + bl sub_814F9EC ldr r0, =0x00000173 bl PlayBGM ldr r2, =gTasks @@ -1868,7 +1868,7 @@ _0813EBE4: _0813EBEC: ldr r0, =gStringVar4 movs r1, 0 - bl battle_show_message_maybe + bl sub_814F9EC ldr r1, =gTasks mov r2, r8 adds r0, r2, r7 @@ -1900,7 +1900,7 @@ _0813EC2A: bl StrCpyDecodeToDisplayedStringBattle ldr r0, =gDisplayedStringBattle movs r1, 0 - bl battle_show_message_maybe + bl sub_814F9EC ldr r0, =gTasks mov r3, r8 adds r1, r3, r7 @@ -1997,7 +1997,7 @@ _0813ED16: bl StrCpyDecodeToDisplayedStringBattle ldr r0, =gDisplayedStringBattle movs r1, 0 - bl battle_show_message_maybe + bl sub_814F9EC ldr r0, =gTasks mov r2, r8 adds r1, r2, r7 @@ -2026,7 +2026,7 @@ _0813ED62: bl StrCpyDecodeToDisplayedStringBattle ldr r0, =gDisplayedStringBattle movs r1, 0 - bl battle_show_message_maybe + bl sub_814F9EC ldr r0, =gTasks mov r3, r8 adds r1, r3, r7 @@ -2051,7 +2051,7 @@ _0813ED90: bl StrCpyDecodeToDisplayedStringBattle ldr r0, =gDisplayedStringBattle movs r1, 0 - bl battle_show_message_maybe + bl sub_814F9EC ldr r0, =gTasks mov r2, r8 adds r1, r2, r7 @@ -2087,7 +2087,7 @@ _0813EDEA: bl sub_8056A3C ldr r0, =gText_BattleYesNoChoice movs r1, 0xC - bl battle_show_message_maybe + bl sub_814F9EC ldr r0, =gTasks mov r3, r8 adds r1, r3, r7 @@ -2100,7 +2100,7 @@ _0813EDEA: ldr r0, =gBattleCommunication strb r2, [r0, 0x1] movs r0, 0 - bl sub_8056B74 + bl BattleCreateCursorAt b _0813F1A4 .pool _0813EE34: @@ -2117,10 +2117,10 @@ _0813EE34: movs r0, 0x5 bl PlaySE ldrb r0, [r4, 0x1] - bl sub_8056BAC + bl BattleDestroyCursorAt movs r0, 0 strb r0, [r4, 0x1] - bl sub_8056B74 + bl BattleCreateCursorAt _0813EE5C: ldr r0, =gMain ldrh r1, [r0, 0x2E] @@ -2135,10 +2135,10 @@ _0813EE5C: movs r0, 0x5 bl PlaySE ldrb r0, [r4, 0x1] - bl sub_8056BAC + bl BattleDestroyCursorAt movs r0, 0x1 strb r0, [r4, 0x1] - bl sub_8056B74 + bl BattleCreateCursorAt _0813EE84: ldr r0, =gMain ldrh r1, [r0, 0x2E] @@ -2292,7 +2292,7 @@ _0813EFC8: bl StrCpyDecodeToDisplayedStringBattle ldr r0, =gDisplayedStringBattle movs r1, 0 - bl battle_show_message_maybe + bl sub_814F9EC ldr r1, =gTasks mov r2, r8 adds r0, r2, r7 @@ -2341,7 +2341,7 @@ _0813F05C: bl StrCpyDecodeToDisplayedStringBattle ldr r0, =gDisplayedStringBattle movs r1, 0 - bl battle_show_message_maybe + bl sub_814F9EC ldr r0, =gTasks mov r2, r8 adds r1, r2, r7 @@ -2370,7 +2370,7 @@ _0813F0AA: bl StrCpyDecodeToDisplayedStringBattle ldr r0, =gDisplayedStringBattle movs r1, 0 - bl battle_show_message_maybe + bl sub_814F9EC ldr r0, =gTasks mov r3, r8 adds r1, r3, r7 @@ -2398,7 +2398,7 @@ _0813F0D8: bl StrCpyDecodeToDisplayedStringBattle ldr r0, =gDisplayedStringBattle movs r1, 0 - bl battle_show_message_maybe + bl sub_814F9EC ldr r1, =gTasks mov r2, r8 adds r0, r2, r7 @@ -2414,7 +2414,7 @@ _0813F120: bl StrCpyDecodeToDisplayedStringBattle ldr r0, =gDisplayedStringBattle movs r1, 0 - bl battle_show_message_maybe + bl sub_814F9EC ldr r1, =gTasks mov r3, r8 adds r0, r3, r7 @@ -2434,7 +2434,7 @@ _0813F154: bl StrCpyDecodeToDisplayedStringBattle ldr r0, =gDisplayedStringBattle movs r1, 0 - bl battle_show_message_maybe + bl sub_814F9EC ldr r1, =gTasks mov r2, r8 adds r0, r2, r7 diff --git a/asm/recorded_battle.s b/asm/recorded_battle.s index 94d96b2f8..c84b518c3 100644 --- a/asm/recorded_battle.s +++ b/asm/recorded_battle.s @@ -236,8 +236,8 @@ _08184FA0: .pool thumb_func_end sub_8184E58 - thumb_func_start sub_8184FBC -sub_8184FBC: @ 8184FBC + thumb_func_start RecordedBattle_SetBankAction +RecordedBattle_SetBankAction: @ 8184FBC push {r4-r6,lr} lsls r0, 24 lsrs r5, r0, 24 @@ -269,7 +269,7 @@ _08184FF0: pop {r0} bx r0 .pool - thumb_func_end sub_8184FBC + thumb_func_end RecordedBattle_SetBankAction thumb_func_start sub_8185008 sub_8185008: @ 8185008 @@ -2212,7 +2212,7 @@ _081860C2: ldr r1, [sp, 0x4C] lsrs r0, r1, 24 movs r1, 0x6 - bl sub_8184FBC + bl RecordedBattle_SetBankAction movs r5, 0 ldr r2, =gUnknown_0203CC70 mov r8, r2 @@ -2241,7 +2241,7 @@ _081860F0: lsrs r1, 24 ldr r2, [sp, 0x4C] lsrs r0, r2, 24 - bl sub_8184FBC + bl RecordedBattle_SetBankAction b _08186118 .pool _08186110: diff --git a/asm/reshow_battle_screen.s b/asm/reshow_battle_screen.s index f83a11ff1..97cc16c77 100644 --- a/asm/reshow_battle_screen.s +++ b/asm/reshow_battle_screen.s @@ -10,8 +10,8 @@ nullsub_35: @ 80A92F4 bx lr thumb_func_end nullsub_35 - thumb_func_start sub_80A92F8 -sub_80A92F8: @ 80A92F8 + thumb_func_start ReshowBattleScreenAfterMenu +ReshowBattleScreenAfterMenu: @ 80A92F8 push {lr} ldr r2, =gPaletteFade ldrb r0, [r2, 0x8] @@ -37,7 +37,7 @@ sub_80A92F8: @ 80A92F8 pop {r0} bx r0 .pool - thumb_func_end sub_80A92F8 + thumb_func_end ReshowBattleScreenAfterMenu thumb_func_start c2_80777E8 c2_80777E8: @ 80A933C @@ -301,7 +301,7 @@ _080A95A4: movs r0, 0x7F ands r0, r1 strb r0, [r2, 0x8] - ldr r0, =sub_8038420 + ldr r0, =BattleMainCB2 bl SetMainCallback2 bl sub_805EF14 _080A95D2: diff --git a/asm/rom3.s b/asm/rom3.s index 4ab819fa2..bf68c86c8 100644 --- a/asm/rom3.s +++ b/asm/rom3.s @@ -2319,8 +2319,8 @@ dp01_build_cmdbuf_x07_7_7_7: @ 80339E4 .pool thumb_func_end dp01_build_cmdbuf_x07_7_7_7 - thumb_func_start dp01_build_cmdbuf_x08_8_8_8 -dp01_build_cmdbuf_x08_8_8_8: @ 8033A04 + thumb_func_start EmitTrainerSlide +EmitTrainerSlide: @ 8033A04 push {lr} lsls r0, 24 lsrs r0, 24 @@ -2335,7 +2335,7 @@ dp01_build_cmdbuf_x08_8_8_8: @ 8033A04 pop {r0} bx r0 .pool - thumb_func_end dp01_build_cmdbuf_x08_8_8_8 + thumb_func_end EmitTrainerSlide thumb_func_start dp01_build_cmdbuf_x09_9_9_9 dp01_build_cmdbuf_x09_9_9_9: @ 8033A24 @@ -3038,8 +3038,8 @@ dp01_build_cmdbuf_x1A_aaaa_bbbb: @ 8033F68 .pool thumb_func_end dp01_build_cmdbuf_x1A_aaaa_bbbb - thumb_func_start dp01_build_cmdbuf_x1B_aaaa_b -dp01_build_cmdbuf_x1B_aaaa_b: @ 8033FBC + thumb_func_start EmitStatusAnimation +EmitStatusAnimation: @ 8033FBC push {r4,lr} adds r4, r1, 0 lsls r0, 24 @@ -3067,7 +3067,7 @@ dp01_build_cmdbuf_x1B_aaaa_b: @ 8033FBC pop {r0} bx r0 .pool - thumb_func_end dp01_build_cmdbuf_x1B_aaaa_b + thumb_func_end EmitStatusAnimation thumb_func_start dp01_build_cmdbuf_x1C_a dp01_build_cmdbuf_x1C_a: @ 8033FF8 @@ -3431,8 +3431,8 @@ dp01_build_cmdbuf_x28_28_28_28: @ 8034274 .pool thumb_func_end dp01_build_cmdbuf_x28_28_28_28 - thumb_func_start dp01_build_cmdbuf_x29_29_29_29 -dp01_build_cmdbuf_x29_29_29_29: @ 8034294 + thumb_func_start EmitHitAnimation +EmitHitAnimation: @ 8034294 push {lr} lsls r0, 24 lsrs r0, 24 @@ -3447,10 +3447,10 @@ dp01_build_cmdbuf_x29_29_29_29: @ 8034294 pop {r0} bx r0 .pool - thumb_func_end dp01_build_cmdbuf_x29_29_29_29 + thumb_func_end EmitHitAnimation - thumb_func_start dp01_build_cmdbuf_x2A_2A_2A_2A -dp01_build_cmdbuf_x2A_2A_2A_2A: @ 80342B4 + thumb_func_start Emit_x2A +Emit_x2A: @ 80342B4 push {lr} lsls r0, 24 lsrs r0, 24 @@ -3465,7 +3465,7 @@ dp01_build_cmdbuf_x2A_2A_2A_2A: @ 80342B4 pop {r0} bx r0 .pool - thumb_func_end dp01_build_cmdbuf_x2A_2A_2A_2A + thumb_func_end Emit_x2A thumb_func_start EmitEffectivenessSound EmitEffectivenessSound: @ 80342D4 @@ -3491,8 +3491,8 @@ EmitEffectivenessSound: @ 80342D4 .pool thumb_func_end EmitEffectivenessSound - thumb_func_start sub_8034300 -sub_8034300: @ 8034300 + thumb_func_start EmitPlaySound +EmitPlaySound: @ 8034300 push {r4,lr} lsls r0, 24 lsrs r0, 24 @@ -3512,10 +3512,10 @@ sub_8034300: @ 8034300 pop {r0} bx r0 .pool - thumb_func_end sub_8034300 + thumb_func_end EmitPlaySound - thumb_func_start dp01_build_cmdbuf_x2D_2D_2D_2D -dp01_build_cmdbuf_x2D_2D_2D_2D: @ 803432C + thumb_func_start EmitFaintingCry +EmitFaintingCry: @ 803432C push {lr} lsls r0, 24 lsrs r0, 24 @@ -3530,7 +3530,7 @@ dp01_build_cmdbuf_x2D_2D_2D_2D: @ 803432C pop {r0} bx r0 .pool - thumb_func_end dp01_build_cmdbuf_x2D_2D_2D_2D + thumb_func_end EmitFaintingCry thumb_func_start dp01_build_cmdbuf_x2E_a dp01_build_cmdbuf_x2E_a: @ 803434C @@ -3567,8 +3567,8 @@ dp01_build_cmdbuf_x2F_2F_2F_2F: @ 803436C .pool thumb_func_end dp01_build_cmdbuf_x2F_2F_2F_2F - thumb_func_start dp01_build_cmdbuf_x30_TODO -dp01_build_cmdbuf_x30_TODO: @ 803438C + thumb_func_start EmitCmd48 +EmitCmd48: @ 803438C push {r4,r5,lr} adds r4, r1, 0 lsls r0, 24 @@ -3604,10 +3604,10 @@ _080343B4: pop {r0} bx r0 .pool - thumb_func_end dp01_build_cmdbuf_x30_TODO + thumb_func_end EmitCmd48 - thumb_func_start dp01_build_cmdbuf_x31_31_31_31 -dp01_build_cmdbuf_x31_31_31_31: @ 80343D4 + thumb_func_start EmitCmd49 +EmitCmd49: @ 80343D4 push {lr} lsls r0, 24 lsrs r0, 24 @@ -3622,7 +3622,7 @@ dp01_build_cmdbuf_x31_31_31_31: @ 80343D4 pop {r0} bx r0 .pool - thumb_func_end dp01_build_cmdbuf_x31_31_31_31 + thumb_func_end EmitCmd49 thumb_func_start dp01_build_cmdbuf_x32_32_32_32 dp01_build_cmdbuf_x32_32_32_32: @ 80343F4 @@ -3735,8 +3735,8 @@ dp01_build_cmdbuf_x38_a: @ 80344A8 .pool thumb_func_end dp01_build_cmdbuf_x38_a - thumb_func_start dp01_build_cmdbuf_x37_a -dp01_build_cmdbuf_x37_a: @ 80344C8 + thumb_func_start Emit_x37 +Emit_x37: @ 80344C8 push {r4,r5,lr} adds r5, r0, 0 lsls r5, 24 @@ -3770,6 +3770,6 @@ dp01_build_cmdbuf_x37_a: @ 80344C8 pop {r0} bx r0 .pool - thumb_func_end dp01_build_cmdbuf_x37_a + thumb_func_end Emit_x37 .align 2, 0 @ Don't pad with nop. diff --git a/data/data2b.s b/data/data2b.s index 5df0bdf54..fd72e835e 100644 --- a/data/data2b.s +++ b/data/data2b.s @@ -209,7 +209,7 @@ gTypeEffectiveness:: @ 831ACE8 .include "data/text/type_names.inc" .align 2 -gUnknown_0831AEB8:: @ 831AEB8 +gTrainerMoneyTable:: @ 831AEB8 .incbin "baserom.gba", 0x31aeb8, 0xe0 @ 831AF98 diff --git a/include/battle.h b/include/battle.h index e71a23e28..d45944274 100644 --- a/include/battle.h +++ b/include/battle.h @@ -200,6 +200,7 @@ #define REQUEST_HP_BATTLE 0x2A // array entries for battle communication +#define CURSOR_POSITION 0x1 #define MOVE_EFFECT_BYTE 0x3 #define MULTISTRING_CHOOSER 0x5 #define MSG_DISPLAY 0x7 @@ -236,6 +237,46 @@ #define CMP_COMMON_BITS 0x4 #define CMP_NO_COMMON_BITS 0x5 +struct TrainerMonNoItemDefaultMoves +{ + u16 species; + u8 lvl; + u16 evsValue; +}; + +struct TrainerMonItemDefaultMoves +{ + u16 species; + u8 lvl; + u16 evsValue; + u16 heldItem; +}; + +struct TrainerMonNoItemCustomMoves +{ + u16 species; + u8 lvl; + u16 evsValue; + u16 moves[4]; +}; + +struct TrainerMonItemCustomMoves +{ + u16 species; + u8 lvl; + u16 evsValue; + u16 heldItem; + u16 moves[4]; +}; + +union TrainerMonPtr +{ + struct TrainerMonNoItemDefaultMoves* NoItemDefaultMoves; + struct TrainerMonNoItemCustomMoves* NoItemCustomMoves; + struct TrainerMonItemDefaultMoves* ItemDefaultMoves; + struct TrainerMonItemCustomMoves* ItemCustomMoves; +}; + struct Trainer { /*0x00*/ u8 partyFlags; @@ -247,9 +288,12 @@ struct Trainer /*0x18*/ bool8 doubleBattle; /*0x1C*/ u32 aiFlags; /*0x20*/ u8 partySize; - /*0x24*/ void *party; + /*0x24*/ union TrainerMonPtr party; }; +#define PARTY_FLAG_CUSTOM_MOVES 0x1 +#define PARTY_FLAG_HAS_ITEM 0x2 + extern const struct Trainer gTrainers[]; #define TRAINER_ENCOUNTER_MUSIC(trainer)((gTrainers[trainer].encounterMusic_gender & 0x7F)) @@ -289,7 +333,8 @@ struct DisableStruct /*0x16*/ u8 isFirstTurn; /*0x17*/ u8 unk17; /*0x18*/ u8 truantCounter : 1; - /*0x18*/ u8 unk18_a : 3; + /*0x18*/ u8 truantUnknownBit : 1; + /*0x18*/ u8 unk18_a_2 : 2; /*0x18*/ u8 unk18_b : 4; /*0x19*/ u8 rechargeCounter; /*0x1A*/ u8 unk1A[2]; @@ -464,7 +509,7 @@ struct BattleResults { u8 playerFaintCounter; // 0x0 u8 opponentFaintCounter; // 0x1 - u8 unk2; // 0x2 + u8 playerSwitchesCounter; // 0x2 u8 unk3; // 0x3 u8 unk4; // 0x4 u8 unk5_0:1; // 0x5 @@ -664,6 +709,13 @@ extern struct BattleStruct* gBattleStruct; varName = (u16*)(((void*)(*memes1) + (u32)(memes2))); \ } +#define GET_HP_SWITCHOUT_PTR_VIA_MEME_ACCESS(bank, varName) \ +{ \ + void** memes1 = (void**)(&gBattleStruct); \ + void* memes2 = (void*)((u32)(bank * 2 + offsetof(struct BattleStruct, hpOnSwitchout))); \ + varName = (u16*)(((void*)(*memes1) + (u32)(memes2))); \ +} + #define GET_MOVE_TYPE(move, typeArg) \ { \ if (gBattleStruct->dynamicMoveType) \ @@ -815,6 +867,9 @@ struct BattleScripting u8 statChanger; u8 field_1B; u8 atk23_state; + u8 field_1D; + u8 field_1E; + u8 learnMoveState; }; extern struct BattleScripting gBattleScripting; @@ -829,6 +884,9 @@ u8 GetBattleBank(u8 caseId); void UndoEffectsAfterFainting(void); bool8 HasMoveFailed(u8 bank); void SwitchInClearStructs(void); +void sub_803BDA0(u8 bank); +void sub_803FA70(u8 bank); +void BattleMainCB2(void); // battle_3 void BattleScriptPush(const u8* bsPtr); @@ -860,9 +918,12 @@ void AI_CalcDmg(u8 bankAtk, u8 bankDef); u8 TypeCalc(u16 move, u8 bankAtk, u8 bankDef); u8 AI_TypeCalc(u16 move, u16 species, u8 ability); u8 BankGetTurnOrder(u8 bank); +void BattleDestroyCursorAt(u8 cursorPosition); +void BattleCreateCursorAt(u8 cursorPosition); // battle_5 void AdjustFriendshipOnBattleFaint(u8 bank); +void sub_80571DC(u8 bank, u8 arg1); // battle 7 void BattleMusicStop(void); diff --git a/include/battle_controllers.h b/include/battle_controllers.h index 443ca5be1..b24aa9cc5 100644 --- a/include/battle_controllers.h +++ b/include/battle_controllers.h @@ -1,13 +1,21 @@ #ifndef GUARD_BATTLE_CONTROLLERS_H #define GUARD_BATTLE_CONTROLLERS_H +struct HpAndStatus +{ + u16 hp; + u32 status; +}; + // rom3.s, emitters void EmitSetAttributes(u8 bufferId, u8 request, u8 c, u8 bytes, void *data); void EmitMoveAnimation(u8 bufferId, u16 move, u8 turnOfMove, u16 movePower, s32 dmg, u8 friendship, struct DisableStruct* disableStructPtr, u8 multihit); void EmitHealthBarUpdate(u8 bufferId, u16 hpValue); void EmitEffectivenessSound(u8 bufferId, u16 songId); +void EmitPlaySound(u8 bufferId, u16 songId, u8 arg2); void EmitPrintStringPlayerOnly(u8 bufferId, u16 stringId); void EmitFaintAnimation(u8 bufferId); +void Emit_x2A(u8 bufferId); void EmitExpUpdate(u8 bufferId, u8 partyId, u16 expPoints); void EmitBattleAnimation(u8 bufferId, u8 animationId, u16 argument); void EmitSpriteInvisibility(u8 bufferId, bool8 isInvisible); @@ -15,6 +23,14 @@ void EmitReturnPokeToBall(u8 bufferId, u8 arg1); void EmitGetAttributes(u8 bufferId, u8 arg1, u8 arg2); void EmitSwitchInAnim(u8 bufferId, u8 partyId, bool8 dontClearSubstituteBit); void EmitChoosePokemon(u8 bufferId, u8 caseId, u8 arg2, u8 abilityId, const u8* arg4); +void EmitLinkStandbyMsg(u8 bufferId, u8 arg1, u8 arg2); +void EmitTrainerSlide(u8 bufferId); +void EmitFaintingCry(u8 bufferId); +void Emit_x37(u8 bufferId, u8 arg1); +void EmitHitAnimation(u8 bufferId); +void EmitCmd48(u8 bufferId, struct HpAndStatus* hpAndStatus, u8 arg2); +void EmitCmd49(u8 bufferId); +void EmitStatusAnimation(u8 bufferId, bool8 status2, u32 status); void MarkBufferBankForExecution(u8 bank); diff --git a/include/battle_message.h b/include/battle_message.h index ca310ae6f..ad1ce3455 100644 --- a/include/battle_message.h +++ b/include/battle_message.h @@ -1,6 +1,147 @@ #ifndef GUARD_BATTLE_MESSAGE_H #define GUARD_BATTLE_MESSAGE_H +// for 0xFD + +#define B_TXT_BUFF1 00 +#define B_TXT_BUFF2 01 +#define B_TXT_COPY_VAR_1 02 +#define B_TXT_COPY_VAR_2 03 +#define B_TXT_COPY_VAR_3 04 +#define B_TXT_PLAYER_MON1_NAME 05 +#define B_TXT_OPPONENT_MON1_NAME 06 +#define B_TXT_PLAYER_MON2_NAME 07 +#define B_TXT_OPPONENT_MON2_NAME 08 +#define B_TXT_LINK_PLAYER_MON1_NAME 09 +#define B_TXT_LINK_OPPONENT_MON1_NAME 0A +#define B_TXT_LINK_PLAYER_MON2_NAME 0B +#define B_TXT_LINK_OPPONENT_MON2_NAME 0C +#define B_TXT_ATK_NAME_WITH_PREFIX_MON1 0D +#define B_TXT_ATK_NAME 0E +#define B_TXT_ATK_NAME_WITH_PREFIX 0F +#define B_TXT_DEF_NAME_WITH_PREFIX 10 +#define B_TXT_EFF_NAME_WITH_PREFIX 11 // EFF = short for gEffectBank +#define B_TXT_SCR_ACTIVE_NAME_WITH_PREFIX 12 +#define B_TXT_ACTIVE_NAME_WITH_PREFIX 13 +#define B_TXT_CURRENT_MOVE 14 +#define B_TXT_LAST_MOVE 15 +#define B_TXT_LAST_ITEM 16 +#define B_TXT_LAST_ABILITY 17 +#define B_TXT_ATK_ABILITY 18 +#define B_TXT_DEF_ABILITY 19 +#define B_TXT_SCR_ACTIVE_ABILITY 1A +#define B_TXT_EFF_ABILITY 1B +#define B_TXT_TRAINER1_CLASS 1C +#define B_TXT_TRAINER1_NAME 1D +#define B_TXT_1E 1E // trainer name for a link player +#define B_TXT_1F 1F // trainer name for a link player +#define B_TXT_20 20 // trainer name for a link player +#define B_TXT_21 21 // trainer name for a link player +#define B_TXT_22 22 // trainer name for a link player +#define B_TXT_PLAYER_NAME 23 +#define B_TXT_TRAINER1_LOSE_TEXT 24 +#define B_TXT_TRAINER1_WIN_TEXT 25 +#define B_TXT_26 26 +#define B_TXT_PC_CREATOR_NAME 27 +#define B_TXT_ATK_PREFIX1 28 +#define B_TXT_DEF_PREFIX1 29 +#define B_TXT_ATK_PREFIX2 2A +#define B_TXT_DEF_PREFIX2 2B +#define B_TXT_ATK_PREFIX3 2C +#define B_TXT_DEF_PREFIX3 2D +#define B_TXT_TRAINER2_CLASS 2E +#define B_TXT_TRAINER2_NAME 2F +#define B_TXT_TRAINER2_LOSE_TEXT 30 +#define B_TXT_TRAINER2_WIN_TEXT 31 +#define B_TXT_PARTNER_CLASS 32 +#define B_TXT_PARTNER_NAME 33 +#define B_TXT_BUFF3 34 + +// for B_TXT_BUFF1, B_TXT_BUFF2 and B_TXT_BUFF3 + +#define B_BUFF_STRING 0 +#define B_BUFF_NUMBER 1 +#define B_BUFF_MOVE 2 +#define B_BUFF_TYPE 3 +#define B_BUFF_MON_NICK_WITH_PREFIX 4 +#define B_BUFF_STAT 5 +#define B_BUFF_SPECIES 6 +#define B_BUFF_MON_NICK 7 +#define B_BUFF_NEGATIVE_FLAVOUR 8 +#define B_BUFF_ABILITY 9 +#define B_BUFF_ITEM 10 + +#define B_BUFF_PLACEHOLDER_BEGIN 0xFD +#define B_BUFF_EOS 0xFF + +#define PREPARE_BYTE_NUMBER_BUFFER(textVar, maxDigits, number) \ +{ \ + textVar[0] = B_BUFF_PLACEHOLDER_BEGIN; \ + textVar[1] = B_BUFF_NUMBER; \ + textVar[2] = 1; \ + textVar[3] = maxDigits; \ + textVar[4] = (number); \ + textVar[5] = B_BUFF_EOS; \ +} + +#define PREPARE_WORD_NUMBER_BUFFER(textVar, maxDigits, number) \ +{ \ + textVar[0] = B_BUFF_PLACEHOLDER_BEGIN; \ + textVar[1] = B_BUFF_NUMBER; \ + textVar[2] = 4; \ + textVar[3] = maxDigits; \ + textVar[4] = (number); \ + textVar[5] = (number & 0x0000FF00) >> 8; \ + textVar[6] = (number & 0x00FF0000) >> 16; \ + textVar[7] = (number & 0xFF000000) >> 24; \ + textVar[8] = B_BUFF_EOS; \ +} + +#define PREPARE_STRING_BUFFER(textVar, stringId) \ +{ \ + textVar[0] = B_BUFF_PLACEHOLDER_BEGIN; \ + textVar[1] = B_BUFF_STRING; \ + textVar[2] = stringId; \ + textVar[3] = (stringId & 0xFF00) >> 8; \ + textVar[4] = B_BUFF_EOS; \ +} + +#define PREPARE_MOVE_BUFFER(textVar, move) \ +{ \ + textVar[0] = B_BUFF_PLACEHOLDER_BEGIN; \ + textVar[1] = B_BUFF_MOVE; \ + textVar[2] = move; \ + textVar[3] = (move & 0xFF00) >> 8; \ + textVar[4] = B_BUFF_EOS; \ +} + +#define PREPARE_SPECIES_BUFFER(textVar, species) \ +{ \ + textVar[0] = B_BUFF_PLACEHOLDER_BEGIN; \ + textVar[1] = B_BUFF_SPECIES; \ + textVar[2] = species; \ + textVar[3] = (species & 0xFF00) >> 8; \ + textVar[4] = B_BUFF_EOS; \ +} + +#define PREPARE_MON_NICK_WITH_PREFIX_BUFFER(textVar, bank, partyId) \ +{ \ + textVar[0] = B_BUFF_PLACEHOLDER_BEGIN; \ + textVar[1] = B_BUFF_MON_NICK_WITH_PREFIX; \ + textVar[2] = bank; \ + textVar[3] = partyId; \ + textVar[4] = B_BUFF_EOS; \ +} + +#define PREPARE_MON_NICK_BUFFER(textVar, bank, partyId) \ +{ \ + textVar[0] = B_BUFF_PLACEHOLDER_BEGIN; \ + textVar[1] = B_BUFF_MON_NICK; \ + textVar[2] = bank; \ + textVar[3] = partyId; \ + textVar[4] = B_BUFF_EOS; \ +} + struct StringInfoBattle { u16 currentMove; @@ -18,7 +159,8 @@ struct StringInfoBattle void BufferStringBattle(u16 stringID); u32 StrCpyDecodeToDisplayedStringBattle(const u8* src); -u32 StrCpyDecodeBattle(const u8* src, u8* dst); +u32 BattleStringExpandPlaceholders(const u8* src, u8* dst); +void sub_814F9EC(const u8* text, u8 arg1); extern u8 gBattleTextBuff1[]; extern u8 gBattleTextBuff2[]; diff --git a/include/pokemon.h b/include/pokemon.h index f629799e5..518d28e58 100644 --- a/include/pokemon.h +++ b/include/pokemon.h @@ -626,6 +626,7 @@ bool8 IsTradedMon(struct Pokemon *mon); void HandleSetPokedexFlag(u16 nationalNum, u8 caseId, u32 personality); s32 sub_806D864(u16 a1); bool16 sub_806D82C(u8 id); +u16 MonTryLearningNewMove(struct Pokemon* mon, bool8); #include "sprite.h" diff --git a/include/recorded_battle.h b/include/recorded_battle.h new file mode 100644 index 000000000..d19a2b713 --- /dev/null +++ b/include/recorded_battle.h @@ -0,0 +1,6 @@ +#ifndef GUARD_RECORDED_BATTLE_H +#define GUARD_RECORDED_BATTLE_H + +void RecordedBattle_SetBankAction(u8 bank, u8 action); + +#endif // GUARD_RECORDED_BATTLE_H diff --git a/include/reshow_battle_screen.h b/include/reshow_battle_screen.h new file mode 100644 index 000000000..62773b48b --- /dev/null +++ b/include/reshow_battle_screen.h @@ -0,0 +1,6 @@ +#ifndef GUARD_RESHOW_BATTLE_SCREEN_H +#define GUARD_RESHOW_BATTLE_SCREEN_H + +void ReshowBattleScreenAfterMenu(void); + +#endif // GUARD_RESHOW_BATTLE_SCREEN_H diff --git a/include/text.h b/include/text.h index dba409f37..f0c85b978 100644 --- a/include/text.h +++ b/include/text.h @@ -71,7 +71,9 @@ #define EXT_CTRL_CODE_BEGIN 0xFC // extended control code #define PLACEHOLDER_BEGIN 0xFD // string placeholder #define CHAR_NEWLINE 0xFE -#define EOS 0xFF // end of string +#define EOS 0xFF // end of string + +// battle placeholders are located in battle_message.h #define EXT_CTRL_CODE_JPN 0x15 #define EXT_CTRL_CODE_ENG 0x16 diff --git a/src/battle_4.c b/src/battle_4.c index db6d7fe53..77a4393c4 100644 --- a/src/battle_4.c +++ b/src/battle_4.c @@ -18,6 +18,12 @@ #include "text.h" #include "sound.h" #include "pokedex.h" +#include "recorded_battle.h" +#include "window.h" +#include "reshow_battle_screen.h" +#include "main.h" +#include "palette.h" +#include "money.h" // variables @@ -32,7 +38,7 @@ extern u32 gBattleExecBuffer; extern u8 gNoOfAllBanks; extern u16 gBattlePartyID[BATTLE_BANKS_COUNT]; extern u8 gTurnOrder[BATTLE_BANKS_COUNT]; -extern u8 gUnknown_02024A76[BATTLE_BANKS_COUNT]; +extern u8 gUnknown_0202407A[BATTLE_BANKS_COUNT]; extern u16 gCurrentMove; extern u8 gLastUsedAbility; extern u16 gBattleWeather; @@ -47,7 +53,6 @@ extern u16 gPaydayMoney; extern u16 gRandomTurnNumber; extern u8 gBattleOutcome; extern u8 gBattleTerrain; -extern u16 gTrainerBattleOpponent; extern u8 gBankAttacker; extern u8 gBankTarget; extern const u8* gBattlescriptCurrInstr; @@ -84,18 +89,29 @@ extern u16 gPartnerTrainerId; extern u16 gLastUsedMove; extern u16 gUnknownMovesUsedByBanks[BATTLE_BANKS_COUNT]; extern u16 gLastUsedMovesByBanks[BATTLE_BANKS_COUNT]; +extern u16 gTrainerBattleOpponent_A; +extern u16 gTrainerBattleOpponent_B; + +struct TrainerMoney +{ + u8 classId; + u8 value; +}; extern const struct BattleMove gBattleMoves[]; extern const struct BaseStats gBaseStats[]; extern const u8 gTypeEffectiveness[]; extern const u16 gMissStringIds[]; extern const u16 gTrappingMoves[]; -extern const u8 gTrainerMoney[]; +extern const struct TrainerMoney gTrainerMoneyTable[]; extern const u8* const gBattleScriptsForMoveEffects[]; // functions extern void sub_81A5718(u8 bank); // battle frontier 2 extern void sub_81A56B4(void); // battle frontier 2 +extern void sub_81BFA38(struct Pokemon* party, u8 monPartyId, u8 monCount, void (*callback)(void), u16 move); // pokemon summary screen +extern u8 sub_81C1B94(void); // pokemon summary screen +extern void IncrementGameStat(u8 statId); // rom_4 // BattleScripts extern const u8 BattleScript_MoveEnd[]; @@ -143,6 +159,12 @@ extern const u8 BattleScript_GrudgeTakesPp[]; extern const u8 BattleScript_RageIsBuilding[]; extern const u8 BattleScript_DefrostedViaFireMove[]; extern const u8 gUnknown_082DB87D[]; +extern const u8 gUnknown_082DAE90[]; +extern const u8 gUnknown_082DAE59[]; +extern const u8 gUnknown_082DAEC7[]; + +// strings +extern const u8 gText_BattleYesNoChoice[]; // read via orr #define BSScriptRead32(ptr) ((ptr)[0] | (ptr)[1] << 8 | (ptr)[2] << 16 | (ptr)[3] << 24) @@ -164,6 +186,7 @@ void DestinyBondFlagUpdate(void); u8 AttacksThisTurn(u8 bank, u16 move); // Note: returns 1 if it's a charging turn, otherwise 2. static void CheckWonderGuardAndLevitate(void); u8 ChangeStatBuffs(s8 statValue, u8 statId, u8, const u8* BS_ptr); +void sub_8056A3C(u8 arg0, u8 arg1, u8 arg2, u8 arg3, u8 arg4); void atk00_attackcanceler(void); void atk01_accuracycheck(void); @@ -255,8 +278,8 @@ void atk56_fainting_cry(void); void atk57(void); void atk58_return_to_ball(void); void atk59_learnmove_inbattle(void); -void atk5A(void); -void atk5B_80256E0(void); +void atk5A_yesnoboxlearnmove(void); +void atk5B_yesnoboxstoplearningmove(void); void atk5C_hitanimation(void); void atk5D_getmoneyreward(void); void atk5E_8025A70(void); @@ -268,9 +291,9 @@ void atk63_jumptorandomattack(void); void atk64_statusanimation(void); void atk65_status2animation(void); void atk66_chosenstatusanimation(void); -void atk67_8025ECC(void); +void atk67_yesnobox(void); void atk68_80246A0(void); -void atk69_dmg_adjustment2(void); +void atk69_dmg_adjustment3(void); void atk6A_removeitem(void); void atk6B_atknameinbuff1(void); void atk6C_lvlbox_display(void); @@ -507,8 +530,8 @@ void (* const gBattleScriptingCommandsTable[])(void) = atk57, atk58_return_to_ball, atk59_learnmove_inbattle, - atk5A, - atk5B_80256E0, + atk5A_yesnoboxlearnmove, + atk5B_yesnoboxstoplearningmove, atk5C_hitanimation, atk5D_getmoneyreward, atk5E_8025A70, @@ -520,9 +543,9 @@ void (* const gBattleScriptingCommandsTable[])(void) = atk64_statusanimation, atk65_status2animation, atk66_chosenstatusanimation, - atk67_8025ECC, + atk67_yesnobox, atk68_80246A0, - atk69_dmg_adjustment2, + atk69_dmg_adjustment3, atk6A_removeitem, atk6B_atknameinbuff1, atk6C_lvlbox_display, @@ -758,7 +781,7 @@ const u32 gStatusFlagsForMoveEffects[] = 0x00000000 }; -extern const u8* gMoveEffectBS_Ptrs[]; +extern const u8* const gMoveEffectBS_Ptrs[]; void atk00_attackcanceler(void) { @@ -2890,11 +2913,7 @@ void atk19_faint_pokemon(void) EmitSetAttributes(0, moveIndex + REQUEST_PPMOVE1_BATTLE, 0, 1, &gBattleMons[gActiveBank].pp[moveIndex]); MarkBufferBankForExecution(gActiveBank); - gBattleTextBuff1[0] = PLACEHOLDER_BEGIN; - gBattleTextBuff1[1] = 2; - gBattleTextBuff1[2] = gBattleMons[gBankAttacker].moves[moveIndex]; - gBattleTextBuff1[3] = gBattleMons[gBankAttacker].moves[moveIndex] >> 8; - gBattleTextBuff1[4] = EOS; + PREPARE_MOVE_BUFFER(gBattleTextBuff1, gBattleMons[gBankAttacker].moves[moveIndex]) } } else @@ -3262,30 +3281,12 @@ void atk23_getexp(void) else gBattleStruct->expGetterBank = 0; - // buffer poke name - gBattleTextBuff1[0] = PLACEHOLDER_BEGIN; - gBattleTextBuff1[1] = 4; - gBattleTextBuff1[2] = gBattleStruct->expGetterBank; - gBattleTextBuff1[3] = gBattleStruct->expGetterId; - gBattleTextBuff1[4] = EOS; + PREPARE_MON_NICK_WITH_PREFIX_BUFFER(gBattleTextBuff1, gBattleStruct->expGetterBank, gBattleStruct->expGetterId) // buffer 'gained' or 'gained a boosted' - gBattleTextBuff2[0] = PLACEHOLDER_BEGIN; - gBattleTextBuff2[1] = 0; - gBattleTextBuff2[2] = i; - gBattleTextBuff2[3] = (i & 0xFF00) >> 8; - gBattleTextBuff2[4] = EOS; + PREPARE_STRING_BUFFER(gBattleTextBuff2, i) - // buffer exp number - gBattleTextBuff3[0] = PLACEHOLDER_BEGIN; - gBattleTextBuff3[1] = 1; - gBattleTextBuff3[2] = 4; // word - gBattleTextBuff3[3] = 5; // max digits - gBattleTextBuff3[4] = gBattleMoveDamage; - gBattleTextBuff3[5] = (gBattleMoveDamage & 0x0000FF00) >> 8; - gBattleTextBuff3[6] = (gBattleMoveDamage & 0x00FF0000) >> 16; - gBattleTextBuff3[7] = (gBattleMoveDamage & 0xFF000000) >> 24; - gBattleTextBuff3[8] = EOS; + PREPARE_WORD_NUMBER_BUFFER(gBattleTextBuff3, 5, gBattleMoveDamage) PrepareStringBattle(0xD, gBattleStruct->expGetterBank); MonGainEVs(&gPlayerParty[gBattleStruct->expGetterId], gBattleMons[gBank1].species); @@ -3324,20 +3325,9 @@ void atk23_getexp(void) if (gBattleTypeFlags & BATTLE_TYPE_TRAINER && gBattlePartyID[gActiveBank] == gBattleStruct->expGetterId) sub_805E990(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank); - // buff poke name - gBattleTextBuff1[0] = PLACEHOLDER_BEGIN; - gBattleTextBuff1[1] = 4; - gBattleTextBuff1[2] = gActiveBank; - gBattleTextBuff1[3] = gBattleStruct->expGetterId; - gBattleTextBuff1[4] = EOS; + PREPARE_MON_NICK_WITH_PREFIX_BUFFER(gBattleTextBuff1, gActiveBank, gBattleStruct->expGetterId) - // buff level - gBattleTextBuff2[0] = PLACEHOLDER_BEGIN; - gBattleTextBuff2[1] = 1; - gBattleTextBuff2[2] = 1; - gBattleTextBuff2[3] = 3; - gBattleTextBuff2[4] = GetMonData(&gPlayerParty[gBattleStruct->expGetterId], MON_DATA_LEVEL); - gBattleTextBuff2[5] = EOS; + PREPARE_BYTE_NUMBER_BUFFER(gBattleTextBuff2, 3, GetMonData(&gPlayerParty[gBattleStruct->expGetterId], MON_DATA_LEVEL)) BattleScriptPushCursor(); gLeveledUpInBattle |= gBitTable[gBattleStruct->expGetterId]; @@ -5280,3 +5270,1050 @@ void sub_804CF10(u8 arg0) EmitChoosePokemon(0, 1, arg0, 0, gBattleStruct->field_60[gActiveBank]); MarkBufferBankForExecution(gActiveBank); } + +void atk50_openpartyscreen(void) +{ + u32 flags; + u8 hitmarkerFaintBits; + u8 bank; + const u8 *jumpPtr; + + bank = 0; + flags = 0; + jumpPtr = BSScriptReadPtr(gBattlescriptCurrInstr + 2); + + if (gBattlescriptCurrInstr[1] == 5) + { + if ((gBattleTypeFlags & (BATTLE_TYPE_DOUBLE | BATTLE_TYPE_MULTI)) != BATTLE_TYPE_DOUBLE) + { + for (gActiveBank = 0; gActiveBank < gNoOfAllBanks; gActiveBank++) + { + if (gHitMarker & HITMARKER_FAINTED(gActiveBank)) + { + if (sub_80423F4(gActiveBank, 6, 6)) + { + gAbsentBankFlags |= gBitTable[gActiveBank]; + gHitMarker &= ~(HITMARKER_FAINTED(gActiveBank)); + EmitLinkStandbyMsg(0, 2, 0); + MarkBufferBankForExecution(gActiveBank); + } + else if (!gSpecialStatuses[gActiveBank].flag40) + { + sub_804CF10(6); + gSpecialStatuses[gActiveBank].flag40 = 1; + } + } + else + { + EmitLinkStandbyMsg(0, 2, 0); + MarkBufferBankForExecution(gActiveBank); + } + } + } + else if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE) + { + u8 flag40_0, flag40_1, flag40_2, flag40_3; + + hitmarkerFaintBits = gHitMarker >> 0x1C; + + if (gBitTable[0] & hitmarkerFaintBits) + { + gActiveBank = 0; + if (sub_80423F4(0, 6, 6)) + { + gAbsentBankFlags |= gBitTable[gActiveBank]; + gHitMarker &= ~(HITMARKER_FAINTED(gActiveBank)); + Emit_x2A(0); + MarkBufferBankForExecution(gActiveBank); + } + else if (!gSpecialStatuses[gActiveBank].flag40) + { + sub_804CF10(gBattleStruct->field_5C[2]); + gSpecialStatuses[gActiveBank].flag40 = 1; + } + else + { + EmitLinkStandbyMsg(0, 2, 0); + MarkBufferBankForExecution(gActiveBank); + flags |= 1; + } + } + if (gBitTable[2] & hitmarkerFaintBits && !(gBitTable[0] & hitmarkerFaintBits)) + { + gActiveBank = 2; + if (sub_80423F4(2, 6, 6)) + { + gAbsentBankFlags |= gBitTable[gActiveBank]; + gHitMarker &= ~(HITMARKER_FAINTED(gActiveBank)); + Emit_x2A(0); + MarkBufferBankForExecution(gActiveBank); + } + else if (!gSpecialStatuses[gActiveBank].flag40) + { + sub_804CF10(gBattleStruct->field_5C[0]); + gSpecialStatuses[gActiveBank].flag40 = 1; + } + else if (!(flags & 1)) + { + EmitLinkStandbyMsg(0, 2, 0); + MarkBufferBankForExecution(gActiveBank); + } + } + if (gBitTable[1] & hitmarkerFaintBits) + { + gActiveBank = 1; + if (sub_80423F4(1, 6, 6)) + { + gAbsentBankFlags |= gBitTable[gActiveBank]; + gHitMarker &= ~(HITMARKER_FAINTED(gActiveBank)); + Emit_x2A(0); + MarkBufferBankForExecution(gActiveBank); + } + else if (!gSpecialStatuses[gActiveBank].flag40) + { + sub_804CF10(gBattleStruct->field_5C[3]); + gSpecialStatuses[gActiveBank].flag40 = 1; + } + else + { + EmitLinkStandbyMsg(0, 2, 0); + MarkBufferBankForExecution(gActiveBank); + flags |= 2; + } + } + if (gBitTable[3] & hitmarkerFaintBits && !(gBitTable[1] & hitmarkerFaintBits)) + { + gActiveBank = 3; + if (sub_80423F4(3, 6, 6)) + { + gAbsentBankFlags |= gBitTable[gActiveBank]; + gHitMarker &= ~(HITMARKER_FAINTED(gActiveBank)); + Emit_x2A(0); + MarkBufferBankForExecution(gActiveBank); + } + else if (!gSpecialStatuses[gActiveBank].flag40) + { + sub_804CF10(gBattleStruct->field_5C[1]); + gSpecialStatuses[gActiveBank].flag40 = 1; + } + else if (!(flags & 2)) + { + EmitLinkStandbyMsg(0, 2, 0); + MarkBufferBankForExecution(gActiveBank); + } + } + + flag40_0 = gSpecialStatuses[0].flag40; + if (!flag40_0) + { + flag40_2 = gSpecialStatuses[2].flag40; + if (!flag40_2 && hitmarkerFaintBits != 0) + { + if (gAbsentBankFlags & gBitTable[0]) + gActiveBank = 2; + else + gActiveBank = 0; + + EmitLinkStandbyMsg(0, 2, 0); + MarkBufferBankForExecution(gActiveBank); + } + + } + flag40_1 = gSpecialStatuses[1].flag40; + if (!flag40_1) + { + flag40_3 = gSpecialStatuses[3].flag40; + if (!flag40_3 && hitmarkerFaintBits != 0) + { + if (gAbsentBankFlags & gBitTable[1]) + gActiveBank = 3; + else + gActiveBank = 1; + + EmitLinkStandbyMsg(0, 2, 0); + MarkBufferBankForExecution(gActiveBank); + } + } + } + gBattlescriptCurrInstr += 6; + } + else if (gBattlescriptCurrInstr[1] == 6) + { + if (!(gBattleTypeFlags & BATTLE_TYPE_MULTI)) + { + if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE) + { + hitmarkerFaintBits = gHitMarker >> 0x1C; + if (gBitTable[2] & hitmarkerFaintBits && gBitTable[0] & hitmarkerFaintBits) + { + gActiveBank = 2; + if (sub_80423F4(2, gBattleBufferB[0][1], 6)) + { + gAbsentBankFlags |= gBitTable[gActiveBank]; + gHitMarker &= ~(HITMARKER_FAINTED(gActiveBank)); + Emit_x2A(0); + MarkBufferBankForExecution(gActiveBank); + } + else if (!gSpecialStatuses[gActiveBank].flag40) + { + sub_804CF10(gBattleStruct->field_5C[0]); + gSpecialStatuses[gActiveBank].flag40 = 1; + } + } + if (gBitTable[3] & hitmarkerFaintBits && hitmarkerFaintBits & gBitTable[1]) + { + gActiveBank = 3; + if (sub_80423F4(3, gBattleBufferB[1][1], 6)) + { + gAbsentBankFlags |= gBitTable[gActiveBank]; + gHitMarker &= ~(HITMARKER_FAINTED(gActiveBank)); + Emit_x2A(0); + MarkBufferBankForExecution(gActiveBank); + } + else if (!gSpecialStatuses[gActiveBank].flag40) + { + sub_804CF10(gBattleStruct->field_5C[1]); + gSpecialStatuses[gActiveBank].flag40 = 1; + } + } + gBattlescriptCurrInstr += 6; + } + else + { + gBattlescriptCurrInstr += 6; + } + } + else + { + gBattlescriptCurrInstr += 6; + } + + hitmarkerFaintBits = gHitMarker >> 0x1C; + + gBank1 = 0; + while (1) + { + if (gBitTable[gBank1] & hitmarkerFaintBits) + break; + if (gBank1 >= gNoOfAllBanks) + break; + gBank1++; + } + + if (gBank1 == gNoOfAllBanks) + gBattlescriptCurrInstr = jumpPtr; + } + else + { + if (gBattlescriptCurrInstr[1] & 0x80) + hitmarkerFaintBits = 0; // used here as the caseId for the EmitChoose function + else + hitmarkerFaintBits = 1; + + bank = GetBattleBank(gBattlescriptCurrInstr[1] & ~(0x80)); + if (gSpecialStatuses[bank].flag40) + { + gBattlescriptCurrInstr += 6; + } + else if (sub_80423F4(bank, 6, 6)) + { + gActiveBank = bank; + gAbsentBankFlags |= gBitTable[gActiveBank]; + gHitMarker &= ~(HITMARKER_FAINTED(gActiveBank)); + gBattlescriptCurrInstr = jumpPtr; + } + else + { + gActiveBank = bank; + *(gBattleStruct->field_58 + gActiveBank) = gBattlePartyID[gActiveBank]; + *(gBattleStruct->field_5C + gActiveBank) = 6; + gBattleStruct->field_93 &= ~(gBitTable[gActiveBank]); + + EmitChoosePokemon(0, hitmarkerFaintBits, *(gBattleStruct->field_5C + (gActiveBank ^ 2)), 0, gBattleStruct->field_60[gActiveBank]); + MarkBufferBankForExecution(gActiveBank); + + gBattlescriptCurrInstr += 6; + + if (GetBankIdentity(gActiveBank) == 0 && gBattleResults.playerSwitchesCounter < 0xFF) + gBattleResults.playerSwitchesCounter++; + + if (gBattleTypeFlags & BATTLE_TYPE_MULTI) + { + for (gActiveBank = 0; gActiveBank < gNoOfAllBanks; gActiveBank++) + { + if (gActiveBank != bank) + { + EmitLinkStandbyMsg(0, 2, 0); + MarkBufferBankForExecution(gActiveBank); + } + } + } + else + { + gActiveBank = GetBankByPlayerAI(GetBankIdentity(bank) ^ 1); + if (gAbsentBankFlags & gBitTable[gActiveBank]) + gActiveBank ^= 2; + + EmitLinkStandbyMsg(0, 2, 0); + MarkBufferBankForExecution(gActiveBank); + } + } + } +} + +void atk51_switch_handle_order(void) +{ + s32 i; + if (gBattleExecBuffer) + return; + + gActiveBank = GetBattleBank(BSScriptRead8(gBattlescriptCurrInstr + 1)); + + switch (BSScriptRead8(gBattlescriptCurrInstr + 2)) + { + case 0: + for (i = 0; i < gNoOfAllBanks; i++) + { + if (gBattleBufferB[i][0] == 0x22) + { + *(gBattleStruct->field_5C + i) = gBattleBufferB[i][1]; + if (!(gBattleStruct->field_93 & gBitTable[i])) + { + RecordedBattle_SetBankAction(i, gBattleBufferB[i][1]); + gBattleStruct->field_93 |= gBitTable[i]; + } + } + } + break; + case 1: + if (!(gBattleTypeFlags & BATTLE_TYPE_MULTI)) + sub_803BDA0(gActiveBank); + break; + case 2: + if (!(gBattleStruct->field_93 & gBitTable[gActiveBank])) + { + RecordedBattle_SetBankAction(gActiveBank, gBattleBufferB[gActiveBank][1]); + gBattleStruct->field_93 |= gBitTable[gActiveBank]; + } + // fall through + case 3: + gBattleCommunication[0] = gBattleBufferB[gActiveBank][1]; + *(gBattleStruct->field_5C + gActiveBank) = gBattleBufferB[gActiveBank][1]; + + if ((gBattleTypeFlags & (BATTLE_TYPE_MULTI | BATTLE_TYPE_LINK)) == (BATTLE_TYPE_MULTI | BATTLE_TYPE_LINK)) + { + *(gActiveBank * 3 + (u8*)(gBattleStruct->field_60) + 0) &= 0xF; + *(gActiveBank * 3 + (u8*)(gBattleStruct->field_60) + 0) |= (gBattleBufferB[gActiveBank][2] & 0xF0); + *(gActiveBank * 3 + (u8*)(gBattleStruct->field_60) + 1) = gBattleBufferB[gActiveBank][3]; + + *((gActiveBank ^ 2) * 3 + (u8*)(gBattleStruct->field_60) + 0) &= (0xF0); + *((gActiveBank ^ 2) * 3 + (u8*)(gBattleStruct->field_60) + 0) |= (gBattleBufferB[gActiveBank][2] & 0xF0) >> 4; + *((gActiveBank ^ 2) * 3 + (u8*)(gBattleStruct->field_60) + 2) = gBattleBufferB[gActiveBank][3]; + } + else if (gBattleTypeFlags & BATTLE_TYPE_INGAME_PARTNER) + { + sub_80571DC(gActiveBank, *(gBattleStruct->field_5C + gActiveBank)); + } + else + { + sub_803BDA0(gActiveBank); + } + + PREPARE_SPECIES_BUFFER(gBattleTextBuff1, gBattleMons[gBankAttacker].species) + PREPARE_MON_NICK_BUFFER(gBattleTextBuff2, gActiveBank, gBattleBufferB[gActiveBank][1]) + + break; + } + + gBattlescriptCurrInstr += 3; +} + +void atk52_switch_in_effects(void) +{ + s32 i; + + gActiveBank = GetBattleBank(BSScriptRead8(gBattlescriptCurrInstr + 1)); + sub_803FA70(gActiveBank); + + gHitMarker &= ~(HITMARKER_FAINTED(gActiveBank)); + gSpecialStatuses[gActiveBank].flag40 = 0; + + if (!(gSideAffecting[GetBankSide(gActiveBank)] & SIDE_STATUS_SPIKES_DAMAGED) + && (gSideAffecting[GetBankSide(gActiveBank)] & SIDE_STATUS_SPIKES) + && gBattleMons[gActiveBank].type1 != TYPE_FLYING + && gBattleMons[gActiveBank].type2 != TYPE_FLYING + && gBattleMons[gActiveBank].ability != ABILITY_LEVITATE) + { + u8 spikesDmg; + + gSideAffecting[GetBankSide(gActiveBank)] |= SIDE_STATUS_SPIKES_DAMAGED; + + gBattleMons[gActiveBank].status2 &= ~(STATUS2_DESTINY_BOND); + gHitMarker &= ~(HITMARKER_DESTINYBOND); + + spikesDmg = (5 - gSideTimers[GetBankSide(gActiveBank)].spikesAmount) * 2; + gBattleMoveDamage = gBattleMons[gActiveBank].maxHP / (spikesDmg); + if (gBattleMoveDamage == 0) + gBattleMoveDamage = 1; + + gBattleScripting.bank = gActiveBank; + BattleScriptPushCursor(); + + if (BSScriptRead8(gBattlescriptCurrInstr + 1) == 0) + gBattlescriptCurrInstr = gUnknown_082DAE90; + else if (BSScriptRead8(gBattlescriptCurrInstr + 1) == 1) + gBattlescriptCurrInstr = gUnknown_082DAE59; + else + gBattlescriptCurrInstr = gUnknown_082DAEC7; + } + else + { + if (gBattleMons[gActiveBank].ability == ABILITY_TRUANT && !gDisableStructs[gActiveBank].truantUnknownBit) + gDisableStructs[gActiveBank].truantCounter = 1; + + gDisableStructs[gActiveBank].truantUnknownBit = 0; + + if (AbilityBattleEffects(ABILITYEFFECT_ON_SWITCHIN, gActiveBank, 0, 0, 0) == 0 && + ItemBattleEffects(0, gActiveBank, 0) == 0) + { + gSideAffecting[GetBankSide(gActiveBank)] &= ~(SIDE_STATUS_SPIKES_DAMAGED); + + for (i = 0; i < gNoOfAllBanks; i++) + { + if (gTurnOrder[i] == gActiveBank) + gUnknown_0202407A[i] = 0xC; + } + + for (i = 0; i < gNoOfAllBanks; i++) + { + u16* hpOnSwitchout; + GET_HP_SWITCHOUT_PTR_VIA_MEME_ACCESS(GetBankSide(i), hpOnSwitchout) + *hpOnSwitchout = gBattleMons[i].hp; + } + + if (BSScriptRead8(gBattlescriptCurrInstr + 1) == 5) + { + u32 hitmarkerFaintBits = gHitMarker >> 0x1C; + + gBank1++; + while (1) + { + if (hitmarkerFaintBits & gBitTable[gBank1] && !(gAbsentBankFlags & gBitTable[gBank1])) + break; + if (gBank1 >= gNoOfAllBanks) + break; + gBank1++; + } + } + gBattlescriptCurrInstr += 2; + } + } +} + +void atk53_trainer_slide(void) +{ + gActiveBank = GetBankByPlayerAI(gBattlescriptCurrInstr[1]); + EmitTrainerSlide(0); + MarkBufferBankForExecution(gActiveBank); + + gBattlescriptCurrInstr += 2; +} + +void atk54_effectiveness_sound(void) +{ + gActiveBank = gBankAttacker; + EmitEffectivenessSound(0, BS2ScriptRead16(gBattlescriptCurrInstr + 1)); + MarkBufferBankForExecution(gActiveBank); + + gBattlescriptCurrInstr += 3; +} + +void atk55_play_sound(void) +{ + gActiveBank = gBankAttacker; + EmitPlaySound(0, BS2ScriptRead16(gBattlescriptCurrInstr + 1), 0); + MarkBufferBankForExecution(gActiveBank); + + gBattlescriptCurrInstr += 3; +} + +void atk56_fainting_cry(void) +{ + gActiveBank = GetBattleBank(BSScriptRead8(gBattlescriptCurrInstr + 1)); + EmitFaintingCry(0); + MarkBufferBankForExecution(gActiveBank); + + gBattlescriptCurrInstr += 2; +} + +void atk57(void) +{ + gActiveBank = GetBankByPlayerAI(0); + Emit_x37(0, gBattleOutcome); + MarkBufferBankForExecution(gActiveBank); + + gBattlescriptCurrInstr += 1; +} + +void atk58_return_to_ball(void) +{ + gActiveBank = GetBattleBank(BSScriptRead8(gBattlescriptCurrInstr + 1)); + EmitReturnPokeToBall(0, 1); + MarkBufferBankForExecution(gActiveBank); + + gBattlescriptCurrInstr += 2; +} + +void atk59_learnmove_inbattle(void) +{ + const u8* jumpPtr1 = BSScriptReadPtr(gBattlescriptCurrInstr + 1); + const u8* jumpPtr2 = BSScriptReadPtr(gBattlescriptCurrInstr + 5); + + u16 ret = MonTryLearningNewMove(&gPlayerParty[gBattleStruct->expGetterId], BSScriptRead8(gBattlescriptCurrInstr + 9)); + while (ret == 0xFFFE) + ret = MonTryLearningNewMove(&gPlayerParty[gBattleStruct->expGetterId], 0); + + if (ret == 0) + { + gBattlescriptCurrInstr = jumpPtr2; + } + else if (ret == 0xFFFF) + { + gBattlescriptCurrInstr += 10; + } + else + { + gActiveBank = GetBankByPlayerAI(0); + + if (gBattlePartyID[gActiveBank] == gBattleStruct->expGetterId + && !(gBattleMons[gActiveBank].status2 & STATUS2_TRANSFORMED)) + { + GiveMoveToBattleMon(&gBattleMons[gActiveBank], ret); + } + if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE) + { + gActiveBank = GetBankByPlayerAI(2); + if (gBattlePartyID[gActiveBank] == gBattleStruct->expGetterId + && !(gBattleMons[gActiveBank].status2 & STATUS2_TRANSFORMED)) + { + GiveMoveToBattleMon(&gBattleMons[gActiveBank], ret); + } + } + + gBattlescriptCurrInstr = jumpPtr1; + } +} + +void atk5A_yesnoboxlearnmove(void) +{ + gActiveBank = 0; + + switch (gBattleScripting.learnMoveState) + { + case 0: + sub_8056A3C(0x18, 8, 0x1D, 0xD, 0); + sub_814F9EC(gText_BattleYesNoChoice, 0xC); + gBattleScripting.learnMoveState++; + gBattleCommunication[CURSOR_POSITION] = 0; + BattleCreateCursorAt(0); + break; + case 1: + if (gMain.newKeys & DPAD_UP && gBattleCommunication[CURSOR_POSITION] != 0) + { + PlaySE(SE_SELECT); + BattleDestroyCursorAt(gBattleCommunication[CURSOR_POSITION]); + gBattleCommunication[CURSOR_POSITION] = 0; + BattleCreateCursorAt(0); + } + if (gMain.newKeys & DPAD_DOWN && gBattleCommunication[CURSOR_POSITION] == 0) + { + PlaySE(SE_SELECT); + BattleDestroyCursorAt(gBattleCommunication[CURSOR_POSITION]); + gBattleCommunication[CURSOR_POSITION] = 1; + BattleCreateCursorAt(1); + } + if (gMain.newKeys & A_BUTTON) + { + PlaySE(SE_SELECT); + if (gBattleCommunication[1] == 0) + { + sub_8056A3C(0x18, 0x8, 0x1D, 0xD, 1); + BeginNormalPaletteFade(-1, 0, 0, 0x10, 0); + gBattleScripting.learnMoveState++; + } + else + { + gBattleScripting.learnMoveState = 5; + } + } + else if (gMain.newKeys & B_BUTTON) + { + PlaySE(SE_SELECT); + gBattleScripting.learnMoveState = 5; + } + break; + case 2: + if (!gPaletteFade.active) + { + FreeAllWindowBuffers(); + sub_81BFA38(gPlayerParty, gBattleStruct->expGetterId, gPlayerPartyCount - 1, ReshowBattleScreenAfterMenu, gMoveToLearn); + gBattleScripting.learnMoveState++; + } + break; + case 3: + if (!gPaletteFade.active && gMain.callback2 == BattleMainCB2) + { + gBattleScripting.learnMoveState++; + } + break; + case 4: + if (!gPaletteFade.active && gMain.callback2 == BattleMainCB2) + { + u8 movePosition = sub_81C1B94(); + if (movePosition == 4) + { + gBattleScripting.learnMoveState = 5; + } + else + { + u16 moveId = GetMonData(&gPlayerParty[gBattleStruct->expGetterId], MON_DATA_MOVE1 + movePosition); + if (IsHMMove2(moveId)) + { + PrepareStringBattle(0x13F, gActiveBank); + gBattleScripting.learnMoveState = 6; + } + else + { + gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); + + PREPARE_MOVE_BUFFER(gBattleTextBuff2, moveId) + + RemoveMonPPBonus(&gPlayerParty[gBattleStruct->expGetterId], movePosition); + SetMonMoveSlot(&gPlayerParty[gBattleStruct->expGetterId], gMoveToLearn, movePosition); + + if (gBattlePartyID[0] == gBattleStruct->expGetterId + && !(gBattleMons[0].status2 & STATUS2_TRANSFORMED) + && !(gDisableStructs[0].unk18_b & gBitTable[movePosition])) + { + RemoveBattleMonPPBonus(&gBattleMons[0], movePosition); + SetBattleMonMoveSlot(&gBattleMons[0], gMoveToLearn, movePosition); + } + if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE + && gBattlePartyID[2] == gBattleStruct->expGetterId + && !(gBattleMons[2].status2 & STATUS2_TRANSFORMED) + && !(gDisableStructs[2].unk18_b & gBitTable[movePosition])) + { + RemoveBattleMonPPBonus(&gBattleMons[2], movePosition); + SetBattleMonMoveSlot(&gBattleMons[2], gMoveToLearn, movePosition); + } + } + } + } + break; + case 5: + sub_8056A3C(0x18, 8, 0x1D, 0xD, 1); + gBattlescriptCurrInstr += 5; + break; + case 6: + if (gBattleExecBuffer == 0) + { + gBattleScripting.learnMoveState = 2; + } + break; + } +} + +void atk5B_yesnoboxstoplearningmove(void) +{ + switch (gBattleScripting.learnMoveState) + { + case 0: + sub_8056A3C(0x18, 8, 0x1D, 0xD, 0); + sub_814F9EC(gText_BattleYesNoChoice, 0xC); + gBattleScripting.learnMoveState++; + gBattleCommunication[CURSOR_POSITION] = 0; + BattleCreateCursorAt(0); + break; + case 1: + if (gMain.newKeys & DPAD_UP && gBattleCommunication[CURSOR_POSITION] != 0) + { + PlaySE(SE_SELECT); + BattleDestroyCursorAt(gBattleCommunication[CURSOR_POSITION]); + gBattleCommunication[CURSOR_POSITION] = 0; + BattleCreateCursorAt(0); + } + if (gMain.newKeys & DPAD_DOWN && gBattleCommunication[CURSOR_POSITION] == 0) + { + PlaySE(SE_SELECT); + BattleDestroyCursorAt(gBattleCommunication[CURSOR_POSITION]); + gBattleCommunication[CURSOR_POSITION] = 1; + BattleCreateCursorAt(1); + } + if (gMain.newKeys & A_BUTTON) + { + PlaySE(SE_SELECT); + + if (gBattleCommunication[1] != 0) + gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); + else + gBattlescriptCurrInstr += 5; + + sub_8056A3C(0x18, 0x8, 0x1D, 0xD, 1); + } + else if (gMain.newKeys & B_BUTTON) + { + PlaySE(SE_SELECT); + gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); + sub_8056A3C(0x18, 0x8, 0x1D, 0xD, 1); + } + break; + } +} + +void atk5C_hitanimation(void) +{ + gActiveBank = GetBattleBank(BSScriptRead8(gBattlescriptCurrInstr + 1)); + + if (gBattleMoveFlags & MOVESTATUS_NOEFFECT) + { + gBattlescriptCurrInstr += 2; + } + else if (!(gHitMarker & HITMARKER_IGNORE_SUBSTITUTE) || !(gBattleMons[gActiveBank].status2 & STATUS2_SUBSTITUTE) || gDisableStructs[gActiveBank].substituteHP == 0) + { + EmitHitAnimation(0); + MarkBufferBankForExecution(gActiveBank); + gBattlescriptCurrInstr += 2; + } + else + { + gBattlescriptCurrInstr += 2; + } +} + +static u32 GetTrainerMoneyToGive(u16 trainerId) +{ + u32 i = 0; + u32 lastMonLevel = 0; + u32 moneyReward = 0; + + if (trainerId == SECRET_BASE_OPPONENT) + { + moneyReward = 20 * gBattleResources->secretBase->partyLevels[0] * gBattleStruct->moneyMultiplier; + } + else + { + switch (gTrainers[trainerId].partyFlags) + { + case 0: + { + const struct TrainerMonNoItemDefaultMoves *party = gTrainers[trainerId].party.NoItemDefaultMoves; + lastMonLevel = party[gTrainers[trainerId].partySize - 1].lvl; + } + break; + case PARTY_FLAG_CUSTOM_MOVES: + { + const struct TrainerMonNoItemCustomMoves *party = gTrainers[trainerId].party.NoItemCustomMoves; + lastMonLevel = party[gTrainers[trainerId].partySize - 1].lvl; + } + break; + case PARTY_FLAG_HAS_ITEM: + { + const struct TrainerMonItemDefaultMoves *party = gTrainers[trainerId].party.ItemDefaultMoves; + lastMonLevel = party[gTrainers[trainerId].partySize - 1].lvl; + } + break; + case PARTY_FLAG_CUSTOM_MOVES | PARTY_FLAG_HAS_ITEM: + { + const struct TrainerMonItemCustomMoves *party = gTrainers[trainerId].party.ItemCustomMoves; + lastMonLevel = party[gTrainers[trainerId].partySize - 1].lvl; + } + break; + } + + for (; gTrainerMoneyTable[i].classId != 0xFF; i++) + { + if (gTrainerMoneyTable[i].classId == gTrainers[trainerId].trainerClass) + break; + } + + if (gBattleTypeFlags & BATTLE_TYPE_TWO_OPPONENTS) + moneyReward = 4 * lastMonLevel * gBattleStruct->moneyMultiplier * gTrainerMoneyTable[i].value; + else if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE) + moneyReward = 4 * lastMonLevel * gBattleStruct->moneyMultiplier * 2 * gTrainerMoneyTable[i].value; + else + moneyReward = 4 * lastMonLevel * gBattleStruct->moneyMultiplier * gTrainerMoneyTable[i].value; + } + + return moneyReward; +} + +void atk5D_getmoneyreward(void) +{ + u32 moneyReward = GetTrainerMoneyToGive(gTrainerBattleOpponent_A); + if (gBattleTypeFlags & BATTLE_TYPE_TWO_OPPONENTS) + moneyReward += GetTrainerMoneyToGive(gTrainerBattleOpponent_B); + + AddMoney(&gSaveBlock1Ptr->money, moneyReward); + + PREPARE_WORD_NUMBER_BUFFER(gBattleTextBuff1, 5, moneyReward) + + gBattlescriptCurrInstr++; +} + +void atk5E_8025A70(void) +{ + gActiveBank = GetBattleBank(BSScriptRead8(gBattlescriptCurrInstr + 1)); + + switch (gBattleCommunication[0]) + { + case 0: + EmitGetAttributes(0, REQUEST_ALL_BATTLE, 0); + MarkBufferBankForExecution(gActiveBank); + gBattleCommunication[0]++; + break; + case 1: + if (gBattleExecBuffer == 0) + { + s32 i; + struct BattlePokemon* bufferPoke = (struct BattlePokemon*) &gBattleBufferB[gActiveBank][4]; + for (i = 0; i < 4; i++) + { + gBattleMons[gActiveBank].moves[i] = bufferPoke->moves[i]; + gBattleMons[gActiveBank].pp[i] = bufferPoke->pp[i]; + } + gBattlescriptCurrInstr += 2; + } + break; + } +} + +void atk5F_8025B24(void) +{ + gActiveBank = gBankAttacker; + gBankAttacker = gBankTarget; + gBankTarget = gActiveBank; + + if (gHitMarker & HITMARKER_PURSUIT_TRAP) + gHitMarker &= ~(HITMARKER_PURSUIT_TRAP); + else + gHitMarker |= HITMARKER_PURSUIT_TRAP; + + gBattlescriptCurrInstr++; +} + +void atk60_increment_gamestat(void) +{ + if (GetBankSide(gBankAttacker) == SIDE_PLAYER) + IncrementGameStat(BSScriptRead8(gBattlescriptCurrInstr + 1)); + + gBattlescriptCurrInstr += 2; +} + +void atk61_8025BA4(void) +{ + s32 i; + struct Pokemon* party; + struct HpAndStatus hpStatuses[6]; + + if (gBattleExecBuffer) + return; + + gActiveBank = GetBattleBank(BSScriptRead8(gBattlescriptCurrInstr + 1)); + + if (GetBankSide(gActiveBank) == SIDE_PLAYER) + party = gPlayerParty; + else + party = gEnemyParty; + + for (i = 0; i < 6; i++) + { + if (GetMonData(&party[i], MON_DATA_SPECIES2) == SPECIES_NONE + || GetMonData(&party[i], MON_DATA_SPECIES2) == SPECIES_EGG) + { + hpStatuses[i].hp = 0xFFFF; + hpStatuses[i].status = 0; + } + else + { + hpStatuses[i].hp = GetMonData(&party[i], MON_DATA_HP); + hpStatuses[i].status = GetMonData(&party[i], MON_DATA_STATUS); + } + } + + EmitCmd48(0, hpStatuses, 1); + MarkBufferBankForExecution(gActiveBank); + + gBattlescriptCurrInstr += 2; +} + +void atk62_08025C6C(void) +{ + gActiveBank = GetBattleBank(BSScriptRead8(gBattlescriptCurrInstr + 1)); + EmitCmd49(0); + MarkBufferBankForExecution(gActiveBank); + + gBattlescriptCurrInstr += 2; +} + +void atk63_jumptorandomattack(void) +{ + if (BSScriptRead8(gBattlescriptCurrInstr + 1) != 0) + gCurrentMove = gRandomMove; + else + gLastUsedMove = gCurrentMove = gRandomMove; + + gBattlescriptCurrInstr = gBattleScriptsForMoveEffects[gBattleMoves[gCurrentMove].effect]; +} + +void atk64_statusanimation(void) +{ + if (gBattleExecBuffer == 0) + { + gActiveBank = GetBattleBank(BSScriptRead8(gBattlescriptCurrInstr + 1)); + if (!(gStatuses3[gActiveBank] & STATUS3_SEMI_INVULNERABLE) + && gDisableStructs[gActiveBank].substituteHP == 0 + && !(gHitMarker & HITMARKER_NO_ANIMATIONS)) + { + EmitStatusAnimation(0, FALSE, gBattleMons[gActiveBank].status1); + MarkBufferBankForExecution(gActiveBank); + } + gBattlescriptCurrInstr += 2; + } +} + +void atk65_status2animation(void) +{ + u32 wantedToAnimate; + + if (gBattleExecBuffer == 0) + { + gActiveBank = GetBattleBank(BSScriptRead8(gBattlescriptCurrInstr + 1)); + wantedToAnimate = BSScriptRead32(gBattlescriptCurrInstr + 2); + if (!(gStatuses3[gActiveBank] & STATUS3_SEMI_INVULNERABLE) + && gDisableStructs[gActiveBank].substituteHP == 0 + && !(gHitMarker & HITMARKER_NO_ANIMATIONS)) + { + EmitStatusAnimation(0, TRUE, gBattleMons[gActiveBank].status2 & wantedToAnimate); + MarkBufferBankForExecution(gActiveBank); + } + gBattlescriptCurrInstr += 6; + } +} + +void atk66_chosenstatusanimation(void) +{ + u32 wantedStatus; + + if (gBattleExecBuffer == 0) + { + gActiveBank = GetBattleBank(BSScriptRead8(gBattlescriptCurrInstr + 1)); + wantedStatus = BSScriptRead32(gBattlescriptCurrInstr + 3); + if (!(gStatuses3[gActiveBank] & STATUS3_SEMI_INVULNERABLE) + && gDisableStructs[gActiveBank].substituteHP == 0 + && !(gHitMarker & HITMARKER_NO_ANIMATIONS)) + { + EmitStatusAnimation(0, BSScriptRead8(gBattlescriptCurrInstr + 2), wantedStatus); + MarkBufferBankForExecution(gActiveBank); + } + gBattlescriptCurrInstr += 7; + } +} + +void atk67_yesnobox(void) +{ + switch (gBattleCommunication[0]) + { + case 0: + sub_8056A3C(0x18, 8, 0x1D, 0xD, 0); + sub_814F9EC(gText_BattleYesNoChoice, 0xC); + gBattleCommunication[0]++; + gBattleCommunication[CURSOR_POSITION] = 0; + BattleCreateCursorAt(0); + break; + case 1: + if (gMain.newKeys & DPAD_UP && gBattleCommunication[CURSOR_POSITION] != 0) + { + PlaySE(SE_SELECT); + BattleDestroyCursorAt(gBattleCommunication[CURSOR_POSITION]); + gBattleCommunication[CURSOR_POSITION] = 0; + BattleCreateCursorAt(0); + } + if (gMain.newKeys & DPAD_DOWN && gBattleCommunication[CURSOR_POSITION] == 0) + { + PlaySE(SE_SELECT); + BattleDestroyCursorAt(gBattleCommunication[CURSOR_POSITION]); + gBattleCommunication[CURSOR_POSITION] = 1; + BattleCreateCursorAt(1); + } + if (gMain.newKeys & B_BUTTON) + { + gBattleCommunication[CURSOR_POSITION] = 1; + PlaySE(SE_SELECT); + sub_8056A3C(0x18, 8, 0x1D, 0xD, 1); + gBattlescriptCurrInstr++; + } + else if (gMain.newKeys & A_BUTTON) + { + PlaySE(SE_SELECT); + sub_8056A3C(0x18, 8, 0x1D, 0xD, 1); + gBattlescriptCurrInstr++; + } + break; + } +} + +void atk68_80246A0(void) +{ + s32 i; + + for (i = 0; i < gNoOfAllBanks; i++) + gUnknown_0202407A[i] = 0xC; + + gBattlescriptCurrInstr++; +} + +void atk69_dmg_adjustment3(void) // The same as 0x7, except there's no random damage multiplier. +{ + u8 holdEffect, quality; + + if (gBattleMons[gBankTarget].item == ITEM_ENIGMA_BERRY) + { + holdEffect = gEnigmaBerries[gBankTarget].holdEffect, quality = gEnigmaBerries[gBankTarget].holdEffectParam; + } + else + { + holdEffect = ItemId_GetHoldEffect(gBattleMons[gBankTarget].item); + quality = ItemId_GetHoldEffectParam(gBattleMons[gBankTarget].item); + } + + gStringBank = gBankTarget; + + if (holdEffect == HOLD_EFFECT_FOCUS_BAND && (Random() % 100) < quality) + { + RecordItemEffectBattle(gBankTarget, holdEffect); + gSpecialStatuses[gBankTarget].focusBanded = 1; + } + if (gBattleMons[gBankTarget].status2 & STATUS2_SUBSTITUTE) + goto END; + if (gBattleMoves[gCurrentMove].effect != EFFECT_FALSE_SWIPE && !gProtectStructs[gBankTarget].endured + && !gSpecialStatuses[gBankTarget].focusBanded) + goto END; + + if (gBattleMons[gBankTarget].hp > gBattleMoveDamage) + goto END; + + gBattleMoveDamage = gBattleMons[gBankTarget].hp - 1; + + if (gProtectStructs[gBankTarget].endured) + { + gBattleMoveFlags |= MOVESTATUS_ENDURED; + } + else if (gSpecialStatuses[gBankTarget].focusBanded) + { + gBattleMoveFlags |= MOVESTATUS_HUNGON; + gLastUsedItem = gBattleMons[gBankTarget].item; + } + + END: + gBattlescriptCurrInstr++; +} diff --git a/src/pokemon_3.c b/src/pokemon_3.c index 2bc06c580..aaa02c5d4 100644 --- a/src/pokemon_3.c +++ b/src/pokemon_3.c @@ -1374,7 +1374,7 @@ void sub_806E994(void) gBattleTextBuff2[2] = gBankInMenu; gBattleTextBuff2[3] = pokemon_order_func(gBattlePartyID[gBankInMenu]); gBattleTextBuff2[4] = EOS; - StrCpyDecodeBattle(gText_PkmnsXPreventsSwitching, gStringVar4); + BattleStringExpandPlaceholders(gText_PkmnsXPreventsSwitching, gStringVar4); } struct PokeItem