fix clippy warnings

This commit is contained in:
Denis-Cosmin Nutiu 2024-12-11 19:51:35 +02:00
parent 0fbb74b431
commit 083318bdc0
4 changed files with 34 additions and 38 deletions

View file

@ -45,7 +45,7 @@ impl Display for TerminalDisplay {
print!(" ")
}
}
print!("\n")
println!()
}
}
}

View file

@ -5,7 +5,7 @@ use crate::instruction::{Instruction, ProcessorInstruction};
use crate::sound::SoundModule;
use crate::stack::Stack;
use anyhow::anyhow;
use log::{info, trace, warn};
use log::{debug, info, trace, warn};
use rand::Rng;
use std::io::Read;
use std::sync::mpsc;
@ -116,12 +116,12 @@ where
T: Read,
{
self.load_rom(rom)?;
self.emulation_loop::<T>()?;
self.emulation_loop()?;
Ok(())
}
/// Emulation loop executes the fetch -> decode -> execute pipeline
fn emulation_loop<T>(&mut self) -> Result<(), anyhow::Error> {
fn emulation_loop(&mut self) -> Result<(), anyhow::Error> {
let mut tick_timer = Instant::now();
let target_fps: u128 = 60;
@ -465,7 +465,9 @@ where
where
T: Read,
{
rom.read(&mut self.memory[0x200..])?;
let amount = rom.read(&mut self.memory[0x200..])?;
debug!("Loaded ROM of size {amount} into memory");
// Set program counter to start of memory
self.program_counter = 0x200;

View file

@ -47,39 +47,34 @@ impl InputModule for CrossTermInput {
// It's guaranteed that read() won't block if `poll` returns `Ok(true)`
let read_result = read();
if let Ok(event) = read_result {
match event {
Event::Key(key_event) => match key_event.code {
KeyCode::Esc => {
return Some(0xFF);
if let Ok(Event::Key(key_event)) = read_result {
match key_event.code {
KeyCode::Esc => {
return Some(0xFF);
}
KeyCode::Char(character) => {
if let Some(char) = character.to_lowercase().next() {
return match char {
'1' => Some(1),
'2' => Some(2),
'3' => Some(3),
'4' => Some(0xC),
'q' => Some(4),
'w' => Some(5),
'e' => Some(6),
'r' => Some(0xD),
'a' => Some(7),
's' => Some(8),
'd' => Some(9),
'f' => Some(0xE),
'z' => Some(0xA),
'x' => Some(0),
'c' => Some(0xB),
'v' => Some(0xF),
_ => None,
};
}
KeyCode::Char(character) => {
let lowercase_character = character.to_lowercase();
for char in lowercase_character {
return match char {
'1' => Some(1),
'2' => Some(2),
'3' => Some(3),
'4' => Some(0xC),
'q' => Some(4),
'w' => Some(5),
'e' => Some(6),
'r' => Some(0xD),
'a' => Some(7),
's' => Some(8),
'd' => Some(9),
'f' => Some(0xE),
'z' => Some(0xA),
'x' => Some(0),
'c' => Some(0xB),
'v' => Some(0xF),
_ => None,
};
}
}
_ => {}
},
// ignore non key events
}
_ => {}
}
}

View file

@ -3,7 +3,6 @@ use crate::emulator::Emulator;
use crate::input::CrossTermInput;
use crate::sound::TerminalSound;
use clap::Parser;
use env_logger;
use std::fs::File;
mod display;