chore(bus): ensure no read-only bits are overwritten by the cpu

This commit is contained in:
Rekai Nyangadzayi Musuka 2021-05-05 19:23:01 -05:00
parent f4e0a024eb
commit 6575eb5531
1 changed files with 4 additions and 4 deletions

View File

@ -29,11 +29,11 @@ bitfield! {
impl JoypadStatus {
pub(crate) fn update(&mut self, byte: u8) {
let action_row = (byte >> 5) & 0x01;
let direction_row = (byte >> 4) & 0x01;
// Bytes 3 -> 0 are Read Only
let mask = 0b00001111;
self.set_action_row(action_row.into());
self.set_direction_row(direction_row.into());
let read_only = self.0 & mask;
self.0 = (byte & !mask) | read_only;
}
}