chip sample selection, part 2

add functions to retrieve whether a sample was loaded in chip memory
eventually I'll put warning feedback on the sample list
This commit is contained in:
tildearrow 2022-11-26 18:44:04 -05:00
parent 1c8440b68d
commit 85cb64b227
29 changed files with 173 additions and 0 deletions

View file

@ -156,6 +156,10 @@ size_t DivDispatch::getSampleMemUsage(int index) {
return 0;
}
bool DivDispatch::isSampleLoaded(int index, int sample) {
return false;
}
void DivDispatch::renderSamples() {
}

View file

@ -362,6 +362,12 @@ size_t DivPlatformMSM6258::getSampleMemUsage(int index) {
return index == 0 ? adpcmMemLen : 0;
}
bool DivPlatformMSM6258::isSampleLoaded(int index, int sample) {
if (index!=0) return false;
if (sample<0 || sample>255) return false;
return sampleLoaded[sample];
}
void DivPlatformMSM6258::renderSamples() {
memset(adpcmMem,0,getSampleMemCapacity(0));

View file

@ -81,6 +81,7 @@ class DivPlatformMSM6258: public DivDispatch {
unsigned char* adpcmMem;
size_t adpcmMemLen;
bool sampleLoaded[256];
unsigned char sampleBank, msmPan, msmDivider, rateSel, msmClock, clockSel;
signed char msmDividerCount, msmClockCount;
short msmOut;
@ -113,6 +114,7 @@ class DivPlatformMSM6258: public DivDispatch {
const void* getSampleMem(int index);
size_t getSampleMemCapacity(int index);
size_t getSampleMemUsage(int index);
bool isSampleLoaded(int index, int sample);
void renderSamples();
int init(DivEngine* parent, int channels, int sugRate, const DivConfig& flags);

View file

@ -335,6 +335,12 @@ size_t DivPlatformMSM6295::getSampleMemUsage(int index) {
return index == 0 ? adpcmMemLen : 0;
}
bool DivPlatformMSM6295::isSampleLoaded(int index, int sample) {
if (index!=0) return false;
if (sample<0 || sample>255) return false;
return sampleLoaded[sample];
}
void DivPlatformMSM6295::renderSamples() {
unsigned int sampleOffVOX[256];

View file

@ -68,6 +68,7 @@ class DivPlatformMSM6295: public DivDispatch, public vgsound_emu_mem_intf {
unsigned char* adpcmMem;
size_t adpcmMemLen;
bool sampleLoaded[256];
unsigned char sampleBank;
int delay, updateOsc;
@ -101,6 +102,7 @@ class DivPlatformMSM6295: public DivDispatch, public vgsound_emu_mem_intf {
virtual const void* getSampleMem(int index) override;
virtual size_t getSampleMemCapacity(int index) override;
virtual size_t getSampleMemUsage(int index) override;
virtual bool isSampleLoaded(int index, int sample) override;
virtual void renderSamples() override;
virtual int init(DivEngine* parent, int channels, int sugRate, const DivConfig& flags) override;

View file

@ -721,6 +721,12 @@ size_t DivPlatformNES::getSampleMemUsage(int index) {
return index==0?dpcmMemLen:0;
}
bool DivPlatformNES::isSampleLoaded(int index, int sample) {
if (index!=0) return false;
if (sample<0 || sample>255) return false;
return sampleLoaded[sample];
}
void DivPlatformNES::renderSamples() {
memset(dpcmMem,0,getSampleMemCapacity(0));

View file

@ -68,6 +68,7 @@ class DivPlatformNES: public DivDispatch {
int dacSample;
unsigned char* dpcmMem;
size_t dpcmMemLen;
bool sampleLoaded[256];
unsigned char dpcmBank;
unsigned char sampleBank;
unsigned char writeOscBuf;
@ -115,6 +116,7 @@ class DivPlatformNES: public DivDispatch {
const void* getSampleMem(int index);
size_t getSampleMemCapacity(int index);
size_t getSampleMemUsage(int index);
bool isSampleLoaded(int index, int sample);
void renderSamples();
int init(DivEngine* parent, int channels, int sugRate, const DivConfig& flags);
void quit();

View file

@ -1757,6 +1757,12 @@ size_t DivPlatformOPL::getSampleMemUsage(int index) {
return (index==0 && adpcmChan>=0) ? adpcmBMemLen : 0;
}
bool DivPlatformOPL::isSampleLoaded(int index, int sample) {
if (index!=0) return false;
if (sample<0 || sample>255) return false;
return sampleLoaded[sample];
}
void DivPlatformOPL::renderSamples() {
if (adpcmChan<0) return;
memset(adpcmBMem,0,getSampleMemCapacity(0));

View file

@ -91,6 +91,7 @@ class DivPlatformOPL: public DivDispatch {
size_t adpcmBMemLen;
DivOPLAInterface iface;
unsigned int sampleOffB[256];
bool sampleLoaded[256];
ymfm::adpcm_b_engine* adpcmB;
const unsigned char** slotsNonDrums;
@ -152,6 +153,7 @@ class DivPlatformOPL: public DivDispatch {
const void* getSampleMem(int index);
size_t getSampleMemCapacity(int index);
size_t getSampleMemUsage(int index);
bool isSampleLoaded(int index, int sample);
void renderSamples();
int init(DivEngine* parent, int channels, int sugRate, const DivConfig& flags);
void quit();

View file

@ -644,6 +644,12 @@ size_t DivPlatformQSound::getSampleMemUsage(int index) {
return index == 0 ? sampleMemLen : 0;
}
bool DivPlatformQSound::isSampleLoaded(int index, int sample) {
if (index!=0) return false;
if (sample<0 || sample>255) return false;
return sampleLoaded[sample];
}
// TODO: ADPCM... come on...
void DivPlatformQSound::renderSamples() {
memset(sampleMem,0,getSampleMemCapacity());

View file

@ -69,6 +69,7 @@ class DivPlatformQSound: public DivDispatch {
unsigned char* sampleMem;
size_t sampleMemLen;
bool sampleLoaded[256];
struct qsound_chip chip;
unsigned short regPool[512];
@ -103,6 +104,7 @@ class DivPlatformQSound: public DivDispatch {
const void* getSampleMem(int index = 0);
size_t getSampleMemCapacity(int index = 0);
size_t getSampleMemUsage(int index = 0);
bool isSampleLoaded(int index, int sample);
void renderSamples();
int init(DivEngine* parent, int channels, int sugRate, const DivConfig& flags);
void quit();

View file

@ -385,6 +385,12 @@ size_t DivPlatformRF5C68::getSampleMemUsage(int index) {
return index == 0 ? sampleMemLen : 0;
}
bool DivPlatformRF5C68::isSampleLoaded(int index, int sample) {
if (index!=0) return false;
if (sample<0 || sample>255) return false;
return sampleLoaded[sample];
}
void DivPlatformRF5C68::renderSamples() {
memset(sampleMem,0,getSampleMemCapacity());
memset(sampleOffRFC,0,256*sizeof(unsigned int));

View file

@ -67,6 +67,7 @@ class DivPlatformRF5C68: public DivDispatch {
int chipType;
unsigned char curChan;
unsigned int sampleOffRFC[256];
bool sampleLoaded[256];
unsigned char* sampleMem;
size_t sampleMemLen;
@ -99,6 +100,7 @@ class DivPlatformRF5C68: public DivDispatch {
const void* getSampleMem(int index = 0);
size_t getSampleMemCapacity(int index = 0);
size_t getSampleMemUsage(int index = 0);
bool isSampleLoaded(int index, int sample);
void renderSamples();
int init(DivEngine* parent, int channels, int sugRate, const DivConfig& flags);
void quit();

View file

@ -797,6 +797,12 @@ size_t DivPlatformSNES::getSampleMemUsage(int index) {
return index == 0 ? sampleMemLen : 0;
}
bool DivPlatformSNES::isSampleLoaded(int index, int sample) {
if (index!=0) return false;
if (sample<0 || sample>255) return false;
return sampleLoaded[sample];
}
void DivPlatformSNES::renderSamples() {
memset(copyOfSampleMem,0,getSampleMemCapacity());
memset(sampleOff,0,256*sizeof(unsigned int));

View file

@ -109,6 +109,7 @@ class DivPlatformSNES: public DivDispatch {
signed char copyOfSampleMem[65536];
size_t sampleMemLen;
unsigned int sampleOff[256];
bool sampleLoaded[256];
unsigned char regPool[0x80];
SPC_DSP dsp;
friend void putDispatchChan(void*,int,int);
@ -136,6 +137,7 @@ class DivPlatformSNES: public DivDispatch {
const void* getSampleMem(int index = 0);
size_t getSampleMemCapacity(int index = 0);
size_t getSampleMemUsage(int index = 0);
bool isSampleLoaded(int index, int sample);
void renderSamples();
int init(DivEngine* parent, int channels, int sugRate, const DivConfig& flags);
void quit();

View file

@ -547,6 +547,12 @@ size_t DivPlatformSoundUnit::getSampleMemUsage(int index) {
return (index==0)?sampleMemLen:0;
}
bool DivPlatformSoundUnit::isSampleLoaded(int index, int sample) {
if (index!=0) return false;
if (sample<0 || sample>255) return false;
return sampleLoaded[sample];
}
void DivPlatformSoundUnit::renderSamples() {
memset(su->pcm,0,getSampleMemCapacity(0));
memset(sampleOffSU,0,256*sizeof(unsigned int));

View file

@ -102,6 +102,7 @@ class DivPlatformSoundUnit: public DivDispatch {
unsigned char initIlCtrl, initIlSize, initFil1;
signed char echoVol, initEchoVol;
unsigned int sampleOffSU[256];
bool sampleLoaded[256];
int cycles, curChan, delay;
short tempL;
@ -138,6 +139,7 @@ class DivPlatformSoundUnit: public DivDispatch {
const void* getSampleMem(int index);
size_t getSampleMemCapacity(int index);
size_t getSampleMemUsage(int index);
bool isSampleLoaded(int index, int sample);
void renderSamples();
int init(DivEngine* parent, int channels, int sugRate, const DivConfig& flags);
void quit();

View file

@ -949,6 +949,12 @@ size_t DivPlatformX1_010::getSampleMemUsage(int index) {
return index >= 0 ? sampleMemLen : 0;
}
bool DivPlatformX1_010::isSampleLoaded(int index, int sample) {
if (index!=0) return false;
if (sample<0 || sample>255) return false;
return sampleLoaded[sample];
}
void DivPlatformX1_010::renderSamples() {
memset(sampleMem,0,getSampleMemCapacity());
memset(sampleOffX1,0,256*sizeof(unsigned int));

View file

@ -116,6 +116,7 @@ class DivPlatformX1_010: public DivDispatch, public vgsound_emu_mem_intf {
bool isBanked=false;
unsigned int bankSlot[8];
unsigned int sampleOffX1[256];
bool sampleLoaded[256];
unsigned char regPool[0x2000];
double NoteX1_010(int ch, int note);
@ -146,6 +147,7 @@ class DivPlatformX1_010: public DivDispatch, public vgsound_emu_mem_intf {
const void* getSampleMem(int index = 0);
size_t getSampleMemCapacity(int index = 0);
size_t getSampleMemUsage(int index = 0);
bool isSampleLoaded(int index, int sample);
void renderSamples();
const char** getRegisterSheet();
void setBanked(bool banked);

View file

@ -1336,6 +1336,12 @@ size_t DivPlatformYM2608::getSampleMemUsage(int index) {
return index == 0 ? adpcmBMemLen : 0;
}
bool DivPlatformYM2608::isSampleLoaded(int index, int sample) {
if (index!=0) return false;
if (sample<0 || sample>255) return false;
return sampleLoaded[sample];
}
void DivPlatformYM2608::renderSamples() {
memset(adpcmBMem,0,getSampleMemCapacity(0));
memset(sampleOffB,0,256*sizeof(unsigned int));

View file

@ -100,6 +100,7 @@ class DivPlatformYM2608: public DivPlatformOPN {
size_t adpcmBMemLen;
DivYM2608Interface iface;
unsigned int sampleOffB[256];
bool sampleLoaded[256];
DivPlatformAY8910* ay;
unsigned char sampleBank;
@ -137,6 +138,7 @@ class DivPlatformYM2608: public DivPlatformOPN {
const void* getSampleMem(int index);
size_t getSampleMemCapacity(int index);
size_t getSampleMemUsage(int index);
bool isSampleLoaded(int index, int sample);
void renderSamples();
void setFlags(const DivConfig& flags);
int init(DivEngine* parent, int channels, int sugRate, const DivConfig& flags);

View file

@ -142,6 +142,8 @@ template<int ChanNum> class DivPlatformYM2610Base: public DivPlatformOPN {
unsigned char sampleBank;
bool extMode, noExtMacros;
bool sampleLoaded[2][256];
unsigned char writeADPCMAOff, writeADPCMAOn;
int globalADPCMAVolume;
@ -208,10 +210,17 @@ template<int ChanNum> class DivPlatformYM2610Base: public DivPlatformOPN {
return index == 0 ? adpcmAMemLen : index == 1 ? adpcmBMemLen : 0;
}
bool isSampleLoaded(int index, int sample) {
if (index<0 || index>1) return false;
if (sample<0 || sample>255) return false;
return sampleLoaded[index][sample];
}
void renderSamples() {
memset(adpcmAMem,0,getSampleMemCapacity(0));
memset(sampleOffA,0,256*sizeof(unsigned int));
memset(sampleOffB,0,256*sizeof(unsigned int));
memset(sampleLoaded,0,256*2*sizeof(bool));
size_t memPos=0;
for (int i=0; i<parent->song.sampleLen; i++) {
@ -231,6 +240,7 @@ template<int ChanNum> class DivPlatformYM2610Base: public DivPlatformOPN {
memcpy(adpcmAMem+memPos,s->dataA,paddedLen);
}
sampleOffA[i]=memPos;
sampleLoaded[0][i]=true;
memPos+=paddedLen;
}
adpcmAMemLen=memPos+256;
@ -255,6 +265,7 @@ template<int ChanNum> class DivPlatformYM2610Base: public DivPlatformOPN {
memcpy(adpcmBMem+memPos,s->dataB,paddedLen);
}
sampleOffB[i]=memPos;
sampleLoaded[1][i]=true;
memPos+=paddedLen;
}
adpcmBMemLen=memPos+256;

View file

@ -420,6 +420,12 @@ size_t DivPlatformYMZ280B::getSampleMemUsage(int index) {
return index == 0 ? sampleMemLen : 0;
}
bool DivPlatformYMZ280B::isSampleLoaded(int index, int sample) {
if (index!=0) return false;
if (sample<0 || sample>255) return false;
return sampleLoaded[sample];
}
void DivPlatformYMZ280B::renderSamples() {
memset(sampleMem,0,getSampleMemCapacity());
memset(sampleOff,0,256*sizeof(unsigned int));

View file

@ -67,6 +67,7 @@ class DivPlatformYMZ280B: public DivDispatch {
bool isMuted[8];
int chipType;
unsigned int sampleOff[256];
bool sampleLoaded[256];
unsigned char* sampleMem;
size_t sampleMemLen;
@ -99,6 +100,7 @@ class DivPlatformYMZ280B: public DivDispatch {
const void* getSampleMem(int index = 0);
size_t getSampleMemCapacity(int index = 0);
size_t getSampleMemUsage(int index = 0);
bool isSampleLoaded(int index, int sample);
void renderSamples();
void setFlags(const DivConfig& flags);
int init(DivEngine* parent, int channels, int sugRate, const DivConfig& flags);