mirror of
https://github.com/FranLMSP/rmg-001.git
synced 2026-08-05 17:50:04 -04:00
Refactor 16bit bus read write
This commit is contained in:
+11
-1
@@ -1,3 +1,4 @@
|
||||
use crate::utils::{join_bytes};
|
||||
use crate::rom::ROM;
|
||||
|
||||
pub enum MemoryMap {
|
||||
@@ -46,7 +47,6 @@ impl Bus {
|
||||
Ok(rom) => rom,
|
||||
_ => ROM::from_bytes(&[0; 0xFFFF])
|
||||
};
|
||||
game_rom.print_content(Some(0x102));
|
||||
Self {
|
||||
data: [0; 0x10000],
|
||||
game_rom,
|
||||
@@ -62,7 +62,17 @@ impl Bus {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn read_16bit(&self, address: u16) -> u16 {
|
||||
join_bytes(self.read(address + 1), self.read(address))
|
||||
}
|
||||
|
||||
pub fn write(&mut self, address: u16, data: u8) {
|
||||
self.data[address as usize] = data;
|
||||
}
|
||||
|
||||
pub fn write_16bit(&mut self, address: u16, data: u16) {
|
||||
let bytes = data.to_be_bytes();
|
||||
self.write(address, bytes[1]);
|
||||
self.write(address + 1, bytes[0]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user