From 9bea9e1624a30980aa194b076f0324b77c76edc9 Mon Sep 17 00:00:00 2001 From: Phlosioneer Date: Tue, 5 Mar 2019 06:06:20 -0500 Subject: [PATCH] Start decompiling menu_unknown --- asm/menu_unknown.s | 320 ----------------------------------------- data/menu_unknown.s | 14 -- include/menu.h | 2 +- include/menu_unknown.h | 15 ++ include/pokenav.h | 9 -- ld_script.txt | 2 + src/menu_unknown.c | 186 ++++++++++++++++++++++++ src/party_menu.c | 3 +- src/player_pc.c | 2 +- 9 files changed, 207 insertions(+), 346 deletions(-) create mode 100644 include/menu_unknown.h create mode 100644 src/menu_unknown.c diff --git a/asm/menu_unknown.s b/asm/menu_unknown.s index 6b449e704..52f4dbee0 100644 --- a/asm/menu_unknown.s +++ b/asm/menu_unknown.s @@ -5,327 +5,7 @@ .syntax unified .text - - thumb_func_start sub_81D1C44 -sub_81D1C44: @ 81D1C44 - push {r4,lr} - lsls r0, 24 - ldr r4, =gUnknown_0203CF4C - lsrs r0, 21 - adds r0, 0x8 - bl Alloc - str r0, [r4] - cmp r0, 0 - bne _081D1C60 - movs r0, 0 - b _081D1C7A - .pool -_081D1C60: - movs r2, 0 - ldr r4, =gUnknown_0203CF48 - movs r3, 0xFF -_081D1C66: - adds r0, r2, r4 - ldrb r1, [r0] - orrs r1, r3 - strb r1, [r0] - adds r0, r2, 0x1 - lsls r0, 24 - lsrs r2, r0, 24 - cmp r2, 0x2 - bls _081D1C66 - movs r0, 0x1 -_081D1C7A: - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end sub_81D1C44 - thumb_func_start sub_81D1C84 -sub_81D1C84: @ 81D1C84 - push {r4-r6,lr} - sub sp, 0x8 - lsls r0, 24 - lsrs r4, r0, 24 - ldr r6, =gUnknown_0203CF48 - adds r5, r4, r6 - ldrb r0, [r5] - cmp r0, 0xFF - bne _081D1CEC - cmp r4, 0x2 - bne _081D1CD4 - ldr r0, =gUnknown_086253E8 - ldr r1, [r0, 0x14] - ldr r0, [r0, 0x10] - str r0, [sp] - str r1, [sp, 0x4] - ldr r0, =gMailboxMailOptions - movs r1, 0x4 - bl GetMaxWidthInMenuTable - lsls r0, 24 - ldr r2, =0x00ffffff - ldr r1, [sp] - ands r1, r2 - orrs r1, r0 - str r1, [sp] - mov r0, sp - bl AddWindow - strb r0, [r6, 0x2] - b _081D1CE0 - .pool -_081D1CD4: - lsls r0, r4, 3 - ldr r1, =gUnknown_086253E8 - adds r0, r1 - bl AddWindow - strb r0, [r5] -_081D1CE0: - ldr r0, =gUnknown_0203CF48 - adds r0, r4, r0 - ldrb r0, [r0] - movs r1, 0 - bl SetStandardWindowBorderStyle -_081D1CEC: - ldr r0, =gUnknown_0203CF48 - adds r0, r4, r0 - ldrb r0, [r0] - add sp, 0x8 - pop {r4-r6} - pop {r1} - bx r1 - .pool - thumb_func_end sub_81D1C84 - - thumb_func_start sub_81D1D04 -sub_81D1D04: @ 81D1D04 - push {r4,lr} - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - ldr r0, =gUnknown_0203CF48 - adds r4, r0 - ldrb r0, [r4] - movs r1, 0 - bl sub_8198070 - ldrb r0, [r4] - bl ClearWindowTilemap - ldrb r0, [r4] - bl RemoveWindow - movs r0, 0xFF - strb r0, [r4] - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81D1D04 - - thumb_func_start sub_81D1D34 -sub_81D1D34: @ 81D1D34 - lsls r0, 24 - lsrs r0, 24 - ldr r1, =gUnknown_0203CF48 - adds r0, r1 - ldrb r0, [r0] - bx lr - .pool - thumb_func_end sub_81D1D34 - - thumb_func_start sub_81D1D44 -sub_81D1D44: @ 81D1D44 - push {r4,r5,lr} - sub sp, 0x34 - adds r3, r1, 0 - lsls r0, 24 - lsrs r4, r0, 24 - lsls r2, 24 - lsrs r5, r2, 24 - movs r0, 0x2 - negs r0, r0 - cmp r3, r0 - beq _081D1DAC - ldr r0, =gSaveBlock1Ptr - lsls r1, r3, 3 - adds r1, r3 - lsls r1, 2 - ldr r0, [r0] - adds r1, r0 - ldr r0, =0x00002cca - adds r1, r0 - add r0, sp, 0x14 - bl StringCopy - add r0, sp, 0x14 - bl sub_81DB52C - add r0, sp, 0x14 - bl StringLength - lsls r0, 16 - lsrs r0, 16 - cmp r0, 0x5 - bhi _081D1D8C - add r0, sp, 0x14 - movs r1, 0x1 - bl ConvertInternationalString -_081D1D8C: - movs r0, 0 - str r0, [sp] - str r0, [sp, 0x4] - ldr r0, =gUnknown_08625400 - str r0, [sp, 0x8] - movs r0, 0x1 - negs r0, r0 - str r0, [sp, 0xC] - add r0, sp, 0x14 - str r0, [sp, 0x10] - adds r0, r4, 0 - movs r1, 0x1 - movs r2, 0x8 - adds r3, r5, 0 - bl AddTextPrinterParameterized4 -_081D1DAC: - add sp, 0x34 - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81D1D44 - - thumb_func_start sub_81D1DC0 -sub_81D1DC0: @ 81D1DC0 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - adds r5, r0, 0 - movs r3, 0 - ldr r7, =gUnknown_0203CF4C - ldr r0, =gText_Cancel2 - mov r12, r0 - ldr r4, =gMultiuseListMenuTemplate - ldr r1, =gUnknown_0203CF48 - mov r8, r1 - ldr r2, =sub_81D1E7C - mov r9, r2 - ldr r0, =sub_81D1D44 - mov r10, r0 - ldrb r1, [r5, 0x5] - cmp r3, r1 - bcs _081D1E02 - adds r6, r7, 0 - ldr r2, =gUnknown_08625403 -_081D1DEC: - ldr r1, [r6] - lsls r0, r3, 3 - adds r0, r1 - str r2, [r0] - str r3, [r0, 0x4] - adds r0, r3, 0x1 - lsls r0, 16 - lsrs r3, r0, 16 - ldrb r0, [r5, 0x5] - cmp r3, r0 - bcc _081D1DEC -_081D1E02: - ldr r2, [r7] - lsls r0, r3, 3 - adds r0, r2 - mov r1, r12 - str r1, [r0] - movs r1, 0x2 - negs r1, r1 - str r1, [r0, 0x4] - str r2, [r4] - ldrb r0, [r5, 0x5] - adds r0, 0x1 - movs r1, 0 - strh r0, [r4, 0xC] - mov r2, r8 - ldrb r0, [r2, 0x1] - strb r0, [r4, 0x10] - strb r1, [r4, 0x11] - movs r0, 0x8 - strb r0, [r4, 0x12] - strb r1, [r4, 0x13] - strh r0, [r4, 0xE] - movs r0, 0x29 - strb r0, [r4, 0x14] - movs r0, 0x31 - strb r0, [r4, 0x15] - mov r0, r9 - str r0, [r4, 0x4] - mov r1, r10 - str r1, [r4, 0x8] - movs r0, 0x1 - strb r0, [r4, 0x17] - movs r0, 0 - strb r0, [r4, 0x16] - ldrh r1, [r5, 0x2] - ldrh r2, [r5] - adds r0, r4, 0 - bl ListMenuInit - lsls r0, 24 - lsrs r0, 24 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r1} - bx r1 - .pool - thumb_func_end sub_81D1DC0 - - thumb_func_start sub_81D1E7C -sub_81D1E7C: @ 81D1E7C - push {lr} - lsls r1, 24 - lsrs r1, 24 - cmp r1, 0x1 - beq _081D1E8C - movs r0, 0x5 - bl PlaySE -_081D1E8C: - pop {r0} - bx r0 - thumb_func_end sub_81D1E7C - - thumb_func_start sub_81D1E90 -sub_81D1E90: @ 81D1E90 - push {r4,lr} - sub sp, 0x10 - adds r4, r0, 0 - ldrb r0, [r4, 0x5] - ldrb r1, [r4, 0x4] - subs r0, r1 - adds r0, 0x1 - str r0, [sp] - movs r0, 0x6E - str r0, [sp, 0x4] - str r0, [sp, 0x8] - adds r0, r4, 0x2 - str r0, [sp, 0xC] - movs r0, 0x2 - movs r1, 0xC8 - movs r2, 0xC - movs r3, 0x94 - bl AddScrollIndicatorArrowPairParameterized - strb r0, [r4, 0x9] - add sp, 0x10 - pop {r4} - pop {r0} - bx r0 - thumb_func_end sub_81D1E90 - - thumb_func_start sub_81D1EC0 -sub_81D1EC0: @ 81D1EC0 - push {lr} - ldr r0, =gUnknown_0203CF4C - ldr r0, [r0] - bl Free - pop {r0} - bx r0 - .pool - thumb_func_end sub_81D1EC0 thumb_func_start sub_81D1ED4 sub_81D1ED4: @ 81D1ED4 push {r4-r7,lr} diff --git a/data/menu_unknown.s b/data/menu_unknown.s index 6d1bd7ecf..1ea0786a4 100644 --- a/data/menu_unknown.s +++ b/data/menu_unknown.s @@ -3,20 +3,6 @@ .section .rodata -gUnknown_086253E8:: @ 86253E8 - .4byte 0x8010100 - .4byte 0x80F02 - .4byte 0x8011500 - .4byte 0x180F12 - .4byte 0xB010100 - .4byte 0x180F08 - -gUnknown_08625400:: @ 8625400 - .byte 1, 2, 3 - -gUnknown_08625403:: @ 8625403 - .byte 0xFF - @ ScanlineEffectParams gUnknown_08625404:: @ 8625404 .4byte 0x04000040 @ REG_ADDR_WIN0H diff --git a/include/menu.h b/include/menu.h index aca462468..af60e5192 100644 --- a/include/menu.h +++ b/include/menu.h @@ -31,7 +31,7 @@ u16 AddTextPrinterParameterized2(u8 windowId, u8 fontId, const u8 *str, u8 speed void PrintPlayerNameOnWindow(u8, const u8*, u16, u16); void DisplayItemMessageOnField(u8 taskId, const u8 *src, TaskFunc callback); void sub_8197434(u8 windowId, bool8 copyToVram); -void SetStandardWindowBorderStyle(u8 a0, u8 a1); +void SetStandardWindowBorderStyle(u8 windowId, bool8 copyToVram); void DisplayYesNoMenu(void); u32 GetPlayerTextSpeed(void); u8 GetPlayerTextSpeedDelay(void); diff --git a/include/menu_unknown.h b/include/menu_unknown.h new file mode 100644 index 000000000..b4c161dad --- /dev/null +++ b/include/menu_unknown.h @@ -0,0 +1,15 @@ +#ifndef GUARD_MENU_UNKNOWN_H +#define GUARD_MENU_UNKNOWN_H + +#include "player_pc.h" + +bool8 sub_81D1C44(u8 a0); +u8 sub_81D1C84(u8 a0); +u8 sub_81D1DC0(struct PlayerPCItemPageStruct *a0); +void sub_81D1E90(struct PlayerPCItemPageStruct *a0); +void sub_81D1EC0(void); +void sub_81D1D04(u8 a0); +void DrawLevelUpWindowPg1(u16 arg0, void* statStoreLocation1, void* statStoreLocation2, u8 arg3, u8 arg4, u8 arg5); +void DrawLevelUpWindowPg2(u16 arg0, void* statStoreLocation1, u8 arg2, u8 arg3, u8 arg4); + +#endif // GUARD_MENU_UNKNOWN_H \ No newline at end of file diff --git a/include/pokenav.h b/include/pokenav.h index 849c9bf16..a1f311944 100644 --- a/include/pokenav.h +++ b/include/pokenav.h @@ -1,6 +1,5 @@ #ifndef GUARD_POKENAV_H #define GUARD_POKENAV_H -#include "player_pc.h" #include "list_menu.h" bool8 sub_81D20BC(void *arg0); @@ -13,12 +12,6 @@ void sub_81D3464(void *arg0); void sub_81D3480(void *arg0, u8 arg1); void sub_81D2754(void *arg0, void *arg1); void sub_81D1F84(void *arg0, void *arg1, void *arg2); -u8 sub_81D1C84(u8); -u8 sub_81D1DC0(struct PlayerPCItemPageStruct *); -void sub_81D1E90(struct PlayerPCItemPageStruct *); -void sub_81D1EC0(void); -void sub_81D1D04(u8); -bool8 sub_81D1C44(u8); bool8 sub_81D4A58(struct EventObject*); void MoveRelearnerPrintText(u8 *); u16 MoveRelearnerRunTextPrinters(void); @@ -28,7 +21,5 @@ void InitMoveRelearnerWindows(bool8 useContextWindow); bool8 EventObjectIsFarawayIslandMew(struct EventObject *); u32 sub_81D427C(void); void sub_81D4998(void); -void DrawLevelUpWindowPg1(u16 arg0, void* statStoreLocation1, void* statStoreLocation2, u8 arg3, u8 arg4, u8 arg5); -void DrawLevelUpWindowPg2(u16 arg0, void* statStoreLocation1, u8 arg2, u8 arg3, u8 arg4); #endif //GUARD_POKENAV_H diff --git a/ld_script.txt b/ld_script.txt index 31e952cf3..4c12291fe 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -291,6 +291,7 @@ SECTIONS { src/pokenav.o(.text); asm/pokenav.o(.text); src/pokenav_match_call.o(.text); + src/menu_unknown.o(.text); asm/menu_unknown.o(.text); asm/rom_81D1C44.o(.text); src/trainer_hill.o(.text); @@ -595,6 +596,7 @@ SECTIONS { src/pokenav.o(.rodata); data/pokenav.o(.rodata); src/pokenav_match_call.o(.rodata); + src/menu_unknown.o(.rodata); data/menu_unknown.o(.rodata); data/rom_81D1C44.o(.rodata); src/trainer_hill.o(.rodata); diff --git a/src/menu_unknown.c b/src/menu_unknown.c new file mode 100644 index 000000000..21f42d264 --- /dev/null +++ b/src/menu_unknown.c @@ -0,0 +1,186 @@ +#include "global.h" +#include "alloc.h" +#include "international_string_util.h" +#include "menu.h" +#include "menu_unknown.h" +#include "player_pc.h" +#include "sound.h" +#include "strings.h" +#include "string_util.h" +#include "window.h" +#include "constants/songs.h" + +#define WINDOW_UNK_0 0 +#define WINDOW_UNK_1 1 +#define WINDOW_UNK_2 2 + +extern struct ListMenuItem *gUnknown_0203CF4C; +extern u8 gUnknown_0203CF48[3]; + +void sub_81D1E7C(s32 itemIndex, bool8 onInit, struct ListMenu *list); + +const struct WindowTemplate gUnknown_086253E8[] = +{ + [WINDOW_UNK_0] = { + //0x08010100, + .bg = 0, + .tilemapLeft = 1, + .tilemapTop = 1, + .width = 8, + //0x00080F02, + .height = 2, + .paletteNum = 0xF, + .baseBlock = 0x8 + }, + [WINDOW_UNK_1] = { + //0x08 01 15 00, + .bg = 0, + .tilemapLeft = 21, + .tilemapTop = 1, + .width = 8, + //0x0018 0F 12, + .height = 18, + .paletteNum = 0xF, + .baseBlock = 0x18 + }, + [WINDOW_UNK_2] = { + //0x0B 01 01 00 + .bg = 0, + .tilemapLeft = 1, + .tilemapTop = 1, + .width = 11, + //0x0018 0F 08 + .height = 8, + .paletteNum = 0xF, + .baseBlock = 0x18 + } +}; + +const u8 gUnknown_08625400[] = { + 1, 2, 3 +}; + +static const u8 sEmptyItemName[] = _(""); + +bool8 sub_81D1C44(u8 count) +{ + u32 i; + struct ListMenuItem **v1; + v1 = &gUnknown_0203CF4C; + *v1 = Alloc(count * sizeof(struct ListMenuItem) + sizeof(struct ListMenuItem)); + + if (gUnknown_0203CF4C == NULL) + return FALSE; + + for (i = 0; i < ARRAY_COUNT(gUnknown_0203CF48); i = (u8)(i + 1)) + { + gUnknown_0203CF48[i] |= 0xFF; + } + + return TRUE; +} + +u8 sub_81D1C84(u8 a0) +{ + struct WindowTemplate template; + + u8 windowId = gUnknown_0203CF48[a0]; + if (windowId == 0xFF) + { + if (a0 == WINDOW_UNK_2) + { + u32 v1; + u32 v2; + s32 v3; + + template = gUnknown_086253E8[WINDOW_UNK_2]; + v3 = GetMaxWidthInMenuTable(&gMailboxMailOptions[0], 4); + template.width = v3; + gUnknown_0203CF48[WINDOW_UNK_2] = AddWindow(&template); + } + else + { + gUnknown_0203CF48[a0] = AddWindow(&gUnknown_086253E8[a0]); + } + SetStandardWindowBorderStyle(gUnknown_0203CF48[a0], 0); + } + return gUnknown_0203CF48[a0]; +} + +void sub_81D1D04(u8 a0) +{ + sub_8198070(gUnknown_0203CF48[a0], 0); + ClearWindowTilemap(gUnknown_0203CF48[a0]); + RemoveWindow(gUnknown_0203CF48[a0]); + gUnknown_0203CF48[a0] = 0xFF; +} + +u8 sub_81D1D34(u8 a0) +{ + return gUnknown_0203CF48[a0]; +} + +void sub_81D1D44(u8 windowId, s32 itemId, u8 y) +{ + u8 buffer[30]; + u16 length; + + if (itemId == LIST_CANCEL) + return; + + StringCopy(buffer, gSaveBlock1Ptr->mail[6 + itemId].playerName); + sub_81DB52C(buffer); + length = StringLength(buffer); + if (length <= 5) + ConvertInternationalString(buffer, LANGUAGE_JAPANESE); + AddTextPrinterParameterized4(windowId, 1, 8, y, 0, 0, gUnknown_08625400, -1, buffer); +} + +u8 sub_81D1DC0(struct PlayerPCItemPageStruct *page) +{ + u16 i; + for (i = 0; i < page->count; i++) + { + gUnknown_0203CF4C[i].name = sEmptyItemName; + gUnknown_0203CF4C[i].id = i; + } + + gUnknown_0203CF4C[i].name = gText_Cancel2; + gUnknown_0203CF4C[i].id = LIST_CANCEL; + + gMultiuseListMenuTemplate.items = gUnknown_0203CF4C; + gMultiuseListMenuTemplate.totalItems = page->count + 1; + gMultiuseListMenuTemplate.windowId = gUnknown_0203CF48[1]; + gMultiuseListMenuTemplate.header_X = 0; + gMultiuseListMenuTemplate.item_X = 8; + gMultiuseListMenuTemplate.cursor_X = 0; + gMultiuseListMenuTemplate.maxShowed = 8; + gMultiuseListMenuTemplate.upText_Y = 9; + gMultiuseListMenuTemplate.cursorPal = 2; + gMultiuseListMenuTemplate.fillValue = 1; + gMultiuseListMenuTemplate.cursorShadowPal = 3; + gMultiuseListMenuTemplate.moveCursorFunc = sub_81D1E7C; + gMultiuseListMenuTemplate.itemPrintFunc = sub_81D1D44; + gMultiuseListMenuTemplate.fontId = 1; + gMultiuseListMenuTemplate.cursorKind = 0; + gMultiuseListMenuTemplate.lettersSpacing = 0; + gMultiuseListMenuTemplate.itemVerticalPadding = 0; + gMultiuseListMenuTemplate.scrollMultiple = LIST_NO_MULTIPLE_SCROLL; + return ListMenuInit(&gMultiuseListMenuTemplate, page->itemsAbove, page->cursorPos); +} + +void sub_81D1E7C(s32 itemIndex, bool8 onInit, struct ListMenu *list) +{ + if (onInit != TRUE) + PlaySE(SE_SELECT); +} + +void sub_81D1E90(struct PlayerPCItemPageStruct *page) +{ + page->scrollIndicatorId = AddScrollIndicatorArrowPairParameterized(2, 0xC8, 12, 0x94, page->count - page->pageItems + 1, 0x6E, 0x6E, &page->itemsAbove); +} + +void sub_81D1EC0(void) +{ + Free(gUnknown_0203CF4C); +} \ No newline at end of file diff --git a/src/party_menu.c b/src/party_menu.c index 7e47e9ced..7e47cbf80 100755 --- a/src/party_menu.c +++ b/src/party_menu.c @@ -37,15 +37,16 @@ #include "main.h" #include "menu.h" #include "menu_helpers.h" +#include "menu_unknown.h" #include "metatile_behavior.h" #include "overworld.h" #include "palette.h" #include "party_menu.h" +#include "player_pc.h" #include "pokemon.h" #include "pokemon_icon.h" #include "pokemon_storage_system.h" #include "pokemon_summary_screen.h" -#include "pokenav.h" #include "region_map.h" #include "reshow_battle_screen.h" #include "rom_8011DC0.h" diff --git a/src/player_pc.c b/src/player_pc.c index bec763b41..f167062cb 100644 --- a/src/player_pc.c +++ b/src/player_pc.c @@ -20,7 +20,6 @@ #include "overworld.h" #include "palette.h" #include "party_menu.h" -#include "pokenav.h" #include "player_pc.h" #include "script.h" #include "sound.h" @@ -29,6 +28,7 @@ #include "strings.h" #include "task.h" #include "window.h" +#include "menu_unknown.h" // structures struct Struct203BCC4