diff --git a/res/roms/test/cgb_acid2.gbc b/res/roms/test/cgb_acid2.gbc new file mode 100644 index 0000000000000000000000000000000000000000..5f71bd36060b46eefcf7785f81ce16a5a6c5fc67 Binary files /dev/null and b/res/roms/test/cgb_acid2.gbc differ diff --git a/src/gb.rs b/src/gb.rs index 867e6b0f0cd681ed74e10e5ac36d55f47aecf715..a4a936f7372ecaf42e3f709d926c7e282a674b10 100644 --- a/src/gb.rs +++ b/src/gb.rs @@ -82,6 +82,13 @@ impl Display for GameBoyMode { } } +#[cfg_attr(feature = "wasm", wasm_bindgen)] +#[derive(Clone, Copy, PartialEq, Eq)] +pub enum GameBoySpeed { + Normal = 0, + Double = 1, +} + #[cfg_attr(feature = "wasm", wasm_bindgen)] #[derive(Clone, Copy, PartialEq, Eq)] pub struct GameBoyConfig { diff --git a/src/mmu.rs b/src/mmu.rs index 7418189c16f070f0819b0ff57ac0e0ece92b6798..9914e86ad7701b0bd100c6642c91a7edfa4498db 100644 --- a/src/mmu.rs +++ b/src/mmu.rs @@ -1,7 +1,7 @@ use crate::{ apu::Apu, debugln, - gb::{GameBoyConfig, GameBoyMode}, + gb::{GameBoyConfig, GameBoyMode, GameBoySpeed}, pad::Pad, ppu::Ppu, rom::Cartridge, @@ -29,6 +29,8 @@ pub struct Mmu { /// (CGB only). pub key0: u8, + pub speed: GameBoySpeed, + /// Reference to the PPU (Pixel Processing Unit) that is going /// to be used both for VRAM reading/writing and to forward /// some of the access operations. @@ -110,6 +112,7 @@ impl Mmu { ram_offset: 0x1000, ie: 0x0, key0: 0x0, + speed: GameBoySpeed::Normal, mode, gbc, } @@ -253,7 +256,7 @@ impl Mmu { 0x4c => self.key0, // 0xFF4D - KEY1 (CGB only) - 0x4d => todo!("CGB speed switch"), + 0x4d => (false as u8) | ((self.speed as u8) << 7), // 0xFF50 - Boot active flag 0x50 => u8::from(self.boot_active),