diff --git a/gemma/src/chip8/instructions.rs b/gemma/src/chip8/instructions.rs index 2ce56a3..431197c 100644 --- a/gemma/src/chip8/instructions.rs +++ b/gemma/src/chip8/instructions.rs @@ -432,7 +432,7 @@ impl Chip8CpuInstructions { } } pub fn execute(&self, input: &mut Chip8Computer) -> Chip8Computer { - print!("INSTRUCTION {}", self); +// print!("INSTRUCTION {}", self); let start_time = Instant::now(); let start_pc = input.registers.peek_pc(); input.registers.poke_pc(start_pc + 2); @@ -665,21 +665,6 @@ impl Chip8CpuInstructions { let x_offset = input.registers.peek(*x) as u16; let y_offset = input.registers.peek(*y) as u16; - let mut buffer = vec![]; - - for byte_index in 0..*n { - buffer.push(input.memory.peek(byte_index as u16 + source_memory_offset)); - } - - - for (idx, byte) in buffer.iter().enumerate() { - let local_x = (x_offset + idx as u16) * 64; - for bit_index in 0..8 { - input.video_memory.poke(x_offset + (y_offset + bit_index as u16), (current_byte & (0x80 >> bit_index)) != 0); - } - } - - for byte_index in 0..*n { let current_byte = input.memory.peek(byte_index as u16 + source_memory_offset); let x_offset: u16 = (x_offset + byte_index as u16) * 64; @@ -688,12 +673,16 @@ impl Chip8CpuInstructions { } } - - if input.video_memory.has_frame_changed { - input.registers.poke(0xf, 1u8); + let target = if input.video_memory.has_frame_changed { + 1u8 } else { - input.registers.poke(0xf, 0u8); - } + 0u8 + }; + + input.registers.poke(0xf, target); + + + } Chip8CpuInstructions::SkpVx(x) => { // Ex9E - SKP Vx @@ -824,7 +813,7 @@ impl Chip8CpuInstructions { Chip8CpuInstructions::XXXXERRORINSTRUCTION => {} }; let cycle_time = Instant::now().duration_since(start_time).as_nanos(); - println!("\t\tTook {cycle_time}ms"); +// println!("\t\tTook {cycle_time}ms"); input.to_owned() } }