Fctor out repeated update_fp calls in handle_fp_interaction

This commit is contained in:
pjht 2024-02-01 18:48:45 -06:00
parent 0c76aab81c
commit a98a9c3d8b
Signed by: pjht
GPG Key ID: 7B5F6AFBEC7EE78E

View File

@ -50,7 +50,6 @@ impl EmuState {
ActionSwitch::SingleStep => { ActionSwitch::SingleStep => {
if state == SwitchState::Up { if state == SwitchState::Up {
self.run_cpu_cycle(); self.run_cpu_cycle();
self.update_fp();
} }
} }
ActionSwitch::Examine => { ActionSwitch::Examine => {
@ -59,11 +58,9 @@ impl EmuState {
self.cpu.finish_m_cycle(0xC3); // JMP self.cpu.finish_m_cycle(0xC3); // JMP
self.cpu.finish_m_cycle(self.fp_state.ad_sws() as u8); self.cpu.finish_m_cycle(self.fp_state.ad_sws() as u8);
self.cpu.finish_m_cycle((self.fp_state.ad_sws() >> 8) as u8); self.cpu.finish_m_cycle((self.fp_state.ad_sws() >> 8) as u8);
self.update_fp();
} else if state == SwitchState::Down { } else if state == SwitchState::Down {
// Assume M1 // Assume M1
self.cpu.finish_m_cycle(0x0); // NOP self.cpu.finish_m_cycle(0x0); // NOP
self.update_fp();
} }
} }
ActionSwitch::Deposit => { ActionSwitch::Deposit => {
@ -71,19 +68,16 @@ impl EmuState {
// Assume M1 // Assume M1
self.mem[self.cpu.get_mem_cycle().address() as usize] = self.mem[self.cpu.get_mem_cycle().address() as usize] =
self.fp_state.ad_sws() as u8; self.fp_state.ad_sws() as u8;
self.update_fp();
} else if state == SwitchState::Down { } else if state == SwitchState::Down {
// Assume M1 // Assume M1
self.cpu.finish_m_cycle(0x0); // NOP self.cpu.finish_m_cycle(0x0); // NOP
self.mem[self.cpu.get_mem_cycle().address() as usize] = self.mem[self.cpu.get_mem_cycle().address() as usize] =
self.fp_state.ad_sws() as u8; self.fp_state.ad_sws() as u8;
self.update_fp();
} }
} }
ActionSwitch::Reset => { ActionSwitch::Reset => {
if state == SwitchState::Up { if state == SwitchState::Up {
self.cpu.reset(); self.cpu.reset();
self.update_fp();
} }
} }
ActionSwitch::Protect => (), ActionSwitch::Protect => (),
@ -97,14 +91,13 @@ impl EmuState {
self.audio_tx.send(AudioMessage::FanOn).unwrap(); self.audio_tx.send(AudioMessage::FanOn).unwrap();
self.running = false; self.running = false;
self.cpu = I8080::new(); self.cpu = I8080::new();
self.update_fp();
} else { } else {
self.audio_tx.send(AudioMessage::FanOff).unwrap(); self.audio_tx.send(AudioMessage::FanOff).unwrap();
}
}
}
self.update_fp(); self.update_fp();
} }
}
}
}
pub fn update_fp(&mut self) { pub fn update_fp(&mut self) {
if !self.fp_state.power() { if !self.fp_state.power() {