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

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

Removed form-feed comments.

  • 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, i;
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, c, advsw;
186
187 ec = stccol - cfetp->flcol; /* setup edit buffer column */
188
189#if DEBUGIT
190 printf("nd_trns(0x%04.4x, 0x%02.2x) ec = %d, tp = 0x%08.8lx\r\n",
191 n, k, ec, tp);
192#endif
193
194 advsw = TRUE;
195
196 if (ec EQ 0) { /* first column of field ? */
197
198 switch (k) { /* what are we entering ? */
199
200 case 0: /* digit 0 */
201
202 ebuf[0] = '0';
203 k = ebuf[4];
204 break;
205
206 case 1: /* digit 1 */
207
208 if (ebuf[4] EQ '+')
209 k = SP_P1; /* +1 */
210 else
211 k = SP_M1; /* -1 */
212
213 ebuf[0] = '1';
214 break;
215
216 case 8: /* - */
217
218 if (ebuf[0] EQ '0')
219 k = '-';
220 else
221 k = SP_M1;
222
223 ebuf[4] = '-';
224 advsw = FALSE;
225 break;
226
227
228 case 9: /* + */
229
230 if (ebuf[0] EQ '0')
231 k = '+';
232 else
233 k = SP_P1;
234
235 ebuf[4] = '+';
236 advsw = FALSE;
237 break;
238
239 default: /* anything else is an error */
240
241 return(FAILURE);
242 }
243
244 } else { /* any other column */
245
246 ebuf[ec] = k + '0';
247 }
248
249 dspbuf[0] = (k > 9) ? k : (k + '0');
250 dspbuf[1] = '\0';
251
252 if (v_regs[5] & 0x0180)
253 vbank(0);
254
255 vputs(obj8, 3, stccol, dspbuf, SDW11DEA);
256
257#if DEBUGIT
258 printf("nd_trns: char=0x%02.2x, col=%d\n", dspbuf[0], stccol);
259#endif
260
261 if (advsw)
262 advscur();
263
264 return(SUCCESS);
265}
266
Note: See TracBrowser for help on using the repository browser.