mirror of
https://github.com/JorjBauer/aiie.git
synced 2024-06-15 21:29:32 +00:00
remove macros for threading compatability
This commit is contained in:
parent
f9d060b593
commit
16fbb37f90
|
@ -16,12 +16,14 @@
|
||||||
|
|
||||||
//#define DEBUG_TIMING
|
//#define DEBUG_TIMING
|
||||||
|
|
||||||
#define THREADED if (1)
|
|
||||||
|
|
||||||
#if F_CPU < 240000000
|
#if F_CPU < 240000000
|
||||||
#pragma AiiE warning: performance will improve if you overclock the Teensy to 240MHz (F_CPU=240MHz) or 256MHz (F_CPU=256MHz)
|
#pragma AiiE warning: performance will improve if you overclock the Teensy to 240MHz (F_CPU=240MHz) or 256MHz (F_CPU=256MHz)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if F_CPU == 600000000
|
||||||
|
#pragma AiiE suggestion: if you underclock to 528MHz (F_CPU=528MHz) then it will use significantly less power, and still perform perfectly
|
||||||
|
#endif
|
||||||
|
|
||||||
#define RESETPIN 38
|
#define RESETPIN 38
|
||||||
#define DEBUGPIN 23
|
#define DEBUGPIN 23
|
||||||
|
|
||||||
|
@ -226,18 +228,16 @@ void runMaintenance(uint32_t now)
|
||||||
{
|
{
|
||||||
static uint32_t nextRuntime = 0;
|
static uint32_t nextRuntime = 0;
|
||||||
|
|
||||||
THREADED {
|
if (now >= nextRuntime) {
|
||||||
if (now >= nextRuntime) {
|
nextRuntime = now + 100000; // FIXME: what's a good time here? 1/10 sec?
|
||||||
nextRuntime = now + 100000; // FIXME: what's a good time here? 1/10 sec?
|
|
||||||
|
if (!resetButtonDebouncer.read()) {
|
||||||
if (!resetButtonDebouncer.read()) {
|
// This is the BIOS interrupt. We immediately act on it.
|
||||||
// This is the BIOS interrupt. We immediately act on it.
|
biosInterrupt();
|
||||||
biosInterrupt();
|
|
||||||
}
|
|
||||||
|
|
||||||
g_keyboard->maintainKeyboard();
|
|
||||||
usb.maintain();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
g_keyboard->maintainKeyboard();
|
||||||
|
usb.maintain();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -254,66 +254,63 @@ void runDisplay(uint32_t now)
|
||||||
static uint32_t lastFps = 0;
|
static uint32_t lastFps = 0;
|
||||||
static uint32_t displayFrameCount = 0;
|
static uint32_t displayFrameCount = 0;
|
||||||
|
|
||||||
THREADED {
|
// If it's time to draw the next frame, then do so
|
||||||
// If it's time to draw the next frame, then do so
|
if (now >= microsForNext) {
|
||||||
if (now >= microsForNext) {
|
refreshCount++;
|
||||||
refreshCount++;
|
microsForNext = microsAtStart + (1000000.0*((float)refreshCount/(float)TARGET_FPS));
|
||||||
microsForNext = microsAtStart + (1000000.0*((float)refreshCount/(float)TARGET_FPS));
|
|
||||||
|
|
||||||
doDebugging(lastFps);
|
|
||||||
|
|
||||||
g_ui->blit();
|
|
||||||
g_vm->vmdisplay->lockDisplay();
|
|
||||||
if (g_vm->vmdisplay->needsRedraw()) { // necessary for the VM to redraw
|
|
||||||
// Used to get the dirty rect and blit just that rect. Could still do,
|
|
||||||
// but instead, I'm just wildly wasting resources. MWAHAHAHA
|
|
||||||
// AiieRect what = g_vm->vmdisplay->getDirtyRect();
|
|
||||||
g_vm->vmdisplay->didRedraw();
|
|
||||||
// g_display->blit(what);
|
|
||||||
}
|
|
||||||
g_display->blit(); // Blit the whole thing, including UI area
|
|
||||||
g_vm->vmdisplay->unlockDisplay();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Once a second, start counting all over again
|
doDebugging(lastFps);
|
||||||
if (now >= nextResetMicros) {
|
|
||||||
uint32_t newFrameCount = ((TeensyDisplay *)g_display)->frameCount();
|
g_ui->blit();
|
||||||
|
g_vm->vmdisplay->lockDisplay();
|
||||||
// There are two "FPS" counters here, actually. One is how often
|
if (g_vm->vmdisplay->needsRedraw()) { // necessary for the VM to redraw
|
||||||
// we're polling the Apple //e memory to refresh the DMA buffer,
|
// Used to get the dirty rect and blit just that rect. Could still do,
|
||||||
// and to show that, we'd use this:
|
// but instead, I'm just wildly wasting resources. MWAHAHAHA
|
||||||
// lastFps = refreshCount;
|
// AiieRect what = g_vm->vmdisplay->getDirtyRect();
|
||||||
// The other is how often the DMA code is refreshing the actual
|
g_vm->vmdisplay->didRedraw();
|
||||||
// display, and to show that, we'd use this:
|
// g_display->blit(what);
|
||||||
lastFps = newFrameCount - displayFrameCount;
|
|
||||||
#ifdef DEBUG_TIMING
|
|
||||||
// ... and this debugging code shows both.
|
|
||||||
println("DMA buffer refresh at ", refreshCount, " FPS");
|
|
||||||
println("Display refresh at ", newFrameCount - displayFrameCount, " FPS");
|
|
||||||
#endif
|
|
||||||
displayFrameCount = newFrameCount;
|
|
||||||
nextResetMicros = now + 1000000;
|
|
||||||
refreshCount = 0;
|
|
||||||
microsAtStart = now;
|
|
||||||
microsForNext = microsAtStart + (1000000.0*((float)refreshCount/(float)TARGET_FPS));
|
|
||||||
}
|
}
|
||||||
|
g_display->blit(); // Blit the whole thing, including UI area
|
||||||
|
g_vm->vmdisplay->unlockDisplay();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Once a second, start counting all over again
|
||||||
|
if (now >= nextResetMicros) {
|
||||||
|
uint32_t newFrameCount = ((TeensyDisplay *)g_display)->frameCount();
|
||||||
|
|
||||||
|
// There are two "FPS" counters here, actually. One is how often
|
||||||
|
// we're polling the Apple //e memory to refresh the DMA buffer,
|
||||||
|
// and to show that, we'd use this:
|
||||||
|
// lastFps = refreshCount;
|
||||||
|
// The other is how often the DMA code is refreshing the actual
|
||||||
|
// display, and to show that, we'd use this:
|
||||||
|
lastFps = newFrameCount - displayFrameCount;
|
||||||
|
#ifdef DEBUG_TIMING
|
||||||
|
// ... and this debugging code shows both.
|
||||||
|
println("DMA buffer refresh at ", refreshCount, " FPS");
|
||||||
|
println("Display refresh at ", newFrameCount - displayFrameCount, " FPS");
|
||||||
|
#endif
|
||||||
|
displayFrameCount = newFrameCount;
|
||||||
|
nextResetMicros = now + 1000000;
|
||||||
|
refreshCount = 0;
|
||||||
|
microsAtStart = now;
|
||||||
|
microsForNext = microsAtStart + (1000000.0*((float)refreshCount/(float)TARGET_FPS));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// The debouncer is used in the bios, which blocks the main loop
|
// The debouncer is used in the bios, which blocks the main loop
|
||||||
// execution; so this thread updates the debouncer instead.
|
// execution; so this function updates the debouncer instead. It used
|
||||||
|
// to be a thread of its own, but now that this is single-threaded
|
||||||
|
// again, it's a standalone method.
|
||||||
void runDebouncer()
|
void runDebouncer()
|
||||||
{
|
{
|
||||||
static uint32_t nextRuntime = 0;
|
static uint32_t nextRuntime = 0;
|
||||||
// while (1) {
|
if (millis() >= nextRuntime) {
|
||||||
if (millis() >= nextRuntime) {
|
nextRuntime = millis() + 10;
|
||||||
nextRuntime = millis() + 10;
|
resetButtonDebouncer.update();
|
||||||
resetButtonDebouncer.update();
|
} else {
|
||||||
} else {
|
|
||||||
yield();
|
yield();
|
||||||
// threads.yield();
|
}
|
||||||
}
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void runCPU(uint32_t now)
|
void runCPU(uint32_t now)
|
||||||
|
@ -323,25 +320,23 @@ void runCPU(uint32_t now)
|
||||||
static uint32_t microsAtStart = micros();
|
static uint32_t microsAtStart = micros();
|
||||||
static uint32_t microsForNext = microsAtStart + (countSinceLast * SPEEDCTL);
|
static uint32_t microsForNext = microsAtStart + (countSinceLast * SPEEDCTL);
|
||||||
|
|
||||||
THREADED {
|
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.
|
((AppleVM *)g_vm)->cpuMaintenance(g_cpu->cycles);
|
||||||
((AppleVM *)g_vm)->cpuMaintenance(g_cpu->cycles);
|
|
||||||
|
microsForNext = microsAtStart + (countSinceLast * SPEEDCTL);
|
||||||
microsForNext = microsAtStart + (countSinceLast * SPEEDCTL);
|
}
|
||||||
}
|
|
||||||
|
if (now >= nextResetMicros) {
|
||||||
if (now >= nextResetMicros) {
|
nextResetMicros = now + 1000000;
|
||||||
nextResetMicros = now + 1000000;
|
|
||||||
#ifdef DEBUG_TIMING
|
#ifdef DEBUG_TIMING
|
||||||
float pct = (100.0 * (float)countSinceLast) / (float)g_speed;
|
float pct = (100.0 * (float)countSinceLast) / (float)g_speed;
|
||||||
sprintf(debugBuf, "CPU running at %f%%", pct);
|
sprintf(debugBuf, "CPU running at %f%%", pct);
|
||||||
println(debugBuf);
|
println(debugBuf);
|
||||||
#endif
|
#endif
|
||||||
countSinceLast = 0;
|
countSinceLast = 0;
|
||||||
microsAtStart = now;
|
microsAtStart = now;
|
||||||
microsForNext = microsAtStart + (countSinceLast * SPEEDCTL);
|
microsForNext = microsAtStart + (countSinceLast * SPEEDCTL);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user