implements PLN-0109
Intrepid/Prometeu/Runtime/pipeline/head This commit looks good
Intrepid/Prometeu/Runtime/pipeline/pr-master This commit looks good

This commit is contained in:
2026-06-15 10:47:34 +01:00
parent 117a18ee72
commit 9cf9fa6163
11 changed files with 60 additions and 351 deletions
@@ -1,39 +0,0 @@
use crate::asset_bridge::AssetBridge;
use crate::audio_bridge::AudioBridge;
use crate::gfx_bridge::GfxBridge;
use crate::pad_bridge::PadBridge;
use crate::render_submission::{Game2DFramePacket, RenderSubmission};
use crate::sprite::Sprite;
use crate::touch_bridge::TouchBridge;
/// Legacy migration scaffold for code that has not moved to `platform` facades yet.
///
/// `HardwareBridge` is intentionally not the final runtime-facing contract. New
/// platform boundaries belong in `crate::platform`, and this trait must be
/// removed after runtime, firmware, host, and tests finish migrating.
pub trait HardwareBridge {
fn begin_frame(&mut self);
fn bind_scene(&mut self, scene_bank_id: usize) -> bool;
fn unbind_scene(&mut self);
fn set_camera(&mut self, x: i32, y: i32);
fn emit_sprite(&mut self, sprite: Sprite) -> bool;
fn close_game2d_packet(&self) -> Game2DFramePacket;
fn publish_render_submission(&mut self, submission: &RenderSubmission);
fn render_frame(&mut self);
fn has_glyph_bank(&self, bank_id: usize) -> bool;
fn gfx(&self) -> &dyn GfxBridge;
fn gfx_mut(&mut self) -> &mut dyn GfxBridge;
fn audio(&self) -> &dyn AudioBridge;
fn audio_mut(&mut self) -> &mut dyn AudioBridge;
fn pad(&self) -> &dyn PadBridge;
fn pad_mut(&mut self) -> &mut dyn PadBridge;
fn touch(&self) -> &dyn TouchBridge;
fn touch_mut(&mut self) -> &mut dyn TouchBridge;
fn assets(&self) -> &dyn AssetBridge;
fn assets_mut(&mut self) -> &mut dyn AssetBridge;
}
@@ -1,27 +1,17 @@
use crate::hardware_bridge::HardwareBridge;
use crate::platform::RuntimePlatform;
use crate::vm_fault::VmFault;
pub struct HostContext<'a> {
pub hw: Option<&'a mut dyn HardwareBridge>,
pub platform: Option<&'a mut dyn RuntimePlatform>,
}
impl<'a> HostContext<'a> {
pub fn new(hw: Option<&'a mut dyn HardwareBridge>) -> Self {
Self { hw, platform: None }
pub fn new(platform: Option<&'a mut dyn RuntimePlatform>) -> Self {
Self { platform }
}
pub fn new_platform(platform: Option<&'a mut dyn RuntimePlatform>) -> Self {
Self { hw: None, platform }
}
#[inline]
pub fn require_hw(&mut self) -> Result<&mut dyn HardwareBridge, VmFault> {
match &mut self.hw {
Some(hw) => Ok(*hw),
None => Err(VmFault::Unavailable),
}
Self::new(platform)
}
#[inline]
+2 -5
View File
@@ -11,7 +11,6 @@ pub mod debugger_protocol;
pub mod gfx_bridge;
pub mod glyph;
pub mod glyph_bank;
pub mod hardware_bridge;
pub mod host_context;
pub mod host_return;
pub mod input_signals;
@@ -40,7 +39,6 @@ pub use asset_bridge::AssetBridge;
pub use audio_bridge::{AudioBridge, AudioOpStatus, LoopMode};
pub use composer_status::ComposerOpStatus;
pub use gfx_bridge::{BlendMode, GfxBridge, GfxOpStatus};
pub use hardware_bridge::HardwareBridge;
pub use host_context::{HostContext, HostContextProvider};
pub use host_return::HostReturn;
pub use input_signals::InputSignals;
@@ -49,9 +47,8 @@ pub use native_interface::{NativeInterface, SyscallId};
pub use pad_bridge::PadBridge;
pub use platform::{
AssetStoragePlatform, AudioPlatform, ClockPacingPlatform, Game2DFrameComposer, InputPlatform,
LegacyHardwareGame2DFrameComposer, LegacyHardwareRenderSubmissionSink,
LegacyHardwareRuntimePlatform, NoopTelemetryPlatform, RenderBackend, RenderSubmissionSink,
RenderSubmitError, RuntimePlatform, TelemetryPlatform, TestPlatform,
NoopTelemetryPlatform, RenderBackend, RenderSubmissionSink, RenderSubmitError, RuntimePlatform,
TelemetryPlatform, TestPlatform,
};
pub use render_submission::{
BoundScenePacket, Camera2D, ComposerFramePacket, FrameId, Game2DFramePacket, GameSpritePacket,
-197
View File
@@ -1,7 +1,6 @@
use crate::asset_bridge::AssetBridge;
use crate::audio_bridge::AudioBridge;
use crate::composer_status::ComposerOpStatus;
use crate::hardware_bridge::HardwareBridge;
use crate::pad_bridge::PadBridge;
use crate::render_submission::{Game2DFramePacket, RenderSubmission};
use crate::sprite::Sprite;
@@ -21,26 +20,6 @@ pub trait RenderSubmissionSink {
) -> Result<(), RenderSubmitError>;
}
pub struct LegacyHardwareRenderSubmissionSink<'a> {
hw: &'a mut dyn HardwareBridge,
}
impl<'a> LegacyHardwareRenderSubmissionSink<'a> {
pub fn new(hw: &'a mut dyn HardwareBridge) -> Self {
Self { hw }
}
}
impl RenderSubmissionSink for LegacyHardwareRenderSubmissionSink<'_> {
fn submit_render_submission(
&mut self,
submission: RenderSubmission,
) -> Result<(), RenderSubmitError> {
self.hw.publish_render_submission(&submission);
Ok(())
}
}
pub trait RenderBackend {
fn render_frame(&mut self);
}
@@ -54,138 +33,6 @@ pub trait Game2DFrameComposer {
fn close_game2d_packet(&self) -> Game2DFramePacket;
}
pub struct LegacyHardwareGame2DFrameComposer<'a> {
hw: &'a mut dyn HardwareBridge,
}
impl<'a> LegacyHardwareGame2DFrameComposer<'a> {
pub fn new(hw: &'a mut dyn HardwareBridge) -> Self {
Self { hw }
}
}
impl Game2DFrameComposer for LegacyHardwareGame2DFrameComposer<'_> {
fn begin_frame(&mut self) {
self.hw.begin_frame();
}
fn bind_scene(&mut self, scene_bank_id: usize) -> ComposerOpStatus {
if self.hw.bind_scene(scene_bank_id) {
ComposerOpStatus::Ok
} else {
ComposerOpStatus::SceneUnavailable
}
}
fn unbind_scene(&mut self) {
self.hw.unbind_scene();
}
fn set_camera(&mut self, x: i32, y: i32) -> ComposerOpStatus {
self.hw.set_camera(x, y);
ComposerOpStatus::Ok
}
fn emit_sprite(&mut self, sprite: Sprite) -> ComposerOpStatus {
if !self.hw.has_glyph_bank(sprite.bank_id as usize) {
return ComposerOpStatus::BankInvalid;
}
if self.hw.emit_sprite(sprite) {
ComposerOpStatus::Ok
} else {
ComposerOpStatus::SpriteOverflow
}
}
fn close_game2d_packet(&self) -> Game2DFramePacket {
self.hw.close_game2d_packet()
}
}
pub struct LegacyHardwareRuntimePlatform<'a> {
hw: &'a mut dyn HardwareBridge,
}
impl<'a> LegacyHardwareRuntimePlatform<'a> {
pub fn new(hw: &'a mut dyn HardwareBridge) -> Self {
Self { hw }
}
}
impl RenderSubmissionSink for LegacyHardwareRuntimePlatform<'_> {
fn submit_render_submission(
&mut self,
submission: RenderSubmission,
) -> Result<(), RenderSubmitError> {
self.hw.publish_render_submission(&submission);
Ok(())
}
}
impl RenderBackend for LegacyHardwareRuntimePlatform<'_> {
fn render_frame(&mut self) {
self.hw.render_frame();
}
}
impl Game2DFrameComposer for LegacyHardwareRuntimePlatform<'_> {
fn begin_frame(&mut self) {
self.hw.begin_frame();
}
fn bind_scene(&mut self, scene_bank_id: usize) -> ComposerOpStatus {
if self.hw.bind_scene(scene_bank_id) {
ComposerOpStatus::Ok
} else {
ComposerOpStatus::SceneUnavailable
}
}
fn unbind_scene(&mut self) {
self.hw.unbind_scene();
}
fn set_camera(&mut self, x: i32, y: i32) -> ComposerOpStatus {
self.hw.set_camera(x, y);
ComposerOpStatus::Ok
}
fn emit_sprite(&mut self, sprite: Sprite) -> ComposerOpStatus {
if !self.hw.has_glyph_bank(sprite.bank_id as usize) {
return ComposerOpStatus::BankInvalid;
}
if self.hw.emit_sprite(sprite) {
ComposerOpStatus::Ok
} else {
ComposerOpStatus::SpriteOverflow
}
}
fn close_game2d_packet(&self) -> Game2DFramePacket {
self.hw.close_game2d_packet()
}
}
impl InputPlatform for LegacyHardwareRuntimePlatform<'_> {
fn pad(&self) -> &dyn PadBridge {
self.hw.pad()
}
fn pad_mut(&mut self) -> &mut dyn PadBridge {
self.hw.pad_mut()
}
fn touch(&self) -> &dyn TouchBridge {
self.hw.touch()
}
fn touch_mut(&mut self) -> &mut dyn TouchBridge {
self.hw.touch_mut()
}
}
pub trait AudioPlatform: AudioBridge {}
impl<T: AudioBridge + ?Sized> AudioPlatform for T {}
@@ -212,8 +59,6 @@ pub struct NoopTelemetryPlatform;
impl TelemetryPlatform for NoopTelemetryPlatform {}
static LEGACY_NOOP_TELEMETRY: NoopTelemetryPlatform = NoopTelemetryPlatform;
pub trait RuntimePlatform {
fn display_size(&self) -> (usize, usize) {
(480, 270)
@@ -231,48 +76,6 @@ pub trait RuntimePlatform {
fn telemetry(&self) -> &dyn TelemetryPlatform;
}
impl RuntimePlatform for LegacyHardwareRuntimePlatform<'_> {
fn render_submission_sink(&mut self) -> &mut dyn RenderSubmissionSink {
self
}
fn render_backend(&mut self) -> &mut dyn RenderBackend {
self
}
fn game2d_frame_composer(&mut self) -> &mut dyn Game2DFrameComposer {
self
}
fn audio(&self) -> &dyn AudioBridge {
self.hw.audio()
}
fn audio_mut(&mut self) -> &mut dyn AudioBridge {
self.hw.audio_mut()
}
fn input(&self) -> &dyn InputPlatform {
self
}
fn input_mut(&mut self) -> &mut dyn InputPlatform {
self
}
fn assets(&self) -> &dyn AssetBridge {
self.hw.assets()
}
fn assets_mut(&mut self) -> &mut dyn AssetBridge {
self.hw.assets_mut()
}
fn telemetry(&self) -> &dyn TelemetryPlatform {
&LEGACY_NOOP_TELEMETRY
}
}
pub trait TestPlatform: RuntimePlatform {}
impl<T: RuntimePlatform + ?Sized> TestPlatform for T {}