change names of modules
This commit is contained in:
@@ -0,0 +1,78 @@
|
||||
use crate::firmware::firmware_state::FirmwareState;
|
||||
use crate::hardware::{HardwareBridge, InputSignals};
|
||||
use crate::model::{AppMode, Cartridge, Color};
|
||||
use crate::prometeu_hub::PrometeuHub;
|
||||
use crate::prometeu_os::PrometeuOS;
|
||||
|
||||
pub struct Firmware {
|
||||
pub os: PrometeuOS,
|
||||
pub hub: PrometeuHub,
|
||||
pub state: FirmwareState,
|
||||
}
|
||||
|
||||
impl Firmware {
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
os: PrometeuOS::new(),
|
||||
hub: PrometeuHub::new(),
|
||||
state: FirmwareState::Reset,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn step_frame(&mut self, signals: &InputSignals, hw: &mut dyn HardwareBridge) {
|
||||
match &mut self.state {
|
||||
FirmwareState::Reset => {
|
||||
self.os.reset();
|
||||
self.state = FirmwareState::SplashScreen;
|
||||
}
|
||||
FirmwareState::SplashScreen => {
|
||||
// Splash logic opcional
|
||||
self.state = FirmwareState::LaunchHubHome;
|
||||
}
|
||||
FirmwareState::LaunchHubHome => {
|
||||
self.hub.init();
|
||||
self.state = FirmwareState::HubHome;
|
||||
}
|
||||
FirmwareState::HubHome => {
|
||||
hw.gfx_mut().clear(Color::INDIGO);
|
||||
self.hub.gui_update(&mut self.os);
|
||||
hw.gfx_mut().present();
|
||||
}
|
||||
FirmwareState::PosRunGame(_cart) => {
|
||||
if let Some(error) = self.os.step_frame(signals, hw) {
|
||||
self.state = FirmwareState::PosCrashScreen(error);
|
||||
}
|
||||
}
|
||||
FirmwareState::PosRunSystem(_cart) => {
|
||||
// System Apps rodam "dentro" do Hub/Window System
|
||||
if let Some(error) = self.os.step_frame(signals, hw) {
|
||||
self.state = FirmwareState::PosCrashScreen(error);
|
||||
}
|
||||
// TODO: Compor com a UI do Hub
|
||||
}
|
||||
FirmwareState::PosCrashScreen(_error) => {
|
||||
// Atualiza periféricos para input na tela de crash
|
||||
hw.pad_mut().begin_frame(signals);
|
||||
|
||||
// Tela de erro: fundo vermelho, texto branco
|
||||
hw.gfx_mut().clear(Color::RED);
|
||||
// Por enquanto apenas logamos ou mostramos algo simples
|
||||
// No futuro, usar draw_text
|
||||
hw.gfx_mut().present();
|
||||
|
||||
// Se apertar START, volta pro Hub
|
||||
if hw.pad().start.down {
|
||||
self.state = FirmwareState::LaunchHubHome;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn load_app(&mut self, cart: Cartridge, mode: AppMode) {
|
||||
self.os.load_cartridge(&cart);
|
||||
match mode {
|
||||
AppMode::Game => self.state = FirmwareState::PosRunGame(cart),
|
||||
AppMode::System => self.state = FirmwareState::PosRunSystem(cart),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
use crate::model::Cartridge;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum FirmwareState {
|
||||
Reset,
|
||||
SplashScreen,
|
||||
LaunchHubHome,
|
||||
HubHome,
|
||||
PosRunGame(Cartridge),
|
||||
PosRunSystem(Cartridge),
|
||||
PosCrashScreen(String),
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
mod firmware;
|
||||
pub mod firmware_state;
|
||||
|
||||
pub use firmware::Firmware;
|
||||
Reference in New Issue
Block a user