Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ulowell!m2c!applix!scott From: scott@applix.UUCP (Scott Evernden) Newsgroups: comp.graphics Subject: Re: Trying to get QRT working... Message-ID: <915@applix.UUCP> Date: 3 Mar 89 15:39:29 GMT References: <10469@pasteur.Berkeley.EDU> Reply-To: scott@applix.UUCP (Scott Evernden) Distribution: na Organization: APPLiX Inc., Westboro MA Lines: 157 In article <10469@pasteur.Berkeley.EDU> talvola@cory.berkeley.edu writes: > >As soon as the QRT source was posted, I immediately compiled it on the >Sun 3/50 here at Berkeley. After adding a #include to lexer.c >to get toupper() defined, it compiled perfectly. However, I can't get >it to run on any of the sample files posted here. Here is what happens >if I try to execute the program on the table.qrt file: > > >Fatal error code 207: syntax error In addition to adding #include in lexer.c, you need to change the line that uses toupper from: s[x++]=c=toupper(towhite(fgetc(stdin))); to something like c=towhite(fgetc(stdin)); if (islower(c)) c = toupper(c); s[x++]=c; Then it runs just fine. Just another berzerkelyism you need to watch out for... While I'm here, Here is a *really* quick hack I thru together some time ago to view .RAW files on a black and white sun. It's a modified QrtPost.c, which quite rudely draws right onto the framebuffer. /********************************************************* SunQRTPost is a post processor for QRT on the Sun It reads in the QRT file, and draws it right onto the Sun Screen *********************************************************/ #include #define MAXXRES 640 /* max x resolution */ #define SHIFT 3 /* convert 0..127 to 0..15 */ main(argc,argv) int argc; char *argv[]; { int xres, yres, line; register int x; unsigned short r[MAXXRES], g[MAXXRES], b[MAXXRES]; FILE *in; unsigned char fgetc(); /** open files **/ bitmap = (struct pixrect *) pr_open("/dev/fb"); if (argc == 1) in = stdin; else if ((in = fopen(argv[1],"r"))==NULL) { printf("Couldn't open file %s\n",argv[1]); exit(1); } /** load x and y resolution **/ xres = yres = 0; xres = ((unsigned int)fgetc(in)); xres += ((unsigned int)(fgetc(in) << 8)); yres = ((unsigned int)fgetc(in)); yres += ((unsigned int)(fgetc(in) << 8)); /** print info **/ if (1 < argc) { printf("\nInput file = %s\n", argv[1]); printf("X resolution = %d\n", xres); printf("Y resolution = %d\n\n", yres); } while (!feof(in)) { /* read scan line number */ line = ((int)fgetc(in)); if (line == EOF) break; line |= ((int)(fgetc(in) << 8)); /* read color data */ for (x=0; x struct pixrect *bitmap; /* top left is.. */ #define XOFF 5 #define YOFF 50 short dither[4][4] = { #if 1 { 10, 6, 9, 5 }, { 2, 14, 1, 13 }, { 8, 4, 11, 7 }, { 0, 12, 3, 15 } #else { 0, 5, 10, 1 }, { 9, 14, 15, 6 }, { 4, 13, 12, 11 }, { 3, 8, 7, 2 } { 14, 5, 10, 15 }, { 9, 0, 1, 6 }, { 4, 3, 2, 11 }, { 13, 8, 7, 12 } #endif }; drawline(y, xres, r, g, b) int y, xres; unsigned short *r, *g, *b; { int x, lum, val; for (x = 0; x < xres; x++) { lum = (30 * (*r++ - 4) + 59 * (*g++ - 4) + 11 * (*b++ - 4)) / 265; /* 0->16 */ val = lum <= dither[(2*x)&3][y&3]; pr_put(bitmap, XOFF+(2*x), YOFF+y, val); val = lum <= dither[(2*x+1)&3][y&3]; pr_put(bitmap, XOFF+(2*x+1), YOFF+y, val); } } /********************************************************* -scott