diff options
Diffstat (limited to 'src/menu.c')
-rw-r--r-- | src/menu.c | 139 |
1 files changed, 70 insertions, 69 deletions
diff --git a/src/menu.c b/src/menu.c index b20ab5164..f4ffec023 100644 --- a/src/menu.c +++ b/src/menu.c @@ -25,11 +25,11 @@ #define STD_WINDOW_PALETTE_NUM 14 #define STD_WINDOW_BASE_TILE_NUM 0x214 -struct SomeUnkStruct_60F0D4 +struct MoveMenuInfoIcon { - u8 unk1; - u8 unk2; - u16 unk3; + u8 width; + u8 height; + u16 offset; }; struct Menu @@ -48,7 +48,7 @@ struct Menu bool8 APressMuted; }; -static EWRAM_DATA u8 gUnknown_0203CD8C = 0; +static EWRAM_DATA u8 gStartMenuWindowId = 0; static EWRAM_DATA u8 gUnknown_0203CD8D = 0; static EWRAM_DATA struct Menu gUnknown_0203CD90 = {0}; static EWRAM_DATA u16 gUnknown_0203CD9C = 0; @@ -76,34 +76,36 @@ static const struct WindowTemplate gUnknown_0860F0A8 = const u16 gUnknown_0860F0B0[] = INCBIN_U16("graphics/interface/860F0B0.gbapal"); const u8 gUnknown_0860F0D0[] = { 15, 1, 2 }; -const struct SomeUnkStruct_60F0D4 gUnknown_0860F0D4[] = -{ - { 12, 12, 0x00 }, - { 32, 12, 0x20 }, - { 32, 12, 0x64 }, - { 32, 12, 0x60 }, - { 32, 12, 0x80 }, - { 32, 12, 0x48 }, - { 32, 12, 0x44 }, - { 32, 12, 0x6C }, - { 32, 12, 0x68 }, - { 32, 12, 0x88 }, - { 32, 12, 0xA4 }, - { 32, 12, 0x24 }, - { 32, 12, 0x28 }, - { 32, 12, 0x2C }, - { 32, 12, 0x40 }, - { 32, 12, 0x84 }, - { 32, 12, 0x4C }, - { 32, 12, 0xA0 }, - { 32, 12, 0x8C }, - { 42, 12, 0xA8 }, - { 42, 12, 0xC0 }, - { 42, 12, 0xC8 }, - { 42, 12, 0xE0 }, - { 42, 12, 0xE8 }, - { 8, 8, 0xAE }, - { 8, 8, 0xAF }, + +// Table of move info icon offsets in graphics/interface_fr/menu.png +const struct MoveMenuInfoIcon gMoveMenuInfoIcons[] = +{ // { width, height, offset } + { 12, 12, 0x00 }, // Unused + { 32, 12, 0x20 }, // Normal icon + { 32, 12, 0x64 }, // Fight icon + { 32, 12, 0x60 }, // Flying icon + { 32, 12, 0x80 }, // Poison icon + { 32, 12, 0x48 }, // Ground icon + { 32, 12, 0x44 }, // Rock icon + { 32, 12, 0x6C }, // Bug icon + { 32, 12, 0x68 }, // Ghost icon + { 32, 12, 0x88 }, // Steel icon + { 32, 12, 0xA4 }, // ??? (Mystery) icon + { 32, 12, 0x24 }, // Fire icon + { 32, 12, 0x28 }, // Water icon + { 32, 12, 0x2C }, // Grass icon + { 32, 12, 0x40 }, // Electric icon + { 32, 12, 0x84 }, // Psychic icon + { 32, 12, 0x4C }, // Ice icon + { 32, 12, 0xA0 }, // Dragon icon + { 32, 12, 0x8C }, // Dark icon + { 42, 12, 0xA8 }, // -Type- icon + { 42, 12, 0xC0 }, // -Power- icon + { 42, 12, 0xC8 }, // -Accuracy- icon + { 42, 12, 0xE0 }, // -PP- icon + { 42, 12, 0xE8 }, // -Effect- icon + { 8, 8, 0xAE }, // Unused (Small white pokeball) + { 8, 8, 0xAF }, // Unused (Small dark pokeball) }; // Forward declarations @@ -118,14 +120,13 @@ extern void DrawWindowBorder(u8, u8, u8, u8, u8, u8); extern void sub_81980A8(u8, u8, u8, u8, u8, u8); extern u8 MoveMenuCursor(s8); extern u8 sub_8199134(s8, s8); -extern void sub_8199F74(u8 windowId, u8 fontId, const u8 *str, u8 left, u8 top, u8 speed, void (*callback)(struct TextSubPrinter *, u16), u8 letterSpacing, u8 lineSpacing); extern void sub_8198C78(void); extern void task_free_buf_after_copying_tile_data_to_vram(u8 taskId); void sub_81971D0(void) { InitWindows(gUnknown_0860F098); - gUnknown_0203CD8C = 0xFF; + gStartMenuWindowId = 0xFF; gUnknown_0203CD8D = 0xFF; } @@ -191,8 +192,8 @@ void AddTextPrinterWithCustomSpeedForMessage(bool8 allowSkippingDelayWithButtonP void sub_81973A4(void) { - copy_textbox_border_tile_patterns_to_vram(0, DLG_WINDOW_BASE_TILE_NUM, DLG_WINDOW_PALETTE_NUM * 0x10); - sub_809882C(0, STD_WINDOW_BASE_TILE_NUM, STD_WINDOW_PALETTE_NUM * 0x10); + LoadMessageBoxGfx(0, DLG_WINDOW_BASE_TILE_NUM, DLG_WINDOW_PALETTE_NUM * 0x10); + LoadUserWindowBorderGfx(0, STD_WINDOW_BASE_TILE_NUM, STD_WINDOW_PALETTE_NUM * 0x10); } void NewMenuHelpers_DrawDialogueFrame(u8 windowId, bool8 copyToVram) @@ -410,7 +411,7 @@ void SetStandardWindowBorderStyle(u8 windowId, bool8 copyToVram) void sub_819786C(u8 windowId, bool8 copyToVram) { - copy_textbox_border_tile_patterns_to_vram(windowId, DLG_WINDOW_BASE_TILE_NUM, DLG_WINDOW_PALETTE_NUM * 0x10); + LoadMessageBoxGfx(windowId, DLG_WINDOW_BASE_TILE_NUM, DLG_WINDOW_PALETTE_NUM * 0x10); sub_8197B1C(windowId, copyToVram, DLG_WINDOW_BASE_TILE_NUM, 0xF); } @@ -471,22 +472,22 @@ u8 GetPlayerTextSpeed(void) u8 sub_81979C4(u8 a1) { - if (gUnknown_0203CD8C == 0xFF) - gUnknown_0203CD8C = sub_8198AA4(0, 0x16, 1, 7, (a1 * 2) + 2, 0xF, 0x139); - return gUnknown_0203CD8C; + if (gStartMenuWindowId == 0xFF) + gStartMenuWindowId = sub_8198AA4(0, 0x16, 1, 7, (a1 * 2) + 2, 0xF, 0x139); + return gStartMenuWindowId; } u8 GetStartMenuWindowId(void) { - return gUnknown_0203CD8C; + return gStartMenuWindowId; } -void remove_start_menu_window_maybe(void) +void RemoveStartMenuWindow(void) { - if (gUnknown_0203CD8C != 0xFF) + if (gStartMenuWindowId != 0xFF) { - RemoveWindow(gUnknown_0203CD8C); - gUnknown_0203CD8C = 0xFF; + RemoveWindow(gStartMenuWindowId); + gStartMenuWindowId = 0xFF; } } @@ -1105,12 +1106,12 @@ void AddItemMenuActionTextPrinters(u8 windowId, u8 fontId, u8 left, u8 top, u8 l printer.windowId = windowId; printer.fontId = fontId; - printer.fgColor = GetFontAttribute(fontId, 5); - printer.bgColor = GetFontAttribute(fontId, 6); - printer.shadowColor = GetFontAttribute(fontId, 7); - printer.fontColor_l = GetFontAttribute(fontId, 4); + printer.fgColor = GetFontAttribute(fontId, FONTATTR_COLOR_FOREGROUND); + printer.bgColor = GetFontAttribute(fontId, FONTATTR_COLOR_BACKGROUND); + printer.shadowColor = GetFontAttribute(fontId, FONTATTR_COLOR_SHADOW); + printer.fontColor_l = GetFontAttribute(fontId, FONTATTR_COLOR_LOWNIBBLE); printer.letterSpacing = letterSpacing; - printer.lineSpacing = GetFontAttribute(fontId, 3); + printer.lineSpacing = GetFontAttribute(fontId, FONTATTR_LINE_SPACING); printer.x = left; printer.currentX = left; @@ -1127,7 +1128,7 @@ void AddItemMenuActionTextPrinters(u8 windowId, u8 fontId, u8 left, u8 top, u8 l void sub_81989B8(u8 windowId, u8 fontId, u8 lineHeight, u8 itemCount, const struct MenuAction *strs, const u8 *a5) { - AddItemMenuActionTextPrinters(windowId, fontId, GetFontAttribute(fontId, 0), 1, GetFontAttribute(fontId, 2), lineHeight, itemCount, strs, a5); + AddItemMenuActionTextPrinters(windowId, fontId, GetFontAttribute(fontId, FONTATTR_MAX_LETTER_WIDTH), 1, GetFontAttribute(fontId, FONTATTR_LETTER_SPACING), lineHeight, itemCount, strs, a5); } void SetWindowTemplateFields(struct WindowTemplate *template, u8 bg, u8 left, u8 top, u8 width, u8 height, u8 paletteNum, u16 baseBlock) @@ -1141,7 +1142,7 @@ void SetWindowTemplateFields(struct WindowTemplate *template, u8 bg, u8 left, u8 template->baseBlock = baseBlock; } -struct WindowTemplate sub_8198A50(u8 bg, u8 left, u8 top, u8 width, u8 height, u8 paletteNum, u16 baseBlock) +struct WindowTemplate CreateWindowTemplate(u8 bg, u8 left, u8 top, u8 width, u8 height, u8 paletteNum, u16 baseBlock) { struct WindowTemplate template; SetWindowTemplateFields(&template, bg, left, top, width, height, paletteNum, baseBlock); @@ -1165,20 +1166,20 @@ void sub_8198AF8(const struct WindowTemplate *window, u8 fontId, u8 left, u8 top printer.current_text_offset = gText_YesNo; printer.windowId = gUnknown_0203CD9F; printer.fontId = fontId; - printer.x = GetFontAttribute(fontId, 0) + left; + printer.x = GetFontAttribute(fontId, FONTATTR_MAX_LETTER_WIDTH) + left; printer.y = top; printer.currentX = printer.x; printer.currentY = printer.y; - printer.fgColor = GetFontAttribute(fontId, 5); - printer.bgColor = GetFontAttribute(fontId, 6); - printer.shadowColor = GetFontAttribute(fontId, 7); - printer.fontColor_l = GetFontAttribute(fontId, 4); - printer.letterSpacing = GetFontAttribute(fontId, 2); - printer.lineSpacing = GetFontAttribute(fontId, 3); + printer.fgColor = GetFontAttribute(fontId, FONTATTR_COLOR_FOREGROUND); + printer.bgColor = GetFontAttribute(fontId, FONTATTR_COLOR_BACKGROUND); + printer.shadowColor = GetFontAttribute(fontId, FONTATTR_COLOR_SHADOW); + printer.fontColor_l = GetFontAttribute(fontId, FONTATTR_COLOR_LOWNIBBLE); + printer.letterSpacing = GetFontAttribute(fontId, FONTATTR_LETTER_SPACING); + printer.lineSpacing = GetFontAttribute(fontId, FONTATTR_LINE_SPACING); AddTextPrinter(&printer, 0xFF, NULL); - sub_81983AC(gUnknown_0203CD9F, fontId, left, top, GetFontAttribute(fontId, 1), 2, initialCursorPos); + sub_81983AC(gUnknown_0203CD9F, fontId, left, top, GetFontAttribute(fontId, FONTATTR_MAX_LETTER_HEIGHT), 2, initialCursorPos); } void sub_8198C34(const struct WindowTemplate *window, u8 fontId, u16 baseTileNum, u8 paletteNum) @@ -1988,7 +1989,7 @@ void sub_8199F74(u8 windowId, u8 fontId, const u8 *str, u8 left, u8 top, u8 spee AddTextPrinter(&printer, speed, callback); } -void sub_819A024(u8 windowId, const u8 *src, u16 a2, u16 a3) +void PrintPlayerNameOnWindow(u8 windowId, const u8 *src, u16 x, u16 y) { int count = 0; while (gSaveBlock2Ptr->playerName[count] != EOS) @@ -1996,7 +1997,7 @@ void sub_819A024(u8 windowId, const u8 *src, u16 a2, u16 a3) StringExpandPlaceholders(gStringVar4, src); - PrintTextOnWindow(windowId, 1, gStringVar4, a2, a3, 0xFF, 0); + PrintTextOnWindow(windowId, 1, gStringVar4, x, y, 0xFF, 0); } //Screw this function, it's long and unreferenced and ugh @@ -2078,7 +2079,7 @@ void sub_819A080(struct UnkStruct_819A080 *a0, struct UnkStruct_819A080 *a1, u16 } } #else -__attribute__((naked)) +NAKED void sub_819A080(struct UnkStruct_819A080 *a0, struct UnkStruct_819A080 *a1, u16 a2, u16 a3, u16 a4, u16 a5, u16 a6, u16 a7) { asm("push {r4-r7,lr}\n\ @@ -2364,22 +2365,22 @@ void sub_819A2BC(u8 palOffset, u8 palId) void blit_move_info_icon(u8 windowId, u8 iconId, u16 x, u16 y) { - BlitBitmapRectToWindow(windowId, gFireRedMenuElements_Gfx + gUnknown_0860F0D4[iconId].unk3 * 32, 0, 0, 128, 128, x, y, gUnknown_0860F0D4[iconId].unk1, gUnknown_0860F0D4[iconId].unk2); + BlitBitmapRectToWindow(windowId, gFireRedMenuElements_Gfx + gMoveMenuInfoIcons[iconId].offset * 32, 0, 0, 128, 128, x, y, gMoveMenuInfoIcons[iconId].width, gMoveMenuInfoIcons[iconId].height); } -void sub_819A344(u8 a0, u8 *a1, u8 a2) +void sub_819A344(u8 a0, u8 *dest, u8 color) { s32 curFlag; s32 flagCount; u8 *endOfString; - u8 *string = a1; + u8 *string = dest; *(string++) = EXT_CTRL_CODE_BEGIN; *(string++) = EXT_CTRL_CODE_COLOR; - *(string++) = a2; + *(string++) = color; *(string++) = EXT_CTRL_CODE_BEGIN; *(string++) = EXT_CTRL_CODE_SHADOW; - *(string++) = a2 + 1; + *(string++) = color + 1; switch (a0) { |