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