emu2413, part 1

missing:
- patches
- chan osc
This commit is contained in:
tildearrow 2024-04-05 17:01:50 -05:00
parent 129237fb2c
commit dc2daccf05

View file

@ -94,6 +94,20 @@ void DivPlatformOPLL::acquire_ymfm(short** buf, size_t len) {
}
void DivPlatformOPLL::acquire_emu(short** buf, size_t len) {
thread_local int os;
for (size_t h=0; h<len; h++) {
if (!writes.empty()) {
QueuedWrite& w=writes.front();
OPLL_writeReg(fm_emu,w.addr,w.val);
writes.pop();
}
os=OPLL_calc(fm_emu)<<1;
if (os<-32768) os=-32768;
if (os>32767) os=32767;
buf[0][h]=os;
}
}
void DivPlatformOPLL::acquire(short** buf, size_t len) {
@ -1103,10 +1117,18 @@ void DivPlatformOPLL::setFlags(const DivConfig& flags) {
chipClock=COLOR_NTSC;
}
CHECK_CUSTOM_CLOCK;
rate=chipClock/36;
patchSet=flags.getInt("patchSet",0);
if (selCore==1) {
rate=chipClock/72;
} else {
rate=chipClock/36;
}
for (int i=0; i<11; i++) {
oscBuf[i]->rate=rate/2;
if (selCore==1) {
oscBuf[i]->rate=rate;
} else {
oscBuf[i]->rate=rate/2;
}
}
noTopHatFreq=flags.getBool("noTopHatFreq",false);
fixedAll=flags.getBool("fixedAll",true);
@ -1117,6 +1139,12 @@ int DivPlatformOPLL::init(DivEngine* p, int channels, int sugRate, const DivConf
dumpWrites=false;
skipRegisterWrites=false;
patchSet=0;
fm_emu=NULL;
if (selCore==1) {
fm_emu=OPLL_new(72,1);
OPLL_setChipType(fm_emu,vrc7?1:0);
}
for (int i=0; i<11; i++) {
isMuted[i]=false;
oscBuf[i]=new DivDispatchOscBuffer;
@ -1131,6 +1159,10 @@ void DivPlatformOPLL::quit() {
for (int i=0; i<11; i++) {
delete oscBuf[i];
}
if (fm_emu!=NULL) {
OPLL_delete(fm_emu);
fm_emu=NULL;
}
}
DivPlatformOPLL::~DivPlatformOPLL() {