mirror of
https://github.com/TomHarte/CLK.git
synced 2024-11-23 03:32:32 +00:00
Added just enough that this is probably a successful boot. I guess I'm going to need to get invested in graphics next? Hmmm.
This commit is contained in:
parent
8c1bfa5a05
commit
47a7654c00
@ -15,6 +15,7 @@ using namespace Electron;
|
|||||||
Machine::Machine()
|
Machine::Machine()
|
||||||
{
|
{
|
||||||
setup6502();
|
setup6502();
|
||||||
|
_interruptStatus = 0x02;
|
||||||
}
|
}
|
||||||
|
|
||||||
Machine::~Machine()
|
Machine::~Machine()
|
||||||
@ -45,19 +46,40 @@ unsigned int Machine::perform_bus_operation(CPU6502::BusOperation operation, uin
|
|||||||
switch(address&0xf)
|
switch(address&0xf)
|
||||||
{
|
{
|
||||||
case 0x0:
|
case 0x0:
|
||||||
|
if(isReadOperation(operation))
|
||||||
|
{
|
||||||
|
*value = _interruptStatus;
|
||||||
|
_interruptStatus &= ~0x02;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_interruptControl = *value;
|
||||||
|
}
|
||||||
printf("Interrupt status or control\n");
|
printf("Interrupt status or control\n");
|
||||||
break;
|
break;
|
||||||
case 0x1:
|
case 0x1:
|
||||||
break;
|
break;
|
||||||
case 0x2:
|
case 0x2:
|
||||||
|
_screenStartAddress = (_screenStartAddress & 0xff00) | ((*value) & 0xe0);
|
||||||
|
printf("Screen start address low, now %04x\n", _screenStartAddress);
|
||||||
|
break;
|
||||||
case 0x3:
|
case 0x3:
|
||||||
printf("Screen start address\n");
|
_screenStartAddress = (_screenStartAddress & 0x00ff) | (uint16_t)(((*value) & 0x3f) << 8);
|
||||||
|
printf("Screen start address high, now %04x\n", _screenStartAddress);
|
||||||
break;
|
break;
|
||||||
case 0x4:
|
case 0x4:
|
||||||
printf("Cassette\n");
|
printf("Cassette\n");
|
||||||
break;
|
break;
|
||||||
case 0x5:
|
case 0x5:
|
||||||
printf("Interrupt clear and paging\n");
|
if(!isReadOperation(operation))
|
||||||
|
{
|
||||||
|
uint8_t nextROM = (*value)&0xf;
|
||||||
|
if((_activeRom&0x12) != 0x8 || nextROM >= 8)
|
||||||
|
{
|
||||||
|
_activeRom = (Electron::ROMSlot)nextROM;
|
||||||
|
}
|
||||||
|
printf("Interrupt clear and paging\n");
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 0x6:
|
case 0x6:
|
||||||
printf("Counter\n");
|
printf("Counter\n");
|
||||||
@ -78,7 +100,21 @@ unsigned int Machine::perform_bus_operation(CPU6502::BusOperation operation, uin
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(isReadOperation(operation)) *value = basic[address - 32768];
|
if(isReadOperation(operation))
|
||||||
|
{
|
||||||
|
switch(_activeRom)
|
||||||
|
{
|
||||||
|
case ROMSlotBASIC:
|
||||||
|
case ROMSlotBASIC+1:
|
||||||
|
*value = basic[address - 32768];
|
||||||
|
break;
|
||||||
|
case ROMSlotKeyboard:
|
||||||
|
case ROMSlotKeyboard+1:
|
||||||
|
*value = 0;
|
||||||
|
break;
|
||||||
|
default: break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -90,8 +126,9 @@ void Machine::set_rom(ROMSlot slot, size_t length, const uint8_t *data)
|
|||||||
uint8_t *target = nullptr;
|
uint8_t *target = nullptr;
|
||||||
switch(slot)
|
switch(slot)
|
||||||
{
|
{
|
||||||
case ROMTypeBASIC: target = basic; break;
|
case ROMSlotBASIC: target = basic; break;
|
||||||
case ROMTypeOS: target = os; break;
|
case ROMSlotOS: target = os; break;
|
||||||
|
default: return;
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(target, data, std::min((size_t)16384, length));
|
memcpy(target, data, std::min((size_t)16384, length));
|
||||||
|
@ -16,9 +16,16 @@
|
|||||||
|
|
||||||
namespace Electron {
|
namespace Electron {
|
||||||
|
|
||||||
enum ROMSlot: int {
|
enum ROMSlot: uint8_t {
|
||||||
ROMTypeBASIC = 12,
|
ROMSlot0 = 0, ROMSlot1, ROMSlot2, ROMSlot3,
|
||||||
ROMTypeOS = 16,
|
ROMSlot4, ROMSlot5, ROMSlot6, ROMSlot7,
|
||||||
|
|
||||||
|
ROMSlotKeyboard = 8, ROMSlot9,
|
||||||
|
ROMSlotBASIC = 10, ROMSlot11,
|
||||||
|
|
||||||
|
ROMSlot12, ROMSlot13, ROMSlot14, ROMSlot15,
|
||||||
|
|
||||||
|
ROMSlotOS
|
||||||
};
|
};
|
||||||
|
|
||||||
class Machine: public CPU6502::Processor<Machine> {
|
class Machine: public CPU6502::Processor<Machine> {
|
||||||
@ -34,6 +41,9 @@ class Machine: public CPU6502::Processor<Machine> {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
uint8_t os[16384], basic[16384], ram[32768];
|
uint8_t os[16384], basic[16384], ram[32768];
|
||||||
|
uint8_t _interruptStatus, _interruptControl;
|
||||||
|
uint16_t _screenStartAddress;
|
||||||
|
ROMSlot _activeRom;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -20,11 +20,11 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
- (void)setOSROM:(nonnull NSData *)rom {
|
- (void)setOSROM:(nonnull NSData *)rom {
|
||||||
_electron.set_rom(Electron::ROMTypeOS, rom.length, (const uint8_t *)rom.bytes);
|
_electron.set_rom(Electron::ROMSlotOS, rom.length, (const uint8_t *)rom.bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setBASICROM:(nonnull NSData *)rom {
|
- (void)setBASICROM:(nonnull NSData *)rom {
|
||||||
_electron.set_rom(Electron::ROMTypeBASIC, rom.length, (const uint8_t *)rom.bytes);
|
_electron.set_rom(Electron::ROMSlotBASIC, rom.length, (const uint8_t *)rom.bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
Loading…
Reference in New Issue
Block a user