* Varian driver for the new troff
* Richard L. Hyde, Perdue University
* and David Slattengren, U.C. Berkeley
/*******************************************************************************
output language from troff:
all numbers are character strings
fn font as number from 1 to n
Cxyz funny char \(xyz. terminated by white space
Hn go to absolute horizontal position n
Vn go to absolute vertical position n (down is positive)
hn go n units horizontally (relative)
nnc move right nn, then print c (exactly 2 digits!)
(this wart is an optimization that shrinks output file size
about 35% and run-time about 15% while preserving ascii-ness)
p new page begins -- set v to 0
nb a end of line (information only -- no action needed)
b = space before line, a = after
w paddable word space -- no action needed
Dt ..\n draw operation 't':
Dl x y line from here by x,y
Dc d circle of diameter d with left side here
De x y ellipse of axes x,y with left side here
Da x y r arc counter-clockwise by x,y of radius r
D~ x y x y ... B-spline curve by x,y then x,y ...
x ..\n device control functions:
x T s name of device is s
x r n h v resolution is n/inch h = min horizontal motion, v = min vert
x s stop -- done for ever
x f n s font position n contains font s
x H n set character height to n
Subcommands like "i" are often spelled out like "init".
*******************************************************************************/
/* #define DEBUGABLE /* No, not debugable... */
#define DRIVER /* Yes, we're driving directly */
/* #define FULLPAGE /* No, don't output full pages */
#define NFONTS 60 /* total number of fonts useable */
#define MAXSTATE 6 /* number of environments rememberable */
#define OPENREAD 0 /* mode for openning files */
#define RESTART 1 /* upon exit, return either RESTART */
#define ABORT 2 /* or ABORT */
#define FATAL 1 /* type of error */
#define BMASK 0377 /* byte grabber */
#define FONTDIR "/usr/lib/font" /* default place to find font descriptions */
#define BITDIR "/usr/lib/vfont" /* default place to look for font rasters */
#define MAXWRIT 4096 /* max characters allowed to write at once */
#define hmot(n) hgoto(hpos + n)
#define vmot(n) vgoto(vpos + n)
char SccsId
[]= "dvar.c 1.11 84/03/14";
int output
= 0; /* do we do output at all? */
int nolist
= 0; /* output page list if > 0 */
int olist
[20]; /* pairs of page numbers */
int spage
= 9999; /* stop every spage pages */
struct font
*fontbase
[NFONTS
+1];
short * pstab
; /* point size table pointer */
int nsizes
; /* number of sizes device is capable of printing */
int nfonts
; /* number of fonts device is capable of printing */
char * fitab
[NFONTS
+1]; /* font inclusion table - maps ascii to ch # */
char * widtab
[NFONTS
+1]; /* width table for each font */
char * codetab
[NFONTS
+1]; /* device codes */
char * fontdir
= FONTDIR
; /* place to find devxxx directories */
char * bitdir
= BITDIR
; /* place to find raster fonts and fontmap */
char * fontname
[NFONTS
+1]; /* table of what font is on what position */
struct { /* table of what font */
char fname
[3]; /* name maps to what */
char *ffile
; /* filename in bitdirectory */
int size
= -1; /* current point size (internal pstable index) */
int font
= -1; /* current font - not using any to start with */
int hpos
; /* horizontal position we are to be at next; left = 0 */
int vpos
; /* current vertical position (down positive) */
extern linethickness
; /* thickness (in pixels) of any drawn object */
extern linmod
; /* line style (a bit mask - dotted, etc.) of objects */
int lastw
; /* width of last character printed */
#define DISPATCHSIZE 256 /* must be a power of two */
#define CHARMASK (DISPATCHSIZE-1)
#define DSIZ ((sizeof *dispatch)*DISPATCHSIZE)
#define OUTFILE fileno (stdout)
#define RES 200 /* resolution of the device (dots/in) */
#define RASTER_LENGTH 2112 /* device line length */
#define BYTES_PER_LINE (RASTER_LENGTH/8)
# define NLINES 1600 /* page width, 8 inches */
# define NLINES 1700 /* page width, 8.5 inches */
#define BUFFER_SIZE (NLINES*BYTES_PER_LINE) /* number of chars in picture */
int pltmode
[] = { VPLOT
};
int prtmode
[] = { VPRINT
};
char buffer1
[BUFFER_SIZE
]; /* Big line buffers */
char buffer2
[BUFFER_SIZE
];
char * fill
= &buffer1
[0]; /* Zero origin in filling buffer */
char * empty
= &buffer2
[0]; /* Zero origin in emptying buffer */
char * elevel
= &buffer2
[0]; /* current position in emptying buffer */
int emptypos
= NLINES
; /* amount of emptying done (initially "done") */
int fnum
; /* if == -1, then this position is empty */
} fontdes
[NFONTS
+1]; /* initialized at program start */
struct dispatch
*dispatch
;
int fontwanted
= 1; /* flag: "has a new font been requested?" */
for (i
= 0; i
<= NFONTS
; fontdes
[i
++].fnum
= -1);
while (--argc
> 0 && **++argv
== '-') {
bitdir
= operand(&argc
, &argv
);
fontdir
= operand(&argc
, &argv
);
outlist(operand(&argc
, &argv
));
dbg
= atoi(operand(&argc
, &argv
));
spage
= atoi(operand(&argc
, &argv
));
ioctl(OUTFILE
, VSETSTATE
, pltmode
);
if (strcmp(*argv
, "-") == 0)
else if ((fp
= fopen(*argv
, "r")) == NULL
)
error(FATAL
, "can't open %s", *argv
);
/*----------------------------------------------------------------------------*
| Routine: char * operand (& argc, & argv)
| Results: returns address of the operand given with a command-line
| option. It uses either "-Xoperand" or "-X operand", whichever
| is present. The program is terminated if no option is present.
| Side Efct: argc and argv are updated as necessary.
*----------------------------------------------------------------------------*/
char *operand(argcp
, argvp
)
if ((**argvp
)[2]) return(**argvp
+ 2); /* operand immediately follows */
if ((--*argcp
) <= 0) /* no operand */
error (FATAL
, "command-line option operand missing.\n");
return(*(++(*argvp
))); /* operand next word */
outlist(s
) /* process list of page numbers to be printed */
n1
= 10 * n1
+ *s
++ - '0';
n2
= 10 * n2
+ *s
++ - '0';
for (i
=0; i
<nolist
; i
+= 2)
fprintf(stderr
,"%3d %3d\n", olist
[i
], olist
[i
+1]);
while ((c
= getc(fp
)) != EOF
) {
case '\n': /* when input is text */
case 0: /* occasional noise creeps in */
case '{': /* push down current environment */
case '0': case '1': case '2': case '3': case '4':
case '5': case '6': case '7': case '8': case '9':
/* two motion digits plus a character */
hmot((c
-'0')*10 + getc(fp
)-'0');
case 'c': /* single ascii character */
case 't': /* straight text */
fgets(buf
, sizeof(buf
), fp
);
case 'D': /* draw function */
if (fgets(buf
, sizeof(buf
), fp
) == NULL
)
error(FATAL
, "unexpected end of input");;
case 'l': /* draw a line */
sscanf(buf
+1, "%d %d", &n
, &m
);
sscanf(buf
+1, "%d %d", &m
, &n
);
sscanf(buf
+1, "%d %d %d %d", &n
, &m
, &n1
, &m1
);
case '~': /* wiggly line */
case 'g': /* gremlin spline */
drawwig(buf
+1, fp
, buf
[0] == '~');
case 't': /* line thickness */
case 's': /* line style */
error(FATAL
, "unknown drawing function %s", buf
);
fscanf(fp
, "%d", &n
); /* ignore fractional sizes */
case 'H': /* absolute horizontal motion */
/* fscanf(fp, "%d", &n); */
while ((c
= getc(fp
)) == ' ')
} while (isdigit(c
= getc(fp
)));
case 'h': /* relative horizontal motion */
while ((c
= getc(fp
)) == ' ')
} while (isdigit(c
= getc(fp
)));
case 'w': /* word space */
case 'n': /* end of line */
while (c
!= '\n' && c
!= EOF
);
case 'x': /* device control */
if (devcntrl(fp
)) return;
error(FATAL
, "unknown input character %o %c", c
, c
);
if (emptypos
< NLINES
) { /* for each input operation */
slop_lines(1); /* put out an output line */
if (emptypos
== NLINES
) {
ioctl(OUTFILE
, VSETSTATE
, prtmode
);
if (write(OUTFILE
, "\f", 2) != 2)
ioctl(OUTFILE
, VSETSTATE
, pltmode
);
int devcntrl(fp
) /* interpret device control functions */
FILE *fp
; /* returns -1 upon "stop" command */
char str
[20], str1
[50], buf
[50];
switch (str
[0]) { /* crude for now */
case 'i': /* initialize */
case 'p': /* pause -- can restart */
case 'r': /* resolution assumed when prepared */
if (n
!=RES
) error(FATAL
,"Input computed with wrong resolution");
case 'f': /* font used */
fscanf(fp
, "%d %s", &n
, str
);
fgets(buf
, sizeof buf
, fp
); /* in case there's a filename */
ungetc('\n', fp
); /* fgets goes too far */
str1
[0] = 0; /* in case nothing comes in */
/* these don't belong here... */
case 'H': /* char height */
while ((c
= getc(fp
)) != '\n') /* skip rest of input line */
/* fileinit: read in font and code files, etc.
Must open table for device, read in resolution,
size info, font info, etc. and set params.
Also read in font name mapping.
/* first, read in font map file. The file must be of Format:
XX FILENAME (XX = troff font name)
with one entry per text line of the file.
Extra stuff after FILENAME is ignored */
sprintf(temp
, "%s/fontmap", bitdir
);
if ((fp
= fopen(temp
, "r")) == NULL
)
error(FATAL
, "Can't open %s", temp
);
for (i
= 0; i
<= NFONTS
&& fgets(temp
, 100, fp
) != NULL
; i
++) {
sscanf(temp
, "%2s", fontmap
[i
].fname
);
while (*p
!= ' ' && *p
!= ' ') p
++;
while (*p
== ' ' || *p
== ' ') p
++;
for (nw
= 1; *p
!= '\n' && *p
!= ' ' && *p
!= '\t'; p
++) nw
++;
fontmap
[i
].ffile
= nalloc(1, nw
);
sscanf(filebase
, "%s", fontmap
[i
].ffile
);
fontmap
[++i
].fname
[0] = '0'; /* finish off with zeros */
fontmap
[i
].ffile
= (char *) 0;
fprintf(stderr
, "font map:\n");
for (i
= 0; fontmap
[i
].ffile
; i
++)
fprintf(stderr
,"%s = %s\n", fontmap
[i
].fname
, fontmap
[i
].ffile
);
sprintf(temp
, "%s/devva/DESC.out", fontdir
);
if ((fin
= open(temp
, 0)) < 0)
error(FATAL
, "can't open tables for %s", temp
);
read(fin
, &dev
, sizeof(struct dev
));
filebase
= calloc(1, dev
.filesize
); /* enough room for whole file */
read(fin
, filebase
, dev
.filesize
); /* all at once */
pstab
= (short *) filebase
;
chtab
= pstab
+ nsizes
+ 1;
chname
= (char *) (chtab
+ dev
.nchtab
);
p
= chname
+ dev
.lchname
;
for (i
= 1; i
<= nfonts
; i
++) {
fontbase
[i
] = (struct font
*) p
;
nw
= *p
& BMASK
; /* 1st thing is width count */
p
+= sizeof(struct font
);
p
+= 3 * nw
+ dev
.nchtab
+ 128 - 32;
t_fp(i
, fontbase
[i
]->namefont
, fontbase
[i
]->intname
);
if (dbg
> 1) fontprint(i
);
fontbase
[0] = (struct font
*)
calloc(1,3*255 + dev
.nchtab
+ (128-32) + sizeof (struct font
));
widtab
[0] = (char *) fontbase
[0] + sizeof (struct font
);
fontbase
[0]->nwfont
= 255;
fontprint(i
) /* debugging print of font i (0,...) */
fprintf(stderr
,"font %d:\n", i
);
p
= (char *) fontbase
[i
];
n
= fontbase
[i
]->nwfont
& BMASK
;
"base=0%o, nchars=%d, spec=%d, name=%s, widtab=0%o, fitab=0%o\n",p
,
n
,fontbase
[i
]->specfont
,fontbase
[i
]->namefont
,widtab
[i
],fitab
[i
]);
fprintf(stderr
,"widths:\n");
fprintf(stderr
," %2d", widtab
[i
][j
] & BMASK
);
if (j
% 20 == 19) fprintf(stderr
,"\n");
fprintf(stderr
,"\ncodetab:\n");
fprintf(stderr
," %2d", codetab
[i
][j
] & BMASK
);
if (j
% 20 == 19) fprintf(stderr
,"\n");
fprintf(stderr
,"\nfitab:\n");
for (j
=0; j
<= dev
.nchtab
+ 128-32; j
++) {
fprintf(stderr
," %2d", fitab
[i
][j
] & BMASK
);
if (j
% 20 == 19) fprintf(stderr
,"\n");
loadfont(n
, s
, s1
) /* load font info for font s on position n (0...) */
error(FATAL
, "illegal fp command %d %s", n
, s
);
if (strcmp(s
, fontbase
[n
]->namefont
) == 0)
for (fin
= 1; fin
<= NFONTS
; fin
++) /* first check to see if the */
if (strcmp(s
, fontbase
[fin
]->namefont
) == 0) { /* font is loaded */
register char *c
; /* somewhere else */
#define ptrswap(x, y) { c = (char*) (x); x = y; y = c; }
#define ptrfswap(x, y) { c = (char*) (x); x = y; y = (struct font *) c; }
ptrfswap(fontbase
[n
], fontbase
[fin
]);
ptrswap(codetab
[n
], codetab
[fin
]);
ptrswap(widtab
[n
], widtab
[fin
]);
ptrswap(fitab
[n
], fitab
[fin
]);
t_fp(n
, fontbase
[n
]->namefont
, fontbase
[n
]->intname
);
t_fp(fin
, fontbase
[fin
]->namefont
, fontbase
[fin
]->intname
);
if (s1
== NULL
|| s1
[0] == '\0')
sprintf(temp
, "%s/devva/%s.out", fontdir
, s
);
sprintf(temp
, "%s/%s.out", s1
, s
);
if ((fin
= open(temp
, 0)) < 0)
error(FATAL
, "can't open font table %s", temp
);
norig
= fontbase
[n
]->nwfont
& BMASK
;
read(fin
, fontbase
[n
], 3*norig
+ nchtab
+128-32 + sizeof(struct font
));
if ((fontbase
[n
]->nwfont
& BMASK
) > norig
)
error(FATAL
, "Font %s too big for position %d", s
, n
);
nw
= fontbase
[n
]->nwfont
& BMASK
;
widtab
[n
] = (char *) fontbase
[n
] + sizeof(struct font
);
codetab
[n
] = (char *) widtab
[n
] + 2 * nw
;
fitab
[n
] = (char *) widtab
[n
] + 3 * nw
;
t_fp(n
, fontbase
[n
]->namefont
, fontbase
[n
]->intname
);
fontbase
[n
]->nwfont
= norig
; /* to later use full original size */
if (dbg
> 1) fontprint(n
);
error(f
, s
, a1
, a2
, a3
, a4
, a5
, a6
, a7
) {
fprintf(stderr
, "dvar: ");
fprintf(stderr
, s
, a1
, a2
, a3
, a4
, a5
, a6
, a7
);
t_init() /* initialize device */
setsize(t_size(10)); /* start somewhere */
struct state state
[MAXSTATE
];
struct state
*statep
= state
;
t_push() /* begin a new block */
statep
->sthick
= linethickness
;
if (statep
++ >= state
+MAXSTATE
)
error(FATAL
, "{ nested too deep");
t_pop() /* pop to previous state */
linethickness
= statep
->sthick
;
t_page(n
) /* do whatever new page functions */
if (emptypos
< NLINES
) { /* finish off last page, if */
slop_lines(NLINES
- emptypos
); /* it's not done yet */
ioctl(OUTFILE
, VSETSTATE
, prtmode
);
if (write(OUTFILE
, "\f", 2) != 2)
ioctl(OUTFILE
, VSETSTATE
, pltmode
);
emptypos
= 0; /* set emptying to be started */
elevel
= fill
; /* swap buffer pointers */
return; /* no -o specified */
for (i
= 0; i
< nolist
; i
+= 2)
if (n
>= olist
[i
] && n
<= olist
[i
+1]) {
t_newline() /* do whatever for the end of a line */
hpos
= 0; /* because we're now back at the left margin */
t_size(n
) /* convert integer to internal size number*/
else if (n
>= pstab
[nsizes
- 1])
for (i
= 0; n
> pstab
[i
]; i
++)
t_charht(n
) /* set character height to n */
if (dbg
) error(!FATAL
, "can't set height on varian");
t_slant(n
) /* set slant to n */
if (dbg
) error(!FATAL
, "can't set slant on varian");
t_font(s
) /* convert string to internal font number */
t_text(s
) /* print string s as text */
if (dbg
) fprintf(stderr
,"width = %d\n", lastw
);
ioctl(OUTFILE
, VSETSTATE
, prtmode
);
if (write(OUTFILE
, "\f", 2) != 2)
/*----------------------------------------------------------------------------*
| Routine: hgoto (horizontal_spot)
| Results: hpos is set to n. If n overlaps in either direction, it wraps
| around to the other end of the page.
*----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------*
| Routine: vgoto (vertical_spot)
| Results: vpos is set to n. If n overlaps in either direction, it wraps
| around to the other end of the page.
*----------------------------------------------------------------------------*/
else if (n
> RASTER_LENGTH
)
put1s(s
) /* s is a funny char name */
if (dbg
) fprintf(stderr
,"%s ", s
);
for (i
= 0; i
< nchtab
; i
++)
if (strcmp(&chname
[chtab
[i
]], s
) == 0)
put1(c
) /* output char c */
if (dbg
) fprintf(stderr
,"non-exist 0%o\n", c
+ 32);
lastw
= (widtab
[font
][0] * pstab
[size
] + dev
.unitwidth
/2)
i
= fitab
[font
][c
] & BMASK
;
if (i
!= 0) { /* it's on this font */
p
= codetab
[font
]; /* get the printing value of ch */
pw
= widtab
[font
]; /* get the width */
} else { /* on another font - run down the font list */
for (j
=0; j
++ <= nfonts
; k
= (k
+1) % (nfonts
+1)) {
if ((i
=fitab
[k
][c
] & BMASK
) != 0) {
if (dbg
) fprintf(stderr
,"not found 0%o\n", c
+32);
fprintf(stderr
,"%c %d\n", c
+32, code
);
fprintf(stderr
,"%03o %d\n", c
+32, code
);
outc(code
); /* character is < 254 */
lastw
= ((pw
[i
]&077) * pstab
[size
] + dev
.unitwidth
/2) / dev
.unitwidth
;
setsize(n
) /* set point size to n (internal) */
return; /* already there */
if (vloadfont(font
, pstab
[n
]) != -1)
t_fp(n
, s
, si
) /* font position n now contains font s, intname si */
int n
; /* internal name is ignored */
/* first convert s to filename if possible */
for (i
= 0; fontmap
[i
].ffile
!= (char *) 0; i
++) {
if(dbg
>1)fprintf(stderr
,"testing :%s:%s:\n",s
,fontmap
[i
].fname
);
if (strcmp(s
, fontmap
[i
].fname
) == 0) {
if(dbg
)fprintf(stderr
, "found :%s:\n",fontmap
[i
].ffile
);
for(i
= 0;i
<= NFONTS
;i
++) /* free the bits of that font */
if (fontdes
[i
].fnum
== n
){
setfont(n
) /* set font to n */
error(FATAL
, "illegal font %d", n
);
if (vloadfont(n
,pstab
[size
]) != -1)
if (fnum
== cfnum
&& fsize
== cpsize
)
for (i
= 0; i
< NFONTS
; i
++) {
if (fontdes
[i
].fnum
== fnum
&& fontdes
[i
].psize
== fsize
) {
cpsize
= fontdes
[i
].psize
;
dispatch
= &fontdes
[i
].disp
[0];
if (fnum
< 0 || fnum
> NFONTS
|| fontname
[fnum
] == 0) {
fprintf(stderr
, "Internal error: illegal font %d name %s size\n",
fontname
[fnum
], fnum
, fsize
);
/* Need to verify the existance of that font/size here*/
register int sizehunt
= size
;
/* try to open font file - if unsuccessful, hunt for */
/* a file of same style, different size to substitute */
d
= -1; /* direction to look in pstab (smaller first) */
sprintf(cbuf
, "%s/%s.%dr", bitdir
, fontname
[fnum
], fsize
);
fontd
= open(cbuf
, OPENREAD
);
if (fontd
== -1) { /* File wasn't found. Try another ps */
if (sizehunt
< 0) { /* past beginning - look higher */
if (sizehunt
> nsizes
) { /* past top - forget it */
} while (fontd
== -1 && d
!= 0);
if (fontd
== -1) { /* completely unsuccessful */
error(!FATAL
,"fnum = %d, psize = %d, name = %s",
fnum
, npsize
, fontname
[fnum
]);
if (read(fontd
, &header
, sizeof (header
)) != sizeof (header
)
fprintf(stderr
, "%s: Bad font file", cbuf
);
if ((bits
=nalloc(header
.size
+DSIZ
+1,1))== NULL
)
if ((bits
=allpanic(header
.size
+DSIZ
+1))== NULL
) {
error(FATAL
,"%s: ran out of memory", cbuf
);
* have allocated one chunk of mem for font, dispatch.
* get the dispatch addr, align to word boundary.
d
= (int) bits
+header
.size
;
if (read (fontd
, d
, DSIZ
) != DSIZ
|| read (fontd
, bits
, header
.size
) != header
.size
)
fprintf(stderr
, "bad font header");
cfnum
= fontdes
[cfont
].fnum
= fnum
;
cpsize
= fontdes
[cfont
].psize
= fsize
;
fontdes
[cfont
].bits
= bits
;
fontdes
[cfont
].disp
= (struct dispatch
*) d
;
dispatch
= &fontdes
[cfont
].disp
[0];
* "release" a font position - find an empty one, if possible
for (newfont
= 0; newfont
< NFONTS
; newfont
++)
if (fontdes
[newfont
].fnum
== -1)
if (fontdes
[newfont
].fnum
!= -1) {
nfree (fontdes
[newfont
].bits
);
if (dbg
) fprintf (stderr
, "freeing position %d\n", newfont
);
fprintf (stderr
, "taking, not freeing, position %d\n", newfont
);
fontdes
[newfont
].fnum
= -1;
for (i
= 0; i
<= NFONTS
; i
++) {
if (fontdes
[i
].fnum
!= -1) nfree(fontdes
[i
].bits
);
return(nalloc(nbytes
,1));
int M
[] = { 0xffffffff, 0xfefefefe, 0xfcfcfcfc, 0xf8f8f8f8,
0xf0f0f0f0, 0xe0e0e0e0, 0xc0c0c0c0, 0x80808080, 0x0 };
int N
[] = { 0x00000000, 0x01010101, 0x03030303, 0x07070707,
0x0f0f0f0f, 0x1f1f1f1f, 0x3f3f3f3f, 0x7f7f7f7f, 0xffffffff };
int strim
[] = { 0xffffffff, 0xffffff00, 0xffff0000, 0xff000000, 0 };
int code
; /* character to print */
register struct dispatch
*dis
; /* ptr to character font record */
register char *addr
; /* addr of font data */
int llen
; /* length of each font line */
int nlines
; /* number of font lines */
register char *scanp
; /* ptr to output buffer */
int scanp_inc
; /* increment to start of next buffer */
int offset
; /* bit offset to start of font data */
register int i
; /* loop counter */
register int count
; /* font data ptr */
register unsigned fontdata
; /* font data temporary */
register int off8
; /* offset + 8 */
llen
= (dis
->up
+ dis
->down
+ 7) >> 3;
nlines
= dis
->right
+ dis
->left
;
scanp
= fill
+ (hpos
+ 1 - dis
->left
) * BYTES_PER_LINE
- (1 + ((dis
->down
+ vpos
- 1) >> 3));
scanp_inc
= BYTES_PER_LINE
- llen
;
off8
= ((dis
->down
+ vpos
- 1) &07);
for (i
= 0; i
< nlines
; i
++) {
if (scanp
>= fill
+ BUFFER_SIZE
)
if (scanp
+ count
< fill
+ BUFFER_SIZE
) {
fontdata
= *(unsigned *)addr
;
fontdata
&= ~strim
[count
];
*(unsigned*)scanp
|=(fontdata
<< offset
) & ~M
[off8
];
*(unsigned*)scanp
|=(fontdata
<< off8
) & ~N
[off8
];
scanp
+= scanp_inc
+count
;
/* Output "nlines" lines from the buffer, and clear that section of the */
/* buffer. Also updates the pointers to the emptying buffer */
usize
= BYTES_PER_LINE
* nlines
;
tsize
= usize
> MAXWRIT
? MAXWRIT
: usize
;
if (dbg
)fprintf(stderr
,"buf = %d size = %d\n",buf
,tsize
);
if ((tsize
= write(OUTFILE
, buf
, tsize
)) < 0) {
perror("dvar: write failed");
if ((unsigned)(16*1024) < nbytes
) {
if (dbg
) fprintf(stderr
,"clearing ptr = %d size = %d\n",ptr
,tsize
);
asm("movc5 $0,(sp),$0,8(ap),*4(ap)");
if (dbg
) fprintf(stderr
, "allocated %d bytes at %x\n", i
* j
, cp
);
if (dbg
) fprintf(stderr
, "freeing at %x\n", cp
);
* Points should be in the range 0 <= x < RASTER_LENGTH, 0 <= y < NLINES.
* The origin is the top left-hand corner with increasing x towards the
* right and increasing y going down. X and Y should be sent as (0,0) being
* at the bottom left. The output array is NLINES x BYTES_PER_LINE pixels.
if ((unsigned)(y
=RASTER_LENGTH
-y
) < RASTER_LENGTH
&& (unsigned)x
< NLINES
) {
*(fill
+ x
* BYTES_PER_LINE
+ (y
>> 3)) |= 1 << (7 - (y
& 07));