uint cineExec(uint cycles) { ccpu_ICount[0] = (int)cycles; bailOut = false; do { int opcode; /* * goto the correct piece of code * for the current opcode. That piece of code will set the state * for the next run, as well. */ opcode = cpu_readop(register_PC++); state = cineops[(int)state][opcode](opcode); ccpu_ICount[0] -= ccpu_cycles[opcode]; /* * the opcode code has set a state and done mischief with flags and * the program counter; now jump back to the top and run through another * opcode. */ if (bailOut) /* ccpu_ICount = 0; */ ccpu_ICount[0] -= 100; } while (ccpu_ICount[0] > 0); return (uint)(cycles - ccpu_ICount[0]); }
static void cineReset() { /* zero registers */ register_PC = 0; register_A = 0; register_B = 0; register_I = 0; register_J = 0; register_P = 0; FromX = 0; FromY = 0; register_T = 0; /* zero flags */ flag_C = 0; /* reset state */ state = CINESTATE.state_A; /* reset RAM */ Array.Clear(ram, 0, ram.Length);//memset(ram, 0, sizeof(ram)); /* reset internal state */ cmp_old = 0; cmp_new = 0; acc_a0 = 0; }