fix: properly implement LY==LYC behaviour

This commit is contained in:
2021-05-05 08:29:39 -05:00
parent b36f4441fa
commit abdff1251e
3 changed files with 35 additions and 22 deletions

View File

@@ -13,6 +13,16 @@ bitfield! {
pub from into PpuMode, mode, set_mode: 1, 0;
}
impl LCDStatus {
pub fn update(&mut self, byte: u8) {
// Bytes 2 -> 0 are read only
let mask = 0b00000111;
let read_only = self.0 & mask;
self.0 = (byte & !mask) | read_only;
}
}
impl Copy for LCDStatus {}
impl Clone for LCDStatus {
fn clone(&self) -> Self {
@@ -26,12 +36,6 @@ impl Default for LCDStatus {
}
}
impl From<u8> for LCDStatus {
fn from(byte: u8) -> Self {
Self(byte)
}
}
impl From<LCDStatus> for u8 {
fn from(status: LCDStatus) -> Self {
status.0