Example #1
3
        public static Canvas GetFullScreenCanvas(Mode mode)
        {
            if (MyVideoDriver == null)
                return MyVideoDriver = new VBEScreen(mode);

            /* We have already got a VideoDriver istance simple change its mode */
            MyVideoDriver.Mode = mode;
            return MyVideoDriver;
        }
Example #2
0
        public VBEScreen(Mode mode) : base(mode)
        {
            if (!IsModeValid(mode))
                throw new ArgumentOutOfRangeException($"Mode {mode} is not supported by VBE Driver");

            VBEDriver = new VBEDriver((ushort)mode.Rows, (ushort)mode.Columns, (ushort)mode.ColorDepth);
        }
Example #3
0
File: Mode.cs Project: fanoI/Cosmos
        public bool Equals(Mode other)
        {
            if (this.columns == other.columns && this.rows == other.rows && this.color_depth == other.color_depth)
                return true;

            return false;
        }
Example #4
0
File: Mode.cs Project: fanoI/Cosmos
        public int CompareTo(Mode other)
        {
            // color_depth has no effect on the orderiring
            if (this.columns < other.columns && this.rows < other.rows)
                return -1;

            if (this.columns > other.columns && this.rows > other.rows)
                return 1;

            // They are effectively Equals
            return 0;
        }
Example #5
0
        public VGA(bool buffered = true)
        {
            byte[] g_320x200x256 =
            {
                /* MISC */
                0x63,
                /* SEQ */
                0x03, 0x01, 0x0F, 0x00, 0x0E,
                /* CRTC */
                0x5F, 0x4F, 0x50, 0x82, 0x54, 0x80, 0xBF, 0x1F,
                0x00, 0x41, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                0x9C, 0x0E, 0x8F, 0x28, 0x40, 0x96, 0xB9, 0xA3,
                0xFF,
                /* GC */
                0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x05, 0x0F,
                0xFF,
                /* AC */
                0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
                0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
                0x41, 0x00, 0x0F, 0x00, 0x00
            };

            fixed(byte *fixedPTR = g_320x200x256)
            {
                WriteRegs(fixedPTR);
            }

            if (!buffered)
            {
                writeOnVGAMem = true;
                return;
            }



            ScrW = 320;
            ScrH = 200;

            PixelStride = (byte)((BitsPerPixel | 7) >> 3);
            Pitch       = ScrW * PixelStride;
            BackBuffer  = (byte *)(ScrH * Pitch);
            bufsize     = ScrH * Pitch;

            Mode = new Sys.Graphics.Mode(ScrW, ScrH, Sys.Graphics.ColorDepth.ColorDepth8);

            colorsInBuffer = new Color[(ScrH * ScrW)];
        }
Example #6
0
        /// <summary>
        /// Use this to setup the screen, this will disable the console.
        /// </summary>
        /// <param name="Mode">The desired Mode resolution</param>
        private void SetMode(Mode mode)
        {
            if (!IsModeValid(mode))
                throw new ArgumentOutOfRangeException($"Mode {mode} is not supported by VBE Driver");

            ushort xres = (ushort)Mode.Rows;
            ushort yres = (ushort)Mode.Columns;
            ushort bpp = (ushort)Mode.ColorDepth;

            //set the screen
           VBEDriver.VBESet(xres, yres, bpp);
        }
Example #7
0
 protected Canvas(Mode mode)
 {
     this.mode = mode;
     aviableModes = getAviableModes();
     defaultGraphicMode = getDefaultGraphicMode();
 }
Example #8
0
        protected bool IsModeValid(Mode mode)
        {
            /* This would have been the more "modern" version but LINQ is not working */
            //return aviableModes.Exists(element => element == mode);

            foreach(var elem in aviableModes)
            {
                if (elem == mode)
                    return true;
            }

            /* 'mode' was not in the 'aviableModes' List ==> 'mode' in NOT Valid */
            return false;
        }