WIP PPU structure

This commit is contained in:
2022-12-12 22:04:03 -05:00
parent 0d1e8f8078
commit a3f12e61b4
6 changed files with 26 additions and 5 deletions
+4 -4
View File
@@ -2,19 +2,19 @@ use super::registers::PPURegisters;
pub struct PPU {
framebuffer: Vec<u8>,
registers: PPURegisters,
pub registers: PPURegisters,
}
impl PPU {
pub fn new() -> Self {
Self {
framebuffer: vec![],
registers: PPURegisters,
registers: PPURegisters::new(),
}
}
pub fn tick(&mut self, cycles: usize) {
for _ in 0..cycles {
pub fn tick(&mut self, cpu_cycles: usize) {
for _ in 0..cpu_cycles {
self.do_cycle();
}
}
+12 -1
View File
@@ -61,10 +61,21 @@ pub const TMW: u16 = 0x212E; // Window Area Main Screen Disable (W)
pub const TSW: u16 = 0x212F; // Window Area Sub Screen Disable (W)
pub struct PPURegisters {
data: [u8; 256],
}
impl PPURegisters {
pub fn new() -> Self {
Self {
data: [0x00; 256],
}
}
pub fn read(&self, address: u16) -> u8 {
self.data[(address as usize) - 0x2100]
}
pub fn write(&mut self, address: u16, value: u8) {
self.data[(address as usize) - 0x2100] = value;
}
}