use c-like struct for SkipEqualVXVY & SkipNotEqualVXVY instruction
This commit is contained in:
parent
4cba27de97
commit
e7b69b72b2
2 changed files with 27 additions and 21 deletions
|
@ -359,7 +359,7 @@ where
|
||||||
self.program_counter += 2
|
self.program_counter += 2
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ProcessorInstruction::SkipEqualVXVY(vx, vy) => {
|
ProcessorInstruction::SkipEqualVXVY { vx, vy } => {
|
||||||
trace!("SkipNotEqualVXData");
|
trace!("SkipNotEqualVXData");
|
||||||
let vx_data = self.registers[vx as usize];
|
let vx_data = self.registers[vx as usize];
|
||||||
let vy_data = self.registers[vy as usize];
|
let vy_data = self.registers[vy as usize];
|
||||||
|
@ -367,7 +367,7 @@ where
|
||||||
self.program_counter += 2
|
self.program_counter += 2
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ProcessorInstruction::SkipNotEqualVXVY(vx, vy) => {
|
ProcessorInstruction::SkipNotEqualVXVY { vx, vy } => {
|
||||||
trace!("SkipNotEqualVXVY");
|
trace!("SkipNotEqualVXVY");
|
||||||
let vx_data = self.registers[vx as usize];
|
let vx_data = self.registers[vx as usize];
|
||||||
let vy_data = self.registers[vy as usize];
|
let vy_data = self.registers[vy as usize];
|
||||||
|
|
|
@ -59,9 +59,9 @@ pub enum ProcessorInstruction {
|
||||||
/// Skip the next instruction if VX is not equal to data.
|
/// Skip the next instruction if VX is not equal to data.
|
||||||
SkipNotEqualVXData { vx: u8, data: u8 },
|
SkipNotEqualVXData { vx: u8, data: u8 },
|
||||||
/// Skips the next instruction if VX is equal to VY.
|
/// Skips the next instruction if VX is equal to VY.
|
||||||
SkipEqualVXVY(u8, u8),
|
SkipEqualVXVY { vx: u8, vy: u8 },
|
||||||
/// Skip the next instruction if VX is not equal to VY.
|
/// Skip the next instruction if VX is not equal to VY.
|
||||||
SkipNotEqualVXVY(u8, u8),
|
SkipNotEqualVXVY { vx: u8, vy: u8 },
|
||||||
/// Sets the value of the VX instruction to the current value of the delay timer.
|
/// Sets the value of the VX instruction to the current value of the delay timer.
|
||||||
SetVXToDelayTimer(u8),
|
SetVXToDelayTimer(u8),
|
||||||
/// Sets the delay timer to the value in VX.
|
/// Sets the delay timer to the value in VX.
|
||||||
|
@ -213,14 +213,14 @@ impl Instruction {
|
||||||
vx: Self::grab_first_nibble(data),
|
vx: Self::grab_first_nibble(data),
|
||||||
data: Self::grab_last_byte(data),
|
data: Self::grab_last_byte(data),
|
||||||
},
|
},
|
||||||
(0x5, _, _, 0x0) => ProcessorInstruction::SkipEqualVXVY(
|
(0x5, _, _, 0x0) => ProcessorInstruction::SkipEqualVXVY {
|
||||||
Self::grab_first_nibble(data),
|
vx: Self::grab_first_nibble(data),
|
||||||
Self::grab_middle_nibble(data),
|
vy: Self::grab_middle_nibble(data),
|
||||||
),
|
},
|
||||||
(0x9, _, _, 0x0) => ProcessorInstruction::SkipNotEqualVXVY(
|
(0x9, _, _, 0x0) => ProcessorInstruction::SkipNotEqualVXVY {
|
||||||
Self::grab_first_nibble(data),
|
vx: Self::grab_first_nibble(data),
|
||||||
Self::grab_middle_nibble(data),
|
vy: Self::grab_middle_nibble(data),
|
||||||
),
|
},
|
||||||
(0xF, _, 0x0, 0x7) => {
|
(0xF, _, 0x0, 0x7) => {
|
||||||
ProcessorInstruction::SetVXToDelayTimer(Self::grab_first_nibble(data))
|
ProcessorInstruction::SetVXToDelayTimer(Self::grab_first_nibble(data))
|
||||||
}
|
}
|
||||||
|
@ -365,7 +365,10 @@ mod tests {
|
||||||
let instruction = Instruction::new([0x3A, 0xBC]);
|
let instruction = Instruction::new([0x3A, 0xBC]);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
instruction.processor_instruction,
|
instruction.processor_instruction,
|
||||||
ProcessorInstruction::SkipEqualVXData{vx: 0xA, data: 0xBC}
|
ProcessorInstruction::SkipEqualVXData {
|
||||||
|
vx: 0xA,
|
||||||
|
data: 0xBC
|
||||||
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -374,7 +377,10 @@ mod tests {
|
||||||
let instruction = Instruction::new([0x4A, 0xBC]);
|
let instruction = Instruction::new([0x4A, 0xBC]);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
instruction.processor_instruction,
|
instruction.processor_instruction,
|
||||||
ProcessorInstruction::SkipNotEqualVXData{vx: 0xA, data: 0xBC}
|
ProcessorInstruction::SkipNotEqualVXData {
|
||||||
|
vx: 0xA,
|
||||||
|
data: 0xBC
|
||||||
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -383,7 +389,7 @@ mod tests {
|
||||||
let instruction = Instruction::new([0x5A, 0xB0]);
|
let instruction = Instruction::new([0x5A, 0xB0]);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
instruction.processor_instruction,
|
instruction.processor_instruction,
|
||||||
ProcessorInstruction::SkipEqualVXVY(0xA, 0xB)
|
ProcessorInstruction::SkipEqualVXVY { vx: 0xA, vy: 0xB }
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -392,7 +398,7 @@ mod tests {
|
||||||
let instruction = Instruction::new([0x9A, 0xB0]);
|
let instruction = Instruction::new([0x9A, 0xB0]);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
instruction.processor_instruction,
|
instruction.processor_instruction,
|
||||||
ProcessorInstruction::SkipNotEqualVXVY(0xA, 0xB)
|
ProcessorInstruction::SkipNotEqualVXVY { vx: 0xA, vy: 0xB }
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue