source: buchla-68k/ram/etiact.c

Last change on this file was 6d5247b, checked in by Thomas Lopatic <thomas@…>, 6 years ago

Fixed etiact.c.

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