source: buchla-68k/ram/sqdkey.c@ 7c0efb6

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

Fixed sqdkey.c.

  • Property mode set to 100644
File size: 6.8 KB
RevLine 
[f40a309]1/*
2 =============================================================================
3 sqdkey.c -- MIDAS-VII sequence display data entry functions
4 Version 8 -- 1988-11-22 -- D.N. Lynx Crowe
5 =============================================================================
6*/
7
[b28a12e]8#include "ram.h"
[f40a309]9
[7258c6a]10int16_t actfmt; /* action code format */
[f40a309]11
[7258c6a]12int8_t actlft[] = { 12, 24, 36 }; /* action field leftmost columns */
[f40a309]13
[7258c6a]14int8_t seqdfmt[] = { /* action data entry format by action */
[f40a309]15
16 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 0, 4, 0, 3
17};
18
19/*
20 =============================================================================
21 seq2buf() -- load the edit buffer from the current sequence line
22 =============================================================================
23*/
24
[0580615]25void seq2buf(void)
[f40a309]26{
27 memcpyw(&seqbuf, &seqtab[curslin], NSEQW);
28 dsqlin(sqdebuf, curslin);
29 sqdeflg = TRUE;
30}
31
32/*
33 =============================================================================
34 sqactde() -- sequence action digit data entry function
35 =============================================================================
36*/
37
[7258c6a]38void sqactde(int16_t key)
[f40a309]39{
[7258c6a]40 register int16_t col;
41 int16_t defmt;
42 uint16_t act, vtype;
43 int8_t buf[8];
[f40a309]44
45 col = stccol - actlft[action]; /* get field data entry column */
46
47 switch (action) { /* get action code from sequence entry */
48
49 case 0: /* action 1 */
50
51 act = seqbuf.seqact1;
52 vtype = SQ_MTYP & seqbuf.seqdat1;
53 break;
54
55 case 1: /* action 2 */
56
57 act = seqbuf.seqact2;
58 vtype = SQ_MTYP & seqbuf.seqdat2;
59 break;
60
61 case 2: /* action 3 */
62
63 act = seqbuf.seqact3;
64 vtype = SQ_MTYP & seqbuf.seqdat3;
65 break;
66
67 default: /* something weird got in here */
68
69 return;
70 }
71
72 defmt = seqdfmt[SQ_MACT & act]; /* get data entry format code */
[fa38804]73
[f40a309]74 switch (defmt) { /* switch off of data entry format */
75
76 case 1: /* key, port, chan */
77
78 if (inrange(col, 3, 5)) { /* key */
79
80 if ((col EQ 3) AND (key > 1))
81 return;
82
[3f2d518]83 buf[0] = (int8_t)(key + '0');
[f40a309]84
85 } else if (col EQ 7) { /* port */
86
87 if ((key EQ 1) OR (key EQ 2)) { /* MIDI */
88
[3f2d518]89 buf[0] = (int8_t)(key + '0');
[f40a309]90
91 UpdVid(7, stccol + 1, " 01", PTDATR);
92 memcpy(&sqdebuf[stccol + 1], " 01", 3);
93
94 } else if (key EQ 3) { /* local */
95
96 buf[0] = 'L';
97
98 UpdVid(7, stccol + 1, " ", PTDATR);
99 memset(&sqdebuf[stccol + 1], ' ', 3);
100
101 } else {
102
103 return;
104 }
105
106 } else if (inrange(col, 9, 10)) { /* channel */
107
108 if ((col EQ 9) AND (key > 1))
109 return;
110
[3f2d518]111 buf[0] = (int8_t)(key + '0');
[f40a309]112 }
113
114 buf[1] = '\0';
115 sqdebuf[stccol] = buf[0];
116
117 UpdVid(7, stccol, buf, PTDATR);
118
119 if ((col EQ 5) OR (col EQ 7)) { /* skip blanks */
120
121 ++stccol;
122 ++col;
123 }
124
125 if (col EQ 10)
126 ctcon();
127 else
128 movestc(stcrow, ++stccol);
129
130 return;
[fa38804]131
[f40a309]132 case 2: /* trigger */
133
134 if (inrange(col, 9, 10)) {
135
136 if ((col EQ 9) AND (key > 1))
137 return;
138
139 } else {
140
141 return;
142 }
143
[3f2d518]144 buf[0] = (int8_t)(key + '0');
[f40a309]145 buf[1] = '\0';
[3f2d518]146 sqdebuf[stccol] = (int8_t)(key + '0');
[f40a309]147
148 UpdVid(7, stccol, buf, PTDATR);
149
150 if (col EQ 10)
151 ctcon();
152 else
153 movestc(stcrow, ++stccol);
154
155 return;
[fa38804]156
[f40a309]157 case 3: /* register operations */
158
159 if ((col EQ 7) AND (act EQ SQ_AREG)) {
160
161 if (key EQ 8) /* - */
162 buf[0] = '-';
163 else if (key EQ 9) /* + */
164 buf[0] = '+';
165 else
166 return;
167
168 buf[1] = '\0';
169 sqdebuf[stccol] = buf[0];
170 UpdVid(7, stccol, buf, PTDATR);
171 movestc(stcrow, ++stccol);
172 return;
173 }
174
175 switch (vtype) {
176
177 case SQ_REG: /* register contents */
178
179 if (inrange(col, 5, 6) OR inrange(col, 9, 10)) {
180
181 if ( ((col EQ 5) OR (col EQ 9)) AND (key > 1) )
182 return;
183
184 } else {
185
186 return;
187 }
188
[3f2d518]189 buf[0] = (int8_t)(key + '0');
[f40a309]190 buf[1] = '\0';
[3f2d518]191 sqdebuf[stccol] = (int8_t)(key + '0');
[f40a309]192
193 UpdVid(7, stccol, buf, PTDATR);
194
195 if (col EQ 6) {
196
197 col += 2;
198 stccol += 2;
199 }
200
201 if (col EQ 10)
202 ctcon();
203 else
204 movestc(stcrow, ++stccol);
205
206 return;
[fa38804]207
[f40a309]208 case SQ_VAL: /* constant value */
209
210 if (inrange(col, 5, 6) OR inrange(col, 8, 9)) {
211
212 if ((col EQ 5) AND (key > 1))
213 return;
214
215 } else {
216
217 return;
218 }
[9519422]219
[3f2d518]220 buf[0] = (int8_t)(key + '0');
[f40a309]221 buf[1] = '\0';
[3f2d518]222 sqdebuf[stccol] = (int8_t)(key + '0');
[f40a309]223
224 UpdVid(7, stccol, buf, PTDATR);
225
226 if (col EQ 6) {
227
228 ++col;
229 ++stccol;
230 }
231
232 if (col EQ 9)
233 ctcon();
234 else
235 movestc(stcrow, ++stccol);
236
237 return;
[fa38804]238
[f40a309]239 case SQ_VLT: /* voltage input */
240
241 if (inrange(col, 5, 6) OR (col EQ 9)) {
242
243 if ((col EQ 5) AND (key > 1))
244 return;
245 else if ( (col EQ 9) AND ((key < 1) OR (key > 4)) )
246 return;
247
248 } else {
249
250 return;
251 }
252
[3f2d518]253 buf[0] = (int8_t)(key + '0');
[f40a309]254 buf[1] = '\0';
[3f2d518]255 sqdebuf[stccol] = (int8_t)(key + '0');
[f40a309]256
257 UpdVid(7, stccol, buf, PTDATR);
258
259 if (col EQ 6) {
260
261 col += 2;
262 stccol += 2;
263 }
264
265 if (col EQ 9)
266 ctcon();
267 else
268 movestc(stcrow, ++stccol);
269
270 return;
[fa38804]271
[f40a309]272 case SQ_RND: /* random value */
273
274 if (inrange(col, 5, 6) OR (col EQ 9)) {
275
276 if ((col EQ 5) AND (key > 1))
277 return;
278
279 if ((col EQ 9) AND (key > 6))
280 return;
281
282 } else {
283
284 return;
285 }
286
[3f2d518]287 buf[0] = (int8_t)(key + '0');
[f40a309]288 buf[1] = '\0';
[3f2d518]289 sqdebuf[stccol] = (int8_t)(key + '0');
[f40a309]290
291 UpdVid(7, stccol, buf, PTDATR);
292
293 if (col EQ 6) {
294
295 col += 2;
296 stccol += 2;
297 }
298
299 if (col EQ 9)
300 ctcon();
301 else
302 movestc(stcrow, ++stccol);
303
304 return;
305 }
[fa38804]306
[f40a309]307 case 4: /* sequence line */
308
309 if (inrange(col, 0, 7))
310 return;
311
[3f2d518]312 buf[0] = (int8_t)(key + '0');
[f40a309]313 buf[1] = '\0';
[3f2d518]314 sqdebuf[stccol] = (int8_t)(key + '0');
[f40a309]315
316 UpdVid(7, stccol, buf, PTDATR);
317
318 if (col EQ 10)
319 ctcon();
320 else
321 movestc(stcrow, ++stccol);
322
323 return;
324
325 case 0: /* -none- */
326 default:
327
328 return;
329 }
330}
331
332/*
333 =============================================================================
334 sqdkey() -- sequence digit data entry control function
335 =============================================================================
336*/
337
[7258c6a]338void sqdkey(int16_t k)
[f40a309]339{
[7258c6a]340 register int16_t key;
341 int8_t buf[8];
[f40a309]342
[7ecfb7b]343 (void)k;
344
[f40a309]345 if (NOT astat) /* only do this on key closures */
346 return;
347
348 if (NOT sqdeflg) /* load up the edit buffer */
349 seq2buf();
350
351 key = asig - 60;
352
353 if (inrange(stccol, 2, 4)) { /* line */
354
[3f2d518]355 buf[0] = (int8_t)(key + '0');
[f40a309]356 buf[1] = '\0';
357
[3f2d518]358 sqdebuf[stccol] = (int8_t)(key + '0');
[f40a309]359
360 UpdVid(7, stccol, buf, PTDATR);
361
362 if (stccol EQ 4)
363 ctcon();
364 else
365 movestc(stcrow, ++stccol);
366
367 return;
[fa38804]368
[f40a309]369 } else if (inrange(stccol, 6, 10)) { /* time */
370
371 if (stccol EQ 8)
372 return;
373
[3f2d518]374 buf[0] = (int8_t)(key + '0');
[f40a309]375 buf[1] = '\0';
376
[3f2d518]377 sqdebuf[stccol] = (int8_t)(key + '0');
[f40a309]378
379 UpdVid(7, stccol, buf, PTDATR);
380
381 if (stccol EQ 7)
382 ++stccol;
383
384 if (stccol EQ 10)
385 ctcon();
386 else
387 movestc(stcrow, ++stccol);
388
389 return;
390
391 } else if (inrange(stccol, 12, 22)) { /* action 1 */
392
393 action = 0;
394 sqactde(key);
395 return;
396
397 } else if (inrange(stccol, 24, 34)) { /* action 2 */
398
399 action = 1;
400 sqactde(key);
401 return;
402
403 } else if (inrange(stccol, 36, 46)) { /* action 3 */
404
405 action = 2;
406 sqactde(key);
407 return;
408 }
409}
[6262b5c]410
Note: See TracBrowser for help on using the repository browser.