fiddle around with sdl frameadvance throttle
This commit is contained in:
parent
aa90b868a1
commit
7bcc8a67f3
|
@ -11,7 +11,9 @@ static const double Normal = 1.0; // 1x speed (around 60 fps on NTSC)
|
||||||
static uint64 Lasttime, Nexttime;
|
static uint64 Lasttime, Nexttime;
|
||||||
static long double desired_frametime;
|
static long double desired_frametime;
|
||||||
static int InFrame;
|
static int InFrame;
|
||||||
double g_fpsScale = Normal; // used by sdl.cpp
|
double fps_scale = Normal; // used by sdl.cpp
|
||||||
|
double fps_scale_frameadvance = Normal;
|
||||||
|
double fps_scale_unpaused = Normal;
|
||||||
bool MaxSpeed = false;
|
bool MaxSpeed = false;
|
||||||
|
|
||||||
/* LOGMUL = exp(log(2) / 3)
|
/* LOGMUL = exp(log(2) / 3)
|
||||||
|
@ -31,7 +33,7 @@ void
|
||||||
RefreshThrottleFPS()
|
RefreshThrottleFPS()
|
||||||
{
|
{
|
||||||
uint64 fps = FCEUI_GetDesiredFPS(); // Do >> 24 to get in Hz
|
uint64 fps = FCEUI_GetDesiredFPS(); // Do >> 24 to get in Hz
|
||||||
desired_frametime = 16777216.0l / (fps * g_fpsScale);
|
desired_frametime = 16777216.0l / (fps * fps_scale);
|
||||||
|
|
||||||
Lasttime=0;
|
Lasttime=0;
|
||||||
Nexttime=0;
|
Nexttime=0;
|
||||||
|
@ -44,7 +46,7 @@ RefreshThrottleFPS()
|
||||||
int
|
int
|
||||||
SpeedThrottle()
|
SpeedThrottle()
|
||||||
{
|
{
|
||||||
if(g_fpsScale >= 32)
|
if(fps_scale >= 32)
|
||||||
{
|
{
|
||||||
return 0; /* Done waiting */
|
return 0; /* Done waiting */
|
||||||
}
|
}
|
||||||
|
@ -92,13 +94,15 @@ SpeedThrottle()
|
||||||
*/
|
*/
|
||||||
void IncreaseEmulationSpeed(void)
|
void IncreaseEmulationSpeed(void)
|
||||||
{
|
{
|
||||||
g_fpsScale *= LOGMUL;
|
fps_scale_unpaused *= LOGMUL;
|
||||||
|
|
||||||
if(g_fpsScale > Fastest) g_fpsScale = Fastest;
|
if(fps_scale_unpaused > Fastest) fps_scale_unpaused = Fastest;
|
||||||
|
|
||||||
|
fps_scale = fps_scale_unpaused;
|
||||||
|
|
||||||
RefreshThrottleFPS();
|
RefreshThrottleFPS();
|
||||||
|
|
||||||
FCEU_DispMessage("Emulation speed %.1f%%",0, g_fpsScale*100.0);
|
FCEU_DispMessage("Emulation speed %.1f%%",0, fps_scale*100.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -106,9 +110,11 @@ void IncreaseEmulationSpeed(void)
|
||||||
*/
|
*/
|
||||||
void DecreaseEmulationSpeed(void)
|
void DecreaseEmulationSpeed(void)
|
||||||
{
|
{
|
||||||
g_fpsScale /= LOGMUL;
|
fps_scale_unpaused /= LOGMUL;
|
||||||
if(g_fpsScale < Slowest)
|
if(fps_scale_unpaused < Slowest)
|
||||||
g_fpsScale = Slowest;
|
fps_scale_unpaused = Slowest;
|
||||||
|
|
||||||
|
fps_scale = fps_scale_unpaused;
|
||||||
|
|
||||||
RefreshThrottleFPS();
|
RefreshThrottleFPS();
|
||||||
|
|
||||||
|
@ -125,19 +131,19 @@ FCEUD_SetEmulationSpeed(int cmd)
|
||||||
|
|
||||||
switch(cmd) {
|
switch(cmd) {
|
||||||
case EMUSPEED_SLOWEST:
|
case EMUSPEED_SLOWEST:
|
||||||
g_fpsScale = Slowest;
|
fps_scale_unpaused = Slowest;
|
||||||
break;
|
break;
|
||||||
case EMUSPEED_SLOWER:
|
case EMUSPEED_SLOWER:
|
||||||
DecreaseEmulationSpeed();
|
DecreaseEmulationSpeed();
|
||||||
break;
|
break;
|
||||||
case EMUSPEED_NORMAL:
|
case EMUSPEED_NORMAL:
|
||||||
g_fpsScale = Normal;
|
fps_scale_unpaused = Normal;
|
||||||
break;
|
break;
|
||||||
case EMUSPEED_FASTER:
|
case EMUSPEED_FASTER:
|
||||||
IncreaseEmulationSpeed();
|
IncreaseEmulationSpeed();
|
||||||
break;
|
break;
|
||||||
case EMUSPEED_FASTEST:
|
case EMUSPEED_FASTEST:
|
||||||
g_fpsScale = Fastest;
|
fps_scale_unpaused = Fastest;
|
||||||
MaxSpeed = true;
|
MaxSpeed = true;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -48,8 +48,9 @@
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
|
||||||
|
extern double fps_scale;
|
||||||
extern double g_fpsScale;
|
extern double fps_scale_frameadvance;
|
||||||
|
extern double fps_scale_unpaused;
|
||||||
|
|
||||||
extern bool MaxSpeed;
|
extern bool MaxSpeed;
|
||||||
|
|
||||||
|
@ -402,14 +403,14 @@ FCEUD_Update(uint8 *XBuf,
|
||||||
|
|
||||||
int ocount = Count;
|
int ocount = Count;
|
||||||
// apply frame scaling to Count
|
// apply frame scaling to Count
|
||||||
Count = (int)(Count / g_fpsScale);
|
Count = (int)(Count / fps_scale);
|
||||||
if(Count) {
|
if(Count) {
|
||||||
int32 can=GetWriteSound();
|
int32 can=GetWriteSound();
|
||||||
static int uflow=0;
|
static int uflow=0;
|
||||||
int32 tmpcan;
|
int32 tmpcan;
|
||||||
|
|
||||||
// don't underflow when scaling fps
|
// don't underflow when scaling fps
|
||||||
if(can >= GetMaxSound() && g_fpsScale==1.0) uflow=1; /* Go into massive underflow mode. */
|
if(can >= GetMaxSound() && fps_scale==1.0) uflow=1; /* Go into massive underflow mode. */
|
||||||
|
|
||||||
if(can > Count) can=Count;
|
if(can > Count) can=Count;
|
||||||
else uflow=0;
|
else uflow=0;
|
||||||
|
@ -422,7 +423,7 @@ FCEUD_Update(uint8 *XBuf,
|
||||||
//if(uflow) puts("Underflow");
|
//if(uflow) puts("Underflow");
|
||||||
tmpcan = GetWriteSound();
|
tmpcan = GetWriteSound();
|
||||||
// don't underflow when scaling fps
|
// don't underflow when scaling fps
|
||||||
if(g_fpsScale>1.0 || ((tmpcan < Count*0.90) && !uflow)) {
|
if(fps_scale>1.0 || ((tmpcan < Count*0.90) && !uflow)) {
|
||||||
if(XBuf && (inited&4) && !(NoWaiting & 2))
|
if(XBuf && (inited&4) && !(NoWaiting & 2))
|
||||||
BlitScreen(XBuf);
|
BlitScreen(XBuf);
|
||||||
Buffer+=can;
|
Buffer+=can;
|
||||||
|
|
|
@ -52,11 +52,11 @@ extern void CDLoggerROMChanged();
|
||||||
extern void ResetDebugStatisticsCounters();
|
extern void ResetDebugStatisticsCounters();
|
||||||
extern void SetMainWindowText();
|
extern void SetMainWindowText();
|
||||||
extern bool isTaseditorRecording();
|
extern bool isTaseditorRecording();
|
||||||
|
#endif
|
||||||
|
|
||||||
extern int32 fps_scale;
|
extern int32 fps_scale;
|
||||||
extern int32 fps_scale_unpaused;
|
extern int32 fps_scale_unpaused;
|
||||||
extern int32 fps_scale_frameadvance;
|
extern int32 fps_scale_frameadvance;
|
||||||
#endif
|
|
||||||
extern void RefreshThrottleFPS();
|
extern void RefreshThrottleFPS();
|
||||||
|
|
||||||
#ifdef _S9XLUA_H
|
#ifdef _S9XLUA_H
|
||||||
|
@ -643,24 +643,20 @@ void FCEUI_Emulate(uint8 **pXBuf, int32 **SoundBuf, int32 *SoundBufSize, int ski
|
||||||
// the user is holding Frame Advance key
|
// the user is holding Frame Advance key
|
||||||
// clear paused flag temporarily
|
// clear paused flag temporarily
|
||||||
EmulationPaused &= ~EMULATIONPAUSED_PAUSED;
|
EmulationPaused &= ~EMULATIONPAUSED_PAUSED;
|
||||||
#ifdef WIN32
|
|
||||||
// different emulation speed when holding Frame Advance
|
// different emulation speed when holding Frame Advance
|
||||||
if (fps_scale_frameadvance > 0)
|
if (fps_scale_frameadvance > 0)
|
||||||
{
|
{
|
||||||
fps_scale = fps_scale_frameadvance;
|
fps_scale = fps_scale_frameadvance;
|
||||||
RefreshThrottleFPS();
|
RefreshThrottleFPS();
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
#ifdef WIN32
|
|
||||||
if (fps_scale_frameadvance > 0)
|
if (fps_scale_frameadvance > 0)
|
||||||
{
|
{
|
||||||
// restore emulation speed when Frame Advance is not held
|
// restore emulation speed when Frame Advance is not held
|
||||||
fps_scale = fps_scale_unpaused;
|
fps_scale = fps_scale_unpaused;
|
||||||
RefreshThrottleFPS();
|
RefreshThrottleFPS();
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
if (EmulationPaused & EMULATIONPAUSED_PAUSED)
|
if (EmulationPaused & EMULATIONPAUSED_PAUSED)
|
||||||
{
|
{
|
||||||
// emulator is paused
|
// emulator is paused
|
||||||
|
|
Loading…
Reference in New Issue