Use raw pitch in envelope column
This commit is contained in:
parent
ccd0d676c2
commit
f2e2d4e0b4
|
@ -674,11 +674,25 @@ void DivPlatformAY8910::tick(bool sysTick) {
|
||||||
ayEnvPeriod=chan[3].std.ex5.val<<8;
|
ayEnvPeriod=chan[3].std.ex5.val<<8;
|
||||||
}
|
}
|
||||||
else if ((chan[3].freqChanged && chan[3].active) || chan[3].keyOn) {
|
else if ((chan[3].freqChanged && chan[3].active) || chan[3].keyOn) {
|
||||||
chan[3].freq=parent->calcFreq(chan[3].baseFreq,chan[3].pitch,chan[3].fixedArp?chan[3].baseNoteOverride:chan[3].arpOff,chan[3].fixedArp,true,0,chan[3].pitch2,chipClock*16,CHIP_DIVIDER);
|
if (envRawMode) {
|
||||||
if (chan[3].freq<0) chan[3].freq=0;
|
// Compute base without pitch2, then apply pitch2 directly to the raw envelope period
|
||||||
if (chan[3].freq>65535*256) chan[3].freq=65535*256;
|
int baseFreq=parent->calcFreq(chan[3].baseFreq,chan[3].pitch,chan[3].fixedArp?chan[3].baseNoteOverride:chan[3].arpOff,chan[3].fixedArp,true,0,0,chipClock*16,CHIP_DIVIDER);
|
||||||
ayEnvPeriod=chan[3].freq;
|
if (baseFreq<0) baseFreq=0;
|
||||||
chan[3].freqChanged=false;
|
if (baseFreq>65535*256) baseFreq=65535*256;
|
||||||
|
// Apply pitch2 later as raw offset in the same fixed-point scale (8 fractional bits)
|
||||||
|
long adjusted=(long)baseFreq + ((long)chan[3].pitch2<<8);
|
||||||
|
if (adjusted<0) adjusted=0;
|
||||||
|
if (adjusted>(long)65535*256) adjusted=(long)65535*256;
|
||||||
|
chan[3].freq=(int)adjusted;
|
||||||
|
ayEnvPeriod=chan[3].freq;
|
||||||
|
chan[3].freqChanged=false;
|
||||||
|
} else {
|
||||||
|
chan[3].freq=parent->calcFreq(chan[3].baseFreq,chan[3].pitch,chan[3].fixedArp?chan[3].baseNoteOverride:chan[3].arpOff,chan[3].fixedArp,true,0,chan[3].pitch2,chipClock*16,CHIP_DIVIDER);
|
||||||
|
if (chan[3].freq<0) chan[3].freq=0;
|
||||||
|
if (chan[3].freq>65535*256) chan[3].freq=65535*256;
|
||||||
|
ayEnvPeriod=chan[3].freq;
|
||||||
|
chan[3].freqChanged=false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (chan[3].keyOn) chan[3].keyOn=false;
|
if (chan[3].keyOn) chan[3].keyOn=false;
|
||||||
if (chan[3].keyOff) chan[3].keyOff=false;
|
if (chan[3].keyOff) chan[3].keyOff=false;
|
||||||
|
@ -1317,6 +1331,7 @@ void DivPlatformAY8910::setFlags(const DivConfig& flags) {
|
||||||
stereo=flags.getBool("stereo",false);
|
stereo=flags.getBool("stereo",false);
|
||||||
stereoSep=flags.getInt("stereoSep",0)&255;
|
stereoSep=flags.getInt("stereoSep",0)&255;
|
||||||
extendedSsg=false;
|
extendedSsg=false;
|
||||||
|
envRawMode=flags.getBool("envRawMode",false);
|
||||||
switch (flags.getInt("panLaw",0)) {
|
switch (flags.getInt("panLaw",0)) {
|
||||||
case 1:
|
case 1:
|
||||||
centerVol=sqrtf((stereoSep+256)/512.f)*256.f;
|
centerVol=sqrtf((stereoSep+256)/512.f)*256.f;
|
||||||
|
|
|
@ -141,6 +141,10 @@ class DivPlatformAY8910: public DivDispatch {
|
||||||
unsigned char dacRateDiv;
|
unsigned char dacRateDiv;
|
||||||
|
|
||||||
bool stereo, sunsoft, intellivision, clockSel, yamaha;
|
bool stereo, sunsoft, intellivision, clockSel, yamaha;
|
||||||
|
// When true, the AY "envelope column" uses raw register values instead of
|
||||||
|
// converting linear pitch/note values into envelope frequency. Intended for
|
||||||
|
// embedded AY inside chips like YM2203.
|
||||||
|
bool envRawMode;
|
||||||
bool ioPortA, ioPortB;
|
bool ioPortA, ioPortB;
|
||||||
unsigned char portAVal, portBVal;
|
unsigned char portAVal, portBVal;
|
||||||
|
|
||||||
|
@ -202,6 +206,7 @@ class DivPlatformAY8910: public DivDispatch {
|
||||||
extMode(useExtMode),
|
extMode(useExtMode),
|
||||||
extClock(eclk),
|
extClock(eclk),
|
||||||
extDiv(ediv),
|
extDiv(ediv),
|
||||||
dacRateDiv(ddiv) {}
|
dacRateDiv(ddiv),
|
||||||
|
envRawMode(false) {}
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1472,6 +1472,9 @@ void DivPlatformYM2203::setFlags(const DivConfig& flags) {
|
||||||
ayFlags.set("stereo",stereo);
|
ayFlags.set("stereo",stereo);
|
||||||
ayFlags.set("stereoSep",stereoSep);
|
ayFlags.set("stereoSep",stereoSep);
|
||||||
ayFlags.set("panLaw",flags.getInt("panLaw",0));
|
ayFlags.set("panLaw",flags.getInt("panLaw",0));
|
||||||
|
// AY inside YM2203 should treat envelope column values as raw register values
|
||||||
|
// rather than linear pitch-derived values.
|
||||||
|
ayFlags.set("envRawMode",true);
|
||||||
if (useCombo==2) {
|
if (useCombo==2) {
|
||||||
rate=chipClock/(fmDivBase*2);
|
rate=chipClock/(fmDivBase*2);
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue