rusted-nes/src/main.rs

26 lines
750 B
Rust

use rusted_nes::sim6502::*;
use std::fs;
use std::fs::File;
use std::io::Read;
fn main() {
let args: Vec<String> = std::env::args().collect();
if args.len() < 2 {
panic!("Please provide a path to the rom")
}
let rom_path = &args[1];
let mut f = File::open(rom_path).expect("File not found");
let metadata = fs::metadata(rom_path).expect("Could not load metadata");
let bytes = metadata.len();
let mut buffer = vec![0; bytes as usize];
let bytes_read = f.read(&mut buffer).expect("Problem reading file into buffer");
println!("Read {} bytes", bytes_read);
let instructions = decode_instructions(&buffer, bytes_read as i32);
for inst in instructions {
println!("{:?}", inst);
}
}