From 69f3225fa862d7bda3b8ded0bceb2e57184829e1 Mon Sep 17 00:00:00 2001 From: Zephyron Date: Tue, 11 Nov 2025 20:05:07 +1000 Subject: [PATCH] fix: correct Little Nightmares 3 TitleID check for PC to LR recovery The TitleID check was broken due to using || operator which evaluated to 1 instead of a title ID value, preventing the recovery mechanism from working. - Fix title_ids.h: Replace incorrect || expression with proper LittleNightmares3Base constant (0x010066101A55A000) - Update physical_core.cpp: Use GetBaseTitleID() to match both base and update title ID variants This now correctly identifies Little Nightmares 3 and enables the recovery mechanism that sets PC to LR when detecting null pointer execution loops. Signed-off-by: Zephyron --- src/citron/util/title_ids.h | 4 +++- src/core/hle/kernel/physical_core.cpp | 5 ++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/citron/util/title_ids.h b/src/citron/util/title_ids.h index 7f1c26754..049fc3081 100644 --- a/src/citron/util/title_ids.h +++ b/src/citron/util/title_ids.h @@ -14,7 +14,9 @@ private: public: static constexpr u64 FinalFantasyTactics = 0x010038B015560000ULL; - static constexpr u64 LittleNightmares3 = 0x010066101A55A800ULL || 0x010066101A55A000ULL; + // Base title ID for Little Nightmares 3 (covers both 0x010066101A55A800 and 0x010066101A55A000) + // The base title ID is obtained by masking with 0xFFFFFFFFFFFFE000 + static constexpr u64 LittleNightmares3Base = 0x010066101A55A000ULL; }; } // namespace UICommon diff --git a/src/core/hle/kernel/physical_core.cpp b/src/core/hle/kernel/physical_core.cpp index 69db3790d..31cd74c5f 100644 --- a/src/core/hle/kernel/physical_core.cpp +++ b/src/core/hle/kernel/physical_core.cpp @@ -6,6 +6,7 @@ #include "citron/util/title_ids.h" #include "core/core.h" #include "core/debugger/debugger.h" +#include "core/file_sys/common_funcs.h" #include "core/hle/kernel/k_process.h" #include "core/hle/kernel/k_thread.h" #include "core/hle/kernel/kernel.h" @@ -136,7 +137,9 @@ void PhysicalCore::RunThread(Kernel::KThread* thread) { // Detect null pointer execution loop (PC in very low memory addresses) // Only apply this recovery fix for Little Nightmares 3 to avoid issues with other games - if (current_pc < 0x1000 && program_id == UICommon::TitleID::LittleNightmares3) { + // Check if the base title ID matches Little Nightmares 3 (covers both base and update variants) + if (current_pc < 0x1000 && + FileSys::GetBaseTitleID(program_id) == UICommon::TitleID::LittleNightmares3Base) { LOG_WARNING(Core_ARM, "Null pointer execution detected at PC={:016X}", current_pc); LOG_WARNING(Core_ARM, "Attempting to recover by returning from invalid function call");