source: buchla-68k/orig/RAM/GCURPOS.C@ a6f5b95

Last change on this file since a6f5b95 was 3ae31e9, checked in by Thomas Lopatic <thomas@…>, 8 years ago

Imported original source code.

  • Property mode set to 100755
File size: 9.3 KB
RevLine 
[3ae31e9]1/*
2 =============================================================================
3 gcurpos.c -- MIDAS cursor arrow functions and arrow object definitions
4 Version 16 -- 1988-03-11 -- D.N. Lynx Crowe
5 =============================================================================
6*/
7
8#include "stddefs.h"
9#include "hwdefs.h"
10#include "graphdef.h"
11#include "vsdd.h"
12#include "vsddvars.h"
13
14#include "midas.h"
15
16#define YOFF 15 /* y pixel offset */
17#define XOFF 14 /* x pixel offset */
18
19extern short sgcsw;
20
21/* 4 bit pixel patterns */
22
23#define AW_0 0x0000
24#define AW_1 0xF000
25#define AW_2 0x0F00
26#define AW_3 0xFF00
27#define AW_4 0x00F0
28#define AW_5 0xF0F0
29#define AW_6 0x0FF0
30#define AW_7 0xFFF0
31#define AW_8 0x000F
32#define AW_9 0xF00F
33#define AW_A 0x0F0F
34#define AW_B 0xFF0F
35#define AW_C 0x00FF
36#define AW_D 0xF0FF
37#define AW_E 0x0FFF
38#define AW_F 0xFFFF
39
40extern int objclr(), SetPri(), vbank();
41
42extern unsigned exp_c();
43
44extern short stcrow, stccol;
45
46/*
47
48*/
49
50static int ar_ule[] = { /* upper left even pixel arrow */
51
52 AW_F, AW_0, AW_0, AW_0, /* 0 */
53 AW_C, AW_0, AW_0, AW_0, /* 1 */
54 AW_A, AW_0, AW_0, AW_0, /* 2 */
55 AW_9, AW_0, AW_0, AW_0, /* 3 */
56 AW_0, AW_8, AW_0, AW_0, /* 4 */
57 AW_0, AW_4, AW_0, AW_0, /* 5 */
58 AW_0, AW_2, AW_0, AW_0, /* 6 */
59 AW_0, AW_1, AW_0, AW_0, /* 7 */
60 AW_0, AW_0, AW_8, AW_0, /* 8 */
61 AW_0, AW_0, AW_7, AW_8, /* 9 */
62 AW_0, AW_0, AW_6, AW_0, /* 10 */
63 AW_0, AW_0, AW_5, AW_E, /* 11 */
64 AW_0, AW_0, AW_5, AW_8, /* 12 */
65 AW_0, AW_0, AW_1, AW_4, /* 13 */
66 AW_0, AW_0, AW_1, AW_2, /* 14 */
67 AW_0, AW_0, AW_0, AW_0 /* 15 */
68};
69
70static int ar_ulo[] = { /* upper left odd pixel arrow */
71
72 AW_7, AW_8, AW_0, AW_0, /* 0 */
73 AW_6, AW_0, AW_0, AW_0, /* 1 */
74 AW_5, AW_0, AW_0, AW_0, /* 2 */
75 AW_4, AW_8, AW_0, AW_0, /* 3 */
76 AW_0, AW_4, AW_0, AW_0, /* 4 */
77 AW_0, AW_2, AW_0, AW_0, /* 5 */
78 AW_0, AW_1, AW_0, AW_0, /* 6 */
79 AW_0, AW_0, AW_8, AW_0, /* 7 */
80 AW_0, AW_0, AW_4, AW_0, /* 8 */
81 AW_0, AW_0, AW_3, AW_C, /* 9 */
82 AW_0, AW_0, AW_3, AW_0, /* 10 */
83 AW_0, AW_0, AW_2, AW_F, /* 11 */
84 AW_0, AW_0, AW_2, AW_C, /* 12 */
85 AW_0, AW_0, AW_0, AW_A, /* 13 */
86 AW_0, AW_0, AW_0, AW_9, /* 14 */
87 AW_0, AW_0, AW_0, AW_0 /* 15 */
88};
89
90/*
91
92*/
93
94static int ar_ure[] = { /* upper right even pixel arrow */
95
96 AW_0, AW_0, AW_1, AW_E, /* 0 */
97 AW_0, AW_0, AW_0, AW_6, /* 1 */
98 AW_0, AW_0, AW_0, AW_A, /* 2 */
99 AW_0, AW_0, AW_1, AW_2, /* 3 */
100 AW_0, AW_0, AW_2, AW_0, /* 4 */
101 AW_0, AW_0, AW_4, AW_0, /* 5 */
102 AW_0, AW_0, AW_8, AW_0, /* 6 */
103 AW_0, AW_1, AW_0, AW_0, /* 7 */
104 AW_0, AW_2, AW_0, AW_0, /* 8 */
105 AW_3, AW_C, AW_0, AW_0, /* 9 */
106 AW_0, AW_C, AW_0, AW_0, /* 10 */
107 AW_F, AW_4, AW_0, AW_0, /* 11 */
108 AW_3, AW_4, AW_0, AW_0, /* 12 */
109 AW_5, AW_0, AW_0, AW_0, /* 13 */
110 AW_9, AW_0, AW_0, AW_0, /* 14 */
111 AW_0, AW_0, AW_0, AW_0 /* 15 */
112};
113
114static int ar_uro[] = { /* upper right odd pixel arrow */
115
116 AW_0, AW_0, AW_0, AW_F, /* 0 */
117 AW_0, AW_0, AW_0, AW_3, /* 1 */
118 AW_0, AW_0, AW_0, AW_5, /* 2 */
119 AW_0, AW_0, AW_0, AW_9, /* 3 */
120 AW_0, AW_0, AW_1, AW_0, /* 4 */
121 AW_0, AW_0, AW_2, AW_0, /* 5 */
122 AW_0, AW_0, AW_4, AW_0, /* 6 */
123 AW_0, AW_0, AW_8, AW_0, /* 7 */
124 AW_0, AW_1, AW_0, AW_0, /* 8 */
125 AW_1, AW_E, AW_0, AW_0, /* 9 */
126 AW_0, AW_6, AW_0, AW_0, /* 10 */
127 AW_7, AW_A, AW_0, AW_0, /* 11 */
128 AW_1, AW_A, AW_0, AW_0, /* 12 */
129 AW_2, AW_8, AW_0, AW_0, /* 13 */
130 AW_4, AW_8, AW_0, AW_0, /* 14 */
131 AW_0, AW_0, AW_0, AW_0 /* 15 */
132};
133
134/*
135
136*/
137
138static int ar_lle[] = { /* lower left even pixel arrow */
139
140 AW_0, AW_0, AW_0, AW_0, /* 0 */
141 AW_0, AW_0, AW_1, AW_2, /* 1 */
142 AW_0, AW_0, AW_1, AW_4, /* 2 */
143 AW_0, AW_0, AW_5, AW_8, /* 3 */
144 AW_0, AW_0, AW_5, AW_E, /* 4 */
145 AW_0, AW_0, AW_6, AW_0, /* 5 */
146 AW_0, AW_0, AW_7, AW_8, /* 6 */
147 AW_0, AW_0, AW_8, AW_0, /* 7 */
148 AW_0, AW_1, AW_0, AW_0, /* 8 */
149 AW_0, AW_2, AW_0, AW_0, /* 9 */
150 AW_0, AW_4, AW_0, AW_0, /* 10 */
151 AW_0, AW_8, AW_0, AW_0, /* 11 */
152 AW_9, AW_0, AW_0, AW_0, /* 12 */
153 AW_A, AW_0, AW_0, AW_0, /* 13 */
154 AW_C, AW_0, AW_0, AW_0, /* 14 */
155 AW_F, AW_0, AW_0, AW_0 /* 15 */
156};
157
158static int ar_llo[] = { /* lower left odd pixel arrow */
159
160 AW_0, AW_0, AW_0, AW_0, /* 0 */
161 AW_0, AW_0, AW_0, AW_9, /* 1 */
162 AW_0, AW_0, AW_0, AW_A, /* 2 */
163 AW_0, AW_0, AW_2, AW_C, /* 3 */
164 AW_0, AW_0, AW_2, AW_F, /* 4 */
165 AW_0, AW_0, AW_3, AW_0, /* 5 */
166 AW_0, AW_0, AW_3, AW_C, /* 6 */
167 AW_0, AW_0, AW_4, AW_0, /* 7 */
168 AW_0, AW_0, AW_8, AW_0, /* 8 */
169 AW_0, AW_1, AW_0, AW_0, /* 9 */
170 AW_0, AW_2, AW_0, AW_0, /* 10 */
171 AW_0, AW_4, AW_0, AW_0, /* 11 */
172 AW_4, AW_8, AW_0, AW_0, /* 12 */
173 AW_5, AW_0, AW_0, AW_0, /* 13 */
174 AW_6, AW_0, AW_0, AW_0, /* 14 */
175 AW_7, AW_8, AW_0, AW_0 /* 15 */
176};
177
178/*
179
180*/
181
182static int ar_lre[] = { /* lower right even pixel arrow */
183
184 AW_0, AW_0, AW_0, AW_0, /* 0 */
185 AW_9, AW_0, AW_0, AW_0, /* 1 */
186 AW_5, AW_0, AW_0, AW_0, /* 2 */
187 AW_3, AW_4, AW_0, AW_0, /* 3 */
188 AW_F, AW_4, AW_0, AW_0, /* 4 */
189 AW_0, AW_C, AW_0, AW_0, /* 5 */
190 AW_3, AW_C, AW_0, AW_0, /* 6 */
191 AW_0, AW_2, AW_0, AW_0, /* 7 */
192 AW_0, AW_1, AW_0, AW_0, /* 8 */
193 AW_0, AW_0, AW_8, AW_0, /* 9 */
194 AW_0, AW_0, AW_4, AW_0, /* 10 */
195 AW_0, AW_0, AW_2, AW_0, /* 11 */
196 AW_0, AW_0, AW_1, AW_2, /* 12 */
197 AW_0, AW_0, AW_0, AW_A, /* 13 */
198 AW_0, AW_0, AW_0, AW_6, /* 14 */
199 AW_0, AW_0, AW_1, AW_E /* 15 */
200};
201
202static int ar_lro[] = { /* lower right odd pixel arrow */
203
204 AW_0, AW_0, AW_0, AW_0, /* 0 */
205 AW_4, AW_8, AW_0, AW_0, /* 1 */
206 AW_2, AW_8, AW_0, AW_0, /* 2 */
207 AW_1, AW_A, AW_0, AW_0, /* 3 */
208 AW_7, AW_A, AW_0, AW_0, /* 4 */
209 AW_0, AW_6, AW_0, AW_0, /* 5 */
210 AW_1, AW_E, AW_0, AW_0, /* 6 */
211 AW_0, AW_1, AW_0, AW_0, /* 7 */
212 AW_0, AW_0, AW_8, AW_0, /* 8 */
213 AW_0, AW_0, AW_4, AW_0, /* 9 */
214 AW_0, AW_0, AW_2, AW_0, /* 10 */
215 AW_0, AW_0, AW_1, AW_0, /* 11 */
216 AW_0, AW_0, AW_0, AW_9, /* 12 */
217 AW_0, AW_0, AW_0, AW_5, /* 13 */
218 AW_0, AW_0, AW_0, AW_3, /* 14 */
219 AW_0, AW_0, AW_0, AW_F /* 15 */
220};
221
222/*
223
224*/
225
226static int *arrows[] = { /* arrow pointer table */
227
228 v_curs0, /* 0 - upper left, even pixel */
229 v_curs1, /* 1 - upper left, odd pixel */
230
231 v_curs2, /* 2 - upper right, even pixel */
232 v_curs3, /* 3 - upper right, odd pixel */
233
234 v_curs4, /* 4 - lower left, even pixel */
235 v_curs5, /* 5 - lower left, odd pixel */
236
237 v_curs6, /* 6 - lower right, even pixel */
238 v_curs7 /* 7 - lower right, odd pixel */
239};
240
241/*
242
243*/
244
245/*
246 =============================================================================
247 gcurpos(xloc, yloc) -- position the graphic cursor at ('xloc', 'yloc')
248
249 Also sets stcrow and stccol to keep them in sync.
250 =============================================================================
251*/
252
253int
254gcurpos(xloc, yloc)
255register int xloc, yloc;
256{
257 register int ab, xo, yo;
258 register struct octent *op;
259
260 if (xloc LT XCTR) {
261
262 xo = 0; /* arrow points left */
263
264 if (yloc LT YCTR)
265 {ab = 0; yo = 0;} /* arrow points up */
266 else
267 {ab = 4; yo = -YOFF;} /* arrow points down */
268
269 } else {
270
271 xo = -XOFF; /* arrow points right */
272
273 if (yloc LT YCTR)
274 {ab = 2; yo = 0;} /* arrow points up */
275 else
276 {ab = 6; yo = -YOFF;} /* arrow points down */
277 }
278
279 if (v_regs[5] & 0x0180)
280 vbank(0);
281
282 v_odtab[GCPRI][0] |= V_BLA;
283 objclr(GCPRI);
284
285 op = &v_obtab[GCURS];
286 op->objx = xloc + xo;
287 op->objy = yloc + yo;
288 op->obase = arrows[ab + (xloc & 0x0001)];
289 op->odtw1 = 0x0400 | (0x03FF & (op->objx >> 1));
290
291 SetPri(GCURS, GCPRI);
292
293 stcrow = yloc / 14;
294 stccol = xloc >> 3;
295 return(ab + (xloc & 0x0001));
296}
297
298/*
299
300*/
301
302/*
303 =============================================================================
304 andcopy() -- copy a pattern
305 =============================================================================
306*/
307
308andcopy(to, from, with, len)
309register unsigned *to, *from, with;
310short len;
311{
312 register short i;
313
314 for (i = len; i--; )
315 *to++ = *from++ & with;
316}
317
318/*
319 =============================================================================
320 arcurs() -- setup the arrow cursor
321 =============================================================================
322*/
323
324arcurs(icolor)
325unsigned icolor;
326{
327 register short color;
328
329 color = exp_c(icolor);
330
331 if ((v_regs[5] & 0x0180) NE 0x0100)
332 vbank(1);
333
334 andcopy(v_curs0, ar_ule, color, 64); /* setup arrow cursor */
335 andcopy(v_curs1, ar_ulo, color, 64);
336 andcopy(v_curs2, ar_ure, color, 64);
337 andcopy(v_curs3, ar_uro, color, 64);
338 andcopy(v_curs4, ar_lle, color, 64);
339 andcopy(v_curs5, ar_llo, color, 64);
340 andcopy(v_curs6, ar_lre, color, 64);
341 andcopy(v_curs7, ar_lro, color, 64);
342}
343
344/*
345
346*/
347
348/*
349 =============================================================================
350 sgcon() -- set graphic cursor object "on"
351 =============================================================================
352*/
353
354sgcon()
355{
356 if (sgcsw)
357 return;
358
359 if (v_regs[5] & 0x0180)
360 vbank(0);
361
362 v_odtab[GCPRI][0] &= ~V_BLA;
363 sgcsw = TRUE;
364}
365
366/*
367 =============================================================================
368 sgcoff() -- set graphic cursor object "off"
369 =============================================================================
370*/
371
372sgcoff()
373{
374 if (!sgcsw)
375 return;
376
377 if (v_regs[5] & 0x0180)
378 vbank(0);
379
380 v_odtab[GCPRI][0] |= V_BLA;
381 sgcsw = FALSE;
382}
Note: See TracBrowser for help on using the repository browser.