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