/* * mem[4] = (Int32)(eastUnit.x * accuracy); * mem[5] = (Int32)(eastUnit.y * accuracy); * mem[6] = (Int32)(eastUnit.z * accuracy); * mem[7] = (Int32)(upUnit.x * accuracy); * mem[8] = (Int32)(upUnit.y * accuracy); * mem[9] = (Int32)(upUnit.z * accuracy); * mem[10] = (Int32)(northUnit.x * accuracy); * mem[11] = (Int32)(northUnit.y * accuracy); * mem[12] = (Int32)(northUnit.z * accuracy); * mem[13] = (Int32)(shipEastVector.x * accuracy); * mem[14] = (Int32)(shipEastVector.y * accuracy); * mem[15] = (Int32)(shipEastVector.z * accuracy); * mem[16] = (Int32)(shipUpVector.x * accuracy); * mem[17] = (Int32)(shipUpVector.y * accuracy); * mem[18] = (Int32)(shipUpVector.z * accuracy); * mem[19] = (Int32)(shipNorthVector.x * accuracy); * mem[20] = (Int32)(shipNorthVector.y * accuracy); * mem[21] = (Int32)(shipNorthVector.z * accuracy); * mem[22] = (Int32)(orbitalSpeed.x * speedAccuracy); * mem[23] = (Int32)(orbitalSpeed.y * speedAccuracy); * mem[24] = (Int32)(orbitalSpeed.z * speedAccuracy); * mem[25] = (Int32)(groundSpeed.x * speedAccuracy); * mem[26] = (Int32)(groundSpeed.y * speedAccuracy); * mem[27] = (Int32)(groundSpeed.z * speedAccuracy); * mem[28] = (Int32)(angularVelocity.x * speedAccuracy); * mem[29] = (Int32)(angularVelocity.y * speedAccuracy); * mem[30] = (Int32)(angularVelocity.z * speedAccuracy); * mem[31] = (Int32)(UInt32)(altitude); * //mem[32] = output 1 * //mem[33] = output 2 * //mem[34] = output 3 * //mem[35] = output 4 * //mem[36] = output msg * //mem[37] = numpad input * //mem[38] = boolean used to see if the input has changed * //mem[39] = output formatting switch * //mem[40] = timer * //mem[41] = vectorAccuracy * //mem[42] = screen mode * //mem[43] = speed accuracy * //mem[44] = interrupt enable * //mem[45] = clock * //mem[46] = interrupt handler adress (64 default) * //mem[47] = timer interrupt frequency * //mem[48] = player throttle * //mem[49] = player yaw * //mem[50] = player pitch * //mem[51] = player roll * //mem[52] = player trn up * //mem[53] = player trn east * //mem[54] = player trn forward * //mem[55] = toggle Actiongroups */ //runs through the instructions untill the necessary ammount of ticks has passed, or all programs have completed operation //returns the excess ticks private int cycle(int cycles) { int ticksElapsed = 0; while (ticksElapsed < cycles) { //debugging tools if (debug) { int opcode = (CPU.getMem(CPU.PC) >> 26) & 0x3f;//decompile instruction int rA = (CPU.getMem(CPU.PC) >> 21) & 0x1f; int rB = (CPU.getMem(CPU.PC) >> 16) & 0x1f; int im = CPU.getMem(CPU.PC) & 0xffff; print("PC: " + CPU.PC + " opcode: " + opcode.ToString("X2") + " r" + rA + ": " + CPU.Registers[rA] + " r" + rB + ": " + CPU.Registers[rB] + " im: " + im + " rC: " + CPU.Registers[im & 0x1f] + " ra: " + CPU.Registers[15] + " sp: " + CPU.Registers[14] + ", " + CPU.getMem((UInt16)(CPU.Registers[14] - 1))); } int cyclesElapsed = CPU.tick(); ticksElapsed += cyclesElapsed; } return(ticksElapsed); }