Merge branch 'cps2' of https://github.com/superctr/furnace into superctr-cps2

This commit is contained in:
tildearrow 2022-02-22 18:21:57 -05:00
commit e6ee28ce0d
18 changed files with 1775 additions and 17 deletions

View file

@ -273,6 +273,28 @@ void DivEngine::performVGMWrite(SafeWriter* w, DivSystem sys, DivRegWrite& write
w->writeC(0xff);
}
break;
case DIV_SYSTEM_QSOUND:
for (int i=0; i<16; i++) {
w->writeC(0xc4);
w->writeC(0);
w->writeC(0);
w->writeC(2+(i*8));
w->writeC(0xc4);
w->writeC(0);
w->writeC(0);
w->writeC(6+(i*8));
}
for (int i=0; i<3; i++) {
w->writeC(0xc4);
w->writeC(0);
w->writeC(0);
w->writeC(0xcd+(i*4));
w->writeC(0xc4);
w->writeC(0x00);
w->writeC(0x01);
w->writeC(0xd6+i);
}
break;
default:
break;
}
@ -395,6 +417,12 @@ void DivEngine::performVGMWrite(SafeWriter* w, DivSystem sys, DivRegWrite& write
w->writeC(write.addr&0xff);
w->writeC(write.val&0xff);
break;
case DIV_SYSTEM_QSOUND:
w->writeC(0xc4);
w->writeC((write.val>>8)&0xff);
w->writeC(write.val&0xff);
w->writeC(write.addr&0xff);
break;
default:
logW("write not handled!\n");
break;
@ -508,6 +536,7 @@ SafeWriter* DivEngine::saveVGM(bool* sysToExport, bool loop) {
bool writePCESamples=false;
bool writeADPCM=false;
bool writeSegaPCM=false;
bool writeQSound=false;
for (int i=0; i<song.systemLen; i++) {
willExport[i]=false;
@ -690,7 +719,7 @@ SafeWriter* DivEngine::saveVGM(bool* sysToExport, bool loop) {
case DIV_SYSTEM_LYNX:
if (!hasLynx) {
hasLynx=disCont[i].dispatch->chipClock;
willExport[i] = true;
willExport[i]=true;
} else if (!(hasLynx&0x40000000)) {
isSecond[i]=true;
willExport[i]=true;
@ -698,6 +727,20 @@ SafeWriter* DivEngine::saveVGM(bool* sysToExport, bool loop) {
howManyChips++;
}
break;
case DIV_SYSTEM_QSOUND:
if (!hasQSound) {
// could set chipClock to 4000000 here for compatibility
// However I think it it not necessary because old VGM players will still
// not be able to handle the 64kb sample bank trick
hasQSound=disCont[i].dispatch->chipClock;
willExport[i]=true;
writeQSound=true;
} else if (!(hasQSound&0x40000000)) {
isSecond[i]=true;
willExport[i]=false;
addWarning("dual QSound is not supported by the VGM format");
}
break;
default:
break;
}
@ -931,6 +974,20 @@ SafeWriter* DivEngine::saveVGM(bool* sysToExport, bool loop) {
w->write(adpcmMem,adpcmMemLen);
}
if (writeQSound && qsoundMemLen>0) {
// always write a whole bank
unsigned int blockSize=(qsoundMemLen + 0xffff) & ~0xffff;
if(blockSize > 0x1000000)
blockSize = 0x1000000;
w->writeC(0x67);
w->writeC(0x66);
w->writeC(0x8F);
w->writeI(blockSize+8);
w->writeI(0x1000000);
w->writeI(0);
w->write(qsoundMem,blockSize);
}
// initialize streams
int streamID=0;
for (int i=0; i<song.systemLen; i++) {