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