Small clippy improvements

This commit is contained in:
Kevin Hamacher 2020-02-20 19:19:37 +01:00
parent fff0f05b73
commit fc935ab214
3 changed files with 7 additions and 7 deletions

View File

@ -49,6 +49,6 @@ pub fn read_file<P: AsRef<Path>>(rom_path: P) -> Result<Box<[u8]>, io::Error> {
pub fn write_file<P: AsRef<Path>>(path: P, data: &Box<[u8]>) -> Result<(), io::Error> {
let mut file = fs::File::create(path)?;
file.write(&data)?;
file.write_all(&data)?;
Ok(())
}

View File

@ -61,7 +61,7 @@ impl MBC for MBC2 {
}
}
0x2000..=0x3FFF => {
if addr & 0x0100 == 1 {
if addr & 0x0100 == 0 {
self.rom_bank_no = val & 0x0F;
println!("MBC2: Selecting bank {:02X}", self.rom_bank_no);
} else {

View File

@ -5,7 +5,7 @@ mod square;
mod wave;
use self::pulse_simple::Playback;
use std::sync::{Arc, Mutex};
use std::sync::{Arc, Mutex, atomic::{AtomicBool, Ordering}};
use std::thread;
const OUTPUT_SAMPLE_RATE: usize = 48100;
@ -332,12 +332,12 @@ pub struct Sound {
pub struct SoundManager {
pub sound_object: Arc<Mutex<Sound>>,
handle: Option<std::thread::JoinHandle<()>>,
do_exit: Arc<Mutex<bool>>,
do_exit: Arc<AtomicBool>,
}
impl Drop for SoundManager {
fn drop(&mut self) {
*self.do_exit.lock().unwrap() = true;
self.do_exit.store(true, Ordering::Relaxed);
self.handle.take().and_then(|h| h.join().ok());
}
}
@ -347,7 +347,7 @@ impl SoundManager {
let mut res = SoundManager {
sound_object: Arc::new(Mutex::new(Sound::new())),
handle: None,
do_exit: Arc::new(Mutex::new(false)),
do_exit: Arc::new(AtomicBool::new(false)),
};
res.launch_thread();
@ -371,7 +371,7 @@ impl SoundManager {
// Counter, used for calling the 512 Hz timer
let mut counter = 0;
while !*do_exit.lock().unwrap() {
while !do_exit.load(Ordering::Relaxed) {
for _ in 0..100 {
let (s1, s2) = {
let mut c_obj = obj.lock().unwrap();