Skip to content

Commit a7c2d5f

Browse files
author
Arawn Davies
committed
Changes
1 parent becfc92 commit a7c2d5f

File tree

8 files changed

+99
-62
lines changed

8 files changed

+99
-62
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,4 @@ source/_ReSharper.Caches/
5353
Docs/~$RingsGen2.xlsx
5454
source/Kernel-X86/90-Application/GuessKernelGen3.csproj
5555
Docs/~$RingsGen3.xlsx
56+
*.map

Demos/CosmosGraphicSubsystem/CosmosGraphicSubsystem.csproj

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
<PropertyGroup>
44
<TargetFramework>netstandard2.0</TargetFramework>
55
<Bochs_Name>CosmosGraphicSubsystemBoot</Bochs_Name>
6+
<VMware_Name>CosmosGraphicSubsystemBoot</VMware_Name>
67
</PropertyGroup>
78

89
<PropertyGroup>
@@ -41,7 +42,7 @@
4142
<Bochs_Description>Use Bochs emulator to deploy and debug.</Bochs_Description>
4243
<Bochs_Deployment>ISO</Bochs_Deployment>
4344
<Bochs_Launch>Bochs</Bochs_Launch>
44-
<Bochs_DebugEnabled>True</Bochs_DebugEnabled>
45+
<Bochs_DebugEnabled>False</Bochs_DebugEnabled>
4546
<Bochs_DebugMode>Source</Bochs_DebugMode>
4647
<Bochs_IgnoreDebugStubAttribute>False</Bochs_IgnoreDebugStubAttribute>
4748
<Bochs_CosmosDebugPort>Serial: COM1</Bochs_CosmosDebugPort>

Demos/CosmosGraphicSubsystem/Kernel.cs

+5-5
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ public class Kernel : Sys.Kernel
1414
protected override void BeforeRun()
1515
{
1616
Console.WriteLine("Cosmos booted successfully. Let's go in Graphic Mode");
17-
Console.WriteLine("Specifying custom graphics mode as 800x600@32");
18-
// Specify custom graphics mode (800x600 @ 16)
19-
Mode start = new Mode(800, 600, ColorDepth.ColorDepth32);
17+
Console.WriteLine("Using default graphics mode");
18+
//Mode start = new Mode(800, 600, ColorDepth.ColorDepth32);
2019

2120
Console.WriteLine("Here we go!");
22-
// Create new instance of FullScreenCanvas, specifying graphics mode
23-
canvas = FullScreenCanvas.GetFullScreenCanvas(start);
21+
Console.ReadKey(true);
22+
// Create new instance of FullScreenCanvas, using default graphics mode
23+
canvas = FullScreenCanvas.GetFullScreenCanvas(); // canvas = GetFullScreenCanvas(start);
2424

2525

2626
/* Clear the Screen with the color 'Blue' */

Kernel.sln

-14
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Spruce", "..\XSharp\source\
9494
EndProject
9595
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "XSharp.x86", "..\XSharp\source\XSharp.x86\XSharp.x86.csproj", "{7370A62F-12DA-4181-BE3B-009D0926CA7E}"
9696
EndProject
97-
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "PCITest", "PCITest", "{58AEE3B6-80BF-4ED3-AD1E-17359139E3FC}"
98-
EndProject
99-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PCITest", "Demos\PCITest\PCITest.csproj", "{D3639BE5-49A0-4163-9174-1D0CC6823E06}"
100-
EndProject
10197
Global
10298
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10399
Debug|Any CPU = Debug|Any CPU
@@ -339,14 +335,6 @@ Global
339335
{7370A62F-12DA-4181-BE3B-009D0926CA7E}.Release|Any CPU.Build.0 = Release|Any CPU
340336
{7370A62F-12DA-4181-BE3B-009D0926CA7E}.Release|x86.ActiveCfg = Release|Any CPU
341337
{7370A62F-12DA-4181-BE3B-009D0926CA7E}.Release|x86.Build.0 = Release|Any CPU
342-
{D3639BE5-49A0-4163-9174-1D0CC6823E06}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
343-
{D3639BE5-49A0-4163-9174-1D0CC6823E06}.Debug|Any CPU.Build.0 = Debug|Any CPU
344-
{D3639BE5-49A0-4163-9174-1D0CC6823E06}.Debug|x86.ActiveCfg = Debug|Any CPU
345-
{D3639BE5-49A0-4163-9174-1D0CC6823E06}.Debug|x86.Build.0 = Debug|Any CPU
346-
{D3639BE5-49A0-4163-9174-1D0CC6823E06}.Release|Any CPU.ActiveCfg = Release|Any CPU
347-
{D3639BE5-49A0-4163-9174-1D0CC6823E06}.Release|Any CPU.Build.0 = Release|Any CPU
348-
{D3639BE5-49A0-4163-9174-1D0CC6823E06}.Release|x86.ActiveCfg = Release|Any CPU
349-
{D3639BE5-49A0-4163-9174-1D0CC6823E06}.Release|x86.Build.0 = Release|Any CPU
350338
EndGlobalSection
351339
GlobalSection(SolutionProperties) = preSolution
352340
HideSolutionNode = FALSE
@@ -392,8 +380,6 @@ Global
392380
{E35E0DBF-555F-4D38-8F28-ACDFA9DC97BD} = {5FF9BF2A-5162-4F12-82B6-1693AD776636}
393381
{0812DD0A-4CEE-4376-B78A-02EBCBAA14C2} = {3CD3D9A5-9BC5-4FEB-8D63-4D535C0ABB78}
394382
{7370A62F-12DA-4181-BE3B-009D0926CA7E} = {3CD3D9A5-9BC5-4FEB-8D63-4D535C0ABB78}
395-
{58AEE3B6-80BF-4ED3-AD1E-17359139E3FC} = {B56A6119-1B8F-44E4-9446-291E52F47D4C}
396-
{D3639BE5-49A0-4163-9174-1D0CC6823E06} = {58AEE3B6-80BF-4ED3-AD1E-17359139E3FC}
397383
EndGlobalSection
398384
GlobalSection(ExtensibilityGlobals) = postSolution
399385
SolutionGuid = {1A1E8F1D-82B3-471F-9B59-0350DEA9203D}

source/Cosmos.System2/Graphics/Canvas.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -249,13 +249,13 @@ public virtual void DrawCircle(Pen pen, int x_center, int y_center, int radius)
249249
}
250250
}
251251

252+
//
252253
public virtual void DrawCircle(Pen pen, Point point, int radius)
253254
{
254255

255256
DrawCircle(pen, point.X, point.Y, radius);
256257

257258
}
258-
259259
//http://members.chello.at/~easyfilter/bresenham.html
260260
public virtual void DrawEllipse(Pen pen, int x_center, int y_center, int x_radius, int y_radius)
261261
{

source/Cosmos.System2/Graphics/FullScreenCanvas.cs

+88-39
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ private enum VideoDriver
1515

1616
private static PCIDevice SVGAIIDevice = PCI.GetDevice(VendorID.VMWare, DeviceID.SVGAIIAdapter);
1717

18-
public static bool DoesSVGAIIExist()
18+
public static bool SVGAIIExist()
1919
{
2020
if (SVGAIIDevice != null)
2121
{
@@ -31,38 +31,44 @@ public static bool DoesSVGAIIExist()
3131
}
3232

3333
}
34-
//public static bool SVGAIIExists = SVGAIIDevice != null;
35-
3634
private static VideoDriver videoDevice;
3735

38-
// Created null - NullReferenceException when calling GetFullScreenCanvas() with 0 overloads
3936
private static Canvas MyVideoDriver = null;
4037

38+
private static Canvas GetVideoDriver()
39+
{
40+
if (SVGAIIExist())
41+
{
42+
return new SVGAIIScreen();
43+
}
44+
else
45+
{
46+
return new VBEScreen();
47+
}
48+
}
49+
private static Canvas GetVideoDriver(Mode mode)
50+
{
51+
if (SVGAIIExist())
52+
{
53+
return new SVGAIIScreen(mode);
54+
}
55+
else
56+
{
57+
return new VBEScreen(mode);
58+
}
59+
}
60+
4161
public static Canvas GetFullScreenCanvas()
4262
{
43-
// If MyVideoDriver is null (hasn't checked if VMWare SVGA exists),
44-
// Do necessary check and set to default gfx mode
4563
if (MyVideoDriver == null)
4664
{
47-
return GetFullScreenCanvas(MyVideoDriver.DefaultGraphicMode);
65+
return MyVideoDriver = GetVideoDriver();
4866
}
49-
// If it's not null, simply change graphics mode */
5067
else
5168
{
5269
MyVideoDriver.Mode = MyVideoDriver.DefaultGraphicMode;
5370
return MyVideoDriver;
5471
}
55-
// Old check left for reference
56-
/*
57-
if (videoDevice == VideoDriver.VMWareSVGAIIDriver)
58-
{
59-
60-
}
61-
else
62-
{
63-
64-
}
65-
*/
6672
}
6773
public static Canvas GetFullScreenCanvas(Mode mode)
6874
{
@@ -71,32 +77,75 @@ public static Canvas GetFullScreenCanvas(Mode mode)
7177
// Do necessary check and set gfx mode as specified (mode)
7278
if (MyVideoDriver == null)
7379
{
74-
if (DoesSVGAIIExist())
75-
{
76-
// Set videoDevice to SVGA, initialize MyVideoDriver as an SVGA display using specified mode
77-
// MyVideoDriver.Mode = mode; isn't exactly needed, just done in case it doesn't set.
78-
// returns MyVideoDriver as the Canvas
79-
videoDevice = VideoDriver.VMWareSVGAIIDriver;
80-
MyVideoDriver = new SVGAIIScreen(mode);
81-
MyVideoDriver.Mode = mode;
82-
return MyVideoDriver;
83-
}
84-
else
85-
{
86-
// Does the same as above, this time using VESA BIOS Extensions (supported by loads of graphics cards)
87-
videoDevice = VideoDriver.VBEDriver;
88-
MyVideoDriver = new VBEScreen(mode);
89-
MyVideoDriver.Mode = mode;
90-
return MyVideoDriver;
91-
}
80+
return MyVideoDriver = GetVideoDriver(mode);
9281
}
9382
else
9483
{
95-
// If MyVideoDriver has been initialized before (Graphics mode has previously been set)
96-
// Change the graphics mode to the mode specified
9784
MyVideoDriver.Mode = mode;
9885
return MyVideoDriver;
9986
}
10087
}
10188
}
10289
}
90+
/*
91+
if (DoesSVGAIIExist())
92+
{
93+
// Set videoDevice to SVGA, initialize MyVideoDriver as an SVGA display using specified mode
94+
// MyVideoDriver.Mode = mode; isn't exactly needed, just done in case it doesn't set.
95+
// returns MyVideoDriver as the Canvas
96+
videoDevice = VideoDriver.VMWareSVGAIIDriver;
97+
MyVideoDriver = new SVGAIIScreen(mode);
98+
MyVideoDriver.Mode = mode;
99+
return MyVideoDriver;
100+
}
101+
else
102+
{
103+
// Does the same as above, this time using VESA BIOS Extensions (supported by loads of graphics cards)
104+
videoDevice = VideoDriver.VBEDriver;
105+
MyVideoDriver = new VBEScreen(mode);
106+
MyVideoDriver.Mode = mode;
107+
return MyVideoDriver;
108+
}
109+
}
110+
else
111+
{
112+
// If MyVideoDriver has been initialized before (Graphics mode has previously been set)
113+
// Change the graphics mode to the mode specified
114+
MyVideoDriver.Mode = mode;
115+
return MyVideoDriver;
116+
}
117+
}
118+
/*
119+
120+
// If MyVideoDriver is null (hasn't checked if VMWare SVGA exists),
121+
// Do necessary check and set to default gfx mode
122+
if (MyVideoDriver == null)
123+
{
124+
if (DoesSVGAIIExist())
125+
{
126+
// Set videoDevice to SVGA, initialize MyVideoDriver as an SVGA display using specified mode
127+
// MyVideoDriver.Mode = mode; isn't exactly needed, just done in case it doesn't set.
128+
// returns MyVideoDriver as the Canvas
129+
videoDevice = VideoDriver.VMWareSVGAIIDriver;
130+
MyVideoDriver = new SVGAIIScreen(SVGAIIScreen.defaultGraphicsMode);
131+
MyVideoDriver.Mode = SVGAIIScreen.defaultGraphicsMode;
132+
return MyVideoDriver;
133+
}
134+
else
135+
{
136+
// Does the same as above, this time using VESA BIOS Extensions (supported by loads of graphics cards)
137+
videoDevice = VideoDriver.VBEDriver;
138+
MyVideoDriver = new VBEScreen(VBEScreen.defaultGraphicsMode);
139+
MyVideoDriver.Mode = VBEScreen.defaultGraphicsMode;
140+
return MyVideoDriver;
141+
}
142+
}
143+
// If it's not null, simply change graphics mode
144+
else
145+
{
146+
MyVideoDriver.Mode = MyVideoDriver.DefaultGraphicMode;
147+
return MyVideoDriver;
148+
}
149+
*/
150+
151+

source/Cosmos.System2/Graphics/SVGAIIScreen.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ public override List<Mode> getAvailableModes()
140140
new Mode(3840, 2400, ColorDepth.ColorDepth32), // WQUXGA
141141
};
142142
}
143-
143+
public static readonly Mode defaultGraphicsMode = new Mode(1024, 768, ColorDepth.ColorDepth16);
144144
protected override Mode getDefaultGraphicMode() => new Mode(1024, 768, ColorDepth.ColorDepth16);
145145

146146
private void SetGraphicsMode(Mode aMode)

source/Cosmos.System2/Graphics/VBEScreen.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public override List<Mode> getAvailableModes()
7575
}
7676

7777
protected override Mode getDefaultGraphicMode() => new Mode(1024, 768, ColorDepth.ColorDepth32);
78-
78+
public static readonly Mode defaultGraphicsMode = new Mode(1024, 768, ColorDepth.ColorDepth32);
7979
/// <summary>
8080
/// Use this to setup the screen, this will disable the console.
8181
/// </summary>

0 commit comments

Comments
 (0)