diff --git a/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj b/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj index 7d826c4e4..3e4acf185 100644 --- a/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj +++ b/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj @@ -97,6 +97,8 @@ 4BAB62AD1D3272D200DF5BA0 /* Disk.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BAB62AB1D3272D200DF5BA0 /* Disk.cpp */; }; 4BAB62B51D327F7E00DF5BA0 /* G64.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BAB62B31D327F7E00DF5BA0 /* G64.cpp */; }; 4BAB62B81D3302CA00DF5BA0 /* PCMTrack.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BAB62B61D3302CA00DF5BA0 /* PCMTrack.cpp */; }; + 4BB17D4E1ED7909F00ABD1E1 /* tests.expected.json in Resources */ = {isa = PBXBuildFile; fileRef = 4BB17D4C1ED7909F00ABD1E1 /* tests.expected.json */; }; + 4BB17D4F1ED7909F00ABD1E1 /* tests.in.json in Resources */ = {isa = PBXBuildFile; fileRef = 4BB17D4D1ED7909F00ABD1E1 /* tests.in.json */; }; 4BB298F11B587D8400A49093 /* start in Resources */ = {isa = PBXBuildFile; fileRef = 4BB297E51B587D8300A49093 /* start */; }; 4BB298F21B587D8400A49093 /* adca in Resources */ = {isa = PBXBuildFile; fileRef = 4BB297E61B587D8300A49093 /* adca */; }; 4BB298F31B587D8400A49093 /* adcax in Resources */ = {isa = PBXBuildFile; fileRef = 4BB297E71B587D8300A49093 /* adcax */; }; @@ -372,8 +374,6 @@ 4BB73EC21B587A5100552FC2 /* Clock_SignalUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4BB73EC11B587A5100552FC2 /* Clock_SignalUITests.swift */; }; 4BBB14311CD2CECE00BDB55C /* IntermediateShader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BBB142F1CD2CECE00BDB55C /* IntermediateShader.cpp */; }; 4BBF49AF1ED2880200AB3669 /* FUSETests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4BBF49AE1ED2880200AB3669 /* FUSETests.swift */; }; - 4BBF49B21ED2881200AB3669 /* tests.expected in Resources */ = {isa = PBXBuildFile; fileRef = 4BBF49B01ED2881200AB3669 /* tests.expected */; }; - 4BBF49B31ED2881200AB3669 /* tests.in in Resources */ = {isa = PBXBuildFile; fileRef = 4BBF49B11ED2881200AB3669 /* tests.in */; }; 4BBF99141C8FBA6F0075DAFB /* TextureBuilder.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BBF99081C8FBA6F0075DAFB /* TextureBuilder.cpp */; }; 4BBF99151C8FBA6F0075DAFB /* CRTOpenGL.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BBF990A1C8FBA6F0075DAFB /* CRTOpenGL.cpp */; }; 4BBF99181C8FBA6F0075DAFB /* TextureTarget.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BBF99121C8FBA6F0075DAFB /* TextureTarget.cpp */; }; @@ -603,6 +603,8 @@ 4BAB62B41D327F7E00DF5BA0 /* G64.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = G64.hpp; sourceTree = ""; }; 4BAB62B61D3302CA00DF5BA0 /* PCMTrack.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PCMTrack.cpp; sourceTree = ""; }; 4BAB62B71D3302CA00DF5BA0 /* PCMTrack.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = PCMTrack.hpp; sourceTree = ""; }; + 4BB17D4C1ED7909F00ABD1E1 /* tests.expected.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; name = tests.expected.json; path = FUSE/tests.expected.json; sourceTree = ""; }; + 4BB17D4D1ED7909F00ABD1E1 /* tests.in.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; name = tests.in.json; path = FUSE/tests.in.json; sourceTree = ""; }; 4BB297E51B587D8300A49093 /* start */ = {isa = PBXFileReference; lastKnownFileType = file; path = " start"; sourceTree = ""; }; 4BB297E61B587D8300A49093 /* adca */ = {isa = PBXFileReference; lastKnownFileType = file; path = adca; sourceTree = ""; }; 4BB297E71B587D8300A49093 /* adcax */ = {isa = PBXFileReference; lastKnownFileType = file; path = adcax; sourceTree = ""; }; @@ -890,8 +892,6 @@ 4BBB14301CD2CECE00BDB55C /* IntermediateShader.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = IntermediateShader.hpp; sourceTree = ""; }; 4BBC34241D2208B100FFC9DF /* CSFastLoading.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSFastLoading.h; sourceTree = ""; }; 4BBF49AE1ED2880200AB3669 /* FUSETests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FUSETests.swift; sourceTree = ""; }; - 4BBF49B01ED2881200AB3669 /* tests.expected */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = tests.expected; path = FUSE/tests.expected; sourceTree = ""; }; - 4BBF49B11ED2881200AB3669 /* tests.in */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = tests.in; path = FUSE/tests.in; sourceTree = ""; }; 4BBF99081C8FBA6F0075DAFB /* TextureBuilder.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TextureBuilder.cpp; sourceTree = ""; }; 4BBF99091C8FBA6F0075DAFB /* TextureBuilder.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = TextureBuilder.hpp; sourceTree = ""; }; 4BBF990A1C8FBA6F0075DAFB /* CRTOpenGL.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CRTOpenGL.cpp; sourceTree = ""; }; @@ -1845,8 +1845,8 @@ 4BBF49B41ED2881600AB3669 /* FUSE */ = { isa = PBXGroup; children = ( - 4BBF49B01ED2881200AB3669 /* tests.expected */, - 4BBF49B11ED2881200AB3669 /* tests.in */, + 4BB17D4C1ED7909F00ABD1E1 /* tests.expected.json */, + 4BB17D4D1ED7909F00ABD1E1 /* tests.in.json */, ); name = FUSE; sourceTree = ""; @@ -2286,6 +2286,7 @@ 4BB298F21B587D8400A49093 /* adca in Resources */, 4BB299391B587D8400A49093 /* cntdef in Resources */, 4BB299591B587D8400A49093 /* flipos in Resources */, + 4BB17D4E1ED7909F00ABD1E1 /* tests.expected.json in Resources */, 4BB2998F1B587D8400A49093 /* lsrax in Resources */, 4BB299001B587D8400A49093 /* andix in Resources */, 4BB2993A1B587D8400A49093 /* cnto2 in Resources */, @@ -2337,6 +2338,7 @@ 4BB299C61B587D8400A49093 /* sbcay in Resources */, 4BB299601B587D8400A49093 /* insa in Resources */, 4BB299951B587D8400A49093 /* mmufetch in Resources */, + 4BB17D4F1ED7909F00ABD1E1 /* tests.in.json in Resources */, 4BB299A71B587D8400A49093 /* phpn in Resources */, 4BB299CC1B587D8400A49093 /* sbczx in Resources */, 4BB299C91B587D8400A49093 /* sbcix in Resources */, @@ -2367,7 +2369,6 @@ 4BB299131B587D8400A49093 /* axsix in Resources */, 4BB299781B587D8400A49093 /* ldaix in Resources */, 4B44EBF71DC9883B00A7820C /* 6502_functional_test.bin in Resources */, - 4BBF49B31ED2881200AB3669 /* tests.in in Resources */, 4BB299291B587D8400A49093 /* cia2pb7 in Resources */, 4BB2994A1B587D8400A49093 /* deca in Resources */, 4BB299CA1B587D8400A49093 /* sbciy in Resources */, @@ -2445,7 +2446,6 @@ 4BB2998D1B587D8400A49093 /* lsezx in Resources */, 4BB299811B587D8400A49093 /* ldya in Resources */, 4BB299991B587D8400A49093 /* nopb in Resources */, - 4BBF49B21ED2881200AB3669 /* tests.expected in Resources */, 4BB299581B587D8400A49093 /* finish in Resources */, 4BB299D11B587D8400A49093 /* shaay in Resources */, 4BB299A21B587D8400A49093 /* oraix in Resources */, diff --git a/OSBindings/Mac/Clock SignalTests/FUSETests.swift b/OSBindings/Mac/Clock SignalTests/FUSETests.swift index 2114fa516..09d8b1727 100644 --- a/OSBindings/Mac/Clock SignalTests/FUSETests.swift +++ b/OSBindings/Mac/Clock SignalTests/FUSETests.swift @@ -51,37 +51,33 @@ fileprivate struct RegisterState { // TODO: isHalted } - init(scanner: Scanner) { - af = readHexInt16(from: scanner) - bc = readHexInt16(from: scanner) - de = readHexInt16(from: scanner) - hl = readHexInt16(from: scanner) + init(dictionary: [String: Any]) { + af = UInt16((dictionary["af"] as! NSNumber).int32Value) + bc = UInt16((dictionary["bc"] as! NSNumber).int32Value) + de = UInt16((dictionary["de"] as! NSNumber).int32Value) + hl = UInt16((dictionary["hl"] as! NSNumber).int32Value) - afDash = readHexInt16(from: scanner) - bcDash = readHexInt16(from: scanner) - deDash = readHexInt16(from: scanner) - hlDash = readHexInt16(from: scanner) + afDash = UInt16((dictionary["afDash"] as! NSNumber).int32Value) + bcDash = UInt16((dictionary["bcDash"] as! NSNumber).int32Value) + deDash = UInt16((dictionary["deDash"] as! NSNumber).int32Value) + hlDash = UInt16((dictionary["hlDash"] as! NSNumber).int32Value) - ix = readHexInt16(from: scanner) - iy = readHexInt16(from: scanner) + ix = UInt16((dictionary["ix"] as! NSNumber).int32Value) + iy = UInt16((dictionary["iy"] as! NSNumber).int32Value) - sp = readHexInt16(from: scanner) - pc = readHexInt16(from: scanner) + sp = UInt16((dictionary["sp"] as! NSNumber).int32Value) + pc = UInt16((dictionary["pc"] as! NSNumber).int32Value) - i = readHexInt8(from: scanner) - r = readHexInt8(from: scanner) + i = UInt8((dictionary["i"] as! NSNumber).int32Value) + r = UInt8((dictionary["r"] as! NSNumber).int32Value) - iff1 = readHexInt8(from: scanner) != 0 - iff2 = readHexInt8(from: scanner) != 0 + iff1 = (dictionary["iff1"] as! NSNumber).boolValue + iff2 = (dictionary["iff2"] as! NSNumber).boolValue - var temporary: UInt32 = 0 - scanner.scanHexInt32(&temporary) - interruptMode = Int(temporary) + interruptMode = (dictionary["im"] as! NSNumber).intValue + isHalted = (dictionary["halted"] as! NSNumber).boolValue - isHalted = readHexInt8(from: scanner) == 1 - - scanner.scanHexInt32(&temporary) - tStates = Int(temporary) + tStates = (dictionary["tStates"] as! NSNumber).intValue } init(machine: CSTestMachineZ80) { @@ -139,90 +135,40 @@ fileprivate func ==(lhs: RegisterState, rhs: RegisterState) -> Bool { class FUSETests: XCTestCase { func testFUSE() { - if let inputFilename = Bundle(for: type(of: self)).path(forResource: "tests", ofType: "in"), - let outputFilename = Bundle(for: type(of: self)).path(forResource: "tests", ofType: "expected") { - if let input = try? String(contentsOf: URL(fileURLWithPath: inputFilename), encoding: .utf8), - let output = try? String(contentsOf: URL(fileURLWithPath: outputFilename), encoding: .utf8) { + let inputFilename: String! = Bundle(for: type(of: self)).path(forResource: "tests.in", ofType: "json") + let outputFilename: String! = Bundle(for: type(of: self)).path(forResource: "tests.expected", ofType: "json") - let inputScanner = Scanner(string: input) - let outputScanner = Scanner(string: output) + XCTAssert(inputFilename != nil && outputFilename != nil) - while !inputScanner.isAtEnd { - autoreleasepool { - var inputName: NSString?, outputName: NSString? - inputScanner.scanUpToCharacters(from: CharacterSet.newlines, into: &inputName) - outputScanner.scanUpToCharacters(from: CharacterSet.newlines, into: &outputName) + let inputData: Data! = try? Data(contentsOf: URL(fileURLWithPath: inputFilename)) + let outputData: Data! = try? Data(contentsOf: URL(fileURLWithPath: outputFilename)) - var outputBlock = "" - while true { - var nextLine: NSString? - outputScanner.scanUpTo("\n", into: &nextLine) - if let nextLine = nextLine { - print("!\(nextLine)") - outputBlock = outputBlock + " " + (nextLine as String) - if nextLine.length == 0 { - break - } - } else { - break - } - } + XCTAssert(inputData != nil && outputData != nil) - if let inputName = inputName, let outputName = outputName { - XCTAssertEqual(outputName, inputName) + let inputArray: [Any]! = try! JSONSerialization.jsonObject(with: inputData, options: []) as? [Any] + let outputArray: [Any]! = try! JSONSerialization.jsonObject(with: outputData, options: []) as? [Any] - let machine = CSTestMachineZ80() - let initialState = RegisterState(scanner: inputScanner) - initialState.set(onMachine: machine) + XCTAssert(inputArray != nil && outputArray != nil) - while true { - var address: UInt32 = 0 - var negative: Int = 0 - if inputScanner.scanHexInt32(&address) { - while true { - var value: UInt32 = 0 - if inputScanner.scanHexInt32(&value) { - machine.setValue(UInt8(value), atAddress: UInt16(address)) - address = address + 1 - } else { - inputScanner.scanInt(&negative) - break - } - } - } else { - inputScanner.scanInt(&negative) - break - } - } + var index = 0 + for item in inputArray { + let itemDictionary = item as! [String: Any] + let outputDictionary = outputArray[index] as! [String: Any] - print("\(inputName)") + let initialState = RegisterState(dictionary: itemDictionary["state"] as! [String: Any]) + let targetState = RegisterState(dictionary: outputDictionary["state"] as! [String: Any]) - machine.captureBusActivity = true - machine.runForNumber(ofCycles: Int32(initialState.tStates)) - machine.runToNextInstruction() + let machine = CSTestMachineZ80() + initialState.set(onMachine: machine) - // test that trapped memory accesses are correct - while true { - var indentation: NSString? - outputScanner.scanCharacters(from: CharacterSet.whitespaces, into: &indentation) - if indentation == nil { - break - } +// machine.runForNumber(ofCycles: Int32(initialState.tStates)) +// machine.runToNextInstruction() - var nextMemoryAccess: NSString? - outputScanner.scanUpToCharacters(from: CharacterSet.newlines, into: &nextMemoryAccess) - print("\(indentation!): \(nextMemoryAccess)") - } +// let finalState = RegisterState(machine: machine) - let finalState = RegisterState(machine: machine) + print("\(initialState) -> \(targetState)") - - - print("\(machine.busOperationCaptures)") - } - } - } - } + index = index + 1 } } }