[f40a309] | 1 | /*
|
---|
| 2 | =============================================================================
|
---|
| 3 | etipnt.c -- instrument editor - point number field handlers
|
---|
| 4 | Version 15 -- 1988-01-13 -- 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 void pntsel(void);
|
---|
[7258c6a] | 21 | extern void showpt(int16_t q);
|
---|
| 22 | extern int16_t timeto(int16_t fn, int16_t pj);
|
---|
| 23 | extern void setseg(int16_t pn, uint16_t ptime);
|
---|
[f40a309] | 24 |
|
---|
[7258c6a] | 25 | extern uint16_t *instob;
|
---|
[f40a309] | 26 |
|
---|
[7258c6a] | 27 | extern int16_t stccol, subj, curvce, curfunc, curpnt;
|
---|
[f40a309] | 28 |
|
---|
[7258c6a] | 29 | extern int16_t idbox[][8];
|
---|
[f40a309] | 30 |
|
---|
[7258c6a] | 31 | extern int8_t dspbuf[];
|
---|
[f40a309] | 32 |
|
---|
| 33 | extern struct instdef vbufs[];
|
---|
| 34 |
|
---|
| 35 | extern struct instpnt *pntptr;
|
---|
| 36 |
|
---|
| 37 | /* |
---|
| 38 |
|
---|
| 39 | */
|
---|
| 40 |
|
---|
| 41 | /*
|
---|
| 42 | =============================================================================
|
---|
| 43 | et_ipnt() -- load the edit buffer
|
---|
| 44 | =============================================================================
|
---|
| 45 | */
|
---|
[7258c6a] | 46 |
|
---|
[f40a309] | 47 | int16_t et_ipnt(int16_t n)
|
---|
| 48 | {
|
---|
| 49 | sprintf(ebuf, "%02d", subj);
|
---|
| 50 | ebflag = TRUE;
|
---|
| 51 |
|
---|
| 52 | return(SUCCESS);
|
---|
| 53 | }
|
---|
| 54 |
|
---|
| 55 | /* |
---|
| 56 |
|
---|
| 57 | */
|
---|
| 58 |
|
---|
| 59 | /*
|
---|
| 60 | =============================================================================
|
---|
| 61 | ef_ipnt() -- parse (unload) the edit buffer
|
---|
| 62 | =============================================================================
|
---|
[7258c6a] | 63 | */
|
---|
[f40a309] | 64 |
|
---|
[7258c6a] | 65 | int16_t ef_ipnt(int16_t n)
|
---|
[f40a309] | 66 | {
|
---|
| 67 | register int16_t i, tmpval, endpnt, basept;
|
---|
| 68 | register struct idfnhdr *fp;
|
---|
| 69 | register struct instdef *ip;
|
---|
| 70 |
|
---|
| 71 | ip = &vbufs[curvce]; /* set instrument pointer */
|
---|
| 72 | fp = &ip->idhfnc[curfunc]; /* set function pointer */
|
---|
| 73 |
|
---|
| 74 | ebuf[2] = '\0'; /* terminate the string in ebuf */
|
---|
| 75 | ebflag = FALSE;
|
---|
| 76 |
|
---|
| 77 | tmpval = 0;
|
---|
| 78 |
|
---|
| 79 | for (i = 0; i < 2; i++) /* convert from ASCII to binary */
|
---|
| 80 | tmpval = (tmpval * 10) + (ebuf[i] - '0');
|
---|
| 81 |
|
---|
| 82 | basept = fp->idfpt1;
|
---|
| 83 | endpnt = fp->idfpt1 + fp->idfpif - 1; /* calculate last point */
|
---|
| 84 | #if DEBUGIT
|
---|
| 85 | printf("ef_ipnt(): subj=%d, basept=%d, tmpval=%d, endpnt=%d, idpif=%d\r\n",
|
---|
| 86 | subj, basept, tmpval, endpnt, fp->idfpif);
|
---|
| 87 | #endif
|
---|
| 88 | if (tmpval GE fp->idfpif) { /* see if we want a new point */
|
---|
| 89 |
|
---|
| 90 | if (fp->idfpif EQ 100) { /* can't do it if we're full */
|
---|
| 91 |
|
---|
| 92 | showpt(1);
|
---|
| 93 | return(FAILURE);
|
---|
| 94 | }
|
---|
| 95 | #if DEBUGIT
|
---|
| 96 | printf("ef_ipnt(): NEW POINT REQUESTED\r\n");
|
---|
| 97 | #endif
|
---|
| 98 | if (FALSE EQ inspnt(ip, curfunc, endpnt)) { /* try to add it */
|
---|
| 99 | #if DEBUGIT
|
---|
| 100 | printf("ef_ipnt(): inspnt() returned FALSE -- no point allocated\r\n");
|
---|
| 101 | #endif
|
---|
| 102 | showpt(1);
|
---|
| 103 | return(FAILURE);
|
---|
| 104 |
|
---|
| 105 | } else {
|
---|
| 106 |
|
---|
| 107 | subj = fp->idfpif - 1; /* make it the current point */
|
---|
| 108 | pntsel();
|
---|
| 109 | memset(pntptr, 0, sizeof (struct instpnt));
|
---|
| 110 | pntptr->ipval = (pntptr - 1)->ipval;
|
---|
| 111 | setseg(subj, timeto(curfunc, subj - 1) + 1);
|
---|
| 112 | showpt(1);
|
---|
| 113 | #if DEBUGIT
|
---|
| 114 | printf("ef_ipnt(): NEW POINT SELECTED curpnt=%d, subj=%d, idpif=%d\r\n",
|
---|
| 115 | curpnt, subj, fp->idfpif);
|
---|
| 116 | #endif
|
---|
| 117 | modinst();
|
---|
| 118 | return(SUCCESS);
|
---|
| 119 | }
|
---|
| 120 |
|
---|
| 121 | } else { /* old point requested */
|
---|
| 122 | #if DEBUGIT
|
---|
| 123 | printf("ef_ipnt(): OLD POINT REQUESTED\r\n");
|
---|
| 124 | #endif
|
---|
| 125 | if ((tmpval + basept) > endpnt) /* check range */
|
---|
| 126 | return(FAILURE);
|
---|
| 127 |
|
---|
| 128 | subj = tmpval; /* make it current */
|
---|
| 129 | pntsel();
|
---|
| 130 | showpt(1);
|
---|
| 131 | #if DEBUGIT
|
---|
| 132 | printf("ef_ipnt(): OLD POINT SELECTED curpnt=%d, subj=%d\r\n",
|
---|
| 133 | curpnt, subj);
|
---|
| 134 | #endif
|
---|
| 135 | return(SUCCESS);
|
---|
| 136 | }
|
---|
| 137 | }
|
---|
| 138 |
|
---|
| 139 | /* |
---|
| 140 |
|
---|
| 141 | */
|
---|
| 142 |
|
---|
| 143 | /*
|
---|
| 144 | =============================================================================
|
---|
| 145 | rd_ipnt() -- (re)display the point number
|
---|
[7258c6a] | 146 | =============================================================================
|
---|
[f40a309] | 147 | */
|
---|
| 148 |
|
---|
| 149 | int16_t rd_ipnt(int16_t n)
|
---|
| 150 | {
|
---|
| 151 | sprintf(dspbuf, "%02d", subj); /* 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 | return(SUCCESS);
|
---|
| 159 | }
|
---|
| 160 |
|
---|
| 161 | /* |
---|
| 162 |
|
---|
| 163 | */
|
---|
| 164 |
|
---|
| 165 | /*
|
---|
| 166 | =============================================================================
|
---|
[7258c6a] | 167 | nd_ipnt() -- handle new data entry
|
---|
[f40a309] | 168 | =============================================================================
|
---|
[7258c6a] | 169 | */
|
---|
[f40a309] | 170 |
|
---|
| 171 | int16_t nd_ipnt(int16_t n, int16_t k)
|
---|
| 172 | {
|
---|
| 173 | register int16_t ec;
|
---|
| 174 |
|
---|
| 175 | ec = stccol - cfetp->flcol; /* setup edit buffer column */
|
---|
| 176 | ebuf[ec] = k + '0';
|
---|
| 177 | ebuf[2] = '\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 | return(SUCCESS);
|
---|
| 190 | }
|
---|