Exemple #1
0
        public void Clear()
        {
            if (m_connected)
            {
                throw new InvalidOperationException("Cannot remove device from connected bus!");
            }
            m_ula        = null;
            m_soundFrame = null;

            m_eventManager.Clear();
            m_deviceList.Clear();
        }
Exemple #2
0
 public void Remove(BusDeviceBase device)
 {
     if (m_connected)
     {
         throw new InvalidOperationException("Cannot remove device from connected bus!");
     }
     if (device is IUlaDevice)
     {
         if (m_ula != device)
         {
             throw new InvalidOperationException("Cannot remove non-existing ULA device!");
         }
         else
         {
             m_ula = null;
         }
     }
     m_deviceList.Remove(device);
 }
Exemple #3
0
        public void Add(BusDeviceBase device)
        {
            if (m_connected)
            {
                throw new InvalidOperationException("Cannot add device into connected bus!");
            }
            foreach (var device2 in m_deviceList)
            {
                if (device2.GetType() == device.GetType())
                {
                    throw new InvalidOperationException(
                              string.Format(
                                  "Cannot add device {0}, because this device already exist!",
                                  device.Name));
                }
            }
            if (device is IJtagDevice && FindDevice <IJtagDevice>() != null)
            {
                throw new InvalidOperationException(
                          string.Format(
                              "Cannot add second instance of JtagDevice! '{0}'",
                              device.Name));
            }
            var ula = device as IUlaDevice;

            if (ula != null)
            {
                if (m_ula != null)
                {
                    throw new InvalidOperationException("Cannot add second ULA device!");
                }
                else
                {
                    m_ula = ula;
                }
            }
            device.BusOrder = m_deviceList.Count;
            m_deviceList.Add(device);
        }
Exemple #4
0
        private unsafe void runThreadProc()
        {
            try
            {
                m_startedEvent.Set();
                Spectrum.IsRunning = true;

                var bus  = Spectrum.BusManager;
                var host = m_host;
                using (var input = new InputAggregator(
                           host,
                           bus.FindDevices <IKeyboardDevice>().ToArray(),
                           bus.FindDevices <IMouseDevice>().ToArray(),
                           bus.FindDevices <IJoystickDevice>().ToArray()))
                {
                    m_ula = Spectrum.BusManager.FindDevice <IUlaDevice>();

                    // main emulation loop
                    while (Spectrum.IsRunning)
                    {
                        input.Scan();
                        var startTime = Stopwatch.GetTimestamp();
                        Spectrum.ExecuteFrame();
                        var stopTime = Stopwatch.GetTimestamp();
                        m_instantUpdateTime = stopTime - startTime - _renderTime;
                        m_instantRenderTime = _renderTime;
                    }

                    m_ula = null;
                }
                OnUpdateState(this, EventArgs.Empty);
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
            }
        }
Exemple #5
0
 public BmpSerializer(IUlaDevice ulaDevice)
     : base(ulaDevice)
 {
 }
 public PngSerializer(IUlaDevice ulaDevice)
     : base(ulaDevice)
 {
 }
 public ScreenshotSerializerBase(IUlaDevice ulaDevice)
 {
     m_ulaDevice = ulaDevice;
 }
 public ScreenshotSerializerBase(IUlaDevice ulaDevice)
 {
     m_ulaDevice = ulaDevice;
 }
 public ScrSerializer(IUlaDevice ulaDevice)
 {
     m_ulaDevice = ulaDevice;
 }
Exemple #10
0
 public BmpSerializer(IUlaDevice ulaDevice)
     : base(ulaDevice)
 {
 }
Exemple #11
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;
        }
Exemple #12
0
 public ScrSerializer(IUlaDevice ulaDevice)
 {
     m_ulaDevice = ulaDevice;
 }
Exemple #13
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;
        }
Exemple #14
0
 public PngSerializer(IUlaDevice ulaDevice)
     : base(ulaDevice)
 {
 }