From e2a4d8f1e64fbd910bb10cb425f107bffb95d02b Mon Sep 17 00:00:00 2001 From: Stenzek Date: Sun, 9 Jun 2024 17:57:50 +1000 Subject: [PATCH] CDVD: Force initialized flag on NVRAM reads Jak 1 crashes on boot if it's not set. --- pcsx2/CDVD/CDVD.cpp | 13 ++++++++++++- pcsx2/VMManager.cpp | 5 +++++ pcsx2/VMManager.h | 3 +++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/pcsx2/CDVD/CDVD.cpp b/pcsx2/CDVD/CDVD.cpp index ef21274da1..b2e4df7caf 100644 --- a/pcsx2/CDVD/CDVD.cpp +++ b/pcsx2/CDVD/CDVD.cpp @@ -333,7 +333,18 @@ s32 cdvdReadConfig(u8* config) cdvdReadNVM(config, nvmLayout->config2 + ((cdvd.CBlockIndex++) * 16), 16); break; default: - cdvdReadNVM(config, nvmLayout->config1 + ((cdvd.CBlockIndex++) * 16), 16); + { + cdvdReadNVM(config, nvmLayout->config1 + (cdvd.CBlockIndex * 16), 16); + DEV_LOG("CONF1: {:02X} {:02X} {:02X} {:02X} {:02X} {:02X}", config[0], config[1], config[2], config[3], config[4], config[5]); + if (cdvd.CBlockIndex == 1 && (NoOSD || VMManager::Internal::WasFastBooted())) + { + // HACK: Set the "initialized" flag when fast booting, otherwise some games crash (e.g. Jak 1). + config[2] |= 0x80; + } + + cdvd.CBlockIndex++; + } + break; } return 0; } diff --git a/pcsx2/VMManager.cpp b/pcsx2/VMManager.cpp index 7172391491..c40bd0bf12 100644 --- a/pcsx2/VMManager.cpp +++ b/pcsx2/VMManager.cpp @@ -2626,6 +2626,11 @@ bool VMManager::ShouldAllowPresentThrottle() return (!valid_vm || (!s_target_speed_synced_to_host && s_target_speed != 1.0f)); } +bool VMManager::Internal::WasFastBooted() +{ + return s_fast_boot_requested; +} + bool VMManager::Internal::IsFastBootInProgress() { return s_fast_boot_requested && !HasBootedELF(); diff --git a/pcsx2/VMManager.h b/pcsx2/VMManager.h index d23369bceb..755958c04f 100644 --- a/pcsx2/VMManager.h +++ b/pcsx2/VMManager.h @@ -261,6 +261,9 @@ namespace VMManager /// Updates the variables in the EmuFolders namespace, reloading subsystems if needed. void UpdateEmuFolders(); + /// Returns true if the VM was fast booted. + bool WasFastBooted(); + /// Returns true if fast booting is active (requested but ELF not started). bool IsFastBootInProgress();