Closed virtualtoja closed 3 years ago
Did it display the same output for the VGAScreen? At the moment I would recommend using the VMware SVGAII Canvas, because it is very fast and it is easy to put images on there. I think they are still working on VBE, so for now stick with VMware SVGAII. Also, to know the exception put Console.WriteLine statements between each line that looks suspicous of an error happening and then when it stops at that location put a try and catch block.
All the screenshots are on Canvas VGAScreen didnt work for me. VS didnt see the VGAScreen class variables and functions. Also sorry for my bad english.
I have a new problem, I changed the VBECanvas to normal Canvas and it also doesnt work but it has different errors.
`using System; using System.Collections.Generic; using System.Threading; using Sys = Cosmos.System; using Cosmos.System.Graphics; using Cosmos.System.FileSystem; using Cosmos.HAL; using System.Drawing; using Cosmos.HAL.Network;
namespace microOS { public class Kernel : Sys.Kernel { protected override void BeforeRun() { Console.Clear(); Console.WriteLine("Starting cmdline..."); StartCmdLine(); Console.WriteLine("Done"); }
public const string version = "v0.1.5";
CommandLine cmd;
void StartCmdLine()
{
Console.WriteLine("Loading commands...");
cmd = new CommandLine();
cmd.InitCommandLine();
Console.WriteLine($"microOS {version} booted succesfully.");
}
void StartGraphicalInterface()
{
Screen.Init();
Sys.MouseManager.ScreenHeight = (uint)Screen.screenY;
Sys.MouseManager.ScreenWidth = (uint)Screen.screenX;
guimode = true;
Screen.ClearScreen(Color.Black);
}
public bool guimode = false;
protected override void Run()
{
if(guimode)
{
DrawCursor(Color.White);
}
else
{
Console.Write(">>>");
string cmmd = Console.ReadLine();
if (cmmd == "startgui")
{
Console.WriteLine("Starting graphical interface...");
StartGraphicalInterface();
}
else
{
cmd.CheckCommand(cmmd);
}
}
}
void DrawCursor(Color c)
{
Screen.SetPixel((int)Sys.MouseManager.X, (int)Sys.MouseManager.Y, c);
Screen.SetPixel((int)Sys.MouseManager.X, (int)Sys.MouseManager.Y-1, c);
Screen.SetPixel((int)Sys.MouseManager.X+1, (int)Sys.MouseManager.Y, c);
Screen.SetPixel((int)Sys.MouseManager.X+1, (int)Sys.MouseManager.Y-1, c);
Screen.DrawScreen();
}
}
public class CommandLine
{
public const string cmdver = "v0.1.1";
public void InitCommandLine()
{
}
public void CheckCommand(string command)
{
if (command.StartsWith("prnt"))
{
try
{
Console.WriteLine(command.Substring(5));
}
catch { }
}
else if (command == "clear")
{
Console.Clear();
}
else if (command == "help")
{
HelpMenu();
}
else if(command == "ver")
{
Console.WriteLine($"cmdline version: {cmdver} microOS version: {Kernel.version}");
}
else if (command.StartsWith("pkg"))
{
if (command.Substring(4).StartsWith("remove"))
{
string pkgname = command.Substring(11);
}
}
else
{
Console.WriteLine($"Command or file \"{command}\" does not exist.");
}
}
public string[] commands = new string[] { "prnt <text>", "clear", "help", "pkg <args>", "ver" };
#region Commands
void HelpMenu()
{
Console.Write("List of available commands: ");
foreach (string command in commands)
{
Console.Write($"{command}, ");
}
Console.WriteLine();
}
#endregion
}
public static class Screen
{
public static int screenX = 320;
public static int screenY = 200;
private static Color[] pixelBuffer = new Color[(screenX * screenY) + screenX];
private static Color[] pixelBufferOld = new Color[(screenX * screenY) + screenX];
private static Canvas canvas = FullScreenCanvas.GetFullScreenCanvas();
public static void Init()
{
canvas.Mode = new Mode(screenX, screenY, ColorDepth.ColorDepth32);
}
public static void SetPixel(int x, int y, Color c)
{
if (x > screenX || y > screenY) return;
pixelBuffer[(x * y) + x] = c;
}
public static void ClearScreen(Color c)
{
canvas.Clear(c);
}
public static void DrawScreen()
{
Pen pen = new Pen(Color.White);
for (int y = 0, h = screenY; y < h; y++)
{
for (int x = 0, w = screenX; x < h; x++)
{
if (!(pixelBuffer[(x * y) + x] == pixelBufferOld[(y * y) + x]))
{
pen.Color = pixelBuffer[(y * screenX) + x];
canvas.DrawPoint(pen, x, y);
}
}
}
for (int i = 0, len = pixelBuffer.Length; i < len; i++)
{
pixelBuffer[i] = pixelBufferOld[i];
}
}
}
public static class DiskManagement
{
public static CosmosVFS fs;
public static void Init()
{
fs = new CosmosVFS();
Sys.FileSystem.VFS.VFSManager.RegisterVFS(fs);
fs.Initialize();
}
}
public static class PackageManager
{
public static void Remove(string packageName)
{
}
public static void Install(string packageName)
{
}
}
} `
This is my new code.
In VMWare it displays black screen:
On real hardware it displays this:
I don't think Canvas is supported on real hardware yet (I mean there are still lots of bugs), also did the VGA Canvas work? Edit: the only driver that will work on real hardware is VGA, all the other ones don't work.
same i have problem with canvas always. you have ide with this?
i think i hopeless with that :)
Changing the mode of the canvas might be the problem.
@quajak and how i can solve that? can i not use a canvas mode?
Pass the correct canvas mode when intialising the canvas. To change the mode while running, disable the canvas and then reinitialise it with the new mode.
ok, thanks!.
When I try to start any type of graphics it displays random errors. It should start graphics when command "startgui" is executed. The errors are mainly Cpu exception x0D or x06. Also VGAScreen does not work.
My code:
Screenshots: