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

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

Added include files for global functions and variables.

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