diff --git a/crates/prometeu-core/src/firmware/firmware.rs b/crates/prometeu-core/src/firmware/firmware.rs index 2e2060b9..a91b3f46 100644 --- a/crates/prometeu-core/src/firmware/firmware.rs +++ b/crates/prometeu-core/src/firmware/firmware.rs @@ -46,11 +46,11 @@ impl Firmware { /// /// This method is called exactly once per Host frame (60Hz). /// It updates peripheral signals and delegates the logic to the current state. - pub fn step_frame(&mut self, signals: &InputSignals, hw: &mut dyn HardwareBridge) { + pub fn tick(&mut self, signals: &InputSignals, hw: &mut dyn HardwareBridge) { // 0. Process asset commits at the beginning of the frame boundary. hw.assets_mut().apply_commits(); - // 1. Update peripheral state using the latest signals from the Host. + // 1. Update the peripheral state using the latest signals from the Host. // This ensures input is consistent throughout the entire update. hw.pad_mut().begin_frame(signals); hw.touch_mut().begin_frame(signals); diff --git a/crates/prometeu-core/src/firmware/firmware_step_game_running.rs b/crates/prometeu-core/src/firmware/firmware_step_game_running.rs index 6c095b25..9bb65c47 100644 --- a/crates/prometeu-core/src/firmware/firmware_step_game_running.rs +++ b/crates/prometeu-core/src/firmware/firmware_step_game_running.rs @@ -11,7 +11,7 @@ impl GameRunningStep { } pub fn on_update(&mut self, ctx: &mut PrometeuContext) -> Option { - let result = ctx.os.step_frame(ctx.vm, ctx.signals, ctx.hw); + let result = ctx.os.tick(ctx.vm, ctx.signals, ctx.hw); if !ctx.os.logical_frame_active { ctx.hw.gfx_mut().present(); diff --git a/crates/prometeu-core/src/firmware/firmware_step_hub_home.rs b/crates/prometeu-core/src/firmware/firmware_step_hub_home.rs index accfb1a2..211ea674 100644 --- a/crates/prometeu-core/src/firmware/firmware_step_hub_home.rs +++ b/crates/prometeu-core/src/firmware/firmware_step_hub_home.rs @@ -21,7 +21,7 @@ impl HubHomeStep { ctx.hub.window_manager.remove_window(focused_id); } else { // System App runs here, drawing over the Hub background - error = ctx.os.step_frame(ctx.vm, ctx.signals, ctx.hw); + error = ctx.os.tick(ctx.vm, ctx.signals, ctx.hw); } } diff --git a/crates/prometeu-core/src/prometeu_os/prometeu_os.rs b/crates/prometeu-core/src/prometeu_os/prometeu_os.rs index a85c8dde..773084ac 100644 --- a/crates/prometeu-core/src/prometeu_os/prometeu_os.rs +++ b/crates/prometeu-core/src/prometeu_os/prometeu_os.rs @@ -188,8 +188,8 @@ impl PrometeuOS { /// This method is responsible for managing the logical frame lifecycle. /// A single host tick might execute a full logical frame, part of it, /// or multiple frames depending on the configured slices. - pub fn step_frame(&mut self, vm: &mut VirtualMachine, signals: &InputSignals, hw: &mut dyn HardwareBridge) -> Option { - let start = std::time::Instant::now(); + pub fn tick(&mut self, vm: &mut VirtualMachine, signals: &InputSignals, hw: &mut dyn HardwareBridge) -> Option { + let start = Instant::now(); self.tick_index += 1; // If the system is paused, we don't advance unless there's a debug step request. @@ -214,13 +214,13 @@ impl PrometeuOS { } // 2. Budget Allocation - // Determine how many cycles we can run in this host tick. + // Determines how many cycles we can run in this host tick. let budget = std::cmp::min(Self::SLICE_PER_TICK, self.logical_frame_remaining_cycles); // 3. VM Execution if budget > 0 { - // Run the VM until budget is hit or FRAME_SYNC is reached. - let run_result = vm.run_budget(budget, self, hw); + // Run the VM until the budget is hit or FRAME_SYNC is reached. + let run_result = vm.run_budget(budget, self, hw); // internally dispatch to frame on SDK match run_result { Ok(run) => { @@ -416,12 +416,12 @@ mod tests { os.initialize_vm(&mut vm, &cartridge); // First tick - os.step_frame(&mut vm, &signals, &mut hw); + os.tick(&mut vm, &signals, &mut hw); let cycles_after_tick_1 = vm.cycles; assert!(cycles_after_tick_1 >= PrometeuOS::CYCLES_PER_LOGICAL_FRAME); // Second tick - Now it SHOULD NOT gain more budget - os.step_frame(&mut vm, &signals, &mut hw); + os.tick(&mut vm, &signals, &mut hw); let cycles_after_tick_2 = vm.cycles; // FIX: It should not have consumed cycles in the second tick because the logical frame budget ended @@ -457,7 +457,7 @@ mod tests { os.initialize_vm(&mut vm, &cartridge); // First tick - os.step_frame(&mut vm, &signals, &mut hw); + os.tick(&mut vm, &signals, &mut hw); let cycles_after_tick_1 = vm.cycles; // Should have stopped at FrameSync @@ -465,7 +465,7 @@ mod tests { assert!(cycles_after_tick_1 < PrometeuOS::CYCLES_PER_LOGICAL_FRAME); // Second tick - Should reset the budget and run a bit more until the next FrameSync - os.step_frame(&mut vm, &signals, &mut hw); + os.tick(&mut vm, &signals, &mut hw); let cycles_after_tick_2 = vm.cycles; assert!(cycles_after_tick_2 > cycles_after_tick_1, "VM should have consumed more cycles because FrameSync reset the budget"); diff --git a/crates/prometeu-runtime-desktop/src/runner.rs b/crates/prometeu-runtime-desktop/src/runner.rs index 6ae61c74..0d5ec15a 100644 --- a/crates/prometeu-runtime-desktop/src/runner.rs +++ b/crates/prometeu-runtime-desktop/src/runner.rs @@ -266,7 +266,7 @@ impl ApplicationHandler for HostRunner { while self.accumulator >= self.frame_target_dt { // Unless the debugger is waiting for a 'start' command, advance the system. if !self.debugger.waiting_for_start { - self.firmware.step_frame(&self.input.signals, &mut self.hardware); + self.firmware.tick(&self.input.signals, &mut self.hardware); } // Sync virtual audio commands to the physical mixer.