1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-06-25 18:30:07 +00:00

Made an attempt at correct timing, adding support for additional paged ROMs, added file association for .rom.

This commit is contained in:
Thomas Harte 2016-01-12 22:34:26 -05:00
parent 84ba4e2900
commit d28abdc037
6 changed files with 35 additions and 10 deletions

View File

@ -27,6 +27,8 @@ Machine::Machine() :
memset(_palette, 0xf, sizeof(_palette));
_crt = new Outputs::CRT(crt_cycles_per_line, 312, 1, 1);
_interruptStatus = 0x02;
for(int c = 0; c < 16; c++)
memset(_roms[c], 0xff, 16384);
setup6502();
}
@ -55,6 +57,13 @@ unsigned int Machine::perform_bus_operation(CPU6502::BusOperation operation, uin
// TODO: RAM timing for Modes 03
cycles += (_frameCycles&1)^1;
if(_screenMode < 4)
{
const int current_line = _frameCycles >> 7;
const int line_position = _frameCycles & 127;
if(current_line >= 28 && current_line < 28+256 && line_position >= 24 && line_position < 104)
cycles = (unsigned int)(104 - line_position);
}
}
else
{
@ -191,10 +200,6 @@ unsigned int Machine::perform_bus_operation(CPU6502::BusOperation operation, uin
{
switch(_activeRom)
{
case ROMSlotBASIC:
case ROMSlotBASIC+1:
*value = _basic[address & 16383];
break;
case ROMSlotKeyboard:
case ROMSlotKeyboard+1:
*value = 0xf0;
@ -204,7 +209,7 @@ unsigned int Machine::perform_bus_operation(CPU6502::BusOperation operation, uin
}
break;
default:
*value = 0xff;
*value = _roms[_activeRom][address & 16383];
break;
}
}
@ -235,9 +240,8 @@ void Machine::set_rom(ROMSlot slot, size_t length, const uint8_t *data)
uint8_t *target = nullptr;
switch(slot)
{
case ROMSlotBASIC: target = _basic; break;
case ROMSlotOS: target = _os; break;
default: return;
case ROMSlotOS: target = _os; break;
default: target = _roms[slot]; break;
}
memcpy(target, data, std::min((size_t)16384, length));

View File

@ -73,7 +73,8 @@ class Machine: public CPU6502::Processor<Machine> {
const char *get_signal_decoder();
private:
uint8_t _os[16384], _basic[16384], _ram[32768];
uint8_t _roms[16][16384];
uint8_t _os[16384], _ram[32768];
uint8_t _interruptStatus, _interruptControl;
uint8_t _palette[16];
uint8_t _keyStates[14];

View File

@ -34,6 +34,7 @@ class ElectronDocument: MachineDocument {
}
override func readFromData(data: NSData, ofType typeName: String) throws {
electron.setROM(data, slot: 15)
}
// MARK: CSOpenGLViewDelegate

View File

@ -41,6 +41,20 @@
<key>NSDocumentClass</key>
<string>$(PRODUCT_MODULE_NAME).ElectronDocument</string>
</dict>
<dict>
<key>CFBundleTypeExtensions</key>
<array>
<string>rom</string>
</array>
<key>CFBundleTypeName</key>
<string>Electron/BBC ROM Image</string>
<key>CFBundleTypeRole</key>
<string>Viewer</string>
<key>LSTypeIsPackage</key>
<integer>0</integer>
<key>NSDocumentClass</key>
<string>$(PRODUCT_MODULE_NAME).ElectronDocument</string>
</dict>
</array>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>

View File

@ -13,6 +13,7 @@
- (void)setOSROM:(nonnull NSData *)rom;
- (void)setBASICROM:(nonnull NSData *)rom;
- (void)setROM:(nonnull NSData *)rom slot:(int)slot;
- (void)setKey:(uint16_t)key isPressed:(BOOL)isPressed;

View File

@ -27,7 +27,11 @@
_electron.set_rom(Electron::ROMSlotBASIC, rom.length, (const uint8_t *)rom.bytes);
}
- (void)setCRTDelegate:(Outputs::CRT::Delegate *)delegate{
- (void)setROM:(nonnull NSData *)rom slot:(int)slot {
_electron.set_rom((Electron::ROMSlot)slot, rom.length, (const uint8_t *)rom.bytes);
}
- (void)setCRTDelegate:(Outputs::CRT::Delegate *)delegate {
_electron.get_crt()->set_delegate(delegate);
}