mirror of
https://github.com/FranLMSP/rmg-001.git
synced 2024-11-23 18:21:31 +00:00
Small PPU refactor for HDMA addresses
This commit is contained in:
parent
a69c5be762
commit
885bfea434
29
src/ppu.rs
29
src/ppu.rs
@ -390,17 +390,14 @@ impl PPU {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_register(&self, address: u16) -> u8 {
|
pub fn get_register(&self, address: u16) -> u8 {
|
||||||
if address >= 0xFF51 && address <= 0xFF55 {
|
if address >= HDMA1_ADDRESS && address <= HDMA5_ADDRESS {
|
||||||
if address == HDMA1_ADDRESS {
|
return match address {
|
||||||
return self.hdma_source.to_be_bytes()[0];
|
HDMA1_ADDRESS => self.hdma_source.to_be_bytes()[0],
|
||||||
} else if address == HDMA2_ADDRESS {
|
HDMA2_ADDRESS => self.hdma_source.to_be_bytes()[1],
|
||||||
return self.hdma_source.to_be_bytes()[1];
|
HDMA3_ADDRESS => self.hdma_destination.to_be_bytes()[0],
|
||||||
} else if address == HDMA3_ADDRESS {
|
HDMA4_ADDRESS => self.hdma_destination.to_be_bytes()[1],
|
||||||
return self.hdma_destination.to_be_bytes()[0];
|
HDMA5_ADDRESS => self.hdma_start,
|
||||||
} else if address == HDMA4_ADDRESS {
|
_ => 0x00,
|
||||||
return self.hdma_destination.to_be_bytes()[1];
|
|
||||||
} else if address == HDMA5_ADDRESS {
|
|
||||||
return self.hdma_start;
|
|
||||||
}
|
}
|
||||||
} else if address >= 0xFF68 && address <= 0xFF6B {
|
} else if address >= 0xFF68 && address <= 0xFF6B {
|
||||||
return self.cram_registers[(address as usize) - 0xFF68];
|
return self.cram_registers[(address as usize) - 0xFF68];
|
||||||
@ -415,7 +412,15 @@ impl PPU {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_register(&mut self, address: u16, data: u8) {
|
pub fn set_register(&mut self, address: u16, data: u8) {
|
||||||
if address >= 0xFF51 && address <= 0xFF55 {
|
if address >= HDMA1_ADDRESS && address <= HDMA5_ADDRESS {
|
||||||
|
match address {
|
||||||
|
HDMA1_ADDRESS => self.hdma_source = (self.hdma_source & 0xFF) | ((data as u16) << 8),
|
||||||
|
HDMA2_ADDRESS => self.hdma_source = (self.hdma_source & 0xFF00) | (data as u16),
|
||||||
|
HDMA3_ADDRESS => self.hdma_destination = (self.hdma_destination & 0xFF) | ((data as u16) << 8),
|
||||||
|
HDMA4_ADDRESS => self.hdma_destination = (self.hdma_destination & 0xFF00) | (data as u16),
|
||||||
|
HDMA5_ADDRESS => self.hdma_start = data,
|
||||||
|
_ => (),
|
||||||
|
};
|
||||||
if address == HDMA1_ADDRESS {
|
if address == HDMA1_ADDRESS {
|
||||||
self.hdma_source = (self.hdma_source & 0xFF) | ((data as u16) << 8);
|
self.hdma_source = (self.hdma_source & 0xFF) | ((data as u16) << 8);
|
||||||
} else if address == HDMA2_ADDRESS {
|
} else if address == HDMA2_ADDRESS {
|
||||||
|
Loading…
Reference in New Issue
Block a user