mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
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:
parent
b4db1e6941
commit
074ef84559
3 changed files with 40 additions and 18 deletions
|
@ -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) {
|
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) {
|
if (voiceNum >= PSP_SAS_VOICES_MAX || voiceNum < 0) {
|
||||||
WARN_LOG(SCESAS, "%s: invalid voicenum %d", __FUNCTION__, voiceNum);
|
WARN_LOG(SCESAS, "%s: invalid voicenum %d", __FUNCTION__, voiceNum);
|
||||||
return ERROR_SAS_INVALID_VOICE;
|
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];
|
SasVoice &v = sas->voices[voiceNum];
|
||||||
v.envelope.SetSimpleEnvelope(ADSREnv1 & 0xFFFF, ADSREnv2 & 0xFFFF);
|
v.envelope.SetSimpleEnvelope(ADSREnv1 & 0xFFFF, ADSREnv2 & 0xFFFF);
|
||||||
|
|
|
@ -396,7 +396,7 @@ int sceUtilityNetconfInitStart(u32 paramsAddr)
|
||||||
int sceUtilityNetconfShutdownStart(unsigned int unknown)
|
int sceUtilityNetconfShutdownStart(unsigned int unknown)
|
||||||
{
|
{
|
||||||
if (currentDialogType != UTILITY_DIALOG_NET) {
|
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;
|
return SCE_ERROR_UTILITY_WRONG_TYPE;
|
||||||
}
|
}
|
||||||
currentDialogActive = false;
|
currentDialogActive = false;
|
||||||
|
|
|
@ -218,7 +218,7 @@ void SasAtrac3::DoState(PointerWrap &p) {
|
||||||
|
|
||||||
// http://code.google.com/p/jpcsp/source/browse/trunk/src/jpcsp/HLE/modules150/sceSasCore.java
|
// 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;
|
n &= 0x7F;
|
||||||
if (n == 0x7F) {
|
if (n == 0x7F) {
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -230,6 +230,18 @@ int simpleRate(int n) {
|
||||||
return rate;
|
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) {
|
static int getAttackRate(int bitfield1) {
|
||||||
return simpleRate(bitfield1 >> 8);
|
return simpleRate(bitfield1 >> 8);
|
||||||
}
|
}
|
||||||
|
@ -239,22 +251,22 @@ static int getAttackType(int bitfield1) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static int getDecayRate(int bitfield1) {
|
static int getDecayRate(int bitfield1) {
|
||||||
return 0x80000000 >> ((bitfield1 >> 4) & 0x000F);
|
int n = (bitfield1 >> 4) & 0x000F;
|
||||||
}
|
if (n == 0)
|
||||||
|
return 0x7FFFFFFF;
|
||||||
static int getSustainRate(int bitfield2) {
|
return 0x80000000 >> n;
|
||||||
return simpleRate(bitfield2 >> 6);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int getSustainType(int bitfield2) {
|
static int getSustainType(int bitfield2) {
|
||||||
switch (bitfield2 >> 13) {
|
return (bitfield2 >> 14) & 3;
|
||||||
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;
|
static int getSustainRate(int bitfield2) {
|
||||||
case 6: return PSP_SAS_ADSR_CURVE_MODE_EXPONENT_DECREASE;
|
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) {
|
static int getReleaseType(int bitfield2) {
|
||||||
|
@ -267,9 +279,14 @@ static int getReleaseRate(int bitfield2) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (getReleaseType(bitfield2) == PSP_SAS_ADSR_CURVE_MODE_LINEAR_DECREASE) {
|
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) {
|
static int getSustainLevel(int bitfield1) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue