mirror of
https://github.com/danbulant/Cosmos
synced 2026-06-12 19:21:40 +00:00
Clean up of Hardware text class
This commit is contained in:
parent
218415ea73
commit
95ef6fa0f2
9 changed files with 164 additions and 137 deletions
|
|
@ -20,6 +20,9 @@ EndProject
|
|||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Cosmos.Hardware", "Cosmos\Cosmos.Hardware\Cosmos.Hardware.csproj", "{CE50FE98-9AC4-4B4D-ADC7-31F6DCD28755}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Kernel", "Kernel", "{0D558E33-78B0-47DB-B5EF-B7C2F3114D75}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
Notes.html = Notes.html
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Cosmos.Kernel.Plugs", "Cosmos\Cosmos.Kernel.Plugs\Cosmos.Kernel.Plugs.csproj", "{B168BEDD-C6A6-4E7C-B9A5-0144286E9E42}"
|
||||
EndProject
|
||||
|
|
|
|||
|
|
@ -94,13 +94,12 @@
|
|||
<Compile Include="Bus\PCIBus.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Old\RTC.cs" />
|
||||
<Compile Include="Old\Screen\Text.cs" />
|
||||
<Compile Include="Old\Serial.cs" />
|
||||
<Compile Include="Old\Storage\ATA.cs" />
|
||||
<Compile Include="Old\Storage\ATAOld.cs" />
|
||||
<Compile Include="Old\Storage\Storage.cs" />
|
||||
<Compile Include="SerialDevice.cs" />
|
||||
<Compile Include="TextScreen-Old.cs" />
|
||||
<Compile Include="TextScreen.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Cosmos.snk" />
|
||||
|
|
|
|||
|
|
@ -1,69 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Cosmos.Hardware.Screen {
|
||||
public class Text {
|
||||
public const int Columns = 80;
|
||||
public const int Lines = 24;
|
||||
public const int VideoAddr = 0xB8000;
|
||||
private const byte DefaultColor = 7;
|
||||
private static bool mInitialized = false;
|
||||
private static byte Color;
|
||||
|
||||
private static void CheckInit() {
|
||||
if (!mInitialized) {
|
||||
Color = DefaultColor;
|
||||
mInitialized = true;
|
||||
}
|
||||
}
|
||||
|
||||
public static unsafe void Clear() {
|
||||
CheckInit();
|
||||
|
||||
byte* xScreenPtr = (byte*)VideoAddr;
|
||||
|
||||
for (int i = 0; i < Columns * (Lines + 1); i++) {
|
||||
*xScreenPtr = 0;
|
||||
xScreenPtr++;
|
||||
*xScreenPtr = Color;
|
||||
xScreenPtr++;
|
||||
}
|
||||
}
|
||||
|
||||
public static unsafe void ScrollUp() {
|
||||
CheckInit();
|
||||
int Columns2 = Columns * 2;
|
||||
byte* xScreenPtr = (byte*)(VideoAddr );
|
||||
for (int i = 0; i < Columns * (Lines); i++) {
|
||||
*xScreenPtr = *(xScreenPtr + Columns2);
|
||||
xScreenPtr ++;
|
||||
*xScreenPtr = *(xScreenPtr + Columns2);
|
||||
xScreenPtr++;
|
||||
}
|
||||
|
||||
xScreenPtr = (byte*)(VideoAddr + ( Lines * Columns) * 2);
|
||||
for (int i = 0; i < Columns; i++) {
|
||||
*xScreenPtr = 0;
|
||||
xScreenPtr ++;
|
||||
*xScreenPtr = Color;
|
||||
xScreenPtr++;
|
||||
}
|
||||
}
|
||||
|
||||
public unsafe static void PutChar(int aLine, int aPos, char aChar) {
|
||||
CheckInit();
|
||||
int xScreenOffset = ((aPos + (aLine * Columns)) * 2);
|
||||
byte* xScreenPtr = (byte*)(VideoAddr + xScreenOffset);
|
||||
byte xVal = (byte)aChar;
|
||||
*xScreenPtr = xVal;
|
||||
xScreenPtr ++;
|
||||
*xScreenPtr = Color;
|
||||
}
|
||||
|
||||
public static void SetColors(ConsoleColor foreground, ConsoleColor background) {
|
||||
CheckInit();
|
||||
Color = (byte)((byte)(foreground ) | ((byte)(background ) << 4));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,57 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using HW = Cosmos.Hardware.Screen;
|
||||
|
||||
namespace Cosmos.Kernel {
|
||||
public class TextScreen {
|
||||
public static int CurrentLine = 0;
|
||||
public static int CurrentChar = 0;
|
||||
|
||||
public static int WindowHeight {
|
||||
get {
|
||||
return HW.Text.Lines;
|
||||
}
|
||||
}
|
||||
|
||||
public static int WindowWidth {
|
||||
get {
|
||||
return HW.Text.Columns;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the console colors.
|
||||
/// </summary>
|
||||
/// <param name="foreground"></param>
|
||||
/// <param name="background"></param>
|
||||
public static void SetColors(ConsoleColor foreground, ConsoleColor background)
|
||||
{
|
||||
HW.Text.SetColors(foreground, background);
|
||||
}
|
||||
|
||||
public static void NewLine() {
|
||||
CurrentLine += 1;
|
||||
CurrentChar = 0;
|
||||
if (CurrentLine > (HW.Text.Lines)) {
|
||||
HW.Text.ScrollUp();
|
||||
CurrentLine -= 1;
|
||||
CurrentChar = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public static void Clear() {
|
||||
HW.Text.Clear();
|
||||
CurrentChar = 0;
|
||||
CurrentLine = 0;
|
||||
}
|
||||
|
||||
public static void WriteChar(char aChar) {
|
||||
HW.Text.PutChar(CurrentLine, CurrentChar, aChar);
|
||||
CurrentChar += 1;
|
||||
if (CurrentChar == HW.Text.Columns) {
|
||||
NewLine();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
97
source/Cosmos/Cosmos.Hardware/TextScreen.cs
Normal file
97
source/Cosmos/Cosmos.Hardware/TextScreen.cs
Normal file
|
|
@ -0,0 +1,97 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Cosmos.Hardware {
|
||||
public class TextScreen {
|
||||
public static int CurrentRow = 0;
|
||||
public static int CurrentChar = 0;
|
||||
protected const int VideoAddr = 0xB8000;
|
||||
protected const byte DefaultColor = 7;
|
||||
protected static bool mInitialized = false;
|
||||
protected static byte Color;
|
||||
|
||||
protected static void CheckInit() {
|
||||
if (!mInitialized) {
|
||||
Color = DefaultColor;
|
||||
mInitialized = true;
|
||||
}
|
||||
}
|
||||
|
||||
public static int Rows {
|
||||
get { return 24; }
|
||||
}
|
||||
|
||||
public static int Columns {
|
||||
get { return 80; }
|
||||
}
|
||||
|
||||
public static void NewLine() {
|
||||
CurrentRow += 1;
|
||||
CurrentChar = 0;
|
||||
if (CurrentRow > Rows) {
|
||||
ScrollUp();
|
||||
CurrentRow -= 1;
|
||||
CurrentChar = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public static unsafe void Clear() {
|
||||
CheckInit();
|
||||
|
||||
byte* xScreenPtr = (byte*)VideoAddr;
|
||||
for (int i = 0; i < Columns * (Rows + 1); i++) {
|
||||
*xScreenPtr = 0;
|
||||
xScreenPtr++;
|
||||
*xScreenPtr = Color;
|
||||
xScreenPtr++;
|
||||
}
|
||||
|
||||
CurrentChar = 0;
|
||||
CurrentRow = 0;
|
||||
}
|
||||
|
||||
public static void WriteChar(char aChar) {
|
||||
PutChar(CurrentRow, CurrentChar, aChar);
|
||||
CurrentChar += 1;
|
||||
if (CurrentChar == Columns) {
|
||||
NewLine();
|
||||
}
|
||||
}
|
||||
|
||||
protected static unsafe void ScrollUp() {
|
||||
CheckInit();
|
||||
int Columns2 = Columns * 2;
|
||||
byte* xScreenPtr = (byte*)(VideoAddr );
|
||||
for (int i = 0; i < Columns * Rows; i++) {
|
||||
*xScreenPtr = *(xScreenPtr + Columns2);
|
||||
xScreenPtr ++;
|
||||
*xScreenPtr = *(xScreenPtr + Columns2);
|
||||
xScreenPtr++;
|
||||
}
|
||||
|
||||
xScreenPtr = (byte*)(VideoAddr + Rows * Columns * 2);
|
||||
for (int i = 0; i < Columns; i++) {
|
||||
*xScreenPtr = 0;
|
||||
xScreenPtr ++;
|
||||
*xScreenPtr = Color;
|
||||
xScreenPtr++;
|
||||
}
|
||||
}
|
||||
|
||||
public unsafe static void PutChar(int aLine, int aRow, char aChar) {
|
||||
CheckInit();
|
||||
int xScreenOffset = ((aRow + (aLine * Columns)) * 2);
|
||||
byte* xScreenPtr = (byte*)(VideoAddr + xScreenOffset);
|
||||
byte xVal = (byte)aChar;
|
||||
*xScreenPtr = xVal;
|
||||
xScreenPtr ++;
|
||||
*xScreenPtr = Color;
|
||||
}
|
||||
|
||||
public static void SetColors(ConsoleColor aForeground, ConsoleColor aBackground) {
|
||||
CheckInit();
|
||||
Color = (byte)((byte)(aForeground ) | ((byte)(aBackground ) << 4));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2,6 +2,7 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Cosmos.Kernel;
|
||||
using Cosmos.Hardware;
|
||||
using Indy.IL2CPU.Plugs;
|
||||
|
||||
namespace Cosmos.Kernel.Plugs {
|
||||
|
|
@ -38,7 +39,7 @@ namespace Cosmos.Kernel.Plugs {
|
|||
}
|
||||
|
||||
public static int get_CursorTop() {
|
||||
return TextScreen.CurrentLine;
|
||||
return TextScreen.CurrentRow;
|
||||
}
|
||||
|
||||
public static void set_CursorLeft(int x)
|
||||
|
|
@ -47,15 +48,15 @@ namespace Cosmos.Kernel.Plugs {
|
|||
}
|
||||
|
||||
public static void set_CursorTop(int y) {
|
||||
TextScreen.CurrentLine = y;
|
||||
TextScreen.CurrentRow = y;
|
||||
}
|
||||
|
||||
public static int get_WindowHeight() {
|
||||
return TextScreen.WindowHeight;
|
||||
return TextScreen.Rows;
|
||||
}
|
||||
|
||||
public static int get_WindowWidth() {
|
||||
return TextScreen.WindowWidth;
|
||||
return TextScreen.Columns;
|
||||
}
|
||||
|
||||
//TODO: Console uses TextWriter - intercept and plug it instead
|
||||
|
|
|
|||
54
source/Notes.html
Normal file
54
source/Notes.html
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" >
|
||||
<head>
|
||||
<title>Untitled Page</title>
|
||||
<style type="text/css">
|
||||
.style1
|
||||
{
|
||||
width: 100%;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<table class="style1">
|
||||
<tr>
|
||||
<td>
|
||||
<a href="http://www.gocosmos.org/milestones/Future/Rings.EN.aspx">Kernel Ring</a></td>
|
||||
<td>
|
||||
Hardware</td>
|
||||
<td>
|
||||
System</td>
|
||||
<td>
|
||||
User</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
Cosmos.Kernel</td>
|
||||
<td>
|
||||
Cosmos.Hardware</td>
|
||||
<td>
|
||||
Cosmos.Sys</td>
|
||||
<td>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
Cosmos.Kernel.Plugs</td>
|
||||
<td>
|
||||
</td>
|
||||
<td>
|
||||
Cosmos.Filesystem</td>
|
||||
<td>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<p>
|
||||
Cosmos.Filesystem should be renamed to Cosmos.Sys.Filesystem</p>
|
||||
<p>
|
||||
</p>
|
||||
<p>
|
||||
</p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -10,7 +10,6 @@ namespace RsenkTest
|
|||
public static List<String> GetParsed(string line)
|
||||
{
|
||||
List<String> retList = new List<String>();
|
||||
string lineOld = "";
|
||||
|
||||
//Read command
|
||||
String command = ReadCommand(line);
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ using Cosmos.Hardware.PC.Bus;
|
|||
using Cosmos.FileSystem;
|
||||
using Cosmos.Hardware;
|
||||
using System.Diagnostics;
|
||||
using S = Cosmos.Hardware.Screen.Text;
|
||||
using S = Cosmos.Hardware.TextScreen;
|
||||
|
||||
namespace SteveKernel
|
||||
{
|
||||
|
|
@ -70,7 +70,7 @@ namespace SteveKernel
|
|||
|
||||
Player[] players = new Player[playersc];
|
||||
|
||||
bool[] board = new bool[S.Columns * S.Lines];
|
||||
bool[] board = new bool[S.Columns * S.Rows];
|
||||
|
||||
for (int i = 0; i < playersc; i++)
|
||||
{
|
||||
|
|
@ -78,7 +78,7 @@ namespace SteveKernel
|
|||
players[i] = new Player()
|
||||
{
|
||||
x = r.Next(S.Columns),
|
||||
y = r.Next(S.Lines),
|
||||
y = r.Next(S.Rows),
|
||||
d = r.Next(4),
|
||||
i = i,
|
||||
alive = true
|
||||
|
|
@ -122,7 +122,7 @@ namespace SteveKernel
|
|||
ny++;
|
||||
break;
|
||||
}
|
||||
if (nx >= 0 && nx < S.Columns && ny >= 0 && ny < S.Lines &&
|
||||
if (nx >= 0 && nx < S.Columns && ny >= 0 && ny < S.Rows &&
|
||||
board[nx + ny * S.Columns] == false)
|
||||
{
|
||||
p.alive = true;
|
||||
|
|
|
|||
Loading…
Reference in a new issue