Added a load prev and next state functions for state recorder.
This commit is contained in:
parent
99aefa563a
commit
55bcb3d41a
|
@ -2758,14 +2758,14 @@ void consoleWin_t::loadState9(void){ loadState(9); }
|
|||
void consoleWin_t::loadPrevState(void)
|
||||
{
|
||||
FCEU_WRAPPER_LOCK();
|
||||
FCEU_StateRecorderLoadState( FCEU_StateRecorderGetStateIndex()-1 );
|
||||
FCEU_StateRecorderLoadPrevState();
|
||||
FCEU_WRAPPER_UNLOCK();
|
||||
}
|
||||
|
||||
void consoleWin_t::loadNextState(void)
|
||||
{
|
||||
FCEU_WRAPPER_LOCK();
|
||||
FCEU_StateRecorderLoadState( FCEU_StateRecorderGetStateIndex()-1 );
|
||||
FCEU_StateRecorderLoadNextState();
|
||||
FCEU_WRAPPER_UNLOCK();
|
||||
}
|
||||
|
||||
|
|
|
@ -1338,6 +1338,41 @@ class StateRecorder
|
|||
return 0;
|
||||
}
|
||||
|
||||
int loadPrevState(void)
|
||||
{
|
||||
int snapIdx = lastState;
|
||||
|
||||
if ( lastState == ringHead )
|
||||
{ // No States to Load
|
||||
return -1;
|
||||
}
|
||||
if ( lastState != ringStart )
|
||||
{
|
||||
if ( (lastLoadFrame+30) > frameCounter)
|
||||
{
|
||||
snapIdx--;
|
||||
|
||||
if (snapIdx < 0)
|
||||
{
|
||||
snapIdx += ringBufSize;
|
||||
}
|
||||
}
|
||||
}
|
||||
return loadStateByIndex( snapIdx );
|
||||
}
|
||||
|
||||
int loadNextState(void)
|
||||
{
|
||||
int snapIdx = lastState;
|
||||
int nextIdx = (lastState + 1) % ringBufSize;
|
||||
|
||||
if ( nextIdx != ringHead )
|
||||
{
|
||||
snapIdx = nextIdx;
|
||||
}
|
||||
return loadStateByIndex( snapIdx );
|
||||
}
|
||||
|
||||
int getHeadIndex(void)
|
||||
{
|
||||
return ringHead;
|
||||
|
@ -1436,11 +1471,13 @@ bool FCEU_StateRecorderRunning(void)
|
|||
|
||||
int FCEU_StateRecorderLoadState(int snapIndex)
|
||||
{
|
||||
int ret = -1;
|
||||
|
||||
if (stateRecorder != nullptr)
|
||||
{
|
||||
stateRecorder->loadStateByIndex(snapIndex);
|
||||
ret = stateRecorder->loadStateByIndex(snapIndex);
|
||||
}
|
||||
return 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
int FCEU_StateRecorderGetStateIndex(void)
|
||||
|
@ -1448,6 +1485,28 @@ int FCEU_StateRecorderGetStateIndex(void)
|
|||
return StateRecorder::lastState;
|
||||
}
|
||||
|
||||
int FCEU_StateRecorderLoadPrevState(void)
|
||||
{
|
||||
int ret = -1;
|
||||
|
||||
if (stateRecorder != nullptr)
|
||||
{
|
||||
ret = stateRecorder->loadPrevState();
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int FCEU_StateRecorderLoadNextState(void)
|
||||
{
|
||||
int ret = -1;
|
||||
|
||||
if (stateRecorder != nullptr)
|
||||
{
|
||||
ret = stateRecorder->loadNextState();
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
const StateRecorderConfigData& FCEU_StateRecorderGetConfigData(void)
|
||||
{
|
||||
return stateRecorderConfig;
|
||||
|
|
|
@ -111,5 +111,7 @@ bool FCEU_StateRecorderIsEnabled(void);
|
|||
void FCEU_StateRecorderSetEnabled(bool enabled);
|
||||
int FCEU_StateRecorderGetStateIndex(void);
|
||||
int FCEU_StateRecorderLoadState(int snapIndex);
|
||||
int FCEU_StateRecorderLoadPrevState(void);
|
||||
int FCEU_StateRecorderLoadNextState(void);
|
||||
int FCEU_StateRecorderSetConfigData(const StateRecorderConfigData &newConfig);
|
||||
const StateRecorderConfigData& FCEU_StateRecorderGetConfigData(void);
|
||||
|
|
Loading…
Reference in New Issue