diff options
Diffstat (limited to 'src/menu.c')
-rw-r--r-- | src/menu.c | 143 |
1 files changed, 67 insertions, 76 deletions
diff --git a/src/menu.c b/src/menu.c index 62387c323..85275b6bc 100644 --- a/src/menu.c +++ b/src/menu.c @@ -18,7 +18,6 @@ #include "task.h" #include "text_window.h" #include "window.h" -#include "constants/flags.h" #include "constants/songs.h" #define DLG_WINDOW_PALETTE_NUM 15 @@ -57,9 +56,9 @@ static EWRAM_DATA u8 sPaletteNum = 0; static EWRAM_DATA u8 sYesNoWindowId = 0; static EWRAM_DATA u8 sWindowId = 0; static EWRAM_DATA u16 sFiller = 0; // needed to align -static EWRAM_DATA bool8 gUnknown_0203CDA4[4] = {FALSE}; -static EWRAM_DATA u16 gUnknown_0203CDA8 = 0; -static EWRAM_DATA void *gUnknown_0203CDAC[0x20] = {NULL}; +static EWRAM_DATA bool8 sScheduledBgCopiesToVram[4] = {FALSE}; +static EWRAM_DATA u16 sTempTileDataBufferIdx = 0; +static EWRAM_DATA void *sTempTileDataBuffer[0x20] = {NULL}; const u16 gUnknown_0860F074[] = INCBIN_U16("graphics/interface/860F074.gbapal"); @@ -154,7 +153,7 @@ void FreeAllOverworldWindowBuffers(void) FreeAllWindowBuffers(); } -void sub_8197200(void) +void InitTextBoxGfxAndPrinters(void) { ChangeBgX(0, 0, 0); ChangeBgY(0, 0, 0); @@ -181,7 +180,7 @@ u16 AddTextPrinterParameterized2(u8 windowId, u8 fontId, const u8 *str, u8 speed printer.currentY = 1; printer.letterSpacing = 0; printer.lineSpacing = 0; - printer.unk = 0; + printer.style = 0; printer.fgColor = fgColor; printer.bgColor = bgColor; printer.shadowColor = shadowColor; @@ -1076,17 +1075,17 @@ s8 Menu_ProcessInputNoWrapAround_other(void) PlaySE(SE_SELECT); return sMenu.cursorPos; } - else if (gMain.newKeys & B_BUTTON) + if (gMain.newKeys & B_BUTTON) { return MENU_B_PRESSED; } - else if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_UP) + if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_UP) { if (oldPos != Menu_MoveCursorNoWrapAround(-1)) PlaySE(SE_SELECT); return MENU_NOTHING_CHOSEN; } - else if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_DOWN) + if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_DOWN) { if (oldPos != Menu_MoveCursorNoWrapAround(1)) PlaySE(SE_SELECT); @@ -1131,7 +1130,7 @@ void AddItemMenuActionTextPrinters(u8 windowId, u8 fontId, u8 left, u8 top, u8 l printer.fgColor = GetFontAttribute(fontId, FONTATTR_COLOR_FOREGROUND); printer.bgColor = GetFontAttribute(fontId, FONTATTR_COLOR_BACKGROUND); printer.shadowColor = GetFontAttribute(fontId, FONTATTR_COLOR_SHADOW); - printer.unk = GetFontAttribute(fontId, FONTATTR_UNKNOWN); + printer.style = GetFontAttribute(fontId, FONTATTR_STYLE); printer.letterSpacing = letterSpacing; printer.lineSpacing = GetFontAttribute(fontId, FONTATTR_LINE_SPACING); printer.x = left; @@ -1195,7 +1194,7 @@ void sub_8198AF8(const struct WindowTemplate *window, u8 fontId, u8 left, u8 top printer.fgColor = GetFontAttribute(fontId, FONTATTR_COLOR_FOREGROUND); printer.bgColor = GetFontAttribute(fontId, FONTATTR_COLOR_BACKGROUND); printer.shadowColor = GetFontAttribute(fontId, FONTATTR_COLOR_SHADOW); - printer.unk = GetFontAttribute(fontId, FONTATTR_UNKNOWN); + printer.style = GetFontAttribute(fontId, FONTATTR_STYLE); printer.letterSpacing = GetFontAttribute(fontId, FONTATTR_LETTER_SPACING); printer.lineSpacing = GetFontAttribute(fontId, FONTATTR_LINE_SPACING); @@ -1253,7 +1252,7 @@ void sub_8198DBC(u8 windowId, u8 fontId, u8 left, u8 top, u8 a4, u8 itemCount, u printer.fgColor = GetFontAttribute(fontId, FONTATTR_COLOR_FOREGROUND); printer.bgColor = GetFontAttribute(fontId, FONTATTR_COLOR_BACKGROUND); printer.shadowColor = GetFontAttribute(fontId, FONTATTR_COLOR_SHADOW); - printer.unk = GetFontAttribute(fontId, FONTATTR_UNKNOWN); + printer.style = GetFontAttribute(fontId, FONTATTR_STYLE); printer.letterSpacing = GetFontAttribute(fontId, FONTATTR_LETTER_SPACING); printer.lineSpacing = GetFontAttribute(fontId, FONTATTR_LINE_SPACING); @@ -1300,10 +1299,12 @@ u8 sub_8198F58(u8 windowId, u8 fontId, u8 left, u8 top, u8 a4, u8 cursorHeight, else sMenu.cursorPos = pos; - sub_8199134(0, 0); + // Why call this when it's not gonna move? + ChangeListMenuCursorPosition(MENU_CURSOR_DELTA_NONE, MENU_CURSOR_DELTA_NONE); return sMenu.cursorPos; } +// Unused u8 sub_8198FD4(u8 windowId, u8 fontId, u8 left, u8 top, u8 a4, u8 a5, u8 a6, u8 a7) { u8 cursorHeight = GetMenuCursorDimensionByFont(fontId, 1); @@ -1334,40 +1335,28 @@ void sub_8199060(u8 oldCursorPos, u8 newCursorPos) 0); } -u8 sub_8199134(s8 deltaX, s8 deltaY) +u8 ChangeListMenuCursorPosition(s8 deltaX, s8 deltaY) { u8 oldPos = sMenu.cursorPos; if (deltaX != 0) { if ((sMenu.cursorPos % sMenu.columns) + deltaX < 0) - { sMenu.cursorPos += sMenu.columns - 1; - } else if ((sMenu.cursorPos % sMenu.columns) + deltaX >= sMenu.columns) - { sMenu.cursorPos = (sMenu.cursorPos / sMenu.columns) * sMenu.columns; - } else - { sMenu.cursorPos += deltaX; - } } if (deltaY != 0) { if ((sMenu.cursorPos / sMenu.columns) + deltaY < 0) - { sMenu.cursorPos += sMenu.columns * (sMenu.rows - 1); - } else if ((sMenu.cursorPos / sMenu.columns) + deltaY >= sMenu.rows) - { sMenu.cursorPos -= sMenu.columns * (sMenu.rows - 1); - } else - { sMenu.cursorPos += (sMenu.columns * deltaY); - } } if (sMenu.cursorPos > sMenu.maxCursorPos) @@ -1382,7 +1371,7 @@ u8 sub_8199134(s8 deltaX, s8 deltaY) } } -u8 sub_81991F8(s8 deltaX, s8 deltaY) +u8 ChangeGridMenuCursorPosition(s8 deltaX, s8 deltaY) { u8 oldPos = sMenu.cursorPos; @@ -1430,25 +1419,25 @@ s8 sub_8199284(void) else if (gMain.newKeys & DPAD_UP) { PlaySE(SE_SELECT); - sub_8199134(0, -1); + ChangeListMenuCursorPosition(MENU_CURSOR_DELTA_NONE, MENU_CURSOR_DELTA_UP); return MENU_NOTHING_CHOSEN; } else if (gMain.newKeys & DPAD_DOWN) { PlaySE(SE_SELECT); - sub_8199134(0, 1); + ChangeListMenuCursorPosition(MENU_CURSOR_DELTA_NONE, MENU_CURSOR_DELTA_DOWN); return MENU_NOTHING_CHOSEN; } else if (gMain.newKeys & DPAD_LEFT || GetLRKeysPressed() == MENU_L_PRESSED) { PlaySE(SE_SELECT); - sub_8199134(-1, 0); + ChangeListMenuCursorPosition(MENU_CURSOR_DELTA_LEFT, MENU_CURSOR_DELTA_NONE); return MENU_NOTHING_CHOSEN; } else if (gMain.newKeys & DPAD_RIGHT || GetLRKeysPressed() == MENU_R_PRESSED) { PlaySE(SE_SELECT); - sub_8199134(1, 0); + ChangeListMenuCursorPosition(MENU_CURSOR_DELTA_RIGHT, MENU_CURSOR_DELTA_NONE); return MENU_NOTHING_CHOSEN; } @@ -1470,25 +1459,25 @@ s8 Menu_ProcessInputGridLayout(void) } else if (gMain.newKeys & DPAD_UP) { - if (oldPos != sub_81991F8(0, -1)) + if (oldPos != ChangeGridMenuCursorPosition(0, -1)) PlaySE(SE_SELECT); return MENU_NOTHING_CHOSEN; } else if (gMain.newKeys & DPAD_DOWN) { - if (oldPos != sub_81991F8(0, 1)) + if (oldPos != ChangeGridMenuCursorPosition(0, 1)) PlaySE(SE_SELECT); return MENU_NOTHING_CHOSEN; } else if (gMain.newKeys & DPAD_LEFT || GetLRKeysPressed() == MENU_L_PRESSED) { - if (oldPos != sub_81991F8(-1, 0)) + if (oldPos != ChangeGridMenuCursorPosition(-1, 0)) PlaySE(SE_SELECT); return MENU_NOTHING_CHOSEN; } else if (gMain.newKeys & DPAD_RIGHT || GetLRKeysPressed() == MENU_R_PRESSED) { - if (oldPos != sub_81991F8(1, 0)) + if (oldPos != ChangeGridMenuCursorPosition(1, 0)) PlaySE(SE_SELECT); return MENU_NOTHING_CHOSEN; } @@ -1510,31 +1499,32 @@ s8 sub_81993D8(void) else if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_UP) { PlaySE(SE_SELECT); - sub_8199134(0, -1); + ChangeListMenuCursorPosition(MENU_CURSOR_DELTA_NONE, MENU_CURSOR_DELTA_UP); return MENU_NOTHING_CHOSEN; } else if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_DOWN) { PlaySE(SE_SELECT); - sub_8199134(0, 1); + ChangeListMenuCursorPosition(MENU_CURSOR_DELTA_NONE, MENU_CURSOR_DELTA_DOWN); return MENU_NOTHING_CHOSEN; } else if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_LEFT || GetLRKeysPressedAndHeld() == MENU_L_PRESSED) { PlaySE(SE_SELECT); - sub_8199134(-1, 0); + ChangeListMenuCursorPosition(MENU_CURSOR_DELTA_LEFT, MENU_CURSOR_DELTA_NONE); return MENU_NOTHING_CHOSEN; } else if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_RIGHT || GetLRKeysPressedAndHeld() == MENU_R_PRESSED) { PlaySE(SE_SELECT); - sub_8199134(1, 0); + ChangeListMenuCursorPosition(MENU_CURSOR_DELTA_RIGHT, MENU_CURSOR_DELTA_NONE); return MENU_NOTHING_CHOSEN; } return MENU_NOTHING_CHOSEN; } +//Unused s8 sub_8199484(void) { u8 oldPos = sMenu.cursorPos; @@ -1550,25 +1540,25 @@ s8 sub_8199484(void) } else if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_UP) { - if (oldPos != sub_81991F8(0, -1)) + if (oldPos != ChangeGridMenuCursorPosition(0, -1)) PlaySE(SE_SELECT); return MENU_NOTHING_CHOSEN; } else if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_DOWN) { - if (oldPos != sub_81991F8(0, 1)) + if (oldPos != ChangeGridMenuCursorPosition(0, 1)) PlaySE(SE_SELECT); return MENU_NOTHING_CHOSEN; } else if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_LEFT || GetLRKeysPressedAndHeld() == MENU_L_PRESSED) { - if (oldPos != sub_81991F8(-1, 0)) + if (oldPos != ChangeGridMenuCursorPosition(-1, 0)) PlaySE(SE_SELECT); return MENU_NOTHING_CHOSEN; } else if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_RIGHT || GetLRKeysPressedAndHeld() == MENU_R_PRESSED) { - if (oldPos != sub_81991F8(1, 0)) + if (oldPos != ChangeGridMenuCursorPosition(1, 0)) PlaySE(SE_SELECT); return MENU_NOTHING_CHOSEN; } @@ -1626,7 +1616,7 @@ void sub_81995E4(u8 windowId, u8 itemCount, const struct MenuAction *strs, const printer.fgColor = GetFontAttribute(1, FONTATTR_COLOR_FOREGROUND); printer.bgColor = GetFontAttribute(1, FONTATTR_COLOR_BACKGROUND); printer.shadowColor = GetFontAttribute(1, FONTATTR_COLOR_SHADOW); - printer.unk = GetFontAttribute(1, FONTATTR_UNKNOWN); + printer.style = GetFontAttribute(1, FONTATTR_STYLE); printer.letterSpacing = 0; printer.lineSpacing = 0; printer.x = 8; @@ -1660,7 +1650,7 @@ void CreateYesNoMenu(const struct WindowTemplate *window, u16 baseTileNum, u8 pa printer.fgColor = GetFontAttribute(1, FONTATTR_COLOR_FOREGROUND); printer.bgColor = GetFontAttribute(1, FONTATTR_COLOR_BACKGROUND); printer.shadowColor = GetFontAttribute(1, FONTATTR_COLOR_SHADOW); - printer.unk = GetFontAttribute(1, FONTATTR_UNKNOWN); + printer.style = GetFontAttribute(1, FONTATTR_STYLE); printer.letterSpacing = 0; printer.lineSpacing = 0; @@ -1691,7 +1681,7 @@ void sub_819983C(u8 windowId, u8 a4, u8 itemCount, u8 itemCount2, const struct M printer.fgColor = GetFontAttribute(1, FONTATTR_COLOR_FOREGROUND); printer.bgColor = GetFontAttribute(1, FONTATTR_COLOR_BACKGROUND); printer.shadowColor = GetFontAttribute(1, FONTATTR_COLOR_SHADOW); - printer.unk = GetFontAttribute(1, FONTATTR_UNKNOWN); + printer.style = GetFontAttribute(1, FONTATTR_STYLE); printer.letterSpacing = 0; printer.lineSpacing = 0; @@ -1733,67 +1723,68 @@ u8 sub_8199944(u8 windowId, u8 optionWidth, u8 columns, u8 rows, u8 initialCurso else sMenu.cursorPos = pos; - sub_8199134(0, 0); + // Why call this when it's not gonna move? + ChangeListMenuCursorPosition(MENU_CURSOR_DELTA_NONE, MENU_CURSOR_DELTA_NONE); return sMenu.cursorPos; } -void clear_scheduled_bg_copies_to_vram(void) +void ClearScheduledBgCopiesToVram(void) { - memset(gUnknown_0203CDA4, 0, sizeof(gUnknown_0203CDA4)); + memset(sScheduledBgCopiesToVram, 0, sizeof(sScheduledBgCopiesToVram)); } -void schedule_bg_copy_tilemap_to_vram(u8 bgId) +void ScheduleBgCopyTilemapToVram(u8 bgId) { - gUnknown_0203CDA4[bgId] = TRUE; + sScheduledBgCopiesToVram[bgId] = TRUE; } -void do_scheduled_bg_tilemap_copies_to_vram(void) +void DoScheduledBgTilemapCopiesToVram(void) { - if (gUnknown_0203CDA4[0] == TRUE) + if (sScheduledBgCopiesToVram[0] == TRUE) { CopyBgTilemapBufferToVram(0); - gUnknown_0203CDA4[0] = FALSE; + sScheduledBgCopiesToVram[0] = FALSE; } - if (gUnknown_0203CDA4[1] == TRUE) + if (sScheduledBgCopiesToVram[1] == TRUE) { CopyBgTilemapBufferToVram(1); - gUnknown_0203CDA4[1] = FALSE; + sScheduledBgCopiesToVram[1] = FALSE; } - if (gUnknown_0203CDA4[2] == TRUE) + if (sScheduledBgCopiesToVram[2] == TRUE) { CopyBgTilemapBufferToVram(2); - gUnknown_0203CDA4[2] = FALSE; + sScheduledBgCopiesToVram[2] = FALSE; } - if (gUnknown_0203CDA4[3] == TRUE) + if (sScheduledBgCopiesToVram[3] == TRUE) { CopyBgTilemapBufferToVram(3); - gUnknown_0203CDA4[3] = FALSE; + sScheduledBgCopiesToVram[3] = FALSE; } } -void reset_temp_tile_data_buffers(void) +void ResetTempTileDataBuffers(void) { int i; - for (i = 0; i < (s32)ARRAY_COUNT(gUnknown_0203CDAC); i++) + for (i = 0; i < (int)ARRAY_COUNT(sTempTileDataBuffer); i++) { - gUnknown_0203CDAC[i] = NULL; + sTempTileDataBuffer[i] = NULL; } - gUnknown_0203CDA8 = 0; + sTempTileDataBufferIdx = 0; } -bool8 free_temp_tile_data_buffers_if_possible(void) +bool8 FreeTempTileDataBuffersIfPossible(void) { int i; if (!IsDma3ManagerBusyWithBgCopy()) { - if (gUnknown_0203CDA8) + if (sTempTileDataBufferIdx) { - for (i = 0; i < gUnknown_0203CDA8; i++) + for (i = 0; i < sTempTileDataBufferIdx; i++) { - FREE_AND_SET_NULL(gUnknown_0203CDAC[i]); + FREE_AND_SET_NULL(sTempTileDataBuffer[i]); } - gUnknown_0203CDA8 = 0; + sTempTileDataBufferIdx = 0; } return FALSE; } @@ -1803,10 +1794,10 @@ bool8 free_temp_tile_data_buffers_if_possible(void) } } -void *decompress_and_copy_tile_data_to_vram(u8 bgId, const void *src, u32 size, u16 offset, u8 mode) +void *DecompressAndCopyTileDataToVram(u8 bgId, const void *src, u32 size, u16 offset, u8 mode) { u32 sizeOut; - if (gUnknown_0203CDA8 < ARRAY_COUNT(gUnknown_0203CDAC)) + if (sTempTileDataBufferIdx < ARRAY_COUNT(sTempTileDataBuffer)) { void *ptr = malloc_and_decompress(src, &sizeOut); if (!size) @@ -1814,7 +1805,7 @@ void *decompress_and_copy_tile_data_to_vram(u8 bgId, const void *src, u32 size, if (ptr) { copy_decompressed_tile_data_to_vram(bgId, ptr, size, offset, mode); - gUnknown_0203CDAC[gUnknown_0203CDA8++] = ptr; + sTempTileDataBuffer[sTempTileDataBufferIdx++] = ptr; } return ptr; } @@ -1958,7 +1949,7 @@ void AddTextPrinterParameterized3(u8 windowId, u8 fontId, u8 left, u8 top, const printer.currentY = printer.y; printer.letterSpacing = GetFontAttribute(fontId, 2); printer.lineSpacing = GetFontAttribute(fontId, 3); - printer.unk = 0; + printer.style = 0; printer.fgColor = color[1]; printer.bgColor = color[0]; printer.shadowColor = color[2]; @@ -1979,7 +1970,7 @@ void AddTextPrinterParameterized4(u8 windowId, u8 fontId, u8 left, u8 top, u8 le printer.currentY = printer.y; printer.letterSpacing = letterSpacing; printer.lineSpacing = lineSpacing; - printer.unk = 0; + printer.style = 0; printer.fgColor = color[1]; printer.bgColor = color[0]; printer.shadowColor = color[2]; @@ -2000,7 +1991,7 @@ void AddTextPrinterParameterized5(u8 windowId, u8 fontId, const u8 *str, u8 left printer.currentY = top; printer.letterSpacing = letterSpacing; printer.lineSpacing = lineSpacing; - printer.unk = 0; + printer.style = 0; printer.fgColor = GetFontAttribute(fontId, 5); printer.bgColor = GetFontAttribute(fontId, 6); @@ -2107,7 +2098,7 @@ void sub_819A27C(u8 windowId, u16 speciesId, u32 personality, u16 x, u16 y) BlitBitmapToWindow(windowId, GetMonIconPtr(speciesId, personality, 1), x, y, 32, 32); } -void sub_819A2BC(u8 palOffset, u8 palId) +void ListMenuLoadStdPalAt(u8 palOffset, u8 palId) { const u16 *palette; |