chip sample selection, part 4

partially works
This commit is contained in:
tildearrow 2022-11-26 23:50:20 -05:00
parent 3a9349d49a
commit cf38680072
28 changed files with 94 additions and 31 deletions

View File

@ -557,8 +557,9 @@ class DivDispatch {
/** /**
* Render samples into sample memory. * Render samples into sample memory.
* @param sysID the chip's index in the chip list.
*/ */
virtual void renderSamples(); virtual void renderSamples(int sysID);
/** /**
* initialize this DivDispatch. * initialize this DivDispatch.

View File

@ -1315,7 +1315,7 @@ void DivEngine::renderSamples() {
// step 2: render samples to dispatch // step 2: render samples to dispatch
for (int i=0; i<song.systemLen; i++) { for (int i=0; i<song.systemLen; i++) {
if (disCont[i].dispatch!=NULL) { if (disCont[i].dispatch!=NULL) {
disCont[i].dispatch->renderSamples(); disCont[i].dispatch->renderSamples(i);
} }
} }
} }

View File

@ -165,7 +165,7 @@ bool DivDispatch::isSampleLoaded(int index, int sample) {
return false; return false;
} }
void DivDispatch::renderSamples() { void DivDispatch::renderSamples(int sysID) {
} }

View File

@ -368,7 +368,7 @@ bool DivPlatformMSM6258::isSampleLoaded(int index, int sample) {
return sampleLoaded[sample]; return sampleLoaded[sample];
} }
void DivPlatformMSM6258::renderSamples() { void DivPlatformMSM6258::renderSamples(int sysID) {
memset(adpcmMem,0,getSampleMemCapacity(0)); memset(adpcmMem,0,getSampleMemCapacity(0));
memset(sampleLoaded,0,256*sizeof(bool)); memset(sampleLoaded,0,256*sizeof(bool));
@ -378,6 +378,8 @@ void DivPlatformMSM6258::renderSamples() {
if (sampleCount>128) sampleCount=128; if (sampleCount>128) sampleCount=128;
for (int i=0; i<sampleCount; i++) { for (int i=0; i<sampleCount; i++) {
DivSample* s=parent->song.sample[i]; DivSample* s=parent->song.sample[i];
if (!s->renderOn[0][sysID]) continue;
int paddedLen=s->lengthVOX; int paddedLen=s->lengthVOX;
if (memPos>=getSampleMemCapacity(0)) { if (memPos>=getSampleMemCapacity(0)) {
logW("out of ADPCM memory for sample %d!",i); logW("out of ADPCM memory for sample %d!",i);

View File

@ -115,7 +115,7 @@ class DivPlatformMSM6258: public DivDispatch {
size_t getSampleMemCapacity(int index); size_t getSampleMemCapacity(int index);
size_t getSampleMemUsage(int index); size_t getSampleMemUsage(int index);
bool isSampleLoaded(int index, int sample); bool isSampleLoaded(int index, int sample);
void renderSamples(); void renderSamples(int chipID);
int init(DivEngine* parent, int channels, int sugRate, const DivConfig& flags); int init(DivEngine* parent, int channels, int sugRate, const DivConfig& flags);
void quit(); void quit();

View File

@ -341,7 +341,7 @@ bool DivPlatformMSM6295::isSampleLoaded(int index, int sample) {
return sampleLoaded[sample]; return sampleLoaded[sample];
} }
void DivPlatformMSM6295::renderSamples() { void DivPlatformMSM6295::renderSamples(int sysID) {
unsigned int sampleOffVOX[256]; unsigned int sampleOffVOX[256];
memset(adpcmMem,0,getSampleMemCapacity(0)); memset(adpcmMem,0,getSampleMemCapacity(0));
@ -354,6 +354,11 @@ void DivPlatformMSM6295::renderSamples() {
if (sampleCount>128) sampleCount=128; if (sampleCount>128) sampleCount=128;
for (int i=0; i<sampleCount; i++) { for (int i=0; i<sampleCount; i++) {
DivSample* s=parent->song.sample[i]; DivSample* s=parent->song.sample[i];
if (!s->renderOn[0][sysID]) {
sampleOffVOX[i]=0;
continue;
}
int paddedLen=s->lengthVOX; int paddedLen=s->lengthVOX;
if (memPos>=getSampleMemCapacity(0)) { if (memPos>=getSampleMemCapacity(0)) {
logW("out of ADPCM memory for sample %d!",i); logW("out of ADPCM memory for sample %d!",i);

View File

@ -103,7 +103,7 @@ class DivPlatformMSM6295: public DivDispatch, public vgsound_emu_mem_intf {
virtual size_t getSampleMemCapacity(int index) override; virtual size_t getSampleMemCapacity(int index) override;
virtual size_t getSampleMemUsage(int index) override; virtual size_t getSampleMemUsage(int index) override;
virtual bool isSampleLoaded(int index, int sample) override; virtual bool isSampleLoaded(int index, int sample) override;
virtual void renderSamples() override; virtual void renderSamples(int chipID) override;
virtual int init(DivEngine* parent, int channels, int sugRate, const DivConfig& flags) override; virtual int init(DivEngine* parent, int channels, int sugRate, const DivConfig& flags) override;
virtual void quit() override; virtual void quit() override;

View File

@ -727,13 +727,18 @@ bool DivPlatformNES::isSampleLoaded(int index, int sample) {
return sampleLoaded[sample]; return sampleLoaded[sample];
} }
void DivPlatformNES::renderSamples() { void DivPlatformNES::renderSamples(int sysID) {
memset(dpcmMem,0,getSampleMemCapacity(0));\ memset(dpcmMem,0,getSampleMemCapacity(0));\
memset(sampleLoaded,0,256*sizeof(bool)); memset(sampleLoaded,0,256*sizeof(bool));
size_t memPos=0; size_t memPos=0;
for (int i=0; i<parent->song.sampleLen; i++) { for (int i=0; i<parent->song.sampleLen; i++) {
DivSample* s=parent->song.sample[i]; DivSample* s=parent->song.sample[i];
if (!s->renderOn[0][sysID]) {
sampleOffDPCM[i]=0;
continue;
}
unsigned int paddedLen=(s->lengthDPCM+63)&(~0x3f); unsigned int paddedLen=(s->lengthDPCM+63)&(~0x3f);
logV("%d padded length: %d",i,paddedLen); logV("%d padded length: %d",i,paddedLen);
if ((memPos&(~0x3fff))!=((memPos+paddedLen)&(~0x3fff))) { if ((memPos&(~0x3fff))!=((memPos+paddedLen)&(~0x3fff))) {

View File

@ -117,7 +117,7 @@ class DivPlatformNES: public DivDispatch {
size_t getSampleMemCapacity(int index); size_t getSampleMemCapacity(int index);
size_t getSampleMemUsage(int index); size_t getSampleMemUsage(int index);
bool isSampleLoaded(int index, int sample); bool isSampleLoaded(int index, int sample);
void renderSamples(); void renderSamples(int chipID);
int init(DivEngine* parent, int channels, int sugRate, const DivConfig& flags); int init(DivEngine* parent, int channels, int sugRate, const DivConfig& flags);
void quit(); void quit();
~DivPlatformNES(); ~DivPlatformNES();

View File

@ -1763,7 +1763,7 @@ bool DivPlatformOPL::isSampleLoaded(int index, int sample) {
return sampleLoaded[sample]; return sampleLoaded[sample];
} }
void DivPlatformOPL::renderSamples() { void DivPlatformOPL::renderSamples(int sysID) {
if (adpcmChan<0) return; if (adpcmChan<0) return;
memset(adpcmBMem,0,getSampleMemCapacity(0)); memset(adpcmBMem,0,getSampleMemCapacity(0));
memset(sampleOffB,0,256*sizeof(unsigned int)); memset(sampleOffB,0,256*sizeof(unsigned int));
@ -1772,6 +1772,11 @@ void DivPlatformOPL::renderSamples() {
size_t memPos=0; size_t memPos=0;
for (int i=0; i<parent->song.sampleLen; i++) { for (int i=0; i<parent->song.sampleLen; i++) {
DivSample* s=parent->song.sample[i]; DivSample* s=parent->song.sample[i];
if (!s->renderOn[0][sysID]) {
sampleOffB[i]=0;
continue;
}
int paddedLen=(s->lengthB+255)&(~0xff); int paddedLen=(s->lengthB+255)&(~0xff);
if ((memPos&0xf00000)!=((memPos+paddedLen)&0xf00000)) { if ((memPos&0xf00000)!=((memPos+paddedLen)&0xf00000)) {
memPos=(memPos+0xfffff)&0xf00000; memPos=(memPos+0xfffff)&0xf00000;

View File

@ -154,7 +154,7 @@ class DivPlatformOPL: public DivDispatch {
size_t getSampleMemCapacity(int index); size_t getSampleMemCapacity(int index);
size_t getSampleMemUsage(int index); size_t getSampleMemUsage(int index);
bool isSampleLoaded(int index, int sample); bool isSampleLoaded(int index, int sample);
void renderSamples(); void renderSamples(int chipID);
int init(DivEngine* parent, int channels, int sugRate, const DivConfig& flags); int init(DivEngine* parent, int channels, int sugRate, const DivConfig& flags);
void quit(); void quit();
~DivPlatformOPL(); ~DivPlatformOPL();

View File

@ -651,13 +651,18 @@ bool DivPlatformQSound::isSampleLoaded(int index, int sample) {
} }
// TODO: ADPCM... come on... // TODO: ADPCM... come on...
void DivPlatformQSound::renderSamples() { void DivPlatformQSound::renderSamples(int sysID) {
memset(sampleMem,0,getSampleMemCapacity()); memset(sampleMem,0,getSampleMemCapacity());
memset(sampleLoaded,0,256*sizeof(bool)); memset(sampleLoaded,0,256*sizeof(bool));
size_t memPos=0; size_t memPos=0;
for (int i=0; i<parent->song.sampleLen; i++) { for (int i=0; i<parent->song.sampleLen; i++) {
DivSample* s=parent->song.sample[i]; DivSample* s=parent->song.sample[i];
if (!s->renderOn[0][sysID]) {
offPCM[i]=0;
continue;
}
int length=s->length8; int length=s->length8;
if (length>65536-16) { if (length>65536-16) {
length=65536-16; length=65536-16;

View File

@ -105,7 +105,7 @@ class DivPlatformQSound: public DivDispatch {
size_t getSampleMemCapacity(int index = 0); size_t getSampleMemCapacity(int index = 0);
size_t getSampleMemUsage(int index = 0); size_t getSampleMemUsage(int index = 0);
bool isSampleLoaded(int index, int sample); bool isSampleLoaded(int index, int sample);
void renderSamples(); void renderSamples(int chipID);
int init(DivEngine* parent, int channels, int sugRate, const DivConfig& flags); int init(DivEngine* parent, int channels, int sugRate, const DivConfig& flags);
void quit(); void quit();
}; };

View File

@ -391,7 +391,7 @@ bool DivPlatformRF5C68::isSampleLoaded(int index, int sample) {
return sampleLoaded[sample]; return sampleLoaded[sample];
} }
void DivPlatformRF5C68::renderSamples() { void DivPlatformRF5C68::renderSamples(int sysID) {
memset(sampleMem,0,getSampleMemCapacity()); memset(sampleMem,0,getSampleMemCapacity());
memset(sampleOffRFC,0,256*sizeof(unsigned int)); memset(sampleOffRFC,0,256*sizeof(unsigned int));
memset(sampleLoaded,0,256*sizeof(bool)); memset(sampleLoaded,0,256*sizeof(bool));
@ -399,6 +399,11 @@ void DivPlatformRF5C68::renderSamples() {
size_t memPos=0; size_t memPos=0;
for (int i=0; i<parent->song.sampleLen; i++) { for (int i=0; i<parent->song.sampleLen; i++) {
DivSample* s=parent->song.sample[i]; DivSample* s=parent->song.sample[i];
if (!s->renderOn[0][sysID]) {
sampleOffRFC[i]=0;
continue;
}
int length=s->getLoopEndPosition(DIV_SAMPLE_DEPTH_8BIT); int length=s->getLoopEndPosition(DIV_SAMPLE_DEPTH_8BIT);
int actualLength=MIN((int)(getSampleMemCapacity()-memPos)-31,length); int actualLength=MIN((int)(getSampleMemCapacity()-memPos)-31,length);
if (actualLength>0) { if (actualLength>0) {

View File

@ -101,7 +101,7 @@ class DivPlatformRF5C68: public DivDispatch {
size_t getSampleMemCapacity(int index = 0); size_t getSampleMemCapacity(int index = 0);
size_t getSampleMemUsage(int index = 0); size_t getSampleMemUsage(int index = 0);
bool isSampleLoaded(int index, int sample); bool isSampleLoaded(int index, int sample);
void renderSamples(); void renderSamples(int chipID);
int init(DivEngine* parent, int channels, int sugRate, const DivConfig& flags); int init(DivEngine* parent, int channels, int sugRate, const DivConfig& flags);
void quit(); void quit();
private: private:

View File

@ -451,7 +451,7 @@ void DivPlatformSegaPCM::reset() {
} }
} }
void DivPlatformSegaPCM::renderSamples() { void DivPlatformSegaPCM::renderSamples(int sysID) {
size_t memPos=0; size_t memPos=0;
for (int i=0; i<parent->song.sampleLen; i++) { for (int i=0; i<parent->song.sampleLen; i++) {

View File

@ -110,7 +110,7 @@ class DivPlatformSegaPCM: public DivDispatch {
void tick(bool sysTick=true); void tick(bool sysTick=true);
void muteChannel(int ch, bool mute); void muteChannel(int ch, bool mute);
void notifyInsChange(int ins); void notifyInsChange(int ins);
void renderSamples(); void renderSamples(int chipID);
void setFlags(const DivConfig& flags); void setFlags(const DivConfig& flags);
bool isStereo(); bool isStereo();
void poke(unsigned int addr, unsigned short val); void poke(unsigned int addr, unsigned short val);

View File

@ -803,7 +803,7 @@ bool DivPlatformSNES::isSampleLoaded(int index, int sample) {
return sampleLoaded[sample]; return sampleLoaded[sample];
} }
void DivPlatformSNES::renderSamples() { void DivPlatformSNES::renderSamples(int sysID) {
memset(copyOfSampleMem,0,getSampleMemCapacity()); memset(copyOfSampleMem,0,getSampleMemCapacity());
memset(sampleOff,0,256*sizeof(unsigned int)); memset(sampleOff,0,256*sizeof(unsigned int));
memset(sampleLoaded,0,256*sizeof(bool)); memset(sampleLoaded,0,256*sizeof(bool));
@ -812,6 +812,11 @@ void DivPlatformSNES::renderSamples() {
size_t memPos=sampleTableBase+8*4+8*9*16; size_t memPos=sampleTableBase+8*4+8*9*16;
for (int i=0; i<parent->song.sampleLen; i++) { for (int i=0; i<parent->song.sampleLen; i++) {
DivSample* s=parent->song.sample[i]; DivSample* s=parent->song.sample[i];
if (!s->renderOn[0][sysID]) {
sampleOff[i]=0;
continue;
}
int length=s->lengthBRR; int length=s->lengthBRR;
int actualLength=MIN((int)(getSampleMemCapacity()-memPos)/9*9,length); int actualLength=MIN((int)(getSampleMemCapacity()-memPos)/9*9,length);
if (actualLength>0) { if (actualLength>0) {

View File

@ -138,7 +138,7 @@ class DivPlatformSNES: public DivDispatch {
size_t getSampleMemCapacity(int index = 0); size_t getSampleMemCapacity(int index = 0);
size_t getSampleMemUsage(int index = 0); size_t getSampleMemUsage(int index = 0);
bool isSampleLoaded(int index, int sample); bool isSampleLoaded(int index, int sample);
void renderSamples(); void renderSamples(int chipID);
int init(DivEngine* parent, int channels, int sugRate, const DivConfig& flags); int init(DivEngine* parent, int channels, int sugRate, const DivConfig& flags);
void quit(); void quit();
private: private:

View File

@ -524,7 +524,7 @@ void DivPlatformSoundUnit::setFlags(const DivConfig& flags) {
sampleMemSize=flags.getInt("sampleMemSize",0); sampleMemSize=flags.getInt("sampleMemSize",0);
su->Init(sampleMemSize?65536:8192,flags.getBool("pdm",false)); su->Init(sampleMemSize?65536:8192,flags.getBool("pdm",false));
renderSamples(); renderSamples(sysIDCache);
} }
void DivPlatformSoundUnit::poke(unsigned int addr, unsigned short val) { void DivPlatformSoundUnit::poke(unsigned int addr, unsigned short val) {
@ -553,7 +553,7 @@ bool DivPlatformSoundUnit::isSampleLoaded(int index, int sample) {
return sampleLoaded[sample]; return sampleLoaded[sample];
} }
void DivPlatformSoundUnit::renderSamples() { void DivPlatformSoundUnit::renderSamples(int sysID) {
memset(su->pcm,0,getSampleMemCapacity(0)); memset(su->pcm,0,getSampleMemCapacity(0));
memset(sampleOffSU,0,256*sizeof(unsigned int)); memset(sampleOffSU,0,256*sizeof(unsigned int));
memset(sampleLoaded,0,256*sizeof(bool)); memset(sampleLoaded,0,256*sizeof(bool));
@ -562,6 +562,11 @@ void DivPlatformSoundUnit::renderSamples() {
for (int i=0; i<parent->song.sampleLen; i++) { for (int i=0; i<parent->song.sampleLen; i++) {
DivSample* s=parent->song.sample[i]; DivSample* s=parent->song.sample[i];
if (s->data8==NULL) continue; if (s->data8==NULL) continue;
if (!s->renderOn[0][sysID]) {
sampleOffSU[i]=0;
continue;
}
int paddedLen=s->length8; int paddedLen=s->length8;
if (memPos>=getSampleMemCapacity(0)) { if (memPos>=getSampleMemCapacity(0)) {
logW("out of PCM memory for sample %d!",i); logW("out of PCM memory for sample %d!",i);
@ -578,7 +583,7 @@ void DivPlatformSoundUnit::renderSamples() {
memPos+=paddedLen; memPos+=paddedLen;
} }
sampleMemLen=memPos; sampleMemLen=memPos;
sysIDCache=sysID;
} }
int DivPlatformSoundUnit::init(DivEngine* p, int channels, int sugRate, const DivConfig& flags) { int DivPlatformSoundUnit::init(DivEngine* p, int channels, int sugRate, const DivConfig& flags) {

View File

@ -104,7 +104,7 @@ class DivPlatformSoundUnit: public DivDispatch {
unsigned int sampleOffSU[256]; unsigned int sampleOffSU[256];
bool sampleLoaded[256]; bool sampleLoaded[256];
int cycles, curChan, delay; int cycles, curChan, delay, sysIDCache;
short tempL; short tempL;
short tempR; short tempR;
unsigned char sampleBank, lfoMode, lfoSpeed; unsigned char sampleBank, lfoMode, lfoSpeed;
@ -140,7 +140,7 @@ class DivPlatformSoundUnit: public DivDispatch {
size_t getSampleMemCapacity(int index); size_t getSampleMemCapacity(int index);
size_t getSampleMemUsage(int index); size_t getSampleMemUsage(int index);
bool isSampleLoaded(int index, int sample); bool isSampleLoaded(int index, int sample);
void renderSamples(); void renderSamples(int chipID);
int init(DivEngine* parent, int channels, int sugRate, const DivConfig& flags); int init(DivEngine* parent, int channels, int sugRate, const DivConfig& flags);
void quit(); void quit();
~DivPlatformSoundUnit(); ~DivPlatformSoundUnit();

View File

@ -955,7 +955,7 @@ bool DivPlatformX1_010::isSampleLoaded(int index, int sample) {
return sampleLoaded[sample]; return sampleLoaded[sample];
} }
void DivPlatformX1_010::renderSamples() { void DivPlatformX1_010::renderSamples(int sysID) {
memset(sampleMem,0,getSampleMemCapacity()); memset(sampleMem,0,getSampleMemCapacity());
memset(sampleOffX1,0,256*sizeof(unsigned int)); memset(sampleOffX1,0,256*sizeof(unsigned int));
memset(sampleLoaded,0,256*sizeof(bool)); memset(sampleLoaded,0,256*sizeof(bool));
@ -963,6 +963,11 @@ void DivPlatformX1_010::renderSamples() {
size_t memPos=0; size_t memPos=0;
for (int i=0; i<parent->song.sampleLen; i++) { for (int i=0; i<parent->song.sampleLen; i++) {
DivSample* s=parent->song.sample[i]; DivSample* s=parent->song.sample[i];
if (!s->renderOn[0][sysID]) {
sampleOffX1[i]=0;
continue;
}
int paddedLen=(s->length8+4095)&(~0xfff); int paddedLen=(s->length8+4095)&(~0xfff);
if (isBanked) { if (isBanked) {
// fit sample bank size to 128KB for Seta 2 external bankswitching logic (not emulated yet!) // fit sample bank size to 128KB for Seta 2 external bankswitching logic (not emulated yet!)

View File

@ -148,7 +148,7 @@ class DivPlatformX1_010: public DivDispatch, public vgsound_emu_mem_intf {
size_t getSampleMemCapacity(int index = 0); size_t getSampleMemCapacity(int index = 0);
size_t getSampleMemUsage(int index = 0); size_t getSampleMemUsage(int index = 0);
bool isSampleLoaded(int index, int sample); bool isSampleLoaded(int index, int sample);
void renderSamples(); void renderSamples(int chipID);
const char** getRegisterSheet(); const char** getRegisterSheet();
void setBanked(bool banked); void setBanked(bool banked);
int init(DivEngine* parent, int channels, int sugRate, const DivConfig& flags); int init(DivEngine* parent, int channels, int sugRate, const DivConfig& flags);

View File

@ -1342,7 +1342,7 @@ bool DivPlatformYM2608::isSampleLoaded(int index, int sample) {
return sampleLoaded[sample]; return sampleLoaded[sample];
} }
void DivPlatformYM2608::renderSamples() { void DivPlatformYM2608::renderSamples(int sysID) {
memset(adpcmBMem,0,getSampleMemCapacity(0)); memset(adpcmBMem,0,getSampleMemCapacity(0));
memset(sampleOffB,0,256*sizeof(unsigned int)); memset(sampleOffB,0,256*sizeof(unsigned int));
memset(sampleLoaded,0,256*sizeof(bool)); memset(sampleLoaded,0,256*sizeof(bool));
@ -1350,6 +1350,11 @@ void DivPlatformYM2608::renderSamples() {
size_t memPos=0; size_t memPos=0;
for (int i=0; i<parent->song.sampleLen; i++) { for (int i=0; i<parent->song.sampleLen; i++) {
DivSample* s=parent->song.sample[i]; DivSample* s=parent->song.sample[i];
if (!s->renderOn[0][sysID]) {
sampleOffB[i]=0;
continue;
}
int paddedLen=(s->lengthB+255)&(~0xff); int paddedLen=(s->lengthB+255)&(~0xff);
if ((memPos&0xf00000)!=((memPos+paddedLen)&0xf00000)) { if ((memPos&0xf00000)!=((memPos+paddedLen)&0xf00000)) {
memPos=(memPos+0xfffff)&0xf00000; memPos=(memPos+0xfffff)&0xf00000;

View File

@ -139,7 +139,7 @@ class DivPlatformYM2608: public DivPlatformOPN {
size_t getSampleMemCapacity(int index); size_t getSampleMemCapacity(int index);
size_t getSampleMemUsage(int index); size_t getSampleMemUsage(int index);
bool isSampleLoaded(int index, int sample); bool isSampleLoaded(int index, int sample);
void renderSamples(); void renderSamples(int chipID);
void setFlags(const DivConfig& flags); void setFlags(const DivConfig& flags);
int init(DivEngine* parent, int channels, int sugRate, const DivConfig& flags); int init(DivEngine* parent, int channels, int sugRate, const DivConfig& flags);
void quit(); void quit();

View File

@ -220,7 +220,7 @@ template<int ChanNum> class DivPlatformYM2610Base: public DivPlatformOPN {
return sampleLoaded[index][sample]; return sampleLoaded[index][sample];
} }
void renderSamples() { void renderSamples(int sysID) {
memset(adpcmAMem,0,getSampleMemCapacity(0)); memset(adpcmAMem,0,getSampleMemCapacity(0));
memset(sampleOffA,0,256*sizeof(unsigned int)); memset(sampleOffA,0,256*sizeof(unsigned int));
memset(sampleOffB,0,256*sizeof(unsigned int)); memset(sampleOffB,0,256*sizeof(unsigned int));
@ -229,6 +229,11 @@ template<int ChanNum> class DivPlatformYM2610Base: public DivPlatformOPN {
size_t memPos=0; size_t memPos=0;
for (int i=0; i<parent->song.sampleLen; i++) { for (int i=0; i<parent->song.sampleLen; i++) {
DivSample* s=parent->song.sample[i]; DivSample* s=parent->song.sample[i];
if (!s->renderOn[0][sysID]) {
sampleOffA[i]=0;
continue;
}
int paddedLen=(s->lengthA+255)&(~0xff); int paddedLen=(s->lengthA+255)&(~0xff);
if ((memPos&0xf00000)!=((memPos+paddedLen)&0xf00000)) { if ((memPos&0xf00000)!=((memPos+paddedLen)&0xf00000)) {
memPos=(memPos+0xfffff)&0xf00000; memPos=(memPos+0xfffff)&0xf00000;
@ -254,6 +259,11 @@ template<int ChanNum> class DivPlatformYM2610Base: public DivPlatformOPN {
memPos=0; memPos=0;
for (int i=0; i<parent->song.sampleLen; i++) { for (int i=0; i<parent->song.sampleLen; i++) {
DivSample* s=parent->song.sample[i]; DivSample* s=parent->song.sample[i];
if (!s->renderOn[1][sysID]) {
sampleOffB[i]=0;
continue;
}
int paddedLen=(s->lengthB+255)&(~0xff); int paddedLen=(s->lengthB+255)&(~0xff);
if ((memPos&0xf00000)!=((memPos+paddedLen)&0xf00000)) { if ((memPos&0xf00000)!=((memPos+paddedLen)&0xf00000)) {
memPos=(memPos+0xfffff)&0xf00000; memPos=(memPos+0xfffff)&0xf00000;

View File

@ -426,7 +426,7 @@ bool DivPlatformYMZ280B::isSampleLoaded(int index, int sample) {
return sampleLoaded[sample]; return sampleLoaded[sample];
} }
void DivPlatformYMZ280B::renderSamples() { void DivPlatformYMZ280B::renderSamples(int sysID) {
memset(sampleMem,0,getSampleMemCapacity()); memset(sampleMem,0,getSampleMemCapacity());
memset(sampleOff,0,256*sizeof(unsigned int)); memset(sampleOff,0,256*sizeof(unsigned int));
memset(sampleLoaded,0,256*sizeof(bool)); memset(sampleLoaded,0,256*sizeof(bool));
@ -434,6 +434,11 @@ void DivPlatformYMZ280B::renderSamples() {
size_t memPos=0; size_t memPos=0;
for (int i=0; i<parent->song.sampleLen; i++) { for (int i=0; i<parent->song.sampleLen; i++) {
DivSample* s=parent->song.sample[i]; DivSample* s=parent->song.sample[i];
if (!s->renderOn[0][sysID]) {
sampleOff[i]=0;
continue;
}
int length=s->getCurBufLen(); int length=s->getCurBufLen();
unsigned char* src=(unsigned char*)s->getCurBuf(); unsigned char* src=(unsigned char*)s->getCurBuf();
int actualLength=MIN((int)(getSampleMemCapacity()-memPos),length); int actualLength=MIN((int)(getSampleMemCapacity()-memPos),length);

View File

@ -101,7 +101,7 @@ class DivPlatformYMZ280B: public DivDispatch {
size_t getSampleMemCapacity(int index = 0); size_t getSampleMemCapacity(int index = 0);
size_t getSampleMemUsage(int index = 0); size_t getSampleMemUsage(int index = 0);
bool isSampleLoaded(int index, int sample); bool isSampleLoaded(int index, int sample);
void renderSamples(); void renderSamples(int chipID);
void setFlags(const DivConfig& flags); void setFlags(const DivConfig& flags);
int init(DivEngine* parent, int channels, int sugRate, const DivConfig& flags); int init(DivEngine* parent, int channels, int sugRate, const DivConfig& flags);
void quit(); void quit();