@Test public void shouldIncrementProgramCounterOnceIfTheJumpConditionIsFalse() { z80.setProgramCounter(ANY_PROGRAM_COUNTER); when(mmu.readByte(ANY_PROGRAM_COUNTER)).thenReturn((byte) PROGRAM_COUNTER_INCREMENT); z80.enableFlagZ(); Instruction instruction = new JumpR(z80, mmu, JUMP_NON_ZERO, FLAG_Z); instruction.execute(); int expectedProgramCounter = ANY_PROGRAM_COUNTER + 1; assertEquals(expectedProgramCounter, z80.getProgramCounter()); }
@Override public void execute() { int programCounter = z80.getProgramCounter(); byte value = mmu.readByte(programCounter); z80.incrementProgramCounter(); if ((z80.get8BitRegisterValue(Register.F) & flag) == condition) { int newProgramCounterValue = z80.getProgramCounter() + value; z80.setProgramCounter(newProgramCounterValue); if (flag != JUMP && condition != JUMP) { z80.setLastInstructionExecutionTime(3); } } z80.setLastInstructionExecutionTime(2); }
JumpR extends Instruction { @Override public void execute() { int programCounter = z80.getProgramCounter(); byte value = mmu.readByte(programCounter); z80.incrementProgramCounter(); if ((z80.get8BitRegisterValue(Register.F) & flag) == condition) { int newProgramCounterValue = z80.getProgramCounter() + value; z80.setProgramCounter(newProgramCounterValue); if (flag != JUMP && condition != JUMP) { z80.setLastInstructionExecutionTime(3); } } z80.setLastInstructionExecutionTime(2); } }
JumpR extends Instruction { @Override public void execute() { int programCounter = z80.getProgramCounter(); byte value = mmu.readByte(programCounter); z80.incrementProgramCounter(); if ((z80.get8BitRegisterValue(Register.F) & flag) == condition) { int newProgramCounterValue = z80.getProgramCounter() + value; z80.setProgramCounter(newProgramCounterValue); if (flag != JUMP && condition != JUMP) { z80.setLastInstructionExecutionTime(3); } } z80.setLastInstructionExecutionTime(2); } JumpR(GBZ80 z80, MMU mmu, int condition, int flag); }
JumpR extends Instruction { @Override public void execute() { int programCounter = z80.getProgramCounter(); byte value = mmu.readByte(programCounter); z80.incrementProgramCounter(); if ((z80.get8BitRegisterValue(Register.F) & flag) == condition) { int newProgramCounterValue = z80.getProgramCounter() + value; z80.setProgramCounter(newProgramCounterValue); if (flag != JUMP && condition != JUMP) { z80.setLastInstructionExecutionTime(3); } } z80.setLastInstructionExecutionTime(2); } JumpR(GBZ80 z80, MMU mmu, int condition, int flag); @Override void execute(); }
JumpR extends Instruction { @Override public void execute() { int programCounter = z80.getProgramCounter(); byte value = mmu.readByte(programCounter); z80.incrementProgramCounter(); if ((z80.get8BitRegisterValue(Register.F) & flag) == condition) { int newProgramCounterValue = z80.getProgramCounter() + value; z80.setProgramCounter(newProgramCounterValue); if (flag != JUMP && condition != JUMP) { z80.setLastInstructionExecutionTime(3); } } z80.setLastInstructionExecutionTime(2); } JumpR(GBZ80 z80, MMU mmu, int condition, int flag); @Override void execute();  }