mirror of
https://github.com/FranLMSP/rmg-001.git
synced 2024-11-23 10:12:11 +00:00
Memory maps
This commit is contained in:
parent
1902884df9
commit
2afa2a1ff8
32
src/bus.rs
Normal file
32
src/bus.rs
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
pub enum MemoryMap {
|
||||||
|
BankZero,
|
||||||
|
BankSwitchable,
|
||||||
|
VideoRAM,
|
||||||
|
ExternalRAM,
|
||||||
|
WorkRAM1,
|
||||||
|
WorkRAM2,
|
||||||
|
EchoRAM,
|
||||||
|
SpriteAttributeTable,
|
||||||
|
NotUsable,
|
||||||
|
IORegisters,
|
||||||
|
HighRAM,
|
||||||
|
InterruptEnableRegister,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl MemoryMap {
|
||||||
|
pub fn get_map(address: u16) -> Self {
|
||||||
|
if address <= 0x3FFF {return Self::BankZero;}
|
||||||
|
if address >= 0x4000 && address <= 0x7FFF {return Self::BankSwitchable;}
|
||||||
|
if address >= 0x8000 && address <= 0x9FFF {return Self::VideoRAM;}
|
||||||
|
if address >= 0xA000 && address <= 0xBFFF {return Self::ExternalRAM;}
|
||||||
|
if address >= 0xC000 && address <= 0xCFFF {return Self::WorkRAM1;}
|
||||||
|
if address >= 0xD000 && address <= 0xDFFF {return Self::WorkRAM2;}
|
||||||
|
if address >= 0xE000 && address <= 0xFDFF {return Self::EchoRAM;} // Mirror of C000~DDFF
|
||||||
|
if address >= 0xFE00 && address <= 0xFE9F {return Self::SpriteAttributeTable;}
|
||||||
|
if address >= 0xFEA0 && address <= 0xFEFF {return Self::NotUsable;}
|
||||||
|
if address >= 0xFF00 && address <= 0xFF7F {return Self::IORegisters;}
|
||||||
|
if address >= 0xFF80 && address <= 0xFFFE {return Self::HighRAM;}
|
||||||
|
if address == 0xFFFF {return Self::InterruptEnableRegister;}
|
||||||
|
Self::BankZero
|
||||||
|
}
|
||||||
|
}
|
@ -1,3 +1,4 @@
|
|||||||
pub mod utils;
|
pub mod utils;
|
||||||
pub mod cpu;
|
pub mod cpu;
|
||||||
pub mod rom;
|
pub mod rom;
|
||||||
|
pub mod bus;
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
pub struct AddressRange(u16, u16);
|
|
||||||
|
|
||||||
pub enum BitIndex {
|
pub enum BitIndex {
|
||||||
I0,
|
I0,
|
||||||
I1,
|
I1,
|
||||||
|
Loading…
Reference in New Issue
Block a user