allow booting bootrom
This commit is contained in:
parent
bbc05c48c7
commit
ca839d9375
1 changed files with 15 additions and 3 deletions
18
src/main.rs
18
src/main.rs
|
@ -17,6 +17,10 @@ struct Args {
|
|||
/// BootROM path
|
||||
#[arg(short, long)]
|
||||
bootrom: String,
|
||||
|
||||
/// Just run BootROM
|
||||
#[arg(long)]
|
||||
run_bootrom: bool,
|
||||
}
|
||||
|
||||
type Address = u16;
|
||||
|
@ -156,10 +160,18 @@ fn main() {
|
|||
let args = Args::parse();
|
||||
|
||||
let rom: ROM = fs::read(args.rom).expect("Could not load ROM");
|
||||
let _bootrom: ROM = fs::read(args.bootrom).expect("Could not load BootROM");
|
||||
let bootrom: ROM = fs::read(args.bootrom).expect("Could not load BootROM");
|
||||
let mut state = State::default();
|
||||
let run_rom = if args.run_bootrom {
|
||||
state.pc = Register { as_u16: 0x0 };
|
||||
bootrom
|
||||
} else {
|
||||
rom
|
||||
};
|
||||
|
||||
let mut cpu = CPU {
|
||||
memory: Memory::init(rom),
|
||||
state: State::default(),
|
||||
memory: Memory::init(run_rom),
|
||||
state,
|
||||
};
|
||||
loop {
|
||||
cpu.exec_next();
|
||||
|
|
Loading…
Add table
Reference in a new issue