memory composition, part 5

almost there
This commit is contained in:
tildearrow 2024-03-06 03:42:21 -05:00
parent 6763aa44a9
commit 0be5835645
13 changed files with 108 additions and 1 deletions

View file

@ -538,6 +538,9 @@ void DivPlatformK007232::renderSamples(int sysID) {
memset(sampleOffK007232,0,256*sizeof(unsigned int));
memset(sampleLoaded,0,256*sizeof(bool));
memCompo=DivMemoryComposition();
memCompo.name="Sample ROM";
size_t memPos=0;
for (int i=0; i<parent->song.sampleLen; i++) {
DivSample* s=parent->song.sample[i];
@ -556,6 +559,7 @@ void DivPlatformK007232::renderSamples(int sysID) {
memPos=(memPos+0x1ffff)&0xfe0000;
}
sampleOffK007232[i]=memPos;
memCompo.entries.push_back(DivMemoryEntry(DIV_MEMORY_SAMPLE,"Sample",i,memPos,memPos+actualLength+1));
for (int j=0; j<actualLength; j++) {
// convert to 7 bit unsigned
unsigned char val=(unsigned char)(s->data8[j])^0x80;
@ -573,6 +577,9 @@ void DivPlatformK007232::renderSamples(int sysID) {
}
}
sampleMemLen=memPos;
memCompo.used=sampleMemLen;
memCompo.capacity=16777216;
}
int DivPlatformK007232::init(DivEngine* p, int channels, int sugRate, const DivConfig& flags) {

View file

@ -476,6 +476,9 @@ void DivPlatformK053260::renderSamples(int sysID) {
memset(sampleOffK053260,0,256*sizeof(unsigned int));
memset(sampleLoaded,0,256*sizeof(bool));
memCompo=DivMemoryComposition();
memCompo.name="Sample ROM";
size_t memPos=1; // for avoid silence
for (int i=0; i<parent->song.sampleLen; i++) {
DivSample* s=parent->song.sample[i];
@ -491,6 +494,7 @@ void DivPlatformK053260::renderSamples(int sysID) {
actualLength=MIN((int)(getSampleMemCapacity()-memPos-1),length);
if (actualLength>0) {
sampleOffK053260[i]=memPos-1;
memCompo.entries.push_back(DivMemoryEntry(DIV_MEMORY_SAMPLE,"Sample",i,memPos,memPos+actualLength+1));
for (int j=0; j<actualLength; j++) {
sampleMem[memPos++]=s->dataK[j];
}
@ -501,6 +505,7 @@ void DivPlatformK053260::renderSamples(int sysID) {
actualLength=MIN((int)(getSampleMemCapacity()-memPos-1),length);
if (actualLength>0) {
sampleOffK053260[i]=memPos-1;
memCompo.entries.push_back(DivMemoryEntry(DIV_MEMORY_SAMPLE,"Sample",i,memPos,memPos+actualLength+1));
for (int j=0; j<actualLength; j++) {
sampleMem[memPos++]=s->data8[j];
}
@ -514,6 +519,9 @@ void DivPlatformK053260::renderSamples(int sysID) {
sampleLoaded[i]=true;
}
sampleMemLen=memPos;
memCompo.capacity=2097152;
memCompo.used=sampleMemLen;
}
int DivPlatformK053260::init(DivEngine* p, int channels, int sugRate, const DivConfig& flags) {

View file

@ -386,6 +386,11 @@ void DivPlatformMSM6295::renderSamples(int sysID) {
bankedPhrase[i].phrase=0;
}
memCompo=DivMemoryComposition();
memCompo.name="Sample ROM";
memCompo.entries.push_back(DivMemoryEntry(DIV_MEMORY_RESERVED,"Phrase Book",-1,0,128*8));
// sample data
size_t memPos=128*8;
if (isBanked) {
@ -424,6 +429,7 @@ void DivPlatformMSM6295::renderSamples(int sysID) {
bankedPhrase[i].bank=bankInd;
bankedPhrase[i].phrase=phraseInd;
bankedPhrase[i].length=paddedLen;
memCompo.entries.push_back(DivMemoryEntry(DIV_MEMORY_SAMPLE,"Sample",i,memPos,memPos+paddedLen));
memPos+=paddedLen;
phraseInd++;
}
@ -465,6 +471,7 @@ void DivPlatformMSM6295::renderSamples(int sysID) {
sampleLoaded[i]=true;
}
sampleOffVOX[i]=memPos;
memCompo.entries.push_back(DivMemoryEntry(DIV_MEMORY_SAMPLE,"Sample",i,memPos,memPos+paddedLen));
memPos+=paddedLen;
}
adpcmMemLen=memPos+256;
@ -481,6 +488,9 @@ void DivPlatformMSM6295::renderSamples(int sysID) {
adpcmMem[5+i*8]=(endPos)&0xff;
}
}
memCompo.capacity=getSampleMemCapacity(0);
memCompo.used=adpcmMemLen;
}
void DivPlatformMSM6295::setFlags(const DivConfig& flags) {

View file

@ -845,9 +845,12 @@ const DivMemoryComposition* DivPlatformNES::getMemCompo(int index) {
}
void DivPlatformNES::renderSamples(int sysID) {
memset(dpcmMem,0,getSampleMemCapacity(0));\
memset(dpcmMem,0,getSampleMemCapacity(0));
memset(sampleLoaded,0,256*sizeof(bool));
memCompo=DivMemoryComposition();
memCompo.name="DPCM";
size_t memPos=0;
for (int i=0; i<parent->song.sampleLen; i++) {
DivSample* s=parent->song.sample[i];
@ -876,9 +879,13 @@ void DivPlatformNES::renderSamples(int sysID) {
sampleLoaded[i]=true;
}
sampleOffDPCM[i]=memPos;
memCompo.entries.push_back(DivMemoryEntry(DIV_MEMORY_SAMPLE,"Sample",i,memPos,memPos+paddedLen));
memPos+=paddedLen;
}
dpcmMemLen=memPos;
memCompo.capacity=262144;
memCompo.used=dpcmMemLen;
}
int DivPlatformNES::init(DivEngine* p, int channels, int sugRate, const DivConfig& flags) {

View file

@ -2551,6 +2551,9 @@ void DivPlatformOPL::renderSamples(int sysID) {
memset(sampleOffB,0,256*sizeof(unsigned int));
memset(sampleLoaded,0,256*sizeof(bool));
memCompo=DivMemoryComposition();
memCompo.name="Sample Memory";
size_t memPos=0;
for (int i=0; i<parent->song.sampleLen; i++) {
DivSample* s=parent->song.sample[i];
@ -2575,9 +2578,13 @@ void DivPlatformOPL::renderSamples(int sysID) {
sampleLoaded[i]=true;
}
sampleOffB[i]=memPos;
memCompo.entries.push_back(DivMemoryEntry(DIV_MEMORY_SAMPLE,"Sample",i,memPos,memPos+paddedLen));
memPos+=paddedLen;
}
adpcmBMemLen=memPos+256;
memCompo.used=adpcmBMemLen;
memCompo.capacity=getSampleMemCapacity(0);
}
int DivPlatformOPL::init(DivEngine* p, int channels, int sugRate, const DivConfig& flags) {

View file

@ -745,6 +745,9 @@ void DivPlatformQSound::renderSamples(int sysID) {
memset(sampleLoaded,0,256*sizeof(bool));
memset(sampleLoadedBS,0,256*sizeof(bool));
memCompo=DivMemoryComposition();
memCompo.name="Sample ROM";
size_t memPos=0;
for (int i=0; i<parent->song.sampleLen; i++) {
DivSample* s=parent->song.sample[i];
@ -776,6 +779,7 @@ void DivPlatformQSound::renderSamples(int sysID) {
sampleLoaded[i]=true;
}
offPCM[i]=memPos^0x8000;
memCompo.entries.push_back(DivMemoryEntry(DIV_MEMORY_SAMPLE,"PCM",i,memPos,memPos+length));
memPos+=length+16;
}
sampleMemLen=memPos+256;
@ -813,9 +817,13 @@ void DivPlatformQSound::renderSamples(int sysID) {
sampleLoadedBS[i]=true;
}
offBS[i]=memPos;
memCompo.entries.push_back(DivMemoryEntry(DIV_MEMORY_SAMPLE_ALT1,"ADPCM",i,memPos,memPos+length));
memPos+=length+16;
}
sampleMemLenBS=memPos+256;
memCompo.used=sampleMemLenBS;
memCompo.capacity=getSampleMemCapacity(0);
}
int DivPlatformQSound::init(DivEngine* p, int channels, int sugRate, const DivConfig& flags) {

View file

@ -425,6 +425,9 @@ void DivPlatformRF5C68::renderSamples(int sysID) {
memset(sampleOffRFC,0,256*sizeof(unsigned int));
memset(sampleLoaded,0,256*sizeof(bool));
memCompo=DivMemoryComposition();
memCompo.name="Sample Memory";
size_t memPos=0;
for (int i=0; i<parent->song.sampleLen; i++) {
DivSample* s=parent->song.sample[i];
@ -437,6 +440,7 @@ void DivPlatformRF5C68::renderSamples(int sysID) {
int actualLength=MIN((int)(getSampleMemCapacity()-memPos)-32,length);
if (actualLength>0) {
sampleOffRFC[i]=memPos;
memCompo.entries.push_back(DivMemoryEntry(DIV_MEMORY_SAMPLE,"Sample",i,memPos,memPos+actualLength+32));
for (int j=0; j<actualLength; j++) {
// convert to signed magnitude
signed char val=s->data8[j];
@ -456,6 +460,9 @@ void DivPlatformRF5C68::renderSamples(int sysID) {
sampleLoaded[i]=true;
}
sampleMemLen=memPos;
memCompo.used=sampleMemLen;
memCompo.capacity=getSampleMemCapacity(0);
}
int DivPlatformRF5C68::init(DivEngine* p, int channels, int sugRate, const DivConfig& flags) {

View file

@ -491,6 +491,9 @@ void DivPlatformSegaPCM::renderSamples(int sysID) {
memset(sampleLoaded,0,256*sizeof(bool));
memset(sampleOffSegaPCM,0,256*sizeof(unsigned int));
memset(sampleEndSegaPCM,0,256);
memCompo=DivMemoryComposition();
memCompo.name="Sample ROM";
for (int i=0; i<parent->song.sampleLen; i++) {
DivSample* sample=parent->getSample(i);
@ -506,6 +509,7 @@ void DivPlatformSegaPCM::renderSamples(int sysID) {
sampleLoaded[i]=true;
if (memPos>=2097152) break;
sampleOffSegaPCM[i]=memPos;
memCompo.entries.push_back(DivMemoryEntry(DIV_MEMORY_SAMPLE,"Sample",i,memPos,memPos+alignedSize));
for (unsigned int j=0; j<alignedSize; j++) {
if (j>=sample->samples) {
sampleMem[memPos++]=0;
@ -519,6 +523,9 @@ void DivPlatformSegaPCM::renderSamples(int sysID) {
if (memPos>=2097152) break;
}
sampleMemLen=memPos;
memCompo.used=sampleMemLen;
memCompo.capacity=getSampleMemCapacity(0);
}
void DivPlatformSegaPCM::setFlags(const DivConfig& flags) {

View file

@ -667,6 +667,9 @@ void DivPlatformSoundUnit::renderSamples(int sysID) {
memset(sampleOffSU,0,256*sizeof(unsigned int));
memset(sampleLoaded,0,256*sizeof(bool));
memCompo=DivMemoryComposition();
memCompo.name="Sample RAM";
size_t memPos=0;
for (int i=0; i<parent->song.sampleLen; i++) {
DivSample* s=parent->song.sample[i];
@ -689,12 +692,20 @@ void DivPlatformSoundUnit::renderSamples(int sysID) {
sampleLoaded[i]=true;
}
sampleOffSU[i]=memPos;
memCompo.entries.push_back(DivMemoryEntry(DIV_MEMORY_SAMPLE,"Sample",i,memPos,memPos+paddedLen));
memPos+=paddedLen;
}
sampleMemLen=memPos;
sysIDCache=sysID;
memcpy(su->pcm,sampleMem,sampleMemSize?65536:8192);
memCompo.used=sampleMemLen;
memCompo.capacity=sampleMemSize?65536:8192;
if (initIlSize&64) {
memCompo.entries.push_back(DivMemoryEntry(DIV_MEMORY_ECHO,"Echo Buffer",-1,memCompo.capacity-((1+(initIlSize&63))<<7),memCompo.capacity));
}
}
int DivPlatformSoundUnit::init(DivEngine* p, int channels, int sugRate, const DivConfig& flags) {

View file

@ -1005,6 +1005,9 @@ void DivPlatformX1_010::renderSamples(int sysID) {
memset(sampleOffX1,0,256*sizeof(unsigned int));
memset(sampleLoaded,0,256*sizeof(bool));
memCompo=DivMemoryComposition();
memCompo.name="Sample ROM";
size_t memPos=0;
for (int i=0; i<parent->song.sampleLen; i++) {
DivSample* s=parent->song.sample[i];
@ -1035,9 +1038,13 @@ void DivPlatformX1_010::renderSamples(int sysID) {
sampleLoaded[i]=true;
}
sampleOffX1[i]=memPos;
memCompo.entries.push_back(DivMemoryEntry(DIV_MEMORY_SAMPLE,"Sample",i,memPos,memPos+paddedLen));
memPos+=paddedLen;
}
sampleMemLen=memPos+256;
memCompo.used=sampleMemLen;
memCompo.capacity=getSampleMemCapacity(0);
}
int DivPlatformX1_010::init(DivEngine* p, int channels, int sugRate, const DivConfig& flags) {

View file

@ -1615,6 +1615,9 @@ void DivPlatformYM2608::renderSamples(int sysID) {
memset(sampleOffB,0,256*sizeof(unsigned int));
memset(sampleLoaded,0,256*sizeof(bool));
memCompo=DivMemoryComposition();
memCompo.name="ADPCM";
size_t memPos=0;
for (int i=0; i<parent->song.sampleLen; i++) {
DivSample* s=parent->song.sample[i];
@ -1639,9 +1642,13 @@ void DivPlatformYM2608::renderSamples(int sysID) {
sampleLoaded[i]=true;
}
sampleOffB[i]=memPos;
memCompo.entries.push_back(DivMemoryEntry(DIV_MEMORY_SAMPLE,"Sample",i,memPos,memPos+paddedLen));
memPos+=paddedLen;
}
adpcmBMemLen=memPos+256;
memCompo.used=adpcmBMemLen;
memCompo.capacity=getSampleMemCapacity(0);
}
void DivPlatformYM2608::setFlags(const DivConfig& flags) {

View file

@ -160,6 +160,12 @@ class DivPlatformYM2610Base: public DivPlatformOPN {
memset(sampleOffB,0,256*sizeof(unsigned int));
memset(sampleLoaded,0,256*2*sizeof(bool));
memCompoA=DivMemoryComposition();
memCompoA.name="ADPCM-A";
memCompoB=DivMemoryComposition();
memCompoB.name="ADPCM-B";
size_t memPos=0;
for (int i=0; i<parent->song.sampleLen; i++) {
DivSample* s=parent->song.sample[i];
@ -184,10 +190,14 @@ class DivPlatformYM2610Base: public DivPlatformOPN {
sampleLoaded[0][i]=true;
}
sampleOffA[i]=memPos;
memCompoA.entries.push_back(DivMemoryEntry(DIV_MEMORY_SAMPLE,"Sample",i,memPos,memPos+paddedLen));
memPos+=paddedLen;
}
adpcmAMemLen=memPos+256;
memCompoA.used=adpcmAMemLen;
memCompoA.capacity=getSampleMemCapacity(0);
memset(adpcmBMem,0,getSampleMemCapacity(1));
memPos=0;
@ -214,9 +224,13 @@ class DivPlatformYM2610Base: public DivPlatformOPN {
sampleLoaded[1][i]=true;
}
sampleOffB[i]=memPos;
memCompoB.entries.push_back(DivMemoryEntry(DIV_MEMORY_SAMPLE,"Sample",i,memPos,memPos+paddedLen));
memPos+=paddedLen;
}
adpcmBMemLen=memPos+256;
memCompoB.used=adpcmBMemLen;
memCompoB.capacity=getSampleMemCapacity(1);
}
void setFlags(const DivConfig& flags) {

View file

@ -452,6 +452,9 @@ void DivPlatformYMZ280B::renderSamples(int sysID) {
memset(sampleOff,0,256*sizeof(unsigned int));
memset(sampleLoaded,0,256*sizeof(bool));
memCompo=DivMemoryComposition();
memCompo.name="Sample ROM";
size_t memPos=0;
for (int i=0; i<parent->song.sampleLen; i++) {
DivSample* s=parent->song.sample[i];
@ -476,6 +479,7 @@ void DivPlatformYMZ280B::renderSamples(int sysID) {
}
#endif
sampleOff[i]=memPos;
memCompo.entries.push_back(DivMemoryEntry(DIV_MEMORY_SAMPLE,"Sample",i,memPos,memPos+length));
memPos+=length;
}
if (actualLength<length) {
@ -485,6 +489,9 @@ void DivPlatformYMZ280B::renderSamples(int sysID) {
sampleLoaded[i]=true;
}
sampleMemLen=memPos;
memCompo.used=sampleMemLen;
memCompo.capacity=getSampleMemCapacity(0);
}
void DivPlatformYMZ280B::setChipModel(int type) {