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