1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-07-05 10:28:58 +00:00

You now get an Electron only if you ask for a new file. That'll do for now while it's the only thing that one might want to start without supplying a file. The 6502 now starts from a defined point — being reset. The Electron is starting to grow the absolute most simple buds of its memory map.

This commit is contained in:
Thomas Harte 2016-01-06 21:09:49 -05:00
parent c69b3256ba
commit bfd9957c81
4 changed files with 56 additions and 3 deletions

View File

@ -8,10 +8,13 @@
#include "Electron.hpp"
#include <algorithm>
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));
}

View File

@ -16,6 +16,11 @@
namespace Electron {
enum ROMSlot: int {
ROMTypeBASIC = 12,
ROMTypeOS = 16,
};
class Machine: public CPU6502::Processor<Machine> {
public:
@ -25,6 +30,10 @@ class Machine: public CPU6502::Processor<Machine> {
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];
};
}

View File

@ -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
}
}

View File

@ -946,6 +946,11 @@ template <class T> 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()