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

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

Unused variables and parameters.

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