| 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
|
|---|
| 52 | char cmdline[32];
|
|---|
| 53 | #endif
|
|---|
| 54 |
|
|---|
| 55 | int8_t 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 |
|
|---|
| 76 | void puteq(int8_t byte)
|
|---|
| 77 | {
|
|---|
| 78 | register int16_t i;
|
|---|
| 79 | register int8_t *psg;
|
|---|
| 80 | register int8_t eqdata;
|
|---|
| 81 |
|
|---|
| 82 | psg = &io_tone;
|
|---|
| 83 |
|
|---|
| 84 | *(psg + PSG_ADDR) = PSG_IOEN; /* setup PSG I/O controls */
|
|---|
| 85 | *(psg + PSG_WRIT) = PSG_IDLE;
|
|---|
| 86 |
|
|---|
| 87 | *(psg + PSG_ADDR) = PSG_PRTB; /* setup EQ control lines */
|
|---|
| 88 | eqdata = EQ_IDL | (*(psg + PSG_READ) & ~EQ_MASK);
|
|---|
| 89 |
|
|---|
| 90 | for (i = 0; i < 8; i++) { /* send out 8 bits */
|
|---|
| 91 |
|
|---|
| 92 | if (byte & 1) /* setup data line from LSB */
|
|---|
| 93 | eqdata |= EQ_DAT; /* "1" */
|
|---|
| 94 | else
|
|---|
| 95 | eqdata &= ~EQ_DAT; /* "0" */
|
|---|
| 96 |
|
|---|
| 97 | eqdata &= ~EQ_CLK; /* set clock low */
|
|---|
| 98 |
|
|---|
| 99 | *(psg + PSG_ADDR) = PSG_PRTB;
|
|---|
| 100 | *(psg + PSG_WRIT) = eqdata;
|
|---|
| 101 |
|
|---|
| 102 | eqdata |= EQ_CLK; /* set clock high */
|
|---|
| 103 |
|
|---|
| 104 | *(psg + PSG_ADDR) = PSG_PRTB;
|
|---|
| 105 | *(psg + PSG_WRIT) = eqdata;
|
|---|
| 106 |
|
|---|
| 107 | byte >>= 1; /* shift next bit into LSB */
|
|---|
| 108 | }
|
|---|
| 109 |
|
|---|
| 110 | eqdata &= ~EQ_STB; /* set strobe low */
|
|---|
| 111 |
|
|---|
| 112 | *(psg + PSG_ADDR) = PSG_PRTB;
|
|---|
| 113 | *(psg + PSG_WRIT) = eqdata;
|
|---|
| 114 |
|
|---|
| 115 | eqdata |= EQ_STB; /* set strobe high */
|
|---|
| 116 |
|
|---|
| 117 | *(psg + PSG_ADDR) = PSG_PRTB;
|
|---|
| 118 | *(psg + PSG_WRIT) = eqdata;
|
|---|
| 119 | }
|
|---|
| 120 |
|
|---|
| 121 | /* |
|---|
| 122 |
|
|---|
| 123 | */
|
|---|
| 124 |
|
|---|
| 125 | void sendeq(int8_t band, int8_t gain)
|
|---|
| 126 | {
|
|---|
| 127 | puteq(band);
|
|---|
| 128 | puteq(gain);
|
|---|
| 129 | }
|
|---|
| 130 |
|
|---|
| 131 | int8_t gain2eq(int16_t gain)
|
|---|
| 132 | {
|
|---|
| 133 | register int8_t eqdat;
|
|---|
| 134 |
|
|---|
| 135 | if (gain > 0)
|
|---|
| 136 | eqdat = eqgaint[gain] | EQ_ADD;
|
|---|
| 137 | else
|
|---|
| 138 | eqdat = eqgaint[-gain];
|
|---|
| 139 |
|
|---|
| 140 | return(eqdat);
|
|---|
| 141 | }
|
|---|
| 142 |
|
|---|
| 143 | /* |
|---|
| 144 |
|
|---|
| 145 | */
|
|---|
| 146 |
|
|---|
| 147 | #if TESTER
|
|---|
| 148 |
|
|---|
| 149 | extern int xtrap15();
|
|---|
| 150 |
|
|---|
| 151 | char ahex[] = "0123456789abcdefABCDEF";
|
|---|
| 152 |
|
|---|
| 153 | /*
|
|---|
| 154 | ============================================================================
|
|---|
| 155 | xdtoi -- convert hex ASCII to an int digit
|
|---|
| 156 | ============================================================================
|
|---|
| 157 | */
|
|---|
| 158 |
|
|---|
| 159 | int
|
|---|
| 160 | xdtoi(c)
|
|---|
| 161 | register int c;
|
|---|
| 162 | {
|
|---|
| 163 | register int i;
|
|---|
| 164 | register char *ap = &ahex[0];
|
|---|
| 165 |
|
|---|
| 166 | for (i = 0; i < 22; i++)
|
|---|
| 167 | if (c EQ *ap++)
|
|---|
| 168 | if (i >15)
|
|---|
| 169 | return(i - 6);
|
|---|
| 170 | else
|
|---|
| 171 | return(i);
|
|---|
| 172 |
|
|---|
| 173 | return(-1);
|
|---|
| 174 | }
|
|---|
| 175 |
|
|---|
| 176 | /* |
|---|
| 177 |
|
|---|
| 178 | */
|
|---|
| 179 |
|
|---|
| 180 | main()
|
|---|
| 181 | {
|
|---|
| 182 | short rc, c, j;
|
|---|
| 183 | register long temp;
|
|---|
| 184 | char gain, band;
|
|---|
| 185 | register char *aptr;
|
|---|
| 186 |
|
|---|
| 187 | printf("\n\nBuchla 700 EQ chip test -- Enter data in hex\n\n");
|
|---|
| 188 |
|
|---|
| 189 | do {
|
|---|
| 190 |
|
|---|
| 191 | printf("Band = ");
|
|---|
| 192 |
|
|---|
| 193 | rc = getln(CON_DEV, MAXLINE, cmdline);
|
|---|
| 194 |
|
|---|
| 195 | if (rc EQ A_CR) {
|
|---|
| 196 |
|
|---|
| 197 | printf("\n");
|
|---|
| 198 |
|
|---|
| 199 | temp = 0L;
|
|---|
| 200 | aptr = cmdline;
|
|---|
| 201 |
|
|---|
| 202 | if (A_CR EQ (*aptr & 0x00FF)) {
|
|---|
| 203 |
|
|---|
| 204 | xtrap15();
|
|---|
| 205 | continue;
|
|---|
| 206 | }
|
|---|
| 207 |
|
|---|
| 208 | if (CTL('G') EQ (*aptr & 0x00FF)) {
|
|---|
| 209 |
|
|---|
| 210 | while (0 EQ BIOS(B_RDAV, CON_DEV))
|
|---|
| 211 | sendeq(band, gain);
|
|---|
| 212 |
|
|---|
| 213 | BIOS(B_GETC, CON_DEV);
|
|---|
| 214 | continue;
|
|---|
| 215 | }
|
|---|
| 216 |
|
|---|
| 217 | while (isxdigit(c = *aptr++))
|
|---|
| 218 | temp = (temp << 4) + xdtoi(c);
|
|---|
| 219 |
|
|---|
| 220 | if (temp > 255) {
|
|---|
| 221 |
|
|---|
| 222 | printf("\nInput must be < 100\n\n");
|
|---|
| 223 | continue;
|
|---|
| 224 | }
|
|---|
| 225 |
|
|---|
| 226 | band = (char)(temp & 0x000000FFL);
|
|---|
| 227 |
|
|---|
| 228 | } else {
|
|---|
| 229 |
|
|---|
| 230 | printf("Huh ?\n\n");
|
|---|
| 231 | continue;
|
|---|
| 232 | }
|
|---|
| 233 | /* |
|---|
| 234 |
|
|---|
| 235 | */
|
|---|
| 236 | printf("Gain = ");
|
|---|
| 237 |
|
|---|
| 238 | rc = getln(CON_DEV, MAXLINE, cmdline);
|
|---|
| 239 |
|
|---|
| 240 | if (rc EQ A_CR) {
|
|---|
| 241 |
|
|---|
| 242 | printf("\n");
|
|---|
| 243 |
|
|---|
| 244 | temp = 0L;
|
|---|
| 245 | aptr = cmdline;
|
|---|
| 246 |
|
|---|
| 247 | if (A_CR EQ (*aptr & 0x00FF)) {
|
|---|
| 248 |
|
|---|
| 249 | xtrap15();
|
|---|
| 250 | continue;
|
|---|
| 251 | }
|
|---|
| 252 |
|
|---|
| 253 | while (isxdigit(c = *aptr++))
|
|---|
| 254 | temp = (temp << 4) + xdtoi(c);
|
|---|
| 255 |
|
|---|
| 256 | if (temp > 255) {
|
|---|
| 257 |
|
|---|
| 258 | printf("\nInput must be < 100\n\n");
|
|---|
| 259 | continue;
|
|---|
| 260 | }
|
|---|
| 261 |
|
|---|
| 262 | gain = (char)(temp & 0x000000FFL);
|
|---|
| 263 |
|
|---|
| 264 | } else {
|
|---|
| 265 |
|
|---|
| 266 | printf("Huh ?\n\n");
|
|---|
| 267 | continue;
|
|---|
| 268 | }
|
|---|
| 269 |
|
|---|
| 270 | sendeq(band, gain);
|
|---|
| 271 | printf("\n");
|
|---|
| 272 |
|
|---|
| 273 | } while (1);
|
|---|
| 274 | }
|
|---|
| 275 |
|
|---|
| 276 | #endif
|
|---|