source: buchla-68k/ram/puteq.c@ 06f6615

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

Zero redundant declarations.

  • Property mode set to 100644
File size: 3.9 KB
Line 
1/*
2 =============================================================================
3 puteq.c -- output functions for the LMC835 EQ chip on the Buchla 700
4 Version 3 -- 1987-12-10 -- D.N. Lynx Crowe
5 =============================================================================
6*/
7
8#define TESTER 0
9
10#if TESTER
11#define MAXLINE 4
12#endif
13
14#include "ram.h"
15
16#define EQ_STB 0x04
17#define EQ_DAT 0x08
18#define EQ_CLK 0x10
19
20#define EQ_IDL (EQ_STB | EQ_CLK)
21#define EQ_MASK (EQ_STB | EQ_CLK | EQ_DAT)
22
23#define EQ_A6DB 0x20
24#define EQ_B6DB 0x10
25
26#define EQ_6DB (EQ_A6DB | EQ_B6DB)
27
28#define EQ_ADD 0x40
29
30#define PSG_ADDR 0
31#define PSG_READ 0
32#define PSG_WRIT 2
33
34#define PSG_IOEN 7
35#define PSG_IDLE 0xBF
36
37#define PSG_PRTB 15
38
39/*
40
41*/
42
43#if TESTER
44char cmdline[32];
45#endif
46
47int8_t eqgaint[] = {
48
49 0x00, /* 0 db */
50 0x20, /* 1 db */
51 0x10, /* 2 db */
52 0x08, /* 3 db */
53 0x04, /* 4 db */
54 0x02, /* 5 db */
55 0x12, /* 6 db */
56 0x2A, /* 7 db */
57 0x16, /* 8 db */
58 0x01, /* 9 db */
59 0x29, /* 10 db */
60 0x2D, /* 11 db */
61 0x2F /* 12 db */
62};
63
64/*
65
66*/
67
68void puteq(int8_t byte)
69{
70 register int16_t i;
71 register int8_t *psg;
72 register int8_t eqdata;
73
74 psg = &io_tone;
75
76 *(psg + PSG_ADDR) = PSG_IOEN; /* setup PSG I/O controls */
77 *(psg + PSG_WRIT) = PSG_IDLE;
78
79 *(psg + PSG_ADDR) = PSG_PRTB; /* setup EQ control lines */
80 eqdata = EQ_IDL | (*(psg + PSG_READ) & ~EQ_MASK);
81
82 for (i = 0; i < 8; i++) { /* send out 8 bits */
83
84 if (byte & 1) /* setup data line from LSB */
85 eqdata |= EQ_DAT; /* "1" */
86 else
87 eqdata &= ~EQ_DAT; /* "0" */
88
89 eqdata &= ~EQ_CLK; /* set clock low */
90
91 *(psg + PSG_ADDR) = PSG_PRTB;
92 *(psg + PSG_WRIT) = eqdata;
93
94 eqdata |= EQ_CLK; /* set clock high */
95
96 *(psg + PSG_ADDR) = PSG_PRTB;
97 *(psg + PSG_WRIT) = eqdata;
98
99 byte >>= 1; /* shift next bit into LSB */
100 }
101
102 eqdata &= ~EQ_STB; /* set strobe low */
103
104 *(psg + PSG_ADDR) = PSG_PRTB;
105 *(psg + PSG_WRIT) = eqdata;
106
107 eqdata |= EQ_STB; /* set strobe high */
108
109 *(psg + PSG_ADDR) = PSG_PRTB;
110 *(psg + PSG_WRIT) = eqdata;
111}
112
113/*
114
115*/
116
117void sendeq(int8_t band, int8_t gain)
118{
119 puteq(band);
120 puteq(gain);
121}
122
123int8_t gain2eq(int16_t gain)
124{
125 register int8_t eqdat;
126
127 if (gain > 0)
128 eqdat = eqgaint[gain] | EQ_ADD;
129 else
130 eqdat = eqgaint[-gain];
131
132 return(eqdat);
133}
134
135/*
136
137*/
138
139#if TESTER
140
141char ahex[] = "0123456789abcdefABCDEF";
142
143/*
144 ============================================================================
145 xdtoi -- convert hex ASCII to an int digit
146 ============================================================================
147*/
148
149int
150xdtoi(c)
151register int c;
152{
153 register int i;
154 register char *ap = &ahex[0];
155
156 for (i = 0; i < 22; i++)
157 if (c EQ *ap++)
158 if (i >15)
159 return(i - 6);
160 else
161 return(i);
162
163 return(-1);
164}
165
166/*
167
168*/
169
170main()
171{
172 short rc, c, j;
173 register long temp;
174 char gain, band;
175 register char *aptr;
176
177 printf("\n\nBuchla 700 EQ chip test -- Enter data in hex\n\n");
178
179 do {
180
181 printf("Band = ");
182
183 rc = getln(CON_DEV, MAXLINE, cmdline);
184
185 if (rc EQ A_CR) {
186
187 printf("\n");
188
189 temp = 0L;
190 aptr = cmdline;
191
192 if (A_CR EQ (*aptr & 0x00FF)) {
193
194 xtrap15();
195 continue;
196 }
197
198 if (CTL('G') EQ (*aptr & 0x00FF)) {
199
200 while (0 EQ BIOS(B_RDAV, CON_DEV))
201 sendeq(band, gain);
202
203 BIOS(B_GETC, CON_DEV);
204 continue;
205 }
206
207 while (isxdigit(c = *aptr++))
208 temp = (temp << 4) + xdtoi(c);
209
210 if (temp > 255) {
211
212 printf("\nInput must be < 100\n\n");
213 continue;
214 }
215
216 band = (char)(temp & 0x000000FFL);
217
218 } else {
219
220 printf("Huh ?\n\n");
221 continue;
222 }
223/*
224
225*/
226 printf("Gain = ");
227
228 rc = getln(CON_DEV, MAXLINE, cmdline);
229
230 if (rc EQ A_CR) {
231
232 printf("\n");
233
234 temp = 0L;
235 aptr = cmdline;
236
237 if (A_CR EQ (*aptr & 0x00FF)) {
238
239 xtrap15();
240 continue;
241 }
242
243 while (isxdigit(c = *aptr++))
244 temp = (temp << 4) + xdtoi(c);
245
246 if (temp > 255) {
247
248 printf("\nInput must be < 100\n\n");
249 continue;
250 }
251
252 gain = (char)(temp & 0x000000FFL);
253
254 } else {
255
256 printf("Huh ?\n\n");
257 continue;
258 }
259
260 sendeq(band, gain);
261 printf("\n");
262
263 } while (1);
264}
265
266#endif
267
Note: See TracBrowser for help on using the repository browser.