source: buchla-68k/ram/etmcfn.c

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

Fixed etmcfn.c.

  • Property mode set to 100644
File size: 5.2 KB
Line 
1/*
2 =============================================================================
3 etmcfn.c -- instrument editor - ws/cf menu field handlers
4 Version 7 -- 1988-08-26 -- D.N. Lynx Crowe
5 =============================================================================
6*/
7
8#include "ram.h"
9
10/*
11 =============================================================================
12 et_mcfn() -- load the edit buffer
13 =============================================================================
14*/
15
16int16_t et_mcfn(int16_t n)
17{
18 (void)n;
19
20 sprintf(ebuf, "%02d", vbufs[curvce].idhcfg);
21 ebflag = TRUE;
22
23 return(SUCCESS);
24}
25
26/*
27 =============================================================================
28 ef_mcfn() -- parse (unload) the edit buffer
29 =============================================================================
30*/
31
32int16_t ef_mcfn(int16_t n)
33{
34 register int16_t tmpval;
35
36 (void)n;
37
38 wmctag = FALSE;
39 ebuf[2] = '\0'; /* terminate the string in ebuf */
40 ebflag = FALSE;
41
42 tmpval = ((ebuf[0] - '0') * 10) + (ebuf[1] - '0');
43
44 if (tmpval GE NUMCFG) /* check against limit */
45 return(FAILURE);
46
47 vbufs[curvce].idhcfg = (int8_t)tmpval;
48 dosync(curvce);
49 wmctag = TRUE;
50 return(SUCCESS);
51}
52
53/*
54 =============================================================================
55 rd_mcfn() -- (re)display the field
56 =============================================================================
57*/
58
59int16_t rd_mcfn(int16_t n)
60{
61 (void)n;
62
63 sprintf(dspbuf, "%02d", vbufs[curvce].idhcfg);
64
65 if (v_regs[5] & 0x0180)
66 vbank(0);
67
68 vcputsv(instob, 64, CFBX18, CBBX18, 24, 16, dspbuf, 14);
69
70 return(SUCCESS);
71}
72
73/*
74 =============================================================================
75 nd_mcfn() -- handle new data entry
76 =============================================================================
77*/
78
79int16_t nd_mcfn(int16_t n, int16_t k)
80{
81 register int16_t ec;
82
83 (void)n;
84
85 ec = stccol - cfetp->flcol; /* setup edit buffer column */
86 ebuf[ec] = (int8_t)(k + '0'); /* enter new data in buffer */
87 ebuf[2] = '\0'; /* make sure string is terminated */
88
89 dspbuf[0] = (int8_t)(k + '0'); /* setup for display */
90 dspbuf[1] = '\0';
91
92 if (v_regs[5] & 0x0180)
93 vbank(0);
94
95 /* display the new data */
96
97 vcputsv(instob, 64, ID_ENTRY, CBBX18, stcrow, stccol, dspbuf, 14);
98
99 advicur(); /* advance cursor */
100
101 return(SUCCESS);
102}
103
104/*
105 =============================================================================
106 et_mwsn() -- load the edit buffer
107 =============================================================================
108*/
109
110int16_t et_mwsn(int16_t nn)
111{
112 wmcsel = (nn & (int16_t)0xFF00) ? 1 : 0;
113
114 sprintf(ebuf, "%02d", 1 + (wmcsel ? vbufs[curvce].idhwsb
115 : vbufs[curvce].idhwsa));
116
117 ebflag = TRUE;
118
119 return(SUCCESS);
120}
121
122/*
123 =============================================================================
124 ef_mwsn() -- parse (unload) the edit buffer
125 =============================================================================
126*/
127
128int16_t ef_mwsn(int16_t nn)
129{
130 int16_t tmpval;
131 volatile uint16_t *fpuws;
132
133 wmcsel = (nn & (int16_t)0xFF00) ? 1 : 0;
134
135 wmctag = FALSE;
136 ebuf[2] = '\0'; /* terminate the string in ebuf */
137 ebflag = FALSE;
138
139 /* convert from ASCII to binary */
140
141 tmpval = ((ebuf[0] -'0') * 10) + (ebuf[1] - '0');
142
143 if ((tmpval < 1) OR (tmpval > NUMWAVS))
144 return(FAILURE);
145
146 if (wmcsel) {
147
148 /* slot B */
149 vbufs[curvce].idhwsb = (int8_t)(tmpval - 1);
150
151 memcpyw(vbufs[curvce].idhwvbf, &wslib[tmpval - 1],
152 NUMHARM + (2 * NUMWPNT));
153
154 fpuws = io_fpu + FPU_OWST + (curvce << 9) + 1;
155
156 memcpyw(fpuws, vbufs[curvce].idhwvbf, NUMWPNT);
157
158 *(fpuws - 1) = (uint16_t)vbufs[curvce].idhwvbf[0];
159 *(fpuws + NUMWPNT) = (uint16_t)vbufs[curvce].idhwvbf[NUMWPNT - 1];
160
161 } else {
162
163 /* slot A */
164
165 vbufs[curvce].idhwsa = (int8_t)(tmpval - 1);
166
167 memcpyw(vbufs[curvce].idhwvaf, &wslib[tmpval - 1],
168 NUMHARM + (2 * NUMWPNT));
169
170 fpuws = io_fpu + FPU_OWST + (curvce << 9) + 0x100 + 1;
171
172 memcpyw(fpuws, vbufs[curvce].idhwvaf, NUMWPNT);
173
174 *(fpuws - 1) = (uint16_t)vbufs[curvce].idhwvaf[0];
175 *(fpuws + NUMWPNT) = (uint16_t)vbufs[curvce].idhwvaf[NUMWPNT - 1];
176 }
177
178 wmctag = TRUE;
179 return(SUCCESS);
180}
181
182/*
183 =============================================================================
184 rd_mwsn() -- (re)display the field
185 =============================================================================
186*/
187
188int16_t rd_mwsn(int16_t nn)
189{
190 wmcsel = (nn & (int16_t)0xFF00) ? 1 : 0;
191
192 sprintf(dspbuf, "%02d", 1 + (wmcsel ? vbufs[curvce].idhwsb
193 : vbufs[curvce].idhwsa));
194
195 if (v_regs[5] & 0x0180)
196 vbank(0);
197
198 vcputsv(instob, 64, CFBX23, CBBX23, 24, wmcsel ? 16 : 12, dspbuf, 14);
199
200 return(SUCCESS);
201}
202
203/*
204 =============================================================================
205 nd_mwsn() -- handle new data entry
206 =============================================================================
207*/
208
209int16_t nd_mwsn(int16_t nn, int16_t k)
210{
211 register int16_t ec;
212
213 (void)nn;
214
215 ec = stccol - cfetp->flcol; /* setup edit buffer column */
216 ebuf[ec] = (int8_t)(k + '0'); /* enter new data in buffer */
217 ebuf[2] = '\0'; /* make sure string is terminated */
218
219 dspbuf[0] = (int8_t)(k + '0'); /* setup for display */
220 dspbuf[1] = '\0';
221
222 if (v_regs[5] & 0x0180)
223 vbank(0); /* display the new data */
224
225 vcputsv(instob, 64, ID_ENTRY, CBBX23, stcrow, stccol, dspbuf, 14);
226
227 advicur(); /* advance cursor */
228
229 return(SUCCESS);
230}
231
Note: See TracBrowser for help on using the repository browser.