el diego 2 finally plays back correctly

ALMOST
This commit is contained in:
tildearrow 2021-12-27 16:31:16 -05:00
parent 4f2ce0f907
commit 65444d4a99
10 changed files with 20 additions and 13 deletions

View file

@ -69,7 +69,7 @@ void DivPlatformC64::tick() {
rWrite(i*7+4,(isMuted[i]?0:(chan[i].wave<<4))|(chan[i].ring<<2)|(chan[i].sync<<1)|chan[i].active);
}
if (chan[i].freqChanged || chan[i].keyOn || chan[i].keyOff) {
chan[i].freq=(chan[i].baseFreq*(ONE_SEMITONE+chan[i].pitch))/ONE_SEMITONE;
chan[i].freq=(chan[i].baseFreq*pow(2,(double)chan[i].pitch/(12.0*128.0)));
if (chan[i].freq>0xffff) chan[i].freq=0xffff;
if (chan[i].keyOn) {
rWrite(i*7+5,(chan[i].attack<<4)|(chan[i].decay));

View file

@ -25,7 +25,7 @@ void DivPlatformDummy::tick() {
if (chan[i].freqChanged) {
chan[i].freqChanged=false;
chan[i].freq=(chan[i].baseFreq*(ONE_SEMITONE+chan[i].pitch))/ONE_SEMITONE;
chan[i].freq=(chan[i].baseFreq*pow(2,(double)chan[i].pitch/(12.0*128.0)));
}
}
}

View file

@ -126,7 +126,7 @@ void DivPlatformGB::tick() {
if (i==3) { // noise
chan[i].freq=noiseTable[chan[i].baseFreq];
} else {
chan[i].freq=(chan[i].baseFreq*(ONE_SEMITONE-chan[i].pitch))/ONE_SEMITONE;
chan[i].freq=(chan[i].baseFreq*pow(2,(double)-chan[i].pitch/(12.0*128.0)));
if (chan[i].freq>2047) chan[i].freq=2047;
}
if (chan[i].note>0x5d) chan[i].freq=0x01;

View file

@ -94,7 +94,7 @@ void DivPlatformGenesis::tick() {
for (int i=0; i<6; i++) {
if (i==2 && extMode) continue;
if (chan[i].freqChanged) {
chan[i].freq=(chan[i].baseFreq*(ONE_SEMITONE+chan[i].pitch))/ONE_SEMITONE;
chan[i].freq=(chan[i].baseFreq*pow(2,(double)chan[i].pitch/(12.0*128.0)));
int freqt=toFreq(chan[i].freq);
immWrite(chanOffs[i]+0xa4,freqt>>8);
immWrite(chanOffs[i]+0xa0,freqt&0xff);

View file

@ -241,7 +241,7 @@ void DivPlatformGenesisExt::tick() {
unsigned char writeMask=2;
if (extMode) for (int i=0; i<4; i++) {
if (opChan[i].freqChanged) {
opChan[i].freq=(opChan[i].baseFreq*(ONE_SEMITONE+opChan[i].pitch))/ONE_SEMITONE;
opChan[i].freq=(opChan[i].baseFreq*pow(2,(double)opChan[i].pitch/(12.0*128.0)));
if (opChan[i].freq>=82432) {
opChan[i].freqH=((opChan[i].freq>>15)&7)|0x38;
opChan[i].freqL=(opChan[i].freq>>7)&0xff;

View file

@ -111,7 +111,7 @@ void DivPlatformPCE::tick() {
}
if (chan[i].freqChanged || chan[i].keyOn || chan[i].keyOff) {
//DivInstrument* ins=parent->getIns(chan[i].ins);
chan[i].freq=(chan[i].baseFreq*(ONE_SEMITONE-chan[i].pitch))/ONE_SEMITONE;
chan[i].freq=(chan[i].baseFreq*pow(2,(double)-chan[i].pitch/(12.0*128.0)));
if (chan[i].freq>4095) chan[i].freq=4095;
if (chan[i].note>0x5d) chan[i].freq=0x01;
chWrite(i,0x02,chan[i].freq&0xff);

View file

@ -37,7 +37,7 @@ void DivPlatformSMS::tick() {
}
for (int i=0; i<3; i++) {
if (chan[i].freqChanged) {
chan[i].freq=(chan[i].baseFreq*(ONE_SEMITONE-chan[i].pitch))/ONE_SEMITONE;
chan[i].freq=(chan[i].baseFreq*pow(2,(double)-chan[i].pitch/(12.0*128.0)));
if (chan[i].note>0x5d) chan[i].freq=0x01;
sn->write(0x80|i<<5|(chan[i].freq&15));
sn->write(chan[i].freq>>4);
@ -46,7 +46,7 @@ void DivPlatformSMS::tick() {
}
if (chan[3].freqChanged || updateSNMode) {
updateSNMode=false;
chan[3].freq=(chan[3].baseFreq*(ONE_SEMITONE-chan[3].pitch))/ONE_SEMITONE;
chan[3].freq=(chan[3].baseFreq*pow(2,(double)-chan[3].pitch/(12.0*128.0)));
if (chan[3].note>0x5d) chan[3].freq=0x01;
chan[3].freqChanged=false;
if (snNoiseMode&2) { // take period from channel 3

View file

@ -75,7 +75,7 @@ void DivPlatformYM2610::tick() {
chan[i].psgMode|=(chan[i].std.wave+1)&3;
}
if (chan[i].freqChanged || chan[i].keyOn || chan[i].keyOff) {
chan[i].freq=(chan[i].baseFreq*(ONE_SEMITONE-chan[i].pitch))/ONE_SEMITONE;
chan[i].freq=(chan[i].baseFreq*pow(2,(double)-chan[i].pitch/(12.0*128.0)));
if (chan[i].freq>4095) chan[i].freq=4095;
if (chan[i].keyOn) {
//rWrite(16+i*5+1,((chan[i].duty&3)<<6)|(63-(ins->gb.soundLen&63)));
@ -119,7 +119,7 @@ void DivPlatformYM2610::tick() {
for (int i=0; i<4; i++) {
if (i==1 && extMode) continue;
if (chan[i].freqChanged) {
chan[i].freq=(chan[i].baseFreq*(ONE_SEMITONE+chan[i].pitch))/ONE_SEMITONE;
chan[i].freq=(chan[i].baseFreq*pow(2,(double)chan[i].pitch/(12.0*128.0)));
int freqt=toFreq(chan[i].freq);
immWrite(chanOffs[i]+0xa4,freqt>>8);
immWrite(chanOffs[i]+0xa0,freqt&0xff);

View file

@ -217,7 +217,7 @@ void DivPlatformYM2610Ext::tick() {
unsigned char writeMask=2;
if (extMode) for (int i=0; i<4; i++) {
if (opChan[i].freqChanged) {
opChan[i].freq=(opChan[i].baseFreq*(ONE_SEMITONE+opChan[i].pitch))/ONE_SEMITONE;
opChan[i].freq=(opChan[i].baseFreq*pow(2,(double)opChan[i].pitch/(12.0*128.0)));
int freqt=toFreq(opChan[i].freq);
opChan[i].freqH=freqt>>8;
opChan[i].freqL=freqt&0xff;

View file

@ -525,8 +525,15 @@ void DivEngine::processRow(int i, bool afterDelay) {
for (int i=0; i<chans; i++) {
chan[i].pitch-=globalPitch;
}
globalPitch+=(signed char)(effectVal-0x80)*(120-globalPitch/28);
printf("setting global pitch to %d\n",globalPitch);
if (effectVal>0x80) {
for (int i=0; i<effectVal-0x80; i++) {
globalPitch+=(120-globalPitch/32);
}
} else if (effectVal<0x80) {
for (int i=0; i<0x80-effectVal; i++) {
globalPitch-=(120-globalPitch/32);
}
}
for (int i=0; i<chans; i++) {
chan[i].pitch+=globalPitch;
dispatchCmd(DivCommand(DIV_CMD_PITCH,i,chan[i].pitch+(((chan[i].vibratoDepth*vibTable[chan[i].vibratoPos]*chan[i].vibratoFine)>>4)/15)));