update readme, remove todo! from bus and display registers

This commit is contained in:
2023-05-11 22:08:42 -05:00
parent 8333eb13cb
commit 0cc55d7b20
5 changed files with 66 additions and 10 deletions
+13 -2
View File
@@ -1,8 +1,13 @@
use crate::ppu::PPU;
use crate::cpu::internal_registers::InternalRegisters;
use crate::rom::ROM;
use crate::rom::lo_rom::LoROM;
pub struct Bus {
wram: [u8; 0x10000],
pub ppu: PPU,
pub rom: Box<dyn ROM>,
pub internal_registers: InternalRegisters,
}
#[derive(PartialEq, Debug)]
@@ -19,6 +24,8 @@ impl Bus {
Self {
wram: [0; 0x10000],
ppu: PPU::new(),
rom: Box::new(LoROM::new()),
internal_registers: InternalRegisters::new(),
}
}
@@ -54,7 +61,9 @@ impl Bus {
match section {
MemoryMap::WRAM => self.read_wram(address),
MemoryMap::PPU => self.ppu.registers.read(address as u16),
_ => todo!("Implement other memory sections. Address: {:#08X}", address),
MemoryMap::CPU => self.internal_registers.read(address as u16),
MemoryMap::Joypad => 0x00, // TODO: Placeholder
MemoryMap::Cartridge => self.rom.read(address),
}
}
@@ -63,7 +72,9 @@ impl Bus {
match section {
MemoryMap::WRAM => self.write_wram(address, value),
MemoryMap::PPU => self.ppu.registers.write(address as u16, value),
_ => todo!("Implement other memory sections. Address: {:#08X}", address),
MemoryMap::CPU => self.internal_registers.write(address as u16, value),
MemoryMap::Joypad => {}, // TODO: Placeholder
MemoryMap::Cartridge => self.rom.write(address, value),
}
}
}
+24
View File
@@ -0,0 +1,24 @@
pub const INTERNAL_REGISTERS_ADDRESS: u16 = 0x4200;
pub struct InternalRegisters {
_registers: [u8; 32],
}
impl InternalRegisters {
pub fn new() -> Self {
Self {
_registers: [0; 32],
}
}
pub fn read(&self, _address: u16) -> u8 {
// TODO: Placeholder
// self.registers[(address - INTERNAL_REGISTERS_ADDRESS) as usize]
0x00
}
pub fn write(&mut self, _address: u16, _value: u8) {
// TODO: Placeholder
// self.registers[(address - INTERNAL_REGISTERS_ADDRESS) as usize] = value;
}
}
+1
View File
@@ -4,3 +4,4 @@ pub mod bus;
pub mod registers;
pub mod instructions;
pub mod cycles;
pub mod internal_registers;