cpu.rs: Separate lastkey from flags
This commit is contained in:
@@ -528,9 +528,9 @@ impl CPU {
|
||||
/// |`Fx0A`| Wait for key, then vX = K
|
||||
#[inline(always)]
|
||||
pub(super) fn wait_for_key(&mut self, x: Reg) {
|
||||
if let Some(key) = self.flags.lastkey {
|
||||
if let Some(key) = self.lastkey {
|
||||
self.v[x] = key as u8;
|
||||
self.flags.lastkey = None;
|
||||
self.lastkey = None;
|
||||
} else {
|
||||
self.pc = self.pc.wrapping_sub(2);
|
||||
self.flags.keypause = true;
|
||||
|
||||
@@ -19,8 +19,6 @@ pub struct Flags {
|
||||
pub draw_wait: bool,
|
||||
/// Set when the emulator is in high-res mode
|
||||
pub draw_mode: bool,
|
||||
/// Set to the last key that's been *released* after a keypause
|
||||
pub lastkey: Option<usize>,
|
||||
/// Represents the current emulator [Mode]
|
||||
pub mode: Mode,
|
||||
/// Represents the set of emulator [Quirks] to enable, independent of the [Mode]
|
||||
|
||||
@@ -861,7 +861,7 @@ mod io {
|
||||
assert!(cpu.release(key).expect("Key should be released"));
|
||||
assert!(!cpu.release(key).expect("Key shouldn't be released again"));
|
||||
assert!(!cpu.flags.keypause);
|
||||
assert_eq!(Some(key), cpu.flags.lastkey);
|
||||
assert_eq!(Some(key), cpu.lastkey);
|
||||
cpu.wait_for_key(x);
|
||||
assert_eq!(key as u8, cpu.v[x]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user