source: buchla-68k/ram/barbadj.c@ 7ecfb7b

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

Unused variables and parameters.

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