1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-11-26 08:49:37 +00:00

Added enough to load a PRG as a ROM.

This commit is contained in:
Thomas Harte 2016-06-11 14:00:12 -04:00
parent d9b001d3fc
commit 167ed9b8bb
3 changed files with 21 additions and 1 deletions

View File

@ -14,13 +14,19 @@ using namespace Vic20;
Machine::Machine() :
_userPortVIA(new UserPortVIA()),
_keyboardVIA(new KeyboardVIA())
_keyboardVIA(new KeyboardVIA()),
_rom(nullptr)
{
_userPortVIA->set_delegate(this);
_keyboardVIA->set_delegate(this);
set_reset_line(true);
}
Machine::~Machine()
{
delete[] _rom;
}
unsigned int Machine::perform_bus_operation(CPU6502::BusOperation operation, uint16_t address, uint8_t *value)
{
set_reset_line(false);
@ -115,4 +121,11 @@ void Machine::set_rom(ROMSlot slot, size_t length, const uint8_t *data)
void Machine::add_prg(size_t length, const uint8_t *data)
{
if(length > 2)
{
_rom_address = (uint16_t)(data[0] | (data[1] << 8));
_rom_length = (uint16_t)(length - 2);
_rom = new uint8_t[length - 2];
memcpy(_rom, &data[2], length - 2);
}
}

View File

@ -94,6 +94,7 @@ class KeyboardVIA: public MOS::MOS6522<KeyboardVIA> {
class Machine: public CPU6502::Processor<Machine>, public CRTMachine::Machine, public MOS::MOS6522Delegate {
public:
Machine();
~Machine();
void set_rom(ROMSlot slot, size_t length, const uint8_t *data);
void add_prg(size_t length, const uint8_t *data);
@ -118,6 +119,9 @@ class Machine: public CPU6502::Processor<Machine>, public CRTMachine::Machine, p
uint8_t _basicROM[0x2000];
uint8_t _kernelROM[0x2000];
uint8_t *_rom;
uint16_t _rom_address, _rom_length;
uint8_t _userBASICMemory[0x0400];
uint8_t _screenMemory[0x1000];
uint8_t _colorMemory[0x0400];
@ -135,6 +139,7 @@ class Machine: public CPU6502::Processor<Machine>, public CRTMachine::Machine, p
else if(address >= 0x8000 && address < 0x9000) return _characterROM[address&0x0fff];
else if(address >= 0xc000 && address < 0xe000) return _basicROM[address&0x1fff];
else if(address >= 0xe000) return _kernelROM[address&0x1fff];
else if(address >= _rom_address && address < _rom_address+_rom_length) return _rom[address - _rom_address];
return 0xff;
}

View File

@ -83,6 +83,8 @@
{
_vic20.set_key_state((Vic20::Key)targetKey.integerValue, isPressed);
}
else
NSLog(@"Unmapped: %02x", key);
} break;
case VK_Shift: