source: buchla-68k/ram/ettval.c@ e225e77

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

Added missing includes and declarations.

  • Property mode set to 100644
File size: 3.5 KB
Line 
1/*
2 =============================================================================
3 ettval.c -- MIDAS tuning editor -- value field handlers
4 Version 2 -- 1987-12-09 -- D.N. Lynx Crowe
5 =============================================================================
6*/
7
8#include "stddefs.h"
9#include "fields.h"
10#include "vsdd.h"
11#include "vsddsw.h"
12#include "graphdef.h"
13#include "charset.h"
14
15#include "midas.h"
16#include "tundsp.h"
17
18#include "stdio.h"
19
20extern void advtcur(void);
21extern void tdswin(int16_t n);
22
23extern uint16_t *tunob;
24
25extern int16_t stcrow, stccol, tunval, tunmod;
26
27extern int16_t tdbox[][8];
28
29extern int8_t dspbuf[];
30
31/*
32
33*/
34
35/*
36 =============================================================================
37 modtun() -- indicate that the tuning table was modified
38 =============================================================================
39*/
40
41void modtun(void)
42{
43 if (NOT tunmod) {
44
45 tunmod = TRUE;
46 tdswin(6);
47 }
48}
49
50/*
51
52*/
53
54/*
55 =============================================================================
56 et_tval() -- load the edit buffer
57 =============================================================================
58*/
59
60int16_t et_tval(int16_t n)
61{
62 register int16_t tv;
63 register int8_t ts;
64
65 tv = (tunval < 0 ? -tunval : tunval) >> 1;
66 ts = tunval < 0 ? '-' : '+';
67
68 sprintf(ebuf, "%c%04d", ts, tv);
69 ebflag = TRUE;
70
71 return(SUCCESS);
72}
73
74/*
75
76*/
77
78/*
79 =============================================================================
80 ef_tval() -- parse (unload) the edit buffer
81 =============================================================================
82*/
83
84int16_t ef_tval(int16_t n)
85{
86 register int16_t *ov;
87 register int16_t i, tmpval, tv;
88 register int8_t ts;
89
90 ebuf[5] = '\0'; /* terminate the string in ebuf */
91 ebflag = FALSE;
92
93 tmpval = 0;
94
95 for (i = 1; i < 5; i++) /* convert from ASCII to binary */
96 tmpval = (tmpval * 10) + (ebuf[i] - '0');
97
98 if (ebuf[0] EQ '-')
99 tunval = -tmpval << 1;
100 else
101 tunval = tmpval << 1;
102
103 tv = (tunval < 0 ? -tunval : tunval) >> 1;
104 ts = tunval < 0 ? '-' : '+';
105 sprintf(dspbuf, "Val %c%04d", ts, tv);
106
107 vbank(0);
108 vcputsv(tunob, 64, tdbox[n][4], tdbox[n][5], 18, 54, dspbuf, 14);
109
110 modtun();
111 return(SUCCESS);
112}
113
114/*
115
116*/
117
118/*
119 =============================================================================
120 rd_tval() -- (re)display the field
121 =============================================================================
122*/
123
124int16_t rd_tval(int16_t nn)
125{
126 register int16_t tv, n;
127 register int8_t ts;
128
129 n = nn & 0xFF;
130
131 tv = (tunval < 0 ? -tunval : tunval) >> 1;
132 ts = tunval < 0 ? '-' : '+';
133
134 sprintf(dspbuf, "Val %c%04d", ts, tv);
135
136 vbank(0);
137 vcputsv(tunob, 64, tdbox[n][4], tdbox[n][5], 18, 54, dspbuf, 14);
138 return(SUCCESS);
139}
140
141/*
142
143*/
144
145/*
146 =============================================================================
147 nd_tval() -- handle new data entry
148 =============================================================================
149*/
150
151int16_t nd_tval(int16_t nn, int16_t k)
152{
153 register int16_t ec, n;
154
155 n = nn & 0xFF;
156 ec = stccol - cfetp->flcol; /* setup edit buffer column */
157
158 if (ec EQ 0) {
159
160 if (k EQ 8) {
161
162 ebuf[0] = '-';
163 ebuf[5] = '\0';
164
165 dspbuf[0] = '-';
166 dspbuf[1] = '\0';
167
168 } else if (k EQ 9) {
169
170 ebuf[0] = '+';
171 ebuf[5] = '\0';
172
173 dspbuf[0] = '+';
174 dspbuf[1] = '\0';
175
176 } else {
177
178 return(FAILURE);
179 }
180/*
181
182*/
183 } else {
184
185 ebuf[ec] = k + '0';
186 ebuf[5] = '\0';
187
188 dspbuf[0] = k + '0';
189 dspbuf[1] = '\0';
190 }
191
192 vbank(0);
193 vcputsv(tunob, 64, TDENTRY, tdbox[n][5], stcrow, stccol, dspbuf, 14);
194
195 advtcur();
196 return(SUCCESS);
197}
198
Note: See TracBrowser for help on using the repository browser.