mirror of
https://github.com/zeldaret/tp
synced 2026-05-30 08:56:46 -04:00
various Z2Audio / JAudio debug cleanup (#2876)
* some JAudio work * audio cleanup checkpoint * checkpoint more audio cleanup * fix symbols * more z2 cleanup * fix regression * fix build * some fixes
This commit is contained in:
+68
-94
@@ -1,138 +1,112 @@
|
||||
//
|
||||
// Generated By: dol2asm
|
||||
// Translation Unit: Z2Calc
|
||||
//
|
||||
|
||||
#include "Z2AudioLib/Z2Calc.h"
|
||||
#include "JSystem/JMath/random.h"
|
||||
#include "math.h"
|
||||
#include "dol2asm.h"
|
||||
#include <math.h>
|
||||
|
||||
/* 802A968C-802A96F4 2A3FCC 0068+00 1/1 16/16 0/0 .text linearTransform__6Z2CalcFfffffb
|
||||
*/
|
||||
f32 Z2Calc::linearTransform(f32 param1, f32 param2, f32 param3, f32 param4, f32 param5,
|
||||
bool param6) {
|
||||
f32 temp;
|
||||
f32 Z2Calc::linearTransform(f32 inValue, f32 inMin, f32 inMax, f32 outMin, f32 outMax, bool noClamp) {
|
||||
f32 transformed = outMin + ((inValue - inMin) * ((outMax - outMin) / (inMax - inMin)));
|
||||
if (noClamp) {
|
||||
return transformed;
|
||||
}
|
||||
|
||||
temp = param4 + (param1 - param2) * ((param5 - param4) / (param3 - param2));
|
||||
|
||||
if (param6) {
|
||||
return temp;
|
||||
} else if (param4 < param5) {
|
||||
if (temp > param5) {
|
||||
return param5;
|
||||
} else if (temp < param4) {
|
||||
return param4;
|
||||
} else {
|
||||
return temp;
|
||||
}
|
||||
} else if (temp > param4) {
|
||||
return param4;
|
||||
} else if (temp < param5) {
|
||||
return param5;
|
||||
if (outMin < outMax) {
|
||||
return transformed > outMax ? outMax :
|
||||
transformed < outMin ? outMin :
|
||||
transformed;
|
||||
} else {
|
||||
return temp;
|
||||
return transformed > outMin ? outMin :
|
||||
transformed < outMax ? outMax :
|
||||
transformed;
|
||||
}
|
||||
}
|
||||
|
||||
/* ############################################################################################## */
|
||||
/* 80455820-80455824 003E20 0004+00 0/0 1/1 0/0 .sdata2 cEqualCSlope__6Z2Calc */
|
||||
SECTION_SDATA2 f32 Z2Calc::cEqualCSlope = 1.0f;
|
||||
const f32 Z2Calc::cEqualCSlope = 1.0f;
|
||||
|
||||
/* 80455824-80455828 003E24 0004+00 0/0 1/1 0/0 .sdata2 cEqualPSlope__6Z2Calc */
|
||||
SECTION_SDATA2 f32 Z2Calc::cEqualPSlope = 0.5f;
|
||||
const f32 Z2Calc::cEqualPSlope = 0.5f;
|
||||
|
||||
/* 802A96F4-802A9814 2A4034 0120+00 0/0 29/29 0/0 .text
|
||||
* getParamByExp__6Z2CalcFffffffQ26Z2Calc9CurveSign */
|
||||
f32 Z2Calc::getParamByExp(f32 f1, f32 f2, f32 f3, f32 f4, f32 f5, f32 f6, Z2Calc::CurveSign sign) {
|
||||
f32 out;
|
||||
if (sign == Z2Calc::CURVE_SIGN_1) {
|
||||
f32 tmp = exp(Z2Calc::linearTransform(f1, f2, f3, 0.0f, f4, true));
|
||||
out = Z2Calc::linearTransform(tmp, 1.0f, exp(f4), f5, f6, true);
|
||||
} else if (sign == Z2Calc::CURVE_SIGN_0) {
|
||||
f32 tmp = exp(Z2Calc::linearTransform(f1, f2, f3, f4, 0.0f, true));
|
||||
out = Z2Calc::linearTransform(tmp, exp(f4), 1.0f, f5, f6, true);
|
||||
f32 Z2Calc::getParamByExp(f32 value, f32 inMin, f32 inMax, f32 exponent, f32 outMin, f32 outMax, Z2Calc::CurveSign curveSign) {
|
||||
if (curveSign == Z2Calc::CURVE_POSITIVE) {
|
||||
value = linearTransform(value, inMin, inMax, 0.0f, exponent, true);
|
||||
value = expf(value);
|
||||
value = linearTransform(value, 1.0f, expf(exponent), outMin, outMax, true);
|
||||
} else if (curveSign == Z2Calc::CURVE_NEGATIVE) {
|
||||
value = linearTransform(value, inMin, inMax, exponent, 0.0f, true);
|
||||
value = expf(value);
|
||||
value = linearTransform(value, expf(exponent), 1.0f, outMin, outMax, true);
|
||||
} else {
|
||||
out = Z2Calc::linearTransform(f1, f2, f3, f5, f6, false);
|
||||
value = linearTransform(value, inMin, inMax, outMin, outMax, false);
|
||||
}
|
||||
if (out > f6) {
|
||||
return f6;
|
||||
}
|
||||
if (out < f5) {
|
||||
return f5;
|
||||
}
|
||||
return out;
|
||||
|
||||
return value > outMax ? outMax :
|
||||
value < outMin ? outMin :
|
||||
value;
|
||||
}
|
||||
|
||||
/* 802A9814-802A98D4 2A4154 00C0+00 0/0 2/2 0/0 .text getRandom__6Z2CalcFfff */
|
||||
f32 Z2Calc::getRandom(f32 f1, f32 f2, f32 f3) {
|
||||
f32 tmp = 2.0f * f3;
|
||||
f32 tmp2 = (1.0f - f3) * -2.0f;
|
||||
f1 *= Z2Calc::getRandom_0_1() < f3 ? tmp : tmp2;
|
||||
f32 tmp3 = pow(Z2Calc::getRandom_0_1(), f2);
|
||||
return tmp3 * f1;
|
||||
f32 Z2Calc::getRandom(f32 magnitude, f32 exponent, f32 bias) {
|
||||
f32 posBias = 2.0f * bias;
|
||||
f32 negBias = (1.0f - bias) * -2.0f;
|
||||
magnitude *= Z2Calc::getRandom_0_1() < bias ? posBias : negBias;
|
||||
|
||||
f32 exprnd = pow(Z2Calc::getRandom_0_1(), exponent);
|
||||
return exprnd * magnitude;
|
||||
}
|
||||
|
||||
/* 802A98D4-802A9944 2A4214 0070+00 1/1 1/1 0/0 .text getRandom_0_1__6Z2CalcFv */
|
||||
f32 Z2Calc::getRandom_0_1(void) {
|
||||
static JMath::TRandom_fast_ oRandom(0);
|
||||
f32 Z2Calc::getRandom_0_1() {
|
||||
static JMath::TRandom_<JMath::TRandom_fast_> oRandom(0);
|
||||
return oRandom.get_ufloat_1();
|
||||
}
|
||||
|
||||
/* 802A9944-802A9958 2A4284 0014+00 0/0 1/1 0/0 .text setParam__Q26Z2Calc8FNoise1fFfff */
|
||||
void Z2Calc::FNoise1f::setParam(f32 param1, f32 param2, f32 param3) {
|
||||
this->unk0 = param1;
|
||||
this->unk4 = param1;
|
||||
this->unk12 = param2;
|
||||
this->unk8 = param3;
|
||||
void Z2Calc::FNoise1f::setParam(f32 value, f32 threshold, f32 step) {
|
||||
value_ = value;
|
||||
targetValue_ = value;
|
||||
threshold_ = threshold;
|
||||
step_ = step;
|
||||
}
|
||||
|
||||
/* 802A9958-802A99A0 2A4298 0048+00 1/1 0/0 0/0 .text tau__Q26Z2Calc8FNoise1fFf */
|
||||
f32 Z2Calc::FNoise1f::tau(f32 param1) {
|
||||
f32 temp1;
|
||||
f32 temp2;
|
||||
f32 Z2Calc::FNoise1f::tau(f32 input) {
|
||||
f32 var_f30 = 1.0f;
|
||||
|
||||
temp1 = param1;
|
||||
temp2 = temp1 + (temp1 * temp1);
|
||||
|
||||
if (temp2 > 1.0f) {
|
||||
temp2 = temp2 - 1.0f;
|
||||
|
||||
if (temp1 < this->unk12) {
|
||||
temp2 = temp2 + this->unk12;
|
||||
f32 result = input + (input * input);
|
||||
if (result > var_f30) {
|
||||
result = result - var_f30;
|
||||
if (input < threshold_) {
|
||||
result += threshold_;
|
||||
}
|
||||
|
||||
return temp2;
|
||||
} else if (temp1 < this->unk12) {
|
||||
temp2 = temp2 + this->unk12;
|
||||
return result;
|
||||
}
|
||||
return temp2;
|
||||
|
||||
if (input < threshold_) {
|
||||
result += threshold_;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/* 802A99A0-802A9A34 2A42E0 0094+00 0/0 5/5 0/0 .text calcNoise1f__Q26Z2Calc8FNoise1fFv
|
||||
*/
|
||||
f32 Z2Calc::FNoise1f::calcNoise1f(void) {
|
||||
f32 temp1;
|
||||
f32 temp2;
|
||||
|
||||
temp1 = this->unk0;
|
||||
|
||||
if (this->unk0 < this->unk4) {
|
||||
this->unk0 = temp1 + this->unk8;
|
||||
|
||||
if (this->unk0 < this->unk4) {
|
||||
return this->unk0;
|
||||
f32 Z2Calc::FNoise1f::calcNoise1f() {
|
||||
if (value_ < targetValue_) {
|
||||
value_ += step_;
|
||||
if (value_ < targetValue_) {
|
||||
return value_;
|
||||
}
|
||||
} else {
|
||||
this->unk0 = temp1 - this->unk8;
|
||||
|
||||
if (this->unk0 > this->unk4) {
|
||||
return this->unk0;
|
||||
value_ -= step_;
|
||||
if (value_ > targetValue_) {
|
||||
return value_;
|
||||
}
|
||||
}
|
||||
this->unk0 = this->unk4;
|
||||
temp2 = tau(this->unk0);
|
||||
this->unk4 = temp2;
|
||||
|
||||
return this->unk0;
|
||||
value_ = targetValue_;
|
||||
targetValue_ = tau(value_);
|
||||
return value_;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user