From e2e667d4b5ef8df1b707fd8c654ea64b4ea51727 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Mon, 5 Aug 2019 13:47:04 -0400 Subject: [PATCH] Finish pokenav_unk_8 --- asm/pokenav_unk_8.s | 715 ------------------------------------ include/pokenav.h | 15 +- include/strings.h | 3 + ld_script.txt | 1 - src/pokenav_match_call_ui.c | 10 +- src/pokenav_unk_3.c | 71 ++-- src/pokenav_unk_4.c | 2 +- src/pokenav_unk_8.c | 360 ++++++++++++++++-- 8 files changed, 388 insertions(+), 789 deletions(-) delete mode 100644 asm/pokenav_unk_8.s diff --git a/asm/pokenav_unk_8.s b/asm/pokenav_unk_8.s deleted file mode 100644 index 85bd6e17d..000000000 --- a/asm/pokenav_unk_8.s +++ /dev/null @@ -1,715 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .syntax unified - -@ File centered around AllocSubstruct(7) - - thumb_func_start sub_81CF418 -sub_81CF418: @ 81CF418 - push {r4,r5,lr} - sub sp, 0x4 - adds r4, r0, 0 - movs r0, 0x8 - bl GetSubstructPtr - adds r5, r0, 0 - cmp r4, 0x5 - bls _081CF42C - b _081CF56E -_081CF42C: - lsls r0, r4, 2 - ldr r1, =_081CF43C - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_081CF43C: - .4byte _081CF454 - .4byte _081CF4AC - .4byte _081CF4C0 - .4byte _081CF4E0 - .4byte _081CF4F6 - .4byte _081CF55A -_081CF454: - ldr r0, =gUnknown_08623590 - movs r1, 0x2 - bl InitBgTemplates - ldr r1, =gUnknown_086233E4 - movs r0, 0 - str r0, [sp] - movs r0, 0x1 - movs r2, 0 - movs r3, 0 - bl decompress_and_copy_tile_data_to_vram - adds r1, r5, 0 - adds r1, 0x10 - movs r0, 0x1 - bl SetBgTilemapBuffer - ldr r1, =gUnknown_086234AC - movs r0, 0x1 - movs r2, 0 - movs r3, 0 - bl CopyToBgTilemapBuffer - movs r0, 0x1 - bl CopyBgTilemapBufferToVram - ldr r0, =gUnknown_086233C4 - movs r1, 0x10 - movs r2, 0x20 - bl CopyPaletteIntoBufferUnfaded - movs r0, 0x1 - bl CopyBgTilemapBufferToVram -_081CF498: - movs r0, 0 - b _081CF570 - .pool -_081CF4AC: - bl free_temp_tile_data_buffers_if_possible - lsls r0, 24 - cmp r0, 0 - bne _081CF56A - bl sub_81CF0C0 - cmp r0, 0 - beq _081CF56A - b _081CF498 -_081CF4C0: - bl free_temp_tile_data_buffers_if_possible - lsls r0, 24 - cmp r0, 0 - bne _081CF56A - ldr r0, =gUnknown_08623570 - movs r1, 0x20 - movs r2, 0x20 - bl CopyPaletteIntoBufferUnfaded - bl sub_81CF88C - b _081CF498 - .pool -_081CF4E0: - bl sub_81C8224 - cmp r0, 0 - bne _081CF56A - adds r0, r5, 0 - bl sub_81CF7C8 - movs r0, 0x3 - bl sub_81C7BA4 - b _081CF498 -_081CF4F6: - bl free_temp_tile_data_buffers_if_possible - lsls r0, 24 - cmp r0, 0 - bne _081CF56A - movs r0, 0x1 - movs r1, 0 - movs r2, 0 - bl ChangeBgX - movs r0, 0x1 - movs r1, 0 - movs r2, 0 - bl ChangeBgY - movs r0, 0x1 - bl ShowBg - movs r0, 0x2 - bl ShowBg - movs r0, 0x3 - bl HideBg - ldr r0, [r5, 0xC] - cmp r0, 0 - bne _081CF552 - bl sub_81C76AC - adds r4, r0, 0 - adds r4, 0x8 - lsls r4, 24 - lsrs r4, 24 - adds r0, r4, 0 - bl LoadLeftHeaderGfxForIndex - adds r0, r4, 0 - movs r1, 0x1 - movs r2, 0 - bl sub_81C7FA0 - movs r0, 0x1 - movs r1, 0x1 - movs r2, 0 - bl sub_81C7FA0 -_081CF552: - movs r0, 0x1 - bl sub_81C7AC0 - b _081CF498 -_081CF55A: - bl IsPaletteFadeActive - cmp r0, 0 - bne _081CF56A - bl sub_81C8010 - cmp r0, 0 - beq _081CF56E -_081CF56A: - movs r0, 0x2 - b _081CF570 -_081CF56E: - movs r0, 0x4 -_081CF570: - add sp, 0x4 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_81CF418 - - thumb_func_start sub_81CF578 -sub_81CF578: @ 81CF578 - push {r4,r5,lr} - adds r4, r0, 0 - movs r0, 0x8 - bl GetSubstructPtr - adds r5, r0, 0 - cmp r4, 0x1 - beq _081CF5C6 - cmp r4, 0x1 - bgt _081CF592 - cmp r4, 0 - beq _081CF59C - b _081CF5E6 -_081CF592: - cmp r4, 0x2 - beq _081CF5CE - cmp r4, 0x3 - beq _081CF5D8 - b _081CF5E6 -_081CF59C: - bl MatchCall_MoveCursorUp - cmp r0, 0x1 - beq _081CF5B4 - cmp r0, 0x1 - bgt _081CF5AE - cmp r0, 0 - beq _081CF5E6 - b _081CF5D4 -_081CF5AE: - cmp r0, 0x2 - beq _081CF5BE - b _081CF5D4 -_081CF5B4: - movs r0, 0x5 - bl PlaySE - movs r0, 0x7 - b _081CF5E8 -_081CF5BE: - movs r0, 0x5 - bl PlaySE - b _081CF5D4 -_081CF5C6: - bl sub_81C8630 - cmp r0, 0 - bne _081CF5E2 -_081CF5CE: - adds r0, r5, 0 - bl sub_81CF7F4 -_081CF5D4: - movs r0, 0 - b _081CF5E8 -_081CF5D8: - bl IsDma3ManagerBusyWithBgCopy - lsls r0, 24 - cmp r0, 0 - beq _081CF5E6 -_081CF5E2: - movs r0, 0x2 - b _081CF5E8 -_081CF5E6: - movs r0, 0x4 -_081CF5E8: - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_81CF578 - - thumb_func_start sub_81CF5F0 -sub_81CF5F0: @ 81CF5F0 - push {r4,r5,lr} - adds r4, r0, 0 - movs r0, 0x8 - bl GetSubstructPtr - adds r5, r0, 0 - cmp r4, 0x1 - beq _081CF63E - cmp r4, 0x1 - bgt _081CF60A - cmp r4, 0 - beq _081CF614 - b _081CF65E -_081CF60A: - cmp r4, 0x2 - beq _081CF646 - cmp r4, 0x3 - beq _081CF650 - b _081CF65E -_081CF614: - bl MatchCall_MoveCursorDown - cmp r0, 0x1 - beq _081CF62C - cmp r0, 0x1 - bgt _081CF626 - cmp r0, 0 - beq _081CF65E - b _081CF64C -_081CF626: - cmp r0, 0x2 - beq _081CF636 - b _081CF64C -_081CF62C: - movs r0, 0x5 - bl PlaySE - movs r0, 0x7 - b _081CF660 -_081CF636: - movs r0, 0x5 - bl PlaySE - b _081CF64C -_081CF63E: - bl sub_81C8630 - cmp r0, 0 - bne _081CF65A -_081CF646: - adds r0, r5, 0 - bl sub_81CF7F4 -_081CF64C: - movs r0, 0 - b _081CF660 -_081CF650: - bl IsDma3ManagerBusyWithBgCopy - lsls r0, 24 - cmp r0, 0 - beq _081CF65E -_081CF65A: - movs r0, 0x2 - b _081CF660 -_081CF65E: - movs r0, 0x4 -_081CF660: - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_81CF5F0 - - thumb_func_start sub_81CF668 -sub_81CF668: @ 81CF668 - push {r4,r5,lr} - adds r4, r0, 0 - movs r0, 0x8 - bl GetSubstructPtr - adds r5, r0, 0 - cmp r4, 0x1 - beq _081CF6B6 - cmp r4, 0x1 - bgt _081CF682 - cmp r4, 0 - beq _081CF68C - b _081CF6D6 -_081CF682: - cmp r4, 0x2 - beq _081CF6BE - cmp r4, 0x3 - beq _081CF6C8 - b _081CF6D6 -_081CF68C: - bl MatchCall_PageUp - cmp r0, 0x1 - beq _081CF6A4 - cmp r0, 0x1 - bgt _081CF69E - cmp r0, 0 - beq _081CF6D6 - b _081CF6C4 -_081CF69E: - cmp r0, 0x2 - beq _081CF6AE - b _081CF6C4 -_081CF6A4: - movs r0, 0x5 - bl PlaySE - movs r0, 0x7 - b _081CF6D8 -_081CF6AE: - movs r0, 0x5 - bl PlaySE - b _081CF6C4 -_081CF6B6: - bl sub_81C8630 - cmp r0, 0 - bne _081CF6D2 -_081CF6BE: - adds r0, r5, 0 - bl sub_81CF7F4 -_081CF6C4: - movs r0, 0 - b _081CF6D8 -_081CF6C8: - bl IsDma3ManagerBusyWithBgCopy - lsls r0, 24 - cmp r0, 0 - beq _081CF6D6 -_081CF6D2: - movs r0, 0x2 - b _081CF6D8 -_081CF6D6: - movs r0, 0x4 -_081CF6D8: - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_81CF668 - - thumb_func_start sub_81CF6E0 -sub_81CF6E0: @ 81CF6E0 - push {r4,r5,lr} - adds r4, r0, 0 - movs r0, 0x8 - bl GetSubstructPtr - adds r5, r0, 0 - cmp r4, 0x1 - beq _081CF72E - cmp r4, 0x1 - bgt _081CF6FA - cmp r4, 0 - beq _081CF704 - b _081CF74E -_081CF6FA: - cmp r4, 0x2 - beq _081CF736 - cmp r4, 0x3 - beq _081CF740 - b _081CF74E -_081CF704: - bl MatchCall_PageDown - cmp r0, 0x1 - beq _081CF71C - cmp r0, 0x1 - bgt _081CF716 - cmp r0, 0 - beq _081CF74E - b _081CF73C -_081CF716: - cmp r0, 0x2 - beq _081CF726 - b _081CF73C -_081CF71C: - movs r0, 0x5 - bl PlaySE - movs r0, 0x7 - b _081CF750 -_081CF726: - movs r0, 0x5 - bl PlaySE - b _081CF73C -_081CF72E: - bl sub_81C8630 - cmp r0, 0 - bne _081CF74A -_081CF736: - adds r0, r5, 0 - bl sub_81CF7F4 -_081CF73C: - movs r0, 0 - b _081CF750 -_081CF740: - bl IsDma3ManagerBusyWithBgCopy - lsls r0, 24 - cmp r0, 0 - beq _081CF74E -_081CF74A: - movs r0, 0x2 - b _081CF750 -_081CF74E: - movs r0, 0x4 -_081CF750: - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_81CF6E0 - - thumb_func_start sub_81CF758 -sub_81CF758: @ 81CF758 - push {lr} - cmp r0, 0 - beq _081CF764 - cmp r0, 0x1 - beq _081CF778 - b _081CF790 -_081CF764: - movs r0, 0x5 - bl PlaySE - movs r0, 0 - bl sub_81C7AC0 - bl sub_81C78A0 - movs r0, 0 - b _081CF792 -_081CF778: - bl IsPaletteFadeActive - cmp r0, 0 - bne _081CF788 - bl MainMenuLoopedTaskIsBusy - cmp r0, 0 - beq _081CF78C -_081CF788: - movs r0, 0x2 - b _081CF792 -_081CF78C: - bl sub_81C7FDC -_081CF790: - movs r0, 0x4 -_081CF792: - pop {r1} - bx r1 - thumb_func_end sub_81CF758 - - thumb_func_start sub_81CF798 -sub_81CF798: @ 81CF798 - push {lr} - cmp r0, 0 - beq _081CF7A4 - cmp r0, 0x1 - beq _081CF7B4 - b _081CF7C0 -_081CF7A4: - movs r0, 0x5 - bl PlaySE - movs r0, 0 - bl sub_81C7AC0 - movs r0, 0 - b _081CF7C2 -_081CF7B4: - bl IsPaletteFadeActive - cmp r0, 0 - beq _081CF7C0 - movs r0, 0x2 - b _081CF7C2 -_081CF7C0: - movs r0, 0x4 -_081CF7C2: - pop {r1} - bx r1 - thumb_func_end sub_81CF798 - - thumb_func_start sub_81CF7C8 -sub_81CF7C8: @ 81CF7C8 - push {r4,lr} - adds r4, r0, 0 - ldr r0, =gUnknown_086235B4 - bl AddWindow - strh r0, [r4, 0x8] - lsls r0, 24 - lsrs r0, 24 - bl PutWindowTilemap - ldrb r0, [r4, 0x8] - movs r1, 0x1 - bl CopyWindowToVram - adds r0, r4, 0 - bl sub_81CF7F4 - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81CF7C8 - - thumb_func_start sub_81CF7F4 -sub_81CF7F4: @ 81CF7F4 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0xC - mov r8, r0 - bl sub_81CF0F0 - adds r7, r0, 0 - bl DynamicPlaceholderTextUtil_Reset - ldr r4, =gStringVar1 - movs r0, 0 - adds r1, r4, 0 - bl DynamicPlaceholderTextUtil_SetPlaceholderPtr - movs r0, 0xFF - strb r0, [r4] - ldr r5, =gStringVar2 - ldr r1, =gText_NumberF700 - adds r0, r5, 0 - bl DynamicPlaceholderTextUtil_ExpandPlaceholders - mov r1, r8 - ldrb r0, [r1, 0x8] - movs r1, 0x1 - mov r10, r1 - str r1, [sp] - movs r1, 0xFF - mov r9, r1 - str r1, [sp, 0x4] - movs r6, 0 - str r6, [sp, 0x8] - movs r1, 0x1 - adds r2, r5, 0 - movs r3, 0x4 - bl AddTextPrinterParameterized - adds r0, r4, 0 - adds r1, r7, 0 - movs r2, 0x1 - movs r3, 0x3 - bl ConvertIntToDecimalStringN - mov r1, r8 - ldrb r0, [r1, 0x8] - mov r1, r10 - str r1, [sp] - mov r1, r9 - str r1, [sp, 0x4] - str r6, [sp, 0x8] - movs r1, 0x1 - adds r2, r4, 0 - movs r3, 0x22 - bl AddTextPrinterParameterized - mov r1, r8 - ldrb r0, [r1, 0x8] - movs r1, 0x2 - bl CopyWindowToVram - add sp, 0xC - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81CF7F4 - - thumb_func_start sub_81CF88C -sub_81CF88C: @ 81CF88C - push {r4,lr} - sub sp, 0x18 - bl sub_81CF0D0 - str r0, [sp] - bl sub_81CF0E0 - mov r1, sp - movs r4, 0 - strh r0, [r1, 0x4] - movs r0, 0x4 - strb r0, [r1, 0x8] - bl sub_81CF10C - mov r1, sp - strh r0, [r1, 0x6] - movs r0, 0xD - strb r0, [r1, 0x9] - movs r0, 0x11 - strb r0, [r1, 0xA] - mov r0, sp - movs r2, 0x1 - strb r2, [r0, 0xB] - movs r0, 0x8 - strb r0, [r1, 0xC] - movs r0, 0x2 - strb r0, [r1, 0xD] - mov r0, sp - strb r2, [r0, 0xE] - ldr r0, =sub_81CF8E4 - str r0, [sp, 0x10] - str r4, [sp, 0x14] - ldr r0, =gUnknown_08623594 - movs r2, 0 - bl sub_81C81D4 - add sp, 0x18 - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81CF88C - - thumb_func_start sub_81CF8E4 -sub_81CF8E4: @ 81CF8E4 - push {r4-r7,lr} - adds r2, r0, 0 - adds r6, r1, 0 - ldrb r0, [r2] - cmp r0, 0xE - bne _081CF924 - ldrb r1, [r2, 0x1] - movs r0, 0x64 - adds r4, r1, 0 - muls r4, r0 - ldr r0, =gPlayerParty - adds r4, r0 - adds r0, r4, 0 - bl GetMonGender - lsls r0, 24 - lsrs r5, r0, 24 - adds r0, r4, 0 - bl GetLevelFromMonExp - lsls r0, 24 - lsrs r7, r0, 24 - ldr r2, =gStringVar3 - adds r0, r4, 0 - movs r1, 0x2 - bl GetMonData - b _081CF94A - .pool -_081CF924: - ldrb r0, [r2] - ldrb r1, [r2, 0x1] - bl GetBoxedMonPtr - adds r4, r0, 0 - bl GetBoxMonGender - lsls r0, 24 - lsrs r5, r0, 24 - adds r0, r4, 0 - bl GetLevelFromBoxMonExp - lsls r0, 24 - lsrs r7, r0, 24 - ldr r2, =gStringVar3 - adds r0, r4, 0 - movs r1, 0x2 - bl GetBoxMonData -_081CF94A: - ldr r4, =gStringVar3 - adds r0, r4, 0 - bl StringGetEnd10 - adds r0, r6, 0 - movs r1, 0x1 - adds r2, r4, 0 - movs r3, 0x3C - bl sub_81DB494 - adds r6, r0, 0 - cmp r5, 0 - beq _081CF974 - cmp r5, 0xFE - beq _081CF97C - ldr r1, =gUnknown_086235D4 - b _081CF97E - .pool -_081CF974: - ldr r1, =gUnknown_086235BC - b _081CF97E - .pool -_081CF97C: - ldr r1, =gUnknown_086235C8 -_081CF97E: - ldr r4, =gStringVar1 - adds r0, r4, 0 - bl StringCopy - movs r1, 0xBA - strb r1, [r0] - adds r0, 0x1 - movs r1, 0xF9 - strb r1, [r0] - adds r0, 0x1 - movs r1, 0x5 - strb r1, [r0] - adds r0, 0x1 - adds r1, r7, 0 - movs r2, 0 - movs r3, 0x3 - bl ConvertIntToDecimalStringN - adds r0, r6, 0 - movs r1, 0x1 - adds r2, r4, 0 - movs r3, 0x28 - bl sub_81DB494 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81CF8E4 - - .align 2, 0 @ Don't pad with nop. diff --git a/include/pokenav.h b/include/pokenav.h index 276fe7262..c6fd8a622 100644 --- a/include/pokenav.h +++ b/include/pokenav.h @@ -77,7 +77,7 @@ void SetVBlankCallback_(IntrCallback callback); // pokenav_match_call_ui.c struct MatchCallListTemplate { - u32 unk0; + struct PokenavMonList * unk0; u16 unk4; u16 unk6; u8 unk8; @@ -87,9 +87,10 @@ struct MatchCallListTemplate u8 unkC; u8 unkD; u8 unkE; - void (*unk10)(u32, u8 *a1); + void (*unk10)(struct PokenavMonList *, u8 *a1); void (*unk14)(u16 a0, u32 a1, u32 a2); }; + u32 GetSelectedMatchCall(void); bool32 sub_81C8224(void); int MatchCall_MoveCursorUp(void); @@ -167,26 +168,20 @@ void sub_81C99D4(void); void sub_81CAADC(void); // pokenav_unk_3.c -struct Pokenav3Struct_Unk1C -{ - u8 unk0; - u8 unk1; - u16 unk2; -}; bool32 sub_81CAAE8(void); u32 sub_81CAB24(void); void sub_81CAB38(void); int sub_81CAE28(void); int sub_81CAE38(void); int sub_81CAE48(void); -struct Pokenav3Struct_Unk1C *sub_81CAE94(void); +struct PokenavMonList *sub_81CAE94(void); u16 sub_81CAEA4(int); bool32 sub_81CAEBC(int index); 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(u32 arg0, u8 *str); +void sub_81CB050(struct PokenavMonList * arg0, u8 *str); u8 sub_81CB0C8(int rematchIndex); int sub_81CB0E4(int index); bool32 sub_81CAE08(int); diff --git a/include/strings.h b/include/strings.h index f2d3f23ad..7e7fcd322 100644 --- a/include/strings.h +++ b/include/strings.h @@ -2773,6 +2773,9 @@ extern const u8 gUnknown_085EC017[]; extern const u8 gUnknown_085EC01C[]; extern const u8 gUnknown_085EC022[]; +// pokenav_unk_8 +extern const u8 gText_NumberF700[]; + // pokenav_unk_10 extern const u8 gText_RibbonsF700[]; diff --git a/ld_script.txt b/ld_script.txt index 1fbd464f7..339855e23 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -316,7 +316,6 @@ SECTIONS { src/pokenav_unk_6.o(.text); src/pokenav_unk_7.o(.text); src/pokenav_unk_8.o(.text); - asm/pokenav_unk_8.o(.text); src/pokenav_unk_9.o(.text); asm/pokenav_unk_9.o(.text); src/pokenav_unk_10.o(.text); diff --git a/src/pokenav_match_call_ui.c b/src/pokenav_match_call_ui.c index 5204f0ed7..275a4063e 100644 --- a/src/pokenav_match_call_ui.c +++ b/src/pokenav_match_call_ui.c @@ -31,7 +31,7 @@ struct MatchCallWindowState { u16 visibleEntries; u16 unkA; u32 unkC; - u32 unk10; + void * unk10; }; struct PokenavSub17Substruct @@ -40,13 +40,13 @@ struct PokenavSub17Substruct u32 unk10; u32 unk14; u32 unk18; - u32 unk1C; + void * unk1C; s32 unk20; s32 unk24; u32 unk28; s32 unk2C; u32 unk30; - void (*unk34)(u32, u8*); + void (*unk34)(struct PokenavMonList *, u8*); void (*unk38)(u16, u32, u32); struct Sprite *rightArrow; struct Sprite *upArrow; @@ -82,7 +82,7 @@ void sub_81C8D4C(struct MatchCallWindowState *a0, struct PokenavSub17Substruct * void sub_81C8CB4(struct MatchCallWindowState *a0, struct PokenavSub17Substruct *a1); void sub_81C8B70(struct UnknownSubSubStruct_0203CF40 *a0, s32 a1, s32 a2); void sub_81C8568(s32 a0, struct PokenavSub17Substruct *a1); -void sub_81C83AC(u32 a0, u32 a1, u32 a2, u32 a3, u32 a4, struct PokenavSub17Substruct *a5); +void sub_81C83AC(void * a0, u32 a1, u32 a2, u32 a3, u32 a4, struct PokenavSub17Substruct *a5); void sub_81C837C(struct MatchCallWindowState *a0, struct PokenavSub17Substruct *a1); void sub_81C835C(struct UnknownSubSubStruct_0203CF40 *a0); u32 LoopedTask_sub_81C8254(s32 state); @@ -194,7 +194,7 @@ void sub_81C837C(struct MatchCallWindowState *a0, struct PokenavSub17Substruct * sub_81C83AC(a0->unk10, a0->windowTopIndex, arg2, a0->unkC, 0, a1); } -void sub_81C83AC(u32 a0, u32 a1, u32 a2, u32 a3, u32 a4, struct PokenavSub17Substruct *a5) +void sub_81C83AC(void * a0, u32 a1, u32 a2, u32 a3, u32 a4, struct PokenavSub17Substruct *a5) { if (a2 == 0) return; diff --git a/src/pokenav_unk_3.c b/src/pokenav_unk_3.c index 9b62bea78..e44a6563a 100755 --- a/src/pokenav_unk_3.c +++ b/src/pokenav_unk_3.c @@ -26,7 +26,7 @@ struct Pokenav3Struct u32 unk10; u32 unk14; u32 (*callback)(struct Pokenav3Struct*); - struct Pokenav3Struct_Unk1C unk1C[99]; + struct PokenavMonList unk1C[99]; }; static u32 sub_81CAB44(struct Pokenav3Struct *); @@ -84,7 +84,7 @@ static u32 sub_81CAB44(struct Pokenav3Struct *state) state->callback = sub_81CAC04; state->unk0 = 0; selectedMatchCall = GetSelectedMatchCall(); - if (!state->unk1C[selectedMatchCall].unk0 || sub_81D17E8(state->unk1C[selectedMatchCall].unk2)) + if (!state->unk1C[selectedMatchCall].boxId || sub_81D17E8(state->unk1C[selectedMatchCall].unk6)) { state->unk4 = gUnknown_0862250A; state->unk2 = 2; @@ -206,9 +206,9 @@ static u32 sub_81CAD20(s32 taskState) { if (MatchCallFlagGetByIndex(j)) { - state->unk1C[state->unkA].unk2 = j; - state->unk1C[state->unkA].unk0 = 1; - state->unk1C[state->unkA].unk1 = MatchCallMapSecGetByIndex(j); + state->unk1C[state->unkA].unk6 = j; + state->unk1C[state->unkA].boxId = 1; + state->unk1C[state->unkA].monId = MatchCallMapSecGetByIndex(j); state->unkA++; } @@ -226,9 +226,9 @@ static u32 sub_81CAD20(s32 taskState) { if (!sub_81D1BF8(state->unk8) && sub_81CAE08(state->unk8)) { - state->unk1C[state->unkA].unk2 = state->unk8; - state->unk1C[state->unkA].unk0 = 0; - state->unk1C[state->unkA].unk1 = sub_81CB0C8(j); + state->unk1C[state->unkA].unk6 = state->unk8; + state->unk1C[state->unkA].boxId = 0; + state->unk1C[state->unkA].monId = sub_81CB0C8(j); state->unkA++; } @@ -284,10 +284,10 @@ int unref_sub_81CAE6C(int arg0) if (arg0 >= state->unkA) return REMATCH_TABLE_ENTRIES; - return state->unk1C[arg0].unk2; + return state->unk1C[arg0].unk6; } -struct Pokenav3Struct_Unk1C *sub_81CAE94(void) +struct PokenavMonList *sub_81CAE94(void) { struct Pokenav3Struct *state = GetSubstructPtr(5); return state->unk1C; @@ -296,16 +296,16 @@ struct Pokenav3Struct_Unk1C *sub_81CAE94(void) u16 sub_81CAEA4(int index) { struct Pokenav3Struct *state = GetSubstructPtr(5); - return state->unk1C[index].unk1; + return state->unk1C[index].monId; } bool32 sub_81CAEBC(int index) { struct Pokenav3Struct *state = GetSubstructPtr(5); - if (!state->unk1C[index].unk0) - index = state->unk1C[index].unk2; + if (!state->unk1C[index].boxId) + index = state->unk1C[index].unk6; else - index = MatchCall_GetRematchTableIdx(state->unk1C[index].unk2); + index = MatchCall_GetRematchTableIdx(state->unk1C[index].unk6); if (index == REMATCH_TABLE_ENTRIES) return FALSE; @@ -317,13 +317,13 @@ int sub_81CAF04(int index) { int var0; struct Pokenav3Struct *state = GetSubstructPtr(5); - if (!state->unk1C[index].unk0) + if (!state->unk1C[index].boxId) { - index = GetTrainerIdxByRematchIdx(state->unk1C[index].unk2); + index = GetTrainerIdxByRematchIdx(state->unk1C[index].unk6); return gTrainers[index].trainerPic; } - var0 = state->unk1C[index].unk2; + var0 = state->unk1C[index].unk6; index = MatchCall_GetRematchTableIdx(var0); if (index != REMATCH_TABLE_ENTRIES) { @@ -342,10 +342,10 @@ const u8 *sub_81CAF78(int index, u8 *arg1) if (!Overworld_MapTypeAllowsTeleportAndFly(gMapHeader.mapType)) return gText_CallCantBeMadeHere; - if (!state->unk1C[index].unk0) - *arg1 = SelectMatchCallMessage(GetTrainerIdxByRematchIdx(state->unk1C[index].unk2), gStringVar4); + if (!state->unk1C[index].boxId) + *arg1 = SelectMatchCallMessage(GetTrainerIdxByRematchIdx(state->unk1C[index].unk6), gStringVar4); else - MatchCall_GetMessage(state->unk1C[index].unk2, gStringVar4); + MatchCall_GetMessage(state->unk1C[index].unk6, gStringVar4); return gStringVar4; } @@ -354,15 +354,15 @@ const u8 *sub_81CAFD8(int index, int textType) { int var0; struct Pokenav3Struct *state = GetSubstructPtr(5); - if (state->unk1C[index].unk0) + if (state->unk1C[index].boxId) { - var0 = MatchCall_GetRematchTableIdx(state->unk1C[index].unk2); + var0 = MatchCall_GetRematchTableIdx(state->unk1C[index].unk6); if (var0 == REMATCH_TABLE_ENTRIES) - return sub_81D1B40(state->unk1C[index].unk2, textType); + return sub_81D1B40(state->unk1C[index].unk6, textType); } else { - var0 = state->unk1C[index].unk2; + var0 = state->unk1C[index].unk6; } return gMatchCallMessages[var0][textType]; @@ -383,14 +383,13 @@ u16 sub_81CB02C(int arg0) return state->unk4[arg0]; } -void sub_81CB050(u32 arg0, u8 *str) +void sub_81CB050(struct PokenavMonList * arg0, u8 *str) { - struct Pokenav3Struct_Unk1C *var0 = (struct Pokenav3Struct_Unk1C *)arg0; const u8 *trainerName; const u8 *className; - if (!var0->unk0) + if (!arg0->boxId) { - int index = GetTrainerIdxByRematchIdx(var0->unk2); + int index = GetTrainerIdxByRematchIdx(arg0->unk6); const struct Trainer *trainer = &gTrainers[index]; int class = trainer->trainerClass; className = gTrainerClassNames[class]; @@ -398,7 +397,7 @@ void sub_81CB050(u32 arg0, u8 *str) } else { - sub_81D1A78(var0->unk2, &className, &trainerName); + sub_81D1A78(arg0->unk6, &className, &trainerName); } if (className && trainerName) @@ -425,9 +424,9 @@ int sub_81CB0E4(int index) int count = 1; while (++index < state->unkA) { - if (!state->unk1C[index].unk0) + if (!state->unk1C[index].boxId) return count; - if (sub_81D17E8(state->unk1C[index].unk2)) + if (sub_81D17E8(state->unk1C[index].unk6)) return count; count++; @@ -442,9 +441,9 @@ int sub_81CB128(int index) int count = -1; while (--index >= 0) { - if (!state->unk1C[index].unk0) + if (!state->unk1C[index].boxId) return count; - if (sub_81D17E8(state->unk1C[index].unk2)) + if (sub_81D17E8(state->unk1C[index].unk6)) return count; count--; @@ -480,17 +479,17 @@ static bool32 sub_81CB1D0(void) { struct Pokenav3Struct *state = GetSubstructPtr(5); int index = GetSelectedMatchCall(); - if (!state->unk1C[index].unk0) + if (!state->unk1C[index].boxId) { if (sub_81CAEA4(index) == gMapHeader.regionMapSectionId) { - if (!gSaveBlock1Ptr->trainerRematches[state->unk1C[index].unk2]) + if (!gSaveBlock1Ptr->trainerRematches[state->unk1C[index].unk6]) return TRUE; } } else { - if (state->unk1C[index].unk2 == 11) + if (state->unk1C[index].unk6 == 11) { if (sub_81CAEA4(index) == gMapHeader.regionMapSectionId && FlagGet(FLAG_BADGE05_GET) == TRUE) diff --git a/src/pokenav_unk_4.c b/src/pokenav_unk_4.c index 93dab4491..f436cc3ca 100755 --- a/src/pokenav_unk_4.c +++ b/src/pokenav_unk_4.c @@ -870,7 +870,7 @@ u32 sub_81CBB74(s32 taskState) static void sub_81CBBB8(void) { struct MatchCallListTemplate template; - template.unk0 = (u32)sub_81CAE94(); + template.unk0 = sub_81CAE94(); template.unk4 = sub_81CAE38(); template.unk8 = 4; template.unk6 = 0; diff --git a/src/pokenav_unk_8.c b/src/pokenav_unk_8.c index 3f8eb5324..1750a24ba 100644 --- a/src/pokenav_unk_8.c +++ b/src/pokenav_unk_8.c @@ -1,7 +1,14 @@ #include "global.h" #include "pokenav.h" #include "bg.h" +#include "menu.h" #include "window.h" +#include "sound.h" +#include "dynamic_placeholder_text_util.h" +#include "strings.h" +#include "string_util.h" +#include "international_string_util.h" +#include "constants/songs.h" struct PokenavSub7 { @@ -48,26 +55,25 @@ const u32 gUnknown_086233E4[] = INCBIN_U32("graphics/pokenav/condition_search2.4 const u32 gUnknown_086234AC[] = INCBIN_U32("graphics/pokenav/condition_search2.bin.lz"); const u16 gUnknown_08623570[] = INCBIN_U16("graphics/pokenav/8623570.gbapal"); -const struct BgTemplate gUnknown_08623590 = +const struct BgTemplate gUnknown_08623590[] = { - .bg = 1, - .charBaseIndex = 1, - .mapBaseIndex = 0x06, - .screenSize = 0, - .paletteMode = 0, - .priority = 2, - .baseTile = 0 -}; - -const struct BgTemplate gUnknown_08623594 = -{ - .bg = 2, - .charBaseIndex = 2, - .mapBaseIndex = 0x07, - .screenSize = 0, - .paletteMode = 0, - .priority = 3, - .baseTile = 0 + { + .bg = 1, + .charBaseIndex = 1, + .mapBaseIndex = 0x06, + .screenSize = 0, + .paletteMode = 0, + .priority = 2, + .baseTile = 0 + }, { + .bg = 2, + .charBaseIndex = 2, + .mapBaseIndex = 0x07, + .screenSize = 0, + .paletteMode = 0, + .priority = 3, + .baseTile = 0 + } }; const LoopedTask gUnknown_08623598[] = @@ -202,7 +208,7 @@ u16 sub_81CF0E0(void) return ptr->unkPtr->unk0; } -u16 sub_81CF0F0(void) +s32 sub_81CF0F0(void) { struct PokenavSub7 * ptr = (struct PokenavSub7 *)GetSubstructPtr(7); s32 i = GetSelectedMatchCall(); @@ -337,13 +343,17 @@ struct PokenavSub8 { bool32 (*callback)(void); u32 ltid; - u8 winid; + u16 winid; bool32 unkC; u16 buff[0x400]; }; // size: 0x810 bool32 sub_81CF3E4(void); u32 sub_81CF418(s32 state); +void sub_81CF7C8(struct PokenavSub8 *); +void sub_81CF7F4(struct PokenavSub8 *); +void sub_81CF88C(void); +void sub_81CF8E4(struct PokenavMonList *, u8 *); bool32 sub_81CF330(void) { @@ -393,3 +403,311 @@ void sub_81CF3F8(void) RemoveWindow(unk->winid); FreePokenavSubstruct(8); } + +u32 sub_81CF418(s32 state) +{ + struct PokenavSub8 * unk = (struct PokenavSub8 *)GetSubstructPtr(8); + switch (state) + { + case 0: + InitBgTemplates(gUnknown_08623590, NELEMS(gUnknown_08623590)); + decompress_and_copy_tile_data_to_vram(1, gUnknown_086233E4, 0, 0, 0); + SetBgTilemapBuffer(1, unk->buff); + CopyToBgTilemapBuffer(1, gUnknown_086234AC, 0, 0); + CopyBgTilemapBufferToVram(1); + CopyPaletteIntoBufferUnfaded(gUnknown_086233C4, 0x10, 0x20); + CopyBgTilemapBufferToVram(1); + return LT_INC_AND_PAUSE; + case 1: + if (free_temp_tile_data_buffers_if_possible()) + return LT_PAUSE; + if (!sub_81CF0C0()) + return LT_PAUSE; + return LT_INC_AND_PAUSE; + case 2: + if (free_temp_tile_data_buffers_if_possible()) + return LT_PAUSE; + CopyPaletteIntoBufferUnfaded(gUnknown_08623570, 0x20, 0x20); + sub_81CF88C(); + return LT_INC_AND_PAUSE; + case 3: + if (sub_81C8224()) + return LT_PAUSE; + sub_81CF7C8(unk); + sub_81C7BA4(3); + return LT_INC_AND_PAUSE; + case 4: + if (free_temp_tile_data_buffers_if_possible()) + return LT_PAUSE; + ChangeBgX(1, 0, 0); + ChangeBgY(1, 0, 0); + ShowBg(1); + ShowBg(2); + HideBg(3); + if (!unk->unkC) + { + u8 r4 = sub_81C76AC() + 8; + LoadLeftHeaderGfxForIndex(r4); + sub_81C7FA0(r4, 1, 0); + sub_81C7FA0(1, 1, 0); + } + sub_81C7AC0(1); + return LT_INC_AND_PAUSE; + case 5: + if (IsPaletteFadeActive()) + return LT_PAUSE; + if (sub_81C8010()) + return LT_PAUSE; + break; + } + return LT_FINISH; +} + +u32 sub_81CF578(s32 state) +{ + struct PokenavSub8 * unk = (struct PokenavSub8 *)GetSubstructPtr(8); + switch (state) + { + case 0: + switch (MatchCall_MoveCursorUp()) + { + case 0: + return LT_FINISH; + case 1: + PlaySE(SE_SELECT); + return LT_SET_STATE(2); + case 2: + PlaySE(SE_SELECT); + break; + } + return LT_INC_AND_PAUSE; + case 1: + if (sub_81C8630()) + return LT_PAUSE; + // fallthrough + case 2: + sub_81CF7F4(unk); + return LT_INC_AND_PAUSE; + case 3: + if (IsDma3ManagerBusyWithBgCopy()) + return LT_PAUSE; + break; + } + return LT_FINISH; +} + +u32 sub_81CF5F0(s32 state) +{ + struct PokenavSub8 * unk = (struct PokenavSub8 *)GetSubstructPtr(8); + switch (state) + { + case 0: + switch (MatchCall_MoveCursorDown()) + { + case 0: + return LT_FINISH; + case 1: + PlaySE(SE_SELECT); + return LT_SET_STATE(2); + case 2: + PlaySE(SE_SELECT); + break; + } + return LT_INC_AND_PAUSE; + case 1: + if (sub_81C8630()) + return LT_PAUSE; + // fallthrough + case 2: + sub_81CF7F4(unk); + return LT_INC_AND_PAUSE; + case 3: + if (IsDma3ManagerBusyWithBgCopy()) + return LT_PAUSE; + break; + } + return LT_FINISH; +} + +u32 sub_81CF668(s32 state) +{ + struct PokenavSub8 * unk = (struct PokenavSub8 *)GetSubstructPtr(8); + switch (state) + { + case 0: + switch (MatchCall_PageUp()) + { + case 0: + return LT_FINISH; + case 1: + PlaySE(SE_SELECT); + return LT_SET_STATE(2); + case 2: + PlaySE(SE_SELECT); + break; + } + return LT_INC_AND_PAUSE; + case 1: + if (sub_81C8630()) + return LT_PAUSE; + // fallthrough + case 2: + sub_81CF7F4(unk); + return LT_INC_AND_PAUSE; + case 3: + if (IsDma3ManagerBusyWithBgCopy()) + return LT_PAUSE; + break; + } + return LT_FINISH; +} + +u32 sub_81CF6E0(s32 state) +{ + struct PokenavSub8 * unk = (struct PokenavSub8 *)GetSubstructPtr(8); + switch (state) + { + case 0: + switch (MatchCall_PageDown()) + { + case 0: + return LT_FINISH; + case 1: + PlaySE(SE_SELECT); + return LT_SET_STATE(2); + case 2: + PlaySE(SE_SELECT); + break; + } + return LT_INC_AND_PAUSE; + case 1: + if (sub_81C8630()) + return LT_PAUSE; + // fallthrough + case 2: + sub_81CF7F4(unk); + return LT_INC_AND_PAUSE; + case 3: + if (IsDma3ManagerBusyWithBgCopy()) + return LT_PAUSE; + break; + } + return LT_FINISH; +} + +u32 sub_81CF758(s32 state) +{ + switch (state) + { + case 0: + PlaySE(SE_SELECT); + sub_81C7AC0(0); + sub_81C78A0(); + return LT_INC_AND_PAUSE; + case 1: + if (IsPaletteFadeActive()) + return LT_PAUSE; + if (MainMenuLoopedTaskIsBusy()) + return LT_PAUSE; + sub_81C7FDC(); + break; + } + return LT_FINISH; +} + +u32 sub_81CF798(s32 state) +{ + switch (state) + { + case 0: + PlaySE(SE_SELECT); + sub_81C7AC0(0); + return LT_INC_AND_PAUSE; + case 1: + if (IsPaletteFadeActive()) + return LT_PAUSE; + break; + } + return LT_FINISH; +} + +void sub_81CF7C8(struct PokenavSub8 * ptr) +{ + ptr->winid = AddWindow(&gUnknown_086235B4); + PutWindowTilemap(ptr->winid); + CopyWindowToVram(ptr->winid, 1); + sub_81CF7F4(ptr); +} + +void sub_81CF7F4(struct PokenavSub8 * ptr) +{ + s32 r7 = sub_81CF0F0(); + DynamicPlaceholderTextUtil_Reset(); + DynamicPlaceholderTextUtil_SetPlaceholderPtr(0, gStringVar1); + *gStringVar1 = EOS; + DynamicPlaceholderTextUtil_ExpandPlaceholders(gStringVar2, gText_NumberF700); + AddTextPrinterParameterized(ptr->winid, 1, gStringVar2, 4, 1, 0xFF, NULL); + ConvertIntToDecimalStringN(gStringVar1, r7, STR_CONV_MODE_RIGHT_ALIGN, 3); + AddTextPrinterParameterized(ptr->winid, 1, gStringVar1, 34, 1, 0xFF, NULL); + CopyWindowToVram(ptr->winid, 2); +} + +void sub_81CF88C(void) +{ + struct MatchCallListTemplate template; + template.unk0 = sub_81CF0D0(); + template.unk4 = sub_81CF0E0(); + template.unk8 = 4; + template.unk6 = sub_81CF10C(); + template.unk9 = 13; + template.unkA = 17; + template.unkB = 1; + template.unkC = 8; + template.unkD = 2; + template.unkE = 1; + template.unk10 = sub_81CF8E4; + template.unk14 = NULL; + sub_81C81D4(&gUnknown_08623590[1], &template, 0); +} + +void sub_81CF8E4(struct PokenavMonList * item, u8 * dest) +{ + u8 gender; + u8 level; + u8 * s; + const u8 * genderStr; + if (item->boxId == 14) + { + struct Pokemon * mon = &gPlayerParty[item->monId]; + gender = GetMonGender(mon); + level = GetLevelFromMonExp(mon); + GetMonData(mon, MON_DATA_NICKNAME, gStringVar3); + } + else + { + struct BoxPokemon * mon = GetBoxedMonPtr(item->boxId, item->monId); + gender = GetBoxMonGender(mon); + level = GetLevelFromBoxMonExp(mon); + GetBoxMonData(mon, MON_DATA_NICKNAME, gStringVar3); + } + StringGetEnd10(gStringVar3); + dest = sub_81DB494(dest, 1, gStringVar3, 60); + switch (gender) + { + default: + genderStr = gUnknown_086235D4; + break; + case MON_MALE: + genderStr = gUnknown_086235BC; + break; + case MON_FEMALE: + genderStr = gUnknown_086235C8; + break; + } + s = StringCopy(gStringVar1, genderStr); + *s++ = CHAR_SLASH; + *s++ = CHAR_SPECIAL_F9; + *s++ = 5; // LV + ConvertIntToDecimalStringN(s, level, STR_CONV_MODE_LEFT_ALIGN, 3); + sub_81DB494(dest, 1, gStringVar1, 40); +}