source: buchla-68k/ram/etipnt.c@ 411371e

Last change on this file since 411371e was e225e77, checked in by Thomas Lopatic <thomas@…>, 7 years ago

Added missing includes and declarations.

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