diff --git a/asm/battle_anim_utility_funcs.s b/asm/battle_anim_utility_funcs.s deleted file mode 100644 index 138d303ac0..0000000000 --- a/asm/battle_anim_utility_funcs.s +++ /dev/null @@ -1,3059 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .syntax unified - - .text - - thumb_func_start sub_8116620 -sub_8116620: @ 8116620 - push {r4-r6,lr} - adds r5, r0, 0 - lsls r5, 24 - lsrs r5, 24 - ldr r4, =gBattleAnimArgs - movs r1, 0 - ldrsh r0, [r4, r1] - bl sub_811583C - adds r6, r0, 0 - ldrh r3, [r4] - lsls r3, 16 - asrs r0, r3, 23 - movs r4, 0x1 - ands r0, r4 - asrs r1, r3, 24 - ands r1, r4 - asrs r2, r3, 25 - ands r2, r4 - asrs r3, 26 - ands r3, r4 - bl sub_80A76C4 - orrs r6, r0 - adds r0, r5, 0 - adds r1, r6, 0 - bl sub_8116874 - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8116620 - - thumb_func_start sub_8116664 -sub_8116664: @ 8116664 - push {r4-r7,lr} - sub sp, 0x4 - lsls r0, 24 - lsrs r7, r0, 24 - mov r1, sp - movs r0, 0xFF - strb r0, [r1, 0x1] - movs r0, 0x1 - bl sub_811583C - adds r5, r0, 0 - ldr r0, =gBattleAnimArgs - movs r1, 0 - ldrsh r0, [r0, r1] - cmp r0, 0x7 - bhi _0811670E - lsls r0, 2 - ldr r1, =_08116698 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_08116698: - .4byte _081166BA - .4byte _081166C6 - .4byte _081166B8 - .4byte _081166C4 - .4byte _081166D4 - .4byte _081166EC - .4byte _081166F4 - .4byte _08116700 -_081166B8: - movs r5, 0 -_081166BA: - mov r0, sp - ldr r1, =gBattleAnimAttacker - b _081166CA - .pool -_081166C4: - movs r5, 0 -_081166C6: - mov r0, sp - ldr r1, =gBattleAnimTarget -_081166CA: - ldrb r1, [r1] - strb r1, [r0] - b _0811670E - .pool -_081166D4: - mov r1, sp - ldr r0, =gBattleAnimAttacker - ldrb r0, [r0] - strb r0, [r1] - ldr r0, =gBattleAnimTarget - ldrb r0, [r0] - strb r0, [r1, 0x1] - b _0811670E - .pool -_081166EC: - mov r1, sp - movs r0, 0xFF - strb r0, [r1] - b _0811670E -_081166F4: - movs r5, 0 - mov r2, sp - ldr r0, =gBattleAnimAttacker - b _08116706 - .pool -_08116700: - movs r5, 0 - mov r2, sp - ldr r0, =gBattleAnimTarget -_08116706: - ldrb r0, [r0] - movs r1, 0x2 - eors r0, r1 - strb r0, [r2] -_0811670E: - movs r4, 0 - mov r6, sp -_08116712: - ldrb r0, [r6] - cmp r4, r0 - beq _0811673C - ldrb r0, [r6, 0x1] - cmp r4, r0 - beq _0811673C - adds r0, r4, 0 - bl IsBattlerSpriteVisible - lsls r0, 24 - cmp r0, 0 - beq _0811673C - adds r0, r4, 0 - bl sub_80A77AC - lsls r0, 24 - lsrs r0, 24 - movs r1, 0x80 - lsls r1, 9 - lsls r1, r0 - orrs r5, r1 -_0811673C: - adds r0, r4, 0x1 - lsls r0, 24 - lsrs r4, r0, 24 - cmp r4, 0x3 - bls _08116712 - adds r0, r7, 0 - adds r1, r5, 0 - bl sub_8116874 - add sp, 0x4 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8116664 - - thumb_func_start sub_811675C -sub_811675C: @ 811675C - push {r4,lr} - lsls r0, 24 - lsrs r4, r0, 24 - ldr r0, =gBattleAnimArgs - movs r1, 0 - ldrsh r0, [r0, r1] - bl sub_811583C - adds r2, r0, 0 - ldr r0, =gBattleTerrain - ldrb r0, [r0] - cmp r0, 0x9 - bhi _08116832 - lsls r0, 2 - ldr r1, =_0811678C - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_0811678C: - .4byte _081167B4 - .4byte _081167C4 - .4byte _081167D0 - .4byte _081167E0 - .4byte _081167EC - .4byte _081167FC - .4byte _0811680C - .4byte _0811681C - .4byte _0811682C - .4byte _0811682C -_081167B4: - ldr r1, =gBattleAnimArgs - ldr r0, =0x00000b0c - b _08116830 - .pool -_081167C4: - ldr r1, =gBattleAnimArgs - movs r0, 0x9E - lsls r0, 4 - b _08116830 - .pool -_081167D0: - ldr r1, =gBattleAnimArgs - ldr r0, =0x00002f1e - b _08116830 - .pool -_081167E0: - ldr r1, =gBattleAnimArgs - movs r0, 0x90 - lsls r0, 7 - b _08116830 - .pool -_081167EC: - ldr r1, =gBattleAnimArgs - ldr r0, =0x00007ecb - b _08116830 - .pool -_081167FC: - ldr r1, =gBattleAnimArgs - ldr r0, =0x00007ecb - b _08116830 - .pool -_0811680C: - ldr r1, =gBattleAnimArgs - ldr r0, =0x00002a16 - b _08116830 - .pool -_0811681C: - ldr r1, =gBattleAnimArgs - ldr r0, =0x00000d2e - b _08116830 - .pool -_0811682C: - ldr r1, =gBattleAnimArgs - ldr r0, =0x00007fff -_08116830: - strh r0, [r1, 0x8] -_08116832: - adds r0, r4, 0 - adds r1, r2, 0 - bl sub_8116874 - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_811675C - - thumb_func_start AnimTask_BlendParticle -AnimTask_BlendParticle: @ 8116848 - push {r4,lr} - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - ldr r0, =gBattleAnimArgs - ldrh r0, [r0] - bl IndexOfSpritePaletteTag - lsls r0, 24 - lsrs r0, 24 - adds r0, 0x10 - movs r1, 0x1 - lsls r1, r0 - adds r0, r4, 0 - bl sub_8116874 - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end AnimTask_BlendParticle - - thumb_func_start sub_8116874 -sub_8116874: @ 8116874 - push {lr} - lsls r0, 24 - lsrs r0, 24 - ldr r3, =gTasks - lsls r2, r0, 2 - adds r2, r0 - lsls r2, 3 - adds r2, r3 - strh r1, [r2, 0x8] - lsrs r1, 16 - strh r1, [r2, 0xA] - ldr r3, =gBattleAnimArgs - ldrh r1, [r3, 0x2] - strh r1, [r2, 0xC] - ldrh r1, [r3, 0x4] - strh r1, [r2, 0xE] - ldrh r1, [r3, 0x6] - strh r1, [r2, 0x10] - ldrh r1, [r3, 0x8] - strh r1, [r2, 0x12] - ldrh r1, [r3, 0x4] - strh r1, [r2, 0x1C] - ldr r1, =sub_81168B8 - str r1, [r2] - bl _call_via_r1 - pop {r0} - bx r0 - .pool - thumb_func_end sub_8116874 - - thumb_func_start sub_81168B8 -sub_81168B8: @ 81168B8 - push {r4-r7,lr} - mov r7, r9 - mov r6, r8 - push {r6,r7} - lsls r0, 24 - lsrs r7, r0, 24 - movs r6, 0 - ldr r2, =gTasks - lsls r5, r7, 2 - adds r0, r5, r7 - lsls r0, 3 - adds r3, r0, r2 - ldrh r0, [r3, 0x1A] - mov r8, r0 - movs r4, 0x1A - ldrsh r1, [r3, r4] - movs r4, 0xC - ldrsh r0, [r3, r4] - mov r9, r2 - cmp r1, r0 - bne _0811694E - strh r6, [r3, 0x1A] - movs r0, 0x8 - ldrsh r4, [r3, r0] - movs r1, 0xA - ldrsh r0, [r3, r1] - lsls r0, 16 - orrs r4, r0 - mov r8, r5 - cmp r4, 0 - beq _0811691A - adds r5, r3, 0 -_081168F8: - movs r0, 0x1 - ands r0, r4 - cmp r0, 0 - beq _0811690C - ldrb r2, [r5, 0x1C] - ldrh r3, [r5, 0x12] - adds r0, r6, 0 - movs r1, 0x10 - bl BlendPalette -_0811690C: - adds r0, r6, 0 - adds r0, 0x10 - lsls r0, 16 - lsrs r6, r0, 16 - lsrs r4, 1 - cmp r4, 0 - bne _081168F8 -_0811691A: - mov r4, r8 - adds r0, r4, r7 - lsls r0, 3 - mov r1, r9 - adds r2, r0, r1 - ldrh r0, [r2, 0x1C] - movs r4, 0x1C - ldrsh r3, [r2, r4] - movs r4, 0x10 - ldrsh r1, [r2, r4] - cmp r3, r1 - bge _0811693C - adds r0, 0x1 - strh r0, [r2, 0x1C] - b _08116954 - .pool -_0811693C: - cmp r3, r1 - ble _08116946 - subs r0, 0x1 - strh r0, [r2, 0x1C] - b _08116954 -_08116946: - adds r0, r7, 0 - bl DestroyAnimVisualTask - b _08116954 -_0811694E: - mov r0, r8 - adds r0, 0x1 - strh r0, [r3, 0x1A] -_08116954: - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end sub_81168B8 - - thumb_func_start sub_8116960 -sub_8116960: @ 8116960 - push {r4,r5,lr} - sub sp, 0x4 - adds r5, r0, 0 - lsls r5, 24 - lsrs r5, 24 - ldr r4, =gBattleAnimArgs - ldrb r0, [r4] - ldrb r1, [r4, 0x2] - ldrb r2, [r4, 0x4] - ldrb r3, [r4, 0x6] - ldrb r4, [r4, 0x8] - str r4, [sp] - bl BeginHardwarePaletteFade - ldr r1, =gTasks - lsls r0, r5, 2 - adds r0, r5 - lsls r0, 3 - adds r0, r1 - ldr r1, =sub_81169A0 - str r1, [r0] - add sp, 0x4 - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8116960 - - thumb_func_start sub_81169A0 -sub_81169A0: @ 81169A0 - push {lr} - lsls r0, 24 - lsrs r2, r0, 24 - ldr r0, =gPaletteFade - ldrb r1, [r0, 0x7] - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - bne _081169B8 - adds r0, r2, 0 - bl DestroyAnimVisualTask -_081169B8: - pop {r0} - bx r0 - .pool - thumb_func_end sub_81169A0 - - thumb_func_start sub_81169C0 -sub_81169C0: @ 81169C0 - lsls r0, 24 - lsrs r0, 24 - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 3 - ldr r0, =gTasks - adds r1, r0 - ldr r2, =gBattleAnimArgs - ldrh r0, [r2] - movs r3, 0 - strh r0, [r1, 0x8] - strh r3, [r1, 0xA] - ldrh r0, [r2, 0x2] - strh r0, [r1, 0xC] - ldrh r0, [r2, 0x4] - strh r0, [r1, 0xE] - ldrh r0, [r2, 0x6] - strh r0, [r1, 0x10] - strh r3, [r1, 0x12] - ldr r0, =sub_81169F8 - str r0, [r1] - bx lr - .pool - thumb_func_end sub_81169C0 - - thumb_func_start sub_81169F8 -sub_81169F8: @ 81169F8 - push {r4-r6,lr} - lsls r0, 24 - lsrs r5, r0, 24 - adds r2, r5, 0 - lsls r0, r5, 2 - adds r0, r5 - lsls r0, 3 - ldr r1, =gTasks - adds r4, r0, r1 - movs r1, 0x10 - ldrsh r0, [r4, r1] - cmp r0, 0 - beq _08116ABC - ldrh r1, [r4, 0xA] - movs r2, 0xA - ldrsh r0, [r4, r2] - cmp r0, 0 - beq _08116A28 - subs r0, r1, 0x1 - strh r0, [r4, 0xA] - b _08116ACA - .pool -_08116A28: - ldrb r0, [r4, 0x8] - bl duplicate_obj_of_side_rel2move_in_transparent_mode - strh r0, [r4, 0x14] - lsls r0, 16 - cmp r0, 0 - blt _08116AA6 - ldr r6, =gSprites - movs r1, 0x14 - ldrsh r0, [r4, r1] - lsls r1, r0, 4 - adds r1, r0 - lsls r1, 2 - adds r3, r1, r6 - movs r2, 0x8 - ldrsh r0, [r4, r2] - movs r2, 0x2 - cmp r0, 0 - beq _08116A50 - movs r2, 0x1 -_08116A50: - lsls r2, 2 - ldrb r1, [r3, 0x5] - movs r0, 0xD - negs r0, r0 - ands r0, r1 - orrs r0, r2 - strb r0, [r3, 0x5] - movs r0, 0x14 - ldrsh r1, [r4, r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r6 - ldrh r1, [r4, 0xE] - strh r1, [r0, 0x2E] - movs r2, 0x14 - ldrsh r1, [r4, r2] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r6 - strh r5, [r0, 0x30] - movs r0, 0x14 - ldrsh r1, [r4, r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r6 - movs r1, 0x5 - strh r1, [r0, 0x32] - movs r2, 0x14 - ldrsh r1, [r4, r2] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r1, r6, 0 - adds r1, 0x1C - adds r0, r1 - ldr r1, =sub_8116AD0 - str r1, [r0] - ldrh r0, [r4, 0x12] - adds r0, 0x1 - strh r0, [r4, 0x12] -_08116AA6: - ldrh r0, [r4, 0x10] - subs r0, 0x1 - strh r0, [r4, 0x10] - ldrh r0, [r4, 0xC] - strh r0, [r4, 0xA] - b _08116ACA - .pool -_08116ABC: - movs r1, 0x12 - ldrsh r0, [r4, r1] - cmp r0, 0 - bne _08116ACA - adds r0, r2, 0 - bl DestroyAnimVisualTask -_08116ACA: - pop {r4-r6} - pop {r0} - bx r0 - thumb_func_end sub_81169F8 - - thumb_func_start sub_8116AD0 -sub_8116AD0: @ 8116AD0 - push {r4,lr} - adds r4, r0, 0 - ldrh r1, [r4, 0x2E] - movs r2, 0x2E - ldrsh r0, [r4, r2] - cmp r0, 0 - beq _08116AE4 - subs r0, r1, 0x1 - strh r0, [r4, 0x2E] - b _08116B08 -_08116AE4: - ldr r3, =gTasks - movs r0, 0x32 - ldrsh r1, [r4, r0] - lsls r1, 1 - movs r0, 0x30 - ldrsh r2, [r4, r0] - lsls r0, r2, 2 - adds r0, r2 - lsls r0, 3 - adds r1, r0 - adds r3, 0x8 - adds r1, r3 - ldrh r0, [r1] - subs r0, 0x1 - strh r0, [r1] - adds r0, r4, 0 - bl obj_delete_but_dont_free_vram -_08116B08: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8116AD0 - - thumb_func_start sub_8116B14 -sub_8116B14: @ 8116B14 - push {r4-r7,lr} - mov r7, r9 - mov r6, r8 - push {r6,r7} - sub sp, 0x14 - lsls r0, 24 - lsrs r0, 24 - mov r9, r0 - movs r7, 0 - ldr r0, =gBattle_WIN0H - strh r7, [r0] - ldr r0, =gBattle_WIN0V - strh r7, [r0] - ldr r1, =0x00003f3f - movs r0, 0x48 - bl SetGpuReg - ldr r1, =0x00003f3d - movs r0, 0x4A - bl SetGpuReg - movs r1, 0x80 - lsls r1, 8 - movs r0, 0 - bl SetGpuRegBits - ldr r1, =0x00003f42 - movs r0, 0x50 - bl SetGpuReg - ldr r1, =0x00000c08 - movs r0, 0x52 - bl SetGpuReg - movs r0, 0xA - bl GetGpuReg - add r4, sp, 0x10 - strh r0, [r4] - ldrb r1, [r4] - movs r0, 0x4 - negs r0, r0 - mov r8, r0 - ands r0, r1 - strb r0, [r4] - mov r2, sp - adds r2, 0x11 - ldrb r1, [r2] - movs r0, 0x3F - ands r0, r1 - strb r0, [r2] - ldrh r1, [r4] - movs r0, 0xA - bl SetGpuReg - bl IsContest - lsls r0, 24 - cmp r0, 0 - bne _08116BA2 - ldrb r1, [r4] - movs r0, 0xD - negs r0, r0 - ands r0, r1 - movs r1, 0x4 - orrs r0, r1 - strb r0, [r4] - ldrh r1, [r4] - movs r0, 0xA - bl SetGpuReg -_08116BA2: - bl IsDoubleBattle - lsls r0, 24 - cmp r0, 0 - beq _08116C26 - bl IsContest - lsls r0, 24 - cmp r0, 0 - bne _08116C26 - ldr r5, =gBattleAnimAttacker - ldrb r0, [r5] - bl GetBattlerPosition - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x3 - beq _08116BD2 - ldrb r0, [r5] - bl GetBattlerPosition - lsls r0, 24 - cmp r0, 0 - bne _08116C26 -_08116BD2: - ldrb r0, [r5] - movs r6, 0x2 - eors r0, r6 - bl IsBattlerSpriteVisible - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _08116C26 - ldr r3, =gSprites - ldr r1, =gBattlerSpriteIds - ldrb r0, [r5] - eors r0, r6 - adds r0, r1 - ldrb r0, [r0] - lsls r2, r0, 4 - adds r2, r0 - lsls r2, 2 - adds r2, r3 - ldrb r3, [r2, 0x5] - lsls r1, r3, 28 - lsrs r1, 30 - subs r1, 0x1 - movs r0, 0x3 - ands r1, r0 - lsls r1, 2 - movs r0, 0xD - negs r0, r0 - ands r0, r3 - orrs r0, r1 - strb r0, [r2, 0x5] - ldrb r1, [r4] - mov r0, r8 - ands r0, r1 - movs r1, 0x1 - orrs r0, r1 - strb r0, [r4] - ldrh r1, [r4] - movs r0, 0xA - bl SetGpuReg - movs r7, 0x1 -_08116C26: - bl IsContest - lsls r0, 24 - cmp r0, 0 - beq _08116C64 - ldr r0, =gContestResources - ldr r0, [r0] - ldr r0, [r0, 0x18] - ldrh r5, [r0] - b _08116CAC - .pool -_08116C64: - ldr r4, =gBattleAnimAttacker - ldrb r0, [r4] - bl GetBattlerSide - lsls r0, 24 - cmp r0, 0 - beq _08116C90 - ldr r1, =gBattlerPartyIndexes - ldrb r0, [r4] - lsls r0, 1 - adds r0, r1 - ldrh r1, [r0] - movs r0, 0x64 - muls r0, r1 - ldr r1, =gEnemyParty - b _08116CA0 - .pool -_08116C90: - ldr r1, =gBattlerPartyIndexes - ldrb r0, [r4] - lsls r0, 1 - adds r0, r1 - ldrh r1, [r0] - movs r0, 0x64 - muls r0, r1 - ldr r1, =gPlayerParty -_08116CA0: - adds r0, r1 - movs r1, 0xB - bl GetMonData - lsls r0, 16 - lsrs r5, r0, 16 -_08116CAC: - movs r0, 0 - bl GetAnimBattlerSpriteId - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - ldr r0, =gBattleAnimAttacker - ldrb r0, [r0] - adds r1, r4, 0 - adds r2, r5, 0 - bl sub_80A89C8 - adds r5, r0, 0 - lsls r5, 24 - lsrs r5, 24 - mov r0, sp - bl sub_80A6B30 - ldr r1, =gUnknown_08C20684 - mov r0, sp - movs r2, 0 - bl sub_80A6D60 - mov r0, sp - ldrb r0, [r0, 0x9] - ldr r1, =gUnknown_08C20668 - mov r2, sp - ldrh r2, [r2, 0xA] - bl sub_80A6CC0 - ldr r0, =gUnknown_08597418 - mov r1, sp - ldrb r1, [r1, 0x8] - lsls r1, 4 - adds r1, 0x1 - movs r2, 0x2 - bl LoadPalette - ldr r2, =gBattle_BG1_X - ldr r0, =gSprites - lsls r1, r4, 4 - adds r1, r4 - lsls r1, 2 - adds r1, r0 - ldrh r0, [r1, 0x20] - negs r0, r0 - adds r0, 0x20 - strh r0, [r2] - ldr r2, =gBattle_BG1_Y - ldrh r0, [r1, 0x22] - negs r0, r0 - adds r0, 0x20 - strh r0, [r2] - ldr r1, =gTasks - mov r2, r9 - lsls r0, r2, 2 - add r0, r9 - lsls r0, 3 - adds r0, r1 - strh r5, [r0, 0x8] - strh r7, [r0, 0x14] - ldr r1, =sub_8116D64 - str r1, [r0] - add sp, 0x14 - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8116B14 - - thumb_func_start sub_8116D64 -sub_8116D64: @ 8116D64 - push {r4-r7,lr} - mov r7, r8 - push {r7} - sub sp, 0x14 - lsls r0, 24 - lsrs r0, 24 - adds r6, r0, 0 - ldr r1, =gTasks - lsls r0, r6, 2 - adds r0, r6 - lsls r0, 3 - adds r5, r0, r1 - ldrh r0, [r5, 0x1C] - adds r0, 0x4 - movs r1, 0 - mov r8, r1 - strh r0, [r5, 0x1C] - ldr r7, =gBattle_BG1_Y - ldrh r2, [r7] - subs r1, r2, 0x4 - strh r1, [r7] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0x40 - bne _08116E86 - mov r0, r8 - strh r0, [r5, 0x1C] - adds r0, r2, 0 - adds r0, 0x3C - strh r0, [r7] - ldrh r0, [r5, 0x1E] - adds r0, 0x1 - strh r0, [r5, 0x1E] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0x4 - bne _08116E86 - movs r0, 0 - bl sub_80A477C - ldr r0, =gBattle_WIN0H - mov r1, r8 - strh r1, [r0] - ldr r0, =gBattle_WIN0V - strh r1, [r0] - ldr r4, =0x00003f3f - movs r0, 0x48 - adds r1, r4, 0 - bl SetGpuReg - movs r0, 0x4A - adds r1, r4, 0 - bl SetGpuReg - bl IsContest - lsls r0, 24 - cmp r0, 0 - bne _08116DF6 - movs r0, 0xA - bl GetGpuReg - add r1, sp, 0x10 - strh r0, [r1] - ldrb r2, [r1] - movs r0, 0xD - negs r0, r0 - ands r0, r2 - strb r0, [r1] - ldrh r1, [r1] - movs r0, 0xA - bl SetGpuReg -_08116DF6: - movs r0, 0 - bl GetGpuReg - adds r1, r0, 0 - movs r2, 0x80 - lsls r2, 8 - adds r0, r2, 0 - eors r1, r0 - lsls r1, 16 - lsrs r1, 16 - movs r0, 0 - bl SetGpuReg - movs r0, 0x50 - movs r1, 0 - bl SetGpuReg - movs r0, 0x52 - movs r1, 0 - bl SetGpuReg - movs r0, 0 - bl GetAnimBattlerSpriteId - ldr r4, =gSprites - movs r0, 0x8 - ldrsh r1, [r5, r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r4 - bl DestroySprite - mov r0, sp - bl sub_80A6B30 - mov r0, sp - ldrb r0, [r0, 0x9] - bl sub_80A6C68 - movs r1, 0x14 - ldrsh r0, [r5, r1] - cmp r0, 0x1 - bne _08116E7C - ldr r2, =gBattlerSpriteIds - ldr r0, =gBattleAnimAttacker - ldrb r1, [r0] - movs r0, 0x2 - eors r0, r1 - adds r0, r2 - ldrb r0, [r0] - lsls r2, r0, 4 - adds r2, r0 - lsls r2, 2 - adds r2, r4 - ldrb r3, [r2, 0x5] - lsls r1, r3, 28 - lsrs r1, 30 - adds r1, 0x1 - movs r0, 0x3 - ands r1, r0 - lsls r1, 2 - movs r0, 0xD - negs r0, r0 - ands r0, r3 - orrs r0, r1 - strb r0, [r2, 0x5] -_08116E7C: - mov r2, r8 - strh r2, [r7] - adds r0, r6, 0 - bl DestroyAnimVisualTask -_08116E86: - add sp, 0x14 - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8116D64 - - thumb_func_start sub_8116EB4 -sub_8116EB4: @ 8116EB4 - push {r4,r5,lr} - lsls r0, 24 - lsrs r5, r0, 24 - ldr r4, =gUnknown_0203A110 - movs r0, 0x18 - bl AllocZeroed - str r0, [r4] - movs r2, 0 - ldr r3, =gBattleAnimArgs -_08116EC8: - ldr r1, [r4] - lsls r0, r2, 1 - adds r1, 0x4 - adds r1, r0 - adds r0, r3 - ldrh r0, [r0] - strh r0, [r1] - adds r0, r2, 0x1 - lsls r0, 24 - lsrs r2, r0, 24 - cmp r2, 0x7 - bls _08116EC8 - ldr r0, =gTasks - lsls r1, r5, 2 - adds r1, r5 - lsls r1, 3 - adds r1, r0 - ldr r0, =sub_8116F04 - str r0, [r1] - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8116EB4 - - thumb_func_start sub_8116F04 -sub_8116F04: @ 8116F04 - push {r4-r6,lr} - lsls r0, 24 - lsrs r6, r0, 24 - ldr r0, =gUnknown_0203A110 - ldr r1, [r0] - movs r2, 0x8 - ldrsh r0, [r1, r2] - cmp r0, 0 - bne _08116F24 - ldr r0, =gBattleAnimAttacker - b _08116F26 - .pool -_08116F24: - ldr r0, =gBattleAnimTarget -_08116F26: - ldrb r0, [r0] - strb r0, [r1] - ldr r4, =gUnknown_0203A110 - ldr r2, [r4] - ldrb r0, [r2] - movs r1, 0x2 - eors r0, r1 - strb r0, [r2, 0x1] - bl IsContest - lsls r0, 24 - cmp r0, 0 - bne _08116F56 - ldr r1, [r4] - movs r2, 0xA - ldrsh r0, [r1, r2] - cmp r0, 0 - beq _08116F5C - ldrb r0, [r1, 0x1] - bl IsBattlerSpriteVisible - lsls r0, 24 - cmp r0, 0 - bne _08116F5C -_08116F56: - ldr r1, [r4] - movs r0, 0 - strh r0, [r1, 0xA] -_08116F5C: - ldr r0, =gBattle_WIN0H - movs r1, 0 - strh r1, [r0] - ldr r0, =gBattle_WIN0V - strh r1, [r0] - ldr r1, =0x00003f3f - movs r0, 0x48 - bl SetGpuReg - ldr r1, =0x00003f3d - movs r0, 0x4A - bl SetGpuReg - movs r1, 0x80 - lsls r1, 8 - movs r0, 0 - bl SetGpuRegBits - ldr r1, =0x00003f42 - movs r0, 0x50 - bl SetGpuReg - movs r1, 0x80 - lsls r1, 5 - movs r0, 0x52 - bl SetGpuReg - movs r0, 0x1 - movs r1, 0x4 - movs r2, 0 - bl SetAnimBgAttribute - movs r0, 0x1 - movs r1, 0 - movs r2, 0 - bl SetAnimBgAttribute - bl IsContest - lsls r0, 24 - cmp r0, 0 - bne _08116FBA - movs r0, 0x1 - movs r1, 0x3 - movs r2, 0x1 - bl SetAnimBgAttribute -_08116FBA: - bl IsDoubleBattle - lsls r0, 24 - cmp r0, 0 - beq _08117036 - ldr r4, =gUnknown_0203A110 - ldr r1, [r4] - movs r2, 0xA - ldrsh r0, [r1, r2] - cmp r0, 0 - bne _08117036 - ldrb r0, [r1] - bl GetBattlerPosition - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x3 - beq _08116FEC - ldr r0, [r4] - ldrb r0, [r0] - bl GetBattlerPosition - lsls r0, 24 - cmp r0, 0 - bne _08117036 -_08116FEC: - ldr r0, [r4] - ldrb r0, [r0, 0x1] - bl IsBattlerSpriteVisible - lsls r0, 24 - lsrs r5, r0, 24 - cmp r5, 0x1 - bne _08117036 - ldr r3, =gSprites - ldr r1, =gBattlerSpriteIds - ldr r0, [r4] - ldrb r0, [r0, 0x1] - adds r0, r1 - ldrb r0, [r0] - lsls r2, r0, 4 - adds r2, r0 - lsls r2, 2 - adds r2, r3 - ldrb r3, [r2, 0x5] - lsls r1, r3, 28 - lsrs r1, 30 - subs r1, 0x1 - movs r0, 0x3 - ands r1, r0 - lsls r1, 2 - movs r0, 0xD - negs r0, r0 - ands r0, r3 - orrs r0, r1 - strb r0, [r2, 0x5] - movs r0, 0x1 - movs r1, 0x4 - movs r2, 0x1 - bl SetAnimBgAttribute - ldr r0, [r4] - strb r5, [r0, 0x2] -_08117036: - bl IsContest - lsls r0, 24 - cmp r0, 0 - beq _08117078 - ldr r0, =gUnknown_0203A110 - ldr r1, [r0] - ldr r0, =gContestResources - ldr r0, [r0] - ldr r0, [r0, 0x18] - ldrh r0, [r0] - b _081170C4 - .pool -_08117078: - ldr r4, =gUnknown_0203A110 - ldr r0, [r4] - ldrb r0, [r0] - bl GetBattlerSide - lsls r0, 24 - cmp r0, 0 - beq _081170A8 - ldr r1, =gBattlerPartyIndexes - ldr r0, [r4] - ldrb r0, [r0] - lsls r0, 1 - adds r0, r1 - ldrh r1, [r0] - movs r0, 0x64 - muls r0, r1 - ldr r1, =gEnemyParty - b _081170BA - .pool -_081170A8: - ldr r1, =gBattlerPartyIndexes - ldr r0, [r4] - ldrb r0, [r0] - lsls r0, 1 - adds r0, r1 - ldrh r1, [r0] - movs r0, 0x64 - muls r0, r1 - ldr r1, =gPlayerParty -_081170BA: - adds r0, r1 - movs r1, 0xB - bl GetMonData - ldr r1, [r4] -_081170C4: - strh r0, [r1, 0x14] - ldr r0, =gTasks - lsls r1, r6, 2 - adds r1, r6 - lsls r1, 3 - adds r1, r0 - ldr r0, =sub_81170EC - str r0, [r1] - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8116F04 - - thumb_func_start sub_81170EC -sub_81170EC: @ 81170EC - push {r4-r7,lr} - mov r7, r8 - push {r7} - sub sp, 0x10 - lsls r0, 24 - lsrs r5, r0, 24 - movs r0, 0 - mov r8, r0 - ldr r6, =gBattlerSpriteIds - ldr r4, =gUnknown_0203A110 - ldr r2, [r4] - ldrb r0, [r2] - adds r1, r0, r6 - ldrb r1, [r1] - ldrh r2, [r2, 0x14] - bl sub_80A89C8 - lsls r0, 24 - lsrs r7, r0, 24 - ldr r2, [r4] - movs r1, 0xA - ldrsh r0, [r2, r1] - cmp r0, 0 - beq _0811712E - ldrb r0, [r2, 0x1] - adds r1, r0, r6 - ldrb r1, [r1] - ldrh r2, [r2, 0x14] - bl sub_80A89C8 - lsls r0, 24 - lsrs r0, 24 - mov r8, r0 -_0811712E: - mov r0, sp - bl sub_80A6B30 - ldr r0, [r4] - movs r4, 0x4 - ldrsh r0, [r0, r4] - cmp r0, 0 - bne _08117158 - ldr r1, =gUnknown_08C2D930 - mov r0, sp - movs r2, 0 - bl sub_80A6D60 - b _08117162 - .pool -_08117158: - ldr r1, =gUnknown_08C2DA4C - mov r0, sp - movs r2, 0 - bl sub_80A6D60 -_08117162: - mov r0, sp - ldrb r0, [r0, 0x9] - ldr r1, =gUnknown_08C2D720 - mov r2, sp - ldrh r2, [r2, 0xA] - bl sub_80A6CC0 - ldr r0, =gUnknown_0203A110 - ldr r0, [r0] - movs r1, 0x6 - ldrsh r0, [r0, r1] - cmp r0, 0x6 - bhi _081171F8 - lsls r0, 2 - ldr r1, =_08117198 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_08117198: - .4byte _081171B4 - .4byte _081171BC - .4byte _081171C4 - .4byte _081171CC - .4byte _081171D4 - .4byte _081171DC - .4byte _081171E4 -_081171B4: - ldr r0, =gUnknown_08C2DB88 - b _081171E6 - .pool -_081171BC: - ldr r0, =gUnknown_08C2DB68 - b _081171E6 - .pool -_081171C4: - ldr r0, =gUnknown_08C2DBA8 - b _081171E6 - .pool -_081171CC: - ldr r0, =gUnknown_08C2DBC8 - b _081171E6 - .pool -_081171D4: - ldr r0, =gUnknown_08C2DC08 - b _081171E6 - .pool -_081171DC: - ldr r0, =gUnknown_08C2DC28 - b _081171E6 - .pool -_081171E4: - ldr r0, =gUnknown_08C2DC48 -_081171E6: - mov r1, sp - ldrb r1, [r1, 0x8] - lsls r1, 4 - movs r2, 0x20 - bl LoadCompressedPalette - b _08117206 - .pool -_081171F8: - ldr r0, =gUnknown_08C2DBE8 - mov r1, sp - ldrb r1, [r1, 0x8] - lsls r1, 4 - movs r2, 0x20 - bl LoadCompressedPalette -_08117206: - ldr r3, =gBattle_BG1_X - movs r2, 0 - strh r2, [r3] - ldr r0, =gBattle_BG1_Y - strh r2, [r0] - ldr r1, =gUnknown_0203A110 - ldr r0, [r1] - movs r4, 0x4 - ldrsh r0, [r0, r4] - adds r4, r1, 0 - cmp r0, 0x1 - bne _08117248 - movs r0, 0x40 - strh r0, [r3] - ldr r2, =gTasks - lsls r3, r5, 2 - adds r0, r3, r5 - lsls r0, 3 - adds r0, r2 - ldr r1, =0x0000fffd - b _08117254 - .pool -_08117248: - ldr r2, =gTasks - lsls r3, r5, 2 - adds r0, r3, r5 - lsls r0, 3 - adds r0, r2 - movs r1, 0x3 -_08117254: - strh r1, [r0, 0xA] - ldr r0, [r4] - movs r1, 0xC - ldrsh r0, [r0, r1] - cmp r0, 0 - bne _08117274 - adds r0, r3, r5 - lsls r0, 3 - adds r0, r2 - movs r1, 0xA - strh r1, [r0, 0x10] - movs r1, 0x14 - b _08117280 - .pool -_08117274: - adds r0, r3, r5 - lsls r0, 3 - adds r0, r2 - movs r1, 0xD - strh r1, [r0, 0x10] - movs r1, 0x1E -_08117280: - strh r1, [r0, 0x12] - adds r1, r3, r5 - lsls r1, 3 - adds r1, r2 - strh r7, [r1, 0x8] - ldr r3, [r4] - ldrh r0, [r3, 0xA] - strh r0, [r1, 0xC] - mov r4, r8 - strh r4, [r1, 0xE] - ldrb r0, [r3, 0x2] - strh r0, [r1, 0x14] - ldr r2, =gBattlerSpriteIds - ldrb r0, [r3, 0x1] - adds r0, r2 - ldrb r0, [r0] - strh r0, [r1, 0x16] - ldr r0, =sub_81172EC - str r0, [r1] - movs r1, 0x4 - ldrsh r0, [r3, r1] - cmp r0, 0 - bne _081172CC - movs r0, 0x40 - negs r0, r0 - bl BattleAnimAdjustPanning2 - adds r1, r0, 0 - lsls r1, 24 - asrs r1, 24 - movs r0, 0xEF - bl PlaySE12WithPanning - b _081172E0 - .pool -_081172CC: - movs r0, 0x40 - negs r0, r0 - bl BattleAnimAdjustPanning2 - adds r1, r0, 0 - lsls r1, 24 - asrs r1, 24 - movs r0, 0xF5 - bl PlaySE12WithPanning -_081172E0: - add sp, 0x10 - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end sub_81170EC - - thumb_func_start sub_81172EC -sub_81172EC: @ 81172EC - push {r4-r6,lr} - lsls r0, 24 - lsrs r6, r0, 24 - ldr r2, =gBattle_BG1_Y - ldr r1, =gTasks - lsls r0, r6, 2 - adds r0, r6 - lsls r0, 3 - adds r5, r0, r1 - ldrh r0, [r5, 0xA] - ldrh r1, [r2] - adds r0, r1 - strh r0, [r2] - movs r0, 0x26 - ldrsh r2, [r5, r0] - cmp r2, 0x1 - beq _08117362 - cmp r2, 0x1 - bgt _08117320 - cmp r2, 0 - beq _0811732A - b _08117478 - .pool -_08117320: - cmp r2, 0x2 - beq _08117378 - cmp r2, 0x3 - beq _081173B6 - b _08117478 -_0811732A: - ldrh r0, [r5, 0x1E] - adds r1, r0, 0x1 - strh r1, [r5, 0x1E] - lsls r0, 16 - cmp r0, 0 - bgt _08117338 - b _08117478 -_08117338: - strh r2, [r5, 0x1E] - ldrh r1, [r5, 0x20] - adds r1, 0x1 - strh r1, [r5, 0x20] - movs r0, 0x10 - subs r0, r1 - lsls r0, 8 - orrs r1, r0 - lsls r1, 16 - lsrs r1, 16 - movs r0, 0x52 - bl SetGpuReg - movs r2, 0x20 - ldrsh r1, [r5, r2] - movs r2, 0x10 - ldrsh r0, [r5, r2] - cmp r1, r0 - beq _08117360 - b _08117478 -_08117360: - b _081173AE -_08117362: - ldrh r0, [r5, 0x1C] - adds r0, 0x1 - strh r0, [r5, 0x1C] - lsls r0, 16 - asrs r0, 16 - movs r2, 0x12 - ldrsh r1, [r5, r2] - cmp r0, r1 - beq _08117376 - b _08117478 -_08117376: - b _081173AE -_08117378: - ldrh r0, [r5, 0x1E] - adds r1, r0, 0x1 - strh r1, [r5, 0x1E] - lsls r0, 16 - cmp r0, 0 - ble _08117478 - movs r0, 0 - strh r0, [r5, 0x1E] - ldrh r1, [r5, 0x20] - subs r1, 0x1 - strh r1, [r5, 0x20] - movs r0, 0x10 - subs r0, r1 - lsls r0, 8 - orrs r1, r0 - lsls r1, 16 - lsrs r1, 16 - movs r0, 0x52 - bl SetGpuReg - movs r1, 0x20 - ldrsh r0, [r5, r1] - cmp r0, 0 - bne _08117478 - movs r0, 0 - bl sub_80A477C -_081173AE: - ldrh r0, [r5, 0x26] - adds r0, 0x1 - strh r0, [r5, 0x26] - b _08117478 -_081173B6: - ldr r0, =gBattle_WIN0H - movs r1, 0 - strh r1, [r0] - ldr r0, =gBattle_WIN0V - strh r1, [r0] - ldr r4, =0x00003f3f - movs r0, 0x48 - adds r1, r4, 0 - bl SetGpuReg - movs r0, 0x4A - adds r1, r4, 0 - bl SetGpuReg - bl IsContest - lsls r0, 24 - cmp r0, 0 - bne _081173E6 - movs r0, 0x1 - movs r1, 0x3 - movs r2, 0 - bl SetAnimBgAttribute -_081173E6: - movs r0, 0 - bl GetGpuReg - adds r1, r0, 0 - movs r2, 0x80 - lsls r2, 8 - adds r0, r2, 0 - eors r1, r0 - lsls r1, 16 - lsrs r1, 16 - movs r0, 0 - bl SetGpuReg - movs r0, 0x50 - movs r1, 0 - bl SetGpuReg - movs r0, 0x52 - movs r1, 0 - bl SetGpuReg - movs r0, 0x8 - ldrsh r1, [r5, r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - ldr r4, =gSprites - adds r0, r4 - bl DestroySprite - movs r1, 0xC - ldrsh r0, [r5, r1] - cmp r0, 0 - beq _0811743A - movs r2, 0xE - ldrsh r1, [r5, r2] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r4 - bl DestroySprite -_0811743A: - movs r1, 0x14 - ldrsh r0, [r5, r1] - cmp r0, 0x1 - bne _08117466 - movs r2, 0x16 - ldrsh r0, [r5, r2] - lsls r2, r0, 4 - adds r2, r0 - lsls r2, 2 - adds r2, r4 - ldrb r3, [r2, 0x5] - lsls r1, r3, 28 - lsrs r1, 30 - adds r1, 0x1 - movs r0, 0x3 - ands r1, r0 - lsls r1, 2 - movs r0, 0xD - negs r0, r0 - ands r0, r3 - orrs r0, r1 - strb r0, [r2, 0x5] -_08117466: - ldr r4, =gUnknown_0203A110 - ldr r0, [r4] - bl Free - movs r0, 0 - str r0, [r4] - adds r0, r6, 0 - bl DestroyAnimVisualTask -_08117478: - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81172EC - - thumb_func_start sub_8117494 -sub_8117494: @ 8117494 - push {r4-r6,lr} - sub sp, 0xC - adds r5, r0, 0 - lsls r5, 24 - lsrs r5, 24 - movs r0, 0x1 - movs r1, 0x1 - movs r2, 0x1 - movs r3, 0x1 - bl sub_80A76C4 - adds r6, r0, 0 - movs r1, 0 - bl sub_81175C4 - ldr r0, =gTasks - lsls r4, r5, 2 - adds r4, r5 - lsls r4, 3 - adds r4, r0 - lsrs r0, r6, 16 - movs r5, 0 - strh r0, [r4, 0x24] - str r5, [sp] - str r5, [sp, 0x4] - str r5, [sp, 0x8] - movs r0, 0x1 - movs r1, 0 - movs r2, 0 - movs r3, 0 - bl sub_80A75AC - adds r6, r0, 0 - ldr r1, =0x0000ffff - ands r6, r1 - adds r0, r6, 0 - bl sub_81175C4 - strh r6, [r4, 0x26] - strh r5, [r4, 0x8] - strh r5, [r4, 0xA] - ldr r0, =sub_8117500 - str r0, [r4] - add sp, 0xC - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8117494 - - thumb_func_start sub_8117500 -sub_8117500: @ 8117500 - push {r4-r6,lr} - lsls r0, 24 - lsrs r2, r0, 24 - lsls r0, r2, 2 - adds r0, r2 - lsls r0, 3 - ldr r1, =gTasks - adds r4, r0, r1 - movs r0, 0x8 - ldrsh r1, [r4, r0] - cmp r1, 0x1 - beq _08117544 - cmp r1, 0x1 - bgt _08117528 - cmp r1, 0 - beq _0811752E - b _081175BE - .pool -_08117528: - cmp r1, 0x2 - beq _081175B8 - b _081175BE -_0811752E: - ldrh r0, [r4, 0xA] - adds r0, 0x1 - strh r0, [r4, 0xA] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0x6 - ble _081175BE - strh r1, [r4, 0xA] - movs r0, 0x10 - strh r0, [r4, 0xC] - b _081175AC -_08117544: - ldrh r0, [r4, 0xA] - adds r0, 0x1 - strh r0, [r4, 0xA] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0x1 - ble _081175BE - movs r0, 0 - strh r0, [r4, 0xA] - ldrh r0, [r4, 0xC] - subs r0, 0x1 - strh r0, [r4, 0xC] - movs r5, 0 - movs r6, 0x1 -_08117560: - movs r1, 0x26 - ldrsh r0, [r4, r1] - asrs r0, r5 - ands r0, r6 - cmp r0, 0 - beq _0811757A - lsls r0, r5, 20 - lsrs r0, 16 - ldrb r2, [r4, 0xC] - movs r1, 0x10 - ldr r3, =0x0000ffff - bl BlendPalette -_0811757A: - movs r1, 0x24 - ldrsh r0, [r4, r1] - asrs r0, r5 - ands r0, r6 - cmp r0, 0 - beq _0811759A - lsls r0, r5, 20 - movs r1, 0x80 - lsls r1, 17 - adds r0, r1 - lsrs r0, 16 - ldrb r2, [r4, 0xC] - movs r1, 0x10 - movs r3, 0 - bl BlendPalette -_0811759A: - adds r0, r5, 0x1 - lsls r0, 16 - lsrs r5, r0, 16 - cmp r5, 0xF - bls _08117560 - movs r1, 0xC - ldrsh r0, [r4, r1] - cmp r0, 0 - bne _081175BE -_081175AC: - ldrh r0, [r4, 0x8] - adds r0, 0x1 - strh r0, [r4, 0x8] - b _081175BE - .pool -_081175B8: - adds r0, r2, 0 - bl DestroyAnimVisualTask -_081175BE: - pop {r4-r6} - pop {r0} - bx r0 - thumb_func_end sub_8117500 - - thumb_func_start sub_81175C4 -sub_81175C4: @ 81175C4 - push {r4-r6,lr} - adds r3, r0, 0 - lsls r1, 16 - lsrs r6, r1, 16 - movs r2, 0 -_081175CE: - movs r0, 0x1 - ands r0, r3 - lsrs r4, r3, 1 - adds r5, r2, 0x1 - cmp r0, 0 - beq _081175FA - lsls r0, r2, 20 - lsrs r2, r0, 16 - adds r0, r2, 0 - adds r0, 0x10 - cmp r2, r0 - bge _081175FA - ldr r1, =gPlttBufferFaded - adds r3, r0, 0 -_081175EA: - lsls r0, r2, 1 - adds r0, r1 - strh r6, [r0] - adds r0, r2, 0x1 - lsls r0, 16 - lsrs r2, r0, 16 - cmp r2, r3 - blt _081175EA -_081175FA: - adds r3, r4, 0 - lsls r0, r5, 16 - lsrs r2, r0, 16 - cmp r2, 0x1F - bls _081175CE - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81175C4 - - thumb_func_start sub_8117610 -sub_8117610: @ 8117610 - push {r4-r6,lr} - lsls r0, 24 - lsrs r6, r0, 24 - movs r4, 0 - movs r2, 0 - ldr r0, =gBattleAnimAttacker - ldrb r3, [r0] - movs r5, 0x1 -_08117620: - cmp r3, r2 - beq _0811762E - adds r1, r2, 0 - adds r1, 0x10 - adds r0, r5, 0 - lsls r0, r1 - orrs r4, r0 -_0811762E: - adds r2, 0x1 - cmp r2, 0x3 - bls _08117620 - movs r2, 0x5 - ldr r0, =gBattleAnimArgs - adds r1, r0, 0 - adds r1, 0x8 -_0811763C: - ldrh r0, [r1] - strh r0, [r1, 0x2] - subs r1, 0x2 - subs r2, 0x1 - cmp r2, 0 - bne _0811763C - adds r0, r6, 0 - adds r1, r4, 0 - bl sub_8116874 - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8117610 - - thumb_func_start sub_8117660 -sub_8117660: @ 8117660 - push {r4-r6,lr} - lsls r0, 24 - lsrs r6, r0, 24 - movs r0, 0 - bl sub_80A6DAC - ldr r0, =sub_81176D8 - movs r1, 0x5 - bl CreateTask - lsls r0, 24 - lsrs r5, r0, 24 - ldr r4, =gBattleAnimArgs - movs r1, 0x4 - ldrsh r0, [r4, r1] - cmp r0, 0 - beq _0811769C - ldr r0, =gBattleAnimAttacker - ldrb r0, [r0] - bl GetBattlerSide - lsls r0, 24 - cmp r0, 0 - beq _0811769C - ldrh r0, [r4] - negs r0, r0 - strh r0, [r4] - ldrh r0, [r4, 0x2] - negs r0, r0 - strh r0, [r4, 0x2] -_0811769C: - ldr r0, =gTasks - lsls r1, r5, 2 - adds r1, r5 - lsls r1, 3 - adds r1, r0 - ldr r2, =gBattleAnimArgs - ldrh r0, [r2] - strh r0, [r1, 0xA] - ldrh r0, [r2, 0x2] - strh r0, [r1, 0xC] - ldrh r0, [r2, 0x6] - strh r0, [r1, 0xE] - ldrh r0, [r1, 0x8] - adds r0, 0x1 - strh r0, [r1, 0x8] - adds r0, r6, 0 - bl DestroyAnimVisualTask - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8117660 - - thumb_func_start sub_81176D8 -sub_81176D8: @ 81176D8 - push {r4-r7,lr} - lsls r0, 24 - lsrs r5, r0, 24 - ldr r0, =gTasks - lsls r1, r5, 2 - adds r1, r5 - lsls r1, 3 - adds r1, r0 - ldrh r3, [r1, 0xA] - ldrh r0, [r1, 0x1C] - adds r3, r0 - movs r4, 0 - mov r12, r4 - strh r3, [r1, 0x1C] - ldrh r2, [r1, 0xC] - ldrh r7, [r1, 0x1E] - adds r2, r7 - strh r2, [r1, 0x1E] - ldr r6, =gBattle_BG3_X - lsls r0, r3, 16 - asrs r0, 24 - ldrh r4, [r6] - adds r0, r4 - strh r0, [r6] - ldr r4, =gBattle_BG3_Y - lsls r0, r2, 16 - asrs r0, 24 - ldrh r7, [r4] - adds r0, r7 - strh r0, [r4] - movs r0, 0xFF - ands r3, r0 - strh r3, [r1, 0x1C] - ands r2, r0 - strh r2, [r1, 0x1E] - ldr r0, =gBattleAnimArgs - movs r3, 0xE - ldrsh r2, [r0, r3] - movs r7, 0xE - ldrsh r0, [r1, r7] - cmp r2, r0 - bne _0811773E - mov r0, r12 - strh r0, [r6] - strh r0, [r4] - movs r0, 0x1 - bl sub_80A6DAC - adds r0, r5, 0 - bl DestroyTask -_0811773E: - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81176D8 - - thumb_func_start AnimTask_IsAttackerOpponentSide -AnimTask_IsAttackerOpponentSide: @ 8117754 - push {r4,lr} - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - ldr r0, =gBattleAnimAttacker - ldrb r0, [r0] - bl GetBattlerSide - ldr r1, =gBattleAnimArgs - lsls r0, 24 - lsrs r0, 24 - strh r0, [r1, 0xE] - adds r0, r4, 0 - bl DestroyAnimVisualTask - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end AnimTask_IsAttackerOpponentSide - - thumb_func_start AnimTask_IsTargetOpponentSide -AnimTask_IsTargetOpponentSide: @ 8117780 - push {r4,lr} - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - ldr r0, =gBattleAnimTarget - ldrb r0, [r0] - bl GetBattlerSide - ldr r1, =gBattleAnimArgs - lsls r0, 24 - lsrs r0, 24 - strh r0, [r1, 0xE] - adds r0, r4, 0 - bl DestroyAnimVisualTask - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end AnimTask_IsTargetOpponentSide - - thumb_func_start AnimTask_IsTargetPartner -AnimTask_IsTargetPartner: @ 81177AC - push {r4,r5,lr} - lsls r0, 24 - lsrs r3, r0, 24 - ldr r5, =gBattleAnimArgs - movs r4, 0 - ldr r0, =gBattleAnimAttacker - ldrb r2, [r0] - movs r0, 0x2 - ldr r1, =gBattleAnimTarget - eors r0, r2 - ldrb r1, [r1] - cmp r0, r1 - bne _081177C8 - movs r4, 0x1 -_081177C8: - strh r4, [r5, 0xE] - adds r0, r3, 0 - bl DestroyAnimVisualTask - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end AnimTask_IsTargetPartner - - thumb_func_start sub_81177E4 -sub_81177E4: @ 81177E4 - push {r4-r7,lr} - lsls r0, 24 - lsrs r5, r0, 24 - movs r4, 0 - ldr r6, =gSprites -_081177EE: - ldr r0, =gBattleAnimAttacker - ldrb r0, [r0] - cmp r4, r0 - beq _0811782C - lsls r0, r4, 24 - lsrs r0, 24 - bl IsBattlerSpriteVisible - lsls r0, 24 - cmp r0, 0 - beq _0811782C - ldr r0, =gBattlerSpriteIds - adds r0, r4, r0 - ldrb r0, [r0] - lsls r2, r0, 4 - adds r2, r0 - lsls r2, 2 - adds r2, r6 - ldr r1, =gBattleAnimArgs - adds r2, 0x3E - movs r0, 0x1 - ldrb r3, [r1] - ands r3, r0 - lsls r3, 2 - ldrb r0, [r2] - movs r7, 0x5 - negs r7, r7 - adds r1, r7, 0 - ands r0, r1 - orrs r0, r3 - strb r0, [r2] -_0811782C: - adds r0, r4, 0x1 - lsls r0, 16 - lsrs r4, r0, 16 - cmp r4, 0x3 - bls _081177EE - adds r0, r5, 0 - bl DestroyAnimVisualTask - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81177E4 - - thumb_func_start sub_8117854 -sub_8117854: @ 8117854 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x24 - ldr r1, [sp, 0x44] - ldr r4, [sp, 0x48] - ldr r5, [sp, 0x4C] - ldr r6, [sp, 0x50] - lsls r0, 24 - lsrs r0, 24 - mov r9, r0 - lsls r2, 16 - lsrs r2, 16 - str r2, [sp, 0x14] - lsls r3, 24 - lsrs r7, r3, 24 - lsls r1, 24 - lsrs r1, 24 - mov r8, r1 - lsls r4, 24 - lsrs r4, 24 - str r4, [sp, 0x18] - lsls r5, 24 - lsrs r5, 24 - str r5, [sp, 0x1C] - lsls r6, 24 - lsrs r6, 24 - mov r10, r6 - movs r0, 0 - str r0, [sp, 0x20] - movs r0, 0x2 - adds r6, r7, 0 - eors r6, r0 - bl IsContest - lsls r0, 24 - cmp r0, 0 - bne _081178B6 - mov r1, r8 - cmp r1, 0 - beq _081178BA - adds r0, r6, 0 - bl IsBattlerSpriteVisible - lsls r0, 24 - cmp r0, 0 - bne _081178BA -_081178B6: - movs r2, 0 - mov r8, r2 -_081178BA: - ldr r0, =gBattle_WIN0H - movs r1, 0 - strh r1, [r0] - ldr r0, =gBattle_WIN0V - strh r1, [r0] - ldr r1, =0x00003f3f - movs r0, 0x48 - bl SetGpuReg - ldr r1, =0x00003f3d - movs r0, 0x4A - bl SetGpuReg - movs r1, 0x80 - lsls r1, 8 - movs r0, 0 - bl SetGpuRegBits - ldr r1, =0x00003f42 - movs r0, 0x50 - bl SetGpuReg - movs r1, 0x80 - lsls r1, 5 - movs r0, 0x52 - bl SetGpuReg - movs r0, 0xA - bl GetGpuReg - add r4, sp, 0x10 - strh r0, [r4] - ldrb r1, [r4] - movs r0, 0x4 - negs r0, r0 - ands r0, r1 - strb r0, [r4] - mov r2, sp - adds r2, 0x11 - ldrb r1, [r2] - movs r0, 0x3F - ands r0, r1 - strb r0, [r2] - ldrb r0, [r2] - movs r1, 0x20 - orrs r0, r1 - strb r0, [r2] - bl IsContest - lsls r0, 24 - cmp r0, 0 - bne _08117930 - ldrb r0, [r4] - movs r1, 0xD - negs r1, r1 - ands r1, r0 - movs r0, 0x4 - orrs r1, r0 - strb r1, [r4] -_08117930: - ldrh r1, [r4] - movs r0, 0xA - bl SetGpuReg - bl IsContest - lsls r0, 24 - cmp r0, 0 - beq _08117964 - ldr r0, =gContestResources - ldr r0, [r0] - ldr r0, [r0, 0x18] - ldrh r4, [r0] - b _081179A2 - .pool -_08117964: - adds r0, r7, 0 - bl GetBattlerSide - lsls r0, 24 - cmp r0, 0 - beq _08117988 - ldr r1, =gBattlerPartyIndexes - lsls r0, r7, 1 - adds r0, r1 - ldrh r1, [r0] - movs r0, 0x64 - muls r0, r1 - ldr r1, =gEnemyParty - b _08117996 - .pool -_08117988: - ldr r1, =gBattlerPartyIndexes - lsls r0, r7, 1 - adds r0, r1 - ldrh r1, [r0] - movs r0, 0x64 - muls r0, r1 - ldr r1, =gPlayerParty -_08117996: - adds r0, r1 - movs r1, 0xB - bl GetMonData - lsls r0, 16 - lsrs r4, r0, 16 -_081179A2: - ldr r5, =gBattlerSpriteIds - adds r0, r7, r5 - ldrb r1, [r0] - adds r0, r7, 0 - adds r2, r4, 0 - bl sub_80A89C8 - lsls r0, 24 - lsrs r7, r0, 24 - mov r0, r8 - cmp r0, 0 - beq _081179CC - adds r0, r6, r5 - ldrb r1, [r0] - adds r0, r6, 0 - adds r2, r4, 0 - bl sub_80A89C8 - lsls r0, 24 - lsrs r0, 24 - str r0, [sp, 0x20] -_081179CC: - mov r0, sp - bl sub_80A6B30 - mov r0, sp - ldr r1, [sp, 0x58] - movs r2, 0 - bl sub_80A6D60 - mov r0, sp - ldrb r0, [r0, 0x9] - mov r1, sp - ldrh r2, [r1, 0xA] - ldr r1, [sp, 0x54] - bl sub_80A6CC0 - mov r0, sp - ldrb r1, [r0, 0x8] - lsls r1, 4 - ldr r0, [sp, 0x5C] - movs r2, 0x20 - bl LoadCompressedPalette - ldr r0, =gBattle_BG1_X - movs r1, 0 - strh r1, [r0] - ldr r0, =gBattle_BG1_Y - strh r1, [r0] - ldr r1, =gTasks - mov r2, r9 - lsls r0, r2, 2 - add r0, r9 - lsls r0, 3 - adds r0, r1 - mov r1, sp - ldrh r1, [r1, 0x14] - strh r1, [r0, 0xA] - mov r2, sp - ldrh r2, [r2, 0x18] - strh r2, [r0, 0x10] - mov r1, r10 - strh r1, [r0, 0x12] - mov r2, sp - ldrh r2, [r2, 0x1C] - strh r2, [r0, 0x14] - strh r7, [r0, 0x8] - mov r1, r8 - strh r1, [r0, 0xC] - mov r2, sp - ldrh r2, [r2, 0x20] - strh r2, [r0, 0xE] - ldr r1, =sub_8117A60 - str r1, [r0] - add sp, 0x24 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8117854 - - thumb_func_start sub_8117A60 -sub_8117A60: @ 8117A60 - push {r4-r6,lr} - sub sp, 0x4 - lsls r0, 24 - lsrs r6, r0, 24 - ldr r1, =gTasks - lsls r0, r6, 2 - adds r0, r6 - lsls r0, 3 - adds r3, r0, r1 - movs r0, 0xA - ldrsh r2, [r3, r0] - adds r5, r1, 0 - cmp r2, 0 - bge _08117A7E - negs r2, r2 -_08117A7E: - ldrh r0, [r3, 0x22] - adds r4, r0, r2 - strh r4, [r3, 0x22] - movs r1, 0xA - ldrsh r0, [r3, r1] - cmp r0, 0 - bge _08117AA4 - ldr r2, =gBattle_BG1_Y - lsls r1, r4, 16 - asrs r1, 24 - ldrh r0, [r2] - subs r0, r1 - strh r0, [r2] - b _08117AB0 - .pool -_08117AA4: - ldr r1, =gBattle_BG1_Y - lsls r0, r4, 16 - asrs r0, 24 - ldrh r2, [r1] - adds r0, r2 - strh r0, [r1] -_08117AB0: - lsls r0, r6, 2 - adds r0, r6 - lsls r0, 3 - adds r5, r0, r5 - ldrh r1, [r5, 0x22] - movs r0, 0xFF - ands r0, r1 - movs r2, 0 - strh r0, [r5, 0x22] - movs r3, 0x26 - ldrsh r0, [r5, r3] - cmp r0, 0x1 - beq _08117B1A - cmp r0, 0x1 - bgt _08117AD8 - cmp r0, 0 - beq _08117ADE - b _08117C0C - .pool -_08117AD8: - cmp r0, 0x2 - beq _08117B34 - b _08117C0C -_08117ADE: - ldrh r0, [r5, 0x1E] - adds r1, r0, 0x1 - strh r1, [r5, 0x1E] - lsls r0, 16 - asrs r0, 16 - movs r3, 0x14 - ldrsh r1, [r5, r3] - cmp r0, r1 - bge _08117AF2 - b _08117C0C -_08117AF2: - strh r2, [r5, 0x1E] - ldrh r1, [r5, 0x20] - adds r1, 0x1 - strh r1, [r5, 0x20] - movs r0, 0x10 - subs r0, r1 - lsls r0, 8 - orrs r1, r0 - lsls r1, 16 - lsrs r1, 16 - movs r0, 0x52 - bl SetGpuReg - movs r0, 0x20 - ldrsh r1, [r5, r0] - movs r2, 0x10 - ldrsh r0, [r5, r2] - cmp r1, r0 - bne _08117C0C - b _08117B2C -_08117B1A: - ldrh r0, [r5, 0x1C] - adds r0, 0x1 - strh r0, [r5, 0x1C] - lsls r0, 16 - asrs r0, 16 - movs r3, 0x12 - ldrsh r1, [r5, r3] - cmp r0, r1 - bne _08117C0C -_08117B2C: - ldrh r0, [r5, 0x26] - adds r0, 0x1 - strh r0, [r5, 0x26] - b _08117C0C -_08117B34: - ldrh r0, [r5, 0x1E] - adds r1, r0, 0x1 - strh r1, [r5, 0x1E] - lsls r0, 16 - asrs r0, 16 - movs r3, 0x14 - ldrsh r1, [r5, r3] - cmp r0, r1 - blt _08117C0C - strh r2, [r5, 0x1E] - ldrh r1, [r5, 0x20] - subs r1, 0x1 - strh r1, [r5, 0x20] - movs r0, 0x10 - subs r0, r1 - lsls r0, 8 - orrs r1, r0 - lsls r1, 16 - lsrs r1, 16 - movs r0, 0x52 - bl SetGpuReg - movs r0, 0x20 - ldrsh r4, [r5, r0] - cmp r4, 0 - bne _08117C0C - movs r0, 0 - bl sub_80A477C - ldr r0, =gBattle_WIN0H - strh r4, [r0] - ldr r0, =gBattle_WIN0V - strh r4, [r0] - ldr r4, =0x00003f3f - movs r0, 0x48 - adds r1, r4, 0 - bl SetGpuReg - movs r0, 0x4A - adds r1, r4, 0 - bl SetGpuReg - bl IsContest - lsls r0, 24 - cmp r0, 0 - bne _08117BB2 - movs r0, 0xA - bl GetGpuReg - mov r1, sp - strh r0, [r1] - mov r2, sp - ldrb r1, [r2] - movs r0, 0xD - negs r0, r0 - ands r0, r1 - strb r0, [r2] - mov r0, sp - ldrh r1, [r0] - movs r0, 0xA - bl SetGpuReg -_08117BB2: - movs r0, 0 - bl GetGpuReg - adds r1, r0, 0 - movs r2, 0x80 - lsls r2, 8 - adds r0, r2, 0 - eors r1, r0 - lsls r1, 16 - lsrs r1, 16 - movs r0, 0 - bl SetGpuReg - movs r0, 0x50 - movs r1, 0 - bl SetGpuReg - movs r0, 0x52 - movs r1, 0 - bl SetGpuReg - movs r3, 0x8 - ldrsh r1, [r5, r3] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - ldr r4, =gSprites - adds r0, r4 - bl DestroySprite - movs r1, 0xC - ldrsh r0, [r5, r1] - cmp r0, 0 - beq _08117C06 - movs r2, 0xE - ldrsh r1, [r5, r2] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r4 - bl DestroySprite -_08117C06: - adds r0, r6, 0 - bl DestroyAnimVisualTask -_08117C0C: - add sp, 0x4 - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8117A60 - - thumb_func_start AnimTask_GetBattleTerrain -AnimTask_GetBattleTerrain: @ 8117C24 - push {lr} - lsls r0, 24 - lsrs r0, 24 - ldr r2, =gBattleAnimArgs - ldr r1, =gBattleTerrain - ldrb r1, [r1] - strh r1, [r2] - bl DestroyAnimVisualTask - pop {r0} - bx r0 - .pool - thumb_func_end AnimTask_GetBattleTerrain - - thumb_func_start sub_8117C44 -sub_8117C44: @ 8117C44 - push {r4,lr} - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - movs r0, 0x80 - lsls r0, 6 - bl AllocZeroed - ldr r1, =gMonSpritesGfxPtr - ldr r1, [r1] - movs r2, 0xBE - lsls r2, 1 - adds r1, r2 - str r0, [r1] - adds r0, r4, 0 - bl DestroyAnimVisualTask - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8117C44 - - thumb_func_start sub_8117C70 -sub_8117C70: @ 8117C70 - push {r4-r6,lr} - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - ldr r6, =gMonSpritesGfxPtr - ldr r0, [r6] - movs r5, 0xBE - lsls r5, 1 - adds r0, r5 - ldr r0, [r0] - bl Free - ldr r0, [r6] - adds r0, r5 - movs r1, 0 - str r1, [r0] - adds r0, r4, 0 - bl DestroyAnimVisualTask - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8117C70 - - thumb_func_start sub_8117CA0 -sub_8117CA0: @ 8117CA0 - push {r4,r5,lr} - sub sp, 0xC - lsls r0, 24 - lsrs r5, r0, 24 - movs r4, 0 - ldr r0, =gBattleAnimArgs - movs r1, 0 - ldrsh r0, [r0, r1] - cmp r0, 0 - bne _08117CE4 - str r4, [sp] - str r4, [sp, 0x4] - str r4, [sp, 0x8] - movs r0, 0x1 - movs r1, 0 - movs r2, 0 - movs r3, 0 - bl sub_80A75AC - adds r1, r0, 0 - movs r0, 0x1 - ands r0, r1 - cmp r0, 0 - bne _08117CFC - movs r2, 0x1 -_08117CD2: - lsrs r1, 1 - adds r4, 0x1 - adds r0, r1, 0 - ands r0, r2 - cmp r0, 0 - beq _08117CD2 - b _08117CFC - .pool -_08117CE4: - cmp r0, 0x1 - bne _08117CF0 - ldr r0, =gBattleAnimAttacker - b _08117CF6 - .pool -_08117CF0: - cmp r0, 0x2 - bne _08117CFC - ldr r0, =gBattleAnimTarget -_08117CF6: - ldrb r0, [r0] - adds r4, r0, 0 - adds r4, 0x10 -_08117CFC: - ldr r0, =gMonSpritesGfxPtr - ldr r1, [r0] - ldr r0, =gBattleAnimArgs - movs r2, 0x2 - ldrsh r0, [r0, r2] - movs r2, 0xBE - lsls r2, 1 - adds r1, r2 - ldr r1, [r1] - lsls r0, 5 - adds r0, r1 - lsls r1, r4, 5 - ldr r2, =gPlttBufferUnfaded - adds r1, r2 - movs r2, 0x20 - bl memcpy - adds r0, r5, 0 - bl DestroyAnimVisualTask - add sp, 0xC - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8117CA0 - - thumb_func_start sub_8117D3C -sub_8117D3C: @ 8117D3C - push {r4,r5,lr} - sub sp, 0xC - lsls r0, 24 - lsrs r5, r0, 24 - movs r4, 0 - ldr r0, =gBattleAnimArgs - movs r1, 0 - ldrsh r0, [r0, r1] - cmp r0, 0 - bne _08117D80 - str r4, [sp] - str r4, [sp, 0x4] - str r4, [sp, 0x8] - movs r0, 0x1 - movs r1, 0 - movs r2, 0 - movs r3, 0 - bl sub_80A75AC - adds r1, r0, 0 - movs r0, 0x1 - ands r0, r1 - cmp r0, 0 - bne _08117D98 - movs r2, 0x1 -_08117D6E: - lsrs r1, 1 - adds r4, 0x1 - adds r0, r1, 0 - ands r0, r2 - cmp r0, 0 - beq _08117D6E - b _08117D98 - .pool -_08117D80: - cmp r0, 0x1 - bne _08117D8C - ldr r0, =gBattleAnimAttacker - b _08117D92 - .pool -_08117D8C: - cmp r0, 0x2 - bne _08117D98 - ldr r0, =gBattleAnimTarget -_08117D92: - ldrb r0, [r0] - adds r4, r0, 0 - adds r4, 0x10 -_08117D98: - lsls r0, r4, 5 - ldr r1, =gPlttBufferUnfaded - adds r0, r1 - ldr r1, =gMonSpritesGfxPtr - ldr r2, [r1] - ldr r1, =gBattleAnimArgs - movs r3, 0x2 - ldrsh r1, [r1, r3] - movs r3, 0xBE - lsls r3, 1 - adds r2, r3 - ldr r2, [r2] - lsls r1, 5 - adds r1, r2 - movs r2, 0x20 - bl memcpy - adds r0, r5, 0 - bl DestroyAnimVisualTask - add sp, 0xC - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8117D3C - - thumb_func_start sub_8117DD8 -sub_8117DD8: @ 8117DD8 - push {r4,r5,lr} - sub sp, 0xC - lsls r0, 24 - lsrs r5, r0, 24 - movs r4, 0 - ldr r0, =gBattleAnimArgs - movs r1, 0 - ldrsh r0, [r0, r1] - cmp r0, 0 - bne _08117E1C - str r4, [sp] - str r4, [sp, 0x4] - str r4, [sp, 0x8] - movs r0, 0x1 - movs r1, 0 - movs r2, 0 - movs r3, 0 - bl sub_80A75AC - adds r1, r0, 0 - movs r0, 0x1 - ands r0, r1 - cmp r0, 0 - bne _08117E34 - movs r2, 0x1 -_08117E0A: - lsrs r1, 1 - adds r4, 0x1 - adds r0, r1, 0 - ands r0, r2 - cmp r0, 0 - beq _08117E0A - b _08117E34 - .pool -_08117E1C: - cmp r0, 0x1 - bne _08117E28 - ldr r0, =gBattleAnimAttacker - b _08117E2E - .pool -_08117E28: - cmp r0, 0x2 - bne _08117E34 - ldr r0, =gBattleAnimTarget -_08117E2E: - ldrb r0, [r0] - adds r4, r0, 0 - adds r4, 0x10 -_08117E34: - lsls r1, r4, 5 - ldr r0, =gPlttBufferUnfaded - adds r0, r1, r0 - ldr r2, =gPlttBufferFaded - adds r1, r2 - movs r2, 0x20 - bl memcpy - adds r0, r5, 0 - bl DestroyAnimVisualTask - add sp, 0xC - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8117DD8 - - thumb_func_start AnimTask_IsContest -AnimTask_IsContest: @ 8117E60 - push {r4,lr} - lsls r0, 24 - lsrs r4, r0, 24 - bl IsContest - lsls r0, 24 - lsrs r1, r0, 24 - cmp r1, 0 - beq _08117E80 - ldr r1, =gBattleAnimArgs - movs r0, 0x1 - strh r0, [r1, 0xE] - b _08117E84 - .pool -_08117E80: - ldr r0, =gBattleAnimArgs - strh r1, [r0, 0xE] -_08117E84: - adds r0, r4, 0 - bl DestroyAnimVisualTask - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end AnimTask_IsContest - - thumb_func_start sub_8117E94 -sub_8117E94: @ 8117E94 - push {lr} - lsls r0, 24 - lsrs r0, 24 - ldr r2, =gBattleAnimAttacker - ldr r1, =gBattlerTarget - ldrb r1, [r1] - strb r1, [r2] - ldr r2, =gBattleAnimTarget - ldr r1, =gEffectBattler - ldrb r1, [r1] - strb r1, [r2] - bl DestroyAnimVisualTask - pop {r0} - bx r0 - .pool - thumb_func_end sub_8117E94 - - thumb_func_start AnimTask_IsTargetSameSide -AnimTask_IsTargetSameSide: @ 8117EC4 - push {r4,r5,lr} - lsls r0, 24 - lsrs r5, r0, 24 - ldr r0, =gBattleAnimAttacker - ldrb r0, [r0] - bl GetBattlerSide - adds r4, r0, 0 - ldr r0, =gBattleAnimTarget - ldrb r0, [r0] - bl GetBattlerSide - lsls r4, 24 - lsls r0, 24 - cmp r4, r0 - bne _08117EF8 - ldr r1, =gBattleAnimArgs - movs r0, 0x1 - b _08117EFC - .pool -_08117EF8: - ldr r1, =gBattleAnimArgs - movs r0, 0 -_08117EFC: - strh r0, [r1, 0xE] - adds r0, r5, 0 - bl DestroyAnimVisualTask - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end AnimTask_IsTargetSameSide - - thumb_func_start sub_8117F10 -sub_8117F10: @ 8117F10 - push {lr} - lsls r0, 24 - lsrs r0, 24 - ldr r2, =gBattleAnimTarget - ldr r1, =gBattlerTarget - ldrb r1, [r1] - strb r1, [r2] - bl DestroyAnimVisualTask - pop {r0} - bx r0 - .pool - thumb_func_end sub_8117F10 - - thumb_func_start sub_8117F30 -sub_8117F30: @ 8117F30 - push {lr} - lsls r0, 24 - lsrs r0, 24 - ldr r2, =gBattleAnimAttacker - ldr r1, =gBattlerAttacker - ldrb r1, [r1] - strb r1, [r2] - ldr r2, =gBattleAnimTarget - ldr r1, =gEffectBattler - ldrb r1, [r1] - strb r1, [r2] - bl DestroyAnimVisualTask - pop {r0} - bx r0 - .pool - thumb_func_end sub_8117F30 - - thumb_func_start sub_8117F60 -sub_8117F60: @ 8117F60 - push {r4,lr} - lsls r0, 24 - lsrs r4, r0, 24 - bl IsContest - lsls r0, 24 - cmp r0, 0 - beq _08117F78 - adds r0, r4, 0 - bl DestroyAnimVisualTask - b _08117FB4 -_08117F78: - ldr r0, =gTasks - lsls r3, r4, 2 - adds r3, r4 - lsls r3, 3 - adds r3, r0 - ldr r0, =gBattleSpritesDataPtr - ldr r4, [r0] - ldr r2, =gBattleAnimAttacker - ldrb r0, [r2] - ldr r1, [r4] - lsls r0, 2 - adds r0, r1 - ldr r0, [r0] - lsls r0, 31 - lsrs r0, 31 - strh r0, [r3, 0x8] - ldrb r1, [r2] - ldr r0, [r4] - lsls r1, 2 - adds r1, r0 - ldrb r0, [r1] - movs r2, 0x1 - orrs r0, r2 - strb r0, [r1] - ldr r0, =sub_8117FD0 - str r0, [r3] - ldr r1, =gAnimVisualTaskCount - ldrb r0, [r1] - subs r0, 0x1 - strb r0, [r1] -_08117FB4: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8117F60 - - thumb_func_start sub_8117FD0 -sub_8117FD0: @ 8117FD0 - push {r4,lr} - lsls r0, 24 - lsrs r4, r0, 24 - ldr r0, =gBattleAnimArgs - movs r2, 0xE - ldrsh r1, [r0, r2] - movs r0, 0x80 - lsls r0, 5 - cmp r1, r0 - bne _08118014 - ldr r0, =gBattleSpritesDataPtr - ldr r1, [r0] - ldr r0, =gBattleAnimAttacker - ldrb r3, [r0] - ldr r0, [r1] - lsls r3, 2 - adds r3, r0 - ldr r1, =gTasks - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - adds r0, r1 - ldrb r0, [r0, 0x8] - movs r1, 0x1 - ands r1, r0 - ldrb r2, [r3] - movs r0, 0x2 - negs r0, r0 - ands r0, r2 - orrs r0, r1 - strb r0, [r3] - adds r0, r4, 0 - bl DestroyTask -_08118014: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8117FD0 - - .align 2, 0 diff --git a/asm/fossil_specials.s b/asm/fossil_specials.s deleted file mode 100644 index eb7cb8adab..0000000000 --- a/asm/fossil_specials.s +++ /dev/null @@ -1,111 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .syntax unified - - .text - - thumb_func_start sub_81BF2B8 -sub_81BF2B8: @ 81BF2B8 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x8 - str r0, [sp] - mov r10, r1 - adds r6, r2, 0 - mov r8, r3 - ldr r0, [sp, 0x28] - mov r9, r0 - lsls r1, 16 - lsrs r1, 16 - mov r10, r1 - lsls r6, 24 - lsrs r6, 24 - mov r0, r8 - lsls r0, 24 - mov r8, r0 - lsrs r7, r0, 24 - mov r1, r9 - lsls r1, 24 - lsrs r1, 24 - mov r9, r1 - mov r0, r10 - adds r1, r7, 0 - bl __divsi3 - adds r5, r0, 0 - lsls r5, 24 - lsrs r4, r5, 24 - ldr r3, =gUnknown_030012A8 - strh r4, [r3] - mov r0, r10 - adds r1, r7, 0 - str r3, [sp, 0x4] - bl __modsi3 - lsls r0, 24 - lsrs r2, r0, 24 - ldr r3, [sp, 0x4] - strh r2, [r3, 0x2] - movs r1, 0x7 - ands r4, r1 - ands r2, r1 - strh r4, [r3, 0x4] - strh r2, [r3, 0x6] - lsrs r0, 27 - lsrs r5, 27 - strh r0, [r3, 0x8] - strh r5, [r3, 0xA] - mov r1, r8 - lsrs r1, 27 - lsls r1, 6 - mov r8, r1 - mov r1, r8 - muls r1, r5 - lsls r0, 6 - adds r1, r0 - lsls r1, 16 - lsrs r1, 16 - strh r1, [r3, 0xC] - lsls r4, 3 - adds r4, r2 - adds r1, r4 - lsls r4, r1, 16 - lsrs r4, 17 - strh r1, [r3, 0xE] - movs r1, 0x1 - mov r0, r10 - ands r1, r0 - movs r2, 0x1 - eors r1, r2 - lsls r0, r1, 2 - lsls r6, r0 - eors r1, r2 - lsls r1, 2 - movs r0, 0xF - lsls r0, r1 - orrs r6, r0 - lsls r6, 24 - lsrs r6, 24 - mov r1, r9 - lsls r1, 5 - mov r9, r1 - add r9, r4 - ldr r1, [sp] - add r1, r9 - ldrb r0, [r1] - ands r6, r0 - strb r6, [r1] - add sp, 0x8 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81BF2B8 - - .align 2, 0 @ Don't pad with nop. diff --git a/asm/mossdeep_gym.s b/asm/mossdeep_gym.s deleted file mode 100644 index 34dfb94296..0000000000 --- a/asm/mossdeep_gym.s +++ /dev/null @@ -1,701 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .syntax unified - - .text - - thumb_func_start sub_81A8934 -@ void sub_81A8934(u8) -sub_81A8934: @ 81A8934 - push {r4,r5,lr} - lsls r0, 24 - lsrs r5, r0, 24 - ldr r4, =gUnknown_0203CE50 - ldr r0, [r4] - cmp r0, 0 - bne _081A894A - movs r0, 0x44 - bl AllocZeroed - str r0, [r4] -_081A894A: - ldr r0, [r4] - adds r0, 0x41 - strb r5, [r0] - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81A8934 - - thumb_func_start sub_81A895C -sub_81A895C: @ 81A895C - push {r4,lr} - ldr r4, =gUnknown_0203CE50 - ldr r0, [r4] - cmp r0, 0 - beq _081A896E - bl Free - movs r0, 0 - str r0, [r4] -_081A896E: - movs r0, 0xFF - movs r1, 0 - movs r2, 0 - bl GetEventObjectIdByLocalIdAndMap - adds r1, r0, 0 - lsls r1, 24 - lsrs r1, 24 - lsls r0, r1, 3 - adds r0, r1 - lsls r0, 2 - ldr r1, =gEventObjects - adds r0, r1 - bl EventObjectClearHeldMovementIfFinished - bl sub_80D338C - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81A895C - - thumb_func_start sub_81A89A0 -sub_81A89A0: @ 81A89A0 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x4 - lsls r0, 24 - lsrs r0, 24 - str r0, [sp] - ldr r0, =gSaveBlock1Ptr - ldr r0, [r0] - movs r1, 0xC7 - lsls r1, 4 - adds r1, r0 - mov r9, r1 - movs r3, 0 - mov r10, r3 - mov r8, r3 -_081A89C4: - mov r0, r8 - lsls r4, r0, 1 - adds r1, r4, r0 - lsls r1, 3 - add r1, r9 - ldrh r0, [r1, 0x4] - adds r0, 0x7 - ldrh r1, [r1, 0x6] - adds r1, 0x7 - lsls r0, 16 - asrs r0, 16 - lsls r1, 16 - asrs r1, 16 - bl MapGridGetMetatileIdAt - lsls r0, 16 - lsrs r1, r0, 16 - ldr r0, =gUnknown_0203CE50 - ldr r0, [r0] - adds r0, 0x41 - ldrb r0, [r0] - movs r2, 0xA6 - lsls r2, 2 - cmp r0, 0 - bne _081A89F8 - subs r2, 0x48 -_081A89F8: - ldr r0, =0x0000024f - cmp r1, r0 - bls _081A8AD4 - subs r1, r2 - adds r0, r1, 0 - cmp r1, 0 - bge _081A8A08 - adds r0, r1, 0x7 -_081A8A08: - asrs r2, r0, 3 - lsls r0, r2, 24 - lsrs r0, 24 - cmp r0, 0x4 - bhi _081A8AD4 - ldr r3, [sp] - cmp r0, r3 - bne _081A8AD4 - lsls r0, r2, 3 - subs r0, r1, r0 - lsls r0, 24 - lsrs r5, r0, 24 - cmp r5, 0x3 - bhi _081A8AD4 - movs r1, 0 - movs r2, 0 - cmp r5, 0x1 - beq _081A8A58 - cmp r5, 0x1 - bgt _081A8A44 - cmp r5, 0 - beq _081A8A4E - b _081A8AD4 - .pool -_081A8A44: - cmp r5, 0x2 - beq _081A8A64 - cmp r5, 0x3 - beq _081A8A70 - b _081A8AD4 -_081A8A4E: - ldr r7, =gUnknown_08612698 - movs r1, 0x1 - b _081A8A74 - .pool -_081A8A58: - ldr r7, =gUnknown_0861269C - movs r2, 0x1 - b _081A8A74 - .pool -_081A8A64: - ldr r7, =gUnknown_086126A0 - movs r1, 0xFF - b _081A8A74 - .pool -_081A8A70: - ldr r7, =gUnknown_086126A4 - movs r2, 0xFF -_081A8A74: - mov r3, r8 - adds r0, r4, r3 - lsls r0, 3 - mov r3, r9 - adds r4, r0, r3 - lsls r0, r1, 24 - asrs r0, 24 - ldrh r1, [r4, 0x4] - adds r0, r1 - strh r0, [r4, 0x4] - lsls r0, r2, 24 - asrs r0, 24 - ldrh r3, [r4, 0x6] - adds r0, r3 - strh r0, [r4, 0x6] - ldrb r0, [r4] - ldr r6, =gSaveBlock1Ptr - ldr r2, [r6] - ldrb r1, [r2, 0x5] - ldrb r2, [r2, 0x4] - bl GetEventObjectIdByLocalIdAndMap - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x10 - beq _081A8ACC - mov r0, r8 - adds r1, r5, 0 - bl sub_81A8D60 - ldrb r4, [r4] - mov r10, r4 - mov r0, r10 - ldr r2, [r6] - ldrb r1, [r2, 0x5] - ldrb r2, [r2, 0x4] - adds r3, r7, 0 - bl ScriptMovement_StartObjectMovementScript - b _081A8AD4 - .pool -_081A8ACC: - mov r0, r8 - adds r1, r5, 0 - bl sub_81A8D94 -_081A8AD4: - mov r0, r8 - adds r0, 0x1 - lsls r0, 24 - lsrs r0, 24 - mov r8, r0 - cmp r0, 0x3F - bhi _081A8AE4 - b _081A89C4 -_081A8AE4: - mov r0, r10 - add sp, 0x4 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r1} - bx r1 - thumb_func_end sub_81A89A0 - - thumb_func_start sub_81A8AF8 -sub_81A8AF8: @ 81A8AF8 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - ldr r1, =gUnknown_0203CE50 - ldr r2, [r1] - cmp r2, 0 - bne _081A8B0C - b _081A8D4A -_081A8B0C: - adds r0, r2, 0 - adds r0, 0x41 - ldrb r0, [r0] - movs r3, 0xA6 - lsls r3, 2 - mov r10, r3 - cmp r0, 0 - bne _081A8B22 - movs r0, 0x94 - lsls r0, 2 - mov r10, r0 -_081A8B22: - ldr r0, =gSaveBlock1Ptr - ldr r0, [r0] - movs r3, 0xC7 - lsls r3, 4 - adds r7, r0, r3 - movs r0, 0 - mov r9, r0 - adds r0, r2, 0 - adds r0, 0x40 - ldrb r0, [r0] - cmp r9, r0 - bcc _081A8B3C - b _081A8D4A -_081A8B3C: - mov r8, r1 -_081A8B3E: - mov r1, r8 - ldr r0, [r1] - mov r2, r9 - lsls r4, r2, 2 - adds r0, r4 - ldrb r0, [r0, 0x1] - lsls r1, r0, 1 - adds r1, r0 - lsls r1, 3 - adds r1, r7 - ldrh r0, [r1, 0x4] - adds r0, 0x7 - ldrh r1, [r1, 0x6] - adds r1, 0x7 - lsls r0, 16 - asrs r0, 16 - lsls r1, 16 - asrs r1, 16 - bl MapGridGetMetatileIdAt - lsls r0, 16 - lsrs r0, 16 - mov r3, r10 - subs r1, r0, r3 - adds r0, r1, 0 - cmp r1, 0 - bge _081A8B76 - adds r0, r1, 0x7 -_081A8B76: - asrs r0, 3 - lsls r0, 3 - subs r0, r1, r0 - lsls r0, 24 - lsrs r0, 24 - mov r2, r8 - ldr r1, [r2] - adds r1, r4 - ldrb r1, [r1] - subs r0, r1 - lsls r0, 24 - asrs r1, r0, 24 - cmp r1, 0 - blt _081A8B96 - cmp r1, 0x3 - bne _081A8BAC -_081A8B96: - movs r0, 0x3 - negs r0, r0 - movs r6, 0 - cmp r1, r0 - bne _081A8BB4 - b _081A8BB2 - .pool -_081A8BAC: - movs r6, 0x2 - cmp r1, 0 - ble _081A8BB4 -_081A8BB2: - movs r6, 0x1 -_081A8BB4: - ldr r5, =gUnknown_0203CE50 - ldr r0, [r5] - adds r0, r4 - ldrb r1, [r0, 0x1] - lsls r0, r1, 1 - adds r0, r1 - lsls r0, 3 - adds r0, r7 - ldrb r0, [r0] - ldr r1, =gSaveBlock1Ptr - ldr r2, [r1] - ldrb r1, [r2, 0x5] - ldrb r2, [r2, 0x4] - bl GetEventObjectIdByLocalIdAndMap - lsls r0, 24 - lsrs r2, r0, 24 - cmp r2, 0x10 - bne _081A8BDC - b _081A8D32 -_081A8BDC: - ldr r0, =gEventObjects - lsls r1, r2, 3 - adds r1, r2 - lsls r1, 2 - adds r1, r0 - ldrb r0, [r1, 0x18] - lsls r0, 28 - lsrs r0, 28 - adds r1, r0, 0 - cmp r6, 0 - bne _081A8C9C - cmp r0, 0x2 - beq _081A8C60 - cmp r0, 0x2 - bgt _081A8C0C - cmp r0, 0x1 - beq _081A8C30 - b _081A8D32 - .pool -_081A8C0C: - cmp r0, 0x3 - beq _081A8C48 - cmp r0, 0x4 - beq _081A8C16 - b _081A8D32 -_081A8C16: - ldr r3, =gUnknown_086126AE - ldr r0, [r5] - adds r0, r4 - ldrb r1, [r0, 0x1] - lsls r0, r1, 1 - adds r0, r1 - lsls r0, 3 - adds r0, r7 - movs r1, 0x7 - b _081A8C72 - .pool -_081A8C30: - ldr r3, =gUnknown_086126A8 - ldr r0, [r5] - adds r0, r4 - ldrb r1, [r0, 0x1] - lsls r0, r1, 1 - adds r0, r1 - lsls r0, 3 - adds r0, r7 - movs r1, 0xA - b _081A8C72 - .pool -_081A8C48: - ldr r3, =gUnknown_086126AA - ldr r0, [r5] - adds r0, r4 - ldrb r1, [r0, 0x1] - lsls r0, r1, 1 - adds r0, r1 - lsls r0, 3 - adds r0, r7 - movs r1, 0x8 - b _081A8C72 - .pool -_081A8C60: - ldr r3, =gUnknown_086126AC - ldr r0, [r5] - adds r0, r4 - ldrb r1, [r0, 0x1] - lsls r0, r1, 1 - adds r0, r1 - lsls r0, 3 - adds r0, r7 - movs r1, 0x9 -_081A8C72: - strb r1, [r0, 0x9] - mov r1, r8 - ldr r0, [r1] - adds r0, r4 - ldrb r1, [r0, 0x1] - lsls r0, r1, 1 - adds r0, r1 - lsls r0, 3 - adds r0, r7 - ldrb r0, [r0] - ldr r1, =gSaveBlock1Ptr - ldr r2, [r1] - ldrb r1, [r2, 0x5] - ldrb r2, [r2, 0x4] - bl ScriptMovement_StartObjectMovementScript - b _081A8D32 - .pool -_081A8C9C: - cmp r6, 0x1 - bne _081A8D32 - cmp r0, 0x2 - beq _081A8D00 - cmp r0, 0x2 - bgt _081A8CAE - cmp r0, 0x1 - beq _081A8CD0 - b _081A8D32 -_081A8CAE: - cmp r1, 0x3 - beq _081A8CE8 - cmp r1, 0x4 - bne _081A8D32 - ldr r3, =gUnknown_086126AA - ldr r0, [r5] - adds r0, r4 - ldrb r1, [r0, 0x1] - lsls r0, r1, 1 - adds r0, r1 - lsls r0, 3 - adds r0, r7 - movs r1, 0x8 - b _081A8D12 - .pool -_081A8CD0: - ldr r3, =gUnknown_086126AC - ldr r0, [r5] - adds r0, r4 - ldrb r1, [r0, 0x1] - lsls r0, r1, 1 - adds r0, r1 - lsls r0, 3 - adds r0, r7 - movs r1, 0x9 - b _081A8D12 - .pool -_081A8CE8: - ldr r3, =gUnknown_086126AE - ldr r0, [r5] - adds r0, r4 - ldrb r1, [r0, 0x1] - lsls r0, r1, 1 - adds r0, r1 - lsls r0, 3 - adds r0, r7 - movs r1, 0x7 - b _081A8D12 - .pool -_081A8D00: - ldr r3, =gUnknown_086126A8 - ldr r0, [r5] - adds r0, r4 - ldrb r1, [r0, 0x1] - lsls r0, r1, 1 - adds r0, r1 - lsls r0, 3 - adds r0, r7 - movs r1, 0xA -_081A8D12: - strb r1, [r0, 0x9] - mov r2, r8 - ldr r0, [r2] - adds r0, r4 - ldrb r1, [r0, 0x1] - lsls r0, r1, 1 - adds r0, r1 - lsls r0, 3 - adds r0, r7 - ldrb r0, [r0] - ldr r1, =gSaveBlock1Ptr - ldr r2, [r1] - ldrb r1, [r2, 0x5] - ldrb r2, [r2, 0x4] - bl ScriptMovement_StartObjectMovementScript -_081A8D32: - mov r0, r9 - adds r0, 0x1 - lsls r0, 24 - lsrs r0, 24 - mov r9, r0 - mov r3, r8 - ldr r0, [r3] - adds r0, 0x40 - ldrb r0, [r0] - cmp r9, r0 - bcs _081A8D4A - b _081A8B3E -_081A8D4A: - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81A8AF8 - - thumb_func_start sub_81A8D60 -sub_81A8D60: @ 81A8D60 - push {r4,lr} - ldr r4, =gUnknown_0203CE50 - ldr r3, [r4] - adds r2, r3, 0 - adds r2, 0x40 - ldrb r2, [r2] - lsls r2, 2 - adds r3, r2 - strb r0, [r3, 0x1] - ldr r2, [r4] - adds r0, r2, 0 - adds r0, 0x40 - ldrb r0, [r0] - lsls r0, 2 - adds r2, r0 - strb r1, [r2] - ldr r1, [r4] - adds r1, 0x40 - ldrb r0, [r1] - adds r0, 0x1 - strb r0, [r1] - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81A8D60 - - thumb_func_start sub_81A8D94 -sub_81A8D94: @ 81A8D94 - push {r4-r6,lr} - lsls r0, 24 - lsrs r4, r0, 24 - lsls r1, 24 - lsrs r6, r1, 24 - ldr r0, =gSaveBlock1Ptr - ldr r0, [r0] - movs r1, 0xC7 - lsls r1, 4 - adds r5, r0, r1 - lsls r1, r4, 1 - adds r1, r4 - lsls r1, 3 - adds r1, r5 - ldrh r0, [r1, 0x4] - adds r0, 0x7 - ldrh r1, [r1, 0x6] - adds r1, 0x7 - lsls r0, 16 - asrs r0, 16 - lsls r1, 16 - asrs r1, 16 - bl MapGridGetMetatileIdAt - lsls r0, 16 - lsrs r2, r0, 16 - ldr r0, =gUnknown_0203CE50 - ldr r0, [r0] - adds r0, 0x41 - ldrb r0, [r0] - movs r1, 0xA6 - lsls r1, 2 - cmp r0, 0 - bne _081A8DDA - subs r1, 0x48 -_081A8DDA: - subs r1, r2, r1 - adds r0, r1, 0 - cmp r1, 0 - bge _081A8DE4 - adds r0, r1, 0x7 -_081A8DE4: - asrs r0, 3 - lsls r0, 3 - subs r0, r1, r0 - lsls r0, 24 - lsrs r0, 24 - subs r0, r6 - lsls r0, 24 - asrs r1, r0, 24 - cmp r1, 0 - blt _081A8DFC - cmp r1, 0x3 - bne _081A8E08 -_081A8DFC: - movs r2, 0 - b _081A8E1A - .pool -_081A8E08: - cmp r1, 0 - bgt _081A8E14 - movs r0, 0x3 - negs r0, r0 - cmp r1, r0 - bne _081A8E18 -_081A8E14: - movs r2, 0x1 - b _081A8E1A -_081A8E18: - movs r2, 0x2 -_081A8E1A: - lsls r0, r4, 1 - adds r0, r4 - lsls r0, 3 - adds r1, r0, r5 - ldrb r0, [r1, 0x9] - adds r3, r0, 0 - cmp r2, 0 - bne _081A8E4C - cmp r0, 0x8 - beq _081A8E72 - cmp r0, 0x8 - bgt _081A8E38 - cmp r0, 0x7 - beq _081A8E48 - b _081A8E76 -_081A8E38: - cmp r0, 0x9 - beq _081A8E44 - cmp r0, 0xA - bne _081A8E76 - movs r0, 0x7 - b _081A8E74 -_081A8E44: - movs r0, 0x8 - b _081A8E74 -_081A8E48: - movs r0, 0x9 - b _081A8E74 -_081A8E4C: - cmp r2, 0x1 - bne _081A8E76 - cmp r0, 0x8 - beq _081A8E6A - cmp r0, 0x8 - bgt _081A8E5E - cmp r0, 0x7 - beq _081A8E72 - b _081A8E76 -_081A8E5E: - cmp r3, 0x9 - beq _081A8E6E - cmp r3, 0xA - bne _081A8E76 - movs r0, 0x8 - b _081A8E74 -_081A8E6A: - movs r0, 0x9 - b _081A8E74 -_081A8E6E: - movs r0, 0x7 - b _081A8E74 -_081A8E72: - movs r0, 0xA -_081A8E74: - strb r0, [r1, 0x9] -_081A8E76: - pop {r4-r6} - pop {r0} - bx r0 - thumb_func_end sub_81A8D94 - - .align 2, 0 @ Don't pad with nop. diff --git a/common_syms/apprentice.txt b/common_syms/apprentice.txt new file mode 100644 index 0000000000..e35133eccc --- /dev/null +++ b/common_syms/apprentice.txt @@ -0,0 +1,3 @@ +gUnknown_030062EC +gUnknown_030062F0 +gUnknown_030062F4 diff --git a/common_syms/battle_factory_screen.txt b/common_syms/battle_factory_screen.txt new file mode 100644 index 0000000000..9f68681399 --- /dev/null +++ b/common_syms/battle_factory_screen.txt @@ -0,0 +1 @@ +gUnknown_030062E8 diff --git a/common_syms/battle_tower.txt b/common_syms/battle_tower.txt new file mode 100644 index 0000000000..dd198e2292 --- /dev/null +++ b/common_syms/battle_tower.txt @@ -0,0 +1 @@ +gUnknown_03006298 diff --git a/common_syms/berry_blender.txt b/common_syms/berry_blender.txt new file mode 100644 index 0000000000..1b15a33d61 --- /dev/null +++ b/common_syms/berry_blender.txt @@ -0,0 +1 @@ +gInGameOpponentsNo diff --git a/common_syms/overworld.txt b/common_syms/overworld.txt index a3b97a7597..b92da84ec7 100644 --- a/common_syms/overworld.txt +++ b/common_syms/overworld.txt @@ -1,3 +1,6 @@ +gBGTilemapBuffers1 +gBGTilemapBuffers2 +gBGTilemapBuffers3 gUnknown_03005DA8 gFieldCallback gFieldCallback2 diff --git a/common_syms/pokedex.txt b/common_syms/pokedex.txt new file mode 100644 index 0000000000..c982c9d3a3 --- /dev/null +++ b/common_syms/pokedex.txt @@ -0,0 +1,2 @@ +gUnknown_030060B0 +gUnknown_030060B4 diff --git a/common_syms/start_menu.txt b/common_syms/start_menu.txt new file mode 100644 index 0000000000..05beaf57c2 --- /dev/null +++ b/common_syms/start_menu.txt @@ -0,0 +1 @@ +gMenuCallback diff --git a/data/battle_anim_scripts.s b/data/battle_anim_scripts.s index 3669a8f906..9a13e0c21d 100644 --- a/data/battle_anim_scripts.s +++ b/data/battle_anim_scripts.s @@ -4560,7 +4560,7 @@ SkyAttackEnd: SkyAttackSetUp: monbg ANIM_DEF_PARTNER setalpha 12, 11 - createvisualtask AnimTask_IsTargetPartner, 5, ARG_RET_ID + createvisualtask AnimTask_GetTargetIsAttackerPartner, 5, ARG_RET_ID jumpretfalse SkyAttackSetUpAgainstOpponent goto SkyAttackSetUpAgainstPartner SkyAttackSetUpAgainstOpponent: @@ -4764,7 +4764,7 @@ Move_MACH_PUNCH: loadspritegfx ANIM_TAG_IMPACT loadspritegfx ANIM_TAG_HANDS_AND_FEET monbg ANIM_ATK_PARTNER - createvisualtask AnimTask_IsAttackerOpponentSide, 2 + createvisualtask AnimTask_GetAttackerSide, 2 jumprettrue MachPunchAgainstPlayer fadetobg BG_HIGHSPEED_OPPONENT MachPunchContinue: @@ -5024,7 +5024,7 @@ Move_MOONLIGHT: Move_EXTREME_SPEED: loadspritegfx ANIM_TAG_SPEED_DUST loadspritegfx ANIM_TAG_IMPACT - createvisualtask AnimTask_IsAttackerOpponentSide, 2 + createvisualtask AnimTask_GetAttackerSide, 2 jumprettrue ExtremeSpeedAgainstPlayer fadetobg BG_HIGHSPEED_OPPONENT ExtremeSpeedContinue: @@ -5510,13 +5510,13 @@ Move_CAMOUFLAGE: monbg ANIM_ATK_PARTNER monbgprio_28 ANIM_ATTACKER setalpha 16, 0 - createvisualtask sub_811675C, 5, 2, 3, 0, 14 + createvisualtask AnimTask_SetCamouflageBlend, 5, 2, 3, 0, 14 delay 16 createvisualtask sub_81136E8, 2, 4 playsewithpan SE_W185, SOUND_PAN_ATTACKER waitforvisualfinish delay 8 - createvisualtask sub_811675C, 5, 2, 0, 0, 0 + createvisualtask AnimTask_SetCamouflageBlend, 5, 2, 0, 0, 0 waitforvisualfinish createvisualtask sub_81137E4, 2, 1 waitforvisualfinish @@ -7157,7 +7157,7 @@ SolarBeamUnleash1: Move_BLIZZARD: loadspritegfx ANIM_TAG_ICE_CRYSTALS monbg ANIM_DEF_PARTNER - createvisualtask AnimTask_IsAttackerOpponentSide, 2 + createvisualtask AnimTask_GetAttackerSide, 2 jumprettrue BlizzardAgainstPlayer fadetobg BG_HIGHSPEED_OPPONENT BlizzardContinue: @@ -10797,7 +10797,7 @@ Move_SILVER_WIND: monbgprio_29 delay 0 createvisualtask sub_8116664, 10, 1, 0, 0, 4, RGB_BLACK - createvisualtask AnimTask_IsTargetOpponentSide, 2 + createvisualtask AnimTask_GetTargetSide, 2 jumprettrue SilverWindOnPlayer fadetobg BG_BUG_OPPONENT waitbgfadeout diff --git a/include/battle.h b/include/battle.h index 3aab577abd..d25ee3a338 100644 --- a/include/battle.h +++ b/include/battle.h @@ -748,10 +748,22 @@ struct MonSpritesGfx u8 field_F4[0x80]; u8 *barFontGfx; void *field_178; - void *field_17C; + u16 *field_17C; }; // All battle variables are declared in battle_main.c +extern u16 gBattle_BG0_X; +extern u16 gBattle_BG0_Y; +extern u16 gBattle_BG1_X; +extern u16 gBattle_BG1_Y; +extern u16 gBattle_BG2_X; +extern u16 gBattle_BG2_Y; +extern u16 gBattle_BG3_X; +extern u16 gBattle_BG3_Y; +extern u16 gBattle_WIN0H; +extern u16 gBattle_WIN0V; +extern u16 gBattle_WIN1H; +extern u16 gBattle_WIN1V; extern u8 gDisplayedStringBattle[300]; extern u8 gBattleTextBuff1[TEXT_BUFF_ARRAY_COUNT]; extern u8 gBattleTextBuff2[TEXT_BUFF_ARRAY_COUNT]; diff --git a/include/battle_anim.h b/include/battle_anim.h index 653be10b83..e164cef7a9 100644 --- a/include/battle_anim.h +++ b/include/battle_anim.h @@ -9,7 +9,7 @@ enum BG_ANIM_SCREEN_SIZE, BG_ANIM_AREA_OVERFLOW_MODE, BG_ANIM2, - BG_ANIM3, + BG_ANIM_CHAR_BASE_BLOCK, BG_ANIM_PRIORITY, BG_ANIM_5, BG_ANIM_6 @@ -64,6 +64,7 @@ s8 BattleAnimAdjustPanning2(s8 pan); s16 KeepPanInRange(s16 a); 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 void SetAnimBgAttribute(u8 bgId, u8 attributeId, u8 value); @@ -87,6 +88,15 @@ void obj_id_set_rotscale(u8 spriteId, s16 xScale, s16 yScale, u16 rotation); void sub_80A6E14(struct Sprite *sprite); void sub_80A7270(u8 spriteId, u8 objMode); void sub_80A73A0(u8 spriteId); +u32 sub_80A75AC(u8 a1, u8 a2, u8 a3, u8 a4, u8 a5, u8 a6, u8 a7); +u32 sub_80A76C4(u8 a1, u8 a2, u8 a3, u8 a4); +u8 sub_80A77AC(u8 a1); +s16 duplicate_obj_of_side_rel2move_in_transparent_mode(u8); +void obj_delete_but_dont_free_vram(struct Sprite*); +u8 sub_80A89C8(int, u8, int); +void sub_80A6D60(struct UnknownAnimStruct2*, const void*, u32); +void sub_80A6CC0(u32, const void*, u32); +void sub_80A6DAC(bool8); enum { @@ -127,6 +137,11 @@ u8 ItemIdToBallId(u16 itemId); u8 LaunchBallStarsTask(u8 x, u8 y, u8 kindOfStars, u8 arg3, u8 ballId); u8 LaunchBallFadeMonTask(bool8 unFadeLater, u8 battlerId, u32 arg2, u8 ballId); +// battle_anim_utility_funcs.s +void sub_8116EB4(u8); + +u32 sub_811583C(s16); + u8 GetBattlerSpriteFinal_Y(u8, u16, u8); extern const struct OamData gUnknown_08524944; diff --git a/include/battle_tower.h b/include/battle_tower.h index 90c22c9829..b6adcec0ce 100644 --- a/include/battle_tower.h +++ b/include/battle_tower.h @@ -38,6 +38,8 @@ extern const u8 gTowerMaleTrainerGfxIds[30]; extern const u8 gTowerFemaleFacilityClasses[20]; extern const u8 gTowerFemaleTrainerGfxIds[20]; +extern u16 gUnknown_03006298[]; + extern const struct BattleFrontierTrainer *gFacilityTrainers; extern const struct FacilityMon *gFacilityTrainerMons; diff --git a/include/berry_blender.h b/include/berry_blender.h index fb62e3fa35..e8f7bb83dd 100644 --- a/include/berry_blender.h +++ b/include/berry_blender.h @@ -1,6 +1,8 @@ #ifndef GUARD_BERRY_BLENDER_H #define GUARD_BERRY_BLENDER_H +extern u8 gInGameOpponentsNo; + void DoBerryBlending(void); u16 GetBlenderArrowPosition(void); void ShowBerryBlenderRecordWindow(void); diff --git a/include/contest.h b/include/contest.h index d62d33ab70..502d44b906 100644 --- a/include/contest.h +++ b/include/contest.h @@ -239,7 +239,7 @@ struct Shared18000 struct ContestStruct_field_18 { - u16 unk0; + u16 species; u16 unk2; u8 unk4_0:1; u8 unk5; diff --git a/include/gba/io_reg.h b/include/gba/io_reg.h index 03faa1a874..c20b69886e 100644 --- a/include/gba/io_reg.h +++ b/include/gba/io_reg.h @@ -565,12 +565,14 @@ #define WINOUT_WIN01_BG1 (1 << 1) #define WINOUT_WIN01_BG2 (1 << 2) #define WINOUT_WIN01_BG3 (1 << 3) +#define WINOUT_WIN01_BG_ALL (WINOUT_WIN01_BG0 | WINOUT_WIN01_BG1 | WINOUT_WIN01_BG2 | WINOUT_WIN01_BG3) #define WINOUT_WIN01_OBJ (1 << 4) #define WINOUT_WIN01_CLR (1 << 5) #define WINOUT_WINOBJ_BG0 (1 << 8) #define WINOUT_WINOBJ_BG1 (1 << 9) #define WINOUT_WINOBJ_BG2 (1 << 10) #define WINOUT_WINOBJ_BG3 (1 << 11) +#define WINOUT_WINOBJ_BG_ALL (WINOUT_WINOBJ_BG0 | WINOUT_WINOBJ_BG1 | WINOUT_WINOBJ_BG2 | WINOUT_WINOBJ_BG3) #define WINOUT_WINOBJ_OBJ (1 << 12) #define WINOUT_WINOBJ_CLR (1 << 13) diff --git a/include/global.h b/include/global.h index dfd2afacfd..e256f38eed 100644 --- a/include/global.h +++ b/include/global.h @@ -67,11 +67,6 @@ #define min(a, b) ((a) < (b) ? (a) : (b)) #define max(a, b) ((a) >= (b) ? (a) : (b)) -extern u8 gStringVar1[]; -extern u8 gStringVar2[]; -extern u8 gStringVar3[]; -extern u8 gStringVar4[]; - // There are many quirks in the source code which have overarching behavioral differences from // a number of other files. For example, diploma.c seems to declare rodata before each use while // other files declare out of order and must be at the beginning. There are also a number of diff --git a/include/graphics.h b/include/graphics.h index a2c86a67da..a3af44ad7b 100644 --- a/include/graphics.h +++ b/include/graphics.h @@ -4697,6 +4697,20 @@ extern const u32 gBattleAnimBackgroundTilemap_17[]; extern const u32 gBattleAnimBackgroundTilemap_20[]; extern const u32 gBattleAnimBackgroundTilemap_21[]; +extern const u32 gUnknown_08C20668[]; +extern const u32 gUnknown_08C20684[]; +extern const u32 gBattleStatMask_Gfx[]; +extern const u32 gBattleStatMask1_Tilemap[]; +extern const u32 gBattleStatMask2_Tilemap[]; +extern const u32 gBattleStatMask1_Pal[]; +extern const u32 gBattleStatMask2_Pal[]; +extern const u32 gBattleStatMask3_Pal[]; +extern const u32 gBattleStatMask4_Pal[]; +extern const u32 gBattleStatMask5_Pal[]; +extern const u32 gBattleStatMask6_Pal[]; +extern const u32 gBattleStatMask7_Pal[]; +extern const u32 gBattleStatMask8_Pal[]; + extern const u32 gUnknown_08D9A88C[]; extern const u32 gContestMiscGfx[]; extern const u32 gContestAudienceGfx[]; diff --git a/include/mossdeep_gym.h b/include/mossdeep_gym.h new file mode 100644 index 0000000000..c167300947 --- /dev/null +++ b/include/mossdeep_gym.h @@ -0,0 +1,9 @@ +#ifndef GUARD_MOSSDEEP_GYM_H +#define GUARD_MOSSDEEP_GYM_H + +void InitMossdeepGymTiles(bool8 arg0); +void FinishMossdeepGymTiles(void); +u16 MossdeepGym_MoveEvents(u8 arg0); +void MossdeepGym_TurnEvents(void); + +#endif // GUARD_MOSSDEEP_GYM_H diff --git a/include/new_game.h b/include/new_game.h index 7032647ea5..f4d69cbced 100644 --- a/include/new_game.h +++ b/include/new_game.h @@ -1,6 +1,9 @@ #ifndef GUARD_NEW_GAME_H #define GUARD_NEW_GAME_H +extern bool8 gDifferentSaveFile; +extern bool8 gUnknown_020322D5; // The purpose of this variable is unknown as it's read only 3 times(2 times in contest.c and 1 time in berry_blender.c), never written to. + void SetTrainerId(u32 trainerId, u8 *dst); u32 GetTrainerId(u8 *trainerId); void CopyTrainerId(u8 *dst, u8 *src); diff --git a/include/overworld.h b/include/overworld.h index 3e9d42a22c..6f78019050 100644 --- a/include/overworld.h +++ b/include/overworld.h @@ -22,9 +22,9 @@ extern struct LinkPlayerEventObject gLinkPlayerEventObjects[4]; extern u16 *gBGTilemapBuffers1; extern u16 *gBGTilemapBuffers2; extern u16 *gBGTilemapBuffers3; - +extern u16 gUnknown_03005DA8; extern void (*gFieldCallback)(void); - +extern bool8 (*gFieldCallback2)(void); extern u8 gUnknown_03005DB4; extern u8 gFieldLinkPlayerCount; diff --git a/include/pokedex.h b/include/pokedex.h index f9e2365881..11e39997ca 100644 --- a/include/pokedex.h +++ b/include/pokedex.h @@ -1,6 +1,9 @@ #ifndef GUARD_POKEDEX_H #define GUARD_POKEDEX_H +extern u8 gUnknown_030060B0; +extern void (*gUnknown_030060B4)(void); + void ResetPokedex(void); void CopyMonCategoryText(u32 species, u8 *dst); u16 GetPokedexHeightWeight(u16 dexNum, u8 data); diff --git a/include/start_menu.h b/include/start_menu.h index 5551b149db..2fdb3e652c 100644 --- a/include/start_menu.h +++ b/include/start_menu.h @@ -1,7 +1,7 @@ #ifndef GUARD_START_MENU_H #define GUARD_START_MENU_H -extern bool8 (*gMenuCallback)(void); // Defined in sym_common.txt +extern bool8 (*gMenuCallback)(void); void sub_809FA18(void); void sub_809FA34(u8 taskId); diff --git a/include/string_util.h b/include/string_util.h index 7b685fceac..67149bca05 100644 --- a/include/string_util.h +++ b/include/string_util.h @@ -1,6 +1,11 @@ #ifndef GUARD_STRING_UTIL_H #define GUARD_STRING_UTIL_H +extern u8 gStringVar1[]; +extern u8 gStringVar2[]; +extern u8 gStringVar3[]; +extern u8 gStringVar4[]; + enum StringConvertMode { STR_CONV_MODE_LEFT_ALIGN, diff --git a/ld_script.txt b/ld_script.txt index f315d958f5..989c2d740f 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -173,7 +173,7 @@ SECTIONS { asm/dark.o(.text); asm/ground.o(.text); asm/normal.o(.text); - asm/battle_anim_utility_funcs.o(.text); + src/battle_anim_utility_funcs.o(.text); asm/battle_intro.o(.text); src/bike.o(.text); src/easy_chat.o(.text); @@ -188,6 +188,7 @@ SECTIONS { asm/cute_sketch.o(.text); src/decoration.o(.text); src/slot_machine.o(.text); + src/contest_painting.o(.text); asm/contest_painting.o(.text); src/battle_ai_script_commands.o(.text); src/trader.o(.text); @@ -268,7 +269,7 @@ SECTIONS { src/battle_arena.o(.text); src/battle_factory.o(.text); src/battle_pike.o(.text); - asm/mossdeep_gym.o(.text); + src/mossdeep_gym.o(.text); src/battle_pyramid.o(.text); src/item_menu.o(.text); src/list_menu.o(.text); @@ -283,7 +284,6 @@ SECTIONS { src/battle_controller_player_partner.o(.text); src/fldeff_groundshake.o(.text); src/fossil_specials.o(.text); - asm/fossil_specials.o(.text); src/berry_fix_program.o(.text); src/pokemon_summary_screen.o(.text); src/unk_pokedex_area_screen_helper.o(.text); diff --git a/src/apprentice.c b/src/apprentice.c index 07fb6f7fac..3b1c34104b 100644 --- a/src/apprentice.c +++ b/src/apprentice.c @@ -340,9 +340,10 @@ extern const u8 gText_082B7185[]; extern const u8 gText_082B71C1[]; extern const u8 gText_082B71F9[]; -extern struct Unk030062ECStruct *gUnknown_030062EC; -extern struct Unk030062F0Struct *gUnknown_030062F0; -extern void (*gUnknown_030062F4)(void); +// IWRAM common +struct Unk030062ECStruct *gUnknown_030062EC; +struct Unk030062F0Struct *gUnknown_030062F0; +void (*gUnknown_030062F4)(void); // This file's functions. static u16 sub_819FF98(u8 arg0); diff --git a/src/battle_anim.c b/src/battle_anim.c index 5c34d6a43c..e8720fcfbc 100644 --- a/src/battle_anim.c +++ b/src/battle_anim.c @@ -20,14 +20,6 @@ #define ANIM_SPRITE_INDEX_COUNT 8 -extern u16 gBattle_WIN0H; -extern u16 gBattle_WIN0V; -extern u16 gBattle_WIN1H; -extern u16 gBattle_WIN1V; -extern u16 gBattle_BG1_X; -extern u16 gBattle_BG1_Y; -extern u16 gBattle_BG2_X; -extern u16 gBattle_BG2_Y; extern struct MusicPlayerInfo gMPlayInfo_BGM; extern struct MusicPlayerInfo gMPlayInfo_SE1; extern struct MusicPlayerInfo gMPlayInfo_SE2; @@ -1502,7 +1494,7 @@ void LaunchBattleAnimation(const u8 *const animsTable[], u16 tableId, bool8 isMo else { for (i = 0; i < 4; i++) - gAnimBattlerSpecies[i] = gContestResources->field_18->unk0; + gAnimBattlerSpecies[i] = gContestResources->field_18->species; } if (!isMoveAnim) @@ -1959,7 +1951,7 @@ void sub_80A438C(u8 battlerId, bool8 toBG_2, bool8 setSpriteInvisible) battlerSpriteId = gBattlerSpriteIds[battlerId]; gBattle_BG1_X = -(gSprites[battlerSpriteId].pos1.x + gSprites[battlerSpriteId].pos2.x) + 0x20; - if (IsContest() && IsSpeciesNotUnown(gContestResources->field_18->unk0)) + if (IsContest() && IsSpeciesNotUnown(gContestResources->field_18->species)) gBattle_BG1_X--; gBattle_BG1_Y = -(gSprites[battlerSpriteId].pos1.y + gSprites[battlerSpriteId].pos2.y) + 0x20; @@ -2017,7 +2009,7 @@ static void sub_80A46A0(void) struct UnknownAnimStruct2 unknownStruct; u16 *ptr; - if (IsSpeciesNotUnown(gContestResources->field_18->unk0)) + if (IsSpeciesNotUnown(gContestResources->field_18->species)) { sub_80A6B30(&unknownStruct); ptr = unknownStruct.unk4; diff --git a/src/battle_anim_80A5C6C.c b/src/battle_anim_80A5C6C.c index d213e4831e..d8e422bb55 100644 --- a/src/battle_anim_80A5C6C.c +++ b/src/battle_anim_80A5C6C.c @@ -159,7 +159,7 @@ u8 GetBattlerSpriteCoord(u8 battlerId, u8 attributeId) if (shared19348.unk4_0) species = shared19348.unk2; else - species = shared19348.unk0; + species = shared19348.species; } else { @@ -324,7 +324,7 @@ u8 GetBattlerSpriteCoord2(u8 battlerId, u8 attributeId) if (shared19348.unk4_0) species = shared19348.unk2; else - species = shared19348.unk0; + species = shared19348.species; } else { @@ -940,18 +940,18 @@ void sub_80A6BFC(struct UnknownAnimStruct2 *unk) } } -void sub_80A6C68(u32 arg0) +void sub_80A6C68(u32 bgId) { struct UnknownAnimStruct2 unkStruct; - sub_80A6B90(&unkStruct, arg0); + sub_80A6B90(&unkStruct, bgId); CpuFill32(0, unkStruct.bgTiles, 0x2000); LoadBgTiles(unkStruct.bgId, unkStruct.bgTiles, 0x2000, unkStruct.tilesOffset); FillBgTilemapBufferRect(unkStruct.bgId, 0, 0, 0, 0x20, 0x40, 0x11); CopyBgTilemapBufferToVram(unkStruct.bgId); } -void sub_80A6CC0(u32 bgId, void *src, u32 tilesOffset) +void sub_80A6CC0(u32 bgId, const void *src, u32 tilesOffset) { CpuFill32(0, gUnknown_0202305C, 0x2000); LZDecompressWram(src, gUnknown_0202305C); @@ -1854,7 +1854,7 @@ u16 sub_80A7F18(u8 spriteId) { if (IsContest()) { - species = shared19348.unk0; + species = shared19348.species; return gMonBackPicCoords[species].y_offset; } else @@ -2112,7 +2112,7 @@ s16 sub_80A861C(u8 battlerId, u8 a2) } else { - species = shared19348.unk0; + species = shared19348.species; personality = shared19348.unk8; } if (species == SPECIES_UNOWN) diff --git a/src/battle_anim_80A9C70.c b/src/battle_anim_80A9C70.c index 5401247b86..f1245a0329 100644 --- a/src/battle_anim_80A9C70.c +++ b/src/battle_anim_80A9C70.c @@ -17,8 +17,6 @@ extern const u8 *const gBattleAnims_StatusConditions[]; extern const struct OamData gUnknown_08524904; extern const struct OamData gUnknown_08524A3C; -extern void sub_8116EB4(u8 taskId); - // This file's functions. static void sub_80A9DB4(u8 taskId); static void sub_80A9FD0(u8 taskId); diff --git a/src/battle_anim_sound_tasks.c b/src/battle_anim_sound_tasks.c index b49a6d03ff..07fb604b8c 100644 --- a/src/battle_anim_sound_tasks.c +++ b/src/battle_anim_sound_tasks.c @@ -131,7 +131,7 @@ void sub_8158D8C(u8 taskId) if (IsContest()) { if (gBattleAnimArgs[0] == ANIM_ATTACKER) - species = gContestResources->field_18->unk0; + species = gContestResources->field_18->species; else DestroyAnimVisualTask(taskId); // UB: function should return upon destroying task. } @@ -177,7 +177,7 @@ void sub_8158E9C(u8 taskId) if (IsContest()) { if (gBattleAnimArgs[0] == ANIM_ATTACKER) - species = gContestResources->field_18->unk0; + species = gContestResources->field_18->species; else DestroyAnimVisualTask(taskId); // UB: function should return upon destroying task. } @@ -281,7 +281,7 @@ void sub_81590B8(u8 taskId) pan = BattleAnimAdjustPanning(SOUND_PAN_ATTACKER); if (IsContest()) - species = gContestResources->field_18->unk0; + species = gContestResources->field_18->species; else species = gAnimBattlerSpecies[gBattleAnimAttacker]; diff --git a/src/battle_anim_utility_funcs.c b/src/battle_anim_utility_funcs.c index d9c574e73d..11cf46ab59 100644 --- a/src/battle_anim_utility_funcs.c +++ b/src/battle_anim_utility_funcs.c @@ -1,6 +1,42 @@ #include "global.h" #include "battle_anim.h" +#include "contest.h" +#include "gpu_regs.h" +#include "graphics.h" +#include "malloc.h" +#include "palette.h" +#include "sound.h" +#include "sprite.h" +#include "task.h" +#include "util.h" #include "constants/rgb.h" +#include "constants/songs.h" + +struct AnimStatsChangeData +{ + u8 battler1; + u8 battler2; + u8 higherPriority; + s16 data[8]; + u16 species; +}; + +static EWRAM_DATA struct AnimStatsChangeData *sAnimStatsChangeData = {0}; + +static void StartBlendAnimSpriteColor(u8, u32); +static void AnimTask_BlendSpriteColor_Step2(u8); +static void sub_81169A0(u8); +static void sub_81169F8(u8); +static void sub_8116AD0(struct Sprite*); +static void sub_8116D64(u8); +static void sub_8116F04(u8); +static void sub_81170EC(u8); +static void sub_81172EC(u8); +static void sub_8117500(u8); +static void sub_81175C4(u32, u16); +static void sub_81176D8(u8); +static void sub_8117A60(u8); +static void sub_8117FD0(u8); const u16 gUnknown_08597418 = RGB(31, 31, 31); @@ -8,3 +44,1017 @@ const u16 gUnknown_08597418 = RGB(31, 31, 31); // possibly some register offsets const u8 gUnknown_0859741A[] = {0x08, 0x0a, 0x0c, 0x0e}; const u8 gUnknown_0859741E[] = {0x08, 0x0a, 0x0c, 0x0e}; + +void sub_8116620(u8 taskId) +{ + u32 selectedPalettes = sub_811583C(gBattleAnimArgs[0]); + selectedPalettes |= sub_80A76C4((gBattleAnimArgs[0] >> 7) & 1, + (gBattleAnimArgs[0] >> 8) & 1, + (gBattleAnimArgs[0] >> 9) & 1, + (gBattleAnimArgs[0] >> 10) & 1); + StartBlendAnimSpriteColor(taskId, selectedPalettes); +} + +void sub_8116664(u8 taskId) +{ + u8 battler; + u32 selectedPalettes; + u8 animBattlers[2]; + + animBattlers[1] = 0xFF; + selectedPalettes = sub_811583C(1); + switch (gBattleAnimArgs[0]) + { + case 2: + selectedPalettes = 0; + // fall through + case 0: + animBattlers[0] = gBattleAnimAttacker; + break; + case 3: + selectedPalettes = 0; + // fall through + case 1: + animBattlers[0] = gBattleAnimTarget; + break; + case 4: + animBattlers[0] = gBattleAnimAttacker; + animBattlers[1] = gBattleAnimTarget; + break; + case 5: + animBattlers[0] = 0xFF; + break; + case 6: + selectedPalettes = 0; + animBattlers[0] = BATTLE_PARTNER(gBattleAnimAttacker); + break; + case 7: + selectedPalettes = 0; + animBattlers[0] = BATTLE_PARTNER(gBattleAnimTarget); + break; + } + + for (battler = 0; battler < MAX_BATTLERS_COUNT; battler++) + { + if (battler != animBattlers[0] && battler != animBattlers[1] && IsBattlerSpriteVisible(battler)) + selectedPalettes |= 0x10000 << sub_80A77AC(battler); + } + + StartBlendAnimSpriteColor(taskId, selectedPalettes); +} + +void AnimTask_SetCamouflageBlend(u8 taskId) +{ + u32 selectedPalettes = sub_811583C(gBattleAnimArgs[0]); + switch (gBattleTerrain) + { + case BATTLE_TERRAIN_GRASS: + gBattleAnimArgs[4] = RGB(12, 24, 2); + break; + case BATTLE_TERRAIN_LONG_GRASS: + gBattleAnimArgs[4] = RGB(0, 15, 2); + break; + case BATTLE_TERRAIN_SAND: + gBattleAnimArgs[4] = RGB(30, 24, 11); + break; + case BATTLE_TERRAIN_UNDERWATER: + gBattleAnimArgs[4] = RGB(0, 0, 18); + break; + case BATTLE_TERRAIN_WATER: + gBattleAnimArgs[4] = RGB(11, 22, 31); + break; + case BATTLE_TERRAIN_POND: + gBattleAnimArgs[4] = RGB(11, 22, 31); + break; + case BATTLE_TERRAIN_MOUNTAIN: + gBattleAnimArgs[4] = RGB(22, 16, 10); + break; + case BATTLE_TERRAIN_CAVE: + gBattleAnimArgs[4] = RGB(14, 9, 3); + break; + case BATTLE_TERRAIN_BUILDING: + gBattleAnimArgs[4] = RGB(31, 31, 31); + break; + case BATTLE_TERRAIN_PLAIN: + gBattleAnimArgs[4] = RGB(31, 31, 31); + break; + } + + StartBlendAnimSpriteColor(taskId, selectedPalettes); +} + +void AnimTask_BlendParticle(u8 taskId) +{ + u8 paletteIndex = IndexOfSpritePaletteTag(gBattleAnimArgs[0]); + u32 selectedPalettes = 1 << (paletteIndex + 16); + StartBlendAnimSpriteColor(taskId, selectedPalettes); +} + +void StartBlendAnimSpriteColor(u8 taskId, u32 selectedPalettes) +{ + gTasks[taskId].data[0] = selectedPalettes; + gTasks[taskId].data[1] = selectedPalettes >> 16; + gTasks[taskId].data[2] = gBattleAnimArgs[1]; + gTasks[taskId].data[3] = gBattleAnimArgs[2]; + gTasks[taskId].data[4] = gBattleAnimArgs[3]; + gTasks[taskId].data[5] = gBattleAnimArgs[4]; + gTasks[taskId].data[10] = gBattleAnimArgs[2]; + gTasks[taskId].func = AnimTask_BlendSpriteColor_Step2; + gTasks[taskId].func(taskId); +} + +static void AnimTask_BlendSpriteColor_Step2(u8 taskId) +{ + u32 selectedPalettes; + u16 singlePaletteMask = 0; + + if (gTasks[taskId].data[9] == gTasks[taskId].data[2]) + { + gTasks[taskId].data[9] = 0; + selectedPalettes = gTasks[taskId].data[0] | (gTasks[taskId].data[1] << 16); + while (selectedPalettes != 0) + { + if (selectedPalettes & 1) + BlendPalette(singlePaletteMask, 16, gTasks[taskId].data[10], gTasks[taskId].data[5]); + singlePaletteMask += 0x10; + selectedPalettes >>= 1; + } + + if (gTasks[taskId].data[10] < gTasks[taskId].data[4]) + gTasks[taskId].data[10]++; + else if (gTasks[taskId].data[10] > gTasks[taskId].data[4]) + gTasks[taskId].data[10]--; + else + DestroyAnimVisualTask(taskId); + } + else + { + gTasks[taskId].data[9]++; + } +} + +void sub_8116960(u8 taskId) +{ + BeginHardwarePaletteFade( + gBattleAnimArgs[0], + gBattleAnimArgs[1], + gBattleAnimArgs[2], + gBattleAnimArgs[3], + gBattleAnimArgs[4]); + + gTasks[taskId].func = sub_81169A0; +} + +static void sub_81169A0(u8 taskId) +{ + if (!gPaletteFade.active) + DestroyAnimVisualTask(taskId); +} + +void sub_81169C0(u8 taskId) +{ + struct Task *task = &gTasks[taskId]; + + task->data[0] = gBattleAnimArgs[0]; + task->data[1] = 0; + task->data[2] = gBattleAnimArgs[1]; + task->data[3] = gBattleAnimArgs[2]; + task->data[4] = gBattleAnimArgs[3]; + task->data[5] = 0; + task->func = sub_81169F8; +} + +static void sub_81169F8(u8 taskId) +{ + struct Task *task = &gTasks[taskId]; + + if (task->data[4]) + { + if (task->data[1]) + { + task->data[1]--; + } + else + { + task->data[6] = duplicate_obj_of_side_rel2move_in_transparent_mode(task->data[0]); + if (task->data[6] >= 0) + { + gSprites[task->data[6]].oam.priority = task->data[0] ? 1 : 2; + gSprites[task->data[6]].data[0] = task->data[3]; + gSprites[task->data[6]].data[1] = taskId; + gSprites[task->data[6]].data[2] = 5; + gSprites[task->data[6]].callback = sub_8116AD0; + task->data[5]++; + } + + task->data[4]--; + task->data[1] = task->data[2]; + } + } + else if (task->data[5] == 0) + { + DestroyAnimVisualTask(taskId); + } +} + +static void sub_8116AD0(struct Sprite *sprite) +{ + if (sprite->data[0]) + { + sprite->data[0]--; + } + else + { + gTasks[sprite->data[1]].data[sprite->data[2]]--; + obj_delete_but_dont_free_vram(sprite); + } +} + +void sub_8116B14(u8 taskId) +{ + u16 species; + int spriteId, newSpriteId; + u16 var0; + u16 bg1Cnt; + struct UnknownAnimStruct2 unknownStruct; + + var0 = 0; + gBattle_WIN0H = 0; + gBattle_WIN0V = 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_BG0 | WINOUT_WIN01_BG2 | WINOUT_WIN01_BG3 | WINOUT_WIN01_OBJ | WINOUT_WIN01_CLR + | WINOUT_WINOBJ_BG_ALL | WINOUT_WINOBJ_OBJ | WINOUT_WINOBJ_CLR); + SetGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_OBJWIN_ON); + SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_TGT1_BG1 | BLDCNT_TGT2_ALL | BLDCNT_EFFECT_BLEND); + SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(8, 12)); + bg1Cnt = GetGpuReg(REG_OFFSET_BG1CNT); + ((struct BgCnt *)&bg1Cnt)->priority = 0; + ((struct BgCnt *)&bg1Cnt)->screenSize = 0; + SetGpuReg(REG_OFFSET_BG1CNT, bg1Cnt); + + if (!IsContest()) + { + ((struct BgCnt *)&bg1Cnt)->charBaseBlock = 1; + SetGpuReg(REG_OFFSET_BG1CNT, bg1Cnt); + } + + if (IsDoubleBattle() && !IsContest()) + { + if (GetBattlerPosition(gBattleAnimAttacker) == B_POSITION_OPPONENT_RIGHT + || GetBattlerPosition(gBattleAnimAttacker) == B_POSITION_PLAYER_LEFT) + { + if (IsBattlerSpriteVisible(BATTLE_PARTNER(gBattleAnimAttacker)) == TRUE) + { + gSprites[gBattlerSpriteIds[BATTLE_PARTNER(gBattleAnimAttacker)]].oam.priority -= 1; + ((struct BgCnt *)&bg1Cnt)->priority = 1; + SetGpuReg(REG_OFFSET_BG1CNT, bg1Cnt); + var0 = 1; + } + } + } + + if (IsContest()) + { + species = gContestResources->field_18->species; + } + else + { + if (GetBattlerSide(gBattleAnimAttacker) != B_SIDE_PLAYER) + species = GetMonData(&gEnemyParty[gBattlerPartyIndexes[gBattleAnimAttacker]], MON_DATA_SPECIES); + else + species = GetMonData(&gPlayerParty[gBattlerPartyIndexes[gBattleAnimAttacker]], MON_DATA_SPECIES); + } + + spriteId = GetAnimBattlerSpriteId(0); + newSpriteId = sub_80A89C8(gBattleAnimAttacker, spriteId, species); + sub_80A6B30(&unknownStruct); + sub_80A6D60(&unknownStruct, gUnknown_08C20684, 0); + sub_80A6CC0(unknownStruct.bgId, gUnknown_08C20668, unknownStruct.tilesOffset); + LoadPalette(&gUnknown_08597418, unknownStruct.unk8 * 16 + 1, 2); + + gBattle_BG1_X = -gSprites[spriteId].pos1.x + 32; + gBattle_BG1_Y = -gSprites[spriteId].pos1.y + 32; + gTasks[taskId].data[0] = newSpriteId; + gTasks[taskId].data[6] = var0; + gTasks[taskId].func = sub_8116D64; +} + +static void sub_8116D64(u8 taskId) +{ + struct UnknownAnimStruct2 unknownStruct; + struct Sprite *sprite; + u16 bg1Cnt; + + gTasks[taskId].data[10] += 4; + gBattle_BG1_Y -= 4; + if (gTasks[taskId].data[10] == 64) + { + gTasks[taskId].data[10] = 0; + gBattle_BG1_Y += 64; + if (++gTasks[taskId].data[11] == 4) + { + sub_80A477C(0); + gBattle_WIN0H = 0; + gBattle_WIN0V = 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); + if (!IsContest()) + { + bg1Cnt = GetGpuReg(REG_OFFSET_BG1CNT); + ((struct BgCnt *)&bg1Cnt)->charBaseBlock = 0; + SetGpuReg(REG_OFFSET_BG1CNT, bg1Cnt); + } + + SetGpuReg(REG_OFFSET_DISPCNT, GetGpuReg(REG_OFFSET_DISPCNT) ^ DISPCNT_OBJWIN_ON); + SetGpuReg(REG_OFFSET_BLDCNT, 0); + SetGpuReg(REG_OFFSET_BLDALPHA, 0); + sprite = &gSprites[GetAnimBattlerSpriteId(0)]; // unused + sprite = &gSprites[gTasks[taskId].data[0]]; + DestroySprite(sprite); + + sub_80A6B30(&unknownStruct); + sub_80A6C68(unknownStruct.bgId); + if (gTasks[taskId].data[6] == 1) + gSprites[gBattlerSpriteIds[BATTLE_PARTNER(gBattleAnimAttacker)]].oam.priority++; + + gBattle_BG1_Y = 0; + DestroyAnimVisualTask(taskId); + } + } +} + +void sub_8116EB4(u8 taskId) +{ + u8 i; + + sAnimStatsChangeData = AllocZeroed(sizeof(struct AnimStatsChangeData)); + for (i = 0; i < 8; i++) + sAnimStatsChangeData->data[i] = gBattleAnimArgs[i]; + + gTasks[taskId].func = sub_8116F04; +} + +static void sub_8116F04(u8 taskId) +{ + if (sAnimStatsChangeData->data[2] == 0) + sAnimStatsChangeData->battler1 = gBattleAnimAttacker; + else + sAnimStatsChangeData->battler1 = gBattleAnimTarget; + + sAnimStatsChangeData->battler2 = BATTLE_PARTNER(sAnimStatsChangeData->battler1); + if (IsContest() || (sAnimStatsChangeData->data[3] && !IsBattlerSpriteVisible(sAnimStatsChangeData->battler2))) + sAnimStatsChangeData->data[3] = 0; + + gBattle_WIN0H = 0; + gBattle_WIN0V = 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_BG0 | WINOUT_WIN01_BG2 | WINOUT_WIN01_BG3 | WINOUT_WIN01_OBJ | WINOUT_WIN01_CLR + | WINOUT_WINOBJ_BG_ALL | WINOUT_WINOBJ_OBJ | WINOUT_WINOBJ_CLR); + SetGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_OBJWIN_ON); + SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_TGT1_BG1 | BLDCNT_TGT2_ALL | BLDCNT_EFFECT_BLEND); + SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(0, 16)); + SetAnimBgAttribute(1, BG_ANIM_PRIORITY, 0); + SetAnimBgAttribute(1, BG_ANIM_SCREEN_SIZE, 0); + if (!IsContest()) + SetAnimBgAttribute(1, BG_ANIM_CHAR_BASE_BLOCK, 1); + + if (IsDoubleBattle() && sAnimStatsChangeData->data[3] == 0) + { + if (GetBattlerPosition(sAnimStatsChangeData->battler1) == B_POSITION_OPPONENT_RIGHT + || GetBattlerPosition(sAnimStatsChangeData->battler1) == B_POSITION_PLAYER_LEFT) + { + if (IsBattlerSpriteVisible(sAnimStatsChangeData->battler2) == TRUE) + { + gSprites[gBattlerSpriteIds[sAnimStatsChangeData->battler2]].oam.priority -= 1; + SetAnimBgAttribute(1, BG_ANIM_PRIORITY, 1); + sAnimStatsChangeData->higherPriority = 1; + } + } + } + + if (IsContest()) + { + sAnimStatsChangeData->species = gContestResources->field_18->species; + } + else + { + if (GetBattlerSide(sAnimStatsChangeData->battler1) != B_SIDE_PLAYER) + sAnimStatsChangeData->species = GetMonData(&gEnemyParty[gBattlerPartyIndexes[sAnimStatsChangeData->battler1]], MON_DATA_SPECIES); + else + sAnimStatsChangeData->species = GetMonData(&gPlayerParty[gBattlerPartyIndexes[sAnimStatsChangeData->battler1]], MON_DATA_SPECIES); + } + + gTasks[taskId].func = sub_81170EC; +} + +static void sub_81170EC(u8 taskId) +{ + struct UnknownAnimStruct2 unknownStruct; + u8 spriteId, spriteId2; + u8 battlerSpriteId; + + spriteId2 = 0; + battlerSpriteId = gBattlerSpriteIds[sAnimStatsChangeData->battler1]; + spriteId = sub_80A89C8(sAnimStatsChangeData->battler1, battlerSpriteId, sAnimStatsChangeData->species); + if (sAnimStatsChangeData->data[3]) + { + battlerSpriteId = gBattlerSpriteIds[sAnimStatsChangeData->battler2]; + spriteId2 = sub_80A89C8(sAnimStatsChangeData->battler2, battlerSpriteId, sAnimStatsChangeData->species); + } + + sub_80A6B30(&unknownStruct); + if (sAnimStatsChangeData->data[0] == 0) + sub_80A6D60(&unknownStruct, gBattleStatMask1_Tilemap, 0); + else + sub_80A6D60(&unknownStruct, gBattleStatMask2_Tilemap, 0); + + sub_80A6CC0(unknownStruct.bgId, gBattleStatMask_Gfx, unknownStruct.tilesOffset); + switch (sAnimStatsChangeData->data[1]) + { + case 0: + LoadCompressedPalette(gBattleStatMask2_Pal, unknownStruct.unk8 << 4, 32); + break; + case 1: + LoadCompressedPalette(gBattleStatMask1_Pal, unknownStruct.unk8 << 4, 32); + break; + case 2: + LoadCompressedPalette(gBattleStatMask3_Pal, unknownStruct.unk8 << 4, 32); + break; + case 3: + LoadCompressedPalette(gBattleStatMask4_Pal, unknownStruct.unk8 << 4, 32); + break; + case 4: + LoadCompressedPalette(gBattleStatMask6_Pal, unknownStruct.unk8 << 4, 32); + break; + case 5: + LoadCompressedPalette(gBattleStatMask7_Pal, unknownStruct.unk8 << 4, 32); + break; + case 6: + LoadCompressedPalette(gBattleStatMask8_Pal, unknownStruct.unk8 << 4, 32); + break; + default: + LoadCompressedPalette(gBattleStatMask5_Pal, unknownStruct.unk8 << 4, 32); + break; + } + + gBattle_BG1_X = 0; + gBattle_BG1_Y = 0; + + if (sAnimStatsChangeData->data[0] == 1) + { + gBattle_BG1_X = 64; + gTasks[taskId].data[1] = -3; + } + else + { + gTasks[taskId].data[1] = 3; + } + + if (sAnimStatsChangeData->data[4] == 0) + { + gTasks[taskId].data[4] = 10; + gTasks[taskId].data[5] = 20; + } + else + { + gTasks[taskId].data[4] = 13; + gTasks[taskId].data[5] = 30; + } + + gTasks[taskId].data[0] = spriteId; + gTasks[taskId].data[2] = sAnimStatsChangeData->data[3]; + gTasks[taskId].data[3] = spriteId2; + gTasks[taskId].data[6] = sAnimStatsChangeData->higherPriority; + gTasks[taskId].data[7] = gBattlerSpriteIds[sAnimStatsChangeData->battler2]; + gTasks[taskId].func = sub_81172EC; + + if (sAnimStatsChangeData->data[0] == 0) + PlaySE12WithPanning(SE_W287, BattleAnimAdjustPanning2(-64)); + else + PlaySE12WithPanning(SE_W287B, BattleAnimAdjustPanning2(-64)); +} + +static void sub_81172EC(u8 taskId) +{ + gBattle_BG1_Y += gTasks[taskId].data[1]; + + switch (gTasks[taskId].data[15]) + { + case 0: + if (gTasks[taskId].data[11]++ > 0) + { + gTasks[taskId].data[11] = 0; + gTasks[taskId].data[12]++; + SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(gTasks[taskId].data[12], 16 - gTasks[taskId].data[12])); + if (gTasks[taskId].data[12] == gTasks[taskId].data[4]) + gTasks[taskId].data[15]++; + } + break; + case 1: + if (++gTasks[taskId].data[10] == gTasks[taskId].data[5]) + gTasks[taskId].data[15]++; + break; + case 2: + if (gTasks[taskId].data[11]++ > 0) + { + gTasks[taskId].data[11] = 0; + gTasks[taskId].data[12]--; + SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(gTasks[taskId].data[12], 16 - gTasks[taskId].data[12])); + if (gTasks[taskId].data[12] == 0) + { + sub_80A477C(0); + gTasks[taskId].data[15]++;; + } + } + break; + case 3: + gBattle_WIN0H = 0; + gBattle_WIN0V = 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); + + if (!IsContest()) + SetAnimBgAttribute(1, BG_ANIM_CHAR_BASE_BLOCK, 0); + + SetGpuReg(REG_OFFSET_DISPCNT, GetGpuReg(REG_OFFSET_DISPCNT) ^ DISPCNT_OBJWIN_ON); + SetGpuReg(REG_OFFSET_BLDCNT, 0); + SetGpuReg(REG_OFFSET_BLDALPHA, 0); + DestroySprite(&gSprites[gTasks[taskId].data[0]]); + if (gTasks[taskId].data[2]) + DestroySprite(&gSprites[gTasks[taskId].data[3]]); + + if (gTasks[taskId].data[6] == 1) + gSprites[gTasks[taskId].data[7]].oam.priority++; + + Free(sAnimStatsChangeData); + sAnimStatsChangeData = NULL; + DestroyAnimVisualTask(taskId); + break; + } +} + +void sub_8117494(u8 taskId) +{ + u32 selectedPalettes = sub_80A76C4(1, 1, 1, 1); + sub_81175C4(selectedPalettes, 0); + gTasks[taskId].data[14] = selectedPalettes >> 16; + + selectedPalettes = sub_80A75AC(1, 0, 0, 0, 0, 0, 0) & 0xFFFF; + sub_81175C4(selectedPalettes, 0xFFFF); + gTasks[taskId].data[15] = selectedPalettes; + + gTasks[taskId].data[0] = 0; + gTasks[taskId].data[1] = 0; + gTasks[taskId].func = sub_8117500; +} + +static void sub_8117500(u8 taskId) +{ + u16 i; + struct Task *task = &gTasks[taskId]; + + switch (task->data[0]) + { + case 0: + if (++task->data[1] > 6) + { + task->data[1] = 0; + task->data[2] = 16; + task->data[0]++; + } + break; + case 1: + if (++task->data[1] > 1) + { + task->data[1] = 0; + task->data[2]--; + + for (i = 0; i < 16; i++) + { + if ((task->data[15] >> i) & 1) + { + u16 paletteOffset = i * 16; + BlendPalette(paletteOffset, 16, task->data[2], 0xFFFF); + } + + if ((task->data[14] >> i) & 1) + { + u16 paletteOffset = i * 16 + 0x100; + BlendPalette(paletteOffset, 16, task->data[2], 0); + } + } + + if (task->data[2] == 0) + task->data[0]++; + } + break; + case 2: + DestroyAnimVisualTask(taskId); + break; + } +} + +static void sub_81175C4(u32 selectedPalettes, u16 color) +{ + u16 i; + + for (i = 0; i < 32; i++) + { + if (selectedPalettes & 1) + { + u16 curOffset = i * 16; + u16 paletteOffset = curOffset; + while (curOffset < paletteOffset + 16) + { + gPlttBufferFaded[curOffset] = color; + curOffset++; + } + } + + selectedPalettes >>= 1; + } +} + +void sub_8117610(u8 taskId) +{ + u32 battler; + int j; + u32 selectedPalettes = 0; + + for (battler = 0; battler < MAX_BATTLERS_COUNT; battler++) + { + if (gBattleAnimAttacker != battler) + selectedPalettes |= 1 << (battler + 16); + } + + for (j = 5; j != 0; j--) + gBattleAnimArgs[j] = gBattleAnimArgs[j - 1]; + + StartBlendAnimSpriteColor(taskId, selectedPalettes); +} + +void sub_8117660(u8 taskId) +{ + u8 newTaskId; + + sub_80A6DAC(0); + newTaskId = CreateTask(sub_81176D8, 5); + if (gBattleAnimArgs[2] && GetBattlerSide(gBattleAnimAttacker) != B_SIDE_PLAYER) + { + gBattleAnimArgs[0] = -gBattleAnimArgs[0]; + gBattleAnimArgs[1] = -gBattleAnimArgs[1]; + } + + gTasks[newTaskId].data[1] = gBattleAnimArgs[0]; + gTasks[newTaskId].data[2] = gBattleAnimArgs[1]; + gTasks[newTaskId].data[3] = gBattleAnimArgs[3]; + gTasks[newTaskId].data[0]++; + DestroyAnimVisualTask(taskId); +} + +static void sub_81176D8(u8 taskId) +{ + gTasks[taskId].data[10] += gTasks[taskId].data[1]; + gTasks[taskId].data[11] += gTasks[taskId].data[2]; + gBattle_BG3_X += gTasks[taskId].data[10] >> 8; + gBattle_BG3_Y += gTasks[taskId].data[11] >> 8; + gTasks[taskId].data[10] &= 0xFF; + gTasks[taskId].data[11] &= 0xFF; + + if (gBattleAnimArgs[7] == gTasks[taskId].data[3]) + { + gBattle_BG3_X = 0; + gBattle_BG3_Y = 0; + sub_80A6DAC(1); + DestroyTask(taskId); + } +} + +void AnimTask_GetAttackerSide(u8 taskId) +{ + gBattleAnimArgs[7] = GetBattlerSide(gBattleAnimAttacker); + DestroyAnimVisualTask(taskId); +} + +void AnimTask_GetTargetSide(u8 taskId) +{ + gBattleAnimArgs[7] = GetBattlerSide(gBattleAnimTarget); + DestroyAnimVisualTask(taskId); +} + +void AnimTask_GetTargetIsAttackerPartner(u8 taskId) +{ + gBattleAnimArgs[7] = BATTLE_PARTNER(gBattleAnimAttacker) == gBattleAnimTarget; + DestroyAnimVisualTask(taskId); +} + +void sub_81177E4(u8 taskId) +{ + u16 battler; + + for (battler = 0; battler < MAX_BATTLERS_COUNT; battler++) + { + if (battler != gBattleAnimAttacker && IsBattlerSpriteVisible(battler)) + gSprites[gBattlerSpriteIds[battler]].invisible = gBattleAnimArgs[0]; + } + + DestroyAnimVisualTask(taskId); +} + +void sub_8117854(u8 taskId, int unused, u16 arg2, u8 battler1, u8 arg4, u8 arg5, u8 arg6, u8 arg7, const u8 *arg8, const u8 *arg9, const u16 *palette) +{ + u16 species; + u8 spriteId, spriteId2; + u16 bg1Cnt; + struct UnknownAnimStruct2 unknownStruct; + u8 battler2; + + spriteId2 = 0; + battler2 = BATTLE_PARTNER(battler1); + + if (IsContest() || (arg4 && !IsBattlerSpriteVisible(battler2))) + arg4 = 0; + + gBattle_WIN0H = 0; + gBattle_WIN0V = 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_BG0 | WINOUT_WIN01_BG2 | WINOUT_WIN01_BG3 | WINOUT_WIN01_OBJ | WINOUT_WIN01_CLR + | WINOUT_WINOBJ_BG_ALL | WINOUT_WINOBJ_OBJ | WINOUT_WINOBJ_CLR); + SetGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_OBJWIN_ON); + SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_TGT1_BG1 | BLDCNT_TGT2_ALL | BLDCNT_EFFECT_BLEND); + SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(0, 16)); + bg1Cnt = GetGpuReg(REG_OFFSET_BG1CNT); + ((vBgCnt *)&bg1Cnt)->priority = 0; + ((vBgCnt *)&bg1Cnt)->screenSize = 0; + ((vBgCnt *)&bg1Cnt)->areaOverflowMode = 1; + if (!IsContest()) + { + ((vBgCnt *)&bg1Cnt)->charBaseBlock = 1; + } + + SetGpuReg(REG_OFFSET_BG1CNT, bg1Cnt); + + if (IsContest()) + { + species = gContestResources->field_18->species; + } + else + { + if (GetBattlerSide(battler1) != B_SIDE_PLAYER) + species = GetMonData(&gEnemyParty[gBattlerPartyIndexes[battler1]], MON_DATA_SPECIES); + else + species = GetMonData(&gPlayerParty[gBattlerPartyIndexes[battler1]], MON_DATA_SPECIES); + } + + spriteId = sub_80A89C8(battler1, gBattlerSpriteIds[battler1], species); + if (arg4) + spriteId2 = sub_80A89C8(battler2, gBattlerSpriteIds[battler2], species); + + sub_80A6B30(&unknownStruct); + sub_80A6D60(&unknownStruct, arg9, 0); + sub_80A6CC0(unknownStruct.bgId, arg8, unknownStruct.tilesOffset); + LoadCompressedPalette(palette, unknownStruct.unk8 << 4, 32); + + gBattle_BG1_X = 0; + gBattle_BG1_Y = 0; + gTasks[taskId].data[1] = arg2; + gTasks[taskId].data[4] = arg5; + gTasks[taskId].data[5] = arg7; + gTasks[taskId].data[6] = arg6; + gTasks[taskId].data[0] = spriteId; + gTasks[taskId].data[2] = arg4; + gTasks[taskId].data[3] = spriteId2; + gTasks[taskId].func = sub_8117A60; +} + +static void sub_8117A60(u8 taskId) +{ + gTasks[taskId].data[13] += gTasks[taskId].data[1] < 0 ? -gTasks[taskId].data[1] : gTasks[taskId].data[1]; + if (gTasks[taskId].data[1] < 0) + gBattle_BG1_Y -= gTasks[taskId].data[13] >> 8; + else + gBattle_BG1_Y += gTasks[taskId].data[13] >> 8; + + gTasks[taskId].data[13] &= 0xFF; + switch (gTasks[taskId].data[15]) + { + case 0: + if (gTasks[taskId].data[11]++ >= gTasks[taskId].data[6]) + { + gTasks[taskId].data[11] = 0; + gTasks[taskId].data[12]++; + SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(gTasks[taskId].data[12], 16 - gTasks[taskId].data[12])); + if (gTasks[taskId].data[12] == gTasks[taskId].data[4]) + gTasks[taskId].data[15]++; + } + break; + case 1: + if (++gTasks[taskId].data[10] == gTasks[taskId].data[5]) + gTasks[taskId].data[15]++; + break; + case 2: + if (gTasks[taskId].data[11]++ >= gTasks[taskId].data[6]) + { + gTasks[taskId].data[11] = 0; + gTasks[taskId].data[12]--; + SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(gTasks[taskId].data[12], 16 - gTasks[taskId].data[12])); + if (gTasks[taskId].data[12] == 0) + { + sub_80A477C(0); + gBattle_WIN0H = 0; + gBattle_WIN0V = 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); + if (!IsContest()) + { + u16 bg1Cnt = GetGpuReg(REG_OFFSET_BG1CNT); + ((vBgCnt *)&bg1Cnt)->charBaseBlock = 0; + SetGpuReg(REG_OFFSET_BG1CNT, bg1Cnt); + } + + SetGpuReg(REG_OFFSET_DISPCNT, GetGpuReg(REG_OFFSET_DISPCNT) ^ DISPCNT_OBJWIN_ON); + SetGpuReg(REG_OFFSET_BLDCNT, 0); + SetGpuReg(REG_OFFSET_BLDALPHA, 0); + DestroySprite(&gSprites[gTasks[taskId].data[0]]); + if (gTasks[taskId].data[2]) + DestroySprite(&gSprites[gTasks[taskId].data[3]]); + + DestroyAnimVisualTask(taskId); + } + } + break; + } +} + +void AnimTask_GetBattleTerrain(u8 taskId) +{ + gBattleAnimArgs[0] = gBattleTerrain; + DestroyAnimVisualTask(taskId); +} + +void sub_8117C44(u8 taskId) +{ + gMonSpritesGfxPtr->field_17C = AllocZeroed(0x2000); + DestroyAnimVisualTask(taskId); +} + +void sub_8117C70(u8 taskId) +{ + Free(gMonSpritesGfxPtr->field_17C); + gMonSpritesGfxPtr->field_17C = NULL; + DestroyAnimVisualTask(taskId); +} + +void sub_8117CA0(u8 taskId) +{ + u32 selectedPalettes; + int paletteIndex = 0; + + if (gBattleAnimArgs[0] == 0) + { + selectedPalettes = sub_80A75AC(1, 0, 0, 0, 0, 0, 0); + while ((selectedPalettes & 1) == 0) + { + selectedPalettes >>= 1; + paletteIndex++; + } + } + else if (gBattleAnimArgs[0] == 1) + { + paletteIndex = gBattleAnimAttacker + 16; + } + else if (gBattleAnimArgs[0] == 2) + { + paletteIndex = gBattleAnimTarget + 16; + } + + memcpy(&gMonSpritesGfxPtr->field_17C[gBattleAnimArgs[1] * 16], &gPlttBufferUnfaded[paletteIndex * 16], 32); + DestroyAnimVisualTask(taskId); +} + +void sub_8117D3C(u8 taskId) +{ + u32 selectedPalettes; + int paletteIndex = 0; + + if (gBattleAnimArgs[0] == 0) + { + selectedPalettes = sub_80A75AC(1, 0, 0, 0, 0, 0, 0); + while ((selectedPalettes & 1) == 0) + { + selectedPalettes >>= 1; + paletteIndex++; + } + } + else if (gBattleAnimArgs[0] == 1) + { + paletteIndex = gBattleAnimAttacker + 16; + } + else if (gBattleAnimArgs[0] == 2) + { + paletteIndex = gBattleAnimTarget + 16; + } + + memcpy(&gPlttBufferUnfaded[paletteIndex * 16], &gMonSpritesGfxPtr->field_17C[gBattleAnimArgs[1] * 16], 32); + DestroyAnimVisualTask(taskId); +} + +void sub_8117DD8(u8 taskId) +{ + u32 selectedPalettes; + int paletteIndex = 0; + + if (gBattleAnimArgs[0] == 0) + { + selectedPalettes = sub_80A75AC(1, 0, 0, 0, 0, 0, 0); + while ((selectedPalettes & 1) == 0) + { + selectedPalettes >>= 1; + paletteIndex++; + } + } + else if (gBattleAnimArgs[0] == 1) + { + paletteIndex = gBattleAnimAttacker + 16; + } + else if (gBattleAnimArgs[0] == 2) + { + paletteIndex = gBattleAnimTarget + 16; + } + + memcpy(&gPlttBufferUnfaded[paletteIndex * 16], &gPlttBufferFaded[paletteIndex * 16], 32); + DestroyAnimVisualTask(taskId); +} + +void AnimTask_IsContest(u8 taskId) +{ + if (IsContest()) + gBattleAnimArgs[7] = 1; + else + gBattleAnimArgs[7] = 0; + + DestroyAnimVisualTask(taskId); +} + +void sub_8117E94(u8 taskId) +{ + gBattleAnimAttacker = gBattlerTarget; + gBattleAnimTarget = gEffectBattler; + DestroyAnimVisualTask(taskId); +} + +void AnimTask_IsTargetSameSide(u8 taskId) +{ + if (GetBattlerSide(gBattleAnimAttacker) == GetBattlerSide(gBattleAnimTarget)) + gBattleAnimArgs[7] = 1; + else + gBattleAnimArgs[7] = 0; + + DestroyAnimVisualTask(taskId); +} + +void sub_8117F10(u8 taskId) +{ + gBattleAnimTarget = gBattlerTarget; + DestroyAnimVisualTask(taskId); +} + +void sub_8117F30(u8 taskId) +{ + gBattleAnimAttacker = gBattlerAttacker; + gBattleAnimTarget = gEffectBattler; + DestroyAnimVisualTask(taskId); +} + +void sub_8117F60(u8 taskId) +{ + if (IsContest()) + { + DestroyAnimVisualTask(taskId); + } + else + { + gTasks[taskId].data[0] = gBattleSpritesDataPtr->battlerData[gBattleAnimAttacker].invisible; + gBattleSpritesDataPtr->battlerData[gBattleAnimAttacker].invisible = 1; + gTasks[taskId].func = sub_8117FD0; + gAnimVisualTaskCount--; + } +} + +static void sub_8117FD0(u8 taskId) +{ + if (gBattleAnimArgs[7] == 0x1000) + { + gBattleSpritesDataPtr->battlerData[gBattleAnimAttacker].invisible = (u8)gTasks[taskId].data[0] & 1; + DestroyTask(taskId); + } +} diff --git a/src/battle_arena.c b/src/battle_arena.c index 4b47dcaf14..c686ed7919 100644 --- a/src/battle_arena.c +++ b/src/battle_arena.c @@ -22,9 +22,6 @@ #include "constants/battle_frontier.h" #include "constants/moves.h" -extern u16 gBattle_WIN0H; -extern u16 gBattle_WIN0V; - extern const u32 gUnknown_08D854E8[]; extern const u16 gUnknown_08D855E8[]; diff --git a/src/battle_bg.c b/src/battle_bg.c index bbe50cc70e..51138040ce 100644 --- a/src/battle_bg.c +++ b/src/battle_bg.c @@ -31,11 +31,6 @@ struct BattleBackground const void *palette; }; -extern u16 gBattle_BG1_X; -extern u16 gBattle_BG1_Y; -extern u16 gBattle_BG2_X; -extern u16 gBattle_BG2_Y; - extern u8 GetCurrentMapBattleScene(void); // .rodata diff --git a/src/battle_controller_link_opponent.c b/src/battle_controller_link_opponent.c index 6ff9a2b21b..ab8c0c4c6c 100644 --- a/src/battle_controller_link_opponent.c +++ b/src/battle_controller_link_opponent.c @@ -26,8 +26,6 @@ #include "constants/songs.h" #include "constants/trainers.h" -extern u16 gBattle_BG0_X; -extern u16 gBattle_BG0_Y; extern struct MusicPlayerInfo gMPlayInfo_BGM; extern struct UnusedControllerStruct gUnknown_02022D0C; diff --git a/src/battle_controller_link_partner.c b/src/battle_controller_link_partner.c index 337595a483..ed8acfa8a0 100644 --- a/src/battle_controller_link_partner.c +++ b/src/battle_controller_link_partner.c @@ -26,8 +26,6 @@ #include "constants/songs.h" #include "constants/trainers.h" -extern u16 gBattle_BG0_X; -extern u16 gBattle_BG0_Y; extern struct UnusedControllerStruct gUnknown_02022D0C; extern const struct CompressedSpritePalette gTrainerFrontPicPaletteTable[]; diff --git a/src/battle_controller_opponent.c b/src/battle_controller_opponent.c index 478e0a889f..72c9ae078a 100644 --- a/src/battle_controller_opponent.c +++ b/src/battle_controller_opponent.c @@ -33,8 +33,6 @@ #include "constants/songs.h" #include "constants/trainers.h" -extern u16 gBattle_BG0_X; -extern u16 gBattle_BG0_Y; extern struct MusicPlayerInfo gMPlayInfo_BGM; extern struct UnusedControllerStruct gUnknown_02022D0C; diff --git a/src/battle_controller_player.c b/src/battle_controller_player.c index 6ef088977b..5da609b15f 100644 --- a/src/battle_controller_player.c +++ b/src/battle_controller_player.c @@ -37,8 +37,6 @@ extern u8 gUnknown_0203CEE8; extern u8 gUnknown_0203CEE9; extern u8 gUnknown_0203CF00[]; -extern u16 gBattle_BG0_X; -extern u16 gBattle_BG0_Y; extern struct UnusedControllerStruct gUnknown_02022D0C; extern struct MusicPlayerInfo gMPlayInfo_BGM; diff --git a/src/battle_controller_player_partner.c b/src/battle_controller_player_partner.c index e8269cd22b..65e6c2dd8e 100644 --- a/src/battle_controller_player_partner.c +++ b/src/battle_controller_player_partner.c @@ -26,8 +26,6 @@ #include "constants/songs.h" #include "constants/trainers.h" -extern u16 gBattle_BG0_X; -extern u16 gBattle_BG0_Y; extern struct UnusedControllerStruct gUnknown_02022D0C; extern const struct CompressedSpritePalette gTrainerFrontPicPaletteTable[]; diff --git a/src/battle_controller_recorded_opponent.c b/src/battle_controller_recorded_opponent.c index 7ed6f1ce9c..8ce83ae82e 100644 --- a/src/battle_controller_recorded_opponent.c +++ b/src/battle_controller_recorded_opponent.c @@ -28,8 +28,6 @@ #include "constants/songs.h" #include "constants/trainers.h" -extern u16 gBattle_BG0_X; -extern u16 gBattle_BG0_Y; extern struct MusicPlayerInfo gMPlayInfo_BGM; extern struct UnusedControllerStruct gUnknown_02022D0C; extern u8 gUnknown_0203C7B4; diff --git a/src/battle_controller_recorded_player.c b/src/battle_controller_recorded_player.c index 108542269b..cbb46a9405 100644 --- a/src/battle_controller_recorded_player.c +++ b/src/battle_controller_recorded_player.c @@ -25,8 +25,6 @@ #include "constants/battle_anim.h" #include "constants/songs.h" -extern u16 gBattle_BG0_X; -extern u16 gBattle_BG0_Y; extern u32 gTransformedPersonalities[MAX_BATTLERS_COUNT]; extern u8 gUnknown_0203C7B4; extern struct MusicPlayerInfo gMPlayInfo_BGM; diff --git a/src/battle_controller_safari.c b/src/battle_controller_safari.c index 2465008d9a..20c51ea428 100644 --- a/src/battle_controller_safari.c +++ b/src/battle_controller_safari.c @@ -23,9 +23,6 @@ #include "constants/battle_anim.h" #include "constants/songs.h" -extern u16 gBattle_BG0_X; -extern u16 gBattle_BG0_Y; - extern const struct CompressedSpritePalette gTrainerBackPicPaletteTable[]; extern void sub_81358F4(void); diff --git a/src/battle_controller_wally.c b/src/battle_controller_wally.c index c0d4d7d7b4..4208b7fc6f 100644 --- a/src/battle_controller_wally.c +++ b/src/battle_controller_wally.c @@ -31,8 +31,6 @@ #include "constants/songs.h" #include "constants/trainers.h" -extern u16 gBattle_BG0_X; -extern u16 gBattle_BG0_Y; extern s32 gUnknown_0203CD70; extern struct UnusedControllerStruct gUnknown_02022D0C; diff --git a/src/battle_dome.c b/src/battle_dome.c index 7c5915689d..bb1ed02854 100644 --- a/src/battle_dome.c +++ b/src/battle_dome.c @@ -66,14 +66,6 @@ extern u16 GetFrontierBrainMonSpecies(u8); extern void ReducePlayerPartyToThree(void); extern u8 gUnknown_0203CEF8[]; -extern u16 gBattle_BG0_X; -extern u16 gBattle_BG0_Y; -extern u16 gBattle_BG1_X; -extern u16 gBattle_BG1_Y; -extern u16 gBattle_BG2_X; -extern u16 gBattle_BG2_Y; -extern u16 gBattle_BG3_X; -extern u16 gBattle_BG3_Y; extern const u16 gBattleFrontierHeldItems[]; extern const struct FacilityMon gBattleFrontierMons[]; diff --git a/src/battle_factory.c b/src/battle_factory.c index 37abf6addc..1d7fbafc94 100644 --- a/src/battle_factory.c +++ b/src/battle_factory.c @@ -13,8 +13,6 @@ #include "constants/trainers.h" #include "constants/moves.h" -extern u16 gUnknown_03006298[]; - extern const struct FacilityMon gBattleFrontierMons[]; extern const struct FacilityMon gSlateportBattleTentMons[]; extern const struct BattleFrontierTrainer gBattleFrontierTrainers[]; diff --git a/src/battle_factory_screen.c b/src/battle_factory_screen.c index 255cf5aa1c..42a9b579cb 100644 --- a/src/battle_factory_screen.c +++ b/src/battle_factory_screen.c @@ -131,7 +131,6 @@ struct FactorySwapMonsStruct bool8 unk30; }; -extern u8 (*gUnknown_030062E8)(void); extern u8 gUnknown_0203CF20; extern const u16 gBattleFrontierHeldItems[]; @@ -237,6 +236,9 @@ static IWRAM_DATA struct FactorySelectMonsStruct *sFactorySelectScreen; static IWRAM_DATA void (*sSwap_CurrentTableFunc)(u8 taskId); static IWRAM_DATA struct FactorySwapMonsStruct *sFactorySwapScreen; +// IWRAM common +u8 (*gUnknown_030062E8)(void); + // Const rom data. static const u16 gUnknown_0860F13C[] = INCBIN_U16("graphics/unknown/unknown_60F13C.gbapal"); static const u16 gUnknown_0860F15C[] = INCBIN_U16("graphics/unknown/unknown_60F15C.gbapal"); diff --git a/src/battle_main.c b/src/battle_main.c index 29f32d0199..e2101a9c4c 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -70,18 +70,6 @@ struct UnknownPokemonStruct4 /*0x1D*/ u8 language; }; -extern u16 gBattle_BG0_X; -extern u16 gBattle_BG0_Y; -extern u16 gBattle_BG1_X; -extern u16 gBattle_BG1_Y; -extern u16 gBattle_BG2_X; -extern u16 gBattle_BG2_Y; -extern u16 gBattle_BG3_X; -extern u16 gBattle_BG3_Y; -extern u16 gBattle_WIN0H; -extern u16 gBattle_WIN0V; -extern u16 gBattle_WIN1H; -extern u16 gBattle_WIN1V; extern struct MusicPlayerInfo gMPlayInfo_SE1; extern struct MusicPlayerInfo gMPlayInfo_SE2; extern u8 gUnknown_0203CF00[]; @@ -187,6 +175,18 @@ static void HandleAction_NothingIsFainted(void); static void HandleAction_ActionFinished(void); // EWRAM vars +EWRAM_DATA u16 gBattle_BG0_X = 0; +EWRAM_DATA u16 gBattle_BG0_Y = 0; +EWRAM_DATA u16 gBattle_BG1_X = 0; +EWRAM_DATA u16 gBattle_BG1_Y = 0; +EWRAM_DATA u16 gBattle_BG2_X = 0; +EWRAM_DATA u16 gBattle_BG2_Y = 0; +EWRAM_DATA u16 gBattle_BG3_X = 0; +EWRAM_DATA u16 gBattle_BG3_Y = 0; +EWRAM_DATA u16 gBattle_WIN0H = 0; +EWRAM_DATA u16 gBattle_WIN0V = 0; +EWRAM_DATA u16 gBattle_WIN1H = 0; +EWRAM_DATA u16 gBattle_WIN1V = 0; EWRAM_DATA u8 gDisplayedStringBattle[300] = {0}; EWRAM_DATA u8 gBattleTextBuff1[TEXT_BUFF_ARRAY_COUNT] = {0}; EWRAM_DATA u8 gBattleTextBuff2[TEXT_BUFF_ARRAY_COUNT] = {0}; diff --git a/src/battle_palace.c b/src/battle_palace.c index d435f7e155..4033712b62 100644 --- a/src/battle_palace.c +++ b/src/battle_palace.c @@ -6,6 +6,7 @@ #include "battle_tower.h" #include "frontier_util.h" #include "item.h" +#include "string_util.h" #include "constants/items.h" // This file's functions. diff --git a/src/battle_pyramid.c b/src/battle_pyramid.c index 878ea4e706..01f1389252 100644 --- a/src/battle_pyramid.c +++ b/src/battle_pyramid.c @@ -15,6 +15,7 @@ #include "sound.h" #include "task.h" #include "start_menu.h" +#include "string_util.h" #include "trainer_see.h" #include "main.h" #include "load_save.h" diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index f5a23089b0..f793dad2e8 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -48,11 +48,6 @@ #include "battle_pike.h" #include "battle_pyramid.h" -extern u16 gBattle_BG1_X; -extern u16 gBattle_BG1_Y; -extern u16 gBattle_BG2_X; -extern u16 gBattle_BG2_Y; -extern u16 gBattle_BG3_X; extern struct MusicPlayerInfo gMPlayInfo_BGM; extern const u8* const gBattleScriptsForMoveEffects[]; diff --git a/src/battle_tent.c b/src/battle_tent.c index 678222ff52..c7e70912ca 100644 --- a/src/battle_tent.c +++ b/src/battle_tent.c @@ -10,6 +10,7 @@ #include "item.h" #include "battle_factory_screen.h" #include "frontier_util.h" +#include "string_util.h" #include "constants/items.h" #include "constants/region_map_sections.h" @@ -17,10 +18,6 @@ extern const struct BattleFrontierTrainer gSlateportBattleTentTrainers[]; extern const struct FacilityMon gSlateportBattleTentMons[]; extern const u16 gBattleFrontierHeldItems[]; -extern u16 gUnknown_03006298[]; - -extern void sub_81A4C30(void); - // This file's functions. static void sub_81B99D4(void); static void sub_81B9A28(void); diff --git a/src/battle_tower.c b/src/battle_tower.c index 000a03a5b8..165b6bf648 100644 --- a/src/battle_tower.c +++ b/src/battle_tower.c @@ -28,8 +28,6 @@ #include "constants/moves.h" #include "constants/species.h" -extern u16 gUnknown_03006298[]; - extern void sub_81A4C30(void); extern const u8 *const *const gUnknown_085DD690[]; @@ -68,6 +66,9 @@ extern const u8 MossdeepCity_SpaceCenter_2F_EventScript_224166[]; EWRAM_DATA const struct BattleFrontierTrainer *gFacilityTrainers = NULL; EWRAM_DATA const struct FacilityMon *gFacilityTrainerMons = NULL; +// IWRAM common +u16 gUnknown_03006298[4]; + // This file's functions. static void sub_8161F94(void); static void sub_8162054(void); diff --git a/src/battle_transition.c b/src/battle_transition.c index 759f15eeee..94b9e78f94 100644 --- a/src/battle_transition.c +++ b/src/battle_transition.c @@ -1,4 +1,5 @@ #include "global.h" +#include "battle.h" #include "battle_transition.h" #include "bg.h" #include "decompress.h" @@ -56,9 +57,6 @@ struct StructRectangularSpiral typedef bool8 (*TransitionStateFunc)(struct Task *task); typedef bool8 (*TransitionSpriteCallback)(struct Sprite *sprite); -extern u16 gBattle_BG0_X; -extern u16 gBattle_BG0_Y; - extern const struct OamData gEventObjectBaseOam_32x32; extern void sub_80AC3D0(void); diff --git a/src/berry_blender.c b/src/berry_blender.c index fca544e038..7320e905f2 100644 --- a/src/berry_blender.c +++ b/src/berry_blender.c @@ -33,6 +33,7 @@ #include "item_menu.h" #include "battle_records.h" #include "graphics.h" +#include "new_game.h" #define BLENDER_SCORE_BEST 0 #define BLENDER_SCORE_GOOD 1 @@ -132,8 +133,6 @@ struct BerryBlenderData extern struct MusicPlayerInfo gMPlayInfo_SE2; extern struct MusicPlayerInfo gMPlayInfo_BGM; -extern u8 gInGameOpponentsNo; -extern u8 gUnknown_020322D5; // text extern const u8 gText_SavingDontTurnOff2[]; @@ -195,18 +194,21 @@ static void sub_8083170(u16 a0, u16 a1); static void Blender_PrintMadePokeblockString(struct Pokeblock *pokeblock, u8 *dst); static bool32 TryAddContestLinkTvShow(struct Pokeblock *pokeblock, struct TvBlenderStruct *a1); -// ewram +// EWRAM EWRAM_DATA static struct BerryBlenderData *sBerryBlenderData = NULL; EWRAM_DATA static s32 sUnknown_020322A8[5] = {0}; EWRAM_DATA static s32 sUnknown_020322BC[5] = {0}; EWRAM_DATA static u32 sUnknown_020322D0 = 0; -// iwram +// IWRAM bss IWRAM_DATA static s16 sUnknown_03000DE8[8]; IWRAM_DATA static s16 sUnknown_03000DF8[6]; IWRAM_DATA static s16 sUnknown_03000E04; IWRAM_DATA static s16 sUnknown_03000E06; +// IWRAM common +u8 gInGameOpponentsNo; + // rom static const u16 sBlenderCenterPal[] = INCBIN_U16("graphics/berry_blender/center.gbapal"); diff --git a/src/contest.c b/src/contest.c index 76e13781c1..0c3a041b0f 100644 --- a/src/contest.c +++ b/src/contest.c @@ -193,19 +193,6 @@ EWRAM_DATA struct ContestWinner gUnknown_02039F3C = {0}; u32 gContestRngValue; -extern u16 gBattle_BG0_X; -extern u16 gBattle_BG0_Y; -extern u16 gBattle_BG1_X; -extern s16 gBattle_BG1_Y; -extern u16 gBattle_BG2_X; -extern u16 gBattle_BG2_Y; -extern u16 gBattle_BG3_X; -extern u16 gBattle_BG3_Y; -extern u16 gBattle_WIN0H; -extern u16 gBattle_WIN0V; -extern u16 gBattle_WIN1H; -extern u16 gBattle_WIN1V; - extern const u16 gUnknown_08587C30[]; extern const struct BgTemplate gUnknown_08587F34[4]; extern const struct WindowTemplate gUnknown_08587F44[]; @@ -638,7 +625,8 @@ void sub_80D8108(u8 taskId) gTasks[taskId].data[0]++; break; case 1: - if ((gBattle_BG1_Y += 7) <= 160) + (s16)gBattle_BG1_Y += 7; + if ((s16)gBattle_BG1_Y <= 160) break; gTasks[taskId].data[0]++; break; @@ -1915,9 +1903,9 @@ void sub_80DA6B4(u8 taskId) void sub_80DA700(u8 taskId) { gBattle_BG1_Y -= 7; - if (gBattle_BG1_Y < 0) + if ((s16)gBattle_BG1_Y < 0) gBattle_BG1_Y = 0; - if (*(u16 *)&gBattle_BG1_Y == 0) // Why cast? + if (gBattle_BG1_Y == 0) // Why cast? { gTasks[taskId].func = sub_80DA740; gTasks[taskId].data[0] = 0; diff --git a/src/contest_painting.c b/src/contest_painting.c new file mode 100644 index 0000000000..7950b7caca --- /dev/null +++ b/src/contest_painting.c @@ -0,0 +1,8 @@ +#include "global.h" + +// IWRAM bss +IWRAM_DATA u8 gUnknown_030011F0; +IWRAM_DATA u16 gUnknown_030011F2; +IWRAM_DATA u16 gUnknown_030011F4; +IWRAM_DATA u8 gUnknown_030011F6; +IWRAM_DATA u8 gUnknown_030011F7; diff --git a/src/easy_chat.c b/src/easy_chat.c index 7d25d1430b..e4233fb7f6 100644 --- a/src/easy_chat.c +++ b/src/easy_chat.c @@ -13,6 +13,7 @@ #include "palette.h" #include "event_data.h" #include "easy_chat.h" +#include "string_util.h" // Static type declarations diff --git a/src/evolution_scene.c b/src/evolution_scene.c index c1d2ce59e7..0d2072a158 100644 --- a/src/evolution_scene.c +++ b/src/evolution_scene.c @@ -41,15 +41,6 @@ struct EvoInfo static EWRAM_DATA struct EvoInfo *sEvoStructPtr = NULL; static EWRAM_DATA u16 *sEvoMovingBgPtr = NULL; -extern u16 gBattle_BG0_X; -extern u16 gBattle_BG0_Y; -extern u16 gBattle_BG1_X; -extern u16 gBattle_BG1_Y; -extern u16 gBattle_BG2_X; -extern u16 gBattle_BG2_Y; -extern u16 gBattle_BG3_X; -extern u16 gBattle_BG3_Y; - #define sEvoCursorPos gBattleCommunication[1] // when learning a new move #define sEvoGraphicsTaskID gBattleCommunication[2] diff --git a/src/fldeff_strength.c b/src/fldeff_strength.c index c9b91f97fe..f796ecea64 100644 --- a/src/fldeff_strength.c +++ b/src/fldeff_strength.c @@ -5,6 +5,7 @@ #include "party_menu.h" #include "rom6.h" #include "script.h" +#include "string_util.h" #include "task.h" #include "constants/event_objects.h" #include "constants/field_effects.h" diff --git a/src/fossil_specials.c b/src/fossil_specials.c index 49db0f5b6e..8164a3a788 100644 --- a/src/fossil_specials.c +++ b/src/fossil_specials.c @@ -17,29 +17,32 @@ #include "task.h" #include "window.h" -#define MIRAGE_TOWER_GFX_LENGTH (sizeof(gUnknown_08617274) + sizeof(gMirageTower_Gfx)) +#define MIRAGE_TOWER_GFX_LENGTH (32 + sizeof(gMirageTower_Gfx)) #define MIRAGE_TOWER_PALETTE_LENGTH 0x800 #define ROOT_FOSSIL_GFX_LENGTH sizeof(gRootFossil_Gfx) #define ROOT_FOSSIL_GFX_RANDOMIZER_LENGTH 0x100 -//struct -struct Struct8617DA4 { +struct Struct8617DA4 +{ u8 x; u8 y; u16 tileId; }; -struct Struct203CF10 { +struct Struct203CF10 +{ u8 *buffer; - u8 curr_buffer_index; + u8 currIndex; }; -struct DynamicSpriteFrameImage{ +struct DynamicSpriteFrameImage +{ u8 *data; u16 size; }; -struct Struct203CF0C { +struct Struct203CF0C +{ u8 *frameImageTiles; struct DynamicSpriteFrameImage *frameImage; u8 spriteId; @@ -52,10 +55,10 @@ static void sub_81BED50(u8 taskId); static void sub_81BEBF4(u8 taskId); static void sub_81BF028(u8 taskId); static void sub_81BF248(struct Sprite *); -/*static*/ void sub_81BF2B8(u8* a, u16 b, u8 c, u8 d, u8 e); +static void sub_81BF2B8(u8* a, u16 b, u8 c, u8 d, u8 e); // .rodata -static const u8 gUnknown_08617274[] = {00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00}; +static const u8 gUnknown_08617274[32] = {0}; static const u8 gMirageTower_Gfx[] = INCBIN_U8("graphics/misc/mirage_tower.4bpp"); static const u16 gUnknown_08617B94[] = INCBIN_U16("graphics/misc/mirage_tower.bin"); static const u16 gRootFossil_Pal[] = INCBIN_U16("graphics/misc/fossil.gbapal"); @@ -64,16 +67,16 @@ static const u8 gMirageTowerCrumbles_Gfx[] = INCBIN_U8("graphics/misc/mirage_tow static const u16 gMirageTowerCrumbles_Palette[] = INCBIN_U16("graphics/misc/mirage_tower_crumbles.gbapal"); const s16 gUnknown_08617D64[][3] = - { - { 0, 10, 65}, - { 17, 3, 50}, - {-12, 0, 75}, - { 10, 15, 90}, - { 7, 8, 65}, - {-18, 5, 75}, - { 22, -10, 55}, - {-24, -4, 65}, - }; +{ + { 0, 10, 65}, + { 17, 3, 50}, + {-12, 0, 75}, + { 10, 15, 90}, + { 7, 8, 65}, + {-18, 5, 75}, + { 22, -10, 55}, + {-24, -4, 65}, +}; const struct SpriteSheet gUnknown_08617D94[] = { @@ -82,26 +85,26 @@ const struct SpriteSheet gUnknown_08617D94[] = }; static const struct Struct8617DA4 gUnknown_08617DA4[] = - { - {0x12, 0x35, 0x251}, - {0x13, 0x35, 0x251}, - {0x14, 0x35, 0x251}, - {0x12, 0x36, 0x251}, - {0x13, 0x36, 0x251}, - {0x14, 0x36, 0x251}, - {0x12, 0x37, 0x251}, - {0x13, 0x37, 0x251}, - {0x14, 0x37, 0x251}, - {0x12, 0x38, 0x251}, - {0x13, 0x38, 0x251}, - {0x14, 0x38, 0x251}, - {0x12, 0x39, 0x259}, - {0x13, 0x39, 0x259}, - {0x14, 0x39, 0x259}, - {0x12, 0x3A, 0x121}, - {0x13, 0x3A, 0x121}, - {0x14, 0x3A, 0x121}, - }; +{ + {0x12, 0x35, 0x251}, + {0x13, 0x35, 0x251}, + {0x14, 0x35, 0x251}, + {0x12, 0x36, 0x251}, + {0x13, 0x36, 0x251}, + {0x14, 0x36, 0x251}, + {0x12, 0x37, 0x251}, + {0x13, 0x37, 0x251}, + {0x14, 0x37, 0x251}, + {0x12, 0x38, 0x251}, + {0x13, 0x38, 0x251}, + {0x14, 0x38, 0x251}, + {0x12, 0x39, 0x259}, + {0x13, 0x39, 0x259}, + {0x14, 0x39, 0x259}, + {0x12, 0x3A, 0x121}, + {0x13, 0x3A, 0x121}, + {0x14, 0x3A, 0x121}, +}; static const union AnimCmd gSpriteAnim_8617DEC[] = { @@ -131,67 +134,70 @@ static const union AnimCmd *const gSpriteAnimTable_8617DFC[] = gSpriteAnim_8617DEC, }; -static const struct SpriteTemplate gUnknown_08617E00 = { +static const struct SpriteTemplate gUnknown_08617E00 = +{ 0xFFFF, 0xFFFF, &gOamData_8617DF4, gSpriteAnimTable_8617DFC, NULL, gDummySpriteAffineAnimTable, SpriteCallbackDummy }; -// ewram -EWRAM_DATA u8* gUnknown_0203CF04 = NULL; -EWRAM_DATA u8* gUnknown_0203CF08 = NULL; -EWRAM_DATA struct Struct203CF0C *gUnknown_0203CF0C = NULL; -EWRAM_DATA struct Struct203CF10 *gUnknown_0203CF10 = NULL; -EWRAM_DATA u16 *gUnknown_0203CF14 = NULL; +// EWRAM +EWRAM_DATA static u8* sUnknown_0203CF04 = NULL; +EWRAM_DATA static u8* sUnknown_0203CF08 = NULL; +EWRAM_DATA static struct Struct203CF0C *sUnknown_0203CF0C = NULL; +EWRAM_DATA static struct Struct203CF10 *sUnknown_0203CF10 = NULL; +EWRAM_DATA static u16 *sUnknown_0203CF14 = NULL; -// iwram -IWRAM_DATA u16 gUnknown_030012A8[8] = {0, 0, 0, 0, 0, 0, 0, 0}; +// IWRAM bss +IWRAM_DATA static u16 gUnknown_030012A8[8]; // text void sub_81BEB24(void) { u8 i; - for(i = 0; i < (sizeof(gUnknown_08617DA4)/sizeof(gUnknown_08617DA4[0])); i++) + for (i = 0; i < (sizeof(gUnknown_08617DA4)/sizeof(gUnknown_08617DA4[0])); i++) MapGridSetMetatileIdAt(gUnknown_08617DA4[i].x + 7, gUnknown_08617DA4[i].y + 7, gUnknown_08617DA4[i].tileId); DrawWholeMapView(); } void sub_81BEB54(void) { - CreateTask(sub_81BED50, 0x9); + CreateTask(sub_81BED50, 9); } void sub_81BEB68(void) { - CreateTask(sub_81BEBF4, 0x9); + CreateTask(sub_81BEBF4, 9); } void sub_81BEB7C(void) { - CreateTask(sub_81BF028, 0x9); + CreateTask(sub_81BF028, 9); } void sub_81BEB90(void) { - SetGpuReg(REG_OFFSET_BG0HOFS, gUnknown_0203CF14[0]); - SetGpuReg(REG_OFFSET_BG0VOFS, gUnknown_0203CF14[1]); + SetGpuReg(REG_OFFSET_BG0HOFS, sUnknown_0203CF14[0]); + SetGpuReg(REG_OFFSET_BG0VOFS, sUnknown_0203CF14[1]); } void sub_81BEBB4(u8 taskId) { - if(!(gTasks[taskId].data[0])) + if (!(gTasks[taskId].data[0])) { - gUnknown_0203CF14[0] = -gUnknown_0203CF14[0]; + sUnknown_0203CF14[0] = -sUnknown_0203CF14[0]; gTasks[taskId].data[0] = 2; sub_81BEB90(); } else + { gTasks[taskId].data[0]--; + } } static void sub_81BEBF4(u8 taskId) { u8 zero; - switch(gTasks[taskId].data[0]) + switch (gTasks[taskId].data[0]) { case 0: FreeAllWindowBuffers(); @@ -199,19 +205,19 @@ static void sub_81BEBF4(u8 taskId) gTasks[taskId].data[0]++; break; case 1: - gUnknown_0203CF04 = (u8 *)AllocZeroed(MIRAGE_TOWER_GFX_LENGTH); - gUnknown_0203CF08 = (u8 *)AllocZeroed(MIRAGE_TOWER_PALETTE_LENGTH); + sUnknown_0203CF04 = (u8 *)AllocZeroed(MIRAGE_TOWER_GFX_LENGTH); + sUnknown_0203CF08 = (u8 *)AllocZeroed(MIRAGE_TOWER_PALETTE_LENGTH); ChangeBgX(0, 0, 0); ChangeBgY(0, 0, 0); gTasks[taskId].data[0]++; break; case 2: - CpuSet(gUnknown_08617274, gUnknown_0203CF04, MIRAGE_TOWER_GFX_LENGTH / 2); - LoadBgTiles(0, gUnknown_0203CF04, MIRAGE_TOWER_GFX_LENGTH, 0); + CpuSet(gUnknown_08617274, sUnknown_0203CF04, MIRAGE_TOWER_GFX_LENGTH / 2); + LoadBgTiles(0, sUnknown_0203CF04, MIRAGE_TOWER_GFX_LENGTH, 0); gTasks[taskId].data[0]++; break; case 3: - SetBgTilemapBuffer(0, gUnknown_0203CF08); + SetBgTilemapBuffer(0, sUnknown_0203CF08); CopyToBgTilemapBufferRect_ChangePalette(0, &gUnknown_08617B94, 12, 29, 6, 12, 17); CopyBgTilemapBufferToVram(0); gTasks[taskId].data[0]++; @@ -225,10 +231,10 @@ static void sub_81BEBF4(u8 taskId) gTasks[taskId].data[0]++; break; case 6: - gUnknown_0203CF14 = (u16 *)Alloc(4); + sUnknown_0203CF14 = Alloc(4); zero = 0; - gUnknown_0203CF14[0] = 2; - gUnknown_0203CF14[1] = zero; + sUnknown_0203CF14[0] = 2; + sUnknown_0203CF14[1] = zero; CreateTask(sub_81BEBB4, 0xA); DestroyTask(taskId); EnableBothScriptContexts(); @@ -236,86 +242,76 @@ static void sub_81BEBF4(u8 taskId) } } -#ifdef NONMATCHING #define OUTER_BUFFER_LENGTH 0x60 #define INNER_BUFFER_LENGTH 0x30 static void sub_81BED50(u8 taskId) { u8 anotherTaskId, j; + u16 i; + u8 index; - - switch(gTasks[taskId].data[0]) + switch (gTasks[taskId].data[0]) { case 1: - gUnknown_0203CF10 = (struct Struct203CF10 *)AllocZeroed(OUTER_BUFFER_LENGTH * sizeof(struct Struct203CF10)); + sUnknown_0203CF10 = AllocZeroed(OUTER_BUFFER_LENGTH * sizeof(struct Struct203CF10)); break; case 3: + if (gTasks[taskId].data[3] <= (OUTER_BUFFER_LENGTH - 1)) { - u16 i; - u16 left; - u32 index, next; - - index = (u16)gTasks[taskId].data[3]; - if(gTasks[taskId].data[3] <= (OUTER_BUFFER_LENGTH - 1)) + if (gTasks[taskId].data[1] > 1) { - if(gTasks[taskId].data[1] > 1) + index = gTasks[taskId].data[3]; + sUnknown_0203CF10[index].buffer = Alloc(INNER_BUFFER_LENGTH); + for (i = 0; i <= (INNER_BUFFER_LENGTH - 1); i++) + sUnknown_0203CF10[index].buffer[i] = i; + for (i = 0; i <= (INNER_BUFFER_LENGTH - 1); i++) { - index = (u8)index; - gUnknown_0203CF10[index].buffer = (u8 *)Alloc(INNER_BUFFER_LENGTH); - for(i = 0; i <= (INNER_BUFFER_LENGTH - 1); i++) - gUnknown_0203CF10[index].buffer[i] = i; - for(i = 0; i <= (INNER_BUFFER_LENGTH - 1); i++) - { - u16 rand1, rand2, temp; + u16 rand1, rand2, temp; - rand1 = Random() % 0x30; - rand2 = Random() % 0x30; - temp = gUnknown_0203CF10[index].buffer[rand2]; - gUnknown_0203CF10[index].buffer[rand2] = gUnknown_0203CF10[index].buffer[rand1]; - gUnknown_0203CF10[index].buffer[rand1] = temp; - } - if(gTasks[taskId].data[3] <= (OUTER_BUFFER_LENGTH - 1)) - gTasks[taskId].data[3]++; - gTasks[taskId].data[1] = 0; + rand1 = Random() % 0x30; + rand2 = Random() % 0x30; + SWAP(sUnknown_0203CF10[index].buffer[rand2], sUnknown_0203CF10[index].buffer[rand1], temp); } - gTasks[taskId].data[1]++; + if (gTasks[taskId].data[3] <= (OUTER_BUFFER_LENGTH - 1)) + gTasks[taskId].data[3]++; + gTasks[taskId].data[1] = 0; } - index = (u8)gTasks[taskId].data[3]; - for(left = (u8)gTasks[taskId].data[2]; left < (u16)index; left = next) - { - j = 0; - next = left + 1; - while(!j) - { - sub_81BF2B8(gUnknown_0203CF04, ((((OUTER_BUFFER_LENGTH - 1) - left) * INNER_BUFFER_LENGTH) + gUnknown_0203CF10[left].buffer[(gUnknown_0203CF10[left].curr_buffer_index)++]), 0, INNER_BUFFER_LENGTH, 1); - j++; - } - if(gUnknown_0203CF10[left].curr_buffer_index > (INNER_BUFFER_LENGTH - 1)) - { - FREE_AND_SET_NULL(gUnknown_0203CF10[left].buffer); - gTasks[taskId].data[2]++; - if((left % 2) == 1) - gUnknown_0203CF14[1]--; - } - } - LoadBgTiles(0, gUnknown_0203CF04, MIRAGE_TOWER_GFX_LENGTH, 0); - if(gUnknown_0203CF10[OUTER_BUFFER_LENGTH - 1].curr_buffer_index > (INNER_BUFFER_LENGTH - 1)) - break; - return; + gTasks[taskId].data[1]++; } + index = gTasks[taskId].data[3]; + for (i = (u8)(gTasks[taskId].data[2]); i < index; i++) + { + for (j = 0; j < 1; j++) + { + sub_81BF2B8(sUnknown_0203CF04, + ((((OUTER_BUFFER_LENGTH - 1) - i) * INNER_BUFFER_LENGTH) + sUnknown_0203CF10[i].buffer[(sUnknown_0203CF10[i].currIndex)++]), + 0, INNER_BUFFER_LENGTH, 1); + } + if (sUnknown_0203CF10[i].currIndex > (INNER_BUFFER_LENGTH - 1)) + { + FREE_AND_SET_NULL(sUnknown_0203CF10[i].buffer); + gTasks[taskId].data[2]++; + if ((i % 2) == 1) + sUnknown_0203CF14[1]--; + } + } + LoadBgTiles(0, sUnknown_0203CF04, MIRAGE_TOWER_GFX_LENGTH, 0); + if (sUnknown_0203CF10[OUTER_BUFFER_LENGTH - 1].currIndex > (INNER_BUFFER_LENGTH - 1)) + break; + return; case 4: UnsetBgTilemapBuffer(0); anotherTaskId = FindTaskIdByFunc(sub_81BEBB4); - if(anotherTaskId != 0xFF) + if (anotherTaskId != 0xFF) DestroyTask(anotherTaskId); - gUnknown_0203CF14[1] = gUnknown_0203CF14[0] = 0; + sUnknown_0203CF14[1] = sUnknown_0203CF14[0] = 0; sub_81BEB90(); break; case 5: - FREE_AND_SET_NULL(gUnknown_0203CF14); - FREE_AND_SET_NULL(gUnknown_0203CF10); - FREE_AND_SET_NULL(gUnknown_0203CF04); - FREE_AND_SET_NULL(gUnknown_0203CF08); + FREE_AND_SET_NULL(sUnknown_0203CF14); + FREE_AND_SET_NULL(sUnknown_0203CF10); + FREE_AND_SET_NULL(sUnknown_0203CF04); + FREE_AND_SET_NULL(sUnknown_0203CF08); break; case 6: SetGpuRegBits(REG_OFFSET_BG2CNT, 0x2); @@ -334,423 +330,75 @@ static void sub_81BED50(u8 taskId) gTasks[taskId].data[0]++; } -#else -NAKED -static void sub_81BED50(u8 taskId) -{ - asm("\n\ - .syntax unified\n\ - push {r4-r7,lr}\n\ - mov r7, r10\n\ - mov r6, r9\n\ - mov r5, r8\n\ - push {r5-r7}\n\ - sub sp, 0x10\n\ - lsls r0, 24\n\ - lsrs r0, 24\n\ - mov r10, r0\n\ - ldr r1, =gTasks\n\ - lsls r0, 2\n\ - add r0, r10\n\ - lsls r0, 3\n\ - adds r0, r1\n\ - ldrh r0, [r0, 0x8]\n\ - subs r0, 0x1\n\ - lsls r0, 16\n\ - asrs r0, 16\n\ - adds r6, r1, 0\n\ - cmp r0, 0x7\n\ - bls _081BED7C\n\ - b _081BF002\n\ - _081BED7C:\n\ - lsls r0, 2\n\ - ldr r1, =_081BED90\n\ - adds r0, r1\n\ - ldr r0, [r0]\n\ - mov pc, r0\n\ - .pool\n\ - .align 2, 0\n\ - _081BED90:\n\ - .4byte _081BEDB0\n\ - .4byte _081BF002\n\ - .4byte _081BEDC4\n\ - .4byte _081BEF64\n\ - .4byte _081BEF94\n\ - .4byte _081BEFD0\n\ - .4byte _081BEFF0\n\ - .4byte _081BEFF8\n\ - _081BEDB0:\n\ - ldr r4, =gUnknown_0203CF10\n\ - movs r0, 0xC0\n\ - lsls r0, 2\n\ - bl AllocZeroed\n\ - str r0, [r4]\n\ - b _081BF002\n\ - .pool\n\ - _081BEDC4:\n\ - mov r1, r10\n\ - lsls r0, r1, 2\n\ - adds r1, r0, r1\n\ - lsls r1, 3\n\ - adds r2, r1, r6\n\ - ldrh r3, [r2, 0xE]\n\ - movs r4, 0xE\n\ - ldrsh r1, [r2, r4]\n\ - str r0, [sp, 0x8]\n\ - cmp r1, 0x5F\n\ - bgt _081BEE8A\n\ - movs r1, 0xA\n\ - ldrsh r0, [r2, r1]\n\ - cmp r0, 0x1\n\ - ble _081BEE7C\n\ - lsls r0, r3, 24\n\ - lsrs r4, r0, 24\n\ - movs r0, 0x30\n\ - bl Alloc\n\ - ldr r3, =gUnknown_0203CF10\n\ - ldr r1, [r3]\n\ - lsls r2, r4, 3\n\ - adds r1, r2, r1\n\ - str r0, [r1]\n\ - movs r5, 0\n\ - adds r4, r2, 0\n\ - _081BEDFA:\n\ - ldr r0, [r3]\n\ - adds r0, r4, r0\n\ - ldr r0, [r0]\n\ - adds r0, r5\n\ - strb r5, [r0]\n\ - adds r0, r5, 0x1\n\ - lsls r0, 16\n\ - lsrs r5, r0, 16\n\ - cmp r5, 0x2F\n\ - bls _081BEDFA\n\ - movs r5, 0\n\ - ldr r7, =gUnknown_0203CF10\n\ - adds r6, r2, 0\n\ - _081BEE14:\n\ - bl Random\n\ - lsls r0, 16\n\ - lsrs r0, 16\n\ - movs r1, 0x30\n\ - bl __umodsi3\n\ - adds r4, r0, 0\n\ - lsls r4, 16\n\ - lsrs r4, 16\n\ - bl Random\n\ - lsls r0, 16\n\ - lsrs r0, 16\n\ - movs r1, 0x30\n\ - bl __umodsi3\n\ - lsls r0, 16\n\ - lsrs r0, 16\n\ - ldr r1, [r7]\n\ - adds r1, r6, r1\n\ - ldr r1, [r1]\n\ - adds r0, r1, r0\n\ - ldrb r2, [r0]\n\ - adds r1, r4 \n\ - ldrb r1, [r1]\n\ - strb r1, [r0]\n\ - ldr r0, [r7]\n\ - adds r0, r6, r0\n\ - ldr r0, [r0]\n\ - adds r0, r4\n\ - strb r2, [r0]\n\ - adds r0, r5, 0x1\n\ - lsls r0, 16\n\ - lsrs r5, r0, 16\n\ - cmp r5, 0x2F\n\ - bls _081BEE14\n\ - ldr r0, =gTasks\n\ - ldr r1, [sp, 0x8]\n\ - add r1, r10\n\ - lsls r1, 3\n\ - adds r2, r1, r0\n\ - ldrh r3, [r2, 0xE]\n\ - movs r4, 0xE\n\ - ldrsh r1, [r2, r4]\n\ - adds r6, r0, 0\n\ - cmp r1, 0x5F\n\ - bgt _081BEE78\n\ - adds r0, r3, 0x1\n\ - strh r0, [r2, 0xE]\n\ - _081BEE78:\n\ - movs r0, 0\n\ - strh r0, [r2, 0xA]\n\ - _081BEE7C:\n\ - ldr r1, [sp, 0x8]\n\ - add r1, r10\n\ - lsls r1, 3\n\ - adds r1, r6\n\ - ldrh r0, [r1, 0xA]\n\ - adds r0, 0x1\n\ - strh r0, [r1, 0xA]\n\ - _081BEE8A:\n\ - ldr r0, [sp, 0x8]\n\ - add r0, r10\n\ - lsls r0, 3\n\ - adds r0, r6\n\ - ldrb r4, [r0, 0xE]\n\ - ldrb r5, [r0, 0xC]\n\ - lsls r0, r4, 16\n\ - cmp r5, r4\n\ - bcs _081BEF32\n\ - str r0, [sp, 0xC]\n\ - _081BEE9E:\n\ - movs r6, 0\n\ - adds r0, r5, 0x1\n\ - str r0, [sp, 0x4]\n\ - lsls r4, r5, 3\n\ - movs r2, 0x5F\n\ - subs r1, r2, r5\n\ - lsls r0, r1, 1\n\ - adds r0, r1\n\ - lsls r0, 4\n\ - mov r9, r0\n\ - _081BEEB2:\n\ - ldr r0, =gUnknown_0203CF04\n\ - ldr r0, [r0]\n\ - ldr r7, =gUnknown_0203CF10\n\ - ldr r3, [r7]\n\ - adds r3, r4, r3\n\ - ldrb r2, [r3, 0x4]\n\ - adds r1, r2, 0x1\n\ - strb r1, [r3, 0x4]\n\ - lsls r2, 24\n\ - lsrs r2, 24\n\ - ldr r1, [r3]\n\ - adds r1, r2\n\ - ldrb r1, [r1]\n\ - add r1, r9\n\ - lsls r1, 16\n\ - lsrs r1, 16\n\ - movs r2, 0x1\n\ - mov r8, r2\n\ - str r2, [sp]\n\ - movs r2, 0\n\ - movs r3, 0x30\n\ - bl sub_81BF2B8\n\ - adds r0, r6, 0x1\n\ - lsls r0, 24\n\ - lsrs r6, r0, 24\n\ - cmp r6, 0\n\ - beq _081BEEB2\n\ - ldr r0, [r7]\n\ - adds r1, r4, r0\n\ - ldrb r0, [r1, 0x4]\n\ - cmp r0, 0x2F\n\ - bls _081BEF24\n\ - ldr r0, [r1]\n\ - bl Free\n\ - ldr r0, [r7]\n\ - adds r0, r4, r0\n\ - movs r1, 0\n\ - str r1, [r0]\n\ - ldr r1, [sp, 0x8]\n\ - add r1, r10\n\ - lsls r1, 3\n\ - ldr r4, =gTasks\n\ - adds r1, r4\n\ - ldrh r0, [r1, 0xC]\n\ - adds r0, 0x1\n\ - strh r0, [r1, 0xC]\n\ - mov r0, r8\n\ - ands r5, r0\n\ - cmp r5, 0x1\n\ - bne _081BEF24\n\ - ldr r0, =gUnknown_0203CF14\n\ - ldr r1, [r0]\n\ - ldrh r0, [r1, 0x2]\n\ - subs r0, 0x1\n\ - strh r0, [r1, 0x2]\n\ - _081BEF24:\n\ - ldr r1, [sp, 0x4]\n\ - lsls r0, r1, 16\n\ - lsrs r5, r0, 16\n\ - ldr r2, [sp, 0xC]\n\ - lsrs r0, r2, 16\n\ - cmp r5, r0\n\ - bcc _081BEE9E\n\ - _081BEF32:\n\ - ldr r0, =gUnknown_0203CF04\n\ - ldr r1, [r0]\n\ - movs r2, 0x92\n\ - lsls r2, 4\n\ - movs r0, 0\n\ - movs r3, 0\n\ - bl LoadBgTiles\n\ - ldr r0, =gUnknown_0203CF10\n\ - ldr r0, [r0]\n\ - movs r4, 0xBE\n\ - lsls r4, 2\n\ - adds r0, r4\n\ - ldrb r0, [r0, 0x4]\n\ - cmp r0, 0x2F\n\ - bhi _081BF002\n\ - b _081BF014\n\ - .pool\n\ - _081BEF64:\n\ - movs r0, 0\n\ - bl UnsetBgTilemapBuffer\n\ - ldr r0, =sub_81BEBB4\n\ - bl FindTaskIdByFunc\n\ - lsls r0, 24\n\ - lsrs r0, 24\n\ - cmp r0, 0xFF\n\ - beq _081BEF7C\n\ - bl DestroyTask\n\ - _081BEF7C:\n\ - ldr r0, =gUnknown_0203CF14\n\ - ldr r1, [r0]\n\ - movs r0, 0\n\ - strh r0, [r1]\n\ - strh r0, [r1, 0x2]\n\ - bl sub_81BEB90\n\ - b _081BF002\n\ - .pool\n\ - _081BEF94:\n\ - ldr r4, =gUnknown_0203CF14\n\ - ldr r0, [r4]\n\ - bl Free\n\ - movs r5, 0\n\ - str r5, [r4]\n\ - ldr r4, =gUnknown_0203CF10\n\ - ldr r0, [r4]\n\ - bl Free\n\ - str r5, [r4]\n\ - ldr r4, =gUnknown_0203CF04\n\ - ldr r0, [r4]\n\ - bl Free\n\ - str r5, [r4]\n\ - ldr r4, =gUnknown_0203CF08\n\ - ldr r0, [r4]\n\ - bl Free\n\ - str r5, [r4]\n\ - b _081BF002\n\ - .pool\n\ - _081BEFD0:\n\ - movs r0, 0xC\n\ - movs r1, 0x2\n\ - bl SetGpuRegBits\n\ - movs r0, 0x8\n\ - movs r1, 0\n\ - bl SetGpuRegBits\n\ - movs r0, 0\n\ - movs r1, 0x7\n\ - movs r2, 0\n\ - bl SetBgAttribute\n\ - bl sub_81971D0\n\ - b _081BF002\n\ - _081BEFF0:\n\ - movs r0, 0\n\ - bl ShowBg\n\ - b _081BF002\n\ - _081BEFF8:\n\ - mov r0, r10\n\ - bl DestroyTask\n\ - bl EnableBothScriptContexts\n\ - _081BF002:\n\ - ldr r0, =gTasks\n\ - mov r2, r10\n\ - lsls r1, r2, 2\n\ - add r1, r10\n\ - lsls r1, 3\n\ - adds r1, r0\n\ - ldrh r0, [r1, 0x8]\n\ - adds r0, 0x1\n\ - strh r0, [r1, 0x8]\n\ - _081BF014:\n\ - add sp, 0x10\n\ - pop {r3-r5}\n\ - mov r8, r3\n\ - mov r9, r4\n\ - mov r10, r5\n\ - pop {r4-r7}\n\ - pop {r0}\n\ - bx r0\n\ - .pool\n\ - .syntax divided"); -} -#endif // NONMATCHING - static void sub_81BF028(u8 taskId) { u16 i; + u8 *buffer; - switch(gTasks[taskId].data[0]) + switch (gTasks[taskId].data[0]) { case 1: - gUnknown_0203CF0C = (struct Struct203CF0C *)AllocZeroed(sizeof(struct Struct203CF0C)); - gUnknown_0203CF0C->frameImageTiles = (u8 *)AllocZeroed(ROOT_FOSSIL_GFX_LENGTH); - gUnknown_0203CF0C->frameImage = (struct DynamicSpriteFrameImage *) AllocZeroed(sizeof(struct DynamicSpriteFrameImage)); - gUnknown_0203CF0C->unkC = (u16 *)AllocZeroed(ROOT_FOSSIL_GFX_RANDOMIZER_LENGTH * sizeof(u16)); - gUnknown_0203CF0C->unk10 = 0; + sUnknown_0203CF0C = AllocZeroed(sizeof(*sUnknown_0203CF0C)); + sUnknown_0203CF0C->frameImageTiles = AllocZeroed(ROOT_FOSSIL_GFX_LENGTH); + sUnknown_0203CF0C->frameImage = AllocZeroed(sizeof(*sUnknown_0203CF0C->frameImage)); + sUnknown_0203CF0C->unkC = AllocZeroed(ROOT_FOSSIL_GFX_RANDOMIZER_LENGTH * sizeof(u16)); + sUnknown_0203CF0C->unk10 = 0; break; case 2: - { - u8 *buffer; - buffer = gUnknown_0203CF0C->frameImageTiles; - for(i = 0; i < ROOT_FOSSIL_GFX_LENGTH; i++, buffer++) - *buffer = gRootFossil_Gfx[i]; - } + buffer = sUnknown_0203CF0C->frameImageTiles; + for (i = 0; i < ROOT_FOSSIL_GFX_LENGTH; i++, buffer++) + *buffer = gRootFossil_Gfx[i]; break; case 3: - gUnknown_0203CF0C->frameImage->data = gUnknown_0203CF0C->frameImageTiles; - gUnknown_0203CF0C->frameImage->size = ROOT_FOSSIL_GFX_LENGTH; + sUnknown_0203CF0C->frameImage->data = sUnknown_0203CF0C->frameImageTiles; + sUnknown_0203CF0C->frameImage->size = ROOT_FOSSIL_GFX_LENGTH; break; case 4: { - u8 spriteId, zero; struct SpriteTemplate fossilTemplate; fossilTemplate = gUnknown_08617E00; - fossilTemplate.images = (struct SpriteFrameImage *)(gUnknown_0203CF0C->frameImage); - spriteId = CreateSprite(&fossilTemplate, 128, -16, 1); - gUnknown_0203CF0C->spriteId = spriteId; - zero = 0; - gSprites[gUnknown_0203CF0C->spriteId].centerToCornerVecX = zero; - gSprites[gUnknown_0203CF0C->spriteId].data[0] = gSprites[gUnknown_0203CF0C->spriteId].pos1.x; - gSprites[gUnknown_0203CF0C->spriteId].data[1] = 1; + fossilTemplate.images = (struct SpriteFrameImage *)(sUnknown_0203CF0C->frameImage); + sUnknown_0203CF0C->spriteId = CreateSprite(&fossilTemplate, 128, -16, 1); + gSprites[sUnknown_0203CF0C->spriteId].centerToCornerVecX = 0; + gSprites[sUnknown_0203CF0C->spriteId].data[0] = gSprites[sUnknown_0203CF0C->spriteId].pos1.x; + gSprites[sUnknown_0203CF0C->spriteId].data[1] = 1; } case 5: - for(i = 0; i < ROOT_FOSSIL_GFX_RANDOMIZER_LENGTH; i++) - gUnknown_0203CF0C->unkC[i] = i; + for (i = 0; i < ROOT_FOSSIL_GFX_RANDOMIZER_LENGTH; i++) + sUnknown_0203CF0C->unkC[i] = i; break; case 6: + for (i = 0; i < (ROOT_FOSSIL_GFX_RANDOMIZER_LENGTH * sizeof(u16)); i++) { - u16 rand1, rand2, temp, j; - j = (ROOT_FOSSIL_GFX_RANDOMIZER_LENGTH * sizeof(u16)) - 1; - for(i = 0; i <= j; i++) - { - rand1 = Random() % 0x100; - rand2 = Random() % 0x100; - j = (ROOT_FOSSIL_GFX_RANDOMIZER_LENGTH * sizeof(u16)) - 1; - temp = gUnknown_0203CF0C->unkC[rand2]; - gUnknown_0203CF0C->unkC[rand2] = gUnknown_0203CF0C->unkC[rand1]; - gUnknown_0203CF0C->unkC[rand1] = temp; - } - gSprites[gUnknown_0203CF0C->spriteId].callback = sub_81BF248; - break; + u16 rand1, rand2, temp; + + rand1 = Random() % 0x100; + rand2 = Random() % 0x100; + SWAP(sUnknown_0203CF0C->unkC[rand2], sUnknown_0203CF0C->unkC[rand1], temp); } + gSprites[sUnknown_0203CF0C->spriteId].callback = sub_81BF248; + break; case 7: - if(gSprites[gUnknown_0203CF0C->spriteId].callback != SpriteCallbackDummy) + if (gSprites[sUnknown_0203CF0C->spriteId].callback != SpriteCallbackDummy) return; - DestroySprite(&gSprites[gUnknown_0203CF0C->spriteId]); - FREE_AND_SET_NULL(gUnknown_0203CF0C->unkC);; - FREE_AND_SET_NULL(gUnknown_0203CF0C->frameImage); - FREE_AND_SET_NULL(gUnknown_0203CF0C->frameImageTiles); - FREE_AND_SET_NULL(gUnknown_0203CF0C); + DestroySprite(&gSprites[sUnknown_0203CF0C->spriteId]); + FREE_AND_SET_NULL(sUnknown_0203CF0C->unkC);; + FREE_AND_SET_NULL(sUnknown_0203CF0C->frameImage); + FREE_AND_SET_NULL(sUnknown_0203CF0C->frameImageTiles); + FREE_AND_SET_NULL(sUnknown_0203CF0C); break; case 8: EnableBothScriptContexts(); + break; } - ++gTasks[taskId].data[0]; + + gTasks[taskId].data[0]++; } static void sub_81BF248(struct Sprite *sprite) { - if (gUnknown_0203CF0C->unk10 >= (ROOT_FOSSIL_GFX_RANDOMIZER_LENGTH)) + if (sUnknown_0203CF0C->unk10 >= (ROOT_FOSSIL_GFX_RANDOMIZER_LENGTH)) { sprite->callback = SpriteCallbackDummy; } @@ -759,7 +407,7 @@ static void sub_81BF248(struct Sprite *sprite) u8 i; for (i = 0; i < 2; i++) { - sub_81BF2B8(gUnknown_0203CF0C->frameImageTiles, gUnknown_0203CF0C->unkC[gUnknown_0203CF0C->unk10++], 0, 16, 0); + sub_81BF2B8(sUnknown_0203CF0C->frameImageTiles, sUnknown_0203CF0C->unkC[sUnknown_0203CF0C->unk10++], 0, 16, 0); } StartSpriteAnim(sprite, 0); } @@ -768,3 +416,146 @@ static void sub_81BF248(struct Sprite *sprite) sprite->pos1.y++; } } + +#ifdef NONMATCHING +static void sub_81BF2B8(u8* a, u16 b, u8 c, u8 d, u8 e) +{ + u8 r5, r4, r0, r2; + u16 var; + + r4 = r5 = b / d; + gUnknown_030012A8[0] = r4; + + r0 = r2 = b % d; + gUnknown_030012A8[1] = r2; + + r4 &= 7; + r2 &= 7; + gUnknown_030012A8[2] = r4; + gUnknown_030012A8[3] = r2; + + r0 /= 8; + r5 /= 8; + gUnknown_030012A8[4] = r0; + gUnknown_030012A8[5] = r5; + + var = ((d / 8) * (r5 * 64)) + (r0 * 64); + gUnknown_030012A8[6] = var; + + var += (r4 * 8) + r2; + gUnknown_030012A8[7] = var; + + // This part is non-matching. 99% sure it IS functionally equivalent, though. + b = (b & 1) ^ 1; + c = (c << ((b) << 2)) | (15 << ((b ^ 1) << 2)); + + a[(var / 2) + (e * 32)] &= c; +} + +#else +NAKED +static void sub_81BF2B8(u8* a, u16 b, u8 c, u8 d, u8 e) +{ + 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, 0x8\n\ + str r0, [sp]\n\ + mov r10, r1\n\ + adds r6, r2, 0\n\ + mov r8, r3\n\ + ldr r0, [sp, 0x28]\n\ + mov r9, r0\n\ + lsls r1, 16\n\ + lsrs r1, 16\n\ + mov r10, r1\n\ + lsls r6, 24\n\ + lsrs r6, 24\n\ + mov r0, r8\n\ + lsls r0, 24\n\ + mov r8, r0\n\ + lsrs r7, r0, 24\n\ + mov r1, r9\n\ + lsls r1, 24\n\ + lsrs r1, 24\n\ + mov r9, r1\n\ + mov r0, r10\n\ + adds r1, r7, 0\n\ + bl __divsi3\n\ + adds r5, r0, 0\n\ + lsls r5, 24\n\ + lsrs r4, r5, 24\n\ + ldr r3, =gUnknown_030012A8\n\ + strh r4, [r3]\n\ + mov r0, r10\n\ + adds r1, r7, 0\n\ + str r3, [sp, 0x4]\n\ + bl __modsi3\n\ + lsls r0, 24\n\ + lsrs r2, r0, 24\n\ + ldr r3, [sp, 0x4]\n\ + strh r2, [r3, 0x2]\n\ + movs r1, 0x7\n\ + ands r4, r1\n\ + ands r2, r1\n\ + strh r4, [r3, 0x4]\n\ + strh r2, [r3, 0x6]\n\ + lsrs r0, 27\n\ + lsrs r5, 27\n\ + strh r0, [r3, 0x8]\n\ + strh r5, [r3, 0xA]\n\ + mov r1, r8\n\ + lsrs r1, 27\n\ + lsls r1, 6\n\ + mov r8, r1\n\ + mov r1, r8\n\ + muls r1, r5\n\ + lsls r0, 6\n\ + adds r1, r0\n\ + lsls r1, 16\n\ + lsrs r1, 16\n\ + strh r1, [r3, 0xC]\n\ + lsls r4, 3\n\ + adds r4, r2\n\ + adds r1, r4\n\ + lsls r4, r1, 16\n\ + lsrs r4, 17\n\ + strh r1, [r3, 0xE]\n\ + movs r1, 0x1\n\ + mov r0, r10\n\ + ands r1, r0\n\ + movs r2, 0x1\n\ + eors r1, r2\n\ + lsls r0, r1, 2\n\ + lsls r6, r0\n\ + eors r1, r2\n\ + lsls r1, 2\n\ + movs r0, 0xF\n\ + lsls r0, r1\n\ + orrs r6, r0\n\ + lsls r6, 24\n\ + lsrs r6, 24\n\ + mov r1, r9\n\ + lsls r1, 5\n\ + mov r9, r1\n\ + add r9, r4\n\ + ldr r1, [sp]\n\ + add r1, r9\n\ + ldrb r0, [r1]\n\ + ands r6, r0\n\ + strb r6, [r1]\n\ + add sp, 0x8\n\ + pop {r3-r5}\n\ + mov r8, r3\n\ + mov r9, r4\n\ + mov r10, r5\n\ + pop {r4-r7}\n\ + pop {r0}\n\ + bx r0\n\ + .pool\n\ + "); +} +#endif // NONMATCHING diff --git a/src/graphics.c b/src/graphics.c index 0057370350..7c28aa7b66 100644 --- a/src/graphics.c +++ b/src/graphics.c @@ -884,18 +884,18 @@ const u32 gBattleAnimSpritePalette_242[] = INCBIN_U32("graphics/battle_anims/spr const u32 gBattleAnimSpriteSheet_243[] = INCBIN_U32("graphics/battle_anims/sprites/243.4bpp.lz"); const u32 gBattleAnimSpritePalette_243[] = INCBIN_U32("graphics/battle_anims/sprites/243.gbapal.lz"); -const u32 gUnknown_08C2D720[] = INCBIN_U32("graphics/battle_anims/masks/stat.4bpp.lz"); -const u32 gUnknown_08C2D930[] = INCBIN_U32("graphics/battle_anims/masks/stat_tilemap_1.bin.lz"); -const u32 gUnknown_08C2DA4C[] = INCBIN_U32("graphics/battle_anims/masks/stat_tilemap_2.bin.lz"); +const u32 gBattleStatMask_Gfx[] = INCBIN_U32("graphics/battle_anims/masks/stat.4bpp.lz"); +const u32 gBattleStatMask1_Tilemap[] = INCBIN_U32("graphics/battle_anims/masks/stat_tilemap_1.bin.lz"); +const u32 gBattleStatMask2_Tilemap[] = INCBIN_U32("graphics/battle_anims/masks/stat_tilemap_2.bin.lz"); -const u32 gUnknown_08C2DB68[] = INCBIN_U32("graphics/battle_anims/masks/stat1.gbapal.lz"); -const u32 gUnknown_08C2DB88[] = INCBIN_U32("graphics/battle_anims/masks/stat2.gbapal.lz"); -const u32 gUnknown_08C2DBA8[] = INCBIN_U32("graphics/battle_anims/masks/stat3.gbapal.lz"); -const u32 gUnknown_08C2DBC8[] = INCBIN_U32("graphics/battle_anims/masks/stat4.gbapal.lz"); -const u32 gUnknown_08C2DBE8[] = INCBIN_U32("graphics/battle_anims/masks/stat5.gbapal.lz"); -const u32 gUnknown_08C2DC08[] = INCBIN_U32("graphics/battle_anims/masks/stat6.gbapal.lz"); -const u32 gUnknown_08C2DC28[] = INCBIN_U32("graphics/battle_anims/masks/stat7.gbapal.lz"); -const u32 gUnknown_08C2DC48[] = INCBIN_U32("graphics/battle_anims/masks/stat8.gbapal.lz"); +const u32 gBattleStatMask1_Pal[] = INCBIN_U32("graphics/battle_anims/masks/stat1.gbapal.lz"); +const u32 gBattleStatMask2_Pal[] = INCBIN_U32("graphics/battle_anims/masks/stat2.gbapal.lz"); +const u32 gBattleStatMask3_Pal[] = INCBIN_U32("graphics/battle_anims/masks/stat3.gbapal.lz"); +const u32 gBattleStatMask4_Pal[] = INCBIN_U32("graphics/battle_anims/masks/stat4.gbapal.lz"); +const u32 gBattleStatMask5_Pal[] = INCBIN_U32("graphics/battle_anims/masks/stat5.gbapal.lz"); +const u32 gBattleStatMask6_Pal[] = INCBIN_U32("graphics/battle_anims/masks/stat6.gbapal.lz"); +const u32 gBattleStatMask7_Pal[] = INCBIN_U32("graphics/battle_anims/masks/stat7.gbapal.lz"); +const u32 gBattleStatMask8_Pal[] = INCBIN_U32("graphics/battle_anims/masks/stat8.gbapal.lz"); const u32 gUnknown_08C2DC68[] = INCBIN_U32("graphics/battle_anims/masks/cure_bubbles.4bpp.lz"); const u32 gUnknown_08C2DDA4[] = INCBIN_U32("graphics/battle_anims/masks/cure_bubbles.gbapal.lz"); diff --git a/src/mossdeep_gym.c b/src/mossdeep_gym.c new file mode 100644 index 0000000000..cd377ad83b --- /dev/null +++ b/src/mossdeep_gym.c @@ -0,0 +1,313 @@ +#include "global.h" +#include "event_object_movement.h" +#include "fieldmap.h" +#include "malloc.h" +#include "mossdeep_gym.h" +#include "script_movement.h" +#include "constants/event_object_movement_constants.h" + +// Movement scripts. +extern const u8 gUnknown_08612698[]; +extern const u8 gUnknown_0861269C[]; +extern const u8 gUnknown_086126A0[]; +extern const u8 gUnknown_086126A4[]; +extern const u8 gUnknown_086126A8[]; +extern const u8 gUnknown_086126AA[]; +extern const u8 gUnknown_086126AC[]; +extern const u8 gUnknown_086126AE[]; + +struct MossdeepSubStruct +{ + u8 unk0; + u8 eventTemplateId; +}; + +struct MossdeepStruct +{ + struct MossdeepSubStruct objects[EVENT_OBJECTS_COUNT]; + u8 count; + bool8 unk41; +}; + +// This file's functions. +static void AddEventObject(u8 eventTemplateId, u8 arg1); +static void sub_81A8D94(u8 eventTemplateId, u8 arg1); + +// EWRAM vars +EWRAM_DATA static struct MossdeepStruct *gUnknown_0203CE50 = NULL; + +// code +void InitMossdeepGymTiles(bool8 arg0) +{ + if (gUnknown_0203CE50 == NULL) + gUnknown_0203CE50 = AllocZeroed(sizeof(*gUnknown_0203CE50)); + + gUnknown_0203CE50->unk41 = arg0; +} + +void FinishMossdeepGymTiles(void) +{ + u8 id; + + if (gUnknown_0203CE50 != NULL) + FREE_AND_SET_NULL(gUnknown_0203CE50); + + id = GetEventObjectIdByLocalIdAndMap(0xFF, 0, 0); + EventObjectClearHeldMovementIfFinished(&gEventObjects[id]); + sub_80D338C(); +} + +u16 MossdeepGym_MoveEvents(u8 arg0) +{ + u8 i; + struct EventObjectTemplate *events = gSaveBlock1Ptr->eventObjectTemplates; + u16 localId = 0; + + for (i = 0; i < EVENT_OBJECT_TEMPLATES_COUNT; i++) + { + s32 var; + u8 r5; + s16 x = events[i].x + 7; + s16 y = events[i].y + 7; + u16 metatile = MapGridGetMetatileIdAt(x, y); + + if (!gUnknown_0203CE50->unk41) + var = 0x250; + else + var = 0x298; + + if (metatile < 0x250) + continue; + + if ((u8)((metatile - var) / 8) >= 5) + continue; + if ((u8)((metatile - var) / 8) != arg0) + continue; + + r5 = (u8)((metatile - var) % 8); + if (r5 < 4) + { + s8 x = 0; + s8 y = 0; + const u8 *movementScript; + + switch (r5) + { + case 0: + movementScript = gUnknown_08612698; + x = 1; + break; + case 1: + movementScript = gUnknown_0861269C; + y = 1; + break; + case 2: + movementScript = gUnknown_086126A0; + x = -1; + break; + case 3: + movementScript = gUnknown_086126A4; + y = -1; + break; + default: + continue; + } + + events[i].x += x; + events[i].y += y; + if (GetEventObjectIdByLocalIdAndMap(events[i].localId, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup) != EVENT_OBJECTS_COUNT) + { + AddEventObject(i, r5); + localId = events[i].localId; + ScriptMovement_StartObjectMovementScript(localId, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup, movementScript); + } + else + { + sub_81A8D94(i, r5); + } + } + } + + return localId; +} + +void MossdeepGym_TurnEvents(void) +{ + u8 i; + s32 var; + struct EventObjectTemplate *events; + + if (gUnknown_0203CE50 == NULL) + return; + + if (!gUnknown_0203CE50->unk41) + var = 0x250; + else + var = 0x298; + + events = gSaveBlock1Ptr->eventObjectTemplates; + for (i = 0; i < gUnknown_0203CE50->count; i++) + { + s32 r6; + s8 r0; + u8 eventObjectId; + s16 x = events[gUnknown_0203CE50->objects[i].eventTemplateId].x + 7; + s16 y = events[gUnknown_0203CE50->objects[i].eventTemplateId].y + 7; + u16 metatile = MapGridGetMetatileIdAt(x, y); + + r0 = (u8)((metatile - var) % 8); + r0 -= (gUnknown_0203CE50->objects[i].unk0); + if (r0 < 0 || r0 == 3) + { + if (r0 == -3) + r6 = 1; + else + r6 = 0; + } + else + { + if (r0 > 0) + r6 = 1; + else + r6 = 2; + } + + eventObjectId = GetEventObjectIdByLocalIdAndMap(events[gUnknown_0203CE50->objects[i].eventTemplateId].localId, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup); + if (eventObjectId != EVENT_OBJECTS_COUNT) + { + const u8 *movementScript; + u8 direction = gEventObjects[eventObjectId].facingDirection; + if (r6 == 0) + { + switch (direction) + { + case DIR_EAST: + movementScript = gUnknown_086126AE; + events[gUnknown_0203CE50->objects[i].eventTemplateId].movementType = MOVEMENT_TYPE_FACE_UP; + break; + case DIR_SOUTH: + movementScript = gUnknown_086126A8; + events[gUnknown_0203CE50->objects[i].eventTemplateId].movementType = MOVEMENT_TYPE_FACE_RIGHT; + break; + case DIR_WEST: + movementScript = gUnknown_086126AA; + events[gUnknown_0203CE50->objects[i].eventTemplateId].movementType = MOVEMENT_TYPE_FACE_DOWN; + break; + case DIR_NORTH: + movementScript = gUnknown_086126AC; + events[gUnknown_0203CE50->objects[i].eventTemplateId].movementType = MOVEMENT_TYPE_FACE_LEFT; + break; + default: + continue; + } + ScriptMovement_StartObjectMovementScript(events[gUnknown_0203CE50->objects[i].eventTemplateId].localId, + gSaveBlock1Ptr->location.mapNum, + gSaveBlock1Ptr->location.mapGroup, + movementScript); + } + else if (r6 == 1) + { + switch (direction) + { + case DIR_EAST: + movementScript = gUnknown_086126AA; + events[gUnknown_0203CE50->objects[i].eventTemplateId].movementType = MOVEMENT_TYPE_FACE_DOWN; + break; + case DIR_SOUTH: + movementScript = gUnknown_086126AC; + events[gUnknown_0203CE50->objects[i].eventTemplateId].movementType = MOVEMENT_TYPE_FACE_LEFT; + break; + case DIR_WEST: + movementScript = gUnknown_086126AE; + events[gUnknown_0203CE50->objects[i].eventTemplateId].movementType = MOVEMENT_TYPE_FACE_UP; + break; + case DIR_NORTH: + movementScript = gUnknown_086126A8; + events[gUnknown_0203CE50->objects[i].eventTemplateId].movementType = MOVEMENT_TYPE_FACE_RIGHT; + break; + default: + continue; + } + ScriptMovement_StartObjectMovementScript(events[gUnknown_0203CE50->objects[i].eventTemplateId].localId, + gSaveBlock1Ptr->location.mapNum, + gSaveBlock1Ptr->location.mapGroup, + movementScript); + } + } + } +} + +static void AddEventObject(u8 eventTemplateId, u8 arg1) +{ + gUnknown_0203CE50->objects[gUnknown_0203CE50->count].eventTemplateId = eventTemplateId; + gUnknown_0203CE50->objects[gUnknown_0203CE50->count].unk0 = arg1; + gUnknown_0203CE50->count++; +} + +static void sub_81A8D94(u8 eventTemplateId, u8 arg1) +{ + s8 r0; + s32 r6; + s32 var; + u16 movementType; + struct EventObjectTemplate *events = gSaveBlock1Ptr->eventObjectTemplates; + s16 x = events[eventTemplateId].x + 7; + s16 y = events[eventTemplateId].y + 7; + u16 metatile = MapGridGetMetatileIdAt(x, y); + + if (!gUnknown_0203CE50->unk41) + var = 0x250; + else + var = 0x298; + + r0 = (u8)((metatile - var) % 8); + r0 -= arg1; + if (r0 < 0 || r0 == 3) + r6 = 0; + else if (r0 > 0 || r0 == -3) + r6 = 1; + else + r6 = 2; + + movementType = events[eventTemplateId].movementType; + if (r6 == 0) + { + switch (movementType) + { + case MOVEMENT_TYPE_FACE_RIGHT: + events[eventTemplateId].movementType = MOVEMENT_TYPE_FACE_UP; + break; + case MOVEMENT_TYPE_FACE_DOWN: + events[eventTemplateId].movementType = MOVEMENT_TYPE_FACE_RIGHT; + break; + case MOVEMENT_TYPE_FACE_LEFT: + events[eventTemplateId].movementType = MOVEMENT_TYPE_FACE_DOWN; + break; + case MOVEMENT_TYPE_FACE_UP: + events[eventTemplateId].movementType = MOVEMENT_TYPE_FACE_LEFT; + break; + default: + break; + } + } + else if (r6 == 1) + { + switch (movementType) + { + case MOVEMENT_TYPE_FACE_RIGHT: + events[eventTemplateId].movementType = MOVEMENT_TYPE_FACE_DOWN; + break; + case MOVEMENT_TYPE_FACE_DOWN: + events[eventTemplateId].movementType = MOVEMENT_TYPE_FACE_LEFT; + break; + case MOVEMENT_TYPE_FACE_LEFT: + events[eventTemplateId].movementType = MOVEMENT_TYPE_FACE_UP; + break; + case MOVEMENT_TYPE_FACE_UP: + events[eventTemplateId].movementType = MOVEMENT_TYPE_FACE_RIGHT; + break; + default: + break; + } + } +} diff --git a/src/multiboot.c b/src/multiboot.c index 7fd6df2d02..da90a55c05 100644 --- a/src/multiboot.c +++ b/src/multiboot.c @@ -1,7 +1,7 @@ #include "gba/gba.h" #include "multiboot.h" -static u16 MultiBoot_required_data[MULTIBOOT_NCHILD]; +IWRAM_DATA static u16 MultiBoot_required_data[MULTIBOOT_NCHILD]; static int MultiBootSend(struct MultiBootParam *mp, u16 data); static int MultiBootHandShake(struct MultiBootParam *mp); diff --git a/src/mystery_event_script.c b/src/mystery_event_script.c index 921c8e97c5..4196bb34c2 100644 --- a/src/mystery_event_script.c +++ b/src/mystery_event_script.c @@ -18,7 +18,6 @@ #include "pokemon_storage_system.h" extern void sub_811EFC0(u8); -extern void ValidateEReaderTrainer(void); extern ScrCmdFunc gMysteryEventScriptCmdTable[]; extern ScrCmdFunc gMysteryEventScriptCmdTableEnd[]; diff --git a/src/new_game.c b/src/new_game.c index cdabd5cccf..18b128624c 100644 --- a/src/new_game.c +++ b/src/new_game.c @@ -28,7 +28,6 @@ #include "apprentice.h" #include "frontier_util.h" -extern u8 gDifferentSaveFile; extern u16 gSaveFileStatus; extern u8 gUnknown_030060B0; @@ -61,6 +60,10 @@ static void ClearFrontierRecord(void); static void WarpToTruck(void); static void ResetMiniGamesResults(void); +// EWRAM vars +EWRAM_DATA bool8 gDifferentSaveFile = FALSE; +EWRAM_DATA bool8 gUnknown_020322D5 = FALSE; + // const rom data static const struct ContestWinner sContestWinnerPicDummy = { diff --git a/src/overworld.c b/src/overworld.c index 28d2d02ca4..10f2ebd26a 100644 --- a/src/overworld.c +++ b/src/overworld.c @@ -88,12 +88,6 @@ extern const struct MapHeader *const *const gMapGroups[]; extern const s32 gMaxFlashLevel; extern const u16 gUnknown_82EC7C4[]; -u16 gUnknown_03005DA8; -MainCallback gFieldCallback; -bool8 (*gFieldCallback2)(void); -u8 gUnknown_03005DB4; -u8 gFieldLinkPlayerCount; - // functions extern void HealPlayerParty(void); extern void move_tilemap_camera_to_upper_left_corner(void); @@ -256,6 +250,16 @@ IWRAM_DATA static u8 sUnknown_03000E18; IWRAM_DATA static u8 sUnknown_03000E19; IWRAM_DATA static u32 sUnusedVar; +// IWRAM common +u16 *gBGTilemapBuffers1; +u16 *gBGTilemapBuffers2; +u16 *gBGTilemapBuffers3; +u16 gUnknown_03005DA8; +void (*gFieldCallback)(void); +bool8 (*gFieldCallback2)(void); +u8 gUnknown_03005DB4; +u8 gFieldLinkPlayerCount; + // EWRAM vars EWRAM_DATA static u8 sUnknown_020322D8 = 0; EWRAM_DATA struct WarpData gLastUsedWarp = {0}; diff --git a/src/pokedex.c b/src/pokedex.c index 93ff068768..1405393c1b 100644 --- a/src/pokedex.c +++ b/src/pokedex.c @@ -29,14 +29,17 @@ #include "constants/songs.h" #include "constants/species.h" +extern u8 gUnknown_030061EC; + +// EWRAM static EWRAM_DATA struct PokedexView *gUnknown_02039B4C = NULL; static EWRAM_DATA u16 gUnknown_02039B50 = 0; static EWRAM_DATA u8 gUnknown_02039B52 = 0; static EWRAM_DATA struct PokedexListItem *gUnknown_02039B54 = NULL; +// IWRAM common u8 gUnknown_030060B0; -MainCallback gUnknown_030060B4; -u8 gUnknown_030061EC; +void (*gUnknown_030060B4)(void); struct PokedexEntry { diff --git a/src/reshow_battle_screen.c b/src/reshow_battle_screen.c index c68a003cf9..1c1c437c7a 100644 --- a/src/reshow_battle_screen.c +++ b/src/reshow_battle_screen.c @@ -16,15 +16,6 @@ #include "battle_anim.h" #include "data2.h" -extern u16 gBattle_BG0_X; -extern u16 gBattle_BG0_Y; -extern u16 gBattle_BG1_X; -extern u16 gBattle_BG1_Y; -extern u16 gBattle_BG2_X; -extern u16 gBattle_BG2_Y; -extern u16 gBattle_BG3_X; -extern u16 gBattle_BG3_Y; - extern const union AnimCmd * const * const gMonAnimationsSpriteAnimsPtrTable[]; extern void SetMultiuseSpriteTemplateToTrainerBack(u16 backPicId, u8 battlerPosition); diff --git a/src/save.c b/src/save.c index 3ee98f4f75..4ae516fc9c 100644 --- a/src/save.c +++ b/src/save.c @@ -94,6 +94,7 @@ u16 gSaveUnusedVar2; u16 gUnknown_03006294; EWRAM_DATA struct SaveSection gSaveDataBuffer = {0}; +EWRAM_DATA static u8 sUnusedVar = 0; void ClearSaveData(void) { diff --git a/src/scanline_effect.c b/src/scanline_effect.c index 148e053fc2..a9ae9427b6 100644 --- a/src/scanline_effect.c +++ b/src/scanline_effect.c @@ -1,4 +1,5 @@ #include "global.h" +#include "battle.h" #include "data2.h" #include "task.h" #include "trig.h" @@ -7,15 +8,6 @@ static void CopyValue16Bit(void); static void CopyValue32Bit(void); -extern u16 gBattle_BG0_Y; -extern u16 gBattle_BG0_X; -extern u16 gBattle_BG1_X; -extern u16 gBattle_BG1_Y; -extern u16 gBattle_BG2_X; -extern u16 gBattle_BG2_Y; -extern u16 gBattle_BG3_X; -extern u16 gBattle_BG3_Y; - // EWRAM vars // Per-scanline register values. diff --git a/src/scrcmd.c b/src/scrcmd.c index d2a6c2a17b..3103873371 100644 --- a/src/scrcmd.c +++ b/src/scrcmd.c @@ -4,6 +4,7 @@ #include "berry.h" #include "clock.h" #include "coins.h" +#include "contest.h" #include "contest_link_80F57C4.h" #include "contest_painting.h" #include "data2.h" @@ -27,6 +28,7 @@ #include "event_obj_lock.h" #include "menu.h" #include "money.h" +#include "mossdeep_gym.h" #include "mystery_event_script.h" #include "palette.h" #include "party_menu.h" @@ -49,11 +51,6 @@ #include "tv.h" #include "window.h" -extern u16 sub_81A89A0(u8); -extern void sub_81A8AF8(void); -extern void sub_81A895C(void); -extern void sub_81A8934(u8); - typedef u16 (*SpecialFunc)(void); typedef void (*NativeFunc)(void); @@ -66,8 +63,6 @@ static EWRAM_DATA u16 sMovingNpcMapBank = 0; static EWRAM_DATA u16 sMovingNpcMapId = 0; static EWRAM_DATA u16 sFieldEffectScriptId = 0; -extern u16 gSpecialVar_ContestCategory; - IWRAM_DATA u8 gUnknown_03000F30; extern const SpecialFunc gSpecials[]; @@ -2157,13 +2152,13 @@ bool8 ScrCmd_mossdeepgym1(struct ScriptContext *ctx) { u16 v1 = VarGet(ScriptReadHalfword(ctx)); - sMovingNpcId = sub_81A89A0(v1); + sMovingNpcId = MossdeepGym_MoveEvents(v1); return FALSE; } bool8 ScrCmd_mossdeepgym2(struct ScriptContext *ctx) { - sub_81A8AF8(); + MossdeepGym_TurnEvents(); return FALSE; } @@ -2171,13 +2166,13 @@ bool8 ScrCmd_mossdeepgym3(struct ScriptContext *ctx) { u16 v1 = VarGet(ScriptReadHalfword(ctx)); - sub_81A8934(v1); + InitMossdeepGymTiles(v1); return FALSE; } bool8 ScrCmd_mossdeepgym4(struct ScriptContext *ctx) { - sub_81A895C(); + FinishMossdeepGymTiles(); return FALSE; } @@ -2204,7 +2199,7 @@ bool8 ScrCmd_cmdD9(struct ScriptContext *ctx) } } -// This command will force the Pokémon to be obedient, you don't get to make it disobedient +// This command will force the Pokémon to be obedient, you don't get to make it disobedient. bool8 ScrCmd_setmonobedient(struct ScriptContext *ctx) { bool8 obedient = TRUE; diff --git a/src/start_menu.c b/src/start_menu.c index 976cbe2a63..455d26509a 100644 --- a/src/start_menu.c +++ b/src/start_menu.c @@ -35,6 +35,7 @@ #include "field_player_avatar.h" #include "battle_pyramid_bag.h" #include "battle_pike.h" +#include "new_game.h" // Menu actions enum @@ -63,6 +64,10 @@ enum SAVE_ERROR }; +// IWRAM common +bool8 (*gMenuCallback)(void); + +// EWRAM EWRAM_DATA static u8 sSafariBallsWindowId = 0; EWRAM_DATA static u8 sBattlePyramidFloorWindowId = 0; EWRAM_DATA static u8 sStartMenuCursorPos = 0; @@ -76,7 +81,6 @@ EWRAM_DATA static bool8 sSavingComplete = FALSE; EWRAM_DATA static u8 sSaveInfoWindowId = 0; // Extern variables. -extern u8 gDifferentSaveFile; extern u8 gUnknown_03005DB4; // Extern functions in not decompiled files. diff --git a/src/string_util.c b/src/string_util.c index 3fbf79d87e..8ce9a97edc 100644 --- a/src/string_util.c +++ b/src/string_util.c @@ -2,7 +2,11 @@ #include "string_util.h" #include "text.h" -EWRAM_DATA u8 gUnknownStringVar[16] = {0}; +EWRAM_DATA u8 gStringVar1[0x100] = {0}; +EWRAM_DATA u8 gStringVar2[0x100] = {0}; +EWRAM_DATA u8 gStringVar3[0x100] = {0}; +EWRAM_DATA u8 gStringVar4[0x3E8] = {0}; +EWRAM_DATA static u8 sUnknownStringVar[16] = {0}; static const u8 sDigits[] = __("0123456789ABCDEF"); @@ -421,7 +425,7 @@ u8 *StringBraille(u8 *dest, const u8 *src) static const u8 *ExpandPlaceholder_UnknownStringVar(void) { - return gUnknownStringVar; + return sUnknownStringVar; } static const u8 *ExpandPlaceholder_PlayerName(void) diff --git a/src/title_screen.c b/src/title_screen.c index 40e0f5b2fb..70a1a34494 100644 --- a/src/title_screen.c +++ b/src/title_screen.c @@ -1,4 +1,5 @@ #include "global.h" +#include "battle.h" #include "title_screen.h" #include "sprite.h" #include "gba/m4a_internal.h" @@ -37,8 +38,6 @@ #define A_B_START_SELECT (A_BUTTON | B_BUTTON | START_BUTTON | SELECT_BUTTON) extern struct MusicPlayerInfo gMPlayInfo_BGM; -extern u16 gBattle_BG1_X; -extern u16 gBattle_BG1_Y; // this file's functions static void MainCB2(void); diff --git a/sym_bss.txt b/sym_bss.txt index 0b0d31b692..7c11615283 100644 --- a/sym_bss.txt +++ b/sym_bss.txt @@ -32,22 +32,7 @@ .include "src/menu_helpers.o" .include "src/region_map.o" .include "src/slot_machine.o" - -gUnknown_030011F0: @ 30011F0 - .space 0x2 - -gUnknown_030011F2: @ 30011F2 - .space 0x2 - -gUnknown_030011F4: @ 30011F4 - .space 0x2 - -gUnknown_030011F6: @ 30011F6 - .space 0x1 - -gUnknown_030011F7: @ 30011F7 - .space 0x1 - + .include "src/contest_painting.o" .include "src/starter_choose.o" .align 0x2 @@ -75,13 +60,7 @@ gUnknown_03001204: @ 3001204 .include "src/battle_pike.o" .include "src/battle_tent.o" .include "src/multiboot.o" - - .space 0x4 @ XXX: why is this needed? - - .align 2 -gUnknown_030012A8: @ 30012A8 - .space 0x10 - + .include "src/fossil_specials.o" .include "src/berry_fix_program.o" gUnknown_030012BC: @ 30012BC diff --git a/sym_common.txt b/sym_common.txt index 70c6e48715..fd04883b7c 100644 --- a/sym_common.txt +++ b/sym_common.txt @@ -1,157 +1,125 @@ - .space 0x8 - .include "main.o" - .include "bg.o" - .include "window.o" - .include "text.o" - .include "sprite.o" - .include "link.o" - .include "link_rfu.o" + .space 0x8 + .include "main.o" + .include "bg.o" + .include "window.o" + .include "text.o" + .include "sprite.o" + .include "link.o" + .include "link_rfu.o" .include "rtc.o" .include "battle_main.o" .include "random.o" .include "load_save.o" - -gInGameOpponentsNo: @ 3005D98 - .space 0x4 - -gBGTilemapBuffers1: @ 3005D9C - .space 0x4 - -gBGTilemapBuffers2: @ 3005DA0 - .space 0x4 - -gBGTilemapBuffers3: @ 3005DA4 - .space 0x4 - + .include "berry_blender.o" .include "overworld.o" .include "fieldmap.o" .include "field_camera.o" .include "field_control_avatar.o" - -gMenuCallback: @ 3005DF4 - .space 0x4 - + .include "start_menu.o" .include "sound.o" - .include "task.o" - .include "trainer_see.o" - -gUnknown_030060B0: @ 30060B0 - .space 0x4 - -gUnknown_030060B4: @ 30060B4 - .space 0x4 - - .include "contest.o" + .include "task.o" + .include "trainer_see.o" + .include "pokedex.o" + .include "contest.o" .include "tv.o" .include "mauville_old_man.o" gUnknown_03006164: @ 3006164 - .space 0x4 + .space 0x4 gUnknown_03006168: @ 3006168 - .space 0x4 + .space 0x4 gUnknown_0300616C: @ 300616C - .space 0x4 + .space 0x4 gUnknown_03006170: @ 3006170 - .space 0x4 + .space 0x4 gUnknown_03006174: @ 3006174 - .space 0x4 + .space 0x4 gUnknown_03006178: @ 3006178 - .space 0x4 + .space 0x4 gUnknown_0300617C: @ 300617C - .space 0x4 + .space 0x4 gUnknown_03006180: @ 3006180 - .space 0x4 + .space 0x4 gUnknown_03006184: @ 3006184 - .space 0x4 + .space 0x4 gUnknown_03006188: @ 3006188 - .space 0x8 + .space 0x8 gUnknown_03006190: @ 3006190 - .space 0x10 + .space 0x10 gUnknown_030061A0: @ 30061A0 - .space 0x20 + .space 0x20 gUnknown_030061C0: @ 30061C0 - .space 0x4 + .space 0x4 gUnknown_030061C4: @ 30061C4 - .space 0xC + .space 0xC .include "field_specials.o" gCB2_AfterEvolution: @ 30061E8 - .space 0x4 + .space 0x4 gUnknown_030061EC: @ 30061EC - .space 0x4 + .space 0x4 .include "save.o" - -gUnknown_03006298: @ 3006298 - .space 0x8 - + .include "battle_tower.o" .include "intro.o" gUnknown_030062DC: @ 30062DC - .space 0x4 + .space 0x4 gUnknown_030062E0: @ 30062E0 - .space 0x4 + .space 0x4 gUnknown_030062E4: @ 30062E4 - .space 0x4 + .space 0x4 -gUnknown_030062E8: @ 30062E8 - .space 0x4 - -gUnknown_030062EC: @ 30062EC - .space 0x4 - -gUnknown_030062F0: @ 30062F0 - .space 0x4 - -gUnknown_030062F4: @ 30062F4 - .space 0xC - - .include "list_menu.o" + .include "battle_factory_screen.o" + .include "apprentice.o" + + .space 0x8 + + .include "list_menu.o" gUnknown_03006328: @ 3006328 - .space 0x48 + .space 0x48 gUnknown_03006370: @ 3006370 - .space 0x10 + .space 0x10 - .include "m4a_2.o" - - .include "agb_flash.o" + .include "m4a_2.o" + .include "agb_flash.o" gRfuState: @ 3007868 - .space 0x8 + .space 0x8 gUnknown_03007870: @ 3007870 - .space 0x10 + .space 0x10 gUnknown_03007880: @ 3007880 - .space 0x10 + .space 0x10 gUnknown_03007890: @ 3007890 - .space 0x4 + .space 0x4 gUnknown_03007894: @ 3007894 - .space 0x4 + .space 0x4 gUnknown_03007898: @ 3007898 - .space 0x8 + .space 0x8 gUnknown_030078A0: @ 30078A0 - .space 0xC + .space 0xC diff --git a/sym_ewram.txt b/sym_ewram.txt index 484f52d050..bff045d1cc 100644 --- a/sym_ewram.txt +++ b/sym_ewram.txt @@ -3,20 +3,6 @@ .include "src/window.o" .include "src/text.o" .include "src/sprite.o" - .align 2 - -gStringVar1: @ 2021CC4 - .space 0x100 - -gStringVar2: @ 2021DC4 - .space 0x100 - -gStringVar3: @ 2021EC4 - .space 0x100 - -gStringVar4: @ 2021FC4 - .space 0x3E8 - .include "src/string_util.o" .include "src/link.o" .include "src/link_rfu.o" @@ -117,8 +103,6 @@ gUnknown_02022CFC: @ 2022CFC gUnknown_02022D00: @ 2022D00 .space 0x4 -@ src/main_menu.c -gUnknown_02022D04: @ 2022D04 .include "src/main_menu.o" gUnknown_02022D08: @ 2022D08 @@ -138,42 +122,6 @@ gUnknown_02022D0C: @ 2022D0C gUnknown_02022E10: @ 2022E10 .space 0x4 -gBattle_BG0_X: @ 2022E14 - .space 0x2 - -gBattle_BG0_Y: @ 2022E16 - .space 0x2 - -gBattle_BG1_X: @ 2022E18 - .space 0x2 - -gBattle_BG1_Y: @ 2022E1A - .space 0x2 - -gBattle_BG2_X: @ 2022E1C - .space 0x2 - -gBattle_BG2_Y: @ 2022E1E - .space 0x2 - -gBattle_BG3_X: @ 2022E20 - .space 0x2 - -gBattle_BG3_Y: @ 2022E22 - .space 0x2 - -gBattle_WIN0H: @ 2022E24 - .space 0x2 - -gBattle_WIN0V: @ 2022E26 - .space 0x2 - -gBattle_WIN1H: @ 2022E28 - .space 0x2 - -gBattle_WIN1V: @ 2022E2A - .space 0x2 - .include "src/battle_main.o" .include "src/pokemon.o" .include "src/random.o" @@ -199,13 +147,7 @@ gUnknown_020322A0: @ 20322A0 .space 0x4 .include "src/berry_blender.o" - -gDifferentSaveFile: @ 20322D4 - .space 0x1 - -gUnknown_020322D5: @ 20322D5 - .space 0x3 - + .include "src/new_game.o" .include "src/overworld.o" .include "src/fieldmap.o" .include "src/field_camera.o" @@ -381,8 +323,7 @@ gUnknown_0203A0F8: @ 203A0F8 gUnknown_0203A100: @ 203A100 .space 0x10 -gUnknown_0203A110: @ 203A110 - .space 0x4 + .include "src/battle_anim_utility_funcs.o" gUnknown_0203A114: @ 203A114 .space 0x4 @@ -395,6 +336,7 @@ gUnknown_0203A11C: @ 203A11C gUnknown_0203A120: @ 203A120 .space 0x4 + .include "src/mon_markings.o" .include "src/mauville_old_man.o" .include "src/mail.o" @@ -459,9 +401,6 @@ gUnknown_0203ABB5: @ 203ABB5 .include "src/rom_81520A8.o" .include "src/save.o" - -.space 0x4 /*unused var?*/ - .include "src/mystery_event_script.o" .include "src/learn_move.o" .include "src/decoration_inventory.o" @@ -494,13 +433,7 @@ gUnknown_0203CD88: @ 203CD88 .include "src/menu.o" .include "src/battle_factory_screen.o" - -gUnknown_0203CE50: @ 203CE50 - .space 0x4 - -gUnknown_0203CE54: @ 203CE54 - .align 2 - + .include "src/mossdeep_gym.o" .include "src/item_menu.o" .include "src/list_menu.o" .include "src/dynamic_placeholder_text_util.o"