source: buchla-68k/ram/etitim.c@ 6262b5c

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