summaryrefslogtreecommitdiff
path: root/src/core/core_timing.cpp
diff options
context:
space:
mode:
authorGravatar bunnei2016-12-15 19:01:48 -0500
committerGravatar bunnei2016-12-21 23:29:13 -0500
commit232ef55c1a13552e5ba8b72d61d1d072f5851598 (patch)
tree729ee82ded58202888a2c27bdc3beec6ab926768 /src/core/core_timing.cpp
parentfile_util: Remove unused paths. (diff)
downloadyuzu-232ef55c1a13552e5ba8b72d61d1d072f5851598.tar.gz
yuzu-232ef55c1a13552e5ba8b72d61d1d072f5851598.tar.xz
yuzu-232ef55c1a13552e5ba8b72d61d1d072f5851598.zip
core: Consolidate core and system state, remove system module & cleanups.
Diffstat (limited to 'src/core/core_timing.cpp')
-rw-r--r--src/core/core_timing.cpp27
1 files changed, 13 insertions, 14 deletions
diff --git a/src/core/core_timing.cpp b/src/core/core_timing.cpp
index 5220b55ea..9fe374795 100644
--- a/src/core/core_timing.cpp
+++ b/src/core/core_timing.cpp
@@ -130,7 +130,6 @@ int RegisterEvent(const char* name, TimedCallback callback) {
130 130
131static void AntiCrashCallback(u64 userdata, int cycles_late) { 131static void AntiCrashCallback(u64 userdata, int cycles_late) {
132 LOG_CRITICAL(Core_Timing, "Savestate broken: an unregistered event was called."); 132 LOG_CRITICAL(Core_Timing, "Savestate broken: an unregistered event was called.");
133 Core::Halt("invalid timing events");
134} 133}
135 134
136void RestoreRegisterEvent(int event_type, const char* name, TimedCallback callback) { 135void RestoreRegisterEvent(int event_type, const char* name, TimedCallback callback) {
@@ -147,7 +146,7 @@ void UnregisterAllEvents() {
147} 146}
148 147
149void Init() { 148void Init() {
150 Core::g_app_core->down_count = INITIAL_SLICE_LENGTH; 149 Core::AppCore().down_count = INITIAL_SLICE_LENGTH;
151 g_slice_length = INITIAL_SLICE_LENGTH; 150 g_slice_length = INITIAL_SLICE_LENGTH;
152 global_timer = 0; 151 global_timer = 0;
153 idled_cycles = 0; 152 idled_cycles = 0;
@@ -187,7 +186,7 @@ void Shutdown() {
187} 186}
188 187
189u64 GetTicks() { 188u64 GetTicks() {
190 return (u64)global_timer + g_slice_length - Core::g_app_core->down_count; 189 return (u64)global_timer + g_slice_length - Core::AppCore().down_count;
191} 190}
192 191
193u64 GetIdleTicks() { 192u64 GetIdleTicks() {
@@ -461,18 +460,18 @@ void MoveEvents() {
461} 460}
462 461
463void ForceCheck() { 462void ForceCheck() {
464 s64 cycles_executed = g_slice_length - Core::g_app_core->down_count; 463 s64 cycles_executed = g_slice_length - Core::AppCore().down_count;
465 global_timer += cycles_executed; 464 global_timer += cycles_executed;
466 // This will cause us to check for new events immediately. 465 // This will cause us to check for new events immediately.
467 Core::g_app_core->down_count = 0; 466 Core::AppCore().down_count = 0;
468 // But let's not eat a bunch more time in Advance() because of this. 467 // But let's not eat a bunch more time in Advance() because of this.
469 g_slice_length = 0; 468 g_slice_length = 0;
470} 469}
471 470
472void Advance() { 471void Advance() {
473 s64 cycles_executed = g_slice_length - Core::g_app_core->down_count; 472 s64 cycles_executed = g_slice_length - Core::AppCore().down_count;
474 global_timer += cycles_executed; 473 global_timer += cycles_executed;
475 Core::g_app_core->down_count = g_slice_length; 474 Core::AppCore().down_count = g_slice_length;
476 475
477 if (has_ts_events) 476 if (has_ts_events)
478 MoveEvents(); 477 MoveEvents();
@@ -481,7 +480,7 @@ void Advance() {
481 if (!first) { 480 if (!first) {
482 if (g_slice_length < 10000) { 481 if (g_slice_length < 10000) {
483 g_slice_length += 10000; 482 g_slice_length += 10000;
484 Core::g_app_core->down_count += g_slice_length; 483 Core::AppCore().down_count += g_slice_length;
485 } 484 }
486 } else { 485 } else {
487 // Note that events can eat cycles as well. 486 // Note that events can eat cycles as well.
@@ -491,7 +490,7 @@ void Advance() {
491 490
492 const int diff = target - g_slice_length; 491 const int diff = target - g_slice_length;
493 g_slice_length += diff; 492 g_slice_length += diff;
494 Core::g_app_core->down_count += diff; 493 Core::AppCore().down_count += diff;
495 } 494 }
496 if (advance_callback) 495 if (advance_callback)
497 advance_callback(static_cast<int>(cycles_executed)); 496 advance_callback(static_cast<int>(cycles_executed));
@@ -507,12 +506,12 @@ void LogPendingEvents() {
507} 506}
508 507
509void Idle(int max_idle) { 508void Idle(int max_idle) {
510 s64 cycles_down = Core::g_app_core->down_count; 509 s64 cycles_down = Core::AppCore().down_count;
511 if (max_idle != 0 && cycles_down > max_idle) 510 if (max_idle != 0 && cycles_down > max_idle)
512 cycles_down = max_idle; 511 cycles_down = max_idle;
513 512
514 if (first && cycles_down > 0) { 513 if (first && cycles_down > 0) {
515 s64 cycles_executed = g_slice_length - Core::g_app_core->down_count; 514 s64 cycles_executed = g_slice_length - Core::AppCore().down_count;
516 s64 cycles_next_event = first->time - global_timer; 515 s64 cycles_next_event = first->time - global_timer;
517 516
518 if (cycles_next_event < cycles_executed + cycles_down) { 517 if (cycles_next_event < cycles_executed + cycles_down) {
@@ -527,9 +526,9 @@ void Idle(int max_idle) {
527 cycles_down / (float)(g_clock_rate_arm11 * 0.001f)); 526 cycles_down / (float)(g_clock_rate_arm11 * 0.001f));
528 527
529 idled_cycles += cycles_down; 528 idled_cycles += cycles_down;
530 Core::g_app_core->down_count -= cycles_down; 529 Core::AppCore().down_count -= cycles_down;
531 if (Core::g_app_core->down_count == 0) 530 if (Core::AppCore().down_count == 0)
532 Core::g_app_core->down_count = -1; 531 Core::AppCore().down_count = -1;
533} 532}
534 533
535std::string GetScheduledEventsSummary() { 534std::string GetScheduledEventsSummary() {