use std::sync::Arc; use prometeu_hardware_contract::{AssetBridge, AudioBridge, GfxBridge, HardwareBridge, PadBridge, TouchBridge}; use crate::asset::AssetManager; use crate::audio::Audio; use crate::gfx::Gfx; use crate::memory_banks::{MemoryBanks, SoundBankPoolAccess, SoundBankPoolInstaller, TileBankPoolAccess, TileBankPoolInstaller}; use crate::pad::Pad; use crate::touch::Touch; /// Aggregate structure for all virtual hardware peripherals. /// /// This struct represents the "Mainboard" of the PROMETEU console. /// It acts as a container for all hardware subsystems. In the Prometeu /// architecture, hardware is decoupled from the OS and VM, allowing /// for easier testing and different host implementations (Desktop, Web, etc.). /// /// ### Console Specifications: /// - **Resolution**: 320x180 (16:9 Aspect Ratio). /// - **Color Depth**: RGB565 (16-bit). /// - **Audio**: Stereo, Command-based mixing. /// - **Input**: 12-button Digital Gamepad + Absolute Touch/Mouse. pub struct Hardware { /// The Graphics Processing Unit (GPU). Handles drawing primitives, sprites, and tilemaps. pub gfx: Gfx, /// The Sound Processing Unit (SPU). Manages sample playback and volume control. pub audio: Audio, /// The standard digital gamepad. Provides state for D-Pad, face buttons, and triggers. pub pad: Pad, /// The absolute pointer input device (Mouse/Touchscreen). pub touch: Touch, /// The Asset Management system (DMA). Handles loading data into VRAM (TileBanks) and ARAM (SoundBanks). pub assets: AssetManager, } impl HardwareBridge for Hardware { fn gfx(&self) -> &dyn GfxBridge { &self.gfx } fn gfx_mut(&mut self) -> &mut dyn GfxBridge { &mut self.gfx } fn audio(&self) -> &dyn AudioBridge { &self.audio } fn audio_mut(&mut self) -> &mut dyn AudioBridge { &mut self.audio } fn pad(&self) -> &dyn PadBridge { &self.pad } fn pad_mut(&mut self) -> &mut dyn PadBridge { &mut self.pad } fn touch(&self) -> &dyn TouchBridge { &self.touch } fn touch_mut(&mut self) -> &mut dyn TouchBridge { &mut self.touch } fn assets(&self) -> &dyn AssetBridge { &self.assets } fn assets_mut(&mut self) -> &mut dyn AssetBridge { &mut self.assets } } impl Hardware { /// Internal hardware width in pixels. pub const W: usize = 320; /// Internal hardware height in pixels. pub const H: usize = 180; /// Creates a fresh hardware instance with default settings. pub fn new() -> Self { let memory_banks = Arc::new(MemoryBanks::new()); Self { gfx: Gfx::new(Self::W, Self::H, Arc::clone(&memory_banks) as Arc), audio: Audio::new(Arc::clone(&memory_banks) as Arc), pad: Pad::default(), touch: Touch::default(), assets: AssetManager::new( vec![], vec![], Arc::clone(&memory_banks) as Arc, Arc::clone(&memory_banks) as Arc, ), } } }