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