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
+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';
|
||||
|
||||
Reference in new issue
Block a user