Fixed VGACanvas

Mode Property supports changing mode while being active
Disable Method actually reverts to text mode
This commit is contained in:
Quajak 2020-10-05 14:21:43 +02:00 committed by GitHub
parent 50d400065a
commit 838b2866be
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Text;
using Cosmos.HAL;
@ -16,6 +16,7 @@ namespace Cosmos.System.Graphics
/// Private boolean whether VGA graphics mode is enabled or not
/// </summary>
bool _Enabled;
private Mode _Mode;
/// <summary>
/// The HAL VGA driver
@ -50,7 +51,14 @@ namespace Cosmos.System.Graphics
/// <summary>
/// Gets or sets the VGA graphics mode
/// </summary>
public override Mode Mode { get; set; }
public override Mode Mode
{
get => _Mode; set
{
_VGADriver.SetGraphicsMode(ModeToScreenSize(_Mode), (VGADriver.ColorDepth)(int)_Mode.ColorDepth);
_Mode = value;
}
}
/// <summary>
/// Clears the screen of all pixels
@ -59,7 +67,7 @@ namespace Cosmos.System.Graphics
public override void Clear(Color aColor)
{
var paletteIndex = _VGADriver.GetClosestColorInPalette(aColor);
_VGADriver.DrawFilledRectangle(0,0, _VGADriver.PixelWidth, _VGADriver.PixelHeight, paletteIndex);
_VGADriver.DrawFilledRectangle(0, 0, _VGADriver.PixelWidth, _VGADriver.PixelHeight, paletteIndex);
}
/// <summary>
@ -69,6 +77,7 @@ namespace Cosmos.System.Graphics
{
if (Enabled)
{
VGAScreen.SetTextMode(TextSize.Size80x25);
Enabled = false;
}
}
@ -411,7 +420,7 @@ namespace Cosmos.System.Graphics
public override void Display()
{
}
}
}