From 592214f4d6268198378ff6ef8e230069551145d6 Mon Sep 17 00:00:00 2001 From: Etienne Brateau <etienne.brateau@gmail.com> Date: Sun, 20 Oct 2019 18:08:13 +0200 Subject: [PATCH] Use the function get_current_page instead of using direct access --- include/page.h | 2 + src/box.c | 16 +++-- src/gate.c | 56 +++++++++------ src/label.c | 26 ++++--- src/log.c | 180 ++++++++++++++++++++++++++++--------------------- src/node.c | 10 +-- src/page.c | 4 ++ src/window.c | 36 +++++----- src/wire.c | 116 +++++++++++++++++++------------ 9 files changed, 269 insertions(+), 177 deletions(-) diff --git a/include/page.h b/include/page.h index 18b4869..6e4ad5c 100644 --- a/include/page.h +++ b/include/page.h @@ -49,4 +49,6 @@ void pageFree(log_page **page); void pageClear(log_page *page); +log_page *get_current_page(); + #endif diff --git a/src/box.c b/src/box.c index 24ac6c4..2cb7e61 100644 --- a/src/box.c +++ b/src/box.c @@ -5,12 +5,14 @@ #include "utils.h" #include "keyboard.h" #include "pen.h" +#include "page.h" /// Link box to the current page. void linkbox(log_brec *b) { - b->next = gg.pages[gg.curpage - 1]->bbase; - gg.pages[gg.curpage - 1]->bbase = b; + log_page *current_page = get_current_page(); + b->next = current_page->bbase; + current_page->bbase = b; stamp(&gg.boxstamp); } @@ -26,15 +28,17 @@ void newbox(log_brec **b) void unlinkbox(log_brec *b) { log_brec *b1; + + log_page *current_page = get_current_page(); - b1 = gg.pages[gg.curpage - 1]->bbase; + b1 = current_page->bbase; while (b1 != NULL && b1->next != b) b1 = b1->next; if (b1 == NULL) - gg.pages[gg.curpage - 1]->bbase = b->next; + current_page->bbase = b->next; else b1->next = b->next; - chpageplace(gg.pages[gg.curpage - 1], b->x1, b->y1, b->x2, b->y2); + chpageplace(current_page, b->x1, b->y1, b->x2, b->y2); stamp(&gg.boxstamp); } @@ -61,7 +65,7 @@ void addboxat(short x1, short y1, short x2, short y2) clipon(); drawboxc(b, gg.color.dashbox); clipoff(); - chpageplace(gg.pages[gg.curpage - 1], x1, y1, x2, y2); + chpageplace(get_current_page(), x1, y1, x2, y2); gg.nearbox = b; } diff --git a/src/gate.c b/src/gate.c index 74bcfcb..4042f57 100644 --- a/src/gate.c +++ b/src/gate.c @@ -108,9 +108,10 @@ void eragate(log_grec *gate) /// Add a gate to the gate list. void linkgate(log_grec **gate) { - (*gate)->next = gg.pages[gg.curpage - 1]->gbase; - gg.pages[gg.curpage - 1]->gbase = *gate; - chpageplace(gg.pages[gg.curpage - 1], (*gate)->x - (*gate)->kind->bbmax, + log_page *current_page = get_current_page(); + (*gate)->next = current_page->gbase; + current_page->gbase = *gate; + chpageplace(current_page, (*gate)->x - (*gate)->kind->bbmax, (*gate)->y - (*gate)->kind->bbmax, (*gate)->x + (*gate)->kind->bbmax, (*gate)->y + (*gate)->kind->bbmax); } @@ -210,15 +211,16 @@ void copygate(log_grec *old, log_grec **gate) void unlkgate(log_grec **gate) { log_grec *g1; + log_page *current_page = get_current_page(); - g1 = gg.pages[gg.curpage - 1]->gbase; + g1 = current_page->gbase; while (g1 != NULL && g1->next != *gate) g1 = g1->next; if (g1 == NULL) - gg.pages[gg.curpage - 1]->gbase = (*gate)->next; + current_page->gbase = (*gate)->next; else g1->next = (*gate)->next; - chpageplace(gg.pages[gg.curpage - 1], (*gate)->x - (*gate)->kind->bbmax, + chpageplace(current_page, (*gate)->x - (*gate)->kind->bbmax, (*gate)->y - (*gate)->kind->bbmax, (*gate)->x + (*gate)->kind->bbmax, (*gate)->y + (*gate)->kind->bbmax); } @@ -266,10 +268,12 @@ void disposegate(log_grec **gate) */ void closergate(short x, short y) { + log_page *current_page = get_current_page(); + if (gg.textinvisible) gg.nearlabel = NULL; else { - gg.nearlabel = gg.pages[gg.curpage - 1]->lbase; + gg.nearlabel = current_page->lbase; while (gg.nearlabel != NULL && (x < gg.nearlabel->x || x > gg.nearlabel->x + m_strwidth(logfont_lfont, @@ -284,7 +288,7 @@ void closergate(short x, short y) return; } if (!gg.textinvisible) { - gg.nearbox = gg.pages[gg.curpage - 1]->bbase; + gg.nearbox = current_page->bbase; while (gg.nearbox != NULL && ((x != gg.nearbox->x1 && x != gg.nearbox->x2 && y != gg.nearbox->y1 && @@ -298,7 +302,7 @@ void closergate(short x, short y) gg.neargate = NULL; return; } - gg.neargate = gg.pages[gg.curpage - 1]->gbase; + gg.neargate = current_page->gbase; while (gg.neargate != NULL && !insidegate(gg.neargate, x, y)) gg.neargate = gg.neargate->next; } @@ -311,6 +315,8 @@ void chggate(log_grec *gate, int i, log_nrec *oldnode, log_nrec *n) log_grec *g1; short j, k, savepg, pg, x, y, FORLIM; + log_page *current_page = get_current_page(); + trace_message("Change gate %p pin %d to node %p\n", gate, i, n); j = i; do @@ -320,21 +326,21 @@ void chggate(log_grec *gate, int i, log_nrec *oldnode, log_nrec *n) switchnode(&gate->pin[j - 1], n); x = gate->pinpos[j - 1].x; y = gate->pinpos[j - 1].y; - hw = gg.pages[gg.curpage - 1]->hwbase; + hw = current_page->hwbase; while (hw != NULL) { if (hw->x1 <= x && x <= hw->x2 && hw->y == y && hw->node == oldnode) chghw(hw, oldnode, n); hw = hw->next; } - vw = gg.pages[gg.curpage - 1]->vwbase; + vw = current_page->vwbase; while (vw != NULL) { if (vw->y1 <= y && y <= vw->y2 && vw->x == x && vw->node == oldnode) chgvw(vw, oldnode, n); vw = vw->next; } - g1 = gg.pages[gg.curpage - 1]->gbase; + g1 = current_page->gbase; while (g1 != NULL) { if (g1 != gate && P_imax2((long)abs(g1->x - x), (long)abs(g1->y - y)) <= @@ -362,7 +368,7 @@ void chggate(log_grec *gate, int i, log_nrec *oldnode, log_nrec *n) for (pg = 1; pg <= FORLIM; pg++) { gg.curpage = pg; - g1 = gg.pages[gg.curpage - 1]->gbase; + g1 = current_page->gbase; while (g1 != NULL) { if (g1->kind->simtype == simtype_common && g1->sig == gate->sig && @@ -383,10 +389,12 @@ void chggatepin(log_grec *gate, short i, log_nrec **oldnode) log_grec *g1; short j, x, y, FORLIM; + log_page *current_page = get_current_page(); + trace_message("Change gate %p pin %d from node %p\n", gate, i, *oldnode); x = gate->pinpos[i - 1].x; y = gate->pinpos[i - 1].y; - hw = gg.pages[gg.curpage - 1]->hwbase; + hw = current_page->hwbase; while (hw != NULL) { if (hw->x1 <= x && x <= hw->x2 && hw->y == y && hw->node == *oldnode) @@ -397,7 +405,7 @@ void chggatepin(log_grec *gate, short i, log_nrec **oldnode) } hw = hw->next; } - vw = gg.pages[gg.curpage - 1]->vwbase; + vw = current_page->vwbase; while (vw != NULL) { if (vw->y1 <= y && y <= vw->y2 && vw->x == x && vw->node == *oldnode) @@ -408,7 +416,7 @@ void chggatepin(log_grec *gate, short i, log_nrec **oldnode) } vw = vw->next; } - g1 = gg.pages[gg.curpage - 1]->gbase; + g1 = current_page->gbase; while (g1 != NULL) { if (g1 != gate && @@ -527,6 +535,8 @@ int connectgate(log_grec *gate) int success; short FORLIM, FORLIM1; + log_page *current_page = get_current_page(); + trace_message("Connect gate %p, type %s\n", gate, gate->kind->name); linkgate(&gate); initpinpos(gate); @@ -562,21 +572,21 @@ int connectgate(log_grec *gate) xp = gate->pinpos[i].x; yp = gate->pinpos[i].y; n1 = NULL; - hw = gg.pages[gg.curpage - 1]->hwbase; + hw = current_page->hwbase; while (hw != NULL && n1 == NULL) { if (hw->x1 <= xp && xp <= hw->x2 && yp == hw->y) n1 = &hw->node; hw = hw->next; } - vw = gg.pages[gg.curpage - 1]->vwbase; + vw = current_page->vwbase; while (vw != NULL && n1 == NULL) { if (vw->y1 <= yp && yp <= vw->y2 && xp == vw->x) n1 = &vw->node; vw = vw->next; } - g1 = gg.pages[gg.curpage - 1]->gbase; + g1 = current_page->gbase; while (g1 != NULL && n1 == NULL) { if (g1 != gate && P_imax2((long)abs(g1->x - xp), (long)abs(g1->y - yp)) <= @@ -640,6 +650,8 @@ void addgate2(short x, short y, short gtype, short sig, log_gattrrec *attrs) short i, gmax; int flag; + log_page *current_page = get_current_page(); + newgate2(&g, gtype, sig, attrs); if (gatecount[gg.curpage - 1] == log_maxshint) { @@ -648,7 +660,7 @@ void addgate2(short x, short y, short gtype, short sig, log_gattrrec *attrs) do { i++; - g1 = gg.pages[gg.curpage - 1]->gbase; + g1 = current_page->gbase; flag = false; while (g1 != NULL && !flag) { @@ -691,6 +703,8 @@ void uaddgate(short x, short y, short gtype) log_grec *g; log_krec *k; + log_page *current_page = get_current_page(); + 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]; @@ -698,7 +712,7 @@ void uaddgate(short x, short y, short gtype) { xx = (x + gg.xoff) / gg.scale; yy = (y + gg.yoff) / gg.scale; - g = gg.pages[gg.curpage - 1]->gbase; + g = current_page->gbase; while (g != NULL && P_imax2((long)abs(g->x - xx), (long)abs(g->y - yy)) > g->kind->bbmax + k->bbmax) g = g->next; diff --git a/src/label.c b/src/label.c index c31ef6f..c2a1881 100644 --- a/src/label.c +++ b/src/label.c @@ -343,8 +343,10 @@ void xorlabel(short x, short y, log_lrec *l) void linklabel(log_lrec *l) { - l->next = gg.pages[gg.curpage - 1]->lbase; - gg.pages[gg.curpage - 1]->lbase = l; + log_page *current_page = get_current_page(); + + l->next = current_page->lbase; + current_page->lbase = l; stamp(&gg.labelstamp); } @@ -362,14 +364,16 @@ void unlinklabel(log_lrec *l) { log_lrec *l1; - l1 = gg.pages[gg.curpage - 1]->lbase; + log_page *current_page = get_current_page(); + + l1 = current_page->lbase; while (l1 != NULL && l1->next != l) l1 = l1->next; if (l1 == NULL) - gg.pages[gg.curpage - 1]->lbase = l->next; + current_page->lbase = l->next; else l1->next = l->next; - chpageplace(gg.pages[gg.curpage - 1], l->x, l->y, l->x + l->w, l->y + 2); + chpageplace(current_page, l->x, l->y, l->x + l->w, l->y + 2); stamp(&gg.labelstamp); } @@ -385,12 +389,14 @@ void addlabelat(short x, short y, char *s) { log_lrec *l; + log_page *current_page = get_current_page(); + newlabel(&l); strcpy(l->name, s); l->x = x; l->y = y; l->w = m_strwidth(logfont_lfont, s) / log_scale0; - chpageplace(gg.pages[gg.curpage - 1], x, y, x + l->w, y + 2); + chpageplace(current_page, x, y, x + l->w, y + 2); /* now render the label */ remcursor(); @@ -409,6 +415,8 @@ void addlabel(log_lrec **l, char *s) log_lrec *l1; short x, y; + log_page *current_page = get_current_page(); + x = 0; y = baseline - 15; do @@ -417,7 +425,7 @@ void addlabel(log_lrec **l, char *s) // check the position of other label to see if some will colide conflict = false; - l1 = gg.pages[gg.curpage - 1]->lbase; + l1 = current_page->lbase; while (l1 != NULL && !conflict) { if (l1->y * gg.scale - gg.yoff == y && @@ -465,6 +473,8 @@ void editlabel(log_lrec *l) char name[log_lablen + 1]; char STR1[256]; + log_page *current_page = get_current_page(); + // prepare rendering m_graphics_on(); clearalpha(); @@ -626,7 +636,7 @@ void editlabel(log_lrec *l) strcpy(l->name, name); l->w = m_strwidth(logfont_lfont, l->name) / log_scale0; stamp(&gg.labelstamp); - chpageplace(gg.pages[gg.curpage - 1], l->x, l->y, l->x + l->w, l->y + 2); + chpageplace(current_page, l->x, l->y, l->x + l->w, l->y + 2); } gg.t.depressed = false; refreshsoon(); diff --git a/src/log.c b/src/log.c index 69805b5..c8c64f0 100644 --- a/src/log.c +++ b/src/log.c @@ -372,6 +372,8 @@ void testprobe(short xx, short yy) log_vwrec *vw; short FORLIM; + log_page *current_page = get_current_page(); + x = (xx + gg.hscale + gg.xoff) / gg.scale; y = (yy + gg.hscale + gg.yoff) / gg.scale; unprobe(); @@ -379,7 +381,7 @@ void testprobe(short xx, short yy) { if (gg.incircuit) { - g = gg.pages[gg.curpage - 1]->gbase; + g = current_page->gbase; while (g != NULL && gg.probegate == NULL) { k = g->kind; @@ -405,7 +407,7 @@ void testprobe(short xx, short yy) } g = g->next; } - hw = gg.pages[gg.curpage - 1]->hwbase; + hw = current_page->hwbase; while (hw != NULL && gg.probenode == NULL) { if (hw->x1 <= x && x <= hw->x2 && hw->y == y) @@ -415,7 +417,7 @@ void testprobe(short xx, short yy) } hw = hw->next; } - vw = gg.pages[gg.curpage - 1]->vwbase; + vw = current_page->vwbase; while (vw != NULL && gg.probenode == NULL) { if (vw->y1 <= y && y <= vw->y2 && vw->x == x) @@ -867,6 +869,8 @@ void pass() log_vwrec *WITH2; log_srec *WITH3; + log_page *current_page = get_current_page(); + watchdog = timers_sysclock(); gg.busyflag = false; gg.oldsimstate = gg.simstate; @@ -1164,7 +1168,7 @@ void pass() if (gg.glowmode && gg.showpage > 0 && !gg.invisible && !gg.showconflicts) { flag = false; - hw = gg.pages[gg.curpage - 1]->hwbase; + hw = current_page->hwbase; while (hw != NULL) { WITH1 = hw; @@ -1179,7 +1183,7 @@ void pass() } hw = WITH1->next; } - vw = gg.pages[gg.curpage - 1]->vwbase; + vw = current_page->vwbase; while (vw != NULL) { WITH2 = vw; @@ -1196,7 +1200,7 @@ void pass() } if (glowsolder) { - s = gg.pages[gg.curpage - 1]->sbase; + s = current_page->sbase; while (s != NULL) { WITH3 = s; @@ -2322,7 +2326,9 @@ void addblobs(blobrec **blbase, short x1, short y1, short x2, short y2) blobrec *blp; log_srec *s; - s = gg.pages[gg.curpage - 1]->sbase; + log_page *current_page = get_current_page(); + + s = current_page->sbase; while (s != NULL) { if (P_ibetween((long)x1, (long)s->x, (long)x2) && @@ -2345,16 +2351,18 @@ void doblobs(blobrec *blp) log_vwrec *vw; short x, y; + log_page *current_page = get_current_page(); + while (blp != NULL) { if (blp->x != -32768L) { x = blp->x; y = blp->y; - hw = gg.pages[gg.curpage - 1]->hwbase; + hw = current_page->hwbase; while (hw != NULL && (hw->y != y || hw->x1 > x || hw->x2 < x)) hw = hw->next; - vw = gg.pages[gg.curpage - 1]->vwbase; + vw = current_page->vwbase; while (vw != NULL && (vw->x != x || vw->y1 > y || vw->y2 < y)) vw = vw->next; if (hw != NULL && vw != NULL && hw->node != vw->node) @@ -2494,6 +2502,8 @@ static void cutcopy(baseptrs *bases, short x1, short y1, short x2, short y2, int int found; blobrec *blbase; + log_page *current_page = get_current_page(); + clearbuf(bases); anchorx = x2; anchory = y2; @@ -2536,7 +2546,7 @@ static void cutcopy(baseptrs *bases, short x1, short y1, short x2, short y2, int sortshints(&x1, &x2); sortshints(&y1, &y2); bases->pgnum = gg.curpage; - g = gg.pages[gg.curpage - 1]->gbase; + g = current_page->gbase; while (g != NULL) { g1 = g->next; @@ -2557,7 +2567,7 @@ static void cutcopy(baseptrs *bases, short x1, short y1, short x2, short y2, int } g = g1; } - s = gg.pages[gg.curpage - 1]->sbase; + s = current_page->sbase; while (s != NULL) { if (tap) @@ -2577,7 +2587,7 @@ static void cutcopy(baseptrs *bases, short x1, short y1, short x2, short y2, int } s = s->next; } - hw = gg.pages[gg.curpage - 1]->hwbase; + hw = current_page->hwbase; while (hw != NULL) { hw1 = hw->next; @@ -2623,7 +2633,7 @@ static void cutcopy(baseptrs *bases, short x1, short y1, short x2, short y2, int } hw = hw1; } - vw = gg.pages[gg.curpage - 1]->vwbase; + vw = current_page->vwbase; while (vw != NULL) { vw1 = vw->next; @@ -2669,7 +2679,7 @@ static void cutcopy(baseptrs *bases, short x1, short y1, short x2, short y2, int } vw = vw1; } - l = gg.pages[gg.curpage - 1]->lbase; + l = current_page->lbase; while (l != NULL) { l1 = l->next; @@ -2699,7 +2709,7 @@ static void cutcopy(baseptrs *bases, short x1, short y1, short x2, short y2, int } l = l1; } - b = gg.pages[gg.curpage - 1]->bbase; + b = current_page->bbase; while (b != NULL) { b1 = b->next; @@ -2726,7 +2736,7 @@ static void cutcopy(baseptrs *bases, short x1, short y1, short x2, short y2, int b = b1; } bases->valid = true; - if (isPageEmpty(gg.pages[gg.curpage - 1]) && curfilename[gg.curpage - 1] != NULL) + if (isPageEmpty(current_page) && curfilename[gg.curpage - 1] != NULL) Free(curfilename[gg.curpage - 1]); } @@ -3081,6 +3091,8 @@ static void pastebuf(baseptrs *bases, short x, short y) log_lrec *l, *l1; log_brec *b, *b1; + log_page *current_page = get_current_page(); + clipon(); g = bases->gcopy; while (g != NULL) @@ -3140,8 +3152,8 @@ static void pastebuf(baseptrs *bases, short x, short y) while (l != NULL) { l1 = (log_lrec *)Malloc(sizeof(log_lrec)); - l1->next = gg.pages[gg.curpage - 1]->lbase; - gg.pages[gg.curpage - 1]->lbase = l1; + l1->next = current_page->lbase; + current_page->lbase = l1; l1->x = l->x + x; l1->y = l->y + y; strcpy(l1->name, l->name); @@ -3155,7 +3167,7 @@ static void pastebuf(baseptrs *bases, short x, short y) logfont_lfont, l1->name); } clipoff(); - chpageplace(gg.pages[gg.curpage - 1], l1->x, l1->y, l1->x + l1->w, l1->y + 2); + chpageplace(current_page, l1->x, l1->y, l1->x + l1->w, l1->y + 2); stamp(&gg.labelstamp); l = l->next; } @@ -3164,8 +3176,8 @@ static void pastebuf(baseptrs *bases, short x, short y) while (b != NULL) { b1 = (log_brec *)Malloc(sizeof(log_brec)); - b1->next = gg.pages[gg.curpage - 1]->bbase; - gg.pages[gg.curpage - 1]->bbase = b1; + b1->next = current_page->bbase; + current_page->bbase = b1; b1->x1 = b->x1 + x; b1->y1 = b->y1 + y; b1->x2 = b->x2 + x; @@ -3175,7 +3187,7 @@ static void pastebuf(baseptrs *bases, short x, short y) if (!gg.textinvisible) drawboxc(b1, gg.color.dashbox); clipoff(); - chpageplace(gg.pages[gg.curpage - 1], b1->x1, b1->y1, b1->x2, b1->y2); + chpageplace(current_page, b1->x1, b1->y1, b1->x2, b1->y2); stamp(&gg.boxstamp); b = b->next; } @@ -3402,6 +3414,8 @@ static void moveobject() log_vwrec *vw1; blobrec *blbase, *blp; + log_page *current_page = get_current_page(); + closergate(gg.posx, gg.posy); oldpg = gg.curpage; gg.gridx = gg.posx; @@ -3462,7 +3476,7 @@ static void moveobject() oldy1 = gg.nearlabel->y; oldx2 = oldx1 + gg.nearlabel->w; oldy2 = oldy1 + 2; - chpageplace(gg.pages[gg.curpage - 1], oldx1, oldy1, oldx2, oldy2); + chpageplace(current_page, oldx1, oldy1, oldx2, oldy2); stamp(&gg.labelstamp); clipon(); eralabel(gg.nearlabel); @@ -3516,7 +3530,7 @@ static void moveobject() gg.posy * gg.scale - gg.yoff + 2, logfont_lfont, gg.nearlabel->name); gg.refrflag = true; - chpageplace(gg.pages[gg.curpage - 1], gg.nearlabel->x, gg.nearlabel->y, + chpageplace(current_page, gg.nearlabel->x, gg.nearlabel->y, gg.nearlabel->x + gg.nearlabel->w, gg.nearlabel->y + 2); } else @@ -3539,7 +3553,7 @@ static void moveobject() oldy1 = gg.nearbox->y1; oldx2 = gg.nearbox->x2; oldy2 = gg.nearbox->y2; - chpageplace(gg.pages[gg.curpage - 1], oldx1, oldy1, oldx2, oldy2); + chpageplace(current_page, oldx1, oldy1, oldx2, oldy2); stamp(&gg.boxstamp); clipon(); drawboxc(gg.nearbox, gg.color.backgr); @@ -3628,7 +3642,7 @@ static void moveobject() clipon(); drawboxc(gg.nearbox, gg.color.dashbox); clipoff(); - chpageplace(gg.pages[gg.curpage - 1], gg.nearbox->x1, gg.nearbox->y1, + chpageplace(current_page, gg.nearbox->x1, gg.nearbox->y1, gg.nearbox->x2, gg.nearbox->y2); gg.refrflag = true; } @@ -3737,7 +3751,7 @@ static void moveobject() vc = gg.nearvw->wcolr; } blbase = NULL; - s = gg.pages[gg.curpage - 1]->sbase; + s = current_page->sbase; while (s != NULL) { if ((gg.nearhw != NULL && (s->hwire == gg.nearhw || s->hwire2 == gg.nearhw)) || @@ -3872,7 +3886,7 @@ static void moveobject() { if (blp->hw != NULL) { - hw1 = gg.pages[gg.curpage - 1]->hwbase; + hw1 = current_page->hwbase; while (hw1 != NULL && (hw1->node != blp->hw->node || !P_ibetween((long)hw1->x1, (long)vx, (long)hw1->x2) || @@ -3891,7 +3905,7 @@ static void moveobject() } else if (blp->vw != NULL) { - vw1 = gg.pages[gg.curpage - 1]->vwbase; + vw1 = current_page->vwbase; while (vw1 != NULL && (vw1->node != blp->vw->node || !P_ibetween((long)vw1->y1, (long)hy, (long)vw1->y2) || @@ -4021,8 +4035,9 @@ static void openhoriz() if (gg.incircuit && *gg.func == '\0') { - chpage(gg.pages[gg.curpage - 1]); - vw = gg.pages[gg.curpage - 1]->vwbase; + chpage(get_current_page()); + log_page *current_page = get_current_page(); + vw = current_page->vwbase; flag = false; while (vw != NULL) { @@ -4035,14 +4050,14 @@ static void openhoriz() if (!flag) { - g = gg.pages[gg.curpage - 1]->gbase; + g = current_page->gbase; 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.pages[gg.curpage - 1]->sbase; + s = current_page->sbase; while (s != NULL) { @@ -4051,7 +4066,7 @@ static void openhoriz() s->x += x1 - gg.posx; s = s->next; } - hw = gg.pages[gg.curpage - 1]->hwbase; + hw = current_page->hwbase; while (hw != NULL) { @@ -4064,7 +4079,7 @@ static void openhoriz() } hw = hw->next; } - vw = gg.pages[gg.curpage - 1]->vwbase; + vw = current_page->vwbase; while (vw != NULL) { @@ -4072,7 +4087,7 @@ static void openhoriz() vw->x += x1 - gg.posx; vw = vw->next; } - b = gg.pages[gg.curpage - 1]->bbase; + b = current_page->bbase; while (b != NULL) { @@ -4085,7 +4100,7 @@ static void openhoriz() } b = b->next; } - l = gg.pages[gg.curpage - 1]->lbase; + l = current_page->lbase; while (l != NULL) { @@ -4187,8 +4202,9 @@ static void openvert() remcursor(); if (gg.incircuit && *gg.func == '\0') { - chpage(gg.pages[gg.curpage - 1]); - hw = gg.pages[gg.curpage - 1]->hwbase; + chpage(get_current_page()); + log_page *current_page = get_current_page(); + hw = current_page->hwbase; flag = false; while (hw != NULL) @@ -4202,14 +4218,14 @@ static void openvert() if (!flag) { - g = gg.pages[gg.curpage - 1]->gbase; + g = current_page->gbase; 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.pages[gg.curpage - 1]->sbase; + s = current_page->sbase; while (s != NULL) { @@ -4218,7 +4234,7 @@ static void openvert() s->y += y1 - gg.posy; s = s->next; } - vw = gg.pages[gg.curpage - 1]->vwbase; + vw = current_page->vwbase; while (vw != NULL) { @@ -4231,7 +4247,7 @@ static void openvert() } vw = vw->next; } - hw = gg.pages[gg.curpage - 1]->hwbase; + hw = current_page->hwbase; while (hw != NULL) { @@ -4240,7 +4256,7 @@ static void openvert() hw = hw->next; } - b = gg.pages[gg.curpage - 1]->bbase; + b = current_page->bbase; while (b != NULL) { if (gg.posx <= b->x1 && b->x2 <= x1) @@ -4252,7 +4268,7 @@ static void openvert() } b = b->next; } - l = gg.pages[gg.curpage - 1]->lbase; + l = current_page->lbase; while (l != NULL) { if (gg.posx <= l->x && l->x <= x1 && l->y >= gg.posy) @@ -4349,8 +4365,9 @@ static void closehoriz() remcursor(); if (gg.incircuit && *gg.func == '\0') { - chpage(gg.pages[gg.curpage - 1]); - vw = gg.pages[gg.curpage - 1]->vwbase; + chpage(get_current_page()); + log_page *current_page = get_current_page(); + vw = current_page->vwbase; flag = false; while (vw != NULL) { @@ -4363,7 +4380,7 @@ static void closehoriz() if (!flag) { - g = gg.pages[gg.curpage - 1]->gbase; + g = current_page->gbase; while (g != NULL) { g1 = g->next; @@ -4376,7 +4393,7 @@ static void closehoriz() } g = g1; } - s = gg.pages[gg.curpage - 1]->sbase; + s = current_page->sbase; while (s != NULL) { @@ -4389,7 +4406,7 @@ static void closehoriz() } s = s1; } - hw = gg.pages[gg.curpage - 1]->hwbase; + hw = current_page->hwbase; while (hw != NULL) { @@ -4400,7 +4417,7 @@ static void closehoriz() } hw = hw1; } - vw = gg.pages[gg.curpage - 1]->vwbase; + vw = current_page->vwbase; while (vw != NULL) { @@ -4410,7 +4427,7 @@ static void closehoriz() delvwire(vw); vw = vw1; } - hw = gg.pages[gg.curpage - 1]->hwbase; + hw = current_page->hwbase; while (hw != NULL) { @@ -4439,7 +4456,7 @@ static void closehoriz() } hw = hw->next; } - vw = gg.pages[gg.curpage - 1]->vwbase; + vw = current_page->vwbase; while (vw != NULL) { @@ -4447,7 +4464,7 @@ static void closehoriz() vw->x += gg.posx - x1; vw = vw->next; } - b = gg.pages[gg.curpage - 1]->bbase; + b = current_page->bbase; while (b != NULL) { @@ -4482,7 +4499,7 @@ static void closehoriz() } b = b1; } - l = gg.pages[gg.curpage - 1]->lbase; + l = current_page->lbase; while (l != NULL) { @@ -4587,8 +4604,9 @@ static void closevert() remcursor(); if (gg.incircuit && *gg.func == '\0') { - chpage(gg.pages[gg.curpage - 1]); - hw = gg.pages[gg.curpage - 1]->hwbase; + chpage(get_current_page()); + log_page *current_page = get_current_page(); + hw = current_page->hwbase; flag = false; while (hw != NULL) { @@ -4601,7 +4619,7 @@ static void closevert() if (!flag) { - g = gg.pages[gg.curpage - 1]->gbase; + g = current_page->gbase; while (g != NULL) { g1 = g->next; @@ -4614,7 +4632,7 @@ static void closevert() } g = g1; } - s = gg.pages[gg.curpage - 1]->sbase; + s = current_page->sbase; while (s != NULL) { @@ -4627,7 +4645,7 @@ static void closevert() } s = s1; } - vw = gg.pages[gg.curpage - 1]->vwbase; + vw = current_page->vwbase; while (vw != NULL) { @@ -4639,7 +4657,7 @@ static void closevert() } vw = vw1; } - hw = gg.pages[gg.curpage - 1]->hwbase; + hw = current_page->hwbase; while (hw != NULL) { @@ -4649,7 +4667,7 @@ static void closevert() delhwire(hw); hw = hw1; } - vw = gg.pages[gg.curpage - 1]->vwbase; + vw = current_page->vwbase; while (vw != NULL) { @@ -4678,7 +4696,7 @@ static void closevert() } vw = vw->next; } - hw = gg.pages[gg.curpage - 1]->hwbase; + hw = current_page->hwbase; while (hw != NULL) { @@ -4686,7 +4704,7 @@ static void closevert() hw->y += gg.posy - y1; hw = hw->next; } - b = gg.pages[gg.curpage - 1]->bbase; + b = current_page->bbase; while (b != NULL) { @@ -4721,7 +4739,7 @@ static void closevert() } b = b1; } - l = gg.pages[gg.curpage - 1]->lbase; + l = current_page->lbase; while (l != NULL) { @@ -4768,18 +4786,20 @@ static void centercommand() log_lrec *l; log_brec *b; short dx, dy, x1, y1, x2, y2; + log_page *current_page; 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.pages[gg.curpage - 1]->gbase; + current_page = get_current_page(); + g = current_page->gbase; while (g != NULL) { shiftgate(g, dx, dy); g = g->next; } - hw = gg.pages[gg.curpage - 1]->hwbase; + hw = current_page->hwbase; while (hw != NULL) { @@ -4788,7 +4808,7 @@ static void centercommand() hw->y += dy; hw = hw->next; } - vw = gg.pages[gg.curpage - 1]->vwbase; + vw = current_page->vwbase; while (vw != NULL) { @@ -4797,7 +4817,7 @@ static void centercommand() vw->y2 += dy; vw = vw->next; } - s = gg.pages[gg.curpage - 1]->sbase; + s = current_page->sbase; while (s != NULL) { @@ -4805,7 +4825,7 @@ static void centercommand() s->y += dy; s = s->next; } - l = gg.pages[gg.curpage - 1]->lbase; + l = current_page->lbase; while (l != NULL) { @@ -4813,7 +4833,7 @@ static void centercommand() l->y += dy; l = l->next; } - b = gg.pages[gg.curpage - 1]->bbase; + b = current_page->bbase; while (b != NULL) { @@ -6205,7 +6225,7 @@ end; */ } } stamp(attrstamp); - chpage(gg.pages[gg.curpage - 1]); + chpage(get_current_page()); } else if (ch == '\b') { @@ -6295,7 +6315,7 @@ end; */ } } stamp(attrstamp); - chpage(gg.pages[gg.curpage - 1]); + chpage(get_current_page()); } else { @@ -6543,7 +6563,7 @@ end; */ break; } stamp(attrstamp); - chpage(gg.pages[gg.curpage - 1]); + chpage(get_current_page()); drawvalue(V.p, false, &V); } } while (!exitflag); @@ -7181,6 +7201,8 @@ static void touchgate(log_grec *g) { short xx, yy; + log_page *current_page = get_current_page(); + if (g->kind->flag.U3.named) { adjustsignal(g); @@ -7198,7 +7220,7 @@ static void touchgate(log_grec *g) calltoolgate(g, act_touchgate); if (gg.actflag) - chpageplace(gg.pages[gg.curpage - 1], g->x - g->kind->bbmax, g->y - g->kind->bbmax, + chpageplace(current_page, g->x - g->kind->bbmax, g->y - g->kind->bbmax, g->x + g->kind->bbmax, g->y + g->kind->bbmax); else if (!gg.invisible || g->kind->flag.U3.visible) flipgate(g); @@ -10585,6 +10607,8 @@ void dofunction() short FORLIM; unsigned char TEMP; + log_page *current_page = get_current_page(); + TRY(try30); remcursor(); doimmedfunction(); @@ -10682,9 +10706,9 @@ void dofunction() else if (!strcmp(gg.func, "VLSI")) { clearfunc(); - if (gg.pages[gg.curpage - 1]->gbase == NULL && - gg.pages[gg.curpage - 1]->hwbase == NULL && - gg.pages[gg.curpage - 1]->vwbase == NULL) + if (current_page->gbase == NULL && + current_page->hwbase == NULL && + current_page->vwbase == NULL) setvlsimode(!vlsi); } else if (!strcmp(gg.func, "FAST")) diff --git a/src/node.c b/src/node.c index 5fb8a21..8992fe0 100644 --- a/src/node.c +++ b/src/node.c @@ -192,6 +192,8 @@ void dumpnodes() short FORLIM; log_krec *WITH; + log_page *current_page = get_current_page(); + trace_message("\n"); sysdate(&datevar); systime(&timevar); @@ -240,7 +242,7 @@ void dumpnodes() trace_message(" Internal error, %d\n", P_escapecode); ENDTRY(try6); trace_message("\n"); - hw = gg.pages[gg.curpage - 1]->hwbase; + hw = current_page->hwbase; trace_message("HWIRES\n"); TRY(try8); while (hw != NULL) @@ -256,7 +258,7 @@ void dumpnodes() trace_message(" Internal error, %d\n", P_escapecode); ENDTRY(try8); trace_message("\n"); - vw = gg.pages[gg.curpage - 1]->vwbase; + vw = current_page->vwbase; trace_message("VWIRES\n"); TRY(try9); while (vw != NULL) @@ -272,7 +274,7 @@ void dumpnodes() trace_message(" Internal error, %d\n", P_escapecode); ENDTRY(try9); trace_message("\n"); - s = gg.pages[gg.curpage - 1]->sbase; + s = current_page->sbase; trace_message("SOLDER\n"); TRY(try10); while (s != NULL) @@ -290,7 +292,7 @@ void dumpnodes() trace_message(" Internal error, %d\n", P_escapecode); ENDTRY(try10); trace_message("\n"); - g = gg.pages[gg.curpage - 1]->gbase; + g = current_page->gbase; trace_message("GATES\n"); TRY(try11); while (g != NULL) diff --git a/src/page.c b/src/page.c index ea53104..04ddf8b 100644 --- a/src/page.c +++ b/src/page.c @@ -287,3 +287,7 @@ void pageClear(log_page *page) } } +log_page *get_current_page() +{ + return gg.pages[gg.curpage - 1]; +} diff --git a/src/window.c b/src/window.c index 10092ee..7f6e814 100644 --- a/src/window.c +++ b/src/window.c @@ -1649,6 +1649,8 @@ void drawnodec(log_nrec *n, int c) if (gg.invisible || (gg.showconflicts == true && n->conflict == false)) return; + log_page *current_page = get_current_page(); + hidecursor(); if ((unsigned)c > 15) { @@ -1659,7 +1661,7 @@ void drawnodec(log_nrec *n, int c) } if (vlsi && c == gg.color.wire[0]) { - hw = gg.pages[gg.curpage - 1]->hwbase; + hw = current_page->hwbase; while (hw != NULL) { if (hw->node == n && hw != gg.movinghw) @@ -1669,7 +1671,7 @@ void drawnodec(log_nrec *n, int c) } hw = hw->next; } - vw = gg.pages[gg.curpage - 1]->vwbase; + vw = current_page->vwbase; while (vw != NULL) { if (vw->node == n && vw != gg.movingvw) @@ -1683,13 +1685,13 @@ void drawnodec(log_nrec *n, int c) else { m_color((long)c); - hw = gg.pages[gg.curpage - 1]->hwbase; + hw = current_page->hwbase; while (hw != NULL) { if (hw->node == n && hw != gg.movinghw) hline(hw->x1, hw->x2, hw->y); hw = hw->next; } - vw = gg.pages[gg.curpage - 1]->vwbase; + vw = current_page->vwbase; while (vw != NULL) { if (vw->node == n && vw != gg.movingvw) @@ -1699,7 +1701,7 @@ void drawnodec(log_nrec *n, int c) } if (showsolder) { - s = gg.pages[gg.curpage - 1]->sbase; + s = current_page->sbase; while (s != NULL) { if ((s->hwire != NULL && s->hwire->node == n) || @@ -1808,6 +1810,8 @@ void refresh() log_lrec *l; log_brec *b; + log_page *current_page = get_current_page(); + stamp(&gg.refrstamp); gg.showpage = gg.curpage; showsolder = (zoom > -1 && (vlsi || !gg.glowmode || glowsolder)); @@ -1822,7 +1826,7 @@ void refresh() if (!gg.invisible && !gg.showconflicts) { suppressdots = gg.dotsvisible; - g = gg.pages[gg.curpage - 1]->gbase; + g = current_page->gbase; while (g != NULL) { if (P_ibetweenm(x1, (long)g->x, x2, (long)g->kind->bbmax) && @@ -1833,7 +1837,7 @@ void refresh() suppressdots = false; if (gg.glowmode) { - hw = gg.pages[gg.curpage - 1]->hwbase; + hw = current_page->hwbase; while (hw != NULL) { if (hw->y > y1 && hw->y < y2 && hw != gg.movinghw) @@ -1844,7 +1848,7 @@ void refresh() } hw = hw->next; } - vw = gg.pages[gg.curpage - 1]->vwbase; + vw = current_page->vwbase; while (vw != NULL) { if (vw->x > x1 && vw->x < x2 && vw != gg.movingvw) @@ -1857,7 +1861,7 @@ void refresh() } if (showsolder) { - s = gg.pages[gg.curpage - 1]->sbase; + s = current_page->sbase; while (s != NULL) { if (s->hwire != NULL) @@ -1872,7 +1876,7 @@ void refresh() else { m_color((long)gg.color.wire[0]); - hw = gg.pages[gg.curpage - 1]->hwbase; + hw = current_page->hwbase; while (hw != NULL) { if (hw->y > y1 && hw->y < y2 && hw != gg.movinghw) @@ -1883,7 +1887,7 @@ void refresh() } hw = hw->next; } - vw = gg.pages[gg.curpage - 1]->vwbase; + vw = current_page->vwbase; while (vw != NULL) { if (vw->x > x1 && vw->x < x2 && vw != gg.movingvw) @@ -1896,7 +1900,7 @@ void refresh() } if (showsolder) { - s = gg.pages[gg.curpage - 1]->sbase; + s = current_page->sbase; while (s != NULL) { if (s->hwire != NULL) @@ -1911,7 +1915,7 @@ void refresh() if (gg.dotsvisible) { - g = gg.pages[gg.curpage - 1]->gbase; + g = current_page->gbase; while (g != NULL) { if (g->x > x1 && g->x < x2 && g->y > y1 && g->y < y2) @@ -1922,7 +1926,7 @@ void refresh() } else { - g = gg.pages[gg.curpage - 1]->gbase; + g = current_page->gbase; while (g != NULL) { if (g->kind->flag.U3.visible) @@ -1932,13 +1936,13 @@ void refresh() } if (!gg.textinvisible) { - b = gg.pages[gg.curpage - 1]->bbase; + b = current_page->bbase; while (b != NULL) { drawboxc(b, gg.color.dashbox); b = b->next; } - l = gg.pages[gg.curpage - 1]->lbase; + l = current_page->lbase; m_color((long)gg.color.labeltext); while (l != NULL) { diff --git a/src/wire.c b/src/wire.c index 5312633..4553330 100644 --- a/src/wire.c +++ b/src/wire.c @@ -84,9 +84,10 @@ void markcolor(log_hwrec **hw, struct LOC_wantsolder *LINK) /// Create a Horizontal Wire. void newhw(log_hwrec **hw) { + log_page *current_page = get_current_page(); *hw = (log_hwrec *)Malloc(sizeof(log_hwrec)); - (*hw)->next = gg.pages[gg.curpage - 1]->hwbase; - gg.pages[gg.curpage - 1]->hwbase = *hw; + (*hw)->next = current_page->hwbase; + current_page->hwbase = *hw; (*hw)->temp = (na_long)0; } @@ -99,13 +100,15 @@ void disphw(log_hwrec **hw) { log_hwrec *hw1; + log_page *current_page = get_current_page(); + trace_message("Dispose hwire %ld\n", (long)(*hw)); if (*hw == NULL) return; - hw1 = gg.pages[gg.curpage - 1]->hwbase; + hw1 = current_page->hwbase; if (*hw == hw1) { - gg.pages[gg.curpage - 1]->hwbase = (*hw)->next; + current_page->hwbase = (*hw)->next; } else { @@ -116,7 +119,7 @@ void disphw(log_hwrec **hw) else hw1->next = (*hw)->next; } - chpageplace(gg.pages[gg.curpage - 1], (*hw)->x1, (*hw)->y, (*hw)->x2, (*hw)->y); + chpageplace(current_page, (*hw)->x1, (*hw)->y, (*hw)->x2, (*hw)->y); Free(*hw); } @@ -126,9 +129,11 @@ void disphw(log_hwrec **hw) /// Create a Vertical Wire. void newvw(log_vwrec **vw) { + log_page *current_page = get_current_page(); + *vw = (log_vwrec *)Malloc(sizeof(log_vwrec)); - (*vw)->next = gg.pages[gg.curpage - 1]->vwbase; - gg.pages[gg.curpage - 1]->vwbase = *vw; + (*vw)->next = current_page->vwbase; + current_page->vwbase = *vw; (*vw)->temp = (na_long)0; } @@ -141,13 +146,15 @@ void dispvw(log_vwrec **vw) { log_vwrec *vw1; + log_page *current_page = get_current_page(); + trace_message("Dispose vwire %ld\n", (long)(*vw)); if (*vw == NULL) return; - vw1 = gg.pages[gg.curpage - 1]->vwbase; + vw1 = current_page->vwbase; if (*vw == vw1) { - gg.pages[gg.curpage - 1]->vwbase = (*vw)->next; + current_page->vwbase = (*vw)->next; } else { @@ -158,7 +165,7 @@ void dispvw(log_vwrec **vw) else vw1->next = (*vw)->next; } - chpageplace(gg.pages[gg.curpage - 1], (*vw)->x, (*vw)->y1, (*vw)->x, (*vw)->y2); + chpageplace(current_page, (*vw)->x, (*vw)->y1, (*vw)->x, (*vw)->y2); Free(*vw); } @@ -167,9 +174,11 @@ void dispvw(log_vwrec **vw) /// Create a solder point. void newsolder(log_srec **s) { + log_page *current_page = get_current_page(); + *s = (log_srec *)Malloc(sizeof(log_srec)); - (*s)->next = gg.pages[gg.curpage - 1]->sbase; - gg.pages[gg.curpage - 1]->sbase = *s; + (*s)->next = current_page->sbase; + current_page->sbase = *s; (*s)->hwire = NULL; (*s)->hwire2 = NULL; (*s)->vwire = NULL; @@ -186,13 +195,15 @@ void dispsolder(log_srec **s) { log_srec *s1; + log_page *current_page = get_current_page(); + trace_message("Dispose solder %ld\n", (long)(*s)); if (*s == NULL) return; - s1 = gg.pages[gg.curpage - 1]->sbase; + s1 = current_page->sbase; if (*s == s1) { - gg.pages[gg.curpage - 1]->sbase = (*s)->next; + current_page->sbase = (*s)->next; } else { @@ -203,7 +214,7 @@ void dispsolder(log_srec **s) else s1->next = (*s)->next; } - chpageplace(gg.pages[gg.curpage - 1], (*s)->x, (*s)->y, (*s)->x, (*s)->y); + chpageplace(current_page, (*s)->x, (*s)->y, (*s)->x, (*s)->y); Free(*s); } @@ -218,11 +229,14 @@ void closerwire(short x, short y) gg.nearvw = NULL; return; } - gg.nearhw = gg.pages[gg.curpage - 1]->hwbase; + + log_page *current_page = get_current_page(); + + gg.nearhw = current_page->hwbase; while (gg.nearhw != NULL && (gg.nearhw->y != y || gg.nearhw->x1 > x || gg.nearhw->x2 < x)) gg.nearhw = gg.nearhw->next; - gg.nearvw = gg.pages[gg.curpage - 1]->vwbase; + gg.nearvw = current_page->vwbase; while (gg.nearvw != NULL && (gg.nearvw->x != x || gg.nearvw->y1 > y || gg.nearvw->y2 < y)) gg.nearvw = gg.nearvw->next; @@ -239,14 +253,16 @@ void addsolder(short x, short y, log_hwrec *hw, log_hwrec *hw2, log_vwrec *vw, l log_srec *s; log_nrec *n; - s = gg.pages[gg.curpage - 1]->sbase; + log_page *current_page = get_current_page(); + + s = current_page->sbase; while (s != NULL && (s->x != x || s->y != y)) s = s->next; if (s == NULL) { newsolder(&s); s->x = x; s->y = y; - chpageplace(gg.pages[gg.curpage - 1], x, y, x, y); + chpageplace(current_page, x, y, x, y); s->hwire = NULL; s->hwire2 = NULL; s->vwire = NULL; @@ -306,7 +322,7 @@ log_srec *findsolder(short x, short y) { log_srec *s; - s = gg.pages[gg.curpage - 1]->sbase; + s = get_current_page()->sbase; while (s != NULL && (s->x != x || s->y != y)) s = s->next; return s; @@ -349,9 +365,11 @@ void chghw(log_hwrec *hw, log_nrec *oldnode, log_nrec *n) log_srec *s; short i, px, FORLIM; + log_page *current_page = get_current_page(); + trace_message("Change hwire %ld to node %ld\n", (long)hw, (long)n); switchnode(&hw->node, n); - g = gg.pages[gg.curpage - 1]->gbase; + g = current_page->gbase; while (g != NULL) { if (abs(g->y - hw->y) <= g->kind->bbmax && @@ -369,7 +387,7 @@ void chghw(log_hwrec *hw, log_nrec *oldnode, log_nrec *n) } g = g->next; } - vw = gg.pages[gg.curpage - 1]->vwbase; + vw = current_page->vwbase; while (vw != NULL) { if (hw->x1 <= vw->x && vw->x <= hw->x2 && vw->y1 <= hw->y && @@ -382,7 +400,7 @@ void chghw(log_hwrec *hw, log_nrec *oldnode, log_nrec *n) chgvw(vw, oldnode, n); else { /*vlsi only*/ - s = gg.pages[gg.curpage - 1]->sbase; + s = current_page->sbase; while (s != NULL && (s->x != vw->x || s->y != hw->y)) s = s->next; if (s != NULL) @@ -391,7 +409,7 @@ void chghw(log_hwrec *hw, log_nrec *oldnode, log_nrec *n) } vw = vw->next; } - hw1 = gg.pages[gg.curpage - 1]->hwbase; + hw1 = current_page->hwbase; while (hw1 != NULL && vlsi) { if (hw->y == hw1->y && (hw->x1 == hw1->x2 || hw->x2 == hw1->x1) && @@ -416,9 +434,11 @@ void chgvw(log_vwrec *vw, log_nrec *oldnode, log_nrec *n) log_srec *s; short i, py, FORLIM; + log_page *current_page = get_current_page(); + trace_message("Change vwire %ld to node %ld\n", (long)vw, (long)n); switchnode(&vw->node, n); - g = gg.pages[gg.curpage - 1]->gbase; + g = current_page->gbase; while (g != NULL) { if (abs(g->x - vw->x) <= g->kind->bbmax && @@ -436,7 +456,7 @@ void chgvw(log_vwrec *vw, log_nrec *oldnode, log_nrec *n) } g = g->next; } - hw = gg.pages[gg.curpage - 1]->hwbase; + hw = current_page->hwbase; while (hw != NULL) { if (hw->x1 <= vw->x && vw->x <= hw->x2 && vw->y1 <= hw->y && @@ -446,7 +466,7 @@ void chgvw(log_vwrec *vw, log_nrec *oldnode, log_nrec *n) chghw(hw, oldnode, n); else { - s = gg.pages[gg.curpage - 1]->sbase; + s = current_page->sbase; while (s != NULL && (s->x != vw->x || s->y != hw->y)) s = s->next; if (s != NULL) @@ -455,7 +475,7 @@ void chgvw(log_vwrec *vw, log_nrec *oldnode, log_nrec *n) } hw = hw->next; } - vw1 = gg.pages[gg.curpage - 1]->vwbase; + vw1 = current_page->vwbase; while (vw1 != NULL && vlsi) { if (vw->x == vw1->x && (vw->y1 == vw1->y2 || vw->y2 == vw1->y1) && @@ -493,6 +513,8 @@ void delhwire(log_hwrec *hw) log_grec *g; short i, x, y, FORLIM; + log_page *current_page = get_current_page(); + trace_message("Delete hwire %ld\n", (long)hw); clipon(); m_color((long)gg.color.backgr); @@ -500,7 +522,7 @@ void delhwire(log_hwrec *hw) oldnode = hw->node; stamp(&oldnode->simtype->netstamp); switchnode(&hw->node, NULL); - s = gg.pages[gg.curpage - 1]->sbase; + s = current_page->sbase; while (s != NULL) { s1 = s->next; @@ -521,7 +543,7 @@ void delhwire(log_hwrec *hw) } s = s1; } - vw = gg.pages[gg.curpage - 1]->vwbase; + vw = current_page->vwbase; while (vw != NULL) { if (hw->x1 <= vw->x && vw->x <= hw->x2 && vw->y1 <= hw->y && @@ -533,7 +555,7 @@ void delhwire(log_hwrec *hw) } vw = vw->next; } - hw1 = gg.pages[gg.curpage - 1]->hwbase; + hw1 = current_page->hwbase; while (hw1 != NULL && vlsi) { if (hw->y == hw1->y && (hw1->x1 == hw->x2 || hw1->x2 == hw->x1) && @@ -544,7 +566,7 @@ void delhwire(log_hwrec *hw) } hw1 = hw1->next; } - g = gg.pages[gg.curpage - 1]->gbase; + g = current_page->gbase; while (g != NULL) { if (abs(g->y - hw->y) <= g->kind->bbmax && @@ -583,6 +605,8 @@ void delvwire(log_vwrec *vw) log_grec *g; short i, x, y, FORLIM; + log_page *current_page = get_current_page(); + trace_message("Delete vwire %ld\n", (long)vw); clipon(); m_color((long)gg.color.backgr); @@ -590,7 +614,7 @@ void delvwire(log_vwrec *vw) oldnode = vw->node; stamp(&oldnode->simtype->netstamp); switchnode(&vw->node, NULL); - s = gg.pages[gg.curpage - 1]->sbase; + s = current_page->sbase; while (s != NULL) { s1 = s->next; @@ -610,7 +634,7 @@ void delvwire(log_vwrec *vw) } s = s1; } - hw = gg.pages[gg.curpage - 1]->hwbase; + hw = current_page->hwbase; while (hw != NULL) { if (hw->x1 <= vw->x && vw->x <= hw->x2 && vw->y1 <= hw->y && @@ -622,7 +646,7 @@ void delvwire(log_vwrec *vw) } hw = hw->next; } - vw1 = gg.pages[gg.curpage - 1]->vwbase; + vw1 = current_page->vwbase; while (vw1 != NULL && vlsi) { if (vw->x == vw1->x && (vw1->y1 == vw->y2 || vw1->y2 == vw->y1) && @@ -634,7 +658,7 @@ void delvwire(log_vwrec *vw) } vw1 = vw1->next; } - g = gg.pages[gg.curpage - 1]->gbase; + g = current_page->gbase; while (g != NULL) { if (abs(g->x - vw->x) <= g->kind->bbmax && @@ -684,6 +708,8 @@ void addhwire(short x1, short x2, short y, short colr) blobrec *blbase; short FORLIM; + log_page *current_page = get_current_page(); + trace_message("Add hwire %d-%d, %d\n", x1, x2, y); sortshints(&x1, &x2); cnbase = NULL; @@ -721,8 +747,8 @@ void addhwire(short x1, short x2, short y, short colr) hw->x2 = x2; hw->y = y; hw->wcolr = colr; - chpageplace(gg.pages[gg.curpage - 1], x1, y, x2, y); - g = gg.pages[gg.curpage - 1]->gbase; + chpageplace(current_page, x1, y, x2, y); + g = current_page->gbase; while (g != NULL) { if (abs(g->y - y) <= g->kind->bbmax && @@ -738,7 +764,7 @@ void addhwire(short x1, short x2, short y, short colr) } g = g->next; } - vw1 = gg.pages[gg.curpage - 1]->vwbase; + vw1 = current_page->vwbase; while (vw1 != NULL) { vx = vw1->x; @@ -763,7 +789,7 @@ void addhwire(short x1, short x2, short y, short colr) gg.nearhw = NULL; goto _L1; /*return*/ } - vw1 = gg.pages[gg.curpage - 1]->vwbase; + vw1 = current_page->vwbase; while (vw1 != NULL) { vx = vw1->x; @@ -831,6 +857,8 @@ void addvwire(short x, short y1, short y2, short colr) blobrec *blbase; short FORLIM; + log_page *current_page = get_current_page(); + trace_message("Add vwire %d, %d-%d\n", x, y1, y2); sortshints(&y1, &y2); cnbase = NULL; @@ -868,8 +896,8 @@ void addvwire(short x, short y1, short y2, short colr) vw->y2 = y2; vw->x = x; vw->wcolr = colr; - chpageplace(gg.pages[gg.curpage - 1], x, y1, x, y2); - g = gg.pages[gg.curpage - 1]->gbase; + chpageplace(current_page, x, y1, x, y2); + g = current_page->gbase; while (g != NULL) { if (abs(g->x - x) <= g->kind->bbmax && @@ -885,7 +913,7 @@ void addvwire(short x, short y1, short y2, short colr) } g = g->next; } - hw1 = gg.pages[gg.curpage - 1]->hwbase; + hw1 = current_page->hwbase; while (hw1 != NULL) { hy = hw1->y; @@ -911,7 +939,7 @@ void addvwire(short x, short y1, short y2, short colr) gg.nearvw = NULL; goto _L1; /*return*/ } - hw1 = gg.pages[gg.curpage - 1]->hwbase; + hw1 = current_page->hwbase; while (hw1 != NULL) { hy = hw1->y; -- GitLab