Handle MODE_DEBUG in main loop.
Signed-off-by: Andrea Odetti <mariofutire@gmail.com>
This commit is contained in:
parent
9d4f293a3c
commit
329c19c8d9
4 changed files with 20 additions and 8 deletions
|
@ -19,11 +19,11 @@ namespace common2
|
|||
myStartCycles = g_nCumulativeCycles;
|
||||
}
|
||||
|
||||
size_t Speed::getCyclesTillNext(const size_t microseconds) const
|
||||
uint64_t Speed::getCyclesTillNext(const size_t microseconds) const
|
||||
{
|
||||
if (myFixedSpeed)
|
||||
{
|
||||
const size_t cycles = static_cast<uint64_t>(microseconds * g_fCurrentCLK6502 * 1.0e-6);
|
||||
const uint64_t cycles = static_cast<uint64_t>(microseconds * g_fCurrentCLK6502 * 1.0e-6);
|
||||
return cycles;
|
||||
}
|
||||
else
|
||||
|
|
|
@ -14,7 +14,7 @@ namespace common2
|
|||
|
||||
// calculate the number of cycles to execute in the current period
|
||||
// assuming the next call will happen in x microseconds
|
||||
size_t getCyclesTillNext(const size_t microseconds) const;
|
||||
uint64_t getCyclesTillNext(const size_t microseconds) const;
|
||||
|
||||
private:
|
||||
|
||||
|
|
|
@ -92,12 +92,12 @@ namespace ra2
|
|||
|
||||
void Game::executeOneFrame()
|
||||
{
|
||||
const size_t cyclesToExecute = mySpeed.getCyclesTillNext(ourFrameTime);
|
||||
if (g_nAppMode == MODE_RUNNING)
|
||||
{
|
||||
const bool bVideoUpdate = true;
|
||||
const UINT dwClksPerFrame = NTSC_GetCyclesPerFrame();
|
||||
|
||||
const uint64_t cyclesToExecute = mySpeed.getCyclesTillNext(ourFrameTime);
|
||||
const DWORD executedCycles = CpuExecute(cyclesToExecute, bVideoUpdate);
|
||||
|
||||
g_dwCyclesThisFrame = (g_dwCyclesThisFrame + executedCycles) % dwClksPerFrame;
|
||||
|
|
|
@ -533,17 +533,24 @@ namespace sa2
|
|||
{
|
||||
// when running in adaptive speed
|
||||
// the value msNextFrame is only a hint for when the next frame will arrive
|
||||
const uint64_t cyclesToExecute = mySpeed.getCyclesTillNext(msNextFrame * 1000);
|
||||
switch (g_nAppMode)
|
||||
{
|
||||
case MODE_RUNNING:
|
||||
{
|
||||
const size_t cyclesToExecute = mySpeed.getCyclesTillNext(msNextFrame * 1000);
|
||||
Execute(cyclesToExecute);
|
||||
break;
|
||||
}
|
||||
case MODE_STEPPING:
|
||||
{
|
||||
DebugContinueStepping();
|
||||
// In AppleWin this is called without a timer for just one iteration
|
||||
// because we run a "frame" at a time, we need a bit of ingenuity
|
||||
const uint64_t target = g_nCumulativeCycles + cyclesToExecute;
|
||||
|
||||
while (g_nAppMode == MODE_STEPPING && g_nCumulativeCycles < target)
|
||||
{
|
||||
DebugContinueStepping();
|
||||
}
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
@ -553,14 +560,19 @@ namespace sa2
|
|||
{
|
||||
if (mode != g_nAppMode)
|
||||
{
|
||||
g_nAppMode = mode;
|
||||
switch (g_nAppMode)
|
||||
switch (mode)
|
||||
{
|
||||
case MODE_RUNNING:
|
||||
DebugExitDebugger();
|
||||
SoundCore_SetFade(FADE_IN);
|
||||
mySpeed.reset();
|
||||
break;
|
||||
case MODE_DEBUG:
|
||||
DebugBegin();
|
||||
CmdWindowViewConsole(0);
|
||||
break;
|
||||
default:
|
||||
g_nAppMode = mode;
|
||||
SoundCore_SetFade(FADE_OUT);
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue