diff --git a/common/type_system/TypeSpec.h b/common/type_system/TypeSpec.h index 8978f134ca..dd93101a97 100644 --- a/common/type_system/TypeSpec.h +++ b/common/type_system/TypeSpec.h @@ -132,6 +132,12 @@ class TypeSpec { return m_arguments->back(); } + TypeSpec& last_arg() { + ASSERT(m_arguments); + ASSERT(!m_arguments->empty()); + return m_arguments->back(); + } + bool empty() const { if (!m_arguments) { return true; diff --git a/decompiler/IR2/FormExpressionAnalysis.cpp b/decompiler/IR2/FormExpressionAnalysis.cpp index ebd10e5d3e..4d66207544 100644 --- a/decompiler/IR2/FormExpressionAnalysis.cpp +++ b/decompiler/IR2/FormExpressionAnalysis.cpp @@ -3086,7 +3086,8 @@ void FunctionCallElement::update_from_stack(const Env& env, auto vtable_var_name = env.get_variable_name(*vtable_reg); auto arg0_mr = match(Matcher::any_reg(0), unstacked.at(1)); if (arg0_mr.matched && env.get_variable_name(*arg0_mr.maps.regs.at(0)) == vtable_var_name) { - if (tp_type.kind != TP_Type::Kind::VIRTUAL_METHOD) { + if (tp_type.kind != TP_Type::Kind::VIRTUAL_METHOD && + tp_type.kind != TP_Type::Kind::GET_ART_BY_NAME_METHOD) { throw std::runtime_error( "Method internal mismatch. METHOD_OF_OBJECT operator didn't get a VIRTUAL_METHOD " "type."); @@ -3111,6 +3112,13 @@ void FunctionCallElement::update_from_stack(const Env& env, arg_forms.at(0) = pop; auto head = mr.maps.forms.at(1); + // rewrite get-art-by-name-method calls to get-art-by-name, which is a macro that + // will apply the appropriate cast. + if (tp_type.kind == TP_Type::Kind::GET_ART_BY_NAME_METHOD) { + ASSERT(head->to_string(env) == "get-art-by-name-method"); + head = pool.form("get-art-by-name"); + } + auto head_obj = head->to_form(env); if (head_obj.is_symbol() && tp_type.method_from_type().base_type() == "setting-control" && arg_forms.at(0)->to_form(env).is_symbol("*setting-control*") && diff --git a/decompiler/config/all-types.gc b/decompiler/config/all-types.gc index 9f418348cb..f519e28a07 100644 --- a/decompiler/config/all-types.gc +++ b/decompiler/config/all-types.gc @@ -1030,7 +1030,7 @@ (sidekick-hint-rounddoor #x23c) (sidekick-hint-lurkerm #x23d) (sidekick-hint-tower #x23e) - + (sidekick-reminder-fish #x240) (firecanyon-need-cells #x24f) diff --git a/decompiler/config/jak2/all-types.gc b/decompiler/config/jak2/all-types.gc index 8e32099079..55586a6c6c 100644 --- a/decompiler/config/jak2/all-types.gc +++ b/decompiler/config/jak2/all-types.gc @@ -5840,7 +5840,7 @@ (:methods (level-get (_type_ symbol) level 9) (level-get-with-status (_type_ symbol) level 10) - (get-level-by-heap-ptr-and-status (_type_ pointer uint) level 11) ;; + (get-level-by-heap-ptr-and-status (_type_ pointer symbol) level 11) ;; (level-get-for-use (_type_ symbol symbol) level 12) (activate-levels! (_type_) int 13) ;; (debug-print-entities (_type_ symbol type) none 13) (level-group-method-14 () none 14) ;; (debug-draw-actors (_type_ symbol) none 14) @@ -7285,13 +7285,35 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defenum mem-usage-id - :type uint32 - (bsp-leaf-vis-self 62) - (bsp-leaf-vis-adj 63) + :bitfield #f + :type uint32 + (entity 43) + (camera 44) - (level-code 65) - (entity-links 66) - ) + (res 48) + + (bsp-leaf-vis-self 62) + (bsp-leaf-vis-adj 63) + + (level-code 65) + (entity-links 66) + + (joint 67) + + (joint-anim-compressed-control 69) + (joint-anim-fixed 70) + (joint-anim-frame 71) + + (art-group 73) + (art-mesh-anim 74) + (art-mesh-geo 75) + (art-joint-geo 76) + (art-joint-anim 77) + + (joint-anim-drawable 78) + + (eye-anim 111) + ) (deftype memory-usage-info (structure) ((name string :offset-assert 0) ;; guessed by decompiler @@ -7654,8 +7676,8 @@ :flag-assert #xa00000020 ;; field param1 uses ~A with a signed load field param2 uses ~A with a signed load (:methods - ;; (new (symbol type basic) _type_ 0) - (cspace-method-9 () none 9) ;; (reset-and-assign-geo! (_type_ basic) _type_ 9) + (new (symbol type basic) _type_ 0) + (reset-and-assign-geo! (_type_ basic) _type_ 9) ) ) @@ -9710,7 +9732,7 @@ (deftype joint-anim-frame (structure) ((matrices matrix 2 :inline :offset-assert 0) ;; guessed by decompiler - (data matrix :dynamic :offset-assert 128) ;; guessed by decompiler + (data transformq :dynamic :inline :offset-assert 128) ;; guessed by decompiler ) (:methods (new (symbol type int) _type_ 0) @@ -9777,10 +9799,10 @@ :size-assert #x14 :flag-assert #xd00000014 (:methods - (art-method-9 () none 9) ;; (login (_type_) _type_ 9) - (art-method-10 () none 10) ;; (lookup-art (_type_ string type) joint 10) - (art-method-11 () none 11) ;; (lookup-idx-of-art (_type_ string type) int 11) - (art-method-12 () none 12) ;; (needs-link? (_type_) symbol 12) + (login (_type_) _type_ 9) + (get-art-by-name-method (_type_ string type) basic 10) + (get-art-idx-by-name-method (_type_ string type) int 11) + (needs-link? (_type_) symbol 12) ) ) @@ -9794,15 +9816,16 @@ (deftype art-mesh-anim (art-element) - () + ((data basic :dynamic)) :flag-assert #xd00000020 ) +(declare-type merc-eye-anim-block structure) (deftype art-joint-anim (art-element) ((speed float :offset 20) (artist-base float :offset 24) (artist-step float :offset 28) - (eye-anim basic :offset 4) + (eye-anim merc-eye-anim-block :offset 4) (master-art-group-name string :offset-assert 32) ;; guessed by decompiler (master-art-group-index int32 :offset-assert 36) (blend-shape-anim basic :offset-assert 40) @@ -9825,23 +9848,26 @@ :flag-assert #xf00000020 ;; Failed to read fields. (:methods - (art-group-method-13 () none 13) ;; (link-art! (_type_) art-group 13) + (relocate (_type_ kheap (pointer uint8)) none :replace 7) + (link-art! (_type_) art-group 13) (art-group-method-14 () none 14) ;; (unlink-art! (_type_) int 14) ) ) (deftype art-mesh-geo (art-element) - () + ((data basic :dynamic :offset-assert 32) + ) :flag-assert #xd00000020 ) (deftype art-joint-geo (art-element) - () + ((data joint :dynamic :offset-assert 32) + ) :flag-assert #xd00000020 ) (deftype art-joint-anim-manager-slot (structure) - ((anim basic :offset-assert 0) + ((anim art-joint-anim :offset-assert 0) (comp-data uint32 :offset-assert 4) (time-stamp uint64 :offset-assert 8) ) @@ -9862,10 +9888,10 @@ ;; Failed to read fields. (:methods (new (symbol type int) _type_ 0) - (art-joint-anim-manager-method-9 () none 9) - (art-joint-anim-manager-method-10 () none 10) - (unload-from-slot (_type_ int) none 11) - (art-joint-anim-manager-method-12 () none 12) + (decompress (_type_ art-joint-anim) art-joint-anim 9) + (update-time-stamp (_type_ art-joint-anim) art-joint-anim 10) + (unload-from-slot (_type_ int) art-joint-anim 11) + (used-bytes-for-slot (_type_ int) int 12) (unload-from-level (_type_ level) none 13) ) ) @@ -12049,13 +12075,13 @@ (frame-group art-joint-anim :offset-assert 4) (frame-num float :offset-assert 8) (dist meters :offset-assert 12) - (num-func (function joint-control-channel float float float)) + (num-func (function joint-control-channel float float float float)) (param float 3) (frame-interp float 2) (inspector-amount uint8) (command joint-control-command) (group-sub-index int8 :offset-assert 56) - (grou-size int8) + (group-size int8) (eval-time uint32) ) :method-count-assert 9 @@ -12136,10 +12162,10 @@ :flag-assert #xc00000040 ;; Failed to read fields. (:methods - ;; (new (symbol type int) _type_ 0) + (new (symbol type int) _type_ 0) (joint-control-method-9 () none 9) ;; (current-cycle-distance (_type_) float 9) - (joint-control-method-10 () none 10) ;; (debug-print-channels (_type_ symbol) int 10) - (joint-control-method-11 () none 11) + (joint-control-method-10 () none 10) + (debug-print-channels (_type_ symbol) int 11) ) ) @@ -20803,47 +20829,47 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; (define-extern joint-anim-login function) ;; (function joint-anim-drawable joint-anim-drawable) -;; (define-extern joint-anim-inspect-elt function) ;; (function joint-anim float joint-anim) -;; (define-extern jacc-mem-usage function) ;; (function joint-anim-compressed-control memory-usage-block int joint-anim-compressed-control) -;; (define-extern joint-control-channel-eval function) ;; (function joint-control-channel none) -;; (define-extern joint-control-channel-eval! function) ;; (function joint-control-channel (function joint-control-channel float float float) none) -;; (define-extern joint-control-channel-group-eval! function) ;; (function joint-control-channel art-joint-anim (function joint-control-channel float float float) int) -;; (define-extern joint-control-channel-group! function) ;; (function joint-control-channel art-joint-anim (function joint-control-channel float float float) int) -;; (define-extern joint-control-copy! function) ;; (function joint-control joint-control joint-control) -;; (define-extern joint-control-remap! function) ;; (function joint-control art-group art-group pair int string object) -;; (define-extern flatten-joint-control-to-spr function) ;; (function joint-control int) -;; (define-extern matrix-from-joint-anim-frame function) ;; (function joint-anim-compressed-control int int matrix) -;; (define-extern matrix-from-control-channel! function) ;; (function matrix joint joint-control-channel matrix) -;; (define-extern matrix-from-control-pair! function) ;; (function matrix matrix joint matrix) -;; (define-extern matrix-from-control! function) ;; (function matrix-stack joint joint-control symbol matrix) -;; (define-extern cspace<-cspace! function) ;; (function cspace cspace matrix) -;; (define-extern cspace<-cspace-normalized! function) -;; (define-extern cspace<-parent-joint! function) -;; (define-extern cspace<-rot-yxy! function) ;; (function cspace transform matrix) -;; (define-extern cspace<-transform-yxy! function) ;; (function cspace transform matrix) +(define-extern joint-anim-login (function joint-anim-drawable joint-anim-drawable)) +(define-extern joint-anim-inspect-elt (function joint-anim float joint-anim)) +(define-extern jacc-mem-usage (function joint-anim-compressed-control memory-usage-block int joint-anim-compressed-control)) +(define-extern joint-control-channel-eval (function joint-control-channel float :behavior process)) +(define-extern joint-control-channel-eval! (function joint-control-channel (function joint-control-channel float float float float) float :behavior process)) +(define-extern joint-control-channel-group-eval! (function joint-control-channel art-joint-anim (function joint-control-channel float float float float) int)) +(define-extern joint-control-channel-group! (function joint-control-channel art-joint-anim (function joint-control-channel float float float float) int)) +(define-extern joint-control-copy! (function joint-control joint-control joint-control)) +(define-extern joint-control-remap! (function joint-control art-group art-group pair int string object)) +(define-extern flatten-joint-control-to-spr (function joint-control int)) +(define-extern matrix-from-joint-anim-frame (function joint-anim-compressed-control int int matrix)) +(define-extern matrix-from-control-channel! (function matrix joint joint-control-channel matrix)) +(define-extern matrix-from-control-pair! (function matrix matrix joint int matrix)) +(define-extern matrix-from-control! (function matrix-stack joint joint-control symbol matrix)) +(define-extern cspace<-cspace! (function cspace cspace matrix)) +(define-extern cspace<-cspace-normalized! (function cspace cspace matrix)) +(define-extern cspace<-parent-joint! (function cspace (pointer process-drawable) int matrix)) +(define-extern cspace<-rot-yxy! (function cspace transform matrix)) +(define-extern cspace<-transform-yxy! (function cspace transform matrix)) (define-extern cspace<-transformq! (function cspace transformq matrix)) -;; (define-extern cspace<-transformq+trans! function) ;; (function cspace transformq vector matrix) -;; (define-extern cspace<-transformq+world-trans! function) ;; (function cspace transformq vector matrix) -;; (define-extern cspace<-transformq+rot-offset! function) -;; (define-extern cspace-calc-total-matrix! function) ;; (function cspace matrix matrix) -;; (define-extern cspace<-matrix-no-push-joint! function) ;; (function cspace joint-control matrix) -;; (define-extern cspace<-matrix-joint! function) ;; (function cspace matrix matrix) -;; (define-extern cspace<-parented-matrix-joint! function) ;; (function cspace matrix matrix) -;; (define-extern cspace<-parented-matrix-mirror! function) -;; (define-extern cspace<-parented-matrix-joint-flip-z! function) -;; (define-extern cspace<-matrix-joint-flip-z! function) +(define-extern cspace<-transformq+trans! (function cspace transformq vector matrix)) +(define-extern cspace<-transformq+world-trans! (function cspace transformq vector matrix)) +(define-extern cspace<-transformq+rot-offset! (function cspace transformq vector matrix)) +(define-extern cspace-calc-total-matrix! (function cspace matrix matrix)) +(define-extern cspace<-matrix-no-push-joint! (function cspace joint-control matrix)) +(define-extern cspace<-matrix-joint! (function cspace matrix matrix)) +(define-extern cspace<-parented-matrix-joint! (function cspace matrix matrix)) +(define-extern cspace<-parented-matrix-mirror! (function cspace matrix matrix)) +(define-extern cspace<-parented-matrix-joint-flip-z! (function cspace matrix matrix)) +(define-extern cspace<-matrix-joint-flip-z! (function cspace matrix none)) (define-extern cspace<-parented-transformq-joint! (function cspace transformq none)) -;; (define-extern cspace<-parented-transformq-joint-flip-z! function) +(define-extern cspace<-parented-transformq-joint-flip-z! (function cspace transformq none)) ;; (define-extern clear-frame-accumulator function) ;; (function (inline-array vector) none) ;; (define-extern normalize-frame-quaternions function) ;; function -;; (define-extern decompress-fixed-data-to-accumulator function) ;; (function none) -;; (define-extern decompress-frame-data-to-accumulator function) ;; (function none) -;; (define-extern decompress-frame-data-pair-to-accumulator function) ;; (function none) -;; (define-extern make-joint-jump-tables function) ;; (function int) -;; (define-extern calc-animation-from-spr function) ;; (function (inline-array vector) int none) -;; (define-extern create-interpolated-joint-animation-frame function) ;; (function (inline-array vector) int process-drawable int) -;; (define-extern create-interpolated2-joint-animation-frame function) +(define-extern decompress-fixed-data-to-accumulator function) ;; (function none) +(define-extern decompress-frame-data-to-accumulator function) ;; (function none) +(define-extern decompress-frame-data-pair-to-accumulator function) ;; (function none) +(define-extern make-joint-jump-tables (function int)) +(define-extern calc-animation-from-spr (function joint-anim-frame int none)) +(define-extern create-interpolated-joint-animation-frame (function joint-anim-frame int joint-control int)) +(define-extern create-interpolated2-joint-animation-frame (function joint-anim-frame int joint-control int)) (define-extern *anim-manager* art-joint-anim-manager) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -22111,7 +22137,7 @@ ;; (define-extern unpack-comp-rle function) ;; (function (pointer int8) (pointer int8) none) ;; (define-extern unpack-comp-huf function) ;; (function (pointer uint8) (pointer uint8) uint huf-dictionary-node none) -;; (define-extern unpack-comp-lzo function) +(define-extern unpack-comp-lzo (function object object none)) ;; (define-extern pack-comp-rle function) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -27391,7 +27417,7 @@ ) |# -;; (define-extern mem-size function) ;; (function basic symbol int int) +(define-extern mem-size (function basic symbol int int)) ;; (define-extern *max-dma* object) ;; int diff --git a/decompiler/config/jak2/hacks.jsonc b/decompiler/config/jak2/hacks.jsonc index 3923bc1dc3..15ae066e02 100644 --- a/decompiler/config/jak2/hacks.jsonc +++ b/decompiler/config/jak2/hacks.jsonc @@ -36,7 +36,6 @@ "asm_functions_by_name": [ // checking boxed type is different now - these make the cfg stuff sad "name=", - "joint-control-remap!", "(method 21 game-info)", "(anon-function 2 cam-combiner)", "cspace-inspect-tree", @@ -200,6 +199,7 @@ "~170h~5d~220h~5d~280h~5,,2f": 3, "~338h~5d~388h~5d~448h~5,,2f": 3, "~1k~%": 0, + "~0K": 0, "~30Htf: ~8D~134Hpr: ~8D~252Hsh: ~8D~370Hhd: ~8D~%": 4, "~30Hal: ~8D~131Hwa: ~8D~252Hsp: ~8D~370Hwp: ~8D~%": 4, "~0Kload ~16S ~5S ~5DK ~5,,2fs ~5,,2fs~1K ~5,,0f k/s~%": 6 @@ -233,7 +233,8 @@ "mips2c_functions_by_name": [ "collide-do-primitives", - "moving-sphere-triangle-intersect" + "moving-sphere-triangle-intersect", + "calc-animation-from-spr" ], "mips2c_jump_table_functions": {}, diff --git a/decompiler/config/jak2/type_casts.jsonc b/decompiler/config/jak2/type_casts.jsonc index 7c446e8fe9..79dd9b5c19 100644 --- a/decompiler/config/jak2/type_casts.jsonc +++ b/decompiler/config/jak2/type_casts.jsonc @@ -616,6 +616,88 @@ [[454, 467], "a0", "handle"], [[455, 462], "v1", "handle"] ], +"(method 9 art)": [ + [9, "v1", "pointer"] + ], + "(method 12 art-group)":[ + [12, "a0", "art-joint-anim"] + ], + "(method 9 art-mesh-geo)": [ + [20, "s4", "(pointer int16)"], + [[14, 19], "a0", "drawable"], + [10, "v1", "(pointer art)"], + [14, "v1", "(pointer art)"] + ], + "(method 9 art-joint-anim)": [ + [9, "v1", "pointer"] + ], + "joint-control-copy!": [ + [8, "a0", "uint"] + ], + "joint-control-remap!": [ + [127, "t9", "(function joint-control joint-control-channel int object)"], + [181, "t9", "(function joint-control joint-control-channel int object)"], + ["_stack_", 60, "basic"] + ], + "flatten-joint-control-to-spr": [ + [[201, 203], "a1", "terrain-context"], + [[131, 133], "a0", "terrain-context"], + [[182, 184], "a1", "terrain-context"], + [[164, 166], "a0", "terrain-context"], + [195, "v1", "terrain-context"], + [65, "a3", "(pointer float)"], + [67, "a3", "(pointer float)"], + + [[18, 24], "a2", "(inline-array vector)"], + [24, "a3", "(pointer float)"], + [[59, 65], "a2", "(inline-array vector)"], + [[112, 118], "a2", "(inline-array vector)"], + [17, "a2", "int"] + ], + + "(method 2 art-joint-anim-manager-slot)": [ + [21, "s2", "uint"], + [21, "v1", "uint"] + ], + + "create-interpolated2-joint-animation-frame": [ + [[48, 125], "v1", "joint-anim-frame"] + ], + + "(method 12 art-joint-anim-manager)": [ + [15, "a0", "pointer"], + [15, "v1", "pointer"], + [21, "a0", "pointer"], + [21, "v1", "pointer"] + ], + + "(method 11 art-joint-anim-manager)": [ + [54, "v1", "uint"], + [54, "s2", "uint"], + [60, "s2", "uint"], + [65, "s2", "uint"], + [71, "s2", "uint"], + [87, "a1", "uint"], + [94, "a2", "uint"] + ], + + "joint-anim-inspect-elt": [ + [[4, 15], "gp", "joint-anim-matrix"], + [[17, 30], "gp", "joint-anim-transformq"] + ], + + "matrix-from-control!": [ + [22, "v1", "pointer"], + [35, "v1", "pointer"], + [38, "v1", "pointer"], + [65, "v1", "pointer"], + [72, "v1", "pointer"], + [82, "v1", "pointer"], + [85, "v1", "pointer"], + + // [58, "v1", "matrix"], + [[43, 49], "v1", "matrix"] + ], // placeholder "placeholder-do-not-add-below": [] } diff --git a/decompiler/types2/ForwardProp.cpp b/decompiler/types2/ForwardProp.cpp index d4ea91ab36..d2ad3b3744 100644 --- a/decompiler/types2/ForwardProp.cpp +++ b/decompiler/types2/ForwardProp.cpp @@ -1873,6 +1873,15 @@ bool load_var_op_determine_type(types2::Type& type_out, return true; } else { // normal virtual method access. + // first check special cases + if (type_name == "art" || type_name == "art-group") { + if (method_id == 10) { + type_out.type = + TP_Type::make_get_art_by_name(method_type, TypeSpec(type_name), method_id); + return true; + } + } + // nope type_out.type = TP_Type::make_virtual_method(method_type, TypeSpec(type_name), method_id); return true; } @@ -2259,6 +2268,19 @@ void CallOp::propagate_types2(types2::Instruction& instr, in_type = state_to_go_function(state_typespec, TypeSpec("object")); } + if (in_tp.kind == TP_Type::Kind::GET_ART_BY_NAME_METHOD) { + can_backprop = false; + // let's see what a2 holds... + auto& arg2_type = input_types[Register(Reg::GPR, arg_regs[2])]; + if (arg2_type->type) { + auto& tpt = *arg2_type->type; + if (tpt.kind == TP_Type::Kind::TYPE_OF_TYPE_NO_VIRTUAL) { + ASSERT(in_type.last_arg() == TypeSpec("basic")); // just to double check right function + in_type.last_arg() = tpt.get_type_objects_typespec(); + } + } + } + // special case: process initialization if (in_tp.kind == TP_Type::Kind::RUN_FUNCTION_IN_PROCESS_FUNCTION || in_tp.kind == TP_Type::Kind::SET_TO_RUN_FUNCTION) { diff --git a/decompiler/util/TP_Type.cpp b/decompiler/util/TP_Type.cpp index 8b62cf5d94..5126d8598e 100644 --- a/decompiler/util/TP_Type.cpp +++ b/decompiler/util/TP_Type.cpp @@ -78,6 +78,8 @@ std::string TP_Type::print() const { return ""; case Kind::RUN_FUNCTION_IN_PROCESS_FUNCTION: return ""; + case Kind::GET_ART_BY_NAME_METHOD: + return ""; case Kind::INVALID: default: ASSERT(false); @@ -134,6 +136,7 @@ bool TP_Type::operator==(const TP_Type& other) const { case Kind::ENTER_STATE_FUNCTION: case Kind::RUN_FUNCTION_IN_PROCESS_FUNCTION: case Kind::SET_TO_RUN_FUNCTION: + case Kind::GET_ART_BY_NAME_METHOD: return true; case Kind::INVALID: default: @@ -200,6 +203,8 @@ TypeSpec TP_Type::typespec() const { case Kind::SET_TO_RUN_FUNCTION: // give a general function so we can't call it normally. return TypeSpec("function"); + case Kind::GET_ART_BY_NAME_METHOD: + return m_ts; case Kind::INVALID: default: ASSERT(false); diff --git a/decompiler/util/TP_Type.h b/decompiler/util/TP_Type.h index 6b99fb2854..8630c6ae4f 100644 --- a/decompiler/util/TP_Type.h +++ b/decompiler/util/TP_Type.h @@ -41,6 +41,7 @@ class TP_Type { ENTER_STATE_FUNCTION, RUN_FUNCTION_IN_PROCESS_FUNCTION, SET_TO_RUN_FUNCTION, + GET_ART_BY_NAME_METHOD, INVALID } kind = Kind::UNINITIALIZED; TP_Type() = default; @@ -73,6 +74,7 @@ class TP_Type { case Kind::ENTER_STATE_FUNCTION: case Kind::RUN_FUNCTION_IN_PROCESS_FUNCTION: case Kind::SET_TO_RUN_FUNCTION: + case Kind::GET_ART_BY_NAME_METHOD: return false; case Kind::UNINITIALIZED: case Kind::OBJECT_NEW_METHOD: @@ -287,6 +289,17 @@ class TP_Type { return result; } + static TP_Type make_get_art_by_name(const TypeSpec& method_ts, + const TypeSpec& obj_ts, + int method_id) { + TP_Type result; + result.kind = Kind::GET_ART_BY_NAME_METHOD; + result.m_ts = method_ts; + result.m_method_from_type = obj_ts; + result.m_method_id = method_id; + return result; + } + const TypeSpec& get_objects_typespec() const { ASSERT(kind == Kind::TYPESPEC || kind == Kind::INTEGER_CONSTANT_PLUS_VAR); return m_ts; @@ -347,12 +360,14 @@ class TP_Type { } const TypeSpec& method_from_type() const { - ASSERT(kind == Kind::VIRTUAL_METHOD || kind == Kind::NON_VIRTUAL_METHOD); + ASSERT(kind == Kind::VIRTUAL_METHOD || kind == Kind::NON_VIRTUAL_METHOD || + kind == Kind::GET_ART_BY_NAME_METHOD); return m_method_from_type; } int method_id() const { - ASSERT(kind == Kind::VIRTUAL_METHOD || kind == Kind::NON_VIRTUAL_METHOD); + ASSERT(kind == Kind::VIRTUAL_METHOD || kind == Kind::NON_VIRTUAL_METHOD || + kind == Kind::GET_ART_BY_NAME_METHOD); return m_method_id; } diff --git a/game/CMakeLists.txt b/game/CMakeLists.txt index 908a5d5e72..273dfb095f 100644 --- a/game/CMakeLists.txt +++ b/game/CMakeLists.txt @@ -83,6 +83,7 @@ set(RUNTIME_SOURCE mips2c/jak1_functions/tie_methods.cpp mips2c/jak1_functions/time_of_day.cpp mips2c/jak2_functions/collide_func.cpp + mips2c/jak2_functions/joint.cpp overlord/dma.cpp overlord/fake_iso.cpp overlord/iso.cpp diff --git a/game/kernel/jak2/kscheme.cpp b/game/kernel/jak2/kscheme.cpp index 367fdf8481..8521ace527 100644 --- a/game/kernel/jak2/kscheme.cpp +++ b/game/kernel/jak2/kscheme.cpp @@ -1000,8 +1000,6 @@ u64 method_set(u32 type_, u32 method_id, u32 method) { method_id, sym_to_string(sym)->data()); printf("***********************************\n"); } - // todo remove once checked - printf("doing method set: %s %d\n", sym_to_string(sym)->data(), method_id); sym_value->get_method(method_id).offset = method; } } @@ -1020,8 +1018,6 @@ u64 method_set(u32 type_, u32 method_id, u32 method) { method_id, sym_to_string(sym)->data()); printf("***********************************\n"); } - // todo remove once checked - printf("doing method set: %s %d\n", sym_to_string(sym)->data(), method_id); sym_value->get_method(method_id).offset = method; } } diff --git a/game/mips2c/jak2_functions/joint.cpp b/game/mips2c/jak2_functions/joint.cpp new file mode 100644 index 0000000000..c7dc8b1e8f --- /dev/null +++ b/game/mips2c/jak2_functions/joint.cpp @@ -0,0 +1,2543 @@ +//--------------------------MIPS2C--------------------- +#include "game/kernel/jak2/kscheme.h" +#include "game/mips2c/mips2c_private.h" +using namespace jak2; +// clang-format off + +namespace { +struct Cache { + void* clear_frame_accumulator; // clear-frame-accumulator + void* decompress_fixed_data_to_accumulator; // decompress-fixed-data-to-accumulator + void* decompress_frame_data_pair_to_accumulator; // decompress-frame-data-pair-to-accumulator + void* decompress_frame_data_to_accumulator; // decompress-frame-data-to-accumulator + void* normalize_frame_quaternions; // normalize-frame-quaternions + void* fake_scratchpad_data; // *fake-scratchpad-data* + +} cache; +} + +namespace Mips2C::jak2 { +namespace decompress_frame_data_pair_to_accumulator { +u64 execute(void* ctxt) { + auto* c = (ExecutionContext*)ctxt; + bool bc = false; + u32 next_block = 0; + while(true) { + switch(next_block) { + + case 0: + next_block = 1; + c->daddiu(sp, sp, -64); // daddiu sp, sp, -64 + c->sq(a0, 0, sp); // sq a0, 0(sp) + c->sq(t7, 16, sp); // sq t7, 16(sp) + c->sq(s0, 32, sp); // sq s0, 32(sp) + c->sq(s1, 48, sp); // sq s1, 48(sp) + c->mov128_vf_gpr(vf11, t0); // qmtc2.i vf11, t0 + c->daddu(a3, a3, a1); // daddu a3, a3, a1 + c->mov128_vf_gpr(vf13, a2); // qmtc2.i vf13, a2 + //c->lui(t2, 28672); // lui t2, 28672 + get_fake_spad_addr(t2, cache.fake_scratchpad_data, 0, c); + c->lw(t4, 0, a1); // lw t4, 0(a1) + c->daddiu(v1, a1, 16); // daddiu v1, a1, 16 + c->lw(t5, 4, a1); // lw t5, 4(a1) + c->daddu(s5, t1, r0); // daddu s5, t1, r0 + c->lw(t6, 8, a1); // lw t6, 8(a1) + c->daddu(t4, t4, v1); // daddu t4, t4, v1 + c->vsub_bc(DEST::w, BC::x, vf11, vf0, vf11); // vsubx.w vf11, vf0, vf11 + c->lw(t7, 0, a3); // lw t7, 0(a3) + c->vmul_bc(DEST::xyzw, BC::x, vf13, vf14, vf13); // vmulx.xyzw vf13, vf14, vf13 + c->daddiu(t2, t2, 1744); // daddiu t2, t2, 1744 // JAK 2 CHANGE + c->lw(s2, 56, t1); // lw s2, 56(t1) + c->daddu(t5, t5, v1); // daddu t5, t5, v1 + c->lw(s4, 60, t1); // lw s4, 60(t1) + c->daddu(t6, t6, v1); // daddu t6, t6, v1 + c->addiu(s3, r0, 8); // addiu s3, r0, 8 + c->daddiu(s5, s5, 4); // daddiu s5, s5, 4 + c->vmul_bc(DEST::xy, BC::w, vf13, vf13, vf11); // vmulw.xy vf13, vf13, vf11 + c->lw(s0, 4, a3); // lw s0, 4(a3) + c->vmul_bc(DEST::zw, BC::x, vf13, vf13, vf11); // vmulx.zw vf13, vf13, vf11 + c->lw(s1, 8, a3); // lw s1, 8(a3) + // nop // sll r0, r0, 0 + c->daddiu(v1, a3, 16); // daddiu v1, a3, 16 + c->daddu(t7, t7, v1); // daddu t7, t7, v1 + c->daddu(s0, s0, v1); // daddu s0, s0, v1 + c->daddu(s1, s1, v1); // daddu s1, s1, v1 + // nop // sll r0, r0, 0 + c->andi(t3, s4, 1); // andi t3, s4, 1 + // nop // sll r0, r0, 0 + bc = c->sgpr64(t3) == 0; // beq t3, r0, L10 + // nop // sll r0, r0, 0 + if (bc) {next_block = 2;} // branch non-likely + + break; + + case 1: + next_block = 2; + c->lqc2(vf1, 0, t4); // lqc2 vf1, 0(t4) + c->lqc2(vf2, 16, t4); // lqc2 vf2, 16(t4) + c->lqc2(vf3, 32, t4); // lqc2 vf3, 32(t4) + c->lqc2(vf4, 48, t4); // lqc2 vf4, 48(t4) + c->lqc2(vf5, 0, t7); // lqc2 vf5, 0(t7) + c->lqc2(vf6, 16, t7); // lqc2 vf6, 16(t7) + c->lqc2(vf7, 32, t7); // lqc2 vf7, 32(t7) + c->lqc2(vf8, 48, t7); // lqc2 vf8, 48(t7) + c->lqc2(vf9, 0, a0); // lqc2 vf9, 0(a0) + c->daddiu(t4, t4, 64); // daddiu t4, t4, 64 + c->lqc2(vf10, 16, a0); // lqc2 vf10, 16(a0) + c->daddiu(t7, t7, 64); // daddiu t7, t7, 64 + c->lqc2(vf11, 32, a0); // lqc2 vf11, 32(a0) + c->lqc2(vf12, 48, a0); // lqc2 vf12, 48(a0) + c->vmula_bc(DEST::xyzw, BC::w, vf9, vf0); // vmulaw.xyzw acc, vf9, vf0 + c->vmadda_bc(DEST::xyzw, BC::x, vf1, vf13); // vmaddax.xyzw acc, vf1, vf13 + c->vmadd_bc(DEST::xyzw, BC::w, vf9, vf5, vf13); // vmaddw.xyzw vf9, vf5, vf13 + c->vmula_bc(DEST::xyzw, BC::w, vf10, vf0); // vmulaw.xyzw acc, vf10, vf0 + c->vmadda_bc(DEST::xyzw, BC::x, vf2, vf13); // vmaddax.xyzw acc, vf2, vf13 + c->vmadd_bc(DEST::xyzw, BC::w, vf10, vf6, vf13); // vmaddw.xyzw vf10, vf6, vf13 + c->vmula_bc(DEST::xyzw, BC::w, vf11, vf0); // vmulaw.xyzw acc, vf11, vf0 + c->vmadda_bc(DEST::xyzw, BC::x, vf3, vf13); // vmaddax.xyzw acc, vf3, vf13 + c->vmadd_bc(DEST::xyzw, BC::w, vf11, vf7, vf13); // vmaddw.xyzw vf11, vf7, vf13 + c->vmula_bc(DEST::xyzw, BC::w, vf12, vf0); // vmulaw.xyzw acc, vf12, vf0 + c->vmadda_bc(DEST::xyzw, BC::x, vf4, vf13); // vmaddax.xyzw acc, vf4, vf13 + c->vmadd_bc(DEST::xyzw, BC::w, vf12, vf8, vf13); // vmaddw.xyzw vf12, vf8, vf13 + c->sqc2(vf9, 0, a0); // sqc2 vf9, 0(a0) + c->sqc2(vf10, 16, a0); // sqc2 vf10, 16(a0) + c->sqc2(vf11, 32, a0); // sqc2 vf11, 32(a0) + c->sqc2(vf12, 48, a0); // sqc2 vf12, 48(a0) + + case 2: + next_block = 3; + c->andi(t3, s4, 2); // andi t3, s4, 2 + c->daddiu(a0, a0, 64); // daddiu a0, a0, 64 + bc = c->sgpr64(t3) == 0; // beq t3, r0, L11 + // nop // sll r0, r0, 0 + if (bc) {next_block = 4;} // branch non-likely + + break; + + case 3: + next_block = 4; + c->lqc2(vf1, 0, t4); // lqc2 vf1, 0(t4) + c->lqc2(vf2, 16, t4); // lqc2 vf2, 16(t4) + c->lqc2(vf3, 32, t4); // lqc2 vf3, 32(t4) + c->lqc2(vf4, 48, t4); // lqc2 vf4, 48(t4) + c->lqc2(vf5, 0, t7); // lqc2 vf5, 0(t7) + c->lqc2(vf6, 16, t7); // lqc2 vf6, 16(t7) + c->lqc2(vf7, 32, t7); // lqc2 vf7, 32(t7) + c->lqc2(vf8, 48, t7); // lqc2 vf8, 48(t7) + c->lqc2(vf9, 0, a0); // lqc2 vf9, 0(a0) + c->daddiu(t4, t4, 64); // daddiu t4, t4, 64 + c->lqc2(vf10, 16, a0); // lqc2 vf10, 16(a0) + c->daddiu(t7, t7, 64); // daddiu t7, t7, 64 + c->lqc2(vf11, 32, a0); // lqc2 vf11, 32(a0) + c->lqc2(vf12, 48, a0); // lqc2 vf12, 48(a0) + c->vmula_bc(DEST::xyzw, BC::w, vf9, vf0); // vmulaw.xyzw acc, vf9, vf0 + c->vmadda_bc(DEST::xyzw, BC::x, vf1, vf13); // vmaddax.xyzw acc, vf1, vf13 + c->vmadd_bc(DEST::xyzw, BC::w, vf9, vf5, vf13); // vmaddw.xyzw vf9, vf5, vf13 + c->vmula_bc(DEST::xyzw, BC::w, vf10, vf0); // vmulaw.xyzw acc, vf10, vf0 + c->vmadda_bc(DEST::xyzw, BC::x, vf2, vf13); // vmaddax.xyzw acc, vf2, vf13 + c->vmadd_bc(DEST::xyzw, BC::w, vf10, vf6, vf13); // vmaddw.xyzw vf10, vf6, vf13 + c->vmula_bc(DEST::xyzw, BC::w, vf11, vf0); // vmulaw.xyzw acc, vf11, vf0 + c->vmadda_bc(DEST::xyzw, BC::x, vf3, vf13); // vmaddax.xyzw acc, vf3, vf13 + c->vmadd_bc(DEST::xyzw, BC::w, vf11, vf7, vf13); // vmaddw.xyzw vf11, vf7, vf13 + c->vmula_bc(DEST::xyzw, BC::w, vf12, vf0); // vmulaw.xyzw acc, vf12, vf0 + c->vmadda_bc(DEST::xyzw, BC::x, vf4, vf13); // vmaddax.xyzw acc, vf4, vf13 + c->vmadd_bc(DEST::xyzw, BC::w, vf12, vf8, vf13); // vmaddw.xyzw vf12, vf8, vf13 + c->sqc2(vf9, 0, a0); // sqc2 vf9, 0(a0) + c->sqc2(vf10, 16, a0); // sqc2 vf10, 16(a0) + c->sqc2(vf11, 32, a0); // sqc2 vf11, 32(a0) + c->sqc2(vf12, 48, a0); // sqc2 vf12, 48(a0) + + case 4: + next_block = 5; + c->lw(s4, -4, s5); // lw s4, -4(s5) + c->daddiu(a0, a0, 64); // daddiu a0, a0, 64 + + case 5: + next_block = 6; + c->andi(t3, s4, 15); // andi t3, s4, 15 + c->sra(s4, s4, 4); // sra s4, s4, 4 + c->sll(t3, t3, 2); // sll t3, t3, 2 + c->daddiu(s3, s3, -1); // daddiu s3, s3, -1 + c->daddu(t3, t3, t2); // daddu t3, t3, t2 + c->daddiu(s2, s2, -1); // daddiu s2, s2, -1 + c->lw(t3, 0, t3); // lw t3, 0(t3) + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + next_block = 0x4d7666d9 ^ c->gprs[t3].du32[0]; // jr t3 + ASSERT(next_block < 33); + break; + // nop // sll r0, r0, 0 + + case 6: + next_block = 7; + bc = c->sgpr64(s2) == 0; // beq s2, r0, L20 + c->daddiu(a0, a0, 48); // daddiu a0, a0, 48 + if (bc) {next_block = 32;} // branch non-likely + + break; + + case 7: + next_block = 8; + bc = c->sgpr64(s3) != 0; // bne s3, r0, L12 + // nop // sll r0, r0, 0 + if (bc) {next_block = 5;} // branch non-likely + + break; + + case 8: + next_block = 9; + c->lw(s4, 0, s5); // lw s4, 0(s5) + c->daddiu(s5, s5, 4); // daddiu s5, s5, 4 + //beq r0, r0, L12 // beq r0, r0, L12 + c->addiu(s3, r0, 8); // addiu s3, r0, 8 + next_block = 5; // branch always + + break; + + case 9: + next_block = 10; + c->lw(s6, 0, t5); // lw s6, 0(t5) + c->daddiu(t5, t5, 4); // daddiu t5, t5, 4 + c->lh(gp, 0, t6); // lh gp, 0(t6) + c->daddiu(t6, t6, 2); // daddiu t6, t6, 2 + c->lqc2(vf3, 0, a0); // lqc2 vf3, 0(a0) + c->pextlw(s6, gp, s6); // pextlw s6, gp, s6 + c->pextlh(s6, s6, r0); // pextlh s6, s6, r0 + c->psraw(s6, s6, 16); // psraw s6, s6, 16 + c->mov128_vf_gpr(vf1, s6); // qmtc2.i vf1, s6 + c->lw(s6, 0, s0); // lw s6, 0(s0) + c->daddiu(s0, s0, 4); // daddiu s0, s0, 4 + c->lh(gp, 0, s1); // lh gp, 0(s1) + c->daddiu(s1, s1, 2); // daddiu s1, s1, 2 + c->pextlw(s6, gp, s6); // pextlw s6, gp, s6 + c->pextlh(s6, s6, r0); // pextlh s6, s6, r0 + c->psraw(s6, s6, 16); // psraw s6, s6, 16 + c->mov128_vf_gpr(vf2, s6); // qmtc2.i vf2, s6 + c->vitof0(DEST::xyzw, vf1, vf1); // vitof0.xyzw vf1, vf1 + c->vitof0(DEST::xyzw, vf2, vf2); // vitof0.xyzw vf2, vf2 + c->vmula_bc(DEST::xyzw, BC::w, vf3, vf0); // vmulaw.xyzw acc, vf3, vf0 + c->vmadda_bc(DEST::xyzw, BC::y, vf1, vf13); // vmadday.xyzw acc, vf1, vf13 + c->vmadd_bc(DEST::xyzw, BC::z, vf3, vf2, vf13); // vmaddz.xyzw vf3, vf2, vf13 + c->sqc2(vf3, 0, a0); // sqc2 vf3, 0(a0) + //beq r0, r0, L13 // beq r0, r0, L13 + // nop // sll r0, r0, 0 + next_block = 6; // branch always + + break; + + case 10: + next_block = 11; + c->ld(s6, 0, t4); // ld s6, 0(t4) + c->daddiu(t4, t4, 8); // daddiu t4, t4, 8 + c->lw(gp, 0, t5); // lw gp, 0(t5) + c->daddiu(t5, t5, 4); // daddiu t5, t5, 4 + c->lqc2(vf3, 0, a0); // lqc2 vf3, 0(a0) + c->pcpyld(s6, gp, s6); // pcpyld s6, gp, s6 + c->mov128_vf_gpr(vf1, s6); // qmtc2.i vf1, s6 + c->ld(s6, 0, t7); // ld s6, 0(t7) + c->daddiu(t7, t7, 8); // daddiu t7, t7, 8 + c->lw(gp, 0, s0); // lw gp, 0(s0) + c->daddiu(s0, s0, 4); // daddiu s0, s0, 4 + c->pcpyld(s6, gp, s6); // pcpyld s6, gp, s6 + c->mov128_vf_gpr(vf2, s6); // qmtc2.i vf2, s6 + c->vmula_bc(DEST::xyzw, BC::w, vf3, vf0); // vmulaw.xyzw acc, vf3, vf0 + c->vmadda_bc(DEST::xyzw, BC::x, vf1, vf13); // vmaddax.xyzw acc, vf1, vf13 + c->vmadd_bc(DEST::xyzw, BC::w, vf3, vf2, vf13); // vmaddw.xyzw vf3, vf2, vf13 + c->sqc2(vf3, 0, a0); // sqc2 vf3, 0(a0) + //beq r0, r0, L13 // beq r0, r0, L13 + // nop // sll r0, r0, 0 + next_block = 6; // branch always + + break; + + case 11: + next_block = 12; + c->ld(t9, 0, t4); // ld t9, 0(t4) + c->daddiu(t4, t4, 8); // daddiu t4, t4, 8 + c->lqc2(vf6, 16, a0); // lqc2 vf6, 16(a0) + c->pextlh(t9, t9, r0); // pextlh t9, t9, r0 + c->psraw(t9, t9, 16); // psraw t9, t9, 16 + c->mov128_vf_gpr(vf4, t9); // qmtc2.i vf4, t9 + c->ld(t9, 0, t7); // ld t9, 0(t7) + c->daddiu(t7, t7, 8); // daddiu t7, t7, 8 + c->pextlh(t9, t9, r0); // pextlh t9, t9, r0 + c->psraw(t9, t9, 16); // psraw t9, t9, 16 + c->mov128_vf_gpr(vf5, t9); // qmtc2.i vf5, t9 + c->vitof15(DEST::xyzw, vf4, vf4); // vitof15.xyzw vf4, vf4 + c->vitof15(DEST::xyzw, vf5, vf5); // vitof15.xyzw vf5, vf5 + c->vmula_bc(DEST::xyzw, BC::x, vf4, vf13); // vmulax.xyzw acc, vf4, vf13 + c->vmadd_bc(DEST::xyzw, BC::w, vf4, vf5, vf13); // vmaddw.xyzw vf4, vf5, vf13 + c->vmul(DEST::xyzw, vf10, vf4, vf6); // vmul.xyzw vf10, vf4, vf6 + c->vmula_bc(DEST::xyzw, BC::w, vf10, vf0); // vmulaw.xyzw acc, vf10, vf0 + c->vmadda_bc(DEST::xyzw, BC::z, vf0, vf10); // vmaddaz.xyzw acc, vf0, vf10 + c->vmadda_bc(DEST::xyzw, BC::y, vf0, vf10); // vmadday.xyzw acc, vf0, vf10 + c->vmadd_bc(DEST::xyzw, BC::x, vf10, vf0, vf10); // vmaddx.xyzw vf10, vf0, vf10 + c->mov128_gpr_vf(t9, vf10); // qmfc2.i t9, vf10 + c->pcpyud(t9, t9, r0); // pcpyud t9, t9, r0 + if (((s64)c->sgpr64(t9)) < 0) { // bltzl t9, L14 + c->vsub(DEST::xyzw, vf4, vf15, vf4); // vsub.xyzw vf4, vf15, vf4 + next_block = 13; + break; + } + + case 13: + next_block = 14; + c->vadd(DEST::xyzw, vf6, vf6, vf4); // vadd.xyzw vf6, vf6, vf4 + c->sqc2(vf6, 16, a0); // sqc2 vf6, 16(a0) + //beq r0, r0, L13 // beq r0, r0, L13 + // nop // sll r0, r0, 0 + next_block = 6; // branch always + + break; + + case 14: + next_block = 15; + c->ld(t9, 0, t4); // ld t9, 0(t4) + c->daddiu(t4, t4, 8); // daddiu t4, t4, 8 + c->lqc2(vf6, 16, a0); // lqc2 vf6, 16(a0) + c->pextlh(t9, t9, r0); // pextlh t9, t9, r0 + c->psraw(t9, t9, 16); // psraw t9, t9, 16 + c->mov128_vf_gpr(vf4, t9); // qmtc2.i vf4, t9 + c->ld(t9, 0, t7); // ld t9, 0(t7) + c->daddiu(t7, t7, 8); // daddiu t7, t7, 8 + c->pextlh(t9, t9, r0); // pextlh t9, t9, r0 + c->psraw(t9, t9, 16); // psraw t9, t9, 16 + c->mov128_vf_gpr(vf5, t9); // qmtc2.i vf5, t9 + c->vitof15(DEST::xyzw, vf4, vf4); // vitof15.xyzw vf4, vf4 + c->lw(s6, 0, t5); // lw s6, 0(t5) + c->daddiu(t5, t5, 4); // daddiu t5, t5, 4 + c->lh(gp, 0, t6); // lh gp, 0(t6) + c->daddiu(t6, t6, 2); // daddiu t6, t6, 2 + c->vitof15(DEST::xyzw, vf5, vf5); // vitof15.xyzw vf5, vf5 + c->lqc2(vf3, 0, a0); // lqc2 vf3, 0(a0) + c->pextlw(s6, gp, s6); // pextlw s6, gp, s6 + c->vmula_bc(DEST::xyzw, BC::x, vf4, vf13); // vmulax.xyzw acc, vf4, vf13 + c->vmadd_bc(DEST::xyzw, BC::w, vf4, vf5, vf13); // vmaddw.xyzw vf4, vf5, vf13 + c->pextlh(s6, s6, r0); // pextlh s6, s6, r0 + c->psraw(s6, s6, 16); // psraw s6, s6, 16 + c->mov128_vf_gpr(vf1, s6); // qmtc2.i vf1, s6 + c->vmul(DEST::xyzw, vf10, vf4, vf6); // vmul.xyzw vf10, vf4, vf6 + c->lw(s6, 0, s0); // lw s6, 0(s0) + c->daddiu(s0, s0, 4); // daddiu s0, s0, 4 + c->lh(gp, 0, s1); // lh gp, 0(s1) + c->daddiu(s1, s1, 2); // daddiu s1, s1, 2 + c->vmula_bc(DEST::xyzw, BC::w, vf10, vf0); // vmulaw.xyzw acc, vf10, vf0 + c->vmadda_bc(DEST::xyzw, BC::z, vf0, vf10); // vmaddaz.xyzw acc, vf0, vf10 + c->vmadda_bc(DEST::xyzw, BC::y, vf0, vf10); // vmadday.xyzw acc, vf0, vf10 + c->vmadd_bc(DEST::xyzw, BC::x, vf10, vf0, vf10); // vmaddx.xyzw vf10, vf0, vf10 + c->pextlw(s6, gp, s6); // pextlw s6, gp, s6 + c->pextlh(s6, s6, r0); // pextlh s6, s6, r0 + c->psraw(s6, s6, 16); // psraw s6, s6, 16 + c->mov128_gpr_vf(t9, vf10); // qmfc2.i t9, vf10 + c->mov128_vf_gpr(vf2, s6); // qmtc2.i vf2, s6 + c->vitof0(DEST::xyzw, vf1, vf1); // vitof0.xyzw vf1, vf1 + c->pcpyud(t9, t9, r0); // pcpyud t9, t9, r0 + if (((s64)c->sgpr64(t9)) < 0) { // bltzl t9, L15 + c->vsub(DEST::xyzw, vf4, vf15, vf4); // vsub.xyzw vf4, vf15, vf4 + next_block = 16; + break; + } + + case 16: + next_block = 17; + c->vitof0(DEST::xyzw, vf2, vf2); // vitof0.xyzw vf2, vf2 + c->vadd(DEST::xyzw, vf6, vf6, vf4); // vadd.xyzw vf6, vf6, vf4 + c->vmula_bc(DEST::xyzw, BC::w, vf3, vf0); // vmulaw.xyzw acc, vf3, vf0 + c->vmadda_bc(DEST::xyzw, BC::y, vf1, vf13); // vmadday.xyzw acc, vf1, vf13 + c->vmadd_bc(DEST::xyzw, BC::z, vf3, vf2, vf13); // vmaddz.xyzw vf3, vf2, vf13 + c->sqc2(vf6, 16, a0); // sqc2 vf6, 16(a0) + c->sqc2(vf3, 0, a0); // sqc2 vf3, 0(a0) + //beq r0, r0, L13 // beq r0, r0, L13 + // nop // sll r0, r0, 0 + next_block = 6; // branch always + + break; + + case 17: + next_block = 18; + c->ld(t9, 8, t4); // ld t9, 8(t4) + c->daddiu(t4, t4, 8); // daddiu t4, t4, 8 + c->lqc2(vf6, 16, a0); // lqc2 vf6, 16(a0) + c->pextlh(t9, t9, r0); // pextlh t9, t9, r0 + c->psraw(t9, t9, 16); // psraw t9, t9, 16 + c->mov128_vf_gpr(vf4, t9); // qmtc2.i vf4, t9 + c->ld(t9, 8, t7); // ld t9, 8(t7) + c->daddiu(t7, t7, 8); // daddiu t7, t7, 8 + c->pextlh(t9, t9, r0); // pextlh t9, t9, r0 + c->psraw(t9, t9, 16); // psraw t9, t9, 16 + c->mov128_vf_gpr(vf5, t9); // qmtc2.i vf5, t9 + c->vitof15(DEST::xyzw, vf4, vf4); // vitof15.xyzw vf4, vf4 + c->ld(s6, -8, t4); // ld s6, -8(t4) + c->daddiu(t4, t4, 8); // daddiu t4, t4, 8 + c->lw(gp, 0, t5); // lw gp, 0(t5) + c->daddiu(t5, t5, 4); // daddiu t5, t5, 4 + c->vitof15(DEST::xyzw, vf5, vf5); // vitof15.xyzw vf5, vf5 + c->lqc2(vf3, 0, a0); // lqc2 vf3, 0(a0) + c->pcpyld(s6, gp, s6); // pcpyld s6, gp, s6 + c->vmula_bc(DEST::xyzw, BC::x, vf4, vf13); // vmulax.xyzw acc, vf4, vf13 + c->vmadd_bc(DEST::xyzw, BC::w, vf4, vf5, vf13); // vmaddw.xyzw vf4, vf5, vf13 + c->mov128_vf_gpr(vf1, s6); // qmtc2.i vf1, s6 + c->vmul(DEST::xyzw, vf10, vf4, vf6); // vmul.xyzw vf10, vf4, vf6 + c->ld(s6, -8, t7); // ld s6, -8(t7) + c->daddiu(t7, t7, 8); // daddiu t7, t7, 8 + c->lw(gp, 0, s0); // lw gp, 0(s0) + c->daddiu(s0, s0, 4); // daddiu s0, s0, 4 + c->vmula_bc(DEST::xyzw, BC::w, vf10, vf0); // vmulaw.xyzw acc, vf10, vf0 + c->vmadda_bc(DEST::xyzw, BC::z, vf0, vf10); // vmaddaz.xyzw acc, vf0, vf10 + c->vmadda_bc(DEST::xyzw, BC::y, vf0, vf10); // vmadday.xyzw acc, vf0, vf10 + c->vmadd_bc(DEST::xyzw, BC::x, vf10, vf0, vf10); // vmaddx.xyzw vf10, vf0, vf10 + c->pcpyld(s6, gp, s6); // pcpyld s6, gp, s6 + c->mov128_gpr_vf(t9, vf10); // qmfc2.i t9, vf10 + c->mov128_vf_gpr(vf2, s6); // qmtc2.i vf2, s6 + c->pcpyud(t9, t9, r0); // pcpyud t9, t9, r0 + if (((s64)c->sgpr64(t9)) < 0) { // bltzl t9, L16 + c->vsub(DEST::xyzw, vf4, vf15, vf4); // vsub.xyzw vf4, vf15, vf4 + next_block = 19; + break; + } + + case 19: + next_block = 20; + c->vadd(DEST::xyzw, vf6, vf6, vf4); // vadd.xyzw vf6, vf6, vf4 + c->vmula_bc(DEST::xyzw, BC::w, vf3, vf0); // vmulaw.xyzw acc, vf3, vf0 + c->vmadda_bc(DEST::xyzw, BC::x, vf1, vf13); // vmaddax.xyzw acc, vf1, vf13 + c->vmadd_bc(DEST::xyzw, BC::w, vf3, vf2, vf13); // vmaddw.xyzw vf3, vf2, vf13 + c->sqc2(vf6, 16, a0); // sqc2 vf6, 16(a0) + c->sqc2(vf3, 0, a0); // sqc2 vf3, 0(a0) + //beq r0, r0, L13 // beq r0, r0, L13 + // nop // sll r0, r0, 0 + next_block = 6; // branch always + + break; + + case 20: + next_block = 21; + c->lw(t8, 0, t5); // lw t8, 0(t5) + c->daddiu(t5, t5, 4); // daddiu t5, t5, 4 + c->lh(fp, 0, t6); // lh fp, 0(t6) + c->daddiu(t6, t6, 2); // daddiu t6, t6, 2 + c->lqc2(vf9, 32, a0); // lqc2 vf9, 32(a0) + c->pextlw(t8, fp, t8); // pextlw t8, fp, t8 + c->pextlh(t8, t8, r0); // pextlh t8, t8, r0 + c->psraw(t8, t8, 16); // psraw t8, t8, 16 + c->mov128_vf_gpr(vf7, t8); // qmtc2.i vf7, t8 + c->lw(t8, 0, s0); // lw t8, 0(s0) + c->daddiu(s0, s0, 4); // daddiu s0, s0, 4 + c->lh(fp, 0, s1); // lh fp, 0(s1) + c->daddiu(s1, s1, 2); // daddiu s1, s1, 2 + c->pextlw(t8, fp, t8); // pextlw t8, fp, t8 + c->pextlh(t8, t8, r0); // pextlh t8, t8, r0 + c->psraw(t8, t8, 16); // psraw t8, t8, 16 + c->mov128_vf_gpr(vf8, t8); // qmtc2.i vf8, t8 + c->vitof12(DEST::xyzw, vf7, vf7); // vitof12.xyzw vf7, vf7 + c->vitof12(DEST::xyzw, vf8, vf8); // vitof12.xyzw vf8, vf8 + c->vmula_bc(DEST::xyzw, BC::w, vf9, vf0); // vmulaw.xyzw acc, vf9, vf0 + c->vmadda_bc(DEST::xyzw, BC::x, vf7, vf13); // vmaddax.xyzw acc, vf7, vf13 + c->vmadd_bc(DEST::xyzw, BC::w, vf9, vf8, vf13); // vmaddw.xyzw vf9, vf8, vf13 + c->sqc2(vf9, 32, a0); // sqc2 vf9, 32(a0) + //beq r0, r0, L13 // beq r0, r0, L13 + // nop // sll r0, r0, 0 + next_block = 6; // branch always + + break; + + case 21: + next_block = 22; + c->lw(s6, 0, t5); // lw s6, 0(t5) + c->daddiu(t5, t5, 4); // daddiu t5, t5, 4 + c->lh(gp, 0, t6); // lh gp, 0(t6) + c->daddiu(t6, t6, 2); // daddiu t6, t6, 2 + c->lqc2(vf3, 0, a0); // lqc2 vf3, 0(a0) + c->pextlw(s6, gp, s6); // pextlw s6, gp, s6 + c->pextlh(s6, s6, r0); // pextlh s6, s6, r0 + c->psraw(s6, s6, 16); // psraw s6, s6, 16 + c->mov128_vf_gpr(vf1, s6); // qmtc2.i vf1, s6 + c->lw(s6, 0, s0); // lw s6, 0(s0) + c->daddiu(s0, s0, 4); // daddiu s0, s0, 4 + c->lh(gp, 0, s1); // lh gp, 0(s1) + c->daddiu(s1, s1, 2); // daddiu s1, s1, 2 + c->pextlw(s6, gp, s6); // pextlw s6, gp, s6 + c->pextlh(s6, s6, r0); // pextlh s6, s6, r0 + c->psraw(s6, s6, 16); // psraw s6, s6, 16 + c->mov128_vf_gpr(vf2, s6); // qmtc2.i vf2, s6 + c->lw(t8, 0, t5); // lw t8, 0(t5) + c->daddiu(t5, t5, 4); // daddiu t5, t5, 4 + c->lh(fp, 0, t6); // lh fp, 0(t6) + c->daddiu(t6, t6, 2); // daddiu t6, t6, 2 + c->vitof0(DEST::xyzw, vf1, vf1); // vitof0.xyzw vf1, vf1 + c->vitof0(DEST::xyzw, vf2, vf2); // vitof0.xyzw vf2, vf2 + c->lqc2(vf9, 32, a0); // lqc2 vf9, 32(a0) + c->pextlw(t8, fp, t8); // pextlw t8, fp, t8 + c->vmula_bc(DEST::xyzw, BC::w, vf3, vf0); // vmulaw.xyzw acc, vf3, vf0 + c->vmadda_bc(DEST::xyzw, BC::y, vf1, vf13); // vmadday.xyzw acc, vf1, vf13 + c->vmadd_bc(DEST::xyzw, BC::z, vf3, vf2, vf13); // vmaddz.xyzw vf3, vf2, vf13 + c->pextlh(t8, t8, r0); // pextlh t8, t8, r0 + c->psraw(t8, t8, 16); // psraw t8, t8, 16 + c->mov128_vf_gpr(vf7, t8); // qmtc2.i vf7, t8 + c->lw(t8, 0, s0); // lw t8, 0(s0) + c->daddiu(s0, s0, 4); // daddiu s0, s0, 4 + c->lh(fp, 0, s1); // lh fp, 0(s1) + c->daddiu(s1, s1, 2); // daddiu s1, s1, 2 + c->pextlw(t8, fp, t8); // pextlw t8, fp, t8 + c->pextlh(t8, t8, r0); // pextlh t8, t8, r0 + c->psraw(t8, t8, 16); // psraw t8, t8, 16 + c->mov128_vf_gpr(vf8, t8); // qmtc2.i vf8, t8 + c->vitof12(DEST::xyzw, vf7, vf7); // vitof12.xyzw vf7, vf7 + c->vitof12(DEST::xyzw, vf8, vf8); // vitof12.xyzw vf8, vf8 + c->vmula_bc(DEST::xyzw, BC::w, vf9, vf0); // vmulaw.xyzw acc, vf9, vf0 + c->vmadda_bc(DEST::xyzw, BC::x, vf7, vf13); // vmaddax.xyzw acc, vf7, vf13 + c->vmadd_bc(DEST::xyzw, BC::w, vf9, vf8, vf13); // vmaddw.xyzw vf9, vf8, vf13 + c->sqc2(vf3, 0, a0); // sqc2 vf3, 0(a0) + c->sqc2(vf9, 32, a0); // sqc2 vf9, 32(a0) + //beq r0, r0, L13 // beq r0, r0, L13 + // nop // sll r0, r0, 0 + next_block = 6; // branch always + + break; + + case 22: + next_block = 23; + c->ld(s6, 0, t4); // ld s6, 0(t4) + c->daddiu(t4, t4, 8); // daddiu t4, t4, 8 + c->lw(gp, 0, t5); // lw gp, 0(t5) + c->daddiu(t5, t5, 4); // daddiu t5, t5, 4 + c->lqc2(vf3, 0, a0); // lqc2 vf3, 0(a0) + c->pcpyld(s6, gp, s6); // pcpyld s6, gp, s6 + c->mov128_vf_gpr(vf1, s6); // qmtc2.i vf1, s6 + c->ld(s6, 0, t7); // ld s6, 0(t7) + c->daddiu(t7, t7, 8); // daddiu t7, t7, 8 + c->lw(gp, 0, s0); // lw gp, 0(s0) + c->daddiu(s0, s0, 4); // daddiu s0, s0, 4 + c->pcpyld(s6, gp, s6); // pcpyld s6, gp, s6 + c->mov128_vf_gpr(vf2, s6); // qmtc2.i vf2, s6 + c->lw(t8, 0, t5); // lw t8, 0(t5) + c->daddiu(t5, t5, 4); // daddiu t5, t5, 4 + c->lh(fp, 0, t6); // lh fp, 0(t6) + c->daddiu(t6, t6, 2); // daddiu t6, t6, 2 + c->lqc2(vf9, 32, a0); // lqc2 vf9, 32(a0) + c->pextlw(t8, fp, t8); // pextlw t8, fp, t8 + c->vmula_bc(DEST::xyzw, BC::w, vf3, vf0); // vmulaw.xyzw acc, vf3, vf0 + c->vmadda_bc(DEST::xyzw, BC::x, vf1, vf13); // vmaddax.xyzw acc, vf1, vf13 + c->vmadd_bc(DEST::xyzw, BC::w, vf3, vf2, vf13); // vmaddw.xyzw vf3, vf2, vf13 + c->pextlh(t8, t8, r0); // pextlh t8, t8, r0 + c->psraw(t8, t8, 16); // psraw t8, t8, 16 + c->mov128_vf_gpr(vf7, t8); // qmtc2.i vf7, t8 + c->lw(t8, 0, s0); // lw t8, 0(s0) + c->daddiu(s0, s0, 4); // daddiu s0, s0, 4 + c->lh(fp, 0, s1); // lh fp, 0(s1) + c->daddiu(s1, s1, 2); // daddiu s1, s1, 2 + c->pextlw(t8, fp, t8); // pextlw t8, fp, t8 + c->pextlh(t8, t8, r0); // pextlh t8, t8, r0 + c->psraw(t8, t8, 16); // psraw t8, t8, 16 + c->mov128_vf_gpr(vf8, t8); // qmtc2.i vf8, t8 + c->vitof12(DEST::xyzw, vf7, vf7); // vitof12.xyzw vf7, vf7 + c->vitof12(DEST::xyzw, vf8, vf8); // vitof12.xyzw vf8, vf8 + c->vmula_bc(DEST::xyzw, BC::w, vf9, vf0); // vmulaw.xyzw acc, vf9, vf0 + c->vmadda_bc(DEST::xyzw, BC::x, vf7, vf13); // vmaddax.xyzw acc, vf7, vf13 + c->vmadd_bc(DEST::xyzw, BC::w, vf9, vf8, vf13); // vmaddw.xyzw vf9, vf8, vf13 + c->sqc2(vf3, 0, a0); // sqc2 vf3, 0(a0) + c->sqc2(vf9, 32, a0); // sqc2 vf9, 32(a0) + //beq r0, r0, L13 // beq r0, r0, L13 + // nop // sll r0, r0, 0 + next_block = 6; // branch always + + break; + + case 23: + next_block = 24; + c->ld(t9, 0, t4); // ld t9, 0(t4) + c->daddiu(t4, t4, 8); // daddiu t4, t4, 8 + c->lqc2(vf6, 16, a0); // lqc2 vf6, 16(a0) + c->pextlh(t9, t9, r0); // pextlh t9, t9, r0 + c->psraw(t9, t9, 16); // psraw t9, t9, 16 + c->mov128_vf_gpr(vf4, t9); // qmtc2.i vf4, t9 + c->ld(t9, 0, t7); // ld t9, 0(t7) + c->daddiu(t7, t7, 8); // daddiu t7, t7, 8 + c->pextlh(t9, t9, r0); // pextlh t9, t9, r0 + c->psraw(t9, t9, 16); // psraw t9, t9, 16 + c->mov128_vf_gpr(vf5, t9); // qmtc2.i vf5, t9 + c->vitof15(DEST::xyzw, vf4, vf4); // vitof15.xyzw vf4, vf4 + c->lw(t8, 0, t5); // lw t8, 0(t5) + c->daddiu(t5, t5, 4); // daddiu t5, t5, 4 + c->lh(fp, 0, t6); // lh fp, 0(t6) + c->daddiu(t6, t6, 2); // daddiu t6, t6, 2 + c->vitof15(DEST::xyzw, vf5, vf5); // vitof15.xyzw vf5, vf5 + c->lqc2(vf9, 32, a0); // lqc2 vf9, 32(a0) + c->pextlw(t8, fp, t8); // pextlw t8, fp, t8 + c->vmula_bc(DEST::xyzw, BC::x, vf4, vf13); // vmulax.xyzw acc, vf4, vf13 + c->vmadd_bc(DEST::xyzw, BC::w, vf4, vf5, vf13); // vmaddw.xyzw vf4, vf5, vf13 + c->pextlh(t8, t8, r0); // pextlh t8, t8, r0 + c->psraw(t8, t8, 16); // psraw t8, t8, 16 + c->mov128_vf_gpr(vf7, t8); // qmtc2.i vf7, t8 + c->vmul(DEST::xyzw, vf10, vf4, vf6); // vmul.xyzw vf10, vf4, vf6 + c->lw(t8, 0, s0); // lw t8, 0(s0) + c->daddiu(s0, s0, 4); // daddiu s0, s0, 4 + c->lh(fp, 0, s1); // lh fp, 0(s1) + c->daddiu(s1, s1, 2); // daddiu s1, s1, 2 + c->pextlw(t8, fp, t8); // pextlw t8, fp, t8 + c->vmula_bc(DEST::xyzw, BC::w, vf10, vf0); // vmulaw.xyzw acc, vf10, vf0 + c->vmadda_bc(DEST::xyzw, BC::z, vf0, vf10); // vmaddaz.xyzw acc, vf0, vf10 + c->vmadda_bc(DEST::xyzw, BC::y, vf0, vf10); // vmadday.xyzw acc, vf0, vf10 + c->vmadd_bc(DEST::xyzw, BC::x, vf10, vf0, vf10); // vmaddx.xyzw vf10, vf0, vf10 + c->pextlh(t8, t8, r0); // pextlh t8, t8, r0 + c->psraw(t8, t8, 16); // psraw t8, t8, 16 + c->mov128_vf_gpr(vf8, t8); // qmtc2.i vf8, t8 + c->mov128_gpr_vf(t9, vf10); // qmfc2.i t9, vf10 + c->vitof12(DEST::xyzw, vf7, vf7); // vitof12.xyzw vf7, vf7 + c->vitof12(DEST::xyzw, vf8, vf8); // vitof12.xyzw vf8, vf8 + c->pcpyud(t9, t9, r0); // pcpyud t9, t9, r0 + if (((s64)c->sgpr64(t9)) < 0) { // bltzl t9, L17 + c->vsub(DEST::xyzw, vf4, vf15, vf4); // vsub.xyzw vf4, vf15, vf4 + next_block = 25; + break; + } + + case 25: + next_block = 26; + c->vmula_bc(DEST::xyzw, BC::w, vf9, vf0); // vmulaw.xyzw acc, vf9, vf0 + c->vmadda_bc(DEST::xyzw, BC::x, vf7, vf13); // vmaddax.xyzw acc, vf7, vf13 + c->vmadd_bc(DEST::xyzw, BC::w, vf9, vf8, vf13); // vmaddw.xyzw vf9, vf8, vf13 + c->vadd(DEST::xyzw, vf6, vf6, vf4); // vadd.xyzw vf6, vf6, vf4 + c->sqc2(vf6, 16, a0); // sqc2 vf6, 16(a0) + c->sqc2(vf9, 32, a0); // sqc2 vf9, 32(a0) + //beq r0, r0, L13 // beq r0, r0, L13 + // nop // sll r0, r0, 0 + next_block = 6; // branch always + + break; + + case 26: + next_block = 27; + c->ld(t9, 0, t4); // ld t9, 0(t4) + c->daddiu(t4, t4, 8); // daddiu t4, t4, 8 + c->lqc2(vf6, 16, a0); // lqc2 vf6, 16(a0) + c->pextlh(t9, t9, r0); // pextlh t9, t9, r0 + c->psraw(t9, t9, 16); // psraw t9, t9, 16 + c->mov128_vf_gpr(vf4, t9); // qmtc2.i vf4, t9 + c->ld(t9, 0, t7); // ld t9, 0(t7) + c->daddiu(t7, t7, 8); // daddiu t7, t7, 8 + c->pextlh(t9, t9, r0); // pextlh t9, t9, r0 + c->psraw(t9, t9, 16); // psraw t9, t9, 16 + c->mov128_vf_gpr(vf5, t9); // qmtc2.i vf5, t9 + c->lw(s6, 0, t5); // lw s6, 0(t5) + c->daddiu(t5, t5, 4); // daddiu t5, t5, 4 + c->lh(gp, 0, t6); // lh gp, 0(t6) + c->daddiu(t6, t6, 2); // daddiu t6, t6, 2 + c->vitof15(DEST::xyzw, vf4, vf4); // vitof15.xyzw vf4, vf4 + c->vitof15(DEST::xyzw, vf5, vf5); // vitof15.xyzw vf5, vf5 + c->lqc2(vf3, 0, a0); // lqc2 vf3, 0(a0) + c->pextlw(s6, gp, s6); // pextlw s6, gp, s6 + c->vmula_bc(DEST::xyzw, BC::x, vf4, vf13); // vmulax.xyzw acc, vf4, vf13 + c->vmadd_bc(DEST::xyzw, BC::w, vf4, vf5, vf13); // vmaddw.xyzw vf4, vf5, vf13 + c->pextlh(s6, s6, r0); // pextlh s6, s6, r0 + c->psraw(s6, s6, 16); // psraw s6, s6, 16 + c->mov128_vf_gpr(vf1, s6); // qmtc2.i vf1, s6 + c->vmul(DEST::xyzw, vf10, vf4, vf6); // vmul.xyzw vf10, vf4, vf6 + c->lw(s6, 0, s0); // lw s6, 0(s0) + c->daddiu(s0, s0, 4); // daddiu s0, s0, 4 + c->lh(gp, 0, s1); // lh gp, 0(s1) + c->daddiu(s1, s1, 2); // daddiu s1, s1, 2 + c->pextlw(s6, gp, s6); // pextlw s6, gp, s6 + c->vmula_bc(DEST::xyzw, BC::w, vf10, vf0); // vmulaw.xyzw acc, vf10, vf0 + c->vmadda_bc(DEST::xyzw, BC::z, vf0, vf10); // vmaddaz.xyzw acc, vf0, vf10 + c->vmadda_bc(DEST::xyzw, BC::y, vf0, vf10); // vmadday.xyzw acc, vf0, vf10 + c->vmadd_bc(DEST::xyzw, BC::x, vf10, vf0, vf10); // vmaddx.xyzw vf10, vf0, vf10 + c->pextlh(s6, s6, r0); // pextlh s6, s6, r0 + c->psraw(s6, s6, 16); // psraw s6, s6, 16 + c->mov128_vf_gpr(vf2, s6); // qmtc2.i vf2, s6 + c->mov128_gpr_vf(t9, vf10); // qmfc2.i t9, vf10 + c->vitof0(DEST::xyzw, vf1, vf1); // vitof0.xyzw vf1, vf1 + c->lw(t8, 0, t5); // lw t8, 0(t5) + c->daddiu(t5, t5, 4); // daddiu t5, t5, 4 + c->lh(fp, 0, t6); // lh fp, 0(t6) + c->daddiu(t6, t6, 2); // daddiu t6, t6, 2 + c->pcpyud(t9, t9, r0); // pcpyud t9, t9, r0 + if (((s64)c->sgpr64(t9)) < 0) { // bltzl t9, L18 + c->vsub(DEST::xyzw, vf4, vf15, vf4); // vsub.xyzw vf4, vf15, vf4 + next_block = 28; + break; + } + + case 28: + next_block = 29; + c->vitof0(DEST::xyzw, vf2, vf2); // vitof0.xyzw vf2, vf2 + c->vmula_bc(DEST::xyzw, BC::w, vf3, vf0); // vmulaw.xyzw acc, vf3, vf0 + c->vmadda_bc(DEST::xyzw, BC::y, vf1, vf13); // vmadday.xyzw acc, vf1, vf13 + c->vmadd_bc(DEST::xyzw, BC::z, vf3, vf2, vf13); // vmaddz.xyzw vf3, vf2, vf13 + c->vadd(DEST::xyzw, vf6, vf6, vf4); // vadd.xyzw vf6, vf6, vf4 + c->lqc2(vf9, 32, a0); // lqc2 vf9, 32(a0) + c->pextlw(t8, fp, t8); // pextlw t8, fp, t8 + c->pextlh(t8, t8, r0); // pextlh t8, t8, r0 + c->psraw(t8, t8, 16); // psraw t8, t8, 16 + c->mov128_vf_gpr(vf7, t8); // qmtc2.i vf7, t8 + c->lw(t8, 0, s0); // lw t8, 0(s0) + c->daddiu(s0, s0, 4); // daddiu s0, s0, 4 + c->lh(fp, 0, s1); // lh fp, 0(s1) + c->daddiu(s1, s1, 2); // daddiu s1, s1, 2 + c->pextlw(t8, fp, t8); // pextlw t8, fp, t8 + c->pextlh(t8, t8, r0); // pextlh t8, t8, r0 + c->psraw(t8, t8, 16); // psraw t8, t8, 16 + c->mov128_vf_gpr(vf8, t8); // qmtc2.i vf8, t8 + c->vitof12(DEST::xyzw, vf7, vf7); // vitof12.xyzw vf7, vf7 + c->vitof12(DEST::xyzw, vf8, vf8); // vitof12.xyzw vf8, vf8 + c->vmula_bc(DEST::xyzw, BC::w, vf9, vf0); // vmulaw.xyzw acc, vf9, vf0 + c->vmadda_bc(DEST::xyzw, BC::x, vf7, vf13); // vmaddax.xyzw acc, vf7, vf13 + c->vmadd_bc(DEST::xyzw, BC::w, vf9, vf8, vf13); // vmaddw.xyzw vf9, vf8, vf13 + c->sqc2(vf3, 0, a0); // sqc2 vf3, 0(a0) + c->sqc2(vf6, 16, a0); // sqc2 vf6, 16(a0) + c->sqc2(vf9, 32, a0); // sqc2 vf9, 32(a0) + //beq r0, r0, L13 // beq r0, r0, L13 + // nop // sll r0, r0, 0 + next_block = 6; // branch always + + break; + + case 29: + next_block = 30; + c->ld(t9, 8, t4); // ld t9, 8(t4) + c->daddiu(t4, t4, 8); // daddiu t4, t4, 8 + c->lqc2(vf6, 16, a0); // lqc2 vf6, 16(a0) + c->pextlh(t9, t9, r0); // pextlh t9, t9, r0 + c->psraw(t9, t9, 16); // psraw t9, t9, 16 + c->mov128_vf_gpr(vf4, t9); // qmtc2.i vf4, t9 + c->ld(t9, 8, t7); // ld t9, 8(t7) + c->daddiu(t7, t7, 8); // daddiu t7, t7, 8 + c->pextlh(t9, t9, r0); // pextlh t9, t9, r0 + c->psraw(t9, t9, 16); // psraw t9, t9, 16 + c->mov128_vf_gpr(vf5, t9); // qmtc2.i vf5, t9 + c->ld(s6, -8, t4); // ld s6, -8(t4) + c->daddiu(t4, t4, 8); // daddiu t4, t4, 8 + c->lw(gp, 0, t5); // lw gp, 0(t5) + c->daddiu(t5, t5, 4); // daddiu t5, t5, 4 + c->vitof15(DEST::xyzw, vf4, vf4); // vitof15.xyzw vf4, vf4 + c->vitof15(DEST::xyzw, vf5, vf5); // vitof15.xyzw vf5, vf5 + c->lqc2(vf3, 0, a0); // lqc2 vf3, 0(a0) + c->pcpyld(s6, gp, s6); // pcpyld s6, gp, s6 + c->vmula_bc(DEST::xyzw, BC::x, vf4, vf13); // vmulax.xyzw acc, vf4, vf13 + c->vmadd_bc(DEST::xyzw, BC::w, vf4, vf5, vf13); // vmaddw.xyzw vf4, vf5, vf13 + c->mov128_vf_gpr(vf1, s6); // qmtc2.i vf1, s6 + c->vmul(DEST::xyzw, vf10, vf4, vf6); // vmul.xyzw vf10, vf4, vf6 + c->ld(s6, -8, t7); // ld s6, -8(t7) + c->daddiu(t7, t7, 8); // daddiu t7, t7, 8 + c->lw(gp, 0, s0); // lw gp, 0(s0) + c->daddiu(s0, s0, 4); // daddiu s0, s0, 4 + c->pcpyld(s6, gp, s6); // pcpyld s6, gp, s6 + c->vmula_bc(DEST::xyzw, BC::w, vf10, vf0); // vmulaw.xyzw acc, vf10, vf0 + c->vmadda_bc(DEST::xyzw, BC::z, vf0, vf10); // vmaddaz.xyzw acc, vf0, vf10 + c->vmadda_bc(DEST::xyzw, BC::y, vf0, vf10); // vmadday.xyzw acc, vf0, vf10 + c->vmadd_bc(DEST::xyzw, BC::x, vf10, vf0, vf10); // vmaddx.xyzw vf10, vf0, vf10 + c->mov128_vf_gpr(vf2, s6); // qmtc2.i vf2, s6 + c->mov128_gpr_vf(t9, vf10); // qmfc2.i t9, vf10 + c->lw(t8, 0, t5); // lw t8, 0(t5) + c->daddiu(t5, t5, 4); // daddiu t5, t5, 4 + c->lh(fp, 0, t6); // lh fp, 0(t6) + c->daddiu(t6, t6, 2); // daddiu t6, t6, 2 + c->pcpyud(t9, t9, r0); // pcpyud t9, t9, r0 + if (((s64)c->sgpr64(t9)) < 0) { // bltzl t9, L19 + c->vsub(DEST::xyzw, vf4, vf15, vf4); // vsub.xyzw vf4, vf15, vf4 + next_block = 31; + break; + } + + case 31: + next_block = 32; + c->vmula_bc(DEST::xyzw, BC::w, vf3, vf0); // vmulaw.xyzw acc, vf3, vf0 + c->vmadda_bc(DEST::xyzw, BC::x, vf1, vf13); // vmaddax.xyzw acc, vf1, vf13 + c->vmadd_bc(DEST::xyzw, BC::w, vf3, vf2, vf13); // vmaddw.xyzw vf3, vf2, vf13 + c->vadd(DEST::xyzw, vf6, vf6, vf4); // vadd.xyzw vf6, vf6, vf4 + c->lqc2(vf9, 32, a0); // lqc2 vf9, 32(a0) + c->pextlw(t8, fp, t8); // pextlw t8, fp, t8 + c->pextlh(t8, t8, r0); // pextlh t8, t8, r0 + c->psraw(t8, t8, 16); // psraw t8, t8, 16 + c->mov128_vf_gpr(vf7, t8); // qmtc2.i vf7, t8 + c->lw(t8, 0, s0); // lw t8, 0(s0) + c->daddiu(s0, s0, 4); // daddiu s0, s0, 4 + c->lh(fp, 0, s1); // lh fp, 0(s1) + c->daddiu(s1, s1, 2); // daddiu s1, s1, 2 + c->pextlw(t8, fp, t8); // pextlw t8, fp, t8 + c->pextlh(t8, t8, r0); // pextlh t8, t8, r0 + c->psraw(t8, t8, 16); // psraw t8, t8, 16 + c->mov128_vf_gpr(vf8, t8); // qmtc2.i vf8, t8 + c->vitof12(DEST::xyzw, vf7, vf7); // vitof12.xyzw vf7, vf7 + c->vitof12(DEST::xyzw, vf8, vf8); // vitof12.xyzw vf8, vf8 + c->vmula_bc(DEST::xyzw, BC::w, vf9, vf0); // vmulaw.xyzw acc, vf9, vf0 + c->vmadda_bc(DEST::xyzw, BC::x, vf7, vf13); // vmaddax.xyzw acc, vf7, vf13 + c->vmadd_bc(DEST::xyzw, BC::w, vf9, vf8, vf13); // vmaddw.xyzw vf9, vf8, vf13 + c->sqc2(vf3, 0, a0); // sqc2 vf3, 0(a0) + c->sqc2(vf6, 16, a0); // sqc2 vf6, 16(a0) + c->sqc2(vf9, 32, a0); // sqc2 vf9, 32(a0) + //beq r0, r0, L13 // beq r0, r0, L13 + // nop // sll r0, r0, 0 + next_block = 6; // branch always + + break; + + case 32: + next_block = 33; + c->lq(a0, 0, sp); // lq a0, 0(sp) + c->lq(t7, 16, sp); // lq t7, 16(sp) + c->lq(s0, 32, sp); // lq s0, 32(sp) + c->lq(s1, 48, sp); // lq s1, 48(sp) + //jr ra // jr ra + c->daddiu(sp, sp, 64); // daddiu sp, sp, 64 + goto end_of_function; // return + + //jr ra // jr ra + c->daddu(sp, sp, r0); // daddu sp, sp, r0 + goto end_of_function; // return + + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + } + } + end_of_function: + return c->gprs[v0].du64[0]; +} + +u32 jump_table_vals[16] = { + 0x4d7666df, // = 6 ^ 1299605209 + 0x4d7666d0, // = 9 ^ 1299605209 + 0x4d7666d2, // = 11 ^ 1299605209 + 0x4d7666d7, // = 14 ^ 1299605209 + 0x4d7666cd, // = 20 ^ 1299605209 + 0x4d7666cc, // = 21 ^ 1299605209 + 0x4d7666ce, // = 23 ^ 1299605209 + 0x4d7666c3, // = 26 ^ 1299605209 + 0x4d7666df, // = 6 ^ 1299605209 + 0x4d7666d3, // = 10 ^ 1299605209 + 0x4d7666d2, // = 11 ^ 1299605209 + 0x4d7666c8, // = 17 ^ 1299605209 + 0x4d7666cd, // = 20 ^ 1299605209 + 0x4d7666cf, // = 22 ^ 1299605209 + 0x4d7666ce, // = 23 ^ 1299605209 + 0x4d7666c4, // = 29 ^ 1299605209 +}; + +} // namespace decompress_frame_data_pair_to_accumulator +} // namespace Mips2C + +//--------------------------MIPS2C--------------------- +#include "game/mips2c/mips2c_private.h" + +namespace Mips2C::jak2 { +namespace decompress_frame_data_to_accumulator { +u64 execute(void* ctxt) { + auto* c = (ExecutionContext*)ctxt; + bool bc = false; + u32 next_block = 0; + while(true) { + switch(next_block) { + + case 0: + next_block = 1; + c->daddiu(sp, sp, -16); // daddiu sp, sp, -16 + c->mov128_vf_gpr(vf13, a2); // qmtc2.i vf13, a2 + c->sq(a0, 0, sp); // sq a0, 0(sp) + //c->lui(t2, 28672); // lui t2, 28672 + get_fake_spad_addr(t2, cache.fake_scratchpad_data, 0, c); + c->lw(t4, 0, a1); // lw t4, 0(a1) + c->daddiu(v1, a1, 16); // daddiu v1, a1, 16 + c->lw(t5, 4, a1); // lw t5, 4(a1) + c->daddu(s5, t1, r0); // daddu s5, t1, r0 + c->lw(t6, 8, a1); // lw t6, 8(a1) + c->daddu(t4, t4, v1); // daddu t4, t4, v1 + c->vmul_bc(DEST::xyzw, BC::x, vf13, vf14, vf13); // vmulx.xyzw vf13, vf14, vf13 + c->daddiu(t2, t2, 1680); // daddiu t2, t2, 1680 JAK 2 CHANGE + c->lw(s2, 56, t1); // lw s2, 56(t1) + c->daddu(t5, t5, v1); // daddu t5, t5, v1 + c->lw(s4, 60, t1); // lw s4, 60(t1) + c->daddu(t6, t6, v1); // daddu t6, t6, v1 + c->addiu(s3, r0, 8); // addiu s3, r0, 8 + c->daddiu(s5, s5, 4); // daddiu s5, s5, 4 + c->andi(t3, s4, 1); // andi t3, s4, 1 + // nop // sll r0, r0, 0 + bc = c->sgpr64(t3) == 0; // beq t3, r0, L22 + // nop // sll r0, r0, 0 + if (bc) {next_block = 2;} // branch non-likely + + break; + + case 1: + next_block = 2; + c->lqc2(vf1, 0, t4); // lqc2 vf1, 0(t4) + c->lqc2(vf2, 16, t4); // lqc2 vf2, 16(t4) + c->lqc2(vf3, 32, t4); // lqc2 vf3, 32(t4) + c->lqc2(vf4, 48, t4); // lqc2 vf4, 48(t4) + c->lqc2(vf9, 0, a0); // lqc2 vf9, 0(a0) + c->daddiu(t4, t4, 64); // daddiu t4, t4, 64 + c->lqc2(vf10, 16, a0); // lqc2 vf10, 16(a0) + // nop // sll r0, r0, 0 + c->lqc2(vf11, 32, a0); // lqc2 vf11, 32(a0) + c->lqc2(vf12, 48, a0); // lqc2 vf12, 48(a0) + c->vmula_bc(DEST::xyzw, BC::w, vf9, vf0); // vmulaw.xyzw acc, vf9, vf0 + c->vmadd_bc(DEST::xyzw, BC::x, vf9, vf1, vf13); // vmaddx.xyzw vf9, vf1, vf13 + c->vmula_bc(DEST::xyzw, BC::w, vf10, vf0); // vmulaw.xyzw acc, vf10, vf0 + c->vmadd_bc(DEST::xyzw, BC::x, vf10, vf2, vf13); // vmaddx.xyzw vf10, vf2, vf13 + c->vmula_bc(DEST::xyzw, BC::w, vf11, vf0); // vmulaw.xyzw acc, vf11, vf0 + c->vmadd_bc(DEST::xyzw, BC::x, vf11, vf3, vf13); // vmaddx.xyzw vf11, vf3, vf13 + c->vmula_bc(DEST::xyzw, BC::w, vf12, vf0); // vmulaw.xyzw acc, vf12, vf0 + c->vmadd_bc(DEST::xyzw, BC::x, vf12, vf4, vf13); // vmaddx.xyzw vf12, vf4, vf13 + c->sqc2(vf9, 0, a0); // sqc2 vf9, 0(a0) + c->sqc2(vf10, 16, a0); // sqc2 vf10, 16(a0) + c->sqc2(vf11, 32, a0); // sqc2 vf11, 32(a0) + c->sqc2(vf12, 48, a0); // sqc2 vf12, 48(a0) + + case 2: + next_block = 3; + c->andi(t3, s4, 2); // andi t3, s4, 2 + c->daddiu(a0, a0, 64); // daddiu a0, a0, 64 + bc = c->sgpr64(t3) == 0; // beq t3, r0, L23 + // nop // sll r0, r0, 0 + if (bc) {next_block = 4;} // branch non-likely + + break; + + case 3: + next_block = 4; + c->lqc2(vf1, 0, t4); // lqc2 vf1, 0(t4) + c->lqc2(vf2, 16, t4); // lqc2 vf2, 16(t4) + c->lqc2(vf3, 32, t4); // lqc2 vf3, 32(t4) + c->lqc2(vf4, 48, t4); // lqc2 vf4, 48(t4) + c->lqc2(vf9, 0, a0); // lqc2 vf9, 0(a0) + c->daddiu(t4, t4, 64); // daddiu t4, t4, 64 + c->lqc2(vf10, 16, a0); // lqc2 vf10, 16(a0) + // nop // sll r0, r0, 0 + c->lqc2(vf11, 32, a0); // lqc2 vf11, 32(a0) + c->lqc2(vf12, 48, a0); // lqc2 vf12, 48(a0) + c->vmula_bc(DEST::xyzw, BC::w, vf9, vf0); // vmulaw.xyzw acc, vf9, vf0 + c->vmadd_bc(DEST::xyzw, BC::x, vf9, vf1, vf13); // vmaddx.xyzw vf9, vf1, vf13 + c->vmula_bc(DEST::xyzw, BC::w, vf10, vf0); // vmulaw.xyzw acc, vf10, vf0 + c->vmadd_bc(DEST::xyzw, BC::x, vf10, vf2, vf13); // vmaddx.xyzw vf10, vf2, vf13 + c->vmula_bc(DEST::xyzw, BC::w, vf11, vf0); // vmulaw.xyzw acc, vf11, vf0 + c->vmadd_bc(DEST::xyzw, BC::x, vf11, vf3, vf13); // vmaddx.xyzw vf11, vf3, vf13 + c->vmula_bc(DEST::xyzw, BC::w, vf12, vf0); // vmulaw.xyzw acc, vf12, vf0 + c->vmadd_bc(DEST::xyzw, BC::x, vf12, vf4, vf13); // vmaddx.xyzw vf12, vf4, vf13 + c->sqc2(vf9, 0, a0); // sqc2 vf9, 0(a0) + c->sqc2(vf10, 16, a0); // sqc2 vf10, 16(a0) + c->sqc2(vf11, 32, a0); // sqc2 vf11, 32(a0) + c->sqc2(vf12, 48, a0); // sqc2 vf12, 48(a0) + + case 4: + next_block = 5; + c->lw(s4, -4, s5); // lw s4, -4(s5) + c->daddiu(a0, a0, 64); // daddiu a0, a0, 64 + + case 5: + next_block = 6; + c->andi(t3, s4, 15); // andi t3, s4, 15 + c->sra(s4, s4, 4); // sra s4, s4, 4 + c->sll(t3, t3, 2); // sll t3, t3, 2 + c->daddiu(s3, s3, -1); // daddiu s3, s3, -1 + c->daddu(t3, t3, t2); // daddu t3, t3, t2 + c->daddiu(s2, s2, -1); // daddiu s2, s2, -1 + c->lw(t3, 0, t3); // lw t3, 0(t3) + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + next_block = 0x7b2191d ^ c->gprs[t3].du32[0]; // jr t3 + ASSERT(next_block < 33); + break; + // nop // sll r0, r0, 0 + + case 6: + next_block = 7; + bc = c->sgpr64(s2) == 0; // beq s2, r0, L32 + c->daddiu(a0, a0, 48); // daddiu a0, a0, 48 + if (bc) {next_block = 32;} // branch non-likely + + break; + + case 7: + next_block = 8; + bc = c->sgpr64(s3) != 0; // bne s3, r0, L24 + // nop // sll r0, r0, 0 + if (bc) {next_block = 5;} // branch non-likely + + break; + + case 8: + next_block = 9; + c->lw(s4, 0, s5); // lw s4, 0(s5) + c->daddiu(s5, s5, 4); // daddiu s5, s5, 4 + //beq r0, r0, L24 // beq r0, r0, L24 + c->addiu(s3, r0, 8); // addiu s3, r0, 8 + next_block = 5; // branch always + + break; + + case 9: + next_block = 10; + c->lw(s6, 0, t5); // lw s6, 0(t5) + c->daddiu(t5, t5, 4); // daddiu t5, t5, 4 + c->lh(gp, 0, t6); // lh gp, 0(t6) + c->daddiu(t6, t6, 2); // daddiu t6, t6, 2 + c->lqc2(vf3, 0, a0); // lqc2 vf3, 0(a0) + c->pextlw(s6, gp, s6); // pextlw s6, gp, s6 + c->pextlh(s6, s6, r0); // pextlh s6, s6, r0 + c->psraw(s6, s6, 16); // psraw s6, s6, 16 + c->mov128_vf_gpr(vf1, s6); // qmtc2.i vf1, s6 + c->vitof0(DEST::xyzw, vf1, vf1); // vitof0.xyzw vf1, vf1 + c->vmula_bc(DEST::xyzw, BC::w, vf3, vf0); // vmulaw.xyzw acc, vf3, vf0 + c->vmadd_bc(DEST::xyzw, BC::y, vf3, vf1, vf13); // vmaddy.xyzw vf3, vf1, vf13 + c->sqc2(vf3, 0, a0); // sqc2 vf3, 0(a0) + //beq r0, r0, L25 // beq r0, r0, L25 + // nop // sll r0, r0, 0 + next_block = 6; // branch always + + break; + + case 10: + next_block = 11; + c->ld(s6, 0, t4); // ld s6, 0(t4) + c->daddiu(t4, t4, 8); // daddiu t4, t4, 8 + c->lw(gp, 0, t5); // lw gp, 0(t5) + c->daddiu(t5, t5, 4); // daddiu t5, t5, 4 + c->lqc2(vf3, 0, a0); // lqc2 vf3, 0(a0) + c->pcpyld(s6, gp, s6); // pcpyld s6, gp, s6 + c->mov128_vf_gpr(vf1, s6); // qmtc2.i vf1, s6 + c->vmula_bc(DEST::xyzw, BC::w, vf3, vf0); // vmulaw.xyzw acc, vf3, vf0 + c->vmadd_bc(DEST::xyzw, BC::x, vf3, vf1, vf13); // vmaddx.xyzw vf3, vf1, vf13 + c->sqc2(vf3, 0, a0); // sqc2 vf3, 0(a0) + //beq r0, r0, L25 // beq r0, r0, L25 + // nop // sll r0, r0, 0 + next_block = 6; // branch always + + break; + + case 11: + next_block = 12; + c->ld(t9, 0, t4); // ld t9, 0(t4) + c->daddiu(t4, t4, 8); // daddiu t4, t4, 8 + c->lqc2(vf6, 16, a0); // lqc2 vf6, 16(a0) + c->pextlh(t9, t9, r0); // pextlh t9, t9, r0 + c->psraw(t9, t9, 16); // psraw t9, t9, 16 + c->mov128_vf_gpr(vf4, t9); // qmtc2.i vf4, t9 + c->vitof15(DEST::xyzw, vf4, vf4); // vitof15.xyzw vf4, vf4 + c->vmul(DEST::xyzw, vf10, vf4, vf6); // vmul.xyzw vf10, vf4, vf6 + c->vmula_bc(DEST::xyzw, BC::w, vf10, vf0); // vmulaw.xyzw acc, vf10, vf0 + c->vmadda_bc(DEST::xyzw, BC::z, vf0, vf10); // vmaddaz.xyzw acc, vf0, vf10 + c->vmadda_bc(DEST::xyzw, BC::y, vf0, vf10); // vmadday.xyzw acc, vf0, vf10 + c->vmadd_bc(DEST::xyzw, BC::x, vf10, vf0, vf10); // vmaddx.xyzw vf10, vf0, vf10 + c->mov128_gpr_vf(t9, vf10); // qmfc2.i t9, vf10 + c->pcpyud(t9, t9, r0); // pcpyud t9, t9, r0 + if (((s64)c->sgpr64(t9)) < 0) { // bltzl t9, L26 + c->vsub(DEST::xyzw, vf4, vf15, vf4); // vsub.xyzw vf4, vf15, vf4 + next_block = 13; + break; + } + + case 13: + next_block = 14; + c->vmula_bc(DEST::xyzw, BC::w, vf6, vf0); // vmulaw.xyzw acc, vf6, vf0 + c->vmadd_bc(DEST::xyzw, BC::x, vf6, vf4, vf13); // vmaddx.xyzw vf6, vf4, vf13 + c->sqc2(vf6, 16, a0); // sqc2 vf6, 16(a0) + //beq r0, r0, L25 // beq r0, r0, L25 + // nop // sll r0, r0, 0 + next_block = 6; // branch always + + break; + + case 14: + next_block = 15; + c->ld(t9, 0, t4); // ld t9, 0(t4) + c->daddiu(t4, t4, 8); // daddiu t4, t4, 8 + c->lqc2(vf6, 16, a0); // lqc2 vf6, 16(a0) + c->pextlh(t9, t9, r0); // pextlh t9, t9, r0 + c->psraw(t9, t9, 16); // psraw t9, t9, 16 + c->mov128_vf_gpr(vf4, t9); // qmtc2.i vf4, t9 + c->lw(s6, 0, t5); // lw s6, 0(t5) + c->daddiu(t5, t5, 4); // daddiu t5, t5, 4 + c->lh(gp, 0, t6); // lh gp, 0(t6) + c->daddiu(t6, t6, 2); // daddiu t6, t6, 2 + c->lqc2(vf3, 0, a0); // lqc2 vf3, 0(a0) + c->vitof15(DEST::xyzw, vf4, vf4); // vitof15.xyzw vf4, vf4 + c->pextlw(s6, gp, s6); // pextlw s6, gp, s6 + c->pextlh(s6, s6, r0); // pextlh s6, s6, r0 + c->psraw(s6, s6, 16); // psraw s6, s6, 16 + c->vmul(DEST::xyzw, vf10, vf4, vf6); // vmul.xyzw vf10, vf4, vf6 + c->mov128_vf_gpr(vf1, s6); // qmtc2.i vf1, s6 + c->vmula_bc(DEST::xyzw, BC::w, vf10, vf0); // vmulaw.xyzw acc, vf10, vf0 + c->vitof0(DEST::xyzw, vf1, vf1); // vitof0.xyzw vf1, vf1 + c->vmadda_bc(DEST::xyzw, BC::z, vf0, vf10); // vmaddaz.xyzw acc, vf0, vf10 + c->vmadda_bc(DEST::xyzw, BC::y, vf0, vf10); // vmadday.xyzw acc, vf0, vf10 + c->vmadd_bc(DEST::xyzw, BC::x, vf10, vf0, vf10); // vmaddx.xyzw vf10, vf0, vf10 + c->vmula_bc(DEST::xyzw, BC::w, vf3, vf0); // vmulaw.xyzw acc, vf3, vf0 + c->vmadd_bc(DEST::xyzw, BC::y, vf3, vf1, vf13); // vmaddy.xyzw vf3, vf1, vf13 + c->mov128_gpr_vf(t9, vf10); // qmfc2.i t9, vf10 + c->pcpyud(t9, t9, r0); // pcpyud t9, t9, r0 + if (((s64)c->sgpr64(t9)) < 0) { // bltzl t9, L27 + c->vsub(DEST::xyzw, vf4, vf15, vf4); // vsub.xyzw vf4, vf15, vf4 + next_block = 16; + break; + } + + case 16: + next_block = 17; + c->vmula_bc(DEST::xyzw, BC::w, vf6, vf0); // vmulaw.xyzw acc, vf6, vf0 + c->vmadd_bc(DEST::xyzw, BC::x, vf6, vf4, vf13); // vmaddx.xyzw vf6, vf4, vf13 + c->sqc2(vf3, 0, a0); // sqc2 vf3, 0(a0) + c->sqc2(vf6, 16, a0); // sqc2 vf6, 16(a0) + //beq r0, r0, L25 // beq r0, r0, L25 + // nop // sll r0, r0, 0 + next_block = 6; // branch always + + break; + + case 17: + next_block = 18; + c->ld(t9, 8, t4); // ld t9, 8(t4) + c->daddiu(t4, t4, 8); // daddiu t4, t4, 8 + c->lqc2(vf6, 16, a0); // lqc2 vf6, 16(a0) + c->pextlh(t9, t9, r0); // pextlh t9, t9, r0 + c->psraw(t9, t9, 16); // psraw t9, t9, 16 + c->mov128_vf_gpr(vf4, t9); // qmtc2.i vf4, t9 + c->ld(s6, -8, t4); // ld s6, -8(t4) + c->daddiu(t4, t4, 8); // daddiu t4, t4, 8 + c->lw(gp, 0, t5); // lw gp, 0(t5) + c->daddiu(t5, t5, 4); // daddiu t5, t5, 4 + c->lqc2(vf3, 0, a0); // lqc2 vf3, 0(a0) + c->vitof15(DEST::xyzw, vf4, vf4); // vitof15.xyzw vf4, vf4 + c->pcpyld(s6, gp, s6); // pcpyld s6, gp, s6 + c->vmul(DEST::xyzw, vf10, vf4, vf6); // vmul.xyzw vf10, vf4, vf6 + c->mov128_vf_gpr(vf1, s6); // qmtc2.i vf1, s6 + c->vmula_bc(DEST::xyzw, BC::w, vf10, vf0); // vmulaw.xyzw acc, vf10, vf0 + c->vmadda_bc(DEST::xyzw, BC::z, vf0, vf10); // vmaddaz.xyzw acc, vf0, vf10 + c->vmadda_bc(DEST::xyzw, BC::y, vf0, vf10); // vmadday.xyzw acc, vf0, vf10 + c->vmadd_bc(DEST::xyzw, BC::x, vf10, vf0, vf10); // vmaddx.xyzw vf10, vf0, vf10 + c->vmula_bc(DEST::xyzw, BC::w, vf3, vf0); // vmulaw.xyzw acc, vf3, vf0 + c->vmadd_bc(DEST::xyzw, BC::x, vf3, vf1, vf13); // vmaddx.xyzw vf3, vf1, vf13 + c->mov128_gpr_vf(t9, vf10); // qmfc2.i t9, vf10 + c->pcpyud(t9, t9, r0); // pcpyud t9, t9, r0 + if (((s64)c->sgpr64(t9)) < 0) { // bltzl t9, L28 + c->vsub(DEST::xyzw, vf4, vf15, vf4); // vsub.xyzw vf4, vf15, vf4 + next_block = 19; + break; + } + + case 19: + next_block = 20; + c->vmula_bc(DEST::xyzw, BC::w, vf6, vf0); // vmulaw.xyzw acc, vf6, vf0 + c->vmadd_bc(DEST::xyzw, BC::x, vf6, vf4, vf13); // vmaddx.xyzw vf6, vf4, vf13 + c->sqc2(vf3, 0, a0); // sqc2 vf3, 0(a0) + c->sqc2(vf6, 16, a0); // sqc2 vf6, 16(a0) + //beq r0, r0, L25 // beq r0, r0, L25 + // nop // sll r0, r0, 0 + next_block = 6; // branch always + + break; + + case 20: + next_block = 21; + c->lw(t8, 0, t5); // lw t8, 0(t5) + c->daddiu(t5, t5, 4); // daddiu t5, t5, 4 + c->lh(fp, 0, t6); // lh fp, 0(t6) + c->daddiu(t6, t6, 2); // daddiu t6, t6, 2 + c->lqc2(vf9, 32, a0); // lqc2 vf9, 32(a0) + c->pextlw(t8, fp, t8); // pextlw t8, fp, t8 + c->pextlh(t8, t8, r0); // pextlh t8, t8, r0 + c->psraw(t8, t8, 16); // psraw t8, t8, 16 + c->mov128_vf_gpr(vf7, t8); // qmtc2.i vf7, t8 + c->vitof12(DEST::xyzw, vf7, vf7); // vitof12.xyzw vf7, vf7 + c->vmula_bc(DEST::xyzw, BC::w, vf9, vf0); // vmulaw.xyzw acc, vf9, vf0 + c->vmadd_bc(DEST::xyzw, BC::x, vf9, vf7, vf13); // vmaddx.xyzw vf9, vf7, vf13 + c->sqc2(vf9, 32, a0); // sqc2 vf9, 32(a0) + //beq r0, r0, L25 // beq r0, r0, L25 + // nop // sll r0, r0, 0 + next_block = 6; // branch always + + break; + + case 21: + next_block = 22; + c->lw(s6, 0, t5); // lw s6, 0(t5) + c->daddiu(t5, t5, 4); // daddiu t5, t5, 4 + c->lh(gp, 0, t6); // lh gp, 0(t6) + c->daddiu(t6, t6, 2); // daddiu t6, t6, 2 + c->lqc2(vf3, 0, a0); // lqc2 vf3, 0(a0) + c->pextlw(s6, gp, s6); // pextlw s6, gp, s6 + c->pextlh(s6, s6, r0); // pextlh s6, s6, r0 + c->psraw(s6, s6, 16); // psraw s6, s6, 16 + c->mov128_vf_gpr(vf1, s6); // qmtc2.i vf1, s6 + c->lw(t8, 0, t5); // lw t8, 0(t5) + c->daddiu(t5, t5, 4); // daddiu t5, t5, 4 + c->lh(fp, 0, t6); // lh fp, 0(t6) + c->daddiu(t6, t6, 2); // daddiu t6, t6, 2 + c->lqc2(vf9, 32, a0); // lqc2 vf9, 32(a0) + c->vitof0(DEST::xyzw, vf1, vf1); // vitof0.xyzw vf1, vf1 + c->pextlw(t8, fp, t8); // pextlw t8, fp, t8 + c->pextlh(t8, t8, r0); // pextlh t8, t8, r0 + c->psraw(t8, t8, 16); // psraw t8, t8, 16 + c->mov128_vf_gpr(vf7, t8); // qmtc2.i vf7, t8 + c->vmula_bc(DEST::xyzw, BC::w, vf3, vf0); // vmulaw.xyzw acc, vf3, vf0 + c->vmadd_bc(DEST::xyzw, BC::y, vf3, vf1, vf13); // vmaddy.xyzw vf3, vf1, vf13 + c->vitof12(DEST::xyzw, vf7, vf7); // vitof12.xyzw vf7, vf7 + c->vmula_bc(DEST::xyzw, BC::w, vf9, vf0); // vmulaw.xyzw acc, vf9, vf0 + c->vmadd_bc(DEST::xyzw, BC::x, vf9, vf7, vf13); // vmaddx.xyzw vf9, vf7, vf13 + c->sqc2(vf3, 0, a0); // sqc2 vf3, 0(a0) + c->sqc2(vf9, 32, a0); // sqc2 vf9, 32(a0) + //beq r0, r0, L25 // beq r0, r0, L25 + // nop // sll r0, r0, 0 + next_block = 6; // branch always + + break; + + case 22: + next_block = 23; + c->ld(s6, 0, t4); // ld s6, 0(t4) + c->daddiu(t4, t4, 8); // daddiu t4, t4, 8 + c->lw(gp, 0, t5); // lw gp, 0(t5) + c->daddiu(t5, t5, 4); // daddiu t5, t5, 4 + c->lqc2(vf3, 0, a0); // lqc2 vf3, 0(a0) + c->pcpyld(s6, gp, s6); // pcpyld s6, gp, s6 + c->mov128_vf_gpr(vf1, s6); // qmtc2.i vf1, s6 + c->lw(t8, 0, t5); // lw t8, 0(t5) + c->daddiu(t5, t5, 4); // daddiu t5, t5, 4 + c->lh(fp, 0, t6); // lh fp, 0(t6) + c->daddiu(t6, t6, 2); // daddiu t6, t6, 2 + c->lqc2(vf9, 32, a0); // lqc2 vf9, 32(a0) + c->pextlw(t8, fp, t8); // pextlw t8, fp, t8 + c->pextlh(t8, t8, r0); // pextlh t8, t8, r0 + c->psraw(t8, t8, 16); // psraw t8, t8, 16 + c->mov128_vf_gpr(vf7, t8); // qmtc2.i vf7, t8 + c->vmula_bc(DEST::xyzw, BC::w, vf3, vf0); // vmulaw.xyzw acc, vf3, vf0 + c->vmadd_bc(DEST::xyzw, BC::x, vf3, vf1, vf13); // vmaddx.xyzw vf3, vf1, vf13 + c->vitof12(DEST::xyzw, vf7, vf7); // vitof12.xyzw vf7, vf7 + c->vmula_bc(DEST::xyzw, BC::w, vf9, vf0); // vmulaw.xyzw acc, vf9, vf0 + c->vmadd_bc(DEST::xyzw, BC::x, vf9, vf7, vf13); // vmaddx.xyzw vf9, vf7, vf13 + c->sqc2(vf3, 0, a0); // sqc2 vf3, 0(a0) + c->sqc2(vf9, 32, a0); // sqc2 vf9, 32(a0) + //beq r0, r0, L25 // beq r0, r0, L25 + // nop // sll r0, r0, 0 + next_block = 6; // branch always + + break; + + case 23: + next_block = 24; + c->ld(t9, 0, t4); // ld t9, 0(t4) + c->daddiu(t4, t4, 8); // daddiu t4, t4, 8 + c->lqc2(vf6, 16, a0); // lqc2 vf6, 16(a0) + c->pextlh(t9, t9, r0); // pextlh t9, t9, r0 + c->psraw(t9, t9, 16); // psraw t9, t9, 16 + c->mov128_vf_gpr(vf4, t9); // qmtc2.i vf4, t9 + c->lw(t8, 0, t5); // lw t8, 0(t5) + c->daddiu(t5, t5, 4); // daddiu t5, t5, 4 + c->lh(fp, 0, t6); // lh fp, 0(t6) + c->daddiu(t6, t6, 2); // daddiu t6, t6, 2 + c->lqc2(vf9, 32, a0); // lqc2 vf9, 32(a0) + c->vitof15(DEST::xyzw, vf4, vf4); // vitof15.xyzw vf4, vf4 + c->pextlw(t8, fp, t8); // pextlw t8, fp, t8 + c->pextlh(t8, t8, r0); // pextlh t8, t8, r0 + c->psraw(t8, t8, 16); // psraw t8, t8, 16 + c->vmul(DEST::xyzw, vf10, vf4, vf6); // vmul.xyzw vf10, vf4, vf6 + c->mov128_vf_gpr(vf7, t8); // qmtc2.i vf7, t8 + c->vmula_bc(DEST::xyzw, BC::w, vf10, vf0); // vmulaw.xyzw acc, vf10, vf0 + c->vitof12(DEST::xyzw, vf7, vf7); // vitof12.xyzw vf7, vf7 + c->vmadda_bc(DEST::xyzw, BC::z, vf0, vf10); // vmaddaz.xyzw acc, vf0, vf10 + c->vmadda_bc(DEST::xyzw, BC::y, vf0, vf10); // vmadday.xyzw acc, vf0, vf10 + c->vmadd_bc(DEST::xyzw, BC::x, vf10, vf0, vf10); // vmaddx.xyzw vf10, vf0, vf10 + c->vmula_bc(DEST::xyzw, BC::w, vf9, vf0); // vmulaw.xyzw acc, vf9, vf0 + c->vmadd_bc(DEST::xyzw, BC::x, vf9, vf7, vf13); // vmaddx.xyzw vf9, vf7, vf13 + c->mov128_gpr_vf(t9, vf10); // qmfc2.i t9, vf10 + c->pcpyud(t9, t9, r0); // pcpyud t9, t9, r0 + if (((s64)c->sgpr64(t9)) < 0) { // bltzl t9, L29 + c->vsub(DEST::xyzw, vf4, vf15, vf4); // vsub.xyzw vf4, vf15, vf4 + next_block = 25; + break; + } + + case 25: + next_block = 26; + c->vmula_bc(DEST::xyzw, BC::w, vf6, vf0); // vmulaw.xyzw acc, vf6, vf0 + c->vmadd_bc(DEST::xyzw, BC::x, vf6, vf4, vf13); // vmaddx.xyzw vf6, vf4, vf13 + c->sqc2(vf6, 16, a0); // sqc2 vf6, 16(a0) + c->sqc2(vf9, 32, a0); // sqc2 vf9, 32(a0) + //beq r0, r0, L25 // beq r0, r0, L25 + // nop // sll r0, r0, 0 + next_block = 6; // branch always + + break; + + case 26: + next_block = 27; + c->ld(t9, 0, t4); // ld t9, 0(t4) + c->daddiu(t4, t4, 8); // daddiu t4, t4, 8 + c->lqc2(vf6, 16, a0); // lqc2 vf6, 16(a0) + c->pextlh(t9, t9, r0); // pextlh t9, t9, r0 + c->psraw(t9, t9, 16); // psraw t9, t9, 16 + c->mov128_vf_gpr(vf4, t9); // qmtc2.i vf4, t9 + c->lw(s6, 0, t5); // lw s6, 0(t5) + c->daddiu(t5, t5, 4); // daddiu t5, t5, 4 + c->lh(gp, 0, t6); // lh gp, 0(t6) + c->daddiu(t6, t6, 2); // daddiu t6, t6, 2 + c->lqc2(vf3, 0, a0); // lqc2 vf3, 0(a0) + c->vitof15(DEST::xyzw, vf4, vf4); // vitof15.xyzw vf4, vf4 + c->pextlw(s6, gp, s6); // pextlw s6, gp, s6 + c->pextlh(s6, s6, r0); // pextlh s6, s6, r0 + c->psraw(s6, s6, 16); // psraw s6, s6, 16 + c->vmul(DEST::xyzw, vf10, vf4, vf6); // vmul.xyzw vf10, vf4, vf6 + c->mov128_vf_gpr(vf1, s6); // qmtc2.i vf1, s6 + c->lw(t8, 0, t5); // lw t8, 0(t5) + c->daddiu(t5, t5, 4); // daddiu t5, t5, 4 + c->lh(fp, 0, t6); // lh fp, 0(t6) + c->daddiu(t6, t6, 2); // daddiu t6, t6, 2 + c->vmula_bc(DEST::xyzw, BC::w, vf10, vf0); // vmulaw.xyzw acc, vf10, vf0 + c->vmadda_bc(DEST::xyzw, BC::z, vf0, vf10); // vmaddaz.xyzw acc, vf0, vf10 + c->vmadda_bc(DEST::xyzw, BC::y, vf0, vf10); // vmadday.xyzw acc, vf0, vf10 + c->vmadd_bc(DEST::xyzw, BC::x, vf10, vf0, vf10); // vmaddx.xyzw vf10, vf0, vf10 + c->vitof0(DEST::xyzw, vf1, vf1); // vitof0.xyzw vf1, vf1 + c->lqc2(vf9, 32, a0); // lqc2 vf9, 32(a0) + c->pextlw(t8, fp, t8); // pextlw t8, fp, t8 + c->mov128_gpr_vf(t9, vf10); // qmfc2.i t9, vf10 + c->pextlh(t8, t8, r0); // pextlh t8, t8, r0 + c->psraw(t8, t8, 16); // psraw t8, t8, 16 + c->mov128_vf_gpr(vf7, t8); // qmtc2.i vf7, t8 + c->pcpyud(t9, t9, r0); // pcpyud t9, t9, r0 + if (((s64)c->sgpr64(t9)) < 0) { // bltzl t9, L30 + c->vsub(DEST::xyzw, vf4, vf15, vf4); // vsub.xyzw vf4, vf15, vf4 + next_block = 28; + break; + } + + case 28: + next_block = 29; + c->vitof12(DEST::xyzw, vf7, vf7); // vitof12.xyzw vf7, vf7 + c->vmula_bc(DEST::xyzw, BC::w, vf6, vf0); // vmulaw.xyzw acc, vf6, vf0 + c->vmadd_bc(DEST::xyzw, BC::x, vf6, vf4, vf13); // vmaddx.xyzw vf6, vf4, vf13 + c->vmula_bc(DEST::xyzw, BC::w, vf3, vf0); // vmulaw.xyzw acc, vf3, vf0 + c->vmadd_bc(DEST::xyzw, BC::y, vf3, vf1, vf13); // vmaddy.xyzw vf3, vf1, vf13 + c->vmula_bc(DEST::xyzw, BC::w, vf9, vf0); // vmulaw.xyzw acc, vf9, vf0 + c->vmadd_bc(DEST::xyzw, BC::x, vf9, vf7, vf13); // vmaddx.xyzw vf9, vf7, vf13 + c->sqc2(vf3, 0, a0); // sqc2 vf3, 0(a0) + c->sqc2(vf6, 16, a0); // sqc2 vf6, 16(a0) + c->sqc2(vf9, 32, a0); // sqc2 vf9, 32(a0) + //beq r0, r0, L25 // beq r0, r0, L25 + // nop // sll r0, r0, 0 + next_block = 6; // branch always + + break; + + case 29: + next_block = 30; + c->ld(t9, 8, t4); // ld t9, 8(t4) + c->daddiu(t4, t4, 8); // daddiu t4, t4, 8 + c->lqc2(vf6, 16, a0); // lqc2 vf6, 16(a0) + c->pextlh(t9, t9, r0); // pextlh t9, t9, r0 + c->psraw(t9, t9, 16); // psraw t9, t9, 16 + c->mov128_vf_gpr(vf4, t9); // qmtc2.i vf4, t9 + c->ld(s6, -8, t4); // ld s6, -8(t4) + c->daddiu(t4, t4, 8); // daddiu t4, t4, 8 + c->lw(gp, 0, t5); // lw gp, 0(t5) + c->daddiu(t5, t5, 4); // daddiu t5, t5, 4 + c->lqc2(vf3, 0, a0); // lqc2 vf3, 0(a0) + c->vitof15(DEST::xyzw, vf4, vf4); // vitof15.xyzw vf4, vf4 + c->pcpyld(s6, gp, s6); // pcpyld s6, gp, s6 + c->vmul(DEST::xyzw, vf10, vf4, vf6); // vmul.xyzw vf10, vf4, vf6 + c->mov128_vf_gpr(vf1, s6); // qmtc2.i vf1, s6 + c->lw(t8, 0, t5); // lw t8, 0(t5) + c->daddiu(t5, t5, 4); // daddiu t5, t5, 4 + c->lh(fp, 0, t6); // lh fp, 0(t6) + c->daddiu(t6, t6, 2); // daddiu t6, t6, 2 + c->vmula_bc(DEST::xyzw, BC::w, vf10, vf0); // vmulaw.xyzw acc, vf10, vf0 + c->vmadda_bc(DEST::xyzw, BC::z, vf0, vf10); // vmaddaz.xyzw acc, vf0, vf10 + c->vmadda_bc(DEST::xyzw, BC::y, vf0, vf10); // vmadday.xyzw acc, vf0, vf10 + c->vmadd_bc(DEST::xyzw, BC::x, vf10, vf0, vf10); // vmaddx.xyzw vf10, vf0, vf10 + c->lqc2(vf9, 32, a0); // lqc2 vf9, 32(a0) + c->pextlw(t8, fp, t8); // pextlw t8, fp, t8 + c->mov128_gpr_vf(t9, vf10); // qmfc2.i t9, vf10 + c->pextlh(t8, t8, r0); // pextlh t8, t8, r0 + c->psraw(t8, t8, 16); // psraw t8, t8, 16 + c->mov128_vf_gpr(vf7, t8); // qmtc2.i vf7, t8 + c->pcpyud(t9, t9, r0); // pcpyud t9, t9, r0 + if (((s64)c->sgpr64(t9)) < 0) { // bltzl t9, L31 + c->vsub(DEST::xyzw, vf4, vf15, vf4); // vsub.xyzw vf4, vf15, vf4 + next_block = 31; + break; + } + + case 31: + next_block = 32; + c->vitof12(DEST::xyzw, vf7, vf7); // vitof12.xyzw vf7, vf7 + c->vmula_bc(DEST::xyzw, BC::w, vf6, vf0); // vmulaw.xyzw acc, vf6, vf0 + c->vmadd_bc(DEST::xyzw, BC::x, vf6, vf4, vf13); // vmaddx.xyzw vf6, vf4, vf13 + c->vmula_bc(DEST::xyzw, BC::w, vf3, vf0); // vmulaw.xyzw acc, vf3, vf0 + c->vmadd_bc(DEST::xyzw, BC::x, vf3, vf1, vf13); // vmaddx.xyzw vf3, vf1, vf13 + c->vmula_bc(DEST::xyzw, BC::w, vf9, vf0); // vmulaw.xyzw acc, vf9, vf0 + c->vmadd_bc(DEST::xyzw, BC::x, vf9, vf7, vf13); // vmaddx.xyzw vf9, vf7, vf13 + c->sqc2(vf3, 0, a0); // sqc2 vf3, 0(a0) + c->sqc2(vf6, 16, a0); // sqc2 vf6, 16(a0) + c->sqc2(vf9, 32, a0); // sqc2 vf9, 32(a0) + //beq r0, r0, L25 // beq r0, r0, L25 + // nop // sll r0, r0, 0 + next_block = 6; // branch always + + break; + + case 32: + next_block = 33; + c->lq(a0, 0, sp); // lq a0, 0(sp) + // nop // sll r0, r0, 0 + //jr ra // jr ra + c->daddiu(sp, sp, 16); // daddiu sp, sp, 16 + goto end_of_function; // return + + //jr ra // jr ra + c->daddu(sp, sp, r0); // daddu sp, sp, r0 + goto end_of_function; // return + + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + } + } + end_of_function: + return c->gprs[v0].du64[0]; +} + +u32 jump_table_vals[16] = { + 0x7b2191b, // = 6 ^ 129112349 + 0x7b21914, // = 9 ^ 129112349 + 0x7b21916, // = 11 ^ 129112349 + 0x7b21913, // = 14 ^ 129112349 + 0x7b21909, // = 20 ^ 129112349 + 0x7b21908, // = 21 ^ 129112349 + 0x7b2190a, // = 23 ^ 129112349 + 0x7b21907, // = 26 ^ 129112349 + 0x7b2191b, // = 6 ^ 129112349 + 0x7b21917, // = 10 ^ 129112349 + 0x7b21916, // = 11 ^ 129112349 + 0x7b2190c, // = 17 ^ 129112349 + 0x7b21909, // = 20 ^ 129112349 + 0x7b2190b, // = 22 ^ 129112349 + 0x7b2190a, // = 23 ^ 129112349 + 0x7b21900, // = 29 ^ 129112349 +}; + +} // namespace decompress_frame_data_to_accumulator +} // namespace Mips2C + +//--------------------------MIPS2C--------------------- +#include "game/mips2c/mips2c_private.h" + +namespace Mips2C::jak2 { +namespace decompress_fixed_data_to_accumulator { +u64 execute(void* ctxt) { + auto* c = (ExecutionContext*)ctxt; + bool bc = false; + u32 next_block = 0; + while(true) { + switch(next_block) { + + case 0: + next_block = 1; + c->lq(t4, 0, a1); // lq t4, 0(a1) + c->daddiu(sp, sp, -16); // daddiu sp, sp, -16 + c->lq(t5, 16, a1); // lq t5, 16(a1) + // nop // sll r0, r0, 0 + c->sq(t4, 0, t1); // sq t4, 0(t1) + // nop // sll r0, r0, 0 + c->sq(t5, 16, t1); // sq t5, 16(t1) + // nop // sll r0, r0, 0 + c->lq(t4, 32, a1); // lq t4, 32(a1) + // nop // sll r0, r0, 0 + c->lq(t5, 48, a1); // lq t5, 48(a1) + // nop // sll r0, r0, 0 + c->sq(t4, 32, t1); // sq t4, 32(t1) + // nop // sll r0, r0, 0 + c->sq(t5, 48, t1); // sq t5, 48(t1) + // nop // sll r0, r0, 0 + c->sq(a0, 0, sp); // sq a0, 0(sp) + // nop // sll r0, r0, 0 + c->mov128_vf_gpr(vf13, a2); // qmtc2.i vf13, a2 + // c->lui(t2, 28672); // lui t2, 28672 + get_fake_spad_addr(t2, cache.fake_scratchpad_data, 0, c); + c->lw(t4, 64, a1); // lw t4, 64(a1) + c->daddiu(v1, a1, 80); // daddiu v1, a1, 80 + c->lw(t5, 68, a1); // lw t5, 68(a1) + c->daddu(s5, t1, r0); // daddu s5, t1, r0 + c->lw(t6, 72, a1); // lw t6, 72(a1) + c->daddu(t4, t4, v1); // daddu t4, t4, v1 + c->vmul_bc(DEST::xyzw, BC::x, vf13, vf14, vf13); // vmulx.xyzw vf13, vf14, vf13 + c->daddiu(t2, t2, 1616); // daddiu t2, t2, 1616 JAK 2 CHANGE + c->lw(s2, 56, t1); // lw s2, 56(t1) + c->daddu(t5, t5, v1); // daddu t5, t5, v1 + c->lw(s4, 60, t1); // lw s4, 60(t1) + c->daddu(t6, t6, v1); // daddu t6, t6, v1 + c->addiu(s3, r0, 8); // addiu s3, r0, 8 + c->daddiu(s5, s5, 4); // daddiu s5, s5, 4 + c->andi(t3, s4, 1); // andi t3, s4, 1 + // nop // sll r0, r0, 0 + bc = c->sgpr64(t3) != 0; // bne t3, r0, L34 + // nop // sll r0, r0, 0 + if (bc) {next_block = 2;} // branch non-likely + + break; + + case 1: + next_block = 2; + c->lqc2(vf1, 0, t4); // lqc2 vf1, 0(t4) + c->lqc2(vf2, 16, t4); // lqc2 vf2, 16(t4) + c->lqc2(vf3, 32, t4); // lqc2 vf3, 32(t4) + c->lqc2(vf4, 48, t4); // lqc2 vf4, 48(t4) + c->lqc2(vf9, 0, a0); // lqc2 vf9, 0(a0) + c->daddiu(t4, t4, 64); // daddiu t4, t4, 64 + c->lqc2(vf10, 16, a0); // lqc2 vf10, 16(a0) + // nop // sll r0, r0, 0 + c->lqc2(vf11, 32, a0); // lqc2 vf11, 32(a0) + c->lqc2(vf12, 48, a0); // lqc2 vf12, 48(a0) + c->vmula_bc(DEST::xyzw, BC::w, vf9, vf0); // vmulaw.xyzw acc, vf9, vf0 + c->vmadd_bc(DEST::xyzw, BC::x, vf9, vf1, vf13); // vmaddx.xyzw vf9, vf1, vf13 + c->vmula_bc(DEST::xyzw, BC::w, vf10, vf0); // vmulaw.xyzw acc, vf10, vf0 + c->vmadd_bc(DEST::xyzw, BC::x, vf10, vf2, vf13); // vmaddx.xyzw vf10, vf2, vf13 + c->vmula_bc(DEST::xyzw, BC::w, vf11, vf0); // vmulaw.xyzw acc, vf11, vf0 + c->vmadd_bc(DEST::xyzw, BC::x, vf11, vf3, vf13); // vmaddx.xyzw vf11, vf3, vf13 + c->vmula_bc(DEST::xyzw, BC::w, vf12, vf0); // vmulaw.xyzw acc, vf12, vf0 + c->vmadd_bc(DEST::xyzw, BC::x, vf12, vf4, vf13); // vmaddx.xyzw vf12, vf4, vf13 + c->sqc2(vf9, 0, a0); // sqc2 vf9, 0(a0) + c->sqc2(vf10, 16, a0); // sqc2 vf10, 16(a0) + c->sqc2(vf11, 32, a0); // sqc2 vf11, 32(a0) + c->sqc2(vf12, 48, a0); // sqc2 vf12, 48(a0) + + case 2: + next_block = 3; + c->andi(t3, s4, 2); // andi t3, s4, 2 + c->daddiu(a0, a0, 64); // daddiu a0, a0, 64 + bc = c->sgpr64(t3) != 0; // bne t3, r0, L35 + // nop // sll r0, r0, 0 + if (bc) {next_block = 4;} // branch non-likely + + break; + + case 3: + next_block = 4; + c->lqc2(vf1, 0, t4); // lqc2 vf1, 0(t4) + c->lqc2(vf2, 16, t4); // lqc2 vf2, 16(t4) + c->lqc2(vf3, 32, t4); // lqc2 vf3, 32(t4) + c->lqc2(vf4, 48, t4); // lqc2 vf4, 48(t4) + c->lqc2(vf9, 0, a0); // lqc2 vf9, 0(a0) + c->daddiu(t4, t4, 64); // daddiu t4, t4, 64 + c->lqc2(vf10, 16, a0); // lqc2 vf10, 16(a0) + // nop // sll r0, r0, 0 + c->lqc2(vf11, 32, a0); // lqc2 vf11, 32(a0) + c->lqc2(vf12, 48, a0); // lqc2 vf12, 48(a0) + c->vmula_bc(DEST::xyzw, BC::w, vf9, vf0); // vmulaw.xyzw acc, vf9, vf0 + c->vmadd_bc(DEST::xyzw, BC::x, vf9, vf1, vf13); // vmaddx.xyzw vf9, vf1, vf13 + c->vmula_bc(DEST::xyzw, BC::w, vf10, vf0); // vmulaw.xyzw acc, vf10, vf0 + c->vmadd_bc(DEST::xyzw, BC::x, vf10, vf2, vf13); // vmaddx.xyzw vf10, vf2, vf13 + c->vmula_bc(DEST::xyzw, BC::w, vf11, vf0); // vmulaw.xyzw acc, vf11, vf0 + c->vmadd_bc(DEST::xyzw, BC::x, vf11, vf3, vf13); // vmaddx.xyzw vf11, vf3, vf13 + c->vmula_bc(DEST::xyzw, BC::w, vf12, vf0); // vmulaw.xyzw acc, vf12, vf0 + c->vmadd_bc(DEST::xyzw, BC::x, vf12, vf4, vf13); // vmaddx.xyzw vf12, vf4, vf13 + c->sqc2(vf9, 0, a0); // sqc2 vf9, 0(a0) + c->sqc2(vf10, 16, a0); // sqc2 vf10, 16(a0) + c->sqc2(vf11, 32, a0); // sqc2 vf11, 32(a0) + c->sqc2(vf12, 48, a0); // sqc2 vf12, 48(a0) + + case 4: + next_block = 5; + c->lw(s4, -4, s5); // lw s4, -4(s5) + c->daddiu(a0, a0, 64); // daddiu a0, a0, 64 + + case 5: + next_block = 6; + c->andi(t3, s4, 15); // andi t3, s4, 15 + c->sra(s4, s4, 4); // sra s4, s4, 4 + c->sll(t3, t3, 2); // sll t3, t3, 2 + c->daddiu(s3, s3, -1); // daddiu s3, s3, -1 + c->daddu(t3, t3, t2); // daddu t3, t3, t2 + c->daddiu(s2, s2, -1); // daddiu s2, s2, -1 + c->lw(t3, 0, t3); // lw t3, 0(t3) + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + next_block = 0x3ee6b6f0 ^ c->gprs[t3].du32[0]; // jr t3 + ASSERT(next_block < 33); + break; + // nop // sll r0, r0, 0 + + case 6: + next_block = 7; + bc = c->sgpr64(s2) == 0; // beq s2, r0, L44 + c->daddiu(a0, a0, 48); // daddiu a0, a0, 48 + if (bc) {next_block = 32;} // branch non-likely + + break; + + case 7: + next_block = 8; + bc = c->sgpr64(s3) != 0; // bne s3, r0, L36 + // nop // sll r0, r0, 0 + if (bc) {next_block = 5;} // branch non-likely + + break; + + case 8: + next_block = 9; + c->lw(s4, 0, s5); // lw s4, 0(s5) + c->daddiu(s5, s5, 4); // daddiu s5, s5, 4 + //beq r0, r0, L36 // beq r0, r0, L36 + c->addiu(s3, r0, 8); // addiu s3, r0, 8 + next_block = 5; // branch always + + break; + + case 9: + next_block = 10; + c->ld(t9, 0, t4); // ld t9, 0(t4) + c->daddiu(t4, t4, 8); // daddiu t4, t4, 8 + c->lqc2(vf6, 16, a0); // lqc2 vf6, 16(a0) + c->pextlh(t9, t9, r0); // pextlh t9, t9, r0 + c->psraw(t9, t9, 16); // psraw t9, t9, 16 + c->mov128_vf_gpr(vf4, t9); // qmtc2.i vf4, t9 + c->lw(s6, 0, t5); // lw s6, 0(t5) + c->daddiu(t5, t5, 4); // daddiu t5, t5, 4 + c->lh(gp, 0, t6); // lh gp, 0(t6) + c->daddiu(t6, t6, 2); // daddiu t6, t6, 2 + c->lqc2(vf3, 0, a0); // lqc2 vf3, 0(a0) + c->vitof15(DEST::xyzw, vf4, vf4); // vitof15.xyzw vf4, vf4 + c->pextlw(s6, gp, s6); // pextlw s6, gp, s6 + c->pextlh(s6, s6, r0); // pextlh s6, s6, r0 + c->psraw(s6, s6, 16); // psraw s6, s6, 16 + c->vmul(DEST::xyzw, vf10, vf4, vf6); // vmul.xyzw vf10, vf4, vf6 + c->mov128_vf_gpr(vf1, s6); // qmtc2.i vf1, s6 + c->lw(t8, 0, t5); // lw t8, 0(t5) + c->daddiu(t5, t5, 4); // daddiu t5, t5, 4 + c->lh(fp, 0, t6); // lh fp, 0(t6) + c->daddiu(t6, t6, 2); // daddiu t6, t6, 2 + c->vmula_bc(DEST::xyzw, BC::w, vf10, vf0); // vmulaw.xyzw acc, vf10, vf0 + c->vmadda_bc(DEST::xyzw, BC::z, vf0, vf10); // vmaddaz.xyzw acc, vf0, vf10 + c->vmadda_bc(DEST::xyzw, BC::y, vf0, vf10); // vmadday.xyzw acc, vf0, vf10 + c->vmadd_bc(DEST::xyzw, BC::x, vf10, vf0, vf10); // vmaddx.xyzw vf10, vf0, vf10 + c->vitof0(DEST::xyzw, vf1, vf1); // vitof0.xyzw vf1, vf1 + c->lqc2(vf9, 32, a0); // lqc2 vf9, 32(a0) + c->pextlw(t8, fp, t8); // pextlw t8, fp, t8 + c->mov128_gpr_vf(t9, vf10); // qmfc2.i t9, vf10 + c->pextlh(t8, t8, r0); // pextlh t8, t8, r0 + c->psraw(t8, t8, 16); // psraw t8, t8, 16 + c->mov128_vf_gpr(vf7, t8); // qmtc2.i vf7, t8 + c->pcpyud(t9, t9, r0); // pcpyud t9, t9, r0 + if (((s64)c->sgpr64(t9)) < 0) { // bltzl t9, L38 + c->vsub(DEST::xyzw, vf4, vf15, vf4); // vsub.xyzw vf4, vf15, vf4 + next_block = 11; + break; + } + + case 11: + next_block = 12; + c->vitof12(DEST::xyzw, vf7, vf7); // vitof12.xyzw vf7, vf7 + c->vmula_bc(DEST::xyzw, BC::w, vf6, vf0); // vmulaw.xyzw acc, vf6, vf0 + c->vmadd_bc(DEST::xyzw, BC::x, vf6, vf4, vf13); // vmaddx.xyzw vf6, vf4, vf13 + c->vmula_bc(DEST::xyzw, BC::w, vf3, vf0); // vmulaw.xyzw acc, vf3, vf0 + c->vmadd_bc(DEST::xyzw, BC::y, vf3, vf1, vf13); // vmaddy.xyzw vf3, vf1, vf13 + c->vmula_bc(DEST::xyzw, BC::w, vf9, vf0); // vmulaw.xyzw acc, vf9, vf0 + c->vmadd_bc(DEST::xyzw, BC::x, vf9, vf7, vf13); // vmaddx.xyzw vf9, vf7, vf13 + c->sqc2(vf3, 0, a0); // sqc2 vf3, 0(a0) + c->sqc2(vf6, 16, a0); // sqc2 vf6, 16(a0) + c->sqc2(vf9, 32, a0); // sqc2 vf9, 32(a0) + //beq r0, r0, L37 // beq r0, r0, L37 + // nop // sll r0, r0, 0 + next_block = 6; // branch always + + break; + + case 12: + next_block = 13; + c->ld(t9, 8, t4); // ld t9, 8(t4) + c->daddiu(t4, t4, 8); // daddiu t4, t4, 8 + c->lqc2(vf6, 16, a0); // lqc2 vf6, 16(a0) + c->pextlh(t9, t9, r0); // pextlh t9, t9, r0 + c->psraw(t9, t9, 16); // psraw t9, t9, 16 + c->mov128_vf_gpr(vf4, t9); // qmtc2.i vf4, t9 + c->ld(s6, -8, t4); // ld s6, -8(t4) + c->daddiu(t4, t4, 8); // daddiu t4, t4, 8 + c->lw(gp, 0, t5); // lw gp, 0(t5) + c->daddiu(t5, t5, 4); // daddiu t5, t5, 4 + c->lqc2(vf3, 0, a0); // lqc2 vf3, 0(a0) + c->vitof15(DEST::xyzw, vf4, vf4); // vitof15.xyzw vf4, vf4 + c->pcpyld(s6, gp, s6); // pcpyld s6, gp, s6 + c->vmul(DEST::xyzw, vf10, vf4, vf6); // vmul.xyzw vf10, vf4, vf6 + c->mov128_vf_gpr(vf1, s6); // qmtc2.i vf1, s6 + c->lw(t8, 0, t5); // lw t8, 0(t5) + c->daddiu(t5, t5, 4); // daddiu t5, t5, 4 + c->lh(fp, 0, t6); // lh fp, 0(t6) + c->daddiu(t6, t6, 2); // daddiu t6, t6, 2 + c->vmula_bc(DEST::xyzw, BC::w, vf10, vf0); // vmulaw.xyzw acc, vf10, vf0 + c->vmadda_bc(DEST::xyzw, BC::z, vf0, vf10); // vmaddaz.xyzw acc, vf0, vf10 + c->vmadda_bc(DEST::xyzw, BC::y, vf0, vf10); // vmadday.xyzw acc, vf0, vf10 + c->vmadd_bc(DEST::xyzw, BC::x, vf10, vf0, vf10); // vmaddx.xyzw vf10, vf0, vf10 + c->lqc2(vf9, 32, a0); // lqc2 vf9, 32(a0) + c->pextlw(t8, fp, t8); // pextlw t8, fp, t8 + c->mov128_gpr_vf(t9, vf10); // qmfc2.i t9, vf10 + c->pextlh(t8, t8, r0); // pextlh t8, t8, r0 + c->psraw(t8, t8, 16); // psraw t8, t8, 16 + c->mov128_vf_gpr(vf7, t8); // qmtc2.i vf7, t8 + c->pcpyud(t9, t9, r0); // pcpyud t9, t9, r0 + if (((s64)c->sgpr64(t9)) < 0) { // bltzl t9, L39 + c->vsub(DEST::xyzw, vf4, vf15, vf4); // vsub.xyzw vf4, vf15, vf4 + next_block = 14; + break; + } + + case 14: + next_block = 15; + c->vitof12(DEST::xyzw, vf7, vf7); // vitof12.xyzw vf7, vf7 + c->vmula_bc(DEST::xyzw, BC::w, vf6, vf0); // vmulaw.xyzw acc, vf6, vf0 + c->vmadd_bc(DEST::xyzw, BC::x, vf6, vf4, vf13); // vmaddx.xyzw vf6, vf4, vf13 + c->vmula_bc(DEST::xyzw, BC::w, vf3, vf0); // vmulaw.xyzw acc, vf3, vf0 + c->vmadd_bc(DEST::xyzw, BC::x, vf3, vf1, vf13); // vmaddx.xyzw vf3, vf1, vf13 + c->vmula_bc(DEST::xyzw, BC::w, vf9, vf0); // vmulaw.xyzw acc, vf9, vf0 + c->vmadd_bc(DEST::xyzw, BC::x, vf9, vf7, vf13); // vmaddx.xyzw vf9, vf7, vf13 + c->sqc2(vf3, 0, a0); // sqc2 vf3, 0(a0) + c->sqc2(vf6, 16, a0); // sqc2 vf6, 16(a0) + c->sqc2(vf9, 32, a0); // sqc2 vf9, 32(a0) + //beq r0, r0, L37 // beq r0, r0, L37 + // nop // sll r0, r0, 0 + next_block = 6; // branch always + + break; + + case 15: + next_block = 16; + c->ld(t9, 0, t4); // ld t9, 0(t4) + c->daddiu(t4, t4, 8); // daddiu t4, t4, 8 + c->lqc2(vf6, 16, a0); // lqc2 vf6, 16(a0) + c->pextlh(t9, t9, r0); // pextlh t9, t9, r0 + c->psraw(t9, t9, 16); // psraw t9, t9, 16 + c->mov128_vf_gpr(vf4, t9); // qmtc2.i vf4, t9 + c->lw(t8, 0, t5); // lw t8, 0(t5) + c->daddiu(t5, t5, 4); // daddiu t5, t5, 4 + c->lh(fp, 0, t6); // lh fp, 0(t6) + c->daddiu(t6, t6, 2); // daddiu t6, t6, 2 + c->lqc2(vf9, 32, a0); // lqc2 vf9, 32(a0) + c->vitof15(DEST::xyzw, vf4, vf4); // vitof15.xyzw vf4, vf4 + c->pextlw(t8, fp, t8); // pextlw t8, fp, t8 + c->pextlh(t8, t8, r0); // pextlh t8, t8, r0 + c->psraw(t8, t8, 16); // psraw t8, t8, 16 + c->vmul(DEST::xyzw, vf10, vf4, vf6); // vmul.xyzw vf10, vf4, vf6 + c->mov128_vf_gpr(vf7, t8); // qmtc2.i vf7, t8 + c->vmula_bc(DEST::xyzw, BC::w, vf10, vf0); // vmulaw.xyzw acc, vf10, vf0 + c->vitof12(DEST::xyzw, vf7, vf7); // vitof12.xyzw vf7, vf7 + c->vmadda_bc(DEST::xyzw, BC::z, vf0, vf10); // vmaddaz.xyzw acc, vf0, vf10 + c->vmadda_bc(DEST::xyzw, BC::y, vf0, vf10); // vmadday.xyzw acc, vf0, vf10 + c->vmadd_bc(DEST::xyzw, BC::x, vf10, vf0, vf10); // vmaddx.xyzw vf10, vf0, vf10 + c->vmula_bc(DEST::xyzw, BC::w, vf9, vf0); // vmulaw.xyzw acc, vf9, vf0 + c->vmadd_bc(DEST::xyzw, BC::x, vf9, vf7, vf13); // vmaddx.xyzw vf9, vf7, vf13 + c->mov128_gpr_vf(t9, vf10); // qmfc2.i t9, vf10 + c->pcpyud(t9, t9, r0); // pcpyud t9, t9, r0 + if (((s64)c->sgpr64(t9)) < 0) { // bltzl t9, L40 + c->vsub(DEST::xyzw, vf4, vf15, vf4); // vsub.xyzw vf4, vf15, vf4 + next_block = 17; + break; + } + + case 17: + next_block = 18; + c->vmula_bc(DEST::xyzw, BC::w, vf6, vf0); // vmulaw.xyzw acc, vf6, vf0 + c->vmadd_bc(DEST::xyzw, BC::x, vf6, vf4, vf13); // vmaddx.xyzw vf6, vf4, vf13 + c->sqc2(vf6, 16, a0); // sqc2 vf6, 16(a0) + c->sqc2(vf9, 32, a0); // sqc2 vf9, 32(a0) + //beq r0, r0, L37 // beq r0, r0, L37 + // nop // sll r0, r0, 0 + next_block = 6; // branch always + + break; + + case 18: + next_block = 19; + c->lw(s6, 0, t5); // lw s6, 0(t5) + c->daddiu(t5, t5, 4); // daddiu t5, t5, 4 + c->lh(gp, 0, t6); // lh gp, 0(t6) + c->daddiu(t6, t6, 2); // daddiu t6, t6, 2 + c->lqc2(vf3, 0, a0); // lqc2 vf3, 0(a0) + c->pextlw(s6, gp, s6); // pextlw s6, gp, s6 + c->pextlh(s6, s6, r0); // pextlh s6, s6, r0 + c->psraw(s6, s6, 16); // psraw s6, s6, 16 + c->mov128_vf_gpr(vf1, s6); // qmtc2.i vf1, s6 + c->lw(t8, 0, t5); // lw t8, 0(t5) + c->daddiu(t5, t5, 4); // daddiu t5, t5, 4 + c->lh(fp, 0, t6); // lh fp, 0(t6) + c->daddiu(t6, t6, 2); // daddiu t6, t6, 2 + c->lqc2(vf9, 32, a0); // lqc2 vf9, 32(a0) + c->vitof0(DEST::xyzw, vf1, vf1); // vitof0.xyzw vf1, vf1 + c->pextlw(t8, fp, t8); // pextlw t8, fp, t8 + c->pextlh(t8, t8, r0); // pextlh t8, t8, r0 + c->psraw(t8, t8, 16); // psraw t8, t8, 16 + c->mov128_vf_gpr(vf7, t8); // qmtc2.i vf7, t8 + c->vmula_bc(DEST::xyzw, BC::w, vf3, vf0); // vmulaw.xyzw acc, vf3, vf0 + c->vmadd_bc(DEST::xyzw, BC::y, vf3, vf1, vf13); // vmaddy.xyzw vf3, vf1, vf13 + c->vitof12(DEST::xyzw, vf7, vf7); // vitof12.xyzw vf7, vf7 + c->vmula_bc(DEST::xyzw, BC::w, vf9, vf0); // vmulaw.xyzw acc, vf9, vf0 + c->vmadd_bc(DEST::xyzw, BC::x, vf9, vf7, vf13); // vmaddx.xyzw vf9, vf7, vf13 + c->sqc2(vf3, 0, a0); // sqc2 vf3, 0(a0) + c->sqc2(vf9, 32, a0); // sqc2 vf9, 32(a0) + //beq r0, r0, L37 // beq r0, r0, L37 + // nop // sll r0, r0, 0 + next_block = 6; // branch always + + break; + + case 19: + next_block = 20; + c->ld(s6, 0, t4); // ld s6, 0(t4) + c->daddiu(t4, t4, 8); // daddiu t4, t4, 8 + c->lw(gp, 0, t5); // lw gp, 0(t5) + c->daddiu(t5, t5, 4); // daddiu t5, t5, 4 + c->lqc2(vf3, 0, a0); // lqc2 vf3, 0(a0) + c->pcpyld(s6, gp, s6); // pcpyld s6, gp, s6 + c->mov128_vf_gpr(vf1, s6); // qmtc2.i vf1, s6 + c->lw(t8, 0, t5); // lw t8, 0(t5) + c->daddiu(t5, t5, 4); // daddiu t5, t5, 4 + c->lh(fp, 0, t6); // lh fp, 0(t6) + c->daddiu(t6, t6, 2); // daddiu t6, t6, 2 + c->lqc2(vf9, 32, a0); // lqc2 vf9, 32(a0) + c->pextlw(t8, fp, t8); // pextlw t8, fp, t8 + c->pextlh(t8, t8, r0); // pextlh t8, t8, r0 + c->psraw(t8, t8, 16); // psraw t8, t8, 16 + c->mov128_vf_gpr(vf7, t8); // qmtc2.i vf7, t8 + c->vmula_bc(DEST::xyzw, BC::w, vf3, vf0); // vmulaw.xyzw acc, vf3, vf0 + c->vmadd_bc(DEST::xyzw, BC::x, vf3, vf1, vf13); // vmaddx.xyzw vf3, vf1, vf13 + c->vitof12(DEST::xyzw, vf7, vf7); // vitof12.xyzw vf7, vf7 + c->vmula_bc(DEST::xyzw, BC::w, vf9, vf0); // vmulaw.xyzw acc, vf9, vf0 + c->vmadd_bc(DEST::xyzw, BC::x, vf9, vf7, vf13); // vmaddx.xyzw vf9, vf7, vf13 + c->sqc2(vf3, 0, a0); // sqc2 vf3, 0(a0) + c->sqc2(vf9, 32, a0); // sqc2 vf9, 32(a0) + //beq r0, r0, L37 // beq r0, r0, L37 + // nop // sll r0, r0, 0 + next_block = 6; // branch always + + break; + + case 20: + next_block = 21; + c->lw(t8, 0, t5); // lw t8, 0(t5) + c->daddiu(t5, t5, 4); // daddiu t5, t5, 4 + c->lh(fp, 0, t6); // lh fp, 0(t6) + c->daddiu(t6, t6, 2); // daddiu t6, t6, 2 + c->lqc2(vf9, 32, a0); // lqc2 vf9, 32(a0) + c->pextlw(t8, fp, t8); // pextlw t8, fp, t8 + c->pextlh(t8, t8, r0); // pextlh t8, t8, r0 + c->psraw(t8, t8, 16); // psraw t8, t8, 16 + c->mov128_vf_gpr(vf7, t8); // qmtc2.i vf7, t8 + c->vitof12(DEST::xyzw, vf7, vf7); // vitof12.xyzw vf7, vf7 + c->vmula_bc(DEST::xyzw, BC::w, vf9, vf0); // vmulaw.xyzw acc, vf9, vf0 + c->vmadd_bc(DEST::xyzw, BC::x, vf9, vf7, vf13); // vmaddx.xyzw vf9, vf7, vf13 + c->sqc2(vf9, 32, a0); // sqc2 vf9, 32(a0) + //beq r0, r0, L37 // beq r0, r0, L37 + // nop // sll r0, r0, 0 + next_block = 6; // branch always + + break; + + case 21: + next_block = 22; + c->ld(t9, 0, t4); // ld t9, 0(t4) + c->daddiu(t4, t4, 8); // daddiu t4, t4, 8 + c->lqc2(vf6, 16, a0); // lqc2 vf6, 16(a0) + c->pextlh(t9, t9, r0); // pextlh t9, t9, r0 + c->psraw(t9, t9, 16); // psraw t9, t9, 16 + c->mov128_vf_gpr(vf4, t9); // qmtc2.i vf4, t9 + c->lw(s6, 0, t5); // lw s6, 0(t5) + c->daddiu(t5, t5, 4); // daddiu t5, t5, 4 + c->lh(gp, 0, t6); // lh gp, 0(t6) + c->daddiu(t6, t6, 2); // daddiu t6, t6, 2 + c->lqc2(vf3, 0, a0); // lqc2 vf3, 0(a0) + c->vitof15(DEST::xyzw, vf4, vf4); // vitof15.xyzw vf4, vf4 + c->pextlw(s6, gp, s6); // pextlw s6, gp, s6 + c->pextlh(s6, s6, r0); // pextlh s6, s6, r0 + c->psraw(s6, s6, 16); // psraw s6, s6, 16 + c->vmul(DEST::xyzw, vf10, vf4, vf6); // vmul.xyzw vf10, vf4, vf6 + c->mov128_vf_gpr(vf1, s6); // qmtc2.i vf1, s6 + c->vmula_bc(DEST::xyzw, BC::w, vf10, vf0); // vmulaw.xyzw acc, vf10, vf0 + c->vitof0(DEST::xyzw, vf1, vf1); // vitof0.xyzw vf1, vf1 + c->vmadda_bc(DEST::xyzw, BC::z, vf0, vf10); // vmaddaz.xyzw acc, vf0, vf10 + c->vmadda_bc(DEST::xyzw, BC::y, vf0, vf10); // vmadday.xyzw acc, vf0, vf10 + c->vmadd_bc(DEST::xyzw, BC::x, vf10, vf0, vf10); // vmaddx.xyzw vf10, vf0, vf10 + c->vmula_bc(DEST::xyzw, BC::w, vf3, vf0); // vmulaw.xyzw acc, vf3, vf0 + c->vmadd_bc(DEST::xyzw, BC::y, vf3, vf1, vf13); // vmaddy.xyzw vf3, vf1, vf13 + c->mov128_gpr_vf(t9, vf10); // qmfc2.i t9, vf10 + c->pcpyud(t9, t9, r0); // pcpyud t9, t9, r0 + if (((s64)c->sgpr64(t9)) < 0) { // bltzl t9, L41 + c->vsub(DEST::xyzw, vf4, vf15, vf4); // vsub.xyzw vf4, vf15, vf4 + next_block = 23; + break; + } + + case 23: + next_block = 24; + c->vmula_bc(DEST::xyzw, BC::w, vf6, vf0); // vmulaw.xyzw acc, vf6, vf0 + c->vmadd_bc(DEST::xyzw, BC::x, vf6, vf4, vf13); // vmaddx.xyzw vf6, vf4, vf13 + c->sqc2(vf3, 0, a0); // sqc2 vf3, 0(a0) + c->sqc2(vf6, 16, a0); // sqc2 vf6, 16(a0) + //beq r0, r0, L37 // beq r0, r0, L37 + // nop // sll r0, r0, 0 + next_block = 6; // branch always + + break; + + case 24: + next_block = 25; + c->ld(t9, 8, t4); // ld t9, 8(t4) + c->daddiu(t4, t4, 8); // daddiu t4, t4, 8 + c->lqc2(vf6, 16, a0); // lqc2 vf6, 16(a0) + c->pextlh(t9, t9, r0); // pextlh t9, t9, r0 + c->psraw(t9, t9, 16); // psraw t9, t9, 16 + c->mov128_vf_gpr(vf4, t9); // qmtc2.i vf4, t9 + c->ld(s6, -8, t4); // ld s6, -8(t4) + c->daddiu(t4, t4, 8); // daddiu t4, t4, 8 + c->lw(gp, 0, t5); // lw gp, 0(t5) + c->daddiu(t5, t5, 4); // daddiu t5, t5, 4 + c->lqc2(vf3, 0, a0); // lqc2 vf3, 0(a0) + c->vitof15(DEST::xyzw, vf4, vf4); // vitof15.xyzw vf4, vf4 + c->pcpyld(s6, gp, s6); // pcpyld s6, gp, s6 + c->vmul(DEST::xyzw, vf10, vf4, vf6); // vmul.xyzw vf10, vf4, vf6 + c->mov128_vf_gpr(vf1, s6); // qmtc2.i vf1, s6 + c->vmula_bc(DEST::xyzw, BC::w, vf10, vf0); // vmulaw.xyzw acc, vf10, vf0 + c->vmadda_bc(DEST::xyzw, BC::z, vf0, vf10); // vmaddaz.xyzw acc, vf0, vf10 + c->vmadda_bc(DEST::xyzw, BC::y, vf0, vf10); // vmadday.xyzw acc, vf0, vf10 + c->vmadd_bc(DEST::xyzw, BC::x, vf10, vf0, vf10); // vmaddx.xyzw vf10, vf0, vf10 + c->vmula_bc(DEST::xyzw, BC::w, vf3, vf0); // vmulaw.xyzw acc, vf3, vf0 + c->vmadd_bc(DEST::xyzw, BC::x, vf3, vf1, vf13); // vmaddx.xyzw vf3, vf1, vf13 + c->mov128_gpr_vf(t9, vf10); // qmfc2.i t9, vf10 + c->pcpyud(t9, t9, r0); // pcpyud t9, t9, r0 + if (((s64)c->sgpr64(t9)) < 0) { // bltzl t9, L42 + c->vsub(DEST::xyzw, vf4, vf15, vf4); // vsub.xyzw vf4, vf15, vf4 + next_block = 26; + break; + } + + case 26: + next_block = 27; + c->vmula_bc(DEST::xyzw, BC::w, vf6, vf0); // vmulaw.xyzw acc, vf6, vf0 + c->vmadd_bc(DEST::xyzw, BC::x, vf6, vf4, vf13); // vmaddx.xyzw vf6, vf4, vf13 + c->sqc2(vf3, 0, a0); // sqc2 vf3, 0(a0) + c->sqc2(vf6, 16, a0); // sqc2 vf6, 16(a0) + //beq r0, r0, L37 // beq r0, r0, L37 + // nop // sll r0, r0, 0 + next_block = 6; // branch always + + break; + + case 27: + next_block = 28; + c->ld(t9, 0, t4); // ld t9, 0(t4) + c->daddiu(t4, t4, 8); // daddiu t4, t4, 8 + c->lqc2(vf6, 16, a0); // lqc2 vf6, 16(a0) + c->pextlh(t9, t9, r0); // pextlh t9, t9, r0 + c->psraw(t9, t9, 16); // psraw t9, t9, 16 + c->mov128_vf_gpr(vf4, t9); // qmtc2.i vf4, t9 + c->vitof15(DEST::xyzw, vf4, vf4); // vitof15.xyzw vf4, vf4 + c->vmul(DEST::xyzw, vf10, vf4, vf6); // vmul.xyzw vf10, vf4, vf6 + c->vmula_bc(DEST::xyzw, BC::w, vf10, vf0); // vmulaw.xyzw acc, vf10, vf0 + c->vmadda_bc(DEST::xyzw, BC::z, vf0, vf10); // vmaddaz.xyzw acc, vf0, vf10 + c->vmadda_bc(DEST::xyzw, BC::y, vf0, vf10); // vmadday.xyzw acc, vf0, vf10 + c->vmadd_bc(DEST::xyzw, BC::x, vf10, vf0, vf10); // vmaddx.xyzw vf10, vf0, vf10 + c->mov128_gpr_vf(t9, vf10); // qmfc2.i t9, vf10 + c->pcpyud(t9, t9, r0); // pcpyud t9, t9, r0 + if (((s64)c->sgpr64(t9)) < 0) { // bltzl t9, L43 + c->vsub(DEST::xyzw, vf4, vf15, vf4); // vsub.xyzw vf4, vf15, vf4 + next_block = 29; + break; + } + + case 29: + next_block = 30; + c->vmula_bc(DEST::xyzw, BC::w, vf6, vf0); // vmulaw.xyzw acc, vf6, vf0 + c->vmadd_bc(DEST::xyzw, BC::x, vf6, vf4, vf13); // vmaddx.xyzw vf6, vf4, vf13 + c->sqc2(vf6, 16, a0); // sqc2 vf6, 16(a0) + //beq r0, r0, L37 // beq r0, r0, L37 + // nop // sll r0, r0, 0 + next_block = 6; // branch always + + break; + + case 30: + next_block = 31; + c->lw(s6, 0, t5); // lw s6, 0(t5) + c->daddiu(t5, t5, 4); // daddiu t5, t5, 4 + c->lh(gp, 0, t6); // lh gp, 0(t6) + c->daddiu(t6, t6, 2); // daddiu t6, t6, 2 + c->lqc2(vf3, 0, a0); // lqc2 vf3, 0(a0) + c->pextlw(s6, gp, s6); // pextlw s6, gp, s6 + c->pextlh(s6, s6, r0); // pextlh s6, s6, r0 + c->psraw(s6, s6, 16); // psraw s6, s6, 16 + c->mov128_vf_gpr(vf1, s6); // qmtc2.i vf1, s6 + c->vitof0(DEST::xyzw, vf1, vf1); // vitof0.xyzw vf1, vf1 + c->vmula_bc(DEST::xyzw, BC::w, vf3, vf0); // vmulaw.xyzw acc, vf3, vf0 + c->vmadd_bc(DEST::xyzw, BC::y, vf3, vf1, vf13); // vmaddy.xyzw vf3, vf1, vf13 + c->sqc2(vf3, 0, a0); // sqc2 vf3, 0(a0) + //beq r0, r0, L37 // beq r0, r0, L37 + // nop // sll r0, r0, 0 + next_block = 6; // branch always + + break; + + case 31: + next_block = 32; + c->ld(s6, 0, t4); // ld s6, 0(t4) + c->daddiu(t4, t4, 8); // daddiu t4, t4, 8 + c->lw(gp, 0, t5); // lw gp, 0(t5) + c->daddiu(t5, t5, 4); // daddiu t5, t5, 4 + c->lqc2(vf3, 0, a0); // lqc2 vf3, 0(a0) + c->pcpyld(s6, gp, s6); // pcpyld s6, gp, s6 + c->mov128_vf_gpr(vf1, s6); // qmtc2.i vf1, s6 + c->vmula_bc(DEST::xyzw, BC::w, vf3, vf0); // vmulaw.xyzw acc, vf3, vf0 + c->vmadd_bc(DEST::xyzw, BC::x, vf3, vf1, vf13); // vmaddx.xyzw vf3, vf1, vf13 + c->sqc2(vf3, 0, a0); // sqc2 vf3, 0(a0) + //beq r0, r0, L37 // beq r0, r0, L37 + // nop // sll r0, r0, 0 + next_block = 6; // branch always + + break; + + case 32: + next_block = 33; + c->lq(a0, 0, sp); // lq a0, 0(sp) + // nop // sll r0, r0, 0 + //jr ra // jr ra + c->daddiu(sp, sp, 16); // daddiu sp, sp, 16 + goto end_of_function; // return + + //jr ra // jr ra + c->daddu(sp, sp, r0); // daddu sp, sp, r0 + goto end_of_function; // return + + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + } + } + end_of_function: + return c->gprs[v0].du64[0]; +} + +u32 jump_table_vals[16] = { + 0x3ee6b6f9, // = 9 ^ 1055307504 + 0x3ee6b6ff, // = 15 ^ 1055307504 + 0x3ee6b6e2, // = 18 ^ 1055307504 + 0x3ee6b6e4, // = 20 ^ 1055307504 + 0x3ee6b6e5, // = 21 ^ 1055307504 + 0x3ee6b6eb, // = 27 ^ 1055307504 + 0x3ee6b6ee, // = 30 ^ 1055307504 + 0x3ee6b6f6, // = 6 ^ 1055307504 + 0x3ee6b6fc, // = 12 ^ 1055307504 + 0x3ee6b6ff, // = 15 ^ 1055307504 + 0x3ee6b6e3, // = 19 ^ 1055307504 + 0x3ee6b6e4, // = 20 ^ 1055307504 + 0x3ee6b6e8, // = 24 ^ 1055307504 + 0x3ee6b6eb, // = 27 ^ 1055307504 + 0x3ee6b6ef, // = 31 ^ 1055307504 + 0x3ee6b6f6, // = 6 ^ 1055307504 +}; + +} // namespace decompress_fixed_data_to_accumulator +} // namespace Mips2C + +//--------------------------MIPS2C--------------------- +#include "game/mips2c/mips2c_private.h" + +namespace Mips2C::jak2 { +namespace normalize_frame_quaternions { +u64 execute(void* ctxt) { + auto* c = (ExecutionContext*)ctxt; + bool bc = false; + c->daddiu(sp, sp, -16); // daddiu sp, sp, -16 + c->daddiu(s2, s2, -2); // daddiu s2, s2, -2 + c->sw(a0, 0, sp); // sw a0, 0(sp) + c->daddiu(a0, a0, 128); // daddiu a0, a0, 128 + + block_1: + c->lqc2(vf4, 16, a0); // lqc2 vf4, 16(a0) + c->lqc2(vf1, 0, a0); // lqc2 vf1, 0(a0) + c->lqc2(vf7, 32, a0); // lqc2 vf7, 32(a0) + c->vmul(DEST::xyzw, vf10, vf4, vf4); // vmul.xyzw vf10, vf4, vf4 + c->vmove(DEST::w, vf1, vf0); // vmove.w vf1, vf0 + c->vmove(DEST::w, vf7, vf0); // vmove.w vf7, vf0 + c->vmula_bc(DEST::xyzw, BC::w, vf0, vf10); // vmulaw.xyzw acc, vf0, vf10 + c->vmadda_bc(DEST::xyzw, BC::z, vf0, vf10); // vmaddaz.xyzw acc, vf0, vf10 + c->vmadda_bc(DEST::xyzw, BC::y, vf0, vf10); // vmadday.xyzw acc, vf0, vf10 + c->vmadd_bc(DEST::xyzw, BC::x, vf10, vf0, vf10); // vmaddx.xyzw vf10, vf0, vf10 + c->sqc2(vf1, 0, a0); // sqc2 vf1, 0(a0) + c->sqc2(vf7, 32, a0); // sqc2 vf7, 32(a0) + c->daddiu(a0, a0, 48); // daddiu a0, a0, 48 + c->vrsqrt(vf0, BC::w, vf10, BC::w); // vrsqrt Q, vf0.w, vf10.w + c->vwaitq(); // vwaitq + c->vmulq(DEST::xyzw, vf4, vf4); // vmulq.xyzw vf4, vf4, Q + c->daddiu(s2, s2, -1); // daddiu s2, s2, -1 + bc = c->sgpr64(s2) != 0; // bne s2, r0, L46 + c->sqc2(vf4, -32, a0); // sqc2 vf4, -32(a0) + if (bc) {goto block_1;} // branch non-likely + + c->lw(a0, 0, sp); // lw a0, 0(sp) + // nop // sll r0, r0, 0 + //jr ra // jr ra + c->daddiu(sp, sp, 16); // daddiu sp, sp, 16 + goto end_of_function; // return + + //jr ra // jr ra + c->daddu(sp, sp, r0); // daddu sp, sp, r0 + goto end_of_function; // return + + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + end_of_function: + return c->gprs[v0].du64[0]; +} + +} // namespace normalize_frame_quaternions +} // namespace Mips2C + +//--------------------------MIPS2C--------------------- +#include "game/mips2c/mips2c_private.h" + +namespace Mips2C::jak2 { +namespace clear_frame_accumulator { +u64 execute(void* ctxt) { + auto* c = (ExecutionContext*)ctxt; + bool bc = false; + c->daddiu(sp, sp, -16); // daddiu sp, sp, -16 + // nop // sll r0, r0, 0 + c->sw(a0, 0, sp); // sw a0, 0(sp) + // nop // sll r0, r0, 0 + c->sq(r0, 0, a0); // sq r0, 0(a0) + c->daddiu(s2, s2, -2); // daddiu s2, s2, -2 + c->sq(r0, 16, a0); // sq r0, 16(a0) + // nop // sll r0, r0, 0 + c->sq(r0, 32, a0); // sq r0, 32(a0) + // nop // sll r0, r0, 0 + c->sq(r0, 48, a0); // sq r0, 48(a0) + // nop // sll r0, r0, 0 + c->sq(r0, 64, a0); // sq r0, 64(a0) + // nop // sll r0, r0, 0 + c->sq(r0, 80, a0); // sq r0, 80(a0) + // nop // sll r0, r0, 0 + c->sq(r0, 96, a0); // sq r0, 96(a0) + // nop // sll r0, r0, 0 + c->sq(r0, 112, a0); // sq r0, 112(a0) + c->daddiu(a0, a0, 128); // daddiu a0, a0, 128 + + block_1: + c->sq(r0, 0, a0); // sq r0, 0(a0) + c->daddiu(s2, s2, -1); // daddiu s2, s2, -1 + c->sq(r0, 16, a0); // sq r0, 16(a0) + c->daddiu(a0, a0, 48); // daddiu a0, a0, 48 + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + bc = c->sgpr64(s2) != 0; // bne s2, r0, L48 + c->sq(r0, -16, a0); // sq r0, -16(a0) + if (bc) {goto block_1;} // branch non-likely + + c->lw(a0, 0, sp); // lw a0, 0(sp) + // nop // sll r0, r0, 0 + //jr ra // jr ra + c->daddiu(sp, sp, 16); // daddiu sp, sp, 16 + goto end_of_function; // return + + //jr ra // jr ra + c->daddu(sp, sp, r0); // daddu sp, sp, r0 + goto end_of_function; // return + + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + end_of_function: + return c->gprs[v0].du64[0]; +} +} // namespace clear_frame_accumulator +} // namespace Mips2C + + +//--------------------------MIPS2C--------------------- +#include "game/mips2c/mips2c_private.h" + +namespace Mips2C::jak2 { +namespace calc_animation_from_spr { + + +u64 execute(void* ctxt) { + auto* c = (ExecutionContext*)ctxt; + bool bc = false; + u32 call_addr = 0; + u32 madr, sadr, qwc; + c->mov64(v1, a1); // or v1, a1, r0 + c->daddiu(sp, sp, -192); // daddiu sp, sp, -192 + c->sq(s0, 0, sp); // sq s0, 0(sp) + c->sq(s1, 16, sp); // sq s1, 16(sp) + c->sq(s2, 32, sp); // sq s2, 32(sp) + c->sq(s3, 48, sp); // sq s3, 48(sp) + c->sq(s4, 64, sp); // sq s4, 64(sp) + c->sq(s5, 80, sp); // sq s5, 80(sp) + c->sq(s6, 96, sp); // sq s6, 96(sp) + c->sq(t8, 112, sp); // sq t8, 112(sp) + c->sq(t9, 128, sp); // sq t9, 128(sp) + c->sq(gp, 144, sp); // sq gp, 144(sp) + c->sq(fp, 160, sp); // sq fp, 160(sp) + c->sq(ra, 176, sp); // sq ra, 176(sp) + c->daddiu(sp, sp, -16); // daddiu sp, sp, -16 + c->mov128_vf_gpr(vf15, r0); // qmtc2.i vf15, r0 + c->sw(a1, 0, sp); // sw a1, 0(sp) + //c->lui(v1, 28672); // lui v1, 28672 + get_fake_spad_addr(v1, cache.fake_scratchpad_data, 0, c); + c->lw(s1, 2384, v1); // lw s1, 2400(v1) + c->daddiu(t7, v1, 1808); // daddiu t7, v1, 1824 + c->lui(s0, 4096); // lui s0, 4096 + c->daddiu(t1, v1, 7328); // daddiu t1, v1, 7344 + bc = c->sgpr64(s1) == 0; // beq s1, r0, L7 + c->ori(s0, s0, 54272); // ori s0, s0, 54272 // spr to (d400) + if (bc) {goto block_12;} // branch non-likely + + c->lw(t2, 0, t7); // lw t2, 0(t7) + c->addiu(t3, r0, 7392); // addiu t3, r0, 7408 + c->lw(t4, 4, t7); // lw t4, 4(t7) + c->addiu(v1, r0, 256); // addiu v1, r0, 256 + // c->sw(t2, 16, s0); // sw t2, 16(s0) + madr = c->sgpr64(t2); + c->vadd_bc(DEST::xyzw, BC::w, vf14, vf15, vf0); // vaddw.xyzw vf14, vf15, vf0 + //c->sw(t3, 128, s0); // sw t3, 128(s0) + sadr = c->sgpr64(t3); + // nop // sll r0, r0, 0 + //c->sw(t4, 32, s0); // sw t4, 32(s0) + qwc = c->sgpr64(t4); + // Unknown instr: sync.l + //c->sw(v1, 0, s0); // sw v1, 0(s0) + spad_to_dma_no_sadr_off(cache.fake_scratchpad_data, madr, sadr, qwc); + // Unknown instr: sync.l + c->load_symbol(t9, cache.clear_frame_accumulator);// lw t9, clear-frame-accumulator(s7) + c->vadd(DEST::yz, vf14, vf14, vf14); // vadd.yz vf14, vf14, vf14 + c->lw(s2, 0, sp); // lw s2, 0(sp) + // nop // sll r0, r0, 0 + call_addr = c->gprs[t9].du32[0]; // function call: + c->vadd(DEST::yz, vf14, vf14, vf14); // vadd.yz vf14, vf14, vf14 + //c->jalr(call_addr); // jalr ra, t9 + clear_frame_accumulator::execute(c); + + block_2: +// c->lw(v1, 0, s0); // lw v1, 0(s0) +// // nop // sll r0, r0, 0 +// c->andi(v1, v1, 256); // andi v1, v1, 256 +// // nop // sll r0, r0, 0 +// // nop // sll r0, r0, 0 +// // nop // sll r0, r0, 0 +// bc = c->sgpr64(v1) != 0; // bne v1, r0, L3 +// // nop // sll r0, r0, 0 +// if (bc) {goto block_2;} // branch non-likely + + c->lw(t2, 8, t7); // lw t2, 8(t7) + c->addiu(t3, r0, 9600); // addiu t3, r0, 9616 + c->lw(t4, 12, t7); // lw t4, 12(t7) + c->addiu(v1, r0, 256); // addiu v1, r0, 256 + //c->sw(t2, 16, s0); // sw t2, 16(s0) + madr = c->sgpr64(t2); + // nop // sll r0, r0, 0 + //c->sw(t3, 128, s0); // sw t3, 128(s0) + sadr = c->sgpr64(t3); + // nop // sll r0, r0, 0 + //c->sw(t4, 32, s0); // sw t4, 32(s0) + qwc = c->sgpr64(t4); + // Unknown instr: sync.l + //c->sw(v1, 0, s0); // sw v1, 0(s0) + spad_to_dma_no_sadr_off(cache.fake_scratchpad_data, madr, sadr, qwc); + // Unknown instr: sync.l + c->lw(a2, 16, t7); // lw a2, 16(t7) + //c->lui(a1, 28672); // lui a1, 28672 + get_fake_spad_addr(a1, cache.fake_scratchpad_data, 0, c); + c->load_symbol(t9, cache.decompress_fixed_data_to_accumulator);// lw t9, decompress-fixed-data-to-accumulator(s7) + c->daddiu(a1, a1, 7392); // daddiu a1, a1, 7408 + call_addr = c->gprs[t9].du32[0]; // function call: + c->daddiu(s1, s1, -1); // daddiu s1, s1, -1 + //c->jalr(call_addr); // jalr ra, t9 + decompress_fixed_data_to_accumulator::execute(c); + +// block_4: +// c->lw(v1, 0, s0); // lw v1, 0(s0) +// // nop // sll r0, r0, 0 +// c->andi(v1, v1, 256); // andi v1, v1, 256 +// // nop // sll r0, r0, 0 +// // nop // sll r0, r0, 0 +// // nop // sll r0, r0, 0 +// bc = c->sgpr64(v1) != 0; // bne v1, r0, L4 +// // nop // sll r0, r0, 0 +// if (bc) {goto block_4;} // branch non-likely + + bc = c->sgpr64(s1) == 0; // beq s1, r0, L5 + // nop // sll r0, r0, 0 + if (bc) {goto block_7;} // branch non-likely + + c->lw(t2, 24, t7); // lw t2, 24(t7) + c->addiu(t3, r0, 7392); // addiu t3, r0, 7408 + c->lw(t4, 28, t7); // lw t4, 28(t7) + c->addiu(v1, r0, 256); // addiu v1, r0, 256 + //c->sw(t2, 16, s0); // sw t2, 16(s0) + madr = c->sgpr64(t2); + // nop // sll r0, r0, 0 + //c->sw(t3, 128, s0); // sw t3, 128(s0) + sadr = c->sgpr64(t3); + // nop // sll r0, r0, 0 + //c->sw(t4, 32, s0); // sw t4, 32(s0) + qwc = c->sgpr64(t4); + // Unknown instr: sync.l + //c->sw(v1, 0, s0); // sw v1, 0(s0) + spad_to_dma_no_sadr_off(cache.fake_scratchpad_data, madr, sadr, qwc); + // Unknown instr: sync.l + + block_7: + c->lw(t0, 20, t7); // lw t0, 20(t7) + //c->lui(a1, 28672); // lui a1, 28672 + get_fake_spad_addr(a1, cache.fake_scratchpad_data, 0, c); + c->lw(a2, 16, t7); // lw a2, 16(t7) + c->daddiu(a1, a1, 9600); // daddiu a1, a1, 9616 + bc = c->sgpr64(t0) == 0; // beq t0, r0, L6 + // nop // sll r0, r0, 0 + if (bc) {goto block_10;} // branch non-likely + + c->lw(a3, 12, t7); // lw a3, 12(t7) + // nop // sll r0, r0, 0 + c->load_symbol(t9, cache.decompress_frame_data_pair_to_accumulator);// lw t9, decompress-frame-data-pair-to-accumulator(s7) + // nop // sll r0, r0, 0 + call_addr = c->gprs[t9].du32[0]; // function call: + c->sll(a3, a3, 3); // sll a3, a3, 3 + //c->jalr(call_addr); // jalr ra, t9 + decompress_frame_data_pair_to_accumulator::execute(c); + bc = c->sgpr64(s1) != 0; // bne s1, r0, L3 + c->daddiu(t7, t7, 24); // daddiu t7, t7, 24 + if (bc) {goto block_2;} // branch non-likely + + c->load_symbol(t9, cache.normalize_frame_quaternions);// lw t9, normalize-frame-quaternions(s7) + // nop // sll r0, r0, 0 + c->lw(s2, 0, sp); // lw s2, 0(sp) + // nop // sll r0, r0, 0 + call_addr = c->gprs[t9].du32[0]; // function call: + // nop // sll r0, r0, 0 + //c->jalr(call_addr); // jalr ra, t9 + normalize_frame_quaternions::execute(c); + c->daddiu(sp, sp, 16); // daddiu sp, sp, 16 + // nop // sll r0, r0, 0 + c->lq(s0, 0, sp); // lq s0, 0(sp) + c->lq(s1, 16, sp); // lq s1, 16(sp) + c->lq(s2, 32, sp); // lq s2, 32(sp) + c->lq(s3, 48, sp); // lq s3, 48(sp) + c->lq(s4, 64, sp); // lq s4, 64(sp) + c->lq(s5, 80, sp); // lq s5, 80(sp) + c->lq(s6, 96, sp); // lq s6, 96(sp) + c->lq(t8, 112, sp); // lq t8, 112(sp) + c->lq(t9, 128, sp); // lq t9, 128(sp) + c->lq(gp, 144, sp); // lq gp, 144(sp) + c->lq(ra, 176, sp); // lq ra, 176(sp) + c->lq(fp, 160, sp); // lq fp, 160(sp) + //jr ra // jr ra + c->daddiu(sp, sp, 192); // daddiu sp, sp, 192 + goto end_of_function; // return + + + block_10: + c->load_symbol(t9, cache.decompress_frame_data_to_accumulator);// lw t9, decompress-frame-data-to-accumulator(s7) + // nop // sll r0, r0, 0 + call_addr = c->gprs[t9].du32[0]; // function call: + // nop // sll r0, r0, 0 + //c->jalr(call_addr); // jalr ra, t9 + decompress_frame_data_to_accumulator::execute(c); + bc = c->sgpr64(s1) != 0; // bne s1, r0, L3 + c->daddiu(t7, t7, 24); // daddiu t7, t7, 24 + if (bc) {goto block_2;} // branch non-likely + + c->load_symbol(t9, cache.normalize_frame_quaternions);// lw t9, normalize-frame-quaternions(s7) + // nop // sll r0, r0, 0 + c->lw(s2, 0, sp); // lw s2, 0(sp) + // nop // sll r0, r0, 0 + call_addr = c->gprs[t9].du32[0]; // function call: + // nop // sll r0, r0, 0 + //c->jalr(call_addr); // jalr ra, t9 + normalize_frame_quaternions::execute(c); + + block_12: + c->daddiu(sp, sp, 16); // daddiu sp, sp, 16 + // nop // sll r0, r0, 0 + c->lq(s0, 0, sp); // lq s0, 0(sp) + c->lq(s1, 16, sp); // lq s1, 16(sp) + c->lq(s2, 32, sp); // lq s2, 32(sp) + c->lq(s3, 48, sp); // lq s3, 48(sp) + c->lq(s4, 64, sp); // lq s4, 64(sp) + c->lq(s5, 80, sp); // lq s5, 80(sp) + c->lq(s6, 96, sp); // lq s6, 96(sp) + c->lq(t8, 112, sp); // lq t8, 112(sp) + c->lq(t9, 128, sp); // lq t9, 128(sp) + c->lq(gp, 144, sp); // lq gp, 144(sp) + c->lq(ra, 176, sp); // lq ra, 176(sp) + c->lq(fp, 160, sp); // lq fp, 160(sp) + //jr ra // jr ra + c->daddiu(sp, sp, 192); // daddiu sp, sp, 192 + goto end_of_function; // return + + //jr ra // jr ra + c->daddu(sp, sp, r0); // daddu sp, sp, r0 + goto end_of_function; // return + + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + end_of_function: + return c->gprs[v0].du64[0]; +} + +void link() { + cache.clear_frame_accumulator = intern_from_c("clear-frame-accumulator").c(); + cache.decompress_fixed_data_to_accumulator = intern_from_c("decompress-fixed-data-to-accumulator").c(); + cache.decompress_frame_data_pair_to_accumulator = intern_from_c("decompress-frame-data-pair-to-accumulator").c(); + cache.decompress_frame_data_to_accumulator = intern_from_c("decompress-frame-data-to-accumulator").c(); + cache.normalize_frame_quaternions = intern_from_c("normalize-frame-quaternions").c(); + cache.fake_scratchpad_data = intern_from_c("*fake-scratchpad-data*").c(); + + gLinkedFunctionTable.reg("calc-animation-from-spr", execute, 1024); +} + +} // namespace calc_animation_from_spr +} // namespace Mips2C + +//--------------------------MIPS2C--------------------- +#include "game/mips2c/mips2c_private.h" + +namespace Mips2C::jak2 { +namespace cspace_parented_transformq_joint { +u64 execute(void* ctxt) { + auto* c = (ExecutionContext*)ctxt; + bool bc = false; + // nop // sll r0, r0, 0 + c->lw(a3, 0, a0); // lw a3, 0(a0) + c->lui(v1, 16256); // lui v1, 16256 + c->lqc2(vf5, 16, a1); // lqc2 vf5, 16(a1) + c->mtc1(f0, v1); // mtc1 f0, v1 + c->lw(t0, 16, a3); // lw t0, 16(a3) + // nop // sll r0, r0, 0 + c->lw(a2, 16, a0); // lw a2, 16(a0) + c->vadd(DEST::xyzw, vf6, vf5, vf5); // vadd.xyzw vf6, vf5, vf5 + c->lwc1(f1, 64, t0); // lwc1 f1, 64(t0) + c->vadd_bc(DEST::x, BC::w, vf2, vf0, vf5); // vaddw.x vf2, vf0, vf5 + c->lqc2(vf15, 0, a1); // lqc2 vf15, 0(a1) + c->vadd_bc(DEST::y, BC::z, vf2, vf0, vf5); // vaddz.y vf2, vf0, vf5 + c->lqc2(vf1, 32, a1); // lqc2 vf1, 32(a1) + c->divs_accurate(f4, f0, f1); // div.s f4, f0, f1 + c->lqc2(vf7, 0, t0); // lqc2 vf7, 0(t0) + c->vsub_bc(DEST::z, BC::y, vf2, vf0, vf5); // vsuby.z vf2, vf0, vf5 + c->lqc2(vf8, 16, t0); // lqc2 vf8, 16(t0) + c->vsub_bc(DEST::w, BC::w, vf2, vf0, vf0); // vsubw.w vf2, vf0, vf0 + c->lqc2(vf9, 32, t0); // lqc2 vf9, 32(t0) + c->vsub_bc(DEST::x, BC::z, vf3, vf0, vf5); // vsubz.x vf3, vf0, vf5 + c->lqc2(vf10, 48, t0); // lqc2 vf10, 48(t0) + c->vadd_bc(DEST::y, BC::w, vf3, vf0, vf5); // vaddw.y vf3, vf0, vf5 + c->lwc1(f2, 68, t0); // lwc1 f2, 68(t0) + c->vadd_bc(DEST::z, BC::x, vf3, vf0, vf5); // vaddx.z vf3, vf0, vf5 + c->sqc2(vf1, 64, a2); // sqc2 vf1, 64(a2) + c->vsub_bc(DEST::w, BC::w, vf3, vf0, vf0); // vsubw.w vf3, vf0, vf0 + c->lwc1(f3, 72, t0); // lwc1 f3, 72(t0) + c->vadd_bc(DEST::x, BC::y, vf4, vf0, vf5); // vaddy.x vf4, vf0, vf5 + c->lw(v1, 76, t0); // lw v1, 76(t0) + c->vsub_bc(DEST::y, BC::x, vf4, vf0, vf5); // vsubx.y vf4, vf0, vf5 + c->mfc1(t1, f4); // mfc1 t1, f4 + c->vadd_bc(DEST::z, BC::w, vf4, vf0, vf5); // vaddw.z vf4, vf0, vf5 + c->divs_accurate(f4, f0, f2); // div.s f4, f0, f2 + c->vsub_bc(DEST::w, BC::w, vf4, vf0, vf0); // vsubw.w vf4, vf0, vf0 + c->vopmula(vf6, vf2); // vopmula.xyz acc, vf6, vf2 + c->vopmsub(vf2, vf2, vf6); // vopmsub.xyz vf2, vf2, vf6 + c->vopmula(vf6, vf3); // vopmula.xyz acc, vf6, vf3 + c->vopmsub(vf3, vf3, vf6); // vopmsub.xyz vf3, vf3, vf6 + c->vopmula(vf6, vf4); // vopmula.xyz acc, vf6, vf4 + c->vopmsub(vf4, vf4, vf6); // vopmsub.xyz vf4, vf4, vf6 + c->vadd_bc(DEST::x, BC::w, vf2, vf2, vf0); // vaddw.x vf2, vf2, vf0 + c->vadd_bc(DEST::y, BC::w, vf3, vf3, vf0); // vaddw.y vf3, vf3, vf0 + c->vadd_bc(DEST::z, BC::w, vf4, vf4, vf0); // vaddw.z vf4, vf4, vf0 + c->mfc1(t2, f4); // mfc1 t2, f4 + bc = c->sgpr64(v1) != 0; // bne v1, r0, L50 + c->divs_accurate(f4, f0, f3); // div.s f4, f0, f3 + if (bc) {goto block_2;} // branch non-likely + + c->vmul_bc(DEST::xyzw, BC::x, vf2, vf2, vf1); // vmulx.xyzw vf2, vf2, vf1 + c->vmul_bc(DEST::xyzw, BC::y, vf3, vf3, vf1); // vmuly.xyzw vf3, vf3, vf1 + c->vmul_bc(DEST::xyzw, BC::z, vf4, vf4, vf1); // vmulz.xyzw vf4, vf4, vf1 + c->vmula_bc(DEST::xyzw, BC::x, vf7, vf2); // vmulax.xyzw acc, vf7, vf2 + c->vmadda_bc(DEST::xyzw, BC::y, vf8, vf2); // vmadday.xyzw acc, vf8, vf2 + c->vmadda_bc(DEST::xyzw, BC::z, vf9, vf2); // vmaddaz.xyzw acc, vf9, vf2 + c->vmadd_bc(DEST::xyzw, BC::w, vf11, vf10, vf2); // vmaddw.xyzw vf11, vf10, vf2 + c->vmula_bc(DEST::xyzw, BC::x, vf7, vf3); // vmulax.xyzw acc, vf7, vf3 + c->vmadda_bc(DEST::xyzw, BC::y, vf8, vf3); // vmadday.xyzw acc, vf8, vf3 + c->vmadda_bc(DEST::xyzw, BC::z, vf9, vf3); // vmaddaz.xyzw acc, vf9, vf3 + c->vmadd_bc(DEST::xyzw, BC::w, vf12, vf10, vf3); // vmaddw.xyzw vf12, vf10, vf3 + c->vmula_bc(DEST::xyzw, BC::x, vf7, vf4); // vmulax.xyzw acc, vf7, vf4 + c->vmadda_bc(DEST::xyzw, BC::y, vf8, vf4); // vmadday.xyzw acc, vf8, vf4 + c->vmadda_bc(DEST::xyzw, BC::z, vf9, vf4); // vmaddaz.xyzw acc, vf9, vf4 + c->vmadd_bc(DEST::xyzw, BC::w, vf13, vf10, vf4); // vmaddw.xyzw vf13, vf10, vf4 + c->vmula_bc(DEST::xyzw, BC::x, vf7, vf15); // vmulax.xyzw acc, vf7, vf15 + c->vmadda_bc(DEST::xyzw, BC::y, vf8, vf15); // vmadday.xyzw acc, vf8, vf15 + c->vmadda_bc(DEST::xyzw, BC::z, vf9, vf15); // vmaddaz.xyzw acc, vf9, vf15 + c->vmadd_bc(DEST::xyzw, BC::w, vf14, vf10, vf0); // vmaddw.xyzw vf14, vf10, vf0 + c->sqc2(vf11, 0, a2); // sqc2 vf11, 0(a2) + c->sqc2(vf12, 16, a2); // sqc2 vf12, 16(a2) + c->sqc2(vf13, 32, a2); // sqc2 vf13, 32(a2) + c->sqc2(vf14, 48, a2); // sqc2 vf14, 48(a2) + //jr ra // jr ra + // nop // sll r0, r0, 0 + goto end_of_function; // return + + + block_2: + c->pextlw(t1, t2, t1); // pextlw t1, t2, t1 + c->vmul_bc(DEST::xyzw, BC::x, vf2, vf2, vf1); // vmulx.xyzw vf2, vf2, vf1 + c->vmul_bc(DEST::xyzw, BC::y, vf3, vf3, vf1); // vmuly.xyzw vf3, vf3, vf1 + c->vmul_bc(DEST::xyzw, BC::z, vf4, vf4, vf1); // vmulz.xyzw vf4, vf4, vf1 + c->mfc1(t3, f4); // mfc1 t3, f4 + c->pcpyld(t1, t3, t1); // pcpyld t1, t3, t1 + c->mov128_vf_gpr(vf16, t1); // qmtc2.i vf16, t1 + c->vmul(DEST::xyzw, vf2, vf2, vf16); // vmul.xyzw vf2, vf2, vf16 + c->vmul(DEST::xyzw, vf3, vf3, vf16); // vmul.xyzw vf3, vf3, vf16 + c->vmul(DEST::xyzw, vf4, vf4, vf16); // vmul.xyzw vf4, vf4, vf16 + c->vmula_bc(DEST::xyzw, BC::x, vf7, vf2); // vmulax.xyzw acc, vf7, vf2 + c->vmadda_bc(DEST::xyzw, BC::y, vf8, vf2); // vmadday.xyzw acc, vf8, vf2 + c->vmadda_bc(DEST::xyzw, BC::z, vf9, vf2); // vmaddaz.xyzw acc, vf9, vf2 + c->vmadd_bc(DEST::xyzw, BC::w, vf11, vf10, vf2); // vmaddw.xyzw vf11, vf10, vf2 + c->vmula_bc(DEST::xyzw, BC::x, vf7, vf3); // vmulax.xyzw acc, vf7, vf3 + c->vmadda_bc(DEST::xyzw, BC::y, vf8, vf3); // vmadday.xyzw acc, vf8, vf3 + c->vmadda_bc(DEST::xyzw, BC::z, vf9, vf3); // vmaddaz.xyzw acc, vf9, vf3 + c->vmadd_bc(DEST::xyzw, BC::w, vf12, vf10, vf3); // vmaddw.xyzw vf12, vf10, vf3 + c->vmula_bc(DEST::xyzw, BC::x, vf7, vf4); // vmulax.xyzw acc, vf7, vf4 + c->vmadda_bc(DEST::xyzw, BC::y, vf8, vf4); // vmadday.xyzw acc, vf8, vf4 + c->vmadda_bc(DEST::xyzw, BC::z, vf9, vf4); // vmaddaz.xyzw acc, vf9, vf4 + c->vmadd_bc(DEST::xyzw, BC::w, vf13, vf10, vf4); // vmaddw.xyzw vf13, vf10, vf4 + c->vmula_bc(DEST::xyzw, BC::x, vf7, vf15); // vmulax.xyzw acc, vf7, vf15 + c->vmadda_bc(DEST::xyzw, BC::y, vf8, vf15); // vmadday.xyzw acc, vf8, vf15 + c->vmadda_bc(DEST::xyzw, BC::z, vf9, vf15); // vmaddaz.xyzw acc, vf9, vf15 + c->vmadd_bc(DEST::xyzw, BC::w, vf14, vf10, vf0); // vmaddw.xyzw vf14, vf10, vf0 + c->sqc2(vf11, 0, a2); // sqc2 vf11, 0(a2) + c->sqc2(vf12, 16, a2); // sqc2 vf12, 16(a2) + c->sqc2(vf13, 32, a2); // sqc2 vf13, 32(a2) + c->sqc2(vf14, 48, a2); // sqc2 vf14, 48(a2) + //jr ra // jr ra + // nop // sll r0, r0, 0 + goto end_of_function; // return + + //jr ra // jr ra + c->daddu(sp, sp, r0); // daddu sp, sp, r0 + goto end_of_function; // return + + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + end_of_function: + return c->gprs[v0].du64[0]; +} + +void link() { + gLinkedFunctionTable.reg("cspace<-parented-transformq-joint!", execute, 128); +} + +} // namespace cspace<_parented_transformq_joint +} // namespace Mips2C +// add cspace<_parented_transformq_joint::link to the link callback table for the object file. +// FWD DEC: + + +namespace normalize_frame_quaternions { extern void link(); } + +namespace decompress_fixed_data_to_accumulator { extern void link(); } +namespace decompress_frame_data_to_accumulator { extern void link(); } + + +namespace decompress_frame_data_pair_to_accumulator { extern void link(); } diff --git a/game/mips2c/mips2c_table.cpp b/game/mips2c/mips2c_table.cpp index e18278cbf9..d8347b93b2 100644 --- a/game/mips2c/mips2c_table.cpp +++ b/game/mips2c/mips2c_table.cpp @@ -117,6 +117,9 @@ namespace generic_tie_convert { extern void link(); } namespace jak2 { namespace collide_do_primitives { extern void link(); } namespace moving_sphere_triangle_intersect { extern void link(); } +namespace calc_animation_from_spr { extern void link(); } +namespace cspace_parented_transformq_joint { extern void link(); } + } // clang-format on @@ -194,7 +197,10 @@ PerGameVersion>> gMips2C {"generic-tie", {jak1::generic_tie_dma_to_spad_sync::link, jak1::generic_tie_convert::link}}}, /////////// JAK 2 {{"collide-func", - {jak2::collide_do_primitives::link, jak2::moving_sphere_triangle_intersect::link}}}}; + {jak2::collide_do_primitives::link, jak2::moving_sphere_triangle_intersect::link}}, + {"joint", + {jak2::calc_animation_from_spr::link, jak2::cspace_parented_transformq_joint::link}}}, +}; void LinkedFunctionTable::reg(const std::string& name, u64 (*exec)(void*), u32 stack_size) { const auto& it = m_executes.insert({name, {exec, Ptr()}}); diff --git a/goal_src/jak2/engine/anim/joint-h.gc b/goal_src/jak2/engine/anim/joint-h.gc index 9c954fbab5..115234754c 100644 --- a/goal_src/jak2/engine/anim/joint-h.gc +++ b/goal_src/jak2/engine/anim/joint-h.gc @@ -34,18 +34,18 @@ ;; DECOMP BEGINS (deftype joint-control-channel (structure) - ((parent joint-control :offset-assert 0) - (frame-group art-joint-anim :offset-assert 4) - (frame-num float :offset-assert 8) - (dist meters :offset-assert 12) - (num-func (function joint-control-channel float float float) :offset-assert 16) - (param float 3 :offset-assert 20) - (frame-interp float 2 :offset-assert 32) - (inspector-amount uint8 :offset-assert 40) - (command joint-control-command :offset-assert 48) - (group-sub-index int8 :offset-assert 56) - (grou-size int8 :offset-assert 57) - (eval-time uint32 :offset-assert 60) + ((parent joint-control :offset-assert 0) + (frame-group art-joint-anim :offset-assert 4) + (frame-num float :offset-assert 8) + (dist meters :offset-assert 12) + (num-func (function joint-control-channel float float float float) :offset-assert 16) + (param float 3 :offset-assert 20) + (frame-interp float 2 :offset-assert 32) + (inspector-amount uint8 :offset-assert 40) + (command joint-control-command :offset-assert 48) + (group-sub-index int8 :offset-assert 56) + (group-size int8 :offset-assert 57) + (eval-time uint32 :offset-assert 60) ) :method-count-assert 9 :size-assert #x40 @@ -105,9 +105,10 @@ :size-assert #x40 :flag-assert #xc00000040 (:methods + (new (symbol type int) _type_ 0) (joint-control-method-9 () none 9) (joint-control-method-10 () none 10) - (joint-control-method-11 () none 11) + (debug-print-channels (_type_ symbol) int 11) ) ) diff --git a/goal_src/jak2/engine/anim/joint.gc b/goal_src/jak2/engine/anim/joint.gc index 66e6a03913..45740a6947 100644 --- a/goal_src/jak2/engine/anim/joint.gc +++ b/goal_src/jak2/engine/anim/joint.gc @@ -5,5 +5,1785 @@ ;; name in dgo: joint ;; dgos: ENGINE, GAME +(define-extern create-interpolated-joint-animation-frame (function joint-anim-frame int joint-control int)) +(define-extern *anim-manager* art-joint-anim-manager) + ;; DECOMP BEGINS +(defmethod print joint ((obj joint)) + (format #t "#<~A ~S ~D @ #x~X>" (-> obj type) (-> obj name) (-> obj number) obj) + obj + ) + +(defmethod mem-usage joint ((obj joint) (arg0 memory-usage-block) (arg1 int)) + (set! (-> arg0 length) (max 68 (-> arg0 length))) + (set! (-> arg0 data 67 name) "joint") + (+! (-> arg0 data 67 count) 1) + (let ((v1-6 (asize-of obj))) + (+! (-> arg0 data 67 used) v1-6) + (+! (-> arg0 data 67 total) (logand -16 (+ v1-6 15))) + ) + obj + ) + +(defmethod print joint-anim ((obj joint-anim)) + (format #t "#<~A ~S ~D [~D] @ #x~X>" (-> obj type) (-> obj name) (-> obj number) (-> obj length) obj) + obj + ) + +(defmethod length joint-anim ((obj joint-anim)) + (-> obj length) + ) + +(defmethod asize-of joint-anim-matrix ((obj joint-anim-matrix)) + (the-as int (+ (-> joint-anim-matrix size) (* (-> obj length) 64))) + ) + +(defmethod asize-of joint-anim-transformq ((obj joint-anim-transformq)) + (the-as int (+ (-> joint-anim-transformq size) (* 48 (-> obj length)))) + ) + +(defmethod asize-of joint-anim-drawable ((obj joint-anim-drawable)) + (the-as int (+ (-> joint-anim-drawable size) (* (-> obj length) 4))) + ) + +(defun joint-anim-login ((arg0 joint-anim-drawable)) + (dotimes (s5-0 (-> arg0 length)) + (if (-> arg0 data s5-0) + (login (-> arg0 data s5-0)) + ) + ) + arg0 + ) + +(defun joint-anim-inspect-elt ((arg0 joint-anim) (arg1 float)) + (case (-> arg0 type) + ((joint-anim-matrix) + (inspect (-> (the-as joint-anim-matrix arg0) data (the int arg1))) + ) + ((joint-anim-transformq) + (format #t "~`transform`P~%" (-> (the-as joint-anim-transformq arg0) data (the int arg1))) + ) + ) + arg0 + ) + +(defmethod mem-usage joint-anim-drawable ((obj joint-anim-drawable) (arg0 memory-usage-block) (arg1 int)) + (set! (-> arg0 length) (max 80 (-> arg0 length))) + (set! (-> arg0 data 79 name) "joint-anim-drawable") + (+! (-> arg0 data 79 count) 1) + (let ((v1-6 (asize-of obj))) + (+! (-> arg0 data 79 used) v1-6) + (+! (-> arg0 data 79 total) (logand -16 (+ v1-6 15))) + ) + (dotimes (s3-0 (-> obj length)) + (mem-usage (-> obj data s3-0) arg0 arg1) + ) + obj + ) + +(defun jacc-mem-usage ((arg0 joint-anim-compressed-control) (arg1 memory-usage-block) (arg2 int)) + (set! (-> arg1 length) (max 70 (-> arg1 length))) + (set! (-> arg1 data 69 name) "joint-anim-compressed-control") + (+! (-> arg1 data 69 count) 1) + (let ((v1-7 (+ (* (-> arg0 num-frames) 4) 16))) + (+! (-> arg1 data 69 used) v1-7) + (+! (-> arg1 data 69 total) (logand -16 (+ v1-7 15))) + ) + (set! (-> arg1 length) (max 71 (-> arg1 length))) + (set! (-> arg1 data 70 name) "joint-anim-fixed") + (+! (-> arg1 data 70 count) 1) + (let ((v1-17 (+ (-> arg0 fixed-qwc) 16))) + (+! (-> arg1 data 70 used) v1-17) + (+! (-> arg1 data 70 total) (logand -16 (+ v1-17 15))) + ) + (dotimes (v1-21 (the-as int (-> arg0 num-frames))) + (set! (-> arg1 length) (max 72 (-> arg1 length))) + (set! (-> arg1 data 71 name) "joint-anim-frame") + (+! (-> arg1 data 71 count) 1) + (let ((a2-15 (* (-> arg0 frame-qwc) 16))) + (+! (-> arg1 data 71 used) a2-15) + (+! (-> arg1 data 71 total) (logand -16 (+ a2-15 15))) + ) + ) + arg0 + ) + +(defmethod print joint-control-channel ((obj joint-control-channel)) + (let ((t9-0 format) + (a0-1 #t) + (a1-0 "#") + (v1-0 (-> obj command)) + ) + (t9-0 + a0-1 + a1-0 + (cond + ((= v1-0 (joint-control-command stack1)) + "stack1" + ) + ((= v1-0 (joint-control-command push)) + "push" + ) + ((= v1-0 (joint-control-command blend)) + "blend" + ) + ((= v1-0 (joint-control-command push1)) + "push1" + ) + ((= v1-0 (joint-control-command float)) + "float" + ) + ((= v1-0 (joint-control-command stack)) + "stack" + ) + (else + "*unknown*" + ) + ) + (-> obj frame-group) + (-> obj frame-num) + obj + ) + ) + obj + ) + +(defmethod asize-of joint-control ((obj joint-control)) + (the-as int (+ (-> obj type size) (* (-> obj allocated-length) 64))) + ) + +(defmethod new joint-control ((allocation symbol) (type-to-make type) (arg0 int)) + (let ((v0-0 (object-new allocation type-to-make (the-as int (+ (-> type-to-make size) (* arg0 64)))))) + (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 generate-frame-function) create-interpolated-joint-animation-frame) + (set! (-> v0-0 prebind-function) #f) + (set! (-> v0-0 postbind-function) #f) + (set! (-> v0-0 effect) #f) + (set! (-> v0-0 top-anim) #f) + (set! (-> v0-0 override) #f) + (dotimes (v1-4 arg0) + (set! (-> v0-0 channel v1-4 parent) v0-0) + ) + (set! (-> v0-0 blend-index) (the-as uint -1)) + v0-0 + ) + ) + +(defmethod debug-print-channels joint-control ((obj joint-control) (arg0 symbol)) + (format arg0 "~0K") + (dotimes (s4-0 (the-as int (+ (-> obj active-channels) (-> obj float-channels)))) + (let* ((s3-0 (-> obj channel s4-0)) + (s2-0 (if (and (-> s3-0 frame-group) (nonzero? (-> s3-0 frame-group))) + (-> s3-0 frame-group) + ) + ) + ) + (let* ((t9-1 format) + (a0-3 arg0) + (a1-2 "~S~2d ~C ~-35S ") + (a2-0 (if (= (-> obj root-channel) s3-0) + "~3Lch:~0L" + "ch:" + ) + ) + (a3-0 s4-0) + (v1-6 (-> s3-0 command)) + (t0-2 (cond + ((= v1-6 (joint-control-command push)) + 80 + ) + ((= v1-6 (joint-control-command push1)) + 112 + ) + ((= v1-6 (joint-control-command blend)) + 66 + ) + ((= v1-6 (joint-control-command stack)) + 83 + ) + ((= v1-6 (joint-control-command stack1)) + 115 + ) + ((= v1-6 (joint-control-command float)) + 102 + ) + ) + ) + ) + (t9-1 a0-3 a1-2 a2-0 a3-0 t0-2 (if s2-0 + (-> s2-0 name) + "(none)" + ) + ) + ) + (if (and (= (-> s3-0 frame-interp 0) 0.0) (!= (-> s3-0 frame-interp 1) 0.0)) + (format + arg0 + "f: ~6,,2f ~1L~4,,2f~0L ~4,,2f%~%" + (+ (* (-> s3-0 frame-num) (if s2-0 + (-> s2-0 artist-step) + 1.0 + ) + ) + (if s2-0 + (-> s2-0 artist-base) + 0.0 + ) + ) + (-> s3-0 frame-interp 1) + (* 0.003921569 (the float (-> s3-0 inspector-amount))) + ) + (format + arg0 + "f: ~6,,2f ~4,,2f ~4,,2f%~%" + (+ (* (-> s3-0 frame-num) (if s2-0 + (-> s2-0 artist-step) + 1.0 + ) + ) + (if s2-0 + (-> s2-0 artist-base) + 0.0 + ) + ) + (-> s3-0 frame-interp (-> obj active-frame-interp)) + (* 0.003921569 (the float (-> s3-0 inspector-amount))) + ) + ) + ) + ) + (format arg0 "~1K") + 0 + ) + +(defmethod needs-link? art ((obj art)) + #f + ) + +(defmethod get-art-by-name-method art ((obj art) (arg0 string) (arg1 type)) + (the-as basic #f) + ) + +(defmacro get-art-by-name (obj name type) + "Helper macro for casting the result of get-art-by-name-method. Generated by decompiler." + `(the-as ,type (get-art-by-name-method ,obj ,name ,type)) + ) + +(defmethod get-art-idx-by-name-method art ((obj art) (arg0 string) (arg1 type)) + (the-as int #f) + ) + +(defmethod print art ((obj art)) + (format #t "#<~A ~S :length ~D @ #x~X>" (-> obj type) (-> obj name) (-> obj length) obj) + obj + ) + +(defmethod length art ((obj art)) + (-> obj length) + ) + +(defmethod login art ((obj art)) + (if (and (-> obj extra) (zero? (-> obj extra tag))) + (set! (-> obj extra tag) (the-as (pointer res-tag) (&+ (the-as pointer (-> obj extra)) 28))) + ) + obj + ) + +(defmethod mem-usage art-mesh-anim ((obj art-mesh-anim) (arg0 memory-usage-block) (arg1 int)) + (set! (-> arg0 length) (max 75 (-> arg0 length))) + (set! (-> arg0 data 74 name) "art-mesh-anim") + (+! (-> arg0 data 74 count) 1) + (let ((v1-6 (asize-of obj))) + (+! (-> arg0 data 74 used) v1-6) + (+! (-> arg0 data 74 total) (logand -16 (+ v1-6 15))) + ) + (if (-> obj extra) + (mem-usage (-> obj extra) arg0 (logior arg1 512)) + ) + (dotimes (s3-0 (-> obj length)) + (mem-usage (-> obj data s3-0) arg0 arg1) + ) + obj + ) + +(defmethod mem-usage art-joint-anim ((obj art-joint-anim) (arg0 memory-usage-block) (arg1 int)) + (set! (-> arg0 length) (max 78 (-> arg0 length))) + (set! (-> arg0 data 77 name) "art-joint-anim") + (+! (-> arg0 data 77 count) 1) + (let ((v1-6 (asize-of obj))) + (+! (-> arg0 data 77 used) v1-6) + (+! (-> arg0 data 77 total) (logand -16 (+ v1-6 15))) + ) + (if (-> obj extra) + (mem-usage (-> obj extra) arg0 (logior arg1 512)) + ) + (jacc-mem-usage (-> obj frames) arg0 arg1) + (when (and (nonzero? (-> obj eye-anim)) (-> obj eye-anim)) + (set! (-> arg0 length) (max 112 (-> arg0 length))) + (set! (-> arg0 data 111 name) "eye-anim") + (+! (-> arg0 data 111 count) 1) + (let ((v1-26 (* (* (+ (-> obj eye-anim max-frame) 1) 2) 8))) + (+! (-> arg0 data 111 used) v1-26) + (+! (-> arg0 data 111 total) (logand -16 (+ v1-26 15))) + ) + ) + obj + ) + +(defmethod asize-of art-joint-anim ((obj art-joint-anim)) + (the-as int (+ (-> art size) (* (-> obj length) 4))) + ) + +(defmethod inspect art-group ((obj art-group)) + (format #t "[~8x] ~A~%" obj (-> obj type)) + (format #t "~Tinfo: ~A~%" (-> obj info)) + (format #t "~Tlength: ~D~%" (-> obj length)) + (format #t "~Tname: ~A~%" (-> obj name)) + (format #t "~Textra: ~A~%" (-> obj extra)) + (format #t "~Tdata[~D]: @ #x~X~%" (-> obj length) (-> obj data)) + (dotimes (s5-0 (-> obj length)) + (if (-> obj data s5-0) + (format #t "~T [~D] ~A (~D bytes)~%" s5-0 (-> obj data s5-0) (mem-size (-> obj data s5-0) #f 0)) + (format #t "~T [~D] ~A (~D bytes)~%" s5-0 (-> obj data s5-0) 0) + ) + ) + obj + ) + +(defmethod needs-link? art-group ((obj art-group)) + (and (nonzero? (-> obj length)) + (type? (-> obj data 0) art-joint-anim) + (!= (-> obj name) (-> (the-as art-joint-anim (-> obj data 0)) master-art-group-name)) + ) + ) + +(defmethod get-art-by-name-method art-group ((obj art-group) (arg0 string) (arg1 type)) + (cond + (arg1 + (let ((s3-0 (+ (length (-> obj name)) 1))) + (dotimes (s2-0 (-> obj length)) + (if (and (-> obj data s2-0) + (= (-> obj data s2-0 type) arg1) + (or (name= arg0 (-> obj data s2-0 name)) (string-charp= arg0 (&-> (-> obj data s2-0 name) data s3-0))) + ) + (return (the-as basic (-> obj data s2-0))) + ) + ) + ) + (the-as art-element #f) + ) + (else + (dotimes (s4-1 (-> obj length)) + (if (and (-> obj data s4-1) (name= arg0 (-> obj data s4-1 name))) + (return (the-as basic (-> obj data s4-1))) + ) + ) + (the-as art-element #f) + ) + ) + ) + +(defmethod get-art-idx-by-name-method art-group ((obj art-group) (arg0 string) (arg1 type)) + (cond + (arg1 + (let ((s3-0 (+ (length (-> obj name)) 1))) + (dotimes (s2-0 (-> obj length)) + (if (and (-> obj data s2-0) + (= (-> obj data s2-0 type) arg1) + (or (name= arg0 (-> obj data s2-0 name)) (string-charp= arg0 (&-> (-> obj data s2-0 name) data s3-0))) + ) + (return s2-0) + ) + ) + ) + (the-as int #f) + ) + (else + (dotimes (s4-1 (-> obj length)) + (if (and (-> obj data s4-1) (name= arg0 (-> obj data s4-1 name))) + (return s4-1) + ) + ) + (the-as int #f) + ) + ) + ) + +(defmethod login art-group ((obj art-group)) + (dotimes (s5-0 (-> obj length)) + (if (-> obj data s5-0) + (set! (-> obj data s5-0) (login (-> obj data s5-0))) + ) + ) + obj + ) + +(defmethod mem-usage art-group ((obj art-group) (arg0 memory-usage-block) (arg1 int)) + (set! (-> arg0 length) (max 74 (-> arg0 length))) + (set! (-> arg0 data 73 name) "art-group") + (+! (-> arg0 data 73 count) 1) + (let ((v1-6 (asize-of obj))) + (+! (-> arg0 data 73 used) v1-6) + (+! (-> arg0 data 73 total) (logand -16 (+ v1-6 15))) + ) + (if (-> obj extra) + (mem-usage (-> obj extra) arg0 (logior arg1 512)) + ) + (dotimes (s3-0 (-> obj length)) + (if (-> obj data s3-0) + (mem-usage (-> obj data s3-0) arg0 arg1) + ) + ) + obj + ) + +(defmethod relocate art-group ((obj art-group) (arg0 kheap) (arg1 (pointer uint8))) + (let ((s4-0 (clear *temp-string*))) + (string<-charp s4-0 arg1) + (set! obj + (cond + ((not obj) + (format 0 "ERROR: art-group ~A is not a valid file.~%" s4-0) + (the-as art-group #f) + ) + ((not (type? obj art-group)) + (format 0 "ERROR: art-group ~A is not a art-group.~%" s4-0) + (the-as art-group #f) + ) + ((not (file-info-correct-version? (-> obj info) (file-kind art-group) 0)) + (the-as art-group #f) + ) + (else + (let ((s5-1 (-> *level* loading-level))) + (if (and (nonzero? (-> s5-1 code-memory-end)) (< (the-as uint (-> s5-1 load-buffer-mode)) (the-as uint 2))) + (set! (-> s5-1 load-buffer-mode) (load-buffer-mode medium)) + ) + (cond + ((and s5-1 (= (-> s5-1 name) 'default) (not *print-login*)) + (format + 0 + "ERROR: illegal login of art ~A (in level ~A) to level ~A~%" + obj + (get-level-by-heap-ptr-and-status *level* (the-as pointer obj) 'loading) + s5-1 + ) + (break!) + 0 + ) + ((or (not s5-1) (= (-> s5-1 name) 'default)) + ) + ((!= (get-level-by-heap-ptr-and-status *level* (the-as pointer obj) 'loading) s5-1) + (format + 0 + "ERROR: illegal login of art ~A (in level ~A) to level ~A~%" + obj + (get-level-by-heap-ptr-and-status *level* (the-as pointer obj) 'loading) + s5-1 + ) + (break!) + 0 + ) + ) + (when (or (not s5-1) (= (-> s5-1 name) 'default)) + (login obj) + (if (needs-link? obj) + (link-art! obj) + ) + ) + (if s5-1 + (set-loaded-art (-> s5-1 art-group) obj) + ) + ) + obj + ) + ) + ) + ) + (none) + ) + +(defmethod asize-of art-mesh-geo ((obj art-mesh-geo)) + (the-as int (+ (-> art size) (* (-> obj length) 4))) + ) + +(defmethod mem-usage art-mesh-geo ((obj art-mesh-geo) (arg0 memory-usage-block) (arg1 int)) + (set! (-> arg0 length) (max 76 (-> arg0 length))) + (set! (-> arg0 data 75 name) "art-mesh-geo") + (+! (-> arg0 data 75 count) 1) + (let ((v1-6 (asize-of obj))) + (+! (-> arg0 data 75 used) v1-6) + (+! (-> arg0 data 75 total) (logand -16 (+ v1-6 15))) + ) + (if (-> obj extra) + (mem-usage (-> obj extra) arg0 (logior arg1 512)) + ) + (dotimes (s3-0 (-> obj length)) + (mem-usage (-> obj data s3-0) arg0 arg1) + ) + obj + ) + +(defmethod login art-mesh-geo ((obj art-mesh-geo)) + (dotimes (s5-0 (-> obj length)) + (let ((s4-0 (the-as object (-> obj data s5-0)))) + (dotimes (s3-0 (-> (the-as (pointer int16) s4-0) 3)) + (if (-> (the-as (pointer art) (+ (* s3-0 4) (the-as int s4-0))) 2) + (login (the-as drawable (-> (the-as (pointer art) (+ (* s3-0 4) (the-as int s4-0))) 2))) + ) + ) + ) + ) + obj + ) + +(defmethod login art-joint-anim ((obj art-joint-anim)) + (if (and (-> obj extra) (zero? (-> obj extra tag))) + (set! (-> obj extra tag) (the-as (pointer res-tag) (&+ (the-as pointer (-> obj extra)) 28))) + ) + obj + ) + +(defmethod asize-of art-joint-geo ((obj art-joint-geo)) + (the-as int (+ (-> art size) (* (-> obj length) 4))) + ) + +(defmethod get-art-by-name-method art-joint-geo ((obj art-joint-geo) (arg0 string) (arg1 type)) + (cond + (arg1 + (dotimes (s3-0 (-> obj length)) + (if (and (= (-> obj data s3-0 type) arg1) (name= arg0 (-> obj data s3-0 name))) + (return (the-as basic (-> obj data s3-0))) + ) + ) + (the-as joint #f) + ) + (else + (dotimes (s4-1 (-> obj length)) + (if (name= arg0 (-> obj data s4-1 name)) + (return (the-as basic (-> obj data s4-1))) + ) + ) + (the-as joint #f) + ) + ) + ) + +(defmethod get-art-idx-by-name-method art-joint-geo ((obj art-joint-geo) (arg0 string) (arg1 type)) + (cond + (arg1 + (dotimes (s3-0 (-> obj length)) + (if (and (= (-> obj data s3-0 type) arg1) (name= arg0 (-> obj data s3-0 name))) + (return s3-0) + ) + ) + (the-as int #f) + ) + (else + (dotimes (s4-1 (-> obj length)) + (if (name= arg0 (-> obj data s4-1 name)) + (return s4-1) + ) + ) + (the-as int #f) + ) + ) + ) + +(defmethod mem-usage art-joint-geo ((obj art-joint-geo) (arg0 memory-usage-block) (arg1 int)) + (set! (-> arg0 length) (max 77 (-> arg0 length))) + (set! (-> arg0 data 76 name) "art-joint-geo") + (+! (-> arg0 data 76 count) 1) + (let ((v1-6 (asize-of obj))) + (+! (-> arg0 data 76 used) v1-6) + (+! (-> arg0 data 76 total) (logand -16 (+ v1-6 15))) + ) + (if (-> obj extra) + (mem-usage (-> obj extra) arg0 (logior arg1 512)) + ) + (dotimes (s3-0 (-> obj length)) + (mem-usage (-> obj data s3-0) arg0 arg1) + ) + obj + ) + +(defbehavior joint-control-channel-eval process ((arg0 joint-control-channel)) + (let ((f0-3 ((-> arg0 num-func) arg0 (-> arg0 param 0) (-> arg0 param 1) (-> arg0 param 2)))) + (set! (-> arg0 eval-time) (the-as uint (-> self clock frame-counter))) + f0-3 + ) + ) + +(defbehavior joint-control-channel-eval! process ((arg0 joint-control-channel) (arg1 (function joint-control-channel float float float float))) + (set! (-> arg0 num-func) arg1) + (let ((f0-3 (arg1 arg0 (-> arg0 param 0) (-> arg0 param 1) (-> arg0 param 2)))) + (set! (-> arg0 eval-time) (the-as uint (-> self clock frame-counter))) + f0-3 + ) + ) + +(defun joint-control-channel-group-eval! ((arg0 joint-control-channel) + (arg1 art-joint-anim) + (arg2 (function joint-control-channel float float float float)) + ) + (with-pp + (set! (-> arg0 num-func) arg2) + (cond + ((= (-> arg0 command) (joint-control-command stack)) + ) + (else + (if arg1 + (set! (-> arg0 frame-group) arg1) + ) + (arg2 arg0 (-> arg0 param 0) (-> arg0 param 1) (-> arg0 param 2)) + (set! (-> arg0 eval-time) (the-as uint (-> pp clock frame-counter))) + ) + ) + 0 + ) + ) + +(defun joint-control-channel-group! ((arg0 joint-control-channel) + (arg1 art-joint-anim) + (arg2 (function joint-control-channel float float float float)) + ) + (set! (-> arg0 num-func) arg2) + (cond + ((= (-> arg0 command) (joint-control-command stack)) + ) + (arg1 + (set! (-> arg0 frame-group) arg1) + ) + ) + 0 + ) + +(defun joint-control-copy! ((arg0 joint-control) (arg1 joint-control)) + (set! (-> arg0 blend-index) (-> arg1 blend-index)) + (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))) + ) + (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)) + ) + (dotimes (v1-12 (the-as int (-> arg0 allocated-length))) + (set! (-> arg0 channel v1-12 parent) arg0) + ) + arg0 + ) + +(defun joint-control-remap! ((arg0 joint-control) (arg1 art-group) (arg2 art-group) (arg3 pair) (arg4 int) (arg5 string)) + (local-vars + (sv-16 int) + (sv-24 symbol) + (sv-32 int) + (sv-40 int) + (sv-48 joint-control-channel) + (sv-52 basic) + (sv-56 object) + (sv-60 basic) + (sv-64 art-joint-anim) + (sv-80 string) + ) + (set! sv-16 (+ (length (-> arg2 name)) 1)) + (set! sv-24 #t) + (set! sv-32 arg4) + (set! sv-40 2) + (while (and (< sv-40 (-> arg1 length)) (or (not (-> arg1 data sv-40)) (!= (-> arg1 data sv-40 type) art-joint-anim))) + (set! sv-40 (+ sv-40 1)) + ) + (dotimes (s2-1 (the-as int (+ (-> arg0 active-channels) (-> arg0 float-channels)))) + (set! sv-48 (-> arg0 channel s2-1)) + (set! sv-52 (the-as basic #f)) + (when (-> sv-48 frame-group) + (format (clear *temp-string*) "~S~G" arg5 (&+ (-> sv-48 frame-group name data) sv-16)) + (when (not (null? arg3)) + (set! sv-56 (nassoc *temp-string* arg3)) + (when sv-56 + (let* ((s1-1 sv-32) + (a0-8 sv-56) + (v1-36 (mod s1-1 (+ ((method-of-type (rtype-of a0-8) length) a0-8) -1))) + ) + (set! sv-60 (the-as basic (ref sv-56 (+ v1-36 1)))) + ) + (cond + ((= (-> sv-60 type) string) + (format (clear *temp-string*) "~S" sv-60) + ) + ((= (-> sv-60 type) function) + (set! sv-52 sv-60) + (let ((s1-3 format) + (s0-0 (clear *temp-string*)) + ) + (set! sv-80 "~S") + (let ((a2-4 ((the-as (function joint-control joint-control-channel int object) sv-52) arg0 sv-48 0))) + (s1-3 s0-0 sv-80 a2-4) + ) + ) + ) + ) + ) + ) + (set! sv-64 (get-art-by-name arg1 *temp-string* art-joint-anim)) + (cond + (sv-64 + (let* ((v1-46 (-> sv-48 frame-group)) + (f0-2 (+ (* (-> sv-48 frame-num) (-> v1-46 artist-step)) (-> v1-46 artist-base))) + ) + (set! (-> sv-48 frame-group) sv-64) + (set! (-> sv-48 frame-num) (/ (- f0-2 (-> sv-64 artist-base)) (-> sv-64 artist-step))) + ) + (set! (-> sv-48 frame-num) + (fmax 0.0 (fmin (-> sv-48 frame-num) (the float (+ (-> sv-64 frames num-frames) -1)))) + ) + (if sv-52 + ((the-as (function joint-control joint-control-channel int object) sv-52) arg0 sv-48 1) + ) + ) + (else + (set! (-> sv-48 frame-group) (the-as art-joint-anim (-> arg1 data sv-40))) + (set! (-> sv-48 frame-num) 0.0) + (set! sv-24 (the-as symbol #f)) + ) + ) + ) + ) + (the-as object sv-24) + ) + +(defun flatten-joint-control-to-spr ((arg0 joint-control)) + (rlet ((vf1 :class vf) + (vf10 :class vf) + (vf11 :class vf) + (vf12 :class vf) + (vf13 :class vf) + (vf14 :class vf) + (vf2 :class vf) + (vf3 :class vf) + (vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + (vf7 :class vf) + (vf8 :class vf) + (vf9 :class vf) + ) + (let ((s5-0 (+ (-> arg0 active-channels) (-> arg0 float-channels)))) + (let ((f0-0 1.0) + (v1-2 0) + ;(a2-0 (the-as object #x70000960)) + (a2-0 (scratchpad-object object :offset #x960)) ;; flattened array. + (a0-2 (-> arg0 active-frame-interp)) + ) + (dotimes (a1-0 (the-as int s5-0)) + (let ((a3-2 (-> arg0 channel a1-0))) + (case (-> a3-2 command) + (((joint-control-command push)) + (let ((a3-3 (the-as object (+ (the-as int a2-0) v1-2)))) + (set! (-> (the-as (inline-array vector) a2-0) 0 quad) (the-as uint128 0)) + (set! (-> (the-as (inline-array vector) a2-0) 1 quad) (the-as uint128 0)) + (set! (-> (the-as (inline-array vector) a2-0) 2 quad) (the-as uint128 0)) + (set! (-> (the-as (inline-array vector) a2-0) 3 quad) (the-as uint128 0)) + (set! (-> (the-as (inline-array vector) a2-0) 4 quad) (the-as uint128 0)) + (set! (-> (the-as (inline-array vector) a2-0) 5 quad) (the-as uint128 0)) + (set! (-> (the-as (pointer float) a3-3) 0) f0-0) + ) + (set! a2-0 (+ (the-as int a2-0) 96)) + ) + (((joint-control-command blend) (joint-control-command push1) (joint-control-command float)) + (let ((f1-0 (-> a3-2 frame-interp a0-2))) + (let ((a3-5 (- f0-0 f1-0))) + (.mov vf1 a3-5) + ) + (let ((a2-1 (the-as object (+ (the-as int a2-0) -96)))) + (.lvf vf2 (the-as int a2-1)) + (let ((a3-6 (the-as object (+ (the-as int a2-1) v1-2)))) + (.lvf vf3 (+ (the-as int a2-1) 16)) + (.lvf vf4 (+ (the-as int a2-1) 32)) + (.lvf vf5 (+ (the-as int a2-1) 48)) + (.lvf vf6 (+ (the-as int a2-1) 64)) + (.lvf vf7 (+ (the-as int a2-1) 80)) + (.mul.x.vf vf2 vf2 vf1) + (.mul.x.vf vf3 vf3 vf1) + (.mul.x.vf vf4 vf4 vf1) + (.mul.x.vf vf5 vf5 vf1) + (.mul.x.vf vf6 vf6 vf1) + (.mul.x.vf vf7 vf7 vf1) + (.svf (&-> (the-as (inline-array vector) a2-1) 0 quad) vf2) + (.svf (&-> (the-as (inline-array vector) a2-1) 1 quad) vf3) + (.svf (&-> (the-as (inline-array vector) a2-1) 2 quad) vf4) + (.svf (&-> (the-as (inline-array vector) a2-1) 3 quad) vf5) + (.svf (&-> (the-as (inline-array vector) a2-1) 4 quad) vf6) + (.svf (&-> (the-as (inline-array vector) a2-1) 5 quad) vf7) + (+! (-> (the-as (pointer float) a3-6) 0) f1-0) + ) + (set! a2-0 (+ (the-as int a2-1) 96)) + ) + ) + ) + (((joint-control-command stack)) + (let* ((f2-2 (-> a3-2 frame-interp a0-2)) + (f1-2 (- f0-0 f2-2)) + (a2-2 (the-as object (+ (the-as int a2-0) -192))) + ) + (let ((a3-8 f2-2)) + (.mov vf1 a3-8) + ) + (let ((a3-9 f1-2)) + (.mov vf2 a3-9) + ) + (.lvf vf3 (the-as int a2-2)) + (.lvf vf4 (+ (the-as int a2-2) 16)) + (.lvf vf5 (+ (the-as int a2-2) 32)) + (.lvf vf6 (+ (the-as int a2-2) 48)) + (.lvf vf7 (+ (the-as int a2-2) 64)) + (.lvf vf8 (+ (the-as int a2-2) 80)) + (.mul.x.vf vf3 vf3 vf2) + (.mul.x.vf vf4 vf4 vf2) + (.mul.x.vf vf5 vf5 vf2) + (.mul.x.vf vf6 vf6 vf2) + (.mul.x.vf vf7 vf7 vf2) + (.mul.x.vf vf8 vf8 vf2) + (.lvf vf9 (+ (the-as int a2-2) 96)) + (.lvf vf10 (+ (the-as int a2-2) 112)) + (.lvf vf11 (+ (the-as int a2-2) 128)) + (.lvf vf12 (+ (the-as int a2-2) 144)) + (.lvf vf13 (+ (the-as int a2-2) 160)) + (.lvf vf14 (+ (the-as int a2-2) 176)) + (.mul.x.vf vf9 vf9 vf1) + (.mul.x.vf vf10 vf10 vf1) + (.mul.x.vf vf11 vf11 vf1) + (.mul.x.vf vf12 vf12 vf1) + (.mul.x.vf vf13 vf13 vf1) + (.mul.x.vf vf14 vf14 vf1) + (.add.vf vf3 vf3 vf9) + (.add.vf vf4 vf4 vf10) + (.add.vf vf5 vf5 vf11) + (.add.vf vf6 vf6 vf12) + (.add.vf vf7 vf7 vf13) + (.add.vf vf8 vf8 vf14) + (.svf (&-> (the-as (inline-array vector) a2-2) 0 quad) vf3) + (.svf (&-> (the-as (inline-array vector) a2-2) 1 quad) vf4) + (.svf (&-> (the-as (inline-array vector) a2-2) 2 quad) vf5) + (.svf (&-> (the-as (inline-array vector) a2-2) 3 quad) vf6) + (.svf (&-> (the-as (inline-array vector) a2-2) 4 quad) vf7) + (.svf (&-> (the-as (inline-array vector) a2-2) 5 quad) vf8) + (set! a2-0 (+ (the-as int a2-2) 96)) + ) + ) + ) + ) + (+! v1-2 4) + ) + ) + (let ((s4-0 0)) + (dotimes (s3-0 (the-as int s5-0)) + (when (< 0.001 (-> (scratchpad-object terrain-context) work foreground joint-work flatten-array s3-0)) + (let* ((v1-11 (-> arg0 channel s3-0)) + (s2-0 (-> v1-11 frame-group frames)) + (f0-2 (-> v1-11 frame-num)) + (s1-0 (the int f0-2)) + (f30-0 (- f0-2 (the float s1-0))) + ) + (let ((s0-0 (+ (-> s2-0 num-frames) -1))) + (if (not (-> v1-11 frame-group)) + (format 0 "Channel ~D skel ~A frame-group is #f!!!~%" s3-0 arg0) + ) + (when (>= s1-0 (the-as int s0-0)) + (set! f30-0 0.0) + (set! s1-0 (the-as int s0-0)) + ) + ) + (let ((v1-20 (-> (scratchpad-object terrain-context) work foreground joint-work uploads s4-0))) + (set! (-> v1-20 fixed) (-> s2-0 fixed)) + (set! (-> v1-20 fixed-qwc) (the-as int (-> s2-0 fixed-qwc))) + (set! (-> v1-20 frame) (-> s2-0 data s1-0)) + (set! (-> v1-20 frame-qwc) (the-as int (if (= f30-0 0.0) + (-> s2-0 frame-qwc) + (* (-> s2-0 frame-qwc) 2) + ) + ) + ) + (set! (-> v1-20 amount) + (-> (scratchpad-object terrain-context) work foreground joint-work flatten-array s3-0) + ) + (set! (-> v1-20 interp) f30-0) + ) + ) + (+! s4-0 1) + ) + ) + (set! (-> (scratchpad-object terrain-context) work foreground joint-work num-uploads) s4-0) + ) + (dotimes (v1-26 (the-as int s5-0)) + (set! (-> arg0 channel v1-26 inspector-amount) + (the-as + uint + (the int (* 255.0 (-> (scratchpad-object terrain-context) work foreground joint-work flatten-array v1-26))) + ) + ) + ) + ) + 0 + ) + ) + +(defun matrix-from-joint-anim-frame ((arg0 joint-anim-compressed-control) (arg1 int) (arg2 int)) + (let ((v1-1 (the-as object (-> arg0 fixed data))) + (v0-0 (the-as object (-> arg0 data arg2 data))) + ) + (cond + ((zero? (logand (-> arg0 fixed hdr matrix-bits) 1)) + (set! v1-1 (cond + ((zero? arg1) + (return (the-as matrix v1-1)) + v1-1 + ) + (else + (-> (the-as (inline-array vector) v1-1) 4) + ) + ) + ) + ) + ((zero? arg1) + (return (the-as matrix v0-0)) + ) + (else + (set! v0-0 (-> (the-as (inline-array vector) v0-0) 4)) + ) + ) + (if (zero? (logand (-> arg0 fixed hdr matrix-bits) 2)) + (return (the-as matrix v1-1)) + ) + (the-as matrix v0-0) + ) + ) + +(defun matrix-from-control-channel! ((arg0 matrix) (arg1 joint) (arg2 joint-control-channel)) + (let ((s4-0 (-> arg2 frame-group)) + (s5-0 (-> arg1 number)) + ) + (if (>= s5-0 2) + (format 0 "ERROR: Call to matrix-from-control-channel! on joint ~D~%" s5-0) + ) + (let* ((f30-0 (fmax 0.0 (fmin (-> arg2 frame-num) (the float (+ (-> s4-0 frames num-frames) -1))))) + (f0-1 f30-0) + ) + (cond + ((= (the float (the int f0-1)) f0-1) + (let* ((a2-3 (matrix-from-joint-anim-frame (-> s4-0 frames) s5-0 (the int f30-0))) + (v1-7 (-> a2-3 vector 0 quad)) + (a0-3 (-> a2-3 vector 1 quad)) + (a1-3 (-> a2-3 vector 2 quad)) + (a2-4 (-> a2-3 trans quad)) + ) + (set! (-> arg0 vector 0 quad) v1-7) + (set! (-> arg0 vector 1 quad) a0-3) + (set! (-> arg0 vector 2 quad) a1-3) + (set! (-> arg0 trans quad) a2-4) + ) + arg0 + ) + (else + (let ((s3-1 (matrix-from-joint-anim-frame (-> s4-0 frames) s5-0 (the int f30-0))) + (a2-7 (matrix-from-joint-anim-frame (-> s4-0 frames) s5-0 (+ (the int f30-0) 1))) + (f0-9 (- f30-0 (the float (the int f30-0)))) + ) + (matrix-lerp! arg0 s3-1 a2-7 f0-9) + ) + ) + ) + ) + ) + ) + +(defun matrix-from-control-pair! ((arg0 matrix) (arg1 matrix) (arg2 joint) (arg3 int)) + (let ((f30-0 (-> arg1 vector 2 data arg3))) + (cond + ((>= 0.0 f30-0) + (empty) + arg0 + ) + ((>= f30-0 1.0) + (matrix-from-control-channel! arg0 arg2 (the-as joint-control-channel arg1)) + ) + (else + (let ((a2-3 + (matrix-from-control-channel! (scratchpad-object matrix) arg2 (the-as joint-control-channel arg1)) + ) + ) + (matrix-lerp! arg0 arg0 a2-3 f30-0) + ) + ) + ) + ) + ) + +(defun matrix-from-control! ((arg0 matrix-stack) (arg1 joint) (arg2 joint-control) (arg3 symbol)) + (set! (-> arg0 top) (the-as matrix (-> arg0 data))) + (dotimes (s2-0 (the-as int (+ (-> arg2 active-channels) (-> arg2 float-channels)))) + (let* ((a2-1 (-> arg2 channel s2-0)) + (v1-3 (-> a2-1 command)) + (s1-0 64) + ) + (cond + ((and (= arg3 'no-push) (= v1-3 (joint-control-command push1))) + (matrix-from-control-channel! + (the-as matrix (&- (the-as pointer (-> arg0 top)) (the-as uint s1-0))) + arg1 + a2-1 + ) + ) + ((and (= arg3 'no-push) (= v1-3 (joint-control-command stack))) + (set! (-> arg0 top) (the-as matrix (&- (the-as pointer (-> arg0 top)) (the-as uint s1-0)))) + (let* ((v1-9 (the-as object (&- (the-as pointer (-> arg0 top)) (the-as uint s1-0)))) + (a3-1 (-> arg0 top)) + (a0-8 (-> a3-1 vector 0 quad)) + (a1-6 (-> a3-1 vector 1 quad)) + (a2-2 (-> a3-1 vector 2 quad)) + (a3-2 (-> a3-1 trans quad)) + ) + (set! (-> (the-as matrix v1-9) vector 0 quad) a0-8) + (set! (-> (the-as matrix v1-9) vector 1 quad) a1-6) + (set! (-> (the-as matrix v1-9) vector 2 quad) a2-2) + (set! (-> (the-as matrix v1-9) trans quad) a3-2) + ) + ) + ((and (= arg3 'no-push) (= v1-3 (joint-control-command float))) + ) + ((= v1-3 (joint-control-command push)) + (matrix-from-control-channel! (-> arg0 top) arg1 a2-1) + (set! (-> arg0 top) (the-as matrix (&+ (the-as pointer (-> arg0 top)) s1-0))) + ) + ((logtest? v1-3 (joint-control-command blend)) + (matrix-from-control-pair! + (the-as matrix (&- (the-as pointer (-> arg0 top)) (the-as uint s1-0))) + (the-as matrix a2-1) + arg1 + (the-as int (-> arg2 active-frame-interp)) + ) + ) + ((= v1-3 (joint-control-command stack)) + (set! (-> arg0 top) (the-as matrix (&- (the-as pointer (-> arg0 top)) (the-as uint s1-0)))) + (let ((a1-11 (&- (the-as pointer (-> arg0 top)) (the-as uint s1-0))) + (v1-19 (-> arg0 top)) + (f0-0 (-> a2-1 frame-interp (-> arg2 active-frame-interp))) + ) + (matrix-lerp! (the-as matrix a1-11) (the-as matrix a1-11) v1-19 f0-0) + ) + ) + ) + ) + ) + (the-as matrix (-> arg0 data)) + ) + + +(defmethod reset-and-assign-geo! cspace ((obj cspace) (arg0 basic)) + (set! (-> obj parent) #f) + (set! (-> obj joint) #f) + (set! (-> obj geo) arg0) + (set! (-> obj param0) #f) + (set! (-> obj param1) #f) + (set! (-> obj param2) #f) + obj + ) + +(defmethod new cspace ((allocation symbol) (type-to-make type) (arg0 basic)) + (let ((t9-0 (method-of-type structure new)) + (v1-1 type-to-make) + ) + (-> type-to-make size) + ((method-of-type cspace reset-and-assign-geo!) (the-as cspace (t9-0 allocation v1-1)) arg0) + ) + ) + +(defun cspace<-cspace! ((arg0 cspace) (arg1 cspace)) + (let ((v0-0 (-> arg0 bone transform))) + (let* ((a2-0 (-> arg1 bone transform)) + (v1-2 (-> a2-0 vector 0 quad)) + (a0-1 (-> a2-0 vector 1 quad)) + (a1-1 (-> a2-0 vector 2 quad)) + (a2-1 (-> a2-0 trans quad)) + ) + (set! (-> v0-0 vector 0 quad) v1-2) + (set! (-> v0-0 vector 1 quad) a0-1) + (set! (-> v0-0 vector 2 quad) a1-1) + (set! (-> v0-0 trans quad) a2-1) + ) + v0-0 + ) + ) + +(defun cspace<-cspace-normalized! ((arg0 cspace) (arg1 cspace)) + (let ((gp-0 (-> arg0 bone transform))) + (let* ((a2-0 (-> arg1 bone transform)) + (v1-2 (-> a2-0 vector 0 quad)) + (a0-1 (-> a2-0 vector 1 quad)) + (a1-1 (-> a2-0 vector 2 quad)) + (a2-1 (-> a2-0 trans quad)) + ) + (set! (-> gp-0 vector 0 quad) v1-2) + (set! (-> gp-0 vector 1 quad) a0-1) + (set! (-> gp-0 vector 2 quad) a1-1) + (set! (-> gp-0 trans quad) a2-1) + ) + (vector-normalize! (the-as vector (-> gp-0 data)) 1.0) + (vector-normalize! (the-as vector (&-> gp-0 data 4)) 1.0) + (vector-normalize! (the-as vector (&-> gp-0 data 8)) 1.0) + gp-0 + ) + ) + +(defun cspace<-parent-joint! ((arg0 cspace) (arg1 (pointer process-drawable)) (arg2 int)) + (let ((v0-0 (-> arg0 bone transform))) + (let* ((a2-1 (-> arg1 0 node-list data arg2 bone transform)) + (v1-5 (-> a2-1 vector 0 quad)) + (a0-2 (-> a2-1 vector 1 quad)) + (a1-1 (-> a2-1 vector 2 quad)) + (a2-2 (-> a2-1 trans quad)) + ) + (set! (-> v0-0 vector 0 quad) v1-5) + (set! (-> v0-0 vector 1 quad) a0-2) + (set! (-> v0-0 vector 2 quad) a1-1) + (set! (-> v0-0 trans quad) a2-2) + ) + v0-0 + ) + ) + +(defun cspace<-rot-yxy! ((arg0 cspace) (arg1 transform)) + (let ((s5-0 (-> arg0 bone transform))) + (matrix-rotate-yxy! s5-0 (-> arg1 rot)) + (scale-matrix! s5-0 (-> arg1 scale) s5-0) + ) + ) + +(defun cspace<-transform-yxy! ((arg0 cspace) (arg1 transform)) + (let ((s4-0 (-> arg0 bone transform)) + (s5-0 (new 'stack-no-clear 'matrix)) + (s3-0 (new 'stack-no-clear 'matrix)) + ) + (matrix-identity! s4-0) + (matrix-translate! s4-0 (-> arg1 trans)) + (matrix-rotate-yxy! s5-0 (-> arg1 rot)) + (matrix*! s3-0 s5-0 s4-0) + (scale-matrix! s4-0 (-> arg1 scale) s3-0) + ) + ) + +(defun cspace<-transformq! ((arg0 cspace) (arg1 transformq)) + (matrix<-transformq! (-> arg0 bone transform) arg1) + ) + +(defun cspace<-transformq+trans! ((arg0 cspace) (arg1 transformq) (arg2 vector)) + (matrix<-transformq+trans! (-> arg0 bone transform) arg1 arg2) + ) + +(defun cspace<-transformq+world-trans! ((arg0 cspace) (arg1 transformq) (arg2 vector)) + (matrix<-transformq+world-trans! (-> arg0 bone transform) arg1 arg2) + ) + +(defun cspace<-transformq+rot-offset! ((arg0 cspace) (arg1 transformq) (arg2 vector)) + (matrix<-transformq+rot-offset! (-> arg0 bone transform) arg1 arg2) + ) + +(defun cspace-calc-total-matrix! ((arg0 cspace) (arg1 matrix)) + (matrix*! arg1 (-> arg0 bone transform) (-> *math-camera* camera-temp)) + ) + +(defun cspace<-matrix-no-push-joint! ((arg0 cspace) (arg1 joint-control)) + (let ((v1-2 (matrix-from-control! (scratchpad-object matrix-stack :offset 64) (-> arg0 joint) arg1 'no-push)) + (v0-1 (-> arg0 bone transform)) + ) + (let ((a0-4 (-> v1-2 vector 0 quad)) + (a1-2 (-> v1-2 vector 1 quad)) + (a2-1 (-> v1-2 vector 2 quad)) + (v1-3 (-> v1-2 trans quad)) + ) + (set! (-> v0-1 vector 0 quad) a0-4) + (set! (-> v0-1 vector 1 quad) a1-2) + (set! (-> v0-1 vector 2 quad) a2-1) + (set! (-> v0-1 trans quad) v1-3) + ) + v0-1 + ) + ) + +(defun cspace<-matrix-joint! ((arg0 cspace) (arg1 matrix)) + (let ((v0-0 (-> arg0 bone transform))) + (let* ((a2-0 arg1) + (v1-1 (-> a2-0 vector 0 quad)) + (a0-1 (-> a2-0 vector 1 quad)) + (a1-1 (-> a2-0 vector 2 quad)) + (a2-1 (-> a2-0 trans quad)) + ) + (set! (-> v0-0 vector 0 quad) v1-1) + (set! (-> v0-0 vector 1 quad) a0-1) + (set! (-> v0-0 vector 2 quad) a1-1) + (set! (-> v0-0 trans quad) a2-1) + ) + v0-0 + ) + ) + +(defun cspace<-parented-matrix-joint! ((arg0 cspace) (arg1 matrix)) + (rlet ((acc :class vf) + (vf10 :class vf) + (vf11 :class vf) + (vf12 :class vf) + (vf13 :class vf) + (vf14 :class vf) + (vf15 :class vf) + (vf16 :class vf) + (vf17 :class vf) + (vf18 :class vf) + (vf19 :class vf) + (vf20 :class vf) + (vf21 :class vf) + ) + (let ((v0-0 (-> arg0 bone transform))) + (let ((v1-1 arg1)) + (let ((a0-3 (-> arg0 parent bone transform))) + (.lvf vf10 (&-> v1-1 vector 0 quad)) + (.lvf vf14 (&-> a0-3 vector 0 quad)) + (.lvf vf15 (&-> a0-3 vector 1 quad)) + (.lvf vf16 (&-> a0-3 vector 2 quad)) + (.lvf vf17 (&-> a0-3 trans quad)) + ) + (.lvf vf11 (&-> v1-1 vector 1 quad)) + (.lvf vf12 (&-> v1-1 vector 2 quad)) + (.lvf vf13 (&-> v1-1 trans quad)) + ) + (.mul.x.vf acc vf14 vf10) + (.add.mul.y.vf acc vf15 vf10 acc) + (.add.mul.z.vf acc vf16 vf10 acc) + (.add.mul.w.vf vf18 vf17 vf10 acc) + (.mul.x.vf acc vf14 vf11) + (.add.mul.y.vf acc vf15 vf11 acc) + (.add.mul.z.vf acc vf16 vf11 acc) + (.add.mul.w.vf vf19 vf17 vf11 acc) + (.mul.x.vf acc vf14 vf12) + (.add.mul.y.vf acc vf15 vf12 acc) + (.add.mul.z.vf acc vf16 vf12 acc) + (.add.mul.w.vf vf20 vf17 vf12 acc) + (.mul.x.vf acc vf14 vf13) + (.add.mul.y.vf acc vf15 vf13 acc) + (.add.mul.z.vf acc vf16 vf13 acc) + (.add.mul.w.vf vf21 vf17 vf13 acc) + (.svf (&-> v0-0 vector 0 quad) vf18) + (.svf (&-> v0-0 vector 1 quad) vf19) + (.svf (&-> v0-0 vector 2 quad) vf20) + (.svf (&-> v0-0 trans quad) vf21) + v0-0 + ) + ) + ) + +(defun cspace<-parented-matrix-mirror! ((arg0 cspace) (arg1 matrix)) + (let ((gp-0 (matrix-mirror! + (new 'stack-no-clear 'matrix) + (the-as vector (-> arg0 param1)) + (the-as vector (-> arg0 param2)) + ) + ) + ) + (cspace<-parented-matrix-joint! arg0 arg1) + (matrix*! (-> arg0 bone transform) (-> arg0 bone transform) gp-0) + ) + ) + +(defun cspace<-parented-matrix-joint-flip-z! ((arg0 cspace) (arg1 matrix)) + (rlet ((acc :class vf) + (vf0 :class vf) + (vf10 :class vf) + (vf11 :class vf) + (vf12 :class vf) + (vf13 :class vf) + (vf14 :class vf) + (vf15 :class vf) + (vf16 :class vf) + (vf17 :class vf) + (vf18 :class vf) + (vf19 :class vf) + (vf20 :class vf) + (vf21 :class vf) + (vf31 :class vf) + ) + (init-vf0-vector) + (let ((v0-0 (-> arg0 bone transform))) + (let ((v1-1 arg1)) + (let ((a0-3 (-> arg0 parent bone transform))) + (.lvf vf10 (&-> v1-1 vector 0 quad)) + (.lvf vf14 (&-> a0-3 vector 0 quad)) + (.lvf vf15 (&-> a0-3 vector 1 quad)) + (.lvf vf16 (&-> a0-3 vector 2 quad)) + (.lvf vf17 (&-> a0-3 trans quad)) + ) + (.lvf vf11 (&-> v1-1 vector 1 quad)) + (.lvf vf12 (&-> v1-1 vector 2 quad)) + (.lvf vf13 (&-> v1-1 trans quad)) + ) + (.sub.vf vf31 vf0 vf0) + (.mul.x.vf acc vf14 vf10) + (.add.mul.y.vf acc vf15 vf10 acc) + (.add.mul.z.vf acc vf16 vf10 acc) + (.add.mul.w.vf vf18 vf17 vf10 acc) + (.mul.x.vf acc vf14 vf12) + (.add.mul.y.vf acc vf15 vf12 acc) + (.add.mul.z.vf acc vf16 vf12 acc) + (.add.mul.w.vf vf20 vf17 vf12 acc) + (.mul.x.vf acc vf14 vf11) + (.add.mul.y.vf acc vf15 vf11 acc) + (.add.mul.z.vf acc vf16 vf11 acc) + (.add.mul.w.vf vf19 vf17 vf11 acc) + (.sub.vf vf18 vf31 vf18) + (.mul.x.vf acc vf14 vf13) + (.add.mul.y.vf acc vf15 vf13 acc) + (.add.mul.z.vf acc vf16 vf13 acc) + (.add.mul.w.vf vf21 vf17 vf13 acc) + (.svf (&-> v0-0 vector 0 quad) vf18) + (.svf (&-> v0-0 vector 1 quad) vf19) + (.svf (&-> v0-0 vector 2 quad) vf20) + (.svf (&-> v0-0 trans quad) vf21) + v0-0 + ) + ) + ) + +(defun cspace<-matrix-joint-flip-z! ((arg0 cspace) (arg1 matrix)) + (local-vars (v1-2 float)) + (rlet ((vf0 :class vf) + (vf30 :class vf) + (vf31 :class vf) + ) + (init-vf0-vector) + (let ((v1-1 (-> arg0 bone transform))) + (.sub.vf vf31 vf0 vf0) + (.lvf vf30 (&-> v1-1 vector 0 quad)) + (.sub.vf vf30 vf31 vf30) + (.svf (&-> v1-1 vector 0 quad) vf30) + ) + (.mov v1-2 vf30) + 0 + (none) + ) + ) + +(def-mips2c cspace<-parented-transformq-joint! (function cspace transformq none)) + +(defun cspace<-parented-transformq-joint-flip-z! ((arg0 cspace) (arg1 transformq)) + (cspace<-parented-transformq-joint! arg0 arg1) + (cspace<-matrix-joint-flip-z! arg0 (-> arg0 bone transform)) + 0 + (none) + ) + +;; definition for function clear-frame-accumulator + +;; definition for function normalize-frame-quaternions + +;; definition for function decompress-fixed-data-to-accumulator + +;; definition for function decompress-frame-data-to-accumulator + +;; definition for function decompress-frame-data-pair-to-accumulator + +;; definition for function make-joint-jump-tables +(defun make-joint-jump-tables () +#| + #x3ee6b6f9, // = 9 ^ 1055307504 + #x3ee6b6ff, // = 15 ^ 1055307504 + #x3ee6b6e2, // = 18 ^ 1055307504 + #x3ee6b6e4, // = 20 ^ 1055307504 + #x3ee6b6e5, // = 21 ^ 1055307504 + #x3ee6b6eb, // = 27 ^ 1055307504 + #x3ee6b6ee, // = 30 ^ 1055307504 + #x3ee6b6f6, // = 6 ^ 1055307504 + #x3ee6b6fc, // = 12 ^ 1055307504 + #x3ee6b6ff, // = 15 ^ 1055307504 + #x3ee6b6e3, // = 19 ^ 1055307504 + #x3ee6b6e4, // = 20 ^ 1055307504 + #x3ee6b6e8, // = 24 ^ 1055307504 + #x3ee6b6eb, // = 27 ^ 1055307504 + #x3ee6b6ef, // = 31 ^ 1055307504 + #x3ee6b6f6, // = 6 ^ 1055307504 + |# + (set! (-> (scratchpad-object terrain-context) work foreground joint-work fix-jmp-table 0) + (the-as (function none) (+ 0 #x3ee6b6f9)) + ) + (set! (-> (scratchpad-object terrain-context) work foreground joint-work fix-jmp-table 1) + (the-as (function none) (+ 0 #x3ee6b6ff)) + ) + (set! (-> (scratchpad-object terrain-context) work foreground joint-work fix-jmp-table 2) + (the-as (function none) (+ 0 #x3ee6b6e2)) + ) + (set! (-> (scratchpad-object terrain-context) work foreground joint-work fix-jmp-table 3) + (the-as (function none) (+ 0 #x3ee6b6e4)) + ) + (set! (-> (scratchpad-object terrain-context) work foreground joint-work fix-jmp-table 4) + (the-as (function none) (+ 0 #x3ee6b6e5)) + ) + (set! (-> (scratchpad-object terrain-context) work foreground joint-work fix-jmp-table 5) + (the-as (function none) (+ 0 #x3ee6b6eb)) + ) + (set! (-> (scratchpad-object terrain-context) work foreground joint-work fix-jmp-table 6) + (the-as (function none) (+ 0 #x3ee6b6ee)) + ) + (set! (-> (scratchpad-object terrain-context) work foreground joint-work fix-jmp-table 7) + (the-as (function none) (+ 0 #x3ee6b6f6)) + ) + (set! (-> (scratchpad-object terrain-context) work foreground joint-work fix-jmp-table 8) + (the-as (function none) (+ 0 #x3ee6b6fc)) + ) + (set! (-> (scratchpad-object terrain-context) work foreground joint-work fix-jmp-table 9) + (the-as (function none) (+ 0 #x3ee6b6ff)) + ) + (set! (-> (scratchpad-object terrain-context) work foreground joint-work fix-jmp-table 10) + (the-as (function none) (+ 0 #x3ee6b6e3)) + ) + (set! (-> (scratchpad-object terrain-context) work foreground joint-work fix-jmp-table 11) + (the-as (function none) (+ 0 #x3ee6b6e4)) + ) + (set! (-> (scratchpad-object terrain-context) work foreground joint-work fix-jmp-table 12) + (the-as (function none) (+ 0 #x3ee6b6e8)) + ) + (set! (-> (scratchpad-object terrain-context) work foreground joint-work fix-jmp-table 13) + (the-as (function none) (+ 0 #x3ee6b6eb)) + ) + (set! (-> (scratchpad-object terrain-context) work foreground joint-work fix-jmp-table 14) + (the-as (function none) (+ 0 #x3ee6b6ef)) + ) + (set! (-> (scratchpad-object terrain-context) work foreground joint-work fix-jmp-table 15) + (the-as (function none) (+ 0 #x3ee6b6f6)) + ) + + + (let ((arr (new 'static 'array uint32 16 + #x7b2191b ;; = 6 ^ 129112349 + #x7b21914 ;; = 9 ^ 129112349 + #x7b21916 ;; = 11 ^ 129112349 + #x7b21913 ;; = 14 ^ 129112349 + #x7b21909 ;; = 20 ^ 129112349 + #x7b21908 ;; = 21 ^ 129112349 + #x7b2190a ;; = 23 ^ 129112349 + #x7b21907 ;; = 26 ^ 129112349 + #x7b2191b ;; = 6 ^ 129112349 + #x7b21917 ;; = 10 ^ 129112349 + #x7b21916 ;; = 11 ^ 129112349 + #x7b2190c ;; = 17 ^ 129112349 + #x7b21909 ;; = 20 ^ 129112349 + #x7b2190b ;; = 22 ^ 129112349 + #x7b2190a ;; = 23 ^ 129112349 + #x7b21900 ;; = 29 ^ 129112349 + ))) + (dotimes (i 16) + (set! (-> (scratchpad-object terrain-context) work foreground joint-work frm-jmp-table i) + (the-as (function none) (-> arr i)) + ) + ) + ) + + (let ((arr (new 'static 'array uint32 16 + #x4d7666df ;; = 6 ^ 1299605209 + #x4d7666d0 ;; = 9 ^ 1299605209 + #x4d7666d2 ;; = 11 ^ 1299605209 + #x4d7666d7 ;; = 14 ^ 1299605209 + #x4d7666cd ;; = 20 ^ 1299605209 + #x4d7666cc ;; = 21 ^ 1299605209 + #x4d7666ce ;; = 23 ^ 1299605209 + #x4d7666c3 ;; = 26 ^ 1299605209 + #x4d7666df ;; = 6 ^ 1299605209 + #x4d7666d3 ;; = 10 ^ 1299605209 + #x4d7666d2 ;; = 11 ^ 1299605209 + #x4d7666c8 ;; = 17 ^ 1299605209 + #x4d7666cd ;; = 20 ^ 1299605209 + #x4d7666cf ;; = 22 ^ 1299605209 + #x4d7666ce ;; = 23 ^ 1299605209 + #x4d7666c4 ;; = 29 ^ 1299605209 + ))) + (dotimes (i 16) + (set! (-> (scratchpad-object terrain-context) work foreground joint-work pair-jmp-table i) + (the-as (function none) (-> arr i)) + ) + ) + ) + 0 + ) + +(def-mips2c calc-animation-from-spr (function joint-anim-frame int none)) + +(defun create-interpolated-joint-animation-frame ((arg0 joint-anim-frame) (arg1 int) (arg2 joint-control)) + (flatten-joint-control-to-spr arg2) + (make-joint-jump-tables) + (calc-animation-from-spr arg0 arg1) + 0 + ) + +(defun create-interpolated2-joint-animation-frame ((arg0 joint-anim-frame) (arg1 int) (arg2 joint-control)) + (if (and (zero? (-> arg2 interp-select 0)) (zero? (-> arg2 interp-select 1))) + (return (create-interpolated-joint-animation-frame arg0 arg1 arg2)) + ) + (set! (-> arg2 active-frame-interp) (the-as uint 1)) + (flatten-joint-control-to-spr arg2) + (make-joint-jump-tables) + (calc-animation-from-spr arg0 arg1) + (format 0 "create-interpolated2-joint-animation-frame: untested copy~%") + (ultimate-memcpy (the-as pointer *gsf-buffer*) (the-as pointer arg0) (the-as uint (+ (* 48 arg1) 128))) + ; (dma-send-from-spr-no-flush + ; (the-as uint *gsf-buffer*) + ; (the-as uint arg0) + ; (the-as uint (/ (+ (* 48 arg1) 128) 16)) + ; #f + ; ) + (set! (-> arg2 active-frame-interp) (the-as uint 0)) + (flatten-joint-control-to-spr arg2) + (make-joint-jump-tables) + (calc-animation-from-spr arg0 arg1) + (let ((v1-9 (the-as joint-anim-frame *gsf-buffer*))) + (let ((a0-8 (-> arg2 interp-select 0))) + (dotimes (a1-5 2) + (when (logtest? a0-8 1) + (let* ((a2-7 (-> arg0 matrices a1-5)) + (t2-0 (-> v1-9 matrices a1-5)) + (a3-3 (-> t2-0 vector 0 quad)) + (t0-0 (-> t2-0 vector 1 quad)) + (t1-0 (-> t2-0 vector 2 quad)) + (t2-1 (-> t2-0 trans quad)) + ) + (set! (-> a2-7 vector 0 quad) a3-3) + (set! (-> a2-7 vector 1 quad) t0-0) + (set! (-> a2-7 vector 2 quad) t1-0) + (set! (-> a2-7 trans quad) t2-1) + ) + ) + (set! a0-8 (shr a0-8 1)) + ) + (let ((a1-9 (min 62 (+ arg1 -2)))) + (dotimes (a2-9 a1-9) + (when (logtest? a0-8 1) + (let* ((a3-9 (-> arg0 data a2-9)) + (t2-2 (-> v1-9 data a2-9)) + (t0-4 (-> t2-2 trans quad)) + (t1-1 (-> t2-2 quat vec quad)) + (t2-3 (-> t2-2 scale quad)) + ) + (set! (-> a3-9 trans quad) t0-4) + (set! (-> a3-9 quat vec quad) t1-1) + (set! (-> a3-9 scale quad) t2-3) + ) + ) + (set! a0-8 (shr a0-8 1)) + ) + ) + ) + (let ((a0-12 (min 64 (+ arg1 -64))) + (a1-11 (-> arg2 interp-select 1)) + ) + (dotimes (a2-10 a0-12) + (when (logtest? a1-11 1) + (let* ((a3-15 (-> arg0 data (+ a2-10 62))) + (t2-4 (-> v1-9 data (+ a2-10 62))) + (t0-9 (-> t2-4 trans quad)) + (t1-3 (-> t2-4 quat vec quad)) + (t2-5 (-> t2-4 scale quad)) + ) + (set! (-> a3-15 trans quad) t0-9) + (set! (-> a3-15 quat vec quad) t1-3) + (set! (-> a3-15 scale quad) t2-5) + ) + ) + (set! a1-11 (shr a1-11 1)) + ) + ) + ) + 0 + ) + +(defmethod print art-joint-anim-manager-slot ((obj art-joint-anim-manager-slot)) + (let* ((gp-0 format) + (s5-0 #t) + (s4-0 "#") + (v1-0 (-> obj anim)) + (s3-0 (if v1-0 + (-> v1-0 name) + ) + ) + (s1-0 (-> obj comp-data)) + (v1-1 (-> obj anim)) + ) + (gp-0 + s5-0 + s4-0 + s3-0 + s1-0 + (if v1-1 + (-> v1-1 frames fixed) + 0 + ) + (if (-> obj anim) + (sar + (used-bytes-for-slot + *anim-manager* + (the-as int (/ (the-as int (- (the-as uint obj) (the-as uint (the-as uint (-> *anim-manager* slot))))) 16)) + ) + 10 + ) + 0 + ) + (-> obj time-stamp) + ) + ) + obj + ) + +(defmethod used-bytes-for-slot art-joint-anim-manager ((obj art-joint-anim-manager) (arg0 int)) + (let ((v1-2 (-> obj slot arg0))) + (if (< arg0 (+ (-> obj free-index) -1)) + (&- + (the-as pointer (-> obj slot (+ arg0 1) anim frames fixed)) + (the-as uint (the-as pointer (-> v1-2 anim frames fixed))) + ) + (&- (the-as pointer (-> obj kheap current)) (the-as uint (the-as pointer (-> v1-2 anim frames fixed)))) + ) + ) + ) + +(defmethod unload-from-slot art-joint-anim-manager ((obj art-joint-anim-manager) (arg0 int)) + (let* ((s3-0 (-> obj slot arg0)) + (s5-0 (-> s3-0 anim)) + ) + (let ((s2-0 (the-as object (-> s5-0 frames fixed)))) + (if (= (-> *display* base-clock frame-counter) (-> s3-0 time-stamp)) + (format 0 "ERROR: anim-decomp: removing cache entry for ~A, but it is still in use.~%" s5-0) + ) + (let ((a0-5 (-> s3-0 comp-data)) + (v1-6 (-> s5-0 frames)) + ) + (set! (-> v1-6 fixed) (the-as joint-anim-compressed-fixed a0-5)) + (dotimes (a1-2 (the-as int (-> v1-6 num-frames))) + (set! (-> v1-6 data a1-2) + (the-as + joint-anim-compressed-frame + (+ a0-5 (* (+ (-> v1-6 fixed-qwc) (* (the-as uint a1-2) (-> v1-6 frame-qwc))) 16)) + ) + ) + ) + (logior! (-> v1-6 flags) 1) + (set! (-> v1-6 flags) (logand -3 (-> v1-6 flags))) + ) + (cond + ((< arg0 (+ (-> obj free-index) -1)) + (let ((s1-0 (- (the-as uint (-> obj slot (+ arg0 1) anim frames fixed)) (the-as uint s2-0)))) + (let ((s0-0 (+ (- -1 arg0) (-> obj free-index)))) + (let ((a2-6 (&- (-> obj kheap current) (the-as uint (+ (the-as uint s2-0) s1-0))))) + (if (< (the-as int a2-6) 2560) + (qmem-copy<-! (the-as pointer s2-0) (the-as pointer (+ (the-as uint s2-0) s1-0)) (the-as int a2-6)) + (ultimate-memcpy (the-as pointer s2-0) (the-as pointer (+ (the-as uint s2-0) s1-0)) (the-as uint a2-6)) + ) + ) + (qmem-copy<-! (the-as pointer s3-0) (the-as pointer (&+ s3-0 16)) (* s0-0 16)) + (dotimes (v1-20 s0-0) + (let ((a0-21 (-> obj slot (+ arg0 v1-20) anim frames))) + (set! (-> a0-21 fixed) (the-as joint-anim-compressed-fixed (- (the-as uint (-> a0-21 fixed)) s1-0))) + (dotimes (a1-9 (the-as int (-> a0-21 num-frames))) + (set! (-> a0-21 data a1-9) (the-as joint-anim-compressed-frame (- (the-as uint (-> a0-21 data a1-9)) s1-0))) + ) + ) + ) + ) + (set! s3-0 (-> obj slot (+ (-> obj free-index) -1))) + (set! (-> obj kheap current) (the pointer (- (the uint (-> obj kheap current)) (the-as uint s1-0)))) + ) + ) + (else + (set! (-> obj kheap current) (the-as pointer s2-0)) + ) + ) + ) + (+! (-> obj free-index) -1) + (set! (-> s3-0 anim) #f) + (set! (-> s3-0 time-stamp) (the-as uint 0)) + (set! (-> s3-0 comp-data) (the-as uint 0)) + s5-0 + ) + ) + +(defmethod update-time-stamp art-joint-anim-manager ((obj art-joint-anim-manager) (arg0 art-joint-anim)) + (countdown (v1-0 (-> obj free-index)) + (when (= arg0 (-> obj slot v1-0 anim)) + (set! (-> obj slot v1-0 time-stamp) (the-as uint (-> *display* base-clock frame-counter))) + (return arg0) + ) + ) + arg0 + ) + +(defmethod decompress art-joint-anim-manager ((obj art-joint-anim-manager) (arg0 art-joint-anim)) + (let* ((s5-0 (-> arg0 frames)) + (s3-0 (* (+ (-> s5-0 fixed-qwc) (* (-> s5-0 num-frames) (-> s5-0 frame-qwc))) 16)) + ) + (while (or (< (the-as uint (&- (-> obj kheap top) (the-as uint (-> obj kheap current)))) (+ s3-0 64)) + (>= (-> obj free-index) 64) + ) + (let ((a1-2 -1)) + (let ((a0-3 0)) + (dotimes (v1-2 (-> obj free-index)) + (when (or (< a1-2 0) (< (the-as int (-> obj slot v1-2 time-stamp)) a0-3)) + (set! a0-3 (the-as int (-> obj slot v1-2 time-stamp))) + (set! a1-2 v1-2) + ) + ) + ) + (unload-from-slot obj a1-2) + ) + ) + (let ((v1-15 (-> obj slot (-> obj free-index)))) + 0 + (+! (-> obj free-index) 1) + (set! (-> v1-15 anim) arg0) + (set! (-> v1-15 time-stamp) (the-as uint (-> *display* base-clock frame-counter))) + (set! (-> v1-15 comp-data) (the-as uint (-> s5-0 fixed))) + ) + (let ((s4-1 (kmalloc (-> obj kheap) (the-as int s3-0) (kmalloc-flags) "malloc"))) + (unpack-comp-lzo s4-1 (-> s5-0 fixed)) + (set! (-> s5-0 flags) (logand -2 (-> s5-0 flags))) + (logior! (-> s5-0 flags) 2) + (set! (-> s5-0 fixed) (the-as joint-anim-compressed-fixed s4-1)) + (dotimes (v1-22 (the-as int (-> s5-0 num-frames))) + (set! (-> s5-0 data v1-22) + (the-as + joint-anim-compressed-frame + (&+ s4-1 (* (+ (-> s5-0 fixed-qwc) (* (the-as uint v1-22) (-> s5-0 frame-qwc))) 16)) + ) + ) + ) + ) + ) + (flush-cache 0) + arg0 + ) + +(defmethod unload-from-level art-joint-anim-manager ((obj art-joint-anim-manager) (arg0 level)) + (let ((s5-0 (-> arg0 heap base)) + (s4-0 (-> arg0 heap top-base)) + ) + (countdown (s3-0 (-> obj free-index)) + (if (and (>= (the-as int (-> obj slot s3-0 anim)) (the-as int s5-0)) + (< (the-as int (-> obj slot s3-0 anim)) (the-as int s4-0)) + ) + (unload-from-slot obj s3-0) + ) + ) + ) + 0 + (none) + ) + +(kmemopen global "anim-manager") +(define *anim-manager* (new 'global 'art-joint-anim-manager #x30000)) +(kmemclose) diff --git a/goal_src/jak2/engine/anim/mspace-h.gc b/goal_src/jak2/engine/anim/mspace-h.gc index ac99a2599f..fe074a5dec 100644 --- a/goal_src/jak2/engine/anim/mspace-h.gc +++ b/goal_src/jak2/engine/anim/mspace-h.gc @@ -61,7 +61,8 @@ :size-assert #x20 :flag-assert #xa00000020 (:methods - (cspace-method-9 () none 9) + (new (symbol type basic) _type_ 0) + (reset-and-assign-geo! (_type_ basic) _type_ 9) ) ) diff --git a/goal_src/jak2/engine/data/art-h.gc b/goal_src/jak2/engine/data/art-h.gc index b099b3416a..b3f6108ea9 100644 --- a/goal_src/jak2/engine/data/art-h.gc +++ b/goal_src/jak2/engine/data/art-h.gc @@ -9,6 +9,7 @@ (declare-type merc-ctrl art-element) (declare-type ripple-control basic) (declare-type shadow-control basic) +(declare-type merc-eye-anim-block structure) (defenum draw-control-status :type uint16 @@ -83,8 +84,8 @@ ) (deftype joint-anim-frame (structure) - ((matrices matrix 2 :inline :offset-assert 0) - (data matrix :dynamic :offset-assert 128) + ((matrices matrix 2 :inline :offset-assert 0) + (data transformq :inline :dynamic :offset-assert 128) ) :method-count-assert 9 :size-assert #x80 @@ -160,10 +161,10 @@ :size-assert #x14 :flag-assert #xd00000014 (:methods - (art-method-9 () none 9) - (art-method-10 () none 10) - (art-method-11 () none 11) - (art-method-12 () none 12) + (login (_type_) _type_ 9) + (get-art-by-name-method (_type_ string type) basic 10) + (get-art-idx-by-name-method (_type_ string type) int 11) + (needs-link? (_type_) symbol 12) ) ) @@ -176,18 +177,18 @@ ) (deftype art-mesh-anim (art-element) - () + ((data basic :dynamic :offset-assert 32) + ) :method-count-assert 13 :size-assert #x20 :flag-assert #xd00000020 ) -;; definition of type art-joint-anim (deftype art-joint-anim (art-element) ((speed float :offset 20) (artist-base float :offset 24) (artist-step float :offset 28) - (eye-anim basic :offset 4) + (eye-anim merc-eye-anim-block :offset 4) (master-art-group-name string :offset-assert 32) (master-art-group-index int32 :offset-assert 36) (blend-shape-anim basic :offset-assert 40) @@ -206,32 +207,32 @@ :size-assert #x20 :flag-assert #xf00000020 (:methods - (art-group-method-13 () none 13) + (relocate (_type_ kheap (pointer uint8)) none :replace 7) + (link-art! (_type_) art-group 13) (art-group-method-14 () none 14) ) ) -;; definition of type art-mesh-geo (deftype art-mesh-geo (art-element) - () + ((data basic :dynamic :offset-assert 32) + ) :method-count-assert 13 :size-assert #x20 :flag-assert #xd00000020 ) -;; definition of type art-joint-geo (deftype art-joint-geo (art-element) - () + ((data joint :dynamic :offset-assert 32) + ) :method-count-assert 13 :size-assert #x20 :flag-assert #xd00000020 ) -;; definition of type art-joint-anim-manager-slot (deftype art-joint-anim-manager-slot (structure) - ((anim basic :offset-assert 0) - (comp-data uint32 :offset-assert 4) - (time-stamp uint64 :offset-assert 8) + ((anim art-joint-anim :offset-assert 0) + (comp-data uint32 :offset-assert 4) + (time-stamp uint64 :offset-assert 8) ) :method-count-assert 9 :size-assert #x10 @@ -248,10 +249,10 @@ :flag-assert #xe00000430 (:methods (new (symbol type int) _type_ 0) - (art-joint-anim-manager-method-9 () none 9) - (art-joint-anim-manager-method-10 () none 10) - (unload-from-slot (_type_ int) none 11) - (art-joint-anim-manager-method-12 () none 12) + (decompress (_type_ art-joint-anim) art-joint-anim 9) + (update-time-stamp (_type_ art-joint-anim) art-joint-anim 10) + (unload-from-slot (_type_ int) art-joint-anim 11) + (used-bytes-for-slot (_type_ int) int 12) (unload-from-level (_type_ level) none 13) ) ) diff --git a/goal_src/jak2/engine/debug/memory-usage-h.gc b/goal_src/jak2/engine/debug/memory-usage-h.gc index 7333d6aec2..9432436be3 100644 --- a/goal_src/jak2/engine/debug/memory-usage-h.gc +++ b/goal_src/jak2/engine/debug/memory-usage-h.gc @@ -5,6 +5,36 @@ ;; name in dgo: memory-usage-h ;; dgos: ENGINE, GAME +(defenum mem-usage-id + :bitfield #f + :type uint32 + (entity 43) + (camera 44) + + (res 48) + + (bsp-leaf-vis-self 62) + (bsp-leaf-vis-adj 63) + + (level-code 65) + (entity-links 66) + + (joint 67) + + (joint-anim-compressed-control 69) + (joint-anim-fixed 70) + (joint-anim-frame 71) + + (art-group 73) + (art-mesh-anim 74) + (art-mesh-geo 75) + (art-joint-geo 76) + (art-joint-anim 77) + + (joint-anim-drawable 78) + + (eye-anim 111) + ) ;; DECOMP BEGINS (declare-file (debug)) @@ -42,5 +72,7 @@ ) +(define-extern mem-size (function basic symbol int int)) + diff --git a/goal_src/jak2/engine/level/level-h.gc b/goal_src/jak2/engine/level/level-h.gc index cd716a08e0..1792f1e5b2 100644 --- a/goal_src/jak2/engine/level/level-h.gc +++ b/goal_src/jak2/engine/level/level-h.gc @@ -16,6 +16,8 @@ (define-extern *level* level-group) (define-extern *draw-index* int) (define-extern *level-index* int) +(define-extern *print-login* symbol) + (defenum load-buffer-mode :type uint32 @@ -487,7 +489,7 @@ (:methods (level-get (_type_ symbol) level 9) (level-get-with-status (_type_ symbol) level 10) - (get-level-by-heap-ptr-and-status (_type_ pointer uint) level 11) + (get-level-by-heap-ptr-and-status (_type_ pointer symbol) level 11) (level-get-for-use (_type_ symbol symbol) level 12) (activate-levels! (_type_) int 13) (level-group-method-14 () none 14) diff --git a/goal_src/jak2/engine/load/decomp-h.gc b/goal_src/jak2/engine/load/decomp-h.gc index c9d0de7dcd..fe4cb6027a 100644 --- a/goal_src/jak2/engine/load/decomp-h.gc +++ b/goal_src/jak2/engine/load/decomp-h.gc @@ -5,6 +5,8 @@ ;; name in dgo: decomp-h ;; dgos: ENGINE, GAME +(define-extern unpack-comp-lzo (function object object none)) + ;; DECOMP BEGINS ;; temporary storage for visibility data decompression. diff --git a/goal_src/jak2/kernel/gkernel-h.gc b/goal_src/jak2/kernel/gkernel-h.gc index d6df11c754..2eab881de8 100644 --- a/goal_src/jak2/kernel/gkernel-h.gc +++ b/goal_src/jak2/kernel/gkernel-h.gc @@ -714,4 +714,9 @@ (defmacro defmethod-mips2c (name method-id method-type) "Define a mips2c method." `(method-set! ,method-type ,method-id (__pc-get-mips2c ,name)) + ) + +(defmacro scratchpad-object (type &key (offset 0)) + "Access an object on the scratchpad." + `(the-as ,type (&+ *fake-scratchpad-data* ,offset)) ) \ No newline at end of file diff --git a/test/decompiler/reference/jak2/decompiler-macros.gc b/test/decompiler/reference/jak2/decompiler-macros.gc index 9a73f7c0be..da960e42d1 100644 --- a/test/decompiler/reference/jak2/decompiler-macros.gc +++ b/test/decompiler/reference/jak2/decompiler-macros.gc @@ -792,4 +792,9 @@ (defmacro set-setting! (s &rest args) `(setting-control-func! set-setting ,s ,@args) + ) + +(defmacro get-art-by-name (obj name type) + "Helper macro for casting the result of get-art-by-name-method. Generated by decompiler." + `(the-as ,type (get-art-by-name-method ,obj ,name ,type)) ) \ No newline at end of file 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 8b1ef04be7..e895e880ac 100644 --- a/test/decompiler/reference/jak2/engine/anim/joint-h_REF.gc +++ b/test/decompiler/reference/jak2/engine/anim/joint-h_REF.gc @@ -3,18 +3,18 @@ ;; definition of type joint-control-channel (deftype joint-control-channel (structure) - ((parent joint-control :offset-assert 0) - (frame-group art-joint-anim :offset-assert 4) - (frame-num float :offset-assert 8) - (dist meters :offset-assert 12) - (num-func (function joint-control-channel float float float) :offset-assert 16) - (param float 3 :offset-assert 20) - (frame-interp float 2 :offset-assert 32) - (inspector-amount uint8 :offset-assert 40) - (command joint-control-command :offset-assert 48) - (group-sub-index int8 :offset-assert 56) - (grou-size int8 :offset-assert 57) - (eval-time uint32 :offset-assert 60) + ((parent joint-control :offset-assert 0) + (frame-group art-joint-anim :offset-assert 4) + (frame-num float :offset-assert 8) + (dist meters :offset-assert 12) + (num-func (function joint-control-channel float float float float) :offset-assert 16) + (param float 3 :offset-assert 20) + (frame-interp float 2 :offset-assert 32) + (inspector-amount uint8 :offset-assert 40) + (command joint-control-command :offset-assert 48) + (group-sub-index int8 :offset-assert 56) + (group-size int8 :offset-assert 57) + (eval-time uint32 :offset-assert 60) ) :method-count-assert 9 :size-assert #x40 @@ -74,7 +74,7 @@ ) ) (format #t "~1Tgroup-sub-index: ~D~%" (-> obj group-sub-index)) - (format #t "~1Tgroup-size: ~D~%" (-> obj grou-size)) + (format #t "~1Tgroup-size: ~D~%" (-> obj group-size)) (format #t "~1Teval-time: ~D~%" (-> obj eval-time)) (label cfg-23) obj @@ -165,9 +165,10 @@ :size-assert #x40 :flag-assert #xc00000040 (:methods + (new (symbol type int) _type_ 0) (joint-control-method-9 () none 9) (joint-control-method-10 () none 10) - (joint-control-method-11 () none 11) + (debug-print-channels (_type_ symbol) int 11) ) ) @@ -339,7 +340,3 @@ ;; failed to figure out what this is: 0 - - - - diff --git a/test/decompiler/reference/jak2/engine/anim/joint_REF.gc b/test/decompiler/reference/jak2/engine/anim/joint_REF.gc new file mode 100644 index 0000000000..ac53121178 --- /dev/null +++ b/test/decompiler/reference/jak2/engine/anim/joint_REF.gc @@ -0,0 +1,2160 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition for method 2 of type joint +(defmethod print joint ((obj joint)) + (format #t "#<~A ~S ~D @ #x~X>" (-> obj type) (-> obj name) (-> obj number) obj) + obj + ) + +;; definition for method 8 of type joint +(defmethod mem-usage joint ((obj joint) (arg0 memory-usage-block) (arg1 int)) + (set! (-> arg0 length) (max 68 (-> arg0 length))) + (set! (-> arg0 data 67 name) "joint") + (+! (-> arg0 data 67 count) 1) + (let ((v1-6 (asize-of obj))) + (+! (-> arg0 data 67 used) v1-6) + (+! (-> arg0 data 67 total) (logand -16 (+ v1-6 15))) + ) + obj + ) + +;; definition for method 2 of type joint-anim +(defmethod print joint-anim ((obj joint-anim)) + (format #t "#<~A ~S ~D [~D] @ #x~X>" (-> obj type) (-> obj name) (-> obj number) (-> obj length) obj) + obj + ) + +;; definition for method 4 of type joint-anim +(defmethod length joint-anim ((obj joint-anim)) + (-> obj length) + ) + +;; definition for method 5 of type joint-anim-matrix +;; INFO: Return type mismatch uint vs int. +(defmethod asize-of joint-anim-matrix ((obj joint-anim-matrix)) + (the-as int (+ (-> joint-anim-matrix size) (* (-> obj length) 64))) + ) + +;; definition for method 5 of type joint-anim-transformq +;; INFO: Return type mismatch uint vs int. +(defmethod asize-of joint-anim-transformq ((obj joint-anim-transformq)) + (the-as int (+ (-> joint-anim-transformq size) (* 48 (-> obj length)))) + ) + +;; definition for method 5 of type joint-anim-drawable +;; INFO: Return type mismatch uint vs int. +(defmethod asize-of joint-anim-drawable ((obj joint-anim-drawable)) + (the-as int (+ (-> joint-anim-drawable size) (* (-> obj length) 4))) + ) + +;; definition for function joint-anim-login +(defun joint-anim-login ((arg0 joint-anim-drawable)) + (dotimes (s5-0 (-> arg0 length)) + (if (-> arg0 data s5-0) + (login (-> arg0 data s5-0)) + ) + ) + arg0 + ) + +;; definition for function joint-anim-inspect-elt +(defun joint-anim-inspect-elt ((arg0 joint-anim) (arg1 float)) + (case (-> arg0 type) + ((joint-anim-matrix) + (inspect (-> (the-as joint-anim-matrix arg0) data (the int arg1))) + ) + ((joint-anim-transformq) + (format #t "~`transform`P~%" (-> (the-as joint-anim-transformq arg0) data (the int arg1))) + ) + ) + arg0 + ) + +;; definition for method 8 of type joint-anim-drawable +(defmethod mem-usage joint-anim-drawable ((obj joint-anim-drawable) (arg0 memory-usage-block) (arg1 int)) + (set! (-> arg0 length) (max 80 (-> arg0 length))) + (set! (-> arg0 data 79 name) "joint-anim-drawable") + (+! (-> arg0 data 79 count) 1) + (let ((v1-6 (asize-of obj))) + (+! (-> arg0 data 79 used) v1-6) + (+! (-> arg0 data 79 total) (logand -16 (+ v1-6 15))) + ) + (dotimes (s3-0 (-> obj length)) + (mem-usage (-> obj data s3-0) arg0 arg1) + ) + obj + ) + +;; definition for function jacc-mem-usage +(defun jacc-mem-usage ((arg0 joint-anim-compressed-control) (arg1 memory-usage-block) (arg2 int)) + (set! (-> arg1 length) (max 70 (-> arg1 length))) + (set! (-> arg1 data 69 name) "joint-anim-compressed-control") + (+! (-> arg1 data 69 count) 1) + (let ((v1-7 (+ (* (-> arg0 num-frames) 4) 16))) + (+! (-> arg1 data 69 used) v1-7) + (+! (-> arg1 data 69 total) (logand -16 (+ v1-7 15))) + ) + (set! (-> arg1 length) (max 71 (-> arg1 length))) + (set! (-> arg1 data 70 name) "joint-anim-fixed") + (+! (-> arg1 data 70 count) 1) + (let ((v1-17 (+ (-> arg0 fixed-qwc) 16))) + (+! (-> arg1 data 70 used) v1-17) + (+! (-> arg1 data 70 total) (logand -16 (+ v1-17 15))) + ) + (dotimes (v1-21 (the-as int (-> arg0 num-frames))) + (set! (-> arg1 length) (max 72 (-> arg1 length))) + (set! (-> arg1 data 71 name) "joint-anim-frame") + (+! (-> arg1 data 71 count) 1) + (let ((a2-15 (* (-> arg0 frame-qwc) 16))) + (+! (-> arg1 data 71 used) a2-15) + (+! (-> arg1 data 71 total) (logand -16 (+ a2-15 15))) + ) + ) + arg0 + ) + +;; definition for method 2 of type joint-control-channel +(defmethod print joint-control-channel ((obj joint-control-channel)) + (let ((t9-0 format) + (a0-1 #t) + (a1-0 "#") + (v1-0 (-> obj command)) + ) + (t9-0 + a0-1 + a1-0 + (cond + ((= v1-0 (joint-control-command stack1)) + "stack1" + ) + ((= v1-0 (joint-control-command push)) + "push" + ) + ((= v1-0 (joint-control-command blend)) + "blend" + ) + ((= v1-0 (joint-control-command push1)) + "push1" + ) + ((= v1-0 (joint-control-command float)) + "float" + ) + ((= v1-0 (joint-control-command stack)) + "stack" + ) + (else + "*unknown*" + ) + ) + (-> obj frame-group) + (-> obj frame-num) + obj + ) + ) + obj + ) + +;; definition for method 5 of type joint-control +;; INFO: Return type mismatch uint vs int. +(defmethod asize-of joint-control ((obj joint-control)) + (the-as int (+ (-> obj type size) (* (-> obj allocated-length) 64))) + ) + +;; definition for method 0 of type joint-control +(defmethod new joint-control ((allocation symbol) (type-to-make type) (arg0 int)) + (let ((v0-0 (object-new allocation type-to-make (the-as int (+ (-> type-to-make size) (* arg0 64)))))) + (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 generate-frame-function) create-interpolated-joint-animation-frame) + (set! (-> v0-0 prebind-function) #f) + (set! (-> v0-0 postbind-function) #f) + (set! (-> v0-0 effect) #f) + (set! (-> v0-0 top-anim) #f) + (set! (-> v0-0 override) #f) + (dotimes (v1-4 arg0) + (set! (-> v0-0 channel v1-4 parent) v0-0) + ) + (set! (-> v0-0 blend-index) (the-as uint -1)) + v0-0 + ) + ) + +;; definition for method 11 of type joint-control +(defmethod debug-print-channels joint-control ((obj joint-control) (arg0 symbol)) + (format arg0 "~0K") + (dotimes (s4-0 (the-as int (+ (-> obj active-channels) (-> obj float-channels)))) + (let* ((s3-0 (-> obj channel s4-0)) + (s2-0 (if (and (-> s3-0 frame-group) (nonzero? (-> s3-0 frame-group))) + (-> s3-0 frame-group) + ) + ) + ) + (let* ((t9-1 format) + (a0-3 arg0) + (a1-2 "~S~2d ~C ~-35S ") + (a2-0 (if (= (-> obj root-channel) s3-0) + "~3Lch:~0L" + "ch:" + ) + ) + (a3-0 s4-0) + (v1-6 (-> s3-0 command)) + (t0-2 (cond + ((= v1-6 (joint-control-command push)) + 80 + ) + ((= v1-6 (joint-control-command push1)) + 112 + ) + ((= v1-6 (joint-control-command blend)) + 66 + ) + ((= v1-6 (joint-control-command stack)) + 83 + ) + ((= v1-6 (joint-control-command stack1)) + 115 + ) + ((= v1-6 (joint-control-command float)) + 102 + ) + ) + ) + ) + (t9-1 a0-3 a1-2 a2-0 a3-0 t0-2 (if s2-0 + (-> s2-0 name) + "(none)" + ) + ) + ) + (if (and (= (-> s3-0 frame-interp 0) 0.0) (!= (-> s3-0 frame-interp 1) 0.0)) + (format + arg0 + "f: ~6,,2f ~1L~4,,2f~0L ~4,,2f%~%" + (+ (* (-> s3-0 frame-num) (if s2-0 + (-> s2-0 artist-step) + 1.0 + ) + ) + (if s2-0 + (-> s2-0 artist-base) + 0.0 + ) + ) + (-> s3-0 frame-interp 1) + (* 0.003921569 (the float (-> s3-0 inspector-amount))) + ) + (format + arg0 + "f: ~6,,2f ~4,,2f ~4,,2f%~%" + (+ (* (-> s3-0 frame-num) (if s2-0 + (-> s2-0 artist-step) + 1.0 + ) + ) + (if s2-0 + (-> s2-0 artist-base) + 0.0 + ) + ) + (-> s3-0 frame-interp (-> obj active-frame-interp)) + (* 0.003921569 (the float (-> s3-0 inspector-amount))) + ) + ) + ) + ) + (format arg0 "~1K") + 0 + ) + +;; definition for method 12 of type art +(defmethod needs-link? art ((obj art)) + #f + ) + +;; definition for method 10 of type art +;; INFO: Return type mismatch symbol vs basic. +(defmethod get-art-by-name-method art ((obj art) (arg0 string) (arg1 type)) + (the-as basic #f) + ) + +;; definition for method 11 of type art +;; INFO: Return type mismatch symbol vs int. +(defmethod get-art-idx-by-name-method art ((obj art) (arg0 string) (arg1 type)) + (the-as int #f) + ) + +;; definition for method 2 of type art +(defmethod print art ((obj art)) + (format #t "#<~A ~S :length ~D @ #x~X>" (-> obj type) (-> obj name) (-> obj length) obj) + obj + ) + +;; definition for method 4 of type art +(defmethod length art ((obj art)) + (-> obj length) + ) + +;; definition for method 9 of type art +(defmethod login art ((obj art)) + (if (and (-> obj extra) (zero? (-> obj extra tag))) + (set! (-> obj extra tag) (the-as (pointer res-tag) (&+ (the-as pointer (-> obj extra)) 28))) + ) + obj + ) + +;; definition for method 8 of type art-mesh-anim +(defmethod mem-usage art-mesh-anim ((obj art-mesh-anim) (arg0 memory-usage-block) (arg1 int)) + (set! (-> arg0 length) (max 75 (-> arg0 length))) + (set! (-> arg0 data 74 name) "art-mesh-anim") + (+! (-> arg0 data 74 count) 1) + (let ((v1-6 (asize-of obj))) + (+! (-> arg0 data 74 used) v1-6) + (+! (-> arg0 data 74 total) (logand -16 (+ v1-6 15))) + ) + (if (-> obj extra) + (mem-usage (-> obj extra) arg0 (logior arg1 512)) + ) + (dotimes (s3-0 (-> obj length)) + (mem-usage (-> obj data s3-0) arg0 arg1) + ) + obj + ) + +;; definition for method 8 of type art-joint-anim +(defmethod mem-usage art-joint-anim ((obj art-joint-anim) (arg0 memory-usage-block) (arg1 int)) + (set! (-> arg0 length) (max 78 (-> arg0 length))) + (set! (-> arg0 data 77 name) "art-joint-anim") + (+! (-> arg0 data 77 count) 1) + (let ((v1-6 (asize-of obj))) + (+! (-> arg0 data 77 used) v1-6) + (+! (-> arg0 data 77 total) (logand -16 (+ v1-6 15))) + ) + (if (-> obj extra) + (mem-usage (-> obj extra) arg0 (logior arg1 512)) + ) + (jacc-mem-usage (-> obj frames) arg0 arg1) + (when (and (nonzero? (-> obj eye-anim)) (-> obj eye-anim)) + (set! (-> arg0 length) (max 112 (-> arg0 length))) + (set! (-> arg0 data 111 name) "eye-anim") + (+! (-> arg0 data 111 count) 1) + (let ((v1-26 (* (* (+ (-> obj eye-anim max-frame) 1) 2) 8))) + (+! (-> arg0 data 111 used) v1-26) + (+! (-> arg0 data 111 total) (logand -16 (+ v1-26 15))) + ) + ) + obj + ) + +;; definition for method 5 of type art-joint-anim +;; INFO: Return type mismatch uint vs int. +(defmethod asize-of art-joint-anim ((obj art-joint-anim)) + (the-as int (+ (-> art size) (* (-> obj length) 4))) + ) + +;; definition for method 3 of type art-group +(defmethod inspect art-group ((obj art-group)) + (format #t "[~8x] ~A~%" obj (-> obj type)) + (format #t "~Tinfo: ~A~%" (-> obj info)) + (format #t "~Tlength: ~D~%" (-> obj length)) + (format #t "~Tname: ~A~%" (-> obj name)) + (format #t "~Textra: ~A~%" (-> obj extra)) + (format #t "~Tdata[~D]: @ #x~X~%" (-> obj length) (-> obj data)) + (dotimes (s5-0 (-> obj length)) + (if (-> obj data s5-0) + (format #t "~T [~D] ~A (~D bytes)~%" s5-0 (-> obj data s5-0) (mem-size (-> obj data s5-0) #f 0)) + (format #t "~T [~D] ~A (~D bytes)~%" s5-0 (-> obj data s5-0) 0) + ) + ) + obj + ) + +;; definition for method 12 of type art-group +(defmethod needs-link? art-group ((obj art-group)) + (and (nonzero? (-> obj length)) + (type? (-> obj data 0) art-joint-anim) + (!= (-> obj name) (-> (the-as art-joint-anim (-> obj data 0)) master-art-group-name)) + ) + ) + +;; definition for method 10 of type art-group +;; INFO: Return type mismatch art-element vs basic. +(defmethod get-art-by-name-method art-group ((obj art-group) (arg0 string) (arg1 type)) + (cond + (arg1 + (let ((s3-0 (+ (length (-> obj name)) 1))) + (dotimes (s2-0 (-> obj length)) + (if (and (-> obj data s2-0) + (= (-> obj data s2-0 type) arg1) + (or (name= arg0 (-> obj data s2-0 name)) (string-charp= arg0 (&-> (-> obj data s2-0 name) data s3-0))) + ) + (return (the-as basic (-> obj data s2-0))) + ) + ) + ) + (the-as art-element #f) + ) + (else + (dotimes (s4-1 (-> obj length)) + (if (and (-> obj data s4-1) (name= arg0 (-> obj data s4-1 name))) + (return (the-as basic (-> obj data s4-1))) + ) + ) + (the-as art-element #f) + ) + ) + ) + +;; definition for method 11 of type art-group +(defmethod get-art-idx-by-name-method art-group ((obj art-group) (arg0 string) (arg1 type)) + (cond + (arg1 + (let ((s3-0 (+ (length (-> obj name)) 1))) + (dotimes (s2-0 (-> obj length)) + (if (and (-> obj data s2-0) + (= (-> obj data s2-0 type) arg1) + (or (name= arg0 (-> obj data s2-0 name)) (string-charp= arg0 (&-> (-> obj data s2-0 name) data s3-0))) + ) + (return s2-0) + ) + ) + ) + (the-as int #f) + ) + (else + (dotimes (s4-1 (-> obj length)) + (if (and (-> obj data s4-1) (name= arg0 (-> obj data s4-1 name))) + (return s4-1) + ) + ) + (the-as int #f) + ) + ) + ) + +;; definition for method 9 of type art-group +(defmethod login art-group ((obj art-group)) + (dotimes (s5-0 (-> obj length)) + (if (-> obj data s5-0) + (set! (-> obj data s5-0) (login (-> obj data s5-0))) + ) + ) + obj + ) + +;; definition for method 8 of type art-group +(defmethod mem-usage art-group ((obj art-group) (arg0 memory-usage-block) (arg1 int)) + (set! (-> arg0 length) (max 74 (-> arg0 length))) + (set! (-> arg0 data 73 name) "art-group") + (+! (-> arg0 data 73 count) 1) + (let ((v1-6 (asize-of obj))) + (+! (-> arg0 data 73 used) v1-6) + (+! (-> arg0 data 73 total) (logand -16 (+ v1-6 15))) + ) + (if (-> obj extra) + (mem-usage (-> obj extra) arg0 (logior arg1 512)) + ) + (dotimes (s3-0 (-> obj length)) + (if (-> obj data s3-0) + (mem-usage (-> obj data s3-0) arg0 arg1) + ) + ) + obj + ) + +;; definition for method 7 of type art-group +;; INFO: Return type mismatch art-group vs none. +(defmethod relocate art-group ((obj art-group) (arg0 kheap) (arg1 (pointer uint8))) + (let ((s4-0 (clear *temp-string*))) + (string<-charp s4-0 arg1) + (set! obj + (cond + ((not obj) + (format 0 "ERROR: art-group ~A is not a valid file.~%" s4-0) + (the-as art-group #f) + ) + ((not (type? obj art-group)) + (format 0 "ERROR: art-group ~A is not a art-group.~%" s4-0) + (the-as art-group #f) + ) + ((not (file-info-correct-version? (-> obj info) (file-kind art-group) 0)) + (the-as art-group #f) + ) + (else + (let ((s5-1 (-> *level* loading-level))) + (if (and (nonzero? (-> s5-1 code-memory-end)) (< (the-as uint (-> s5-1 load-buffer-mode)) (the-as uint 2))) + (set! (-> s5-1 load-buffer-mode) (load-buffer-mode medium)) + ) + (cond + ((and s5-1 (= (-> s5-1 name) 'default) (not *print-login*)) + (format + 0 + "ERROR: illegal login of art ~A (in level ~A) to level ~A~%" + obj + (get-level-by-heap-ptr-and-status *level* (the-as pointer obj) 'loading) + s5-1 + ) + (break!) + 0 + ) + ((or (not s5-1) (= (-> s5-1 name) 'default)) + ) + ((!= (get-level-by-heap-ptr-and-status *level* (the-as pointer obj) 'loading) s5-1) + (format + 0 + "ERROR: illegal login of art ~A (in level ~A) to level ~A~%" + obj + (get-level-by-heap-ptr-and-status *level* (the-as pointer obj) 'loading) + s5-1 + ) + (break!) + 0 + ) + ) + (when (or (not s5-1) (= (-> s5-1 name) 'default)) + (login obj) + (if (needs-link? obj) + (link-art! obj) + ) + ) + (if s5-1 + (set-loaded-art (-> s5-1 art-group) obj) + ) + ) + obj + ) + ) + ) + ) + (none) + ) + +;; definition for method 5 of type art-mesh-geo +;; INFO: Return type mismatch uint vs int. +(defmethod asize-of art-mesh-geo ((obj art-mesh-geo)) + (the-as int (+ (-> art size) (* (-> obj length) 4))) + ) + +;; definition for method 8 of type art-mesh-geo +(defmethod mem-usage art-mesh-geo ((obj art-mesh-geo) (arg0 memory-usage-block) (arg1 int)) + (set! (-> arg0 length) (max 76 (-> arg0 length))) + (set! (-> arg0 data 75 name) "art-mesh-geo") + (+! (-> arg0 data 75 count) 1) + (let ((v1-6 (asize-of obj))) + (+! (-> arg0 data 75 used) v1-6) + (+! (-> arg0 data 75 total) (logand -16 (+ v1-6 15))) + ) + (if (-> obj extra) + (mem-usage (-> obj extra) arg0 (logior arg1 512)) + ) + (dotimes (s3-0 (-> obj length)) + (mem-usage (-> obj data s3-0) arg0 arg1) + ) + obj + ) + +;; definition for method 9 of type art-mesh-geo +(defmethod login art-mesh-geo ((obj art-mesh-geo)) + (dotimes (s5-0 (-> obj length)) + (let ((s4-0 (the-as object (-> obj data s5-0)))) + (dotimes (s3-0 (-> (the-as (pointer int16) s4-0) 3)) + (if (-> (the-as (pointer art) (+ (* s3-0 4) (the-as int s4-0))) 2) + (login (the-as drawable (-> (the-as (pointer art) (+ (* s3-0 4) (the-as int s4-0))) 2))) + ) + ) + ) + ) + obj + ) + +;; definition for method 9 of type art-joint-anim +(defmethod login art-joint-anim ((obj art-joint-anim)) + (if (and (-> obj extra) (zero? (-> obj extra tag))) + (set! (-> obj extra tag) (the-as (pointer res-tag) (&+ (the-as pointer (-> obj extra)) 28))) + ) + obj + ) + +;; definition for method 5 of type art-joint-geo +;; INFO: Return type mismatch uint vs int. +(defmethod asize-of art-joint-geo ((obj art-joint-geo)) + (the-as int (+ (-> art size) (* (-> obj length) 4))) + ) + +;; definition for method 10 of type art-joint-geo +;; INFO: Return type mismatch joint vs basic. +(defmethod get-art-by-name-method art-joint-geo ((obj art-joint-geo) (arg0 string) (arg1 type)) + (cond + (arg1 + (dotimes (s3-0 (-> obj length)) + (if (and (= (-> obj data s3-0 type) arg1) (name= arg0 (-> obj data s3-0 name))) + (return (the-as basic (-> obj data s3-0))) + ) + ) + (the-as joint #f) + ) + (else + (dotimes (s4-1 (-> obj length)) + (if (name= arg0 (-> obj data s4-1 name)) + (return (the-as basic (-> obj data s4-1))) + ) + ) + (the-as joint #f) + ) + ) + ) + +;; definition for method 11 of type art-joint-geo +(defmethod get-art-idx-by-name-method art-joint-geo ((obj art-joint-geo) (arg0 string) (arg1 type)) + (cond + (arg1 + (dotimes (s3-0 (-> obj length)) + (if (and (= (-> obj data s3-0 type) arg1) (name= arg0 (-> obj data s3-0 name))) + (return s3-0) + ) + ) + (the-as int #f) + ) + (else + (dotimes (s4-1 (-> obj length)) + (if (name= arg0 (-> obj data s4-1 name)) + (return s4-1) + ) + ) + (the-as int #f) + ) + ) + ) + +;; definition for method 8 of type art-joint-geo +(defmethod mem-usage art-joint-geo ((obj art-joint-geo) (arg0 memory-usage-block) (arg1 int)) + (set! (-> arg0 length) (max 77 (-> arg0 length))) + (set! (-> arg0 data 76 name) "art-joint-geo") + (+! (-> arg0 data 76 count) 1) + (let ((v1-6 (asize-of obj))) + (+! (-> arg0 data 76 used) v1-6) + (+! (-> arg0 data 76 total) (logand -16 (+ v1-6 15))) + ) + (if (-> obj extra) + (mem-usage (-> obj extra) arg0 (logior arg1 512)) + ) + (dotimes (s3-0 (-> obj length)) + (mem-usage (-> obj data s3-0) arg0 arg1) + ) + obj + ) + +;; definition for function joint-control-channel-eval +(defbehavior joint-control-channel-eval process ((arg0 joint-control-channel)) + (let ((f0-3 ((-> arg0 num-func) arg0 (-> arg0 param 0) (-> arg0 param 1) (-> arg0 param 2)))) + (set! (-> arg0 eval-time) (the-as uint (-> self clock frame-counter))) + f0-3 + ) + ) + +;; definition for function joint-control-channel-eval! +(defbehavior joint-control-channel-eval! process ((arg0 joint-control-channel) (arg1 (function joint-control-channel float float float float))) + (set! (-> arg0 num-func) arg1) + (let ((f0-3 (arg1 arg0 (-> arg0 param 0) (-> arg0 param 1) (-> arg0 param 2)))) + (set! (-> arg0 eval-time) (the-as uint (-> self clock frame-counter))) + f0-3 + ) + ) + +;; definition for function joint-control-channel-group-eval! +(defun joint-control-channel-group-eval! ((arg0 joint-control-channel) + (arg1 art-joint-anim) + (arg2 (function joint-control-channel float float float float)) + ) + (with-pp + (set! (-> arg0 num-func) arg2) + (cond + ((= (-> arg0 command) (joint-control-command stack)) + ) + (else + (if arg1 + (set! (-> arg0 frame-group) arg1) + ) + (arg2 arg0 (-> arg0 param 0) (-> arg0 param 1) (-> arg0 param 2)) + (set! (-> arg0 eval-time) (the-as uint (-> pp clock frame-counter))) + ) + ) + 0 + ) + ) + +;; definition for function joint-control-channel-group! +(defun joint-control-channel-group! ((arg0 joint-control-channel) + (arg1 art-joint-anim) + (arg2 (function joint-control-channel float float float float)) + ) + (set! (-> arg0 num-func) arg2) + (cond + ((= (-> arg0 command) (joint-control-command stack)) + ) + (arg1 + (set! (-> arg0 frame-group) arg1) + ) + ) + 0 + ) + +;; definition for function joint-control-copy! +(defun joint-control-copy! ((arg0 joint-control) (arg1 joint-control)) + (set! (-> arg0 blend-index) (-> arg1 blend-index)) + (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))) + ) + (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)) + ) + (dotimes (v1-12 (the-as int (-> arg0 allocated-length))) + (set! (-> arg0 channel v1-12 parent) arg0) + ) + arg0 + ) + +;; definition for function joint-control-remap! +;; INFO: Used lq/sq +;; INFO: Return type mismatch symbol vs object. +;; WARN: Using new Jak 2 rtype-of +(defun joint-control-remap! ((arg0 joint-control) (arg1 art-group) (arg2 art-group) (arg3 pair) (arg4 int) (arg5 string)) + (local-vars + (sv-16 int) + (sv-24 symbol) + (sv-32 int) + (sv-40 int) + (sv-48 joint-control-channel) + (sv-52 basic) + (sv-56 object) + (sv-60 basic) + (sv-64 art-joint-anim) + (sv-80 string) + ) + (set! sv-16 (+ (length (-> arg2 name)) 1)) + (set! sv-24 #t) + (set! sv-32 arg4) + (set! sv-40 2) + (while (and (< sv-40 (-> arg1 length)) (or (not (-> arg1 data sv-40)) (!= (-> arg1 data sv-40 type) art-joint-anim))) + (set! sv-40 (+ sv-40 1)) + ) + (dotimes (s2-1 (the-as int (+ (-> arg0 active-channels) (-> arg0 float-channels)))) + (set! sv-48 (-> arg0 channel s2-1)) + (set! sv-52 (the-as basic #f)) + (when (-> sv-48 frame-group) + (format (clear *temp-string*) "~S~G" arg5 (&+ (-> sv-48 frame-group name data) sv-16)) + (when (not (null? arg3)) + (set! sv-56 (nassoc *temp-string* arg3)) + (when sv-56 + (let* ((s1-1 sv-32) + (a0-8 sv-56) + (v1-36 (mod s1-1 (+ ((method-of-type (rtype-of a0-8) length) a0-8) -1))) + ) + (set! sv-60 (the-as basic (ref sv-56 (+ v1-36 1)))) + ) + (cond + ((= (-> sv-60 type) string) + (format (clear *temp-string*) "~S" sv-60) + ) + ((= (-> sv-60 type) function) + (set! sv-52 sv-60) + (let ((s1-3 format) + (s0-0 (clear *temp-string*)) + ) + (set! sv-80 "~S") + (let ((a2-4 ((the-as (function joint-control joint-control-channel int object) sv-52) arg0 sv-48 0))) + (s1-3 s0-0 sv-80 a2-4) + ) + ) + ) + ) + ) + ) + (set! sv-64 (get-art-by-name arg1 *temp-string* art-joint-anim)) + (cond + (sv-64 + (let* ((v1-46 (-> sv-48 frame-group)) + (f0-2 (+ (* (-> sv-48 frame-num) (-> v1-46 artist-step)) (-> v1-46 artist-base))) + ) + (set! (-> sv-48 frame-group) sv-64) + (set! (-> sv-48 frame-num) (/ (- f0-2 (-> sv-64 artist-base)) (-> sv-64 artist-step))) + ) + (set! (-> sv-48 frame-num) + (fmax 0.0 (fmin (-> sv-48 frame-num) (the float (+ (-> sv-64 frames num-frames) -1)))) + ) + (if sv-52 + ((the-as (function joint-control joint-control-channel int object) sv-52) arg0 sv-48 1) + ) + ) + (else + (set! (-> sv-48 frame-group) (the-as art-joint-anim (-> arg1 data sv-40))) + (set! (-> sv-48 frame-num) 0.0) + (set! sv-24 (the-as symbol #f)) + ) + ) + ) + ) + (the-as object sv-24) + ) + +;; definition for function flatten-joint-control-to-spr +;; INFO: Used lq/sq +(defun flatten-joint-control-to-spr ((arg0 joint-control)) + (rlet ((vf1 :class vf) + (vf10 :class vf) + (vf11 :class vf) + (vf12 :class vf) + (vf13 :class vf) + (vf14 :class vf) + (vf2 :class vf) + (vf3 :class vf) + (vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + (vf7 :class vf) + (vf8 :class vf) + (vf9 :class vf) + ) + (let ((s5-0 (+ (-> arg0 active-channels) (-> arg0 float-channels)))) + (let ((f0-0 1.0) + (v1-2 0) + (a2-0 (the-as object #x70000960)) + (a0-2 (-> arg0 active-frame-interp)) + ) + (dotimes (a1-0 (the-as int s5-0)) + (let ((a3-2 (-> arg0 channel a1-0))) + (case (-> a3-2 command) + (((joint-control-command push)) + (let ((a3-3 (the-as object (+ (the-as int a2-0) v1-2)))) + (set! (-> (the-as (inline-array vector) a2-0) 0 quad) (the-as uint128 0)) + (set! (-> (the-as (inline-array vector) a2-0) 1 quad) (the-as uint128 0)) + (set! (-> (the-as (inline-array vector) a2-0) 2 quad) (the-as uint128 0)) + (set! (-> (the-as (inline-array vector) a2-0) 3 quad) (the-as uint128 0)) + (set! (-> (the-as (inline-array vector) a2-0) 4 quad) (the-as uint128 0)) + (set! (-> (the-as (inline-array vector) a2-0) 5 quad) (the-as uint128 0)) + (set! (-> (the-as (pointer float) a3-3) 0) f0-0) + ) + (set! a2-0 (+ (the-as int a2-0) 96)) + ) + (((joint-control-command blend) (joint-control-command push1) (joint-control-command float)) + (let ((f1-0 (-> a3-2 frame-interp a0-2))) + (let ((a3-5 (- f0-0 f1-0))) + (.mov vf1 a3-5) + ) + (let ((a2-1 (the-as object (+ (the-as int a2-0) -96)))) + (.lvf vf2 (the-as int a2-1)) + (let ((a3-6 (the-as object (+ (the-as int a2-1) v1-2)))) + (.lvf vf3 (+ (the-as int a2-1) 16)) + (.lvf vf4 (+ (the-as int a2-1) 32)) + (.lvf vf5 (+ (the-as int a2-1) 48)) + (.lvf vf6 (+ (the-as int a2-1) 64)) + (.lvf vf7 (+ (the-as int a2-1) 80)) + (.mul.x.vf vf2 vf2 vf1) + (.mul.x.vf vf3 vf3 vf1) + (.mul.x.vf vf4 vf4 vf1) + (.mul.x.vf vf5 vf5 vf1) + (.mul.x.vf vf6 vf6 vf1) + (.mul.x.vf vf7 vf7 vf1) + (.svf (&-> (the-as (inline-array vector) a2-1) 0 quad) vf2) + (.svf (&-> (the-as (inline-array vector) a2-1) 1 quad) vf3) + (.svf (&-> (the-as (inline-array vector) a2-1) 2 quad) vf4) + (.svf (&-> (the-as (inline-array vector) a2-1) 3 quad) vf5) + (.svf (&-> (the-as (inline-array vector) a2-1) 4 quad) vf6) + (.svf (&-> (the-as (inline-array vector) a2-1) 5 quad) vf7) + (+! (-> (the-as (pointer float) a3-6) 0) f1-0) + ) + (set! a2-0 (+ (the-as int a2-1) 96)) + ) + ) + ) + (((joint-control-command stack)) + (let* ((f2-2 (-> a3-2 frame-interp a0-2)) + (f1-2 (- f0-0 f2-2)) + (a2-2 (the-as object (+ (the-as int a2-0) -192))) + ) + (let ((a3-8 f2-2)) + (.mov vf1 a3-8) + ) + (let ((a3-9 f1-2)) + (.mov vf2 a3-9) + ) + (.lvf vf3 (the-as int a2-2)) + (.lvf vf4 (+ (the-as int a2-2) 16)) + (.lvf vf5 (+ (the-as int a2-2) 32)) + (.lvf vf6 (+ (the-as int a2-2) 48)) + (.lvf vf7 (+ (the-as int a2-2) 64)) + (.lvf vf8 (+ (the-as int a2-2) 80)) + (.mul.x.vf vf3 vf3 vf2) + (.mul.x.vf vf4 vf4 vf2) + (.mul.x.vf vf5 vf5 vf2) + (.mul.x.vf vf6 vf6 vf2) + (.mul.x.vf vf7 vf7 vf2) + (.mul.x.vf vf8 vf8 vf2) + (.lvf vf9 (+ (the-as int a2-2) 96)) + (.lvf vf10 (+ (the-as int a2-2) 112)) + (.lvf vf11 (+ (the-as int a2-2) 128)) + (.lvf vf12 (+ (the-as int a2-2) 144)) + (.lvf vf13 (+ (the-as int a2-2) 160)) + (.lvf vf14 (+ (the-as int a2-2) 176)) + (.mul.x.vf vf9 vf9 vf1) + (.mul.x.vf vf10 vf10 vf1) + (.mul.x.vf vf11 vf11 vf1) + (.mul.x.vf vf12 vf12 vf1) + (.mul.x.vf vf13 vf13 vf1) + (.mul.x.vf vf14 vf14 vf1) + (.add.vf vf3 vf3 vf9) + (.add.vf vf4 vf4 vf10) + (.add.vf vf5 vf5 vf11) + (.add.vf vf6 vf6 vf12) + (.add.vf vf7 vf7 vf13) + (.add.vf vf8 vf8 vf14) + (.svf (&-> (the-as (inline-array vector) a2-2) 0 quad) vf3) + (.svf (&-> (the-as (inline-array vector) a2-2) 1 quad) vf4) + (.svf (&-> (the-as (inline-array vector) a2-2) 2 quad) vf5) + (.svf (&-> (the-as (inline-array vector) a2-2) 3 quad) vf6) + (.svf (&-> (the-as (inline-array vector) a2-2) 4 quad) vf7) + (.svf (&-> (the-as (inline-array vector) a2-2) 5 quad) vf8) + (set! a2-0 (+ (the-as int a2-2) 96)) + ) + ) + ) + ) + (+! v1-2 4) + ) + ) + (let ((s4-0 0)) + (dotimes (s3-0 (the-as int s5-0)) + (when (< 0.001 (-> (the-as terrain-context #x70000000) work foreground joint-work flatten-array s3-0)) + (let* ((v1-11 (-> arg0 channel s3-0)) + (s2-0 (-> v1-11 frame-group frames)) + (f0-2 (-> v1-11 frame-num)) + (s1-0 (the int f0-2)) + (f30-0 (- f0-2 (the float s1-0))) + ) + (let ((s0-0 (+ (-> s2-0 num-frames) -1))) + (if (not (-> v1-11 frame-group)) + (format 0 "Channel ~D skel ~A frame-group is #f!!!~%" s3-0 arg0) + ) + (when (>= s1-0 (the-as int s0-0)) + (set! f30-0 0.0) + (set! s1-0 (the-as int s0-0)) + ) + ) + (let ((v1-20 (-> (the-as terrain-context #x70000000) work foreground joint-work uploads s4-0))) + (set! (-> v1-20 fixed) (-> s2-0 fixed)) + (set! (-> v1-20 fixed-qwc) (the-as int (-> s2-0 fixed-qwc))) + (set! (-> v1-20 frame) (-> s2-0 data s1-0)) + (set! (-> v1-20 frame-qwc) (the-as int (if (= f30-0 0.0) + (-> s2-0 frame-qwc) + (* (-> s2-0 frame-qwc) 2) + ) + ) + ) + (set! (-> v1-20 amount) + (-> (the-as terrain-context #x70000000) work foreground joint-work flatten-array s3-0) + ) + (set! (-> v1-20 interp) f30-0) + ) + ) + (+! s4-0 1) + ) + ) + (set! (-> (the-as terrain-context #x70000000) work foreground joint-work num-uploads) s4-0) + ) + (dotimes (v1-26 (the-as int s5-0)) + (set! (-> arg0 channel v1-26 inspector-amount) + (the-as + uint + (the int (* 255.0 (-> (the-as terrain-context #x70000000) work foreground joint-work flatten-array v1-26))) + ) + ) + ) + ) + 0 + ) + ) + +;; definition for function matrix-from-joint-anim-frame +;; INFO: Return type mismatch object vs matrix. +(defun matrix-from-joint-anim-frame ((arg0 joint-anim-compressed-control) (arg1 int) (arg2 int)) + (let ((v1-1 (the-as object (-> arg0 fixed data))) + (v0-0 (the-as object (-> arg0 data arg2 data))) + ) + (cond + ((zero? (logand (-> arg0 fixed hdr matrix-bits) 1)) + (set! v1-1 (cond + ((zero? arg1) + (return (the-as matrix v1-1)) + v1-1 + ) + (else + (-> (the-as (inline-array vector) v1-1) 4) + ) + ) + ) + ) + ((zero? arg1) + (return (the-as matrix v0-0)) + ) + (else + (set! v0-0 (-> (the-as (inline-array vector) v0-0) 4)) + ) + ) + (if (zero? (logand (-> arg0 fixed hdr matrix-bits) 2)) + (return (the-as matrix v1-1)) + ) + (the-as matrix v0-0) + ) + ) + +;; definition for function matrix-from-control-channel! +;; INFO: Used lq/sq +(defun matrix-from-control-channel! ((arg0 matrix) (arg1 joint) (arg2 joint-control-channel)) + (let ((s4-0 (-> arg2 frame-group)) + (s5-0 (-> arg1 number)) + ) + (if (>= s5-0 2) + (format 0 "ERROR: Call to matrix-from-control-channel! on joint ~D~%" s5-0) + ) + (let* ((f30-0 (fmax 0.0 (fmin (-> arg2 frame-num) (the float (+ (-> s4-0 frames num-frames) -1))))) + (f0-1 f30-0) + ) + (cond + ((= (the float (the int f0-1)) f0-1) + (let* ((a2-3 (matrix-from-joint-anim-frame (-> s4-0 frames) s5-0 (the int f30-0))) + (v1-7 (-> a2-3 vector 0 quad)) + (a0-3 (-> a2-3 vector 1 quad)) + (a1-3 (-> a2-3 vector 2 quad)) + (a2-4 (-> a2-3 trans quad)) + ) + (set! (-> arg0 vector 0 quad) v1-7) + (set! (-> arg0 vector 1 quad) a0-3) + (set! (-> arg0 vector 2 quad) a1-3) + (set! (-> arg0 trans quad) a2-4) + ) + arg0 + ) + (else + (let ((s3-1 (matrix-from-joint-anim-frame (-> s4-0 frames) s5-0 (the int f30-0))) + (a2-7 (matrix-from-joint-anim-frame (-> s4-0 frames) s5-0 (+ (the int f30-0) 1))) + (f0-9 (- f30-0 (the float (the int f30-0)))) + ) + (matrix-lerp! arg0 s3-1 a2-7 f0-9) + ) + ) + ) + ) + ) + ) + +;; definition for function matrix-from-control-pair! +(defun matrix-from-control-pair! ((arg0 matrix) (arg1 matrix) (arg2 joint) (arg3 int)) + (let ((f30-0 (-> arg1 vector 2 data arg3))) + (cond + ((>= 0.0 f30-0) + (empty) + arg0 + ) + ((>= f30-0 1.0) + (matrix-from-control-channel! arg0 arg2 (the-as joint-control-channel arg1)) + ) + (else + (let ((a2-3 + (matrix-from-control-channel! (the-as matrix (+ #x70000000 0)) arg2 (the-as joint-control-channel arg1)) + ) + ) + (matrix-lerp! arg0 arg0 a2-3 f30-0) + ) + ) + ) + ) + ) + +;; definition for function matrix-from-control! +;; INFO: Used lq/sq +;; INFO: Return type mismatch (inline-array matrix) vs matrix. +(defun matrix-from-control! ((arg0 matrix-stack) (arg1 joint) (arg2 joint-control) (arg3 symbol)) + (set! (-> arg0 top) (the-as matrix (-> arg0 data))) + (dotimes (s2-0 (the-as int (+ (-> arg2 active-channels) (-> arg2 float-channels)))) + (let* ((a2-1 (-> arg2 channel s2-0)) + (v1-3 (-> a2-1 command)) + (s1-0 64) + ) + (cond + ((and (= arg3 'no-push) (= v1-3 (joint-control-command push1))) + (matrix-from-control-channel! + (the-as matrix (&- (the-as pointer (-> arg0 top)) (the-as uint s1-0))) + arg1 + a2-1 + ) + ) + ((and (= arg3 'no-push) (= v1-3 (joint-control-command stack))) + (set! (-> arg0 top) (the-as matrix (&- (the-as pointer (-> arg0 top)) (the-as uint s1-0)))) + (let* ((v1-9 (the-as object (&- (the-as pointer (-> arg0 top)) (the-as uint s1-0)))) + (a3-1 (-> arg0 top)) + (a0-8 (-> a3-1 vector 0 quad)) + (a1-6 (-> a3-1 vector 1 quad)) + (a2-2 (-> a3-1 vector 2 quad)) + (a3-2 (-> a3-1 trans quad)) + ) + (set! (-> (the-as matrix v1-9) vector 0 quad) a0-8) + (set! (-> (the-as matrix v1-9) vector 1 quad) a1-6) + (set! (-> (the-as matrix v1-9) vector 2 quad) a2-2) + (set! (-> (the-as matrix v1-9) trans quad) a3-2) + ) + ) + ((and (= arg3 'no-push) (= v1-3 (joint-control-command float))) + ) + ((= v1-3 (joint-control-command push)) + (matrix-from-control-channel! (-> arg0 top) arg1 a2-1) + (set! (-> arg0 top) (the-as matrix (&+ (the-as pointer (-> arg0 top)) s1-0))) + ) + ((logtest? v1-3 (joint-control-command blend)) + (matrix-from-control-pair! + (the-as matrix (&- (the-as pointer (-> arg0 top)) (the-as uint s1-0))) + (the-as matrix a2-1) + arg1 + (the-as int (-> arg2 active-frame-interp)) + ) + ) + ((= v1-3 (joint-control-command stack)) + (set! (-> arg0 top) (the-as matrix (&- (the-as pointer (-> arg0 top)) (the-as uint s1-0)))) + (let ((a1-11 (&- (the-as pointer (-> arg0 top)) (the-as uint s1-0))) + (v1-19 (-> arg0 top)) + (f0-0 (-> a2-1 frame-interp (-> arg2 active-frame-interp))) + ) + (matrix-lerp! (the-as matrix a1-11) (the-as matrix a1-11) v1-19 f0-0) + ) + ) + ) + ) + ) + (the-as matrix (-> arg0 data)) + ) + +;; definition for method 9 of type cspace +(defmethod reset-and-assign-geo! cspace ((obj cspace) (arg0 basic)) + (set! (-> obj parent) #f) + (set! (-> obj joint) #f) + (set! (-> obj geo) arg0) + (set! (-> obj param0) #f) + (set! (-> obj param1) #f) + (set! (-> obj param2) #f) + obj + ) + +;; definition for method 0 of type cspace +(defmethod new cspace ((allocation symbol) (type-to-make type) (arg0 basic)) + (let ((t9-0 (method-of-type structure new)) + (v1-1 type-to-make) + ) + (-> type-to-make size) + ((method-of-type cspace reset-and-assign-geo!) (the-as cspace (t9-0 allocation v1-1)) arg0) + ) + ) + +;; definition for function cspace<-cspace! +;; INFO: Used lq/sq +(defun cspace<-cspace! ((arg0 cspace) (arg1 cspace)) + (let ((v0-0 (-> arg0 bone transform))) + (let* ((a2-0 (-> arg1 bone transform)) + (v1-2 (-> a2-0 vector 0 quad)) + (a0-1 (-> a2-0 vector 1 quad)) + (a1-1 (-> a2-0 vector 2 quad)) + (a2-1 (-> a2-0 trans quad)) + ) + (set! (-> v0-0 vector 0 quad) v1-2) + (set! (-> v0-0 vector 1 quad) a0-1) + (set! (-> v0-0 vector 2 quad) a1-1) + (set! (-> v0-0 trans quad) a2-1) + ) + v0-0 + ) + ) + +;; definition for function cspace<-cspace-normalized! +;; INFO: Used lq/sq +(defun cspace<-cspace-normalized! ((arg0 cspace) (arg1 cspace)) + (let ((gp-0 (-> arg0 bone transform))) + (let* ((a2-0 (-> arg1 bone transform)) + (v1-2 (-> a2-0 vector 0 quad)) + (a0-1 (-> a2-0 vector 1 quad)) + (a1-1 (-> a2-0 vector 2 quad)) + (a2-1 (-> a2-0 trans quad)) + ) + (set! (-> gp-0 vector 0 quad) v1-2) + (set! (-> gp-0 vector 1 quad) a0-1) + (set! (-> gp-0 vector 2 quad) a1-1) + (set! (-> gp-0 trans quad) a2-1) + ) + (vector-normalize! (the-as vector (-> gp-0 data)) 1.0) + (vector-normalize! (the-as vector (&-> gp-0 data 4)) 1.0) + (vector-normalize! (the-as vector (&-> gp-0 data 8)) 1.0) + gp-0 + ) + ) + +;; definition for function cspace<-parent-joint! +;; INFO: Used lq/sq +(defun cspace<-parent-joint! ((arg0 cspace) (arg1 (pointer process-drawable)) (arg2 int)) + (let ((v0-0 (-> arg0 bone transform))) + (let* ((a2-1 (-> arg1 0 node-list data arg2 bone transform)) + (v1-5 (-> a2-1 vector 0 quad)) + (a0-2 (-> a2-1 vector 1 quad)) + (a1-1 (-> a2-1 vector 2 quad)) + (a2-2 (-> a2-1 trans quad)) + ) + (set! (-> v0-0 vector 0 quad) v1-5) + (set! (-> v0-0 vector 1 quad) a0-2) + (set! (-> v0-0 vector 2 quad) a1-1) + (set! (-> v0-0 trans quad) a2-2) + ) + v0-0 + ) + ) + +;; definition for function cspace<-rot-yxy! +(defun cspace<-rot-yxy! ((arg0 cspace) (arg1 transform)) + (let ((s5-0 (-> arg0 bone transform))) + (matrix-rotate-yxy! s5-0 (-> arg1 rot)) + (scale-matrix! s5-0 (-> arg1 scale) s5-0) + ) + ) + +;; definition for function cspace<-transform-yxy! +(defun cspace<-transform-yxy! ((arg0 cspace) (arg1 transform)) + (let ((s4-0 (-> arg0 bone transform)) + (s5-0 (new 'stack-no-clear 'matrix)) + (s3-0 (new 'stack-no-clear 'matrix)) + ) + (matrix-identity! s4-0) + (matrix-translate! s4-0 (-> arg1 trans)) + (matrix-rotate-yxy! s5-0 (-> arg1 rot)) + (matrix*! s3-0 s5-0 s4-0) + (scale-matrix! s4-0 (-> arg1 scale) s3-0) + ) + ) + +;; definition for function cspace<-transformq! +(defun cspace<-transformq! ((arg0 cspace) (arg1 transformq)) + (matrix<-transformq! (-> arg0 bone transform) arg1) + ) + +;; definition for function cspace<-transformq+trans! +(defun cspace<-transformq+trans! ((arg0 cspace) (arg1 transformq) (arg2 vector)) + (matrix<-transformq+trans! (-> arg0 bone transform) arg1 arg2) + ) + +;; definition for function cspace<-transformq+world-trans! +(defun cspace<-transformq+world-trans! ((arg0 cspace) (arg1 transformq) (arg2 vector)) + (matrix<-transformq+world-trans! (-> arg0 bone transform) arg1 arg2) + ) + +;; definition for function cspace<-transformq+rot-offset! +(defun cspace<-transformq+rot-offset! ((arg0 cspace) (arg1 transformq) (arg2 vector)) + (matrix<-transformq+rot-offset! (-> arg0 bone transform) arg1 arg2) + ) + +;; definition for function cspace-calc-total-matrix! +(defun cspace-calc-total-matrix! ((arg0 cspace) (arg1 matrix)) + (matrix*! arg1 (-> arg0 bone transform) (-> *math-camera* camera-temp)) + ) + +;; definition for function cspace<-matrix-no-push-joint! +;; INFO: Used lq/sq +(defun cspace<-matrix-no-push-joint! ((arg0 cspace) (arg1 joint-control)) + (let ((v1-2 (matrix-from-control! (the-as matrix-stack (+ 64 #x70000000)) (-> arg0 joint) arg1 'no-push)) + (v0-1 (-> arg0 bone transform)) + ) + (let ((a0-4 (-> v1-2 vector 0 quad)) + (a1-2 (-> v1-2 vector 1 quad)) + (a2-1 (-> v1-2 vector 2 quad)) + (v1-3 (-> v1-2 trans quad)) + ) + (set! (-> v0-1 vector 0 quad) a0-4) + (set! (-> v0-1 vector 1 quad) a1-2) + (set! (-> v0-1 vector 2 quad) a2-1) + (set! (-> v0-1 trans quad) v1-3) + ) + v0-1 + ) + ) + +;; definition for function cspace<-matrix-joint! +;; INFO: Used lq/sq +(defun cspace<-matrix-joint! ((arg0 cspace) (arg1 matrix)) + (let ((v0-0 (-> arg0 bone transform))) + (let* ((a2-0 arg1) + (v1-1 (-> a2-0 vector 0 quad)) + (a0-1 (-> a2-0 vector 1 quad)) + (a1-1 (-> a2-0 vector 2 quad)) + (a2-1 (-> a2-0 trans quad)) + ) + (set! (-> v0-0 vector 0 quad) v1-1) + (set! (-> v0-0 vector 1 quad) a0-1) + (set! (-> v0-0 vector 2 quad) a1-1) + (set! (-> v0-0 trans quad) a2-1) + ) + v0-0 + ) + ) + +;; definition for function cspace<-parented-matrix-joint! +(defun cspace<-parented-matrix-joint! ((arg0 cspace) (arg1 matrix)) + (rlet ((acc :class vf) + (vf10 :class vf) + (vf11 :class vf) + (vf12 :class vf) + (vf13 :class vf) + (vf14 :class vf) + (vf15 :class vf) + (vf16 :class vf) + (vf17 :class vf) + (vf18 :class vf) + (vf19 :class vf) + (vf20 :class vf) + (vf21 :class vf) + ) + (let ((v0-0 (-> arg0 bone transform))) + (let ((v1-1 arg1)) + (let ((a0-3 (-> arg0 parent bone transform))) + (.lvf vf10 (&-> v1-1 vector 0 quad)) + (.lvf vf14 (&-> a0-3 vector 0 quad)) + (.lvf vf15 (&-> a0-3 vector 1 quad)) + (.lvf vf16 (&-> a0-3 vector 2 quad)) + (.lvf vf17 (&-> a0-3 trans quad)) + ) + (.lvf vf11 (&-> v1-1 vector 1 quad)) + (.lvf vf12 (&-> v1-1 vector 2 quad)) + (.lvf vf13 (&-> v1-1 trans quad)) + ) + (.mul.x.vf acc vf14 vf10) + (.add.mul.y.vf acc vf15 vf10 acc) + (.add.mul.z.vf acc vf16 vf10 acc) + (.add.mul.w.vf vf18 vf17 vf10 acc) + (.mul.x.vf acc vf14 vf11) + (.add.mul.y.vf acc vf15 vf11 acc) + (.add.mul.z.vf acc vf16 vf11 acc) + (.add.mul.w.vf vf19 vf17 vf11 acc) + (.mul.x.vf acc vf14 vf12) + (.add.mul.y.vf acc vf15 vf12 acc) + (.add.mul.z.vf acc vf16 vf12 acc) + (.add.mul.w.vf vf20 vf17 vf12 acc) + (.mul.x.vf acc vf14 vf13) + (.add.mul.y.vf acc vf15 vf13 acc) + (.add.mul.z.vf acc vf16 vf13 acc) + (.add.mul.w.vf vf21 vf17 vf13 acc) + (.svf (&-> v0-0 vector 0 quad) vf18) + (.svf (&-> v0-0 vector 1 quad) vf19) + (.svf (&-> v0-0 vector 2 quad) vf20) + (.svf (&-> v0-0 trans quad) vf21) + v0-0 + ) + ) + ) + +;; definition for function cspace<-parented-matrix-mirror! +(defun cspace<-parented-matrix-mirror! ((arg0 cspace) (arg1 matrix)) + (let ((gp-0 (matrix-mirror! + (new 'stack-no-clear 'matrix) + (the-as vector (-> arg0 param1)) + (the-as vector (-> arg0 param2)) + ) + ) + ) + (cspace<-parented-matrix-joint! arg0 arg1) + (matrix*! (-> arg0 bone transform) (-> arg0 bone transform) gp-0) + ) + ) + +;; definition for function cspace<-parented-matrix-joint-flip-z! +(defun cspace<-parented-matrix-joint-flip-z! ((arg0 cspace) (arg1 matrix)) + (rlet ((acc :class vf) + (vf0 :class vf) + (vf10 :class vf) + (vf11 :class vf) + (vf12 :class vf) + (vf13 :class vf) + (vf14 :class vf) + (vf15 :class vf) + (vf16 :class vf) + (vf17 :class vf) + (vf18 :class vf) + (vf19 :class vf) + (vf20 :class vf) + (vf21 :class vf) + (vf31 :class vf) + ) + (init-vf0-vector) + (let ((v0-0 (-> arg0 bone transform))) + (let ((v1-1 arg1)) + (let ((a0-3 (-> arg0 parent bone transform))) + (.lvf vf10 (&-> v1-1 vector 0 quad)) + (.lvf vf14 (&-> a0-3 vector 0 quad)) + (.lvf vf15 (&-> a0-3 vector 1 quad)) + (.lvf vf16 (&-> a0-3 vector 2 quad)) + (.lvf vf17 (&-> a0-3 trans quad)) + ) + (.lvf vf11 (&-> v1-1 vector 1 quad)) + (.lvf vf12 (&-> v1-1 vector 2 quad)) + (.lvf vf13 (&-> v1-1 trans quad)) + ) + (.sub.vf vf31 vf0 vf0) + (.mul.x.vf acc vf14 vf10) + (.add.mul.y.vf acc vf15 vf10 acc) + (.add.mul.z.vf acc vf16 vf10 acc) + (.add.mul.w.vf vf18 vf17 vf10 acc) + (.mul.x.vf acc vf14 vf12) + (.add.mul.y.vf acc vf15 vf12 acc) + (.add.mul.z.vf acc vf16 vf12 acc) + (.add.mul.w.vf vf20 vf17 vf12 acc) + (.mul.x.vf acc vf14 vf11) + (.add.mul.y.vf acc vf15 vf11 acc) + (.add.mul.z.vf acc vf16 vf11 acc) + (.add.mul.w.vf vf19 vf17 vf11 acc) + (.sub.vf vf18 vf31 vf18) + (.mul.x.vf acc vf14 vf13) + (.add.mul.y.vf acc vf15 vf13 acc) + (.add.mul.z.vf acc vf16 vf13 acc) + (.add.mul.w.vf vf21 vf17 vf13 acc) + (.svf (&-> v0-0 vector 0 quad) vf18) + (.svf (&-> v0-0 vector 1 quad) vf19) + (.svf (&-> v0-0 vector 2 quad) vf20) + (.svf (&-> v0-0 trans quad) vf21) + v0-0 + ) + ) + ) + +;; definition for function cspace<-matrix-joint-flip-z! +;; INFO: Return type mismatch int vs none. +(defun cspace<-matrix-joint-flip-z! ((arg0 cspace) (arg1 matrix)) + (local-vars (v1-2 float)) + (rlet ((vf0 :class vf) + (vf30 :class vf) + (vf31 :class vf) + ) + (init-vf0-vector) + (let ((v1-1 (-> arg0 bone transform))) + (.sub.vf vf31 vf0 vf0) + (.lvf vf30 (&-> v1-1 vector 0 quad)) + (.sub.vf vf30 vf31 vf30) + (.svf (&-> v1-1 vector 0 quad) vf30) + ) + (.mov v1-2 vf30) + 0 + (none) + ) + ) + +;; definition for function cspace<-parented-transformq-joint! +;; ERROR: Function may read a register that is not set: ra +;; ERROR: Unsupported inline assembly instruction kind - [jr ra] +;; ERROR: Unsupported inline assembly instruction kind - [jr ra] +(defun cspace<-parented-transformq-joint! ((arg0 cspace) (arg1 transformq)) + (local-vars (t1-1 uint128) (ra-0 none) (f4-2 float)) + (rlet ((acc :class vf) + (vf0 :class vf) + (vf1 :class vf) + (vf10 :class vf) + (vf11 :class vf) + (vf12 :class vf) + (vf13 :class vf) + (vf14 :class vf) + (vf15 :class vf) + (vf16 :class vf) + (vf2 :class vf) + (vf3 :class vf) + (vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + (vf7 :class vf) + (vf8 :class vf) + (vf9 :class vf) + ) + (init-vf0-vector) + (nop!) + (let ((a3-0 (-> arg0 parent)) + (v1-0 1.0) + ) + (.lvf vf5 (&-> arg1 quat vec quad)) + (let ((f0-0 v1-0) + (t0-0 (-> a3-0 bone)) + ) + (nop!) + (let ((a2-0 (-> arg0 bone))) + (.add.vf vf6 vf5 vf5) + (let ((f1-0 (-> t0-0 scale x))) + (.add.w.vf vf2 vf0 vf5 :mask #b1) + (.lvf vf15 (&-> arg1 trans quad)) + (.add.z.vf vf2 vf0 vf5 :mask #b10) + (.lvf vf1 (&-> arg1 scale quad)) + (let ((f4-0 (/ f0-0 f1-0))) + (.lvf vf7 (&-> t0-0 transform vector 0 quad)) + (.sub.y.vf vf2 vf0 vf5 :mask #b100) + (.lvf vf8 (&-> t0-0 transform vector 1 quad)) + (.sub.w.vf vf2 vf0 vf0 :mask #b1000) + (.lvf vf9 (&-> t0-0 transform vector 2 quad)) + (.sub.z.vf vf3 vf0 vf5 :mask #b1) + (.lvf vf10 (&-> t0-0 transform trans quad)) + (.add.w.vf vf3 vf0 vf5 :mask #b10) + (let ((f2-0 (-> t0-0 scale y))) + (.add.x.vf vf3 vf0 vf5 :mask #b100) + (.svf (&-> a2-0 scale quad) vf1) + (.sub.w.vf vf3 vf0 vf0 :mask #b1000) + (let ((f3-0 (-> t0-0 scale z))) + (.add.y.vf vf4 vf0 vf5 :mask #b1) + (let ((v1-1 (-> t0-0 scale w))) + (.sub.x.vf vf4 vf0 vf5 :mask #b10) + (let ((t1-0 (the-as uint128 f4-0))) + (.add.w.vf vf4 vf0 vf5 :mask #b100) + (let ((f4-1 (/ f0-0 f2-0))) + (.sub.w.vf vf4 vf0 vf0 :mask #b1000) + (.outer.product.a.vf acc vf6 vf2) + (.outer.product.b.vf vf2 vf2 vf6 acc) + (.outer.product.a.vf acc vf6 vf3) + (.outer.product.b.vf vf3 vf3 vf6 acc) + (.outer.product.a.vf acc vf6 vf4) + (.outer.product.b.vf vf4 vf4 vf6 acc) + (.add.w.vf vf2 vf2 vf0 :mask #b1) + (.add.w.vf vf3 vf3 vf0 :mask #b10) + (.add.w.vf vf4 vf4 vf0 :mask #b100) + (let ((t2-0 (the-as uint128 f4-1))) + (b! (nonzero? v1-1) cfg-2 :delay (set! f4-2 (/.s f0-0 f3-0))) + (.mul.x.vf vf2 vf2 vf1) + (.mul.y.vf vf3 vf3 vf1) + (.mul.z.vf vf4 vf4 vf1) + (.mul.x.vf acc vf7 vf2) + (.add.mul.y.vf acc vf8 vf2 acc) + (.add.mul.z.vf acc vf9 vf2 acc) + (.add.mul.w.vf vf11 vf10 vf2 acc) + (.mul.x.vf acc vf7 vf3) + (.add.mul.y.vf acc vf8 vf3 acc) + (.add.mul.z.vf acc vf9 vf3 acc) + (.add.mul.w.vf vf12 vf10 vf3 acc) + (.mul.x.vf acc vf7 vf4) + (.add.mul.y.vf acc vf8 vf4 acc) + (.add.mul.z.vf acc vf9 vf4 acc) + (.add.mul.w.vf vf13 vf10 vf4 acc) + (.mul.x.vf acc vf7 vf15) + (.add.mul.y.vf acc vf8 vf15 acc) + (.add.mul.z.vf acc vf9 vf15 acc) + (.add.mul.w.vf vf14 vf10 vf0 acc) + (.svf (&-> a2-0 transform vector 0 quad) vf11) + (.svf (&-> a2-0 transform vector 1 quad) vf12) + (.svf (&-> a2-0 transform vector 2 quad) vf13) + (.svf (&-> a2-0 transform trans quad) vf14) + (.jr ra-0) + (nop!) + (label cfg-2) + (.pextlw t1-1 t2-0 t1-0) + ) + ) + ) + ) + ) + ) + ) + ) + (.mul.x.vf vf2 vf2 vf1) + (.mul.y.vf vf3 vf3 vf1) + (.mul.z.vf vf4 vf4 vf1) + (let ((t1-2 (make-u128 f4-2 (the-as int t1-1)))) + (.mov vf16 t1-2) + ) + (.mul.vf vf2 vf2 vf16) + (.mul.vf vf3 vf3 vf16) + (.mul.vf vf4 vf4 vf16) + (.mul.x.vf acc vf7 vf2) + (.add.mul.y.vf acc vf8 vf2 acc) + (.add.mul.z.vf acc vf9 vf2 acc) + (.add.mul.w.vf vf11 vf10 vf2 acc) + (.mul.x.vf acc vf7 vf3) + (.add.mul.y.vf acc vf8 vf3 acc) + (.add.mul.z.vf acc vf9 vf3 acc) + (.add.mul.w.vf vf12 vf10 vf3 acc) + (.mul.x.vf acc vf7 vf4) + (.add.mul.y.vf acc vf8 vf4 acc) + (.add.mul.z.vf acc vf9 vf4 acc) + (.add.mul.w.vf vf13 vf10 vf4 acc) + (.mul.x.vf acc vf7 vf15) + (.add.mul.y.vf acc vf8 vf15 acc) + (.add.mul.z.vf acc vf9 vf15 acc) + (.add.mul.w.vf vf14 vf10 vf0 acc) + (.svf (&-> a2-0 transform vector 0 quad) vf11) + (.svf (&-> a2-0 transform vector 1 quad) vf12) + (.svf (&-> a2-0 transform vector 2 quad) vf13) + (.svf (&-> a2-0 transform trans quad) vf14) + ) + ) + ) + (.jr ra-0) + (nop!) + (none) + ) + ) + +;; definition for function cspace<-parented-transformq-joint-flip-z! +;; INFO: Return type mismatch int vs none. +(defun cspace<-parented-transformq-joint-flip-z! ((arg0 cspace) (arg1 transformq)) + (cspace<-parented-transformq-joint! arg0 arg1) + (cspace<-matrix-joint-flip-z! arg0 (-> arg0 bone transform)) + 0 + (none) + ) + +;; definition for function clear-frame-accumulator +;; ERROR: function has no type analysis. Cannot decompile. + +;; definition for function normalize-frame-quaternions +;; ERROR: function has no type analysis. Cannot decompile. + +;; definition for function decompress-fixed-data-to-accumulator +;; ERROR: function was not converted to expressions. Cannot decompile. + +;; definition for function decompress-frame-data-to-accumulator +;; ERROR: function was not converted to expressions. Cannot decompile. + +;; definition for function decompress-frame-data-pair-to-accumulator +;; ERROR: function was not converted to expressions. Cannot decompile. + +;; definition for function make-joint-jump-tables +(defun make-joint-jump-tables () + (let ((v1-1 (+ (the-as uint decompress-fixed-data-to-accumulator) (* 108 4))) + (a0-2 #x70000000) + ) + (s.w! (+ a0-2 1616) v1-1) + ) + (let ((v1-3 (+ (the-as uint decompress-fixed-data-to-accumulator) (* 199 4))) + (a0-5 #x70000000) + ) + (s.w! (+ a0-5 1620) v1-3) + ) + (let ((v1-5 (+ (the-as uint decompress-fixed-data-to-accumulator) (* 233 4))) + (a0-8 #x70000000) + ) + (s.w! (+ a0-8 1624) v1-5) + ) + (let ((v1-7 (+ (the-as uint decompress-fixed-data-to-accumulator) (* 286 4))) + (a0-11 #x70000000) + ) + (s.w! (+ a0-11 1628) v1-7) + ) + (let ((v1-9 (+ (the-as uint decompress-fixed-data-to-accumulator) (* 301 4))) + (a0-14 #x70000000) + ) + (s.w! (+ a0-14 1632) v1-9) + ) + (let ((v1-11 (+ (the-as uint decompress-fixed-data-to-accumulator) (* 366 4))) + (a0-17 #x70000000) + ) + (s.w! (+ a0-17 1636) v1-11) + ) + (let ((v1-13 (+ (the-as uint decompress-fixed-data-to-accumulator) (* 387 4))) + (a0-20 #x70000000) + ) + (s.w! (+ a0-20 1640) v1-13) + ) + (let ((v1-15 (+ (the-as uint decompress-fixed-data-to-accumulator) (* 100 4))) + (a0-23 #x70000000) + ) + (s.w! (+ a0-23 1644) v1-15) + ) + (let ((v1-17 (+ (the-as uint decompress-fixed-data-to-accumulator) (* 155 4))) + (a0-26 #x70000000) + ) + (s.w! (+ a0-26 1648) v1-17) + ) + (let ((v1-19 (+ (the-as uint decompress-fixed-data-to-accumulator) (* 199 4))) + (a0-29 #x70000000) + ) + (s.w! (+ a0-29 1652) v1-19) + ) + (let ((v1-21 (+ (the-as uint decompress-fixed-data-to-accumulator) (* 261 4))) + (a0-32 #x70000000) + ) + (s.w! (+ a0-32 1656) v1-21) + ) + (let ((v1-23 (+ (the-as uint decompress-fixed-data-to-accumulator) (* 286 4))) + (a0-35 #x70000000) + ) + (s.w! (+ a0-35 1660) v1-23) + ) + (let ((v1-25 (+ (the-as uint decompress-fixed-data-to-accumulator) (* 335 4))) + (a0-38 #x70000000) + ) + (s.w! (+ a0-38 1664) v1-25) + ) + (let ((v1-27 (+ (the-as uint decompress-fixed-data-to-accumulator) (* 366 4))) + (a0-41 #x70000000) + ) + (s.w! (+ a0-41 1668) v1-27) + ) + (let ((v1-29 (+ (the-as uint decompress-fixed-data-to-accumulator) (* 402 4))) + (a0-44 #x70000000) + ) + (s.w! (+ a0-44 1672) v1-29) + ) + (let ((v1-31 (+ (the-as uint decompress-fixed-data-to-accumulator) (* 100 4))) + (a0-47 #x70000000) + ) + (s.w! (+ a0-47 1676) v1-31) + ) + (let ((v1-33 (+ (the-as uint decompress-frame-data-to-accumulator) (* 84 4))) + (a0-50 #x70000000) + ) + (s.w! (+ a0-50 1680) v1-33) + ) + (let ((v1-35 (+ (the-as uint decompress-frame-data-to-accumulator) (* 92 4))) + (a0-53 #x70000000) + ) + (s.w! (+ a0-53 1684) v1-35) + ) + (let ((v1-37 (+ (the-as uint decompress-frame-data-to-accumulator) (* 119 4))) + (a0-56 #x70000000) + ) + (s.w! (+ a0-56 1688) v1-37) + ) + (let ((v1-39 (+ (the-as uint decompress-frame-data-to-accumulator) (* 140 4))) + (a0-59 #x70000000) + ) + (s.w! (+ a0-59 1692) v1-39) + ) + (let ((v1-41 (+ (the-as uint decompress-frame-data-to-accumulator) (* 205 4))) + (a0-62 #x70000000) + ) + (s.w! (+ a0-62 1696) v1-41) + ) + (let ((v1-43 (+ (the-as uint decompress-frame-data-to-accumulator) (* 220 4))) + (a0-65 #x70000000) + ) + (s.w! (+ a0-65 1700) v1-43) + ) + (let ((v1-45 (+ (the-as uint decompress-frame-data-to-accumulator) (* 273 4))) + (a0-68 #x70000000) + ) + (s.w! (+ a0-68 1704) v1-45) + ) + (let ((v1-47 (+ (the-as uint decompress-frame-data-to-accumulator) (* 307 4))) + (a0-71 #x70000000) + ) + (s.w! (+ a0-71 1708) v1-47) + ) + (let ((v1-49 (+ (the-as uint decompress-frame-data-to-accumulator) (* 84 4))) + (a0-74 #x70000000) + ) + (s.w! (+ a0-74 1712) v1-49) + ) + (let ((v1-51 (+ (the-as uint decompress-frame-data-to-accumulator) (* 107 4))) + (a0-77 #x70000000) + ) + (s.w! (+ a0-77 1716) v1-51) + ) + (let ((v1-53 (+ (the-as uint decompress-frame-data-to-accumulator) (* 119 4))) + (a0-80 #x70000000) + ) + (s.w! (+ a0-80 1720) v1-53) + ) + (let ((v1-55 (+ (the-as uint decompress-frame-data-to-accumulator) (* 174 4))) + (a0-83 #x70000000) + ) + (s.w! (+ a0-83 1724) v1-55) + ) + (let ((v1-57 (+ (the-as uint decompress-frame-data-to-accumulator) (* 205 4))) + (a0-86 #x70000000) + ) + (s.w! (+ a0-86 1728) v1-57) + ) + (let ((v1-59 (+ (the-as uint decompress-frame-data-to-accumulator) (* 248 4))) + (a0-89 #x70000000) + ) + (s.w! (+ a0-89 1732) v1-59) + ) + (let ((v1-61 (+ (the-as uint decompress-frame-data-to-accumulator) (* 273 4))) + (a0-92 #x70000000) + ) + (s.w! (+ a0-92 1736) v1-61) + ) + (let ((v1-63 (+ (the-as uint decompress-frame-data-to-accumulator) (* 354 4))) + (a0-95 #x70000000) + ) + (s.w! (+ a0-95 1740) v1-63) + ) + (let ((v1-65 (+ (the-as uint decompress-frame-data-pair-to-accumulator) (* 117 4))) + (a0-98 #x70000000) + ) + (s.w! (+ a0-98 1744) v1-65) + ) + (let ((v1-67 (+ (the-as uint decompress-frame-data-pair-to-accumulator) (* 125 4))) + (a0-101 #x70000000) + ) + (s.w! (+ a0-101 1748) v1-67) + ) + (let ((v1-69 (+ (the-as uint decompress-frame-data-pair-to-accumulator) (* 169 4))) + (a0-104 #x70000000) + ) + (s.w! (+ a0-104 1752) v1-69) + ) + (let ((v1-71 (+ (the-as uint decompress-frame-data-pair-to-accumulator) (* 197 4))) + (a0-107 #x70000000) + ) + (s.w! (+ a0-107 1756) v1-71) + ) + (let ((v1-73 (+ (the-as uint decompress-frame-data-pair-to-accumulator) (* 293 4))) + (a0-110 #x70000000) + ) + (s.w! (+ a0-110 1760) v1-73) + ) + (let ((v1-75 (+ (the-as uint decompress-frame-data-pair-to-accumulator) (* 318 4))) + (a0-113 #x70000000) + ) + (s.w! (+ a0-113 1764) v1-75) + ) + (let ((v1-77 (+ (the-as uint decompress-frame-data-pair-to-accumulator) (* 408 4))) + (a0-116 #x70000000) + ) + (s.w! (+ a0-116 1768) v1-77) + ) + (let ((v1-79 (+ (the-as uint decompress-frame-data-pair-to-accumulator) (* 459 4))) + (a0-119 #x70000000) + ) + (s.w! (+ a0-119 1772) v1-79) + ) + (let ((v1-81 (+ (the-as uint decompress-frame-data-pair-to-accumulator) (* 117 4))) + (a0-122 #x70000000) + ) + (s.w! (+ a0-122 1776) v1-81) + ) + (let ((v1-83 (+ (the-as uint decompress-frame-data-pair-to-accumulator) (* 150 4))) + (a0-125 #x70000000) + ) + (s.w! (+ a0-125 1780) v1-83) + ) + (let ((v1-85 (+ (the-as uint decompress-frame-data-pair-to-accumulator) (* 169 4))) + (a0-128 #x70000000) + ) + (s.w! (+ a0-128 1784) v1-85) + ) + (let ((v1-87 (+ (the-as uint decompress-frame-data-pair-to-accumulator) (* 248 4))) + (a0-131 #x70000000) + ) + (s.w! (+ a0-131 1788) v1-87) + ) + (let ((v1-89 (+ (the-as uint decompress-frame-data-pair-to-accumulator) (* 293 4))) + (a0-134 #x70000000) + ) + (s.w! (+ a0-134 1792) v1-89) + ) + (let ((v1-91 (+ (the-as uint decompress-frame-data-pair-to-accumulator) (* 366 4))) + (a0-137 #x70000000) + ) + (s.w! (+ a0-137 1796) v1-91) + ) + (let ((v1-93 (+ (the-as uint decompress-frame-data-pair-to-accumulator) (* 408 4))) + (a0-140 #x70000000) + ) + (s.w! (+ a0-140 1800) v1-93) + ) + (let ((v1-95 (+ (the-as uint decompress-frame-data-pair-to-accumulator) (* 533 4))) + (a0-143 #x70000000) + ) + (s.w! (+ a0-143 1804) v1-95) + ) + 0 + ) + +;; definition for function calc-animation-from-spr +;; ERROR: function was not converted to expressions. Cannot decompile. + +;; definition for function create-interpolated-joint-animation-frame +(defun create-interpolated-joint-animation-frame ((arg0 joint-anim-frame) (arg1 int) (arg2 joint-control)) + (flatten-joint-control-to-spr arg2) + (make-joint-jump-tables) + (calc-animation-from-spr arg0 arg1) + 0 + ) + +;; definition for function create-interpolated2-joint-animation-frame +;; INFO: Used lq/sq +(defun create-interpolated2-joint-animation-frame ((arg0 joint-anim-frame) (arg1 int) (arg2 joint-control)) + (if (and (zero? (-> arg2 interp-select 0)) (zero? (-> arg2 interp-select 1))) + (return (create-interpolated-joint-animation-frame arg0 arg1 arg2)) + ) + (set! (-> arg2 active-frame-interp) (the-as uint 1)) + (flatten-joint-control-to-spr arg2) + (make-joint-jump-tables) + (calc-animation-from-spr arg0 arg1) + (dma-send-from-spr-no-flush + (the-as uint *gsf-buffer*) + (the-as uint arg0) + (the-as uint (/ (+ (* 48 arg1) 128) 16)) + #f + ) + (set! (-> arg2 active-frame-interp) (the-as uint 0)) + (flatten-joint-control-to-spr arg2) + (make-joint-jump-tables) + (calc-animation-from-spr arg0 arg1) + (let ((v1-9 (the-as joint-anim-frame *gsf-buffer*))) + (let ((a0-8 (-> arg2 interp-select 0))) + (dotimes (a1-5 2) + (when (logtest? a0-8 1) + (let* ((a2-7 (-> arg0 matrices a1-5)) + (t2-0 (-> v1-9 matrices a1-5)) + (a3-3 (-> t2-0 vector 0 quad)) + (t0-0 (-> t2-0 vector 1 quad)) + (t1-0 (-> t2-0 vector 2 quad)) + (t2-1 (-> t2-0 trans quad)) + ) + (set! (-> a2-7 vector 0 quad) a3-3) + (set! (-> a2-7 vector 1 quad) t0-0) + (set! (-> a2-7 vector 2 quad) t1-0) + (set! (-> a2-7 trans quad) t2-1) + ) + ) + (set! a0-8 (shr a0-8 1)) + ) + (let ((a1-9 (min 62 (+ arg1 -2)))) + (dotimes (a2-9 a1-9) + (when (logtest? a0-8 1) + (let* ((a3-9 (-> arg0 data a2-9)) + (t2-2 (-> v1-9 data a2-9)) + (t0-4 (-> t2-2 trans quad)) + (t1-1 (-> t2-2 quat vec quad)) + (t2-3 (-> t2-2 scale quad)) + ) + (set! (-> a3-9 trans quad) t0-4) + (set! (-> a3-9 quat vec quad) t1-1) + (set! (-> a3-9 scale quad) t2-3) + ) + ) + (set! a0-8 (shr a0-8 1)) + ) + ) + ) + (let ((a0-12 (min 64 (+ arg1 -64))) + (a1-11 (-> arg2 interp-select 1)) + ) + (dotimes (a2-10 a0-12) + (when (logtest? a1-11 1) + (let* ((a3-15 (-> arg0 data (+ a2-10 62))) + (t2-4 (-> v1-9 data (+ a2-10 62))) + (t0-9 (-> t2-4 trans quad)) + (t1-3 (-> t2-4 quat vec quad)) + (t2-5 (-> t2-4 scale quad)) + ) + (set! (-> a3-15 trans quad) t0-9) + (set! (-> a3-15 quat vec quad) t1-3) + (set! (-> a3-15 scale quad) t2-5) + ) + ) + (set! a1-11 (shr a1-11 1)) + ) + ) + ) + 0 + ) + +;; definition for method 2 of type art-joint-anim-manager-slot +(defmethod print art-joint-anim-manager-slot ((obj art-joint-anim-manager-slot)) + (let* ((gp-0 format) + (s5-0 #t) + (s4-0 "#") + (v1-0 (-> obj anim)) + (s3-0 (if v1-0 + (-> v1-0 name) + ) + ) + (s1-0 (-> obj comp-data)) + (v1-1 (-> obj anim)) + ) + (gp-0 + s5-0 + s4-0 + s3-0 + s1-0 + (if v1-1 + (-> v1-1 frames fixed) + 0 + ) + (if (-> obj anim) + (sar + (used-bytes-for-slot + *anim-manager* + (the-as int (/ (the-as int (- (the-as uint obj) (the-as uint (the-as uint (-> *anim-manager* slot))))) 16)) + ) + 10 + ) + 0 + ) + (-> obj time-stamp) + ) + ) + obj + ) + +;; definition for method 12 of type art-joint-anim-manager +(defmethod used-bytes-for-slot art-joint-anim-manager ((obj art-joint-anim-manager) (arg0 int)) + (let ((v1-2 (-> obj slot arg0))) + (if (< arg0 (+ (-> obj free-index) -1)) + (&- + (the-as pointer (-> obj slot (+ arg0 1) anim frames fixed)) + (the-as uint (the-as pointer (-> v1-2 anim frames fixed))) + ) + (&- (the-as pointer (-> obj kheap current)) (the-as uint (the-as pointer (-> v1-2 anim frames fixed)))) + ) + ) + ) + +;; definition for method 11 of type art-joint-anim-manager +(defmethod unload-from-slot art-joint-anim-manager ((obj art-joint-anim-manager) (arg0 int)) + (let* ((s3-0 (-> obj slot arg0)) + (s5-0 (-> s3-0 anim)) + ) + (let ((s2-0 (the-as object (-> s5-0 frames fixed)))) + (if (= (-> *display* base-clock frame-counter) (-> s3-0 time-stamp)) + (format 0 "ERROR: anim-decomp: removing cache entry for ~A, but it is still in use.~%" s5-0) + ) + (let ((a0-5 (-> s3-0 comp-data)) + (v1-6 (-> s5-0 frames)) + ) + (set! (-> v1-6 fixed) (the-as joint-anim-compressed-fixed a0-5)) + (dotimes (a1-2 (the-as int (-> v1-6 num-frames))) + (set! (-> v1-6 data a1-2) + (the-as + joint-anim-compressed-frame + (+ a0-5 (* (+ (-> v1-6 fixed-qwc) (* (the-as uint a1-2) (-> v1-6 frame-qwc))) 16)) + ) + ) + ) + (logior! (-> v1-6 flags) 1) + (set! (-> v1-6 flags) (logand -3 (-> v1-6 flags))) + ) + (cond + ((< arg0 (+ (-> obj free-index) -1)) + (let ((s1-0 (- (the-as uint (-> obj slot (+ arg0 1) anim frames fixed)) (the-as uint s2-0)))) + (let ((s0-0 (+ (- -1 arg0) (-> obj free-index)))) + (let ((a2-6 (&- (-> obj kheap current) (the-as uint (+ (the-as uint s2-0) s1-0))))) + (if (< (the-as int a2-6) 2560) + (qmem-copy<-! (the-as pointer s2-0) (the-as pointer (+ (the-as uint s2-0) s1-0)) (the-as int a2-6)) + (ultimate-memcpy (the-as pointer s2-0) (the-as pointer (+ (the-as uint s2-0) s1-0)) (the-as uint a2-6)) + ) + ) + (qmem-copy<-! (the-as pointer s3-0) (the-as pointer (&+ s3-0 16)) (* s0-0 16)) + (dotimes (v1-20 s0-0) + (let ((a0-21 (-> obj slot (+ arg0 v1-20) anim frames))) + (set! (-> a0-21 fixed) (the-as joint-anim-compressed-fixed (- (the-as uint (-> a0-21 fixed)) s1-0))) + (dotimes (a1-9 (the-as int (-> a0-21 num-frames))) + (set! (-> a0-21 data a1-9) (the-as joint-anim-compressed-frame (- (the-as uint (-> a0-21 data a1-9)) s1-0))) + ) + ) + ) + ) + (set! s3-0 (-> obj slot (+ (-> obj free-index) -1))) + (set! (-> obj kheap current) (&- (-> obj kheap current) (the-as uint s1-0))) + ) + ) + (else + (set! (-> obj kheap current) (the-as pointer s2-0)) + ) + ) + ) + (+! (-> obj free-index) -1) + (set! (-> s3-0 anim) #f) + (set! (-> s3-0 time-stamp) (the-as uint 0)) + (set! (-> s3-0 comp-data) (the-as uint 0)) + s5-0 + ) + ) + +;; definition for method 10 of type art-joint-anim-manager +(defmethod update-time-stamp art-joint-anim-manager ((obj art-joint-anim-manager) (arg0 art-joint-anim)) + (countdown (v1-0 (-> obj free-index)) + (when (= arg0 (-> obj slot v1-0 anim)) + (set! (-> obj slot v1-0 time-stamp) (the-as uint (-> *display* base-clock frame-counter))) + (return arg0) + ) + ) + arg0 + ) + +;; definition for method 9 of type art-joint-anim-manager +(defmethod decompress art-joint-anim-manager ((obj art-joint-anim-manager) (arg0 art-joint-anim)) + (let* ((s5-0 (-> arg0 frames)) + (s3-0 (* (+ (-> s5-0 fixed-qwc) (* (-> s5-0 num-frames) (-> s5-0 frame-qwc))) 16)) + ) + (while (or (< (the-as uint (&- (-> obj kheap top) (the-as uint (-> obj kheap current)))) (+ s3-0 64)) + (>= (-> obj free-index) 64) + ) + (let ((a1-2 -1)) + (let ((a0-3 0)) + (dotimes (v1-2 (-> obj free-index)) + (when (or (< a1-2 0) (< (the-as int (-> obj slot v1-2 time-stamp)) a0-3)) + (set! a0-3 (the-as int (-> obj slot v1-2 time-stamp))) + (set! a1-2 v1-2) + ) + ) + ) + (unload-from-slot obj a1-2) + ) + ) + (let ((v1-15 (-> obj slot (-> obj free-index)))) + 0 + (+! (-> obj free-index) 1) + (set! (-> v1-15 anim) arg0) + (set! (-> v1-15 time-stamp) (the-as uint (-> *display* base-clock frame-counter))) + (set! (-> v1-15 comp-data) (the-as uint (-> s5-0 fixed))) + ) + (let ((s4-1 (kmalloc (-> obj kheap) (the-as int s3-0) (kmalloc-flags) "malloc"))) + (unpack-comp-lzo s4-1 (-> s5-0 fixed)) + (set! (-> s5-0 flags) (logand -2 (-> s5-0 flags))) + (logior! (-> s5-0 flags) 2) + (set! (-> s5-0 fixed) (the-as joint-anim-compressed-fixed s4-1)) + (dotimes (v1-22 (the-as int (-> s5-0 num-frames))) + (set! (-> s5-0 data v1-22) + (the-as + joint-anim-compressed-frame + (&+ s4-1 (* (+ (-> s5-0 fixed-qwc) (* (the-as uint v1-22) (-> s5-0 frame-qwc))) 16)) + ) + ) + ) + ) + ) + (flush-cache 0) + arg0 + ) + +;; definition for method 13 of type art-joint-anim-manager +;; INFO: Return type mismatch int vs none. +(defmethod unload-from-level art-joint-anim-manager ((obj art-joint-anim-manager) (arg0 level)) + (let ((s5-0 (-> arg0 heap base)) + (s4-0 (-> arg0 heap top-base)) + ) + (countdown (s3-0 (-> obj free-index)) + (if (and (>= (the-as int (-> obj slot s3-0 anim)) (the-as int s5-0)) + (< (the-as int (-> obj slot s3-0 anim)) (the-as int s4-0)) + ) + (unload-from-slot obj s3-0) + ) + ) + ) + 0 + (none) + ) + +;; failed to figure out what this is: +(kmemopen global "anim-manager") + +;; definition for symbol *anim-manager*, type art-joint-anim-manager +(define *anim-manager* (new 'global 'art-joint-anim-manager #x30000)) + +;; failed to figure out what this is: +(kmemclose) + + + + diff --git a/test/decompiler/reference/jak2/engine/anim/mspace-h_REF.gc b/test/decompiler/reference/jak2/engine/anim/mspace-h_REF.gc index 6c40eb9aed..8396e24dc3 100644 --- a/test/decompiler/reference/jak2/engine/anim/mspace-h_REF.gc +++ b/test/decompiler/reference/jak2/engine/anim/mspace-h_REF.gc @@ -121,7 +121,8 @@ :size-assert #x20 :flag-assert #xa00000020 (:methods - (cspace-method-9 () none 9) + (new (symbol type basic) _type_ 0) + (reset-and-assign-geo! (_type_ basic) _type_ 9) ) ) @@ -186,7 +187,3 @@ ;; failed to figure out what this is: 0 - - - - diff --git a/test/decompiler/reference/jak2/engine/data/art-h_REF.gc b/test/decompiler/reference/jak2/engine/data/art-h_REF.gc index d5b6bb6b00..779ff04df8 100644 --- a/test/decompiler/reference/jak2/engine/data/art-h_REF.gc +++ b/test/decompiler/reference/jak2/engine/data/art-h_REF.gc @@ -88,8 +88,8 @@ ;; definition of type joint-anim-frame (deftype joint-anim-frame (structure) - ((matrices matrix 2 :inline :offset-assert 0) - (data matrix :dynamic :offset-assert 128) + ((matrices matrix 2 :inline :offset-assert 0) + (data transformq :inline :dynamic :offset-assert 128) ) :method-count-assert 9 :size-assert #x80 @@ -249,10 +249,10 @@ :size-assert #x14 :flag-assert #xd00000014 (:methods - (art-method-9 () none 9) - (art-method-10 () none 10) - (art-method-11 () none 11) - (art-method-12 () none 12) + (login (_type_) _type_ 9) + (get-art-by-name-method (_type_ string type) basic 10) + (get-art-idx-by-name-method (_type_ string type) int 11) + (needs-link? (_type_) symbol 12) ) ) @@ -295,7 +295,8 @@ ;; definition of type art-mesh-anim (deftype art-mesh-anim (art-element) - () + ((data basic :dynamic :offset-assert 32) + ) :method-count-assert 13 :size-assert #x20 :flag-assert #xd00000020 @@ -306,7 +307,7 @@ ((speed float :offset 20) (artist-base float :offset 24) (artist-step float :offset 28) - (eye-anim basic :offset 4) + (eye-anim merc-eye-anim-block :offset 4) (master-art-group-name string :offset-assert 32) (master-art-group-index int32 :offset-assert 36) (blend-shape-anim basic :offset-assert 40) @@ -348,14 +349,16 @@ :size-assert #x20 :flag-assert #xf00000020 (:methods - (art-group-method-13 () none 13) + (relocate (_type_ kheap (pointer uint8)) none :replace 7) + (link-art! (_type_) art-group 13) (art-group-method-14 () none 14) ) ) ;; definition of type art-mesh-geo (deftype art-mesh-geo (art-element) - () + ((data basic :dynamic :offset-assert 32) + ) :method-count-assert 13 :size-assert #x20 :flag-assert #xd00000020 @@ -363,7 +366,8 @@ ;; definition of type art-joint-geo (deftype art-joint-geo (art-element) - () + ((data joint :dynamic :offset-assert 32) + ) :method-count-assert 13 :size-assert #x20 :flag-assert #xd00000020 @@ -371,9 +375,9 @@ ;; definition of type art-joint-anim-manager-slot (deftype art-joint-anim-manager-slot (structure) - ((anim basic :offset-assert 0) - (comp-data uint32 :offset-assert 4) - (time-stamp uint64 :offset-assert 8) + ((anim art-joint-anim :offset-assert 0) + (comp-data uint32 :offset-assert 4) + (time-stamp uint64 :offset-assert 8) ) :method-count-assert 9 :size-assert #x10 @@ -405,10 +409,10 @@ :flag-assert #xe00000430 (:methods (new (symbol type int) _type_ 0) - (art-joint-anim-manager-method-9 () none 9) - (art-joint-anim-manager-method-10 () none 10) - (unload-from-slot (_type_ int) none 11) - (art-joint-anim-manager-method-12 () none 12) + (decompress (_type_ art-joint-anim) art-joint-anim 9) + (update-time-stamp (_type_ art-joint-anim) art-joint-anim 10) + (unload-from-slot (_type_ int) art-joint-anim 11) + (used-bytes-for-slot (_type_ int) int 12) (unload-from-level (_type_ level) none 13) ) ) diff --git a/test/decompiler/reference/jak2/engine/level/level-h_REF.gc b/test/decompiler/reference/jak2/engine/level/level-h_REF.gc index b4fbfd524d..385489763c 100644 --- a/test/decompiler/reference/jak2/engine/level/level-h_REF.gc +++ b/test/decompiler/reference/jak2/engine/level/level-h_REF.gc @@ -686,7 +686,7 @@ (:methods (level-get (_type_ symbol) level 9) (level-get-with-status (_type_ symbol) level 10) - (get-level-by-heap-ptr-and-status (_type_ pointer uint) level 11) + (get-level-by-heap-ptr-and-status (_type_ pointer symbol) level 11) (level-get-for-use (_type_ symbol symbol) level 12) (activate-levels! (_type_) int 13) (level-group-method-14 () none 14) diff --git a/test/offline/config/jak2/config.jsonc b/test/offline/config/jak2/config.jsonc index af876eb207..5757584dbf 100644 --- a/test/offline/config/jak2/config.jsonc +++ b/test/offline/config/jak2/config.jsonc @@ -43,6 +43,8 @@ "load-game-text-info", // - never fixed this one in jak 1, assumed there was an original bug? "print-game-text", + // joint asm + "cspace<-parented-transformq-joint!", "(method 11 art-joint-anim-manager)", "make-joint-jump-tables", "i-hopefully-will-never-exist-dont-add-anything-after-me-please" ],