Initial LVGL modifications
Basic LVGL wrapper with an example desktop & windowing system.
This commit is contained in:
1 parent
ceb03a9d7e
commit
989e36ffe2
17 files changed
+3380
-95
No files matched your search
@@ -51,6 +51,11 @@ type
|
||||
|
||||
procedure init();
|
||||
procedure DrawCursor;
|
||||
function getMouseX: sint32;
|
||||
function getMouseY: sint32;
|
||||
function getMouseLMB: boolean;
|
||||
function getMouseRMB: boolean;
|
||||
function getMouseScroll: sint32; { returns accumulated scroll delta since last call }
|
||||
|
||||
implementation
|
||||
|
||||
@@ -59,7 +64,7 @@ var
|
||||
FirstDraw : boolean = true;
|
||||
BackPixels : Array[0..1] of Array[0..7] of uint64;
|
||||
Cycle : uint32 = 0;
|
||||
Mouse_Byte : Array[0..2] of uint8;
|
||||
Mouse_Byte : Array[0..3] of uint8;
|
||||
Packet : uint32;
|
||||
Registered : Boolean = false;
|
||||
NeedsRedraw : Boolean = false;
|
||||
@@ -67,6 +72,35 @@ var
|
||||
LMouseDownPos : TMousePos;
|
||||
LMouseDown : Boolean;
|
||||
RMouseDown : Boolean;
|
||||
HasScrollWheel : Boolean = false;
|
||||
ScrollAccum : sint32 = 0;
|
||||
PacketSize : uint32 = 3;
|
||||
|
||||
function getMouseX: sint32;
|
||||
begin
|
||||
getMouseX := Current.x;
|
||||
end;
|
||||
|
||||
function getMouseY: sint32;
|
||||
begin
|
||||
getMouseY := Current.y;
|
||||
end;
|
||||
|
||||
function getMouseLMB: boolean;
|
||||
begin
|
||||
getMouseLMB := LMouseDown;
|
||||
end;
|
||||
|
||||
function getMouseRMB: boolean;
|
||||
begin
|
||||
getMouseRMB := RMouseDown;
|
||||
end;
|
||||
|
||||
function getMouseScroll: sint32;
|
||||
begin
|
||||
getMouseScroll := ScrollAccum;
|
||||
ScrollAccum := 0;
|
||||
end;
|
||||
|
||||
procedure DrawCursor;
|
||||
var
|
||||
@@ -151,7 +185,7 @@ begin
|
||||
Mouse_Byte[Cycle]:= b;
|
||||
Inc(Cycle);
|
||||
end;
|
||||
if Cycle = 3 then begin
|
||||
if Cycle = PacketSize then begin
|
||||
//Process
|
||||
f:= Mouse_Byte[0];
|
||||
Packet.x_sign:= (f AND %00010000) = %00010000;
|
||||
@@ -173,6 +207,10 @@ begin
|
||||
if Current.x > (Console.getConsoleProperties^.Width-8) then Current.x:= (Console.getConsoleProperties^.Width-8);
|
||||
if Current.y > (Console.getConsoleProperties^.Height-8) then Current.y:= (Console.getConsoleProperties^.Height-8);
|
||||
end;
|
||||
{ Process scroll wheel (4th byte, signed) }
|
||||
if HasScrollWheel then begin
|
||||
ScrollAccum := ScrollAccum + sint8(Mouse_Byte[3]);
|
||||
end;
|
||||
Cycle:= 0;
|
||||
if Packet.LMB_Down then begin
|
||||
if not LMouseDown then begin
|
||||
@@ -217,7 +255,8 @@ end;
|
||||
|
||||
function load(ptr : void) : boolean;
|
||||
var
|
||||
status : uint8;
|
||||
status : uint8;
|
||||
devid_byte : uint8;
|
||||
begin
|
||||
push_trace('mouse.load');
|
||||
mouse_wait(1);
|
||||
@@ -232,6 +271,26 @@ begin
|
||||
outb($60, status);
|
||||
mouse_write($F6);
|
||||
mouse_read();
|
||||
|
||||
{ Enable IntelliMouse scroll wheel: set sample rate 200, 100, 80 }
|
||||
mouse_write($F3); mouse_read(); mouse_write(200); mouse_read();
|
||||
mouse_write($F3); mouse_read(); mouse_write(100); mouse_read();
|
||||
mouse_write($F3); mouse_read(); mouse_write(80); mouse_read();
|
||||
|
||||
{ Query device ID — ID 3 = IntelliMouse (scroll wheel) }
|
||||
mouse_write($F2);
|
||||
mouse_read(); { ACK }
|
||||
devid_byte := mouse_read(); { Device ID }
|
||||
if devid_byte = 3 then begin
|
||||
HasScrollWheel := true;
|
||||
PacketSize := 4;
|
||||
console.outputln('PS/2 MOUSE', 'Scroll wheel enabled (IntelliMouse).');
|
||||
end else begin
|
||||
HasScrollWheel := false;
|
||||
PacketSize := 3;
|
||||
console.outputln('PS/2 MOUSE', 'Standard mouse (no scroll wheel).');
|
||||
end;
|
||||
|
||||
mouse_write($F4);
|
||||
mouse_read();
|
||||
isrmanager.registerISR(44, @Main);
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
@@ -40,6 +40,8 @@ function frontBufferBpp : uint8;
|
||||
function backBufferWidth : uint32;
|
||||
function backBufferHeight : uint32;
|
||||
function backBufferBpp : uint8;
|
||||
function backBufferLocation : uint32;
|
||||
function frontBufferLocation : uint32;
|
||||
|
||||
Procedure basicFDrawTexture(Buffer : PVideoBuffer; X : uint32; Y : uint32; Texture : PTexture);
|
||||
|
||||
@@ -315,4 +317,14 @@ begin
|
||||
backBufferBpp:= VideoInterface.BackBuffer.BitsPerPixel;
|
||||
end;
|
||||
|
||||
function backBufferLocation : uint32;
|
||||
begin
|
||||
backBufferLocation:= VideoInterface.BackBuffer.Location;
|
||||
end;
|
||||
|
||||
function frontBufferLocation : uint32;
|
||||
begin
|
||||
frontBufferLocation:= VideoInterface.FrontBuffer.Location;
|
||||
end;
|
||||
|
||||
end.
|
||||
File diff suppressed because it is too large.
Load diff
+26
-1
@@ -300,8 +300,33 @@ begin
|
||||
end;
|
||||
|
||||
function intToString(i : uint32) : pchar;
|
||||
var
|
||||
buf : array[0..11] of char;
|
||||
len : uint32;
|
||||
tmp : uint32;
|
||||
result : pchar;
|
||||
j : uint32;
|
||||
begin
|
||||
intToString:= ' ';
|
||||
if i = 0 then begin
|
||||
result := stringNew(1);
|
||||
result[0] := '0';
|
||||
result[1] := #0;
|
||||
intToString := result;
|
||||
exit;
|
||||
end;
|
||||
len := 0;
|
||||
tmp := i;
|
||||
while tmp > 0 do begin
|
||||
buf[len] := char(byte('0') + (tmp mod 10));
|
||||
tmp := tmp div 10;
|
||||
inc(len);
|
||||
end;
|
||||
result := stringNew(len);
|
||||
for j := 0 to len - 1 do begin
|
||||
result[j] := buf[len - 1 - j];
|
||||
end;
|
||||
result[len] := #0;
|
||||
intToString := result;
|
||||
end;
|
||||
|
||||
function boolToString(b : boolean; ext : boolean) : pchar;
|
||||
|
||||
@@ -266,6 +266,8 @@ procedure fpc_shortstr_assign(len: longint; sstr, dstr: Pointer); compilerproc;
|
||||
any int64/uint64 arithmetic occurs (e.g. sint32 * uint32 promotion).
|
||||
Must live in the system unit so the compiler can resolve it. }
|
||||
function fpc_mul_int64(f1, f2: int64): int64; compilerproc;
|
||||
function fpc_div_int64(n, d: int64): int64; compilerproc;
|
||||
function fpc_mod_int64(n, d: int64): int64; compilerproc;
|
||||
|
||||
{ Memory allocation compilerprocs – delegate to kernel heap (lmemorymanager) }
|
||||
function fpc_getmem(size: PtrUInt): Pointer; compilerproc;
|
||||
@@ -454,6 +456,111 @@ begin
|
||||
fpc_mul_int64 := res;
|
||||
end;
|
||||
|
||||
{ ---------- 64-bit division / modulo ---------- }
|
||||
|
||||
{ Helper: unsigned 64÷64→64 using shift-subtract (binary long division).
|
||||
Called by both signed div and mod after sign handling. }
|
||||
procedure udiv64(dividendLo, dividendHi, divisorLo, divisorHi: uint32;
|
||||
var quotLo, quotHi, remLo, remHi: uint32);
|
||||
var
|
||||
bit: longint;
|
||||
begin
|
||||
quotLo := 0; quotHi := 0;
|
||||
remLo := 0; remHi := 0;
|
||||
|
||||
for bit := 63 downto 0 do begin
|
||||
{ rem := rem shl 1 }
|
||||
remHi := (remHi shl 1) or (remLo shr 31);
|
||||
remLo := remLo shl 1;
|
||||
|
||||
{ bring down next bit of dividend }
|
||||
if bit >= 32 then begin
|
||||
remLo := remLo or ((dividendHi shr (bit - 32)) and 1);
|
||||
end else begin
|
||||
remLo := remLo or ((dividendLo shr bit) and 1);
|
||||
end;
|
||||
|
||||
{ if rem >= divisor then rem -= divisor; set quotient bit }
|
||||
if (remHi > divisorHi) or
|
||||
((remHi = divisorHi) and (remLo >= divisorLo)) then begin
|
||||
{ rem -= divisor (64-bit subtract) }
|
||||
if remLo < divisorLo then begin
|
||||
remHi := remHi - divisorHi - 1;
|
||||
remLo := remLo - divisorLo;
|
||||
end else begin
|
||||
remHi := remHi - divisorHi;
|
||||
remLo := remLo - divisorLo;
|
||||
end;
|
||||
{ set quotient bit }
|
||||
if bit >= 32 then
|
||||
quotHi := quotHi or (uint32(1) shl (bit - 32))
|
||||
else
|
||||
quotLo := quotLo or (uint32(1) shl bit);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
function fpc_div_int64(n, d: int64): int64; [public, alias: 'FPC_DIV_INT64']; compilerproc;
|
||||
var
|
||||
negate: boolean;
|
||||
nLo, nHi, dLo, dHi: uint32;
|
||||
qLo, qHi, rLo, rHi: uint32;
|
||||
begin
|
||||
if d = 0 then begin
|
||||
HandleErrorInternal(200); { divide by zero }
|
||||
fpc_div_int64 := 0;
|
||||
exit;
|
||||
end;
|
||||
|
||||
negate := false;
|
||||
|
||||
{ Make both operands positive, track sign }
|
||||
if n < 0 then begin
|
||||
n := -n;
|
||||
negate := not negate;
|
||||
end;
|
||||
if d < 0 then begin
|
||||
d := -d;
|
||||
negate := not negate;
|
||||
end;
|
||||
|
||||
nLo := uint32(n); nHi := uint32(n shr 32);
|
||||
dLo := uint32(d); dHi := uint32(d shr 32);
|
||||
|
||||
udiv64(nLo, nHi, dLo, dHi, qLo, qHi, rLo, rHi);
|
||||
|
||||
fpc_div_int64 := int64(qLo) or (int64(qHi) shl 32);
|
||||
if negate then
|
||||
fpc_div_int64 := -fpc_div_int64;
|
||||
end;
|
||||
|
||||
function fpc_mod_int64(n, d: int64): int64; [public, alias: 'FPC_MOD_INT64']; compilerproc;
|
||||
var
|
||||
nNeg: boolean;
|
||||
nLo, nHi, dLo, dHi: uint32;
|
||||
qLo, qHi, rLo, rHi: uint32;
|
||||
begin
|
||||
if d = 0 then begin
|
||||
HandleErrorInternal(200); { divide by zero }
|
||||
fpc_mod_int64 := 0;
|
||||
exit;
|
||||
end;
|
||||
|
||||
nNeg := n < 0;
|
||||
|
||||
if n < 0 then n := -n;
|
||||
if d < 0 then d := -d;
|
||||
|
||||
nLo := uint32(n); nHi := uint32(n shr 32);
|
||||
dLo := uint32(d); dHi := uint32(d shr 32);
|
||||
|
||||
udiv64(nLo, nHi, dLo, dHi, qLo, qHi, rLo, rHi);
|
||||
|
||||
fpc_mod_int64 := int64(rLo) or (int64(rHi) shl 32);
|
||||
if nNeg then
|
||||
fpc_mod_int64 := -fpc_mod_int64;
|
||||
end;
|
||||
|
||||
{ ---------- Memory allocation compilerprocs ---------- }
|
||||
|
||||
function kernel_kalloc(size: uint32): Pointer; external name 'kernel_kalloc';
|
||||
|
||||
+21
-84
@@ -55,7 +55,7 @@ uses
|
||||
rand,
|
||||
terminal,
|
||||
hashmap, vfs,
|
||||
video, vesa, doublebuffer, color;
|
||||
video, vesa, doublebuffer, color, lvgl, desktop, uidebug;
|
||||
|
||||
procedure kmain(mbinfo: Pmultiboot_info_t; mbmagic: uint32); stdcall;
|
||||
|
||||
@@ -108,27 +108,8 @@ end;
|
||||
|
||||
procedure kmain(mbinfo: Pmultiboot_info_t; mbmagic: uint32); stdcall; [public, alias: 'kmain'];
|
||||
var
|
||||
c : uint8;
|
||||
z : uint32;
|
||||
dds : uint32;
|
||||
pint : puint32;
|
||||
pint2 : puint32;
|
||||
keyboard_layout : array [0..1] of TKeyInfo;
|
||||
i : uint32;
|
||||
cEIP : uint32;
|
||||
temp : uint32;
|
||||
atmp : puint32;
|
||||
test : puint8;
|
||||
fb : puint16;
|
||||
l : PLinkedListBase;
|
||||
ulf : pointer;
|
||||
|
||||
HM : PHashMap;
|
||||
|
||||
colour : TRGB32;
|
||||
|
||||
array1 : Array[0..255] of char;
|
||||
array2 : Array[0..255] of char;
|
||||
|
||||
begin
|
||||
{ Init the base system unit }
|
||||
@@ -214,47 +195,6 @@ begin
|
||||
doublebuffer.init(@video.register);
|
||||
video.enable('VESA');
|
||||
video.enable('BASIC_DOUBLE_BUFFER');
|
||||
colour:= color.white;
|
||||
|
||||
// serial.sendHex(uint32(@array1[8]));
|
||||
// serial.sendHex(uint32(@array2[8]));
|
||||
// for i:=8 to 23 do begin
|
||||
// array2[i]:= '?';
|
||||
// end;
|
||||
// array2[24]:= #0;
|
||||
|
||||
// array1[8]:= 'H';
|
||||
// array1[9]:= 'e';
|
||||
// array1[10]:= 'l';
|
||||
// array1[11]:= 'l';
|
||||
// array1[12]:= 'o';
|
||||
// array1[13]:= 'w';
|
||||
// array1[14]:= 'o';
|
||||
// array1[15]:= 'r';
|
||||
// array1[16]:= 'l';
|
||||
// array1[17]:= 'd';
|
||||
// array1[18]:= '1';
|
||||
// array1[19]:= '2';
|
||||
// array1[20]:= '3';
|
||||
// array1[21]:= '4';
|
||||
// array1[22]:= '5';
|
||||
// array1[23]:= '!';
|
||||
// __SSE_128_memcpy(uint32(@array1[8]), uint32(@array2[8]));
|
||||
// serial.sendString(pchar(@array2[8]));
|
||||
|
||||
for i:=0 to video.frontBufferWidth-1 do begin
|
||||
for z:=0 to video.frontBufferHeight-1 do begin
|
||||
video.DrawPixel(i, z, colour);
|
||||
end;
|
||||
end;
|
||||
|
||||
video.DrawLine(50,50,100,100,1,color.black);
|
||||
video.DrawRect(50,150,100,200,1,color.black);
|
||||
video.FillRect(50,250,100,300,1,color.black,color.red);
|
||||
video.DrawLine(50,350,100,350,1,color.black);
|
||||
video.Flush();
|
||||
|
||||
while true do begin end;
|
||||
|
||||
{ VFS Init }
|
||||
vfs.init();
|
||||
@@ -265,15 +205,15 @@ begin
|
||||
tracer.push_trace('kmain.STRMGMT');
|
||||
storagemanagement.init();
|
||||
|
||||
{ Hook Timer for Ticks }
|
||||
{ Enable interrupts and hook timer BEFORE LVGL }
|
||||
tracer.push_trace('kmain.TMR');
|
||||
STI;
|
||||
TMR_0_ISR.hook(uint32(@bios_data_area.tick_update));
|
||||
|
||||
{ Filsystems }
|
||||
{ Filesystems }
|
||||
fat32.init();
|
||||
|
||||
{ Device Drivers }
|
||||
{ Device Drivers — must init before LVGL so mouse/keyboard are available }
|
||||
tracer.push_trace('kmain.DEVDRV');
|
||||
console.outputln('KERNEL', 'DEVICE DRIVERS: INIT BEGIN.');
|
||||
keyboard.init(keyboard_layout);
|
||||
@@ -294,33 +234,30 @@ begin
|
||||
tracer.push_trace('kmain.NETDRV');
|
||||
net.init;
|
||||
|
||||
tracer.push_trace('kmain.VMINIT');
|
||||
//vm.init();
|
||||
|
||||
{ Init Progs }
|
||||
progmanager.init();
|
||||
|
||||
{ Init Splash }
|
||||
//tracer.push_trace('kmain.SPLASHINIT');
|
||||
//splash.init();
|
||||
|
||||
{ End of Boot }
|
||||
tracer.push_trace('kmain.EOB');
|
||||
|
||||
console.writestringln('');
|
||||
console.setdefaultattribute(console.combinecolors($17E0, $0000));
|
||||
console.writestringln('Asuro Booted Correctly!');
|
||||
console.setdefaultattribute(console.combinecolors($FFFF, $0000));
|
||||
writestringln(' ');
|
||||
|
||||
tracer.push_trace('kmain.END');
|
||||
{ Seed RNG }
|
||||
rand.srand((getDateTime.Seconds SHL 24) OR (getDateTime.Minutes SHL 16) OR (getDateTime.Hours SHL 8) OR (getDateTime.Day));
|
||||
|
||||
tracer.push_trace('kmain.TICK');
|
||||
{ Initialize LVGL }
|
||||
console.outputln('KERNEL', 'LVGL: INIT BEGIN.');
|
||||
lvgl_init(video.frontBufferWidth, video.frontBufferHeight);
|
||||
console.outputln('KERNEL', 'LVGL: INIT COMPLETE.');
|
||||
|
||||
{ Initialize desktop environment }
|
||||
console.outputln('KERNEL', 'DESKTOP: INIT BEGIN.');
|
||||
desktop.init;
|
||||
console.outputln('KERNEL', 'DESKTOP: INIT COMPLETE.');
|
||||
|
||||
{ Main render loop }
|
||||
console.outputln('KERNEL', 'Entering main render loop.');
|
||||
tracer.push_trace('kmain.MAINLOOP');
|
||||
while true do begin
|
||||
tracer.push_trace('kmain.RedrawWindows');
|
||||
console.redrawWindows;
|
||||
desktop.update;
|
||||
uidebug.update;
|
||||
lvgl_handler;
|
||||
video.Flush();
|
||||
end;
|
||||
|
||||
end;
|
||||
|
||||
+6
-3
@@ -58,10 +58,13 @@ align 0x1000
|
||||
_PageDirectory equ BootPageDirectory
|
||||
global _PageDirectory
|
||||
BootPageDirectory:
|
||||
dd 0x00000083
|
||||
dd 0x00000083 ; Identity map first 4MB (for boot transition)
|
||||
times (KERNEL_PAGE_NUMBER - 1) dd 0
|
||||
dd 0x00000083
|
||||
times (1024 - KERNEL_PAGE_NUMBER - 1) dd 0
|
||||
dd 0x00000083 ; 0xC0000000 -> phys 0x00000000 (0-4MB)
|
||||
dd 0x00400083 ; 0xC0400000 -> phys 0x00400000 (4-8MB)
|
||||
dd 0x00800083 ; 0xC0800000 -> phys 0x00800000 (8-12MB)
|
||||
dd 0x00C00083 ; 0xC0C00000 -> phys 0x00C00000 (12-16MB)
|
||||
times (1024 - KERNEL_PAGE_NUMBER - 4) dd 0
|
||||
|
||||
section .text
|
||||
;
|
||||
|
||||
Reference in new issue
Block a user