print emulator state as hex

This commit is contained in:
Lea 2023-01-25 19:40:31 +01:00
parent 14d04d32ee
commit 22e0217890
Signed by untrusted user: Lea
GPG key ID: 1BAFFE8347019C42
2 changed files with 6 additions and 4 deletions

View file

@ -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);
}

1
test Normal file
View file

@ -0,0 +1 @@
ニdニ<05>