[f40a309] | 1 | /*
|
---|
| 2 | =============================================================================
|
---|
| 3 | etival.c -- MIDAS-VI -- instrument editor - value field handlers
|
---|
| 4 | Version 16 -- 1988-09-15 -- D.N. Lynx Crowe
|
---|
| 5 | =============================================================================
|
---|
| 6 | */
|
---|
| 7 |
|
---|
| 8 | #define DEBUGIT 0
|
---|
| 9 |
|
---|
| 10 | #include "stddefs.h"
|
---|
| 11 | #include "fields.h"
|
---|
| 12 | #include "vsdd.h"
|
---|
| 13 | #include "vsddsw.h"
|
---|
| 14 | #include "graphdef.h"
|
---|
| 15 | #include "charset.h"
|
---|
| 16 | #include "smdefs.h"
|
---|
| 17 |
|
---|
| 18 | #include "midas.h"
|
---|
| 19 | #include "instdsp.h"
|
---|
| 20 |
|
---|
[e225e77] | 21 | #include "stdio.h"
|
---|
| 22 |
|
---|
[f40a309] | 23 | #if DEBUGIT
|
---|
| 24 | extern short debugsw;
|
---|
| 25 | #endif
|
---|
| 26 |
|
---|
[0580615] | 27 | extern void advicur(void);
|
---|
[7258c6a] | 28 | extern int16_t edfunc(int16_t n);
|
---|
| 29 | extern int16_t dec2fr(int8_t *s);
|
---|
[f40a309] | 30 |
|
---|
[7258c6a] | 31 | extern int8_t *dsimlt(int8_t *buf, int16_t src, int16_t mltval);
|
---|
| 32 | extern int8_t *fr2dec(int16_t v, int8_t *s);
|
---|
[f40a309] | 33 |
|
---|
[e225e77] | 34 | extern void dswin(int16_t n);
|
---|
| 35 | extern void idvlblc(void);
|
---|
| 36 | extern void idvlbld(void);
|
---|
| 37 | extern void modinst(void);
|
---|
| 38 | extern void ttcpos(int16_t row, int16_t col);
|
---|
| 39 |
|
---|
[7258c6a] | 40 | extern uint16_t *instob;
|
---|
[f40a309] | 41 |
|
---|
[7258c6a] | 42 | extern int16_t stccol, curfunc;
|
---|
[f40a309] | 43 |
|
---|
[7258c6a] | 44 | extern int16_t idbox[][8];
|
---|
[f40a309] | 45 |
|
---|
[7258c6a] | 46 | extern int8_t dspbuf[];
|
---|
[f40a309] | 47 |
|
---|
| 48 | extern struct instpnt *pntptr;
|
---|
| 49 |
|
---|
[7258c6a] | 50 | extern int16_t vtcrow, vtccol, idsrcsw, submenu;
|
---|
[f40a309] | 51 |
|
---|
| 52 | /* |
---|
| 53 |
|
---|
| 54 | */
|
---|
| 55 |
|
---|
| 56 | /*
|
---|
| 57 | =============================================================================
|
---|
| 58 | et_ival() -- load the edit buffer
|
---|
| 59 | =============================================================================
|
---|
| 60 | */
|
---|
[7258c6a] | 61 |
|
---|
[f40a309] | 62 | int16_t et_ival(int16_t n)
|
---|
[7258c6a] | 63 | {
|
---|
[f40a309] | 64 | register int16_t vv, vh, vl;
|
---|
| 65 |
|
---|
| 66 | vv = pntptr->ipval >> 5;
|
---|
| 67 | vh = vv / 100;
|
---|
| 68 | vl = vv - (vh * 100);
|
---|
| 69 |
|
---|
| 70 | sprintf(ebuf, "%02d.%02d", vh, vl);
|
---|
| 71 | ebuf[5] = '0' + pntptr->ipvsrc;
|
---|
| 72 | fr2dec(pntptr->ipvmlt, &ebuf[6]);
|
---|
| 73 | ebuf[10] = '\0';
|
---|
| 74 | ebflag = TRUE;
|
---|
| 75 |
|
---|
| 76 | #if DEBUGIT
|
---|
| 77 | if (debugsw)
|
---|
| 78 | printf("et_ival(): ebuf=[%s]\n", ebuf);
|
---|
| 79 | #endif
|
---|
| 80 |
|
---|
| 81 | return(SUCCESS);
|
---|
| 82 | }
|
---|
| 83 |
|
---|
| 84 | /* |
---|
| 85 |
|
---|
| 86 | */
|
---|
| 87 |
|
---|
| 88 | /*
|
---|
| 89 | =============================================================================
|
---|
| 90 | ef_ival() -- parse (unload) the edit buffer
|
---|
| 91 | =============================================================================
|
---|
[7258c6a] | 92 | */
|
---|
[f40a309] | 93 |
|
---|
[7258c6a] | 94 | int16_t ef_ival(int16_t n)
|
---|
[f40a309] | 95 | {
|
---|
| 96 | register int16_t i, tmpval, srctmp;
|
---|
| 97 |
|
---|
| 98 | ebuf[2] = '.';
|
---|
| 99 | ebuf[10] = '\0'; /* terminate the string in ebuf */
|
---|
| 100 | ebflag = FALSE;
|
---|
| 101 |
|
---|
| 102 | #if DEBUGIT
|
---|
| 103 | if (debugsw)
|
---|
| 104 | printf("ef_ival(): ebuf=[%s]\n", ebuf);
|
---|
| 105 | #endif
|
---|
| 106 |
|
---|
| 107 | /* |
---|
| 108 |
|
---|
| 109 | */
|
---|
| 110 | if (idsrcsw) { /* entering the source */
|
---|
| 111 |
|
---|
| 112 | idsrcsw = FALSE;
|
---|
| 113 | submenu = FALSE;
|
---|
| 114 |
|
---|
| 115 | if (vtcrow EQ 22) {
|
---|
| 116 |
|
---|
| 117 | /* 'PchW/HT", 'Pch/Frq', 'Random', 'Ctl V1' */
|
---|
| 118 |
|
---|
| 119 | if (vtccol LT 24)
|
---|
| 120 | srctmp = SM_HTPW;
|
---|
| 121 | else if ((vtccol GT 24) AND (vtccol LT 28))
|
---|
| 122 | srctmp = SM_PTCH;
|
---|
| 123 | else if ((vtccol GT 28) AND (vtccol LT 32))
|
---|
| 124 | srctmp = SM_FREQ;
|
---|
| 125 | else if ((vtccol GT 32) AND (vtccol LT 40))
|
---|
| 126 | srctmp = SM_RAND;
|
---|
| 127 | else
|
---|
| 128 | srctmp = SM_CTL1;
|
---|
| 129 |
|
---|
| 130 | } else if (vtcrow EQ 23) {
|
---|
| 131 |
|
---|
| 132 | /* 'ModW/VT', 'Key Vel', 'Pedal 1' */
|
---|
[9519422] | 133 |
|
---|
[f40a309] | 134 | if (vtccol LT 24)
|
---|
| 135 | srctmp = SM_VTMW;
|
---|
| 136 | else if ((vtccol GT 24) AND (vtccol LT 32))
|
---|
| 137 | srctmp = SM_KVEL;
|
---|
| 138 | else if ((vtccol GT 32) AND (vtccol LT 40))
|
---|
| 139 | srctmp = SM_PED1;
|
---|
| 140 | else
|
---|
| 141 | srctmp = SM_NONE;
|
---|
| 142 |
|
---|
| 143 | } else { /* must be row 24 */
|
---|
| 144 |
|
---|
| 145 | /* 'Brth/LP', 'Key Prs' */
|
---|
| 146 |
|
---|
| 147 | if (vtccol LT 24)
|
---|
| 148 | srctmp = SM_LPBR;
|
---|
| 149 | else if ((vtccol GT 24) AND (vtccol LT 32))
|
---|
| 150 | srctmp = SM_KPRS;
|
---|
| 151 | else
|
---|
| 152 | srctmp = SM_NONE;
|
---|
| 153 | }
|
---|
| 154 |
|
---|
| 155 | pntptr->ipvsrc = srctmp; /* set the source */
|
---|
| 156 | objclr(TTCPRI); /* turn off the menu cursor */
|
---|
| 157 | idvlblc(); /* blank the menu area */
|
---|
| 158 | dswin(22); /* refresh the screen */
|
---|
| 159 | modinst();
|
---|
| 160 | /* |
---|
| 161 |
|
---|
| 162 | */
|
---|
| 163 | } else if (stccol LT 32) { /* entering value */
|
---|
| 164 |
|
---|
| 165 | tmpval = 0;
|
---|
| 166 |
|
---|
| 167 | for (i = 0; i < 2; i++) /* convert from ASCII to binary */
|
---|
| 168 | tmpval = (tmpval * 10) + (ebuf[i] - '0');
|
---|
| 169 |
|
---|
| 170 | for (i = 3; i < 5; i++) /* convert from ASCII to binary */
|
---|
| 171 | tmpval = (tmpval * 10) + (ebuf[i] - '0');
|
---|
| 172 |
|
---|
| 173 | if (tmpval GT 1000) {
|
---|
| 174 |
|
---|
| 175 | #if DEBUGIT
|
---|
| 176 | if (debugsw)
|
---|
| 177 | printf("ef_ival(): FAILURE - val - ebuf=[%s]\n", ebuf);
|
---|
| 178 | #endif
|
---|
| 179 |
|
---|
| 180 | return(FAILURE);
|
---|
| 181 | }
|
---|
| 182 |
|
---|
| 183 | pntptr->ipval = tmpval << 5;
|
---|
| 184 | edfunc(curfunc);
|
---|
| 185 | modinst();
|
---|
| 186 |
|
---|
| 187 | } else if ((stccol GE 33) AND (stccol LE 39)) { /* selecting the source */
|
---|
| 188 |
|
---|
| 189 | idsrcsw = TRUE; /* set the select switch */
|
---|
| 190 | submenu = TRUE;
|
---|
| 191 | idvlbld(); /* load the menu area */
|
---|
| 192 | dswin(22); /* refresh the screen */
|
---|
| 193 | SetPri(TTCURS, TTCPRI); /* turn on the typewriter cursor */
|
---|
| 194 | ttcpos(22, 17); /* position the typewriter cusor */
|
---|
| 195 |
|
---|
| 196 | } else if ((stccol GE 41) AND (stccol LE 44)) { /* entering the multiplier */
|
---|
| 197 |
|
---|
| 198 | tmpval = dec2fr(&ebuf[6]);
|
---|
| 199 |
|
---|
| 200 | if (tmpval EQ 0xFFFF) {
|
---|
| 201 |
|
---|
| 202 | #if DEBUGIT
|
---|
| 203 | if (debugsw)
|
---|
| 204 | printf("ef_ival(): FAILURE - mlt - ebuf=[%s]\n", ebuf);
|
---|
| 205 | #endif
|
---|
| 206 |
|
---|
| 207 | return(FAILURE);
|
---|
| 208 |
|
---|
| 209 | } else {
|
---|
| 210 |
|
---|
| 211 | pntptr->ipvmlt = tmpval;
|
---|
| 212 | modinst();
|
---|
| 213 | }
|
---|
| 214 |
|
---|
| 215 | } else
|
---|
| 216 | return(FAILURE);
|
---|
| 217 |
|
---|
| 218 | #if DEBUGIT
|
---|
| 219 | if (debugsw)
|
---|
| 220 | printf("ef_ival(): SUCCESS\n");
|
---|
| 221 | #endif
|
---|
| 222 |
|
---|
| 223 | return(SUCCESS);
|
---|
| 224 | }
|
---|
| 225 |
|
---|
| 226 | /* |
---|
| 227 |
|
---|
| 228 | */
|
---|
| 229 |
|
---|
| 230 | /*
|
---|
[7258c6a] | 231 | =============================================================================
|
---|
[f40a309] | 232 | rd_ival() -- (re)display the field
|
---|
[7258c6a] | 233 | =============================================================================
|
---|
[f40a309] | 234 | */
|
---|
| 235 |
|
---|
| 236 | int16_t rd_ival(int16_t n)
|
---|
| 237 | {
|
---|
| 238 | register int16_t vv, vh, vl;
|
---|
| 239 |
|
---|
| 240 | vv = pntptr->ipval >> 5;
|
---|
| 241 | vh = vv / 100;
|
---|
| 242 | vl = vv - (vh * 100);
|
---|
| 243 |
|
---|
| 244 | sprintf(dspbuf, "%02d.%02d ", vh, vl);
|
---|
| 245 | dsimlt(&dspbuf[6], pntptr->ipvsrc, pntptr->ipvmlt);
|
---|
| 246 |
|
---|
| 247 | vbank(0); /* display the value */
|
---|
| 248 |
|
---|
| 249 | vcputsv(instob, 64, idbox[n][4], idbox[n][5],
|
---|
| 250 | idbox[n][6] + 1, idbox[n][7], dspbuf, 14);
|
---|
| 251 |
|
---|
| 252 | return(SUCCESS);
|
---|
| 253 | }
|
---|
| 254 |
|
---|
| 255 | /* |
---|
| 256 |
|
---|
| 257 | */
|
---|
| 258 |
|
---|
[7258c6a] | 259 | /*
|
---|
[f40a309] | 260 | =============================================================================
|
---|
| 261 | nd_ival() -- handle new data entry
|
---|
| 262 | =============================================================================
|
---|
| 263 | */
|
---|
| 264 |
|
---|
| 265 | int16_t nd_ival(int16_t n, int16_t k)
|
---|
| 266 | {
|
---|
| 267 | if (idsrcsw) /* not in source menu */
|
---|
| 268 | return(FAILURE);
|
---|
| 269 |
|
---|
| 270 | if ((stccol GE 32) AND (stccol LE 40)) /* not in source */
|
---|
| 271 | return(FAILURE);
|
---|
| 272 |
|
---|
| 273 | if (stccol EQ 29) /* not in decimal point */
|
---|
| 274 | return(FAILURE);
|
---|
| 275 |
|
---|
| 276 | ebuf[2] = '.'; /* setup the fixed stuff */
|
---|
| 277 | ebuf[10] = '\0';
|
---|
| 278 |
|
---|
| 279 | /* |
---|
| 280 |
|
---|
| 281 | */
|
---|
| 282 | if (stccol LT 32) { /* value */
|
---|
| 283 |
|
---|
| 284 | ebuf[stccol - 27] = k + '0';
|
---|
| 285 | dspbuf[0] = k + '0';
|
---|
| 286 |
|
---|
| 287 | } else if (stccol EQ 41) { /* mutiplier sign */
|
---|
| 288 |
|
---|
| 289 | if (k EQ 8) { /* - */
|
---|
| 290 |
|
---|
| 291 | ebuf[9] = '-';
|
---|
| 292 | dspbuf[0] = '-';
|
---|
| 293 |
|
---|
| 294 | } else if (k EQ 9) { /* + */
|
---|
| 295 |
|
---|
| 296 | ebuf[9] = '+';
|
---|
| 297 | dspbuf[0] = '+';
|
---|
| 298 |
|
---|
| 299 | } else
|
---|
| 300 | return(FAILURE);
|
---|
| 301 |
|
---|
| 302 | } else if (stccol EQ 42) { /* 1st digit */
|
---|
| 303 |
|
---|
| 304 | if (k EQ 0) { /* 0 */
|
---|
| 305 |
|
---|
| 306 | ebuf[6] = '0';
|
---|
| 307 | dspbuf[0] = '.';
|
---|
| 308 |
|
---|
| 309 | } else if (k EQ 1) { /* 1 */
|
---|
| 310 |
|
---|
| 311 | ebuf[6] = '1';
|
---|
| 312 | dspbuf[0] = SP_1P;
|
---|
| 313 |
|
---|
| 314 | } else
|
---|
| 315 | return(FAILURE);
|
---|
| 316 |
|
---|
| 317 | } else { /* 2nd or 3rd digit */
|
---|
| 318 |
|
---|
| 319 | ebuf[stccol - 36] = k + '0';
|
---|
| 320 | dspbuf[0] = k + '0';
|
---|
| 321 | }
|
---|
| 322 | /* |
---|
| 323 |
|
---|
| 324 | */
|
---|
| 325 | dspbuf[1] = '\0'; /* terminate display buffer */
|
---|
| 326 |
|
---|
| 327 | vbank(0);
|
---|
| 328 |
|
---|
| 329 | vcputsv(instob, 64, ID_ENTRY, idbox[n][5],
|
---|
| 330 | idbox[n][6] + 1, stccol, dspbuf, 14);
|
---|
| 331 |
|
---|
| 332 | if ((stccol EQ 31) OR (stccol EQ 44)) /* last column of field ? */
|
---|
| 333 | return(SUCCESS);
|
---|
| 334 |
|
---|
| 335 | advicur();
|
---|
| 336 |
|
---|
| 337 | if (stccol EQ 29) /* decimal point ? */
|
---|
| 338 | advicur();
|
---|
| 339 |
|
---|
| 340 | return(SUCCESS);
|
---|
| 341 | }
|
---|