From 825f4e8dca6dbcd83e1f744049cd48bd50f19926 Mon Sep 17 00:00:00 2001 From: darreoncollins Date: Thu, 10 Sep 2026 07:49:28 +0000 Subject: [PATCH] Pending changes exported from your codespace --- .vscode/launch.json | 16 ++++++++++ src/engine/fox_game.c | 71 ++++++++++++++++++++++++++++++++++++++++--- src/port/Engine.cpp | 6 ++++ src/port/Engine.h | 1 + 4 files changed, 90 insertions(+), 4 deletions(-) create mode 100644 .vscode/launch.json diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 000000000..c5674dab8 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,16 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + + { + "type": "chrome", + "request": "launch", + "name": "Launch Chrome against localhost", + "url": "http://localhost:8080", + "webRoot": "${workspaceFolder}" + } + ] +} \ No newline at end of file diff --git a/src/engine/fox_game.c b/src/engine/fox_game.c index 9591dad80..3ba5cba66 100644 --- a/src/engine/fox_game.c +++ b/src/engine/fox_game.c @@ -23,6 +23,50 @@ f32 gFovY; f32 gProjectNear; f32 gProjectFar; +void Map_Draw(void); +static Gfx sDualScreenHudDL[0x8000]; + +static bool Game_DualScreenEnabled(void) { + return GameEngine_GetSecondaryFramebuffer() != 0; +} + +static void Game_DrawSecondaryHud(void) { + if (gDrawMode == DRAW_MAP) { + Map_Draw(); + return; + } + + if ((gDrawMode == DRAW_PLAY) || (gDrawMode == DRAW_ENDING)) { + Radio_Draw(); + if (gShowHud) { + HUD_Draw(); + CALL_CANCELLABLE_EVENT(DrawEdgeArrowsHUDEvent) { + HUD_EdgeArrows_Update(); + } + } + CALL_CANCELLABLE_EVENT(DrawBossHealthHUDEvent) { + HUD_DrawBossHealth(); + } + } + + HUD_DrawStatusScreens(); + AllRange_DrawCountdown(); +} + +static void Game_BuildSecondaryHud(void) { + Gfx* savedMasterDisp; + + if (!Game_DualScreenEnabled()) { + return; + } + + savedMasterDisp = gMasterDisp; + gMasterDisp = sDualScreenHudDL; + Game_DrawSecondaryHud(); + gSPEndDisplayList(gMasterDisp++); + gMasterDisp = savedMasterDisp; +} + bool gShowReticles[4] = { true, true, true, true }; bool D_game_800D2870 = false; s32 sVsCameraULx[] = { 0, SCREEN_WIDTH / 2, 0, SCREEN_WIDTH / 2 }; @@ -283,7 +327,9 @@ void Game_Draw(s32 playerNum) { break; case DRAW_MAP: Background_DrawStarfield(); - OvlMenu_CallFunction(OVLCALL_MAP_DRAW, NULL); + if (!Game_DualScreenEnabled()) { + OvlMenu_CallFunction(OVLCALL_MAP_DRAW, NULL); + } break; case DRAW_PLAY: gPlayerNum = playerNum; @@ -518,6 +564,8 @@ void Game_Update(void) { Game_Draw(0); + Game_BuildSecondaryHud(); + if (gCamCount == 2) { Game_InitViewport(&gMasterDisp, gCamCount, 1); Game_Draw(1); @@ -565,7 +613,7 @@ void Game_Update(void) { OTRGetRectDimensionFromRightEdge(SCREEN_WIDTH - 1), SCREEN_HEIGHT - 1, gPlayerGlareReds[0], gPlayerGlareGreens[0], gPlayerGlareBlues[0], gPlayerGlareAlphas[0]); - if ((gDrawMode == DRAW_PLAY) || (gDrawMode == DRAW_ENDING)) { + if (!Game_DualScreenEnabled() && ((gDrawMode == DRAW_PLAY) || (gDrawMode == DRAW_ENDING))) { Radio_Draw(); if (gShowHud) { HUD_Draw(); @@ -594,13 +642,28 @@ void Game_Update(void) { } Background_dummy_80040CDC(); - HUD_DrawStatusScreens(); - AllRange_DrawCountdown(); + if (!Game_DualScreenEnabled()) { + HUD_DrawStatusScreens(); + AllRange_DrawCountdown(); + } if ((gGameState == GSTATE_PLAY) && gVersusMode) { Versus_Draw(); } + if (Game_DualScreenEnabled()) { + gSPDisplayList(gMasterDisp++, gRcpInitDL); + gsSPSetFB(gMasterDisp++, GameEngine_GetSecondaryFramebuffer()); + gDPSetScissor(gMasterDisp++, G_SC_NON_INTERLACE, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT); + gDPSetCycleType(gMasterDisp++, G_CYC_FILL); + gDPSetFillColor(gMasterDisp++, FILL_COLOR(gBgColor | 1)); + gDPFillRectangle(gMasterDisp++, 0, 0, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1); + Lib_InitPerspective(&gMasterDisp); + Game_InitViewport(&gMasterDisp, 1, 0); + gSPDisplayList(gMasterDisp++, sDualScreenHudDL); + gsSPResetFB(gMasterDisp++); + } + Wipe_Draw(WIPE_CIRCULAR, gCircleWipeFrame); if (!partialFill) { diff --git a/src/port/Engine.cpp b/src/port/Engine.cpp index bc0ccb1f7..f21e01dab 100644 --- a/src/port/Engine.cpp +++ b/src/port/Engine.cpp @@ -128,6 +128,7 @@ GameEngine::GameEngine() { this->context->InitConfiguration(); // without this line InitConsoleVariables fails at Config::Reload() this->context->InitConsoleVariables(); // without this line the controldeck constructor failes in // ShipDeviceIndexMappingManager::UpdateControllerNamesFromConfig() + CVarRegisterInteger("gDualScreen.Enabled", 0); auto defaultMappings = std::make_shared( // KeyboardKeyToButtonMappings - use built-in LUS defaults @@ -533,6 +534,11 @@ void GameEngine::ProcessGfxCommands(Gfx* commands) { last_update_rate = gVIsPerFrame; } +extern "C" int32_t GameEngine_GetSecondaryFramebuffer() { + auto window = std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()); + return window != nullptr ? window->GetSecondaryFramebuffer() : 0; +} + uint32_t GameEngine::GetInterpolationFPS() { if (CVarGetInteger("gMatchRefreshRate", 0)) { return Ship::Context::GetInstance()->GetWindow()->GetCurrentRefreshRate(); diff --git a/src/port/Engine.h b/src/port/Engine.h index b937e9db0..e822e0e92 100644 --- a/src/port/Engine.h +++ b/src/port/Engine.h @@ -62,6 +62,7 @@ extern "C" { void* GameEngine_Malloc(size_t size); bool GameEngine_HasVersion(SF64Version ver); void GameEngine_ProcessGfxCommands(Gfx* commands); +int32_t GameEngine_GetSecondaryFramebuffer(void); float GameEngine_GetAspectRatio(); uint8_t GameEngine_OTRSigCheck(const char* imgData); uint32_t OTRGetCurrentWidth(void);