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