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