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