forked from Lea/invadeez
print emulator state as hex
This commit is contained in:
parent
14d04d32ee
commit
22e0217890
|
@ -95,11 +95,12 @@ fn set_register(register: Register, value: u8, state: &mut EmulatorState) {
|
|||
fn print_state(state: &EmulatorState) {
|
||||
// State
|
||||
println!("\nsp\tpc\tei");
|
||||
println!("{}\t{}\t{}", state.sp, state.pc, state.ei);
|
||||
println!("{:#06x}\t{:#06x}\t{}", state.sp, state.pc, state.ei);
|
||||
|
||||
// Registers
|
||||
println!("\nB\tC\tD\tE\tH\tL\tA");
|
||||
println!("{}\t{}\t{}\t{}\t{}\t{}\t{}", state.b, state.c, state.d, state.e, state.h, state.l, state.a);
|
||||
println!("{:#04x}\t{:#04x}\t{:#04x}\t{:#04x}\t{:#04x}\t{:#04x}\t{:#04x}",
|
||||
state.b, state.c, state.d, state.e, state.h, state.l, state.a);
|
||||
|
||||
// Flags
|
||||
println!("\nz\ts\tp\tc");
|
||||
|
@ -129,11 +130,11 @@ fn main() {
|
|||
.expect("Provide a path to a ROM file to emulate as an argument");
|
||||
let file = fs::read(filename).expect("where file");
|
||||
|
||||
for i in 0..8192 {
|
||||
for i in 0..(MEMORY_SIZE.min(file.len())) {
|
||||
state.memory[i] = file[i];
|
||||
}
|
||||
|
||||
while state.pc < 8192 {
|
||||
while state.pc < MEMORY_SIZE as u16 {
|
||||
tick(&mut state);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue