home *** CD-ROM | disk | FTP | other *** search
- Subject: v12i042: Hershey font manipulation tools and data, Part03/05
- Newsgroups: comp.sources.unix
- Sender: sources
- Approved: rs@uunet.UU.NET
-
- Submitted-by: lee@uhccux.UUCP (Greg Lee)
- Posting-number: Volume 12, Issue 42
- Archive-name: hershtools/part03
-
- # This is a shell archive. Remove anything before this line
- # then unpack it by saving it in a file and typing "sh file"
- # (Files unpacked will be owned by you and have default permissions).
- # This archive contains the following files:
- # ./hplot.c
- #
- if `test ! -s ./hplot.c`
- then
- echo "writing ./hplot.c"
- sed 's/^X//' > ./hplot.c << '\Rogue\Monster\'
- X
- X
- X#include <stdio.h>
- X#include <sys/file.h>
- X
- X#define TRUE 1
- X#define FALSE 0
- X#define ERROR -1
- X
- Xint tty_fid;
- Xextern char *term_name;
- Xchar w300 = FALSE;
- X
- X#define movmem bcopy
- X
- X#define STSIZE 32000
- X#define KEEPSIZE 20
- X#define GRSIZE 160
- X#define GROFF 80
- X
- Xchar debug, ins[90];
- XFILE *ibuf;
- Xint cnum;
- X
- Xint itempt, co1, co2, w, x, y;
- Xint deltax, deltay, xinc, yinc;
- Xint lx,llx,ly,lly, cx,ccx,cy,ccy, x1,x2,y1,y2, a1,a2,d1,d2, i1,i2;
- Xint xx1,xx2,yy1,yy2;
- Xint minx, miny, maxx, maxy, base, obase, xheight, ytop, ybot, serifs;
- Xchar itemtype, linelet, retrace, openflag, lighten, hairflag, cvflag;
- Xint lbear, rbear;
- Xunsigned char letter;
- Xint xheavy, xlight, yheavy, ylight, penwidth, pxdelta, pydelta,
- X squarepen, shading, xshade, yshade;
- Xint ppenw, blob, bblob, dblob;
- Xint fgrey,fvertical,fhorizontal,fchecked,fhatched,fdiagonal,fwidth;
- Xint bwidth,bedge,breverse;
- X
- X
- X#define WYSE 1
- X#define ESC 27
- X
- X#define FTSIZE 12000
- X#define PRPTNL 2
- X
- X#define BLACK '1'
- X#define BLUE '2'
- X#define GREEN '3'
- X#define CYAN '4'
- X#define RED '5'
- X#define MAGENTA '6'
- X#define YELLOW '7'
- X#define WHITE '8'
- X
- X#define UPPRDOT ','
- X#define LOWRDOT '-'
- X#define BOTHDOT '7'
- X#define NODOT ' '
- X
- Xchar upperdot=UPPRDOT, lowerdot=LOWRDOT, bothdot=BOTHDOT;
- X
- Xchar cmd, currch, cch, cbyte, cbyteo, mxflag;
- Xint col, row, currlen;
- X
- Xchar vkeep[GRSIZE][KEEPSIZE], gxoff, gyoff, ib;
- Xchar ckeep[6][GRSIZE];
- X
- Xint i, fd;
- Xchar ftname[30];
- X
- X
- Xchar duplflag /*, ftlen[128]*/;
- Xshort int fix[128];
- Xchar ft[FTSIZE];
- X
- X
- X
- X
- Xchar gr[GRSIZE][GRSIZE];
- X
- Xunsigned stsize, cindex[128], storept;
- Xchar store[STSIZE];
- X
- X
- X#include "vfont.c"
- X
- Xmain()
- X{ char key();
- X
- X/* stuff from xum */
- X
- X if (term_setup() != 0)
- X {
- X printf("Warning: This program needs to have the\n");
- X printf("TERM environment variable setup before\n");
- X printf("being run. Make sure this is done before\n");
- X printf("executing hplot again (set yourself up like\n");
- X printf("you were going to use vi).\n");
- X exit(1);
- X }
- X printf("Terminal is a %s.\n", term_name);
- X if (!strcmp(term_name, "w300")) w300 = TRUE;
- X if (!w300)
- X { upperdot='^'; lowerdot='j'; bothdot='g';
- X }
- X
- X tty_fid = cbreak_tty("/dev/tty");
- X if (tty_fid == -1)
- X {
- X printf("Error opening terminal for cbreak i/o\n");
- X exit(1);
- X }
- X
- X debug = 0;
- X
- X stsize = STSIZE;
- X
- X printf("\nHplot - (c) Greg Lee, Oct. 1984\n\n");
- X
- X base = 9;
- X ytop = 22;
- X ybot = 7;
- X cvflag = FALSE;
- X lbear = rbear = 2;
- X strcpy(ftname,"vwork");
- X letter = currch = duplflag = 0;
- X
- X storept = x1 = x2 = y1 = y2 = a2 = d2 = 1;
- X serifs = 2;
- X
- X do
- X { printf("\n");
- X if (currch > ' ') printf("%c",currch);
- X else printf("^%c",currch+64);
- X printf("* ");
- X cmd = key();
- X switch (cmd)
- X {
- X case 'r': rdchr(); break;
- X case 'z': bzero(cindex, 128*sizeof(int));
- X bzero(store, STSIZE);
- X storept = 1;
- X printf("zapped");
- X break;
- X case 'p': plotlet(); break;
- X case 'g': printf("enerating the font\n");
- X /*for (letter=1;letter<127;letter++)
- X lplot(letter);*/
- X vfont();
- X cvflag = FALSE;
- X break;
- X#if WYSE
- X case 'v': if (currch) showbits(); break;
- X#endif
- X case 'b': gvar("ase",&base); break;
- X case 'h': gvar("eight",&ytop); break;
- X case 'd': gvar("epth",&ybot); break;
- X case 'f': printf("actors:\n");
- X gvar("X1",&x1);
- X gvar("X2",&x2);
- X gvar("Y1",&y1);
- X gvar("Y2",&y2);
- X break;
- X case '2': printf(" FACTORS (plot 2):\n");
- X gvar("XX1",&xx1);
- X gvar("XX2",&xx2);
- X gvar("YY1",&yy1);
- X gvar("YY2",&yy2);
- X break;
- X case 'A': printf("SCENDERS:\n");
- X gvar("A1",&a1);
- X gvar("A2",&a2);
- X break;
- X case 'D': printf("ESCENDERS:\n");
- X gvar("D1",&d1);
- X gvar("D2",&d2);
- X break;
- X case 'I': printf("^ITALIC:\n");
- X gvar("I1",&i1);
- X gvar("I2",&i2);
- X break;
- X case 't': if (duplflag) fix[0] &= ~PRPTNL;
- X else fix[0] |= PRPTNL;
- X chkdupl();
- X if (!duplflag) printf("not "); printf("tall");
- X break;
- X case 'P': printf("EN STYLE:\n");
- X gvar("Width",&penwidth);
- X gvar("Delta X",&pxdelta);
- X gvar("Delta Y",&pydelta);
- X gvar("Square Pen",&squarepen);
- X gvar("Blob",&blob);
- X gvar("Delta Blob",&dblob);
- X break;
- X case 'H': printf(" SHADE:\n");
- X gvar("Shading",&shading);
- X gvar("X Shade",&xshade);
- X gvar("Y Shade",&yshade);
- X break;
- X case 'F': printf("ILL:\n");
- X gvar("Grey",&fgrey);
- X gvar("Vertical",&fvertical);
- X gvar("Horizontal",&fhorizontal);
- X gvar("Checked",&fchecked);
- X gvar("Hatched",&fhatched);
- X gvar("Diagonal",&fdiagonal);
- X gvar("Width",&fwidth);
- X break;
- X case 'w': printf("idth adjust:\n");
- X gvar("Left Bearing",&lbear);
- X gvar("Right Bearing",&rbear);
- X break;
- X case 'B': printf("OX:\n");
- X gvar("Width",&bwidth);
- X gvar("Edge",&bedge);
- X gvar("Reverse",&breverse);
- X break;
- X case 'L': printf("INE STYLE:\n");
- X gvar("X Heavy",&xheavy);
- X gvar("X Light",&xlight);
- X gvar("Y Heavy",&yheavy);
- X gvar("Y Light",&ylight);
- X break;
- X case 'O': if (openflag) printf("not ");
- X openflag = ~openflag;
- X printf("open");
- X break;
- X case 'l': if (lighten) printf("not ");
- X lighten = ~lighten;
- X printf("light");
- X break;
- X case 's': gvar("erifs",&serifs);
- X break;
- X case 'R': if (retrace) printf(" not r");
- X retrace = !retrace;
- X printf("etrace");
- X break;
- X case 'n': printf("ame of font(%s) = ",ftname);
- X scanf("%s",ftname);
- X break;
- X case '?': cmdinfo();
- X printf("\nstore room %d, font room %d",
- X stsize-storept,FTSIZE-fix[127]);
- X break;
- X case '\\': printf("debug");
- X if (debug) printf(" off");
- X debug = !debug;
- X case 'q':
- X case 'x': break;
- X case 'c': loadft();
- X cvflag = TRUE;
- X break;
- X default: conout('?'); break;
- X }
- X }
- X while ((cmd != 'x') && (cmd != 'q'));
- X
- X reset_tty(tty_fid);
- X
- X}
- X
- Xcmdinfo()
- X{
- X printf("\nRead Plot Name font mag.Factors ^Pen style\n");
- X printf("Zap Generate ^Ascenders ^Line style\n");
- X printf("Base Vdisplay Serifs ^Descenders ^Open face\n");
- X printf("Height eXit/Quit^Italic s^Hading Convert\n");
- X printf("Depth ^Fill ^Box ^Retrace Width adjust\n");
- X}
- X
- X
- Xgvar(s,v)
- Xchar *s; int *v;
- X{ char is[80];
- X
- X printf(s);
- X printf("(%d) = ", *v);
- X gets(is);
- X if (is[0] < '0' || is[0] > '9') return;
- X sscanf(is, "%d", v);
- X}
- X
- Xplotlet()
- X{
- X printf("lot a letter? : ");
- X scanf("%c", &letter);
- X lplot(letter);
- X}
- X
- X
- Xrdchr()
- X{ char fname[20];
- X
- X
- X printf("ead what .chr file? : "); scanf("%s", fname);
- X if (!fname[0]) return;
- X strcat(fname, ".chr");
- X if ((ibuf = fopen(fname, "r")) == NULL) return;
- X
- X while (fgets(ins, 90, ibuf))
- X { itempt = 0;
- X while (itemtype = scnitem())
- X switch(itemtype)
- X {
- X case 1: letter = 0;
- X break;
- X case 2: cindex[letter] = storept;
- X lbear = rbear = 2;
- X break;
- X case 3: sto2(co1 + 64, co2 + 64);
- X break;
- X case 4: sto2(0, 64);
- X break;
- X case 5: sto2(0, 0);
- X break;
- X case 6: sto2(0, 'H');
- X break;
- X }
- X }
- X
- X
- X fclose(ibuf);
- X
- X printf("\nUsed %u of buffer (%d remaining).", storept,stsize-storept);
- X}
- X
- Xsto2(x,y)
- Xchar x, y;
- X{
- X if (letter < 1 || letter > 127) return;
- X if (storept > stsize - 2) return;
- X
- X store[storept++] = x;
- X store[storept++] = y;
- X
- X}
- X
- Xscnitem()
- X{ char dc;
- X
- X while (ins[itempt] == ' ' || ins[itempt] == '\t') itempt++;
- X
- X if (!ins[itempt] || ins[itempt] == '\n') return(0);
- X
- X if (sscanf(ins + itempt, "%d:", &cnum))
- X { match(':'); return(1); }
- X
- X if (sscanf(ins + itempt, "'%c':", &letter))
- X { match(':'); return(2); }
- X
- X if (sscanf(ins + itempt, "^%c':", &letter))
- X { match(':'); letter &= 0x1F; return(2); }
- X
- X if (sscanf(ins + itempt, "Bounds(%d,%d)", &co1, &co2))
- X { match(')'); return(66); }
- X
- X if (sscanf(ins + itempt, "Bearings(%d,%d)", &lbear, &rbear))
- X { match(')'); return(66); }
- X
- X if (sscanf(ins + itempt, "s(%d,%d)", &co1, &co2))
- X { match(')'); if (serifs) return(3); return(66); }
- X
- X if (sscanf(ins + itempt, "S(%d,%d)", &co1, &co2))
- X { match(')'); if (serifs>1) return(3); return(66); }
- X
- X if (sscanf(ins + itempt, "(%d,%d)", &co1, &co2))
- X { match(')'); return(3); }
- X
- X if (sscanf(ins + itempt, "Pen Up%c", &dc))
- X { match('p'); return(4); }
- X
- X if (sscanf(ins + itempt, "End Char%c", &dc))
- X { match('r'); return(5); }
- X
- X if (sscanf(ins + itempt, "Hair%c", &dc))
- X { match('r'); return(6); }
- X
- X if (sscanf(ins + itempt, "Base(%d)", &base))
- X { match(')'); obase = base; return(66); }
- X
- X if (sscanf(ins + itempt, "x Height(%d)", &xheight))
- X { match(')'); return(66); }
- X
- X if (sscanf(ins + itempt, "Height(%d)", &ytop))
- X { match(')'); return(66); }
- X
- X if (sscanf(ins + itempt, "Depth(%d)", &ybot))
- X { match(')'); return(66); }
- X
- X return(0);
- X
- X}
- X
- Xmatch(c)
- Xchar c;
- X{ while (ins[itempt++] != c);
- X}
- X
- Xlplot(let)
- Xchar let;
- X{ int ox1,ox2,oy1,oy2;
- X int oopen;
- X
- X if (xx1 || xx2 || yy1 || yy2)
- X { ox1 = x1; oy1 = y1;
- X ox2 = x2; oy2 = y2;
- X oopen = openflag;
- X
- X if (xx1 || xx2)
- X { x1 = xx1 ; x2 = xx2; }
- X if (yy1 || yy2)
- X { y1 = yy1 ; y2 = yy2; }
- X
- X openflag = FALSE;
- X retrace = 2;
- X llplot(let);
- X openflag = oopen;
- X
- X x1 = ox1; y1 = oy1;
- X x2 = ox2; y2 = oy2;
- X retrace = TRUE;
- X }
- X
- X llplot(let);
- X}
- X
- X
- Xllplot(let)
- Xchar let;
- X{ char c1, c2, penstate;
- X unsigned xpt;
- X
- X currch = let;
- X chkdupl();
- X
- X if (let < 0 || let > 128) return;
- X
- X if (!(xpt = cindex[let])) return;
- X /*if (kbhit()) return;*/
- X
- X if (retrace != TRUE) cleargr();
- X
- X bblob = blob;
- X
- X for (penstate = 0 ; (c1 = store[xpt++])
- X + (c2 = store[xpt++]) ; )
- X if (!c1)
- X { penstate = 0;
- X if (c2 == 'H') hairflag = TRUE;
- X
- X bblob = blob;
- X }
- X
- X else
- X { lx = cx; ly = cy;
- X cx = c1 - 64; cy = c2 - 64;
- X
- X if (penstate) drawline();
- X
- X penstate = 1;
- X
- X }
- X
- X
- X showgr();
- X
- X retrace = 0;
- X}
- X
- X
- Xcleargr()
- X{
- X bzero(gr, GRSIZE * GRSIZE);
- X linelet = '0';
- X/* penwidth = abs(penwidth);*/
- X}
- X
- X
- Xdrawline()
- X{
- X if (debug) printf("\nDrawing from (%d,%d) to (%d,%d).", lx,ly,cx,cy);
- X
- X linelet++;
- X if (linelet > '9' && linelet < 'A') linelet = 'A';
- X else if (linelet > 'Z' && linelet < 'a') linelet = 'a';
- X else if (linelet > 'z') linelet = '!'+1;
- X
- X if (abs(cy) <= abs(ly))
- X { llx = lx;
- X lly = ly;
- X ccx = cx;
- X ccy = cy;
- X }
- X else
- X { llx = cx;
- X lly = cy;
- X ccx = lx;
- X ccy = ly;
- X }
- X
- X
- X if (i1 && i2) llx += fadjust(lly,i1,i2)-GROFF;
- X x = fadjust(llx,x1,x2);
- X
- X if (i1 && i2) ccx += fadjust(ccy,i1,i2)-GROFF;
- X ccx = fadjust(ccx,x1,x2);
- X
- X deltax = abs(ccx - x);
- X if (ccx >= x) xinc = 1; else xinc = -1;
- X
- X if (xheight && letter >= 'a' && letter <= 'z')
- X { if (lly > obase) lly += ((lly-obase)*d1)/d2;
- X else if (lly + xheight <= obase)
- X lly -= ((obase+1-xheight-lly)*a1)/a2;
- X if (ccy > obase) ccy += ((ccy-obase)*d1)/d2;
- X else if (ccy + xheight <= obase)
- X ccy -= ((obase+1-xheight-ccy)*a1)/a2;
- X }
- X
- X y = fadjust(lly,y1,y2);
- X ccy = fadjust(ccy,y1,y2);
- X deltay = abs(ccy - y);
- X if (ccy >= y) yinc = 1; else yinc = -1;
- X
- X drawdot();
- X
- X if (deltax >= deltay) doforx();
- X else dofory();
- X
- X hairflag = FALSE;
- X}
- X
- Xfadjust(u,f1,f2)
- Xint u,f1,f2;
- X{
- X return( (u * f1 + f2-1)/f2 + GROFF);
- X}
- X
- Xdrawdot()
- X{
- X dotset();
- X
- X if (bblob > 0) bblob -= dblob;
- X else if (bblob < 0) bblob += dblob;
- X
- X ppenw = abs(penwidth + bblob/8);
- X if (ppenw) doforpen();
- X}
- X
- X
- X
- Xdoforpen()
- X{ int sx,sy;
- X
- X if (hairflag) return;
- X
- X sx = x; sy = y;
- X
- X x -= ppenw * pxdelta / 2;
- X y -= ppenw * pydelta / 2;
- X
- X w = ppenw;
- X while(w--)
- X { x += pxdelta;
- X dotset();
- X y += pydelta;
- X dotset();
- X }
- X
- X
- X w = ppenw;
- X if (squarepen)
- X while(w--)
- X { x -= pydelta;
- X y -= pxdelta;
- X dotset();
- X }
- X
- X w = ppenw;
- X if (squarepen > 1)
- X while(w--)
- X { x -= pxdelta;
- X y -= pydelta;
- X dotset();
- X }
- X
- X w = ppenw;
- X if (squarepen > 2)
- X while(w--)
- X { x += pydelta;
- X y += pxdelta;
- X dotset();
- X }
- X
- X x = sx; y = sy;
- X}
- X
- X
- Xdotset()
- X{
- X
- X if (x<0 || x>=GRSIZE || y<0 || y>=GRSIZE) return;
- X if (gr[x][y]) return;
- X gr[x][y] = linelet;
- X
- X}
- X
- X
- X
- Xdoforx()
- X{ int err, i;
- X
- X err = deltax / 2;
- X i = deltax;
- X
- X while (i--)
- X { err += deltay;
- X if (err >= deltax)
- X { err -= deltax;
- X y += yinc;
- X if (xheavy) drawdot();
- X if (xlight) {x += xinc; continue;}
- X }
- X x += xinc;
- X if (hairflag && (i&1)) continue;
- X drawdot();
- X if (debug) printf("\n @(%d,%d) [%d,%d]",
- X x-GROFF, y-GROFF, x,y);
- X }
- X
- X}
- X
- Xdofory()
- X{ int err, i;
- X
- X gr[x][y] = linelet;
- X
- X err = deltay / 2;
- X i = deltay;
- X
- X while (i--)
- X { err += deltax;
- X if (err >= deltay)
- X { err -= deltay;
- X x += xinc;
- X if (yheavy) drawdot();
- X if (ylight) { y+= yinc; continue; }
- X }
- X y += yinc;
- X if (hairflag && (i&1)) continue;
- X drawdot();
- X if (debug) printf("\n @(%d,%d) [%d,%d]",
- X x-GROFF, y-GROFF, x,y);
- X }
- X
- X}
- X
- Xshowgr()
- X{ /* int x, y;*/
- X
- X minx = miny = GRSIZE-1;
- X maxx = maxy = 0;
- X
- X for (y = 0; y < GRSIZE; y++)
- X { for (x = 0; x < GRSIZE; x++)
- X if (gr[x][y])
- X { if (x < minx) minx = x;
- X if (y < miny) miny = y;
- X if (x > maxx) maxx = x;
- X if (y > maxy) maxy = y;
- X }
- X }
- X
- X if (bwidth)
- X { i = max(bedge+2, 1 + (bwidth + minx - maxx) / 2);
- X minx = max(0, minx - i);
- X maxx = min(GRSIZE-1, maxx + i);
- X while (maxx - minx > GRSIZE) {minx++; maxx--; }
- X miny = base + GROFF + 1 - ytop;
- X maxy = miny + ybot;
- X }
- X
- X printf("\n");
- X
- X if (openflag || lighten)
- X { for (y = miny; y <= maxy; y++)
- X for (x = minx; x <= maxx; x++)
- X if (gr[x][y])
- X {
- X if (!gr[x+1][y] && !gr[x+2][y] && !gr[x+3][y]) continue;
- X if (!gr[x][y+1] && !gr[x][y+2] && !gr[x][y+3]) continue;
- X if (!gr[x-1][y] && !gr[x-2][y] && !gr[x-3][y]) continue;
- X if (!gr[x][y-1] && !gr[x][y-2] && !gr[x][y-3]) continue;
- X gr[x][y] = 1;
- X }
- X
- X if (breverse)
- X for (y = miny; y <= maxy; y++)
- X for (x = minx; x <= maxx; x++)
- X { if (!gr[x][y]) gr[x][y] = 1;
- X else if (gr[x][y] == 1) gr[x][y] = 0;
- X }
- X
- X for (y = miny; y <= maxy; y++)
- X for (x = minx; x <= maxx; x++)
- X if (gr[x][y])
- X { gr[x][y]--;
- X if (lighten)
- X if (gr[x][y])
- X { if (gr[x-1][y])
- X { if (gr[x-1][y-1])
- X gr[x-1][y] = 0;
- X else gr[x][y] = 0;
- X }
- X }
- X else if (!gr[x-1][y] && gr[x+1][y] < 2)
- X gr[x][y] = '*';
- X
- X if (fgrey<0) gr[x][y] = 0;
- X if (gr[x][y]) continue;
- X
- X if (fgrey)
- X { if (x % fgrey) continue;
- X if (y % fgrey) continue;
- X if (!fwidth) gr[x][y] = '+';
- X }
- X
- X if (fwidth)
- X { if (t(x,fvertical)) continue;
- X if (t(y,fhorizontal)) continue;
- X if (fchecked &&
- X (!t(x,fchecked) == !t(y,fchecked))) continue;
- X if (t(x,fhatched) && t(y,fhatched)) continue;
- X if (fdiagonal < 0)
- X { if (t(abs(x-y),-fdiagonal)) continue; }
- X else if (t(x+y, fdiagonal)) continue;
- X
- X gr[x][y] = '#';
- X }
- X }
- X }
- X
- X
- X if (shading && retrace != 2)
- X { shading = abs(shading);
- X xshade = abs(xshade);
- X
- X lx = minx + shading + yshade;
- X ly = min(maxy + shading + yshade,GRSIZE-1);
- X
- X llx = maxx;
- X
- X while (lx <= llx)
- X { raybounce();
- X lx += 2 + xshade;
- X }
- X
- X while (ly >= miny)
- X { raybounce();
- X ly -= 2 + xshade;
- X }
- X }
- X
- X
- X if (bedge && retrace != 2)
- X for (y = miny; y <= maxy; y++)
- X for (x = minx; x <= maxx; x++)
- X if ( y < miny+bedge
- X || y > maxy-bedge
- X || x < minx+bedge
- X || x > maxx-bedge
- X )
- X gr[x][y] = '|';
- X
- X if (maxx - minx > GRSIZE-1) maxx = minx + GRSIZE-1;
- X
- X for (y = miny; y <= maxy; y++)
- X { for (x = minx; x <= maxx; x++)
- X { if (x-minx > 78) break;
- X if (gr[x][y]) printf("%c",gr[x][y]);
- X else if (y == base+GROFF) putchar('-');
- X else putchar(' ');
- X }
- X /*if (y-miny == 23) key();*/
- X printf("\n");
- X }
- X
- X printf("\nHeight %d; Depth %d; Width %d\n",
- X base+GROFF+1-miny, maxy-GROFF-base, maxx-minx+1);
- X
- X rdedf();
- X}
- X
- X
- Xt(a,period)
- Xint a, period;
- X{ if (!period) return(FALSE);
- X a %= period;
- X if (fwidth == 1) return(a);
- X if (fwidth < 0) a = (a >= abs(period) / -fwidth);
- X else a = (a < abs(period) / fwidth);
- X
- X if (period < 0) a = !a;
- X
- X return(a);
- X}
- X
- X
- X
- Xradar()
- X{ x = lx; y = ly;
- X
- X while ( !gr[x][y]
- X && !gr[x-1][y]
- X && !gr[x][y-1]
- X && !gr[x-1][y-1] )
- X { x--; y--;
- X if (x < minx || y < miny) return(FALSE);
- X }
- X return(TRUE);
- X}
- X
- Xraybounce()
- X{
- X if (!radar()) return;
- X
- X i = shading;
- X cx = x + yshade; cy = y + yshade;
- X
- X while(i-- && cx<98 && cy<98 )
- X { cx++; cy++;
- X if (gr[cx][cy]) i = 0;
- X else gr[cx][cy] = '.';
- X }
- X maxx = max(cx,maxx);
- X maxy = max(cy,maxy);
- X}
- X
- X
- Xchar conin()
- X{ return (0x7f & getchar());
- X}
- X
- Xconout(c)
- Xchar c;
- X{ putchar(c);
- X}
- X
- X
- Xtokeep()
- X{
- X tokepp(0, currch);
- X if (duplflag) tokepp(3, dtrans(currch, FALSE));
- X}
- X
- Xtokepp(ib, currch)
- Xunsigned char ib, currch;
- X{ int i, j, cbase;
- X
- X cbase = fix[currch];
- X currlen = (fix[currch+1] - cbase) / 3;
- X
- X if (currlen > GRSIZE) currlen = GRSIZE;
- X for (i = 0; i < 3; i++)
- X for (j = 0; j < GRSIZE; j++)
- X if (j >= currlen) ckeep[ib+i][j] = 0;
- X else ckeep[ib+i][j] = ft[cbase + j + i*currlen];
- X}
- X
- X
- X#if WYSE
- Xfromkeep()
- X{
- X frommkeep(0,currch);
- X if (duplflag) frommkeep(3, dtrans(currch, FALSE));
- X}
- X
- Xfrommkeep(ib, currch)
- Xchar ib, currch;
- X#else
- Xfromkeep()
- X#endif
- X{ int i, j, cend, cbase, cnext, mlen;
- X
- X cbase = fix[currch];
- X cnext = fix[currch+1];
- X
- X cend = cbase + currlen * 3;
- X mlen = (cend-cnext) ? FTSIZE - 1 - max(cnext,cend)
- X : 0;
- X if (fix[127] + cend - cnext >= FTSIZE)
- X { printf("\nfont overflow\n"); return; }
- X
- X if (mlen)
- X { movmem(ft+cnext, ft+cend, mlen);
- X for (i = currch+1; i < 128; i++)
- X fix[i] = fix[i] + cend - cnext;
- X /*for (i = 0; i < 127; i++)
- X ftlen[i] = (fix[i+1] - fix[i])/3;*/
- X /*if (fix[127] >= FTSIZE) ovlflag = TRUE;*/
- X }
- X
- X if (currlen)
- X for (i = 0; i < 3; i++)
- X for (j = 0; j < currlen; j++)
- X ft[cbase + j + i*currlen] = vkeep[ib+i][j];
- X}
- X
- X
- Xchar key()
- X{ char c;
- X
- X c = conin();
- X if (c < ' ') c += '@';
- X else if (c >='A' && c <= 'Z')
- X c += ' ';
- X if (c == 'J') return(key());
- X return(c);
- X}
- X
- X
- Xdtrans(c, upper)
- Xchar c, upper;
- X{ if (c == 0x20 || c == 0x5F) return(c);
- X
- X if (c >= 0x60) c -= 0x20;
- X else if (c < 0x20) c += 0x20;
- X
- X if (upper) return(c);
- X
- X if (c < 0x40) c -= 0x20;
- X else c += 0x20;
- X
- X return(c);
- X}
- X
- Xchkdupl()
- X{
- X duplflag = fix[0] & PRPTNL;
- X#if WYSE
- X if (duplflag) currch = dtrans(currch, TRUE);
- X#endif
- X}
- X
- Xrdedf()
- X{ char c;
- X int i, y, lasty, dcurrlen;
- X
- X
- X if (duplflag) currch = dtrans(currch, TRUE);
- X
- X
- X lbear = rbear = 0;
- X
- X
- X bzero(vkeep, KEEPSIZE*GRSIZE);
- X row = currlen = 0; dcurrlen = 10000;
- X
- X y = base + GROFF + 1 - ytop;
- X lasty = y + ytop + ybot;
- X if (lasty >= GRSIZE) lasty = GRSIZE-1;
- X
- X for ( ; y <= lasty; row++,y++)
- X {
- X for (i = minx, col = lbear; i <= maxx; col++,i++)
- X if (gr[i][y]) chngbit(TRUE);
- X
- X if (currlen < col + rbear)
- X currlen = col + rbear;
- X }
- X
- X/* fromkeep();*/
- X}
- X
- X
- Xchngbit(biton)
- Xchar biton;
- X{ unsigned char bit, mask;
- X
- X bit = col % 8;
- X mask = 128 >> bit;
- X cbyte = vkeep[row][col/8];
- X if (biton) cbyte |= mask;
- X else cbyte &= ~mask;
- X vkeep[row][col/8] = cbyte;
- X}
- X
- X
- X
- X
- X
- X
- Xgxy(x,y)
- Xchar x,y;
- X{ if (w300)
- X { conout(ESC); conout('=');
- X conout(y+' '); conout(x+' ');
- X } else mov_cur(x,y);
- X}
- X
- Xshowbits()
- X{
- X/* conout(0x1A);
- X sleep(1);
- X*/ cls();
- X graph(TRUE);
- X/* tokeep();*/
- X
- X gxoff = (78 - currlen)/2;
- X gyoff = (46 - ytop - ybot)/4;
- X sshowbits();
- X graph(FALSE);
- X gxy(0,22);
- X}
- X
- Xsshowbits()
- X{ unsigned char i, j, bit, mask, r;
- X
- X r = gyoff + (ytop + ybot + 1)/2;
- X
- X if (currlen > 0)
- X {
- X color(RED,WHITE);
- X gxy(gxoff-1,gyoff-1);
- X conout(w300 ? '2':'+');
- X for (i = 0; i < currlen; i++) conout(w300 ? ':':'-');
- X conout(w300 ? '3':'+');
- X
- X for (i = gyoff; i < r; i++)
- X {
- X gxy(gxoff-1,i); conout(w300 ? '6':'|');
- X gxy(currlen+gxoff,i); conout(w300 ? '6':'|');
- X }
- X gxy(gxoff-1,r);
- X conout(w300 ? '1':'+');
- X for (i = 0; i < currlen; i++) conout(w300 ? ':':'-');
- X conout(w300 ? '5':'+');
- X
- X color(BLACK,WHITE);
- X }
- X
- X for (i = 0; i < ytop + ybot; i++,i++)
- X for (j = 0; j < currlen; j += 8)
- X { cbyte = vkeep[i][j/8];
- X cbyteo = vkeep[i+1][j/8];
- X mask = 128;
- X for (bit = 0; bit < 8; bit++, mask >>= 1)
- X if ( /* there is a dot in this row or the next */
- X (mask & cbyte) | (mask & cbyteo)
- X )
- X { gxy(j+bit+gxoff, i/2+gyoff);
- X /* both dots? */
- X if ((mask & cbyte)&& (mask & cbyteo))
- X conout(bothdot);
- X /* dot in this row only? */
- X else if (mask & cbyte)
- X conout(upperdot);
- X else conout(lowerdot); /* must be dot in next row */
- X }
- X }
- X}
- X
- X
- Xgraph(yes)
- Xchar yes;
- X{ if (!w300) return;
- X
- X conout(ESC); conout('H');
- X if (yes) conout(2); else conout(3);
- X conout(ESC); conout('`'); /* cursor off/on */
- X if (yes) conout('0'); else conout('1');
- X if (!yes) color(BLACK, WHITE);
- X}
- X
- Xcolor(fc, bc)
- Xchar fc, bc;
- X{ if (!w300) return;
- X
- X conout(ESC); conout('g');
- X conout(fc); conout(bc);
- X}
- X
- X
- Xmax(x,y)
- Xint x,y;
- X{ if (x >= y) return(x);
- X return(y);
- X}
- X
- Xmin(x,y)
- Xint x,y;
- X{ if (x >= y) return(y);
- X return(x);
- X}
- X
- Xctovkeep()
- X{ bzero(vkeep,KEEPSIZE*GRSIZE);
- X
- X for (row = 0; row < 24; row++)
- X for (col = 0; col < currlen+lbear; col++)
- X if (chkcbit()) chngbit(TRUE);
- X currlen += lbear + rbear;
- X}
- X
- Xchkcbit()
- X{ if (duplflag && row > 23)
- X return( cchkcbit(3, row - 24));
- X else return( cchkcbit(0, row));
- X}
- X
- Xcchkcbit(ib, row)
- Xchar ib, row;
- X{ unsigned char bit, mask, cbyte;
- X
- X if (col < lbear) return(0);
- X bit = row / 3;
- X mask = 128 >> bit;
- X cbyte = ckeep[ib + (row % 3)][col-lbear];
- X if (cbyte & mask) return(1);
- X return(0);
- X}
- X
- X
- X
- Xloadft()
- X{ int fdft, i, ftrecs;
- X char fname[20];
- X
- X strcpy(fname,ftname); strcat(fname,".fn2");
- X
- X if ((fdft = open(fname,O_RDONLY,"r")) == ERROR)
- X {printf("no font"); return;}
- X if (read(fdft, fix, 2*128) != 2*128)
- X {printf("bad font"); return;}
- X
- X /* only read enough of the font to get info for char's
- X up to ascii nul (which is not used) */
- X ftrecs = (fix[127]+127)/128;
- X
- X if (read(fdft, ft, ftrecs*128) != ftrecs*128)
- X {printf("bad font"); return;}
- X close(fdft);
- X/*
- X if (ftrecs > FTSIZE/128) ovlflag = TRUE;
- X for (i = 1; i < 127; i++)
- X ftlen[i] = (fix[i+1] - fix[i])/3;
- X*/
- X chkdupl();
- X
- X}
- X
- X
- X
- \Rogue\Monster\
- else
- echo "will not over write ./hplot.c"
- fi
- if [ `wc -c ./hplot.c | awk '{printf $1}'` -ne 20996 ]
- then
- echo `wc -c ./hplot.c | awk '{print "Got " $1 ", Expected " 20996}'`
- fi
- echo "Finished archive 3 of 4"
- # if you want to concatenate archives, remove anything after this line
- exit
-
-