[f40a309] | 1 | /*
|
---|
| 2 | =============================================================================
|
---|
| 3 | sqdkey.c -- MIDAS-VII sequence display data entry functions
|
---|
| 4 | Version 8 -- 1988-11-22 -- D.N. Lynx Crowe
|
---|
| 5 | =============================================================================
|
---|
| 6 | */
|
---|
| 7 |
|
---|
| 8 | #include "stddefs.h"
|
---|
| 9 | #include "hwdefs.h"
|
---|
| 10 | #include "vsdd.h"
|
---|
| 11 | #include "fields.h"
|
---|
| 12 | #include "curpak.h"
|
---|
| 13 | #include "patch.h"
|
---|
| 14 | #include "macros.h"
|
---|
| 15 |
|
---|
| 16 | #include "midas.h"
|
---|
| 17 | #include "ptdisp.h"
|
---|
| 18 |
|
---|
[e225e77] | 19 | #include "memory.h"
|
---|
| 20 |
|
---|
| 21 | extern void UpdVid(int16_t row, int16_t col, int8_t *str, uint16_t atr);
|
---|
| 22 | extern void ctcon(void);
|
---|
| 23 | extern void dsqlin(int8_t *buf, int16_t slin);
|
---|
| 24 | extern void movestc(int16_t r, int16_t c);
|
---|
| 25 |
|
---|
[7258c6a] | 26 | extern int16_t asig, astat;
|
---|
[f40a309] | 27 |
|
---|
[7258c6a] | 28 | extern int16_t action;
|
---|
| 29 | extern int16_t curslin;
|
---|
| 30 | extern int16_t sqdeflg;
|
---|
| 31 | extern int16_t stccol;
|
---|
| 32 | extern int16_t stcrow;
|
---|
[f40a309] | 33 |
|
---|
[7258c6a] | 34 | extern int8_t sqdebuf[50];
|
---|
[f40a309] | 35 |
|
---|
| 36 | extern struct seqent seqbuf;
|
---|
| 37 | extern struct seqent seqtab[];
|
---|
| 38 |
|
---|
[7258c6a] | 39 | int16_t actfmt; /* action code format */
|
---|
[f40a309] | 40 |
|
---|
| 41 | /* |
---|
| 42 |
|
---|
| 43 | */
|
---|
[7258c6a] | 44 |
|
---|
[f40a309] | 45 | int8_t actlft[] = { 12, 24, 36 }; /* action field leftmost columns */
|
---|
[7258c6a] | 46 |
|
---|
[f40a309] | 47 | int8_t seqdfmt[] = { /* action data entry format by action */
|
---|
| 48 |
|
---|
| 49 | 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 0, 4, 0, 3
|
---|
| 50 | };
|
---|
| 51 |
|
---|
| 52 | /* |
---|
| 53 |
|
---|
| 54 | */
|
---|
| 55 |
|
---|
| 56 | /*
|
---|
| 57 | =============================================================================
|
---|
| 58 | seq2buf() -- load the edit buffer from the current sequence line
|
---|
| 59 | =============================================================================
|
---|
[0580615] | 60 | */
|
---|
[f40a309] | 61 |
|
---|
| 62 | void seq2buf(void)
|
---|
| 63 | {
|
---|
| 64 | memcpyw(&seqbuf, &seqtab[curslin], NSEQW);
|
---|
| 65 | dsqlin(sqdebuf, curslin);
|
---|
| 66 | sqdeflg = TRUE;
|
---|
| 67 | }
|
---|
| 68 |
|
---|
| 69 | /* |
---|
| 70 |
|
---|
| 71 | */
|
---|
| 72 |
|
---|
| 73 | /*
|
---|
| 74 | =============================================================================
|
---|
| 75 | sqactde() -- sequence action digit data entry function
|
---|
[7258c6a] | 76 | =============================================================================
|
---|
[f40a309] | 77 | */
|
---|
[7258c6a] | 78 |
|
---|
| 79 | void sqactde(int16_t key)
|
---|
| 80 | {
|
---|
| 81 | register int16_t col;
|
---|
[f40a309] | 82 | int16_t defmt;
|
---|
| 83 | uint16_t act, vtype;
|
---|
| 84 | int8_t buf[8];
|
---|
| 85 |
|
---|
| 86 | col = stccol - actlft[action]; /* get field data entry column */
|
---|
| 87 |
|
---|
| 88 | switch (action) { /* get action code from sequence entry */
|
---|
| 89 |
|
---|
| 90 | case 0: /* action 1 */
|
---|
| 91 |
|
---|
| 92 | act = seqbuf.seqact1;
|
---|
| 93 | vtype = SQ_MTYP & seqbuf.seqdat1;
|
---|
| 94 | break;
|
---|
| 95 |
|
---|
| 96 | case 1: /* action 2 */
|
---|
| 97 |
|
---|
| 98 | act = seqbuf.seqact2;
|
---|
| 99 | vtype = SQ_MTYP & seqbuf.seqdat2;
|
---|
| 100 | break;
|
---|
| 101 |
|
---|
| 102 | case 2: /* action 3 */
|
---|
| 103 |
|
---|
| 104 | act = seqbuf.seqact3;
|
---|
| 105 | vtype = SQ_MTYP & seqbuf.seqdat3;
|
---|
| 106 | break;
|
---|
| 107 |
|
---|
| 108 | default: /* something weird got in here */
|
---|
| 109 |
|
---|
| 110 | return;
|
---|
| 111 | }
|
---|
| 112 |
|
---|
| 113 | defmt = seqdfmt[SQ_MACT & act]; /* get data entry format code */
|
---|
| 114 | /* |
---|
| 115 |
|
---|
| 116 | */
|
---|
| 117 | switch (defmt) { /* switch off of data entry format */
|
---|
| 118 |
|
---|
| 119 | case 1: /* key, port, chan */
|
---|
| 120 |
|
---|
| 121 | if (inrange(col, 3, 5)) { /* key */
|
---|
| 122 |
|
---|
| 123 | if ((col EQ 3) AND (key > 1))
|
---|
| 124 | return;
|
---|
| 125 |
|
---|
| 126 | buf[0] = key + '0';
|
---|
| 127 |
|
---|
| 128 | } else if (col EQ 7) { /* port */
|
---|
| 129 |
|
---|
| 130 | if ((key EQ 1) OR (key EQ 2)) { /* MIDI */
|
---|
| 131 |
|
---|
| 132 | buf[0] = key + '0';
|
---|
| 133 |
|
---|
| 134 | UpdVid(7, stccol + 1, " 01", PTDATR);
|
---|
| 135 | memcpy(&sqdebuf[stccol + 1], " 01", 3);
|
---|
| 136 |
|
---|
| 137 | } else if (key EQ 3) { /* local */
|
---|
| 138 |
|
---|
| 139 | buf[0] = 'L';
|
---|
| 140 |
|
---|
| 141 | UpdVid(7, stccol + 1, " ", PTDATR);
|
---|
| 142 | memset(&sqdebuf[stccol + 1], ' ', 3);
|
---|
| 143 |
|
---|
| 144 | } else {
|
---|
| 145 |
|
---|
| 146 | return;
|
---|
| 147 | }
|
---|
| 148 |
|
---|
| 149 | } else if (inrange(col, 9, 10)) { /* channel */
|
---|
| 150 |
|
---|
| 151 | if ((col EQ 9) AND (key > 1))
|
---|
| 152 | return;
|
---|
| 153 |
|
---|
| 154 | buf[0] = key + '0';
|
---|
| 155 | }
|
---|
| 156 |
|
---|
| 157 | buf[1] = '\0';
|
---|
| 158 | sqdebuf[stccol] = buf[0];
|
---|
| 159 |
|
---|
| 160 | UpdVid(7, stccol, buf, PTDATR);
|
---|
| 161 |
|
---|
| 162 | if ((col EQ 5) OR (col EQ 7)) { /* skip blanks */
|
---|
| 163 |
|
---|
| 164 | ++stccol;
|
---|
| 165 | ++col;
|
---|
| 166 | }
|
---|
| 167 |
|
---|
| 168 | if (col EQ 10)
|
---|
| 169 | ctcon();
|
---|
| 170 | else
|
---|
| 171 | movestc(stcrow, ++stccol);
|
---|
| 172 |
|
---|
| 173 | return;
|
---|
| 174 | /* |
---|
| 175 |
|
---|
| 176 | */
|
---|
| 177 | case 2: /* trigger */
|
---|
| 178 |
|
---|
| 179 | if (inrange(col, 9, 10)) {
|
---|
| 180 |
|
---|
| 181 | if ((col EQ 9) AND (key > 1))
|
---|
| 182 | return;
|
---|
| 183 |
|
---|
| 184 | } else {
|
---|
| 185 |
|
---|
| 186 | return;
|
---|
| 187 | }
|
---|
| 188 |
|
---|
| 189 | buf[0] = key + '0';
|
---|
| 190 | buf[1] = '\0';
|
---|
| 191 | sqdebuf[stccol] = key + '0';
|
---|
| 192 |
|
---|
| 193 | UpdVid(7, stccol, buf, PTDATR);
|
---|
| 194 |
|
---|
| 195 | if (col EQ 10)
|
---|
| 196 | ctcon();
|
---|
| 197 | else
|
---|
| 198 | movestc(stcrow, ++stccol);
|
---|
| 199 |
|
---|
| 200 | return;
|
---|
| 201 | /* |
---|
| 202 |
|
---|
| 203 | */
|
---|
| 204 | case 3: /* register operations */
|
---|
| 205 |
|
---|
| 206 | if ((col EQ 7) AND (act EQ SQ_AREG)) {
|
---|
| 207 |
|
---|
| 208 | if (key EQ 8) /* - */
|
---|
| 209 | buf[0] = '-';
|
---|
| 210 | else if (key EQ 9) /* + */
|
---|
| 211 | buf[0] = '+';
|
---|
| 212 | else
|
---|
| 213 | return;
|
---|
| 214 |
|
---|
| 215 | buf[1] = '\0';
|
---|
| 216 | sqdebuf[stccol] = buf[0];
|
---|
| 217 | UpdVid(7, stccol, buf, PTDATR);
|
---|
| 218 | movestc(stcrow, ++stccol);
|
---|
| 219 | return;
|
---|
| 220 | }
|
---|
| 221 |
|
---|
| 222 | switch (vtype) {
|
---|
| 223 |
|
---|
| 224 | case SQ_REG: /* register contents */
|
---|
| 225 |
|
---|
| 226 | if (inrange(col, 5, 6) OR inrange(col, 9, 10)) {
|
---|
| 227 |
|
---|
| 228 | if ( ((col EQ 5) OR (col EQ 9)) AND (key > 1) )
|
---|
| 229 | return;
|
---|
| 230 |
|
---|
| 231 | } else {
|
---|
| 232 |
|
---|
| 233 | return;
|
---|
| 234 | }
|
---|
| 235 |
|
---|
| 236 | buf[0] = key + '0';
|
---|
| 237 | buf[1] = '\0';
|
---|
| 238 | sqdebuf[stccol] = key + '0';
|
---|
| 239 |
|
---|
| 240 | UpdVid(7, stccol, buf, PTDATR);
|
---|
| 241 |
|
---|
| 242 | if (col EQ 6) {
|
---|
| 243 |
|
---|
| 244 | col += 2;
|
---|
| 245 | stccol += 2;
|
---|
| 246 | }
|
---|
| 247 |
|
---|
| 248 | if (col EQ 10)
|
---|
| 249 | ctcon();
|
---|
| 250 | else
|
---|
| 251 | movestc(stcrow, ++stccol);
|
---|
| 252 |
|
---|
| 253 | return;
|
---|
| 254 | /* |
---|
| 255 |
|
---|
| 256 | */
|
---|
| 257 | case SQ_VAL: /* constant value */
|
---|
| 258 |
|
---|
| 259 | if (inrange(col, 5, 6) OR inrange(col, 8, 9)) {
|
---|
| 260 |
|
---|
[9519422] | 261 | if ((col EQ 5) AND (key > 1))
|
---|
[f40a309] | 262 | return;
|
---|
| 263 |
|
---|
| 264 | } else {
|
---|
| 265 |
|
---|
| 266 | return;
|
---|
| 267 | }
|
---|
| 268 |
|
---|
| 269 | buf[0] = key + '0';
|
---|
| 270 | buf[1] = '\0';
|
---|
| 271 | sqdebuf[stccol] = key + '0';
|
---|
| 272 |
|
---|
| 273 | UpdVid(7, stccol, buf, PTDATR);
|
---|
| 274 |
|
---|
| 275 | if (col EQ 6) {
|
---|
| 276 |
|
---|
| 277 | ++col;
|
---|
| 278 | ++stccol;
|
---|
| 279 | }
|
---|
| 280 |
|
---|
| 281 | if (col EQ 9)
|
---|
| 282 | ctcon();
|
---|
| 283 | else
|
---|
| 284 | movestc(stcrow, ++stccol);
|
---|
| 285 |
|
---|
| 286 | return;
|
---|
| 287 | /* |
---|
| 288 |
|
---|
| 289 | */
|
---|
| 290 | case SQ_VLT: /* voltage input */
|
---|
| 291 |
|
---|
| 292 | if (inrange(col, 5, 6) OR (col EQ 9)) {
|
---|
| 293 |
|
---|
| 294 | if ((col EQ 5) AND (key > 1))
|
---|
| 295 | return;
|
---|
| 296 | else if ( (col EQ 9) AND ((key < 1) OR (key > 4)) )
|
---|
| 297 | return;
|
---|
| 298 |
|
---|
| 299 | } else {
|
---|
| 300 |
|
---|
| 301 | return;
|
---|
| 302 | }
|
---|
| 303 |
|
---|
| 304 | buf[0] = key + '0';
|
---|
| 305 | buf[1] = '\0';
|
---|
| 306 | sqdebuf[stccol] = key + '0';
|
---|
| 307 |
|
---|
| 308 | UpdVid(7, stccol, buf, PTDATR);
|
---|
| 309 |
|
---|
| 310 | if (col EQ 6) {
|
---|
| 311 |
|
---|
| 312 | col += 2;
|
---|
| 313 | stccol += 2;
|
---|
| 314 | }
|
---|
| 315 |
|
---|
| 316 | if (col EQ 9)
|
---|
| 317 | ctcon();
|
---|
| 318 | else
|
---|
| 319 | movestc(stcrow, ++stccol);
|
---|
| 320 |
|
---|
| 321 | return;
|
---|
| 322 | /* |
---|
| 323 |
|
---|
| 324 | */
|
---|
| 325 | case SQ_RND: /* random value */
|
---|
| 326 |
|
---|
| 327 | if (inrange(col, 5, 6) OR (col EQ 9)) {
|
---|
| 328 |
|
---|
| 329 | if ((col EQ 5) AND (key > 1))
|
---|
| 330 | return;
|
---|
| 331 |
|
---|
| 332 | if ((col EQ 9) AND (key > 6))
|
---|
| 333 | return;
|
---|
| 334 |
|
---|
| 335 | } else {
|
---|
| 336 |
|
---|
| 337 | return;
|
---|
| 338 | }
|
---|
| 339 |
|
---|
| 340 | buf[0] = key + '0';
|
---|
| 341 | buf[1] = '\0';
|
---|
| 342 | sqdebuf[stccol] = key + '0';
|
---|
| 343 |
|
---|
| 344 | UpdVid(7, stccol, buf, PTDATR);
|
---|
| 345 |
|
---|
| 346 | if (col EQ 6) {
|
---|
| 347 |
|
---|
| 348 | col += 2;
|
---|
| 349 | stccol += 2;
|
---|
| 350 | }
|
---|
| 351 |
|
---|
| 352 | if (col EQ 9)
|
---|
| 353 | ctcon();
|
---|
| 354 | else
|
---|
| 355 | movestc(stcrow, ++stccol);
|
---|
| 356 |
|
---|
| 357 | return;
|
---|
| 358 | }
|
---|
| 359 | /* |
---|
| 360 |
|
---|
| 361 | */
|
---|
| 362 | case 4: /* sequence line */
|
---|
| 363 |
|
---|
| 364 | if (inrange(col, 0, 7))
|
---|
| 365 | return;
|
---|
| 366 |
|
---|
| 367 | buf[0] = key + '0';
|
---|
| 368 | buf[1] = '\0';
|
---|
| 369 | sqdebuf[stccol] = key + '0';
|
---|
| 370 |
|
---|
| 371 | UpdVid(7, stccol, buf, PTDATR);
|
---|
| 372 |
|
---|
| 373 | if (col EQ 10)
|
---|
| 374 | ctcon();
|
---|
| 375 | else
|
---|
| 376 | movestc(stcrow, ++stccol);
|
---|
| 377 |
|
---|
| 378 | return;
|
---|
| 379 |
|
---|
| 380 | case 0: /* -none- */
|
---|
| 381 | default:
|
---|
| 382 |
|
---|
| 383 | return;
|
---|
| 384 | }
|
---|
| 385 | }
|
---|
[7258c6a] | 386 |
|
---|
[f40a309] | 387 | /* |
---|
[7258c6a] | 388 |
|
---|
| 389 | */
|
---|
[f40a309] | 390 |
|
---|
| 391 | /*
|
---|
| 392 | =============================================================================
|
---|
| 393 | sqdkey() -- sequence digit data entry control function
|
---|
| 394 | =============================================================================
|
---|
| 395 | */
|
---|
| 396 |
|
---|
| 397 | void sqdkey(int16_t k)
|
---|
| 398 | {
|
---|
| 399 | register int16_t key;
|
---|
| 400 | int8_t buf[8];
|
---|
| 401 |
|
---|
| 402 | if (NOT astat) /* only do this on key closures */
|
---|
| 403 | return;
|
---|
| 404 |
|
---|
| 405 | if (NOT sqdeflg) /* load up the edit buffer */
|
---|
| 406 | seq2buf();
|
---|
| 407 |
|
---|
| 408 | key = asig - 60;
|
---|
| 409 |
|
---|
| 410 | if (inrange(stccol, 2, 4)) { /* line */
|
---|
| 411 |
|
---|
| 412 | buf[0] = key + '0';
|
---|
| 413 | buf[1] = '\0';
|
---|
| 414 |
|
---|
| 415 | sqdebuf[stccol] = key + '0';
|
---|
| 416 |
|
---|
| 417 | UpdVid(7, stccol, buf, PTDATR);
|
---|
| 418 |
|
---|
| 419 | if (stccol EQ 4)
|
---|
| 420 | ctcon();
|
---|
| 421 | else
|
---|
| 422 | movestc(stcrow, ++stccol);
|
---|
| 423 |
|
---|
| 424 | return;
|
---|
| 425 | /* |
---|
| 426 |
|
---|
| 427 | */
|
---|
| 428 | } else if (inrange(stccol, 6, 10)) { /* time */
|
---|
| 429 |
|
---|
| 430 | if (stccol EQ 8)
|
---|
| 431 | return;
|
---|
| 432 |
|
---|
| 433 | buf[0] = key + '0';
|
---|
| 434 | buf[1] = '\0';
|
---|
| 435 |
|
---|
| 436 | sqdebuf[stccol] = key + '0';
|
---|
| 437 |
|
---|
| 438 | UpdVid(7, stccol, buf, PTDATR);
|
---|
| 439 |
|
---|
| 440 | if (stccol EQ 7)
|
---|
| 441 | ++stccol;
|
---|
| 442 |
|
---|
| 443 | if (stccol EQ 10)
|
---|
| 444 | ctcon();
|
---|
| 445 | else
|
---|
| 446 | movestc(stcrow, ++stccol);
|
---|
| 447 |
|
---|
| 448 | return;
|
---|
| 449 |
|
---|
| 450 | } else if (inrange(stccol, 12, 22)) { /* action 1 */
|
---|
| 451 |
|
---|
| 452 | action = 0;
|
---|
| 453 | sqactde(key);
|
---|
| 454 | return;
|
---|
| 455 |
|
---|
| 456 | } else if (inrange(stccol, 24, 34)) { /* action 2 */
|
---|
| 457 |
|
---|
| 458 | action = 1;
|
---|
| 459 | sqactde(key);
|
---|
| 460 | return;
|
---|
| 461 |
|
---|
| 462 | } else if (inrange(stccol, 36, 46)) { /* action 3 */
|
---|
| 463 |
|
---|
| 464 | action = 2;
|
---|
| 465 | sqactde(key);
|
---|
| 466 | return;
|
---|
| 467 | }
|
---|
| 468 | }
|
---|