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

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

Removed form-feed comments.

  • Property mode set to 100644
File size: 6.6 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
83 buf[0] = key + '0';
84
85 } else if (col EQ 7) { /* port */
86
87 if ((key EQ 1) OR (key EQ 2)) { /* MIDI */
88
89 buf[0] = key + '0';
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
111 buf[0] = key + '0';
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
144 buf[0] = key + '0';
145 buf[1] = '\0';
146 sqdebuf[stccol] = key + '0';
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
189 buf[0] = key + '0';
190 buf[1] = '\0';
191 sqdebuf[stccol] = key + '0';
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
[f40a309]220 buf[0] = key + '0';
221 buf[1] = '\0';
222 sqdebuf[stccol] = key + '0';
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
253 buf[0] = key + '0';
254 buf[1] = '\0';
255 sqdebuf[stccol] = key + '0';
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
287 buf[0] = key + '0';
288 buf[1] = '\0';
289 sqdebuf[stccol] = key + '0';
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
312 buf[0] = key + '0';
313 buf[1] = '\0';
314 sqdebuf[stccol] = key + '0';
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
343 if (NOT astat) /* only do this on key closures */
344 return;
345
346 if (NOT sqdeflg) /* load up the edit buffer */
347 seq2buf();
348
349 key = asig - 60;
350
351 if (inrange(stccol, 2, 4)) { /* line */
352
353 buf[0] = key + '0';
354 buf[1] = '\0';
355
356 sqdebuf[stccol] = key + '0';
357
358 UpdVid(7, stccol, buf, PTDATR);
359
360 if (stccol EQ 4)
361 ctcon();
362 else
363 movestc(stcrow, ++stccol);
364
365 return;
[fa38804]366
[f40a309]367 } else if (inrange(stccol, 6, 10)) { /* time */
368
369 if (stccol EQ 8)
370 return;
371
372 buf[0] = key + '0';
373 buf[1] = '\0';
374
375 sqdebuf[stccol] = key + '0';
376
377 UpdVid(7, stccol, buf, PTDATR);
378
379 if (stccol EQ 7)
380 ++stccol;
381
382 if (stccol EQ 10)
383 ctcon();
384 else
385 movestc(stcrow, ++stccol);
386
387 return;
388
389 } else if (inrange(stccol, 12, 22)) { /* action 1 */
390
391 action = 0;
392 sqactde(key);
393 return;
394
395 } else if (inrange(stccol, 24, 34)) { /* action 2 */
396
397 action = 1;
398 sqactde(key);
399 return;
400
401 } else if (inrange(stccol, 36, 46)) { /* action 3 */
402
403 action = 2;
404 sqactde(key);
405 return;
406 }
407}
[6262b5c]408
Note: See TracBrowser for help on using the repository browser.