chore: clean up code
This commit is contained in:
parent
84babc4d69
commit
3d82465b04
17
src/bus.rs
17
src/bus.rs
|
@ -70,17 +70,18 @@ impl Bus {
|
||||||
match addr {
|
match addr {
|
||||||
0x0000..=0x3FFF => {
|
0x0000..=0x3FFF => {
|
||||||
// 16KB ROM bank 00
|
// 16KB ROM bank 00
|
||||||
if addr <= 0x00FF && self.boot.is_some() {
|
if addr < 0x00FF {
|
||||||
let boot = self.boot.unwrap();
|
if let Some(boot) = self.boot {
|
||||||
boot[addr as usize]
|
return boot[addr as usize];
|
||||||
} else {
|
}
|
||||||
match &self.cartridge {
|
}
|
||||||
|
|
||||||
|
match self.cartridge.as_ref() {
|
||||||
Some(cart) => cart.read_byte(addr),
|
Some(cart) => cart.read_byte(addr),
|
||||||
None => panic!("Tried to read from a non-existant cartridge"),
|
None => panic!("Tried to read from a non-existant cartridge"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
0x4000..=0x7FFF => match self.cartridge.as_ref() {
|
||||||
0x4000..=0x7FFF => match &self.cartridge {
|
|
||||||
// 16KB ROM Bank 01 -> NN (switchable via MB)
|
// 16KB ROM Bank 01 -> NN (switchable via MB)
|
||||||
Some(cart) => cart.read_byte(addr),
|
Some(cart) => cart.read_byte(addr),
|
||||||
None => panic!("Tried to read from a non-existant cartridge"),
|
None => panic!("Tried to read from a non-existant cartridge"),
|
||||||
|
@ -89,7 +90,7 @@ impl Bus {
|
||||||
// 8KB Video RAM
|
// 8KB Video RAM
|
||||||
self.ppu.vram[(addr - 0x8000) as usize]
|
self.ppu.vram[(addr - 0x8000) as usize]
|
||||||
}
|
}
|
||||||
0xA000..=0xBFFF => match &self.cartridge {
|
0xA000..=0xBFFF => match self.cartridge.as_ref() {
|
||||||
// 8KB External RAM
|
// 8KB External RAM
|
||||||
Some(cart) => cart.read_byte(addr),
|
Some(cart) => cart.read_byte(addr),
|
||||||
None => panic!("Tried to read from the external RAM of a non-existant cartridge"),
|
None => panic!("Tried to read from the external RAM of a non-existant cartridge"),
|
||||||
|
|
Loading…
Reference in New Issue