Move renderSamples() to DivDispatch implementations.
To prevent rendering samples for systems that are not in use. Additionally, it gives the systems more flexibility to render the samples according to their specific configuration.
This commit is contained in:
parent
58fe971a3c
commit
7f0074511c
16 changed files with 327 additions and 219 deletions
|
|
@ -268,8 +268,6 @@ const char* DivPlatformQSound::getEffectName(unsigned char effect) {
|
|||
return NULL;
|
||||
}
|
||||
void DivPlatformQSound::acquire(short* bufL, short* bufR, size_t start, size_t len) {
|
||||
chip.rom_data = parent->qsoundMem;
|
||||
chip.rom_mask = 0xffffff;
|
||||
for (size_t h=start; h<start+len; h++) {
|
||||
qsound_update(&chip);
|
||||
bufL[h]=chip.out[0];
|
||||
|
|
@ -638,6 +636,51 @@ int DivPlatformQSound::getRegisterPoolDepth() {
|
|||
return 16;
|
||||
}
|
||||
|
||||
const void* DivPlatformQSound::getSampleMem(int index) {
|
||||
return index == 0 ? sampleMem : NULL;
|
||||
}
|
||||
|
||||
size_t DivPlatformQSound::getSampleMemCapacity(int index) {
|
||||
return index == 0 ? 16777216 : 0;
|
||||
}
|
||||
|
||||
size_t DivPlatformQSound::getSampleMemUsage(int index) {
|
||||
return index == 0 ? sampleMemLen : 0;
|
||||
}
|
||||
|
||||
void DivPlatformQSound::renderSamples() {
|
||||
memset(sampleMem,0,getSampleMemCapacity());
|
||||
|
||||
size_t memPos=0;
|
||||
for (int i=0; i<parent->song.sampleLen; i++) {
|
||||
DivSample* s=parent->song.sample[i];
|
||||
int length=s->length8;
|
||||
if (length>65536-16) {
|
||||
length=65536-16;
|
||||
}
|
||||
if ((memPos&0xff0000)!=((memPos+length)&0xff0000)) {
|
||||
memPos=(memPos+0xffff)&0xff0000;
|
||||
}
|
||||
if (memPos>=getSampleMemCapacity()) {
|
||||
logW("out of QSound PCM memory for sample %d!",i);
|
||||
break;
|
||||
}
|
||||
if (memPos+length>=getSampleMemCapacity()) {
|
||||
for (unsigned int i=0; i<getSampleMemCapacity()-(memPos+length); i++) {
|
||||
sampleMem[(memPos+i)^0x8000]=s->data8[i];
|
||||
}
|
||||
logW("out of QSound PCM memory for sample %d!",i);
|
||||
} else {
|
||||
for (int i=0; i<length; i++) {
|
||||
sampleMem[(memPos+i)^0x8000]=s->data8[i];
|
||||
}
|
||||
}
|
||||
s->offQSound=memPos^0x8000;
|
||||
memPos+=length+16;
|
||||
}
|
||||
sampleMemLen=memPos+256;
|
||||
}
|
||||
|
||||
int DivPlatformQSound::init(DivEngine* p, int channels, int sugRate, unsigned int flags) {
|
||||
parent=p;
|
||||
dumpWrites=false;
|
||||
|
|
@ -651,8 +694,10 @@ int DivPlatformQSound::init(DivEngine* p, int channels, int sugRate, unsigned in
|
|||
|
||||
chipClock=60000000;
|
||||
rate = qsound_start(&chip, chipClock);
|
||||
chip.rom_data = (unsigned char*)&chip.rom_mask;
|
||||
chip.rom_mask = 0;
|
||||
sampleMem=new unsigned char[getSampleMemCapacity()];
|
||||
sampleMemLen=0;
|
||||
chip.rom_data=sampleMem;
|
||||
chip.rom_mask=0xffffff;
|
||||
reset();
|
||||
|
||||
for (int i=0; i<19; i++) {
|
||||
|
|
@ -662,6 +707,7 @@ int DivPlatformQSound::init(DivEngine* p, int channels, int sugRate, unsigned in
|
|||
}
|
||||
|
||||
void DivPlatformQSound::quit() {
|
||||
delete[] sampleMem;
|
||||
for (int i=0; i<19; i++) {
|
||||
delete oscBuf[i];
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue