source: buchla-68k/orig/RAM/ETITIM.C@ c79db87

Last change on this file since c79db87 was 3ae31e9, checked in by Thomas Lopatic <thomas@…>, 8 years ago

Imported original source code.

  • Property mode set to 100755
File size: 4.1 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 short advicur(), edfunc(), pntsel();
20
21extern unsigned *instob;
22
23extern short stccol, subj, curvce, curfunc, curpnt;
24extern short pecase, npts, temin, temax, pntsv;
25
26extern short idbox[][8];
27
28extern char dspbuf[];
29
30extern struct instdef vbufs[];
31
32extern struct instpnt *pntptr;
33
34/*
35
36*/
37
38/*
39 =============================================================================
40 et_itim() -- load the edit buffer
41 =============================================================================
42*/
43
44short
45et_itim(n)
46short 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
80ef_itim(n)
81short n;
82{
83 register short i, endpnt, basept;
84 register unsigned tmpval;
85 register struct idfnhdr *fp;
86 register struct instdef *ip;
87
88 ip = &vbufs[curvce]; /* set instrument pointer */
89 fp = &ip->idhfnc[curfunc]; /* set function pointer */
90
91 ebuf[2] = '.'; /* add implied decimal point */
92 ebuf[6] = '\0'; /* terminate the string in ebuf */
93 ebflag = FALSE;
94#if DEBUGIT
95 printf("ef_itim(): voice=%d, func=%d, ebuf=[%s]\r\n",
96 curvce, curfunc, ebuf);
97#endif
98 tmpval = 0;
99
100 for (i = 0; i < 2; i++) /* convert from ASCII to binary */
101 tmpval = (tmpval * 10) + (ebuf[i] - '0');
102
103 for (i = 3; i < 6; i++)
104 tmpval = (tmpval * 10) + (ebuf[i] - '0');
105#if DEBUGIT
106 printf("ef_itim(): subj=%d, case=%d, min=%d, val=%d, max=%d\r\n",
107 subj, pecase, temin, tmpval, temax);
108#endif
109 if (tmpval > (unsigned)temax)
110 return(FAILURE);
111
112 if (tmpval < (unsigned)temin)
113 return(FAILURE);
114
115 setseg(subj, tmpval);
116
117 if (pecase EQ 2)
118 setseg(subj + 1, temax);
119#if DEBUGIT
120 printf("ef_itim(): SUCCESS time %d set at point %d <%d> = %d\r\n",
121 tmpval, subj, curpnt, timeto(curfunc, subj));
122#endif
123 modinst();
124 return(SUCCESS);
125}
126
127/*
128
129*/
130
131/*
132 =============================================================================
133 rd_itim() -- (re)display the field
134 =============================================================================
135*/
136
137short
138rd_itim(n)
139short n;
140{
141 register short th, tl;
142 register long tt, sc;
143
144 sc = 1000L;
145 tt = timeto(curfunc, subj);
146 th = tt / sc;
147 tl = tt - (th * sc);
148
149 sprintf(dspbuf, "%02d.%03d", th, tl); /* convert to ASCII */
150
151 vbank(0); /* display the value */
152
153 vcputsv(instob, 64, idbox[n][4], idbox[n][5],
154 idbox[n][6] + 1, idbox[n][7], dspbuf, 14);
155
156 edfunc(curfunc);
157 return(SUCCESS);
158}
159
160/*
161
162*/
163
164/*
165 =============================================================================
166 nd_itim() -- handle new data entry
167 =============================================================================
168*/
169
170short
171nd_itim(n, k)
172short n;
173register short k;
174{
175 register short ec;
176
177 ec = stccol - cfetp->flcol; /* setup edit buffer column */
178
179 if (ec EQ 2)
180 return(FAILURE);
181
182 ebuf[ec] = k + '0';
183 ebuf[2] = '.';
184 ebuf[6] = '\0';
185
186 dspbuf[0] = k + '0';
187 dspbuf[1] = '\0';
188
189 vbank(0);
190
191 vcputsv(instob, 64, ID_ENTRY, idbox[n][5],
192 idbox[n][6] + 1, stccol, dspbuf, 14);
193
194 advicur();
195
196 if (stccol EQ (idbox[n][7] + 2))
197 advicur();
198
199 return(SUCCESS);
200}
Note: See TracBrowser for help on using the repository browser.