Skip to content

Commit

Permalink
Accept ROM path as a command line argument
Browse files Browse the repository at this point in the history
  • Loading branch information
GroobleDierne committed Jul 18, 2021
1 parent 811e7f0 commit 7e0fc07
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
3 changes: 1 addition & 2 deletions src/chip8.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,7 @@ impl Cpu {
if x == 0 as u8 { return " " }else { return "\x1B[107m \x1B[49m" }
}).collect::<Vec<&str>>().join(""), "|"));
}
lines.push(format!("—————————————————————————————————————————————————————————————————— V{:?}", self.v));
lines.push("fdf".to_owned());
lines.push(format!("—————————————————————————————————————————————————————————————————— V{:?}\n", self.v));
print!("{}", lines.join("\n"));
if self.sound_timer > 0 {print!("\u{0007}")}
}
Expand Down
9 changes: 7 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
mod chip8;
use std::thread::sleep;
use std::time::Duration;
use std::env;

fn main() {
let args: Vec<String> = env::args().collect();

let rom = if args.len() > 1 {args[1].as_str()}else {"pong.rom"};

let mut cpu = chip8::create_cpu();
cpu.initialize();
cpu.load_rom("pong.rom").expect("Unable to load ROM");
cpu.load_rom(rom).expect("Unable to load ROM");

loop {
cpu.do_cycle();
sleep(Duration::from_millis(1000/70));
sleep(Duration::from_millis(1000/75));
}
}

0 comments on commit 7e0fc07

Please sign in to comment.