C64: bind reSIDfp

This commit is contained in:
tildearrow 2022-08-29 03:26:49 -05:00
parent 32050a211f
commit 8d280fd9a3
3 changed files with 56 additions and 13 deletions

View file

@ -218,10 +218,12 @@ void DivDispatchContainer::init(DivSystem sys, DivEngine* eng, int chanCount, do
break;
case DIV_SYSTEM_C64_6581:
dispatch=new DivPlatformC64;
((DivPlatformC64*)dispatch)->setFP(eng->getConfInt("c64Core",1)==1);
((DivPlatformC64*)dispatch)->setChipModel(true);
break;
case DIV_SYSTEM_C64_8580:
dispatch=new DivPlatformC64;
((DivPlatformC64*)dispatch)->setFP(eng->getConfInt("c64Core",1)==1);
((DivPlatformC64*)dispatch)->setChipModel(false);
break;
case DIV_SYSTEM_YM2151:

View file

@ -19,9 +19,10 @@
#include "c64.h"
#include "../engine.h"
#include "sound/c64_fp/siddefs-fp.h"
#include <math.h>
#define rWrite(a,v) if (!skipRegisterWrites) {sid.write(a,v); regPool[(a)&0x1f]=v; if (dumpWrites) {addWrite(a,v);} }
#define rWrite(a,v) if (!skipRegisterWrites) {if (isFP) {sid_fp.write(a,v);} else {sid.write(a,v);}; regPool[(a)&0x1f]=v; if (dumpWrites) {addWrite(a,v);} }
#define CHIP_FREQBASE 524288
@ -63,15 +64,19 @@ const char** DivPlatformC64::getRegisterSheet() {
}
void DivPlatformC64::acquire(short* bufL, short* bufR, size_t start, size_t len) {
int dcOff=sid.get_dc(0);
int dcOff=isFP?0:sid.get_dc(0);
for (size_t i=start; i<start+len; i++) {
sid.clock();
bufL[i]=sid.output();
if (++writeOscBuf>=8) {
writeOscBuf=0;
oscBuf[0]->data[oscBuf[0]->needle++]=(sid.last_chan_out[0]-dcOff)>>5;
oscBuf[1]->data[oscBuf[1]->needle++]=(sid.last_chan_out[1]-dcOff)>>5;
oscBuf[2]->data[oscBuf[2]->needle++]=(sid.last_chan_out[2]-dcOff)>>5;
if (isFP) {
sid_fp.clock(4,&bufL[i]);
} else {
sid.clock();
bufL[i]=sid.output();
if (++writeOscBuf>=8) {
writeOscBuf=0;
oscBuf[0]->data[oscBuf[0]->needle++]=(sid.last_chan_out[0]-dcOff)>>5;
oscBuf[1]->data[oscBuf[1]->needle++]=(sid.last_chan_out[1]-dcOff)>>5;
oscBuf[2]->data[oscBuf[2]->needle++]=(sid.last_chan_out[2]-dcOff)>>5;
}
}
}
}
@ -405,7 +410,11 @@ int DivPlatformC64::dispatch(DivCommand c) {
void DivPlatformC64::muteChannel(int ch, bool mute) {
isMuted[ch]=mute;
sid.set_is_muted(ch,mute);
if (isFP) {
sid_fp.mute(ch,mute);
} else {
sid.set_is_muted(ch,mute);
}
}
void DivPlatformC64::forceIns() {
@ -462,13 +471,21 @@ bool DivPlatformC64::getWantPreNote() {
return true;
}
float DivPlatformC64::getPostAmp() {
return isFP?3.0f:1.0f;
}
void DivPlatformC64::reset() {
for (int i=0; i<3; i++) {
chan[i]=DivPlatformC64::Channel();
chan[i].std.setEngine(parent);
}
sid.reset();
if (isFP) {
sid_fp.reset();
} else {
sid.reset();
}
memset(regPool,0,32);
rWrite(0x18,0x0f);
@ -490,12 +507,24 @@ void DivPlatformC64::poke(std::vector<DivRegWrite>& wlist) {
void DivPlatformC64::setChipModel(bool is6581) {
if (is6581) {
sid.set_chip_model(MOS6581);
if (isFP) {
sid_fp.setChipModel(reSIDfp::MOS6581);
} else {
sid.set_chip_model(MOS6581);
}
} else {
sid.set_chip_model(MOS8580);
if (isFP) {
sid_fp.setChipModel(reSIDfp::MOS8580);
} else {
sid.set_chip_model(MOS8580);
}
}
}
void DivPlatformC64::setFP(bool fp) {
isFP=fp;
}
void DivPlatformC64::setFlags(unsigned int flags) {
switch (flags&0xf) {
case 0x0: // NTSC C64
@ -513,6 +542,10 @@ void DivPlatformC64::setFlags(unsigned int flags) {
for (int i=0; i<3; i++) {
oscBuf[i]->rate=rate/16;
}
if (isFP) {
rate/=4;
sid_fp.setSamplingParameters(chipClock,reSIDfp::DECIMATE,rate,0);
}
}
int DivPlatformC64::init(DivEngine* p, int channels, int sugRate, unsigned int flags) {

View file

@ -23,6 +23,7 @@
#include "../dispatch.h"
#include "../macroInt.h"
#include "sound/c64/sid.h"
#include "sound/c64_fp/SID.h"
class DivPlatformC64: public DivDispatch {
struct Channel {
@ -76,12 +77,17 @@ class DivPlatformC64: public DivDispatch {
unsigned char filtControl, filtRes, vol;
unsigned char writeOscBuf;
int filtCut, resetTime;
bool isFP;
SID sid;
reSIDfp::SID sid_fp;
unsigned char regPool[32];
friend void putDispatchChan(void*,int,int);
void acquire_classic(short* bufL, short* bufR, size_t start, size_t len);
void acquire_fp(short* bufL, short* bufR, size_t start, size_t len);
void updateFilter();
public:
void acquire(short* bufL, short* bufR, size_t start, size_t len);
@ -98,6 +104,7 @@ class DivPlatformC64: public DivDispatch {
void notifyInsChange(int ins);
bool getDCOffRequired();
bool getWantPreNote();
float getPostAmp();
DivMacroInt* getChanMacroInt(int ch);
void notifyInsDeletion(void* ins);
void poke(unsigned int addr, unsigned short val);
@ -105,6 +112,7 @@ class DivPlatformC64: public DivDispatch {
const char** getRegisterSheet();
int init(DivEngine* parent, int channels, int sugRate, unsigned int flags);
void setChipModel(bool is6581);
void setFP(bool fp);
void quit();
~DivPlatformC64();
};