implements PLN-0101
This commit is contained in:
parent
18cfeedbff
commit
6f3df74e79
@ -187,7 +187,6 @@ impl NativeInterface for VmRuntimeHost<'_> {
|
|||||||
Syscall::GfxClear => {
|
Syscall::GfxClear => {
|
||||||
let color = self.get_color(expect_int(args, 0)?)?;
|
let color = self.get_color(expect_int(args, 0)?)?;
|
||||||
self.gfx2d_commands.push(Gfx2dCommand::Clear { color });
|
self.gfx2d_commands.push(Gfx2dCommand::Clear { color });
|
||||||
hw.gfx_mut().clear(color);
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
Syscall::GfxUiClear => {
|
Syscall::GfxUiClear => {
|
||||||
@ -199,7 +198,6 @@ impl NativeInterface for VmRuntimeHost<'_> {
|
|||||||
}
|
}
|
||||||
let color = self.get_color(expect_int(args, 0)?)?;
|
let color = self.get_color(expect_int(args, 0)?)?;
|
||||||
self.gfxui_commands.push(GfxUiCommand::Clear { color });
|
self.gfxui_commands.push(GfxUiCommand::Clear { color });
|
||||||
hw.gfx_mut().clear(color);
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
Syscall::GfxFillRect => {
|
Syscall::GfxFillRect => {
|
||||||
@ -210,7 +208,6 @@ impl NativeInterface for VmRuntimeHost<'_> {
|
|||||||
let color = self.get_color(expect_int(args, 4)?)?;
|
let color = self.get_color(expect_int(args, 4)?)?;
|
||||||
self.gfx2d_commands
|
self.gfx2d_commands
|
||||||
.push(Gfx2dCommand::FillRect { rect: Rect { x, y, w, h }, color });
|
.push(Gfx2dCommand::FillRect { rect: Rect { x, y, w, h }, color });
|
||||||
hw.gfx_mut().fill_rect(x, y, w, h, color);
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
Syscall::GfxUiFillRect => {
|
Syscall::GfxUiFillRect => {
|
||||||
@ -227,7 +224,6 @@ impl NativeInterface for VmRuntimeHost<'_> {
|
|||||||
let color = self.get_color(expect_int(args, 4)?)?;
|
let color = self.get_color(expect_int(args, 4)?)?;
|
||||||
self.gfxui_commands
|
self.gfxui_commands
|
||||||
.push(GfxUiCommand::FillRect { rect: Rect { x, y, w, h }, color });
|
.push(GfxUiCommand::FillRect { rect: Rect { x, y, w, h }, color });
|
||||||
hw.gfx_mut().fill_rect(x, y, w, h, color);
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
Syscall::GfxDrawLine => {
|
Syscall::GfxDrawLine => {
|
||||||
@ -243,7 +239,6 @@ impl NativeInterface for VmRuntimeHost<'_> {
|
|||||||
y1: y2,
|
y1: y2,
|
||||||
color,
|
color,
|
||||||
});
|
});
|
||||||
hw.gfx_mut().draw_line(x1, y1, x2, y2, color);
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
Syscall::GfxUiDrawLine => {
|
Syscall::GfxUiDrawLine => {
|
||||||
@ -265,7 +260,6 @@ impl NativeInterface for VmRuntimeHost<'_> {
|
|||||||
y1: y2,
|
y1: y2,
|
||||||
color,
|
color,
|
||||||
});
|
});
|
||||||
hw.gfx_mut().draw_line(x1, y1, x2, y2, color);
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
Syscall::GfxDrawCircle => {
|
Syscall::GfxDrawCircle => {
|
||||||
@ -274,7 +268,6 @@ impl NativeInterface for VmRuntimeHost<'_> {
|
|||||||
let r = expect_int(args, 2)? as i32;
|
let r = expect_int(args, 2)? as i32;
|
||||||
let color = self.get_color(expect_int(args, 3)?)?;
|
let color = self.get_color(expect_int(args, 3)?)?;
|
||||||
self.gfx2d_commands.push(Gfx2dCommand::DrawCircle { x, y, radius: r, color });
|
self.gfx2d_commands.push(Gfx2dCommand::DrawCircle { x, y, radius: r, color });
|
||||||
hw.gfx_mut().draw_circle(x, y, r, color);
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
Syscall::GfxUiDrawCircle => {
|
Syscall::GfxUiDrawCircle => {
|
||||||
@ -289,7 +282,6 @@ impl NativeInterface for VmRuntimeHost<'_> {
|
|||||||
let r = expect_int(args, 2)? as i32;
|
let r = expect_int(args, 2)? as i32;
|
||||||
let color = self.get_color(expect_int(args, 3)?)?;
|
let color = self.get_color(expect_int(args, 3)?)?;
|
||||||
self.gfxui_commands.push(GfxUiCommand::DrawCircle { x, y, radius: r, color });
|
self.gfxui_commands.push(GfxUiCommand::DrawCircle { x, y, radius: r, color });
|
||||||
hw.gfx_mut().draw_circle(x, y, r, color);
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
Syscall::GfxDrawDisc => {
|
Syscall::GfxDrawDisc => {
|
||||||
@ -305,7 +297,6 @@ impl NativeInterface for VmRuntimeHost<'_> {
|
|||||||
border_color,
|
border_color,
|
||||||
fill_color,
|
fill_color,
|
||||||
});
|
});
|
||||||
hw.gfx_mut().draw_disc(x, y, r, border_color, fill_color);
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
Syscall::GfxUiDrawDisc => {
|
Syscall::GfxUiDrawDisc => {
|
||||||
@ -327,7 +318,6 @@ impl NativeInterface for VmRuntimeHost<'_> {
|
|||||||
border_color,
|
border_color,
|
||||||
fill_color,
|
fill_color,
|
||||||
});
|
});
|
||||||
hw.gfx_mut().draw_disc(x, y, r, border_color, fill_color);
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
Syscall::GfxDrawSquare => {
|
Syscall::GfxDrawSquare => {
|
||||||
@ -342,7 +332,6 @@ impl NativeInterface for VmRuntimeHost<'_> {
|
|||||||
border_color,
|
border_color,
|
||||||
fill_color,
|
fill_color,
|
||||||
});
|
});
|
||||||
hw.gfx_mut().draw_square(x, y, w, h, border_color, fill_color);
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
Syscall::GfxUiDrawSquare => {
|
Syscall::GfxUiDrawSquare => {
|
||||||
@ -363,7 +352,6 @@ impl NativeInterface for VmRuntimeHost<'_> {
|
|||||||
border_color,
|
border_color,
|
||||||
fill_color,
|
fill_color,
|
||||||
});
|
});
|
||||||
hw.gfx_mut().draw_square(x, y, w, h, border_color, fill_color);
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
Syscall::GfxDrawText => {
|
Syscall::GfxDrawText => {
|
||||||
@ -372,7 +360,6 @@ impl NativeInterface for VmRuntimeHost<'_> {
|
|||||||
let msg = expect_string(args, 2, "message")?;
|
let msg = expect_string(args, 2, "message")?;
|
||||||
let color = self.get_color(expect_int(args, 3)?)?;
|
let color = self.get_color(expect_int(args, 3)?)?;
|
||||||
self.gfx2d_commands.push(Gfx2dCommand::DrawText { x, y, text: msg.clone(), color });
|
self.gfx2d_commands.push(Gfx2dCommand::DrawText { x, y, text: msg.clone(), color });
|
||||||
hw.gfx_mut().draw_text(x, y, &msg, color);
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
Syscall::GfxUiDrawText => {
|
Syscall::GfxUiDrawText => {
|
||||||
@ -387,7 +374,6 @@ impl NativeInterface for VmRuntimeHost<'_> {
|
|||||||
let msg = expect_string(args, 2, "message")?;
|
let msg = expect_string(args, 2, "message")?;
|
||||||
let color = self.get_color(expect_int(args, 3)?)?;
|
let color = self.get_color(expect_int(args, 3)?)?;
|
||||||
self.gfxui_commands.push(GfxUiCommand::DrawText { x, y, text: msg.clone(), color });
|
self.gfxui_commands.push(GfxUiCommand::DrawText { x, y, text: msg.clone(), color });
|
||||||
hw.gfx_mut().draw_text(x, y, &msg, color);
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
Syscall::ComposerBindScene => {
|
Syscall::ComposerBindScene => {
|
||||||
|
|||||||
@ -488,6 +488,105 @@ fn tick_shell_profile_closes_gfxui_commands_into_shell_packet() {
|
|||||||
assert_eq!(runtime.frame_scheduler.active_game_frame_id(), None);
|
assert_eq!(runtime.frame_scheduler.active_game_frame_id(), None);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn tick_gfx2d_clear_buffers_without_immediate_pixel_mutation_before_frame_close() {
|
||||||
|
let mut runtime = VirtualMachineRuntime::new(None);
|
||||||
|
let mut log_service = LogService::new(4096);
|
||||||
|
let mut fs = VirtualFS::new();
|
||||||
|
let mut fs_state = FsState::Unmounted;
|
||||||
|
let mut memcard = MemcardService::new();
|
||||||
|
let mut open_files: HashMap<u32, String> = HashMap::new();
|
||||||
|
let mut next_handle = 1;
|
||||||
|
let mut vm = VirtualMachine::default();
|
||||||
|
let mut hardware = Hardware::new();
|
||||||
|
let signals = InputSignals::default();
|
||||||
|
let code = assemble("PUSH_I32 287454020\nHOSTCALL 0\nJMP 0").expect("assemble");
|
||||||
|
let program = serialized_single_function_module(
|
||||||
|
code,
|
||||||
|
vec![SyscallDecl {
|
||||||
|
module: "gfx2d".into(),
|
||||||
|
name: "clear".into(),
|
||||||
|
version: 1,
|
||||||
|
arg_slots: 1,
|
||||||
|
ret_slots: 0,
|
||||||
|
}],
|
||||||
|
);
|
||||||
|
let cartridge = cartridge_with_program(program, caps::GFX);
|
||||||
|
|
||||||
|
runtime.initialize_vm(&mut log_service, &mut vm, &cartridge).expect("runtime must initialize");
|
||||||
|
let report = runtime.tick(
|
||||||
|
&mut log_service,
|
||||||
|
&mut fs,
|
||||||
|
&mut fs_state,
|
||||||
|
&mut memcard,
|
||||||
|
&mut open_files,
|
||||||
|
&mut next_handle,
|
||||||
|
&mut vm,
|
||||||
|
&signals,
|
||||||
|
&mut hardware,
|
||||||
|
);
|
||||||
|
|
||||||
|
assert!(report.is_none());
|
||||||
|
assert!(runtime.render_manager.latest_complete_submission().is_none());
|
||||||
|
assert!(matches!(
|
||||||
|
runtime.gfx2d_commands.first(),
|
||||||
|
Some(prometeu_hal::Gfx2dCommand::Clear { color })
|
||||||
|
if *color == Color::from_raw(0x11223344)
|
||||||
|
));
|
||||||
|
assert_ne!(hardware.gfx.front_buffer()[0], Color::from_raw(0x11223344).raw());
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn tick_gfx2d_draw_text_buffers_without_immediate_pixel_mutation_before_frame_close() {
|
||||||
|
let mut runtime = VirtualMachineRuntime::new(None);
|
||||||
|
let mut log_service = LogService::new(4096);
|
||||||
|
let mut fs = VirtualFS::new();
|
||||||
|
let mut fs_state = FsState::Unmounted;
|
||||||
|
let mut memcard = MemcardService::new();
|
||||||
|
let mut open_files: HashMap<u32, String> = HashMap::new();
|
||||||
|
let mut next_handle = 1;
|
||||||
|
let mut vm = VirtualMachine::default();
|
||||||
|
let mut hardware = Hardware::new();
|
||||||
|
let signals = InputSignals::default();
|
||||||
|
let code =
|
||||||
|
assemble("PUSH_I32 0\nPUSH_I32 0\nPUSH_CONST 0\nPUSH_I32 287454020\nHOSTCALL 0\nJMP 0")
|
||||||
|
.expect("assemble");
|
||||||
|
let program = serialized_single_function_module_with_consts(
|
||||||
|
code,
|
||||||
|
vec![ConstantPoolEntry::String("I".into())],
|
||||||
|
vec![SyscallDecl {
|
||||||
|
module: "gfx2d".into(),
|
||||||
|
name: "draw_text".into(),
|
||||||
|
version: 1,
|
||||||
|
arg_slots: 4,
|
||||||
|
ret_slots: 0,
|
||||||
|
}],
|
||||||
|
);
|
||||||
|
let cartridge = cartridge_with_program(program, caps::GFX);
|
||||||
|
|
||||||
|
runtime.initialize_vm(&mut log_service, &mut vm, &cartridge).expect("runtime must initialize");
|
||||||
|
let report = runtime.tick(
|
||||||
|
&mut log_service,
|
||||||
|
&mut fs,
|
||||||
|
&mut fs_state,
|
||||||
|
&mut memcard,
|
||||||
|
&mut open_files,
|
||||||
|
&mut next_handle,
|
||||||
|
&mut vm,
|
||||||
|
&signals,
|
||||||
|
&mut hardware,
|
||||||
|
);
|
||||||
|
|
||||||
|
assert!(report.is_none());
|
||||||
|
assert!(runtime.render_manager.latest_complete_submission().is_none());
|
||||||
|
assert!(matches!(
|
||||||
|
runtime.gfx2d_commands.first(),
|
||||||
|
Some(prometeu_hal::Gfx2dCommand::DrawText { x: 0, y: 0, text, color })
|
||||||
|
if text == "I" && *color == Color::from_raw(0x11223344)
|
||||||
|
));
|
||||||
|
assert_ne!(hardware.gfx.front_buffer()[0], Color::from_raw(0x11223344).raw());
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn tick_system_profile_rejects_bank_game_surface() {
|
fn tick_system_profile_rejects_bank_game_surface() {
|
||||||
let mut runtime = VirtualMachineRuntime::new(None);
|
let mut runtime = VirtualMachineRuntime::new(None);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user