source: buchla-68k/ram/puteq.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 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 "all.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
141extern int xtrap15();
142
143char ahex[] = "0123456789abcdefABCDEF";
144
145/*
146 ============================================================================
147 xdtoi -- convert hex ASCII to an int digit
148 ============================================================================
149*/
150
151int
152xdtoi(c)
153register int c;
154{
155 register int i;
156 register char *ap = &ahex[0];
157
158 for (i = 0; i < 22; i++)
159 if (c EQ *ap++)
160 if (i >15)
161 return(i - 6);
162 else
163 return(i);
164
165 return(-1);
166}
167
168/*
169
170*/
171
172main()
173{
174 short rc, c, j;
175 register long temp;
176 char gain, band;
177 register char *aptr;
178
179 printf("\n\nBuchla 700 EQ chip test -- Enter data in hex\n\n");
180
181 do {
182
183 printf("Band = ");
184
185 rc = getln(CON_DEV, MAXLINE, cmdline);
186
187 if (rc EQ A_CR) {
188
189 printf("\n");
190
191 temp = 0L;
192 aptr = cmdline;
193
194 if (A_CR EQ (*aptr & 0x00FF)) {
195
196 xtrap15();
197 continue;
198 }
199
200 if (CTL('G') EQ (*aptr & 0x00FF)) {
201
202 while (0 EQ BIOS(B_RDAV, CON_DEV))
203 sendeq(band, gain);
204
205 BIOS(B_GETC, CON_DEV);
206 continue;
207 }
208
209 while (isxdigit(c = *aptr++))
210 temp = (temp << 4) + xdtoi(c);
211
212 if (temp > 255) {
213
214 printf("\nInput must be < 100\n\n");
215 continue;
216 }
217
218 band = (char)(temp & 0x000000FFL);
219
220 } else {
221
222 printf("Huh ?\n\n");
223 continue;
224 }
225/*
226
227*/
228 printf("Gain = ");
229
230 rc = getln(CON_DEV, MAXLINE, cmdline);
231
232 if (rc EQ A_CR) {
233
234 printf("\n");
235
236 temp = 0L;
237 aptr = cmdline;
238
239 if (A_CR EQ (*aptr & 0x00FF)) {
240
241 xtrap15();
242 continue;
243 }
244
245 while (isxdigit(c = *aptr++))
246 temp = (temp << 4) + xdtoi(c);
247
248 if (temp > 255) {
249
250 printf("\nInput must be < 100\n\n");
251 continue;
252 }
253
254 gain = (char)(temp & 0x000000FFL);
255
256 } else {
257
258 printf("Huh ?\n\n");
259 continue;
260 }
261
262 sendeq(band, gain);
263 printf("\n");
264
265 } while (1);
266}
267
268#endif
269
Note: See TracBrowser for help on using the repository browser.