int retCode;
long tickCount = 0;
long start = System.currentTimeMillis();
boolean halted = false;
ArrayList<Value> prevOutputs = null;
Propagator prop = circState.getPropagator();
while (true) {
ArrayList<Value> curOutputs = new ArrayList<Value>();
for (Instance pin : outputPins) {
InstanceState pinState = circState.getInstanceState(pin);
Value val = Pin.FACTORY.getValue(pinState);
if (pin == haltPin) {
halted |= val.equals(Value.TRUE);
} else if (showTable) {
curOutputs.add(val);
}
}
if (showTable) {
displayTableRow(prevOutputs, curOutputs);
}
if (halted) {
retCode = 0; // normal exit
break;
}
if (prop.isOscillating()) {
retCode = 1; // abnormal exit
break;
}
if (keyboardStates != null) {
char[] buffer = stdinThread.getBuffer();
if (buffer != null) {
for (InstanceState keyState : keyboardStates) {
Keyboard.addToBuffer(keyState, buffer);
}
}
}
prevOutputs = curOutputs;
tickCount++;
prop.tick();
prop.propagate();
}
long elapse = System.currentTimeMillis() - start;
if (showTty) ensureLineTerminated();
if (showHalt || retCode != 0) {
if (retCode == 0) {