source: buchla-68k/ram/etiact.c@ 7258c6a

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

Use standard integer types.

  • Property mode set to 100644
File size: 7.5 KB
Line 
1/*
2 =============================================================================
3 etiact.c -- point action field handlers
4 Version 16 -- 1988-08-31 -- D.N. Lynx Crowe
5 =============================================================================
6*/
7
8#define DEBUGIT 0
9
10#include "stddefs.h"
11#include "fields.h"
12#include "vsdd.h"
13#include "vsddsw.h"
14#include "graphdef.h"
15#include "charset.h"
16
17#include "midas.h"
18#include "instdsp.h"
19
20/* functions defined elsewhere */
21
22extern void advicur(void);
23
24extern int8_t *strcpy(int8_t *s1, int8_t *s2);
25
26/* variables defined elsewhere */
27
28extern int16_t stcrow, stccol, curvce, curpnt, curfunc;
29extern int16_t debugsw;
30
31extern int16_t idbox[][8];
32
33extern uint16_t *instob;
34
35extern int8_t dspbuf[];
36
37extern struct instdef vbufs[];
38
39extern int16_t aform;
40
41/*
42
43*/
44
45/*
46 =============================================================================
47 et_iact() -- load edit buffer
48 =============================================================================
49*/
50
51int16_t et_iact(int16_t nn)
52{
53 register struct instpnt *pp;
54
55 pp = &vbufs[curvce].idhpnt[curpnt];
56
57 aform = pp->ipact;
58
59 switch (aform) {
60
61 case AC_NULL:
62 case AC_SUST:
63 case AC_ENBL:
64 case AC_UNDF:
65
66 ebuf[0] = '\0';
67 break;
68
69 case AC_JUMP:
70 case AC_KYUP:
71 case AC_KYDN:
72
73 sprintf(ebuf, "%02d", pp->ippar1);
74 break;
75
76 case AC_LOOP:
77
78 sprintf(ebuf, "%02d %02d", pp->ippar1, pp->ippar2);
79 break;
80 }
81
82#if DEBUGIT
83 if (debugsw)
84 printf("et_iact(): aform=%d, ebuf=[%s]\r\n", aform, ebuf);
85#endif
86
87 ebflag = TRUE;
88 return(SUCCESS);
89}
90
91/*
92
93*/
94
95/*
96 =============================================================================
97 ef_iact() -- unload (parse) edit buffer
98 =============================================================================
99*/
100
101int16_t ef_iact(int16_t nn)
102{
103 register int16_t i, tmp1, tmp2;
104 register struct instpnt *pp;
105 register struct idfnhdr *fp;
106
107 fp = &vbufs[curvce].idhfnc[curfunc];
108 pp = &vbufs[curvce].idhpnt[curpnt];
109 ebflag = FALSE;
110
111#if DEBUGIT
112 if (debugsw)
113 printf("ef_iact(): aform=%d, fp=$%08lX, pp=$%08lX\r\n",
114 aform, fp, pp);
115#endif
116
117 switch (aform) {
118
119 case AC_NULL:
120 case AC_UNDF:
121
122 aform = AC_NULL;
123
124 case AC_SUST:
125 case AC_ENBL:
126
127 pp->ipact = aform;
128
129#if DEBUGIT
130 if (debugsw)
131 printf("ef_iact(): aform=%d, ipact=%d, ippar1=%d, ippar2=%d\r\n",
132 aform, pp->ipact, pp->ippar1, pp->ippar2);
133#endif
134
135 modinst();
136 return(SUCCESS);
137
138 case AC_JUMP:
139 case AC_KYUP:
140 case AC_KYDN:
141
142 tmp1 = 0;
143
144 for (i = 0; i < 2; i++)
145 tmp1 = (tmp1 * 10) + (ebuf[i] - '0');
146
147 if (tmp1 GE fp->idfpif)
148 return(FAILURE);
149
150 pp->ipact = aform;
151 pp->ippar1 = tmp1;
152 pp->ippar2 = 0;
153 pp->ippar3 = 0;
154
155#if DEBUGIT
156 if (debugsw)
157 printf("ef_iact(): aform=%d, ipact=%d, ippar1=%d, ippar2=%d\r\n",
158 aform, pp->ipact, pp->ippar1, pp->ippar2);
159#endif
160
161 modinst();
162 return(SUCCESS);
163/*
164
165*/
166 case AC_LOOP:
167
168 tmp1 = 0;
169
170 for (i = 0; i < 2; i++)
171 tmp1 = (tmp1 * 10) + (ebuf[i] - '0');
172
173 if (tmp1 GE fp->idfpif)
174 return(FAILURE);
175
176 tmp2 = 0;
177
178 for (i = 3; i < 5; i++)
179 tmp2 = (tmp2 * 10) + (ebuf[i] - '0');
180
181 pp->ipact = aform;
182 pp->ippar1 = tmp1;
183 pp->ippar2 = tmp2;
184 pp->ippar3 = 0;
185
186#if DEBUGIT
187 if (debugsw)
188 printf("ef_iact(): aform=%d, ipact=%d, ippar1=%d, ippar2=%d\r\n",
189 aform, pp->ipact, pp->ippar1, pp->ippar2);
190#endif
191
192 modinst();
193 return(SUCCESS);
194 }
195
196 return(FAILURE);
197}
198
199/*
200
201*/
202
203/*
204 =============================================================================
205 rd_iact() -- (re)-display the field
206 =============================================================================
207*/
208
209int16_t rd_iact(int16_t nn)
210{
211 register int16_t pnt, par, n;
212 register struct instpnt *pp;
213 register int8_t *s1;
214
215 n = nn & 0x00FF;
216 pp = &vbufs[curvce].idhpnt[curpnt];
217 pnt = pp->ippar1;
218 par = pp->ippar2;
219 aform = pp->ipact;
220
221#if DEBUGIT
222 if (debugsw)
223 printf("rd_iact(): aform=%d, pp=$%08lX, pnt=%d, par=%d\r\n",
224 aform, pp, pnt, par);
225#endif
226
227 switch (aform) {
228
229 case AC_NULL:
230
231 s1 = " ";
232 break;
233
234 case AC_SUST:
235
236 sprintf(dspbuf, "Pause if key %c ", SP_DNA);
237 s1 = dspbuf;
238 break;
239
240 case AC_ENBL:
241
242 sprintf(dspbuf, "Stop if key %c ", SP_UPA);
243 s1 = dspbuf;
244 break;
245
246 case AC_JUMP:
247
248 sprintf(dspbuf, "GoTo %02d forever ", pnt);
249 s1 = dspbuf;
250 break;
251
252/*
253
254*/
255 case AC_LOOP:
256
257 sprintf(dspbuf, "GoTo %02d %02d times", pnt, par);
258
259 if (dspbuf[8] EQ '9')
260 dspbuf[8] = 'R';
261
262 s1 = dspbuf;
263 break;
264
265 case AC_KYUP:
266
267 sprintf(dspbuf, "GoTo %02d if key %c", pnt, SP_UPA);
268 s1 = dspbuf;
269 break;
270
271 case AC_KYDN:
272
273 sprintf(dspbuf, "GoTo %02d if key %c", pnt, SP_DNA);
274 s1 = dspbuf;
275 break;
276
277 default:
278
279 s1 = "????????????????";
280 break;
281 }
282
283 vbank(0);
284 vcputsv(instob, 64, idbox[n][4], idbox[n][5],
285 idbox[n][6] + 1, idbox[n][7], s1, 14);
286
287 return(SUCCESS);
288}
289
290/*
291
292*/
293
294/*
295 =============================================================================
296 setactb() -- set action field data entry buffer format
297 =============================================================================
298*/
299
300void setactb(int16_t n)
301{
302 register int8_t *s1;
303
304 switch (aform) {
305
306 case AC_NULL:
307
308 s1 = " ";
309 ebuf[0] = '\0';
310 break;
311
312 case AC_SUST:
313
314 sprintf(dspbuf, "Pause if key %c ", SP_DNA);
315 s1 = dspbuf;
316 ebuf[0] = '\0';
317 break;
318
319 case AC_ENBL:
320
321 sprintf(dspbuf, "Stop if key %c ", SP_UPA);
322 s1 = dspbuf;
323 ebuf[0] = '\0';
324 break;
325
326 case AC_JUMP:
327
328 s1 = "GoTo 00 forever ";
329 ebuf[0] = '0';
330 ebuf[1] = '0';
331 ebuf[2] = '\0';
332 break;
333
334/*
335
336*/
337 case AC_LOOP:
338
339 s1 = "GoTo 00 00 times";
340 ebuf[0] = '0';
341 ebuf[1] = '0';
342 ebuf[2] = ' ';
343 ebuf[3] = '0';
344 ebuf[4] = '0';
345 ebuf[5] = '\0';
346 break;
347
348 case AC_KYUP:
349
350 sprintf(dspbuf, "GoTo 00 if key %c", SP_UPA);
351 s1 = dspbuf;
352 ebuf[0] = '0';
353 ebuf[1] = '0';
354 ebuf[2] = '\0';
355 break;
356
357 case AC_KYDN:
358
359 sprintf(dspbuf, "GoTo 00 if key %c", SP_DNA);
360 s1 = dspbuf;
361 ebuf[0] = '0';
362 ebuf[1] = '0';
363 ebuf[2] = '\0';
364 break;
365
366 default:
367
368 s1 = "????????????????";
369 ebuf[0] = '\0';
370 break;
371 }
372
373 vbank(0);
374 vcputsv(instob, 64, ID_ENTRY, idbox[n][5],
375 idbox[n][6] + 1, idbox[n][7], s1, 14);
376}
377
378/*
379
380*/
381
382/*
383 =============================================================================
384 nd_iact() -- process new data entry
385 =============================================================================
386*/
387
388int16_t nd_iact(int16_t nn, int16_t k)
389{
390 register int16_t n, ec;
391
392 n = nn & 0xFF;
393
394 if (stccol LT (idbox[n][7] + 5)) {
395
396 if (k EQ 8) {
397
398 if (--aform < 0)
399 aform = AC_KYDN;
400
401 setactb(n);
402 return(SUCCESS);
403
404 } else if (k EQ 9) {
405
406 if (++aform > AC_KYDN)
407 aform = AC_NULL;
408
409 setactb(n);
410 return(SUCCESS);
411 }
412
413 return(FAILURE);
414
415/*
416
417*/
418 } else {
419
420 switch (aform) {
421
422 case AC_NULL:
423 case AC_UNDF:
424 case AC_ENBL:
425 case AC_SUST:
426
427 return(FAILURE);
428
429 case AC_KYUP:
430 case AC_KYDN:
431 case AC_JUMP:
432
433 if ((stccol EQ (idbox[n][7] + 5)) OR
434 (stccol EQ (idbox[n][7] + 6))) {
435
436 ebuf[stccol - (idbox[n][7] + 5)] = k + '0';
437 dspbuf[0] = k + '0';
438 dspbuf[1] = '\0';
439
440 vbank(0);
441 vcputsv(instob, 64, ID_ENTRY, idbox[n][5],
442 stcrow, stccol, dspbuf, 14);
443
444 advicur();
445 return(SUCCESS);
446
447 } else {
448
449 return(FAILURE);
450 }
451/*
452
453*/
454 case AC_LOOP:
455
456 if ((stccol GE (idbox[n][7] + 5)) AND
457 (stccol LE (idbox[n][7] + 9))) {
458
459 ec = stccol - (idbox[n][7] + 5);
460
461 if (ec EQ 2)
462 return(FAILURE);
463
464 ebuf[ec] = k + '0';
465 dspbuf[0] = k + '0';
466 dspbuf[1] = '\0';
467
468 if ((ec EQ 3) AND (k EQ 9))
469 dspbuf[0] = 'R';
470
471 vbank(0);
472 vcputsv(instob, 64, ID_ENTRY, idbox[n][5],
473 stcrow, stccol, dspbuf, 14);
474
475 advicur();
476
477 if (ec EQ 1)
478 advicur();
479
480 return(SUCCESS);
481
482 } else {
483
484 return(FAILURE);
485 }
486 }
487
488 return(FAILURE);
489 }
490}
Note: See TracBrowser for help on using the repository browser.