diff --git a/decompiler/IR2/FormExpressionAnalysis.cpp b/decompiler/IR2/FormExpressionAnalysis.cpp index 4d66207544..f14371fc2a 100644 --- a/decompiler/IR2/FormExpressionAnalysis.cpp +++ b/decompiler/IR2/FormExpressionAnalysis.cpp @@ -1225,7 +1225,9 @@ void SimpleExpressionElement::update_from_stack_add_i(const Env& env, auto& name = env.func->guessed_name; if (name.kind == FunctionName::FunctionKind::METHOD && name.method_id == 7 && env.func->type.arg_count() == 3) { - if (env.dts->ts.tc(TypeSpec("structure"), arg0_type.typespec()) && (arg1_i || arg1_u)) { + if ((env.dts->ts.tc(TypeSpec("structure"), arg0_type.typespec()) || + arg0_type.typespec().base_type() == "inline-array") && + (arg1_i || arg1_u)) { auto new_form = pool.alloc_element( GenericOperator::make_fixed(FixedOperatorKind::ADDITION_PTR), args.at(0), args.at(1)); result->push_back(new_form); diff --git a/decompiler/config/jak2/all-types.gc b/decompiler/config/jak2/all-types.gc index 8c1a1c2172..54c36dd63c 100644 --- a/decompiler/config/jak2/all-types.gc +++ b/decompiler/config/jak2/all-types.gc @@ -12331,7 +12331,7 @@ ((status joint-control-status) (allocated-length uint8) (active-channels uint8) - (root-channel uint32 :offset 16) + (root-channel (inline-array joint-control) :offset 16) (blend-index uint8) (active-frame-interp uint8) (float-channels uint8) diff --git a/decompiler/config/jak2/type_casts.jsonc b/decompiler/config/jak2/type_casts.jsonc index 4f43548b45..f6d58b4662 100644 --- a/decompiler/config/jak2/type_casts.jsonc +++ b/decompiler/config/jak2/type_casts.jsonc @@ -702,7 +702,10 @@ [14, "v1", "(pointer art)"] ], "(method 9 art-joint-anim)": [[9, "v1", "pointer"]], - "joint-control-copy!": [[8, "a0", "uint"]], + "joint-control-copy!": [ + [8, "a0", "uint"], + [8, "v1", "uint"] + ], "joint-control-remap!": [ [127, "t9", "(function joint-control joint-control-channel int object)"], [181, "t9", "(function joint-control joint-control-channel int object)"], diff --git a/goal_src/jak2/engine/anim/joint-h.gc b/goal_src/jak2/engine/anim/joint-h.gc index 115234754c..fa6d93e0ed 100644 --- a/goal_src/jak2/engine/anim/joint-h.gc +++ b/goal_src/jak2/engine/anim/joint-h.gc @@ -85,21 +85,21 @@ ) (deftype joint-control (basic) - ((status joint-control-status :offset-assert 4) - (allocated-length uint8 :offset-assert 6) - (active-channels uint8 :offset-assert 7) - (root-channel uint32 :offset 16) - (blend-index uint8 :offset-assert 20) - (active-frame-interp uint8 :offset-assert 21) - (float-channels uint8 :offset-assert 22) - (generate-frame-function function :offset-assert 24) - (prebind-function function :offset-assert 28) - (postbind-function function :offset-assert 32) - (effect basic :offset-assert 36) - (interp-select int64 2 :offset-assert 40) - (top-anim top-anim-joint-control :offset-assert 56) - (override basic :offset-assert 60) - (channel joint-control-channel :inline :dynamic :offset-assert 64) + ((status joint-control-status :offset-assert 4) + (allocated-length uint8 :offset-assert 6) + (active-channels uint8 :offset-assert 7) + (root-channel (inline-array joint-control) :offset 16) + (blend-index uint8 :offset-assert 20) + (active-frame-interp uint8 :offset-assert 21) + (float-channels uint8 :offset-assert 22) + (generate-frame-function function :offset-assert 24) + (prebind-function function :offset-assert 28) + (postbind-function function :offset-assert 32) + (effect basic :offset-assert 36) + (interp-select int64 2 :offset-assert 40) + (top-anim top-anim-joint-control :offset-assert 56) + (override basic :offset-assert 60) + (channel joint-control-channel :inline :dynamic :offset-assert 64) ) :method-count-assert 12 :size-assert #x40 @@ -112,6 +112,7 @@ ) ) + (deftype matrix-stack (structure) ((top matrix :offset-assert 0) (data matrix 24 :inline :offset-assert 16) diff --git a/goal_src/jak2/engine/anim/joint.gc b/goal_src/jak2/engine/anim/joint.gc index 45740a6947..ad4dfc0cd2 100644 --- a/goal_src/jak2/engine/anim/joint.gc +++ b/goal_src/jak2/engine/anim/joint.gc @@ -158,7 +158,7 @@ (set! (-> v0-0 allocated-length) (the-as uint arg0)) (set! (-> v0-0 active-channels) (the-as uint 0)) (set! (-> v0-0 float-channels) (the-as uint 0)) - (set! (-> v0-0 root-channel) (the-as uint (-> v0-0 channel))) + (set! (-> v0-0 root-channel) (the-as (inline-array joint-control) (-> v0-0 channel))) (set! (-> v0-0 generate-frame-function) create-interpolated-joint-animation-frame) (set! (-> v0-0 prebind-function) #f) (set! (-> v0-0 postbind-function) #f) @@ -666,7 +666,13 @@ (set! (-> arg0 active-channels) (-> arg1 active-channels)) (set! (-> arg0 float-channels) (the-as uint 0)) (set! (-> arg0 root-channel) - (the-as uint (-> arg0 channel (/ (the-as int (- (-> arg1 root-channel) (the-as uint (-> arg1 channel)))) 64))) + (the-as + (inline-array joint-control) + (-> arg0 + channel + (/ (the-as int (- (the-as uint (-> arg1 root-channel)) (the-as uint (the-as uint (-> arg1 channel))))) 64) + ) + ) ) (let ((v1-10 (min (the-as int (-> arg0 allocated-length)) (the-as int (-> arg1 active-channels))))) (mem-copy! (the-as pointer (-> arg0 channel)) (the-as pointer (-> arg1 channel)) (* v1-10 64)) diff --git a/goal_src/jak2/engine/entity/relocate.gc b/goal_src/jak2/engine/entity/relocate.gc index c8422f0d92..cc22887475 100644 --- a/goal_src/jak2/engine/entity/relocate.gc +++ b/goal_src/jak2/engine/entity/relocate.gc @@ -212,7 +212,7 @@ (if (-> obj top-anim) (&+! (-> obj top-anim) arg0) ) - (+! (-> obj root-channel) arg0) + (&+! (-> obj root-channel) arg0) (countdown (v1-10 (-> obj allocated-length)) (&+! (-> obj channel v1-10 parent) arg0) ) diff --git a/test/decompiler/reference/jak1/engine/entity/relocate_REF.gc b/test/decompiler/reference/jak1/engine/entity/relocate_REF.gc index 5aa3f836e4..708aeb9455 100644 --- a/test/decompiler/reference/jak1/engine/entity/relocate_REF.gc +++ b/test/decompiler/reference/jak1/engine/entity/relocate_REF.gc @@ -224,9 +224,7 @@ (if (-> obj effect) (&+! (-> obj effect) arg0) ) - (set! (-> obj root-channel) - (the-as (inline-array joint-control-channel) (+ (the-as uint (-> obj root-channel)) arg0)) - ) + (set! (-> obj root-channel) (the-as (inline-array joint-control-channel) (&+ (-> obj root-channel) arg0))) (countdown (v1-6 (-> obj allocated-length)) (&+! (-> obj channel v1-6 parent) arg0) ) diff --git a/test/decompiler/reference/jak2/engine/anim/joint-h_REF.gc b/test/decompiler/reference/jak2/engine/anim/joint-h_REF.gc index e895e880ac..e9f48634bc 100644 --- a/test/decompiler/reference/jak2/engine/anim/joint-h_REF.gc +++ b/test/decompiler/reference/jak2/engine/anim/joint-h_REF.gc @@ -145,21 +145,21 @@ ;; definition of type joint-control (deftype joint-control (basic) - ((status joint-control-status :offset-assert 4) - (allocated-length uint8 :offset-assert 6) - (active-channels uint8 :offset-assert 7) - (root-channel uint32 :offset 16) - (blend-index uint8 :offset-assert 20) - (active-frame-interp uint8 :offset-assert 21) - (float-channels uint8 :offset-assert 22) - (generate-frame-function function :offset-assert 24) - (prebind-function function :offset-assert 28) - (postbind-function function :offset-assert 32) - (effect basic :offset-assert 36) - (interp-select int64 2 :offset-assert 40) - (top-anim top-anim-joint-control :offset-assert 56) - (override basic :offset-assert 60) - (channel joint-control-channel :inline :dynamic :offset-assert 64) + ((status joint-control-status :offset-assert 4) + (allocated-length uint8 :offset-assert 6) + (active-channels uint8 :offset-assert 7) + (root-channel (inline-array joint-control) :offset 16) + (blend-index uint8 :offset-assert 20) + (active-frame-interp uint8 :offset-assert 21) + (float-channels uint8 :offset-assert 22) + (generate-frame-function function :offset-assert 24) + (prebind-function function :offset-assert 28) + (postbind-function function :offset-assert 32) + (effect basic :offset-assert 36) + (interp-select int64 2 :offset-assert 40) + (top-anim top-anim-joint-control :offset-assert 56) + (override basic :offset-assert 60) + (channel joint-control-channel :inline :dynamic :offset-assert 64) ) :method-count-assert 12 :size-assert #x40 diff --git a/test/decompiler/reference/jak2/engine/anim/joint_REF.gc b/test/decompiler/reference/jak2/engine/anim/joint_REF.gc index 9f1646ed81..946468f664 100644 --- a/test/decompiler/reference/jak2/engine/anim/joint_REF.gc +++ b/test/decompiler/reference/jak2/engine/anim/joint_REF.gc @@ -167,7 +167,7 @@ (set! (-> v0-0 allocated-length) (the-as uint arg0)) (set! (-> v0-0 active-channels) (the-as uint 0)) (set! (-> v0-0 float-channels) (the-as uint 0)) - (set! (-> v0-0 root-channel) (the-as uint (-> v0-0 channel))) + (set! (-> v0-0 root-channel) (the-as (inline-array joint-control) (-> v0-0 channel))) (set! (-> v0-0 generate-frame-function) create-interpolated-joint-animation-frame) (set! (-> v0-0 prebind-function) #f) (set! (-> v0-0 postbind-function) #f) @@ -708,7 +708,13 @@ (set! (-> arg0 active-channels) (-> arg1 active-channels)) (set! (-> arg0 float-channels) (the-as uint 0)) (set! (-> arg0 root-channel) - (the-as uint (-> arg0 channel (/ (the-as int (- (-> arg1 root-channel) (the-as uint (-> arg1 channel)))) 64))) + (the-as + (inline-array joint-control) + (-> arg0 + channel + (/ (the-as int (- (the-as uint (-> arg1 root-channel)) (the-as uint (the-as uint (-> arg1 channel))))) 64) + ) + ) ) (let ((v1-10 (min (the-as int (-> arg0 allocated-length)) (the-as int (-> arg1 active-channels))))) (mem-copy! (the-as pointer (-> arg0 channel)) (the-as pointer (-> arg1 channel)) (* v1-10 64)) diff --git a/test/decompiler/reference/jak2/engine/entity/relocate_REF.gc b/test/decompiler/reference/jak2/engine/entity/relocate_REF.gc index 24d8aef0b0..f4888b39b1 100644 --- a/test/decompiler/reference/jak2/engine/entity/relocate_REF.gc +++ b/test/decompiler/reference/jak2/engine/entity/relocate_REF.gc @@ -218,7 +218,7 @@ (if (-> obj top-anim) (&+! (-> obj top-anim) arg0) ) - (+! (-> obj root-channel) arg0) + (&+! (-> obj root-channel) arg0) (countdown (v1-10 (-> obj allocated-length)) (&+! (-> obj channel v1-10 parent) arg0) )