implements PLN-0102

This commit is contained in:
2026-06-15 05:51:07 +01:00
parent 6f3df74e79
commit d2bace2612
5 changed files with 184 additions and 30 deletions
@@ -12,8 +12,9 @@ use prometeu_hal::sprite::Sprite;
use prometeu_hal::syscalls::Syscall;
use prometeu_hal::vm_fault::VmFault;
use prometeu_hal::{
AudioOpStatus, ComposerOpStatus, Gfx2dCommand, GfxUiCommand, HostContext, HostReturn,
NativeInterface, SyscallId, expect_bool, expect_int,
AudioOpStatus, ComposerOpStatus, Game2DFrameComposer, Gfx2dCommand, GfxUiCommand, HostContext,
HostReturn, LegacyHardwareGame2DFrameComposer, NativeInterface, SyscallId, expect_bool,
expect_int,
};
use std::collections::HashMap;
use std::ops::{Deref, DerefMut};
@@ -385,23 +386,24 @@ impl NativeInterface for VmRuntimeHost<'_> {
}
};
let bound = catch_unwind(AssertUnwindSafe(|| hw.bind_scene(scene_bank_id)))
.map_err(|payload| VmFault::Panic(Self::panic_payload_to_string(payload)))?;
let status = catch_unwind(AssertUnwindSafe(|| {
let mut composer = LegacyHardwareGame2DFrameComposer::new(hw);
composer.bind_scene(scene_bank_id)
}))
.map_err(|payload| VmFault::Panic(Self::panic_payload_to_string(payload)))?;
let status =
if bound { ComposerOpStatus::Ok } else { ComposerOpStatus::SceneUnavailable };
ret.push_int(status as i64);
Ok(())
}
Syscall::ComposerUnbindScene => {
hw.unbind_scene();
LegacyHardwareGame2DFrameComposer::new(hw).unbind_scene();
ret.push_int(ComposerOpStatus::Ok as i64);
Ok(())
}
Syscall::ComposerSetCamera => {
let x = Self::int_arg_to_i32_trap(expect_int(args, 0)?, "camera x")?;
let y = Self::int_arg_to_i32_trap(expect_int(args, 1)?, "camera y")?;
hw.set_camera(x, y);
LegacyHardwareGame2DFrameComposer::new(hw).set_camera(x, y);
Ok(())
}
Syscall::ComposerEmitSprite => {
@@ -449,12 +451,7 @@ impl NativeInterface for VmRuntimeHost<'_> {
}
};
if !hw.has_glyph_bank(bank_id as usize) {
ret.push_int(ComposerOpStatus::BankInvalid as i64);
return Ok(());
}
let emitted = hw.emit_sprite(Sprite {
let status = LegacyHardwareGame2DFrameComposer::new(hw).emit_sprite(Sprite {
glyph: Glyph { glyph_id, palette_id },
x,
y,
@@ -465,8 +462,6 @@ impl NativeInterface for VmRuntimeHost<'_> {
flip_y,
priority,
});
let status =
if emitted { ComposerOpStatus::Ok } else { ComposerOpStatus::SpriteOverflow };
ret.push_int(status as i64);
Ok(())
}