Advertisement
Guest User

Legacy Display Driver

a guest
Jan 18th, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.98 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using Cosmos.HAL;
  5. using Sys = Cosmos.System;
  6.  
  7. namespace NewTech.Display
  8. {
  9.     public class LegacyDisplayDriver
  10.     {
  11.         protected VGAScreen screen;
  12.         private int width, height;
  13.  
  14.         public LegacyDisplayDriver()
  15.         {
  16.             screen = new VGAScreen();
  17.         }
  18.  
  19.         public void init()
  20.         {
  21.             Console.WriteLine("LegacyDisplayDriver Booted lets go to graphic mode!");
  22.             Console.Clear();
  23.             screen.SetGraphicsMode(VGAScreen.ScreenSize.Size320x200, VGAScreen.ColorDepth.BitDepth8);
  24.             width = screen.PixelWidth;
  25.             height = screen.PixelHeight;
  26.             screen.Clear(0);
  27.             clear(0);
  28.         }
  29.  
  30.         public virtual void setPixel(int x, int y, int c)
  31.         {
  32.             if (screen.GetPixel320x200x8((uint)x, (uint)y) != (uint)c)
  33.                 setPixelRaw(x, y, c);
  34.         }
  35.  
  36.         public virtual byte getPixel(int x, int y)
  37.         {
  38.             return (byte)screen.GetPixel320x200x8((uint)x, (uint)y);
  39.         }
  40.  
  41.         public virtual void clear()
  42.         {
  43.             clear(0);
  44.         }
  45.  
  46.         public virtual void clear(int c)
  47.         {
  48.             DrawFilledRectangle(0, 0, width, width, c);
  49.         }
  50.  
  51.         public virtual void step() { }
  52.  
  53.         public int getWidth()
  54.         {
  55.             return width;
  56.         }
  57.  
  58.         public int getHeight()
  59.         {
  60.             return height;
  61.         }
  62.  
  63.         public void setPixelRaw(int x, int y, int c)
  64.         {
  65.             screen.SetPixel320x200x8((uint)x, (uint)y, (uint)c);
  66.         }
  67.  
  68.         public void DrawFilledRectangle(uint x0, uint y0, int Width, int Height, int color)
  69.         {
  70.             for(uint i = 0; i < Width; i++)
  71.             {
  72.                 for(uint h = 0; h < Height; h++)
  73.                 {
  74.                     setPixel((int)(x0 + i), (int)(y0 + h), color);
  75.                 }
  76.             }
  77.         }
  78.     }
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement