SoundUnit: add 64K chip revision
This commit is contained in:
parent
1f57d09fbf
commit
0d4f20b7a6
|
@ -54,7 +54,7 @@ void SoundUnit::NextSample(short* l, short* r) {
|
|||
chan[i].pcmpos=chan[i].pcmrst;
|
||||
}
|
||||
}
|
||||
chan[i].pcmpos&=(SOUNDCHIP_PCM_SIZE-1);
|
||||
chan[i].pcmpos&=(pcmSize-1);
|
||||
} else if (chan[i].flags.pcmloop) {
|
||||
chan[i].pcmpos=chan[i].pcmrst;
|
||||
}
|
||||
|
@ -228,9 +228,10 @@ void SoundUnit::NextSample(short* l, short* r) {
|
|||
*r=minval(32767,maxval(-32767,tnsR));
|
||||
}
|
||||
|
||||
void SoundUnit::Init() {
|
||||
void SoundUnit::Init(int sampleMemSize) {
|
||||
pcmSize=sampleMemSize;
|
||||
Reset();
|
||||
memset(pcm,0,SOUNDCHIP_PCM_SIZE);
|
||||
memset(pcm,0,pcmSize);
|
||||
for (int i=0; i<256; i++) {
|
||||
SCsine[i]=sin((i/128.0f)*M_PI)*127;
|
||||
SCtriangle[i]=(i>127)?(255-i):(i);
|
||||
|
@ -242,9 +243,6 @@ void SoundUnit::Init() {
|
|||
SCpantabR[128+i]=i-1;
|
||||
}
|
||||
SCpantabR[128]=0;
|
||||
for (int i=0; i<8; i++) {
|
||||
muted[i]=false;
|
||||
}
|
||||
}
|
||||
|
||||
void SoundUnit::Reset() {
|
||||
|
@ -282,6 +280,8 @@ void SoundUnit::Write(unsigned char addr, unsigned char data) {
|
|||
}
|
||||
|
||||
SoundUnit::SoundUnit() {
|
||||
Init();
|
||||
memset(pcm,0,SOUNDCHIP_PCM_SIZE);
|
||||
Init(65536); // default
|
||||
for (int i=0; i<8; i++) {
|
||||
muted[i]=false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,8 +3,6 @@
|
|||
#include <math.h>
|
||||
#include <assert.h>
|
||||
|
||||
#define SOUNDCHIP_PCM_SIZE 8192
|
||||
|
||||
class SoundUnit {
|
||||
signed char SCsine[256];
|
||||
signed char SCtriangle[256];
|
||||
|
@ -24,6 +22,7 @@ class SoundUnit {
|
|||
int tnsL, tnsR;
|
||||
unsigned short oldfreq[8];
|
||||
unsigned short oldflags[8];
|
||||
unsigned int pcmSize;
|
||||
public:
|
||||
unsigned short resetfreq[8];
|
||||
unsigned short voldcycles[8];
|
||||
|
@ -84,7 +83,7 @@ class SoundUnit {
|
|||
unsigned short wc;
|
||||
unsigned short restimer;
|
||||
} chan[8];
|
||||
signed char pcm[SOUNDCHIP_PCM_SIZE];
|
||||
signed char pcm[65536];
|
||||
bool muted[8];
|
||||
void Write(unsigned char addr, unsigned char data);
|
||||
void NextSample(short* l, short* r);
|
||||
|
@ -94,7 +93,7 @@ class SoundUnit {
|
|||
if (ret>32767) ret=32767;
|
||||
return ret;
|
||||
}
|
||||
void Init();
|
||||
void Init(int sampleMemSize=8192);
|
||||
void Reset();
|
||||
SoundUnit();
|
||||
};
|
||||
|
|
|
@ -555,6 +555,11 @@ void DivPlatformSoundUnit::setFlags(unsigned int flags) {
|
|||
for (int i=0; i<8; i++) {
|
||||
oscBuf[i]->rate=rate;
|
||||
}
|
||||
|
||||
sampleMemSize=flags&16;
|
||||
|
||||
su->Init(sampleMemSize?65536:8192);
|
||||
renderSamples();
|
||||
}
|
||||
|
||||
void DivPlatformSoundUnit::poke(unsigned int addr, unsigned short val) {
|
||||
|
@ -570,7 +575,7 @@ const void* DivPlatformSoundUnit::getSampleMem(int index) {
|
|||
}
|
||||
|
||||
size_t DivPlatformSoundUnit::getSampleMemCapacity(int index) {
|
||||
return (index==0)?8192:0;
|
||||
return (index==0)?(sampleMemSize?65536:8192):0;
|
||||
}
|
||||
|
||||
size_t DivPlatformSoundUnit::getSampleMemUsage(int index) {
|
||||
|
@ -583,6 +588,7 @@ void DivPlatformSoundUnit::renderSamples() {
|
|||
size_t memPos=0;
|
||||
for (int i=0; i<parent->song.sampleLen; i++) {
|
||||
DivSample* s=parent->song.sample[i];
|
||||
if (s->data8==NULL) continue;
|
||||
int paddedLen=s->samples;
|
||||
if (memPos>=getSampleMemCapacity(0)) {
|
||||
logW("out of PCM memory for sample %d!",i);
|
||||
|
@ -609,9 +615,8 @@ int DivPlatformSoundUnit::init(DivEngine* p, int channels, int sugRate, unsigned
|
|||
isMuted[i]=false;
|
||||
oscBuf[i]=new DivDispatchOscBuffer;
|
||||
}
|
||||
setFlags(flags);
|
||||
su=new SoundUnit();
|
||||
su->Init();
|
||||
setFlags(flags);
|
||||
reset();
|
||||
return 6;
|
||||
}
|
||||
|
|
|
@ -96,6 +96,7 @@ class DivPlatformSoundUnit: public DivDispatch {
|
|||
};
|
||||
std::queue<QueuedWrite> writes;
|
||||
unsigned char lastPan;
|
||||
bool sampleMemSize;
|
||||
|
||||
int cycles, curChan, delay;
|
||||
short tempL;
|
||||
|
|
|
@ -120,6 +120,23 @@ void FurnaceGUI::drawSysConf(int chan, DivSystem type, unsigned int& flags, bool
|
|||
}
|
||||
break;
|
||||
}
|
||||
case DIV_SYSTEM_SOUND_UNIT: {
|
||||
ImGui::Text("CPU rate:");
|
||||
if (ImGui::RadioButton("6.18MHz (NTSC)",(flags&15)==0)) {
|
||||
copyOfFlags=(flags&(~15))|0;
|
||||
}
|
||||
if (ImGui::RadioButton("5.95MHz (PAL)",(flags&15)==1)) {
|
||||
copyOfFlags=(flags&(~15))|1;
|
||||
}
|
||||
ImGui::Text("Chip revision (sample memory):");
|
||||
if (ImGui::RadioButton("A/B/E (8K)",(flags&16)==0)) {
|
||||
copyOfFlags=(flags&(~16))|0;
|
||||
}
|
||||
if (ImGui::RadioButton("D/F (64K)",(flags&16)==16)) {
|
||||
copyOfFlags=(flags&(~16))|16;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case DIV_SYSTEM_GB: {
|
||||
bool antiClick=flags&8;
|
||||
if (ImGui::Checkbox("Disable anti-click",&antiClick)) {
|
||||
|
|
Loading…
Reference in New Issue