source: buchla-68k/ram/etres1.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.7 KB
RevLine 
[f40a309]1/*
2 =============================================================================
3 etres1.c -- analog variable field handlers
4 Version 16 -- 1988-06-28 -- D.N. Lynx Crowe
5 =============================================================================
6*/
7
8#include "stddefs.h"
9#include "fields.h"
10#include "smdefs.h"
11#include "hwdefs.h"
12#include "graphdef.h"
13#include "vsdd.h"
14#include "vsddsw.h"
15#include "score.h"
16#include "scfns.h"
17#include "macros.h"
18
19#include "midas.h"
20#include "scdsp.h"
21
[e225e77]22#include "stdio.h"
23
24extern void advscur(void);
25extern void ds_anmd(void);
26extern void ds_anrs(void);
27extern void ds_anvl(void);
28extern void scupd(void);
29extern void se_disp(struct s_entry *ep, int16_t sd, struct gdsel *gdstb[], int16_t cf);
30extern void setsv(int16_t grp, int16_t src, int16_t ival);
31
[7258c6a]32extern int16_t ancmsw;
33extern int16_t angroup;
34extern int16_t ctrsw;
35extern int16_t recsw;
36extern int16_t stccol;
[f40a309]37
[7258c6a]38extern uint16_t *obj8;
[f40a309]39
[7258c6a]40extern int16_t anrs[8][16];
41extern int16_t grpmode[12];
42extern int16_t grpstat[12];
43extern int16_t var2src[6];
44extern int16_t varmode[8][16];
[f40a309]45
46extern struct gdsel *gdstbc[];
47extern struct valent valents[];
48
49/*
50 =============================================================================
51 et_res1() -- load edit buffer
52 =============================================================================
53*/
54
[7258c6a]55int16_t et_res1(int16_t n)
[f40a309]56{
57 ebuf[0] = anrs[n][abs(angroup)-1];
58 ebflag = TRUE;
59 return(SUCCESS);
60}
61
62/*
63
64*/
65
66/*
67 =============================================================================
68 ef_res1() -- parse edit buffer
69 =============================================================================
70*/
[7258c6a]71
[f40a309]72int16_t ef_res1(int16_t n)
[7258c6a]73{
[f40a309]74 register int16_t ival, grp, vg;
75 register struct s_entry *ep;
76
77 ebflag = FALSE;
78 grp = abs(angroup)-1;
79 ival = ebuf[0] & 0x00FF;
80
81 if ((ival < 3) OR (ival > 8))
82 return(FAILURE);
83
84 anrs[n][grp] = ival;
85
86 if (recsw AND grpstat[grp] AND
87 (2 EQ (ancmsw ? varmode[n][grp] : grpmode[grp]))) {
88
89 vg = ((n << 4) | grp);
90
91 if (E_NULL NE (ep = findev(p_cur, t_cur, EV_ANRS, vg, -1))) {
92
93 ep->e_data2 = ival;
94
95 } else if (E_NULL NE (ep = e_alc(E_SIZE2))) {
96
97 ep->e_type = EV_ANRS;
98 ep->e_data1 = vg;
99 ep->e_data2 = ival;
100 ep->e_time = t_cur;
101 p_cur = e_ins(ep, ep_adj(p_cur, 0, t_cur))->e_fwd;
102 eh_ins(ep, EH_ANRS);
103 ctrsw = TRUE;
104 se_disp(ep, D_FWD, gdstbc, 1);
105 scupd();
106 }
107 }
108
109 return(SUCCESS);
110}
111
112/*
113
114*/
115
116/*
117 =============================================================================
118 rd_res1() -- (re)display the field
119 =============================================================================
[7258c6a]120*/
[f40a309]121
[7258c6a]122int16_t rd_res1(int16_t n)
[f40a309]123{
124 register int16_t grp, chr;
125
126 grp = abs(angroup) - 1;
127
128 chr = anrs[n][grp] + '0';
129
130 if (v_regs[5] & 0x0180)
131 vbank(0);
132
133 vputc(obj8, 7, 6 + (n * 9), chr, SDW12ATR);
134
135 return(SUCCESS);
136}
137
138/*
139
140*/
141
142/*
143 =============================================================================
144 nd_res1() -- data entry function
[7258c6a]145 =============================================================================
[f40a309]146*/
147
148int16_t nd_res1(int16_t n, int16_t k)
149{
150 ebuf[0] = k;
151
152 if (v_regs[5] & 0x0180)
153 vbank(0);
154
155 vputc(obj8, 7, stccol, k + '0', SDW12DEA);
156
157 return(SUCCESS);
158}
159
160/*
161
162*/
163
164/*
165 =============================================================================
[7258c6a]166 et_aval() -- load edit buffer
[f40a309]167 =============================================================================
[7258c6a]168*/
169
[f40a309]170int16_t et_aval(int16_t n)
171{
172 register int16_t val, grp, gs;
173 int16_t val1, val2, val3;
174
175 grp = abs(angroup) - 1;
176 gs = (grp << 4) | var2src[n];
177 val = (valents[gs].val) >> 5;
178
179 if (val < 0 ) {
180
181 ebuf[0] = 8;
182 val = -val;
183
184 } else {
185
186 ebuf[0] = 9;
187 }
188
189 val1 = val / 100;
190 ebuf[4] = (val - (val1 * 100)) / 10;
191 val2 = val1 / 10;
192 ebuf[2] = val1 - (val2 * 10);
193 ebuf[1] = val2;
194
195 ebflag = TRUE;
196
197 return(SUCCESS);
198}
199
200/*
201
202*/
203
204/*
[7258c6a]205 =============================================================================
[f40a309]206 ef_res1() -- parse edit buffer
[7258c6a]207 =============================================================================
[f40a309]208*/
209
210int16_t ef_aval(int16_t n)
211{
212 register int16_t val, grp, src, vg;
213 register struct s_entry *ep;
214
215 ebflag = FALSE;
216 grp = abs(angroup) - 1;
217 src = var2src[n];
218 val = ((ebuf[1] * 100) + (ebuf[2] * 10) + ebuf[4]) * 10;
219
220 if (val > 1000)
221 return(FAILURE);
222
223 if (ebuf[0] EQ 8)
224 val = -val;
225
226 val = val << 5;
227
228 setsv(grp, src, val);
229
230 if (recsw AND grpstat[grp] AND
231 (2 EQ (ancmsw ? varmode[n][grp] : grpmode[grp]))) {
[7258c6a]232
[f40a309]233 vg = (n << 4) | grp;
234
235 if (E_NULL NE (ep = findev(p_cur, t_cur, EV_ANVL, vg, -1))) {
236
237 ep->e_dn = (struct s_entry *)((int32_t)val << 16);
[7258c6a]238
[f40a309]239 } else if (E_NULL NE (ep = e_alc(E_SIZE2))) {
240
241 ep->e_type = EV_ANVL;
242 ep->e_data1 = vg;
243 ep->e_dn = (struct s_entry *)((int32_t)val << 16);
244 ep->e_time = t_cur;
245 p_cur = e_ins(ep, ep_adj(p_cur, 0, t_cur))->e_fwd;
246 ctrsw = TRUE;
247 se_disp(ep, D_FWD, gdstbc, 1);
248 scupd();
249 }
250 }
251
252 return(SUCCESS);
253}
254
255/*
256
257*/
258
[7258c6a]259/*
[f40a309]260 =============================================================================
[7258c6a]261 rd_aval() -- (re)display the field
262 =============================================================================
263*/
[f40a309]264
265int16_t rd_aval(int16_t n)
266{
267 register int16_t grp, val, gs;
268 int16_t val1, val2;
269 int8_t buf[6];
270
271 grp = abs(angroup) - 1;
272 gs = (grp << 4) | var2src[n];
273 val = (valents[gs].val) >> 5;
274
275 if (val < 0) {
276
277 buf[0] = '-';
278 val = -val;
279
280 } else {
281
282 buf[0] = '+';
283 }
284
285 val1 = val / 100;
286 buf[4] = '0' + ((val - (val1 * 100)) / 10);
287 val2 = val1 / 10;
288 buf[2] = '0' + (val1 - (val2 * 10));
289 buf[1] = '0' + val2;
290 buf[3] = '.';
291 buf[5] = '\0';
292
293 if (v_regs[5] & 0x0180)
294 vbank(0);
295
296 vputs(obj8, 7, 8 + (n * 9), buf, SDW12ATR);
297
298 return(SUCCESS);
299}
300
301/*
302
303*/
[7258c6a]304
[f40a309]305/*
[7258c6a]306 =============================================================================
[f40a309]307 nd_aval() -- data entry function
308 =============================================================================
309*/
310
311int16_t nd_aval(int16_t n, int16_t k)
312{
313 register int16_t ec;
314
315 ec = stccol - cfetp->flcol;
316
317 if (ec EQ 3)
318 return(FAILURE);
319
320 ebuf[ec] = k;
321
322 if (ec EQ 0)
323 k = (k EQ 8) ? '-' : '+';
324 else
325 k += '0';
326
327 if (v_regs[5] & 0x0180)
328 vbank(0);
329
330 vputc(obj8, 7, stccol, k, SDW12DEA);
331
332 if (ec EQ 4)
333 return(SUCCESS);
334
335 advscur();
336
337 if (ec EQ 2)
338 advscur();
339
340 return(SUCCESS);
341}
342
343/*
344
[7258c6a]345*/
[f40a309]346
347/*
348 =============================================================================
349 et_agrp() -- load edit buffer
350 =============================================================================
351*/
352
353int16_t et_agrp(int16_t n)
354{
355 sprintf(ebuf, "%02.2d", abs(angroup));
356 ebflag = TRUE;
357 return(SUCCESS);
358}
359
360/*
[7258c6a]361
[f40a309]362*/
[7258c6a]363
[f40a309]364/*
365 =============================================================================
366 ef_agrp() -- parse edit buffer
367 =============================================================================
368*/
369
370int16_t ef_agrp(int16_t n)
371{
372 register int16_t ival;
373
374 ebflag = FALSE;
375 ival = (10 * (ebuf[0] - '0')) + (ebuf[1] - '0');
376
377 if ((ival >12) OR (ival < 1))
378 return(FAILURE);
379
380 angroup = sign(angroup, ival);
381
382 ds_anmd();
383 ds_anrs();
384 ds_anvl();
385 return(SUCCESS);
386}
387
[7258c6a]388/*
[f40a309]389
[7258c6a]390*/
[f40a309]391
392/*
393 =============================================================================
394 rd_agrp() -- (re)display the field
395 =============================================================================
396*/
397
398int16_t rd_agrp(int16_t n)
399{
400 int8_t buf[4];
401
402 sprintf(buf, "%02.2d", abs(angroup));
403
404 if (v_regs[5] & 0x0180)
405 vbank(0);
406
407 vputs(obj8, 7, 61, buf, SDW12ATR);
408
409 return(SUCCESS);
410}
[7258c6a]411
[f40a309]412/*
[7258c6a]413
[f40a309]414*/
415
416/*
417 =============================================================================
418 nd_agrp() -- data entry function
419 =============================================================================
420*/
421
422int16_t nd_agrp(int16_t n, int16_t k)
423{
424 register int16_t ec;
425
426 ec = stccol - cfetp->flcol;
427
428 ebuf[ec] = k + '0';
429
430 if (v_regs[5] & 0x0180)
431 vbank(0);
432
433 vputc(obj8, 7, stccol, k + '0', SDW12DEA);
434 advscur();
435
436 return(SUCCESS);
437}
Note: See TracBrowser for help on using the repository browser.