/// <summary> /// Runs an instruction and returns the number of ticks it took to complete. /// </summary> /// <param name="memory">The memory.</param> /// <returns>The number of ticks that the instruction took to run.</returns> public static int Run(GbMemory memory) { memory.Update(1); byte opcode = memory.LdI8(); memory.Update(1); if (memory.HaltBugged) { memory.HaltBugged = false; memory.R.Pc--; } return(NmOps[opcode].Invoke(memory)); }