diff --git a/include/JSystem/JStudio/JStudio/functionvalue_weak.h b/include/JSystem/JStudio/JStudio/functionvalue_weak.h new file mode 100644 index 000000000..305e2f221 --- /dev/null +++ b/include/JSystem/JStudio/JStudio/functionvalue_weak.h @@ -0,0 +1,46 @@ +#ifndef FUNCTIONVALUE_INLINES_H +#define FUNCTIONVALUE_INLINES_H + +// Note: These weak functions need to go in a separate file for functionvalue's .sdata2 section to match properly. +// The actual name of this file and its exact contents are unknown, this is a guess. + +#include "global.h" +#include "math.h" + +namespace JStudio { + +namespace functionvalue { + +/* 80272F64-80272F68 .text extrapolateParameter_raw__Q27JStudio13functionvalueFdd */ +inline f64 extrapolateParameter_raw(f64 a1, f64 a2) { + return a1; +} + +/* 80272F68-80272FA4 .text extrapolateParameter_repeat__Q27JStudio13functionvalueFdd */ +inline f64 extrapolateParameter_repeat(f64 a1, f64 a2) { + f64 t = fmod(a1, a2); + + if (t < 0.0) + t += a2; + + return t; +} + +f64 extrapolateParameter_turn(f64, f64); + +/* 80272FA4-80272FD0 .text extrapolateParameter_clamp__Q27JStudio13functionvalueFdd */ +inline f64 extrapolateParameter_clamp(f64 value, f64 max) { + if (value <= 0.0) + return 0.0; + + if (max <= value) + value = max; + + return value; +} + +}; // namespace functionvalue + +} // namespace JStudio + +#endif /* FUNCTIONVALUE_INLINES_H */ diff --git a/src/JSystem/JStudio/JStudio/functionvalue.cpp b/src/JSystem/JStudio/JStudio/functionvalue.cpp index aaa7a2742..2f537a5ae 100644 --- a/src/JSystem/JStudio/JStudio/functionvalue.cpp +++ b/src/JSystem/JStudio/JStudio/functionvalue.cpp @@ -4,6 +4,7 @@ // #include "JSystem/JStudio/JStudio/functionvalue.h" +#include "JSystem/JStudio/JStudio/functionvalue_weak.h" #include "JSystem/JUtility/JUTException.h" #include "JSystem/JGadget/linklist.h" #include "dolphin/types.h" @@ -18,21 +19,6 @@ Iterator findUpperBound_binary_current(Iterator, Iterator, Iterator, const B1&); namespace JStudio { -namespace functionvalue { -f64 extrapolateParameter_raw(f64, f64); -inline f64 extrapolateParameter_repeat(f64, f64); -f64 extrapolateParameter_turn(f64, f64); -f64 extrapolateParameter_clamp(f64, f64); -static inline f64 i_extrapolateParameter_repeat(f64 a1, f64 a2) { - f64 t = fmod(a1, a2); - - if (t < 0.0) - t += a2; - - return t; -} -}; // namespace functionvalue - namespace { ExtrapolateParameter gapfnExtrapolateParameter_[4] = { functionvalue::extrapolateParameter_raw, @@ -76,7 +62,6 @@ namespace functionvalue { /* 802710E8-8027114C .text interpolateValue_hermite__Q27JStudio13functionvalueFddddddd */ f64 interpolateValue_hermite(f64 c0, f64 c1, f64 x, f64 c2, f64 x2, f64 c3, f64 x3) { - /* Nonmatching */ f64 a; f64 b; f64 c; @@ -134,7 +119,7 @@ inline f64 interpolateValue_plateau(f64 a1, f64 a2, f64 a3, f64 a4, f64 a5) { /* 80271290-802712F0 .text extrapolateParameter_turn__Q27JStudio13functionvalueFdd */ f64 extrapolateParameter_turn(f64 param_0, f64 param_1) { f64 dVar2 = 2.0 * param_1; - f64 dVar1 = i_extrapolateParameter_repeat(param_0, dVar2); + f64 dVar1 = extrapolateParameter_repeat(param_0, dVar2); if (dVar1 >= param_1) { dVar1 = dVar2 - dVar1; } @@ -156,6 +141,7 @@ void TFunctionValueAttribute_range::range_initialize() { /* 80271324-802713CC .text range_prepare__Q27JStudio29TFunctionValueAttribute_rangeFv */ void TFunctionValueAttribute_range::range_prepare() { + /* Nonmatching */ TFunctionValue::TEProgress progress = range_getProgress(); switch (progress) { @@ -196,6 +182,7 @@ void TFunctionValueAttribute_range::range_set(f64 begin, f64 end) { /* 802713E0-802716F0 .text range_getParameter__Q27JStudio29TFunctionValueAttribute_rangeCFddd */ f64 TFunctionValueAttribute_range::range_getParameter(f64 arg1, f64 arg2, f64 arg3) const { + /* Nonmatching */ f64 progress = range_getParameter_progress(arg1); TFunctionValue::TEAdjust adjust = range_getAdjust(); @@ -281,7 +268,6 @@ f64 TFunctionValue_composite::composite_raw(const JGadget::TVector_pointerRCQ37JStudio24TFunctionValue_composite5TDatad */ f64 TFunctionValue_composite::composite_index(const JGadget::TVector_pointer& param_1, const TFunctionValue_composite::TData& param_2, f64 param_3) { - /* Nonmatching */ s32 size = param_1.size(); if (size <= 1) { return 0.0; @@ -566,6 +552,7 @@ void TFunctionValue_list::prepare() { /* 8027224C-80272604 .text getValue__Q27JStudio19TFunctionValue_listFd */ f64 TFunctionValue_list::getValue(f64 param_1) { + /* Nonmatching */ f64 dVar9 = range_getParameter_progress(param_1); u32 iVar7 = uData_ - 1; TFunctionValue::TEAdjust iVar5 = range_getAdjust(); @@ -902,36 +889,4 @@ f64 TFunctionValue_hermite::getValue(f64 pfData_) { pfVar5[1], pfVar5[2]); } -namespace functionvalue { - -/* 80272F64-80272F68 .text extrapolateParameter_raw__Q27JStudio13functionvalueFdd */ -f64 extrapolateParameter_raw(f64 a1, f64 a2) { - return a1; -} - -/* 80272F68-80272FA4 .text extrapolateParameter_repeat__Q27JStudio13functionvalueFdd */ -f64 extrapolateParameter_repeat(f64 a1, f64 a2) { - /* Nonmatching */ - f64 t = fmod(a1, a2); - - if (t < 0.0) - t += a2; - - return t; -} - -/* 80272FA4-80272FD0 .text extrapolateParameter_clamp__Q27JStudio13functionvalueFdd */ -f64 extrapolateParameter_clamp(f64 value, f64 max) { - /* Nonmatching */ - if (value <= 0.0) - return 0.0; - - if (max <= value) - value = max; - - return value; -} - -} // namespace functionvalue - } // namespace JStudio diff --git a/src/JSystem/JStudio/JStudio/jstudio-object.cpp b/src/JSystem/JStudio/JStudio/jstudio-object.cpp index 01cf7e542..d1f909b01 100644 --- a/src/JSystem/JStudio/JStudio/jstudio-object.cpp +++ b/src/JSystem/JStudio/JStudio/jstudio-object.cpp @@ -307,11 +307,11 @@ JStudio::TObject_message::TObject_message(const JStudio::stb::data::TParse_TBloc /* 802700F4-80270184 .text do_paragraph__Q27JStudio15TObject_messageFUlPCvUl */ void JStudio::TObject_message::do_paragraph(u32 param_1, const void* param_2, u32 param_3) { - /* Nonmatching */ TAdaptor* adaptor = getAdaptor(); if (adaptor != NULL) { u32 uVar1 = (param_1 >> 5); param_1 &= 0x1f; + u8 temp = param_1; // fakematch? paragraphFunc pmfn_ = NULL; switch (uVar1) { case 0x42: @@ -320,7 +320,7 @@ void JStudio::TObject_message::do_paragraph(u32 param_1, const void* param_2, u3 default: return; } - (((TObject*)adaptor)->*pmfn_)(param_1, param_2, param_3); + (((TObject*)adaptor)->*pmfn_)(temp, param_2, param_3); } }