1 | /*
|
---|
2 | =============================================================================
|
---|
3 | etwhrv.c -- waveshape editor - harmonic value field handlers
|
---|
4 | Version 12 -- 1988-09-09 -- D.N. Lynx Crowe
|
---|
5 | =============================================================================
|
---|
6 | */
|
---|
7 |
|
---|
8 | #include "stddefs.h"
|
---|
9 | #include "fields.h"
|
---|
10 | #include "vsdd.h"
|
---|
11 | #include "vsddsw.h"
|
---|
12 | #include "graphdef.h"
|
---|
13 | #include "charset.h"
|
---|
14 |
|
---|
15 | #include "midas.h"
|
---|
16 | #include "instdsp.h"
|
---|
17 | #include "wsdsp.h"
|
---|
18 |
|
---|
19 | #include "stdio.h"
|
---|
20 |
|
---|
21 | extern void advwcur(void);
|
---|
22 | extern void wdswin(int16_t n);
|
---|
23 |
|
---|
24 | extern void adj(int16_t wshar);
|
---|
25 | extern void whupd(void);
|
---|
26 | extern void wscalc(void);
|
---|
27 |
|
---|
28 | extern uint16_t *waveob;
|
---|
29 |
|
---|
30 | extern int16_t stcrow, stccol, curwhrv, curvce, curwslt, curwhrm;
|
---|
31 |
|
---|
32 | extern int16_t wdbox[][8];
|
---|
33 |
|
---|
34 | extern int8_t dspbuf[];
|
---|
35 |
|
---|
36 | extern struct instdef vbufs[];
|
---|
37 |
|
---|
38 | extern int16_t wsnmod[12][2];
|
---|
39 |
|
---|
40 | extern int16_t vmtab[NUMHARM];
|
---|
41 |
|
---|
42 | /* |
---|
43 |
|
---|
44 | */
|
---|
45 |
|
---|
46 | /*
|
---|
47 | =============================================================================
|
---|
48 | et_whrv() -- load the edit buffer
|
---|
49 | =============================================================================
|
---|
50 | */
|
---|
51 |
|
---|
52 | int16_t et_whrv(int16_t n)
|
---|
53 | {
|
---|
54 | register int16_t harv;
|
---|
55 | register int8_t hvsgn;
|
---|
56 |
|
---|
57 | if (curwhrv LT 0) {
|
---|
58 |
|
---|
59 | hvsgn = '-';
|
---|
60 | harv = -curwhrv;
|
---|
61 |
|
---|
62 | } else {
|
---|
63 |
|
---|
64 | hvsgn = '+';
|
---|
65 | harv = curwhrv;
|
---|
66 | }
|
---|
67 |
|
---|
68 | sprintf(ebuf, "%c%03d", hvsgn, harv);
|
---|
69 | ebflag = TRUE;
|
---|
70 |
|
---|
71 | return(SUCCESS);
|
---|
72 | }
|
---|
73 |
|
---|
74 | /* |
---|
75 |
|
---|
76 | */
|
---|
77 |
|
---|
78 | /*
|
---|
79 | =============================================================================
|
---|
80 | ef_whrv() -- parse (unload) the edit buffer
|
---|
81 | =============================================================================
|
---|
82 | */
|
---|
83 |
|
---|
84 | int16_t ef_whrv(int16_t n)
|
---|
85 | {
|
---|
86 | register int16_t *hv;
|
---|
87 | register int16_t i, tmpval;
|
---|
88 |
|
---|
89 | ebuf[4] = '\0'; /* terminate the string in ebuf */
|
---|
90 | ebflag = FALSE;
|
---|
91 |
|
---|
92 | tmpval = 0;
|
---|
93 |
|
---|
94 | for (i = 1; i < 4; i++) /* convert from ASCII to binary */
|
---|
95 | tmpval = (tmpval * 10) + (ebuf[i] - '0');
|
---|
96 |
|
---|
97 | if (tmpval GT 100)
|
---|
98 | return(FAILURE);
|
---|
99 |
|
---|
100 | if (ebuf[0] EQ '-')
|
---|
101 | curwhrv = -tmpval;
|
---|
102 | else
|
---|
103 | curwhrv = tmpval;
|
---|
104 |
|
---|
105 | hv = curwslt ? vbufs[curvce].idhwvbh : vbufs[curvce].idhwvah;
|
---|
106 | hv[curwhrm] = curwhrv;
|
---|
107 | vmtab[curwhrm] = curwhrv;
|
---|
108 | adj(curwhrm);
|
---|
109 | wscalc();
|
---|
110 | whupd();
|
---|
111 | wsnmod[curvce][curwslt] = TRUE;
|
---|
112 | wdswin(0);
|
---|
113 | wdswin(2);
|
---|
114 | wdswin(4);
|
---|
115 | return(SUCCESS);
|
---|
116 | }
|
---|
117 |
|
---|
118 | /* |
---|
119 |
|
---|
120 | */
|
---|
121 |
|
---|
122 | /*
|
---|
123 | =============================================================================
|
---|
124 | rd_whrv() -- (re)display the field
|
---|
125 | =============================================================================
|
---|
126 | */
|
---|
127 |
|
---|
128 | int16_t rd_whrv(int16_t nn)
|
---|
129 | {
|
---|
130 | register int16_t harv, n;
|
---|
131 | register int8_t hvsgn;
|
---|
132 |
|
---|
133 | n = nn & 0x00FF;
|
---|
134 |
|
---|
135 | if (curwhrv LT 0) {
|
---|
136 |
|
---|
137 | hvsgn = '-';
|
---|
138 | harv = -curwhrv;
|
---|
139 |
|
---|
140 | } else {
|
---|
141 |
|
---|
142 | hvsgn = '+';
|
---|
143 | harv = curwhrv;
|
---|
144 | }
|
---|
145 |
|
---|
146 | sprintf(dspbuf, "%c%03d", hvsgn, harv);
|
---|
147 |
|
---|
148 | vbank(0); /* display the value */
|
---|
149 | vcputsv(waveob, 64, wdbox[n][4], wdbox[n][5],
|
---|
150 | wdbox[n][6] + 1, wdbox[n][7] + WHRV_OFF, dspbuf, 14);
|
---|
151 |
|
---|
152 | return(SUCCESS);
|
---|
153 | }
|
---|
154 |
|
---|
155 | /* |
---|
156 |
|
---|
157 | */
|
---|
158 |
|
---|
159 | /*
|
---|
160 | =============================================================================
|
---|
161 | nd_whrv() -- handle new data entry
|
---|
162 | =============================================================================
|
---|
163 | */
|
---|
164 |
|
---|
165 | int16_t nd_whrv(int16_t nn, int16_t k)
|
---|
166 | {
|
---|
167 | register int16_t ec, n;
|
---|
168 |
|
---|
169 | n = nn & 0x00FF;
|
---|
170 | ec = stccol - cfetp->flcol; /* setup edit buffer column */
|
---|
171 |
|
---|
172 | if (ec EQ 0) {
|
---|
173 |
|
---|
174 | if (k EQ 8) {
|
---|
175 |
|
---|
176 | ebuf[0] = dspbuf[0] = '-';
|
---|
177 | ebuf[4] = dspbuf[1] = '\0';
|
---|
178 |
|
---|
179 | } else if (k EQ 9) {
|
---|
180 |
|
---|
181 | ebuf[0] = dspbuf[0] = '+';
|
---|
182 | ebuf[4] = dspbuf[1] = '\0';
|
---|
183 |
|
---|
184 | } else {
|
---|
185 |
|
---|
186 | return(FAILURE);
|
---|
187 | }
|
---|
188 |
|
---|
189 | } else {
|
---|
190 |
|
---|
191 | ebuf[ec] = dspbuf[0] = k + '0';
|
---|
192 | ebuf[4] = dspbuf[1] = '\0';
|
---|
193 | }
|
---|
194 |
|
---|
195 | vbank(0);
|
---|
196 | vcputsv(waveob, 64, WS_ENTRY, wdbox[n][5],
|
---|
197 | stcrow, stccol, dspbuf, 14);
|
---|
198 |
|
---|
199 | advwcur();
|
---|
200 | return(SUCCESS);
|
---|
201 | }
|
---|