From f9f5f34b0c52b02e6b342ecdbccb2692d1c75521 Mon Sep 17 00:00:00 2001 From: Marcus Huderle Date: Tue, 16 Apr 2019 11:00:13 -0500 Subject: [PATCH] Finish decompiling pokenav_unk_4.c --- asm/pokenav_unk_4.s | 1777 ----------------------------------- include/match_call.h | 2 + include/pokenav.h | 38 +- include/strings.h | 4 + ld_script.txt | 1 - src/match_call.c | 2 +- src/pokenav.c | 15 +- src/pokenav_main_menu.c | 2 +- src/pokenav_match_call_ui.c | 19 +- src/pokenav_unk_3.c | 9 +- src/pokenav_unk_4.c | 844 ++++++++++++++++- 11 files changed, 884 insertions(+), 1829 deletions(-) delete mode 100644 asm/pokenav_unk_4.s diff --git a/asm/pokenav_unk_4.s b/asm/pokenav_unk_4.s deleted file mode 100644 index b47370b6b..000000000 --- a/asm/pokenav_unk_4.s +++ /dev/null @@ -1,1777 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .syntax unified - -@ File centered around AllocSubstruct(6) - - thumb_func_start sub_81CB6F0 -sub_81CB6F0: @ 81CB6F0 - push {r4,r5,lr} - adds r4, r0, 0 - movs r0, 0x6 - bl GetSubstructPtr - adds r5, r0, 0 - cmp r4, 0 - beq _081CB706 - cmp r4, 0x1 - beq _081CB71C - b _081CB72A -_081CB706: - movs r0, 0x5 - bl PlaySE - adds r0, r5, 0 - bl sub_81CBF60 - movs r0, 0x7 - bl sub_81C7BA4 - movs r0, 0 - b _081CB72C -_081CB71C: - adds r0, r5, 0 - bl sub_81CBFC4 - cmp r0, 0 - beq _081CB72A - movs r0, 0x2 - b _081CB72C -_081CB72A: - movs r0, 0x4 -_081CB72C: - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_81CB6F0 - - thumb_func_start sub_81CB734 -sub_81CB734: @ 81CB734 - push {r4,lr} - movs r0, 0x5 - bl PlaySE - movs r0, 0x6 - bl GetSubstructPtr - adds r4, r0, 0 - bl sub_81CB01C - adds r1, r0, 0 - lsls r1, 16 - lsrs r1, 16 - adds r0, r4, 0 - bl sub_81CC344 - movs r0, 0x4 - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_81CB734 - - thumb_func_start sub_81CB75C -sub_81CB75C: @ 81CB75C - push {r4,r5,lr} - adds r4, r0, 0 - movs r0, 0x6 - bl GetSubstructPtr - adds r5, r0, 0 - cmp r4, 0 - beq _081CB772 - cmp r4, 0x1 - beq _081CB788 - b _081CB796 -_081CB772: - movs r0, 0x5 - bl PlaySE - adds r0, r5, 0 - bl sub_81CBFF0 - movs r0, 0x6 - bl sub_81C7BA4 - movs r0, 0 - b _081CB798 -_081CB788: - adds r0, r5, 0 - bl sub_81CC004 - cmp r0, 0 - beq _081CB796 - movs r0, 0x2 - b _081CB798 -_081CB796: - movs r0, 0x4 -_081CB798: - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_81CB75C - - thumb_func_start sub_81CB7A0 -sub_81CB7A0: @ 81CB7A0 - push {r4,r5,lr} - adds r4, r0, 0 - movs r0, 0x6 - bl GetSubstructPtr - adds r5, r0, 0 - cmp r4, 0x1 - beq _081CB7D4 - cmp r4, 0x1 - bgt _081CB7BA - cmp r4, 0 - beq _081CB7C4 - b _081CB81A -_081CB7BA: - cmp r4, 0x2 - beq _081CB7F8 - cmp r4, 0x3 - beq _081CB80C - b _081CB81A -_081CB7C4: - movs r0, 0x1 - bl ToggleMatchCallVerticalArrows - adds r0, r5, 0 - bl sub_81CC058 - movs r0, 0 - b _081CB81C -_081CB7D4: - adds r0, r5, 0 - bl sub_81CC0D0 - adds r4, r0, 0 - cmp r4, 0 - bne _081CB816 - adds r0, r5, 0 - bl sub_81CC0E0 - ldr r0, =0x00000107 - bl PlaySE - strb r4, [r5, 0xE] - movs r0, 0 - b _081CB81C - .pool -_081CB7F8: - adds r0, r5, 0 - bl sub_81CC104 - cmp r0, 0 - bne _081CB816 - adds r0, r5, 0 - bl sub_81CC158 - movs r0, 0 - b _081CB81C -_081CB80C: - adds r0, r5, 0 - bl sub_81CC194 - cmp r0, 0 - beq _081CB81A -_081CB816: - movs r0, 0x2 - b _081CB81C -_081CB81A: - movs r0, 0x4 -_081CB81C: - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_81CB7A0 - - thumb_func_start sub_81CB824 -sub_81CB824: @ 81CB824 - push {r4,r5,lr} - adds r4, r0, 0 - movs r0, 0x6 - bl GetSubstructPtr - adds r5, r0, 0 - cmp r4, 0x1 - beq _081CB85E - cmp r4, 0x1 - bgt _081CB83E - cmp r4, 0 - beq _081CB844 - b _081CB880 -_081CB83E: - cmp r4, 0x2 - beq _081CB872 - b _081CB880 -_081CB844: - movs r0, 0x5 - bl PlaySE - adds r0, r5, 0 - bl sub_81CC09C - movs r0, 0x1 - bl ToggleMatchCallVerticalArrows - movs r0, 0x1 - strb r0, [r5, 0xE] - movs r0, 0 - b _081CB882 -_081CB85E: - adds r0, r5, 0 - bl sub_81CC0D0 - cmp r0, 0 - bne _081CB87C - adds r0, r5, 0 - bl sub_81CC11C - movs r0, 0 - b _081CB882 -_081CB872: - adds r0, r5, 0 - bl sub_81CC140 - cmp r0, 0 - beq _081CB880 -_081CB87C: - movs r0, 0x2 - b _081CB882 -_081CB880: - movs r0, 0x4 -_081CB882: - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_81CB824 - - thumb_func_start sub_81CB888 -sub_81CB888: @ 81CB888 - push {r4-r6,lr} - adds r5, r0, 0 - movs r0, 0x6 - bl GetSubstructPtr - adds r4, r0, 0 - movs r6, 0 - cmp r5, 0x6 - bhi _081CB934 - lsls r0, r5, 2 - ldr r1, =_081CB8A8 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_081CB8A8: - .4byte _081CB8C4 - .4byte _081CB8DA - .4byte _081CB8E2 - .4byte _081CB8F0 - .4byte _081CB8F8 - .4byte _081CB90C - .4byte _081CB922 -_081CB8C4: - ldrb r0, [r4, 0xE] - cmp r0, 0 - bne _081CB8D2 - movs r0, 0x84 - lsls r0, 1 - bl PlaySE -_081CB8D2: - movs r0, 0x5 - bl PlaySE - b _081CB934 -_081CB8DA: - adds r0, r4, 0 - bl sub_81CC1DC - b _081CB934 -_081CB8E2: - adds r0, r4, 0 - bl sub_81CC204 - cmp r0, 0 - beq _081CB934 -_081CB8EC: - movs r6, 0x2 - b _081CB934 -_081CB8F0: - adds r0, r4, 0 - bl sub_81CBFF0 - b _081CB934 -_081CB8F8: - adds r0, r4, 0 - bl sub_81CC004 - cmp r0, 0 - beq _081CB904 - movs r6, 0x2 -_081CB904: - movs r0, 0x6 - bl sub_81C7BA4 - b _081CB934 -_081CB90C: - bl IsDma3ManagerBusyWithBgCopy_ - cmp r0, 0 - bne _081CB8EC - ldrb r0, [r4, 0xF] - cmp r0, 0 - beq _081CB92C - bl sub_81C8838 - movs r6, 0x1 - b _081CB934 -_081CB922: - bl IsDma3ManagerBusyWithBgCopy - lsls r0, 24 - cmp r0, 0 - bne _081CB8EC -_081CB92C: - movs r0, 0 - bl ToggleMatchCallVerticalArrows - movs r6, 0x4 -_081CB934: - adds r0, r6, 0 - pop {r4-r6} - pop {r1} - bx r1 - thumb_func_end sub_81CB888 - - thumb_func_start sub_81CB93C -sub_81CB93C: @ 81CB93C - push {r4,r5,lr} - adds r4, r0, 0 - movs r0, 0x6 - bl GetSubstructPtr - adds r5, r0, 0 - cmp r4, 0x1 - beq _081CB974 - cmp r4, 0x1 - bgt _081CB956 - cmp r4, 0 - beq _081CB960 - b _081CB9BE -_081CB956: - cmp r4, 0x2 - beq _081CB990 - cmp r4, 0x3 - beq _081CB9A0 - b _081CB9BE -_081CB960: - movs r0, 0x5 - bl PlaySE - bl sub_81C877C - adds r0, r5, 0 - bl sub_81CC014 - movs r0, 0 - b _081CB9C0 -_081CB974: - bl sub_81C8820 - cmp r0, 0 - bne _081CB9BA - adds r0, r5, 0 - bl sub_81CC004 - cmp r0, 0 - bne _081CB9BA - movs r0, 0x8 - bl sub_81C7BA4 - movs r0, 0 - b _081CB9C0 -_081CB990: - movs r0, 0 - bl sub_81C87AC - adds r0, r5, 0 - bl sub_81CC39C - movs r0, 0 - b _081CB9C0 -_081CB9A0: - bl sub_81C8820 - cmp r0, 0 - bne _081CB9BA - adds r0, r5, 0 - bl sub_81CC42C - cmp r0, 0 - bne _081CB9BA - bl IsDma3ManagerBusyWithBgCopy_ - cmp r0, 0 - beq _081CB9BE -_081CB9BA: - movs r0, 0x2 - b _081CB9C0 -_081CB9BE: - movs r0, 0x4 -_081CB9C0: - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_81CB93C - - thumb_func_start sub_81CB9C8 -sub_81CB9C8: @ 81CB9C8 - push {r4,r5,lr} - adds r5, r0, 0 - movs r0, 0x6 - bl GetSubstructPtr - adds r4, r0, 0 - cmp r5, 0x4 - bhi _081CBA60 - lsls r0, r5, 2 - ldr r1, =_081CB9E8 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_081CB9E8: - .4byte _081CB9FC - .4byte _081CBA1C - .4byte _081CBA34 - .4byte _081CBA40 - .4byte _081CBA4A -_081CB9FC: - bl GetMatchCallListTopIndex - bl sub_81CB0E4 - adds r5, r0, 0 - cmp r5, 0 - beq _081CBA60 - movs r0, 0x5 - bl PlaySE - strh r5, [r4, 0x16] - adds r0, r4, 0 - bl sub_81CC420 - movs r0, 0 - b _081CBA62 -_081CBA1C: - adds r0, r4, 0 - bl sub_81CC42C - cmp r0, 0 - bne _081CBA5C - movs r0, 0x16 - ldrsh r1, [r4, r0] - adds r0, r4, 0 - bl sub_81CBEF8 - movs r0, 0 - b _081CBA62 -_081CBA34: - movs r1, 0x16 - ldrsh r0, [r4, r1] - bl sub_81C87AC - movs r0, 0 - b _081CBA62 -_081CBA40: - adds r0, r4, 0 - bl sub_81CC39C - movs r0, 0 - b _081CBA62 -_081CBA4A: - bl sub_81C8820 - cmp r0, 0 - bne _081CBA5C - adds r0, r4, 0 - bl sub_81CC42C - cmp r0, 0 - beq _081CBA60 -_081CBA5C: - movs r0, 0x2 - b _081CBA62 -_081CBA60: - movs r0, 0x4 -_081CBA62: - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_81CB9C8 - - thumb_func_start sub_81CBA68 -sub_81CBA68: @ 81CBA68 - push {r4,r5,lr} - adds r4, r0, 0 - movs r0, 0x6 - bl GetSubstructPtr - adds r5, r0, 0 - cmp r4, 0x1 - beq _081CBA9C - cmp r4, 0x1 - bgt _081CBA82 - cmp r4, 0 - beq _081CBA88 - b _081CBACC -_081CBA82: - cmp r4, 0x2 - beq _081CBABE - b _081CBACC -_081CBA88: - movs r0, 0x5 - bl PlaySE - adds r0, r5, 0 - bl sub_81CC420 - bl sub_81C87F0 - movs r0, 0 - b _081CBACE -_081CBA9C: - bl sub_81C8820 - cmp r0, 0 - bne _081CBAC8 - adds r0, r5, 0 - bl sub_81CC42C - cmp r0, 0 - bne _081CBAC8 - movs r0, 0x6 - bl sub_81C7BA4 - adds r0, r5, 0 - bl sub_81CBDC0 - movs r0, 0 - b _081CBACE -_081CBABE: - bl IsDma3ManagerBusyWithBgCopy - lsls r0, 24 - cmp r0, 0 - beq _081CBACC -_081CBAC8: - movs r0, 0x2 - b _081CBACE -_081CBACC: - movs r0, 0x4 -_081CBACE: - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_81CBA68 - - thumb_func_start sub_81CBAD4 -sub_81CBAD4: @ 81CBAD4 - push {r4,r5,lr} - adds r5, r0, 0 - movs r0, 0x6 - bl GetSubstructPtr - adds r4, r0, 0 - cmp r5, 0x4 - bhi _081CBB6C - lsls r0, r5, 2 - ldr r1, =_081CBAF4 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_081CBAF4: - .4byte _081CBB08 - .4byte _081CBB28 - .4byte _081CBB40 - .4byte _081CBB4C - .4byte _081CBB56 -_081CBB08: - bl GetMatchCallListTopIndex - bl sub_81CB128 - adds r5, r0, 0 - cmp r5, 0 - beq _081CBB6C - movs r0, 0x5 - bl PlaySE - strh r5, [r4, 0x16] - adds r0, r4, 0 - bl sub_81CC420 - movs r0, 0 - b _081CBB6E -_081CBB28: - adds r0, r4, 0 - bl sub_81CC42C - cmp r0, 0 - bne _081CBB68 - movs r0, 0x16 - ldrsh r1, [r4, r0] - adds r0, r4, 0 - bl sub_81CBEF8 - movs r0, 0 - b _081CBB6E -_081CBB40: - movs r1, 0x16 - ldrsh r0, [r4, r1] - bl sub_81C87AC - movs r0, 0 - b _081CBB6E -_081CBB4C: - adds r0, r4, 0 - bl sub_81CC39C - movs r0, 0 - b _081CBB6E -_081CBB56: - bl sub_81C8820 - cmp r0, 0 - bne _081CBB68 - adds r0, r4, 0 - bl sub_81CC42C - cmp r0, 0 - beq _081CBB6C -_081CBB68: - movs r0, 0x2 - b _081CBB6E -_081CBB6C: - movs r0, 0x4 -_081CBB6E: - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_81CBAD4 - - thumb_func_start sub_81CBB74 -sub_81CBB74: @ 81CBB74 - push {lr} - cmp r0, 0 - beq _081CBB80 - cmp r0, 0x1 - beq _081CBB9A - b _081CBBB2 -_081CBB80: - movs r0, 0x5 - bl PlaySE - movs r0, 0 - bl sub_81CBC38 - movs r0, 0 - bl sub_81C7AC0 - bl sub_81C78A0 - movs r0, 0 - b _081CBBB4 -_081CBB9A: - bl IsPaletteFadeActive - cmp r0, 0 - bne _081CBBAA - bl MainMenuLoopedTaskIsBusy - cmp r0, 0 - beq _081CBBAE -_081CBBAA: - movs r0, 0x2 - b _081CBBB4 -_081CBBAE: - bl sub_81C7FDC -_081CBBB2: - movs r0, 0x4 -_081CBBB4: - pop {r1} - bx r1 - thumb_func_end sub_81CBB74 - - thumb_func_start sub_81CBBB8 -sub_81CBBB8: @ 81CBBB8 - push {lr} - sub sp, 0x18 - bl sub_81CAE94 - str r0, [sp] - bl sub_81CAE38 - mov r1, sp - movs r2, 0 - strh r0, [r1, 0x4] - movs r0, 0x4 - strb r0, [r1, 0x8] - mov r0, sp - strh r2, [r0, 0x6] - movs r0, 0xD - strb r0, [r1, 0x9] - movs r0, 0x10 - strb r0, [r1, 0xA] - movs r0, 0x1 - strb r0, [r1, 0xB] - movs r0, 0x8 - strb r0, [r1, 0xC] - movs r0, 0x3 - strb r0, [r1, 0xD] - movs r0, 0x7 - strb r0, [r1, 0xE] - ldr r0, =sub_81CB050 - str r0, [sp, 0x10] - ldr r0, =sub_81CBCEC - str r0, [sp, 0x14] - ldr r0, =gUnknown_08622794 - movs r2, 0x2 - bl sub_81C81D4 - ldr r0, =sub_81CBC64 - movs r1, 0x7 - bl CreateTask - add sp, 0x18 - pop {r0} - bx r0 - .pool - thumb_func_end sub_81CBBB8 - - thumb_func_start sub_81CBC1C -sub_81CBC1C: @ 81CBC1C - push {lr} - bl sub_81C8234 - ldr r0, =sub_81CBC64 - bl FindTaskIdByFunc - lsls r0, 24 - lsrs r0, 24 - bl DestroyTask - pop {r0} - bx r0 - .pool - thumb_func_end sub_81CBC1C - - thumb_func_start sub_81CBC38 -sub_81CBC38: @ 81CBC38 - push {r4,lr} - adds r4, r0, 0 - ldr r0, =sub_81CBC64 - bl FindTaskIdByFunc - lsls r0, 24 - lsrs r2, r0, 24 - cmp r2, 0xFF - beq _081CBC56 - ldr r1, =gTasks - lsls r0, r2, 2 - adds r0, r2 - lsls r0, 3 - adds r0, r1 - strh r4, [r0, 0x26] -_081CBC56: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81CBC38 - - thumb_func_start sub_81CBC64 -sub_81CBC64: @ 81CBC64 - push {r4,lr} - sub sp, 0x8 - lsls r0, 24 - lsrs r0, 24 - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 3 - ldr r0, =gTasks + 0x8 - adds r2, r1, r0 - movs r1, 0x1E - ldrsh r0, [r2, r1] - cmp r0, 0 - beq _081CBCC8 - ldrh r0, [r2] - adds r0, 0x4 - movs r1, 0x7F - ands r0, r1 - strh r0, [r2] - ldr r1, =gSineTable - movs r3, 0 - ldrsh r0, [r2, r3] - lsls r0, 1 - adds r0, r1 - ldrh r0, [r0] - lsls r0, 16 - asrs r0, 20 - strh r0, [r2, 0x2] - ldr r0, =gUnknown_08622720 - adds r1, r0, 0 - adds r1, 0x20 - movs r3, 0x2 - ldrsh r2, [r2, r3] - str r2, [sp] - ldr r4, =gPlttBufferUnfaded + 0xA0 - str r4, [sp, 0x4] - movs r2, 0x10 - movs r3, 0x10 - bl sub_81C79BC - ldr r0, =gPaletteFade - ldrb r1, [r0, 0x7] - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - bne _081CBCC8 - ldr r1, =gPlttBufferFaded + 0xA0 - ldr r2, =0x04000008 - adds r0, r4, 0 - bl CpuSet -_081CBCC8: - add sp, 0x8 - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81CBC64 - - thumb_func_start sub_81CBCEC -sub_81CBCEC: @ 81CBCEC - push {r4-r6,lr} - adds r5, r1, 0 - adds r4, r2, 0 - lsls r0, 24 - lsrs r0, 24 - movs r1, 0 - bl GetWindowAttribute - lsls r0, 24 - lsrs r0, 24 - bl GetBgTilemapBuffer - adds r6, r0, 0 - lsls r4, 7 - adds r4, 0x3A - adds r6, r4 - adds r0, r5, 0 - bl sub_81CAEBC - cmp r0, 0 - beq _081CBD30 - movs r1, 0xA0 - lsls r1, 7 - adds r0, r1, 0 - strh r0, [r6] - adds r1, r6, 0 - adds r1, 0x40 - ldr r2, =0x00005001 - adds r0, r2, 0 - strh r0, [r1] - b _081CBD3C - .pool -_081CBD30: - ldr r0, =0x00005002 - adds r1, r0, 0 - strh r1, [r6] - adds r0, r6, 0 - adds r0, 0x40 - strh r1, [r0] -_081CBD3C: - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81CBCEC - - thumb_func_start sub_81CBD48 -sub_81CBD48: @ 81CBD48 - push {r4,lr} - adds r4, r1, 0 - lsls r0, 24 - lsrs r0, 24 - movs r1, 0 - bl GetWindowAttribute - lsls r0, 24 - lsrs r0, 24 - bl GetBgTilemapBuffer - lsls r4, 7 - adds r4, 0x3A - adds r0, r4 - ldr r2, =0x00005002 - adds r1, r2, 0 - strh r1, [r0] - adds r0, 0x40 - strh r1, [r0] - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81CBD48 - - thumb_func_start sub_81CBD78 -sub_81CBD78: @ 81CBD78 - push {r4,lr} - adds r4, r0, 0 - ldr r0, =gUnknown_086227D8 - bl AddWindow - strh r0, [r4, 0x10] - ldr r0, =gUnknown_086227E0 - bl AddWindow - strh r0, [r4, 0x12] - ldrb r0, [r4, 0x10] - movs r1, 0x11 - bl FillWindowPixelBuffer - ldrb r0, [r4, 0x10] - bl PutWindowTilemap - ldrb r0, [r4, 0x12] - movs r1, 0x11 - bl FillWindowPixelBuffer - ldrb r0, [r4, 0x12] - bl PutWindowTilemap - ldrb r0, [r4, 0x10] - movs r1, 0x1 - bl CopyWindowToVram - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81CBD78 - - thumb_func_start sub_81CBDC0 -sub_81CBDC0: @ 81CBDC0 - push {r4,lr} - adds r4, r0, 0 - ldrb r0, [r4, 0x12] - movs r1, 0x11 - bl FillWindowPixelBuffer - ldrh r0, [r4, 0x12] - bl sub_81CBDF4 - ldrh r0, [r4, 0x12] - bl sub_81CBE0C - ldrh r0, [r4, 0x12] - bl sub_81CBE38 - ldrh r0, [r4, 0x12] - bl sub_81CBE50 - ldrb r0, [r4, 0x12] - movs r1, 0x2 - bl CopyWindowToVram - pop {r4} - pop {r0} - bx r0 - thumb_func_end sub_81CBDC0 - - thumb_func_start sub_81CBDF4 -sub_81CBDF4: @ 81CBDF4 - push {lr} - lsls r0, 16 - lsrs r0, 16 - ldr r1, =gText_NumberRegistered - movs r2, 0 - bl sub_81CBE88 - pop {r0} - bx r0 - .pool - thumb_func_end sub_81CBDF4 - - thumb_func_start sub_81CBE0C -sub_81CBE0C: @ 81CBE0C - push {r4,lr} - sub sp, 0x4 - adds r4, r0, 0 - lsls r4, 16 - lsrs r4, 16 - bl sub_81CAE38 - adds r1, r0, 0 - mov r0, sp - movs r2, 0 - movs r3, 0x3 - bl ConvertIntToDecimalStringN - adds r0, r4, 0 - mov r1, sp - movs r2, 0x1 - bl sub_81CBEB4 - add sp, 0x4 - pop {r4} - pop {r0} - bx r0 - thumb_func_end sub_81CBE0C - - thumb_func_start sub_81CBE38 -sub_81CBE38: @ 81CBE38 - push {lr} - lsls r0, 16 - lsrs r0, 16 - ldr r1, =gText_NumberOfBattles - movs r2, 0x2 - bl sub_81CBE88 - pop {r0} - bx r0 - .pool - thumb_func_end sub_81CBE38 - - thumb_func_start sub_81CBE50 -sub_81CBE50: @ 81CBE50 - push {r4,lr} - sub sp, 0x8 - lsls r0, 16 - lsrs r4, r0, 16 - movs r0, 0x9 - bl GetGameStat - adds r1, r0, 0 - ldr r0, =0x0001869f - cmp r1, r0 - ble _081CBE68 - adds r1, r0, 0 -_081CBE68: - mov r0, sp - movs r2, 0 - movs r3, 0x5 - bl ConvertIntToDecimalStringN - adds r0, r4, 0 - mov r1, sp - movs r2, 0x3 - bl sub_81CBEB4 - add sp, 0x8 - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81CBE50 - - thumb_func_start sub_81CBE88 -sub_81CBE88: @ 81CBE88 - push {lr} - sub sp, 0xC - adds r3, r1, 0 - lsls r2, 4 - adds r2, 0x1 - lsls r0, 24 - lsrs r0, 24 - lsls r2, 24 - lsrs r2, 24 - str r2, [sp] - movs r1, 0xFF - str r1, [sp, 0x4] - movs r1, 0 - str r1, [sp, 0x8] - movs r1, 0x7 - adds r2, r3, 0 - movs r3, 0x2 - bl AddTextPrinterParameterized - add sp, 0xC - pop {r0} - bx r0 - thumb_func_end sub_81CBE88 - - thumb_func_start sub_81CBEB4 -sub_81CBEB4: @ 81CBEB4 - push {r4-r6,lr} - sub sp, 0xC - adds r5, r0, 0 - adds r6, r1, 0 - adds r4, r2, 0 - lsls r5, 16 - lsrs r5, 16 - movs r0, 0x7 - movs r2, 0x56 - bl GetStringRightAlignXOffset - adds r3, r0, 0 - lsls r4, 4 - adds r4, 0x1 - lsls r5, 24 - lsrs r5, 24 - lsls r3, 24 - lsrs r3, 24 - lsls r4, 24 - lsrs r4, 24 - str r4, [sp] - movs r0, 0xFF - str r0, [sp, 0x4] - movs r0, 0 - str r0, [sp, 0x8] - adds r0, r5, 0 - movs r1, 0x7 - adds r2, r6, 0 - bl AddTextPrinterParameterized - add sp, 0xC - pop {r4-r6} - pop {r0} - bx r0 - thumb_func_end sub_81CBEB4 - - thumb_func_start sub_81CBEF8 -sub_81CBEF8: @ 81CBEF8 - push {r4,r5,lr} - sub sp, 0x2C - adds r5, r0, 0 - adds r4, r1, 0 - bl GetSelectedMatchCall - adds r0, r4 - bl sub_81CAEA4 - lsls r0, 16 - lsrs r1, r0, 16 - cmp r1, 0xD5 - beq _081CBF1C - add r0, sp, 0xC - movs r2, 0 - bl GetMapName - b _081CBF24 -_081CBF1C: - ldr r1, =gText_Unknown - add r0, sp, 0xC - bl StringCopy -_081CBF24: - movs r0, 0x7 - add r1, sp, 0xC - movs r2, 0x58 - bl GetStringCenterAlignXOffset - adds r4, r0, 0 - ldrb r0, [r5, 0x10] - movs r1, 0x11 - bl FillWindowPixelBuffer - ldrb r0, [r5, 0x10] - lsls r4, 24 - lsrs r4, 24 - movs r1, 0x1 - str r1, [sp] - movs r1, 0 - str r1, [sp, 0x4] - str r1, [sp, 0x8] - movs r1, 0x7 - add r2, sp, 0xC - adds r3, r4, 0 - bl AddTextPrinterParameterized - add sp, 0x2C - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81CBEF8 - - thumb_func_start sub_81CBF60 -sub_81CBF60: @ 81CBF60 - push {r4-r6,lr} - sub sp, 0xC - adds r5, r0, 0 - ldrb r0, [r5, 0x12] - movs r1, 0x11 - bl FillWindowPixelBuffer - movs r4, 0 - movs r6, 0x80 - lsls r6, 17 - b _081CBF9C -_081CBF76: - ldrb r0, [r5, 0x12] - ldr r2, =gUnknown_086227E8 - lsls r1, 2 - adds r1, r2 - ldr r2, [r1] - lsrs r1, r6, 24 - str r1, [sp] - movs r1, 0xFF - str r1, [sp, 0x4] - movs r1, 0 - str r1, [sp, 0x8] - movs r1, 0x7 - movs r3, 0x10 - bl AddTextPrinterParameterized - movs r0, 0x80 - lsls r0, 21 - adds r6, r0 - adds r4, 0x1 -_081CBF9C: - cmp r4, 0x2 - bhi _081CBFAE - adds r0, r4, 0 - bl sub_81CB02C - lsls r0, 16 - lsrs r1, r0, 16 - cmp r1, 0x3 - bne _081CBF76 -_081CBFAE: - ldrb r0, [r5, 0x12] - movs r1, 0x2 - bl CopyWindowToVram - add sp, 0xC - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81CBF60 - - thumb_func_start sub_81CBFC4 -sub_81CBFC4: @ 81CBFC4 - push {r4,lr} - adds r4, r0, 0 - bl IsDma3ManagerBusyWithBgCopy - lsls r0, 24 - cmp r0, 0 - beq _081CBFD6 - movs r0, 0x1 - b _081CBFE8 -_081CBFD6: - bl sub_81CB01C - adds r1, r0, 0 - lsls r1, 16 - lsrs r1, 16 - adds r0, r4, 0 - bl sub_81CC2F0 - movs r0, 0 -_081CBFE8: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_81CBFC4 - - thumb_func_start sub_81CBFF0 -sub_81CBFF0: @ 81CBFF0 - push {r4,lr} - adds r4, r0, 0 - bl sub_81CC330 - adds r0, r4, 0 - bl sub_81CBDC0 - pop {r4} - pop {r0} - bx r0 - thumb_func_end sub_81CBFF0 - - thumb_func_start sub_81CC004 -sub_81CC004: @ 81CC004 - push {lr} - bl IsDma3ManagerBusyWithBgCopy - lsls r0, 24 - lsrs r0, 24 - pop {r1} - bx r1 - thumb_func_end sub_81CC004 - - thumb_func_start sub_81CC014 -sub_81CC014: @ 81CC014 - push {r4,lr} - adds r4, r0, 0 - bl sub_81CC330 - ldrb r0, [r4, 0x12] - movs r1, 0x11 - bl FillWindowPixelBuffer - ldrb r0, [r4, 0x12] - movs r1, 0x2 - bl CopyWindowToVram - pop {r4} - pop {r0} - bx r0 - thumb_func_end sub_81CC014 - - thumb_func_start sub_81CC034 -sub_81CC034: @ 81CC034 - push {r4,lr} - adds r4, r0, 0 - ldr r0, =gUnknown_08622808 - bl AddWindow - strh r0, [r4, 0x14] - ldrh r0, [r4, 0x14] - movs r1, 0x1 - movs r2, 0x4 - bl sub_8197184 - bl sub_81C7B40 - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81CC034 - - thumb_func_start sub_81CC058 -sub_81CC058: @ 81CC058 - push {r4,lr} - adds r4, r0, 0 - ldrh r0, [r4, 0x14] - movs r1, 0x1 - movs r2, 0x4 - bl sub_8197184 - ldrh r0, [r4, 0x14] - movs r1, 0x1 - movs r2, 0x4 - bl sub_81971C4 - ldrb r0, [r4, 0x14] - movs r1, 0x11 - bl FillWindowPixelBuffer - ldrb r0, [r4, 0x14] - bl PutWindowTilemap - ldrb r0, [r4, 0x14] - movs r1, 0x3 - bl CopyWindowToVram - bl PauseSpinningPokenavSprite - movs r2, 0 - movs r1, 0x18 - strh r1, [r0, 0x20] - movs r1, 0x70 - strh r1, [r0, 0x22] - strh r2, [r0, 0x26] - pop {r4} - pop {r0} - bx r0 - thumb_func_end sub_81CC058 - - thumb_func_start sub_81CC09C -sub_81CC09C: @ 81CC09C - push {r4,lr} - adds r4, r0, 0 - ldrb r0, [r4, 0x14] - movs r1, 0x1 - movs r2, 0x40 - bl LoadUserWindowBorderGfx - ldrb r0, [r4, 0x14] - movs r1, 0x1 - movs r2, 0x4 - bl DrawTextBorderOuter - ldrb r0, [r4, 0x14] - movs r1, 0x11 - bl FillWindowPixelBuffer - ldrb r0, [r4, 0x14] - bl PutWindowTilemap - ldrb r0, [r4, 0x14] - movs r1, 0x3 - bl CopyWindowToVram - pop {r4} - pop {r0} - bx r0 - thumb_func_end sub_81CC09C - - thumb_func_start sub_81CC0D0 -sub_81CC0D0: @ 81CC0D0 - push {lr} - bl IsDma3ManagerBusyWithBgCopy - lsls r0, 24 - lsrs r0, 24 - pop {r1} - bx r1 - thumb_func_end sub_81CC0D0 - - thumb_func_start sub_81CC0E0 -sub_81CC0E0: @ 81CC0E0 - push {lr} - sub sp, 0xC - ldrb r0, [r0, 0x14] - ldr r2, =gUnknown_086227F4 - movs r1, 0x1 - str r1, [sp] - str r1, [sp, 0x4] - movs r1, 0 - str r1, [sp, 0x8] - movs r1, 0x1 - movs r3, 0x20 - bl AddTextPrinterParameterized - add sp, 0xC - pop {r0} - bx r0 - .pool - thumb_func_end sub_81CC0E0 - - thumb_func_start sub_81CC104 -sub_81CC104: @ 81CC104 - push {r4,lr} - adds r4, r0, 0 - bl RunTextPrinters - ldrb r0, [r4, 0x14] - bl IsTextPrinterActive - lsls r0, 16 - lsrs r0, 16 - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_81CC104 - - thumb_func_start sub_81CC11C -sub_81CC11C: @ 81CC11C - push {lr} - sub sp, 0xC - ldrb r0, [r0, 0x14] - ldr r2, =gText_TrainerCloseBy - movs r1, 0x1 - str r1, [sp] - str r1, [sp, 0x4] - movs r1, 0 - str r1, [sp, 0x8] - movs r1, 0x1 - movs r3, 0 - bl AddTextPrinterParameterized - add sp, 0xC - pop {r0} - bx r0 - .pool - thumb_func_end sub_81CC11C - - thumb_func_start sub_81CC140 -sub_81CC140: @ 81CC140 - push {r4,lr} - adds r4, r0, 0 - bl RunTextPrinters - ldrb r0, [r4, 0x14] - bl IsTextPrinterActive - lsls r0, 16 - lsrs r0, 16 - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_81CC140 - - thumb_func_start sub_81CC158 -sub_81CC158: @ 81CC158 - push {r4,r5,lr} - sub sp, 0xC - adds r4, r0, 0 - bl GetSelectedMatchCall - adds r1, r4, 0 - adds r1, 0xF - bl sub_81CAF78 - adds r5, r0, 0 - bl GetPlayerTextSpeedDelay - lsls r0, 24 - lsrs r0, 24 - ldrb r2, [r4, 0x14] - movs r1, 0x1 - str r1, [sp] - str r0, [sp, 0x4] - movs r0, 0 - str r0, [sp, 0x8] - adds r0, r2, 0 - adds r2, r5, 0 - movs r3, 0x20 - bl AddTextPrinterParameterized - add sp, 0xC - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end sub_81CC158 - - thumb_func_start sub_81CC194 -sub_81CC194: @ 81CC194 - push {r4,lr} - adds r4, r0, 0 - ldr r0, =gMain - ldrh r1, [r0, 0x2C] - movs r0, 0x1 - ands r0, r1 - cmp r0, 0 - beq _081CC1B8 - ldr r0, =gTextFlags - ldrb r1, [r0] - movs r2, 0x1 - orrs r1, r2 - strb r1, [r0] - b _081CC1C4 - .pool -_081CC1B8: - ldr r2, =gTextFlags - ldrb r1, [r2] - movs r0, 0x2 - negs r0, r0 - ands r0, r1 - strb r0, [r2] -_081CC1C4: - bl RunTextPrinters - ldrb r0, [r4, 0x14] - bl IsTextPrinterActive - lsls r0, 16 - lsrs r0, 16 - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end sub_81CC194 - - thumb_func_start sub_81CC1DC -sub_81CC1DC: @ 81CC1DC - push {lr} - sub sp, 0x8 - bl ResumeSpinningPokenavSprite - movs r0, 0x20 - str r0, [sp] - movs r0, 0x14 - str r0, [sp, 0x4] - movs r0, 0x1 - movs r1, 0 - movs r2, 0 - movs r3, 0 - bl FillBgTilemapBufferRect_Palette0 - movs r0, 0x1 - bl CopyBgTilemapBufferToVram - add sp, 0x8 - pop {r0} - bx r0 - thumb_func_end sub_81CC1DC - - thumb_func_start sub_81CC204 -sub_81CC204: @ 81CC204 - push {lr} - bl IsDma3ManagerBusyWithBgCopy - lsls r0, 24 - lsrs r0, 24 - pop {r1} - bx r1 - thumb_func_end sub_81CC204 - - thumb_func_start sub_81CC214 -sub_81CC214: @ 81CC214 - push {r4-r6,lr} - sub sp, 0x8 - movs r0, 0x6 - bl GetSubstructPtr - adds r6, r0, 0 - movs r5, 0 - ldr r4, =gUnknown_08622810 -_081CC224: - adds r0, r4, 0 - bl LoadCompressedSpriteSheet - adds r4, 0x8 - adds r5, 0x1 - cmp r5, 0 - beq _081CC224 - ldr r0, =gUnknown_08622818 - bl Pokenav_AllocAndLoadPalettes - movs r0, 0 - str r0, [r6, 0x1C] - ldr r1, =0x00001828 - adds r0, r6, r1 - str r0, [sp] - ldr r1, =0xffff0000 - ldr r0, [sp, 0x4] - ands r0, r1 - movs r1, 0x80 - lsls r1, 4 - orrs r0, r1 - ldr r1, =0x0000ffff - ands r0, r1 - movs r1, 0x80 - lsls r1, 12 - orrs r0, r1 - str r0, [sp, 0x4] - mov r0, sp - bl LoadSpriteSheet - ldr r2, =0x00001824 - adds r1, r6, r2 - lsls r0, 16 - lsrs r0, 11 - ldr r2, =0x06010000 - adds r0, r2 - str r0, [r1] - movs r0, 0xD - bl AllocSpritePalette - lsls r0, 24 - lsrs r0, 20 - movs r1, 0x80 - lsls r1, 1 - adds r0, r1 - strh r0, [r6, 0x1A] - bl sub_81CC370 - str r0, [r6, 0x20] - adds r0, 0x3E - ldrb r1, [r0] - movs r2, 0x4 - orrs r1, r2 - strb r1, [r0] - add sp, 0x8 - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81CC214 - - thumb_func_start sub_81CC2B4 -sub_81CC2B4: @ 81CC2B4 - push {r4,lr} - movs r0, 0x6 - bl GetSubstructPtr - adds r4, r0, 0 - ldr r0, [r4, 0x1C] - cmp r0, 0 - beq _081CC2C8 - bl DestroySprite -_081CC2C8: - ldr r0, [r4, 0x20] - cmp r0, 0 - beq _081CC2D2 - bl DestroySprite -_081CC2D2: - movs r0, 0x8 - bl FreeSpriteTilesByTag - movs r0, 0x7 - bl FreeSpriteTilesByTag - movs r0, 0xC - bl FreeSpritePaletteByTag - movs r0, 0xD - bl FreeSpritePaletteByTag - pop {r4} - pop {r0} - bx r0 - thumb_func_end sub_81CC2B4 - - thumb_func_start sub_81CC2F0 -sub_81CC2F0: @ 81CC2F0 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - ldr r0, [r4, 0x1C] - cmp r0, 0 - bne _081CC320 - ldr r0, =gUnknown_08622830 - movs r1, 0x4 - movs r2, 0x50 - movs r3, 0x5 - 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, 0x1C] - adds r0, r4, 0 - adds r1, r5, 0 - bl sub_81CC344 -_081CC320: - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81CC2F0 - - thumb_func_start sub_81CC330 -sub_81CC330: @ 81CC330 - push {r4,lr} - adds r4, r0, 0 - ldr r0, [r4, 0x1C] - bl DestroySprite - movs r0, 0 - str r0, [r4, 0x1C] - pop {r4} - pop {r0} - bx r0 - thumb_func_end sub_81CC330 - - thumb_func_start sub_81CC344 -sub_81CC344: @ 81CC344 - ldr r0, [r0, 0x1C] - lsls r1, 4 - strh r1, [r0, 0x26] - bx lr - thumb_func_end sub_81CC344 - - thumb_func_start sub_81CC34C -sub_81CC34C: @ 81CC34C - push {lr} - adds r2, r0, 0 - ldrh r0, [r2, 0x2E] - adds r0, 0x1 - strh r0, [r2, 0x2E] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0x3 - ble _081CC36C - movs r0, 0 - strh r0, [r2, 0x2E] - ldrh r0, [r2, 0x24] - adds r0, 0x1 - movs r1, 0x7 - ands r0, r1 - strh r0, [r2, 0x24] -_081CC36C: - pop {r0} - bx r0 - thumb_func_end sub_81CC34C - - thumb_func_start sub_81CC370 -sub_81CC370: @ 81CC370 - push {lr} - ldr r0, =gUnknown_08622850 - movs r1, 0x2C - movs r2, 0x68 - movs r3, 0x6 - bl CreateSprite - adds r1, r0, 0 - lsls r1, 24 - lsrs r1, 24 - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - ldr r1, =gSprites - adds r0, r1 - pop {r1} - bx r1 - .pool - thumb_func_end sub_81CC370 - - thumb_func_start sub_81CC39C -sub_81CC39C: @ 81CC39C - push {r4-r7,lr} - adds r7, r0, 0 - bl GetSelectedMatchCall - bl sub_81CAF04 - cmp r0, 0 - blt _081CC400 - lsls r4, r0, 3 - ldr r0, =gTrainerFrontPicTable - adds r0, r4, r0 - ldr r1, =0x00001828 - adds r5, r7, r1 - adds r1, r5, 0 - movs r2, 0 - bl DecompressPicFromTable - ldr r0, =gTrainerFrontPicPaletteTable - adds r4, r0 - ldr r0, [r4] - ldr r1, =0x00002028 - adds r6, r7, r1 - adds r1, r6, 0 - bl LZ77UnCompWram - ldr r1, =0x00001824 - adds r0, r7, r1 - ldr r1, [r0] - movs r2, 0x80 - lsls r2, 4 - adds r0, r5, 0 - movs r3, 0x1 - bl RequestDma3Copy - adds r4, r0, 0 - lsls r4, 16 - lsrs r4, 16 - ldrh r1, [r7, 0x1A] - adds r0, r6, 0 - movs r2, 0x20 - bl LoadPalette - ldr r1, [r7, 0x20] - movs r0, 0 - strh r0, [r1, 0x2E] - ldr r0, [r7, 0x20] - strh r4, [r0, 0x3C] - ldr r1, [r7, 0x20] - ldr r0, =sub_81CC440 - str r0, [r1, 0x1C] -_081CC400: - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81CC39C - - thumb_func_start sub_81CC420 -sub_81CC420: @ 81CC420 - ldr r1, [r0, 0x20] - ldr r0, =sub_81CC4A4 - str r0, [r1, 0x1C] - bx lr - .pool - thumb_func_end sub_81CC420 - - thumb_func_start sub_81CC42C -sub_81CC42C: @ 81CC42C - ldr r0, [r0, 0x20] - ldr r1, [r0, 0x1C] - ldr r0, =SpriteCallbackDummy - eors r1, r0 - negs r0, r1 - orrs r0, r1 - lsrs r0, 31 - bx lr - .pool - thumb_func_end sub_81CC42C - - thumb_func_start sub_81CC440 -sub_81CC440: @ 81CC440 - push {r4,lr} - adds r4, r0, 0 - movs r1, 0x2E - ldrsh r0, [r4, r1] - cmp r0, 0 - beq _081CC452 - cmp r0, 0x1 - beq _081CC484 - b _081CC498 -_081CC452: - movs r1, 0x3C - ldrsh r0, [r4, r1] - bl CheckForSpaceForDma3Request - lsls r0, 16 - asrs r0, 16 - movs r1, 0x1 - negs r1, r1 - cmp r0, r1 - beq _081CC498 - ldr r0, =0x0000ffb0 - strh r0, [r4, 0x24] - adds r2, r4, 0 - adds r2, 0x3E - ldrb r1, [r2] - movs r0, 0x5 - negs r0, r0 - ands r0, r1 - strb r0, [r2] - ldrh r0, [r4, 0x2E] - adds r0, 0x1 - strh r0, [r4, 0x2E] - b _081CC498 - .pool -_081CC484: - ldrh r0, [r4, 0x24] - adds r0, 0x8 - strh r0, [r4, 0x24] - lsls r0, 16 - cmp r0, 0 - blt _081CC498 - movs r0, 0 - strh r0, [r4, 0x24] - ldr r0, =SpriteCallbackDummy - str r0, [r4, 0x1C] -_081CC498: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81CC440 - - thumb_func_start sub_81CC4A4 -sub_81CC4A4: @ 81CC4A4 - push {lr} - adds r3, r0, 0 - ldrh r0, [r3, 0x24] - subs r0, 0x8 - strh r0, [r3, 0x24] - lsls r0, 16 - asrs r0, 16 - movs r1, 0x50 - negs r1, r1 - cmp r0, r1 - bgt _081CC4CA - adds r2, r3, 0 - adds r2, 0x3E - ldrb r0, [r2] - movs r1, 0x4 - orrs r0, r1 - strb r0, [r2] - ldr r0, =SpriteCallbackDummy - str r0, [r3, 0x1C] -_081CC4CA: - pop {r0} - bx r0 - .pool - thumb_func_end sub_81CC4A4 - - .align 2, 0 @ Don't pad with nop. diff --git a/include/match_call.h b/include/match_call.h index 014b20eb4..52eab63ec 100644 --- a/include/match_call.h +++ b/include/match_call.h @@ -17,5 +17,7 @@ bool32 IsMatchCallTaskActive(void); void StartMatchCallFromScript(u8 *message); void sub_8197080(u8 *destStr); bool32 SelectMatchCallMessage(int, u8 *); +void sub_8197184(u32 windowId, u32 destOffset, u32 paletteId); +void sub_81971C4(u32 windowId, u32 tileOffset, u32 paletteId); #endif //GUARD_MATCH_CALL_H diff --git a/include/pokenav.h b/include/pokenav.h index b740297c3..443ab11d5 100644 --- a/include/pokenav.h +++ b/include/pokenav.h @@ -57,6 +57,21 @@ u32 GetPokenavMode(void); bool32 CanViewRibbonsMenu(void); // pokenav_match_call_ui.c +struct MatchCallListTemplate +{ + u32 unk0; + u16 unk4; + u16 unk6; + u8 unk8; + u8 unk9; + u8 unkA; + u8 unkB; + u8 unkC; + u8 unkD; + u8 unkE; + void (*unk10)(u32, u8 *a1); + void (*unk14)(u16 a0, u32 a1, u32 a2); +}; u32 GetSelectedMatchCall(void); bool32 sub_81C8224(void); int MatchCall_MoveCursorUp(void); @@ -64,6 +79,15 @@ int MatchCall_MoveCursorDown(void); int MatchCall_PageDown(void); int MatchCall_PageUp(void); bool32 sub_81C8630(void); +void ToggleMatchCallVerticalArrows(bool32 shouldHide); +void sub_81C8838(void); +void sub_81C877C(void); +bool32 sub_81C8820(void); +void sub_81C87AC(s16 a0); +u32 GetMatchCallListTopIndex(void); +void sub_81C87F0(void); +bool32 sub_81C81D4(const struct BgTemplate *arg0, struct MatchCallListTemplate *arg1, s32 arg2); +void sub_81C8234(void); // pokenav_match_call_data.c bool32 sub_81D17E8(u32 idx); @@ -88,6 +112,15 @@ void sub_81C7AC0(int a0); bool32 sub_81C8010(void); void InitBgTemplates(const struct BgTemplate *templates, int count); bool32 IsPaletteFadeActive(void); +void sub_81C7BA4(u32 helpBarIndex); +bool32 IsDma3ManagerBusyWithBgCopy_(void); +void sub_81C78A0(void); +bool32 MainMenuLoopedTaskIsBusy(void); +void sub_81C7FDC(void); +void sub_81C79BC(const u16 *a0, const u16 *a1, u32 a2, u32 a3, u32 a4, u16 *a5); +void sub_81C7B40(void); +struct Sprite *PauseSpinningPokenavSprite(void); +void ResumeSpinningPokenavSprite(void); // pokenav_unk_1.c bool32 sub_81C9298(void); @@ -124,14 +157,17 @@ int sub_81CAF04(int index); const u8 *sub_81CAFD8(int index, int textType); u16 sub_81CB01C(void); u16 sub_81CB02C(int arg0); -void sub_81CB050(struct Pokenav3Struct_Unk1C *arg0, u8 *str); +void sub_81CB050(u32 arg0, u8 *str); int sub_81CB0C8(int rematchIndex); int sub_81CB0E4(int index); bool32 sub_81CAE08(int); +int sub_81CB128(int index); // pokenav_unk_4.c u32 sub_81CB260(void); +void sub_81CB29C(int index); u32 sub_81CB2CC(void); void sub_81CB2E0(void); +void sub_81CBD48(u16 windowId, u32 a1); #endif //GUARD_POKENAV_H diff --git a/include/strings.h b/include/strings.h index 5de5b8e1d..964c46ef2 100644 --- a/include/strings.h +++ b/include/strings.h @@ -2710,5 +2710,9 @@ extern const u8 gText_Exit2[]; // Pokenav Match Call extern const u8 gText_CallCantBeMadeHere[]; +extern const u8 gText_NumberRegistered[]; +extern const u8 gText_NumberOfBattles[]; +extern const u8 gText_Unknown[]; +extern const u8 gText_TrainerCloseBy[]; #endif // GUARD_STRINGS_H diff --git a/ld_script.txt b/ld_script.txt index 9c45dd3d0..68d7cb19e 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -307,7 +307,6 @@ SECTIONS { asm/pokenav_unk_2.o(.text); src/pokenav_unk_3.o(.text); src/pokenav_unk_4.o(.text); - asm/pokenav_unk_4.o(.text); asm/pokenav_unk_5.o(.text); asm/pokenav_unk_6.o(.text); asm/pokenav_unk_7.o(.text); diff --git a/src/match_call.c b/src/match_call.c index 1f5324f02..6221affe1 100644 --- a/src/match_call.c +++ b/src/match_call.c @@ -2002,7 +2002,7 @@ void sub_8197080(u8 *destStr) Free(buffer); } -void sub_8197184(u8 windowId, u32 destOffset, u32 paletteId) +void sub_8197184(u32 windowId, u32 destOffset, u32 paletteId) { u8 bg = GetWindowAttribute(windowId, WINDOW_BG); LoadBgTiles(bg, sUnknown_0860EA6C, 0x100, destOffset); diff --git a/src/pokenav.c b/src/pokenav.c index fde79682b..5556dbc42 100644 --- a/src/pokenav.c +++ b/src/pokenav.c @@ -31,7 +31,7 @@ struct UnknownPokenavCallbackStruct bool32 (*unk0)(void); u32 (*unk4)(void); u32 (*unk8)(void); - u32 (*unkC)(void); + void (*unkC)(int); u32 (*unk10)(void); void (*unk14)(void); void (*unk18)(void); @@ -39,44 +39,43 @@ struct UnknownPokenavCallbackStruct extern u32 sub_81C9924(void); extern u32 sub_81C99C0(void); -extern u32 sub_81C9990(void); +extern void sub_81C9990(int); extern u32 sub_81C9940(void); extern u32 sub_81CC4D4(void); extern u32 sub_81CC554(void); extern u32 sub_81CC5F4(void); -extern u32 sub_81CC62C(void); +extern void sub_81CC62C(int); extern u32 sub_81CC65C(void); extern void sub_81CC524(void); extern void sub_81CC670(void); extern u32 sub_81CCFD8(void); extern u32 sub_81CD070(void); extern u32 sub_81CDDD4(void); -extern u32 sub_81CDE2C(void); +extern void sub_81CDE2C(int); extern u32 sub_81CDE64(void); extern void sub_81CD1C0(void); extern void sub_81CECA0(void); extern u32 sub_81CEF3C(void); extern u32 sub_81CEFDC(void); extern u32 sub_81CF330(void); -extern u32 sub_81CF3A0(void); +extern void sub_81CF3A0(int); extern u32 sub_81CF3D0(void); extern void sub_81CEFF0(void); extern void sub_81CF3F8(void); extern u32 sub_81CD024(void); extern u32 sub_81CEF98(void); extern u32 sub_81CF368(void); -extern u32 sub_81CB29C(void); extern u32 sub_81CF9BC(void); extern u32 sub_81CFA34(void); extern u32 sub_81CFDD0(void); -extern u32 sub_81CFE40(void); +extern void sub_81CFE40(int); extern u32 sub_81CFE70(void); extern void sub_81CFA48(void); extern void sub_81CFE98(void); extern u32 sub_81D0450(void); extern u32 sub_81D04A0(void); extern u32 sub_81D0978(void); -extern u32 sub_81D09B0(void); +extern void sub_81D09B0(int); extern u32 sub_81D09E0(void); extern void sub_81D04B8(void); extern void sub_81D09F4(void); diff --git a/src/pokenav_main_menu.c b/src/pokenav_main_menu.c index e133e01fe..94dab60bb 100644 --- a/src/pokenav_main_menu.c +++ b/src/pokenav_main_menu.c @@ -502,7 +502,7 @@ void sub_81C7990(u32 a0, u16 a1) } NAKED -void sub_81C79BC(u16 *a0, u16 *a1, u32 a2, u32 a3, u32 a4, u32 a5) +void sub_81C79BC(const u16 *a0, const u16 *a1, u32 a2, u32 a3, u32 a4, u16 *a5) { asm(".syntax unified\n\ push {r4-r7,lr}\n\ diff --git a/src/pokenav_match_call_ui.c b/src/pokenav_match_call_ui.c index 72449c7c0..795b4d599 100644 --- a/src/pokenav_match_call_ui.c +++ b/src/pokenav_match_call_ui.c @@ -64,23 +64,6 @@ struct UnknownSubStruct_81C81D4 u32 unk8A0; }; -struct MatchCallListTemplate -{ - u32 unk0; - u16 unk4; - u16 unk6; - u8 unk8; - u8 unk9; - u8 unkA; - u8 unkB; - u8 unkC; - u8 unkD; - u8 unkE; - void (*unk10)(u32, u8 *a1); - void (*unk14)(u16 a0, u32 a1, u32 a2); -}; - -extern void sub_81CBD48(u16 windowId, u32 a1); extern void sub_81DB620(u32 windowId, u32 a1, u32 a2, u32 a3, u32 a4); void sub_81C82E4(struct UnknownSubStruct_81C81D4 *a0); @@ -648,7 +631,7 @@ void sub_81C877C(void) structPtr->unk8A0 = CreateLoopedTask(LoopedTask_sub_81C8870, 6); } -void sub_81C87AC(u16 a0) +void sub_81C87AC(s16 a0) { u16 temp; struct UnknownSubStruct_81C81D4 *structPtr; diff --git a/src/pokenav_unk_3.c b/src/pokenav_unk_3.c index 2c5110143..c6705a352 100755 --- a/src/pokenav_unk_3.c +++ b/src/pokenav_unk_3.c @@ -382,13 +382,14 @@ u16 sub_81CB02C(int arg0) return state->unk4[arg0]; } -void sub_81CB050(struct Pokenav3Struct_Unk1C *arg0, u8 *str) +void sub_81CB050(u32 arg0, u8 *str) { + struct Pokenav3Struct_Unk1C *var0 = (struct Pokenav3Struct_Unk1C *)arg0; const u8 *trainerName; const u8 *className; - if (!arg0->unk0) + if (!var0->unk0) { - int index = GetTrainerIdxByRematchIdx(arg0->unk2); + int index = GetTrainerIdxByRematchIdx(var0->unk2); const struct Trainer *trainer = &gTrainers[index]; int class = trainer->trainerClass; className = gTrainerClassNames[class]; @@ -396,7 +397,7 @@ void sub_81CB050(struct Pokenav3Struct_Unk1C *arg0, u8 *str) } else { - sub_81D1A78(arg0->unk2, &className, &trainerName); + sub_81D1A78(var0->unk2, &className, &trainerName); } if (className && trainerName) diff --git a/src/pokenav_unk_4.c b/src/pokenav_unk_4.c index 9a90090ac..38a531bec 100755 --- a/src/pokenav_unk_4.c +++ b/src/pokenav_unk_4.c @@ -1,41 +1,98 @@ #include "global.h" #include "bg.h" +#include "data.h" +#include "decompress.h" +#include "dma3.h" +#include "international_string_util.h" +#include "main.h" +#include "match_call.h" #include "menu.h" +#include "overworld.h" +#include "palette.h" #include "pokenav.h" +#include "region_map.h" #include "sound.h" +#include "sprite.h" +#include "string_util.h" +#include "strings.h" +#include "task.h" +#include "text.h" +#include "text_window.h" +#include "trig.h" #include "window.h" +#include "constants/game_stat.h" +#include "constants/region_map_sections.h" #include "constants/songs.h" +#include "constants/species.h" struct Pokenav4Struct { u32 (*unk0)(void); u32 unk4; - u8 filler8[0x8]; - u8 unk10; - u8 filler11[0x1]; - u8 unk12; - u8 filler13[0x1]; - u8 unk14; - u8 filler15[0x4]; + u8 filler8[0x6]; + u8 unkE; + u8 unkF; + u16 unk10; + u16 unk12; + u16 unk14; + s16 unk16; + u8 unused18; u8 unk19; - u8 filler1A[0xA]; + u16 unk1A; + struct Sprite *unk1C; + struct Sprite *unk20; u8 unk24[0x800]; u8 unk824[0x800]; u8 unk1024[0x800]; - u8 unk1824[0x824]; + u8 *unk1824; + u8 unk1828[0x800]; + u8 unk2028[0x20]; }; static bool32 sub_81CB310(void); static u32 sub_81CB324(int); -void sub_81CBC1C(void); -void sub_81CC2B4(void); -void sub_81CC034(struct Pokenav4Struct *); -void sub_81CBBB8(void); -void sub_81CBD78(struct Pokenav4Struct *); -void sub_81CBDC0(struct Pokenav4Struct *); -void sub_81CBEF8(struct Pokenav4Struct *, int); -void sub_81CC214(void); -void sub_81CBC38(int); +static void sub_81CBBB8(void); +static void sub_81CBC1C(void); +static void sub_81CC2B4(void); +static void sub_81CC034(struct Pokenav4Struct *); +static void sub_81CBD78(struct Pokenav4Struct *); +static void sub_81CBDC0(struct Pokenav4Struct *); +static void sub_81CBEF8(struct Pokenav4Struct *, int); +static void sub_81CC214(void); +static void sub_81CBC38(int); +static void sub_81CBF60(struct Pokenav4Struct *); +static bool32 sub_81CBFC4(struct Pokenav4Struct *); +static void sub_81CC344(struct Pokenav4Struct *, int); +static bool32 sub_81CC004(struct Pokenav4Struct *); +static void sub_81CBFF0(struct Pokenav4Struct *); +static void sub_81CC058(struct Pokenav4Struct *); +static bool32 sub_81CC0D0(struct Pokenav4Struct *); +static void sub_81CC0E0(struct Pokenav4Struct *); +static bool32 sub_81CC104(struct Pokenav4Struct *); +static void sub_81CC158(struct Pokenav4Struct *); +static bool32 sub_81CC194(struct Pokenav4Struct *); +static void sub_81CC09C(struct Pokenav4Struct *); +static void sub_81CC11C(struct Pokenav4Struct *); +static bool32 sub_81CC140(struct Pokenav4Struct *); +static void sub_81CC1DC(struct Pokenav4Struct *); +static bool32 sub_81CC204(struct Pokenav4Struct *); +static void sub_81CC014(struct Pokenav4Struct *); +static void sub_81CC39C(struct Pokenav4Struct *); +static bool32 sub_81CC42C(struct Pokenav4Struct *); +static void sub_81CC420(struct Pokenav4Struct *); +static void sub_81CBC64(u8 taskId); +static void sub_81CBCEC(u16 windowId, u32, u32); +static void sub_81CBDF4(u16 windowId); +static void sub_81CBE0C(u16 windowId); +static void sub_81CBE38(u16 windowId); +static void sub_81CBE50(u16 windowId); +static void sub_81CBE88(u16 windowId, const u8 *str, int top); +static void sub_81CBEB4(u16 windowId, const u8 *str, int top); +static void sub_81CC2F0(struct Pokenav4Struct *, int); +static void sub_81CC330(struct Pokenav4Struct *); +static struct Sprite *sub_81CC370(void); +static void sub_81CC440(struct Sprite *sprite); +static void sub_81CC4A4(struct Sprite *sprite); extern const LoopedTask gUnknown_08622798[]; extern const struct BgTemplate gUnknown_0862278C[3]; @@ -46,6 +103,16 @@ extern const u16 gUnknown_08622700[]; extern const u16 gUnknown_08622720[]; extern const u8 gUnknown_086225D4[]; extern const u16 gUnknown_086226E0[]; +extern const struct BgTemplate gUnknown_08622794; +extern const struct WindowTemplate gUnknown_086227D8; +extern const struct WindowTemplate gUnknown_086227E0; +extern const u8 *const gUnknown_086227E8[]; +extern const struct WindowTemplate gUnknown_08622808; +extern const u8 gUnknown_086227F4[]; +extern const struct CompressedSpriteSheet gUnknown_08622810[1]; +extern const struct SpritePalette gUnknown_08622818[]; +extern const struct SpriteTemplate gUnknown_08622830; +extern const struct SpriteTemplate gUnknown_08622850; bool32 sub_81CB260(void) { @@ -309,3 +376,744 @@ u32 sub_81CB678(int taskState) } return 4; } + +u32 sub_81CB6F0(int taskState) +{ + struct Pokenav4Struct *state = GetSubstructPtr(6); + switch (taskState) + { + case 0: + PlaySE(SE_SELECT); + sub_81CBF60(state); + sub_81C7BA4(7); + return 0; + case 1: + if (sub_81CBFC4(state)) + return 2; + break; + } + + return 4; +} + +u32 sub_81CB734(int taskState) +{ + struct Pokenav4Struct *state; + u16 var0; + + PlaySE(SE_SELECT); + state = GetSubstructPtr(6); + var0 = sub_81CB01C(); + sub_81CC344(state, var0); + return 4; +} + +u32 sub_81CB75C(int taskState) +{ + struct Pokenav4Struct *state = GetSubstructPtr(6); + switch (taskState) + { + case 0: + PlaySE(SE_SELECT); + sub_81CBFF0(state); + sub_81C7BA4(6); + return 0; + case 1: + if (sub_81CC004(state)) + return 2; + break; + } + + return 4; +} + +u32 sub_81CB7A0(int taskState) +{ + struct Pokenav4Struct *state = GetSubstructPtr(6); + switch (taskState) + { + case 0: + ToggleMatchCallVerticalArrows(TRUE); + sub_81CC058(state); + return 0; + case 1: + if (sub_81CC0D0(state)) + return 2; + + sub_81CC0E0(state); + PlaySE(SE_TOREEYE); + state->unkE = 0; + return 0; + case 2: + if (sub_81CC104(state)) + return 2; + + sub_81CC158(state); + return 0; + case 3: + if (sub_81CC194(state)) + return 2; + break; + } + + return 4; +} + +u32 sub_81CB824(int taskState) +{ + struct Pokenav4Struct *state = GetSubstructPtr(6); + switch (taskState) + { + case 0: + PlaySE(SE_SELECT); + sub_81CC09C(state); + ToggleMatchCallVerticalArrows(TRUE); + state->unkE = 1; + return 0; + case 1: + if (sub_81CC0D0(state)) + return 2; + + sub_81CC11C(state); + return 0; + case 2: + if (sub_81CC140(state)) + return 2; + break; + } + + return 4; +} + +u32 sub_81CB888(int taskState) +{ + struct Pokenav4Struct *state = GetSubstructPtr(6); + u32 result = 0; + + switch (taskState) + { + case 0: + if (!state->unkE) + PlaySE(SE_TOREOFF); + + PlaySE(SE_SELECT); + break; + case 1: + sub_81CC1DC(state); + break; + case 2: + if (sub_81CC204(state)) + result = 2; + break; + case 3: + sub_81CBFF0(state); + break; + case 4: + if (sub_81CC004(state)) + result = 2; + + sub_81C7BA4(6); + break; + case 5: + if (IsDma3ManagerBusyWithBgCopy_()) + { + result = 2; + } + else + { + if (state->unkF) + { + sub_81C8838(); + result = 1; + } + else + { + ToggleMatchCallVerticalArrows(FALSE); + result = 4; + } + } + break; + case 6: + if (IsDma3ManagerBusyWithBgCopy()) + { + result = 2; + } + else + { + ToggleMatchCallVerticalArrows(FALSE); + result = 4; + } + break; + } + + return result; +} + +u32 sub_81CB93C(int taskState) +{ + struct Pokenav4Struct *state = GetSubstructPtr(6); + switch (taskState) + { + case 0: + PlaySE(SE_SELECT); + sub_81C877C(); + sub_81CC014(state); + return 0; + case 1: + if (sub_81C8820() || sub_81CC004(state)) + return 2; + + sub_81C7BA4(8); + return 0; + case 2: + sub_81C87AC(0); + sub_81CC39C(state); + return 0; + case 3: + if (sub_81C8820() || sub_81CC42C(state) || IsDma3ManagerBusyWithBgCopy_()) + return 2; + break; + } + + return 4; +} + +u32 sub_81CB9C8(int taskState) +{ + int index; + int var0; + struct Pokenav4Struct *state = GetSubstructPtr(6); + switch (taskState) + { + case 0: + index = GetMatchCallListTopIndex(); + var0 = sub_81CB0E4(index); + if (var0) + { + PlaySE(SE_SELECT); + state->unk16 = var0; + sub_81CC420(state); + return 0; + } + break; + case 1: + if (sub_81CC42C(state)) + return 2; + + sub_81CBEF8(state, state->unk16); + return 0; + case 2: + sub_81C87AC(state->unk16); + return 0; + case 3: + sub_81CC39C(state); + return 0; + case 4: + if (sub_81C8820() || sub_81CC42C(state)) + return 2; + break; + } + + return 4; +} + +u32 sub_81CBA68(int taskState) +{ + struct Pokenav4Struct *state = GetSubstructPtr(6); + switch (taskState) + { + case 0: + PlaySE(SE_SELECT); + sub_81CC420(state); + sub_81C87F0(); + return 0; + case 1: + if (sub_81C8820() || sub_81CC42C(state)) + return 2; + + sub_81C7BA4(6); + sub_81CBDC0(state); + return 0; + case 2: + if (IsDma3ManagerBusyWithBgCopy()) + return 2; + break; + } + + return 4; +} + +u32 sub_81CBAD4(int taskState) +{ + int index; + int var0; + struct Pokenav4Struct *state = GetSubstructPtr(6); + switch (taskState) + { + case 0: + index = GetMatchCallListTopIndex(); + var0 = sub_81CB128(index); + if (var0) + { + PlaySE(SE_SELECT); + state->unk16 = var0; + sub_81CC420(state); + return 0; + } + break; + case 1: + if (sub_81CC42C(state)) + return 2; + + sub_81CBEF8(state, state->unk16); + return 0; + case 2: + sub_81C87AC(state->unk16); + return 0; + case 3: + sub_81CC39C(state); + return 0; + case 4: + if (sub_81C8820() || sub_81CC42C(state)) + return 2; + break; + } + + return 4; +} + +u32 sub_81CBB74(int taskState) +{ + switch (taskState) + { + case 0: + PlaySE(SE_SELECT); + sub_81CBC38(0); + sub_81C7AC0(0); + sub_81C78A0(); + return 0; + case 1: + if (IsPaletteFadeActive() || MainMenuLoopedTaskIsBusy()) + return 2; + + sub_81C7FDC(); + break; + } + + return 4; +} + +static void sub_81CBBB8(void) +{ + struct MatchCallListTemplate template; + template.unk0 = (u32)sub_81CAE94(); + template.unk4 = sub_81CAE38(); + template.unk8 = 4; + template.unk6 = 0; + template.unk9 = 13; + template.unkA = 16; + template.unkB = 1; + template.unkC = 8; + template.unkD = 3; + template.unkE = 7; + template.unk10 = sub_81CB050; + template.unk14 = sub_81CBCEC; + sub_81C81D4(&gUnknown_08622794, &template, 2); + CreateTask(sub_81CBC64, 7); +} + +static void sub_81CBC1C(void) +{ + sub_81C8234(); + DestroyTask(FindTaskIdByFunc(sub_81CBC64)); +} + +static void sub_81CBC38(int arg0) +{ + u8 taskId = FindTaskIdByFunc(sub_81CBC64); + if (taskId != 0xFF) + gTasks[taskId].data[15] = arg0; +} + +static void sub_81CBC64(u8 taskId) +{ + s16 *taskData = gTasks[taskId].data; + if (taskData[15]) + { + taskData[0] += 4; + taskData[0] &= 0x7F; + taskData[1] = gSineTable[taskData[0]] >> 4; + sub_81C79BC(gUnknown_08622720, gUnknown_08622720 + 0x10, 0x10, 0x10, taskData[1], gPlttBufferUnfaded + 0x50); + if (!gPaletteFade.active) + CpuCopy32(gPlttBufferUnfaded + 0x50, gPlttBufferFaded + 0x50, 0x20); + } +} + +static void sub_81CBCEC(u16 windowId, u32 arg1, u32 arg2) +{ + u8 bg = GetWindowAttribute(windowId, WINDOW_BG); + u16 *tilemap = GetBgTilemapBuffer(bg); + tilemap += arg2 * 0x40 + 0x1D; + if (sub_81CAEBC(arg1)) + { + tilemap[0] = 0x5000; + tilemap[0x20] = 0x5001; + } + else + { + tilemap[0] = 0x5002; + tilemap[0x20] = 0x5002; + } +} + +void sub_81CBD48(u16 windowId, u32 arg0) +{ + u8 bg = GetWindowAttribute(windowId, WINDOW_BG); + u16 *tilemap = GetBgTilemapBuffer(bg); + tilemap += arg0 * 0x40 + 0x1D; + tilemap[0] = 0x5002; + tilemap[0x20] = 0x5002; +} + +static void sub_81CBD78(struct Pokenav4Struct *state) +{ + state->unk10 = AddWindow(&gUnknown_086227D8); + state->unk12 = AddWindow(&gUnknown_086227E0); + FillWindowPixelBuffer(state->unk10, PIXEL_FILL(1)); + PutWindowTilemap(state->unk10); + FillWindowPixelBuffer(state->unk12, PIXEL_FILL(1)); + PutWindowTilemap(state->unk12); + CopyWindowToVram(state->unk10, 1); +} + +static void sub_81CBDC0(struct Pokenav4Struct *state) +{ + FillWindowPixelBuffer(state->unk12, PIXEL_FILL(1)); + sub_81CBDF4(state->unk12); + sub_81CBE0C(state->unk12); + sub_81CBE38(state->unk12); + sub_81CBE50(state->unk12); + CopyWindowToVram(state->unk12, 2); +} + +static void sub_81CBDF4(u16 windowId) +{ + sub_81CBE88(windowId, gText_NumberRegistered, 0); +} + +static void sub_81CBE0C(u16 windowId) +{ + u8 str[3]; + ConvertIntToDecimalStringN(str, sub_81CAE38(), STR_CONV_MODE_LEFT_ALIGN, 3); + sub_81CBEB4(windowId, str, 1); +} + +static void sub_81CBE38(u16 windowId) +{ + sub_81CBE88(windowId, gText_NumberOfBattles, 2); +} + +static void sub_81CBE50(u16 windowId) +{ + u8 str[5]; + int numTrainerBattles = GetGameStat(GAME_STAT_TRAINER_BATTLES); + if (numTrainerBattles > 99999) + numTrainerBattles = 99999; + + ConvertIntToDecimalStringN(str, numTrainerBattles, STR_CONV_MODE_LEFT_ALIGN, 5); + sub_81CBEB4(windowId, str, 3); +} + +static void sub_81CBE88(u16 windowId, const u8 *str, int top) +{ + int y = top * 16 + 1; + AddTextPrinterParameterized(windowId, 7, str, 2, y, TEXT_SPEED_FF, NULL); +} + +static void sub_81CBEB4(u16 windowId, const u8 *str, int top) +{ + int x = GetStringRightAlignXOffset(7, str, 86); + int y = top * 16 + 1; + AddTextPrinterParameterized(windowId, 7, str, x, y, TEXT_SPEED_FF, NULL); +} + +static void sub_81CBEF8(struct Pokenav4Struct *state, int arg1) +{ + u8 mapName[32]; + int x; + int index = GetSelectedMatchCall() + arg1; + int regionMapSection = sub_81CAEA4(index); + if (regionMapSection != MAPSEC_NONE) + GetMapName(mapName, regionMapSection, 0); + else + StringCopy(mapName, gText_Unknown); + + x = GetStringCenterAlignXOffset(7, mapName, 88); + FillWindowPixelBuffer(state->unk10, PIXEL_FILL(1)); + AddTextPrinterParameterized(state->unk10, 7, mapName, x, 1, 0, NULL); +} + +static void sub_81CBF60(struct Pokenav4Struct *state) +{ + u32 i; + + FillWindowPixelBuffer(state->unk12, PIXEL_FILL(1)); + for (i = 0; i < 3; i++) + { + int messageId = sub_81CB02C(i); + if (messageId == 3) + break; + + AddTextPrinterParameterized(state->unk12, 7, gUnknown_086227E8[messageId], 16, i * 16 + 1, TEXT_SPEED_FF, NULL); + } + + CopyWindowToVram(state->unk12, 2); +} + +static bool32 sub_81CBFC4(struct Pokenav4Struct *state) +{ + if (!IsDma3ManagerBusyWithBgCopy()) + { + sub_81CC2F0(state, sub_81CB01C()); + return FALSE; + } + + return TRUE; +} + +static void sub_81CBFF0(struct Pokenav4Struct *state) +{ + sub_81CC330(state); + sub_81CBDC0(state); +} + +static bool32 sub_81CC004(struct Pokenav4Struct *state) +{ + return IsDma3ManagerBusyWithBgCopy(); +} + +static void sub_81CC014(struct Pokenav4Struct *state) +{ + sub_81CC330(state); + FillWindowPixelBuffer(state->unk12, PIXEL_FILL(1)); + CopyWindowToVram(state->unk12, 2); +} + +static void sub_81CC034(struct Pokenav4Struct *state) +{ + state->unk14 = AddWindow(&gUnknown_08622808); + sub_8197184(state->unk14, 1, 4); + sub_81C7B40(); +} + +static void sub_81CC058(struct Pokenav4Struct *state) +{ + struct Sprite *sprite; + sub_8197184(state->unk14, 1, 4); + sub_81971C4(state->unk14, 1, 4); + FillWindowPixelBuffer(state->unk14, PIXEL_FILL(1)); + PutWindowTilemap(state->unk14); + CopyWindowToVram(state->unk14, 3); + sprite = PauseSpinningPokenavSprite(); + sprite->pos1.x = 24; + sprite->pos1.y = 112; + sprite->pos2.y = 0; +} + +static void sub_81CC09C(struct Pokenav4Struct *state) +{ + LoadUserWindowBorderGfx(state->unk14, 1, 0x40); + DrawTextBorderOuter(state->unk14, 1, 4); + FillWindowPixelBuffer(state->unk14, PIXEL_FILL(1)); + PutWindowTilemap(state->unk14); + CopyWindowToVram(state->unk14, 3); +} + +static bool32 sub_81CC0D0(struct Pokenav4Struct *state) +{ + return IsDma3ManagerBusyWithBgCopy(); +} + +static void sub_81CC0E0(struct Pokenav4Struct *state) +{ + AddTextPrinterParameterized(state->unk14, 1, gUnknown_086227F4, 32, 1, 1, NULL); +} + +static bool32 sub_81CC104(struct Pokenav4Struct *state) +{ + RunTextPrinters(); + return IsTextPrinterActive(state->unk14); +} + +static void sub_81CC11C(struct Pokenav4Struct *state) +{ + AddTextPrinterParameterized(state->unk14, 1, gText_TrainerCloseBy, 0, 1, 1, NULL); +} + +static bool32 sub_81CC140(struct Pokenav4Struct *state) +{ + RunTextPrinters(); + return IsTextPrinterActive(state->unk14); +} + +static void sub_81CC158(struct Pokenav4Struct *state) +{ + int index = GetSelectedMatchCall(); + const u8 *str = sub_81CAF78(index, &state->unkF); + u8 speed = GetPlayerTextSpeedDelay(); + AddTextPrinterParameterized(state->unk14, 1, str, 32, 1, speed, NULL); +} + +static bool32 sub_81CC194(struct Pokenav4Struct *state) +{ + if (gMain.heldKeys & A_BUTTON) + gTextFlags.canABSpeedUpPrint = 1; + else + gTextFlags.canABSpeedUpPrint = 0; + + RunTextPrinters(); + return IsTextPrinterActive(state->unk14); +} + +static void sub_81CC1DC(struct Pokenav4Struct *state) +{ + ResumeSpinningPokenavSprite(); + FillBgTilemapBufferRect_Palette0(1, 0, 0, 0, 32, 20); + CopyBgTilemapBufferToVram(1); +} + +static bool32 sub_81CC204(struct Pokenav4Struct *state) +{ + return IsDma3ManagerBusyWithBgCopy(); +} + +static void sub_81CC214(void) +{ + int i; + u8 paletteNum; + struct SpriteSheet spriteSheet; + struct Pokenav4Struct *state = GetSubstructPtr(6); + + for (i = 0; i < ARRAY_COUNT(gUnknown_08622810); i++) + LoadCompressedSpriteSheet(&gUnknown_08622810[i]); + + Pokenav_AllocAndLoadPalettes(gUnknown_08622818); + state->unk1C = NULL; + spriteSheet.data = state->unk1828; + spriteSheet.size = 0x800; + spriteSheet.tag = 8; + state->unk1824 = (u8 *)OBJ_VRAM0 + LoadSpriteSheet(&spriteSheet) * 0x20; + paletteNum = AllocSpritePalette(13); + state->unk1A = 0x100 + paletteNum * 0x10; + state->unk20 = sub_81CC370(); + state->unk20->invisible = 1; +} + +static void sub_81CC2B4(void) +{ + struct Pokenav4Struct *state = GetSubstructPtr(6); + if (state->unk1C) + DestroySprite(state->unk1C); + if (state->unk20) + DestroySprite(state->unk20); + + FreeSpriteTilesByTag(8); + FreeSpriteTilesByTag(7); + FreeSpritePaletteByTag(12); + FreeSpritePaletteByTag(13); +} + +static void sub_81CC2F0(struct Pokenav4Struct *state, int top) +{ + if (!state->unk1C) + { + u8 spriteId = CreateSprite(&gUnknown_08622830, 4, 80, 5); + state->unk1C = &gSprites[spriteId]; + sub_81CC344(state, top); + } +} + +static void sub_81CC330(struct Pokenav4Struct *state) +{ + DestroySprite(state->unk1C); + state->unk1C = NULL; +} + +static void sub_81CC344(struct Pokenav4Struct *state, int top) +{ + state->unk1C->pos2.y = top * 16; +} + +void sub_81CC34C(struct Sprite *sprite) +{ + if (++sprite->data[0] > 3) + { + sprite->data[0] = 0; + sprite->pos2.x = (sprite->pos2.x + 1) & 0x7; + } +} + +static struct Sprite *sub_81CC370(void) +{ + u8 spriteId = CreateSprite(&gUnknown_08622850, 44, 104, 6); + return &gSprites[spriteId]; +} + +static void sub_81CC39C(struct Pokenav4Struct *state) +{ + u16 cursor; + int trainerId = sub_81CAF04(GetSelectedMatchCall()); + if (trainerId >= 0) + { + DecompressPicFromTable(&gTrainerFrontPicTable[trainerId], state->unk1828, SPECIES_NONE); + LZ77UnCompWram(gTrainerFrontPicPaletteTable[trainerId].data, state->unk2028); + cursor = RequestDma3Copy(state->unk1828, state->unk1824, 0x800, 1); + LoadPalette(state->unk2028, state->unk1A, 0x20); + state->unk20->data[0] = 0; + state->unk20->data[7] = cursor; + state->unk20->callback = sub_81CC440; + } +} + +static void sub_81CC420(struct Pokenav4Struct *state) +{ + state->unk20->callback = sub_81CC4A4; +} + +static bool32 sub_81CC42C(struct Pokenav4Struct *state) +{ + return state->unk20->callback != SpriteCallbackDummy; +} + +static void sub_81CC440(struct Sprite *sprite) +{ + switch (sprite->data[0]) + { + case 0: + if (CheckForSpaceForDma3Request(sprite->data[7]) != -1) + { + sprite->pos2.x = -80; + sprite->invisible = 0; + sprite->data[0]++; + } + break; + case 1: + sprite->pos2.x += 8; + if (sprite->pos2.x >= 0) + { + sprite->pos2.x = 0; + sprite->callback = SpriteCallbackDummy; + } + break; + } +} + +static void sub_81CC4A4(struct Sprite *sprite) +{ + sprite->pos2.x -= 8; + if (sprite->pos2.x <= -80) + { + sprite->invisible = 1; + sprite->callback = SpriteCallbackDummy; + } +}