Exemplo n.º 1
0
        public FloppyControllerAdapter(X8086 cpu) : base(cpu)
        {
            task       = new TaskSC(this);
            this.sched = cpu.Sched;
            if (cpu.PIC != null)
            {
                this.irq = cpu.PIC.GetIrqLine((byte)6);
            }
            if (cpu.DMA != null)
            {
                this.dma = cpu.DMA.GetChannel(2);
                cpu.DMA.BindChannel(2, this);
            }

            curCylinder       = new byte[4];
            diskimg           = new DiskImage[512];
            regDOR            = (byte)(0xC);
            ctlStepRateTime   = (byte)0;
            ctlHeadUnloadTime = (byte)0;
            ctlHeadLoadTime   = (byte)0;
            ctlNonDma         = false;

            for (uint i = 0x3F0; i <= 0x3F7; i++)
            {
                ValidPortAddress.Add(i);
            }
        }
Exemplo n.º 2
0
        public PPI8255(X8086 cpu, InterruptRequest irq)
        {
            task = new TaskSC(this);

            for (int i = 0x60; i <= 0x6F; i++)
            {
                ValidPortAddress.Add((uint)i);
            }

            //PPISystemControl = x8086.WordToBitsArray(&HA5, PPISystemControl.Length)
            //PPI = x8086.WordToBitsArray(&HA, PPISystemControl.Length)
            //PPICommandModeRegister = &H99

            this.cpu   = cpu;
            this.sched = cpu.Sched;
            this.irq   = irq;
            if (cpu.PIT != null)
            {
                timer = cpu.PIT;
                timer.SetCh2Gate((ppiB & 1) != 0);
            }

            keyBuf          = "";
            keyShiftPending = false;
            keyMap          = new KeyMap();
        }
Exemplo n.º 3
0
        private Scheduler.Task task;// = new TaskSC(this);

        public RTC(X8086 cpu, InterruptRequest irq)
        {
            task     = new TaskSC(this);
            this.irq = irq;

            for (int i = 0x70; i <= 0x71; i++)
            {
                ValidPortAddress.Add((uint)i);
            }

            for (int i = 0x240; i <= 0x24F; i++)
            {
                ValidPortAddress.Add((uint)i);
            }

            // FIXME: Although this works, when pausing the emulation causes the internal timers to get out of sync:
            // The contents at 46C no longer reflect what's returned by INT 1A, 02
            // So the x8086.Resume method should perform a re-sync setting the new tick values into 46C.
            // It also appears that the x8086.Resume method should also advance the time...

            cpu.TryAttachHook((byte)(0x8), new X8086.IntHandler(() =>
            {
                uint ticks = (uint)((DateTime.Now - new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 0, 0, 0)).Ticks / 10000000 * 18.206);
                //cpu.RAM16[0x40, 0x6E] = (ticks >> 16) & 0xFFFF;
                //cpu.RAM16[0x40, 0x6C] = ticks & 0xFFFF;
                //cpu.RAM8[0x40, 0x70] = 0;
                cpu.set_RAM16(0x40, 0x6E, 0x0, false, (ushort)((long)(ticks >> 16) & 0xFFFF));
                cpu.set_RAM16(0x40, 0x6C, 0x0, false, (ushort)((long)(ticks) & 0xFFFF));
                cpu.set_RAM8(0x40, 0x70, 0x0, false, 0x00);

                cpu.TryDetachHook(0x8);
                return(false);
            }));

            cpu.TryAttachHook((byte)(0x1A), new X8086.IntHandler(() =>
            {
                switch (cpu.Registers.AH)
                {
                case 0x2:    // Read real time clock time
                    cpu.Registers.CH = (byte)ToBCD((ushort)DateTime.Now.Hour);
                    cpu.Registers.CL = (byte)ToBCD((ushort)DateTime.Now.Minute);
                    cpu.Registers.DH = (byte)ToBCD((ushort)DateTime.Now.Second);
                    cpu.Registers.DL = 0;
                    cpu.Flags.CF     = 0;
                    return(true);

                case 0x4:    // Read real time clock date
                    cpu.Registers.CH = (byte)ToBCD((ushort)(DateTime.Now.Year / 100));
                    cpu.Registers.CL = (byte)ToBCD((ushort)DateTime.Now.Year);
                    cpu.Registers.DH = (byte)ToBCD((ushort)DateTime.Now.Month);
                    cpu.Registers.DL = (byte)ToBCD((ushort)DateTime.Now.Day);
                    cpu.Flags.CF     = 0;
                    return(true);

                default:
                    return(false);
                }
            }));
        }
Exemplo n.º 4
0
        private const int M = 77; //M as ascii

        public MouseAdapter(X8086 cpu) : base(cpu)
        {
            if (base.CPU.PIC != null)
            {
                irq = base.CPU.PIC.GetIrqLine((byte)4);
            }

            for (uint i = 0x3F8; i <= 0x3F8 + 7; i++)
            {
                ValidPortAddress.Add(i);
            }
        }
Exemplo n.º 5
0
        //protected WebUI wui;

        public CGAAdapter(X8086 cpu, bool useInternalTimer = true, bool enableWebUI = false) : base(cpu)
        {
            CGABasePalette = new Color[] {
                Color.FromArgb(0x0, 0x0, 0x0),
                Color.FromArgb(0x0, 0x0, 0xAA),
                Color.FromArgb(0x0, 0xAA, 0x0),
                Color.FromArgb(0x0, 0xAA, 0xAA),
                Color.FromArgb(0xAA, 0x0, 0x0),
                Color.FromArgb(0xAA, 0x0, 0xAA),
                Color.FromArgb(0xAA, 0x55, 0x0),
                Color.FromArgb(0xAA, 0xAA, 0xAA),
                Color.FromArgb(0x55, 0x55, 0x55),
                Color.FromArgb(0x55, 0x55, 0xFF),
                Color.FromArgb(0x55, 0xFF, 0x55),
                Color.FromArgb(0x55, 0xFF, 0xFF),
                Color.FromArgb(0xFF, 0x55, 0x55),
                Color.FromArgb(0xFF, 0x55, 0xFF),
                Color.FromArgb(0xFF, 0xFF, 0x55),
                Color.FromArgb(0xFF, 0xFF, 0xFF)
            };
            vidModeChangeFlag = (int)(+0b1000);

            this.useInternalTimer = useInternalTimer;

            //if (enableWebUI)
            //{
            //	wui = new WebUI(cpu, videoBMP, chars);
            //}

            for (uint i = 0x3D0; i <= 0x3DF; i++) // CGA
            {
                ValidPortAddress.Add(i);
            }
            ValidPortAddress.Add(0x3B8);

            for (int i = 0; i <= 255; i++)
            {
                if (i >= 32 && i < 255)
                {
                    chars[i] = Convert.ToChar(i);
                }
                else
                {
                    chars[i] = ' ';
                }
            }

            Reset();

            //VideoMode = VideoModes.Mode7_Text_BW_80x25
        }
Exemplo n.º 6
0
        public AdlibAdapter(X8086 cpu) : base(cpu)
        {
            for (int i = 0; i <= Opl.Length - 1; i++)
            {
                Opl[i] = new OplStruct[2];
            }

            ValidPortAddress.Add(0x388);
            ValidPortAddress.Add(0x389);

            Array.Resize(ref attackTable, 16);
            Array.Resize(ref decayTable, 16);
            Array.Resize(ref oplTable, 16);
        }
Exemplo n.º 7
0
        public DMAI8237(X8086 cpu)
        {
            task     = new TaskSC(this);
            this.cpu = cpu;
            channels = new Channel[5];
            for (int i = 0; i <= 4 - 1; i++)
            {
                channels[i] = new Channel(this);
            }
            MaskReg        = 0xF; //  mask all channels
            ch0NextTrigger = -1;

            for (uint i = 0x0; i <= 0xF; i++)
            {
                ValidPortAddress.Add(i);
            }

            for (uint i = 0x80; i <= 0x8F; i++)
            {
                ValidPortAddress.Add(i);
            }
        }
Exemplo n.º 8
0
        public PIC8259(X8086 cpu, PIC8259 master = null)
        {
            if (ReferenceEquals(master, null))
            {
                for (int i = 0x20; i <= 0x2F; i++)
                {
                    ValidPortAddress.Add((uint)i);
                }

                //cascadeId = 0
                //slave(cascadeId) = New PIC8259(cpu, Me)
                //slave(cascadeId).SetMaster(Me, 2)
            }
            else
            {
                for (int i = 0x30; i <= 0x3F; i++)
                {
                    ValidPortAddress.Add((uint)i);
                }
            }

            state = States.ICW1;
        }
Exemplo n.º 9
0
        public PIT8254(X8086 cpu, InterruptRequest irq)
        {
            task             = new TaskSC(this);
            this.cpu         = cpu;
            this.irq         = irq;
            this.currentTime = cpu.Sched.CurrentTime;

            // construct 3 timer channels
            mChannels[0] = new Counter(this);
            mChannels[1] = new Counter(this);
            mChannels[2] = new Counter(this);

            // gate input for channels 0 and 1 is always high
            mChannels[0].Gate = true;
            mChannels[1].Gate = true;

            for (int i = 0x40; i <= 0x43; i++)
            {
                ValidPortAddress.Add((uint)i);
            }

            UpdateClock();
        }