source: buchla-68k/ram/etioas.c@ e225e77

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

Added missing includes and declarations.

  • Property mode set to 100644
File size: 10.4 KB
Line 
1/*
2 =============================================================================
3 etioas.c -- line 17 field handlers (I/O Assignment thru Interpolate)
4 Version 12 -- 1988-08-22 -- D.N. Lynx Crowe
5 =============================================================================
6*/
7
8#include "fields.h"
9#include "hwdefs.h"
10#include "graphdef.h"
11#include "vsdd.h"
12#include "vsddsw.h"
13#include "stddefs.h"
14#include "score.h"
15#include "scfns.h"
16#include "slice.h"
17
18#include "midas.h"
19#include "scdsp.h"
20
21#include "stdio.h"
22
23extern uint16_t fromfpu(uint16_t fputime);
24extern uint16_t tofpu(uint16_t time);
25
26extern void advscur(void);
27extern void getasg(int16_t n);
28extern void gettun(int16_t n);
29extern void mpcupd(void);
30extern void scupd(void);
31extern void se_disp(struct s_entry *ep, int16_t sd, struct gdsel *gdstb[], int16_t cf);
32extern void settmpo(int16_t val);
33
34extern uint16_t *obj8;
35extern uint16_t curintp;
36
37extern int16_t ctrsw;
38extern int16_t curasg;
39extern int16_t curtun;
40extern int16_t tmpoval;
41extern int16_t recsw;
42extern int16_t stccol;
43
44extern int8_t dspbuf[];
45
46extern struct gdsel *gdstbc[];
47
48/*
49
50*/
51
52/*
53 =============================================================================
54 Assignment table field handlers
55 =============================================================================
56*/
57
58/*
59 =============================================================================
60 et_ioas() -- load edit buffer
61 =============================================================================
62*/
63
64int16_t et_ioas(int16_t n)
65{
66 sprintf(ebuf, "%02.2d", curasg);
67 ebflag = TRUE;
68
69 return(SUCCESS);
70}
71
72/*
73
74*/
75/*
76 =============================================================================
77 ef_ioas() -- parse edit buffer
78 =============================================================================
79*/
80
81int16_t ef_ioas(int16_t n)
82{
83 register int16_t ival;
84 register struct s_entry *ep;
85
86 ebuf[2] = '\0';
87 ival = ((ebuf[0] - '0') * 10) + (ebuf[1] - '0');
88
89 ebflag = FALSE;
90
91 if (ival GE NASGS)
92 return(FAILURE);
93
94 getasg(curasg = ival);
95 mpcupd();
96
97 if (recsw) {
98
99 if (E_NULL NE (ep = findev(p_cur, t_cur, EV_ASGN, -1, -1))) {
100
101 ep->e_data1 = ival;
102
103 } else if (E_NULL NE (ep = e_alc(E_SIZE2))) {
104
105 ep->e_type = EV_ASGN;
106 ep->e_data1 = ival;
107 ep->e_time = t_cur;
108 p_cur = e_ins(ep, ep_adj(p_cur, 0, t_cur))->e_fwd;
109 eh_ins(ep, EH_ASGN);
110 ctrsw = TRUE;
111 se_disp(ep, D_FWD, gdstbc, 1);
112 scupd();
113 }
114 }
115
116 return(SUCCESS);
117}
118
119/*
120
121*/
122
123/*
124 =============================================================================
125 rd_ioas() -- (re)display the field
126 =============================================================================
127*/
128
129int16_t rd_ioas(int16_t n)
130{
131 sprintf(dspbuf, "%02.2d", curasg);
132
133 if (v_regs[5] & 0x0180)
134 vbank(0);
135
136 vputs(obj8, 1, 11, dspbuf, SDW04ATR);
137 return(SUCCESS);
138}
139
140/*
141 =============================================================================
142 nd_ioas() -- data entry function
143 =============================================================================
144*/
145
146int16_t nd_ioas(int16_t n, int16_t k)
147{
148 register int16_t ec;
149
150 ec = stccol - cfetp->flcol;
151 ebuf[ec] = k + '0';
152
153 if (v_regs[5] & 0x0180)
154 vbank(0);
155
156 vputc(obj8, 1, stccol, k + '0', SDW04DEA);
157 advscur();
158 return(SUCCESS);
159}
160
161/*
162
163*/
164
165/*
166 =============================================================================
167 Tuning field handlers
168 =============================================================================
169*/
170
171/*
172 =============================================================================
173 et_tune() -- load edit buffer
174 =============================================================================
175*/
176
177int16_t et_tune(int16_t n)
178{
179 ebuf[0] = '0' + curtun;
180 ebuf[1] = '\0';
181 ebflag = TRUE;
182 return(SUCCESS);
183}
184
185/*
186
187*/
188
189/*
190 =============================================================================
191 ef_tune() -- parse edit buffer
192 =============================================================================
193*/
194
195int16_t ef_tune(int16_t n)
196{
197 register int16_t ival;
198 register struct s_entry *ep;
199
200 ebuf[1] = '\0';
201 ival = ebuf[0] - '0';
202 ebflag = FALSE;
203 gettun(ival);
204
205 if (recsw) {
206
207 if (E_NULL NE (ep = findev(p_cur, t_cur, EV_TUNE, -1, -1))) {
208
209 ep->e_data1 = ival;
210
211 } else if (E_NULL NE (ep = e_alc(E_SIZE2))) {
212
213 ep->e_type = EV_TUNE;
214 ep->e_data1 = ival;
215 ep->e_time = t_cur;
216 p_cur = e_ins(ep, ep_adj(p_cur, 0, t_cur))->e_fwd;
217 eh_ins(ep, EH_TUNE);
218 ctrsw = TRUE;
219 se_disp(ep, D_FWD, gdstbc, 1);
220 scupd();
221 }
222 }
223
224 return(SUCCESS);
225}
226
227/*
228
229*/
230
231/*
232 =============================================================================
233 rd_tune() -- (re)display the field
234 =============================================================================
235*/
236
237int16_t rd_tune(int16_t n)
238{
239 if (v_regs[5] & 0x0180)
240 vbank(0);
241
242 vputc(obj8, 1, 19, curtun + '0', SDW05ATR);
243
244 return(SUCCESS);
245}
246
247/*
248 =============================================================================
249 nd_tune() -- data entry function
250 =============================================================================
251*/
252
253int16_t nd_tune(int16_t n, int16_t k)
254{
255 register int16_t ec;
256
257 ebuf[0] = k + '0';
258
259 if (v_regs[5] & 0x0180)
260 vbank(0);
261
262 vputc(obj8, 1, stccol, k + '0', SDW05DEA);
263
264 return(SUCCESS);
265}
266
267/*
268
269*/
270
271/*
272 =============================================================================
273 Tempo field handlers
274 =============================================================================
275*/
276
277/*
278 =============================================================================
279 et_tmpo() -- load edit buffer
280 =============================================================================
281*/
282
283int16_t et_tmpo(int16_t n)
284{
285 sprintf(ebuf, "%03.3d", tmpoval);
286 ebflag = TRUE;
287
288 return(SUCCESS);
289}
290
291/*
292
293*/
294
295/*
296 =============================================================================
297 ef_tmpo() -- parse edit buffer
298 =============================================================================
299*/
300
301int16_t ef_tmpo(int16_t n)
302{
303 register int16_t ival;
304 register struct s_entry *ep;
305
306 ebuf[3] = '\0';
307 ival = ((ebuf[0] - '0') * 100) + ((ebuf[1] - '0') * 10)
308 + (ebuf[2] - '0');
309
310 ebflag = FALSE;
311
312 if ((ival GT 240) OR (ival LT 4))
313 return(FAILURE);
314
315 settmpo(ival);
316
317 if (recsw) {
318
319 if (E_NULL NE (ep = findev(p_cur, t_cur, EV_TMPO, -1, -1))) {
320
321 ep->e_data1 = ival;
322
323 } else if (E_NULL NE (ep = e_alc(E_SIZE2))) {
324
325 ep->e_type = EV_TMPO;
326 ep->e_data1 = ival;
327 ep->e_time = t_cur;
328 p_cur = e_ins(ep, ep_adj(p_cur, 0, t_cur))->e_fwd;
329 eh_ins(ep, EH_TMPO);
330 ctrsw = TRUE;
331 se_disp(ep, D_FWD, gdstbc, 1);
332 scupd();
333 }
334 }
335
336 return(SUCCESS);
337}
338
339/*
340
341*/
342
343/*
344 =============================================================================
345 rd_tmpo() -- (re)display the field
346 =============================================================================
347*/
348
349int16_t rd_tmpo(int16_t n)
350{
351 sprintf(dspbuf, "%03.3d", tmpoval);
352
353 if (v_regs[5] & 0x0180)
354 vbank(0);
355
356 vputs(obj8, 1, 27, dspbuf, SDW06ATR);
357
358 return(SUCCESS);
359}
360
361/*
362 =============================================================================
363 nd_tmpo() -- data entry function
364 =============================================================================
365*/
366
367int16_t nd_tmpo(int16_t n, int16_t k)
368{
369 register int16_t ec;
370
371 ec = stccol - cfetp->flcol;
372 ebuf[ec] = k + '0';
373
374 if (v_regs[5] & 0x0180)
375 vbank(0);
376
377 vputc(obj8, 1, stccol, k + '0', SDW06DEA);
378 advscur();
379
380 return(SUCCESS);
381}
382
383/*
384
385*/
386
387/*
388 =============================================================================
389 Interpolate field handlers
390 =============================================================================
391*/
392
393/*
394 =============================================================================
395 et_intp() -- load edit buffer
396 =============================================================================
397*/
398
399int16_t et_intp(int16_t n)
400{
401 register int16_t th, tl;
402 register int32_t tt, sc, sf;
403
404 sc = 1000L;
405 sf = 100L;
406 tt = fromfpu(curintp);
407 th = tt / sc;
408 tl = (tt - (th * sc)) / sf;
409
410 sprintf(ebuf, "%02d.%d", th, tl);
411 ebflag = TRUE;
412
413 return(SUCCESS);
414}
415
416/*
417 =============================================================================
418 ef_intp() -- parse edit buffer
419 =============================================================================
420*/
421
422int16_t ef_intp(int16_t n)
423{
424 register int16_t i;
425 register uint16_t tmpval;
426 register struct s_entry *ep;
427
428 ebuf[2] = '.'; /* add implied decimal point */
429 ebuf[4] = '\0'; /* terminate the string in ebuf */
430 ebflag = FALSE;
431 tmpval = 0;
432
433 for (i = 0; i < 2; i++) /* convert from ASCII to binary */
434 tmpval = (tmpval * 10) + (ebuf[i] - '0');
435
436 tmpval = ((tmpval * 10) + (ebuf[3] - '0')) * 100;
437
438 if (tmpval > (uint16_t)64900)
439 return(FAILURE);
440
441 if (tmpval EQ 0)
442 tmpval = 1;
443
444 curintp = tofpu(tmpval);
445
446 if (recsw) {
447
448 if (E_NULL NE (ep = findev(p_cur, t_cur, EV_INTP, -1, -1))) {
449
450 ep->e_data1 = (curintp >> 8);
451 ep->e_data2 = 0x00FF & curintp;
452
453 } else if (E_NULL NE (ep = e_alc(E_SIZE3))) {
454
455 ep->e_type = EV_INTP;
456 ep->e_time = t_cur;
457 ep->e_data1 = (curintp >> 8);
458 ep->e_data2 = 0x00FF & curintp;
459 p_cur = e_ins(ep, ep_adj(p_cur, 0, t_cur))->e_fwd;
460 eh_ins(ep, EH_INTP);
461 ctrsw = TRUE;
462 se_disp(ep, D_FWD, gdstbc, 1);
463 scupd();
464 }
465 }
466
467 return(SUCCESS);
468}
469
470/*
471
472*/
473
474/*
475 =============================================================================
476 rd_intp() -- (re)display the field
477 =============================================================================
478*/
479
480int16_t rd_intp(int16_t n)
481{
482 register int16_t th, tl;
483 register int32_t tt, sc, sf;
484
485 sc = 1000L;
486 sf = 100L;
487 tt = fromfpu(curintp);
488 th = tt / sc;
489 tl = (tt - (th * sc)) / sf;
490
491 sprintf(dspbuf, "%02d.%d", th, tl); /* convert to ASCII */
492
493 vbank(0); /* display the value */
494
495 vputs(obj8, 1, 35, dspbuf, SDW07ATR);
496
497 return(SUCCESS);
498}
499
500/*
501 =============================================================================
502 nd_intp() -- data entry function
503 =============================================================================
504*/
505
506int16_t nd_intp(int16_t n, int16_t k)
507{
508 register int16_t ec;
509
510 ec = stccol - cfetp->flcol; /* setup edit buffer column */
511
512 if (ec EQ 2)
513 return(FAILURE);
514
515 if ((ec EQ 0) AND (k > 6))
516 return(FAILURE);
517
518 if ((ec EQ 1) AND (ebuf[0] EQ '6') AND (k > 4))
519 return(FAILURE);
520
521 ebuf[ec] = k + '0';
522 ebuf[2] = '.';
523 ebuf[4] = '\0';
524
525 dspbuf[0] = k + '0';
526 dspbuf[1] = '\0';
527
528 vbank(0);
529
530 vputs(obj8, 1, stccol, dspbuf, SDW07DEA);
531
532 advscur();
533
534 if (stccol EQ 37)
535 advscur();
536
537 return(SUCCESS);
538}
Note: See TracBrowser for help on using the repository browser.