From 7da87a06a21cf892a03b3dcc77b64fc6103afa43 Mon Sep 17 00:00:00 2001 From: wheremyfoodat Date: Tue, 9 May 2023 01:56:49 +0300 Subject: [PATCH] [CFG] Add stereo camera setting (Fixes NaNs in Metroid 2 et al) --- src/core/services/cfg.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/core/services/cfg.cpp b/src/core/services/cfg.cpp index 98b8eca7..0dfd7233 100644 --- a/src/core/services/cfg.cpp +++ b/src/core/services/cfg.cpp @@ -3,6 +3,9 @@ #include "system_models.hpp" #include "ipc.hpp" +#include +#include + namespace CFGCommands { enum : u32 { GetConfigInfoBlk2 = 0x00010082, @@ -68,7 +71,16 @@ void CFGService::getConfigInfoBlk2(u32 messagePointer) { mem.write8(output + 2, 2); // Province (Temporarily stubbed to Washington DC like Citra) mem.write8(output + 3, static_cast(country)); // Country code } else if (size == 0x20 && blockID == 0x50005) { - printf("[Unimplemented] Read stereo display settings from NAND\n"); + // "Stereo Camera settings" + // Implementing this properly fixes NaN uniforms in some games. Values taken from 3dmoo & Citra + static constexpr std::array STEREO_CAMERA_SETTINGS = { + 62.0f, 289.0f, 76.80000305175781f, 46.08000183105469f, + 10.0f, 5.0f, 55.58000183105469f, 21.56999969482422f + }; + + for (int i = 0; i < 8; i++) { + mem.write32(output + i * 4, std::bit_cast(STEREO_CAMERA_SETTINGS[i])); + } } else if (size == 0x1C && blockID == 0xA0000) { // Username writeStringU16(output, u"Pander"); } else if (size == 0xC0 && blockID == 0xC0000) { // Parental restrictions info