Removed "Automatic frame skipping" option, will now be activated with throttling

Throttling now uses (actually rapes) the Smooth60FPS functionality, so that throttling is no more skippy.

git-svn-id: https://svn.code.sf.net/p/vbam/code/trunk@239 a31d4220-a93d-0410-bf67-fe4944624d44
This commit is contained in:
spacy51 2007-12-26 16:09:21 +00:00
parent cecabf15bc
commit b42d881176
8 changed files with 106 additions and 122 deletions

View File

@ -122,8 +122,6 @@ BEGIN_MESSAGE_MAP(MainWnd, CWnd)
ON_COMMAND(ID_OPTIONS_FRAMESKIP_THROTTLE_150, OnOptionsFrameskipThrottle150)
ON_COMMAND(ID_OPTIONS_FRAMESKIP_THROTTLE_200, OnOptionsFrameskipThrottle200)
ON_COMMAND(ID_OPTIONS_FRAMESKIP_THROTTLE_OTHER, OnOptionsFrameskipThrottleOther)
ON_COMMAND(ID_OPTIONS_FRAMESKIP_AUTOMATIC, OnOptionsFrameskipAutomatic)
ON_UPDATE_COMMAND_UI(ID_OPTIONS_FRAMESKIP_AUTOMATIC, OnUpdateOptionsFrameskipAutomatic)
ON_UPDATE_COMMAND_UI(ID_OPTIONS_VIDEO_FRAMESKIP_0, OnUpdateOptionsVideoFrameskip0)
ON_UPDATE_COMMAND_UI(ID_OPTIONS_VIDEO_FRAMESKIP_1, OnUpdateOptionsVideoFrameskip1)
ON_UPDATE_COMMAND_UI(ID_OPTIONS_VIDEO_FRAMESKIP_2, OnUpdateOptionsVideoFrameskip2)
@ -662,7 +660,7 @@ bool MainWnd::FileRun()
theApp.frameskipadjust = 0;
theApp.renderedFrames = 0;
theApp.autoFrameSkipLastTime = theApp.throttleLastTime = systemGetClock();
theApp.autoFrameSkipLastTime = systemGetClock();
theApp.rewindCount = 0;
theApp.rewindCounter = 0;

View File

@ -148,8 +148,6 @@ class MainWnd : public CWnd
afx_msg void OnOptionsFrameskipThrottle150();
afx_msg void OnOptionsFrameskipThrottle200();
afx_msg void OnOptionsFrameskipThrottleOther();
afx_msg void OnOptionsFrameskipAutomatic();
afx_msg void OnUpdateOptionsFrameskipAutomatic(CCmdUI* pCmdUI);
afx_msg void OnUpdateOptionsVideoFrameskip0(CCmdUI* pCmdUI);
afx_msg void OnUpdateOptionsVideoFrameskip1(CCmdUI* pCmdUI);
afx_msg void OnUpdateOptionsVideoFrameskip2(CCmdUI* pCmdUI);

View File

@ -53,110 +53,101 @@ extern int emulating;
extern void CPUUpdateRenderBuffers(bool force);
void MainWnd::OnOptionsFrameskipThrottleNothrottle()
{
theApp.throttle = 0;
theApp.autoFrameSkip = false;
theApp.updateThrottle( 0 ); // disable
}
void MainWnd::OnUpdateOptionsFrameskipThrottleNothrottle(CCmdUI* pCmdUI)
{
pCmdUI->SetCheck(theApp.throttle == 0);
pCmdUI->SetCheck( theApp.throttle == 0 );
}
void MainWnd::OnOptionsFrameskipThrottle25()
{
theApp.throttle = 25;
theApp.autoFrameSkip = false;
theApp.updateThrottle( 25 );
}
void MainWnd::OnUpdateOptionsFrameskipThrottle25(CCmdUI* pCmdUI)
{
pCmdUI->SetCheck(theApp.throttle == 25);
pCmdUI->SetCheck( theApp.throttle == 25 );
}
void MainWnd::OnOptionsFrameskipThrottle50()
{
theApp.throttle = 50;
theApp.autoFrameSkip = false;
theApp.updateThrottle( 50 );
}
void MainWnd::OnUpdateOptionsFrameskipThrottle50(CCmdUI* pCmdUI)
{
pCmdUI->SetCheck(theApp.throttle == 50);
pCmdUI->SetCheck( theApp.throttle == 50 );
}
void MainWnd::OnOptionsFrameskipThrottle100()
{
theApp.throttle = 100;
theApp.autoFrameSkip = false;
theApp.updateThrottle( 100 );
}
void MainWnd::OnUpdateOptionsFrameskipThrottle100(CCmdUI* pCmdUI)
{
pCmdUI->SetCheck(theApp.throttle == 100);
pCmdUI->SetCheck( theApp.throttle == 100 );
}
void MainWnd::OnOptionsFrameskipThrottle150()
{
theApp.throttle = 150;
theApp.autoFrameSkip = false;
theApp.updateThrottle( 150 );
}
void MainWnd::OnUpdateOptionsFrameskipThrottle150(CCmdUI* pCmdUI)
{
pCmdUI->SetCheck(theApp.throttle == 150);
pCmdUI->SetCheck( theApp.throttle == 150 );
}
void MainWnd::OnOptionsFrameskipThrottle200()
{
theApp.throttle = 200;
theApp.autoFrameSkip = false;
theApp.updateThrottle( 200 );
}
void MainWnd::OnUpdateOptionsFrameskipThrottle200(CCmdUI* pCmdUI)
{
pCmdUI->SetCheck(theApp.throttle == 200);
pCmdUI->SetCheck( theApp.throttle == 200 );
}
void MainWnd::OnOptionsFrameskipThrottleOther()
{
Throttle dlg;
int v = (int)dlg.DoModal();
unsigned short v = (unsigned short)dlg.DoModal();
if( v ) {
theApp.throttle = v;
theApp.autoFrameSkip = false;
theApp.updateThrottle( v );
}
}
void MainWnd::OnUpdateOptionsFrameskipThrottleOther(CCmdUI* pCmdUI)
{
int throttle = theApp.throttle;
pCmdUI->SetCheck(throttle != 0 && throttle != 25 &&
throttle != 50 && throttle != 100 &&
throttle != 150 && throttle != 200);
pCmdUI->SetCheck(
( theApp.throttle != 0 ) &&
( theApp.throttle != 25 ) &&
( theApp.throttle != 50 ) &&
( theApp.throttle != 100 ) &&
( theApp.throttle != 150 ) &&
( theApp.throttle != 200 ) );
}
void MainWnd::OnOptionsFrameskipAutomatic()
{
theApp.autoFrameSkip = !theApp.autoFrameSkip;
if(!theApp.autoFrameSkip && emulating)
theApp.updateFrameSkip();
else
{
theApp.throttle = false;
frameSkip = 0;
systemFrameSkip = 0;
}
}
void MainWnd::OnUpdateOptionsFrameskipAutomatic(CCmdUI* pCmdUI)
{
pCmdUI->SetCheck(theApp.autoFrameSkip);
}
BOOL MainWnd::OnOptionsFrameskip(UINT nID)
{
@ -174,7 +165,7 @@ BOOL MainWnd::OnOptionsFrameskip(UINT nID)
}
if(emulating)
theApp.updateFrameSkip();
theApp.autoFrameSkip = false;
theApp.updateThrottle( 0 );
return TRUE;
break;
case ID_OPTIONS_VIDEO_FRAMESKIP_6:
@ -188,7 +179,7 @@ BOOL MainWnd::OnOptionsFrameskip(UINT nID)
}
if(emulating)
theApp.updateFrameSkip();
theApp.autoFrameSkip = false;
theApp.updateThrottle( 0 );
return TRUE;
break;
}

View File

@ -286,8 +286,11 @@ void OpenAL::write()
assert( AL_NO_ERROR == ALFunction.alGetError() );
if( nBuffersProcessed == theApp.oalBufferCount ) {
static int i = 0;
log( "OpenAL: Buffers were not refilled fast enough (%i)\n", i++ );
if( theApp.throttle >= 100 ) {
// we only want to know about it when we are emulating at full speed (or faster)
static int i = 0;
log( "OpenAL: Buffers were not refilled fast enough (%i)\n", i++ );
}
}
if( !speedup && synchronize && !theApp.throttle ) {

View File

@ -181,7 +181,7 @@ extern "C" bool cpu_mmx;
namespace Sm60FPS
{
float K_fCpuSpeed = 98.0f;
float K_fCpuSpeed = 100.0f; // was 98.0f before, but why?
float K_fTargetFps = 60.0f * K_fCpuSpeed / 100;
float K_fDT = 1000.0f / K_fTargetFps;
@ -280,7 +280,6 @@ VBA::VBA()
tripleBuffering = true;
autoHideMenu = false;
throttle = 0;
throttleLastTime = 0;
autoFrameSkipLastTime = 0;
autoFrameSkip = false;
vsync = false;
@ -919,6 +918,25 @@ void VBA::updateFilter()
}
void VBA::updateThrottle( unsigned short throttle )
{
this->throttle = throttle;
if( throttle == 0 ) {
autoFrameSkip = false;
return;
} else {
Sm60FPS::K_fCpuSpeed = (float)throttle;
Sm60FPS::K_fTargetFps = 60.0f * Sm60FPS::K_fCpuSpeed / 100;
Sm60FPS::K_fDT = 1000.0f / Sm60FPS::K_fTargetFps;
autoFrameSkip = true;
frameSkip = 0;
systemFrameSkip = 0;
return;
}
}
void VBA::updateMenuBar()
{
if(menu != NULL) {
@ -1118,32 +1136,20 @@ void systemFrame()
void system10Frames(int rate)
{
u32 time = systemGetClock();
if (theApp.autoFrameSkip)
{
u32 diff = time - theApp.autoFrameSkipLastTime;
Sm60FPS::nCurSpeed = 100;
if (diff)
Sm60FPS::nCurSpeed = (1000000/rate)/diff;
}
if( theApp.autoFrameSkip )
{
u32 time = systemGetClock();
u32 diff = time - theApp.autoFrameSkipLastTime;
theApp.autoFrameSkipLastTime = time;
if( diff ) {
// countermeasure against div/0 when debugging
Sm60FPS::nCurSpeed = (1000000/rate)/diff;
} else {
Sm60FPS::nCurSpeed = 100;
}
}
if(!theApp.wasPaused && theApp.throttle) {
if(!speedup) {
u32 diff = time - theApp.throttleLastTime;
int target = (1000000/(rate*theApp.throttle));
int d = (target - diff);
if(d > 0) {
Sleep(d);
}
}
theApp.throttleLastTime = systemGetClock();
}
if(theApp.rewindMemory) {
if(++theApp.rewindCounter >= (theApp.rewindTimer)) {
theApp.rewindSaveNeeded = true;
@ -1158,7 +1164,6 @@ void system10Frames(int rate)
}
theApp.wasPaused = false;
theApp.autoFrameSkipLastTime = time;
}
void systemScreenMessage(const char *msg)
@ -1412,8 +1417,6 @@ void VBA::loadSettings()
if(gbFrameSkip < 0 || gbFrameSkip > 9)
gbFrameSkip = 0;
autoFrameSkip = regQueryDwordValue("autoFrameSkip", FALSE) ? TRUE : FALSE;
vsync = regQueryDwordValue("vsync", false) ? true : false ;
synchronize = regQueryDwordValue("synchronize", 1) ? true : false;
fullScreenStretch = regQueryDwordValue("stretch", 0) ? true : false;
@ -1676,9 +1679,7 @@ void VBA::loadSettings()
fsMaxScale = regQueryDwordValue("fsMaxScale", 0);
throttle = regQueryDwordValue("throttle", 0);
if(throttle < 5 || throttle > 1000)
throttle = 0;
updateThrottle( (unsigned short)regQueryDwordValue( "throttle", 0 ) );
linktimeout = regQueryDwordValue("LinkTimeout", 1000);
@ -1690,12 +1691,6 @@ void VBA::loadSettings()
linkenable = regQueryDwordValue("linkEnabled", false) ? true : false;
lanlink.active = regQueryDwordValue("LAN", 0) ? true : false;
if (autoFrameSkip)
{
throttle = 0;
frameSkip = 0;
systemFrameSkip = 0;
}
Sm60FPS::bSaveMoreCPU = regQueryDwordValue("saveMoreCPU", 0);
@ -2538,8 +2533,6 @@ void VBA::saveSettings()
regSetDwordValue("gbFrameSkip", gbFrameSkip);
regSetDwordValue("autoFrameSkip", autoFrameSkip);
regSetDwordValue("vsync", vsync);
regSetDwordValue("synchronize", synchronize);
regSetDwordValue("stretch", fullScreenStretch);

View File

@ -143,8 +143,7 @@ class VBA : public CWinApp
int captureFormat;
bool tripleBuffering;
bool autoHideMenu;
int throttle;
u32 throttleLastTime;
unsigned short throttle;
u32 autoFrameSkipLastTime;
bool autoFrameSkip;
bool vsync;
@ -236,6 +235,7 @@ class VBA : public CWinApp
void adjustDestRect();
void updateIFB();
void updateFilter();
void updateThrottle( unsigned short throttle );
void updateMenuBar();
void winAddUpdateListener(IUpdateListener *l);
void winRemoveUpdateListener(IUpdateListener *l);

View File

@ -1623,34 +1623,6 @@ BEGIN
MENUITEM "Stretch to &fit", ID_OPTIONS_VIDEO_FULLSCREENSTRETCHTOFIT
END
MENUITEM SEPARATOR
POPUP "&Frame Skip"
BEGIN
MENUITEM "&Automatic", ID_OPTIONS_FRAMESKIP_AUTOMATIC
MENUITEM SEPARATOR
MENUITEM "&No frame skip", ID_OPTIONS_VIDEO_FRAMESKIP_0
MENUITEM "&1 frame", ID_OPTIONS_VIDEO_FRAMESKIP_1
MENUITEM "&2 frames", ID_OPTIONS_VIDEO_FRAMESKIP_2
MENUITEM "&3 frames", ID_OPTIONS_VIDEO_FRAMESKIP_3
MENUITEM "&4 frames", ID_OPTIONS_VIDEO_FRAMESKIP_4
MENUITEM "&5 frames", ID_OPTIONS_VIDEO_FRAMESKIP_5
MENUITEM "&6 frames", ID_OPTIONS_VIDEO_FRAMESKIP_6
MENUITEM "&7 frames", ID_OPTIONS_VIDEO_FRAMESKIP_7
MENUITEM "&8 frames", ID_OPTIONS_VIDEO_FRAMESKIP_8
MENUITEM "&9 frames", ID_OPTIONS_VIDEO_FRAMESKIP_9
MENUITEM SEPARATOR
MENUITEM "Turbo mode", ID_OPTIONS_EMULATOR_SPEEDUPTOGGLE
END
POPUP "Throttle"
BEGIN
MENUITEM "No throttle", ID_OPTIONS_FRAMESKIP_THROTTLE_NOTHROTTLE
MENUITEM "25%", ID_OPTIONS_FRAMESKIP_THROTTLE_25
MENUITEM "50%", ID_OPTIONS_FRAMESKIP_THROTTLE_50
MENUITEM "100%", ID_OPTIONS_FRAMESKIP_THROTTLE_100
MENUITEM "150%", ID_OPTIONS_FRAMESKIP_THROTTLE_150
MENUITEM "200%", ID_OPTIONS_FRAMESKIP_THROTTLE_200
MENUITEM "&Other...", ID_OPTIONS_FRAMESKIP_THROTTLE_OTHER
END
MENUITEM SEPARATOR
MENUITEM "D&isable status messages", ID_OPTIONS_EMULATOR_DISABLESTATUSMESSAGES
END
POPUP "&Pixel Filter"
@ -1780,6 +1752,34 @@ BEGIN
END
MENUITEM "Rewind interval...", ID_OPTIONS_EMULATOR_REWINDINTERVAL
END
POPUP "&Speed"
BEGIN
POPUP "&Throttle"
BEGIN
MENUITEM "25%", ID_OPTIONS_FRAMESKIP_THROTTLE_25
MENUITEM "50%", ID_OPTIONS_FRAMESKIP_THROTTLE_50
MENUITEM "100%", ID_OPTIONS_FRAMESKIP_THROTTLE_100
MENUITEM "150%", ID_OPTIONS_FRAMESKIP_THROTTLE_150
MENUITEM "200%", ID_OPTIONS_FRAMESKIP_THROTTLE_200
MENUITEM "&Other...", ID_OPTIONS_FRAMESKIP_THROTTLE_OTHER
MENUITEM "No throttle", ID_OPTIONS_FRAMESKIP_THROTTLE_NOTHROTTLE
END
MENUITEM SEPARATOR
POPUP "&Frame Skip"
BEGIN
MENUITEM "&No frame skip", ID_OPTIONS_VIDEO_FRAMESKIP_0
MENUITEM "&1 frame", ID_OPTIONS_VIDEO_FRAMESKIP_1
MENUITEM "&2 frames", ID_OPTIONS_VIDEO_FRAMESKIP_2
MENUITEM "&3 frames", ID_OPTIONS_VIDEO_FRAMESKIP_3
MENUITEM "&4 frames", ID_OPTIONS_VIDEO_FRAMESKIP_4
MENUITEM "&5 frames", ID_OPTIONS_VIDEO_FRAMESKIP_5
MENUITEM "&6 frames", ID_OPTIONS_VIDEO_FRAMESKIP_6
MENUITEM "&7 frames", ID_OPTIONS_VIDEO_FRAMESKIP_7
MENUITEM "&8 frames", ID_OPTIONS_VIDEO_FRAMESKIP_8
MENUITEM "&9 frames", ID_OPTIONS_VIDEO_FRAMESKIP_9
END
MENUITEM "Turbo mode", ID_OPTIONS_EMULATOR_SPEEDUPTOGGLE
END
MENUITEM SEPARATOR
POPUP "&Emulator"
BEGIN

View File

@ -821,13 +821,14 @@
#define ID_OUTPUTAPI_OALCONFIGURATION 40350
#define ID_RENDERAPI_FILTER 40351
#define ID_OPTIONS_VIDEO_RENDEROPTIONS_GLSLSHADERS 40352
#define ID_OPTIONS_SPEED 40353
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 161
#define _APS_NEXT_COMMAND_VALUE 40353
#define _APS_NEXT_COMMAND_VALUE 40354
#define _APS_NEXT_CONTROL_VALUE 1272
#define _APS_NEXT_SYMED_VALUE 103
#endif