mirror of
https://github.com/tildearrow/furnace.git
synced 2025-01-06 23:51:21 +00:00
Fix playback and VGM export
This commit is contained in:
parent
df7ac3e073
commit
8f31c4b49f
4 changed files with 66 additions and 53 deletions
|
@ -187,7 +187,7 @@ void DivPlatformWS::tick() {
|
|||
}
|
||||
if (chan[i].freqChanged || chan[i].keyOn || chan[i].keyOff) {
|
||||
chan[i].freq=parent->calcFreq(chan[i].baseFreq,chan[i].pitch,true);
|
||||
if (i==1 && furnaceDac) {
|
||||
if (i==1 && pcm && furnaceDac) {
|
||||
double off=1.0;
|
||||
if (dacSample>=0 && dacSample<parent->song.sampleLen) {
|
||||
DivSample* s=parent->getSample(dacSample);
|
||||
|
@ -237,56 +237,58 @@ int DivPlatformWS::dispatch(DivCommand c) {
|
|||
switch (c.cmd) {
|
||||
case DIV_CMD_NOTE_ON: {
|
||||
DivInstrument* ins=parent->getIns(chan[c.chan].ins);
|
||||
if (c.chan==1 && ins->type==DIV_INS_AMIGA) {
|
||||
pcm=true;
|
||||
} else if (furnaceDac) {
|
||||
pcm=false;
|
||||
}
|
||||
if (c.chan==1 && pcm) {
|
||||
if (skipRegisterWrites) break;
|
||||
dacPos=0;
|
||||
dacPeriod=0;
|
||||
if (c.chan==1) {
|
||||
if (ins->type==DIV_INS_AMIGA) {
|
||||
dacSample=ins->amiga.initSample;
|
||||
if (dacSample<0 || dacSample>=parent->song.sampleLen) {
|
||||
dacSample=-1;
|
||||
if (dumpWrites) addWrite(0xffff0002,0);
|
||||
break;
|
||||
} else {
|
||||
if (dumpWrites) {
|
||||
addWrite(0xffff0000,dacSample);
|
||||
}
|
||||
}
|
||||
if (c.value!=DIV_NOTE_NULL) {
|
||||
chan[1].baseFreq=NOTE_PERIODIC(c.value);
|
||||
chan[1].freqChanged=true;
|
||||
chan[1].note=c.value;
|
||||
}
|
||||
chan[1].active=true;
|
||||
chan[1].keyOn=true;
|
||||
chan[1].std.init(ins);
|
||||
furnaceDac=true;
|
||||
} else {
|
||||
if (c.value!=DIV_NOTE_NULL) {
|
||||
chan[1].note=c.value;
|
||||
}
|
||||
dacSample=12*sampleBank+chan[1].note%12;
|
||||
if (dacSample>=parent->song.sampleLen) {
|
||||
dacSample=-1;
|
||||
if (dumpWrites) addWrite(0xffff0002,0);
|
||||
break;
|
||||
} else {
|
||||
if (dumpWrites) addWrite(0xffff0000,dacSample);
|
||||
}
|
||||
dacRate=parent->getSample(dacSample)->rate;
|
||||
if (dumpWrites) {
|
||||
addWrite(0xffff0001,dacRate);
|
||||
}
|
||||
chan[1].active=true;
|
||||
chan[1].keyOn=true;
|
||||
furnaceDac=false;
|
||||
pcm=true;
|
||||
} else if (furnaceDac) {
|
||||
pcm=false;
|
||||
}
|
||||
if (pcm) {
|
||||
if (skipRegisterWrites) break;
|
||||
dacPos=0;
|
||||
dacPeriod=0;
|
||||
if (ins->type==DIV_INS_AMIGA) {
|
||||
dacSample=ins->amiga.initSample;
|
||||
if (dacSample<0 || dacSample>=parent->song.sampleLen) {
|
||||
dacSample=-1;
|
||||
if (dumpWrites) addWrite(0xffff0002,0);
|
||||
break;
|
||||
} else {
|
||||
if (dumpWrites) {
|
||||
addWrite(0xffff0000,dacSample);
|
||||
}
|
||||
}
|
||||
if (c.value!=DIV_NOTE_NULL) {
|
||||
chan[1].baseFreq=NOTE_PERIODIC(c.value);
|
||||
chan[1].freqChanged=true;
|
||||
chan[1].note=c.value;
|
||||
}
|
||||
chan[1].active=true;
|
||||
chan[1].keyOn=true;
|
||||
chan[1].std.init(ins);
|
||||
furnaceDac=true;
|
||||
} else {
|
||||
if (c.value!=DIV_NOTE_NULL) {
|
||||
chan[1].note=c.value;
|
||||
}
|
||||
dacSample=12*sampleBank+chan[1].note%12;
|
||||
if (dacSample>=parent->song.sampleLen) {
|
||||
dacSample=-1;
|
||||
if (dumpWrites) addWrite(0xffff0002,0);
|
||||
break;
|
||||
} else {
|
||||
if (dumpWrites) addWrite(0xffff0000,dacSample);
|
||||
}
|
||||
dacRate=parent->getSample(dacSample)->rate;
|
||||
if (dumpWrites) {
|
||||
addWrite(0xffff0001,dacRate);
|
||||
}
|
||||
chan[1].active=true;
|
||||
chan[1].keyOn=true;
|
||||
furnaceDac=false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (c.value!=DIV_NOTE_NULL) {
|
||||
chan[c.chan].baseFreq=NOTE_PERIODIC(c.value);
|
||||
|
@ -412,7 +414,7 @@ int DivPlatformWS::dispatch(DivCommand c) {
|
|||
return 15;
|
||||
break;
|
||||
case DIV_ALWAYS_SET_VOLUME:
|
||||
return 0;
|
||||
return 1;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -456,6 +458,7 @@ void DivPlatformWS::reset() {
|
|||
chan[i]=Channel();
|
||||
chan[i].vol=15;
|
||||
chan[i].pan=0xff;
|
||||
rWrite(0x08+i,0xff);
|
||||
}
|
||||
if (dumpWrites) {
|
||||
addWrite(0xffffffff,0);
|
||||
|
|
|
@ -80,6 +80,10 @@ int SafeWriter::writeC(signed char val) {
|
|||
int SafeWriter::writeS(short val) {
|
||||
return write(&val,2);
|
||||
}
|
||||
int SafeWriter::writeS_BE(short val) {
|
||||
unsigned char bytes[2]{(val>>8)&0xff, val&0xff};
|
||||
return write(bytes,2);
|
||||
}
|
||||
|
||||
int SafeWriter::writeI(int val) {
|
||||
return write(&val,4);
|
||||
|
|
|
@ -451,7 +451,7 @@ void DivEngine::performVGMWrite(SafeWriter* w, DivSystem sys, DivRegWrite& write
|
|||
} else {
|
||||
// (Wave) RAM write
|
||||
w->writeC(0xc6);
|
||||
w->writeS(baseAddr2S|(write.addr&0x3f));
|
||||
w->writeS_BE(baseAddr2S|(write.addr&0x3f));
|
||||
w->writeC(write.val&0xff);
|
||||
}
|
||||
break;
|
||||
|
@ -1061,9 +1061,9 @@ SafeWriter* DivEngine::saveVGM(bool* sysToExport, bool loop) {
|
|||
case DIV_SYSTEM_SWAN:
|
||||
w->writeC(0x90);
|
||||
w->writeC(streamID);
|
||||
w->writeC(33);
|
||||
w->writeC(isSecond[i]?0xa1:0x21);
|
||||
w->writeC(0); // port
|
||||
w->writeC(isSecond[i]?0x89:0x09); // DAC
|
||||
w->writeC(0x09); // DAC
|
||||
|
||||
w->writeC(0x91);
|
||||
w->writeC(streamID);
|
||||
|
|
|
@ -6390,6 +6390,12 @@ FurnaceGUI::FurnaceGUI():
|
|||
0
|
||||
}
|
||||
));
|
||||
cat.systems.push_back(FurnaceGUISysDef(
|
||||
"WonderSwan", {
|
||||
DIV_SYSTEM_SWAN, 64, 0, 0,
|
||||
0
|
||||
}
|
||||
));
|
||||
sysCategories.push_back(cat);
|
||||
|
||||
cat=FurnaceGUISysCategory("Computers");
|
||||
|
|
Loading…
Reference in a new issue