using System; using HALVGAScreen = Cosmos.HAL.VGAScreen; namespace Cosmos.System.Graphics { /// /// VGAScreen class. Used to control screen. /// public class VGAScreen { /// /// Text size. /// public enum TextSize { /// /// 40x25 /// Size40x25, /// /// 40x50 /// Size40x50, /// /// 80x25 /// Size80x25, /// /// 80x50 /// Size80x50, /// /// 90x30 /// Size90x30, /// /// 90x60 /// Size90x60 }; /// /// Screen size (resolution). /// public enum ScreenSize { /// /// 640x480 graphics mode - 2 and 4 bit color depth available /// Size640x480, /// /// 720x480 graphics mode - 16 bit color depth available /// Size720x480, /// /// 320x200 graphics mode - 4 and 8 bit color depth available /// Size320x200 }; /// /// Color depth. bits per pixel. /// public enum ColorDepth { /// /// 2 bits per pixel. /// BitDepth2, /// /// 4 bits per pixel. /// BitDepth4, /// /// 8 bits per pixel. /// BitDepth8, /// /// 16 bits per pixel. /// BitDepth16 }; private static HALVGAScreen mScreen = new HALVGAScreen(); /// /// Set graphics mode. /// /// Screen size. /// Color depth. /// Thrown if screen size / color depth not supported. public static void SetGraphicsMode(ScreenSize screenSize, ColorDepth colorDepth) { HALVGAScreen.ScreenSize ScrSize = HALVGAScreen.ScreenSize.Size320x200; HALVGAScreen.ColorDepth ClrDepth = HALVGAScreen.ColorDepth.BitDepth8; switch (screenSize) { case ScreenSize.Size320x200: ScrSize = HALVGAScreen.ScreenSize.Size320x200; break; case ScreenSize.Size640x480: ScrSize = HALVGAScreen.ScreenSize.Size640x480; break; case ScreenSize.Size720x480: ScrSize = HALVGAScreen.ScreenSize.Size720x480; break; default: throw new Exception("This situation is not implemented!"); } switch (colorDepth) { case ColorDepth.BitDepth2: ClrDepth = HALVGAScreen.ColorDepth.BitDepth2; break; case ColorDepth.BitDepth4: ClrDepth = HALVGAScreen.ColorDepth.BitDepth4; break; case ColorDepth.BitDepth8: ClrDepth = HALVGAScreen.ColorDepth.BitDepth8; break; case ColorDepth.BitDepth16: ClrDepth = HALVGAScreen.ColorDepth.BitDepth16; break; default: throw new Exception("This situation is not implemented!"); } mScreen.SetGraphicsMode(ScrSize, ClrDepth); } /// /// Set pixel color. /// /// x coordinat. /// y coordinat. /// Color to set. public static void SetPixel(uint X, uint Y, uint Color) { mScreen.SetPixel(X, Y, Color); } /// /// Clear screen, and paint in in color. /// /// Color to set the screen to. public static void Clear(int Color) { mScreen.Clear(Color); } /// /// Test mode 320x200x8 /// /// /// /// Thrown when color depth not supported for the size. /// Unknown screen size. /// Memory error. /// /// public static void TestMode320x200x8() { mScreen.TestMode320x200x8(); } /// /// Set palette. /// /// Index. /// Palette. /// The array contains more than Int32.MaxValue elements. public static void SetPalette(int Index, byte[] Palette) { mScreen.SetPalette(Index, Palette); } /// /// Set palette entry. /// /// Index. /// Red. /// Green. /// Blue. public static void SetPaletteEntry(int Index, byte R, byte G, byte B) { mScreen.SetPaletteEntry(Index, R, G, B); } /// /// Get pixel. /// /// x coordinat. /// y coordinat. /// uint value. public static uint GetPixel(uint X, uint Y) { return mScreen.GetPixel(X, Y); } /// /// Set text mode. /// /// Text size. /// Thrown when text size invalid / unable to determine memory segment. public static void SetTextMode(TextSize Size) { switch (Size) { case TextSize.Size40x25: mScreen.SetTextMode(HALVGAScreen.TextSize.Size40x25); break; case TextSize.Size40x50: mScreen.SetTextMode(HALVGAScreen.TextSize.Size40x50); break; case TextSize.Size80x25: mScreen.SetTextMode(HALVGAScreen.TextSize.Size80x25); break; case TextSize.Size80x50: mScreen.SetTextMode(HALVGAScreen.TextSize.Size80x50); break; case TextSize.Size90x30: mScreen.SetTextMode(HALVGAScreen.TextSize.Size90x30); break; case TextSize.Size90x60: mScreen.SetTextMode(HALVGAScreen.TextSize.Size90x60); break; default: throw new Exception("This situation is not implemented!"); } } /// /// Get pixel height. /// public static int PixelHeight = mScreen.PixelHeight; /// /// Get pixel width. /// public static int PixelWidth = mScreen.PixelWidth; /// /// Get colors. /// public static int Colors = mScreen.Colors; } }