using ParsonsMegaDrive.Core; using ParsonsMegaDrive.Core.Memory; using Xunit; namespace ParsonsMegaDrive.Tests { public class CpuTests { [Fact] public void MoveQ_ShouldLoadDataAndSetFlags() { // 1. Arrange: Boot the machine var bus = new MdMemoryBus(); var cpu = new M68000(bus); // 2. Load the opcode for "MOVEQ #5, D1" (0x7205) into memory at PC 0 bus.Write16(0x000000, 0x7205); // 3. Act: Step the CPU exactly once int cycles = cpu.Step(); // 4. Assert: Did it work? Assert.Equal(4, cycles); // Should take exactly 4 cycles Assert.Equal(2u, cpu.PC); // PC should advance by 2 bytes Assert.Equal(5u, cpu.D[1]); // D1 should now contain the number 5 // Assert Flags (5 is greater than 0, so Z and N should be false) Assert.False(cpu.FlagZ); Assert.False(cpu.FlagN); Assert.False(cpu.FlagV); Assert.False(cpu.FlagC); } } }