1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-10-04 17:56:29 +00:00

Made the slightest possible effort to get TAPs opened and passed to the VIC.

This commit is contained in:
Thomas Harte 2016-06-25 16:24:52 -04:00
parent ee19417ded
commit 8741be5c84
8 changed files with 55 additions and 9 deletions

View File

@ -135,6 +135,18 @@ void Machine::add_prg(size_t length, const uint8_t *data)
}
}
#pragma mar - Tape
void Machine::set_tape(std::shared_ptr<Storage::Tape> tape)
{
tape->get_next_pulse();
tape->get_next_pulse();
tape->get_next_pulse();
tape->get_next_pulse();
tape->get_next_pulse();
tape->get_next_pulse();
}
#pragma mark - Typer
int Machine::get_typer_delay()

View File

@ -10,6 +10,7 @@
#define Vic20_hpp
#include "../../Processors/6502/CPU6502.hpp"
#include "../../Storage/Tape/Tape.hpp"
#include "../../Components/6560/6560.hpp"
#include "../../Components/6522/6522.hpp"
@ -104,6 +105,8 @@ class Machine:
void set_rom(ROMSlot slot, size_t length, const uint8_t *data);
void add_prg(size_t length, const uint8_t *data);
void set_tape(std::shared_ptr<Storage::Tape> tape);
void set_key_state(Key key, bool isPressed) { _keyboardVIA.set_key_state(key, isPressed); }
void clear_all_keys() { _keyboardVIA.clear_all_keys(); }

View File

@ -42,9 +42,6 @@ class ElectronDocument: MachineDocument {
}
override func readFromURL(url: NSURL, ofType typeName: String) throws {
print(url)
print(typeName)
if let pathExtension = url.pathExtension {
switch pathExtension.lowercaseString {
case "uef":

View File

@ -36,6 +36,20 @@ class Vic20Document: MachineDocument {
return "Vic20Document"
}
override func readFromURL(url: NSURL, ofType typeName: String) throws {
if let pathExtension = url.pathExtension {
switch pathExtension.lowercaseString {
case "tap":
vic20.openTAPAtURL(url)
return
default: break;
}
}
let fileWrapper = try NSFileWrapper(URL: url, options: NSFileWrapperReadingOptions(rawValue: 0))
try self.readFromFileWrapper(fileWrapper, ofType: typeName)
}
// MARK: machine setup
private func rom(name: String) -> NSData? {
return dataForResource(name, ofType: "bin", inDirectory: "ROMImages/Vic20")

View File

@ -98,7 +98,7 @@
<key>CFBundleTypeRole</key>
<string>Viewer</string>
<key>NSDocumentClass</key>
<string>Vic20Document</string>
<string>$(PRODUCT_MODULE_NAME).Vic20Document</string>
</dict>
</array>
<key>CFBundleExecutable</key>

View File

@ -8,9 +8,9 @@
#import "CSElectron.h"
#import "Electron.hpp"
#include "Electron.hpp"
#import "CSMachine+Subclassing.h"
#import "TapeUEF.hpp"
#include "TapeUEF.hpp"
@implementation CSElectron {
Electron::Machine _electron;

View File

@ -14,6 +14,8 @@
- (void)setKernelROM:(nonnull NSData *)rom;
- (void)setBASICROM:(nonnull NSData *)rom;
- (void)setCharactersROM:(nonnull NSData *)rom;
- (void)setPRG:(nonnull NSData *)prg;
- (BOOL)openTAPAtURL:(nonnull NSURL *)URL;
@end

View File

@ -8,7 +8,8 @@
#import "CSVic20.h"
#import "Vic20.hpp"
#include "Vic20.hpp"
#include "CommodoreTAP.hpp"
@implementation CSVic20 {
Vic20::Machine _vic20;
@ -19,7 +20,9 @@
}
- (void)setROM:(nonnull NSData *)rom slot:(Vic20::ROMSlot)slot {
_vic20.set_rom(slot, rom.length, (const uint8_t *)rom.bytes);
@synchronized(self) {
_vic20.set_rom(slot, rom.length, (const uint8_t *)rom.bytes);
}
}
- (void)setKernelROM:(nonnull NSData *)rom {
@ -34,8 +37,23 @@
[self setROM:rom slot:Vic20::ROMSlotCharacters];
}
- (BOOL)openTAPAtURL:(NSURL *)URL {
@synchronized(self) {
try {
std::shared_ptr<Storage::CommodoreTAP> tape(new Storage::CommodoreTAP([URL fileSystemRepresentation]));
_vic20.set_tape(tape);
return YES;
} catch(int exception) {
return NO;
}
}
}
- (void)setPRG:(nonnull NSData *)prg {
_vic20.add_prg(prg.length, (const uint8_t *)prg.bytes);
@synchronized(self) {
_vic20.add_prg(prg.length, (const uint8_t *)prg.bytes);
}
}
- (void)setKey:(uint16_t)key isPressed:(BOOL)isPressed {