mirror of
https://github.com/tildearrow/furnace.git
synced 2024-12-29 11:01:27 +00:00
VGM export: fix up SegaPCM
turns out it is capable of arbitrary loop position!
This commit is contained in:
parent
9654c6a85d
commit
50a0f1f360
3 changed files with 23 additions and 20 deletions
|
@ -2032,7 +2032,7 @@ SafeWriter* DivEngine::saveVGM() {
|
|||
int hasOPN2=0;
|
||||
int hasOPM=0;
|
||||
int hasSegaPCM=0;
|
||||
int segaPCMOffset=0x2000;
|
||||
int segaPCMOffset=0xf8000d;
|
||||
int hasRFC=0;
|
||||
int hasOPN=0;
|
||||
int hasOPNA=0;
|
||||
|
@ -2281,24 +2281,28 @@ SafeWriter* DivEngine::saveVGM() {
|
|||
size_t memPos=0;
|
||||
for (int i=0; i<song.sampleLen; i++) {
|
||||
DivSample* sample=song.sample[i];
|
||||
if ((memPos&0xff0000)!=((memPos+sample->rendLength)&0xff0000)) {
|
||||
memPos=(memPos+0xffff)&0xff0000;
|
||||
}
|
||||
if (memPos>=16777216) break;
|
||||
sample->rendOffP=memPos;
|
||||
unsigned int alignedSize=(sample->rendLength+0xff)&(~0xff);
|
||||
if (alignedSize>65536) alignedSize=65536;
|
||||
if (sample->depth==8) {
|
||||
for (unsigned int j=0; j<alignedSize; j++) {
|
||||
if (j>=sample->rendLength) {
|
||||
pcmMem[memPos++]=0;
|
||||
pcmMem[memPos++]=0x80;
|
||||
} else {
|
||||
pcmMem[memPos++]=((unsigned char)sample->rendData[j]);
|
||||
pcmMem[memPos++]=((unsigned char)sample->rendData[j]+0x80);
|
||||
}
|
||||
if (memPos>=16777216) break;
|
||||
}
|
||||
} else {
|
||||
for (unsigned int j=0; j<alignedSize; j++) {
|
||||
if (j>=sample->rendLength) {
|
||||
pcmMem[memPos++]=0;
|
||||
pcmMem[memPos++]=0x80;
|
||||
} else {
|
||||
pcmMem[memPos++]=(((unsigned short)sample->rendData[j])>>8);
|
||||
pcmMem[memPos++]=(((unsigned short)sample->rendData[j]+0x8000)>>8);
|
||||
}
|
||||
if (memPos>=16777216) break;
|
||||
}
|
||||
|
|
|
@ -240,7 +240,7 @@ int DivPlatformArcade::dispatch(DivCommand c) {
|
|||
if (chan[c.chan].pcm.sample<0 || chan[c.chan].pcm.sample>=parent->song.sampleLen) {
|
||||
chan[c.chan].pcm.sample=-1;
|
||||
if (dumpWrites) {
|
||||
addWrite(0x10086+(pcmChan<<3),1);
|
||||
addWrite(0x10086+(pcmChan<<3),3);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -250,17 +250,18 @@ int DivPlatformArcade::dispatch(DivCommand c) {
|
|||
chan[c.chan].furnacePCM=true;
|
||||
if (dumpWrites) { // Sega PCM writes
|
||||
DivSample* s=parent->song.sample[chan[c.chan].pcm.sample];
|
||||
addWrite(0x10084+(c.chan<<3),(s->rendOffP>>8)&0xff);
|
||||
addWrite(0x10085+(c.chan<<3),(s->rendOffP>>16)&0xff);
|
||||
addWrite(0x10006+(c.chan<<3),(MIN(65536,((s->rendLength+0xff)&(~0xff)))>>8)-1);
|
||||
addWrite(0x10086+(c.chan<<3),0);
|
||||
addWrite(0x10086+(pcmChan<<3),3+((s->rendOffP>>16)<<3));
|
||||
addWrite(0x10084+(pcmChan<<3),(s->rendOffP)&0xff);
|
||||
addWrite(0x10085+(pcmChan<<3),(s->rendOffP>>8)&0xff);
|
||||
addWrite(0x10006+(pcmChan<<3),MIN(255,((s->rendOffP&0xffff)+s->rendLength)>>8));
|
||||
addWrite(0x10086+(pcmChan<<3),2+((s->rendOffP>>16)<<3));
|
||||
}
|
||||
} else {
|
||||
chan[c.chan].pcm.sample=12*sampleBank+c.value%12;
|
||||
if (chan[c.chan].pcm.sample>=parent->song.sampleLen) {
|
||||
chan[c.chan].pcm.sample=-1;
|
||||
if (dumpWrites) {
|
||||
addWrite(0x10086+(pcmChan<<3),1);
|
||||
addWrite(0x10086+(pcmChan<<3),3);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -269,10 +270,11 @@ int DivPlatformArcade::dispatch(DivCommand c) {
|
|||
chan[c.chan].furnacePCM=false;
|
||||
if (dumpWrites) { // Sega PCM writes
|
||||
DivSample* s=parent->song.sample[chan[c.chan].pcm.sample];
|
||||
addWrite(0x10084+(pcmChan<<3),(s->rendOffP>>8)&0xff);
|
||||
addWrite(0x10085+(pcmChan<<3),(s->rendOffP>>16)&0xff);
|
||||
addWrite(0x10006+(pcmChan<<3),(MIN(65536,((s->rendLength+0xff)&(~0xff)))>>8)-1);
|
||||
addWrite(0x10086+(pcmChan<<3),0);
|
||||
addWrite(0x10086+(pcmChan<<3),3+((s->rendOffP>>16)<<3));
|
||||
addWrite(0x10084+(pcmChan<<3),(s->rendOffP)&0xff);
|
||||
addWrite(0x10085+(pcmChan<<3),(s->rendOffP>>8)&0xff);
|
||||
addWrite(0x10006+(pcmChan<<3),MIN(255,((s->rendOffP&0xffff)+s->rendLength)>>8));
|
||||
addWrite(0x10086+(pcmChan<<3),2+((s->rendOffP>>16)<<3));
|
||||
addWrite(0x10007+(pcmChan<<3),chan[c.chan].pcm.freq);
|
||||
}
|
||||
}
|
||||
|
@ -321,7 +323,7 @@ int DivPlatformArcade::dispatch(DivCommand c) {
|
|||
if (c.chan>7) {
|
||||
chan[c.chan].pcm.sample=-1;
|
||||
if (dumpWrites) {
|
||||
addWrite(0x10086+(pcmChan<<3),1);
|
||||
addWrite(0x10086+(pcmChan<<3),3);
|
||||
}
|
||||
}
|
||||
chan[c.chan].keyOff=true;
|
||||
|
@ -559,7 +561,7 @@ void DivPlatformArcade::reset() {
|
|||
//rWrite(0x1b,0x00);
|
||||
if (dumpWrites) {
|
||||
for (int i=0; i<5; i++) {
|
||||
addWrite(0x10086+(i<<3),1);
|
||||
addWrite(0x10086+(i<<3),3);
|
||||
addWrite(0x10002+(i<<3),0x7f);
|
||||
addWrite(0x10003+(i<<3),0x7f);
|
||||
}
|
||||
|
|
|
@ -1674,9 +1674,6 @@ void FurnaceGUI::drawSampleEdit() {
|
|||
if (sample->loopStart&1) {
|
||||
ImGui::Text("- sample loop start will be aligned to the nearest even sample on Amiga");
|
||||
}
|
||||
if (sample->loopStart&255) {
|
||||
ImGui::Text("- sample loop start will be aligned by 256 on Sega PCM");
|
||||
}
|
||||
}
|
||||
if (sample->length&1) {
|
||||
considerations=true;
|
||||
|
|
Loading…
Reference in a new issue