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