mirror of
https://github.com/TomHarte/CLK.git
synced 2025-01-11 08:30:55 +00:00
Set up a test class to allow me to discover which of the machine cycle sequences I'm in error on.
This commit is contained in:
parent
a336048c98
commit
ac37424878
@ -411,6 +411,7 @@
|
||||
4BD4A8D01E077FD20020D856 /* PCMTrackTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4BD4A8CF1E077FD20020D856 /* PCMTrackTests.mm */; };
|
||||
4BD5F1951D13528900631CD1 /* CSBestEffortUpdater.m in Sources */ = {isa = PBXBuildFile; fileRef = 4BD5F1941D13528900631CD1 /* CSBestEffortUpdater.m */; };
|
||||
4BD69F941D98760000243FE1 /* AcornADF.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BD69F921D98760000243FE1 /* AcornADF.cpp */; };
|
||||
4BDDBA991EF3451200347E61 /* Z80MachineCycleTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4BDDBA981EF3451200347E61 /* Z80MachineCycleTests.swift */; };
|
||||
4BE77A2E1D84ADFB00BC3827 /* File.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BE77A2C1D84ADFB00BC3827 /* File.cpp */; };
|
||||
4BE7C9181E3D397100A5496D /* TIA.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BE7C9161E3D397100A5496D /* TIA.cpp */; };
|
||||
4BE9A6B11EDE293000CBCB47 /* zexdoc.com in Resources */ = {isa = PBXBuildFile; fileRef = 4BE9A6B01EDE293000CBCB47 /* zexdoc.com */; };
|
||||
@ -969,6 +970,7 @@
|
||||
4BD5F1941D13528900631CD1 /* CSBestEffortUpdater.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CSBestEffortUpdater.m; path = Updater/CSBestEffortUpdater.m; sourceTree = "<group>"; };
|
||||
4BD69F921D98760000243FE1 /* AcornADF.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AcornADF.cpp; sourceTree = "<group>"; };
|
||||
4BD69F931D98760000243FE1 /* AcornADF.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = AcornADF.hpp; sourceTree = "<group>"; };
|
||||
4BDDBA981EF3451200347E61 /* Z80MachineCycleTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Z80MachineCycleTests.swift; sourceTree = "<group>"; };
|
||||
4BE77A2C1D84ADFB00BC3827 /* File.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = File.cpp; path = ../../StaticAnalyser/Commodore/File.cpp; sourceTree = "<group>"; };
|
||||
4BE77A2D1D84ADFB00BC3827 /* File.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = File.hpp; path = ../../StaticAnalyser/Commodore/File.hpp; sourceTree = "<group>"; };
|
||||
4BE7C9161E3D397100A5496D /* TIA.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TIA.cpp; sourceTree = "<group>"; };
|
||||
@ -1856,6 +1858,7 @@
|
||||
4B1414611B58888700E04248 /* KlausDormannTests.swift */,
|
||||
4B14145F1B58885000E04248 /* WolfgangLorenzTests.swift */,
|
||||
4B08A2741EE35D56008B7065 /* Z80InterruptTests.swift */,
|
||||
4BDDBA981EF3451200347E61 /* Z80MachineCycleTests.swift */,
|
||||
4BFCA12A1ECBE7C400AC40C1 /* ZexallTests.swift */,
|
||||
4B3BA0C41D318B44005DD7A7 /* Bridges */,
|
||||
4B1414631B588A1100E04248 /* Test Binaries */,
|
||||
@ -2666,6 +2669,7 @@
|
||||
4B14145E1B5887AA00E04248 /* 6502AllRAM.cpp in Sources */,
|
||||
4B14145D1B5887A600E04248 /* 6502.cpp in Sources */,
|
||||
4B1E85811D176468001EF87D /* 6532Tests.swift in Sources */,
|
||||
4BDDBA991EF3451200347E61 /* Z80MachineCycleTests.swift in Sources */,
|
||||
4BC9E1EE1D23449A003FCEE4 /* 6502InterruptTests.swift in Sources */,
|
||||
4BEF6AAA1D35CE9E00E73575 /* DigitalPhaseLockedLoopBridge.mm in Sources */,
|
||||
4B924E991E74D22700B76AF1 /* AtariStaticAnalyserTests.mm in Sources */,
|
||||
|
57
OSBindings/Mac/Clock SignalTests/Z80MachineCycleTests.swift
Normal file
57
OSBindings/Mac/Clock SignalTests/Z80MachineCycleTests.swift
Normal file
@ -0,0 +1,57 @@
|
||||
//
|
||||
// Z80MachineCycleTests.swift
|
||||
// Clock Signal
|
||||
//
|
||||
// Created by Thomas Harte on 15/06/2017.
|
||||
// Copyright © 2017 Thomas Harte. All rights reserved.
|
||||
//
|
||||
|
||||
import XCTest
|
||||
|
||||
class Z80MachineCycleTests: XCTestCase {
|
||||
|
||||
struct MachineCycle {
|
||||
var operation: CSTestMachineZ80BusOperationCaptureOperation
|
||||
var length: Int32
|
||||
}
|
||||
|
||||
func test(program : Array<UInt8>, busCycles : [MachineCycle]) {
|
||||
// Create a machine and install the supplied program at address 0, setting the PC to run from there
|
||||
let machine = CSTestMachineZ80()
|
||||
machine.setValue(0x0000, for: .programCounter)
|
||||
machine.setData(Data(bytes: program), atAddress: 0x0000)
|
||||
|
||||
// Figure out the total number of cycles implied by the bus cycles
|
||||
var totalCycles: Int32 = 0
|
||||
for cycle in busCycles {
|
||||
totalCycles += Int32(cycle.length)
|
||||
}
|
||||
|
||||
// Run the machine, capturing bus activity
|
||||
machine.captureBusActivity = true
|
||||
machine.runForNumber(ofCycles: totalCycles)
|
||||
|
||||
// Check the results
|
||||
totalCycles = 0
|
||||
var index = 0
|
||||
for cycle in machine.busOperationCaptures {
|
||||
let length = cycle.timeStamp - totalCycles
|
||||
totalCycles += length
|
||||
|
||||
XCTAssertEqual(length, busCycles[index].length)
|
||||
XCTAssertEqual(cycle.operation, busCycles[index].operation)
|
||||
|
||||
index += 1
|
||||
}
|
||||
}
|
||||
|
||||
func testLDrs() {
|
||||
test(
|
||||
program: [0x40],
|
||||
busCycles: [
|
||||
MachineCycle(operation: .read, length: 4)
|
||||
]
|
||||
)
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user