From 170b6ef44992f4b7decb31451a3756b6bd4e2d46 Mon Sep 17 00:00:00 2001 From: Marcus Huderle Date: Wed, 12 Dec 2018 23:18:25 -0600 Subject: [PATCH] Decompile battle_intro.c (#444) --- asm/battle_intro.s | 2035 ------------------------------- data/data2c.s | 5 +- include/battle_anim.h | 12 +- include/gba/types.h | 4 +- ld_script.txt | 2 +- src/battle_anim_utility_funcs.c | 8 +- src/battle_intro.c | 742 ++++++++++- src/battle_main.c | 4 +- src/easy_chat.c | 3 + sym_ewram.txt | 15 +- 10 files changed, 752 insertions(+), 2078 deletions(-) delete mode 100644 asm/battle_intro.s diff --git a/asm/battle_intro.s b/asm/battle_intro.s deleted file mode 100644 index 04a0301ce..000000000 --- a/asm/battle_intro.s +++ /dev/null @@ -1,2035 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .syntax unified - - .text - - thumb_func_start SetAnimBgAttribute -SetAnimBgAttribute: @ 811802C - push {r4-r6,lr} - lsls r0, 24 - lsrs r6, r0, 24 - lsls r1, 24 - lsrs r5, r1, 24 - lsls r2, 24 - lsrs r4, r2, 24 - cmp r6, 0x3 - bls _08118040 - b _08118132 -_08118040: - ldr r0, =gUnknown_0859741A - adds r0, r6, r0 - ldrb r0, [r0] - bl GetGpuReg - ldr r1, =gUnknown_0203A114 - strh r0, [r1] - cmp r5, 0x6 - bhi _08118124 - lsls r0, r5, 2 - ldr r1, =_08118068 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_08118068: - .4byte _08118084 - .4byte _08118098 - .4byte _081180B0 - .4byte _081180C8 - .4byte _081180E0 - .4byte _081180FC - .4byte _08118110 -_08118084: - ldr r2, =gUnknown_0203A114 - lsls r3, r4, 6 - ldrb r1, [r2, 0x1] - movs r0, 0x3F - ands r0, r1 - orrs r0, r3 - strb r0, [r2, 0x1] - b _08118124 - .pool -_08118098: - ldr r3, =gUnknown_0203A114 - movs r0, 0x1 - adds r1, r4, 0 - ands r1, r0 - lsls r1, 5 - ldrb r2, [r3, 0x1] - movs r0, 0x21 - negs r0, r0 - b _0811811E - .pool -_081180B0: - ldr r3, =gUnknown_0203A114 - movs r0, 0x1 - adds r1, r4, 0 - ands r1, r0 - lsls r1, 6 - ldrb r2, [r3] - movs r0, 0x41 - negs r0, r0 - b _081180EE - .pool -_081180C8: - ldr r3, =gUnknown_0203A114 - movs r0, 0x3 - adds r1, r4, 0 - ands r1, r0 - lsls r1, 2 - ldrb r2, [r3] - movs r0, 0xD - negs r0, r0 - b _081180EE - .pool -_081180E0: - ldr r3, =gUnknown_0203A114 - movs r0, 0x3 - adds r1, r4, 0 - ands r1, r0 - ldrb r2, [r3] - movs r0, 0x4 - negs r0, r0 -_081180EE: - ands r0, r2 - orrs r0, r1 - strb r0, [r3] - b _08118124 - .pool -_081180FC: - ldr r2, =gUnknown_0203A114 - lsls r3, r4, 7 - ldrb r1, [r2] - movs r0, 0x7F - ands r0, r1 - orrs r0, r3 - strb r0, [r2] - b _08118124 - .pool -_08118110: - ldr r3, =gUnknown_0203A114 - movs r0, 0x1F - adds r1, r4, 0 - ands r1, r0 - ldrb r2, [r3, 0x1] - movs r0, 0x20 - negs r0, r0 -_0811811E: - ands r0, r2 - orrs r0, r1 - strb r0, [r3, 0x1] -_08118124: - ldr r0, =gUnknown_0859741A - adds r0, r6, r0 - ldrb r0, [r0] - ldr r1, =gUnknown_0203A114 - ldrh r1, [r1] - bl SetGpuReg -_08118132: - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end SetAnimBgAttribute - - thumb_func_start GetAnimBgAttribute -GetAnimBgAttribute: @ 8118140 - push {r4,lr} - sub sp, 0x4 - lsls r0, 24 - lsrs r2, r0, 24 - lsls r1, 24 - lsrs r4, r1, 24 - cmp r2, 0x3 - bhi _081181C8 - ldr r0, =gUnknown_0859741E - adds r0, r2, r0 - ldrb r0, [r0] - bl GetGpuReg - mov r1, sp - strh r0, [r1] - cmp r4, 0x6 - bhi _081181C8 - lsls r0, r4, 2 - ldr r1, =_08118174 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_08118174: - .4byte _08118190 - .4byte _08118198 - .4byte _081181A0 - .4byte _081181A8 - .4byte _081181B0 - .4byte _081181B8 - .4byte _081181C0 -_08118190: - ldr r0, [sp] - lsls r0, 16 - lsrs r0, 30 - b _081181CA -_08118198: - ldr r0, [sp] - lsls r0, 18 - lsrs r0, 31 - b _081181CA -_081181A0: - ldr r0, [sp] - lsls r0, 25 - lsrs r0, 31 - b _081181CA -_081181A8: - ldr r0, [sp] - lsls r0, 28 - lsrs r0, 30 - b _081181CA -_081181B0: - ldr r0, [sp] - lsls r0, 30 - lsrs r0, 30 - b _081181CA -_081181B8: - ldr r0, [sp] - lsls r0, 24 - lsrs r0, 31 - b _081181CA -_081181C0: - ldr r0, [sp] - lsls r0, 19 - lsrs r0, 27 - b _081181CA -_081181C8: - movs r0, 0 -_081181CA: - add sp, 0x4 - pop {r4} - pop {r1} - bx r1 - thumb_func_end GetAnimBgAttribute - - thumb_func_start HandleIntroSlide -HandleIntroSlide: @ 81181D4 - push {r4,lr} - lsls r0, 24 - lsrs r4, r0, 24 - ldr r2, =gBattleTypeFlags - ldr r0, [r2] - movs r1, 0x80 - lsls r1, 15 - ands r0, r1 - cmp r0, 0 - beq _08118208 - ldr r0, =gPartnerTrainerId - ldrh r1, [r0] - ldr r0, =0x00000c03 - cmp r1, r0 - beq _08118208 - ldr r0, =sub_8118D68 - b _08118258 - .pool -_08118208: - ldr r2, [r2] - movs r0, 0x2 - ands r0, r2 - cmp r0, 0 - beq _0811821C - ldr r0, =task00_battle_intro_wireless - b _08118258 - .pool -_0811821C: - ldr r0, =0x003f0100 - ands r0, r2 - cmp r0, 0 - beq _08118230 - ldr r0, =task_battle_intro_anim - b _08118258 - .pool -_08118230: - movs r0, 0x80 - lsls r0, 5 - ands r2, r0 - cmp r2, 0 - beq _08118250 - ldr r0, =gGameVersion - ldrb r0, [r0] - cmp r0, 0x2 - beq _08118250 - movs r4, 0x3 - ldr r0, =task00_battle_intro_80BC6C8 - b _08118258 - .pool -_08118250: - ldr r1, =gUnknown_08597424 - lsls r0, r4, 2 - adds r0, r1 - ldr r0, [r0] -_08118258: - movs r1, 0 - bl CreateTask - lsls r0, 24 - lsrs r2, r0, 24 - ldr r0, =gTasks - lsls r1, r2, 2 - adds r1, r2 - lsls r1, 3 - adds r1, r0 - movs r0, 0 - strh r0, [r1, 0x8] - strh r4, [r1, 0xA] - strh r0, [r1, 0xC] - strh r0, [r1, 0xE] - strh r0, [r1, 0x10] - strh r0, [r1, 0x12] - strh r0, [r1, 0x14] - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end HandleIntroSlide - - thumb_func_start sub_811828C -sub_811828C: @ 811828C - push {r4,lr} - lsls r0, 24 - lsrs r0, 24 - bl DestroyTask - ldr r0, =gBattle_BG1_X - movs r1, 0 - strh r1, [r0] - ldr r0, =gBattle_BG1_Y - strh r1, [r0] - ldr r0, =gBattle_BG2_X - strh r1, [r0] - ldr r0, =gBattle_BG2_Y - strh r1, [r0] - movs r0, 0x50 - movs r1, 0 - bl SetGpuReg - movs r0, 0x52 - movs r1, 0 - bl SetGpuReg - movs r0, 0x54 - movs r1, 0 - bl SetGpuReg - ldr r4, =0x00003f3f - movs r0, 0x48 - adds r1, r4, 0 - bl SetGpuReg - movs r0, 0x4A - adds r1, r4, 0 - bl SetGpuReg - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_811828C - - thumb_func_start task_battle_intro_80BC47C -task_battle_intro_80BC47C: @ 81182EC - push {r4-r7,lr} - mov r7, r9 - mov r6, r8 - push {r6,r7} - sub sp, 0x4 - lsls r0, 24 - lsrs r4, r0, 24 - ldr r1, =gBattle_BG1_X - ldrh r0, [r1] - adds r0, 0x6 - strh r0, [r1] - ldr r1, =gTasks - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - adds r0, r1 - movs r2, 0x8 - ldrsh r0, [r0, r2] - mov r8, r1 - cmp r0, 0x4 - bls _08118318 - b _0811852A -_08118318: - lsls r0, 2 - ldr r1, =_08118330 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_08118330: - .4byte _08118344 - .4byte _08118374 - .4byte _0811839C - .4byte _081183E4 - .4byte _08118524 -_08118344: - ldr r0, =gBattleTypeFlags - ldr r0, [r0] - movs r1, 0x2 - ands r0, r1 - cmp r0, 0 - beq _08118360 - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - add r0, r8 - movs r1, 0x10 - b _0811836A - .pool -_08118360: - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - add r0, r8 - movs r1, 0x1 -_0811836A: - strh r1, [r0, 0xC] - ldrh r1, [r0, 0x8] - adds r1, 0x1 - strh r1, [r0, 0x8] - b _0811852A -_08118374: - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - mov r3, r8 - adds r1, r0, r3 - ldrh r0, [r1, 0xC] - subs r0, 0x1 - strh r0, [r1, 0xC] - lsls r0, 16 - cmp r0, 0 - beq _0811838C - b _0811852A -_0811838C: - ldrh r0, [r1, 0x8] - adds r0, 0x1 - strh r0, [r1, 0x8] - movs r0, 0x48 - movs r1, 0x3F - bl SetGpuReg - b _0811852A -_0811839C: - ldr r1, =gBattle_WIN0V - ldrh r0, [r1] - subs r0, 0xFF - strh r0, [r1] - movs r1, 0xFF - lsls r1, 8 - ands r0, r1 - movs r1, 0xC0 - lsls r1, 6 - cmp r0, r1 - beq _081183B4 - b _0811852A -_081183B4: - lsls r1, r4, 2 - adds r1, r4 - lsls r1, 3 - add r1, r8 - ldrh r0, [r1, 0x8] - adds r0, 0x1 - strh r0, [r1, 0x8] - movs r0, 0xF0 - strh r0, [r1, 0xC] - movs r0, 0x20 - strh r0, [r1, 0xE] - ldr r2, =gIntroSlideFlags - ldrh r1, [r2] - ldr r0, =0x0000fffe - ands r0, r1 - strh r0, [r2] - b _0811852A - .pool -_081183E4: - lsls r0, r4, 2 - adds r1, r0, r4 - lsls r1, 3 - mov r5, r8 - adds r2, r1, r5 - ldrh r3, [r2, 0xE] - movs r5, 0xE - ldrsh r1, [r2, r5] - mov r12, r0 - cmp r1, 0 - beq _08118400 - subs r0, r3, 0x1 - strh r0, [r2, 0xE] - b _0811842E -_08118400: - movs r1, 0xA - ldrsh r0, [r2, r1] - cmp r0, 0x1 - bne _08118420 - ldr r2, =gBattle_BG1_Y - ldrh r1, [r2] - ldr r0, =0x0000ffb0 - cmp r1, r0 - beq _0811842E - subs r0, r1, 0x2 - b _0811842C - .pool -_08118420: - ldr r2, =gBattle_BG1_Y - ldrh r1, [r2] - ldr r0, =0x0000ffc8 - cmp r1, r0 - beq _0811842E - subs r0, r1, 0x1 -_0811842C: - strh r0, [r2] -_0811842E: - ldr r2, =gBattle_WIN0V - ldrh r1, [r2] - movs r0, 0xFF - lsls r0, 8 - ands r0, r1 - cmp r0, 0 - beq _08118442 - ldr r3, =0xfffffc04 - adds r0, r1, r3 - strh r0, [r2] -_08118442: - mov r5, r12 - adds r0, r5, r4 - lsls r0, 3 - mov r2, r8 - adds r1, r0, r2 - ldrh r2, [r1, 0xC] - movs r3, 0xC - ldrsh r0, [r1, r3] - cmp r0, 0 - beq _0811845A - subs r0, r2, 0x2 - strh r0, [r1, 0xC] -_0811845A: - movs r3, 0 - ldr r5, =gScanlineEffect - mov r9, r5 - ldr r7, =gScanlineEffectRegBuffers - mov r6, r9 - adds r5, r1, 0 -_08118466: - lsls r2, r3, 1 - ldrb r1, [r6, 0x14] - lsls r0, r1, 4 - subs r0, r1 - lsls r0, 7 - adds r2, r0 - adds r2, r7 - ldrh r0, [r5, 0xC] - strh r0, [r2] - adds r3, 0x1 - cmp r3, 0x4F - ble _08118466 - cmp r3, 0x9F - bgt _081184AA - ldr r7, =gScanlineEffectRegBuffers - ldr r6, =gScanlineEffect - ldr r1, =gTasks - mov r2, r12 - adds r0, r2, r4 - lsls r0, 3 - adds r5, r0, r1 -_08118490: - lsls r2, r3, 1 - ldrb r1, [r6, 0x14] - lsls r0, r1, 4 - subs r0, r1 - lsls r0, 7 - adds r2, r0 - adds r2, r7 - ldrh r0, [r5, 0xC] - negs r0, r0 - strh r0, [r2] - adds r3, 0x1 - cmp r3, 0x9F - ble _08118490 -_081184AA: - mov r3, r12 - adds r0, r3, r4 - lsls r0, 3 - mov r5, r8 - adds r1, r0, r5 - movs r0, 0xC - ldrsh r2, [r1, r0] - cmp r2, 0 - bne _0811852A - movs r0, 0x3 - mov r3, r9 - strb r0, [r3, 0x15] - ldrh r0, [r1, 0x8] - adds r0, 0x1 - strh r0, [r1, 0x8] - str r2, [sp] - ldr r1, =0x0600e000 - ldr r2, =0x05000200 - mov r0, sp - bl CpuSet - movs r0, 0x1 - movs r1, 0x1 - movs r2, 0 - bl SetBgAttribute - movs r0, 0x2 - movs r1, 0x1 - movs r2, 0 - bl SetBgAttribute - movs r1, 0x9C - lsls r1, 8 - movs r0, 0xA - bl SetGpuReg - movs r1, 0xBC - lsls r1, 7 - movs r0, 0xC - bl SetGpuReg - b _0811852A - .pool -_08118524: - adds r0, r4, 0 - bl sub_811828C -_0811852A: - add sp, 0x4 - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end task_battle_intro_80BC47C - - thumb_func_start task00_battle_intro_80BC6C8 -task00_battle_intro_80BC6C8: @ 8118538 - push {r4-r7,lr} - mov r7, r8 - push {r7} - sub sp, 0x4 - lsls r0, 24 - lsrs r5, r0, 24 - ldr r1, =gTasks - lsls r0, r5, 2 - adds r0, r5 - lsls r0, 3 - adds r0, r1 - movs r2, 0xA - ldrsh r0, [r0, r2] - adds r2, r1, 0 - cmp r0, 0x3 - beq _08118578 - cmp r0, 0x3 - bgt _08118568 - cmp r0, 0x2 - beq _0811856C - b _08118580 - .pool -_08118568: - cmp r0, 0x4 - bne _08118580 -_0811856C: - ldr r1, =gBattle_BG1_X - ldrh r0, [r1] - adds r0, 0x8 - b _0811857E - .pool -_08118578: - ldr r1, =gBattle_BG1_X - ldrh r0, [r1] - adds r0, 0x6 -_0811857E: - strh r0, [r1] -_08118580: - lsls r0, r5, 2 - adds r1, r0, r5 - lsls r1, 3 - adds r4, r1, r2 - movs r3, 0xA - ldrsh r1, [r4, r3] - adds r6, r0, 0 - cmp r1, 0x4 - bne _081185E4 - ldr r7, =gBattle_BG1_Y - ldrh r0, [r4, 0x14] - bl Cos2 - lsls r0, 16 - asrs r0, 16 - cmp r0, 0 - bge _081185A6 - ldr r1, =0x000001ff - adds r0, r1 -_081185A6: - asrs r0, 9 - subs r0, 0x8 - strh r0, [r7] - ldrh r1, [r4, 0x14] - movs r2, 0x14 - ldrsh r0, [r4, r2] - cmp r0, 0xB3 - bgt _081185C8 - adds r0, r1, 0x4 - b _081185CA - .pool -_081185C8: - adds r0, r1, 0x6 -_081185CA: - strh r0, [r4, 0x14] - ldr r2, =gTasks - adds r0, r6, r5 - lsls r0, 3 - adds r3, r0, r2 - movs r0, 0x14 - ldrsh r1, [r3, r0] - movs r0, 0xB4 - lsls r0, 1 - cmp r1, r0 - bne _081185E4 - movs r0, 0 - strh r0, [r3, 0x14] -_081185E4: - adds r0, r6, r5 - lsls r0, 3 - adds r0, r2 - movs r1, 0x8 - ldrsh r0, [r0, r1] - cmp r0, 0x4 - bls _081185F4 - b _0811881A -_081185F4: - lsls r0, 2 - ldr r1, =_08118608 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_08118608: - .4byte _0811861C - .4byte _0811864C - .4byte _08118678 - .4byte _081186C8 - .4byte _08118814 -_0811861C: - ldr r1, =gTasks - adds r0, r6, r5 - lsls r0, 3 - adds r2, r0, r1 - movs r3, 0x10 - strh r3, [r2, 0x10] - ldr r0, =gBattleTypeFlags - ldr r0, [r0] - movs r1, 0x2 - ands r0, r1 - cmp r0, 0 - beq _08118640 - strh r3, [r2, 0xC] - b _08118644 - .pool -_08118640: - movs r0, 0x1 - strh r0, [r2, 0xC] -_08118644: - ldrh r0, [r2, 0x8] - adds r0, 0x1 - strh r0, [r2, 0x8] - b _0811881A -_0811864C: - ldr r0, =gTasks - adds r1, r6, r5 - lsls r1, 3 - adds r1, r0 - ldrh r0, [r1, 0xC] - subs r0, 0x1 - strh r0, [r1, 0xC] - lsls r0, 16 - cmp r0, 0 - beq _08118662 - b _0811881A -_08118662: - ldrh r0, [r1, 0x8] - adds r0, 0x1 - strh r0, [r1, 0x8] - movs r0, 0x48 - movs r1, 0x3F - bl SetGpuReg - b _0811881A - .pool -_08118678: - ldr r1, =gBattle_WIN0V - ldrh r0, [r1] - subs r0, 0xFF - strh r0, [r1] - movs r1, 0xFF - lsls r1, 8 - ands r0, r1 - movs r1, 0xC0 - lsls r1, 6 - cmp r0, r1 - beq _08118690 - b _0811881A -_08118690: - ldr r0, =gTasks - adds r1, r6, r5 - lsls r1, 3 - adds r1, r0 - ldrh r0, [r1, 0x8] - adds r0, 0x1 - strh r0, [r1, 0x8] - movs r0, 0xF0 - strh r0, [r1, 0xC] - movs r0, 0x20 - strh r0, [r1, 0xE] - movs r0, 0x1 - strh r0, [r1, 0x12] - ldr r2, =gIntroSlideFlags - ldrh r1, [r2] - ldr r0, =0x0000fffe - ands r0, r1 - strh r0, [r2] - b _0811881A - .pool -_081186C8: - ldr r0, =gTasks - adds r1, r6, r5 - lsls r1, 3 - adds r1, r0 - ldrh r2, [r1, 0xE] - movs r3, 0xE - ldrsh r0, [r1, r3] - cmp r0, 0 - beq _08118708 - subs r0, r2, 0x1 - strh r0, [r1, 0xE] - lsls r0, 16 - cmp r0, 0 - bne _08118728 - ldr r1, =0x00001842 - movs r0, 0x50 - bl SetGpuReg - movs r0, 0x52 - movs r1, 0xF - bl SetGpuReg - movs r0, 0x54 - movs r1, 0 - bl SetGpuReg - b _08118728 - .pool -_08118708: - ldrh r2, [r1, 0x10] - movs r0, 0x1F - ands r0, r2 - cmp r0, 0 - beq _08118728 - ldrh r0, [r1, 0x12] - subs r0, 0x1 - strh r0, [r1, 0x12] - lsls r0, 16 - cmp r0, 0 - bne _08118728 - adds r0, r2, 0 - adds r0, 0xFF - strh r0, [r1, 0x10] - movs r0, 0x4 - strh r0, [r1, 0x12] -_08118728: - ldr r2, =gBattle_WIN0V - ldrh r1, [r2] - movs r0, 0xFF - lsls r0, 8 - ands r0, r1 - cmp r0, 0 - beq _0811873C - ldr r3, =0xfffffc04 - adds r0, r1, r3 - strh r0, [r2] -_0811873C: - ldr r0, =gTasks - adds r1, r6, r5 - lsls r1, 3 - adds r1, r0 - ldrh r2, [r1, 0xC] - movs r3, 0xC - ldrsh r0, [r1, r3] - cmp r0, 0 - beq _08118752 - subs r0, r2, 0x2 - strh r0, [r1, 0xC] -_08118752: - movs r3, 0 - ldr r0, =gScanlineEffect - mov r8, r0 - ldr r2, =gScanlineEffectRegBuffers - mov r12, r2 - mov r7, r8 - adds r4, r1, 0 -_08118760: - lsls r2, r3, 1 - ldrb r1, [r7, 0x14] - lsls r0, r1, 4 - subs r0, r1 - lsls r0, 7 - adds r2, r0 - add r2, r12 - ldrh r0, [r4, 0xC] - strh r0, [r2] - adds r3, 0x1 - cmp r3, 0x4F - ble _08118760 - cmp r3, 0x9F - bgt _081187A4 - ldr r0, =gScanlineEffectRegBuffers - mov r12, r0 - ldr r7, =gScanlineEffect - ldr r1, =gTasks - adds r0, r6, r5 - lsls r0, 3 - adds r4, r0, r1 -_0811878A: - lsls r2, r3, 1 - ldrb r1, [r7, 0x14] - lsls r0, r1, 4 - subs r0, r1 - lsls r0, 7 - adds r2, r0 - add r2, r12 - ldrh r0, [r4, 0xC] - negs r0, r0 - strh r0, [r2] - adds r3, 0x1 - cmp r3, 0x9F - ble _0811878A -_081187A4: - ldr r1, =gTasks - adds r0, r6, r5 - lsls r0, 3 - adds r1, r0, r1 - movs r3, 0xC - ldrsh r2, [r1, r3] - cmp r2, 0 - bne _0811881A - movs r0, 0x3 - mov r3, r8 - strb r0, [r3, 0x15] - ldrh r0, [r1, 0x8] - adds r0, 0x1 - strh r0, [r1, 0x8] - str r2, [sp] - ldr r1, =0x0600e000 - ldr r2, =0x05000200 - mov r0, sp - bl CpuSet - movs r0, 0x1 - movs r1, 0x1 - movs r2, 0 - bl SetBgAttribute - movs r0, 0x2 - movs r1, 0x1 - movs r2, 0 - bl SetBgAttribute - movs r1, 0x9C - lsls r1, 8 - movs r0, 0xA - bl SetGpuReg - movs r1, 0xBC - lsls r1, 7 - movs r0, 0xC - bl SetGpuReg - b _0811881A - .pool -_08118814: - adds r0, r5, 0 - bl sub_811828C -_0811881A: - ldr r0, =gTasks - adds r1, r6, r5 - lsls r1, 3 - adds r1, r0 - movs r2, 0x8 - ldrsh r0, [r1, r2] - cmp r0, 0x4 - beq _08118832 - ldrh r1, [r1, 0x10] - movs r0, 0x52 - bl SetGpuReg -_08118832: - add sp, 0x4 - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end task00_battle_intro_80BC6C8 - - thumb_func_start task_battle_intro_anim -task_battle_intro_anim: @ 8118844 - push {r4-r7,lr} - mov r7, r8 - push {r7} - sub sp, 0x4 - lsls r0, 24 - lsrs r5, r0, 24 - ldr r1, =gBattle_BG1_X - ldrh r0, [r1] - adds r0, 0x8 - strh r0, [r1] - ldr r1, =gTasks - lsls r0, r5, 2 - adds r0, r5 - lsls r0, 3 - adds r0, r1 - movs r2, 0x8 - ldrsh r0, [r0, r2] - adds r4, r1, 0 - cmp r0, 0x4 - bls _0811886E - b _08118A96 -_0811886E: - lsls r0, 2 - ldr r1, =_08118884 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_08118884: - .4byte _08118898 - .4byte _081188F0 - .4byte _0811891C - .4byte _0811896C - .4byte _08118A90 -_08118898: - ldr r1, =0x00001842 - movs r0, 0x50 - bl SetGpuReg - ldr r4, =0x00000808 - movs r0, 0x52 - adds r1, r4, 0 - bl SetGpuReg - movs r0, 0x54 - movs r1, 0 - bl SetGpuReg - ldr r1, =gTasks - lsls r0, r5, 2 - adds r0, r5 - lsls r0, 3 - adds r2, r0, r1 - strh r4, [r2, 0x10] - ldr r0, =gBattleTypeFlags - ldr r0, [r0] - ldr r1, =0x02000002 - ands r0, r1 - cmp r0, 0 - beq _081188E4 - movs r0, 0x10 - b _081188E6 - .pool -_081188E4: - movs r0, 0x1 -_081188E6: - strh r0, [r2, 0xC] - ldrh r0, [r2, 0x8] - adds r0, 0x1 - strh r0, [r2, 0x8] - b _08118A96 -_081188F0: - ldr r0, =gTasks - lsls r1, r5, 2 - adds r1, r5 - lsls r1, 3 - adds r1, r0 - ldrh r0, [r1, 0xC] - subs r0, 0x1 - strh r0, [r1, 0xC] - lsls r0, 16 - cmp r0, 0 - beq _08118908 - b _08118A96 -_08118908: - ldrh r0, [r1, 0x8] - adds r0, 0x1 - strh r0, [r1, 0x8] - movs r0, 0x48 - movs r1, 0x3F - bl SetGpuReg - b _08118A96 - .pool -_0811891C: - ldr r1, =gBattle_WIN0V - ldrh r0, [r1] - subs r0, 0xFF - strh r0, [r1] - movs r1, 0xFF - lsls r1, 8 - ands r0, r1 - movs r1, 0xC0 - lsls r1, 6 - cmp r0, r1 - beq _08118934 - b _08118A96 -_08118934: - ldr r0, =gTasks - lsls r1, r5, 2 - adds r1, r5 - lsls r1, 3 - adds r1, r0 - ldrh r0, [r1, 0x8] - adds r0, 0x1 - strh r0, [r1, 0x8] - movs r0, 0xF0 - strh r0, [r1, 0xC] - movs r0, 0x20 - strh r0, [r1, 0xE] - movs r0, 0x1 - strh r0, [r1, 0x12] - ldr r2, =gIntroSlideFlags - ldrh r1, [r2] - ldr r0, =0x0000fffe - ands r0, r1 - strh r0, [r2] - b _08118A96 - .pool -_0811896C: - lsls r0, r5, 2 - adds r1, r0, r5 - lsls r1, 3 - adds r2, r1, r4 - ldrh r3, [r2, 0xE] - movs r6, 0xE - ldrsh r1, [r2, r6] - mov r12, r0 - cmp r1, 0 - beq _08118986 - subs r0, r3, 0x1 - strh r0, [r2, 0xE] - b _081189A6 -_08118986: - ldrh r1, [r2, 0x10] - movs r0, 0xF - ands r0, r1 - cmp r0, 0 - beq _081189A6 - ldrh r0, [r2, 0x12] - subs r0, 0x1 - strh r0, [r2, 0x12] - lsls r0, 16 - cmp r0, 0 - bne _081189A6 - adds r0, r1, 0 - adds r0, 0xFF - strh r0, [r2, 0x10] - movs r0, 0x6 - strh r0, [r2, 0x12] -_081189A6: - ldr r2, =gBattle_WIN0V - ldrh r1, [r2] - movs r0, 0xFF - lsls r0, 8 - ands r0, r1 - cmp r0, 0 - beq _081189BA - ldr r3, =0xfffffc04 - adds r0, r1, r3 - strh r0, [r2] -_081189BA: - mov r6, r12 - adds r0, r6, r5 - lsls r0, 3 - adds r1, r0, r4 - ldrh r2, [r1, 0xC] - movs r3, 0xC - ldrsh r0, [r1, r3] - cmp r0, 0 - beq _081189D0 - subs r0, r2, 0x2 - strh r0, [r1, 0xC] -_081189D0: - movs r3, 0 - ldr r6, =gScanlineEffect - mov r8, r6 - ldr r7, =gScanlineEffectRegBuffers - adds r4, r1, 0 -_081189DA: - lsls r2, r3, 1 - ldrb r1, [r6, 0x14] - lsls r0, r1, 4 - subs r0, r1 - lsls r0, 7 - adds r2, r0 - adds r2, r7 - ldrh r0, [r4, 0xC] - strh r0, [r2] - adds r3, 0x1 - cmp r3, 0x4F - ble _081189DA - cmp r3, 0x9F - bgt _08118A1E - ldr r7, =gScanlineEffectRegBuffers - ldr r6, =gScanlineEffect - ldr r1, =gTasks - mov r2, r12 - adds r0, r2, r5 - lsls r0, 3 - adds r4, r0, r1 -_08118A04: - lsls r2, r3, 1 - ldrb r1, [r6, 0x14] - lsls r0, r1, 4 - subs r0, r1 - lsls r0, 7 - adds r2, r0 - adds r2, r7 - ldrh r0, [r4, 0xC] - negs r0, r0 - strh r0, [r2] - adds r3, 0x1 - cmp r3, 0x9F - ble _08118A04 -_08118A1E: - ldr r1, =gTasks - lsls r0, r5, 2 - adds r0, r5 - lsls r0, 3 - adds r1, r0, r1 - movs r3, 0xC - ldrsh r2, [r1, r3] - cmp r2, 0 - bne _08118A96 - movs r0, 0x3 - mov r6, r8 - strb r0, [r6, 0x15] - ldrh r0, [r1, 0x8] - adds r0, 0x1 - strh r0, [r1, 0x8] - str r2, [sp] - ldr r1, =0x0600e000 - ldr r2, =0x05000200 - mov r0, sp - bl CpuSet - movs r0, 0x1 - movs r1, 0x1 - movs r2, 0 - bl SetBgAttribute - movs r0, 0x2 - movs r1, 0x1 - movs r2, 0 - bl SetBgAttribute - movs r1, 0x9C - lsls r1, 8 - movs r0, 0xA - bl SetGpuReg - movs r1, 0xBC - lsls r1, 7 - movs r0, 0xC - bl SetGpuReg - b _08118A96 - .pool -_08118A90: - adds r0, r5, 0 - bl sub_811828C -_08118A96: - ldr r0, =gTasks - lsls r1, r5, 2 - adds r1, r5 - lsls r1, 3 - adds r1, r0 - movs r2, 0x8 - ldrsh r0, [r1, r2] - cmp r0, 0x4 - beq _08118AB0 - ldrh r1, [r1, 0x10] - movs r0, 0x52 - bl SetGpuReg -_08118AB0: - add sp, 0x4 - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end task_battle_intro_anim - - thumb_func_start task00_battle_intro_wireless -task00_battle_intro_wireless: @ 8118AC0 - push {r4-r7,lr} - mov r7, r9 - mov r6, r8 - push {r6,r7} - sub sp, 0x8 - lsls r0, 24 - lsrs r6, r0, 24 - ldr r1, =gTasks - lsls r0, r6, 2 - adds r0, r6 - lsls r0, 3 - adds r7, r0, r1 - movs r1, 0x8 - ldrsh r0, [r7, r1] - cmp r0, 0x1 - ble _08118B36 - movs r2, 0x10 - ldrsh r0, [r7, r2] - cmp r0, 0 - bne _08118B36 - ldr r2, =gBattle_BG1_X - ldrh r1, [r2] - movs r0, 0x80 - lsls r0, 8 - ands r0, r1 - lsls r0, 16 - lsrs r5, r0, 16 - cmp r5, 0 - bne _08118AFE - cmp r1, 0x4F - bhi _08118B18 -_08118AFE: - adds r0, r1, 0x3 - strh r0, [r2] - ldr r1, =gBattle_BG2_X - ldrh r0, [r1] - subs r0, 0x3 - strh r0, [r1] - b _08118B36 - .pool -_08118B18: - str r5, [sp] - ldr r1, =0x0600e000 - ldr r4, =0x05000200 - mov r0, sp - adds r2, r4, 0 - bl CpuSet - str r5, [sp, 0x4] - add r0, sp, 0x4 - ldr r1, =0x0600f000 - adds r2, r4, 0 - bl CpuSet - movs r0, 0x1 - strh r0, [r7, 0x10] -_08118B36: - ldr r0, =gTasks - lsls r2, r6, 2 - adds r1, r2, r6 - lsls r1, 3 - adds r1, r0 - movs r3, 0x8 - ldrsh r1, [r1, r3] - mov r9, r0 - adds r5, r2, 0 - cmp r1, 0x4 - bls _08118B4E - b _08118D5A -_08118B4E: - lsls r0, r1, 2 - ldr r1, =_08118B6C - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_08118B6C: - .4byte _08118B80 - .4byte _08118B92 - .4byte _08118C38 - .4byte _08118C7C - .4byte _08118D54 -_08118B80: - adds r0, r5, r6 - lsls r0, 3 - add r0, r9 - movs r1, 0x20 - strh r1, [r0, 0xC] - ldrh r1, [r0, 0x8] - adds r1, 0x1 - strh r1, [r0, 0x8] - b _08118D5A -_08118B92: - adds r0, r5, r6 - lsls r0, 3 - mov r2, r9 - adds r1, r0, r2 - ldrh r0, [r1, 0xC] - subs r0, 0x1 - strh r0, [r1, 0xC] - lsls r0, 16 - cmp r0, 0 - beq _08118BA8 - b _08118D5A -_08118BA8: - ldrh r0, [r1, 0x8] - adds r0, 0x1 - strh r0, [r1, 0x8] - ldr r4, =gSprites - ldr r5, =gBattleStruct - ldr r0, [r5] - adds r0, 0x7D - ldrb r0, [r0] - lsls r1, r0, 4 - adds r1, r0 - lsls r1, 2 - adds r1, r4 - ldrb r3, [r1, 0x1] - movs r2, 0xD - negs r2, r2 - adds r0, r2, 0 - ands r0, r3 - movs r3, 0x8 - mov r9, r3 - mov r3, r9 - orrs r0, r3 - strb r0, [r1, 0x1] - ldr r3, [r5] - adds r0, r3, 0 - adds r0, 0x7D - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - movs r1, 0x1C - adds r1, r4 - mov r8, r1 - add r0, r8 - ldr r6, =sub_8038B74 - str r6, [r0] - adds r3, 0x7E - ldrb r1, [r3] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r4 - ldrb r1, [r0, 0x1] - ands r2, r1 - mov r3, r9 - orrs r2, r3 - strb r2, [r0, 0x1] - ldr r0, [r5] - adds r0, 0x7E - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - add r0, r8 - str r6, [r0] - movs r0, 0x48 - movs r1, 0x3F - bl SetGpuReg - ldr r1, =0x00003f06 - movs r0, 0x4A - bl SetGpuReg - b _08118D5A - .pool -_08118C38: - ldr r1, =gBattle_WIN0V - ldrh r0, [r1] - subs r0, 0xFF - strh r0, [r1] - movs r1, 0xFF - lsls r1, 8 - ands r0, r1 - movs r1, 0xC0 - lsls r1, 6 - cmp r0, r1 - beq _08118C50 - b _08118D5A -_08118C50: - adds r1, r5, r6 - lsls r1, 3 - add r1, r9 - ldrh r0, [r1, 0x8] - adds r0, 0x1 - strh r0, [r1, 0x8] - movs r0, 0xF0 - strh r0, [r1, 0xC] - movs r0, 0x20 - strh r0, [r1, 0xE] - ldr r2, =gIntroSlideFlags - ldrh r1, [r2] - ldr r0, =0x0000fffe - ands r0, r1 - strh r0, [r2] - b _08118D5A - .pool -_08118C7C: - ldr r2, =gBattle_WIN0V - ldrh r1, [r2] - movs r0, 0xFF - lsls r0, 8 - ands r0, r1 - cmp r0, 0 - beq _08118C90 - ldr r3, =0xfffffc04 - adds r0, r1, r3 - strh r0, [r2] -_08118C90: - adds r0, r5, r6 - lsls r0, 3 - mov r2, r9 - adds r1, r0, r2 - ldrh r2, [r1, 0xC] - movs r3, 0xC - ldrsh r0, [r1, r3] - cmp r0, 0 - beq _08118CA6 - subs r0, r2, 0x2 - strh r0, [r1, 0xC] -_08118CA6: - movs r3, 0 - ldr r0, =gScanlineEffect - mov r12, r0 - ldr r2, =gScanlineEffectRegBuffers - mov r8, r2 - mov r7, r12 - adds r4, r1, 0 -_08118CB4: - lsls r2, r3, 1 - ldrb r1, [r7, 0x14] - lsls r0, r1, 4 - subs r0, r1 - lsls r0, 7 - adds r2, r0 - add r2, r8 - ldrh r0, [r4, 0xC] - strh r0, [r2] - adds r3, 0x1 - cmp r3, 0x4F - ble _08118CB4 - cmp r3, 0x9F - bgt _08118CF8 - ldr r0, =gScanlineEffectRegBuffers - mov r8, r0 - ldr r7, =gScanlineEffect - ldr r1, =gTasks - adds r0, r5, r6 - lsls r0, 3 - adds r4, r0, r1 -_08118CDE: - lsls r2, r3, 1 - ldrb r1, [r7, 0x14] - lsls r0, r1, 4 - subs r0, r1 - lsls r0, 7 - adds r2, r0 - add r2, r8 - ldrh r0, [r4, 0xC] - negs r0, r0 - strh r0, [r2] - adds r3, 0x1 - cmp r3, 0x9F - ble _08118CDE -_08118CF8: - adds r0, r5, r6 - lsls r0, 3 - mov r2, r9 - adds r1, r0, r2 - movs r3, 0xC - ldrsh r0, [r1, r3] - cmp r0, 0 - bne _08118D5A - movs r0, 0x3 - mov r2, r12 - strb r0, [r2, 0x15] - ldrh r0, [r1, 0x8] - adds r0, 0x1 - strh r0, [r1, 0x8] - movs r0, 0x1 - movs r1, 0x1 - movs r2, 0 - bl SetBgAttribute - movs r0, 0x2 - movs r1, 0x1 - movs r2, 0 - bl SetBgAttribute - movs r1, 0x9C - lsls r1, 8 - movs r0, 0xA - bl SetGpuReg - movs r1, 0xBC - lsls r1, 7 - movs r0, 0xC - bl SetGpuReg - b _08118D5A - .pool -_08118D54: - adds r0, r6, 0 - bl sub_811828C -_08118D5A: - add sp, 0x8 - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end task00_battle_intro_wireless - - thumb_func_start sub_8118D68 -sub_8118D68: @ 8118D68 - push {r4-r6,lr} - sub sp, 0x4 - lsls r0, 24 - lsrs r4, r0, 24 - ldr r1, =gTasks - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - adds r0, r1 - movs r2, 0x8 - ldrsh r0, [r0, r2] - adds r6, r1, 0 - cmp r0, 0x5 - bls _08118D86 - b _08118FB2 -_08118D86: - lsls r0, 2 - ldr r1, =_08118D98 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_08118D98: - .4byte _08118DB0 - .4byte _08118DBE - .4byte _08118E4C - .4byte _08118EA8 - .4byte _08118F00 - .4byte _08118FAC -_08118DB0: - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - adds r0, r6 - movs r1, 0x1 - strh r1, [r0, 0xC] - b _08118F84 -_08118DBE: - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - adds r1, r0, r6 - ldrh r0, [r1, 0xC] - subs r0, 0x1 - strh r0, [r1, 0xC] - lsls r0, 16 - cmp r0, 0 - beq _08118DD4 - b _08118FB2 -_08118DD4: - ldrh r0, [r1, 0x8] - adds r0, 0x1 - strh r0, [r1, 0x8] - ldr r1, =0x00005c0a - movs r0, 0xA - bl SetGpuReg - ldr r1, =0x00005e0a - movs r0, 0xC - bl SetGpuReg - movs r0, 0 - bl GetGpuReg - adds r1, r0, 0 - ldr r2, =0x0000f040 - adds r0, r2, 0 - orrs r1, r0 - lsls r1, 16 - lsrs r1, 16 - movs r0, 0 - bl SetGpuReg - movs r1, 0xF8 - lsls r1, 6 - movs r0, 0x48 - bl SetGpuReg - ldr r1, =0x00003f3f - movs r0, 0x4A - bl SetGpuReg - ldr r1, =gBattle_BG0_Y - ldr r2, =0x0000ffd0 - adds r0, r2, 0 - strh r0, [r1] - ldr r1, =gBattle_BG1_X - movs r0, 0xF0 - strh r0, [r1] - ldr r1, =gBattle_BG2_X - subs r2, 0xC0 - adds r0, r2, 0 - strh r0, [r1] - b _08118FB2 - .pool -_08118E4C: - ldr r2, =gBattle_WIN0V - ldrh r3, [r2] - movs r1, 0x80 - lsls r1, 1 - adds r0, r1, 0 - adds r1, r3, r0 - strh r1, [r2] - movs r5, 0xFF - lsls r5, 8 - ands r1, r5 - lsls r0, 16 - lsrs r0, 16 - cmp r1, r0 - beq _08118E6E - adds r0, r3, 0 - adds r0, 0xFF - strh r0, [r2] -_08118E6E: - ldrh r0, [r2] - adds r1, r5, 0 - ands r1, r0 - movs r0, 0x80 - lsls r0, 6 - cmp r1, r0 - beq _08118E7E - b _08118FB2 -_08118E7E: - lsls r1, r4, 2 - adds r1, r4 - lsls r1, 3 - adds r1, r6 - ldrh r0, [r1, 0x8] - adds r0, 0x1 - strh r0, [r1, 0x8] - movs r0, 0xF0 - strh r0, [r1, 0xC] - ldr r2, =gIntroSlideFlags - ldrh r1, [r2] - ldr r0, =0x0000fffe - ands r0, r1 - strh r0, [r2] - b _08118FB2 - .pool -_08118EA8: - ldr r3, =gBattle_WIN0V - ldrh r2, [r3] - movs r0, 0xFF - lsls r0, 8 - ands r0, r2 - movs r1, 0x98 - lsls r1, 7 - cmp r0, r1 - beq _08118EC2 - movs r1, 0xFF - lsls r1, 2 - adds r0, r2, r1 - strh r0, [r3] -_08118EC2: - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - adds r3, r0, r6 - ldrh r1, [r3, 0xC] - movs r2, 0xC - ldrsh r0, [r3, r2] - cmp r0, 0 - beq _08118ED8 - subs r0, r1, 0x2 - strh r0, [r3, 0xC] -_08118ED8: - ldr r1, =gBattle_BG1_X - ldrh r0, [r3, 0xC] - strh r0, [r1] - ldr r2, =gBattle_BG2_X - negs r1, r0 - strh r1, [r2] - lsls r0, 16 - cmp r0, 0 - bne _08118FB2 - ldrh r0, [r3, 0x8] - adds r0, 0x1 - strh r0, [r3, 0x8] - b _08118FB2 - .pool -_08118F00: - ldr r1, =gBattle_BG0_Y - ldrh r0, [r1] - adds r3, r0, 0x2 - strh r3, [r1] - ldr r1, =gBattle_BG2_Y - ldrh r0, [r1] - adds r0, 0x2 - strh r0, [r1] - ldr r5, =gBattle_WIN0V - ldrh r2, [r5] - movs r0, 0xFF - lsls r0, 8 - ands r0, r2 - movs r1, 0xA0 - lsls r1, 7 - cmp r0, r1 - beq _08118F28 - adds r0, r2, 0 - adds r0, 0xFF - strh r0, [r5] -_08118F28: - lsls r0, r3, 16 - lsrs r0, 16 - cmp r0, 0 - bne _08118FB2 - str r0, [sp] - ldr r1, =0x0600e000 - ldr r2, =0x05000800 - mov r0, sp - bl CpuSet - movs r0, 0 - bl GetGpuReg - ldr r1, =0x0000bfff - ands r1, r0 - movs r0, 0 - bl SetGpuReg - movs r0, 0x1 - movs r1, 0x1 - movs r2, 0 - bl SetBgAttribute - movs r0, 0x2 - movs r1, 0x1 - movs r2, 0 - bl SetBgAttribute - movs r1, 0x9C - lsls r1, 8 - movs r0, 0xA - bl SetGpuReg - movs r1, 0xBC - lsls r1, 7 - movs r0, 0xC - bl SetGpuReg - ldr r1, =gScanlineEffect - movs r0, 0x3 - strb r0, [r1, 0x15] - ldr r1, =gTasks - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - adds r0, r1 -_08118F84: - ldrh r1, [r0, 0x8] - adds r1, 0x1 - strh r1, [r0, 0x8] - b _08118FB2 - .pool -_08118FAC: - adds r0, r4, 0 - bl sub_811828C -_08118FB2: - add sp, 0x4 - pop {r4-r6} - pop {r0} - bx r0 - thumb_func_end sub_8118D68 - - thumb_func_start sub_8118FBC -sub_8118FBC: @ 8118FBC - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x4 - str r0, [sp] - adds r6, r2, 0 - adds r4, r3, 0 - ldr r0, [sp, 0x24] - ldr r7, [sp, 0x28] - ldr r2, [sp, 0x2C] - mov r9, r2 - ldr r5, [sp, 0x30] - lsls r1, 24 - lsrs r1, 24 - mov r8, r1 - lsls r6, 24 - lsrs r6, 24 - lsls r4, 24 - lsrs r4, 24 - lsls r0, 24 - lsrs r0, 24 - mov r10, r0 - lsls r5, 16 - lsrs r5, 16 - adds r0, r4, 0 - bl GetBattlerAtPosition - lsls r0, 24 - lsrs r0, 24 - ldr r1, =gMonSpritesGfxPtr - ldr r2, [r1] - lsls r4, 2 - adds r2, 0x4 - adds r2, r4 - ldr r1, =gBattleMonForms - adds r0, r1 - ldrb r1, [r0] - lsls r1, 11 - ldr r0, [r2] - adds r0, r1 - movs r2, 0x80 - lsls r2, 3 - adds r1, r7, 0 - bl CpuSet - ldr r1, [sp] - lsls r0, r1, 24 - lsrs r0, 24 - movs r2, 0x80 - lsls r2, 5 - adds r1, r7, 0 - adds r3, r5, 0 - bl LoadBgTiles - adds r0, r6, 0 - adds r0, 0x8 - cmp r6, r0 - bge _08119068 - mov r12, r0 - mov r2, r8 - lsls r7, r2, 1 -_0811903A: - mov r1, r8 - adds r2, r1, 0 - adds r2, 0x8 - adds r4, r6, 0x1 - cmp r1, r2 - bge _08119062 - mov r0, r10 - lsls r3, r0, 12 - lsls r0, r6, 6 - add r0, r9 - adds r6, r7, r0 - subs r1, r2, r1 -_08119052: - adds r0, r5, 0 - orrs r0, r3 - strh r0, [r6] - adds r5, 0x1 - adds r6, 0x2 - subs r1, 0x1 - cmp r1, 0 - bne _08119052 -_08119062: - adds r6, r4, 0 - cmp r6, r12 - blt _0811903A -_08119068: - ldr r1, [sp] - lsls r0, r1, 24 - lsrs r0, 24 - movs r2, 0x80 - lsls r2, 4 - mov r1, r9 - movs r3, 0 - bl LoadBgTilemap - 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 sub_8118FBC - - thumb_func_start sub_8119094 -sub_8119094: @ 8119094 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x4 - ldr r4, [sp, 0x24] - ldr r5, [sp, 0x28] - mov r8, r5 - ldr r5, [sp, 0x2C] - ldr r6, [sp, 0x30] - mov r9, r6 - lsls r0, 24 - lsrs r0, 24 - mov r12, r0 - lsls r1, 24 - lsls r2, 24 - lsls r3, 24 - lsls r4, 24 - lsrs r4, 24 - mov r10, r4 - mov r7, r8 - lsls r7, 16 - lsrs r6, r7, 16 - lsls r5, 24 - lsrs r5, 24 - mov r0, r9 - lsls r0, 24 - mov r9, r0 - ldr r4, =0x040000d4 - ldr r0, =gMonSpritesGfxPtr - ldr r0, [r0] - lsrs r2, 22 - adds r0, 0x4 - adds r0, r2 - lsrs r3, 13 - ldr r0, [r0] - adds r0, r3 - str r0, [r4] - movs r0, 0xC0 - lsls r0, 19 - adds r6, r0 - str r6, [r4, 0x4] - ldr r0, =0x80000400 - str r0, [r4, 0x8] - ldr r0, [r4, 0x8] - adds r2, r7, 0 - lsrs r2, 21 - mov r6, r9 - lsrs r6, 15 - subs r4, r2, r6 - lsrs r0, r1, 24 - adds r1, r0, 0 - adds r1, 0x8 - cmp r0, r1 - bge _08119148 - mov r9, r1 - mov r7, r12 - lsls r7, 1 - mov r8, r7 - lsls r5, 11 - str r5, [sp] -_08119110: - mov r2, r12 - adds r3, r2, 0 - adds r3, 0x8 - adds r5, r0, 0x1 - cmp r2, r3 - bge _08119142 - mov r1, r10 - lsls r6, r1, 12 - lsls r0, 6 - movs r7, 0xC0 - lsls r7, 19 - adds r0, r7 - ldr r1, [sp] - adds r0, r1, r0 - mov r7, r8 - adds r1, r7, r0 - subs r2, r3, r2 -_08119132: - adds r0, r4, 0 - orrs r0, r6 - strh r0, [r1] - adds r4, 0x1 - adds r1, 0x2 - subs r2, 0x1 - cmp r2, 0 - bne _08119132 -_08119142: - adds r0, r5, 0 - cmp r0, r9 - blt _08119110 -_08119148: - 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 sub_8119094 - - .align 2, 0 @ Don't pad with nop. diff --git a/data/data2c.s b/data/data2c.s index 1946f5bdb..5bfea56ae 100644 --- a/data/data2c.s +++ b/data/data2c.s @@ -9,10 +9,13 @@ .section .rodata .align 2 -gUnknown_0831AC70:: @ 831AC70 +gBattleIntroSlideScanlineEffectParams:: @ 831AC70 .4byte REG_BG3HOFS .4byte ((DMA_ENABLE | DMA_START_HBLANK | DMA_REPEAT | DMA_DEST_RELOAD) << 16) | 1 .4byte 1 + + .align 2 +gUnknown_0831AC7C:: @ 831AC7C .4byte REG_BG3HOFS .4byte ((DMA_ENABLE | DMA_START_HBLANK | DMA_32BIT | DMA_REPEAT | DMA_DEST_RELOAD) << 16) | 1 .4byte 1 diff --git a/include/battle_anim.h b/include/battle_anim.h index fa4058c1b..541c165e7 100644 --- a/include/battle_anim.h +++ b/include/battle_anim.h @@ -9,11 +9,11 @@ enum { BG_ANIM_SCREEN_SIZE, BG_ANIM_AREA_OVERFLOW_MODE, - BG_ANIM2, + BG_ANIM_MOSAIC, BG_ANIM_CHAR_BASE_BLOCK, BG_ANIM_PRIORITY, - BG_ANIM_5, - BG_ANIM_6 + BG_ANIM_PALETTES_MODE, + BG_ANIM_SCREEN_BASE_BLOCK, }; struct UnknownAnimStruct2 @@ -67,11 +67,11 @@ s16 CalculatePanIncrement(s16 sourcePan, s16 targetPan, s16 incrementPan); void sub_80A4720(u16 a, u16 *b, u32 c, u8 d); void sub_80A477C(bool8); -// battle_anim_80FE840.s +// battle_intro.s void SetAnimBgAttribute(u8 bgId, u8 attributeId, u8 value); -void sub_8118FBC(u8 arg0, u8 arg1, u8 arg2, u8 battlerPosition, u8 arg4, void *arg5, u16 *arg6, u16 arg7); +void sub_8118FBC(int bgId, u8 arg1, u8 arg2, u8 battlerPosition, u8 arg4, u8 *arg5, u16 *arg6, u16 arg7); void HandleIntroSlide(u8 terrainId); -u32 GetAnimBgAttribute(u8 bgId, u8 attributeId); +int GetAnimBgAttribute(u8 bgId, u8 attributeId); // battle_anim_80A5C6C.s void sub_80A6450(struct Sprite *sprite); diff --git a/include/gba/types.h b/include/gba/types.h index a7dbf3e03..fff48d437 100644 --- a/include/gba/types.h +++ b/include/gba/types.h @@ -32,7 +32,9 @@ struct BgCnt { u16 priority:2; u16 charBaseBlock:2; - u16 dummy:4; + u16 dummy:2; + u16 mosaic:1; + u16 palettes:1; u16 screenBaseBlock:5; u16 areaOverflowMode:1; u16 screenSize:2; diff --git a/ld_script.txt b/ld_script.txt index 0dbff7996..80c614471 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -175,7 +175,7 @@ SECTIONS { src/ground.o(.text); src/normal.o(.text); src/battle_anim_utility_funcs.o(.text); - asm/battle_intro.o(.text); + src/battle_intro.o(.text); src/bike.o(.text); src/easy_chat.o(.text); asm/easy_chat.o(.text); diff --git a/src/battle_anim_utility_funcs.c b/src/battle_anim_utility_funcs.c index c3d0fe90f..85ff692b3 100644 --- a/src/battle_anim_utility_funcs.c +++ b/src/battle_anim_utility_funcs.c @@ -40,10 +40,10 @@ static void sub_8117FD0(u8); const u16 gUnknown_08597418 = RGB(31, 31, 31); -// no clue what these are... -// possibly some register offsets -const u8 gUnknown_0859741A[] = {0x08, 0x0a, 0x0c, 0x0e}; -const u8 gUnknown_0859741E[] = {0x08, 0x0a, 0x0c, 0x0e}; +// These belong in battle_intro.c, but there putting them there causes 2 bytes of alignment padding +// between the two .rodata segments. Perhaps battle_intro.c actually belongs in this file, too. +const u8 gUnknown_0859741A[] = {REG_OFFSET_BG0CNT, REG_OFFSET_BG1CNT, REG_OFFSET_BG2CNT, REG_OFFSET_BG3CNT}; +const u8 gUnknown_0859741E[] = {REG_OFFSET_BG0CNT, REG_OFFSET_BG1CNT, REG_OFFSET_BG2CNT, REG_OFFSET_BG3CNT}; void sub_8116620(u8 taskId) { diff --git a/src/battle_intro.c b/src/battle_intro.c index 0ccc7e828..91e7c8ea0 100644 --- a/src/battle_intro.c +++ b/src/battle_intro.c @@ -1,21 +1,733 @@ #include "global.h" +#include "battle.h" +#include "battle_anim.h" +#include "battle_main.h" +#include "battle_setup.h" +#include "bg.h" +#include "gpu_regs.h" +#include "main.h" +#include "scanline_effect.h" #include "task.h" +#include "trig.h" +#include "constants/trainers.h" -extern void task_battle_intro_80BC47C(u8); -extern void task00_battle_intro_80BC6C8(u8); -extern void task_battle_intro_80BC47C(u8); -extern void task_battle_intro_anim(u8); +static EWRAM_DATA u16 sBgCnt = 0; -const TaskFunc gUnknown_08597424[] = +extern const u8 gUnknown_0859741A[]; +extern const u8 gUnknown_0859741E[]; + +static void BattleIntroSlide1(u8); +static void BattleIntroSlide2(u8); +static void BattleIntroSlide3(u8); +static void BattleIntroSlideLink(u8); +static void BattleIntroSlidePartner(u8); + +static const TaskFunc sBattleIntroSlideFuncs[] = { - task_battle_intro_80BC47C, - task_battle_intro_80BC47C, - task00_battle_intro_80BC6C8, - task00_battle_intro_80BC6C8, - task00_battle_intro_80BC6C8, - task_battle_intro_80BC47C, - task_battle_intro_80BC47C, - task_battle_intro_80BC47C, - task_battle_intro_anim, - task_battle_intro_anim, + BattleIntroSlide1, // BATTLE_TERRAIN_GRASS + BattleIntroSlide1, // BATTLE_TERRAIN_LONG_GRASS + BattleIntroSlide2, // BATTLE_TERRAIN_SAND + BattleIntroSlide2, // BATTLE_TERRAIN_UNDERWATER + BattleIntroSlide2, // BATTLE_TERRAIN_WATER + BattleIntroSlide1, // BATTLE_TERRAIN_POND + BattleIntroSlide1, // BATTLE_TERRAIN_MOUNTAIN + BattleIntroSlide1, // BATTLE_TERRAIN_CAVE + BattleIntroSlide3, // BATTLE_TERRAIN_BUILDING + BattleIntroSlide3, // BATTLE_TERRAIN_PLAIN }; + +void SetAnimBgAttribute(u8 bgId, u8 attributeId, u8 value) +{ + if (bgId < 4) + { + sBgCnt = GetGpuReg(gUnknown_0859741A[bgId]); + switch (attributeId) + { + case BG_ANIM_SCREEN_SIZE: + ((struct BgCnt *)&sBgCnt)->screenSize = value; + break; + case BG_ANIM_AREA_OVERFLOW_MODE: + ((struct BgCnt *)&sBgCnt)->areaOverflowMode = value; + break; + case BG_ANIM_MOSAIC: + ((struct BgCnt *)&sBgCnt)->mosaic = value; + break; + case BG_ANIM_CHAR_BASE_BLOCK: + ((struct BgCnt *)&sBgCnt)->charBaseBlock = value; + break; + case BG_ANIM_PRIORITY: + ((struct BgCnt *)&sBgCnt)->priority = value; + break; + case BG_ANIM_PALETTES_MODE: + ((struct BgCnt *)&sBgCnt)->palettes = value; + break; + case BG_ANIM_SCREEN_BASE_BLOCK: + ((struct BgCnt *)&sBgCnt)->screenBaseBlock = value; + break; + } + + SetGpuReg(gUnknown_0859741A[bgId], sBgCnt); + } +} + +int GetAnimBgAttribute(u8 bgId, u8 attributeId) +{ + u16 bgCnt; + + if (bgId < 4) + { + bgCnt = GetGpuReg(gUnknown_0859741E[bgId]); + switch (attributeId) + { + case BG_ANIM_SCREEN_SIZE: + return ((struct BgCnt *)&bgCnt)->screenSize; + case BG_ANIM_AREA_OVERFLOW_MODE: + return ((struct BgCnt *)&bgCnt)->areaOverflowMode; + case BG_ANIM_MOSAIC: + return ((struct BgCnt *)&bgCnt)->mosaic; + case BG_ANIM_CHAR_BASE_BLOCK: + return ((struct BgCnt *)&bgCnt)->charBaseBlock; + case BG_ANIM_PRIORITY: + return ((struct BgCnt *)&bgCnt)->priority; + case BG_ANIM_PALETTES_MODE: + return ((struct BgCnt *)&bgCnt)->palettes; + case BG_ANIM_SCREEN_BASE_BLOCK: + return ((struct BgCnt *)&bgCnt)->screenBaseBlock; + } + } + + return 0; +} + +void HandleIntroSlide(u8 terrain) +{ + u8 taskId; + + if ((gBattleTypeFlags & BATTLE_TYPE_INGAME_PARTNER) && gPartnerTrainerId != TRAINER_STEVEN_PARTNER) + { + taskId = CreateTask(BattleIntroSlidePartner, 0); + } + else if (gBattleTypeFlags & BATTLE_TYPE_LINK) + { + taskId = CreateTask(BattleIntroSlideLink, 0); + } + else if (gBattleTypeFlags & BATTLE_TYPE_FRONTIER) + { + taskId = CreateTask(BattleIntroSlide3, 0); + } + else if ((gBattleTypeFlags & BATTLE_TYPE_KYOGRE_GROUDON) && gGameVersion != VERSION_RUBY) + { + terrain = BATTLE_TERRAIN_UNDERWATER; + taskId = CreateTask(BattleIntroSlide2, 0); + } + else + { + taskId = CreateTask(sBattleIntroSlideFuncs[terrain], 0); + } + + gTasks[taskId].data[0] = 0; + gTasks[taskId].data[1] = terrain; + gTasks[taskId].data[2] = 0; + gTasks[taskId].data[3] = 0; + gTasks[taskId].data[4] = 0; + gTasks[taskId].data[5] = 0; + gTasks[taskId].data[6] = 0; +} + +void sub_811828C(u8 taskId) +{ + DestroyTask(taskId); + gBattle_BG1_X = 0; + gBattle_BG1_Y = 0; + gBattle_BG2_X = 0; + gBattle_BG2_Y = 0; + SetGpuReg(REG_OFFSET_BLDCNT, 0); + SetGpuReg(REG_OFFSET_BLDALPHA, 0); + SetGpuReg(REG_OFFSET_BLDY, 0); + SetGpuReg(REG_OFFSET_WININ, WININ_WIN0_BG_ALL | WININ_WIN0_OBJ | WININ_WIN0_CLR | WININ_WIN1_BG_ALL | WININ_WIN1_OBJ | WININ_WIN1_CLR); + SetGpuReg(REG_OFFSET_WINOUT, WINOUT_WIN01_BG_ALL | WINOUT_WIN01_OBJ | WINOUT_WIN01_CLR | WINOUT_WINOBJ_BG_ALL | WINOUT_WINOBJ_OBJ | WINOUT_WINOBJ_CLR); +} + +static void BattleIntroSlide1(u8 taskId) +{ + int i; + + gBattle_BG1_X += 6; + switch (gTasks[taskId].data[0]) + { + case 0: + if (gBattleTypeFlags & BATTLE_TYPE_LINK) + { + gTasks[taskId].data[2] = 16; + gTasks[taskId].data[0]++; + } + else + { + gTasks[taskId].data[2] = 1; + gTasks[taskId].data[0]++; + } + break; + case 1: + if (--gTasks[taskId].data[2] == 0) + { + gTasks[taskId].data[0]++; + SetGpuReg(REG_OFFSET_WININ, WININ_WIN0_BG_ALL | WININ_WIN0_OBJ | WININ_WIN0_CLR); + } + break; + case 2: + gBattle_WIN0V -= 0xFF; + if ((gBattle_WIN0V & 0xFF00) == 0x3000) + { + gTasks[taskId].data[0]++; + gTasks[taskId].data[2] = 240; + gTasks[taskId].data[3] = 32; + gIntroSlideFlags &= ~1; + } + break; + case 3: + if (gTasks[taskId].data[3]) + { + gTasks[taskId].data[3]--; + } + else + { + if (gTasks[taskId].data[1] == 1) + { + if (gBattle_BG1_Y != 0xFFB0) + gBattle_BG1_Y -= 2; + } + else + { + if (gBattle_BG1_Y != 0xFFC8) + gBattle_BG1_Y -= 1; + } + } + + if (gBattle_WIN0V & 0xFF00) + gBattle_WIN0V -= 0x3FC; + + if (gTasks[taskId].data[2]) + gTasks[taskId].data[2] -= 2; + + // Scanline settings have already been set in CB2_InitBattleInternal() + for (i = 0; i < 80; i++) + gScanlineEffectRegBuffers[gScanlineEffect.srcBuffer][i] = gTasks[taskId].data[2]; + + for (; i < 160; i++) + gScanlineEffectRegBuffers[gScanlineEffect.srcBuffer][i] = -gTasks[taskId].data[2]; + + if (!gTasks[taskId].data[2]) + { + gScanlineEffect.state = 3; + gTasks[taskId].data[0]++; + CpuFill32(0, (void *)BG_SCREEN_ADDR(28), BG_SCREEN_SIZE); + SetBgAttribute(1, BG_CTRL_ATTR_VISIBLE, 0); + SetBgAttribute(2, BG_CTRL_ATTR_VISIBLE, 0); + SetGpuReg(REG_OFFSET_BG1CNT, BGCNT_PRIORITY(0) | BGCNT_CHARBASE(0) | BGCNT_16COLOR | BGCNT_SCREENBASE(28) | BGCNT_TXT256x512); + SetGpuReg(REG_OFFSET_BG2CNT, BGCNT_PRIORITY(0) | BGCNT_CHARBASE(0) | BGCNT_16COLOR | BGCNT_SCREENBASE(30) | BGCNT_TXT512x256); + } + break; + case 4: + sub_811828C(taskId); + break; + } +} + +static void BattleIntroSlide2(u8 taskId) +{ + int i; + + switch (gTasks[taskId].data[1]) + { + case 2: + case 4: + gBattle_BG1_X += 8; + break; + case 3: + gBattle_BG1_X += 6; + break; + } + + if (gTasks[taskId].data[1] == 4) + { + u16 *bg1Y = &gBattle_BG1_Y; + int cos = Cos2(gTasks[taskId].data[6]); + if (cos < 0) + cos += 0x1FF; + *bg1Y = (cos >> 9) - 8; + + if (gTasks[taskId].data[6] < 180) + gTasks[taskId].data[6] += 4; + else + gTasks[taskId].data[6] += 6; + + if (gTasks[taskId].data[6] == 360) + gTasks[taskId].data[6] = 0; + } + + switch (gTasks[taskId].data[0]) + { + case 0: + gTasks[taskId].data[4] = 16; + if (gBattleTypeFlags & BATTLE_TYPE_LINK) + { + gTasks[taskId].data[2] = 16; + gTasks[taskId].data[0]++; + } + else + { + gTasks[taskId].data[2] = 1; + gTasks[taskId].data[0]++; + } + break; + case 1: + if (--gTasks[taskId].data[2] == 0) + { + gTasks[taskId].data[0]++; + SetGpuReg(REG_OFFSET_WININ, WININ_WIN0_BG_ALL | WININ_WIN0_OBJ | WININ_WIN0_CLR); + } + break; + case 2: + gBattle_WIN0V -= 0xFF; + if ((gBattle_WIN0V & 0xFF00) == 0x3000) + { + gTasks[taskId].data[0]++; + gTasks[taskId].data[2] = 240; + gTasks[taskId].data[3] = 32; + gTasks[taskId].data[5] = 1; + gIntroSlideFlags &= ~1; + } + break; + case 3: + if (gTasks[taskId].data[3]) + { + if (--gTasks[taskId].data[3] == 0) + { + SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_TGT1_BG1 | BLDCNT_EFFECT_BLEND | BLDCNT_TGT2_BG3 | BLDCNT_TGT2_OBJ); + SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(15, 0)); + SetGpuReg(REG_OFFSET_BLDY, 0); + } + } + else + { + if ((gTasks[taskId].data[4] & 0x1F) && --gTasks[taskId].data[5] == 0) + { + gTasks[taskId].data[4] += 0xFF; + gTasks[taskId].data[5] = 4; + } + } + + if (gBattle_WIN0V & 0xFF00) + gBattle_WIN0V -= 0x3FC; + + if (gTasks[taskId].data[2]) + gTasks[taskId].data[2] -= 2; + + // Scanline settings have already been set in CB2_InitBattleInternal() + for (i = 0; i < 80; i++) + gScanlineEffectRegBuffers[gScanlineEffect.srcBuffer][i] = gTasks[taskId].data[2]; + + for (; i < 160; i++) + gScanlineEffectRegBuffers[gScanlineEffect.srcBuffer][i] = -gTasks[taskId].data[2]; + + if (!gTasks[taskId].data[2]) + { + gScanlineEffect.state = 3; + gTasks[taskId].data[0]++; + CpuFill32(0, (void *)BG_SCREEN_ADDR(28), BG_SCREEN_SIZE); + SetBgAttribute(1, BG_CTRL_ATTR_VISIBLE, 0); + SetBgAttribute(2, BG_CTRL_ATTR_VISIBLE, 0); + SetGpuReg(REG_OFFSET_BG1CNT, BGCNT_PRIORITY(0) | BGCNT_CHARBASE(0) | BGCNT_16COLOR | BGCNT_SCREENBASE(28) | BGCNT_TXT256x512); + SetGpuReg(REG_OFFSET_BG2CNT, BGCNT_PRIORITY(0) | BGCNT_CHARBASE(0) | BGCNT_16COLOR | BGCNT_SCREENBASE(30) | BGCNT_TXT512x256); + } + break; + case 4: + sub_811828C(taskId); + break; + } + + if (gTasks[taskId].data[0] != 4) + SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(gTasks[taskId].data[4], 0)); +} + +static void BattleIntroSlide3(u8 taskId) +{ + int i; + + gBattle_BG1_X += 8; + switch (gTasks[taskId].data[0]) + { + case 0: + SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_TGT1_BG1 | BLDCNT_EFFECT_BLEND | BLDCNT_TGT2_BG3 | BLDCNT_TGT2_OBJ); + SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(8, 8)); + SetGpuReg(REG_OFFSET_BLDY, 0); + gTasks[taskId].data[4] = BLDALPHA_BLEND(8, 8); + if (gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_x2000000)) + { + gTasks[taskId].data[2] = 16; + gTasks[taskId].data[0]++; + } + else + { + gTasks[taskId].data[2] = 1; + gTasks[taskId].data[0]++; + } + break; + case 1: + if (--gTasks[taskId].data[2] == 0) + { + gTasks[taskId].data[0]++; + SetGpuReg(REG_OFFSET_WININ, WININ_WIN0_BG_ALL | WININ_WIN0_OBJ | WININ_WIN0_CLR); + } + break; + case 2: + gBattle_WIN0V -= 0xFF; + if ((gBattle_WIN0V & 0xFF00) == 0x3000) + { + gTasks[taskId].data[0]++; + gTasks[taskId].data[2] = 240; + gTasks[taskId].data[3] = 32; + gTasks[taskId].data[5] = 1; + gIntroSlideFlags &= ~1; + } + break; + case 3: + if (gTasks[taskId].data[3]) + { + gTasks[taskId].data[3]--; + } + else + { + if ((gTasks[taskId].data[4] & 0xF) && --gTasks[taskId].data[5] == 0) + { + gTasks[taskId].data[4] += 0xFF; + gTasks[taskId].data[5] = 6; + } + } + + if (gBattle_WIN0V & 0xFF00) + gBattle_WIN0V -= 0x3FC; + + if (gTasks[taskId].data[2]) + gTasks[taskId].data[2] -= 2; + + // Scanline settings have already been set in CB2_InitBattleInternal() + for (i = 0; i < 80; i++) + gScanlineEffectRegBuffers[gScanlineEffect.srcBuffer][i] = gTasks[taskId].data[2]; + + for (; i < 160; i++) + gScanlineEffectRegBuffers[gScanlineEffect.srcBuffer][i] = -gTasks[taskId].data[2]; + + if (!gTasks[taskId].data[2]) + { + gScanlineEffect.state = 3; + gTasks[taskId].data[0]++; + CpuFill32(0, (void *)BG_SCREEN_ADDR(28), BG_SCREEN_SIZE); + SetBgAttribute(1, BG_CTRL_ATTR_VISIBLE, 0); + SetBgAttribute(2, BG_CTRL_ATTR_VISIBLE, 0); + SetGpuReg(REG_OFFSET_BG1CNT, BGCNT_PRIORITY(0) | BGCNT_CHARBASE(0) | BGCNT_16COLOR | BGCNT_SCREENBASE(28) | BGCNT_TXT256x512); + SetGpuReg(REG_OFFSET_BG2CNT, BGCNT_PRIORITY(0) | BGCNT_CHARBASE(0) | BGCNT_16COLOR | BGCNT_SCREENBASE(30) | BGCNT_TXT512x256); + } + break; + case 4: + sub_811828C(taskId); + break; + } + + if (gTasks[taskId].data[0] != 4) + SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(gTasks[taskId].data[4], 0)); +} + +static void BattleIntroSlideLink(u8 taskId) +{ + int i; + + if (gTasks[taskId].data[0] > 1 && !gTasks[taskId].data[4]) + { + u16 var0 = gBattle_BG1_X & 0x8000; + if (var0 || gBattle_BG1_X < 80) + { + gBattle_BG1_X += 3; + gBattle_BG2_X -= 3; + } + else + { + CpuFill32(0, (void *)BG_SCREEN_ADDR(28), BG_SCREEN_SIZE); + CpuFill32(0, (void *)BG_SCREEN_ADDR(30), BG_SCREEN_SIZE); + gTasks[taskId].data[4] = 1; + } + } + + switch (gTasks[taskId].data[0]) + { + case 0: + gTasks[taskId].data[2] = 32; + gTasks[taskId].data[0]++; + break; + case 1: + if (--gTasks[taskId].data[2] == 0) + { + gTasks[taskId].data[0]++; + gSprites[gBattleStruct->field_7D].oam.objMode = ST_OAM_OBJ_WINDOW; + gSprites[gBattleStruct->field_7D].callback = sub_8038B74; + gSprites[gBattleStruct->field_7E].oam.objMode = ST_OAM_OBJ_WINDOW; + gSprites[gBattleStruct->field_7E].callback = sub_8038B74; + SetGpuReg(REG_OFFSET_WININ, WININ_WIN0_BG_ALL | WININ_WIN0_OBJ | WININ_WIN0_CLR); + SetGpuReg(REG_OFFSET_WINOUT, WINOUT_WINOBJ_BG_ALL | WINOUT_WINOBJ_OBJ | WINOUT_WINOBJ_CLR | WINOUT_WIN01_BG1 | WINOUT_WIN01_BG2); + } + break; + case 2: + gBattle_WIN0V -= 0xFF; + if ((gBattle_WIN0V & 0xFF00) == 0x3000) + { + gTasks[taskId].data[0]++; + gTasks[taskId].data[2] = 240; + gTasks[taskId].data[3] = 32; + gIntroSlideFlags &= ~1; + } + break; + case 3: + if (gBattle_WIN0V & 0xFF00) + gBattle_WIN0V -= 0x3FC; + + if (gTasks[taskId].data[2]) + gTasks[taskId].data[2] -= 2; + + // Scanline settings have already been set in CB2_InitBattleInternal() + for (i = 0; i < 80; i++) + gScanlineEffectRegBuffers[gScanlineEffect.srcBuffer][i] = gTasks[taskId].data[2]; + + for (; i < 160; i++) + gScanlineEffectRegBuffers[gScanlineEffect.srcBuffer][i] = -gTasks[taskId].data[2]; + + if (!gTasks[taskId].data[2]) + { + gScanlineEffect.state = 3; + gTasks[taskId].data[0]++; + SetBgAttribute(1, BG_CTRL_ATTR_VISIBLE, 0); + SetBgAttribute(2, BG_CTRL_ATTR_VISIBLE, 0); + SetGpuReg(REG_OFFSET_BG1CNT, BGCNT_PRIORITY(0) | BGCNT_CHARBASE(0) | BGCNT_16COLOR | BGCNT_SCREENBASE(28) | BGCNT_TXT256x512); + SetGpuReg(REG_OFFSET_BG2CNT, BGCNT_PRIORITY(0) | BGCNT_CHARBASE(0) | BGCNT_16COLOR | BGCNT_SCREENBASE(30) | BGCNT_TXT512x256); + } + break; + case 4: + sub_811828C(taskId); + break; + } +} + +static void BattleIntroSlidePartner(u8 taskId) +{ + switch (gTasks[taskId].data[0]) + { + case 0: + gTasks[taskId].data[2] = 1; + gTasks[taskId].data[0]++; + break; + case 1: + if (--gTasks[taskId].data[2] == 0) + { + gTasks[taskId].data[0]++; + SetGpuReg(REG_OFFSET_BG1CNT, BGCNT_PRIORITY(2) | BGCNT_CHARBASE(2) | BGCNT_16COLOR | BGCNT_SCREENBASE(28) | BGCNT_TXT512x256); + SetGpuReg(REG_OFFSET_BG2CNT, BGCNT_PRIORITY(2) | BGCNT_CHARBASE(2) | BGCNT_16COLOR | BGCNT_SCREENBASE(30) | BGCNT_TXT512x256); + SetGpuReg(REG_OFFSET_DISPCNT, GetGpuReg(REG_OFFSET_DISPCNT) | DISPCNT_OBJ_1D_MAP | DISPCNT_OBJ_ON | DISPCNT_WIN0_ON | DISPCNT_WIN1_ON | DISPCNT_OBJWIN_ON); + SetGpuReg(REG_OFFSET_WININ, WININ_WIN1_BG1 | WININ_WIN1_BG2 | WININ_WIN1_BG3 | WININ_WIN1_OBJ | WININ_WIN1_CLR); + SetGpuReg(REG_OFFSET_WINOUT, WINOUT_WIN01_BG_ALL | WINOUT_WIN01_OBJ | WINOUT_WIN01_CLR | WINOUT_WINOBJ_BG_ALL | WINOUT_WINOBJ_OBJ | WINOUT_WINOBJ_CLR); + gBattle_BG0_Y = -48; + gBattle_BG1_X = 240; + gBattle_BG2_X = -240; + } + break; + case 2: + gBattle_WIN0V += 0x100; + if ((gBattle_WIN0V & 0xFF00) != 0x100) + gBattle_WIN0V--; + + if ((gBattle_WIN0V & 0xFF00) == 0x2000) + { + gTasks[taskId].data[0]++; + gTasks[taskId].data[2] = 240; + gIntroSlideFlags &= ~1; + } + break; + case 3: + if ((gBattle_WIN0V & 0xFF00) != 0x4C00) + gBattle_WIN0V += 0x3FC; + + if (gTasks[taskId].data[2]) + gTasks[taskId].data[2] -= 2; + + gBattle_BG1_X = gTasks[taskId].data[2]; + gBattle_BG2_X = -gTasks[taskId].data[2]; + if (!gTasks[taskId].data[2]) + gTasks[taskId].data[0]++; + break; + case 4: + gBattle_BG0_Y += 2; + gBattle_BG2_Y += 2; + if ((gBattle_WIN0V & 0xFF00) != 0x5000) + gBattle_WIN0V += 0xFF; + + if (!gBattle_BG0_Y) + { + CpuFill32(0, (void *)BG_SCREEN_ADDR(28), BG_SCREEN_SIZE * 4); + SetGpuReg(REG_OFFSET_DISPCNT, GetGpuReg(REG_OFFSET_DISPCNT) & ~DISPCNT_WIN1_ON); + SetBgAttribute(1, BG_CTRL_ATTR_VISIBLE, 0); + SetBgAttribute(2, BG_CTRL_ATTR_VISIBLE, 0); + SetGpuReg(REG_OFFSET_BG1CNT, BGCNT_PRIORITY(0) | BGCNT_CHARBASE(0) | BGCNT_16COLOR | BGCNT_SCREENBASE(28) | BGCNT_TXT256x512); + SetGpuReg(REG_OFFSET_BG2CNT, BGCNT_PRIORITY(0) | BGCNT_CHARBASE(0) | BGCNT_16COLOR | BGCNT_SCREENBASE(30) | BGCNT_TXT512x256); + gScanlineEffect.state = 3; + gTasks[taskId].data[0]++; + } + break; + case 5: + sub_811828C(taskId); + break; + } +} + +void sub_8118FBC(int bgId, u8 arg1, u8 arg2, u8 battlerPosition, u8 arg4, u8 *arg5, u16 *arg6, u16 tilesOffset) +{ + int i, j; + u8 battler = GetBattlerAtPosition(battlerPosition); + int offset = tilesOffset; + CpuCopy16(gMonSpritesGfxPtr->sprites[battlerPosition] + BG_SCREEN_SIZE * gBattleMonForms[battler], arg5, BG_SCREEN_SIZE); + LoadBgTiles(bgId, arg5, 0x1000, tilesOffset); + for (i = arg2; i < arg2 + 8; i++) + { + for (j = arg1; j < arg1 + 8; j++) + { + arg6[i * 32 + j] = offset | (arg4 << 12); + offset++; + } + } + + LoadBgTilemap(bgId, arg6, BG_SCREEN_SIZE, 0); +} + +#ifdef NONMATCHING +void unref_sub_8119094(u8 arg0, u8 arg1, u8 battlerPosition, u8 arg3, u8 arg4, u16 arg5, u8 arg6, u8 arg7) +{ + int i, j; + int offset; + DmaCopy16(3, gMonSpritesGfxPtr->sprites[battlerPosition] + BG_SCREEN_SIZE * arg3, (void *)BG_SCREEN_ADDR(0) + arg5, BG_SCREEN_SIZE); + offset = (arg5 >> 5) - (arg7 << 9); + for (i = arg1; i < arg1 + 8; i++) + { + for (j = arg0; j < arg0 + 8; j++) + { + ((u16 *)BG_VRAM)[i * 32 + j + (arg6 * 0x400) + arg0] = offset | (arg4 << 12); + offset++; + } + } +} +#else +NAKED +void unref_sub_8119094(u8 arg0, u8 arg1, u8 battlerPosition, u8 arg3, u8 arg4, u16 arg5, u8 arg6, u8 arg7) +{ + asm_unified("\n\ + push {r4-r7,lr}\n\ + mov r7, r10\n\ + mov r6, r9\n\ + mov r5, r8\n\ + push {r5-r7}\n\ + sub sp, 0x4\n\ + ldr r4, [sp, 0x24]\n\ + ldr r5, [sp, 0x28]\n\ + mov r8, r5\n\ + ldr r5, [sp, 0x2C]\n\ + ldr r6, [sp, 0x30]\n\ + mov r9, r6\n\ + lsls r0, 24\n\ + lsrs r0, 24\n\ + mov r12, r0\n\ + lsls r1, 24\n\ + lsls r2, 24\n\ + lsls r3, 24\n\ + lsls r4, 24\n\ + lsrs r4, 24\n\ + mov r10, r4\n\ + mov r7, r8\n\ + lsls r7, 16\n\ + lsrs r6, r7, 16\n\ + lsls r5, 24\n\ + lsrs r5, 24\n\ + mov r0, r9\n\ + lsls r0, 24\n\ + mov r9, r0\n\ + ldr r4, =0x040000d4\n\ + ldr r0, =gMonSpritesGfxPtr\n\ + ldr r0, [r0]\n\ + lsrs r2, 22\n\ + adds r0, 0x4\n\ + adds r0, r2\n\ + lsrs r3, 13\n\ + ldr r0, [r0]\n\ + adds r0, r3\n\ + str r0, [r4]\n\ + movs r0, 0xC0\n\ + lsls r0, 19\n\ + adds r6, r0\n\ + str r6, [r4, 0x4]\n\ + ldr r0, =0x80000400\n\ + str r0, [r4, 0x8]\n\ + ldr r0, [r4, 0x8]\n\ + adds r2, r7, 0\n\ + lsrs r2, 21\n\ + mov r6, r9\n\ + lsrs r6, 15\n\ + subs r4, r2, r6\n\ + lsrs r0, r1, 24\n\ + adds r1, r0, 0\n\ + adds r1, 0x8\n\ + cmp r0, r1\n\ + bge _08119148\n\ + mov r9, r1\n\ + mov r7, r12\n\ + lsls r7, 1\n\ + mov r8, r7\n\ + lsls r5, 11\n\ + str r5, [sp]\n\ +_08119110:\n\ + mov r2, r12\n\ + adds r3, r2, 0\n\ + adds r3, 0x8\n\ + adds r5, r0, 0x1\n\ + cmp r2, r3\n\ + bge _08119142\n\ + mov r1, r10\n\ + lsls r6, r1, 12\n\ + lsls r0, 6\n\ + movs r7, 0xC0\n\ + lsls r7, 19\n\ + adds r0, r7\n\ + ldr r1, [sp]\n\ + adds r0, r1, r0\n\ + mov r7, r8\n\ + adds r1, r7, r0\n\ + subs r2, r3, r2\n\ +_08119132:\n\ + adds r0, r4, 0\n\ + orrs r0, r6\n\ + strh r0, [r1]\n\ + adds r4, 0x1\n\ + adds r1, 0x2\n\ + subs r2, 0x1\n\ + cmp r2, 0\n\ + bne _08119132\n\ +_08119142:\n\ + adds r0, r5, 0\n\ + cmp r0, r9\n\ + blt _08119110\n\ +_08119148:\n\ + add sp, 0x4\n\ + pop {r3-r5}\n\ + mov r8, r3\n\ + mov r9, r4\n\ + mov r10, r5\n\ + pop {r4-r7}\n\ + pop {r0}\n\ + bx r0\n\ + .pool"); +} +#endif diff --git a/src/battle_main.c b/src/battle_main.c index 9b7f58023..fb2e5105a 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -81,7 +81,7 @@ extern const u8 *const gBattlescriptsForBallThrow[]; extern const u8 *const gBattlescriptsForRunningByItem[]; extern const u8 *const gBattlescriptsForUsingItem[]; extern const u8 *const gBattlescriptsForSafariActions[]; -extern const struct ScanlineEffectParams gUnknown_0831AC70; +extern const struct ScanlineEffectParams gBattleIntroSlideScanlineEffectParams; // strings extern const u8 gText_LinkStandby3[]; @@ -633,7 +633,7 @@ static void CB2_InitBattleInternal(void) gScanlineEffectRegBuffers[1][i] = 0xFF10; } - ScanlineEffect_SetParams(gUnknown_0831AC70); + ScanlineEffect_SetParams(gBattleIntroSlideScanlineEffectParams); } ResetPaletteFade(); diff --git a/src/easy_chat.c b/src/easy_chat.c index 25ef069e4..c4bc02e42 100644 --- a/src/easy_chat.c +++ b/src/easy_chat.c @@ -51,6 +51,9 @@ EWRAM_DATA struct u16 ecWordBuffer[9]; } *gUnknown_0203A118 = NULL; +EWRAM_DATA void *gUnknown_0203A11C = 0; +EWRAM_DATA void *gUnknown_0203A120 = 0; + // Static ROM declarations static void sub_811A2C0(u8); diff --git a/sym_ewram.txt b/sym_ewram.txt index b413f287d..4f77532b2 100644 --- a/sym_ewram.txt +++ b/sym_ewram.txt @@ -292,19 +292,8 @@ gUnknown_0203A100: @ 203A100 .space 0x10 .include "src/battle_anim_utility_funcs.o" - -gUnknown_0203A114: @ 203A114 - .space 0x4 - -gUnknown_0203A118: @ 203A118 - .space 0x4 - -gUnknown_0203A11C: @ 203A11C - .space 0x4 - -gUnknown_0203A120: @ 203A120 - .space 0x4 - + .include "src/battle_intro.o" + .include "src/easy_chat.o" .include "src/mon_markings.o" .include "src/mauville_old_man.o" .include "src/mail.o"