source: buchla-68k/orig/RAM/MIDAS.C@ 4f508e6

Last change on this file since 4f508e6 was 3ae31e9, checked in by Thomas Lopatic <thomas@…>, 7 years ago

Imported original source code.

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