@@ -162,7 +162,6 @@ enum VMCommand {
162162 Pause ,
163163 Step ,
164164 Continue ,
165- Restart ,
166165 SetPower ( bool ) ,
167166 SetPause ( bool ) ,
168167 SetSingleStep ( bool ) ,
@@ -356,7 +355,6 @@ fn process_cmd(out: &TextContent, cmd: &str) -> Option<VMCommand> {
356355 "pause" => VMCommand :: Pause ,
357356 "s" | "step" => VMCommand :: Step ,
358357 "c" | "continue" => VMCommand :: Continue ,
359- "rs" | "restart" => VMCommand :: Restart ,
360358 "b" | "break" if cmd. len ( ) >= 2 => match cmd[ 1 ] {
361359 "clear" => VMCommand :: SetBreakpoint ( None ) ,
362360 value => match u32:: from_str_radix ( value. trim_start_matches ( "0x" ) , 16 ) {
@@ -517,6 +515,8 @@ fn main() -> Result<(), Box<dyn Error>> {
517515
518516 // switch to TUI
519517
518+ println ! ( "Starting." ) ;
519+
520520 let stdout = TextContent :: new ( "" ) ;
521521 let debug = TextContent :: new ( "" ) ;
522522
@@ -542,19 +542,18 @@ fn main() -> Result<(), Box<dyn Error>> {
542542 * single_step = cli. step ;
543543 }
544544
545- let mut prev_power = false ;
545+ let mut prev_power = true ;
546546 let mut frozen = false ;
547547 let mut ticks = 0 ;
548548 let mut uart_buf = String :: new ( ) ;
549- let mut start = Instant :: now ( ) ;
550- let mut next_state_update = start;
551549 let state_update_interval = Duration :: from_secs_f64 ( 1. / 8. ) ;
550+ let start = Instant :: now ( ) ;
551+ let mut run_start = start;
552+ let mut next_state_update = start;
552553
553554 loop {
554- let now = Instant :: now ( ) ;
555- let time = now - start;
556555 if !frozen {
557- vm. do_tick_with_delta ( time , cli. delta ) ;
556+ vm. do_tick_with_delta ( start . elapsed ( ) , cli. delta ) ;
558557 ticks += 1 ;
559558 }
560559
@@ -579,6 +578,7 @@ fn main() -> Result<(), Box<dyn Error>> {
579578 }
580579 }
581580
581+ let now = Instant :: now ( ) ;
582582 if now >= next_state_update
583583 && let BuildingData :: Switch ( power) = & mut * power_switch. data . borrow_mut ( )
584584 && let BuildingData :: Message ( error_output) = & * error_output. data . borrow ( )
@@ -613,14 +613,6 @@ fn main() -> Result<(), Box<dyn Error>> {
613613 * pause = false ;
614614 * single_step = false ;
615615 }
616- VMCommand :: Restart => {
617- controller. state . set_variable ( u16str ! ( "pc" ) , 0 . into ( ) ) ?;
618- * power = true ;
619- * pause = false ;
620- * single_step = false ;
621- start = Instant :: now ( ) ;
622- next_state_update = start;
623- }
624616 VMCommand :: SetPower ( value) => {
625617 * power = value;
626618 }
@@ -716,8 +708,11 @@ fn main() -> Result<(), Box<dyn Error>> {
716708 if * power != prev_power {
717709 prev_power = * power;
718710 if * power {
719- tui_println ! ( do_tui, debug, "Starting." ) ;
711+ ticks = 0 ;
712+ run_start = Instant :: now ( ) ;
713+ next_state_update = run_start;
720714 } else {
715+ let time = run_start. elapsed ( ) ;
721716 tui_println ! ( do_tui, debug, "Processor halted." ) ;
722717 if !error_output. is_empty ( ) {
723718 tui_println ! ( do_tui, debug, "Error output: {}" , error_output. display( ) ) ;
0 commit comments