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

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

Added RAM files.

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