private void ProcessNextInstruction() { byte opCode = memoryMap.ReadByte(registers.PC); registers.PC++; cycles = processor.ProcessOpcode(opCode); }
/// <summary> /// Performs operations specified by the passed in opcode. /// This method modifies memory, registers, and flags. /// The program counter will be incremented if the specified opcode /// has operands. /// The number of cycles the operation takes is returned. /// </summary> /// <param name="opcode">The opcode to process.</param> /// <returns>The number of cycles the operation takes.</returns> public int ProcessOpcode(byte opcode) { currentOpcode = opcode; branchTaken = false; if ((PrimaryOpcode)opcode == PrimaryOpcode.PREFIX_CB) { isPrimaryOpcode = false; registers.PC++; opcode = memoryMap.ReadByte(registers.PC); return(ProcessPrefixedOpcode((PrefixedOpcode)opcode)); } else { isPrimaryOpcode = true; return(ProcessPrimaryOpcode((PrimaryOpcode)opcode)); } }