implements PLN-0022
This commit is contained in:
@@ -4,14 +4,11 @@ use prometeu_bytecode::{TRAP_INVALID_SYSCALL, TRAP_OOB, TRAP_TYPE, Value};
|
||||
use prometeu_hal::asset::{AssetId, AssetOpStatus, BankType, SlotRef};
|
||||
use prometeu_hal::cartridge::AppMode;
|
||||
use prometeu_hal::color::Color;
|
||||
use prometeu_hal::glyph::Glyph;
|
||||
use prometeu_hal::log::{LogLevel, LogSource};
|
||||
use prometeu_hal::sprite::Sprite;
|
||||
use prometeu_hal::syscalls::Syscall;
|
||||
use prometeu_hal::vm_fault::VmFault;
|
||||
use prometeu_hal::{
|
||||
AudioOpStatus, GfxOpStatus, HostContext, HostReturn, NativeInterface, SyscallId, expect_bool,
|
||||
expect_int,
|
||||
AudioOpStatus, HostContext, HostReturn, NativeInterface, SyscallId, expect_int,
|
||||
};
|
||||
use std::sync::atomic::Ordering;
|
||||
|
||||
@@ -135,49 +132,6 @@ impl NativeInterface for VirtualMachineRuntime {
|
||||
hw.gfx_mut().draw_square(x, y, w, h, border_color, fill_color);
|
||||
Ok(())
|
||||
}
|
||||
Syscall::GfxSetSprite => {
|
||||
let bank_id = expect_int(args, 0)? as u8;
|
||||
let index = expect_int(args, 1)? as usize;
|
||||
let x = expect_int(args, 2)? as i32;
|
||||
let y = expect_int(args, 3)? as i32;
|
||||
let glyph_id = expect_int(args, 4)? as u16;
|
||||
let palette_id = expect_int(args, 5)? as u8;
|
||||
let active = expect_bool(args, 6)?;
|
||||
let flip_x = expect_bool(args, 7)?;
|
||||
let flip_y = expect_bool(args, 8)?;
|
||||
let priority = expect_int(args, 9)? as u8;
|
||||
|
||||
if index >= 512 {
|
||||
ret.push_int(GfxOpStatus::InvalidSpriteIndex as i64);
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
if hw.assets().slot_info(SlotRef::gfx(bank_id as usize)).asset_id.is_none() {
|
||||
ret.push_int(GfxOpStatus::BankInvalid as i64);
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
if palette_id >= 64 || priority >= 5 {
|
||||
ret.push_int(GfxOpStatus::ArgRangeInvalid as i64);
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
if active {
|
||||
hw.emit_sprite(Sprite {
|
||||
glyph: Glyph { glyph_id, palette_id },
|
||||
x,
|
||||
y,
|
||||
layer: 0,
|
||||
bank_id,
|
||||
active: false,
|
||||
flip_x,
|
||||
flip_y,
|
||||
priority,
|
||||
});
|
||||
}
|
||||
ret.push_int(GfxOpStatus::Ok as i64);
|
||||
Ok(())
|
||||
}
|
||||
Syscall::GfxDrawText => {
|
||||
let x = expect_int(args, 0)? as i32;
|
||||
let y = expect_int(args, 1)? as i32;
|
||||
@@ -194,6 +148,13 @@ impl NativeInterface for VirtualMachineRuntime {
|
||||
hw.gfx_mut().clear(Color::from_raw(color_val as u16));
|
||||
Ok(())
|
||||
}
|
||||
Syscall::ComposerBindScene
|
||||
| Syscall::ComposerUnbindScene
|
||||
| Syscall::ComposerSetCamera
|
||||
| Syscall::ComposerEmitSprite => Err(VmFault::Trap(
|
||||
TRAP_INVALID_SYSCALL,
|
||||
"Composer syscall support is not implemented yet".into(),
|
||||
)),
|
||||
Syscall::AudioPlaySample => {
|
||||
let sample_id_raw = expect_int(args, 0)?;
|
||||
let voice_id_raw = expect_int(args, 1)?;
|
||||
|
||||
Reference in New Issue
Block a user