Options menu: cleanup

This commit is contained in:
Martin Griffin 2022-08-21 15:10:18 +01:00
parent 2aa821176b
commit f4a2040843

View File

@ -16,7 +16,6 @@
#include "gba/m4a_internal.h"
#include "constants/rgb.h"
// Task data
#define tMenuSelection data[0]
#define tTextSpeed data[1]
#define tBattleSceneOff data[2]
@ -25,7 +24,6 @@
#define tButtonMode data[5]
#define tWindowFrameType data[6]
// Menu items
enum
{
MENUITEM_TEXTSPEED,
@ -38,7 +36,6 @@ enum
MENUITEM_COUNT,
};
// Window Ids
enum
{
WIN_HEADER,
@ -52,23 +49,22 @@ enum
#define YPOS_BUTTONMODE (MENUITEM_BUTTONMODE * 16)
#define YPOS_FRAMETYPE (MENUITEM_FRAMETYPE * 16)
// this file's functions
static void Task_OptionMenuFadeIn(u8 taskId);
static void Task_OptionMenuProcessInput(u8 taskId);
static void Task_OptionMenuSave(u8 taskId);
static void Task_OptionMenuFadeOut(u8 taskId);
static void HighlightOptionMenuItem(u8 selection);
static u8 TextSpeed_ProcessInput(u8 selection);
static u8 TextSpeed_ProcessInput(u8 selection);
static void TextSpeed_DrawChoices(u8 selection);
static u8 BattleScene_ProcessInput(u8 selection);
static u8 BattleScene_ProcessInput(u8 selection);
static void BattleScene_DrawChoices(u8 selection);
static u8 BattleStyle_ProcessInput(u8 selection);
static u8 BattleStyle_ProcessInput(u8 selection);
static void BattleStyle_DrawChoices(u8 selection);
static u8 Sound_ProcessInput(u8 selection);
static u8 Sound_ProcessInput(u8 selection);
static void Sound_DrawChoices(u8 selection);
static u8 FrameType_ProcessInput(u8 selection);
static u8 FrameType_ProcessInput(u8 selection);
static void FrameType_DrawChoices(u8 selection);
static u8 ButtonMode_ProcessInput(u8 selection);
static u8 ButtonMode_ProcessInput(u8 selection);
static void ButtonMode_DrawChoices(u8 selection);
static void DrawHeaderText(void);
static void DrawOptionMenuTexts(void);
@ -116,29 +112,28 @@ static const struct WindowTemplate sOptionMenuWinTemplates[] =
static const struct BgTemplate sOptionMenuBgTemplates[] =
{
{
.bg = 1,
.charBaseIndex = 1,
.mapBaseIndex = 30,
.screenSize = 0,
.paletteMode = 0,
.priority = 0,
.baseTile = 0
},
{
.bg = 0,
.charBaseIndex = 1,
.mapBaseIndex = 31,
.screenSize = 0,
.paletteMode = 0,
.priority = 1,
.baseTile = 0
}
{
.bg = 1,
.charBaseIndex = 1,
.mapBaseIndex = 30,
.screenSize = 0,
.paletteMode = 0,
.priority = 0,
.baseTile = 0
},
{
.bg = 0,
.charBaseIndex = 1,
.mapBaseIndex = 31,
.screenSize = 0,
.paletteMode = 0,
.priority = 1,
.baseTile = 0
}
};
static const u16 sOptionMenuBg_Pal[] = {RGB(17, 18, 31)};
// code
static void MainCB2(void)
{
RunTasks();
@ -213,7 +208,7 @@ void CB2_InitOptionMenu(void)
gMain.state++;
break;
case 6:
PutWindowTilemap(0);
PutWindowTilemap(WIN_HEADER);
DrawHeaderText();
gMain.state++;
break;
@ -221,7 +216,7 @@ void CB2_InitOptionMenu(void)
gMain.state++;
break;
case 8:
PutWindowTilemap(1);
PutWindowTilemap(WIN_OPTIONS);
DrawOptionMenuTexts();
gMain.state++;
case 9:
@ -253,7 +248,7 @@ void CB2_InitOptionMenu(void)
break;
}
case 11:
BeginNormalPaletteFade(PALETTES_ALL, 0, 0x10, 0, RGB_BLACK);
BeginNormalPaletteFade(PALETTES_ALL, 0, 16, 0, RGB_BLACK);
SetVBlankCallback(VBlankCB);
SetMainCallback2(MainCB2);
return;
@ -362,7 +357,7 @@ static void Task_OptionMenuSave(u8 taskId)
gSaveBlock2Ptr->optionsButtonMode = gTasks[taskId].tButtonMode;
gSaveBlock2Ptr->optionsWindowFrameType = gTasks[taskId].tWindowFrameType;
BeginNormalPaletteFade(PALETTES_ALL, 0, 0, 0x10, RGB_BLACK);
BeginNormalPaletteFade(PALETTES_ALL, 0, 0, 16, RGB_BLACK);
gTasks[taskId].func = Task_OptionMenuFadeOut;
}
@ -387,13 +382,13 @@ static void DrawOptionMenuChoice(const u8 *text, u8 x, u8 y, u8 style)
u8 dst[16];
u16 i;
for (i = 0; *text != EOS && i <= 14; i++)
for (i = 0; *text != EOS && i < ARRAY_COUNT(dst) - 1; i++)
dst[i] = *(text++);
if (style != 0)
{
dst[2] = 4;
dst[5] = 5;
dst[2] = TEXT_COLOR_RED;
dst[5] = TEXT_COLOR_LIGHT_RED;
}
dst[i] = EOS;
@ -564,7 +559,7 @@ static void FrameType_DrawChoices(u8 selection)
{
text[i] = n % 10 + CHAR_0;
i++;
text[i] = 0x77;
text[i] = CHAR_SPACER;
i++;
}