mirror of
https://github.com/TomHarte/CLK.git
synced 2024-12-25 03:32:01 +00:00
Corrects Xcode tests.
This commit is contained in:
parent
250f7bf6b0
commit
05b95ea2e0
@ -267,6 +267,8 @@
|
||||
4B92EACA1B7C112B00246143 /* 6502TimingTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B92EAC91B7C112B00246143 /* 6502TimingTests.swift */; };
|
||||
4B95FA9D1F11893B0008E395 /* ZX8081OptionsPanel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B95FA9C1F11893B0008E395 /* ZX8081OptionsPanel.swift */; };
|
||||
4B96F7221D75119A0058BB2D /* Tape.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B96F7201D75119A0058BB2D /* Tape.cpp */; };
|
||||
4B98A05E1FFAD3F600ADF63B /* CSROMFetcher.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4B98A05D1FFAD3F600ADF63B /* CSROMFetcher.mm */; };
|
||||
4B98A05F1FFAD62400ADF63B /* CSROMFetcher.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4B98A05D1FFAD3F600ADF63B /* CSROMFetcher.mm */; };
|
||||
4B9C9D751FF81CC00030A129 /* Z80.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B9C9D731FF81CC00030A129 /* Z80.cpp */; };
|
||||
4B9C9D781FF81ED30030A129 /* AddressMapper.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B9C9D761FF81ED30030A129 /* AddressMapper.cpp */; };
|
||||
4B9CCDA11DA279CA0098B625 /* Vic20OptionsPanel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B9CCDA01DA279CA0098B625 /* Vic20OptionsPanel.swift */; };
|
||||
@ -901,6 +903,8 @@
|
||||
4B95FA9C1F11893B0008E395 /* ZX8081OptionsPanel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ZX8081OptionsPanel.swift; sourceTree = "<group>"; };
|
||||
4B96F7201D75119A0058BB2D /* Tape.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Tape.cpp; path = ../../StaticAnalyser/Acorn/Tape.cpp; sourceTree = "<group>"; };
|
||||
4B96F7211D75119A0058BB2D /* Tape.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = Tape.hpp; path = ../../StaticAnalyser/Acorn/Tape.hpp; sourceTree = "<group>"; };
|
||||
4B98A05C1FFAD3F600ADF63B /* CSROMFetcher.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = CSROMFetcher.hpp; sourceTree = "<group>"; };
|
||||
4B98A05D1FFAD3F600ADF63B /* CSROMFetcher.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = CSROMFetcher.mm; sourceTree = "<group>"; };
|
||||
4B9C9D731FF81CC00030A129 /* Z80.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = Z80.cpp; path = ../../StaticAnalyser/Disassembler/Z80.cpp; sourceTree = "<group>"; };
|
||||
4B9C9D741FF81CC00030A129 /* Z80.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; name = Z80.hpp; path = ../../StaticAnalyser/Disassembler/Z80.hpp; sourceTree = "<group>"; };
|
||||
4B9C9D761FF81ED30030A129 /* AddressMapper.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = AddressMapper.cpp; path = ../../StaticAnalyser/Disassembler/AddressMapper.cpp; sourceTree = "<group>"; };
|
||||
@ -1501,9 +1505,11 @@
|
||||
4B2A53951D117D36003C6002 /* CSMachine.h */,
|
||||
4B2A53941D117D36003C6002 /* CSMachine+Subclassing.h */,
|
||||
4B643F3C1D77AE5C00D431D6 /* CSMachine+Target.h */,
|
||||
4B98A05C1FFAD3F600ADF63B /* CSROMFetcher.hpp */,
|
||||
4B2A53971D117D36003C6002 /* KeyCodes.h */,
|
||||
4B8FE2251DA1DE2D0090D3CE /* NSBundle+DataResource.h */,
|
||||
4BA61EAE1D91515900B3C876 /* NSData+StdVector.h */,
|
||||
4B98A05D1FFAD3F600ADF63B /* CSROMFetcher.mm */,
|
||||
4B8FE2261DA1DE2D0090D3CE /* NSBundle+DataResource.m */,
|
||||
4B2A53961D117D36003C6002 /* CSMachine.mm */,
|
||||
4BA61EAF1D91515900B3C876 /* NSData+StdVector.mm */,
|
||||
@ -3480,6 +3486,7 @@
|
||||
4B4518871F75E91A00926311 /* DigitalPhaseLockedLoop.cpp in Sources */,
|
||||
4B2A53A31D117D36003C6002 /* CSVic20.mm in Sources */,
|
||||
4B2A53A21D117D36003C6002 /* CSElectron.mm in Sources */,
|
||||
4B98A05E1FFAD3F600ADF63B /* CSROMFetcher.mm in Sources */,
|
||||
4B8FE2201DA19D7C0090D3CE /* Atari2600OptionsPanel.swift in Sources */,
|
||||
4B8805F41DCFD22A003085B1 /* Commodore.cpp in Sources */,
|
||||
4B2E2D9A1C3A06EC00138695 /* Atari2600.cpp in Sources */,
|
||||
@ -3527,6 +3534,7 @@
|
||||
files = (
|
||||
4B1E85811D176468001EF87D /* 6532Tests.swift in Sources */,
|
||||
4BDDBA991EF3451200347E61 /* Z80MachineCycleTests.swift in Sources */,
|
||||
4B98A05F1FFAD62400ADF63B /* CSROMFetcher.mm in Sources */,
|
||||
4BC9E1EE1D23449A003FCEE4 /* 6502InterruptTests.swift in Sources */,
|
||||
4BEF6AAA1D35CE9E00E73575 /* DigitalPhaseLockedLoopBridge.mm in Sources */,
|
||||
4B924E991E74D22700B76AF1 /* AtariStaticAnalyserTests.mm in Sources */,
|
||||
|
@ -10,6 +10,8 @@
|
||||
#import "CSMachine+Subclassing.h"
|
||||
#import "CSMachine+Target.h"
|
||||
|
||||
#include "CSROMFetcher.hpp"
|
||||
|
||||
#include "ConfigurationTarget.hpp"
|
||||
#include "JoystickMachine.hpp"
|
||||
#include "KeyboardMachine.hpp"
|
||||
@ -74,23 +76,7 @@ struct MachineDelegate: CRTMachine::Machine::Delegate, public LockProtectedDeleg
|
||||
_speakerDelegate.machineAccessLock = _delegateMachineAccessLock;
|
||||
|
||||
_machine->crt_machine()->set_delegate(&_machineDelegate);
|
||||
_machine->crt_machine()->set_rom_fetcher( [] (const std::string &machine, const std::vector<std::string> &names) -> std::vector<std::unique_ptr<std::vector<std::uint8_t>>> {
|
||||
NSString *subDirectory = [@"ROMImages/" stringByAppendingString:[NSString stringWithUTF8String:machine.c_str()]];
|
||||
std::vector<std::unique_ptr<std::vector<std::uint8_t>>> results;
|
||||
for(auto &name: names) {
|
||||
NSData *fileData = [[NSBundle mainBundle] dataForResource:[NSString stringWithUTF8String:name.c_str()] withExtension:nil subdirectory:subDirectory];
|
||||
|
||||
if(!fileData)
|
||||
results.emplace_back(nullptr);
|
||||
else {
|
||||
std::unique_ptr<std::vector<std::uint8_t>> data(new std::vector<std::uint8_t>);
|
||||
*data = fileData.stdVector8;
|
||||
results.emplace_back(std::move(data));
|
||||
}
|
||||
}
|
||||
|
||||
return results;
|
||||
});
|
||||
CSApplyROMFetcher(*_machine->crt_machine());
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
11
OSBindings/Mac/Clock Signal/Machine/CSROMFetcher.hpp
Normal file
11
OSBindings/Mac/Clock Signal/Machine/CSROMFetcher.hpp
Normal file
@ -0,0 +1,11 @@
|
||||
//
|
||||
// ROMFetcher.h
|
||||
// Clock Signal
|
||||
//
|
||||
// Created by Thomas Harte on 01/01/2018.
|
||||
// Copyright © 2018 Thomas Harte. All rights reserved.
|
||||
//
|
||||
|
||||
#include "ROMMachine.hpp"
|
||||
|
||||
void CSApplyROMFetcher(ROMMachine::Machine &rom_machine);
|
35
OSBindings/Mac/Clock Signal/Machine/CSROMFetcher.mm
Normal file
35
OSBindings/Mac/Clock Signal/Machine/CSROMFetcher.mm
Normal file
@ -0,0 +1,35 @@
|
||||
//
|
||||
// CSROMFetcher.m
|
||||
// Clock Signal
|
||||
//
|
||||
// Created by Thomas Harte on 01/01/2018.
|
||||
// Copyright © 2018 Thomas Harte. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#include "CSROMFetcher.hpp"
|
||||
|
||||
#import "NSBundle+DataResource.h"
|
||||
#import "NSData+StdVector.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
void CSApplyROMFetcher(ROMMachine::Machine &rom_machine) {
|
||||
rom_machine.set_rom_fetcher( [] (const std::string &machine, const std::vector<std::string> &names) -> std::vector<std::unique_ptr<std::vector<std::uint8_t>>> {
|
||||
NSString *subDirectory = [@"ROMImages/" stringByAppendingString:[NSString stringWithUTF8String:machine.c_str()]];
|
||||
std::vector<std::unique_ptr<std::vector<std::uint8_t>>> results;
|
||||
for(auto &name: names) {
|
||||
NSData *fileData = [[NSBundle mainBundle] dataForResource:[NSString stringWithUTF8String:name.c_str()] withExtension:nil subdirectory:subDirectory];
|
||||
|
||||
if(!fileData)
|
||||
results.emplace_back(nullptr);
|
||||
else {
|
||||
std::unique_ptr<std::vector<std::uint8_t>> data(new std::vector<std::uint8_t>);
|
||||
*data = fileData.stdVector8;
|
||||
results.emplace_back(std::move(data));
|
||||
}
|
||||
}
|
||||
|
||||
return results;
|
||||
});
|
||||
}
|
@ -10,8 +10,7 @@
|
||||
|
||||
@implementation NSBundle (DataResource)
|
||||
|
||||
- (NSData *)dataForResource:(NSString *)resource withExtension:(NSString *)extension subdirectory:(NSString *)subdirectory
|
||||
{
|
||||
- (NSData *)dataForResource:(NSString *)resource withExtension:(NSString *)extension subdirectory:(NSString *)subdirectory {
|
||||
NSURL *url = [self URLForResource:resource withExtension:extension subdirectory:subdirectory];
|
||||
if(!url) return nil;
|
||||
return [NSData dataWithContentsOfURL:url];
|
||||
|
@ -15,6 +15,5 @@
|
||||
@property (nonatomic) BOOL clockLine;
|
||||
|
||||
- (void)runForCycles:(NSUInteger)numberOfCycles;
|
||||
- (void)setROM:(NSData *)ROM;
|
||||
|
||||
@end
|
||||
|
@ -9,6 +9,7 @@
|
||||
#import "C1540Bridge.h"
|
||||
#include "C1540.hpp"
|
||||
#include "NSData+StdVector.h"
|
||||
#include "CSROMFetcher.hpp"
|
||||
|
||||
class VanillaSerialPort: public Commodore::Serial::Port {
|
||||
public:
|
||||
@ -20,7 +21,7 @@ class VanillaSerialPort: public Commodore::Serial::Port {
|
||||
};
|
||||
|
||||
@implementation C1540Bridge {
|
||||
Commodore::C1540::Machine _c1540;
|
||||
std::unique_ptr<Commodore::C1540::Machine> _c1540;
|
||||
std::shared_ptr<Commodore::Serial::Bus> _serialBus;
|
||||
std::shared_ptr<VanillaSerialPort> _serialPort;
|
||||
}
|
||||
@ -31,18 +32,16 @@ class VanillaSerialPort: public Commodore::Serial::Port {
|
||||
_serialBus.reset(new ::Commodore::Serial::Bus);
|
||||
_serialPort.reset(new VanillaSerialPort);
|
||||
|
||||
_c1540.set_serial_bus(_serialBus);
|
||||
_c1540.reset(new Commodore::C1540::Machine(Commodore::C1540::Machine::C1540));
|
||||
CSApplyROMFetcher(*_c1540);
|
||||
_c1540->set_serial_bus(_serialBus);
|
||||
Commodore::Serial::AttachPortAndBus(_serialPort, _serialBus);
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)setROM:(NSData *)ROM {
|
||||
_c1540.set_rom(ROM.stdVector8);
|
||||
}
|
||||
|
||||
- (void)runForCycles:(NSUInteger)numberOfCycles {
|
||||
_c1540.run_for(Cycles((int)numberOfCycles));
|
||||
_c1540->run_for(Cycles((int)numberOfCycles));
|
||||
}
|
||||
|
||||
- (void)setAttentionLine:(BOOL)attentionLine {
|
||||
|
@ -12,12 +12,6 @@ class C1540Tests: XCTestCase {
|
||||
|
||||
fileprivate func with1540(_ action: (C1540Bridge) -> ()) {
|
||||
let bridge = C1540Bridge()
|
||||
|
||||
if let path = Bundle.main.path(forResource: "1541", ofType: "bin", inDirectory: "ROMImages/Commodore1540") {
|
||||
let data = try? Data(contentsOf: URL(fileURLWithPath: path))
|
||||
bridge.setROM(data)
|
||||
}
|
||||
|
||||
action(bridge)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user