33 lines
788 B
Rust
33 lines
788 B
Rust
// let's try to write our own, awesome emulator.
|
|
// gameboy (color?)
|
|
|
|
use std::path::Path;
|
|
use std::io::Read;
|
|
use std::fs;
|
|
use std::env;
|
|
|
|
mod cpu;
|
|
mod interconnect;
|
|
|
|
fn main() {
|
|
let bios_path = env::args().nth(1).unwrap();
|
|
let rom_path = env::args().nth(2).unwrap();
|
|
let bios = read_rom(&bios_path);
|
|
let rom = read_rom(&rom_path);
|
|
|
|
// Now we need to execute commands
|
|
let mut interconnect = interconnect::Interconnect::new(bios, rom);
|
|
let mut CPU = cpu::CPU::new(interconnect);
|
|
|
|
loop {
|
|
CPU.run_instruction();
|
|
}
|
|
}
|
|
|
|
fn read_rom<P: AsRef<Path>>(rom_path: P) -> Box<[u8]> {
|
|
let mut file = fs::File::open(rom_path).unwrap();
|
|
let mut buf = Vec::new();
|
|
file.read_to_end(&mut buf).expect("Reading file failed");
|
|
buf.into_boxed_slice()
|
|
}
|