From 429e85da9d7c8ea14d6a9173d060155ee47f4a69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Magalh=C3=A3es?= <joamag@gmail.com> Date: Mon, 7 Aug 2023 15:31:35 +0100 Subject: [PATCH] chore: better ram data handling --- src/state.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/state.rs b/src/state.rs index e60d2217..dadef710 100644 --- a/src/state.rs +++ b/src/state.rs @@ -99,7 +99,7 @@ impl Serialize for BeesState { data.seek(SeekFrom::Start(self.footer.start_offset as u64)) .unwrap(); - // @TODO we need to soft code this loading process to make it + // @TODO: we need to soft code this loading process to make it // more flexible and able to handle a random sequence of blocks // as we never know which blocks are we going to find self.name.load(data); @@ -572,7 +572,7 @@ impl Serialize for BeesCore { impl State for BeesCore { fn from_gb(gb: &mut GameBoy) -> Self { let mut core = Self::new( - String::from("GD "), + String::from("GD "), // @TODO: use the proper string gb.cpu_i().pc(), gb.cpu_i().af(), gb.cpu_i().bc(), @@ -582,10 +582,12 @@ impl State for BeesCore { gb.cpu_i().ime(), gb.mmu_i().ie, 0, + // @TODO: these registers cannot be totally retrieved gb.mmu().read_many(0xff00, 128).try_into().unwrap(), ); core.ram.fill_buffer(gb.mmu().ram()); core.vram.fill_buffer(&gb.mmu().read_many(0x8000, 0x2000)); + core.mbc_ram.fill_buffer(gb.rom_i().ram_data()); core.oam.fill_buffer(&gb.mmu().read_many(0xfe00, 0x00a0)); core.hram.fill_buffer(&gb.mmu().read_many(0xff80, 0x007f)); core @@ -604,9 +606,9 @@ impl State for BeesCore { gb.mmu().write_many(0xff00, &self.io_registers); - gb.mmu().set_ram(self.ram.buffer.clone()); + gb.mmu().set_ram(self.ram.buffer.to_vec()); gb.mmu().write_many(0x8000, &self.vram.buffer); - //@TODO the MBC is missing + gb.rom().set_ram_data(&self.mbc_ram.buffer); gb.mmu().write_many(0xfe00, &self.oam.buffer); gb.mmu().write_many(0xff80, &self.hram.buffer); //@TODO the background palettes are missing - CGB only -- GitLab