Back color configurable, added fps counter checkbox

This commit is contained in:
2026-03-28 13:32:26 +01:00
parent bb93ecdc5d
commit 69aa4e079d
4 changed files with 18 additions and 17 deletions

View File

@@ -37,5 +37,10 @@ ifeq ($(MEMOVERLAY),1)
CPPFLAGS += -DPSXSPLASH_MEMOVERLAY CPPFLAGS += -DPSXSPLASH_MEMOVERLAY
endif endif
# FPSOVERLAY=1 → Enable runtime FPS overlay
ifeq ($(FPSOVERLAY), 1)
CPPFLAGS += -DPSXSPLASH_FPSOVERLAY
endif
include third_party/nugget/psyqo-lua/psyqo-lua.mk include third_party/nugget/psyqo-lua/psyqo-lua.mk
include third_party/nugget/psyqo/psyqo.mk include third_party/nugget/psyqo/psyqo.mk

View File

@@ -119,8 +119,10 @@ void MainScene::frame() {
m_sceneManager.GameTick(gpu()); m_sceneManager.GameTick(gpu());
#if defined(PSXSPLASH_FPSOVERLAY)
app.m_font.chainprintf(gpu(), {{.x = 2, .y = 2}}, {{.r = 0xff, .g = 0xff, .b = 0xff}}, "FPS: %i", app.m_font.chainprintf(gpu(), {{.x = 2, .y = 2}}, {{.r = 0xff, .g = 0xff, .b = 0xff}}, "FPS: %i",
gpu().getRefreshRate() / deltaTime); gpu().getRefreshRate() / deltaTime);
#endif
gpu().pumpCallbacks(); gpu().pumpCallbacks();
} }

View File

@@ -45,14 +45,14 @@ void psxsplash::Renderer::SetCamera(psxsplash::Camera& camera) { m_currentCamera
void psxsplash::Renderer::SetFog(const FogConfig& fog) { void psxsplash::Renderer::SetFog(const FogConfig& fog) {
m_fog = fog; m_fog = fog;
if (fog.enabled) { // Always use fog color as the GPU clear/back color
m_clearcolor = fog.color; m_clearcolor = fog.color;
if (fog.enabled) {
write<Register::RFC, Unsafe>(static_cast<uint32_t>(fog.color.r) << 4); write<Register::RFC, Unsafe>(static_cast<uint32_t>(fog.color.r) << 4);
write<Register::GFC, Unsafe>(static_cast<uint32_t>(fog.color.g) << 4); write<Register::GFC, Unsafe>(static_cast<uint32_t>(fog.color.g) << 4);
write<Register::BFC, Safe>(static_cast<uint32_t>(fog.color.b) << 4); write<Register::BFC, Safe>(static_cast<uint32_t>(fog.color.b) << 4);
m_fog.fogFarSZ = 8000 / fog.density; m_fog.fogFarSZ = 8000 / fog.density;
} else { } else {
m_clearcolor = {.r = 0, .g = 0, .b = 0};
m_fog.fogFarSZ = 0; m_fog.fogFarSZ = 0;
} }
} }
@@ -135,9 +135,8 @@ void psxsplash::Renderer::processTriangle(
int32_t fogIR[3] = {0, 0, 0}; int32_t fogIR[3] = {0, 0, 0};
if (fogFarSZ > 0) { if (fogFarSZ > 0) {
int32_t fogNear = fogFarSZ / 4; int32_t fogNear = fogFarSZ / 4;
int32_t range4 = (fogFarSZ - fogNear) >> 4; int32_t range = fogFarSZ - fogNear;
if (range4 < 1) range4 = 1; if (range < 1) range = 1;
int32_t scale = 4096 / range4;
int32_t szArr[3] = {sz0, sz1, sz2}; int32_t szArr[3] = {sz0, sz1, sz2};
for (int vi = 0; vi < 3; vi++) { for (int vi = 0; vi < 3; vi++) {
int32_t ir; int32_t ir;
@@ -146,11 +145,10 @@ void psxsplash::Renderer::processTriangle(
} else if (szArr[vi] >= fogFarSZ) { } else if (szArr[vi] >= fogFarSZ) {
ir = 4096; ir = 4096;
} else { } else {
ir = ((szArr[vi] - fogNear) * scale) >> 4; // Linear 0..4096 over [fogNear, fogFarSZ]
if (ir > 4096) ir = 4096; int32_t t = ((szArr[vi] - fogNear) * 4096) / range;
int32_t inv = 4096 - ir; // Quadratic ease-in: t^2 / 4096
ir = 4096 - ((inv >> 2) * (inv >> 2) >> 8); ir = (t * t) >> 12;
if (ir < 0) ir = 0;
} }
fogIR[vi] = ir; fogIR[vi] = ir;
} }

View File

@@ -69,17 +69,13 @@ void psxsplash::SceneManager::InitializeScene(uint8_t* splashpackData, LoadingSc
m_roomTriRefs = sceneSetup.roomTriRefs; m_roomTriRefs = sceneSetup.roomTriRefs;
m_roomTriRefCount = sceneSetup.roomTriRefCount; m_roomTriRefCount = sceneSetup.roomTriRefCount;
// Configure fog from splashpack data (v11+) // Configure fog and back color from splashpack data (v11+)
if (sceneSetup.fogEnabled) { {
psxsplash::FogConfig fogCfg; psxsplash::FogConfig fogCfg;
fogCfg.enabled = true; fogCfg.enabled = sceneSetup.fogEnabled;
fogCfg.color = {.r = sceneSetup.fogR, .g = sceneSetup.fogG, .b = sceneSetup.fogB}; fogCfg.color = {.r = sceneSetup.fogR, .g = sceneSetup.fogG, .b = sceneSetup.fogB};
fogCfg.density = sceneSetup.fogDensity; fogCfg.density = sceneSetup.fogDensity;
Renderer::GetInstance().SetFog(fogCfg); Renderer::GetInstance().SetFog(fogCfg);
} else {
psxsplash::FogConfig fogCfg;
fogCfg.enabled = false;
Renderer::GetInstance().SetFog(fogCfg);
} }
// Copy component arrays // Copy component arrays
m_interactables = std::move(sceneSetup.interactables); m_interactables = std::move(sceneSetup.interactables);