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