Correct the rates set by sceSasSetSimpleADSR().

They were wrong for a few combinations before.  Could have effected how
accurate sound effects were (they may have been too quite, or dropped off
wrong, etc.)
This commit is contained in:
Unknown W. Brackets 2014-02-07 22:29:54 -08:00
parent b4db1e6941
commit 074ef84559
3 changed files with 40 additions and 18 deletions

View file

@ -379,12 +379,17 @@ u32 sceSasSetADSRMode(u32 core, int voiceNum,int flag ,int a, int d, int s, int
u32 sceSasSetSimpleADSR(u32 core, int voiceNum, u32 ADSREnv1, u32 ADSREnv2) {
DEBUG_LOG(SCESAS, "sasSetSimpleADSR(%08x, %i, %08x, %08x)", core, voiceNum, ADSREnv1, ADSREnv2);
if (voiceNum >= PSP_SAS_VOICES_MAX || voiceNum < 0) {
WARN_LOG(SCESAS, "%s: invalid voicenum %d", __FUNCTION__, voiceNum);
return ERROR_SAS_INVALID_VOICE;
}
// This bit could be related to decay type or systain type, but gives an error if you try to set it.
if ((ADSREnv2 >> 13) & 1) {
WARN_LOG_REPORT(SCESAS, "sceSasSetSimpleADSR(%08x, %d, %04x, %04x): Invalid ADSREnv2", core, voiceNum, ADSREnv1, ADSREnv2);
return ERROR_SAS_INVALID_ADSR_CURVE_MODE;
}
DEBUG_LOG(SCESAS, "sasSetSimpleADSR(%08x, %i, %08x, %08x)", core, voiceNum, ADSREnv1, ADSREnv2);
SasVoice &v = sas->voices[voiceNum];
v.envelope.SetSimpleEnvelope(ADSREnv1 & 0xFFFF, ADSREnv2 & 0xFFFF);

View file

@ -396,7 +396,7 @@ int sceUtilityNetconfInitStart(u32 paramsAddr)
int sceUtilityNetconfShutdownStart(unsigned int unknown)
{
if (currentDialogType != UTILITY_DIALOG_NET) {
WARN_LOG(SCEUTILITY, "sceUtilityNetconfShutdownStartt(): wrong dialog type");
WARN_LOG(SCEUTILITY, "sceUtilityNetconfShutdownStart(): wrong dialog type");
return SCE_ERROR_UTILITY_WRONG_TYPE;
}
currentDialogActive = false;

View file

@ -218,7 +218,7 @@ void SasAtrac3::DoState(PointerWrap &p) {
// http://code.google.com/p/jpcsp/source/browse/trunk/src/jpcsp/HLE/modules150/sceSasCore.java
int simpleRate(int n) {
static int simpleRate(int n) {
n &= 0x7F;
if (n == 0x7F) {
return 0;
@ -230,6 +230,18 @@ int simpleRate(int n) {
return rate;
}
static int exponentRate(int n) {
n &= 0x7F;
if (n == 0x7F) {
return 0;
}
int rate = ((7 - (n & 0x3)) << 24) >> (n >> 2);
if (rate == 0) {
return 1;
}
return rate;
}
static int getAttackRate(int bitfield1) {
return simpleRate(bitfield1 >> 8);
}
@ -239,22 +251,22 @@ static int getAttackType(int bitfield1) {
}
static int getDecayRate(int bitfield1) {
return 0x80000000 >> ((bitfield1 >> 4) & 0x000F);
}
static int getSustainRate(int bitfield2) {
return simpleRate(bitfield2 >> 6);
int n = (bitfield1 >> 4) & 0x000F;
if (n == 0)
return 0x7FFFFFFF;
return 0x80000000 >> n;
}
static int getSustainType(int bitfield2) {
switch (bitfield2 >> 13) {
case 0: return PSP_SAS_ADSR_CURVE_MODE_LINEAR_INCREASE;
case 2: return PSP_SAS_ADSR_CURVE_MODE_LINEAR_DECREASE;
case 4: return PSP_SAS_ADSR_CURVE_MODE_LINEAR_BENT;
case 6: return PSP_SAS_ADSR_CURVE_MODE_EXPONENT_DECREASE;
return (bitfield2 >> 14) & 3;
}
static int getSustainRate(int bitfield2) {
if (getSustainType(bitfield2) == PSP_SAS_ADSR_CURVE_MODE_EXPONENT_DECREASE) {
return exponentRate(bitfield2 >> 6);
} else {
return simpleRate(bitfield2 >> 6);
}
ERROR_LOG(SASMIX,"sasSetSimpleADSR,ERROR_SAS_INVALID_ADSR_CURVE_MODE");
return 0;
}
static int getReleaseType(int bitfield2) {
@ -267,9 +279,14 @@ static int getReleaseRate(int bitfield2) {
return 0;
}
if (getReleaseType(bitfield2) == PSP_SAS_ADSR_CURVE_MODE_LINEAR_DECREASE) {
return (0x40000000 >> (n + 2));
if (n == 30) {
return 0x40000000;
} else if (n == 29) {
return 1;
}
return 0x10000000 >> n;
}
return (0x40000000 >> n);
return 0x80000000 >> n;
}
static int getSustainLevel(int bitfield1) {