[f40a309] | 1 | /*
|
---|
| 2 | =============================================================================
|
---|
| 3 | etwhrv.c -- waveshape editor - harmonic value field handlers
|
---|
| 4 | Version 12 -- 1988-09-09 -- D.N. Lynx Crowe
|
---|
| 5 | =============================================================================
|
---|
| 6 | */
|
---|
| 7 |
|
---|
| 8 | #include "stddefs.h"
|
---|
| 9 | #include "fields.h"
|
---|
| 10 | #include "vsdd.h"
|
---|
| 11 | #include "vsddsw.h"
|
---|
| 12 | #include "graphdef.h"
|
---|
| 13 | #include "charset.h"
|
---|
| 14 |
|
---|
| 15 | #include "midas.h"
|
---|
| 16 | #include "instdsp.h"
|
---|
| 17 | #include "wsdsp.h"
|
---|
| 18 |
|
---|
[0580615] | 19 | extern void advwcur(void);
|
---|
| 20 | extern void wdswin(short n);
|
---|
[f40a309] | 21 |
|
---|
| 22 | extern unsigned *waveob;
|
---|
| 23 |
|
---|
| 24 | extern short stcrow, stccol, curwhrv, curvce, curwslt, curwhrm;
|
---|
| 25 |
|
---|
| 26 | extern short wdbox[][8];
|
---|
| 27 |
|
---|
| 28 | extern char dspbuf[];
|
---|
| 29 |
|
---|
| 30 | extern struct instdef vbufs[];
|
---|
| 31 |
|
---|
| 32 | extern short wsnmod[12][2];
|
---|
| 33 |
|
---|
| 34 | extern short vmtab[NUMHARM];
|
---|
| 35 |
|
---|
| 36 | /* |
---|
| 37 |
|
---|
| 38 | */
|
---|
| 39 |
|
---|
| 40 | /*
|
---|
| 41 | =============================================================================
|
---|
| 42 | et_whrv() -- load the edit buffer
|
---|
| 43 | =============================================================================
|
---|
| 44 | */
|
---|
[0580615] | 45 |
|
---|
[f40a309] | 46 | short et_whrv(short n)
|
---|
| 47 | {
|
---|
| 48 | register short harv;
|
---|
| 49 | register char hvsgn;
|
---|
| 50 |
|
---|
| 51 | if (curwhrv LT 0) {
|
---|
| 52 |
|
---|
| 53 | hvsgn = '-';
|
---|
| 54 | harv = -curwhrv;
|
---|
| 55 |
|
---|
| 56 | } else {
|
---|
| 57 |
|
---|
| 58 | hvsgn = '+';
|
---|
| 59 | harv = curwhrv;
|
---|
| 60 | }
|
---|
| 61 |
|
---|
| 62 | sprintf(ebuf, "%c%03d", hvsgn, harv);
|
---|
| 63 | ebflag = TRUE;
|
---|
| 64 |
|
---|
| 65 | return(SUCCESS);
|
---|
| 66 | }
|
---|
| 67 |
|
---|
| 68 | /* |
---|
| 69 |
|
---|
| 70 | */
|
---|
| 71 |
|
---|
| 72 | /*
|
---|
| 73 | =============================================================================
|
---|
| 74 | ef_whrv() -- parse (unload) the edit buffer
|
---|
| 75 | =============================================================================
|
---|
[0580615] | 76 | */
|
---|
[f40a309] | 77 |
|
---|
| 78 | short ef_whrv(short n)
|
---|
| 79 | {
|
---|
| 80 | register short *hv;
|
---|
| 81 | register short i, tmpval;
|
---|
| 82 |
|
---|
| 83 | ebuf[4] = '\0'; /* terminate the string in ebuf */
|
---|
| 84 | ebflag = FALSE;
|
---|
| 85 |
|
---|
| 86 | tmpval = 0;
|
---|
| 87 |
|
---|
| 88 | for (i = 1; i < 4; i++) /* convert from ASCII to binary */
|
---|
| 89 | tmpval = (tmpval * 10) + (ebuf[i] - '0');
|
---|
| 90 |
|
---|
| 91 | if (tmpval GT 100)
|
---|
| 92 | return(FAILURE);
|
---|
| 93 |
|
---|
| 94 | if (ebuf[0] EQ '-')
|
---|
| 95 | curwhrv = -tmpval;
|
---|
| 96 | else
|
---|
| 97 | curwhrv = tmpval;
|
---|
| 98 |
|
---|
| 99 | hv = curwslt ? vbufs[curvce].idhwvbh : vbufs[curvce].idhwvah;
|
---|
| 100 | hv[curwhrm] = curwhrv;
|
---|
| 101 | vmtab[curwhrm] = curwhrv;
|
---|
| 102 | adj(curwhrm);
|
---|
| 103 | wscalc();
|
---|
| 104 | whupd();
|
---|
| 105 | wsnmod[curvce][curwslt] = TRUE;
|
---|
| 106 | wdswin(0);
|
---|
| 107 | wdswin(2);
|
---|
| 108 | wdswin(4);
|
---|
| 109 | return(SUCCESS);
|
---|
| 110 | }
|
---|
| 111 |
|
---|
| 112 | /* |
---|
| 113 |
|
---|
| 114 | */
|
---|
| 115 |
|
---|
| 116 | /*
|
---|
| 117 | =============================================================================
|
---|
| 118 | rd_whrv() -- (re)display the field
|
---|
[0580615] | 119 | =============================================================================
|
---|
[f40a309] | 120 | */
|
---|
| 121 |
|
---|
| 122 | short rd_whrv(short nn)
|
---|
| 123 | {
|
---|
| 124 | register short harv, n;
|
---|
| 125 | register char hvsgn;
|
---|
| 126 |
|
---|
| 127 | n = nn & 0x00FF;
|
---|
| 128 |
|
---|
| 129 | if (curwhrv LT 0) {
|
---|
| 130 |
|
---|
| 131 | hvsgn = '-';
|
---|
| 132 | harv = -curwhrv;
|
---|
| 133 |
|
---|
| 134 | } else {
|
---|
| 135 |
|
---|
| 136 | hvsgn = '+';
|
---|
| 137 | harv = curwhrv;
|
---|
| 138 | }
|
---|
| 139 |
|
---|
| 140 | sprintf(dspbuf, "%c%03d", hvsgn, harv);
|
---|
| 141 |
|
---|
| 142 | vbank(0); /* display the value */
|
---|
| 143 | vcputsv(waveob, 64, wdbox[n][4], wdbox[n][5],
|
---|
| 144 | wdbox[n][6] + 1, wdbox[n][7] + WHRV_OFF, dspbuf, 14);
|
---|
| 145 |
|
---|
| 146 | return(SUCCESS);
|
---|
| 147 | }
|
---|
| 148 |
|
---|
| 149 | /* |
---|
| 150 |
|
---|
| 151 | */
|
---|
| 152 |
|
---|
| 153 | /*
|
---|
| 154 | =============================================================================
|
---|
[0580615] | 155 | nd_whrv() -- handle new data entry
|
---|
[f40a309] | 156 | =============================================================================
|
---|
| 157 | */
|
---|
| 158 |
|
---|
| 159 | short nd_whrv(short nn, short k)
|
---|
| 160 | {
|
---|
| 161 | register short ec, n;
|
---|
| 162 |
|
---|
| 163 | n = nn & 0x00FF;
|
---|
| 164 | ec = stccol - cfetp->flcol; /* setup edit buffer column */
|
---|
| 165 |
|
---|
| 166 | if (ec EQ 0) {
|
---|
| 167 |
|
---|
| 168 | if (k EQ 8) {
|
---|
| 169 |
|
---|
| 170 | ebuf[0] = dspbuf[0] = '-';
|
---|
| 171 | ebuf[4] = dspbuf[1] = '\0';
|
---|
| 172 |
|
---|
| 173 | } else if (k EQ 9) {
|
---|
| 174 |
|
---|
| 175 | ebuf[0] = dspbuf[0] = '+';
|
---|
| 176 | ebuf[4] = dspbuf[1] = '\0';
|
---|
| 177 |
|
---|
| 178 | } else {
|
---|
| 179 |
|
---|
| 180 | return(FAILURE);
|
---|
| 181 | }
|
---|
| 182 |
|
---|
| 183 | } else {
|
---|
| 184 |
|
---|
| 185 | ebuf[ec] = dspbuf[0] = k + '0';
|
---|
| 186 | ebuf[4] = dspbuf[1] = '\0';
|
---|
| 187 | }
|
---|
| 188 |
|
---|
| 189 | vbank(0);
|
---|
| 190 | vcputsv(waveob, 64, WS_ENTRY, wdbox[n][5],
|
---|
| 191 | stcrow, stccol, dspbuf, 14);
|
---|
| 192 |
|
---|
| 193 | advwcur();
|
---|
| 194 | return(SUCCESS);
|
---|
| 195 | }
|
---|