[f40a309] | 1 | /*
|
---|
| 2 | =============================================================================
|
---|
| 3 | etimlt.c -- instrument editor - global source / multiplier field
|
---|
| 4 | Version 14 -- 1988-09-15 -- D.N. Lynx Crowe
|
---|
| 5 | =============================================================================
|
---|
| 6 | */
|
---|
| 7 |
|
---|
| 8 | #define DEBUGIT 0
|
---|
| 9 |
|
---|
[b28a12e] | 10 | #include "ram.h"
|
---|
[f40a309] | 11 |
|
---|
| 12 | /*
|
---|
| 13 | =============================================================================
|
---|
| 14 | dsimlt() -- decode a source / multiplier pair for display
|
---|
| 15 | =============================================================================
|
---|
| 16 | */
|
---|
| 17 |
|
---|
[7258c6a] | 18 | int8_t *dsimlt(int8_t *buf, int16_t src, int16_t mltval)
|
---|
[f40a309] | 19 | {
|
---|
[7258c6a] | 20 | int8_t mltstr[5], mlttmp[5];
|
---|
[f40a309] | 21 |
|
---|
| 22 | fr2dec(mltval, mlttmp); /* convert to ASCII from binary */
|
---|
| 23 |
|
---|
| 24 | mltstr[0] = mlttmp[3]; /* sign */
|
---|
| 25 |
|
---|
| 26 | if (mlttmp[0] EQ '0') /* 1st digit & decimal point */
|
---|
| 27 | mltstr[1] = '.';
|
---|
| 28 | else
|
---|
| 29 | mltstr[1] = SP_1P;
|
---|
| 30 |
|
---|
| 31 | mltstr[2] = mlttmp[1]; /* 2nd digit */
|
---|
| 32 | mltstr[3] = mlttmp[2]; /* 3rd digit */
|
---|
| 33 | mltstr[4] = '\0'; /* terminate the string */
|
---|
| 34 |
|
---|
| 35 | sprintf(buf, "%7.7s %s", srctbl[src], mltstr);
|
---|
| 36 |
|
---|
| 37 | #if DEBUGIT
|
---|
| 38 | if (debugsw)
|
---|
| 39 | printf("dsimlt($%08.8lX, %d, $%04.4X): [%s]\n",
|
---|
| 40 | buf, src, mltval, buf);
|
---|
| 41 | #endif
|
---|
| 42 |
|
---|
| 43 | return(buf);
|
---|
| 44 | }
|
---|
| 45 |
|
---|
| 46 | /* |
---|
| 47 |
|
---|
| 48 | */
|
---|
| 49 |
|
---|
| 50 | /*
|
---|
| 51 | =============================================================================
|
---|
| 52 | et_imlt() -- load the edit buffer
|
---|
| 53 | =============================================================================
|
---|
| 54 | */
|
---|
[7258c6a] | 55 |
|
---|
[f40a309] | 56 | int16_t et_imlt(int16_t n)
|
---|
| 57 | {
|
---|
| 58 | register struct instdef *ip;
|
---|
| 59 | register struct idfnhdr *fp;
|
---|
| 60 |
|
---|
| 61 | ip = &vbufs[curvce];
|
---|
| 62 | fp = &ip->idhfnc[curfunc];
|
---|
| 63 |
|
---|
| 64 | ebuf[0] = '0' + fp->idfsrc;
|
---|
| 65 | fr2dec(fp->idfmlt, &ebuf[1]);
|
---|
| 66 | ebuf[5] = '\0';
|
---|
| 67 |
|
---|
| 68 | ebflag = TRUE;
|
---|
| 69 |
|
---|
| 70 | #if DEBUGIT
|
---|
| 71 | if (debugsw)
|
---|
| 72 | printf("et_imlt(): ebuf=[%s]\n", ebuf);
|
---|
| 73 | #endif
|
---|
| 74 |
|
---|
| 75 | return(SUCCESS);
|
---|
| 76 | }
|
---|
| 77 |
|
---|
| 78 | /* |
---|
| 79 |
|
---|
| 80 | */
|
---|
| 81 |
|
---|
| 82 | /*
|
---|
| 83 | =============================================================================
|
---|
| 84 | ef_imlt() -- parse (unload) the edit buffer (called by 'E' key)
|
---|
| 85 | =============================================================================
|
---|
[7258c6a] | 86 | */
|
---|
[f40a309] | 87 |
|
---|
[7258c6a] | 88 | int16_t ef_imlt(int16_t n)
|
---|
[f40a309] | 89 | {
|
---|
| 90 | register int16_t i, tmpval, srctmp;
|
---|
| 91 | register struct instdef *ip;
|
---|
| 92 | register struct idfnhdr *fp;
|
---|
| 93 |
|
---|
| 94 | ip = &vbufs[curvce];
|
---|
| 95 | fp = &ip->idhfnc[curfunc];
|
---|
| 96 |
|
---|
| 97 | ebuf[5] = '\0'; /* terminate the string in ebuf */
|
---|
| 98 | ebflag = FALSE;
|
---|
| 99 |
|
---|
| 100 | #if DEBUGIT
|
---|
| 101 | if (debugsw)
|
---|
| 102 | printf("ef_imlt(): ebuf=[%s]\n", ebuf);
|
---|
| 103 | #endif
|
---|
| 104 |
|
---|
| 105 | /* |
---|
| 106 |
|
---|
| 107 | */
|
---|
| 108 | if (idsrcsw) { /* entering the source */
|
---|
| 109 |
|
---|
| 110 | idsrcsw = FALSE;
|
---|
| 111 | submenu = FALSE;
|
---|
| 112 |
|
---|
| 113 | if (vtcrow EQ 22) {
|
---|
| 114 |
|
---|
| 115 | /* 'PchW/HT', 'Pitch', 'Random', 'GPC/CV1' */
|
---|
| 116 |
|
---|
| 117 | if (vtccol LT 24)
|
---|
| 118 | srctmp = SM_HTPW;
|
---|
| 119 | else if ((vtccol GT 24) AND (vtccol LT 28))
|
---|
| 120 | srctmp = SM_PTCH;
|
---|
| 121 | else if ((vtccol GT 28) AND (vtccol LT 32))
|
---|
| 122 | srctmp = SM_FREQ;
|
---|
| 123 | else if ((vtccol GT 32) AND (vtccol LT 40))
|
---|
| 124 | srctmp = SM_RAND;
|
---|
| 125 | else
|
---|
| 126 | srctmp = SM_CTL1;
|
---|
| 127 |
|
---|
| 128 | } else if (vtcrow EQ 23) {
|
---|
| 129 |
|
---|
| 130 | /* 'ModW/VT', 'Key Vel', 'Pedal 1' */
|
---|
[9519422] | 131 |
|
---|
[f40a309] | 132 | if (vtccol LT 24)
|
---|
| 133 | srctmp = SM_VTMW;
|
---|
| 134 | else if ((vtccol GT 24) AND (vtccol LT 32))
|
---|
| 135 | srctmp = SM_KVEL;
|
---|
| 136 | else if ((vtccol GT 32) AND (vtccol LT 40))
|
---|
| 137 | srctmp = SM_PED1;
|
---|
| 138 | else
|
---|
| 139 | srctmp = SM_NONE;
|
---|
| 140 |
|
---|
| 141 | } else { /* must be row 24 */
|
---|
| 142 |
|
---|
| 143 | /* 'PchW/LP', 'Key Prs' */
|
---|
| 144 |
|
---|
| 145 | if (vtccol LT 24)
|
---|
| 146 | srctmp = SM_LPBR;
|
---|
| 147 | else if ((vtccol GT 24) AND (vtccol LT 32))
|
---|
| 148 | srctmp = SM_KPRS;
|
---|
| 149 | else
|
---|
| 150 | srctmp = SM_NONE;
|
---|
| 151 | }
|
---|
| 152 |
|
---|
| 153 | fp->idfsrc = srctmp; /* set the source */
|
---|
| 154 | objclr(TTCPRI); /* turn off the menu cursor */
|
---|
| 155 | idvlblc(); /* blank the menu area */
|
---|
| 156 | modinst();
|
---|
| 157 | dswin(22); /* refresh the screen */
|
---|
| 158 | /* |
---|
| 159 |
|
---|
| 160 | */
|
---|
| 161 | } else if (stccol LT 8) { /* selecting the source */
|
---|
| 162 |
|
---|
| 163 | idsrcsw = TRUE; /* set the select switch */
|
---|
| 164 | submenu = TRUE;
|
---|
| 165 | idvlbld(); /* load the menu area */
|
---|
| 166 | dswin(22); /* refresh the screen */
|
---|
| 167 | SetPri(TTCURS, TTCPRI); /* turn on the typewriter cursor */
|
---|
| 168 | ttcpos(22, 17); /* position the typewriter cusor */
|
---|
| 169 |
|
---|
| 170 | } else if (stccol GT 8) { /* entering the multiplier */
|
---|
| 171 |
|
---|
| 172 | tmpval = dec2fr(&ebuf[1]);
|
---|
| 173 |
|
---|
| 174 | if (tmpval EQ 0xFFFF)
|
---|
| 175 | return(FAILURE);
|
---|
| 176 | else
|
---|
| 177 | fp->idfmlt = tmpval;
|
---|
| 178 |
|
---|
| 179 | modinst();
|
---|
| 180 |
|
---|
| 181 | } else
|
---|
| 182 | return(FAILURE);
|
---|
| 183 |
|
---|
| 184 | #if DEBUGIT
|
---|
| 185 | if (debugsw)
|
---|
| 186 | printf("ef_imlt(): SUCCESS\n");
|
---|
| 187 | #endif
|
---|
| 188 |
|
---|
| 189 | return(SUCCESS);
|
---|
| 190 | }
|
---|
| 191 |
|
---|
| 192 | /* |
---|
| 193 |
|
---|
| 194 | */
|
---|
| 195 |
|
---|
| 196 | /*
|
---|
[7258c6a] | 197 | =============================================================================
|
---|
[f40a309] | 198 | rd_imlt() -- (re)display the field
|
---|
| 199 | =============================================================================
|
---|
| 200 | */
|
---|
| 201 |
|
---|
| 202 | int16_t rd_imlt(int16_t n)
|
---|
| 203 | {
|
---|
| 204 | register struct instdef *ip;
|
---|
| 205 | register struct idfnhdr *fp;
|
---|
| 206 |
|
---|
| 207 | ip = &vbufs[curvce];
|
---|
| 208 | fp = &ip->idhfnc[curfunc];
|
---|
| 209 |
|
---|
| 210 | dsimlt(dspbuf, fp->idfsrc, fp->idfmlt);
|
---|
| 211 |
|
---|
| 212 | vcputsv(instob, 64, idbox[n][4], idbox[n][5],
|
---|
| 213 | idbox[n][6] + 1, idbox[n][7], dspbuf, 14);
|
---|
| 214 |
|
---|
| 215 | return(SUCCESS);
|
---|
| 216 | }
|
---|
| 217 |
|
---|
| 218 | /* |
---|
| 219 |
|
---|
| 220 | */
|
---|
| 221 |
|
---|
[7258c6a] | 222 | /*
|
---|
[f40a309] | 223 | =============================================================================
|
---|
[7258c6a] | 224 | nd_imlt() -- handle new data entry
|
---|
[f40a309] | 225 | =============================================================================
|
---|
| 226 | */
|
---|
| 227 |
|
---|
| 228 | int16_t nd_imlt(int16_t n, int16_t k)
|
---|
| 229 | {
|
---|
| 230 | register int16_t ec;
|
---|
| 231 |
|
---|
| 232 | if (idsrcsw) /* not if the source menu is up */
|
---|
| 233 | return(FAILURE);
|
---|
| 234 |
|
---|
| 235 | if (stccol LT 9) /* only in the multiplier field */
|
---|
| 236 | return(FAILURE);
|
---|
| 237 |
|
---|
| 238 | ec = stccol - 9; /* calculate edit buffer column */
|
---|
| 239 |
|
---|
| 240 | switch (ec) {
|
---|
| 241 |
|
---|
| 242 | case 0: /* sign position */
|
---|
| 243 |
|
---|
| 244 | if (k EQ 8) { /* - */
|
---|
| 245 |
|
---|
| 246 | ebuf[4] = '-';
|
---|
| 247 | dspbuf[0] = '-'; /* setup display buffer */
|
---|
| 248 |
|
---|
| 249 | } else if (k EQ 9) { /* + */
|
---|
| 250 |
|
---|
| 251 | ebuf[4] = '+';
|
---|
| 252 | dspbuf[0] = '+'; /* setup display buffer */
|
---|
| 253 |
|
---|
| 254 | } else
|
---|
| 255 | return(FAILURE);
|
---|
| 256 |
|
---|
| 257 | break;
|
---|
| 258 |
|
---|
| 259 | case 1: /* 1st digit position (0 or 1) */
|
---|
| 260 |
|
---|
| 261 | if (k EQ 0) { /* '0' -> '.' */
|
---|
| 262 |
|
---|
| 263 | ebuf[1] = '0';
|
---|
| 264 | dspbuf[0] = '.'; /* setup display buffer */
|
---|
| 265 |
|
---|
| 266 | } else if (k EQ 1) { /* '1' -> '1.' */
|
---|
| 267 |
|
---|
| 268 | ebuf[1] = '1';
|
---|
| 269 | dspbuf[0] = SP_1P; /* setup display buffer */
|
---|
| 270 |
|
---|
| 271 | } else
|
---|
| 272 | return(FAILURE);
|
---|
| 273 |
|
---|
| 274 | break;
|
---|
| 275 |
|
---|
| 276 | case 2: /* 2nd digit position */
|
---|
| 277 | case 3: /* 3rd digit position */
|
---|
| 278 |
|
---|
| 279 | ebuf[ec] = k + '0';
|
---|
| 280 | dspbuf[0] = k + '0'; /* setup display buffer */
|
---|
| 281 | break;
|
---|
| 282 |
|
---|
| 283 | default:
|
---|
| 284 | return(FAILURE);
|
---|
| 285 | }
|
---|
| 286 |
|
---|
| 287 | ebuf[5] = '\0';
|
---|
| 288 | dspbuf[1] = '\0';
|
---|
| 289 |
|
---|
| 290 | #if DEBUGIT
|
---|
| 291 | if (debugsw)
|
---|
| 292 | printf("nd_imlt(): OK - k=%d, ec=%d, ebuf=[%s]\n", k, ec, ebuf);
|
---|
| 293 | #endif
|
---|
| 294 |
|
---|
| 295 | vbank(0);
|
---|
| 296 |
|
---|
| 297 | vcputsv(instob, 64, ID_ENTRY, idbox[n][5],
|
---|
| 298 | idbox[n][6] + 1, stccol, dspbuf, 14);
|
---|
| 299 |
|
---|
| 300 | if (ec EQ 4)
|
---|
[6262b5c] | 301 | return(SUCCESS);
|
---|
| 302 |
|
---|
| 303 | advicur();
|
---|
| 304 |
|
---|
| 305 | return(SUCCESS);
|
---|
| 306 | }
|
---|
| 307 |
|
---|