-
Notifications
You must be signed in to change notification settings - Fork 0
/
pcm.c
50 lines (47 loc) · 1.34 KB
/
pcm.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include <genesis.h>
#include <pcm.h>
static void pcm_writeDAC(u8 sample);
void pcm_stream(void)
{
YM2612_writeReg(0, 0x28, 0); // All channels off
YM2612_writeReg(0, 0x28, 1);
YM2612_writeReg(0, 0x28, 2);
YM2612_writeReg(0, 0x28, 4);
YM2612_writeReg(0, 0x28, 5);
YM2612_writeReg(0, 0x28, 6);
YM2612_writeReg(0, 0x90, 0);
YM2612_writeReg(0, 0x94, 0);
YM2612_writeReg(0, 0x98, 0);
YM2612_writeReg(0, 0x9C, 0);
YM2612_enableDAC();
SYS_disableInts();
for (;;) {
while (!ssf_usb_rd_ready())
;
pcm_writeDAC(ssf_usb_read());
}
}
static void pcm_writeDAC(u8 sample)
{
vs8* pb;
pb = (s8*)YM2612_BASEPORT;
__asm__ volatile("nop"); // Wait for YM2612 to be ready...
__asm__ volatile("nop"); // 2
__asm__ volatile("nop"); // 3
__asm__ volatile("nop"); // 4
__asm__ volatile("nop"); // 5
__asm__ volatile("nop"); // 6
__asm__ volatile("nop"); // 7
__asm__ volatile("nop"); // 8
__asm__ volatile("nop"); // 9
__asm__ volatile("nop"); // 10
__asm__ volatile("nop"); // 11
__asm__ volatile("nop"); // 12
__asm__ volatile("nop"); // 13
__asm__ volatile("nop"); // 14
__asm__ volatile("nop"); // 15
__asm__ volatile("nop"); // 16
__asm__ volatile("nop"); // 17 - Sweet spot for 32,000 Hz!
pb[0] = 0x2A;
pb[1] = sample;
}