Files
prometeu-runtime/crates/host/prometeu-host-desktop-winit/src/lib.rs
T
bquarkz 6c2a07e579
Intrepid/Prometeu/Runtime/pipeline/pr-master This commit looks good
feat(runtime): implement shared transactional memcard with async saves
2026-10-13 15:24:01 +01:00

85 lines
2.3 KiB
Rust

pub mod audio;
pub mod cap;
pub mod debugger;
pub mod fs_backend;
pub mod input;
pub mod log_sink;
pub mod runner;
pub mod stats;
pub mod utilities;
pub mod wall_clock;
use cap::load_cap_config;
use clap::Parser;
use prometeu_firmware::BootTarget;
use runner::HostRunner;
use winit::event_loop::EventLoop;
#[derive(Parser, Debug)]
#[command(author, version, about, long_about = None)]
struct Cli {
/// Run a cartridge
#[arg(long, value_name = "PATH", conflicts_with = "debug")]
run: Option<String>,
/// Debug a cartridge
#[arg(long, value_name = "PATH", conflicts_with = "run")]
debug: Option<String>,
/// Port for the debugger
#[arg(long, default_value_t = 7777)]
port: u16,
/// Root directory for the filesystem
#[arg(long, value_name = "PATH")]
fs_root: Option<String>,
/// Root directory for local game cartridge discovery
#[arg(long, value_name = "PATH")]
games_root: Option<String>,
/// Install a memory-card image (never converted or overwritten).
#[arg(long, value_name = "PATH")]
memcard: Option<std::path::PathBuf>,
/// Create and fully allocate the named new memory card before installation.
#[arg(long, requires = "memcard")]
create_memcard: bool,
/// Path to the capability configuration file
#[arg(long, value_name = "PATH")]
cap: Option<String>,
}
pub fn run() -> Result<(), Box<dyn std::error::Error>> {
let cli = Cli::parse();
let fs_root = cli.fs_root;
let cap_config = cli.cap.as_ref().and_then(|path| load_cap_config(path));
let boot_target = if let Some(path) = cli.debug {
BootTarget::Cartridge { path, debug: true, debug_port: cli.port }
} else if let Some(path) = cli.run {
BootTarget::Cartridge { path, debug: false, debug_port: 7777 }
} else {
BootTarget::Hub
};
let event_loop = EventLoop::new()?;
let mut runner = HostRunner::new(fs_root, cap_config);
if let Some(games_root) = cli.games_root {
runner.set_games_root(games_root);
}
if let Some(path) = cli.memcard {
runner
.install_memcard(path, cli.create_memcard)
.map_err(|e| format!("Cannot install memory card: {e:?}"))?;
}
runner.set_boot_target(boot_target);
event_loop.run_app(&mut runner)?;
Ok(())
}