mirror of
https://github.com/JorjBauer/aiie.git
synced 2024-11-25 03:34:51 +00:00
avoid fast-forwarding the CPU after exiting the BIOS
This commit is contained in:
parent
9f530fa2b5
commit
d81cbb5607
@ -36,6 +36,8 @@ volatile bool wantResume = false;
|
||||
|
||||
volatile bool cpuDebuggerRunning = false;
|
||||
|
||||
volatile bool cpuClockInitialized = false;
|
||||
|
||||
void doDebugging();
|
||||
void readPrefs();
|
||||
void writePrefs();
|
||||
@ -118,14 +120,13 @@ static struct timespec runBIOS(struct timespec now)
|
||||
|
||||
static struct timespec runCPU(struct timespec now)
|
||||
{
|
||||
static bool initialized = false;
|
||||
static struct timespec startTime;
|
||||
static struct timespec nextInstructionTime;
|
||||
|
||||
if (!initialized) {
|
||||
if (!cpuClockInitialized) {
|
||||
do_gettime(&startTime);
|
||||
do_gettime(&nextInstructionTime);
|
||||
initialized = true;
|
||||
cpuClockInitialized = true;
|
||||
}
|
||||
|
||||
// Check for interrupt-like actions before running the CPU
|
||||
@ -337,6 +338,7 @@ void loop()
|
||||
g_display->redraw(); // Redraw the UI
|
||||
((AppleDisplay*)(g_vm->vmdisplay))->modeChange(); // force a full re-draw and blit
|
||||
|
||||
cpuClockInitialized = false; // force it to reset so it doesn't fast-forward
|
||||
wasBios = false;
|
||||
}
|
||||
}
|
||||
|
@ -41,6 +41,8 @@ TeensyUSB usb;
|
||||
|
||||
Bounce resetButtonDebouncer = Bounce();
|
||||
|
||||
volatile bool cpuClockInitialized = false;
|
||||
|
||||
void onKeypress(int unicode)
|
||||
{
|
||||
/*
|
||||
@ -309,6 +311,16 @@ void runCPU(uint32_t now)
|
||||
static uint32_t countSinceLast = 0;
|
||||
static uint32_t microsAtStart = micros();
|
||||
static uint32_t microsForNext = microsAtStart + (countSinceLast * SPEEDCTL);
|
||||
|
||||
// Allow the BIOS to reset our timing
|
||||
if (!cpuClockInitialized) {
|
||||
nextResetMicros = 0;
|
||||
countSinceLast = 0;
|
||||
microsAtStart = micros();
|
||||
microsForNext = microsAtStart + (countSinceLast * SPEEDCTL);
|
||||
|
||||
cpuClockInitialized = true;
|
||||
}
|
||||
|
||||
if (now >= microsForNext) {
|
||||
countSinceLast += g_cpu->Run(24); // The CPU runs in bursts of cycles. This '24' is the max burst we perform.
|
||||
@ -361,6 +373,8 @@ void loop()
|
||||
// Poll the keyboard before we start, so we can do selftest on startup
|
||||
g_keyboard->maintainKeyboard();
|
||||
|
||||
// Reset the CPU clock so it doesn't fast-forward
|
||||
cpuClockInitialized = false;
|
||||
wasBios = false;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user