Intrepid/Prometeu/Runtime/pipeline/head This commit looks good
Centralize the fixed 640x360 RGBA8888/60 Hz contract in the existing HAL. Preserve 8/16/32 tiles and composition, cover partial edges and mixed-size camera movement, and adapt firmware, fixtures, hosts and native tests. Share nearest-neighbor presentation geometry with pointer input. Measure actual framebuffer publications and successful host presentations separately from VM ticks, with bounded opt-in diagnostics and release harnesses. Validated with the complete tooling verify gate, native rendering tests, GPU readback, headless/process integration, formatting and strict clippy. The existing synchronous session path is documented; no worker/session architecture replacement or format compatibility layer is introduced. Work: WRK-0016 / DEC-0001 / PLN-0001 Commit and push explicitly authorized by the user after completion.
155 lines
6.4 KiB
Rust
155 lines
6.4 KiB
Rust
use crate::firmware::firmware_state::{
|
|
AppCrashesStep, FirmwareState, LoadCartridgeStep, ShellRunningStep,
|
|
};
|
|
use crate::firmware::prometeu_context::PrometeuContext;
|
|
use crate::firmware::resident_game_termination;
|
|
use prometeu_hal::app_mode::AppMode;
|
|
use prometeu_hal::cartridge_loader::CartridgeLoader;
|
|
use prometeu_hal::log::{LogLevel, LogSource};
|
|
use prometeu_hal::primitives::Rect;
|
|
use prometeu_system::SystemProfileAction;
|
|
use prometeu_system::windows::WindowOwner;
|
|
|
|
#[derive(Debug, Clone)]
|
|
pub struct HubHomeStep;
|
|
|
|
impl HubHomeStep {
|
|
pub fn on_enter(&mut self, ctx: &mut PrometeuContext) {
|
|
ctx.os.log(LogLevel::Info, LogSource::Hub, 0, "Entering HubHome".to_string());
|
|
ctx.os.windows().remove_all_windows();
|
|
ctx.hub.init();
|
|
}
|
|
|
|
pub fn on_update(&mut self, ctx: &mut PrometeuContext) -> Option<FirmwareState> {
|
|
let outcome = ctx.hub.update_shell_profile(ctx.os, ctx.platform);
|
|
if let Some(report) = outcome.crash {
|
|
return Some(FirmwareState::AppCrashes(AppCrashesStep { report }));
|
|
}
|
|
|
|
match outcome.action {
|
|
Some(SystemProfileAction::LaunchNativeShell(app)) => {
|
|
let task_id = match ctx
|
|
.os
|
|
.sessions()
|
|
.try_create_native_shell_task(app.app_id(), app.title())
|
|
{
|
|
Ok(task_id) => task_id,
|
|
Err(error) => {
|
|
ctx.os.log(
|
|
LogLevel::Warn,
|
|
LogSource::Hub,
|
|
0,
|
|
format!("Failed to launch native shell {}: {:?}", app.title(), error),
|
|
);
|
|
return None;
|
|
}
|
|
};
|
|
let id = ctx.os.windows().add_window(
|
|
app.title().to_string(),
|
|
WindowOwner::Task(task_id),
|
|
Rect {
|
|
x: 40,
|
|
y: 20,
|
|
w: prometeu_hal::graphics_contract::WIDTH as i32 - 80,
|
|
h: prometeu_hal::graphics_contract::HEIGHT as i32 - 50,
|
|
},
|
|
app.color(),
|
|
);
|
|
ctx.os.windows().set_focus(id);
|
|
return Some(FirmwareState::ShellRunning(ShellRunningStep::new(task_id)));
|
|
}
|
|
Some(SystemProfileAction::LaunchGame { target }) => {
|
|
match CartridgeLoader::load(&target.path) {
|
|
Ok(cartridge) => {
|
|
if ctx.os.lifecycle().resident_game_task().is_none()
|
|
&& ctx.os.memcard().session.mode().is_some()
|
|
{
|
|
if ctx.os.memcard().session.unsaved() {
|
|
return Some(FirmwareState::ConfirmDiscard(
|
|
super::firmware_state::ConfirmDiscardStep::new(Some(cartridge)),
|
|
));
|
|
}
|
|
ctx.os.memcard().session.end_session();
|
|
}
|
|
if cartridge.app_mode == AppMode::Game
|
|
&& let Some(resident_task_id) = ctx.os.lifecycle().resident_game_task()
|
|
{
|
|
let resident_app_id = ctx
|
|
.os
|
|
.sessions()
|
|
.vm_session_for_task(resident_task_id)
|
|
.map(|session| session.app_id)
|
|
.unwrap_or(0);
|
|
|
|
if resident_app_id == cartridge.app_id {
|
|
return Some(FirmwareState::ResumeResidentGame);
|
|
}
|
|
|
|
if ctx.os.memcard().session.unsaved() {
|
|
return Some(FirmwareState::ConfirmDiscard(
|
|
super::firmware_state::ConfirmDiscardStep::new(Some(cartridge)),
|
|
));
|
|
}
|
|
if let Err(error) = resident_game_termination::terminate_resident_game(
|
|
ctx.os,
|
|
ctx.platform,
|
|
false,
|
|
) {
|
|
ctx.os.log(
|
|
LogLevel::Error,
|
|
LogSource::Hub,
|
|
0,
|
|
format!(
|
|
"Failed to terminate resident game app_id {} before launching {}: {:?}",
|
|
resident_app_id, cartridge.title, error
|
|
),
|
|
);
|
|
return None;
|
|
}
|
|
}
|
|
|
|
return Some(FirmwareState::LoadCartridge(
|
|
LoadCartridgeStep::new_game_switch(cartridge),
|
|
));
|
|
}
|
|
Err(error) => {
|
|
ctx.os.log(
|
|
LogLevel::Error,
|
|
LogSource::Hub,
|
|
0,
|
|
format!(
|
|
"Failed to launch Home game {}: {:?}",
|
|
target.path.display(),
|
|
error
|
|
),
|
|
);
|
|
}
|
|
}
|
|
}
|
|
Some(SystemProfileAction::KillResidentGame) => {
|
|
if ctx.os.memcard().session.unsaved() {
|
|
return Some(FirmwareState::ConfirmDiscard(
|
|
super::firmware_state::ConfirmDiscardStep::new(None),
|
|
));
|
|
}
|
|
|
|
if let Err(error) =
|
|
resident_game_termination::terminate_resident_game(ctx.os, ctx.platform, true)
|
|
{
|
|
ctx.os.log(
|
|
LogLevel::Error,
|
|
LogSource::Hub,
|
|
0,
|
|
format!("Failed to kill resident game from Hub: {error:?}"),
|
|
);
|
|
}
|
|
}
|
|
Some(SystemProfileAction::CloseShell) | None => {}
|
|
}
|
|
|
|
None
|
|
}
|
|
|
|
pub fn on_exit(&mut self, _ctx: &mut PrometeuContext) {}
|
|
}
|