summaryrefslogtreecommitdiff
path: root/plugins/peopsxgl
diff options
context:
space:
mode:
authoriCatButler <i.am.catbutler@gmail.com>2016-03-30 15:07:35 +0100
committeriCatButler <i.am.catbutler@gmail.com>2016-03-30 15:07:35 +0100
commit8b4350fee747708ffd376744ef5dc1e239a87ba6 (patch)
treea9ab6e2f25e06edc7c668353f8000856704f7fa3 /plugins/peopsxgl
parente3df273095a5800e3dcdcb63bd66e269c0c2d3a8 (diff)
downloadpcsxr-8b4350fee747708ffd376744ef5dc1e239a87ba6.tar.gz
Bring up to date with PCSX-R master (97809)
Diffstat (limited to 'plugins/peopsxgl')
-rwxr-xr-xplugins/peopsxgl/fps.c49
1 files changed, 39 insertions, 10 deletions
diff --git a/plugins/peopsxgl/fps.c b/plugins/peopsxgl/fps.c
index 32eeb4c6..5b9f7449 100755
--- a/plugins/peopsxgl/fps.c
+++ b/plugins/peopsxgl/fps.c
@@ -36,6 +36,7 @@
BOOL bIsPerformanceCounter=FALSE;
float fFrameRateHz=0;
+float speed=1;
DWORD dwFrameRateTicks=16;
float fFrameRate;
int iFrameLimit;
@@ -64,7 +65,9 @@ void FrameCap(void)
{
static unsigned long curticks, lastticks, _ticks_since_last_update;
static unsigned long TicksToWait = 0;
+ double remTime;
bool Waiting = TRUE;
+ DWORD frTicks=(DWORD)(dwFrameRateTicks / speed);
{
curticks = timeGetTime();
@@ -75,9 +78,9 @@ void FrameCap(void)
{
lastticks = curticks;
- if((_ticks_since_last_update-TicksToWait) > dwFrameRateTicks)
+ if((_ticks_since_last_update-TicksToWait) > frTicks)
TicksToWait=0;
- else TicksToWait=dwFrameRateTicks-(_ticks_since_last_update-TicksToWait);
+ else TicksToWait=frTicks-(_ticks_since_last_update-TicksToWait);
}
else
{
@@ -85,13 +88,18 @@ void FrameCap(void)
{
curticks = timeGetTime();
_ticks_since_last_update = curticks - lastticks;
+ remTime = (TicksToWait - _ticks_since_last_update) * 1e6 / TIMEBASE;
if ((_ticks_since_last_update > TicksToWait) ||
(curticks < lastticks))
{
Waiting = FALSE;
lastticks = curticks;
- TicksToWait = dwFrameRateTicks;
+ TicksToWait = frTicks;
}
+ else if (remTime > 2)
+ {
+ usleep(remTime - 2);
+ }
}
}
}
@@ -105,9 +113,15 @@ void FrameSkip(void)
static int iNumSkips=0,iAdditionalSkip=0; // number of additional frames to skip
static DWORD dwLastLace=0; // helper var for frame limitation
static DWORD curticks, lastticks, _ticks_since_last_update;
+ DWORD frTicks=(DWORD)(dwFrameRateTicks / speed);
+ double remTime;
+ DWORD maxSkipTicks = 0;
if(!dwLaceCnt) return; // important: if no updatelace happened, we ignore it completely
+ if (speed > 1) {
+ maxSkipTicks = 1/30. * TIMEBASE;
+ }
if(iNumSkips) // we are in skipping mode?
{
dwLastLace+=dwLaceCnt; // -> calc frame limit helper (number of laces)
@@ -128,23 +142,28 @@ void FrameSkip(void)
curticks = timeGetTime();
_ticks_since_last_update= dwT+curticks - lastticks;
- dwWaitTime=dwLastLace*dwFrameRateTicks; // -> and now we calc the time the real psx would have needed
+ dwWaitTime=dwLastLace*frTicks; // -> and now we calc the time the real psx would have needed
if(_ticks_since_last_update<dwWaitTime) // -> we were too fast?
{
if((dwWaitTime-_ticks_since_last_update)> // -> some more security, to prevent
- (60*dwFrameRateTicks)) // wrong waiting times
+ (60*frTicks)) // wrong waiting times
_ticks_since_last_update=dwWaitTime;
while(_ticks_since_last_update<dwWaitTime) // -> loop until we have reached the real psx time
{ // (that's the additional limitation, yup)
+ remTime = (dwWaitTime - _ticks_since_last_update) * 1e6 / TIMEBASE;
+ if (remTime > 2) {
+ usleep(remTime - 2);
+ }
curticks = timeGetTime();
_ticks_since_last_update = dwT+curticks - lastticks;
}
}
else // we were still too slow ?!!?
{
- if(iAdditionalSkip<MAXSKIP) // -> well, somewhen we really have to stop skipping on very slow systems
+ if(iAdditionalSkip<MAXSKIP &&
+ _ticks_since_last_update<maxSkipTicks) // -> well, somewhen we really have to stop skipping on very slow systems
{
iAdditionalSkip++; // -> inc our watchdog var
dwLaceCnt=0; // -> reset lace count
@@ -170,7 +189,7 @@ void FrameSkip(void)
_ticks_since_last_update = curticks - lastticks;
dwLastLace=dwLaceCnt; // store curr count (frame limitation helper)
- dwWaitTime=dwLaceCnt*dwFrameRateTicks; // calc the 'real psx lace time'
+ dwWaitTime=dwLaceCnt*frTicks; // calc the 'real psx lace time'
if(_ticks_since_last_update>dwWaitTime) // hey, we needed way too long for that frame...
{
@@ -194,6 +213,10 @@ void FrameSkip(void)
while(_ticks_since_last_update<dwWaitTime) // just do a waiting loop...
{
+ remTime = (dwWaitTime - _ticks_since_last_update) * 1e6 / TIMEBASE;
+ if (remTime > 2) {
+ usleep(remTime - 2);
+ }
curticks = timeGetTime();
_ticks_since_last_update = curticks - lastticks;
}
@@ -247,8 +270,8 @@ void calcfps(void)
fps_cnt = 0;
fps_tck = 1;
- if(bUseFrameLimit && fps_cur>fFrameRateHz) // optical adjust ;) avoids flickering fps display
- fps_cur=fFrameRateHz;
+ if(bUseFrameLimit && fps_cur>fFrameRateHz * speed) // optical adjust ;) avoids flickering fps display
+ fps_cur=fFrameRateHz * speed;
}
}
@@ -267,7 +290,7 @@ void PCFrameCap (void)
{
Waiting = FALSE;
lastticks = curticks;
- TicksToWait = (TIMEBASE / (unsigned long)fFrameRateHz);
+ TicksToWait = (TIMEBASE / (unsigned long)(fFrameRateHz * speed));
}
}
}
@@ -380,6 +403,12 @@ void CheckFrameRate(void) // called in updatelace (
}
}
+void CALLBACK GPUsetSpeed(float newSpeed) {
+ if (newSpeed > 0 && newSpeed <= 1000) {
+ speed = newSpeed;
+ }
+}
+
void CALLBACK GPUsetframelimit(unsigned long option) // new EPSXE interface func: main emu can enable/disable fps limitation this way
{
bInitCap = TRUE;