diff --git a/include/logglobals.h b/include/logglobals.h index f903a351dd9b49a78f16da4c084a06afb2ce97af..cfa6fb52505fe76a3a240e4925c038c75a6551f7 100644 --- a/include/logglobals.h +++ b/include/logglobals.h @@ -65,11 +65,6 @@ extern short curwcolor; /* Current VLSI wire color */ extern char cureditmode; /* Current editing (gate-tapping) mode */ extern short curlistgroup; /* Current group in library list */ -extern int vlsimode[log_maxpages]; /* Page contains VLSI circuits */ -extern long xoffp[log_maxpages], yoffp[log_maxpages]; -/* XOFF, YOFF for non-current pages */ -extern short gatecount[log_maxpages]; /* Highest used gate-ID number */ -extern char *curfilename[log_maxpages]; /* Name of last-loaded file */ extern long realcurpage; extern baseptrs copybuf; /* Del/Copy/Paste buffer */ diff --git a/include/page.h b/include/page.h index 6e4ad5c369c3dc11a4d7e851ba4d9a57e97d413b..9797ac924c51211c9ac2dd734a5e78961390155d 100644 --- a/include/page.h +++ b/include/page.h @@ -16,6 +16,13 @@ typedef struct log_regrec { } log_regrec; /* Sensitive region */ typedef struct log_page { + long xoffp; ///< XOFF for non-current pages + long yoffp; ///< YOFF for non-current pages + int vlsimode; ///< Page contains VLSI circuits + short gatecount; ///< Highest used gate-ID number + char *curfilename; ///< Name of last-loaded file + long pagestamp; + int pagechanged; log_grec *gbase; /* base gate of the page */ log_srec *sbase; /* base solderpoint of the page */ log_hwrec *hwbase; /* base horizontal wire of the page */ @@ -23,8 +30,6 @@ typedef struct log_page { log_lrec *lbase; /* base label of page */ log_brec *bbase; /* base box of page */ log_regrec *pageregions; /* base region of page */ - long pagestamp; - int pagechanged; } log_page; void chpage(log_page *page); diff --git a/src/display.c b/src/display.c index 81255dae0a7a9a135665a1da7dddf37491c9ffc2..57c7ef1e5ac6e32c86d48fcf59c5151e17cccf57 100644 --- a/src/display.c +++ b/src/display.c @@ -19,6 +19,7 @@ void setscale(short s) void zoomto(short z) { short s0, i, FORLIM; + log_page *page; if (-2 > z || z > 2 || z == zoom) { @@ -32,8 +33,9 @@ void zoomto(short z) FORLIM = gg.numpages; for (i = 0; i < FORLIM; i++) { - xoffp[i] = (xoffp[i] + across / 2) * gg.scale / s0 - across / 2; - yoffp[i] = (yoffp[i] + baseline / 2) * gg.scale / s0 - baseline / 2; + page = gg.pages[i]; + page->xoffp = (page->xoffp + across / 2) * gg.scale / s0 - across / 2; + page->yoffp = (page->yoffp + baseline / 2) * gg.scale / s0 - baseline / 2; } refrfunc(); } diff --git a/src/gate.c b/src/gate.c index 4042f5783b43b19f9410d074b1b9fa9205d18f5e..940afb5653a45afcbde27b7b266b1cf1f2f68f99 100644 --- a/src/gate.c +++ b/src/gate.c @@ -653,7 +653,7 @@ void addgate2(short x, short y, short gtype, short sig, log_gattrrec *attrs) log_page *current_page = get_current_page(); newgate2(&g, gtype, sig, attrs); - if (gatecount[gg.curpage - 1] == log_maxshint) + if (current_page->gatecount == log_maxshint) { i = 0; gmax = 0; @@ -670,12 +670,12 @@ void addgate2(short x, short y, short gtype, short sig, log_gattrrec *attrs) } } while (flag); g->gc = i; - gatecount[gg.curpage - 1] = gmax; + current_page->gatecount = gmax; } else { - gatecount[gg.curpage - 1]++; - g->gc = gatecount[gg.curpage - 1]; + current_page->gatecount++; + g->gc = current_page->gatecount; } g->x = x; g->y = y; diff --git a/src/log.c b/src/log.c index c8c64f04ba7c80832da78d171dfab4e8229ef99c..af38f89cf563a399d74b55df48b77950e6129693 100644 --- a/src/log.c +++ b/src/log.c @@ -133,11 +133,6 @@ short curwcolor; ///< Current VLSI wire color char cureditmode; ///< Current editing (gate-tapping) mode short curlistgroup; ///< Current group in library list -int vlsimode[log_maxpages]; ///< Page contains VLSI circuits -long xoffp[log_maxpages]; ///< XOFF for non-current pages -long yoffp[log_maxpages]; ///< YOFF for non-current pages -short gatecount[log_maxpages]; ///< Highest used gate-ID number -char *curfilename[log_maxpages]; ///< Name of last-loaded file long realcurpage; baseptrs copybuf; ///< Del/Copy/Paste buffer @@ -2036,6 +2031,8 @@ void doimmedfunction() char cmd[256]; strlist_t *l1; + log_page *current_page = get_current_page(); + if (*gg.func != '\0') { l1 = strlist_find(commandlist, gg.func); @@ -2154,10 +2151,10 @@ void doimmedfunction() } if (!strcmp(gg.func, "ALTPOSN")) { - xoff0 = xoffp[gg.curpage - 1] - gg.xoff; - yoff0 = yoffp[gg.curpage - 1] - gg.yoff; - xoffp[gg.curpage - 1] = gg.xoff; - yoffp[gg.curpage - 1] = gg.yoff; + xoff0 = current_page->xoffp - gg.xoff; + yoff0 = current_page->yoffp - gg.yoff; + current_page->xoffp = gg.xoff; + current_page->yoffp = gg.yoff; refrfunc(); return; } @@ -2736,8 +2733,8 @@ static void cutcopy(baseptrs *bases, short x1, short y1, short x2, short y2, int b = b1; } bases->valid = true; - if (isPageEmpty(current_page) && curfilename[gg.curpage - 1] != NULL) - Free(curfilename[gg.curpage - 1]); + if (isPageEmpty(current_page) && current_page->curfilename != NULL) + Free(current_page->curfilename); } @@ -5671,7 +5668,7 @@ void setvlsimode(int flag) else curwcolor = log_wcol_normal; vlsi = flag; - vlsimode[gg.curpage - 1] = vlsi; + get_current_page()->vlsimode = vlsi; } @@ -9003,7 +9000,7 @@ static void savecommand() sprintf(STR2, "No changes to page %d", pgnum); message(STR2); } - else if (curfilename[pgnum - 1] == NULL) + else if (gg.pages[pgnum - 1]->curfilename == NULL) { sprintf(STR2, "Page %d: no file name!", pgnum); message(STR2); @@ -9012,7 +9009,7 @@ static void savecommand() { sprintf(STR1, "Saving page %d", pgnum); message(STR1); - safesavepage(pgnum, curfilename[pgnum - 1]); + safesavepage(pgnum, gg.pages[pgnum - 1]->curfilename); } } } @@ -9020,8 +9017,9 @@ static void savecommand() { beginbottom(); nc_printf("File name to save: "); - if (curfilename[gg.curpage - 1] != NULL) - strcpy(filename, curfilename[gg.curpage - 1]); + log_page *current_page = get_current_page(); + if (current_page->curfilename != NULL) + strcpy(filename, current_page->curfilename); else *filename = '\0'; readlnpass(filename, 3); @@ -9041,12 +9039,14 @@ static void namecommand() { char filename[256]; char STR2[256], STR3[256]; + + log_page *current_page = get_current_page(); if (*gg.funcarg == '\0') { beginbottom(); nc_printf("File name for page %ld", gg.curpage); - if (curfilename[gg.curpage - 1] != NULL) - nc_printf(" [%s]", curfilename[gg.curpage - 1]); + if (current_page->curfilename != NULL) + nc_printf(" [%s]", current_page->curfilename); nc_printf(": "); readlnpass(filename, 0); endbottom(); @@ -9056,19 +9056,19 @@ static void namecommand() strcpy(filename, gg.funcarg); if (*filename != '\0') { if (!strcmp(filename, "\"\"") || *strcpy(STR3, strltrim(filename)) == '\0') - Free(curfilename[gg.curpage - 1]); + Free(current_page->curfilename); else { newci_fixfname(filename, "lgf", ""); - if (curfilename[gg.curpage - 1] == NULL) - curfilename[gg.curpage - 1] = (char *)Malloc(256); - strcpy(curfilename[gg.curpage - 1], filename); + if (current_page->curfilename == NULL) + current_page->curfilename = (char *)Malloc(256); + strcpy(current_page->curfilename, filename); } } - if (curfilename[gg.curpage - 1] == NULL) { + if (current_page->curfilename == NULL) { sprintf(STR2, "No file name for page %ld", gg.curpage); message(STR2); } else { - sprintf(STR2, "Current file name is %s", curfilename[gg.curpage - 1]); + sprintf(STR2, "Current file name is %s", current_page->curfilename); message(STR2); } clearfunc(); @@ -9672,8 +9672,8 @@ static void status_mem() else nc_printf("No "); - if (curfilename[i] != NULL) - nc_puts(curfilename[i]); + if (gg.pages[i]->curfilename != NULL) + nc_puts(gg.pages[i]->curfilename); } else { @@ -11598,14 +11598,14 @@ static void initialize() *gg.genfunc = '\0'; gg.xoff = origin; gg.yoff = origin; - xoffp[0] = origin; - yoffp[0] = origin; + get_current_page()->xoffp = origin; + get_current_page()->yoffp = origin; xoff0 = 0; yoff0 = 0; - gatecount[0] = 0; + get_current_page()->gatecount = 0; gg.nbase = NULL; stamp(&gg.pages[0]->pagestamp); - curfilename[0] = NULL; + get_current_page()->curfilename = NULL; initbuf(©buf); nodeconflictbase = NULL; gateconflictbase = NULL; diff --git a/src/page.c b/src/page.c index 04ddf8b57e62b168abc1777903188f021167f997..d6b0521a8e41cf0f95b5afe5d988a1b8a87d62ca 100644 --- a/src/page.c +++ b/src/page.c @@ -80,9 +80,9 @@ void newpage(short pg) garbagecoll(); for (i = gg.numpages; i < pg; i++) { - xoffp[i] = (origin + across / 2) * gg.scale / log_scale0 - across / 2; - yoffp[i] = (origin + baseline / 2) * gg.scale / log_scale0 - baseline / 2; - gatecount[i] = 0; + gg.pages[i]->xoffp = (origin + across / 2) * gg.scale / log_scale0 - across / 2; + gg.pages[i]->yoffp = (origin + baseline / 2) * gg.scale / log_scale0 - baseline / 2; + gg.pages[i]->gatecount = 0; gg.pages[i]->gbase = NULL; gg.pages[i]->sbase = NULL; gg.pages[i]->hwbase = NULL; @@ -92,16 +92,16 @@ void newpage(short pg) gg.pages[i]->pagechanged = false; stamp(&gg.pages[i]->pagestamp); gg.pages[i]->pageregions = NULL; - curfilename[i] = NULL; - vlsimode[i] = vlsi; + gg.pages[i]->curfilename = NULL; + gg.pages[i]->vlsimode = vlsi; } if (pg != gg.curpage) { - xoffp[gg.curpage - 1] = gg.xoff; - yoffp[gg.curpage - 1] = gg.yoff; - gg.xoff = xoffp[pg - 1]; - gg.yoff = yoffp[pg - 1]; - vlsi = vlsimode[pg - 1]; + gg.pages[gg.curpage - 1]->xoffp = gg.xoff; + gg.pages[gg.curpage - 1]->yoffp = gg.yoff; + gg.xoff = gg.pages[pg - 1]->xoffp; + gg.yoff = gg.pages[pg - 1]->yoffp; + vlsi = gg.pages[pg - 1]->vlsimode; curwcolor = log_wcol_normal; gg.numpages = P_imax2((long)pg, gg.numpages); gg.curpage = pg; diff --git a/src/pagereader.c b/src/pagereader.c index 144ac3e669e8834d90e5e89239ccf30c99d39629..de5a48e54eb59f1aa4a68d60157df1932aa7b353 100644 --- a/src/pagereader.c +++ b/src/pagereader.c @@ -116,6 +116,8 @@ void loadpage(char *filename_, char *reason_) short FORLIM; char *TEMP; + log_page *current_page = get_current_page(); + strcpy(filename, filename_); V.reason = reason_; V.f = NULL; @@ -138,11 +140,12 @@ void loadpage(char *filename_, char *reason_) gg.actx = gg.curpage - 1; calltools(act_clear); - pageClear(gg.pages[gg.curpage - 1]); + pageClear(current_page); + current_page = get_current_page(); garbagecoll(); stamp(&gg.loadstamp); - stamp(&gg.pages[gg.curpage - 1]->pagestamp); + stamp(¤t_page->pagestamp); if (ver < 5) { loadlog30(&V.f, ver); @@ -407,7 +410,7 @@ void loadpage(char *filename_, char *reason_) g1 = g; newgate(&g, j + x1 * log_kindoffset); if (g1 == NULL) - gg.pages[gg.curpage - 1]->gbase = g; + current_page->gbase = g; else g1->next = g; g->next = NULL; @@ -494,11 +497,12 @@ void loadpage(char *filename_, char *reason_) V.f = NULL; if (V.ip != NULL) Free(V.ip); - chpage(gg.pages[gg.curpage - 1]); - gg.pages[gg.curpage - 1]->pagechanged = false; - if (curfilename[gg.curpage - 1] == NULL) - curfilename[gg.curpage - 1] = (char *)Malloc(256); - strcpy(curfilename[gg.curpage - 1], filename); + chpage(current_page); + current_page = get_current_page(); + current_page->pagechanged = false; + if (current_page->curfilename == NULL) + current_page->curfilename = (char *)Malloc(256); + strcpy(current_page->curfilename, filename); } } @@ -749,6 +753,8 @@ void readpage(char *filename_, char *reason) char buf[256]; char *TEMP; + log_page *current_page = get_current_page(); + strcpy(filename, filename_); f = NULL; *reason = '\0'; @@ -772,11 +778,12 @@ void readpage(char *filename_, char *reason) if (f != NULL) fclose(f); f = NULL; - chpage(gg.pages[gg.curpage - 1]); - gg.pages[gg.curpage - 1]->pagechanged = false; - if (curfilename[gg.curpage - 1] == NULL) - curfilename[gg.curpage - 1] = (char *)Malloc(256); - strcpy(curfilename[gg.curpage - 1], filename); + chpage(current_page); + current_page = get_current_page(); + current_page->pagechanged = false; + if (current_page->curfilename == NULL) + current_page->curfilename = (char *)Malloc(256); + strcpy(current_page->curfilename, filename); if (f != NULL) fclose(f); } @@ -1133,5 +1140,5 @@ void loadlog30(FILE **f, short ver) if (TEMP != NULL) *TEMP = 0; } - chpage(gg.pages[gg.curpage - 1]); + chpage(get_current_page()); } diff --git a/src/pagewriter.c b/src/pagewriter.c index 669fa99dfd3a51745809d8e7f0f236d8e73fcef3..fc724d5ef95c244edb423abf740dae71377a4342 100644 --- a/src/pagewriter.c +++ b/src/pagewriter.c @@ -493,9 +493,9 @@ void savepage(short pgnum, char *filename_) fclose(f); f = NULL; gg.pages[pgnum - 1]->pagechanged = false; - if (curfilename[pgnum - 1] == NULL) - curfilename[pgnum - 1] = (char *)Malloc(256); - strcpy(curfilename[pgnum - 1], filename); + if (gg.pages[pgnum - 1]->curfilename == NULL) + gg.pages[pgnum - 1]->curfilename = (char *)Malloc(256); + strcpy(gg.pages[pgnum - 1]->curfilename, filename); } if (f != NULL) fclose(f); @@ -508,8 +508,8 @@ void emergencysave(short pgnum) TRY(try25); nc_printf("File name"); - if (curfilename[pgnum - 1] != NULL) - nc_printf("(was %s)", curfilename[pgnum - 1]); + if (gg.pages[pgnum - 1]->curfilename != NULL) + nc_printf("(was %s)", gg.pages[pgnum - 1]->curfilename); nc_printf(": "); nc_fgets(filename, 256, stdin); if (*filename != '\0')