diff options
Diffstat (limited to 'arm9/src')
-rw-r--r-- | arm9/src/error_message_reset.c | 21 | ||||
-rw-r--r-- | arm9/src/game_init.c | 50 | ||||
-rw-r--r-- | arm9/src/heap.c | 2 | ||||
-rw-r--r-- | arm9/src/itemtool.c | 2 | ||||
-rw-r--r-- | arm9/src/list_menu.c | 572 | ||||
-rw-r--r-- | arm9/src/main.c | 71 | ||||
-rw-r--r-- | arm9/src/scrcmd.c | 42 | ||||
-rw-r--r-- | arm9/src/script_buffers.c | 20 | ||||
-rw-r--r-- | arm9/src/text.c | 48 | ||||
-rw-r--r-- | arm9/src/text_02054590.c | 34 | ||||
-rw-r--r-- | arm9/src/unk_0200CA44.c | 10 | ||||
-rw-r--r-- | arm9/src/unk_0202E29C.c | 334 | ||||
-rw-r--r-- | arm9/src/unk_0206015C.c | 2 |
13 files changed, 879 insertions, 329 deletions
diff --git a/arm9/src/error_message_reset.c b/arm9/src/error_message_reset.c index f70fec0f..426ba876 100644 --- a/arm9/src/error_message_reset.c +++ b/arm9/src/error_message_reset.c @@ -20,18 +20,17 @@ u32 sErrorMessagePrinterLock; extern void FUN_0200E3A0(PMLCDTarget, int); extern u32 *FUN_02016B94(u32 param0); extern void FUN_02016BBC(const struct GraphicsModes *modes); -extern void FUN_02016C18(u32 *param0, u32 param1, void *param2, u32 param3); +extern void FUN_02016C18(u32 *param0, struct Window * param1, const u32 *param2, u32 param3); extern void FUN_02018744(u32 *param0, u32 param1); extern void FUN_0200CB00(u32 *param0, u32 param1, u32 param2, u32 param3, u8 param4, u32 param5); extern void FUN_02002ED0(u32 param0, u32 param1, u32 param2); extern void FUN_02017F18(u32 param0, u32 param1, u32 param2, u32 param3); extern void FUN_02017FE4(u32 param0, u32 param1); -extern void FUN_02019150(u32 *param0, u32 *param1, const u32 *param2); -extern void FUN_020196F4(u32 *, u8, u16, u16, u16, u16); -extern void FUN_0200CCA4(u32 *param0, u32 param1, u32 param2, u32 param3); +extern void FUN_02019150(u32 *param0, struct Window *param1, const u32 *param2); +extern void FUN_0200CCA4(struct Window *param0, u32 param1, u32 param2, u32 param3); extern void FUN_0200E394(u32 param0); extern void FUN_0200A274(u32 param0, u32 param1, u32 param2); -extern void FUN_02019178(u32 *param0); +extern void FUN_02019178(struct Window *param0); THUMB_FUNC void VBlankHandler() { @@ -44,7 +43,7 @@ THUMB_FUNC void PrintErrorMessageAndReset() { u32 *ptr; - u32 buf[4]; + struct Window buf; if (sErrorMessagePrinterLock != 1) { @@ -97,13 +96,13 @@ THUMB_FUNC void PrintErrorMessageAndReset() struct String *str = String_ctor(6 << 6, 0); FUN_0201BD5C(); - FUN_02019150(ptr, buf, UNK_020FF49C); - FUN_020196F4(buf, 15, 0, 0, 0xd0, 0x90); - FUN_0200CCA4(buf, 0, 0x1f7, 2); + FUN_02019150(ptr, &buf, UNK_020FF49C); + FillWindowPixelRect(&buf, 15, 0, 0, 0xd0, 0x90); + FUN_0200CCA4(&buf, 0, 0x1f7, 2); ReadMsgDataIntoString(msg_data, 3, str); - AddTextPrinterParameterized((u32)buf, 0, (const u16 *)str, 0, 0, 0, NULL); // wtf + AddTextPrinterParameterized(&buf, 0, (const u16 *)str, 0, 0, 0, NULL); // wtf String_dtor(str); GX_BothDispOn(); @@ -133,7 +132,7 @@ THUMB_FUNC void PrintErrorMessageAndReset() FUN_0200E3A0(PM_LCD_TOP, 0x7FFF); FUN_0200E3A0(PM_LCD_BOTTOM, 0x7FFF); - FUN_02019178(buf); + FUN_02019178(&buf); DestroyMsgData(msg_data); FreeToHeap(ptr); diff --git a/arm9/src/game_init.c b/arm9/src/game_init.c index a7508fab..f52a6659 100644 --- a/arm9/src/game_init.c +++ b/arm9/src/game_init.c @@ -203,7 +203,7 @@ void * FUN_020161A4(u32 heap_id, const char * path) { if (size != FS_ReadFile(&file, ret, (s32)size)) { - FUN_02016A8C(heap_id, ret); + FreeToHeapExplicit(heap_id, ret); ret = NULL; } } @@ -344,8 +344,8 @@ void FUN_020163BC(void) gMain.unk3C = 0; gMain.unk40 = 0; gMain.unk44 = 0; - gMain.unk48 = 0; - gMain.unk4C = 0; + gMain.newKeys = 0; + gMain.newAndRepeatedKeys = 0; gMain.unk50 = 0; gMain.unk54 = 8; gMain.unk58 = 15; @@ -387,9 +387,9 @@ void FUN_02016464(void) TPData raw, calib; if (PAD_DetectFold()) { - gMain.unk48 = 0; + gMain.newKeys = 0; gMain.unk44 = 0; - gMain.unk4C = 0; + gMain.newAndRepeatedKeys = 0; gMain.unk60 = 0; gMain.unk62 = 0; return; @@ -409,9 +409,9 @@ void FUN_02016464(void) gMain.unk50 = gMain.unk58; } gMain.unk38 = r0; - gMain.unk48 = gMain.unk3C; + gMain.newKeys = gMain.unk3C; gMain.unk44 = r0; - gMain.unk4C = gMain.unk40; + gMain.newAndRepeatedKeys = gMain.unk40; FUN_02016568(); if (gMain.unk64 == 0) { @@ -453,26 +453,26 @@ void FUN_02016568(void) case 0: // Normal break; case 1: // Start = X - if (gMain.unk48 & PAD_BUTTON_START) - gMain.unk48 |= PAD_BUTTON_X; + if (gMain.newKeys & PAD_BUTTON_START) + gMain.newKeys |= PAD_BUTTON_X; if (gMain.unk44 & PAD_BUTTON_START) gMain.unk44 |= PAD_BUTTON_X; - if (gMain.unk4C & PAD_BUTTON_START) - gMain.unk4C |= PAD_BUTTON_X; + if (gMain.newAndRepeatedKeys & PAD_BUTTON_START) + gMain.newAndRepeatedKeys |= PAD_BUTTON_X; break; case 2: // Swap X and Y; unused in the retail game { u32 r1 = 0; - if (gMain.unk48 & PAD_BUTTON_X) + if (gMain.newKeys & PAD_BUTTON_X) { r1 |= PAD_BUTTON_Y; } - if (gMain.unk48 & PAD_BUTTON_Y) + if (gMain.newKeys & PAD_BUTTON_Y) { r1 |= PAD_BUTTON_X; } - gMain.unk48 &= 0xF3FF; - gMain.unk48 |= r1; + gMain.newKeys &= 0xF3FF; + gMain.newKeys |= r1; } { u32 r1 = 0; @@ -489,28 +489,28 @@ void FUN_02016568(void) } { u32 r1 = 0; - if (gMain.unk4C & PAD_BUTTON_X) + if (gMain.newAndRepeatedKeys & PAD_BUTTON_X) { r1 |= PAD_BUTTON_Y; } - if (gMain.unk4C & PAD_BUTTON_Y) + if (gMain.newAndRepeatedKeys & PAD_BUTTON_Y) { r1 |= PAD_BUTTON_X; } - gMain.unk4C &= 0xF3FF; - gMain.unk4C |= r1; + gMain.newAndRepeatedKeys &= 0xF3FF; + gMain.newAndRepeatedKeys |= r1; } break; case 3: // L = A - if (gMain.unk48 & PAD_BUTTON_L) - gMain.unk48 |= PAD_BUTTON_A; + if (gMain.newKeys & PAD_BUTTON_L) + gMain.newKeys |= PAD_BUTTON_A; if (gMain.unk44 & PAD_BUTTON_L) gMain.unk44 |= PAD_BUTTON_A; - if (gMain.unk4C & PAD_BUTTON_L) - gMain.unk4C |= PAD_BUTTON_A; - gMain.unk48 &= 0xFCFF; + if (gMain.newAndRepeatedKeys & PAD_BUTTON_L) + gMain.newAndRepeatedKeys |= PAD_BUTTON_A; + gMain.newKeys &= 0xFCFF; gMain.unk44 &= 0xFCFF; - gMain.unk4C &= 0xFCFF; + gMain.newAndRepeatedKeys &= 0xFCFF; } } diff --git a/arm9/src/heap.c b/arm9/src/heap.c index 895ce808..f28b4f88 100644 --- a/arm9/src/heap.c +++ b/arm9/src/heap.c @@ -309,7 +309,7 @@ void FreeToHeap(void *ptr) ErrorHandling(); } -void FUN_02016A8C(u32 param0, void *param1) +void FreeToHeapExplicit(u32 param0, void *param1) { GF_ASSERT (OS_GetProcMode() != OS_PROCMODE_IRQ); diff --git a/arm9/src/itemtool.c b/arm9/src/itemtool.c index 6b892d6d..9982ff40 100644 --- a/arm9/src/itemtool.c +++ b/arm9/src/itemtool.c @@ -778,7 +778,7 @@ u32 GetItemAttr(u16 item, u32 attr, u32 heap_id) u32 ret; struct ItemData * itemData = (struct ItemData *)LoadItemDataOrGfx(item, 0, heap_id); ret = GetItemAttr_PreloadedItemData(itemData, attr); - FUN_02016A8C(heap_id, itemData); + FreeToHeapExplicit(heap_id, itemData); return ret; } diff --git a/arm9/src/list_menu.c b/arm9/src/list_menu.c new file mode 100644 index 00000000..5ae5a5b4 --- /dev/null +++ b/arm9/src/list_menu.c @@ -0,0 +1,572 @@ +#include "global.h" +#include "heap.h" +#include "main.h" +#include "list_menu.h" +#include "text.h" + +void ListMenuPrintEntries(struct ListMenu * list, u16 startIndex, u16 yOffset, u16 count); +void ListMenuDrawCursor(struct ListMenu * list); +BOOL ListMenuChangeSelection(struct ListMenu * list, u8 updateCursorAndCallCallback, u8 count, u8 movingDown); +void ListMenuCallSelectionChangedCallback(struct ListMenu * list, u8 onInit); + +static inline u32 MakeFontColor(u32 fgPal, u32 shdwPal, u32 bgPal) +{ + return (u32)( + ((u32)(fgPal << 24) >> 8) + | ((u32)(shdwPal << 24) >> 16) + | ((u32)(bgPal << 24) >> 24) + ); +} + +THUMB_FUNC struct ListMenu * ListMenuInit(const struct ListMenuTemplate * template, u16 cursorPos, u16 itemsAbove, u32 heap_id) +{ + struct ListMenu * list = AllocFromHeap(heap_id, sizeof(struct ListMenu)); + list->template = *template; + list->cursor = ListMenuCursorNew(heap_id); + list->cursorPos = cursorPos; + list->itemsAbove = itemsAbove; + list->unk_30 = 0; + list->unk_31 = 0; + list->taskId = 0xFF; + list->unk_33 = 0; + list->heap_id = (u8)heap_id; + list->cursorPal = list->template.cursorPal; + list->fillValue = list->template.fillValue; + list->cursorShadowPal = list->template.cursorShadowPal; + list->lettersSpacing = list->template.lettersSpacing; + list->fontId = list->template.fontId; + list->overrideEnabled = FALSE; + if (list->template.totalItems < list->template.maxShowed) + list->template.maxShowed = list->template.totalItems; + ListMenuCursorSetColor( + list->cursor, +// MakeFontColor(list->template.cursorPal, list->template.cursorShadowPal, list->fillValue) + (u32)( + ((u32)(list->template.cursorPal << 24) >> 8) + | ((u32)(list->template.cursorShadowPal << 24) >> 16) + | ((u32)(list->template.fillValue << 24) >> 24) + ) + ); + FillWindowPixelBuffer(list->template.window, list->template.fillValue); + ListMenuPrintEntries(list, list->cursorPos, 0, list->template.maxShowed); + ListMenuDrawCursor(list); + ListMenuCallSelectionChangedCallback(list, TRUE); + CopyWindowToVram(template->window); + return list; +} + +THUMB_FUNC s32 ListMenu_ProcessInput(struct ListMenu * list) +{ + list->unk_33 = 0; + + if (gMain.newKeys & REG_PAD_KEYINPUT_A_MASK) { + return list->template.items[list->cursorPos + list->itemsAbove].index; + } + else if (gMain.newKeys & REG_PAD_KEYINPUT_B_MASK) { + return LIST_CANCEL; + } + else if (gMain.newAndRepeatedKeys & REG_PAD_KEYINPUT_UP_MASK) { + if (!ListMenuChangeSelection(list, TRUE, 1, FALSE)) + list->unk_33 = 1; + return LIST_NOTHING_CHOSEN; + } + else if (gMain.newAndRepeatedKeys & REG_PAD_KEYINPUT_DOWN_MASK) { + if (!ListMenuChangeSelection(list, TRUE, 1, TRUE)) + list->unk_33 = 2; + return LIST_NOTHING_CHOSEN; + } + else + { + u16 rightButton, leftButton; + switch (list->template.scrollMultiple) + { + case LIST_NO_MULTIPLE_SCROLL: + default: + leftButton = FALSE; + rightButton = FALSE; + break; + case LIST_MULTIPLE_SCROLL_DPAD: + leftButton = gMain.newAndRepeatedKeys & REG_PAD_KEYINPUT_LEFT_MASK; + rightButton = gMain.newAndRepeatedKeys & REG_PAD_KEYINPUT_RIGHT_MASK; + break; + case LIST_MULTIPLE_SCROLL_L_R: + leftButton = gMain.newAndRepeatedKeys & REG_PAD_KEYINPUT_L_MASK; + rightButton = gMain.newAndRepeatedKeys & REG_PAD_KEYINPUT_R_MASK; + break; + } + if (leftButton) + { + if (!ListMenuChangeSelection(list, TRUE, list->template.maxShowed, FALSE)) + list->unk_33 = 3; + return LIST_NOTHING_CHOSEN; + } + else if (rightButton) + { + if (!ListMenuChangeSelection(list, TRUE, list->template.maxShowed, TRUE)) + list->unk_33 = 4; + return LIST_NOTHING_CHOSEN; + } + else + { + return LIST_NOTHING_CHOSEN; + } + } +} + +THUMB_FUNC void DestroyListMenu(struct ListMenu * list, u16 * cursorPos, u16 * itemsAbove) +{ + if (cursorPos != NULL) + *cursorPos = list->cursorPos; + if (itemsAbove != NULL) + *itemsAbove = list->itemsAbove; + DestroyListMenuCursorObj(list->cursor); + FreeToHeapExplicit(list->heap_id, list); +} + +THUMB_FUNC void RedrawListMenu(struct ListMenu * list) +{ + FillWindowPixelBuffer(list->template.window, list->template.fillValue); + ListMenuPrintEntries(list, list->cursorPos, 0, list->template.maxShowed); + ListMenuDrawCursor(list); + CopyWindowToVram(list->template.window); +} + +THUMB_FUNC s32 ListMenuTestInputInternal(struct ListMenu * list, const struct ListMenuTemplate * template, u16 cursorPos, u16 itemsAbove, u16 updateFlag, u16 input, u16 *newCursorPos, u16 *newItemsAbove) +{ + if (template != NULL) + list->template = *template; + list->cursorPos = cursorPos; + list->itemsAbove = itemsAbove; + list->unk_30 = 0; + list->unk_31 = 0; + + if (input == REG_PAD_KEYINPUT_UP_MASK) + { + ListMenuChangeSelection(list, updateFlag, 1, FALSE); + } + else if (input == REG_PAD_KEYINPUT_DOWN_MASK) + { + ListMenuChangeSelection(list, updateFlag, 1, TRUE); + } + if (newCursorPos != NULL) + { + *newCursorPos = list->cursorPos; + } + if (newItemsAbove != NULL) + { + *newItemsAbove = list->itemsAbove; + } + return -1; +} + +THUMB_FUNC s32 ListMenuTestInput(struct ListMenu * list, const struct ListMenuTemplate * template, u16 cursorPos, u16 itemsAbove, u16 input, u16 *newCursorPos, u16 *newItemsAbove) +{ + return ListMenuTestInputInternal(list, template, cursorPos, itemsAbove, FALSE, input, newCursorPos, newItemsAbove); +} + +THUMB_FUNC void ListMenuOverrideSetColors(struct ListMenu * list, u8 cursorPal, u8 fillValue, u8 cursorShadowPal) +{ + list->cursorPal = cursorPal; + list->fillValue = fillValue; + list->cursorShadowPal = cursorShadowPal; + list->overrideEnabled = TRUE; +} + +THUMB_FUNC void ListMenuGetCurrentItemArrayId(struct ListMenu * list, u16 * index_p) +{ + *index_p = list->cursorPos + list->itemsAbove; +} + +THUMB_FUNC void ListMenuGetScrollAndRow(struct ListMenu * list, u16 * cursorPos_p, u16 * itemsAbove_p) +{ + if (cursorPos_p != NULL) + *cursorPos_p = list->cursorPos; + if (itemsAbove_p != NULL) + *itemsAbove_p = list->itemsAbove; +} + +THUMB_FUNC u8 ListMenuGetUnk33(struct ListMenu * list) +{ + return list->unk_33; +} + +THUMB_FUNC s32 ListMenuGetValueByArrayId(struct ListMenu * list, s32 index) +{ + return list->template.items[index].index; +} + +THUMB_FUNC s32 ListMenuGetTemplateField(struct ListMenu * list, u32 attr) +{ + switch (attr) + { + case 0: + return (s32)list->template.moveCursorFunc; + case 1: + return (s32)list->template.itemPrintFunc; + case 2: + return (s32)list->template.totalItems; + case 3: + return (s32)list->template.maxShowed; + case 4: + break; + case 5: + return (s32)list->template.header_X; + case 6: + return (s32)list->template.item_X; + case 7: + return (s32)list->template.cursor_X; + case 8: + return (s32)list->template.upText_Y; + case 9: + return GetFontAttribute(list->template.fontId, 1) + list->template.itemVerticalPadding; + case 10: + return (s32)list->template.cursorPal; + case 11: + return (s32)list->template.fillValue; + case 12: + return (s32)list->template.cursorShadowPal; + case 13: + return (s32)list->template.lettersSpacing; + case 14: + return (s32)list->template.itemVerticalPadding; + case 15: + return (s32)list->template.scrollMultiple; + case 16: + return (s32)list->template.fontId; + case 17: + return (s32)list->template.cursorKind; + case 18: + return (s32)list->template.window; + case 19: + return (s32)list->template.unk_1C; + } + + return -1; +} + +THUMB_FUNC void ListMenuSetTemplateField(struct ListMenu * list, u32 attr, s32 value) +{ + switch (attr) + { + case 0: + list->template.moveCursorFunc = (LM_MoveCursorFunc_t)value; + break; + case 1: + list->template.itemPrintFunc = (LM_ItemPrintFunc_t)value; + break; + case 2: + list->template.totalItems = (u16)value; + break; + case 3: + list->template.maxShowed = (u16)value; + break; + case 4: + break; + case 5: + list->template.header_X = (u8)value; + break; + case 6: + list->template.item_X = (u8)value; + break; + case 7: + list->template.cursor_X = (u8)value; + break; + case 8: + list->template.upText_Y = (u8)value; + break; + case 9: + break; + case 10: + list->template.cursorPal = (u8)value; + break; + case 11: + list->template.fillValue = (u8)value; + break; + case 12: + list->template.cursorShadowPal = (u8)value; + break; + case 13: + list->template.lettersSpacing = (u8)value; + break; + case 14: + list->template.itemVerticalPadding = (u8)value; + break; + case 15: + list->template.scrollMultiple = (u8)value; + break; + case 16: + list->template.fontId = (u8)value; + break; + case 17: + list->template.cursorKind = (u8)value; + break; + case 18: + list->template.window = (struct Window *)value; + break; + case 19: + list->template.unk_1C = (u32)value; + break; + } +} + +THUMB_FUNC void ListMenuGetItemStr(struct ListMenu * list, struct ListMenuItem * items) +{ + list->template.items = items; +} + +THUMB_FUNC void ListMenuPrint(struct ListMenu * list, const u16 * str, u8 x, u8 y) +{ + if (str != NULL) + { + if (list->overrideEnabled) + { + AddTextPrinterParameterized3(list->template.window, list->fontId, str, x, y, 0xFF, MakeFontColor(list->cursorPal, list->cursorShadowPal, list->fillValue), list->lettersSpacing, 0, NULL); + } + else + { + AddTextPrinterParameterized3(list->template.window, list->template.fontId, str, x, y, 0xFF, MakeFontColor(list->template.cursorPal, list->template.cursorShadowPal, list->template.fillValue), list->template.lettersSpacing, 0, NULL); + } + } +} + +THUMB_FUNC void ListMenuPrintEntries(struct ListMenu * list, u16 startIndex, u16 yOffset, u16 count) +{ + s32 i; + u8 x, y; + u8 yMultiplier = GetFontAttribute(list->template.fontId, 1) + list->template.itemVerticalPadding; + + for (i = 0; i < count; i++) + { + if (list->template.items[startIndex].index != LIST_HEADER) + x = list->template.item_X; + else + x = list->template.header_X; + y = (yOffset + i) * yMultiplier + list->template.upText_Y; + if (list->template.itemPrintFunc != NULL) + list->template.itemPrintFunc(list, list->template.items[startIndex].index, y); + ListMenuPrint(list, list->template.items[startIndex].text, x, y); + startIndex++; + } +} + +THUMB_FUNC void ListMenuDrawCursor(struct ListMenu * list) +{ + u8 yMultiplier = GetFontAttribute(list->template.fontId, 1) + list->template.itemVerticalPadding; + u8 x = list->template.cursor_X; + u8 y = list->itemsAbove * yMultiplier + list->template.upText_Y; + switch (list->template.cursorKind) + { + case 0: + ListMenuUpdateCursorObj(list->cursor, list->template.window, x, y); + break; + case 1: + case 2: // leftover + case 3: // leftover + break; + } +} + +THUMB_FUNC void ListMenuErasePrintedCursor(struct ListMenu * list, u16 itemsAbove) +{ + switch (list->template.cursorKind) + { + case 0: + u8 yMultiplier = GetFontAttribute(list->template.fontId, 1) + list->template.itemVerticalPadding; + u8 width = 8; + u8 height = 16; + FillWindowPixelRect(list->template.window, + list->template.fillValue, + list->template.cursor_X, + itemsAbove * yMultiplier + list->template.upText_Y, + width, + height); + break; + case 1: + case 2: // leftover + case 3: // leftover + break; + } +} + +THUMB_FUNC u8 ListMenuUpdateSelectedRowIndexAndScrollOffset(struct ListMenu *list, u8 movingDown) +{ + u32 cursorPos; + u16 itemsAbove; + u16 newRow; + + itemsAbove = list->itemsAbove; + cursorPos = list->cursorPos; + + if (!movingDown) + { + if (list->template.maxShowed == 1) + newRow = 0; + else + newRow = list->template.maxShowed - ((list->template.maxShowed / 2) + (list->template.maxShowed % 2)) - 1; + + if (cursorPos == 0) + { + while (itemsAbove != 0) + { + itemsAbove--; + if (list->template.items[cursorPos + itemsAbove].index != LIST_HEADER) + { + list->itemsAbove = itemsAbove; + return 1; + } + } + return 0; + } + else + { + while (itemsAbove > newRow) + { + itemsAbove--; + if (list->template.items[cursorPos + itemsAbove].index != LIST_HEADER) + { + list->itemsAbove = itemsAbove; + return 1; + } + } + list->itemsAbove = newRow; + list->cursorPos = cursorPos - 1; + } + } + else + { + if (list->template.maxShowed == 1) + newRow = 0; + else + newRow = ((list->template.maxShowed / 2) + (list->template.maxShowed % 2)); + + if (cursorPos == list->template.totalItems - list->template.maxShowed) + { + while (itemsAbove < list->template.maxShowed - 1) + { + itemsAbove++; + if (list->template.items[cursorPos + itemsAbove].index != LIST_HEADER) + { + list->itemsAbove = itemsAbove; + return 1; + } + } + return 0; + } + else + { + while (itemsAbove < newRow) + { + itemsAbove++; + if (list->template.items[cursorPos + itemsAbove].index != LIST_HEADER) + { + list->itemsAbove = itemsAbove; + return 1; + } + } + list->itemsAbove = newRow; + list->cursorPos = cursorPos + 1; + } + } + return 2; +} + +THUMB_FUNC void ListMenuScroll(struct ListMenu * list, u8 count, u8 movingDown) +{ + if (count >= list->template.maxShowed) + { + FillWindowPixelBuffer(list->template.window, list->template.fillValue); + ListMenuPrintEntries(list, list->cursorPos, 0, list->template.maxShowed); + } + else + { + u8 yMultiplier = GetFontAttribute(list->template.fontId, 1) + list->template.itemVerticalPadding; + + if (!movingDown) + { + u16 y, width, height; + + ScrollWindow(list->template.window, 1, count * yMultiplier, (list->template.fillValue << 4) | list->template.fillValue); + ListMenuPrintEntries(list, list->cursorPos, 0, count); + + y = (list->template.maxShowed * yMultiplier) + list->template.upText_Y; + width = GetWindowWidth(list->template.window); + height = GetWindowHeight(list->template.window); + FillWindowPixelRect(list->template.window, + list->template.fillValue, + 0, y, width * 8, height * 8 - y); + } + else + { + u32 width; + + ScrollWindow(list->template.window, 0, count * yMultiplier, (list->template.fillValue << 4) | list->template.fillValue); + ListMenuPrintEntries(list, list->cursorPos + (list->template.maxShowed - count), list->template.maxShowed - count, count); + + width = GetWindowWidth(list->template.window); + FillWindowPixelRect(list->template.window, + list->template.fillValue, + 0, 0, width * 8, list->template.upText_Y); + } + } +} + +THUMB_FUNC BOOL ListMenuChangeSelection(struct ListMenu * list, u8 updateCursorAndCallCallback, u8 count, u8 movingDown) +{ + u16 oldSelectedRow; + u8 selectionChange, i, cursorCount; + + oldSelectedRow = list->itemsAbove; + cursorCount = 0; + selectionChange = 0; + for (i = 0; i < count; i++) + { + do + { + u8 ret = ListMenuUpdateSelectedRowIndexAndScrollOffset(list, movingDown); + + selectionChange |= ret; + if (ret != 2) + break; + cursorCount++; + } + while (list->template.items[list->cursorPos + list->itemsAbove].index == LIST_HEADER); + } + + if (updateCursorAndCallCallback) + { + switch (selectionChange) + { + case 0: + default: + return TRUE; + case 1: + ListMenuErasePrintedCursor(list, oldSelectedRow); + ListMenuDrawCursor(list); + ListMenuCallSelectionChangedCallback(list, FALSE); + CopyWindowToVram(list->template.window); + break; + case 2: + case 3: + ListMenuErasePrintedCursor(list, oldSelectedRow); + ListMenuScroll(list, cursorCount, movingDown); + ListMenuDrawCursor(list); + ListMenuCallSelectionChangedCallback(list, FALSE); + CopyWindowToVram(list->template.window); + break; + } + } + return FALSE; +} + +THUMB_FUNC void ListMenuCallSelectionChangedCallback(struct ListMenu * list, u8 onInit) +{ + if (list->template.moveCursorFunc != NULL) + { + list->template.moveCursorFunc(list, list->template.items[list->cursorPos + list->itemsAbove].index, onInit); + } +} + +THUMB_FUNC void ListMenuCopyToVram(struct ListMenu * list) +{ + CopyWindowToVram(list->template.window); +} diff --git a/arm9/src/main.c b/arm9/src/main.c index 117535b2..4879cb4c 100644 --- a/arm9/src/main.c +++ b/arm9/src/main.c @@ -22,7 +22,9 @@ FS_EXTERN_OVERLAY(MODULE_63); #define SOFT_RESET_KEY (PAD_BUTTON_L | PAD_BUTTON_R | PAD_BUTTON_START | PAD_BUTTON_SELECT) -struct Unk2106FA0 gBacklightTop; +s32 UNK_02016FA4; +PMBackLightSwitch gBacklightTop; +struct UnkStruct_02016FA8 UNK_02016FA8;; extern void InitSystemForTheGame(void); extern void InitGraphicMemory(void); @@ -52,6 +54,7 @@ extern u8 SDK_STATIC_BSS_START[]; const int gGameLanguage = GAME_LANGUAGE; const int gGameVersion = GAME_VERSION; +__declspec(noreturn) THUMB_FUNC void NitroMain(void) { InitSystemForTheGame(); @@ -68,13 +71,13 @@ THUMB_FUNC void NitroMain(void) FUN_02002C50(0, 3); FUN_02002C50(1, 3); FUN_02002C50(3, 3); - gBacklightTop.unk18 = -1; - gBacklightTop.unk20 = SaveBlock2_new(); - InitSoundData(FUN_02029EF8(gBacklightTop.unk20), Sav2_PlayerData_GetOptionsAddr(gBacklightTop.unk20)); + UNK_02016FA8.unk10 = -1; + UNK_02016FA8.unk18 = SaveBlock2_new(); + InitSoundData(FUN_02029EF8(UNK_02016FA8.unk18), Sav2_PlayerData_GetOptionsAddr(UNK_02016FA8.unk18)); Init_Timer3(); if (FUN_020337E8(3) == 3) FUN_02034188(3, 0); - if (FUN_020227FC(gBacklightTop.unk20) == 0) + if (FUN_020227FC(UNK_02016FA8.unk18) == 0) { FUN_02089D90(0); } @@ -84,12 +87,12 @@ THUMB_FUNC void NitroMain(void) { case 0: // Title Demo - gBacklightTop.unk1C = 0; + UNK_02016FA8.unk14 = 0; RegisterMainOverlay(FS_OVERLAY_ID(MODULE_63), &MOD63_021DBE18); break; case 1: // Reset transition? - gBacklightTop.unk1C = 1; + UNK_02016FA8.unk14 = 1; RegisterMainOverlay(FS_OVERLAY_ID(MODULE_52), &MOD52_021D76C8); break; default: @@ -102,7 +105,7 @@ THUMB_FUNC void NitroMain(void) InitializeMainRNG(); FUN_0200A2AC(); FUN_02015E30(); - gBacklightTop.unk4 = 0; + UNK_02016FA4 = 0; for (;;) { FUN_02000EE8(); @@ -141,40 +144,40 @@ THUMB_FUNC void NitroMain(void) THUMB_FUNC void FUN_02000DF4(void) { - gBacklightTop.unk8 = (FSOverlayID)-1; - gBacklightTop.unkC = 0; - gBacklightTop.unk10 = (FSOverlayID)-1; // overlay invalid - gBacklightTop.unk14 = NULL; + UNK_02016FA8.unk0 = SDK_OVERLAY_INVALID_ID; + UNK_02016FA8.unk4 = NULL; + UNK_02016FA8.unk8 = SDK_OVERLAY_INVALID_ID; // overlay invalid + UNK_02016FA8.unkC = NULL; } THUMB_FUNC void Main_RunOverlayManager(void) { - if (!gBacklightTop.unkC) + if (UNK_02016FA8.unk4 == NULL) { - if (gBacklightTop.unk14 == NULL) + if (UNK_02016FA8.unkC == NULL) return; - if (gBacklightTop.unk10 != SDK_OVERLAY_INVALID_ID) - HandleLoadOverlay(gBacklightTop.unk10, 0); - gBacklightTop.unk8 = gBacklightTop.unk10; - gBacklightTop.unkC = OverlayManager_new(gBacklightTop.unk14, &gBacklightTop.unk18, 0); - gBacklightTop.unk10 = SDK_OVERLAY_INVALID_ID; - gBacklightTop.unk14 = NULL; + if (UNK_02016FA8.unk8 != SDK_OVERLAY_INVALID_ID) + HandleLoadOverlay(UNK_02016FA8.unk8, 0); + UNK_02016FA8.unk0 = UNK_02016FA8.unk8; + UNK_02016FA8.unk4 = OverlayManager_new(UNK_02016FA8.unkC, &UNK_02016FA8.unk10, 0); + UNK_02016FA8.unk8 = SDK_OVERLAY_INVALID_ID; + UNK_02016FA8.unkC = NULL; } - if (OverlayManager_Run(gBacklightTop.unkC)) + if (OverlayManager_Run(UNK_02016FA8.unk4)) { - OverlayManager_delete(gBacklightTop.unkC); - gBacklightTop.unkC = 0; - if (gBacklightTop.unk8 != SDK_OVERLAY_INVALID_ID) - UnloadOverlayByID(gBacklightTop.unk8); + OverlayManager_delete(UNK_02016FA8.unk4); + UNK_02016FA8.unk4 = NULL; + if (UNK_02016FA8.unk0 != SDK_OVERLAY_INVALID_ID) + UnloadOverlayByID(UNK_02016FA8.unk0); } } THUMB_FUNC void RegisterMainOverlay(FSOverlayID id, const struct Unk21DBE18 * arg1) { - if (gBacklightTop.unk14 != NULL) + if (UNK_02016FA8.unkC != NULL) ErrorHandling(); - gBacklightTop.unk10 = id; - gBacklightTop.unk14 = arg1; + UNK_02016FA8.unk8 = id; + UNK_02016FA8.unkC = arg1; } THUMB_FUNC void FUN_02000E9C(void) @@ -215,7 +218,7 @@ THUMB_FUNC void FUN_02000EE8(void) extern void FUN_0200E3A0(PMLCDTarget, int); -// No Return +__declspec(noreturn) THUMB_FUNC void DoSoftReset(u32 parameter) { FUN_0200E3A0(PM_LCD_TOP, 0x7FFF); @@ -252,7 +255,7 @@ THUMB_FUNC void FUN_02000F4C(u32 arg0, u32 arg1) { HandleDSLidAction(); FUN_02016464(); - if (gMain.unk48 & 1) + if (gMain.newKeys & 1) break; FUN_02000E9C(); } @@ -289,10 +292,10 @@ THUMB_FUNC void HandleDSLidAction(void) FUN_0201CE04(); if (CTRDG_IsPulledOut() == TRUE) { - gBacklightTop.unk4 = 1; + UNK_02016FA4 = 1; } { - int r1 = gBacklightTop.unk4; + int r1 = UNK_02016FA4; while (1) { PMWakeUpTrigger trigger = PM_TRIGGER_COVER_OPEN | PM_TRIGGER_CARD; @@ -306,7 +309,7 @@ THUMB_FUNC void HandleDSLidAction(void) } else if (PAD_DetectFold()) { - r1 = gBacklightTop.unk4 = 1; + r1 = UNK_02016FA4 = 1; } else break; @@ -326,6 +329,6 @@ THUMB_FUNC void HandleDSLidAction(void) { PM_GetBackLight(&top, &bottom); if (top == PM_BACKLIGHT_OFF) - PM_SetBackLight(PM_LCD_ALL, gBacklightTop.unk0); + PM_SetBackLight(PM_LCD_ALL, gBacklightTop); } } diff --git a/arm9/src/scrcmd.c b/arm9/src/scrcmd.c index fb88da54..00ccd34d 100644 --- a/arm9/src/scrcmd.c +++ b/arm9/src/scrcmd.c @@ -676,7 +676,7 @@ THUMB_FUNC BOOL ScrCmd_WaitButtonAB(struct ScriptContext *ctx) THUMB_FUNC static BOOL FUN_0203A46C(struct ScriptContext *ctx) { #pragma unused(ctx) - if (gMain.unk48 & 0x3) // Mask (A | B) ? + if (gMain.newKeys & 0x3) // Mask (A | B) ? { return TRUE; } @@ -692,7 +692,7 @@ THUMB_FUNC BOOL ScrCmd_WaitButtonABTime(struct ScriptContext *ctx) THUMB_FUNC static BOOL FUN_0203A4AC(struct ScriptContext *ctx) { - if (gMain.unk48 & 0x3) // Mask (A | B) ? + if (gMain.newKeys & 0x3) // Mask (A | B) ? { return TRUE; } @@ -713,27 +713,27 @@ THUMB_FUNC BOOL ScrCmd_WaitButton(struct ScriptContext *ctx) THUMB_FUNC static BOOL FUN_0203A4E0(struct ScriptContext *ctx) { - if (gMain.unk48 & 3) + if (gMain.newKeys & 3) { return TRUE; } - else if (gMain.unk48 & 0x40) + else if (gMain.newKeys & 0x40) { FUN_02055304(ctx->unk80->unk38, 0); } - else if (gMain.unk48 & 0x80) + else if (gMain.newKeys & 0x80) { FUN_02055304(ctx->unk80->unk38, 1); } - else if (gMain.unk48 & 0x20) + else if (gMain.newKeys & 0x20) { FUN_02055304(ctx->unk80->unk38, 2); } - else if (gMain.unk48 & 0x10) + else if (gMain.newKeys & 0x10) { FUN_02055304(ctx->unk80->unk38, 3); } - else if (gMain.unk48 & 0x400) + else if (gMain.newKeys & 0x400) { FUN_02039460(ctx->unk80); } @@ -753,11 +753,11 @@ THUMB_FUNC BOOL ScrCmd_Unk0032(struct ScriptContext *ctx) THUMB_FUNC static BOOL FUN_0203A570(struct ScriptContext *ctx) { #pragma unused(ctx) - if (gMain.unk48 & 0x3) + if (gMain.newKeys & 0x3) { return TRUE; } - else if (gMain.unk48 & 0xf0) + else if (gMain.newKeys & 0xf0) { return TRUE; } @@ -973,19 +973,19 @@ THUMB_FUNC static BOOL FUN_0203A94C(struct ScriptContext *ctx) return TRUE; } - if (gMain.unk48 & 0x40) + if (gMain.newKeys & 0x40) { tmp = 0; } - else if (gMain.unk48 & 0x80) + else if (gMain.newKeys & 0x80) { tmp = 1; } - else if (gMain.unk48 & 0x20) + else if (gMain.newKeys & 0x20) { tmp = 2; } - else if (gMain.unk48 & 0x10) + else if (gMain.newKeys & 0x10) { tmp = 3; } @@ -999,7 +999,7 @@ THUMB_FUNC static BOOL FUN_0203A94C(struct ScriptContext *ctx) } else { - if (gMain.unk48 & 0x400) + if (gMain.newKeys & 0x400) { FUN_0201BD7C(*unk1); *varPtr = 1; @@ -1022,24 +1022,24 @@ THUMB_FUNC static BOOL FUN_0203AA0C(struct ScriptContext *ctx) u16 *unk = GetVarPointer(ctx->unk80, (u16)ctx->data[0]); u32 tmp = 0xFFFF; - if (gMain.unk48 & 0x3) + if (gMain.newKeys & 0x3) { *unk = 0; return TRUE; } - else if (gMain.unk48 & 0x40) + else if (gMain.newKeys & 0x40) { tmp = 0; } - else if (gMain.unk48 & 0x80) + else if (gMain.newKeys & 0x80) { tmp = 1; } - else if (gMain.unk48 & 0x20) + else if (gMain.newKeys & 0x20) { tmp = 2; } - else if (gMain.unk48 & 0x10) + else if (gMain.newKeys & 0x10) { tmp = 3; } @@ -1052,7 +1052,7 @@ THUMB_FUNC static BOOL FUN_0203AA0C(struct ScriptContext *ctx) } else { - if (gMain.unk48 & 0x400) + if (gMain.newKeys & 0x400) { *unk = 1; return TRUE; diff --git a/arm9/src/script_buffers.c b/arm9/src/script_buffers.c index e9a55051..939781f4 100644 --- a/arm9/src/script_buffers.c +++ b/arm9/src/script_buffers.c @@ -12,6 +12,8 @@ #include "trainer_data.h" #include "script_buffers.h" #include "unk_02024E64.h" +#include "window.h" +#include "text.h" #pragma thumb on @@ -20,9 +22,7 @@ extern void GetECWordIntoStringByIndex(u32 a0, struct String * a1); extern void StringCat_HandleTrainerName(struct String * dest, const struct String * src); extern void StrAddChar(struct String * str, u16 val); extern void * FUN_02006BB0(NarcId, s32, s32, struct UnkStruct_0200B870_sub **, u32); -extern BOOL UncompressFromNarc(NarcId narcId, s32 memberNo, BOOL a2, u32 heap_id, BOOL a4); -extern void FUN_02019658(int, u8 *, u16, u16, u16, u16, u16, u16, u16, u16); -extern void FUN_020196F4(int, u8, u16, u16, u16, u16); +extern void * UncompressFromNarc(NarcId narcId, s32 memberNo, BOOL isCompressed, u32 heap_id, BOOL allocAtEnd); const u16 UNK_020ECE6C[][2] = { { 0x0140, 0x0008 }, @@ -803,24 +803,24 @@ void MessagePrinter_delete(struct UnkStruct_0200B870 * a0) } } -void FUN_0200B9A8(struct UnkStruct_0200B870 * a0, int a1, int a2, int a3, int a4) +void FUN_0200B9A8(struct UnkStruct_0200B870 * a0, int a1, struct Window * a2, int a3, int a4) { - FUN_02019658(a2, a0->unk_4->unk_14 + UNK_020ECE6C[a1][0], 0, 0, UNK_020ECE6C[a1][1], 8, (u16)a3, (u16)a4, UNK_020ECE6C[a1][1], 8); + BlitBitmapRectToWindow(a2, a0->unk_4->unk_14 + UNK_020ECE6C[a1][0], 0, 0, UNK_020ECE6C[a1][1], 8, (u16)a3, (u16)a4, UNK_020ECE6C[a1][1], 8); } -void FUN_0200B9EC(struct UnkStruct_0200B870 * string, u32 value, u32 n, enum PrintingMode mode, int sp30, int r5, int r7) +void FUN_0200B9EC(struct UnkStruct_0200B870 * string, u32 value, u32 n, enum PrintingMode mode, struct Window *window, int x, int y) { ConvertUIntToDecimalString(string->data, value, mode, n); for (int i = 0; string->data[i] != EOS; i++) { - if (string->data[i] >= 0x00A2 && string->data[i] <= 0x00AB) + if (string->data[i] >= CHAR_0 && string->data[i] <= CHAR_9) { - FUN_02019658(sp30, string->unk_4->unk_14 + (string->data[i] - 0x00A2) * 32, 0, 0, 8, 8, (u16)r5, (u16)r7, 8, 8); + BlitBitmapRectToWindow(window, string->unk_4->unk_14 + (string->data[i] - CHAR_0) * 32, 0, 0, 8, 8, (u16)x, (u16)y, 8, 8); } else { - FUN_020196F4(sp30, (u8)string->unk_28, (u16)r5, (u16)r7, 8, 8); + FillWindowPixelRect(window, (u8)string->unk_28, (u16)x, (u16)y, 8, 8); } - r5 += 8; + x += 8; } } diff --git a/arm9/src/text.c b/arm9/src/text.c index 3034baab..b21acf88 100644 --- a/arm9/src/text.c +++ b/arm9/src/text.c @@ -2,6 +2,9 @@ #include "heap.h" #include "string16.h" #include "MI_memory.h" +#include "filesystem.h" +#include "script_buffers.h" +#include "unk_0200CA44.h" const struct FontInfo *gFonts = NULL; @@ -12,20 +15,13 @@ u16 UNK_021C5710; u16 UNK_021C5712; u8 UNK_021C570C; -extern u32 FUN_0200CA7C(void (*func)(u32, struct TextPrinter *), struct TextPrinter *printer, u32 param2); - extern struct TextPrinter *FUN_0201B6C8(void); -extern void FUN_0200CAB4(u32 param0); extern void FUN_0201C1A8(struct TextPrinter *printer); -extern void CopyWindowToVram(u32 windowId); extern u32 FontFunc(u8 fontId, struct TextPrinter *printer); -extern void *FUN_02006BB0(u32 param0, u32 param1, u32 param2, struct TextPrinter **param3, u32 param4); - -extern u32 FUN_0201AB0C(u32 windowId); -extern void FUN_02019658(u32 param0, u32 param1, u32 param2, u32 param3, u32 param4, u32 param5, u32 param6, u32 param7, u32 param8, u32 param9); +extern void * FUN_02006BB0(NarcId, s32, s32, struct UnkStruct_0200B870_sub **, u32); THUMB_FUNC void SetFontsPointer(const struct FontInfo *fonts) @@ -99,11 +95,11 @@ THUMB_FUNC void FUN_0201BD7C(u32 param0) FUN_0201BCFC(param0); } -THUMB_FUNC u16 AddTextPrinterParameterized(u32 windowId, u8 fontId, const u16 *str, u32 x, u32 y, u32 speed, u8 (*callback)(struct TextPrinterTemplate *, u16)) +THUMB_FUNC u16 AddTextPrinterParameterized(struct Window * window, u8 fontId, const u16 *str, u32 x, u32 y, u32 speed, u8 (*callback)(struct TextPrinterTemplate *, u16)) { struct TextPrinterTemplate printerTemplate; - printerTemplate.windowId = windowId; + printerTemplate.window = window; printerTemplate.currentChar = str; printerTemplate.fontId = fontId; printerTemplate.x = (u8)x; @@ -122,11 +118,11 @@ THUMB_FUNC u16 AddTextPrinterParameterized(u32 windowId, u8 fontId, const u16 *s return AddTextPrinter(&printerTemplate, speed, callback); } -THUMB_FUNC u16 AddTextPrinterParameterized2(u32 windowId, u8 fontId, const u16 *str, u32 x, u32 y, u32 speed, u32 colors, u8 (*callback)(struct TextPrinterTemplate *, u16)) +THUMB_FUNC u16 AddTextPrinterParameterized2(struct Window * window, u8 fontId, const u16 *str, u32 x, u32 y, u32 speed, u32 colors, u8 (*callback)(struct TextPrinterTemplate *, u16)) { struct TextPrinterTemplate printerTemplate; - printerTemplate.windowId = windowId; + printerTemplate.window = window; printerTemplate.currentChar = str; printerTemplate.fontId = fontId; printerTemplate.x = (u8)x; @@ -145,13 +141,13 @@ THUMB_FUNC u16 AddTextPrinterParameterized2(u32 windowId, u8 fontId, const u16 * return AddTextPrinter(&printerTemplate, speed, callback); } -THUMB_FUNC u16 AddTextPrinterParameterized3(u32 windowId, u8 fontId, const u16 *str, u32 x, u32 y, u32 speed, u32 colors, u32 letterSpacing, u32 lineSpacing, u8 (*callback)(struct TextPrinterTemplate *, u16)) +THUMB_FUNC u16 AddTextPrinterParameterized3(struct Window * window, u32 fontId, const u16 *str, u32 x, u32 y, u32 speed, u32 colors, u32 letterSpacing, u32 lineSpacing, u8 (*callback)(struct TextPrinterTemplate *, u16)) { struct TextPrinterTemplate printerTemplate; - printerTemplate.windowId = windowId; + printerTemplate.window = window; printerTemplate.currentChar = str; - printerTemplate.fontId = fontId; + printerTemplate.fontId = (u8)fontId; printerTemplate.x = (u8)x; printerTemplate.y = (u8)y; printerTemplate.currentX = (u8)x; @@ -214,7 +210,7 @@ THUMB_FUNC u16 AddTextPrinter(struct TextPrinterTemplate *printerTemplate, u32 s } if (speed != 0xff) { - CopyWindowToVram(printer->printerTemplate.windowId); // CopyWindowToVram? + CopyWindowToVram(printer->printerTemplate.window); } FUN_0201C238(printer); FreeToHeap((void *)printer); @@ -235,7 +231,7 @@ THUMB_FUNC void RunTextPrinter(u32 param0, struct TextPrinter *printer) switch (temp) { case 0: - CopyWindowToVram(printer->printerTemplate.windowId); + CopyWindowToVram(printer->printerTemplate.window); //fallthrough case 3: if (printer->callback == NULL) @@ -330,12 +326,12 @@ THUMB_FUNC void FUN_0201C1A8(struct TextPrinter *printer) printer->Unk2C = NULL; } -THUMB_FUNC void *FUN_0201C1B0(void) +THUMB_FUNC u16 *FUN_0201C1B0(void) { - void *res = AllocFromHeap(0, sizeof(struct TextPrinter) * 32); - struct TextPrinter *var; - void *tmp = FUN_02006BB0(14, 5, 0, &var, 0); - MIi_CpuCopy32((void *)var->printerTemplate.Unk20, res, sizeof(struct TextPrinter) * 32); //todo Unk20 can't be right here + void *res = AllocFromHeap(0, 32 * 24 * sizeof(u16)); + struct UnkStruct_0200B870_sub * var; + void *tmp = FUN_02006BB0(NARC_GRAPHIC_FONT, 5, 0, &var, 0); + MIi_CpuCopy32(var->unk_14, res, 32 * 24 * sizeof(u16)); FreeToHeap(tmp); return res; } @@ -343,14 +339,14 @@ THUMB_FUNC void *FUN_0201C1B0(void) THUMB_FUNC void FUN_0201C1EC(struct TextPrinter *printer, u32 param1, u32 param2, u32 param3) { #pragma unused (param1, param2) - u32 windowId = printer->printerTemplate.windowId; + struct Window * window = printer->printerTemplate.window; if (printer->Unk2C == NULL) { printer->Unk2C = FUN_0201C1B0(); } - u32 r6 = (u32)printer->Unk2C + param3 * (sizeof(struct TextPrinter) * 8); - u32 r2 = ((FUN_0201AB0C(windowId) - 3) << 0x13) >> 0x10; - FUN_02019658(windowId, r6, 0, 0, 24, 32, r2, 0, 24, 32); + u16 * r6 = printer->Unk2C + param3 * 24 * 8; + u16 r2 = (GetWindowWidth(window) - 3) * 8; + BlitBitmapRectToWindow(window, r6, 0, 0, 24, 32, r2, 0, 24, 32); } THUMB_FUNC void FUN_0201C238(struct TextPrinter *printer) diff --git a/arm9/src/text_02054590.c b/arm9/src/text_02054590.c index 470a2fe3..e2765c6f 100644 --- a/arm9/src/text_02054590.c +++ b/arm9/src/text_02054590.c @@ -7,18 +7,16 @@ extern void FUN_02002EEC(u32 param0, u32 param1, u32 param2); extern void FUN_02019064(u32 param0, u32 param1, u32 param2, u8 param3, u32 param4, u8 param5, u32 param6, u32 param7, u32 param8); -extern void FUN_0200CD68(u32 param0, u32 param1, u32 param2, u32 param3, u8 param4, u32 param5); -extern u32 FUN_0201AB08(u32 *param0); -extern void FUN_0200D0BC(u32 *param0, u32 param1, u32 param2, u32 param3); - -extern void FUN_02019620(u32 *param0, u32 param1); +extern void FUN_0200CD68(void * param0, u32 param1, u32 param2, u32 param3, u8 param4, u32 param5); +extern u32 FUN_0201AB08(struct Window *param0); +extern void FUN_0200D0BC(struct Window *param0, u32 param1, u32 param2, u32 param3); extern void FUN_02002B60(u8 param0); extern void FUN_02002B7C(u32 param0); extern void FUN_02002BB8(u32 param0); -extern void FUN_0200D300(u32 param0, u32 param1, u32 param2, u32 param3, u8 param4, u32 param5, u32 param6); -extern void FUN_0200D6F8(u32 *param0, u32 param1, u32 param2, u32 param3, u8 param4); +extern void FUN_0200D300(void * param0, u32 param1, u32 param2, u32 param3, u8 param4, u32 param5, u32 param6); +extern void FUN_0200D6F8(struct Window *param0, u32 param1, u32 param2, u32 param3, u8 param4); THUMB_FUNC void FUN_02054590(u32 param0, u32 param1) @@ -43,32 +41,32 @@ THUMB_FUNC void FUN_020545B8(u32 param0, u32 param1, u32 param2) } } -THUMB_FUNC void FUN_02054608(u32 *param0, struct Options *options) +THUMB_FUNC void FUN_02054608(struct Window *param0, struct Options *options) { - FUN_0200CD68(*param0, FUN_0201AB08(param0), 994, 10, (u8)Options_GetFrame(options), 4); + FUN_0200CD68(param0->unk_00, FUN_0201AB08(param0), 994, 10, (u8)Options_GetFrame(options), 4); FUN_0205464C(param0); FUN_0200D0BC(param0, 0, 994, 10); } -THUMB_FUNC void FUN_0205464C(u32 *param0) +THUMB_FUNC void FUN_0205464C(struct Window *param0) { - FUN_02019620(param0, 15); + FillWindowPixelBuffer(param0, 15); } -THUMB_FUNC u16 FUN_02054658(u8 windowId, const u16 *str, struct Options *options, u8 param3) +THUMB_FUNC u16 FUN_02054658(struct Window * window, const u16 *str, struct Options *options, u8 param3) { FUN_02002B60(param3); FUN_02002B7C(0); FUN_02002BB8(0); - return AddTextPrinterParameterized(windowId, 1, str, 0, 0, (u32)Options_GetTextFrameDelay(options), NULL); + return AddTextPrinterParameterized(window, 1, str, 0, 0, (u32)Options_GetTextFrameDelay(options), NULL); } -THUMB_FUNC u16 DrawFieldMessage(u8 windowId, const u16 *str, u8 fontId, u32 speed, u8 a4, u32 a5) +THUMB_FUNC u16 DrawFieldMessage(struct Window * window, const u16 *str, u8 fontId, u32 speed, u8 a4, u32 a5) { FUN_02002B60(a4); FUN_02002B7C(a5); FUN_02002BB8(0); - return AddTextPrinterParameterized(windowId, fontId, str, 0, 0, speed, NULL); + return AddTextPrinterParameterized(window, fontId, str, 0, 0, speed, NULL); } THUMB_FUNC u8 FUN_020546C8(u32 param0) //bool8? @@ -100,9 +98,9 @@ THUMB_FUNC void FUN_020546E0(u32 param0, u32 param1, u32 param2, u32 param3) } } -THUMB_FUNC void FUN_02054744(u32 *param0, u32 param1, u32 param2) +THUMB_FUNC void FUN_02054744(struct Window *param0, u32 param1, u32 param2) { - FUN_0200D300(*param0, FUN_0201AB08(param0), 0x399, 9, (u8)param1, param2, 4); - FUN_02019620(param0, 15); + FUN_0200D300(param0->unk_00, FUN_0201AB08(param0), 0x399, 9, (u8)param1, param2, 4); + FillWindowPixelBuffer(param0, 15); FUN_0200D6F8(param0, 0, 0x399, 9, (u8)param1); } diff --git a/arm9/src/unk_0200CA44.c b/arm9/src/unk_0200CA44.c index fd703cd3..6ffed8be 100644 --- a/arm9/src/unk_0200CA44.c +++ b/arm9/src/unk_0200CA44.c @@ -2,25 +2,25 @@ #include "main.h" #include "unk_0200CA44.h" -extern BOOL FUN_0201B60C(void *, void (*)(u32, void *), void *, void *); +extern BOOL FUN_0201B60C(void *, void (*)(u32, struct TextPrinter *), struct TextPrinter *, u32); extern void FUN_0201B6A0(s32); -THUMB_FUNC BOOL FUN_0200CA44(void (*r0)(u32, void *), void * r1, void * r2) +THUMB_FUNC BOOL FUN_0200CA44(void (*r0)(u32, struct TextPrinter *), struct TextPrinter * r1, u32 r2) { return FUN_0201B60C(gMain.unk18, r0, r1, r2); } -THUMB_FUNC BOOL FUN_0200CA60(void (*r0)(u32, void *), void * r1, void * r2) +THUMB_FUNC BOOL FUN_0200CA60(void (*r0)(u32, struct TextPrinter *), struct TextPrinter * r1, u32 r2) { return FUN_0201B60C(gMain.unk1C, r0, r1, r2); } -THUMB_FUNC BOOL FUN_0200CA7C(void (*r0)(u32, void *), void * r1, void * r2) +THUMB_FUNC BOOL FUN_0200CA7C(void (*r0)(u32, struct TextPrinter *), struct TextPrinter * r1, u32 r2) { return FUN_0201B60C(gMain.unk24, r0, r1, r2); } -THUMB_FUNC BOOL FUN_0200CA98(void (*r0)(u32, void *), void * r1, void * r2) +THUMB_FUNC BOOL FUN_0200CA98(void (*r0)(u32, struct TextPrinter *), struct TextPrinter * r1, u32 r2) { return FUN_0201B60C(gMain.unk20, r0, r1, r2); } diff --git a/arm9/src/unk_0202E29C.c b/arm9/src/unk_0202E29C.c index 5f99ca8f..938107f2 100644 --- a/arm9/src/unk_0202E29C.c +++ b/arm9/src/unk_0202E29C.c @@ -17,13 +17,9 @@ struct UnkStruct_0202E29C_const const struct UnkStruct_0202E29C_const UNK_020EEC40 = { { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF } }; -struct -{ - u16 unk0; - u32 unk4; - struct UnkStruct_0202E29C *unk8; - -} UNK_021C59E8; +u16 UNK_021C59E8; +struct UnkStruct_0202E29C *UNK_021C59F0; +u32 UNK_021C59EC; extern u32 FUN_0202CEEC(); extern u32 FUN_02023AC4(); @@ -59,28 +55,28 @@ extern BOOL FUN_0202D2D0(); THUMB_FUNC void FUN_0202E29C(struct PlayerData *player_data) { - if (UNK_021C59E8.unk8 == NULL) + if (UNK_021C59F0 == NULL) { - UNK_021C59E8.unk8 = AllocFromHeap(0xf, sizeof(struct UnkStruct_0202E29C)); - MI_CpuFill8(UNK_021C59E8.unk8, 0, sizeof(struct UnkStruct_0202E29C)); + UNK_021C59F0 = AllocFromHeap(0xf, sizeof(struct UnkStruct_0202E29C)); + MI_CpuFill8(UNK_021C59F0, 0, sizeof(struct UnkStruct_0202E29C)); - UNK_021C59E8.unk8->unkCA4 = AllocFromHeap(0xf, FUN_0202CEEC()); - MI_CpuFill8(UNK_021C59E8.unk8->unkCA4, 0, FUN_0202CEEC()); + UNK_021C59F0->unkCA4 = AllocFromHeap(0xf, FUN_0202CEEC()); + MI_CpuFill8(UNK_021C59F0->unkCA4, 0, FUN_0202CEEC()); - UNK_021C59E8.unk8->unkCBC = AllocFromHeap(0xf, FUN_02023AC4()); - MI_CpuFill8(UNK_021C59E8.unk8->unkCBC, 0, FUN_02023AC4()); + UNK_021C59F0->unkCBC = AllocFromHeap(0xf, FUN_02023AC4()); + MI_CpuFill8(UNK_021C59F0->unkCBC, 0, FUN_02023AC4()); - UNK_021C59E8.unk8->unkCC0 = 0x333; - UNK_021C59E8.unk8->unkCB8 = player_data; + UNK_021C59F0->unkCC0 = 0x333; + UNK_021C59F0->unkCB8 = player_data; - MailMsg_init(&UNK_021C59E8.unk8->unkCA8); + MailMsg_init(&UNK_021C59F0->unkCA8); FUN_0202E500(); } } THUMB_FUNC BOOL FUN_0202E344() { - if (UNK_021C59E8.unk8 != NULL) + if (UNK_021C59F0 != NULL) { return TRUE; } @@ -142,26 +138,26 @@ THUMB_FUNC void FUN_0202E380(struct UnkStruct_0202E29C_sub *param0, u32 param1) for (int i = 0; i < 0x10; i++) { - if (UNK_021C59E8.unk8->unkC84[i] == 0) + if (UNK_021C59F0->unkC84[i] == 0) { continue; } - if (!FUN_0202E358(UNK_021C59E8.unk8->unk054[i].unk04, param0->unk04, 6)) + if (!FUN_0202E358(UNK_021C59F0->unk054[i].unk04, param0->unk04, 6)) { continue; } - UNK_021C59E8.unk8->unkC84[i] = 0x96; + UNK_021C59F0->unkC84[i] = 0x96; - MI_CpuCopy8(param0, &UNK_021C59E8.unk8->unk054[i], sizeof(struct UnkStruct_0202E29C_sub)); + MI_CpuCopy8(param0, &UNK_021C59F0->unk054[i], sizeof(struct UnkStruct_0202E29C_sub)); return; } int i; for (i = 0; i < 0x10; i++) { - if (UNK_021C59E8.unk8->unkC84[i] == 0) + if (UNK_021C59F0->unkC84[i] == 0) { break; } @@ -169,9 +165,9 @@ THUMB_FUNC void FUN_0202E380(struct UnkStruct_0202E29C_sub *param0, u32 param1) if (i < 0x10) { - UNK_021C59E8.unk8->unkC84[i] = 0x96; - MI_CpuCopy8(param0, &UNK_021C59E8.unk8->unk054[i], sizeof(struct UnkStruct_0202E29C_sub)); - UNK_021C59E8.unk8->unkCB4 = 1; + UNK_021C59F0->unkC84[i] = 0x96; + MI_CpuCopy8(param0, &UNK_021C59F0->unk054[i], sizeof(struct UnkStruct_0202E29C_sub)); + UNK_021C59F0->unkCB4 = 1; } } @@ -183,19 +179,19 @@ THUMB_FUNC void FUN_0202E470(u32 param0, u32 param1) OS_Terminate(); } - UNK_021C59E8.unk4 = 2; + UNK_021C59EC = 2; } THUMB_FUNC void FUN_0202E488() { - UNK_021C59E8.unk4 = 0; + UNK_021C59EC = 0; FUN_02016454(4); } THUMB_FUNC void FUN_0202E49C() { FUN_02016444(4); - UNK_021C59E8.unk4 = 1; + UNK_021C59EC = 1; if (FUN_02090DB8(8, FUN_0202E470, 0) != 1) { OS_Terminate(); @@ -204,7 +200,7 @@ THUMB_FUNC void FUN_0202E49C() THUMB_FUNC BOOL FUN_0202E4C8() { - if (UNK_021C59E8.unk4 == 2) + if (UNK_021C59EC == 2) { return TRUE; } @@ -214,7 +210,7 @@ THUMB_FUNC BOOL FUN_0202E4C8() THUMB_FUNC BOOL FUN_0202E4DC() { - if (UNK_021C59E8.unk4 != 0) + if (UNK_021C59EC != 0) { return TRUE; } @@ -229,42 +225,42 @@ THUMB_FUNC void FUN_0202E4F0() THUMB_FUNC void FUN_0202E500() { - UNK_021C59E8.unk8->unkCB0 = 0; - FUN_0202CE64(UNK_021C59E8.unk8->unkCA4 + (32 - (u32)(UNK_021C59E8.unk8->unkCA4) % 32)); + UNK_021C59F0->unkCB0 = 0; + FUN_0202CE64(UNK_021C59F0->unkCA4 + (32 - (u32)(UNK_021C59F0->unkCA4) % 32)); - FUN_0202CB70(UNK_021C59E8.unk8->unkCC0); + FUN_0202CB70(UNK_021C59F0->unkCC0); } THUMB_FUNC void FUN_0202E538() { for (int i = 0; i < 0x10; i++) { - UNK_021C59E8.unk8->unkC84[i] = 0; + UNK_021C59F0->unkC84[i] = 0; } - MI_CpuFill8(UNK_021C59E8.unk8->unk054, 0, 0xC00); + MI_CpuFill8(UNK_021C59F0->unk054, 0, 0xC00); } THUMB_FUNC void FUN_0202E56C(u32 param0) { - UNK_021C59E8.unk8->unkDAD_3 = (u8)param0; + UNK_021C59F0->unkDAD_3 = (u8)param0; } THUMB_FUNC void FUN_0202E594() { - UNK_021C59E8.unk8->unkCB4 = 0; + UNK_021C59F0->unkCB4 = 0; - UNK_021C59E8.unk8->unkDAD_0 = 0; + UNK_021C59F0->unkDAD_0 = 0; - UNK_021C59E8.unk8->unkDAD_2 = 0; + UNK_021C59F0->unkDAD_2 = 0; - UNK_021C59E8.unk8->unkDAA = 0; + UNK_021C59F0->unkDAA = 0; - UNK_021C59E8.unk8->unkDAD_4 = 0; + UNK_021C59F0->unkDAD_4 = 0; - UNK_021C59E8.unk8->unkDAC = 0; + UNK_021C59F0->unkDAC = 0; - UNK_021C59E8.unk8->unkDAB = 0; + UNK_021C59F0->unkDAB = 0; } THUMB_FUNC BOOL FUN_0202E5F8(u32 param0, u32 param1, u32 param2) @@ -274,13 +270,13 @@ THUMB_FUNC BOOL FUN_0202E5F8(u32 param0, u32 param1, u32 param2) FUN_0202E56C(param1); FUN_0202D2F4(); - if (UNK_021C59E8.unk8->unkDAB == 0) + if (UNK_021C59F0->unkDAB == 0) { FUN_0202D0A0(FUN_020303BC, 0xe); - UNK_021C59E8.unk8->unkDAB = 1; + UNK_021C59F0->unkDAB = 1; } - UNK_021C59E8.unk8->unkDAD_5 = (u8)param2; + UNK_021C59F0->unkDAD_5 = (u8)param2; if (FUN_0202CBD4() == 1 && FUN_0202CBFC() != 0) { return TRUE; @@ -298,10 +294,10 @@ THUMB_FUNC u32 FUN_0202E66C(u32 param0, u32 param1) FUN_0202E538(); } - if (UNK_021C59E8.unk8->unkDAB == 0) + if (UNK_021C59F0->unkDAB == 0) { FUN_0202D0A0(FUN_02030238, 0xe); - UNK_021C59E8.unk8->unkDAB = 1; + UNK_021C59F0->unkDAB = 1; } if (FUN_0202CBD4() == 1) @@ -319,23 +315,23 @@ THUMB_FUNC u32 FUN_0202E66C(u32 param0, u32 param1) THUMB_FUNC u32 FUN_0202E6F0() { - if (UNK_021C59E8.unk8 == NULL) + if (UNK_021C59F0 == NULL) { return 1; } - switch (UNK_021C59E8.unk8->unkDAC) + switch (UNK_021C59F0->unkDAC) { case 0: if (FUN_0202D21C() != 0) { FUN_0202C770(); - UNK_021C59E8.unk8->unkDAC = 1; + UNK_021C59F0->unkDAC = 1; } else if (FUN_0202D1E4() == 0) { FUN_0202D100(); - UNK_021C59E8.unk8->unkDAC = 2; + UNK_021C59F0->unkDAC = 2; } break; @@ -343,7 +339,7 @@ THUMB_FUNC u32 FUN_0202E6F0() if (FUN_0202D1E4() == 0) { FUN_0202D100(); - UNK_021C59E8.unk8->unkDAC = 2; + UNK_021C59F0->unkDAC = 2; } break; case 2: @@ -354,7 +350,7 @@ THUMB_FUNC u32 FUN_0202E6F0() if (FUN_0202D200() != 0) { - UNK_021C59E8.unk8->unkDAC = 1; + UNK_021C59F0->unkDAC = 1; } break; } @@ -364,9 +360,9 @@ THUMB_FUNC u32 FUN_0202E6F0() THUMB_FUNC BOOL FUN_0202E784() { - if (UNK_021C59E8.unk8 != NULL && UNK_021C59E8.unk8->unkDAA == 0) + if (UNK_021C59F0 != NULL && UNK_021C59F0->unkDAA == 0) { - UNK_021C59E8.unk8->unkDAA = 1; + UNK_021C59F0->unkDAA = 1; FUN_0202D100(); return TRUE; } @@ -376,26 +372,26 @@ THUMB_FUNC BOOL FUN_0202E784() THUMB_FUNC void FUN_0202E7B0(u32 param0) { - if (UNK_021C59E8.unk8 != NULL) + if (UNK_021C59F0 != NULL) { if (param0 != 0) { - UNK_021C59E8.unk8->unkDAA = 2; + UNK_021C59F0->unkDAA = 2; return; } - UNK_021C59E8.unk8->unkDAA = 0; + UNK_021C59F0->unkDAA = 0; FUN_0202E500(); } } THUMB_FUNC void FUN_0202E7D8() { - FreeToHeap(UNK_021C59E8.unk8->unkCBC); - FreeToHeap(UNK_021C59E8.unk8->unkCA4); - FreeToHeap(UNK_021C59E8.unk8); + FreeToHeap(UNK_021C59F0->unkCBC); + FreeToHeap(UNK_021C59F0->unkCA4); + FreeToHeap(UNK_021C59F0); - UNK_021C59E8.unk8 = NULL; + UNK_021C59F0 = NULL; } THUMB_FUNC u32 FUN_0202E810() @@ -408,7 +404,7 @@ THUMB_FUNC u32 FUN_0202E810() u32 count = 0; for (int i = 0; i < 0x10; i++) { - if (UNK_021C59E8.unk8->unkC84[i] != 0) + if (UNK_021C59F0->unkC84[i] != 0) { count++; } @@ -423,7 +419,7 @@ THUMB_FUNC s32 FUN_0202E844(u32 param0) u32 count = 0; for (i = 0; i < 0x10; i++) { - if (UNK_021C59E8.unk8->unkC84[i] == 0) + if (UNK_021C59F0->unkC84[i] == 0) { continue; } @@ -442,25 +438,25 @@ THUMB_FUNC s32 FUN_0202E844(u32 param0) THUMB_FUNC u8 FUN_0202E878() { - return UNK_021C59E8.unk8->unkCB4; + return UNK_021C59F0->unkCB4; } THUMB_FUNC void FUN_0202E88C() { - UNK_021C59E8.unk8->unkCB4 = 0; + UNK_021C59F0->unkCB4 = 0; } THUMB_FUNC s32 FUN_0202E8A0(s32 param0) { - if (UNK_021C59E8.unk8->unkC84[param0] != 0) + if (UNK_021C59F0->unkC84[param0] != 0) { - if (UNK_021C59E8.unk8->unk054[param0].unk50.unk06 == 0) + if (UNK_021C59F0->unk054[param0].unk50.unk06 == 0) { return 1; } else { - return UNK_021C59E8.unk8->unk054[param0].unk50.unk06; + return UNK_021C59F0->unk054[param0].unk50.unk06; } } @@ -490,7 +486,7 @@ THUMB_FUNC s32 FUN_0202E8F4() for (int i = 0xf; i >= 0; i--) { - if (UNK_021C59E8.unk8->unkC84[i] != 0 && FUN_0202EFE4(UNK_021C59E8.unk8->unk054[i].unk04)) + if (UNK_021C59F0->unkC84[i] != 0 && FUN_0202EFE4(UNK_021C59F0->unk054[i].unk04)) { s32 ret2 = FUN_0202E8A0(i); if (ret2 > 1 && ret2 < 8) @@ -512,7 +508,7 @@ THUMB_FUNC s32 FUN_0202E950() for (int i = 0xf; i >= 0; i--) { - if (UNK_021C59E8.unk8->unkC84[i] != 0 && FUN_0202EFE4(UNK_021C59E8.unk8->unk054[i].unk04)) + if (UNK_021C59F0->unkC84[i] != 0 && FUN_0202EFE4(UNK_021C59F0->unk054[i].unk04)) { return i; @@ -534,7 +530,7 @@ THUMB_FUNC void FUN_0202E9AC(u32 param0, struct PlayerData *player_data) u32 count = 0; for (i = 0; i < 0x10; i++) { - if (UNK_021C59E8.unk8->unkC84[i] == 0) + if (UNK_021C59F0->unkC84[i] == 0) { continue; } @@ -561,14 +557,14 @@ THUMB_FUNC u32 FUN_0202E9E8(u32 param0) if (FUN_0202CBD4() == 1) { s32 ret = FUN_02033534(); - UNK_021C59E8.unk8->unkDA8 = (u8)UNK_021C59E8.unk8->unk054[param0].unk36; + UNK_021C59F0->unkDA8 = (u8)UNK_021C59F0->unk054[param0].unk36; if (FUN_0202D8B0(ret) != 0) { - FUN_0202C4D8(1, UNK_021C59E8.unk8->unk054[param0].unk04, 0); + FUN_0202C4D8(1, UNK_021C59F0->unk054[param0].unk04, 0); } else { - FUN_0202D034(1, &UNK_021C59E8.unk8->unk054[param0]); + FUN_0202D034(1, &UNK_021C59F0->unk054[param0]); } return 1; @@ -581,20 +577,20 @@ THUMB_FUNC void FUN_0202EA54() { for (int i = 0; i < 0x10; i++) { - if (UNK_021C59E8.unk8->unkC84[i] == 0) + if (UNK_021C59F0->unkC84[i] == 0) { continue; } - if (UNK_021C59E8.unk8->unkC84[i] == 0) + if (UNK_021C59F0->unkC84[i] == 0) { continue; } - UNK_021C59E8.unk8->unkC84[i]--; + UNK_021C59F0->unkC84[i]--; - if (UNK_021C59E8.unk8->unkC84[i] == 0) + if (UNK_021C59F0->unkC84[i] == 0) { - UNK_021C59E8.unk8->unkCB4 = 1; + UNK_021C59F0->unkCB4 = 1; } } } @@ -606,48 +602,48 @@ THUMB_FUNC void FUN_0202EA9C() if (res != 0xf) { - struct UnkStruct_0202E29C_sub2 *res = &UNK_021C59E8.unk8->unkCC4; + struct UnkStruct_0202E29C_sub2 *res = &UNK_021C59F0->unkCC4; GF_ASSERT((s32)FUN_02023AC4() <= 0x20); GF_ASSERT(PlayerProfile_sizeof() == 0x20); MI_CpuCopy8(player_data, &res->unk08.unk08, PlayerProfile_sizeof()); - MI_CpuCopy8(UNK_021C59E8.unk8->unkCBC, res->unk08.unk28, FUN_02023AC4()); + MI_CpuCopy8(UNK_021C59F0->unkCBC, res->unk08.unk28, FUN_02023AC4()); res->unk00 = PlayerProfile_GetTrainerID(player_data); res->unk04 = (u8)FUN_02033534(); res->unk05 = FUN_0203354C(); - MI_CpuCopy8(&UNK_021C59E8.unk8->unkCA8, &res->unk08.unk00, sizeof(struct MailMessage)); + MI_CpuCopy8(&UNK_021C59F0->unkCA8, &res->unk08.unk00, sizeof(struct MailMessage)); res->unk08.unk4C = (u8)FUN_0202D358(); } else { - struct UnkStruct_0202E29C_sub2 *res = &UNK_021C59E8.unk8->unkCC4; + struct UnkStruct_0202E29C_sub2 *res = &UNK_021C59F0->unkCC4; res->unk00 = PlayerProfile_GetTrainerID(player_data); res->unk04 = (u8)FUN_02033534(); res->unk05 = FUN_0203354C(); - MI_CpuCopy8(&UNK_021C59E8.unk8->unk000, &res->unk08, sizeof(struct UnkStruct_0202E29C_sub3)); + MI_CpuCopy8(&UNK_021C59F0->unk000, &res->unk08, sizeof(struct UnkStruct_0202E29C_sub3)); } - DC_FlushRange(&UNK_021C59E8.unk8->unkCC4, sizeof(struct UnkStruct_0202E29C_sub2)); - FUN_0202CB7C(&UNK_021C59E8.unk8->unkCC4, sizeof(struct UnkStruct_0202E29C_sub2)); + DC_FlushRange(&UNK_021C59F0->unkCC4, sizeof(struct UnkStruct_0202E29C_sub2)); + FUN_0202CB7C(&UNK_021C59F0->unkCC4, sizeof(struct UnkStruct_0202E29C_sub2)); } THUMB_FUNC void FUN_0202EB7C() { - struct UnkStruct_0202E29C_sub2 *r4 = &UNK_021C59E8.unk8->unkCC4; + struct UnkStruct_0202E29C_sub2 *r4 = &UNK_021C59F0->unkCC4; if (r4->unk06 != FUN_0202EDB8()) { r4->unk06 = (u8)FUN_0202EDB8(); - DC_FlushRange(&UNK_021C59E8.unk8->unkCC4, sizeof(struct UnkStruct_0202E29C_sub2)); - FUN_0202CB7C(&UNK_021C59E8.unk8->unkCC4, sizeof(struct UnkStruct_0202E29C_sub2)); + DC_FlushRange(&UNK_021C59F0->unkCC4, sizeof(struct UnkStruct_0202E29C_sub2)); + FUN_0202CB7C(&UNK_021C59F0->unkCC4, sizeof(struct UnkStruct_0202E29C_sub2)); - FUN_0202D240(&UNK_021C59E8.unk8->unkCC4, + FUN_0202D240(&UNK_021C59F0->unkCC4, sizeof(struct UnkStruct_0202E29C_sub2), - UNK_021C59E8.unk8->unkCC0, - UNK_021C59E8.unk0); + UNK_021C59F0->unkCC0, + UNK_021C59E8); } } @@ -657,20 +653,20 @@ THUMB_FUNC void FUN_0202EBD0(u16 param0) FUN_0202DF54(); FUN_0202EB7C(); - if (FUN_0202D19C() == 0 && FUN_0202EE24() == 0 && UNK_021C59E8.unk8->unkDAD_2) + if (FUN_0202D19C() == 0 && FUN_0202EE24() == 0 && UNK_021C59F0->unkDAD_2) { - UNK_021C59E8.unk8->unkDAD_0 = 1; + UNK_021C59F0->unkDAD_0 = 1; } - if (UNK_021C59E8.unk8->unkDA6 == 0xFFFF) + if (UNK_021C59F0->unkDA6 == 0xFFFF) { - UNK_021C59E8.unk8->unkDA6 = param0; + UNK_021C59F0->unkDA6 = param0; } - if (UNK_021C59E8.unk8->unkDAD_1 && - UNK_021C59E8.unk8->unkDA6 > param0) + if (UNK_021C59F0->unkDAD_1 && + UNK_021C59F0->unkDA6 > param0) { - UNK_021C59E8.unk8->unkDAD_0 = 1; + UNK_021C59F0->unkDAD_0 = 1; } if (FUN_0202CBE8() == 25) @@ -681,24 +677,24 @@ THUMB_FUNC void FUN_0202EBD0(u16 param0) switch (r5) { case 0: - if (UNK_021C59E8.unk8->unkDAA == 1) + if (UNK_021C59F0->unkDAA == 1) { FUN_0202E7D8(); return; } - else if (UNK_021C59E8.unk8->unkDAA == 2) + else if (UNK_021C59F0->unkDAA == 2) { - UNK_021C59E8.unk8->unkDAA = 3; + UNK_021C59F0->unkDAA = 3; } break; case 1: - if (UNK_021C59E8.unk8->unkDAA == 1 && FUN_0202D178() != 0) + if (UNK_021C59F0->unkDAA == 1 && FUN_0202D178() != 0) { return; } - if (UNK_021C59E8.unk8->unkDAA == 2 && FUN_0202D178() != 0) + if (UNK_021C59F0->unkDAA == 2 && FUN_0202D178() != 0) { return; } @@ -708,41 +704,41 @@ THUMB_FUNC void FUN_0202EBD0(u16 param0) case 8: case 9: - if (UNK_021C59E8.unk8 != NULL) + if (UNK_021C59F0 != NULL) { - UNK_021C59E8.unk8->unkDAD_0 = 1; + UNK_021C59F0->unkDAD_0 = 1; return; } break; case 7: u16 r0 = FUN_0202CDA4(); - if (UNK_021C59E8.unk8->unkDA9 == 0) + if (UNK_021C59F0->unkDA9 == 0) { - UNK_021C59E8.unk8->unkDA4 = r0; - UNK_021C59E8.unk8->unkDA9 = 5; + UNK_021C59F0->unkDA4 = r0; + UNK_021C59F0->unkDA9 = 5; } else { - UNK_021C59E8.unk8->unkDA9--; + UNK_021C59F0->unkDA9--; } - u16 r5 = UNK_021C59E8.unk8->unkDA4; - if (UNK_021C59E8.unk8->unkDAD_3) + u16 r5 = UNK_021C59F0->unkDA4; + if (UNK_021C59F0->unkDAD_3) { - UNK_021C59E8.unk0++; + UNK_021C59E8++; } FUN_0202EA9C(); FUN_0202CF84(0, - UNK_021C59E8.unk0, + UNK_021C59E8, r5, FUN_0202D858((u16)FUN_02033534()), FUN_0202EEE8((u16)FUN_02033534()), - UNK_021C59E8.unk8->unkDAD_5); + UNK_021C59F0->unkDAD_5); - UNK_021C59E8.unk8->unkDA8 = (u8)r5; + UNK_021C59F0->unkDA8 = (u8)r5; break; } @@ -750,7 +746,7 @@ THUMB_FUNC void FUN_0202EBD0(u16 param0) THUMB_FUNC void FUN_0202ED70(u16 param0) { - if (UNK_021C59E8.unk8 != NULL) + if (UNK_021C59F0 != NULL) { FUN_0202EBD0(param0); } @@ -758,7 +754,7 @@ THUMB_FUNC void FUN_0202ED70(u16 param0) THUMB_FUNC u32 FUN_0202ED84(u16 param0) { - if (UNK_021C59E8.unk8 == NULL) + if (UNK_021C59F0 == NULL) { return 0; } @@ -792,9 +788,9 @@ THUMB_FUNC u32 FUN_0202EDB8() THUMB_FUNC BOOL FUN_0202EDD8() { - if (UNK_021C59E8.unk8 != NULL) + if (UNK_021C59F0 != NULL) { - if (UNK_021C59E8.unk8->unkDAA == 3) + if (UNK_021C59F0->unkDAA == 3) { return TRUE; } @@ -805,7 +801,7 @@ THUMB_FUNC BOOL FUN_0202EDD8() THUMB_FUNC BOOL FUN_0202EDF8() { - if (UNK_021C59E8.unk8 != NULL) + if (UNK_021C59F0 != NULL) { return TRUE; } @@ -815,7 +811,7 @@ THUMB_FUNC BOOL FUN_0202EDF8() THUMB_FUNC u32 FUN_0202EE0C() { - if (UNK_021C59E8.unk8 != NULL) + if (UNK_021C59F0 != NULL) { return FUN_0202D1C8(); } @@ -825,7 +821,7 @@ THUMB_FUNC u32 FUN_0202EE0C() THUMB_FUNC u32 FUN_0202EE24() { - if (UNK_021C59E8.unk8 != NULL) + if (UNK_021C59F0 != NULL) { return FUN_0202CB8C() & 0xFFFE; } @@ -845,7 +841,7 @@ THUMB_FUNC BOOL FUN_0202EE44() THUMB_FUNC BOOL FUN_0202EE60() { - if (UNK_021C59E8.unk8 != NULL && UNK_021C59E8.unk8->unkDAD_0) + if (UNK_021C59F0 != NULL && UNK_021C59F0->unkDAD_0) { return TRUE; } @@ -855,19 +851,19 @@ THUMB_FUNC BOOL FUN_0202EE60() THUMB_FUNC void FUN_0202EE84(u32 param0) { - if (UNK_021C59E8.unk8 != NULL) + if (UNK_021C59F0 != NULL) { - UNK_021C59E8.unk8->unkDAD_2 = (u8)param0; + UNK_021C59F0->unkDAD_2 = (u8)param0; } } THUMB_FUNC void FUN_0202EEB0(u32 param0) { - if (UNK_021C59E8.unk8 != NULL) + if (UNK_021C59F0 != NULL) { - UNK_021C59E8.unk8->unkDAD_1 = (u8)param0; + UNK_021C59F0->unkDAD_1 = (u8)param0; - UNK_021C59E8.unk8->unkDA6 = 0xFFFF; + UNK_021C59F0->unkDA6 = 0xFFFF; } } @@ -891,11 +887,11 @@ THUMB_FUNC u32 FUN_0202EEE8(u16 param0) THUMB_FUNC struct UnkStruct_0202E29C_sub *FUN_0202EF18(u32 param0) { - if (UNK_021C59E8.unk8 != NULL) + if (UNK_021C59F0 != NULL) { - if (UNK_021C59E8.unk8->unkC84[param0] != 0) + if (UNK_021C59F0->unkC84[param0] != 0) { - return &UNK_021C59E8.unk8->unk054[param0]; + return &UNK_021C59F0->unk054[param0]; } } @@ -904,11 +900,11 @@ THUMB_FUNC struct UnkStruct_0202E29C_sub *FUN_0202EF18(u32 param0) THUMB_FUNC struct UnkStruct_0202E29C_sub4 *FUN_0202EF44(s32 param0) { - if (UNK_021C59E8.unk8 != NULL) + if (UNK_021C59F0 != NULL) { - if (UNK_021C59E8.unk8->unkC84[param0] != 0) + if (UNK_021C59F0->unkC84[param0] != 0) { - return &UNK_021C59E8.unk8->unk054[param0].unk50; + return &UNK_021C59F0->unk054[param0].unk50; } } @@ -917,63 +913,49 @@ THUMB_FUNC struct UnkStruct_0202E29C_sub4 *FUN_0202EF44(s32 param0) THUMB_FUNC struct PlayerData *FUN_0202EF70() { - return UNK_021C59E8.unk8->unkCB8; + return UNK_021C59F0->unkCB8; } THUMB_FUNC struct PlayerData *FUN_0202EF84(int param0) { - if (UNK_021C59E8.unk8->unkC84[param0] == 0) + if (UNK_021C59F0->unkC84[param0] == 0) { return NULL; } - struct UnkStruct_0202E29C_sub4 *r0 = &UNK_021C59E8.unk8->unk054[param0].unk50; + struct UnkStruct_0202E29C_sub4 *r0 = &UNK_021C59F0->unk054[param0].unk50; return &r0->unk10; } THUMB_FUNC void FUN_0202EFAC(u8 *param0, s32 param1) { - if (UNK_021C59E8.unk8 != NULL) + if (UNK_021C59F0 != NULL) { GF_ASSERT(param1 < 8); - MI_CpuCopy8(param0, UNK_021C59E8.unk8->unkC54[param1], 6); + MI_CpuCopy8(param0, UNK_021C59F0->unkC54[param1], 6); } } #ifdef NONMATCHING THUMB_FUNC BOOL FUN_0202EFE4(u8 *param0) { - + u8 (*ptr)[6] = UNK_021C59F0->unkC54; for (int i = 0; i < 8; i++) { - if (UNK_021C59E8.unk8->unkC54[i][0] != param0[0]) - { + if (ptr[i][0] != param0[0]) continue; - } - - if (UNK_021C59E8.unk8->unkC54[i][1] != param0[1]) - { + if (ptr[i][1] != param0[1]) continue; - } - if (UNK_021C59E8.unk8->unkC54[i][2] != param0[2]) - { + if (ptr[i][2] != param0[2]) continue; - } - if (UNK_021C59E8.unk8->unkC54[i][3] != param0[3]) - { + if (ptr[i][3] != param0[3]) continue; - } - if (UNK_021C59E8.unk8->unkC54[i][4] != param0[4]) - { + if (ptr[i][4] != param0[4]) continue; - } - if (UNK_021C59E8.unk8->unkC54[i][5] != param0[5]) - { + if (ptr[i][5] != param0[5]) continue; - } - return TRUE; } @@ -1031,9 +1013,9 @@ _0202F026: THUMB_FUNC u32 FUN_0202F03C() { - if (UNK_021C59E8.unk8 != NULL) + if (UNK_021C59F0 != NULL) { - return UNK_021C59E8.unk8->unkDAD_4; + return UNK_021C59F0->unkDAD_4; } return 0; @@ -1041,29 +1023,29 @@ THUMB_FUNC u32 FUN_0202F03C() THUMB_FUNC void FUN_0202F05C() { - if (UNK_021C59E8.unk8 != NULL) + if (UNK_021C59F0 != NULL) { - UNK_021C59E8.unk8->unkDAD_4 = 1; + UNK_021C59F0->unkDAD_4 = 1; } } THUMB_FUNC void FUN_0202F078(struct MailMessage *mail_message) { - MI_CpuCopy8(mail_message, &UNK_021C59E8.unk8->unkCA8, sizeof(struct MailMessage)); + MI_CpuCopy8(mail_message, &UNK_021C59F0->unkCA8, sizeof(struct MailMessage)); } THUMB_FUNC void FUN_0202F094(void *param0) { - MI_CpuCopy8(param0, UNK_021C59E8.unk8->unkCBC, FUN_02023AC4()); + MI_CpuCopy8(param0, UNK_021C59F0->unkCBC, FUN_02023AC4()); } THUMB_FUNC void FUN_0202F0B8() { FUN_0202EA9C(); - FUN_0202D240(&UNK_021C59E8.unk8->unkCC4, + FUN_0202D240(&UNK_021C59F0->unkCC4, sizeof(struct UnkStruct_0202E29C_sub2), - UNK_021C59E8.unk8->unkCC0, - UNK_021C59E8.unk0); + UNK_021C59F0->unkCC0, + UNK_021C59E8); } THUMB_FUNC u32 FUN_0202F0DC(u8 param0) @@ -1089,15 +1071,15 @@ THUMB_FUNC BOOL FUN_0202F104() THUMB_FUNC void FUN_0202F10C(struct UnkStruct_0202E29C_sub3 *param0) { - MI_CpuCopy8(param0, &UNK_021C59E8.unk8->unk000, sizeof(struct UnkStruct_0202E29C_sub3)); + MI_CpuCopy8(param0, &UNK_021C59F0->unk000, sizeof(struct UnkStruct_0202E29C_sub3)); FUN_0202F0B8(); } THUMB_FUNC u8 *FUN_0202F124(u32 param0) { - if (UNK_021C59E8.unk8 != NULL && UNK_021C59E8.unk8->unkC84[param0] != 0) + if (UNK_021C59F0 != NULL && UNK_021C59F0->unkC84[param0] != 0) { - struct UnkStruct_0202E29C_sub4 *r0 = &UNK_021C59E8.unk8->unk054[param0].unk50; + struct UnkStruct_0202E29C_sub4 *r0 = &UNK_021C59F0->unk054[param0].unk50; return r0->unk08; } diff --git a/arm9/src/unk_0206015C.c b/arm9/src/unk_0206015C.c index 3d295156..a217f52c 100644 --- a/arm9/src/unk_0206015C.c +++ b/arm9/src/unk_0206015C.c @@ -111,7 +111,7 @@ THUMB_FUNC BOOL FUN_02060194(struct UnkStruct_0204639C *unkStruct0) case 5: unkStruct1->unkE += 1; - if (unkStruct1->unkE < 0x3c && !(gMain.unk48 & 1)) + if (unkStruct1->unkE < 0x3c && !(gMain.newKeys & 1)) break; MOD06_02245198(unkStruct1->unkD, unkStruct1->unk4); |