chore: inline some functions
	
		
			
	
		
	
	
		
	
		
			Some checks reported errors
		
		
	
	
		
			
				
	
				continuous-integration/drone/push Build was killed
				
			
		
		
	
	
				
					
				
			
		
			Some checks reported errors
		
		
	
	continuous-integration/drone/push Build was killed
				
			This commit is contained in:
		| @@ -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 { | ||||
|   | ||||
| @@ -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 | ||||
|     } | ||||
|   | ||||
| @@ -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>) { | ||||
|   | ||||
| @@ -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::*; | ||||
|   | ||||
| @@ -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!()) | ||||
|   | ||||
| @@ -629,6 +629,7 @@ impl ObjectBuffer { | ||||
|         self.len += 1; | ||||
|     } | ||||
|  | ||||
|     #[inline] | ||||
|     fn iter_mut(&mut self) -> std::slice::IterMut<'_, Option<ObjectAttribute>> { | ||||
|         self.inner.iter_mut() | ||||
|     } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user