当我这样做时,display.init()
我会得到这些白线和其他一些不同的像素。接下来发生的事情是它们一次消失一行,这阻止了我的 VGA 启动。
我将发布我的内核代码和显示驱动程序。
显示驱动程序 C#
using Cosmos.HAL;
using Sys = Cosmos.System;
namespace Display
{
public class DisplayDriver
{
protected VGAScreen screen;
private int width, height;
public DisplayDriver()
{
screen = new VGAScreen();
}
public void init()
{
screen.SetGraphicsMode(VGAScreen.ScreenSize.Size320x200, VGAScreen.ColorDepth.BitDepth8);
screen.Clear(0);
width = screen.PixelWidth;
height = screen.PixelHeight;
}
public virtual void setPixel(int x, int y, int c)
{
if (screen.GetPixel320x200x8((uint)x, (uint)y) != (uint)c)
setPixelRaw(x, y, c);
}
public virtual byte getPixel(int x, int y)
{
return (byte)screen.GetPixel320x200x8((uint)x, (uint)y);
}
public virtual void clear()
{
clear(0);
}
public virtual void clear(int c)
{
screen.Clear(c);
}
public virtual void step() { }
public int getWidth()
{
return width;
}
public int getHeight()
{
return height;
}
public void setPixelRaw(int x, int y, int c)
{
screen.SetPixel320x200x8((uint)x, (uint)y, (uint)c);
}
}
}
核心:
using System;
using Sys = Cosmos.System;
using Display;
using Cosmos.Core;
using Cosmos.HAL;
using Cosmos.Common;
using Cosmos.Debug;
using Cosmos.IL2CPU;
namespace CosmosKernel3
{
public class Kernel : Sys.Kernel
{
protected override void BeforeRun()
{
Console.WriteLine("Booting VGADriver.");
try
{
var display = new DisplayDriver();
Console.WriteLine("ATTEMPTING");
display.init(); //init display
display.clear();
display.setPixel((int)40, 50, 60);
}
catch (Exception)
{
Console.WriteLine("Booting VGA failed. Booting into DOS mode.");
dosemergency();
}
}
protected override void Run()
{
boot();
while (true) ;
}
public static void boot()
{
}
public static void dosemergency()
{
Console.WriteLine("XENA DOS EMERGENCY MODE.");
Console.WriteLine("COMMANDS:");
Console.WriteLine("graphics -r (Graphics retry)");
String meow = Console.ReadLine();
if (meow == "graphics -r") ;
Console.WriteLine("Booting VGADriver.");
try
{
var display = new DisplayDriver();
display.init(); //init display
boot(); //boot
}
catch (Exception)
{
Console.WriteLine("Booting VGA failed. Booting into DOS mode.");
dosemergency();
}
}
}
}
截屏:
无论如何,这已经发生了一段时间,我似乎无法弄清楚它为什么这样做。帮助!