1 | /*
|
---|
2 | =============================================================================
|
---|
3 | wdselbx.c -- waveshape editor box selection functions
|
---|
4 | Version 27 -- 1988-09-15 -- D.N. Lynx Crowe
|
---|
5 | =============================================================================
|
---|
6 | */
|
---|
7 |
|
---|
8 | #define DEBUGIT 0
|
---|
9 |
|
---|
10 | #include "all.h"
|
---|
11 |
|
---|
12 | extern int16_t entbh(int16_t n);
|
---|
13 | extern void wdswin(int16_t n);
|
---|
14 |
|
---|
15 | extern int16_t curvce, curwdth, cursbox, hitbox, cxval, cyval, hitcx, hitcy;
|
---|
16 | extern int16_t curwave, curwfnl, curwpnt, curwoff, curwhrm, curwhrv, curwslt;
|
---|
17 | extern int16_t wdupdfl, wpntsv, wplast, wvlast, lstwoff, lstwpnt;
|
---|
18 |
|
---|
19 | extern int16_t offsets[NUMWPCAL];
|
---|
20 | extern int16_t vmtab[NUMHARM];
|
---|
21 | extern int16_t wsbuf[NUMWPCAL];
|
---|
22 |
|
---|
23 | extern int32_t vknm[NUMHARM][NUMWPCAL];
|
---|
24 |
|
---|
25 | extern int16_t wdbox[][8];
|
---|
26 |
|
---|
27 | extern int16_t wsnmod[12][2];
|
---|
28 |
|
---|
29 | extern int16_t crate1[], crate2[], *cratex, *cratey;
|
---|
30 |
|
---|
31 | extern struct selbox *csbp, *curboxp;
|
---|
32 |
|
---|
33 | extern struct instdef vbufs[];
|
---|
34 |
|
---|
35 | extern struct wstbl wslib[];
|
---|
36 |
|
---|
37 | /* forward references */
|
---|
38 |
|
---|
39 | int16_t bx_null(void);
|
---|
40 | int16_t wdfnbox(int16_t n);
|
---|
41 |
|
---|
42 | extern int16_t gcurpos(int16_t xloc, int16_t yloc);
|
---|
43 | extern void arcurs(uint16_t icolor);
|
---|
44 | extern void settc(int16_t rv, int16_t cv);
|
---|
45 | extern void updfpu(void);
|
---|
46 | extern void wadj(void);
|
---|
47 |
|
---|
48 | /* |
---|
49 |
|
---|
50 | */
|
---|
51 |
|
---|
52 | struct selbox wdboxes[] = {
|
---|
53 |
|
---|
54 | { 1, 1, 510, 307, 0, wdfnbox}, /* 0 */
|
---|
55 | { 1, 308, 510, 320, 1, wdfnbox}, /* 1 */
|
---|
56 | { 1, 322, 174, 348, 2, entbh}, /* 2 */
|
---|
57 | {176, 322, 230, 348, 3, wdfnbox}, /* 3 */
|
---|
58 | {232, 322, 398, 348, 4, entbh}, /* 4 */
|
---|
59 | {400, 322, 510, 348, 5, entbh}, /* 5 */
|
---|
60 |
|
---|
61 | { 0, 0, 0, 0, 0, FN_NULL} /* end of table */
|
---|
62 | };
|
---|
63 |
|
---|
64 | /*
|
---|
65 | =============================================================================
|
---|
66 | dsnewws() -- display a new waveshape
|
---|
67 | =============================================================================
|
---|
68 | */
|
---|
69 |
|
---|
70 | void dsnewws(void)
|
---|
71 | {
|
---|
72 | wdswin(0);
|
---|
73 | wdswin(2);
|
---|
74 | wdswin(4);
|
---|
75 | wdswin(5);
|
---|
76 | }
|
---|
77 |
|
---|
78 | /* |
---|
79 |
|
---|
80 | */
|
---|
81 |
|
---|
82 | /*
|
---|
83 | =============================================================================
|
---|
84 | newws() -- setup editing for a new waveshape
|
---|
85 | =============================================================================
|
---|
86 | */
|
---|
87 |
|
---|
88 | void newws(void)
|
---|
89 | {
|
---|
90 | register int16_t i;
|
---|
91 | register struct instdef *ip;
|
---|
92 |
|
---|
93 | ip = &vbufs[curvce];
|
---|
94 |
|
---|
95 | if (curwslt) {
|
---|
96 |
|
---|
97 | for (i = 0; i < NUMWPNT; i++) {
|
---|
98 |
|
---|
99 | offsets[i + 1] = ip->idhwvbo[i] >> 5;
|
---|
100 | wsbuf[i + 1] = ip->idhwvbf[i] >> 5;
|
---|
101 | }
|
---|
102 |
|
---|
103 | memcpyw(vmtab, ip->idhwvbh, NUMHARM);
|
---|
104 |
|
---|
105 | } else {
|
---|
106 |
|
---|
107 | for (i = 0; i < NUMWPNT; i++) {
|
---|
108 |
|
---|
109 | offsets[i + 1] = ip->idhwvao[i] >> 5;
|
---|
110 | wsbuf[i + 1] = ip->idhwvaf[i] >> 5;
|
---|
111 | }
|
---|
112 |
|
---|
113 | memcpyw(vmtab, ip->idhwvah, NUMHARM);
|
---|
114 | }
|
---|
115 |
|
---|
116 | offsets[0] = offsets[1];
|
---|
117 | wsbuf[0] = wsbuf[1];
|
---|
118 |
|
---|
119 | curwhrv = vmtab[curwhrm];
|
---|
120 | lstwoff = wvlast = curwoff = offsets[1 + curwpnt];
|
---|
121 | curwfnl = wsbuf[curwpnt + 1];
|
---|
122 | lstwpnt = wplast = curwpnt;
|
---|
123 |
|
---|
124 | memsetw(vknm, 0, (NUMHARM * NUMWPCAL) << 1);
|
---|
125 | wadj();
|
---|
126 | }
|
---|
127 |
|
---|
128 | /* |
---|
129 |
|
---|
130 | */
|
---|
131 |
|
---|
132 | /*
|
---|
133 | =============================================================================
|
---|
134 | wdfnbox() -- waveshape display box hit processor
|
---|
135 | =============================================================================
|
---|
136 | */
|
---|
137 |
|
---|
138 | int16_t wdfnbox(int16_t n)
|
---|
139 | {
|
---|
140 | register int16_t wval;
|
---|
141 | register int8_t wsgn;
|
---|
142 | register int16_t *fpuws;
|
---|
143 |
|
---|
144 | switch (n) { /* switch off of window ID */
|
---|
145 |
|
---|
146 | case 0: /* process a hit in the main window */
|
---|
147 |
|
---|
148 | switch (wpntsv) {
|
---|
149 |
|
---|
150 | case 0: /* nothing selected so far: select a point */
|
---|
151 |
|
---|
152 | wpntsv = 1;
|
---|
153 | curwpnt = (cxval - 2) / 2;
|
---|
154 |
|
---|
155 | if (curwpnt GE NUMWPNT)
|
---|
156 | curwpnt = NUMWPNT - 1;
|
---|
157 | else if (curwpnt < 0)
|
---|
158 | curwpnt = 0;
|
---|
159 |
|
---|
160 | cratex = crate2;
|
---|
161 | cratey = crate2;
|
---|
162 | newws();
|
---|
163 | cyval = WPOFF - ((curwoff * WPSF1) / WPSF2);
|
---|
164 | cxval = (curwpnt << 1) + 2;
|
---|
165 | arcurs(WS_GRAB);
|
---|
166 | gcurpos(cxval, cyval);
|
---|
167 | wplast = curwpnt;
|
---|
168 | wvlast = curwoff;
|
---|
169 | wdswin(4);
|
---|
170 | break;
|
---|
171 | /* |
---|
172 |
|
---|
173 | */
|
---|
174 | case 1: /* point was selected: unselect it */
|
---|
175 |
|
---|
176 | wpntsv = 0;
|
---|
177 | cratex = crate1;
|
---|
178 | cratey = crate1;
|
---|
179 |
|
---|
180 | arcurs(WDCURS);
|
---|
181 | gcurpos(cxval, cyval);
|
---|
182 | break;
|
---|
183 |
|
---|
184 | case 2: /* harmonic was selected: unselect it */
|
---|
185 |
|
---|
186 | wpntsv = 0;
|
---|
187 | cratex = crate1;
|
---|
188 | cratey = crate1;
|
---|
189 |
|
---|
190 | arcurs(WDCURS);
|
---|
191 | settc(22, 1 + (curwhrm << 1));
|
---|
192 | break;
|
---|
193 | }
|
---|
194 |
|
---|
195 | return(TRUE);
|
---|
196 |
|
---|
197 | case 1: /* process a hit in the harmonic legend */
|
---|
198 |
|
---|
199 | wpntsv = 2;
|
---|
200 | cratex = crate1;
|
---|
201 | cratey = crate1;
|
---|
202 |
|
---|
203 | curwhrm = cxval >> 4;
|
---|
204 | curwhrv = vmtab[curwhrm];
|
---|
205 |
|
---|
206 | cxval = (curwhrm << 4) + 8;
|
---|
207 |
|
---|
208 | if (curwhrv < 0) {
|
---|
209 |
|
---|
210 | cyval = WBOFF - ((-curwhrv * WBSF1) / WBSF2);
|
---|
211 |
|
---|
212 | } else {
|
---|
213 |
|
---|
214 | cyval = WBOFF - ((curwhrv * WBSF1) / WBSF2);
|
---|
215 | }
|
---|
216 |
|
---|
217 | arcurs(WS_GRAB);
|
---|
218 | gcurpos(cxval, cyval);
|
---|
219 | wdswin(5);
|
---|
220 | return(TRUE);
|
---|
221 | /* |
---|
222 |
|
---|
223 | */
|
---|
224 | case 3: /* process a hit in the store & fetch window */
|
---|
225 |
|
---|
226 | wsnmod[curvce][curwslt] = FALSE;
|
---|
227 |
|
---|
228 | if (cyval < 336) { /* store ? */
|
---|
229 |
|
---|
230 | memcpyw(&wslib[curwave],
|
---|
231 | curwslt ? vbufs[curvce].idhwvbf
|
---|
232 | : vbufs[curvce].idhwvaf,
|
---|
233 | NUMHARM + (2 * NUMWPNT));
|
---|
234 |
|
---|
235 | wdswin(2);
|
---|
236 |
|
---|
237 | } else { /* retrieve */
|
---|
238 |
|
---|
239 | memcpyw(curwslt ? vbufs[curvce].idhwvbf
|
---|
240 | : vbufs[curvce].idhwvaf,
|
---|
241 | &wslib[curwave],
|
---|
242 | NUMHARM + (2 * NUMWPNT));
|
---|
243 |
|
---|
244 | updfpu();
|
---|
245 | newws();
|
---|
246 | dsnewws();
|
---|
247 | }
|
---|
248 |
|
---|
249 | cratex = crate1;
|
---|
250 | cratey = crate1;
|
---|
251 | return(TRUE);
|
---|
252 |
|
---|
253 | default: /* anywhere else is an error */
|
---|
254 |
|
---|
255 | cratex = crate1;
|
---|
256 | cratey = crate1;
|
---|
257 | return(FALSE);
|
---|
258 | }
|
---|
259 | }
|
---|
260 |
|
---|