public void RRA_nc_nc() { var ob = OpcodeByte.New(z: 7, y: 3); var cpu = ExecuteTest(ob, (cpuZ80) => { cpuZ80.Registers.A = Value1; cpuZ80.Registers.Flags.Z = false; cpuZ80.Registers.Flags.S = true; }); cpu.AssertRegisters(a: ExpectedValue1R); cpu.Registers.Flags.S.Should().BeTrue(); cpu.Registers.Flags.Z.Should().BeFalse(); cpu.Registers.Flags.C.Should().BeFalse(); cpu.Registers.Flags.N.Should().BeFalse(); cpu.Registers.Flags.H.Should().BeFalse(); }
private static CpuZ80 ExecuteTest(byte b, long cycles) { var djnz = OpcodeByte.New(y: 2); var d = unchecked ((byte)-2); var cpuZ80 = new CpuZ80(); var model = cpuZ80.Initialize(new byte[] { djnz.Value, d }); var bc = (ushort)((b << 8) | CpuZ80TestExtensions.MagicValue); cpuZ80.FillRegisters(bc: bc); model.ClockGen.SquareWave(cycles); Console.WriteLine(model.LogicAnalyzer.ToWaveJson()); return(cpuZ80); }
public void SRL_c() { ForEachRegister((reg) => { var ob = OpcodeByte.New(z: (byte)reg, y: 7); var cpu = ExecuteTest(ob, (cpuZ80) => { cpuZ80.Registers[reg] = Value2; }, 0xCB); cpu.Registers[reg].Should().Be(ExpectedValue2R); cpu.Registers.Flags.S.Should().BeFalse(); cpu.Registers.Flags.Z.Should().BeFalse(); cpu.Registers.Flags.C.Should().BeTrue(); cpu.Registers.Flags.N.Should().BeFalse(); cpu.Registers.Flags.H.Should().BeFalse(); }); }
private static SimulationModel ExecuteTest(Action <SimulationModel> preTest, byte extension = 0) { var ob = OpcodeByte.New(z: 6, y: 6); var cpuZ80 = new CpuZ80(); var buffer = extension == 0 ? new byte[] { ob.Value, Value, 0, 0, 0, 0 } : new byte[] { extension, ob.Value, unchecked ((byte)Offset), Value, 0, 0, 0 }; var model = cpuZ80.Initialize(buffer); cpuZ80.FillRegisters(); preTest(model); model.ClockGen.SquareWave(extension == 0 ? 10 : 19); Console.WriteLine(model.LogicAnalyzer.ToWaveJson()); return(model); }
private CpuZ80 ExecuteTest(byte value) { var ob = OpcodeByte.New(x: 1, z: 4, y: 0); var cpuZ80 = new CpuZ80(); byte[] buffer = new byte[] { 0xED, ob.Value }; var model = cpuZ80.Initialize(buffer); cpuZ80.FillRegisters(); cpuZ80.Registers.A = value; model.ClockGen.SquareWave(8); Console.WriteLine(model.LogicAnalyzer.ToWaveJson()); return(cpuZ80); }
private static CpuZ80 ExecuteTest(Register16Table reg16, bool carry) { var ob = OpcodeByte.New(x: 1, z: 2, q: 0, p: (byte)reg16); var cpuZ80 = new CpuZ80(); byte[] buffer = new byte[] { 0xED, ob.Value }; var model = cpuZ80.Initialize(buffer); cpuZ80.Registers.Flags.C = carry; cpuZ80.FillRegisters(hl: Value); cpuZ80.Registers[reg16] = ValueToSub; model.ClockGen.SquareWave(15); Console.WriteLine(model.LogicAnalyzer.ToWaveJson()); return(cpuZ80); }
private void Adc(bool carry, byte extension = 0) { var ob = OpcodeByte.New(x: 2, z: 6, y: (byte)MathOperations.AddWithCarry); var expectedValue = (byte)(CpuZ80TestExtensions.MagicValue + Value); if (carry) { expectedValue += 1; } var cpu = TestMathOperation(ob, expectedValue, carry: carry, extension: extension); var flags = cpu.Registers.Flags; flags.S.Should().Be(true); flags.Z.Should().Be(false); flags.C.Should().Be(false); flags.H.Should().Be(true); flags.N.Should().Be(false); flags.PV.Should().Be(carry); }
public void LDIR_WhenConditionIsMet_ExitRepeat() { // solved by adding altCycles in opcode defs. var ob = OpcodeByte.New(x: 2, z: 0, y: 6); int count = 0; var model = ExecuteTest(ob, (cpu) => { cpu.Registers.HL = RdAddress; cpu.Registers.DE = WrAddress; cpu.Registers.BC = Length; cpu.InstructionExecuted += (s, e) => { count++; }; // 3 LDIR repeats + last & nop return(3 * 21 + 16 + 4); }); count.Should().Be(5); model.Cpu.AssertRegisters(bc: 0, de: WrAddress + Length, hl: RdAddress + Length); model.Cpu.Registers.Flags.PV.Should().Be(false); }
private static CpuZ80 ExecuteTest(MathOperations mathOp, Register8Table register, Action <SimulationModel> fnPreTest) { var ob = OpcodeByte.New(x: 2, z: (byte)register, y: (byte)mathOp); return(ExecuteTest(ob, fnPreTest)); }
private static SimulationModel ExecuteTest(byte x, byte bit, byte value) { var ob = OpcodeByte.New(x: x, y: bit, z: 6); return(ExecuteTest(ob, value)); }
private static CpuZ80 ExecuteTest(byte bit, Register8Table register, Action <SimulationModel> fnPreTest) { var ob = OpcodeByte.New(x: 3, y: bit, z: (byte)register); return(ExecuteTest(ob, fnPreTest)); }