chore: remove duplicate Instruction::INC match

This commit is contained in:
Rekai Nyangadzayi Musuka 2020-12-23 01:11:03 -06:00
parent 5187cbed76
commit 9cd4c4ea11
1 changed files with 44 additions and 34 deletions

View File

@ -315,18 +315,9 @@ impl Instruction {
}
_ => unreachable!(),
},
Instruction::INC(Registers::Word(pair)) => {
// INC rp[p] | Increment Register Pair
match pair {
RegisterPair::BC | RegisterPair::DE | RegisterPair::HL | RegisterPair::SP => {
let value = cpu.register_pair(pair);
cpu.set_register_pair(pair, value + 1);
}
_ => unreachable!(),
}
Cycles(8)
}
Instruction::INC(Registers::Byte(reg)) => {
Instruction::INC(registers) => {
match registers {
Registers::Byte(reg) => {
// INC r[y] | Increment Register
let mut flags: Flags = cpu.register(Register::Flag).into();
let cycles: Cycles;
@ -347,7 +338,10 @@ impl Instruction {
}
InstrRegister::IndirectHL => {
let addr = cpu.register_pair(RegisterPair::HL);
cpu.write_byte(addr, Self::inc_register(cpu.read_byte(addr), &mut flags));
cpu.write_byte(
addr,
Self::inc_register(cpu.read_byte(addr), &mut flags),
);
cycles = Cycles(12)
}
InstrRegister::IndirectC => unreachable!(),
@ -355,6 +349,22 @@ impl Instruction {
cpu.set_register(Register::Flag, flags.into());
cycles
}
Registers::Word(pair) => {
// INC rp[p] | Increment Register Pair
match pair {
RegisterPair::BC
| RegisterPair::DE
| RegisterPair::HL
| RegisterPair::SP => {
let value = cpu.register_pair(pair);
cpu.set_register_pair(pair, value + 1);
}
_ => unreachable!(),
}
Cycles(8)
}
}
}
Instruction::DEC(Registers::Word(pair)) => {
// DEC rp[p] | Decrement Register Pair
match pair {