From 18c1c39d5e3c096fdcfafa38487f735501c543fb Mon Sep 17 00:00:00 2001 From: Yuri Kunde Schlesner Date: Tue, 25 Aug 2015 23:47:29 -0300 Subject: SVC: Advance time when calling GetSystemTick to escape busy-wait loops Cubic Ninja waited for the frame to end by spinning on a loop calling GetSystemTick while doing nothing else. Since GetSystemTick doesn't cause a reschedule (which advances time), this meant that very little emulated time would pass inside that loop, causing the game to spend most of the frame burning away CPU. --- src/core/hle/svc.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/core/hle/svc.cpp b/src/core/hle/svc.cpp index 19f750d72..45d5f3c5d 100644 --- a/src/core/hle/svc.cpp +++ b/src/core/hle/svc.cpp @@ -755,7 +755,10 @@ static void SleepThread(s64 nanoseconds) { /// This returns the total CPU ticks elapsed since the CPU was powered-on static s64 GetSystemTick() { - return (s64)CoreTiming::GetTicks(); + s64 result = CoreTiming::GetTicks(); + // Advance time to defeat dumb games (like Cubic Ninja) that busy-wait for the frame to end. + Core::g_app_core->AddTicks(150); // Measured time between two calls on a 9.2 o3DS with Ninjhax 1.1b + return result; } /// Creates a memory block at the specified address with the specified permissions and size -- cgit v1.2.3