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())
|
||||
, myMultiplier(1)
|
||||
, myFullscreen(false)
|
||||
, myExtraCycles(0)
|
||||
{
|
||||
}
|
||||
|
||||
void Emulator::executeOneFrame()
|
||||
{
|
||||
const DWORD uCyclesToExecute = int(g_fCurrentCLK6502 / myFPS);
|
||||
const UINT dwClksPerFrame = NTSC_GetCyclesPerFrame();
|
||||
const bool bVideoUpdate = true;
|
||||
const DWORD uActualCyclesExecuted = CpuExecute(uCyclesToExecute, bVideoUpdate);
|
||||
g_dwCyclesThisFrame = (g_dwCyclesThisFrame + uActualCyclesExecuted) % dwClksPerFrame;
|
||||
const int nExecutionPeriodUsec = 1000; // 1.0ms
|
||||
const double fUsecPerSec = 1.e6;
|
||||
const double fExecutionPeriodClks = int(g_fCurrentCLK6502 * (nExecutionPeriodUsec / fUsecPerSec));
|
||||
|
||||
GetCardMgr().GetDisk2CardMgr().UpdateDriveState(uActualCyclesExecuted);
|
||||
MB_PeriodicUpdate(uActualCyclesExecuted);
|
||||
SpkrUpdate(uActualCyclesExecuted);
|
||||
int totalCyclesExecuted = 0;
|
||||
const DWORD uCyclesToExecute = int(g_fCurrentCLK6502 / myFPS) + myExtraCycles;
|
||||
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
|
||||
const SDL_Rect srect = refreshTexture(myTexture);
|
||||
renderScreen(myRenderer, myTexture, srect);
|
||||
|
|
|
@ -13,6 +13,7 @@ public:
|
|||
);
|
||||
|
||||
void executeOneFrame();
|
||||
void refreshVideo();
|
||||
void processEvents(bool & quit);
|
||||
|
||||
private:
|
||||
|
@ -27,4 +28,5 @@ private:
|
|||
|
||||
int myMultiplier;
|
||||
bool myFullscreen;
|
||||
int myExtraCycles;
|
||||
};
|
||||
|
|
|
@ -216,6 +216,7 @@ void run_sdl(int argc, const char * argv [])
|
|||
SDirectSound::writeAudio();
|
||||
emulator.processEvents(quit);
|
||||
emulator.executeOneFrame();
|
||||
emulator.refreshVideo();
|
||||
} while (!quit);
|
||||
|
||||
SDirectSound::stop();
|
||||
|
|
Loading…
Add table
Reference in a new issue