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 c3e773797..2fb265c37 100644
--- a/Demos/CosmosGraphicSubsystem/CosmosGraphicSubsystem.csproj
+++ b/Demos/CosmosGraphicSubsystem/CosmosGraphicSubsystem.csproj
@@ -2,10 +2,12 @@
netstandard2.0
+ CosmosGraphicSubsystemBoot
+ CosmosGraphicSubsystemBoot
- elf
+ Bin
True
Source
User
@@ -17,9 +19,9 @@
MethodFooters
False
Serial: COM1
- Bochs
- Bochs
- Use Bochs emulator to deploy and debug.
+ VMware
+ VMware
+ Use VMware Player or Workstation to deploy and debug.
192.168.0.8
True
MethodFooters
@@ -40,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 84cfe3082..5efa754c9 100644
--- a/Demos/CosmosGraphicSubsystem/Kernel.cs
+++ b/Demos/CosmosGraphicSubsystem/Kernel.cs
@@ -14,9 +14,14 @@ namespace Cosmos_Graphic_Subsytem
protected override void BeforeRun()
{
Console.WriteLine("Cosmos booted successfully. Let's go in Graphic Mode");
+ Console.WriteLine("Using default graphics mode");
+ //Mode start = new Mode(800, 600, ColorDepth.ColorDepth32);
+
+ Console.WriteLine("Here we go!");
+ Console.ReadKey(true);
+ // Create new instance of FullScreenCanvas, using default graphics mode
+ canvas = FullScreenCanvas.GetFullScreenCanvas(); // canvas = GetFullScreenCanvas(start);
- /* Get on istance of the Canvas that is all the Screen */
- canvas = FullScreenCanvas.GetFullScreenCanvas();
/* Clear the Screen with the color 'Blue' */
canvas.Clear(Color.Blue);
diff --git a/Kernel.sln b/Kernel.sln
index f6adc82d7..7f506d1f8 100644
--- a/Kernel.sln
+++ b/Kernel.sln
@@ -1,6 +1,6 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
-VisualStudioVersion = 15.0.27130.2010
+VisualStudioVersion = 15.0.27130.2036
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Kernel G2", "Kernel G2", "{9A923E6F-FF63-4F02-A4EA-C2D44F9323FD}"
EndProject
diff --git a/Tests/Cosmos.Compiler.Tests.Bcl/Kernel.cs b/Tests/Cosmos.Compiler.Tests.Bcl/Kernel.cs
index 8bb114a44..11509f711 100644
--- a/Tests/Cosmos.Compiler.Tests.Bcl/Kernel.cs
+++ b/Tests/Cosmos.Compiler.Tests.Bcl/Kernel.cs
@@ -45,6 +45,7 @@ namespace Cosmos.Compiler.Tests.Bcl
SingleTest.Execute();
DoubleTest.Execute();
MathTest.Execute();
+ ConvertTests.Execute();
//mDebugger.Send("Thread test start of 500 ms");
//ThreadTest.Execute();
diff --git a/Tests/Cosmos.Compiler.Tests.Bcl/System/ArrayTests.cs b/Tests/Cosmos.Compiler.Tests.Bcl/System/ArrayTests.cs
index 1bbefd499..2335e1001 100644
--- a/Tests/Cosmos.Compiler.Tests.Bcl/System/ArrayTests.cs
+++ b/Tests/Cosmos.Compiler.Tests.Bcl/System/ArrayTests.cs
@@ -11,13 +11,32 @@ namespace Cosmos.Compiler.Tests.Bcl.System
{
public static void Execute()
{
- byte[] xResult = { 1, 2, 3, 4, 5, 6, 7, 8 };
- byte[] xExpectedResult = { 1, 2, 3, 4, 5, 6, 7, 1 };
- byte[] xSource = { 1 };
+ byte[] xByteResult = { 1, 2, 3, 4, 5, 6, 7, 8 };
+ byte[] xByteExpectedResult = { 1, 2, 3, 4, 5, 6, 7, 1 };
+ byte[] xByteSource = { 1 };
- Array.Copy(xSource, 0, xResult, 7, 1);
+ Array.Copy(xByteSource, 0, xByteResult, 7, 1);
- Assert.IsTrue((xResult[7] == xExpectedResult[7]), "Array.Copy doesn't work: xResult[7] = " + (uint)xResult[7] + " != " + (uint)xExpectedResult[7]);
+ Assert.IsTrue((xByteResult[7] == xByteExpectedResult[7]), "Array.Copy doesn't work: xResult[7] = " + (uint)xByteResult[7] + " != " + (uint)xByteExpectedResult[7]);
+
+ // Single[] Test
+ float[] xSingleResult = { 1.25f, 2.50f, 3.51f, 4.31f, 9.28f, 18.56f };
+ float[] xSingleExpectedResult = { 1.25f, 2.598f, 5.39f, 4.31f, 9.28f, 18.56f };
+ float[] xSingleSource = { 0.49382f, 1.59034f, 2.598f, 5.39f, 7.48392f, 4.2839f };
+
+ xSingleResult[1] = xSingleSource[2];
+ xSingleResult[2] = xSingleSource[3];
+
+ Assert.IsTrue(((xSingleResult[1] + xSingleResult[2]) == (xSingleExpectedResult[1] + xSingleExpectedResult[2])), "Assinging values to single array elements doesn't work: xResult[1] = " + (uint)xSingleResult[1] + " != " + (uint)xSingleExpectedResult[1] + " and xResult[2] = " + (uint)xSingleResult[2] + " != " + (uint)xSingleExpectedResult[2]);
+
+ // Double[] Test
+ double[] xDoubleResult = { 0.384, 1.5823, 2.5894, 2.9328539, 3.9201, 4.295 };
+ double[] xDoubleExpectedResult = { 0.384, 1.5823, 2.5894, 95.32815, 3.9201, 4.295 };
+ double[] xDoubleSource = { 95.32815 };
+
+ xDoubleResult[3] = xDoubleSource[0];
+
+ Assert.IsTrue(xDoubleResult[3] == xDoubleExpectedResult[3], "Assinging values to double array elements doesn't work: xResult[1] = " + (uint)xDoubleResult[3] + " != " + (uint)xDoubleExpectedResult[3]);
}
}
}
diff --git a/Tests/Cosmos.Compiler.Tests.Bcl/System/ConvertTests.cs b/Tests/Cosmos.Compiler.Tests.Bcl/System/ConvertTests.cs
new file mode 100644
index 000000000..656c30f79
--- /dev/null
+++ b/Tests/Cosmos.Compiler.Tests.Bcl/System/ConvertTests.cs
@@ -0,0 +1,29 @@
+using System;
+
+using Cosmos.TestRunner;
+
+namespace Cosmos.Compiler.Tests.Bcl.System
+{
+ internal static class ConvertTests
+ {
+ public static void Execute()
+ {
+ var number = 5;
+ var numberToString = Convert.ToString(number);
+
+ Assert.IsTrue(numberToString == "5", $"Convert.ToString(Int32) doesn't work. Result: {numberToString}");
+
+ var numberToByte = Convert.ToByte(number);
+
+ Assert.IsTrue(numberToByte == 5, $"Convert.ToByte(Int32) doesn't work. Result: {numberToByte}");
+
+ var byteToSingle = Convert.ToSingle(numberToByte);
+
+ Assert.IsTrue(EqualityHelper.SinglesAreEqual(byteToSingle, 5.0f), $"Convert.ToSingle(Byte) doesn't work. Result: {byteToSingle}");
+
+ var numberToBase64 = Convert.ToBase64String(BitConverter.GetBytes(number));
+
+ Assert.IsTrue(numberToBase64 == "BQAAAA==", $"Convert.ToBase64String(byte[]) doesn't work. Result: {numberToBase64}");
+ }
+ }
+}
diff --git a/appveyor.yml b/appveyor.yml
index 6c74fd4b2..2fa476d8e 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -11,61 +11,41 @@ init:
git clone https://github.com/CosmosOS/IL2CPU.git c:\IL2CPU --depth 1
build_script:
-- cmd: >-
+- cmd: |
rem %APPVEYOR_BUILD_FOLDER%
Build\Tools\nuget restore "Builder.sln"
-
Build\Tools\nuget restore "..\XSharp\XSharp.sln"
-
Build\Tools\nuget restore "..\IL2CPU\IL2CPU.sln"
-
Build\Tools\nuget restore "Build.sln"
-
Build\Tools\nuget restore "Test.sln"
- msbuild "Builder.sln" /maxcpucount /verbosity:normal /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" /p:Platform="Any CPU" /p:Configuration=Debug /p:DeployExtension=false
+ msbuild "Builder.sln" /maxcpucount /verbosity:normal /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" /p:Platform="Any CPU" /p:Configuration=Debug
msbuild "Build.sln" /maxcpucount /verbosity:normal /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" /p:Platform="Any CPU" /p:Configuration=Debug /p:OutputPath="%APPVEYOR_BUILD_FOLDER%\Build\VSIP" /p:DeployExtension=false
-
msbuild "Test.sln" /maxcpucount /verbosity:normal /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" /p:Platform="Any CPU" /p:Configuration=Debug
- dotnet publish source\Cosmos.Build.MSBuild -r win7-x86 -o "c:\CosmosRun\Build\VSIP\"
-
dotnet publish ..\IL2CPU\source\IL2CPU -r win7-x86 -o "c:\CosmosRun\Build\IL2CPU\"
xcopy /Y "Build\VSIP\Cosmos.Debug.Kernel.*" "c:\CosmosRun\Kernel\"
-
xcopy /Y "Build\VSIP\Cosmos.Core.*" "c:\CosmosRun\Kernel\"
-
xcopy /Y "Build\VSIP\Cosmos.HAL.*" "c:\CosmosRun\Kernel\"
-
xcopy /Y "Build\VSIP\Cosmos.System.*" "c:\CosmosRun\Kernel\"
-
xcopy /Y "Build\VSIP\Cosmos.Common.*" "c:\CosmosRun\Kernel\"
-
xcopy /Y "Build\VSIP\Cosmos.Debug.GDB.exe" "c:\CosmosRun\Build\VSIP\"
-
xcopy /Y "Build\syslinux\*.*" "c:\CosmosRun\Build\ISO\"
-
xcopy /Y /S "Build\VMware\*" "c:\CosmosRun\Build\VMware\"
-
xcopy /Y /S "Build\Tools" "c:\CosmosRun\Build\Tools\"
-
xcopy /Y "source\Cosmos.Core.DebugStub\*.xs" "c:\CosmosRun\XSharp\DebugStub\"
-
xcopy /Y /S "Resources\Bochs\*.*" "%ProgramFiles(x86)%\Bochs-2.6.8\"
-
reg add HKLM\SOFTWARE\WOW6432Node\Cosmos /v UserKit /d c:\CosmosRun\
-
reg add HKCR\BochsConfigFile\shell\Run\command /ve /d "\"C:\Program Files (x86)\Bochs-2.6.8\Bochs.exe\" -q -f \"%1\""
-
#test: off
# assemblies:
# - Cosmos.Core.Memory.Test.dll
diff --git a/source/Cosmos.Build.Tasks/ExtractMapFromElfFile.cs b/source/Cosmos.Build.Tasks/ExtractMapFromElfFile.cs
index c90c64e28..aaa2195aa 100644
--- a/source/Cosmos.Build.Tasks/ExtractMapFromElfFile.cs
+++ b/source/Cosmos.Build.Tasks/ExtractMapFromElfFile.cs
@@ -20,6 +20,9 @@ namespace Cosmos.Build.Tasks
protected override string ToolName => "objdump.exe";
+ protected override MessageImportance StandardErrorLoggingImportance => MessageImportance.High;
+ protected override MessageImportance StandardOutputLoggingImportance => MessageImportance.High;
+
protected override bool ValidateParameters()
{
if (!File.Exists(InputFile))
diff --git a/source/Cosmos.Build.Tasks/Ld.cs b/source/Cosmos.Build.Tasks/Ld.cs
index 8287c22ac..6a5632bc3 100644
--- a/source/Cosmos.Build.Tasks/Ld.cs
+++ b/source/Cosmos.Build.Tasks/Ld.cs
@@ -28,7 +28,9 @@ namespace Cosmos.Build.Tasks
#endregion
protected override string ToolName => "ld.exe";
+
protected override MessageImportance StandardErrorLoggingImportance => MessageImportance.High;
+ protected override MessageImportance StandardOutputLoggingImportance => MessageImportance.High;
private static bool IsValidAddress(string aAddress)
{
diff --git a/source/Cosmos.Build.Tasks/MakeIso.cs b/source/Cosmos.Build.Tasks/MakeIso.cs
index 3b0b5eaa5..5b565c120 100644
--- a/source/Cosmos.Build.Tasks/MakeIso.cs
+++ b/source/Cosmos.Build.Tasks/MakeIso.cs
@@ -14,7 +14,9 @@ namespace Cosmos.Build.Tasks
public string OutputFile { get; set; }
protected override string ToolName => "mkisofs.exe";
+
protected override MessageImportance StandardErrorLoggingImportance => MessageImportance.High;
+ protected override MessageImportance StandardOutputLoggingImportance => MessageImportance.High;
protected override bool ValidateParameters()
{
diff --git a/source/Cosmos.Build.Tasks/Nasm.cs b/source/Cosmos.Build.Tasks/Nasm.cs
index e35776a2d..5421ee40e 100644
--- a/source/Cosmos.Build.Tasks/Nasm.cs
+++ b/source/Cosmos.Build.Tasks/Nasm.cs
@@ -34,6 +34,9 @@ namespace Cosmos.Build.Tasks
protected override string ToolName => "nasm.exe";
+ protected override MessageImportance StandardErrorLoggingImportance => MessageImportance.High;
+ protected override MessageImportance StandardOutputLoggingImportance => MessageImportance.High;
+
protected override bool ValidateParameters()
{
if (String.IsNullOrWhiteSpace(InputFile))
diff --git a/source/Cosmos.Build.Tasks/TheRingMaster.cs b/source/Cosmos.Build.Tasks/TheRingMaster.cs
index dac363f11..a575a31ca 100644
--- a/source/Cosmos.Build.Tasks/TheRingMaster.cs
+++ b/source/Cosmos.Build.Tasks/TheRingMaster.cs
@@ -12,6 +12,9 @@ namespace Cosmos.Build.Tasks
protected override string ToolName => "TheRingMaster.exe";
+ protected override MessageImportance StandardErrorLoggingImportance => MessageImportance.High;
+ protected override MessageImportance StandardOutputLoggingImportance => MessageImportance.High;
+
protected override bool ValidateParameters()
{
if (!File.Exists(KernelAssemblyPath))
diff --git a/source/Cosmos.HAL2/PciDevice.cs b/source/Cosmos.HAL2/PciDevice.cs
index 6419beceb..7d6d372ad 100644
--- a/source/Cosmos.HAL2/PciDevice.cs
+++ b/source/Cosmos.HAL2/PciDevice.cs
@@ -107,8 +107,14 @@ namespace Cosmos.HAL
HeaderType = (PCIHeaderType)ReadRegister8((byte)Config.HeaderType);
BIST = (PCIBist)ReadRegister8((byte)Config.BIST);
InterruptPIN = (PCIInterruptPIN)ReadRegister8((byte)Config.InterruptPIN);
-
- DeviceExists = (uint)VendorID != 0xFFFF && (uint)DeviceID != 0xFFFF;
+ if ((uint)VendorID == 0xFF && (uint)DeviceID == 0xFFFF)
+ {
+ DeviceExists = false;
+ }
+ else
+ {
+ DeviceExists = true;
+ }
if (HeaderType == PCIHeaderType.Normal)
{
BaseAddressBar = new PCIBaseAddressBar[6];
diff --git a/source/Cosmos.System2/FileSystem/CosmosVFS.cs b/source/Cosmos.System2/FileSystem/CosmosVFS.cs
index 724f69c4e..494035375 100644
--- a/source/Cosmos.System2/FileSystem/CosmosVFS.cs
+++ b/source/Cosmos.System2/FileSystem/CosmosVFS.cs
@@ -364,7 +364,6 @@ namespace Cosmos.System.FileSystem
if (BlockDevice.Devices[i] is Partition)
{
mPartitions.Add((Partition)BlockDevice.Devices[i]);
- break;
}
}
diff --git a/source/Cosmos.System2/Graphics/Canvas.cs b/source/Cosmos.System2/Graphics/Canvas.cs
index 2019fd1ab..a009ceccc 100644
--- a/source/Cosmos.System2/Graphics/Canvas.cs
+++ b/source/Cosmos.System2/Graphics/Canvas.cs
@@ -1,4 +1,4 @@
-//#define COSMOSDEBUG
+//#define COSMOSDEBUG
using System;
using System.Drawing;
using System.Collections.Generic;
@@ -92,6 +92,8 @@ namespace Cosmos.System.Graphics
public abstract void DrawPoint(Pen pen, int x, int y);
public abstract void DrawPoint(Pen pen, float x, float y);
+
+ public abstract Color GetPointColor(int x, int y);
public virtual void DrawArray(Color[] colors, Point point, int width, int height)
{
@@ -246,11 +248,11 @@ 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 dd7618be9..c0558d655 100644
--- a/source/Cosmos.System2/Graphics/FullScreenCanvas.cs
+++ b/source/Cosmos.System2/Graphics/FullScreenCanvas.cs
@@ -1,38 +1,151 @@
-//#define COSMOSDEBUG
+//#define COSMOSDEBUG
using Cosmos.System.Graphics;
+using Cosmos.HAL;
namespace Cosmos.System.Graphics
{
public static class FullScreenCanvas
{
- /*
- * For now we hardcode that the VideoDriver is always VBE when we have more that a driver supported we need to find
- * what to use when we do the 'new' (inside GetFullScreenCanvas() static methods). MyVideoDriver should be
- * of type Canvas
- */
- static private Canvas MyVideoDriver = null;
-
- public static Canvas GetFullScreenCanvas(Mode mode)
+ private enum VideoDriver
{
- Global.mDebugger.SendInternal("GetFullScreenCanvas() with mode " + mode);
+ VMWareSVGAIIDriver,
+ //VGADriver,
+ VBEDriver
+ }
- if (MyVideoDriver == null)
- return MyVideoDriver = new VBEScreen(mode);
+ private static PCIDevice SVGAIIDevice = PCI.GetDevice(VendorID.VMWare, DeviceID.SVGAIIAdapter);
- /* We have already got a VideoDriver istance simple change its mode */
- MyVideoDriver.Mode = mode;
- return MyVideoDriver;
+ public static bool SVGAIIExist()
+ {
+ if (SVGAIIDevice != null)
+ {
+ if (SVGAIIDevice.DeviceExists == true)
+ {
+ return true;
+ }
+ return false;
+ }
+ else
+ {
+ return false;
+ }
+
+ }
+ private static VideoDriver videoDevice;
+
+ 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()
{
- Global.mDebugger.SendInternal($"GetFullScreenCanvas() with default mode");
if (MyVideoDriver == null)
- return new VBEScreen();
-
- /* We have already got a VideoDriver istance simple reset its mode to DefaultGraphicMode */
- MyVideoDriver.Mode = MyVideoDriver.DefaultGraphicMode;
- return MyVideoDriver;
+ {
+ return MyVideoDriver = GetVideoDriver();
+ }
+ else
+ {
+ MyVideoDriver.Mode = MyVideoDriver.DefaultGraphicMode;
+ return MyVideoDriver;
+ }
+ }
+ public static Canvas GetFullScreenCanvas(Mode mode)
+ {
+ Global.mDebugger.SendInternal($"GetFullScreenCanvas() with mode" + mode);
+ // If MyVideoDriver is null (hasn't checked if VMWare SVGA exists),
+ // Do necessary check and set gfx mode as specified (mode)
+ if (MyVideoDriver == null)
+ {
+ return MyVideoDriver = GetVideoDriver(mode);
+ }
+ else
+ {
+ 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
new file mode 100644
index 000000000..c8f5b5d92
--- /dev/null
+++ b/source/Cosmos.System2/Graphics/SVGAIIScreen.cs
@@ -0,0 +1,195 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using Cosmos.HAL.Drivers.PCI.Video;
+
+namespace Cosmos.System.Graphics
+{
+ public class SVGAIIScreen : Canvas
+ {
+ public VMWareSVGAII xSVGAIIDriver;
+ internal Debug.Kernel.Debugger mSVGAIIDebugger = new Debug.Kernel.Debugger("System", "SVGAIIScreen");
+
+ public SVGAIIScreen() : base()
+ {
+ mSVGAIIDebugger.SendInternal($"Creting new SVGAIIScreen with default mode {defaultGraphicMode}");
+
+ xSVGAIIDriver = new VMWareSVGAII();
+ xSVGAIIDriver.SetMode((uint)defaultGraphicMode.Columns, (uint)defaultGraphicMode.Rows, (uint)defaultGraphicMode.ColorDepth);
+ }
+
+ public SVGAIIScreen(Mode aMode) : base(aMode)
+ {
+ ThrowIfModeIsNotValid(aMode);
+
+ xSVGAIIDriver = new VMWareSVGAII();
+ xSVGAIIDriver.SetMode((uint)aMode.Columns, (uint)aMode.Rows, (uint)aMode.ColorDepth);
+ }
+
+ public override Mode Mode
+ {
+ get => mode;
+ set
+ {
+ mode = value;
+ SetGraphicsMode(mode);
+ }
+ }
+
+ public override void DrawPoint(Pen pen, int x, int y)
+ {
+ Color xColor = pen.Color;
+
+ mSVGAIIDebugger.SendInternal($"Drawing point to x:{x}, y:{y} with {xColor.Name} Color");
+ xSVGAIIDriver.SetPixel((uint)x, (uint)y, (uint)xColor.ToArgb());
+ mSVGAIIDebugger.SendInternal($"Done drawing point");
+ xSVGAIIDriver.Update(0, 0, (uint)mode.Columns, (uint)mode.Rows);
+ }
+
+ public override void DrawArray(Color[] colors, int x, int y, int width, int height)
+ {
+ throw new NotImplementedException();
+ //xSVGAIIDriver.
+ }
+ public override void DrawPoint(Pen pen, float x, float y)
+ {
+ //xSVGAIIDriver.
+ throw new NotImplementedException();
+ }
+
+ public override void DrawFilledRectangle(Pen pen, int x_start, int y_start, int width, int height)
+ {
+ xSVGAIIDriver.Fill((uint)x_start, (uint)y_start, (uint)width, (uint)height, (uint)pen.Color.ToArgb());
+ }
+
+ public override List getAvailableModes()
+ {
+ return new List
+ {
+ /* 16-bit Depth Resolutions*/
+
+ /* SD Resolutions */
+ new Mode(320, 200, ColorDepth.ColorDepth16),
+ new Mode(320, 240, ColorDepth.ColorDepth16),
+ new Mode(640, 480, ColorDepth.ColorDepth16),
+ new Mode(720, 480, ColorDepth.ColorDepth16),
+ new Mode(800, 600, ColorDepth.ColorDepth16),
+ new Mode(1152, 768, ColorDepth.ColorDepth16),
+
+ /* Old HD-Ready Resolutions */
+ new Mode(1280, 720, ColorDepth.ColorDepth16),
+ new Mode(1280, 768, ColorDepth.ColorDepth16),
+ new Mode(1280, 800, ColorDepth.ColorDepth16), // WXGA
+ new Mode(1280, 1024, ColorDepth.ColorDepth16), // SXGA
+
+ /* Better HD-Ready Resolutions */
+ new Mode(1360, 768, ColorDepth.ColorDepth16),
+ new Mode(1366, 768, ColorDepth.ColorDepth16), // Original Laptop Resolution
+ new Mode(1440, 900, ColorDepth.ColorDepth16), // WXGA+
+ new Mode(1400, 1050, ColorDepth.ColorDepth16), // SXGA+
+ new Mode(1600, 1200, ColorDepth.ColorDepth16), // UXGA
+ new Mode(1680, 1050, ColorDepth.ColorDepth16), // WXGA++
+
+ /* HDTV Resolutions */
+ new Mode(1920, 1080, ColorDepth.ColorDepth16),
+ new Mode(1920, 1200, ColorDepth.ColorDepth16), // WUXGA
+
+ /* 2K Resolutions */
+ new Mode(2048, 1536, ColorDepth.ColorDepth16), // QXGA
+ new Mode(2560, 1080, ColorDepth.ColorDepth16), // UW-UXGA
+ new Mode(2560, 1600, ColorDepth.ColorDepth16), // WQXGA
+ new Mode(2560, 2048, ColorDepth.ColorDepth16), // QXGA+
+ new Mode(3200, 2048, ColorDepth.ColorDepth16), // WQXGA+
+ new Mode(3200, 2400, ColorDepth.ColorDepth16), // QUXGA
+ new Mode(3840, 2400, ColorDepth.ColorDepth16), // WQUXGA
+
+ /* 32-bit Depth Resolutions*/
+ /* SD Resolutions */
+ new Mode(320, 200, ColorDepth.ColorDepth32),
+ new Mode(320, 240, ColorDepth.ColorDepth32),
+ new Mode(640, 480, ColorDepth.ColorDepth32),
+ new Mode(720, 480, ColorDepth.ColorDepth32),
+ new Mode(800, 600, ColorDepth.ColorDepth32),
+ new Mode(1152, 768, ColorDepth.ColorDepth32),
+
+ /* Old HD-Ready Resolutions */
+ new Mode(1280, 720, ColorDepth.ColorDepth32),
+ new Mode(1280, 768, ColorDepth.ColorDepth32),
+ new Mode(1280, 800, ColorDepth.ColorDepth32), // WXGA
+ new Mode(1280, 1024, ColorDepth.ColorDepth32), // SXGA
+
+ /* Better HD-Ready Resolutions */
+ new Mode(1360, 768, ColorDepth.ColorDepth32),
+ new Mode(1366, 768, ColorDepth.ColorDepth32), // Original Laptop Resolution
+ new Mode(1440, 900, ColorDepth.ColorDepth32), // WXGA+
+ new Mode(1400, 1050, ColorDepth.ColorDepth32), // SXGA+
+ new Mode(1600, 1200, ColorDepth.ColorDepth32), // UXGA
+ new Mode(1680, 1050, ColorDepth.ColorDepth32), // WXGA++
+
+ /* HDTV Resolutions */
+ new Mode(1920, 1080, ColorDepth.ColorDepth32),
+ new Mode(1920, 1200, ColorDepth.ColorDepth32), // WUXGA
+
+ /* 2K Resolutions */
+ new Mode(2048, 1536, ColorDepth.ColorDepth32), // QXGA
+ new Mode(2560, 1080, ColorDepth.ColorDepth32), // UW-UXGA
+ new Mode(2560, 1600, ColorDepth.ColorDepth32), // WQXGA
+ new Mode(2560, 2048, ColorDepth.ColorDepth32), // QXGA+
+ new Mode(3200, 2048, ColorDepth.ColorDepth32), // WQXGA+
+ new Mode(3200, 2400, ColorDepth.ColorDepth32), // QUXGA
+ 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)
+ {
+ ThrowIfModeIsNotValid(aMode);
+
+ var xWidth = (uint)aMode.Columns;
+ var xHeight = (uint)aMode.Rows;
+ var xColorDepth = (uint)aMode.ColorDepth;
+
+ xSVGAIIDriver.SetMode(xWidth, xHeight, xColorDepth);
+ }
+
+ public override void Clear(Color color)
+ {
+ xSVGAIIDriver.Fill(0, 0, (uint)mode.Columns, (uint)mode.Rows, (uint)color.ToArgb());
+ }
+
+ public Color GetPixel(int aX, int aY)
+ {
+ var xColorARGB = xSVGAIIDriver.GetPixel((uint)aX, (uint)aX);
+ var xColor = Color.FromArgb((int)xColorARGB);
+ return xColor;
+ }
+
+ public void SetCursor(bool aVisible, int aX, int aY)
+ {
+ xSVGAIIDriver.SetCursor(aVisible, (uint)aX, (uint)aY);
+ }
+
+ public void CreateCursor()
+ {
+ xSVGAIIDriver.DefineCursor();
+ }
+
+ public void CopyPixel(int aX, int aY, int aNewX, int aNewY, int aWidth = 1, int aHeight = 1)
+ {
+ xSVGAIIDriver.Copy((uint)aX, (uint)aY, (uint)aNewX, (uint)aNewY, (uint)aWidth, (uint)aHeight);
+ }
+
+ public void MovePixel(int aX, int aY, int aNewX, int aNewY)
+ {
+ xSVGAIIDriver.Copy((uint)aX, (uint)aY, (uint)aNewX, (uint)aNewY, 1, 1);
+ xSVGAIIDriver.SetPixel((uint)aX, (uint)aY, 0);
+ }
+
+ public override Color GetPointColor(int x, int y)
+ {
+ return Color.FromArgb((int)xSVGAIIDriver.GetPixel((uint)x, (uint)y));
+ }
+ }
+}
diff --git a/source/Cosmos.System2/Graphics/VBEScreen.cs b/source/Cosmos.System2/Graphics/VBEScreen.cs
index d19544215..ec3510806 100644
--- a/source/Cosmos.System2/Graphics/VBEScreen.cs
+++ b/source/Cosmos.System2/Graphics/VBEScreen.cs
@@ -1,13 +1,13 @@
-//#define COSMOSDEBUG
+//#define COSMOSDEBUG
using Cosmos.HAL.Drivers;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
-using Cosmos.System.Graphics;
+using Cosmos.Common.Extensions;
-namespace Cosmos.System
+namespace Cosmos.System.Graphics
{
public class VBEScreen : Canvas
{
@@ -26,7 +26,7 @@ namespace Cosmos.System
public VBEScreen(Mode mode) : base(mode)
{
- //Global.mDebugger.SendInternal($"Creating new VBEScreen() with mode {mode}");
+ Global.mDebugger.SendInternal($"Creating new VBEScreen() with mode {mode.Columns}x{mode.Rows}x{(uint)mode.ColorDepth}");
ThrowIfModeIsNotValid(mode);
@@ -75,7 +75,7 @@ namespace Cosmos.System
}
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.
///
@@ -128,9 +128,7 @@ namespace Cosmos.System
* For now we can Draw only if the ColorDepth is 32 bit, we will throw otherwise.
*
* How to support other ColorDepth? The offset calculation should be the same (and so could be done out of the switch)
- * adding support ColorDepth.ColorDepth24 is easier as you need can use the version of SetVRAM() that take a byte
- * and call it 3 time for the B, G and R component (the Color class has properties to do this!), the problem is
- * for ColorDepth.ColorDepth16 and ColorDepth.ColorDepth8 than need a conversion from color (an ARGB32 color) to the RGB16 and RGB8
+ * ColorDepth.ColorDepth16 and ColorDepth.ColorDepth8 need a conversion from color (an ARGB32 color) to the RGB16 and RGB8
* how to do this conversion faster maybe using pre-computed tables? What happens if the color cannot be converted? We will throw?
*/
switch (mode.ColorDepth)
@@ -148,7 +146,18 @@ namespace Cosmos.System
Global.mDebugger.SendInternal("Point drawn");
break;
+ case ColorDepth.ColorDepth24:
+ Global.mDebugger.SendInternal("Computing offset...");
+ pitch = (uint)mode.Columns * ColorDepthInBytes;
+ stride = ColorDepthInBytes;
+ //offset = ((uint)x * pitch) + ((uint)y * stride);
+ offset = ((uint)x * stride) + ((uint)y * pitch);
+ Global.mDebugger.SendInternal($"Drawing Point of color {color} at offset {offset}");
+ VBEDriver.SetVRAM(offset, (((uint)color.R * 1000 + color.G) * 1000 + color.B));
+
+ Global.mDebugger.SendInternal("Point drawn");
+ break;
default:
String errorMsg = "DrawPoint() with ColorDepth " + (int)Mode.ColorDepth + " not yet supported";
throw new NotImplementedException(errorMsg);
@@ -184,7 +193,22 @@ namespace Cosmos.System
#endregion
#region Reading
- // TODO add to Canvas GetPointColor()
+ public override Color GetPointColor(int x, int y)
+ {
+ uint pitch;
+ uint stride;
+ uint offset;
+ uint ColorDepthInBytes = (uint)mode.ColorDepth / 8;
+
+ Global.mDebugger.SendInternal("Computing offset...");
+ pitch = (uint)mode.Columns * ColorDepthInBytes;
+ stride = ColorDepthInBytes;
+ //offset = ((uint)x * pitch) + ((uint)y * stride);
+ offset = ((uint)x * stride) + ((uint)y * pitch);
+
+ Global.mDebugger.SendInternal($"Getting color from point at offset {offset}");
+ return Color.FromArgb(VBEDriver.GetVRAM(offset));
+ }
#endregion
diff --git a/source/Cosmos.System2/Graphics/VGAScreen.cs b/source/Cosmos.System2/Graphics/VGAScreen.cs
index 5fae7bd03..388d7378f 100644
--- a/source/Cosmos.System2/Graphics/VGAScreen.cs
+++ b/source/Cosmos.System2/Graphics/VGAScreen.cs
@@ -1,7 +1,7 @@
using System;
using HALVGAScreen = Cosmos.HAL.VGAScreen;
-namespace Cosmos.System
+namespace Cosmos.System.Graphics
{
public class VGAScreen
{
diff --git a/source/Archive/Old System Plugs/DecimalImpl.cs b/source/Cosmos.System2_Plugs/System/DecimalImpl.cs
similarity index 70%
rename from source/Archive/Old System Plugs/DecimalImpl.cs
rename to source/Cosmos.System2_Plugs/System/DecimalImpl.cs
index 434744b46..9b452bed6 100644
--- a/source/Archive/Old System Plugs/DecimalImpl.cs
+++ b/source/Cosmos.System2_Plugs/System/DecimalImpl.cs
@@ -1,12 +1,8 @@
using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using Cosmos.IL2CPU.Plugs;
+using IL2CPU.API.Attribs;
-namespace Cosmos.System.Plugs.System
+namespace Cosmos.System_Plugs.System
{
[Plug(Target = typeof(decimal))]
public static class DecimalImpl
diff --git a/source/Cosmos.System2_Plugs/System/Int32Impl.cs b/source/Cosmos.System2_Plugs/System/Int32Impl.cs
index 76d855515..be131cba9 100644
--- a/source/Cosmos.System2_Plugs/System/Int32Impl.cs
+++ b/source/Cosmos.System2_Plugs/System/Int32Impl.cs
@@ -1,7 +1,5 @@
using System;
using Cosmos.Common;
-using Cosmos.Debug.Kernel;
-using IL2CPU.API;
using IL2CPU.API.Attribs;
namespace Cosmos.System_Plugs.System
@@ -14,6 +12,8 @@ namespace Cosmos.System_Plugs.System
return StringHelper.GetNumberString(aThis);
}
+ public static string ToString(ref int aThis, IFormatProvider aFormatProvider) => ToString(ref aThis);
+
public static Int32 Parse(string s)
{
const string digits = "0123456789";