From c9f16cb1a89378dce1968d30c966387b1f1210c3 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sun, 31 Mar 2019 11:16:19 -0400 Subject: [PATCH] WIP sub_8018DAC --- asm/mystery_gift.s | 154 --------------------------------------- include/list_menu.h | 2 +- include/mevent_801BAAC.h | 9 +++ include/strings.h | 2 + src/list_menu.c | 2 +- src/mystery_gift.c | 120 ++++++++++++++++++++++++++++++ 6 files changed, 133 insertions(+), 156 deletions(-) create mode 100644 include/mevent_801BAAC.h diff --git a/asm/mystery_gift.s b/asm/mystery_gift.s index 6fec153ca..6fc9c31d5 100755 --- a/asm/mystery_gift.s +++ b/asm/mystery_gift.s @@ -5,160 +5,6 @@ .text - thumb_func_start sub_8018C4C -sub_8018C4C: @ 8018C4C - push {r4-r6,lr} - sub sp, 0x14 - adds r6, r0, 0 - adds r5, r1, 0 - ldrb r0, [r6] - cmp r0, 0x1 - beq _08018CE8 - cmp r0, 0x1 - bgt _08018C64 - cmp r0, 0 - beq _08018C6C - b _08018D8C -_08018C64: - cmp r0, 0xFF - bne _08018C6A - b _08018D68 -_08018C6A: - b _08018D8C -_08018C6C: - cmp r2, 0 - bne _08018C84 - ldr r0, =gStringVar4 - ldr r1, =gText_WhatToDoWithCards - bl StringExpandPlaceholders - b _08018C8C - .pool -_08018C84: - ldr r0, =gStringVar4 - ldr r1, =gText_WhatToDoWithNews - bl StringExpandPlaceholders -_08018C8C: - ldr r0, =gUnknown_082F05D8 - bl AddWindow - strh r0, [r5] - lsls r0, 24 - lsrs r0, 24 - movs r1, 0x11 - bl FillWindowPixelBuffer - ldrb r0, [r5] - movs r2, 0 - str r2, [sp] - str r2, [sp, 0x4] - ldr r1, =gUnknown_082F0728 - str r1, [sp, 0x8] - str r2, [sp, 0xC] - ldr r1, =gStringVar4 - str r1, [sp, 0x10] - movs r1, 0x1 - movs r3, 0x1 - bl AddTextPrinterParameterized4 - ldrb r0, [r5] - movs r1, 0x1 - movs r2, 0xF - bl sub_8098858 - ldrb r0, [r5] - movs r1, 0x2 - bl CopyWindowToVram - ldrb r0, [r5] - bl PutWindowTilemap - ldrb r0, [r6] - adds r0, 0x1 - strb r0, [r6] - b _08018D8C - .pool -_08018CE8: - cmp r3, 0 - beq _08018D10 - cmp r2, 0 - bne _08018D00 - ldr r0, =gUnknown_082F05F8 - ldr r1, =gUnknown_082F06C8 - b _08018D28 - .pool -_08018D00: - ldr r0, =gUnknown_082F0600 - ldr r1, =gUnknown_082F06F8 - b _08018D28 - .pool -_08018D10: - cmp r2, 0 - bne _08018D24 - ldr r0, =gUnknown_082F05F0 - ldr r1, =gUnknown_082F06B0 - b _08018D28 - .pool -_08018D24: - ldr r0, =gUnknown_082F05F8 - ldr r1, =gUnknown_082F06E0 -_08018D28: - movs r2, 0xE0 - str r2, [sp] - movs r2, 0x1 - movs r3, 0xA - bl DoMysteryGiftListMenu - adds r4, r0, 0 - movs r0, 0x1 - negs r0, r0 - cmp r4, r0 - beq _08018D8C - movs r0, 0 - strb r0, [r6] - ldrb r0, [r5] - bl rbox_fill_rectangle - ldrb r0, [r5] - bl ClearWindowTilemap - ldrb r0, [r5] - movs r1, 0x1 - bl CopyWindowToVram - ldrb r0, [r5] - bl RemoveWindow - adds r0, r4, 0 - b _08018D90 - .pool -_08018D68: - movs r0, 0 - strb r0, [r6] - ldrb r0, [r5] - bl rbox_fill_rectangle - ldrb r0, [r5] - bl ClearWindowTilemap - ldrb r0, [r5] - movs r1, 0x1 - bl CopyWindowToVram - ldrb r0, [r5] - bl RemoveWindow - movs r0, 0x2 - negs r0, r0 - b _08018D90 -_08018D8C: - movs r0, 0x1 - negs r0, r0 -_08018D90: - add sp, 0x14 - pop {r4-r6} - pop {r1} - bx r1 - thumb_func_end sub_8018C4C - - thumb_func_start sub_8018D98 -sub_8018D98: @ 8018D98 - push {lr} - cmp r0, 0 - beq _08018DA4 - bl sub_801B0CC - b _08018DA8 -_08018DA4: - bl sub_801B27C -_08018DA8: - pop {r1} - bx r1 - thumb_func_end sub_8018D98 - thumb_func_start sub_8018DAC sub_8018DAC: @ 8018DAC push {r4,r5,lr} diff --git a/include/list_menu.h b/include/list_menu.h index a301e5b32..0a54a069a 100644 --- a/include/list_menu.h +++ b/include/list_menu.h @@ -98,7 +98,7 @@ struct CursorStruct extern struct ScrollArrowsTemplate gTempScrollArrowTemplate; extern struct ListMenuTemplate gMultiuseListMenuTemplate; -s32 DoMysteryGiftListMenu(struct WindowTemplate *windowTemplate, struct ListMenuTemplate *listMenuTemplate, u8 arg2, u16 tileNum, u16 palNum); +s32 DoMysteryGiftListMenu(const struct WindowTemplate *windowTemplate, const struct ListMenuTemplate *listMenuTemplate, u8 arg2, u16 tileNum, u16 palNum); u8 ListMenuInit(struct ListMenuTemplate *listMenuTemplate, u16 scrollOffset, u16 selectedRow); u8 ListMenuInitInRect(struct ListMenuTemplate *listMenuTemplate, struct ListMenuWindowRect *arg1, u16 scrollOffset, u16 selectedRow); s32 ListMenu_ProcessInput(u8 listTaskId); diff --git a/include/mevent_801BAAC.h b/include/mevent_801BAAC.h new file mode 100644 index 000000000..db1bb0571 --- /dev/null +++ b/include/mevent_801BAAC.h @@ -0,0 +1,9 @@ +#ifndef GUARD_MEVENT_801BAAC_H +#define GUARD_MEVENT_801BAAC_H + +bool32 sub_801BAAC(struct MEventBuffer_32E0_Sub * r5, struct MEventBuffer_3430_Sub * r6); +bool32 sub_801C6C8(const struct MEventBuffer_3120_Sub * a0); +s32 sub_801BB74(void); +s32 sub_801C758(void); + +#endif //GUARD_MEVENT_801BAAC_H diff --git a/include/strings.h b/include/strings.h index 2f9a64af1..2ef8411c7 100644 --- a/include/strings.h +++ b/include/strings.h @@ -2626,5 +2626,7 @@ extern const u8 gText_VarietyOfEventsImportedWireless[]; extern const u8 gText_WonderCardsInPossession[]; extern const u8 gText_ReadNewsThatArrived[]; extern const u8 gText_ReturnToTitle[]; +extern const u8 gText_WhatToDoWithCards[]; +extern const u8 gText_WhatToDoWithNews[]; #endif // GUARD_STRINGS_H diff --git a/src/list_menu.c b/src/list_menu.c index 57bcc5c4f..3bcd3073d 100644 --- a/src/list_menu.c +++ b/src/list_menu.c @@ -312,7 +312,7 @@ static void ListMenuDummyTask(u8 taskId) } -s32 DoMysteryGiftListMenu(struct WindowTemplate *windowTemplate, struct ListMenuTemplate *listMenuTemplate, u8 arg2, u16 tileNum, u16 palNum) +s32 DoMysteryGiftListMenu(const struct WindowTemplate *windowTemplate, const struct ListMenuTemplate *listMenuTemplate, u8 arg2, u16 tileNum, u16 palNum) { switch (sMysteryGiftLinkMenu.state) { diff --git a/src/mystery_gift.c b/src/mystery_gift.c index da2a3bcc0..9561fbbeb 100644 --- a/src/mystery_gift.c +++ b/src/mystery_gift.c @@ -21,6 +21,8 @@ #include "international_string_util.h" #include "list_menu.h" #include "string_util.h" +#include "mevent.h" +#include "mevent_801BAAC.h" void bgid_upload_textbox_1(u8 bgId); void task_add_00_mystery_gift(void); @@ -696,3 +698,121 @@ s32 sub_8018B08(u8 * textState, u16 * windowId, bool8 r6, const u8 * str) return -2; } + +s32 sub_8018C4C(u8 * textState, u16 * windowId, bool32 r2, bool32 r3) +{ + struct WindowTemplate windowTemplate; + s32 input; + + switch (*textState) + { + case 0: + if (r2 == 0) + { + StringExpandPlaceholders(gStringVar4, gText_WhatToDoWithCards); + } + else + { + StringExpandPlaceholders(gStringVar4, gText_WhatToDoWithNews); + } + *windowId = AddWindow(&gUnknown_082F05D8); + FillWindowPixelBuffer(*windowId, 0x11); + AddTextPrinterParameterized4(*windowId, 1, 0, 1, 0, 0, gUnknown_082F0728, 0, gStringVar4); + sub_8098858(*windowId, 0x001, 0x0F); + CopyWindowToVram(*windowId, 2); + PutWindowTilemap(*windowId); + (*textState)++; + break; + case 1: + windowTemplate = gUnknown_082F05E8; + if (r3) + { + if (r2 == 0) + { + input = DoMysteryGiftListMenu(&gUnknown_082F05F8, &gUnknown_082F06C8, 1, 0x00A, 0xE0); + } + else + { + input = DoMysteryGiftListMenu(&gUnknown_082F0600, &gUnknown_082F06F8, 1, 0x00A, 0xE0); + } + } + else + { + if (r2 == 0) + { + input = DoMysteryGiftListMenu(&gUnknown_082F05F0, &gUnknown_082F06B0, 1, 0x00A, 0xE0); + } + else + { + input = DoMysteryGiftListMenu(&gUnknown_082F05F8, &gUnknown_082F06E0, 1, 0x00A, 0xE0); + } + } + if (input != -1) + { + *textState = 0; + rbox_fill_rectangle(*windowId); + ClearWindowTilemap(*windowId); + CopyWindowToVram(*windowId, 1); + RemoveWindow(*windowId); + return input; + } + break; + case 0xFF: + *textState = 0; + rbox_fill_rectangle(*windowId); + ClearWindowTilemap(*windowId); + CopyWindowToVram(*windowId, 1); + RemoveWindow(*windowId); + return -2; + } + + return -1; +} + +s32 sub_8018D98(bool32 a0) +{ + if (a0 == 0) + { + return sub_801B27C(); + } + else + { + return sub_801B0CC(); + } +} + +/*bool32 sub_8018DAC(u8 * state, bool32 arg1) +{ + switch (*state) + { + case 0: + if (arg1 == 0) + { + sub_801BAAC(sav1_get_mevent_buffer_1(), sav1_get_mevent_buffer_2()); + } + else + { + sub_801C6C8(sub_801B00C()); + } + (*state)++; + case 1: + if (arg1 == 0) + { + if (sub_801BB74() == 0) + { + break; + } + } + else + { + if (sub_801C758() == 0) + { + break; + } + } + *state = 0; + return TRUE; + } + + return FALSE; +}*/