private void AssertTiming(int expectedTiming, params int[] opcodes) { for (int i = 0; i < opcodes.Length; i++) { memory[OFFSET + i] = opcodes[i]; } cpu.ClearState(); cpu.Registers.PC = OFFSET; int ticks = 0; Opcode opcode = null; do { cpu.Tick(); if (opcode == null && cpu.CurrentOpcode != null) { opcode = cpu.CurrentOpcode; } ticks++; } while (cpu.State != Cpu.CpuState.OPCODE || ticks < 4); Assert.Equal(expectedTiming, ticks); }
private void AssertTiming(int expectedTiming, params int[] opcodes) { for (int i = 0; i < opcodes.Length; i++) { _memory.SetByte(Offset + i, opcodes[i]); } _cpu.ClearState(); _cpu.Registers.PC = Offset; int ticks = 0; Opcode opcode = null; do { _cpu.Tick(); if (opcode == null && _cpu.CurrentOpcode != null) { opcode = _cpu.CurrentOpcode; } ticks++; } while (_cpu.State != State.OPCODE || ticks < 4); if (opcode == null) { Assert.That(expectedTiming, Is.EqualTo(ticks), "Invalid timing value for " + HexArray(opcodes)); } else { Assert.That(expectedTiming, Is.EqualTo(ticks), $"Invalid timing value for [{opcode}]"); } }