Exemplo n.º 1
0
        public void Step()
        {
            try
            {
                RefreshProps();
                double cpuHertz = 4.77 * 1000000;

                _sw.Restart();
                double clocks = _cpu.ProcessSingleInstruction(Debug);
                _sw.Stop();
                double us = (clocks / cpuHertz) * 1000000;

                UpdateSpeed(us);

                _timer.Step(us);
                DrawBuffer = _video.Step(us);
                _masterPic.Step();
                _slavePic.Step();
                _masterFloppy.Step(us);
                _slaveFloppy.Step(us);
                RefreshProps();

                var breakpoint = Breakpoints.FirstOrDefault(b => b.Address == GetCurrentAddress());
                if (breakpoint != null)
                {
                    Status = SystemStatus.Paused;
                    if (breakpoint.IsInternal)
                    {
                        RemoveBreakpoint(breakpoint.Address);
                    }
                    BreakpointHit?.Invoke();
                    RefreshProps(true);
                }
            }
            catch (InvalidOperationException e)
            {
                Console.WriteLine(e.Message);
                Console.WriteLine("SYSTEM PAUSED");
                Status = SystemStatus.Paused;
                BreakpointHit?.Invoke();
                RefreshProps(true);
            }
        }
Exemplo n.º 2
0
        private static void Main()
        {
            Console.BufferHeight = 32766;
            Console.WriteLine("z100emu");

            var rom = ZenithRom.GetRom("v1-2.bin");

            var slave8259  = new Intel8259();
            var master8259 = new Intel8259(slave8259);

            var video = new ZenithVideo(master8259);
            var ram   = new ZenithRam(1024 * 1024, master8259);

            ram.MapBank(rom);

            var disk = new ImdFloppy(File.ReadAllBytes("msd2131.imd"));

            Console.WriteLine("IMD Version: " + disk.ImdVersion);
            Console.WriteLine("IMD Date:    " + disk.ImdDate);
            Console.WriteLine("IMD Comment: " + disk.ImdComment);

            ICpu cpu = new Cpu8086(ram, master8259);

            var timer = new Intel8253(master8259);

            cpu.AttachPortDevice(timer);

            cpu.AttachPortDevice(master8259);
            cpu.AttachPortDevice(slave8259);

            cpu.AttachPortDevice(new ZenithMemControl(ram, rom));
            cpu.AttachPortDevice(new ZenithReserved());

            var kb = new Zenith8041a(master8259);

            cpu.AttachPortDevice(kb);
            cpu.AttachPortDevice(new ZenithParallel());
            cpu.AttachPortDevice(new ZenithSerial(0xE8));
            cpu.AttachPortDevice(new ZenithSerial(0xEC));
            cpu.AttachPortDevice(new ZenithExpansion());

            cpu.AttachPortDevice(new ZenithDIP());

            cpu.AttachPortDevice(new ZenithWinchester());

            var masterStatus = new StatusPort(slave8259, 0xB5);
            var masterFloppy = new WD1797(masterStatus, 0xB0, disk);
            var masterCl     = new ControlLatch(0xB4);
            var slaveStatus  = new StatusPort(slave8259, 0xBD);
            var slaveFloppy  = new WD1797(slaveStatus, 0xB8, disk);
            var slaveCl      = new ControlLatch(0xBC);

            cpu.AttachPortDevice(masterFloppy);
            cpu.AttachPortDevice(masterCl);
            cpu.AttachPortDevice(masterStatus);
            cpu.AttachPortDevice(slaveFloppy);
            cpu.AttachPortDevice(slaveCl);
            cpu.AttachPortDevice(slaveStatus);

            ram.MapBank(video);
            cpu.AttachPortDevice(video);


            var debug = false;

            double cpuHertz = 4.77 * 1000000;

            Stopwatch sw = new Stopwatch();

            var quit = false;

            while (!quit)
            {
                sw.Restart();
                double clocks = cpu.ProcessSingleInstruction(debug);
                sw.Stop();
                double realUs = sw.ElapsedTicks * TimeSpan.TicksPerMillisecond * 1000;
                double us     = (clocks / cpuHertz) * 1000000;
                timer.Step(us);
                video.Step(us);
                master8259.Step();
                slave8259.Step();
                masterFloppy.Step(us);
                slaveFloppy.Step(us);
            }
        }