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