mirror of
https://github.com/danbulant/Cosmos
synced 2026-06-07 00:32:29 +00:00
Merge remote-tracking branch 'upstream/master'
This commit is contained in:
commit
37e6ee122f
22 changed files with 464 additions and 79 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -53,3 +53,4 @@ source/_ReSharper.Caches/
|
||||||
Docs/~$RingsGen2.xlsx
|
Docs/~$RingsGen2.xlsx
|
||||||
source/Kernel-X86/90-Application/GuessKernelGen3.csproj
|
source/Kernel-X86/90-Application/GuessKernelGen3.csproj
|
||||||
Docs/~$RingsGen3.xlsx
|
Docs/~$RingsGen3.xlsx
|
||||||
|
*.map
|
||||||
|
|
|
||||||
|
|
@ -2,10 +2,12 @@
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>netstandard2.0</TargetFramework>
|
<TargetFramework>netstandard2.0</TargetFramework>
|
||||||
|
<Bochs_Name>CosmosGraphicSubsystemBoot</Bochs_Name>
|
||||||
|
<VMware_Name>CosmosGraphicSubsystemBoot</VMware_Name>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<BinFormat>elf</BinFormat>
|
<BinFormat>Bin</BinFormat>
|
||||||
<DebugEnabled>True</DebugEnabled>
|
<DebugEnabled>True</DebugEnabled>
|
||||||
<DebugMode>Source</DebugMode>
|
<DebugMode>Source</DebugMode>
|
||||||
<TraceMode>User</TraceMode>
|
<TraceMode>User</TraceMode>
|
||||||
|
|
@ -17,9 +19,9 @@
|
||||||
<StackCorruptionDetectionLevel>MethodFooters</StackCorruptionDetectionLevel>
|
<StackCorruptionDetectionLevel>MethodFooters</StackCorruptionDetectionLevel>
|
||||||
<IgnoreDebugStubAttribute>False</IgnoreDebugStubAttribute>
|
<IgnoreDebugStubAttribute>False</IgnoreDebugStubAttribute>
|
||||||
<CosmosDebugPort>Serial: COM1</CosmosDebugPort>
|
<CosmosDebugPort>Serial: COM1</CosmosDebugPort>
|
||||||
<Launch>Bochs</Launch>
|
<Launch>VMware</Launch>
|
||||||
<Profile>Bochs</Profile>
|
<Profile>VMware</Profile>
|
||||||
<Description>Use Bochs emulator to deploy and debug.</Description>
|
<Description>Use VMware Player or Workstation to deploy and debug.</Description>
|
||||||
<PxeInterface>192.168.0.8</PxeInterface>
|
<PxeInterface>192.168.0.8</PxeInterface>
|
||||||
<VMware_StackCorruptionDetectionEnabled>True</VMware_StackCorruptionDetectionEnabled>
|
<VMware_StackCorruptionDetectionEnabled>True</VMware_StackCorruptionDetectionEnabled>
|
||||||
<VMware_StackCorruptionDetectionLevel>MethodFooters</VMware_StackCorruptionDetectionLevel>
|
<VMware_StackCorruptionDetectionLevel>MethodFooters</VMware_StackCorruptionDetectionLevel>
|
||||||
|
|
@ -40,7 +42,7 @@
|
||||||
<Bochs_Description>Use Bochs emulator to deploy and debug.</Bochs_Description>
|
<Bochs_Description>Use Bochs emulator to deploy and debug.</Bochs_Description>
|
||||||
<Bochs_Deployment>ISO</Bochs_Deployment>
|
<Bochs_Deployment>ISO</Bochs_Deployment>
|
||||||
<Bochs_Launch>Bochs</Bochs_Launch>
|
<Bochs_Launch>Bochs</Bochs_Launch>
|
||||||
<Bochs_DebugEnabled>True</Bochs_DebugEnabled>
|
<Bochs_DebugEnabled>False</Bochs_DebugEnabled>
|
||||||
<Bochs_DebugMode>Source</Bochs_DebugMode>
|
<Bochs_DebugMode>Source</Bochs_DebugMode>
|
||||||
<Bochs_IgnoreDebugStubAttribute>False</Bochs_IgnoreDebugStubAttribute>
|
<Bochs_IgnoreDebugStubAttribute>False</Bochs_IgnoreDebugStubAttribute>
|
||||||
<Bochs_CosmosDebugPort>Serial: COM1</Bochs_CosmosDebugPort>
|
<Bochs_CosmosDebugPort>Serial: COM1</Bochs_CosmosDebugPort>
|
||||||
|
|
|
||||||
|
|
@ -14,9 +14,14 @@ namespace Cosmos_Graphic_Subsytem
|
||||||
protected override void BeforeRun()
|
protected override void BeforeRun()
|
||||||
{
|
{
|
||||||
Console.WriteLine("Cosmos booted successfully. Let's go in Graphic Mode");
|
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' */
|
/* Clear the Screen with the color 'Blue' */
|
||||||
canvas.Clear(Color.Blue);
|
canvas.Clear(Color.Blue);
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
# Visual Studio 15
|
# Visual Studio 15
|
||||||
VisualStudioVersion = 15.0.27130.2010
|
VisualStudioVersion = 15.0.27130.2036
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Kernel G2", "Kernel G2", "{9A923E6F-FF63-4F02-A4EA-C2D44F9323FD}"
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Kernel G2", "Kernel G2", "{9A923E6F-FF63-4F02-A4EA-C2D44F9323FD}"
|
||||||
EndProject
|
EndProject
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,7 @@ namespace Cosmos.Compiler.Tests.Bcl
|
||||||
SingleTest.Execute();
|
SingleTest.Execute();
|
||||||
DoubleTest.Execute();
|
DoubleTest.Execute();
|
||||||
MathTest.Execute();
|
MathTest.Execute();
|
||||||
|
ConvertTests.Execute();
|
||||||
|
|
||||||
//mDebugger.Send("Thread test start of 500 ms");
|
//mDebugger.Send("Thread test start of 500 ms");
|
||||||
//ThreadTest.Execute();
|
//ThreadTest.Execute();
|
||||||
|
|
|
||||||
|
|
@ -11,13 +11,32 @@ namespace Cosmos.Compiler.Tests.Bcl.System
|
||||||
{
|
{
|
||||||
public static void Execute()
|
public static void Execute()
|
||||||
{
|
{
|
||||||
byte[] xResult = { 1, 2, 3, 4, 5, 6, 7, 8 };
|
byte[] xByteResult = { 1, 2, 3, 4, 5, 6, 7, 8 };
|
||||||
byte[] xExpectedResult = { 1, 2, 3, 4, 5, 6, 7, 1 };
|
byte[] xByteExpectedResult = { 1, 2, 3, 4, 5, 6, 7, 1 };
|
||||||
byte[] xSource = { 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]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
29
Tests/Cosmos.Compiler.Tests.Bcl/System/ConvertTests.cs
Normal file
29
Tests/Cosmos.Compiler.Tests.Bcl/System/ConvertTests.cs
Normal file
|
|
@ -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}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
24
appveyor.yml
24
appveyor.yml
|
|
@ -11,61 +11,41 @@ init:
|
||||||
git clone https://github.com/CosmosOS/IL2CPU.git c:\IL2CPU --depth 1
|
git clone https://github.com/CosmosOS/IL2CPU.git c:\IL2CPU --depth 1
|
||||||
|
|
||||||
build_script:
|
build_script:
|
||||||
- cmd: >-
|
- cmd: |
|
||||||
rem %APPVEYOR_BUILD_FOLDER%
|
rem %APPVEYOR_BUILD_FOLDER%
|
||||||
|
|
||||||
|
|
||||||
Build\Tools\nuget restore "Builder.sln"
|
Build\Tools\nuget restore "Builder.sln"
|
||||||
|
|
||||||
Build\Tools\nuget restore "..\XSharp\XSharp.sln"
|
Build\Tools\nuget restore "..\XSharp\XSharp.sln"
|
||||||
|
|
||||||
Build\Tools\nuget restore "..\IL2CPU\IL2CPU.sln"
|
Build\Tools\nuget restore "..\IL2CPU\IL2CPU.sln"
|
||||||
|
|
||||||
Build\Tools\nuget restore "Build.sln"
|
Build\Tools\nuget restore "Build.sln"
|
||||||
|
|
||||||
Build\Tools\nuget restore "Test.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 "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
|
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\"
|
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.Debug.Kernel.*" "c:\CosmosRun\Kernel\"
|
||||||
|
|
||||||
xcopy /Y "Build\VSIP\Cosmos.Core.*" "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.HAL.*" "c:\CosmosRun\Kernel\"
|
||||||
|
|
||||||
xcopy /Y "Build\VSIP\Cosmos.System.*" "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.Common.*" "c:\CosmosRun\Kernel\"
|
||||||
|
|
||||||
xcopy /Y "Build\VSIP\Cosmos.Debug.GDB.exe" "c:\CosmosRun\Build\VSIP\"
|
xcopy /Y "Build\VSIP\Cosmos.Debug.GDB.exe" "c:\CosmosRun\Build\VSIP\"
|
||||||
|
|
||||||
xcopy /Y "Build\syslinux\*.*" "c:\CosmosRun\Build\ISO\"
|
xcopy /Y "Build\syslinux\*.*" "c:\CosmosRun\Build\ISO\"
|
||||||
|
|
||||||
xcopy /Y /S "Build\VMware\*" "c:\CosmosRun\Build\VMware\"
|
xcopy /Y /S "Build\VMware\*" "c:\CosmosRun\Build\VMware\"
|
||||||
|
|
||||||
xcopy /Y /S "Build\Tools" "c:\CosmosRun\Build\Tools\"
|
xcopy /Y /S "Build\Tools" "c:\CosmosRun\Build\Tools\"
|
||||||
|
|
||||||
xcopy /Y "source\Cosmos.Core.DebugStub\*.xs" "c:\CosmosRun\XSharp\DebugStub\"
|
xcopy /Y "source\Cosmos.Core.DebugStub\*.xs" "c:\CosmosRun\XSharp\DebugStub\"
|
||||||
|
|
||||||
xcopy /Y /S "Resources\Bochs\*.*" "%ProgramFiles(x86)%\Bochs-2.6.8\"
|
xcopy /Y /S "Resources\Bochs\*.*" "%ProgramFiles(x86)%\Bochs-2.6.8\"
|
||||||
|
|
||||||
|
|
||||||
reg add HKLM\SOFTWARE\WOW6432Node\Cosmos /v UserKit /d c:\CosmosRun\
|
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\""
|
reg add HKCR\BochsConfigFile\shell\Run\command /ve /d "\"C:\Program Files (x86)\Bochs-2.6.8\Bochs.exe\" -q -f \"%1\""
|
||||||
|
|
||||||
|
|
||||||
#test: off
|
#test: off
|
||||||
# assemblies:
|
# assemblies:
|
||||||
# - Cosmos.Core.Memory.Test.dll
|
# - Cosmos.Core.Memory.Test.dll
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,9 @@ namespace Cosmos.Build.Tasks
|
||||||
|
|
||||||
protected override string ToolName => "objdump.exe";
|
protected override string ToolName => "objdump.exe";
|
||||||
|
|
||||||
|
protected override MessageImportance StandardErrorLoggingImportance => MessageImportance.High;
|
||||||
|
protected override MessageImportance StandardOutputLoggingImportance => MessageImportance.High;
|
||||||
|
|
||||||
protected override bool ValidateParameters()
|
protected override bool ValidateParameters()
|
||||||
{
|
{
|
||||||
if (!File.Exists(InputFile))
|
if (!File.Exists(InputFile))
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,9 @@ namespace Cosmos.Build.Tasks
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
protected override string ToolName => "ld.exe";
|
protected override string ToolName => "ld.exe";
|
||||||
|
|
||||||
protected override MessageImportance StandardErrorLoggingImportance => MessageImportance.High;
|
protected override MessageImportance StandardErrorLoggingImportance => MessageImportance.High;
|
||||||
|
protected override MessageImportance StandardOutputLoggingImportance => MessageImportance.High;
|
||||||
|
|
||||||
private static bool IsValidAddress(string aAddress)
|
private static bool IsValidAddress(string aAddress)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,9 @@ namespace Cosmos.Build.Tasks
|
||||||
public string OutputFile { get; set; }
|
public string OutputFile { get; set; }
|
||||||
|
|
||||||
protected override string ToolName => "mkisofs.exe";
|
protected override string ToolName => "mkisofs.exe";
|
||||||
|
|
||||||
protected override MessageImportance StandardErrorLoggingImportance => MessageImportance.High;
|
protected override MessageImportance StandardErrorLoggingImportance => MessageImportance.High;
|
||||||
|
protected override MessageImportance StandardOutputLoggingImportance => MessageImportance.High;
|
||||||
|
|
||||||
protected override bool ValidateParameters()
|
protected override bool ValidateParameters()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,9 @@ namespace Cosmos.Build.Tasks
|
||||||
|
|
||||||
protected override string ToolName => "nasm.exe";
|
protected override string ToolName => "nasm.exe";
|
||||||
|
|
||||||
|
protected override MessageImportance StandardErrorLoggingImportance => MessageImportance.High;
|
||||||
|
protected override MessageImportance StandardOutputLoggingImportance => MessageImportance.High;
|
||||||
|
|
||||||
protected override bool ValidateParameters()
|
protected override bool ValidateParameters()
|
||||||
{
|
{
|
||||||
if (String.IsNullOrWhiteSpace(InputFile))
|
if (String.IsNullOrWhiteSpace(InputFile))
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,9 @@ namespace Cosmos.Build.Tasks
|
||||||
|
|
||||||
protected override string ToolName => "TheRingMaster.exe";
|
protected override string ToolName => "TheRingMaster.exe";
|
||||||
|
|
||||||
|
protected override MessageImportance StandardErrorLoggingImportance => MessageImportance.High;
|
||||||
|
protected override MessageImportance StandardOutputLoggingImportance => MessageImportance.High;
|
||||||
|
|
||||||
protected override bool ValidateParameters()
|
protected override bool ValidateParameters()
|
||||||
{
|
{
|
||||||
if (!File.Exists(KernelAssemblyPath))
|
if (!File.Exists(KernelAssemblyPath))
|
||||||
|
|
|
||||||
|
|
@ -107,8 +107,14 @@ namespace Cosmos.HAL
|
||||||
HeaderType = (PCIHeaderType)ReadRegister8((byte)Config.HeaderType);
|
HeaderType = (PCIHeaderType)ReadRegister8((byte)Config.HeaderType);
|
||||||
BIST = (PCIBist)ReadRegister8((byte)Config.BIST);
|
BIST = (PCIBist)ReadRegister8((byte)Config.BIST);
|
||||||
InterruptPIN = (PCIInterruptPIN)ReadRegister8((byte)Config.InterruptPIN);
|
InterruptPIN = (PCIInterruptPIN)ReadRegister8((byte)Config.InterruptPIN);
|
||||||
|
if ((uint)VendorID == 0xFF && (uint)DeviceID == 0xFFFF)
|
||||||
DeviceExists = (uint)VendorID != 0xFFFF && (uint)DeviceID != 0xFFFF;
|
{
|
||||||
|
DeviceExists = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DeviceExists = true;
|
||||||
|
}
|
||||||
if (HeaderType == PCIHeaderType.Normal)
|
if (HeaderType == PCIHeaderType.Normal)
|
||||||
{
|
{
|
||||||
BaseAddressBar = new PCIBaseAddressBar[6];
|
BaseAddressBar = new PCIBaseAddressBar[6];
|
||||||
|
|
|
||||||
|
|
@ -364,7 +364,6 @@ namespace Cosmos.System.FileSystem
|
||||||
if (BlockDevice.Devices[i] is Partition)
|
if (BlockDevice.Devices[i] is Partition)
|
||||||
{
|
{
|
||||||
mPartitions.Add((Partition)BlockDevice.Devices[i]);
|
mPartitions.Add((Partition)BlockDevice.Devices[i]);
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
//#define COSMOSDEBUG
|
//#define COSMOSDEBUG
|
||||||
using System;
|
using System;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
@ -93,6 +93,8 @@ namespace Cosmos.System.Graphics
|
||||||
|
|
||||||
public abstract void DrawPoint(Pen pen, float x, float 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)
|
public virtual void DrawArray(Color[] colors, Point point, int width, int height)
|
||||||
{
|
{
|
||||||
DrawArray(colors, point.X, point.Y, width, height);
|
DrawArray(colors, point.X, point.Y, width, height);
|
||||||
|
|
@ -246,11 +248,11 @@ namespace Cosmos.System.Graphics
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
public virtual void DrawCircle(Pen pen, Point point, int radius)
|
public virtual void DrawCircle(Pen pen, Point point, int radius)
|
||||||
{
|
{
|
||||||
DrawCircle(pen, point.X, point.Y, radius);
|
DrawCircle(pen, point.X, point.Y, radius);
|
||||||
}
|
}
|
||||||
|
|
||||||
//http://members.chello.at/~easyfilter/bresenham.html
|
//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)
|
public virtual void DrawEllipse(Pen pen, int x_center, int y_center, int x_radius, int y_radius)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,38 +1,151 @@
|
||||||
//#define COSMOSDEBUG
|
//#define COSMOSDEBUG
|
||||||
using Cosmos.System.Graphics;
|
using Cosmos.System.Graphics;
|
||||||
|
using Cosmos.HAL;
|
||||||
|
|
||||||
namespace Cosmos.System.Graphics
|
namespace Cosmos.System.Graphics
|
||||||
{
|
{
|
||||||
public static class FullScreenCanvas
|
public static class FullScreenCanvas
|
||||||
{
|
{
|
||||||
/*
|
private enum VideoDriver
|
||||||
* 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)
|
|
||||||
{
|
{
|
||||||
Global.mDebugger.SendInternal("GetFullScreenCanvas() with mode " + mode);
|
VMWareSVGAIIDriver,
|
||||||
|
//VGADriver,
|
||||||
|
VBEDriver
|
||||||
|
}
|
||||||
|
|
||||||
if (MyVideoDriver == null)
|
private static PCIDevice SVGAIIDevice = PCI.GetDevice(VendorID.VMWare, DeviceID.SVGAIIAdapter);
|
||||||
return MyVideoDriver = new VBEScreen(mode);
|
|
||||||
|
|
||||||
/* We have already got a VideoDriver istance simple change its mode */
|
public static bool SVGAIIExist()
|
||||||
MyVideoDriver.Mode = mode;
|
{
|
||||||
return MyVideoDriver;
|
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()
|
public static Canvas GetFullScreenCanvas()
|
||||||
{
|
{
|
||||||
Global.mDebugger.SendInternal($"GetFullScreenCanvas() with default mode");
|
|
||||||
if (MyVideoDriver == null)
|
if (MyVideoDriver == null)
|
||||||
return new VBEScreen();
|
{
|
||||||
|
return MyVideoDriver = GetVideoDriver();
|
||||||
/* We have already got a VideoDriver istance simple reset its mode to DefaultGraphicMode */
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
MyVideoDriver.Mode = MyVideoDriver.DefaultGraphicMode;
|
MyVideoDriver.Mode = MyVideoDriver.DefaultGraphicMode;
|
||||||
return MyVideoDriver;
|
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;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
195
source/Cosmos.System2/Graphics/SVGAIIScreen.cs
Normal file
195
source/Cosmos.System2/Graphics/SVGAIIScreen.cs
Normal file
|
|
@ -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<Mode> getAvailableModes()
|
||||||
|
{
|
||||||
|
return new List<Mode>
|
||||||
|
{
|
||||||
|
/* 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));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,13 +1,13 @@
|
||||||
//#define COSMOSDEBUG
|
//#define COSMOSDEBUG
|
||||||
using Cosmos.HAL.Drivers;
|
using Cosmos.HAL.Drivers;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Cosmos.System.Graphics;
|
using Cosmos.Common.Extensions;
|
||||||
|
|
||||||
namespace Cosmos.System
|
namespace Cosmos.System.Graphics
|
||||||
{
|
{
|
||||||
public class VBEScreen : Canvas
|
public class VBEScreen : Canvas
|
||||||
{
|
{
|
||||||
|
|
@ -26,7 +26,7 @@ namespace Cosmos.System
|
||||||
|
|
||||||
public VBEScreen(Mode mode) : base(mode)
|
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);
|
ThrowIfModeIsNotValid(mode);
|
||||||
|
|
||||||
|
|
@ -75,7 +75,7 @@ namespace Cosmos.System
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override Mode getDefaultGraphicMode() => new Mode(1024, 768, ColorDepth.ColorDepth32);
|
protected override Mode getDefaultGraphicMode() => new Mode(1024, 768, ColorDepth.ColorDepth32);
|
||||||
|
public static readonly Mode defaultGraphicsMode = new Mode(1024, 768, ColorDepth.ColorDepth32);
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Use this to setup the screen, this will disable the console.
|
/// Use this to setup the screen, this will disable the console.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -128,9 +128,7 @@ namespace Cosmos.System
|
||||||
* For now we can Draw only if the ColorDepth is 32 bit, we will throw otherwise.
|
* 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)
|
* 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
|
* ColorDepth.ColorDepth16 and ColorDepth.ColorDepth8 need a conversion from color (an ARGB32 color) to the RGB16 and RGB8
|
||||||
* 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
|
|
||||||
* how to do this conversion faster maybe using pre-computed tables? What happens if the color cannot be converted? We will throw?
|
* 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)
|
switch (mode.ColorDepth)
|
||||||
|
|
@ -148,7 +146,18 @@ namespace Cosmos.System
|
||||||
|
|
||||||
Global.mDebugger.SendInternal("Point drawn");
|
Global.mDebugger.SendInternal("Point drawn");
|
||||||
break;
|
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:
|
default:
|
||||||
String errorMsg = "DrawPoint() with ColorDepth " + (int)Mode.ColorDepth + " not yet supported";
|
String errorMsg = "DrawPoint() with ColorDepth " + (int)Mode.ColorDepth + " not yet supported";
|
||||||
throw new NotImplementedException(errorMsg);
|
throw new NotImplementedException(errorMsg);
|
||||||
|
|
@ -184,7 +193,22 @@ namespace Cosmos.System
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Reading
|
#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
|
#endregion
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
using System;
|
using System;
|
||||||
using HALVGAScreen = Cosmos.HAL.VGAScreen;
|
using HALVGAScreen = Cosmos.HAL.VGAScreen;
|
||||||
|
|
||||||
namespace Cosmos.System
|
namespace Cosmos.System.Graphics
|
||||||
{
|
{
|
||||||
public class VGAScreen
|
public class VGAScreen
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,8 @@
|
||||||
using System;
|
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))]
|
[Plug(Target = typeof(decimal))]
|
||||||
public static class DecimalImpl
|
public static class DecimalImpl
|
||||||
|
|
@ -1,7 +1,5 @@
|
||||||
using System;
|
using System;
|
||||||
using Cosmos.Common;
|
using Cosmos.Common;
|
||||||
using Cosmos.Debug.Kernel;
|
|
||||||
using IL2CPU.API;
|
|
||||||
using IL2CPU.API.Attribs;
|
using IL2CPU.API.Attribs;
|
||||||
|
|
||||||
namespace Cosmos.System_Plugs.System
|
namespace Cosmos.System_Plugs.System
|
||||||
|
|
@ -14,6 +12,8 @@ namespace Cosmos.System_Plugs.System
|
||||||
return StringHelper.GetNumberString(aThis);
|
return StringHelper.GetNumberString(aThis);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static string ToString(ref int aThis, IFormatProvider aFormatProvider) => ToString(ref aThis);
|
||||||
|
|
||||||
public static Int32 Parse(string s)
|
public static Int32 Parse(string s)
|
||||||
{
|
{
|
||||||
const string digits = "0123456789";
|
const string digits = "0123456789";
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue