diff --git a/source/Cosmos.Core/Multiboot.cs b/source/Cosmos.Core/Multiboot.cs index bb61cbf04..97de17c68 100644 --- a/source/Cosmos.Core/Multiboot.cs +++ b/source/Cosmos.Core/Multiboot.cs @@ -64,6 +64,25 @@ namespace Cosmos.Core public unsafe static class VBE { + static uint VBEINFO_PRESENT = (1 << 11); + + public static bool IsAvailable() + { + if ((Bootstrap.header->Flags & VBEINFO_PRESENT) == 0) + { + return false; + } + else + { + return true; + } + } + + public static ModeInfo getModeInfo() + { + return *Bootstrap.modeinfo; + } + [StructLayout(LayoutKind.Explicit, Size = 36)] public struct ControllerInfo { diff --git a/source/Cosmos.System2/Graphics/FullScreenCanvas.cs b/source/Cosmos.System2/Graphics/FullScreenCanvas.cs index 4beffad0c..2395c13d6 100644 --- a/source/Cosmos.System2/Graphics/FullScreenCanvas.cs +++ b/source/Cosmos.System2/Graphics/FullScreenCanvas.cs @@ -66,7 +66,7 @@ namespace Cosmos.System.Graphics { return new SVGAIICanvas(); } - else if (BGAExists() || PCI.GetDevice((VendorID)0x80EE, (DeviceID)0xBEEF) != null) + else if (BGAExists() || PCI.GetDevice((VendorID)0x80EE, (DeviceID)0xBEEF) != null || Core.VBE.IsAvailable()) { return new VBECanvas(); } @@ -88,7 +88,7 @@ namespace Cosmos.System.Graphics { return new SVGAIICanvas(mode); } - else if (BGAExists() || PCI.GetDevice((VendorID)0x80EE, (DeviceID)0xBEEF) != null) + else if (BGAExists() || PCI.GetDevice((VendorID)0x80EE, (DeviceID)0xBEEF) != null || Core.VBE.IsAvailable()) { return new VBECanvas(mode); } diff --git a/source/Cosmos.System2/Graphics/VBECanvas.cs b/source/Cosmos.System2/Graphics/VBECanvas.cs index a38d5a735..4bc6a5a33 100644 --- a/source/Cosmos.System2/Graphics/VBECanvas.cs +++ b/source/Cosmos.System2/Graphics/VBECanvas.cs @@ -44,6 +44,12 @@ namespace Cosmos.System.Graphics { Global.mDebugger.SendInternal($"Creating new VBEScreen() with mode {aMode.Columns}x{aMode.Rows}x{(uint)aMode.ColorDepth}"); + if (Core.VBE.IsAvailable()) + { + Core.VBE.ModeInfo ModeInfo = Core.VBE.getModeInfo(); + aMode = new Mode(ModeInfo.width, ModeInfo.height, (ColorDepth)ModeInfo.bpp); + } + ThrowIfModeIsNotValid(aMode); _VBEDriver = new VBEDriver((ushort)aMode.Columns, (ushort)aMode.Rows, (ushort)aMode.ColorDepth);