diff --git a/asm/pokenav_unk_2.s b/asm/pokenav_unk_2.s deleted file mode 100644 index d74a485a8..000000000 --- a/asm/pokenav_unk_2.s +++ /dev/null @@ -1,787 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .syntax unified - -@ File centered around AllocSubstruct(2) - - thumb_func_start sub_81CA4AC -sub_81CA4AC: @ 81CA4AC - push {r4,r5,lr} - adds r4, r0, 0 - ldrh r1, [r4, 0x2E] - movs r2, 0x2E - ldrsh r0, [r4, r2] - cmp r0, 0 - bne _081CA574 - movs r0, 0x30 - ldrsh r5, [r4, r0] - cmp r5, 0 - bne _081CA4E2 - adds r0, r4, 0 - movs r1, 0x1 - bl StartSpriteAffineAnim - ldrh r0, [r4, 0x30] - adds r0, 0x1 - strh r0, [r4, 0x30] - movs r0, 0x80 - lsls r0, 1 - strh r0, [r4, 0x32] - ldrh r0, [r4, 0x24] - ldrh r1, [r4, 0x20] - adds r0, r1 - strh r0, [r4, 0x20] - strh r5, [r4, 0x24] - b _081CA578 -_081CA4E2: - ldrh r0, [r4, 0x32] - adds r0, 0x10 - strh r0, [r4, 0x32] - movs r2, 0x32 - ldrsh r0, [r4, r2] - asrs r1, r0, 3 - adds r0, r1, 0 - subs r0, 0x20 - lsrs r1, r0, 31 - adds r0, r1 - asrs r1, r0, 1 - movs r2, 0x3C - ldrsh r0, [r4, r2] - cmp r0, 0x1 - beq _081CA518 - cmp r0, 0x1 - bgt _081CA50A - cmp r0, 0 - beq _081CA514 - b _081CA526 -_081CA50A: - cmp r0, 0x2 - beq _081CA51C - cmp r0, 0x3 - beq _081CA520 - b _081CA526 -_081CA514: - negs r1, r1 - b _081CA520 -_081CA518: - negs r0, r1 - b _081CA524 -_081CA51C: - strh r1, [r4, 0x24] - b _081CA526 -_081CA520: - lsls r0, r1, 1 - adds r0, r1 -_081CA524: - strh r0, [r4, 0x24] -_081CA526: - adds r0, r4, 0 - adds r0, 0x3F - ldrb r1, [r0] - movs r0, 0x20 - ands r0, r1 - cmp r0, 0 - beq _081CA578 - adds r2, r4, 0 - adds r2, 0x3E - ldrb r0, [r2] - movs r1, 0x4 - orrs r0, r1 - strb r0, [r2] - ldrb r0, [r4, 0x3] - lsls r0, 26 - lsrs r0, 27 - bl FreeOamMatrix - ldrb r1, [r4, 0x1] - lsrs r1, 6 - ldrb r2, [r4, 0x3] - lsrs r2, 6 - adds r0, r4, 0 - movs r3, 0 - bl CalcCenterToCornerVec - ldrb r1, [r4, 0x1] - movs r0, 0x4 - negs r0, r0 - ands r0, r1 - movs r1, 0xD - negs r1, r1 - ands r0, r1 - strb r0, [r4, 0x1] - ldr r0, =SpriteCallbackDummy - str r0, [r4, 0x1C] - b _081CA578 - .pool -_081CA574: - subs r0, r1, 0x1 - strh r0, [r4, 0x2E] -_081CA578: - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end sub_81CA4AC - - thumb_func_start sub_81CA580 -sub_81CA580: @ 81CA580 - push {r4,r5,lr} - lsls r0, 24 - lsrs r5, r0, 24 - lsls r0, r5, 2 - adds r0, r5 - lsls r0, 3 - ldr r1, =gTasks + 0x8 - adds r4, r0, r1 - ldrh r0, [r4] - movs r1, 0 - ldrsh r2, [r4, r1] - cmp r2, 0 - bne _081CA634 - movs r0, 0x2 - ldrsh r1, [r4, r0] - cmp r1, 0 - beq _081CA5AC - cmp r1, 0x1 - beq _081CA5CC - b _081CA638 - .pool -_081CA5AC: - movs r0, 0x10 - strh r0, [r4, 0x4] - strh r2, [r4, 0x6] - movs r1, 0xFC - lsls r1, 6 - movs r0, 0x50 - bl SetGpuReg - movs r0, 0x52 - movs r1, 0x10 - bl SetGpuReg - ldrh r0, [r4, 0x2] - adds r0, 0x1 - strh r0, [r4, 0x2] - b _081CA638 -_081CA5CC: - ldrh r0, [r4, 0x8] - ands r1, r0 - cmp r1, 0 - beq _081CA5E4 - ldrh r0, [r4, 0x4] - subs r0, 0x3 - strh r0, [r4, 0x4] - lsls r0, 16 - cmp r0, 0 - bge _081CA5F6 - strh r2, [r4, 0x4] - b _081CA5F6 -_081CA5E4: - ldrh r0, [r4, 0x6] - adds r0, 0x3 - strh r0, [r4, 0x6] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0x10 - ble _081CA5F6 - movs r0, 0x10 - strh r0, [r4, 0x6] -_081CA5F6: - ldrh r1, [r4, 0x6] - lsls r1, 8 - ldrh r0, [r4, 0x4] - orrs r1, r0 - lsls r1, 16 - lsrs r1, 16 - movs r0, 0x52 - bl SetGpuReg - ldrh r0, [r4, 0x8] - adds r0, 0x1 - strh r0, [r4, 0x8] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0xC - bne _081CA638 - movs r0, 0x2 - bl GetSubstructPtr - ldrb r1, [r0, 0xC] - subs r1, 0x1 - strb r1, [r0, 0xC] - movs r1, 0x80 - lsls r1, 5 - movs r0, 0x52 - bl SetGpuReg - adds r0, r5, 0 - bl DestroyTask - b _081CA638 -_081CA634: - subs r0, 0x1 - strh r0, [r4] -_081CA638: - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end sub_81CA580 - - thumb_func_start sub_81CA640 -sub_81CA640: @ 81CA640 - push {r4,lr} - movs r0, 0x2 - bl GetSubstructPtr - adds r4, r0, 0 - ldr r0, =gUnknown_0862036C - movs r1, 0x10 - movs r2, 0x60 - movs r3, 0x4 - bl CreateSprite - lsls r0, 24 - lsrs r0, 24 - lsls r1, r0, 4 - adds r1, r0 - lsls r1, 2 - ldr r0, =gSprites - adds r1, r0 - str r1, [r4, 0x28] - bl sub_81C98D4 - cmp r0, 0 - beq _081CA684 - ldr r1, [r4, 0x28] - ldr r0, =sub_81CA6AC - str r0, [r1, 0x1C] - b _081CA690 - .pool -_081CA684: - ldr r0, [r4, 0x28] - adds r0, 0x3E - ldrb r1, [r0] - movs r2, 0x4 - orrs r1, r2 - strb r1, [r0] -_081CA690: - pop {r4} - pop {r0} - bx r0 - thumb_func_end sub_81CA640 - - thumb_func_start sub_81CA698 -sub_81CA698: @ 81CA698 - push {lr} - movs r0, 0x2 - bl GetSubstructPtr - ldr r0, [r0, 0x28] - bl DestroySprite - pop {r0} - bx r0 - thumb_func_end sub_81CA698 - - thumb_func_start sub_81CA6AC -sub_81CA6AC: @ 81CA6AC - push {lr} - adds r3, r0, 0 - ldrh r0, [r3, 0x2E] - adds r0, 0x1 - strh r0, [r3, 0x2E] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0x8 - ble _081CA6DA - movs r0, 0 - strh r0, [r3, 0x2E] - adds r3, 0x3E - ldrb r2, [r3] - lsls r0, r2, 29 - lsrs r0, 31 - movs r1, 0x1 - eors r1, r0 - lsls r1, 2 - movs r0, 0x5 - negs r0, r0 - ands r0, r2 - orrs r0, r1 - strb r0, [r3] -_081CA6DA: - pop {r0} - bx r0 - thumb_func_end sub_81CA6AC - - thumb_func_start sub_81CA6E0 -sub_81CA6E0: @ 81CA6E0 - push {r4,lr} - movs r0, 0x2 - bl GetSubstructPtr - adds r4, r0, 0 - ldr r0, =gUnknown_086202CC - bl AddWindow - strh r0, [r4, 0x8] - lsls r0, 24 - lsrs r0, 24 - bl PutWindowTilemap - ldrb r0, [r4, 0x8] - movs r1, 0x66 - bl FillWindowPixelBuffer - ldrb r0, [r4, 0x8] - movs r1, 0x3 - bl CopyWindowToVram - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81CA6E0 - - thumb_func_start sub_81CA714 -sub_81CA714: @ 81CA714 - push {r4-r6,lr} - sub sp, 0xC - movs r0, 0x2 - bl GetSubstructPtr - adds r5, r0, 0 - bl sub_81C98B4 - ldr r1, =gUnknown_086202D4 - lsls r0, 2 - adds r0, r1 - ldr r6, [r0] - movs r2, 0x1 - negs r2, r2 - movs r0, 0x1 - adds r1, r6, 0 - bl GetStringWidth - adds r4, r0, 0 - ldrb r0, [r5, 0x8] - movs r1, 0x66 - bl FillWindowPixelBuffer - ldrb r0, [r5, 0x8] - movs r2, 0xC0 - subs r2, r4 - lsrs r2, 1 - lsls r2, 24 - lsrs r2, 24 - ldr r1, =gUnknown_0862030C - str r1, [sp] - movs r1, 0 - str r1, [sp, 0x4] - str r6, [sp, 0x8] - movs r1, 0x1 - movs r3, 0x1 - bl AddTextPrinterParameterized3 - add sp, 0xC - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81CA714 - - thumb_func_start sub_81CA770 -sub_81CA770: @ 81CA770 - push {r4-r6,lr} - sub sp, 0xC - movs r0, 0x2 - bl GetSubstructPtr - adds r5, r0, 0 - ldr r6, =gText_NoRibbonWinners - movs r2, 0x1 - negs r2, r2 - movs r0, 0x1 - adds r1, r6, 0 - bl GetStringWidth - adds r4, r0, 0 - ldrb r0, [r5, 0x8] - movs r1, 0x66 - bl FillWindowPixelBuffer - ldrb r0, [r5, 0x8] - movs r2, 0xC0 - subs r2, r4 - lsrs r2, 1 - lsls r2, 24 - lsrs r2, 24 - ldr r1, =gUnknown_0862030F - str r1, [sp] - movs r1, 0 - str r1, [sp, 0x4] - str r6, [sp, 0x8] - movs r1, 0x1 - movs r3, 0x1 - bl AddTextPrinterParameterized3 - add sp, 0xC - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81CA770 - - thumb_func_start sub_81CA7C4 -sub_81CA7C4: @ 81CA7C4 - push {lr} - bl IsDma3ManagerBusyWithBgCopy - lsls r0, 24 - lsrs r0, 24 - pop {r1} - bx r1 - thumb_func_end sub_81CA7C4 - - thumb_func_start sub_81CA7D4 -sub_81CA7D4: @ 81CA7D4 - push {r4,lr} - movs r0, 0x2 - bl GetSubstructPtr - adds r4, r0, 0 - ldr r0, =sub_81CA808 - movs r1, 0x2 - bl CreateTask - strb r0, [r4, 0xA] - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81CA7D4 - - thumb_func_start sub_81CA7F4 -sub_81CA7F4: @ 81CA7F4 - push {lr} - movs r0, 0x2 - bl GetSubstructPtr - ldrb r0, [r0, 0xA] - bl DestroyTask - pop {r0} - bx r0 - thumb_func_end sub_81CA7F4 - - thumb_func_start sub_81CA808 -sub_81CA808: @ 81CA808 - push {lr} - movs r0, 0x3 - movs r1, 0x80 - movs r2, 0x1 - bl ChangeBgX - pop {r0} - bx r0 - thumb_func_end sub_81CA808 - - thumb_func_start sub_81CA818 -sub_81CA818: @ 81CA818 - push {r4,r5,lr} - ldr r0, =sub_81CA8B0 - movs r1, 0x3 - bl CreateTask - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - ldr r5, =gUnknown_0861FC78 + 2 - adds r0, r4, 0 - movs r1, 0x1 - adds r2, r5, 0 - bl SetWordTaskArg - adds r5, 0xC - adds r0, r4, 0 - movs r1, 0x3 - adds r2, r5, 0 - bl SetWordTaskArg - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81CA818 - - thumb_func_start sub_81CA850 -sub_81CA850: @ 81CA850 - push {lr} - ldr r0, =gUnknown_0861FC78 + 0xE - movs r1, 0x31 - movs r2, 0x4 - bl CopyPaletteIntoBufferUnfaded - pop {r0} - bx r0 - .pool - thumb_func_end sub_81CA850 - - thumb_func_start sub_81CA864 -sub_81CA864: @ 81CA864 - push {r4,r5,lr} - ldr r0, =sub_81CA8B0 - movs r1, 0x3 - bl CreateTask - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - ldr r5, =gUnknown_0861FC78 + 0xE - adds r0, r4, 0 - movs r1, 0x1 - adds r2, r5, 0 - bl SetWordTaskArg - subs r5, 0xC - adds r0, r4, 0 - movs r1, 0x3 - adds r2, r5, 0 - bl SetWordTaskArg - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81CA864 - - thumb_func_start sub_81CA89C -sub_81CA89C: @ 81CA89C - push {lr} - ldr r0, =sub_81CA8B0 - bl FuncIsActiveTask - lsls r0, 24 - lsrs r0, 24 - pop {r1} - bx r1 - .pool - thumb_func_end sub_81CA89C - - thumb_func_start sub_81CA8B0 -sub_81CA8B0: @ 81CA8B0 - push {r4-r6,lr} - sub sp, 0xC - lsls r0, 24 - lsrs r6, r0, 24 - lsls r4, r6, 2 - adds r4, r6 - lsls r4, 3 - ldr r0, =gTasks + 0x8 - adds r4, r0 - adds r0, r6, 0 - movs r1, 0x1 - bl GetWordTaskArg - adds r5, r0, 0 - adds r0, r6, 0 - movs r1, 0x3 - bl GetWordTaskArg - adds r1, r0, 0 - ldrh r0, [r4] - adds r0, 0x1 - strh r0, [r4] - lsls r0, 16 - asrs r0, 16 - str r0, [sp] - add r0, sp, 0x8 - str r0, [sp, 0x4] - adds r0, r5, 0 - movs r2, 0x2 - movs r3, 0xC - bl sub_81C79BC - add r0, sp, 0x8 - movs r1, 0x31 - movs r2, 0x4 - bl LoadPalette - movs r1, 0 - ldrsh r0, [r4, r1] - cmp r0, 0xC - bne _081CA908 - adds r0, r6, 0 - bl DestroyTask -_081CA908: - add sp, 0xC - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81CA8B0 - - thumb_func_start sub_81CA914 -sub_81CA914: @ 81CA914 - push {lr} - bl TransferPlttBuffer - bl LoadOam - bl ProcessSpriteCopyRequests - bl ScanlineEffect_InitHBlankDmaTransfer - pop {r0} - bx r0 - thumb_func_end sub_81CA914 - - thumb_func_start titlescreen_0 -titlescreen_0: @ 81CA92C - push {lr} - movs r0, 0x50 - movs r1, 0x90 - bl SetGpuReg - movs r0, 0x54 - movs r1, 0 - bl SetGpuReg - movs r1, 0x80 - lsls r1, 6 - movs r0, 0 - bl SetGpuRegBits - movs r0, 0x48 - movs r1, 0x3F - bl SetGpuRegBits - movs r0, 0x4A - movs r1, 0x1F - bl SetGpuRegBits - movs r0, 0x44 - movs r1, 0xA0 - bl SetGpuRegBits - bl ScanlineEffect_Stop - bl sub_81CAA3C - ldr r2, =gUnknown_08620384 - ldr r0, [r2] - ldr r1, [r2, 0x4] - ldr r2, [r2, 0x8] - bl ScanlineEffect_SetParams - ldr r0, =sub_81CA914 - bl SetVBlankCallback_ - ldr r0, =sub_81CA9EC - movs r1, 0x3 - bl CreateTask - pop {r0} - bx r0 - .pool - thumb_func_end titlescreen_0 - - thumb_func_start sub_81CA994 -sub_81CA994: @ 81CA994 - push {lr} - movs r0, 0x50 - movs r1, 0 - bl SetGpuReg - movs r1, 0x80 - lsls r1, 6 - movs r0, 0 - bl ClearGpuRegBits - bl ScanlineEffect_Stop - ldr r0, =sub_81CA9EC - bl FindTaskIdByFunc - lsls r0, 24 - lsrs r0, 24 - bl DestroyTask - bl SetPokenavVBlankCallback - pop {r0} - bx r0 - .pool - thumb_func_end sub_81CA994 - - thumb_func_start sub_81CA9C8 -sub_81CA9C8: @ 81CA9C8 - push {lr} - movs r0, 0x50 - movs r1, 0 - bl SetGpuReg - pop {r0} - bx r0 - thumb_func_end sub_81CA9C8 - - thumb_func_start sub_81CA9D8 -sub_81CA9D8: @ 81CA9D8 - push {lr} - bl sub_81CAA3C - movs r0, 0x50 - movs r1, 0x90 - bl SetGpuReg - pop {r0} - bx r0 - thumb_func_end sub_81CA9D8 - - thumb_func_start sub_81CA9EC -sub_81CA9EC: @ 81CA9EC - push {lr} - lsls r0, 24 - lsrs r0, 24 - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 3 - ldr r0, =gTasks + 0x8 - adds r2, r1, r0 - ldrh r0, [r2] - adds r0, 0x1 - strh r0, [r2] - lsls r0, 16 - cmp r0, 0 - ble _081CAA30 - movs r0, 0 - strh r0, [r2] - ldrh r0, [r2, 0x2] - adds r0, 0x3 - movs r1, 0x7F - ands r0, r1 - strh r0, [r2, 0x2] - ldr r1, =gSineTable - movs r3, 0x2 - ldrsh r0, [r2, r3] - lsls r0, 1 - adds r0, r1 - ldrh r1, [r0] - lsls r1, 16 - asrs r1, 21 - lsls r1, 16 - lsrs r1, 16 - movs r0, 0x54 - bl SetGpuReg -_081CAA30: - pop {r0} - bx r0 - .pool - thumb_func_end sub_81CA9EC - - thumb_func_start sub_81CAA3C -sub_81CAA3C: @ 81CAA3C - push {r4-r6,lr} - mov r6, r9 - mov r5, r8 - push {r5,r6} - sub sp, 0x8 - bl sub_81C9894 - adds r4, r0, 0 - bl sub_81C98A4 - ldr r2, =gUnknown_08620240 - lsls r1, r4, 3 - subs r1, r4 - lsls r1, 2 - adds r1, r2 - ldrh r2, [r1, 0x2] - adds r4, r2, 0 - muls r4, r0 - ldrh r1, [r1] - adds r4, r1 - subs r4, 0x8 - mov r0, sp - movs r6, 0 - strh r6, [r0] - ldr r5, =gScanlineEffectRegBuffers - ldr r0, =0x010000a0 - mov r8, r0 - mov r0, sp - adds r1, r5, 0 - mov r2, r8 - bl CpuSet - mov r0, sp - adds r0, 0x2 - strh r6, [r0] - movs r1, 0xF0 - lsls r1, 3 - adds r1, r5 - mov r9, r1 - mov r2, r8 - bl CpuSet - add r0, sp, 0x4 - ldr r1, =0x000072f0 - adds r6, r1, 0 - strh r6, [r0] - lsls r4, 1 - adds r5, r4, r5 - ldr r1, =0x01000010 - mov r8, r1 - adds r1, r5, 0 - mov r2, r8 - bl CpuSet - mov r0, sp - adds r0, 0x6 - strh r6, [r0] - add r4, r9 - adds r1, r4, 0 - mov r2, r8 - bl CpuSet - add sp, 0x8 - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81CAA3C - - thumb_func_start sub_81CAADC -sub_81CAADC: @ 81CAADC - push {lr} - bl sub_81CA9C8 - pop {r0} - bx r0 - thumb_func_end sub_81CAADC - - .align 2, 0 @ Don't pad with nop. diff --git a/include/pokenav.h b/include/pokenav.h index ecf66de51..75f08a9e9 100644 --- a/include/pokenav.h +++ b/include/pokenav.h @@ -152,8 +152,9 @@ u32 sub_81C941C(void); void sub_81C9430(void); int sub_81C9894(void); const u8 *sub_81CAF78(int index, u8 *arg1); -u16 sub_81C98C4(void); int sub_81C98A4(void); +int sub_81C98B4(void); +u16 sub_81C98C4(void); // pokenav_unk_2.c void sub_81C99D4(void); diff --git a/include/strings.h b/include/strings.h index 97285b051..f2d3f23ad 100644 --- a/include/strings.h +++ b/include/strings.h @@ -2766,6 +2766,7 @@ extern const u8 gUnknown_085EBE06[]; extern const u8 gUnknown_085EBE19[]; extern const u8 gUnknown_085EBE2D[]; extern const u8 gUnknown_085EBE41[]; +extern const u8 gText_NoRibbonWinners[]; // pokenav_unk_4 extern const u8 gUnknown_085EC017[]; diff --git a/ld_script.txt b/ld_script.txt index 769df23f8..f3531344b 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -310,7 +310,6 @@ SECTIONS { src/pokenav_match_call_ui.o(.text); src/pokenav_unk_1.o(.text); src/pokenav_unk_2.o(.text); - asm/pokenav_unk_2.o(.text); src/pokenav_unk_3.o(.text); src/pokenav_unk_4.o(.text); src/pokenav_unk_5.o(.text); diff --git a/src/pokenav_unk_2.c b/src/pokenav_unk_2.c index b428e20c6..a21109316 100644 --- a/src/pokenav_unk_2.c +++ b/src/pokenav_unk_2.c @@ -2,6 +2,8 @@ #include "alloc.h" #include "decompress.h" #include "bg.h" +#include "palette.h" +#include "trig.h" #include "gpu_regs.h" #include "menu.h" #include "window.h" @@ -20,14 +22,13 @@ struct Pokenav2Struct { bool32 (*callback)(void); u32 loopedTaskId; - u8 field_008; - u8 field_009; + u16 field_008; u8 field_00a; u8 field_00b; u8 field_00c; u8 field_00d; bool32 field_010[6]; - u8 filler_028[4]; + struct Sprite * field_028; struct Sprite * field_02c[6][4]; u8 field_08c[0x800]; }; @@ -60,6 +61,7 @@ void sub_81CA474(struct Sprite * sprite); void sub_81CA4AC(struct Sprite * sprite); void sub_81CA580(u8 taskId); void sub_81CA640(void); +void sub_81CA6AC(struct Sprite * sprite); void sub_81CA698(void); void sub_81CA6E0(void); void sub_81CA714(void); @@ -67,14 +69,17 @@ void sub_81CA770(void); bool32 sub_81CA7C4(void); void sub_81CA7D4(void); void sub_81CA7F4(void); +void sub_81CA808(u8 taskId); void sub_81CA818(void); void sub_81CA850(void); void sub_81CA864(void); bool32 sub_81CA89C(void); +void sub_81CA8B0(u8 taskId); void titlescreen_0(void); void sub_81CA994(void); void sub_81CA9C8(void); void sub_81CA9D8(void); +void sub_81CA9EC(u8 taskId); void sub_81CAA3C(void); extern const u32 gPokenavOptions_Gfx[]; @@ -987,3 +992,286 @@ void sub_81CA474(struct Sprite * sprite) sprite->callback = SpriteCallbackDummy; } } + +void sub_81CA4AC(struct Sprite * sprite) +{ + s32 r0; + s32 r1; + if (sprite->data[0] == 0) + { + if (sprite->data[1] == 0) + { + StartSpriteAffineAnim(sprite, 1); + sprite->data[1]++; + sprite->data[2] = 0x100; + sprite->pos1.x += sprite->pos2.x; + sprite->pos2.x = 0; + } + else + { + sprite->data[2] += 16; + r0 = sprite->data[2]; + r1 = r0 >> 3; + r1 = (r1 - 32) / 2; + switch (sprite->data[7]) + { + case 0: + sprite->pos2.x = -r1 * 3; + break; + case 1: + sprite->pos2.x = -r1; + break; + case 2: + sprite->pos2.x = r1; + break; + case 3: + sprite->pos2.x = r1 * 3; + break; + } + if (sprite->affineAnimEnded) + { + sprite->invisible = TRUE; + FreeOamMatrix(sprite->oam.matrixNum); + CalcCenterToCornerVec(sprite, sprite->oam.shape, sprite->oam.size, 0); + sprite->oam.affineMode = ST_OAM_AFFINE_OFF; + sprite->oam.objMode = ST_OAM_OBJ_NORMAL; + sprite->callback = SpriteCallbackDummy; + } + } + } + else + { + sprite->data[0]--; + } +} + +void sub_81CA580(u8 taskId) +{ + s16 * data = gTasks[taskId].data; + + if (data[0] == 0) + { + switch (data[1]) + { + case 0: + data[2] = 16; + data[3] = 0; + SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_EFFECT_NONE | BLDCNT_TGT2_ALL); + SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(0x10, 0x00)); + data[1]++; + break; + case 1: + if (data[4] & 1) + { + data[2] -= 3; + if (data[2] < 0) + data[2] = 0; + } + else + { + data[3] += 3; + if (data[3] > 16) + data[3] = 16; + } + SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(data[2], data[3])); + data[4]++; + if (data[4] == 12) + { + ((struct Pokenav2Struct *)GetSubstructPtr(2))->field_00c--; + SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(0x00, 0x10)); + DestroyTask(taskId); + } + break; + } + } + else + data[0]--; +} + +void sub_81CA640(void) +{ + struct Pokenav2Struct * ptr = GetSubstructPtr(2); + u8 spriteId = CreateSprite(&gUnknown_0862036C, 0x10, 0x60, 4); + ptr->field_028 = &gSprites[spriteId]; + if (sub_81C98D4()) + ptr->field_028->callback = sub_81CA6AC; + else + ptr->field_028->invisible = TRUE; +} + +void sub_81CA698(void) +{ + struct Pokenav2Struct * ptr = GetSubstructPtr(2); + DestroySprite(ptr->field_028); +} + +void sub_81CA6AC(struct Sprite * sprite) +{ + sprite->data[0]++; + if (sprite->data[0] > 8) + { + sprite->data[0] = 0; + sprite->invisible ^= 1; + } +} + +void sub_81CA6E0(void) +{ + struct Pokenav2Struct * ptr = GetSubstructPtr(2); + + ptr->field_008 = AddWindow(&gUnknown_086202CC); + PutWindowTilemap(ptr->field_008); + FillWindowPixelBuffer(ptr->field_008, PIXEL_FILL(6)); + CopyWindowToVram(ptr->field_008, 3); +} + +void sub_81CA714(void) +{ + struct Pokenav2Struct * ptr = GetSubstructPtr(2); + int i = sub_81C98B4(); + const u8 * s = gUnknown_086202D4[i]; + u32 width = GetStringWidth(1, s, -1); + FillWindowPixelBuffer(ptr->field_008, PIXEL_FILL(6)); + AddTextPrinterParameterized3(ptr->field_008, 1, (192 - width) / 2, 1, gUnknown_0862030C, 0, s); +} + + +void sub_81CA770(void) +{ + struct Pokenav2Struct * ptr = GetSubstructPtr(2); + const u8 * s = gText_NoRibbonWinners; + u32 width = GetStringWidth(1, s, -1); + FillWindowPixelBuffer(ptr->field_008, PIXEL_FILL(6)); + AddTextPrinterParameterized3(ptr->field_008, 1, (192 - width) / 2, 1, gUnknown_0862030F, 0, s); +} + +bool32 sub_81CA7C4(void) +{ + return IsDma3ManagerBusyWithBgCopy(); +} + +void sub_81CA7D4(void) +{ + struct Pokenav2Struct * ptr = GetSubstructPtr(2); + ptr->field_00a = CreateTask(sub_81CA808, 2); +} + +void sub_81CA7F4(void) +{ + struct Pokenav2Struct * ptr = GetSubstructPtr(2); + DestroyTask(ptr->field_00a); +} + +void sub_81CA808(u8 taskId) +{ + ChangeBgX(3, 0x80, 1); +} + +void sub_81CA818(void) +{ + u8 taskId = CreateTask(sub_81CA8B0, 3); + SetWordTaskArg(taskId, 1, (uintptr_t)(gUnknown_0861FC78 + 1)); + SetWordTaskArg(taskId, 3, (uintptr_t)(gUnknown_0861FC78 + 7)); +} + +void sub_81CA850(void) +{ + CopyPaletteIntoBufferUnfaded(gUnknown_0861FC78 + 7, 0x31, 4); +} + +void sub_81CA864(void) +{ + u8 taskId = CreateTask(sub_81CA8B0, 3); + SetWordTaskArg(taskId, 1, (uintptr_t)(gUnknown_0861FC78 + 7)); + SetWordTaskArg(taskId, 3, (uintptr_t)(gUnknown_0861FC78 + 1)); +} + +bool32 sub_81CA89C(void) +{ + return FuncIsActiveTask(sub_81CA8B0); +} + +void sub_81CA8B0(u8 taskId) +{ + u16 sp8[2]; + s16 * data = gTasks[taskId].data; + const u16 * pal1 = (const u16 *)GetWordTaskArg(taskId, 1); + const u16 * pal2 = (const u16 *)GetWordTaskArg(taskId, 3); + + sub_81C79BC(pal1, pal2, 2, 12, ++data[0], sp8); + LoadPalette(sp8, 0x31, 4); + if (data[0] == 12) + DestroyTask(taskId); +} + +void sub_81CA914(void) +{ + TransferPlttBuffer(); + LoadOam(); + ProcessSpriteCopyRequests(); + ScanlineEffect_InitHBlankDmaTransfer(); +} + +void titlescreen_0(void) // almost definitely the wrong name +{ + SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_TGT1_OBJ | BLDCNT_EFFECT_LIGHTEN); + SetGpuReg(REG_OFFSET_BLDY, 0); + SetGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_WIN0_ON); + SetGpuRegBits(REG_OFFSET_WININ, 0x3F); + SetGpuRegBits(REG_OFFSET_WINOUT, 0x1F); + SetGpuRegBits(REG_OFFSET_WIN0V, 0xA0); + ScanlineEffect_Stop(); + sub_81CAA3C(); + ScanlineEffect_SetParams(gUnknown_08620384); + SetVBlankCallback_(sub_81CA914); + CreateTask(sub_81CA9EC, 3); +} + +void sub_81CA994(void) +{ + SetGpuReg(REG_OFFSET_BLDCNT, 0); + ClearGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_WIN0_ON); + ScanlineEffect_Stop(); + DestroyTask(FindTaskIdByFunc(sub_81CA9EC)); + SetPokenavVBlankCallback(); +} + +void sub_81CA9C8(void) +{ + SetGpuReg(REG_OFFSET_BLDCNT, 0); +} + +void sub_81CA9D8(void) +{ + sub_81CAA3C(); + SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_TGT1_OBJ | BLDCNT_EFFECT_LIGHTEN); +} + +void sub_81CA9EC(u8 taskId) +{ + s16 * data = gTasks[taskId].data; + data[0]++; + if (data[0] > 0) + { + data[0] = 0; + data[1] += 3; + data[1] &= 0x7F; + SetGpuReg(REG_OFFSET_BLDY, gSineTable[data[1]] >> 5); + } +} + +void sub_81CAA3C(void) +{ + int i = sub_81C9894(); + int j = sub_81C98A4(); + int r4 = gUnknown_08620240[i].unk2 * j + gUnknown_08620240[i].unk0 - 8; + CpuFill16(0, gScanlineEffectRegBuffers[0], 0x140); + CpuFill16(0, gScanlineEffectRegBuffers[1], 0x140); + CpuFill16(0x72F0, &gScanlineEffectRegBuffers[0][r4], 0x20); + CpuFill16(0x72F0, &gScanlineEffectRegBuffers[1][r4], 0x20); +} + +void sub_81CAADC(void) +{ + sub_81CA9C8(); +}