source: buchla-68k/ram/ettrns.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: 5.5 KB
Line 
1/*
2 =============================================================================
3 ettrns.c -- transposition field handlers
4 Version 20 -- 1988-07-12 -- D.N. Lynx Crowe
5 =============================================================================
6*/
7
8#define DEBUGIT 0
9
10#include "stddefs.h"
11#include "fields.h"
12#include "charset.h"
13#include "hwdefs.h"
14#include "vsdd.h"
15#include "graphdef.h"
16#include "score.h"
17#include "scfns.h"
18
19#include "midas.h"
20#include "scdsp.h"
21
22#include "stdio.h"
23#include "vsddsw.h"
24
25extern void advscur(void);
26
27extern void scupd(void);
28extern void se_disp(struct s_entry *ep, int16_t sd, struct gdsel *gdstb[], int16_t cf);
29extern void settune(void);
30
31extern uint16_t *obj8;
32
33extern int16_t ctrsw, recsw, stccol, stcrow;
34
35extern int16_t s_trns[12]; /* current transposition values */
36
37extern int8_t dspbuf[65];
38
39extern int16_t grpdyn[], grpmode[], grpstat[];
40
41extern struct gdsel *gdstbc[];
42
43/*
44
45*/
46
47/*
48 =============================================================================
49 et_trns() -- load the edit buffer
50 =============================================================================
51*/
52
53int16_t et_trns(int16_t n)
54{
55 register int16_t trval;
56 register int8_t trsign;
57
58 trval = s_trns[n];
59
60 if (trval < 0) {
61
62 trval = (-trval);
63 trsign = '-';
64
65 } else {
66
67 trsign = '+';
68 }
69
70 sprintf(ebuf, "%04.4d%c", trval, trsign);
71
72 ebflag = TRUE;
73
74#if DEBUGIT
75 printf("et_trns(0x%04.4x) [%s]\r\n", n, ebuf);
76#endif
77
78 return(SUCCESS);
79}
80
81/*
82
83*/
84
85/*
86 =============================================================================
87 ef_trns() -- parse (unload) the edit buffer
88 =============================================================================
89*/
90
91int16_t ef_trns(int16_t n)
92{
93 register int16_t i, trval;
94 register struct s_entry *ep, *trnval;
95
96 ebuf[5] = '\0'; /* terminate the string in ebuf */
97
98#if DEBUGIT
99 printf("ef_trns(0x%04.4x) [%s]\r\n", n, ebuf);
100#endif
101
102 ebflag = FALSE;
103 trval = 0;
104
105 for (i = 0; i < 4; i++) /* convert from ASCII to binary */
106 trval = (trval * 10) + (ebuf[i] - '0');
107
108 if (trval GT 1200) /* check against limit */
109 return(FAILURE);
110
111 if (ebuf[4] EQ '-') /* fixup sign of value */
112 trval = (-trval);
113
114 s_trns[n] = trval; /* store new value */
115 settune(); /* update FPU */
116
117 if (recsw AND grpmode[n] AND (2 EQ grpmode[n])) {
118
119 trnval = (struct s_entry *)((int32_t)trval << 16);
120
121 if (E_NULL NE (ep = findev(p_cur, t_cur, EV_TRNS, n, -1))) {
122
123 ep->e_lft = trnval;
124
125 } else if (E_NULL NE (ep = e_alc(E_SIZE3))) {
126
127 ep->e_type = EV_TRNS;
128 ep->e_time = t_cur;
129 ep->e_data1 = n;
130 ep->e_lft = trnval;
131 p_cur = e_ins(ep, ep_adj(p_cur, 0, t_cur))->e_fwd;
132 eh_ins(ep, EH_TRNS);
133 ctrsw = TRUE;
134 se_disp(ep, D_FWD, gdstbc, 1);
135 scupd();
136 }
137 }
138
139#if DEBUGIT
140 printf(" SUCCESS: %d\r\n", trval);
141#endif
142 return(SUCCESS);
143}
144
145/*
146
147*/
148
149/*
150 =============================================================================
151 rd_trns() -- (re)display the value
152 =============================================================================
153*/
154
155int16_t rd_trns(int16_t n)
156{
157 register int16_t trval, i;
158 register int8_t trsign;
159
160 trval = s_trns[n]; /* get the value */
161
162 if (trval < 0) { /* adjust for the sign */
163
164 trsign = '-';
165 trval = (-trval);
166
167 } else {
168
169 trsign = '+';
170 }
171
172 sprintf(dspbuf, "%04.4d", trval); /* convert to ASCII */
173
174#if DEBUGIT
175 printf("rd_trns: %d <%d> [%s] -> ", n, s_trns[n], dspbuf);
176#endif
177
178 if (trsign EQ '-') { /* handle +1, -1 cases */
179
180 if (dspbuf[0] EQ '1')
181 dspbuf[0] = SP_M1; /* -1 */
182 else
183 dspbuf[0] = '-';
184
185 } else {
186
187 if (dspbuf[0] EQ '1')
188 dspbuf[0] = SP_P1; /* +1 */
189 else
190 dspbuf[0] = '+';
191 }
192
193#if DEBUGIT
194 printf("{%02x %02x %02x %02x}\r\n",
195 dspbuf[0], dspbuf[1], dspbuf[2], dspbuf[3]);
196#endif
197
198 if (v_regs[5] & 0x0180)
199 vbank(0); /* display the value */
200
201 vputs(obj8, 3, (5 * (n + 1)), dspbuf, SDW11ATR);
202
203 return(SUCCESS);
204}
205
206/*
207
208*/
209
210/*
211 =============================================================================
212 ds_trns() -- display all transposition values
213 =============================================================================
214*/
215
216void ds_trns(void)
217{
218 register int16_t i;
219
220 for (i = 0; i < 12; i++) /* display each of the groups */
221 rd_trns(i);
222}
223
224/*
225
226*/
227
228/*
229 =============================================================================
230 nd_trns() -- handle new data entry
231 =============================================================================
232*/
233
234int16_t nd_trns(int16_t n, int16_t k)
235{
236 register int16_t ec, c, advsw;
237
238 ec = stccol - cfetp->flcol; /* setup edit buffer column */
239
240#if DEBUGIT
241 printf("nd_trns(0x%04.4x, 0x%02.2x) ec = %d, tp = 0x%08.8lx\r\n",
242 n, k, ec, tp);
243#endif
244
245 advsw = TRUE;
246
247 if (ec EQ 0) { /* first column of field ? */
248
249 switch (k) { /* what are we entering ? */
250
251 case 0: /* digit 0 */
252
253 ebuf[0] = '0';
254 k = ebuf[4];
255 break;
256
257 case 1: /* digit 1 */
258
259 if (ebuf[4] EQ '+')
260 k = SP_P1; /* +1 */
261 else
262 k = SP_M1; /* -1 */
263
264 ebuf[0] = '1';
265 break;
266
267 case 8: /* - */
268
269 if (ebuf[0] EQ '0')
270 k = '-';
271 else
272 k = SP_M1;
273
274 ebuf[4] = '-';
275 advsw = FALSE;
276 break;
277
278
279 case 9: /* + */
280
281 if (ebuf[0] EQ '0')
282 k = '+';
283 else
284 k = SP_P1;
285
286 ebuf[4] = '+';
287 advsw = FALSE;
288 break;
289
290 default: /* anything else is an error */
291
292 return(FAILURE);
293 }
294
295 } else { /* any other column */
296
297 ebuf[ec] = k + '0';
298 }
299
300 dspbuf[0] = (k > 9) ? k : (k + '0');
301 dspbuf[1] = '\0';
302
303 if (v_regs[5] & 0x0180)
304 vbank(0);
305
306 vputs(obj8, 3, stccol, dspbuf, SDW11DEA);
307
308#if DEBUGIT
309 printf("nd_trns: char=0x%02.2x, col=%d\n", dspbuf[0], stccol);
310#endif
311
312 if (advsw)
313 advscur();
314
315 return(SUCCESS);
316}
Note: See TracBrowser for help on using the repository browser.