mirror of
https://github.com/TomHarte/CLK.git
synced 2024-12-26 09:29:45 +00:00
System ROMs are now supplied to the Vic-20 wrapper, though they stop there. I also factored key forwarding out of the ElectronDocument and into the superclass, depending upon the child conforming to CSKeyboardMachine.
This commit is contained in:
parent
363e14a92f
commit
8052ce9223
@ -685,6 +685,7 @@
|
||||
4BC76E681C98E31700E6EF73 /* FIRFilter.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = FIRFilter.hpp; sourceTree = "<group>"; };
|
||||
4BC76E6A1C98F43700E6EF73 /* Accelerate.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Accelerate.framework; path = System/Library/Frameworks/Accelerate.framework; sourceTree = SDKROOT; };
|
||||
4BC9DF441D044FCA00F44158 /* ROMImages */ = {isa = PBXFileReference; lastKnownFileType = folder; name = ROMImages; path = ../../../../ROMImages; sourceTree = "<group>"; };
|
||||
4BC9DF461D04565200F44158 /* CSKeyboardMachine.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSKeyboardMachine.h; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
@ -796,6 +797,7 @@
|
||||
4B55CE4A1C3B3B0C0093A61B /* CSAtari2600.mm */,
|
||||
4B55CE521C3B7ABF0093A61B /* CSElectron.h */,
|
||||
4B55CE531C3B7ABF0093A61B /* CSElectron.mm */,
|
||||
4BC9DF461D04565200F44158 /* CSKeyboardMachine.h */,
|
||||
4B55CE4C1C3B3BDA0093A61B /* CSMachine.h */,
|
||||
4B55CE4D1C3B3BDA0093A61B /* CSMachine.mm */,
|
||||
4B55CE4F1C3B78A80093A61B /* CSMachine+Subclassing.h */,
|
||||
|
@ -3,6 +3,7 @@
|
||||
//
|
||||
|
||||
#import "CSMachine.h"
|
||||
#import "CSKeyboardMachine.h"
|
||||
|
||||
#import "CSAtari2600.h"
|
||||
#import "CSElectron.h"
|
||||
|
@ -21,7 +21,7 @@ class ElectronDocument: MachineDocument {
|
||||
}
|
||||
|
||||
private func rom(name: String) -> NSData? {
|
||||
return dataForResource(name, ofType: "rom", inDirectory: "ROMImages/Electron")
|
||||
return dataForResource(name, ofType: "rom", inDirectory: "ROMImages/Electron")
|
||||
}
|
||||
|
||||
override func windowControllerDidLoadNib(aController: NSWindowController) {
|
||||
@ -29,10 +29,8 @@ class ElectronDocument: MachineDocument {
|
||||
|
||||
self.intendedCyclesPerSecond = 2000000
|
||||
|
||||
if let os = rom("os") {
|
||||
if let os = rom("os"), basic = rom("basic") {
|
||||
self.electron.setOSROM(os)
|
||||
}
|
||||
if let basic = rom("basic") {
|
||||
self.electron.setBASICROM(basic)
|
||||
}
|
||||
|
||||
@ -97,25 +95,4 @@ class ElectronDocument: MachineDocument {
|
||||
electron.useTelevisionOutput = (displayType == 1)
|
||||
self.displayTypeButton.selectItemAtIndex(displayType)
|
||||
}
|
||||
|
||||
// MARK: NSWindowDelegate
|
||||
func windowDidResignKey(notification: NSNotification) {
|
||||
electron.clearAllKeys()
|
||||
}
|
||||
|
||||
// MARK: CSOpenGLViewResponderDelegate
|
||||
override func keyDown(event: NSEvent) {
|
||||
electron.setKey(event.keyCode, isPressed: true)
|
||||
}
|
||||
|
||||
override func keyUp(event: NSEvent) {
|
||||
electron.setKey(event.keyCode, isPressed: false)
|
||||
}
|
||||
|
||||
override func flagsChanged(newModifiers: NSEvent) {
|
||||
electron.setKey(VK_Shift, isPressed: newModifiers.modifierFlags.contains(.ShiftKeyMask))
|
||||
electron.setKey(VK_Control, isPressed: newModifiers.modifierFlags.contains(.ControlKeyMask))
|
||||
electron.setKey(VK_Command, isPressed: newModifiers.modifierFlags.contains(.CommandKeyMask))
|
||||
electron.setKey(VK_Option, isPressed: newModifiers.modifierFlags.contains(.AlternateKeyMask))
|
||||
}
|
||||
}
|
||||
|
@ -119,13 +119,36 @@ class MachineDocument: NSDocument, CSOpenGLViewDelegate, CSOpenGLViewResponderDe
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: CSOpenGLViewResponderDelegate
|
||||
func keyDown(event: NSEvent) {}
|
||||
func keyUp(event: NSEvent) {}
|
||||
func flagsChanged(newModifiers: NSEvent) {}
|
||||
|
||||
// MARK: NSDocument overrides
|
||||
override func dataOfType(typeName: String) throws -> NSData {
|
||||
throw NSError(domain: NSOSStatusErrorDomain, code: unimpErr, userInfo: nil)
|
||||
}
|
||||
|
||||
// MARK: Key forwarding
|
||||
private func withKeyboardMachine(action: (CSKeyboardMachine) -> ()) {
|
||||
if let keyboardMachine = self.machine() as? CSKeyboardMachine {
|
||||
action(keyboardMachine)
|
||||
}
|
||||
}
|
||||
|
||||
func windowDidResignKey(notification: NSNotification) {
|
||||
self.withKeyboardMachine { $0.clearAllKeys() }
|
||||
}
|
||||
|
||||
func keyDown(event: NSEvent) {
|
||||
self.withKeyboardMachine { $0.setKey(event.keyCode, isPressed: true) }
|
||||
}
|
||||
|
||||
func keyUp(event: NSEvent) {
|
||||
self.withKeyboardMachine { $0.setKey(event.keyCode, isPressed: false) }
|
||||
}
|
||||
|
||||
func flagsChanged(newModifiers: NSEvent) {
|
||||
self.withKeyboardMachine {
|
||||
$0.setKey(VK_Shift, isPressed: newModifiers.modifierFlags.contains(.ShiftKeyMask))
|
||||
$0.setKey(VK_Control, isPressed: newModifiers.modifierFlags.contains(.ControlKeyMask))
|
||||
$0.setKey(VK_Command, isPressed: newModifiers.modifierFlags.contains(.CommandKeyMask))
|
||||
$0.setKey(VK_Option, isPressed: newModifiers.modifierFlags.contains(.AlternateKeyMask))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -20,6 +20,12 @@ class Vic20Document: MachineDocument {
|
||||
super.init()
|
||||
self.intendedCyclesPerSecond = 1022727
|
||||
// TODO: or 1108405 for PAL; see http://www.antimon.org/dl/c64/code/stable.txt
|
||||
|
||||
if let kernel = rom("kernel"), basic = rom("basic"), characters = rom("characters-english") {
|
||||
vic20.setKernelROM(kernel)
|
||||
vic20.setBASICROM(basic)
|
||||
vic20.setCharactersROM(characters)
|
||||
}
|
||||
}
|
||||
|
||||
override class func autosavesInPlace() -> Bool {
|
||||
@ -30,6 +36,11 @@ class Vic20Document: MachineDocument {
|
||||
return "Vic20Document"
|
||||
}
|
||||
|
||||
// MARK: machine setup
|
||||
private func rom(name: String) -> NSData? {
|
||||
return dataForResource(name, ofType: "bin", inDirectory: "ROMImages/Vic20")
|
||||
}
|
||||
|
||||
override func readFromData(data: NSData, ofType typeName: String) throws {
|
||||
print("\(data.length)")
|
||||
}
|
||||
|
@ -8,17 +8,15 @@
|
||||
|
||||
#include "CSMachine.h"
|
||||
#import "KeyCodes.h"
|
||||
#import "CSKeyboardMachine.h"
|
||||
|
||||
@interface CSElectron : CSMachine
|
||||
@interface CSElectron : CSMachine <CSKeyboardMachine>
|
||||
|
||||
- (void)setOSROM:(nonnull NSData *)rom;
|
||||
- (void)setBASICROM:(nonnull NSData *)rom;
|
||||
- (void)setROM:(nonnull NSData *)rom slot:(int)slot;
|
||||
- (BOOL)openUEFAtURL:(nonnull NSURL *)URL;
|
||||
|
||||
- (void)setKey:(uint16_t)key isPressed:(BOOL)isPressed;
|
||||
- (void)clearAllKeys;
|
||||
|
||||
@property (nonatomic, assign) BOOL useFastLoadingHack;
|
||||
@property (nonatomic, assign) BOOL useTelevisionOutput;
|
||||
|
||||
|
14
OSBindings/Mac/Clock Signal/Wrappers/CSKeyboardMachine.h
Normal file
14
OSBindings/Mac/Clock Signal/Wrappers/CSKeyboardMachine.h
Normal file
@ -0,0 +1,14 @@
|
||||
//
|
||||
// CSKeyboardMachine.h
|
||||
// Clock Signal
|
||||
//
|
||||
// Created by Thomas Harte on 05/06/2016.
|
||||
// Copyright © 2016 Thomas Harte. All rights reserved.
|
||||
//
|
||||
|
||||
@protocol CSKeyboardMachine <NSObject>
|
||||
|
||||
- (void)setKey:(uint16_t)key isPressed:(BOOL)isPressed;
|
||||
- (void)clearAllKeys;
|
||||
|
||||
@end
|
@ -7,7 +7,13 @@
|
||||
//
|
||||
|
||||
#import "CSMachine.h"
|
||||
#import "CSKeyboardMachine.h"
|
||||
|
||||
@interface CSVic20 : CSMachine
|
||||
@interface CSVic20 : CSMachine <CSKeyboardMachine>
|
||||
|
||||
- (void)setKernelROM:(nonnull NSData *)rom;
|
||||
- (void)setBASICROM:(nonnull NSData *)rom;
|
||||
- (void)setCharactersROM:(nonnull NSData *)rom;
|
||||
- (void)setROM:(nonnull NSData *)rom address:(uint16_t)address;
|
||||
|
||||
@end
|
||||
|
@ -18,4 +18,22 @@
|
||||
return &_vic20;
|
||||
}
|
||||
|
||||
- (void)setKernelROM:(nonnull NSData *)rom {
|
||||
}
|
||||
|
||||
- (void)setBASICROM:(nonnull NSData *)rom {
|
||||
}
|
||||
|
||||
- (void)setCharactersROM:(nonnull NSData *)rom {
|
||||
}
|
||||
|
||||
- (void)setROM:(nonnull NSData *)rom address:(uint16_t)address {
|
||||
}
|
||||
|
||||
- (void)setKey:(uint16_t)key isPressed:(BOOL)isPressed {
|
||||
}
|
||||
|
||||
- (void)clearAllKeys {
|
||||
}
|
||||
|
||||
@end
|
||||
|
Loading…
Reference in New Issue
Block a user