MrKWatkins.EmulatorTestSuites 0.1.9 Help

Z80TestHarness Class

Definition

Base class for a Z80 emulator test harness. Implement this class to use it with the test suites.

public abstract class Z80TestHarness

Constructors

Name

Description

Z80TestHarness()

Properties

Name

Description

Cycles

Gets the recorded CPU cycles. Only available when RecordCycles is true.

FlagC

Gets or sets the carry flag, C.

FlagH

Gets or sets the half-carry flag, H.

FlagN

Gets or sets the add/subtract flag, N.

FlagPV

Gets or sets the parity/overflow flag, P/V.

FlagS

Gets or sets the sign flag, S.

FlagX

Gets or sets the undocumented X flag, bit 3 of the F register.

FlagY

Gets or sets the undocumented Y flag, bit 5 of the F register.

FlagZ

Gets or sets the zero flag, Z.

Halted

Gets or sets whether the CPU is in the halted state.

IFF1

Gets or sets the IFF1 interrupt flip-flop.

IFF2

Gets or sets the IFF2 interrupt flip-flop.

IM

Gets or sets the interrupt mode.

Interrupt

Gets or sets whether an interrupt is pending.

IOReader

Gets the IO reader implementation.

IOWriter

Gets the IO writer implementation.

MutableCycles

A mutable list of Cycles to update when RecordCycles is true, null otherwise.

RecordCycles

Gets or sets whether CPU cycles should be recorded.

RegisterA

Gets or sets the A register.

RegisterAF

Gets or sets the AF register pair.

RegisterB

Gets or sets the B register.

RegisterBC

Gets or sets the BC register pair.

RegisterC

Gets or sets the C register.

RegisterD

Gets or sets the D register.

RegisterDE

Gets or sets the DE register pair.

RegisterE

Gets or sets the E register.

RegisterF

Gets or sets the F register.

RegisterH

Gets or sets the H register.

RegisterHL

Gets or sets the HL register pair.

RegisterI

Gets or sets the I register.

RegisterIX

Gets or sets the IX register pair.

RegisterIXH

Gets or sets the IXH register.

RegisterIXL

Gets or sets the IXL register.

RegisterIY

Gets or sets the IY register pair.

RegisterIYH

Gets or sets the IYH register.

RegisterIYL

Gets or sets the IYL register.

RegisterL

Gets or sets the L register.

RegisterPC

Gets or sets the PC register.

RegisterQ

Gets or sets the internal Q register.

RegisterR

Gets or sets the R register.

RegisterSP

Gets or sets the SP register.

RegisterWZ

Gets or sets the internal WZ register, sometimes called MEMPTR.

RomArea

Gets or sets the ROM area in memory. Memory writes in this area by the emulator should be ignored.

ShadowRegisterAF

Gets or sets the AF' register pair.

ShadowRegisterBC

Gets or sets the BC' register pair.

ShadowRegisterDE

Gets or sets the DE' register pair.

ShadowRegisterHL

Gets or sets the HL' register pair.

TStates

Gets or sets the number of T-states (clock cycles) executed.

Methods

Name

Description

AssertEqual<T>(T, T, DefaultInterpolatedStringHandler)

Asserts that the actual value is equal to the expected value. If the values are not equal, an error is reported.

AssertFail(String)

Signals that a test has failed with the provided error message.

ClearMemory()

Clears memory.

CopyToMemory(UInt16, ReadOnlySpan<Byte>)

Copies a span of bytes into the memory starting at the specified address.

CopyToMemory(UInt16, IReadOnlyList<Byte>)

Copies a sequence of bytes into memory starting at the specified address.

CreateAssertionScope(String)

Creates an assertion scope that allows multiple AssertEqual<T>(T, T, DefaultInterpolatedStringHandler) assertions to be made with just one AssertFail(String).

ExecuteInstruction()

Executes a single instruction.

ExecuteInstruction(TextWriter)

Executes a single instruction with debug output.

OnRomAreaChanged()

Called when RomArea changes. Override to update your emulator with the ROM area.

ReadByteFromMemory(UInt16)

Reads a byte from memory.

ReadWordFromMemory(UInt16)

Reads a word in little endian format from memory.

Reset()

Resets the test harness state.

SetIO<TIO>(TIO)

Sets both the IO reader and writer to the same implementation.

WriteByteToMemory(UInt16, Byte)

Writes a byte to memory. Does not take RomArea into account as this is used by tests to setup memory.

WriteWordToMemory(UInt16, UInt16)

Writes a word in little endian format to memory. Does not take RomArea into account as this is used by tests to setup memory.

Last modified: 13 July 2025