Started work on refactored video.
This commit is contained in:
parent
189526cab8
commit
b73c66f6d6
@ -1776,14 +1776,15 @@ var
|
||||
fb: puint32;
|
||||
|
||||
Begin
|
||||
Ready:= False;
|
||||
fb:= puint32(uint32(multibootinfo^.framebuffer_addr));
|
||||
Console_Properties.Width:= multibootinfo^.framebuffer_width;
|
||||
Console_Properties.Height:= multibootinfo^.framebuffer_height;
|
||||
Console_Properties.BitsPerPixel:= multibootinfo^.framebuffer_bpp;
|
||||
Console_Properties.MAX_CELL_X:= (Console_Properties.Width div 8) - 1;
|
||||
Console_Properties.MAX_CELL_Y:= (Console_Properties.Height div 16) - 1;
|
||||
If Console_Properties.BitsPerPixel <> 16 then while true do begin
|
||||
|
||||
If Console_Properties.BitsPerPixel <> 16 then begin
|
||||
exit;
|
||||
end;
|
||||
kpalloc(uint32(fb));
|
||||
keyboard.hook(@keyhook);
|
||||
|
83
src/driver/video/video.pas
Normal file
83
src/driver/video/video.pas
Normal file
@ -0,0 +1,83 @@
|
||||
unit video;
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
multiboot, lmemorymanager, tracer, color, rand;
|
||||
|
||||
procedure init();
|
||||
procedure DrawPixel(X : uint32; Y : uint32; Pixel : TRGB32);
|
||||
|
||||
type
|
||||
TVESALinearBuffer = record
|
||||
Location : uint64;
|
||||
BitsPerPixel : uint8;
|
||||
Width : uint32;
|
||||
Height : uint32;
|
||||
end;
|
||||
TVESA = record
|
||||
initialized : Boolean;
|
||||
Framebuffer : TVESALinearBuffer;
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
var
|
||||
VESA : TVESA;
|
||||
|
||||
procedure allocateFrameBuffer(Address : uint32; Width : uint32; Height : uint32);
|
||||
var
|
||||
LowerAddress, UpperAddress : uint32;
|
||||
Block : uint32;
|
||||
|
||||
begin
|
||||
tracer.push_trace('video.allocateFrameBuffer.enter');
|
||||
LowerAddress:= ((Address) SHR 22)-1;
|
||||
UpperAddress:= ((Address + (Width * Height)) SHR 22)+1;
|
||||
For Block:=LowerAddress to UpperAddress do begin
|
||||
kpalloc(Block SHL 22);
|
||||
end;
|
||||
tracer.push_trace('video.allocateFrameBuffer.enter');
|
||||
end;
|
||||
|
||||
procedure init();
|
||||
var
|
||||
RGB : TRGB32;
|
||||
x,y : uint32;
|
||||
|
||||
begin
|
||||
tracer.push_trace('video.init.enter');
|
||||
If not(VESA.initialized) then begin
|
||||
VESA.Framebuffer.Location:= multiboot.multibootinfo^.framebuffer_addr;
|
||||
VESA.Framebuffer.BitsPerPixel:= multiboot.multibootinfo^.framebuffer_bpp;
|
||||
VESA.Framebuffer.Width:= multiboot.multibootinfo^.framebuffer_width;
|
||||
VESA.Framebuffer.Height:= multiboot.multibootinfo^.framebuffer_height;
|
||||
allocateFrameBuffer(VESA.Framebuffer.Location, VESA.Framebuffer.Width, VESA.Framebuffer.Height);
|
||||
VESA.initialized:= true;
|
||||
end;
|
||||
srand(98354754397);
|
||||
while true do begin
|
||||
Inc(RGB.R);
|
||||
for x:=0 to VESA.Framebuffer.Width-1 do begin
|
||||
Inc(RGB.G);
|
||||
for y:=0 to VESA.Framebuffer.Height-1 do begin
|
||||
DrawPixel(x,y,RGB);
|
||||
Inc(RGB.B);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
tracer.push_trace('video.init.exit');
|
||||
end;
|
||||
|
||||
procedure DrawPixel(X : uint32; Y : uint32; Pixel : TRGB32);
|
||||
var
|
||||
Location : PuInt32;
|
||||
Increment : Uint32;
|
||||
|
||||
begin
|
||||
Location:= Puint32(VESA.Framebuffer.Location);
|
||||
Increment:= (Y * VESA.Framebuffer.Width) + X;
|
||||
Location[Increment]:= uint32(Pixel);
|
||||
end;
|
||||
|
||||
end.
|
27
src/include/color.pas
Normal file
27
src/include/color.pas
Normal file
@ -0,0 +1,27 @@
|
||||
unit color;
|
||||
|
||||
interface
|
||||
|
||||
type
|
||||
TRGB32 = bitpacked record
|
||||
B : uint8;
|
||||
G : uint8;
|
||||
R : uint8;
|
||||
A : uint8;
|
||||
end;
|
||||
|
||||
TRGB16 = bitpacked record
|
||||
B : UBit5;
|
||||
G : UBit6;
|
||||
R : UBit5;
|
||||
end;
|
||||
|
||||
TRGB8 = bitpacked record
|
||||
B : UBit2;
|
||||
G : UBit4;
|
||||
R : UBit2;
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
end.
|
@ -54,7 +54,7 @@ uses
|
||||
base64,
|
||||
rand,
|
||||
terminal,
|
||||
hashmap, vfs;
|
||||
hashmap, vfs, video;
|
||||
|
||||
procedure kmain(mbinfo: Pmultiboot_info_t; mbmagic: uint32); stdcall;
|
||||
|
||||
@ -135,6 +135,8 @@ begin
|
||||
multibootinfo:= mbinfo;
|
||||
multibootmagic:= mbmagic;
|
||||
|
||||
//video.init();
|
||||
|
||||
{ Ensure tracer is frozen }
|
||||
tracer.freeze();
|
||||
|
||||
@ -263,6 +265,8 @@ begin
|
||||
|
||||
tracer.push_trace('kmain.TICK');
|
||||
|
||||
video.init();
|
||||
|
||||
while true do begin
|
||||
tracer.push_trace('kmain.RedrawWindows');
|
||||
console.redrawWindows;
|
||||
|
@ -77,9 +77,9 @@ dd 0
|
||||
dd 0
|
||||
dd 0
|
||||
dd 0
|
||||
dd 1280
|
||||
dd 1024
|
||||
dd 16
|
||||
dd 1600
|
||||
dd 1200
|
||||
dd 32
|
||||
|
||||
;
|
||||
; Entrypoint
|
||||
|
Loading…
x
Reference in New Issue
Block a user