diff --git a/Source/Core/Core/CoreTiming.cpp b/Source/Core/Core/CoreTiming.cpp index 7479d03922..a7b390c4d0 100644 --- a/Source/Core/Core/CoreTiming.cpp +++ b/Source/Core/Core/CoreTiming.cpp @@ -232,7 +232,7 @@ u64 GetIdleTicks() // This is to be called when outside threads, such as the graphics thread, wants to // schedule things to be executed on the main thread. -void ScheduleEvent_Threadsafe(int cyclesIntoFuture, int event_type, u64 userdata) +void ScheduleEvent_Threadsafe(s64 cyclesIntoFuture, int event_type, u64 userdata) { _assert_msg_(POWERPC, !Core::IsCPUThread(), "ScheduleEvent_Threadsafe from wrong thread"); if (Core::g_want_determinism) @@ -271,7 +271,7 @@ void ScheduleEvent_Threadsafe_Immediate(int event_type, u64 userdata) } // To be used from any thread, including the CPU thread -void ScheduleEvent_AnyThread(int cyclesIntoFuture, int event_type, u64 userdata) +void ScheduleEvent_AnyThread(s64 cyclesIntoFuture, int event_type, u64 userdata) { if (Core::IsCPUThread()) ScheduleEvent(cyclesIntoFuture, event_type, userdata); @@ -310,7 +310,7 @@ static void AddEventToQueue(Event* ne) // This must be run ONLY from within the CPU thread // cyclesIntoFuture may be VERY inaccurate if called from anything else // than Advance -void ScheduleEvent(int cyclesIntoFuture, int event_type, u64 userdata) +void ScheduleEvent(s64 cyclesIntoFuture, int event_type, u64 userdata) { _assert_msg_(POWERPC, Core::IsCPUThread() || Core::GetState() == Core::CORE_PAUSE, "ScheduleEvent from wrong thread"); @@ -363,12 +363,13 @@ void RemoveAllEvents(int event_type) RemoveEvent(event_type); } -void ForceExceptionCheck(int cycles) +void ForceExceptionCheck(s64 cycles) { - if (DowncountToCycles(PowerPC::ppcState.downcount) > cycles) + if (s64(DowncountToCycles(PowerPC::ppcState.downcount)) > cycles) { - slicelength -= (DowncountToCycles(PowerPC::ppcState.downcount) - cycles); // Account for cycles already executed by adjusting the slicelength - PowerPC::ppcState.downcount = CyclesToDowncount(cycles); + // downcount is always (much) smaller than MAX_INT so we can safely cast cycles to an int here. + slicelength -= (DowncountToCycles(PowerPC::ppcState.downcount) - (int)cycles); // Account for cycles already executed by adjusting the g_slicelength + PowerPC::ppcState.downcount = CyclesToDowncount((int)cycles); } } diff --git a/Source/Core/Core/CoreTiming.h b/Source/Core/Core/CoreTiming.h index 287ea38ccc..066ef6ae29 100644 --- a/Source/Core/Core/CoreTiming.h +++ b/Source/Core/Core/CoreTiming.h @@ -45,11 +45,11 @@ int RegisterEvent(const std::string& name, TimedCallback callback); void UnregisterAllEvents(); // userdata MAY NOT CONTAIN POINTERS. userdata might get written and reloaded from savestates. -void ScheduleEvent(int cyclesIntoFuture, int event_type, u64 userdata = 0); +void ScheduleEvent(s64 cyclesIntoFuture, int event_type, u64 userdata = 0); void ScheduleEvent_Immediate(int event_type, u64 userdata = 0); -void ScheduleEvent_Threadsafe(int cyclesIntoFuture, int event_type, u64 userdata = 0); +void ScheduleEvent_Threadsafe(s64 cyclesIntoFuture, int event_type, u64 userdata = 0); void ScheduleEvent_Threadsafe_Immediate(int event_type, u64 userdata = 0); -void ScheduleEvent_AnyThread(int cyclesIntoFuture, int event_type, u64 userdata = 0); +void ScheduleEvent_AnyThread(s64 cyclesIntoFuture, int event_type, u64 userdata = 0); // We only permit one event of each type in the queue at a time. void RemoveEvent(int event_type); @@ -77,7 +77,7 @@ void SetFakeTBStartValue(u64 val); u64 GetFakeTBStartTicks(); void SetFakeTBStartTicks(u64 val); -void ForceExceptionCheck(int cycles); +void ForceExceptionCheck(s64 cycles); extern int slicelength; extern float lastOCFactor;