diff --git a/common/Timer.cpp b/common/Timer.cpp index c54d395a18..f914fbc7c7 100644 --- a/common/Timer.cpp +++ b/common/Timer.cpp @@ -1,5 +1,5 @@ /* PCSX2 - PS2 Emulator for PCs - * Copyright (C) 2002-2021 PCSX2 Dev Team + * Copyright (C) 2002-2023 PCSX2 Dev Team * * PCSX2 is free software: you can redistribute it and/or modify it under the terms * of the GNU Lesser General Public License as published by the Free Software Found- @@ -163,4 +163,38 @@ namespace Common m_tvStartValue = value; return ret; } + + + bool Timer::ResetIfSecondsPassed(double s) + { + const Value value = GetCurrentValue(); + const double ret = ConvertValueToSeconds(value - m_tvStartValue); + if (ret < s) + return false; + + m_tvStartValue = value; + return true; + } + + bool Timer::ResetIfMillisecondsPassed(double s) + { + const Value value = GetCurrentValue(); + const double ret = ConvertValueToMilliseconds(value - m_tvStartValue); + if (ret < s) + return false; + + m_tvStartValue = value; + return true; + } + + bool Timer::ResetIfNanosecondsPassed(double s) + { + const Value value = GetCurrentValue(); + const double ret = ConvertValueToNanoseconds(value - m_tvStartValue); + if (ret < s) + return false; + + m_tvStartValue = value; + return true; + } } // namespace Common diff --git a/common/Timer.h b/common/Timer.h index df5dad03d7..8c7cf41c2b 100644 --- a/common/Timer.h +++ b/common/Timer.h @@ -1,5 +1,5 @@ /* PCSX2 - PS2 Emulator for PCs - * Copyright (C) 2002-2021 PCSX2 Dev Team + * Copyright (C) 2002-2023 PCSX2 Dev Team * * PCSX2 is free software: you can redistribute it and/or modify it under the terms * of the GNU Lesser General Public License as published by the Free Software Found- @@ -46,6 +46,10 @@ namespace Common double GetTimeMillisecondsAndReset(); double GetTimeNanosecondsAndReset(); + bool ResetIfSecondsPassed(double s); + bool ResetIfMillisecondsPassed(double s); + bool ResetIfNanosecondsPassed(double s); + private: Value m_tvStartValue; };