[f40a309] | 1 | /*
|
---|
| 2 | =============================================================================
|
---|
| 3 | etitim.c -- instrument editor - time field handlers
|
---|
| 4 | Version 14 -- 1987-12-09 -- 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 |
|
---|
| 16 | #include "midas.h"
|
---|
| 17 | #include "instdsp.h"
|
---|
| 18 |
|
---|
[e225e77] | 19 | #include "stdio.h"
|
---|
| 20 |
|
---|
[0580615] | 21 | extern void advicur(void);
|
---|
[7258c6a] | 22 | extern int16_t edfunc(int16_t n);
|
---|
[0580615] | 23 | extern void pntsel(void);
|
---|
[f40a309] | 24 |
|
---|
[e225e77] | 25 | extern int16_t timeto(int16_t fn, int16_t pj);
|
---|
| 26 | extern void modinst(void);
|
---|
| 27 | extern void setseg(int16_t pn, uint16_t ptime);
|
---|
| 28 |
|
---|
[7258c6a] | 29 | extern uint16_t *instob;
|
---|
[f40a309] | 30 |
|
---|
[7258c6a] | 31 | extern int16_t stccol, subj, curvce, curfunc, curpnt;
|
---|
| 32 | extern int16_t pecase, npts, temin, temax, pntsv;
|
---|
[f40a309] | 33 |
|
---|
[7258c6a] | 34 | extern int16_t idbox[][8];
|
---|
[f40a309] | 35 |
|
---|
[7258c6a] | 36 | extern int8_t dspbuf[];
|
---|
[f40a309] | 37 |
|
---|
| 38 | extern struct instdef vbufs[];
|
---|
| 39 |
|
---|
| 40 | extern struct instpnt *pntptr;
|
---|
| 41 |
|
---|
| 42 | /* |
---|
| 43 |
|
---|
| 44 | */
|
---|
| 45 |
|
---|
| 46 | /*
|
---|
| 47 | =============================================================================
|
---|
| 48 | et_itim() -- load the edit buffer
|
---|
| 49 | =============================================================================
|
---|
| 50 | */
|
---|
[7258c6a] | 51 |
|
---|
[f40a309] | 52 | int16_t et_itim(int16_t n)
|
---|
[7258c6a] | 53 | {
|
---|
| 54 | register int16_t th, tl;
|
---|
[f40a309] | 55 | register int32_t tt, sc;
|
---|
| 56 |
|
---|
| 57 | pntsel(); /* make sure edit limits are current */
|
---|
| 58 |
|
---|
| 59 | sc = 1000L;
|
---|
| 60 | tt = timeto(curfunc, subj);
|
---|
| 61 | th = tt / sc;
|
---|
| 62 | tl = tt - (th * sc);
|
---|
| 63 |
|
---|
| 64 | sprintf(ebuf, "%02d.%03d", th, tl);
|
---|
| 65 | ebflag = TRUE;
|
---|
| 66 | #if DEBUGIT
|
---|
| 67 | printf("et_itim(): voice=%d, func=%d, pnt=%d, ebuf=[%s]\r\n",
|
---|
| 68 | curvce, curfunc, curpnt, ebuf);
|
---|
| 69 | printf("et_itim(): npts=%d, subj=%d, case=%d, min=%d, max=%d\r\n",
|
---|
| 70 | npts, subj, pecase, temin, temax);
|
---|
| 71 | #endif
|
---|
| 72 | return(SUCCESS);
|
---|
| 73 | }
|
---|
| 74 |
|
---|
| 75 | /* |
---|
| 76 |
|
---|
| 77 | */
|
---|
| 78 |
|
---|
| 79 | /*
|
---|
| 80 | =============================================================================
|
---|
| 81 | ef_itim() -- parse (unload) the edit buffer
|
---|
| 82 | =============================================================================
|
---|
[7258c6a] | 83 | */
|
---|
[f40a309] | 84 |
|
---|
[7258c6a] | 85 | int16_t ef_itim(int16_t n)
|
---|
| 86 | {
|
---|
[f40a309] | 87 | register int16_t i, endpnt, basept;
|
---|
| 88 | register uint16_t tmpval;
|
---|
| 89 | register struct idfnhdr *fp;
|
---|
| 90 | register struct instdef *ip;
|
---|
| 91 |
|
---|
| 92 | ip = &vbufs[curvce]; /* set instrument pointer */
|
---|
| 93 | fp = &ip->idhfnc[curfunc]; /* set function pointer */
|
---|
| 94 |
|
---|
| 95 | ebuf[2] = '.'; /* add implied decimal point */
|
---|
| 96 | ebuf[6] = '\0'; /* terminate the string in ebuf */
|
---|
| 97 | ebflag = FALSE;
|
---|
| 98 | #if DEBUGIT
|
---|
| 99 | printf("ef_itim(): voice=%d, func=%d, ebuf=[%s]\r\n",
|
---|
| 100 | curvce, curfunc, ebuf);
|
---|
| 101 | #endif
|
---|
| 102 | tmpval = 0;
|
---|
| 103 |
|
---|
| 104 | for (i = 0; i < 2; i++) /* convert from ASCII to binary */
|
---|
| 105 | tmpval = (tmpval * 10) + (ebuf[i] - '0');
|
---|
| 106 |
|
---|
| 107 | for (i = 3; i < 6; i++)
|
---|
| 108 | tmpval = (tmpval * 10) + (ebuf[i] - '0');
|
---|
| 109 | #if DEBUGIT
|
---|
| 110 | printf("ef_itim(): subj=%d, case=%d, min=%d, val=%d, max=%d\r\n",
|
---|
[7258c6a] | 111 | subj, pecase, temin, tmpval, temax);
|
---|
[f40a309] | 112 | #endif
|
---|
| 113 | if (tmpval > (uint16_t)temax)
|
---|
[7258c6a] | 114 | return(FAILURE);
|
---|
[f40a309] | 115 |
|
---|
| 116 | if (tmpval < (uint16_t)temin)
|
---|
| 117 | return(FAILURE);
|
---|
| 118 |
|
---|
| 119 | setseg(subj, tmpval);
|
---|
| 120 |
|
---|
| 121 | if (pecase EQ 2)
|
---|
| 122 | setseg(subj + 1, temax);
|
---|
| 123 | #if DEBUGIT
|
---|
| 124 | printf("ef_itim(): SUCCESS time %d set at point %d <%d> = %d\r\n",
|
---|
| 125 | tmpval, subj, curpnt, timeto(curfunc, subj));
|
---|
| 126 | #endif
|
---|
| 127 | modinst();
|
---|
| 128 | return(SUCCESS);
|
---|
| 129 | }
|
---|
| 130 |
|
---|
| 131 | /* |
---|
| 132 |
|
---|
| 133 | */
|
---|
| 134 |
|
---|
| 135 | /*
|
---|
| 136 | =============================================================================
|
---|
| 137 | rd_itim() -- (re)display the field
|
---|
[7258c6a] | 138 | =============================================================================
|
---|
[f40a309] | 139 | */
|
---|
[7258c6a] | 140 |
|
---|
| 141 | int16_t rd_itim(int16_t n)
|
---|
[f40a309] | 142 | {
|
---|
| 143 | register int16_t th, tl;
|
---|
| 144 | register int32_t tt, sc;
|
---|
| 145 |
|
---|
| 146 | sc = 1000L;
|
---|
| 147 | tt = timeto(curfunc, subj);
|
---|
| 148 | th = tt / sc;
|
---|
| 149 | tl = tt - (th * sc);
|
---|
| 150 |
|
---|
| 151 | sprintf(dspbuf, "%02d.%03d", th, tl); /* convert to ASCII */
|
---|
| 152 |
|
---|
| 153 | vbank(0); /* display the value */
|
---|
| 154 |
|
---|
| 155 | vcputsv(instob, 64, idbox[n][4], idbox[n][5],
|
---|
| 156 | idbox[n][6] + 1, idbox[n][7], dspbuf, 14);
|
---|
| 157 |
|
---|
| 158 | edfunc(curfunc);
|
---|
| 159 | return(SUCCESS);
|
---|
| 160 | }
|
---|
| 161 |
|
---|
| 162 | /* |
---|
| 163 |
|
---|
| 164 | */
|
---|
| 165 |
|
---|
| 166 | /*
|
---|
| 167 | =============================================================================
|
---|
[7258c6a] | 168 | nd_itim() -- handle new data entry
|
---|
[f40a309] | 169 | =============================================================================
|
---|
[7258c6a] | 170 | */
|
---|
[f40a309] | 171 |
|
---|
| 172 | int16_t nd_itim(int16_t n, int16_t k)
|
---|
| 173 | {
|
---|
| 174 | register int16_t ec;
|
---|
| 175 |
|
---|
| 176 | ec = stccol - cfetp->flcol; /* setup edit buffer column */
|
---|
| 177 |
|
---|
| 178 | if (ec EQ 2)
|
---|
| 179 | return(FAILURE);
|
---|
| 180 |
|
---|
| 181 | ebuf[ec] = k + '0';
|
---|
| 182 | ebuf[2] = '.';
|
---|
| 183 | ebuf[6] = '\0';
|
---|
| 184 |
|
---|
| 185 | dspbuf[0] = k + '0';
|
---|
| 186 | dspbuf[1] = '\0';
|
---|
| 187 |
|
---|
| 188 | vbank(0);
|
---|
| 189 |
|
---|
| 190 | vcputsv(instob, 64, ID_ENTRY, idbox[n][5],
|
---|
| 191 | idbox[n][6] + 1, stccol, dspbuf, 14);
|
---|
| 192 |
|
---|
| 193 | advicur();
|
---|
| 194 |
|
---|
| 195 | if (stccol EQ (idbox[n][7] + 2))
|
---|
| 196 | advicur();
|
---|
| 197 |
|
---|
| 198 | return(SUCCESS);
|
---|
| 199 | }
|
---|