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

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

Removed form-feed comments.

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