1
0
mirror of https://github.com/mist64/perfect6502.git synced 2024-06-02 17:41:32 +00:00

cleanup, restore missing loop exit case

This commit is contained in:
Michael Steil 2010-10-05 18:13:48 +00:00
parent 57d2ce2c91
commit 4189c81c70

View File

@ -419,12 +419,8 @@ getGroupValue()
void void
addRecalcNode(nodenum_t nn) addRecalcNode(nodenum_t nn)
{ {
/* we already know about this node */ if (!listout_contains(nn))
if (listout_contains(nn)) listout_add(nn);
return;
/* add node to list */
listout_add(nn);
} }
#ifdef BROKEN_TRANSISTORS #ifdef BROKEN_TRANSISTORS
@ -434,21 +430,14 @@ transnum_t broken_transistor = (transnum_t)-1;
void void
toggleTransistor(transnum_t tn) toggleTransistor(transnum_t tn)
{ {
/* if the gate is high, the transistor should be on */
#if 0 /* safer version: set it to what the gate says */
BOOL on = isNodeHigh(transistors_gate[tn]);
#else /* easier version: toggle it */
BOOL on = !get_transistors_on(tn);
#endif
#ifdef BROKEN_TRANSISTORS #ifdef BROKEN_TRANSISTORS
if (tn == broken_transistor) { if (tn == broken_transistor) {
if (!on) if (!get_transistors_on(tn))
return; return;
} }
#endif #endif
set_transistors_on(tn, on); set_transistors_on(tn, !get_transistors_on(tn));
/* next time, we'll have to look at both nodes behind the transistor */ /* next time, we'll have to look at both nodes behind the transistor */
addRecalcNode(transistors_c1[tn]); addRecalcNode(transistors_c1[tn]);
@ -478,11 +467,11 @@ recalcNode(nodenum_t node)
*/ */
for (count_t i = 0; i < group_count(); i++) { for (count_t i = 0; i < group_count(); i++) {
nodenum_t nn = group_get(i); nodenum_t nn = group_get(i);
BOOL needs_recalc = get_nodes_state_value(nn) != newv; if (get_nodes_state_value(nn) != newv) {
set_nodes_state_value(nn, newv); set_nodes_state_value(nn, newv);
if (needs_recalc)
for (count_t t = 0; t < nodes_gatecount[nn]; t++) for (count_t t = 0; t < nodes_gatecount[nn]; t++)
toggleTransistor(nodes_gates[nn][t]); toggleTransistor(nodes_gates[nn][t]);
}
} }
} }
@ -490,22 +479,15 @@ recalcNode(nodenum_t node)
* NOTE: "list" as provided by the caller must * NOTE: "list" as provided by the caller must
* at least be able to hold NODES elements! * at least be able to hold NODES elements!
*/ */
//int highest = 0;
void void
recalcNodeList(const nodenum_t *source, count_t count) recalcNodeList(const nodenum_t *source, count_t count)
{ {
listin_fill(source, count); listin_fill(source, count);
// static int highest = 0;
int j; int j;
for (j = 0; j < 100; j++) { /* loop limiter */ for (j = 0; j < 100; j++) { /* loop limiter */
if (!listin_count()) { if (!listin_count())
// if (j > highest) { break;
// highest = j;
// printf("******* NEW HIGHEST ***** %d\n", highest);
// }
// break;
}
listout_clear(); listout_clear();