1
0
mirror of https://github.com/mist64/perfect6502.git synced 2024-12-29 17:30:49 +00:00

made recalclist global -> speedup

This commit is contained in:
Michael Steil 2010-09-22 17:40:32 +00:00
parent bbe8c76720
commit ebc4217551

View File

@ -203,21 +203,24 @@ getNodeValue(int *group, int groupcount)
return flstate; return flstate;
} }
int *recalclist;
int recalccount;
void void
addRecalcNode(int nn, int *recalclist, int *recalccount) addRecalcNode(int nn)
{ {
#ifdef DEBUG #ifdef DEBUG
printf("%s nn=%d recalclist=", __func__, nn); printf("%s nn=%d recalclist=", __func__, nn);
printarray(recalclist, *recalccount); printarray(recalclist, recalccount);
#endif #endif
if (nn == ngnd) if (nn == ngnd)
return; return;
if (nn == npwr) if (nn == npwr)
return; return;
if (arrayContains(recalclist, *recalccount, nn)) if (arrayContains(recalclist, recalccount, nn))
return; return;
recalclist[*recalccount] = nn; recalclist[recalccount] = nn;
(*recalccount)++; recalccount++;
} }
void void
@ -249,11 +252,11 @@ isNodeHigh(int nn)
} }
void void
recalcTransistor(int tn, int *recalclist, int *recalccount) recalcTransistor(int tn)
{ {
#ifdef DEBUG #ifdef DEBUG
printf("%s tn=%d, recalclist=", __func__, tn); printf("%s tn=%d, recalclist=", __func__, tn);
printarray(recalclist, *recalccount); printarray(recalclist, recalccount);
#endif #endif
transistor_t *t = &transistors[tn]; transistor_t *t = &transistors[tn];
BOOL on = isNodeHigh(t->gate); BOOL on = isNodeHigh(t->gate);
@ -264,16 +267,16 @@ recalcTransistor(int tn, int *recalclist, int *recalccount)
floatnode(t->c1); floatnode(t->c1);
floatnode(t->c2); floatnode(t->c2);
} }
addRecalcNode(t->c1, recalclist, recalccount); addRecalcNode(t->c1);
addRecalcNode(t->c2, recalclist, recalccount); addRecalcNode(t->c2);
} }
void void
recalcNode(int node, int *recalclist, int *recalccount) recalcNode(int node)
{ {
#ifdef DEBUG #ifdef DEBUG
printf("%s node=%d, recalclist=", __func__, node); printf("%s node=%d, recalclist=", __func__, node);
printarray(recalclist, *recalccount); printarray(recalclist, recalccount);
#endif #endif
if (node == ngnd) if (node == ngnd)
return; return;
@ -305,7 +308,7 @@ recalcNode(int node, int *recalclist, int *recalccount)
#endif #endif
//printf("there are %d gates\n", n.gatecount); //printf("there are %d gates\n", n.gatecount);
for (t = 0; t < n.gatecount; t++) for (t = 0; t < n.gatecount; t++)
recalcTransistor(n.gates[t], recalclist, recalccount); recalcTransistor(n.gates[t]);
} }
} }
@ -317,8 +320,8 @@ recalcNodeList(int *list, int count)
printarray(list, count); printarray(list, count);
#endif #endif
int list1[2000]; int list1[2000];
int *recalclist = list1; recalclist = list1;
int recalccount = 0; recalccount = 0;
int i, j; int i, j;
for (j = 0; j < 100; j++) { // loop limiter for (j = 0; j < 100; j++) { // loop limiter
if (!count) if (!count)
@ -328,7 +331,7 @@ recalcNodeList(int *list, int count)
printarray(list, count); printarray(list, count);
#endif #endif
for (i = 0; i < count; i++) for (i = 0; i < count; i++)
recalcNode(list[i], recalclist, &recalccount); recalcNode(list[i]);
SWAP(list, recalclist); SWAP(list, recalclist);
count = recalccount; count = recalccount;
recalccount = 0; recalccount = 0;