Skip to content

Commit

Permalink
Implement nametable_base() and nmi_enable()
Browse files Browse the repository at this point in the history
  • Loading branch information
lyrakisk committed Nov 28, 2024
1 parent ad29ed7 commit af81d64
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/ppu/registers/control.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,27 @@ impl Control {
return Control { value };
}

pub fn nametable_base(&self) -> u16 {
match self.value & 0b0000_0011 {
0 => 0x2000,
1 => 0x2400,
2 => 0x2800,
3 => 0x2c00,
_ => panic!("Not possible")
}
}

pub fn vram_increment(&self) -> u16 {
if (self.value & 0b0000_0100) >> 2 == 0 {
return 1;
} else {
return 32;
}
}

pub fn nmi_enable(&self) -> bool {
return (self.value & 0b1000_0000) >> 7 == 1
}
}

impl Register8 for Control {
Expand All @@ -27,3 +41,4 @@ impl Register8 for Control {
self.value = data;
}
}

0 comments on commit af81d64

Please sign in to comment.