fceu main loop - code cleanup. Saves a few cycles in a the process!

This commit is contained in:
adelikat 2008-12-05 03:59:46 +00:00
parent a1aaca5df1
commit b199505bcb
1 changed files with 15 additions and 32 deletions

View File

@ -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();
@ -597,35 +596,19 @@ void FCEUI_Emulate(uint8 **pXBuf, int32 **SoundBuf, int32 *SoundBufSize, int ski
*pXBuf=skip?0:XBuf; *pXBuf=skip?0:XBuf;
*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
#ifdef WIN32
if(soundoptions&SO_MUTEFA) //mute the frame advance if the user requested it
*SoundBufSize=0; // keep sound muted
#endif
JustFrameAdvanced = true;
}
}
}
else
{ {
if(EmulationPaused&2) EmulationPaused = 1; // restore paused flag
{ JustFrameAdvanced = true;
EmulationPaused = 1; // restore paused flag #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; }
}
} //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)