37 lines
831 B
Rust
37 lines
831 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 display;
|
|
mod interconnect;
|
|
mod sound;
|
|
mod timer;
|
|
mod serial;
|
|
|
|
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 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()
|
|
}
|