split
This commit is contained in:
parent
892c6e383f
commit
b360d27f22
3 changed files with 27 additions and 7 deletions
|
@ -182,21 +182,38 @@ Emulator::Emulator(
|
||||||
, myFPS(getFPS())
|
, myFPS(getFPS())
|
||||||
, myMultiplier(1)
|
, myMultiplier(1)
|
||||||
, myFullscreen(false)
|
, myFullscreen(false)
|
||||||
|
, myExtraCycles(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void Emulator::executeOneFrame()
|
void Emulator::executeOneFrame()
|
||||||
{
|
{
|
||||||
const DWORD uCyclesToExecute = int(g_fCurrentCLK6502 / myFPS);
|
|
||||||
const UINT dwClksPerFrame = NTSC_GetCyclesPerFrame();
|
|
||||||
const bool bVideoUpdate = true;
|
const bool bVideoUpdate = true;
|
||||||
const DWORD uActualCyclesExecuted = CpuExecute(uCyclesToExecute, bVideoUpdate);
|
const int nExecutionPeriodUsec = 1000; // 1.0ms
|
||||||
g_dwCyclesThisFrame = (g_dwCyclesThisFrame + uActualCyclesExecuted) % dwClksPerFrame;
|
const double fUsecPerSec = 1.e6;
|
||||||
|
const double fExecutionPeriodClks = int(g_fCurrentCLK6502 * (nExecutionPeriodUsec / fUsecPerSec));
|
||||||
|
|
||||||
GetCardMgr().GetDisk2CardMgr().UpdateDriveState(uActualCyclesExecuted);
|
int totalCyclesExecuted = 0;
|
||||||
MB_PeriodicUpdate(uActualCyclesExecuted);
|
const DWORD uCyclesToExecute = int(g_fCurrentCLK6502 / myFPS) + myExtraCycles;
|
||||||
SpkrUpdate(uActualCyclesExecuted);
|
const UINT dwClksPerFrame = NTSC_GetCyclesPerFrame();
|
||||||
|
|
||||||
|
while (totalCyclesExecuted < uCyclesToExecute)
|
||||||
|
{
|
||||||
|
// go in small steps of 1ms
|
||||||
|
const DWORD uActualCyclesExecuted = CpuExecute(fExecutionPeriodClks, bVideoUpdate);
|
||||||
|
totalCyclesExecuted += uActualCyclesExecuted;
|
||||||
|
g_dwCyclesThisFrame = (g_dwCyclesThisFrame + uActualCyclesExecuted) % dwClksPerFrame;
|
||||||
|
|
||||||
|
GetCardMgr().GetDisk2CardMgr().UpdateDriveState(uActualCyclesExecuted);
|
||||||
|
MB_PeriodicUpdate(uActualCyclesExecuted);
|
||||||
|
SpkrUpdate(uActualCyclesExecuted);
|
||||||
|
}
|
||||||
|
|
||||||
|
myExtraCycles = uCyclesToExecute - totalCyclesExecuted;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Emulator::refreshVideo()
|
||||||
|
{
|
||||||
// SDL2 seems to synch with screen refresh rate so we do not need to worry about timers
|
// SDL2 seems to synch with screen refresh rate so we do not need to worry about timers
|
||||||
const SDL_Rect srect = refreshTexture(myTexture);
|
const SDL_Rect srect = refreshTexture(myTexture);
|
||||||
renderScreen(myRenderer, myTexture, srect);
|
renderScreen(myRenderer, myTexture, srect);
|
||||||
|
|
|
@ -13,6 +13,7 @@ public:
|
||||||
);
|
);
|
||||||
|
|
||||||
void executeOneFrame();
|
void executeOneFrame();
|
||||||
|
void refreshVideo();
|
||||||
void processEvents(bool & quit);
|
void processEvents(bool & quit);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -27,4 +28,5 @@ private:
|
||||||
|
|
||||||
int myMultiplier;
|
int myMultiplier;
|
||||||
bool myFullscreen;
|
bool myFullscreen;
|
||||||
|
int myExtraCycles;
|
||||||
};
|
};
|
||||||
|
|
|
@ -216,6 +216,7 @@ void run_sdl(int argc, const char * argv [])
|
||||||
SDirectSound::writeAudio();
|
SDirectSound::writeAudio();
|
||||||
emulator.processEvents(quit);
|
emulator.processEvents(quit);
|
||||||
emulator.executeOneFrame();
|
emulator.executeOneFrame();
|
||||||
|
emulator.refreshVideo();
|
||||||
} while (!quit);
|
} while (!quit);
|
||||||
|
|
||||||
SDirectSound::stop();
|
SDirectSound::stop();
|
||||||
|
|
Loading…
Add table
Reference in a new issue