mirror of
https://github.com/TomHarte/CLK.git
synced 2025-02-16 18:30:32 +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:
parent
c69b3256ba
commit
bfd9957c81
@ -8,10 +8,13 @@
|
|||||||
|
|
||||||
#include "Electron.hpp"
|
#include "Electron.hpp"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
using namespace Electron;
|
using namespace Electron;
|
||||||
|
|
||||||
Machine::Machine()
|
Machine::Machine()
|
||||||
{
|
{
|
||||||
|
setup6502();
|
||||||
}
|
}
|
||||||
|
|
||||||
Machine::~Machine()
|
Machine::~Machine()
|
||||||
@ -20,5 +23,40 @@ Machine::~Machine()
|
|||||||
|
|
||||||
unsigned int Machine::perform_bus_operation(CPU6502::BusOperation operation, uint16_t address, uint8_t *value)
|
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;
|
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));
|
||||||
|
}
|
||||||
|
@ -16,6 +16,11 @@
|
|||||||
|
|
||||||
namespace Electron {
|
namespace Electron {
|
||||||
|
|
||||||
|
enum ROMSlot: int {
|
||||||
|
ROMTypeBASIC = 12,
|
||||||
|
ROMTypeOS = 16,
|
||||||
|
};
|
||||||
|
|
||||||
class Machine: public CPU6502::Processor<Machine> {
|
class Machine: public CPU6502::Processor<Machine> {
|
||||||
|
|
||||||
public:
|
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);
|
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];
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -11,8 +11,6 @@ import Cocoa
|
|||||||
@NSApplicationMain
|
@NSApplicationMain
|
||||||
class AppDelegate: NSObject, NSApplicationDelegate {
|
class AppDelegate: NSObject, NSApplicationDelegate {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
func applicationDidFinishLaunching(aNotification: NSNotification) {
|
func applicationDidFinishLaunching(aNotification: NSNotification) {
|
||||||
// Insert code here to initialize your application
|
// Insert code here to initialize your application
|
||||||
}
|
}
|
||||||
@ -21,6 +19,9 @@ class AppDelegate: NSObject, NSApplicationDelegate {
|
|||||||
// Insert code here to tear down your application
|
// 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
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -946,6 +946,11 @@ template <class T> class Processor {
|
|||||||
_overflowFlag &= Flag::Overflow;
|
_overflowFlag &= Flag::Overflow;
|
||||||
_s = 0;
|
_s = 0;
|
||||||
_nextBusOperation = BusOperation::None;
|
_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()
|
void return_from_subroutine()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user