File: epson.trm

package info (click to toggle)
gnuplot5 5.0.0~rc%2Bdfsg2-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 11,548 kB
  • ctags: 8,104
  • sloc: ansic: 77,108; cpp: 6,848; makefile: 1,932; sh: 1,343; lisp: 657; perl: 302; awk: 235; pascal: 194; tcl: 88; python: 46
file content (1183 lines) | stat: -rw-r--r-- 31,398 bytes parent folder | download | duplicates (8)
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
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
/* Hello, Emacs, this is -*-C-*-
 * $Id: epson.trm,v 1.26 2011/11/19 04:24:17 sfeam Exp $
 *
 */

/* GNUPLOT - epson.trm */

/*[
 * Copyright 1990 - 1993, 1998, 2004
 *
 * Permission to use, copy, and distribute this software and its
 * documentation for any purpose with or without fee is hereby granted,
 * provided that the above copyright notice appear in all copies and
 * that both that copyright notice and this permission notice appear
 * in supporting documentation.
 *
 * Permission to modify the software is granted, but not the right to
 * distribute the complete modified source code.  Modifications are to
 * be distributed as patches to the released version.  Permission to
 * distribute binaries produced by compiling modified sources is granted,
 * provided you
 *   1. distribute the corresponding source modifications from the
 *    released version in the form of a patch file along with the binaries,
 *   2. add special version identification to distinguish your version
 *    in addition to the base release version number,
 *   3. provide your name and address as the primary contact for the
 *    support of your modified version, and
 *   4. retain our contact information in regard to use of the base
 *    software.
 * Permission to distribute the released version of the source code along
 * with corresponding source modifications in the form of a patch file is
 * granted with same provisions 2 through 4 for binary distributions.
 *
 * This software is provided "as is" without express or implied warranty
 * to the extent permitted by applicable law.
]*/

/*
 * This file is included by ../term.c.
 *
 * This terminal driver supports:
 *  epson_lx800, nec_cp6, starc,
 *  epson_60dpi, tandy_60dpi
 *  epson_180dpi
 *  dpu414
 *
 * AUTHORS
 *  Russell Lang
 *  William Wilson
 *
 * send your comments or suggestions to (gnuplot-info@lists.sourceforge.net).
 *
 */

/*
 * adapted to the new terminal layout by Stefan Bodewig (1995)
 */

#include "driver.h"

#ifdef TERM_REGISTER
#ifdef EPS180
register_term(epson_180dpi)
#endif /* EPS180 */
#ifdef EPS60
register_term(epson_60dpi)
#endif /* EPS60 */
#ifdef EPSONP
register_term(epson_lx800)
#endif /* EPSONP */
#ifdef NEC
register_term(nec_cp6)
#endif /* NEC */
#ifdef OKIDATA
register_term(okidata)
#endif /* OKIDATA */
#ifdef STARC
register_term(starc)
#endif /* STARC */
#ifdef TANDY60
register_term(tandy_60dpi)
#endif /* TANDY60 */
#ifdef DPU414
register_term(dpu414)
#endif /* DPU414 */
#endif /* TERM_REGISTER */

#ifdef TERM_PROTO

TERM_PUBLIC void EPSON_reset __PROTO((void));

#if defined(EPS180) || defined(EPS60) || defined(EPSONP) || defined(TANDY60) || defined(OKIDATA)
TERM_PUBLIC void EPSON_init __PROTO((void));

#if defined(EPS60) || defined(EPSONP) || defined(TANDY60) || defined(OKIDATA)
#define EPSONVCHAR		FNT5X9_VCHAR
#define EPSONHCHAR		FNT5X9_HCHAR
#define EPSONVTIC		6
#define EPSONHTIC		6

#ifdef EPSONP
#define EPSONXMAX	512
#define EPSONYMAX	384
TERM_PUBLIC void EPSON_graphics __PROTO((void));
TERM_PUBLIC void EPSON_text __PROTO((void));
#endif /* EPSONP */
#endif /* four drivers */
#endif /* all five */

#ifdef EPS180
TERM_PUBLIC void EPS180_graphics __PROTO((void));
TERM_PUBLIC void EPS180_text __PROTO((void));
#define EPSON180VCHAR		FNT13X25_VCHAR
#define EPSON180HCHAR		FNT13X25_HCHAR
#define EPSON180VTIC		18
#define EPSON180HTIC		18
/* make the total dimensions 8 inches by 6 inches */
#define EPS180XMAX	1260
#define EPS180YMAX	1080
#endif /* EPS180 */

#if defined(EPS60) || defined(TANDY60) || defined(OKIDATA)
/* make the total dimensions 8 inches by 5 inches */
#define EPS60XMAX	480
#define EPS60YMAX	360
TERM_PUBLIC void EPS60_graphics __PROTO((void));
#ifdef TANDY60
TERM_PUBLIC void TANDY60_text __PROTO((void));
#endif /* TANDY60 */
#ifdef OKIDATA
TERM_PUBLIC void OKIDATA_text __PROTO((void));
#endif /* OKIDATA */
#ifdef EPS60
TERM_PUBLIC void EPS60_text __PROTO((void));
#endif /* EPS60 */
#endif /* all three */

#ifdef NEC
TERM_PUBLIC void NEC_options __PROTO((void));
TERM_PUBLIC void NEC_init __PROTO((void));
TERM_PUBLIC void NEC_graphics __PROTO((void));
TERM_PUBLIC void NEC_text __PROTO((void));
TERM_PUBLIC void NEC_linetype __PROTO((int linetype));
#define NECXMAX	400
#define NECYMAX	320
#define NECVCHAR		FNT5X9_VCHAR
#define NECHCHAR		FNT5X9_HCHAR
#define NECVTIC		6
#define NECHTIC		6
#endif /* NEC */

#ifdef STARC
TERM_PUBLIC void STARC_init __PROTO((void));
TERM_PUBLIC void STARC_graphics __PROTO((void));
TERM_PUBLIC void STARC_text __PROTO((void));
TERM_PUBLIC void STARC_linetype __PROTO((int linetype));
#define STARCXMAX	512
#define STARCYMAX	384
#define STARCVCHAR		FNT5X9_VCHAR
#define STARCHCHAR		FNT5X9_HCHAR
#define STARCVTIC		6
#define STARCHTIC		6
#endif /* STARC */

#ifdef DPU414
TERM_PUBLIC void DPU414_options __PROTO((void));
TERM_PUBLIC void DPU414_init __PROTO((void));
TERM_PUBLIC void DPU414_graphics __PROTO((void));
TERM_PUBLIC void DPU414_text __PROTO((void));
TERM_PUBLIC void DPU414_setfont __PROTO((void));
#define DPU414XMAX	(640)
#define DPU414YMAX	(480)
#define DPU414VCHAR	FNT5X9_VCHAR
#define DPU414HCHAR	FNT5X9_HCHAR
#define DPU414VTIC	FNT5X9_HBITS
#define DPU414HTIC	FNT5X9_HBITS
#endif /* DPU414 */

#endif /* TERM_PROTO */

#ifndef TERM_PROTO_ONLY
#ifdef TERM_BODY


TERM_PUBLIC void
EPSON_reset()
{
#ifdef VMS
    fflush_binary();
#endif
}


#ifdef EPSONP

/* The following epson lx800 driver uses generic bit mapped graphics
   routines to build up a bit map in memory. */
/* by Russell Lang, rjl@monu1.cc.monash.edu.au */
/* On PC, print using 'copy file /b lpt1:', do NOT use 'print' */
/* EPSON_init changes gpoutfile to binary mode on PC's */

static void epson_dump __PROTO((void));

#define EPSONXLAST (EPSONXMAX - 1)
#define EPSONYLAST (EPSONYMAX - 1)

TERM_PUBLIC void
EPSON_init()
{
}

TERM_PUBLIC void
EPSON_graphics()
{
    b_charsize(FNT5X9);
    b_makebitmap((unsigned int) (EPSONXMAX * xsize),
		 (unsigned int) (EPSONYMAX * ysize), 1);
}


TERM_PUBLIC void
EPSON_text()
{
    epson_dump();
    b_freebitmap();
}


/* output file must be binary mode for epson_dump */
static void
epson_dump()
{
    register unsigned int x;
    int j;
    for (j = (b_ysize / 8) - 1; j >= 0; j--) {
	/* select plotter graphics mode (square pixels) */
	fputs("\033J\030", gpoutfile);	/* line feed 8/72" = 8 dots */
	fputs("\r\033*\005", gpoutfile);
	(void) fputc((char) (b_xsize % 256), gpoutfile);
	(void) fputc((char) (b_xsize / 256), gpoutfile);
	for (x = 0; x < b_xsize; x++) {
	    (void) fputc((char) (*((*b_p)[j] + x)), gpoutfile);
	}
    }
#ifdef PC
    fputs("Print using: COPY /B\n", stderr);
#endif
}

#endif /* EPSONP */


/* The following NEC CP6 Pinwriter driver uses generic bit mapped graphics
   routines to build up a bit map in memory. */
/* by Russell Lang, rjl@monu1.cc.monash.edu.au */
/* On PC, print using 'copy file /b lpt1:', do NOT use 'print' */
/* NEC_init changes gpoutfile to binary mode for PC's */

/* Add a Monochrome NEC printer (for faster speed and line types) jdc */

#ifdef NEC

static void nec_dump __PROTO((void));
static void nec_draft_dump __PROTO((void));

#define NECXLAST (NECXMAX - 1)
#define NECYLAST (NECYMAX - 1)


/* plane 0=black, 1=cyan(blue), 2=magenta(red), 3=yellow */
static unsigned int neccolor[] = { 1, 8, 4, 2, 10, 12, 6, 14 };
static unsigned int necpcolor[] = { 0, 2, 1, 4 };

static int NECmode;

enum NEC_id { NEC_MONOCHROME, NEC_COLOR, NEC_DRAFT, NEC_OTHER };

static struct gen_table NEC_opts[] =
{
    { "m$onochrome", NEC_MONOCHROME },
    { "c$olor", NEC_COLOR },
    { "c$olour", NEC_COLOR },
    { "d$raft", NEC_DRAFT },
    { NULL, NEC_OTHER }
};

TERM_PUBLIC void
NEC_options()
{
    /* default */
    if (END_OF_COMMAND) {
	strcpy(term_options, "monochrome");
	NECmode = 'm';
    }

    while (!END_OF_COMMAND) {
	switch(lookup_table(&NEC_opts[0],c_token)) {
	case NEC_MONOCHROME:
	    c_token++;
	    strcpy(term_options, "monochrome");
	    NECmode = 'm';
	    break;
	case NEC_COLOR:
	    c_token++;
	    strcpy(term_options, "color");
	    NECmode = 'c';
 	    break;
	case NEC_DRAFT:
	    c_token++;
	    strcpy(term_options, "draft");
	    NECmode = 'd';
	    break;
	case NEC_OTHER:
	default:
	    /* FIXME - not the most sensible thing to do */
	    /* error, but since the terminal is already set, default to mono */
	    strcpy(term_options, "monochrome");
	    NECmode = 'm';
	    int_error(c_token, "modes: color, monochrome, draft");
	    break;
	}
    }

}

TERM_PUBLIC void
NEC_init()
{
}

TERM_PUBLIC void
NEC_graphics()
{
    b_charsize(FNT5X9);
    b_makebitmap((unsigned int) (NECXMAX * xsize),
		 (unsigned int) (NECYMAX * ysize), (NECmode == 'c' ? 4 : 1));
}

TERM_PUBLIC void
NEC_text()
{
    if (NECmode == 'd') {
	nec_draft_dump();
    } else {
	nec_dump();
    }
    b_freebitmap();
}

TERM_PUBLIC void
NEC_linetype(int linetype)
{
    if (NECmode == 'c') {
	if (linetype >= 6)
	    linetype %= 6;
	b_setvalue(neccolor[linetype + 2]);
    } else {
	b_setlinetype(linetype);
    }
}



/* output file must be binary mode for nec_dump */
static void
nec_dump()
{
    unsigned int x;
    unsigned int plane, offset;
    int j;
    unsigned int column8;
    unsigned long column24;
    char column3, column2, column1;
    fputs("\033P\033l\005", gpoutfile);	/* 10cpi, left margin 5 char */
    for (j = (b_ysize / 8) - 1; j >= 0; j--) {
	fputs("\033J\030", gpoutfile);	/* 24/180" line feed */
	for (plane = 0; plane < b_planes; plane++) {
	    offset = plane * b_psize;
	    if (b_planes > 1) {
		/* select colour for plane */
		fputs("\033r", gpoutfile);
		(void) fputc((char) necpcolor[plane], gpoutfile);
	    }
	    /* select plotter graphics mode (square pixels) */
	    fputs("\r\033*\047", gpoutfile);
	    (void) fputc((char) ((b_xsize * 3) % 256), gpoutfile);
	    (void) fputc((char) ((b_xsize * 3) / 256), gpoutfile);
	    for (x = 0; x < b_xsize; x++) {
		column8 = (unsigned int) (*((*b_p)[j + offset] + x));
		column24 = 0;
		if (column8 & 0x01)
		    column24 |= (long) 0x000007;
		if (column8 & 0x02)
		    column24 |= (long) 0x000038;
		if (column8 & 0x04)
		    column24 |= (long) 0x0001c0;
		if (column8 & 0x08)
		    column24 |= (long) 0x000e00;
		if (column8 & 0x10)
		    column24 |= (long) 0x007000;
		if (column8 & 0x20)
		    column24 |= (long) 0x038000;
		if (column8 & 0x40)
		    column24 |= (long) 0x1c0000;
		if (column8 & 0x80)
		    column24 |= (long) 0xe00000;
		column1 = (char) (column24 & (long) 0xff);
		column2 = (char) ((column24 >> 8) & (long) 0xff);
		column3 = (char) ((column24 >> 16) & (long) 0xff);
		(void) fputc(column3, gpoutfile);
		(void) fputc(column2, gpoutfile);
		(void) fputc(column1, gpoutfile);
		(void) fputc(column3, gpoutfile);
		(void) fputc(column2, gpoutfile);
		(void) fputc(column1, gpoutfile);
		(void) fputc(column3, gpoutfile);
		(void) fputc(column2, gpoutfile);
		(void) fputc(column1, gpoutfile);
	    }
	}
    }
    fputs("\r\033l", gpoutfile);
    (void) fputc('\0', gpoutfile);	/* set left margin to 0 */
    if (b_planes > 1) {
	fprintf(gpoutfile, "\033r");
	(void) fputc('\0', gpoutfile);	/* set color to black */
    }
#ifdef PC
    fputs("Print using: COPY /B\n", stderr);
#endif
#ifdef VMS
    fflush_binary();
#endif
}

/* output file must be binary mode for nec_dump */
static void
nec_draft_dump()
{
    unsigned int x;
    unsigned int plane, offset;
    int j;
    fputs("\033P\033l\005\r", gpoutfile);	/* 10cpi, left margin 5 char */
    for (j = (b_ysize / 8) - 1; j >= 0; j--) {
	fputs("\033J\030", gpoutfile);	/* 24/180" line feed */
	for (plane = 0; plane < b_planes; plane++) {
	    offset = plane * b_psize;
	    if (b_planes > 1) {
		/* select colour for plane */
		fputs("\033r", gpoutfile);
		(void) fputc((char) necpcolor[plane], gpoutfile);
	    }
	    /* select plotter graphics mode (square pixels) */
	    fputs("\r\033*", gpoutfile);
	    (void) fputc('\0', gpoutfile);
	    (void) fputc((char) (b_xsize % 256), gpoutfile);
	    (void) fputc((char) (b_xsize / 256), gpoutfile);
	    for (x = 0; x < b_xsize; x++) {
		(void) fputc((char) (*((*b_p)[j + offset] + x)), gpoutfile);
	    }
	}
    }
    fputs("\r\033l", gpoutfile);
    (void) fputc('\0', gpoutfile);	/* set left margin to 0 */
    if (b_planes > 1) {
	fputs("\033r", gpoutfile);
	(void) fputc('\0', gpoutfile);	/* set color to black */
    }
#ifdef PC
    fputs("Print using: COPY /B\n", gpoutfile);
#endif
}

#endif /* NEC */

#ifdef STARC
/* The following Star color driver uses generic bit mapped graphics
   routines to build up a bit map in memory. */
/* Star Color changes made by William Wilson, wew@naucse.cse.nau.edu */
/* On PC, print using 'copy file /b lpt1:', do NOT use 'print' */
/* STARC_init changes gpoutfile to binary mode on PC's */

static void STARC_dump __PROTO((void));

#define STARCXLAST (STARCXMAX - 1)
#define STARCYLAST (STARCYMAX - 1)


/* plane 0=black, 1=cyan(blue), 2=magenta(red), 3=yellow */
static unsigned int STARCcolor[] = { 1, 8, 4, 2, 10, 12, 6, 14 };
static unsigned int STARCpcolor[] = { 0, 2, 1, 4 };

TERM_PUBLIC void
STARC_init()
{
}

TERM_PUBLIC void
STARC_graphics()
{
    b_charsize(FNT5X9);
    b_makebitmap((unsigned int) (STARCXMAX * xsize),
		 (unsigned int) (STARCYMAX * ysize), 4);
}


TERM_PUBLIC void
STARC_text()
{
    STARC_dump();
    b_freebitmap();
}

TERM_PUBLIC void
STARC_linetype(int linetype)
{
    if (linetype >= 6)
	linetype %= 6;
    b_setvalue(STARCcolor[linetype + 2]);
}



/* output file must be binary mode for STARC_dump */
static void
STARC_dump()
{
    unsigned int x;
    unsigned int plane, offset;
    int j;
    for (j = (b_ysize / 8) - 1; j >= 0; j--) {
	fputs("\033J\030", gpoutfile);	/* line feed 8/72" = 8 dots */
	for (plane = 0; plane < b_planes; plane++) {
	    offset = plane * b_psize;
	    if (b_planes > 1) {
		/* select colour for plane */
		fputs("\033r", gpoutfile);
		(void) fputc((char) STARCpcolor[plane], gpoutfile);
	    }
	    /* select plotter graphics mode (square pixels) */
	    fputs("\r\033*\005", gpoutfile);
	    (void) fputc((char) (b_xsize % 256), gpoutfile);
	    (void) fputc((char) (b_xsize / 256), gpoutfile);
	    for (x = 0; x < b_xsize; x++) {
		(void) fputc((char) (*((*b_p)[j + offset] + x)), gpoutfile);
	    }
	}
    }
    if (b_planes > 1) {
	fputs("\033r", gpoutfile);
	(void) fputc('\0', gpoutfile);	/* set color to black */
    }
#ifdef PC
    fputs("Print using: COPY /B\n", stderr);
#endif
}

#endif /* STARC */


#ifdef EPS180

static void eps180_dump __PROTO((void));

#define EPS180XLAST (EPS180XMAX - 1)
#define EPS180YLAST (EPS180YMAX - 1)

TERM_PUBLIC void
EPS180_graphics()
{
    b_charsize(FNT13X25);
    b_makebitmap((unsigned int) (EPS180XMAX * xsize),
		 (unsigned int) (EPS180YMAX * ysize), 1);
}


TERM_PUBLIC void
EPS180_text()
{
    eps180_dump();
    b_freebitmap();
}



/* output file must be binary mode for eps180_dump */
static void
eps180_dump()
{
    register unsigned int x;
    int j;

    /* reset, set line spacing to 24/180", and move left margin */
    fputs("\033@\033+\060\033l\005", gpoutfile);
    for (j = (b_ysize / 8) - 1; j >= 0;) {
	/* select printer graphics mode '39' */
	fputs("\r\n\033*'", gpoutfile);
	(void) fputc((char) (b_xsize % 256), gpoutfile);
	(void) fputc((char) (b_xsize / 256), gpoutfile);
	for (x = 0; x < b_xsize; x++) {
	    (void) fputc((char) (*((*b_p)[j] + x)), gpoutfile);
	    (void) fputc((char) (*((*b_p)[j - 1] + x)), gpoutfile);
	    (void) fputc((char) (*((*b_p)[j - 2] + x)), gpoutfile);
	}
	j -= 3;
    }
    fputs("\r\n\033@\r\n", gpoutfile);	/* reset printer */
#ifdef PC
    fputs("Print using: COPY /B\n", stderr);
#endif
}

#endif /* EPS180 */

#ifdef EPS60

static void eps60_dump __PROTO((void));

#define EPS60XLAST (EPS60XMAX - 1)
#define EPS60YLAST (EPS60YMAX - 1)

TERM_PUBLIC void
EPS60_graphics()
{
    b_charsize(FNT5X9);
    b_makebitmap((unsigned int) (EPS60XMAX * xsize),
		 (unsigned int) (EPS60YMAX * ysize), 1);
}


TERM_PUBLIC void
EPS60_text()
{
    eps60_dump();
    b_freebitmap();
}



/* output file must be binary mode for eps60_dump */
static void
eps60_dump()
{
    register unsigned int x;
    int j;
    fprintf(gpoutfile, "\033%c\030", '3');	/* set line spacing 24/216" = 8 dots */
    for (j = (b_ysize / 8) - 1; j >= 0; j--) {
	/* select printer graphics mode 'K' */
	fputs("\r\n\033K", gpoutfile);
	(void) fputc((char) (b_xsize % 256), gpoutfile);
	(void) fputc((char) (b_xsize / 256), gpoutfile);
	for (x = 0; x < b_xsize; x++) {
	    (void) fputc((char) (*((*b_p)[j] + x)), gpoutfile);
	}
    }
    fprintf(gpoutfile, "\033%c\044\r\n", '3');	/* set line spacing 36/216" = 1/6" */
#ifdef PC
    fputs("Print using: COPY /B\n", stderr);
#endif
}

#endif /* EPS60 */

#ifdef TANDY60

/* The only difference between TANDY60 and EPS60 is the inclusion
   of codes to swap the Tandy printer into IBM mode and back
   into Tandy mode.  For a Tandy already in IBM mode, use EPS60. */


TERM_PUBLIC void
TANDY60_text()
{
#ifdef PC
    fputs("Inserting Tandy/IBM mode conversion codes\n", stderr);
#endif
    /* Switch to IBM mode, and leave 3 inches above the plot so as
       to get rough vertical centring on the page.  Perform the
       centring by setting 1" line feeds and issuing 3 of them. */
    fprintf(gpoutfile, "\033!\033%c%c\n\n\n", '3', 216);
    eps60_dump();
    b_freebitmap();
    /* A form feed must be sent before switching back to Tandy mode,
       or else the form setting will be messed up. */
    fputs("\f\033!", gpoutfile);
}


#endif /* TANDY60 */

#ifdef OKIDATA

static void okidata_dump __PROTO((void));

TERM_PUBLIC void
OKIDATA_text()
{
    okidata_dump();
    b_freebitmap();
}

static int OKIDATAbitrev_tbl[] =
{
    0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0,
    0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0,
    0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8,
    0x18, 0x98, 0x58, 0xd8, 0x38, 0xb8, 0x78, 0xf8,
    0x04, 0x84, 0x44, 0xc4, 0x24, 0xa4, 0x64, 0xe4,
    0x14, 0x94, 0x54, 0xd4, 0x34, 0xb4, 0x74, 0xf4,
    0x0c, 0x8c, 0x4c, 0xcc, 0x2c, 0xac, 0x6c, 0xec,
    0x1c, 0x9c, 0x5c, 0xdc, 0x3c, 0xbc, 0x7c, 0xfc,
    0x02, 0x82, 0x42, 0xc2, 0x22, 0xa2, 0x62, 0xe2,
    0x12, 0x92, 0x52, 0xd2, 0x32, 0xb2, 0x72, 0xf2,
    0x0a, 0x8a, 0x4a, 0xca, 0x2a, 0xaa, 0x6a, 0xea,
    0x1a, 0x9a, 0x5a, 0xda, 0x3a, 0xba, 0x7a, 0xfa,
    0x06, 0x86, 0x46, 0xc6, 0x26, 0xa6, 0x66, 0xe6,
    0x16, 0x96, 0x56, 0xd6, 0x36, 0xb6, 0x76, 0xf6,
    0x0e, 0x8e, 0x4e, 0xce, 0x2e, 0xae, 0x6e, 0xee,
    0x1e, 0x9e, 0x5e, 0xde, 0x3e, 0xbe, 0x7e, 0xfe,
    0x01, 0x81, 0x41, 0xc1, 0x21, 0xa1, 0x61, 0xe1,
    0x11, 0x91, 0x51, 0xd1, 0x31, 0xb1, 0x71, 0xf1,
    0x09, 0x89, 0x49, 0xc9, 0x29, 0xa9, 0x69, 0xe9,
    0x19, 0x99, 0x59, 0xd9, 0x39, 0xb9, 0x79, 0xf9,
    0x05, 0x85, 0x45, 0xc5, 0x25, 0xa5, 0x65, 0xe5,
    0x15, 0x95, 0x55, 0xd5, 0x35, 0xb5, 0x75, 0xf5,
    0x0d, 0x8d, 0x4d, 0xcd, 0x2d, 0xad, 0x6d, 0xed,
    0x1d, 0x9d, 0x5d, 0xdd, 0x3d, 0xbd, 0x7d, 0xfd,
    0x03, 0x83, 0x43, 0xc3, 0x23, 0xa3, 0x63, 0xe3,
    0x13, 0x93, 0x53, 0xd3, 0x33, 0xb3, 0x73, 0xf3,
    0x0b, 0x8b, 0x4b, 0xcb, 0x2b, 0xab, 0x6b, 0xeb,
    0x1b, 0x9b, 0x5b, 0xdb, 0x3b, 0xbb, 0x7b, 0xfb,
    0x07, 0x87, 0x47, 0xc7, 0x27, 0xa7, 0x67, 0xe7,
    0x17, 0x97, 0x57, 0xd7, 0x37, 0xb7, 0x77, 0xf7,
    0x0f, 0x8f, 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, 0xef,
    0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff
};

/* output file must be binary mode for okidata_dump */
static void
okidata_dump()
{
    register unsigned int x;
    int j;
    char cur_char;
    int prev_char;

    prev_char = 0;
    /* set line spacing 16/144" = 8 dots, turn on single density
     * graphics mode: */
    fprintf(gpoutfile, "\033%c%c\020\033*eP:\003", '%', '9');
    for (j = (b_ysize / 8) - 1; j >= 0; j--) {
	fputs("\003\016", gpoutfile);
/*		(void) fputc((char)(b_xsize%256),gpoutfile); */
/*		(void) fputc((char)(b_xsize/256),gpoutfile); */
	for (x = 0; x < b_xsize; x++) {
	    if ((cur_char = (char)
		 (OKIDATAbitrev_tbl[(int) (*((*b_p)[j] + x))])) == '\003') {
		fputs("\003\003", gpoutfile);
	    } else {
		(void) fputc((char) cur_char, gpoutfile);
	    }
	}
    }
    fprintf(gpoutfile, "\003\002\033%c%c\030\r\n", '%', '9');	/* Turned off graphics mode: set line spacing 24/144" = 1/6" */
#ifdef PC
    fputs("Print using: COPY /B\n", stderr);
#endif
}

#endif /* OKIDATA */

#ifdef DPU414

static void DPU414_dump __PROTO((void));

static int DPU414_font = 2; /* medium font */
static int DPU414_quality = 1; /* normal */

enum DPU414_id {
	DPU414_SMALL, DPU414_MEDIUM, DPU414_LARGE,
	DPU414_NORMAL, DPU414_DRAFT,
	DPU414_OTHER
};

static struct gen_table DPU414_opts[] =
{
	{ "s$mall", DPU414_SMALL },
	{ "m$edium", DPU414_MEDIUM },
	{ "l$arge", DPU414_LARGE },
	{ "n$ormal", DPU414_NORMAL },
	{ "d$raft", DPU414_DRAFT },
	{ NULL, DPU414_OTHER }
};

TERM_PUBLIC void
DPU414_options()
{
	DPU414_font = 2;
	DPU414_quality = 1;
	term_options[0] = NUL;

	while (!END_OF_COMMAND) {
		switch(lookup_table(&DPU414_opts[0],c_token)) {
			case DPU414_SMALL:
				DPU414_font = 1;
				c_token++;
				break;
			case DPU414_MEDIUM:
				DPU414_font = 2;
				c_token++;
				break;
			case DPU414_LARGE:
				DPU414_font = 3;
				c_token++;
				break;
			case DPU414_NORMAL:
				DPU414_quality = 1;
				c_token++;
				break;
			case DPU414_DRAFT:
				DPU414_quality = 2;
				c_token++;
				break;
			case DPU414_OTHER:
			default:
				/* reset to default, since term is already set */
				DPU414_font = 2;
				DPU414_quality = 1;
				int_error(c_token, "expecting: {small, medium, large} {normal, draft}");
				break;
		}
	}

	term->v_tic = (term->xmax < term->ymax) ? term->xmax/100 : term->ymax/100;
	if (term->v_tic < 1)
		term->v_tic = 1;
	term->h_tic = term->v_tic;

	/* setup options string */
	switch (DPU414_font) {
		case 1:
			strcat(term_options, "small");
			break;
		case 2:
			strcat(term_options, "medium");
			break;
		case 3:
			strcat(term_options, "large");
			break;
	}
	switch (DPU414_quality) {
		case 1:
			strcat(term_options, " normal");
			term->xmax = DPU414XMAX;
			term->ymax = DPU414YMAX;
			break;
		case 2:
			strcat(term_options, " draft");
			term->xmax = DPU414XMAX / 2;
			term->ymax = DPU414YMAX / 2;
			break;
	}
}

TERM_PUBLIC void
DPU414_init()
{
	DPU414_setfont();
}

TERM_PUBLIC void
DPU414_setfont()
{
	switch (DPU414_font) {
	case 1:
		b_charsize(FNT5X9);
		term->v_char = FNT5X9_VCHAR;
		term->h_char = FNT5X9_HCHAR;
		break;
	case 2:
		b_charsize(FNT9X17);
		term->v_char = FNT9X17_VCHAR;
		term->h_char = FNT9X17_HCHAR;
		break;
	case 3:
		b_charsize(FNT13X25);
		term->v_char = FNT13X25_VCHAR;
		term->h_char = FNT13X25_HCHAR;
		break;
	}
}

TERM_PUBLIC void
DPU414_graphics()
{
	switch (DPU414_quality) {
	case 1:
		b_makebitmap((unsigned int) (DPU414XMAX * xsize),
		             (unsigned int) (DPU414YMAX * ysize), 1);
		break;
	case 2:
		term->xmax = DPU414XMAX / 2;
		term->ymax = DPU414YMAX / 2;
		b_makebitmap((unsigned int) (DPU414XMAX / 2 * xsize),
		             (unsigned int) (DPU414YMAX / 2 * ysize), 1);
		break;
	}
}

TERM_PUBLIC void
DPU414_text()
{
	DPU414_dump();
	b_freebitmap();
}

static void
DPU414_dump()
{
	register unsigned int x;
	int j;

	fputs("\r", gpoutfile);	/* carriage return */
	fprintf(gpoutfile, "\033%c", 'U');	/* unidirectional printing */
	(void) fputc((char) 0, gpoutfile);

	switch (DPU414_quality) {
	case 1:
		for (j = (b_ysize / 8) - 1; j >= 0; j-=2) {
			/* select 120-dpi, emulated 16-pin printer graphics mode */
			/* in reality it's 640/(89.6mm/25.4mm) = 181 dpi = appr. 180 dpi */
			fputs("\033^\001", gpoutfile);
			(void) fputc((char) (b_xsize % 256), gpoutfile);
			(void) fputc((char) (b_xsize / 256), gpoutfile);
			for (x = 0; x < b_xsize; x++) {
				(void) fputc((char) (*((*b_p)[j] + x)), gpoutfile);
				(void) fputc((char) (*((*b_p)[j-1] + x)), gpoutfile);
			}
			fprintf(gpoutfile, "\033%c\x10\r", 'J');	/* advance 16 halfdots, carriage return */
		}
		break;
	case 2:
		for (j = (b_ysize / 8) - 1; j >= 0; j--) {
			/* select 60-dpi, 8-pin printer graphics mode */
			/* in reality it's 320/(89.6mm/25.4mm) = 91 dpi = appr. 90 dpi */
			fputs("\033K", gpoutfile);
			(void) fputc((char) (b_xsize % 256), gpoutfile);
			(void) fputc((char) (b_xsize / 256), gpoutfile);
			for (x = 0; x < b_xsize; x++) {
				(void) fputc((char) (*((*b_p)[j] + x)), gpoutfile);
			}
			fprintf(gpoutfile, "\033%c\x10\r", 'J');	/* advance 16 halfdots, carriage return */
		}
		break;
	}
	fputs("\r\n\033@\r\n", gpoutfile);	/* reset printer */
#ifdef PC
	fputs("Print using: COPY /B\n", stderr);
#endif
}

#endif /* DPU414 */

#endif /* TERM_BODY */

#ifdef TERM_TABLE

#ifdef EPS180
TERM_TABLE_START(epson180_driver)
    "epson_180dpi", "Epson LQ-style 180-dot per inch (24 pin) printers",
    EPS180XMAX, EPS180YMAX, EPSON180VCHAR, EPSON180HCHAR,
    EPSON180VTIC, EPSON180HTIC, options_null, EPSON_init, EPSON_reset,
    EPS180_text, null_scale, EPS180_graphics, b_move, b_vector,
    b_setlinetype, b_put_text, b_text_angle,
    null_justify_text, do_point, do_arrow, set_font_null, 0, TERM_BINARY,
    0, 0, b_boxfill
TERM_TABLE_END(epson180_driver)

#undef LAST_TERM
#define LAST_TERM epson180_driver
#endif /* EPS180 */

#ifdef EPS60
TERM_TABLE_START(epson60_driver)
    "epson_60dpi", "Epson-style 60-dot per inch printers",
    EPS60XMAX, EPS60YMAX, EPSONVCHAR, EPSONHCHAR,
    EPSONVTIC, EPSONHTIC, options_null, EPSON_init, EPSON_reset,
    EPS60_text, null_scale, EPS60_graphics, b_move, b_vector,
    b_setlinetype, b_put_text, b_text_angle,
    null_justify_text, do_point, do_arrow, set_font_null, 0, TERM_BINARY,
    0, 0, b_boxfill
TERM_TABLE_END(epson60_driver)

#undef LAST_TERM
#define LAST_TERM epson60_driver
#endif /* EPS60 */

#ifdef EPSONP
TERM_TABLE_START(epsonlx_driver)
    "epson_lx800", "Epson LX-800, Star NL-10, NX-1000, PROPRINTER ...",
    EPSONXMAX, EPSONYMAX, EPSONVCHAR, EPSONHCHAR,
    EPSONVTIC, EPSONHTIC, options_null, EPSON_init, EPSON_reset,
    EPSON_text, null_scale, EPSON_graphics, b_move, b_vector,
    b_setlinetype, b_put_text, b_text_angle,
    null_justify_text, line_and_point, do_arrow, set_font_null, 0, TERM_BINARY,
    0, 0, b_boxfill
TERM_TABLE_END(epsonlx_driver)

#undef LAST_TERM
#define LAST_TERM epsonlx_driver
#endif /* EPSONP */

#ifdef NEC
    TERM_TABLE_START(nec_driver)
    "nec_cp6", "NEC printer CP6, Epson LQ-800 [monochrome color draft]",
    NECXMAX, NECYMAX, NECVCHAR, NECHCHAR,
    NECVTIC, NECHTIC, NEC_options, NEC_init, EPSON_reset,
    NEC_text, null_scale, NEC_graphics, b_move, b_vector,
    NEC_linetype, b_put_text, b_text_angle,
    null_justify_text, line_and_point, do_arrow, set_font_null, 0, TERM_BINARY,
    0, 0, b_boxfill
TERM_TABLE_END(nec_driver)

#undef LAST_TERM
#define LAST_TERM nec_driver
#endif /* NEC */

#ifdef OKIDATA
TERM_TABLE_START(okidata_driver)
    "okidata", "OKIDATA 320/321 Standard",
    EPS60XMAX, EPS60YMAX, EPSONVCHAR, EPSONHCHAR,
    EPSONVTIC, EPSONHTIC, options_null, EPSON_init, EPSON_reset,
    OKIDATA_text, null_scale, EPS60_graphics, b_move, b_vector,
    b_setlinetype, b_put_text, b_text_angle,
    null_justify_text, do_point, do_arrow, set_font_null, 0, TERM_BINARY,
    0, 0, b_boxfill
TERM_TABLE_END(okidata_driver)

#undef LAST_TERM
#define LAST_TERM okidata_driver
#endif /* OKIDATA */

#ifdef STARC
TERM_TABLE_START(starc_driver)
    "starc", "Star Color Printer",
    STARCXMAX, STARCYMAX, STARCVCHAR, STARCHCHAR,
    STARCVTIC, STARCHTIC, options_null, STARC_init, EPSON_reset,
    STARC_text, null_scale, STARC_graphics, b_move, b_vector,
    STARC_linetype, b_put_text, b_text_angle,
    null_justify_text, line_and_point, do_arrow, set_font_null, 0, TERM_BINARY,
    0, 0, b_boxfill
TERM_TABLE_END(starc_driver)

#undef LAST_TERM
#define LAST_TERM starc_driver
#endif /* STARC */

#ifdef TANDY60
TERM_TABLE_START(tandy60_driver)
    "tandy_60dpi", "Tandy DMP-130 series 60-dot per inch graphics",
    EPS60XMAX, EPS60YMAX, EPSONVCHAR, EPSONHCHAR,
    EPSONVTIC, EPSONHTIC, options_null, EPSON_init, EPSON_reset,
    TANDY60_text, null_scale, EPS60_graphics, b_move, b_vector,
    b_setlinetype, b_put_text, b_text_angle,
    null_justify_text, do_point, do_arrow, set_font_null, 0, TERM_BINARY,
    0, 0, b_boxfill
TERM_TABLE_END(tandy60_driver)

#undef LAST_TERM
#define LAST_TERM tandy60_driver
#endif /* TANDY60 */

#ifdef DPU414
TERM_TABLE_START(dpu414_driver)
    "dpu414", "Seiko DPU-414 thermal printer [small medium large]",
    DPU414XMAX, DPU414YMAX, DPU414VCHAR, DPU414HCHAR,
    DPU414VTIC, DPU414HTIC, DPU414_options, DPU414_init, EPSON_reset,
    DPU414_text, null_scale, DPU414_graphics, b_move, b_vector,
    b_setlinetype, b_put_text, b_text_angle,
    null_justify_text, line_and_point, do_arrow, set_font_null, 0, TERM_BINARY,
    0, 0, b_boxfill
TERM_TABLE_END(dpu414_driver)

#undef LAST_TERM
#define LAST_TERM dpu414_driver
#endif /* DPU414 */

#endif /* TERM_TABLE */
#endif /* TERM_PROTO_ONLY */

#ifdef TERM_HELP
START_HELP(epson_180dpi)
"1 epson_180dpi",
"?commands set terminal epson_180dpi",
"?set terminal epson_180dpi",
"?set term epson_180dpi",
"?terminal epson_180dpi",
"?term epson_180dpi",
"?epson_180dpi",
"?commands set terminal epson_60dpi",
"?set terminal epson_60dpi",
"?set term epson_60dpi",
"?terminal epson_60dpi",
"?term epson_60dpi",
"?epson_60dpi",
"?commands set terminal epson_lx800",
"?set terminal epson_lx800",
"?set term epson_lx800",
"?terminal epson_lx800",
"?term epson_lx800",
"?epson_lx800",
"?commands set terminal nec_cp6",
"?set terminal nec_cp6",
"?set term nec_cp6",
"?terminal nec_cp6",
"?term nec_cp6",
"?nec_cp6",
"?commands set terminal okidata",
"?set terminal okidata",
"?set term okidata",
"?terminal okidata",
"?term okidata",
"?okidata",
"?commands set terminal starc",
"?set terminal starc",
"?set term starc",
"?terminal starc",
"?term starc",
"?starc",
"?commands set terminal tandy_60dpi",
"?set terminal tandy_60dpi",
"?set term tandy_60dpi",
"?terminal tandy_60dpi",
"?term tandy_60dpi",
"?tandy_60dpi",
"?commands set terminal dpu414",
"?set terminal dpu414",
"?set term dpu414",
"?terminal dpu414",
"?term dpu414",
"?dpu414",
" This driver supports a family of Epson printers and derivatives.",
"",
" `epson_180dpi` and `epson_60dpi` are drivers for Epson LQ-style 24-pin",
" printers with resolutions of 180 and 60 dots per inch, respectively.",
"",
" `epson_lx800` is a generic 9-pin driver appropriate for printers like the",
" Epson LX-800, the Star NL-10 and NX-1000, the PROPRINTER, and so forth.",
"",
" `nec_cp6` is generic 24-pin driver that can be used for printers like the",
" NEC CP6 and the Epson LQ-800.",
"",
" The `okidata` driver supports the 9-pin OKIDATA 320/321 Standard printers.",
"",
" The `starc` driver is for the Star Color Printer.",
"",
" The `tandy_60dpi` driver is for the Tandy DMP-130 series of 9-pin, 60-dpi",
" printers.",
"",
" The `dpu414` driver is for the Seiko DPU-414 thermal printer.",
"",
" `nec_cp6` has the options:",
"",
" Syntax:",
"       set terminal nec_cp6 {monochrome | colour | draft}",
"",
" which defaults to monochrome.",
"",
" `dpu414` has the options:",
"",
" Syntax:",
"       set terminal dpu414 {small | medium | large} {normal | draft}",
"",
" which defaults to medium (=font size) and normal.",
" Preferred combinations are `medium normal` and `small draft`.",
#ifdef MSDOS
"",
" With each of these drivers, a binary copy is required on a PC to print.",
" Do not use `print`---use instead `copy file /b lpt1:`.",
#endif
""
END_HELP(epson_180dpi)
#endif /* TERM_HELP */