Exemplo n.º 1
0
        private static void SanityUla(string name, IUlaDevice ula, byte[] opcode, int[] pattern)
        {
            IMemoryDevice mem  = new ZXMAK2.Hardware.Spectrum.MemorySpectrum48();           // MemoryPentagon128();
            var           p128 = GetTestMachine(Resources.machines_test);

            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.DebugReset();
            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       = CpuModeIndex.None;
            p128.CPU.XFX      = CpuModeEx.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.DebugStepInto();
                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;
        }
Exemplo n.º 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;
        }