diff --git a/Machines/Electron/Electron.cpp b/Machines/Electron/Electron.cpp index 808bff52b..6d8a0fd2c 100644 --- a/Machines/Electron/Electron.cpp +++ b/Machines/Electron/Electron.cpp @@ -8,10 +8,13 @@ #include "Electron.hpp" +#include + using namespace Electron; Machine::Machine() { + setup6502(); } Machine::~Machine() @@ -20,5 +23,40 @@ Machine::~Machine() unsigned int Machine::perform_bus_operation(CPU6502::BusOperation operation, uint16_t address, uint8_t *value) { + if(address < 32768) + { + if(isReadOperation(operation)) + { + *value = ram[address]; + } + else + { + ram[address] = *value; + } + } + else + { + if(address > 49152) + { + if(isReadOperation(operation)) *value = os[address - 49152]; + } + else + { + if(isReadOperation(operation)) *value = basic[address - 32768]; + } + } + return 1; } + +void Machine::set_rom(ROMSlot slot, size_t length, const uint8_t *data) +{ + uint8_t *target = nullptr; + switch(slot) + { + case ROMTypeBASIC: target = basic; break; + case ROMTypeOS: target = os; break; + } + + memcpy(target, data, std::min((size_t)16384, length)); +} diff --git a/Machines/Electron/Electron.hpp b/Machines/Electron/Electron.hpp index 23f5930c7..82ab352e3 100644 --- a/Machines/Electron/Electron.hpp +++ b/Machines/Electron/Electron.hpp @@ -16,6 +16,11 @@ namespace Electron { +enum ROMSlot: int { + ROMTypeBASIC = 12, + ROMTypeOS = 16, +}; + class Machine: public CPU6502::Processor { public: @@ -25,6 +30,10 @@ class Machine: public CPU6502::Processor { unsigned int perform_bus_operation(CPU6502::BusOperation operation, uint16_t address, uint8_t *value); + void set_rom(ROMSlot slot, size_t length, const uint8_t *data); + + private: + uint8_t os[16384], basic[16384], ram[32768]; }; } diff --git a/OSBindings/Mac/Clock Signal/AppDelegate.swift b/OSBindings/Mac/Clock Signal/AppDelegate.swift index 2abf97a3a..2286db90e 100644 --- a/OSBindings/Mac/Clock Signal/AppDelegate.swift +++ b/OSBindings/Mac/Clock Signal/AppDelegate.swift @@ -11,8 +11,6 @@ import Cocoa @NSApplicationMain class AppDelegate: NSObject, NSApplicationDelegate { - - func applicationDidFinishLaunching(aNotification: NSNotification) { // Insert code here to initialize your application } @@ -21,6 +19,9 @@ class AppDelegate: NSObject, NSApplicationDelegate { // Insert code here to tear down your application } - + // decline to open a new file unless the user explicitly requests it + func applicationShouldOpenUntitledFile(sender: NSApplication) -> Bool { + return false + } } diff --git a/Processors/6502/CPU6502.hpp b/Processors/6502/CPU6502.hpp index 3c420e0a0..2411bc30b 100644 --- a/Processors/6502/CPU6502.hpp +++ b/Processors/6502/CPU6502.hpp @@ -946,6 +946,11 @@ template class Processor { _overflowFlag &= Flag::Overflow; _s = 0; _nextBusOperation = BusOperation::None; + + // TODO: is this accurate? It feels more likely that a CPU would need to wait + // on an explicit reset command, since the relative startup times of different + // components from power on would be a bit unpredictable. + schedule_program(get_reset_program()); } void return_from_subroutine()