chore: inline some functions
continuous-integration/drone/push Build was killed
Details
continuous-integration/drone/push Build was killed
Details
This commit is contained in:
parent
bcd67cb317
commit
5882678bc5
|
@ -64,10 +64,12 @@ impl Bus {
|
||||||
self.boot.is_some()
|
self.boot.is_some()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub(crate) fn clock(&mut self) {
|
pub(crate) fn clock(&mut self) {
|
||||||
self.tick(4);
|
self.tick(4);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn tick(&mut self, limit: u8) {
|
fn tick(&mut self, limit: u8) {
|
||||||
for _ in 0..limit {
|
for _ in 0..limit {
|
||||||
self.timer.tick();
|
self.timer.tick();
|
||||||
|
@ -83,6 +85,11 @@ impl Bus {
|
||||||
self.oam_write_byte(dest_addr, byte);
|
self.oam_write_byte(dest_addr, byte);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub(crate) fn joyp_mut(&mut self) -> &mut Joypad {
|
||||||
|
&mut self.joypad
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Bus {
|
impl Bus {
|
||||||
|
|
|
@ -156,10 +156,12 @@ impl BusIo for Cpu {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Cpu {
|
impl Cpu {
|
||||||
|
#[inline]
|
||||||
pub(crate) fn bus(&self) -> &Bus {
|
pub(crate) fn bus(&self) -> &Bus {
|
||||||
&self.bus
|
&self.bus
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub(crate) fn bus_mut(&mut self) -> &mut Bus {
|
pub(crate) fn bus_mut(&mut self) -> &mut Bus {
|
||||||
&mut self.bus
|
&mut self.bus
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,8 +17,8 @@ pub fn run_frame(emu: &mut Emulator, gamepad: &mut Gilrs, key: &WinitInputHelper
|
||||||
if let Some(event) = gamepad.next_event() {
|
if let Some(event) = gamepad.next_event() {
|
||||||
joypad::handle_gamepad_input(emu.joyp_mut(), event);
|
joypad::handle_gamepad_input(emu.joyp_mut(), event);
|
||||||
}
|
}
|
||||||
|
|
||||||
joypad::handle_keyboard_input(emu.joyp_mut(), key);
|
joypad::handle_keyboard_input(emu.joyp_mut(), key);
|
||||||
|
|
||||||
while elapsed < CYCLES_IN_FRAME {
|
while elapsed < CYCLES_IN_FRAME {
|
||||||
elapsed += emu.step();
|
elapsed += emu.step();
|
||||||
}
|
}
|
||||||
|
@ -44,15 +44,18 @@ impl Emulator {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn step(&mut self) -> Cycle {
|
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>) {
|
fn load_cart(&mut self, rom: Vec<u8>) {
|
||||||
self.cpu.bus_mut().load_cart(rom)
|
self.cpu.bus_mut().load_cart(rom)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn joyp_mut(&mut self) -> &mut Joypad {
|
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>) {
|
pub fn set_prod(&mut self, prod: SampleProducer<f32>) {
|
||||||
|
|
|
@ -110,6 +110,7 @@ impl ButtonEvent {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn handle_keyboard_input(pad: &mut Joypad, input: &WinitInputHelper) {
|
pub fn handle_keyboard_input(pad: &mut Joypad, input: &WinitInputHelper) {
|
||||||
use winit::event::VirtualKeyCode;
|
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) {
|
pub fn handle_gamepad_input(pad: &mut Joypad, event: GamepadEvent) {
|
||||||
use Button::*;
|
use Button::*;
|
||||||
use GamepadEventType::*;
|
use GamepadEventType::*;
|
||||||
|
|
|
@ -14,7 +14,7 @@ use winit::window::{Window, WindowBuilder};
|
||||||
use winit_input_helper::WinitInputHelper;
|
use winit_input_helper::WinitInputHelper;
|
||||||
|
|
||||||
const WINDOW_SCALE: usize = 3;
|
const WINDOW_SCALE: usize = 3;
|
||||||
const AUDIO_ENABLED: bool = false;
|
const AUDIO_ENABLED: bool = true;
|
||||||
|
|
||||||
fn main() -> Result<()> {
|
fn main() -> Result<()> {
|
||||||
let app = App::new(crate_name!())
|
let app = App::new(crate_name!())
|
||||||
|
|
|
@ -629,6 +629,7 @@ impl ObjectBuffer {
|
||||||
self.len += 1;
|
self.len += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn iter_mut(&mut self) -> std::slice::IterMut<'_, Option<ObjectAttribute>> {
|
fn iter_mut(&mut self) -> std::slice::IterMut<'_, Option<ObjectAttribute>> {
|
||||||
self.inner.iter_mut()
|
self.inner.iter_mut()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue