using System;
using Cosmos.HAL;
using static Cosmos.HAL.VGADriver;
namespace Cosmos.System.Graphics
{
///
/// VGAScreen class. Used to control VGA textmode.
///
public class VGAScreen
{
private static readonly VGADriver _Screen = new VGADriver();
///
/// Set graphics mode.
///
/// Screen size.
/// Color depth.
/// Thrown if screen size / color depth not supported.
public static void SetGraphicsMode(ScreenSize aScreenSize, ColorDepth aColorDepth)
{
var vgaColorDepth = aColorDepth switch
{
ColorDepth.ColorDepth4 => VGADriver.ColorDepth.BitDepth4,
ColorDepth.ColorDepth8 => VGADriver.ColorDepth.BitDepth8,
ColorDepth.ColorDepth16 => VGADriver.ColorDepth.BitDepth16,
ColorDepth.ColorDepth24 => throw new NotImplementedException(),
ColorDepth.ColorDepth32 => throw new NotImplementedException(),
_ => throw new NotImplementedException(),
};
_Screen.SetGraphicsMode(aScreenSize, vgaColorDepth);
}
///
/// Set text mode.
///
/// Text size.
public static void SetTextMode(TextSize aSize)
{
_Screen.SetTextMode(aSize);
}
///
/// Get Height
///
public static int PixelHeight = _Screen.PixelHeight;
///
/// Get Width
///
public static int PixelWidth = _Screen.PixelWidth;
///
/// Get Colors
///
public static int Colors = _Screen.Colors;
///
/// Set a textmode font.
///
/// Font file.
/// /// Font Height.
/// Thrown when font height > 32.
public static void SetFont(byte[] fontData, int fontHeight)
{
if(fontHeight > 32)
{
throw new ArgumentOutOfRangeException("fontHeight");
}
_Screen.WriteFont(fontData, (byte)fontHeight);
}
}
}