2016-06-04 21:43:50 -04:00
|
|
|
//
|
|
|
|
// Vic20Document.swift
|
|
|
|
// Clock Signal
|
|
|
|
//
|
|
|
|
// Created by Thomas Harte on 04/06/2016.
|
|
|
|
// Copyright © 2016 Thomas Harte. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
import Foundation
|
|
|
|
|
|
|
|
class Vic20Document: MachineDocument {
|
|
|
|
|
|
|
|
private lazy var vic20 = CSVic20()
|
|
|
|
override func machine() -> CSMachine! {
|
|
|
|
return vic20
|
|
|
|
}
|
|
|
|
|
|
|
|
// MARK: NSDocument overrides
|
|
|
|
override init() {
|
|
|
|
super.init()
|
2016-06-05 08:53:05 -04:00
|
|
|
|
2016-06-05 11:20:05 -04:00
|
|
|
if let kernel = rom("kernel-ntsc"), basic = rom("basic"), characters = rom("characters-english") {
|
2016-06-05 08:53:05 -04:00
|
|
|
vic20.setKernelROM(kernel)
|
|
|
|
vic20.setBASICROM(basic)
|
|
|
|
vic20.setCharactersROM(characters)
|
|
|
|
}
|
2016-06-04 21:43:50 -04:00
|
|
|
}
|
2016-06-04 21:49:03 -04:00
|
|
|
|
|
|
|
override class func autosavesInPlace() -> Bool {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
|
|
|
override var windowNibName: String? {
|
|
|
|
return "Vic20Document"
|
|
|
|
}
|
|
|
|
|
2016-06-05 08:53:05 -04:00
|
|
|
// MARK: machine setup
|
|
|
|
private func rom(name: String) -> NSData? {
|
|
|
|
return dataForResource(name, ofType: "bin", inDirectory: "ROMImages/Vic20")
|
|
|
|
}
|
|
|
|
|
2016-06-04 21:49:03 -04:00
|
|
|
override func readFromData(data: NSData, ofType typeName: String) throws {
|
2016-06-05 09:01:32 -04:00
|
|
|
vic20.setPRG(data)
|
2016-06-04 21:49:03 -04:00
|
|
|
}
|
2016-06-04 21:43:50 -04:00
|
|
|
}
|