source: buchla-68k/ram/etipnt.c

Last change on this file was 7c0efb6, checked in by Thomas Lopatic <thomas@…>, 6 years ago

Fixed etipnt.c.

  • Property mode set to 100644
File size: 3.6 KB
Line 
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 "ram.h"
11
12/*
13 =============================================================================
14 et_ipnt() -- load the edit buffer
15 =============================================================================
16*/
17
18int16_t et_ipnt(int16_t n)
19{
20 (void)n;
21
22 sprintf(ebuf, "%02d", subj);
23 ebflag = TRUE;
24
25 return(SUCCESS);
26}
27
28/*
29 =============================================================================
30 ef_ipnt() -- parse (unload) the edit buffer
31 =============================================================================
32*/
33
34int16_t ef_ipnt(int16_t n)
35{
36 register int16_t i, tmpval, endpnt, basept;
37 register struct idfnhdr *fp;
38 register struct instdef *ip;
39
40 (void)n;
41
42 ip = &vbufs[curvce]; /* set instrument pointer */
43 fp = &ip->idhfnc[curfunc]; /* set function pointer */
44
45 ebuf[2] = '\0'; /* terminate the string in ebuf */
46 ebflag = FALSE;
47
48 tmpval = 0;
49
50 for (i = 0; i < 2; i++) /* convert from ASCII to binary */
51 tmpval = (tmpval * 10) + (ebuf[i] - '0');
52
53 basept = fp->idfpt1;
54 endpnt = fp->idfpt1 + fp->idfpif - 1; /* calculate last point */
55#if DEBUGIT
56 printf("ef_ipnt(): subj=%d, basept=%d, tmpval=%d, endpnt=%d, idpif=%d\r\n",
57 subj, basept, tmpval, endpnt, fp->idfpif);
58#endif
59 if (tmpval GE fp->idfpif) { /* see if we want a new point */
60
61 if (fp->idfpif EQ 100) { /* can't do it if we're full */
62
63 showpt(1);
64 return(FAILURE);
65 }
66#if DEBUGIT
67 printf("ef_ipnt(): NEW POINT REQUESTED\r\n");
68#endif
69 if (FALSE EQ inspnt(ip, curfunc, endpnt)) { /* try to add it */
70#if DEBUGIT
71 printf("ef_ipnt(): inspnt() returned FALSE -- no point allocated\r\n");
72#endif
73 showpt(1);
74 return(FAILURE);
75
76 } else {
77
78 subj = fp->idfpif - 1; /* make it the current point */
79 pntsel();
80 memset(pntptr, 0, sizeof (struct instpnt));
81 pntptr->ipval = (pntptr - 1)->ipval;
82 setseg(subj, timeto(curfunc, subj - 1) + 1);
83 showpt(1);
84#if DEBUGIT
85 printf("ef_ipnt(): NEW POINT SELECTED curpnt=%d, subj=%d, idpif=%d\r\n",
86 curpnt, subj, fp->idfpif);
87#endif
88 modinst();
89 return(SUCCESS);
90 }
91
92 } else { /* old point requested */
93#if DEBUGIT
94 printf("ef_ipnt(): OLD POINT REQUESTED\r\n");
95#endif
96 if ((tmpval + basept) > endpnt) /* check range */
97 return(FAILURE);
98
99 subj = tmpval; /* make it current */
100 pntsel();
101 showpt(1);
102#if DEBUGIT
103 printf("ef_ipnt(): OLD POINT SELECTED curpnt=%d, subj=%d\r\n",
104 curpnt, subj);
105#endif
106 return(SUCCESS);
107 }
108}
109
110/*
111 =============================================================================
112 rd_ipnt() -- (re)display the point number
113 =============================================================================
114*/
115
116int16_t rd_ipnt(int16_t n)
117{
118 sprintf(dspbuf, "%02d", subj); /* convert to ASCII */
119
120 vbank(0); /* display the value */
121
122 vcputsv(instob, 64, idbox[n][4], idbox[n][5],
123 idbox[n][6] + 1, idbox[n][7], dspbuf, 14);
124
125 return(SUCCESS);
126}
127
128/*
129 =============================================================================
130 nd_ipnt() -- handle new data entry
131 =============================================================================
132*/
133
134int16_t nd_ipnt(int16_t n, int16_t k)
135{
136 register int16_t ec;
137
138 ec = stccol - cfetp->flcol; /* setup edit buffer column */
139 ebuf[ec] = (int8_t)(k + '0');
140 ebuf[2] = '\0';
141
142 dspbuf[0] = (int8_t)(k + '0');
143 dspbuf[1] = '\0';
144
145 vbank(0);
146
147 vcputsv(instob, 64, ID_ENTRY, idbox[n][5],
148 idbox[n][6] + 1, stccol, dspbuf, 14);
149
150 advicur();
151
152 return(SUCCESS);
153}
154
Note: See TracBrowser for help on using the repository browser.