source: buchla-68k/ram/ettpch.c@ e225e77

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

Added missing includes and declarations.

  • Property mode set to 100644
File size: 5.1 KB
Line 
1/*
2 =============================================================================
3 ettpch.c -- MIDAS tuning table pitch field handlers
4 Version 6 -- 1987-12-21 -- D.N. Lynx Crowe
5 =============================================================================
6*/
7
8#define DEBUGIT 0
9
10#include "stddefs.h"
11#include "fields.h"
12#include "vsdd.h"
13#include "vsddsw.h"
14#include "graphdef.h"
15#include "charset.h"
16
17#include "midas.h"
18#include "tundsp.h"
19
20/* functions defined elsewhere */
21
22extern int16_t cnvp2c(void);
23
24extern void advtcur(void);
25extern void cnvc2p(int8_t *buf, int16_t cv);
26extern void modtun(void);
27
28/* variables defined elsewhere */
29
30#if DEBUGIT
31extern short debugsw;
32#endif
33
34extern int16_t stcrow, stccol, cents;
35
36extern int16_t tdbox[][8];
37
38extern int16_t tuntab[];
39
40extern int8_t dspbuf[];
41extern int8_t sfdsp[];
42
43extern uint16_t *tunob;
44
45/*
46
47*/
48
49/*
50 =============================================================================
51 loc2key() -- convert a screen location to a key number or field code
52 =============================================================================
53*/
54
55int16_t loc2key(int16_t row, int16_t col)
56{
57 if (row EQ 24) {
58
59 if ((col > 6) AND (col < 39))
60 return(-1); /* -1 = name */
61 else if (col > 52)
62 return(-9); /* -9 = table # */
63 else
64 return(-10); /* -10 = not a field */
65
66 } else if (col < 12)
67 return(row); /* 0..23 = key 0..23 */
68 else if ((col > 11) AND (col < 22))
69 return(row + 24); /* 24..47 = key 24..47 */
70 else if ((col > 21) AND (col < 32))
71 return(row + 48); /* 48..71 = key 48..71 */
72 else if ((col > 31) AND (col < 42))
73 return(row + 72); /* 72..95 = key 72..95 */
74 else if ((col > 41) AND (col < 53))
75 return(row + 96); /* 96..119 = key 96..119 */
76 else if ((col > 52) AND (row < 8))
77 return(row + 120); /* 120..127 = key 120..127 */
78 else if (col > 52) {
79
80 if ((row EQ 9) OR (row EQ 10))
81 return(-2); /* -2 = transpose and copy */
82 else if (row EQ 12)
83 return(-3); /* -3 = increment */
84 else if (row EQ 14)
85 return(-4); /* -4 = interpolate */
86 else if (row EQ 16)
87 return(-5); /* -5 = undo */
88 else if (row EQ 18)
89 return(-6); /* -6 = value */
90 else if (row EQ 20)
91 return(-7); /* -7 = store */
92 else if (row EQ 22)
93 return(-8); /* -8 = retrieve */
94 else
95 return(-10); /* -10 = not a field */
96 } else
97 return(-10); /* -10 = not a field */
98}
99
100/*
101
102*/
103
104/*
105 =============================================================================
106 et_tpch() -- load the edit buffer
107 =============================================================================
108*/
109
110int16_t et_tpch(int16_t nn)
111{
112 register int16_t key, val;
113
114 key = loc2key(stcrow, stccol);
115
116 if (key < 0)
117 return(FAILURE);
118
119 val = tuntab[key];
120 cnvc2p(ebuf, (val >> 1));
121 ebflag = TRUE;
122 return(SUCCESS);
123}
124
125/*
126
127*/
128
129/*
130 =============================================================================
131 ef_tpch() -- unload (parse) edit buffer
132 =============================================================================
133*/
134
135int16_t ef_tpch(int16_t nn)
136{
137 register int16_t key;
138
139 ebflag = FALSE;
140 key = loc2key(stcrow, stccol);
141
142 if (key < 0)
143 return(FAILURE);
144
145 if (cnvp2c() EQ FAILURE)
146 return(FAILURE);
147
148 modtun();
149 tuntab[key] = cents << 1;
150 return(SUCCESS);
151}
152
153/*
154
155*/
156
157/*
158 =============================================================================
159 rd_tpch() -- (re)display the field
160 =============================================================================
161*/
162
163int16_t rd_tpch(int16_t nn)
164{
165 register int16_t val, key, n;
166
167 n = nn & 0xFF;
168 key = loc2key(cfetp->frow, cfetp->flcol);
169 val = tuntab[key];
170
171 cnvc2p(dspbuf, (val >> 1));
172
173 dspbuf[0] += '0';
174 dspbuf[1] += 'A';
175 dspbuf[2] = sfdsp[dspbuf[2] - 7];
176 dspbuf[3] += '0';
177 dspbuf[4] += '0';
178 dspbuf[5] = '\0';
179
180 vbank(0);
181 vcputsv(tunob, 64,
182 ((val EQ 320) OR (val EQ 21920))
183 ? TDMKEYC : tdbox[n][4], tdbox[n][5],
184 cfetp->frow, cfetp->flcol, dspbuf, 14);
185
186 return(SUCCESS);
187}
188
189/*
190
191*/
192
193/*
194 =============================================================================
195 nd_tpch() -- handle new data entry
196 =============================================================================
197*/
198
199int16_t nd_tpch(int16_t nn, int16_t k)
200{
201 register int16_t col, n;
202
203 n = nn & 0xFF;
204
205 if (stccol < 11)
206 col = stccol - 6;
207 else if (stccol < 21)
208 col = stccol - 16;
209 else if (stccol < 31)
210 col = stccol - 26;
211 else if (stccol < 41)
212 col = stccol - 36;
213 else if (stccol < 52)
214 col = stccol - 47;
215 else
216 col = stccol - 58;
217
218 switch (col) {
219
220 case 0:
221
222 ebuf[0] = k;
223 dspbuf[0] = k + '0';
224 break;
225
226 case 1:
227
228 if (k GT 6)
229 return(FAILURE);
230
231 ebuf[1] = k;
232 dspbuf[0] = k + 'A';
233 break;
234/*
235
236*/
237 case 2:
238
239 if (k EQ 7) { /* blank */
240
241 ebuf[2] = k;
242 dspbuf[0] = sfdsp[0];
243 break;
244
245 } else if (k EQ 8) { /* flat */
246
247 ebuf[2] = k;
248 dspbuf[0] = sfdsp[1];
249 break;
250
251 } else if (k EQ 9) { /* sharp */
252
253 ebuf[2] = k;
254 dspbuf[0] = sfdsp[2];
255 break;
256
257 } else
258 return(FAILURE);
259/*
260
261*/
262 case 3:
263 case 4:
264
265 ebuf[col] = k;
266 dspbuf[0] = k + '0';
267 break;
268 }
269
270 dspbuf[1] = '\0';
271
272 vbank(0);
273 vcputsv(tunob, 64, TDENTRY, tdbox[n][5], stcrow, stccol, dspbuf, 14);
274
275 if (col EQ 4)
276 return(SUCCESS);
277
278 advtcur();
279 return(SUCCESS);
280}
Note: See TracBrowser for help on using the repository browser.