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

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

Fixed puteq.c.

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