1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-11-26 23:52:26 +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)); memset(_palette, 0xf, sizeof(_palette));
_crt = new Outputs::CRT(crt_cycles_per_line, 312, 1, 1); _crt = new Outputs::CRT(crt_cycles_per_line, 312, 1, 1);
_interruptStatus = 0x02; _interruptStatus = 0x02;
for(int c = 0; c < 16; c++)
memset(_roms[c], 0xff, 16384);
setup6502(); setup6502();
} }
@ -55,6 +57,13 @@ unsigned int Machine::perform_bus_operation(CPU6502::BusOperation operation, uin
// TODO: RAM timing for Modes 03 // TODO: RAM timing for Modes 03
cycles += (_frameCycles&1)^1; 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 else
{ {
@ -191,10 +200,6 @@ unsigned int Machine::perform_bus_operation(CPU6502::BusOperation operation, uin
{ {
switch(_activeRom) switch(_activeRom)
{ {
case ROMSlotBASIC:
case ROMSlotBASIC+1:
*value = _basic[address & 16383];
break;
case ROMSlotKeyboard: case ROMSlotKeyboard:
case ROMSlotKeyboard+1: case ROMSlotKeyboard+1:
*value = 0xf0; *value = 0xf0;
@ -204,7 +209,7 @@ unsigned int Machine::perform_bus_operation(CPU6502::BusOperation operation, uin
} }
break; break;
default: default:
*value = 0xff; *value = _roms[_activeRom][address & 16383];
break; break;
} }
} }
@ -235,9 +240,8 @@ 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 ROMSlotBASIC: target = _basic; break;
case ROMSlotOS: target = _os; break; case ROMSlotOS: target = _os; break;
default: return; default: target = _roms[slot]; break;
} }
memcpy(target, data, std::min((size_t)16384, length)); 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(); const char *get_signal_decoder();
private: 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 _interruptStatus, _interruptControl;
uint8_t _palette[16]; uint8_t _palette[16];
uint8_t _keyStates[14]; uint8_t _keyStates[14];

View File

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

View File

@ -41,6 +41,20 @@
<key>NSDocumentClass</key> <key>NSDocumentClass</key>
<string>$(PRODUCT_MODULE_NAME).ElectronDocument</string> <string>$(PRODUCT_MODULE_NAME).ElectronDocument</string>
</dict> </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> </array>
<key>CFBundleExecutable</key> <key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string> <string>$(EXECUTABLE_NAME)</string>

View File

@ -13,6 +13,7 @@
- (void)setOSROM:(nonnull NSData *)rom; - (void)setOSROM:(nonnull NSData *)rom;
- (void)setBASICROM:(nonnull NSData *)rom; - (void)setBASICROM:(nonnull NSData *)rom;
- (void)setROM:(nonnull NSData *)rom slot:(int)slot;
- (void)setKey:(uint16_t)key isPressed:(BOOL)isPressed; - (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); _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); _electron.get_crt()->set_delegate(delegate);
} }