diff --git a/gemma/src/chip8/instructions.rs b/gemma/src/chip8/instructions.rs index 671a31b..a090db3 100644 --- a/gemma/src/chip8/instructions.rs +++ b/gemma/src/chip8/instructions.rs @@ -803,18 +803,24 @@ impl Chip8CpuInstructions { let working_16_or = working_16_x | working_16_y; // shift them back to 8 bit. input.registers.poke(*x, working_16_or as u8); + // reset of VF quirk + input.registers.poke(0x0f, 0x00); debug!("OrVxVy [0x{x:1x}] [0x{y:1x}]") } // 0x8xy2 Set Vx = Vx AND Vy Chip8CpuInstructions::AND(x, y) => { let lhs_16 = input.registers.peek(*x) as u16; let rhs_16 = input.registers.peek(*y) as u16; + // reset of VF quirk + input.registers.poke(0x0f, 0x00); input.registers.poke(*x, (lhs_16 & rhs_16) as u8); } // 0x8xy3 Set Vx = Vx XOR Vy Chip8CpuInstructions::ORY(x, y) => { let lhs_16 = input.registers.peek(*x) as u16; let rhs_16 = input.registers.peek(*y) as u16; + // reset of VF quirk + input.registers.poke(0x0f, 0x00); input.registers.poke(*x, (lhs_16 ^ rhs_16) as u8); } // 0x8xy4 Set Vx = Vx + Vy (SET VF on Carry) @@ -1107,7 +1113,7 @@ impl Chip8CpuInstructions { Chip8CpuInstructions::LDIX(x) => { // Store registers V0 through Vx in memory starting at location I. // - // The interpreter copies the values of registers V0 through Vx into memory, + // The interpreter copi=es the values of registers V0 through Vx into memory, // starting at the address in I. let offset = input.registers.peek_i(); for i in 0..=*x { diff --git a/gemmaimgui/src/bin/gemmaimgui.rs b/gemmaimgui/src/bin/gemmaimgui.rs index d8fa033..93ab949 100644 --- a/gemmaimgui/src/bin/gemmaimgui.rs +++ b/gemmaimgui/src/bin/gemmaimgui.rs @@ -22,7 +22,6 @@ fn main() { let mut system = Chip8ComputerManager::default(); let mut ui_state = ImGuiUiState::default(); - let target_ips = ui_state.target_ips; support::simple_init(file!(), move |_, ui| { let current_time = Instant::now(); @@ -54,14 +53,14 @@ fn main() { let target_ms = ui_state.frame_time; let loop_start_time = Instant::now(); - while Instant::now().duration_since(current_time).as_millis() < target_ms as u128 && num_cycles < target_ips { + while Instant::now().duration_since(current_time).as_millis() < target_ms as u128 && num_cycles < ui_state.target_ips { if system.tick() { num_cycles += 1; } } let cycles_time = Instant::now().duration_since(loop_start_time); if num_cycles > 0 { - println!("Ran for {}ms and executed {}/{} cycles.", cycles_time.as_millis(), num_cycles, target_ips); + println!("Ran for {}ms and executed {}/{} cycles.", cycles_time.as_millis(), num_cycles, ui_state.target_ips); } // GUI Parts if ui_state.show_video { diff --git a/gemmaimgui/src/bin/support/emmagui_support.rs b/gemmaimgui/src/bin/support/emmagui_support.rs index 5b632a6..f9d8d30 100644 --- a/gemmaimgui/src/bin/support/emmagui_support.rs +++ b/gemmaimgui/src/bin/support/emmagui_support.rs @@ -158,6 +158,7 @@ impl GemmaImguiSupport { ui.checkbox("Show Registers", &mut gui_state.show_registers); ui.same_line(); ui.checkbox("Show Keypad", &mut gui_state.show_keypad); + ui.input_int("Target IPS", &mut gui_state.target_ips).build(); }; }); }