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