From 9fcae555ce4522a7be4c84e1d7086fecaa18cbc9 Mon Sep 17 00:00:00 2001 From: John Breaux Date: Mon, 3 Apr 2023 05:45:22 -0500 Subject: [PATCH] chirp-minifb: Add quirk toggles back in --- src/bin/chirp-minifb/main.rs | 61 ++++++++++++++++++++---------------- 1 file changed, 34 insertions(+), 27 deletions(-) diff --git a/src/bin/chirp-minifb/main.rs b/src/bin/chirp-minifb/main.rs index c38dc1a..7038682 100644 --- a/src/bin/chirp-minifb/main.rs +++ b/src/bin/chirp-minifb/main.rs @@ -43,32 +43,32 @@ struct Arguments { )] pub mode: Option, - // #[options( - // short = "z", - // help = "Disable setting vF to 0 after a bitwise operation." - // )] - // pub vfreset: bool, - // #[options( - // short = "x", - // help = "Disable waiting for vblank after issuing a draw call." - // )] - // pub drawsync: bool, + #[options( + short = "z", + help = "Disable setting vF to 0 after a bitwise operation." + )] + pub vfreset: bool, + #[options( + short = "x", + help = "Disable waiting for vblank after issuing a draw call." + )] + pub drawsync: bool, - // #[options( - // short = "c", - // help = "Use CHIP-48 style DMA instructions, which don't touch I." - // )] - // pub memory: bool, - // #[options( - // short = "v", - // help = "Use CHIP-48 style bit-shifts, which don't touch vY." - // )] - // pub shift: bool, - // #[options( - // short = "b", - // help = "Use SUPER-CHIP style indexed jump, which is indexed relative to v[adr]." - // )] - // pub jumping: bool, + #[options( + short = "c", + help = "Use CHIP-48 style DMA instructions, which don't touch I." + )] + pub memory: bool, + #[options( + short = "v", + help = "Use CHIP-48 style bit-shifts, which don't touch vY." + )] + pub shift: bool, + #[options( + short = "b", + help = "Use SUPER-CHIP style indexed jump, which is indexed relative to v[adr]." + )] + pub jumping: bool, #[options( long = "break", help = "Set breakpoints for the emulator to stop at.", @@ -111,7 +111,7 @@ impl State { // Load the ROM file into RAM Program [0x0200..0x1000] = &read(&options.file)?, // Create a screen - Screen [0x1000..0x1400], + Screen [0x1000..0x1100], // Create a stack Stack [0x0EA0..0x0F00], }, @@ -134,6 +134,12 @@ impl State { ui: UIBuilder::new(128, 64, &options.file).build()?, ft: Instant::now(), }; + // Flip the state of the quirks + state.ch8.cpu.flags.quirks.bin_ops ^= options.vfreset; + state.ch8.cpu.flags.quirks.dma_inc ^= options.memory; + state.ch8.cpu.flags.quirks.draw_wait ^= options.drawsync; + state.ch8.cpu.flags.quirks.shift ^= options.shift; + state.ch8.cpu.flags.quirks.stupid_jumps ^= options.jumping; state.ch8.bus.write(0x1feu16, options.data); Ok(state) } @@ -154,9 +160,10 @@ impl State { let time = time.elapsed(); let nspt = time.as_secs_f64() / ticks as f64; eprintln!( - "{ticks},\t{time:.05?},\t{:.4}nspt,\t{}ipf", + "{ticks},\t{time:.05?},\t{:.4} nspt,\t{} ipf,\t{} mips", nspt * 1_000_000_000.0, ((1.0 / 60.0f64) / nspt).trunc(), + (1.0 / nspt).trunc() / 1_000_000.0, ); } }