chore: inline some functions
continuous-integration/drone/push Build was killed Details

This commit is contained in:
Rekai Nyangadzayi Musuka 2021-09-20 01:31:03 -03:00
parent 9baa15050e
commit 0e51bd204e
6 changed files with 19 additions and 4 deletions

View File

@ -64,10 +64,12 @@ impl Bus {
self.boot.is_some()
}
#[inline]
pub(crate) fn clock(&mut self) {
self.tick(4);
}
#[inline]
fn tick(&mut self, limit: u8) {
for _ in 0..limit {
self.timer.tick();
@ -83,6 +85,11 @@ impl Bus {
self.oam_write_byte(dest_addr, byte);
}
}
#[inline]
pub(crate) fn joyp_mut(&mut self) -> &mut Joypad {
&mut self.joypad
}
}
impl Bus {

View File

@ -156,10 +156,12 @@ 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
}

View File

@ -17,8 +17,8 @@ pub fn run_frame(emu: &mut Emulator, gamepad: &mut Gilrs, key: &WinitInputHelper
if let Some(event) = gamepad.next_event() {
joypad::handle_gamepad_input(emu.joyp_mut(), event);
}
joypad::handle_keyboard_input(emu.joyp_mut(), key);
while elapsed < CYCLES_IN_FRAME {
elapsed += emu.step();
}
@ -44,15 +44,18 @@ impl Emulator {
}
fn step(&mut self) -> Cycle {
self.cpu.step()
let cycles = self.cpu.step();
self.timestamp += cycles;
cycles
}
fn load_cart(&mut self, rom: Vec<u8>) {
self.cpu.bus_mut().load_cart(rom)
}
#[inline]
fn joyp_mut(&mut self) -> &mut Joypad {
&mut self.cpu.bus_mut().joypad
self.cpu.bus_mut().joyp_mut()
}
pub fn set_prod(&mut self, prod: SampleProducer<f32>) {

View File

@ -110,6 +110,7 @@ impl ButtonEvent {
}
}
#[inline]
pub fn handle_keyboard_input(pad: &mut Joypad, input: &WinitInputHelper) {
use winit::event::VirtualKeyCode;
@ -175,6 +176,7 @@ pub fn handle_keyboard_input(pad: &mut Joypad, input: &WinitInputHelper) {
}
}
#[inline]
pub fn handle_gamepad_input(pad: &mut Joypad, event: GamepadEvent) {
use Button::*;
use GamepadEventType::*;

View File

@ -14,7 +14,7 @@ use winit::window::{Window, WindowBuilder};
use winit_input_helper::WinitInputHelper;
const WINDOW_SCALE: usize = 3;
const AUDIO_ENABLED: bool = false;
const AUDIO_ENABLED: bool = true;
fn main() -> Result<()> {
let app = App::new(crate_name!())

View File

@ -629,6 +629,7 @@ impl ObjectBuffer {
self.len += 1;
}
#[inline]
fn iter_mut(&mut self) -> std::slice::IterMut<'_, Option<ObjectAttribute>> {
self.inner.iter_mut()
}