| 1 | /*
|
|---|
| 2 | =============================================================================
|
|---|
| 3 | ptfield.c -- MIDAS-VII patch display field functions
|
|---|
| 4 | Version 35 -- 1989-11-16 -- D.N. Lynx Crowe
|
|---|
| 5 | =============================================================================
|
|---|
| 6 | */
|
|---|
| 7 |
|
|---|
| 8 | #define DEBUGXP 0
|
|---|
| 9 |
|
|---|
| 10 | #define USEVECTR 0 /* to force vector cursor control */
|
|---|
| 11 |
|
|---|
| 12 | #include "stddefs.h"
|
|---|
| 13 | #include "hwdefs.h"
|
|---|
| 14 | #include "graphdef.h"
|
|---|
| 15 | #include "vsdd.h"
|
|---|
| 16 | #include "fields.h"
|
|---|
| 17 | #include "curpak.h"
|
|---|
| 18 | #include "patch.h"
|
|---|
| 19 | #include "macros.h"
|
|---|
| 20 |
|
|---|
| 21 | #include "midas.h"
|
|---|
| 22 | #include "ptdisp.h"
|
|---|
| 23 |
|
|---|
| 24 | #if DEBUGXP
|
|---|
| 25 | extern short debugsw;
|
|---|
| 26 |
|
|---|
| 27 | short debugxp = 1;
|
|---|
| 28 | #endif
|
|---|
| 29 |
|
|---|
| 30 | #if USEVECTR
|
|---|
| 31 | short usevect = TRUE;
|
|---|
| 32 |
|
|---|
| 33 | extern void (*cx_key)(void);
|
|---|
| 34 | extern void (*cy_key)(void);
|
|---|
| 35 | #endif
|
|---|
| 36 |
|
|---|
| 37 | extern void (*xy_up)(void);
|
|---|
| 38 | extern void (*xy_dn)(void);
|
|---|
| 39 | extern void (*premove)(void);
|
|---|
| 40 | extern void (*pstmove)(void);
|
|---|
| 41 | extern int16_t (*curtype)(void);
|
|---|
| 42 |
|
|---|
| 43 | extern uint16_t fromfpu(uint16_t fputime);
|
|---|
| 44 |
|
|---|
| 45 | extern void select(void);
|
|---|
| 46 | extern void nokey(void);
|
|---|
| 47 | extern int16_t nonf(int16_t k);
|
|---|
| 48 | extern int16_t stdctp5(void);
|
|---|
| 49 | extern void cxkstd(void);
|
|---|
| 50 | extern void cykstd(void);
|
|---|
| 51 | extern void stdmkey(void);
|
|---|
| 52 | extern void stddkey(int16_t k);
|
|---|
| 53 | extern void stopcm(void);
|
|---|
| 54 | extern void smxupd(void);
|
|---|
| 55 | extern void smyupd(void);
|
|---|
| 56 | extern void aftercm(void);
|
|---|
| 57 | extern void ptdkey(int16_t k);
|
|---|
| 58 |
|
|---|
| 59 | extern int16_t astat;
|
|---|
| 60 | extern int16_t chtime;
|
|---|
| 61 | extern int16_t chwait;
|
|---|
| 62 | extern int16_t cmfirst;
|
|---|
| 63 | extern int16_t cmtype;
|
|---|
| 64 | extern int16_t curhold;
|
|---|
| 65 | extern int16_t cvtime;
|
|---|
| 66 | extern int16_t cvwait;
|
|---|
| 67 | extern int16_t ncvwait;
|
|---|
| 68 | extern int16_t ptbflag;
|
|---|
| 69 | extern int16_t ptecpos;
|
|---|
| 70 | extern int16_t ptedef;
|
|---|
| 71 | extern int16_t ptedfok;
|
|---|
| 72 | extern int16_t pteset;
|
|---|
| 73 | extern int16_t ptestm;
|
|---|
| 74 | extern int16_t ptestok;
|
|---|
| 75 | extern int16_t ss_ptsw;
|
|---|
| 76 | extern int16_t ss_sqsw;
|
|---|
| 77 | extern int16_t stccol;
|
|---|
| 78 | extern int16_t stcrow;
|
|---|
| 79 | extern int16_t syrate;
|
|---|
| 80 | extern int16_t tvcwval;
|
|---|
| 81 | extern int16_t vcwval;
|
|---|
| 82 |
|
|---|
| 83 | extern int16_t crate1[];
|
|---|
| 84 |
|
|---|
| 85 | extern int8_t ptdebuf[];
|
|---|
| 86 |
|
|---|
| 87 | extern struct selbox *csbp;
|
|---|
| 88 | extern struct selbox ptboxes[];
|
|---|
| 89 |
|
|---|
| 90 | extern struct patch ptebuf;
|
|---|
| 91 |
|
|---|
| 92 | void ptxkey(void);
|
|---|
| 93 | void ptmkey(void);
|
|---|
| 94 | void ptekey(void);
|
|---|
| 95 |
|
|---|
| 96 | /* |
|---|
| 97 |
|
|---|
| 98 | */
|
|---|
| 99 |
|
|---|
| 100 | int8_t *trdata[] = { "Trans", "Stop ", "Start" };
|
|---|
| 101 | int8_t *ssdata[] = { "Stop ", "Start" };
|
|---|
| 102 |
|
|---|
| 103 | int8_t *stdata[] = { "Srce" , "Mult", "Time", "Valu", "Func" };
|
|---|
| 104 |
|
|---|
| 105 | int8_t *smdata[] = {
|
|---|
| 106 |
|
|---|
| 107 | " ", /* SM_NONE 0 No source - always 0 */
|
|---|
| 108 | "Randm", /* SM_RAND 1 Random source */
|
|---|
| 109 | "GPC/V", /* SM_CTL1 2 Control Voltage 1 / MIDI GPC 1 */
|
|---|
| 110 | "??3??", /* ------- 3 -unused- */
|
|---|
| 111 | "??4??", /* ------- 4 -unused- */
|
|---|
| 112 | "Pitch", /* SM_PTCH 5 Key Pitch */
|
|---|
| 113 | "KeyPr", /* SM_KPRS 6 Key Pressure */
|
|---|
| 114 | "KeyVL", /* SM_KVEL 7 Key Velocity */
|
|---|
| 115 | "Pedal", /* SM_PED1 8 Pedal 1 */
|
|---|
| 116 | "??9??", /* ------- 9 -unused- */
|
|---|
| 117 | "Freq ", /* SM_FREQ 10 Key Frequency */
|
|---|
| 118 | "PchWh", /* SM_HTPW 11 Tablet X / MIDI Pitch Wheel */
|
|---|
| 119 | "ModWh", /* SM_VTMW 12 Tablet Y / MIDI Mod Wheel */
|
|---|
| 120 | "Breth", /* SM_LPBR 13 LongPot / MIDI Breath Controller */
|
|---|
| 121 | };
|
|---|
| 122 |
|
|---|
| 123 | struct curpak pt_flds = {
|
|---|
| 124 |
|
|---|
| 125 | stdctp5, /* curtype */
|
|---|
| 126 | nokey, /* premove */
|
|---|
| 127 | aftercm, /* pstmove */
|
|---|
| 128 | cxkstd, /* cx_key */
|
|---|
| 129 | cykstd, /* cy_key */
|
|---|
| 130 | smxupd, /* cx_upd */
|
|---|
| 131 | smyupd, /* cy_upd */
|
|---|
| 132 | stopcm, /* xy_up */
|
|---|
| 133 | nokey, /* xy_dn */
|
|---|
| 134 | ptxkey, /* x_key */
|
|---|
| 135 | ptekey, /* e_key */
|
|---|
| 136 | ptmkey, /* m_key */
|
|---|
| 137 | ptdkey, /* d_key */
|
|---|
| 138 | nonf, /* not_fld */
|
|---|
| 139 | (struct fet *)NULL, /* curfet */
|
|---|
| 140 | ptboxes, /* csbp */
|
|---|
| 141 | crate1, /* cratex */
|
|---|
| 142 | crate1, /* cratey */
|
|---|
| 143 | CT_SMTH, /* cmtype */
|
|---|
| 144 | CTOX(2), /* cxval */
|
|---|
| 145 | RTOY(DATAROW) /* cyval */
|
|---|
| 146 | };
|
|---|
| 147 |
|
|---|
| 148 | /* |
|---|
| 149 |
|
|---|
| 150 | */
|
|---|
| 151 |
|
|---|
| 152 | /*
|
|---|
| 153 | =============================================================================
|
|---|
| 154 | ptmkey() -- M key processing for the patch display
|
|---|
| 155 | =============================================================================
|
|---|
| 156 | */
|
|---|
| 157 |
|
|---|
| 158 | void ptmkey(void)
|
|---|
| 159 | {
|
|---|
| 160 | register int16_t nc;
|
|---|
| 161 |
|
|---|
| 162 | if (astat) {
|
|---|
| 163 |
|
|---|
| 164 | if (stccol EQ 48) {
|
|---|
| 165 |
|
|---|
| 166 | if (ss_sqsw EQ 0) {
|
|---|
| 167 |
|
|---|
| 168 | (*xy_dn)(); /* handle KEY_DOWN functions */
|
|---|
| 169 |
|
|---|
| 170 | (*premove)(); /* handle PRE-MOVE functions */
|
|---|
| 171 |
|
|---|
| 172 | nc = (*curtype)(); /* get new CURSOR TYPE wanted */
|
|---|
| 173 |
|
|---|
| 174 | cvtime = syrate;
|
|---|
| 175 | ncvwait = curhold;
|
|---|
| 176 |
|
|---|
| 177 | ss_ptsw = -1;
|
|---|
| 178 | cmtype = nc;
|
|---|
| 179 | cvwait = 1;
|
|---|
| 180 | }
|
|---|
| 181 |
|
|---|
| 182 | } else
|
|---|
| 183 | stdmkey();
|
|---|
| 184 |
|
|---|
| 185 | } else {
|
|---|
| 186 |
|
|---|
| 187 | if (stccol EQ 48) {
|
|---|
| 188 |
|
|---|
| 189 | ss_ptsw = 0;
|
|---|
| 190 | cvwait = 1;
|
|---|
| 191 | ncvwait = cvtime;
|
|---|
| 192 | cmfirst = TRUE;
|
|---|
| 193 |
|
|---|
| 194 | if (ss_sqsw EQ 0)
|
|---|
| 195 | (*xy_up)();
|
|---|
| 196 |
|
|---|
| 197 | (*pstmove)(); /* handle POST-MOVE functions */
|
|---|
| 198 |
|
|---|
| 199 | } else
|
|---|
| 200 | stdmkey();
|
|---|
| 201 | }
|
|---|
| 202 | }
|
|---|
| 203 |
|
|---|
| 204 | /* |
|---|
| 205 |
|
|---|
| 206 | */
|
|---|
| 207 |
|
|---|
| 208 | /*
|
|---|
| 209 | =============================================================================
|
|---|
| 210 | ptekey() -- E key processing for the patch display
|
|---|
| 211 | =============================================================================
|
|---|
| 212 | */
|
|---|
| 213 |
|
|---|
| 214 | void ptekey(void)
|
|---|
| 215 | {
|
|---|
| 216 | register int16_t nc;
|
|---|
| 217 |
|
|---|
| 218 | if (astat) {
|
|---|
| 219 |
|
|---|
| 220 | if (stccol EQ 48) {
|
|---|
| 221 |
|
|---|
| 222 | if (ss_sqsw EQ 0) {
|
|---|
| 223 |
|
|---|
| 224 | (*xy_dn)(); /* handle KEY_DOWN functions */
|
|---|
| 225 |
|
|---|
| 226 | (*premove)(); /* handle PRE-MOVE functions */
|
|---|
| 227 |
|
|---|
| 228 | nc = (*curtype)(); /* get new CURSOR TYPE wanted */
|
|---|
| 229 |
|
|---|
| 230 | cvtime = syrate;
|
|---|
| 231 | ncvwait = curhold;
|
|---|
| 232 |
|
|---|
| 233 | ss_ptsw = 1;
|
|---|
| 234 | cmtype = nc;
|
|---|
| 235 | cvwait = 1;
|
|---|
| 236 | }
|
|---|
| 237 |
|
|---|
| 238 | } else
|
|---|
| 239 | select();
|
|---|
| 240 |
|
|---|
| 241 | } else {
|
|---|
| 242 |
|
|---|
| 243 | if (stccol EQ 48) {
|
|---|
| 244 |
|
|---|
| 245 | ss_ptsw = 0;
|
|---|
| 246 | cvwait = 1;
|
|---|
| 247 | ncvwait = cvtime;
|
|---|
| 248 | cmfirst = TRUE;
|
|---|
| 249 |
|
|---|
| 250 | if (ss_sqsw EQ 0)
|
|---|
| 251 | (*xy_up)();
|
|---|
| 252 |
|
|---|
| 253 | (*pstmove)(); /* handle POST-MOVE functions */
|
|---|
| 254 |
|
|---|
| 255 | } else
|
|---|
| 256 | select();
|
|---|
| 257 | }
|
|---|
| 258 | }
|
|---|
| 259 |
|
|---|
| 260 | /* |
|---|
| 261 |
|
|---|
| 262 | */
|
|---|
| 263 |
|
|---|
| 264 | /*
|
|---|
| 265 | =============================================================================
|
|---|
| 266 | ptxkey() -- X key processing for the patch display
|
|---|
| 267 | =============================================================================
|
|---|
| 268 | */
|
|---|
| 269 |
|
|---|
| 270 | void ptxkey(void)
|
|---|
| 271 | {
|
|---|
| 272 | register int16_t i, cp, pp, sp, stm;
|
|---|
| 273 |
|
|---|
| 274 | if (NOT astat) /* only on key closures ... */
|
|---|
| 275 | return;
|
|---|
| 276 |
|
|---|
| 277 | if (inrange(stccol, 2, 13)) { /* definer -- clear definer */
|
|---|
| 278 |
|
|---|
| 279 | if (ptecpos AND NOT ptbflag) { /* refresh data entry stuff */
|
|---|
| 280 |
|
|---|
| 281 | memcpyw(&ptebuf.defnum, &patches[ptecpos].defnum, 6);
|
|---|
| 282 | pteset = TRUE;
|
|---|
| 283 | pte2buf();
|
|---|
| 284 | }
|
|---|
| 285 |
|
|---|
| 286 | ptedef = NULL_DEF;
|
|---|
| 287 | ptedfok = TRUE;
|
|---|
| 288 |
|
|---|
| 289 | memset(&ptdebuf[2], ' ', 12);
|
|---|
| 290 |
|
|---|
| 291 | for (i = 0; i < 48; i++)
|
|---|
| 292 | if (ptdebuf[i] EQ '\0')
|
|---|
| 293 | ptdebuf[i] = ' ';
|
|---|
| 294 |
|
|---|
| 295 | ptdebuf[0] = '\260';
|
|---|
| 296 | ptdebuf[48] = '\0';
|
|---|
| 297 |
|
|---|
| 298 | UpdVid(7, 0, ptdebuf, PTEATR);
|
|---|
| 299 | movectc(stcrow, stccol);
|
|---|
| 300 |
|
|---|
| 301 | /* |
|---|
| 302 |
|
|---|
| 303 | */
|
|---|
| 304 | } else if (inrange(stccol, 15, 26)) { /* stimulus -- clear stimulus */
|
|---|
| 305 |
|
|---|
| 306 | if (ptecpos AND NOT ptbflag) { /* refresh data entry stuff */
|
|---|
| 307 |
|
|---|
| 308 | memcpyw(&ptebuf.defnum, &patches[ptecpos].defnum, 6);
|
|---|
| 309 | pteset = TRUE;
|
|---|
| 310 | pte2buf();
|
|---|
| 311 | }
|
|---|
| 312 |
|
|---|
| 313 | ptestm = NULL_DEF;
|
|---|
| 314 | ptestok = FALSE;
|
|---|
| 315 |
|
|---|
| 316 | memset(&ptdebuf[15], ' ', 12);
|
|---|
| 317 |
|
|---|
| 318 | for (i = 0; i < 48; i++)
|
|---|
| 319 | if (ptdebuf[i] EQ '\0')
|
|---|
| 320 | ptdebuf[i] = ' ';
|
|---|
| 321 |
|
|---|
| 322 | ptdebuf[0] = '\260';
|
|---|
| 323 | ptdebuf[48] = '\0';
|
|---|
| 324 |
|
|---|
| 325 | UpdVid(7, 0, ptdebuf, PTEATR);
|
|---|
| 326 | movectc(stcrow, stccol);
|
|---|
| 327 |
|
|---|
| 328 | } else if (inrange(stccol, 28, 40)) { /* destination -- clear line */
|
|---|
| 329 |
|
|---|
| 330 | voidpb(); /* void the patch buffer */
|
|---|
| 331 |
|
|---|
| 332 | ptdebuf[0] = '\260';
|
|---|
| 333 | ptdebuf[48] = '\0';
|
|---|
| 334 |
|
|---|
| 335 | UpdVid(7, 0, ptdebuf, PTEATR);
|
|---|
| 336 | movectc(stcrow, stccol);
|
|---|
| 337 | /* |
|---|
| 338 |
|
|---|
| 339 | */
|
|---|
| 340 | } else if (inrange(stccol, 42, 46)) { /* datum -- delete the patch */
|
|---|
| 341 |
|
|---|
| 342 | if (ptecpos) {
|
|---|
| 343 |
|
|---|
| 344 | cp = ptecpos; /* setup indices */
|
|---|
| 345 | pp = patches[cp].prevstm;
|
|---|
| 346 | sp = patches[cp].nextstm;
|
|---|
| 347 |
|
|---|
| 348 | stm = patches[cp].stmnum; /* get stimulus used */
|
|---|
| 349 | #if DEBUGXP
|
|---|
| 350 | if (debugsw AND debugxp)
|
|---|
| 351 | printf("ptxkey(): DELETING PATCH pp = %d cp = %d sp = %d\n",
|
|---|
| 352 | pp, cp, sp);
|
|---|
| 353 | #endif
|
|---|
| 354 |
|
|---|
| 355 | if (pp) /* adjust predecessor */
|
|---|
| 356 | patches[pp].nextstm = sp;
|
|---|
| 357 | else /* adjust stmptr */
|
|---|
| 358 | stmptr[TRG_MASK & stm] = sp;
|
|---|
| 359 |
|
|---|
| 360 | if (sp) /* adjust successor */
|
|---|
| 361 | patches[sp].prevstm = pp;
|
|---|
| 362 |
|
|---|
| 363 | if (sp = findnxt(cp)) /* adjust ptecpos */
|
|---|
| 364 | ptecpos = sp;
|
|---|
| 365 | else if (pp = findprv(cp))
|
|---|
| 366 | ptecpos = pp;
|
|---|
| 367 | else
|
|---|
| 368 | ptecpos = 0;
|
|---|
| 369 |
|
|---|
| 370 | pt_del(cp); /* delete the patch entry */
|
|---|
| 371 | /* |
|---|
| 372 |
|
|---|
| 373 | */
|
|---|
| 374 | for (i = 0; i < NDEFSTMS; ++i) { /* adjust defptr list */
|
|---|
| 375 |
|
|---|
| 376 | if (cp = defptr[i]) { /* in use ? */
|
|---|
| 377 |
|
|---|
| 378 | pp = 0; /* initial predecessor */
|
|---|
| 379 |
|
|---|
| 380 | while (cp) { /* check the chain */
|
|---|
| 381 |
|
|---|
| 382 | sp = defents[cp].nextdef; /* successor */
|
|---|
| 383 |
|
|---|
| 384 | if (defents[cp].stm EQ stm) {
|
|---|
| 385 |
|
|---|
| 386 | #if DEBUGXP
|
|---|
| 387 | if (debugsw AND debugxp) {
|
|---|
| 388 |
|
|---|
| 389 | printf("ptxkey(): DELETING DEF trg=$%04.4X stm=$%04.4X\n",
|
|---|
| 390 | i, stm);
|
|---|
| 391 |
|
|---|
| 392 | printf("ptxkey(): DELETING DEF pp=%d cp=%d sp=%d\n",
|
|---|
| 393 | pp, cp, sp);
|
|---|
| 394 | }
|
|---|
| 395 | #endif
|
|---|
| 396 |
|
|---|
| 397 | if (pp) /* adjust predecessor */
|
|---|
| 398 | defents[pp].nextdef = sp;
|
|---|
| 399 | else /* adjust defptr */
|
|---|
| 400 | defptr[i] = sp;
|
|---|
| 401 |
|
|---|
| 402 | dt_del(cp); /* delete def entry */
|
|---|
| 403 |
|
|---|
| 404 | } else {
|
|---|
| 405 |
|
|---|
| 406 | pp = cp; /* update predecessor index */
|
|---|
| 407 | }
|
|---|
| 408 |
|
|---|
| 409 | cp = sp; /* next defent */
|
|---|
| 410 | }
|
|---|
| 411 | }
|
|---|
| 412 | }
|
|---|
| 413 |
|
|---|
| 414 | dptw(); /* update the display */
|
|---|
| 415 | }
|
|---|
| 416 | }
|
|---|
| 417 | }
|
|---|
| 418 |
|
|---|
| 419 | /* |
|---|
| 420 |
|
|---|
| 421 | */
|
|---|
| 422 |
|
|---|
| 423 | /*
|
|---|
| 424 | =============================================================================
|
|---|
| 425 | dspdfst() -- convert a patch DEF or STM value for display
|
|---|
| 426 | =============================================================================
|
|---|
| 427 | */
|
|---|
| 428 |
|
|---|
| 429 | void dspdfst(int8_t *buf, uint16_t val)
|
|---|
| 430 | {
|
|---|
| 431 | register uint16_t chan, port, stim;
|
|---|
| 432 |
|
|---|
| 433 | if (val EQ NULL_DEF) { /* handle possible blank definer */
|
|---|
| 434 |
|
|---|
| 435 | strcpy(buf, " ");
|
|---|
| 436 | return;
|
|---|
| 437 | }
|
|---|
| 438 |
|
|---|
| 439 | port = (val >> 11) & 0x0003;
|
|---|
| 440 | chan = (val >> 7) & 0x000F;
|
|---|
| 441 | stim = val & 0x007F;
|
|---|
| 442 |
|
|---|
| 443 | switch (port) { /* use port to decode possible types */
|
|---|
| 444 |
|
|---|
| 445 | case 0: /* MIDI-1 - Keys */
|
|---|
| 446 | case 1: /* MIDI-2 - Keys */
|
|---|
| 447 |
|
|---|
| 448 | sprintf(buf, "%s %03u %u %02u",
|
|---|
| 449 | (val & 0x8000) ? "Rel" : "Key",
|
|---|
| 450 | 1 + stim, 1 + port, 1 + chan);
|
|---|
| 451 |
|
|---|
| 452 | break;
|
|---|
| 453 | /* |
|---|
| 454 |
|
|---|
| 455 | */
|
|---|
| 456 |
|
|---|
| 457 | case 2: /* Local Keys */
|
|---|
| 458 |
|
|---|
| 459 | switch (chan) { /* use channel to further decode */
|
|---|
| 460 |
|
|---|
| 461 | case 0: /* Keys - Local Keyboard */
|
|---|
| 462 |
|
|---|
| 463 | sprintf(buf, "%s %03u L ",
|
|---|
| 464 | (val & 0x8000) ? "Rel" : "Key",
|
|---|
| 465 | 1 + stim);
|
|---|
| 466 |
|
|---|
| 467 | break;
|
|---|
| 468 |
|
|---|
| 469 | case 2: /* Triggers */
|
|---|
| 470 |
|
|---|
| 471 | sprintf(buf, "Trig %02u ", 1 + stim);
|
|---|
| 472 | break;
|
|---|
| 473 |
|
|---|
| 474 | case 3: /* Pulses */
|
|---|
| 475 |
|
|---|
| 476 | sprintf(buf, "Pulse %u ", 1 + stim);
|
|---|
| 477 | break;
|
|---|
| 478 |
|
|---|
| 479 | default: /* spurious type -- shouldn't happen */
|
|---|
| 480 |
|
|---|
| 481 | sprintf(buf, "%s?? %03u L %02u",
|
|---|
| 482 | (val & 0x8000) ? "r" : "c",
|
|---|
| 483 | 1 + stim, 1 + chan);
|
|---|
| 484 | break;
|
|---|
| 485 |
|
|---|
| 486 | }
|
|---|
| 487 |
|
|---|
| 488 | break;
|
|---|
| 489 |
|
|---|
| 490 | default: /* spurious port -- should never happen */
|
|---|
| 491 |
|
|---|
| 492 | sprintf(buf, "??? %03u %u %02u", 1 + stim, 1 + port, 1 + chan);
|
|---|
| 493 | break;
|
|---|
| 494 | }
|
|---|
| 495 | }
|
|---|
| 496 |
|
|---|
| 497 | /* |
|---|
| 498 |
|
|---|
| 499 | */
|
|---|
| 500 |
|
|---|
| 501 | /*
|
|---|
| 502 | =============================================================================
|
|---|
| 503 | dfpdat() -- convert FPU datum for display
|
|---|
| 504 | =============================================================================
|
|---|
| 505 | */
|
|---|
| 506 |
|
|---|
| 507 | int8_t *dfpdat(struct patch *pp)
|
|---|
| 508 | {
|
|---|
| 509 | static int8_t buf[32];
|
|---|
| 510 | uint16_t sgn, vp1, vp2;
|
|---|
| 511 | int16_t val;
|
|---|
| 512 |
|
|---|
| 513 | val = pp->padat2;
|
|---|
| 514 |
|
|---|
| 515 | switch (pp->padat1) {
|
|---|
| 516 |
|
|---|
| 517 | case PSA_SRC: /* source */
|
|---|
| 518 |
|
|---|
| 519 | strcpy(buf, smdata[val]);
|
|---|
| 520 | break;
|
|---|
| 521 |
|
|---|
| 522 | case PSA_MLT: /* multiplier */
|
|---|
| 523 |
|
|---|
| 524 | fr2dec(val, ebuf);
|
|---|
| 525 |
|
|---|
| 526 | buf[0] = ebuf[3];
|
|---|
| 527 | buf[1] = ebuf[0];
|
|---|
| 528 | buf[2] = '.';
|
|---|
| 529 | buf[3] = ebuf[1];
|
|---|
| 530 | buf[4] = ebuf[2];
|
|---|
| 531 | buf[5] = '\0';
|
|---|
| 532 | break;
|
|---|
| 533 | /* |
|---|
| 534 |
|
|---|
| 535 | */
|
|---|
| 536 | case PSA_VAL: /* value */
|
|---|
| 537 |
|
|---|
| 538 | val >>= 5;
|
|---|
| 539 |
|
|---|
| 540 | if (val < 0) {
|
|---|
| 541 |
|
|---|
| 542 | val = -val;
|
|---|
| 543 | sgn = '-';
|
|---|
| 544 |
|
|---|
| 545 | } else {
|
|---|
| 546 |
|
|---|
| 547 | sgn = '+';
|
|---|
| 548 | }
|
|---|
| 549 |
|
|---|
| 550 | vp1 = val / 100;
|
|---|
| 551 | vp2 = val - (vp1 * 100);
|
|---|
| 552 |
|
|---|
| 553 | if (vp1 > 9) {
|
|---|
| 554 |
|
|---|
| 555 | vp1 = 0;
|
|---|
| 556 |
|
|---|
| 557 | if (sgn EQ '+')
|
|---|
| 558 | sgn = '\240';
|
|---|
| 559 | else
|
|---|
| 560 | sgn = '\241';
|
|---|
| 561 | }
|
|---|
| 562 |
|
|---|
| 563 | sprintf(buf, "%c%u.%02u", sgn, vp1, vp2);
|
|---|
| 564 | break;
|
|---|
| 565 | /* |
|---|
| 566 |
|
|---|
| 567 | */
|
|---|
| 568 | case PSA_TIM: /* time */
|
|---|
| 569 |
|
|---|
| 570 | vp1 = fromfpu(val);
|
|---|
| 571 |
|
|---|
| 572 | sprintf(buf, "%5u", vp1);
|
|---|
| 573 | break;
|
|---|
| 574 |
|
|---|
| 575 | case PSA_FNC: /* function / control */
|
|---|
| 576 |
|
|---|
| 577 | if ((PE_SPEC & pp->paspec) EQ PA_AUX)
|
|---|
| 578 | sprintf(buf, "%s", (val & 0x0001) ? "On " : "Off ");
|
|---|
| 579 | else
|
|---|
| 580 | sprintf(buf, "%s", (val & 0x0001) ? "Start" : "Stop ");
|
|---|
| 581 |
|
|---|
| 582 | break;
|
|---|
| 583 |
|
|---|
| 584 | default:
|
|---|
| 585 |
|
|---|
| 586 | sprintf(buf, "$%04.4X", val);
|
|---|
| 587 | break;
|
|---|
| 588 | }
|
|---|
| 589 |
|
|---|
| 590 | return(buf);
|
|---|
| 591 | }
|
|---|
| 592 |
|
|---|
| 593 | /* |
|---|
| 594 |
|
|---|
| 595 | */
|
|---|
| 596 |
|
|---|
| 597 | /*
|
|---|
| 598 | =============================================================================
|
|---|
| 599 | pafpu1() -- convert patch for display -- aaaaa ssss tn ddddd
|
|---|
| 600 |
|
|---|
| 601 | Level, Filtr, Fil Q, Loctn, Dynmc
|
|---|
| 602 | =============================================================================
|
|---|
| 603 | */
|
|---|
| 604 |
|
|---|
| 605 | void pafpu1(int8_t *bf, int8_t *ad, uint16_t gt, uint16_t gn, struct patch *pp)
|
|---|
| 606 | {
|
|---|
| 607 | sprintf(bf, "%s %s %c%c %s", ad, stdata[pp->padat1], gt, gn, dfpdat(pp));
|
|---|
| 608 | }
|
|---|
| 609 |
|
|---|
| 610 | /*
|
|---|
| 611 | =============================================================================
|
|---|
| 612 | pafpu2() -- convert patch for display -- aaa n ssss tn ddddd
|
|---|
| 613 |
|
|---|
| 614 | Index, Freq
|
|---|
| 615 | =============================================================================
|
|---|
| 616 | */
|
|---|
| 617 |
|
|---|
| 618 | void pafpu2(int8_t *bf, int8_t *ad, uint16_t os, uint16_t gt, uint16_t gn, struct patch *pp)
|
|---|
| 619 | {
|
|---|
| 620 | sprintf(bf, "%s %d %s %c%c %s", ad, os, stdata[pp->padat1], gt, gn, dfpdat(pp));
|
|---|
| 621 | }
|
|---|
| 622 |
|
|---|
| 623 | /*
|
|---|
| 624 | =============================================================================
|
|---|
| 625 | pafpu3() -- convert patch for display -- aaaaa ssss ddddd
|
|---|
| 626 |
|
|---|
| 627 | Aux, Rate, Inten, Depth, Vlt
|
|---|
| 628 | =============================================================================
|
|---|
| 629 | */
|
|---|
| 630 |
|
|---|
| 631 | void pafpu3(int8_t *bf, int8_t *ad, struct patch *pp)
|
|---|
| 632 | {
|
|---|
| 633 | sprintf(bf, "%s %s %s", ad, stdata[pp->padat1], dfpdat(pp));
|
|---|
| 634 | }
|
|---|
| 635 |
|
|---|
| 636 | /* |
|---|
| 637 |
|
|---|
| 638 | */
|
|---|
| 639 |
|
|---|
| 640 | /*
|
|---|
| 641 | =============================================================================
|
|---|
| 642 | dspdest() -- convert patch destination and datum for display
|
|---|
| 643 | =============================================================================
|
|---|
| 644 | */
|
|---|
| 645 |
|
|---|
| 646 | void dspdest(int8_t *buf, struct patch *pp)
|
|---|
| 647 | {
|
|---|
| 648 | uint16_t chan, osc, port, stim, vg, vgt, vgn, vp1, vp2, sgn;
|
|---|
| 649 | int16_t val;
|
|---|
| 650 | int8_t buf2[16], *rtype;
|
|---|
| 651 |
|
|---|
| 652 | port = (pp->pasuba >> 11) & 0x0003; /* for trg types */
|
|---|
| 653 | chan = (pp->pasuba >> 7) & 0x000F;
|
|---|
| 654 | stim = pp->pasuba & 0x007F;
|
|---|
| 655 |
|
|---|
| 656 | vg = (pp->pasuba >> 8) & 0x00FF; /* for vg types */
|
|---|
| 657 | osc = (pp->pasuba & 0x00FF) + 1;
|
|---|
| 658 |
|
|---|
| 659 | if (vg > 11) {
|
|---|
| 660 |
|
|---|
| 661 | vgt = 'G';
|
|---|
| 662 | vgn = vg - 11;
|
|---|
| 663 |
|
|---|
| 664 | } else {
|
|---|
| 665 |
|
|---|
| 666 | vgt = 'V';
|
|---|
| 667 | vgn = vg + 1;
|
|---|
| 668 | }
|
|---|
| 669 |
|
|---|
| 670 | vgn = vgn + ((vgn > 9) ? '\242' : '0');
|
|---|
| 671 |
|
|---|
| 672 | /* |
|---|
| 673 |
|
|---|
| 674 | */
|
|---|
| 675 | switch (PE_SPEC & pp->paspec) {
|
|---|
| 676 |
|
|---|
| 677 | case PA_KEY: /* key action */
|
|---|
| 678 |
|
|---|
| 679 | sprintf(buf, "K %03u %u %02u %s",
|
|---|
| 680 | 1 + stim, 1 + port, 1 + chan,
|
|---|
| 681 | trdata[pp->padat2 & 0x0003]);
|
|---|
| 682 |
|
|---|
| 683 | break;
|
|---|
| 684 |
|
|---|
| 685 | case PA_TRG:
|
|---|
| 686 |
|
|---|
| 687 | sprintf(buf, "Trigger %02u %s",
|
|---|
| 688 | 1 + stim,
|
|---|
| 689 | ssdata[pp->padat2 & 0x0001]);
|
|---|
| 690 |
|
|---|
| 691 | break;
|
|---|
| 692 |
|
|---|
| 693 | case PA_PLS:
|
|---|
| 694 |
|
|---|
| 695 | sprintf(buf, "Pulse %u %s",
|
|---|
| 696 | 1 + stim,
|
|---|
| 697 | trdata[pp->padat2 & 0x0003]);
|
|---|
| 698 |
|
|---|
| 699 | break;
|
|---|
| 700 | /* |
|---|
| 701 |
|
|---|
| 702 | */
|
|---|
| 703 | case PA_LED:
|
|---|
| 704 |
|
|---|
| 705 | if (pp->pasuba & 0x0001) {
|
|---|
| 706 |
|
|---|
| 707 | sprintf(buf, "LED %c %c%c%c%c",
|
|---|
| 708 | 'A' + pp->pasuba,
|
|---|
| 709 | '0' + ((pp->padat1 >> 14) & 0x0003),
|
|---|
| 710 | '0' + ((pp->padat1 >> 12) & 0x0003),
|
|---|
| 711 | '0' + ((pp->padat1 >> 10) & 0x0003),
|
|---|
| 712 | '0' + ((pp->padat1 >> 8) & 0x0003));
|
|---|
| 713 |
|
|---|
| 714 | } else {
|
|---|
| 715 |
|
|---|
| 716 | sprintf(buf, "LED %c %c%c%c",
|
|---|
| 717 | 'A' + pp->pasuba,
|
|---|
| 718 | '0' + ((pp->padat1 >> 14) & 0x0003),
|
|---|
| 719 | '0' + ((pp->padat1 >> 12) & 0x0003),
|
|---|
| 720 | '0' + ((pp->padat1 >> 10) & 0x0003));
|
|---|
| 721 | }
|
|---|
| 722 |
|
|---|
| 723 | break;
|
|---|
| 724 |
|
|---|
| 725 | case PA_SLIN:
|
|---|
| 726 |
|
|---|
| 727 | sprintf(buf, "Seq %02u Lin %03u",
|
|---|
| 728 | 1 + pp->pasuba,
|
|---|
| 729 | pp->padat1);
|
|---|
| 730 |
|
|---|
| 731 | break;
|
|---|
| 732 |
|
|---|
| 733 | case PA_SCTL:
|
|---|
| 734 |
|
|---|
| 735 | sprintf(buf, "Seq %02u Ctl %s",
|
|---|
| 736 | 1 + pp->pasuba,
|
|---|
| 737 | ssdata[pp->padat2 & 0x0001]);
|
|---|
| 738 |
|
|---|
| 739 | break;
|
|---|
| 740 |
|
|---|
| 741 | case PA_TUNE:
|
|---|
| 742 |
|
|---|
| 743 | sprintf(buf, "Tune Table %u",
|
|---|
| 744 | pp->padat1);
|
|---|
| 745 |
|
|---|
| 746 | break;
|
|---|
| 747 | /* |
|---|
| 748 |
|
|---|
| 749 | */
|
|---|
| 750 | case PA_RSET:
|
|---|
| 751 |
|
|---|
| 752 | rtype = "Set";
|
|---|
| 753 | goto doregs;
|
|---|
| 754 |
|
|---|
| 755 | case PA_RADD:
|
|---|
| 756 |
|
|---|
| 757 | rtype = "Add";
|
|---|
| 758 |
|
|---|
| 759 | doregs:
|
|---|
| 760 |
|
|---|
| 761 | if (pp->padat1 & 0x0001) {
|
|---|
| 762 |
|
|---|
| 763 | sprintf(buf, "Reg %02u %s R%02u",
|
|---|
| 764 | 1 + pp->pasuba, rtype,
|
|---|
| 765 | 1 + pp->padat2);
|
|---|
| 766 |
|
|---|
| 767 | } else {
|
|---|
| 768 |
|
|---|
| 769 | if ((val = pp->padat2) < 0) {
|
|---|
| 770 |
|
|---|
| 771 | sgn = '-';
|
|---|
| 772 | val = - val;
|
|---|
| 773 |
|
|---|
| 774 | } else {
|
|---|
| 775 |
|
|---|
| 776 | sgn = '+';
|
|---|
| 777 | }
|
|---|
| 778 |
|
|---|
| 779 | sprintf(buf, "Reg %02u %s %c%02u",
|
|---|
| 780 | 1 + pp->pasuba, rtype,
|
|---|
| 781 | sgn, val);
|
|---|
| 782 | }
|
|---|
| 783 |
|
|---|
| 784 | break;
|
|---|
| 785 |
|
|---|
| 786 | case PA_INST:
|
|---|
| 787 |
|
|---|
| 788 | sprintf(buf, "Instrument %c%c %02u",
|
|---|
| 789 | vgt, vgn, pp->padat1);
|
|---|
| 790 |
|
|---|
| 791 | break;
|
|---|
| 792 | /* |
|---|
| 793 |
|
|---|
| 794 | */
|
|---|
| 795 | case PA_OSC:
|
|---|
| 796 |
|
|---|
| 797 | val = pp->padat2 >> 1;
|
|---|
| 798 |
|
|---|
| 799 | switch (pp->padat1) {
|
|---|
| 800 |
|
|---|
| 801 | case PSO_INT: /* interval */
|
|---|
| 802 |
|
|---|
| 803 | if (val < 0) {
|
|---|
| 804 |
|
|---|
| 805 | sgn = '-';
|
|---|
| 806 | val = -val;
|
|---|
| 807 |
|
|---|
| 808 | } else {
|
|---|
| 809 |
|
|---|
| 810 | sgn = '+';
|
|---|
| 811 | }
|
|---|
| 812 |
|
|---|
| 813 | sprintf(buf, "Osc %u Int %c%c %c%04u",
|
|---|
| 814 | osc, vgt, vgn, sgn, val);
|
|---|
| 815 |
|
|---|
| 816 | break;
|
|---|
| 817 |
|
|---|
| 818 | case PSO_RAT: /* ratio */
|
|---|
| 819 |
|
|---|
| 820 | int2rat(val);
|
|---|
| 821 |
|
|---|
| 822 | sprintf(buf, "Osc %u Rat %c%c %s",
|
|---|
| 823 | osc, vgt, vgn, ebuf);
|
|---|
| 824 |
|
|---|
| 825 | break;
|
|---|
| 826 |
|
|---|
| 827 | case PSO_FRQ: /* frequency */
|
|---|
| 828 |
|
|---|
| 829 | vp1 = val / 10;
|
|---|
| 830 | vp2 = val - (vp1 * 10);
|
|---|
| 831 |
|
|---|
| 832 | sprintf(buf, "Osc %u Frq %c%c %02u.%u",
|
|---|
| 833 | osc, vgt, vgn, vp1, vp2);
|
|---|
| 834 |
|
|---|
| 835 | break;
|
|---|
| 836 | /* |
|---|
| 837 |
|
|---|
| 838 | */
|
|---|
| 839 | case PSO_PCH: /* pitch */
|
|---|
| 840 |
|
|---|
| 841 | cnvc2p(ebuf, val);
|
|---|
| 842 |
|
|---|
| 843 | sprintf(buf, "Osc %u Pch %c%c %s",
|
|---|
| 844 | osc, vgt, vgn, ebuf);
|
|---|
| 845 |
|
|---|
| 846 | break;
|
|---|
| 847 |
|
|---|
| 848 | default:
|
|---|
| 849 |
|
|---|
| 850 | break;
|
|---|
| 851 | }
|
|---|
| 852 |
|
|---|
| 853 | break;
|
|---|
| 854 | /* |
|---|
| 855 |
|
|---|
| 856 | */
|
|---|
| 857 | case PA_WAVA:
|
|---|
| 858 |
|
|---|
| 859 | sgn = 'A';
|
|---|
| 860 | goto dowaves;
|
|---|
| 861 |
|
|---|
| 862 | case PA_WAVB:
|
|---|
| 863 |
|
|---|
| 864 | sgn = 'B';
|
|---|
| 865 |
|
|---|
| 866 | dowaves:
|
|---|
| 867 |
|
|---|
| 868 | sprintf(buf, "Waveshape%c %c%c %02u",
|
|---|
| 869 | sgn, vgt, vgn, pp->padat1);
|
|---|
| 870 |
|
|---|
| 871 | break;
|
|---|
| 872 |
|
|---|
| 873 | case PA_CNFG:
|
|---|
| 874 |
|
|---|
| 875 | sprintf(buf, "Configure %c%c %02u",
|
|---|
| 876 | vgt, vgn, pp->padat1);
|
|---|
| 877 |
|
|---|
| 878 | break;
|
|---|
| 879 | /* |
|---|
| 880 |
|
|---|
| 881 | */
|
|---|
| 882 | case PA_LEVL:
|
|---|
| 883 |
|
|---|
| 884 | pafpu1(buf, "Level", vgt, vgn, pp);
|
|---|
| 885 | break;
|
|---|
| 886 |
|
|---|
| 887 | case PA_INDX:
|
|---|
| 888 |
|
|---|
| 889 | pafpu2(buf, "Ind", osc, vgt, vgn, pp);
|
|---|
| 890 | break;
|
|---|
| 891 |
|
|---|
| 892 | case PA_FREQ:
|
|---|
| 893 |
|
|---|
| 894 | pafpu2(buf, "Frq", osc, vgt, vgn, pp);
|
|---|
| 895 | break;
|
|---|
| 896 |
|
|---|
| 897 | case PA_FILT:
|
|---|
| 898 |
|
|---|
| 899 | pafpu1(buf, "Filtr", vgt, vgn, pp);
|
|---|
| 900 | break;
|
|---|
| 901 |
|
|---|
| 902 | case PA_FILQ:
|
|---|
| 903 |
|
|---|
| 904 | pafpu1(buf, "Fil Q", vgt, vgn, pp);
|
|---|
| 905 | break;
|
|---|
| 906 |
|
|---|
| 907 | case PA_LOCN:
|
|---|
| 908 |
|
|---|
| 909 | pafpu1(buf, "Loctn", vgt, vgn, pp);
|
|---|
| 910 | break;
|
|---|
| 911 |
|
|---|
| 912 | case PA_DYNM:
|
|---|
| 913 |
|
|---|
| 914 | pafpu1(buf, "Dynmc", vgt, vgn, pp);
|
|---|
| 915 | break;
|
|---|
| 916 | /* |
|---|
| 917 |
|
|---|
| 918 | */
|
|---|
| 919 | case PA_AUX:
|
|---|
| 920 |
|
|---|
| 921 | pafpu3(buf, "Aux ", pp);
|
|---|
| 922 | break;
|
|---|
| 923 |
|
|---|
| 924 | case PA_RATE:
|
|---|
| 925 |
|
|---|
| 926 | pafpu3(buf, "Rate ", pp);
|
|---|
| 927 | break;
|
|---|
| 928 |
|
|---|
| 929 | case PA_INTN:
|
|---|
| 930 |
|
|---|
| 931 | pafpu3(buf, "Inten", pp);
|
|---|
| 932 | break;
|
|---|
| 933 |
|
|---|
| 934 | case PA_DPTH:
|
|---|
| 935 |
|
|---|
| 936 | pafpu3(buf, "Depth", pp);
|
|---|
| 937 | break;
|
|---|
| 938 |
|
|---|
| 939 | case PA_VOUT:
|
|---|
| 940 |
|
|---|
| 941 | sprintf(buf2, "Vlt %u", pp->pasuba);
|
|---|
| 942 | pafpu3(buf, buf2, pp);
|
|---|
| 943 | break;
|
|---|
| 944 |
|
|---|
| 945 | default:
|
|---|
| 946 |
|
|---|
| 947 | break;
|
|---|
| 948 | }
|
|---|
| 949 | }
|
|---|
| 950 |
|
|---|
| 951 | /* |
|---|
| 952 |
|
|---|
| 953 | */
|
|---|
| 954 |
|
|---|
| 955 | /*
|
|---|
| 956 | =============================================================================
|
|---|
| 957 | ptfield() -- setup field routines for the patch editor
|
|---|
| 958 | =============================================================================
|
|---|
| 959 | */
|
|---|
| 960 |
|
|---|
| 961 | void ptfield(void)
|
|---|
| 962 | {
|
|---|
| 963 | curset(&pt_flds);
|
|---|
| 964 |
|
|---|
| 965 | #if USEVECTR
|
|---|
| 966 | if (usevect) {
|
|---|
| 967 |
|
|---|
| 968 | cx_key = cxkstd;
|
|---|
| 969 | cy_key = cykstd;
|
|---|
| 970 | }
|
|---|
| 971 | #endif
|
|---|
| 972 |
|
|---|
| 973 | }
|
|---|