Update FT2Play.

CQTexperiment
Chris Moeller 2016-07-13 19:47:13 -07:00
parent a2a519b3fd
commit b4ae0cc4eb
1 changed files with 103 additions and 76 deletions

View File

@ -1,7 +1,9 @@
/* /*
** FT2PLAY v0.77- 26th of June 2016 ** FT2PLAY v0.77- 29th of June 2016
** ================================ ** ================================
** **
** modplay version for foo_dumb.dll (foobar2000)
**
** Changelog from v0.68 (later changelogs missing): ** Changelog from v0.68 (later changelogs missing):
** - Bug fix for Lxx (Set Envelope Position) ** - Bug fix for Lxx (Set Envelope Position)
** **
@ -523,8 +525,8 @@ static void RetrigEnvelopeVibrato(StmTyp *ch)
} }
/* FT2 doesn't check if fadeout is more than 32768 */ /* FT2 doesn't check if fadeout is more than 32768 */
ch->FadeOutSpeed = (int32_t)(ch->InstrSeg.FadeOut) << 1; ch->FadeOutSpeed = ch->InstrSeg.FadeOut;
ch->FadeOutAmp = 65536; ch->FadeOutAmp = 32768;
if (ch->InstrSeg.VibDepth) if (ch->InstrSeg.VibDepth)
{ {
@ -734,7 +736,7 @@ static void CheckEffects(PLAYER *p, StmTyp *ch)
uint8_t tmpEff; uint8_t tmpEff;
uint8_t tmpEffHi; uint8_t tmpEffHi;
int16_t newEnvPos; int16_t newEnvPos;
int16_t envPos; int8_t envPos;
uint16_t i; uint16_t i;
/* *** VOLUME COLUMN EFFECTS (TICK 0) *** */ /* *** VOLUME COLUMN EFFECTS (TICK 0) *** */
@ -1009,13 +1011,14 @@ static void CheckEffects(PLAYER *p, StmTyp *ch)
// Lxx - set vol and pan envelope position // Lxx - set vol and pan envelope position
else if (ch->EffTyp == 21) else if (ch->EffTyp == 21)
{ {
// *** VOLUME ENVELOPE *** /* *** VOLUME ENVELOPE *** */
if (ch->InstrSeg.EnvVTyp & 1) if (ch->InstrSeg.EnvVTyp & 1)
{ {
ch->EnvVCnt = ch->Eff - 1; ch->EnvVCnt = ch->Eff - 1;
envPos = 0;
envUpdate = 1; envPos = 0;
newEnvPos = ch->Eff; envUpdate = 1;
newEnvPos = ch->Eff;
if (ch->InstrSeg.EnvVPAnt > 1) if (ch->InstrSeg.EnvVPAnt > 1)
{ {
@ -1025,8 +1028,8 @@ static void CheckEffects(PLAYER *p, StmTyp *ch)
if (newEnvPos < ch->InstrSeg.EnvVP[envPos][0]) if (newEnvPos < ch->InstrSeg.EnvVP[envPos][0])
{ {
envPos--; envPos--;
newEnvPos -= ch->InstrSeg.EnvVP[envPos][0];
newEnvPos -= ch->InstrSeg.EnvVP[envPos][0];
if (newEnvPos == 0) if (newEnvPos == 0)
{ {
envUpdate = 0; envUpdate = 0;
@ -1039,12 +1042,10 @@ static void CheckEffects(PLAYER *p, StmTyp *ch)
break; break;
} }
ch->EnvVIPValue = ch->InstrSeg.EnvVP[envPos + 1][1]; ch->EnvVIPValue = ((ch->InstrSeg.EnvVP[envPos + 1][1] - ch->InstrSeg.EnvVP[envPos][1]) & 0x00FF) << 8;
ch->EnvVIPValue -= ch->InstrSeg.EnvVP[envPos ][1]; ch->EnvVIPValue /= (ch->InstrSeg.EnvVP[envPos + 1][0] - ch->InstrSeg.EnvVP[envPos][0]);
ch->EnvVIPValue = (ch->EnvVIPValue & 0x00FF) << 8;
ch->EnvVIPValue/=(ch->InstrSeg.EnvVP[envPos+1][0]-ch->InstrSeg.EnvVP[envPos][0]); ch->EnvVAmp = (ch->EnvVIPValue * (newEnvPos - 1)) + ((ch->InstrSeg.EnvVP[envPos][1] & 0x00FF) << 8);
ch->EnvVAmp=(ch->EnvVIPValue*(newEnvPos-1))+((ch->InstrSeg.EnvVP[envPos][1] & 0x00FF)<<8);
envPos++; envPos++;
@ -1061,22 +1062,27 @@ static void CheckEffects(PLAYER *p, StmTyp *ch)
if (envUpdate) if (envUpdate)
{ {
ch->EnvVIPValue = 0; ch->EnvVIPValue = 0;
ch->EnvVAmp = (ch->InstrSeg.EnvVP[envPos][1] & 0x00FF) << 8; ch->EnvVAmp = (ch->InstrSeg.EnvVP[envPos][1] & 0x00FF) << 8;
} }
if (envPos >= ch->InstrSeg.EnvVPAnt) if (envPos >= ch->InstrSeg.EnvVPAnt)
envPos = (int16_t)(ch->InstrSeg.EnvVPAnt) - 1; {
envPos = ch->InstrSeg.EnvVPAnt - 1;
if (envPos < 0)
envPos = 0;
}
ch->EnvVPos = (envPos < 0) ? 0 : (uint8_t)(envPos); ch->EnvVPos = envPos;
} }
// *** PANNING ENVELOPE *** /* *** PANNING ENVELOPE *** */
if (ch->InstrSeg.EnvVTyp & 2) // probably an FT2 bug if (ch->InstrSeg.EnvVTyp & 2) /* probably an FT2 bug */
{ {
ch->EnvPCnt = ch->Eff - 1; ch->EnvPCnt = ch->Eff - 1;
envPos = 0;
envUpdate = 1; envPos = 0;
newEnvPos = ch->Eff; envUpdate = 1;
newEnvPos = ch->Eff;
if (ch->InstrSeg.EnvPPAnt > 1) if (ch->InstrSeg.EnvPPAnt > 1)
{ {
@ -1086,8 +1092,8 @@ static void CheckEffects(PLAYER *p, StmTyp *ch)
if (newEnvPos < ch->InstrSeg.EnvPP[envPos][0]) if (newEnvPos < ch->InstrSeg.EnvPP[envPos][0])
{ {
envPos--; envPos--;
newEnvPos -= ch->InstrSeg.EnvPP[envPos][0];
newEnvPos -= ch->InstrSeg.EnvPP[envPos][0];
if (newEnvPos == 0) if (newEnvPos == 0)
{ {
envUpdate = 0; envUpdate = 0;
@ -1100,12 +1106,10 @@ static void CheckEffects(PLAYER *p, StmTyp *ch)
break; break;
} }
ch->EnvPIPValue = ch->InstrSeg.EnvPP[envPos + 1][1]; ch->EnvPIPValue = ((ch->InstrSeg.EnvPP[envPos + 1][1] - ch->InstrSeg.EnvPP[envPos][1]) & 0x00FF) << 8;
ch->EnvPIPValue -= ch->InstrSeg.EnvPP[envPos ][1]; ch->EnvPIPValue /= (ch->InstrSeg.EnvPP[envPos + 1][0] - ch->InstrSeg.EnvPP[envPos][0]);
ch->EnvPIPValue = (ch->EnvPIPValue & 0x00FF) << 8;
ch->EnvPIPValue/=(ch->InstrSeg.EnvPP[envPos+1][0]-ch->InstrSeg.EnvPP[envPos][0]); ch->EnvPAmp = (ch->EnvPIPValue * (newEnvPos - 1)) + ((ch->InstrSeg.EnvPP[envPos][1] & 0x00FF) << 8);
ch->EnvPAmp=(ch->EnvPIPValue*(newEnvPos-1))+((ch->InstrSeg.EnvPP[envPos][1]&0x00FF)<<8);
envPos++; envPos++;
@ -1122,13 +1126,17 @@ static void CheckEffects(PLAYER *p, StmTyp *ch)
if (envUpdate) if (envUpdate)
{ {
ch->EnvPIPValue = 0; ch->EnvPIPValue = 0;
ch->EnvPAmp = (ch->InstrSeg.EnvPP[envPos][1] & 0x00FF) << 8; ch->EnvPAmp = (ch->InstrSeg.EnvPP[envPos][1] & 0x00FF) << 8;
} }
if (envPos >= ch->InstrSeg.EnvPPAnt) if (envPos >= ch->InstrSeg.EnvPPAnt)
envPos = (int16_t)(ch->InstrSeg.EnvPPAnt) - 1; {
envPos = ch->InstrSeg.EnvPPAnt - 1;
if (envPos < 0)
envPos = 0;
}
ch->EnvPPos = (envPos < 0) ? 0 : (uint8_t)(envPos); ch->EnvPPos = envPos;
} }
} }
@ -1347,28 +1355,29 @@ static void FixaEnvelopeVibrato(PLAYER *p, StmTyp *ch)
int16_t autoVibAmp; int16_t autoVibAmp;
int16_t tmpPeriod; int16_t tmpPeriod;
// *** FADEOUT *** /* *** FADEOUT *** */
if (!ch->EnvSustainActive) if (!ch->EnvSustainActive)
{ {
ch->Status |= IS_Vol; ch->Status |= IS_Vol;
ch->FadeOutAmp -= ch->FadeOutSpeed; if (ch->FadeOutSpeed > 0)
if (ch->FadeOutAmp <= 0)
{ {
ch->FadeOutAmp = 0; ch->FadeOutAmp -= ch->FadeOutSpeed;
ch->FadeOutSpeed = 0; if (ch->FadeOutAmp <= 0)
{
ch->FadeOutAmp = 0;
ch->FadeOutSpeed = 0;
}
} }
} }
if (!ch->Mute) if (!ch->Mute)
{ {
// *** VOLUME ENVELOPE *** /* *** VOLUME ENVELOPE *** */
envInterpolateFlag = 1; envVal = 0;
envDidInterpolate = 0;
envVal = 0;
if (ch->InstrSeg.EnvVTyp & 1) if (ch->InstrSeg.EnvVTyp & 1)
{ {
envDidInterpolate = 0;
envPos = ch->EnvVPos; envPos = ch->EnvVPos;
ch->EnvVCnt++; ch->EnvVCnt++;
@ -1380,39 +1389,41 @@ static void FixaEnvelopeVibrato(PLAYER *p, StmTyp *ch)
if (ch->InstrSeg.EnvVTyp & 4) if (ch->InstrSeg.EnvVTyp & 4)
{ {
envPos--; envPos--;
if (envPos == ch->InstrSeg.EnvVRepE) if (envPos == ch->InstrSeg.EnvVRepE)
{ {
if (!(ch->InstrSeg.EnvVTyp&2)||(envPos!=ch->InstrSeg.EnvVSust)||ch->EnvSustainActive) if (!(ch->InstrSeg.EnvVTyp & 2) || (envPos != ch->InstrSeg.EnvVSust) || ch->EnvSustainActive)
{ {
envPos = ch->InstrSeg.EnvVRepS; envPos = ch->InstrSeg.EnvVRepS;
ch->EnvVCnt = ch->InstrSeg.EnvVP[envPos][0];
ch->EnvVCnt = ch->InstrSeg.EnvVP[envPos][0];
ch->EnvVAmp = (ch->InstrSeg.EnvVP[envPos][1] & 0x00FF) << 8; ch->EnvVAmp = (ch->InstrSeg.EnvVP[envPos][1] & 0x00FF) << 8;
} }
} }
envPos++; envPos++;
} }
ch->EnvVIPValue = 0;
if (envPos < ch->InstrSeg.EnvVPAnt) if (envPos < ch->InstrSeg.EnvVPAnt)
{ {
envInterpolateFlag = 1;
if ((ch->InstrSeg.EnvVTyp & 2) && ch->EnvSustainActive) if ((ch->InstrSeg.EnvVTyp & 2) && ch->EnvSustainActive)
{ {
envPos--; if ((envPos - 1) == ch->InstrSeg.EnvVSust)
if (envPos == ch->InstrSeg.EnvVSust) {
envPos--;
ch->EnvVIPValue = 0;
envInterpolateFlag = 0; envInterpolateFlag = 0;
else }
envPos++;
} }
if (envInterpolateFlag) if (envInterpolateFlag)
{ {
ch->EnvVPos = envPos; ch->EnvVPos = envPos;
if (ch->InstrSeg.EnvVP[envPos - 0][0] > ch->InstrSeg.EnvVP[envPos - 1][0])
if (ch->InstrSeg.EnvVP[envPos][0] > ch->InstrSeg.EnvVP[envPos - 1][0])
{ {
ch->EnvVIPValue = ch->InstrSeg.EnvVP[envPos - 0][1]; ch->EnvVIPValue = ((ch->InstrSeg.EnvVP[envPos][1] - ch->InstrSeg.EnvVP[envPos - 1][1]) & 0x00FF) << 8;
ch->EnvVIPValue -= ch->InstrSeg.EnvVP[envPos - 1][1];
ch->EnvVIPValue = (ch->EnvVIPValue & 0x00FF) << 8;
ch->EnvVIPValue /= (ch->InstrSeg.EnvVP[envPos][0] - ch->InstrSeg.EnvVP[envPos - 1][0]); ch->EnvVIPValue /= (ch->InstrSeg.EnvVP[envPos][0] - ch->InstrSeg.EnvVP[envPos - 1][0]);
envVal = ch->EnvVAmp; envVal = ch->EnvVAmp;
@ -1420,6 +1431,10 @@ static void FixaEnvelopeVibrato(PLAYER *p, StmTyp *ch)
} }
} }
} }
else
{
ch->EnvVIPValue = 0;
}
} }
if (!envDidInterpolate) if (!envDidInterpolate)
@ -1427,10 +1442,14 @@ static void FixaEnvelopeVibrato(PLAYER *p, StmTyp *ch)
ch->EnvVAmp += ch->EnvVIPValue; ch->EnvVAmp += ch->EnvVIPValue;
envVal = ch->EnvVAmp; envVal = ch->EnvVAmp;
if ((envVal & 0xFF00) > 0x4000) if ((envVal >> 8) > 0x40)
{ {
if ((envVal >> 8) > ((0x40 + 0xC0) / 2))
envVal = 16384;
else
envVal = 0;
ch->EnvVIPValue = 0; ch->EnvVIPValue = 0;
envVal = ((envVal & 0xFF00) > 0x8000) ? 0x0000 : 0x4000;
} }
} }
@ -1452,13 +1471,11 @@ static void FixaEnvelopeVibrato(PLAYER *p, StmTyp *ch)
ch->FinalVol = 0; ch->FinalVol = 0;
} }
// *** PANNING ENVELOPE *** /* *** PANNING ENVELOPE *** */
envInterpolateFlag = 1; envVal = 0;
envDidInterpolate = 0;
envVal = 0;
if (ch->InstrSeg.EnvPTyp & 1) if (ch->InstrSeg.EnvPTyp & 1)
{ {
envDidInterpolate = 0;
envPos = ch->EnvPPos; envPos = ch->EnvPPos;
ch->EnvPCnt++; ch->EnvPCnt++;
@ -1470,39 +1487,41 @@ static void FixaEnvelopeVibrato(PLAYER *p, StmTyp *ch)
if (ch->InstrSeg.EnvPTyp & 4) if (ch->InstrSeg.EnvPTyp & 4)
{ {
envPos--; envPos--;
if (envPos == ch->InstrSeg.EnvPRepE) if (envPos == ch->InstrSeg.EnvPRepE)
{ {
if (!(ch->InstrSeg.EnvPTyp&2)||(envPos!=ch->InstrSeg.EnvPSust)||ch->EnvSustainActive) if (!(ch->InstrSeg.EnvPTyp & 2) || (envPos != ch->InstrSeg.EnvPSust) || ch->EnvSustainActive)
{ {
envPos = ch->InstrSeg.EnvPRepS; envPos = ch->InstrSeg.EnvPRepS;
ch->EnvPCnt = ch->InstrSeg.EnvPP[envPos][0];
ch->EnvPCnt = ch->InstrSeg.EnvPP[envPos][0];
ch->EnvPAmp = (ch->InstrSeg.EnvPP[envPos][1] & 0x00FF) << 8; ch->EnvPAmp = (ch->InstrSeg.EnvPP[envPos][1] & 0x00FF) << 8;
} }
} }
envPos++; envPos++;
} }
ch->EnvPIPValue = 0;
if (envPos < ch->InstrSeg.EnvPPAnt) if (envPos < ch->InstrSeg.EnvPPAnt)
{ {
envInterpolateFlag = 1;
if ((ch->InstrSeg.EnvPTyp & 2) && ch->EnvSustainActive) if ((ch->InstrSeg.EnvPTyp & 2) && ch->EnvSustainActive)
{ {
envPos--; if ((envPos - 1) == ch->InstrSeg.EnvPSust)
if (envPos == ch->InstrSeg.EnvPSust) {
envPos--;
ch->EnvPIPValue = 0;
envInterpolateFlag = 0; envInterpolateFlag = 0;
else }
envPos++;
} }
if (envInterpolateFlag) if (envInterpolateFlag)
{ {
ch->EnvPPos = envPos; ch->EnvPPos = envPos;
if (ch->InstrSeg.EnvPP[envPos - 0][0] > ch->InstrSeg.EnvPP[envPos - 1][0])
if (ch->InstrSeg.EnvPP[envPos][0] > ch->InstrSeg.EnvPP[envPos - 1][0])
{ {
ch->EnvPIPValue = ch->InstrSeg.EnvPP[envPos - 0][1]; ch->EnvPIPValue = ((ch->InstrSeg.EnvPP[envPos][1] - ch->InstrSeg.EnvPP[envPos - 1][1]) & 0x00FF) << 8;
ch->EnvPIPValue -= ch->InstrSeg.EnvPP[envPos - 1][1];
ch->EnvPIPValue = (ch->EnvPIPValue & 0x00FF) << 8;
ch->EnvPIPValue /= (ch->InstrSeg.EnvPP[envPos][0] - ch->InstrSeg.EnvPP[envPos - 1][0]); ch->EnvPIPValue /= (ch->InstrSeg.EnvPP[envPos][0] - ch->InstrSeg.EnvPP[envPos - 1][0]);
envVal = ch->EnvPAmp; envVal = ch->EnvPAmp;
@ -1510,6 +1529,10 @@ static void FixaEnvelopeVibrato(PLAYER *p, StmTyp *ch)
} }
} }
} }
else
{
ch->EnvPIPValue = 0;
}
} }
if (!envDidInterpolate) if (!envDidInterpolate)
@ -1517,10 +1540,14 @@ static void FixaEnvelopeVibrato(PLAYER *p, StmTyp *ch)
ch->EnvPAmp += ch->EnvPIPValue; ch->EnvPAmp += ch->EnvPIPValue;
envVal = ch->EnvPAmp; envVal = ch->EnvPAmp;
if ((envVal & 0xFF00) > 0x4000) if ((envVal >> 8) > 0x40)
{ {
if ((envVal >> 8) > ((0x40 + 0xC0) / 2))
envVal = 16384;
else
envVal = 0;
ch->EnvPIPValue = 0; ch->EnvPIPValue = 0;
envVal = ((envVal & 0xFF00) > 0x8000) ? 0x0000 : 0x4000;
} }
} }