private void EmulatorThreadProc(string rom) { if (!String.IsNullOrEmpty(rom)) { emulator.LoadFile(rom); } else { //emulator.LoadFile(@"Z:\public\ROMs\NES\World\Super Mario Bros. (W) [!].nes"); //emulator.LoadFile(@"Z:\public\ROMs\NES\World\Mario Bros. (W) [!].nes"); //emulator.LoadFile(@"Z:\public\ROMs\NES\USA\Arkanoid (U) [!].nes"); //emulator.LoadFile(@"Z:\public\ROMs\NES\World\Donkey Kong (W) (PRG1) [!].nes"); //emulator.LoadFile(@"Z:\public\ROMs\NES\World\Duck Hunt (W) [!].nes"); //emulator.LoadFile(@"Z:\public\ROMs\NES\tests\spritecans-2011\spritecans.nes"); //emulator.LoadFile(@"Z:\public\ROMs\NES\USA\Balloon Fight (U) [!].nes"); //emulator.LoadFile(@"Z:\public\ROMs\NES\USA\Legend of Zelda, The (U) (PRG1) [!].nes"); //emulator.LoadFile(@"Z:\public\ROMs\NES\Tests\holy_diver\testroms\M4_P256K_C256K.nes"); //emulator.LoadFile(@"Z:\public\ROMs\NES\USA\Super Mario Bros. 2 (U) (PRG1) [!].nes"); //emulator.LoadFile(@"Z:\public\ROMs\NES\USA\Super Mario Bros. 3 (U) (PRG1) [!].nes"); //emulator.LoadFile(@"Z:\public\ROMs\NES\Tests\mmc3_test\1-clocking.nes"); emulator.LoadFile(@"Z:\public\ROMs\NES\USA\Kirby's Adventure (U) (PRG1) [!].nes"); //emulator.LoadFile(@"Z:\public\ROMs\NES\Unlicensed\Hot Dance 2000 (Unl).nes"); //emulator.LoadFile(@"Z:\public\ROMs\NES\Tests\apu_mixer\square.nes"); } emulator.Run(); }
private void RunSpriteHitTest(string rom) { IEmulator emulator = this.GetInstance(); emulator.LoadFile(rom); IMemoryBus cpuBus = (IMemoryBus)emulator.Components.First(c => c.Name == "CPU Bus"); IComponentWithBreakpoints cpuBusBP = (IComponentWithBreakpoints)cpuBus; bool testComplete = false; // This is kind of a hack - the test ROMs set 0xF8 to the number of the test that failed, or 1 // if all tests pass, but it's incremented as the tests run. To determine when the test run // is over, look for a write to 0x07F1, which happens in the routine that prints the results, // and check 0xF8 at that point. IMemoryBreakpoint memBP = (IMemoryBreakpoint)cpuBusBP.CreateBreakpoint("MemoryBreakpoint"); memBP.TargetAddress = 0x07F1; memBP.AccessType = AccessType.Write; memBP.BreakpointHit += (sender, e) => { testComplete = true; }; memBP.Enabled = true; base.RunEmulator(emulator, () => !testComplete); byte value = cpuBus.Read(0xF8); if (value != 1) { // Non-zero value other than 1 indicates failure Assert.Fail("Test #{0} failed!", value); } }
public void RunCpuTest() { IEmulator emulator = this.GetInstance(); emulator.LoadFile(@"TestRoms\nestest\nestest.nes"); List <string> expectedOutput = new List <string>(File.ReadAllLines(@"TestResources\CpuTests\nestest.expected")); IProcessorCore cpu = (IProcessorCore)emulator.Components.First(c => c.Name == "Ricoh 2A03 CPU"); IComponentWithRegisters ppu = (IComponentWithRegisters)emulator.Components.First(c => c.Name == "Ricoh 2C02 PPU"); IMemoryBus cpuBus = (IMemoryBus)emulator.Components.First(c => c.Name == "CPU Bus"); // Jump to automated test entry point cpu.GetRegisterByName("PC").Value = 0xC000; // Set initial state cpu.GetRegisterByName("S").Value = 0xFD; ppu.GetRegisterByName("cycle").Value = 0; ppu.GetRegisterByName("scanline").Value = 241; IEnumerator <string> outputLineEnumerator = expectedOutput.GetEnumerator(); outputLineEnumerator.MoveNext(); base.RunEmulator(emulator, () => { string state = this.DumpEmulatorState(cpu, ppu, cpuBus); string expectedOutputLine = outputLineEnumerator.Current; if (!expectedOutputLine.StartsWith("#") && !String.Equals(state, expectedOutputLine, StringComparison.Ordinal)) { Debug.WriteLine("**** {0}", (object)state); Debug.WriteLine("Exp: {0}", (object)expectedOutputLine); Assert.Fail("Output mismatch!"); return(false); } Debug.WriteLine(state); return(outputLineEnumerator.MoveNext()); }); }