From 2f2cd626e33053b5259e0829d261be5883f1a009 Mon Sep 17 00:00:00 2001 From: valentinbreiz Date: Thu, 24 Dec 2020 03:21:02 +0100 Subject: [PATCH 1/4] Implement non linear framebuffer detection for VBE multiboot Real hardware doesn't often use a linear framebuffer. It can causes graphics issues. --- source/Cosmos.HAL2/Drivers/Video/VBEDriver.cs | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/source/Cosmos.HAL2/Drivers/Video/VBEDriver.cs b/source/Cosmos.HAL2/Drivers/Video/VBEDriver.cs index b7174ef8a..0839b17a9 100644 --- a/source/Cosmos.HAL2/Drivers/Video/VBEDriver.cs +++ b/source/Cosmos.HAL2/Drivers/Video/VBEDriver.cs @@ -81,8 +81,21 @@ namespace Cosmos.HAL.Drivers if (VBE.IsAvailable()) //VBE VESA Enabled Mulitboot Parsing { Global.mDebugger.SendInternal($"Creating VBE VESA driver with Mode {xres}*{yres}@{bpp}"); - IO.LinearFrameBuffer = new MemoryBlock(VBE.getLfbOffset(), (uint)xres * yres * (uint)(bpp / 8)); - lastbuffer = new ManagedMemoryBlock((uint)xres * yres * (uint)(bpp / 8)); + + var ModeInfo = VBE.getModeInfo(); + + if ((ModeInfo.pitch / 4) == ModeInfo.width) //linear framebuffer detection + { + IO.LinearFrameBuffer = new MemoryBlock(VBE.getLfbOffset(), (uint)xres * yres * (uint)(bpp / 8)); + lastbuffer = new ManagedMemoryBlock((uint)xres * yres * (uint)(bpp / 8)); + } + else + { + uint OffScreenSize = (ModeInfo.pitch / (uint)(bpp / 8)) - ModeInfo.width; + + IO.LinearFrameBuffer = new MemoryBlock(VBE.getLfbOffset(), (uint)(xres * yres * (uint)(bpp / 8)) + (OffScreenSize * yres * (uint)(bpp / 8))); + lastbuffer = new ManagedMemoryBlock((uint)(xres * yres * (uint)(bpp / 8)) + (OffScreenSize * yres * (uint)(bpp / 8))); + } } else if (ISAModeAvailable()) //Bochs Graphics Adaptor ISA Mode { From 32ee02c6d4fb7ecc167218044f614c0f146eb64b Mon Sep 17 00:00:00 2001 From: valentinbreiz Date: Thu, 24 Dec 2020 03:22:25 +0100 Subject: [PATCH 2/4] bpp is not always 4! --- source/Cosmos.HAL2/Drivers/Video/VBEDriver.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/Cosmos.HAL2/Drivers/Video/VBEDriver.cs b/source/Cosmos.HAL2/Drivers/Video/VBEDriver.cs index 0839b17a9..f50d52a2f 100644 --- a/source/Cosmos.HAL2/Drivers/Video/VBEDriver.cs +++ b/source/Cosmos.HAL2/Drivers/Video/VBEDriver.cs @@ -84,7 +84,7 @@ namespace Cosmos.HAL.Drivers var ModeInfo = VBE.getModeInfo(); - if ((ModeInfo.pitch / 4) == ModeInfo.width) //linear framebuffer detection + if ((ModeInfo.pitch / (bpp / 8)) == ModeInfo.width) //linear framebuffer detection { IO.LinearFrameBuffer = new MemoryBlock(VBE.getLfbOffset(), (uint)xres * yres * (uint)(bpp / 8)); lastbuffer = new ManagedMemoryBlock((uint)xres * yres * (uint)(bpp / 8)); From 053902b3eae67e67e1d53bd6404665597e369cd2 Mon Sep 17 00:00:00 2001 From: KM198912 <55886806+KM198912@users.noreply.github.com> Date: Wed, 13 Jan 2021 09:01:27 +0100 Subject: [PATCH 3/4] Update RestoreSources.props myget currently has a issue where it cant find roslyn-tools, so disable it for the time being so the devkit builds --- build/Targets/RestoreSources.props | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/build/Targets/RestoreSources.props b/build/Targets/RestoreSources.props index 0043818b3..30d427524 100644 --- a/build/Targets/RestoreSources.props +++ b/build/Targets/RestoreSources.props @@ -8,8 +8,7 @@ https://www.myget.org/F/cosmos/api/v3/index.json; https://ci.appveyor.com/nuget/cosmos-common; https://ci.appveyor.com/nuget/il2cpu; - https://ci.appveyor.com/nuget/xsharp; - https://dotnet.myget.org/F/roslyn-tools/api/v3/index.json + https://ci.appveyor.com/nuget/xsharp $(RestoreSources);$(DefaultPackageOutputPath) From ee9e7fe15eea12ce2f297c14101fd300b5e3bee2 Mon Sep 17 00:00:00 2001 From: Quajak Date: Wed, 13 Jan 2021 10:36:22 +0100 Subject: [PATCH 4/4] Revert "Implement non linear framebuffer detection for VBE multiboot" --- source/Cosmos.HAL2/Drivers/Video/VBEDriver.cs | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/source/Cosmos.HAL2/Drivers/Video/VBEDriver.cs b/source/Cosmos.HAL2/Drivers/Video/VBEDriver.cs index f50d52a2f..b7174ef8a 100644 --- a/source/Cosmos.HAL2/Drivers/Video/VBEDriver.cs +++ b/source/Cosmos.HAL2/Drivers/Video/VBEDriver.cs @@ -81,21 +81,8 @@ namespace Cosmos.HAL.Drivers if (VBE.IsAvailable()) //VBE VESA Enabled Mulitboot Parsing { Global.mDebugger.SendInternal($"Creating VBE VESA driver with Mode {xres}*{yres}@{bpp}"); - - var ModeInfo = VBE.getModeInfo(); - - if ((ModeInfo.pitch / (bpp / 8)) == ModeInfo.width) //linear framebuffer detection - { - IO.LinearFrameBuffer = new MemoryBlock(VBE.getLfbOffset(), (uint)xres * yres * (uint)(bpp / 8)); - lastbuffer = new ManagedMemoryBlock((uint)xres * yres * (uint)(bpp / 8)); - } - else - { - uint OffScreenSize = (ModeInfo.pitch / (uint)(bpp / 8)) - ModeInfo.width; - - IO.LinearFrameBuffer = new MemoryBlock(VBE.getLfbOffset(), (uint)(xres * yres * (uint)(bpp / 8)) + (OffScreenSize * yres * (uint)(bpp / 8))); - lastbuffer = new ManagedMemoryBlock((uint)(xres * yres * (uint)(bpp / 8)) + (OffScreenSize * yres * (uint)(bpp / 8))); - } + IO.LinearFrameBuffer = new MemoryBlock(VBE.getLfbOffset(), (uint)xres * yres * (uint)(bpp / 8)); + lastbuffer = new ManagedMemoryBlock((uint)xres * yres * (uint)(bpp / 8)); } else if (ISAModeAvailable()) //Bochs Graphics Adaptor ISA Mode {