diff --git a/src/emulator.rs b/src/emulator.rs index e5f564c..be0ff85 100644 --- a/src/emulator.rs +++ b/src/emulator.rs @@ -212,9 +212,9 @@ where trace!("Set register {} to data {:04x}", register, data); self.registers[register as usize] = data } - ProcessorInstruction::AddValueToRegister(register, data) => { - trace!("Add to register {} data {:04x}", register, data); - let (result, _) = self.registers[register as usize].overflowing_add(data); + ProcessorInstruction::AddValueToRegister { register, value } => { + trace!("Add to register {} data {:04x}", register, value); + let (result, _) = self.registers[register as usize].overflowing_add(value); self.registers[register as usize] = result; } ProcessorInstruction::SetIndexRegister(data) => { diff --git a/src/instruction.rs b/src/instruction.rs index a0b036b..0f5ea32 100644 --- a/src/instruction.rs +++ b/src/instruction.rs @@ -21,7 +21,7 @@ pub enum ProcessorInstruction { /// Sets the register in the first argument to the given value SetRegister { register: u8, data: u8 }, /// Adds the value to the register - AddValueToRegister(u8, u8), + AddValueToRegister { register: u8, value: u8 }, /// Sets the index register SetIndexRegister(u16), /// Draws to the screen. @@ -140,10 +140,10 @@ impl Instruction { // Add value to register (0x7, _, _, _) => { // 7XNN - ProcessorInstruction::AddValueToRegister( - Self::grab_first_nibble(data), - Self::grab_last_byte(data), - ) + ProcessorInstruction::AddValueToRegister { + register: Self::grab_first_nibble(data), + value: Self::grab_last_byte(data), + } } // Set index register (0xA, _, _, _) => ProcessorInstruction::SetIndexRegister(Self::grab_inner_data(data)), @@ -407,7 +407,10 @@ mod tests { let instruction = Instruction::new([0x71, 0x40]); assert_eq!( instruction.processor_instruction, - ProcessorInstruction::AddValueToRegister(0x1, 0x40) + ProcessorInstruction::AddValueToRegister { + register: 0x1, + value: 0x40 + } ) }