summaryrefslogtreecommitdiff
path: root/src/engine
diff options
context:
space:
mode:
Diffstat (limited to 'src/engine')
-rw-r--r--src/engine/cable_club.c6
-rw-r--r--src/engine/clear_save_data_menu.c6
-rw-r--r--src/engine/link.c6
-rw-r--r--src/engine/main_menu.c94
-rw-r--r--src/engine/menu.c150
-rw-r--r--src/engine/mystery_event_menu.c32
-rw-r--r--src/engine/naming_screen.c14
-rw-r--r--src/engine/option_menu.c34
-rw-r--r--src/engine/record_mixing.c10
-rw-r--r--src/engine/reset_rtc_screen.c22
-rw-r--r--src/engine/save_failed_screen.c32
-rw-r--r--src/engine/save_menu_util.c18
-rw-r--r--src/engine/text.c707
-rw-r--r--src/engine/text_window.c157
-rw-r--r--src/engine/trade.c118
-rw-r--r--src/engine/trainer_card.c28
16 files changed, 756 insertions, 678 deletions
diff --git a/src/engine/cable_club.c b/src/engine/cable_club.c
index 3187de7ed..b12ee38ce 100644
--- a/src/engine/cable_club.c
+++ b/src/engine/cable_club.c
@@ -109,13 +109,13 @@ static void sub_8082CD4(u8 arg0, u8 arg1)
static void sub_8082D18(u32 value)
{
ConvertIntToDecimalStringN(gStringVar1, value, STR_CONV_MODE_LEFT_ALIGN, 1);
- MenuDrawTextWindow(18, 10, 28, 13);
+ Menu_DrawStdWindowFrame(18, 10, 28, 13);
sub_8072BD8(gOtherText_PLink, 19, 11, 72);
}
static void sub_8082D4C()
{
- MenuZeroFillWindowRect(18, 10, 28, 13);
+ Menu_EraseWindowRect(18, 10, 28, 13);
}
static void sub_8082D60(u8 taskId, u8 arg1)
@@ -790,7 +790,7 @@ static void sub_80839DC(u8 taskId)
case 3:
sub_8055588();
HideFieldMessageBox();
- MenuZeroFillScreen();
+ Menu_EraseScreen();
DestroyTask(taskId);
EnableBothScriptContexts();
break;
diff --git a/src/engine/clear_save_data_menu.c b/src/engine/clear_save_data_menu.c
index 12cde22a7..ae6c85180 100644
--- a/src/engine/clear_save_data_menu.c
+++ b/src/engine/clear_save_data_menu.c
@@ -41,10 +41,10 @@ static void Task_InitMenu(u8 taskId)
REG_DISPCNT = DISPCNT_MODE_0 | DISPCNT_OBJ_1D_MAP | DISPCNT_BG0_ON | DISPCNT_BG3_ON | DISPCNT_OBJ_ON;
SetVBlankCallback(VBlankCB_ClearSaveDataScreen);
- MenuDrawTextWindow(2, 14, 27, 19);
- MenuPrint(gSystemText_ClearAllSaveDataPrompt, 3, 15);
+ Menu_DrawStdWindowFrame(2, 14, 27, 19);
+ Menu_PrintText(gSystemText_ClearAllSaveDataPrompt, 3, 15);
- MenuDrawTextWindow(2, 1, 8, 6);
+ Menu_DrawStdWindowFrame(2, 1, 8, 6);
PrintMenuItems(3, 2, 2, gMenuYesNoItems);
InitMenu(0, 3, 2, 2, 1, 5);
diff --git a/src/engine/link.c b/src/engine/link.c
index 28323207c..a2df02b5f 100644
--- a/src/engine/link.c
+++ b/src/engine/link.c
@@ -239,7 +239,7 @@ void LinkTestScreen(void)
ResetTasks();
SetVBlankCallback(VBlankCB_LinkTest);
SetUpWindowConfig(&gWindowConfig_81E6CE4);
- InitMenuWindow((struct WindowConfig *)&gWindowConfig_81E6CE4);
+ InitMenuWindow((struct WindowTemplate *)&gWindowConfig_81E6CE4);
ResetBlockSend();
gLinkType = 0x1111;
OpenLink();
@@ -1237,8 +1237,8 @@ void CB2_LinkError(void)
ResetTasks();
SetVBlankCallback(VBlankCB_LinkTest);
SetUpWindowConfig(&gWindowConfig_81E7198);
- InitMenuWindow((struct WindowConfig *)&gWindowConfig_81E7198);
- MenuZeroFillScreen();
+ InitMenuWindow((struct WindowTemplate *)&gWindowConfig_81E7198);
+ Menu_EraseScreen();
REG_BLDALPHA = 0;
REG_BG0VOFS = 0;
REG_BG0HOFS = 0;
diff --git a/src/engine/main_menu.c b/src/engine/main_menu.c
index 909b5676b..623969802 100644
--- a/src/engine/main_menu.c
+++ b/src/engine/main_menu.c
@@ -234,7 +234,7 @@ u32 InitMainMenu(u8 a1)
ResetSpriteData();
FreeAllSpritePalettes();
SetUpWindowConfig(&gWindowConfig_81E6C3C);
- InitMenuWindow((struct WindowConfig *)&gWindowConfig_81E6CE4);
+ InitMenuWindow((struct WindowTemplate *)&gWindowConfig_81E6CE4);
if (a1)
BeginNormalPaletteFade(-1, 0, 0x10, 0, 0x0000); // fade to black
@@ -293,7 +293,7 @@ void Task_MainMenuCheckSave(u8 taskId)
gTasks[taskId].func = Task_MainMenuCheckRtc;
break;
case 2:
- MenuDrawTextWindow(2, 14, 27, 19);
+ Menu_DrawStdWindowFrame(2, 14, 27, 19);
MenuPrintMessage(gSaveFileDeletedMessage, 3, 15);
REG_WIN0H = WIN_RANGE(17, 223);
REG_WIN0V = WIN_RANGE(113, 159);
@@ -301,7 +301,7 @@ void Task_MainMenuCheckSave(u8 taskId)
gTasks[taskId].func = Task_MainMenuWaitForSaveErrorAck;
break;
case 255:
- MenuDrawTextWindow(2, 14, 27, 19);
+ Menu_DrawStdWindowFrame(2, 14, 27, 19);
MenuPrintMessage(gSaveFileCorruptMessage, 3, 15);
REG_WIN0H = WIN_RANGE(17, 223);
REG_WIN0V = WIN_RANGE(113, 159);
@@ -319,7 +319,7 @@ void Task_MainMenuCheckSave(u8 taskId)
gTasks[taskId].func = Task_MainMenuCheckRtc;
break;
case 4:
- MenuDrawTextWindow(2, 14, 27, 19);
+ Menu_DrawStdWindowFrame(2, 14, 27, 19);
MenuPrintMessage(gBoardNotInstalledMessage, 3, 15);
REG_WIN0H = WIN_RANGE(17, 223);
REG_WIN0V = WIN_RANGE(113, 159);
@@ -331,11 +331,11 @@ void Task_MainMenuCheckSave(u8 taskId)
void Task_MainMenuWaitForSaveErrorAck(u8 taskId)
{
- if (MenuUpdateWindowText())
+ if (Menu_UpdateWindowText())
{
if (gMain.newKeys & A_BUTTON)
{
- MenuZeroFillWindowRect(2, 14, 27, 19);
+ Menu_EraseWindowRect(2, 14, 27, 19);
gTasks[taskId].func = Task_MainMenuCheckRtc;
}
}
@@ -359,7 +359,7 @@ void Task_MainMenuCheckRtc(u8 taskId)
}
else
{
- MenuDrawTextWindow(2, 14, 27, 19);
+ Menu_DrawStdWindowFrame(2, 14, 27, 19);
MenuPrintMessage(gBatteryDryMessage, 3, 15);
REG_WIN0H = WIN_RANGE(17, 223);
REG_WIN0V = WIN_RANGE(113, 159);
@@ -370,11 +370,11 @@ void Task_MainMenuCheckRtc(u8 taskId)
void Task_MainMenuWaitForRtcErrorAck(u8 taskId)
{
- if (MenuUpdateWindowText())
+ if (Menu_UpdateWindowText())
{
if ( gMain.newKeys & 1 )
{
- MenuZeroFillWindowRect(2, 14, 27, 19);
+ Menu_EraseWindowRect(2, 14, 27, 19);
gTasks[taskId].func = Task_MainMenuDraw;
}
}
@@ -412,28 +412,28 @@ void Task_MainMenuDraw(u8 taskId)
{
case HAS_NO_SAVED_GAME:
default:
- MenuDrawTextWindow(1, 0, 28, 3);
+ Menu_DrawStdWindowFrame(1, 0, 28, 3);
PrintMainMenuItem(gMainMenuString_NewGame, 2, 1);
- MenuDrawTextWindow(1, 4, 28, 7);
+ Menu_DrawStdWindowFrame(1, 4, 28, 7);
PrintMainMenuItem(gMainMenuString_Option, 2, 5);
break;
case HAS_SAVED_GAME:
- MenuDrawTextWindow(1, 0, 28, 7);
+ Menu_DrawStdWindowFrame(1, 0, 28, 7);
PrintMainMenuItem(gMainMenuString_Continue, 2, 1);
- MenuDrawTextWindow(1, 8, 28, 11);
+ Menu_DrawStdWindowFrame(1, 8, 28, 11);
PrintMainMenuItem(gMainMenuString_NewGame, 2, 9);
- MenuDrawTextWindow(1, 12, 28, 15);
+ Menu_DrawStdWindowFrame(1, 12, 28, 15);
PrintMainMenuItem(gMainMenuString_Option, 2, 13);
PrintSaveFileInfo();
break;
case HAS_MYSTERY_GIFT:
- MenuDrawTextWindow(1, 0, 28, 7);
+ Menu_DrawStdWindowFrame(1, 0, 28, 7);
PrintMainMenuItem(gMainMenuString_Continue, 2, 1);
- MenuDrawTextWindow(1, 8, 28, 11);
+ Menu_DrawStdWindowFrame(1, 8, 28, 11);
PrintMainMenuItem(gMainMenuString_NewGame, 2, 9);
- MenuDrawTextWindow(1, 12, 28, 15);
+ Menu_DrawStdWindowFrame(1, 12, 28, 15);
PrintMainMenuItem(gMainMenuString_MysteryEvents, 2, 13);
- MenuDrawTextWindow(1, 16, 28, 19);
+ Menu_DrawStdWindowFrame(1, 16, 28, 19);
PrintMainMenuItem(gMainMenuString_Option, 2, 0x11);
PrintSaveFileInfo();
break;
@@ -681,7 +681,7 @@ void PrintMainMenuItem(const u8 *text, u8 left, u8 top)
buffer[29] = EOS;
- MenuPrint(buffer, left, top);
+ Menu_PrintText(buffer, left, top);
}
void PrintSaveFileInfo(void)
@@ -694,8 +694,8 @@ void PrintSaveFileInfo(void)
void PrintPlayerName(void)
{
- MenuPrint(gMainMenuString_Player, 2, 3);
- MenuPrint(gSaveBlock2.playerName, 9, 3);
+ Menu_PrintText(gMainMenuString_Player, 2, 3);
+ Menu_PrintText(gSaveBlock2.playerName, 9, 3);
}
void PrintPlayTime(void)
@@ -704,15 +704,15 @@ void PrintPlayTime(void)
u8 alignedPlayTime[32];
#if defined(ENGLISH)
- MenuPrint(gMainMenuString_Time, 16, 3);
+ Menu_PrintText(gMainMenuString_Time, 16, 3);
FormatPlayTime(playTime, gSaveBlock2.playTimeHours, gSaveBlock2.playTimeMinutes, 1);
sub_8072C74(alignedPlayTime, playTime, 48, 1);
- MenuPrint(alignedPlayTime, 22, 3);
+ Menu_PrintText(alignedPlayTime, 22, 3);
#elif defined(GERMAN)
MenuPrint_PixelCoords(gMainMenuString_Time, 124, 24, TRUE);
FormatPlayTime(playTime, gSaveBlock2.playTimeHours, gSaveBlock2.playTimeMinutes, 1);
sub_8072C74(alignedPlayTime, playTime, 40, 1);
- MenuPrint(alignedPlayTime, 23, 3);
+ Menu_PrintText(alignedPlayTime, 23, 3);
#endif
}
@@ -720,9 +720,9 @@ void PrintPokedexCount(void)
{
u8 buffer[16];
- MenuPrint(gMainMenuString_Pokedex, 2, 5);
+ Menu_PrintText(gMainMenuString_Pokedex, 2, 5);
sub_8072C14(buffer, GetPokedexSeenCount(), 18, 0);
- MenuPrint(buffer, 9, 5);
+ Menu_PrintText(buffer, 9, 5);
}
void PrintBadgeCount(void)
@@ -730,7 +730,7 @@ void PrintBadgeCount(void)
u8 buffer[16];
#if defined(ENGLISH)
- MenuPrint(gMainMenuString_Badges, 16, 5);
+ Menu_PrintText(gMainMenuString_Badges, 16, 5);
#elif defined(GERMAN)
MenuPrint_PixelCoords(gMainMenuString_Badges, 124, 40, TRUE);
#endif
@@ -751,7 +751,7 @@ void PrintBadgeCount(void)
static void Task_NewGameSpeech1(u8 taskId)
{
SetUpWindowConfig(&gWindowConfig_81E6C3C);
- InitMenuWindow((struct WindowConfig *)&gWindowConfig_81E6CE4);
+ InitMenuWindow((struct WindowTemplate *)&gWindowConfig_81E6CE4);
REG_WIN0H = 0;
REG_WIN0V = 0;
REG_WININ = 0;
@@ -812,7 +812,7 @@ static void Task_NewGameSpeech3(u8 taskId)
}
else
{
- MenuDrawTextWindow(2, 13, 27, 18);
+ Menu_DrawStdWindowFrame(2, 13, 27, 18);
//"Hi! Sorry to keep you waiting...
//...But everyone calls me the POKEMON PROFESSOR."
MenuPrintMessage(gBirchSpeech_Welcome, 3, 14);
@@ -886,7 +886,7 @@ static void Task_NewGameSpeech9(u8 taskId)
{
if (BirchSpeechUpdateWindowText())
{
- MenuDrawTextWindow(2, 13, 27, 18);
+ Menu_DrawStdWindowFrame(2, 13, 27, 18);
//"And you are?"
MenuPrintMessage(gBirchSpeech_AndYouAre, 3, 14);
gTasks[taskId].func = Task_NewGameSpeech10;
@@ -962,7 +962,7 @@ static void Task_NewGameSpeech13(u8 taskId)
static void Task_NewGameSpeech14(u8 taskId)
{
- MenuDrawTextWindow(2, 13, 27, 18);
+ Menu_DrawStdWindowFrame(2, 13, 27, 18);
//"Are you a boy? Or are you a girl?"
MenuPrintMessage(gBirchSpeech_AreYouBoyOrGirl, 3, 14);
gTasks[taskId].func = Task_NewGameSpeech15;
@@ -988,19 +988,19 @@ static void Task_NewGameSpeech16(u8 taskId)
HandleDestroyMenuCursors();
PlaySE(SE_SELECT);
gSaveBlock2.playerGender = MALE;
- MenuZeroFillWindowRect(2, 4, 8, 9);
+ Menu_EraseWindowRect(2, 4, 8, 9);
gTasks[taskId].func = Task_NewGameSpeech19;
break;
case FEMALE:
HandleDestroyMenuCursors();
PlaySE(SE_SELECT);
gSaveBlock2.playerGender = FEMALE;
- MenuZeroFillWindowRect(2, 4, 8, 9);
+ Menu_EraseWindowRect(2, 4, 8, 9);
gTasks[taskId].func = Task_NewGameSpeech19;
break;
}
- cursorPos = GetMenuCursorPos();
+ cursorPos = Menu_GetCursorPos();
if (cursorPos != gTasks[taskId].tGenderSelection)
{
@@ -1062,7 +1062,7 @@ static void Task_NewGameSpeech18(u8 taskId)
static void Task_NewGameSpeech19(u8 taskId)
{
- MenuDrawTextWindow(2, 13, 27, 18);
+ Menu_DrawStdWindowFrame(2, 13, 27, 18);
//"All right. What's your name?"
MenuPrintMessage(gBirchSpeech_WhatsYourName, 3, 14);
gTasks[taskId].func = Task_NewGameSpeech20;
@@ -1090,7 +1090,7 @@ static void Task_NewGameSpeech21(u8 taskId)
case 4:
HandleDestroyMenuCursors();
PlaySE(SE_SELECT);
- MenuZeroFillWindowRect(2, 1, 22, 12);
+ Menu_EraseWindowRect(2, 1, 22, 12);
SetPresetPlayerName(selection);
gTasks[taskId].func = Task_NewGameSpeech23;
break;
@@ -1102,7 +1102,7 @@ static void Task_NewGameSpeech21(u8 taskId)
case -1: //B button
HandleDestroyMenuCursors();
PlaySE(SE_SELECT);
- MenuZeroFillWindowRect(2, 1, 22, 12);
+ Menu_EraseWindowRect(2, 1, 22, 12);
gTasks[taskId].func = Task_NewGameSpeech14; //Go back to gender menu
break;
}
@@ -1120,7 +1120,7 @@ static void Task_NewGameSpeech22(u8 taskId)
static void Task_NewGameSpeech23(u8 taskId)
{
- MenuDrawTextWindow(2, 13, 27, 18);
+ Menu_DrawStdWindowFrame(2, 13, 27, 18);
//"So it's (PLAYER)?"
StringExpandPlaceholders(gStringVar4, gBirchSpeech_SoItsPlayer);
MenuPrintMessage(gStringVar4, 3, 14);
@@ -1143,7 +1143,7 @@ static void Task_NewGameSpeech25(u8 taskId)
{
case 0: //YES
PlaySE(SE_SELECT);
- MenuZeroFillWindowRect(2, 1, 8, 7);
+ Menu_EraseWindowRect(2, 1, 8, 7);
gSprites[gTasks[taskId].tTrainerSpriteId].oam.objMode = ST_OAM_OBJ_BLEND;
StartSpriteFadeOut(taskId, 2);
StartBackgroundFadeOut(taskId, 1);
@@ -1152,7 +1152,7 @@ static void Task_NewGameSpeech25(u8 taskId)
case -1: //B button
case 1: //NO
PlaySE(SE_SELECT);
- MenuZeroFillWindowRect(2, 1, 8, 7);
+ Menu_EraseWindowRect(2, 1, 8, 7);
gTasks[taskId].func = Task_NewGameSpeech14; //Go back to gender menu
break;
}
@@ -1197,7 +1197,7 @@ static void Task_NewGameSpeech27(u8 taskId)
StartSpriteFadeIn(taskId, 2);
StartBackgroundFadeIn(taskId, 1);
- MenuDrawTextWindow(2, 13, 27, 18);
+ Menu_DrawStdWindowFrame(2, 13, 27, 18);
StringExpandPlaceholders(gStringVar4, gBirchSpeech_AhOkayYouArePlayer);
//"Ah, okay! You're (PLAYER) who's moving...
//...I get it now!"
@@ -1267,7 +1267,7 @@ static void Task_NewGameSpeech29(u8 taskId)
StartSpriteFadeIn(taskId, 2);
StartBackgroundFadeIn(taskId, 1);
- MenuDrawTextWindow(2, 13, 27, 18);
+ Menu_DrawStdWindowFrame(2, 13, 27, 18);
MenuPrintMessage(gBirchSpeech_AreYouReady, 3, 14);
gTasks[taskId].func = Task_NewGameSpeech30;
}
@@ -1374,7 +1374,7 @@ void CB_ContinueNewGameSpeechPart2()
AddBirchSpeechObjects(taskId);
SetUpWindowConfig(&gWindowConfig_81E6C3C);
- InitMenuWindow((struct WindowConfig *)&gWindowConfig_81E6CE4);
+ InitMenuWindow((struct WindowTemplate *)&gWindowConfig_81E6CE4);
if (gSaveBlock2.playerGender != MALE)
{
@@ -1661,7 +1661,7 @@ static void StartBackgroundFadeIn(u8 taskId, u8 interval)
static void CreateGenderMenu(u8 left, u8 top)
{
u8 menuLeft, menuTop;
- MenuDrawTextWindow(left, top, left + 6, top + 5);
+ Menu_DrawStdWindowFrame(left, top, left + 6, top + 5);
menuLeft = left + 1;
menuTop = top + 1;
PrintMenuItems(menuLeft, menuTop, 2, gUnknown_081E79B0);
@@ -1670,12 +1670,12 @@ static void CreateGenderMenu(u8 left, u8 top)
static s8 GenderMenuProcessInput(void)
{
- return ProcessMenuInputNoWrap();
+ return Menu_ProcessInputNoWrap();
}
static void CreateNameMenu(u8 left, u8 top)
{
- MenuDrawTextWindow(left, top, left + 10, top + 11);
+ Menu_DrawStdWindowFrame(left, top, left + 10, top + 11);
if (gSaveBlock2.playerGender == MALE)
PrintMenuItems(left + 1, top + 1, 5, gMalePresetNames);
@@ -1687,7 +1687,7 @@ static void CreateNameMenu(u8 left, u8 top)
static s8 NameMenuProcessInput(void)
{
- return ProcessMenuInput();
+ return Menu_ProcessInput();
}
static void SetPresetPlayerName(u8 index)
diff --git a/src/engine/menu.c b/src/engine/menu.c
index 10988c1d7..fe88bf4e4 100644
--- a/src/engine/menu.c
+++ b/src/engine/menu.c
@@ -24,8 +24,8 @@ struct Menu
u8 columnXCoords[8];
};
-static void MultistepInitMenuWindowInternal(const struct WindowConfig *, u16);
-static void InitMenuWindowInternal(const struct WindowConfig *, u16);
+static void MultistepInitMenuWindowInternal(const struct WindowTemplate *, u16);
+static void InitMenuWindowInternal(const struct WindowTemplate *, u16);
static bool8 sub_80723D4(void);
static u8 sub_8072484(u8, u8, u8, u8, u8, u8, u32);
static u8 sub_80724F4(u8, u8, u8, const struct MenuAction[], u8);
@@ -52,7 +52,7 @@ const struct MenuAction gMenuYesNoItems[] =
void CloseMenu(void)
{
PlaySE(SE_SELECT);
- MenuZeroFillScreen();
+ Menu_EraseScreen();
sub_8064E2C();
ScriptContext2_Disable();
HandleDestroyMenuCursors();
@@ -64,22 +64,22 @@ void AppendToList(u8 *list, u8 *pindex, u32 value)
(*pindex)++;
}
-void InitMenuWindow(const struct WindowConfig *winConfig)
+void InitMenuWindow(const struct WindowTemplate *winTemplate)
{
- InitMenuWindowInternal(winConfig, 1);
+ InitMenuWindowInternal(winTemplate, 1);
}
-void MultistepInitMenuWindowBegin(const struct WindowConfig *winConfig)
+void MultistepInitMenuWindowBegin(const struct WindowTemplate *winTemplate)
{
- MultistepInitMenuWindowInternal(winConfig, 1);
+ MultistepInitMenuWindowInternal(winTemplate, 1);
}
-static void MultistepInitMenuWindowInternal(const struct WindowConfig *winConfig, u16 tileOffset)
+static void MultistepInitMenuWindowInternal(const struct WindowTemplate *winTemplate, u16 tileOffset)
{
gMenuMultistepInitState = 0;
gMenuTextTileOffset = tileOffset;
gMenuWindowPtr = &gMenuWindow;
- InitWindowFromConfig(&gMenuWindow, winConfig);
+ Text_InitWindowWithTemplate(&gMenuWindow, winTemplate);
}
bool32 MultistepInitMenuWindowContinue(void)
@@ -97,13 +97,13 @@ bool32 MultistepInitMenuWindowContinue(void)
goto fail;
goto next;
case 3:
- gMenuTextWindowContentTileOffset = SetTextWindowBaseTileNum(gMenuTextWindowTileOffset);
+ gMenuTextWindowContentTileOffset = TextWindow_SetBaseTileNum(gMenuTextWindowTileOffset);
next:
gMenuMultistepInitState++;
return 0;
case 4:
- LoadTextWindowGraphics(gMenuWindowPtr);
- gMenuMessageBoxContentTileOffset = SetMessageBoxBaseTileNum(gMenuTextWindowContentTileOffset);
+ TextWindow_LoadStdFrameGraphics(gMenuWindowPtr);
+ gMenuMessageBoxContentTileOffset = TextWindow_SetDlgFrameBaseTileNum(gMenuTextWindowContentTileOffset);
return 1;
default:
fail:
@@ -111,73 +111,73 @@ bool32 MultistepInitMenuWindowContinue(void)
}
}
-static void InitMenuWindowInternal(const struct WindowConfig *winConfig, u16 tileOffset)
+static void InitMenuWindowInternal(const struct WindowTemplate *winTemplate, u16 tileOffset)
{
gMenuWindowPtr = &gMenuWindow;
- InitWindowFromConfig(&gMenuWindow, winConfig);
+ Text_InitWindowWithTemplate(&gMenuWindow, winTemplate);
gMenuTextTileOffset = tileOffset;
gMenuTextWindowTileOffset = InitWindowTileData(gMenuWindowPtr, gMenuTextTileOffset);
- gMenuTextWindowContentTileOffset = SetTextWindowBaseTileNum(gMenuTextWindowTileOffset);
- LoadTextWindowGraphics(gMenuWindowPtr);
- gMenuMessageBoxContentTileOffset = SetMessageBoxBaseTileNum(gMenuTextWindowContentTileOffset);
+ gMenuTextWindowContentTileOffset = TextWindow_SetBaseTileNum(gMenuTextWindowTileOffset);
+ TextWindow_LoadStdFrameGraphics(gMenuWindowPtr);
+ gMenuMessageBoxContentTileOffset = TextWindow_SetDlgFrameBaseTileNum(gMenuTextWindowContentTileOffset);
}
-void unref_sub_8071DA4(struct WindowConfig *winConfig, u16 tileOffset)
+void unref_sub_8071DA4(struct WindowTemplate *winTemplate, u16 tileOffset)
{
gMenuWindowPtr = &gMenuWindow;
- InitWindowFromConfig(&gMenuWindow, winConfig);
+ Text_InitWindowWithTemplate(&gMenuWindow, winTemplate);
gMenuTextWindowTileOffset = tileOffset;
- gMenuTextWindowContentTileOffset = SetTextWindowBaseTileNum(gMenuTextWindowTileOffset);
- LoadTextWindowGraphics(gMenuWindowPtr);
- gMenuTextTileOffset = SetMessageBoxBaseTileNum(gMenuTextWindowContentTileOffset);
+ gMenuTextWindowContentTileOffset = TextWindow_SetBaseTileNum(gMenuTextWindowTileOffset);
+ TextWindow_LoadStdFrameGraphics(gMenuWindowPtr);
+ gMenuTextTileOffset = TextWindow_SetDlgFrameBaseTileNum(gMenuTextWindowContentTileOffset);
gMenuMessageBoxContentTileOffset = InitWindowTileData(gMenuWindowPtr, gMenuTextTileOffset);
}
-void MenuLoadTextWindowGraphics_OverrideFrameType(u8 frameType)
+void Menu_LoadStdFrameGraphicsOverrideStyle(u8 frameType)
{
- LoadTextWindowGraphics_OverrideFrameType(gMenuWindowPtr, frameType);
+ TextWindow_LoadStdFrameGraphicsOverrideStyle(gMenuWindowPtr, frameType);
}
-void MenuLoadTextWindowGraphics(void)
+void Menu_LoadStdFrameGraphics(void)
{
- LoadTextWindowGraphics(gMenuWindowPtr);
+ TextWindow_LoadStdFrameGraphics(gMenuWindowPtr);
}
-void BasicInitMenuWindow(const struct WindowConfig *winConfig)
+void BasicInitMenuWindow(const struct WindowTemplate *winTemplate)
{
- InitWindowFromConfig(gMenuWindowPtr, winConfig);
+ Text_InitWindowWithTemplate(gMenuWindowPtr, winTemplate);
gMenuWindowPtr->tileDataStartOffset = gMenuTextTileOffset;
}
-void MenuPrint(const u8 *str, u8 left, u8 top)
+void Menu_PrintText(const u8 *str, u8 left, u8 top)
{
- sub_8003460(gMenuWindowPtr, str, gMenuTextTileOffset, left, top);
+ Text_InitWindowAndPrintText(gMenuWindowPtr, str, gMenuTextTileOffset, left, top);
}
-void MenuZeroFillWindowRect(u8 left, u8 top, u8 right, u8 bottom)
+void Menu_EraseWindowRect(u8 left, u8 top, u8 right, u8 bottom)
{
ZeroFillWindowRect(gMenuWindowPtr, left, top, right, bottom);
}
-void MenuFillWindowRectWithBlankTile(u8 left, u8 top, u8 right, u8 bottom)
+void Menu_BlankWindowRect(u8 left, u8 top, u8 right, u8 bottom)
{
- FillWindowRectWithBlankTile(gMenuWindowPtr, left, top, right, bottom);
+ Text_BlankWindowRect(gMenuWindowPtr, left, top, right, bottom);
}
-void MenuZeroFillScreen(void)
+void Menu_EraseScreen(void)
{
- MenuZeroFillWindowRect(0, 0, 29, 19);
+ Menu_EraseWindowRect(0, 0, 29, 19);
}
-void MenuDrawTextWindow(u8 left, u8 top, u8 right, u8 bottom)
+void Menu_DrawStdWindowFrame(u8 left, u8 top, u8 right, u8 bottom)
{
- DrawTextWindow(gMenuWindowPtr, left, top, right, bottom);
+ TextWindow_DrawStdFrame(gMenuWindowPtr, left, top, right, bottom);
}
void sub_8071F40(const u8 *str)
{
- MenuDrawTextWindow(2, 14, 28, 19);
- MenuPrint(str, 3, 15);
+ Menu_DrawStdWindowFrame(2, 14, 28, 19);
+ Menu_PrintText(str, 3, 15);
}
void sub_8071F60(u8 a1, u8 a2, u8 a3)
@@ -187,27 +187,27 @@ void sub_8071F60(u8 a1, u8 a2, u8 a3)
u16 unref_sub_8071F98(u8 x, u8 y)
{
- return GetWindowTilemapEntry(gMenuWindowPtr, x, y);
+ return Text_GetWindowTilemapEntry(gMenuWindowPtr, x, y);
}
void unref_sub_8071FBC(u16 a1, u8 a2, u8 a3, u8 a4, u8 a5)
{
- DrawWindowRect(gMenuWindowPtr, a1, a2, a3, a4, a5);
+ Text_FillWindowBorder(gMenuWindowPtr, a1, a2, a3, a4, a5);
}
-void MenuDisplayMessageBox(void)
+void Menu_DisplayDialogueFrame(void)
{
- DisplayMessageBox(gMenuWindowPtr);
+ TextWindow_DisplayDialogueFrame(gMenuWindowPtr);
}
void MenuPrintMessage(const u8 *str, u8 left, u8 top)
{
- sub_8002EB0(gMenuWindowPtr, str, gMenuTextTileOffset, left, top);
+ Text_InitWindow8002EB0(gMenuWindowPtr, str, gMenuTextTileOffset, left, top);
}
void MenuPrintMessageDefaultCoords(const u8 *str)
{
- sub_8002EB0(gMenuWindowPtr, str, gMenuTextTileOffset, 2, 15);
+ Text_InitWindow8002EB0(gMenuWindowPtr, str, gMenuTextTileOffset, 2, 15);
}
void MenuSetText(const u8 *str)
@@ -215,22 +215,22 @@ void MenuSetText(const u8 *str)
sub_8002E90(gMenuWindowPtr, str);
}
-u8 MenuUpdateWindowText(void)
+u8 Menu_UpdateWindowText(void)
{
- return sub_80035AC(gMenuWindowPtr);
+ return Text_UpdateWindow(gMenuWindowPtr);
}
u8 unref_sub_8072098(void)
{
- return sub_8003418(gMenuWindowPtr);
+ return Text_PrintWindowSimple(gMenuWindowPtr);
}
-void sub_80720B0(void)
+void Menu_ClearWindowText(void)
{
- ClearWindowTextLines(gMenuWindowPtr);
+ Text_ClearWindow(gMenuWindowPtr);
}
-u8 MoveMenuCursor(s8 delta)
+u8 Menu_MoveCursor(s8 delta)
{
s32 newPos = gMenu.cursorPos + delta;
@@ -245,7 +245,7 @@ u8 MoveMenuCursor(s8 delta)
return gMenu.cursorPos;
}
-u8 MoveMenuCursorNoWrap(s8 delta)
+u8 Menu_MoveCursorNoWrap(s8 delta)
{
s32 newPos = gMenu.cursorPos + delta;
@@ -260,12 +260,12 @@ u8 MoveMenuCursorNoWrap(s8 delta)
return gMenu.cursorPos;
}
-u8 GetMenuCursorPos(void)
+u8 Menu_GetCursorPos(void)
{
return gMenu.cursorPos;
}
-s8 ProcessMenuInput(void)
+s8 Menu_ProcessInput(void)
{
if (gMain.newKeys & A_BUTTON)
{
@@ -285,20 +285,20 @@ s8 ProcessMenuInput(void)
if (gMain.newKeys & DPAD_UP)
{
PlaySE(SE_SELECT);
- MoveMenuCursor(-1);
+ Menu_MoveCursor(-1);
return -2;
}
else if (gMain.newKeys & DPAD_DOWN)
{
PlaySE(SE_SELECT);
- MoveMenuCursor(1);
+ Menu_MoveCursor(1);
return -2;
}
return -2;
}
-s8 ProcessMenuInputNoWrap(void)
+s8 Menu_ProcessInputNoWrap(void)
{
u8 cursorPos = gMenu.cursorPos;
@@ -319,18 +319,18 @@ s8 ProcessMenuInputNoWrap(void)
if (gMain.newKeys & DPAD_UP)
{
- if (cursorPos != MoveMenuCursorNoWrap(-1))
+ if (cursorPos != Menu_MoveCursorNoWrap(-1))
PlaySE(SE_SELECT);
return -2;
}
else if (gMain.newKeys & DPAD_DOWN)
{
- if (cursorPos != MoveMenuCursorNoWrap(1))
+ if (cursorPos != Menu_MoveCursorNoWrap(1))
PlaySE(SE_SELECT);
return -2;
}
- MoveMenuCursorNoWrap(0);
+ Menu_MoveCursorNoWrap(0);
return -2;
}
@@ -465,7 +465,7 @@ static u8 sub_80724F4(u8 left, u8 top, u8 menuItemCount, const struct MenuAction
totalWidth = (gMenu.columnXCoords[columnCount] + 1);
right = left + totalWidth;
- MenuDrawTextWindow(left, top, right, bottom);
+ Menu_DrawStdWindowFrame(left, top, right, bottom);
}
return maxWidth;
@@ -501,7 +501,7 @@ static void sub_8072620(u8 left, u8 top, u8 menuItemCount, const struct MenuActi
u8 row = 0;
u8 j;
for (j = 0; i + j < menuItemCount; j += columnCount, row++)
- MenuPrint(menuItems[i + j].text, left + gMenu.columnXCoords[i % columnCount], top + 2 * row);
+ Menu_PrintText(menuItems[i + j].text, left + gMenu.columnXCoords[i % columnCount], top + 2 * row);
}
}
@@ -513,14 +513,14 @@ void sub_807274C(u8 left, u8 top, u8 menuItemCount, u8 a4, const struct MenuActi
sub_8072620(left + 1, top + 1, menuItemCount, menuItems, columnCount);
}
-s8 sub_80727CC(void)
+s8 Menu_ProcessInputGridLayout(void)
{
if (gMain.newKeys & A_BUTTON)
{
if (gMenu.menu_field_7)
HandleDestroyMenuCursors();
PlaySE(SE_SELECT);
- return GetMenuCursorPos();
+ return Menu_GetCursorPos();
}
if (gMain.newKeys & B_BUTTON)
@@ -568,7 +568,7 @@ void PrintMenuItems(u8 left, u8 top, u8 menuItemCount, const struct MenuAction m
u8 i;
for (i = 0; i < menuItemCount; i++)
- MenuPrint(menuItems[i].text, left, top + 2 * i);
+ Menu_PrintText(menuItems[i].text, left, top + 2 * i);
}
void PrintMenuItemsReordered(u8 left, u8 top, u8 menuItemCount, const struct MenuAction2 menuItems[], const u8 *order)
@@ -576,7 +576,7 @@ void PrintMenuItemsReordered(u8 left, u8 top, u8 menuItemCount, const struct Men
u8 i;
for (i = 0; i < menuItemCount; i++)
- MenuPrint(menuItems[order[i]].text, left, top + 2 * i);
+ Menu_PrintText(menuItems[order[i]].text, left, top + 2 * i);
}
void InitYesNoMenu(u8 left, u8 top, u8 a3)
@@ -587,14 +587,14 @@ void InitYesNoMenu(u8 left, u8 top, u8 a3)
void DisplayYesNoMenu(u8 left, u8 top, u32 a3)
{
- MenuDrawTextWindow(left, top, left + 6, top + 5);
+ Menu_DrawStdWindowFrame(left, top, left + 6, top + 5);
InitYesNoMenu(left, top, 5);
gMenu.menu_field_7 = a3 ? -1 : 0;
}
s8 ProcessMenuInputNoWrap_(void)
{
- return ProcessMenuInputNoWrap();
+ return Menu_ProcessInputNoWrap();
}
u8 MenuPrint_PixelCoords(const u8 *text, u8 left, u16 top, u8 a4)
@@ -623,7 +623,7 @@ int sub_8072AB0(const u8 *str, u8 left, u16 top, u8 width, u8 height, u32 a6)
height = (height + 7) / 8;
if (newlineCount < height)
- MenuFillWindowRectWithBlankTile(left, top + 2 * newlineCount, left + width - 1, height + top - 1);
+ Menu_BlankWindowRect(left, top + 2 * newlineCount, left + width - 1, height + top - 1);
}
#elif GERMAN
__attribute__((naked))
@@ -700,7 +700,7 @@ _08072B0C:\n\
lsls r3, 24\n\
lsrs r3, 24\n\
adds r0, r5, 0\n\
- bl MenuFillWindowRectWithBlankTile\n\
+ bl Menu_BlankWindowRect\n\
_08072B3E:\n\
add sp, 0x10\n\
pop {r4-r7}\n\
@@ -720,7 +720,7 @@ void sub_8072B80(const u8 *a1, u8 a2, u8 a3, const u8 *a4)
u8 buffer[64];
u8 width = GetStringWidth(gMenuWindowPtr, a4);
AlignString(gMenuWindowPtr, buffer, a1, width, 1);
- sub_8003460(gMenuWindowPtr, buffer, gMenuTextTileOffset, a2, a3);
+ Text_InitWindowAndPrintText(gMenuWindowPtr, buffer, gMenuTextTileOffset, a2, a3);
}
void sub_8072BD8(const u8 *a1, u8 a2, u8 a3, u16 a4)
@@ -753,14 +753,14 @@ u8 sub_8072CBC()
return sub_8004E24(gMenuWindowPtr);
}
-void sub_8072CD4(u8 *a1, u8 *a2, u8 *a3)
+void Menu_GetTextColors(u8 *a1, u8 *a2, u8 *a3)
{
- sub_8004E28(gMenuWindowPtr, a1, a2, a3);
+ Text_GetTextColors(gMenuWindowPtr, a1, a2, a3);
}
u32 MenuUpdateWindowText_OverrideLineLength(u8 lineLength)
{
- return sub_80037C8(gMenuWindowPtr, lineLength);
+ return Text_UpdateWindowOverrideLineLength(gMenuWindowPtr, lineLength);
}
struct Window *unref_sub_8072D0C(void)
@@ -792,7 +792,7 @@ u8 InitMenu(u8 cursorSubpriority, u8 left, u8 top, u8 numChoices, u8 cursorPos,
pos = 0;
gMenu.cursorPos = pos;
- MoveMenuCursor(0);
+ Menu_MoveCursor(0);
return pos;
}
diff --git a/src/engine/mystery_event_menu.c b/src/engine/mystery_event_menu.c
index b9c3d5ad8..abb912938 100644
--- a/src/engine/mystery_event_menu.c
+++ b/src/engine/mystery_event_menu.c
@@ -47,7 +47,7 @@ void CB2_InitMysteryEventMenu(void)
SetVBlankCallback(VBlankCB);
SetUpWindowConfig(&gWindowConfig_81E6CE4);
InitMenuWindow(&gWindowConfig_81E6CE4);
- MenuZeroFillScreen();
+ Menu_EraseScreen();
REG_DISPCNT = DISPCNT_MODE_0 | DISPCNT_OBJ_1D_MAP | DISPCNT_BG0_ON;
REG_BLDCNT = 0;
CreateTask(Task_DestroySelf, 0);
@@ -86,7 +86,7 @@ static void CB2_MysteryEventMenu(void)
switch (gMain.state)
{
case 0:
- MenuDrawTextWindow(0, 14, 29, 19);
+ Menu_DrawStdWindowFrame(0, 14, 29, 19);
BeginNormalPaletteFade(0xFFFFFFFF, 0, 0x10, 0, 0);
gMain.state++;
break;
@@ -97,7 +97,7 @@ static void CB2_MysteryEventMenu(void)
gMain.state++;
break;
case 2:
- if (MenuUpdateWindowText())
+ if (Menu_UpdateWindowText())
{
gMain.state++;
gLinkType = 21761;
@@ -119,7 +119,7 @@ static void CB2_MysteryEventMenu(void)
}
break;
case 4:
- if (MenuUpdateWindowText())
+ if (Menu_UpdateWindowText())
gMain.state++;
break;
#ifdef NONMATCHING
@@ -135,8 +135,8 @@ static void CB2_MysteryEventMenu(void)
{
PlaySE(SE_SELECT);
sub_8007F4C();
- MenuDrawTextWindow(6, 5, 23, 8);
- MenuPrint(gSystemText_LoadingEvent, 7, 6);
+ Menu_DrawStdWindowFrame(6, 5, 23, 8);
+ Menu_PrintText(gSystemText_LoadingEvent, 7, 6);
gMain.state++;
}
else if (gMain.newKeys & B_BUTTON)
@@ -155,7 +155,7 @@ static void CB2_MysteryEventMenu(void)
if (GetLinkPlayerDataExchangeStatusTimed() == 3)
{
sub_800832C();
- MenuZeroFillWindowRect(6, 5, 23, 8);
+ Menu_EraseWindowRect(6, 5, 23, 8);
GetEventLoadMessage(gStringVar4, 1);
MenuPrintMessageDefaultCoords(gStringVar4);
gMain.state = 13;
@@ -170,7 +170,7 @@ static void CB2_MysteryEventMenu(void)
else
{
CloseLink();
- MenuZeroFillWindowRect(6, 5, 23, 8);
+ Menu_EraseWindowRect(6, 5, 23, 8);
GetEventLoadMessage(gStringVar4, 1);
MenuPrintMessageDefaultCoords(gStringVar4);
gMain.state = 13;
@@ -195,8 +195,8 @@ static void CB2_MysteryEventMenu(void)
{
PlaySE(SE_SELECT);
sub_8007F4C();
- MenuDrawTextWindow(6, 5, 23, 8);
- MenuPrint(gSystemText_LoadingEvent, 7, 6);
+ Menu_DrawStdWindowFrame(6, 5, 23, 8);
+ Menu_PrintText(gSystemText_LoadingEvent, 7, 6);
gMain.state++;
}
else if (gMain.newKeys & B_BUTTON)
@@ -219,7 +219,7 @@ static void CB2_MysteryEventMenu(void)
if (GetLinkPlayerDataExchangeStatusTimed() == 3)
{
sub_800832C();
- MenuZeroFillWindowRect(6, 5, 23, 8);
+ Menu_EraseWindowRect(6, 5, 23, 8);
GetEventLoadMessage(gStringVar4, 1);
MenuPrintMessageDefaultCoords(gStringVar4);
ptr = (u8 *)&gMain;
@@ -245,7 +245,7 @@ static void CB2_MysteryEventMenu(void)
else
{
CloseLink();
- MenuZeroFillWindowRect(6, 5, 23, 8);
+ Menu_EraseWindowRect(6, 5, 23, 8);
label:
GetEventLoadMessage(gStringVar4, 1);
MenuPrintMessageDefaultCoords(gStringVar4);
@@ -266,7 +266,7 @@ static void CB2_MysteryEventMenu(void)
break;
#endif
case 7:
- if (MenuUpdateWindowText())
+ if (Menu_UpdateWindowText())
gMain.state++;
break;
case 8:
@@ -297,8 +297,8 @@ static void CB2_MysteryEventMenu(void)
gMain.state++;
break;
case 13:
- MenuZeroFillWindowRect(6, 5, 23, 8);
- if (MenuUpdateWindowText())
+ Menu_EraseWindowRect(6, 5, 23, 8);
+ if (Menu_UpdateWindowText())
{
gMain.state++;
gUnknown_02039338 = 0;
@@ -326,7 +326,7 @@ static void CB2_MysteryEventMenu(void)
if (!IsLinkMaster())
{
CloseLink();
- MenuZeroFillWindowRect(6, 5, 23, 8);
+ Menu_EraseWindowRect(6, 5, 23, 8);
GetEventLoadMessage(gStringVar4, 1);
MenuPrintMessageDefaultCoords(gStringVar4);
gMain.state = 13;
diff --git a/src/engine/naming_screen.c b/src/engine/naming_screen.c
index 440504d5a..5685584f5 100644
--- a/src/engine/naming_screen.c
+++ b/src/engine/naming_screen.c
@@ -503,7 +503,7 @@ static bool8 MainState_6(struct Task *task)
static bool8 MainState_UpdateSentToPCMessage(struct Task *task)
{
- if (MenuUpdateWindowText())
+ if (Menu_UpdateWindowText())
namingScreenDataPtr->state++;
return FALSE;
}
@@ -1611,7 +1611,7 @@ static void DisplaySentToPCMessage(void)
StringCopy(gStringVar1, namingScreenDataPtr->destBuffer);
StringExpandPlaceholders(gStringVar4, gOtherText_SentToPC);
BasicInitMenuWindow(&gWindowConfig_81E6E88);
- MenuDisplayMessageBox();
+ Menu_DisplayDialogueFrame();
MenuPrintMessageDefaultCoords(gStringVar4);
}
@@ -1757,7 +1757,7 @@ static void (*const gUnknown_083CE310[][2])(void) =
sub_80B7844,
};
-static const struct WindowConfig *const gUnknown_083CE328[][2][2] =
+static const struct WindowTemplate *const gUnknown_083CE328[][2][2] =
{
{
{&gWindowConfig_81E6EDC, &gWindowConfig_81E6EF8},
@@ -1838,7 +1838,7 @@ static void PrintKeyboardCharacters(u8 page) //print letters on page
s16 r5;
for (i = 0, r5 = 9; i < 4; i++, r5 += 2)
- MenuPrint(sKeyboardCharacters[page][i], 3, r5);
+ Menu_PrintText(sKeyboardCharacters[page][i], 3, r5);
}
static void sub_80B78A8(void)
@@ -1846,7 +1846,7 @@ static void sub_80B78A8(void)
BasicInitMenuWindow(&gWindowConfig_81E6F4C);
gUnknown_083CE358[namingScreenDataPtr->templateNum]();
gUnknown_083CE368[namingScreenDataPtr->template->unk3]();
- MenuPrint(namingScreenDataPtr->template->title, 9, 2);
+ Menu_PrintText(namingScreenDataPtr->template->title, 9, 2);
}
static void nullsub_61(void)
@@ -1870,7 +1870,7 @@ static void sub_80B7924(void)
{
if ((s16)namingScreenDataPtr->unk40 == MON_FEMALE)
genderSymbol[0] = 0xB6; //female symbol
- MenuPrint(genderSymbol, 0x14, 4);
+ Menu_PrintText(genderSymbol, 0x14, 4);
}
}
@@ -1887,7 +1887,7 @@ static void sub_80B7960(void)
string += 6;
StringCopy(string, namingScreenDataPtr->textBuffer);
BasicInitMenuWindow(&gWindowConfig_81E6F4C);
- MenuPrint(gStringVar1, namingScreenDataPtr->unk2, 4);
+ Menu_PrintText(gStringVar1, namingScreenDataPtr->unk2, 4);
}
//--------------------------------------------------
diff --git a/src/engine/option_menu.c b/src/engine/option_menu.c
index dfc49b035..f35ed5b5a 100644
--- a/src/engine/option_menu.c
+++ b/src/engine/option_menu.c
@@ -173,17 +173,17 @@ void CB2_InitOptionMenu(void)
gTasks[taskId].data[TD_BUTTONMODE] = gSaveBlock2.optionsButtonMode;
gTasks[taskId].data[TD_FRAMETYPE] = gSaveBlock2.optionsWindowFrameType;
- MenuDrawTextWindow(2, 0, 27, 3);
- MenuDrawTextWindow(2, 4, 27, 19);
-
- MenuPrint(gSystemText_OptionMenu, 4, 1);
- MenuPrint(gSystemText_TextSpeed, 4, 5);
- MenuPrint(gSystemText_BattleScene, 4, 7);
- MenuPrint(gSystemText_BattleStyle, 4, 9);
- MenuPrint(gSystemText_Sound, 4, 11);
- MenuPrint(gSystemText_ButtonMode, 4, 13);
- MenuPrint(gSystemText_Frame, 4, 15);
- MenuPrint(gSystemText_Cancel, 4, 17);
+ Menu_DrawStdWindowFrame(2, 0, 27, 3);
+ Menu_DrawStdWindowFrame(2, 4, 27, 19);
+
+ Menu_PrintText(gSystemText_OptionMenu, 4, 1);
+ Menu_PrintText(gSystemText_TextSpeed, 4, 5);
+ Menu_PrintText(gSystemText_BattleScene, 4, 7);
+ Menu_PrintText(gSystemText_BattleStyle, 4, 9);
+ Menu_PrintText(gSystemText_Sound, 4, 11);
+ Menu_PrintText(gSystemText_ButtonMode, 4, 13);
+ Menu_PrintText(gSystemText_Frame, 4, 15);
+ Menu_PrintText(gSystemText_Cancel, 4, 17);
TextSpeed_DrawChoices(gTasks[taskId].data[TD_TEXTSPEED]);
BattleScene_DrawChoices(gTasks[taskId].data[TD_BATTLESCENE]);
@@ -432,11 +432,11 @@ static u8 FrameType_ProcessInput(u8 selection)
{
if (gMain.newKeys & DPAD_RIGHT)
{
- if (selection <= 18)
+ if (selection < 19)
selection++;
else
selection = 0;
- MenuLoadTextWindowGraphics_OverrideFrameType(selection);
+ Menu_LoadStdFrameGraphicsOverrideStyle(selection);
}
if (gMain.newKeys & DPAD_LEFT)
{
@@ -444,7 +444,7 @@ static u8 FrameType_ProcessInput(u8 selection)
selection--;
else
selection = 19;
- MenuLoadTextWindowGraphics_OverrideFrameType(selection);
+ Menu_LoadStdFrameGraphicsOverrideStyle(selection);
}
return selection;
}
@@ -478,8 +478,8 @@ static void FrameType_DrawChoices(u8 selection)
}
text[i] = EOS;
- MenuPrint(gSystemText_Type, 15, 15);
- MenuPrint(text, 18, 15);
+ Menu_PrintText(gSystemText_Type, 15, 15);
+ Menu_PrintText(text, 18, 15);
}
#elif GERMAN
__attribute__((naked))
@@ -536,7 +536,7 @@ _0808C380:\n\
mov r0, sp\n\
movs r1, 0xF\n\
movs r2, 0xF\n\
- bl MenuPrint\n\
+ bl Menu_PrintText\n\
add sp, 0x10\n\
pop {r4-r6}\n\
pop {r0}\n\
diff --git a/src/engine/record_mixing.c b/src/engine/record_mixing.c
index c8e2e34d5..75ca92e6a 100644
--- a/src/engine/record_mixing.c
+++ b/src/engine/record_mixing.c
@@ -146,8 +146,8 @@ void Task_RecordMixing_Main(u8 taskId)
{
tState = 4;
data[10] = sub_8083664();
- sub_80720B0();
- MenuPrint(gOtherText_MixingComplete, 2, 15);
+ Menu_ClearWindowText();
+ Menu_PrintText(gOtherText_MixingComplete, 2, 15);
data[8] = 0;
}
break;
@@ -160,7 +160,7 @@ void Task_RecordMixing_Main(u8 taskId)
if (!gTasks[data[10]].isActive)
{
sub_8055588();
- MenuZeroFillScreen();
+ Menu_EraseScreen();
DestroyTask(taskId);
EnableBothScriptContexts();
}
@@ -176,8 +176,8 @@ void sub_80B95F0(u8 taskId)
{
case 0:
sub_80B9A78();
- MenuDisplayMessageBox();
- MenuPrint(gOtherText_MixingRecordsWithFriend, 2, 15);
+ Menu_DisplayDialogueFrame();
+ Menu_PrintText(gOtherText_MixingRecordsWithFriend, 2, 15);
task->data[8] = 0x708;
task->tState = 400;
ClearLinkCallback_2();
diff --git a/src/engine/reset_rtc_screen.c b/src/engine/reset_rtc_screen.c
index 67e146899..eb823b84b 100644
--- a/src/engine/reset_rtc_screen.c
+++ b/src/engine/reset_rtc_screen.c
@@ -267,7 +267,7 @@ void ResetRtcScreen_FreeCursorPalette(void)
void ResetRtcScreen_HideChooseTimeWindow(void)
{
- MenuZeroFillWindowRect(3, 8, 25, 11);
+ Menu_EraseWindowRect(3, 8, 25, 11);
}
void ResetRtcScreen_PrintTime(u8 x, u8 y, u16 days, u8 hours, u8 minutes, u8 seconds)
@@ -286,13 +286,13 @@ void ResetRtcScreen_PrintTime(u8 x, u8 y, u16 days, u8 hours, u8 minutes, u8 sec
dest = ConvertIntToDecimalStringN(dest, minutes, STR_CONV_MODE_LEADING_ZEROS, 2);
dest = StringCopy(dest, gUnknown_08376500);
ConvertIntToDecimalStringN(dest, seconds, STR_CONV_MODE_LEADING_ZEROS, 2);
- MenuPrint(gStringVar4, x, y);
+ Menu_PrintText(gStringVar4, x, y);
}
void ResetRtcScreen_ShowChooseTimeWindow(u16 days, u8 hours, u8 minutes, u8 seconds)
{
- MenuDrawTextWindow(3, 8, 25, 11);
- MenuPrint(gOtherText_OK, 20, 9);
+ Menu_DrawStdWindowFrame(3, 8, 25, 11);
+ Menu_PrintText(gOtherText_OK, 20, 9);
ResetRtcScreen_PrintTime(4, 9, days, hours, minutes, seconds);
}
@@ -468,8 +468,8 @@ void VBlankCB_ResetRtcScreen(void)
void ResetRtcScreen_ShowMessage(const u8 *str)
{
- MenuDisplayMessageBox();
- MenuPrint(str, 2, 15);
+ Menu_DisplayDialogueFrame();
+ Menu_PrintText(str, 2, 15);
}
void Task_ShowResetRtcPrompt(u8 taskId)
@@ -479,9 +479,9 @@ void Task_ShowResetRtcPrompt(u8 taskId)
switch (data[0])
{
case 0:
- MenuZeroFillScreen();
- MenuDrawTextWindow(0, 0, 20, 10);
- MenuPrint(gSystemText_PresentTime, 1, 1);
+ Menu_EraseScreen();
+ Menu_DrawStdWindowFrame(0, 0, 20, 10);
+ Menu_PrintText(gSystemText_PresentTime, 1, 1);
ResetRtcScreen_PrintTime(
1,
3,
@@ -489,7 +489,7 @@ void Task_ShowResetRtcPrompt(u8 taskId)
gLocalTime.hours,
gLocalTime.minutes,
gLocalTime.seconds);
- MenuPrint(gSystemText_PreviousTime, 1, 5);
+ Menu_PrintText(gSystemText_PreviousTime, 1, 5);
ResetRtcScreen_PrintTime(
1,
7,
@@ -543,7 +543,7 @@ void Task_ResetRtcScreen(u8 taskId)
case 2:
if (gTasks[data[1]].isActive != TRUE)
{
- MenuZeroFillScreen();
+ Menu_EraseScreen();
ResetRtcScreen_ShowMessage(gSystemText_PleaseResetTime);
gLocalTime = gSaveBlock2.lastBerryTreeUpdate;
data[1] = CreateTask(Task_ResetRtc_0, 80);
diff --git a/src/engine/save_failed_screen.c b/src/engine/save_failed_screen.c
index ba2d46546..a4642d241 100644
--- a/src/engine/save_failed_screen.c
+++ b/src/engine/save_failed_screen.c
@@ -122,9 +122,9 @@ static void CB2_SaveFailedScreen(void)
LoadPalette(&gSaveFailedClockPal, 0x100, sizeof(gSaveFailedClockPal));
SetUpWindowConfig(&gWindowConfig_81E6C3C);
InitMenuWindow(&gWindowConfig_81E6CE4);
- MenuDrawTextWindow(13, CLOCK_WIN_TOP, 16, CLOCK_WIN_TOP + 3); // clock window
- MenuDrawTextWindow(1, MSG_WIN_TOP, 28, 19); // message window
- MenuPrint(gSystemText_SaveFailedBackupCheck, 2, MSG_WIN_TOP + 1);
+ Menu_DrawStdWindowFrame(13, CLOCK_WIN_TOP, 16, CLOCK_WIN_TOP + 3); // clock window
+ Menu_DrawStdWindowFrame(1, MSG_WIN_TOP, 28, 19); // message window
+ Menu_PrintText(gSystemText_SaveFailedBackupCheck, 2, MSG_WIN_TOP + 1);
BeginNormalPaletteFade(0xFFFFFFFF, 0, 16, 0, 0);
ime = REG_IME;
REG_IME = 0;
@@ -158,22 +158,22 @@ static void CB2_WipeSave(void)
{
if (WipeSectors(gDamagedSaveSectors) != FALSE)
{
- MenuDrawTextWindow(1, MSG_WIN_TOP, 28, 19);
- MenuPrint(gSystemText_BackupDamagedGameContinue, 2, MSG_WIN_TOP + 1);
+ Menu_DrawStdWindowFrame(1, MSG_WIN_TOP, 28, 19);
+ Menu_PrintText(gSystemText_BackupDamagedGameContinue, 2, MSG_WIN_TOP + 1);
SetMainCallback2(CB2_GameplayCannotBeContinued);
return;
}
- MenuDrawTextWindow(1, MSG_WIN_TOP, 28, 19);
- MenuPrint(gSystemText_CheckCompleteSaveAttempt, 2, MSG_WIN_TOP + 1);
+ Menu_DrawStdWindowFrame(1, MSG_WIN_TOP, 28, 19);
+ Menu_PrintText(gSystemText_CheckCompleteSaveAttempt, 2, MSG_WIN_TOP + 1);
HandleSavingData(gSaveFailedType);
if (gDamagedSaveSectors != 0)
{
#ifdef BUGFIX_SAVEFAILEDSCREEN2
- MenuDrawTextWindow(1, MSG_WIN_TOP, 28, 19);
+ Menu_DrawStdWindowFrame(1, MSG_WIN_TOP, 28, 19);
#endif
- MenuPrint(gSystemText_SaveFailedBackupCheck, 2, MSG_WIN_TOP + 1);
+ Menu_PrintText(gSystemText_SaveFailedBackupCheck, 2, MSG_WIN_TOP + 1);
}
wipeTries++;
@@ -181,19 +181,19 @@ static void CB2_WipeSave(void)
if (wipeTries == 3)
{
- MenuDrawTextWindow(1, MSG_WIN_TOP, 28, 19);
- MenuPrint(gSystemText_BackupDamagedGameContinue, 2, MSG_WIN_TOP + 1);
+ Menu_DrawStdWindowFrame(1, MSG_WIN_TOP, 28, 19);
+ Menu_PrintText(gSystemText_BackupDamagedGameContinue, 2, MSG_WIN_TOP + 1);
SetMainCallback2(CB2_FadeAndReturnToTitleScreen); // called again below
}
else
{
- MenuDrawTextWindow(1, MSG_WIN_TOP, 28, 19);
+ Menu_DrawStdWindowFrame(1, MSG_WIN_TOP, 28, 19);
// no callback exists, so the game cannot continue.
if (gGameContinueCallback == 0)
- MenuPrint(gSystemText_SaveCompletedGameEnd, 2, MSG_WIN_TOP + 1);
+ Menu_PrintText(gSystemText_SaveCompletedGameEnd, 2, MSG_WIN_TOP + 1);
else // callback exists, so continue
- MenuPrint(gSystemText_SaveCompletedPressA, 2, MSG_WIN_TOP + 1);
+ Menu_PrintText(gSystemText_SaveCompletedPressA, 2, MSG_WIN_TOP + 1);
}
SetMainCallback2(CB2_FadeAndReturnToTitleScreen);
@@ -205,8 +205,8 @@ static void CB2_GameplayCannotBeContinued(void)
if (gMain.newKeys & A_BUTTON)
{
- MenuDrawTextWindow(1, MSG_WIN_TOP, 28, 19);
- MenuPrint(gSystemText_GameplayEnded, 2, MSG_WIN_TOP + 1);
+ Menu_DrawStdWindowFrame(1, MSG_WIN_TOP, 28, 19);
+ Menu_PrintText(gSystemText_GameplayEnded, 2, MSG_WIN_TOP + 1);
SetVBlankCallback(VBlankCB);
SetMainCallback2(CB2_FadeAndReturnToTitleScreen);
}
diff --git a/src/engine/save_menu_util.c b/src/engine/save_menu_util.c
index 771cb72c7..2c5eb6afe 100644
--- a/src/engine/save_menu_util.c
+++ b/src/engine/save_menu_util.c
@@ -18,7 +18,7 @@ void HandleDrawSaveWindowInfo(s16 left, s16 top)
if (FlagGet(FLAG_SYS_POKEDEX_GET))
{
// print info + dex information.
- MenuDrawTextWindow(left, top, left + width, top + 11);
+ Menu_DrawStdWindowFrame(left, top, left + width, top + 11);
PrintSaveMapName(++left, ++top); // MAP NAME
PrintSavePlayerName(left, top + 2); // PLAYER
PrintSaveBadges(left, top + 4); // BADGES
@@ -28,7 +28,7 @@ void HandleDrawSaveWindowInfo(s16 left, s16 top)
else
{
// print everything besides dex.
- MenuDrawTextWindow(left, top, left + width, top + 9);
+ Menu_DrawStdWindowFrame(left, top, left + width, top + 9);
PrintSaveMapName(++left, ++top); // MAP NAME
PrintSavePlayerName(left, top + 2); // PLAYER
PrintSaveBadges(left, top + 4); // BADGES
@@ -45,9 +45,9 @@ void HandleCloseSaveWindow(u16 left, u16 top)
width = 13;
if (FlagGet(FLAG_SYS_POKEDEX_GET))
- MenuZeroFillWindowRect(left, top, left + width, top + 11);
+ Menu_EraseWindowRect(left, top, left + width, top + 11);
else
- MenuZeroFillWindowRect(left, top, left + width, top + 9);
+ Menu_EraseWindowRect(left, top, left + width, top + 9);
}
/*
@@ -62,7 +62,7 @@ u8 IsResizeSaveWindowEnabled(void) // i don't know what else to name it..
void PrintSavePlayerName(s16 x, s16 y)
{
- MenuPrint(gOtherText_Player, x, y);
+ Menu_PrintText(gOtherText_Player, x, y);
MenuPrint_RightAligned(gSaveBlock2.playerName, x + 12, y);
}
@@ -71,14 +71,14 @@ void PrintSaveMapName(s16 x, s16 y)
char name[32];
CopyMapName(name, gMapHeader.regionMapSectionId);
- MenuPrint(name, x, y);
+ Menu_PrintText(name, x, y);
}
void PrintSaveBadges(s16 x, s16 y)
{
char badges[16];
- MenuPrint(gOtherText_Badges, x, y);
+ Menu_PrintText(gOtherText_Badges, x, y);
ConvertIntToDecimalString(badges, GetBadgeCount());
MenuPrint_RightAligned(badges, x + 12, y);
}
@@ -87,7 +87,7 @@ void PrintSavePokedexCount(s16 x, s16 y)
{
char pokedex[16];
- MenuPrint(gOtherText_Pokedex, x, y);
+ Menu_PrintText(gOtherText_Pokedex, x, y);
ConvertIntToDecimalStringN(pokedex, GetPokedexSeenCount(), 1, 3);
MenuPrint_RightAligned(pokedex, x + 12, y);
}
@@ -96,7 +96,7 @@ void PrintSavePlayTime(s16 x, s16 y)
{
char playtime[16];
- MenuPrint(gOtherText_PlayTime, x, y);
+ Menu_PrintText(gOtherText_PlayTime, x, y);
FormatPlayTime(playtime, gSaveBlock2.playTimeHours, gSaveBlock2.playTimeMinutes, 1);
MenuPrint_RightAligned(playtime, x + 12, y);
}
diff --git a/src/engine/text.c b/src/engine/text.c
index 1b158d979..2d6d95877 100644
--- a/src/engine/text.c
+++ b/src/engine/text.c
@@ -12,16 +12,31 @@ enum
WIN_STATE_END,
WIN_STATE_BEGIN,
WIN_STATE_NORMAL,
- WIN_STATE_INTERRUPTIBLE_PAUSE,
+ WIN_STATE_CHAR_DELAY,
WIN_STATE_PAUSE,
WIN_STATE_WAIT_BUTTON,
WIN_STATE_NEWLINE,
WIN_STATE_PLACEHOLDER,
- WIN_STATE_PARAGRAPH,
- WIN_STATE_NEWLINE_WAIT,
+ WIN_STATE_WAIT_CLEAR,
+ WIN_STATE_WAIT_SCROLL,
WIN_STATE_WAIT_SOUND,
};
+enum
+{
+ TEXT_MODE_UNKNOWN0,
+ TEXT_MODE_MONOSPACE,
+ TEXT_MODE_UNKNOWN2, // variable width?
+};
+
+enum
+{
+ WAIT_TYPE_NORMAL, // allows the player to interrupt the text delay with A or B
+ WAIT_TYPE_BATTLE, // disables interrupting the text delay if in a link battle
+ WAIT_TYPE_AUTOSCROLL, // disables interrupting the text delay
+ WAIT_TYPE_CONTEST, // disables interrupting the text delay if in a link contest
+};
+
struct Font
{
u32 type;
@@ -66,7 +81,7 @@ static u16 LoadFixedWidthFont_Font4Latin(struct Window *, u16);
static u16 LoadFixedWidthFont_Braille(struct Window *, u16);
static void MultistepLoadFont_LoadGlyph(struct Window *, u16, u8);
static u8 sub_8002FA0(struct Window *, const u8 *);
-static u8 InterpretText(struct Window *);
+static u8 PrintNextChar(struct Window *);
static u8 HandleExtCtrlCode(struct Window *);
static u8 UpdateWindowText(struct Window *);
static u8 DrawGlyph_TextMode0(struct Window *, u32);
@@ -83,26 +98,26 @@ static void AddToCursorY(struct Window *, u8);
static void ClipLeft(struct Window *);
static void ClipRight(struct Window *);
static void InitColors(struct Window *);
-static void SetBackgroundColor(struct Window *, u8);
-static void SetShadowColor(struct Window *, u8);
-static void SetForegroundColor(struct Window *, u8);
+static void SetWindowBackgroundColor(struct Window *, u8);
+static void SetWindowShadowColor(struct Window *, u8);
+static void SetWindowForegroundColor(struct Window *, u8);
static u8 GetTextDelay(struct Window *);
-static bool8 PlayerCanInterruptWait(struct Window *);
+static bool8 PlayerCanInterruptDelay(struct Window *);
static void ScrollWindowTextLines(struct Window *);
static void ScrollWindowTextLines_TextMode0(struct Window *);
static void DoScroll_TextMode0(struct Window *, u16);
-static void ScrollWindowTextLines_TextMode1(struct Window *);
-static void DoScroll_TextMode1(struct Window *, u16);
+static void ScrollWindowTextLines_TextModeMonospace(struct Window *);
+static void DoScroll_TextModeMonospace(struct Window *, u16);
static void ScrollWindowTextLines_TextMode2(struct Window *);
static void DoScroll_TextMode2(struct Window *, u8);
-void ClearWindowTextLines(struct Window *);
+void Text_ClearWindow(struct Window *);
static void ClearWindowTextLines_TextMode0_TextMode1(struct Window *, u8);
static void ClearWindowTextLines_TextMode2(struct Window *, u8);
static void TryEraseDownArrow(struct Window *);
static u16 GetBlankTileNum(struct Window *);
static u8 WaitWithDownArrow(struct Window *);
static void DrawInitialDownArrow(struct Window *);
-static void DrawMovingDownArrow(struct Window *);
+static void UpdateDownArrowAnimation(struct Window *);
static u16 GetCursorTileNum(struct Window *, u32, u32);
static s32 DrawGlyphTiles(struct Window *, u32, u32);
static void UpdateTilemap(struct Window *, u32);
@@ -477,7 +492,7 @@ static const ShiftGlyphTileShadowedFunc sShiftGlyphTileShadowedFuncs[] =
ShiftGlyphTile_ShadowedFont_Width8,
};
-const struct WindowConfig gWindowConfig_81E6C3C =
+const struct WindowTemplate gWindowConfig_81E6C3C =
{
0, // BG number
2, // BG character base block
@@ -498,7 +513,7 @@ const struct WindowConfig gWindowConfig_81E6C3C =
BG_SCREEN_ADDR(31), // tilemap
};
-const struct WindowConfig gWindowConfig_81E6C58 =
+const struct WindowTemplate gWindowConfig_81E6C58 =
{
0, // BG number
0, // BG character base block
@@ -519,7 +534,7 @@ const struct WindowConfig gWindowConfig_81E6C58 =
BG_SCREEN_ADDR(24), // tilemap
};
-const struct WindowConfig gWindowConfig_81E6C74 =
+const struct WindowTemplate gWindowConfig_81E6C74 =
{
0, // BG number
0, // BG character base block
@@ -540,7 +555,7 @@ const struct WindowConfig gWindowConfig_81E6C74 =
NULL, // tilemap
};
-const struct WindowConfig gWindowConfig_81E6C90 =
+const struct WindowTemplate gWindowConfig_81E6C90 =
{
0, // BG number
1, // BG character base block
@@ -561,7 +576,7 @@ const struct WindowConfig gWindowConfig_81E6C90 =
BG_SCREEN_ADDR(30), // tilemap
};
-const struct WindowConfig gWindowConfig_81E6CAC =
+const struct WindowTemplate gWindowConfig_81E6CAC =
{
0, // BG number
0, // BG character base block
@@ -582,7 +597,7 @@ const struct WindowConfig gWindowConfig_81E6CAC =
NULL, // tilemap
};
-const struct WindowConfig gWindowConfig_81E6CC8 =
+const struct WindowTemplate gWindowConfig_81E6CC8 =
{
2, // BG number
2, // BG character base block
@@ -603,7 +618,7 @@ const struct WindowConfig gWindowConfig_81E6CC8 =
BG_SCREEN_ADDR(15), // tilemap
};
-const struct WindowConfig gWindowConfig_81E6CE4 =
+const struct WindowTemplate gWindowConfig_81E6CE4 =
{
0, // BG number
2, // BG character base block
@@ -624,7 +639,7 @@ const struct WindowConfig gWindowConfig_81E6CE4 =
BG_SCREEN_ADDR(31), // tilemap
};
-const struct WindowConfig gWindowConfig_81E6D00 =
+const struct WindowTemplate gWindowConfig_81E6D00 =
{
0, // BG number
0, // BG character base block
@@ -645,7 +660,7 @@ const struct WindowConfig gWindowConfig_81E6D00 =
BG_SCREEN_ADDR(31), // tilemap
};
-const struct WindowConfig gWindowConfig_81E6D1C =
+const struct WindowTemplate gWindowConfig_81E6D1C =
{
1, // BG number
0, // BG character base block
@@ -666,7 +681,7 @@ const struct WindowConfig gWindowConfig_81E6D1C =
BG_SCREEN_ADDR(31), // tilemap
};
-const struct WindowConfig gWindowConfig_81E6D38 =
+const struct WindowTemplate gWindowConfig_81E6D38 =
{
0, // BG number
0, // BG character base block
@@ -687,7 +702,7 @@ const struct WindowConfig gWindowConfig_81E6D38 =
NULL, // tilemap
};
-const struct WindowConfig gWindowConfig_81E6D54 =
+const struct WindowTemplate gWindowConfig_81E6D54 =
{
3, // BG number
3, // BG character base block
@@ -708,7 +723,7 @@ const struct WindowConfig gWindowConfig_81E6D54 =
BG_SCREEN_ADDR(15), // tilemap
};
-const struct WindowConfig gWindowConfig_81E6D70 =
+const struct WindowTemplate gWindowConfig_81E6D70 =
{
3, // BG number
3, // BG character base block
@@ -729,7 +744,7 @@ const struct WindowConfig gWindowConfig_81E6D70 =
BG_SCREEN_ADDR(15), // tilemap
};
-const struct WindowConfig gWindowConfig_81E6D8C =
+const struct WindowTemplate gWindowConfig_81E6D8C =
{
1, // BG number
0, // BG character base block
@@ -750,7 +765,7 @@ const struct WindowConfig gWindowConfig_81E6D8C =
BG_SCREEN_ADDR(14), // tilemap
};
-const struct WindowConfig gWindowConfig_81E6DA8 =
+const struct WindowTemplate gWindowConfig_81E6DA8 =
{
0, // BG number
0, // BG character base block
@@ -771,7 +786,7 @@ const struct WindowConfig gWindowConfig_81E6DA8 =
BG_SCREEN_ADDR(11), // tilemap
};
-const struct WindowConfig WindowConfig_TrainerCard_Back_Values =
+const struct WindowTemplate WindowConfig_TrainerCard_Back_Values =
{
0, // BG number
2, // BG character base block
@@ -792,7 +807,7 @@ const struct WindowConfig WindowConfig_TrainerCard_Back_Values =
BG_SCREEN_ADDR(30), // tilemap
};
-const struct WindowConfig WindowConfig_TrainerCard_Back_Labels =
+const struct WindowTemplate WindowConfig_TrainerCard_Back_Labels =
{
0, // BG number
2, // BG character base block
@@ -813,7 +828,7 @@ const struct WindowConfig WindowConfig_TrainerCard_Back_Labels =
BG_SCREEN_ADDR(30), // tilemap
};
-const struct WindowConfig gWindowConfig_81E6DFC =
+const struct WindowTemplate gWindowConfig_81E6DFC =
{
0, // BG number
2, // BG character base block
@@ -834,7 +849,7 @@ const struct WindowConfig gWindowConfig_81E6DFC =
BG_SCREEN_ADDR(31), // tilemap
};
-const struct WindowConfig gWindowConfig_81E6E18 =
+const struct WindowTemplate gWindowConfig_81E6E18 =
{
0, // BG number
2, // BG character base block
@@ -855,7 +870,7 @@ const struct WindowConfig gWindowConfig_81E6E18 =
BG_SCREEN_ADDR(31), // tilemap
};
-const struct WindowConfig gWindowConfig_81E6E34 =
+const struct WindowTemplate gWindowConfig_81E6E34 =
{
1, // BG number
0, // BG character base block
@@ -876,7 +891,7 @@ const struct WindowConfig gWindowConfig_81E6E34 =
BG_SCREEN_ADDR(31), // tilemap
};
-const struct WindowConfig gWindowConfig_81E6E50 =
+const struct WindowTemplate gWindowConfig_81E6E50 =
{
0, // BG number
2, // BG character base block
@@ -897,7 +912,7 @@ const struct WindowConfig gWindowConfig_81E6E50 =
BG_SCREEN_ADDR(28), // tilemap
};
-const struct WindowConfig gWindowConfig_81E6E6C =
+const struct WindowTemplate gWindowConfig_81E6E6C =
{
0, // BG number
2, // BG character base block
@@ -918,7 +933,7 @@ const struct WindowConfig gWindowConfig_81E6E6C =
BG_SCREEN_ADDR(30), // tilemap
};
-const struct WindowConfig gWindowConfig_81E6E88 =
+const struct WindowTemplate gWindowConfig_81E6E88 =
{
0, // BG number
0, // BG character base block
@@ -939,7 +954,7 @@ const struct WindowConfig gWindowConfig_81E6E88 =
BG_SCREEN_ADDR(31), // tilemap
};
-const struct WindowConfig gWindowConfig_81E6EA4 =
+const struct WindowTemplate gWindowConfig_81E6EA4 =
{
1, // BG number
0, // BG character base block
@@ -960,7 +975,7 @@ const struct WindowConfig gWindowConfig_81E6EA4 =
BG_SCREEN_ADDR(28), // tilemap
};
-const struct WindowConfig gWindowConfig_81E6EC0 =
+const struct WindowTemplate gWindowConfig_81E6EC0 =
{
2, // BG number
2, // BG character base block
@@ -981,7 +996,7 @@ const struct WindowConfig gWindowConfig_81E6EC0 =
BG_SCREEN_ADDR(29), // tilemap
};
-const struct WindowConfig gWindowConfig_81E6EDC =
+const struct WindowTemplate gWindowConfig_81E6EDC =
{
1, // BG number
0, // BG character base block
@@ -1002,7 +1017,7 @@ const struct WindowConfig gWindowConfig_81E6EDC =
BG_SCREEN_ADDR(28), // tilemap
};
-const struct WindowConfig gWindowConfig_81E6EF8 =
+const struct WindowTemplate gWindowConfig_81E6EF8 =
{
2, // BG number
2, // BG character base block
@@ -1023,7 +1038,7 @@ const struct WindowConfig gWindowConfig_81E6EF8 =
BG_SCREEN_ADDR(29), // tilemap
};
-const struct WindowConfig gWindowConfig_81E6F14 =
+const struct WindowTemplate gWindowConfig_81E6F14 =
{
1, // BG number
0, // BG character base block
@@ -1044,7 +1059,7 @@ const struct WindowConfig gWindowConfig_81E6F14 =
BG_SCREEN_ADDR(28), // tilemap
};
-const struct WindowConfig gWindowConfig_81E6F30 =
+const struct WindowTemplate gWindowConfig_81E6F30 =
{
2, // BG number
2, // BG character base block
@@ -1065,7 +1080,7 @@ const struct WindowConfig gWindowConfig_81E6F30 =
BG_SCREEN_ADDR(29), // tilemap
};
-const struct WindowConfig gWindowConfig_81E6F4C =
+const struct WindowTemplate gWindowConfig_81E6F4C =
{
3, // BG number
0, // BG character base block
@@ -1086,7 +1101,7 @@ const struct WindowConfig gWindowConfig_81E6F4C =
BG_SCREEN_ADDR(30), // tilemap
};
-const struct WindowConfig gWindowConfig_81E6F68 =
+const struct WindowTemplate gWindowConfig_81E6F68 =
{
0, // BG number
2, // BG character base block
@@ -1107,7 +1122,7 @@ const struct WindowConfig gWindowConfig_81E6F68 =
BG_SCREEN_ADDR(13), // tilemap
};
-const struct WindowConfig gWindowConfig_81E6F84 =
+const struct WindowTemplate gWindowConfig_81E6F84 =
{
0, // BG number
2, // BG character base block
@@ -1128,7 +1143,7 @@ const struct WindowConfig gWindowConfig_81E6F84 =
BG_SCREEN_ADDR(31), // tilemap
};
-const struct WindowConfig gWindowConfig_81E6FA0 =
+const struct WindowTemplate gWindowConfig_81E6FA0 =
{
1, // BG number
0, // BG character base block
@@ -1149,7 +1164,7 @@ const struct WindowConfig gWindowConfig_81E6FA0 =
BG_SCREEN_ADDR(24), // tilemap
};
-const struct WindowConfig gWindowConfig_81E6FBC =
+const struct WindowTemplate gWindowConfig_81E6FBC =
{
0, // BG number
0, // BG character base block
@@ -1170,7 +1185,7 @@ const struct WindowConfig gWindowConfig_81E6FBC =
BG_SCREEN_ADDR(30), // tilemap
};
-const struct WindowConfig gWindowConfig_81E6FD8 =
+const struct WindowTemplate gWindowConfig_81E6FD8 =
{
0, // BG number
0, // BG character base block
@@ -1191,7 +1206,7 @@ const struct WindowConfig gWindowConfig_81E6FD8 =
BG_SCREEN_ADDR(24), // tilemap
};
-const struct WindowConfig gWindowConfig_81E6FF4 =
+const struct WindowTemplate gWindowConfig_81E6FF4 =
{
0, // BG number
0, // BG character base block
@@ -1212,7 +1227,7 @@ const struct WindowConfig gWindowConfig_81E6FF4 =
BG_SCREEN_ADDR(24), // tilemap
};
-const struct WindowConfig gWindowConfig_81E7010 =
+const struct WindowTemplate gWindowConfig_81E7010 =
{
0, // BG number
0, // BG character base block
@@ -1233,7 +1248,7 @@ const struct WindowConfig gWindowConfig_81E7010 =
BG_SCREEN_ADDR(30), // tilemap
};
-const struct WindowConfig gWindowConfig_81E702C =
+const struct WindowTemplate gWindowConfig_81E702C =
{
3, // BG number
2, // BG character base block
@@ -1254,7 +1269,7 @@ const struct WindowConfig gWindowConfig_81E702C =
BG_SCREEN_ADDR(15), // tilemap
};
-const struct WindowConfig gWindowConfig_81E7048 =
+const struct WindowTemplate gWindowConfig_81E7048 =
{
2, // BG number
2, // BG character base block
@@ -1275,7 +1290,7 @@ const struct WindowConfig gWindowConfig_81E7048 =
BG_SCREEN_ADDR(14), // tilemap
};
-const struct WindowConfig gWindowConfig_81E7064 =
+const struct WindowTemplate gWindowConfig_81E7064 =
{
2, // BG number
2, // BG character base block
@@ -1296,7 +1311,7 @@ const struct WindowConfig gWindowConfig_81E7064 =
BG_SCREEN_ADDR(14), // tilemap
};
-const struct WindowConfig gWindowConfig_81E7080 =
+const struct WindowTemplate gWindowConfig_81E7080 =
{
3, // BG number
0, // BG character base block
@@ -1317,7 +1332,7 @@ const struct WindowConfig gWindowConfig_81E7080 =
BG_SCREEN_ADDR(30), // tilemap
};
-const struct WindowConfig gWindowConfig_81E709C =
+const struct WindowTemplate gWindowConfig_81E709C =
{
0, // BG number
0, // BG character base block
@@ -1338,7 +1353,7 @@ const struct WindowConfig gWindowConfig_81E709C =
BG_SCREEN_ADDR(31), // tilemap
};
-const struct WindowConfig gWindowConfig_81E70B8 =
+const struct WindowTemplate gWindowConfig_81E70B8 =
{
2, // BG number
0, // BG character base block
@@ -1359,7 +1374,7 @@ const struct WindowConfig gWindowConfig_81E70B8 =
BG_SCREEN_ADDR(30), // tilemap
};
-const struct WindowConfig gWindowConfig_81E70D4 =
+const struct WindowTemplate gWindowConfig_81E70D4 =
{
3, // BG number
0, // BG character base block
@@ -1380,7 +1395,7 @@ const struct WindowConfig gWindowConfig_81E70D4 =
BG_SCREEN_ADDR(30), // tilemap
};
-const struct WindowConfig gWindowConfig_81E70F0 =
+const struct WindowTemplate gWindowConfig_81E70F0 =
{
0, // BG number
0, // BG character base block
@@ -1401,7 +1416,7 @@ const struct WindowConfig gWindowConfig_81E70F0 =
NULL, // tilemap
};
-const struct WindowConfig gWindowConfig_81E710C =
+const struct WindowTemplate gWindowConfig_81E710C =
{
0, // BG number
0, // BG character base block
@@ -1422,7 +1437,7 @@ const struct WindowConfig gWindowConfig_81E710C =
BG_SCREEN_ADDR(31), // tilemap
};
-const struct WindowConfig gWindowConfig_81E7128 =
+const struct WindowTemplate gWindowConfig_81E7128 =
{
0, // BG number
2, // BG character base block
@@ -1443,7 +1458,7 @@ const struct WindowConfig gWindowConfig_81E7128 =
BG_SCREEN_ADDR(31), // tilemap
};
-const struct WindowConfig gWindowConfig_81E7144 =
+const struct WindowTemplate gWindowConfig_81E7144 =
{
0, // BG number
2, // BG character base block
@@ -1464,7 +1479,7 @@ const struct WindowConfig gWindowConfig_81E7144 =
BG_SCREEN_ADDR(31), // tilemap
};
-const struct WindowConfig gWindowConfig_81E7160 =
+const struct WindowTemplate gWindowConfig_81E7160 =
{
1, // BG number
1, // BG character base block
@@ -1485,7 +1500,7 @@ const struct WindowConfig gWindowConfig_81E7160 =
BG_SCREEN_ADDR(10), // tilemap
};
-const struct WindowConfig gWindowConfig_81E717C =
+const struct WindowTemplate gWindowConfig_81E717C =
{
0, // BG number
3, // BG character base block
@@ -1506,7 +1521,7 @@ const struct WindowConfig gWindowConfig_81E717C =
BG_SCREEN_ADDR(31), // tilemap
};
-const struct WindowConfig gWindowConfig_81E7198 =
+const struct WindowTemplate gWindowConfig_81E7198 =
{
0, // BG number
2, // BG character base block
@@ -1527,7 +1542,7 @@ const struct WindowConfig gWindowConfig_81E7198 =
BG_SCREEN_ADDR(15), // tilemap
};
-const struct WindowConfig gWindowConfig_81E71B4 =
+const struct WindowTemplate gWindowConfig_81E71B4 =
{
0, // BG number
2, // BG character base block
@@ -1548,7 +1563,7 @@ const struct WindowConfig gWindowConfig_81E71B4 =
BG_SCREEN_ADDR(15), // tilemap
};
-const struct WindowConfig gWindowConfig_81E71D0 =
+const struct WindowTemplate gWindowConfig_81E71D0 =
{
1, // BG number
1, // BG character base block
@@ -1569,7 +1584,7 @@ const struct WindowConfig gWindowConfig_81E71D0 =
BG_SCREEN_ADDR(28), // tilemap
};
-const struct WindowConfig gWindowConfig_81E71EC =
+const struct WindowTemplate gWindowConfig_81E71EC =
{
2, // BG number
1, // BG character base block
@@ -1590,7 +1605,7 @@ const struct WindowConfig gWindowConfig_81E71EC =
BG_SCREEN_ADDR(30), // tilemap
};
-const struct WindowConfig gWindowConfig_81E7208 =
+const struct WindowTemplate gWindowConfig_81E7208 =
{
0, // BG number
2, // BG character base block
@@ -1611,7 +1626,7 @@ const struct WindowConfig gWindowConfig_81E7208 =
BG_SCREEN_ADDR(28), // tilemap
};
-const struct WindowConfig gWindowConfig_81E7224 =
+const struct WindowTemplate gWindowConfig_81E7224 =
{
0, // BG number
0, // BG character base block
@@ -1632,7 +1647,7 @@ const struct WindowConfig gWindowConfig_81E7224 =
BG_SCREEN_ADDR(31), // tilemap
};
-const struct WindowConfig gWindowConfig_81E7240 =
+const struct WindowTemplate gWindowConfig_81E7240 =
{
1, // BG number
2, // BG character base block
@@ -1653,7 +1668,7 @@ const struct WindowConfig gWindowConfig_81E7240 =
BG_SCREEN_ADDR(30), // tilemap
};
-const struct WindowConfig gWindowConfig_81E725C =
+const struct WindowTemplate gWindowConfig_81E725C =
{
0, // BG number
0, // BG character base block
@@ -1674,7 +1689,7 @@ const struct WindowConfig gWindowConfig_81E725C =
NULL, // tilemap
};
-const struct WindowConfig gWindowConfig_81E7278 =
+const struct WindowTemplate gWindowConfig_81E7278 =
{
0, // BG number
0, // BG character base block
@@ -1695,7 +1710,7 @@ const struct WindowConfig gWindowConfig_81E7278 =
NULL, // tilemap
};
-const struct WindowConfig gWindowConfig_81E7294 =
+const struct WindowTemplate gWindowConfig_81E7294 =
{
0, // BG number
0, // BG character base block
@@ -1716,32 +1731,32 @@ const struct WindowConfig gWindowConfig_81E7294 =
NULL, // tilemap
};
-static void UpdateBGRegs(const struct WindowConfig *winConfig)
+static void UpdateBGRegs(const struct WindowTemplate *winTemplate)
{
- u8 bgNum = winConfig->bgNum;
+ u8 bgNum = winTemplate->bgNum;
*gBGHOffsetRegs[bgNum] = 0;
*gBGVOffsetRegs[bgNum] = 0;
- *gBGControlRegs[bgNum] = winConfig->priority | (winConfig->screenBaseBlock << 8) | (winConfig->charBaseBlock << 2);
+ *gBGControlRegs[bgNum] = winTemplate->priority | (winTemplate->screenBaseBlock << 8) | (winTemplate->charBaseBlock << 2);
}
-static void ClearBGMem(const struct WindowConfig *winConfig)
+static void ClearBGMem(const struct WindowTemplate *winTemplate)
{
- CpuFastFill(0, winConfig->tileData, 32);
+ CpuFastFill(0, winTemplate->tileData, 32);
- if (winConfig->tilemap)
- CpuFastFill(0, winConfig->tilemap, 0x800);
+ if (winTemplate->tilemap)
+ CpuFastFill(0, winTemplate->tilemap, 0x800);
}
-void LoadFontDefaultPalette(const struct WindowConfig *winConfig)
+void LoadFontDefaultPalette(const struct WindowTemplate *winTemplate)
{
- LoadPalette(gFontDefaultPalette, 16 * winConfig->paletteNum, 32);
+ LoadPalette(gFontDefaultPalette, 16 * winTemplate->paletteNum, 32);
}
-void SetUpWindowConfig(const struct WindowConfig *winConfig)
+void SetUpWindowConfig(const struct WindowTemplate *winTemplate)
{
- UpdateBGRegs(winConfig);
- ClearBGMem(winConfig);
- LoadFontDefaultPalette(winConfig);
+ UpdateBGRegs(winTemplate);
+ ClearBGMem(winTemplate);
+ LoadFontDefaultPalette(winTemplate);
}
u16 InitWindowTileData(struct Window *win, u16 startOffset)
@@ -1751,13 +1766,13 @@ u16 InitWindowTileData(struct Window *win, u16 startOffset)
win->tileDataStartOffset = startOffset;
retVal = 0;
- switch (win->config->textMode)
+ switch (win->template->textMode)
{
- case 2:
+ case TEXT_MODE_UNKNOWN2:
retVal = InitVariableWidthFontTileData(win, startOffset);
break;
- case 1:
- switch (win->config->fontNum)
+ case TEXT_MODE_MONOSPACE:
+ switch (win->template->fontNum)
{
case 0:
case 3:
@@ -1789,7 +1804,7 @@ static u16 InitVariableWidthFontTileData(struct Window *win, u16 startOffset)
win->tileDataOffset = 2;
buffer = win->tileData + 32 * win->tileDataStartOffset;
CpuFastFill(0, buffer, 32);
- ApplyColors_UnshadowedFont(sBlankTile, (u32 *)(buffer + 32), win->config->foregroundColor, win->config->backgroundColor);
+ ApplyColors_UnshadowedFont(sBlankTile, (u32 *)(buffer + 32), win->template->foregroundColor, win->template->backgroundColor);
return win->tileDataStartOffset + win->tileDataOffset + win->width * win->height;
}
@@ -1850,15 +1865,15 @@ u32 MultistepInitWindowTileData(struct Window *win, u16 startOffset)
win->tileDataStartOffset = startOffset;
retVal = 0;
- switch (win->config->textMode)
+ switch (win->template->textMode)
{
- case 2:
+ case TEXT_MODE_UNKNOWN2:
retVal = InitVariableWidthFontTileData(win, startOffset);
break;
- case 1:
+ case TEXT_MODE_MONOSPACE:
retVal = 256;
- if (win->config->fontNum == 0
- || win->config->fontNum == 3)
+ if (win->template->fontNum == 0
+ || win->template->fontNum == 3)
retVal *= 2;
break;
}
@@ -1870,7 +1885,7 @@ bool32 MultistepLoadFont(void)
{
bool32 retVal = TRUE;
- if (sMultistepLoadFont_Window->config->textMode == 1)
+ if (sMultistepLoadFont_Window->template->textMode == TEXT_MODE_MONOSPACE)
{
s32 i;
@@ -1890,7 +1905,7 @@ static void MultistepLoadFont_LoadGlyph(struct Window *win, u16 startOffset, u8
{
u8 *buffer;
- switch (win->config->fontNum)
+ switch (win->template->fontNum)
{
case 0:
case 3:
@@ -1923,42 +1938,42 @@ void EmptyFunc(void)
{
}
-void InitWindowFromConfig(struct Window *win, const struct WindowConfig *winConfig)
+void Text_InitWindowWithTemplate(struct Window *win, const struct WindowTemplate *winTemplate)
{
*win = sDefaultWindow;
- win->config = (struct WindowConfig *)winConfig;
- win->textMode = winConfig->textMode;
- win->spacing = winConfig->spacing;
- win->fontNum = winConfig->fontNum;
- win->paletteNum = winConfig->paletteNum;
- win->tilemapLeft = winConfig->tilemapLeft;
- win->tilemapTop = winConfig->tilemapTop;
- win->width = winConfig->width;
- win->height = winConfig->height;
- win->tileData = winConfig->tileData;
- win->tilemap = winConfig->tilemap;
+ win->template = (struct WindowTemplate *)winTemplate;
+ win->textMode = winTemplate->textMode;
+ win->spacing = winTemplate->spacing;
+ win->fontNum = winTemplate->fontNum;
+ win->paletteNum = winTemplate->paletteNum;
+ win->tilemapLeft = winTemplate->tilemapLeft;
+ win->tilemapTop = winTemplate->tilemapTop;
+ win->width = winTemplate->width;
+ win->height = winTemplate->height;
+ win->tileData = winTemplate->tileData;
+ win->tilemap = winTemplate->tilemap;
InitColors(win);
- SetBackgroundColor(win, winConfig->backgroundColor);
- SetShadowColor(win, winConfig->shadowColor);
- SetForegroundColor(win, winConfig->foregroundColor);
+ SetWindowBackgroundColor(win, winTemplate->backgroundColor);
+ SetWindowShadowColor(win, winTemplate->shadowColor);
+ SetWindowForegroundColor(win, winTemplate->foregroundColor);
}
-void InitWindow(struct Window *win, const u8 *text, u16 tileDataStartOffset, u8 left, u8 top)
+void Text_InitWindow(struct Window *win, const u8 *text, u16 tileDataStartOffset, u8 left, u8 top)
{
- const struct WindowConfig *winConfig = win->config;
- win->textMode = winConfig->textMode;
- win->fontNum = winConfig->fontNum;
+ const struct WindowTemplate *winTemplate = win->template;
+ win->textMode = winTemplate->textMode;
+ win->fontNum = winTemplate->fontNum;
win->language = GAME_LANGUAGE;
- win->paletteNum = winConfig->paletteNum;
+ win->paletteNum = winTemplate->paletteNum;
win->win_field_B = 0;
win->win_field_C = 0;
win->delayCounter = 0;
- win->spacing = winConfig->spacing;
+ win->spacing = winTemplate->spacing;
win->win_field_F = 0;
- win->tilemapLeft = winConfig->tilemapLeft;
- win->tilemapTop = winConfig->tilemapTop;
- win->width = winConfig->width;
- win->height = winConfig->height;
+ win->tilemapLeft = winTemplate->tilemapLeft;
+ win->tilemapTop = winTemplate->tilemapTop;
+ win->width = winTemplate->width;
+ win->height = winTemplate->height;
win->text = text;
win->textIndex = 0;
win->tileDataStartOffset = tileDataStartOffset;
@@ -1969,19 +1984,19 @@ void InitWindow(struct Window *win, const u8 *text, u16 tileDataStartOffset, u8
win->cursorY = 0;
win->state = WIN_STATE_BEGIN;
win->downArrowCounter = 0;
- win->tileData = winConfig->tileData;
- win->tilemap = winConfig->tilemap;
+ win->tileData = winTemplate->tileData;
+ win->tilemap = winTemplate->tilemap;
InitColors(win);
- SetBackgroundColor(win, winConfig->backgroundColor);
- SetShadowColor(win, winConfig->shadowColor);
- SetForegroundColor(win, winConfig->foregroundColor);
+ SetWindowBackgroundColor(win, winTemplate->backgroundColor);
+ SetWindowShadowColor(win, winTemplate->shadowColor);
+ SetWindowForegroundColor(win, winTemplate->foregroundColor);
}
-void sub_8002E4C(struct Window *win, const u8 *text, u16 tileDataStartOffset, u8 left, u16 top, u32 a6)
+void Text_InitWindow8002E4C(struct Window *win, const u8 *text, u16 tileDataStartOffset, u8 left, u16 top, u32 a6)
{
u8 val;
- InitWindow(win, text, tileDataStartOffset, 0, 0);
+ Text_InitWindow(win, text, tileDataStartOffset, 0, 0);
win->left = left;
win->top = top;
val = 0;
@@ -2003,15 +2018,15 @@ void sub_8002E90(struct Window *win, const u8 *text)
win->delayCounter = 0;
}
-void sub_8002EB0(struct Window *win, const u8 *text, u16 tileDataStartOffset, u8 left, u8 top)
+void Text_InitWindow8002EB0(struct Window *win, const u8 *text, u16 tileDataStartOffset, u8 left, u8 top)
{
gMain.watchedKeysMask = A_BUTTON | B_BUTTON;
gMain.watchedKeysPressed = 0;
- sWaitType = 0;
+ sWaitType = WAIT_TYPE_NORMAL;
sLineLength = 26;
- InitWindow(win, text, tileDataStartOffset, left, top);
+ Text_InitWindow(win, text, tileDataStartOffset, left, top);
win->win_field_B = -1;
- if (win->textMode == 0)
+ if (win->textMode == TEXT_MODE_UNKNOWN0)
{
u16 val = GetCursorTileNum(win, 0, 0);
u8 *buffer = win->tileData + 32 * val;
@@ -2021,9 +2036,9 @@ void sub_8002EB0(struct Window *win, const u8 *text, u16 tileDataStartOffset, u8
}
}
-u8 sub_8002F44(struct Window *win)
+u8 Text_PrintWindow8002F44(struct Window *win)
{
- while (win->state)
+ while (win->state != WIN_STATE_END)
{
if (win->state == WIN_STATE_NEWLINE)
{
@@ -2038,7 +2053,7 @@ u8 sub_8002F44(struct Window *win)
sub_8002FA0(win, GetExpandedPlaceholder(win->text[win->textIndex++]));
}
- InterpretText(win);
+ PrintNextChar(win);
}
return 1;
}
@@ -2048,11 +2063,12 @@ static u8 sub_8002FA0(struct Window *win, const u8 *text)
u8 retVal;
u8 savedLanguage = win->language;
const u8 *savedText = win->text;
+
u16 savedTextIndex = win->textIndex;
win->text = text;
win->textIndex = 0;
win->state = WIN_STATE_NORMAL;
- retVal = sub_8002F44(win);
+ retVal = Text_PrintWindow8002F44(win);
win->text = savedText;
win->textIndex = savedTextIndex;
win->state = WIN_STATE_NORMAL;
@@ -2060,32 +2076,33 @@ static u8 sub_8002FA0(struct Window *win, const u8 *text)
return retVal;
}
-static u8 InterpretText(struct Window *win)
+static u8 PrintNextChar(struct Window *win)
{
u8 c = win->text[win->textIndex++];
+ // Handle special control characters
switch (c)
{
- case 0xFF:
+ case EOS:
ClipRight(win);
win->state = WIN_STATE_END;
return 0;
- case 0xFD:
+ case PLACEHOLDER_BEGIN:
win->state = WIN_STATE_PLACEHOLDER;
return 2;
- case 0xFE:
+ case CHAR_NEWLINE:
ClipRight(win);
win->state = WIN_STATE_NEWLINE;
return 2;
- case 0xFB:
+ case CHAR_PROMPT_CLEAR:
DrawInitialDownArrow(win);
- win->state = WIN_STATE_PARAGRAPH;
+ win->state = WIN_STATE_WAIT_CLEAR;
return 2;
- case 0xFA:
+ case CHAR_PROMPT_SCROLL:
DrawInitialDownArrow(win);
- win->state = WIN_STATE_NEWLINE_WAIT;
+ win->state = WIN_STATE_WAIT_SCROLL;
return 2;
- case 0xFC:
+ case EXT_CTRL_CODE_BEGIN:
return HandleExtCtrlCode(win);
}
@@ -2093,6 +2110,8 @@ static u8 InterpretText(struct Window *win)
return 1;
}
+// Extended 0xFC control functions
+
static u8 HandleExtCtrlCode(struct Window *win)
{
return sExtCtrlCodeFuncs[win->text[win->textIndex++]](win);
@@ -2105,27 +2124,27 @@ static u8 ExtCtrlCode_Nop(struct Window *win)
static u8 ExtCtrlCode_ForegroundColor(struct Window *win)
{
- SetForegroundColor(win, win->text[win->textIndex++]);
+ SetWindowForegroundColor(win, win->text[win->textIndex++]);
return 2;
}
static u8 ExtCtrlCode_BackgroundColor(struct Window *win)
{
- SetBackgroundColor(win, win->text[win->textIndex++]);
+ SetWindowBackgroundColor(win, win->text[win->textIndex++]);
return 2;
}
static u8 ExtCtrlCode_ShadowColor(struct Window *win)
{
- SetShadowColor(win, win->text[win->textIndex++]);
+ SetWindowShadowColor(win, win->text[win->textIndex++]);
return 2;
}
static u8 ExtCtrlCode_AllColors(struct Window *win)
{
- SetForegroundColor(win, win->text[win->textIndex++]);
- SetBackgroundColor(win, win->text[win->textIndex++]);
- SetShadowColor(win, win->text[win->textIndex++]);
+ SetWindowForegroundColor(win, win->text[win->textIndex++]);
+ SetWindowBackgroundColor(win, win->text[win->textIndex++]);
+ SetWindowShadowColor(win, win->text[win->textIndex++]);
return 2;
}
@@ -2143,7 +2162,7 @@ static u8 ExtCtrlCode_Font(struct Window *win)
static u8 ExtCtrlCode_DefaultFont(struct Window *win)
{
- win->fontNum = win->config->fontNum;
+ win->fontNum = win->template->fontNum;
return 2;
}
@@ -2197,7 +2216,7 @@ static u8 ExtCtrlCode_SetCursorY(struct Window *win)
static u8 ExtCtrlCode_ClearWindowTextLines(struct Window *win)
{
- ClearWindowTextLines(win);
+ Text_ClearWindow(win);
return 2;
}
@@ -2211,7 +2230,7 @@ static u8 ExtCtrlCode_PlaySE(struct Window *win)
static void DrawSpace(struct Window *win)
{
- if (win->textMode == 1 || (win->left + win->cursorX) & 7 || win->spacing <= 7)
+ if (win->textMode == TEXT_MODE_MONOSPACE || (win->left + win->cursorX) & 7 || win->spacing <= 7)
{
sPrintGlyphFuncs[win->textMode](win, 0);
}
@@ -2302,10 +2321,11 @@ static u8 ExtCtrlCode_Latin(struct Window *win)
return 2;
}
-u8 sub_8003418(struct Window *win)
+// Prints the window text without expanding any placeholders
+u8 Text_PrintWindowSimple(struct Window *win)
{
u8 retVal = 1;
- while (win->state)
+ while (win->state != WIN_STATE_END)
{
if (win->state == WIN_STATE_NEWLINE)
{
@@ -2315,7 +2335,7 @@ u8 sub_8003418(struct Window *win)
ClipLeft(win);
win->state = WIN_STATE_NORMAL;
}
- if (InterpretText(win) == 1)
+ if (PrintNextChar(win) == 1)
{
retVal = 0;
break;
@@ -2324,10 +2344,10 @@ u8 sub_8003418(struct Window *win)
return retVal;
}
-u8 sub_8003460(struct Window *win, const u8 *text, u16 tileDataStartOffset, u8 left, u8 top)
+u8 Text_InitWindowAndPrintText(struct Window *win, const u8 *text, u16 tileDataStartOffset, u8 left, u8 top)
{
- InitWindow(win, text, tileDataStartOffset, left, top);
- return sub_8002F44(win);
+ Text_InitWindow(win, text, tileDataStartOffset, left, top);
+ return Text_PrintWindow8002F44(win);
}
u8 sub_8003490(struct Window *win, u8 c, u16 tileDataStartOffset, u8 left, u8 top)
@@ -2336,8 +2356,8 @@ u8 sub_8003490(struct Window *win, u8 c, u16 tileDataStartOffset, u8 left, u8 to
u8 text[2];
text[0] = c;
text[1] = EOS;
- InitWindow(win, text, tileDataStartOffset, left, top);
- retVal = InterpretText(win);
+ Text_InitWindow(win, text, tileDataStartOffset, left, top);
+ retVal = PrintNextChar(win);
ClipRight(win);
return retVal;
}
@@ -2349,35 +2369,38 @@ void sub_80034D4(u8 *tileData, const u8 *text)
u8 sub_80034EC(u8 *str)
{
- return GetStringWidthGivenWindowConfig((struct WindowConfig *)&gWindowConfig_81E6C74, str);
+ return Text_GetStringWidthFromWindowTemplate((struct WindowTemplate *)&gWindowConfig_81E6C74, str);
}
u8 *sub_8003504(u8 *dest, s32 value, u8 alignAmount, u8 alignType)
{
- sTempWindow.config = (struct WindowConfig *)&gWindowConfig_81E6C74;
- InitWindow(&sTempWindow, 0, 0, 0, 0);
+ sTempWindow.template = (struct WindowTemplate *)&gWindowConfig_81E6C74;
+ Text_InitWindow(&sTempWindow, 0, 0, 0, 0);
return AlignInt2(&sTempWindow, dest, value, alignAmount, alignType);
}
u8 *sub_8003558(u8 *dest, const u8 *src, u8 alignAmount, u8 alignType)
{
- sTempWindow.config = (struct WindowConfig *)&gWindowConfig_81E6C74;
- InitWindow(&sTempWindow, src, 0, 0, 0);
+ sTempWindow.template = (struct WindowTemplate *)&gWindowConfig_81E6C74;
+ Text_InitWindow(&sTempWindow, src, 0, 0, 0);
return AlignString(&sTempWindow, dest, src, alignAmount, alignType);
}
-u8 sub_80035AC(struct Window *win)
+// Updates the window text
+// The text delay can be accelerated by holding the A button
+u8 Text_UpdateWindow(struct Window *win)
{
- sWaitType = 0;
+ sWaitType = WAIT_TYPE_NORMAL;
return UpdateWindowText(win);
}
+// Returns TRUE when all of the text has been printed.
static u8 UpdateWindowText(struct Window *win)
{
switch (win->state)
{
case WIN_STATE_WAIT_BUTTON:
- if (PlayerCanInterruptWait(win))
+ if (PlayerCanInterruptDelay(win))
{
if (gMain.newKeys & (A_BUTTON | B_BUTTON))
{
@@ -2385,48 +2408,56 @@ static u8 UpdateWindowText(struct Window *win)
}
else
{
- return 0;
+ return FALSE;
}
}
else
{
win->delayCounter--;
if (win->delayCounter)
- return 0;
+ return FALSE;
}
win->state = WIN_STATE_NORMAL;
- return 0;
- case WIN_STATE_INTERRUPTIBLE_PAUSE:
- if (PlayerCanInterruptWait(win) && (gMain.heldKeys & (A_BUTTON | B_BUTTON)) && gMain.watchedKeysPressed == TRUE)
+ return FALSE;
+ case WIN_STATE_CHAR_DELAY:
+ // Allow the player to speed up text by holding a button
+ if (PlayerCanInterruptDelay(win)
+ && (gMain.heldKeys & (A_BUTTON | B_BUTTON))
+ && gMain.watchedKeysPressed == TRUE)
{
win->delayCounter = 0;
win->state = WIN_STATE_NORMAL;
break;
}
+ // fall through
case WIN_STATE_PAUSE:
+ // Wait for timer to expire, then continue printing
if (win->delayCounter)
{
win->delayCounter--;
if (win->delayCounter)
- return 0;
+ return FALSE;
}
-
win->state = WIN_STATE_NORMAL;
break;
- case WIN_STATE_PARAGRAPH:
- if (!WaitWithDownArrow(win))
- return 0;
- ClearWindowTextLines(win);
- win->state = WIN_STATE_NORMAL;
- BLOCK_CROSS_JUMP
- return 0;
- case WIN_STATE_NEWLINE_WAIT:
- if (!WaitWithDownArrow(win))
- return 0;
- ScrollWindowTextLines(win);
- win->state = WIN_STATE_NORMAL;
- BLOCK_CROSS_JUMP
- return 0;
+ case WIN_STATE_WAIT_CLEAR:
+ // Erase the text once a button is pressed
+ if (WaitWithDownArrow(win))
+ {
+ Text_ClearWindow(win);
+ win->state = WIN_STATE_NORMAL;
+ asm("");
+ }
+ return FALSE;
+ case WIN_STATE_WAIT_SCROLL:
+ // Scroll the text once a button is pressed
+ if (WaitWithDownArrow(win))
+ {
+ ScrollWindowTextLines(win);
+ win->state = WIN_STATE_NORMAL;
+ asm("");
+ }
+ return FALSE;
case WIN_STATE_PLACEHOLDER:
win->textIndex++;
win->state = WIN_STATE_NORMAL;
@@ -2434,35 +2465,35 @@ static u8 UpdateWindowText(struct Window *win)
case WIN_STATE_NEWLINE:
ScrollWindowTextLines(win);
win->state = WIN_STATE_NORMAL;
- BLOCK_CROSS_JUMP
- return 0;
+ asm("");
+ return FALSE;
case WIN_STATE_BEGIN:
- ClearWindowTextLines(win);
+ Text_ClearWindow(win);
break;
case WIN_STATE_WAIT_SOUND:
if (IsSEPlaying())
- return 0;
+ return FALSE;
win->state = WIN_STATE_NORMAL;
break;
case WIN_STATE_END:
- return 1;
+ return TRUE; // done printing text
case WIN_STATE_NORMAL:
break;
default:
win->state = WIN_STATE_END;
- return 1;
+ return TRUE;
}
- InterpretText(win);
+ PrintNextChar(win);
switch (win->state)
{
case WIN_STATE_END:
- return 1;
+ return TRUE; // done printing text
case WIN_STATE_WAIT_BUTTON:
- case WIN_STATE_PARAGRAPH:
- case WIN_STATE_NEWLINE_WAIT:
- if (PlayerCanInterruptWait(win))
+ case WIN_STATE_WAIT_CLEAR:
+ case WIN_STATE_WAIT_SCROLL:
+ if (PlayerCanInterruptDelay(win))
return 0;
win->delayCounter = 60;
break;
@@ -2471,8 +2502,9 @@ static u8 UpdateWindowText(struct Window *win)
case WIN_STATE_WAIT_SOUND:
break;
default:
- win->state = WIN_STATE_INTERRUPTIBLE_PAUSE;
+ win->state = WIN_STATE_CHAR_DELAY;
win->delayCounter = GetTextDelay(win);
+ break;
}
return 0;
@@ -2484,45 +2516,45 @@ static u8 UpdateWindowText(struct Window *win)
#define SUB_800374C_LINE_LENGTH 27
#endif
-u8 sub_800374C(struct Window *win)
+u8 Text_UpdateWindowInBattle(struct Window *win)
{
u8 retVal;
- sWaitType = 1;
+ sWaitType = WAIT_TYPE_BATTLE;
sLineLength = SUB_800374C_LINE_LENGTH;
retVal = UpdateWindowText(win);
sLineLength = 26;
- sWaitType = 0;
+ sWaitType = WAIT_TYPE_NORMAL;
return retVal;
}
-u8 sub_8003778(struct Window *win)
+u8 Text_UpdateWindowAutoscroll(struct Window *win)
{
u8 retVal;
- sWaitType = 2;
+ sWaitType = WAIT_TYPE_AUTOSCROLL;
sLineLength = 26;
retVal = UpdateWindowText(win);
- sWaitType = 0;
+ sWaitType = WAIT_TYPE_NORMAL;
return retVal;
}
-u8 sub_80037A0(struct Window *win)
+u8 Text_UpdateWindowInContest(struct Window *win)
{
u8 retVal;
- sWaitType = 3;
+ sWaitType = WAIT_TYPE_CONTEST;
sLineLength = 17;
retVal = UpdateWindowText(win);
sLineLength = 26;
return retVal;
}
-u32 sub_80037C8(struct Window *win, u8 lineLength)
+u32 Text_UpdateWindowOverrideLineLength(struct Window *win, u8 lineLength)
{
u8 retVal;
- sWaitType = 0;
+ sWaitType = WAIT_TYPE_NORMAL;
sLineLength = lineLength;
retVal = UpdateWindowText(win);
sLineLength = 26;
@@ -2757,14 +2789,14 @@ static void ApplyColors_ShadowedFont(const void *src, void *dest, u8 foreground,
static void SetCursorX(struct Window *win, u8 x)
{
- if (win->textMode == 0 && ((win->left + win->cursorX) & 7))
+ if (win->textMode == TEXT_MODE_UNKNOWN0 && ((win->left + win->cursorX) & 7))
win->tileDataOffset += 2;
win->cursorX = x;
}
static void AddToCursorX(struct Window *win, u8 deltaX)
{
- if (win->textMode == 0)
+ if (win->textMode == TEXT_MODE_UNKNOWN0)
{
u8 x = win->cursorX;
win->cursorX += deltaX;
@@ -2779,7 +2811,7 @@ static void AddToCursorX(struct Window *win, u8 deltaX)
static void AddToCursorY(struct Window *win, u8 deltaY)
{
- if (win->textMode == 0 && ((win->left + win->cursorX) & 7))
+ if (win->textMode == TEXT_MODE_UNKNOWN0 && ((win->left + win->cursorX) & 7))
win->tileDataOffset += 2;
win->cursorY += deltaY;
}
@@ -2788,11 +2820,11 @@ static void EraseAtCursor(struct Window *win)
{
switch (win->textMode)
{
- case 0:
- case 2:
+ case TEXT_MODE_UNKNOWN0:
+ case TEXT_MODE_UNKNOWN2:
DrawGlyphTiles(win, 0, 8);
break;
- case 1:
+ case TEXT_MODE_MONOSPACE:
sWriteGlyphTilemapFuncs[win->fontNum](win, 0);
break;
}
@@ -2801,7 +2833,8 @@ static void EraseAtCursor(struct Window *win)
static void ClipLeft(struct Window *win)
{
u32 pixel = win->left & 7;
- if (win->textMode != 1 && pixel)
+
+ if (win->textMode != TEXT_MODE_MONOSPACE && pixel)
{
const u32 *masks = sGlyphMasks[8][pixel];
u32 outsideMask = masks[0];
@@ -2834,32 +2867,40 @@ static void ClipRight(struct Window *win)
{
register u8 cursorX asm("r0") = win->cursorX;
u8 left = win->left;
- u32 pixel = (cursorX + left) & 7;
- if (win->textMode != 1 && pixel)
+ u32 pixelX = (cursorX + left) & 7;
+
+ if (win->textMode != TEXT_MODE_MONOSPACE && pixelX != 0)
{
- const u32 *masks = sGlyphMasks[8 - pixel][pixel];
+ const u32 *masks = sGlyphMasks[8 - pixelX][pixelX];
u32 insideMask = masks[0];
u32 outside = (sGlyphBuffer.background & ~insideMask);
- u16 tileNum = GetCursorTileNum(win, 0, 0);
- u32 *buffer = (u32 *)(win->tileData + 32 * tileNum);
- buffer[0] = (buffer[0] & insideMask) | outside;
- buffer[1] = (buffer[1] & insideMask) | outside;
- buffer[2] = (buffer[2] & insideMask) | outside;
- buffer[3] = (buffer[3] & insideMask) | outside;
- buffer[4] = (buffer[4] & insideMask) | outside;
- buffer[5] = (buffer[5] & insideMask) | outside;
- buffer[6] = (buffer[6] & insideMask) | outside;
- buffer[7] = (buffer[7] & insideMask) | outside;
+ u16 tileNum;
+ u32 *tileData;
+
+ tileNum = GetCursorTileNum(win, 0, 0);
+ tileData = (u32 *)(win->tileData + 32 * tileNum);
+
+ tileData[0] = (tileData[0] & insideMask) | outside;
+ tileData[1] = (tileData[1] & insideMask) | outside;
+ tileData[2] = (tileData[2] & insideMask) | outside;
+ tileData[3] = (tileData[3] & insideMask) | outside;
+ tileData[4] = (tileData[4] & insideMask) | outside;
+ tileData[5] = (tileData[5] & insideMask) | outside;
+ tileData[6] = (tileData[6] & insideMask) | outside;
+ tileData[7] = (tileData[7] & insideMask) | outside;
+
tileNum = GetCursorTileNum(win, 0, 1);
- buffer = (u32 *)(win->tileData + 32 * tileNum);
- buffer[0] = (buffer[0] & insideMask) | outside;
- buffer[1] = (buffer[1] & insideMask) | outside;
- buffer[2] = (buffer[2] & insideMask) | outside;
- buffer[3] = (buffer[3] & insideMask) | outside;
- buffer[4] = (buffer[4] & insideMask) | outside;
- buffer[5] = (buffer[5] & insideMask) | outside;
- buffer[6] = (buffer[6] & insideMask) | outside;
- buffer[7] = (buffer[7] & insideMask) | outside;
+ tileData = (u32 *)(win->tileData + 32 * tileNum);
+
+ tileData[0] = (tileData[0] & insideMask) | outside;
+ tileData[1] = (tileData[1] & insideMask) | outside;
+ tileData[2] = (tileData[2] & insideMask) | outside;
+ tileData[3] = (tileData[3] & insideMask) | outside;
+ tileData[4] = (tileData[4] & insideMask) | outside;
+ tileData[5] = (tileData[5] & insideMask) | outside;
+ tileData[6] = (tileData[6] & insideMask) | outside;
+ tileData[7] = (tileData[7] & insideMask) | outside;
+
UpdateTilemap(win, 1);
}
}
@@ -2876,7 +2917,7 @@ static void InitColors(struct Window *win)
sGlyphBuffer.colors[i] = i;
}
-static void SetBackgroundColor(struct Window *win, u8 color)
+static void SetWindowBackgroundColor(struct Window *win, u8 color)
{
u32 val1;
u32 val2;
@@ -2889,13 +2930,13 @@ static void SetBackgroundColor(struct Window *win, u8 color)
sGlyphBuffer.background = val3;
}
-static void SetShadowColor(struct Window *win, u8 color)
+static void SetWindowShadowColor(struct Window *win, u8 color)
{
win->shadowColor = color;
sGlyphBuffer.colors[14] = color;
}
-static void SetForegroundColor(struct Window *win, u8 color)
+static void SetWindowForegroundColor(struct Window *win, u8 color)
{
win->foregroundColor = color;
sGlyphBuffer.colors[15] = color;
@@ -2903,25 +2944,25 @@ static void SetForegroundColor(struct Window *win, u8 color)
static u8 GetTextDelay(struct Window *win)
{
- if (!PlayerCanInterruptWait(win))
+ if (!PlayerCanInterruptDelay(win))
return 3;
return sTextSpeedDelays[gSaveBlock2.optionsTextSpeed];
}
-static bool8 PlayerCanInterruptWait(struct Window *win)
+static bool8 PlayerCanInterruptDelay(struct Window *win)
{
bool8 retVal = TRUE;
switch (sWaitType)
{
- case 2:
+ case WAIT_TYPE_AUTOSCROLL:
retVal = FALSE;
break;
- case 3:
+ case WAIT_TYPE_CONTEST:
retVal = gIsLinkContest ? FALSE : TRUE;
break;
- case 1:
+ case WAIT_TYPE_BATTLE:
retVal = (gBattleTypeFlags & BATTLE_TYPE_LINK) ? FALSE : TRUE;
break;
}
@@ -2933,13 +2974,13 @@ static void ScrollWindowTextLines(struct Window *win)
{
switch (win->textMode)
{
- case 0:
+ case TEXT_MODE_UNKNOWN0:
ScrollWindowTextLines_TextMode0(win);
break;
- case 1:
- ScrollWindowTextLines_TextMode1(win);
+ case TEXT_MODE_MONOSPACE:
+ ScrollWindowTextLines_TextModeMonospace(win);
break;
- case 2:
+ case TEXT_MODE_UNKNOWN2:
ScrollWindowTextLines_TextMode2(win);
break;
}
@@ -2949,6 +2990,7 @@ static void ScrollWindowTextLines_TextMode0(struct Window *win)
{
if (win->cursorY == 0)
{
+ // Advance to the next line
win->tileDataOffset = 2 * sLineLength + 2;
win->cursorX = 0;
win->cursorY += 16;
@@ -2959,7 +3001,7 @@ static void ScrollWindowTextLines_TextMode0(struct Window *win)
win->tileDataOffset = 2 * sLineLength + 2;
else
win->tileDataOffset = 2;
- win->win_field_C = win->win_field_C ^ 2;
+ win->win_field_C ^= 2;
win->cursorX = 0;
DoScroll_TextMode0(win, sLineLength);
}
@@ -2973,16 +3015,21 @@ static void DoScroll_TextMode0(struct Window *win, u16 lineLength)
u16 fill;
buffer += val1 + val2;
fill = (win->paletteNum << 12) | GetBlankTileNum(win);
+
+ // Move the bottom line up
CpuCopy16(buffer + 64, buffer, lineLength * 2);
CpuCopy16(buffer + 96, buffer + 32, lineLength * 2);
+
+ // Clear the bottom line
CpuFill16(fill, buffer + 64, lineLength * 2);
CpuFill16(fill, buffer + 96, lineLength * 2);
}
-static void ScrollWindowTextLines_TextMode1(struct Window *win)
+static void ScrollWindowTextLines_TextModeMonospace(struct Window *win)
{
if (win->cursorY == 0)
{
+ // Advance to the next line
win->cursorX = 0;
win->cursorY += 16;
}
@@ -2990,17 +3037,21 @@ static void ScrollWindowTextLines_TextMode1(struct Window *win)
{
win->win_field_C ^= 2;
win->cursorX = 0;
- DoScroll_TextMode1(win, sLineLength);
+ DoScroll_TextModeMonospace(win, sLineLength);
}
}
-static void DoScroll_TextMode1(struct Window *win, u16 lineLength)
+static void DoScroll_TextModeMonospace(struct Window *win, u16 lineLength)
{
u16 *buffer = GetCursorTilemapPointer(win);
u16 *dest = buffer - 32;
u16 fill = (win->paletteNum << 12) | GetBlankTileNum(win);
+
+ // Move the bottom line up
CpuCopy16(buffer + 32, dest, lineLength * 2);
CpuCopy16(buffer + 64, buffer, lineLength * 2);
+
+ // Clear the bottom line
CpuFill16(fill, buffer + 32, lineLength * 2);
CpuFill16(fill, buffer + 64, lineLength * 2);
}
@@ -3009,6 +3060,7 @@ static void ScrollWindowTextLines_TextMode2(struct Window *win)
{
if (win->cursorY == 0)
{
+ // Advance to the next line
win->cursorX = 0;
win->cursorY += 16;
}
@@ -3055,18 +3107,18 @@ static void DoScroll_TextMode2(struct Window *win, u8 lineLength)
}
}
-void ClearWindowTextLines(struct Window *win)
+void Text_ClearWindow(struct Window *win)
{
switch (win->textMode)
{
- case 0:
+ case TEXT_MODE_UNKNOWN0:
ClearWindowTextLines_TextMode0_TextMode1(win, sLineLength);
win->tileDataOffset = 2;
break;
- case 1:
+ case TEXT_MODE_MONOSPACE:
ClearWindowTextLines_TextMode0_TextMode1(win, sLineLength);
break;
- case 2:
+ case TEXT_MODE_UNKNOWN2:
ClearWindowTextLines_TextMode2(win, sLineLength);
break;
}
@@ -3074,7 +3126,7 @@ void ClearWindowTextLines(struct Window *win)
static void ClearWindowTextLines_TextMode0_TextMode1(struct Window *win, u8 lineLength)
{
- u8 i;
+ u8 x, y;
u16 *buffer;
u16 fill;
@@ -3085,11 +3137,10 @@ static void ClearWindowTextLines_TextMode0_TextMode1(struct Window *win, u8 line
buffer = GetCursorTilemapPointer(win);
fill = GetBlankTileNum(win) | (win->paletteNum << 12);
- for (i = 0; i < 4; i++)
+ for (y = 0; y < 4; y++)
{
- u8 j;
- for (j = 0; j < lineLength; j++)
- buffer[j] = fill;
+ for (x = 0; x < lineLength; x++)
+ buffer[x] = fill;
buffer += 32;
}
}
@@ -3114,13 +3165,13 @@ static void ClearWindowTextLines_TextMode2(struct Window *win, u8 lineLength)
static void DrawDownArrow(struct Window *win)
{
- if (PlayerCanInterruptWait(win))
+ if (PlayerCanInterruptDelay(win))
{
const u32 *downArrowTiles = &sDownArrowTiles[((win->downArrowCounter & 0x0F00) >> 8) * 16];
switch (win->textMode)
{
- case 1:
+ case TEXT_MODE_MONOSPACE:
{
u8 *buffer;
u16 tileNum = win->tileDataStartOffset + 254;
@@ -3132,8 +3183,8 @@ static void DrawDownArrow(struct Window *win)
WriteGlyphTilemap(win, tileNum, tileNum + 1);
break;
}
- case 0:
- case 2:
+ case TEXT_MODE_UNKNOWN0:
+ case TEXT_MODE_UNKNOWN2:
{
struct GlyphTileInfo glyphTileInfo;
glyphTileInfo.textMode = win->textMode;
@@ -3172,9 +3223,9 @@ static void DrawDownArrow(struct Window *win)
static u8 WaitWithDownArrow(struct Window *win)
{
- u8 retVal = 1;
+ u8 retVal = TRUE;
- if (!PlayerCanInterruptWait(win))
+ if (!PlayerCanInterruptDelay(win))
{
win->delayCounter--;
if (!win->delayCounter)
@@ -3183,8 +3234,8 @@ static u8 WaitWithDownArrow(struct Window *win)
}
else
{
- DrawMovingDownArrow(win);
- retVal = 0;
+ UpdateDownArrowAnimation(win);
+ retVal = FALSE;
}
}
else
@@ -3196,8 +3247,8 @@ static u8 WaitWithDownArrow(struct Window *win)
}
else
{
- DrawMovingDownArrow(win);
- retVal = 0;
+ UpdateDownArrowAnimation(win);
+ retVal = FALSE;
}
}
@@ -3210,7 +3261,7 @@ static void DrawInitialDownArrow(struct Window *win)
DrawDownArrow(win);
}
-static void DrawMovingDownArrow(struct Window *win)
+static void UpdateDownArrowAnimation(struct Window *win)
{
u16 downArrowPos = (win->downArrowCounter & 0x0F00) >> 8;
u16 wait = win->downArrowCounter & 0x000F;
@@ -3237,31 +3288,37 @@ static void DrawMovingDownArrow(struct Window *win)
static void TryEraseDownArrow(struct Window *win)
{
win->downArrowCounter = 0;
- if (PlayerCanInterruptWait(win) == TRUE)
+ if (PlayerCanInterruptDelay(win) == TRUE)
EraseAtCursor(win);
}
-u16 GetWindowTilemapEntry(struct Window *win, u8 x, u8 y)
+// unused
+u16 Text_GetWindowTilemapEntry(struct Window *win, u8 x, u8 y)
{
u16 *tilemap = win->tilemap;
return tilemap[32 * y + x];
}
-void DrawWindowRect(struct Window *win, u16 tilemapEntry, u8 left, u8 top, u8 right, u8 bottom)
+// unused
+void Text_FillWindowBorder(struct Window *win, u16 tilemapEntry, u8 left, u8 top, u8 right, u8 bottom)
{
u8 i;
u16 *buffer = &win->tilemap[top * 32];
+ // Fill top border
for (i = left; i <= right; i++)
buffer[i] = tilemapEntry;
for (i = top + 1; i < bottom - 1; i++)
{
buffer += 32;
+ // left border
buffer[left] = tilemapEntry;
+ // right border
buffer[right] = tilemapEntry;
}
+ // Fill bottom border
if (top != bottom)
{
buffer += 32;
@@ -3270,19 +3327,21 @@ void DrawWindowRect(struct Window *win, u16 tilemapEntry, u8 left, u8 top, u8 ri
}
}
+// unused
void DrawWindowRect_DefaultPalette(struct Window *win, u16 tileNum, u8 left, u8 top, u8 right, u8 bottom)
{
- DrawWindowRect(win, (win->paletteNum << 12) | tileNum, left, top, right, bottom);
+ Text_FillWindowBorder(win, (win->paletteNum << 12) | tileNum, left, top, right, bottom);
}
+// Fills the whole window area with tilemapEntry
void FillWindowRect(struct Window *win, u16 tilemapEntry, u8 left, u8 top, u8 right, u8 bottom)
{
u16 *buffer = &win->tilemap[top * 32];
while (top++ <= bottom)
{
- u8 j;
- for (j = left; j <= right; j++)
- buffer[j] = tilemapEntry;
+ u8 x;
+ for (x = left; x <= right; x++)
+ buffer[x] = tilemapEntry;
buffer += 32;
}
}
@@ -3297,7 +3356,7 @@ void ZeroFillWindowRect(struct Window *win, u8 left, u8 top, u8 right, u8 bottom
FillWindowRect_DefaultPalette(win, 0, left, top, right, bottom);
}
-void FillWindowRectWithBlankTile(struct Window *win, u8 left, u8 top, u8 right, u8 bottom)
+void Text_BlankWindowRect(struct Window *win, u8 left, u8 top, u8 right, u8 bottom)
{
u16 tileNum = GetBlankTileNum(win);
FillWindowRect_DefaultPalette(win, tileNum, left, top, right, bottom);
@@ -3309,12 +3368,12 @@ static u16 GetBlankTileNum(struct Window *win)
switch (win->textMode)
{
- case 0:
+ case TEXT_MODE_UNKNOWN0:
break;
- case 2:
+ case TEXT_MODE_UNKNOWN2:
retVal++;
break;
- case 1:
+ case TEXT_MODE_MONOSPACE:
switch (win->fontNum)
{
case 1:
@@ -3451,7 +3510,7 @@ u8 *AlignInt2(struct Window *win, u8 *dest, s32 value, u8 alignAmount, u8 alignT
ConvertIntToDecimalString(temp, value);
width = GetStringWidth(win, temp);
dest = StringCopy(dest, temp);
- dest[0] = 0xFC;
+ dest[0] = EXT_CTRL_CODE_BEGIN;
dest[1] = 17;
dest[2] = alignAmount - width;
dest += 3;
@@ -3462,7 +3521,7 @@ u8 *AlignInt2(struct Window *win, u8 *dest, s32 value, u8 alignAmount, u8 alignT
width = GetStringWidth(win, temp);
if (alignAmount > width)
{
- dest[0] = 0xFC;
+ dest[0] = EXT_CTRL_CODE_BEGIN;
dest[1] = 17;
dest[2] = alignAmount - width;
dest += 3;
@@ -3474,7 +3533,7 @@ u8 *AlignInt2(struct Window *win, u8 *dest, s32 value, u8 alignAmount, u8 alignT
width = GetStringWidth(win, temp);
if (alignAmount > width)
{
- dest[0] = 0xFC;
+ dest[0] = EXT_CTRL_CODE_BEGIN;
dest[1] = 17;
dest[2] = (alignAmount - width) / 2;
dest += 3;
@@ -3482,7 +3541,7 @@ u8 *AlignInt2(struct Window *win, u8 *dest, s32 value, u8 alignAmount, u8 alignT
dest = StringCopy(dest, temp);
if (alignAmount > width)
{
- dest[0] = 0xFC;
+ dest[0] = EXT_CTRL_CODE_BEGIN;
dest[1] = 17;
dest[2] = (alignAmount - width) / 2;
dest += 3;
@@ -3500,7 +3559,7 @@ u8 *AlignString(struct Window *win, u8 *dest, const u8 *src, u8 alignAmount, u8
{
case 0:
dest = StringCopy(dest, src);
- dest[0] = 0xFC;
+ dest[0] = EXT_CTRL_CODE_BEGIN;
dest[1] = 19;
dest[2] = alignAmount;
dest += 3;
@@ -3510,7 +3569,7 @@ u8 *AlignString(struct Window *win, u8 *dest, const u8 *src, u8 alignAmount, u8
width = GetStringWidth(win, src);
if (alignAmount > width)
{
- dest[0] = 0xFC;
+ dest[0] = EXT_CTRL_CODE_BEGIN;
dest[1] = 19;
dest[2] = alignAmount - width;
dest += 3;
@@ -3521,7 +3580,7 @@ u8 *AlignString(struct Window *win, u8 *dest, const u8 *src, u8 alignAmount, u8
width = GetStringWidth(win, src);
if (alignAmount > width)
{
- dest[0] = 0xFC;
+ dest[0] = EXT_CTRL_CODE_BEGIN;
dest[1] = 19;
dest[2] = (alignAmount - width) / 2;
dest += 3;
@@ -3529,7 +3588,7 @@ u8 *AlignString(struct Window *win, u8 *dest, const u8 *src, u8 alignAmount, u8
dest = StringCopy(dest, src);
if (alignAmount > width)
{
- dest[0] = 0xFC;
+ dest[0] = EXT_CTRL_CODE_BEGIN;
dest[1] = 19;
dest[2] = alignAmount;
dest += 3;
@@ -3544,16 +3603,16 @@ u8 GetStringWidth(struct Window *win, const u8 *s)
{
u8 width = 0;
u8 savedFontNum = win->fontNum;
- u8 savedCharset = win->language;
+ u8 savedLanguage = win->language;
u8 savedSpacing = win->spacing;
s32 i = 0;
- while (s[i] != 0xFF)
+ while (s[i] != EOS)
{
u8 c = s[i];
switch (c)
{
- case 0xFD:
+ case PLACEHOLDER_BEGIN:
{
u8 temp;
i++;
@@ -3563,7 +3622,7 @@ u8 GetStringWidth(struct Window *win, const u8 *s)
i++;
break;
}
- case 0xFC:
+ case EXT_CTRL_CODE_BEGIN:
i++;
switch (s[i])
{
@@ -3571,7 +3630,7 @@ u8 GetStringWidth(struct Window *win, const u8 *s)
win->fontNum = s[i + 1];
break;
case 7:
- win->fontNum = win->config->fontNum;
+ win->fontNum = win->template->fontNum;
break;
case 0x11:
width += s[i + 1];
@@ -3601,7 +3660,7 @@ u8 GetStringWidth(struct Window *win, const u8 *s)
}
win->spacing = savedSpacing;
- win->language = savedCharset;
+ win->language = savedLanguage;
win->fontNum = savedFontNum;
return width;
@@ -3609,30 +3668,30 @@ u8 GetStringWidth(struct Window *win, const u8 *s)
u8 sub_8004D04(struct Window *win, const u8 *text, u16 tileDataStartOffset, u8 left, u16 top, u32 a6)
{
- sub_8002E4C(win, text, tileDataStartOffset, left, top, a6);
- return sub_8002F44(win);
+ Text_InitWindow8002E4C(win, text, tileDataStartOffset, left, top, a6);
+ return Text_PrintWindow8002F44(win);
}
u8 sub_8004D38(struct Window *win, const u8 *text, u16 tileDataStartOffset, u8 left, u8 top)
{
u8 width = GetStringWidth(win, text);
- InitWindow(win, text, tileDataStartOffset, left - ((u32)(width + 7) >> 3), top);
+ Text_InitWindow(win, text, tileDataStartOffset, left - ((u32)(width + 7) >> 3), top);
EraseAtCursor(win);
width &= 7;
if (width)
width = 8 - width;
sub_80048D8(win, width, 0);
- return sub_8002F44(win);
+ return Text_PrintWindow8002F44(win);
}
u8 sub_8004DB0(struct Window *win, const u8 *text, u16 tileDataStartOffset, u8 left, u8 top, u16 a6)
{
register u32 val asm("r5") = (u8)((a6 >> 1) - (GetStringWidth(win, text) >> 1));
left += (val >> 3);
- InitWindow(win, text, tileDataStartOffset, left, top);
+ Text_InitWindow(win, text, tileDataStartOffset, left, top);
EraseAtCursor(win);
sub_80048D8(win, val & 7, 0);
- return sub_8002F44(win);
+ return Text_PrintWindow8002F44(win);
}
u8 sub_8004E24(struct Window *win)
@@ -3640,25 +3699,25 @@ u8 sub_8004E24(struct Window *win)
return win->paletteNum;
}
-void sub_8004E28(struct Window *win, u8 *foreground, u8 *background, u8 *shadow)
+void Text_GetTextColors(struct Window *win, u8 *foreground, u8 *background, u8 *shadow)
{
*foreground = win->foregroundColor;
*background = win->backgroundColor;
*shadow = win->shadowColor;
}
-void sub_8004E3C(const struct WindowConfig *winConfig, u8 *tileData, const u8 *text)
+void sub_8004E3C(const struct WindowTemplate *winTemplate, u8 *tileData, const u8 *text)
{
- sTempWindow.config = winConfig;
- InitWindow(&sTempWindow, text, 0, 0, 0);
+ sTempWindow.template = winTemplate;
+ Text_InitWindow(&sTempWindow, text, 0, 0, 0);
sTempWindow.tileData = tileData;
- sub_8002F44(&sTempWindow);
+ Text_PrintWindow8002F44(&sTempWindow);
}
-u8 GetStringWidthGivenWindowConfig(const struct WindowConfig *winConfig, const u8 *s)
+u8 Text_GetStringWidthFromWindowTemplate(const struct WindowTemplate *winTemplate, const u8 *s)
{
- sTempWindow.config = winConfig;
- InitWindow(&sTempWindow, s, 0, 0, 0);
+ sTempWindow.template = winTemplate;
+ Text_InitWindow(&sTempWindow, s, 0, 0, 0);
return GetStringWidth(&sTempWindow, s);
}
@@ -3801,8 +3860,8 @@ u8 sub_8004FD0(struct Window *win, u8 *dest, const u8 *src, u16 tileDataStartOff
if (endsWithoutNewline)
newlineCount++;
- sub_8002E4C(win, start, tileDataStartOffset, left, top, a8);
- sub_8002F44(win);
+ Text_InitWindow8002E4C(win, start, tileDataStartOffset, left, top, a8);
+ Text_PrintWindow8002F44(win);
return newlineCount;
}
@@ -3827,7 +3886,7 @@ static s32 DrawGlyphTile_UnshadowedFont(struct GlyphTileInfo *glyphTileInfo)
if (glyphTileInfo->startPixel + glyphTileInfo->width > 8)
{
u32 mask2 = masks[1];
- if (glyphTileInfo->textMode == 2)
+ if (glyphTileInfo->textMode == TEXT_MODE_UNKNOWN2)
{
glyphBuffer->pixelRows[8] = buffer[8] & mask2;
glyphBuffer->pixelRows[9] = buffer[9] & mask2;
@@ -3867,7 +3926,7 @@ static s32 DrawGlyphTile_UnshadowedFont(struct GlyphTileInfo *glyphTileInfo)
if (glyphTileInfo->startPixel + glyphTileInfo->width > 8)
{
- if (glyphTileInfo->textMode != 2)
+ if (glyphTileInfo->textMode != TEXT_MODE_UNKNOWN2)
buffer += 8;
buffer[8] = glyphBuffer->pixelRows[8];
buffer[9] = glyphBuffer->pixelRows[9];
@@ -4039,7 +4098,7 @@ static s32 DrawGlyphTile_ShadowedFont(struct GlyphTileInfo *glyphTileInfo)
if (glyphTileInfo->startPixel + glyphTileInfo->width > 8)
{
u32 mask2 = masks[1];
- if (glyphTileInfo->textMode == 2)
+ if (glyphTileInfo->textMode == TEXT_MODE_UNKNOWN2)
{
glyphBuffer->pixelRows[8] = buffer[8] & mask2;
glyphBuffer->pixelRows[9] = buffer[9] & mask2;
@@ -4076,7 +4135,7 @@ static s32 DrawGlyphTile_ShadowedFont(struct GlyphTileInfo *glyphTileInfo)
if (glyphTileInfo->startPixel + glyphTileInfo->width > 8)
{
- if (glyphTileInfo->textMode != 2)
+ if (glyphTileInfo->textMode != TEXT_MODE_UNKNOWN2)
buffer += 8;
buffer[8] = glyphBuffer->pixelRows[8];
buffer[9] = glyphBuffer->pixelRows[9];
@@ -4314,7 +4373,7 @@ static u16 GetCursorTileNum(struct Window *win, u32 xOffset, u32 yOffset)
{
u16 index;
- if (win->textMode == 2)
+ if (win->textMode == TEXT_MODE_UNKNOWN2)
index = win->tileDataStartOffset
+ win->tileDataOffset
+ (((win->top + win->cursorY) >> 3) + yOffset) * win->width
diff --git a/src/engine/text_window.c b/src/engine/text_window.c
index c001ddefc..ade349f4e 100644
--- a/src/engine/text_window.c
+++ b/src/engine/text_window.c
@@ -4,19 +4,22 @@
#include "palette.h"
#include "text.h"
-#define STD_MSG_BOX_LEFT 0
-#define STD_MSG_BOX_TOP 14
-#define STD_MSG_BOX_WIDTH 26
-#define STD_MSG_BOX_HEIGHT 4
+#define STD_WINDOW_PALETTE_NUM 14
+
+// Dimensions (in tiles) of a field dialogue frame
+#define STD_DLG_FRAME_LEFT 0
+#define STD_DLG_FRAME_TOP 14
+#define STD_DLG_FRAME_WIDTH 26
+#define STD_DLG_FRAME_HEIGHT 4
static void LoadTextWindowTiles(u8, void *);
static void LoadTextWindowPalette(u8, u8);
-static void DrawTextWindowInternal(u16 *dest, u16 baseTileNum, u8 left, u8 top, u8 right, u8 bottom);
-static u16 GetMessageBoxTilemapEntry(u16 tilemapEntry, u8 x, u8 y, u8 width, u8 height);
-static void DrawMessageBox(struct Window *win, u8 left, u8 top, u8 width, u8 height);
+static void DrawStandardFrame(u16 *dest, u16 baseTileNum, u8 left, u8 top, u8 right, u8 bottom);
+static u16 GetDialogueFrameTilemapEntry(u16 tilemapEntry, u8 x, u8 y, u8 width, u8 height);
+static void DrawDialogueFrame(struct Window *win, u8 left, u8 top, u8 width, u8 height);
static u16 sTextWindowBaseTileNum;
-static u16 sMessageBoxBaseTileNum;
+static u16 sDialogueFrameBaseTileNum;
extern const u8 gTextWindowFrame1_Gfx[];
extern const u8 gTextWindowFrame2_Gfx[];
@@ -60,9 +63,9 @@ extern const u16 gTextWindowFrame18_Pal[];
extern const u16 gTextWindowFrame19_Pal[];
extern const u16 gTextWindowFrame20_Pal[];
-extern const u8 gMessageBox_Gfx[];
+extern const u8 gDialogueFrame_Gfx[];
-static const struct FrameGraphics gUnknown_083761F0[20] =
+static const struct FrameGraphics sTextWindowFrameGraphics[20] =
{
{gTextWindowFrame1_Gfx, gTextWindowFrame1_Pal},
{gTextWindowFrame2_Gfx, gTextWindowFrame2_Pal},
@@ -86,7 +89,7 @@ static const struct FrameGraphics gUnknown_083761F0[20] =
{gTextWindowFrame20_Gfx, gTextWindowFrame20_Pal},
};
-static const u16 gMessageBoxTilemap[5][7] =
+static const u16 sDialogueFrameTilemap[5][7] =
{
{1, 3, 4, 4, 5, 6, 9},
{11, 9, 9, 9, 9, 0x040B, 9},
@@ -95,113 +98,124 @@ static const u16 gMessageBoxTilemap[5][7] =
{0x0801, 0x0803, 0x0804, 0x0804, 0x0805, 0x0806, 9},
};
-u16 SetTextWindowBaseTileNum(u16 baseTileNum)
+u16 TextWindow_SetBaseTileNum(u16 baseTileNum)
{
sTextWindowBaseTileNum = baseTileNum;
return baseTileNum + 9;
}
-void LoadTextWindowGraphics(struct Window *win)
+// Loads the tiles and palette of the window frame into VRAM using the selected frame type
+void TextWindow_LoadStdFrameGraphics(struct Window *win)
{
- u8 *tileData = win->config->tileData + TILE_SIZE_4BPP * sTextWindowBaseTileNum;
+ u8 *tileData = win->template->tileData + TILE_SIZE_4BPP * sTextWindowBaseTileNum;
LoadTextWindowTiles(gSaveBlock2.optionsWindowFrameType, tileData);
- LoadTextWindowPalette(gSaveBlock2.optionsWindowFrameType, 0xE);
+ LoadTextWindowPalette(gSaveBlock2.optionsWindowFrameType, STD_WINDOW_PALETTE_NUM);
}
-void LoadTextWindowGraphics_OverridePalSlot(struct Window *win, u8 palSlot)
+// Loads the tiles and palette of the window frame into VRAM with an alternate palette
+void TextWindow_LoadStdFrameGraphicsOverridePal(struct Window *win, u8 palSlot)
{
- u8 *tileData = win->config->tileData + TILE_SIZE_4BPP * sTextWindowBaseTileNum;
+ u8 *tileData = win->template->tileData + TILE_SIZE_4BPP * sTextWindowBaseTileNum;
LoadTextWindowTiles(gSaveBlock2.optionsWindowFrameType, tileData);
LoadTextWindowPalette(gSaveBlock2.optionsWindowFrameType, palSlot);
}
-void LoadTextWindowGraphics_OverrideFrameType(struct Window *win, u8 frameType)
+// Loads the tiles and palette of the window frame into VRAM with an alternate frame type
+void TextWindow_LoadStdFrameGraphicsOverrideStyle(struct Window *win, u8 frameType)
{
- u8 *tileData = win->config->tileData + TILE_SIZE_4BPP * sTextWindowBaseTileNum;
+ u8 *tileData = win->template->tileData + TILE_SIZE_4BPP * sTextWindowBaseTileNum;
LoadTextWindowTiles(frameType, tileData);
- LoadTextWindowPalette(frameType, 0xE);
+ LoadTextWindowPalette(frameType, STD_WINDOW_PALETTE_NUM);
}
-void DrawTextWindow(struct Window *win, u8 left, u8 top, u8 right, u8 bottom)
+void TextWindow_DrawStdFrame(struct Window *win, u8 left, u8 top, u8 right, u8 bottom)
{
- DrawTextWindowInternal(win->config->tilemap, sTextWindowBaseTileNum, left, top, right, bottom);
+ DrawStandardFrame(win->template->tilemap, sTextWindowBaseTileNum, left, top, right, bottom);
}
-const struct FrameGraphics *GetTextWindowFrameGraphics(u8 frameType)
+// Returns the tile data and palette for the specified frame type
+const struct FrameGraphics *TextWindow_GetFrameGraphics(u8 frameType)
{
if (frameType > 19)
- return &gUnknown_083761F0[0];
+ return &sTextWindowFrameGraphics[0];
else
- return &gUnknown_083761F0[frameType];
+ return &sTextWindowFrameGraphics[frameType];
}
static void LoadTextWindowTiles(u8 frameType, void *dest)
{
- const struct FrameGraphics *frameGraphics = GetTextWindowFrameGraphics(frameType);
+ const struct FrameGraphics *frameGraphics = TextWindow_GetFrameGraphics(frameType);
CpuFastCopy(frameGraphics->tiles, dest, 9 * TILE_SIZE_4BPP);
}
static void LoadTextWindowPalette(u8 frameType, u8 palSlot)
{
- const struct FrameGraphics *frameGraphics = GetTextWindowFrameGraphics(frameType);
+ const struct FrameGraphics *frameGraphics = TextWindow_GetFrameGraphics(frameType);
LoadPalette(frameGraphics->palette, 16 * palSlot, 0x20);
}
-static void DrawTextWindowInternal(u16 *dest, u16 baseTileNum, u8 left, u8 top, u8 right, u8 bottom)
+// Draws a standard window frame
+static void DrawStandardFrame(u16 *tilemap, u16 baseTileNum, u8 left, u8 top, u8 right, u8 bottom)
{
+ u8 startX = min(left, right);
+ u8 endX = max(left, right);
+ u8 startY = min(top, bottom);
+ u8 endY = max(top, bottom);
u8 x, y;
- u8 startX, endX;
- u8 startY, endY;
-
- startX = (left < right) ? left : right;
- endX = (right > left) ? right : left;
-
- startY = (top < bottom) ? top : bottom;
- endY = (bottom > top) ? bottom : top;
- dest[32 * startY + startX] = baseTileNum | 0xE000;
+ // top left corner
+ tilemap[32 * startY + startX] = baseTileNum | (STD_WINDOW_PALETTE_NUM << 12);
+ // top border
for (x = startX + 1; x < endX; x++)
- dest[32 * startY + x] = (baseTileNum + 1) | 0xE000;
+ tilemap[32 * startY + x] = (baseTileNum + 1) | (STD_WINDOW_PALETTE_NUM << 12);
- dest[32 * startY + endX] = (baseTileNum + 2) | 0xE000;
+ // top right corner
+ tilemap[32 * startY + endX] = (baseTileNum + 2) | (STD_WINDOW_PALETTE_NUM << 12);
for (y = startY + 1; y < endY; y++)
{
- dest[32 * y + startX] = (baseTileNum + 3) | 0xE000;
+ // left border
+ tilemap[32 * y + startX] = (baseTileNum + 3) | (STD_WINDOW_PALETTE_NUM << 12);
+ // middle
for (x = startX + 1; x < endX; x++)
- dest[32 * y + x] = (baseTileNum + 4) | 0xE000;
+ tilemap[32 * y + x] = (baseTileNum + 4) | (STD_WINDOW_PALETTE_NUM << 12);
- dest[32 * y + endX] = (baseTileNum + 5) | 0xE000;
+ // right border
+ tilemap[32 * y + endX] = (baseTileNum + 5) | (STD_WINDOW_PALETTE_NUM << 12);
}
- dest[32 * endY + startX] = (baseTileNum + 6) | 0xE000;
+ // bottom left corner
+ tilemap[32 * endY + startX] = (baseTileNum + 6) | (STD_WINDOW_PALETTE_NUM << 12);
+ // bottom border
for (x = startX + 1; x < endX; x++)
- dest[32 * endY + x] = (baseTileNum + 7) | 0xE000;
+ tilemap[32 * endY + x] = (baseTileNum + 7) | (STD_WINDOW_PALETTE_NUM << 12);
- dest[32 * endY + endX] = (baseTileNum + 8) | 0xE000;
+ // bottom right corner
+ tilemap[32 * endY + endX] = (baseTileNum + 8) | (STD_WINDOW_PALETTE_NUM << 12);
}
-u16 SetMessageBoxBaseTileNum(u16 baseTileNum)
+u16 TextWindow_SetDlgFrameBaseTileNum(u16 baseTileNum)
{
- sMessageBoxBaseTileNum = baseTileNum;
+ sDialogueFrameBaseTileNum = baseTileNum;
return baseTileNum + 14;
}
void unref_sub_80651DC(struct Window *win, u8 *text)
{
- sub_8002EB0(win, text, sMessageBoxBaseTileNum + 14, 2, 15);
+ Text_InitWindow8002EB0(win, text, sDialogueFrameBaseTileNum + 14, 2, 15);
}
-void DisplayMessageBox(struct Window *win)
+// Loads and draws a dialogue window frame
+void TextWindow_DisplayDialogueFrame(struct Window *win)
{
- LoadMessageBoxTiles(win);
- DrawStandardMessageBox(win);
+ TextWindow_LoadDialogueFrameTiles(win);
+ TextWindow_DrawDialogueFrame(win);
}
-static u16 GetMessageBoxTilemapEntry(u16 baseTilemapEntry, u8 x, u8 y, u8 width, u8 height)
+static u16 GetDialogueFrameTilemapEntry(u16 baseTilemapEntry, u8 x, u8 y, u8 width, u8 height)
{
u16 tilemapEntry = 9;
@@ -215,42 +229,47 @@ static u16 GetMessageBoxTilemapEntry(u16 baseTilemapEntry, u8 x, u8 y, u8 width,
else if (x > 2)
x = 3;
- if (x <= 6 && y <= 4)
- tilemapEntry = gMessageBoxTilemap[y][x];
+ if (x < 7 && y < 5)
+ tilemapEntry = sDialogueFrameTilemap[y][x];
tilemapEntry += baseTilemapEntry;
return tilemapEntry;
}
-static void DrawMessageBox(struct Window *win, u8 left, u8 top, u8 width, u8 height)
+static void DrawDialogueFrame(struct Window *win, u8 left, u8 top, u8 width, u8 height)
{
- u8 i, j;
- u16 tilemapEntry = (win->paletteNum << 12) | sMessageBoxBaseTileNum;
- u16 *tilemap = win->config->tilemap;
+ u8 x, y;
+ u16 baseTilemapEntry = (win->paletteNum << 12) | sDialogueFrameBaseTileNum;
+ u16 *tilemap = win->template->tilemap;
- for (i = 0; i < height + 2; i++)
- for (j = 0; j < width + 6; j++)
- tilemap[(left + j) + 32 * (top + i)] = (win->paletteNum << 12) | GetMessageBoxTilemapEntry(tilemapEntry, j, i, width, height);
+ for (y = 0; y < height + 2; y++)
+ {
+ for (x = 0; x < width + 6; x++)
+ tilemap[(left + x) + 32 * (top + y)] = (win->paletteNum << 12) | GetDialogueFrameTilemapEntry(baseTilemapEntry, x, y, width, height);
+ }
}
-void DrawStandardMessageBox(struct Window *win)
+// Draws an alternate styled frame used for dialogue windows that appear on the overworld
+void TextWindow_DrawDialogueFrame(struct Window *win)
{
- DrawMessageBox(win, STD_MSG_BOX_LEFT, STD_MSG_BOX_TOP, STD_MSG_BOX_WIDTH, STD_MSG_BOX_HEIGHT);
+ DrawDialogueFrame(win, STD_DLG_FRAME_LEFT, STD_DLG_FRAME_TOP, STD_DLG_FRAME_WIDTH, STD_DLG_FRAME_HEIGHT);
}
-void LoadMessageBoxTiles(struct Window *win)
+// Loads the dialogue window frame tiles into VRAM
+void TextWindow_LoadDialogueFrameTiles(struct Window *win)
{
- u8 *tileData = win->config->tileData;
- CpuFastCopy(gMessageBox_Gfx, tileData + 32 * sMessageBoxBaseTileNum, 14 * TILE_SIZE_4BPP);
+ u8 *tileData = win->template->tileData;
+ CpuFastCopy(gDialogueFrame_Gfx, tileData + 32 * sDialogueFrameBaseTileNum, 14 * TILE_SIZE_4BPP);
}
-void ClearStandardMessageBox(struct Window *win)
+// Erases a dialogue window frame
+void TextWindow_EraseDialogueFrame(struct Window *win)
{
u8 i;
- u16 *tilemap = win->config->tilemap + (STD_MSG_BOX_TOP * 32);
+ u16 *tilemap = win->template->tilemap + (STD_DLG_FRAME_TOP * 32);
u16 tilemapEntry = win->paletteNum << 12;
- for (i = 0; i < ((STD_MSG_BOX_HEIGHT + 2) * 32); i++)
+ for (i = 0; i < ((STD_DLG_FRAME_HEIGHT + 2) * 32); i++)
tilemap[i] = tilemapEntry;
}
diff --git a/src/engine/trade.c b/src/engine/trade.c
index 0bc589ff4..d37b36f72 100644
--- a/src/engine/trade.c
+++ b/src/engine/trade.c
@@ -141,7 +141,7 @@ struct TradeEwramStruct {
};
static void sub_8047EC0(void);
-static void sub_804AFB8(const struct WindowConfig *, u8 *, const u8 *, u8);
+static void sub_804AFB8(const struct WindowTemplate *, u8 *, const u8 *, u8);
static void sub_804ACD8(const u8 *, u8 *, u8);
static void nullsub_5(u8, u8);
static void sub_804AA88(void);
@@ -1089,10 +1089,10 @@ static void sub_8047EC0(void)
SetVBlankCallback(sub_80489F4);
InitMenuWindow(&gWindowConfig_81E6CE4);
SetUpWindowConfig(&gWindowConfig_81E6F84);
- InitWindowFromConfig(&gUnknown_03004824->window, &gWindowConfig_81E6F84);
- gUnknown_03004824->unk_007a = SetTextWindowBaseTileNum(20);
- LoadTextWindowGraphics(&gUnknown_03004824->window);
- MenuZeroFillScreen();
+ Text_InitWindowWithTemplate(&gUnknown_03004824->window, &gWindowConfig_81E6F84);
+ gUnknown_03004824->unk_007a = TextWindow_SetBaseTileNum(20);
+ TextWindow_LoadStdFrameGraphics(&gUnknown_03004824->window);
+ Menu_EraseScreen();
sub_809D51C();
gUnknown_03004824->unk_0075 = 0;
gUnknown_03004824->unk_007b = 0;
@@ -1269,10 +1269,10 @@ static void sub_80484F4(void)
SetVBlankCallback(sub_80489F4);
InitMenuWindow(&gWindowConfig_81E6CE4);
SetUpWindowConfig(&gWindowConfig_81E6F84);
- InitWindowFromConfig(&gUnknown_03004824->window, &gWindowConfig_81E6F84);
- gUnknown_03004824->unk_007a = SetTextWindowBaseTileNum(20);
- LoadTextWindowGraphics(&gUnknown_03004824->window);
- MenuZeroFillScreen();
+ Text_InitWindowWithTemplate(&gUnknown_03004824->window, &gWindowConfig_81E6F84);
+ gUnknown_03004824->unk_007a = TextWindow_SetBaseTileNum(20);
+ TextWindow_LoadStdFrameGraphics(&gUnknown_03004824->window);
+ Menu_EraseScreen();
sub_809D51C();
gUnknown_03004824->unk_0075 = 0;
gUnknown_03004824->unk_007b = 0;
@@ -2096,7 +2096,7 @@ static void sub_8049680(void)
PlaySE(SE_SELECT);
if (gUnknown_03004824->tradeMenuCursorPosition < PARTY_SIZE)
{
- DrawTextWindow(&gUnknown_03004824->window, 18, 14, 28, 19);
+ TextWindow_DrawStdFrame(&gUnknown_03004824->window, 18, 14, 28, 19);
PrintMenuItems(19, 15, 2, (const struct MenuAction *)gUnknown_0820C320);
InitMenu(0, 19, 15, 2, 0, 9);
gUnknown_03004824->unk_007b = 1;
@@ -2108,7 +2108,7 @@ static void sub_8049680(void)
}
else if (gUnknown_03004824->tradeMenuCursorPosition == 2 * PARTY_SIZE)
{
- DrawTextWindow(&gUnknown_03004824->window, 24, 14, 29, 19);
+ TextWindow_DrawStdFrame(&gUnknown_03004824->window, 24, 14, 29, 19);
InitYesNoMenu(24, 14, 4);
gUnknown_03004824->unk_007b = 4;
sub_804ACD8(gUnknown_0820C14C[4], BG_CHAR_ADDR(4) + 32 * gUnknown_03004824->unk_007e, 20);
@@ -2138,17 +2138,17 @@ static void sub_8049860(void)
if (gMain.newAndRepeatedKeys & DPAD_UP)
{
PlaySE(SE_SELECT);
- gUnknown_03004824->unk_007c = MoveMenuCursor(-1);
+ gUnknown_03004824->unk_007c = Menu_MoveCursor(-1);
}
else if (gMain.newAndRepeatedKeys & DPAD_DOWN)
{
PlaySE(SE_SELECT);
- gUnknown_03004824->unk_007c = MoveMenuCursor(+1);
+ gUnknown_03004824->unk_007c = Menu_MoveCursor(+1);
}
if (gMain.newKeys & A_BUTTON)
{
PlaySE(SE_SELECT);
- if (GetMenuCursorPos() == 0)
+ if (Menu_GetCursorPos() == 0)
{
BeginNormalPaletteFade(-1, 0, 0, 16, 0);
gUnknown_03004824->unk_007b = 2;
@@ -2239,17 +2239,17 @@ static void sub_8049AC0(void)
if (gMain.newAndRepeatedKeys & DPAD_UP)
{
PlaySE(SE_SELECT);
- gUnknown_03004824->unk_007c = MoveMenuCursor(-1);
+ gUnknown_03004824->unk_007c = Menu_MoveCursor(-1);
}
else if (gMain.newAndRepeatedKeys & DPAD_DOWN)
{
PlaySE(SE_SELECT);
- gUnknown_03004824->unk_007c = MoveMenuCursor(+1);
+ gUnknown_03004824->unk_007c = Menu_MoveCursor(+1);
}
if (gMain.newKeys & A_BUTTON)
{
PlaySE(SE_SELECT);
- if (GetMenuCursorPos() == 0)
+ if (Menu_GetCursorPos() == 0)
{
sub_8049A20();
}
@@ -2267,9 +2267,9 @@ static void sub_8049AC0(void)
else if (gMain.newKeys & B_BUTTON)
{
sub_804AADC(3, 1);
- if (GetMenuCursorPos() == 0)
+ if (Menu_GetCursorPos() == 0)
{
- gUnknown_03004824->unk_007c = MoveMenuCursor(+1);
+ gUnknown_03004824->unk_007c = Menu_MoveCursor(+1);
}
gUnknown_03004824->linkData[0] = 0xbbcc;
Trade_SendData(gUnknown_03004824);
@@ -2282,17 +2282,17 @@ static void sub_8049BC0(void)
if (gMain.newAndRepeatedKeys & DPAD_UP)
{
PlaySE(SE_SELECT);
- gUnknown_03004824->unk_007c = MoveMenuCursor(-1);
+ gUnknown_03004824->unk_007c = Menu_MoveCursor(-1);
}
else if (gMain.newAndRepeatedKeys & DPAD_DOWN)
{
PlaySE(SE_SELECT);
- gUnknown_03004824->unk_007c = MoveMenuCursor(+1);
+ gUnknown_03004824->unk_007c = Menu_MoveCursor(+1);
}
if (gMain.newKeys & A_BUTTON)
{
PlaySE(SE_SELECT);
- if (GetMenuCursorPos() == 0)
+ if (Menu_GetCursorPos() == 0)
{
sub_804AA0C(4);
gUnknown_03004824->linkData[0] = 0xeeaa;
@@ -2337,7 +2337,7 @@ static void DisplayMessageAndContinueTask(void)
gUnknown_03004824->unk_00b4++;
if (gUnknown_03004824->unk_00b4 > 120)
{
- DrawTextWindow(&gUnknown_03004824->window, 24, 14, 29, 19);
+ TextWindow_DrawStdFrame(&gUnknown_03004824->window, 24, 14, 29, 19);
InitYesNoMenu(24, 14, 4);
gUnknown_03004824->unk_00b4 = 0;
gUnknown_03004824->unk_007b = 3;
@@ -2491,10 +2491,10 @@ static void sub_8049ED4(u8 a0)
string1[3] = 0xFC;
string1[4] = 0x11;
string1[5] = (64 - stringLength) / 2;
- sub_8003460(&gUnknown_03004824->window, string1, gUnknown_03004824->unk_007a + whichParty * 6 * 32, gUnknown_0820C334[whichParty][0], gUnknown_0820C334[whichParty][1]);
+ Text_InitWindowAndPrintText(&gUnknown_03004824->window, string1, gUnknown_03004824->unk_007a + whichParty * 6 * 32, gUnknown_0820C334[whichParty][0], gUnknown_0820C334[whichParty][1]);
sub_804A33C(string2, whichParty, whichPokemon);
- sub_8003460(&gUnknown_03004824->window, gOtherText_Terminator2, gUnknown_03004824->unk_007a + whichParty * 6 * 32 + 32, gUnknown_0820C334[whichParty + 1][0], gUnknown_0820C334[whichParty + 1][1] + 1);
- sub_8003460(&gUnknown_03004824->window, string2, gUnknown_03004824->unk_007a + whichParty * 6 * 32 + 38, gUnknown_0820C334[whichParty + 1][0], gUnknown_0820C334[whichParty + 1][1] + 1);
+ Text_InitWindowAndPrintText(&gUnknown_03004824->window, gOtherText_Terminator2, gUnknown_03004824->unk_007a + whichParty * 6 * 32 + 32, gUnknown_0820C334[whichParty + 1][0], gUnknown_0820C334[whichParty + 1][1] + 1);
+ Text_InitWindowAndPrintText(&gUnknown_03004824->window, string2, gUnknown_03004824->unk_007a + whichParty * 6 * 32 + 38, gUnknown_0820C334[whichParty + 1][0], gUnknown_0820C334[whichParty + 1][1] + 1);
gUnknown_03004824->unk_0080[a0] ++;
break;
case 4:
@@ -2884,7 +2884,7 @@ static void sub_8049ED4(u8 a0)
"\tldrb r1, [r1]\n"
"\tstr r1, [sp]\n"
"\tadd r1, sp, 0xC\n"
- "\tbl sub_8003460\n"
+ "\tbl Text_InitWindowAndPrintText\n"
"\tadd r7, sp, 0x34\n"
"\tadds r0, r7, 0\n"
"\tldr r1, [sp, 0x6C]\n"
@@ -2910,7 +2910,7 @@ static void sub_8049ED4(u8 a0)
"\tlsrs r4, 24\n"
"\tstr r4, [sp]\n"
"\tadds r3, r5, 0\n"
- "\tbl sub_8003460\n"
+ "\tbl Text_InitWindowAndPrintText\n"
"\tldr r0, _0804A22C @ =gUnknown_03004824\n"
"\tldr r1, [r0]\n"
"\tadds r0, r1, 0x4\n"
@@ -2921,7 +2921,7 @@ static void sub_8049ED4(u8 a0)
"\tstr r4, [sp]\n"
"\tadds r1, r7, 0\n"
"\tadds r3, r5, 0\n"
- "\tbl sub_8003460\n"
+ "\tbl Text_InitWindowAndPrintText\n"
"\tldr r2, _0804A22C @ =gUnknown_03004824\n"
"\tldr r1, [r2]\n"
"\tb _0804A28A\n"
@@ -3010,7 +3010,7 @@ u8 sub_804A2B4(u8 *a0, u8 whichParty, u8 whichPokemon)
GetMonGender(&gEnemyParty[whichPokemon]);
GetMonData(&gEnemyParty[whichPokemon], MON_DATA_LEVEL);
}
- return GetStringWidthGivenWindowConfig(&gWindowConfig_81E7294, a0);
+ return Text_GetStringWidthFromWindowTemplate(&gWindowConfig_81E7294, a0);
}
#ifdef NONMATCHING
@@ -3067,8 +3067,8 @@ static void sub_804A41C(u8 whichParty)
GetMonData(pokemon, MON_DATA_NICKNAME, nickname);
StringCopy10(string + 6, nickname);
GetMonGender(pokemon);
- string[5] = (50 - GetStringWidthGivenWindowConfig(&gWindowConfig_81E7294, string + 6)) / 2;
- sub_8003460(&gUnknown_03004824->window, string, gUnknown_03004824->unk_007a + 22 * 6 * whichParty + 22 * i, gTradeMonSpriteCoords[i + 6 * whichParty][0], gTradeMonSpriteCoords[i + 6 * whichParty][1]);
+ string[5] = (50 - Text_GetStringWidthFromWindowTemplate(&gWindowConfig_81E7294, string + 6)) / 2;
+ Text_InitWindowAndPrintText(&gUnknown_03004824->window, string, gUnknown_03004824->unk_007a + 22 * 6 * whichParty + 22 * i, gTradeMonSpriteCoords[i + 6 * whichParty][0], gTradeMonSpriteCoords[i + 6 * whichParty][1]);
}
}
#else
@@ -3142,7 +3142,7 @@ static void sub_804A41C(u8 whichParty)
"\tmov r1, sp\n"
"\tadds r1, 0x22\n"
"\tldr r0, _0804A518 @ =gWindowConfig_81E7294\n"
- "\tbl GetStringWidthGivenWindowConfig\n"
+ "\tbl Text_GetStringWidthFromWindowTemplate\n"
"\tlsls r0, 24\n"
"\tlsrs r0, 24\n"
"\tmovs r1, 0x32\n"
@@ -3177,7 +3177,7 @@ static void sub_804A41C(u8 whichParty)
"\tldrb r1, [r1]\n"
"\tstr r1, [sp]\n"
"\tmov r1, r8\n"
- "\tbl sub_8003460\n"
+ "\tbl Text_InitWindowAndPrintText\n"
"\tadds r0, r6, 0x1\n"
"\tlsls r0, 24\n"
"\tlsrs r6, r0, 24\n"
@@ -3413,18 +3413,18 @@ static void sub_804A96C_alt(struct UnkStructD *arg0, u8 left, u8 top, const u16
static void sub_804A9F4(u8 unused)
{
- MenuZeroFillScreen();
+ Menu_EraseScreen();
}
static void sub_804AA00(u8 unused)
{
- MenuZeroFillScreen();
+ Menu_EraseScreen();
}
static void sub_804AA0C(u8 a0)
{
- DrawTextWindow(&gUnknown_03004824->window, gTradeMessageWindowRects[a0][0], gTradeMessageWindowRects[a0][1], gTradeMessageWindowRects[a0][2], gTradeMessageWindowRects[a0][3]);
- sub_8003460(&gUnknown_03004824->window, gUnknown_0820C2F0[a0], 0x180 + gUnknown_03004824->unk_007a, gTradeMessageWindowRects[a0][0] + 1, gTradeMessageWindowRects[a0][1] + 1);
+ TextWindow_DrawStdFrame(&gUnknown_03004824->window, gTradeMessageWindowRects[a0][0], gTradeMessageWindowRects[a0][1], gTradeMessageWindowRects[a0][2], gTradeMessageWindowRects[a0][3]);
+ Text_InitWindowAndPrintText(&gUnknown_03004824->window, gUnknown_0820C2F0[a0], 0x180 + gUnknown_03004824->unk_007a, gTradeMessageWindowRects[a0][0] + 1, gTradeMessageWindowRects[a0][1] + 1);
}
static void sub_804AA88(void)
@@ -3798,7 +3798,7 @@ static void sub_804AF84(void)
gSaveBlock1.giftRibbons[i] = gUnknown_03004824->unk_00b5[i];
}
-static void sub_804AFB8(const struct WindowConfig *windowConfig, u8 *dest, const u8 *src, u8 size)
+static void sub_804AFB8(const struct WindowTemplate *windowConfig, u8 *dest, const u8 *src, u8 size)
{
u8 i;
u8 *tileBuffer;
@@ -4029,10 +4029,10 @@ static void sub_804B41C(void)
SetVBlankCallback(sub_804B210);
sub_804B228();
SetUpWindowConfig(&gWindowConfig_81E6F84);
- InitWindowFromConfig(&gUnknown_03004828->window, &gWindowConfig_81E6F84);
- gUnknown_03004828->textWindowBaseTileNum = SetTextWindowBaseTileNum(2);
- LoadTextWindowGraphics(&gUnknown_03004828->window);
- MenuZeroFillScreen();
+ Text_InitWindowWithTemplate(&gUnknown_03004828->window, &gWindowConfig_81E6F84);
+ gUnknown_03004828->textWindowBaseTileNum = TextWindow_SetBaseTileNum(2);
+ TextWindow_LoadStdFrameGraphics(&gUnknown_03004828->window);
+ Menu_EraseScreen();
gLinkType = 0x1144;
gMain.state ++;
LZDecompressVram(gUnknown_08D00000, (void *)VRAM);
@@ -4188,16 +4188,16 @@ static __attribute__((naked)) void sub_804B41C(void)
"\tldr r0, [r6]\n"
"\tadds r0, 0x4\n"
"\tadds r1, r4, 0\n"
- "\tbl InitWindowFromConfig\n"
+ "\tbl Text_InitWindowWithTemplate\n"
"\tmovs r0, 0x2\n"
- "\tbl SetTextWindowBaseTileNum\n"
+ "\tbl TextWindow_SetBaseTileNum\n"
"\tldr r1, [r6]\n"
"\tadds r1, 0x34\n"
"\tstrb r0, [r1]\n"
"\tldr r0, [r6]\n"
"\tadds r0, 0x4\n"
- "\tbl LoadTextWindowGraphics\n"
- "\tbl MenuZeroFillScreen\n"
+ "\tbl TextWindow_LoadStdFrameGraphics\n"
+ "\tbl Menu_EraseScreen\n"
"\tldr r1, _0804B580 @ =gLinkType\n"
"\tldr r4, _0804B584 @ =0x00001144\n"
"\tadds r0, r4, 0\n"
@@ -4532,10 +4532,10 @@ static void sub_804B790(void)
SetVBlankCallback(sub_804B210);
sub_804B228();
SetUpWindowConfig(&gWindowConfig_81E717C);
- InitWindowFromConfig(&gUnknown_03004828->window, &gWindowConfig_81E717C);
- gUnknown_03004828->textWindowBaseTileNum = SetTextWindowBaseTileNum(2);
- LoadTextWindowGraphics(&gUnknown_03004828->window);
- MenuZeroFillScreen();
+ Text_InitWindowWithTemplate(&gUnknown_03004828->window, &gWindowConfig_81E717C);
+ gUnknown_03004828->textWindowBaseTileNum = TextWindow_SetBaseTileNum(2);
+ TextWindow_LoadStdFrameGraphics(&gUnknown_03004828->window);
+ Menu_EraseScreen();
gLinkType = 0x1144;
gUnknown_03004828->isLinkTrade = FALSE;
gUnknown_03004828->unk_00b6 = 0;
@@ -4733,7 +4733,7 @@ static void sub_804BBE8(u8 a0)
for (i = 0; i < 0x280; i ++)
buffer[i] |= 0x7000;
DmaCopy16Defvars(3, gSharedMem, BG_SCREEN_ADDR(5), 0x500);
- MenuZeroFillWindowRect(2, 15, 27, 18);
+ Menu_EraseWindowRect(2, 15, 27, 18);
break;
case 6:
REG_DISPCNT = DISPCNT_MODE_1 | DISPCNT_OBJ_1D_MAP | DISPCNT_BG2_ON | DISPCNT_OBJ_ON;
@@ -4843,7 +4843,7 @@ static bool8 sub_804C29C(void)
case 10:
StringExpandPlaceholders(gStringVar4, gTradeText_WillBeSent);
- sub_8003460(&gUnknown_03004828->window, gStringVar4, gUnknown_03004828->textWindowBaseTileNum, 2, 15);
+ Text_InitWindowAndPrintText(&gUnknown_03004828->window, gStringVar4, gUnknown_03004828->textWindowBaseTileNum, 2, 15);
gUnknown_03004828->unk_00c4 = 11;
gUnknown_03004828->unk_00c0 = 0;
break;
@@ -4854,11 +4854,11 @@ static bool8 sub_804C29C(void)
gUnknown_03004828->unk_00c4 ++;
ZeroFillWindowRect(&gUnknown_03004828->window, 0, 0, 29, 19);
StringExpandPlaceholders(gStringVar4, gTradeText_ByeBye);
- sub_8003460(&gUnknown_03004828->window, gStringVar4, gUnknown_03004828->textWindowBaseTileNum, 2, 15);
+ Text_InitWindowAndPrintText(&gUnknown_03004828->window, gStringVar4, gUnknown_03004828->textWindowBaseTileNum, 2, 15);
}
break;
case 12:
- if (gSprites[gUnknown_03004828->unk_0102].callback == SpriteCallbackDummy && sub_80035AC(&gUnknown_03004828->window) == TRUE)
+ if (gSprites[gUnknown_03004828->unk_0102].callback == SpriteCallbackDummy && Text_UpdateWindow(&gUnknown_03004828->window) == TRUE)
{
gUnknown_03004828->unk_0103 = CreateSprite(&gSpriteTemplate_821595C, 0x78, 0x20, 0);
gSprites[gUnknown_03004828->unk_0103].callback = sub_804D738;
@@ -5201,7 +5201,7 @@ static bool8 sub_804C29C(void)
REG_DISPCNT = DISPCNT_MODE_0 | DISPCNT_OBJ_1D_MAP | DISPCNT_BG0_ON | DISPCNT_BG1_ON | DISPCNT_BG2_ON | DISPCNT_OBJ_ON;
ZeroFillWindowRect(&gUnknown_03004828->window, 0, 0, 29, 19);
StringExpandPlaceholders(gStringVar4, gTradeText_SentOverPoke);
- sub_8003460(&gUnknown_03004828->window, gStringVar4, gUnknown_03004828->textWindowBaseTileNum, 2, 15);
+ Text_InitWindowAndPrintText(&gUnknown_03004828->window, gStringVar4, gUnknown_03004828->textWindowBaseTileNum, 2, 15);
gUnknown_03004828->unk_00c4 ++;
gUnknown_03004828->unk_00c0 = 0;
break;
@@ -5215,7 +5215,7 @@ static bool8 sub_804C29C(void)
gUnknown_03004828->unk_00c4 ++;
ZeroFillWindowRect(&gUnknown_03004828->window, 0, 0, 29, 19);
StringExpandPlaceholders(gStringVar4, gTradeText_TakeGoodCare);
- sub_8003460(&gUnknown_03004828->window, gStringVar4, gUnknown_03004828->textWindowBaseTileNum, 2, 15);
+ Text_InitWindowAndPrintText(&gUnknown_03004828->window, gStringVar4, gUnknown_03004828->textWindowBaseTileNum, 2, 15);
gUnknown_03004828->unk_00c0 = 0;
}
break;
@@ -5538,7 +5538,7 @@ static void sub_804DC88(void)
gMain.state ++;
ZeroFillWindowRect(&gUnknown_03004828->window, 0, 0, 29, 19);
StringExpandPlaceholders(gStringVar4, gOtherText_LinkStandby2);
- sub_8003460(&gUnknown_03004828->window, gStringVar4, gUnknown_03004828->textWindowBaseTileNum, 2, 15);
+ Text_InitWindowAndPrintText(&gUnknown_03004828->window, gStringVar4, gUnknown_03004828->textWindowBaseTileNum, 2, 15);
break;
case 1:
sub_80084A4();
@@ -5565,7 +5565,7 @@ static void sub_804DC88(void)
case 2:
gMain.state = 50;
ZeroFillWindowRect(&gUnknown_03004828->window, 0, 0, 29, 19);
- sub_8003460(&gUnknown_03004828->window, gSystemText_Saving, gUnknown_03004828->textWindowBaseTileNum, 2, 15);
+ Text_InitWindowAndPrintText(&gUnknown_03004828->window, gSystemText_Saving, gUnknown_03004828->textWindowBaseTileNum, 2, 15);
break;
case 50:
SetSecretBase2Field_9_AndHideBG();
diff --git a/src/engine/trainer_card.c b/src/engine/trainer_card.c
index ffa4cbd08..da9dd7179 100644
--- a/src/engine/trainer_card.c
+++ b/src/engine/trainer_card.c
@@ -700,7 +700,7 @@ static void sub_80939DC(u8 taskId)
task->data[TD_0] ^= TRUE;
}
TrainerCard_Front_PrintPlayTime(buffer, task->data[TD_0]);
- MenuPrint(buffer, 10, 12);
+ Menu_PrintText(buffer, 10, 12);
}
static void sub_8093A28(void)
@@ -1130,7 +1130,7 @@ static void sub_8093DAC(void)
static void sub_8093DC8(void)
{
- MenuZeroFillScreen();
+ Menu_EraseScreen();
sub_80940E4();
sub_8093F14();
sub_8093F80();
@@ -1141,7 +1141,7 @@ static void sub_8093DC8(void)
static void sub_8093DEC(void)
{
- MenuZeroFillScreen();
+ Menu_EraseScreen();
sub_80940E4();
sub_8093F48();
sub_8094188();
@@ -1322,7 +1322,7 @@ static void sub_8094140(void)
buffer = gStringVar1;
StringCopy(buffer, ewram0_2.var_64.playerName);
ConvertInternationalString(buffer, ewram0_2.language);
- MenuPrint(buffer, 7, 5);
+ Menu_PrintText(buffer, 7, 5);
TrainerCard_Front_PrintTrainerID();
TrainerCard_Front_PrintMoney();
@@ -1355,7 +1355,7 @@ static void TrainerCard_Front_PrintTrainerID(void)
u8 buffer[8];
ConvertIntToDecimalStringN(buffer, ewram0_2.var_64.trainerId, STR_CONV_MODE_LEADING_ZEROS, 5);
- MenuPrint(buffer, 20, 2);
+ Menu_PrintText(buffer, 20, 2);
}
static void TrainerCard_Front_PrintMoney(void)
@@ -1406,14 +1406,14 @@ static void sub_809429C(void)
str[0] = 00;
str++;
str = StringCopy(str, ewram0_2.var_20[1]);
- MenuPrint(gStringVar1, 2, 14);
+ Menu_PrintText(gStringVar1, 2, 14);
str = gStringVar1;
str = StringCopy(str, ewram0_2.var_20[2]);
str[0] = 00;
str++;
str = StringCopy(str, ewram0_2.var_20[3]);
- MenuPrint(gStringVar1, 2, 16);
+ Menu_PrintText(gStringVar1, 2, 16);
}
}
@@ -1437,7 +1437,7 @@ static void TrainerCard_Back_PrintName(void)
static void TrainerCard_Back_PrintHallOfFameTime_Label(void)
{
if (ewram0_2.var_8 != 0)
- MenuPrint(gOtherText_FirstHOF, 3, 5);
+ Menu_PrintText(gOtherText_FirstHOF, 3, 5);
}
static void TrainerCard_Back_PrintHallOfFameTime(void)
@@ -1459,7 +1459,7 @@ static void TrainerCard_Back_PrintHallOfFameTime(void)
static void TrainerCard_Back_PrintLinkBattlesLabel(void)
{
if (ewram0_2.var_9 != 0)
- MenuPrint(gOtherText_LinkCableBattles, 3, 7);
+ Menu_PrintText(gOtherText_LinkCableBattles, 3, 7);
}
static void TrainerCard_Back_PrintLinkBattles(void)
@@ -1479,7 +1479,7 @@ static void TrainerCard_Back_PrintLinkBattles(void)
static void TrainerCard_Back_PrintBattleTower_Label(void)
{
if (ewram0_2.var_a != 0)
- MenuPrint(gOtherText_BattleTowerWinRecord, 3, 15);
+ Menu_PrintText(gOtherText_BattleTowerWinRecord, 3, 15);
}
static void TrainerCard_Back_PrintBattleTower(void)
@@ -1499,7 +1499,7 @@ static void TrainerCard_Back_PrintBattleTower(void)
static void TrainerCard_Back_PrintLinkContests_Label(void)
{
if (ewram0_2.var_b != 0)
- MenuPrint(gOtherText_ContestRecord, 3, 13);
+ Menu_PrintText(gOtherText_ContestRecord, 3, 13);
}
static void TrainerCard_Back_PrintLinkContests(void)
@@ -1516,7 +1516,7 @@ static void TrainerCard_Back_PrintLinkContests(void)
static void TrainerCard_Back_PrintLinkPokeblocks_Label(void)
{
if (ewram0_2.var_c != 0)
- MenuPrint(gOtherText_MixingRecord, 3, 11);
+ Menu_PrintText(gOtherText_MixingRecord, 3, 11);
}
static void TrainerCard_Back_PrintLinkPokeblocks(void)
@@ -1533,7 +1533,7 @@ static void TrainerCard_Back_PrintLinkPokeblocks(void)
static void TrainerCard_Back_PrintPokemonTrades_Label(void)
{
if (ewram0_2.var_d != 0)
- MenuPrint(gOtherText_TradeRecord, 3, 9);
+ Menu_PrintText(gOtherText_TradeRecord, 3, 9);
}
static void TrainerCard_Back_PrintPokemonTrades(void)
@@ -1553,5 +1553,5 @@ void unref_sub_8094588(u16 left, u16 top)
if (gSaveBlock2.playerGender == FEMALE)
text = gOtherText_Girl;
- MenuPrint(text, left, top);
+ Menu_PrintText(text, left, top);
}