Enable native desktop applications and synchronized resolution changes

This commit is contained in:
Aaron committed 2026-11-08 09:02:34 +00:00
1 parent b71e6d67b4
commit e462165049
28 files changed
+459 -428

No files matched your search

+1 -1
View File
@@ -22,7 +22,7 @@ unit app.base64;
interface
uses
io.stdio, core.util, arch.x86.util, core.strings, debug.tracer, core.enc.base64, memory.heap;
io.stdio, core.util, arch.platform.cpu, core.strings, debug.tracer, core.enc.base64, memory.heap;
procedure init();
+2 -2
View File
@@ -25,7 +25,7 @@ uses
core.strings,
io.stdio,
debug.tracer,
core.util, arch.x86.util,
core.util, arch.platform.cpu,
driver.storage.vol.mgr;
var
@@ -254,7 +254,7 @@ begin
{ Allocate a zero buffer - 64 sectors at a time }
bufSects := 64;
buf := puint32(kalloc(bufSects * device^.sectorSize));
memset(uint32(buf), 0, bufSects * device^.sectorSize);
memset(PtrUInt(buf), 0, bufSects * device^.sectorSize);
print('Wiping device ');
printint(idx);
+12 -11
View File
@@ -34,7 +34,7 @@ uses
driver.video,
driver.storage.vol.mgr,
driver.video.windows,
core.util, arch.x86.util;
core.util, arch.platform.cpu;
const
WIN_W = 740;
@@ -129,9 +129,9 @@ begin
item := PUIText(kalloc(sizeof(TUIText)+n+m+1));
if item = nil then exit;
item^.Next := TextTemps; TextTemps := item;
dest := pchar(uint32(item)+sizeof(TUIText));
if n > 0 then memcpy(uint32(a), uint32(dest), n);
if m > 0 then memcpy(uint32(b), uint32(dest)+n, m);
dest := pchar(PtrUInt(item)+sizeof(TUIText));
if n > 0 then memcpy(PtrUInt(a), PtrUInt(dest), n);
if m > 0 then memcpy(PtrUInt(b), PtrUInt(dest)+n, m);
dest[n+m] := #0; uiConcat := dest;
end;
@@ -606,7 +606,7 @@ begin
end;
end;
memset(uint32(@part), 0, sizeof(TPartition_table));
memset(PtrUInt(@part), 0, sizeof(TPartition_table));
driver.storage.vol.mbr.setup_partition(@part, lba, sectors);
cbCtx := begin_partition_ui(1);
if cbCtx = nil then exit;
@@ -702,18 +702,19 @@ end;
procedure operation_done(error : TError; userdata : pointer);
var
ctx : PFmtUICallbackCtx;
flags : uint32;
flags : PtrUInt;
begin
ctx := PFmtUICallbackCtx(userdata);
if ctx <> nil then begin
asm pushfd; cli; pop flags end;
flags := arch.platform.cpu.lock;
if ctx^.SessionID = ui_session_id then begin
fmt_done_error := error;
fmt_done_vol_idx := ctx^.VolumeIdx;
done_kind := ctx^.Kind; done_device := ctx^.DeviceIdx;
done_kind := ctx^.Kind;
done_device := ctx^.DeviceIdx;
puint32(@fmt_done_flag)^ := 1;
end;
if (flags and $200) <> 0 then asm sti end;
arch.platform.cpu.unlock(flags);
kfree(void(ctx));
end;
end;
@@ -824,7 +825,7 @@ begin
fs := driver.storage.fs.mgr.get_filesystem(selIdx);
if fs = nil then begin closeMsgBox; exit; end;
memset(uint32(@params), 0, sizeof(TFSFormatParams));
memset(PtrUInt(@params), 0, sizeof(TFSFormatParams));
params.Version := FS_FORMAT_PARAMS_VERSION_1;
paramPtr := nil;
@@ -874,7 +875,7 @@ begin
if fs^.validateLabelCallback(text,normalized) <> eNone then begin
set_fmt_param_error('Use up to 11 ASCII characters without punctuation such as / or :'); exit;
end;
memcpy(uint32(@normalized[0]),uint32(@params.LabelText[0]),12);
memcpy(PtrUInt(@normalized[0]),PtrUInt(@params.LabelText[0]),12);
params.Flags := params.Flags or FS_FORMAT_PARAM_LABEL; paramPtr := @params;
end;
+9 -9
View File
@@ -32,7 +32,7 @@ uses
core.gfx.fileicons,
debug.tracer,
core.util,
arch.x86.util;
arch.platform.cpu;
const
WIN_W = 800;
@@ -785,9 +785,9 @@ begin
dir_names := PNameBuf(kalloc(sizeof(TNameBuf)));
file_names := PNameBuf(kalloc(sizeof(TNameBuf)));
file_sizes := PSizeBuf(kalloc(sizeof(TSizeBuf)));
memset(uint32(dir_names), 0, sizeof(TNameBuf));
memset(uint32(file_names), 0, sizeof(TNameBuf));
memset(uint32(file_sizes), 0, sizeof(TSizeBuf));
memset(PtrUInt(dir_names), 0, sizeof(TNameBuf));
memset(PtrUInt(file_names), 0, sizeof(TNameBuf));
memset(PtrUInt(file_sizes), 0, sizeof(TSizeBuf));
{ Load directory from VFS — this may do disk I/O }
Map := driver.storage.vfs.GetDirectoryListingFrom(state^.cur_path, '/');
@@ -1330,7 +1330,7 @@ begin
parent := stringCopy('/')
else begin
parent := pchar(kalloc(uint32(i) + 1));
memcpy(uint32(cur), uint32(parent), uint32(i));
memcpy(PtrUInt(cur), PtrUInt(parent), uint32(i));
parent[i] := char(0);
end;
navigate_to(state, parent);
@@ -1440,7 +1440,7 @@ begin
{ Segment name label }
segBuf := pchar(kalloc(segEnd - segStart + 1));
memcpy(uint32(@path[segStart]), uint32(segBuf), segEnd - segStart);
memcpy(PtrUInt(@path[segStart]), uint32(segBuf), segEnd - segStart);
segBuf[segEnd - segStart] := char(0);
lbl := lv_label_create(btn);
lv_label_set_text(lbl, segBuf);
@@ -1979,7 +1979,7 @@ begin
if state^.tabs[idx] <> nil then
free_tab_snapshot(state^.tabs[idx]);
snap := PTabSnapshot(kalloc(sizeof(TTabSnapshot)));
memset(uint32(snap), 0, sizeof(TTabSnapshot));
memset(PtrUInt(snap), 0, sizeof(TTabSnapshot));
if state^.cur_path <> nil then
snap^.cur_path := stringCopy(state^.cur_path)
else
@@ -2090,7 +2090,7 @@ begin
save_tab(state, state^.active_tab);
{ Create snapshot for new tab }
snap := PTabSnapshot(kalloc(sizeof(TTabSnapshot)));
memset(uint32(snap), 0, sizeof(TTabSnapshot));
memset(PtrUInt(snap), 0, sizeof(TTabSnapshot));
snap^.cur_path := stringCopy(path);
snap^.hist_len := 0;
snap^.hist_pos := 0;
@@ -3053,7 +3053,7 @@ begin
{ Allocate and zero-initialise state }
state := PFileBrowserState(kalloc(sizeof(TFileBrowserState)));
memset(uint32(state), 0, sizeof(TFileBrowserState));
memset(PtrUInt(state), 0, sizeof(TFileBrowserState));
state^.win_id := g_win_id;
state^.cur_path := stringCopy('/');
state^.view_mode := vmDetail;
+5 -5
View File
@@ -64,7 +64,7 @@ uses
core.strings.helpers,
io.syslog,
debug.tracer,
core.util, arch.x86.util,
core.util, arch.platform.cpu,
driver.storage.vfs;
const
@@ -325,9 +325,9 @@ begin
dir_names := PNameBuf(kalloc(sizeof(TNameBuf)));
file_names := PNameBuf(kalloc(sizeof(TNameBuf)));
file_sizes := PSizeBuf(kalloc(sizeof(TSizeBuf)));
memset(uint32(dir_names), 0, sizeof(TNameBuf));
memset(uint32(file_names), 0, sizeof(TNameBuf));
memset(uint32(file_sizes), 0, sizeof(TSizeBuf));
memset(PtrUInt(dir_names), 0, sizeof(TNameBuf));
memset(PtrUInt(file_names), 0, sizeof(TNameBuf));
memset(PtrUInt(file_sizes), 0, sizeof(TSizeBuf));
{ Sync path bar }
if p^.path_bar <> nil then
@@ -898,7 +898,7 @@ begin
io.syslog.logln('FPCIK', 'make_picker: enter');
p := PPicker(kalloc(sizeof(TPicker)));
memset(uint32(p), 0, sizeof(TPicker));
memset(PtrUInt(p), 0, sizeof(TPicker));
p^.cb := cb;
p^.userdata := userdata;
p^.is_save := is_save;
+7 -2
View File
@@ -22,7 +22,7 @@ unit app.md5sum;
interface
uses
io.stdio, core.util, arch.x86.util, core.strings, debug.tracer, core.enc.md5;
memory.heap, io.stdio, core.util, arch.platform.cpu, core.strings, debug.tracer, core.enc.md5;
procedure init();
@@ -36,6 +36,10 @@ var
i : uint32;
begin
if paramCount(Params) = 0 then begin
io.stdio.bufWriteStrLn(stderr_buf, 'Usage: MD5SUM <word>');
exit;
end;
md5word:= getParam(0, Params);
wordlen:= stringSize(md5word);
MD5_Hash := MD5Buffer(puint8(md5word), wordlen);
@@ -43,6 +47,7 @@ begin
io.stdio.bufWriteHexPair(stdout_buf, MD5_Hash^[i]);
end;
io.stdio.bufWriteStrLn(stdout_buf, ' ');
memory.heap.kfree(void(MD5_Hash));
end;
procedure init();
@@ -51,4 +56,4 @@ begin
io.stdio.registerCommand('MD5SUM', @Run, 'Perform MD5SUM on a word.');
end;
end.
end.
+23 -43
View File
@@ -22,7 +22,7 @@ unit app.meminfo;
interface
uses
io.stdio, arch.x86.multiboot, arch.x86.memory.physical, memory.heap, debug.tracer;
io.stdio, arch.platform.memory, memory.heap, debug.tracer;
procedure init();
@@ -30,50 +30,30 @@ implementation
procedure run(Params : PParamList; stdin_buf, stdout_buf, stderr_buf : POutBuf);
var
pmm_total, pmm_free, pmm_used : uint32;
lmm_pages, lmm_free : uint32;
total, available: uint64;
heapPages: uint32;
begin
{ Multiboot memory info }
io.stdio.bufWriteStrLn(stdout_buf, '--- Multiboot ---');
io.stdio.bufWriteStr(stdout_buf, 'Lower Memory : ');
io.stdio.bufWriteInt(stdout_buf, multibootinfo^.mem_lower);
io.stdio.bufWriteStrLn(stdout_buf, ' KB');
io.stdio.bufWriteStr(stdout_buf, 'Upper Memory : ');
io.stdio.bufWriteInt(stdout_buf, multibootinfo^.mem_upper);
io.stdio.bufWriteStrLn(stdout_buf, ' KB');
io.stdio.bufWriteStr(stdout_buf, 'Total Memory : ');
io.stdio.bufWriteInt(stdout_buf, ((multibootinfo^.mem_upper + 1000) div 1024) + 1);
io.stdio.bufWriteStrLn(stdout_buf, ' MB');
{ PMM stats }
io.stdio.bufWriteStrLn(stdout_buf, '--- PMM (4 MB blocks) ---');
pmm_total := arch.x86.memory.physical.pmm_total_blocks;
pmm_free := arch.x86.memory.physical.pmm_free_blocks;
pmm_used := pmm_total - pmm_free;
io.stdio.bufWriteStr(stdout_buf, 'Total Blocks : ');
io.stdio.bufWriteIntLn(stdout_buf, pmm_total);
io.stdio.bufWriteStr(stdout_buf, 'Free Blocks : ');
io.stdio.bufWriteIntLn(stdout_buf, pmm_free);
io.stdio.bufWriteStr(stdout_buf, 'Used Blocks : ');
io.stdio.bufWriteIntLn(stdout_buf, pmm_used);
io.stdio.bufWriteStr(stdout_buf, 'Free Physical : ');
io.stdio.bufWriteInt(stdout_buf, pmm_free * 4);
io.stdio.bufWriteStrLn(stdout_buf, ' MB');
{ LMM heap stats }
io.stdio.bufWriteStrLn(stdout_buf, '--- LMM (Heap) ---');
lmm_pages := memory.heap.lmm_page_count;
lmm_free := memory.heap.lmm_total_free;
io.stdio.bufWriteStr(stdout_buf, 'Heap Pages : ');
io.stdio.bufWriteIntLn(stdout_buf, lmm_pages);
io.stdio.bufWriteStr(stdout_buf, 'Heap Size : ');
io.stdio.bufWriteInt(stdout_buf, lmm_pages * 4);
io.stdio.bufWriteStrLn(stdout_buf, ' MB');
io.stdio.bufWriteStr(stdout_buf, 'Heap Free : ');
io.stdio.bufWriteInt(stdout_buf, lmm_free div 1024);
io.stdio.bufWriteStrLn(stdout_buf, ' KB');
total := arch.platform.memory.totalPhysicalBytes;
available := arch.platform.memory.freePhysicalBytes;
io.stdio.bufWriteStr(stdout_buf, 'Usable Physical: ');
io.stdio.bufWriteInt(stdout_buf, total div 1024);
io.stdio.bufWriteStrLn(stdout_buf, ' KiB');
io.stdio.bufWriteStr(stdout_buf, 'Free Physical : ');
io.stdio.bufWriteInt(stdout_buf, available div 1024);
io.stdio.bufWriteStrLn(stdout_buf, ' KiB');
io.stdio.bufWriteStr(stdout_buf, 'Used Physical : ');
io.stdio.bufWriteInt(stdout_buf, (total - available) div 1024);
io.stdio.bufWriteStrLn(stdout_buf, ' KiB');
heapPages := memory.heap.lmm_page_count;
io.stdio.bufWriteStr(stdout_buf, 'Heap Regions : ');
io.stdio.bufWriteIntLn(stdout_buf, heapPages);
io.stdio.bufWriteStr(stdout_buf, 'Heap Size : ');
io.stdio.bufWriteInt(stdout_buf, uint64(heapPages) * PAGE_SIZE_LMM div 1024);
io.stdio.bufWriteStrLn(stdout_buf, ' KiB');
io.stdio.bufWriteStr(stdout_buf, 'Heap Free : ');
io.stdio.bufWriteInt(stdout_buf, memory.heap.lmm_total_free div 1024);
io.stdio.bufWriteStrLn(stdout_buf, ' KiB');
end;
procedure init();
begin
debug.tracer.push_trace('meminfo.init');
+14 -29
View File
@@ -11,8 +11,7 @@
- Status bar showing Line, Col, filename, and dirty flag
Key design notes:
- lv_event_t.stop_processing (bit 1 at struct byte offset 24) is set
directly to prevent LVGL's default textarea key handler from also
- lv_event_stop_processing prevents LVGL's default textarea handler from also
acting on keys we have fully handled ourselves.
- Shift state is read from driver.hid.keyboard.is_shift / driver.hid.keyboard.is_ctrl.
- selection anchor (sel_anchor) is stored as a sint32 byte offset;
@@ -43,7 +42,7 @@ uses
io.syslog,
io.stdio,
debug.tracer,
core.util, arch.x86.util,
core.util, arch.platform.cpu,
driver.storage.vfs,
driver.video,
driver.video.windows;
@@ -62,19 +61,6 @@ const
FILE_BUF_SIZE = 65536; { 64 KB read / write buffer }
{
Byte offset and bitmask for lv_event_t.stop_processing.
struct lv_event_t (32-bit ABI):
offset 0: current_target (ptr)
offset 4: original_target (ptr)
offset 8: code (uint32 — lv_event_code_t)
offset 12: user_data (ptr)
offset 16: param (ptr)
offset 20: prev (ptr)
offset 24: flags byte [bit0=deleted, bit1=stop_processing, bit2=stop_bubbling]
}
LV_EVT_STOP_OFF = 24;
LV_EVT_STOP_BIT = 2; { bit 1 = stop_processing }
type
PNotepadState = ^TNotepadState;
@@ -130,8 +116,7 @@ procedure removeInstance(state: PNotepadState); forward;
============================================================ }
procedure stopEvent(e: Plv_event);
begin
puint8(uint32(e) + LV_EVT_STOP_OFF)^ :=
puint8(uint32(e) + LV_EVT_STOP_OFF)^ or LV_EVT_STOP_BIT;
lv_event_stop_processing(e);
end;
{ ============================================================
@@ -157,18 +142,18 @@ begin
if to_idx < from_idx then to_idx := from_idx;
result_len := from_idx + ins_len + (src_len - to_idx);
buf := pchar(kalloc(result_len + 1));
memset(uint32(buf), 0, result_len + 1);
memset(PtrUInt(buf), 0, result_len + 1);
pos := 0;
if from_idx > 0 then begin
memcpy(uint32(src), uint32(buf), from_idx);
memcpy(PtrUInt(src), PtrUInt(buf), from_idx);
pos := from_idx;
end;
if ins_len > 0 then begin
memcpy(uint32(insert), uint32(@buf[pos]), ins_len);
memcpy(PtrUInt(insert), PtrUInt(@buf[pos]), ins_len);
pos := pos + ins_len;
end;
if to_idx < src_len then
memcpy(uint32(@src[to_idx]), uint32(@buf[pos]), src_len - to_idx);
memcpy(PtrUInt(@src[to_idx]), PtrUInt(@buf[pos]), src_len - to_idx);
buildSplicedString := buf;
end;
@@ -198,12 +183,12 @@ begin
{ Generous output buffer: original + 4 bytes per line (worst case ~512 lines) }
out_buf := pchar(kalloc(src_len + 2049));
memset(uint32(out_buf), 0, src_len + 2049);
memset(PtrUInt(out_buf), 0, src_len + 2049);
out_pos := 0;
{ Copy everything before the affected region verbatim }
if first_ls > 0 then begin
memcpy(uint32(src), uint32(out_buf), first_ls);
memcpy(PtrUInt(src), PtrUInt(out_buf), first_ls);
out_pos := first_ls;
end;
@@ -215,7 +200,7 @@ begin
if i >= sel_end then begin
{ Past the affected region: copy the remainder verbatim }
if i < src_len then begin
memcpy(uint32(@src[i]), uint32(@out_buf[out_pos]), src_len - i);
memcpy(PtrUInt(@src[i]), PtrUInt(@out_buf[out_pos]), src_len - i);
out_pos := out_pos + (src_len - i);
end;
break;
@@ -426,8 +411,8 @@ begin
len := stringSize(txt);
if len > FILE_BUF_SIZE - 1 then len := FILE_BUF_SIZE - 1;
buf := pchar(kalloc(FILE_BUF_SIZE));
memset(uint32(buf), 0, FILE_BUF_SIZE);
memcpy(uint32(txt), uint32(buf), len);
memset(PtrUInt(buf), 0, FILE_BUF_SIZE);
memcpy(PtrUInt(txt), PtrUInt(buf), len);
fHandle := driver.storage.vfs.OpenFile(state^.currentPath, omReadWrite, @fError);
if fHandle = 0 then
fHandle := driver.storage.vfs.OpenFile(state^.currentPath, omCreate, @fError);
@@ -477,7 +462,7 @@ begin
exit;
end;
buf := pchar(kalloc(FILE_BUF_SIZE));
memset(uint32(buf), 0, FILE_BUF_SIZE);
memset(PtrUInt(buf), 0, FILE_BUF_SIZE);
driver.storage.vfs.ReadFile(fHandle, 0, puint8(buf), FILE_BUF_SIZE - 1);
driver.storage.vfs.CloseFile(fHandle);
if state^.currentPath <> nil then kfree(void(state^.currentPath));
@@ -943,7 +928,7 @@ begin
{ Allocate and zero-initialise state }
state := PNotepadState(kalloc(sizeof(TNotepadState)));
memset(uint32(state), 0, sizeof(TNotepadState));
memset(PtrUInt(state), 0, sizeof(TNotepadState));
state^.win_id := wid;
state^.sel_anchor := -1;
addInstance(state);
+6 -2
View File
@@ -14,7 +14,7 @@ unit app.setres;
interface
uses
io.stdio, driver.video.gpu, core.util, arch.x86.util, core.strings, debug.tracer, io.syslog;
io.stdio, driver.video.lvgl, driver.video.gpu, core.util, arch.platform.cpu, core.strings, debug.tracer, io.syslog;
procedure init();
@@ -25,6 +25,7 @@ var
w, h : uint32;
wStr, hStr : pchar;
info : TGPUModeInfo;
changed: boolean;
begin
debug.tracer.push_trace('setres.run');
@@ -55,7 +56,10 @@ begin
io.stdio.bufWriteStrLn(stdout_buf, 'x32...');
{ Step 1: Set display mode via GPU framework (tries BGA first, then VBE) }
if not driver.video.gpu.setMode(w, h, 32, info) then begin
driver.video.lvgl.lvgl_lock;
changed := driver.video.gpu.setMode(w, h, 32, info);
driver.video.lvgl.lvgl_unlock;
if not changed then begin
io.stdio.bufWriteStrLn(stderr_buf, 'Error: Mode switch failed. Mode may not be supported.');
debug.tracer.pop_trace;
exit;
+1 -1
View File
@@ -19,7 +19,7 @@ unit app.uidebug;
interface
uses
driver.video.lvgl, driver.video.windows, driver.hid.mouse, driver.video, arch.x86.multiboot, debug.tracer;
driver.video.lvgl, driver.video.windows, driver.hid.mouse, driver.video, boot.multiboot, debug.tracer;
{ Call once per frame from the main loop (before lvgl_handler). }
procedure update;
File diff suppressed because it is too large. Load diff