From 85a41cba46d8ae497914679de8cd4097a81b7ca1 Mon Sep 17 00:00:00 2001 From: Zephyron Date: Mon, 10 Nov 2025 20:00:55 +1000 Subject: [PATCH] Fix: Make PC return recovery title-specific for Little Nightmares 3 The PC < 0x1000 recovery mechanism introduced in commit fbb4f5c0 was causing issues for other games. This change restricts the recovery to only apply when the title ID matches Little Nightmares 3. - Add LittleNightmares3 title ID constant to title_ids.h - Check program ID before applying PC return recovery in physical_core.cpp - Recovery now only triggers for Little Nightmares 3 (010066101A55A800) to avoid affecting other games Fixes issues caused by the general PC return recovery in other titles. Signed-off-by: Zephyron --- src/citron/util/title_ids.h | 1 + src/core/hle/kernel/physical_core.cpp | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/citron/util/title_ids.h b/src/citron/util/title_ids.h index b6671a7d0..ddbe4756c 100644 --- a/src/citron/util/title_ids.h +++ b/src/citron/util/title_ids.h @@ -14,6 +14,7 @@ private: public: static constexpr u64 FinalFantasyTactics = 0x010038B015560000ULL; + static constexpr u64 LittleNightmares3 = 0x010066101A55A800ULL; }; } // namespace UICommon diff --git a/src/core/hle/kernel/physical_core.cpp b/src/core/hle/kernel/physical_core.cpp index 9d826e243..69db3790d 100644 --- a/src/core/hle/kernel/physical_core.cpp +++ b/src/core/hle/kernel/physical_core.cpp @@ -3,6 +3,7 @@ #include "common/scope_exit.h" #include "common/settings.h" +#include "citron/util/title_ids.h" #include "core/core.h" #include "core/debugger/debugger.h" #include "core/hle/kernel/k_process.h" @@ -130,8 +131,12 @@ void PhysicalCore::RunThread(Kernel::KThread* thread) { interface->GetContext(ctx); u64 current_pc = ctx.pc; + // Get the program ID (title ID) to check if this fix should apply + u64 program_id = process->GetProgramId(); + // Detect null pointer execution loop (PC in very low memory addresses) - if (current_pc < 0x1000) { + // Only apply this recovery fix for Little Nightmares 3 to avoid issues with other games + if (current_pc < 0x1000 && program_id == UICommon::TitleID::LittleNightmares3) { 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");