aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/apu.rs5
-rw-r--r--src/bin.rs14
-rw-r--r--src/lib.rs4
3 files changed, 13 insertions, 10 deletions
diff --git a/src/apu.rs b/src/apu.rs
index 1a8a4fa..6b06b0b 100644
--- a/src/apu.rs
+++ b/src/apu.rs
@@ -26,8 +26,9 @@ impl LPFilter {
}
fn output(&mut self, input: i16) -> i16 {
- let out = cutoff((input as i32 - self.prev_out as i32)
- * LP_FACTOR / AUDIO_LEVEL_MAX);
+ let out = cutoff(self.prev_out as i32 +
+ (input as i32 - self.prev_out as i32)
+ * LP_FACTOR / AUDIO_LEVEL_MAX);
self.prev_out = out;
out
}
diff --git a/src/bin.rs b/src/bin.rs
index 332126d..7d94c7b 100644
--- a/src/bin.rs
+++ b/src/bin.rs
@@ -5,8 +5,7 @@ use std::sync::{Mutex, Condvar};
use std::io::Read;
use std::cell::RefCell;
use std::intrinsics::transmute;
-//use std::time::{Instant, Duration};
-//use std::thread;
+use std::process::exit;
extern crate sdl2;
#[macro_use] extern crate clap;
@@ -211,7 +210,7 @@ impl<'a> ppu::Screen for SDLWindow<'a> {
self.canvas.clear();
self.canvas.copy(&self.texture, self.copy_area, None).unwrap();
self.canvas.present();
- if self.poll() {std::process::exit(0);}
+ if self.poll() { exit(0) }
}
}
@@ -360,7 +359,7 @@ fn main() {
let fname = matches.value_of("INPUT").unwrap();
let mut file = File::open(fname).unwrap();
let mut rheader = [0; 16];
- println!("read {}", file.read(&mut rheader[..]).unwrap());
+ file.read(&mut rheader[..]).unwrap();
let header = unsafe{transmute::<[u8; 16], INesHeader>(rheader)};
let mirror = match ((header.flags6 >> 2) & 2) | (header.flags6 & 1) {
0 => MirrorType::Horizontal,
@@ -370,8 +369,11 @@ fn main() {
_ => MirrorType::Four,
};
let mapper_id = (header.flags7 & 0xf0) | (header.flags6 >> 4);
- println!("magic:{}, prg size:{}, chr size:{}, mirror type:{}, mapper:{}",
- std::str::from_utf8(&header.magic).unwrap(),
+ if std::str::from_utf8(&header.magic).unwrap() != "NES\x1a" {
+ println!("not an iNES file");
+ exit(1);
+ }
+ println!("prg size:{}, chr size:{}, mirror type:{}, mapper:{}",
header.prg_rom_nbanks,
header.chr_rom_nbanks,
mirror as u8,
diff --git a/src/lib.rs b/src/lib.rs
index 6439124..ade3a2d 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1,5 +1,5 @@
-//#![no_std]
-extern crate core;
+#![no_std]
+//extern crate core;
mod memory;
#[macro_use] mod mos6502;
mod ppu;