From 838b2866be7e712ba26f06212ac417e54daf5afa Mon Sep 17 00:00:00 2001 From: Quajak Date: Mon, 5 Oct 2020 14:21:43 +0200 Subject: [PATCH] Fixed VGACanvas Mode Property supports changing mode while being active Disable Method actually reverts to text mode --- source/Cosmos.System2/Graphics/VGACanvas.cs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/source/Cosmos.System2/Graphics/VGACanvas.cs b/source/Cosmos.System2/Graphics/VGACanvas.cs index aac7203fde..8608bc38b7 100644 --- a/source/Cosmos.System2/Graphics/VGACanvas.cs +++ b/source/Cosmos.System2/Graphics/VGACanvas.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Text; using Cosmos.HAL; @@ -16,6 +16,7 @@ public class VGACanvas : Canvas /// Private boolean whether VGA graphics mode is enabled or not /// bool _Enabled; + private Mode _Mode; /// /// The HAL VGA driver @@ -50,7 +51,14 @@ public VGACanvas() : base() /// /// Gets or sets the VGA graphics mode /// - public override Mode Mode { get; set; } + public override Mode Mode + { + get => _Mode; set + { + _VGADriver.SetGraphicsMode(ModeToScreenSize(_Mode), (VGADriver.ColorDepth)(int)_Mode.ColorDepth); + _Mode = value; + } + } /// /// Clears the screen of all pixels @@ -59,7 +67,7 @@ public VGACanvas() : base() 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); } /// @@ -69,6 +77,7 @@ public override void Disable() { if (Enabled) { + VGAScreen.SetTextMode(TextSize.Size80x25); Enabled = false; } } @@ -411,7 +420,7 @@ private ScreenSize ModeToScreenSize(Mode aMode) public override void Display() { - + } } }