source: buchla-68k/vlib/glcinit.c@ d21fc6f

Last change on this file since d21fc6f was b28a12e, checked in by Thomas Lopatic <thomas@…>, 7 years ago

Zero redundant declarations.

  • Property mode set to 100644
File size: 7.3 KB
Line 
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 "ram.h"
62
63uint16_t lcdbase; /* LCD graphics base address */
64uint16_t lcdbit; /* LCD graphics pixel bit mask */
65uint16_t lcdcol; /* LCD text column */
66uint16_t lcdctl1; /* LCD display control -- command */
67uint16_t lcdctl2; /* LCD display control -- data */
68uint16_t lcdcurs; /* LCD graphics pixel byte address */
69uint16_t lcdrow; /* LCD text row */
70uint16_t lcdx; /* LCD graphics x */
71uint16_t lcdy; /* LCD graphics y */
72
73/* GLC initialization values */
74
75int8_t glc_is1[] = { 0x12, 0x05, 0x07, 0x54, 0x58, 0x3F, 0x55, 0x00 };
76int8_t glc_is2[] = { 0x00, 0x00, 0x3F, 0x00, 0x20, 0x3F, 0x00, 0x00 };
77
78/*
79
80*/
81
82/*
83 =============================================================================
84 GLCdisp(dsp, crs, blk1, blk2, blk3) -- set GLC display status
85 Sets the overall display, cursor and block status values.
86 =============================================================================
87*/
88
89void GLCdisp(int16_t dsp, int16_t crs, int16_t blk1, int16_t blk2, int16_t blk3)
90{
91 register int16_t val;
92
93 val = ((blk3 & 3) << 6) | ((blk2 & 3) << 4) | ((blk1 & 3) << 2) |
94 (crs & 3);
95
96 lcdctl1 = G_DSPCTL | (dsp & 1);
97 lcdctl2 = val;
98
99 LCD_WC = lcdctl1;
100 LCD_WD = lcdctl2;
101
102}
103
104/*
105 =============================================================================
106 GLCcurs() -- turns the cursor on or off
107 =============================================================================
108*/
109
110void GLCcurs(int16_t crs)
111{
112 lcdctl2 = (crs & 3) | (lcdctl2 & ~3);
113
114 LCD_WC = lcdctl1;
115 LCD_WD = lcdctl2;
116}
117
118/*
119
120*/
121
122/*
123 =============================================================================
124 GLCinit() -- initialize GLC
125 Initializes the GLC.
126 =============================================================================
127*/
128
129void GLCinit(void)
130{
131 register int16_t i;
132 register int32_t ic;
133 register int8_t *gp;
134
135 lcdbase = G_PLANE2; /* set defaults for graphics variables */
136 lcdx = 0;
137 lcdy = 0;
138 lcdbit = 0x01;
139
140 lcdrow = 0; /* set default for text variables */
141 lcdcol = 0;
142
143 lcdctl1 = G_DSPCTL;
144 lcdctl2 = 0;
145
146 LCD_WC = G_INIT; /* initialize the GLC */
147 gp = &glc_is1[0];
148
149 for (i = 0; i < 8; i++)
150 LCD_WD= *gp++;
151
152 LCD_WC = G_SETSAD; /* setup scroll registers */
153 gp = &glc_is2[0];
154
155 for (i = 0; i < 8; i++)
156 LCD_WD = *gp++;
157
158 LCD_WC = G_HSCRL; /* clear the horizontal scroll counter */
159 LCD_WD = 0;
160
161 LCD_WC = G_OVRLAY; /* setup the display mode */
162 LCD_WD = 0x08;
163
164 GLCdisp(G_OFF, G_B2, G_ON, G_ON, G_OFF);
165
166/*
167
168*/
169 LCD_WC = G_CRSWR; /* set cursor at (0,0) in G_PLANE1 */
170 LCD_WD = G_PLANE1 & 0xFF;
171 LCD_WD = (G_PLANE1 >> 8) & 0xFF;
172
173 LCD_WC = G_CRSMRT; /* set cursor motion forward */
174
175 LCD_WC = G_MWRITE; /* write zeros to GLC RAM */
176
177 for (ic = 0; ic < 65536L; ic++)
178 LCD_WD = 0;
179
180 LCD_WC = G_CRSWR; /* set cursor to (0,0) in G_PLANE1 */
181 LCD_WD = G_PLANE1 & 0xFF;
182 LCD_WD = (G_PLANE1 >> 8) & 0xFF;
183
184 LCD_WC = G_CRSFRM; /* setup a blinking underline cursor */
185 LCD_WD = 0x04;
186 LCD_WD = 0x06;
187
188 /* enable display */
189
190 GLCdisp(G_ON, G_B2, G_ON, G_ON, G_OFF);
191}
192
193/*
194
195*/
196
197/*
198 =============================================================================
199 GLCcrc(row, col) -- position GLC text cursor
200 Positions the GLC cursor at ('row', 'col') preparatory
201 to writing text. Returns calculated cursor address.
202 =============================================================================
203*/
204
205uint16_t GLCcrc(uint16_t row, uint16_t col)
206{
207 uint16_t curad;
208
209 curad = col + (row * 85); /* calculate cursor location */
210
211 LCD_WC = G_CRSWR; /* send cursor address to GLC */
212 LCD_WD = curad & 0xFF;
213 LCD_WD = (curad >> 8) & 0xFF;
214
215 lcdrow = row; /* set text cursor variables */
216 lcdcol = col;
217
218 return(curad); /* return calculated cursor address */
219}
220
221/*
222
223*/
224
225/*
226 =============================================================================
227 GLCcxy(x, y) -- position GLC graphics cursor
228 Positions the GLC cursor at ('x', 'y') preparatory to
229 writing graphics. Returns a bit mask for the pixel.
230 Leaves cursor address in lcdcurs.
231 Limits: 0 LE x LE 511, 0 LE y LE 63.
232 =============================================================================
233*/
234
235uint16_t GLCcxy(uint16_t x, uint16_t y)
236{
237 register uint16_t curad, xby6;
238
239 /* calculate cursor address */
240
241 xby6 = x % 6;
242 curad = lcdbase + (85 * (63 - y)) + (x / 6) + (xby6 >> 3);
243 lcdcurs = curad;
244
245 /* send cursor address to GLC */
246
247 LCD_WC = G_CRSWR;
248 LCD_WD = curad & 0xFF;
249 LCD_WD = (curad >> 8) & 0xFF;
250
251 /* set graphics variables */
252
253 lcdx = x;
254 lcdy = y;
255
256 /* calculate bit mask */
257
258 lcdbit = 0x01 << (xby6 & 0x07);
259
260 return(lcdbit);
261}
262
263/*
264
265*/
266
267/*
268 =============================================================================
269 GLCwrts(s) -- write text string to GLC
270 Writes the character string pointed to by 's' at the
271 current cursor position on the LCD display.
272 Cursor must start and end on the same line.
273 No error checks are done.
274 =============================================================================
275*/
276
277void GLCwrts(int8_t *s)
278{
279 LCD_WC = G_CRSMRT; /* set cursor motion = right */
280
281 LCD_WC = G_MWRITE; /* set to write data */
282
283 while (*s) { /* write string to GLC */
284
285 LCD_WD = *s++;
286 lcdcol++; /* keep column variable up to date */
287 }
288}
289
290/*
291
292*/
293
294/*
295 =============================================================================
296 GLCtext(row, col, s) -- position GLC cursor and write text
297 Sets the GLC cursor to ('row', 'col'), then writes the
298 character string pointed to by 's'.
299 Cursor must start and end on the same line.
300 No error checks are done.
301 =============================================================================
302*/
303
304void GLCtext(uint16_t row, uint16_t col, int8_t *s)
305{
306 register uint16_t curad;
307
308 curad = col + (row * 85); /* calculate cursor address */
309
310 LCD_WC = G_CRSWR; /* send cursor address to GLC */
311 LCD_WD = curad & 0xFF;
312 LCD_WD = (curad >> 8) & 0xFF;
313
314 lcdrow = row; /* set GLC text cursor variables */
315 lcdcol = col;
316
317 LCD_WC = G_CRSMRT; /* set cursor motion = right */
318
319 LCD_WC = G_MWRITE; /* set to write data */
320
321 while (*s) { /* write string to GLC */
322
323 LCD_WD = *s++;
324 lcdcol++; /* keep cursor column up to date */
325 }
326}
327
328
Note: See TracBrowser for help on using the repository browser.