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