source: buchla-68k/ram/ettrns.c@ b28a12e

Last change on this file since b28a12e was b28a12e, checked in by Thomas Lopatic <thomas@…>, 7 years ago

Zero redundant declarations.

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