diff --git a/examples/sdl/src/main.rs b/examples/sdl/src/main.rs index c9baeaa666e36056cee43bf0cb57ad0c50d21afd..0e8aa6ad00902fa4fbcc82ecc8c465ae917015b2 100644 --- a/examples/sdl/src/main.rs +++ b/examples/sdl/src/main.rs @@ -159,7 +159,8 @@ fn main() { //let rom = game_boy.load_rom_file("../../res/roms.prop/dr_mario.gb"); //let rom = game_boy.load_rom_file("../../res/roms.prop/alleyway.gb"); //let rom = game_boy.load_rom_file("../../res/roms.prop/super_mario.gb"); - let rom = game_boy.load_rom_file("../../res/roms.prop/super_mario_2.gb"); + //let rom = game_boy.load_rom_file("../../res/roms.prop/super_mario_2.gb"); + let rom = game_boy.load_rom_file("../../res/roms.prop/pokemon_red.gb"); //let rom = game_boy.load_rom_file("../../res/roms/firstwhite.gb"); //let rom = game_boy.load_rom_file("../../res/roms/opus5.gb"); diff --git a/src/rom.rs b/src/rom.rs index b41cfb968ce13c85fe019b9629f1da4348b27cba..ae5c68bb82dda475aae8670bbaddc5ad6e13632f 100644 --- a/src/rom.rs +++ b/src/rom.rs @@ -20,18 +20,62 @@ pub enum RomType { Mbc1RamBattery = 0x03, Mbc2 = 0x05, Mbc2Battery = 0x06, - Unknown = 0xff, + RomRam = 0x08, + RomRamBattery = 0x09, + Mmm01 = 0x0b, + Mmm01Ram = 0x0c, + Mmm01RamBattery = 0x0d, + Mbc3TimerBattery = 0x0f, + Mbc3TimerRamBattery = 0x10, + Mbc3 = 0x11, + Mbc3Ram = 0x12, + Mbc3RamBattery = 0x13, + Mbc5 = 0x19, + Mbc5Ram = 0x1a, + Mbc5RamBattery = 0x1b, + Mbc5Rumble = 0x1c, + Mbc5RumbleRam = 0x1d, + Mbc5RumbleRamBattery = 0x1e, + Mbc6 = 0x20, + Mbc7SensorRumbleRamBattery = 0x22, + PocketCamera = 0xfc, + BandaiTama5 = 0xfd, + HuC3 = 0xfe, + HuC1RamBattery = 0xff, + Unknown = 0xef, } impl Display for RomType { fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { let str = match self { RomType::RomOnly => "ROM Only", - RomType::Mbc1 => "MBC 1", - RomType::Mbc1Ram => "MBC 1 + RAM", - RomType::Mbc1RamBattery => "MBC 1 + RAM + Battery", - RomType::Mbc2 => "MBC 2", - RomType::Mbc2Battery => "MBC 2 + RAM", + RomType::Mbc1 => "MBC1", + RomType::Mbc1Ram => "MBC1 + RAM", + RomType::Mbc1RamBattery => "MBC1 + RAM + Battery", + RomType::Mbc2 => "MBC2", + RomType::Mbc2Battery => "MBC2 + RAM", + RomType::RomRam => "ROM + RAM", + RomType::RomRamBattery => "ROM + RAM + BATTERY", + RomType::Mmm01 => "MMM01", + RomType::Mmm01Ram => "MMM01 + RAM", + RomType::Mmm01RamBattery => "MMM01 + RAM + BATTERY", + RomType::Mbc3TimerBattery => "MBC3 + TIMER + BATTERY", + RomType::Mbc3TimerRamBattery => "MBC3 + TIMER + RAM + BATTERY", + RomType::Mbc3 => "MBC3", + RomType::Mbc3Ram => "MBC3 + RAM", + RomType::Mbc3RamBattery => "MBC3 + RAM + BATTERY", + RomType::Mbc5 => "MBC5", + RomType::Mbc5Ram => "MBC5 + RAM", + RomType::Mbc5RamBattery => "MBC5 + RAM + BATTERY", + RomType::Mbc5Rumble => "MBC5 + RUMBLE", + RomType::Mbc5RumbleRam => "MBC5 + RUMBLE + RAM", + RomType::Mbc5RumbleRamBattery => "MBC5 + RUMBLE + RAM + BATTERY", + RomType::Mbc6 => "MBC6", + RomType::Mbc7SensorRumbleRamBattery => "MBC6 + SENSOR + RUMBLE + RAM + BATTERY", + RomType::PocketCamera => "POCKET CAMERA", + RomType::BandaiTama5 => "BANDAI TAMA5", + RomType::HuC3 => "HuC3", + RomType::HuC1RamBattery => "HuC1 + RAM + BATTERY", RomType::Unknown => "Unknown", }; write!(f, "{}", str) @@ -212,7 +256,7 @@ impl Cartridge { RomType::Mbc1 => &MBC1, RomType::Mbc1Ram => &MBC1, RomType::Mbc1RamBattery => &MBC1, - _ => &NO_MBC, + rom_type => panic!("No MBC controller available for {}", rom_type), } } @@ -258,6 +302,28 @@ impl Cartridge { 0x03 => RomType::Mbc1RamBattery, 0x05 => RomType::Mbc2, 0x06 => RomType::Mbc2Battery, + 0x08 => RomType::RomRam, + 0x09 => RomType::RomRamBattery, + 0x0b => RomType::Mmm01, + 0x0c => RomType::Mmm01Ram, + 0x0d => RomType::Mmm01RamBattery, + 0x0f => RomType::Mbc3TimerBattery, + 0x10 => RomType::Mbc3TimerRamBattery, + 0x11 => RomType::Mbc3, + 0x12 => RomType::Mbc3Ram, + 0x13 => RomType::Mbc3RamBattery, + 0x19 => RomType::Mbc5, + 0x1a => RomType::Mbc5Ram, + 0x1b => RomType::Mbc5RamBattery, + 0x1c => RomType::Mbc5Rumble, + 0x1d => RomType::Mbc5RumbleRam, + 0x1e => RomType::Mbc5RumbleRamBattery, + 0x20 => RomType::Mbc6, + 0x22 => RomType::Mbc7SensorRumbleRamBattery, + 0xfc => RomType::PocketCamera, + 0xfd => RomType::BandaiTama5, + 0xfe => RomType::HuC3, + 0xff => RomType::HuC1RamBattery, _ => RomType::Unknown, } }