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

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

Added include files for global functions and variables.

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