Beispiel #1
0
        public void Initialize()
        {
            AllocConsole();
            Console.BufferHeight = 32766;
            Console.WriteLine("z100emu");
            //Console.WriteLine("IMD Version: " + _disk.ImdVersion);
            //Console.WriteLine("IMD Date:    " + _disk.ImdDate);
            //Console.WriteLine("IMD Comment: " + _disk.ImdComment);

            _rom = ZenithRom.GetRom("mtr.bin");

            _slavePic  = new Intel8259();
            _masterPic = new Intel8259(_slavePic);
            _timer     = new Intel8253(_masterPic);
            Ram        = new ZenithRam(512 * 1024, _masterPic);
            _video     = new ZenithVideo(_masterPic);
            //_disk = new RawFloppy(File.ReadAllBytes("zdos4-1.img"));
            _disk = new RawFloppy(File.ReadAllBytes("bios402-msdos401-1.img"));
            //_disk = new RawFloppy(File.ReadAllBytes("zdos31-diag.img"));
            //_disk = new RawFloppy(File.ReadAllBytes("zdos31-1.img"));
            //_disk = new ImdFloppy(File.ReadAllBytes("msdosv11.imd"));

            _cpu = new Cpu8086(Ram, _masterPic);
            _cpu.DebugLineEmitted += DebugLine;

            Keyboard = new Zenith8041a(_masterPic);

            _masterStatus = new StatusPort(_slavePic, 0xB5);
            _masterFloppy = new WD1797(_masterStatus, 0xB0, _disk);
            _masterCl     = new ControlLatch(0xB4);
            _slaveStatus  = new StatusPort(_slavePic, 0xBD);
            _slaveFloppy  = new WD1797(_slaveStatus, 0xB8, _disk);
            _slaveCl      = new ControlLatch(0xBC);

            _steps      = 0;
            _totalUs    = 0;
            _totalTicks = 0;
            _sw         = new Stopwatch();


            Ram.MapBank(_rom);
            Ram.MapBank(_video);

            _cpu.AttachPortDevice(_timer);

            _cpu.AttachPortDevice(_masterPic);
            _cpu.AttachPortDevice(_slavePic);

            _cpu.AttachPortDevice(new ZenithMemControl(Ram, _rom));
            _cpu.AttachPortDevice(new ZenithReserved());

            _cpu.AttachPortDevice(Keyboard);
            _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());

            _cpu.AttachPortDevice(_masterFloppy);
            _cpu.AttachPortDevice(_masterCl);
            _cpu.AttachPortDevice(_masterStatus);
            _cpu.AttachPortDevice(_slaveFloppy);
            _cpu.AttachPortDevice(_slaveCl);
            _cpu.AttachPortDevice(_slaveStatus);

            _cpu.AttachPortDevice(_video);

            Breakpoints = new List <Breakpoint>();

            Status = SystemStatus.Paused;
            RefreshProps();

            //AddBreakpoint(0x51B9);
            //AddBreakpoint(0x40 * 0x10 + 0x4424); // timer
            //AddBreakpoint(0x40 * 0x10 + 0x44B6); // mem
            AddBreakpoint(0x40 * 0x10 + 0x450D); // mem
            AddBreakpoint(0x8716);               // ?
        }
Beispiel #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);
            }
        }