source: buchla-68k/ram/etipnt.c@ 39a696b

Last change on this file since 39a696b was 6262b5c, checked in by Thomas Lopatic <thomas@…>, 7 years ago

Added include files for global functions and variables.

  • 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 "all.h"
11
12extern void advicur(void);
13extern void pntsel(void);
14extern void showpt(int16_t q);
15extern int16_t timeto(int16_t fn, int16_t pj);
16extern void setseg(int16_t pn, uint16_t ptime);
17
18extern int16_t inspnt(struct instdef *ip, int16_t fn, int16_t inpnt);
19extern void modinst(void);
20
21extern uint16_t *instob;
22
23extern int16_t stccol, subj, curvce, curfunc, curpnt;
24
25extern int16_t idbox[][8];
26
27extern int8_t dspbuf[];
28
29extern struct instdef vbufs[];
30
31extern struct instpnt *pntptr;
32
33/*
34
35*/
36
37/*
38 =============================================================================
39 et_ipnt() -- load the edit buffer
40 =============================================================================
41*/
42
43int16_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 =============================================================================
59*/
60
61int16_t ef_ipnt(int16_t n)
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
142 =============================================================================
143*/
144
145int16_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 =============================================================================
163 nd_ipnt() -- handle new data entry
164 =============================================================================
165*/
166
167int16_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
183 advicur();
184
185 return(SUCCESS);
186}
187
Note: See TracBrowser for help on using the repository browser.