diff --git a/src/console.pas b/src/console.pas index a52468dc..cb8cf317 100644 --- a/src/console.pas +++ b/src/console.pas @@ -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); diff --git a/src/driver/video/video.pas b/src/driver/video/video.pas new file mode 100644 index 00000000..511f7646 --- /dev/null +++ b/src/driver/video/video.pas @@ -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. \ No newline at end of file diff --git a/src/include/color.pas b/src/include/color.pas new file mode 100644 index 00000000..4b81efe3 --- /dev/null +++ b/src/include/color.pas @@ -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. \ No newline at end of file diff --git a/src/kernel.pas b/src/kernel.pas index ace9f2a1..462c13e0 100644 --- a/src/kernel.pas +++ b/src/kernel.pas @@ -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; diff --git a/src/stub/stub.asm b/src/stub/stub.asm index 31f879d7..2bb01079 100644 --- a/src/stub/stub.asm +++ b/src/stub/stub.asm @@ -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