source: buchla-68k/ram/midas.c@ 6262b5c

Last change on this file since 6262b5c was 6262b5c, checked in by Thomas Lopatic <thomas@…>, 7 years ago

Added include files for global functions and variables.

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