summaryrefslogtreecommitdiff
path: root/dviware/beebe/src/dvioki.c
blob: bdf627766cc8896694c9ac49ef503b1351c54b6d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
/* -*-C-*- dvioki.c */
/*-->dvioki*/
/**********************************************************************/
/******************************* dvioki *******************************/
/**********************************************************************/

#include "dvihead.h"

/**********************************************************************/
/************************  Device Definitions  ************************/
/**********************************************************************/

/* All output-device-specific definitions go here.  This section must
be changed when modifying a dvi driver for use on a new device */

#undef OKIDATA2410
#define  OKIDATA2410       1		/* conditional compilation flag */

#undef HIRES
#define  HIRES		  1		/* this is 144 dpi version  */

#define VERSION_NO	"2.10"		/* DVI driver version number */

#if    HIRES
#define  DEVICE_ID	"OKIDATA Pacemark 2410 144 dpi dot matrix printer"
					/* this string is printed at runtime */
#define  XDPI		144		/* horizontal dots/inch */
#undef MAXOPEN
#define MAXOPEN		 06		/* limit on number of open PXL files */
#else
#define  DEVICE_ID	"OKIDATA Pacemark 2410 72 dpi dot matrix printer"
					/* this string is printed at runtime */
#define  XDPI		72		/* horizontal dots/inch */
#endif

#define OUTFILE_EXT	"oki"

#define  BYTE_SIZE        7		/* output file byte size */

#undef STDRES
#define STDRES  0			/* 0 for low-resolution devices */

#define  XPSIZE		14		/* horizontal paper size in inches */
#define  XSIZE		(((XDPI*XPSIZE+2*HOST_WORD_SIZE-1)/\
				(2*HOST_WORD_SIZE))*(2*HOST_WORD_SIZE))
					/* number of horizontal dots; */
					/* MUST BE multiple of */
					/* 2*HOST_WORD_SIZE */
#define  XWORDS		((XSIZE + HOST_WORD_SIZE - 1)/HOST_WORD_SIZE)
					/* number of words in rows  */
					/* of bitmap array */

#define  YDPI		XDPI		/* vertical dots/inch */
#define  YPSIZE		11		/* vertical paper size in inches */
#define  YSIZE		(YDPI*YPSIZE)	/* number of vertical dots */

/* The printer bit map. */

#define XBIT XWORDS
#define YBIT YSIZE

#if    (IBM_PC_LATTICE | IBM_PC_MICROSOFT | IBM_PC_WIZARD)
#undef SEGMEM
#define SEGMEM 1 /* ( ((long)XBIT * (long)YBIT) > 65536L ) */
#endif

#include "bitmap.h"


#include "main.h"
#include "abortrun.h"
#include "actfact.h"
#include "alldone.h"
#include "chargf.h"
#include "charpk.h"
#include "charpxl.h"
#include "clrbmap.h"
#include "clrrow.h"
#include "dbgopen.h"

/*-->devinit*/
/**********************************************************************/
/****************************** devinit *******************************/
/**********************************************************************/

void
devinit(argc,argv)		/* initialize device */
int argc;
char *argv[];
{
    (void)getbmap();
}

/*-->devterm*/
/**********************************************************************/
/****************************** devterm *******************************/
/**********************************************************************/

void
devterm()			/* terminate device */
{
}

#include "dispchar.h"
#include "dvifile.h"
#include "dviinit.h"
#include "dviterm.h"
#include "f20open.h"
#include "fatal.h"
#include "fillrect.h"
#include "findpost.h"
#include "fixpos.h"
#include "fontfile.h"
#include "fontsub.h"
#include "getbmap.h"
#include "getbytes.h"
#include "getfntdf.h"
#include "getpgtab.h"
#include "inch.h"
#include "initglob.h"
#include "loadchar.h"

/*-->makechar*/
/**********************************************************************/
/****************************** makechar ******************************/
/**********************************************************************/

char
makechar(p,mask)
UNSIGN32* p[];
register UNSIGN32 mask;
{
    register char c;


#if    SEGMEM
#define Q(n) p[n]			/* use precomputed pointers */
#else /* NOT SEGMEM */
#define Q(n) (p[0] - (n)*XBIT)		/* compute pointers on the fly */
#endif /* SEGMEM */

    c = '\000';
    if (*Q(0) & mask)
	c |= '\001';
    if (*Q(1) & mask)
	c |= '\002';
    if (*Q(2) & mask)
	c |= '\004';
    if (*Q(3) & mask)
	c |= '\010';
    if (*Q(4) & mask)
	c |= '\020';
    if (*Q(5) & mask)
	c |= '\040';
    if (*Q(6) & mask)
	c |= '\100';
    return(c);
}

#include "movedown.h"
#include "moveover.h"
#include "moveto.h"
#include "nosignex.h"
#include "openfont.h"
#include "option.h"

/*-->outline*/
/**********************************************************************/
/****************************** outline *******************************/
/**********************************************************************/

/*
************************************************************************
The OKIDATA Pacemark 2410 has a serious  design flaw in that it lacks  a
command to reset to  power-on state.  This is  serious, because it  uses
ETX to enter graphics mode, ETX STX  to exit graphics mode, and ETX  ETX
to mean ETX as graphics  data.  This means that  a single ETX sent  from
the host may cause it to enter graphics mode, or generate an error if it
is already in graphics mode.  Similarly, an ETX STX will enter  graphics
mode if it is not already in  it, instead of exiting graphics mode.   We
therefore turn on graphics mode for  each line, then turn it off  again.
That way, there may be some remote hope of resynchronizing if we lose an
ETX due to line errors along the way.

From an efficiency standout, it is regrettable that it has no run-length
encoding of graphics data.  The  output quality and speed are  otherwise
quite reasonable as low-cost dot matrix printers go.
************************************************************************
*/

void
outline(pline)
char *pline;
{

/* A few ASCII control character definitions */

#define	STX '\002'
#define	ETX '\003'
#define	SO  '\016'
#define	ESC '\033'

    register INT16 left;
    register char *c;

    for ((left = XSIZE, c = pline + XSIZE - 1);
	(*c == '\000') && (left > 1);
	(--left,--c))			/* trim white space but leave */
	;				/* at least 1 character in line */

    OUTC(ESC);				/* ESC A - 12 cpi for square */
    OUTC('A');				/* aspect ratio*/

#if    HIRES
    OUTC(ESC);
    OUTC('R');				/* ESC R - 144 dpi plot mode */
#else
    OUTC(ESC);
    OUTC('P');				/* ESC P -  72 dpi plot mode */
#endif

    OUTC(ETX);				/* ETX - begin graphics mode */

    for (c = pline; left; --left)
    {
	if (*c == ETX)
	    OUTC(ETX);			/* ETX's must be doubled */
	OUTC(*c);
	++c;
    }
    OUTC(ETX);
    OUTC(SO);				/* ETX SO - graphics carriage return */
    OUTC(ETX);
    OUTC(STX);				/* ETX STX - end graphics mode */
}

#include "outrow.h"

/*-->prtbmap*/
/**********************************************************************/
/****************************** prtbmap *******************************/
/**********************************************************************/

void
prtbmap()
{

    register char *c;			/* pointer into v7[] */
    UNSIGN32 *p;			/* pointer into bitmap[][] */
    register UNSIGN32 mask;		/* mask for single bit selection */
    INT16 i,j,k,ybottom,ytop;
    char v7[XSIZE+2];			/* vertical 7-bit raster encodings */

#undef Q
#if    SEGMEM
    UNSIGN32* q[14];			/* pointers to 14 raster lines */
#define Q(n) q[n]			/* use precomputed pointers */
#else /* NOT SEGMEM */
#define Q(n) (p - (n)*XBIT)		/* compute pointers on the fly */
#endif /* SEGMEM */

    (void)clearerr(plotfp);

    ytop = YBIT-1;

    k = -1;	    /* find bottom non-zero raster */
    for (j = 0; (j < ytop) && (k < 0); ++j) /* loop over raster lines */
    {

#if    IBM_PC_MICROSOFT
	for (k = XBIT - 1; ((k >= 0) && (*BITMAP(j,k) == 0)); --k)
	    ;				/* trim white space */
#else
	p = BITMAP(j,XBIT-1);
	for (k = XBIT - 1; ((k >= 0) && (*p == 0)); --k)
	    --p;			/* trim white space */
#endif

    }
    ybottom = MAX(0,7*((j-1+6)/7));	/* need 7n raster lines */

    for (j = ytop; (j >= ybottom) ; j -= 7)    /* loop over raster lines */
					       /* in groups of 7 */
    {

#if    SEGMEM
#else
	p = BITMAP(j,0);	/* the j-th raster line */
#endif

	c = &v7[0];		/* vertical 7-bit encodings */
	for (i = 0; i < XBIT; (++p,++i))	/* loop over raster words */
	{
	    /* PCC-20 compiled (1 << (HOST_WORD_SIZE-1)) to 0, so do it the
	       hard way, arghh... */
	    mask = 1;
	    mask <<= (HOST_WORD_SIZE-1);	/* to select leftmost bit */

#if    SEGMEM
	    for (k = 0; k < 16; ++k)	/* compute pointers to 16 rasters */
	        q[k] = BITMAP(j-k,i);
#endif

	    for (k = 0; k < HOST_WORD_SIZE; (++c,++k))/* loop over word bits */
	    {
#if    SEGMEM
		*c = makechar(&q[0],mask);	/* examine bits in 7 adjacent */
					/* rows and build 7-bit */
					/* character value */
#else
		*c = makechar(&p,mask);	/* examine bits in 7 adjacent */
					/* rows and build 7-bit */
					/* character value */
#endif
		mask >>= 1;		/* move masking bit right 1 position */
	    }
	}
	--c;				/* last character encoded */

	outline(&v7[0]);
    }
    OUTS("\r\r\r\r\r\n");		/* force a carriage return since it
    					does not always correctly return the
					head to the left margin */
    OUTC('\f');				/* FF to eject page */

    (void)fflush(plotfp);
    if (DISKFULL(plotfp))
	(void)fatal("prtbmap(): Output error -- disk storage probably full");
}

#include "prtpage.h"
#include "readfont.h"
#include "readgf.h"
#include "readpk.h"
#include "readpost.h"
#include "readpxl.h"
#include "reldfont.h"
#include "rulepxl.h"
#include "setchar.h"
#include "setfntnm.h"
#include "setrule.h"
#include "signex.h"
#include "skgfspec.h"
#include "skipfont.h"
#include "skpkspec.h"
#include "special.h"
#include "strchr.h"
#include "strcm2.h"
#include "strid2.h"
#include "strrchr.h"
#include "tctos.h"
#include "usage.h"
#include "warning.h"