common serial; added disk debugging

This commit is contained in:
Jorj Bauer 2020-07-04 08:03:58 -04:00
parent 0033490cc5
commit 89895f828a
1 changed files with 26 additions and 16 deletions

View File

@ -13,6 +13,7 @@
#include "teensy-filemanager.h" #include "teensy-filemanager.h"
#include "appleui.h" #include "appleui.h"
#include "teensy-prefs.h" #include "teensy-prefs.h"
#include "teensy-println.h"
#define RESETPIN 39 #define RESETPIN 39
#define BATTERYPIN 32 #define BATTERYPIN 32
@ -55,9 +56,9 @@ void setup()
setSyncProvider(getTeensy3Time); setSyncProvider(getTeensy3Time);
delay(100); // don't know if we need this delay(100); // don't know if we need this
if (timeStatus() == timeSet) { if (timeStatus() == timeSet) {
Serial.println("RTC set from Teensy"); println("RTC set from Teensy");
} else { } else {
Serial.println("Error while setting RTC"); println("Error while setting RTC");
} }
pinMode(RESETPIN, INPUT); pinMode(RESETPIN, INPUT);
@ -71,54 +72,54 @@ void setup()
pinMode(SPEAKERPIN, OUTPUT); // analog speaker output, used as digital volume control pinMode(SPEAKERPIN, OUTPUT); // analog speaker output, used as digital volume control
pinMode(BATTERYPIN, INPUT); pinMode(BATTERYPIN, INPUT);
Serial.println("creating virtual hardware"); println("creating virtual hardware");
g_speaker = new TeensySpeaker(SPEAKERPIN); g_speaker = new TeensySpeaker(SPEAKERPIN);
Serial.println(" fm"); println(" fm");
// First create the filemanager - the interface to the host file system. // First create the filemanager - the interface to the host file system.
g_filemanager = new TeensyFileManager(); g_filemanager = new TeensyFileManager();
// Construct the interface to the host display. This will need the // Construct the interface to the host display. This will need the
// VM's video buffer in order to draw the VM, but we don't have that // VM's video buffer in order to draw the VM, but we don't have that
// yet. // yet.
Serial.println(" display"); println(" display");
g_display = new TeensyDisplay(); g_display = new TeensyDisplay();
Serial.println(" UI"); println(" UI");
g_ui = new AppleUI(); g_ui = new AppleUI();
// Next create the virtual CPU. This needs the VM's MMU in order to // Next create the virtual CPU. This needs the VM's MMU in order to
// run, but we don't have that yet. // run, but we don't have that yet.
Serial.println(" cpu"); println(" cpu");
g_cpu = new Cpu(); g_cpu = new Cpu();
// Create the virtual machine. This may read from g_filemanager to // Create the virtual machine. This may read from g_filemanager to
// get ROMs if necessary. (The actual Apple VM we've built has them // get ROMs if necessary. (The actual Apple VM we've built has them
// compiled in, though.) It will create its virutal hardware (MMU, // compiled in, though.) It will create its virutal hardware (MMU,
// video driver, floppy, paddles, whatever). // video driver, floppy, paddles, whatever).
Serial.println(" vm"); println(" vm");
g_vm = new AppleVM(); g_vm = new AppleVM();
// Now that the VM exists and it has created an MMU, we tell the CPU // Now that the VM exists and it has created an MMU, we tell the CPU
// how to access memory through the MMU. // how to access memory through the MMU.
Serial.println(" [setMMU]"); println(" [setMMU]");
g_cpu->SetMMU(g_vm->getMMU()); g_cpu->SetMMU(g_vm->getMMU());
// And the physical keyboard needs hooks in to the virtual keyboard... // And the physical keyboard needs hooks in to the virtual keyboard...
Serial.println(" keyboard"); println(" keyboard");
g_keyboard = new TeensyKeyboard(g_vm->getKeyboard()); g_keyboard = new TeensyKeyboard(g_vm->getKeyboard());
Serial.println(" paddles"); println(" paddles");
g_paddles = new TeensyPaddles(A23, A24, 1, 1); g_paddles = new TeensyPaddles(A23, A24, 1, 1);
// Now that all the virtual hardware is glued together, reset the VM // Now that all the virtual hardware is glued together, reset the VM
Serial.println("Resetting VM"); println("Resetting VM");
g_vm->Reset(); g_vm->Reset();
g_display->redraw(); g_display->redraw();
// g_display->blit(); // g_display->blit();
Serial.println("Reading prefs"); println("Reading prefs");
readPrefs(); // read from eeprom and set anything we need setting readPrefs(); // read from eeprom and set anything we need setting
startMicros = nextInstructionMicros = micros(); startMicros = nextInstructionMicros = micros();
@ -132,9 +133,9 @@ void setup()
// pinMode(57, OUTPUT); // pinMode(57, OUTPUT);
Serial.print("Free RAM: "); Serial.print("Free RAM: ");
Serial.println(FreeRamEstimate()); println(FreeRamEstimate());
Serial.println("free-running"); println("free-running");
threads.setDefaultTimeSlice(1); threads.setDefaultTimeSlice(1);
threads.setSliceMicros(500); threads.setSliceMicros(500);
@ -301,7 +302,7 @@ void loop()
*/ */
#if 0 #if 0
Serial.print("battery: "); Serial.print("battery: ");
Serial.println(batteryLevel); println(batteryLevel);
#endif #endif
if (batteryLevel < 146) if (batteryLevel < 146)
@ -356,6 +357,15 @@ void doDebugging()
sprintf(buf, "%.2d:%.2d:%.2d", hour(), minute(), second()); sprintf(buf, "%.2d:%.2d:%.2d", hour(), minute(), second());
g_display->debugMsg(buf); g_display->debugMsg(buf);
break; break;
case D_SHOWDSK:
{
uint8_t sd = ((AppleVM *)g_vm)->disk6->selectedDrive();
sprintf(buf, "s %d t %d",
sd,
((AppleVM *)g_vm)->disk6->headPosition(sd));
g_display->debugMsg(buf);
}
break;
} }
} }