source: buchla-68k/ram/etitim.c@ 081eee0

Last change on this file since 081eee0 was 8a3cab0, checked in by Thomas Lopatic <thomas@…>, 7 years ago

Fixed etitim.c.

  • Property mode set to 100644
File size: 3.4 KB
RevLine 
[f40a309]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
[b28a12e]10#include "ram.h"
[f40a309]11
12/*
13 =============================================================================
14 et_itim() -- load the edit buffer
15 =============================================================================
16*/
17
[7258c6a]18int16_t et_itim(int16_t n)
[f40a309]19{
[7258c6a]20 register int16_t th, tl;
21 register int32_t tt, sc;
[f40a309]22
[7ecfb7b]23 (void)n;
24
[f40a309]25 pntsel(); /* make sure edit limits are current */
26
27 sc = 1000L;
28 tt = timeto(curfunc, subj);
[8a3cab0]29 th = (int16_t)(tt / sc);
30 tl = (int16_t)(tt - (th * sc));
[f40a309]31
32 sprintf(ebuf, "%02d.%03d", th, tl);
33 ebflag = TRUE;
34#if DEBUGIT
35 printf("et_itim(): voice=%d, func=%d, pnt=%d, ebuf=[%s]\r\n",
36 curvce, curfunc, curpnt, ebuf);
37 printf("et_itim(): npts=%d, subj=%d, case=%d, min=%d, max=%d\r\n",
38 npts, subj, pecase, temin, temax);
39#endif
40 return(SUCCESS);
41}
42
43/*
44 =============================================================================
45 ef_itim() -- parse (unload) the edit buffer
46 =============================================================================
47*/
48
[7258c6a]49int16_t ef_itim(int16_t n)
[f40a309]50{
[7ecfb7b]51 register int16_t i;
[7258c6a]52 register uint16_t tmpval;
[f40a309]53
[7ecfb7b]54 (void)n;
[f40a309]55
56 ebuf[2] = '.'; /* add implied decimal point */
57 ebuf[6] = '\0'; /* terminate the string in ebuf */
58 ebflag = FALSE;
59#if DEBUGIT
60 printf("ef_itim(): voice=%d, func=%d, ebuf=[%s]\r\n",
61 curvce, curfunc, ebuf);
62#endif
63 tmpval = 0;
64
65 for (i = 0; i < 2; i++) /* convert from ASCII to binary */
[8a3cab0]66 tmpval = (tmpval * 10) + (uint16_t)(ebuf[i] - '0');
[f40a309]67
68 for (i = 3; i < 6; i++)
[8a3cab0]69 tmpval = (tmpval * 10) + (uint16_t)(ebuf[i] - '0');
[f40a309]70#if DEBUGIT
71 printf("ef_itim(): subj=%d, case=%d, min=%d, val=%d, max=%d\r\n",
72 subj, pecase, temin, tmpval, temax);
73#endif
[fa50076]74 if (tmpval > temax)
[f40a309]75 return(FAILURE);
76
[fa50076]77 if (tmpval < temin)
[f40a309]78 return(FAILURE);
79
80 setseg(subj, tmpval);
81
82 if (pecase EQ 2)
83 setseg(subj + 1, temax);
84#if DEBUGIT
85 printf("ef_itim(): SUCCESS time %d set at point %d <%d> = %d\r\n",
86 tmpval, subj, curpnt, timeto(curfunc, subj));
87#endif
88 modinst();
89 return(SUCCESS);
90}
91
92/*
93 =============================================================================
94 rd_itim() -- (re)display the field
95 =============================================================================
96*/
97
[7258c6a]98int16_t rd_itim(int16_t n)
[f40a309]99{
[7258c6a]100 register int16_t th, tl;
101 register int32_t tt, sc;
[f40a309]102
103 sc = 1000L;
104 tt = timeto(curfunc, subj);
[8a3cab0]105 th = (int16_t)(tt / sc);
106 tl = (int16_t)(tt - (th * sc));
[f40a309]107
108 sprintf(dspbuf, "%02d.%03d", th, tl); /* convert to ASCII */
109
110 vbank(0); /* display the value */
111
112 vcputsv(instob, 64, idbox[n][4], idbox[n][5],
113 idbox[n][6] + 1, idbox[n][7], dspbuf, 14);
114
115 edfunc(curfunc);
116 return(SUCCESS);
117}
118
119/*
120 =============================================================================
121 nd_itim() -- handle new data entry
122 =============================================================================
123*/
124
[7258c6a]125int16_t nd_itim(int16_t n, int16_t k)
[f40a309]126{
[7258c6a]127 register int16_t ec;
[f40a309]128
129 ec = stccol - cfetp->flcol; /* setup edit buffer column */
130
131 if (ec EQ 2)
132 return(FAILURE);
133
[8a3cab0]134 ebuf[ec] = (int8_t)(k + '0');
[f40a309]135 ebuf[2] = '.';
136 ebuf[6] = '\0';
137
[8a3cab0]138 dspbuf[0] = (int8_t)(k + '0');
[f40a309]139 dspbuf[1] = '\0';
140
141 vbank(0);
142
143 vcputsv(instob, 64, ID_ENTRY, idbox[n][5],
144 idbox[n][6] + 1, stccol, dspbuf, 14);
145
146 advicur();
147
148 if (stccol EQ (idbox[n][7] + 2))
149 advicur();
150
151 return(SUCCESS);
152}
[6262b5c]153
Note: See TracBrowser for help on using the repository browser.