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

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

Use standard integer types.

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