Beispiel #1
0
        private static void runZexall()
        {
            SpectrumConcrete p128 = new SpectrumConcrete();
            p128.Init();
            p128.IsRunning = true;
            p128.DoReset();
            p128.ExecuteFrame();
            p128.IsRunning = false;
            foreach (var kbd in p128.BusManager.FindDevices<IKeyboardDevice>())
            {
                kbd.KeyboardState = new FakeKeyboardState(Key.Y);
            }

            using (Stream testStream = GetTestStream("zexall.sna"))
            {
                p128.Loader.GetSerializer(Path.GetExtension("zexall.sna")).Deserialize(testStream);
            }
            p128.IsRunning = true;
            int frame;
            for (frame = 0; frame < 700000; frame++)
            {
                p128.ExecuteFrame();
                if (frame % 30000 == 0 || ((frame > 630000 && frame < 660000) && frame % 10000 == 0))
                {
                    Console.WriteLine(string.Format("{0:D8}", frame));
                    p128.Loader.SaveFileName(string.Format("{0:D8}.PNG", frame));
                }
            }
            p128.Loader.SaveFileName(string.Format("{0:D8}.PNG", frame));
            p128.BusManager.Disconnect();
        }
Beispiel #2
0
        private static void SanityUla(string name, IUlaDevice ula, byte[] opcode, int[] pattern)
        {
            IMemoryDevice mem = new ZXMAK2.Hardware.Spectrum.MemorySpectrum48();// MemoryPentagon128();
            SpectrumConcrete p128 = new SpectrumConcrete();
            p128.Init();
            p128.BusManager.Disconnect();
            p128.BusManager.Clear();
            p128.BusManager.Add((BusDeviceBase)mem);
            p128.BusManager.Add((BusDeviceBase)ula);
            p128.BusManager.Connect();
            p128.IsRunning = true;
            p128.DoReset();
            p128.ExecuteFrame();
            p128.IsRunning = false;

            ushort offset = 0x4000;
            for (int i = 0; i < pattern.Length; i++)
            {
                for (int j = 0; j < opcode.Length; j++)
                    mem.WRMEM_DBG(offset++, opcode[j]);
            }
            p128.CPU.regs.PC = 0x4000;
            p128.CPU.regs.IR = 0x4000;
            p128.CPU.regs.SP = 0x4000;
            p128.CPU.regs.AF = 0x4000;
            p128.CPU.regs.HL = 0x4000;
            p128.CPU.regs.DE = 0x4000;
            p128.CPU.regs.BC = 0x4000;
            p128.CPU.regs.IX = 0x4000;
            p128.CPU.regs.IY = 0x4000;
            p128.CPU.regs._AF = 0x4000;
            p128.CPU.regs._HL = 0x4000;
            p128.CPU.regs._DE = 0x4000;
            p128.CPU.regs._BC = 0x4000;
            p128.CPU.regs.MW = 0x4000;
            p128.CPU.IFF1 = p128.CPU.IFF2 = false;
            p128.CPU.IM = 2;
            p128.CPU.BINT = false;
            p128.CPU.FX = ZXMAK2.Engine.Z80.OPFX.NONE;
            p128.CPU.XFX = ZXMAK2.Engine.Z80.OPXFX.NONE;

            long needsTact = pattern[0];
            long frameTact = p128.CPU.Tact % ula.FrameTactCount;
            long deltaTact = needsTact - frameTact;
            if (deltaTact < 0)
                deltaTact += ula.FrameTactCount;
            p128.CPU.Tact += deltaTact;

            //if (pattern == s_patternUla48_Late_LDAHL)
            //    p128.Loader.SaveFileName("TEST-LDAHL-48-LATE.SZX");
            //if (pattern == s_patternUla48_Early_LDAHL)
            //    p128.Loader.SaveFileName("TEST-LDAHL-48-EARLY.SZX");

            for (int i = 0; i < pattern.Length - 1; i++)
            {
                p128.DoStepInto();
                frameTact = p128.CPU.Tact % ula.FrameTactCount;
                if (frameTact != pattern[i + 1])
                {
                    ConsoleColor tmp = Console.ForegroundColor;
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine(
                        "Sanity ULA {0} [{1}]:\tfailed @ {2}->{3} (should be {2}->{4})",
                        ula.GetType().Name,
                        name,
                        pattern[i],
                        frameTact,
                        pattern[i + 1]);
                    Console.ForegroundColor = tmp;
                    return;
                }
            }
            p128.BusManager.Disconnect();
            ConsoleColor tmp2 = Console.ForegroundColor;
            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine("Sanity ULA {0} [{1}]:\tpassed", ula.GetType().Name, name);
            Console.ForegroundColor = tmp2;
        }
Beispiel #3
0
        private static void ExecTests(string testName, int frameCount)
        {
            SpectrumConcrete p128 = new SpectrumConcrete();
            p128.Init();
            p128.IsRunning = true;
            p128.DoReset();
            p128.ExecuteFrame();

            p128.IsRunning = false;
            using (Stream testStream = GetTestStream(testName))
                p128.Loader.GetSerializer(Path.GetExtension(testName)).Deserialize(testStream);
            p128.IsRunning = true;

            Stopwatch watch = new Stopwatch();
            watch.Start();
            for (int frame = 0; frame < frameCount; frame++)
                p128.ExecuteFrame();
            watch.Stop();
            Console.WriteLine("{0}:\t{1} [ms]", testName, watch.ElapsedMilliseconds);
            //p128.Loader.SaveFileName(testName);
            p128.BusManager.Disconnect();
        }