source: buchla-68k/ram/etitim.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.0 KB
Line 
1/*
2 =============================================================================
3 etitim.c -- instrument editor - time field handlers
4 Version 14 -- 1987-12-09 -- 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 short edfunc(short n);
21extern void pntsel(void);
22
23extern unsigned *instob;
24
25extern short stccol, subj, curvce, curfunc, curpnt;
26extern short pecase, npts, temin, temax, pntsv;
27
28extern short idbox[][8];
29
30extern char dspbuf[];
31
32extern struct instdef vbufs[];
33
34extern struct instpnt *pntptr;
35
36/*
37
38*/
39
40/*
41 =============================================================================
42 et_itim() -- load the edit buffer
43 =============================================================================
44*/
45
46short et_itim(short n)
47{
48 register short th, tl;
49 register long tt, sc;
50
51 pntsel(); /* make sure edit limits are current */
52
53 sc = 1000L;
54 tt = timeto(curfunc, subj);
55 th = tt / sc;
56 tl = tt - (th * sc);
57
58 sprintf(ebuf, "%02d.%03d", th, tl);
59 ebflag = TRUE;
60#if DEBUGIT
61 printf("et_itim(): voice=%d, func=%d, pnt=%d, ebuf=[%s]\r\n",
62 curvce, curfunc, curpnt, ebuf);
63 printf("et_itim(): npts=%d, subj=%d, case=%d, min=%d, max=%d\r\n",
64 npts, subj, pecase, temin, temax);
65#endif
66 return(SUCCESS);
67}
68
69/*
70
71*/
72
73/*
74 =============================================================================
75 ef_itim() -- parse (unload) the edit buffer
76 =============================================================================
77*/
78
79short ef_itim(short n)
80{
81 register short i, endpnt, basept;
82 register unsigned tmpval;
83 register struct idfnhdr *fp;
84 register struct instdef *ip;
85
86 ip = &vbufs[curvce]; /* set instrument pointer */
87 fp = &ip->idhfnc[curfunc]; /* set function pointer */
88
89 ebuf[2] = '.'; /* add implied decimal point */
90 ebuf[6] = '\0'; /* terminate the string in ebuf */
91 ebflag = FALSE;
92#if DEBUGIT
93 printf("ef_itim(): voice=%d, func=%d, ebuf=[%s]\r\n",
94 curvce, curfunc, ebuf);
95#endif
96 tmpval = 0;
97
98 for (i = 0; i < 2; i++) /* convert from ASCII to binary */
99 tmpval = (tmpval * 10) + (ebuf[i] - '0');
100
101 for (i = 3; i < 6; i++)
102 tmpval = (tmpval * 10) + (ebuf[i] - '0');
103#if DEBUGIT
104 printf("ef_itim(): subj=%d, case=%d, min=%d, val=%d, max=%d\r\n",
105 subj, pecase, temin, tmpval, temax);
106#endif
107 if (tmpval > (unsigned)temax)
108 return(FAILURE);
109
110 if (tmpval < (unsigned)temin)
111 return(FAILURE);
112
113 setseg(subj, tmpval);
114
115 if (pecase EQ 2)
116 setseg(subj + 1, temax);
117#if DEBUGIT
118 printf("ef_itim(): SUCCESS time %d set at point %d <%d> = %d\r\n",
119 tmpval, subj, curpnt, timeto(curfunc, subj));
120#endif
121 modinst();
122 return(SUCCESS);
123}
124
125/*
126
127*/
128
129/*
130 =============================================================================
131 rd_itim() -- (re)display the field
132 =============================================================================
133*/
134
135short rd_itim(short n)
136{
137 register short th, tl;
138 register long tt, sc;
139
140 sc = 1000L;
141 tt = timeto(curfunc, subj);
142 th = tt / sc;
143 tl = tt - (th * sc);
144
145 sprintf(dspbuf, "%02d.%03d", th, tl); /* convert to ASCII */
146
147 vbank(0); /* display the value */
148
149 vcputsv(instob, 64, idbox[n][4], idbox[n][5],
150 idbox[n][6] + 1, idbox[n][7], dspbuf, 14);
151
152 edfunc(curfunc);
153 return(SUCCESS);
154}
155
156/*
157
158*/
159
160/*
161 =============================================================================
162 nd_itim() -- handle new data entry
163 =============================================================================
164*/
165
166short nd_itim(short n, short k)
167{
168 register short ec;
169
170 ec = stccol - cfetp->flcol; /* setup edit buffer column */
171
172 if (ec EQ 2)
173 return(FAILURE);
174
175 ebuf[ec] = k + '0';
176 ebuf[2] = '.';
177 ebuf[6] = '\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 if (stccol EQ (idbox[n][7] + 2))
190 advicur();
191
192 return(SUCCESS);
193}
Note: See TracBrowser for help on using the repository browser.