diff options
Diffstat (limited to 'src/start_menu.c')
-rw-r--r-- | src/start_menu.c | 158 |
1 files changed, 74 insertions, 84 deletions
diff --git a/src/start_menu.c b/src/start_menu.c index 5c7e5365d..4822c12e6 100644 --- a/src/start_menu.c +++ b/src/start_menu.c @@ -1,44 +1,49 @@ #include "global.h" -#include "start_menu.h" -#include "menu.h" -#include "safari_zone.h" -#include "event_data.h" -#include "window.h" -#include "string_util.h" -#include "text.h" -#include "strings.h" +#include "battle_pike.h" +#include "battle_pyramid.h" +#include "battle_pyramid_bag.h" #include "bg.h" +#include "event_data.h" +#include "event_object_movement.h" +#include "event_obj_lock.h" +#include "event_scripts.h" +#include "fieldmap.h" #include "field_effect.h" -#include "party_menu.h" -#include "frontier_pass.h" -#include "task.h" -#include "overworld.h" -#include "link.h" -#include "frontier_util.h" -#include "rom_818CFC8.h" +#include "field_player_avatar.h" #include "field_specials.h" -#include "event_object_movement.h" -#include "script.h" -#include "main.h" -#include "sound.h" -#include "pokedex.h" #include "field_weather.h" -#include "palette.h" +#include "field_screen_effect.h" +#include "frontier_pass.h" +#include "frontier_util.h" +#include "gpu_regs.h" +#include "international_string_util.h" #include "item_menu.h" +#include "link.h" +#include "load_save.h" +#include "main.h" +#include "menu.h" +#include "new_game.h" #include "option_menu.h" -#include "event_scripts.h" +#include "overworld.h" +#include "palette.h" +#include "party_menu.h" +#include "pokedex.h" +#include "pokenav.h" +#include "safari_zone.h" #include "save.h" -#include "gpu_regs.h" #include "scanline_effect.h" +#include "script.h" +#include "sound.h" +#include "start_menu.h" +#include "strings.h" +#include "string_util.h" +#include "task.h" +#include "text.h" #include "text_window.h" -#include "load_save.h" #include "trainer_card.h" -#include "international_string_util.h" +#include "window.h" #include "constants/songs.h" -#include "field_player_avatar.h" -#include "battle_pyramid_bag.h" -#include "battle_pike.h" -#include "new_game.h" +#include "rom_8011DC0.h" // Menu actions enum @@ -83,21 +88,6 @@ EWRAM_DATA static u8 sSaveDialogTimer = 0; EWRAM_DATA static bool8 sSavingComplete = FALSE; EWRAM_DATA static u8 sSaveInfoWindowId = 0; -// Extern variables. -extern u8 gUnknown_03005DB4; - -// Extern functions in not decompiled files. -extern void sub_80AF688(void); -extern void var_800D_set_xB(void); -extern void sub_808B864(void); -extern void CB2_Pokedex(void); -extern void PlayRainSoundEffect(void); -extern void CB2_PokeNav(void); -extern void ScriptUnfreezeEventObjects(void); -extern void sub_81A9EC8(void); -extern void save_serialize_map(void); -extern void sub_81A9E90(void); - // Menu action callbacks static bool8 StartMenuPokedexCallback(void); static bool8 StartMenuPokemonCallback(void); @@ -125,7 +115,7 @@ static u8 SaveConfirmSaveCallback(void); static u8 SaveYesNoCallback(void); static u8 SaveConfirmInputCallback(void); static u8 SaveFileExistsCallback(void); -static u8 SaveConfirmOverwriteNoCallback(void); +static u8 SaveConfirmOverwriteDefaultNoCallback(void); static u8 SaveConfirmOverwriteCallback(void); static u8 SaveOverwriteInputCallback(void); static u8 SaveSavingMessageCallback(void); @@ -246,7 +236,7 @@ static void BuildStartMenuActions(void) { sNumStartMenuActions = 0; - if (is_c1_link_related_active() == TRUE) + if (IsUpdateLinkStateCBActive() == TRUE) { BuildLinkModeStartMenu(); } @@ -378,7 +368,7 @@ static void ShowSafariBallsWindow(void) { sSafariBallsWindowId = AddWindow(&sSafariBallsWindowTemplate); PutWindowTilemap(sSafariBallsWindowId); - NewMenuHelpers_DrawStdWindowFrame(sSafariBallsWindowId, FALSE); + DrawStdWindowFrame(sSafariBallsWindowId, FALSE); ConvertIntToDecimalStringN(gStringVar1, gNumSafariBalls, STR_CONV_MODE_RIGHT_ALIGN, 2); StringExpandPlaceholders(gStringVar4, gText_SafariBallStock); AddTextPrinterParameterized(sSafariBallsWindowId, 1, gStringVar4, 0, 1, 0xFF, NULL); @@ -393,7 +383,7 @@ static void ShowPyramidFloorWindow(void) sBattlePyramidFloorWindowId = AddWindow(&sPyramidFloorWindowTemplate_2); PutWindowTilemap(sBattlePyramidFloorWindowId); - NewMenuHelpers_DrawStdWindowFrame(sBattlePyramidFloorWindowId, FALSE); + DrawStdWindowFrame(sBattlePyramidFloorWindowId, FALSE); StringCopy(gStringVar1, sPyramindFloorNames[gSaveBlock2Ptr->frontier.curChallengeBattleNum]); StringExpandPlaceholders(gStringVar4, gText_BattlePyramidFloor); AddTextPrinterParameterized(sBattlePyramidFloorWindowId, 1, gStringVar4, 0, 1, 0xFF, NULL); @@ -404,13 +394,13 @@ static void RemoveExtraStartMenuWindows(void) { if (GetSafariZoneFlag()) { - sub_8198070(sSafariBallsWindowId, FALSE); + ClearStdWindowAndFrameToTransparent(sSafariBallsWindowId, FALSE); CopyWindowToVram(sSafariBallsWindowId, 2); RemoveWindow(sSafariBallsWindowId); } if (InBattlePyramid()) { - sub_8198070(sBattlePyramidFloorWindowId, FALSE); + ClearStdWindowAndFrameToTransparent(sBattlePyramidFloorWindowId, FALSE); RemoveWindow(sBattlePyramidFloorWindowId); } } @@ -461,7 +451,7 @@ static bool32 InitStartMenuStep(void) break; case 2: sub_81973A4(); - NewMenuHelpers_DrawStdWindowFrame(sub_81979C4(sNumStartMenuActions), FALSE); + DrawStdWindowFrame(sub_81979C4(sNumStartMenuActions), FALSE); sUnknown_02037619[1] = 0; sUnknown_02037619[0]++; break; @@ -549,7 +539,7 @@ void sub_809FA34(u8 taskId) // Referenced in field_screen.s and rom_8011DC0.s void ShowStartMenu(void) // Called from overworld.c and field_control_avatar.s { - if (!is_c1_link_related_active()) + if (!IsUpdateLinkStateCBActive()) { FreezeEventObjects(); sub_808B864(); @@ -610,7 +600,7 @@ static bool8 StartMenuPokedexCallback(void) if (!gPaletteFade.active) { IncrementGameStat(GAME_STAT_CHECKED_POKEDEX); - PlayRainSoundEffect(); + PlayRainStoppingSoundEffect(); RemoveExtraStartMenuWindows(); CleanupOverworldWindowsAndTilemaps(); SetMainCallback2(CB2_Pokedex); @@ -625,7 +615,7 @@ static bool8 StartMenuPokemonCallback(void) { if (!gPaletteFade.active) { - PlayRainSoundEffect(); + PlayRainStoppingSoundEffect(); RemoveExtraStartMenuWindows(); CleanupOverworldWindowsAndTilemaps(); SetMainCallback2(CB2_PartyMenuFromStartMenu); // Display party menu @@ -640,7 +630,7 @@ static bool8 StartMenuBagCallback(void) { if (!gPaletteFade.active) { - PlayRainSoundEffect(); + PlayRainStoppingSoundEffect(); RemoveExtraStartMenuWindows(); CleanupOverworldWindowsAndTilemaps(); SetMainCallback2(CB2_BagMenuFromStartMenu); // Display bag menu @@ -655,10 +645,10 @@ static bool8 StartMenuPokeNavCallback(void) { if (!gPaletteFade.active) { - PlayRainSoundEffect(); + PlayRainStoppingSoundEffect(); RemoveExtraStartMenuWindows(); CleanupOverworldWindowsAndTilemaps(); - SetMainCallback2(CB2_PokeNav); // Display PokeNav + SetMainCallback2(CB2_InitPokeNav); // Display PokeNav return TRUE; } @@ -670,11 +660,11 @@ static bool8 StartMenuPlayerNameCallback(void) { if (!gPaletteFade.active) { - PlayRainSoundEffect(); + PlayRainStoppingSoundEffect(); RemoveExtraStartMenuWindows(); CleanupOverworldWindowsAndTilemaps(); - if (is_c1_link_related_active() || InUnionRoom()) + if (IsUpdateLinkStateCBActive() || InUnionRoom()) ShowPlayerTrainerCard(CB2_ReturnToFieldWithOpenMenu); // Display trainer card else if (FlagGet(FLAG_SYS_FRONTIER_PASS)) ShowFrontierPass(CB2_ReturnToFieldWithOpenMenu); // Display frontier pass @@ -701,7 +691,7 @@ static bool8 StartMenuOptionCallback(void) { if (!gPaletteFade.active) { - PlayRainSoundEffect(); + PlayRainStoppingSoundEffect(); RemoveExtraStartMenuWindows(); CleanupOverworldWindowsAndTilemaps(); SetMainCallback2(CB2_InitOptionMenu); // Display option menu @@ -734,9 +724,9 @@ static bool8 StartMenuLinkModePlayerNameCallback(void) { if (!gPaletteFade.active) { - PlayRainSoundEffect(); + PlayRainStoppingSoundEffect(); CleanupOverworldWindowsAndTilemaps(); - ShowTrainerCardInLink(gUnknown_03005DB4, CB2_ReturnToFieldWithOpenMenu); + ShowTrainerCardInLink(gLocalLinkPlayerId, CB2_ReturnToFieldWithOpenMenu); return TRUE; } @@ -751,9 +741,9 @@ static bool8 StartMenuBattlePyramidRetireCallback(void) return FALSE; } -void sub_809FDD4(void) // Called from battle_frontier_2.s +void sub_809FDD4(void) { - sub_8197DF8(0, FALSE); + ClearDialogWindowAndFrameToTransparent(0, FALSE); ScriptUnfreezeEventObjects(); CreateStartMenuTask(sub_809FA34); ScriptContext2_Enable(); @@ -763,7 +753,7 @@ static bool8 StartMenuBattlePyramidBagCallback(void) { if (!gPaletteFade.active) { - PlayRainSoundEffect(); + PlayRainStoppingSoundEffect(); RemoveExtraStartMenuWindows(); CleanupOverworldWindowsAndTilemaps(); SetMainCallback2(CB2_PyramidBagMenuFromStartMenu); @@ -789,16 +779,16 @@ static bool8 SaveCallback(void) case SAVE_IN_PROGRESS: return FALSE; case SAVE_CANCELED: // Back to start menu - sub_8197DF8(0, FALSE); + ClearDialogWindowAndFrameToTransparent(0, FALSE); InitStartMenu(); gMenuCallback = HandleStartMenuInput; return FALSE; case SAVE_SUCCESS: case SAVE_ERROR: // Close start menu - sub_8197DF8(0, TRUE); + ClearDialogWindowAndFrameToTransparent(0, TRUE); ScriptUnfreezeEventObjects(); ScriptContext2_Disable(); - sub_81A9EC8(); + SoftResetInBattlePyramid(); return TRUE; } @@ -832,7 +822,7 @@ static bool8 BattlePyramidRetireCallback(void) case SAVE_IN_PROGRESS: return FALSE; case SAVE_CANCELED: // Yes (Retire from battle pyramid) - sub_8197DF8(0, TRUE); + ClearDialogWindowAndFrameToTransparent(0, TRUE); ScriptUnfreezeEventObjects(); ScriptContext2_Disable(); ScriptContext1_SetupScript(BattleFrontier_BattlePyramidEmptySquare_EventScript_252C88); @@ -899,7 +889,7 @@ static void SaveGameTask(u8 taskId) static void sub_80A0014(void) { - sub_8197434(0, TRUE); + ClearDialogWindowAndFrame(0, TRUE); } static void HideSaveInfoWindow(void) @@ -945,7 +935,7 @@ static bool8 SaveErrorTimer(void) static u8 SaveConfirmSaveCallback(void) { - sub_819746C(GetStartMenuWindowId(), FALSE); + ClearStdWindowAndFrame(GetStartMenuWindowId(), FALSE); RemoveStartMenuWindow(); ShowSaveInfoWindow(); @@ -963,7 +953,7 @@ static u8 SaveConfirmSaveCallback(void) static u8 SaveYesNoCallback(void) { - DisplayYesNoMenu(); // Show Yes/No menu + DisplayYesNoMenuDefaultYes(); // Show Yes/No menu sSaveDialogCallback = SaveConfirmInputCallback; return SAVE_IN_PROGRESS; } @@ -1004,7 +994,7 @@ static u8 SaveFileExistsCallback(void) { if (gDifferentSaveFile == TRUE) { - ShowSaveMessage(gText_DifferentSaveFile, SaveConfirmOverwriteNoCallback); + ShowSaveMessage(gText_DifferentSaveFile, SaveConfirmOverwriteDefaultNoCallback); } else { @@ -1014,16 +1004,16 @@ static u8 SaveFileExistsCallback(void) return SAVE_IN_PROGRESS; } -static u8 SaveConfirmOverwriteNoCallback(void) +static u8 SaveConfirmOverwriteDefaultNoCallback(void) { - sub_8197948(1); // Show Yes/No menu (No selected as default) + DisplayYesNoMenuWithDefault(1); // Show Yes/No menu (No selected as default) sSaveDialogCallback = SaveOverwriteInputCallback; return SAVE_IN_PROGRESS; } static u8 SaveConfirmOverwriteCallback(void) { - DisplayYesNoMenu(); // Show Yes/No menu + DisplayYesNoMenuDefaultYes(); // Show Yes/No menu sSaveDialogCallback = SaveOverwriteInputCallback; return SAVE_IN_PROGRESS; } @@ -1137,7 +1127,7 @@ static void InitBattlePyramidRetire(void) static u8 BattlePyramidConfirmRetireCallback(void) { - sub_819746C(GetStartMenuWindowId(), FALSE); + ClearStdWindowAndFrame(GetStartMenuWindowId(), FALSE); RemoveStartMenuWindow(); ShowSaveMessage(gText_BattlePyramidConfirmRetire, BattlePyramidRetireYesNoCallback); @@ -1146,7 +1136,7 @@ static u8 BattlePyramidConfirmRetireCallback(void) static u8 BattlePyramidRetireYesNoCallback(void) { - sub_8197948(1); // Show Yes/No menu (No selected as default) + DisplayYesNoMenuWithDefault(1); // Show Yes/No menu (No selected as default) sSaveDialogCallback = BattlePyramidRetireInputCallback; return SAVE_IN_PROGRESS; @@ -1234,7 +1224,7 @@ static void sub_80A0550(u8 taskId) switch (*step) { case 0: - FillWindowPixelBuffer(0, 17); + FillWindowPixelBuffer(0, PIXEL_FILL(1)); AddTextPrinterParameterized2(0, 1, gText_SavingDontTurnOffPower, @@ -1267,11 +1257,11 @@ static void sub_80A0550(u8 taskId) break; case 1: SetContinueGameWarpStatusToDynamicWarp(); - sub_8153430(); + FullSaveGame(); *step = 2; break; case 2: - if (sub_8153474()) + if (CheckSaveFile()) { ClearContinueGameWarpStatus2(); *step = 3; @@ -1315,7 +1305,7 @@ static void ShowSaveInfoWindow(void) } sSaveInfoWindowId = AddWindow(&saveInfoWindow); - NewMenuHelpers_DrawStdWindowFrame(sSaveInfoWindowId, FALSE); + DrawStdWindowFrame(sSaveInfoWindowId, FALSE); gender = gSaveBlock2Ptr->playerGender; color = TEXT_COLOR_RED; // Red when female, blue when male. @@ -1366,7 +1356,7 @@ static void ShowSaveInfoWindow(void) static void RemoveSaveInfoWindow(void) { - sub_819746C(sSaveInfoWindowId, FALSE); + ClearStdWindowAndFrame(sSaveInfoWindowId, FALSE); RemoveWindow(sSaveInfoWindowId); } @@ -1388,7 +1378,7 @@ void sub_80A08CC(void) // Referenced in data/specials.inc and data/scripts/maps/ static void HideStartMenuWindow(void) { - sub_819746C(GetStartMenuWindowId(), TRUE); + ClearStdWindowAndFrame(GetStartMenuWindowId(), TRUE); RemoveStartMenuWindow(); ScriptUnfreezeEventObjects(); ScriptContext2_Disable(); |