implements PLN-0080 shell ui gfxui packet

This commit is contained in:
2026-05-25 14:13:06 +01:00
parent 5e00f6bb0d
commit ae85ed4eff
7 changed files with 92 additions and 7 deletions
@@ -12,8 +12,8 @@ use prometeu_hal::sprite::Sprite;
use prometeu_hal::syscalls::Syscall;
use prometeu_hal::vm_fault::VmFault;
use prometeu_hal::{
AudioOpStatus, ComposerOpStatus, Gfx2dCommand, HostContext, HostReturn, NativeInterface,
SyscallId, expect_bool, expect_int,
AudioOpStatus, ComposerOpStatus, Gfx2dCommand, GfxUiCommand, HostContext, HostReturn,
NativeInterface, SyscallId, expect_bool, expect_int,
};
use std::collections::HashMap;
use std::ops::{Deref, DerefMut};
@@ -198,6 +198,7 @@ impl NativeInterface for VmRuntimeHost<'_> {
));
}
let color = self.get_color(expect_int(args, 0)?)?;
self.gfxui_commands.push(GfxUiCommand::Clear { color });
hw.gfx_mut().clear(color);
Ok(())
}
@@ -224,6 +225,8 @@ impl NativeInterface for VmRuntimeHost<'_> {
let w = expect_int(args, 2)? as i32;
let h = expect_int(args, 3)? as i32;
let color = self.get_color(expect_int(args, 4)?)?;
self.gfxui_commands
.push(GfxUiCommand::FillRect { rect: Rect { x, y, w, h }, color });
hw.gfx_mut().fill_rect(x, y, w, h, color);
Ok(())
}
@@ -255,6 +258,13 @@ impl NativeInterface for VmRuntimeHost<'_> {
let x2 = expect_int(args, 2)? as i32;
let y2 = expect_int(args, 3)? as i32;
let color = self.get_color(expect_int(args, 4)?)?;
self.gfxui_commands.push(GfxUiCommand::DrawLine {
x0: x1,
y0: y1,
x1: x2,
y1: y2,
color,
});
hw.gfx_mut().draw_line(x1, y1, x2, y2, color);
Ok(())
}
@@ -278,6 +288,7 @@ impl NativeInterface for VmRuntimeHost<'_> {
let y = expect_int(args, 1)? as i32;
let r = expect_int(args, 2)? as i32;
let color = self.get_color(expect_int(args, 3)?)?;
self.gfxui_commands.push(GfxUiCommand::DrawCircle { x, y, radius: r, color });
hw.gfx_mut().draw_circle(x, y, r, color);
Ok(())
}
@@ -309,6 +320,13 @@ impl NativeInterface for VmRuntimeHost<'_> {
let r = expect_int(args, 2)? as i32;
let border_color = self.get_color(expect_int(args, 3)?)?;
let fill_color = self.get_color(expect_int(args, 4)?)?;
self.gfxui_commands.push(GfxUiCommand::DrawDisc {
x,
y,
radius: r,
border_color,
fill_color,
});
hw.gfx_mut().draw_disc(x, y, r, border_color, fill_color);
Ok(())
}
@@ -340,6 +358,11 @@ impl NativeInterface for VmRuntimeHost<'_> {
let h = expect_int(args, 3)? as i32;
let border_color = self.get_color(expect_int(args, 4)?)?;
let fill_color = self.get_color(expect_int(args, 5)?)?;
self.gfxui_commands.push(GfxUiCommand::DrawSquare {
rect: Rect { x, y, w, h },
border_color,
fill_color,
});
hw.gfx_mut().draw_square(x, y, w, h, border_color, fill_color);
Ok(())
}
@@ -363,6 +386,7 @@ impl NativeInterface for VmRuntimeHost<'_> {
let y = expect_int(args, 1)? as i32;
let msg = expect_string(args, 2, "message")?;
let color = self.get_color(expect_int(args, 3)?)?;
self.gfxui_commands.push(GfxUiCommand::DrawText { x, y, text: msg.clone(), color });
hw.gfx_mut().draw_text(x, y, &msg, color);
Ok(())
}