process messages outside of step loop
This commit is contained in:
parent
bb6ab69d66
commit
cbc5a634e2
19
src/lib.rs
19
src/lib.rs
|
@ -101,6 +101,7 @@ pub fn init(
|
||||||
verbose_println!("\n\n Begin execution...\n");
|
verbose_println!("\n\n Begin execution...\n");
|
||||||
match options.step_by {
|
match options.step_by {
|
||||||
Some(step_size) => loop {
|
Some(step_size) => loop {
|
||||||
|
process_messages(&receiver, &mut cpu);
|
||||||
for _ in 0..step_size {
|
for _ in 0..step_size {
|
||||||
cycle_num += 1;
|
cycle_num += 1;
|
||||||
if options.cycle_count {
|
if options.cycle_count {
|
||||||
|
@ -113,6 +114,17 @@ pub fn init(
|
||||||
pause();
|
pause();
|
||||||
},
|
},
|
||||||
None => loop {
|
None => loop {
|
||||||
|
process_messages(&receiver, &mut cpu);
|
||||||
|
cycle_num += 1;
|
||||||
|
if options.cycle_count {
|
||||||
|
print_cycles(&cycle_num);
|
||||||
|
}
|
||||||
|
run_cycle(&mut cpu);
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn process_messages(receiver: &Receiver<EmulatorMessage>, cpu: &mut Cpu) {
|
||||||
while let Ok(msg) = receiver.try_recv() {
|
while let Ok(msg) = receiver.try_recv() {
|
||||||
match msg {
|
match msg {
|
||||||
EmulatorMessage::Stop => {
|
EmulatorMessage::Stop => {
|
||||||
|
@ -121,13 +133,6 @@ pub fn init(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cycle_num += 1;
|
|
||||||
if options.cycle_count {
|
|
||||||
print_cycles(&cycle_num);
|
|
||||||
}
|
|
||||||
run_cycle(&mut cpu);
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn run_cycle(cpu: &mut Cpu) {
|
fn run_cycle(cpu: &mut Cpu) {
|
||||||
|
|
Loading…
Reference in a new issue