[f40a309] | 1 | /*
|
---|
| 2 | =============================================================================
|
---|
| 3 | tdselbx.c -- tuning editor box selection functions
|
---|
| 4 | Version 14 -- 1988-12-08 -- D.N. Lynx Crowe
|
---|
| 5 | =============================================================================
|
---|
| 6 | */
|
---|
| 7 |
|
---|
| 8 | #include "stddefs.h"
|
---|
| 9 | #include "fields.h"
|
---|
| 10 | #include "vsdd.h"
|
---|
| 11 | #include "graphdef.h"
|
---|
| 12 |
|
---|
| 13 | #include "midas.h"
|
---|
| 14 | #include "tundsp.h"
|
---|
| 15 |
|
---|
[0580615] | 16 | extern void enterit(void);
|
---|
| 17 | extern short loc2key(short row, short col);
|
---|
| 18 | extern void advtcur(void);
|
---|
| 19 | extern void bsptcur(void);
|
---|
| 20 | extern void vtdisp(unsigned *obj, unsigned fg, unsigned bg, short row, short col, char *buf);
|
---|
[60288f5] | 21 | extern void nokey(void);
|
---|
[f40a309] | 22 |
|
---|
[0580615] | 23 | extern unsigned exp_c(unsigned c);
|
---|
[f40a309] | 24 |
|
---|
| 25 | extern short hitbox, cxval, cyval, hitcx, hitcy, submenu;
|
---|
| 26 | extern short tunmod, curtun, tdnamsw;
|
---|
| 27 | extern short ttcmdsv, ttsel1, ttsel2, ttsel3;
|
---|
| 28 |
|
---|
| 29 | extern short tdbox[][8];
|
---|
| 30 |
|
---|
| 31 | extern struct selbox *csbp, *curboxp;
|
---|
| 32 |
|
---|
| 33 | extern unsigned *tunob;
|
---|
| 34 |
|
---|
| 35 | extern short tuntab[];
|
---|
| 36 | extern short oldtun[];
|
---|
| 37 |
|
---|
| 38 | extern char tuncurn[];
|
---|
| 39 | extern char vtlin1[], vtlin2[], vtlin3[];
|
---|
| 40 |
|
---|
| 41 | /* forward references */
|
---|
| 42 |
|
---|
[0580615] | 43 | short bx_null(void);
|
---|
| 44 | short tdfnbox(short n);
|
---|
[f40a309] | 45 |
|
---|
| 46 | /* |
---|
| 47 |
|
---|
| 48 | */
|
---|
| 49 |
|
---|
| 50 | struct selbox tdboxes[] = {
|
---|
| 51 |
|
---|
| 52 | { 0, 0, 95, 335, 0, tdfnbox}, /* 0: keys 0..23 */
|
---|
| 53 | { 96, 0, 175, 335, 1, tdfnbox}, /* 1: keys 24..47 */
|
---|
| 54 | {176, 0, 255, 335, 2, tdfnbox}, /* 2: keys 48..71 */
|
---|
| 55 | {256, 0, 335, 335, 3, tdfnbox}, /* 3: keys 72..95 */
|
---|
| 56 | {336, 0, 423, 335, 4, tdfnbox}, /* 4: keys 96..119 */
|
---|
| 57 | {424, 0, 511, 118, 5, tdfnbox}, /* 5: keys 120..127 */
|
---|
| 58 | {424, 119, 511, 349, 6, tdfnbox}, /* 6: commands */
|
---|
| 59 | { 0, 336, 423, 349, 7, tdfnbox}, /* 7: name */
|
---|
| 60 |
|
---|
| 61 | { 0, 0, 0, 0, 0, FN_NULL} /* end of table */
|
---|
| 62 | };
|
---|
| 63 |
|
---|
| 64 | /* |
---|
| 65 |
|
---|
| 66 | */
|
---|
| 67 |
|
---|
| 68 | /*
|
---|
| 69 | =============================================================================
|
---|
| 70 | endttyp() -- end function for virtual typewriter
|
---|
| 71 | =============================================================================
|
---|
[0580615] | 72 | */
|
---|
[f40a309] | 73 |
|
---|
| 74 | void endttyp(void)
|
---|
| 75 | {
|
---|
| 76 | tdnamsw = FALSE;
|
---|
| 77 | submenu = FALSE;
|
---|
| 78 | tdswin(0);
|
---|
| 79 | tdswin(1);
|
---|
| 80 | tdswin(2);
|
---|
| 81 | tdswin(6);
|
---|
| 82 | }
|
---|
| 83 |
|
---|
| 84 | /*
|
---|
| 85 | =============================================================================
|
---|
| 86 | tcoladj() -- adjust select column to be a display column
|
---|
| 87 | =============================================================================
|
---|
[0580615] | 88 | */
|
---|
[f40a309] | 89 |
|
---|
| 90 | short tcoladj(short icol)
|
---|
| 91 | {
|
---|
| 92 | if (icol < 12)
|
---|
| 93 | return(6);
|
---|
| 94 | else if (icol < 22)
|
---|
| 95 | return(16);
|
---|
| 96 | else if (icol < 32)
|
---|
| 97 | return(26);
|
---|
| 98 | else if (icol < 42)
|
---|
| 99 | return(36);
|
---|
| 100 | else if (icol < 53)
|
---|
| 101 | return(47);
|
---|
| 102 | else
|
---|
| 103 | return(58);
|
---|
| 104 | }
|
---|
| 105 |
|
---|
| 106 | /* |
---|
| 107 |
|
---|
| 108 | */
|
---|
| 109 |
|
---|
| 110 | /*
|
---|
| 111 | =============================================================================
|
---|
| 112 | tdhilit() -- highlight selected tuning entries
|
---|
[0580615] | 113 | =============================================================================
|
---|
[f40a309] | 114 | */
|
---|
| 115 |
|
---|
| 116 | void tdhilit(short from, short to)
|
---|
| 117 | {
|
---|
| 118 | register short i, row, col, box;
|
---|
| 119 |
|
---|
| 120 | if (to < from) {
|
---|
| 121 |
|
---|
| 122 | i = to;
|
---|
| 123 | to = from;
|
---|
| 124 | from = i;
|
---|
| 125 | }
|
---|
| 126 | /* |
---|
| 127 |
|
---|
| 128 | */
|
---|
| 129 | for (i = from; i LE to; i++) {
|
---|
| 130 |
|
---|
| 131 | if (i < 24) {
|
---|
| 132 |
|
---|
| 133 | row = i;
|
---|
| 134 | col = 6;
|
---|
| 135 | box = 0;
|
---|
| 136 |
|
---|
| 137 | } else if (i < 48) {
|
---|
| 138 |
|
---|
| 139 | row = i - 24;
|
---|
| 140 | col = 16;
|
---|
| 141 | box = 1;
|
---|
| 142 |
|
---|
| 143 | } else if (i < 72) {
|
---|
| 144 |
|
---|
| 145 | row = i - 48;
|
---|
| 146 | col = 26;
|
---|
| 147 | box = 2;
|
---|
| 148 |
|
---|
| 149 | } else if (i < 96) {
|
---|
| 150 |
|
---|
| 151 | row = i - 72;
|
---|
| 152 | col = 36;
|
---|
| 153 | box = 3;
|
---|
| 154 |
|
---|
| 155 | } else if (i < 120) {
|
---|
| 156 |
|
---|
| 157 | row = i - 96;
|
---|
| 158 | col = 47;
|
---|
| 159 | box = 4;
|
---|
| 160 |
|
---|
| 161 | } else {
|
---|
| 162 |
|
---|
| 163 | row = i - 120;
|
---|
| 164 | col = 58;
|
---|
| 165 | box = 5;
|
---|
| 166 | }
|
---|
| 167 |
|
---|
| 168 | dsttval(row, col, tuntab[i], TDSELD, tdbox[box][5]);
|
---|
| 169 | }
|
---|
| 170 | }
|
---|
| 171 |
|
---|
| 172 | /* |
---|
| 173 |
|
---|
| 174 | */
|
---|
| 175 |
|
---|
| 176 | /*
|
---|
[0580615] | 177 | =============================================================================
|
---|
[f40a309] | 178 | tdfnbox() -- tuning display box hit processor
|
---|
| 179 | =============================================================================
|
---|
| 180 | */
|
---|
| 181 |
|
---|
| 182 | short tdfnbox(short n)
|
---|
| 183 | {
|
---|
| 184 | register short i, key, dcol, row, col;
|
---|
| 185 |
|
---|
| 186 | row = hitcy / 14;
|
---|
| 187 | col = hitcx >> 3;
|
---|
| 188 |
|
---|
| 189 | switch (hitbox) {
|
---|
| 190 |
|
---|
| 191 | case 0: /* pitch area */
|
---|
| 192 | case 1:
|
---|
| 193 | case 2:
|
---|
| 194 | case 3:
|
---|
| 195 | case 4:
|
---|
| 196 | case 5:
|
---|
| 197 |
|
---|
| 198 | switch (ttcmdsv) { /* switch on editing state */
|
---|
| 199 |
|
---|
| 200 | case 0: /* data entry */
|
---|
| 201 |
|
---|
| 202 | enterit();
|
---|
| 203 | return(SUCCESS);
|
---|
| 204 | /* |
---|
| 205 |
|
---|
| 206 | */
|
---|
| 207 | case 1: /* transpose and copy -- start */
|
---|
| 208 |
|
---|
| 209 | ttsel1 = loc2key(row, col);
|
---|
| 210 |
|
---|
| 211 | if (ttsel1 < 0) {
|
---|
| 212 |
|
---|
| 213 | ttcmdsv = 0;
|
---|
| 214 | tdswin(6);
|
---|
| 215 | return(SUCCESS);
|
---|
| 216 | }
|
---|
| 217 |
|
---|
| 218 | ttcmdsv = 2;
|
---|
| 219 | dcol = tcoladj(col);
|
---|
| 220 | dsttval(row, dcol, tuntab[ttsel1], TDSELD,
|
---|
| 221 | tdbox[hitbox][5]);
|
---|
| 222 |
|
---|
| 223 | return(SUCCESS);
|
---|
| 224 |
|
---|
| 225 | case 2: /* transpose and copy -- finish */
|
---|
| 226 |
|
---|
| 227 | ttsel2 = loc2key(row, col);
|
---|
| 228 |
|
---|
| 229 | if (ttsel2 < 0) {
|
---|
| 230 |
|
---|
| 231 | ttcmdsv = 0;
|
---|
| 232 | tdswin(6);
|
---|
| 233 | return(SUCCESS);
|
---|
| 234 | }
|
---|
| 235 |
|
---|
| 236 | ttcmdsv = 3;
|
---|
| 237 | tdhilit(ttsel1, ttsel2);
|
---|
| 238 | return(SUCCESS);
|
---|
| 239 |
|
---|
| 240 | case 3: /* transpose and copy -- dest */
|
---|
| 241 |
|
---|
| 242 | ttsel3 = loc2key(row, col);
|
---|
| 243 |
|
---|
| 244 | if (ttsel3 GE 0)
|
---|
| 245 | tt_trcp(ttsel1, ttsel2, ttsel3);
|
---|
| 246 |
|
---|
| 247 | ttcmdsv = 0;
|
---|
| 248 |
|
---|
| 249 | for (i = 0; i < 7; i++)
|
---|
| 250 | tdswin(i);
|
---|
| 251 |
|
---|
| 252 | return(SUCCESS);
|
---|
| 253 | /* |
---|
| 254 |
|
---|
| 255 | */
|
---|
| 256 | case 4: /* increment -- from */
|
---|
| 257 |
|
---|
| 258 | ttsel1 = loc2key(row, col);
|
---|
| 259 |
|
---|
| 260 | if (ttsel1 < 0) {
|
---|
| 261 |
|
---|
| 262 | ttcmdsv = 0;
|
---|
| 263 | tdswin(6);
|
---|
| 264 | return(SUCCESS);
|
---|
| 265 | }
|
---|
| 266 |
|
---|
| 267 | ttcmdsv = 5;
|
---|
| 268 | dcol = tcoladj(col);
|
---|
| 269 | dsttval(row, dcol, tuntab[ttsel1], TDSELD,
|
---|
| 270 | tdbox[hitbox][5]);
|
---|
| 271 |
|
---|
| 272 | return(SUCCESS);
|
---|
| 273 |
|
---|
| 274 | case 5: /* increment -- to */
|
---|
| 275 |
|
---|
| 276 | ttsel2 = loc2key(row, col);
|
---|
| 277 |
|
---|
| 278 | if (ttsel2 GE 0)
|
---|
| 279 | tt_incr(ttsel1, ttsel2);
|
---|
| 280 |
|
---|
| 281 | ttcmdsv = 0;
|
---|
| 282 |
|
---|
| 283 | for (i = 0; i < 7; i++)
|
---|
| 284 | tdswin(i);
|
---|
| 285 |
|
---|
| 286 | return(SUCCESS);
|
---|
| 287 | /* |
---|
| 288 |
|
---|
| 289 | */
|
---|
| 290 | case 6: /* interpolate -- from */
|
---|
| 291 |
|
---|
| 292 | ttsel1 = loc2key(row, col);
|
---|
| 293 |
|
---|
| 294 | if (ttsel1 < 0) {
|
---|
| 295 |
|
---|
| 296 | ttcmdsv = 0;
|
---|
| 297 | tdswin(6);
|
---|
| 298 | return(SUCCESS);
|
---|
| 299 | }
|
---|
| 300 |
|
---|
| 301 | ttcmdsv = 7;
|
---|
| 302 | dcol = tcoladj(col);
|
---|
| 303 | dsttval(row, dcol, tuntab[ttsel1], TDSELD,
|
---|
| 304 | tdbox[hitbox][5]);
|
---|
| 305 |
|
---|
| 306 | return(SUCCESS);
|
---|
| 307 |
|
---|
| 308 | case 7: /* interpolate -- to */
|
---|
| 309 |
|
---|
| 310 | ttsel2 = loc2key(row, col);
|
---|
| 311 |
|
---|
| 312 | if (ttsel2 GE 0)
|
---|
| 313 | tt_intp(ttsel1, ttsel2);
|
---|
| 314 |
|
---|
| 315 | ttcmdsv = 0;
|
---|
| 316 |
|
---|
| 317 | for (i = 0; i < 7; i++)
|
---|
| 318 | tdswin(i);
|
---|
| 319 |
|
---|
| 320 | return(SUCCESS);
|
---|
| 321 | }
|
---|
| 322 |
|
---|
| 323 | return(FAILURE);
|
---|
| 324 | /* |
---|
| 325 |
|
---|
| 326 | */
|
---|
| 327 | case 6: /* command, value, table # */
|
---|
| 328 |
|
---|
| 329 | switch (row) {
|
---|
| 330 |
|
---|
| 331 | case 9: /* transpose and copy */
|
---|
| 332 | case 10:
|
---|
| 333 |
|
---|
| 334 | ttcmdsv = 1;
|
---|
| 335 | td_trcp(1);
|
---|
| 336 | return(SUCCESS);
|
---|
| 337 |
|
---|
| 338 | case 12: /* increment */
|
---|
| 339 |
|
---|
| 340 | ttcmdsv = 4;
|
---|
| 341 | td_incr(1);
|
---|
| 342 | return(SUCCESS);
|
---|
| 343 |
|
---|
| 344 | case 14: /* interpolate */
|
---|
| 345 |
|
---|
| 346 | ttcmdsv = 6;
|
---|
| 347 | td_intp(1);
|
---|
| 348 | return(SUCCESS);
|
---|
| 349 |
|
---|
| 350 | case 16: /* undo */
|
---|
| 351 |
|
---|
| 352 | ttcmdsv = 0;
|
---|
| 353 | memcpyw(tuntab, oldtun, 128);
|
---|
| 354 | twins();
|
---|
| 355 | return(SUCCESS);
|
---|
| 356 | /* |
---|
| 357 |
|
---|
| 358 | */
|
---|
| 359 | case 18: /* data entry */
|
---|
| 360 | case 24:
|
---|
| 361 |
|
---|
| 362 | enterit();
|
---|
| 363 | return(SUCCESS);
|
---|
| 364 |
|
---|
| 365 | case 20: /* store */
|
---|
| 366 |
|
---|
| 367 | if (curtun EQ 0)
|
---|
| 368 | return(FAILURE);
|
---|
| 369 |
|
---|
| 370 | puttun(curtun);
|
---|
| 371 | memcpyw(oldtun, tuntab, 128);
|
---|
| 372 | tdswin(6);
|
---|
| 373 | return(SUCCESS);
|
---|
| 374 |
|
---|
| 375 | case 22: /* retrieve */
|
---|
| 376 |
|
---|
| 377 | gettun(curtun);
|
---|
| 378 | memcpyw(oldtun, tuntab, 128);
|
---|
| 379 | twins();
|
---|
| 380 | return(SUCCESS);
|
---|
| 381 | }
|
---|
| 382 |
|
---|
| 383 | return(FAILURE);
|
---|
| 384 |
|
---|
| 385 | /* |
---|
| 386 |
|
---|
| 387 | */
|
---|
| 388 | case 7: /* tuning table name */
|
---|
| 389 |
|
---|
| 390 | if ((col < 7) OR (col GT 38))
|
---|
| 391 | return(FAILURE);
|
---|
| 392 |
|
---|
| 393 | if (tdnamsw) {
|
---|
| 394 |
|
---|
| 395 | vtyper();
|
---|
| 396 | tunmod = TRUE;
|
---|
| 397 |
|
---|
| 398 | } else {
|
---|
| 399 |
|
---|
| 400 | vbank(0);
|
---|
| 401 | vbfill4(tunob, 128, CTOX(1), RTOY(21),
|
---|
| 402 | CTOX(31) - 1, RTOY(24) - 1, exp_c(TDTCURB));
|
---|
| 403 |
|
---|
| 404 | tsplot4(tunob, 64, TDTCHRC, 21, 1, vtlin1, 14);
|
---|
| 405 | tsplot4(tunob, 64, TDTCHRC, 22, 1, vtlin2, 14);
|
---|
| 406 | tsplot4(tunob, 64, TDTCHRC, 23, 1, vtlin3, 14);
|
---|
| 407 |
|
---|
| 408 | vtsetup(tunob, vtdisp, 7, tuncurn, 21, 1,
|
---|
| 409 | advtcur, bsptcur, nokey, nokey, endttyp,
|
---|
| 410 | tdbox[n][4], tdbox[n][5]);
|
---|
| 411 |
|
---|
| 412 | tdnamsw = TRUE;
|
---|
| 413 | submenu = TRUE;
|
---|
| 414 | }
|
---|
| 415 |
|
---|
| 416 | return(SUCCESS);
|
---|
| 417 | }
|
---|
| 418 |
|
---|
| 419 | return(FAILURE);
|
---|
| 420 | }
|
---|