mirror of
https://github.com/AppleWin/AppleWin.git
synced 2024-06-09 22:29:40 +00:00
Improve ContinueExecution() whilst MODE_STEPPING:
. GetKeyState(VK_SCROLL) is slow, so only call periodically . Account for g_nCpuCyclesFeedback before calling SpkrUpdate()
This commit is contained in:
parent
29b7fa15b8
commit
743add80f0
|
@ -131,7 +131,7 @@ void LogFileTimeUntilFirstKeyRead(void)
|
|||
if (!g_fh || bLogKeyReadDone)
|
||||
return;
|
||||
|
||||
if (mem[regs.pc-3] != 0x2C) // bit $c0000
|
||||
if (mem[regs.pc-3] != 0x2C) // bit $c000
|
||||
return;
|
||||
|
||||
DWORD dwTime = GetTickCount() - dwLogKeyReadTickStart;
|
||||
|
@ -208,6 +208,7 @@ void SetPriorityNormal(void)
|
|||
//---------------------------------------------------------------------------
|
||||
|
||||
static UINT g_uModeStepping_Cycles = 0;
|
||||
static bool g_uModeStepping_LastGetKey_ScrollLock = false;
|
||||
|
||||
static void ContinueExecution(void)
|
||||
{
|
||||
|
@ -225,9 +226,27 @@ static void ContinueExecution(void)
|
|||
|
||||
//
|
||||
|
||||
bool bScrollLock_FullSpeed = sg_PropertySheet.GetScrollLockToggle()
|
||||
? g_bScrollLock_FullSpeed
|
||||
: (GetKeyState(VK_SCROLL) < 0);
|
||||
bool bScrollLock_FullSpeed = false;
|
||||
if (sg_PropertySheet.GetScrollLockToggle())
|
||||
{
|
||||
bScrollLock_FullSpeed = g_bScrollLock_FullSpeed;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (g_nAppMode == MODE_RUNNING)
|
||||
{
|
||||
bScrollLock_FullSpeed = GetKeyState(VK_SCROLL) < 0;
|
||||
}
|
||||
else if (!IsDebugSteppingAtFullSpeed()) // Implicitly: MODE_STEPPING
|
||||
{
|
||||
// NB. For MODE_STEPPING: GetKeyState() is slow, so only call periodically
|
||||
// . 0x3FFF is roughly the number of cycles in a video frame, which seems a reasonable rate to call GetKeyState()
|
||||
if ((g_uModeStepping_Cycles & 0x3FFF) == 0)
|
||||
g_uModeStepping_LastGetKey_ScrollLock = GetKeyState(VK_SCROLL) < 0;
|
||||
|
||||
bScrollLock_FullSpeed = g_uModeStepping_LastGetKey_ScrollLock;
|
||||
}
|
||||
}
|
||||
|
||||
const bool bWasFullSpeed = g_bFullSpeed;
|
||||
g_bFullSpeed = (g_dwSpeed == SPEED_MAX) ||
|
||||
|
@ -256,9 +275,7 @@ static void ContinueExecution(void)
|
|||
else
|
||||
{
|
||||
if (bWasFullSpeed)
|
||||
{
|
||||
VideoRedrawScreenAfterFullSpeed(g_dwCyclesThisFrame);
|
||||
}
|
||||
|
||||
// Don't call Spkr_Demute()
|
||||
MB_Demute();
|
||||
|
@ -270,15 +287,15 @@ static void ContinueExecution(void)
|
|||
|
||||
//
|
||||
|
||||
int nCyclesToExecute = (int) fExecutionPeriodClks + g_nCpuCyclesFeedback;
|
||||
if (nCyclesToExecute < 0)
|
||||
nCyclesToExecute = 0;
|
||||
int nCyclesWithFeedback = (int) fExecutionPeriodClks + g_nCpuCyclesFeedback;
|
||||
const UINT uCyclesToExecuteWithFeedback = (nCyclesWithFeedback >= 0) ? nCyclesWithFeedback
|
||||
: 0;
|
||||
|
||||
if (g_nAppMode == MODE_STEPPING)
|
||||
nCyclesToExecute = 0;
|
||||
const DWORD uCyclesToExecute = (g_nAppMode == MODE_RUNNING) ? uCyclesToExecuteWithFeedback
|
||||
/* MODE_STEPPING */ : 0;
|
||||
|
||||
const bool bVideoUpdate = !g_bFullSpeed;
|
||||
const DWORD uActualCyclesExecuted = CpuExecute(nCyclesToExecute, bVideoUpdate);
|
||||
const DWORD uActualCyclesExecuted = CpuExecute(uCyclesToExecute, bVideoUpdate);
|
||||
g_dwCyclesThisFrame += uActualCyclesExecuted;
|
||||
|
||||
DiskUpdatePosition(uActualCyclesExecuted);
|
||||
|
@ -295,11 +312,11 @@ static void ContinueExecution(void)
|
|||
if (g_nAppMode == MODE_STEPPING && !IsDebugSteppingAtFullSpeed())
|
||||
{
|
||||
g_uModeStepping_Cycles += uActualCyclesExecuted;
|
||||
if (g_uModeStepping_Cycles >= fExecutionPeriodClks)
|
||||
if (g_uModeStepping_Cycles >= uCyclesToExecuteWithFeedback)
|
||||
{
|
||||
uSpkrActualCyclesExecuted = g_uModeStepping_Cycles;
|
||||
|
||||
g_uModeStepping_Cycles -= (UINT)fExecutionPeriodClks;
|
||||
g_uModeStepping_Cycles -= uCyclesToExecuteWithFeedback;
|
||||
bModeStepping_WaitTimer = true;
|
||||
}
|
||||
}
|
||||
|
@ -329,8 +346,14 @@ static void ContinueExecution(void)
|
|||
}
|
||||
}
|
||||
|
||||
void SingleStep(void)
|
||||
void SingleStep(bool bReinit)
|
||||
{
|
||||
if (bReinit)
|
||||
{
|
||||
g_uModeStepping_Cycles = 0;
|
||||
g_uModeStepping_LastGetKey_ScrollLock = false;
|
||||
}
|
||||
|
||||
ContinueExecution();
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ extern eApple2Type g_Apple2Type;
|
|||
eApple2Type GetApple2Type(void);
|
||||
void SetApple2Type(eApple2Type type);
|
||||
|
||||
void SingleStep(void);
|
||||
void SingleStep(bool bReinit);
|
||||
|
||||
extern bool g_bFullSpeed;
|
||||
|
||||
|
|
|
@ -202,6 +202,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|||
|
||||
static bool g_bDebugFullSpeed = false;
|
||||
static bool g_bLastGoCmdWasFullSpeed = false;
|
||||
static bool g_bGoCmd_ReinitFlag = false;
|
||||
|
||||
// Display ____________________________________________________________________
|
||||
|
||||
|
@ -1909,6 +1910,7 @@ static Update_t CmdGo (int nArgs, const bool bFullSpeed)
|
|||
|
||||
g_bDebugFullSpeed = bFullSpeed;
|
||||
g_bLastGoCmdWasFullSpeed = bFullSpeed;
|
||||
g_bGoCmd_ReinitFlag = true;
|
||||
|
||||
g_nAppMode = MODE_STEPPING;
|
||||
FrameRefreshStatus(DRAW_TITLE);
|
||||
|
@ -8501,7 +8503,8 @@ void DebugContinueStepping ()
|
|||
g_aProfileOpmodes[ nOpmode ].m_nCount++;
|
||||
}
|
||||
|
||||
SingleStep();
|
||||
SingleStep(g_bGoCmd_ReinitFlag);
|
||||
g_bGoCmd_ReinitFlag = false;
|
||||
|
||||
g_bDebugBreakpointHit |= CheckBreakpointsIO() || CheckBreakpointsReg();
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user