diff --git a/.gitignore b/.gitignore index a2b71da68..b149e8e43 100644 --- a/.gitignore +++ b/.gitignore @@ -53,3 +53,4 @@ source/_ReSharper.Caches/ Docs/~$RingsGen2.xlsx source/Kernel-X86/90-Application/GuessKernelGen3.csproj Docs/~$RingsGen3.xlsx +*.map diff --git a/Demos/CosmosGraphicSubsystem/CosmosGraphicSubsystem.csproj b/Demos/CosmosGraphicSubsystem/CosmosGraphicSubsystem.csproj index d57ca8c04..2fb265c37 100644 --- a/Demos/CosmosGraphicSubsystem/CosmosGraphicSubsystem.csproj +++ b/Demos/CosmosGraphicSubsystem/CosmosGraphicSubsystem.csproj @@ -3,6 +3,7 @@ netstandard2.0 CosmosGraphicSubsystemBoot + CosmosGraphicSubsystemBoot @@ -41,7 +42,7 @@ Use Bochs emulator to deploy and debug. ISO Bochs - True + False Source False Serial: COM1 diff --git a/Demos/CosmosGraphicSubsystem/Kernel.cs b/Demos/CosmosGraphicSubsystem/Kernel.cs index c23251ab6..5efa754c9 100644 --- a/Demos/CosmosGraphicSubsystem/Kernel.cs +++ b/Demos/CosmosGraphicSubsystem/Kernel.cs @@ -14,13 +14,13 @@ namespace Cosmos_Graphic_Subsytem protected override void BeforeRun() { Console.WriteLine("Cosmos booted successfully. Let's go in Graphic Mode"); - Console.WriteLine("Specifying custom graphics mode as 800x600@32"); - // Specify custom graphics mode (800x600 @ 16) - Mode start = new Mode(800, 600, ColorDepth.ColorDepth32); + Console.WriteLine("Using default graphics mode"); + //Mode start = new Mode(800, 600, ColorDepth.ColorDepth32); Console.WriteLine("Here we go!"); - // Create new instance of FullScreenCanvas, specifying graphics mode - canvas = FullScreenCanvas.GetFullScreenCanvas(start); + Console.ReadKey(true); + // Create new instance of FullScreenCanvas, using default graphics mode + canvas = FullScreenCanvas.GetFullScreenCanvas(); // canvas = GetFullScreenCanvas(start); /* Clear the Screen with the color 'Blue' */ diff --git a/Kernel.sln b/Kernel.sln index 7fec20689..7f506d1f8 100644 --- a/Kernel.sln +++ b/Kernel.sln @@ -94,10 +94,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Spruce", "..\XSharp\source\ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "XSharp.x86", "..\XSharp\source\XSharp.x86\XSharp.x86.csproj", "{7370A62F-12DA-4181-BE3B-009D0926CA7E}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "PCITest", "PCITest", "{58AEE3B6-80BF-4ED3-AD1E-17359139E3FC}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PCITest", "Demos\PCITest\PCITest.csproj", "{D3639BE5-49A0-4163-9174-1D0CC6823E06}" -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -339,14 +335,6 @@ Global {7370A62F-12DA-4181-BE3B-009D0926CA7E}.Release|Any CPU.Build.0 = Release|Any CPU {7370A62F-12DA-4181-BE3B-009D0926CA7E}.Release|x86.ActiveCfg = Release|Any CPU {7370A62F-12DA-4181-BE3B-009D0926CA7E}.Release|x86.Build.0 = Release|Any CPU - {D3639BE5-49A0-4163-9174-1D0CC6823E06}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {D3639BE5-49A0-4163-9174-1D0CC6823E06}.Debug|Any CPU.Build.0 = Debug|Any CPU - {D3639BE5-49A0-4163-9174-1D0CC6823E06}.Debug|x86.ActiveCfg = Debug|Any CPU - {D3639BE5-49A0-4163-9174-1D0CC6823E06}.Debug|x86.Build.0 = Debug|Any CPU - {D3639BE5-49A0-4163-9174-1D0CC6823E06}.Release|Any CPU.ActiveCfg = Release|Any CPU - {D3639BE5-49A0-4163-9174-1D0CC6823E06}.Release|Any CPU.Build.0 = Release|Any CPU - {D3639BE5-49A0-4163-9174-1D0CC6823E06}.Release|x86.ActiveCfg = Release|Any CPU - {D3639BE5-49A0-4163-9174-1D0CC6823E06}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -392,8 +380,6 @@ Global {E35E0DBF-555F-4D38-8F28-ACDFA9DC97BD} = {5FF9BF2A-5162-4F12-82B6-1693AD776636} {0812DD0A-4CEE-4376-B78A-02EBCBAA14C2} = {3CD3D9A5-9BC5-4FEB-8D63-4D535C0ABB78} {7370A62F-12DA-4181-BE3B-009D0926CA7E} = {3CD3D9A5-9BC5-4FEB-8D63-4D535C0ABB78} - {58AEE3B6-80BF-4ED3-AD1E-17359139E3FC} = {B56A6119-1B8F-44E4-9446-291E52F47D4C} - {D3639BE5-49A0-4163-9174-1D0CC6823E06} = {58AEE3B6-80BF-4ED3-AD1E-17359139E3FC} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {1A1E8F1D-82B3-471F-9B59-0350DEA9203D} diff --git a/source/Cosmos.System2/Graphics/Canvas.cs b/source/Cosmos.System2/Graphics/Canvas.cs index 4163d4bec..004027853 100644 --- a/source/Cosmos.System2/Graphics/Canvas.cs +++ b/source/Cosmos.System2/Graphics/Canvas.cs @@ -249,13 +249,13 @@ namespace Cosmos.System.Graphics } } + // public virtual void DrawCircle(Pen pen, Point point, int radius) { DrawCircle(pen, point.X, point.Y, radius); } - //http://members.chello.at/~easyfilter/bresenham.html public virtual void DrawEllipse(Pen pen, int x_center, int y_center, int x_radius, int y_radius) { diff --git a/source/Cosmos.System2/Graphics/FullScreenCanvas.cs b/source/Cosmos.System2/Graphics/FullScreenCanvas.cs index 18ec3928b..c0558d655 100644 --- a/source/Cosmos.System2/Graphics/FullScreenCanvas.cs +++ b/source/Cosmos.System2/Graphics/FullScreenCanvas.cs @@ -15,7 +15,7 @@ namespace Cosmos.System.Graphics private static PCIDevice SVGAIIDevice = PCI.GetDevice(VendorID.VMWare, DeviceID.SVGAIIAdapter); - public static bool DoesSVGAIIExist() + public static bool SVGAIIExist() { if (SVGAIIDevice != null) { @@ -31,38 +31,44 @@ namespace Cosmos.System.Graphics } } - //public static bool SVGAIIExists = SVGAIIDevice != null; - private static VideoDriver videoDevice; - // Created null - NullReferenceException when calling GetFullScreenCanvas() with 0 overloads private static Canvas MyVideoDriver = null; + private static Canvas GetVideoDriver() + { + if (SVGAIIExist()) + { + return new SVGAIIScreen(); + } + else + { + return new VBEScreen(); + } + } + private static Canvas GetVideoDriver(Mode mode) + { + if (SVGAIIExist()) + { + return new SVGAIIScreen(mode); + } + else + { + return new VBEScreen(mode); + } + } + public static Canvas GetFullScreenCanvas() { - // If MyVideoDriver is null (hasn't checked if VMWare SVGA exists), - // Do necessary check and set to default gfx mode if (MyVideoDriver == null) { - return GetFullScreenCanvas(MyVideoDriver.DefaultGraphicMode); + return MyVideoDriver = GetVideoDriver(); } - // If it's not null, simply change graphics mode */ else { MyVideoDriver.Mode = MyVideoDriver.DefaultGraphicMode; return MyVideoDriver; } - // Old check left for reference - /* - if (videoDevice == VideoDriver.VMWareSVGAIIDriver) - { - - } - else - { - - } - */ } public static Canvas GetFullScreenCanvas(Mode mode) { @@ -71,32 +77,75 @@ namespace Cosmos.System.Graphics // Do necessary check and set gfx mode as specified (mode) if (MyVideoDriver == null) { - if (DoesSVGAIIExist()) - { - // Set videoDevice to SVGA, initialize MyVideoDriver as an SVGA display using specified mode - // MyVideoDriver.Mode = mode; isn't exactly needed, just done in case it doesn't set. - // returns MyVideoDriver as the Canvas - videoDevice = VideoDriver.VMWareSVGAIIDriver; - MyVideoDriver = new SVGAIIScreen(mode); - MyVideoDriver.Mode = mode; - return MyVideoDriver; - } - else - { - // Does the same as above, this time using VESA BIOS Extensions (supported by loads of graphics cards) - videoDevice = VideoDriver.VBEDriver; - MyVideoDriver = new VBEScreen(mode); - MyVideoDriver.Mode = mode; - return MyVideoDriver; - } + return MyVideoDriver = GetVideoDriver(mode); } else { - // If MyVideoDriver has been initialized before (Graphics mode has previously been set) - // Change the graphics mode to the mode specified MyVideoDriver.Mode = mode; return MyVideoDriver; } } } } +/* + if (DoesSVGAIIExist()) + { + // Set videoDevice to SVGA, initialize MyVideoDriver as an SVGA display using specified mode + // MyVideoDriver.Mode = mode; isn't exactly needed, just done in case it doesn't set. + // returns MyVideoDriver as the Canvas + videoDevice = VideoDriver.VMWareSVGAIIDriver; + MyVideoDriver = new SVGAIIScreen(mode); + MyVideoDriver.Mode = mode; + return MyVideoDriver; + } + else + { + // Does the same as above, this time using VESA BIOS Extensions (supported by loads of graphics cards) + videoDevice = VideoDriver.VBEDriver; + MyVideoDriver = new VBEScreen(mode); + MyVideoDriver.Mode = mode; + return MyVideoDriver; + } +} +else +{ + // If MyVideoDriver has been initialized before (Graphics mode has previously been set) + // Change the graphics mode to the mode specified + MyVideoDriver.Mode = mode; + return MyVideoDriver; +} +} +/* + +// If MyVideoDriver is null (hasn't checked if VMWare SVGA exists), +// Do necessary check and set to default gfx mode +if (MyVideoDriver == null) +{ +if (DoesSVGAIIExist()) +{ + // Set videoDevice to SVGA, initialize MyVideoDriver as an SVGA display using specified mode + // MyVideoDriver.Mode = mode; isn't exactly needed, just done in case it doesn't set. + // returns MyVideoDriver as the Canvas + videoDevice = VideoDriver.VMWareSVGAIIDriver; + MyVideoDriver = new SVGAIIScreen(SVGAIIScreen.defaultGraphicsMode); + MyVideoDriver.Mode = SVGAIIScreen.defaultGraphicsMode; + return MyVideoDriver; +} +else +{ + // Does the same as above, this time using VESA BIOS Extensions (supported by loads of graphics cards) + videoDevice = VideoDriver.VBEDriver; + MyVideoDriver = new VBEScreen(VBEScreen.defaultGraphicsMode); + MyVideoDriver.Mode = VBEScreen.defaultGraphicsMode; + return MyVideoDriver; +} +} +// If it's not null, simply change graphics mode +else +{ +MyVideoDriver.Mode = MyVideoDriver.DefaultGraphicMode; +return MyVideoDriver; +} +*/ + + diff --git a/source/Cosmos.System2/Graphics/SVGAIIScreen.cs b/source/Cosmos.System2/Graphics/SVGAIIScreen.cs index fe9393890..c8f5b5d92 100644 --- a/source/Cosmos.System2/Graphics/SVGAIIScreen.cs +++ b/source/Cosmos.System2/Graphics/SVGAIIScreen.cs @@ -140,7 +140,7 @@ namespace Cosmos.System.Graphics new Mode(3840, 2400, ColorDepth.ColorDepth32), // WQUXGA }; } - + public static readonly Mode defaultGraphicsMode = new Mode(1024, 768, ColorDepth.ColorDepth16); protected override Mode getDefaultGraphicMode() => new Mode(1024, 768, ColorDepth.ColorDepth16); private void SetGraphicsMode(Mode aMode) diff --git a/source/Cosmos.System2/Graphics/VBEScreen.cs b/source/Cosmos.System2/Graphics/VBEScreen.cs index 2e129f981..ec3510806 100644 --- a/source/Cosmos.System2/Graphics/VBEScreen.cs +++ b/source/Cosmos.System2/Graphics/VBEScreen.cs @@ -75,7 +75,7 @@ namespace Cosmos.System.Graphics } protected override Mode getDefaultGraphicMode() => new Mode(1024, 768, ColorDepth.ColorDepth32); - + public static readonly Mode defaultGraphicsMode = new Mode(1024, 768, ColorDepth.ColorDepth32); /// /// Use this to setup the screen, this will disable the console. ///