From 9839f3b6cd9ea0d62730edee7db027dde86f6239 Mon Sep 17 00:00:00 2001 From: bunnei Date: Thu, 29 May 2014 20:30:17 -0400 Subject: core: changed time delay before kernel reschedule to "approximate" a screen refresh --- src/core/core.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'src/core/core.cpp') diff --git a/src/core/core.cpp b/src/core/core.cpp index f88bcd704..070f92ed5 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp @@ -9,6 +9,7 @@ #include "core/core.h" #include "core/mem_map.h" #include "core/hw/hw.h" +#include "core/hw/lcd.h" #include "core/arm/disassembler/arm_disasm.h" #include "core/arm/interpreter/arm_interpreter.h" @@ -23,7 +24,7 @@ ARM_Interface* g_sys_core = NULL; ///< ARM11 system (OS) core /// Run the core CPU loop void RunLoop() { for (;;){ - g_app_core->Run(100); + g_app_core->Run(LCD::kFrameTicks / 2); HW::Update(); Kernel::Reschedule(); } @@ -31,9 +32,17 @@ void RunLoop() { /// Step the CPU one instruction void SingleStep() { + static int ticks = 0; + g_app_core->Step(); - HW::Update(); - Kernel::Reschedule(); + + if (ticks >= LCD::kFrameTicks / 2) { + HW::Update(); + Kernel::Reschedule(); + ticks = 0; + } else { + ticks++; + } } /// Halt the core -- cgit v1.2.3 From 174cc9a0ed023ca89420fbc999ed82337cc94b8b Mon Sep 17 00:00:00 2001 From: bunnei Date: Thu, 5 Jun 2014 00:26:48 -0400 Subject: hle: added a hokey way to force a thread reschedule during CPU single step mode (as used by the debugger) --- src/core/core.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/core/core.cpp') diff --git a/src/core/core.cpp b/src/core/core.cpp index 070f92ed5..0500394b3 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp @@ -13,6 +13,7 @@ #include "core/arm/disassembler/arm_disasm.h" #include "core/arm/interpreter/arm_interpreter.h" +#include "core/hle/hle.h" #include "core/hle/kernel/thread.h" namespace Core { @@ -36,7 +37,7 @@ void SingleStep() { g_app_core->Step(); - if (ticks >= LCD::kFrameTicks / 2) { + if ((ticks >= LCD::kFrameTicks / 2) || HLE::g_reschedule) { HW::Update(); Kernel::Reschedule(); ticks = 0; -- cgit v1.2.3 From 3449aaa35066b9a4bd784fe86a303666713076bf Mon Sep 17 00:00:00 2001 From: bunnei Date: Thu, 5 Jun 2014 23:32:02 -0400 Subject: Core: Changed HW update/thread reschedule to occur more frequently (assume each instruction is ~3 cycles) --- src/core/core.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/core/core.cpp') diff --git a/src/core/core.cpp b/src/core/core.cpp index 0500394b3..6ec25fdd4 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp @@ -25,7 +25,7 @@ ARM_Interface* g_sys_core = NULL; ///< ARM11 system (OS) core /// Run the core CPU loop void RunLoop() { for (;;){ - g_app_core->Run(LCD::kFrameTicks / 2); + g_app_core->Run(LCD::kFrameTicks / 3); HW::Update(); Kernel::Reschedule(); } @@ -37,7 +37,7 @@ void SingleStep() { g_app_core->Step(); - if ((ticks >= LCD::kFrameTicks / 2) || HLE::g_reschedule) { + if ((ticks >= LCD::kFrameTicks / 3) || HLE::g_reschedule) { HW::Update(); Kernel::Reschedule(); ticks = 0; -- cgit v1.2.3 From 0deeda54eefb18aaf6a62b8ec139cfe9bd21769c Mon Sep 17 00:00:00 2001 From: bunnei Date: Fri, 6 Jun 2014 00:06:33 -0400 Subject: Core: Cleaned up SingleStep(), updated default LCD refresh to assume each instruction is ~3 cycles --- src/core/core.cpp | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'src/core/core.cpp') diff --git a/src/core/core.cpp b/src/core/core.cpp index 6ec25fdd4..26d52f7be 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp @@ -18,14 +18,15 @@ namespace Core { -ARM_Disasm* g_disasm = NULL; ///< ARM disassembler -ARM_Interface* g_app_core = NULL; ///< ARM11 application core -ARM_Interface* g_sys_core = NULL; ///< ARM11 system (OS) core +u64 g_last_ticks = 0; ///< Last CPU ticks +ARM_Disasm* g_disasm = NULL; ///< ARM disassembler +ARM_Interface* g_app_core = NULL; ///< ARM11 application core +ARM_Interface* g_sys_core = NULL; ///< ARM11 system (OS) core /// Run the core CPU loop void RunLoop() { for (;;){ - g_app_core->Run(LCD::kFrameTicks / 3); + g_app_core->Run(LCD::kFrameTicks); HW::Update(); Kernel::Reschedule(); } @@ -33,16 +34,14 @@ void RunLoop() { /// Step the CPU one instruction void SingleStep() { - static int ticks = 0; - g_app_core->Step(); - - if ((ticks >= LCD::kFrameTicks / 3) || HLE::g_reschedule) { + + // Update and reschedule after approx. 1 frame + u64 current_ticks = Core::g_app_core->GetTicks(); + if ((current_ticks - g_last_ticks) >= LCD::kFrameTicks || HLE::g_reschedule) { + g_last_ticks = current_ticks; HW::Update(); Kernel::Reschedule(); - ticks = 0; - } else { - ticks++; } } @@ -64,6 +63,8 @@ int Init() { g_app_core = new ARM_Interpreter(); g_sys_core = new ARM_Interpreter(); + g_last_ticks = Core::g_app_core->GetTicks(); + return 0; } -- cgit v1.2.3 From c95972275e276abe3afcac79d956ea29a0879c8e Mon Sep 17 00:00:00 2001 From: bunnei Date: Fri, 6 Jun 2014 00:35:49 -0400 Subject: HLE: Updated all uses of NULL to nullptr (to be C++11 compliant) --- src/core/core.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/core/core.cpp') diff --git a/src/core/core.cpp b/src/core/core.cpp index 26d52f7be..d366498a5 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp @@ -18,10 +18,10 @@ namespace Core { -u64 g_last_ticks = 0; ///< Last CPU ticks -ARM_Disasm* g_disasm = NULL; ///< ARM disassembler -ARM_Interface* g_app_core = NULL; ///< ARM11 application core -ARM_Interface* g_sys_core = NULL; ///< ARM11 system (OS) core +u64 g_last_ticks = 0; ///< Last CPU ticks +ARM_Disasm* g_disasm = nullptr; ///< ARM disassembler +ARM_Interface* g_app_core = nullptr; ///< ARM11 application core +ARM_Interface* g_sys_core = nullptr; ///< ARM11 system (OS) core /// Run the core CPU loop void RunLoop() { -- cgit v1.2.3