diff options
| author | LagoLunatic <LagoLunatic@users.noreply.github.com> | 2025-04-12 02:12:27 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-04-12 09:12:27 +0300 |
| commit | b52d288cd025ee6459caf3fc838b5108b45a0f75 (patch) | |
| tree | 4315dc61b5506ea048ed2676cb9b780f64f29c8e /include | |
| parent | cc3e0856bfc1d7597c47c84fb428da5f8e0a5536 (diff) | |
functionvalue 100% (#2389)
* functionvalue 100%
* Fix ninja always thinking the build is dirty due to nonexistent dependent file
Diffstat (limited to 'include')
| -rw-r--r-- | include/JSystem/JGadget/search.h | 23 | ||||
| -rw-r--r-- | include/JSystem/JGadget/vector.h | 15 | ||||
| -rw-r--r-- | include/JSystem/JStudio/JStudio/functionvalue.h | 233 | ||||
| -rw-r--r-- | include/JSystem/JStudio/JStudio_JStage/control.h | 4 |
4 files changed, 184 insertions, 91 deletions
diff --git a/include/JSystem/JGadget/search.h b/include/JSystem/JGadget/search.h index 1e6b7561af..1fdd846dde 100644 --- a/include/JSystem/JGadget/search.h +++ b/include/JSystem/JGadget/search.h @@ -25,13 +25,22 @@ struct TExpandStride_<s32> { //! Target: toValueFromIndex<PFdd_d>__7JGadgetFiPCPFdd_dUlRCPFdd_d_RCPFdd_d template <typename T> inline const T& toValueFromIndex(int idx, const T* pValue, u32 count, const T& fallback) { - ASSERT(pValue != NULL); - return (idx >= count) ? fallback : pValue[idx]; + JUT_ASSERT(200, pValue!=0); + u32 index = idx; + if (index >= count) { + return fallback; + } else { + return pValue[index]; + } } +template <typename Category, typename T, typename Distance, typename Pointer, typename Reference> +struct TIterator : public std::iterator<Category, T, Distance, Pointer, Reference> { +}; + template <typename Iterator, typename T, typename Predicate> inline Iterator findUpperBound_binary_all(Iterator first, Iterator last, const T& val, Predicate p) { - return upper_bound(first, last, val, p); + return std::upper_bound(first, last, val, p); } template <typename Iterator, typename T, typename Predicate> @@ -104,15 +113,13 @@ inline Iterator findUpperBound_binary_end(Iterator first, Iterator last, const T template <typename Iterator, typename T, typename Predicate> Iterator findUpperBound_binary_current(Iterator first, Iterator last, Iterator current, const T& val, Predicate p) { return current == last || p(val, *current) ? - findUpperBound_binary_end(first, current, val, p) - : findUpperBound_binary_begin(current, last, val, p); + findUpperBound_binary_end(first, current, val, p) : + findUpperBound_binary_begin(current, last, val, p); } -// NONMATCHING stack alloc template <typename Iterator, typename T> Iterator findUpperBound_binary_current(Iterator first, Iterator last, Iterator current, const T& val) { - std::less<T> less; - return findUpperBound_binary_current(first, last, current, val, less); + return findUpperBound_binary_current(first, last, current, val, std::less<T>()); } } // namespace JGadget diff --git a/include/JSystem/JGadget/vector.h b/include/JSystem/JGadget/vector.h index 6372f183a5..e38211f6b5 100644 --- a/include/JSystem/JGadget/vector.h +++ b/include/JSystem/JGadget/vector.h @@ -1,9 +1,8 @@ #ifndef VECTOR_H #define VECTOR_H -#include <dolphin/types.h> - -extern u8 data_804511E0; +#include "JSystem/JGadget/std-memory.h" +#include "types.h" namespace JGadget { @@ -15,16 +14,6 @@ typedef u32 (*ExtendFunc)(u32, u32, u32); } // namespace vector -template <typename T> -struct TAllocator { - static TAllocator get() {} - inline TAllocator(u8 param_0) { _0 = param_0; } - /* 0x0 */ u8 _0; - /* 0x4 */ u32 _4; - /* 0x8 */ u32 _8; - /* 0xc */ u32 _c; -}; - template <typename T, template <class> class Allocator> struct TVector { TVector(Allocator<T> alloc) { diff --git a/include/JSystem/JStudio/JStudio/functionvalue.h b/include/JSystem/JStudio/JStudio/functionvalue.h index 6152f05fdb..2d9430287b 100644 --- a/include/JSystem/JStudio/JStudio/functionvalue.h +++ b/include/JSystem/JStudio/JStudio/functionvalue.h @@ -1,11 +1,10 @@ #ifndef FUNCTIONVALUE_H #define FUNCTIONVALUE_H +#include <math.h> #include "JSystem/JGadget/std-vector.h" -#include "dolphin/os.h" -#include <iterator.h> - -extern u8 lit_569; +#include "JSystem/JGadget/define.h" +#include "JSystem/JGadget/search.h" namespace JStudio { @@ -229,8 +228,8 @@ public: }; class TFunctionValue_transition : public TFunctionValue, - TFunctionValueAttribute_range, - TFunctionValueAttribute_interpolate { + public TFunctionValueAttribute_range, + public TFunctionValueAttribute_interpolate { public: /* 802823EC */ TFunctionValue_transition(); /* 80283CE4 */ virtual ~TFunctionValue_transition() {} @@ -254,8 +253,8 @@ private: }; class TFunctionValue_list : public TFunctionValue, - TFunctionValueAttribute_range, - TFunctionValueAttribute_interpolate { + public TFunctionValueAttribute_range, + public TFunctionValueAttribute_interpolate { public: struct TIndexData_ { f64 _0; @@ -305,43 +304,78 @@ private: }; class TFunctionValue_list_parameter : public TFunctionValue, - TFunctionValueAttribute_range, - TFunctionValueAttribute_interpolate { + public TFunctionValueAttribute_range, + public TFunctionValueAttribute_interpolate { public: - struct TIterator_data_ { - TIterator_data_(const f32* value) : value_(value) {} - TIterator_data_& operator--() { - value_ -= 2; + struct TIterator_data_ + : public JGadget::TIterator< + std::random_access_iterator_tag, + const f32, + ptrdiff_t, + const f32*, + const f32& + > + { + TIterator_data_(const TFunctionValue_list_parameter& rParent, const f32* value) { +#ifdef DEBUG + pOwn_ = &rParent; +#endif + pf_ = value; + } + + const f32* get() const { return pf_; } + void set(const f32* value) { pf_ = value; } + + friend bool operator==(const TIterator_data_& r1, const TIterator_data_& r2) { +#ifdef DEBUG + if (!(r1.pOwn_==r2.pOwn_)) { + JGadget_outMessage msg(JGadget_outMessage::warning, __FILE__, 124); + msg << "r1.pOwn_==r2.pOwn_"; + } +#endif + return r1.pf_ == r2.pf_; + } + + f32 operator*() { +#ifdef DEBUG + JUT_ASSERT(947, pf_!=0); +#endif + return *pf_; + } + + TIterator_data_& operator+=(s32 n) { + pf_ += suData_size * n; return *this; } TIterator_data_& operator-=(s32 n) { - value_ -= n * 2; + pf_ -= suData_size * n; return *this; } - s32 operator-(const TIterator_data_& other) { - return (u32)(value_ - other.value_) >> 1; - } TIterator_data_& operator++() { - value_ += 2; + pf_ += suData_size; return *this; } - TIterator_data_& operator+=(s32 n) { - value_ += n * 2; + TIterator_data_& operator--() { + pf_ -= suData_size; return *this; } - friend bool operator==(const TIterator_data_& lhs, const TIterator_data_& rhs) { return lhs.value_ == rhs.value_; } - f32 operator*() { return *value_; } - const f32* get() const { return value_; } - void set(const f32* value) { value_ = value; } - - const f32* value_; + friend s32 operator-(const TIterator_data_& r1, const TIterator_data_& r2) { +#ifdef DEBUG + if (!(r1.pOwn_==r2.pOwn_)) { + JGadget_outMessage msg(JGadget_outMessage::warning, __FILE__, 124); + msg << "r1.pOwn_==r2.pOwn_"; + } +#endif + return (r1.pf_ - r2.pf_) / suData_size; + } - typedef s32 difference_type; - typedef f32 value_type; - typedef const f32* pointer; - typedef const f32& reference; - typedef std::random_access_iterator_tag iterator_category; +#ifdef DEBUG + /* 0x00 */ const TFunctionValue_list_parameter* pOwn_; + /* 0x04 */ const f32* pf_; +#else + /* 0x00 */ const f32* pf_; +#endif }; typedef f64 (*update_INTERPOLATE)(const TFunctionValue_list_parameter&, f64); @@ -364,10 +398,12 @@ public: /* 80283060 */ static f64 update_INTERPOLATE_BSPLINE_dataMore3_(JStudio::TFunctionValue_list_parameter const&, f64); - f64 data_getValue_back() { - return pfData_[(uData_ - 1) * 2]; + static const u32 suData_size = 2; + + f64 data_getValue_back() const { + return pfData_[(uData_ - 1) * suData_size]; } - f64 data_getValue_front() { return pfData_[0]; } + f64 data_getValue_front() const { return pfData_[0]; } private: /* 0x44 */ const f32* pfData_; @@ -378,52 +414,88 @@ private: /* 0x58 */ update_INTERPOLATE pfnUpdate_; }; -class TFunctionValue_hermite : public TFunctionValue, TFunctionValueAttribute_range { +class TFunctionValue_hermite : public TFunctionValue, public TFunctionValueAttribute_range { public: - struct TIterator_data_ { + struct TIterator_data_ + : public JGadget::TIterator< + std::random_access_iterator_tag, + const f32, + ptrdiff_t, + const f32*, + const f32& + > + { TIterator_data_(const TFunctionValue_hermite& rParent, const f32* value) { - value_ = value; - size_ = rParent.data_getSize(); +#ifdef DEBUG + pOwn_ = &rParent; +#endif + pf_ = value; + uSize_ = rParent.data_getSize(); } - const f32* get() { return value_; } - + const f32* get() const { return pf_; } void set(const f32* value, u32 size) { - value_ = value; - size_ = size; + pf_ = value; + uSize_ = size; } - - friend bool operator==(const TIterator_data_& lhs, const TIterator_data_& rhs) { return lhs.value_ == rhs.value_; } - f32 operator*() { return *value_; } - TIterator_data_& operator--() { - value_ -= size_; + friend bool operator==(const TIterator_data_& r1, const TIterator_data_& r2) { +#ifdef DEBUG + if (!(r1.pOwn_==r2.pOwn_)) { + JGadget_outMessage msg(JGadget_outMessage::warning, __FILE__, 124); + msg << "r1.pOwn_==r2.pOwn_"; + } +#endif + return r1.pf_ == r2.pf_; + } + + f32 operator*() { +#ifdef DEBUG + JUT_ASSERT(1098, pf_!=0); +#endif + return *pf_; + } + + TIterator_data_& operator+=(s32 n) { + pf_ += uSize_ * n; return *this; } TIterator_data_& operator-=(s32 n) { - value_ -= size_ * n; + pf_ -= uSize_ * n; return *this; } - s32 operator-(const TIterator_data_& other) { - return (value_ - other.value_) / size_; - } TIterator_data_& operator++() { - value_ += size_; + pf_ += uSize_; return *this; } - TIterator_data_& operator+=(s32 n) { - value_ += size_ * n; + TIterator_data_& operator--() { + pf_ -= uSize_; return *this; } - /* 0x00 */ const f32* value_; - /* 0x04 */ u32 size_; + friend s32 operator-(const TIterator_data_& r1, const TIterator_data_& r2) { +#ifdef DEBUG + if (!(r1.pOwn_==r2.pOwn_)) { + JGadget_outMessage msg(JGadget_outMessage::warning, __FILE__, 124); + msg << "r1.pOwn_==r2.pOwn_"; + } + if (!(r1.uSize_==r2.uSize_)) { + JGadget_outMessage msg(JGadget_outMessage::warning, __FILE__, 124); + msg << "r1.uSize_==r2.uSize_"; + } + JUT_ASSERT(0, r1.uSize_>0); +#endif + return (r1.pf_ - r2.pf_) / r1.uSize_; + } - typedef s32 difference_type; - typedef f32 value_type; - typedef const f32* pointer; - typedef const f32& reference; - typedef std::random_access_iterator_tag iterator_category; +#ifdef DEBUG + /* 0x00 */ const TFunctionValue_hermite* pOwn_; + /* 0x04 */ const f32* pf_; + /* 0x08 */ u32 uSize_; +#else + /* 0x00 */ const f32* pf_; + /* 0x04 */ u32 uSize_; +#endif }; /* 802832C4 */ TFunctionValue_hermite(); @@ -437,13 +509,13 @@ public: /* 8028344C */ virtual f64 getValue(f64); u32 data_getSize() const { return uSize_; } - f64 data_getValue_back() { - return pf_[(u_ - 1) * uSize_]; + f64 data_getValue_back() const { + return pfData_[(u_ - 1) * uSize_]; } - f64 data_getValue_front() { return pf_[0]; } + f64 data_getValue_front() const { return pfData_[0]; } private: - /* 0x40 */ const f32* pf_; + /* 0x40 */ const f32* pfData_; /* 0x44 */ u32 u_; /* 0x48 */ u32 uSize_; /* 0x4c */ TIterator_data_ dat1; @@ -451,6 +523,35 @@ private: /* 0x54 */ TIterator_data_ dat3; }; +namespace functionvalue { + +inline f64 extrapolateParameter_raw(f64 a1, f64 a2) { + return a1; +} + +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); + +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_H */ diff --git a/include/JSystem/JStudio/JStudio_JStage/control.h b/include/JSystem/JStudio/JStudio_JStage/control.h index c595055640..86ed98c0be 100644 --- a/include/JSystem/JStudio/JStudio_JStage/control.h +++ b/include/JSystem/JStudio/JStudio_JStage/control.h @@ -52,10 +52,6 @@ struct TAdaptor_actor : public JStudio::TAdaptor_actor, public JStudio_JStage::T typedef f32 (JStage::TActor::*Getter)() const; typedef f32 (JStage::TActor::*MaxGetter)() const; - enum TEVariableValue { - TEACTOR_1 = 1, - }; - struct TVVOutput_ANIMATION_FRAME_ : public JStudio::TVariableValue::TOutput { |
