forked from emestee/bk-emulator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsynth.c
48 lines (41 loc) · 852 Bytes
/
synth.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
#include "defines.h"
#include "emu2149.h"
#include <fcntl.h>
#include <stdio.h>
#include <sys/ioctl.h>
#include <libintl.h>
#define _(String) gettext (String)
unsigned char synth_reg;
#define SOUND_FREQ 44100
PSG * psg;
synth_init() {
synth_reg = ~0;
if (!psg) {
PSG_init(3579545, SOUND_FREQ);
psg=PSG_new();
}
PSG_reset(psg);
// PSG_setVolumeMode(psg,2);
}
synth_read(c_addr addr, d_word *word)
{
// *word = PSG_readReg(psg, synth_reg) ^ 0xFF;
*word = 0; // BK does not read from AY
return OK;
}
synth_write(c_addr addr, d_word word)
{
// Writing register address
synth_reg = (word & 0xF) ^ 0xF;
return OK;
}
synth_bwrite(c_addr addr, d_byte byte) {
// Writing data; what happens if the address is odd?
PSG_writeReg(psg, synth_reg, byte ^ 0xFF);
return OK;
}
int
synth_next() {
int a = psg ? PSG_calc(psg) : 0;
return a;
}