Exemplo n.º 1
0
        public SVGAIIScreen(Mode aMode) : base(aMode)
        {
            ThrowIfModeIsNotValid(aMode);

            xSVGAIIDriver = new VMWareSVGAII();
            xSVGAIIDriver.SetMode((uint)aMode.Columns, (uint)aMode.Rows, (uint)aMode.ColorDepth);
        }
Exemplo n.º 2
0
 public static void DrawRectangle(VMWareSVGAII driver, int x, int y, int w, int h, uint color)
 {
     DrawLine(driver, x, y, x, y + h, color);
     DrawLine(driver, x, y, x + w, y, color);
     DrawLine(driver, x, y + h, x + w, y + h, color);
     DrawLine(driver, x + w, y, x + w, y + h, color);
 }
Exemplo n.º 3
0
        public static int DrawChar(VMWareSVGAII driver, char c, int x, int y, uint color, Font f)
        {
            int index = 0;

            for (int i = 0; i < f.Char.Count; i++)
            {
                if (c == f.Char[i])
                {
                    index = i;
                    break;
                }
            }

            byte width = f.Width[index];

            int z = 0;

            for (int p = y; p < y + f.Height[index]; p++)
            {
                for (int i = x; i < x + width; i++)
                {
                    if (f.Data[index][z] == 1)
                    {
                        driver.SetPixel((uint)i, (uint)p, color);
                    }
                    z++;
                }
            }

            return(width);
        }
Exemplo n.º 4
0
        public SVGAIIScreen() : base()
        {
            mSVGAIIDebugger.SendInternal($"Creting new SVGAIIScreen with default mode {defaultGraphicMode}");

            xSVGAIIDriver = new VMWareSVGAII();
            xSVGAIIDriver.SetMode((uint)defaultGraphicMode.Columns, (uint)defaultGraphicMode.Rows, (uint)defaultGraphicMode.ColorDepth);
        }
Exemplo n.º 5
0
        // Draws the mouse
        public void Draw(VMWareSVGAII vgaDriver)
        {
            // If the mouse hasn't moved, don't reset.
            if (LastDrawX != X || LastDrawY != Y)
            {
                // Clears the old mouse draw location.
                DoDraw(LastDrawX, LastDrawY, vgaDriver, LastDrawPosCols, true);

                // Stores the existing colours where the mouse will now be.
                for (ushort x = 0; x < 20; x++)
                {
                    for (ushort y = 0; y < 20; y++)
                    {
                        LastDrawPosCols[y][x] = vgaDriver.GetPixel((ushort)(X + x), (ushort)(Y + y));
                    }
                }

                // Updates the last draw mouse position to the new position.
                LastDrawX = X;
                LastDrawY = Y;
            }

            // Draws the mouse in it's current position - ensure it's always on top.
            DoDraw(X, Y, vgaDriver, MouseCols, false);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Create new instance of the <see cref="SVGAIICanvas"/> class.
        /// </summary>
        /// <param name="aMode">A graphics mode.</param>
        /// <exception cref="ArgumentOutOfRangeException">Thrown if mode is not suppoted.</exception>
        public SVGAIICanvas(Mode aMode)
        {
            mSVGAIIDebugger.SendInternal($"Called ctor with mode {aMode}");
            ThrowIfModeIsNotValid(aMode);

            _xSVGADriver = new VMWareSVGAII();
            Mode         = aMode;
        }
Exemplo n.º 7
0
        public SVGAIIScreen(Mode aMode)
        {
            Debugger.SendInternal($"Called ctor with mode {aMode}");
            ThrowIfModeIsNotValid(aMode);

            xSVGAIIDriver = new VMWareSVGAII();
            Mode          = aMode;
        }
Exemplo n.º 8
0
        public static void DrawString(VMWareSVGAII driver, string pc, string c, int x, int y, uint color)
        {
            Font f = Fonts.Consolas14_cff;

            if (pc != c)
            {
                DoChar(driver, pc, x, y, 0x0, f); // Clears the previous string.
            }
            DoChar(driver, c, x, y, color, f);    // Draws the new string.
        }
Exemplo n.º 9
0
        public static void FillRectangle(VMWareSVGAII driver, int x, int y, int w, int h, uint color)
        {
            DrawLine(driver, x, y, x, y + h, color);
            DrawLine(driver, x, y, x + w, y, color);
            DrawLine(driver, x, y + h, x + w, y + h, color);
            DrawLine(driver, x + w, y, x + w, y + h, color);

            for (int i = 0; i < h; i++)
            {
                DrawLine(driver, x, y + i, x + w, y + i, color);
            }
        }
Exemplo n.º 10
0
 // Actually does the draw.
 private void DoDraw(int X, int Y, VMWareSVGAII vgaDriver, uint[][] mouseCol, bool allowBlack)
 {
     for (ushort x = 0; x < 20; x++)
     {
         for (ushort y = 0; y < 20; y++)
         {
             if (allowBlack || mouseCol[y][x] != 0)
             {
                 vgaDriver.SetPixel((ushort)(X + x), (ushort)(Y + y), mouseCol[y][x]);
             }
         }
     }
 }
Exemplo n.º 11
0
        // init
        public static bool Initialize()
        {
            // init device
            device = new VMWareSVGAII();
            device.SetMode(width, height, 32);

            // init buffer
            buffer = new uint[width * height];

            refresh = true;

            // success
            return(true);
        }
Exemplo n.º 12
0
        public static void InitGUI_1024x768()
        {
            VMWareSVGAII driver = new VMWareSVGAII();

            driver.SetMode(1024, 768);
            driver.Clear(0x16711935);
            MouseDriver mouseDriver = new MouseDriver(1024, 768);
            bool        OK          = true;

            while (OK)
            {
                mouseDriver.Draw(driver);
                driver.Update(0, 0, 1024, 768);
            }
        }
Exemplo n.º 13
0
 public static bool Initialize()
 {
     try
     {
         // init display
         Driver = new VMWareSVGAII();
         SetResolution(512, 384, true);
         return(true);
     }
     catch (Exception ex)
     {
         // error
         return(false);
     }
 }
Exemplo n.º 14
0
        public static void InitGUI_800x600()
        {
            VMWareSVGAII driver = new VMWareSVGAII();

            driver.SetMode(800, 600);
            driver.Clear(0x16711935);
            MouseDriver mouseDriver = new MouseDriver(800, 600);
            bool        OK          = true;

            while (OK)
            {
                mouseDriver.Draw(driver);
                driver.Update(0, 0, 800, 600);
            }
        }
Exemplo n.º 15
0
        public static void ASUSEeePC1001PX_OEM() // It's recommended that this code be deleted in outside projects as it is not wanted.
        {
            Console.WriteLine("Using ASUS EeePC 1001PX Resolution Mode");
            VMWareSVGAII driver = new VMWareSVGAII();

            driver.SetMode(1024, 600);
            driver.Clear(0x16711935);
            MouseDriver mouseDriver = new MouseDriver(1024, 600);
            bool        OK          = true;

            while (OK)
            {
                mouseDriver.Draw(driver);
                driver.Update(0, 0, 1024, 600);
            }
        }
Exemplo n.º 16
0
        public static void Init()
        {
            // Initializes the GUI
            ColorConsole.WriteLine(ConsoleColor.White, "=> Loading driver...");
            driver = new VMWareSVGAII();
            driver.SetMode(Width, Height);
            driver.Clear(0x0);

            deltaT = RTC.Second;

            // And now the mouse
            ColorConsole.WriteLine(ConsoleColor.White, "=> Loading mouse...");
            m = new Mouse(Width, Height);

            DrawComponents(); // Draws a simple mouse, rectangle and handles events
        }
Exemplo n.º 17
0
        public void Draw(VMWareSVGAII vgaDriver)
        {
            if (LastDrawX != X || LastDrawY != Y)
            {
                DoDraw(LastDrawX, LastDrawY, vgaDriver, LastDrawPosCols, true);

                for (ushort x = 0; x < 20; x++)
                {
                    for (ushort y = 0; y < 20; y++)
                    {
                        LastDrawPosCols[y][x] = vgaDriver.GetPixel((ushort)(X + x), (ushort)(Y + y));
                    }
                }

                LastDrawX = X;
                LastDrawY = Y;
            }

            DoDraw(X, Y, vgaDriver, MouseCols, false);
        }
Exemplo n.º 18
0
        private static void DoChar(VMWareSVGAII driver, string c, int x, int y, uint color, Font f)
        {
            int totalwidth = 0;

            for (int i = 0; i < c.Length; i++)
            {
                var ch = c[i];
                if (ch == ' ')
                {
                    totalwidth += f.Width[0];
                }
                else if (ch == '\t')
                {
                    totalwidth += f.Width[0] * 4;
                }
                else
                {
                    totalwidth += DrawChar(driver, ch, x + totalwidth, y, color, f);
                }
            }
        }
Exemplo n.º 19
0
 public Graphics()
 {
     pallete[0]  = 0x000000; // Black
     pallete[1]  = 0x000080; // Darkblue
     pallete[2]  = 0x008000; // DarkGreen
     pallete[3]  = 0x008080; // DarkCyan
     pallete[4]  = 0x800000; // DarkRed
     pallete[5]  = 0x800080; // DarkMagenta
     pallete[6]  = 0x808000; // DarkYellow
     pallete[7]  = 0xC0C0C0; // Gray
     pallete[8]  = 0x808080; // DarkGray
     pallete[9]  = 0x5555FF; // Blue
     pallete[10] = 0x55FF55; // Green
     pallete[11] = 0x00FFFF; // Cyan
     pallete[12] = 0xFF5555; // Red
     pallete[13] = 0xFF00FF; // Magenta
     pallete[14] = 0xFFFF55; // Yellow
     pallete[15] = 0xFFFFFF; //White
     font        = Read_font();
     svga        = new VMWareSVGAII();
     svga.SetMode(800, 600);
     svga.Clear(0);
 }
Exemplo n.º 20
0
 private static void DrawButton(VMWareSVGAII driver, int x, int y, int widthAdd, uint col, string text)
 {
     DrawUtils.DrawRectangle(driver, x, y, y + widthAdd, x - 30, col);
     DrawUtils.DrawString(driver, string.Empty, text, x, y, col);
 }
Exemplo n.º 21
0
        public static void DrawLine(VMWareSVGAII driver, int x, int y, int x2, int y2, uint color)
        {
            int w = x2 - x;
            int h = y2 - y;
            int dx1 = 0, dy1 = 0, dx2 = 0, dy2 = 0;

            if (w < 0)
            {
                dx1 = -1;
            }
            else if (w > 0)
            {
                dx1 = 1;
            }
            if (h < 0)
            {
                dy1 = -1;
            }
            else if (h > 0)
            {
                dy1 = 1;
            }
            if (w < 0)
            {
                dx2 = -1;
            }
            else if (w > 0)
            {
                dx2 = 1;
            }
            int longest  = w;
            int shortest = h;

            if (!(longest > shortest))
            {
                longest  = h;
                shortest = w;
                if (h < 0)
                {
                    dy2 = -1;
                }
                else if (h > 0)
                {
                    dy2 = 1;
                }
                dx2 = 0;
            }
            int numerator = longest >> 1;

            for (int i = 0; i <= longest; i++)
            {
                driver.SetPixel((uint)x, (uint)y, color);
                numerator += shortest;
                if (!(numerator < longest))
                {
                    numerator -= longest;
                    x         += dx1;
                    y         += dy1;
                }
                else
                {
                    x += dx2;
                    y += dy2;
                }
            }
        }