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