|
|
1.1 ! root 1: #include <jerq.h> ! 2: ! 3: #define TRUE 1 ! 4: #define FALSE 0 ! 5: ! 6: extern getdots(); ! 7: extern putdots(); ! 8: extern void idmaxx (); ! 9: extern void idmaxy (); ! 10: extern void idminx (); ! 11: extern void idminy (); ! 12: extern void idwidth (); ! 13: extern void idcolwid (); ! 14: extern char *scanstr(); ! 15: extern char *scanfloat(); ! 16: extern idline (); ! 17: extern idarc (); ! 18: extern idleft (); ! 19: extern idcenter (); ! 20: extern idright (); ! 21: extern idspline (); ! 22: extern idknot (); ! 23: extern idendspline (); ! 24: extern yeserase (); ! 25: extern noerase(); ! 26: extern idendbound(); ! 27: ! 28: char input[10000]; ! 29: char *ip = input; ! 30: ! 31: long maxx, maxy; ! 32: long minx, miny; ! 33: long width = 4; ! 34: long colwid = 6; ! 35: long scale; ! 36: ! 37: #define boolean int ! 38: ! 39: boolean maxxset, maxyset; ! 40: boolean minxset, minyset; ! 41: boolean widset, colset; ! 42: boolean boundset; ! 43: ! 44: boolean veryfirst = TRUE; ! 45: ! 46: boolean wanterase = TRUE; ! 47: ! 48: POINT textpos; ! 49: char temp[100]; ! 50: ! 51: print (s) ! 52: char *s; ! 53: { ! 54: jmoveto(textpos); ! 55: jstring ("*"); ! 56: jstring(s); ! 57: jstring ("*"); ! 58: textpos.x = 30; ! 59: textpos.y += 15; ! 60: } ! 61: ! 62: main (argc, argv) ! 63: int argc; ! 64: char *argv[]; ! 65: { ! 66: jinit(); ! 67: qinit(); ! 68: binit(); ! 69: aciainit(); ! 70: spl0(); ! 71: jBonW(); ! 72: cursinhibit(); ! 73: textpos.x = 30; ! 74: textpos.y = XMAX+20; ! 75: for (;;) { ! 76: getdots(); ! 77: if (wanterase == TRUE) ! 78: jrectf(screenmap.rect, F_CLR); ! 79: putdots(); ! 80: } ! 81: } ! 82: ! 83: getdots() ! 84: { ! 85: register char *start, *ip; ! 86: ip = input; ! 87: jputchar('*'); ! 88: do { ! 89: start = ip; ! 90: while ((*ip++ = jgetchar()) != '\n') ! 91: jputchar('*'); ! 92: } while (strncmp (start, ".IS", 3)); ! 93: ip = input; ! 94: do { ! 95: start = ip; ! 96: while ((*ip++ = jgetchar()) != '\n') ! 97: jputchar('*'); ! 98: *ip = '\0'; ! 99: } while (strncmp (start, ".IE", 3) && strncmp (start, ".IF", 3)); ! 100: maxxset = minxset = FALSE; ! 101: maxyset = minyset = FALSE; ! 102: widset = colset = boundset = FALSE; ! 103: } ! 104: ! 105: #define getfloats(n) for (i = 0; i < n; i ++) ip = scanfloat (&f[i], ip); ! 106: ! 107: putdots() ! 108: { ! 109: register char *ip; ! 110: char cmd[10]; ! 111: long f[10]; ! 112: int i; ! 113: POINT pos; ! 114: char *ip2; ! 115: ! 116: ip = input; ! 117: while (*ip) { ! 118: ip = scanstr(cmd,ip); ! 119: if (!boundset) { ! 120: if (strcmp (cmd, "...maxx") == 0) { ! 121: getfloats(1); ! 122: idmaxx (f[0]); ! 123: } else if (strcmp (cmd, "...maxy") == 0) { ! 124: getfloats(1); ! 125: idmaxy (f[0]); ! 126: } else if (strcmp (cmd, "...minx") == 0) { ! 127: getfloats(1); ! 128: idminx (f[0]); ! 129: } else if (strcmp (cmd, "...miny") == 0) { ! 130: getfloats(1); ! 131: idminy (f[0]); ! 132: } else if (strcmp (cmd, "...width") == 0) { ! 133: getfloats(1); ! 134: idwidth (f[0]); ! 135: } else if (strcmp (cmd, "...colwid") == 0) { ! 136: getfloats(1); ! 137: idcolwid (f[0]); ! 138: } else if (strcmp (cmd, "...obbox") == 0) { ! 139: if (!veryfirst) { ! 140: maxxset = maxyset = TRUE; ! 141: minxset = minyset = TRUE; ! 142: boundset = TRUE; ! 143: } ! 144: } else if (strcmp (cmd, "...noerase") == 0) { ! 145: idnoerase (); ! 146: } else if (strcmp (cmd, "...yeserase") == 0) { ! 147: idyeserase (); ! 148: } else { ! 149: idendbound (); ! 150: veryfirst = FALSE; ! 151: } ! 152: } ! 153: if (boundset) { ! 154: if (strcmp (cmd, "...line") == 0) { ! 155: getfloats(4); ! 156: idline (f[0], f[1], f[2], f[3]); ! 157: } else if (strcmp (cmd, "...circle") == 0) { ! 158: getfloats(3); ! 159: idcircle (f[0], f[1], f[2]); ! 160: } else if (strcmp (cmd, "...arc") == 0) { ! 161: getfloats(9); ! 162: idarc (f[0], f[1], f[2], f[3], f[4], f[5], f[6], f[7], f[8]); ! 163: } else if (strcmp (cmd, "...left") == 0) { ! 164: getfloats(2); ! 165: ip2 = ip; ! 166: while (*ip2++ != '\n') ! 167: ; ! 168: *--ip2 = '\0'; ! 169: idleft(f[0],f[1],ip); ! 170: ip = ip2+1; ! 171: } else if (strcmp (cmd, "...center") == 0) { ! 172: getfloats(2); ! 173: ip2 = ip; ! 174: while (*ip2++ != '\n') ! 175: ; ! 176: *--ip2 = '\0'; ! 177: idcenter(f[0],f[1],ip); ! 178: ip = ip2+1; ! 179: } else if (strcmp (cmd, "...right") == 0) { ! 180: getfloats(2); ! 181: ip2 = ip; ! 182: while (*ip2++ != '\n') ! 183: ; ! 184: *--ip2 = '\0'; ! 185: idright(f[0],f[1],ip); ! 186: ip = ip2+1; ! 187: } else if (strcmp (cmd, "...spline") == 0) { ! 188: getfloats(2); ! 189: idspline (f[0], f[1]); ! 190: } else if (strcmp (cmd, "...knot") == 0) { ! 191: getfloats(2); ! 192: idknot (f[0], f[1]); ! 193: } else if (strcmp (cmd, "...endspline") == 0) { ! 194: idendspline (); ! 195: } ! 196: } ! 197: } ! 198: } ! 199: ! 200: void idmaxx (x) ! 201: long x; ! 202: { ! 203: if (!maxxset) { ! 204: maxx = x; ! 205: maxxset = TRUE; ! 206: } ! 207: } ! 208: ! 209: void idmaxy (y) ! 210: long y; ! 211: { ! 212: if (!maxyset) { ! 213: maxy = y; ! 214: maxyset = TRUE; ! 215: } ! 216: } ! 217: ! 218: void idminx (x) ! 219: long x; ! 220: { ! 221: if (!minxset) { ! 222: minx = x; ! 223: minxset = TRUE; ! 224: } ! 225: } ! 226: ! 227: void idminy (y) ! 228: long y; ! 229: { ! 230: if (!minyset) { ! 231: miny = y; ! 232: minyset = TRUE; ! 233: } ! 234: } ! 235: ! 236: void idwidth (wid) ! 237: long wid; ! 238: { ! 239: if (!widset) { ! 240: width = wid; ! 241: widset = TRUE; ! 242: } ! 243: } ! 244: ! 245: void idcolwid (wid) ! 246: long wid; ! 247: { ! 248: if (!colset) { ! 249: colwid = wid; ! 250: colset = TRUE; ! 251: } ! 252: } ! 253: ! 254: char *scanstr(object, source) ! 255: char *object, *source; ! 256: { ! 257: while (*source != '\0' && (*source == ' ' || *source == '\n')) ! 258: source++; ! 259: while (*source != '\0' && *source != ' ' && *source != '\n') ! 260: *object++ = *source++; ! 261: *object = '\0'; ! 262: return (source); ! 263: } ! 264: ! 265: #define isdigit(ch) ((ch) >= '0' && (ch) <= '9') ! 266: #define PRECISION 1000 ! 267: ! 268: char *scanfloat(f, source) ! 269: long *f; ! 270: char *source; ! 271: { ! 272: int i; ! 273: boolean negflag; ! 274: long part[2]; ! 275: int len[2]; ! 276: long n; ! 277: negflag = FALSE; ! 278: while (!isdigit(*source) && *source != '.' && *source != '-') ! 279: source++; ! 280: if (*source == '-') { ! 281: negflag = TRUE; ! 282: source ++; ! 283: } ! 284: part[0] = part[1] = 0; ! 285: len[0] = len[1] = 0; ! 286: for (i = 0; i < 2; i++) { ! 287: while (isdigit(*source)) { ! 288: part[i] = 10*part[i] + *source++ - '0'; ! 289: len[i]++; ! 290: } ! 291: if (*source != '.') ! 292: break; ! 293: source++; ! 294: } ! 295: n = 1; ! 296: for (i = 0; i < len[1]; i ++) ! 297: n *= 10; ! 298: *f = part[0]*PRECISION + (PRECISION*part[1])/n; ! 299: if (negflag) ! 300: *f *= -1; ! 301: return (source); ! 302: } ! 303: ! 304: #define jx(x) XMAX*((x)-minx)/scale ! 305: #define jy(y) XMAX*(maxy-(y))/scale ! 306: ! 307: idline (x0, y0, x1, y1) ! 308: long x0, y0, x1, y1; ! 309: { ! 310: POINT p; ! 311: p.x = jx(x0); ! 312: p.y = jy(y0); ! 313: jmoveto(p); ! 314: p.x = jx(x1); ! 315: p.y = jy(y1); ! 316: jlineto(p,F_STORE); ! 317: } ! 318: ! 319: #define abs(x) ((x)>0?(x):-(x)) ! 320: ! 321: idcircle (x0, y0, r) ! 322: long x0, y0, r; ! 323: { ! 324: POINT p; ! 325: p.x = jx(x0); ! 326: p.y = jy(y0); ! 327: jcircle(p, (short)(XMAX*abs(r)/scale), F_STORE); ! 328: } ! 329: ! 330: idarc (x0, y0, x1, y1, x2, y2, t1, t2, r) ! 331: long x0, y0, x1, y1, x2, y2, t1, t2, r; ! 332: { ! 333: POINT p0, p1, p2; ! 334: p0.x = jx(x0); ! 335: p0.y = jy(y0); ! 336: p1.x = jx(x1); ! 337: p1.y = jy(y1); ! 338: p2.x = jx(x2); ! 339: p2.y = jy(y2); ! 340: jarc (p0, p2, p1, F_XOR); ! 341: } ! 342: ! 343: idleft (x0, y0, s) ! 344: long x0, y0; ! 345: char *s; ! 346: { ! 347: POINT p; ! 348: p.x = jx(x0); ! 349: p.y = jy(y0); ! 350: jmoveto(p); ! 351: jstring(s); ! 352: } ! 353: ! 354: idcenter (x0, y0, s) ! 355: long x0, y0; ! 356: char *s; ! 357: { ! 358: POINT p; ! 359: p.x = jx(x0) - strwidth(s)/2; ! 360: p.y = jy(y0); ! 361: jmoveto(p); ! 362: jstring(s); ! 363: } ! 364: ! 365: idright (x0, y0, s) ! 366: long x0, y0; ! 367: char *s; ! 368: { ! 369: POINT p; ! 370: p.x = jx(x0) - strwidth(s); ! 371: p.y = jy(y0); ! 372: jmoveto(p); ! 373: jstring(s); ! 374: } ! 375: ! 376: idspline (x0,y0) ! 377: long x0,y0; ! 378: { ! 379: } ! 380: ! 381: idknot (x0,y0) ! 382: long x0,y0; ! 383: { ! 384: } ! 385: ! 386: idendspline () ! 387: { ! 388: } ! 389: ! 390: idnoerase () ! 391: { ! 392: wanterase = FALSE; ! 393: } ! 394: ! 395: idyeserase () ! 396: { ! 397: wanterase = TRUE; ! 398: } ! 399: ! 400: idendbound () ! 401: { ! 402: if (boundset) ! 403: return; ! 404: boundset = TRUE; ! 405: idmaxx ((long)6); ! 406: idminx ((long)-6); ! 407: idmaxy ((long)6); ! 408: idminy ((long)-6); ! 409: scale = maxx - minx; ! 410: if (scale < maxy - miny) ! 411: scale = maxy - miny; ! 412: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.