implements PLN-0104
This commit is contained in:
@@ -12,9 +12,8 @@ use prometeu_hal::sprite::Sprite;
|
||||
use prometeu_hal::syscalls::Syscall;
|
||||
use prometeu_hal::vm_fault::VmFault;
|
||||
use prometeu_hal::{
|
||||
AudioOpStatus, ComposerOpStatus, Game2DFrameComposer, Gfx2dCommand, GfxUiCommand, HostContext,
|
||||
HostReturn, LegacyHardwareGame2DFrameComposer, 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};
|
||||
@@ -180,7 +179,7 @@ impl NativeInterface for VmRuntimeHost<'_> {
|
||||
|
||||
self.ensure_game_profile_syscall(syscall)?;
|
||||
|
||||
let hw = ctx.require_hw()?;
|
||||
let platform = ctx.require_platform()?;
|
||||
|
||||
match syscall {
|
||||
Syscall::SystemHasCart => unreachable!(),
|
||||
@@ -387,8 +386,7 @@ impl NativeInterface for VmRuntimeHost<'_> {
|
||||
};
|
||||
|
||||
let status = catch_unwind(AssertUnwindSafe(|| {
|
||||
let mut composer = LegacyHardwareGame2DFrameComposer::new(hw);
|
||||
composer.bind_scene(scene_bank_id)
|
||||
platform.game2d_frame_composer().bind_scene(scene_bank_id)
|
||||
}))
|
||||
.map_err(|payload| VmFault::Panic(Self::panic_payload_to_string(payload)))?;
|
||||
|
||||
@@ -396,14 +394,14 @@ impl NativeInterface for VmRuntimeHost<'_> {
|
||||
Ok(())
|
||||
}
|
||||
Syscall::ComposerUnbindScene => {
|
||||
LegacyHardwareGame2DFrameComposer::new(hw).unbind_scene();
|
||||
platform.game2d_frame_composer().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")?;
|
||||
LegacyHardwareGame2DFrameComposer::new(hw).set_camera(x, y);
|
||||
platform.game2d_frame_composer().set_camera(x, y);
|
||||
Ok(())
|
||||
}
|
||||
Syscall::ComposerEmitSprite => {
|
||||
@@ -451,7 +449,7 @@ impl NativeInterface for VmRuntimeHost<'_> {
|
||||
}
|
||||
};
|
||||
|
||||
let status = LegacyHardwareGame2DFrameComposer::new(hw).emit_sprite(Sprite {
|
||||
let status = platform.game2d_frame_composer().emit_sprite(Sprite {
|
||||
glyph: Glyph { glyph_id, palette_id },
|
||||
x,
|
||||
y,
|
||||
@@ -488,7 +486,7 @@ impl NativeInterface for VmRuntimeHost<'_> {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
let status = hw.audio_mut().play(
|
||||
let status = platform.audio_mut().play(
|
||||
0,
|
||||
sample_id_raw as u16,
|
||||
voice_id_raw as usize,
|
||||
@@ -518,7 +516,8 @@ impl NativeInterface for VmRuntimeHost<'_> {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
if hw.assets().slot_info(SlotRef::audio(bank_id as usize)).asset_id.is_none() {
|
||||
if platform.assets().slot_info(SlotRef::audio(bank_id as usize)).asset_id.is_none()
|
||||
{
|
||||
ret.push_int(AudioOpStatus::BankInvalid as i64);
|
||||
return Ok(());
|
||||
}
|
||||
@@ -534,7 +533,7 @@ impl NativeInterface for VmRuntimeHost<'_> {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
let status = hw.audio_mut().play(
|
||||
let status = platform.audio_mut().play(
|
||||
bank_id,
|
||||
sample_id_raw as u16,
|
||||
voice_id_raw as usize,
|
||||
@@ -731,7 +730,7 @@ impl NativeInterface for VmRuntimeHost<'_> {
|
||||
})?;
|
||||
let slot_index = expect_int(args, 1)? as usize;
|
||||
|
||||
match hw.assets().load(asset_id, slot_index) {
|
||||
match platform.assets().load(asset_id, slot_index) {
|
||||
Ok(handle) => {
|
||||
ret.push_int(AssetOpStatus::Ok as i64);
|
||||
ret.push_int(handle as i64);
|
||||
@@ -745,16 +744,16 @@ impl NativeInterface for VmRuntimeHost<'_> {
|
||||
}
|
||||
}
|
||||
Syscall::AssetStatus => {
|
||||
ret.push_int(hw.assets().status(expect_int(args, 0)? as u32) as i64);
|
||||
ret.push_int(platform.assets().status(expect_int(args, 0)? as u32) as i64);
|
||||
Ok(())
|
||||
}
|
||||
Syscall::AssetCommit => {
|
||||
let status = hw.assets().commit(expect_int(args, 0)? as u32);
|
||||
let status = platform.assets().commit(expect_int(args, 0)? as u32);
|
||||
ret.push_int(status as i64);
|
||||
Ok(())
|
||||
}
|
||||
Syscall::AssetCancel => {
|
||||
let status = hw.assets().cancel(expect_int(args, 0)? as u32);
|
||||
let status = platform.assets().cancel(expect_int(args, 0)? as u32);
|
||||
ret.push_int(status as i64);
|
||||
Ok(())
|
||||
}
|
||||
@@ -764,7 +763,7 @@ impl NativeInterface for VmRuntimeHost<'_> {
|
||||
1 => BankType::SOUNDS,
|
||||
_ => return Err(VmFault::Trap(TRAP_TYPE, "Invalid asset type".to_string())),
|
||||
};
|
||||
let telemetry = hw
|
||||
let telemetry = platform
|
||||
.assets()
|
||||
.bank_telemetry()
|
||||
.into_iter()
|
||||
|
||||
Reference in New Issue
Block a user