diff --git a/hardware.cpp b/hardware.cpp index 604c963..10c35b3 100644 --- a/hardware.cpp +++ b/hardware.cpp @@ -14,15 +14,10 @@ spiram sram(SPIRAM_SIZE); UTFT utft(TFT_MODEL, TFT_RS, TFT_WR, TFT_CS, TFT_RST); static CPU *_cpu; -bool hardware_init(CPU &cpu) { - _cpu = &cpu; - ps2.begin(KBD_DATA, KBD_IRQ); - - pinMode(SD_CS, OUTPUT); +bool hardware_reset() { bool sd = SD.begin(SD_CS, 3, SD_SPI); #if defined(TFT_BACKLIGHT) - pinMode(TFT_BACKLIGHT, OUTPUT); digitalWrite(TFT_BACKLIGHT, HIGH); #endif utft.InitLCD(); @@ -31,10 +26,20 @@ bool hardware_init(CPU &cpu) { sram.begin(SPIRAM_CS, SPIRAM_SPI); - cpu.reset(); + _cpu->reset(); return sd; } +void hardware_init(CPU &cpu) { + _cpu = &cpu; + memory.begin(); + ps2.begin(KBD_DATA, KBD_IRQ); + pinMode(SD_CS, OUTPUT); +#if defined(TFT_BACKLIGHT) + pinMode(TFT_BACKLIGHT, OUTPUT); +#endif +} + void hardware_checkpoint(Stream &s) { unsigned ds = 0; for (unsigned i = 0; i < 0x10000; i += ds) { diff --git a/hardware.h b/hardware.h index 15c316c..633f984 100644 --- a/hardware.h +++ b/hardware.h @@ -32,7 +32,8 @@ #define SD_CS PF_3 #define SD_SPI 1 -bool hardware_init(class CPU &); +bool hardware_reset(); +void hardware_init(class CPU &); void hardware_checkpoint(Stream &); // FIXME: make a path? void hardware_restore(Stream &);