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