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

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

Point of no return.

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