--- ray/src/px/oki20c.c 1989/10/20 12:07:08 1.4 +++ ray/src/px/oki20c.c 1989/10/20 20:36:02 1.7 @@ -45,7 +45,7 @@ char *fname; { FILE *input; int xres, yres; - COLOR scanline[NCOLS]; + COLR scanline[NCOLS]; int i; if (fname == NULL) { @@ -67,13 +67,14 @@ char *fname; return(-1); } /* set line spacing (overlap for knitting) */ - fputs("\0333\036", stdout); + fputs("\0333\042", stdout); /* put out scanlines */ for (i = yres-1; i >= 0; i--) { - if (freadscan(scanline, xres, input) < 0) { + if (freadcolrs(scanline, xres, input) < 0) { fprintf(stderr, "%s: read error (y=%d)\n", fname, i); return(-1); } + normcolrs(scanline, xres); plotscan(scanline, xres, i); } /* advance page */ @@ -86,7 +87,7 @@ char *fname; plotscan(scan, len, y) /* plot a scanline */ -COLOR scan[]; +COLR scan[]; int len; int y; { @@ -95,18 +96,11 @@ int y; register long c; register int i, j; - if (bpos = y % 20) { + if (bpos = y % 23) { - if (y > 20 & bpos < 4) /* knit bits */ - for (j = 0; j < 3; j++) - for (i = 0; i < len; i++) - pat[i][j] |= (long)colbit(scan[i],i,j) - << (i+j & 4 ? bpos+24 : bpos); - else - for (j = 0; j < 3; j++) - for (i = 0; i < len; i++) - pat[i][j] |= (long)colbit(scan[i],i,j) - << bpos; + for (j = 0; j < 3; j++) + for (i = 0; i < len; i++) + pat[i][j] |= (long)colbit(scan[i],i,j) << bpos; } else { @@ -114,18 +108,15 @@ int y; for (j = 0; j < 3; j++) { fputs("\033%O", stdout); - putchar(len & 0xff); + putchar(len & 255); putchar(len >> 8); for (i = 0; i < len; i++) { - c = pat[i][j]; - pat[i][j] = c>>4 & 0xf00000; - if (i+j & 4) /* knit last bit */ - pat[i][j] |= colbit(scan[i],i,j) << 20; - else - c |= colbit(scan[i],i,j); - putchar(c>>16 & 0xff); - putchar(c>>8 & 0xff); - putchar(c & 0xff); + c = pat[i][j] | colbit(scan[i],i,j); + /* repeat this row */ + pat[i][j] = (c & 1) << 23; + putchar(c>>16); + putchar(c>>8 & 255); + putchar(c & 255); } putchar('\r'); } @@ -135,21 +126,20 @@ int y; colbit(col, x, s) /* determine bit value for primary at x */ -COLOR col; +COLR col; register int x; int s; { - static float cerr[NCOLS][3]; - static double err[3]; - double b; + static int cerr[NCOLS][3]; + static int err[3]; + int b; register int a, ison; a = sub_add(s); /* use additive primary */ - b = colval(col,a); - if (b > 1.0) b = 1.0; + b = col[a]; err[a] += b + cerr[x][a]; - ison = err[a] < 0.5; - if (!ison) err[a] -= 1.0; - cerr[x][a] = err[a] *= 0.5; + ison = err[a] < 128; + if (!ison) err[a] -= 256; + cerr[x][a] = err[a] /= 2; return(ison); }