From 7dfcd448206d2a99129529f2f7b9367e04647a2a Mon Sep 17 00:00:00 2001 From: Rekai Musuka Date: Mon, 1 Nov 2021 17:56:42 +0900 Subject: [PATCH] chore(emu): remove bus and bus_mut from cpu --- src/cpu.rs | 10 ---------- src/emu.rs | 16 ++++++++-------- 2 files changed, 8 insertions(+), 18 deletions(-) diff --git a/src/cpu.rs b/src/cpu.rs index c63901f..358339c 100644 --- a/src/cpu.rs +++ b/src/cpu.rs @@ -151,16 +151,6 @@ impl BusIo for Cpu { } impl Cpu { - #[inline] - pub(crate) fn bus(&self) -> &Bus { - &self.bus - } - - #[inline] - pub(crate) fn bus_mut(&mut self) -> &mut Bus { - &mut self.bus - } - fn handle_ei(&mut self) { match self.ime { ImeState::EiExecuted => self.ime = ImeState::Pending, diff --git a/src/emu.rs b/src/emu.rs index 7459b32..923d0c0 100644 --- a/src/emu.rs +++ b/src/emu.rs @@ -32,7 +32,7 @@ pub fn run_frame(emu: &mut Emulator, gamepad: &mut Gilrs, key: &WinitInputHelper } pub fn draw_frame(emu: &Emulator, buf: &mut [u8; GB_HEIGHT * GB_WIDTH * 4]) { - buf.copy_from_slice(emu.cpu.bus().ppu().frame_buf()); + buf.copy_from_slice(emu.cpu.bus.ppu().frame_buf()); } pub struct Emulator { @@ -81,25 +81,25 @@ impl Emulator { } fn load_rom(&mut self, rom: Vec) { - self.cpu.bus_mut().load_cart(rom); + self.cpu.bus.load_cart(rom); } #[inline] fn joyp_mut(&mut self) -> &mut Joypad { - self.cpu.bus_mut().joyp_mut() + self.cpu.bus.joyp_mut() } pub fn set_prod(&mut self, prod: SampleProducer) { - self.cpu.bus_mut().apu_mut().attach_producer(prod) + self.cpu.bus.apu_mut().attach_producer(prod) } pub fn title(&self) -> &str { - self.cpu.bus().cart_title().unwrap_or(DEFAULT_TITLE) + self.cpu.bus.cart_title().unwrap_or(DEFAULT_TITLE) } pub fn try_write_sav(&self) -> std::io::Result<()> { - if let Some(ext_ram) = self.cpu.bus().cart().map(|c| c.ext_ram()).flatten() { - if let Some(title) = self.cpu.bus().cart_title() { + if let Some(ext_ram) = self.cpu.bus.cart().map(|c| c.ext_ram()).flatten() { + if let Some(title) = self.cpu.bus.cart_title() { let mut save_path = Self::data_path().unwrap_or_else(|| PathBuf::from(".")); save_path.push(title); save_path.set_extension("sav"); @@ -113,7 +113,7 @@ impl Emulator { } pub fn try_load_sav(&mut self) -> std::io::Result<()> { - if let Some(cart) = self.cpu.bus_mut().cart_mut() { + if let Some(cart) = self.cpu.bus.cart_mut() { if let Some(title) = cart.title() { let mut save_path = Self::data_path().unwrap_or_else(|| PathBuf::from(".")); save_path.push(title);