fceu main loop - code cleanup. Saves a few cycles in a the process!
This commit is contained in:
parent
a1aaca5df1
commit
b199505bcb
35
src/fceu.cpp
35
src/fceu.cpp
|
@ -556,7 +556,6 @@ void FCEUI_Emulate(uint8 **pXBuf, int32 **SoundBuf, int32 *SoundBufSize, int ski
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if(EmulationPaused&2)
|
if(EmulationPaused&2)
|
||||||
EmulationPaused &= ~1; // clear paused flag temporarily (frame advance)
|
EmulationPaused &= ~1; // clear paused flag temporarily (frame advance)
|
||||||
else if((EmulationPaused&1))
|
else if((EmulationPaused&1))
|
||||||
|
@ -571,7 +570,7 @@ void FCEUI_Emulate(uint8 **pXBuf, int32 **SoundBuf, int32 *SoundBufSize, int ski
|
||||||
}
|
}
|
||||||
|
|
||||||
AutoFire();
|
AutoFire();
|
||||||
UpdateAutosave();
|
if(!EnableAutosave) UpdateAutosave();
|
||||||
|
|
||||||
#ifdef _S9XLUA_H
|
#ifdef _S9XLUA_H
|
||||||
FCEU_LuaFrameBoundary();
|
FCEU_LuaFrameBoundary();
|
||||||
|
@ -598,34 +597,18 @@ void FCEUI_Emulate(uint8 **pXBuf, int32 **SoundBuf, int32 *SoundBufSize, int ski
|
||||||
*SoundBuf=WaveFinal;
|
*SoundBuf=WaveFinal;
|
||||||
*SoundBufSize=ssize;
|
*SoundBufSize=ssize;
|
||||||
|
|
||||||
//if we were asked to frame advance, then since we have just finished a frame, we should switch to regular pause
|
if (EmulationPaused&2 && ( !frameAdvanceLagSkip || !lagFlag) )
|
||||||
if (frameAdvanceLagSkip)
|
//Lots of conditions here. EmulationPaused&2 must be true. In addition frameAdvanceLagSkip or lagFlag must be false
|
||||||
{ //Holy nested loops Batman!
|
|
||||||
if (!lagFlag)
|
|
||||||
{
|
|
||||||
if(EmulationPaused&2)
|
|
||||||
{
|
{
|
||||||
EmulationPaused = 1; // restore paused flag
|
EmulationPaused = 1; // restore paused flag
|
||||||
|
JustFrameAdvanced = true;
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
if(soundoptions&SO_MUTEFA) //mute the frame advance if the user requested it
|
if(soundoptions&SO_MUTEFA) //mute the frame advance if the user requested it
|
||||||
*SoundBufSize=0; // keep sound muted
|
*SoundBufSize=0; //keep sound muted
|
||||||
#endif
|
#endif
|
||||||
JustFrameAdvanced = true;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if(EmulationPaused&2)
|
|
||||||
{
|
|
||||||
EmulationPaused = 1; // restore paused flag
|
|
||||||
#ifdef WIN32
|
|
||||||
if(soundoptions&SO_MUTEFA) //mute the frame advance if the user requested it
|
|
||||||
*SoundBufSize=0; // keep sound muted
|
|
||||||
#endif
|
|
||||||
JustFrameAdvanced = true;
|
|
||||||
}
|
|
||||||
} //I apologize to anyone who comes in and tries to figure out this IF branching
|
|
||||||
currMovieData.TryDumpIncremental();
|
currMovieData.TryDumpIncremental();
|
||||||
if (lagFlag)
|
if (lagFlag)
|
||||||
{
|
{
|
||||||
|
@ -872,9 +855,9 @@ static int AutosaveCounter = 0;
|
||||||
|
|
||||||
void UpdateAutosave(void)
|
void UpdateAutosave(void)
|
||||||
{
|
{
|
||||||
if(!EnableAutosave)
|
/*if(!EnableAutosave)
|
||||||
return;
|
return;
|
||||||
|
*/
|
||||||
char * f;
|
char * f;
|
||||||
AutosaveCounter = (AutosaveCounter + 1) % 256;
|
AutosaveCounter = (AutosaveCounter + 1) % 256;
|
||||||
if(AutosaveCounter == 0)
|
if(AutosaveCounter == 0)
|
||||||
|
|
Loading…
Reference in New Issue