Macroize main_menu and general cleanup

This commit is contained in:
Diegoisawesome 2018-09-07 19:24:33 -05:00
parent ef62393289
commit d945a8bf2f
4 changed files with 134 additions and 105 deletions

View File

@ -574,8 +574,6 @@
#define WINOUT_WINOBJ_OBJ (1 << 12) #define WINOUT_WINOBJ_OBJ (1 << 12)
#define WINOUT_WINOBJ_CLR (1 << 13) #define WINOUT_WINOBJ_CLR (1 << 13)
#define WINHV_COORDS(m, n) (((m) << 8) | (n))
// BLDCNT // BLDCNT
// Bits 0-5 select layers for the 1st target // Bits 0-5 select layers for the 1st target
#define BLDCNT_TGT1_BG0 (1 << 0) #define BLDCNT_TGT1_BG0 (1 << 0)

View File

@ -6024,7 +6024,7 @@ static void HblankCb_BattleDome(void)
if (vCount < 50) if (vCount < 50)
{ {
REG_WININ = WININ_WIN0_BG0 | WININ_WIN0_BG1 | WININ_WIN0_BG3 | WININ_WIN0_OBJ | WININ_WIN0_CLR | WININ_WIN1_BG0 | WININ_WIN1_BG1 | WININ_WIN1_BG3 | WININ_WIN1_OBJ | WININ_WIN1_CLR; REG_WININ = WININ_WIN0_BG0 | WININ_WIN0_BG1 | WININ_WIN0_BG3 | WININ_WIN0_OBJ | WININ_WIN0_CLR | WININ_WIN1_BG0 | WININ_WIN1_BG1 | WININ_WIN1_BG3 | WININ_WIN1_OBJ | WININ_WIN1_CLR;
SET_WIN0H_WIN1H(WINHV_COORDS(152, 155), WINHV_COORDS(85, 88)); SET_WIN0H_WIN1H(WIN_RANGE(152, 155), WIN_RANGE(85, 88));
return; return;
} }
else if (vCount > 57) else if (vCount > 57)
@ -6032,13 +6032,13 @@ static void HblankCb_BattleDome(void)
if (vCount < 75) if (vCount < 75)
{ {
REG_WININ = WININ_WIN0_BG0 | WININ_WIN0_BG1 | WININ_WIN0_BG3 | WININ_WIN0_OBJ | WININ_WIN0_CLR | WININ_WIN1_BG0 | WININ_WIN1_BG1 | WININ_WIN1_BG3 | WININ_WIN1_OBJ | WININ_WIN1_CLR; REG_WININ = WININ_WIN0_BG0 | WININ_WIN0_BG1 | WININ_WIN0_BG3 | WININ_WIN0_OBJ | WININ_WIN0_CLR | WININ_WIN1_BG0 | WININ_WIN1_BG1 | WININ_WIN1_BG3 | WININ_WIN1_OBJ | WININ_WIN1_CLR;
SET_WIN0H_WIN1H(WINHV_COORDS(144, 152), WINHV_COORDS(88, 96)); SET_WIN0H_WIN1H(WIN_RANGE(144, 152), WIN_RANGE(88, 96));
return; return;
} }
else if (vCount < 82) else if (vCount < 82)
{ {
REG_WININ = WININ_WIN0_BG0 | WININ_WIN0_BG1 | WININ_WIN0_BG3 | WININ_WIN0_OBJ | WININ_WIN0_CLR | WININ_WIN1_BG0 | WININ_WIN1_BG1 | WININ_WIN1_BG3 | WININ_WIN1_OBJ | WININ_WIN1_CLR; REG_WININ = WININ_WIN0_BG0 | WININ_WIN0_BG1 | WININ_WIN0_BG3 | WININ_WIN0_OBJ | WININ_WIN0_CLR | WININ_WIN1_BG0 | WININ_WIN1_BG1 | WININ_WIN1_BG3 | WININ_WIN1_OBJ | WININ_WIN1_CLR;
SET_WIN0H_WIN1H(WINHV_COORDS(152, 155), WINHV_COORDS(85, 88)); SET_WIN0H_WIN1H(WIN_RANGE(152, 155), WIN_RANGE(85, 88));
return; return;
} }
else if (vCount > 94) else if (vCount > 94)
@ -6046,13 +6046,13 @@ static void HblankCb_BattleDome(void)
if (vCount < 103) if (vCount < 103)
{ {
REG_WININ = WININ_WIN0_BG0 | WININ_WIN0_BG1 | WININ_WIN0_BG2 | WININ_WIN0_OBJ | WININ_WIN0_CLR | WININ_WIN1_BG0 | WININ_WIN1_BG1 | WININ_WIN1_BG2 | WININ_WIN1_OBJ | WININ_WIN1_CLR; REG_WININ = WININ_WIN0_BG0 | WININ_WIN0_BG1 | WININ_WIN0_BG2 | WININ_WIN0_OBJ | WININ_WIN0_CLR | WININ_WIN1_BG0 | WININ_WIN1_BG1 | WININ_WIN1_BG2 | WININ_WIN1_OBJ | WININ_WIN1_CLR;
SET_WIN0H_WIN1H(WINHV_COORDS(152, 155), WINHV_COORDS(85, 88)); SET_WIN0H_WIN1H(WIN_RANGE(152, 155), WIN_RANGE(85, 88));
return; return;
} }
else if (vCount < 119) else if (vCount < 119)
{ {
REG_WININ = WININ_WIN0_BG0 | WININ_WIN0_BG1 | WININ_WIN0_BG2 | WININ_WIN0_OBJ | WININ_WIN0_CLR | WININ_WIN1_BG0 | WININ_WIN1_BG1 | WININ_WIN1_BG2 | WININ_WIN1_OBJ | WININ_WIN1_CLR; REG_WININ = WININ_WIN0_BG0 | WININ_WIN0_BG1 | WININ_WIN0_BG2 | WININ_WIN0_OBJ | WININ_WIN0_CLR | WININ_WIN1_BG0 | WININ_WIN1_BG1 | WININ_WIN1_BG2 | WININ_WIN1_OBJ | WININ_WIN1_CLR;
SET_WIN0H_WIN1H(WINHV_COORDS(144, 152), WINHV_COORDS(88, 96)); SET_WIN0H_WIN1H(WIN_RANGE(144, 152), WIN_RANGE(88, 96));
return; return;
} }
else if (vCount > 126) else if (vCount > 126)
@ -6060,7 +6060,7 @@ static void HblankCb_BattleDome(void)
if (vCount_ < 135) if (vCount_ < 135)
{ {
REG_WININ = WININ_WIN0_BG0 | WININ_WIN0_BG1 | WININ_WIN0_BG2 | WININ_WIN0_OBJ | WININ_WIN0_CLR | WININ_WIN1_BG0 | WININ_WIN1_BG1 | WININ_WIN1_BG2 | WININ_WIN1_OBJ | WININ_WIN1_CLR; REG_WININ = WININ_WIN0_BG0 | WININ_WIN0_BG1 | WININ_WIN0_BG2 | WININ_WIN0_OBJ | WININ_WIN0_CLR | WININ_WIN1_BG0 | WININ_WIN1_BG1 | WININ_WIN1_BG2 | WININ_WIN1_OBJ | WININ_WIN1_CLR;
SET_WIN0H_WIN1H(WINHV_COORDS(152, 155), WINHV_COORDS(85, 88)); SET_WIN0H_WIN1H(WIN_RANGE(152, 155), WIN_RANGE(85, 88));
return; return;
} }
} }

View File

@ -131,85 +131,115 @@ const u8 gUnknown_082FEEF0[] = INCBIN_U8("graphics/birch_speech/map.bin.lz");
const u16 gUnknown_082FF018[] = INCBIN_U16("graphics/birch_speech/bg2.gbapal"); const u16 gUnknown_082FF018[] = INCBIN_U16("graphics/birch_speech/bg2.gbapal");
const u16 gUnknown_082FF028[] = {0, 0, 0, 0, 0, 0, 0, 0}; const u16 gUnknown_082FF028[] = {0, 0, 0, 0, 0, 0, 0, 0};
const struct WindowTemplate sWindowTemplates_NoSavedGame[] = #define MENU_LEFT 2
#define MENU_TOP_WIN0 1
#define MENU_TOP_WIN1 5
#define MENU_TOP_WIN2 1
#define MENU_TOP_WIN3 9
#define MENU_TOP_WIN4 13
#define MENU_TOP_WIN5 17
#define MENU_TOP_WIN6 21
#define MENU_WIDTH 26
#define MENU_HEIGHT_WIN0 2
#define MENU_HEIGHT_WIN1 2
#define MENU_HEIGHT_WIN2 6
#define MENU_HEIGHT_WIN3 2
#define MENU_HEIGHT_WIN4 2
#define MENU_HEIGHT_WIN5 2
#define MENU_HEIGHT_WIN6 2
#define MENU_LEFT_ERROR 2
#define MENU_TOP_ERROR 15
#define MENU_WIDTH_ERROR 26
#define MENU_HEIGHT_ERROR 4
#define MENU_SHADOW_PADDING 1
#define MENU_WIN_HCOORDS WIN_RANGE(((MENU_LEFT - 1) * 8) + MENU_SHADOW_PADDING, (MENU_LEFT + MENU_WIDTH + 1) * 8 - MENU_SHADOW_PADDING)
#define MENU_WIN_VCOORDS(n) WIN_RANGE(((MENU_TOP_WIN##n - 1) * 8) + MENU_SHADOW_PADDING, (MENU_TOP_WIN##n + MENU_HEIGHT_WIN##n + 1) * 8 - MENU_SHADOW_PADDING)
#define MENU_SCROLL_SHIFT WIN_RANGE(32, 32)
const struct WindowTemplate sWindowTemplates_MainMenu[] =
{ {
// No saved game
// NEW GAME
{ {
.priority = 0, .priority = 0,
.tilemapLeft = 2, .tilemapLeft = MENU_LEFT,
.tilemapTop = 1, .tilemapTop = MENU_TOP_WIN0,
.width = 26, .width = MENU_WIDTH,
.height = 2, .height = MENU_HEIGHT_WIN0,
.paletteNum = 15, .paletteNum = 15,
.baseBlock = 1 .baseBlock = 1
}, },
// OPTIONS
{ {
.priority = 0, .priority = 0,
.tilemapLeft = 2, .tilemapLeft = MENU_LEFT,
.tilemapTop = 5, .tilemapTop = MENU_TOP_WIN1,
.width = 26, .width = MENU_WIDTH,
.height = 2, .height = MENU_HEIGHT_WIN1,
.paletteNum = 15, .paletteNum = 15,
.baseBlock = 0x35 .baseBlock = 0x35
} },
}; // Has saved game
// CONTINUE
const struct WindowTemplate sWindowTemplates_HasSavedGame[] =
{
{ {
.priority = 0, .priority = 0,
.tilemapLeft = 2, .tilemapLeft = MENU_LEFT,
.tilemapTop = 1, .tilemapTop = MENU_TOP_WIN2,
.width = 26, .width = MENU_WIDTH,
.height = 6, .height = MENU_HEIGHT_WIN2,
.paletteNum = 15, .paletteNum = 15,
.baseBlock = 1 .baseBlock = 1
}, },
// NEW GAME
{ {
.priority = 0, .priority = 0,
.tilemapLeft = 2, .tilemapLeft = MENU_LEFT,
.tilemapTop = 9, .tilemapTop = MENU_TOP_WIN3,
.width = 26, .width = MENU_WIDTH,
.height = 2, .height = MENU_HEIGHT_WIN3,
.paletteNum = 15, .paletteNum = 15,
.baseBlock = 0x9D .baseBlock = 0x9D
}, },
// OPTION / MYSTERY GIFT
{ {
.priority = 0, .priority = 0,
.tilemapLeft = 2, .tilemapLeft = MENU_LEFT,
.tilemapTop = 13, .tilemapTop = MENU_TOP_WIN4,
.width = 26, .width = MENU_WIDTH,
.height = 2, .height = MENU_HEIGHT_WIN4,
.paletteNum = 15, .paletteNum = 15,
.baseBlock = 0xD1 .baseBlock = 0xD1
}, },
// OPTION / MYSTERY EVENTS
{ {
.priority = 0, .priority = 0,
.tilemapLeft = 2, .tilemapLeft = MENU_LEFT,
.tilemapTop = 17, .tilemapTop = MENU_TOP_WIN5,
.width = 26, .width = MENU_WIDTH,
.height = 2, .height = MENU_HEIGHT_WIN5,
.paletteNum = 15, .paletteNum = 15,
.baseBlock = 0x105 .baseBlock = 0x105
}, },
// OPTION
{ {
.priority = 0, .priority = 0,
.tilemapLeft = 2, .tilemapLeft = MENU_LEFT,
.tilemapTop = 21, .tilemapTop = MENU_TOP_WIN6,
.width = 26, .width = MENU_WIDTH,
.height = 2, .height = MENU_HEIGHT_WIN6,
.paletteNum = 15, .paletteNum = 15,
.baseBlock = 0x139 .baseBlock = 0x139
} },
}; // Error message window
const struct WindowTemplate sWindowTemplate_ErrorWindow[] =
{
{ {
.priority = 0, .priority = 0,
.tilemapLeft = 2, .tilemapLeft = MENU_LEFT_ERROR,
.tilemapTop = 15, .tilemapTop = MENU_TOP_ERROR,
.width = 26, .width = MENU_WIDTH_ERROR,
.height = 4, .height = MENU_HEIGHT_ERROR,
.paletteNum = 15, .paletteNum = 15,
.baseBlock = 0x16D .baseBlock = 0x16D
}, },
@ -351,14 +381,14 @@ enum
{ {
HAS_NO_SAVED_GAME, //NEW GAME, OPTION HAS_NO_SAVED_GAME, //NEW GAME, OPTION
HAS_SAVED_GAME, //CONTINUE, NEW GAME, OPTION HAS_SAVED_GAME, //CONTINUE, NEW GAME, OPTION
HAS_MYSTERY_GIFT, //CONTINUE, NEW GAME, MYSTERY EVENTS, OPTION HAS_MYSTERY_GIFT, //CONTINUE, NEW GAME, MYSTERY GIFT, OPTION
HAS_MYSTERY_EVENTS, HAS_MYSTERY_EVENTS, //CONTINUE, NEW GAME, MYSTERY GIFT, MYSTERY EVENTS, OPTION
}; };
enum { enum {
ACTION_NEW_GAME, ACTION_NEW_GAME,
ACTION_CONTINUE, ACTION_CONTINUE,
ACTION_OPTIONS, ACTION_OPTION,
ACTION_MYSTERY_GIFT, ACTION_MYSTERY_GIFT,
ACTION_MYSTERY_EVENTS, ACTION_MYSTERY_EVENTS,
ACTION_UNKNOWN, // TODO: change when rom_8011DC0 decompiled ACTION_UNKNOWN, // TODO: change when rom_8011DC0 decompiled
@ -423,12 +453,12 @@ u32 InitMainMenu(bool8 returningFromOptionsMenu)
else else
BeginNormalPaletteFade(0xFFFFFFFF, 0, 0x10, 0, 0xFFFF); // fade to white BeginNormalPaletteFade(0xFFFFFFFF, 0, 0x10, 0, 0xFFFF); // fade to white
ResetBgsAndClearDma3BusyFlags(0); ResetBgsAndClearDma3BusyFlags(0);
InitBgsFromTemplates(0, gUnknown_082FF0E8, 2); InitBgsFromTemplates(0, gUnknown_082FF0E8, ARRAY_COUNT(gUnknown_082FF0E8));
ChangeBgX(0, 0, 0); ChangeBgX(0, 0, 0);
ChangeBgY(0, 0, 0); ChangeBgY(0, 0, 0);
ChangeBgX(1, 0, 0); ChangeBgX(1, 0, 0);
ChangeBgY(1, 0, 0); ChangeBgY(1, 0, 0);
InitWindows(sWindowTemplates_NoSavedGame); InitWindows(sWindowTemplates_MainMenu);
DeactivateAllTextPrinters(); DeactivateAllTextPrinters();
LoadMainMenuWindowFrameTiles(0, MAIN_MENU_BORDER_TILE); LoadMainMenuWindowFrameTiles(0, MAIN_MENU_BORDER_TILE);
@ -535,7 +565,7 @@ void Task_WaitForSaveFileErrorWindow(u8 taskId)
if (!IsTextPrinterActive(7) && (gMain.newKeys & A_BUTTON)) if (!IsTextPrinterActive(7) && (gMain.newKeys & A_BUTTON))
{ {
ClearWindowTilemap(7); ClearWindowTilemap(7);
ClearMainMenuWindowTilemap(sWindowTemplate_ErrorWindow); ClearMainMenuWindowTilemap(&sWindowTemplates_MainMenu[7]);
gTasks[taskId].func = Task_MainMenuCheckBattery; gTasks[taskId].func = Task_MainMenuCheckBattery;
} }
} }
@ -570,7 +600,7 @@ void Task_WaitForBatteryDryErrorWindow(u8 taskId)
if (!IsTextPrinterActive(7) && (gMain.newKeys & A_BUTTON)) if (!IsTextPrinterActive(7) && (gMain.newKeys & A_BUTTON))
{ {
ClearWindowTilemap(7); ClearWindowTilemap(7);
ClearMainMenuWindowTilemap(sWindowTemplate_ErrorWindow); ClearMainMenuWindowTilemap(&sWindowTemplates_MainMenu[7]);
gTasks[taskId].func = Task_DisplayMainMenu; gTasks[taskId].func = Task_DisplayMainMenu;
} }
} }
@ -625,8 +655,8 @@ void Task_DisplayMainMenu(u8 taskId)
PutWindowTilemap(1); PutWindowTilemap(1);
CopyWindowToVram(0, 2); CopyWindowToVram(0, 2);
CopyWindowToVram(1, 2); CopyWindowToVram(1, 2);
DrawMainMenuWindowBorder(&sWindowTemplates_NoSavedGame[0], MAIN_MENU_BORDER_TILE); DrawMainMenuWindowBorder(&sWindowTemplates_MainMenu[0], MAIN_MENU_BORDER_TILE);
DrawMainMenuWindowBorder(&sWindowTemplates_NoSavedGame[1], MAIN_MENU_BORDER_TILE); DrawMainMenuWindowBorder(&sWindowTemplates_MainMenu[1], MAIN_MENU_BORDER_TILE);
break; break;
case HAS_SAVED_GAME: case HAS_SAVED_GAME:
FillWindowPixelBuffer(2, 0xAA); FillWindowPixelBuffer(2, 0xAA);
@ -642,9 +672,9 @@ void Task_DisplayMainMenu(u8 taskId)
CopyWindowToVram(2, 2); CopyWindowToVram(2, 2);
CopyWindowToVram(3, 2); CopyWindowToVram(3, 2);
CopyWindowToVram(4, 2); CopyWindowToVram(4, 2);
DrawMainMenuWindowBorder(&sWindowTemplates_HasSavedGame[0], MAIN_MENU_BORDER_TILE); DrawMainMenuWindowBorder(&sWindowTemplates_MainMenu[2], MAIN_MENU_BORDER_TILE);
DrawMainMenuWindowBorder(&sWindowTemplates_HasSavedGame[1], MAIN_MENU_BORDER_TILE); DrawMainMenuWindowBorder(&sWindowTemplates_MainMenu[3], MAIN_MENU_BORDER_TILE);
DrawMainMenuWindowBorder(&sWindowTemplates_HasSavedGame[2], MAIN_MENU_BORDER_TILE); DrawMainMenuWindowBorder(&sWindowTemplates_MainMenu[4], MAIN_MENU_BORDER_TILE);
break; break;
case HAS_MYSTERY_GIFT: case HAS_MYSTERY_GIFT:
FillWindowPixelBuffer(2, 0xAA); FillWindowPixelBuffer(2, 0xAA);
@ -664,10 +694,10 @@ void Task_DisplayMainMenu(u8 taskId)
CopyWindowToVram(3, 2); CopyWindowToVram(3, 2);
CopyWindowToVram(4, 2); CopyWindowToVram(4, 2);
CopyWindowToVram(5, 2); CopyWindowToVram(5, 2);
DrawMainMenuWindowBorder(sWindowTemplates_HasSavedGame, MAIN_MENU_BORDER_TILE); DrawMainMenuWindowBorder(&sWindowTemplates_MainMenu[2], MAIN_MENU_BORDER_TILE);
DrawMainMenuWindowBorder(&sWindowTemplates_HasSavedGame[1], MAIN_MENU_BORDER_TILE); DrawMainMenuWindowBorder(&sWindowTemplates_MainMenu[3], MAIN_MENU_BORDER_TILE);
DrawMainMenuWindowBorder(&sWindowTemplates_HasSavedGame[2], MAIN_MENU_BORDER_TILE); DrawMainMenuWindowBorder(&sWindowTemplates_MainMenu[4], MAIN_MENU_BORDER_TILE);
DrawMainMenuWindowBorder(&sWindowTemplates_HasSavedGame[3], MAIN_MENU_BORDER_TILE); DrawMainMenuWindowBorder(&sWindowTemplates_MainMenu[5], MAIN_MENU_BORDER_TILE);
break; break;
case HAS_MYSTERY_EVENTS: case HAS_MYSTERY_EVENTS:
FillWindowPixelBuffer(2, 0xAA); FillWindowPixelBuffer(2, 0xAA);
@ -691,11 +721,11 @@ void Task_DisplayMainMenu(u8 taskId)
CopyWindowToVram(4, 2); CopyWindowToVram(4, 2);
CopyWindowToVram(5, 2); CopyWindowToVram(5, 2);
CopyWindowToVram(6, 2); CopyWindowToVram(6, 2);
DrawMainMenuWindowBorder(&sWindowTemplates_HasSavedGame[0], MAIN_MENU_BORDER_TILE); DrawMainMenuWindowBorder(&sWindowTemplates_MainMenu[2], MAIN_MENU_BORDER_TILE);
DrawMainMenuWindowBorder(&sWindowTemplates_HasSavedGame[1], MAIN_MENU_BORDER_TILE); DrawMainMenuWindowBorder(&sWindowTemplates_MainMenu[3], MAIN_MENU_BORDER_TILE);
DrawMainMenuWindowBorder(&sWindowTemplates_HasSavedGame[2], MAIN_MENU_BORDER_TILE); DrawMainMenuWindowBorder(&sWindowTemplates_MainMenu[4], MAIN_MENU_BORDER_TILE);
DrawMainMenuWindowBorder(&sWindowTemplates_HasSavedGame[3], MAIN_MENU_BORDER_TILE); DrawMainMenuWindowBorder(&sWindowTemplates_MainMenu[5], MAIN_MENU_BORDER_TILE);
DrawMainMenuWindowBorder(&sWindowTemplates_HasSavedGame[4], MAIN_MENU_BORDER_TILE); DrawMainMenuWindowBorder(&sWindowTemplates_MainMenu[6], MAIN_MENU_BORDER_TILE);
tScrollArrowTaskId = AddScrollIndicatorArrowPair(&sScrollArrowsTemplate_MainMenu, &sCurrItemAndOptionMenuCheck); tScrollArrowTaskId = AddScrollIndicatorArrowPair(&sScrollArrowsTemplate_MainMenu, &sCurrItemAndOptionMenuCheck);
gTasks[tScrollArrowTaskId].func = Task_ScrollIndicatorArrowPairOnMainMenu; gTasks[tScrollArrowTaskId].func = Task_ScrollIndicatorArrowPairOnMainMenu;
if (sCurrItemAndOptionMenuCheck == 4) if (sCurrItemAndOptionMenuCheck == 4)
@ -732,8 +762,8 @@ bool8 HandleMainMenuInput(u8 taskId)
{ {
PlaySE(SE_SELECT); PlaySE(SE_SELECT);
BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, RGB_WHITEALPHA); BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, RGB_WHITEALPHA);
SetGpuReg(REG_OFFSET_WIN0H, 0xF0); SetGpuReg(REG_OFFSET_WIN0H, WIN_RANGE(0, 240));
SetGpuReg(REG_OFFSET_WIN0V, 0xA0); SetGpuReg(REG_OFFSET_WIN0V, WIN_RANGE(0, 160));
gTasks[taskId].func = Task_HandleMainMenuBPressed; gTasks[taskId].func = Task_HandleMainMenuBPressed;
} }
else if ((gMain.newKeys & DPAD_UP) && tCurrItem > 0) else if ((gMain.newKeys & DPAD_UP) && tCurrItem > 0)
@ -798,7 +828,7 @@ void Task_HandleMainMenuAPressed(u8 taskId)
action = ACTION_NEW_GAME; action = ACTION_NEW_GAME;
break; break;
case 1: case 1:
action = ACTION_OPTIONS; action = ACTION_OPTION;
break; break;
} }
break; break;
@ -813,7 +843,7 @@ void Task_HandleMainMenuAPressed(u8 taskId)
action = ACTION_NEW_GAME; action = ACTION_NEW_GAME;
break; break;
case 2: case 2:
action = ACTION_OPTIONS; action = ACTION_OPTION;
break; break;
} }
break; break;
@ -832,11 +862,11 @@ void Task_HandleMainMenuAPressed(u8 taskId)
if (!wirelessAdapterConnected) if (!wirelessAdapterConnected)
{ {
action = ACTION_INVALID; action = ACTION_INVALID;
gTasks[taskId].tMenuType = 0; gTasks[taskId].tMenuType = HAS_NO_SAVED_GAME;
} }
break; break;
case 3: case 3:
action = ACTION_OPTIONS; action = ACTION_OPTION;
break; break;
} }
break; break;
@ -857,13 +887,13 @@ void Task_HandleMainMenuAPressed(u8 taskId)
if (!wirelessAdapterConnected) if (!wirelessAdapterConnected)
{ {
action = ACTION_INVALID; action = ACTION_INVALID;
gTasks[taskId].tMenuType = 0; gTasks[taskId].tMenuType = HAS_NO_SAVED_GAME;
} }
} }
else if (wirelessAdapterConnected) else if (wirelessAdapterConnected)
{ {
action = ACTION_INVALID; action = ACTION_INVALID;
gTasks[taskId].tMenuType = 1; gTasks[taskId].tMenuType = HAS_SAVED_GAME;
} }
else else
{ {
@ -874,7 +904,7 @@ void Task_HandleMainMenuAPressed(u8 taskId)
if (wirelessAdapterConnected) if (wirelessAdapterConnected)
{ {
action = ACTION_INVALID; action = ACTION_INVALID;
gTasks[taskId].tMenuType = 2; gTasks[taskId].tMenuType = HAS_MYSTERY_GIFT;
} }
else else
{ {
@ -882,7 +912,7 @@ void Task_HandleMainMenuAPressed(u8 taskId)
} }
break; break;
case 4: case 4:
action = ACTION_OPTIONS; action = ACTION_OPTION;
break; break;
} }
break; break;
@ -903,7 +933,7 @@ void Task_HandleMainMenuAPressed(u8 taskId)
SetMainCallback2(CB2_ContinueSavedGame); SetMainCallback2(CB2_ContinueSavedGame);
DestroyTask(taskId); DestroyTask(taskId);
break; break;
case ACTION_OPTIONS: case ACTION_OPTION:
gMain.savedCallback = CB2_ReinitMainMenu; gMain.savedCallback = CB2_ReinitMainMenu;
SetMainCallback2(CB2_InitOptionMenu); SetMainCallback2(CB2_InitOptionMenu);
DestroyTask(taskId); DestroyTask(taskId);
@ -935,7 +965,7 @@ void Task_HandleMainMenuAPressed(u8 taskId)
return; return;
} }
FreeAllWindowBuffers(); FreeAllWindowBuffers();
if (action != ACTION_OPTIONS) if (action != ACTION_OPTION)
sCurrItemAndOptionMenuCheck = 0; sCurrItemAndOptionMenuCheck = 0;
else else
sCurrItemAndOptionMenuCheck |= 0x8000; // entering the options menu sCurrItemAndOptionMenuCheck |= 0x8000; // entering the options menu
@ -1005,7 +1035,7 @@ void Task_DisplayMainMenuInvalidActionError(u8 taskId)
void HighlightSelectedMainMenuItem(u8 menuType, u8 selectedMenuItem, s16 isScrolled) void HighlightSelectedMainMenuItem(u8 menuType, u8 selectedMenuItem, s16 isScrolled)
{ {
SetGpuReg(REG_OFFSET_WIN0H, WINHV_COORDS(9, 231)); SetGpuReg(REG_OFFSET_WIN0H, MENU_WIN_HCOORDS);
switch (menuType) switch (menuType)
{ {
@ -1015,10 +1045,10 @@ void HighlightSelectedMainMenuItem(u8 menuType, u8 selectedMenuItem, s16 isScrol
{ {
case 0: case 0:
default: default:
SetGpuReg(REG_OFFSET_WIN0V, WINHV_COORDS(1, 31)); SetGpuReg(REG_OFFSET_WIN0V, MENU_WIN_VCOORDS(0));
break; break;
case 1: case 1:
SetGpuReg(REG_OFFSET_WIN0V, WINHV_COORDS(33, 63)); SetGpuReg(REG_OFFSET_WIN0V, MENU_WIN_VCOORDS(1));
break; break;
} }
break; break;
@ -1027,13 +1057,13 @@ void HighlightSelectedMainMenuItem(u8 menuType, u8 selectedMenuItem, s16 isScrol
{ {
case 0: case 0:
default: default:
SetGpuReg(REG_OFFSET_WIN0V, WINHV_COORDS(1, 63)); SetGpuReg(REG_OFFSET_WIN0V, MENU_WIN_VCOORDS(2));
break; break;
case 1: case 1:
SetGpuReg(REG_OFFSET_WIN0V, WINHV_COORDS(65, 95)); SetGpuReg(REG_OFFSET_WIN0V, MENU_WIN_VCOORDS(3));
break; break;
case 2: case 2:
SetGpuReg(REG_OFFSET_WIN0V, WINHV_COORDS(97, 127)); SetGpuReg(REG_OFFSET_WIN0V, MENU_WIN_VCOORDS(4));
break; break;
} }
break; break;
@ -1042,16 +1072,16 @@ void HighlightSelectedMainMenuItem(u8 menuType, u8 selectedMenuItem, s16 isScrol
{ {
case 0: case 0:
default: default:
SetGpuReg(REG_OFFSET_WIN0V, WINHV_COORDS(1, 63)); SetGpuReg(REG_OFFSET_WIN0V, MENU_WIN_VCOORDS(2));
break; break;
case 1: case 1:
SetGpuReg(REG_OFFSET_WIN0V, WINHV_COORDS(65, 95)); SetGpuReg(REG_OFFSET_WIN0V, MENU_WIN_VCOORDS(3));
break; break;
case 2: case 2:
SetGpuReg(REG_OFFSET_WIN0V, WINHV_COORDS(97, 127)); SetGpuReg(REG_OFFSET_WIN0V, MENU_WIN_VCOORDS(4));
break; break;
case 3: case 3:
SetGpuReg(REG_OFFSET_WIN0V, WINHV_COORDS(129, 159)); SetGpuReg(REG_OFFSET_WIN0V, MENU_WIN_VCOORDS(5));
break; break;
} }
break; break;
@ -1060,28 +1090,28 @@ void HighlightSelectedMainMenuItem(u8 menuType, u8 selectedMenuItem, s16 isScrol
{ {
case 0: case 0:
default: default:
SetGpuReg(REG_OFFSET_WIN0V, WINHV_COORDS(1, 63)); SetGpuReg(REG_OFFSET_WIN0V, MENU_WIN_VCOORDS(2));
break; break;
case 1: case 1:
if (isScrolled) if (isScrolled)
SetGpuReg(REG_OFFSET_WIN0V, WINHV_COORDS(33, 63)); SetGpuReg(REG_OFFSET_WIN0V, MENU_WIN_VCOORDS(3) - MENU_SCROLL_SHIFT);
else else
SetGpuReg(REG_OFFSET_WIN0V, WINHV_COORDS(65, 95)); SetGpuReg(REG_OFFSET_WIN0V, MENU_WIN_VCOORDS(3));
break; break;
case 2: case 2:
if (isScrolled) if (isScrolled)
SetGpuReg(REG_OFFSET_WIN0V, WINHV_COORDS(65, 95)); SetGpuReg(REG_OFFSET_WIN0V, MENU_WIN_VCOORDS(4) - MENU_SCROLL_SHIFT);
else else
SetGpuReg(REG_OFFSET_WIN0V, WINHV_COORDS(97, 127)); SetGpuReg(REG_OFFSET_WIN0V, MENU_WIN_VCOORDS(4));
break; break;
case 3: case 3:
if (isScrolled) if (isScrolled)
SetGpuReg(REG_OFFSET_WIN0V, WINHV_COORDS(97, 127)); SetGpuReg(REG_OFFSET_WIN0V, MENU_WIN_VCOORDS(5) - MENU_SCROLL_SHIFT);
else else
SetGpuReg(REG_OFFSET_WIN0V, WINHV_COORDS(129, 159)); SetGpuReg(REG_OFFSET_WIN0V, MENU_WIN_VCOORDS(5));
break; break;
case 4: case 4:
SetGpuReg(REG_OFFSET_WIN0V, WINHV_COORDS(129, 159)); SetGpuReg(REG_OFFSET_WIN0V, MENU_WIN_VCOORDS(6) - MENU_SCROLL_SHIFT);
break; break;
} }
break; break;
@ -1915,9 +1945,9 @@ void CreateMainMenuErrorWindow(const u8* str)
PrintTextOnWindow(7, 1, str, 0, 1, 2, 0); PrintTextOnWindow(7, 1, str, 0, 1, 2, 0);
PutWindowTilemap(7); PutWindowTilemap(7);
CopyWindowToVram(7, 2); CopyWindowToVram(7, 2);
DrawMainMenuWindowBorder(sWindowTemplate_ErrorWindow, MAIN_MENU_BORDER_TILE); DrawMainMenuWindowBorder(&sWindowTemplates_MainMenu[7], MAIN_MENU_BORDER_TILE);
SetGpuReg(REG_OFFSET_WIN0H, 0x9E7); SetGpuReg(REG_OFFSET_WIN0H, WIN_RANGE(9, 231));
SetGpuReg(REG_OFFSET_WIN0V, 0x719F); SetGpuReg(REG_OFFSET_WIN0V, WIN_RANGE(113, 159));
} }
void fmt_savegame(void) void fmt_savegame(void)

View File

@ -1 +1,2 @@
gbafix gbafix
README