diff --git a/src/core/save_state_version.h b/src/core/save_state_version.h index 215b4ea00..5e17ec4a0 100644 --- a/src/core/save_state_version.h +++ b/src/core/save_state_version.h @@ -2,7 +2,7 @@ #include "types.h" static constexpr u32 SAVE_STATE_MAGIC = 0x43435544; -static constexpr u32 SAVE_STATE_VERSION = 42; +static constexpr u32 SAVE_STATE_VERSION = 43; static constexpr u32 SAVE_STATE_MINIMUM_VERSION = 42; #pragma pack(push, 4) diff --git a/src/core/system.cpp b/src/core/system.cpp index fd07881eb..04ce5618d 100644 --- a/src/core/system.cpp +++ b/src/core/system.cpp @@ -93,7 +93,7 @@ static float s_worst_frame_time = 0.0f; static float s_average_frame_time = 0.0f; static u32 s_last_frame_number = 0; static u32 s_last_internal_frame_number = 0; -static u32 s_last_global_tick_counter = 0; +static u64 s_last_global_tick_counter = 0; static Common::Timer s_fps_timer; static Common::Timer s_frame_timer; @@ -1229,7 +1229,7 @@ void UpdatePerformanceCounters() return; const float frames_presented = static_cast(s_frame_number - s_last_frame_number); - const u32 global_tick_counter = TimingEvents::GetGlobalTickCounter(); + const u64 global_tick_counter = TimingEvents::GetGlobalTickCounter(); s_worst_frame_time = s_worst_frame_time_accumulator; s_worst_frame_time_accumulator = 0.0f; diff --git a/src/core/timing_event.cpp b/src/core/timing_event.cpp index 8197eff80..bc6dfd1b9 100644 --- a/src/core/timing_event.cpp +++ b/src/core/timing_event.cpp @@ -12,10 +12,10 @@ static TimingEvent* s_active_events_head; static TimingEvent* s_active_events_tail; static TimingEvent* s_current_event = nullptr; static u32 s_active_event_count = 0; -static u32 s_global_tick_counter = 0; -static u32 s_last_event_run_time = 0; +static u64 s_global_tick_counter = 0; +static u64 s_last_event_run_time = 0; -u32 GetGlobalTickCounter() +u64 GetGlobalTickCounter() { return s_global_tick_counter; } @@ -255,7 +255,8 @@ void RunEvents() { DebugAssert(!s_current_event); - TickCount pending_ticks = (s_global_tick_counter + CPU::GetPendingTicks()) - s_last_event_run_time; + TickCount pending_ticks = + static_cast((s_global_tick_counter + static_cast(CPU::GetPendingTicks())) - s_last_event_run_time); CPU::ResetPendingTicks(); while (pending_ticks > 0) { @@ -298,7 +299,16 @@ void RunEvents() bool DoState(StateWrapper& sw) { - sw.Do(&s_global_tick_counter); + if (sw.IsReading() && sw.GetVersion() < 43) + { + u32 global_tick_counter32; + sw.Do(&global_tick_counter32); + s_global_tick_counter = ZeroExtend64(global_tick_counter32); + } + else + { + sw.Do(&s_global_tick_counter); + } if (sw.IsReading()) { @@ -333,7 +343,16 @@ bool DoState(StateWrapper& sw) event->m_interval = interval; } - sw.Do(&s_last_event_run_time); + if (sw.GetVersion() < 43) + { + u32 last_event_run_time32; + sw.Do(&last_event_run_time32); + s_last_event_run_time = ZeroExtend64(last_event_run_time32); + } + else + { + sw.Do(&s_last_event_run_time); + } Log_DevPrintf("Loaded %u events from save state.", event_count); SortEvents(); diff --git a/src/core/timing_event.h b/src/core/timing_event.h index ca58ddbdf..758245dd0 100644 --- a/src/core/timing_event.h +++ b/src/core/timing_event.h @@ -71,7 +71,7 @@ public: namespace TimingEvents { -u32 GetGlobalTickCounter(); +u64 GetGlobalTickCounter(); void Initialize(); void Reset();