source: buchla-68k/ram/etipnt.c@ 0c834c5

Last change on this file since 0c834c5 was 0580615, checked in by Thomas Lopatic <thomas@…>, 7 years ago

Point of no return.

  • Property mode set to 100644
File size: 4.1 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 "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
19extern void advicur(void);
20extern void pntsel(void);
21extern void showpt(short q);
22extern short timeto(short fn, short pj);
23extern void setseg(short pn, unsigned ptime);
24
25extern unsigned *instob;
26
27extern short stccol, subj, curvce, curfunc, curpnt;
28
29extern short idbox[][8];
30
31extern char dspbuf[];
32
33extern struct instdef vbufs[];
34
35extern struct instpnt *pntptr;
36
37/*
38
39*/
40
41/*
42 =============================================================================
43 et_ipnt() -- load the edit buffer
44 =============================================================================
45*/
46
47short et_ipnt(short 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 =============================================================================
63*/
64
65short ef_ipnt(short n)
66{
67 register short 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
146 =============================================================================
147*/
148
149short rd_ipnt(short 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 =============================================================================
167 nd_ipnt() -- handle new data entry
168 =============================================================================
169*/
170
171short nd_ipnt(short n, short k)
172{
173 register short 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}
Note: See TracBrowser for help on using the repository browser.