Exemplo n.º 1
0
        public DosPic(Processor.x86.CSharpExecutor.Cpu implementation, RawProgramMain rawProgramMain)
            : base(implementation)
        {
            Implementation = implementation;
            RawProgramMain = rawProgramMain;

            /* Setup pic0 and pic1 with initial values like DOS has normally */

            for (var i = 0; i < 2; i++)
            {
                pics[i].masked             = 0xff;
                pics[i].auto_eoi           = false;
                pics[i].rotate_on_auto_eoi = false;
                pics[i].request_issr       = false;
                pics[i].special            = false;
                pics[i].single             = false;
                pics[i].icw_index          = 0;
                pics[i].icw_words          = 0;
            }

            for (var i = 0; i <= 7; i++)
            {
                irqs[i].active    = false;
                irqs[i].masked    = true;
                irqs[i].inservice = false;

                irqs[i + 8].active    = false;
                irqs[i + 8].masked    = true;
                irqs[i + 8].inservice = false;

                irqs[i].InterruptVector     = 0x8 + i;
                irqs[i + 8].InterruptVector = 0x70 + i;
            }

            irqs[0].masked = false;    /* Enable system timer */
            irqs[1].masked = false;    /* Enable Keyboard IRQ */
            irqs[2].masked = false;    /* Enable second pic */
            irqs[8].masked = false;    /* Enable RTC IRQ */

            //        if (machine == MCH_PCJR)
            //        {
            //            /* Enable IRQ6 (replacement for the NMI for PCJr) */
            //            irqs[6].masked = false;
            //        }
        }
Exemplo n.º 2
0
        public DosDma(ICpu implementation, RawProgramMain rawProgramMain)
            : base(implementation)
        {
            RawProgramMain    = rawProgramMain;
            DmaControllers[0] = new DmaController(0, rawProgramMain.Implementation);
            DmaControllers[1] = new DmaController(1, rawProgramMain.Implementation);

            Task.Run(async() => {
                var chan = RawProgramMain.DosDma.dma_get_channel(5);

                while (true)
                {
                    if (!chan.Masked)
                    {
                        var buf = new byte[2 * 50];
                        chan.Read(buf);
                    }
                    await Task.Delay(TimeSpan.FromSeconds(0.05));
                }
            });
        }
Exemplo n.º 3
0
        public DosInterrupt(Cpu implementation, RawProgramMain rawProgramMain)
            : base(implementation)
        {
            Implementation = implementation;
            RawProgramMain = rawProgramMain;

            fileHandlers.Add(null); // in
            fileHandlers.Add(null); // out
            fileHandlers.Add(null); // err
            fileHandlers.Add(null); // dummy (from dosbox)
            fileHandlers.Add(null); // dummy (from dosbox)
            fileHandlersPreserve = 5;

            if (!string.IsNullOrEmpty(RawProgramMain.Configuration.Dos.PngOutput))
            {
                Directory.CreateDirectory(RawProgramMain.Configuration.Dos.PngOutput);
                foreach (var filePath in Directory.EnumerateFiles(RawProgramMain.Configuration.Dos.PngOutput, "*.png"))
                {
                    File.Delete(filePath);
                }
            }
        }
Exemplo n.º 4
0
        public unsafe void int_10()
        {
            const int vga_vmemsize = 0x200000;

            switch (ah.UInt16)
            {
            case 0x0f:
                ah = 0x50;  // width in char
                al = 0x3;   // video mode
                bh = 0;     // page
                break;

            case 0x4f:     // VESA Calls
                switch (al.UInt16)
                {
                case 0x01:         // Get SVGA Mode Information
                {
                    if (cx != 0x101)
                    {
                        throw new NotImplementedException();
                    }

                    al = 0x4f;
                    ah = 0;         // success

                    {
                        var page_size = 640 * 480;
                        page_size = page_size & (~15);

                        ushort mode_attr = 0x9b;

                        var span = Memory.GetFixSize(es, di, Marshal.SizeOf <mode_info>());
                        span.Clear();

                        ref var mi = ref Memory.Ref <mode_info>(es[di]);

                        mi.BytesPerScanLine = 640;
                        mi.NumberOfPlanes   = 1;
                        mi.BitsPerPixel     = 8;
                        mi.MemoryModel      = 4;
                        mi.WinAAttributes   = 7;

                        if (vga_vmemsize < page_size)
                        {
                            throw new NotImplementedException();
                        }
                        else
                        {
                            mi.ModeAttributes     = mode_attr;
                            mi.NumberOfImagePages = (byte)((vga_vmemsize / page_size) - 1);
                        }

                        mi.WinGranularity = 64;
                        mi.WinSize        = 64;
                        mi.WinASegment    = 0xa000;
                        mi.XResolution    = 640;
                        mi.YResolution    = 480;

                        if (added_callback_setwindow == false)
                        {
                            RawProgramMain.AddInternalDynamicMethod(callback_setwindow, 16, 0xf0001320);
                            added_callback_setwindow = true;
                        }

                        mi.WinFuncPtr    = 0xf0001320;
                        mi.NumberOfBanks = 1;
                        mi.Reserved_page = 1;
                        mi.XCharSize     = 8;
                        mi.YCharSize     = 16;
                        mi.PhysBasePtr   = 0;
                    }

                    break;
                }

                case 0x02:         // Set videomode
                {
                    if (bx != 0x101)
                    {
                        throw new NotImplementedException();
                    }

                    al = 0x4f;
                    ah = 0;         // success

                    // /* mode  ,type     ,sw  ,sh  ,tw ,th ,cw,ch ,pt,pstart  ,plength,htot,vtot,hde,vde special flags */
                    //{ 0x101  ,M_LIN8   ,640 ,480 ,80 ,30 ,8 ,16 ,1 ,0xa0000 ,0x10000,100 ,525 ,80 ,480 ,0    },

                    break;
                }

                case 0x05:
                {
                    if (bh != 0)
                    {
                        throw new NotImplementedException();
                    }

                    // ah = SetCPUWindow(bl, dl); (window, address)

                    if (bl != 0)
                    {
                        ah = 1;
                    }
                    else
                    {
                        if (dl.Int32 * 0x10000 < vga_vmemsize)
                        {
                            ah = 0;
                            // out(0x3d4, 0x6a)
                            // out(0x3d5, dl)
                            // std::cerr << static_cast<uint>(dl) << std::endl;


                            var curr_bank = ((Memory)Memory)
                                            .mem_phys_raw(0xa0000, 0x10000)
                                            .Slice(0, 0x10000);


                            var offset = 3 * curr_bank_num * 0x10000;
                            for (var i = 0; i < 0x10000; i++)
                            {
                                if (img_data.Length <= offset + 3 * i + 2)
                                {
                                    break;
                                }

                                var c = curr_bank[i];

#if false
                                img_data[offset + 3 * i + 0] = c;
                                img_data[offset + 3 * i + 1] = c;
                                img_data[offset + 3 * i + 2] = c;
#else
                                img_data[offset + 3 * i + 2] = pal[c].rgb[2];
                                img_data[offset + 3 * i + 1] = pal[c].rgb[1];
                                img_data[offset + 3 * i + 0] = pal[c].rgb[0];
#endif
                            }

                            //if (dl == 0)
                            {
                                //var width = 640;
                                //var height = 480;

                                var ms         = new MemoryStream();
                                var nimg       = Image.LoadPixelData <Rgb24>(img_data, buf_width, buf_height);
                                var pngEncoder = new PngEncoder();
                                pngEncoder.CompressionLevel = 1;
                                pngEncoder.Encode(nimg, ms);
                                PngBytes = ms.ToArray();

                                var forgot = MainHub.SendClientUpdateImage(RawProgramMain.ServiceProvider);

                                fileNum++;
                                if (!string.IsNullOrEmpty(RawProgramMain.Configuration.Dos.PngOutput))
                                {
                                    var pngOutput = RawProgramMain.Configuration.Dos.PngOutput;
                                    var filePath  = Path.Combine(pngOutput, $"img-{fileNum:D4}.png");
                                    File.WriteAllBytes(filePath, PngBytes);
                                }

                                var time = DateTime.Now.TimeOfDay;
                                time = new TimeSpan(0, time.Hours, time.Minutes, time.Seconds, time.Milliseconds / 10 * 10);
                                NonBlockingConsole.WriteLine($"    Screen. Time: {time:hh\\:mm\\:ss\\.ff}, Number: {fileNum}.");
                            }


                            var need_cpy = (curr_bank_num * 0x10000 < all_banks.Length);

                            if (need_cpy)
                            {
                                curr_bank.CopyTo(all_banks.AsSpan(curr_bank_num * 0x10000));
                            }

                            curr_bank_num = dl.UInt16;

                            if (need_cpy)
                            {
                                all_banks.AsSpan().Slice(curr_bank_num * 0x10000, 0x10000).CopyTo(curr_bank);
                            }
                        }
                        else
                        {
                            ah = 1;
                        }
                    }

                    al = 0x4f;
                    break;
                }

                default:
                    throw new NotImplementedException();
                }

                break;
Exemplo n.º 5
0
 public MainController(RawProgramMain rawProgramMain)
 {
     RawProgramMain = rawProgramMain;
 }
Exemplo n.º 6
0
 public MainHub(RawProgramMain rawProgramMain)
 {
     _rawProgramMain = rawProgramMain;
 }
Exemplo n.º 7
0
 public DosPort(Cpu implementation, RawProgramMain rawProgramMain)
     : base(implementation)
 {
     Implementation = implementation;
     RawProgramMain = rawProgramMain;
 }
Exemplo n.º 8
0
 public DosTimer(ICpu implementation, RawProgramMain rawProgramMain)
     : base(implementation)
 {
     RawProgramMain = rawProgramMain;
 }