Beispiel #1
0
        private void Run(string[] args)
        {
            var fileName    = args.Length == 0 ? "zexall.com" : args[0];
            var testsToSkip = args.Length >= 2 ? int.Parse(args[1]) : 0;

            DollarCode = Encoding.ASCII.GetBytes(new[] { '$' })[0];

            var z80 = new Z80Processor();

            z80.ClockSynchronizer           = null;
            z80.AutoStopOnRetWithStackEmpty = true;

            var program = File.ReadAllBytes(fileName);

            z80.Memory.SetContents(0x100, program);

            z80.Memory[6] = 0xFF;
            z80.Memory[7] = 0xFF;

            z80.BeforeInstructionFetch += Z80OnBeforeInstructionFetch;

            SkipTests(z80, testsToSkip);

            Stopwatch sw = new Stopwatch();

            sw.Start();

            z80.Reset();
            z80.Registers.PC = 0x100;
            z80.Continue();

            sw.Stop();
            Console.WriteLine("\r\nElapsed time: " + sw.Elapsed);
        }
Beispiel #2
0
        public BenchmarkRunner(Benchmark settings)
        {
            // Create the emulator
            var emulator = new Z80Processor();

            // Insert the memory contents
            foreach (var item in settings.Memory)
            {
                emulator.Memory.SetContents(item.Offset, item.Values);
            }

            // Configure the CPU emulator...
            emulator.MemoryAccess += OnMemoryAccess;
            var counter = new CycleCountingClockSynchronizer(emulator, settings.MaxCycles);

            emulator.ClockSynchronizer           = counter;
            emulator.AutoStopOnRetWithStackEmpty = true;
            emulator.InterruptMode = 1;
            emulator.Reset();
            // ReSharper disable once IntVariableOverflowInUncheckedContext
            emulator.Registers.SP = (short)settings.StackPointer;
            emulator.Registers.PC = (ushort)settings.ExecutionAddress;

            var sw = Stopwatch.StartNew();

            emulator.Start();
            sw.Stop();

            if (emulator.StopReason == StopReason.StopInvoked)
            {
                throw new Exception("Emulator stopped due to running for too long");
            }

            VramMismatches = checkComparisons(settings.VramComparisons, i => _vdp.Vram[i]).ToList();
            RamMismatches  = checkComparisons(settings.RamComparisons, i => emulator.Memory[i]).ToList();

            sw.Stop();

            // Record state
            Cycles        = counter.Cycles;
            WallClockTime = sw.Elapsed;
        }