mirror of
https://github.com/FranLMSP/rmg-001.git
synced 2024-11-23 10:12:11 +00:00
Small PPU refactor for HDMA addresses
This commit is contained in:
parent
a69c5be762
commit
60bcc39a74
40
src/ppu.rs
40
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,18 +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 {
|
||||||
if address == HDMA1_ADDRESS {
|
match address {
|
||||||
self.hdma_source = (self.hdma_source & 0xFF) | ((data as u16) << 8);
|
HDMA1_ADDRESS => self.hdma_source = (self.hdma_source & 0xFF) | ((data as u16) << 8),
|
||||||
} else if address == HDMA2_ADDRESS {
|
HDMA2_ADDRESS => self.hdma_source = (self.hdma_source & 0xFF00) | (data as u16),
|
||||||
self.hdma_source = (self.hdma_source & 0xFF00) | (data as u16);
|
HDMA3_ADDRESS => self.hdma_destination = (self.hdma_destination & 0xFF) | ((data as u16) << 8),
|
||||||
} else if address == HDMA3_ADDRESS {
|
HDMA4_ADDRESS => self.hdma_destination = (self.hdma_destination & 0xFF00) | (data as u16),
|
||||||
self.hdma_destination = (self.hdma_destination & 0xFF) | ((data as u16) << 8);
|
HDMA5_ADDRESS => self.hdma_start = data,
|
||||||
} else if address == HDMA4_ADDRESS {
|
_ => (),
|
||||||
self.hdma_destination = (self.hdma_destination & 0xFF00) | (data as u16);
|
};
|
||||||
} else if address == HDMA5_ADDRESS {
|
|
||||||
self.hdma_start = data;
|
|
||||||
}
|
|
||||||
} else if address >= 0xFF68 && address <= 0xFF6B {
|
} else if address >= 0xFF68 && address <= 0xFF6B {
|
||||||
self.cram_registers[(address as usize) - 0xFF68] = data;
|
self.cram_registers[(address as usize) - 0xFF68] = data;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user