1 | /*
|
---|
2 | =============================================================================
|
---|
3 | midas.c -- MIDAS-VII main function
|
---|
4 | Version 26 -- 1989-07-19 -- D.N. Lynx Crowe
|
---|
5 | =============================================================================
|
---|
6 | */
|
---|
7 |
|
---|
8 | #define DEBUGIT 0
|
---|
9 |
|
---|
10 | #include "stddefs.h"
|
---|
11 | #include "biosdefs.h"
|
---|
12 | #include "vsdd.h"
|
---|
13 | #include "hwdefs.h"
|
---|
14 | #include "wordq.h"
|
---|
15 | #include "sclock.h"
|
---|
16 |
|
---|
17 | #include "graphdef.h"
|
---|
18 | #include "midas.h"
|
---|
19 |
|
---|
20 | #include "score.h"
|
---|
21 | #include "scfns.h"
|
---|
22 | #include "strings.h"
|
---|
23 |
|
---|
24 | #define LCD_TIME ((int32_t)(800 * 240)) /* LCD backlight 'on' time */
|
---|
25 |
|
---|
26 | #if DEBUGIT
|
---|
27 | extern short debugsw;
|
---|
28 |
|
---|
29 | short debugmm = 1;
|
---|
30 | #endif
|
---|
31 |
|
---|
32 | extern void fpuint(void);
|
---|
33 | extern void clk_ped(int16_t stat);
|
---|
34 | extern void pch_ped(int16_t stat);
|
---|
35 |
|
---|
36 | extern int16_t MouseWK(void);
|
---|
37 | extern int16_t rscript(int8_t *p[]);
|
---|
38 | extern uint16_t setipl(uint16_t arg);
|
---|
39 | extern void adfield(void);
|
---|
40 | extern void allwins(void);
|
---|
41 | extern void asgdsp(void);
|
---|
42 | extern void awins(void);
|
---|
43 | extern void fpuclr(void);
|
---|
44 | extern void idfield(void);
|
---|
45 | extern void im700(void);
|
---|
46 | extern void instdsp(void);
|
---|
47 | extern void lcd_on(void);
|
---|
48 | extern void ldfield(void);
|
---|
49 | extern void libdsp(void);
|
---|
50 | extern void m7menu(void);
|
---|
51 | extern void msl(void);
|
---|
52 | extern void newws(void);
|
---|
53 | extern void ptdisp(void);
|
---|
54 | extern void ptfield(void);
|
---|
55 | extern void scfield(void);
|
---|
56 | extern void scopeon(void);
|
---|
57 | extern void sdsetup(void);
|
---|
58 | extern void sdwins(void);
|
---|
59 | extern void setinst(void);
|
---|
60 | extern void setsio(void);
|
---|
61 | extern void settune(void);
|
---|
62 | extern void sqdisp(void);
|
---|
63 | extern void sqfield(void);
|
---|
64 | extern void tdfield(void);
|
---|
65 | extern void tsetup(void);
|
---|
66 | extern void tundsp(void);
|
---|
67 | extern void twins(void);
|
---|
68 | extern void wdfield(void);
|
---|
69 | extern void wsdsp(void);
|
---|
70 | extern void wwins(void);
|
---|
71 |
|
---|
72 | extern void (*foot1)(int16_t stat);
|
---|
73 | extern void (*foot2)(int16_t stat);
|
---|
74 | extern void (*pulse1)(void);
|
---|
75 | extern void (*pulse2)(void);
|
---|
76 |
|
---|
77 | extern int8_t end, etext, edata;
|
---|
78 |
|
---|
79 | extern int16_t clkrun, clksrc, initcfg, ndisp, verbose;
|
---|
80 |
|
---|
81 | extern int32_t lcdontm, lcdtime;
|
---|
82 |
|
---|
83 | extern int16_t fp_resv[];
|
---|
84 |
|
---|
85 | extern int8_t *script0[];
|
---|
86 |
|
---|
87 | extern int8_t VerDate[];
|
---|
88 |
|
---|
89 | extern struct wordq ptefifo; /* trigger fifo */
|
---|
90 |
|
---|
91 | int8_t m7verms[32]; /* version message for the main menu */
|
---|
92 |
|
---|
93 | int16_t clkdiv; /* clock divider */
|
---|
94 |
|
---|
95 | /* |
---|
96 |
|
---|
97 | */
|
---|
98 |
|
---|
99 | /*
|
---|
100 | =============================================================================
|
---|
101 | dopls1() -- process pulse 1 inputs
|
---|
102 | =============================================================================
|
---|
103 | */
|
---|
104 |
|
---|
105 | void dopls1(void)
|
---|
106 | {
|
---|
107 | putwq(&ptefifo, 0x1180); /* pulse 1 trigger -> STM fifo */
|
---|
108 |
|
---|
109 | if (NOT clkrun) /* check for clock enable */
|
---|
110 | return; /* done if not enabled */
|
---|
111 |
|
---|
112 | if (clksrc EQ CK_PLS24) { /* Pulse 24 mode ? */
|
---|
113 |
|
---|
114 | fc_val += 2L; /* 2 clocks per pulse */
|
---|
115 |
|
---|
116 | if (fc_val > 0x00FFFFFFL) /* limit clock at maximum */
|
---|
117 | fc_val = 0x00FFFFFFL;
|
---|
118 |
|
---|
119 | } else if (clksrc EQ CK_PLS48) { /* Pulse 48 mode ? */
|
---|
120 |
|
---|
121 | ++fc_val; /* 1 clock per pulse */
|
---|
122 |
|
---|
123 | if (fc_val > 0x00FFFFFFL) /* limit clock at maximum */
|
---|
124 | fc_val = 0x00FFFFFFL;
|
---|
125 |
|
---|
126 | } else if (clksrc EQ CK_PLS96) { /* Pulse 96 mode ? */
|
---|
127 |
|
---|
128 | if (clkdiv++) { /* 2 pulses per clock */
|
---|
129 |
|
---|
130 | clkdiv = 0; /* reset divider */
|
---|
131 | ++fc_val; /* update frame clock */
|
---|
132 |
|
---|
133 | if (fc_val > 0x00FFFFFFL) /* limit clock at maximum */
|
---|
134 | fc_val = 0x00FFFFFFL;
|
---|
135 | }
|
---|
136 | }
|
---|
137 | }
|
---|
138 |
|
---|
139 | /*
|
---|
140 | =============================================================================
|
---|
141 | dopls2() -- process pulse 2 inputs
|
---|
142 | =============================================================================
|
---|
143 | */
|
---|
144 |
|
---|
145 | void dopls2(void)
|
---|
146 | {
|
---|
147 | putwq(&ptefifo, 0x1181); /* pulse 2 trigger -> STM fifo */
|
---|
148 | }
|
---|
149 |
|
---|
150 | /* |
---|
151 |
|
---|
152 | */
|
---|
153 |
|
---|
154 | /*
|
---|
155 | =============================================================================
|
---|
156 | mpcupd() -- MIDI program change display update
|
---|
157 | =============================================================================
|
---|
158 | */
|
---|
159 |
|
---|
160 | void mpcupd(void)
|
---|
161 | {
|
---|
162 | switch (ndisp) {
|
---|
163 |
|
---|
164 | case 0: /* Librarian */
|
---|
165 |
|
---|
166 | break;
|
---|
167 |
|
---|
168 | case 1: /* Patch Editor */
|
---|
169 |
|
---|
170 | break;
|
---|
171 |
|
---|
172 | case 2: /* Score Editor */
|
---|
173 |
|
---|
174 | sdwins(); /* fill in the windows */
|
---|
175 | break;
|
---|
176 |
|
---|
177 | case 3: /* Sequence Editor */
|
---|
178 |
|
---|
179 | break;
|
---|
180 |
|
---|
181 | case 4: /* Instrument Editor */
|
---|
182 |
|
---|
183 | setinst(); /* bring variables up to date */
|
---|
184 | allwins(); /* fill in the windows */
|
---|
185 | break;
|
---|
186 |
|
---|
187 | case 5: /* Initialize System */
|
---|
188 |
|
---|
189 | break;
|
---|
190 |
|
---|
191 | case 6: /* Waveshape Editor */
|
---|
192 |
|
---|
193 | newws(); /* bring variables up to date */
|
---|
194 | wwins(); /* fill in the windows */
|
---|
195 | break;
|
---|
196 |
|
---|
197 | case 7: /* Write Program to Disk */
|
---|
198 |
|
---|
199 | break;
|
---|
200 |
|
---|
201 | case 8: /* Tuning Editor */
|
---|
202 |
|
---|
203 | twins(); /* fill in the windows */
|
---|
204 | break;
|
---|
205 |
|
---|
206 | case 9: /* Format Disk */
|
---|
207 |
|
---|
208 | break;
|
---|
209 |
|
---|
210 | case 10: /* Assignment Editor */
|
---|
211 |
|
---|
212 | awins(); /* fill in the windows */
|
---|
213 | break;
|
---|
214 | }
|
---|
215 | }
|
---|
216 |
|
---|
217 | /* |
---|
218 |
|
---|
219 | */
|
---|
220 |
|
---|
221 | /*
|
---|
222 | =============================================================================
|
---|
223 | MIDAS 700 main function
|
---|
224 | =============================================================================
|
---|
225 | */
|
---|
226 |
|
---|
227 | void main(void)
|
---|
228 | {
|
---|
229 | setipl(FPU_DI); /* disable FPU interrupts */
|
---|
230 |
|
---|
231 | /* +++++++++++++++++++++++ FPU INTERRUPTS DISABLED ++++++++++++++++++++++++++ */
|
---|
232 |
|
---|
233 | BIOS(B_SETV, 26, fpuint); /* set level 2 int. vector for FPU */
|
---|
234 |
|
---|
235 | initcfg = 0; /* set initial configuration (in MS bits) */
|
---|
236 | fp_resv[0] = (-1000) << 5; /* initial output amplitude = 0.0 */
|
---|
237 |
|
---|
238 | fpuclr(); /* quiet the FPU */
|
---|
239 |
|
---|
240 | tsetup(); /* setup the timer and timer interrupts */
|
---|
241 | setsio(); /* setup the serial I/O port interrupts */
|
---|
242 |
|
---|
243 | foot1 = clk_ped; /* setup clock on/off pedal processing */
|
---|
244 | foot2 = pch_ped; /* setup punch in/out pedal processing */
|
---|
245 |
|
---|
246 | pulse1 = dopls1; /* setup pulse input 1 processing */
|
---|
247 | pulse2 = dopls2; /* setup pulse input 2 processing */
|
---|
248 |
|
---|
249 | lcdontm = LCD_TIME; /* set the LCD backlight 'on' time */
|
---|
250 | lcd_on(); /* turn on the LCD backlight */
|
---|
251 |
|
---|
252 | strcpy(m7verms, &VerDate[2]); /* setup the version message */
|
---|
253 |
|
---|
254 | im700(); /* initialize everything */
|
---|
255 | settune(); /* ... including fine tuning */
|
---|
256 |
|
---|
257 | ndisp = -1; /* say nothing has been selected yet */
|
---|
258 | verbose = FALSE; /* setup to run the script quietly */
|
---|
259 | rscript(script0); /* run the initial script */
|
---|
260 | sc_goto(0L); /* position the score */
|
---|
261 |
|
---|
262 | MouseWK(); /* wake up the mouse if it's there */
|
---|
263 |
|
---|
264 | goto startup; /* go put up the main menu */
|
---|
265 |
|
---|
266 | /* |
---|
267 |
|
---|
268 | */
|
---|
269 |
|
---|
270 | newdisp:
|
---|
271 |
|
---|
272 | msl(); /* run the new display */
|
---|
273 |
|
---|
274 | startup:
|
---|
275 |
|
---|
276 | #if DEBUGIT
|
---|
277 | if (debugsw AND debugmm)
|
---|
278 | printf("main(): switching to MAIN MENU\N");
|
---|
279 | #endif
|
---|
280 |
|
---|
281 | m7menu(); /* put up the main menu */
|
---|
282 | msl(); /* run the main menu */
|
---|
283 |
|
---|
284 | #if DEBUGIT
|
---|
285 | if (debugsw AND debugmm)
|
---|
286 | printf("main(): switching to %d\n", ndisp);
|
---|
287 | #endif
|
---|
288 |
|
---|
289 | switch (ndisp) { /* setup for a new display */
|
---|
290 |
|
---|
291 | case 0: /* =================== librarian ==================== */
|
---|
292 |
|
---|
293 | ldfield(); /* setup the librarian field handlers */
|
---|
294 | libdsp(); /* setup the librarian display */
|
---|
295 | break;
|
---|
296 |
|
---|
297 | case 1: /* =================== patch editor ================= */
|
---|
298 |
|
---|
299 | ptfield(); /* setup the patch field handlers */
|
---|
300 | ptdisp(); /* setup the patch display */
|
---|
301 | break;
|
---|
302 |
|
---|
303 | case 2: /* =================== score editor ================= */
|
---|
304 |
|
---|
305 | scfield(); /* initialize score field handlers */
|
---|
306 | sdsetup(); /* setup the score display */
|
---|
307 | break;
|
---|
308 |
|
---|
309 | case 3: /* ================ sequence editor ================= */
|
---|
310 |
|
---|
311 | sqfield(); /* initialize sequence field handlers */
|
---|
312 | sqdisp(); /* setup the sequence display */
|
---|
313 | break;
|
---|
314 | /* |
---|
315 |
|
---|
316 | */
|
---|
317 | case 4: /* =============== instrument editor ================ */
|
---|
318 |
|
---|
319 | idfield(); /* setup instrument field handlers */
|
---|
320 | instdsp(); /* setup the instrument display */
|
---|
321 | break;
|
---|
322 |
|
---|
323 | case 6: /* ================ waveshape editor ================ */
|
---|
324 |
|
---|
325 | wdfield(); /* setup waveshape field handlers */
|
---|
326 | wsdsp(); /* setup the waveshape display */
|
---|
327 | break;
|
---|
328 |
|
---|
329 | case 8: /* ================ tuning editor ================ */
|
---|
330 |
|
---|
331 | tdfield(); /* setup tuning editor field handlers */
|
---|
332 | tundsp(); /* setup the tuning display */
|
---|
333 | break;
|
---|
334 |
|
---|
335 | case 10: /* ================ assignment editor =============== */
|
---|
336 |
|
---|
337 | adfield(); /* setup assignment field handlers */
|
---|
338 | asgdsp(); /* setup the assignment display */
|
---|
339 | break;
|
---|
340 |
|
---|
341 | case 11: /* ================ diagnostics ===================== */
|
---|
342 |
|
---|
343 | scopeon(); /* setup the diagnostics */
|
---|
344 | break;
|
---|
345 |
|
---|
346 | default:
|
---|
347 |
|
---|
348 | #if DEBUGIT
|
---|
349 | if (debugsw AND debugmm)
|
---|
350 | printf("main(): UNKNOWN display (%d)\n", ndisp);
|
---|
351 | #endif
|
---|
352 |
|
---|
353 | ndisp = -1;
|
---|
354 | goto startup;
|
---|
355 | }
|
---|
356 |
|
---|
357 | #if DEBUGIT
|
---|
358 | if (debugsw AND debugmm)
|
---|
359 | printf("main(): display switch complete to %d\n", ndisp);
|
---|
360 | #endif
|
---|
361 |
|
---|
362 | goto newdisp;
|
---|
363 | }
|
---|