1 | /*
|
---|
2 | =============================================================================
|
---|
3 | glcinit.c -- LCD drivers for the Epson GLC controller chip
|
---|
4 | Version 5 -- 1988-08-03 -- D.N. Lynx Crowe
|
---|
5 | (c) Copyright 1987, 1988 -- D.N. Lynx Crowe
|
---|
6 |
|
---|
7 | GLCinit()
|
---|
8 |
|
---|
9 | Initializes the GLC.
|
---|
10 |
|
---|
11 | unsigned
|
---|
12 | GLCcrc(row, col)
|
---|
13 | unsigned row, col;
|
---|
14 |
|
---|
15 | Positions the GLC cursor at ('row', 'col') preparatory
|
---|
16 | to writing text. Returns the calculated cursor address.
|
---|
17 |
|
---|
18 | unsigned
|
---|
19 | GLCcxy(x, y)
|
---|
20 | unsigned x, y;
|
---|
21 |
|
---|
22 | Positions the GLC cursor at ('x', 'y') preparatory to
|
---|
23 | writing graphics. Returns a bit mask for the pixel.
|
---|
24 | Leaves the cursor address in lcdcurs.
|
---|
25 | Limits: 0 LE x LE 511, 0 LE y LE 63.
|
---|
26 |
|
---|
27 | GLCwrts(s)
|
---|
28 | char *s;
|
---|
29 |
|
---|
30 | Writes the character string pointed to by 's' at the
|
---|
31 | current cursor position on the LCD display.
|
---|
32 | Cursor must start and end on the same line.
|
---|
33 | No error checks are done.
|
---|
34 |
|
---|
35 | GLCtext(row, col, s)
|
---|
36 | unsigned row, col;
|
---|
37 | char *s;
|
---|
38 |
|
---|
39 | Sets the GLC cursor to ('row', 'col'), then writes the
|
---|
40 | character string pointed to by 's'.
|
---|
41 | Cursor must start and end on the same line.
|
---|
42 | No error checks are done.
|
---|
43 | |
---|
44 |
|
---|
45 | GLCdisp(dsp, crs, blk1, blk2, blk3)
|
---|
46 | short dsp, crs, blk1, blk2, blk3;
|
---|
47 |
|
---|
48 | Sets the overall display, cursor and block status values.
|
---|
49 |
|
---|
50 | GLCcurs(crs)
|
---|
51 | short crs;
|
---|
52 |
|
---|
53 | Turns the cursor on or off.
|
---|
54 | =============================================================================
|
---|
55 | */
|
---|
56 |
|
---|
57 | /* |
---|
58 |
|
---|
59 | */
|
---|
60 |
|
---|
61 | #include "stddefs.h"
|
---|
62 | #include "hwdefs.h"
|
---|
63 | #include "glcdefs.h"
|
---|
64 |
|
---|
65 | unsigned lcdbase; /* LCD graphics base address */
|
---|
66 | unsigned lcdbit; /* LCD graphics pixel bit mask */
|
---|
67 | unsigned lcdcol; /* LCD text column */
|
---|
68 | unsigned lcdctl1; /* LCD display control -- command */
|
---|
69 | unsigned lcdctl2; /* LCD display control -- data */
|
---|
70 | unsigned lcdcurs; /* LCD graphics pixel byte address */
|
---|
71 | unsigned lcdrow; /* LCD text row */
|
---|
72 | unsigned lcdx; /* LCD graphics x */
|
---|
73 | unsigned lcdy; /* LCD graphics y */
|
---|
74 |
|
---|
75 | /* GLC initialization values */
|
---|
76 |
|
---|
77 | char glc_is1[] = { 0x12, 0x05, 0x07, 0x54, 0x58, 0x3F, 0x55, 0x00 };
|
---|
78 | char glc_is2[] = { 0x00, 0x00, 0x3F, 0x00, 0x20, 0x3F, 0x00, 0x00 };
|
---|
79 |
|
---|
80 | /* |
---|
81 |
|
---|
82 | */
|
---|
83 |
|
---|
84 | /*
|
---|
85 | =============================================================================
|
---|
86 | GLCdisp(dsp, crs, blk1, blk2, blk3) -- set GLC display status
|
---|
87 | Sets the overall display, cursor and block status values.
|
---|
88 | =============================================================================
|
---|
89 | */
|
---|
90 |
|
---|
91 | GLCdisp(dsp, crs, blk1, blk2, blk3)
|
---|
92 | short dsp, crs, blk1, blk2, blk3;
|
---|
93 | {
|
---|
94 | register short val;
|
---|
95 |
|
---|
96 | val = ((blk3 & 3) << 6) | ((blk2 & 3) << 4) | ((blk1 & 3) << 2) |
|
---|
97 | (crs & 3);
|
---|
98 |
|
---|
99 | lcdctl1 = G_DSPCTL | (dsp & 1);
|
---|
100 | lcdctl2 = val;
|
---|
101 |
|
---|
102 | LCD_WC = lcdctl1;
|
---|
103 | LCD_WD = lcdctl2;
|
---|
104 |
|
---|
105 | }
|
---|
106 |
|
---|
107 | /*
|
---|
108 | =============================================================================
|
---|
109 | GLCcurs() -- turns the cursor on or off
|
---|
110 | =============================================================================
|
---|
111 | */
|
---|
112 |
|
---|
113 | GLCcurs(crs)
|
---|
114 | short crs;
|
---|
115 | {
|
---|
116 | lcdctl2 = (crs & 3) | (lcdctl2 & ~3);
|
---|
117 |
|
---|
118 | LCD_WC = lcdctl1;
|
---|
119 | LCD_WD = lcdctl2;
|
---|
120 | }
|
---|
121 |
|
---|
122 | /* |
---|
123 |
|
---|
124 | */
|
---|
125 |
|
---|
126 | /*
|
---|
127 | =============================================================================
|
---|
128 | GLCinit() -- initialize GLC
|
---|
129 | Initializes the GLC.
|
---|
130 | =============================================================================
|
---|
131 | */
|
---|
132 |
|
---|
133 | GLCinit()
|
---|
134 | {
|
---|
135 | register int i;
|
---|
136 | register long ic;
|
---|
137 | register char *gp;
|
---|
138 |
|
---|
139 | lcdbase = G_PLANE2; /* set defaults for graphics variables */
|
---|
140 | lcdx = 0;
|
---|
141 | lcdy = 0;
|
---|
142 | lcdbit = 0x01;
|
---|
143 |
|
---|
144 | lcdrow = 0; /* set default for text variables */
|
---|
145 | lcdcol = 0;
|
---|
146 |
|
---|
147 | lcdctl1 = G_DSPCTL;
|
---|
148 | lcdctl2 = 0;
|
---|
149 |
|
---|
150 | LCD_WC = G_INIT; /* initialize the GLC */
|
---|
151 | gp = &glc_is1[0];
|
---|
152 |
|
---|
153 | for (i = 0; i < 8; i++)
|
---|
154 | LCD_WD= *gp++;
|
---|
155 |
|
---|
156 | LCD_WC = G_SETSAD; /* setup scroll registers */
|
---|
157 | gp = &glc_is2[0];
|
---|
158 |
|
---|
159 | for (i = 0; i < 8; i++)
|
---|
160 | LCD_WD = *gp++;
|
---|
161 |
|
---|
162 | LCD_WC = G_HSCRL; /* clear the horizontal scroll counter */
|
---|
163 | LCD_WD = 0;
|
---|
164 |
|
---|
165 | LCD_WC = G_OVRLAY; /* setup the display mode */
|
---|
166 | LCD_WD = 0x08;
|
---|
167 |
|
---|
168 | GLCdisp(G_OFF, G_B2, G_ON, G_ON, G_OFF);
|
---|
169 |
|
---|
170 | /* |
---|
171 |
|
---|
172 | */
|
---|
173 | LCD_WC = G_CRSWR; /* set cursor at (0,0) in G_PLANE1 */
|
---|
174 | LCD_WD = G_PLANE1 & 0xFF;
|
---|
175 | LCD_WD = (G_PLANE1 >> 8) & 0xFF;
|
---|
176 |
|
---|
177 | LCD_WC = G_CRSMRT; /* set cursor motion forward */
|
---|
178 |
|
---|
179 | LCD_WC = G_MWRITE; /* write zeros to GLC RAM */
|
---|
180 |
|
---|
181 | for (ic = 0; ic < 65536L; ic++)
|
---|
182 | LCD_WD = 0;
|
---|
183 |
|
---|
184 | LCD_WC = G_CRSWR; /* set cursor to (0,0) in G_PLANE1 */
|
---|
185 | LCD_WD = G_PLANE1 & 0xFF;
|
---|
186 | LCD_WD = (G_PLANE1 >> 8) & 0xFF;
|
---|
187 |
|
---|
188 | LCD_WC = G_CRSFRM; /* setup a blinking underline cursor */
|
---|
189 | LCD_WD = 0x04;
|
---|
190 | LCD_WD = 0x06;
|
---|
191 |
|
---|
192 | /* enable display */
|
---|
193 |
|
---|
194 | GLCdisp(G_ON, G_B2, G_ON, G_ON, G_OFF);
|
---|
195 | }
|
---|
196 |
|
---|
197 | /* |
---|
198 |
|
---|
199 | */
|
---|
200 |
|
---|
201 | /*
|
---|
202 | =============================================================================
|
---|
203 | GLCcrc(row, col) -- position GLC text cursor
|
---|
204 | Positions the GLC cursor at ('row', 'col') preparatory
|
---|
205 | to writing text. Returns calculated cursor address.
|
---|
206 | =============================================================================
|
---|
207 | */
|
---|
208 |
|
---|
209 | unsigned
|
---|
210 | GLCcrc(row, col)
|
---|
211 | unsigned row, col;
|
---|
212 | {
|
---|
213 | unsigned curad;
|
---|
214 |
|
---|
215 | curad = col + (row * 85); /* calculate cursor location */
|
---|
216 |
|
---|
217 | LCD_WC = G_CRSWR; /* send cursor address to GLC */
|
---|
218 | LCD_WD = curad & 0xFF;
|
---|
219 | LCD_WD = (curad >> 8) & 0xFF;
|
---|
220 |
|
---|
221 | lcdrow = row; /* set text cursor variables */
|
---|
222 | lcdcol = col;
|
---|
223 |
|
---|
224 | return(curad); /* return calculated cursor address */
|
---|
225 | }
|
---|
226 |
|
---|
227 | /* |
---|
228 |
|
---|
229 | */
|
---|
230 |
|
---|
231 | /*
|
---|
232 | =============================================================================
|
---|
233 | GLCcxy(x, y) -- position GLC graphics cursor
|
---|
234 | Positions the GLC cursor at ('x', 'y') preparatory to
|
---|
235 | writing graphics. Returns a bit mask for the pixel.
|
---|
236 | Leaves cursor address in lcdcurs.
|
---|
237 | Limits: 0 LE x LE 511, 0 LE y LE 63.
|
---|
238 | =============================================================================
|
---|
239 | */
|
---|
240 |
|
---|
241 | unsigned
|
---|
242 | GLCcxy(x, y)
|
---|
243 | register unsigned x, y;
|
---|
244 | {
|
---|
245 | register unsigned curad, xby6;
|
---|
246 |
|
---|
247 | /* calculate cursor address */
|
---|
248 |
|
---|
249 | xby6 = x % 6;
|
---|
250 | curad = lcdbase + (85 * (63 - y)) + (x / 6) + (xby6 >> 3);
|
---|
251 | lcdcurs = curad;
|
---|
252 |
|
---|
253 | /* send cursor address to GLC */
|
---|
254 |
|
---|
255 | LCD_WC = G_CRSWR;
|
---|
256 | LCD_WD = curad & 0xFF;
|
---|
257 | LCD_WD = (curad >> 8) & 0xFF;
|
---|
258 |
|
---|
259 | /* set graphics variables */
|
---|
260 |
|
---|
261 | lcdx = x;
|
---|
262 | lcdy = y;
|
---|
263 |
|
---|
264 | /* calculate bit mask */
|
---|
265 |
|
---|
266 | lcdbit = 0x01 << (xby6 & 0x07);
|
---|
267 |
|
---|
268 | return(lcdbit);
|
---|
269 | }
|
---|
270 |
|
---|
271 | /* |
---|
272 |
|
---|
273 | */
|
---|
274 |
|
---|
275 | /*
|
---|
276 | =============================================================================
|
---|
277 | GLCwrts(s) -- write text string to GLC
|
---|
278 | Writes the character string pointed to by 's' at the
|
---|
279 | current cursor position on the LCD display.
|
---|
280 | Cursor must start and end on the same line.
|
---|
281 | No error checks are done.
|
---|
282 | =============================================================================
|
---|
283 | */
|
---|
284 |
|
---|
285 | GLCwrts(s)
|
---|
286 | register char *s;
|
---|
287 | {
|
---|
288 | LCD_WC = G_CRSMRT; /* set cursor motion = right */
|
---|
289 |
|
---|
290 | LCD_WC = G_MWRITE; /* set to write data */
|
---|
291 |
|
---|
292 | while (*s) { /* write string to GLC */
|
---|
293 |
|
---|
294 | LCD_WD = *s++;
|
---|
295 | lcdcol++; /* keep column variable up to date */
|
---|
296 | }
|
---|
297 | }
|
---|
298 |
|
---|
299 | /* |
---|
300 |
|
---|
301 | */
|
---|
302 |
|
---|
303 | /*
|
---|
304 | =============================================================================
|
---|
305 | GLCtext(row, col, s) -- position GLC cursor and write text
|
---|
306 | Sets the GLC cursor to ('row', 'col'), then writes the
|
---|
307 | character string pointed to by 's'.
|
---|
308 | Cursor must start and end on the same line.
|
---|
309 | No error checks are done.
|
---|
310 | =============================================================================
|
---|
311 | */
|
---|
312 |
|
---|
313 | GLCtext(row, col, s)
|
---|
314 | register unsigned row, col;
|
---|
315 | register char *s;
|
---|
316 | {
|
---|
317 | register unsigned curad;
|
---|
318 |
|
---|
319 | curad = col + (row * 85); /* calculate cursor address */
|
---|
320 |
|
---|
321 | LCD_WC = G_CRSWR; /* send cursor address to GLC */
|
---|
322 | LCD_WD = curad & 0xFF;
|
---|
323 | LCD_WD = (curad >> 8) & 0xFF;
|
---|
324 |
|
---|
325 | lcdrow = row; /* set GLC text cursor variables */
|
---|
326 | lcdcol = col;
|
---|
327 |
|
---|
328 | LCD_WC = G_CRSMRT; /* set cursor motion = right */
|
---|
329 |
|
---|
330 | LCD_WC = G_MWRITE; /* set to write data */
|
---|
331 |
|
---|
332 | while (*s) { /* write string to GLC */
|
---|
333 |
|
---|
334 | LCD_WD = *s++;
|
---|
335 | lcdcol++; /* keep cursor column up to date */
|
---|
336 | }
|
---|
337 | }
|
---|
338 |
|
---|