From f023a46a5d5ef8e969427dbd694366f06fb078b7 Mon Sep 17 00:00:00 2001 From: Archez Date: Tue, 25 Feb 2025 03:13:17 -0500 Subject: [PATCH] Use gamemode enum (#5089) * Use gamemode enum * update console command for file_select --- soh/soh/Enhancements/cosmetics/CustomLogoTitle.cpp | 2 +- soh/soh/Enhancements/debugconsole.cpp | 13 +++++++------ .../Enhancements/randomizer/randomizer_entrance.c | 2 +- soh/src/code/graph.c | 2 +- soh/src/code/z_camera.c | 2 +- soh/src/code/z_construct.c | 2 +- soh/src/code/z_demo.c | 14 +++++++------- soh/src/code/z_kankyo.c | 6 +++--- soh/src/code/z_parameter.c | 2 +- soh/src/code/z_player_lib.c | 2 +- soh/src/overlays/actors/ovl_En_Light/z_en_light.c | 2 +- soh/src/overlays/actors/ovl_En_Mag/z_en_mag.c | 6 +++--- soh/src/overlays/actors/ovl_En_Mm/z_en_mm.c | 2 +- .../ovl_En_Okarina_Effect/z_en_okarina_effect.c | 2 +- .../overlays/actors/ovl_player_actor/z_player.c | 2 +- .../gamestates/ovl_file_choose/z_file_choose.c | 5 +---- .../overlays/gamestates/ovl_opening/z_opening.c | 2 +- soh/src/overlays/gamestates/ovl_title/z_title.c | 2 +- 18 files changed, 34 insertions(+), 36 deletions(-) diff --git a/soh/soh/Enhancements/cosmetics/CustomLogoTitle.cpp b/soh/soh/Enhancements/cosmetics/CustomLogoTitle.cpp index d478f8fc3..2d750ab5d 100644 --- a/soh/soh/Enhancements/cosmetics/CustomLogoTitle.cpp +++ b/soh/soh/Enhancements/cosmetics/CustomLogoTitle.cpp @@ -205,7 +205,7 @@ void OnZTitleUpdateSkipToFileSelect(void* gameState) { gSaveContext.seqId = (u8)NA_BGM_DISABLED; gSaveContext.natureAmbienceId = 0xFF; - gSaveContext.gameMode = GAMEMODE_TITLE_SCREEN; + gSaveContext.gameMode = GAMEMODE_FILE_SELECT; titleContext->state.running = false; SET_NEXT_GAMESTATE(&titleContext->state, FileChoose_Init, FileChooseContext); diff --git a/soh/soh/Enhancements/debugconsole.cpp b/soh/soh/Enhancements/debugconsole.cpp index 5df00dfab..67547437d 100644 --- a/soh/soh/Enhancements/debugconsole.cpp +++ b/soh/soh/Enhancements/debugconsole.cpp @@ -146,7 +146,7 @@ static bool SetPlayerHealthHandler(std::shared_ptr Console, const static bool LoadSceneHandler(std::shared_ptr Console, const std::vector&, std::string* output) { gSaveContext.respawnFlag = 0; gSaveContext.seqId = 0xFF; - gSaveContext.gameMode = 0; + gSaveContext.gameMode = GAMEMODE_NORMAL; return 0; } @@ -489,13 +489,14 @@ static bool FWHandler(std::shared_ptr Console, const std::vector< } static bool FileSelectHandler(std::shared_ptr Console, const std::vector& args, std::string* output) { - if (gPlayState != nullptr) { - SET_NEXT_GAMESTATE(&gPlayState->state, FileChoose_Init, FileChooseContext); - gPlayState->state.running = 0; - } else { - ERROR_MESSAGE("gPlayState == nullptr"); + if (gGameState == nullptr) { + ERROR_MESSAGE("gGameState == nullptr"); return 1; } + + gSaveContext.gameMode = GAMEMODE_FILE_SELECT; + SET_NEXT_GAMESTATE(gGameState, FileChoose_Init, FileChooseContext); + gGameState->running = false; return 0; } diff --git a/soh/soh/Enhancements/randomizer/randomizer_entrance.c b/soh/soh/Enhancements/randomizer/randomizer_entrance.c index fdb1f6809..3ad26b1f6 100644 --- a/soh/soh/Enhancements/randomizer/randomizer_entrance.c +++ b/soh/soh/Enhancements/randomizer/randomizer_entrance.c @@ -440,7 +440,7 @@ void Entrance_SetWarpSongEntrance(void) { // have to force the grotto return afterwards Grotto_ForceGrottoReturnOnSpecialEntrance(); - if (gSaveContext.gameMode != 0) { + if (gSaveContext.gameMode != GAMEMODE_NORMAL) { // During DHWW the cutscene must play at the destination gSaveContext.respawnFlag = -3; } else if (gSaveContext.respawnFlag == -3) { diff --git a/soh/src/code/graph.c b/soh/src/code/graph.c index 51f8fcd17..be5ee994d 100644 --- a/soh/src/code/graph.c +++ b/soh/src/code/graph.c @@ -412,7 +412,7 @@ void Graph_Update(GraphicsContext* gfxCtx, GameState* gameState) { { if (CHECK_BTN_ALL(gameState->input[0].press.button, BTN_Z) && CHECK_BTN_ALL(gameState->input[0].cur.button, BTN_L | BTN_R)) { - gSaveContext.gameMode = 0; + gSaveContext.gameMode = GAMEMODE_NORMAL; SET_NEXT_GAMESTATE(gameState, Select_Init, SelectContext); gameState->running = false; } diff --git a/soh/src/code/z_camera.c b/soh/src/code/z_camera.c index 6551d6347..7167daceb 100644 --- a/soh/src/code/z_camera.c +++ b/soh/src/code/z_camera.c @@ -7589,7 +7589,7 @@ Vec3s Camera_Update(Camera* camera) { } if (camera->status == CAM_STAT_ACTIVE) { - if ((gSaveContext.gameMode != 0) && (gSaveContext.gameMode != 3)) { + if ((gSaveContext.gameMode != GAMEMODE_NORMAL) && (gSaveContext.gameMode != GAMEMODE_END_CREDITS)) { sCameraInterfaceFlags = 0; Camera_UpdateInterface(sCameraInterfaceFlags); } else if ((D_8011D3F0 != 0) && (camera->thisIdx == MAIN_CAM)) { diff --git a/soh/src/code/z_construct.c b/soh/src/code/z_construct.c index 960088cba..065c6f413 100644 --- a/soh/src/code/z_construct.c +++ b/soh/src/code/z_construct.c @@ -479,7 +479,7 @@ void Regs_InitDataImpl(void) { WREG(94) = 3; WREG(95) = 6; - if (gSaveContext.gameMode == 0) { + if (gSaveContext.gameMode == GAMEMODE_NORMAL) { R_TEXTBOX_X = 52; R_TEXTBOX_Y = 36; VREG(2) = 214; diff --git a/soh/src/code/z_demo.c b/soh/src/code/z_demo.c index 9821b8d26..c079d0064 100644 --- a/soh/src/code/z_demo.c +++ b/soh/src/code/z_demo.c @@ -510,8 +510,8 @@ void Cutscene_Command_Terminator(PlayState* play, CutsceneContext* csCtx, CsCmdB bool debugCsSkip = (CHECK_BTN_ALL(play->state.input[0].press.button, BTN_START) && (gSaveContext.fileNum != 0xFEDC) && CVarGetInteger(CVAR_DEVELOPER_TOOLS("DebugEnabled"), 0)); - if ((gSaveContext.gameMode != 0) && (gSaveContext.gameMode != 3) && (play->sceneNum != SCENE_HYRULE_FIELD) && - (csCtx->frames > 20) && + if ((gSaveContext.gameMode != GAMEMODE_NORMAL) && (gSaveContext.gameMode != GAMEMODE_END_CREDITS) && + (play->sceneNum != SCENE_HYRULE_FIELD) && (csCtx->frames > 20) && (CHECK_BTN_ALL(play->state.input[0].press.button, BTN_A) || CHECK_BTN_ALL(play->state.input[0].press.button, BTN_B) || CHECK_BTN_ALL(play->state.input[0].press.button, BTN_START)) && @@ -575,7 +575,7 @@ void Cutscene_Command_Terminator(PlayState* play, CutsceneContext* csCtx, CsCmdB osSyncPrintf("\n分岐先指定!!=[%d]番", cmd->base); // "Future fork designation=No. [%d]" - if ((gSaveContext.gameMode != 0) && (csCtx->frames != cmd->startFrame)) { + if ((gSaveContext.gameMode != GAMEMODE_NORMAL) && (csCtx->frames != cmd->startFrame)) { gSaveContext.unk_13E7 = 1; } @@ -908,7 +908,7 @@ void Cutscene_Command_Terminator(PlayState* play, CutsceneContext* csCtx, CsCmdB play->transitionType = TRANS_TYPE_FADE_WHITE; break; case 54: - gSaveContext.gameMode = 3; + gSaveContext.gameMode = GAMEMODE_END_CREDITS; Audio_SetSoundBanksMute(0x6F); play->linkAgeOnLoad = 1; play->nextEntranceIndex = ENTR_GERUDO_VALLEY_EAST_EXIT; @@ -1288,7 +1288,7 @@ void Cutscene_Command_Terminator(PlayState* play, CutsceneContext* csCtx, CsCmdB gSaveContext.nextTransitionType = TRANS_TYPE_FADE_WHITE; break; case 117: - gSaveContext.gameMode = 3; + gSaveContext.gameMode = GAMEMODE_END_CREDITS; Audio_SetSoundBanksMute(0x6F); play->linkAgeOnLoad = 0; play->nextEntranceIndex = ENTR_HYRULE_FIELD_PAST_BRIDGE_SPAWN; @@ -2080,7 +2080,7 @@ void func_80068DC0(PlayState* play, CutsceneContext* csCtx) { osSyncPrintf("\n\n\n\n\nやっぱりここかいな"); // "Right here, huh" gSaveContext.cutsceneIndex = 0; - gSaveContext.gameMode = 0; + gSaveContext.gameMode = GAMEMODE_NORMAL; if (D_8015FCC8 != 0) { switch (gSaveContext.entranceIndex) { @@ -2203,7 +2203,7 @@ void Cutscene_HandleConditionalTriggers(PlayState* play) { return; } - if ((gSaveContext.gameMode == 0) && (gSaveContext.respawnFlag <= 0) && (gSaveContext.cutsceneIndex < 0xFFF0)) { + if ((gSaveContext.gameMode == GAMEMODE_NORMAL) && (gSaveContext.respawnFlag <= 0) && (gSaveContext.cutsceneIndex < 0xFFF0)) { if ((gSaveContext.entranceIndex == ENTR_DESERT_COLOSSUS_OUTSIDE_TEMPLE) && !Flags_GetEventChkInf(EVENTCHKINF_LEARNED_REQUIEM_OF_SPIRIT)) { Flags_SetEventChkInf(EVENTCHKINF_LEARNED_REQUIEM_OF_SPIRIT); gSaveContext.entranceIndex = ENTR_DESERT_COLOSSUS_EAST_EXIT; diff --git a/soh/src/code/z_kankyo.c b/soh/src/code/z_kankyo.c index 6e3736b77..df5decc4a 100644 --- a/soh/src/code/z_kankyo.c +++ b/soh/src/code/z_kankyo.c @@ -895,7 +895,7 @@ void Environment_Update(PlayState* play, EnvironmentContext* envCtx, LightContex EnvLightSettings* lightSettingsList = play->envCtx.lightSettingsList; s32 adjustment; - if ((((void)0, gSaveContext.gameMode) != 0) && (((void)0, gSaveContext.gameMode) != 3)) { + if ((((void)0, gSaveContext.gameMode) != GAMEMODE_NORMAL) && (((void)0, gSaveContext.gameMode) != GAMEMODE_END_CREDITS)) { func_800AA16C(play); } @@ -925,9 +925,9 @@ void Environment_Update(PlayState* play, EnvironmentContext* envCtx, LightContex } if ((pauseCtx->state == 0) && (gameOverCtx->state == GAMEOVER_INACTIVE)) { - if (((msgCtx->msgLength == 0) && (msgCtx->msgMode == 0)) || (((void)0, gSaveContext.gameMode) == 3)) { + if (((msgCtx->msgLength == 0) && (msgCtx->msgMode == 0)) || (((void)0, gSaveContext.gameMode) == GAMEMODE_END_CREDITS)) { if ((envCtx->unk_1A == 0) && !FrameAdvance_IsEnabled(play) && - (play->transitionMode == TRANS_MODE_OFF || ((void)0, gSaveContext.gameMode) != 0)) { + (play->transitionMode == TRANS_MODE_OFF || ((void)0, gSaveContext.gameMode) != GAMEMODE_NORMAL)) { if (IS_DAY || gTimeIncrement >= 0x190) { gSaveContext.dayTime += gTimeIncrement; diff --git a/soh/src/code/z_parameter.c b/soh/src/code/z_parameter.c index a331e4ace..1daa29fb9 100644 --- a/soh/src/code/z_parameter.c +++ b/soh/src/code/z_parameter.c @@ -3215,7 +3215,7 @@ void Interface_UpdateMagicBar(PlayState* play) { case MAGIC_STATE_FILL: gSaveContext.magic += 4; - if (gSaveContext.gameMode == 0 && gSaveContext.sceneSetupIndex < 4) { + if (gSaveContext.gameMode == GAMEMODE_NORMAL && gSaveContext.sceneSetupIndex < 4) { Audio_PlaySoundGeneral(NA_SE_SY_GAUGE_UP - SFX_FLAG, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); } diff --git a/soh/src/code/z_player_lib.c b/soh/src/code/z_player_lib.c index 9d4b55091..bf7189616 100644 --- a/soh/src/code/z_player_lib.c +++ b/soh/src/code/z_player_lib.c @@ -1131,7 +1131,7 @@ void Player_DrawImpl(PlayState* play, void** skeleton, Vec3s* jointTable, s32 dL if (((CVarGetInteger(CVAR_ENHANCEMENT("FirstPersonGauntlets"), 0) && LINK_IS_ADULT) || (overrideLimbDraw != Player_OverrideLimbDrawGameplayFirstPerson)) && (overrideLimbDraw != Player_OverrideLimbDrawGameplayCrawling) && - (gSaveContext.gameMode != 3)) { + (gSaveContext.gameMode != GAMEMODE_END_CREDITS)) { if (LINK_IS_ADULT) { s32 strengthUpgrade = CUR_UPG_VALUE(UPG_STRENGTH); diff --git a/soh/src/overlays/actors/ovl_En_Light/z_en_light.c b/soh/src/overlays/actors/ovl_En_Light/z_en_light.c index d7f9772d6..ca5cdaa0d 100644 --- a/soh/src/overlays/actors/ovl_En_Light/z_en_light.c +++ b/soh/src/overlays/actors/ovl_En_Light/z_en_light.c @@ -50,7 +50,7 @@ void EnLight_Init(Actor* thisx, PlayState* play) { EnLight* this = (EnLight*)thisx; s16 yOffset; - if (gSaveContext.gameMode == 3) { + if (gSaveContext.gameMode == GAMEMODE_END_CREDITS) { // special case for the credits yOffset = (this->actor.params < 0) ? 1 : 40; Lights_PointNoGlowSetInfo(&this->lightInfo, this->actor.world.pos.x, yOffset + (s16)this->actor.world.pos.y, diff --git a/soh/src/overlays/actors/ovl_En_Mag/z_en_mag.c b/soh/src/overlays/actors/ovl_En_Mag/z_en_mag.c index 558a18796..0ea4a2e25 100644 --- a/soh/src/overlays/actors/ovl_En_Mag/z_en_mag.c +++ b/soh/src/overlays/actors/ovl_En_Mag/z_en_mag.c @@ -251,7 +251,7 @@ void EnMag_UpdateMq(Actor* thisx, PlayState* play) { Audio_PlaySoundGeneral(NA_SE_SY_PIECE_OF_HEART, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); - gSaveContext.gameMode = 2; + gSaveContext.gameMode = GAMEMODE_FILE_SELECT; play->transitionTrigger = TRANS_TRIGGER_START; play->transitionType = TRANS_TYPE_FADE_BLACK; } @@ -411,7 +411,7 @@ void EnMag_UpdateVanilla(Actor* thisx, PlayState* play) { Audio_PlaySoundGeneral(NA_SE_SY_PIECE_OF_HEART, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); - gSaveContext.gameMode = 2; + gSaveContext.gameMode = GAMEMODE_FILE_SELECT; play->transitionTrigger = TRANS_TRIGGER_START; play->transitionType = TRANS_TYPE_FADE_BLACK; } @@ -1065,4 +1065,4 @@ void EnMag_Draw(Actor* thisx, PlayState* play) { POLY_OPA_DISP = gfx; CLOSE_DISPS(play->state.gfxCtx); -} \ No newline at end of file +} diff --git a/soh/src/overlays/actors/ovl_En_Mm/z_en_mm.c b/soh/src/overlays/actors/ovl_En_Mm/z_en_mm.c index e72a174f8..c3a27994f 100644 --- a/soh/src/overlays/actors/ovl_En_Mm/z_en_mm.c +++ b/soh/src/overlays/actors/ovl_En_Mm/z_en_mm.c @@ -463,7 +463,7 @@ void func_80AAE294(EnMm* this, PlayState* play) { dustPos.y = this->actor.world.pos.y; dustPos.z = this->actor.world.pos.z; - if (gSaveContext.gameMode != 3) { + if (gSaveContext.gameMode != GAMEMODE_END_CREDITS) { func_80033480(play, &dustPos, 50.0f, 2, 350, 20, 0); } diff --git a/soh/src/overlays/actors/ovl_En_Okarina_Effect/z_en_okarina_effect.c b/soh/src/overlays/actors/ovl_En_Okarina_Effect/z_en_okarina_effect.c index 0d3519e3d..5bde1af54 100644 --- a/soh/src/overlays/actors/ovl_En_Okarina_Effect/z_en_okarina_effect.c +++ b/soh/src/overlays/actors/ovl_En_Okarina_Effect/z_en_okarina_effect.c @@ -73,7 +73,7 @@ void EnOkarinaEffect_ManageStorm(EnOkarinaEffect* this, PlayState* play) { Flags_UnsetEnv(play, 5); // clear storms env flag if (((play->pauseCtx.state == 0) && (play->gameOverCtx.state == GAMEOVER_INACTIVE) && (play->msgCtx.msgLength == 0) && (!FrameAdvance_IsEnabled(play)) && - ((play->transitionMode == TRANS_MODE_OFF) || (gSaveContext.gameMode != 0))) || + ((play->transitionMode == TRANS_MODE_OFF) || (gSaveContext.gameMode != GAMEMODE_NORMAL))) || (this->timer >= 250)) { if (play->envCtx.indoors || play->envCtx.unk_1F != 1) { this->timer--; diff --git a/soh/src/overlays/actors/ovl_player_actor/z_player.c b/soh/src/overlays/actors/ovl_player_actor/z_player.c index 1c9d5a688..1d9c89212 100644 --- a/soh/src/overlays/actors/ovl_player_actor/z_player.c +++ b/soh/src/overlays/actors/ovl_player_actor/z_player.c @@ -10859,7 +10859,7 @@ void Player_Init(Actor* thisx, PlayState* play2) { } if (startMode != PLAYER_START_MODE_NOTHING) { - if ((gSaveContext.gameMode == 0) || (gSaveContext.gameMode == 3)) { + if ((gSaveContext.gameMode == GAMEMODE_NORMAL) || (gSaveContext.gameMode == GAMEMODE_END_CREDITS)) { this->naviActor = Player_SpawnFairy(play, this, &thisx->world.pos, &D_80854778, FAIRY_NAVI); if (gSaveContext.dogParams != 0) { gSaveContext.dogParams |= 0x8000; diff --git a/soh/src/overlays/gamestates/ovl_file_choose/z_file_choose.c b/soh/src/overlays/gamestates/ovl_file_choose/z_file_choose.c index 6b2d0546f..664a9dcfc 100644 --- a/soh/src/overlays/gamestates/ovl_file_choose/z_file_choose.c +++ b/soh/src/overlays/gamestates/ovl_file_choose/z_file_choose.c @@ -3112,7 +3112,7 @@ void FileChoose_LoadGame(GameState* thisx) { Audio_PlaySoundGeneral(NA_SE_SY_FSEL_DECIDE_L, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); gSaveContext.fileNum = this->buttonIndex; - gSaveContext.gameMode = 0; + gSaveContext.gameMode = GAMEMODE_NORMAL; if ((this->buttonIndex == FS_BTN_SELECT_FILE_1 && CVarGetInteger(CVAR_DEVELOPER_TOOLS("DebugEnabled"), 0)) || this->buttonIndex == 0xFF) { if (this->buttonIndex == 0xFF) { @@ -3737,7 +3737,4 @@ void FileChoose_Init(GameState* thisx) { Font_LoadOrderedFont(&this->font); Audio_QueueSeqCmd(0xF << 28 | SEQ_PLAYER_BGM_MAIN << 24 | 0xA); func_800F5E18(SEQ_PLAYER_BGM_MAIN, NA_BGM_FILE_SELECT, 0, 7, 1); - - // Originally this was only set when transitioning from the title screen, but gSkipLogoTitle skips that process so we're ensuring it's set here - gSaveContext.gameMode = GAMEMODE_FILE_SELECT; } diff --git a/soh/src/overlays/gamestates/ovl_opening/z_opening.c b/soh/src/overlays/gamestates/ovl_opening/z_opening.c index 3ecd61fca..7898e8aed 100644 --- a/soh/src/overlays/gamestates/ovl_opening/z_opening.c +++ b/soh/src/overlays/gamestates/ovl_opening/z_opening.c @@ -9,7 +9,7 @@ void Sram_InitDebugSave(void); void Opening_SetupTitleScreen(OpeningContext* this) { - gSaveContext.gameMode = 1; + gSaveContext.gameMode = GAMEMODE_TITLE_SCREEN; this->state.running = false; gSaveContext.linkAge = 0; gSaveContext.fileNum = 0xFF; diff --git a/soh/src/overlays/gamestates/ovl_title/z_title.c b/soh/src/overlays/gamestates/ovl_title/z_title.c index 544fb6884..239ee9d3d 100644 --- a/soh/src/overlays/gamestates/ovl_title/z_title.c +++ b/soh/src/overlays/gamestates/ovl_title/z_title.c @@ -137,7 +137,7 @@ void Title_Main(GameState* thisx) { if (this->exit) { gSaveContext.seqId = (u8)NA_BGM_DISABLED; gSaveContext.natureAmbienceId = 0xFF; - gSaveContext.gameMode = 1; + gSaveContext.gameMode = GAMEMODE_TITLE_SCREEN; this->state.running = false; SET_NEXT_GAMESTATE(&this->state, Opening_Init, OpeningContext); }