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