Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -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}"
}
]
}
71 changes: 67 additions & 4 deletions src/engine/fox_game.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -518,6 +564,8 @@ void Game_Update(void) {

Game_Draw(0);

Game_BuildSecondaryHud();

if (gCamCount == 2) {
Game_InitViewport(&gMasterDisp, gCamCount, 1);
Game_Draw(1);
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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) {
Expand Down
6 changes: 6 additions & 0 deletions src/port/Engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<Ship::ControllerDefaultMappings>(
// KeyboardKeyToButtonMappings - use built-in LUS defaults
Expand Down Expand Up @@ -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<Fast::Fast3dWindow>(Ship::Context::GetInstance()->GetWindow());
return window != nullptr ? window->GetSecondaryFramebuffer() : 0;
}

uint32_t GameEngine::GetInterpolationFPS() {
if (CVarGetInteger("gMatchRefreshRate", 0)) {
return Ship::Context::GetInstance()->GetWindow()->GetCurrentRefreshRate();
Expand Down
1 change: 1 addition & 0 deletions src/port/Engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down