source: buchla-68k/ram/barbadj.c@ 6262b5c

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

Added include files for global functions and variables.

  • Property mode set to 100644
File size: 8.4 KB
Line 
1/*
2 =============================================================================
3 barbadj.c -- MIDAS-VII -- GLC bar graph drivers
4 Version 8 -- 1988-10-27 -- D.N. Lynx Crowe
5
6 BarBadj(bar, val)
7 short bar, val;
8
9 Adjusts a bottom-zero bar graph, 'bar',
10 to read 'val'.
11
12 BarBset(bar, val)
13 short bar, val;
14
15 Sets a bottom-zero bar graph, 'bar',
16 to an intial value, 'val'.
17
18 BarCadj(bar, val)
19 short bar, val;
20
21 Adjusts a centered-zero bar graph, 'bar',
22 to read 'val'.
23
24 BarCset(bar, val)
25 short bar, val;
26
27 Sets a centered-zero bar graph, 'bar',
28 to an intial value, 'val'.
29 =============================================================================
30*/
31
32#include "all.h"
33
34extern int16_t BarBcur[];
35extern int16_t BarCcur[];
36
37/* left-most bar columns */
38
39int16_t BarCols[14] = { 2, 8, 14, 20, 26, 32, 38, 44, 50, 56, 62, 68, 74, 80 };
40
41/* bar dot data */
42
43int16_t BarDots[3] = { 0x1C, 0xFC, 0xE0 };
44
45#include "glcbars.h" /* bar graph driver constant definitions */
46
47/*
48
49*/
50
51/*
52 =============================================================================
53 BarBadj() -- adjust a bottom-zero bar graph to a new value
54 =============================================================================
55*/
56
57void BarBadj(int16_t bar, int16_t val)
58{
59 register int16_t bardot, barpos, curdif;
60 register uint16_t baradr;
61 int16_t barcol, bardif, curbar, i, newbar;
62
63 newbar = BarBLn[val]; /* look up the new bar position */
64 curbar = BarBcur[bar]; /* get the current bar position */
65 bardif = newbar - curbar; /* calculate how far to move the bar */
66
67 if (0 EQ bardif) /* done if bar doesn't need to be moved */
68 return;
69
70 GLCcurs(G_ON); /* turn on GLC cursor to enable writing */
71 barcol = BarCols[bar]; /* find leftmost column of bar */
72
73 if (bardif > 0) { /* increasing value */
74
75 /* calculate initial GLC RAM write address */
76
77 baradr = barcol + (85 * (63 - (curbar + 1))) + G_PLANE2;
78
79 LCD_WC = G_CRSMUP; /* set cursor motion "up" */
80
81 for (i = 0; i < 3; i++) { /* for each bar column ... */
82
83 curdif = bardif; /* set difference counter */
84 bardot = BarDots[i]; /* get the column dot value */
85
86 LCD_WC = G_CRSWR; /* set cursor address */
87 LCD_WD = baradr & 0xFF;
88 LCD_WD = (baradr >> 8) & 0xFF;
89
90 ++baradr; /* update GLC start address */
91
92 LCD_WC = G_MWRITE; /* setup to write */
93
94 while (curdif--) /* write new dots */
95 LCD_WD = bardot;
96 }
97/*
98
99*/
100 } else { /* decreasing value */
101
102 /* calculate initial GLC RAM write address */
103
104 baradr = barcol + (85 * (63 - curbar)) + G_PLANE2;
105
106 LCD_WC = G_CRSMDN; /* set cursor motion "down" */
107
108 for (i = 0; i < 3; i++) { /* for each bar column ... */
109
110 curdif = -bardif; /* set difference counter */
111
112 LCD_WC = G_CRSWR; /* set cursor address */
113 LCD_WD = baradr & 0xFF;
114 LCD_WD = (baradr >> 8) & 0xFF;
115
116 ++baradr; /* update GLC start address */
117
118 LCD_WC = G_MWRITE; /* setup to write */
119
120 while (curdif--) /* erase old dots */
121 LCD_WD = 0x00;
122 }
123 }
124
125 LCD_WC = G_CRSMRT; /* set cursor motion = "right" */
126 GLCcurs(G_OFF); /* turn off the cursor */
127
128 BarBcur[bar] = newbar; /* update current bar position */
129}
130
131/*
132
133*/
134
135/*
136 =============================================================================
137 BarBset() -- set a bottom-zero bar graph to an initial value
138 =============================================================================
139*/
140
141void BarBset(int16_t bar, int16_t val)
142{
143 register int16_t bardot, barpos, newbar;
144 register uint16_t baradr;
145 int16_t barcol, i;
146
147 newbar = BarBLn[val]; /* look up the new bar position */
148 barcol = BarCols[bar]; /* find leftmost column of bar */
149
150 GLCcurs(G_ON); /* turn on GLC cursor to enable writing */
151
152 /* calculate initial GLC RAM write address */
153
154 baradr = barcol + (85 * (63 - BBase)) + G_PLANE2;
155
156 LCD_WC = G_CRSMUP; /* set cursor motion = "up" */
157
158 for (i = 0; i < 3; i++) { /* for each bar column ... */
159
160 bardot = BarDots[i]; /* get the column dot value */
161 barpos = BBase; /* get base of bar */
162
163 LCD_WC = G_CRSWR; /* set cursor address */
164 LCD_WD = baradr & 0xFF;
165 LCD_WD = (baradr >> 8) & 0xFF;
166
167 ++baradr; /* update GLC start address */
168
169 LCD_WC = G_MWRITE; /* setup to write */
170
171 while (barpos++ LE newbar) /* write new dots */
172 LCD_WD = bardot;
173
174 while (barpos++ < BTop) /* erase old dots */
175 LCD_WD = 0x00;
176 }
177
178 LCD_WC = G_CRSMRT; /* set cursor motion = "right" */
179 GLCcurs(G_OFF); /* turn off the cursor */
180
181 BarBcur[bar] = newbar; /* update current bar position */
182}
183
184/*
185
186*/
187
188/*
189 =============================================================================
190 BarCadj() -- adjust a centered-zero bar graph to a new value
191 =============================================================================
192*/
193
194void BarCadj(int16_t bar, int16_t val)
195{
196 register int16_t bardot, barpos, newbar;
197 register uint16_t baradr;
198 int16_t barcol, bardif, curbar, i;
199
200 newbar = BarCLn[val + BOffset]; /* look up the new bar position */
201 curbar = BarCcur[bar]; /* get the current bar position */
202 bardif = newbar - curbar; /* calculate how far to move the bar */
203
204 if (0 EQ bardif) /* done if bar doesn't need to be moved */
205 return;
206
207 GLCcurs(G_ON); /* turn on GLC cursor to enable writing */
208
209 barcol = BarCols[bar]; /* find leftmost column of bar */
210
211 /* calculate initial GLC RAM write address */
212
213 baradr = barcol + (85 * (63 - curbar)) + G_PLANE2;
214
215/*
216
217*/
218 if (newbar > curbar) { /* increasing value */
219
220 LCD_WC = G_CRSMUP; /* set cursor motion "up" */
221
222 for (i = 0; i < 3; i++) { /* for each bar column ... */
223
224 bardot = BarDots[i]; /* get the column dot value */
225 barpos = curbar; /* set current vert. position */
226
227 LCD_WC = G_CRSWR; /* set cursor address */
228 LCD_WD = baradr & 0xFF;
229 LCD_WD = (baradr >> 8) & 0xFF;
230
231 LCD_WC = G_MWRITE; /* setup to write */
232
233 while (barpos NE newbar) /* write bar on LCD */
234 if (barpos++ < BCenter)
235 LCD_WD = 0x00; /* dots off */
236 else
237 LCD_WD = bardot; /* dots on */
238
239 ++baradr; /* update GLC start address */
240 }
241/*
242
243*/
244 } else { /* decreasing value */
245
246 LCD_WC = G_CRSMDN; /* set cursor motion "down" */
247
248 for (i = 0; i < 3; i++) { /* for each bar column ... */
249
250 bardot = BarDots[i]; /* get column dot value */
251 barpos = curbar; /* set current bar location */
252
253 LCD_WC = G_CRSWR; /* set cursor address */
254 LCD_WD = baradr & 0xFF;
255 LCD_WD = (baradr >> 8) & 0xFF;
256
257 LCD_WC = G_MWRITE; /* setup to write */
258
259 while (barpos NE newbar) /* write bar to LCD */
260 if (barpos-- > BCenter)
261 LCD_WD= 0x00; /* dots off */
262 else
263 LCD_WD = bardot; /* dots on */
264
265 ++baradr; /* update GLC start address */
266 }
267 }
268
269 LCD_WC = G_CRSMRT; /* set cursor motion = "right" */
270 GLCcurs(G_OFF); /* turn off the cursor */
271
272 BarCcur[bar] = newbar; /* update current bar position */
273}
274
275/*
276
277*/
278
279/*
280 =============================================================================
281 BarCset() -- set a centered-zero bar graph to an initial value
282 =============================================================================
283*/
284
285void BarCset(int16_t bar, int16_t val)
286{
287 register int16_t bardot, barpos, barloc1, barloc2;
288 register uint16_t baradr;
289 int16_t barcol, i, newbar;
290
291 GLCcurs(G_ON); /* turn on GLC cursor to enable writing */
292
293 newbar = BarCLn[val + BOffset]; /* look up the new bar position */
294 barcol = BarCols[bar]; /* find leftmost column of bar */
295
296 /* calculate initial GLC RAM write address */
297
298 baradr = barcol + (85 * (63 - BBase)) + G_PLANE2;
299
300 if (newbar < BCenter) { /* target below center */
301
302 barloc1 = newbar; /* off limit */
303 barloc2 = BCenter; /* on limit */
304
305 } else { /* target at or above center */
306
307 barloc1 = BCenter; /* off limit */
308 barloc2 = newbar; /* on limit */
309 }
310
311 LCD_WC = G_CRSMUP; /* set cursor motion "up" */
312
313/*
314
315*/
316 for (i = 0; i < 3; i++) { /* for each bar column ... */
317
318 bardot = BarDots[i]; /* get the column dot value */
319 barpos = BBase; /* set current vert. position */
320
321 LCD_WC = G_CRSWR; /* set cursor address */
322 LCD_WD = baradr & 0xFF;
323 LCD_WD = (baradr >> 8) & 0xFF;
324
325 LCD_WC = G_MWRITE; /* setup to write */
326
327 while (barpos < barloc1) { /* write "off" dots */
328
329 LCD_WD = 0x00;
330 barpos++;
331 }
332
333 while (barpos LE barloc2) { /* write "on" dots */
334
335 LCD_WD = bardot;
336 barpos++;
337 }
338
339 while (barpos LE BTop) { /* write "off" dots */
340
341 LCD_WD = 0x00;
342 barpos++;
343 }
344
345 ++baradr; /* update GLC start address */
346 }
347
348 LCD_WC = G_CRSMRT; /* set cursor motion = "right" */
349 GLCcurs(G_OFF); /* turn off the cursor */
350
351 BarCcur[bar] = newbar; /* update current bar position */
352}
353
Note: See TracBrowser for help on using the repository browser.