mirror of https://github.com/PCSX2/pcsx2.git
Timer: Add ResetIfNPassed()
This commit is contained in:
parent
5555e334af
commit
25a3ea98bc
|
@ -1,5 +1,5 @@
|
||||||
/* PCSX2 - PS2 Emulator for PCs
|
/* 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
|
* 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-
|
* of the GNU Lesser General Public License as published by the Free Software Found-
|
||||||
|
@ -163,4 +163,38 @@ namespace Common
|
||||||
m_tvStartValue = value;
|
m_tvStartValue = value;
|
||||||
return ret;
|
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
|
} // namespace Common
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/* PCSX2 - PS2 Emulator for PCs
|
/* 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
|
* 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-
|
* of the GNU Lesser General Public License as published by the Free Software Found-
|
||||||
|
@ -46,6 +46,10 @@ namespace Common
|
||||||
double GetTimeMillisecondsAndReset();
|
double GetTimeMillisecondsAndReset();
|
||||||
double GetTimeNanosecondsAndReset();
|
double GetTimeNanosecondsAndReset();
|
||||||
|
|
||||||
|
bool ResetIfSecondsPassed(double s);
|
||||||
|
bool ResetIfMillisecondsPassed(double s);
|
||||||
|
bool ResetIfNanosecondsPassed(double s);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Value m_tvStartValue;
|
Value m_tvStartValue;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue