chirp-minifb: Add quirk toggles back in

This commit is contained in:
John 2023-04-03 05:45:22 -05:00
parent acc7629516
commit 9fcae555ce

View File

@ -43,32 +43,32 @@ struct Arguments {
)] )]
pub mode: Option<Mode>, pub mode: Option<Mode>,
// #[options( #[options(
// short = "z", short = "z",
// help = "Disable setting vF to 0 after a bitwise operation." help = "Disable setting vF to 0 after a bitwise operation."
// )] )]
// pub vfreset: bool, pub vfreset: bool,
// #[options( #[options(
// short = "x", short = "x",
// help = "Disable waiting for vblank after issuing a draw call." help = "Disable waiting for vblank after issuing a draw call."
// )] )]
// pub drawsync: bool, pub drawsync: bool,
// #[options( #[options(
// short = "c", short = "c",
// help = "Use CHIP-48 style DMA instructions, which don't touch I." help = "Use CHIP-48 style DMA instructions, which don't touch I."
// )] )]
// pub memory: bool, pub memory: bool,
// #[options( #[options(
// short = "v", short = "v",
// help = "Use CHIP-48 style bit-shifts, which don't touch vY." help = "Use CHIP-48 style bit-shifts, which don't touch vY."
// )] )]
// pub shift: bool, pub shift: bool,
// #[options( #[options(
// short = "b", short = "b",
// help = "Use SUPER-CHIP style indexed jump, which is indexed relative to v[adr]." help = "Use SUPER-CHIP style indexed jump, which is indexed relative to v[adr]."
// )] )]
// pub jumping: bool, pub jumping: bool,
#[options( #[options(
long = "break", long = "break",
help = "Set breakpoints for the emulator to stop at.", help = "Set breakpoints for the emulator to stop at.",
@ -111,7 +111,7 @@ impl State {
// Load the ROM file into RAM // Load the ROM file into RAM
Program [0x0200..0x1000] = &read(&options.file)?, Program [0x0200..0x1000] = &read(&options.file)?,
// Create a screen // Create a screen
Screen [0x1000..0x1400], Screen [0x1000..0x1100],
// Create a stack // Create a stack
Stack [0x0EA0..0x0F00], Stack [0x0EA0..0x0F00],
}, },
@ -134,6 +134,12 @@ impl State {
ui: UIBuilder::new(128, 64, &options.file).build()?, ui: UIBuilder::new(128, 64, &options.file).build()?,
ft: Instant::now(), 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); state.ch8.bus.write(0x1feu16, options.data);
Ok(state) Ok(state)
} }
@ -154,9 +160,10 @@ impl State {
let time = time.elapsed(); let time = time.elapsed();
let nspt = time.as_secs_f64() / ticks as f64; let nspt = time.as_secs_f64() / ticks as f64;
eprintln!( 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, nspt * 1_000_000_000.0,
((1.0 / 60.0f64) / nspt).trunc(), ((1.0 / 60.0f64) / nspt).trunc(),
(1.0 / nspt).trunc() / 1_000_000.0,
); );
} }
} }