1
0
mirror of https://github.com/TomHarte/CLK.git synced 2025-01-12 15:31:09 +00:00

Implemented an additional constructor for RegisterStates, pulling it out into file-level scope and implementing Equatable.

This commit is contained in:
Thomas Harte 2017-05-23 22:05:33 -04:00
parent a23a6db4d6
commit 454c8628c3

View File

@ -9,9 +9,7 @@
import XCTest
import Foundation
class FUSETests: XCTestCase {
struct RegisterState {
fileprivate struct RegisterState {
var af: UInt16 = 0, bc: UInt16 = 0, de: UInt16 = 0, hl: UInt16 = 0
var afDash: UInt16 = 0, bcDash: UInt16 = 0, deDash: UInt16 = 0, hlDash: UInt16 = 0
var ix: UInt16 = 0, iy: UInt16 = 0, sp: UInt16 = 0, pc: UInt16 = 0
@ -73,8 +71,8 @@ class FUSETests: XCTestCase {
i = readHexInt8(from: scanner)
r = readHexInt8(from: scanner)
iff1 = readHexInt8(from: scanner) == 1
iff2 = readHexInt8(from: scanner) == 1
iff1 = readHexInt8(from: scanner) != 0
iff2 = readHexInt8(from: scanner) != 0
var temporary: UInt32 = 0
scanner.scanHexInt32(&temporary)
@ -85,7 +83,60 @@ class FUSETests: XCTestCase {
scanner.scanHexInt32(&temporary)
tStates = Int(temporary)
}
init(machine: CSTestMachineZ80) {
af = machine.value(for: .AF)
bc = machine.value(for: .BC)
de = machine.value(for: .DE)
hl = machine.value(for: .HL)
afDash = machine.value(for: .afDash)
bcDash = machine.value(for: .bcDash)
deDash = machine.value(for: .deDash)
hlDash = machine.value(for: .hlDash)
ix = machine.value(for: .IX)
iy = machine.value(for: .IY)
sp = machine.value(for: .stackPointer)
pc = machine.value(for: .programCounter)
i = UInt8(machine.value(for: .I))
r = UInt8(machine.value(for: .R))
iff1 = machine.value(for: .IFF1) != 0
iff2 = machine.value(for: .IFF2) != 0
interruptMode = Int(machine.value(for: .IM))
isHalted = false // TODO
tStates = 0 // TODO
}
}
extension RegisterState: Equatable {}
fileprivate func ==(lhs: RegisterState, rhs: RegisterState) -> Bool {
return lhs.af == rhs.af &&
lhs.bc == rhs.bc &&
lhs.de == rhs.de &&
lhs.hl == rhs.hl &&
lhs.afDash == rhs.afDash &&
lhs.bcDash == rhs.bcDash &&
lhs.deDash == rhs.deDash &&
lhs.hlDash == rhs.hlDash &&
lhs.ix == rhs.ix &&
lhs.iy == rhs.iy &&
lhs.sp == rhs.sp &&
lhs.pc == rhs.pc &&
lhs.i == rhs.i &&
lhs.r == rhs.r &&
lhs.iff1 == rhs.iff1 &&
lhs.iff2 == rhs.iff2 &&
lhs.interruptMode == rhs.interruptMode
}
class FUSETests: XCTestCase {
func testFUSE() {
if let inputFilename = Bundle(for: type(of: self)).path(forResource: "tests", ofType: "in"),