public void InterruptDeviceResetWorksAsExpected() { // --- Arrange var vm = new SpectrumAdvancedTestMachine(); var idev = new InterruptDevice(TEST_INT_TACT); idev.OnAttachedToVm(vm); // --- Act idev.Reset(); // --- Assert idev.InterruptRaised.ShouldBeFalse(); idev.InterruptRevoked.ShouldBeFalse(); }
public void InterruptIsRaisedWithinAllowedRange() { for (var tact = TEST_INT_TACT; tact <= TEST_INT_TACT + InterruptDevice.LONGEST_OP_TACTS; tact++) { // --- Arrange var vm = new SpectrumAdvancedTestMachine(); var idev = new InterruptDevice(TEST_INT_TACT); idev.OnAttachedToVm(vm); // --- Act/Assert idev.CheckForInterrupt(tact); idev.InterruptRaised.ShouldBeTrue(); idev.InterruptRevoked.ShouldBeFalse(); idev.FrameCount.ShouldBe(1); (vm.Cpu.StateFlags & Z80StateFlags.Int).ShouldBe(Z80StateFlags.Int); } }
public void InterruptNotRaisedTooEarly() { // --- Arrange var vm = new SpectrumAdvancedTestMachine(); var idev = new InterruptDevice(TEST_INT_TACT); idev.OnAttachedToVm(vm); // --- Act/Assert for (var tact = 0; tact < TEST_INT_TACT; tact++) { idev.CheckForInterrupt(tact); idev.InterruptRaised.ShouldBeFalse(); idev.InterruptRevoked.ShouldBeFalse(); idev.FrameCount.ShouldBe(0); (vm.Cpu.StateFlags & Z80StateFlags.Int).ShouldBe(Z80StateFlags.None); } }
public void InterruptIsNotRereaised() { // --- Arrange var vm = new SpectrumAdvancedTestMachine(); var idev = new InterruptDevice(TEST_INT_TACT); idev.OnAttachedToVm(vm); idev.CheckForInterrupt(TEST_INT_TACT); // --- Act vm.Cpu.StateFlags &= Z80StateFlags.InvInt; idev.CheckForInterrupt(TEST_INT_TACT + 1); // --- Assert idev.InterruptRaised.ShouldBeTrue(); idev.InterruptRevoked.ShouldBeFalse(); (vm.Cpu.StateFlags & Z80StateFlags.Int).ShouldBe(Z80StateFlags.None); idev.FrameCount.ShouldBe(1); }
public void InterruptIsNotRaisedTooLate() { // --- Arrange var vm = new SpectrumAdvancedTestMachine(); var idev = new InterruptDevice(TEST_INT_TACT); idev.OnAttachedToVm(vm); // --- Act/Assert var lateTact = TEST_INT_TACT + InterruptDevice.LONGEST_OP_TACTS + 1; for (var tact = lateTact; tact < lateTact + 10; tact++) { idev.CheckForInterrupt(tact); idev.InterruptRaised.ShouldBeFalse(); idev.InterruptRevoked.ShouldBeTrue(); idev.FrameCount.ShouldBe(0); (vm.Cpu.StateFlags & Z80StateFlags.Int).ShouldBe(Z80StateFlags.None); } }