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