[f40a309] | 1 | /*
|
---|
| 2 | =============================================================================
|
---|
| 3 | ettpch.c -- MIDAS tuning table pitch field handlers
|
---|
| 4 | Version 6 -- 1987-12-21 -- D.N. Lynx Crowe
|
---|
| 5 | =============================================================================
|
---|
| 6 | */
|
---|
| 7 |
|
---|
| 8 | #define DEBUGIT 0
|
---|
| 9 |
|
---|
[b28a12e] | 10 | #include "ram.h"
|
---|
[f40a309] | 11 |
|
---|
| 12 | /*
|
---|
| 13 | =============================================================================
|
---|
| 14 | loc2key() -- convert a screen location to a key number or field code
|
---|
| 15 | =============================================================================
|
---|
| 16 | */
|
---|
| 17 |
|
---|
[7258c6a] | 18 | int16_t loc2key(int16_t row, int16_t col)
|
---|
[f40a309] | 19 | {
|
---|
| 20 | if (row EQ 24) {
|
---|
| 21 |
|
---|
| 22 | if ((col > 6) AND (col < 39))
|
---|
| 23 | return(-1); /* -1 = name */
|
---|
| 24 | else if (col > 52)
|
---|
| 25 | return(-9); /* -9 = table # */
|
---|
| 26 | else
|
---|
| 27 | return(-10); /* -10 = not a field */
|
---|
| 28 |
|
---|
| 29 | } else if (col < 12)
|
---|
| 30 | return(row); /* 0..23 = key 0..23 */
|
---|
| 31 | else if ((col > 11) AND (col < 22))
|
---|
| 32 | return(row + 24); /* 24..47 = key 24..47 */
|
---|
| 33 | else if ((col > 21) AND (col < 32))
|
---|
| 34 | return(row + 48); /* 48..71 = key 48..71 */
|
---|
| 35 | else if ((col > 31) AND (col < 42))
|
---|
| 36 | return(row + 72); /* 72..95 = key 72..95 */
|
---|
| 37 | else if ((col > 41) AND (col < 53))
|
---|
| 38 | return(row + 96); /* 96..119 = key 96..119 */
|
---|
| 39 | else if ((col > 52) AND (row < 8))
|
---|
| 40 | return(row + 120); /* 120..127 = key 120..127 */
|
---|
| 41 | else if (col > 52) {
|
---|
| 42 |
|
---|
| 43 | if ((row EQ 9) OR (row EQ 10))
|
---|
| 44 | return(-2); /* -2 = transpose and copy */
|
---|
| 45 | else if (row EQ 12)
|
---|
| 46 | return(-3); /* -3 = increment */
|
---|
| 47 | else if (row EQ 14)
|
---|
| 48 | return(-4); /* -4 = interpolate */
|
---|
| 49 | else if (row EQ 16)
|
---|
| 50 | return(-5); /* -5 = undo */
|
---|
| 51 | else if (row EQ 18)
|
---|
| 52 | return(-6); /* -6 = value */
|
---|
| 53 | else if (row EQ 20)
|
---|
| 54 | return(-7); /* -7 = store */
|
---|
| 55 | else if (row EQ 22)
|
---|
| 56 | return(-8); /* -8 = retrieve */
|
---|
| 57 | else
|
---|
| 58 | return(-10); /* -10 = not a field */
|
---|
[599d89b] | 59 | } else
|
---|
| 60 | return(-10); /* -10 = not a field */
|
---|
[f40a309] | 61 | }
|
---|
| 62 |
|
---|
| 63 | /*
|
---|
| 64 | =============================================================================
|
---|
| 65 | et_tpch() -- load the edit buffer
|
---|
| 66 | =============================================================================
|
---|
| 67 | */
|
---|
| 68 |
|
---|
[7258c6a] | 69 | int16_t et_tpch(int16_t nn)
|
---|
[f40a309] | 70 | {
|
---|
[7258c6a] | 71 | register int16_t key, val;
|
---|
[f40a309] | 72 |
|
---|
[7ecfb7b] | 73 | (void)nn;
|
---|
| 74 |
|
---|
[f40a309] | 75 | key = loc2key(stcrow, stccol);
|
---|
| 76 |
|
---|
| 77 | if (key < 0)
|
---|
| 78 | return(FAILURE);
|
---|
| 79 |
|
---|
| 80 | val = tuntab[key];
|
---|
| 81 | cnvc2p(ebuf, (val >> 1));
|
---|
| 82 | ebflag = TRUE;
|
---|
| 83 | return(SUCCESS);
|
---|
| 84 | }
|
---|
| 85 |
|
---|
| 86 | /*
|
---|
| 87 | =============================================================================
|
---|
| 88 | ef_tpch() -- unload (parse) edit buffer
|
---|
| 89 | =============================================================================
|
---|
| 90 | */
|
---|
| 91 |
|
---|
[7258c6a] | 92 | int16_t ef_tpch(int16_t nn)
|
---|
[f40a309] | 93 | {
|
---|
[7258c6a] | 94 | register int16_t key;
|
---|
[f40a309] | 95 |
|
---|
[7ecfb7b] | 96 | (void)nn;
|
---|
| 97 |
|
---|
[f40a309] | 98 | ebflag = FALSE;
|
---|
| 99 | key = loc2key(stcrow, stccol);
|
---|
| 100 |
|
---|
| 101 | if (key < 0)
|
---|
| 102 | return(FAILURE);
|
---|
| 103 |
|
---|
| 104 | if (cnvp2c() EQ FAILURE)
|
---|
| 105 | return(FAILURE);
|
---|
| 106 |
|
---|
| 107 | modtun();
|
---|
| 108 | tuntab[key] = cents << 1;
|
---|
| 109 | return(SUCCESS);
|
---|
| 110 | }
|
---|
| 111 |
|
---|
| 112 | /*
|
---|
| 113 | =============================================================================
|
---|
| 114 | rd_tpch() -- (re)display the field
|
---|
| 115 | =============================================================================
|
---|
| 116 | */
|
---|
| 117 |
|
---|
[7258c6a] | 118 | int16_t rd_tpch(int16_t nn)
|
---|
[f40a309] | 119 | {
|
---|
[7258c6a] | 120 | register int16_t val, key, n;
|
---|
[f40a309] | 121 |
|
---|
| 122 | n = nn & 0xFF;
|
---|
| 123 | key = loc2key(cfetp->frow, cfetp->flcol);
|
---|
| 124 | val = tuntab[key];
|
---|
| 125 |
|
---|
| 126 | cnvc2p(dspbuf, (val >> 1));
|
---|
| 127 |
|
---|
[4b63bf3] | 128 | dspbuf[0] = (int8_t)(dspbuf[0] + '0');
|
---|
| 129 | dspbuf[1] = (int8_t)(dspbuf[1] + 'A');
|
---|
[f40a309] | 130 | dspbuf[2] = sfdsp[dspbuf[2] - 7];
|
---|
[4b63bf3] | 131 | dspbuf[3] = (int8_t)(dspbuf[3] + '0');
|
---|
| 132 | dspbuf[4] = (int8_t)(dspbuf[4] + '0');
|
---|
[f40a309] | 133 | dspbuf[5] = '\0';
|
---|
| 134 |
|
---|
| 135 | vbank(0);
|
---|
| 136 | vcputsv(tunob, 64,
|
---|
| 137 | ((val EQ 320) OR (val EQ 21920))
|
---|
| 138 | ? TDMKEYC : tdbox[n][4], tdbox[n][5],
|
---|
| 139 | cfetp->frow, cfetp->flcol, dspbuf, 14);
|
---|
| 140 |
|
---|
| 141 | return(SUCCESS);
|
---|
| 142 | }
|
---|
| 143 |
|
---|
| 144 | /*
|
---|
| 145 | =============================================================================
|
---|
| 146 | nd_tpch() -- handle new data entry
|
---|
| 147 | =============================================================================
|
---|
| 148 | */
|
---|
| 149 |
|
---|
[7258c6a] | 150 | int16_t nd_tpch(int16_t nn, int16_t k)
|
---|
[f40a309] | 151 | {
|
---|
[7258c6a] | 152 | register int16_t col, n;
|
---|
[f40a309] | 153 |
|
---|
| 154 | n = nn & 0xFF;
|
---|
| 155 |
|
---|
| 156 | if (stccol < 11)
|
---|
| 157 | col = stccol - 6;
|
---|
| 158 | else if (stccol < 21)
|
---|
| 159 | col = stccol - 16;
|
---|
| 160 | else if (stccol < 31)
|
---|
| 161 | col = stccol - 26;
|
---|
| 162 | else if (stccol < 41)
|
---|
| 163 | col = stccol - 36;
|
---|
| 164 | else if (stccol < 52)
|
---|
| 165 | col = stccol - 47;
|
---|
| 166 | else
|
---|
| 167 | col = stccol - 58;
|
---|
| 168 |
|
---|
| 169 | switch (col) {
|
---|
| 170 |
|
---|
| 171 | case 0:
|
---|
| 172 |
|
---|
[4b63bf3] | 173 | ebuf[0] = (int8_t)k;
|
---|
| 174 | dspbuf[0] = (int8_t)(k + '0');
|
---|
[f40a309] | 175 | break;
|
---|
| 176 |
|
---|
| 177 | case 1:
|
---|
| 178 |
|
---|
| 179 | if (k GT 6)
|
---|
| 180 | return(FAILURE);
|
---|
| 181 |
|
---|
[4b63bf3] | 182 | ebuf[1] = (int8_t)k;
|
---|
| 183 | dspbuf[0] = (int8_t)(k + 'A');
|
---|
[f40a309] | 184 | break;
|
---|
[fa38804] | 185 |
|
---|
[f40a309] | 186 | case 2:
|
---|
| 187 |
|
---|
| 188 | if (k EQ 7) { /* blank */
|
---|
| 189 |
|
---|
[4b63bf3] | 190 | ebuf[2] = (int8_t)k;
|
---|
[f40a309] | 191 | dspbuf[0] = sfdsp[0];
|
---|
| 192 | break;
|
---|
| 193 |
|
---|
| 194 | } else if (k EQ 8) { /* flat */
|
---|
| 195 |
|
---|
[4b63bf3] | 196 | ebuf[2] = (int8_t)k;
|
---|
[f40a309] | 197 | dspbuf[0] = sfdsp[1];
|
---|
| 198 | break;
|
---|
| 199 |
|
---|
| 200 | } else if (k EQ 9) { /* sharp */
|
---|
| 201 |
|
---|
[4b63bf3] | 202 | ebuf[2] = (int8_t)k;
|
---|
[f40a309] | 203 | dspbuf[0] = sfdsp[2];
|
---|
| 204 | break;
|
---|
| 205 |
|
---|
| 206 | } else
|
---|
| 207 | return(FAILURE);
|
---|
[fa38804] | 208 |
|
---|
[f40a309] | 209 | case 3:
|
---|
| 210 | case 4:
|
---|
| 211 |
|
---|
[4b63bf3] | 212 | ebuf[col] = (int8_t)k;
|
---|
| 213 | dspbuf[0] = (int8_t)(k + '0');
|
---|
[f40a309] | 214 | break;
|
---|
| 215 | }
|
---|
| 216 |
|
---|
| 217 | dspbuf[1] = '\0';
|
---|
| 218 |
|
---|
| 219 | vbank(0);
|
---|
| 220 | vcputsv(tunob, 64, TDENTRY, tdbox[n][5], stcrow, stccol, dspbuf, 14);
|
---|
| 221 |
|
---|
| 222 | if (col EQ 4)
|
---|
| 223 | return(SUCCESS);
|
---|
| 224 |
|
---|
| 225 | advtcur();
|
---|
| 226 | return(SUCCESS);
|
---|
| 227 | }
|
---|
[6262b5c] | 228 |
|
---|