From 67f78822424c1afed0e9acbe81e135df34d58728 Mon Sep 17 00:00:00 2001 From: Garrett Cox Date: Thu, 11 Jan 2024 04:44:55 +0000 Subject: [PATCH] Go to map select @ boot when in debug mode or when pressing Z+L+R (#20) * Go to map select @ boot when in debug mode or when pressing Z+L+R * Update mm/src/code/graph.c --- mm/src/code/graph.c | 11 +++++++ .../overlays/gamestates/ovl_select/z_select.c | 6 ++-- .../overlays/gamestates/ovl_title/z_title.c | 29 ++++++++++++------- 3 files changed, 32 insertions(+), 14 deletions(-) diff --git a/mm/src/code/graph.c b/mm/src/code/graph.c index 0766de493..ac81cb1d6 100644 --- a/mm/src/code/graph.c +++ b/mm/src/code/graph.c @@ -4,6 +4,7 @@ #include "functions.h" #include "fault.h" #include "gfxdebuggerbridge.h" +#include "libultraship/libultraship.h" // Variables are put before most headers as a hacky way to bypass bss reordering FaultAddrConvClient sGraphFaultAddrConvClient; @@ -349,6 +350,16 @@ void Graph_Update(GraphicsContext* gfxCtx, GameState* gameState) { Graph_UpdateGame(gameState); Graph_ExecuteAndDraw(gfxCtx, gameState); + + // 2S2H [Debug] Decomp didn't contain the original code that would allow for this, so this is stolen from ship + if (CVarGetInteger("gDebugEnabled", 0)) { + if (CHECK_BTN_ALL(gameState->input[0].press.button, BTN_Z) && + CHECK_BTN_ALL(gameState->input[0].cur.button, BTN_L | BTN_R)) { + STOP_GAMESTATE(gameState); + gSaveContext.gameMode = GAMEMODE_NORMAL; + SET_NEXT_GAMESTATE(gameState, MapSelect_Init, sizeof(MapSelectState)); + } + } } static struct RunFrameContext { diff --git a/mm/src/overlays/gamestates/ovl_select/z_select.c b/mm/src/overlays/gamestates/ovl_select/z_select.c index e03532197..3f4d2c9c8 100644 --- a/mm/src/overlays/gamestates/ovl_select/z_select.c +++ b/mm/src/overlays/gamestates/ovl_select/z_select.c @@ -23,16 +23,16 @@ void MapSelect_LoadFileSelect(MapSelectState* this) { } void MapSelect_LoadGame(MapSelectState* this, u32 entrance, s32 spawn) { - //if (gSaveContext.fileNum == 0xFF) { + if (gSaveContext.fileNum == 0xFF) { Sram_InitDebugSave(); - //} + } gSaveContext.buttonStatus[EQUIP_SLOT_B] = BTN_ENABLED; gSaveContext.buttonStatus[EQUIP_SLOT_C_LEFT] = BTN_ENABLED; gSaveContext.buttonStatus[EQUIP_SLOT_C_DOWN] = BTN_ENABLED; gSaveContext.buttonStatus[EQUIP_SLOT_C_RIGHT] = BTN_ENABLED; gSaveContext.buttonStatus[EQUIP_SLOT_A] = BTN_ENABLED; - gSaveContext.hudVisibilityForceButtonAlphasByStatus = true; + gSaveContext.hudVisibilityForceButtonAlphasByStatus = false; gSaveContext.nextHudVisibility = HUD_VISIBILITY_IDLE; gSaveContext.hudVisibility = HUD_VISIBILITY_IDLE; gSaveContext.hudVisibilityTimer = 0; diff --git a/mm/src/overlays/gamestates/ovl_title/z_title.c b/mm/src/overlays/gamestates/ovl_title/z_title.c index 2d9862460..16223bb1c 100644 --- a/mm/src/overlays/gamestates/ovl_title/z_title.c +++ b/mm/src/overlays/gamestates/ovl_title/z_title.c @@ -13,6 +13,7 @@ #include "overlays/gamestates/ovl_select/z_select.h" #include #include "BenPort.h" +#include "libultraship/libultraship.h" void ConsoleLogo_UpdateCounters(ConsoleLogoState* this) { if ((this->coverAlpha == 0) && (this->visibleDuration != 0)) { @@ -124,9 +125,6 @@ void ConsoleLogo_Draw(GameState* thisx) { CLOSE_DISPS(this->state.gfxCtx); } -// hack for minibuild work -void MapSelect_Init(GameState* thisx); -void FileSelect_Init(GameState* thisx); void ConsoleLogo_Main(GameState* thisx) { ConsoleLogoState* this = (ConsoleLogoState*)thisx; @@ -134,7 +132,7 @@ void ConsoleLogo_Main(GameState* thisx) { OPEN_DISPS(this->state.gfxCtx); - gSPSegment(OVERLAY_DISP++, 0x01, this->staticSegment); + gSPSegment(POLY_OPA_DISP++, 0x01, this->staticSegment); ConsoleLogo_UpdateCounters(this); ConsoleLogo_Draw(&this->state); @@ -144,8 +142,14 @@ void ConsoleLogo_Main(GameState* thisx) { gSaveContext.gameMode = GAMEMODE_TITLE_SCREEN; STOP_GAMESTATE(&this->state); - // hack - SET_NEXT_GAMESTATE(&this->state, MapSelect_Init, sizeof(MapSelectState)); + // #region 2S2H [Debug] Eventually we'll get rid of this + if (CVarGetInteger("gDebugEnabled", 0)) { + gSaveContext.gameMode = GAMEMODE_NORMAL; + SET_NEXT_GAMESTATE(&this->state, MapSelect_Init, sizeof(MapSelectState)); + // #endregion + } else { + SET_NEXT_GAMESTATE(&this->state, TitleSetup_Init, sizeof(TitleSetupState)); + } } CLOSE_DISPS(this->state.gfxCtx); @@ -175,11 +179,14 @@ void ConsoleLogo_Init(GameState* thisx) { this->state.destroy = ConsoleLogo_Destroy; this->exit = false; - if (!(PadMgr_GetValidControllersMask() & 1)) { - gSaveContext.fileNum = 0xFEDC; - } else { - gSaveContext.fileNum = 0xFF; - } + // #region 2S2H [Debug] This value is set to indicate no controllers are connected, not only + // do we not need this, but it conflicts with us wanting to load the debug file on the map select at boot. + // if (!(PadMgr_GetValidControllersMask() & 1)) { + // gSaveContext.fileNum = 0xFEDC; + // } else { + gSaveContext.fileNum = 0xFF; + // } + // #endregion gSaveContext.flashSaveAvailable = true; Sram_Alloc(thisx, &this->sramCtx);