Initial release of Maemo 5 port of gnuplot
[gnuplot] / term / v384.trm
1 /* Hello, Emacs, this is -*-C-*-
2  * $Id: v384.trm,v 1.12 2006/07/21 02:35:48 sfeam Exp $
3  *
4  */
5
6 /* GNUPLOT - v384.trm */
7
8 /*[
9  * Copyright 1990 - 1993, 1998, 2004
10  *
11  * Permission to use, copy, and distribute this software and its
12  * documentation for any purpose with or without fee is hereby granted,
13  * provided that the above copyright notice appear in all copies and
14  * that both that copyright notice and this permission notice appear
15  * in supporting documentation.
16  *
17  * Permission to modify the software is granted, but not the right to
18  * distribute the complete modified source code.  Modifications are to
19  * be distributed as patches to the released version.  Permission to
20  * distribute binaries produced by compiling modified sources is granted,
21  * provided you
22  *   1. distribute the corresponding source modifications from the
23  *    released version in the form of a patch file along with the binaries,
24  *   2. add special version identification to distinguish your version
25  *    in addition to the base release version number,
26  *   3. provide your name and address as the primary contact for the
27  *    support of your modified version, and
28  *   4. retain our contact information in regard to use of the base
29  *    software.
30  * Permission to distribute the released version of the source code along
31  * with corresponding source modifications in the form of a patch file is
32  * granted with same provisions 2 through 4 for binary distributions.
33  *
34  * This software is provided "as is" without express or implied warranty
35  * to the extent permitted by applicable law.
36 ]*/
37
38 /*
39  * This file is included by ../term.c.
40  *
41  * This terminal driver supports:
42  *  Vectrix 384 - works with tandy color printer as well
43  *
44  * AUTHORS
45  *   roland@moncskermit.OZ (Roland Yap)
46  *
47  * send your comments or suggestions to (gnuplot-info@lists.sourceforge.net).
48  *
49  */
50
51 /*
52  *      Vectrix 384 driver - works with tandy color printer as well
53  *  in reverse printing 8 color mode.
54  *  This doesn't work on Vectrix 128 because it redefines the
55  *  color table. It can be hacked to work on the 128 by changing
56  *  the colours but then it will probably not print best. The color
57  *  table is purposely designed so that it will print well
58  *
59  */
60
61 /*
62  * adapted to the new terminal layout by Stefan Bodewig (Dec. 1995)
63  */
64
65 #include "driver.h"
66
67 #ifdef TERM_REGISTER
68 register_term(vx384)
69 #endif
70
71 #ifdef TERM_PROTO
72 TERM_PUBLIC void V384_init __PROTO((void));
73 TERM_PUBLIC void V384_graphics __PROTO((void));
74 TERM_PUBLIC void V384_text __PROTO((void));
75 TERM_PUBLIC void V384_linetype __PROTO((int linetype));
76 TERM_PUBLIC void V384_move __PROTO((unsigned int x, unsigned int y));
77 TERM_PUBLIC void V384_vector __PROTO((unsigned int x, unsigned int y));
78 TERM_PUBLIC void V384_put_text __PROTO((unsigned int x, unsigned int y, const char str[]));
79 TERM_PUBLIC void V384_reset __PROTO((void));
80
81 #define V384_XMAX 630
82 #define V384_YMAX 480
83
84 #define V384_XLAST (V384_XMAX - 1)
85 #define V384_YLAST (V384_YMAX - 1)
86
87 #define V384_VCHAR      12
88 #define V384_HCHAR      7
89 #define V384_VTIC       8
90 #define V384_HTIC       7
91 #endif /* TERM_PROTO */
92
93 #ifndef TERM_PROTO_ONLY
94 #ifdef TERM_BODY
95
96 TERM_PUBLIC void
97 V384_init()
98 {
99     fprintf(gpoutfile, "%c%c  G0   \n\
100 Q 0 8\n\
101 0 0 0\n\
102 255 0 0\n\
103 0 255 0\n\
104 0 0 255\n\
105 0 255 255\n\
106 255 0 255\n\
107 255 255 0\n\
108 255 255 255\n",
109             27, 18);
110 }
111
112
113 TERM_PUBLIC void
114 V384_graphics()
115 {
116     fprintf(gpoutfile, "%c%c E0 RE N 65535\n", 27, 18);
117 }
118
119
120 TERM_PUBLIC void
121 V384_text()
122 {
123     fprintf(gpoutfile, "%c%c\n", 27, 17);
124 }
125
126
127 TERM_PUBLIC void
128 V384_linetype(int linetype)
129 {
130     static int color[] =
131     {
132         1 /* red */ ,
133         2 /* green */ ,
134         3 /* blue */ ,
135         4 /* cyan */ ,
136         5 /* magenta */ ,
137         6 /* yellow */ ,        /* not a good color so not in use at the moment */
138         7 /* white */
139     };
140
141     if (linetype < 0)
142         linetype = 6;
143     else
144         linetype %= 5;
145
146     fprintf(gpoutfile, "C %d\n", color[linetype]);
147 }
148
149
150 TERM_PUBLIC void
151 V384_move(unsigned int x, unsigned int y)
152 {
153     fprintf(gpoutfile, "M %d %d\n", x + 20, y);
154 }
155
156
157 TERM_PUBLIC void
158 V384_vector(unsigned int x, unsigned int y)
159 {
160     fprintf(gpoutfile, "L %d %d\n", x + 20, y);
161 }
162
163
164 TERM_PUBLIC void
165 V384_put_text(unsigned int x, unsigned int y, const char str[])
166 {
167     V384_move(x, y + V384_VCHAR / 2);
168     fprintf(gpoutfile, "$%s\n", str);
169 }
170
171
172 TERM_PUBLIC void
173 V384_reset()
174 {
175 }
176
177 #endif /* TERM_BODY */
178
179 #ifdef TERM_TABLE
180 TERM_TABLE_START(vx384_driver)
181     "vx384", "Vectrix 384 and Tandy color printer",
182     V384_XMAX, V384_YMAX, V384_VCHAR, V384_HCHAR,
183     V384_VTIC, V384_HTIC, options_null, V384_init, V384_reset,
184     V384_text, null_scale, V384_graphics, V384_move, V384_vector,
185     V384_linetype, V384_put_text, null_text_angle,
186     null_justify_text, do_point, do_arrow, set_font_null
187 TERM_TABLE_END(vx384_driver)
188
189 #undef LAST_TERM
190 #define LAST_TERM vx384_driver
191
192 #endif /* TERM_TABLE */
193 #endif /* TERM_PROTO_ONLY */
194
195 #ifdef TERM_HELP
196 START_HELP(vx384)
197 "1 vx384",
198 "?commands set terminal vx384",
199 "?set terminal vx384",
200 "?set term vx384",
201 "?terminal vx384",
202 "?term vx384",
203 "?vx384",
204 " The `vx384` terminal driver supports the Vectrix 384 and Tandy color",
205 " printers.  It has no options."
206 END_HELP(vx384)
207 #endif