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