From 7d8a2ae7f0d9edaca7770cf472909bf9197acf2a Mon Sep 17 00:00:00 2001 From: Diegoisawesome Date: Thu, 25 Jan 2018 15:25:35 -0600 Subject: Decompile new_menu_helpers.s --- src/battle_message.c | 2 +- src/battle_script_commands.c | 2 +- src/berry_blender.c | 2 +- src/daycare.c | 6 +- src/decoration.c | 4 +- src/hall_of_fame.c | 8 +- src/naming_screen.c | 2 +- src/new_menu_helpers.c | 442 +++++++++++++++++++++++++++++++++++++++++++ src/scrcmd.c | 6 +- src/start_menu.c | 6 +- src/text.c | 6 +- src/unk_text_util_2.c | 12 +- 12 files changed, 470 insertions(+), 28 deletions(-) create mode 100644 src/new_menu_helpers.c (limited to 'src') diff --git a/src/battle_message.c b/src/battle_message.c index 3fa3d0563..32de3df27 100644 --- a/src/battle_message.c +++ b/src/battle_message.c @@ -2440,7 +2440,7 @@ void BattleHandleAddTextPrinter(const u8 *text, u8 arg1) textSubPrinter.letterSpacing = r8[(12 * arg1) + 4]; textSubPrinter.lineSpacing = r8[(12 * arg1) + 5]; textSubPrinter.fontColor_l = 0; - textSubPrinter.fontColor_h = r8[(12 * arg1) + 7]; + textSubPrinter.fgColor = r8[(12 * arg1) + 7]; textSubPrinter.bgColor = r8[(12 * arg1) + 8]; textSubPrinter.shadowColor = r8[(12 * arg1) + 9]; diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index c7976fc2a..72c637849 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -6730,7 +6730,7 @@ static void PutLevelAndGenderOnLvlUpBox(void) subPrinter.letterSpacing = 0; subPrinter.lineSpacing = 0; subPrinter.fontColor_l = TEXT_COLOR_TRANSPARENT; - subPrinter.fontColor_h = TEXT_COLOR_WHITE; + subPrinter.fgColor = TEXT_COLOR_WHITE; subPrinter.bgColor = TEXT_COLOR_TRANSPARENT; subPrinter.shadowColor = TEXT_COLOR_DARK_GREY; diff --git a/src/berry_blender.c b/src/berry_blender.c index c7f465967..3494492de 100644 --- a/src/berry_blender.c +++ b/src/berry_blender.c @@ -3489,7 +3489,7 @@ void ShowBerryBlenderRecordWindow(void) winTemplate = sBlenderRecordWindowTemplate; gResultsWindowId = AddWindow(&winTemplate); - sub_81973FC(gResultsWindowId, 0); + NewMenuHelpers_DrawStdWindowFrame(gResultsWindowId, 0); FillWindowPixelBuffer(gResultsWindowId, 0x11); xPos = GetStringCenterAlignXOffset(1, gText_BlenderMaxSpeedRecord, 0x90); diff --git a/src/daycare.c b/src/daycare.c index 59ee562bd..f7d1825fd 100644 --- a/src/daycare.c +++ b/src/daycare.c @@ -43,7 +43,7 @@ extern u16 ItemIdToBattleMoveId(u16); extern s32 ListMenuHandleInputGetItemId(u8); extern void sub_81AE6C8(u8, u16*, u16*); extern void sub_819746C(u8, bool8); -extern void sub_81973FC(u8, bool8); +extern void NewMenuHelpers_DrawStdWindowFrame(u8, bool8); extern void sub_81B9328(void); extern void sub_81AF078(u32, bool8, struct ListMenu *); extern void c2_exit_to_overworld_2_switch(void); @@ -1212,7 +1212,7 @@ static void DaycareAddTextPrinter(u8 windowId, const u8 *text, u32 x, u32 y) gTextFlags.flag_1 = 0; printer.letterSpacing = 0; printer.lineSpacing = 1; - printer.fontColor_h = 2; + printer.fgColor = 2; printer.bgColor = 1; printer.shadowColor = 3; @@ -1296,7 +1296,7 @@ void ShowDaycareLevelMenu(void) u8 daycareMenuTaskId; windowId = AddWindow(&sDaycareLevelMenuWindowTemplate); - sub_81973FC(windowId, FALSE); + NewMenuHelpers_DrawStdWindowFrame(windowId, FALSE); menuTemplate = sDaycareListMenuLevelTemplate; menuTemplate.unk_10 = windowId; diff --git a/src/decoration.c b/src/decoration.c index a9777c86f..8fb620b36 100644 --- a/src/decoration.c +++ b/src/decoration.c @@ -727,7 +727,7 @@ void sub_81271CC(u8 taskId) { sub_8126A58(1); sub_8126A88(); - sub_81973C4(0, 0); + NewMenuHelpers_DrawDialogueFrame(0, 0); sub_8126C08(); gTasks[taskId].func = sub_8126B80; } @@ -2712,7 +2712,7 @@ void sub_812A334(void) u8 taskId; pal_fill_black(); - sub_81973C4(0, 1); + NewMenuHelpers_DrawDialogueFrame(0, 1); sub_8126ABC(); taskId = CreateTask(sub_812A2C4, 8); gTasks[taskId].data[2] = 0; diff --git a/src/hall_of_fame.c b/src/hall_of_fame.c index 5390814eb..85fb518b5 100644 --- a/src/hall_of_fame.c +++ b/src/hall_of_fame.c @@ -81,7 +81,7 @@ extern const u8 gText_MainMenuTime[]; extern const u8 gContestConfetti_Gfx[]; extern const u8 gContestConfetti_Pal[]; -extern void sub_81973C4(u8, u8); +extern void NewMenuHelpers_DrawDialogueFrame(u8, u8); extern u16 AddTextPrinterParameterized(u8 windowId, u8 fontId, const u8 *str, u8 speed, void ( *callback)(u16, struct TextPrinter *), u8 fgColor, u8 bgColor, u8 shadowColor); extern void sub_8175620(void); extern u8 TrySavingData(u8); @@ -539,7 +539,7 @@ static void Task_Hof_InitTeamSaveData(u8 taskId) } *lastSavedTeam = *sHofMonPtr; - sub_81973C4(0, 0); + NewMenuHelpers_DrawDialogueFrame(0, 0); AddTextPrinterParameterized(0, 1, gText_SavingDontTurnOffPower, 0, NULL, 2, 1, 3); CopyWindowToVram(0, 3); gTasks[taskId].func = Task_Hof_TrySaveData; @@ -746,7 +746,7 @@ static void Task_Hof_WaitAndPrintPlayerInfo(u8 taskId) { FillBgTilemapBufferRect_Palette0(0, 0, 0, 0, 0x20, 0x20); HallOfFame_PrintPlayerInfo(1, 2); - sub_81973C4(0, 0); + NewMenuHelpers_DrawDialogueFrame(0, 0); AddTextPrinterParameterized(0, 1, gText_LeagueChamp, 0, NULL, 2, 1, 3); CopyWindowToVram(0, 3); gTasks[taskId].func = Task_Hof_ExitOnKeyPressed; @@ -1115,7 +1115,7 @@ static void Task_HofPC_HandleExit(u8 taskId) static void Task_HofPC_PrintDataIsCorrupted(u8 taskId) { sub_8198180(gText_UnkCtrlF800Exit, 8, 1); - sub_81973C4(0, 0); + NewMenuHelpers_DrawDialogueFrame(0, 0); AddTextPrinterParameterized(0, 1, gText_HOFCorrupted, 0, NULL, 2, 1, 3); CopyWindowToVram(0, 3); gTasks[taskId].func = Task_HofPC_ExitOnButtonPress; diff --git a/src/naming_screen.c b/src/naming_screen.c index 7139b5c90..9a5cec1e0 100644 --- a/src/naming_screen.c +++ b/src/naming_screen.c @@ -530,7 +530,7 @@ static void DisplaySentToPCMessage(void) stringToDisplay++; StringExpandPlaceholders(gStringVar4, gUnknown_0858BDB8[stringToDisplay]); - sub_81973C4(0, 0); + NewMenuHelpers_DrawDialogueFrame(0, 0); gTextFlags.flag_0 = TRUE; AddTextPrinterParameterized(0, 1, gStringVar4, GetPlayerTextSpeed(), 0, 2, 1, 3); CopyWindowToVram(0, 3); diff --git a/src/new_menu_helpers.c b/src/new_menu_helpers.c new file mode 100644 index 000000000..baa053a22 --- /dev/null +++ b/src/new_menu_helpers.c @@ -0,0 +1,442 @@ +#include "global.h" +#include "bg.h" +#include "palette.h" +#include "window.h" +#include "text.h" +#include "new_menu_helpers.h" +#include "text_window.h" +#include "menu.h" +#include "menu_helpers.h" + +#define STD_WINDOW_PALETTE_NUM 14 +#define STD_WINDOW_BASE_TILE_NUM 0x214 +#define DLG_WINDOW_PALETTE_NUM 15 +#define DLG_WINDOW_BASE_TILE_NUM 0x200 + +extern EWRAM_DATA u8 gUnknown_0203CD8C; +extern EWRAM_DATA u8 gUnknown_0203CD8D; + +extern const u8 gUnknown_0860EA6C[]; +extern const u16 gUnknown_0860EA4C[]; +extern const u16 gUnknown_0860F074[]; +extern const u8 gUnknown_0860F094[]; +extern const struct WindowTemplate gUnknown_0860F098[]; +extern const struct WindowTemplate gUnknown_0860F0A8; + +extern void sub_819645C(void); +// Forward declarations +extern void sub_81973A4(void); +extern void DrawStandardFrame(u8, u8, u8, u8, u8, u8); +extern void DrawDialogueFrame(u8, u8, u8, u8, u8, u8); +extern void sub_81977BC(u8, u8, u8, u8, u8, u8); +extern void sub_8197804(u8, u8, u8, u8, u8, u8); + +void sub_8197184(u8 window, u32 destTile, u32 destPalette) +{ + LoadBgTiles(GetWindowAttribute(window, WINDOW_PRIORITY), gUnknown_0860EA6C, 0x100, destTile); + LoadPalette(gUnknown_0860EA4C, destPalette * 16, 32); +} + +void sub_81971C4(void) +{ + sub_819645C(); +} + +void sub_81971D0(void) +{ + InitWindows(gUnknown_0860F098); + gUnknown_0203CD8C = 0xFF; + gUnknown_0203CD8D = 0xFF; +} + +void sub_81971F4(void) +{ + FreeAllWindowBuffers(); +} + +void sub_8197200(void) +{ + ChangeBgX(0, 0, 0); + ChangeBgY(0, 0, 0); + DeactivateAllTextPrinters(); + sub_81973A4(); +} + +u16 sub_8197224(void) +{ + RunTextPrinters(); + return IsTextPrinterActive(0); +} + +u16 AddTextPrinterParameterized(u8 windowId, u8 fontId, const u8 *str, u8 speed, void (*callback)(struct TextSubPrinter *, u16), u8 fgColor, u8 bgColor, u8 shadowColor) +{ + struct TextSubPrinter printer; + + printer.current_text_offset = str; + printer.windowId = windowId; + printer.fontId = fontId; + printer.x = 0; + printer.y = 1; + printer.currentX = 0; + printer.currentY = 1; + printer.letterSpacing = 0; + printer.lineSpacing = 0; + printer.fontColor_l = 0; + printer.fgColor = fgColor; + printer.bgColor = bgColor; + printer.shadowColor = shadowColor; + + gTextFlags.flag_1 = 0; + return AddTextPrinter(&printer, speed, callback); +} + +void AddTextPrinterForMessage(bool8 allowSkippingDelayWithButtonPress) +{ + void (*callback)(struct TextSubPrinter *, u16) = NULL; + gTextFlags.flag_0 = allowSkippingDelayWithButtonPress; + AddTextPrinterParameterized(0, 1, gStringVar4, GetPlayerTextSpeed(), callback, 2, 1, 3); +} + +void AddTextPrinterForMessage_2(bool8 allowSkippingDelayWithButtonPress) +{ + gTextFlags.flag_0 = allowSkippingDelayWithButtonPress; + AddTextPrinterParameterized(0, 1, gStringVar4, GetPlayerTextSpeed(), NULL, 2, 1, 3); +} + +void AddTextPrinterWithCustomSpeedForMessage(bool8 allowSkippingDelayWithButtonPress, u8 speed) +{ + gTextFlags.flag_0 = allowSkippingDelayWithButtonPress; + AddTextPrinterParameterized(0, 1, gStringVar4, speed, NULL, 2, 1, 3); +} + +void sub_81973A4(void) +{ + copy_textbox_border_tile_patterns_to_vram(0, DLG_WINDOW_BASE_TILE_NUM, 0xF0); + sub_809882C(0, STD_WINDOW_BASE_TILE_NUM, 0xE0); +} + +void NewMenuHelpers_DrawDialogueFrame(u8 windowId, bool8 copyToVram) +{ + CallWindowFunction(windowId, DrawDialogueFrame); + FillWindowPixelBuffer(windowId, 0x11); + PutWindowTilemap(windowId); + if (copyToVram == TRUE) + CopyWindowToVram(windowId, 3); +} + +void NewMenuHelpers_DrawStdWindowFrame(u8 windowId, bool8 copyToVram) +{ + CallWindowFunction(windowId, DrawStandardFrame); + FillWindowPixelBuffer(windowId, 0x11); + PutWindowTilemap(windowId); + if (copyToVram == TRUE) + CopyWindowToVram(windowId, 3); +} + +void sub_8197434(u8 windowId, bool8 copyToVram) +{ + CallWindowFunction(windowId, sub_8197804); + FillWindowPixelBuffer(windowId, 0x11); + ClearWindowTilemap(windowId); + if (copyToVram == TRUE) + CopyWindowToVram(windowId, 3); +} + +void sub_819746C(u8 windowId, bool8 copyToVram) +{ + CallWindowFunction(windowId, sub_81977BC); + FillWindowPixelBuffer(windowId, 0x11); + ClearWindowTilemap(windowId); + if (copyToVram == TRUE) + CopyWindowToVram(windowId, 3); +} + +void DrawStandardFrame(u8 bg, u8 tilemapLeft, u8 tilemapTop, u8 width, u8 height, u8 paletteNum) +{ + int i; + + FillBgTilemapBufferRect(bg, + STD_WINDOW_BASE_TILE_NUM + 0, + tilemapLeft - 1, + tilemapTop - 1, + 1, + 1, + STD_WINDOW_PALETTE_NUM); + FillBgTilemapBufferRect(bg, + STD_WINDOW_BASE_TILE_NUM + 1, + tilemapLeft, + tilemapTop - 1, + width, + 1, + STD_WINDOW_PALETTE_NUM); + FillBgTilemapBufferRect(bg, + STD_WINDOW_BASE_TILE_NUM + 2, + tilemapLeft + width, + tilemapTop - 1, + 1, + 1, + STD_WINDOW_PALETTE_NUM); + + for (i = tilemapTop; i < tilemapTop + height; i++) + { + FillBgTilemapBufferRect(bg, + STD_WINDOW_BASE_TILE_NUM + 3, + tilemapLeft - 1, + i, + 1, + 1, + STD_WINDOW_PALETTE_NUM); + FillBgTilemapBufferRect(bg, + STD_WINDOW_BASE_TILE_NUM + 5, + tilemapLeft + width, + i, + 1, + 1, + STD_WINDOW_PALETTE_NUM); + } + + FillBgTilemapBufferRect(bg, + STD_WINDOW_BASE_TILE_NUM + 6, + tilemapLeft - 1, + tilemapTop + height, + 1, + 1, + STD_WINDOW_PALETTE_NUM); + FillBgTilemapBufferRect(bg, + STD_WINDOW_BASE_TILE_NUM + 7, + tilemapLeft, + tilemapTop + height, + width, + 1, + STD_WINDOW_PALETTE_NUM); + FillBgTilemapBufferRect(bg, + STD_WINDOW_BASE_TILE_NUM + 8, + tilemapLeft + width, + tilemapTop + height, + 1, + 1, + STD_WINDOW_PALETTE_NUM); +} + +void DrawDialogueFrame(u8 bg, u8 tilemapLeft, u8 tilemapTop, u8 width, u8 height, u8 paletteNum) +{ + FillBgTilemapBufferRect(bg, + DLG_WINDOW_BASE_TILE_NUM + 1, + tilemapLeft - 2, + tilemapTop - 1, + 1, + 1, + DLG_WINDOW_PALETTE_NUM); + FillBgTilemapBufferRect(bg, + DLG_WINDOW_BASE_TILE_NUM + 3, + tilemapLeft - 1, + tilemapTop - 1, + 1, + 1, + DLG_WINDOW_PALETTE_NUM); + FillBgTilemapBufferRect(bg, + DLG_WINDOW_BASE_TILE_NUM + 4, + tilemapLeft, + tilemapTop - 1, + width - 1, + 1, + DLG_WINDOW_PALETTE_NUM); + FillBgTilemapBufferRect(bg, + DLG_WINDOW_BASE_TILE_NUM + 5, + tilemapLeft + width - 1, + tilemapTop - 1, + 1, + 1, + DLG_WINDOW_PALETTE_NUM); + FillBgTilemapBufferRect(bg, + DLG_WINDOW_BASE_TILE_NUM + 6, + tilemapLeft + width, + tilemapTop - 1, + 1, + 1, + DLG_WINDOW_PALETTE_NUM); + FillBgTilemapBufferRect(bg, + DLG_WINDOW_BASE_TILE_NUM + 7, + tilemapLeft - 2, + tilemapTop, + 1, + 5, + DLG_WINDOW_PALETTE_NUM); + FillBgTilemapBufferRect(bg, + DLG_WINDOW_BASE_TILE_NUM + 9, + tilemapLeft - 1, + tilemapTop, + width + 1, + 5, + DLG_WINDOW_PALETTE_NUM); + FillBgTilemapBufferRect(bg, + DLG_WINDOW_BASE_TILE_NUM + 10, + tilemapLeft + width, + tilemapTop, + 1, + 5, + DLG_WINDOW_PALETTE_NUM); + FillBgTilemapBufferRect(bg, + BG_TILE_V_FLIP(DLG_WINDOW_BASE_TILE_NUM + 1), + tilemapLeft - 2, + tilemapTop + height, + 1, + 1, + DLG_WINDOW_PALETTE_NUM); + FillBgTilemapBufferRect(bg, + BG_TILE_V_FLIP(DLG_WINDOW_BASE_TILE_NUM + 3), + tilemapLeft - 1, + tilemapTop + height, + 1, + 1, + DLG_WINDOW_PALETTE_NUM); + FillBgTilemapBufferRect(bg, + BG_TILE_V_FLIP(DLG_WINDOW_BASE_TILE_NUM + 4), + tilemapLeft, + tilemapTop + height, + width - 1, + 1, + DLG_WINDOW_PALETTE_NUM); + FillBgTilemapBufferRect(bg, + BG_TILE_V_FLIP(DLG_WINDOW_BASE_TILE_NUM + 5), + tilemapLeft + width - 1, + tilemapTop + height, + 1, + 1, + DLG_WINDOW_PALETTE_NUM); + FillBgTilemapBufferRect(bg, + BG_TILE_V_FLIP(DLG_WINDOW_BASE_TILE_NUM + 6), + tilemapLeft + width, + tilemapTop + height, + 1, + 1, + DLG_WINDOW_PALETTE_NUM); +} + +void sub_81977BC(u8 bg, u8 tilemapLeft, u8 tilemapTop, u8 width, u8 height, u8 paletteNum) +{ + FillBgTilemapBufferRect(bg, 0, tilemapLeft - 1, tilemapTop - 1, width + 2, height + 2, STD_WINDOW_PALETTE_NUM); +} + +void sub_8197804(u8 bg, u8 tilemapLeft, u8 tilemapTop, u8 width, u8 height, u8 paletteNum) +{ + FillBgTilemapBufferRect(bg, 0, tilemapLeft - 3, tilemapTop - 1, width + 6, height + 2, STD_WINDOW_PALETTE_NUM); +} + +void SetStandardWindowBorderStyle(u8 windowId, bool8 copyToVram) +{ + SetWindowBorderStyle(windowId, copyToVram, STD_WINDOW_BASE_TILE_NUM, STD_WINDOW_PALETTE_NUM); +} + +void sub_819786C(u8 windowId, bool8 copyToVram) +{ + copy_textbox_border_tile_patterns_to_vram(windowId, DLG_WINDOW_BASE_TILE_NUM, 0xF0); + sub_8197B1C(windowId, copyToVram, DLG_WINDOW_BASE_TILE_NUM, 0xF); +} + +void sub_819789C(void) +{ + LoadPalette(gUnknown_0860F074, 0xE0, 0x14); +} + +void sub_81978B0(u16 offset) +{ + LoadPalette(gUnknown_0860F074, offset, 0x14); +} + +const u16 *sub_81978C8(void) +{ + return gUnknown_0860F074; +} + +u16 sub_81978D0(u8 colorNum) +{ + if (colorNum > 15) + colorNum = 0; + return gUnknown_0860F074[colorNum]; +} + +void DisplayItemMessageOnField(u8 taskId, const u8 *string, TaskFunc callback) +{ + sub_81973A4(); + DisplayMessageAndContinueTask(taskId, 0, DLG_WINDOW_BASE_TILE_NUM, DLG_WINDOW_PALETTE_NUM, 1, GetPlayerTextSpeed(), string, callback); + CopyWindowToVram(0, 3); +} + +void sub_8197930(void) +{ + CreateYesNoMenu(&gUnknown_0860F0A8, STD_WINDOW_BASE_TILE_NUM, STD_WINDOW_PALETTE_NUM, 0); +} + +void sub_8197948(u8 initialCursorPos) +{ + CreateYesNoMenu(&gUnknown_0860F0A8, STD_WINDOW_BASE_TILE_NUM, STD_WINDOW_PALETTE_NUM, initialCursorPos); +} + +u32 sub_8197964(void) +{ + if (gTextFlags.flag_3) + return 1; + return gSaveBlock2Ptr->optionsTextSpeed; +} + +u8 GetPlayerTextSpeed(void) +{ + u32 speed; + if (gSaveBlock2Ptr->optionsTextSpeed > 2) + gSaveBlock2Ptr->optionsTextSpeed = 1; + speed = sub_8197964(); + return gUnknown_0860F094[speed]; +} + +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; +} + +u8 GetStartMenuWindowId(void) +{ + return gUnknown_0203CD8C; +} + +void remove_start_menu_window_maybe(void) +{ + if (gUnknown_0203CD8C != 0xFF) + { + RemoveWindow(gUnknown_0203CD8C); + gUnknown_0203CD8C = 0xFF; + } +} + +u16 sub_8197A30(void) +{ + return DLG_WINDOW_BASE_TILE_NUM; +} + +u16 sub_8197A38(void) +{ + return STD_WINDOW_BASE_TILE_NUM; +} + +u8 AddMapNamePopUpWindow(void) +{ + if (gUnknown_0203CD8D == 0xFF) + gUnknown_0203CD8D = sub_8198AA4(0, 1, 1, 10, 3, 14, 0x107); + return gUnknown_0203CD8D; +} + +u8 GetMapNamePopUpWindowId(void) +{ + return gUnknown_0203CD8D; +} + +void RemoveMapNamePopUpWindow(void) +{ + if (gUnknown_0203CD8D != 0xFF) + { + RemoveWindow(gUnknown_0203CD8D); + gUnknown_0203CD8D = 0xFF; + } +} diff --git a/src/scrcmd.c b/src/scrcmd.c index 0557cd95e..5a4cc4591 100644 --- a/src/scrcmd.c +++ b/src/scrcmd.c @@ -1313,7 +1313,7 @@ bool8 ScrCmd_cmdDB(struct ScriptContext *ctx) if (msg == NULL) msg = (const u8 *)ctx->data[0]; sub_81973A4(); - sub_81973C4(0, 1); + NewMenuHelpers_DrawDialogueFrame(0, 1); PrintTextOnWindow(0, 1, msg, 0, 1, 0, 0); return FALSE; } @@ -1530,7 +1530,7 @@ bool8 ScrCmd_braillemessage(struct ScriptContext *ctx) template2 = template1; gUnknown_03000F30 = AddWindow(&template2); sub_809882C(gUnknown_03000F30, 0x214, 0xE0); - sub_81973FC(gUnknown_03000F30, 0); + NewMenuHelpers_DrawStdWindowFrame(gUnknown_03000F30, 0); PutWindowTilemap(gUnknown_03000F30); FillWindowPixelBuffer(gUnknown_03000F30, 0x11); PrintTextOnWindow(gUnknown_03000F30, 6, gStringVar4, temp1, temp2, 0xFF, 0x0); @@ -1651,7 +1651,7 @@ _0809AEC6:\n\ bl sub_809882C\n\ ldrb r0, [r5]\n\ mov r1, #0\n\ - bl sub_81973FC\n\ + bl NewMenuHelpers_DrawStdWindowFrame\n\ ldrb r0, [r5]\n\ bl PutWindowTilemap\n\ ldrb r0, [r5]\n\ diff --git a/src/start_menu.c b/src/start_menu.c index a820cd992..36d249078 100644 --- a/src/start_menu.c +++ b/src/start_menu.c @@ -32,7 +32,7 @@ extern bool32 InUnionRoom(void); extern bool8 InBattlePike(void); extern bool8 InBattlePyramid(void); extern bool8 InMultiBattleRoom(void); -extern void sub_81973FC(u8 windowId, u8 a1); +extern void NewMenuHelpers_DrawStdWindowFrame(u8 windowId, u8 a1); extern void sub_8198070(u8 windowId, u8 a1); // this file's functions @@ -224,7 +224,7 @@ void DisplaySafariBallsWindow(void) { sSafariBallsWindowId = AddWindow(&gSafariBallsWindowTemplate); PutWindowTilemap(sSafariBallsWindowId); - sub_81973FC(sSafariBallsWindowId, 0); + NewMenuHelpers_DrawStdWindowFrame(sSafariBallsWindowId, 0); ConvertIntToDecimalStringN(gStringVar1, gNumSafariBalls, STR_CONV_MODE_RIGHT_ALIGN, 2); StringExpandPlaceholders(gStringVar4, gText_SafariBallStock); PrintTextOnWindow(sSafariBallsWindowId, 1, gStringVar4, 0, 1, 0xFF, NULL); @@ -239,7 +239,7 @@ void DisplayPyramidFloorWindow(void) else sBattlePyramidFloorWindowId = AddWindow(&gPyramidFloorWindowTemplate_2); PutWindowTilemap(sBattlePyramidFloorWindowId); - sub_81973FC(sBattlePyramidFloorWindowId, 0); + NewMenuHelpers_DrawStdWindowFrame(sBattlePyramidFloorWindowId, 0); StringCopy(gStringVar1, sPyramindFloorNames[gSaveBlock2Ptr->field_CAA[4]]); StringExpandPlaceholders(gStringVar4, gText_BattlePyramidFloor); PrintTextOnWindow(sBattlePyramidFloorWindowId, 1, gStringVar4, 0, 1, 0xFF, NULL); diff --git a/src/text.c b/src/text.c index 5db3ba308..50e39ab0c 100644 --- a/src/text.c +++ b/src/text.c @@ -159,7 +159,7 @@ u16 PrintTextOnWindow(u8 windowId, u8 fontId, const u8 *str, u8 x, u8 y, u8 spee subPrinter.letterSpacing = gFonts[fontId].letterSpacing; subPrinter.lineSpacing = gFonts[fontId].lineSpacing; subPrinter.fontColor_l = gFonts[fontId].fontColor_l; - subPrinter.fontColor_h = gFonts[fontId].fontColor_h; + subPrinter.fgColor = gFonts[fontId].fgColor; subPrinter.bgColor = gFonts[fontId].bgColor; subPrinter.shadowColor = gFonts[fontId].shadowColor; return AddTextPrinter(&subPrinter, speed, callback); @@ -189,7 +189,7 @@ bool16 AddTextPrinter(struct TextSubPrinter *textSubPrinter, u8 speed, void (*ca gTempTextPrinter.minLetterSpacing = 0; gTempTextPrinter.japanese = 0; - GenerateFontHalfRowLookupTable(textSubPrinter->fontColor_h, textSubPrinter->bgColor, textSubPrinter->shadowColor); + GenerateFontHalfRowLookupTable(textSubPrinter->fgColor, textSubPrinter->bgColor, textSubPrinter->shadowColor); if (speed != TEXT_SPEED_FF && speed != 0x0) { --gTempTextPrinter.text_speed; @@ -3218,7 +3218,7 @@ u8 GetFontAttribute(u8 fontId, u8 attributeId) result = gFontInfos[fontId].fontColor_l; break; case 5: - result = gFontInfos[fontId].fontColor_h; + result = gFontInfos[fontId].fgColor; break; case 6: result = gFontInfos[fontId].bgColor; diff --git a/src/unk_text_util_2.c b/src/unk_text_util_2.c index 8eaab32b6..ca8246128 100644 --- a/src/unk_text_util_2.c +++ b/src/unk_text_util_2.c @@ -57,24 +57,24 @@ u16 Font6Func(struct TextPrinter *textPrinter) switch (char_) { case 1: - textPrinter->subPrinter.fontColor_h = *textPrinter->subPrinter.current_text_offset ++; - GenerateFontHalfRowLookupTable(textPrinter->subPrinter.fontColor_h, textPrinter->subPrinter.bgColor, textPrinter->subPrinter.shadowColor); + textPrinter->subPrinter.fgColor = *textPrinter->subPrinter.current_text_offset ++; + GenerateFontHalfRowLookupTable(textPrinter->subPrinter.fgColor, textPrinter->subPrinter.bgColor, textPrinter->subPrinter.shadowColor); return 2; case 2: textPrinter->subPrinter.bgColor = *textPrinter->subPrinter.current_text_offset ++; - GenerateFontHalfRowLookupTable(textPrinter->subPrinter.fontColor_h, textPrinter->subPrinter.bgColor, textPrinter->subPrinter.shadowColor); + GenerateFontHalfRowLookupTable(textPrinter->subPrinter.fgColor, textPrinter->subPrinter.bgColor, textPrinter->subPrinter.shadowColor); return 2; case 3: textPrinter->subPrinter.shadowColor = *textPrinter->subPrinter.current_text_offset ++; - GenerateFontHalfRowLookupTable(textPrinter->subPrinter.fontColor_h, textPrinter->subPrinter.bgColor, textPrinter->subPrinter.shadowColor); + GenerateFontHalfRowLookupTable(textPrinter->subPrinter.fgColor, textPrinter->subPrinter.bgColor, textPrinter->subPrinter.shadowColor); return 2; case 4: - textPrinter->subPrinter.fontColor_h = *textPrinter->subPrinter.current_text_offset; + textPrinter->subPrinter.fgColor = *textPrinter->subPrinter.current_text_offset; textPrinter->subPrinter.bgColor = *++ textPrinter->subPrinter.current_text_offset; textPrinter->subPrinter.shadowColor = *++ textPrinter->subPrinter.current_text_offset; textPrinter->subPrinter.current_text_offset ++; - GenerateFontHalfRowLookupTable(textPrinter->subPrinter.fontColor_h, textPrinter->subPrinter.bgColor, textPrinter->subPrinter.shadowColor); + GenerateFontHalfRowLookupTable(textPrinter->subPrinter.fgColor, textPrinter->subPrinter.bgColor, textPrinter->subPrinter.shadowColor); return 2; case 5: textPrinter->subPrinter.current_text_offset ++; -- cgit v1.2.3 From 2da7bdbb1175802e55103c4f9df95e035aa38c40 Mon Sep 17 00:00:00 2001 From: Diegoisawesome Date: Fri, 26 Jan 2018 23:41:52 -0600 Subject: Begin menu.s decomp --- src/menu.c | 849 +++++++++++++++++++++++++++++++++++++++++++++++++ src/new_menu_helpers.c | 35 +- 2 files changed, 864 insertions(+), 20 deletions(-) create mode 100644 src/menu.c (limited to 'src') diff --git a/src/menu.c b/src/menu.c new file mode 100644 index 000000000..9ff8d47b6 --- /dev/null +++ b/src/menu.c @@ -0,0 +1,849 @@ +#include "global.h" +#include "new_menu_helpers.h" +#include "bg.h" +#include "window.h" +#include "palette.h" +#include "menu.h" +#include "constants/songs.h" +#include "main.h" +#include "sound.h" + +struct SomeUnkStruct +{ + u8 unk1; + u8 unk2; + u16 unk3; +}; + +struct Menu +{ + u8 left; + u8 top; + s8 cursorPos; + s8 minCursorPos; + s8 maxCursorPos; + u8 windowId; + u8 fontId; + u8 menu_field_7; + u8 cursorHeight; + u8 menu_field_9; + u8 menu_field_A; + u8 menu_field_B; +}; + +extern EWRAM_DATA struct Menu gUnknown_0203CD90; +extern EWRAM_DATA u16 gUnknown_0203CD9C; +extern EWRAM_DATA u8 gUnknown_0203CD9E; +extern EWRAM_DATA u8 gUnknown_0203CD9F; +extern EWRAM_DATA u8 gUnknown_0203CDA0; + +const u16 gUnknown_0860F0B0[] = INCBIN_U16("graphics/interface/860F0B0.gbapal"); +const u8 gUnknown_0860F0D0[] = { 15, 1, 2 }; +const struct SomeUnkStruct 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 }, +}; + +extern const u8 gText_SelectorArrow3[]; +extern const u8 gText_YesNo[]; + +extern void sub_8197BB4(u8, u8, u8, u8, u8, u8); +extern void sub_8197E30(u8, u8, u8, u8, u8, u8); +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, u8, const u8 *str, u8 x, u8 y, u8 speed, void (*callback)(struct TextSubPrinter *, u16), u8, u8); +extern void sub_8198C78(void); + +void AddTextPrinterWithCallbackForMessage(bool8 a1, void (*callback)(struct TextSubPrinter *, u16)) +{ + gTextFlags.flag_0 = a1; + AddTextPrinterParameterized(0, 1, gStringVar4, GetPlayerTextSpeed(), callback, 2, 1, 3); +} + +void sub_8197AE8(bool8 copyToVram) +{ + FillBgTilemapBufferRect(0, 0, 0, 0, 32, 32, 0x11); + if (copyToVram == TRUE) + CopyBgTilemapBufferToVram(0); +} + +void sub_8197B1C(u8 windowId, bool8 copyToVram, u16 a3, u8 a4) +{ + gUnknown_0203CD9C = a3; + gUnknown_0203CD9E = a4; + CallWindowFunction(windowId, sub_8197BB4); + FillWindowPixelBuffer(windowId, 0x11); + PutWindowTilemap(windowId); + if (copyToVram == TRUE) + CopyWindowToVram(windowId, 3); +} + +void sub_8197B64(u8 windowId, bool8 copyToVram, u16 a3) +{ + gUnknown_0203CD9C = a3; + gUnknown_0203CD9E = GetWindowAttribute(windowId, WINDOW_PALETTE_NUM); + CallWindowFunction(windowId, sub_8197BB4); + FillWindowPixelBuffer(windowId, 0x11); + PutWindowTilemap(windowId); + if (copyToVram == TRUE) + CopyWindowToVram(windowId, 3); +} + +void sub_8197BB4(u8 bg, u8 tilemapLeft, u8 tilemapTop, u8 width, u8 height, u8 paletteNum) +{ + FillBgTilemapBufferRect(bg, + gUnknown_0203CD9C + 1, + tilemapLeft - 2, + tilemapTop - 1, + 1, + 1, + gUnknown_0203CD9E); + FillBgTilemapBufferRect(bg, + gUnknown_0203CD9C + 3, + tilemapLeft - 1, + tilemapTop - 1, + 1, + 1, + gUnknown_0203CD9E); + FillBgTilemapBufferRect(bg, + gUnknown_0203CD9C + 4, + tilemapLeft, + tilemapTop - 1, + width - 1, + 1, + gUnknown_0203CD9E); + FillBgTilemapBufferRect(bg, + gUnknown_0203CD9C + 5, + tilemapLeft + width - 1, + tilemapTop - 1, + 1, + 1, + gUnknown_0203CD9E); + FillBgTilemapBufferRect(bg, + gUnknown_0203CD9C + 6, + tilemapLeft + width, + tilemapTop - 1, + 1, + 1, + gUnknown_0203CD9E); + FillBgTilemapBufferRect(bg, + gUnknown_0203CD9C + 7, + tilemapLeft - 2, + tilemapTop, + 1, + 5, + gUnknown_0203CD9E); + FillBgTilemapBufferRect(bg, + gUnknown_0203CD9C + 9, + tilemapLeft - 1, + tilemapTop, + width + 1, + 5, + gUnknown_0203CD9E); + FillBgTilemapBufferRect(bg, + gUnknown_0203CD9C + 10, + tilemapLeft + width, + tilemapTop, + 1, + 5, + gUnknown_0203CD9E); + FillBgTilemapBufferRect(bg, + BG_TILE_V_FLIP(gUnknown_0203CD9C + 1), + tilemapLeft - 2, + tilemapTop + height, + 1, + 1, + gUnknown_0203CD9E); + FillBgTilemapBufferRect(bg, + BG_TILE_V_FLIP(gUnknown_0203CD9C + 3), + tilemapLeft - 1, + tilemapTop + height, + 1, + 1, + gUnknown_0203CD9E); + FillBgTilemapBufferRect(bg, + BG_TILE_V_FLIP(gUnknown_0203CD9C + 4), + tilemapLeft, + tilemapTop + height, + width - 1, + 1, + gUnknown_0203CD9E); + FillBgTilemapBufferRect(bg, + BG_TILE_V_FLIP(gUnknown_0203CD9C + 5), + tilemapLeft + width - 1, + tilemapTop + height, + 1, + 1, + gUnknown_0203CD9E); + FillBgTilemapBufferRect(bg, + BG_TILE_V_FLIP(gUnknown_0203CD9C + 6), + tilemapLeft + width, + tilemapTop + height, + 1, + 1, + gUnknown_0203CD9E); +} + +void sub_8197DF8(u8 windowId, bool8 copyToVram) +{ + CallWindowFunction(windowId, sub_8197E30); + FillWindowPixelBuffer(windowId, 0); + ClearWindowTilemap(windowId); + if (copyToVram == TRUE) + CopyWindowToVram(windowId, 3); +} + +void sub_8197E30(u8 bg, u8 tilemapLeft, u8 tilemapTop, u8 width, u8 height, u8 paletteNum) +{ + FillBgTilemapBufferRect(bg, 0, tilemapLeft - 3, tilemapTop - 1, width + 6, height + 2, 0); +} + +void SetWindowBorderStyle(u8 windowId, bool8 copyToVram, u16 baseTileNum, u8 paletteNum) +{ + gUnknown_0203CD9C = baseTileNum; + gUnknown_0203CD9E = paletteNum; + CallWindowFunction(windowId, DrawWindowBorder); + FillWindowPixelBuffer(windowId, 0x11); + PutWindowTilemap(windowId); + if (copyToVram == TRUE) + CopyWindowToVram(windowId, 3); +} + +void sub_8197EC8(u8 windowId, bool8 copyToVram, u16 baseTileNum) +{ + gUnknown_0203CD9C = baseTileNum; + gUnknown_0203CD9E = GetWindowAttribute(windowId, WINDOW_PALETTE_NUM); + CallWindowFunction(windowId, DrawWindowBorder); + FillWindowPixelBuffer(windowId, 0x11); + PutWindowTilemap(windowId); + if (copyToVram == TRUE) + CopyWindowToVram(windowId, 3); +} + +void DrawWindowBorder(u8 bg, u8 tilemapLeft, u8 tilemapTop, u8 width, u8 height, u8 paletteNum) +{ + FillBgTilemapBufferRect(bg, + gUnknown_0203CD9C + 0, + tilemapLeft - 1, + tilemapTop - 1, + 1, + 1, + gUnknown_0203CD9E); + FillBgTilemapBufferRect(bg, + gUnknown_0203CD9C + 1, + tilemapLeft, + tilemapTop - 1, + width, + 1, + gUnknown_0203CD9E); + FillBgTilemapBufferRect(bg, + gUnknown_0203CD9C + 2, + tilemapLeft + width, + tilemapTop - 1, + 1, + 1, + gUnknown_0203CD9E); + FillBgTilemapBufferRect(bg, + gUnknown_0203CD9C + 3, + tilemapLeft - 1, + tilemapTop, + 1, + height, + gUnknown_0203CD9E); + FillBgTilemapBufferRect(bg, + gUnknown_0203CD9C + 5, + tilemapLeft + width, + tilemapTop, + 1, + height, + gUnknown_0203CD9E); + FillBgTilemapBufferRect(bg, + gUnknown_0203CD9C + 6, + tilemapLeft - 1, + tilemapTop + height, + 1, + 1, + gUnknown_0203CD9E); + FillBgTilemapBufferRect(bg, + gUnknown_0203CD9C + 7, + tilemapLeft, + tilemapTop + height, + width, + 1, + gUnknown_0203CD9E); + FillBgTilemapBufferRect(bg, + gUnknown_0203CD9C + 8, + tilemapLeft + width, + tilemapTop + height, + 1, + 1, + gUnknown_0203CD9E); +} + +void sub_8198070(u8 windowId, bool8 copyToVram) +{ + CallWindowFunction(windowId, sub_81980A8); + FillWindowPixelBuffer(windowId, 0); + ClearWindowTilemap(windowId); + if (copyToVram == TRUE) + CopyWindowToVram(windowId, 3); +} + +void sub_81980A8(u8 bg, u8 tilemapLeft, u8 tilemapTop, u8 width, u8 height, u8 paletteNum) +{ + FillBgTilemapBufferRect(bg, 0, tilemapLeft - 1, tilemapTop - 1, width + 2, height + 2, 0); +} + +u8 sub_81980F0(u8 bg, u8 xPos, u8 yPos, u8 palette, u16 baseTile) +{ + struct WindowTemplate window; + memset(&window, 0, sizeof(window)); + + if (bg > 3) + window.priority = 0; + else + window.priority = bg; + + window.tilemapTop = yPos; + window.height = 2; + window.tilemapLeft = 0x1E - xPos; + window.width = xPos; + window.paletteNum = palette; + window.baseBlock = baseTile; + + gUnknown_0203CDA0 = AddWindow(&window); + + if (palette > 15) + palette = 15 * 16; + else + palette *= 16; + + LoadPalette(gUnknown_0860F0B0, palette, sizeof(gUnknown_0860F0B0)); + return gUnknown_0203CDA0; +} + +void sub_8198180(const u8 *string, u8 a2, bool8 copyToVram) +{ + u16 width = 0; + + if (gUnknown_0203CDA0 != 0xFF) + { + PutWindowTilemap(gUnknown_0203CDA0); + FillWindowPixelBuffer(gUnknown_0203CDA0, 0xFF); + width = GetStringWidth(0, string, 0); + box_print(gUnknown_0203CDA0, + 0, + 0xEC - (GetWindowAttribute(gUnknown_0203CDA0, WINDOW_TILEMAP_LEFT) * 8) - a2 - width, + 1, + gUnknown_0860F0D0, + 0, + string); + if (copyToVram) + CopyWindowToVram(gUnknown_0203CDA0, 3); + } +} + +void sub_8198204(const u8 *string, const u8 *string2, u8 a3, u8 a4, bool8 copyToVram) +{ + struct TextColor color; + u16 width = 0; + + if (gUnknown_0203CDA0 != 0xFF) + { + if (a3 != 0) + { + color.fgColor = 0; + color.bgColor = 1; + color.shadowColor = 2; + } + else + { + color.fgColor = 15; + color.bgColor = 1; + color.shadowColor = 2; + } + PutWindowTilemap(gUnknown_0203CDA0); + FillWindowPixelBuffer(gUnknown_0203CDA0, 0xFF); + if (string2 != NULL) + { + width = GetStringWidth(0, string2, 0); + box_print(gUnknown_0203CDA0, + 0, + 0xEC - (GetWindowAttribute(gUnknown_0203CDA0, WINDOW_TILEMAP_LEFT) * 8) - a4 - width, + 1, + &color, + 0, + string2); + } + AddTextPrinterParameterized2(gUnknown_0203CDA0, 1, 4, 1, 0, 0, &color, 0, string); + if (copyToVram) + CopyWindowToVram(gUnknown_0203CDA0, 3); + } +} + +void sub_81982D8(void) +{ + if (gUnknown_0203CDA0 != 0xFF) + CopyWindowToVram(gUnknown_0203CDA0, 3); +} + +void sub_81982F0(void) +{ + if (gUnknown_0203CDA0 != 0xFF) + { + FillWindowPixelBuffer(gUnknown_0203CDA0, 0xFF); + CopyWindowToVram(gUnknown_0203CDA0, 3); + } +} + +void sub_8198314(void) +{ + if (gUnknown_0203CDA0 != 0xFF) + { + FillWindowPixelBuffer(gUnknown_0203CDA0, 0); + ClearWindowTilemap(gUnknown_0203CDA0); + CopyWindowToVram(gUnknown_0203CDA0, 3); + RemoveWindow(gUnknown_0203CDA0); + gUnknown_0203CDA0 = 0xFF; + } +} + +u8 sub_8198348(u8 windowId, u8 fontId, u8 left, u8 top, u8 cursorHeight, u8 numChoices, u8 cursorPos, u8 a7) +{ + s32 pos; + + gUnknown_0203CD90.left = left; + gUnknown_0203CD90.top = top; + gUnknown_0203CD90.minCursorPos = 0; + gUnknown_0203CD90.maxCursorPos = numChoices - 1; + gUnknown_0203CD90.windowId = windowId; + gUnknown_0203CD90.fontId = fontId; + gUnknown_0203CD90.cursorHeight = cursorHeight; + gUnknown_0203CD90.menu_field_B = a7; + + pos = cursorPos; + + if (pos < 0 || pos > gUnknown_0203CD90.maxCursorPos) + gUnknown_0203CD90.cursorPos = 0; + else + gUnknown_0203CD90.cursorPos = pos; + + MoveMenuCursor(0); + return gUnknown_0203CD90.cursorPos; +} + +u8 sub_81983AC(u8 windowId, u8 fontId, u8 left, u8 top, u8 cursorHeight, u8 numChoices, u8 cursorPos) +{ + return sub_8198348(windowId, fontId, left, top, cursorHeight, numChoices, cursorPos, 0); +} + +u8 sub_81983EC(u8 windowId, u8 fontId, u8 left, u8 top, u8 numChoices, u8 cursorPos) +{ + return sub_81983AC(windowId, fontId, left, top, GetMenuCursorDimensionByFont(fontId, 1), numChoices, cursorPos); +} + +void RedrawMenuCursor(u8 oldPos, u8 newPos) +{ + u8 width, height; + + width = GetMenuCursorDimensionByFont(gUnknown_0203CD90.fontId, 0); + height = GetMenuCursorDimensionByFont(gUnknown_0203CD90.fontId, 1); + FillWindowPixelRect(gUnknown_0203CD90.windowId, 0x11, gUnknown_0203CD90.left, gUnknown_0203CD90.cursorHeight * oldPos + gUnknown_0203CD90.top, width, height); + PrintTextOnWindow(gUnknown_0203CD90.windowId, gUnknown_0203CD90.fontId, gText_SelectorArrow3, gUnknown_0203CD90.left, gUnknown_0203CD90.cursorHeight * newPos + gUnknown_0203CD90.top, 0, 0); +} + +u8 MoveMenuCursor(s8 cursorDelta) +{ + u8 oldPos = gUnknown_0203CD90.cursorPos; + int newPos = gUnknown_0203CD90.cursorPos + cursorDelta; + + if (newPos < gUnknown_0203CD90.minCursorPos) + gUnknown_0203CD90.cursorPos = gUnknown_0203CD90.maxCursorPos; + else if (newPos > gUnknown_0203CD90.maxCursorPos) + gUnknown_0203CD90.cursorPos = gUnknown_0203CD90.minCursorPos; + else + gUnknown_0203CD90.cursorPos += cursorDelta; + + RedrawMenuCursor(oldPos, gUnknown_0203CD90.cursorPos); + return gUnknown_0203CD90.cursorPos; +} + +u8 MoveMenuCursorNoWrapAround(s8 cursorDelta) +{ + u8 oldPos = gUnknown_0203CD90.cursorPos; + int newPos = gUnknown_0203CD90.cursorPos + cursorDelta; + + if (newPos < gUnknown_0203CD90.minCursorPos) + gUnknown_0203CD90.cursorPos = gUnknown_0203CD90.minCursorPos; + else if (newPos > gUnknown_0203CD90.maxCursorPos) + gUnknown_0203CD90.cursorPos = gUnknown_0203CD90.maxCursorPos; + else + gUnknown_0203CD90.cursorPos += cursorDelta; + + RedrawMenuCursor(oldPos, gUnknown_0203CD90.cursorPos); + return gUnknown_0203CD90.cursorPos; +} + +u8 GetMenuCursorPos(void) +{ + return gUnknown_0203CD90.cursorPos; +} + +s8 ProcessMenuInput(void) +{ + if (gMain.newKeys & A_BUTTON) + { + if (!gUnknown_0203CD90.menu_field_B) + PlaySE(SE_SELECT); + return gUnknown_0203CD90.cursorPos; + } + + if (gMain.newKeys & B_BUTTON) + { + return -1; + } + + if (gMain.newKeys & DPAD_UP) + { + PlaySE(SE_SELECT); + MoveMenuCursor(-1); + return -2; + } + else if (gMain.newKeys & DPAD_DOWN) + { + PlaySE(SE_SELECT); + MoveMenuCursor(1); + return -2; + } + + return -2; +} + +s8 ProcessMenuInputNoWrapAround(void) +{ + u8 oldPos = gUnknown_0203CD90.cursorPos; + + if (gMain.newKeys & A_BUTTON) + { + if (!gUnknown_0203CD90.menu_field_B) + PlaySE(SE_SELECT); + return gUnknown_0203CD90.cursorPos; + } + + if (gMain.newKeys & B_BUTTON) + { + return -1; + } + + if (gMain.newKeys & DPAD_UP) + { + if (oldPos != MoveMenuCursorNoWrapAround(-1)) + PlaySE(SE_SELECT); + return -2; + } + else if (gMain.newKeys & DPAD_DOWN) + { + if (oldPos != MoveMenuCursorNoWrapAround(1)) + PlaySE(SE_SELECT); + return -2; + } + + return -2; +} + +s8 ProcessMenuInput_other(void) +{ + if (gMain.newKeys & A_BUTTON) + { + if (!gUnknown_0203CD90.menu_field_B) + PlaySE(SE_SELECT); + return gUnknown_0203CD90.cursorPos; + } + + if (gMain.newKeys & B_BUTTON) + { + return -1; + } + + if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_UP) + { + PlaySE(SE_SELECT); + MoveMenuCursor(-1); + return -2; + } + else if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_DOWN) + { + PlaySE(SE_SELECT); + MoveMenuCursor(1); + return -2; + } + + return -2; +} + +s8 ProcessMenuInputNoWrapAround_other(void) +{ + u8 oldPos = gUnknown_0203CD90.cursorPos; + + if (gMain.newKeys & A_BUTTON) + { + if (!gUnknown_0203CD90.menu_field_B) + PlaySE(SE_SELECT); + return gUnknown_0203CD90.cursorPos; + } + + if (gMain.newKeys & B_BUTTON) + { + return -1; + } + + if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_UP) + { + if (oldPos != MoveMenuCursorNoWrapAround(-1)) + PlaySE(SE_SELECT); + return -2; + } + else if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_DOWN) + { + if (oldPos != MoveMenuCursorNoWrapAround(1)) + PlaySE(SE_SELECT); + return -2; + } + + return -2; +} + +void PrintTextArray(u8 windowId, u8 fontId, u8 left, u8 top, u8 lineHeight, u8 itemCount, const struct MenuAction *strs) +{ + u8 i; + for (i = 0; i < itemCount; i++) + { + PrintTextOnWindow(windowId, fontId, strs[i].text, left, (lineHeight * i) + top, 0xFF, NULL); + } + CopyWindowToVram(windowId, 2); +} + +void sub_81987BC(u8 windowId, u8 fontId, u8 left, u8 top, u8 lineHeight, u8 itemCount, const struct MenuAction *strs, u8 a6, u8 a7) +{ + u8 i; + for (i = 0; i < itemCount; i++) + { + sub_8199F74(windowId, fontId, strs[i].text, left, (lineHeight * i) + top, 0xFF, NULL, a6, a7); + } + CopyWindowToVram(windowId, 2); +} + +void sub_8198854(u8 windowId, u8 fontId, u8 lineHeight, u8 itemCount, const struct MenuAction *strs) +{ + PrintTextArray(windowId, fontId, GetFontAttribute(fontId, 0), 1, lineHeight, itemCount, strs); +} + +void AddItemMenuActionTextPrinters(u8 windowId, u8 fontId, u8 left, u8 top, u8 letterSpacing, u8 lineHeight, u8 itemCount, const struct MenuAction *strs, const u8 *a8) +{ + u8 i; + struct TextSubPrinter printer; + + 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.letterSpacing = letterSpacing; + printer.lineSpacing = GetFontAttribute(fontId, 3); + printer.x = left; + printer.currentX = left; + + for (i = 0; i < itemCount; i++) + { + printer.current_text_offset = strs[a8[i]].text; + printer.y = (lineHeight * i) + top; + printer.currentY = printer.y; + AddTextPrinter(&printer, 0xFF, 0); + } + + CopyWindowToVram(windowId, 2); +} + +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); +} + +void SetWindowTemplateFields(struct WindowTemplate *template, u8 bg, u8 left, u8 top, u8 width, u8 height, u8 paletteNum, u16 baseBlock) +{ + template->priority = bg; + template->tilemapLeft = left; + template->tilemapTop = top; + template->width = width; + template->height = height; + template->paletteNum = paletteNum; + template->baseBlock = baseBlock; +} + +struct WindowTemplate sub_8198A50(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); + return template; +} + +u16 sub_8198AA4(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); + return AddWindow(&template); +} + +void sub_8198AF8(struct WindowTemplate *window, u8 fontId, u8 left, u8 top, u16 baseTileNum, u8 paletteNum, u8 cursorPos) +{ + struct TextSubPrinter printer; + + gUnknown_0203CD9F = AddWindow(window); + SetWindowBorderStyle(gUnknown_0203CD9F, TRUE, baseTileNum, paletteNum); + + printer.current_text_offset = gText_YesNo; + printer.windowId = gUnknown_0203CD9F; + printer.fontId = fontId; + printer.x = GetFontAttribute(fontId, 0) + 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); + + AddTextPrinter(&printer, 0xFF, 0); + + sub_81983AC(gUnknown_0203CD9F, fontId, left, top, GetFontAttribute(fontId, 1), 2, cursorPos); +} + +void sub_8198C34(struct WindowTemplate *window, u8 fontId, u16 baseTileNum, u8 paletteNum) +{ + sub_8198AF8(window, fontId, 0, 1, baseTileNum, paletteNum, 0); +} + +s8 ProcessMenuInputNoWrap_(void) +{ + s8 result = ProcessMenuInputNoWrapAround(); + if (result != -2) + sub_8198C78(); + return result; +} + +void sub_8198C78(void) +{ + sub_8198070(gUnknown_0203CD9F, TRUE); + RemoveWindow(gUnknown_0203CD9F); +} + +void sub_8198C94(u8 windowId, u8 fontId, u8 left, u8 top, u8 a4, u8 a5, u8 a6, u8 a7, const struct MenuAction *strs) +{ + u8 i; + u8 j; + for (i = 0; i < a7; i++) + { + for (j = 0; j < a6; j++) + { + PrintTextOnWindow(windowId, fontId, strs[(i * a6) + j].text, (a4 * j) + left, (a5 * i) + top, 0xFF, NULL); + } + } + CopyWindowToVram(windowId, 2); +} + +void sub_8198D54(u8 windowId, u8 fontId, u8 a2, u8 a3, u8 a4, u8 a5, const struct MenuAction *strs) +{ + sub_8198C94(windowId, fontId, GetFontAttribute(fontId, 0), 0, a2, a3, a4, a5, strs); +} + +void sub_8198DBC(u8 windowId, u8 fontId, u8 left, u8 top, u8 a4, u8 itemCount, u8 itemCount2, const struct MenuAction *strs, const u8 *a8) +{ + u8 i; + u8 j; + struct TextSubPrinter printer; + + 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.letterSpacing = GetFontAttribute(fontId, 2); + printer.lineSpacing = GetFontAttribute(fontId, 3); + + for (i = 0; i < itemCount2; i++) + { + for (j = 0; j < itemCount; j++) + { + printer.current_text_offset = strs[a8[(itemCount * i) + j]].text; + printer.x = (a4 * j) + left; + printer.y = (GetFontAttribute(fontId, 1) * i) + top; + printer.currentX = printer.x; + printer.currentY = printer.y; + AddTextPrinter(&printer, 0xFF, 0); + } + } + + CopyWindowToVram(windowId, 2); +} + +void sub_8198EF8(u8 windowId, u8 fontId, u8 a2, u8 a3, u8 a4, u8 a5, const struct MenuAction *strs, const u8 *a8) +{ + sub_8198DBC(windowId, fontId, GetFontAttribute(fontId, 0), 0, a2, a4, a5, strs, a8); +} + +u8 sub_8198F58(u8 a0, u8 a1, s8 a2, s8 a3, u8 a4, u8 a5, u8 a6, u8 a7, u8 a8, u8 a9) +{ + s32 pos; + + gUnknown_0203CD90.left = a2; + gUnknown_0203CD90.top = a3; + gUnknown_0203CD90.minCursorPos = 0; + gUnknown_0203CD90.maxCursorPos = a8 - 1; + gUnknown_0203CD90.windowId = a0; + gUnknown_0203CD90.fontId = a1; + gUnknown_0203CD90.menu_field_7 = a4; + gUnknown_0203CD90.cursorHeight = a5; + gUnknown_0203CD90.menu_field_9 = a6; + gUnknown_0203CD90.menu_field_A = a7; + + pos = a9; + + if (pos < 0 || pos > gUnknown_0203CD90.maxCursorPos) + gUnknown_0203CD90.cursorPos = 0; + else + gUnknown_0203CD90.cursorPos = pos; + + sub_8199134(0, 0); + return gUnknown_0203CD90.cursorPos; +} diff --git a/src/new_menu_helpers.c b/src/new_menu_helpers.c index baa053a22..a4aad4058 100644 --- a/src/new_menu_helpers.c +++ b/src/new_menu_helpers.c @@ -13,17 +13,23 @@ #define DLG_WINDOW_PALETTE_NUM 15 #define DLG_WINDOW_BASE_TILE_NUM 0x200 -extern EWRAM_DATA u8 gUnknown_0203CD8C; -extern EWRAM_DATA u8 gUnknown_0203CD8D; +static EWRAM_DATA u8 gUnknown_0203CD8C = 0; +static EWRAM_DATA u8 gUnknown_0203CD8D = 0; -extern const u8 gUnknown_0860EA6C[]; -extern const u16 gUnknown_0860EA4C[]; -extern const u16 gUnknown_0860F074[]; -extern const u8 gUnknown_0860F094[]; -extern const struct WindowTemplate gUnknown_0860F098[]; -extern const struct WindowTemplate gUnknown_0860F0A8; +const u16 gUnknown_0860F074[] = INCBIN_U16("graphics/interface/860F074.gbapal"); +static const u8 gUnknown_0860F094[] = { 8, 4, 1 }; + +static const struct WindowTemplate gUnknown_0860F098[] = +{ + { 0x00, 0x02, 0x0F, 0x1B, 0x04, 0x0F, 0x194 }, + DUMMY_WIN_TEMPLATE +}; + +static const struct WindowTemplate gUnknown_0860F0A8 = +{ + 0x00, 0x15, 0x09, 0x05, 0x04, 0x0F, 0x125 +}; -extern void sub_819645C(void); // Forward declarations extern void sub_81973A4(void); extern void DrawStandardFrame(u8, u8, u8, u8, u8, u8); @@ -31,17 +37,6 @@ extern void DrawDialogueFrame(u8, u8, u8, u8, u8, u8); extern void sub_81977BC(u8, u8, u8, u8, u8, u8); extern void sub_8197804(u8, u8, u8, u8, u8, u8); -void sub_8197184(u8 window, u32 destTile, u32 destPalette) -{ - LoadBgTiles(GetWindowAttribute(window, WINDOW_PRIORITY), gUnknown_0860EA6C, 0x100, destTile); - LoadPalette(gUnknown_0860EA4C, destPalette * 16, 32); -} - -void sub_81971C4(void) -{ - sub_819645C(); -} - void sub_81971D0(void) { InitWindows(gUnknown_0860F098); -- cgit v1.2.3 From a3ed94dc69aea88c2e18ddab6099217c3ee1094b Mon Sep 17 00:00:00 2001 From: Diegoisawesome Date: Sat, 27 Jan 2018 17:46:32 -0600 Subject: Continue work on menu.c --- src/menu.c | 427 ++++++++++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 380 insertions(+), 47 deletions(-) (limited to 'src') diff --git a/src/menu.c b/src/menu.c index 9ff8d47b6..02e650ef2 100644 --- a/src/menu.c +++ b/src/menu.c @@ -7,6 +7,7 @@ #include "constants/songs.h" #include "main.h" #include "sound.h" +#include "menu_helpers.h" struct SomeUnkStruct { @@ -24,11 +25,11 @@ struct Menu s8 maxCursorPos; u8 windowId; u8 fontId; - u8 menu_field_7; - u8 cursorHeight; - u8 menu_field_9; - u8 menu_field_A; - u8 menu_field_B; + u8 optionWidth; + u8 optionHeight; + u8 horizontalCount; + u8 verticalCount; + bool8 APressMuted; }; extern EWRAM_DATA struct Menu gUnknown_0203CD90; @@ -435,7 +436,7 @@ void sub_8198314(void) } } -u8 sub_8198348(u8 windowId, u8 fontId, u8 left, u8 top, u8 cursorHeight, u8 numChoices, u8 cursorPos, u8 a7) +u8 sub_8198348(u8 windowId, u8 fontId, u8 left, u8 top, u8 cursorHeight, u8 numChoices, u8 initialCursorPos, u8 a7) { s32 pos; @@ -445,10 +446,10 @@ u8 sub_8198348(u8 windowId, u8 fontId, u8 left, u8 top, u8 cursorHeight, u8 numC gUnknown_0203CD90.maxCursorPos = numChoices - 1; gUnknown_0203CD90.windowId = windowId; gUnknown_0203CD90.fontId = fontId; - gUnknown_0203CD90.cursorHeight = cursorHeight; - gUnknown_0203CD90.menu_field_B = a7; + gUnknown_0203CD90.optionHeight = cursorHeight; + gUnknown_0203CD90.APressMuted = a7; - pos = cursorPos; + pos = initialCursorPos; if (pos < 0 || pos > gUnknown_0203CD90.maxCursorPos) gUnknown_0203CD90.cursorPos = 0; @@ -459,14 +460,15 @@ u8 sub_8198348(u8 windowId, u8 fontId, u8 left, u8 top, u8 cursorHeight, u8 numC return gUnknown_0203CD90.cursorPos; } -u8 sub_81983AC(u8 windowId, u8 fontId, u8 left, u8 top, u8 cursorHeight, u8 numChoices, u8 cursorPos) +u8 sub_81983AC(u8 windowId, u8 fontId, u8 left, u8 top, u8 cursorHeight, u8 numChoices, u8 initialCursorPos) { - return sub_8198348(windowId, fontId, left, top, cursorHeight, numChoices, cursorPos, 0); + return sub_8198348(windowId, fontId, left, top, cursorHeight, numChoices, initialCursorPos, 0); } -u8 sub_81983EC(u8 windowId, u8 fontId, u8 left, u8 top, u8 numChoices, u8 cursorPos) +u8 sub_81983EC(u8 windowId, u8 fontId, u8 left, u8 top, u8 numChoices, u8 initialCursorPos) { - return sub_81983AC(windowId, fontId, left, top, GetMenuCursorDimensionByFont(fontId, 1), numChoices, cursorPos); + u8 cursorHeight = GetMenuCursorDimensionByFont(fontId, 1); + return sub_81983AC(windowId, fontId, left, top, cursorHeight, numChoices, initialCursorPos); } void RedrawMenuCursor(u8 oldPos, u8 newPos) @@ -475,8 +477,8 @@ void RedrawMenuCursor(u8 oldPos, u8 newPos) width = GetMenuCursorDimensionByFont(gUnknown_0203CD90.fontId, 0); height = GetMenuCursorDimensionByFont(gUnknown_0203CD90.fontId, 1); - FillWindowPixelRect(gUnknown_0203CD90.windowId, 0x11, gUnknown_0203CD90.left, gUnknown_0203CD90.cursorHeight * oldPos + gUnknown_0203CD90.top, width, height); - PrintTextOnWindow(gUnknown_0203CD90.windowId, gUnknown_0203CD90.fontId, gText_SelectorArrow3, gUnknown_0203CD90.left, gUnknown_0203CD90.cursorHeight * newPos + gUnknown_0203CD90.top, 0, 0); + FillWindowPixelRect(gUnknown_0203CD90.windowId, 0x11, gUnknown_0203CD90.left, gUnknown_0203CD90.optionHeight * oldPos + gUnknown_0203CD90.top, width, height); + PrintTextOnWindow(gUnknown_0203CD90.windowId, gUnknown_0203CD90.fontId, gText_SelectorArrow3, gUnknown_0203CD90.left, gUnknown_0203CD90.optionHeight * newPos + gUnknown_0203CD90.top, 0, 0); } u8 MoveMenuCursor(s8 cursorDelta) @@ -520,17 +522,15 @@ s8 ProcessMenuInput(void) { if (gMain.newKeys & A_BUTTON) { - if (!gUnknown_0203CD90.menu_field_B) + if (!gUnknown_0203CD90.APressMuted) PlaySE(SE_SELECT); return gUnknown_0203CD90.cursorPos; } - - if (gMain.newKeys & B_BUTTON) + else if (gMain.newKeys & B_BUTTON) { return -1; } - - if (gMain.newKeys & DPAD_UP) + else if (gMain.newKeys & DPAD_UP) { PlaySE(SE_SELECT); MoveMenuCursor(-1); @@ -552,17 +552,15 @@ s8 ProcessMenuInputNoWrapAround(void) if (gMain.newKeys & A_BUTTON) { - if (!gUnknown_0203CD90.menu_field_B) + if (!gUnknown_0203CD90.APressMuted) PlaySE(SE_SELECT); return gUnknown_0203CD90.cursorPos; } - - if (gMain.newKeys & B_BUTTON) + else if (gMain.newKeys & B_BUTTON) { return -1; } - - if (gMain.newKeys & DPAD_UP) + else if (gMain.newKeys & DPAD_UP) { if (oldPos != MoveMenuCursorNoWrapAround(-1)) PlaySE(SE_SELECT); @@ -582,17 +580,15 @@ s8 ProcessMenuInput_other(void) { if (gMain.newKeys & A_BUTTON) { - if (!gUnknown_0203CD90.menu_field_B) + if (!gUnknown_0203CD90.APressMuted) PlaySE(SE_SELECT); return gUnknown_0203CD90.cursorPos; } - - if (gMain.newKeys & B_BUTTON) + else if (gMain.newKeys & B_BUTTON) { return -1; } - - if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_UP) + else if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_UP) { PlaySE(SE_SELECT); MoveMenuCursor(-1); @@ -614,17 +610,15 @@ s8 ProcessMenuInputNoWrapAround_other(void) if (gMain.newKeys & A_BUTTON) { - if (!gUnknown_0203CD90.menu_field_B) + if (!gUnknown_0203CD90.APressMuted) PlaySE(SE_SELECT); return gUnknown_0203CD90.cursorPos; } - - if (gMain.newKeys & B_BUTTON) + else if (gMain.newKeys & B_BUTTON) { return -1; } - - if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_UP) + else if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_UP) { if (oldPos != MoveMenuCursorNoWrapAround(-1)) PlaySE(SE_SELECT); @@ -722,7 +716,7 @@ u16 sub_8198AA4(u8 bg, u8 left, u8 top, u8 width, u8 height, u8 paletteNum, u16 return AddWindow(&template); } -void sub_8198AF8(struct WindowTemplate *window, u8 fontId, u8 left, u8 top, u16 baseTileNum, u8 paletteNum, u8 cursorPos) +void sub_8198AF8(struct WindowTemplate *window, u8 fontId, u8 left, u8 top, u16 baseTileNum, u8 paletteNum, u8 initialCursorPos) { struct TextSubPrinter printer; @@ -745,7 +739,7 @@ void sub_8198AF8(struct WindowTemplate *window, u8 fontId, u8 left, u8 top, u16 AddTextPrinter(&printer, 0xFF, 0); - sub_81983AC(gUnknown_0203CD9F, fontId, left, top, GetFontAttribute(fontId, 1), 2, cursorPos); + sub_81983AC(gUnknown_0203CD9F, fontId, left, top, GetFontAttribute(fontId, 1), 2, initialCursorPos); } void sub_8198C34(struct WindowTemplate *window, u8 fontId, u16 baseTileNum, u8 paletteNum) @@ -822,20 +816,20 @@ void sub_8198EF8(u8 windowId, u8 fontId, u8 a2, u8 a3, u8 a4, u8 a5, const struc sub_8198DBC(windowId, fontId, GetFontAttribute(fontId, 0), 0, a2, a4, a5, strs, a8); } -u8 sub_8198F58(u8 a0, u8 a1, s8 a2, s8 a3, u8 a4, u8 a5, u8 a6, u8 a7, u8 a8, u8 a9) +u8 sub_8198F58(u8 windowId, u8 fontId, u8 left, u8 top, u8 a4, u8 cursorHeight, u8 a6, u8 a7, u8 numChoices, u8 a9) { s32 pos; - gUnknown_0203CD90.left = a2; - gUnknown_0203CD90.top = a3; + gUnknown_0203CD90.left = left; + gUnknown_0203CD90.top = top; gUnknown_0203CD90.minCursorPos = 0; - gUnknown_0203CD90.maxCursorPos = a8 - 1; - gUnknown_0203CD90.windowId = a0; - gUnknown_0203CD90.fontId = a1; - gUnknown_0203CD90.menu_field_7 = a4; - gUnknown_0203CD90.cursorHeight = a5; - gUnknown_0203CD90.menu_field_9 = a6; - gUnknown_0203CD90.menu_field_A = a7; + gUnknown_0203CD90.maxCursorPos = numChoices - 1; + gUnknown_0203CD90.windowId = windowId; + gUnknown_0203CD90.fontId = fontId; + gUnknown_0203CD90.optionWidth = a4; + gUnknown_0203CD90.optionHeight = cursorHeight; + gUnknown_0203CD90.horizontalCount = a6; + gUnknown_0203CD90.verticalCount = a7; pos = a9; @@ -847,3 +841,342 @@ u8 sub_8198F58(u8 a0, u8 a1, s8 a2, s8 a3, u8 a4, u8 a5, u8 a6, u8 a7, u8 a8, u8 sub_8199134(0, 0); return gUnknown_0203CD90.cursorPos; } + +u8 sub_8198FD4(u8 windowId, u8 fontId, u8 left, u8 top, u8 a4, u8 a5, u8 a6, u8 a7) +{ + u8 cursorHeight = GetMenuCursorDimensionByFont(fontId, 1); + u8 numChoices = a5 * a6; + return sub_8198F58(windowId, fontId, left, top, a4, cursorHeight, a5, a6, numChoices, a7); +} + +void sub_8199060(u8 oldCursorPos, u8 newCursorPos) +{ + u8 cursorWidth = GetMenuCursorDimensionByFont(gUnknown_0203CD90.fontId, 0); + u8 cursorHeight = GetMenuCursorDimensionByFont(gUnknown_0203CD90.fontId, 1); + u8 xPos = (oldCursorPos % gUnknown_0203CD90.horizontalCount) * gUnknown_0203CD90.optionWidth + gUnknown_0203CD90.left; + u8 yPos = (oldCursorPos / gUnknown_0203CD90.horizontalCount) * gUnknown_0203CD90.optionHeight + gUnknown_0203CD90.top; + FillWindowPixelRect(gUnknown_0203CD90.windowId, + 0x11, + xPos, + yPos, + cursorWidth, + cursorHeight); + xPos = (newCursorPos % gUnknown_0203CD90.horizontalCount) * gUnknown_0203CD90.optionWidth + gUnknown_0203CD90.left; + yPos = (newCursorPos / gUnknown_0203CD90.horizontalCount) * gUnknown_0203CD90.optionHeight + gUnknown_0203CD90.top; + PrintTextOnWindow(gUnknown_0203CD90.windowId, + gUnknown_0203CD90.fontId, + gText_SelectorArrow3, + xPos, + yPos, + 0, + 0); +} + +u8 sub_8199134(s8 deltaX, s8 deltaY) +{ + u8 oldPos = gUnknown_0203CD90.cursorPos; + + if (deltaX != 0) + { + if ((gUnknown_0203CD90.cursorPos % gUnknown_0203CD90.horizontalCount) + deltaX < 0) + { + gUnknown_0203CD90.cursorPos += gUnknown_0203CD90.horizontalCount - 1; + } + else if ((gUnknown_0203CD90.cursorPos % gUnknown_0203CD90.horizontalCount) + deltaX >= gUnknown_0203CD90.horizontalCount) + { + gUnknown_0203CD90.cursorPos = (gUnknown_0203CD90.cursorPos / gUnknown_0203CD90.horizontalCount) * gUnknown_0203CD90.horizontalCount; + } + else + { + gUnknown_0203CD90.cursorPos += deltaX; + } + } + + if (deltaY != 0) + { + if ((gUnknown_0203CD90.cursorPos / gUnknown_0203CD90.horizontalCount) + deltaY < 0) + { + gUnknown_0203CD90.cursorPos += gUnknown_0203CD90.horizontalCount * (gUnknown_0203CD90.verticalCount - 1); + } + else if ((gUnknown_0203CD90.cursorPos / gUnknown_0203CD90.horizontalCount) + deltaY >= gUnknown_0203CD90.verticalCount) + { + gUnknown_0203CD90.cursorPos -= gUnknown_0203CD90.horizontalCount * (gUnknown_0203CD90.verticalCount - 1); + } + else + { + gUnknown_0203CD90.cursorPos += (gUnknown_0203CD90.horizontalCount * deltaY); + } + } + + if (gUnknown_0203CD90.cursorPos > gUnknown_0203CD90.maxCursorPos) + { + gUnknown_0203CD90.cursorPos = oldPos; + return gUnknown_0203CD90.cursorPos; + } + else + { + sub_8199060(oldPos, gUnknown_0203CD90.cursorPos); + return gUnknown_0203CD90.cursorPos; + } +} + +u8 sub_81991F8(s8 deltaX, s8 deltaY) +{ + u8 oldPos = gUnknown_0203CD90.cursorPos; + + if (deltaX != 0) + { + if (((gUnknown_0203CD90.cursorPos % gUnknown_0203CD90.horizontalCount) + deltaX >= 0) && + ((gUnknown_0203CD90.cursorPos % gUnknown_0203CD90.horizontalCount) + deltaX < gUnknown_0203CD90.horizontalCount)) + { + gUnknown_0203CD90.cursorPos += deltaX; + } + } + + if (deltaY != 0) + { + if (((gUnknown_0203CD90.cursorPos / gUnknown_0203CD90.horizontalCount) + deltaY >= 0) && + ((gUnknown_0203CD90.cursorPos / gUnknown_0203CD90.horizontalCount) + deltaY < gUnknown_0203CD90.verticalCount)) + { + gUnknown_0203CD90.cursorPos += (gUnknown_0203CD90.horizontalCount * deltaY); + } + } + + if (gUnknown_0203CD90.cursorPos > gUnknown_0203CD90.maxCursorPos) + { + gUnknown_0203CD90.cursorPos = oldPos; + return gUnknown_0203CD90.cursorPos; + } + else + { + sub_8199060(oldPos, gUnknown_0203CD90.cursorPos); + return gUnknown_0203CD90.cursorPos; + } +} + +s8 sub_8199284(void) +{ + if (gMain.newKeys & A_BUTTON) + { + PlaySE(SE_SELECT); + return gUnknown_0203CD90.cursorPos; + } + else if (gMain.newKeys & B_BUTTON) + { + return -1; + } + else if (gMain.newKeys & DPAD_UP) + { + PlaySE(SE_SELECT); + sub_8199134(0, -1); + return -2; + } + else if (gMain.newKeys & DPAD_DOWN) + { + PlaySE(SE_SELECT); + sub_8199134(0, 1); + return -2; + } + else if (gMain.newKeys & DPAD_LEFT || GetLRKeysState() == 1) + { + PlaySE(SE_SELECT); + sub_8199134(-1, 0); + return -2; + } + else if (gMain.newKeys & DPAD_RIGHT || GetLRKeysState() == 2) + { + PlaySE(SE_SELECT); + sub_8199134(1, 0); + return -2; + } + + return -2; +} + +s8 sub_8199334(void) +{ + u8 oldPos = gUnknown_0203CD90.cursorPos; + + if (gMain.newKeys & A_BUTTON) + { + PlaySE(SE_SELECT); + return gUnknown_0203CD90.cursorPos; + } + else if (gMain.newKeys & B_BUTTON) + { + return -1; + } + else if (gMain.newKeys & DPAD_UP) + { + if (oldPos != sub_81991F8(0, -1)) + PlaySE(SE_SELECT); + return -2; + } + else if (gMain.newKeys & DPAD_DOWN) + { + if (oldPos != sub_81991F8(0, 1)) + PlaySE(SE_SELECT); + return -2; + } + else if (gMain.newKeys & DPAD_LEFT || GetLRKeysState() == 1) + { + if (oldPos != sub_81991F8(-1, 0)) + PlaySE(SE_SELECT); + return -2; + } + else if (gMain.newKeys & DPAD_RIGHT || GetLRKeysState() == 2) + { + if (oldPos != sub_81991F8(1, 0)) + PlaySE(SE_SELECT); + return -2; + } + + return -2; +} + +s8 sub_81993D8(void) +{ + if (gMain.newKeys & A_BUTTON) + { + PlaySE(SE_SELECT); + return gUnknown_0203CD90.cursorPos; + } + else if (gMain.newKeys & B_BUTTON) + { + return -1; + } + else if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_UP) + { + PlaySE(SE_SELECT); + sub_8199134(0, -1); + return -2; + } + else if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_DOWN) + { + PlaySE(SE_SELECT); + sub_8199134(0, 1); + return -2; + } + else if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_LEFT || sub_812210C() == 1) + { + PlaySE(SE_SELECT); + sub_8199134(-1, 0); + return -2; + } + else if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_RIGHT || sub_812210C() == 2) + { + PlaySE(SE_SELECT); + sub_8199134(1, 0); + return -2; + } + + return -2; +} + +s8 sub_8199484(void) +{ + u8 oldPos = gUnknown_0203CD90.cursorPos; + + if (gMain.newKeys & A_BUTTON) + { + PlaySE(SE_SELECT); + return gUnknown_0203CD90.cursorPos; + } + else if (gMain.newKeys & B_BUTTON) + { + return -1; + } + else if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_UP) + { + if (oldPos != sub_81991F8(0, -1)) + PlaySE(SE_SELECT); + return -2; + } + else if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_DOWN) + { + if (oldPos != sub_81991F8(0, 1)) + PlaySE(SE_SELECT); + return -2; + } + else if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_LEFT || sub_812210C() == 1) + { + if (oldPos != sub_81991F8(-1, 0)) + PlaySE(SE_SELECT); + return -2; + } + else if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_RIGHT || sub_812210C() == 2) + { + if (oldPos != sub_81991F8(1, 0)) + PlaySE(SE_SELECT); + return -2; + } + + return -2; +} + +u8 InitMenuInUpperLeftCorner(u8 windowId, u8 itemCount, u8 initialCursorPos, bool8 APressMuted) +{ + s32 pos; + + gUnknown_0203CD90.left = 0; + gUnknown_0203CD90.top = 1; + gUnknown_0203CD90.minCursorPos = 0; + gUnknown_0203CD90.maxCursorPos = itemCount - 1; + gUnknown_0203CD90.windowId = windowId; + gUnknown_0203CD90.fontId = 1; + gUnknown_0203CD90.optionHeight = 16; + gUnknown_0203CD90.APressMuted = APressMuted; + + pos = initialCursorPos; + + if (pos < 0 || pos > gUnknown_0203CD90.maxCursorPos) + gUnknown_0203CD90.cursorPos = 0; + else + gUnknown_0203CD90.cursorPos = pos; + + return MoveMenuCursor(0); +} + +u8 InitMenuInUpperLeftCornerPlaySoundWhenAPressed(u8 windowId, u8 itemCount, u8 initialCursorPos) +{ + return InitMenuInUpperLeftCorner(windowId, itemCount, initialCursorPos, FALSE); +} + +void PrintMenuTable(u8 windowId, u8 itemCount, const struct MenuAction *strs) +{ + u32 i; + + for (i = 0; i < itemCount; i++) + { + PrintTextOnWindow(windowId, 1, strs[i].text, 8, (i * 16) + 1, 0xFF, NULL); + } + + CopyWindowToVram(windowId, 2); +} + +void sub_81995E4(u8 windowId, u8 itemCount, const struct MenuAction *strs, const u8 *a8) +{ + u8 i; + struct TextSubPrinter printer; + + printer.windowId = windowId; + printer.fontId = 1; + printer.fgColor = GetFontAttribute(1, 5); + printer.bgColor = GetFontAttribute(1, 6); + printer.shadowColor = GetFontAttribute(1, 7); + printer.fontColor_l = GetFontAttribute(1, 4); + printer.letterSpacing = 0; + printer.lineSpacing = 0; + printer.x = 8; + printer.currentX = 8; + + for (i = 0; i < itemCount; i++) + { + printer.current_text_offset = strs[a8[i]].text; + printer.y = (i * 16) + 1; + printer.currentY = (i * 16) + 1; + AddTextPrinter(&printer, 0xFF, 0); + } + + CopyWindowToVram(windowId, 2); +} -- cgit v1.2.3 From 3793152bc3666043764689af9821ef15da1243ae Mon Sep 17 00:00:00 2001 From: Diegoisawesome Date: Mon, 29 Jan 2018 17:26:36 -0600 Subject: More work on menu --- src/dma3_manager.c | 2 +- src/menu.c | 275 ++++++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 274 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/dma3_manager.c b/src/dma3_manager.c index 3832c3663..28df9d932 100644 --- a/src/dma3_manager.c +++ b/src/dma3_manager.c @@ -204,7 +204,7 @@ s16 RequestDma3Fill(s32 value, void *dest, u16 size, u8 mode) return -1; // no free DMA request was found } -int CheckForSpaceForDma3Request(s16 index) +s16 CheckForSpaceForDma3Request(s16 index) { int i = 0; diff --git a/src/menu.c b/src/menu.c index 02e650ef2..b5ff565fe 100644 --- a/src/menu.c +++ b/src/menu.c @@ -8,6 +8,9 @@ #include "main.h" #include "sound.h" #include "menu_helpers.h" +#include "malloc.h" +#include "task.h" +#include "dma3.h" struct SomeUnkStruct { @@ -37,6 +40,9 @@ extern EWRAM_DATA u16 gUnknown_0203CD9C; extern EWRAM_DATA u8 gUnknown_0203CD9E; extern EWRAM_DATA u8 gUnknown_0203CD9F; extern EWRAM_DATA u8 gUnknown_0203CDA0; +extern EWRAM_DATA bool8 gUnknown_0203CDA4[4]; +extern EWRAM_DATA u16 gUnknown_0203CDA8; +extern EWRAM_DATA void *gUnknown_0203CDAC[0x20]; const u16 gUnknown_0860F0B0[] = INCBIN_U16("graphics/interface/860F0B0.gbapal"); const u8 gUnknown_0860F0D0[] = { 15, 1, 2 }; @@ -81,6 +87,7 @@ extern u8 MoveMenuCursor(s8); extern u8 sub_8199134(s8, s8); extern void sub_8199F74(u8, u8, const u8 *str, u8 x, u8 y, u8 speed, void (*callback)(struct TextSubPrinter *, u16), u8, u8); extern void sub_8198C78(void); +extern void task_free_buf_after_copying_tile_data_to_vram(u8 taskId); void AddTextPrinterWithCallbackForMessage(bool8 a1, void (*callback)(struct TextSubPrinter *, u16)) { @@ -716,7 +723,7 @@ u16 sub_8198AA4(u8 bg, u8 left, u8 top, u8 width, u8 height, u8 paletteNum, u16 return AddWindow(&template); } -void sub_8198AF8(struct WindowTemplate *window, u8 fontId, u8 left, u8 top, u16 baseTileNum, u8 paletteNum, u8 initialCursorPos) +void sub_8198AF8(const struct WindowTemplate *window, u8 fontId, u8 left, u8 top, u16 baseTileNum, u8 paletteNum, u8 initialCursorPos) { struct TextSubPrinter printer; @@ -742,7 +749,7 @@ void sub_8198AF8(struct WindowTemplate *window, u8 fontId, u8 left, u8 top, u16 sub_81983AC(gUnknown_0203CD9F, fontId, left, top, GetFontAttribute(fontId, 1), 2, initialCursorPos); } -void sub_8198C34(struct WindowTemplate *window, u8 fontId, u16 baseTileNum, u8 paletteNum) +void sub_8198C34(const struct WindowTemplate *window, u8 fontId, u16 baseTileNum, u8 paletteNum) { sub_8198AF8(window, fontId, 0, 1, baseTileNum, paletteNum, 0); } @@ -1180,3 +1187,267 @@ void sub_81995E4(u8 windowId, u8 itemCount, const struct MenuAction *strs, const CopyWindowToVram(windowId, 2); } + +void CreateYesNoMenu(const struct WindowTemplate *window, u16 baseTileNum, u8 paletteNum, u8 initialCursorPos) +{ + struct TextSubPrinter printer; + + gUnknown_0203CD9F = AddWindow(window); + SetWindowBorderStyle(gUnknown_0203CD9F, TRUE, baseTileNum, paletteNum); + + printer.current_text_offset = gText_YesNo; + printer.windowId = gUnknown_0203CD9F; + printer.fontId = 1; + printer.x = 8; + printer.y = 1; + printer.currentX = printer.x; + printer.currentY = printer.y; + printer.fgColor = GetFontAttribute(1, 5); + printer.bgColor = GetFontAttribute(1, 6); + printer.shadowColor = GetFontAttribute(1, 7); + printer.fontColor_l = GetFontAttribute(1, 4); + printer.letterSpacing = 0; + printer.lineSpacing = 0; + + AddTextPrinter(&printer, 0xFF, 0); + InitMenuInUpperLeftCornerPlaySoundWhenAPressed(gUnknown_0203CD9F, 2, initialCursorPos); +} + +void sub_81997AC(u8 windowId, u8 a4, u8 a6, u8 a7, const struct MenuAction *strs) +{ + u32 i; + u32 j; + for (i = 0; i < a7; i++) + { + for (j = 0; j < a6; j++) + { + PrintTextOnWindow(windowId, 1, strs[(i * a6) + j].text, (a4 * j) + 8, (i * 16) + 1, 0xFF, NULL); + } + } + CopyWindowToVram(windowId, 2); +} + +void sub_819983C(u8 windowId, u8 a4, u8 itemCount, u8 itemCount2, const struct MenuAction *strs, const u8 *a8) +{ + u8 i; + u8 j; + struct TextSubPrinter printer; + + printer.windowId = windowId; + printer.fontId = 1; + printer.fgColor = GetFontAttribute(1, 5); + printer.bgColor = GetFontAttribute(1, 6); + printer.shadowColor = GetFontAttribute(1, 7); + printer.fontColor_l = GetFontAttribute(1, 4); + printer.letterSpacing = 0; + printer.lineSpacing = 0; + + for (i = 0; i < itemCount2; i++) + { + for (j = 0; j < itemCount; j++) + { + printer.current_text_offset = strs[a8[(itemCount * i) + j]].text; + printer.x = (a4 * j) + 8; + printer.y = (16 * i) + 1; + printer.currentX = printer.x; + printer.currentY = printer.y; + AddTextPrinter(&printer, 0xFF, 0); + } + } + + CopyWindowToVram(windowId, 2); +} + +u8 sub_8199944(u8 windowId, u8 optionWidth, u8 horizontalCount, u8 verticalCount, u8 initialCursorPos) +{ + s32 pos; + + gUnknown_0203CD90.left = 0; + gUnknown_0203CD90.top = 1; + gUnknown_0203CD90.minCursorPos = 0; + gUnknown_0203CD90.maxCursorPos = (horizontalCount * verticalCount) - 1; + gUnknown_0203CD90.windowId = windowId; + gUnknown_0203CD90.fontId = 1; + gUnknown_0203CD90.optionWidth = optionWidth; + gUnknown_0203CD90.optionHeight = 16; + gUnknown_0203CD90.horizontalCount = horizontalCount; + gUnknown_0203CD90.verticalCount = verticalCount; + + pos = initialCursorPos; + + if (pos < 0 || pos > gUnknown_0203CD90.maxCursorPos) + gUnknown_0203CD90.cursorPos = 0; + else + gUnknown_0203CD90.cursorPos = pos; + + sub_8199134(0, 0); + return gUnknown_0203CD90.cursorPos; +} + +void clear_scheduled_bg_copies_to_vram(void) +{ + memset(gUnknown_0203CDA4, 0, sizeof(gUnknown_0203CDA4)); +} + +void schedule_bg_copy_tilemap_to_vram(u8 bgId) +{ + gUnknown_0203CDA4[bgId] = TRUE; +} + +void do_scheduled_bg_tilemap_copies_to_vram(void) +{ + if (gUnknown_0203CDA4[0] == TRUE) + { + CopyBgTilemapBufferToVram(0); + gUnknown_0203CDA4[0] = FALSE; + } + if (gUnknown_0203CDA4[1] == TRUE) + { + CopyBgTilemapBufferToVram(1); + gUnknown_0203CDA4[1] = FALSE; + } + if (gUnknown_0203CDA4[2] == TRUE) + { + CopyBgTilemapBufferToVram(2); + gUnknown_0203CDA4[2] = FALSE; + } + if (gUnknown_0203CDA4[3] == TRUE) + { + CopyBgTilemapBufferToVram(3); + gUnknown_0203CDA4[3] = FALSE; + } +} + +void reset_temp_tile_data_buffers(void) +{ + int i; + for (i = 0; i < (s32)ARRAY_COUNT(gUnknown_0203CDAC); i++) + { + gUnknown_0203CDAC[i] = NULL; + } + gUnknown_0203CDA8 = 0; +} + +bool8 free_temp_tile_data_buffers_if_possible(void) +{ + int i; + + if (!IsDma3ManagerBusyWithBgCopy()) + { + if (gUnknown_0203CDA8) + { + for (i = 0; i < gUnknown_0203CDA8; i++) + { + FREE_AND_SET_NULL(gUnknown_0203CDAC[i]); + } + gUnknown_0203CDA8 = 0; + } + return FALSE; + } + else + { + return TRUE; + } +} + +void *decompress_and_copy_tile_data_to_vram(u8 bgId, const void *src, int size, u16 offset, u8 mode) +{ + int sizeOut; + if (gUnknown_0203CDA8 < ARRAY_COUNT(gUnknown_0203CDAC)) + { + void *ptr = malloc_and_decompress(src, &sizeOut); + if (!size) + size = sizeOut; + if (ptr) + { + copy_decompressed_tile_data_to_vram(bgId, ptr, size, offset, mode); + gUnknown_0203CDAC[gUnknown_0203CDA8++] = ptr; + } + return ptr; + } + return NULL; +} + +void copy_decompressed_tile_data_to_vram_autofree(u8 bgId, const void *src, int size, u16 offset, u8 mode) +{ + int sizeOut; + void *ptr = malloc_and_decompress(src, &sizeOut); + if (!size) + size = sizeOut; + if (ptr) + { + u8 taskId = CreateTask(task_free_buf_after_copying_tile_data_to_vram, 0); + gTasks[taskId].data[0] = copy_decompressed_tile_data_to_vram(bgId, ptr, size, offset, mode); + SetWordTaskArg(taskId, 1, (u32)ptr); + } +} + +void task_free_buf_after_copying_tile_data_to_vram(u8 taskId) +{ + if (!CheckForSpaceForDma3Request(gTasks[taskId].data[0])) + { + Free((void *)GetWordTaskArg(taskId, 1)); + DestroyTask(taskId); + } +} + +void *malloc_and_decompress(const void *src, int *size) +{ + void *ptr; + u8 *sizeAsBytes = (u8 *)size; + u8 *srcAsBytes = (u8 *)src; + + sizeAsBytes[0] = srcAsBytes[1]; + sizeAsBytes[1] = srcAsBytes[2]; + sizeAsBytes[2] = srcAsBytes[3]; + sizeAsBytes[3] = 0; + + ptr = Alloc(*size); + if (ptr) + LZ77UnCompWram(src, ptr); + return ptr; +} + +u16 copy_decompressed_tile_data_to_vram(u8 bgId, const void *src, u16 size, u16 offset, u8 mode) +{ + switch (mode) + { + case 0: + return LoadBgTiles(bgId, src, size, offset); + case 1: + return LoadBgTilemap(bgId, src, size, offset); + default: + return -1; + } +} + +void sub_8199C30(u8 bgId, u8 left, u8 top, u8 width, u8 height, u8 palette) +{ + u8 i; + u8 j; + u16 *ptr = GetBgTilemapBuffer(bgId); + + for (i = top; i < top + height; i++) + { + for (j = left; j < left + width; j++) + { + ptr[(i * 32) + j] = (ptr[(i * 32) + j] & 0xFFF) | (palette << 12); + } + } +} + +void sub_8199CBC(u8 bgId, void *dest, u8 left, u8 top, u8 width, u8 height) +{ + u8 i; + u8 j; + u16 *ptr = GetBgTilemapBuffer(bgId); + u16 *destAsU16 = dest; + + for (i = 0; i < height; i++) + { + for (j = 0; j < width; j++) + { + destAsU16[(i * height) + j] = ptr[(i * height) + j]; + } + } +} -- cgit v1.2.3 From 97c9a4ec22a479c5a98226c9333e9bffcf1fd4e0 Mon Sep 17 00:00:00 2001 From: Diegoisawesome Date: Tue, 6 Feb 2018 14:35:23 -0600 Subject: Skip sub_819A080 --- src/menu.c | 447 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 435 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/menu.c b/src/menu.c index b5ff565fe..bcbc21a3b 100644 --- a/src/menu.c +++ b/src/menu.c @@ -11,6 +11,8 @@ #include "malloc.h" #include "task.h" #include "dma3.h" +#include "string_util.h" +#include "pokemon_icon.h" struct SomeUnkStruct { @@ -45,7 +47,7 @@ extern EWRAM_DATA u16 gUnknown_0203CDA8; extern EWRAM_DATA void *gUnknown_0203CDAC[0x20]; const u16 gUnknown_0860F0B0[] = INCBIN_U16("graphics/interface/860F0B0.gbapal"); -const u8 gUnknown_0860F0D0[] = { 15, 1, 2 }; +const struct TextColor gUnknown_0860F0D0[] = { 15, 1, 2 }; const struct SomeUnkStruct gUnknown_0860F0D4[] = { { 12, 12, 0x00 }, @@ -78,6 +80,10 @@ const struct SomeUnkStruct gUnknown_0860F0D4[] = extern const u8 gText_SelectorArrow3[]; extern const u8 gText_YesNo[]; +extern const u16 gFireRedMenuElements1_Pal[16]; +extern const u16 gFireRedMenuElements2_Pal[16]; +extern const u16 gFireRedMenuElements3_Pal[16]; +extern const u8 gFireRedMenuElements_Gfx[]; extern void sub_8197BB4(u8, u8, u8, u8, u8, u8); extern void sub_8197E30(u8, u8, u8, u8, u8, u8); @@ -85,7 +91,7 @@ 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, u8, const u8 *str, u8 x, u8 y, u8 speed, void (*callback)(struct TextSubPrinter *, u16), u8, u8); +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); @@ -687,7 +693,7 @@ void AddItemMenuActionTextPrinters(u8 windowId, u8 fontId, u8 left, u8 top, u8 l printer.current_text_offset = strs[a8[i]].text; printer.y = (lineHeight * i) + top; printer.currentY = printer.y; - AddTextPrinter(&printer, 0xFF, 0); + AddTextPrinter(&printer, 0xFF, NULL); } CopyWindowToVram(windowId, 2); @@ -744,7 +750,7 @@ void sub_8198AF8(const struct WindowTemplate *window, u8 fontId, u8 left, u8 top printer.letterSpacing = GetFontAttribute(fontId, 2); printer.lineSpacing = GetFontAttribute(fontId, 3); - AddTextPrinter(&printer, 0xFF, 0); + AddTextPrinter(&printer, 0xFF, NULL); sub_81983AC(gUnknown_0203CD9F, fontId, left, top, GetFontAttribute(fontId, 1), 2, initialCursorPos); } @@ -811,7 +817,7 @@ void sub_8198DBC(u8 windowId, u8 fontId, u8 left, u8 top, u8 a4, u8 itemCount, u printer.y = (GetFontAttribute(fontId, 1) * i) + top; printer.currentX = printer.x; printer.currentY = printer.y; - AddTextPrinter(&printer, 0xFF, 0); + AddTextPrinter(&printer, 0xFF, NULL); } } @@ -1182,7 +1188,7 @@ void sub_81995E4(u8 windowId, u8 itemCount, const struct MenuAction *strs, const printer.current_text_offset = strs[a8[i]].text; printer.y = (i * 16) + 1; printer.currentY = (i * 16) + 1; - AddTextPrinter(&printer, 0xFF, 0); + AddTextPrinter(&printer, 0xFF, NULL); } CopyWindowToVram(windowId, 2); @@ -1209,7 +1215,7 @@ void CreateYesNoMenu(const struct WindowTemplate *window, u16 baseTileNum, u8 pa printer.letterSpacing = 0; printer.lineSpacing = 0; - AddTextPrinter(&printer, 0xFF, 0); + AddTextPrinter(&printer, 0xFF, NULL); InitMenuInUpperLeftCornerPlaySoundWhenAPressed(gUnknown_0203CD9F, 2, initialCursorPos); } @@ -1251,7 +1257,7 @@ void sub_819983C(u8 windowId, u8 a4, u8 itemCount, u8 itemCount2, const struct M printer.y = (16 * i) + 1; printer.currentX = printer.x; printer.currentY = printer.y; - AddTextPrinter(&printer, 0xFF, 0); + AddTextPrinter(&printer, 0xFF, NULL); } } @@ -1436,18 +1442,435 @@ void sub_8199C30(u8 bgId, u8 left, u8 top, u8 width, u8 height, u8 palette) } } -void sub_8199CBC(u8 bgId, void *dest, u8 left, u8 top, u8 width, u8 height) +void sub_8199CBC(u8 bgId, u16 *dest, u8 left, u8 top, u8 width, u8 height) { u8 i; u8 j; - u16 *ptr = GetBgTilemapBuffer(bgId); - u16 *destAsU16 = dest; + const u16 *src = GetBgTilemapBuffer(bgId); for (i = 0; i < height; i++) { for (j = 0; j < width; j++) { - destAsU16[(i * height) + j] = ptr[(i * height) + j]; + dest[(i * width) + j] = src[(i + top) * 32 + j + left]; } } } + +void sub_8199D3C(void *ptr, int delta, int width, int height, bool32 is8BPP) +{ + int i; + int area = width * height; + if (is8BPP == TRUE) + { + u8 *as8BPP = ptr; + for (i = 0; i < area; i++) + { + as8BPP[i] += delta; + } + } + else + { + u16 *as4BPP = ptr; + for (i = 0; i < area; i++) + { + as4BPP[i] = (as4BPP[i] & 0xFC00) | ((as4BPP[i] + delta) & 0x3FF); + } + } +} + +void sub_8199D98(void) +{ + ChangeBgX(0, 0, 0); + ChangeBgX(1, 0, 0); + ChangeBgX(2, 0, 0); + ChangeBgX(3, 0, 0); + ChangeBgY(0, 0, 0); + ChangeBgY(1, 0, 0); + ChangeBgY(2, 0, 0); + ChangeBgY(3, 0, 0); +} + +void sub_8199DF0(u32 bg, u8 a1, int a2, int a3) +{ + int temp = (!GetBgAttribute(bg, 4)) ? 0x20 : 0x40; + void *addr = (void *)((GetBgAttribute(bg, 1) * 0x4000) + (GetBgAttribute(bg, 10) + a2) * temp); + RequestDma3Fill(a1 << 24 | a1 << 16 | a1 << 8 | a1, addr + VRAM, a3 * temp, 1); +} + +void box_print(u8 windowId, u8 fontId, u8 left, u8 top, const struct TextColor *color, s8 speed, const u8 *str) +{ + struct TextSubPrinter printer; + + printer.current_text_offset = str; + printer.windowId = windowId; + printer.fontId = fontId; + printer.x = left; + printer.y = top; + printer.currentX = printer.x; + printer.currentY = printer.y; + printer.letterSpacing = GetFontAttribute(fontId, 2); + printer.lineSpacing = GetFontAttribute(fontId, 3); + printer.fontColor_l = 0; + printer.fgColor = color->bgColor; + printer.bgColor = color->fgColor; + printer.shadowColor = color->shadowColor; + + AddTextPrinter(&printer, speed, NULL); +} + +void AddTextPrinterParameterized2(u8 windowId, u8 fontId, u8 left, u8 top, u8 letterSpacing, u8 lineSpacing, const struct TextColor *color, s8 speed, const u8 *str) +{ + struct TextSubPrinter printer; + + printer.current_text_offset = str; + printer.windowId = windowId; + printer.fontId = fontId; + printer.x = left; + printer.y = top; + printer.currentX = printer.x; + printer.currentY = printer.y; + printer.letterSpacing = letterSpacing; + printer.lineSpacing = lineSpacing; + printer.fontColor_l = 0; + printer.fgColor = color->bgColor; + printer.bgColor = color->fgColor; + printer.shadowColor = color->shadowColor; + + AddTextPrinter(&printer, speed, NULL); +} + +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) +{ + struct TextSubPrinter printer; + + printer.current_text_offset = str; + printer.windowId = windowId; + printer.fontId = fontId; + printer.x = left; + printer.y = top; + printer.currentX = left; + printer.currentY = top; + printer.letterSpacing = letterSpacing; + printer.lineSpacing = lineSpacing; + printer.fontColor_l = 0; + + printer.fgColor = GetFontAttribute(fontId, 5); + printer.bgColor = GetFontAttribute(fontId, 6); + printer.shadowColor = GetFontAttribute(fontId, 7); + + AddTextPrinter(&printer, speed, callback); +} + +void sub_819A024(u8 windowId, const u8 *src, u16 a2, u16 a3) +{ + int count = 0; + while (gSaveBlock2Ptr->playerName[count] != EOS) + count++; + + StringExpandPlaceholders(gStringVar4, src); + + PrintTextOnWindow(windowId, 1, gStringVar4, a2, a3, 0xFF, 0); +} + +//Screw this function, it's long and unreferenced and ugh +/*void sub_819A080(u16 *a0, u16 *a1, u16 a2, u16 a3, u16 a4, u16 a5, u16 a6, u16 a7) +{ + int v1 = ((a0[2] - a4) > a6) ? (a6 + a2) : (a0[2] - a4); + int v2; + + if (a0[3] - a5 < a7) + v2 = a3 + a0[3] - a5; + else + v2 = a3 + a7; + + +}*/ + +__attribute__((naked)) +void sub_819A080(u16 *a0, u16 *a1, u16 a2, u16 a3, u16 a4, u16 a5, u16 a6, u16 a7) +{ + asm("push {r4-r7,lr}\n\ + mov r7, r10\n\ + mov r6, r9\n\ + mov r5, r8\n\ + push {r5-r7}\n\ + sub sp, #0x28\n\ + str r0, [sp]\n\ + str r1, [sp, #0x4]\n\ + ldr r0, [sp, #0x48]\n\ + ldr r4, [sp, #0x4C]\n\ + ldr r1, [sp, #0x50]\n\ + ldr r5, [sp, #0x54]\n\ + lsl r2, #16\n\ + lsr r2, #16\n\ + str r2, [sp, #0x8]\n\ + lsl r3, #16\n\ + lsr r3, #16\n\ + lsl r0, #16\n\ + lsr r0, #16\n\ + str r0, [sp, #0xC]\n\ + lsl r4, #16\n\ + lsr r4, #16\n\ + lsl r1, #16\n\ + lsr r1, #16\n\ + lsl r5, #16\n\ + lsr r5, #16\n\ + ldr r2, [sp, #0x4]\n\ + ldrh r0, [r2, #0x4]\n\ + ldr r2, [sp, #0xC]\n\ + sub r0, r2\n\ + ldr r2, [sp, #0x8]\n\ + add r2, r1, r2\n\ + str r2, [sp, #0x10]\n\ + cmp r0, r1\n\ + bge _0819A0CC\n\ + ldr r1, [sp, #0x8]\n\ + add r0, r1\n\ + str r0, [sp, #0x10]\n\ +_0819A0CC:\n\ + ldr r2, [sp, #0x4]\n\ + ldrh r1, [r2, #0x6]\n\ + sub r0, r1, r4\n\ + cmp r0, r5\n\ + bge _0819A0DE\n\ + add r0, r3, r1\n\ + sub r0, r4\n\ + str r0, [sp, #0x14]\n\ + b _0819A0E2\n\ +_0819A0DE:\n\ + add r5, r3, r5\n\ + str r5, [sp, #0x14]\n\ +_0819A0E2:\n\ + ldr r0, [sp]\n\ + ldrh r1, [r0, #0x4]\n\ + mov r2, #0x7\n\ + add r0, r1, #0\n\ + and r0, r2\n\ + add r1, r0\n\ + asr r1, #3\n\ + str r1, [sp, #0x18]\n\ + ldr r0, [sp, #0x4]\n\ + ldrh r1, [r0, #0x4]\n\ + add r0, r1, #0\n\ + and r0, r2\n\ + add r1, r0\n\ + asr r1, #3\n\ + str r1, [sp, #0x1C]\n\ + mov r12, r3\n\ + mov r8, r4\n\ + ldr r1, [sp, #0x14]\n\ + cmp r12, r1\n\ + blt _0819A10C\n\ + b _0819A24A\n\ +_0819A10C:\n\ + ldr r5, [sp, #0x8]\n\ + ldr r6, [sp, #0xC]\n\ + mov r2, r12\n\ + add r2, #0x1\n\ + str r2, [sp, #0x20]\n\ + mov r0, r8\n\ + add r0, #0x1\n\ + str r0, [sp, #0x24]\n\ + ldr r1, [sp, #0x10]\n\ + cmp r5, r1\n\ + blt _0819A124\n\ + b _0819A23A\n\ +_0819A124:\n\ + mov r7, #0x1\n\ + mov r2, #0xF0\n\ + mov r10, r2\n\ + mov r0, #0xF\n\ + mov r9, r0\n\ +_0819A12E:\n\ + asr r0, r5, #1\n\ + mov r1, #0x3\n\ + and r0, r1\n\ + ldr r2, [sp]\n\ + ldr r1, [r2]\n\ + add r1, r0\n\ + asr r0, r5, #3\n\ + lsl r0, #5\n\ + add r1, r0\n\ + mov r2, r12\n\ + asr r0, r2, #3\n\ + ldr r2, [sp, #0x18]\n\ + mul r0, r2\n\ + lsl r0, #5\n\ + add r1, r0\n\ + mov r2, r12\n\ + lsl r0, r2, #29\n\ + lsr r0, #27\n\ + add r3, r1, r0\n\ + asr r0, r6, #1\n\ + mov r1, #0x3\n\ + and r0, r1\n\ + ldr r2, [sp, #0x4]\n\ + ldr r1, [r2]\n\ + add r1, r0\n\ + asr r0, r6, #3\n\ + lsl r0, #5\n\ + add r1, r0\n\ + mov r2, r8\n\ + asr r0, r2, #3\n\ + ldr r2, [sp, #0x1C]\n\ + mul r0, r2\n\ + lsl r0, #5\n\ + add r1, r0\n\ + mov r2, r8\n\ + lsl r0, r2, #29\n\ + lsr r0, #27\n\ + add r4, r1, r0\n\ + add r0, r4, #0\n\ + and r0, r7\n\ + cmp r0, #0\n\ + beq _0819A1DA\n\ + sub r4, #0x1\n\ + add r0, r6, #0\n\ + and r0, r7\n\ + cmp r0, #0\n\ + beq _0819A1B2\n\ + ldrh r0, [r4]\n\ + ldr r2, =0x00000fff\n\ + and r2, r0\n\ + add r0, r5, #0\n\ + and r0, r7\n\ + cmp r0, #0\n\ + beq _0819A1A8\n\ + ldrb r1, [r3]\n\ + mov r0, r10\n\ + and r0, r1\n\ + lsl r0, #8\n\ + b _0819A22A\n\ + .pool\n\ +_0819A1A8:\n\ + ldrb r1, [r3]\n\ + mov r0, r9\n\ + and r0, r1\n\ + lsl r0, #12\n\ + b _0819A22A\n\ +_0819A1B2:\n\ + ldrh r0, [r4]\n\ + ldr r2, =0x0000f0ff\n\ + and r2, r0\n\ + add r0, r5, #0\n\ + and r0, r7\n\ + cmp r0, #0\n\ + beq _0819A1D0\n\ + ldrb r1, [r3]\n\ + mov r0, r10\n\ + and r0, r1\n\ + lsl r0, #4\n\ + b _0819A22A\n\ + .pool\n\ +_0819A1D0:\n\ + ldrb r1, [r3]\n\ + mov r0, r9\n\ + and r0, r1\n\ + lsl r0, #8\n\ + b _0819A22A\n\ +_0819A1DA:\n\ + add r0, r6, #0\n\ + and r0, r7\n\ + cmp r0, #0\n\ + beq _0819A206\n\ + ldrh r0, [r4]\n\ + ldr r2, =0x0000ff0f\n\ + and r2, r0\n\ + add r0, r5, #0\n\ + and r0, r7\n\ + cmp r0, #0\n\ + beq _0819A1FC\n\ + ldrb r1, [r3]\n\ + mov r0, r10\n\ + b _0819A228\n\ + .pool\n\ +_0819A1FC:\n\ + ldrb r1, [r3]\n\ + mov r0, r9\n\ + and r0, r1\n\ + lsl r0, #4\n\ + b _0819A22A\n\ +_0819A206:\n\ + ldrh r0, [r4]\n\ + ldr r2, =0x0000fff0\n\ + and r2, r0\n\ + add r0, r5, #0\n\ + and r0, r7\n\ + cmp r0, #0\n\ + beq _0819A224\n\ + ldrb r1, [r3]\n\ + mov r0, r10\n\ + and r0, r1\n\ + lsr r0, #4\n\ + b _0819A22A\n\ + .pool\n\ +_0819A224:\n\ + ldrb r1, [r3]\n\ + mov r0, r9\n\ +_0819A228:\n\ + and r0, r1\n\ +_0819A22A:\n\ + orr r2, r0\n\ + strh r2, [r4]\n\ + add r5, #0x1\n\ + add r6, #0x1\n\ + ldr r0, [sp, #0x10]\n\ + cmp r5, r0\n\ + bge _0819A23A\n\ + b _0819A12E\n\ +_0819A23A:\n\ + ldr r1, [sp, #0x20]\n\ + mov r12, r1\n\ + ldr r2, [sp, #0x24]\n\ + mov r8, r2\n\ + ldr r0, [sp, #0x14]\n\ + cmp r12, r0\n\ + bge _0819A24A\n\ + b _0819A10C\n\ +_0819A24A:\n\ + add sp, #0x28\n\ + pop {r3-r5}\n\ + mov r8, r3\n\ + mov r9, r4\n\ + mov r10, r5\n\ + pop {r4-r7}\n\ + pop {r0}\n\ + bx r0\n"); +} + +void sub_819A25C(u8 palOffset, u16 speciesId) +{ + LoadPalette(GetValidMonIconPalettePtr(speciesId), palOffset, 0x20); +} + +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) +{ + const u16 *palette; + + switch (palId) + { + case 0: + default: + palette = gFireRedMenuElements1_Pal; + break; + case 1: + palette = gFireRedMenuElements2_Pal; + break; + case 2: + palette = gFireRedMenuElements3_Pal; + break; + } + + LoadPalette(palette, palOffset, 0x20); +} + +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); +} -- cgit v1.2.3 From 08516ae12ce1f1c6f8d906eed41a0f27991e704d Mon Sep 17 00:00:00 2001 From: scnorton Date: Tue, 6 Feb 2018 16:29:12 -0500 Subject: take a sharp knife and jam it into sub_819A080 --- src/menu.c | 244 +++++++++++++++++++++++++++++++++++++++---------------------- 1 file changed, 155 insertions(+), 89 deletions(-) (limited to 'src') diff --git a/src/menu.c b/src/menu.c index bcbc21a3b..675cc6c19 100644 --- a/src/menu.c +++ b/src/menu.c @@ -48,7 +48,7 @@ extern EWRAM_DATA void *gUnknown_0203CDAC[0x20]; const u16 gUnknown_0860F0B0[] = INCBIN_U16("graphics/interface/860F0B0.gbapal"); const struct TextColor gUnknown_0860F0D0[] = { 15, 1, 2 }; -const struct SomeUnkStruct gUnknown_0860F0D4[] = +const struct SomeUnkStruct gUnknown_0860F0D4[] = { { 12, 12, 0x00 }, { 32, 12, 0x20 }, @@ -339,26 +339,26 @@ u8 sub_81980F0(u8 bg, u8 xPos, u8 yPos, u8 palette, u16 baseTile) { struct WindowTemplate window; memset(&window, 0, sizeof(window)); - + if (bg > 3) window.priority = 0; else window.priority = bg; - + window.tilemapTop = yPos; window.height = 2; window.tilemapLeft = 0x1E - xPos; window.width = xPos; window.paletteNum = palette; window.baseBlock = baseTile; - + gUnknown_0203CDA0 = AddWindow(&window); - + if (palette > 15) palette = 15 * 16; else palette *= 16; - + LoadPalette(gUnknown_0860F0B0, palette, sizeof(gUnknown_0860F0B0)); return gUnknown_0203CDA0; } @@ -366,7 +366,7 @@ u8 sub_81980F0(u8 bg, u8 xPos, u8 yPos, u8 palette, u16 baseTile) void sub_8198180(const u8 *string, u8 a2, bool8 copyToVram) { u16 width = 0; - + if (gUnknown_0203CDA0 != 0xFF) { PutWindowTilemap(gUnknown_0203CDA0); @@ -388,7 +388,7 @@ void sub_8198204(const u8 *string, const u8 *string2, u8 a3, u8 a4, bool8 copyTo { struct TextColor color; u16 width = 0; - + if (gUnknown_0203CDA0 != 0xFF) { if (a3 != 0) @@ -452,7 +452,7 @@ void sub_8198314(void) u8 sub_8198348(u8 windowId, u8 fontId, u8 left, u8 top, u8 cursorHeight, u8 numChoices, u8 initialCursorPos, u8 a7) { s32 pos; - + gUnknown_0203CD90.left = left; gUnknown_0203CD90.top = top; gUnknown_0203CD90.minCursorPos = 0; @@ -461,14 +461,14 @@ u8 sub_8198348(u8 windowId, u8 fontId, u8 left, u8 top, u8 cursorHeight, u8 numC gUnknown_0203CD90.fontId = fontId; gUnknown_0203CD90.optionHeight = cursorHeight; gUnknown_0203CD90.APressMuted = a7; - + pos = initialCursorPos; - + if (pos < 0 || pos > gUnknown_0203CD90.maxCursorPos) gUnknown_0203CD90.cursorPos = 0; else gUnknown_0203CD90.cursorPos = pos; - + MoveMenuCursor(0); return gUnknown_0203CD90.cursorPos; } @@ -487,7 +487,7 @@ u8 sub_81983EC(u8 windowId, u8 fontId, u8 left, u8 top, u8 numChoices, u8 initia void RedrawMenuCursor(u8 oldPos, u8 newPos) { u8 width, height; - + width = GetMenuCursorDimensionByFont(gUnknown_0203CD90.fontId, 0); height = GetMenuCursorDimensionByFont(gUnknown_0203CD90.fontId, 1); FillWindowPixelRect(gUnknown_0203CD90.windowId, 0x11, gUnknown_0203CD90.left, gUnknown_0203CD90.optionHeight * oldPos + gUnknown_0203CD90.top, width, height); @@ -498,14 +498,14 @@ u8 MoveMenuCursor(s8 cursorDelta) { u8 oldPos = gUnknown_0203CD90.cursorPos; int newPos = gUnknown_0203CD90.cursorPos + cursorDelta; - + if (newPos < gUnknown_0203CD90.minCursorPos) gUnknown_0203CD90.cursorPos = gUnknown_0203CD90.maxCursorPos; else if (newPos > gUnknown_0203CD90.maxCursorPos) gUnknown_0203CD90.cursorPos = gUnknown_0203CD90.minCursorPos; else gUnknown_0203CD90.cursorPos += cursorDelta; - + RedrawMenuCursor(oldPos, gUnknown_0203CD90.cursorPos); return gUnknown_0203CD90.cursorPos; } @@ -514,14 +514,14 @@ u8 MoveMenuCursorNoWrapAround(s8 cursorDelta) { u8 oldPos = gUnknown_0203CD90.cursorPos; int newPos = gUnknown_0203CD90.cursorPos + cursorDelta; - + if (newPos < gUnknown_0203CD90.minCursorPos) gUnknown_0203CD90.cursorPos = gUnknown_0203CD90.minCursorPos; else if (newPos > gUnknown_0203CD90.maxCursorPos) gUnknown_0203CD90.cursorPos = gUnknown_0203CD90.maxCursorPos; else gUnknown_0203CD90.cursorPos += cursorDelta; - + RedrawMenuCursor(oldPos, gUnknown_0203CD90.cursorPos); return gUnknown_0203CD90.cursorPos; } @@ -562,7 +562,7 @@ s8 ProcessMenuInput(void) s8 ProcessMenuInputNoWrapAround(void) { u8 oldPos = gUnknown_0203CD90.cursorPos; - + if (gMain.newKeys & A_BUTTON) { if (!gUnknown_0203CD90.APressMuted) @@ -620,7 +620,7 @@ s8 ProcessMenuInput_other(void) s8 ProcessMenuInputNoWrapAround_other(void) { u8 oldPos = gUnknown_0203CD90.cursorPos; - + if (gMain.newKeys & A_BUTTON) { if (!gUnknown_0203CD90.APressMuted) @@ -676,7 +676,7 @@ void AddItemMenuActionTextPrinters(u8 windowId, u8 fontId, u8 left, u8 top, u8 l { u8 i; struct TextSubPrinter printer; - + printer.windowId = windowId; printer.fontId = fontId; printer.fgColor = GetFontAttribute(fontId, 5); @@ -687,7 +687,7 @@ void AddItemMenuActionTextPrinters(u8 windowId, u8 fontId, u8 left, u8 top, u8 l printer.lineSpacing = GetFontAttribute(fontId, 3); printer.x = left; printer.currentX = left; - + for (i = 0; i < itemCount; i++) { printer.current_text_offset = strs[a8[i]].text; @@ -695,7 +695,7 @@ void AddItemMenuActionTextPrinters(u8 windowId, u8 fontId, u8 left, u8 top, u8 l printer.currentY = printer.y; AddTextPrinter(&printer, 0xFF, NULL); } - + CopyWindowToVram(windowId, 2); } @@ -732,10 +732,10 @@ u16 sub_8198AA4(u8 bg, u8 left, u8 top, u8 width, u8 height, u8 paletteNum, u16 void sub_8198AF8(const struct WindowTemplate *window, u8 fontId, u8 left, u8 top, u16 baseTileNum, u8 paletteNum, u8 initialCursorPos) { struct TextSubPrinter printer; - + gUnknown_0203CD9F = AddWindow(window); SetWindowBorderStyle(gUnknown_0203CD9F, TRUE, baseTileNum, paletteNum); - + printer.current_text_offset = gText_YesNo; printer.windowId = gUnknown_0203CD9F; printer.fontId = fontId; @@ -749,9 +749,9 @@ void sub_8198AF8(const struct WindowTemplate *window, u8 fontId, u8 left, u8 top printer.fontColor_l = GetFontAttribute(fontId, 4); printer.letterSpacing = GetFontAttribute(fontId, 2); printer.lineSpacing = GetFontAttribute(fontId, 3); - + AddTextPrinter(&printer, 0xFF, NULL); - + sub_81983AC(gUnknown_0203CD9F, fontId, left, top, GetFontAttribute(fontId, 1), 2, initialCursorPos); } @@ -798,7 +798,7 @@ void sub_8198DBC(u8 windowId, u8 fontId, u8 left, u8 top, u8 a4, u8 itemCount, u u8 i; u8 j; struct TextSubPrinter printer; - + printer.windowId = windowId; printer.fontId = fontId; printer.fgColor = GetFontAttribute(fontId, 5); @@ -807,7 +807,7 @@ void sub_8198DBC(u8 windowId, u8 fontId, u8 left, u8 top, u8 a4, u8 itemCount, u printer.fontColor_l = GetFontAttribute(fontId, 4); printer.letterSpacing = GetFontAttribute(fontId, 2); printer.lineSpacing = GetFontAttribute(fontId, 3); - + for (i = 0; i < itemCount2; i++) { for (j = 0; j < itemCount; j++) @@ -820,7 +820,7 @@ void sub_8198DBC(u8 windowId, u8 fontId, u8 left, u8 top, u8 a4, u8 itemCount, u AddTextPrinter(&printer, 0xFF, NULL); } } - + CopyWindowToVram(windowId, 2); } @@ -832,7 +832,7 @@ void sub_8198EF8(u8 windowId, u8 fontId, u8 a2, u8 a3, u8 a4, u8 a5, const struc u8 sub_8198F58(u8 windowId, u8 fontId, u8 left, u8 top, u8 a4, u8 cursorHeight, u8 a6, u8 a7, u8 numChoices, u8 a9) { s32 pos; - + gUnknown_0203CD90.left = left; gUnknown_0203CD90.top = top; gUnknown_0203CD90.minCursorPos = 0; @@ -843,14 +843,14 @@ u8 sub_8198F58(u8 windowId, u8 fontId, u8 left, u8 top, u8 a4, u8 cursorHeight, gUnknown_0203CD90.optionHeight = cursorHeight; gUnknown_0203CD90.horizontalCount = a6; gUnknown_0203CD90.verticalCount = a7; - + pos = a9; - + if (pos < 0 || pos > gUnknown_0203CD90.maxCursorPos) gUnknown_0203CD90.cursorPos = 0; else gUnknown_0203CD90.cursorPos = pos; - + sub_8199134(0, 0); return gUnknown_0203CD90.cursorPos; } @@ -888,7 +888,7 @@ void sub_8199060(u8 oldCursorPos, u8 newCursorPos) u8 sub_8199134(s8 deltaX, s8 deltaY) { u8 oldPos = gUnknown_0203CD90.cursorPos; - + if (deltaX != 0) { if ((gUnknown_0203CD90.cursorPos % gUnknown_0203CD90.horizontalCount) + deltaX < 0) @@ -904,7 +904,7 @@ u8 sub_8199134(s8 deltaX, s8 deltaY) gUnknown_0203CD90.cursorPos += deltaX; } } - + if (deltaY != 0) { if ((gUnknown_0203CD90.cursorPos / gUnknown_0203CD90.horizontalCount) + deltaY < 0) @@ -920,7 +920,7 @@ u8 sub_8199134(s8 deltaX, s8 deltaY) gUnknown_0203CD90.cursorPos += (gUnknown_0203CD90.horizontalCount * deltaY); } } - + if (gUnknown_0203CD90.cursorPos > gUnknown_0203CD90.maxCursorPos) { gUnknown_0203CD90.cursorPos = oldPos; @@ -936,7 +936,7 @@ u8 sub_8199134(s8 deltaX, s8 deltaY) u8 sub_81991F8(s8 deltaX, s8 deltaY) { u8 oldPos = gUnknown_0203CD90.cursorPos; - + if (deltaX != 0) { if (((gUnknown_0203CD90.cursorPos % gUnknown_0203CD90.horizontalCount) + deltaX >= 0) && @@ -945,7 +945,7 @@ u8 sub_81991F8(s8 deltaX, s8 deltaY) gUnknown_0203CD90.cursorPos += deltaX; } } - + if (deltaY != 0) { if (((gUnknown_0203CD90.cursorPos / gUnknown_0203CD90.horizontalCount) + deltaY >= 0) && @@ -954,7 +954,7 @@ u8 sub_81991F8(s8 deltaX, s8 deltaY) gUnknown_0203CD90.cursorPos += (gUnknown_0203CD90.horizontalCount * deltaY); } } - + if (gUnknown_0203CD90.cursorPos > gUnknown_0203CD90.maxCursorPos) { gUnknown_0203CD90.cursorPos = oldPos; @@ -1009,7 +1009,7 @@ s8 sub_8199284(void) s8 sub_8199334(void) { u8 oldPos = gUnknown_0203CD90.cursorPos; - + if (gMain.newKeys & A_BUTTON) { PlaySE(SE_SELECT); @@ -1089,7 +1089,7 @@ s8 sub_81993D8(void) s8 sub_8199484(void) { u8 oldPos = gUnknown_0203CD90.cursorPos; - + if (gMain.newKeys & A_BUTTON) { PlaySE(SE_SELECT); @@ -1130,7 +1130,7 @@ s8 sub_8199484(void) u8 InitMenuInUpperLeftCorner(u8 windowId, u8 itemCount, u8 initialCursorPos, bool8 APressMuted) { s32 pos; - + gUnknown_0203CD90.left = 0; gUnknown_0203CD90.top = 1; gUnknown_0203CD90.minCursorPos = 0; @@ -1139,14 +1139,14 @@ u8 InitMenuInUpperLeftCorner(u8 windowId, u8 itemCount, u8 initialCursorPos, boo gUnknown_0203CD90.fontId = 1; gUnknown_0203CD90.optionHeight = 16; gUnknown_0203CD90.APressMuted = APressMuted; - + pos = initialCursorPos; - + if (pos < 0 || pos > gUnknown_0203CD90.maxCursorPos) gUnknown_0203CD90.cursorPos = 0; else gUnknown_0203CD90.cursorPos = pos; - + return MoveMenuCursor(0); } @@ -1158,12 +1158,12 @@ u8 InitMenuInUpperLeftCornerPlaySoundWhenAPressed(u8 windowId, u8 itemCount, u8 void PrintMenuTable(u8 windowId, u8 itemCount, const struct MenuAction *strs) { u32 i; - + for (i = 0; i < itemCount; i++) { PrintTextOnWindow(windowId, 1, strs[i].text, 8, (i * 16) + 1, 0xFF, NULL); } - + CopyWindowToVram(windowId, 2); } @@ -1171,7 +1171,7 @@ void sub_81995E4(u8 windowId, u8 itemCount, const struct MenuAction *strs, const { u8 i; struct TextSubPrinter printer; - + printer.windowId = windowId; printer.fontId = 1; printer.fgColor = GetFontAttribute(1, 5); @@ -1182,7 +1182,7 @@ void sub_81995E4(u8 windowId, u8 itemCount, const struct MenuAction *strs, const printer.lineSpacing = 0; printer.x = 8; printer.currentX = 8; - + for (i = 0; i < itemCount; i++) { printer.current_text_offset = strs[a8[i]].text; @@ -1190,17 +1190,17 @@ void sub_81995E4(u8 windowId, u8 itemCount, const struct MenuAction *strs, const printer.currentY = (i * 16) + 1; AddTextPrinter(&printer, 0xFF, NULL); } - + CopyWindowToVram(windowId, 2); } void CreateYesNoMenu(const struct WindowTemplate *window, u16 baseTileNum, u8 paletteNum, u8 initialCursorPos) { struct TextSubPrinter printer; - + gUnknown_0203CD9F = AddWindow(window); SetWindowBorderStyle(gUnknown_0203CD9F, TRUE, baseTileNum, paletteNum); - + printer.current_text_offset = gText_YesNo; printer.windowId = gUnknown_0203CD9F; printer.fontId = 1; @@ -1214,7 +1214,7 @@ void CreateYesNoMenu(const struct WindowTemplate *window, u16 baseTileNum, u8 pa printer.fontColor_l = GetFontAttribute(1, 4); printer.letterSpacing = 0; printer.lineSpacing = 0; - + AddTextPrinter(&printer, 0xFF, NULL); InitMenuInUpperLeftCornerPlaySoundWhenAPressed(gUnknown_0203CD9F, 2, initialCursorPos); } @@ -1238,7 +1238,7 @@ void sub_819983C(u8 windowId, u8 a4, u8 itemCount, u8 itemCount2, const struct M u8 i; u8 j; struct TextSubPrinter printer; - + printer.windowId = windowId; printer.fontId = 1; printer.fgColor = GetFontAttribute(1, 5); @@ -1247,7 +1247,7 @@ void sub_819983C(u8 windowId, u8 a4, u8 itemCount, u8 itemCount2, const struct M printer.fontColor_l = GetFontAttribute(1, 4); printer.letterSpacing = 0; printer.lineSpacing = 0; - + for (i = 0; i < itemCount2; i++) { for (j = 0; j < itemCount; j++) @@ -1260,14 +1260,14 @@ void sub_819983C(u8 windowId, u8 a4, u8 itemCount, u8 itemCount2, const struct M AddTextPrinter(&printer, 0xFF, NULL); } } - + CopyWindowToVram(windowId, 2); } u8 sub_8199944(u8 windowId, u8 optionWidth, u8 horizontalCount, u8 verticalCount, u8 initialCursorPos) { s32 pos; - + gUnknown_0203CD90.left = 0; gUnknown_0203CD90.top = 1; gUnknown_0203CD90.minCursorPos = 0; @@ -1278,14 +1278,14 @@ u8 sub_8199944(u8 windowId, u8 optionWidth, u8 horizontalCount, u8 verticalCount gUnknown_0203CD90.optionHeight = 16; gUnknown_0203CD90.horizontalCount = horizontalCount; gUnknown_0203CD90.verticalCount = verticalCount; - + pos = initialCursorPos; - + if (pos < 0 || pos > gUnknown_0203CD90.maxCursorPos) gUnknown_0203CD90.cursorPos = 0; else gUnknown_0203CD90.cursorPos = pos; - + sub_8199134(0, 0); return gUnknown_0203CD90.cursorPos; } @@ -1337,7 +1337,7 @@ void reset_temp_tile_data_buffers(void) bool8 free_temp_tile_data_buffers_if_possible(void) { int i; - + if (!IsDma3ManagerBusyWithBgCopy()) { if (gUnknown_0203CDA8) @@ -1402,12 +1402,12 @@ void *malloc_and_decompress(const void *src, int *size) void *ptr; u8 *sizeAsBytes = (u8 *)size; u8 *srcAsBytes = (u8 *)src; - + sizeAsBytes[0] = srcAsBytes[1]; sizeAsBytes[1] = srcAsBytes[2]; sizeAsBytes[2] = srcAsBytes[3]; sizeAsBytes[3] = 0; - + ptr = Alloc(*size); if (ptr) LZ77UnCompWram(src, ptr); @@ -1432,7 +1432,7 @@ void sub_8199C30(u8 bgId, u8 left, u8 top, u8 width, u8 height, u8 palette) u8 i; u8 j; u16 *ptr = GetBgTilemapBuffer(bgId); - + for (i = top; i < top + height; i++) { for (j = left; j < left + width; j++) @@ -1447,7 +1447,7 @@ void sub_8199CBC(u8 bgId, u16 *dest, u8 left, u8 top, u8 width, u8 height) u8 i; u8 j; const u16 *src = GetBgTilemapBuffer(bgId); - + for (i = 0; i < height; i++) { for (j = 0; j < width; j++) @@ -1501,7 +1501,7 @@ void sub_8199DF0(u32 bg, u8 a1, int a2, int a3) void box_print(u8 windowId, u8 fontId, u8 left, u8 top, const struct TextColor *color, s8 speed, const u8 *str) { struct TextSubPrinter printer; - + printer.current_text_offset = str; printer.windowId = windowId; printer.fontId = fontId; @@ -1515,14 +1515,14 @@ void box_print(u8 windowId, u8 fontId, u8 left, u8 top, const struct TextColor * printer.fgColor = color->bgColor; printer.bgColor = color->fgColor; printer.shadowColor = color->shadowColor; - + AddTextPrinter(&printer, speed, NULL); } void AddTextPrinterParameterized2(u8 windowId, u8 fontId, u8 left, u8 top, u8 letterSpacing, u8 lineSpacing, const struct TextColor *color, s8 speed, const u8 *str) { struct TextSubPrinter printer; - + printer.current_text_offset = str; printer.windowId = windowId; printer.fontId = fontId; @@ -1536,14 +1536,14 @@ void AddTextPrinterParameterized2(u8 windowId, u8 fontId, u8 left, u8 top, u8 le printer.fgColor = color->bgColor; printer.bgColor = color->fgColor; printer.shadowColor = color->shadowColor; - + AddTextPrinter(&printer, speed, NULL); } 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) { struct TextSubPrinter printer; - + printer.current_text_offset = str; printer.windowId = windowId; printer.fontId = fontId; @@ -1554,11 +1554,11 @@ void sub_8199F74(u8 windowId, u8 fontId, const u8 *str, u8 left, u8 top, u8 spee printer.letterSpacing = letterSpacing; printer.lineSpacing = lineSpacing; printer.fontColor_l = 0; - + printer.fgColor = GetFontAttribute(fontId, 5); printer.bgColor = GetFontAttribute(fontId, 6); printer.shadowColor = GetFontAttribute(fontId, 7); - + AddTextPrinter(&printer, speed, callback); } @@ -1567,28 +1567,93 @@ void sub_819A024(u8 windowId, const u8 *src, u16 a2, u16 a3) int count = 0; while (gSaveBlock2Ptr->playerName[count] != EOS) count++; - + StringExpandPlaceholders(gStringVar4, src); - + PrintTextOnWindow(windowId, 1, gStringVar4, a2, a3, 0xFF, 0); } //Screw this function, it's long and unreferenced and ugh -/*void sub_819A080(u16 *a0, u16 *a1, u16 a2, u16 a3, u16 a4, u16 a5, u16 a6, u16 a7) -{ - int v1 = ((a0[2] - a4) > a6) ? (a6 + a2) : (a0[2] - a4); - int v2; - - if (a0[3] - a5 < a7) - v2 = a3 + a0[3] - a5; - else - v2 = a3 + a7; - - -}*/ +struct UnkStruct_819A080 { + u8 *unk00; + u16 unk04; + u16 unk06; +}; + +#ifdef NONMATCHING +void sub_819A080(struct UnkStruct_819A080 *a0, struct UnkStruct_819A080 *a1, u16 a2, u16 a3, u16 a4, u16 a5, u16 a6, u16 a7) +{ + // r3 = a3 + // r4 = a5 + // r1 = a6 + // r5 = a7 + // sp+00 = a0 + // sp+04 = a1 + // sp+08 = a2 + // sp+0c = a4 + int sp10 = a1->unk04 - a4 > a6 ? a6 + a2 : a1->unk04 - a4; + int sp14 = a0->unk06 - a5 < a7 ? a3 + a0->unk06 - a5 : a3 + a7; + int sp18 = (a0->unk04 + (a0->unk04 & 0x7)) / 8; + int sp1c = (a1->unk04 + (a1->unk04 & 0x7)) / 8; + int r12; // sp+20 + int r8; // sp+24 + int r5; + int r6; + u16 r2; + + for (r12 = a3, r8 = a5; r12 < sp14; r12++, r8++) + { + for (r5 = a2, r6 = a4; a5 < sp10; a5++, a6++) + { + u8 *r3 = a0->unk00 + ((r5 >> 1) & 0x3) + ((r5 >> 3) << 5) + (((r12 >> 3) * sp18) << 5) + ((r12 & 0x7) << 2); + u8 *r4 = a1->unk00 + ((r6 >> 1) & 0x3) + ((r6 >> 3) << 5) + (((r8 >> 3) * sp1c) << 5) + ((r8 & 0x7) << 2); + if (((uintptr_t)r4) & 0x1) + { + u16 *r4_2 = (u16 *)(r4 - 1); + if (r6 & 0x1) + { + r2 = *r4_2 & 0x0fff; + if (r5 & 0x1) + *r4_2 = r2 | ((*r3 & 0xf0) << 8); + else + *r4_2 = r2 | ((*r3 & 0x0f) << 12); + } + else + { + r2 = *r4_2 * 0xf0ff; + if (r5 & 0x1) + *r4_2 = r2 | ((*r3 & 0xf0) << 4); + else + *r4_2 = r2 | ((*r3 & 0x0f) << 8); + } + } + else + { + u16 *r4_2 = (u16 *)r4; + if (r6 & 1) + { + r2 = *r4_2 & 0xff0f; + if (r5 & 1) + *r4_2 = r2 | ((*r3 & 0xf0) << 0); + else + *r4_2 = r2 | ((*r3 & 0x0f) << 4); + } + else + { + r2 = *r4_2 & 0xfff0; + if (r5 & 1) + *r4_2 = r2 | ((*r3 & 0xf0) >> 4); + else + *r4_2 = r2 | ((*r3 & 0x0f) >> 0); + } + } + } + } +} +#else __attribute__((naked)) -void sub_819A080(u16 *a0, u16 *a1, u16 a2, u16 a3, u16 a4, u16 a5, u16 a6, u16 a7) +void sub_819A080(truct 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\ mov r7, r10\n\ @@ -1838,6 +1903,7 @@ _0819A24A:\n\ pop {r0}\n\ bx r0\n"); } +#endif void sub_819A25C(u8 palOffset, u16 speciesId) { @@ -1852,7 +1918,7 @@ void sub_819A27C(u8 windowId, u16 speciesId, u32 personality, u16 x, u16 y) void sub_819A2BC(u8 palOffset, u8 palId) { const u16 *palette; - + switch (palId) { case 0: @@ -1866,7 +1932,7 @@ void sub_819A2BC(u8 palOffset, u8 palId) palette = gFireRedMenuElements3_Pal; break; } - + LoadPalette(palette, palOffset, 0x20); } -- cgit v1.2.3 From 18abda9dca7e38a1dee63ff0d167e1e2601504bf Mon Sep 17 00:00:00 2001 From: Diegoisawesome Date: Tue, 6 Feb 2018 20:37:54 -0600 Subject: Finish menu.s and eliminate TextColor --- src/battle_interface.c | 10 +++--- src/berry_blender.c | 24 ++++++------- src/diploma.c | 11 ++---- src/egg_hatch.c | 10 +++--- src/menu.c | 86 ++++++++++++++++++++++++++++++++++---------- src/naming_screen.c | 31 ++++++++-------- src/pokeblock.c | 4 +-- src/pokemon_storage_system.c | 2 +- src/pokemon_summary_screen.c | 6 ++-- src/save_failed_screen.c | 10 +++--- src/window.c | 2 +- 11 files changed, 120 insertions(+), 76 deletions(-) (limited to 'src') diff --git a/src/battle_interface.c b/src/battle_interface.c index 2338682e2..0917f0cfc 100644 --- a/src/battle_interface.c +++ b/src/battle_interface.c @@ -2565,17 +2565,17 @@ u8 GetHPBarLevel(s16 hp, s16 maxhp) static u8* AddTextPrinterAndCreateWindowOnHealthbox(const u8 *str, u32 x, u32 y, u32 arg3, u32 *windowId) { u16 winId; - struct TextColor color; + u8 color[3]; struct WindowTemplate winTemplate = sHealthboxWindowTemplate; winId = AddWindow(&winTemplate); FillWindowPixelBuffer(winId, (arg3 << 4) | (arg3)); - color.fgColor = arg3; - color.bgColor = 1; - color.shadowColor = 3; + color[0] = arg3; + color[1] = 1; + color[2] = 3; - AddTextPrinterParameterized2(winId, 0, x, y, 0, 0, &color, -1, str); + AddTextPrinterParameterized2(winId, 0, x, y, 0, 0, color, -1, str); *windowId = winId; return (u8*)(GetWindowAttribute(winId, WINDOW_TILE_DATA)); diff --git a/src/berry_blender.c b/src/berry_blender.c index 3494492de..a9360ca5f 100644 --- a/src/berry_blender.c +++ b/src/berry_blender.c @@ -3574,35 +3574,35 @@ static bool32 TryAddContestLinkTvShow(struct Pokeblock *pokeblock, struct TvBlen static void Blender_AddTextPrinter(u8 windowId, const u8 *string, u8 x, u8 y, s32 speed, s32 caseId) { - struct TextColor txtColor; + u8 txtColor[3]; u32 letterSpacing = 0; switch (caseId) { case 0: case 3: - txtColor.fgColor = 1; - txtColor.bgColor = 2; - txtColor.shadowColor = 3; + txtColor[0] = 1; + txtColor[1] = 2; + txtColor[2] = 3; break; case 1: - txtColor.fgColor = 0; - txtColor.bgColor = 2; - txtColor.shadowColor = 3; + txtColor[0] = 0; + txtColor[1] = 2; + txtColor[2] = 3; break; case 2: - txtColor.fgColor = 0; - txtColor.bgColor = 4; - txtColor.shadowColor = 5; + txtColor[0] = 0; + txtColor[1] = 4; + txtColor[2] = 5; break; } if (caseId != 3) { - FillWindowPixelBuffer(windowId, txtColor.fgColor | (txtColor.fgColor << 4)); + FillWindowPixelBuffer(windowId, txtColor[0] | (txtColor[0] << 4)); } - AddTextPrinterParameterized2(windowId, 1, x, y, letterSpacing, 1, &txtColor, speed, string); + AddTextPrinterParameterized2(windowId, 1, x, y, letterSpacing, 1, txtColor, speed, string); } static bool32 Blender_PrintText(s16 *textState, const u8 *string, s32 textSpeed) diff --git a/src/diploma.c b/src/diploma.c index 24e5e9727..987596227 100644 --- a/src/diploma.c +++ b/src/diploma.c @@ -17,7 +17,7 @@ extern int decompress_and_copy_tile_data_to_vram(u8 bg_id, void *src, int size, extern bool8 free_temp_tile_data_buffers_if_possible(void); extern void sub_80861E8(void); // rom4 extern bool16 sub_80C0944(void); -extern void AddTextPrinterParameterized2(u8 windowId, u8 fontId, u8 x, u8 y, u8 letterSpacing, u8 lineSpacing, struct TextColor *color, s8 speed, u8 *str); +extern void AddTextPrinterParameterized2(u8 windowId, u8 fontId, u8 x, u8 y, u8 letterSpacing, u8 lineSpacing, u8 *color, s8 speed, u8 *str); extern u16 gUnknown_0860F074[]; @@ -208,12 +208,7 @@ static void InitDiplomaWindow(void) static void PrintDiplomaText(u8 *text, u8 var1, u8 var2) { - struct TextColor color = - { - .fgColor = 0, - .bgColor = 2, - .shadowColor = 3, - }; + u8 color[3] = {0, 2, 3}; - AddTextPrinterParameterized2(0, 1, var1, var2, 0, 0, &color, -1, text); + AddTextPrinterParameterized2(0, 1, var1, var2, 0, 0, color, -1, text); } diff --git a/src/egg_hatch.c b/src/egg_hatch.c index 435886638..c78cb2c08 100644 --- a/src/egg_hatch.c +++ b/src/egg_hatch.c @@ -41,7 +41,7 @@ struct EggHatchData u8 unused_9; u8 unused_A; u16 species; - struct TextColor textColor; + u8 textColor[3]; }; extern struct SpriteTemplate gUnknown_0202499C; @@ -863,10 +863,10 @@ static void CreateEggShardSprite(u8 x, u8 y, s16 data1, s16 data2, s16 data3, u8 static void EggHatchPrintMessage(u8 windowId, u8* string, u8 x, u8 y, u8 speed) { FillWindowPixelBuffer(windowId, 0xFF); - sEggHatchData->textColor.fgColor = 0; - sEggHatchData->textColor.bgColor = 5; - sEggHatchData->textColor.shadowColor = 6; - AddTextPrinterParameterized2(windowId, 1, x, y, 0, 0, &sEggHatchData->textColor, speed, string); + sEggHatchData->textColor[0] = 0; + sEggHatchData->textColor[1] = 5; + sEggHatchData->textColor[2] = 6; + AddTextPrinterParameterized2(windowId, 1, x, y, 0, 0, sEggHatchData->textColor, speed, string); } u8 GetEggStepsToSubtract(void) diff --git a/src/menu.c b/src/menu.c index bcbc21a3b..4916c00ea 100644 --- a/src/menu.c +++ b/src/menu.c @@ -13,6 +13,10 @@ #include "dma3.h" #include "string_util.h" #include "pokemon_icon.h" +#include "constants/flags.h" +#include "event_data.h" +#include "pokedex.h" +#include "region_map.h" struct SomeUnkStruct { @@ -47,7 +51,7 @@ extern EWRAM_DATA u16 gUnknown_0203CDA8; extern EWRAM_DATA void *gUnknown_0203CDAC[0x20]; const u16 gUnknown_0860F0B0[] = INCBIN_U16("graphics/interface/860F0B0.gbapal"); -const struct TextColor gUnknown_0860F0D0[] = { 15, 1, 2 }; +const u8 gUnknown_0860F0D0[] = { 15, 1, 2 }; const struct SomeUnkStruct gUnknown_0860F0D4[] = { { 12, 12, 0x00 }, @@ -386,22 +390,22 @@ void sub_8198180(const u8 *string, u8 a2, bool8 copyToVram) void sub_8198204(const u8 *string, const u8 *string2, u8 a3, u8 a4, bool8 copyToVram) { - struct TextColor color; + u8 color[3]; u16 width = 0; if (gUnknown_0203CDA0 != 0xFF) { if (a3 != 0) { - color.fgColor = 0; - color.bgColor = 1; - color.shadowColor = 2; + color[0] = 0; + color[1] = 1; + color[2] = 2; } else { - color.fgColor = 15; - color.bgColor = 1; - color.shadowColor = 2; + color[0] = 15; + color[1] = 1; + color[2] = 2; } PutWindowTilemap(gUnknown_0203CDA0); FillWindowPixelBuffer(gUnknown_0203CDA0, 0xFF); @@ -412,11 +416,11 @@ void sub_8198204(const u8 *string, const u8 *string2, u8 a3, u8 a4, bool8 copyTo 0, 0xEC - (GetWindowAttribute(gUnknown_0203CDA0, WINDOW_TILEMAP_LEFT) * 8) - a4 - width, 1, - &color, + color, 0, string2); } - AddTextPrinterParameterized2(gUnknown_0203CDA0, 1, 4, 1, 0, 0, &color, 0, string); + AddTextPrinterParameterized2(gUnknown_0203CDA0, 1, 4, 1, 0, 0, color, 0, string); if (copyToVram) CopyWindowToVram(gUnknown_0203CDA0, 3); } @@ -1498,7 +1502,7 @@ void sub_8199DF0(u32 bg, u8 a1, int a2, int a3) RequestDma3Fill(a1 << 24 | a1 << 16 | a1 << 8 | a1, addr + VRAM, a3 * temp, 1); } -void box_print(u8 windowId, u8 fontId, u8 left, u8 top, const struct TextColor *color, s8 speed, const u8 *str) +void box_print(u8 windowId, u8 fontId, u8 left, u8 top, const u8 *color, s8 speed, const u8 *str) { struct TextSubPrinter printer; @@ -1512,14 +1516,14 @@ void box_print(u8 windowId, u8 fontId, u8 left, u8 top, const struct TextColor * printer.letterSpacing = GetFontAttribute(fontId, 2); printer.lineSpacing = GetFontAttribute(fontId, 3); printer.fontColor_l = 0; - printer.fgColor = color->bgColor; - printer.bgColor = color->fgColor; - printer.shadowColor = color->shadowColor; + printer.fgColor = color[1]; + printer.bgColor = color[0]; + printer.shadowColor = color[2]; AddTextPrinter(&printer, speed, NULL); } -void AddTextPrinterParameterized2(u8 windowId, u8 fontId, u8 left, u8 top, u8 letterSpacing, u8 lineSpacing, const struct TextColor *color, s8 speed, const u8 *str) +void AddTextPrinterParameterized2(u8 windowId, u8 fontId, u8 left, u8 top, u8 letterSpacing, u8 lineSpacing, const u8 *color, s8 speed, const u8 *str) { struct TextSubPrinter printer; @@ -1533,9 +1537,9 @@ void AddTextPrinterParameterized2(u8 windowId, u8 fontId, u8 left, u8 top, u8 le printer.letterSpacing = letterSpacing; printer.lineSpacing = lineSpacing; printer.fontColor_l = 0; - printer.fgColor = color->bgColor; - printer.bgColor = color->fgColor; - printer.shadowColor = color->shadowColor; + printer.fgColor = color[1]; + printer.bgColor = color[0]; + printer.shadowColor = color[2]; AddTextPrinter(&printer, speed, NULL); } @@ -1874,3 +1878,49 @@ 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); } + +void sub_819A344(u8 a0, u8 *a1, u8 a2) +{ + s32 curFlag; + s32 flagCount; + u8 *endOfString; + u8 *string = a1; + + *(string++) = EXT_CTRL_CODE_BEGIN; + *(string++) = EXT_CTRL_CODE_COLOR; + *(string++) = a2; + *(string++) = EXT_CTRL_CODE_BEGIN; + *(string++) = EXT_CTRL_CODE_SHADOW; + *(string++) = a2 + 1; + + switch (a0) + { + case 0: + StringCopy(string, gSaveBlock2Ptr->playerName); + break; + case 1: + if (IsNationalPokedexEnabled()) + string = ConvertIntToDecimalStringN(string, pokedex_count(1), 0, 3); + else + string = ConvertIntToDecimalStringN(string, sub_80C0844(1), 0, 3); + *string = EOS; + break; + case 2: + string = ConvertIntToDecimalStringN(string, gSaveBlock2Ptr->playTimeHours, 0, 3); + *(string++) = CHAR_COLON; + ConvertIntToDecimalStringN(string, gSaveBlock2Ptr->playTimeMinutes, 2, 2); + break; + case 3: + sub_81245DC(string, gMapHeader.regionMapSectionId); + break; + case 4: + for (curFlag = FLAG_BADGE01_GET, flagCount = 0, endOfString = string + 1; curFlag <= FLAG_BADGE08_GET; curFlag++) + { + if (FlagGet(curFlag)) + flagCount++; + } + *string = flagCount + CHAR_0; + *endOfString = EOS; + break; + } +} diff --git a/src/naming_screen.c b/src/naming_screen.c index 9a5cec1e0..917782e88 100644 --- a/src/naming_screen.c +++ b/src/naming_screen.c @@ -1496,7 +1496,7 @@ static void TaskDummy3(void) } -static const struct TextColor sGenderColors[2] = +static const u8 sGenderColors[2][3] = { {0, 9, 8}, {0, 5, 4} @@ -1516,7 +1516,7 @@ static void sub_80E49BC(void) StringCopy(genderSymbol, gText_FemaleSymbol); isFemale = TRUE; } - box_print(gNamingScreenData->windows[2], 1, 0x68, 1, &sGenderColors[isFemale], -1, genderSymbol); + box_print(gNamingScreenData->windows[2], 1, 0x68, 1, sGenderColors[isFemale], -1, genderSymbol); } } @@ -1661,19 +1661,18 @@ static void sub_80E4D10(void) PutWindowTilemap(gNamingScreenData->windows[2]); } -static const struct AlignedTextColor sUnkColor1 = +struct TextColorThing // needed because of alignment... it's so stupid { - 13, 1, 2 + u8 colors[3][4]; }; -static const struct AlignedTextColor sUnkColor2 = +static const struct TextColorThing sUnkColorStruct = { - 14, 1, 2 -}; - -static const struct AlignedTextColor sUnkColor3 = -{ - 15, 1, 2 + { + {13, 1, 2}, + {14, 1, 2}, + {15, 1, 2} + } }; static const u8 sFillValues[3] = @@ -1681,11 +1680,11 @@ static const u8 sFillValues[3] = 0xEE, 0xDD, 0xFF }; -static const struct AlignedTextColor *const sUnkColors[3] = +static const u8 *const sUnkColors[3] = { - &sUnkColor2, - &sUnkColor1, - &sUnkColor3 + sUnkColorStruct.colors[1], + sUnkColorStruct.colors[0], + sUnkColorStruct.colors[2] }; static void sub_80E4DE4(u8 window, u8 a1) @@ -1738,7 +1737,7 @@ static void sub_80E4E5C(void) static void sub_80E4EF0(void) { - const struct TextColor color[] = { 15, 1, 2 }; + const u8 color[3] = { 15, 1, 2 }; FillWindowPixelBuffer(gNamingScreenData->windows[4], 0xFF); box_print(gNamingScreenData->windows[4], 0, 2, 1, color, 0, gText_MoveOkBack); diff --git a/src/pokeblock.c b/src/pokeblock.c index 1a4ce3155..c20c8c643 100644 --- a/src/pokeblock.c +++ b/src/pokeblock.c @@ -284,7 +284,7 @@ static const struct SpriteTemplate sSpriteTemplate_PokeblockCase = SpriteCallbackDummy }; -static const struct TextColor sTextColorInPokeblockMenu = {0, 2, 3}; +static const u8 sTextColorInPokeblockMenu[3] = {0, 2, 3}; static const struct Pokeblock sFavoritePokeblocksTable[] = { @@ -583,7 +583,7 @@ static void HandleInitWindows(void) static void PrintOnPokeblockWindow(u8 windowId, const u8 *string, s32 x) { - AddTextPrinterParameterized2(windowId, 1, x, 1, 0, 0, &sTextColorInPokeblockMenu, 0, string); + AddTextPrinterParameterized2(windowId, 1, x, 1, 0, 0, sTextColorInPokeblockMenu, 0, string); } static void PutPokeblockInfoText(void) diff --git a/src/pokemon_storage_system.c b/src/pokemon_storage_system.c index bb196dd27..7f8c24ab7 100644 --- a/src/pokemon_storage_system.c +++ b/src/pokemon_storage_system.c @@ -71,7 +71,7 @@ static const union AffineAnimCmd *const sSpriteAffineAnimTable_8571730[] = sSpriteAffineAnim_8571720 }; -const struct TextColor gUnknown_08571734[] = {4, 0xF, 0xE}; +const u8 gUnknown_08571734[] = {4, 0xF, 0xE}; const u8 gUnknown_08571737[] = _("/30"); // code diff --git a/src/pokemon_summary_screen.c b/src/pokemon_summary_screen.c index 4affd830d..e11ba881e 100644 --- a/src/pokemon_summary_screen.c +++ b/src/pokemon_summary_screen.c @@ -54,7 +54,7 @@ extern u16 gSummaryScreenWindow_Tilemap[]; extern struct ContestMove gContestMoves[]; extern struct ContestEffect gContestEffects[]; extern struct WindowTemplate gUnknown_0861CC24; -extern struct TextColor gUnknown_0861CD2C[]; +extern u8 gUnknown_0861CD2C[][3]; extern const u8 gSpeciesNames[][POKEMON_NAME_LENGTH + 1]; extern u8 gText_MaleSymbol[]; extern u8 gText_FemaleSymbol[]; @@ -162,7 +162,7 @@ extern struct BattleMove gBattleMoves[]; extern u32 ChangeBgX(u8 bg, u32 value, u8 op); extern void sub_8199C30(u8 a, u8 b, u8 c, u8 d, u8 e, u8 f); -extern void AddTextPrinterParameterized2(u8 windowId, u8 fontId, u8 x, u8 y, u8 letterSpacing, u8 lineSpacing, struct TextColor* colors, s8 speed, u8 *str); +extern void AddTextPrinterParameterized2(u8 windowId, u8 fontId, u8 x, u8 y, u8 letterSpacing, u8 lineSpacing, const u8* colors, s8 speed, u8 *str); extern s32 GetStringCenterAlignXOffset(u8 fontId, u8 *str, s32 totalWidth); extern s32 GetStringRightAlignXOffset(u8 fontId, u8 *str, s32 totalWidth); extern bool8 sub_81A6BF4(); @@ -2557,7 +2557,7 @@ void sub_81C2554() void sub_81C25A4(u8 a, u8 *b, u8 c, u8 d, u8 e, u8 f) { - AddTextPrinterParameterized2(a, 1, c, d, 0, e, &gUnknown_0861CD2C[f], 0, b); + AddTextPrinterParameterized2(a, 1, c, d, 0, e, gUnknown_0861CD2C[f], 0, b); } void sub_81C25E8() diff --git a/src/save_failed_screen.c b/src/save_failed_screen.c index 95897e721..b207d7e74 100644 --- a/src/save_failed_screen.c +++ b/src/save_failed_screen.c @@ -168,12 +168,12 @@ static bool8 WipeSectors(u32); // although this is a general text printer, it's only used in this file. static void SaveFailedScreenTextPrint(u8 *text, u8 var1, u8 var2) { - struct TextColor color; + u8 color[3]; - color.fgColor = 0; - color.bgColor = 15; - color.shadowColor = 3; - AddTextPrinterParameterized2(gSaveFailedWindowIds[TEXT_WIN_ID], 1, var1 * 8, var2 * 8 + 1, 0, 0, &color, 0, text); + color[0] = 0; + color[1] = 15; + color[2] = 3; + AddTextPrinterParameterized2(gSaveFailedWindowIds[TEXT_WIN_ID], 1, var1 * 8, var2 * 8 + 1, 0, 0, color, 0, text); } void DoSaveFailedScreen(u8 saveType) diff --git a/src/window.c b/src/window.c index 3913b5800..9a892d079 100644 --- a/src/window.c +++ b/src/window.c @@ -403,7 +403,7 @@ void PutWindowRectTilemap(u8 windowId, u8 x, u8 y, u8 width, u8 height) } } -void BlitBitmapToWindow(u8 windowId, u8 *pixels, u16 x, u16 y, u16 width, u16 height) +void BlitBitmapToWindow(u8 windowId, const u8 *pixels, u16 x, u16 y, u16 width, u16 height) { BlitBitmapRectToWindow(windowId, pixels, 0, 0, width, height, x, y, width, height); } -- cgit v1.2.3 From d396a8f89caa2d47ae39f7dfa8da02017945d7f7 Mon Sep 17 00:00:00 2001 From: Diegoisawesome Date: Wed, 7 Feb 2018 00:07:42 -0600 Subject: Merge new_menu_helpers and menu --- src/battle_bg.c | 2 +- src/berry_blender.c | 1 - src/coins.c | 1 - src/decoration.c | 2 +- src/hall_of_fame.c | 1 - src/menu.c | 540 +++++++++++++++++++++++++++++++++++++++++++------ src/naming_screen.c | 1 - src/new_menu_helpers.c | 437 --------------------------------------- src/pokeblock.c | 1 - src/pokeblock_feed.c | 1 - src/scrcmd.c | 1 - src/secret_base.c | 1 - 12 files changed, 483 insertions(+), 506 deletions(-) delete mode 100644 src/new_menu_helpers.c (limited to 'src') diff --git a/src/battle_bg.c b/src/battle_bg.c index 5d5bbf0e9..a67f56fd8 100644 --- a/src/battle_bg.c +++ b/src/battle_bg.c @@ -17,7 +17,7 @@ #include "strings.h" #include "window.h" #include "text_window.h" -#include "new_menu_helpers.h" +#include "menu.h" struct BattleBackground { diff --git a/src/berry_blender.c b/src/berry_blender.c index a9360ca5f..45e3acd24 100644 --- a/src/berry_blender.c +++ b/src/berry_blender.c @@ -18,7 +18,6 @@ #include "event_data.h" #include "main.h" #include "link.h" -#include "new_menu_helpers.h" #include "item_menu_icons.h" #include "berry.h" #include "item.h" diff --git a/src/coins.c b/src/coins.c index 50c31cac0..12e0bd4ef 100644 --- a/src/coins.c +++ b/src/coins.c @@ -4,7 +4,6 @@ #include "window.h" #include "strings.h" #include "string_util.h" -#include "new_menu_helpers.h" #include "menu.h" #include "international_string_util.h" diff --git a/src/decoration.c b/src/decoration.c index 8fb620b36..885b1b0b0 100644 --- a/src/decoration.c +++ b/src/decoration.c @@ -20,7 +20,7 @@ #include "field_map_obj.h" #include "list_menu.h" #include "menu_helpers.h" -#include "new_menu_helpers.h" +#include "menu.h" #include "menu_indicators.h" #include "sound.h" #include "event_scripts.h" diff --git a/src/hall_of_fame.c b/src/hall_of_fame.c index 85fb518b5..9ac415c32 100644 --- a/src/hall_of_fame.c +++ b/src/hall_of_fame.c @@ -82,7 +82,6 @@ extern const u8 gContestConfetti_Gfx[]; extern const u8 gContestConfetti_Pal[]; extern void NewMenuHelpers_DrawDialogueFrame(u8, u8); -extern u16 AddTextPrinterParameterized(u8 windowId, u8 fontId, const u8 *str, u8 speed, void ( *callback)(u16, struct TextPrinter *), u8 fgColor, u8 bgColor, u8 shadowColor); extern void sub_8175620(void); extern u8 TrySavingData(u8); extern u8 sub_818D3E4(u16 species, u32 trainerId, u32 personality, u8 flags, s16 x, s16 y, u8, u16); diff --git a/src/menu.c b/src/menu.c index 4916c00ea..08b718a46 100644 --- a/src/menu.c +++ b/src/menu.c @@ -1,5 +1,4 @@ #include "global.h" -#include "new_menu_helpers.h" #include "bg.h" #include "window.h" #include "palette.h" @@ -17,8 +16,16 @@ #include "event_data.h" #include "pokedex.h" #include "region_map.h" +#include "text_window.h" +#include "strings.h" +#include "graphics.h" -struct SomeUnkStruct +#define DLG_WINDOW_PALETTE_NUM 15 +#define DLG_WINDOW_BASE_TILE_NUM 0x200 +#define STD_WINDOW_PALETTE_NUM 14 +#define STD_WINDOW_BASE_TILE_NUM 0x214 + +struct SomeUnkStruct_60F0D4 { u8 unk1; u8 unk2; @@ -41,18 +48,35 @@ struct Menu bool8 APressMuted; }; -extern EWRAM_DATA struct Menu gUnknown_0203CD90; -extern EWRAM_DATA u16 gUnknown_0203CD9C; -extern EWRAM_DATA u8 gUnknown_0203CD9E; -extern EWRAM_DATA u8 gUnknown_0203CD9F; -extern EWRAM_DATA u8 gUnknown_0203CDA0; -extern EWRAM_DATA bool8 gUnknown_0203CDA4[4]; -extern EWRAM_DATA u16 gUnknown_0203CDA8; -extern EWRAM_DATA void *gUnknown_0203CDAC[0x20]; +static EWRAM_DATA u8 gUnknown_0203CD8C = 0; +static EWRAM_DATA u8 gUnknown_0203CD8D = 0; +static EWRAM_DATA struct Menu gUnknown_0203CD90 = {0}; +static EWRAM_DATA u16 gUnknown_0203CD9C = 0; +static EWRAM_DATA u8 gUnknown_0203CD9E = 0; +static EWRAM_DATA u8 gUnknown_0203CD9F = 0; +static EWRAM_DATA u8 gUnknown_0203CDA0 = 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}; + +const u16 gUnknown_0860F074[] = INCBIN_U16("graphics/interface/860F074.gbapal"); +static const u8 gUnknown_0860F094[] = { 8, 4, 1 }; + +static const struct WindowTemplate gUnknown_0860F098[] = +{ + { 0x00, 0x02, 0x0F, 0x1B, 0x04, 0x0F, 0x194 }, + DUMMY_WIN_TEMPLATE +}; + +static const struct WindowTemplate gUnknown_0860F0A8 = +{ + 0x00, 0x15, 0x09, 0x05, 0x04, 0x0F, 0x125 +}; const u16 gUnknown_0860F0B0[] = INCBIN_U16("graphics/interface/860F0B0.gbapal"); const u8 gUnknown_0860F0D0[] = { 15, 1, 2 }; -const struct SomeUnkStruct gUnknown_0860F0D4[] = +const struct SomeUnkStruct_60F0D4 gUnknown_0860F0D4[] = { { 12, 12, 0x00 }, { 32, 12, 0x20 }, @@ -82,13 +106,12 @@ const struct SomeUnkStruct gUnknown_0860F0D4[] = { 8, 8, 0xAF }, }; -extern const u8 gText_SelectorArrow3[]; -extern const u8 gText_YesNo[]; -extern const u16 gFireRedMenuElements1_Pal[16]; -extern const u16 gFireRedMenuElements2_Pal[16]; -extern const u16 gFireRedMenuElements3_Pal[16]; -extern const u8 gFireRedMenuElements_Gfx[]; - +// Forward declarations +extern void sub_81973A4(void); +extern void DrawStandardFrame(u8, u8, u8, u8, u8, u8); +extern void DrawDialogueFrame(u8, u8, u8, u8, u8, u8); +extern void sub_81977BC(u8, u8, u8, u8, u8, u8); +extern void sub_8197804(u8, u8, u8, u8, u8, u8); extern void sub_8197BB4(u8, u8, u8, u8, u8, u8); extern void sub_8197E30(u8, u8, u8, u8, u8, u8); extern void DrawWindowBorder(u8, u8, u8, u8, u8, u8); @@ -99,6 +122,405 @@ extern void sub_8199F74(u8 windowId, u8 fontId, const u8 *str, u8 left, u8 top, 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; + gUnknown_0203CD8D = 0xFF; +} + +void sub_81971F4(void) +{ + FreeAllWindowBuffers(); +} + +void sub_8197200(void) +{ + ChangeBgX(0, 0, 0); + ChangeBgY(0, 0, 0); + DeactivateAllTextPrinters(); + sub_81973A4(); +} + +u16 sub_8197224(void) +{ + RunTextPrinters(); + return IsTextPrinterActive(0); +} + +u16 AddTextPrinterParameterized(u8 windowId, u8 fontId, const u8 *str, u8 speed, void (*callback)(struct TextSubPrinter *, u16), u8 fgColor, u8 bgColor, u8 shadowColor) +{ + struct TextSubPrinter printer; + + printer.current_text_offset = str; + printer.windowId = windowId; + printer.fontId = fontId; + printer.x = 0; + printer.y = 1; + printer.currentX = 0; + printer.currentY = 1; + printer.letterSpacing = 0; + printer.lineSpacing = 0; + printer.fontColor_l = 0; + printer.fgColor = fgColor; + printer.bgColor = bgColor; + printer.shadowColor = shadowColor; + + gTextFlags.flag_1 = 0; + return AddTextPrinter(&printer, speed, callback); +} + +void AddTextPrinterForMessage(bool8 allowSkippingDelayWithButtonPress) +{ + void (*callback)(struct TextSubPrinter *, u16) = NULL; + gTextFlags.flag_0 = allowSkippingDelayWithButtonPress; + AddTextPrinterParameterized(0, 1, gStringVar4, GetPlayerTextSpeed(), callback, 2, 1, 3); +} + +void AddTextPrinterForMessage_2(bool8 allowSkippingDelayWithButtonPress) +{ + gTextFlags.flag_0 = allowSkippingDelayWithButtonPress; + AddTextPrinterParameterized(0, 1, gStringVar4, GetPlayerTextSpeed(), NULL, 2, 1, 3); +} + +void AddTextPrinterWithCustomSpeedForMessage(bool8 allowSkippingDelayWithButtonPress, u8 speed) +{ + gTextFlags.flag_0 = allowSkippingDelayWithButtonPress; + AddTextPrinterParameterized(0, 1, gStringVar4, speed, NULL, 2, 1, 3); +} + +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); +} + +void NewMenuHelpers_DrawDialogueFrame(u8 windowId, bool8 copyToVram) +{ + CallWindowFunction(windowId, DrawDialogueFrame); + FillWindowPixelBuffer(windowId, 0x11); + PutWindowTilemap(windowId); + if (copyToVram == TRUE) + CopyWindowToVram(windowId, 3); +} + +void NewMenuHelpers_DrawStdWindowFrame(u8 windowId, bool8 copyToVram) +{ + CallWindowFunction(windowId, DrawStandardFrame); + FillWindowPixelBuffer(windowId, 0x11); + PutWindowTilemap(windowId); + if (copyToVram == TRUE) + CopyWindowToVram(windowId, 3); +} + +void sub_8197434(u8 windowId, bool8 copyToVram) +{ + CallWindowFunction(windowId, sub_8197804); + FillWindowPixelBuffer(windowId, 0x11); + ClearWindowTilemap(windowId); + if (copyToVram == TRUE) + CopyWindowToVram(windowId, 3); +} + +void sub_819746C(u8 windowId, bool8 copyToVram) +{ + CallWindowFunction(windowId, sub_81977BC); + FillWindowPixelBuffer(windowId, 0x11); + ClearWindowTilemap(windowId); + if (copyToVram == TRUE) + CopyWindowToVram(windowId, 3); +} + +void DrawStandardFrame(u8 bg, u8 tilemapLeft, u8 tilemapTop, u8 width, u8 height, u8 paletteNum) +{ + int i; + + FillBgTilemapBufferRect(bg, + STD_WINDOW_BASE_TILE_NUM + 0, + tilemapLeft - 1, + tilemapTop - 1, + 1, + 1, + STD_WINDOW_PALETTE_NUM); + FillBgTilemapBufferRect(bg, + STD_WINDOW_BASE_TILE_NUM + 1, + tilemapLeft, + tilemapTop - 1, + width, + 1, + STD_WINDOW_PALETTE_NUM); + FillBgTilemapBufferRect(bg, + STD_WINDOW_BASE_TILE_NUM + 2, + tilemapLeft + width, + tilemapTop - 1, + 1, + 1, + STD_WINDOW_PALETTE_NUM); + + for (i = tilemapTop; i < tilemapTop + height; i++) + { + FillBgTilemapBufferRect(bg, + STD_WINDOW_BASE_TILE_NUM + 3, + tilemapLeft - 1, + i, + 1, + 1, + STD_WINDOW_PALETTE_NUM); + FillBgTilemapBufferRect(bg, + STD_WINDOW_BASE_TILE_NUM + 5, + tilemapLeft + width, + i, + 1, + 1, + STD_WINDOW_PALETTE_NUM); + } + + FillBgTilemapBufferRect(bg, + STD_WINDOW_BASE_TILE_NUM + 6, + tilemapLeft - 1, + tilemapTop + height, + 1, + 1, + STD_WINDOW_PALETTE_NUM); + FillBgTilemapBufferRect(bg, + STD_WINDOW_BASE_TILE_NUM + 7, + tilemapLeft, + tilemapTop + height, + width, + 1, + STD_WINDOW_PALETTE_NUM); + FillBgTilemapBufferRect(bg, + STD_WINDOW_BASE_TILE_NUM + 8, + tilemapLeft + width, + tilemapTop + height, + 1, + 1, + STD_WINDOW_PALETTE_NUM); +} + +void DrawDialogueFrame(u8 bg, u8 tilemapLeft, u8 tilemapTop, u8 width, u8 height, u8 paletteNum) +{ + FillBgTilemapBufferRect(bg, + DLG_WINDOW_BASE_TILE_NUM + 1, + tilemapLeft - 2, + tilemapTop - 1, + 1, + 1, + DLG_WINDOW_PALETTE_NUM); + FillBgTilemapBufferRect(bg, + DLG_WINDOW_BASE_TILE_NUM + 3, + tilemapLeft - 1, + tilemapTop - 1, + 1, + 1, + DLG_WINDOW_PALETTE_NUM); + FillBgTilemapBufferRect(bg, + DLG_WINDOW_BASE_TILE_NUM + 4, + tilemapLeft, + tilemapTop - 1, + width - 1, + 1, + DLG_WINDOW_PALETTE_NUM); + FillBgTilemapBufferRect(bg, + DLG_WINDOW_BASE_TILE_NUM + 5, + tilemapLeft + width - 1, + tilemapTop - 1, + 1, + 1, + DLG_WINDOW_PALETTE_NUM); + FillBgTilemapBufferRect(bg, + DLG_WINDOW_BASE_TILE_NUM + 6, + tilemapLeft + width, + tilemapTop - 1, + 1, + 1, + DLG_WINDOW_PALETTE_NUM); + FillBgTilemapBufferRect(bg, + DLG_WINDOW_BASE_TILE_NUM + 7, + tilemapLeft - 2, + tilemapTop, + 1, + 5, + DLG_WINDOW_PALETTE_NUM); + FillBgTilemapBufferRect(bg, + DLG_WINDOW_BASE_TILE_NUM + 9, + tilemapLeft - 1, + tilemapTop, + width + 1, + 5, + DLG_WINDOW_PALETTE_NUM); + FillBgTilemapBufferRect(bg, + DLG_WINDOW_BASE_TILE_NUM + 10, + tilemapLeft + width, + tilemapTop, + 1, + 5, + DLG_WINDOW_PALETTE_NUM); + FillBgTilemapBufferRect(bg, + BG_TILE_V_FLIP(DLG_WINDOW_BASE_TILE_NUM + 1), + tilemapLeft - 2, + tilemapTop + height, + 1, + 1, + DLG_WINDOW_PALETTE_NUM); + FillBgTilemapBufferRect(bg, + BG_TILE_V_FLIP(DLG_WINDOW_BASE_TILE_NUM + 3), + tilemapLeft - 1, + tilemapTop + height, + 1, + 1, + DLG_WINDOW_PALETTE_NUM); + FillBgTilemapBufferRect(bg, + BG_TILE_V_FLIP(DLG_WINDOW_BASE_TILE_NUM + 4), + tilemapLeft, + tilemapTop + height, + width - 1, + 1, + DLG_WINDOW_PALETTE_NUM); + FillBgTilemapBufferRect(bg, + BG_TILE_V_FLIP(DLG_WINDOW_BASE_TILE_NUM + 5), + tilemapLeft + width - 1, + tilemapTop + height, + 1, + 1, + DLG_WINDOW_PALETTE_NUM); + FillBgTilemapBufferRect(bg, + BG_TILE_V_FLIP(DLG_WINDOW_BASE_TILE_NUM + 6), + tilemapLeft + width, + tilemapTop + height, + 1, + 1, + DLG_WINDOW_PALETTE_NUM); +} + +void sub_81977BC(u8 bg, u8 tilemapLeft, u8 tilemapTop, u8 width, u8 height, u8 paletteNum) +{ + FillBgTilemapBufferRect(bg, 0, tilemapLeft - 1, tilemapTop - 1, width + 2, height + 2, STD_WINDOW_PALETTE_NUM); +} + +void sub_8197804(u8 bg, u8 tilemapLeft, u8 tilemapTop, u8 width, u8 height, u8 paletteNum) +{ + FillBgTilemapBufferRect(bg, 0, tilemapLeft - 3, tilemapTop - 1, width + 6, height + 2, STD_WINDOW_PALETTE_NUM); +} + +void SetStandardWindowBorderStyle(u8 windowId, bool8 copyToVram) +{ + SetWindowBorderStyle(windowId, copyToVram, STD_WINDOW_BASE_TILE_NUM, STD_WINDOW_PALETTE_NUM); +} + +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); + sub_8197B1C(windowId, copyToVram, DLG_WINDOW_BASE_TILE_NUM, 0xF); +} + +void sub_819789C(void) +{ + LoadPalette(gUnknown_0860F074, STD_WINDOW_PALETTE_NUM * 0x10, 0x14); +} + +void sub_81978B0(u16 offset) +{ + LoadPalette(gUnknown_0860F074, offset, 0x14); +} + +const u16 *sub_81978C8(void) +{ + return gUnknown_0860F074; +} + +u16 sub_81978D0(u8 colorNum) +{ + if (colorNum > 15) + colorNum = 0; + return gUnknown_0860F074[colorNum]; +} + +void DisplayItemMessageOnField(u8 taskId, const u8 *string, TaskFunc callback) +{ + sub_81973A4(); + DisplayMessageAndContinueTask(taskId, 0, DLG_WINDOW_BASE_TILE_NUM, DLG_WINDOW_PALETTE_NUM, 1, GetPlayerTextSpeed(), string, callback); + CopyWindowToVram(0, 3); +} + +void sub_8197930(void) +{ + CreateYesNoMenu(&gUnknown_0860F0A8, STD_WINDOW_BASE_TILE_NUM, STD_WINDOW_PALETTE_NUM, 0); +} + +void sub_8197948(u8 initialCursorPos) +{ + CreateYesNoMenu(&gUnknown_0860F0A8, STD_WINDOW_BASE_TILE_NUM, STD_WINDOW_PALETTE_NUM, initialCursorPos); +} + +u32 sub_8197964(void) +{ + if (gTextFlags.flag_3) + return 1; + return gSaveBlock2Ptr->optionsTextSpeed; +} + +u8 GetPlayerTextSpeed(void) +{ + u32 speed; + if (gSaveBlock2Ptr->optionsTextSpeed > 2) + gSaveBlock2Ptr->optionsTextSpeed = 1; + speed = sub_8197964(); + return gUnknown_0860F094[speed]; +} + +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; +} + +u8 GetStartMenuWindowId(void) +{ + return gUnknown_0203CD8C; +} + +void remove_start_menu_window_maybe(void) +{ + if (gUnknown_0203CD8C != 0xFF) + { + RemoveWindow(gUnknown_0203CD8C); + gUnknown_0203CD8C = 0xFF; + } +} + +u16 sub_8197A30(void) +{ + return DLG_WINDOW_BASE_TILE_NUM; +} + +u16 sub_8197A38(void) +{ + return STD_WINDOW_BASE_TILE_NUM; +} + +u8 AddMapNamePopUpWindow(void) +{ + if (gUnknown_0203CD8D == 0xFF) + gUnknown_0203CD8D = sub_8198AA4(0, 1, 1, 10, 3, 14, 0x107); + return gUnknown_0203CD8D; +} + +u8 GetMapNamePopUpWindowId(void) +{ + return gUnknown_0203CD8D; +} + +void RemoveMapNamePopUpWindow(void) +{ + if (gUnknown_0203CD8D != 0xFF) + { + RemoveWindow(gUnknown_0203CD8D); + gUnknown_0203CD8D = 0xFF; + } +} + void AddTextPrinterWithCallbackForMessage(bool8 a1, void (*callback)(struct TextSubPrinter *, u16)) { gTextFlags.flag_0 = a1; @@ -545,22 +967,22 @@ s8 ProcessMenuInput(void) } else if (gMain.newKeys & B_BUTTON) { - return -1; + return MENU_B_PRESSED; } else if (gMain.newKeys & DPAD_UP) { PlaySE(SE_SELECT); MoveMenuCursor(-1); - return -2; + return MENU_NOTHING_CHOSEN; } else if (gMain.newKeys & DPAD_DOWN) { PlaySE(SE_SELECT); MoveMenuCursor(1); - return -2; + return MENU_NOTHING_CHOSEN; } - return -2; + return MENU_NOTHING_CHOSEN; } s8 ProcessMenuInputNoWrapAround(void) @@ -575,22 +997,22 @@ s8 ProcessMenuInputNoWrapAround(void) } else if (gMain.newKeys & B_BUTTON) { - return -1; + return MENU_B_PRESSED; } else if (gMain.newKeys & DPAD_UP) { if (oldPos != MoveMenuCursorNoWrapAround(-1)) PlaySE(SE_SELECT); - return -2; + return MENU_NOTHING_CHOSEN; } else if (gMain.newKeys & DPAD_DOWN) { if (oldPos != MoveMenuCursorNoWrapAround(1)) PlaySE(SE_SELECT); - return -2; + return MENU_NOTHING_CHOSEN; } - return -2; + return MENU_NOTHING_CHOSEN; } s8 ProcessMenuInput_other(void) @@ -603,22 +1025,22 @@ s8 ProcessMenuInput_other(void) } else if (gMain.newKeys & B_BUTTON) { - return -1; + return MENU_B_PRESSED; } else if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_UP) { PlaySE(SE_SELECT); MoveMenuCursor(-1); - return -2; + return MENU_NOTHING_CHOSEN; } else if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_DOWN) { PlaySE(SE_SELECT); MoveMenuCursor(1); - return -2; + return MENU_NOTHING_CHOSEN; } - return -2; + return MENU_NOTHING_CHOSEN; } s8 ProcessMenuInputNoWrapAround_other(void) @@ -633,22 +1055,22 @@ s8 ProcessMenuInputNoWrapAround_other(void) } else if (gMain.newKeys & B_BUTTON) { - return -1; + return MENU_B_PRESSED; } else if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_UP) { if (oldPos != MoveMenuCursorNoWrapAround(-1)) PlaySE(SE_SELECT); - return -2; + return MENU_NOTHING_CHOSEN; } else if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_DOWN) { if (oldPos != MoveMenuCursorNoWrapAround(1)) PlaySE(SE_SELECT); - return -2; + return MENU_NOTHING_CHOSEN; } - return -2; + return MENU_NOTHING_CHOSEN; } void PrintTextArray(u8 windowId, u8 fontId, u8 left, u8 top, u8 lineHeight, u8 itemCount, const struct MenuAction *strs) @@ -767,7 +1189,7 @@ void sub_8198C34(const struct WindowTemplate *window, u8 fontId, u16 baseTileNum s8 ProcessMenuInputNoWrap_(void) { s8 result = ProcessMenuInputNoWrapAround(); - if (result != -2) + if (result != MENU_NOTHING_CHOSEN) sub_8198C78(); return result; } @@ -980,34 +1402,34 @@ s8 sub_8199284(void) } else if (gMain.newKeys & B_BUTTON) { - return -1; + return MENU_B_PRESSED; } else if (gMain.newKeys & DPAD_UP) { PlaySE(SE_SELECT); sub_8199134(0, -1); - return -2; + return MENU_NOTHING_CHOSEN; } else if (gMain.newKeys & DPAD_DOWN) { PlaySE(SE_SELECT); sub_8199134(0, 1); - return -2; + return MENU_NOTHING_CHOSEN; } else if (gMain.newKeys & DPAD_LEFT || GetLRKeysState() == 1) { PlaySE(SE_SELECT); sub_8199134(-1, 0); - return -2; + return MENU_NOTHING_CHOSEN; } else if (gMain.newKeys & DPAD_RIGHT || GetLRKeysState() == 2) { PlaySE(SE_SELECT); sub_8199134(1, 0); - return -2; + return MENU_NOTHING_CHOSEN; } - return -2; + return MENU_NOTHING_CHOSEN; } s8 sub_8199334(void) @@ -1021,34 +1443,34 @@ s8 sub_8199334(void) } else if (gMain.newKeys & B_BUTTON) { - return -1; + return MENU_B_PRESSED; } else if (gMain.newKeys & DPAD_UP) { if (oldPos != sub_81991F8(0, -1)) PlaySE(SE_SELECT); - return -2; + return MENU_NOTHING_CHOSEN; } else if (gMain.newKeys & DPAD_DOWN) { if (oldPos != sub_81991F8(0, 1)) PlaySE(SE_SELECT); - return -2; + return MENU_NOTHING_CHOSEN; } else if (gMain.newKeys & DPAD_LEFT || GetLRKeysState() == 1) { if (oldPos != sub_81991F8(-1, 0)) PlaySE(SE_SELECT); - return -2; + return MENU_NOTHING_CHOSEN; } else if (gMain.newKeys & DPAD_RIGHT || GetLRKeysState() == 2) { if (oldPos != sub_81991F8(1, 0)) PlaySE(SE_SELECT); - return -2; + return MENU_NOTHING_CHOSEN; } - return -2; + return MENU_NOTHING_CHOSEN; } s8 sub_81993D8(void) @@ -1060,34 +1482,34 @@ s8 sub_81993D8(void) } else if (gMain.newKeys & B_BUTTON) { - return -1; + return MENU_B_PRESSED; } else if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_UP) { PlaySE(SE_SELECT); sub_8199134(0, -1); - return -2; + return MENU_NOTHING_CHOSEN; } else if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_DOWN) { PlaySE(SE_SELECT); sub_8199134(0, 1); - return -2; + return MENU_NOTHING_CHOSEN; } else if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_LEFT || sub_812210C() == 1) { PlaySE(SE_SELECT); sub_8199134(-1, 0); - return -2; + return MENU_NOTHING_CHOSEN; } else if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_RIGHT || sub_812210C() == 2) { PlaySE(SE_SELECT); sub_8199134(1, 0); - return -2; + return MENU_NOTHING_CHOSEN; } - return -2; + return MENU_NOTHING_CHOSEN; } s8 sub_8199484(void) @@ -1101,34 +1523,34 @@ s8 sub_8199484(void) } else if (gMain.newKeys & B_BUTTON) { - return -1; + return MENU_B_PRESSED; } else if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_UP) { if (oldPos != sub_81991F8(0, -1)) PlaySE(SE_SELECT); - return -2; + return MENU_NOTHING_CHOSEN; } else if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_DOWN) { if (oldPos != sub_81991F8(0, 1)) PlaySE(SE_SELECT); - return -2; + return MENU_NOTHING_CHOSEN; } else if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_LEFT || sub_812210C() == 1) { if (oldPos != sub_81991F8(-1, 0)) PlaySE(SE_SELECT); - return -2; + return MENU_NOTHING_CHOSEN; } else if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_RIGHT || sub_812210C() == 2) { if (oldPos != sub_81991F8(1, 0)) PlaySE(SE_SELECT); - return -2; + return MENU_NOTHING_CHOSEN; } - return -2; + return MENU_NOTHING_CHOSEN; } u8 InitMenuInUpperLeftCorner(u8 windowId, u8 itemCount, u8 initialCursorPos, bool8 APressMuted) diff --git a/src/naming_screen.c b/src/naming_screen.c index 917782e88..47d8b8ad1 100644 --- a/src/naming_screen.c +++ b/src/naming_screen.c @@ -5,7 +5,6 @@ #include "task.h" #include "sprite.h" #include "string_util.h" -#include "new_menu_helpers.h" #include "window.h" #include "bg.h" #include "gpu_regs.h" diff --git a/src/new_menu_helpers.c b/src/new_menu_helpers.c deleted file mode 100644 index a4aad4058..000000000 --- a/src/new_menu_helpers.c +++ /dev/null @@ -1,437 +0,0 @@ -#include "global.h" -#include "bg.h" -#include "palette.h" -#include "window.h" -#include "text.h" -#include "new_menu_helpers.h" -#include "text_window.h" -#include "menu.h" -#include "menu_helpers.h" - -#define STD_WINDOW_PALETTE_NUM 14 -#define STD_WINDOW_BASE_TILE_NUM 0x214 -#define DLG_WINDOW_PALETTE_NUM 15 -#define DLG_WINDOW_BASE_TILE_NUM 0x200 - -static EWRAM_DATA u8 gUnknown_0203CD8C = 0; -static EWRAM_DATA u8 gUnknown_0203CD8D = 0; - -const u16 gUnknown_0860F074[] = INCBIN_U16("graphics/interface/860F074.gbapal"); -static const u8 gUnknown_0860F094[] = { 8, 4, 1 }; - -static const struct WindowTemplate gUnknown_0860F098[] = -{ - { 0x00, 0x02, 0x0F, 0x1B, 0x04, 0x0F, 0x194 }, - DUMMY_WIN_TEMPLATE -}; - -static const struct WindowTemplate gUnknown_0860F0A8 = -{ - 0x00, 0x15, 0x09, 0x05, 0x04, 0x0F, 0x125 -}; - -// Forward declarations -extern void sub_81973A4(void); -extern void DrawStandardFrame(u8, u8, u8, u8, u8, u8); -extern void DrawDialogueFrame(u8, u8, u8, u8, u8, u8); -extern void sub_81977BC(u8, u8, u8, u8, u8, u8); -extern void sub_8197804(u8, u8, u8, u8, u8, u8); - -void sub_81971D0(void) -{ - InitWindows(gUnknown_0860F098); - gUnknown_0203CD8C = 0xFF; - gUnknown_0203CD8D = 0xFF; -} - -void sub_81971F4(void) -{ - FreeAllWindowBuffers(); -} - -void sub_8197200(void) -{ - ChangeBgX(0, 0, 0); - ChangeBgY(0, 0, 0); - DeactivateAllTextPrinters(); - sub_81973A4(); -} - -u16 sub_8197224(void) -{ - RunTextPrinters(); - return IsTextPrinterActive(0); -} - -u16 AddTextPrinterParameterized(u8 windowId, u8 fontId, const u8 *str, u8 speed, void (*callback)(struct TextSubPrinter *, u16), u8 fgColor, u8 bgColor, u8 shadowColor) -{ - struct TextSubPrinter printer; - - printer.current_text_offset = str; - printer.windowId = windowId; - printer.fontId = fontId; - printer.x = 0; - printer.y = 1; - printer.currentX = 0; - printer.currentY = 1; - printer.letterSpacing = 0; - printer.lineSpacing = 0; - printer.fontColor_l = 0; - printer.fgColor = fgColor; - printer.bgColor = bgColor; - printer.shadowColor = shadowColor; - - gTextFlags.flag_1 = 0; - return AddTextPrinter(&printer, speed, callback); -} - -void AddTextPrinterForMessage(bool8 allowSkippingDelayWithButtonPress) -{ - void (*callback)(struct TextSubPrinter *, u16) = NULL; - gTextFlags.flag_0 = allowSkippingDelayWithButtonPress; - AddTextPrinterParameterized(0, 1, gStringVar4, GetPlayerTextSpeed(), callback, 2, 1, 3); -} - -void AddTextPrinterForMessage_2(bool8 allowSkippingDelayWithButtonPress) -{ - gTextFlags.flag_0 = allowSkippingDelayWithButtonPress; - AddTextPrinterParameterized(0, 1, gStringVar4, GetPlayerTextSpeed(), NULL, 2, 1, 3); -} - -void AddTextPrinterWithCustomSpeedForMessage(bool8 allowSkippingDelayWithButtonPress, u8 speed) -{ - gTextFlags.flag_0 = allowSkippingDelayWithButtonPress; - AddTextPrinterParameterized(0, 1, gStringVar4, speed, NULL, 2, 1, 3); -} - -void sub_81973A4(void) -{ - copy_textbox_border_tile_patterns_to_vram(0, DLG_WINDOW_BASE_TILE_NUM, 0xF0); - sub_809882C(0, STD_WINDOW_BASE_TILE_NUM, 0xE0); -} - -void NewMenuHelpers_DrawDialogueFrame(u8 windowId, bool8 copyToVram) -{ - CallWindowFunction(windowId, DrawDialogueFrame); - FillWindowPixelBuffer(windowId, 0x11); - PutWindowTilemap(windowId); - if (copyToVram == TRUE) - CopyWindowToVram(windowId, 3); -} - -void NewMenuHelpers_DrawStdWindowFrame(u8 windowId, bool8 copyToVram) -{ - CallWindowFunction(windowId, DrawStandardFrame); - FillWindowPixelBuffer(windowId, 0x11); - PutWindowTilemap(windowId); - if (copyToVram == TRUE) - CopyWindowToVram(windowId, 3); -} - -void sub_8197434(u8 windowId, bool8 copyToVram) -{ - CallWindowFunction(windowId, sub_8197804); - FillWindowPixelBuffer(windowId, 0x11); - ClearWindowTilemap(windowId); - if (copyToVram == TRUE) - CopyWindowToVram(windowId, 3); -} - -void sub_819746C(u8 windowId, bool8 copyToVram) -{ - CallWindowFunction(windowId, sub_81977BC); - FillWindowPixelBuffer(windowId, 0x11); - ClearWindowTilemap(windowId); - if (copyToVram == TRUE) - CopyWindowToVram(windowId, 3); -} - -void DrawStandardFrame(u8 bg, u8 tilemapLeft, u8 tilemapTop, u8 width, u8 height, u8 paletteNum) -{ - int i; - - FillBgTilemapBufferRect(bg, - STD_WINDOW_BASE_TILE_NUM + 0, - tilemapLeft - 1, - tilemapTop - 1, - 1, - 1, - STD_WINDOW_PALETTE_NUM); - FillBgTilemapBufferRect(bg, - STD_WINDOW_BASE_TILE_NUM + 1, - tilemapLeft, - tilemapTop - 1, - width, - 1, - STD_WINDOW_PALETTE_NUM); - FillBgTilemapBufferRect(bg, - STD_WINDOW_BASE_TILE_NUM + 2, - tilemapLeft + width, - tilemapTop - 1, - 1, - 1, - STD_WINDOW_PALETTE_NUM); - - for (i = tilemapTop; i < tilemapTop + height; i++) - { - FillBgTilemapBufferRect(bg, - STD_WINDOW_BASE_TILE_NUM + 3, - tilemapLeft - 1, - i, - 1, - 1, - STD_WINDOW_PALETTE_NUM); - FillBgTilemapBufferRect(bg, - STD_WINDOW_BASE_TILE_NUM + 5, - tilemapLeft + width, - i, - 1, - 1, - STD_WINDOW_PALETTE_NUM); - } - - FillBgTilemapBufferRect(bg, - STD_WINDOW_BASE_TILE_NUM + 6, - tilemapLeft - 1, - tilemapTop + height, - 1, - 1, - STD_WINDOW_PALETTE_NUM); - FillBgTilemapBufferRect(bg, - STD_WINDOW_BASE_TILE_NUM + 7, - tilemapLeft, - tilemapTop + height, - width, - 1, - STD_WINDOW_PALETTE_NUM); - FillBgTilemapBufferRect(bg, - STD_WINDOW_BASE_TILE_NUM + 8, - tilemapLeft + width, - tilemapTop + height, - 1, - 1, - STD_WINDOW_PALETTE_NUM); -} - -void DrawDialogueFrame(u8 bg, u8 tilemapLeft, u8 tilemapTop, u8 width, u8 height, u8 paletteNum) -{ - FillBgTilemapBufferRect(bg, - DLG_WINDOW_BASE_TILE_NUM + 1, - tilemapLeft - 2, - tilemapTop - 1, - 1, - 1, - DLG_WINDOW_PALETTE_NUM); - FillBgTilemapBufferRect(bg, - DLG_WINDOW_BASE_TILE_NUM + 3, - tilemapLeft - 1, - tilemapTop - 1, - 1, - 1, - DLG_WINDOW_PALETTE_NUM); - FillBgTilemapBufferRect(bg, - DLG_WINDOW_BASE_TILE_NUM + 4, - tilemapLeft, - tilemapTop - 1, - width - 1, - 1, - DLG_WINDOW_PALETTE_NUM); - FillBgTilemapBufferRect(bg, - DLG_WINDOW_BASE_TILE_NUM + 5, - tilemapLeft + width - 1, - tilemapTop - 1, - 1, - 1, - DLG_WINDOW_PALETTE_NUM); - FillBgTilemapBufferRect(bg, - DLG_WINDOW_BASE_TILE_NUM + 6, - tilemapLeft + width, - tilemapTop - 1, - 1, - 1, - DLG_WINDOW_PALETTE_NUM); - FillBgTilemapBufferRect(bg, - DLG_WINDOW_BASE_TILE_NUM + 7, - tilemapLeft - 2, - tilemapTop, - 1, - 5, - DLG_WINDOW_PALETTE_NUM); - FillBgTilemapBufferRect(bg, - DLG_WINDOW_BASE_TILE_NUM + 9, - tilemapLeft - 1, - tilemapTop, - width + 1, - 5, - DLG_WINDOW_PALETTE_NUM); - FillBgTilemapBufferRect(bg, - DLG_WINDOW_BASE_TILE_NUM + 10, - tilemapLeft + width, - tilemapTop, - 1, - 5, - DLG_WINDOW_PALETTE_NUM); - FillBgTilemapBufferRect(bg, - BG_TILE_V_FLIP(DLG_WINDOW_BASE_TILE_NUM + 1), - tilemapLeft - 2, - tilemapTop + height, - 1, - 1, - DLG_WINDOW_PALETTE_NUM); - FillBgTilemapBufferRect(bg, - BG_TILE_V_FLIP(DLG_WINDOW_BASE_TILE_NUM + 3), - tilemapLeft - 1, - tilemapTop + height, - 1, - 1, - DLG_WINDOW_PALETTE_NUM); - FillBgTilemapBufferRect(bg, - BG_TILE_V_FLIP(DLG_WINDOW_BASE_TILE_NUM + 4), - tilemapLeft, - tilemapTop + height, - width - 1, - 1, - DLG_WINDOW_PALETTE_NUM); - FillBgTilemapBufferRect(bg, - BG_TILE_V_FLIP(DLG_WINDOW_BASE_TILE_NUM + 5), - tilemapLeft + width - 1, - tilemapTop + height, - 1, - 1, - DLG_WINDOW_PALETTE_NUM); - FillBgTilemapBufferRect(bg, - BG_TILE_V_FLIP(DLG_WINDOW_BASE_TILE_NUM + 6), - tilemapLeft + width, - tilemapTop + height, - 1, - 1, - DLG_WINDOW_PALETTE_NUM); -} - -void sub_81977BC(u8 bg, u8 tilemapLeft, u8 tilemapTop, u8 width, u8 height, u8 paletteNum) -{ - FillBgTilemapBufferRect(bg, 0, tilemapLeft - 1, tilemapTop - 1, width + 2, height + 2, STD_WINDOW_PALETTE_NUM); -} - -void sub_8197804(u8 bg, u8 tilemapLeft, u8 tilemapTop, u8 width, u8 height, u8 paletteNum) -{ - FillBgTilemapBufferRect(bg, 0, tilemapLeft - 3, tilemapTop - 1, width + 6, height + 2, STD_WINDOW_PALETTE_NUM); -} - -void SetStandardWindowBorderStyle(u8 windowId, bool8 copyToVram) -{ - SetWindowBorderStyle(windowId, copyToVram, STD_WINDOW_BASE_TILE_NUM, STD_WINDOW_PALETTE_NUM); -} - -void sub_819786C(u8 windowId, bool8 copyToVram) -{ - copy_textbox_border_tile_patterns_to_vram(windowId, DLG_WINDOW_BASE_TILE_NUM, 0xF0); - sub_8197B1C(windowId, copyToVram, DLG_WINDOW_BASE_TILE_NUM, 0xF); -} - -void sub_819789C(void) -{ - LoadPalette(gUnknown_0860F074, 0xE0, 0x14); -} - -void sub_81978B0(u16 offset) -{ - LoadPalette(gUnknown_0860F074, offset, 0x14); -} - -const u16 *sub_81978C8(void) -{ - return gUnknown_0860F074; -} - -u16 sub_81978D0(u8 colorNum) -{ - if (colorNum > 15) - colorNum = 0; - return gUnknown_0860F074[colorNum]; -} - -void DisplayItemMessageOnField(u8 taskId, const u8 *string, TaskFunc callback) -{ - sub_81973A4(); - DisplayMessageAndContinueTask(taskId, 0, DLG_WINDOW_BASE_TILE_NUM, DLG_WINDOW_PALETTE_NUM, 1, GetPlayerTextSpeed(), string, callback); - CopyWindowToVram(0, 3); -} - -void sub_8197930(void) -{ - CreateYesNoMenu(&gUnknown_0860F0A8, STD_WINDOW_BASE_TILE_NUM, STD_WINDOW_PALETTE_NUM, 0); -} - -void sub_8197948(u8 initialCursorPos) -{ - CreateYesNoMenu(&gUnknown_0860F0A8, STD_WINDOW_BASE_TILE_NUM, STD_WINDOW_PALETTE_NUM, initialCursorPos); -} - -u32 sub_8197964(void) -{ - if (gTextFlags.flag_3) - return 1; - return gSaveBlock2Ptr->optionsTextSpeed; -} - -u8 GetPlayerTextSpeed(void) -{ - u32 speed; - if (gSaveBlock2Ptr->optionsTextSpeed > 2) - gSaveBlock2Ptr->optionsTextSpeed = 1; - speed = sub_8197964(); - return gUnknown_0860F094[speed]; -} - -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; -} - -u8 GetStartMenuWindowId(void) -{ - return gUnknown_0203CD8C; -} - -void remove_start_menu_window_maybe(void) -{ - if (gUnknown_0203CD8C != 0xFF) - { - RemoveWindow(gUnknown_0203CD8C); - gUnknown_0203CD8C = 0xFF; - } -} - -u16 sub_8197A30(void) -{ - return DLG_WINDOW_BASE_TILE_NUM; -} - -u16 sub_8197A38(void) -{ - return STD_WINDOW_BASE_TILE_NUM; -} - -u8 AddMapNamePopUpWindow(void) -{ - if (gUnknown_0203CD8D == 0xFF) - gUnknown_0203CD8D = sub_8198AA4(0, 1, 1, 10, 3, 14, 0x107); - return gUnknown_0203CD8D; -} - -u8 GetMapNamePopUpWindowId(void) -{ - return gUnknown_0203CD8D; -} - -void RemoveMapNamePopUpWindow(void) -{ - if (gUnknown_0203CD8D != 0xFF) - { - RemoveWindow(gUnknown_0203CD8D); - gUnknown_0203CD8D = 0xFF; - } -} diff --git a/src/pokeblock.c b/src/pokeblock.c index c20c8c643..2623e12c4 100644 --- a/src/pokeblock.c +++ b/src/pokeblock.c @@ -6,7 +6,6 @@ #include "menu.h" #include "task.h" #include "menu_helpers.h" -#include "new_menu_helpers.h" #include "pokemon.h" #include "graphics.h" #include "malloc.h" diff --git a/src/pokeblock_feed.c b/src/pokeblock_feed.c index d899e54f1..2039808cb 100644 --- a/src/pokeblock_feed.c +++ b/src/pokeblock_feed.c @@ -16,7 +16,6 @@ #include "event_data.h" #include "strings.h" #include "string_util.h" -#include "new_menu_helpers.h" #include "party_menu.h" #include "m4a.h" #include "sound.h" diff --git a/src/scrcmd.c b/src/scrcmd.c index 5a4cc4591..ffdccdbe1 100644 --- a/src/scrcmd.c +++ b/src/scrcmd.c @@ -29,7 +29,6 @@ #include "menu.h" #include "money.h" #include "mystery_event_script.h" -#include "new_menu_helpers.h" #include "palette.h" #include "party_menu.h" #include "pokemon_3.h" diff --git a/src/secret_base.c b/src/secret_base.c index bf6bec1f8..359cc7aca 100644 --- a/src/secret_base.c +++ b/src/secret_base.c @@ -9,7 +9,6 @@ #include "window.h" #include "menu.h" #include "menu_helpers.h" -#include "new_menu_helpers.h" #include "menu_indicators.h" #include "constants/maps.h" #include "constants/songs.h" -- cgit v1.2.3 From 5db765a475bf401417bbf7a3ca8b89dc0425f793 Mon Sep 17 00:00:00 2001 From: Diegoisawesome Date: Wed, 7 Feb 2018 17:13:59 -0600 Subject: Make small change to sub_819A080 --- src/menu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/menu.c b/src/menu.c index 34a689c73..d06f950d3 100644 --- a/src/menu.c +++ b/src/menu.c @@ -2018,7 +2018,7 @@ void sub_819A080(struct UnkStruct_819A080 *a0, struct UnkStruct_819A080 *a1, u16 // sp+04 = a1 // sp+08 = a2 // sp+0c = a4 - int sp10 = a1->unk04 - a4 > a6 ? a6 + a2 : a1->unk04 - a4; + int sp10 = a1->unk04 - a4 < a6 ? a1->unk04 - a4 + a2 : a6 + a2; int sp14 = a0->unk06 - a5 < a7 ? a3 + a0->unk06 - a5 : a3 + a7; int sp18 = (a0->unk04 + (a0->unk04 & 0x7)) / 8; int sp1c = (a1->unk04 + (a1->unk04 & 0x7)) / 8; -- cgit v1.2.3