Skip to content

Commit 0410855

Browse files
committed
load file from args
1 parent d0afcbc commit 0410855

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

Diff for: src/main.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use std::io;
22
use std::io::prelude::*;
33
use std::fs::File;
4+
use std::env;
45

56
mod disassembler;
67
mod display;
@@ -10,13 +11,16 @@ mod keyboard;
1011
mod speaker;
1112

1213
fn main() {
13-
let mut cpu = cpu::Cpu::new();
14+
let args: Vec<String> = env::args().collect();
15+
let path = args.get(1).expect("You must specify the ROM file to run.");
1416

15-
let mut f = File::open("C:\\Users\\micah\\IdeaProjects\\ch8-rs\\roms\\pong.rom").unwrap();
17+
let mut f = File::open(path).unwrap();
1618
let mut buffer = Vec::new();
1719

1820
f.read_to_end(&mut buffer).unwrap();
1921

22+
let mut cpu = cpu::Cpu::new();
23+
2024
cpu.init();
2125
cpu.load_program(&buffer);
2226

0 commit comments

Comments
 (0)