source: buchla-68k/ram/tdselbx.c@ 6262b5c

Last change on this file since 6262b5c was 6262b5c, checked in by Thomas Lopatic <thomas@…>, 7 years ago

Added include files for global functions and variables.

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