From bb8f7623061f7fc3de257f34a2fdfdc44394e223 Mon Sep 17 00:00:00 2001 From: Etienne Brateau <etienne.brateau@ensiie.fr> Date: Thu, 19 Jul 2018 22:33:05 +0200 Subject: [PATCH] Continue to split log, and correct inindentation and clean --- log/src/gate.c | 331 +++++ log/src/log.c | 3295 ++++++++++++++++++------------------------------ log/src/node.c | 643 ++++++++++ log/src/wire.c | 339 +++++ 4 files changed, 2542 insertions(+), 2066 deletions(-) create mode 100644 log/src/node.c diff --git a/log/src/gate.c b/log/src/gate.c index c2a6dd1..26d3bfc 100644 --- a/log/src/gate.c +++ b/log/src/gate.c @@ -525,3 +525,334 @@ static void delgate(log_grec *g) clipoff(); } +static void frygate(log_grec *g) +{ + long t0; + + remcursor(); + clipon(); + t0 = timers_sysclock(); + while (labs(timers_sysclock() - t0) < frytime) + { + drawgatec(g->x, g->y, g->g, gg.color.conflict); + eragate(g); + } + clipoff(); + refreshsoon(); +} + +/*================ CONNECTGATE =================*/ +/*= =*/ +/*= Check each pin of a gate and connect to =*/ +/*= wires, other pins as necessary. =*/ +/*= =*/ +/*================================================*/ + +static void initpinpos(log_grec *g) +{ + short i, rxx, rxy, ryx, ryy; + log_krec *WITH; + short FORLIM; + + rxx = log_rotxx[g->rot]; + rxy = log_rotxy[g->rot]; + ryx = log_rotyx[g->rot]; + ryy = log_rotyy[g->rot]; + WITH = g->kind; + FORLIM = WITH->numpins; + for (i = 0; i < FORLIM; i++) + { + g->pinpos[i].x = g->x + WITH->pin[i].x * rxx + WITH->pin[i].y * ryx; + g->pinpos[i].y = g->y + WITH->pin[i].x * rxy + WITH->pin[i].y * ryy; + } +} + + +static int connectgate(log_grec *g) +{ + int Result; + cnrec *cnbase; + short i, j, xp, yp; + log_hwrec *hw; + log_vwrec *vw; + log_nrec **n1; + log_grec *g1; + short ptrs[log_maxpins]; + int success; + short FORLIM, FORLIM1; + + if (gg.traceflag) + fprintf(tracefile, "Connect gate %ld, type %s\n", (long)g, g->kind->name); + linkgate(&g); + working(); + initpinpos(g); + FORLIM = g->kind->numpins; + for (i = 0; i < FORLIM; i++) + { + ptrs[i] = 0; + g->pin[i] = NULL; + } + FORLIM = g->kind->numpins; + for (i = 1; i <= FORLIM; i++) + { + if (ptrs[i - 1] == 0) + { + newnoderef(&g->pin[i - 1], g->kind->pin[i - 1].s, 1L); + if (g->pin[i - 1] == NULL) + { + Result = false; + goto _L1; /*return*/ + } + j = i; + do + { + ptrs[j - 1] = i; + j = g->kind->pin[j - 1].c; + } while (j != i && j != 0); + } + } + cnbase = NULL; + FORLIM = g->kind->numpins; + for (i = 0; i < FORLIM; i++) + { + xp = g->pinpos[i].x; + yp = g->pinpos[i].y; + n1 = NULL; + hw = gg.hwbase[gg.curpage - 1]; + while (hw != NULL && n1 == NULL) + { + if (hw->x1 <= xp && xp <= hw->x2 && yp == hw->y) + n1 = &hw->node; + hw = hw->next; + } + vw = gg.vwbase[gg.curpage - 1]; + while (vw != NULL && n1 == NULL) + { + if (vw->y1 <= yp && yp <= vw->y2 && xp == vw->x) + n1 = &vw->node; + vw = vw->next; + } + g1 = gg.gbase[gg.curpage - 1]; + while (g1 != NULL && n1 == NULL) + { + if (g1 != g && P_imax2((long)abs(g1->x - xp), (long)abs(g1->y - yp)) <= + g1->kind->bbmax) + { + FORLIM1 = g1->kind->numpins; + for (j = 0; j < FORLIM1; j++) + { + if (g1->pinpos[j].x == xp && g1->pinpos[j].y == yp) + n1 = &g1->pin[j]; + } + } + g1 = g1->next; + } + if (n1 != NULL) + queuecombine(&cnbase, &g->pin[ptrs[i] - 1], n1); + } + if (g->kind->simtype == simtype_common && g->sig != 0) + queuecombine(&cnbase, &gg.signaltab[g->sig - 1].np, g->pin); + gg.actflag = true; + calltoolgate(g, act_connectgate); + success = gg.actflag; + if (success && checkcombine(&cnbase)) + { + FORLIM = g->kind->numpins; + for (i = 0; i < FORLIM; i++) + { + if (ptrs[i] != i + 1) + g->pin[i] = refnode(g->pin[ptrs[i] - 1]); + } + Result = true; + } + else + { + success = false; + } + + if (!success) + { + Result = false; + FORLIM = g->kind->numpins; + for (i = 1; i <= FORLIM; i++) { + if (ptrs[i - 1] == i) + unrefnode(&g->pin[i - 1]); + } + unlkgate(&g); + } +_L1: + return Result; +} + + +static void pconnectgate(log_grec *g, int *success) +{ + *success = connectgate(g); +} + +/*================= ADDGATE1 ===================*/ +/*= =*/ +/*= Add a gate to the circuit. Initialize all =*/ +/*= gate variables, etc. =*/ +/*= =*/ +/*================================================*/ + +static void addgate2(short x, short y, short gtype, short sig, log_gattrrec *attrs) +{ + log_grec *g, *g1; + short i, gmax; + int flag; + + newgate2(&g, gtype, sig, attrs); + if (gatecount[gg.curpage - 1] == log_maxshint) + { + i = 0; + gmax = 0; + do + { + i++; + g1 = gg.gbase[gg.curpage - 1]; + flag = false; + while (g1 != NULL && !flag) + { + if (g1->gc > gmax) + gmax = g1->gc; + flag = (g1->gc == i); + } + } while (flag); + g->gc = i; + gatecount[gg.curpage - 1] = gmax; + } + else + { + gatecount[gg.curpage - 1]++; + g->gc = gatecount[gg.curpage - 1]; + } + g->x = x; + g->y = y; + clipon(); + drawgatex(g); + clipoff(); + if (!connectgate(g)) + { + frygate(g); + disposegate(&g); + } + gg.refrflag = true; + gg.neargate = g; +} + + +static void addgate1(short x, short y, short gtype) +{ + addgate2(x, y, gtype, 0, NULL); +} + +static void uaddgate(short x, short y, short gtype) +{ + short xx, yy; + log_grec *g; + log_krec *k; + + x = P_imin2(P_imax2((long)x, gridcen * 3L / 2), across - gridcen * 3L / 2); + y = P_imin2(P_imax2((long)y, gridcen * 3L / 2), baseline - gridcen * 3L / 2); + k = kind[(gtype & (log_kindoffset - 1)) - 1]; + do + { + xx = (x + gg.xoff) / gg.scale; + yy = (y + gg.yoff) / gg.scale; + g = gg.gbase[gg.curpage - 1]; + while (g != NULL && P_imax2((long)abs(g->x - xx), (long)abs(g->y - yy)) > + g->kind->bbmax + k->bbmax) + g = g->next; + if (g != NULL) + { + x += gridcen * 2; + if (x > across - gridcen * 3) + { + x = gridcen * 2; + y += gridcen * 2; + } + } + } while (g != NULL); + addgate1(xx, yy, gtype); +} + +/*================== ADDGATE ===================*/ +/*= =*/ +/*= Move a gate into position, then add to =*/ +/*= circuit or menu area. =*/ +/*= =*/ +/*================================================*/ + +static void movexorgate(short x, short y, short g, short sig, short yy) +{ + clipoff(); + m_colormode((long)m_xor); + if (yy < baseline) + { + drawgatec(x, y, g, gg.color.gate); + signallabel((int)(x * gg.scale - gg.xoff), (int)(y * gg.scale - gg.yoff), + g, sig, gg.color.signal); + } + else + { + udrawgatec((int)(x * gg.scale - gg.xoff), (int)(y * gg.scale - gg.yoff), + g, gg.color.gate); + if (zoom == 0 && + kind[(g & (log_kindoffset - 1)) - 1]->bbmax <= maxsafescale) + drawgatedotsc(x, y, g, gg.color.gatepin); + } + m_colormode((long)m_normal); +} + + +static int addgate(short gtype, short sig, log_gattrrec *attrs) +{ + int Result; + short yy; + int oo; + log_krec *k; + + Result = false; + if (gtype != 0 && (gtype & (log_kindoffset - 1)) <= maxkinds) + { + k = kind[(gtype & (log_kindoffset - 1)) - 1]; + if (k != NULL) + { + do + { + yy = gg.t.y; + gg.posx = gg.gridx; + gg.posy = gg.gridy; + oo = gg.t.off; + movexorgate(gg.posx, gg.posy, gtype, sig, yy); + do + { + pass(); + trykbd(); + pen(); + } while (gg.gridx == gg.posx && gg.gridy == gg.posy && + gg.t.depressed && strcmp(gg.func, "REFR")); + movexorgate(gg.posx, gg.posy, gtype, sig, yy); + scroll(); + } while (gg.t.depressed); + if (!oo && !gg.t.off) + { + if (gg.t.y < baseline) + { + addgate2(gg.posx, gg.posy, gtype, sig, attrs); + Result = true; + } + else + { + changekind(gtype, sig, attrs); + } + } + } + } + gg.startpoint = false; + return Result; +} + + diff --git a/log/src/log.c b/log/src/log.c index 8be65cc..0f6359b 100644 --- a/log/src/log.c +++ b/log/src/log.c @@ -19,7 +19,7 @@ You should have received a copy of the GNU General Public License along with this program; see the file COPYING. If not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*/ + */ /* Logic Simulator Version 4.1 @@ -29,7 +29,7 @@ Copyright (c) 1985 David Gillespie -*/ + */ #include <unistd.h> @@ -401,8 +401,6 @@ static const rabmustype discomadness = { #define maxeditmodes 4 - - static log_action_t gg; /* External global variables */ static short cursx, cursy; /* Current position of cursor */ @@ -920,7 +918,7 @@ static void getbool(char *buf, int *b) *b = false; return; } - + if (!strcmp(w, "?")) tempverbose = true; else if (*w == '\0') @@ -2636,49 +2634,6 @@ static log_tool *findsimtype(uchar st) } -/*================== ADDNODE ===================*/ -/*= =*/ -/*= Create a new node. =*/ -/*= =*/ -/*================================================*/ - -static void newnptr(log_nrec **n) -{ - if (freenode == NULL) - { - *n = (log_nrec *)Malloc(sizeof(log_nrec)); - } - else - { - *n = freenode; - freenode = freenode->next; - } -} - - -static void newnode(log_nrec **n, uchar st) -{ - newnptr(n); - (*n)->simtype = findsimtype(st); - (*n)->changed = false; - (*n)->conflict = false; - (*n)->conflict1 = false; - (*n)->conflict2 = false; - (*n)->oconflict = false; - (*n)->flag = false; - (*n)->keep = false; - (*n)->ref = 0; - newattrs(&(*n)->attr, (*n)->simtype->nnumattrs, (*n)->simtype->nattr); - (*n)->info = (na_long)0; - (*n)->temp = (na_long)0; - stamp(&(*n)->simtype->netstamp); - calltoolnode(*n, act_newnode); - (*n)->next = gg.nbase; - gg.nbase = *n; - if (gg.traceflag) - fprintf(tracefile, "Make node %ld\n", (long)(*n)); -} - static void dumpconflicts() { /*no longer needed (I hope!)*/ @@ -2714,160 +2669,6 @@ static void dumpconflicts() } -/*================== COPYNODE ==================*/ -/*= =*/ -/*= Create a new node, copied from another. =*/ -/*= =*/ -/*================================================*/ - -static void copynode(log_nrec *old, log_nrec **n) -{ - newnptr(n); - **n = *old; - (*n)->ref = 0; - copyattrs(&(*n)->attr, old->attr, (*n)->simtype->nnumattrs, - (*n)->simtype->nattr); - gg.actnode2 = old; - calltoolnode(*n, act_copynode); - (*n)->next = gg.nbase; - gg.nbase = *n; - if ((*n)->conflict || (*n)->oconflict) - { - (*n)->confnext = nodeconflictbase; - nodeconflictbase = *n; - } - if (gg.traceflag) - fprintf(tracefile, "Copy node %ld from %ld\n", (long)(*n), (long)old); -} - - -/*=================== DISPNODE =================*/ -/*= =*/ -/*= Dispose of a node. =*/ -/*= =*/ -/*================================================*/ - -static void disposenptr(log_nrec **n) -{ - (*n)->next = freenode; - freenode = *n; -} - - -#define rtn "DISPNODE" - - -static void disposenode(log_nrec **n) -{ - log_nrec *n1, *n2; - - if (gg.traceflag) - fprintf(tracefile, "Dispose node %ld\n", (long)(*n)); - if (*n == NULL) - return; - if ((*n)->conflict || (*n)->oconflict) - { - n1 = nodeconflictbase; - n2 = NULL; - while (n1 != NULL && n1 != *n) - { - n2 = n1; - n1 = n1->confnext; - } - if (n1 == NULL) - report(11, rtn); - else if (n2 == NULL) - nodeconflictbase = (*n)->confnext; - else - n2->confnext = (*n)->confnext; - } - if (*n == gg.probenode) - gg.probenode = NULL; - stamp(&(*n)->simtype->netstamp); - calltoolnode(*n, act_disposenode); - n1 = gg.nbase; - if (*n == n1) - { - gg.nbase = (*n)->next; - } - else - { - while (n1 != NULL && n1->next != *n) - n1 = n1->next; - if (n1 == NULL) - report(10, rtn); - else - n1->next = (*n)->next; - } - disposeattrs(&(*n)->attr, (*n)->simtype->nnumattrs, (*n)->simtype->nattr); - disposenptr(n); -} - -#undef rtn - - -static int nodeexists(log_nrec *n) -{ - log_nrec *n1; - - n1 = gg.nbase; - while (n1 != NULL && n1 != n) - n1 = n1->next; - return (n1 != NULL); -} - - -static void newnoderef(log_nrec **n, uchar st, long ref) -{ - newnode(n, st); - (*n)->ref = ref; -} - - -static log_nrec *refnode(log_nrec *n) -{ - if (n == NULL) - return n; - n->ref++; - if (gg.traceflag) - fprintf(tracefile, "Reference node %ld -> %d\n", (long)n, n->ref); - return n; -} - - -#define rtn "UNREFNODE" - - -static void unrefnode(log_nrec **n) -{ - if (*n == NULL) - return; - (*n)->ref--; - if (gg.traceflag) - fprintf(tracefile, "Unref node %ld -> %d\n", (long)(*n), (*n)->ref); - if ((*n)->ref > 0) - return; - if ((*n)->ref < 0) - report(10, rtn); - else { - if (!(*n)->keep) - disposenode(n); - } -} - -#undef rtn - - -static void switchnode(log_nrec **n, log_nrec *n2) -{ - if (*n != n2) - { - unrefnode(n); - *n = refnode(n2); - } -} - - static void purgesignaltab() { short i, pg; @@ -2896,7 +2697,8 @@ static void purgesignaltab() if (copybuf.valid) { g = copybuf.gcopy; - while (g != NULL) { + while (g != NULL) + { if (g->sig != 0) gg.signaltab[g->sig - 1].f = true; g = g->next; @@ -3170,176 +2972,6 @@ static char *colorname(char *Result, short c) } -/*================= DUMPNODES ==================*/ -/*= =*/ -/*= Print a detailed dissection of the major =*/ -/*= data structures. For debugging only. =*/ -/*= =*/ -/*================================================*/ - -static void dumpnodes() -{ - log_nrec *n, *n1; - log_hwrec *hw; - log_vwrec *vw; - log_srec *s; - log_grec *g; - short i, j; - timerec timevar; - daterec datevar; - int savebool; - char STR3[9]; - short FORLIM; - log_krec *WITH; - - savebool = gg.traceflag; - gg.traceflag = true; - tracemessage(""); - gg.traceflag = savebool; - sysdate(&datevar); - systime(&timevar); - fprintf(tracefile, - "-------------------------------------------------------- "); - fprintf(tracefile, "%2d/%2d/%02d", datevar.month, datevar.day, datevar.year); - fprintf(tracefile, " %2d:%2d\n\n", timevar.hour, timevar.minute); - n = gg.nbase; - fprintf(tracefile, "NODES\n"); - i = 0; - j = 0; - TRY(try6); - while (j == i && n != NULL) - { - i++; - fprintf(tracefile, "%12ld T:%s Ref:%d", - (long)n, n->simtype->name, n->ref); - FORLIM = gg.lastsignal; - for (j = 0; j < FORLIM; j++) - { - if (gg.signaltab[j].np == n) - fprintf(tracefile, " %s", gg.signaltab[j].name); - } - putc('\n', tracefile); - TRY(try7); - gg.actfile = gg.tracefile; - gg.actflag = true; - calltoolnode(n, act_writenode); - RECOVER(try7); - if (P_escapecode == -20) - goto _Ltry6; - fprintf(tracefile, " (Failed to output node value) %d\n", - P_escapecode); - ENDTRY(try7); - n1 = gg.nbase; - j = 1; - while (j < i && n1 != n) - { - j++; - n1 = n1->next; - } - if (j < i) - fprintf(tracefile, "Infinite loop in node list\n"); - n = n->next; - } - RECOVER2(try6,_Ltry6); - if (P_escapecode == -20) - _Escape(P_escapecode); - fprintf(tracefile, " Internal error, %d\n", P_escapecode); - ENDTRY(try6); - putc('\n', tracefile); - hw = gg.hwbase[gg.curpage - 1]; - fprintf(tracefile, "HWIRES\n"); - TRY(try8); - while (hw != NULL) - { - fprintf(tracefile, "%12ld X1:%4d X2:%4d Y:%4d N:%ld C:%s\n", - (long)hw, hw->x1, hw->x2, hw->y, (long)hw->node, - colorname(STR3, hw->wcolr)); - hw = hw->next; - } - RECOVER(try8); - if (P_escapecode == -20) - _Escape(P_escapecode); - fprintf(tracefile, " Internal error, %d\n", P_escapecode); - ENDTRY(try8); - putc('\n', tracefile); - vw = gg.vwbase[gg.curpage - 1]; - fprintf(tracefile, "VWIRES\n"); - TRY(try9); - while (vw != NULL) - { - fprintf(tracefile, "%12ld X:%4d Y1:%4d Y2:%4d N:%ld C:%s\n", - (long)vw, vw->x, vw->y1, vw->y2, (long)vw->node, - colorname(STR3, vw->wcolr)); - vw = vw->next; - } - RECOVER(try9); - if (P_escapecode == -20) - _Escape(P_escapecode); - fprintf(tracefile, " Internal error, %d\n", P_escapecode); - ENDTRY(try9); - putc('\n', tracefile); - s = gg.sbase[gg.curpage - 1]; - fprintf(tracefile, "SOLDER\n"); - TRY(try10); - while (s != NULL) - { - fprintf(tracefile, "%12ld X:%4d Y:%4d HW: %ld,%ld", - (long)s, s->x, s->y, (long)s->hwire, (long)s->hwire2); - if (s->hwire == NULL) - fprintf(tracefile, " "); - fprintf(tracefile, " VW: %ld,%ld\n", (long)s->vwire, (long)s->vwire2); - s = s->next; - } - RECOVER(try10); - if (P_escapecode == -20) - _Escape(P_escapecode); - fprintf(tracefile, " Internal error, %d\n", P_escapecode); - ENDTRY(try10); - putc('\n', tracefile); - g = gg.gbase[gg.curpage - 1]; - fprintf(tracefile, "GATES\n"); - TRY(try11); - while (g != NULL) - { - fprintf(tracefile, "%12ld G:%3d X:%4d Y:%4d T:%s %s\n", - (long)g, g->g, g->x, g->y, g->kind->simtype->name, - g->kind->name); - WITH = g->kind; - FORLIM = WITH->numpins; - for (i = 0; i < FORLIM; i++) - { - fprintf(tracefile, " Pin %2d X:%4d Y:%4d N:%ld", - i + 1, g->pinpos[i].x, g->pinpos[i].y, (long)g->pin[i]); - TRY(try12); - fprintf(tracefile, " [%d]", g->pin[i]->ref); - RECOVER(try12); - if (P_escapecode == -20) - goto _Ltry11; - ENDTRY(try12); - putc('\n', tracefile); - } - TRY(try13); - gg.actfile = gg.tracefile; - gg.actflag = true; - calltoolgate(g, act_writegate); - RECOVER(try13); - if (P_escapecode == -20) - goto _Ltry11; - fprintf(tracefile, " (Failed to output gate value) %d\n", - P_escapecode); - ENDTRY(try13); - g = g->next; - } - RECOVER2(try11,_Ltry11); - if (P_escapecode == -20) - _Escape(P_escapecode); - fprintf(tracefile, " Internal error, %d\n", P_escapecode); - ENDTRY(try11); - fprintf(tracefile, - "\n\n-------------------------------------------------------------------------\n\n\n"); -} - - /*=================== GETHELP ==================*/ /*= =*/ /*= Display program Help information. =*/ @@ -4037,13 +3669,12 @@ struct LOC_wantsolder int hasred, hasgreen, hasyellow, hasblue; } ; -static void markcolor(hw, LINK) - log_hwrec **hw; - struct LOC_wantsolder *LINK; +static void markcolor(log_hwrec **hw, struct LOC_wantsolder *LINK) { if (*hw == NULL) return; - switch ((*hw)->wcolr) { + switch ((*hw)->wcolr) + { case log_wcol_red: LINK->hasred = true; @@ -4064,22 +3695,7 @@ static void markcolor(hw, LINK) } -static void delgetnode(save, old, n) - log_nrec **save, **old, **n; -{ - /* if save <> nil then - begin -n := save; --> Not safe! <-- -save := nil; -end -else -*/ - copynode(*old, n); -} - - -static void confirmsimtype(n) - log_nrec *n; +static void confirmsimtype(log_nrec *n) { log_grec *g; short i, pg; @@ -4093,12 +3709,16 @@ static void confirmsimtype(n) return; found = false; FORLIM = gg.numpages; - for (pg = 0; pg < FORLIM; pg++) { + for (pg = 0; pg < FORLIM; pg++) + { g = gg.gbase[pg]; - while (g != NULL && !found) { + while (g != NULL && !found) + { FORLIM1 = g->kind->numpins; - for (i = 0; i < FORLIM1; i++) { - if (g->pin[i] == n) { + for (i = 0; i < FORLIM1; i++) + { + if (g->pin[i] == n) + { if (g->kind->pin[i].s >= 8) found = true; } @@ -4106,14 +3726,17 @@ static void confirmsimtype(n) g = g->next; } } + if (found) return; + if (gg.traceflag) fprintf(tracefile, "Deleting simtype of %ld\n", (long)n); calltoolnode(n, act_disposenode); disposeattrs(&n->attr, n->simtype->nnumattrs, n->simtype->nattr); hn = gg.hnbase; - while (hn != NULL) { + while (hn != NULL) + { if (gg.signaltab[hn->sig - 1].np == n) disposeattrs(&hn->attr, n->simtype->hnumattrs, n->simtype->hattr); hn = hn->next; @@ -4122,343 +3745,51 @@ static void confirmsimtype(n) } -#define rtn "COMBINENODES" - +static void scancn (cnrec *cn, struct LOC_checkcombine *LINK); -/*================ COMBINENODES ================*/ -/*= =*/ -/*= Combine node N1 into N2. Adjust all =*/ -/*= references accordingly. =*/ -/*= =*/ -/*================================================*/ +/* Local variables for scancn: */ +struct LOC_scancn { + struct LOC_checkcombine *LINK; +} ; -static void combinenodes(n2, n1, cnbase) - log_nrec **n2, **n1; - cnrec *cnbase; +static void scan(log_nrec **n, struct LOC_scancn *LINK) { - log_nrec *nn1, *nn2, *n3; - log_hwrec *hw; - log_vwrec *vw; - log_grec *g; cnrec *cn; - log_hnrec *hn; - log_tool *oldsimtype, *newsimtype; - short i, pg, FORLIM, FORLIM1; - if (gg.traceflag) - fprintf(tracefile, "Combine node %ld into %ld\n", - (long)(*n1), (long)(*n2)); - working(); - if (*n2 == NULL) - switchnode(n2, *n1); - nn1 = *n1; /*VAR params may change out from under us*/ - nn2 = *n2; - if (nn1 != NULL) { - if (nn2 == nn1) - stamp(&nn2->simtype->netstamp); - else { - if (nn1->simtype != nn2->simtype) { - if (nn1->simtype->simtype >= 8) { - if (nn2->simtype->simtype >= 8) { - /* shouldn't happen */ - report(10, rtn); - } else { - n3 = nn1; - nn1 = nn2; - nn2 = n3; - } - } - gg.actx = nn1->simtype->simtype; - gg.actnode2 = nn1; - calltoolnode(nn2, act_combineintonode); - } else { - gg.actnode2 = nn1; - calltoolnode(nn2, act_combinenodes); - } - oldsimtype = nn1->simtype; - newsimtype = nn2->simtype; - stamp(&newsimtype->netstamp); - nn2->changed = true; - FORLIM = gg.numpages; - for (pg = 0; pg < FORLIM; pg++) { - hw = gg.hwbase[pg]; - while (hw != NULL) { - if (hw->node == nn1) - switchnode(&hw->node, nn2); - hw = hw->next; - } - vw = gg.vwbase[pg]; - while (vw != NULL) { - if (vw->node == nn1) - switchnode(&vw->node, nn2); - vw = vw->next; - } - g = gg.gbase[pg]; - while (g != NULL) { - FORLIM1 = g->kind->numpins; - for (i = 0; i < FORLIM1; i++) { - if (g->pin[i] == nn1) - switchnode(&g->pin[i], nn2); - } - g = g->next; - } - } - FORLIM = gg.lastsignal; - for (i = 1; i <= FORLIM; i++) { - if (gg.signaltab[i - 1].np == nn1) { - switchnode(&gg.signaltab[i - 1].np, nn2); - if (oldsimtype->simtype < 8 && newsimtype->simtype >= 8) { - hn = gg.hnbase; - while (hn != NULL) { - if (hn->sig == i) - newattrs(&hn->attr, newsimtype->hnumattrs, newsimtype->hattr); - hn = hn->next; - } - } - } - } - cn = cnbase; - while (cn != NULL) { - if (cn->n == nn1) - cn->n = nn2; - cn = cn->next; - } - if (nodeexists(nn1)) { - report(11, rtn); - disposenode(&nn1); - } - } + if (!LINK->LINK->good) + return; + if (*n != NULL) + checknode(*n, LINK->LINK); + cn = *LINK->LINK->cnbase; + while (cn != NULL && LINK->LINK->good) + { + if ((cn->n == *n && *n != NULL) || cn->np == n) + scancn(cn, LINK->LINK); + cn = cn->next; } - *n1 = *n2; } -#undef rtn - - -/* N is one of the nodes to be merged into N2, later. If N is nil, says - that N2 must be assigned a node, but we don't have anything to connect - to it yet. */ - -static void queuecombine(cnbase, n, n2) - cnrec **cnbase; - log_nrec **n, **n2; +static void scancn(cnrec *cn, struct LOC_checkcombine *LINK) { - cnrec *cn; + struct LOC_scancn V; - if (gg.traceflag) - fprintf(tracefile, "Queue-combine, n = %ld, np -> %ld\n", - (long)(*n), (long)(*n2)); - if (*n == NULL) + V.LINK = LINK; + if (cn->done) return; - cn = (cnrec *)Malloc(sizeof(cnrec)); - cn->next = *cnbase; - *cnbase = cn; - cn->n = *n; - cn->np = n2; + cn->done = true; + scan(&cn->n, &V); + scan(cn->np, &V); } - -/* Local variables for checkcombine: */ -struct LOC_checkcombine { - cnrec **cnbase; - short passcount; - int good; - log_tool *cursimtype; -} ; - -static void scancn (cnrec *cn, struct LOC_checkcombine *LINK); - -static void checknode(n, LINK) - log_nrec *n; - struct LOC_checkcombine *LINK; -{ - log_tool *newsimtype; - char STR1[94]; - - newsimtype = n->simtype; - if (newsimtype->simtype < 8) - return; - if (LINK->cursimtype->simtype < 8) { - LINK->cursimtype = newsimtype; - return; - } - if (LINK->cursimtype->simtype == newsimtype->simtype) - return; - if (LINK->passcount == 2) { - sprintf(STR1, "Tried to connect %s signal to %s", - newsimtype->shortname, LINK->cursimtype->shortname); - message(STR1); - } - LINK->good = false; -} - -/* Local variables for scancn: */ -struct LOC_scancn { - struct LOC_checkcombine *LINK; -} ; - -static void scan(log_nrec **n, struct LOC_scancn *LINK) -{ - cnrec *cn; - - if (!LINK->LINK->good) - return; - if (*n != NULL) - checknode(*n, LINK->LINK); - cn = *LINK->LINK->cnbase; - while (cn != NULL && LINK->LINK->good) { - if ((cn->n == *n && *n != NULL) || cn->np == n) - scancn(cn, LINK->LINK); - cn = cn->next; - } -} - -static void scancn(cn, LINK) - cnrec *cn; - struct LOC_checkcombine *LINK; -{ - struct LOC_scancn V; - - V.LINK = LINK; - if (cn->done) - return; - cn->done = true; - scan(&cn->n, &V); - scan(cn->np, &V); -} - - - -/* Merge all queued nodes. If any simtype conflicts would result, don't - merge any nodes. If a node doesn't have anything merged into it, make - a new node. */ - -static int checkcombine(cnbase_) - cnrec **cnbase_; -{ - struct LOC_checkcombine V; - cnrec *cn; - - V.cnbase = cnbase_; - V.passcount = 1; - do { - cn = *V.cnbase; - while (cn != NULL) { - cn->done = false; - cn = cn->next; - } - cn = *V.cnbase; - V.good = true; - while (cn != NULL && V.good) { - V.cursimtype = simtype_ignore; - scancn(cn, &V); - cn = cn->next; - } - if (!V.good && V.passcount == 1) { - cn = *V.cnbase; - while (cn != NULL) { - confirmsimtype(cn->n); - confirmsimtype(*cn->np); - cn = cn->next; - } - } - if (gg.traceflag && *V.cnbase != NULL) - fprintf(tracefile, "Check-combine (pass %d) finds %s\n", - V.passcount, V.good ? " TRUE" : "FALSE"); - V.passcount++; - } while (!(V.good || V.passcount > 2)); - if (V.good) { - cn = *V.cnbase; - while (cn != NULL) { - combinenodes(cn->np, &cn->n, *V.cnbase); - cn = cn->next; - } - } - while (*V.cnbase != NULL) { - cn = (*V.cnbase)->next; - Free(*V.cnbase); - *V.cnbase = cn; - } - return V.good; -} - - - -static int trycombinenodes(n1, n2) - log_nrec **n1, **n2; -{ - cnrec *cnbase; - - cnbase = NULL; - queuecombine(&cnbase, n1, n2); - return (checkcombine(&cnbase)); -} - - -static void fryhwire(hw) - log_hwrec *hw; -{ - long t0; +static void frysolder(short x, short y) +{ + long t0; remcursor(); clipon(); t0 = timers_sysclock(); - while (labs(timers_sysclock() - t0) < frytime) { - m_color((long)gg.color.conflict); - hline(hw->x1, hw->x2, hw->y); - m_color((long)gg.color.backgr); - hline(hw->x1, hw->x2, hw->y); - } - clipoff(); - refreshsoon(); -} - - -static void fryvwire(vw) - log_vwrec *vw; -{ - long t0; - - remcursor(); - clipon(); - t0 = timers_sysclock(); - while (labs(timers_sysclock() - t0) < frytime) { - m_color((long)gg.color.conflict); - vline(vw->x, vw->y1, vw->y2); - m_color((long)gg.color.backgr); - vline(vw->x, vw->y1, vw->y2); - } - clipoff(); - refreshsoon(); -} - - -static void frygate(g) - log_grec *g; -{ - long t0; - - remcursor(); - clipon(); - t0 = timers_sysclock(); - while (labs(timers_sysclock() - t0) < frytime) { - drawgatec(g->x, g->y, g->g, gg.color.conflict); - eragate(g); - } - clipoff(); - refreshsoon(); -} - - -static void frysolder(x, y) - short x, y; -{ - long t0; - - remcursor(); - clipon(); - t0 = timers_sysclock(); - while (labs(timers_sysclock() - t0) < frytime) { + while (labs(timers_sysclock() - t0) < frytime) + { drawsolderc(x, y, gg.color.conflict); drawsolderc(x, y, gg.color.backgr); } @@ -4467,17 +3798,17 @@ static void frysolder(x, y) } -static void addblobs(blbase, x1, y1, x2, y2) - blobrec **blbase; - short x1, y1, x2, y2; +static void addblobs(blobrec **blbase, short x1, short y1, short x2, short y2) { blobrec *blp; log_srec *s; s = gg.sbase[gg.curpage - 1]; - while (s != NULL) { + while (s != NULL) + { if (P_ibetween((long)x1, (long)s->x, (long)x2) && - P_ibetween((long)y1, (long)s->y, (long)y2)) { + P_ibetween((long)y1, (long)s->y, (long)y2)) + { blp = (blobrec *)Malloc(sizeof(blobrec)); blp->x = s->x; blp->y = s->y; @@ -4489,15 +3820,16 @@ static void addblobs(blbase, x1, y1, x2, y2) } -static void doblobs(blp) - blobrec *blp; +static void doblobs(blobrec *blp) { log_hwrec *hw; log_vwrec *vw; short x, y; - while (blp != NULL) { - if (blp->x != -32768L) { + while (blp != NULL) + { + if (blp->x != -32768L) + { x = blp->x; y = blp->y; hw = gg.hwbase[gg.curpage - 1]; @@ -4506,7 +3838,8 @@ static void doblobs(blp) vw = gg.vwbase[gg.curpage - 1]; while (vw != NULL && (vw->x != x || vw->y1 > y || vw->y2 < y)) vw = vw->next; - if (hw != NULL && vw != NULL && hw->node != vw->node) { + if (hw != NULL && vw != NULL && hw->node != vw->node) + { if (trycombinenodes(&hw->node, &vw->node)) { clipon(); addsolder(x, y, hw, NULL, vw, NULL); @@ -4519,12 +3852,12 @@ static void doblobs(blp) } -static void dispblobs(blbase) - blobrec **blbase; +static void dispblobs(blobrec **blbase) { blobrec *blp; - while (*blbase != NULL) { + while (*blbase != NULL) + { blp = *blbase; *blbase = blp->next; Free(blp); @@ -4532,433 +3865,13 @@ static void dispblobs(blbase) } -#define rtn "ADDHWIRE" - - -/*================== ADDVWIRE ==================*/ -/*= =*/ -/*= ADDHWIRE: =*/ -/*= Add a Horizontal wire. Merge with other =*/ -/*= horizontal wires if touching; solder to =*/ -/*= other vertical wires in T-intersections; =*/ -/*= connect to gate pins as necessary. =*/ -/*= VLSI-mode rules are more complex! =*/ -/*= ADDVWIRE works similarly. =*/ -/*= =*/ -/*================================================*/ - -static void addhwire(x1, x2, y, colr) - short x1, x2, y, colr; -{ - cnrec *cnbase; - log_hwrec *hw, *hw1, *hw2; - log_vwrec *vw1, *vw2; - log_grec *g; - short i, xp, hx1, hx2, hy, vx, vy1, vy2, hcolr, vcolr; - blobrec *blbase; - short FORLIM; - - if (gg.traceflag) - fprintf(tracefile, "Add hwire %d-%d, %d\n", x1, x2, y); - sortshints(&x1, &x2); - cnbase = NULL; - remcursor(); - working(); - clipon(); - if (!vlsi) - colr = log_wcol_normal; - newhw(&hw); - hw->x1 = log_maxshint; - hw->x2 = log_maxshint; - hw->y = log_maxshint; - hw->node = NULL; - hw1 = hw->next; - blbase = NULL; - while (hw1 != NULL) { - hw2 = hw1->next; - hx1 = hw1->x1; - hx2 = hw1->x2; - hy = hw1->y; - hcolr = hw1->wcolr; - if (hy == y && hx1 <= x2 && hx2 >= x1) { - if (hcolr == colr) { - x1 = P_imin2((long)x1, (long)hx1); - x2 = P_imax2((long)x2, (long)hx2); - addblobs(&blbase, hx1, hy, hx2, hy); - delhwire(hw1); - } - } - hw1 = hw2; - } - hw->x1 = x1; - hw->x2 = x2; - hw->y = y; - hw->wcolr = colr; - chpageplace((int)gg.curpage, x1, y, x2, y); - g = gg.gbase[gg.curpage - 1]; - while (g != NULL) { - if (abs(g->y - y) <= g->kind->bbmax && - P_ibetweenm((long)x1, (long)g->x, (long)x2, (long)g->kind->bbmax)) { - FORLIM = g->kind->numpins; - for (i = 0; i < FORLIM; i++) { - xp = g->pinpos[i].x; - if (g->pinpos[i].y == y && x1 <= xp && xp <= x2) - queuecombine(&cnbase, &g->pin[i], &hw->node); - } - } - g = g->next; - } - vw1 = gg.vwbase[gg.curpage - 1]; - while (vw1 != NULL) { - vx = vw1->x; - vy1 = vw1->y1; - vy2 = vw1->y2; - vcolr = vw1->wcolr; - vw2 = vw1->next; - if ((((vx == x1 || vx == x2) && vy1 <= y && y <= vy2) || - ((vy1 == y || vy2 == y) && x1 <= vx && vx <= x2)) && - (colr == vcolr || colr == log_wcol_blue || vcolr == log_wcol_blue)) - queuecombine(&cnbase, &vw1->node, &hw->node); - else if (vlsi && x1 < vx && vx < x2 && vy1 < y && y < vy2 && colr == vcolr) - queuecombine(&cnbase, &vw1->node, &hw->node); - vw1 = vw2; - } - if (cnbase == NULL) - newnoderef(&hw->node, 0, 1L); - if (!checkcombine(&cnbase)) { - fryhwire(hw); - disphw(&hw); - gg.nearhw = NULL; - goto _L1; /*return*/ - } - vw1 = gg.vwbase[gg.curpage - 1]; - while (vw1 != NULL) { - vx = vw1->x; - vy1 = vw1->y1; - vy2 = vw1->y2; - vcolr = vw1->wcolr; - vw2 = vw1->next; - if ((((vx == x1 || vx == x2) && vy1 <= y && y <= vy2) || - ((vy1 == y || vy2 == y) && x1 <= vx && vx <= x2)) && - (colr == vcolr || colr == log_wcol_blue || vcolr == log_wcol_blue)) { - clipon(); - if (!vlsi) - addsoldert(hw, vw1); - else if (colr != vcolr) - addsolder(vx, y, hw, NULL, vw1, NULL); - } - vw1 = vw2; - } - clipon(); - if (hw->node->conflict1 && hw->node->conflict2) /*or hw^.node^.oconflict*/ - m_color((long)gg.color.conflict); - else if (gg.glowmode) - m_color(glowcol(hw->node, (long)gg.color.wire[colr - log_wcol_normal])); - else - m_color((long)gg.color.wire[colr - log_wcol_normal]); - hline(x1, x2, y); - doblobs(blbase); - gg.nearhw = hw; - clipoff(); - refreshsoon(); - if (gg.traceflag) - fprintf(tracefile, "Added hwire %ld\n", (long)hw); -_L1: - dispblobs(&blbase); - - /* Deal with color A drawn over color B */ - /*VVV*/ -} - -#undef rtn - - -static void addhwire2(x1, x2, y) - short x1, x2, y; -{ - addhwire(x1, x2, y, log_wcol_normal); -} - - -#define rtn "ADDHWIRE" - - -static void addvwire(x, y1, y2, colr) - short x, y1, y2, colr; -{ - cnrec *cnbase; - log_vwrec *vw, *vw1, *vw2; - log_hwrec *hw1, *hw2; - log_grec *g; - short i, yp, hy, hx1, hx2, vx, vy1, vy2, hcolr, vcolr; - blobrec *blbase; - short FORLIM; - - if (gg.traceflag) - fprintf(tracefile, "Add vwire %d, %d-%d\n", x, y1, y2); - sortshints(&y1, &y2); - cnbase = NULL; - remcursor(); - working(); - clipon(); - if (!vlsi) - colr = log_wcol_normal; - newvw(&vw); - vw->x = log_maxshint; - vw->y1 = log_maxshint; - vw->y2 = log_maxshint; - vw->node = NULL; - vw1 = vw->next; - blbase = NULL; - while (vw1 != NULL) { - vw2 = vw1->next; - vx = vw1->x; - vy1 = vw1->y1; - vy2 = vw1->y2; - vcolr = vw1->wcolr; - if (vx == x && vy1 <= y2 && vy2 >= y1) { - if (vcolr == colr) { - y1 = P_imin2((long)y1, (long)vy1); - y2 = P_imax2((long)y2, (long)vy2); - addblobs(&blbase, vx, vy1, vx, vy2); - delvwire(vw1); - } - } - vw1 = vw2; - } - vw->y1 = y1; - vw->y2 = y2; - vw->x = x; - vw->wcolr = colr; - chpageplace((int)gg.curpage, x, y1, x, y2); - g = gg.gbase[gg.curpage - 1]; - while (g != NULL) { - if (abs(g->x - x) <= g->kind->bbmax && - P_ibetweenm((long)y1, (long)g->y, (long)y2, (long)g->kind->bbmax)) { - FORLIM = g->kind->numpins; - for (i = 0; i < FORLIM; i++) { - yp = g->pinpos[i].y; - if (g->pinpos[i].x == x && y1 <= yp && yp <= y2) - queuecombine(&cnbase, &g->pin[i], &vw->node); - } - } - g = g->next; - } - hw1 = gg.hwbase[gg.curpage - 1]; - while (hw1 != NULL) { - hy = hw1->y; - hx1 = hw1->x1; - hx2 = hw1->x2; - hcolr = hw1->wcolr; - hw2 = hw1->next; - if ((((hy == y1 || hy == y2) && hx1 <= x && x <= hx2) || - ((hx1 == x || hx2 == x) && y1 <= hy && hy <= y2)) && - (colr == hcolr || colr == log_wcol_blue || hcolr == log_wcol_blue)) - queuecombine(&cnbase, &hw1->node, &vw->node); - else if (vlsi && y1 < hy && hy < y2 && hx1 < x && x < hx2 && colr == hcolr) - queuecombine(&cnbase, &hw1->node, &vw->node); - hw1 = hw2; - } - if (cnbase == NULL) - newnoderef(&vw->node, 0, 1L); - if (!checkcombine(&cnbase)) { - fryvwire(vw); - dispvw(&vw); - gg.nearvw = NULL; - goto _L1; /*return*/ - } - hw1 = gg.hwbase[gg.curpage - 1]; - while (hw1 != NULL) { - hy = hw1->y; - hx1 = hw1->x1; - hx2 = hw1->x2; - hcolr = hw1->wcolr; - hw2 = hw1->next; - if ((((hy == y1 || hy == y2) && hx1 <= x && x <= hx2) || - ((hx1 == x || hx2 == x) && y1 <= hy && hy <= y2)) && - (colr == hcolr || colr == log_wcol_blue || hcolr == log_wcol_blue)) { - clipon(); - if (!vlsi) - addsoldert(hw1, vw); - else if (colr != hcolr) - addsolder(x, hy, hw1, NULL, vw, NULL); - } - hw1 = hw2; - } - clipon(); - if (vw->node->conflict1 && vw->node->conflict2) /*or vw^.node^.oconflict*/ - m_color((long)gg.color.conflict); - else if (gg.glowmode) - m_color(glowcol(vw->node, (long)gg.color.wire[colr - log_wcol_normal])); - else - m_color((long)gg.color.wire[colr - log_wcol_normal]); - vline(x, y1, y2); - doblobs(blbase); - gg.nearvw = vw; - clipoff(); - refreshsoon(); - if (gg.traceflag) - fprintf(tracefile, "Added vwire %ld\n", (long)vw); -_L1: - dispblobs(&blbase); - - /* Deal with color A drawn over color B */ - /*VVV*/ -} - -#undef rtn - - -static void addvwire2(x, y1, y2) - short x, y1, y2; -{ - addvwire(x, y1, y2, log_wcol_normal); -} - - -/*================ CONNECTGATE =================*/ -/*= =*/ -/*= Check each pin of a gate and connect to =*/ -/*= wires, other pins as necessary. =*/ -/*= =*/ -/*================================================*/ - -static void initpinpos(g) - log_grec *g; -{ - short i, rxx, rxy, ryx, ryy; - log_krec *WITH; - short FORLIM; - - rxx = log_rotxx[g->rot]; - rxy = log_rotxy[g->rot]; - ryx = log_rotyx[g->rot]; - ryy = log_rotyy[g->rot]; - WITH = g->kind; - FORLIM = WITH->numpins; - for (i = 0; i < FORLIM; i++) { - g->pinpos[i].x = g->x + WITH->pin[i].x * rxx + WITH->pin[i].y * ryx; - g->pinpos[i].y = g->y + WITH->pin[i].x * rxy + WITH->pin[i].y * ryy; - } -} - - -static int connectgate(g) - log_grec *g; -{ - int Result; - cnrec *cnbase; - short i, j, xp, yp; - log_hwrec *hw; - log_vwrec *vw; - log_nrec **n1; - log_grec *g1; - short ptrs[log_maxpins]; - int success; - short FORLIM, FORLIM1; - - if (gg.traceflag) - fprintf(tracefile, "Connect gate %ld, type %s\n", (long)g, g->kind->name); - linkgate(&g); - working(); - initpinpos(g); - FORLIM = g->kind->numpins; - for (i = 0; i < FORLIM; i++) { - ptrs[i] = 0; - g->pin[i] = NULL; - } - FORLIM = g->kind->numpins; - for (i = 1; i <= FORLIM; i++) { - if (ptrs[i - 1] == 0) { - newnoderef(&g->pin[i - 1], g->kind->pin[i - 1].s, 1L); - if (g->pin[i - 1] == NULL) { - Result = false; - goto _L1; /*return*/ - } - j = i; - do { - ptrs[j - 1] = i; - j = g->kind->pin[j - 1].c; - } while (j != i && j != 0); - } - } - cnbase = NULL; - FORLIM = g->kind->numpins; - for (i = 0; i < FORLIM; i++) { - xp = g->pinpos[i].x; - yp = g->pinpos[i].y; - n1 = NULL; - hw = gg.hwbase[gg.curpage - 1]; - while (hw != NULL && n1 == NULL) { - if (hw->x1 <= xp && xp <= hw->x2 && yp == hw->y) - n1 = &hw->node; - hw = hw->next; - } - vw = gg.vwbase[gg.curpage - 1]; - while (vw != NULL && n1 == NULL) { - if (vw->y1 <= yp && yp <= vw->y2 && xp == vw->x) - n1 = &vw->node; - vw = vw->next; - } - g1 = gg.gbase[gg.curpage - 1]; - while (g1 != NULL && n1 == NULL) { - if (g1 != g && P_imax2((long)abs(g1->x - xp), (long)abs(g1->y - yp)) <= - g1->kind->bbmax) { - FORLIM1 = g1->kind->numpins; - for (j = 0; j < FORLIM1; j++) { - if (g1->pinpos[j].x == xp && g1->pinpos[j].y == yp) - n1 = &g1->pin[j]; - } - } - g1 = g1->next; - } - if (n1 != NULL) - queuecombine(&cnbase, &g->pin[ptrs[i] - 1], n1); - } - if (g->kind->simtype == simtype_common && g->sig != 0) - queuecombine(&cnbase, &gg.signaltab[g->sig - 1].np, g->pin); - gg.actflag = true; - calltoolgate(g, act_connectgate); - success = gg.actflag; - if (success && checkcombine(&cnbase)) { - FORLIM = g->kind->numpins; - for (i = 0; i < FORLIM; i++) { - if (ptrs[i] != i + 1) - g->pin[i] = refnode(g->pin[ptrs[i] - 1]); - } - Result = true; - } else - success = false; - if (!success) { - Result = false; - FORLIM = g->kind->numpins; - for (i = 1; i <= FORLIM; i++) { - if (ptrs[i - 1] == i) - unrefnode(&g->pin[i - 1]); - } - unlkgate(&g); - } -_L1: - return Result; -} - - -static void pconnectgate(g, success) - log_grec *g; - int *success; -{ - *success = connectgate(g); -} - - /*================= CLEARBUF ===================*/ /*= =*/ /*= Clear a copy buffer. =*/ /*= =*/ /*================================================*/ -static void initbuf(bases) - baseptrs *bases; +static void initbuf(baseptrs *bases) { bases->gcopy = NULL; bases->scopy = NULL; @@ -4971,8 +3884,7 @@ static void initbuf(bases) } -static void clearbuf(bases) - baseptrs *bases; +static void clearbuf(baseptrs *bases) { log_grec *g; log_srec *s; @@ -4981,44 +3893,54 @@ static void clearbuf(bases) log_lrec *l; log_brec *b; - while (bases->gcopy != NULL) { + while (bases->gcopy != NULL) + { g = bases->gcopy->next; disposegate(&bases->gcopy); bases->gcopy = g; } - while (bases->scopy != NULL) { + + while (bases->scopy != NULL) + { s = bases->scopy->next; Free(bases->scopy); bases->scopy = s; } - while (bases->hwcopy != NULL) { + + while (bases->hwcopy != NULL) + { hw = bases->hwcopy->next; Free(bases->hwcopy); bases->hwcopy = hw; } - while (bases->vwcopy != NULL) { + + while (bases->vwcopy != NULL) + { vw = bases->vwcopy->next; Free(bases->vwcopy); bases->vwcopy = vw; } - while (bases->lcopy != NULL) { + + while (bases->lcopy != NULL) + { l = bases->lcopy->next; Free(bases->lcopy); bases->lcopy = l; } - while (bases->bcopy != NULL) { + + while (bases->bcopy != NULL) + { b = bases->bcopy->next; Free(bases->bcopy); bases->bcopy = b; } + bases->pgnum = 0; bases->valid = false; } - -static int bufempty(bases) - baseptrs *bases; +static int bufempty(baseptrs *bases) { return (bases->gcopy == NULL && bases->scopy == NULL && bases->hwcopy == NULL && bases->vwcopy == NULL && @@ -5026,9 +3948,7 @@ static int bufempty(bases) } - -static int bufissmall(bases) - baseptrs *bases; +static int bufissmall(baseptrs *bases) { return ((bases->gcopy == NULL || bases->gcopy->next == NULL || bases->gcopy->next->next == NULL || @@ -5046,7 +3966,6 @@ static int bufissmall(bases) } - /*================== CUTCOPY ===================*/ /*= =*/ /*= Cut or Copy all gates/wires/solder points =*/ @@ -5055,10 +3974,7 @@ static int bufissmall(bases) /*= =*/ /*================================================*/ -static void cutcopy(bases, x1, y1, x2, y2, cut, tap) - baseptrs *bases; - short x1, y1, x2, y2; - int cut, tap; +static void cutcopy(baseptrs *bases, short x1, short y1, short x2, short y2, int cut, int tap) { log_grec *g, *g1, *g2; log_hwrec *hw, *hw1, *hw2; @@ -5073,25 +3989,32 @@ static void cutcopy(bases, x1, y1, x2, y2, cut, tap) clearbuf(bases); anchorx = x2; anchory = y2; - if (tap) { + if (tap) + { x2 = x1; y2 = y1; closergate(x1, y1); - if (gg.nearlabel == NULL && gg.nearbox == NULL && gg.neargate == NULL) { + if (gg.nearlabel == NULL && gg.nearbox == NULL && gg.neargate == NULL) + { closerwire(x1, y1); - if (gg.nearhw != NULL) { + if (gg.nearhw != NULL) + { gg.nearvw = NULL; x1 = gg.nearhw->x1; x2 = gg.nearhw->x2; y1 = gg.nearhw->y; y2 = gg.nearhw->y; - } else if (gg.nearvw != NULL) { + } + else if (gg.nearvw != NULL) + { x1 = gg.nearvw->x; x2 = gg.nearvw->x; y1 = gg.nearvw->y1; y2 = gg.nearvw->y2; } - } else { + } + else + { gg.nearhw = NULL; gg.nearvw = NULL; } @@ -5106,13 +4029,16 @@ static void cutcopy(bases, x1, y1, x2, y2, cut, tap) sortshints(&y1, &y2); bases->pgnum = gg.curpage; g = gg.gbase[gg.curpage - 1]; - while (g != NULL) { + while (g != NULL) + { g1 = g->next; if (tap) found = (g == gg.neargate); else found = (x1 <= g->x && g->x <= x2 && y1 <= g->y && g->y <= y2); - if (found) { + + if (found) + { copygate(g, &g2); g2->next = bases->gcopy; bases->gcopy = g2; @@ -5124,12 +4050,14 @@ static void cutcopy(bases, x1, y1, x2, y2, cut, tap) g = g1; } s = gg.sbase[gg.curpage - 1]; - while (s != NULL) { + while (s != NULL) + { if (tap) found = ((s->hwire == gg.nearhw && s->hwire != NULL) || (s->vwire == gg.nearvw && s->vwire != NULL)); else found = (x1 <= s->x && s->x <= x2 && y1 <= s->y && s->y <= y2); + if (found && (s->hwire == NULL || (s->hwire->x1 != s->x && s->hwire->x2 != s->x)) && (s->vwire == NULL || (s->vwire->y1 != s->y && s->vwire->y2 != s->y))) { @@ -5142,7 +4070,8 @@ static void cutcopy(bases, x1, y1, x2, y2, cut, tap) s = s->next; } hw = gg.hwbase[gg.curpage - 1]; - while (hw != NULL) { + while (hw != NULL) + { hw1 = hw->next; xx1 = hw->x1; xx2 = hw->x2; @@ -5151,18 +4080,24 @@ static void cutcopy(bases, x1, y1, x2, y2, cut, tap) found = (hw == gg.nearhw); else found = (x1 <= xx2 && xx1 <= x2 && y1 <= yy1 && yy1 <= y2); - if (found) { + if (found) + { hw2 = (log_hwrec *)Malloc(sizeof(log_hwrec)); hw2->x1 = P_imax2((long)xx1, (long)x1) - anchorx; hw2->x2 = P_imin2((long)xx2, (long)x2) - anchorx; hw2->y = yy1 - anchory; hw2->wcolr = hw->wcolr; + if (hw2->x1 == hw2->x2) + { Free(hw2); - else { + } + else + { hw2->next = bases->hwcopy; bases->hwcopy = hw2; - if (cut) { + if (cut) + { blbase = NULL; if (xx1 < x1) addblobs(&blbase, xx1, yy1, x1, yy1); @@ -5181,7 +4116,8 @@ static void cutcopy(bases, x1, y1, x2, y2, cut, tap) hw = hw1; } vw = gg.vwbase[gg.curpage - 1]; - while (vw != NULL) { + while (vw != NULL) + { vw1 = vw->next; xx1 = vw->x; yy1 = vw->y1; @@ -5190,18 +4126,24 @@ static void cutcopy(bases, x1, y1, x2, y2, cut, tap) found = (vw == gg.nearvw); else found = (y1 <= yy2 && yy1 <= y2 && x1 <= xx1 && xx1 <= x2); - if (found) { + + if (found) + { vw2 = (log_vwrec *)Malloc(sizeof(log_vwrec)); vw2->x = xx1 - anchorx; vw2->y1 = P_imax2((long)yy1, (long)y1) - anchory; vw2->y2 = P_imin2((long)yy2, (long)y2) - anchory; vw2->wcolr = vw->wcolr; if (vw2->y1 == vw2->y2) + { Free(vw2); - else { + } + else + { vw2->next = bases->vwcopy; bases->vwcopy = vw2; - if (cut) { + if (cut) + { blbase = NULL; if (yy1 < y1) addblobs(&blbase, xx1, y1, xx1, yy1); @@ -5220,24 +4162,29 @@ static void cutcopy(bases, x1, y1, x2, y2, cut, tap) vw = vw1; } l = gg.lbase[gg.curpage - 1]; - while (l != NULL) { + while (l != NULL) + { l1 = l->next; if (tap) + { found = (l == gg.nearlabel); - else { + } + else + { found = (x1 <= l->x + m_strwidth(logfont_lfont, l->name) / gg.scale && l->x <= x2 && y1 <= l->y + 2 && l->y <= y2); - /* p2c: log.text, line 9208: - * Warning: Symbol 'LOGFONT_LFONT' is not defined [221] */ } - if (found) { + + if (found) + { l2 = (log_lrec *)Malloc(sizeof(log_lrec)); l2->next = bases->lcopy; bases->lcopy = l2; l2->x = l->x - anchorx; l2->y = l->y - anchory; strcpy(l2->name, l->name); - if (cut) { + if (cut) + { eralabel(l); displabel(&l); } @@ -5245,13 +4192,16 @@ static void cutcopy(bases, x1, y1, x2, y2, cut, tap) l = l1; } b = gg.bbase[gg.curpage - 1]; - while (b != NULL) { + while (b != NULL) + { b1 = b->next; if (tap) found = (b == gg.nearbox); else found = (x1 <= b->x1 && b->x2 <= x2 && y1 <= b->y1 && b->y2 <= y2); - if (found) { + + if (found) + { b2 = (log_brec *)Malloc(sizeof(log_brec)); b2->next = bases->bcopy; bases->bcopy = b2; @@ -5259,7 +4209,8 @@ static void cutcopy(bases, x1, y1, x2, y2, cut, tap) b2->y1 = b->y1 - anchory; b2->x2 = b->x2 - anchorx; b2->y2 = b->y2 - anchory; - if (cut) { + if (cut) + { drawboxc(b, gg.color.backgr); dispbox(&b); } @@ -5281,7 +4232,8 @@ static void checkabort() static void waitnear() { - do { + do + { gg.stillnear = true; pass(); trykbdscroll(); @@ -5294,7 +4246,8 @@ static void waitnear() static void getfirstpoint() { checkabort(); - do { + do + { pass(); trykbdscroll(); pen(); @@ -5305,9 +4258,7 @@ static void getfirstpoint() } -static int getrectangle(x1, y1, x2, y2, first) - short *x1, *y1, *x2, *y2; - int first; +static int getrectangle(short *x1, short *y1, short *x2, short *y2, int first) { int flag; long time; @@ -5317,7 +4268,8 @@ static int getrectangle(x1, y1, x2, y2, first) *x1 = gg.posx; *y1 = gg.posy; time = timers_sysclock(); - do { + do + { pen(); *x2 = gg.gridx; *y2 = gg.gridy; @@ -5327,7 +4279,8 @@ static int getrectangle(x1, y1, x2, y2, first) if (flag) rect(*x1, *y1, *x2, *y2); m_colormode((long)m_normal); - do { + do + { pass(); trykbd(); pen(); @@ -5366,15 +4319,15 @@ static void delcommand() clearfunc(); cursortype = delete__; waitnear(); - do { + do + { flag = getrectangle(&x1, &y1, &x2, &y2, true); cutcopy(©buf, x1, y1, x2, y2, true, flag); } while (true); } -static int pagembb(pg, x1, y1, x2, y2) - short pg, *x1, *y1, *x2, *y2; +static int pagembb(short pg, short *x1, short *y1, short *x2, short *y2) { short max; log_grec *g; @@ -5388,7 +4341,8 @@ static int pagembb(pg, x1, y1, x2, y2) *x2 = -log_maxshint; *y2 = -log_maxshint; g = gg.gbase[pg - 1]; - while (g != NULL) { + while (g != NULL) + { max = g->kind->bbmax; if (g->x - max < *x1) *x1 = g->x - max; @@ -5401,7 +4355,8 @@ static int pagembb(pg, x1, y1, x2, y2) g = g->next; } hw = gg.hwbase[pg - 1]; - while (hw != NULL) { + while (hw != NULL) + { if (hw->x1 < *x1) *x1 = hw->x1; if (hw->x2 > *x2) @@ -5413,7 +4368,8 @@ static int pagembb(pg, x1, y1, x2, y2) hw = hw->next; } vw = gg.vwbase[pg - 1]; - while (vw != NULL) { + while (vw != NULL) + { if (vw->x < *x1) *x1 = vw->x; if (vw->x > *x2) @@ -5425,7 +4381,8 @@ static int pagembb(pg, x1, y1, x2, y2) vw = vw->next; } l = gg.lbase[pg - 1]; - while (l != NULL) { + while (l != NULL) + { if (l->x < *x1) *x1 = l->x; max = m_strwidth(logfont_lfont, l->name) / gg.scale; @@ -5438,7 +4395,8 @@ static int pagembb(pg, x1, y1, x2, y2) l = l->next; } b = gg.bbase[pg - 1]; - while (b != NULL) { + while (b != NULL) + { if (b->x1 < *x1) *x1 = b->x1; if (b->x2 > *x2) @@ -5473,15 +4431,14 @@ static void deleverything() /*= =*/ /*================================================*/ -static void changekind2(i, gtype, sig, attrs) - short i, gtype, sig; - log_gattrrec *attrs; +static void changekind2(short i, short gtype, short sig, log_gattrec *attrs) { log_krec *k; clipoff(); kdrawgatec(i, gg.color.backgr); - if (kindattr[i - 1] != NULL) { + if (kindattr[i - 1] != NULL) + { k = kind[(kindgroup[i - 1] & (log_kindoffset - 1)) - 1]; disposeattrs(&kindattr[i - 1], k->numattrs, k->attr); kindattr[i - 1] = NULL; @@ -5497,21 +4454,19 @@ static void changekind2(i, gtype, sig, attrs) } -static void changekind(gtype, sig, attrs) - short gtype, sig; - log_gattrrec *attrs; +static void changekind(short gtype, short sig, log_gattrrec *attrs) { short i; - if (kindgroupleft <= gg.t.x && gg.t.x < kindgroupright) { + if (kindgroupleft <= gg.t.x && gg.t.x < kindgroupright) + { i = (gg.t.x - kindgroupleft) / kindgroupspacing + 1; changekind2(i, gtype, sig, attrs); } } -static void showstick(x1, y1, x2, y2, mode) - long x1, y1, x2, y2, mode; +static void showstick(long x1, long y1, long x2, long y2, long mode) { m_colormode(mode); m_color((long)gg.color.select); @@ -5532,11 +4487,13 @@ static void yardstick() x1 = gg.posx; y1 = gg.posy; - do { + do + { x2 = gg.gridx; y2 = gg.gridy; showstick(x1, y1, x2, y2, (long)m_xor); - do { + do + { pass(); trykbd(); pen(); @@ -5547,14 +4504,17 @@ static void yardstick() } while (gg.t.depressed && *gg.func == '\0'); x1 -= x2; y1 -= y2; - while (gg.t.near_ && *gg.func == '\0') { + while (gg.t.near_ && *gg.func == '\0') + { remcursor(); showstick(x2 + x1, y2 + y1, x2, y2, (long)m_normal); - do { + do + { x2 = gg.gridx; y2 = gg.gridy; showstick(x2 + x1, y2 + y1, x2, y2, (long)m_xor); - do { + do + { pass(); trykbd(); pen(); @@ -5566,178 +4526,21 @@ static void yardstick() } } - -static void yardstickcommand() -{ - log_setmode("YARD"); - clearfunc(); - cursortype = copy_; - getfirstpoint(); - waitnear(); - yardstick(); - cursortype = normal; - log_setmode(""); -} - - -/*================= ADDGATE1 ===================*/ -/*= =*/ -/*= Add a gate to the circuit. Initialize all =*/ -/*= gate variables, etc. =*/ -/*= =*/ -/*================================================*/ - -static void addgate2(x, y, gtype, sig, attrs) - short x, y, gtype, sig; - log_gattrrec *attrs; -{ - log_grec *g, *g1; - short i, gmax; - int flag; - - newgate2(&g, gtype, sig, attrs); - if (gatecount[gg.curpage - 1] == log_maxshint) { - i = 0; - gmax = 0; - do { - i++; - g1 = gg.gbase[gg.curpage - 1]; - flag = false; - while (g1 != NULL && !flag) { - if (g1->gc > gmax) - gmax = g1->gc; - flag = (g1->gc == i); - } - } while (flag); - g->gc = i; - gatecount[gg.curpage - 1] = gmax; - } else { - gatecount[gg.curpage - 1]++; - g->gc = gatecount[gg.curpage - 1]; - } - g->x = x; - g->y = y; - clipon(); - drawgatex(g); - clipoff(); - if (!connectgate(g)) { - frygate(g); - disposegate(&g); - } - gg.refrflag = true; - gg.neargate = g; -} - - -static void addgate1(x, y, gtype) - short x, y, gtype; -{ - addgate2(x, y, gtype, 0, NULL); -} - - -static void uaddgate(x, y, gtype) - short x, y, gtype; -{ - short xx, yy; - log_grec *g; - log_krec *k; - - x = P_imin2(P_imax2((long)x, gridcen * 3L / 2), across - gridcen * 3L / 2); - y = P_imin2(P_imax2((long)y, gridcen * 3L / 2), baseline - gridcen * 3L / 2); - k = kind[(gtype & (log_kindoffset - 1)) - 1]; - do { - xx = (x + gg.xoff) / gg.scale; - yy = (y + gg.yoff) / gg.scale; - g = gg.gbase[gg.curpage - 1]; - while (g != NULL && P_imax2((long)abs(g->x - xx), (long)abs(g->y - yy)) > - g->kind->bbmax + k->bbmax) - g = g->next; - if (g != NULL) { - x += gridcen * 2; - if (x > across - gridcen * 3) { - x = gridcen * 2; - y += gridcen * 2; - } - } - } while (g != NULL); - addgate1(xx, yy, gtype); -} - - - -/*================== ADDGATE ===================*/ -/*= =*/ -/*= Move a gate into position, then add to =*/ -/*= circuit or menu area. =*/ -/*= =*/ -/*================================================*/ - -static void movexorgate(x, y, g, sig, yy) - short x, y, g, sig, yy; -{ - clipoff(); - m_colormode((long)m_xor); - if (yy < baseline) { - drawgatec(x, y, g, gg.color.gate); - signallabel((int)(x * gg.scale - gg.xoff), (int)(y * gg.scale - gg.yoff), - g, sig, gg.color.signal); - } else { - udrawgatec((int)(x * gg.scale - gg.xoff), (int)(y * gg.scale - gg.yoff), - g, gg.color.gate); - if (zoom == 0 && - kind[(g & (log_kindoffset - 1)) - 1]->bbmax <= maxsafescale) - drawgatedotsc(x, y, g, gg.color.gatepin); - } - m_colormode((long)m_normal); -} - - -static int addgate(gtype, sig, attrs) - short gtype, sig; - log_gattrrec *attrs; -{ - int Result; - short yy; - int oo; - log_krec *k; - - Result = false; - if (gtype != 0 && (gtype & (log_kindoffset - 1)) <= maxkinds) { - k = kind[(gtype & (log_kindoffset - 1)) - 1]; - if (k != NULL) { - do { - yy = gg.t.y; - gg.posx = gg.gridx; - gg.posy = gg.gridy; - oo = gg.t.off; - movexorgate(gg.posx, gg.posy, gtype, sig, yy); - do { - pass(); - trykbd(); - pen(); - } while (gg.gridx == gg.posx && gg.gridy == gg.posy && - gg.t.depressed && strcmp(gg.func, "REFR")); - movexorgate(gg.posx, gg.posy, gtype, sig, yy); - scroll(); - } while (gg.t.depressed); - if (!oo && !gg.t.off) { - if (gg.t.y < baseline) { - addgate2(gg.posx, gg.posy, gtype, sig, attrs); - Result = true; - } else - changekind(gtype, sig, attrs); - } - } - } - gg.startpoint = false; - return Result; -} - + +static void yardstickcommand() +{ + log_setmode("YARD"); + clearfunc(); + cursortype = copy_; + getfirstpoint(); + waitnear(); + yardstick(); + cursortype = normal; + log_setmode(""); +} -static void nextkindsig(i) - short i; +static void nextkindsig(short i) { char buf[256]; short j; @@ -5749,13 +4552,18 @@ static void nextkindsig(i) j = strlen(buf); if (!(j > 0 && isdigit(buf[j - 1]))) return; - while (j > 0 && buf[j - 1] == '9') { + while (j > 0 && buf[j - 1] == '9') + { buf[j - 1] = '0'; j--; } + if (j > 0 && isdigit(buf[j - 1])) + { buf[j - 1]++; - else { + } + else + { sprintf(STR1, "1%s", buf + j); strcpy(buf + j, STR1); } @@ -5771,10 +4579,10 @@ struct LOC_xorcopybuf { int aborting; } ; -static int abortit(LINK) - struct LOC_xorcopybuf *LINK; +static int abortit(struct LOC_xorcopybuf *LINK) { - if (LINK->max == LONG_MAX) { + if (LINK->max == LONG_MAX) + { if (LINK->aborting || timers_sysclock() - LINK->time <= 10) return LINK->aborting; clipoff(); @@ -5785,8 +4593,11 @@ static int abortit(LINK) !gg.stillnear || pollkbd2()) LINK->aborting = true; return LINK->aborting; - } else + } + else + { return (*LINK->count >= LINK->max); + } } @@ -5796,10 +4607,7 @@ static int abortit(LINK) /*= =*/ /*================================================*/ -static void xorcopybuf(bases, x, y, count_) - baseptrs *bases; - short x, y; - long *count_; +static void xorcopybuf(baseptrs *bases, short x, short y, long *count_) { struct LOC_xorcopybuf V; log_grec *g; @@ -5816,35 +4624,43 @@ static void xorcopybuf(bases, x, y, count_) clipon(); m_colormode((long)m_xor); b = bases->bcopy; - while (b != NULL && !abortit(&V)) { + + while (b != NULL && !abortit(&V)) + { drawboxc0(b->x1 + x, b->y1 + y, b->x2 + x, b->y2 + y, gg.color.select); (*V.count)++; b = b->next; } m_color((long)gg.color.select); hw = bases->hwcopy; - while (hw != NULL && !abortit(&V)) { + + while (hw != NULL && !abortit(&V)) + { hline(hw->x1 + x, hw->x2 + x, hw->y + y); (*V.count)++; hw = hw->next; } vw = bases->vwcopy; - while (vw != NULL && !abortit(&V)) { + + while (vw != NULL && !abortit(&V)) + { vline(vw->x + x, vw->y1 + y, vw->y2 + y); (*V.count)++; vw = vw->next; } g = bases->gcopy; - while (g != NULL && !abortit(&V)) { + + while (g != NULL && !abortit(&V)) + { drawgatec(g->x + x, g->y + y, g->g, gg.color.select); (*V.count)++; g = g->next; } m_color((long)gg.color.select); l = bases->lcopy; - while (l != NULL && !abortit(&V)) { - /* p2c: log.text, line 9887: - * Warning: Symbol 'LOGFONT_LFONT' is not defined [221] */ + + while (l != NULL && !abortit(&V)) + { m_drawstr((l->x + x) * gg.scale - gg.xoff, (l->y + y) * gg.scale - gg.yoff + 2, logfont_lfont, l->name); (*V.count)++; @@ -5862,9 +4678,7 @@ static void xorcopybuf(bases, x, y, count_) /*= =*/ /*================================================*/ -static void pastebuf(bases, x, y) - baseptrs *bases; - short x, y; +static void pastebuf(baseptrs *bases, short x, short y) { log_grec *g, *g1; log_hwrec *hw; @@ -5875,13 +4689,17 @@ static void pastebuf(bases, x, y) clipon(); g = bases->gcopy; - while (g != NULL) { + while (g != NULL) + { copygate(g, &g1); g1->x = g->x + x; g1->y = g->y + y; if (connectgate(g1)) + { drawgatex(g1); - else { + } + else + { frygate(g1); disposegate(&g1); clipon(); @@ -5890,30 +4708,43 @@ static void pastebuf(bases, x, y) } clipoff(); hw = bases->hwcopy; - while (hw != NULL) { + + while (hw != NULL) + { addhwire(hw->x1 + x, hw->x2 + x, hw->y + y, hw->wcolr); hw = hw->next; } vw = bases->vwcopy; - while (vw != NULL) { + + while (vw != NULL) + { addvwire(vw->x + x, vw->y1 + y, vw->y2 + y, vw->wcolr); vw = vw->next; } s = bases->scopy; - while (s != NULL) { + + while (s != NULL) + { closerwire(s->x + x, s->y + y); - if (gg.nearhw != NULL && gg.nearvw != NULL) { - if (trycombinenodes(&gg.nearvw->node, &gg.nearhw->node)) { + if (gg.nearhw != NULL && gg.nearvw != NULL) + { + if (trycombinenodes(&gg.nearvw->node, &gg.nearhw->node)) + { clipon(); addsolder(s->x + x, s->y + y, gg.nearhw, NULL, gg.nearvw, NULL); clipoff(); - } else + } + else + { frysolder(s->x + x, s->y + y); + } } s = s->next; } l = bases->lcopy; - while (l != NULL) { + + while (l != NULL) + { l1 = (log_lrec *)Malloc(sizeof(log_lrec)); l1->next = gg.lbase[gg.curpage - 1]; gg.lbase[gg.curpage - 1] = l1; @@ -5921,14 +4752,11 @@ static void pastebuf(bases, x, y) l1->y = l->y + y; strcpy(l1->name, l->name); l1->w = m_strwidth(logfont_lfont, l1->name) / log_scale0; - /* p2c: log.text, line 9972: - * Warning: Symbol 'LOGFONT_LFONT' is not defined [221] */ l1->temp = (na_long)0; clipon(); m_color((long)gg.color.labeltext); - if (!gg.textinvisible) { - /* p2c: log.text, line 9977: - * Warning: Symbol 'LOGFONT_LFONT' is not defined [221] */ + if (!gg.textinvisible) + { m_drawstr(l1->x * gg.scale - gg.xoff, l1->y * gg.scale - gg.yoff + 2, logfont_lfont, l1->name); } @@ -5938,7 +4766,9 @@ static void pastebuf(bases, x, y) l = l->next; } b = bases->bcopy; - while (b != NULL) { + + while (b != NULL) + { b1 = (log_brec *)Malloc(sizeof(log_brec)); b1->next = gg.bbase[gg.curpage - 1]; gg.bbase[gg.curpage - 1] = b1; @@ -5972,7 +4802,6 @@ static void xororiginal() } - /*================= PASTEOBJECT ================*/ /*= =*/ /*= Enter Paste mode. When cursor is pressed, =*/ @@ -5983,8 +4812,7 @@ static void xororiginal() /*= =*/ /*================================================*/ -static void pastecommand(movemode) - long movemode; +static void pastecommand(long movemode) { short thepage; long max; @@ -6004,19 +4832,24 @@ static void pastecommand(movemode) xororiginal(); waitnear(); xororiginal(); - do { - do { - if (smallbuf) { + do + { + do + { + if (smallbuf) + { pen(); checkabort(); - if (!gg.t.dn) { + if (!gg.t.dn) + { xororiginal(); gg.posx = gg.gridx; gg.posy = gg.gridy; max = LONG_MAX; xorcopybuf(©buf, gg.posx, gg.posy, &max); while (gg.posx == gg.gridx && gg.posy == gg.gridy && !gg.t.dn && - gg.stillnear && *gg.func == '\0') { + gg.stillnear && *gg.func == '\0') + { pass(); trykbd(); pen(); @@ -6024,10 +4857,13 @@ static void pastecommand(movemode) xorcopybuf(©buf, gg.posx, gg.posy, &max); xororiginal(); } - } else { + } + else + { xororiginal(); time = timers_sysclock(); - do { + do + { gg.posx = gg.gridx; gg.posy = gg.gridy; pass(); @@ -6040,12 +4876,14 @@ static void pastecommand(movemode) xororiginal(); scroll(); checkabort(); - if (gg.posx == gg.gridx && gg.posy == gg.gridy && !gg.t.dn) { + if (gg.posx == gg.gridx && gg.posy == gg.gridy && !gg.t.dn) + { xororiginal(); max = LONG_MAX; xorcopybuf(©buf, gg.posx, gg.posy, &max); while (gg.posx == gg.gridx && gg.posy == gg.gridy && !gg.t.dn && - gg.stillnear && *gg.func == '\0') { + gg.stillnear && *gg.func == '\0') + { pass(); trykbd(); pen(); @@ -6058,28 +4896,37 @@ static void pastecommand(movemode) checkabort(); } while (!gg.t.dn); remcursor(); - if (movemode >= 1) { + + if (movemode >= 1) + { if (gg.posx != copybuf.x1copy || gg.posy != copybuf.y1copy || - gg.curpage != copybuf.pgnum) { + gg.curpage != copybuf.pgnum) + { initbuf(&deleted); thepage = gg.curpage; - if (thepage != copybuf.pgnum) { + if (thepage != copybuf.pgnum) + { newpage(copybuf.pgnum); refrscreen1(); } cutcopy(&deleted, copybuf.x1copy, copybuf.y1copy, copybuf.x2copy, copybuf.y2copy, true, false); - if (thepage != copybuf.pgnum) { + if (thepage != copybuf.pgnum) + { newpage(thepage); refrscreen1(); } clearbuf(&deleted); pastebuf(©buf, gg.posx, gg.posy); } + if (movemode == 2) movemode = 0; - } else + } + else + { pastebuf(©buf, gg.posx, gg.posy); + } gg.refrflag = true; } while (movemode != 1); cursortype = normal; @@ -6087,7 +4934,6 @@ static void pastecommand(movemode) } - static void extract() { int okay; @@ -6103,10 +4949,6 @@ static void extract() clearfunc(); } - - - - /*================= COPYCOMMAND ================*/ /*= =*/ /*= Enter Copy mode. =*/ @@ -6122,7 +4964,8 @@ static void copycommand() clearfunc(); cursortype = copy_; waitnear(); - do { + do + { flag = getrectangle(&x1, &y1, &x2, &y2, true); cutcopy(©buf, x1, y1, x2, y2, false, flag); if (!bufempty(©buf)) @@ -6131,9 +4974,6 @@ static void copycommand() } - - - /*================= MOVECOMMAND ================*/ /*= =*/ /*= Enter Move mode. Sweep out an area, then =*/ @@ -6142,8 +4982,7 @@ static void copycommand() /*= =*/ /*================================================*/ -static void movecommand(waitflag) - int waitflag; +static void movecommand(int waitflag) { short x1, y1, x2, y2; int flag; @@ -6153,10 +4992,12 @@ static void movecommand(waitflag) cursortype = copy_; if (waitflag) waitnear(); - do { + do + { flag = getrectangle(&x1, &y1, &x2, &y2, waitflag); cutcopy(©buf, x1, y1, x2, y2, false, flag); - if (!bufempty(©buf)) { + if (!bufempty(©buf)) + { if (waitflag) pastecommand(1L); else @@ -6166,9 +5007,6 @@ static void movecommand(waitflag) _Escape(5); } - - - static void OLDmovecommand() { short x1, y1, oldpg, stillhere; @@ -6179,17 +5017,21 @@ static void OLDmovecommand() clearfunc(); cursortype = copy_; waitnear(); - do { + do + { gg.posx = gg.gridx; gg.posy = gg.gridy; pass(); trykbdscroll(); pen(); } while (!gg.t.dn && gg.stillnear && *gg.func == '\0'); - while (gg.incircuit && gg.stillnear && *gg.func == '\0') { + + while (gg.incircuit && gg.stillnear && *gg.func == '\0') + { x1 = gg.posx; y1 = gg.posy; - do { + do + { pen(); x1 = gg.gridx; y1 = gg.gridy; @@ -6197,12 +5039,14 @@ static void OLDmovecommand() m_color((long)gg.color.select); rect(gg.posx, gg.posy, x1, y1); m_colormode((long)m_normal); - do { + do + { pass(); trykbd(); pen(); } while (gg.gridx == x1 && gg.gridy == y1 && gg.t.depressed && *gg.func == '\0'); + m_colormode((long)m_xor); m_color((long)gg.color.select); rect(gg.posx, gg.posy, x1, y1); @@ -6210,6 +5054,7 @@ static void OLDmovecommand() scroll(); } while ((gg.t.depressed || abs(x1 - gg.posx) < 2 || abs(y1 - gg.posy) < 2) && *gg.func == '\0'); + sortshints(&gg.posx, &x1); sortshints(&gg.posy, &y1); remcursor(); @@ -6230,14 +5075,18 @@ static void OLDmovecommand() rect(buf.x1copy, buf.y1copy, buf.x2copy, buf.y2copy); m_linestyle(0L); clipoff(); - do { + + do + { stillhere = 50; - do { + do + { gg.posx = gg.gridx; gg.posy = gg.gridy; pass(); trykbd(); - if (!strcmp(gg.func, "REFR")) { + if (!strcmp(gg.func, "REFR")) + { scroll(); clipon(); m_color((long)gg.color.dashbox); @@ -6251,14 +5100,17 @@ static void OLDmovecommand() } while (!(gg.posx != gg.gridx || gg.posy != gg.gridy || stillhere < 0 || gg.t.dn) && gg.stillnear && *gg.func == '\0'); + if (gg.posx == gg.gridx && gg.posy == gg.gridy && !gg.t.dn && - gg.stillnear && *gg.func == '\0') { + gg.stillnear && *gg.func == '\0') + { remcursor(); max = LONG_MAX; xorcopybuf(&buf, gg.posx, gg.posy, &max); restorecursor(); while (gg.posx == gg.gridx && gg.posy == gg.gridy && !gg.t.dn && - gg.stillnear && *gg.func == '\0') { + gg.stillnear && *gg.func == '\0') + { pass(); trykbd(); pen(); @@ -6268,11 +5120,13 @@ static void OLDmovecommand() restorecursor(); } } while (!gg.t.dn && gg.stillnear && *gg.func == '\0'); + remcursor(); clipon(); m_color((long)gg.color.backgr); rect(buf.x1copy, buf.y1copy, buf.x2copy, buf.y2copy); clipoff(); + if (gg.incircuit && gg.stillnear && *gg.func == '\0') pastebuf(&buf, gg.posx, gg.posy); clearbuf(&buf); @@ -6280,7 +5134,8 @@ static void OLDmovecommand() } gg.startpoint = false; log_setmode(""); - if (gg.t.dn && !gg.incircuit) { + if (gg.t.dn && !gg.incircuit) + { gg.t.dn = false; gg.t.depressed = false; } @@ -6288,17 +5143,12 @@ static void OLDmovecommand() } -static int near_(x, y) - short x, y; +static int near_(short x, short y) { return (abs(x - y) < 2); } - - - - /*================ MOVEOBJECT ==================*/ /*= =*/ /*= Move a gate, wire, label, or dashed box. =*/ @@ -6320,33 +5170,40 @@ static void moveobject() gg.gridx = gg.posx; gg.gridy = gg.posy; if (gg.markers && ((gg.gridx == gg.markerx1 && gg.gridy == gg.markery1) || - (gg.gridx == gg.markerx2 && gg.gridy == gg.markery2))) { + (gg.gridx == gg.markerx2 && gg.gridy == gg.markery2))) + { remcursor(); drawmarkersc(gg.color.backgr); gg.markers = false; stamp(&gg.markerstamp); - do { + do + { gg.posx = gg.gridx; gg.posy = gg.gridy; m_colormode((long)m_xor); drawmarkersc(gg.color.marker); m_colormode((long)m_normal); - do { + do + { pass(); trykbd(); pen(); } while (gg.gridx == gg.posx && gg.gridy == gg.posy && gg.t.depressed && strcmp(gg.func, "REFR")); + m_colormode((long)m_xor); drawmarkersc(gg.color.marker); m_colormode((long)m_normal); if (gg.posx == gg.markerx1 && gg.posy == gg.markery1 && - gg.gridx < gg.markerx2 && gg.gridy < gg.markery2 && gg.incircuit) { + gg.gridx < gg.markerx2 && gg.gridy < gg.markery2 && gg.incircuit) + { gg.markerx1 = gg.gridx; gg.markery1 = gg.gridy; - } else if (gg.posx == gg.markerx2 && gg.posy == gg.markery2 && + } + else if (gg.posx == gg.markerx2 && gg.posy == gg.markery2 && gg.gridx > gg.markerx1 && gg.gridy > gg.markery1 && - gg.incircuit) { + gg.incircuit) + { gg.markerx2 = gg.gridx; gg.markery2 = gg.gridy; } @@ -6360,7 +5217,9 @@ static void moveobject() gg.startpoint = false; return; } - if (gg.nearlabel != NULL) { + + if (gg.nearlabel != NULL) + { remcursor(); oldx1 = gg.nearlabel->x; oldy1 = gg.nearlabel->y; @@ -6373,14 +5232,16 @@ static void moveobject() clipoff(); x1 = gg.nearlabel->x - gg.posx; y1 = gg.nearlabel->y - gg.posy; - do { + do + { gg.posx = gg.gridx; gg.posy = gg.gridy; oo = gg.t.off; clipon(); xorlabel(gg.posx + x1, gg.posy + y1, gg.nearlabel); clipoff(); - do { + do + { pass(); trykbd(); pen(); @@ -6389,7 +5250,8 @@ static void moveobject() clipon(); xorlabel(gg.posx + x1, gg.posy + y1, gg.nearlabel); clipoff(); - if (!strcmp(gg.func, "REFR")) { + if (!strcmp(gg.func, "REFR")) + { scroll(); clipon(); eralabel(gg.nearlabel); @@ -6398,12 +5260,14 @@ static void moveobject() } while (gg.t.depressed); remcursor(); chpageplace(oldpg, oldx1, oldy1, oldx2, oldy2); - if (gg.incircuit && !oo && !gg.t.off) { + if (gg.incircuit && !oo && !gg.t.off) + { gg.posx += x1; gg.posy += y1; gg.nearlabel->x = gg.posx; gg.nearlabel->y = gg.posy; - if (gg.curpage != oldpg) { + if (gg.curpage != oldpg) + { newpg = gg.curpage; gg.curpage = oldpg; unlinklabel(gg.nearlabel); @@ -6411,15 +5275,15 @@ static void moveobject() linklabel(gg.nearlabel); } m_color((long)gg.color.labeltext); - /* p2c: log.text, line 10502: - * Warning: Symbol 'LOGFONT_LFONT' is not defined [221] */ m_drawstr(gg.posx * gg.scale - gg.xoff, gg.posy * gg.scale - gg.yoff + 2, logfont_lfont, gg.nearlabel->name); gg.refrflag = true; chpageplace((int)gg.curpage, gg.nearlabel->x, gg.nearlabel->y, gg.nearlabel->x + gg.nearlabel->w, gg.nearlabel->y + 2); - } else { + } + else + { newpg = gg.curpage; gg.curpage = oldpg; displabel(&gg.nearlabel); @@ -6430,7 +5294,9 @@ static void moveobject() gg.startpoint = false; return; } - if (gg.nearbox != NULL) { + + if (gg.nearbox != NULL) + { remcursor(); oldx1 = gg.nearbox->x1; oldy1 = gg.nearbox->y1; @@ -6445,7 +5311,8 @@ static void moveobject() hx2 = gg.nearbox->x2; vy1 = gg.nearbox->y1; vy2 = gg.nearbox->y2; - do { + do + { gg.posx = gg.gridx; gg.posy = gg.gridy; oo = gg.t.off; @@ -6454,36 +5321,49 @@ static void moveobject() drawboxc0(hx1, vy1, hx2, vy2, gg.color.dashbox); m_colormode((long)m_normal); clipoff(); - do { + do + { pass(); trykbd(); pen(); } while (gg.gridx == gg.posx && gg.gridy == gg.posy && gg.t.depressed && strcmp(gg.func, "REFR")); + clipon(); m_colormode((long)m_xor); drawboxc0(hx1, vy1, hx2, vy2, gg.color.dashbox); m_colormode((long)m_normal); clipoff(); - if (near_(gg.posx, hx1) && near_(gg.posy, vy1)) { + if (near_(gg.posx, hx1) && near_(gg.posy, vy1)) + { hx1 = gg.gridx; vy1 = gg.gridy; - } else if (near_(gg.posx, hx1) && near_(gg.posy, vy2)) { + } + else if (near_(gg.posx, hx1) && near_(gg.posy, vy2)) + { hx1 = gg.gridx; vy2 = gg.gridy; - } else if (near_(gg.posx, hx2) && near_(gg.posy, vy1)) { + } + else if (near_(gg.posx, hx2) && near_(gg.posy, vy1)) + { hx2 = gg.gridx; vy1 = gg.gridy; - } else if (near_(gg.posx, hx2) && near_(gg.posy, vy2)) { + } + else if (near_(gg.posx, hx2) && near_(gg.posy, vy2)) + { hx2 = gg.gridx; vy2 = gg.gridy; - } else { + } + else + { hx1 += gg.gridx - gg.posx; hx2 += gg.gridx - gg.posx; vy1 += gg.gridy - gg.posy; vy2 += gg.gridy - gg.posy; } - if (!strcmp(gg.func, "REFR")) { + + if (!strcmp(gg.func, "REFR")) + { scroll(); clipon(); drawboxc(gg.nearbox, gg.color.backgr); @@ -6498,8 +5378,10 @@ static void moveobject() gg.nearbox->y1 = vy1; gg.nearbox->y2 = vy2; chpageplace(oldpg, oldx1, oldy1, oldx2, oldy2); - if (gg.incircuit && !oo && !gg.t.off) { - if (gg.curpage != oldpg) { + if (gg.incircuit && !oo && !gg.t.off) + { + if (gg.curpage != oldpg) + { newpg = gg.curpage; gg.curpage = oldpg; unlinkbox(gg.nearbox); @@ -6512,7 +5394,9 @@ static void moveobject() chpageplace((int)gg.curpage, gg.nearbox->x1, gg.nearbox->y1, gg.nearbox->x2, gg.nearbox->y2); gg.refrflag = true; - } else { + } + else + { newpg = gg.curpage; gg.curpage = oldpg; dispbox(&gg.nearbox); @@ -6523,7 +5407,9 @@ static void moveobject() gg.startpoint = false; return; } - if (gg.neargate != NULL) { + + if (gg.neargate != NULL) + { gtype = gg.neargate->g; remcursor(); clipon(); @@ -6532,13 +5418,15 @@ static void moveobject() disconnectgate(gg.neargate); x1 = gg.neargate->x - gg.posx; y1 = gg.neargate->y - gg.posy; - do { + do + { yy = gg.t.y; gg.posx = gg.gridx; gg.posy = gg.gridy; oo = gg.t.off; movexorgate(gg.posx + x1, gg.posy + y1, gtype, gg.neargate->sig, yy); - do { + do + { pass(); trykbd(); pen(); @@ -6548,7 +5436,9 @@ static void moveobject() scroll(); } while (gg.t.depressed); remcursor(); - if (gg.incircuit && !oo && !gg.t.off) { + + if (gg.incircuit && !oo && !gg.t.off) + { gg.posx += x1; gg.posy += y1; gg.neargate->x = gg.posx; @@ -6556,22 +5446,29 @@ static void moveobject() clipon(); drawgatex(gg.neargate); clipoff(); - if (!connectgate(gg.neargate)) { + if (!connectgate(gg.neargate)) + { frygate(gg.neargate); disposegate(&gg.neargate); } gg.refrflag = true; - } else if (gg.t.y >= baseline) { + } + else if (gg.t.y >= baseline) + { changekind(gg.neargate->g, gg.neargate->sig, gg.neargate->attr); disposegate(&gg.neargate); - } else + } + else + { disposegate(&gg.neargate); + } refreshsoon(); gg.startpoint = false; return; } closerwire(gg.posx, gg.posy); - if (gg.nearhw == NULL && gg.nearvw == NULL) { + if (gg.nearhw == NULL && gg.nearvw == NULL) + { gg.startpoint = false; assertfunc("MOVE *"); return; @@ -6579,7 +5476,8 @@ static void moveobject() remcursor(); clipon(); m_color((long)gg.color.backgr); - if (gg.nearhw != NULL) { + if (gg.nearhw != NULL) + { hx1 = gg.nearhw->x1; hx2 = gg.nearhw->x2; hy = gg.nearhw->y; @@ -6589,7 +5487,9 @@ static void moveobject() gg.movinghw = gg.nearhw; hc = gg.nearhw->wcolr; } - if (gg.nearvw != NULL) { + + if (gg.nearvw != NULL) + { vx = gg.nearvw->x; vy1 = gg.nearvw->y1; vy2 = gg.nearvw->y2; @@ -6601,39 +5501,49 @@ static void moveobject() } blbase = NULL; s = gg.sbase[gg.curpage - 1]; - while (s != NULL) { + while (s != NULL) + { if ((gg.nearhw != NULL && (s->hwire == gg.nearhw || s->hwire2 == gg.nearhw)) || - (gg.nearvw != NULL && (s->vwire == gg.nearvw || s->vwire2 == gg.nearvw))) { + (gg.nearvw != NULL && (s->vwire == gg.nearvw || s->vwire2 == gg.nearvw))) + { drawsolderc(s->x, s->y, gg.color.backgr); blp = (blobrec *)Malloc(sizeof(blobrec)); if (s->hwire == gg.nearhw) blp->hw = NULL; else blp->hw = s->hwire; + if (s->vwire == gg.nearvw) blp->vw = NULL; else blp->vw = s->vwire; + blp->next = blbase; blbase = blp; } s = s->next; } clipoff(); - do { + do + { gg.posx = gg.gridx; gg.posy = gg.gridy; oo = gg.t.off; clipon(); m_colormode((long)m_xor); - if (gg.nearhw != NULL) { - if (fh1) { + if (gg.nearhw != NULL) + { + if (fh1) + { hx1 = gg.posx; hy = gg.posy; - } else if (fh2) { + } else if (fh2) + { hx2 = gg.posx; hy = gg.posy; - } else { + } + else + { if (gg.posx < hx1) hx1 = gg.posx; if (gg.posx > hx2) @@ -6643,14 +5553,20 @@ static void moveobject() m_color((long)gg.color.wire[gg.nearhw->wcolr - log_wcol_normal]); hline(hx1, hx2, hy); } - if (gg.nearvw != NULL) { - if (fv1) { + if (gg.nearvw != NULL) + { + if (fv1) + { vy1 = gg.posy; vx = gg.posx; - } else if (fv2) { + } + else if (fv2) + { vy2 = gg.posy; vx = gg.posx; - } else { + } + else + { if (gg.posy < vy1) vy1 = gg.posy; if (gg.posy > vy2) @@ -6662,7 +5578,8 @@ static void moveobject() } m_colormode((long)m_normal); clipoff(); - do { + do + { pass(); trykbd(); pen(); @@ -6670,14 +5587,18 @@ static void moveobject() strcmp(gg.func, "REFR")); clipon(); m_colormode((long)m_xor); - if (gg.nearhw != NULL) { + if (gg.nearhw != NULL) + { m_color((long)gg.color.wire[gg.nearhw->wcolr - log_wcol_normal]); hline(hx1, hx2, hy); } - if (gg.nearvw != NULL) { + + if (gg.nearvw != NULL) + { m_color((long)gg.color.wire[gg.nearvw->wcolr - log_wcol_normal]); vline(vx, vy1, vy2); } + m_colormode((long)m_normal); clipoff(); scroll(); @@ -6688,51 +5609,77 @@ static void moveobject() remcursor(); gg.curpage = oldpg; if (gg.nearhw != NULL) + { delhwire(gg.nearhw); - else { + } + else + { hx1 = 0; hx2 = 0; } + if (gg.nearvw != NULL) + { delvwire(gg.nearvw); - else { + } + else + { vy1 = 0; vy2 = 0; } + gg.curpage = realcurpage; - if (gg.incircuit && !oo && !gg.t.off) { + if (gg.incircuit && !oo && !gg.t.off) + { blp = blbase; - while (blp != NULL) { - if (blp->hw != NULL) { + while (blp != NULL) + { + if (blp->hw != NULL) + { hw1 = gg.hwbase[gg.curpage - 1]; while (hw1 != NULL && (hw1->node != blp->hw->node || !P_ibetween((long)hw1->x1, (long)vx, (long)hw1->x2) || !P_ibetween((long)vy1, (long)hw1->y, (long)vy2))) hw1 = hw1->next; - if (hw1 != NULL) { + + if (hw1 != NULL) + { blp->x = vx; blp->y = hw1->y; - } else + } + else + { blp->x = -32768L; - } else if (blp->vw != NULL) { + } + } + else if (blp->vw != NULL) + { vw1 = gg.vwbase[gg.curpage - 1]; while (vw1 != NULL && (vw1->node != blp->vw->node || !P_ibetween((long)vw1->y1, (long)hy, (long)vw1->y2) || !P_ibetween((long)hx1, (long)vw1->x, (long)hx2))) vw1 = vw1->next; - if (vw1 != NULL) { + + if (vw1 != NULL) + { blp->x = vw1->x; blp->y = hy; - } else + } + else + { blp->x = -32768L; - } else { + } + } + else + { blp->x = vx; blp->y = hy; } blp = blp->next; } + if (hx1 != hx2) addhwire(hx1, hx2, hy, hc); if (vy1 != vy2) @@ -6748,14 +5695,7 @@ static void moveobject() } - - - - - -static void shiftgate(g, dx, dy) - log_grec *g; - short dx, dy; +static void shiftgate(log_grec *g, short dx, short dy) { short i, FORLIM; log_pinposrec *WITH; @@ -6763,7 +5703,8 @@ static void shiftgate(g, dx, dy) g->x += dx; g->y += dy; FORLIM = g->kind->numpins; - for (i = 0; i < FORLIM; i++) { + for (i = 0; i < FORLIM; i++) + { WITH = &g->pinpos[i]; WITH->x += dx; WITH->y += dy; @@ -6771,8 +5712,7 @@ static void shiftgate(g, dx, dy) } -static void xorrect(x1, y1, x2, y2) - short x1, y1, x2, y2; +static void xorrect(short x1, short y1, short x2, short y2) { short y3; @@ -6789,10 +5729,6 @@ static void xorrect(x1, y1, x2, y2) } - - - - /*================== OPENHORIZ =================*/ /*= =*/ /*= Open space horizontally. =*/ @@ -6814,23 +5750,29 @@ static void openhoriz() clearfunc(); cursortype = copy_; waitnear(); - do { - do { + do + { + do + { gg.posx = gg.gridx; gg.posy = gg.gridy; pass(); trykbdscroll(); pen(); } while (!gg.t.dn && gg.stillnear && *gg.func == '\0'); - if (gg.incircuit && gg.stillnear && *gg.func == '\0') { + + if (gg.incircuit && gg.stillnear && *gg.func == '\0') + { x1 = gg.posx; y1 = gg.posy; - do { + do + { pen(); x1 = gg.gridx; y1 = gg.gridy; xorrect(gg.posx, gg.posy, x1, y1); - do { + do + { pass(); trykbd(); pen(); @@ -6843,34 +5785,45 @@ static void openhoriz() sortshints(&gg.posx, &x1); sortshints(&gg.posy, &y1); remcursor(); - if (gg.incircuit && *gg.func == '\0') { + + if (gg.incircuit && *gg.func == '\0') + { chpage((int)gg.curpage); vw = gg.vwbase[gg.curpage - 1]; flag = false; - while (vw != NULL) { + while (vw != NULL) + { if (vw->x > gg.posx && ((vw->y1 < gg.posy && gg.posy < vw->y2) || (vw->y1 < y1 && y1 < vw->y2))) flag = true; vw = vw->next; } - if (!flag) { + + if (!flag) + { g = gg.gbase[gg.curpage - 1]; - while (g != NULL) { + while (g != NULL) + { if (gg.posy <= g->y && g->y <= y1 && g->x >= gg.posx) shiftgate(g, x1 - gg.posx, 0); g = g->next; } s = gg.sbase[gg.curpage - 1]; - while (s != NULL) { + + while (s != NULL) + { if (!vlsi && gg.posy <= s->vwire->y2 && s->vwire->y1 <= y1 && s->vwire->x > gg.posx) s->x += x1 - gg.posx; s = s->next; } hw = gg.hwbase[gg.curpage - 1]; - while (hw != NULL) { - if (gg.posy <= hw->y && hw->y <= y1) { + + while (hw != NULL) + { + if (gg.posy <= hw->y && hw->y <= y1) + { if (hw->x1 > gg.posx) hw->x1 += x1 - gg.posx; if (hw->x2 >= gg.posx) @@ -6879,14 +5832,19 @@ static void openhoriz() hw = hw->next; } vw = gg.vwbase[gg.curpage - 1]; - while (vw != NULL) { + + while (vw != NULL) + { if (gg.posy <= vw->y2 && vw->y1 <= y1 && vw->x > gg.posx) vw->x += x1 - gg.posx; vw = vw->next; } b = gg.bbase[gg.curpage - 1]; - while (b != NULL) { - if (gg.posy <= b->y1 && b->y2 <= y1) { + + while (b != NULL) + { + if (gg.posy <= b->y1 && b->y2 <= y1) + { if (b->x1 >= gg.posx) b->x1 += x1 - gg.posx; if (b->x2 >= gg.posx) @@ -6895,14 +5853,18 @@ static void openhoriz() b = b->next; } l = gg.lbase[gg.curpage - 1]; - while (l != NULL) { + + while (l != NULL) + { if (gg.posy <= l->y && l->y <= y1 && l->x >= gg.posx) l->x += x1 - gg.posx; l = l->next; } refrfunc(); scroll(); - } else { + } + else + { beginerror(); printf("Can't Open: Blocked by vertical wires\n"); enderror(); @@ -6912,7 +5874,8 @@ static void openhoriz() } while (gg.incircuit && gg.stillnear && *gg.func == '\0'); gg.startpoint = false; log_setmode(""); - if (gg.t.dn && !gg.incircuit) { + if (gg.t.dn && !gg.incircuit) + { gg.t.dn = false; gg.t.depressed = false; } @@ -6920,8 +5883,7 @@ static void openhoriz() } -static void xorrect_(x1, y1, x2, y2) - short x1, y1, x2, y2; +static void xorrect_(short x1, short y1, short x2, short y2) { short x3; @@ -6938,7 +5900,6 @@ static void xorrect_(x1, y1, x2, y2) } - /*================== OPENVERT ==================*/ /*= =*/ /*= Open space vertically. =*/ @@ -6960,22 +5921,28 @@ static void openvert() clearfunc(); cursortype = copy_; waitnear(); - do { - do { + do + { + do + { gg.posx = gg.gridx; gg.posy = gg.gridy; pass(); trykbdscroll(); pen(); } while (!gg.t.dn && gg.stillnear && *gg.func == '\0'); - if (gg.incircuit && gg.stillnear && *gg.func == '\0') { + + if (gg.incircuit && gg.stillnear && *gg.func == '\0') + { x1 = gg.posx; y1 = gg.posy; - do { + do + { x1 = gg.gridx; y1 = gg.gridy; xorrect_(gg.posx, gg.posy, x1, y1); - do { + do + { pass(); trykbd(); pen(); @@ -6988,34 +5955,45 @@ static void openvert() sortshints(&gg.posx, &x1); sortshints(&gg.posy, &y1); remcursor(); - if (gg.incircuit && *gg.func == '\0') { + if (gg.incircuit && *gg.func == '\0') + { chpage((int)gg.curpage); hw = gg.hwbase[gg.curpage - 1]; flag = false; - while (hw != NULL) { + + while (hw != NULL) + { if (hw->y > gg.posy && ((hw->x1 < gg.posx && gg.posx < hw->x2) || (hw->x1 < x1 && x1 < hw->x2))) flag = true; hw = hw->next; } - if (!flag) { + + if (!flag) + { g = gg.gbase[gg.curpage - 1]; - while (g != NULL) { + while (g != NULL) + { if (gg.posx <= g->x && g->x <= x1 && g->y >= gg.posy) shiftgate(g, 0, y1 - gg.posy); g = g->next; } s = gg.sbase[gg.curpage - 1]; - while (s != NULL) { + + while (s != NULL) + { if (!vlsi && gg.posx <= s->hwire->x2 && s->hwire->x1 <= x1 && s->hwire->y > gg.posy) s->y += y1 - gg.posy; s = s->next; } vw = gg.vwbase[gg.curpage - 1]; - while (vw != NULL) { - if (gg.posx <= vw->x && vw->x <= x1) { + + while (vw != NULL) + { + if (gg.posx <= vw->x && vw->x <= x1) + { if (vw->y1 > gg.posy) vw->y1 += y1 - gg.posy; if (vw->y2 >= gg.posy) @@ -7024,14 +6002,19 @@ static void openvert() vw = vw->next; } hw = gg.hwbase[gg.curpage - 1]; - while (hw != NULL) { + + while (hw != NULL) + { if (gg.posx <= hw->x2 && hw->x1 <= x1 && hw->y > gg.posy) hw->y += y1 - gg.posy; hw = hw->next; } + b = gg.bbase[gg.curpage - 1]; - while (b != NULL) { - if (gg.posx <= b->x1 && b->x2 <= x1) { + while (b != NULL) + { + if (gg.posx <= b->x1 && b->x2 <= x1) + { if (b->y1 >= gg.posy) b->y1 += y1 - gg.posy; if (b->y2 >= gg.posy) @@ -7040,14 +6023,17 @@ static void openvert() b = b->next; } l = gg.lbase[gg.curpage - 1]; - while (l != NULL) { + while (l != NULL) + { if (gg.posx <= l->x && l->x <= x1 && l->y >= gg.posy) l->y += y1 - gg.posy; l = l->next; } refrfunc(); scroll(); - } else { + } + else + { beginerror(); printf("Can't Open: Blocked by horizontal wires\n"); enderror(); @@ -7057,16 +6043,15 @@ static void openvert() } while (gg.incircuit && gg.stillnear && *gg.func == '\0'); gg.startpoint = false; log_setmode(""); - if (gg.t.dn && !gg.incircuit) { + if (gg.t.dn && !gg.incircuit) + { gg.t.dn = false; gg.t.depressed = false; } cursortype = normal; } - -static void xorrect__(x1, y1, x2, y2) - short x1, y1, x2, y2; +static void xorrect__(short x1, short y1, short x2, short y2) { short y3; @@ -7083,7 +6068,6 @@ static void xorrect__(x1, y1, x2, y2) } - /*================== CLOSEHORIZ ================*/ /*= =*/ /*= Close space horizontally. =*/ @@ -7105,22 +6089,28 @@ static void closehoriz() clearfunc(); cursortype = copy_; waitnear(); - do { - do { + do + { + do + { gg.posx = gg.gridx; gg.posy = gg.gridy; pass(); trykbdscroll(); pen(); } while (!gg.t.dn && gg.stillnear && *gg.func == '\0'); - if (gg.incircuit && gg.stillnear && *gg.func == '\0') { + + if (gg.incircuit && gg.stillnear && *gg.func == '\0') + { x1 = gg.posx; y1 = gg.posy; - do { + do + { x1 = gg.gridx; y1 = gg.gridy; xorrect__(gg.posx, gg.posy, x1, y1); - do { + do + { pass(); trykbd(); pen(); @@ -7133,22 +6123,28 @@ static void closehoriz() sortshints(&gg.posx, &x1); sortshints(&gg.posy, &y1); remcursor(); - if (gg.incircuit && *gg.func == '\0') { + if (gg.incircuit && *gg.func == '\0') + { chpage((int)gg.curpage); vw = gg.vwbase[gg.curpage - 1]; flag = false; - while (vw != NULL) { + while (vw != NULL) + { if (vw->x >= gg.posx && ((vw->y1 < gg.posy && gg.posy < vw->y2) || (vw->y1 < y1 && y1 < vw->y2))) flag = true; vw = vw->next; } - if (!flag) { + + if (!flag) + { g = gg.gbase[gg.curpage - 1]; - while (g != NULL) { + while (g != NULL) + { g1 = g->next; - if (gg.posy <= g->y && g->y <= y1 && g->x >= gg.posx) { + if (gg.posy <= g->y && g->y <= y1 && g->x >= gg.posx) + { if (g->x <= x1) delgate(g); else @@ -7157,17 +6153,22 @@ static void closehoriz() g = g1; } s = gg.sbase[gg.curpage - 1]; - while (s != NULL) { + + while (s != NULL) + { s1 = s->next; if (!vlsi && gg.posy <= s->vwire->y2 && s->vwire->y1 <= y1 && - s->vwire->x >= gg.posx) { + s->vwire->x >= gg.posx) + { if (s->vwire->x > x1) s->x += gg.posx - x1; } s = s1; } hw = gg.hwbase[gg.curpage - 1]; - while (hw != NULL) { + + while (hw != NULL) + { hw1 = hw->next; if (gg.posy <= hw->y && hw->y <= y1 && hw->x2 >= gg.posx) { if (hw->x1 >= gg.posx && hw->x2 < x1) @@ -7176,7 +6177,9 @@ static void closehoriz() hw = hw1; } vw = gg.vwbase[gg.curpage - 1]; - while (vw != NULL) { + + while (vw != NULL) + { vw1 = vw->next; if (gg.posy <= vw->y2 && vw->y1 <= y1 && vw->x >= gg.posx && vw->x <= x1) @@ -7184,53 +6187,84 @@ static void closehoriz() vw = vw1; } hw = gg.hwbase[gg.curpage - 1]; - while (hw != NULL) { - if (gg.posy <= hw->y && hw->y <= y1 && hw->x2 >= gg.posx) { - if (hw->x1 >= gg.posx) { + + while (hw != NULL) + { + if (gg.posy <= hw->y && hw->y <= y1 && hw->x2 >= gg.posx) + { + if (hw->x1 >= gg.posx) + { if (hw->x1 < x1) + { hw->x1 = gg.posx; - else { + } + else + { hw->x1 += gg.posx - x1; hw->x2 += gg.posx - x1; } - } else if (hw->x2 >= x1) + } + else if (hw->x2 >= x1) + { hw->x2 += gg.posx - x1; + } else if (hw->x2 >= gg.posx) + { hw->x2 = gg.posx; + } } hw = hw->next; } vw = gg.vwbase[gg.curpage - 1]; - while (vw != NULL) { + + while (vw != NULL) + { if (gg.posy <= vw->y2 && vw->y1 <= y1 && vw->x >= gg.posx) vw->x += gg.posx - x1; vw = vw->next; } b = gg.bbase[gg.curpage - 1]; - while (b != NULL) { + + while (b != NULL) + { b1 = b->next; - if (gg.posy <= b->y1 && b->y2 <= y1) { - if (b->x1 >= x1) { + if (gg.posy <= b->y1 && b->y2 <= y1) + { + if (b->x1 >= x1) + { b->x1 += gg.posx - x1; b->x2 += gg.posx - x1; - } else if (b->x1 >= gg.posx) { + } + else if (b->x1 >= gg.posx) + { if (b->x2 < x1) + { dispbox(&b); - else { + } + else + { b->x1 = gg.posx; b->x2 += gg.posx - x1; } - } else if (b->x2 >= x1) + } + else if (b->x2 >= x1) + { b->x2 += gg.posx - x1; + } else if (b->x2 >= gg.posx) + { b->x2 = gg.posx; + } } b = b1; } l = gg.lbase[gg.curpage - 1]; - while (l != NULL) { + + while (l != NULL) + { l1 = l->next; - if (gg.posy <= l->y && l->y <= y1 && l->x >= gg.posx) { + if (gg.posy <= l->y && l->y <= y1 && l->x >= gg.posx) + { if (l->x + strlen(gg.nearlabel->name) * 7 / gg.scale <= x1) displabel(&l); else @@ -7240,7 +6274,9 @@ static void closehoriz() } refrfunc(); scroll(); - } else { + } + else + { beginerror(); printf("Can't Close: Blocked by vertical wires\n"); enderror(); @@ -7250,7 +6286,8 @@ static void closehoriz() } while (gg.incircuit && gg.stillnear && *gg.func == '\0'); gg.startpoint = false; log_setmode(""); - if (gg.t.dn && !gg.incircuit) { + if (gg.t.dn && !gg.incircuit) + { gg.t.dn = false; gg.t.depressed = false; } @@ -7258,8 +6295,7 @@ static void closehoriz() } -static void xorrect___(x1, y1, x2, y2) - short x1, y1, x2, y2; +static void xorrect___(short x1, short y1, short x2, short y2) { short x3; @@ -7276,7 +6312,6 @@ static void xorrect___(x1, y1, x2, y2) } - /*================== CLOSEVERT =================*/ /*= =*/ /*= Close space vertically. =*/ @@ -7298,22 +6333,28 @@ static void closevert() clearfunc(); cursortype = copy_; waitnear(); - do { - do { + do + { + do + { gg.posx = gg.gridx; gg.posy = gg.gridy; pass(); trykbdscroll(); pen(); } while (!gg.t.dn && gg.stillnear && *gg.func == '\0'); - if (gg.incircuit && gg.stillnear && *gg.func == '\0') { + + if (gg.incircuit && gg.stillnear && *gg.func == '\0') + { x1 = gg.posx; y1 = gg.posy; - do { + do + { x1 = gg.gridx; y1 = gg.gridy; xorrect___(gg.posx, gg.posy, x1, y1); - do { + do + { pass(); trykbd(); pen(); @@ -7326,22 +6367,28 @@ static void closevert() sortshints(&gg.posx, &x1); sortshints(&gg.posy, &y1); remcursor(); - if (gg.incircuit && *gg.func == '\0') { + if (gg.incircuit && *gg.func == '\0') + { chpage((int)gg.curpage); hw = gg.hwbase[gg.curpage - 1]; flag = false; - while (hw != NULL) { + while (hw != NULL) + { if (hw->y >= gg.posy && ((hw->x1 < gg.posx && gg.posx < hw->x2) || (hw->x1 < x1 && x1 < hw->x2))) flag = true; hw = hw->next; } - if (!flag) { + + if (!flag) + { g = gg.gbase[gg.curpage - 1]; - while (g != NULL) { + while (g != NULL) + { g1 = g->next; - if (gg.posx <= g->x && g->x <= x1 && g->y >= gg.posy) { + if (gg.posx <= g->x && g->x <= x1 && g->y >= gg.posy) + { if (g->y <= y1) delgate(g); else @@ -7350,26 +6397,34 @@ static void closevert() g = g1; } s = gg.sbase[gg.curpage - 1]; - while (s != NULL) { + + while (s != NULL) + { s1 = s->next; if (!vlsi && gg.posx <= s->hwire->x2 && s->hwire->x1 <= x1 && - s->hwire->y >= gg.posy) { + s->hwire->y >= gg.posy) + { if (s->hwire->y > y1) s->y += gg.posy - y1; } s = s1; } vw = gg.vwbase[gg.curpage - 1]; - while (vw != NULL) { + + while (vw != NULL) + { vw1 = vw->next; - if (gg.posx <= vw->x && vw->x <= x1 && vw->y2 >= gg.posy) { + if (gg.posx <= vw->x && vw->x <= x1 && vw->y2 >= gg.posy) + { if (vw->y1 >= gg.posy && vw->y2 < y1) delvwire(vw); } vw = vw1; } hw = gg.hwbase[gg.curpage - 1]; - while (hw != NULL) { + + while (hw != NULL) + { hw1 = hw->next; if (gg.posx <= hw->x2 && hw->x1 <= x1 && hw->y >= gg.posy && hw->y <= y1) @@ -7377,54 +6432,85 @@ static void closevert() hw = hw1; } vw = gg.vwbase[gg.curpage - 1]; - while (vw != NULL) { - if (gg.posx <= vw->x && vw->x <= x1 && vw->y2 >= gg.posy) { - if (vw->y1 >= gg.posy) { + + while (vw != NULL) + { + if (gg.posx <= vw->x && vw->x <= x1 && vw->y2 >= gg.posy) + { + if (vw->y1 >= gg.posy) + { if (vw->y1 < y1) + { vw->y1 = gg.posy; - else { + } + else + { vw->y1 += gg.posy - y1; vw->y2 += gg.posy - y1; } - } else if (vw->y2 >= y1) + } + else if (vw->y2 >= y1) + { vw->y2 += gg.posy - y1; + } else if (vw->y2 >= gg.posy) + { vw->y2 = gg.posy; + } } vw = vw->next; } hw = gg.hwbase[gg.curpage - 1]; - while (hw != NULL) { + + while (hw != NULL) + { if (gg.posx <= hw->x2 && hw->x1 <= x1 && hw->y >= gg.posy) hw->y += gg.posy - y1; hw = hw->next; } b = gg.bbase[gg.curpage - 1]; - while (b != NULL) { + + while (b != NULL) + { b1 = b->next; - if (gg.posx <= b->x1 && b->x2 <= x1) { - if (b->y1 >= y1) { + if (gg.posx <= b->x1 && b->x2 <= x1) + { + if (b->y1 >= y1) + { b->y1 += gg.posy - y1; b->y2 += gg.posy - y1; - } else if (b->y1 >= gg.posy) { + } + else if (b->y1 >= gg.posy) + { if (b->y2 < y1) + { dispbox(&b); - else { + } + else + { b->y1 = gg.posy; b->y2 += gg.posy - y1; } - } else if (b->y2 >= y1) + } + else if (b->y2 >= y1) + { b->y2 += gg.posy - y1; + } else if (b->y2 >= gg.posy) + { b->y2 = gg.posy; + } } b = b1; } l = gg.lbase[gg.curpage - 1]; - while (l != NULL) { + + while (l != NULL) + { l1 = l->next; if (gg.posx <= l->x && l->y >= gg.posy && - l->x + strlen(gg.nearlabel->name) * 7 / gg.scale <= x1) { + l->x + strlen(gg.nearlabel->name) * 7 / gg.scale <= x1) + { if (l->y <= y1) displabel(&l); else @@ -7434,7 +6520,9 @@ static void closevert() } refrfunc(); scroll(); - } else { + } + else + { beginerror(); printf("Can't Close: Blocked by horizontal wires\n"); enderror(); @@ -7444,7 +6532,8 @@ static void closevert() } while (gg.incircuit && gg.stillnear && *gg.func == '\0'); gg.startpoint = false; log_setmode(""); - if (gg.t.dn && !gg.incircuit) { + if (gg.t.dn && !gg.incircuit) + { gg.t.dn = false; gg.t.depressed = false; } @@ -7462,42 +6551,54 @@ static void centercommand() log_brec *b; short dx, dy, x1, y1, x2, y2; - if (pagembb((int)gg.curpage, &x1, &y1, &x2, &y2)) { + if (pagembb((int)gg.curpage, &x1, &y1, &x2, &y2)) + { dx = (origin + across / 2) / log_scale0 - (x2 + x1) / 2; dy = (origin + baseline / 2) / log_scale0 - (y2 + y1) / 2; g = gg.gbase[gg.curpage - 1]; - while (g != NULL) { + while (g != NULL) + { shiftgate(g, dx, dy); g = g->next; } hw = gg.hwbase[gg.curpage - 1]; - while (hw != NULL) { + + while (hw != NULL) + { hw->x1 += dx; hw->x2 += dx; hw->y += dy; hw = hw->next; } vw = gg.vwbase[gg.curpage - 1]; - while (vw != NULL) { + + while (vw != NULL) + { vw->x += dx; vw->y1 += dy; vw->y2 += dy; vw = vw->next; } s = gg.sbase[gg.curpage - 1]; - while (s != NULL) { + + while (s != NULL) + { s->x += dx; s->y += dy; s = s->next; } l = gg.lbase[gg.curpage - 1]; - while (l != NULL) { + + while (l != NULL) + { l->x += dx; l->y += dy; l = l->next; } b = gg.bbase[gg.curpage - 1]; - while (b != NULL) { + + while (b != NULL) + { b->x1 += dx; b->x2 += dx; b->y1 += dy; @@ -7523,10 +6624,7 @@ static void centercommand() /*= =*/ /*================================================*/ -static int comparestr(s_, g, t_) - char *s_; - short g; - char *t_; +static int comparestr(char *s_, short g, char *t_) { int Result; char s[9], t[9]; @@ -7538,33 +6636,46 @@ static int comparestr(s_, g, t_) strcpy(s, s_); strcpy(t, t_); if (*t == '\0' || !strcmp(s, t)) + { return (strcmp(s, t) == 0); - else { + } + else + { ch = t[0]; - if (ch == '*' || ch == '?' || ch == '=') { + if (ch == '*' || ch == '?' || ch == '=') + { strcpy_overlap(t, t + 1); - do { + do + { match = comparestr(s, g, t); if (!match && *s != '\0') strcpy_overlap(s, s + 1); } while (!(match || *s == '\0')); return (match || comparestr(s, g, t)); - } else if (ch == ';') { + } + else if (ch == ';') + { Result = false; if (*s != '\0') return Result; FORLIM = strlen(t); - for (i = 1; i < FORLIM; i++) { + for (i = 1; i < FORLIM; i++) + { if (t[i] == g + 48) Result = true; } return Result; - } else if (*s != '\0' && (ch == '%' || ch == s[0])) { + } + else if (*s != '\0' && (ch == '%' || ch == s[0])) + { strcpy_overlap(s, s + 1); strcpy_overlap(t, t + 1); return (comparestr(s, g, t)); - } else + } + else + { return false; + } } return Result; } @@ -7579,21 +6690,21 @@ struct LOC_readlibrary_at { long dist; } ; -static void readint(LINK) - struct LOC_readlibrary_at *LINK; +static void readint(struct LOC_readlibrary_at *LINK) { - if (LINK->p >= 64) { + if (LINK->p >= 64) + { GET(libf1[LINK->f - 1]->f, filerec); LINK->p = 0; } } -static long readnum(LINK) - struct LOC_readlibrary_at *LINK; +static long readnum(struct LOC_readlibrary_at *LINK) { long Result; - if (LINK->p >= 256) { + if (LINK->p >= 256) + { GET(libf1[LINK->f - 1]->f, filerec); LINK->p = 0; } @@ -7603,8 +6714,7 @@ static long readnum(LINK) return Result; } -static long readcoord(LINK) - struct LOC_readlibrary_at *LINK; +static long readcoord(struct LOC_readlibrary_at *LINK) { long i; @@ -7617,10 +6727,7 @@ static long readcoord(LINK) return (i - 256); } -static void bound(k, x, y, LINK) - log_krec *k; - long x, y; - struct LOC_readlibrary_at *LINK; +static void bound(log_krec *k, long x, long y, struct LOC_readlibrary_at *LINK) { if (x < k->bbx1) k->bbx1 = x; @@ -7632,9 +6739,7 @@ static void bound(k, x, y, LINK) k->bby2 = y; } -static long uncompress(i, LINK) - long i; - struct LOC_readlibrary_at *LINK; +static long uncompress(long i, struct LOC_readlibrary_at *LINK) { if (i < 0) i += 256; @@ -7645,8 +6750,7 @@ static long uncompress(i, LINK) } -static descrec *readdesc(rec) - char *rec; +static descrec *readdesc(char *rec) { unsigned short i,j1,j2,s1,s2; static descrec d; @@ -7672,8 +6776,7 @@ static descrec *readdesc(rec) } -static log_pnumrec readpnum(rec) - char *rec; +static log_pnumrec readpnum(char *rec) { static log_pnumrec p; @@ -7693,10 +6796,7 @@ static log_pnumrec readpnum(rec) /*= =*/ /*================================================*/ -static short readlibrary_at(n_, where, loadit) - char *n_; - short where; - int loadit; +static short readlibrary_at(char *n_, short where, int loadit) { struct LOC_readlibrary_at V; short Result; @@ -7723,41 +6823,54 @@ static short readlibrary_at(n_, where, loadit) found = false; count = 0; FORLIM = idxsize; - for (i0 = 1; i0 <= FORLIM; i0++) { - if (comparestr(index_[i0 - 1], indexgroup[i0 - 1], n)) { + for (i0 = 1; i0 <= FORLIM; i0++) + { + if (comparestr(index_[i0 - 1], indexgroup[i0 - 1], n)) + { found = true; - if (P_getbits_UB(loadedgates, i0 - 1, 0, 3)) { + if (P_getbits_UB(loadedgates, i0 - 1, 0, 3)) + { i = 0; FORLIM1 = maxkinds; - for (j = 1; j <= FORLIM1; j++) { + for (j = 1; j <= FORLIM1; j++) + { if (kind[j - 1] != NULL && kind[j - 1]->code == i0) i = j; } goto _L1; } - if (!loadit) { + + if (!loadit) + { count++; goto _L1; } i = where; while (i <= maxkinds && kind[i - 1] != NULL) i++; - if (i > maxkinds) { + if (i > maxkinds) + { i = 1; while (i <= maxkinds && kind[i - 1] != NULL) i++; } - if (i > maxkinds) { /*garbage collection*/ + + /* garbagge collection */ + if (i > maxkinds) + { i = libptr; - do { + do + { if (i >= maxkinds) i = 0; i++; flag = false; FORLIM1 = gg.numpages; - for (j = 0; j < FORLIM1; j++) { + for (j = 0; j < FORLIM1; j++) + { g = gg.gbase[j]; - while (g != NULL) { + while (g != NULL) + { flag = (flag || (g->g & (log_kindoffset - 1)) == i); g = g->next; } @@ -7766,7 +6879,9 @@ static short readlibrary_at(n_, where, loadit) for (j = 0; j < FORLIM1; j++) flag = (flag || (kindgroup[j] & (log_kindoffset - 1)) == i); } while (flag && i != libptr); - if (flag) { + + if (flag) + { beginerror(); printf("Maximum of %d gate types are in use.\n", maxkinds); enderror(); @@ -7775,9 +6890,8 @@ static short readlibrary_at(n_, where, loadit) } libptr = i; clipoff(); - if (gg.showpage == log_page_cat) { - /* p2c: log.text, line 11958: - * Note: Using % for possibly-negative arguments [317] */ + if (gg.showpage == log_page_cat) + { udrawgatec((int)(((i - 1) % catwidth * 2 + 1) * gridcen), (int)(((i - 1) / catwidth * 2 + 1) * gridcen), i, gg.color.backgr); @@ -7816,12 +6930,15 @@ static short readlibrary_at(n_, where, loadit) kind[i - 1]->numvects = WITH1->numvects; kind[i - 1]->numpins = WITH1->numpins; kind[i - 1]->flag.i = WITH1->flag; - if (kind[i - 1]->flag.U3.expanded) { + if (kind[i - 1]->flag.U3.expanded) + { kind[i - 1]->bigprocsize = uncompress((long)WITH1->procsize, &V); kind[i - 1]->biglblsize = uncompress((long)WITH1->lblsize, &V); kind[i - 1]->numpnums = 0; kind[i - 1]->bigvectsize = uncompress((long)WITH1->numpnums, &V); - } else { + } + else + { kind[i - 1]->bigprocsize = WITH1->procsize * 4; kind[i - 1]->biglblsize = WITH1->lblsize * 4; kind[i - 1]->numpnums = WITH1->numpnums; @@ -7852,8 +6969,11 @@ static short readlibrary_at(n_, where, loadit) WITH->bby2 = log_scale0; bound(kind[i - 1], (long)WITH->x1, (long)WITH->y1, &V); bound(kind[i - 1], (long)WITH->x2, (long)WITH->y2, &V); - if (WITH->numvects != 0) { - if (WITH->flag.U3.expanded) { + + if (WITH->numvects != 0) + { + if (WITH->flag.U3.expanded) + { tempvects = (log_vectorrec *) Malloc(WITH->numvects * sizeof(log_vectorrec) * 2); j = 0; @@ -7861,14 +6981,19 @@ static short readlibrary_at(n_, where, loadit) V.dist = 0; V.p *= 4; FORLIM1 = WITH->numvects; - for (j0 = 1; j0 <= FORLIM1; j0++) { + for (j0 = 1; j0 <= FORLIM1; j0++) + { ch = (char)readnum(&V); - if (ch >= '1' && ch <= '7') { - do { + if (ch >= '1' && ch <= '7') + { + do + { ch2 = ch; ch = (char)readnum(&V); } while (ch >= '1' && ch <= '7'); - if (ch2 != curcol) { + + if (ch2 != curcol) + { j++; tempvects[j - 1].vkind = ch2; tempvects[j - 1].numcoords = 0; @@ -7878,7 +7003,8 @@ static short readlibrary_at(n_, where, loadit) j++; WITH2 = &tempvects[j - 1]; WITH2->vkind = ch; - switch (ch) { + switch (ch) + { case 'v': case 'C': @@ -7955,8 +7081,6 @@ static short readlibrary_at(n_, where, loadit) bound(kind[i - 1], (long)WITH2->x1, (long)WITH2->y1, &V); j000 = readnum(&V); buf[j000] = '\0'; - /* p2c: log.text, line 12128: - * Note: Modification of string length may translate incorrectly [146] */ for (j00 = 0; j00 < j000; j00++) buf[j00] = (char)readnum(&V); WITH2->UU.U116.sp = strdup(buf); @@ -7976,11 +7100,14 @@ static short readlibrary_at(n_, where, loadit) j0 = readnum(&V); V.p /= 4; Free(tempvects); - } else { + } + else + { WITH->vector = (log_vectorrec *) Malloc(WITH->numvects * sizeof(log_vectorrec)); FORLIM1 = WITH->numvects; - for (j = 0; j < FORLIM1; j++) { + for (j = 0; j < FORLIM1; j++) + { readint(&V); WITH->vector[j].vkind = 'v'; WITH->vector[j].numcoords = 2; @@ -7998,12 +7125,15 @@ static short readlibrary_at(n_, where, loadit) } } } - if (WITH->numpins != 0) { + + if (WITH->numpins != 0) + { WITH->pin = (log_pinrec *)Malloc(WITH->numpins * sizeof(log_pinrec)); WITH->pinnames = (na_strlist_t **) Malloc(WITH->numpins * sizeof(na_strlist_t *)); FORLIM1 = WITH->numpins; - for (j = 0; j < FORLIM1; j++) { + for (j = 0; j < FORLIM1; j++) + { readint(&V); WITH->pin[j].x = GETFBUF(libf1[V.f - 1]->f, filerec).pin[V.p].x / log_scale0; @@ -8017,12 +7147,14 @@ static short readlibrary_at(n_, where, loadit) V.p++; } } - /* p2c: log.text, line 12164: Note: Can't interpret size in NA_NEW [174] */ - if (WITH->numpnums != 0) { + + if (WITH->numpnums != 0) + { WITH->pnum = (log_pnumrec *)Malloc(WITH->numpnums * sizeof(log_pnumrec)); FORLIM1 = WITH->numpnums; - for (j = 0; j < FORLIM1; j++) { + for (j = 0; j < FORLIM1; j++) + { readint(&V); WITH->pnum[j] = readpnum((char *) &GETFBUF(libf1[V.f - 1]->f, filerec).b [4*V.p]); @@ -8031,22 +7163,28 @@ static short readlibrary_at(n_, where, loadit) V.p++; } } - /* p2c: log.text, line 12180: Note: Can't interpret size in NA_NEW [174] */ WITH->numattrs = 0; - if (WITH->biglblsize != 0) { + if (WITH->biglblsize != 0) + { strlist_init(&WITH->lbl); *buf = '\0'; ch = '\001'; FORLIM2 = WITH->biglblsize / 4; - for (j1 = 1; j1 <= FORLIM2; j1++) { + for (j1 = 1; j1 <= FORLIM2; j1++) + { readint(&V); - for (j = 0; j <= 3; j++) { - if (ch != '\0') { + for (j = 0; j <= 3; j++) + { + if (ch != '\0') + { ch = GETFBUF(libf1[V.f - 1]->f, filerec).c4[V.p][j]; - if (ch == '\001') { - if (*buf == '\002') { + if (ch == '\001') + { + if (*buf == '\002') + { j0 = 0; - while (*buf != '\0') { + while (*buf != '\0') + { if (buf[0] == '\002') j0++; strcpy_overlap(buf, buf + 1); @@ -8058,7 +7196,8 @@ static short readlibrary_at(n_, where, loadit) j000 = strlen(buf) + 1; j00 = P_imin2((long)j00, (long)j000); if (j00 > 1) { - if (j0 <= WITH->numpins) { + if (j0 <= WITH->numpins) + { sprintf(STR1, "%.*s", j00 - 1, buf); l2 = strlist_append(&WITH->pinnames[j0 - 1], STR1); l2->value = (na_long)((long)j0); @@ -8066,11 +7205,17 @@ static short readlibrary_at(n_, where, loadit) } strcpy_overlap(buf, buf + j00 - 1); } - } else + } + else + { l2 = strlist_append(&WITH->lbl, buf); + } *buf = '\0'; - } else if (ch != '\0') + } + else if (ch != '\0') + { sprintf(buf + strlen(buf), "%c", ch); + } } } V.p++; @@ -8088,7 +7233,9 @@ static short readlibrary_at(n_, where, loadit) filerec).c[V.p * 4 + j0]; V.p++; } - } else { + } + else + { WITH->proc = (uchar *)Malloc(4L); WITH->proc[0] = '\0'; } @@ -8102,10 +7249,15 @@ static short readlibrary_at(n_, where, loadit) P_putbits_UB(loadedgates, i0 - 1, 1, 0, 3); RECOVER(try15); kind[i - 1] = NULL; + if (P_escapecode == -20) + { _Escape(P_escapecode); - else { - if (P_escapecode != 0) { + } + else + { + if (P_escapecode != 0) + { beginerror(); printf("%d/%d/%ld: ", P_escapecode, i, EXCP_LINE); printf("Unable to read file \"%s\"\n", gatesname[V.f - 1]); @@ -8114,11 +7266,11 @@ static short readlibrary_at(n_, where, loadit) i = 0; goto _L1; } + ENDTRY(try15); clipoff(); - if (gg.showpage == log_page_cat) { - /* p2c: log.text, line 12291: - * Note: Using % for possibly-negative arguments [317] */ + if (gg.showpage == log_page_cat) + { udrawgatec((int)(((i - 1) % catwidth * 2 + 1) * gridcen), (int)(((i - 1) / catwidth * 2 + 1) * gridcen), i, gg.color.catgate); @@ -8127,6 +7279,7 @@ _L1: Result = i; } } + if (!loadit) return count; if (found) @@ -8143,24 +7296,19 @@ _L1: #undef maxvars - -static short readlibrary(n) - char *n; +static short readlibrary(char *n) { return (readlibrary_at(n, 1, true)); } -static void getgate(name, gtype) - char *name; - short *gtype; +static void getgate(char *name, short *gtype) { *gtype = readlibrary(name); } -static void getgategroup(grp) - na_strlist_t *grp; +static void getgategroup(na_strlist_t *grp) { na_strlist_t *l1; short pos, i, count; @@ -8169,41 +7317,59 @@ static void getgategroup(grp) l1 = grp; count = 0; - while (l1 != NULL) { + while (l1 != NULL) + { count += readlibrary_at(l1->s, 1, false); l1 = l1->next; } - if (count != 0) { + + if (count != 0) + { if (count > maxkinds) count = maxkinds; pos = 0; - do { + do + { pos++; - if (count > catwidth) { + if (count > catwidth) + { done = ((pos - 1) % catwidth == 0); - /* p2c: log.text, line 12346: - * Note: Using % for possibly-negative arguments [317] */ - } else + } + else + { done = ((pos - 1) / catwidth == (pos + count - 2) / catwidth); - for (i = pos - 1; i <= pos + count - 2; i++) { + } + + for (i = pos - 1; i <= pos + count - 2; i++) + { if (kind[i] != NULL) done = false; } } while (!(done || pos + count > maxkinds)); - if (done) { - if (count <= catwidth) { + + if (done) + { + if (count <= catwidth) + { cb = (catboxrec *)Malloc(sizeof(catboxrec)); cb->pos = pos; cb->count = count; cb->next = catboxes; catboxes = cb; } - } else + } + else + { pos = 1; - } else + } + } + else + { pos = 1; + } l1 = grp; - while (l1 != NULL) { + while (l1 != NULL) + { i = readlibrary_at(l1->s, pos, true); l1 = l1->next; } @@ -8214,26 +7380,20 @@ static void getgategroup(grp) #define nummap "0.,+123-456*789/.()^" - - - - - -static void showpinname(g, i, c, name) - log_grec *g; - short i, c; - char *name; +static void showpinname(log_grec *g, short i, short c, char *name) { short j, j2, x, y, w, y0, y1, y2; int small; char buf[256]; short FORLIM; - if (zoom < 2) { + if (zoom < 2) + { *buf = '\0'; small = true; FORLIM = strlen(name); - for (j = 0; j < FORLIM; j++) { + for (j = 0; j < FORLIM; j++) + { j2 = strposc(nummap, name[j], 1L); if (j2 > 0) sprintf(buf + strlen(buf), "%c", j2 + 127); @@ -8242,13 +7402,20 @@ static void showpinname(g, i, c, name) else small = false; } - } else + } + else + { small = false; - if (small) { + } + + if (small) + { y0 = -5; y1 = -3; y2 = 3; - } else { + } + else + { y0 = -3; y1 = -4; y2 = 4; @@ -8257,16 +7424,11 @@ static void showpinname(g, i, c, name) x = g->pinpos[i - 1].x * gg.scale - gg.xoff; y = g->pinpos[i - 1].y * gg.scale - gg.yoff; w = m_strwidth(logfont_lfont, buf); - /* p2c: log.text, line 12424: - * Warning: Symbol 'LOGFONT_LFONT' is not defined [221] */ m_color((long)c); if (c == gg.color.backgr) m_fillrect(x - w / 2L - 1, (long)(y + y1), x + w / 2L + 1, (long)(y + y2)); - else { - /* p2c: log.text, line 12430: - * Warning: Symbol 'LOGFONT_LFONT' is not defined [221] */ + else m_centerstr((long)x, (long)(y + y0), logfont_lfont, buf); - } } #undef nummap @@ -8279,9 +7441,7 @@ static void showpinname(g, i, c, name) -static void showgateinfo(info, g) - na_strlist_t *info; - log_grec *g; +static void showgateinfo(na_strlist_t *info, log_grec *g) { na_strlist_t *l1; long width, height, i; @@ -8291,10 +7451,9 @@ static void showgateinfo(info, g) width = 10; height = 0; l1 = info; - while (l1 != NULL) { + while (l1 != NULL) + { i = m_strwidth(logfont_lfont, l1->s); - /* p2c: log.text, line 12451: - * Warning: Symbol 'LOGFONT_LFONT' is not defined [221] */ if (i > width) width = i; height += spc; @@ -8303,7 +7462,8 @@ static void showgateinfo(info, g) width += border * 2; height += border * 2 - 1; mx = -1; - if (g != NULL) { + if (g != NULL) + { gx = g->x * gg.scale - gg.xoff; gy = g->y * gg.scale - gg.yoff; z = g->rot; @@ -8330,6 +7490,7 @@ static void showgateinfo(info, g) mx = across - width; else mx = 0; + if (gy2 + ydiff + height < baseline) my = gy2 + ydiff; else if (gy1 - ydiff - height > 0) @@ -8339,7 +7500,8 @@ static void showgateinfo(info, g) else my = 0; - if (false) { + if (false) + { if (gx < across / 3) mx = (gx2 + across - width) / 2; else if (gx > across * 2 / 3 || (gy >= baseline / 3 && gy <= baseline)) @@ -8368,7 +7530,9 @@ static void showgateinfo(info, g) m_drawline((long)gx2, (long)gy2, mx + width, my + height); m_linestyle(0L); } - if (mx < 0) { + + if (mx < 0) + { mx = P_imax2(across * 3L / 5 - width / 2, 0L); my = P_imax2(baseline * 3L / 5 - height / 2, 0L); } @@ -8379,9 +7543,8 @@ static void showgateinfo(info, g) m_color((long)gg.color.selword); y = my + border; l1 = info; - while (l1 != NULL) { - /* p2c: log.text, line 12541: - * Warning: Symbol 'LOGFONT_LFONT' is not defined [221] */ + while (l1 != NULL) + { m_drawstr((long)(mx + border), (long)y, logfont_lfont, l1->s); y += spc; m_color((long)definetextcolor); @@ -8396,23 +7559,24 @@ static void showgateinfo(info, g) #undef border - -static void showgatedef(k, g) - log_krec *k; - log_grec *g; +static void showgatedef(log_krec *k, log_grec *g) { na_strlist_t *l1; char STR1[42]; gg.actstrlist = NULL; - if (g != NULL) { + if (g != NULL) + { send_gengate(g, "DUMPKIND"); gg.actflag = false; send_gengate(g, "SHOWPINS"); } + if (gg.actstrlist == NULL) send_genkind(k, "DUMPKIND"); - if (gg.actstrlist == NULL) { + + if (gg.actstrlist == NULL) + { sprintf(STR1, "No definition available for gate %s", k->name); l1 = strlist_append(&gg.actstrlist, STR1); } @@ -8420,22 +7584,24 @@ static void showgatedef(k, g) } - - static void gatedefinitioncommand() { long i; char STR1[256]; - if (*gg.funcarg == '\0') { + if (*gg.funcarg == '\0') + { clearfunc(); - do { - do { + do + { + do + { beginbottom(); m_alpha_on(); nk_gotoxy(0, txdown - 1); printf("Select a gate to view its simulator definition."); - do { + do + { pass(); trykbd(); pen(); @@ -8444,12 +7610,16 @@ static void gatedefinitioncommand() endbottom(); scroll(); } while (!(gg.t.dn || *gg.func != '\0')); - if (*gg.func == '\0') { + if (*gg.func == '\0') + { closergate(gg.gridx, gg.gridy); if (gg.neargate != NULL) showgatedef(gg.neargate->kind, gg.neargate); - } else + } + else + { gg.neargate = NULL; + } } while (gg.neargate != NULL); return; } @@ -8469,8 +7639,7 @@ static void gatedefinitioncommand() /*= =*/ /*================================================*/ -static char *strreverse(Result, s) - char *Result, *s; +static char *strreverse(char *Result, char *s) { long i; char s2[256]; @@ -8482,8 +7651,7 @@ static char *strreverse(Result, s) } -static librstrrec *findlibrstr(name_) - char *name_; +static librstrrec *findlibrstr(char *name_) { char name[9]; librstrrec *lsp; @@ -8492,7 +7660,8 @@ static librstrrec *findlibrstr(name_) strcpy(name, name_); lsp = librstrs; strcpy(name, strreverse(STR1, name)); - while (lsp != NULL && strcmp(lsp->name, name)) { + while (lsp != NULL && strcmp(lsp->name, name)) + { if (strcmp(name, lsp->name) < 0) lsp = lsp->left; else @@ -8513,28 +7682,36 @@ struct LOC_listlibrary { short karr[maxmaxi + 1][maxmaxj]; } ; -static short kfunc(i, j, LINK) - short *i, *j; - struct LOC_listlibrary *LINK; +static short kfunc(short *i, short *j, struct LOC_listlibrary *LINK) { /* K for Kludge */ *i = (gg.t.ax - 2) / 10; *j = gg.t.ay - 1; if (!gg.t.near_) + { return -1; + } else if (*j <= 0 || (unsigned)(*i) > LINK->maxi) + { return -2; - else if (*j > LINK->maxj) { + } + else if (*j > LINK->maxj) + { if (*i < 1) return -3; else if (*i < 3) return -4; else return -2; - } else if (LINK->karr[*i][*j - 1] == 0) + } + else if (LINK->karr[*i][*j - 1] == 0) + { return (huge_ + *j * 8 + *i); + } else + { return (LINK->karr[*i][*j - 1]); + } } @@ -8552,7 +7729,8 @@ static void listlibrary() V.maxj = P_imin2(txdown - 3L, (long)maxmaxj); nn0 = 1; exitflag = false; - do { + do + { clearshowalpha(); printf("Listing of gates "); if (librgroupnames[curlistgroup] != NULL && @@ -8561,9 +7739,11 @@ static void listlibrary() stdout); else printf("%*c", txacross - 26, ' '); + printf("Group%2d\n", curlistgroup); FORLIM = V.maxi; - for (i = 0; i <= FORLIM; i++) { + for (i = 0; i <= FORLIM; i++) + { FORLIM1 = V.maxj; for (j = 0; j < FORLIM1; j++) V.karr[i][j] = 0; @@ -8571,15 +7751,18 @@ static void listlibrary() i = 0; j = 1; nn = nn0; - do { - if (indexgroup[nn - 1] == curlistgroup) { + do + { + if (indexgroup[nn - 1] == curlistgroup) + { V.karr[i][j - 1] = nn; nk_gotoxy(i * 10 + 2, j + 1); if (P_getbits_UB(loadedgates, nn - 1, 0, 3)) putchar(chryellow); printf("%s%c", index_[nn - 1], chrgreen); j++; - if (j > V.maxj) { + if (j > V.maxj) + { j = 1; i++; } @@ -8588,25 +7771,33 @@ static void listlibrary() } while (i <= V.maxi && nn <= idxsize); nk_gotoxy(0, txdown); printf("+ for next group, - for last group, space bar to quit."); - do { + do + { k = kfunc(&i, &j, &V); lsp = NULL; - if (k > 0) { - if (k < huge_) { + if (k > 0) + { + if (k < huge_) + { lsp = findlibrstr(index_[k - 1]); - if (lsp != NULL) { + if (lsp != NULL) + { nk_gotoxy(0, txdown - 1); printf("%.*s", txacross, lsp->str); } } nk_gotoxy(i * 10 + 2, j + 1); - if (k < huge_) { + if (k < huge_) + { if (P_getbits_UB(loadedgates, k - 1, 0, 3)) putchar(chryellow); printf("%c%s%c%c", chrinverse, index_[k - 1], chrgreen, chrplain); } - } else { - switch (k) { + } + else + { + switch (k) + { case -1: /* blank case */ @@ -8628,18 +7819,25 @@ static void listlibrary() break; } } + if (gg.t.near_ && gg.t.inalpha) nk_gotoxy(gg.t.ax, gg.t.ay); else noblink(); - do { + + do + { pass(); pen(); } while (!(pollkbd2() || gg.t.dn || k != kfunc(&ii, &jj, &V))); + remcursor(); - if (k > 0) { - if (k < huge_) { - if (lsp != NULL) { + if (k > 0) + { + if (k < huge_) + { + if (lsp != NULL) + { nk_gotoxy(0, txdown - 1); putchar('\t'); } @@ -8648,8 +7846,11 @@ static void listlibrary() putchar(chryellow); printf("%s%c", index_[k - 1], chrgreen); } - } else { - switch (k) { + } + else + { + switch (k) + { case -1: /* blank case */ @@ -8675,17 +7876,26 @@ static void listlibrary() ch = '\0'; if (pollkbd2()) ch = inkey2(); - if (gg.t.dn) { + + if (gg.t.dn) + { if (k >= huge_) + { ch = '\003'; - else if (k > 0) { - if (readlibrary(index_[k - 1]) != 0) { + } + else if (k > 0) + { + if (readlibrary(index_[k - 1]) != 0) + { remcursor(); nk_gotoxy(i * 10 + 2, j + 1); printf("%c%s%c", chryellow, index_[k - 1], chrgreen); } - } else { - switch (k) { + } + else + { + switch (k) + { case -1: case -2: @@ -8703,18 +7913,22 @@ static void listlibrary() } } if (ch >= '0' && ch <= '8') + { curlistgroup = ch - 48; - else if (ch == '\b' || ch == '-') { + } + else if (ch == '\b' || ch == '-') + { curlistgroup = (curlistgroup + 8) % 9; - /* p2c: log.text, line 12836: - * Note: Using % for possibly-negative arguments [317] */ - } else if (ch == '\034' || ch == '+') { + } + else if (ch == '\034' || ch == '+') + { curlistgroup = (curlistgroup + 1) % 9; - /* p2c: log.text, line 12838: - * Note: Using % for possibly-negative arguments [317] */ - } else if (ch == '\003' || ch == '\015' || ch == 'Q' || ch == 'q' || + } + else if (ch == '\003' || ch == '\015' || ch == 'Q' || ch == 'q' || (ch & 255) == 171 || ch == ' ') + { exitflag = true; + } } while (!exitflag); clearscreen(); m_graphics_on(); @@ -8726,7 +7940,6 @@ static void listlibrary() #undef huge_ - /*================= GATECATALOG ================*/ /*= =*/ /*= Process CAT menu item. Display catalog, =*/ @@ -8734,8 +7947,7 @@ static void listlibrary() /*= =*/ /*================================================*/ -static void gatecatalog(librmode) - int librmode; +static void gatecatalog(int librmode) { short x, y, x0, y0, x00, y00, w, x1, y1; char nm[9]; @@ -8750,21 +7962,26 @@ static void gatecatalog(librmode) clearfunc(); done = false; - do { + do + { refrflag = false; - if (librmode) { + if (librmode) + { if (ch >= '0' && ch <= '8') curlistgroup = ch - 48; listlibrary(); librmode = false; - } else { + } + else + { showcatalog(); m_color((long)gg.color.selword); drawstr2(10, down - 27, "LIBR"); drawstr2(across - 32, down - 27, "LIBR"); clearalpha(); pen(); - do { + do + { ch = '\0'; x0 = gg.t.x / (gridcen * 2); y0 = gg.t.y / (gridcen * 2); @@ -8774,14 +7991,13 @@ static void gatecatalog(librmode) botflag = false; if ((unsigned)x0 < catwidth && y0 >= 0 && y0 * catwidth + x0 < maxkinds && - gg.t.near_ && kind[y0 * catwidth + x0] != NULL) { + gg.t.near_ && kind[y0 * catwidth + x0] != NULL) + { flag = true; nm[8] = '\0'; k = kind[y0 * catwidth + x0]; strrtrim(strcpy(nm, k->name)); w = m_strwidth(logfont_lfont, nm); - /* p2c: log.text, line 12903: - * Warning: Symbol 'LOGFONT_LFONT' is not defined [221] */ x00 = (x0 * 2 + 1) * gridcen - w / 2; y00 = (y0 + 1) * gridcen * 2 + 2; remcursor(); @@ -8792,14 +8008,15 @@ static void gatecatalog(librmode) m_centerstr((x0*2+1)*gridcen, y00, logfont_lfont, nm);*/ m_colormode((long)m_xor); m_color((long)gg.color.selword); - /* p2c: log.text, line 12914: - * Warning: Symbol 'LOGFONT_LFONT' is not defined [221] */ m_centerstr((x0 * 2L + 1) * gridcen, (long)y00, logfont_lfont, nm); m_colormode((long)m_normal); lp = k->lbl; + while (lp != NULL && lp->kind != '\0') lp = lp->next; - while (lp != NULL && *bot3 == '\0') { + + while (lp != NULL && *bot3 == '\0') + { if (*bot1 == '\0') strcpy(bot1, lp->s); else if (*bot2 == '\0') @@ -8808,23 +8025,34 @@ static void gatecatalog(librmode) strcpy(bot3, lp->s); lp = lp->next; } - if (*bot1 == '\0') { + + if (*bot1 == '\0') + { lsp = findlibrstr(k->name); if (lsp != NULL) strcpy(bot1, lsp->str); } bottime = timers_sysclock(); - } else + } + else + { flag = false; - do { + } + + do + { x = gg.t.x; y = gg.t.y; pass(); pen(); - if (*bot1 != '\0' && !botflag) { + if (*bot1 != '\0' && !botflag) + { if (labs(x - gg.t.x) > 10 || labs(y - gg.t.y) > 10) + { bottime = timers_sysclock(); - else if (timers_sysclock() > bottime + 10) { + } + else if (timers_sysclock() > bottime + 10) + { m_color((long)gg.color.selword); m_centerstr(across / 2L, down - 27L, NULL, bot1); if (*bot2 != '\0') @@ -8839,18 +8067,19 @@ static void gatecatalog(librmode) x1 = gg.t.x / (gridcen * 2); y1 = gg.t.y / (gridcen * 2); } while (!gg.t.dn && gg.t.near_ && x0 == x1 && y0 == y1 && ch == '\0'); - if (flag) { + if (flag) + { remcursor(); /* m_putcpicture(imax(x00-2,0), y00-2, pic); m_disposepicture(pic); */ m_colormode((long)m_xor); m_color((long)gg.color.selword); - /* p2c: log.text, line 12972: - * Warning: Symbol 'LOGFONT_LFONT' is not defined [221] */ m_centerstr((x0 * 2L + 1) * gridcen, (long)y00, logfont_lfont, nm); m_colormode((long)m_normal); m_color((long)gg.color.backgr); - if (botflag) { + + if (botflag) + { m_centerstr(across / 2L, down - 27L, NULL, bot1); if (*bot2 != '\0') m_centerstr(across / 2L, down - 17L, NULL, bot2); @@ -8858,21 +8087,29 @@ static void gatecatalog(librmode) m_centerstr(across / 2L, down - 7L, NULL, bot3); } } - if (gg.t.dn) { + + if (gg.t.dn) + { if ((x < 40 || x >= across - 37) && y >= down - 32) librmode = true; else done = true; } - if (ch == 251 || ch == 250 || ch == ' ') { - /* p2c: log.text, line 12989: Note: Character >= 128 encountered [281] */ - /* p2c: log.text, line 12989: Note: Character >= 128 encountered [281] */ + + if (ch == 251 || ch == 250 || ch == ' ') + { refrflag = true; - } else if (ch == '\003' || ch == 171 || ch == 'Q' || ch == 'q') + } + else if (ch == '\003' || ch == 171 || ch == 'Q' || ch == 'q') + { done = true; + } else if ((ch >= '0' && ch <= '8') || ch == 'L' || ch == 'l') + { librmode = true; - else if (ch == 'D' || ch == 'd') { + } + else if (ch == 'D' || ch == 'd') + { if ((unsigned)x0 < catwidth && y0 >= 0 && y0 * catwidth + x0 < maxkinds && gg.t.near_ && kind[y0 * catwidth + x0] != NULL) @@ -8882,7 +8119,8 @@ static void gatecatalog(librmode) oo = gg.t.off; pen(); pen(); - if (done && gg.t.depressed && !oo && !gg.t.off && flag) { + if (done && gg.t.depressed && !oo && !gg.t.off && flag) + { refrscreen(); addgate(y0 * catwidth + x0 + 1, 0, NULL); } @@ -8891,19 +8129,16 @@ static void gatecatalog(librmode) } - - - /*================== VLSIMODE ==================*/ /*= =*/ /*= Turn VLSI mode on or off. =*/ /*= =*/ /*================================================*/ -static void setvlsimode(flag) - int flag; +static void setvlsimode(int flag) { - if (flag) { + if (flag) + { beginerror(); printf("VLSI mode not supported in version %s\n", log_version); enderror(); @@ -8950,36 +8185,32 @@ $end$*/ } - - /*================== REALSTR ===================*/ /*= =*/ /*= Convert a real number to a string. =*/ /*= =*/ /*================================================*/ -static char *realstr(Result, r, p) - char *Result; - double r; - short p; +static char *realstr(char *Result, double r, short p) { long i, j; char s[81]; s[80] = '\0'; - if ((fabs(r) < 1e-2 || fabs(r) >= 1e6) && r != 0) { + if ((fabs(r) < 1e-2 || fabs(r) >= 1e6) && r != 0) + { sprintf(s, "% .13E", r); i = strlen(s) + 1; s[i - 1] = '\0'; - /* p2c: log.text, line 13092: - * Note: Modification of string length may translate incorrectly [146] */ i = strposc(s, 'E', 1L) - 1; j = strposc(s, '.', 1L); - while (s[i - 1] == '0' || (p != 0 && i > j + p)) { + while (s[i - 1] == '0' || (p != 0 && i > j + p)) + { strcpy_overlap(s + i - 1, s + i); i--; } - if (s[i - 1] == '.') { + if (s[i - 1] == '.') + { strcpy_overlap(s + i - 1, s + i); i--; } @@ -8989,42 +8220,36 @@ static char *realstr(Result, r, p) strcpy_overlap(s + i + 1, s + i + 2); return strcpy(Result, strltrim(s)); } - if (p == 0) { + + if (p == 0) + { sprintf(s, "%30.9f", r); i = strlen(s) + 1; - do { + do + { i--; } while (s[i - 1] == '0'); + if (s[i - 1] == '.') i--; s[i] = '\0'; - /* p2c: log.text, line 13120: - * Note: Modification of string length may translate incorrectly [146] */ return strcpy(Result, strltrim(s)); } sprintf(s, "%25.*f", p, r); i = strlen(s) + 1; s[i - 1] = '\0'; /* zfprintf(stdout, "realstr:%lf p: %d s: %s\n", r, p, s); **MDG** */ - /* p2c: log.text, line 13125: - * Note: Modification of string length may translate incorrectly [146] */ return strcpy(Result, strltrim(s)); } - /*================= REALUNIT ===================*/ /*= =*/ /*= Convert a unitted real number to a string. =*/ /*= =*/ /*================================================*/ -static char *realunit(Result, r, p, u, mu) - char *Result; - double r; - short p; - char *u; - int mu; +static char *realunit(char *Result, double r, short p, char *u, int mu) { char s[81], STR1[81]; char STR2[162]; @@ -9032,61 +8257,73 @@ static char *realunit(Result, r, p, u, mu) /* zfprintf(stdout, "Realunit r: %le\n ", r); ***MDG** */ *s = '\0'; if (r == 0 || fabs(r) >= 1.0e15 || fabs(r) < 1.0e-16) + { *s = '\0'; - else if (fabs(r) >= 1e12) { + } + else if (fabs(r) >= 1e12) + { strcpy(s, "T"); r /= 1e12; - } else if (fabs(r) >= 1e9) { + } + else if (fabs(r) >= 1e9) + { strcpy(s, "G"); r /= 1e9; - } else if (fabs(r) >= 1e6) { + } + else if (fabs(r) >= 1e6) + { strcpy(s, "Meg"); r /= 1e6; - } else if (fabs(r) >= 1e3) { + } + else if (fabs(r) >= 1e3) + { strcpy(s, "K"); r /= 1e3; - } else if (fabs(r) >= 0.1) { + } + else if (fabs(r) >= 0.1) + { *s = '\0'; - } else if (fabs(r) >= 1e-3) { + } + else if (fabs(r) >= 1e-3) + { strcpy(s, "m"); r *= 1e3; - } else if (fabs(r) >= 1e-6) { + } + else if (fabs(r) >= 1e-6) + { strcpy(s, "u"); r *= 1e6; - } else if (fabs(r) >= 1e-9) { + } + else if (fabs(r) >= 1e-9) + { strcpy(s, "n"); r *= 1e9; - } else if (fabs(r) >= 1e-12) { + } + else if (fabs(r) >= 1e-12) + { strcpy(s, "p"); r *= 1e12; - } else { + } + else + { strcpy(s, "f"); r *= 1e15; } + sprintf(s, "%s%s", realstr(STR1, r, p), strcpy(STR2, s)); sprintf(Result, "%s%s", s, u); /* zfprintf(stdout, "realunit Result: %s\n", Result); ***MDG** */ return Result; } -/* was static Void, cause gcc problems in some releases */ - -extern void prealunit(r, p, u, s) - double r; - short p; - char *u; - char *s; +/* was static void, cause gcc problems in some releases */ +extern void prealunit(double r, short p, char *u, char *s) { realunit(s, r, p, u, false); } -/* was static Void, cause gcc problems in some releases */ - -extern void prealunit2(r, p, u, s) - double r; - short p; - char *u; - char *s; +/* was static void, cause gcc problems in some releases */ +extern void prealunit2(double r, short p, char *u, char *s) { realunit(s, r, p, u, true); } @@ -9106,9 +8343,7 @@ struct LOC_editattrs { short acty, p, ybase; } ; -static void drawlabelline(i, LINK) - long i; - struct LOC_editattrs *LINK; +static void drawlabelline(long i, struct LOC_editattrs *LINK) { long j; na_strlist_t *l1; @@ -9118,25 +8353,24 @@ static void drawlabelline(i, LINK) while (l1 != NULL && l1->kind != '\0') l1 = l1->next; FORLIM = i + LINK->ybase; - for (j = 1; j <= FORLIM; j++) { + for (j = 1; j <= FORLIM; j++) + { if (l1 != NULL) l1 = l1->next; } + if (l1 != NULL) nc_putStr(0, (int)i, l1->s); } -static void eraselabelline(i, LINK) - long i; - struct LOC_editattrs *LINK; +static void eraselabelline(longi, struct LOC_editattrs *LINK) { remcursor(); nk_gotoxy(0, (int)i); putchar('\t'); } -static void drawlabel(LINK) - struct LOC_editattrs *LINK; +static void drawlabel(struct LOC_editattrs *LINK) { short i, FORLIM; @@ -9147,10 +8381,7 @@ static void drawlabel(LINK) drawlabelline((long)i, LINK); } -static void drawvalue(i, highlight, LINK) - short i; - int highlight; - struct LOC_editattrs *LINK; +static void drawvalue(short i, int highlight, struct LOC_editattrs *LINK) { na_strlist_t *l1; log_kattrrec *WITH; @@ -9164,11 +8395,11 @@ static void drawvalue(i, highlight, LINK) nk_gotoxy(WITH->x, WITH->y - LINK->ybase); if (highlight) putchar(129); - /* p2c: log.text, line 13282: Note: Character >= 128 encountered [281] */ - /* p2c: log.text, line 13282: * Note: WRITE statement contains color/attribute characters [203] */ - if (!LINK->gattr[i - 1].blnk) { - switch (WITH->dtype) { + if (!LINK->gattr[i - 1].blnk) + { + switch (WITH->dtype) + { case 'R': fputs(realstr(STR1, LINK->gattr[i - 1].UU.r, WITH->prec), stdout); @@ -9203,12 +8434,15 @@ static void drawvalue(i, highlight, LINK) break; case 'B': - if (WITH->prec == 1) { + if (WITH->prec == 1) + { if (LINK->gattr[i - 1].UU.b) printf("Yes"); else printf("No"); - } else { + } + else + { if (LINK->gattr[i - 1].UU.b) printf("True"); else @@ -9231,27 +8465,28 @@ static void drawvalue(i, highlight, LINK) putchar(' '); LINK->gattr[i - 1].x2 = XPOS - 1; /*from CRT*/ /*prob. no longer used*/ - /* p2c: log.text, line 13317: Note: Character >= 128 encountered [281] */ - /* p2c: log.text, line 13317: - * Note: WRITE statement contains color/attribute characters [203] */ printf("\t\200"); LINK->gattr[i - 1].changed = false; } -static void maskvalues(LINK) - struct LOC_editattrs *LINK; +static void maskvalues(struct LOC_editattrs *LINK) { short i, FORLIM; FORLIM = LINK->numattrs; - for (i = 0; i < FORLIM; i++) { + for (i = 0; i < FORLIM; i++) + { if (LINK->kattr[i].vra != 0 && - LINK->kattr[i].vr != LINK->gattr[LINK->kattr[i].vra - 1].UU.nv) { + LINK->kattr[i].vr != LINK->gattr[LINK->kattr[i].vra - 1].UU.nv) + { if (!LINK->gattr[i].supr) eraselabelline((long)LINK->kattr[i].y, LINK); LINK->gattr[i].supr = true; - } else { - if (LINK->gattr[i].supr) { + } + else + { + if (LINK->gattr[i].supr) + { drawlabelline((long)LINK->kattr[i].y, LINK); drawvalue(i + 1, false, LINK); } @@ -9260,32 +8495,32 @@ static void maskvalues(LINK) } } -static double cleanup(r, r1, LINK) - double r, r1; - struct LOC_editattrs *LINK; +static double cleanup(double r, double r1, struct LOC_editattrs *LINK) { long i; char s[81]; char *STR1; if (fabs(r) * 2 < r1) + { return 0.0; - else if (fabs(r) < 1e9 && r >= 1e-5) { + } + else if (fabs(r) < 1e9 && r >= 1e-5) + { sprintf(s, "%20.0f", r / r1); i = strlen(s) + 1; s[i - 1] = '\0'; - /* p2c: log.text, line 13360: - * Note: Modification of string length may translate incorrectly [146] */ r = strtod(s, &STR1); i = STR1 - s + 1; return (r * r1); - } else + } + else + { return r; + } } -static double scrnincr(p, LINK) - short p; - struct LOC_editattrs *LINK; +static double scrnincr(short p, struct LOC_editattrs *LINK) { long i; double r1; @@ -9293,7 +8528,8 @@ static double scrnincr(p, LINK) log_kattrrec *WITH; WITH = &LINK->kattr[p - 1]; - switch (WITH->dtype) { + switch (WITH->dtype) + { case 'R': realstr(s, LINK->gattr[p - 1].UU.r, WITH->prec); @@ -9309,13 +8545,15 @@ static double scrnincr(p, LINK) } strcat(s, " "); i = 0; - do { + do + { i++; if (s[i - 1] == '-') s[i - 1] = '+'; else if (isdigit(s[i - 1])) s[i - 1] = '0'; } while (s[i - 1] == '.' || s[i - 1] == '+' || s[i - 1] == '0'); + if (i > 1) s[i - 2] = '1'; r1 = 0.0; @@ -9323,9 +8561,7 @@ static double scrnincr(p, LINK) return r1; } -static void callconfig(proc, LINK) - void (*proc) (); - struct LOC_editattrs *LINK; +static void callconfig(void (*proc) (), struct LOC_editattrs *LINK) { gg.actx = LINK->p; gg.acty = LINK->acty; @@ -9337,8 +8573,7 @@ static void callconfig(proc, LINK) (*proc)(); } -static int tryconfig(LINK) - struct LOC_editattrs *LINK; +static int tryconfig(struct LOC_editattrs *LINK) { gg.actflag = true; callconfig(LINK->chproc, LINK); @@ -9916,8 +9151,6 @@ static void configgate(g) } - - static void nproc1() { calltool(gg.acttool, act_confignode); @@ -9954,8 +9187,6 @@ static void confignode(n, name) } - - static void configkind(i) short i; { @@ -10203,7 +9434,6 @@ static int setattr(gattr_, kattr_, p_, buf) } - static void setgattr(g, num, value_) log_grec *g; short num; @@ -10371,9 +9601,6 @@ static void flipkind() restorecursor(); } - - - /*============== ADJUSTSIGNAL ==================*/ /*= =*/ /*= Enter a new name for nameable gate. =*/ @@ -10510,10 +9737,6 @@ static void touchgate(g) flipgate(g); } - - - - static void unsoldernear() { short oldx, oldy1, oldy2, oldcolr; @@ -10549,7 +9772,6 @@ static void unsolderwires(hw, vw) } - static void soldernear() { if (!trycombinenodes(&gg.nearvw->node, &gg.nearhw->node)) { @@ -10574,9 +9796,6 @@ static void solderat(x, y) } - - - static void findattrnum2(numattrs, kattr, lbl, name, kinds, num) short numattrs; log_kattrrec *kattr; @@ -10655,8 +9874,6 @@ static void findattrname(k, num, name) } - - static void findpinnum(k, name_, num) log_krec *k; char *name_; @@ -10686,7 +9903,6 @@ static void findpinnum(k, name_, num) } - static void findpinname(k, num, name) log_krec *k; short num; @@ -10703,8 +9919,6 @@ static void findpinname(k, num, name) } - - static void findpointmarker(k, num, x, y) log_krec *k; short num, *x, *y; @@ -10722,7 +9936,6 @@ static void findpointmarker(k, num, x, y) } - static void findboxmarker(k, num, x1, y1, x2, y2) log_krec *k; short num, *x1, *y1, *x2, *y2; @@ -10742,13 +9955,6 @@ static void findboxmarker(k, num, x1, y1, x2, y2) } - - - - - - - static void addlabelat(x, y, s) short x, y; char *s; @@ -10775,7 +9981,6 @@ static void addlabelat(x, y, s) } - static void addlabel(l, s) log_lrec **l; char *s; @@ -10816,9 +10021,6 @@ static void addlabel(l, s) #define blinkrate 25 - - - /*================ EDITLABEL ===================*/ /*= =*/ /*= Edit or create a label. =*/ @@ -10975,9 +10177,6 @@ static void editlabel(l) #undef blinkrate - - - /*================== ADDBOX ====================*/ /*= =*/ /*= Create a new dashed box. =*/ @@ -11068,9 +10267,6 @@ static void addbox() - - - static void initcolors (); /* Local variables for doshellescape: */ @@ -11120,11 +10316,6 @@ static void doshellescape(arg) ENDTRY(try22); } - - - - - static void dumphistory() { log_htrec *ht; @@ -11161,8 +10352,6 @@ static void dumphistory() - - /*================ SHOWHISTORY =================*/ /*= =*/ /*= Enter History (Scope) display mode. =*/ @@ -13116,8 +12305,6 @@ void safesavepage(pgnum, fn) } - - static void savecommand() { short pgnum; @@ -13159,8 +12346,6 @@ static void savecommand() } - - static void namecommand() { char filename[256]; @@ -13199,14 +12384,6 @@ static void namecommand() } - - - - - - - - static void loadlog30(f, ver) FILE **f; short ver; @@ -13380,8 +12557,6 @@ static void loadlog30(f, ver) } - - static void readattrs(f, gattr, numattrs, kattr, lbl, count) FILE **f; log_gattrrec **gattr; @@ -13560,7 +12735,6 @@ static log_nrec *countnode_(i, LINK) } - /* Local variables for initialize: */ struct LOC_initialize { short j; @@ -14065,10 +13239,6 @@ typedef misc_catentry catarray[catsize]; typedef char dirarray[maxdirmax + 1][fidleng + 1]; - - - - /*================= LOADCOMMAND ================*/ /*= =*/ /*= Load circuit page from disk. Previous =*/ @@ -14553,8 +13723,6 @@ static void readcommand() - - static void singlestep() { gg.singlestepcount = getint(gg.funcarg, 1L); @@ -14564,9 +13732,6 @@ static void singlestep() } - - - static void getgatecmd() { short i; @@ -14581,8 +13746,6 @@ static void getgatecmd() } - - static void makegatecmd() { short i; @@ -15251,7 +14414,7 @@ static void popupmenu(short num) m_color((long)gg.color.blueword); else m_color((long)gg.color.popupword); - + if (menu[j].name[0] == '#' || menu[j].name[0] == '*') { sprintf(STR1, "%.*s", @@ -15519,7 +14682,7 @@ static void echomacro(char key) mp = macrobase; while (mp != NULL && mp->key != key) mp = mp->next; - + if (mp == NULL) { sprintf(STR1, "%s is not defined.", name); @@ -15749,7 +14912,7 @@ static void docnffunction() } else if (gg.initdone) { - statusdisplay("MACRO"); + statusdisplay("MACRO"); } clearfunc(); return; @@ -16957,7 +16120,7 @@ static void initialize() if (gg.traceflag) tracemessage("Trace mode ON"); gg.homedirname = (char *)Malloc(256); - + if (swtab[5].used > 0) { if (*swtab[5].UU.s == '\0') @@ -17083,7 +16246,7 @@ static void initialize() libf1[k]->f = freopen(gatesname[k], "r", libf1[k]->f); else libf1[k]->f = fopen(gatesname[k], "r"); - + if (libf1[k]->f == NULL) { P_escapecode = -10; diff --git a/log/src/node.c b/log/src/node.c new file mode 100644 index 0000000..8fc6cda --- /dev/null +++ b/log/src/node.c @@ -0,0 +1,643 @@ + +#include <p2c/p2c.h> + +/*================== ADDNODE ===================*/ +/*= =*/ +/*= Create a new node. =*/ +/*= =*/ +/*================================================*/ + +static void newnptr(log_nrec **n) +{ + if (freenode == NULL) + { + *n = (log_nrec *)Malloc(sizeof(log_nrec)); + } + else + { + *n = freenode; + freenode = freenode->next; + } +} + + +static void newnode(log_nrec **n, uchar st) +{ + newnptr(n); + (*n)->simtype = findsimtype(st); + (*n)->changed = false; + (*n)->conflict = false; + (*n)->conflict1 = false; + (*n)->conflict2 = false; + (*n)->oconflict = false; + (*n)->flag = false; + (*n)->keep = false; + (*n)->ref = 0; + newattrs(&(*n)->attr, (*n)->simtype->nnumattrs, (*n)->simtype->nattr); + (*n)->info = (na_long)0; + (*n)->temp = (na_long)0; + stamp(&(*n)->simtype->netstamp); + calltoolnode(*n, act_newnode); + (*n)->next = gg.nbase; + gg.nbase = *n; + if (gg.traceflag) + fprintf(tracefile, "Make node %ld\n", (long)(*n)); +} + +/*================== COPYNODE ==================*/ +/*= =*/ +/*= Create a new node, copied from another. =*/ +/*= =*/ +/*================================================*/ + +static void copynode(log_nrec *old, log_nrec **n) +{ + newnptr(n); + **n = *old; + (*n)->ref = 0; + copyattrs(&(*n)->attr, old->attr, (*n)->simtype->nnumattrs, + (*n)->simtype->nattr); + gg.actnode2 = old; + calltoolnode(*n, act_copynode); + (*n)->next = gg.nbase; + gg.nbase = *n; + if ((*n)->conflict || (*n)->oconflict) + { + (*n)->confnext = nodeconflictbase; + nodeconflictbase = *n; + } + if (gg.traceflag) + fprintf(tracefile, "Copy node %ld from %ld\n", (long)(*n), (long)old); +} + + +/*=================== DISPNODE =================*/ +/*= =*/ +/*= Dispose of a node. =*/ +/*= =*/ +/*================================================*/ + +static void disposenptr(log_nrec **n) +{ + (*n)->next = freenode; + freenode = *n; +} + + +#define rtn "DISPNODE" + + +static void disposenode(log_nrec **n) +{ + log_nrec *n1, *n2; + + if (gg.traceflag) + fprintf(tracefile, "Dispose node %ld\n", (long)(*n)); + if (*n == NULL) + return; + if ((*n)->conflict || (*n)->oconflict) + { + n1 = nodeconflictbase; + n2 = NULL; + while (n1 != NULL && n1 != *n) + { + n2 = n1; + n1 = n1->confnext; + } + if (n1 == NULL) + report(11, rtn); + else if (n2 == NULL) + nodeconflictbase = (*n)->confnext; + else + n2->confnext = (*n)->confnext; + } + if (*n == gg.probenode) + gg.probenode = NULL; + stamp(&(*n)->simtype->netstamp); + calltoolnode(*n, act_disposenode); + n1 = gg.nbase; + if (*n == n1) + { + gg.nbase = (*n)->next; + } + else + { + while (n1 != NULL && n1->next != *n) + n1 = n1->next; + if (n1 == NULL) + report(10, rtn); + else + n1->next = (*n)->next; + } + disposeattrs(&(*n)->attr, (*n)->simtype->nnumattrs, (*n)->simtype->nattr); + disposenptr(n); +} + +#undef rtn + + +static int nodeexists(log_nrec *n) +{ + log_nrec *n1; + + n1 = gg.nbase; + while (n1 != NULL && n1 != n) + n1 = n1->next; + return (n1 != NULL); +} + + +static void newnoderef(log_nrec **n, uchar st, long ref) +{ + newnode(n, st); + (*n)->ref = ref; +} + + +static log_nrec *refnode(log_nrec *n) +{ + if (n == NULL) + return n; + n->ref++; + if (gg.traceflag) + fprintf(tracefile, "Reference node %ld -> %d\n", (long)n, n->ref); + return n; +} + + +#define rtn "UNREFNODE" + + +static void unrefnode(log_nrec **n) +{ + if (*n == NULL) + return; + (*n)->ref--; + if (gg.traceflag) + fprintf(tracefile, "Unref node %ld -> %d\n", (long)(*n), (*n)->ref); + if ((*n)->ref > 0) + return; + if ((*n)->ref < 0) + report(10, rtn); + else { + if (!(*n)->keep) + disposenode(n); + } +} + +#undef rtn + + +static void switchnode(log_nrec **n, log_nrec *n2) +{ + if (*n != n2) + { + unrefnode(n); + *n = refnode(n2); + } +} + +/*================= DUMPNODES ==================*/ +/*= =*/ +/*= Print a detailed dissection of the major =*/ +/*= data structures. For debugging only. =*/ +/*= =*/ +/*================================================*/ + +static void dumpnodes() +{ + log_nrec *n, *n1; + log_hwrec *hw; + log_vwrec *vw; + log_srec *s; + log_grec *g; + short i, j; + timerec timevar; + daterec datevar; + int savebool; + char STR3[9]; + short FORLIM; + log_krec *WITH; + + savebool = gg.traceflag; + gg.traceflag = true; + tracemessage(""); + gg.traceflag = savebool; + sysdate(&datevar); + systime(&timevar); + fprintf(tracefile, + "-------------------------------------------------------- "); + fprintf(tracefile, "%2d/%2d/%02d", datevar.month, datevar.day, datevar.year); + fprintf(tracefile, " %2d:%2d\n\n", timevar.hour, timevar.minute); + n = gg.nbase; + fprintf(tracefile, "NODES\n"); + i = 0; + j = 0; + TRY(try6); + while (j == i && n != NULL) + { + i++; + fprintf(tracefile, "%12ld T:%s Ref:%d", + (long)n, n->simtype->name, n->ref); + FORLIM = gg.lastsignal; + for (j = 0; j < FORLIM; j++) + { + if (gg.signaltab[j].np == n) + fprintf(tracefile, " %s", gg.signaltab[j].name); + } + putc('\n', tracefile); + TRY(try7); + gg.actfile = gg.tracefile; + gg.actflag = true; + calltoolnode(n, act_writenode); + RECOVER(try7); + if (P_escapecode == -20) + goto _Ltry6; + fprintf(tracefile, " (Failed to output node value) %d\n", + P_escapecode); + ENDTRY(try7); + n1 = gg.nbase; + j = 1; + while (j < i && n1 != n) + { + j++; + n1 = n1->next; + } + if (j < i) + fprintf(tracefile, "Infinite loop in node list\n"); + n = n->next; + } + RECOVER2(try6,_Ltry6); + if (P_escapecode == -20) + _Escape(P_escapecode); + fprintf(tracefile, " Internal error, %d\n", P_escapecode); + ENDTRY(try6); + putc('\n', tracefile); + hw = gg.hwbase[gg.curpage - 1]; + fprintf(tracefile, "HWIRES\n"); + TRY(try8); + while (hw != NULL) + { + fprintf(tracefile, "%12ld X1:%4d X2:%4d Y:%4d N:%ld C:%s\n", + (long)hw, hw->x1, hw->x2, hw->y, (long)hw->node, + colorname(STR3, hw->wcolr)); + hw = hw->next; + } + RECOVER(try8); + if (P_escapecode == -20) + _Escape(P_escapecode); + fprintf(tracefile, " Internal error, %d\n", P_escapecode); + ENDTRY(try8); + putc('\n', tracefile); + vw = gg.vwbase[gg.curpage - 1]; + fprintf(tracefile, "VWIRES\n"); + TRY(try9); + while (vw != NULL) + { + fprintf(tracefile, "%12ld X:%4d Y1:%4d Y2:%4d N:%ld C:%s\n", + (long)vw, vw->x, vw->y1, vw->y2, (long)vw->node, + colorname(STR3, vw->wcolr)); + vw = vw->next; + } + RECOVER(try9); + if (P_escapecode == -20) + _Escape(P_escapecode); + fprintf(tracefile, " Internal error, %d\n", P_escapecode); + ENDTRY(try9); + putc('\n', tracefile); + s = gg.sbase[gg.curpage - 1]; + fprintf(tracefile, "SOLDER\n"); + TRY(try10); + while (s != NULL) + { + fprintf(tracefile, "%12ld X:%4d Y:%4d HW: %ld,%ld", + (long)s, s->x, s->y, (long)s->hwire, (long)s->hwire2); + if (s->hwire == NULL) + fprintf(tracefile, " "); + fprintf(tracefile, " VW: %ld,%ld\n", (long)s->vwire, (long)s->vwire2); + s = s->next; + } + RECOVER(try10); + if (P_escapecode == -20) + _Escape(P_escapecode); + fprintf(tracefile, " Internal error, %d\n", P_escapecode); + ENDTRY(try10); + putc('\n', tracefile); + g = gg.gbase[gg.curpage - 1]; + fprintf(tracefile, "GATES\n"); + TRY(try11); + while (g != NULL) + { + fprintf(tracefile, "%12ld G:%3d X:%4d Y:%4d T:%s %s\n", + (long)g, g->g, g->x, g->y, g->kind->simtype->name, + g->kind->name); + WITH = g->kind; + FORLIM = WITH->numpins; + for (i = 0; i < FORLIM; i++) + { + fprintf(tracefile, " Pin %2d X:%4d Y:%4d N:%ld", + i + 1, g->pinpos[i].x, g->pinpos[i].y, (long)g->pin[i]); + TRY(try12); + fprintf(tracefile, " [%d]", g->pin[i]->ref); + RECOVER(try12); + if (P_escapecode == -20) + goto _Ltry11; + ENDTRY(try12); + putc('\n', tracefile); + } + TRY(try13); + gg.actfile = gg.tracefile; + gg.actflag = true; + calltoolgate(g, act_writegate); + RECOVER(try13); + if (P_escapecode == -20) + goto _Ltry11; + fprintf(tracefile, " (Failed to output gate value) %d\n", + P_escapecode); + ENDTRY(try13); + g = g->next; + } + RECOVER2(try11,_Ltry11); + if (P_escapecode == -20) + _Escape(P_escapecode); + fprintf(tracefile, " Internal error, %d\n", P_escapecode); + ENDTRY(try11); + fprintf(tracefile, + "\n\n-------------------------------------------------------------------------\n\n\n"); +} + +static void delgetnode(log_nrec **save, log_nrec **old, log_nrec **n) +{ + /* if save <> nil then + begin +n := save; --> Not safe! <-- +save := nil; +end +else +*/ + copynode(*old, n); +} + +#define rtn "COMBINENODES" + + +/*================ COMBINENODES ================*/ +/*= =*/ +/*= Combine node N1 into N2. Adjust all =*/ +/*= references accordingly. =*/ +/*= =*/ +/*================================================*/ + +static void combinenodes(log_nrec **n2, log_nrec **n1, cnrec *cnbase) +{ + log_nrec *nn1, *nn2, *n3; + log_hwrec *hw; + log_vwrec *vw; + log_grec *g; + cnrec *cn; + log_hnrec *hn; + log_tool *oldsimtype, *newsimtype; + short i, pg, FORLIM, FORLIM1; + + if (gg.traceflag) + fprintf(tracefile, "Combine node %ld into %ld\n", + (long)(*n1), (long)(*n2)); + working(); + if (*n2 == NULL) + switchnode(n2, *n1); + nn1 = *n1; /*VAR params may change out from under us*/ + nn2 = *n2; + if (nn1 != NULL) + { + if (nn2 == nn1) + { + stamp(&nn2->simtype->netstamp); + } + else + { + if (nn1->simtype != nn2->simtype) + { + if (nn1->simtype->simtype >= 8) + { + if (nn2->simtype->simtype >= 8) + { + /* shouldn't happen */ + report(10, rtn); + } + else + { + n3 = nn1; + nn1 = nn2; + nn2 = n3; + } + } + gg.actx = nn1->simtype->simtype; + gg.actnode2 = nn1; + calltoolnode(nn2, act_combineintonode); + } + else + { + gg.actnode2 = nn1; + calltoolnode(nn2, act_combinenodes); + } + oldsimtype = nn1->simtype; + newsimtype = nn2->simtype; + stamp(&newsimtype->netstamp); + nn2->changed = true; + FORLIM = gg.numpages; + for (pg = 0; pg < FORLIM; pg++) + { + hw = gg.hwbase[pg]; + while (hw != NULL) + { + if (hw->node == nn1) + switchnode(&hw->node, nn2); + hw = hw->next; + } + vw = gg.vwbase[pg]; + while (vw != NULL) + { + if (vw->node == nn1) + switchnode(&vw->node, nn2); + vw = vw->next; + } + g = gg.gbase[pg]; + while (g != NULL) + { + FORLIM1 = g->kind->numpins; + for (i = 0; i < FORLIM1; i++) + { + if (g->pin[i] == nn1) + switchnode(&g->pin[i], nn2); + } + g = g->next; + } + } + FORLIM = gg.lastsignal; + for (i = 1; i <= FORLIM; i++) + { + if (gg.signaltab[i - 1].np == nn1) + { + switchnode(&gg.signaltab[i - 1].np, nn2); + if (oldsimtype->simtype < 8 && newsimtype->simtype >= 8) + { + hn = gg.hnbase; + while (hn != NULL) + { + if (hn->sig == i) + newattrs(&hn->attr, newsimtype->hnumattrs, newsimtype->hattr); + hn = hn->next; + } + } + } + } + cn = cnbase; + while (cn != NULL) + { + if (cn->n == nn1) + cn->n = nn2; + cn = cn->next; + } + + if (nodeexists(nn1)) + { + report(11, rtn); + disposenode(&nn1); + } + } + } + *n1 = *n2; +} + +#undef rtn + + +/* N is one of the nodes to be merged into N2, later. If N is nil, says + that N2 must be assigned a node, but we don't have anything to connect + to it yet. */ + +static void queuecombine(cnrec **cnbase, log_nrec **n, log_nrec **n2) +{ + cnrec *cn; + + if (gg.traceflag) + fprintf(tracefile, "Queue-combine, n = %ld, np -> %ld\n", (long)(*n), (long)(*n2)); + if (*n == NULL) + return; + cn = (cnrec *)Malloc(sizeof(cnrec)); + cn->next = *cnbase; + *cnbase = cn; + cn->n = *n; + cn->np = n2; +} + + +/* Local variables for checkcombine: */ +struct LOC_checkcombine { + cnrec **cnbase; + short passcount; + int good; + log_tool *cursimtype; +} ; + +static void checknode(log_nrec *n, struct LOC_checkcombine *LINK) +{ + log_tool *newsimtype; + char STR1[94]; + + newsimtype = n->simtype; + if (newsimtype->simtype < 8) + return; + + if (LINK->cursimtype->simtype < 8) + { + LINK->cursimtype = newsimtype; + return; + } + + if (LINK->cursimtype->simtype == newsimtype->simtype) + return; + + if (LINK->passcount == 2) + { + sprintf(STR1, "Tried to connect %s signal to %s", + newsimtype->shortname, LINK->cursimtype->shortname); + message(STR1); + } + LINK->good = false; +} + +/* Merge all queued nodes. If any simtype conflicts would result, don't + merge any nodes. If a node doesn't have anything merged into it, make + a new node. */ +static int checkcombine(cnrec **cnbase_) +{ + struct LOC_checkcombine V; + cnrec *cn; + + V.cnbase = cnbase_; + V.passcount = 1; + do + { + cn = *V.cnbase; + while (cn != NULL) + { + cn->done = false; + cn = cn->next; + } + cn = *V.cnbase; + V.good = true; + while (cn != NULL && V.good) + { + V.cursimtype = simtype_ignore; + scancn(cn, &V); + cn = cn->next; + } + + if (!V.good && V.passcount == 1) + { + cn = *V.cnbase; + while (cn != NULL) + { + confirmsimtype(cn->n); + confirmsimtype(*cn->np); + cn = cn->next; + } + } + + if (gg.traceflag && *V.cnbase != NULL) + fprintf(tracefile, "Check-combine (pass %d) finds %s\n", + V.passcount, V.good ? " TRUE" : "FALSE"); + V.passcount++; + } while (!(V.good || V.passcount > 2)); + + if (V.good) + { + cn = *V.cnbase; + while (cn != NULL) + { + combinenodes(cn->np, &cn->n, *V.cnbase); + cn = cn->next; + } + } + + while (*V.cnbase != NULL) + { + cn = (*V.cnbase)->next; + Free(*V.cnbase); + *V.cnbase = cn; + } + return V.good; +} + + +static int trycombinenodes(log_nrec **n1, log_nrec **n2) +{ + cnrec *cnbase; + + cnbase = NULL; + queuecombine(&cnbase, n1, n2); + return (checkcombine(&cnbase)); +} + + diff --git a/log/src/wire.c b/log/src/wire.c index fc378ab..2d280ba 100644 --- a/log/src/wire.c +++ b/log/src/wire.c @@ -661,3 +661,342 @@ static void delvwire(log_vwrec *vw) clipoff(); } + +#define rtn "ADDHWIRE" + +/*================== ADDVWIRE ==================*/ +/*= =*/ +/*= ADDHWIRE: =*/ +/*= Add a Horizontal wire. Merge with other =*/ +/*= horizontal wires if touching; solder to =*/ +/*= other vertical wires in T-intersections; =*/ +/*= connect to gate pins as necessary. =*/ +/*= VLSI-mode rules are more complex! =*/ +/*= ADDVWIRE works similarly. =*/ +/*= =*/ +/*================================================*/ + +static void addhwire(short x1, short x2, short y, short colr) +{ + cnrec *cnbase; + log_hwrec *hw, *hw1, *hw2; + log_vwrec *vw1, *vw2; + log_grec *g; + short i, xp, hx1, hx2, hy, vx, vy1, vy2, hcolr, vcolr; + blobrec *blbase; + short FORLIM; + + if (gg.traceflag) + fprintf(tracefile, "Add hwire %d-%d, %d\n", x1, x2, y); + sortshints(&x1, &x2); + cnbase = NULL; + remcursor(); + working(); + clipon(); + if (!vlsi) + colr = log_wcol_normal; + newhw(&hw); + hw->x1 = log_maxshint; + hw->x2 = log_maxshint; + hw->y = log_maxshint; + hw->node = NULL; + hw1 = hw->next; + blbase = NULL; + while (hw1 != NULL) + { + hw2 = hw1->next; + hx1 = hw1->x1; + hx2 = hw1->x2; + hy = hw1->y; + hcolr = hw1->wcolr; + if (hy == y && hx1 <= x2 && hx2 >= x1) + { + if (hcolr == colr) + { + x1 = P_imin2((long)x1, (long)hx1); + x2 = P_imax2((long)x2, (long)hx2); + addblobs(&blbase, hx1, hy, hx2, hy); + delhwire(hw1); + } + } + hw1 = hw2; + } + hw->x1 = x1; + hw->x2 = x2; + hw->y = y; + hw->wcolr = colr; + chpageplace((int)gg.curpage, x1, y, x2, y); + g = gg.gbase[gg.curpage - 1]; + while (g != NULL) + { + if (abs(g->y - y) <= g->kind->bbmax && + P_ibetweenm((long)x1, (long)g->x, (long)x2, (long)g->kind->bbmax)) + { + FORLIM = g->kind->numpins; + for (i = 0; i < FORLIM; i++) + { + xp = g->pinpos[i].x; + if (g->pinpos[i].y == y && x1 <= xp && xp <= x2) + queuecombine(&cnbase, &g->pin[i], &hw->node); + } + } + g = g->next; + } + vw1 = gg.vwbase[gg.curpage - 1]; + while (vw1 != NULL) + { + vx = vw1->x; + vy1 = vw1->y1; + vy2 = vw1->y2; + vcolr = vw1->wcolr; + vw2 = vw1->next; + if ((((vx == x1 || vx == x2) && vy1 <= y && y <= vy2) || + ((vy1 == y || vy2 == y) && x1 <= vx && vx <= x2)) && + (colr == vcolr || colr == log_wcol_blue || vcolr == log_wcol_blue)) + queuecombine(&cnbase, &vw1->node, &hw->node); + else if (vlsi && x1 < vx && vx < x2 && vy1 < y && y < vy2 && colr == vcolr) + queuecombine(&cnbase, &vw1->node, &hw->node); + vw1 = vw2; + } + if (cnbase == NULL) + newnoderef(&hw->node, 0, 1L); + if (!checkcombine(&cnbase)) + { + fryhwire(hw); + disphw(&hw); + gg.nearhw = NULL; + goto _L1; /*return*/ + } + vw1 = gg.vwbase[gg.curpage - 1]; + while (vw1 != NULL) + { + vx = vw1->x; + vy1 = vw1->y1; + vy2 = vw1->y2; + vcolr = vw1->wcolr; + vw2 = vw1->next; + if ((((vx == x1 || vx == x2) && vy1 <= y && y <= vy2) || + ((vy1 == y || vy2 == y) && x1 <= vx && vx <= x2)) && + (colr == vcolr || colr == log_wcol_blue || vcolr == log_wcol_blue)) + { + clipon(); + if (!vlsi) + addsoldert(hw, vw1); + else if (colr != vcolr) + addsolder(vx, y, hw, NULL, vw1, NULL); + } + vw1 = vw2; + } + clipon(); + if (hw->node->conflict1 && hw->node->conflict2) /*or hw^.node^.oconflict*/ + m_color((long)gg.color.conflict); + else if (gg.glowmode) + m_color(glowcol(hw->node, (long)gg.color.wire[colr - log_wcol_normal])); + else + m_color((long)gg.color.wire[colr - log_wcol_normal]); + hline(x1, x2, y); + doblobs(blbase); + gg.nearhw = hw; + clipoff(); + refreshsoon(); + if (gg.traceflag) + fprintf(tracefile, "Added hwire %ld\n", (long)hw); +_L1: + dispblobs(&blbase); + + /* Deal with color A drawn over color B */ + /*VVV*/ +} + +#undef rtn + + +static void addhwire2(short x1, short x2, short y) +{ + addhwire(x1, x2, y, log_wcol_normal); +} + + +#define rtn "ADDHWIRE" + + +static void addvwire(short x, short y1, short y2, short colr) +{ + cnrec *cnbase; + log_vwrec *vw, *vw1, *vw2; + log_hwrec *hw1, *hw2; + log_grec *g; + short i, yp, hy, hx1, hx2, vx, vy1, vy2, hcolr, vcolr; + blobrec *blbase; + short FORLIM; + + if (gg.traceflag) + fprintf(tracefile, "Add vwire %d, %d-%d\n", x, y1, y2); + sortshints(&y1, &y2); + cnbase = NULL; + remcursor(); + working(); + clipon(); + if (!vlsi) + colr = log_wcol_normal; + newvw(&vw); + vw->x = log_maxshint; + vw->y1 = log_maxshint; + vw->y2 = log_maxshint; + vw->node = NULL; + vw1 = vw->next; + blbase = NULL; + while (vw1 != NULL) + { + vw2 = vw1->next; + vx = vw1->x; + vy1 = vw1->y1; + vy2 = vw1->y2; + vcolr = vw1->wcolr; + if (vx == x && vy1 <= y2 && vy2 >= y1) + { + if (vcolr == colr) + { + y1 = P_imin2((long)y1, (long)vy1); + y2 = P_imax2((long)y2, (long)vy2); + addblobs(&blbase, vx, vy1, vx, vy2); + delvwire(vw1); + } + } + vw1 = vw2; + } + vw->y1 = y1; + vw->y2 = y2; + vw->x = x; + vw->wcolr = colr; + chpageplace((int)gg.curpage, x, y1, x, y2); + g = gg.gbase[gg.curpage - 1]; + while (g != NULL) + { + if (abs(g->x - x) <= g->kind->bbmax && + P_ibetweenm((long)y1, (long)g->y, (long)y2, (long)g->kind->bbmax)) + { + FORLIM = g->kind->numpins; + for (i = 0; i < FORLIM; i++) + { + yp = g->pinpos[i].y; + if (g->pinpos[i].x == x && y1 <= yp && yp <= y2) + queuecombine(&cnbase, &g->pin[i], &vw->node); + } + } + g = g->next; + } + hw1 = gg.hwbase[gg.curpage - 1]; + while (hw1 != NULL) + { + hy = hw1->y; + hx1 = hw1->x1; + hx2 = hw1->x2; + hcolr = hw1->wcolr; + hw2 = hw1->next; + if ((((hy == y1 || hy == y2) && hx1 <= x && x <= hx2) || + ((hx1 == x || hx2 == x) && y1 <= hy && hy <= y2)) && + (colr == hcolr || colr == log_wcol_blue || hcolr == log_wcol_blue)) + queuecombine(&cnbase, &hw1->node, &vw->node); + else if (vlsi && y1 < hy && hy < y2 && hx1 < x && x < hx2 && colr == hcolr) + queuecombine(&cnbase, &hw1->node, &vw->node); + hw1 = hw2; + } + + if (cnbase == NULL) + newnoderef(&vw->node, 0, 1L); + if (!checkcombine(&cnbase)) + { + fryvwire(vw); + dispvw(&vw); + gg.nearvw = NULL; + goto _L1; /*return*/ + } + hw1 = gg.hwbase[gg.curpage - 1]; + while (hw1 != NULL) + { + hy = hw1->y; + hx1 = hw1->x1; + hx2 = hw1->x2; + hcolr = hw1->wcolr; + hw2 = hw1->next; + if ((((hy == y1 || hy == y2) && hx1 <= x && x <= hx2) || + ((hx1 == x || hx2 == x) && y1 <= hy && hy <= y2)) && + (colr == hcolr || colr == log_wcol_blue || hcolr == log_wcol_blue)) + { + clipon(); + if (!vlsi) + addsoldert(hw1, vw); + else if (colr != hcolr) + addsolder(x, hy, hw1, NULL, vw, NULL); + } + hw1 = hw2; + } + clipon(); + if (vw->node->conflict1 && vw->node->conflict2) /*or vw^.node^.oconflict*/ + m_color((long)gg.color.conflict); + else if (gg.glowmode) + m_color(glowcol(vw->node, (long)gg.color.wire[colr - log_wcol_normal])); + else + m_color((long)gg.color.wire[colr - log_wcol_normal]); + vline(x, y1, y2); + doblobs(blbase); + gg.nearvw = vw; + clipoff(); + refreshsoon(); + if (gg.traceflag) + fprintf(tracefile, "Added vwire %ld\n", (long)vw); +_L1: + dispblobs(&blbase); + + /* Deal with color A drawn over color B */ + /*VVV*/ +} + +#undef rtn + + +static void addvwire2(short x, short y1, short y2) +{ + addvwire(x, y1, y2, log_wcol_normal); +} + +static void fryhwire(log_hwrec *hw) +{ + long t0; + + remcursor(); + clipon(); + t0 = timers_sysclock(); + while (labs(timers_sysclock() - t0) < frytime) + { + m_color((long)gg.color.conflict); + hline(hw->x1, hw->x2, hw->y); + m_color((long)gg.color.backgr); + hline(hw->x1, hw->x2, hw->y); + } + clipoff(); + refreshsoon(); +} + + +static void fryvwire(log_vwrec *vw) +{ + long t0; + + remcursor(); + clipon(); + t0 = timers_sysclock(); + while (labs(timers_sysclock() - t0) < frytime) + { + m_color((long)gg.color.conflict); + vline(vw->x, vw->y +1, vw->y2); + m_color((long)gg.color.backgr); + vline(vw->x, vw->y1, vw->y2); + } + clipoff(); + refreshsoon(); +} + + -- GitLab