From 1c891adeb8a58a62fb3e6a6ff5bb3ec8da00f883 Mon Sep 17 00:00:00 2001 From: hatal175 Date: Wed, 31 Jan 2024 02:02:22 +0200 Subject: [PATCH] work on functionvalue (#2054) --- .../JStudio/functionvalue/func_8028202C.s | 29 - .../JStudio/functionvalue/func_80282094.s | 36 - .../JStudio/functionvalue/func_80282200.s | 36 - ...ue__Q27JStudio22TFunctionValue_hermiteFd.s | 77 --- ...JStudio29TFunctionValue_list_parameterFd.s | 58 -- include/JSystem/JGadget/vector.h | 18 +- .../JSystem/JStudio/JStudio/functionvalue.h | 88 ++- .../JSystem/JStudio/JStudio/functionvalue.cpp | 635 ++++++++++++++---- .../MSL/MSL_C++/MSL_Common/Include/iterator.h | 7 + 9 files changed, 593 insertions(+), 391 deletions(-) delete mode 100644 asm/JSystem/JStudio/JStudio/functionvalue/func_8028202C.s delete mode 100644 asm/JSystem/JStudio/JStudio/functionvalue/func_80282094.s delete mode 100644 asm/JSystem/JStudio/JStudio/functionvalue/func_80282200.s delete mode 100644 asm/JSystem/JStudio/JStudio/functionvalue/getValue__Q27JStudio22TFunctionValue_hermiteFd.s delete mode 100644 asm/JSystem/JStudio/JStudio/functionvalue/getValue__Q27JStudio29TFunctionValue_list_parameterFd.s diff --git a/asm/JSystem/JStudio/JStudio/functionvalue/func_8028202C.s b/asm/JSystem/JStudio/JStudio/functionvalue/func_8028202C.s deleted file mode 100644 index 1616a3c8eeb..00000000000 --- a/asm/JSystem/JStudio/JStudio/functionvalue/func_8028202C.s +++ /dev/null @@ -1,29 +0,0 @@ -lbl_8028202C: -/* 8028202C 94 21 FF F0 */ stwu r1, -0x10(r1) -/* 80282030 7C 08 02 A6 */ mflr r0 -/* 80282034 90 01 00 14 */ stw r0, 0x14(r1) -/* 80282038 C8 04 00 00 */ lfd f0, 0(r4) -/* 8028203C FC 21 00 28 */ fsub f1, f1, f0 -/* 80282040 80 03 00 08 */ lwz r0, 8(r3) -/* 80282044 80 63 00 04 */ lwz r3, 4(r3) -/* 80282048 90 61 00 08 */ stw r3, 8(r1) -/* 8028204C 90 01 00 0C */ stw r0, 0xc(r1) -/* 80282050 48 00 00 24 */ b lbl_80282074 -lbl_80282054: -/* 80282054 80 61 00 08 */ lwz r3, 8(r1) -/* 80282058 38 03 00 04 */ addi r0, r3, 4 -/* 8028205C 90 01 00 08 */ stw r0, 8(r1) -/* 80282060 80 63 00 00 */ lwz r3, 0(r3) -/* 80282064 81 83 00 00 */ lwz r12, 0(r3) -/* 80282068 81 8C 00 1C */ lwz r12, 0x1c(r12) -/* 8028206C 7D 89 03 A6 */ mtctr r12 -/* 80282070 4E 80 04 21 */ bctrl -lbl_80282074: -/* 80282074 80 61 00 08 */ lwz r3, 8(r1) -/* 80282078 80 01 00 0C */ lwz r0, 0xc(r1) -/* 8028207C 7C 03 00 40 */ cmplw r3, r0 -/* 80282080 40 82 FF D4 */ bne lbl_80282054 -/* 80282084 80 01 00 14 */ lwz r0, 0x14(r1) -/* 80282088 7C 08 03 A6 */ mtlr r0 -/* 8028208C 38 21 00 10 */ addi r1, r1, 0x10 -/* 80282090 4E 80 00 20 */ blr diff --git a/asm/JSystem/JStudio/JStudio/functionvalue/func_80282094.s b/asm/JSystem/JStudio/JStudio/functionvalue/func_80282094.s deleted file mode 100644 index 5e4326cc199..00000000000 --- a/asm/JSystem/JStudio/JStudio/functionvalue/func_80282094.s +++ /dev/null @@ -1,36 +0,0 @@ -lbl_80282094: -/* 80282094 94 21 FF E0 */ stwu r1, -0x20(r1) -/* 80282098 7C 08 02 A6 */ mflr r0 -/* 8028209C 90 01 00 24 */ stw r0, 0x24(r1) -/* 802820A0 DB E1 00 18 */ stfd f31, 0x18(r1) -/* 802820A4 DB C1 00 10 */ stfd f30, 0x10(r1) -/* 802820A8 FF C0 08 90 */ fmr f30, f1 -/* 802820AC CB E4 00 00 */ lfd f31, 0(r4) -/* 802820B0 80 03 00 08 */ lwz r0, 8(r3) -/* 802820B4 80 63 00 04 */ lwz r3, 4(r3) -/* 802820B8 90 61 00 08 */ stw r3, 8(r1) -/* 802820BC 90 01 00 0C */ stw r0, 0xc(r1) -/* 802820C0 48 00 00 2C */ b lbl_802820EC -lbl_802820C4: -/* 802820C4 80 61 00 08 */ lwz r3, 8(r1) -/* 802820C8 38 03 00 04 */ addi r0, r3, 4 -/* 802820CC 90 01 00 08 */ stw r0, 8(r1) -/* 802820D0 80 63 00 00 */ lwz r3, 0(r3) -/* 802820D4 FC 20 F0 90 */ fmr f1, f30 -/* 802820D8 81 83 00 00 */ lwz r12, 0(r3) -/* 802820DC 81 8C 00 1C */ lwz r12, 0x1c(r12) -/* 802820E0 7D 89 03 A6 */ mtctr r12 -/* 802820E4 4E 80 04 21 */ bctrl -/* 802820E8 FF FF 08 2A */ fadd f31, f31, f1 -lbl_802820EC: -/* 802820EC 80 61 00 08 */ lwz r3, 8(r1) -/* 802820F0 80 01 00 0C */ lwz r0, 0xc(r1) -/* 802820F4 7C 03 00 40 */ cmplw r3, r0 -/* 802820F8 40 82 FF CC */ bne lbl_802820C4 -/* 802820FC FC 20 F8 90 */ fmr f1, f31 -/* 80282100 CB E1 00 18 */ lfd f31, 0x18(r1) -/* 80282104 CB C1 00 10 */ lfd f30, 0x10(r1) -/* 80282108 80 01 00 24 */ lwz r0, 0x24(r1) -/* 8028210C 7C 08 03 A6 */ mtlr r0 -/* 80282110 38 21 00 20 */ addi r1, r1, 0x20 -/* 80282114 4E 80 00 20 */ blr diff --git a/asm/JSystem/JStudio/JStudio/functionvalue/func_80282200.s b/asm/JSystem/JStudio/JStudio/functionvalue/func_80282200.s deleted file mode 100644 index 6391d0431d3..00000000000 --- a/asm/JSystem/JStudio/JStudio/functionvalue/func_80282200.s +++ /dev/null @@ -1,36 +0,0 @@ -lbl_80282200: -/* 80282200 94 21 FF E0 */ stwu r1, -0x20(r1) -/* 80282204 7C 08 02 A6 */ mflr r0 -/* 80282208 90 01 00 24 */ stw r0, 0x24(r1) -/* 8028220C DB E1 00 18 */ stfd f31, 0x18(r1) -/* 80282210 DB C1 00 10 */ stfd f30, 0x10(r1) -/* 80282214 FF C0 08 90 */ fmr f30, f1 -/* 80282218 CB E4 00 00 */ lfd f31, 0(r4) -/* 8028221C 80 03 00 08 */ lwz r0, 8(r3) -/* 80282220 80 63 00 04 */ lwz r3, 4(r3) -/* 80282224 90 61 00 08 */ stw r3, 8(r1) -/* 80282228 90 01 00 0C */ stw r0, 0xc(r1) -/* 8028222C 48 00 00 2C */ b lbl_80282258 -lbl_80282230: -/* 80282230 80 61 00 08 */ lwz r3, 8(r1) -/* 80282234 38 03 00 04 */ addi r0, r3, 4 -/* 80282238 90 01 00 08 */ stw r0, 8(r1) -/* 8028223C 80 63 00 00 */ lwz r3, 0(r3) -/* 80282240 FC 20 F0 90 */ fmr f1, f30 -/* 80282244 81 83 00 00 */ lwz r12, 0(r3) -/* 80282248 81 8C 00 1C */ lwz r12, 0x1c(r12) -/* 8028224C 7D 89 03 A6 */ mtctr r12 -/* 80282250 4E 80 04 21 */ bctrl -/* 80282254 FF FF 00 72 */ fmul f31, f31, f1 -lbl_80282258: -/* 80282258 80 61 00 08 */ lwz r3, 8(r1) -/* 8028225C 80 01 00 0C */ lwz r0, 0xc(r1) -/* 80282260 7C 03 00 40 */ cmplw r3, r0 -/* 80282264 40 82 FF CC */ bne lbl_80282230 -/* 80282268 FC 20 F8 90 */ fmr f1, f31 -/* 8028226C CB E1 00 18 */ lfd f31, 0x18(r1) -/* 80282270 CB C1 00 10 */ lfd f30, 0x10(r1) -/* 80282274 80 01 00 24 */ lwz r0, 0x24(r1) -/* 80282278 7C 08 03 A6 */ mtlr r0 -/* 8028227C 38 21 00 20 */ addi r1, r1, 0x20 -/* 80282280 4E 80 00 20 */ blr diff --git a/asm/JSystem/JStudio/JStudio/functionvalue/getValue__Q27JStudio22TFunctionValue_hermiteFd.s b/asm/JSystem/JStudio/JStudio/functionvalue/getValue__Q27JStudio22TFunctionValue_hermiteFd.s deleted file mode 100644 index 4f00d8726cf..00000000000 --- a/asm/JSystem/JStudio/JStudio/functionvalue/getValue__Q27JStudio22TFunctionValue_hermiteFd.s +++ /dev/null @@ -1,77 +0,0 @@ -lbl_8028344C: -/* 8028344C 94 21 FF C0 */ stwu r1, -0x40(r1) -/* 80283450 7C 08 02 A6 */ mflr r0 -/* 80283454 90 01 00 44 */ stw r0, 0x44(r1) -/* 80283458 93 E1 00 3C */ stw r31, 0x3c(r1) -/* 8028345C 7C 7F 1B 78 */ mr r31, r3 -/* 80283460 D8 21 00 08 */ stfd f1, 8(r1) -/* 80283464 80 A3 00 40 */ lwz r5, 0x40(r3) -/* 80283468 38 7F 00 08 */ addi r3, r31, 8 -/* 8028346C C0 45 00 00 */ lfs f2, 0(r5) -/* 80283470 80 9F 00 44 */ lwz r4, 0x44(r31) -/* 80283474 38 84 FF FF */ addi r4, r4, -1 -/* 80283478 80 1F 00 48 */ lwz r0, 0x48(r31) -/* 8028347C 7C 04 01 D6 */ mullw r0, r4, r0 -/* 80283480 54 00 10 3A */ slwi r0, r0, 2 -/* 80283484 7C 65 04 2E */ lfsx f3, r5, r0 -/* 80283488 4B FF E5 81 */ bl range_getParameter__Q27JStudio29TFunctionValueAttribute_rangeCFddd -/* 8028348C D8 21 00 08 */ stfd f1, 8(r1) -/* 80283490 80 7F 00 5C */ lwz r3, 0x5c(r31) -/* 80283494 80 1F 00 60 */ lwz r0, 0x60(r31) -/* 80283498 90 61 00 10 */ stw r3, 0x10(r1) -/* 8028349C 90 01 00 14 */ stw r0, 0x14(r1) -/* 802834A0 80 7F 00 54 */ lwz r3, 0x54(r31) -/* 802834A4 80 1F 00 58 */ lwz r0, 0x58(r31) -/* 802834A8 90 61 00 18 */ stw r3, 0x18(r1) -/* 802834AC 90 01 00 1C */ stw r0, 0x1c(r1) -/* 802834B0 80 7F 00 4C */ lwz r3, 0x4c(r31) -/* 802834B4 80 1F 00 50 */ lwz r0, 0x50(r31) -/* 802834B8 90 61 00 20 */ stw r3, 0x20(r1) -/* 802834BC 90 01 00 24 */ stw r0, 0x24(r1) -/* 802834C0 38 61 00 28 */ addi r3, r1, 0x28 -/* 802834C4 38 81 00 20 */ addi r4, r1, 0x20 -/* 802834C8 38 A1 00 18 */ addi r5, r1, 0x18 -/* 802834CC 38 C1 00 10 */ addi r6, r1, 0x10 -/* 802834D0 38 E1 00 08 */ addi r7, r1, 8 -/* 802834D4 48 00 03 85 */ bl func_80283858 -/* 802834D8 80 01 00 28 */ lwz r0, 0x28(r1) -/* 802834DC 90 1F 00 5C */ stw r0, 0x5c(r31) -/* 802834E0 80 01 00 2C */ lwz r0, 0x2c(r1) -/* 802834E4 90 1F 00 60 */ stw r0, 0x60(r31) -/* 802834E8 80 9F 00 5C */ lwz r4, 0x5c(r31) -/* 802834EC 80 1F 00 4C */ lwz r0, 0x4c(r31) -/* 802834F0 7C 04 00 40 */ cmplw r4, r0 -/* 802834F4 40 82 00 0C */ bne lbl_80283500 -/* 802834F8 C0 24 00 04 */ lfs f1, 4(r4) -/* 802834FC 48 00 00 60 */ b lbl_8028355C -lbl_80283500: -/* 80283500 80 1F 00 54 */ lwz r0, 0x54(r31) -/* 80283504 7C 04 00 40 */ cmplw r4, r0 -/* 80283508 40 82 00 24 */ bne lbl_8028352C -/* 8028350C 80 1F 00 60 */ lwz r0, 0x60(r31) -/* 80283510 54 03 10 3A */ slwi r3, r0, 2 -/* 80283514 80 1F 00 5C */ lwz r0, 0x5c(r31) -/* 80283518 7C 03 00 50 */ subf r0, r3, r0 -/* 8028351C 90 1F 00 5C */ stw r0, 0x5c(r31) -/* 80283520 80 7F 00 5C */ lwz r3, 0x5c(r31) -/* 80283524 C0 23 00 04 */ lfs f1, 4(r3) -/* 80283528 48 00 00 34 */ b lbl_8028355C -lbl_8028352C: -/* 8028352C 80 1F 00 48 */ lwz r0, 0x48(r31) -/* 80283530 54 00 10 3A */ slwi r0, r0, 2 -/* 80283534 7C 60 20 50 */ subf r3, r0, r4 -/* 80283538 C8 21 00 08 */ lfd f1, 8(r1) -/* 8028353C C0 43 00 00 */ lfs f2, 0(r3) -/* 80283540 C0 63 00 04 */ lfs f3, 4(r3) -/* 80283544 7C 63 02 14 */ add r3, r3, r0 -/* 80283548 C0 83 FF FC */ lfs f4, -4(r3) -/* 8028354C C0 A4 00 00 */ lfs f5, 0(r4) -/* 80283550 C0 C4 00 04 */ lfs f6, 4(r4) -/* 80283554 C0 E4 00 08 */ lfs f7, 8(r4) -/* 80283558 4B FF E1 B9 */ bl interpolateValue_hermite__Q27JStudio13functionvalueFddddddd -lbl_8028355C: -/* 8028355C 83 E1 00 3C */ lwz r31, 0x3c(r1) -/* 80283560 80 01 00 44 */ lwz r0, 0x44(r1) -/* 80283564 7C 08 03 A6 */ mtlr r0 -/* 80283568 38 21 00 40 */ addi r1, r1, 0x40 -/* 8028356C 4E 80 00 20 */ blr diff --git a/asm/JSystem/JStudio/JStudio/functionvalue/getValue__Q27JStudio29TFunctionValue_list_parameterFd.s b/asm/JSystem/JStudio/JStudio/functionvalue/getValue__Q27JStudio29TFunctionValue_list_parameterFd.s deleted file mode 100644 index b2fa75984c1..00000000000 --- a/asm/JSystem/JStudio/JStudio/functionvalue/getValue__Q27JStudio29TFunctionValue_list_parameterFd.s +++ /dev/null @@ -1,58 +0,0 @@ -lbl_80282F10: -/* 80282F10 94 21 FF D0 */ stwu r1, -0x30(r1) -/* 80282F14 7C 08 02 A6 */ mflr r0 -/* 80282F18 90 01 00 34 */ stw r0, 0x34(r1) -/* 80282F1C 93 E1 00 2C */ stw r31, 0x2c(r1) -/* 80282F20 7C 7F 1B 78 */ mr r31, r3 -/* 80282F24 D8 21 00 08 */ stfd f1, 8(r1) -/* 80282F28 80 A3 00 44 */ lwz r5, 0x44(r3) -/* 80282F2C 38 7F 00 08 */ addi r3, r31, 8 -/* 80282F30 C0 45 00 00 */ lfs f2, 0(r5) -/* 80282F34 80 9F 00 48 */ lwz r4, 0x48(r31) -/* 80282F38 38 04 FF FF */ addi r0, r4, -1 -/* 80282F3C 54 00 18 38 */ slwi r0, r0, 3 -/* 80282F40 7C 65 04 2E */ lfsx f3, r5, r0 -/* 80282F44 4B FF EA C5 */ bl range_getParameter__Q27JStudio29TFunctionValueAttribute_rangeCFddd -/* 80282F48 D8 21 00 08 */ stfd f1, 8(r1) -/* 80282F4C 80 1F 00 54 */ lwz r0, 0x54(r31) -/* 80282F50 90 01 00 10 */ stw r0, 0x10(r1) -/* 80282F54 80 1F 00 50 */ lwz r0, 0x50(r31) -/* 80282F58 90 01 00 14 */ stw r0, 0x14(r1) -/* 80282F5C 80 1F 00 4C */ lwz r0, 0x4c(r31) -/* 80282F60 90 01 00 18 */ stw r0, 0x18(r1) -/* 80282F64 38 61 00 1C */ addi r3, r1, 0x1c -/* 80282F68 38 81 00 18 */ addi r4, r1, 0x18 -/* 80282F6C 38 A1 00 14 */ addi r5, r1, 0x14 -/* 80282F70 38 C1 00 10 */ addi r6, r1, 0x10 -/* 80282F74 38 E1 00 08 */ addi r7, r1, 8 -/* 80282F78 48 00 06 65 */ bl func_802835DC -/* 80282F7C 80 01 00 1C */ lwz r0, 0x1c(r1) -/* 80282F80 90 1F 00 54 */ stw r0, 0x54(r31) -/* 80282F84 80 7F 00 54 */ lwz r3, 0x54(r31) -/* 80282F88 80 1F 00 4C */ lwz r0, 0x4c(r31) -/* 80282F8C 7C 03 00 40 */ cmplw r3, r0 -/* 80282F90 40 82 00 0C */ bne lbl_80282F9C -/* 80282F94 C0 23 00 04 */ lfs f1, 4(r3) -/* 80282F98 48 00 00 3C */ b lbl_80282FD4 -lbl_80282F9C: -/* 80282F9C 80 1F 00 50 */ lwz r0, 0x50(r31) -/* 80282FA0 7C 03 00 40 */ cmplw r3, r0 -/* 80282FA4 40 82 00 1C */ bne lbl_80282FC0 -/* 80282FA8 80 7F 00 54 */ lwz r3, 0x54(r31) -/* 80282FAC 38 03 FF F8 */ addi r0, r3, -8 -/* 80282FB0 90 1F 00 54 */ stw r0, 0x54(r31) -/* 80282FB4 80 7F 00 54 */ lwz r3, 0x54(r31) -/* 80282FB8 C0 23 00 04 */ lfs f1, 4(r3) -/* 80282FBC 48 00 00 18 */ b lbl_80282FD4 -lbl_80282FC0: -/* 80282FC0 7F E3 FB 78 */ mr r3, r31 -/* 80282FC4 C8 21 00 08 */ lfd f1, 8(r1) -/* 80282FC8 81 9F 00 58 */ lwz r12, 0x58(r31) -/* 80282FCC 7D 89 03 A6 */ mtctr r12 -/* 80282FD0 4E 80 04 21 */ bctrl -lbl_80282FD4: -/* 80282FD4 83 E1 00 2C */ lwz r31, 0x2c(r1) -/* 80282FD8 80 01 00 34 */ lwz r0, 0x34(r1) -/* 80282FDC 7C 08 03 A6 */ mtlr r0 -/* 80282FE0 38 21 00 30 */ addi r1, r1, 0x30 -/* 80282FE4 4E 80 00 20 */ blr diff --git a/include/JSystem/JGadget/vector.h b/include/JSystem/JGadget/vector.h index cd597a6a53b..41d1bdce8df 100644 --- a/include/JSystem/JGadget/vector.h +++ b/include/JSystem/JGadget/vector.h @@ -34,6 +34,16 @@ struct TVector { extend = vector::extend_default; } + inline u32 size() const { + if (pBegin_ == NULL) { + return 0; + } + + return ((int)pEnd_ - (int)pBegin_) / 4; + } + + void **const begin() const { return pBegin_; } + void **const end() const { return pEnd_; } void** begin() { return pBegin_; } void** end() { return pEnd_; } // void erase(void** arg1, void** arg2) {} @@ -57,9 +67,15 @@ struct TVector_pointer_void : TVector { template struct TVector_pointer : TVector_pointer_void { - // TVector_pointer(const TAllocator& allocator) : TVector_pointer_void(allocator) {} + TVector_pointer(const TAllocator& allocator) : TVector_pointer_void(allocator) {} ~TVector_pointer() {} + const T* begin() const { return (const T*)TVector_pointer_void::begin(); } + T* begin() { return (T*)TVector_pointer_void::begin(); } + + const T* end() const { return (const T*)TVector_pointer_void::end(); } + T* end() { return (T*)TVector_pointer_void::end(); } + void push_back(const T& ref) { static_cast(this)->push_back((const void*&)ref); } diff --git a/include/JSystem/JStudio/JStudio/functionvalue.h b/include/JSystem/JStudio/JStudio/functionvalue.h index 9450fa776de..9dd8d9abd01 100644 --- a/include/JSystem/JStudio/JStudio/functionvalue.h +++ b/include/JSystem/JStudio/JStudio/functionvalue.h @@ -5,8 +5,6 @@ #include "JSystem/JGadget/vector.h" #include "global.h" -extern u8 lit_652[]; - namespace JStudio { typedef f64 (*ExtrapolateParameter)(f64, f64); @@ -21,7 +19,7 @@ class TFunctionValueAttribute_interpolate; class TFunctionValue { public: enum TEProgress { PROG_INIT }; - enum TEAdjust { ADJ_INIT }; + enum TEAdjust { ADJ_INIT, ADJ_UNK1, ADJ_UNK2, ADJ_UNK3, ADJ_UNK4 }; enum TEOutside { OUT_INIT }; enum TEInterpolate {}; @@ -78,8 +76,8 @@ public: class TFunctionValueAttribute_refer : public JGadget::TVector_pointer { public: - // TFunctionValueAttribute_refer() : - // JGadget::TVector_pointer(JGadget::TAllocator()) {} + TFunctionValueAttribute_refer() : + JGadget::TVector_pointer(JGadget::TAllocator()) {} ~TFunctionValueAttribute_refer() {} /* 802816E8 */ void refer_initialize(); @@ -112,16 +110,20 @@ public: void range_setOutside_begin(TFunctionValue::TEOutside begin) { mBegin = begin; } void range_setOutside_end(TFunctionValue::TEOutside end) { mEnd = end; } f64 range_getParameter_outside(f64 arg1) const { - f64 temp = arg1 - fBegin_; - f64 result = temp; - if (temp < *(f64*)&lit_652) { - result = TFunctionValue::toFunction(mBegin)(temp, fDifference_); - } else if (temp >= fDifference_) { - result = TFunctionValue::toFunction(mEnd)(temp, fDifference_); + f64 result = arg1; + result -= fBegin_; + if (result < 0.0) { + result = TFunctionValue::toFunction(mBegin)(result, fDifference_); + } else if (result >= fDifference_) { + result = TFunctionValue::toFunction(mEnd)(result, fDifference_); } - return result + fBegin_; + result += fBegin_; + return result; } f64 range_getParameter_progress(f64 arg1) const { return _20 + _28 * (arg1 - _20); } + f64 range_getBegin() const { return fBegin_;} + f64 range_getEnd() const { return fEnd_;} + f64 range_getDifference() const { return fDifference_; } private: /* 0x00 */ f64 fBegin_; @@ -176,6 +178,8 @@ public: TData(f32 data) : f32data(data) {} inline void operator=(const TData& rhs) { f32data = rhs.f32data; } + u32 get_unsignedInteger() const { return u32data; } + f64 get_value() const { return f32data; } union { const void* rawData; @@ -196,17 +200,17 @@ public: /* 80281DE0 */ virtual void initialize(); /* 80281E24 */ virtual void prepare(); /* 80281E28 */ virtual f64 getValue(f64); - /* 80281E5C */ void composite_raw(TVector_pointer const&, TData const&, f64); - /* 80281EC8 */ void composite_index(TVector_pointer const&, TData const&, f64); - /* 8028202C */ void composite_parameter(TVector_pointer const&, TData const&, - f64); - /* 80282094 */ void composite_add(TVector_pointer const&, - TData const&, f64); - /* 80282118 */ void composite_subtract(TVector_pointer const&, TData const&, + /* 80281E5C */ static f64 composite_raw(TVector_pointer const&, TData const&, f64); + /* 80281EC8 */ static f64 composite_index(TVector_pointer const&, TData const&, f64); + /* 8028202C */ static f64 composite_parameter(TVector_pointer const&, + TData const&, f64); + /* 80282094 */ static f64 composite_add(TVector_pointer const&, + TData const&, f64); + /* 80282118 */ static f64 composite_subtract(TVector_pointer const&, TData const&, f64); - /* 80282200 */ void composite_multiply(TVector_pointer const&, TData const&, + /* 80282200 */ static f64 composite_multiply(TVector_pointer const&, TData const&, f64); - /* 80282284 */ void composite_divide(TVector_pointer const&, TData const&, + /* 80282284 */ static f64 composite_divide(TVector_pointer const&, TData const&, f64); void data_set(CompositeFunc fn, const TData& dat) { @@ -239,6 +243,8 @@ public: _50 = a2; } + f64 data_getDifference() const { return _50 - _48; } + private: /* 0x48 */ f64 _48; /* 0x50 */ f64 _50; @@ -267,7 +273,7 @@ public: void data_set(const f32* pf, u32 u) { ASSERT((pf != NULL) || (u == 0)); _44 = pf; - _48 = u; + uData_ = u; } void data_setInterval(f64 f) { @@ -290,9 +296,9 @@ public: private: /* 0x44 */ const f32* _44; - /* 0x48 */ u32 _48; + /* 0x48 */ u32 uData_; /* 0x50 */ f64 _50; - /* 0x58 */ update_INTERPOLATE _58; + /* 0x58 */ update_INTERPOLATE pfnUpdate_; }; class TFunctionValue_list_parameter : TFunctionValue, @@ -304,6 +310,11 @@ public: TIterator_data_(const TIterator_data_& other) : value_(other.value_) {} void operator=(const TIterator_data_& rhs) { value_ = rhs.value_; } + TIterator_data_& operator--() { + value_ -= 2; + return *this; + } + friend bool operator==(const TIterator_data_& lhs, const TIterator_data_& rhs) { return lhs.value_ == rhs.value_; } const f32* get() const { return value_; } void set(const f32* value) { value_ = value; } @@ -331,13 +342,18 @@ public: /* 80283060 */ static f64 update_INTERPOLATE_BSPLINE_dataMore3_(JStudio::TFunctionValue_list_parameter const&, f64); + f64 data_getValue_back() { + return pfData_[(uData_ - 1) * 2]; + } + f64 data_getValue_front() { return pfData_[0]; } + private: - /* 0x44 */ const f32* _44; - /* 0x48 */ u32 _48; + /* 0x44 */ const f32* pfData_; + /* 0x48 */ u32 uData_; /* 0x4c */ TIterator_data_ dat1; /* 0x50 */ TIterator_data_ dat2; /* 0x54 */ TIterator_data_ dat3; - /* 0x58 */ update_INTERPOLATE _58; + /* 0x58 */ update_INTERPOLATE pfnUpdate_; }; class TFunctionValue_hermite : TFunctionValue, TFunctionValueAttribute_range { @@ -347,19 +363,19 @@ public: value_ = value; size_ = rParent.data_getSize(); } - TIterator_data_(const TIterator_data_& other) { - value_ = other.value_; - size_ = other.size_; - } + + const f32* get() { return value_; } void set(const f32* value, u32 size) { value_ = value; size_ = size; } + + friend bool operator==(const TIterator_data_& lhs, const TIterator_data_& rhs) { return lhs.value_ == rhs.value_; } - void operator=(const TIterator_data_& rhs) { - value_ = rhs.value_; - size_ = rhs.size_; + TIterator_data_& operator--() { + value_ -= size_; + return *this; } /* 0x00 */ const f32* value_; @@ -377,6 +393,10 @@ public: /* 8028344C */ virtual f64 getValue(f64); u32 data_getSize() const { return uSize_; } + f64 data_getValue_back() { + return pf_[(u_ - 1) * uSize_]; + } + f64 data_getValue_front() { return pf_[0]; } private: /* 0x40 */ const f32* pf_; diff --git a/libs/JSystem/JStudio/JStudio/functionvalue.cpp b/libs/JSystem/JStudio/JStudio/functionvalue.cpp index f0767af6836..45c2d77f664 100644 --- a/libs/JSystem/JStudio/JStudio/functionvalue.cpp +++ b/libs/JSystem/JStudio/JStudio/functionvalue.cpp @@ -5,10 +5,13 @@ #include "JSystem/JStudio/JStudio/functionvalue.h" #include "JSystem/JUtility/JUTException.h" +#include "JSystem/JUtility/JUTAssert.h" +#include "JSystem/JGadget/linklist.h" #include "math.h" #include "stdlib.h" #include "dol2asm.h" #include "global.h" +#include "iterator.h" // // Types: @@ -16,8 +19,8 @@ namespace JGadget { -template -void findUpperBound_binary_current(/* ... */); +template +Iterator findUpperBound_binary_current(Iterator, Iterator, Iterator, const B1&); }; // namespace JGadget namespace std { @@ -40,14 +43,14 @@ void func_80283E24(void* _this, JStudio::TFunctionValue_list_parameter::TIterato }; // namespace std namespace JGadget { -/* 80283858 */ void func_80283858(void* _this, JStudio::TFunctionValue_hermite::TIterator_data_, - JStudio::TFunctionValue_hermite::TIterator_data_, - JStudio::TFunctionValue_hermite::TIterator_data_, f64 const&); -/* 802835DC */ void func_802835DC(void* _this, - JStudio::TFunctionValue_list_parameter::TIterator_data_, - JStudio::TFunctionValue_list_parameter::TIterator_data_, - JStudio::TFunctionValue_list_parameter::TIterator_data_, - f64 const&); +/* 80283858 */ JStudio::TFunctionValue_hermite::TIterator_data_ +func_80283858(JStudio::TFunctionValue_hermite::TIterator_data_, + JStudio::TFunctionValue_hermite::TIterator_data_, + JStudio::TFunctionValue_hermite::TIterator_data_, f64 const&); +/* 802835DC */ JStudio::TFunctionValue_list_parameter::TIterator_data_ +func_802835DC(JStudio::TFunctionValue_list_parameter::TIterator_data_, + JStudio::TFunctionValue_list_parameter::TIterator_data_, + JStudio::TFunctionValue_list_parameter::TIterator_data_, f64 const&); /* 80283634 */ void func_80283634(void* _this, JStudio::TFunctionValue_list_parameter::TIterator_data_, JStudio::TFunctionValue_list_parameter::TIterator_data_, @@ -140,16 +143,18 @@ extern "C" void getValue__Q27JStudio22TFunctionValue_hermiteFd(); extern "C" void extrapolateParameter_raw__Q27JStudio13functionvalueFdd(); extern "C" void extrapolateParameter_repeat__Q27JStudio13functionvalueFdd(); extern "C" void extrapolateParameter_clamp__Q27JStudio13functionvalueFdd(); -extern "C" void func_802835DC(void* _this, JStudio::TFunctionValue_list_parameter::TIterator_data_, - JStudio::TFunctionValue_list_parameter::TIterator_data_, - JStudio::TFunctionValue_list_parameter::TIterator_data_, f64 const&); +extern "C" JStudio::TFunctionValue_list_parameter::TIterator_data_ +func_802835DC(JStudio::TFunctionValue_list_parameter::TIterator_data_, + JStudio::TFunctionValue_list_parameter::TIterator_data_, + JStudio::TFunctionValue_list_parameter::TIterator_data_, f64 const&); extern "C" void func_80283634(void* _this, JStudio::TFunctionValue_list_parameter::TIterator_data_, JStudio::TFunctionValue_list_parameter::TIterator_data_, JStudio::TFunctionValue_list_parameter::TIterator_data_, f64 const&, std::less); -extern "C" void func_80283858(void* _this, JStudio::TFunctionValue_hermite::TIterator_data_, - JStudio::TFunctionValue_hermite::TIterator_data_, - JStudio::TFunctionValue_hermite::TIterator_data_, f64 const&); +extern "C" JStudio::TFunctionValue_hermite::TIterator_data_ +func_80283858(JStudio::TFunctionValue_hermite::TIterator_data_, + JStudio::TFunctionValue_hermite::TIterator_data_, + JStudio::TFunctionValue_hermite::TIterator_data_, f64 const&); extern "C" void func_802838C8(void* _this, JStudio::TFunctionValue_hermite::TIterator_data_, JStudio::TFunctionValue_hermite::TIterator_data_, JStudio::TFunctionValue_hermite::TIterator_data_, f64 const&, @@ -315,9 +320,18 @@ namespace JStudio { namespace functionvalue { f64 extrapolateParameter_raw(f64, f64); -f64 extrapolateParameter_repeat(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 { @@ -357,22 +371,27 @@ void TFunctionValueAttribute_refer::refer_initialize() { namespace functionvalue { -#ifdef NONMATCHING // impossible regalloc +/* 80281710-80281774 27C050 0064+00 4/4 0/0 0/0 .text + * interpolateValue_hermite__Q27JStudio13functionvalueFddddddd */ +// Matches with literals +#ifdef NONMATCHING f64 interpolateValue_hermite(f64 c0, f64 c1, f64 x, f64 c2, f64 x2, f64 c3, f64 x3) { f64 a; - f64 d; - f64 c; f64 b; + f64 c; + f64 d; a = c0 - c1; b = a * (1.0 / (x2 - c1)); // (a - b) * 1.0 / (c - d) c = b - 1.0; // 1.0 d = (3.0 + -2.0 * b) * (b * b); // 3.0 - 2.0 * b - return (a * b * c * x3) + ((1.0 - d) * x + (d * c3)) + (a * (c * c) * c2); + f64 cab = (c * a * b); + f64 coeffx3 = cab * x3; + f64 cca = (c * c * a); + f64 coeffc2 = cca * c2; + return ((1.0 - d) * x + (d * c3)) + coeffc2 + coeffx3; } #else -/* 80281710-80281774 27C050 0064+00 4/4 0/0 0/0 .text - * interpolateValue_hermite__Q27JStudio13functionvalueFddddddd */ #pragma push #pragma optimization_level 0 #pragma optimizewithasm off @@ -384,22 +403,29 @@ asm f64 interpolateValue_hermite(f64 param_0, f64 param_1, f64 param_2, f64 para #pragma pop #endif -#ifdef NONMATCHING // really minor regalloc +/* 80281774-802817D8 27C0B4 0064+00 1/1 0/0 0/0 .text + * interpolateValue_BSpline_uniform__Q27JStudio13functionvalueFddddd */ +// really minor regalloc. +#ifdef NONMATCHING f64 interpolateValue_BSpline_uniform(f64 f1, f64 f2, f64 f3, f64 f4, f64 f5) { // pow3(1.0 - f1) f64 f6 = (1.0 - f1); f64 temp = f6; - temp *= f6 * f6; + temp = (f6 * f6) * temp; f64 f0 = f1 * f1; f64 f8 = f0 * f1; - return ((lit_799 * f8 - f0) + lit_801) * f3 + (temp * f2 + f8 * f5) * 0.5 + - f4 * (0.5 + lit_799 * ((f1 + f0) - f8)); + f64 temp2 = (0.5 + (1.0 / 6.0) * ((f1 + f0) - f8)); + f64 temp3 = temp2 * f4; + + f64 temp4 = (((1.0 / 6.0) * f8 - f0) + (2.0 / 3.0)); + f64 temp5 = temp4 * f3; + + return temp5 + (temp * f2 + f8 * f5) * 0.5 + + temp3; } #else -/* 80281774-802817D8 27C0B4 0064+00 1/1 0/0 0/0 .text - * interpolateValue_BSpline_uniform__Q27JStudio13functionvalueFddddd */ #pragma push #pragma optimization_level 0 #pragma optimizewithasm off @@ -431,12 +457,22 @@ inline f64 interpolateValue_linear_1(f64 a1, f64 a2, f64 a3, f64 a4) { } inline f64 interpolateValue_plateau(f64 a1, f64 a2, f64 a3, f64 a4, f64 a5) { - return interpolateValue_hermite(a1, a2, a3, DOUBLE_LABEL(/* 0.0 */ lit_652), a4, a5, - DOUBLE_LABEL(/* 0.0 */ lit_652)); + return interpolateValue_hermite(a1, a2, a3, 0.0, a4, a5, 0.0); } /* 802818B8-80281918 27C1F8 0060+00 1/0 0/0 0/0 .text * extrapolateParameter_turn__Q27JStudio13functionvalueFdd */ +// Matches with literals +#ifdef NONMATCHING +f64 extrapolateParameter_turn(f64 param_0, f64 param_1) { + f64 dVar2 = 2.0 * param_1; + f64 dVar1 = i_extrapolateParameter_repeat(param_0, dVar2); + if (dVar1 >= param_1) { + dVar1 = dVar2 - dVar1; + } + return dVar1; +} +#else #pragma push #pragma optimization_level 0 #pragma optimizewithasm off @@ -445,6 +481,7 @@ asm f64 extrapolateParameter_turn(f64 param_0, f64 param_1) { #include "asm/JSystem/JStudio/JStudio/functionvalue/extrapolateParameter_turn__Q27JStudio13functionvalueFdd.s" } #pragma pop +#endif } // namespace functionvalue @@ -496,6 +533,9 @@ void TFunctionValueAttribute_range::range_set(f64 begin, f64 end) { ASSERT(fDifference_ >= TValue(0)); } +// /* 80281A08-80281D18 27C348 0310+00 2/2 0/0 0/0 .text +// * range_getParameter__Q27JStudio29TFunctionValueAttribute_rangeCFddd */ +// Matches with literals #ifdef NONMATCHING f64 TFunctionValueAttribute_range::range_getParameter(f64 arg1, f64 arg2, f64 arg3) const { f64 progress = range_getParameter_progress(arg1); @@ -527,8 +567,6 @@ f64 TFunctionValueAttribute_range::range_getParameter(f64 arg1, f64 arg2, f64 ar return result; } #else -// /* 80281A08-80281D18 27C348 0310+00 2/2 0/0 0/0 .text -// * range_getParameter__Q27JStudio29TFunctionValueAttribute_rangeCFddd */ #pragma push #pragma optimization_level 0 #pragma optimizewithasm off @@ -547,6 +585,11 @@ TFunctionValueAttribute_range::TFunctionValueAttribute_range() /* 80281D5C-80281DB8 27C69C 005C+00 0/0 1/1 0/0 .text __ct__Q27JStudio24TFunctionValue_compositeFv */ +// TVector_pointer ctor issue +#ifdef NONMATCHING +TFunctionValue_composite::TFunctionValue_composite() : pfn_(NULL), data((void*)NULL) { +} +#else #pragma push #pragma optimization_level 0 #pragma optimizewithasm off @@ -555,6 +598,7 @@ asm TFunctionValue_composite::TFunctionValue_composite() { #include "asm/JSystem/JStudio/JStudio/functionvalue/__ct__Q27JStudio24TFunctionValue_compositeFv.s" } #pragma pop +#endif u32 TFunctionValue_composite::getType() const { return 1; @@ -585,96 +629,225 @@ f64 TFunctionValue_composite::getValue(f64 arg1) { /* 80281E5C-80281EC8 27C79C 006C+00 0/0 1/0 0/0 .text * composite_raw__Q27JStudio24TFunctionValue_compositeFRCQ27JGadget44TVector_pointerRCQ37JStudio24TFunctionValue_composite5TDatad */ +// Matches with literals +#ifdef NONMATCHING +f64 TFunctionValue_composite::composite_raw(TVector_pointer const& param_1, + TData const& param_2, f64 param_3) { + u32 index = param_2.get_unsignedInteger(); + u32 size = param_1.size(); + if (index >= size) { + return 0.0; + } + TFunctionValue** local_18 = (TFunctionValue**)param_1.begin(); + std::advance_pointer(local_18, index); + TFunctionValue* piVar4 = *local_18; + return piVar4->getValue(param_3); +} +#else #pragma push #pragma optimization_level 0 #pragma optimizewithasm off -asm void TFunctionValue_composite::composite_raw(TVector_pointer const& param_0, +asm f64 TFunctionValue_composite::composite_raw(TVector_pointer const& param_0, TData const& param_1, f64 param_2) { nofralloc #include "asm/JSystem/JStudio/JStudio/functionvalue/func_80281E5C.s" } #pragma pop +#endif /* 80281EC8-8028202C 27C808 0164+00 0/0 1/0 0/0 .text * composite_index__Q27JStudio24TFunctionValue_compositeFRCQ27JGadget44TVector_pointerRCQ37JStudio24TFunctionValue_composite5TDatad */ +// Matches with literals +#ifdef NONMATCHING +f64 TFunctionValue_composite::composite_index(TVector_pointer const& param_1, + TData const& param_2, f64 param_3) { + s32 size = param_1.size(); + if (size <= 1) { + return 0.0; + } + TFunctionValue** local_148 = (TFunctionValue**)param_1.begin(); + TFunctionValue* pFront = *local_148; + JUT_ASSERT(599, pFront!=0); + f64 dVar4 = pFront->getValue(param_3); + s32 index = floor(dVar4); + u32 uVar2 = param_2.get_unsignedInteger(); + switch (uVar2) { + case 0: + case 3: + default: + if (index < 0) { + index = 0; + } else if (index >= size - 1) { + index = size - 2; + } + break; + case 1: + div_t dt = div(index, size - 1); + index = dt.rem; + if (index < 0) { + index = size + index; + index--; + } + break; + case 2: + if (size - 1 == 1) { + index = 0; + } else { + u32 uVar3 = (u32)(size - 2) * 2; + div_t dt2 = div(index, uVar3); + index = dt2.rem; + if (index < 0) { + index += uVar3; + } + if (index >= size - 1) { + index = uVar3 - index; + } + } + break; + } + + std::advance_pointer(local_148, index + 1); + pFront = *local_148; + return pFront->getValue(param_3); +} +#else #pragma push #pragma optimization_level 0 #pragma optimizewithasm off -asm void TFunctionValue_composite::composite_index(TVector_pointer const& param_0, +asm f64 TFunctionValue_composite::composite_index(TVector_pointer const& param_0, TData const& param_1, f64 param_2) { nofralloc #include "asm/JSystem/JStudio/JStudio/functionvalue/func_80281EC8.s" } #pragma pop +#endif + +// TODO: remove when TContainerEnumerator_const is generic enough +template +struct TContainerEnumerator_const_TVector : public JGadget::TEnumerator { + inline TContainerEnumerator_const_TVector(JGadget::TVector_pointer const& param_1) + : JGadget::TEnumerator(param_1.begin(), param_1.end()) {} +}; /* 8028202C-80282094 27C96C 0068+00 0/0 1/0 0/0 .text * composite_parameter__Q27JStudio24TFunctionValue_compositeFRCQ27JGadget44TVector_pointerRCQ37JStudio24TFunctionValue_composite5TDatad */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void -TFunctionValue_composite::composite_parameter(TVector_pointer const& param_0, - TData const& param_1, f64 param_2) { - nofralloc -#include "asm/JSystem/JStudio/JStudio/functionvalue/func_8028202C.s" +f64 +TFunctionValue_composite::composite_parameter(TVector_pointer const& param_1, + TData const& param_2, f64 param_3) { + f64 dVar4 = param_3 - param_2.get_value(); + TContainerEnumerator_const_TVector aTStack_18(param_1); + while (aTStack_18) { + TFunctionValue* const* ppiVar3 = *aTStack_18; + TFunctionValue* piVar3 = *ppiVar3; + dVar4 = piVar3->getValue(dVar4); + } + return dVar4; } -#pragma pop /* 80282094-80282118 27C9D4 0084+00 0/0 1/0 0/0 .text * composite_add__Q27JStudio24TFunctionValue_compositeFRCQ27JGadget44TVector_pointerRCQ37JStudio24TFunctionValue_composite5TDatad */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void TFunctionValue_composite::composite_add(TVector_pointer const& param_0, - TData const& param_1, f64 param_2) { - nofralloc -#include "asm/JSystem/JStudio/JStudio/functionvalue/func_80282094.s" +f64 TFunctionValue_composite::composite_add(TVector_pointer const& param_1, + TData const& param_2, f64 param_3) { + f64 dVar4 = param_2.get_value(); + TContainerEnumerator_const_TVector aTStack_18(param_1); + while (aTStack_18) { + TFunctionValue* const* ppiVar3 = *aTStack_18; + TFunctionValue* piVar3 = *ppiVar3; + dVar4 += piVar3->getValue(param_3); + } + return dVar4; } -#pragma pop /* 80282118-80282200 27CA58 00E8+00 0/0 1/0 0/0 .text * composite_subtract__Q27JStudio24TFunctionValue_compositeFRCQ27JGadget44TVector_pointerRCQ37JStudio24TFunctionValue_composite5TDatad */ +// Matches with literals +#ifdef NONMATCHING +f64 TFunctionValue_composite::composite_subtract(TVector_pointer const& param_1, + TData const& param_2, f64 param_3) { + u32 size = param_1.size(); + if (size == 0) { + return 0.0; + } + TContainerEnumerator_const_TVector aTStack_18(param_1); + TFunctionValue* const* local_148 = *aTStack_18; + TFunctionValue* pFront = *local_148; + JUT_ASSERT(688, pFront!=0); + f64 dVar4 = pFront->getValue(param_3); + while (aTStack_18) { + TFunctionValue* const* ppiVar3 = *aTStack_18; + TFunctionValue* piVar3 = *ppiVar3; + dVar4 -= piVar3->getValue(param_3); + } + dVar4 -= param_2.f32data; + return dVar4; +} +#else #pragma push #pragma optimization_level 0 #pragma optimizewithasm off -asm void +asm f64 TFunctionValue_composite::composite_subtract(TVector_pointer const& param_0, TData const& param_1, f64 param_2) { nofralloc #include "asm/JSystem/JStudio/JStudio/functionvalue/func_80282118.s" } #pragma pop +#endif /* 80282200-80282284 27CB40 0084+00 0/0 1/0 0/0 .text * composite_multiply__Q27JStudio24TFunctionValue_compositeFRCQ27JGadget44TVector_pointerRCQ37JStudio24TFunctionValue_composite5TDatad */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void -TFunctionValue_composite::composite_multiply(TVector_pointer const& param_0, - TData const& param_1, f64 param_2) { - nofralloc -#include "asm/JSystem/JStudio/JStudio/functionvalue/func_80282200.s" +f64 TFunctionValue_composite::composite_multiply(TVector_pointer const& param_1, + TData const& param_2, f64 param_3) { + f64 dVar4 = param_2.get_value(); + TContainerEnumerator_const_TVector aTStack_18(param_1); + while (aTStack_18) { + TFunctionValue* const* ppiVar3 = *aTStack_18; + TFunctionValue* piVar3 = *ppiVar3; + dVar4 *= piVar3->getValue(param_3); + } + return dVar4; } -#pragma pop /* 80282284-8028236C 27CBC4 00E8+00 0/0 1/0 0/0 .text * composite_divide__Q27JStudio24TFunctionValue_compositeFRCQ27JGadget44TVector_pointerRCQ37JStudio24TFunctionValue_composite5TDatad */ +// Matches with literals +#ifdef NONMATCHING +f64 TFunctionValue_composite::composite_divide(TVector_pointer const& param_1, + TData const& param_2, f64 param_3) { + u32 size = param_1.size(); + if (size == 0) { + return 0.0; + } + TContainerEnumerator_const_TVector aTStack_18(param_1); + TFunctionValue* const* local_148 = *aTStack_18; + TFunctionValue* pFront = *local_148; + JUT_ASSERT(724, pFront!=0); + f64 dVar4 = pFront->getValue(param_3); + while (aTStack_18) { + TFunctionValue* const* ppiVar3 = *aTStack_18; + TFunctionValue* piVar3 = *ppiVar3; + dVar4 /= piVar3->getValue(param_3); + } + dVar4 /= param_2.f32data; + return dVar4; +} +#else #pragma push #pragma optimization_level 0 #pragma optimizewithasm off -asm void TFunctionValue_composite::composite_divide(TVector_pointer const& param_0, +asm f64 TFunctionValue_composite::composite_divide(TVector_pointer const& param_0, TData const& param_1, f64 param_2) { nofralloc #include "asm/JSystem/JStudio/JStudio/functionvalue/func_80282284.s" } #pragma pop +#endif TFunctionValue_constant::TFunctionValue_constant() : fValue_(NAN) {} @@ -723,6 +896,47 @@ void TFunctionValue_transition::prepare() { /* 802824F4-802826BC 27CE34 01C8+00 1/0 0/0 0/0 .text * getValue__Q27JStudio25TFunctionValue_transitionFd */ +// regalloc. Maybe return value related. +#ifdef NONMATCHING +f64 TFunctionValue_transition::getValue(f64 param_1) { + f64 progress = range_getParameter_progress(param_1); + f64 dVar3 = range_getParameter_outside(progress); + switch (range_getAdjust()) { + default: + if (dVar3 < range_getBegin()) { + return _48; + } + return _50; + case TFunctionValue::ADJ_UNK2: + if (dVar3 < range_getEnd()) { + return _48; + } + return _50; + case TFunctionValue::ADJ_UNK3: + ADJ_UNK3_label: + if (dVar3 < 0.5 * (range_getBegin() + range_getEnd())) { + return _48; + } + return _50; + case TFunctionValue::ADJ_UNK4: + if (dVar3 < range_getBegin()) { + return _48; + } + if (dVar3 >= range_getEnd()) { + return _50; + } + switch (interpolate_get()) { + case 0: + goto ADJ_UNK3_label; + case 1: + case 3: + return _48 + ((dVar3 - range_getBegin()) * data_getDifference()) / range_getDifference(); + case 2: + return functionvalue::interpolateValue_plateau(dVar3, range_getBegin(), _48, range_getEnd(), _50); + } + } +} +#else #pragma push #pragma optimization_level 0 #pragma optimizewithasm off @@ -731,8 +945,9 @@ asm f64 TFunctionValue_transition::getValue(f64 param_0) { #include "asm/JSystem/JStudio/JStudio/functionvalue/getValue__Q27JStudio25TFunctionValue_transitionFd.s" } #pragma pop +#endif -TFunctionValue_list::TFunctionValue_list() : _44(NULL), _48(0), _50(NAN), _58(NULL) {} +TFunctionValue_list::TFunctionValue_list() : _44(NULL), uData_(0), _50(NAN), pfnUpdate_(NULL) {} u32 TFunctionValue_list::getType() const { return 4; @@ -747,9 +962,9 @@ void TFunctionValue_list::initialize() { interpolate_initialize(); _44 = NULL; - _48 = 0; + uData_ = 0; _50 = NAN; - _58 = NULL; + pfnUpdate_ = NULL; } void TFunctionValue_list::prepare() { @@ -763,24 +978,69 @@ void TFunctionValue_list::prepare() { JUTWarn w; w << "unknown interpolation : " << interp; case 0: - _58 = update_INTERPOLATE_NONE_; + pfnUpdate_ = update_INTERPOLATE_NONE_; break; case 1: - _58 = update_INTERPOLATE_LINEAR_; + pfnUpdate_ = update_INTERPOLATE_LINEAR_; break; case 2: - _58 = update_INTERPOLATE_PLATEAU_; + pfnUpdate_ = update_INTERPOLATE_PLATEAU_; break; case 3: - _58 = update_INTERPOLATE_BSPLINE_dataMore3_; - if (_48 == 2) - _58 = update_INTERPOLATE_LINEAR_; + pfnUpdate_ = update_INTERPOLATE_BSPLINE_dataMore3_; + if (uData_ == 2) + pfnUpdate_ = update_INTERPOLATE_LINEAR_; break; } } /* 80282858-80282C10 27D198 03B8+00 1/0 0/0 0/0 .text getValue__Q27JStudio19TFunctionValue_listFd */ +// Matches with literals +#ifdef NONMATCHING +f64 TFunctionValue_list::getValue(f64 param_1) { + f64 dVar9 = range_getParameter_progress(param_1); + u32 iVar7 = uData_ - 1; + TFunctionValue::TEAdjust iVar5 = range_getAdjust(); + f64 dVar12 = iVar7; + TIndexData_ local_178; + f64 parOutside; + switch (iVar5) { + case 0: + default: + parOutside = range_getParameter_outside(dVar9); + local_178._0 = parOutside / _50; + break; + case 1: + parOutside = range_getParameter_outside(dVar9 + range_getBegin()); + local_178._0 = parOutside / _50; + break; + case 2: + parOutside = range_getParameter_outside(dVar9 + range_getEnd()); + local_178._0 = parOutside / _50; + break; + case 3: + parOutside = range_getParameter_outside(dVar9 + 0.5 * (range_getBegin() + range_getEnd())); + local_178._0 = parOutside / _50; + break; + case 4: + parOutside = range_getParameter_outside(dVar9); + local_178._0 = (dVar12 * (parOutside - range_getBegin())) / range_getDifference(); + break; + } + + if (local_178._0 < 0.0) { + return _44[0]; + } + if (local_178._0 >= dVar12) { + return _44[iVar7]; + } + local_178._8 = floor(local_178._0); + local_178._10 = local_178._8; + JUT_ASSERT(1063, pfnUpdate_!=0); + return pfnUpdate_(*this, local_178); +} +#else #pragma push #pragma optimization_level 0 #pragma optimizewithasm off @@ -789,6 +1049,7 @@ asm f64 TFunctionValue_list::getValue(f64 param_0) { #include "asm/JSystem/JStudio/JStudio/functionvalue/getValue__Q27JStudio19TFunctionValue_listFd.s" } #pragma pop +#endif f64 TFunctionValue_list::update_INTERPOLATE_NONE_(const TFunctionValue_list& rThis, const TIndexData_& data) { @@ -801,18 +1062,19 @@ f64 TFunctionValue_list::update_INTERPOLATE_LINEAR_(const TFunctionValue_list& r rThis._44[data._10 + 1]); } -#ifdef NONMATCHING // float load +/* 80282C58-80282CA8 27D598 0050+00 1/1 0/0 0/0 .text + * update_INTERPOLATE_PLATEAU___Q27JStudio19TFunctionValue_listFRCQ27JStudio19TFunctionValue_listRCQ37JStudio19TFunctionValue_list11TIndexData_ + */ +// Matches with literals +#ifdef NONMATCHING f64 TFunctionValue_list::update_INTERPOLATE_PLATEAU_(const TFunctionValue_list& rThis, const TIndexData_& data) { const f32* arr = rThis._44; return functionvalue::interpolateValue_plateau(data._0, data._8, arr[data._10], - lit_792 + data._8, arr[data._10 + 1]); + 1.0 + data._8, arr[data._10 + 1]); } #else -/* 80282C58-80282CA8 27D598 0050+00 1/1 0/0 0/0 .text - * update_INTERPOLATE_PLATEAU___Q27JStudio19TFunctionValue_listFRCQ27JStudio19TFunctionValue_listRCQ37JStudio19TFunctionValue_list11TIndexData_ - */ #pragma push #pragma optimization_level 0 #pragma optimizewithasm off @@ -828,6 +1090,32 @@ asm f64 JStudio::TFunctionValue_list::update_INTERPOLATE_PLATEAU_( /* 80282CA8-80282D34 27D5E8 008C+00 1/1 0/0 0/0 .text * update_INTERPOLATE_BSPLINE_dataMore3___Q27JStudio19TFunctionValue_listFRCQ27JStudio19TFunctionValue_listRCQ37JStudio19TFunctionValue_list11TIndexData_ */ +// Matches with literals +#ifdef NONMATCHING +f64 TFunctionValue_list::update_INTERPOLATE_BSPLINE_dataMore3_( + TFunctionValue_list const& rThis, TFunctionValue_list::TIndexData_ const& param_2) { + f64 dVar11 = rThis._44[param_2._10]; + f64 dVar10 = rThis._44[param_2._10 + 1]; + f64 dVar9; + f64 dVar8; + if (param_2._10 == 0) { + JUT_ASSERT(1119, rThis.uData_>=3); + dVar9 = 2.0 * dVar11 - dVar10; + dVar8 = rThis._44[param_2._10 + 2]; + } else { + if (param_2._10 == rThis.uData_ - 2) { + JUT_ASSERT(1125, rThis.uData_>=3); + dVar9 = rThis._44[param_2._10 - 1]; + dVar8 = 2.0 * dVar10 - dVar11; + } else { + JUT_ASSERT(1131, rThis.uData_>=3); + dVar9 = rThis._44[param_2._10 - 1]; + dVar8 = rThis._44[param_2._10 + 2]; + } + } + functionvalue::interpolateValue_BSpline_uniform(param_2._0 - param_2._8, dVar9, dVar11, dVar10, dVar8); +} +#else #pragma push #pragma optimization_level 0 #pragma optimizewithasm off @@ -837,9 +1125,10 @@ asm f64 TFunctionValue_list::update_INTERPOLATE_BSPLINE_dataMore3_( #include "asm/JSystem/JStudio/JStudio/functionvalue/func_80282CA8.s" } #pragma pop +#endif TFunctionValue_list_parameter::TFunctionValue_list_parameter() - : _44(NULL), _48(0), dat1(NULL), dat2(dat1), dat3(dat1), _58(NULL) {} + : pfData_(NULL), uData_(0), dat1(NULL), dat2(dat1), dat3(dat1), pfnUpdate_(NULL) {} u32 TFunctionValue_list_parameter::getType() const { return 5; @@ -852,11 +1141,11 @@ TFunctionValueAttributeSet TFunctionValue_list_parameter::getAttributeSet() { void TFunctionValue_list_parameter::data_set(const f32* pf, u32 u) { ASSERT((pf != NULL) || (u == 0)); - _44 = pf; - _48 = u; + pfData_ = pf; + uData_ = u; - dat1.set(_44); - dat2.set(&_44[_48 * 2]); + dat1.set(pfData_); + dat2.set(&pfData_[uData_ * 2]); dat3 = dat1; } @@ -864,15 +1153,15 @@ void TFunctionValue_list_parameter::initialize() { range_initialize(); interpolate_initialize(); - _44 = NULL; - _48 = 0; + pfData_ = NULL; + uData_ = 0; TIterator_data_ iter(NULL); dat1 = iter; dat2 = dat1; dat3 = dat1; - _58 = NULL; + pfnUpdate_ = NULL; } void TFunctionValue_list_parameter::prepare() { @@ -885,33 +1174,46 @@ void TFunctionValue_list_parameter::prepare() { JUTWarn w; w << "unknown interpolation : " << interp; case 0: - _58 = update_INTERPOLATE_NONE_; + pfnUpdate_ = update_INTERPOLATE_NONE_; break; case 1: - _58 = update_INTERPOLATE_LINEAR_; + pfnUpdate_ = update_INTERPOLATE_LINEAR_; break; case 2: - _58 = update_INTERPOLATE_PLATEAU_; + pfnUpdate_ = update_INTERPOLATE_PLATEAU_; break; case 3: - _58 = update_INTERPOLATE_BSPLINE_dataMore3_; - if (_48 != 2) + pfnUpdate_ = update_INTERPOLATE_BSPLINE_dataMore3_; + if (uData_ != 2) return; - _58 = update_INTERPOLATE_LINEAR_; + pfnUpdate_ = update_INTERPOLATE_LINEAR_; break; } } /* 80282F10-80282FE8 27D850 00D8+00 1/0 0/0 0/0 .text * getValue__Q27JStudio29TFunctionValue_list_parameterFd */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm f64 TFunctionValue_list_parameter::getValue(f64 param_0) { - nofralloc -#include "asm/JSystem/JStudio/JStudio/functionvalue/getValue__Q27JStudio29TFunctionValue_list_parameterFd.s" +f64 TFunctionValue_list_parameter::getValue(f64 pfData_) { + pfData_ = range_getParameter(pfData_, data_getValue_front(), data_getValue_back()); + JUT_ASSERT(1395, pfData_!=0) + + // TODO: change to actual function + //dat3 = JGadget::findUpperBound_binary_current(dat1, dat2, dat3, &pfData_); + dat3 = func_802835DC(dat1, dat2, dat3, pfData_); + if (dat3 == dat1) { + return dat3.get()[1]; + } + if (dat3 == dat2) { + --dat3; + return dat3.get()[1]; + } + + const f32* pf = dat3.get(); + const int suData_size = 1; + JUT_ASSERT(1411, (pfData_<=pf-suData_size)&&(pf=3) + const f32* pfVar2 = rThis.dat3.get(); + f64 local_68[4]; + f64 local_48[6]; + local_68[1] = pfVar2[-1]; + local_68[2] = pfVar2[1]; + local_48[2] = pfVar2[-2]; + local_48[3] = pfVar2[0]; + s32 iVar3 = ((int)rThis.dat2.get() - (int)pfVar2) / 4; + s32 iVar5 = ((int)pfVar2 - (int)rThis.dat1.get()) / 4; + switch(iVar5) { + case 2: + local_68[0] = 2.0 * local_68[1] - local_68[2]; + local_68[3] = pfVar2[3]; + local_48[4] = pfVar2[2]; + local_48[1] = 2.0 * local_48[2] - local_48[3]; + local_48[0] = 2.0 * local_48[2] - local_48[4]; + switch (iVar3) { + case 2: + case 4: + local_48[5] = 2.0 * local_48[4] - local_48[3]; + break; + default: + local_48[5] = pfVar2[4]; + break; + } + break; + case 4: + local_68[0] = pfVar2[-3]; + local_48[1] = pfVar2[-4]; + local_48[0] = 2.0 * local_48[1] - local_48[2]; + switch (iVar3) + { + case 2: + local_68[3] = 2.0 * local_68[2] - local_68[1]; + local_48[4] = 2.0 * local_48[3] - local_48[2]; + local_48[5] = 2.0 * local_48[3] - local_48[1]; + break; + case 4: + local_68[3] = pfVar2[3]; + local_48[4] = pfVar2[2]; + local_48[5] = 2.0 * local_48[4] - local_48[3]; + break; + default: + local_68[3] = pfVar2[3]; + local_48[4] = pfVar2[2]; + local_48[5] = pfVar2[4]; + } + break; + default: + local_68[0] = pfVar2[-3]; + local_48[1] = pfVar2[-4]; + local_48[0] = pfVar2[-6]; + switch (iVar3) { + case 2: + local_68[3] = 2.0 * local_68[2] - local_68[1]; + local_48[4] = 2.0 * local_48[3] - local_48[2]; + local_48[5] = 2.0 * local_48[3] - local_48[1]; + break; + case 4: + local_68[3] = pfVar2[3]; + local_48[4] = pfVar2[2]; + local_48[5] = 2.0 * local_48[4] - local_48[3]; + break; + default: + local_68[3] = pfVar2[3]; + local_48[4] = pfVar2[2]; + local_48[5] = pfVar2[4]; + break; + } + break; + } + functionvalue::interpolateValue_BSpline_nonuniform(param_2, (f64*)&local_68, (f64*)&local_48); +} +#else #pragma push #pragma optimization_level 0 #pragma optimizewithasm off @@ -957,6 +1339,7 @@ asm f64 TFunctionValue_list_parameter::update_INTERPOLATE_BSPLINE_dataMore3_( #include "asm/JSystem/JStudio/JStudio/functionvalue/func_80283060.s" } #pragma pop +#endif TFunctionValue_hermite::TFunctionValue_hermite() : pf_(NULL), u_(0), uSize_(0), dat1(*this, NULL), dat2(dat1), dat3(dat1) {} @@ -1001,14 +1384,28 @@ void TFunctionValue_hermite::prepare() { /* 8028344C-80283570 27DD8C 0124+00 1/0 0/0 0/0 .text * getValue__Q27JStudio22TFunctionValue_hermiteFd */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm f64 TFunctionValue_hermite::getValue(f64 param_0) { - nofralloc -#include "asm/JSystem/JStudio/JStudio/functionvalue/getValue__Q27JStudio22TFunctionValue_hermiteFd.s" +f64 TFunctionValue_hermite::getValue(f64 pfData_) { + pfData_ = range_getParameter(pfData_, data_getValue_front(), data_getValue_back()); + JUT_ASSERT(1395, pfData_!=0) + // TODO: change to actual function + //dat3 = JGadget::findUpperBound_binary_current(dat1, dat2, dat3, &pfData_); + dat3 = func_80283858(dat1, dat2, dat3, pfData_); + + if (dat3 == dat1) { + return dat3.get()[1]; + } + if (dat3 == dat2) { + --dat3; + return dat3.get()[1]; + } + + const f32* pfVar5 = dat3.get(); + const f32* pfVar7 = pfVar5 - uSize_; + return functionvalue::interpolateValue_hermite( + pfData_, pfVar7[0], pfVar7[1], + pfVar7[uSize_ - 1], pfVar5[0], + pfVar5[1], pfVar5[2]); } -#pragma pop } // namespace JStudio @@ -1019,7 +1416,7 @@ f64 extrapolateParameter_raw(f64 a1, f64 a2) { return a1; } -f64 extrapolateParameter_repeat(f64 a1, f64 a2) { +inline f64 extrapolateParameter_repeat(f64 a1, f64 a2) { f64 t = fmod(a1, a2); if (t < DOUBLE_LABEL(/* 0.0 */ lit_652)) @@ -1047,11 +1444,10 @@ f64 extrapolateParameter_clamp(f64 value, f64 max) { #pragma push #pragma optimization_level 0 #pragma optimizewithasm off -extern "C" asm void func_802835DC(void* _this, - JStudio::TFunctionValue_list_parameter::TIterator_data_ param_0, - JStudio::TFunctionValue_list_parameter::TIterator_data_ param_1, - JStudio::TFunctionValue_list_parameter::TIterator_data_ param_2, - f64 const& param_3) { +extern "C" asm JStudio::TFunctionValue_list_parameter::TIterator_data_ +func_802835DC(JStudio::TFunctionValue_list_parameter::TIterator_data_ param_0, + JStudio::TFunctionValue_list_parameter::TIterator_data_ param_1, + JStudio::TFunctionValue_list_parameter::TIterator_data_ param_2, f64 const& param_3) { nofralloc #include "asm/JSystem/JStudio/JStudio/functionvalue/func_802835DC.s" } @@ -1079,11 +1475,10 @@ extern "C" asm void func_80283634(void* _this, #pragma push #pragma optimization_level 0 #pragma optimizewithasm off -extern "C" asm void func_80283858(void* _this, - JStudio::TFunctionValue_hermite::TIterator_data_ param_0, - JStudio::TFunctionValue_hermite::TIterator_data_ param_1, - JStudio::TFunctionValue_hermite::TIterator_data_ param_2, - f64 const& param_3) { +extern "C" asm JStudio::TFunctionValue_hermite::TIterator_data_ +func_80283858(JStudio::TFunctionValue_hermite::TIterator_data_ param_0, + JStudio::TFunctionValue_hermite::TIterator_data_ param_1, + JStudio::TFunctionValue_hermite::TIterator_data_ param_2, f64 const& param_3) { nofralloc #include "asm/JSystem/JStudio/JStudio/functionvalue/func_80283858.s" } diff --git a/libs/PowerPC_EABI_Support/MSL/MSL_C++/MSL_Common/Include/iterator.h b/libs/PowerPC_EABI_Support/MSL/MSL_C++/MSL_Common/Include/iterator.h index 82e799a5767..f7d86e37896 100644 --- a/libs/PowerPC_EABI_Support/MSL/MSL_C++/MSL_Common/Include/iterator.h +++ b/libs/PowerPC_EABI_Support/MSL/MSL_C++/MSL_Common/Include/iterator.h @@ -9,6 +9,13 @@ inline void advance( InputIt& it, Distance n) { ++it; } } + +// This needs to be defined with gcc concepts or something similar. Workaround. +template< class InputIt, class Distance > +inline void advance_pointer( InputIt& it, Distance n) { + it += n; +} + } #endif \ No newline at end of file