mirror of
https://github.com/tildearrow/furnace.git
synced 2024-11-15 17:25:06 +00:00
VGM export: PCE samples (kinda)
This commit is contained in:
parent
cda191afee
commit
511b6ba0be
2 changed files with 50 additions and 2 deletions
|
@ -2294,8 +2294,21 @@ SafeWriter* DivEngine::saveVGM() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (writePCESamples) {
|
if (writePCESamples) for (int i=0; i<song.sampleLen; i++) {
|
||||||
// TODO
|
DivSample* sample=song.sample[i];
|
||||||
|
w->writeC(0x67);
|
||||||
|
w->writeC(0x66);
|
||||||
|
w->writeC(5);
|
||||||
|
w->writeI(sample->rendLength);
|
||||||
|
if (sample->depth==8) {
|
||||||
|
for (unsigned int j=0; j<sample->rendLength; j++) {
|
||||||
|
w->writeC(((unsigned char)sample->rendData[j]+0x80)>>3);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (unsigned int j=0; j<sample->rendLength; j++) {
|
||||||
|
w->writeC(((unsigned short)sample->rendData[j]+0x8000)>>11);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (writeSegaPCM) {
|
if (writeSegaPCM) {
|
||||||
|
@ -2412,6 +2425,26 @@ SafeWriter* DivEngine::saveVGM() {
|
||||||
w->writeI(32000); // default
|
w->writeI(32000); // default
|
||||||
streamID++;
|
streamID++;
|
||||||
break;
|
break;
|
||||||
|
case DIV_SYSTEM_PCE:
|
||||||
|
for (int j=0; j<6; j++) {
|
||||||
|
w->writeC(0x90);
|
||||||
|
w->writeC(streamID);
|
||||||
|
w->writeC(27);
|
||||||
|
w->writeC(j); // port
|
||||||
|
w->writeC(0x06); // select+DAC
|
||||||
|
|
||||||
|
w->writeC(0x91);
|
||||||
|
w->writeC(streamID);
|
||||||
|
w->writeC(5);
|
||||||
|
w->writeC(1);
|
||||||
|
w->writeC(0);
|
||||||
|
|
||||||
|
w->writeC(0x92);
|
||||||
|
w->writeC(streamID);
|
||||||
|
w->writeI(32000); // default
|
||||||
|
streamID++;
|
||||||
|
}
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
logW("what? trying to play sample on unsupported system\n");
|
logW("what? trying to play sample on unsupported system\n");
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -133,6 +133,7 @@ void DivPlatformPCE::tick() {
|
||||||
chan[i].freq=parent->calcFreq(chan[i].baseFreq,chan[i].pitch,true);
|
chan[i].freq=parent->calcFreq(chan[i].baseFreq,chan[i].pitch,true);
|
||||||
if (chan[i].furnaceDac) {
|
if (chan[i].furnaceDac) {
|
||||||
chan[i].dacRate=chan[i].freq;
|
chan[i].dacRate=chan[i].freq;
|
||||||
|
if (dumpWrites) addWrite(0xffff0001+(i<<8),1789773/chan[i].dacRate);
|
||||||
}
|
}
|
||||||
if (chan[i].freq>4095) chan[i].freq=4095;
|
if (chan[i].freq>4095) chan[i].freq=4095;
|
||||||
if (chan[i].note>0x5d) chan[i].freq=0x01;
|
if (chan[i].note>0x5d) chan[i].freq=0x01;
|
||||||
|
@ -170,7 +171,13 @@ int DivPlatformPCE::dispatch(DivCommand c) {
|
||||||
chan[c.chan].dacSample=ins->amiga.initSample;
|
chan[c.chan].dacSample=ins->amiga.initSample;
|
||||||
if (chan[c.chan].dacSample<0 || chan[c.chan].dacSample>=parent->song.sampleLen) {
|
if (chan[c.chan].dacSample<0 || chan[c.chan].dacSample>=parent->song.sampleLen) {
|
||||||
chan[c.chan].dacSample=-1;
|
chan[c.chan].dacSample=-1;
|
||||||
|
if (dumpWrites) addWrite(0xffff0002+(c.chan<<8),0);
|
||||||
break;
|
break;
|
||||||
|
} else {
|
||||||
|
if (dumpWrites) {
|
||||||
|
chWrite(c.chan,0x04,0xdf);
|
||||||
|
addWrite(0xffff0000+(c.chan<<8),chan[c.chan].dacSample);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
chan[c.chan].dacPos=0;
|
chan[c.chan].dacPos=0;
|
||||||
chan[c.chan].dacPeriod=0;
|
chan[c.chan].dacPeriod=0;
|
||||||
|
@ -186,11 +193,18 @@ int DivPlatformPCE::dispatch(DivCommand c) {
|
||||||
chan[c.chan].dacSample=12*sampleBank+c.value%12;
|
chan[c.chan].dacSample=12*sampleBank+c.value%12;
|
||||||
if (chan[c.chan].dacSample>=parent->song.sampleLen) {
|
if (chan[c.chan].dacSample>=parent->song.sampleLen) {
|
||||||
chan[c.chan].dacSample=-1;
|
chan[c.chan].dacSample=-1;
|
||||||
|
if (dumpWrites) addWrite(0xffff0002+(c.chan<<8),0);
|
||||||
break;
|
break;
|
||||||
|
} else {
|
||||||
|
if (dumpWrites) addWrite(0xffff0000+(c.chan<<8),chan[c.chan].dacSample);
|
||||||
}
|
}
|
||||||
chan[c.chan].dacPos=0;
|
chan[c.chan].dacPos=0;
|
||||||
chan[c.chan].dacPeriod=0;
|
chan[c.chan].dacPeriod=0;
|
||||||
chan[c.chan].dacRate=1789773/parent->song.sample[chan[c.chan].dacSample]->rate;
|
chan[c.chan].dacRate=1789773/parent->song.sample[chan[c.chan].dacSample]->rate;
|
||||||
|
if (dumpWrites) {
|
||||||
|
chWrite(c.chan,0x04,0xdf);
|
||||||
|
addWrite(0xffff0001+(c.chan<<8),1789773/chan[c.chan].dacRate);
|
||||||
|
}
|
||||||
chan[c.chan].furnaceDac=false;
|
chan[c.chan].furnaceDac=false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -209,6 +223,7 @@ int DivPlatformPCE::dispatch(DivCommand c) {
|
||||||
}
|
}
|
||||||
case DIV_CMD_NOTE_OFF:
|
case DIV_CMD_NOTE_OFF:
|
||||||
chan[c.chan].dacSample=-1;
|
chan[c.chan].dacSample=-1;
|
||||||
|
if (dumpWrites) addWrite(0xffff0002+(c.chan<<8),0);
|
||||||
chan[c.chan].pcm=false;
|
chan[c.chan].pcm=false;
|
||||||
chan[c.chan].active=false;
|
chan[c.chan].active=false;
|
||||||
chan[c.chan].keyOff=true;
|
chan[c.chan].keyOff=true;
|
||||||
|
|
Loading…
Reference in a new issue