110 lines
3.4 KiB
Rust
110 lines
3.4 KiB
Rust
use crate::asset::AssetManager;
|
|
use crate::audio::Audio;
|
|
use crate::gfx::Gfx;
|
|
use crate::memory_banks::{
|
|
GlyphBankPoolAccess, GlyphBankPoolInstaller, MemoryBanks, SceneBankPoolInstaller,
|
|
SoundBankPoolAccess, SoundBankPoolInstaller,
|
|
};
|
|
use crate::pad::Pad;
|
|
use crate::touch::Touch;
|
|
use prometeu_hal::cartridge::AssetsPayloadSource;
|
|
use prometeu_hal::{AssetBridge, AudioBridge, GfxBridge, HardwareBridge, PadBridge, TouchBridge};
|
|
use std::sync::Arc;
|
|
|
|
/// 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 (GlyphBanks) and ARAM (SoundBanks).
|
|
pub assets: AssetManager,
|
|
}
|
|
|
|
impl Default for Hardware {
|
|
fn default() -> Self {
|
|
Self::new()
|
|
}
|
|
}
|
|
|
|
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<dyn GlyphBankPoolAccess>,
|
|
),
|
|
audio: Audio::new(Arc::clone(&memory_banks) as Arc<dyn SoundBankPoolAccess>),
|
|
pad: Pad::default(),
|
|
touch: Touch::default(),
|
|
assets: AssetManager::new(
|
|
vec![],
|
|
AssetsPayloadSource::empty(),
|
|
Arc::clone(&memory_banks) as Arc<dyn GlyphBankPoolInstaller>,
|
|
Arc::clone(&memory_banks) as Arc<dyn SoundBankPoolInstaller>,
|
|
Arc::clone(&memory_banks) as Arc<dyn SceneBankPoolInstaller>,
|
|
),
|
|
}
|
|
}
|
|
}
|