public void Clock() { cpuClockCount++; if (cycles == 0) { state = new State(this); opcode = ReadBus(PC++); currentInstr = instructionSet[opcode]; cycles += currentInstr.Cycles; bool addrm = currentInstr.AddrMode(); bool operation = currentInstr.Operation(); #if LOGGING //LogState(); using (StreamWriter file = new StreamWriter(filePath, true)) file.WriteLine(state); #endif if (addrm & operation) { cycles++; } } clock_count++; cycles--; }