source: buchla-68k/orig/RAM/PUTEQ.C@ c93e44d

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

Imported original source code.

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