add two new compatibility flags

proper noise range and duty macro is wave volume
This commit is contained in:
tildearrow 2022-02-06 01:56:50 -05:00
parent 8772439d3e
commit e06e316e10
8 changed files with 79 additions and 13 deletions

View file

@ -144,6 +144,10 @@ void DivPlatformGB::tick() {
DivInstrument* ins=parent->getIns(chan[i].ins);
if (i!=2) {
rWrite(16+i*5+1,((chan[i].duty&3)<<6)|(63-(ins->gb.soundLen&63)));
} else {
if (parent->song.waveDutyIsVol) {
rWrite(16+i*5+2,gbVolMap[(chan[i].std.duty&3)<<2]);
}
}
}
if (chan[i].std.hadWave) {
@ -164,7 +168,10 @@ void DivPlatformGB::tick() {
if (chan[i].freqChanged || chan[i].keyOn || chan[i].keyOff) {
DivInstrument* ins=parent->getIns(chan[i].ins);
if (i==3) { // noise
chan[i].freq=noiseTable[chan[i].baseFreq];
int ntPos=chan[i].baseFreq;
if (ntPos<0) ntPos=0;
if (ntPos>255) ntPos=255;
chan[i].freq=noiseTable[ntPos];
} else {
chan[i].freq=parent->calcFreq(chan[i].baseFreq,chan[i].pitch,true);
if (chan[i].freq>2047) chan[i].freq=2047;

View file

@ -73,7 +73,7 @@ void DivPlatformNES::acquire(short* bufL, short* bufR, size_t start, size_t len)
}
}
static unsigned char noiseTable[256]={
static unsigned char noiseTable[253]={
6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 4,
15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4,
15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4,
@ -155,7 +155,10 @@ void DivPlatformNES::tick() {
}
if (chan[i].freqChanged || chan[i].keyOn || chan[i].keyOff) {
if (i==3) { // noise
chan[i].freq=noiseTable[chan[i].baseFreq];
int ntPos=chan[i].baseFreq;
if (ntPos<0) ntPos=0;
if (ntPos>252) ntPos=252;
chan[i].freq=(parent->song.properNoiseLayout)?(15-(chan[i].baseFreq&15)):(noiseTable[ntPos]);
} else {
chan[i].freq=parent->calcFreq(chan[i].baseFreq,chan[i].pitch,true);
if (chan[i].freq>2047) chan[i].freq=2047;

View file

@ -129,17 +129,23 @@ void DivPlatformPCE::tick() {
if (chan[i].std.arpMode) {
chan[i].baseFreq=NOTE_PERIODIC(chan[i].std.arp);
// noise
chWrite(i,0x07,chan[i].noise?(0x80|noiseFreq[(chan[i].std.arp)%12]):0);
int noiseSeek=chan[i].std.arp;
if (noiseSeek<0) noiseSeek=0;
chWrite(i,0x07,chan[i].noise?(0x80|(parent->song.properNoiseLayout?(noiseSeek&31):noiseFreq[noiseSeek%12])):0);
} else {
chan[i].baseFreq=NOTE_PERIODIC(chan[i].note+chan[i].std.arp);
chWrite(i,0x07,chan[i].noise?(0x80|noiseFreq[(chan[i].note+chan[i].std.arp)%12]):0);
int noiseSeek=chan[i].note+chan[i].std.arp;
if (noiseSeek<0) noiseSeek=0;
chWrite(i,0x07,chan[i].noise?(0x80|(parent->song.properNoiseLayout?(noiseSeek&31):noiseFreq[noiseSeek%12])):0);
}
}
chan[i].freqChanged=true;
} else {
if (chan[i].std.arpMode && chan[i].std.finishedArp) {
chan[i].baseFreq=NOTE_PERIODIC(chan[i].note);
chWrite(i,0x07,chan[i].noise?(0x80|noiseFreq[chan[i].note%12]):0);
int noiseSeek=chan[i].note;
if (noiseSeek<0) noiseSeek=0;
chWrite(i,0x07,chan[i].noise?(0x80|(parent->song.properNoiseLayout?(noiseSeek&31):noiseFreq[noiseSeek%12])):0);
chan[i].freqChanged=true;
}
}
@ -248,7 +254,9 @@ int DivPlatformPCE::dispatch(DivCommand c) {
chan[c.chan].baseFreq=NOTE_PERIODIC(c.value);
chan[c.chan].freqChanged=true;
chan[c.chan].note=c.value;
chWrite(c.chan,0x07,chan[c.chan].noise?(0x80|noiseFreq[chan[c.chan].note%12]):0);
int noiseSeek=chan[c.chan].note;
if (noiseSeek<0) noiseSeek=0;
chWrite(c.chan,0x07,chan[c.chan].noise?(0x80|(parent->song.properNoiseLayout?(noiseSeek&31):noiseFreq[noiseSeek%12])):0);
}
chan[c.chan].active=true;
chan[c.chan].keyOn=true;