diff --git a/decompiler/IR2/FormExpressionAnalysis.cpp b/decompiler/IR2/FormExpressionAnalysis.cpp index f14371fc2a..eefe5403f2 100644 --- a/decompiler/IR2/FormExpressionAnalysis.cpp +++ b/decompiler/IR2/FormExpressionAnalysis.cpp @@ -1860,20 +1860,33 @@ void SimpleExpressionElement::update_from_stack_logor_or_logand(const Env& env, return; } + // jak 1: + // (logior (shl (-> v1-61 0 pid) 32) (.asm.sllv.r0 v1-61)) + // jak 2: + // (logior (if v1-61 (shl (-> v1-61 0 pid) 32) 0) (.asm.sllv.r0 v1-61)) + auto pid_deref_matcher = Matcher::op_fixed( + FixedOperatorKind::SHL, + {Matcher::deref(Matcher::any_reg(0), false, + {DerefTokenMatcher::integer(0), DerefTokenMatcher::string("pid")}), + Matcher::integer(32)}); auto make_handle_matcher = Matcher::op_fixed( FixedOperatorKind::LOGIOR, - {Matcher::op_fixed( - FixedOperatorKind::SHL, - {Matcher::deref(Matcher::any_reg(0), false, - {DerefTokenMatcher::integer(0), DerefTokenMatcher::string("pid")}), - Matcher::integer(32)}), + {env.version == GameVersion::Jak1 + ? pid_deref_matcher + : Matcher::if_with_else( + Matcher::op(GenericOpMatcher::condition(IR2_Condition::Kind::TRUTHY), + {Matcher::any_reg(2)}), + pid_deref_matcher, Matcher::integer(0)), Matcher::op_fixed(FixedOperatorKind::ASM_SLLV_R0, {Matcher::any_reg(1)})}); auto handle_mr = match(make_handle_matcher, element); if (handle_mr.matched) { auto var_a = handle_mr.maps.regs.at(0).value(); auto var_b = handle_mr.maps.regs.at(1).value(); - if (env.get_variable_name(var_a) == env.get_variable_name(var_b) && + const auto& var_name = env.get_variable_name(var_a); + if (var_name == env.get_variable_name(var_b) && + (env.version == GameVersion::Jak1 || + var_name == env.get_variable_name(handle_mr.maps.regs.at(2).value())) && env.dts->ts.tc(TypeSpec("pointer", {TypeSpec("process")}), env.get_variable_type(var_a, true))) { auto* menv = const_cast(&env); diff --git a/decompiler/analysis/insert_lets.cpp b/decompiler/analysis/insert_lets.cpp index 8ea37652e9..10be1d097e 100644 --- a/decompiler/analysis/insert_lets.cpp +++ b/decompiler/analysis/insert_lets.cpp @@ -1130,19 +1130,26 @@ FormElement* rewrite_joint_macro(LetElement* in, const Env& env, FormPool& pool) } auto form_fg = set_fg ? set_fg : arg_group; + // jak 1: (the float (+ (-> a0-14 frame-group data 0 length) -1)) + // jak 2: (the float (+ (-> a0-14 frame-group frames num-frames) -1)) + auto matcher_cur_group_max_frames = + env.version == GameVersion::Jak1 + ? Matcher::deref( + Matcher::any_reg(0), false, + {DerefTokenMatcher::string("frame-group"), DerefTokenMatcher::string("data"), + DerefTokenMatcher::integer(0), DerefTokenMatcher::string("length")}) + : Matcher::deref( + Matcher::any_reg(0), false, + {DerefTokenMatcher::string("frame-group"), DerefTokenMatcher::string("frames"), + DerefTokenMatcher::string("num-frames")}); auto matcher_max_num = Matcher::cast( - "float", - Matcher::op_fixed( - FixedOperatorKind::ADDITION, - {form_fg - ? Matcher::deref(Matcher::any(1), false, - {DerefTokenMatcher::string("data"), DerefTokenMatcher::integer(0), - DerefTokenMatcher::string("length")}) - : Matcher::deref( - Matcher::any_reg(0), false, - {DerefTokenMatcher::string("frame-group"), DerefTokenMatcher::string("data"), - DerefTokenMatcher::integer(0), DerefTokenMatcher::string("length")}), - Matcher::integer(-1)})); + "float", Matcher::op_fixed(FixedOperatorKind::ADDITION, + {form_fg ? Matcher::deref(Matcher::any(1), false, + {DerefTokenMatcher::string("data"), + DerefTokenMatcher::integer(0), + DerefTokenMatcher::string("length")}) + : matcher_cur_group_max_frames, + Matcher::integer(-1)})); // DONE CHECKING EVERYTHING!!! Now write the goddamn macro. std::vector args; diff --git a/decompiler/config/jak2/all-types.gc b/decompiler/config/jak2/all-types.gc index 9b1ca9622b..60809a1e6d 100644 --- a/decompiler/config/jak2/all-types.gc +++ b/decompiler/config/jak2/all-types.gc @@ -1390,7 +1390,7 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (deftype matrix (structure) - ((data float 16 :offset-assert 0 :score -1) + ((data float 16 :offset-assert 0 :score -10) (vector vector 4 :inline :offset 0) (quad uint128 4 :offset 0) (trans vector :inline :offset 48) @@ -4356,7 +4356,7 @@ (define-extern quaternion-from-two-vectors-smooth! (function quaternion vector vector float int quaternion)) (define-extern matrix-from-two-vectors-max-angle-partial! (function matrix vector vector float float matrix)) (define-extern matrix-from-two-vectors-partial-linear! (function matrix vector vector float matrix)) -(define-extern matrix-remove-z-rot (function matrix matrix matrix)) +(define-extern matrix-remove-z-rot (function matrix vector matrix)) (define-extern matrix-rot-diff! (function vector matrix matrix float)) (define-extern quaternion-seek (function quaternion quaternion quaternion float float quaternion)) (define-extern vector-deg-seek (function vector vector vector float vector)) @@ -4562,7 +4562,7 @@ ;; Failed to read fields. (:methods (new (symbol type int level) _type_ 0) - (load-dir-method-9 () none 9) ;; (load-to-heap-by-name (_type_ string symbol kheap int) art-group 9) + (load-to-heap-by-name (_type_ string symbol kheap int) art-group 9) (set-loaded-art (_type_ art-group) art-group 10) ) ) @@ -4583,7 +4583,7 @@ (locked? symbol :offset-assert 16) ;; guessed by decompiler (login? symbol :offset-assert 20) (frame-lock symbol :offset-assert 24) ;; guessed by decompiler - (init-heap function :offset-assert 28) + (init-heap (function external-art-buffer object) :offset-assert 28) (heap kheap :inline :offset-assert 32) (pending-load-file string :offset-assert 48) ;; guessed by decompiler (pending-load-file-part int32 :offset-assert 52) @@ -4603,23 +4603,24 @@ :flag-assert #x1000000068 (:methods (new (symbol type int function symbol) _type_ 0) - (external-art-buffer-method-9 () none 9) ;; (set-pending-file (_type_ string int handle float) int 9) - (external-art-buffer-method-10 () none 10) ;; (update (_type_) int 10) - (external-art-buffer-method-11 () none 11) ;; (inactive? (_type_) symbol 11) - (external-art-buffer-method-12 () none 12) ;; (file-status (_type_ string int) symbol 12) - (external-art-buffer-method-13 () none 13) ;; (link-file (_type_ art-group) art-group 13) - (external-art-buffer-method-14 () none 14) ;; (unlink-file (_type_ art-group) int 14) - (external-art-buffer-method-15 () none 15) ;; (unlock! (_type_) symbol 15) + (set-pending-file (_type_ string int handle float) int 9) + (update (_type_) int 10) + (inactive? (_type_) symbol 11) + (file-status (_type_ string int) symbol 12) + (link-file (_type_ art-group) art-group 13) + (unlink-file (_type_ art-group) int 14) + (unlock! (_type_) int 15) ) ) (deftype spool-anim (basic) ((name string :offset 16) ;; guessed by decompiler (anim-name basic :offset-assert 20) + (buffer external-art-buffer :offset 20 :score 10) ;; added (parts int32 :offset-assert 24) (hint-id int32 :offset 24) (priority float :offset-assert 28) - (owner uint64 :offset-assert 32) ;; handle + (owner handle :offset-assert 32) (command-list pair :offset-assert 40) ;; guessed by decompiler ) :method-count-assert 9 @@ -4627,6 +4628,7 @@ :flag-assert #x90000002c ) +(declare-type process-drawable process) (deftype external-art-control (basic) ((buffer external-art-buffer 2 :offset-assert 4) ;; guessed by decompiler (rec spool-anim 3 :inline :offset-assert 16) ;; guessed by decompiler @@ -4646,11 +4648,11 @@ (new (symbol type) _type_ 0) (update (_type_ symbol) int 9) (clear-rec (_type_) int 10) - (external-art-control-method-11 () none 11) ;; (spool-push (_type_ string int process float) int 11) - (external-art-control-method-12 () none 12) ;; (file-status (_type_ string int) symbol 12) - (external-art-control-method-13 () none 13) ;; (reserve-alloc (_type_) kheap 13) - (external-art-control-method-14 () none 14) ;; (reserve-free (_type_ kheap) int 14) - (external-art-control-method-15 () none 15) ;; (none-reserved? (_type_) symbol 15) + (spool-push (_type_ string int process float) int 11) + (file-status (_type_ string int) symbol 12) + (reserve-alloc (_type_) kheap 13) + (reserve-free (_type_ kheap) int 14) + (none-reserved? (_type_) symbol 15) ) ) @@ -7079,7 +7081,7 @@ (stereo-mode int32) (music symbol) (sound-stinger int32 :offset-assert 236) - (spool-anim symbol) + (spool-anim spool-anim) (sound-mode uint32) (task-manager (pointer process)) (task symbol) @@ -9983,7 +9985,7 @@ (:methods (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) + (unlink-art! (_type_) int 14) ) ) @@ -11442,16 +11444,16 @@ (reset! (_type_) _type_ 9) (update! (_type_) int 10) (want-levels (_type_ (pointer symbol)) int 11) - (want-sound-banks (_type_ (pointer symbol)) none 12) ;; (want-display-level (_type_ symbol symbol) int 12) + (want-sound-banks (_type_ (pointer symbol)) none 12) (want-display-level (_type_ symbol symbol) int 13) - (want-vis-level (_type_ symbol) none 14) ;; (want-force-vis (_type_ symbol symbol) int 14) - (load-state-method-15 () none 15) ;; (execute-command (_type_ pair) none 15) - (load-state-method-16 () none 16) ;; (execute-commands-up-to (_type_ float) int 16) - (load-state-method-17 () none 17) ;; (backup-load-state-and-set-cmds (_type_ pair) int 17) - (load-state-method-18 () none 18) ;; (restore-load-state-and-cleanup (_type_) int 18) - (load-state-method-19 () none 19) ;; (restore-load-state (_type_) int 19) - (load-state-method-20 () none 20) ;; (set-force-inside! (_type_ symbol symbol) none 20) - (load-state-method-21 () none 21) + (want-vis-level (_type_ symbol) none 14) + (want-force-vis (_type_ symbol symbol) int 15) + (execute-command (_type_ pair) none 16) + (execute-commands-up-to (_type_ float) none 17) + (backup-load-state-and-set-cmds (_type_ pair) int 18) + (restore-load-state-and-cleanup (_type_) int 19) + (restore-load-state (_type_) int 20) + (set-force-inside! (_type_ symbol symbol) none 21) ) ) @@ -11801,8 +11803,8 @@ (channel gui-channel :offset 21) (anim-part uint8 :offset 22) (flags uint8 :offset 23) - (name object :offset 24) - (id uint32 :offset 28) + (name string :offset 24) + (id sound-id :offset 28) (handle handle :offset 0) (time-stamp time-frame :offset 8) (hold-time time-frame :offset-assert 32) @@ -11824,29 +11826,35 @@ (deftype gui-control (basic) ((engine engine) - (data uint8 3272) + (update-time time-frame :offset-assert 8) + (connections gui-connection 32 :inline :offset-assert 16) + (spool-connections gui-connection 4 :inline :offset-assert 1552) + (ids sound-id 96 :offset-assert 1744) + (times time-frame 96 :offset-assert 2128) + (cmd pair 96 :offset-assert 2896) ) :method-count-assert 25 :size-assert #xcd0 :flag-assert #x1900000cd0 ;; Failed to read fields. (:methods - (gui-control-method-9 () none 9) - (gui-control-method-10 () none 10) - (gui-control-method-11 () none 11) - (gui-control-method-12 () none 12) - (update (_type_ symbol) none 13) - (gui-control-method-14 () none 14) - (gui-control-method-15 () none 15) - (gui-control-method-16 () none 16) - (gui-control-method-17 () none 17) - (gui-control-method-18 () none 18) - (gui-control-method-19 () none 19) - (gui-control-method-20 () none 20) - (gui-control-method-21 () none 21) - (gui-control-method-22 () none 22) - (gui-control-method-23 () none 23) - (gui-control-method-24 () none 24) + (new (symbol type int) _type_ 0) + (gui-control-method-9 (_type_ process gui-channel gui-action int float time-frame) sound-id 9) + (gui-control-method-10 (_type_ process gui-channel) none 10) + (gui-control-method-11 (_type_ gui-connection) int 11) + (gui-control-method-12 (_type_ process gui-channel gui-action string int float sound-id) sound-id 12) + (update (_type_ symbol) int 13) + (gui-control-method-14 (_type_ string gui-channel gui-action) int 14) + (gui-control-method-15 (_type_ process gui-channel string sound-id) gui-connection 15) + (gui-control-method-16 (_type_ gui-action sound-id gui-channel gui-action string (function gui-connection symbol) process) int 16) + (gui-control-method-17 (_type_ sound-id) gui-action 17) + (gui-control-method-18 (_type_ gui-channel) symbol 18) + (gui-control-method-19 (_type_ gui-channel gui-connection) symbol 19) + (gui-control-method-20 (_type_ sound-id symbol int int int) gui-connection 20) + (gui-control-method-21 (_type_ gui-connection vector) int 21) + (gui-control-method-22 (_type_ gui-connection process symbol) none 22) + (gui-control-method-23 (_type_ gui-channel gui-channel symbol gui-connection) symbol 23) + (channel-id-set! (_type_ gui-connection sound-id) int 24) ) ) @@ -13286,7 +13294,6 @@ ) (declare-type target process-focusable) -(declare-type process-drawable process) (deftype fact-info-target (fact-info) ((eco-type int32) @@ -14297,16 +14304,21 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defenum joint-mod-mode - :bitfield #t - :type uint32 - (flex-blend 0) ;; 1 - (look-at 1) ;; 2 - (world-look-at 2) ;; 4 - (rotate 3) ;; 8 - (joint-set 4) ;; 16 - (joint-set* 5) ;; 32 - ;; ?? ;; 64 - (reset 7) ;; 128 + :bitfield #t + :type uint32 + (flex-blend) + (look-at) + (world-look-at) + (rotate) + (joint-set) + (joint-set*) + (rotate2) ;; ?? + (reset) + (polar-look-at) + (joint-set*-world) + (gun-look-at) + (foot-rot) + (joint-set-world) ) ;; +++joint-mod-h:track-mode @@ -14325,12 +14337,12 @@ (deftype joint-mod (basic) ((mode joint-mod-mode) - (process process) + (process process-drawable) (joint cspace) - (target vector :inline :offset 16) - (twist vector :inline :offset 32) - ;;(twist-max vector :inline) - (twist-max float 4) + (target vector :inline) + (twist vector :inline) + (twist-max vector :inline) + ;; (twist-max float 4) (extra-twist degrees :offset 40) (track-mode track-mode :offset 44) (loock-at-count uint16 :offset 46) @@ -14369,18 +14381,18 @@ ;; Failed to read fields. (:methods (new (symbol type joint-mod-mode process-drawable int) _type_ 0) - (joint-mod-method-9 () none 9) ;; (set-mode! (_type_ joint-mod-handler-mode) _type_ 9) - (joint-mod-method-10 () none 10) ;; (set-target! (_type_ vector) none 10) - (joint-mod-method-11 () none 11) ;; (look-at-enemy! (_type_ vector symbol process) none 11) + (mode-set! (_type_ joint-mod-mode) none 9) + (target-set! (_type_ vector) none 10) + (look-at! (_type_ vector symbol process) none :behavior process 11) (reset-blend! (_type_) _type_ 12) - (joint-mod-method-13 () none 13) ;; (set-twist! (_type_ float float float) vector 13) - (joint-mod-method-14 () none 14) ;; (set-trs! (_type_ vector quaternion vector) none 14) - (joint-mod-method-15 () none 15) ;; (shut-down! (_type_) float 15) + (twist-set! (_type_ float float float) vector 13) + (trs-set! (_type_ vector quaternion vector) none 14) + (shut-down (_type_) none 15) ) ) (deftype try-to-look-at-info (basic) - ((who handle :offset-assert 8) ;; handle + ((who handle :offset-assert 8) (horz float :offset-assert 16) (vert float :offset-assert 20) ) @@ -14476,10 +14488,18 @@ :flag-assert #x90000002c ) +(defenum joint-mod-blend-flags + :bitfield #t + :type uint32 + (trans) + (scale) + (rotation) + ) + (deftype joint-mod-blend-world (basic) ((transform transformq :inline :offset-assert 16) (blend-transform transformq :inline :offset-assert 64) - (blend-flags uint32 :offset-assert 112) + (blend-flags joint-mod-blend-flags :offset-assert 112) (node-index int32 :offset-assert 116) (blend float :offset-assert 120) (enable symbol :offset-assert 124) @@ -14504,9 +14524,17 @@ :flag-assert #x900000020 ) +(defenum joint-mod-ik-flags + :bitfield #t + :type uint32 + (enable) + (elbow-trans-neg) + (elbow-rot-neg) + ) + (deftype joint-mod-ik (basic) - ((flags uint32 :offset-assert 4) - (process basic :offset-assert 8) + ((flags joint-mod-ik-flags :offset-assert 4) + (process process-drawable :offset-assert 8) (hand-dist float :offset-assert 12) (handle-pos vector :inline :offset-assert 16) (elbow-pole-vector-axis uint32 :offset-assert 32) @@ -14515,7 +14543,7 @@ (user-normal vector :inline :offset-assert 64) (user-blend float :offset-assert 80) (user-float float :offset-assert 84) - (callback basic :offset-assert 88) + (callback (function joint-mod-ik matrix matrix vector object) :offset-assert 88) (shoulder-matrix-no-ik matrix :inline :offset-assert 96) (elbow-matrix-no-ik matrix :inline :offset-assert 160) (blend float :offset-assert 224) @@ -14525,8 +14553,9 @@ :size-assert #xe8 :flag-assert #xb000000e8 (:methods - (joint-mod-ik-method-9 () none 9) - (joint-mod-ik-method-10 () none 10) + (new (symbol type process-drawable int float) _type_) + (handle-copy! (_type_ vector) none 9) + (enable-set! (_type_ symbol) none 10) ) ) @@ -15684,18 +15713,18 @@ (define-extern cspace-by-name-no-fail (function process-drawable string cspace)) (define-extern cspace-index-by-name-no-fail (function process-drawable string int)) -(define-extern num-func-none (function joint-control-channel float float float)) -(define-extern num-func-+! (function joint-control-channel float float float)) -(define-extern num-func--! (function joint-control-channel float float float)) -(define-extern num-func-loop! (function joint-control-channel float float float)) -(define-extern num-func-loop-speedless! (function joint-control-channel float float float)) -(define-extern num-func-seek! (function joint-control-channel float float float)) -(define-extern num-func-blend-in! (function joint-control-channel float float float)) +(define-extern num-func-none (function joint-control-channel float float float float :behavior process)) +(define-extern num-func-+! (function joint-control-channel float float float float :behavior process)) +(define-extern num-func--! (function joint-control-channel float float float float :behavior process)) +(define-extern num-func-loop! (function joint-control-channel float float float float :behavior process)) +(define-extern num-func-loop-speedless! (function joint-control-channel float float float float :behavior process)) +(define-extern num-func-seek! (function joint-control-channel float float float float :behavior process)) +(define-extern num-func-blend-in! (function joint-control-channel float float float float :behavior process)) (define-extern joint-channel-float-delete! (function joint-control-channel none)) -(define-extern num-func-interp-play! (function joint-control-channel float float float float)) -(define-extern num-func-interp1-play! (function joint-control-channel float float float float)) -(define-extern num-func-chan (function joint-control-channel float float float)) -(define-extern num-func-identity (function joint-control-channel float float float)) +(define-extern num-func-interp-play! (function joint-control-channel float float float float :behavior process)) +(define-extern num-func-interp1-play! (function joint-control-channel float float float float :behavior process)) +(define-extern num-func-chan (function joint-control-channel float float float float :behavior process)) +(define-extern num-func-identity (function joint-control-channel float float float float :behavior process)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; process-focusable ;; @@ -16041,7 +16070,7 @@ ((position vector :inline :offset-assert 0) (velocity vector :inline :offset-assert 16) (old-x vector :inline :offset-assert 32) - (joint-mod basic :offset-assert 48) + (joint-mod joint-mod :offset-assert 48) ) :method-count-assert 9 :size-assert #x34 @@ -16062,22 +16091,22 @@ (negate-y basic :offset-assert 1360) (axial-slop float :offset-assert 1364) (maximum-stretch float :offset-assert 1368) - (turn-off-start uint64 :offset-assert 1376) - (turn-off-duration uint64 :offset-assert 1384) + (turn-off-start time-frame :offset-assert 1376) + (turn-off-duration time-frame :offset-assert 1384) ) :method-count-assert 18 :size-assert #x570 :flag-assert #x1200000570 (:methods - (chain-physics-method-9 () none 9) - (chain-physics-method-10 () none 10) - (chain-physics-method-11 () none 11) - (chain-physics-method-12 () none 12) - (chain-physics-method-13 () none 13) - (chain-physics-method-14 () none 14) - (chain-physics-method-15 () none 15) - (chain-physics-method-16 () none 16) - (chain-physics-method-17 () none 17) + (initialize-chain-joints (_type_) symbol 9) + (turn-off (_type_ time-frame) none :behavior process 10) + (update (_type_ process-drawable) none :behavior process 11) + (gravity-update (_type_) none 12) + (apply-gravity (_type_ vector int) none :behavior process 13) + (chain-physics-method-14 (_type_ vector int) none 14) + (clamp-length (_type_ vector vector) vector 15) + (chain-physics-method-16 (_type_ int) float 16) + (chain-physics-method-17 (_type_ vector) none 17) ) ) @@ -20936,14 +20965,16 @@ (defenum stream-status :type uint32 :bitfield #t - (zero 0) - (one 1) ;; another way to be playing - (two 2) - (three 3) - (four 4) ;; is playing? - (five 5) - (six 6) ;; another way to be playing. - (seven 7) + (ststatus-zero 0) + (ststatus-one 1) ;; another way to be playing + (ststatus-two 2) + (ststatus-three 3) + (ststatus-four 4) ;; is playing? + (ststatus-five 5) + (ststatus-six 6) ;; another way to be playing. + (ststatus-seven 7) + (ststatus-eight 8) + (ststatus-nine 9) ) (defenum stereo-mode @@ -20969,7 +21000,8 @@ (stream-position uint32 4 :offset 272) (stream-status stream-status 4 :offset-assert 288) (stream-name sound-stream-name 4 :inline :offset-assert 304) - (stream-id uint32 4 :offset-assert 496) + (stream-id sound-id 4 :offset-assert 496) + (stream-id-int32 int32 4 :offset 496) ;; ughhhh... (music-register uint8 17 :offset-assert 512) (music-excite int8 :offset 528) (ramdisk-name uint8 48 :offset-assert 529) @@ -21116,27 +21148,27 @@ ;; joint-mod ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; (define-extern joint-mod-ik-callback function) -;; (define-extern real-joint-mod-gun-look-at-handler function) -;; (define-extern joint-mod-gun-look-at-handler function) -;; (define-extern joint-mod-foot-rot-handler function) +(define-extern joint-mod-ik-callback (function cspace transformq none :behavior process)) +(define-extern real-joint-mod-gun-look-at-handler (function cspace transformq none :behavior process)) +(define-extern joint-mod-gun-look-at-handler (function cspace transformq none :behavior process)) +(define-extern joint-mod-foot-rot-handler (function cspace transformq none :behavior process)) (define-extern last-try-to-look-at-data try-to-look-at-info) -;; (define-extern joint-mod-look-at-handler function) ;; (function cspace transformq none) -;; (define-extern joint-mod-polar-look-at-guts function) -;; (define-extern joint-mod-polar-look-at-handler function) -;; (define-extern joint-mod-world-look-at-handler function) ;; (function cspace transformq none) -;; (define-extern joint-mod-rotate-handler function) ;; (function cspace transformq none) -;; (define-extern joint-mod-scale-handler function) -;; (define-extern joint-mod-joint-set-handler function) ;; (function cspace transformq none) -;; (define-extern joint-mod-joint-set-world-handler function) -;; (define-extern joint-mod-joint-set*-handler function) ;; (function cspace transformq none) -;; (define-extern joint-mod-joint-set*-world-handler function) +(define-extern joint-mod-look-at-handler (function cspace transformq none :behavior process)) +(define-extern joint-mod-polar-look-at-guts (function cspace transformq none :behavior process)) +(define-extern joint-mod-polar-look-at-handler (function cspace transformq none :behavior process)) +(define-extern joint-mod-world-look-at-handler (function cspace transformq none :behavior process)) +(define-extern joint-mod-rotate-handler (function cspace transformq none :behavior process)) +(define-extern joint-mod-scale-handler (function cspace transformq none :behavior process)) +(define-extern joint-mod-joint-set-handler (function cspace transformq none :behavior process)) +(define-extern joint-mod-joint-set-world-handler (function cspace transformq none :behavior process)) +(define-extern joint-mod-joint-set*-handler (function cspace transformq none :behavior process)) +(define-extern joint-mod-joint-set*-world-handler (function cspace transformq none :behavior process)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; chain-physics ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; (define-extern chain-physics-initialize function) +(define-extern chain-physics-initialize (function process-drawable chain-physics int float (array chain-physics-setup) int)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; cylinder ;; @@ -21575,7 +21607,7 @@ (define-extern add-debug-text-3d (function symbol bucket-id string vector font-color vector2h symbol)) ;; (define-extern add-debug-sphere-with-transform function) ;; (function symbol bucket-id vector meters matrix rgba symbol) (define-extern add-debug-sphere (function symbol bucket-id vector float rgba symbol)) -;; (define-extern add-debug-text-sphere function) ;; (function symbol bucket-id vector float string rgba symbol) +(define-extern add-debug-text-sphere (function symbol bucket-id vector float string rgba symbol)) ;; (define-extern add-debug-spheres function) ;; (function symbol bucket-id (inline-array vector) int rgba symbol) ;; (define-extern add-debug-line-sphere function) ;; (define-extern add-debug-circle function) ;; (function symbol bucket-id vector float rgba matrix symbol) @@ -22959,27 +22991,11 @@ ;; loader ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| -(deftype load-dir (basic) - () - :method-count-assert 11 - :size-assert #x10 - :flag-assert #xb00000010 - ;; Failed to read fields. - (:methods - ;; (new (symbol type int level) _type_ 0) - (load-dir-method-9 () none 9) ;; (load-to-heap-by-name (_type_ string symbol kheap int) art-group 9) - (load-dir-method-10 () none 10) ;; (set-loaded-art (_type_ art-group) art-group 10) - ) - ) -|# - -#| (deftype spooler-block (basic) - ((anim basic :offset-assert 4) - (idle basic :offset-assert 8) - (exit basic :offset-assert 12) - (break-func basic :offset-assert 16) + ((anim spool-anim :offset-assert 4) + (idle art-joint-anim :offset-assert 8) + (exit art-joint-anim :offset-assert 12) + (break-func (function process-drawable object) :offset-assert 16) (part int32 :offset-assert 20) (part-audio-start float :offset-assert 24) (old-status uint16 :offset-assert 28) @@ -22987,25 +23003,31 @@ (good-time time-frame :offset-assert 40) (old-time time-frame :offset-assert 48) (good-count int32 :offset-assert 56) - (sid uint32 :offset-assert 60) + (sid sound-id :offset-assert 60) (real-start-time time-frame :offset-assert 64) - (paused? basic :offset-assert 72) + (paused? symbol :offset-assert 72) ) :method-count-assert 9 :size-assert #x4c :flag-assert #x90000004c + (:methods + (new (symbol type art-joint-anim (function process-drawable symbol)) _type_ 0) + ) ) -|# -;; (define-extern drawable-load function) ;; (function drawable kheap drawable) -;; (define-extern art-load function) ;; (function string kheap art) -;; (define-extern art-group-load-check function) ;; (function string kheap int art-group) -(define-extern external-art-buffer-init function) -;; (define-extern *preload-spool-anims* object) ;; symbol -;; (define-extern ja-play-spooled-anim function) ;; (function spool-anim art-joint-anim art-joint-anim (function process-drawable symbol) int :behavior process-drawable) -;; (define-extern ja-abort-spooled-anim function) ;; (function spool-anim art-joint-anim int int :behavior process-drawable) +(define-extern drawable-load (function drawable kheap drawable)) +(define-extern art-load (function string kheap art)) +(define-extern art-group-load-check (function string kheap int art-group)) +(define-extern external-art-buffer-init (function external-art-buffer int)) +(define-extern *preload-spool-anims* symbol) +(define-extern ja-play-spooled-anim (function spool-anim art-joint-anim art-joint-anim (function process-drawable symbol) int :behavior process-drawable)) +(define-extern ja-abort-spooled-anim (function spool-anim art-joint-anim int int :behavior process-drawable)) (define-extern *gui-control* gui-control) (define-extern *art-control* external-art-control) +(define-extern *stack-top* pointer) +(define-extern *kernel-sp* pointer) +(define-extern loado (function string kheap object)) +(define-extern link (function pointer pointer int kheap int pointer)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; game-info ;; @@ -25611,7 +25633,7 @@ (define-extern cspace-by-name (function process-drawable string cspace)) (define-extern cspace-index-by-name (function process-drawable string int)) (define-extern vector<-cspace! (function vector cspace vector)) -;; (define-extern vector<-matrix! function) +(define-extern vector<-matrix! (function vector matrix vector)) ;; (define-extern vector<-cspace+vector! function) ;; (function vector cspace vector vector) ;; (define-extern cspace-children function) ;; (function process-drawable int pair) ;; (define-extern cspace-inspect-tree function) ;; (function process-drawable cspace int int object object) @@ -25626,8 +25648,8 @@ ;; (define-extern ja-min? function) ;; (function int symbol :behavior process-drawable) ;; (define-extern ja-max? function) ;; (function int symbol :behavior process-drawable) ;; (define-extern ja-num-frames function) ;; (function int int :behavior process-drawable) -;; (define-extern ja-frame-num function) ;; (function int float :behavior process-drawable) -;; (define-extern ja-aframe-num function) ;; (function int float :behavior process-drawable) +(define-extern ja-frame-num (function int float :behavior process-drawable)) +(define-extern ja-aframe-num (function int float :behavior process-drawable)) (define-extern ja-aframe (function float int float :behavior process-drawable)) ;; (define-extern ja-speed function) ;; (function int float :behavior process-drawable) ;; (define-extern ja-step function) ;; (function int float :behavior process-drawable) @@ -25658,7 +25680,7 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; (define-extern can-display-query? function) -;; (define-extern talker-surpress! function) +(define-extern talker-surpress! (function none)) ;; (define-extern talker-displayed? function) ;; (define-extern kill-current-talker function) ;; (define-extern string->talker-speech function) @@ -45948,12 +45970,11 @@ ) |# -#| (deftype under-mine (process-drawable) - ((chain basic :offset-assert 196) - (chain-initialized basic :offset-assert 200) - (main-mod basic :offset-assert 204) - (head-mod basic :offset-assert 208) + ((chain chain-physics :offset-assert 200) + (chain-initialized symbol :offset-assert 204) + (main-mod joint-mod :offset-assert 208) + (head-mod joint-mod :offset-assert 212) ) :method-count-assert 22 :size-assert #xd8 @@ -45963,7 +45984,6 @@ (idle () _type_ :state 21) ) ) -|# #| (deftype under-lift (elevator) diff --git a/decompiler/config/jak2/anonymous_function_types.jsonc b/decompiler/config/jak2/anonymous_function_types.jsonc index e8501c504c..ccdd701de2 100644 --- a/decompiler/config/jak2/anonymous_function_types.jsonc +++ b/decompiler/config/jak2/anonymous_function_types.jsonc @@ -42,6 +42,8 @@ [6, "(function engine-pers connection-pers object object symbol)"] ], + "joint-mod": [[16, "(function cspace transformq none)"]], + "relocate": [[7, "(function sparticle-system sparticle-cpuinfo none)"]], "default-menu": [ diff --git a/decompiler/config/jak2/hacks.jsonc b/decompiler/config/jak2/hacks.jsonc index 81fe5a3c2c..b15261415f 100644 --- a/decompiler/config/jak2/hacks.jsonc +++ b/decompiler/config/jak2/hacks.jsonc @@ -125,8 +125,6 @@ "(method 16 ocean)", // unknown bug - "joint-mod-polar-look-at-guts", - "(method 13 external-art-control)", "update-mood-copy-ctywide", "update-mood-copy-stadium", "update-mood-drillb", @@ -191,7 +189,8 @@ "debug-menu-make-continue-sub-menu", "debug-menu-make-from-template", "debug-menu-context-make-default-menus", - "debug-menu-make-task-menu" + "debug-menu-make-task-menu", + "(method 19 gui-control)" ], // If format is used with the wrong number of arguments, @@ -201,11 +200,9 @@ "bad_format_strings": { "~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 + "ERROR: ~A in spool anim loop for ~A ~D, but not loaded.~": 3 }, "blocks_ending_in_asm_branch": { @@ -226,7 +223,8 @@ "sprite-draw-distorters": [4, 5], "(method 12 perf-stat)": [0], - "(method 11 perf-stat)": [0] + "(method 11 perf-stat)": [0], + "(method 22 gui-control)": [117, 121, 127, 128, 129, 139] }, // Sometimes the game might use format strings that are fetched dynamically, diff --git a/decompiler/config/jak2/inputs.jsonc b/decompiler/config/jak2/inputs.jsonc index b3b988a81f..32d6a88d91 100644 --- a/decompiler/config/jak2/inputs.jsonc +++ b/decompiler/config/jak2/inputs.jsonc @@ -8,159 +8,159 @@ // the DGOs will be processed in this order. Usually it's best to have KERNEL, ENGINE, then the levels when // you want to run on the entire game. "dgo_names": [ - "CGO/ART.CGO", + // "CGO/ART.CGO", "CGO/KERNEL.CGO", "CGO/ENGINE.CGO", "CGO/GAME.CGO", - "CGO/COMMON.CGO", - "DGO/LWIDEB.DGO", - "DGO/LMEETBRT.DGO", - "DGO/CTA.DGO", - "DGO/PALOUT.DGO", - "DGO/STD.DGO", - "DGO/FOR.DGO", - "DGO/CASEXT.DGO", - "DGO/HIDEOUT.DGO", - "DGO/LWIDESTA.DGO", - "DGO/LRACELIT.DGO", - "DGO/CTB.DGO", - "DGO/KIOSK.DGO", - "DGO/DG1.DGO", - "DGO/FEB.DGO", - "DGO/DMI.DGO", - "DGO/ORACLE.DGO", - "DGO/LERLTESS.DGO", - "DGO/DRI.DGO", - "DGO/LBRNERMK.DGO", - "DGO/LRACECF.DGO", - "DGO/CTC.DGO", - "DGO/LTHRNOUT.DGO", - "DGO/FRA.DGO", - "DGO/LGARCSTA.DGO", - "DGO/MTN.DGO", - "DGO/INTROCST.DGO", - "DGO/DRB.DGO", - "DGO/ATE.DGO", - "DGO/LERROL.DGO", - "DGO/LTRNYSAM.DGO", - "DGO/LOUTCSTB.DGO", - "DGO/LASHTHRN.DGO", - "DGO/TOC.DGO", - "DGO/CFB.DGO", - "DGO/CAB.DGO", - "DGO/STC.DGO", - "DGO/STR.DGO", - "DGO/ATO.DGO", - "DGO/SEB.DGO", - "DGO/LPRSNCST.DGO", - "DGO/SWB.DGO", - "DGO/LPOWER.DGO", - "DGO/FOB.DGO", - "DGO/CIB.DGO", - "DGO/LSHUTTLE.DGO", - "DGO/LJAKDAX.DGO", - "DGO/FORDUMPC.DGO", - "DGO/LTRNTESS.DGO", - "DGO/TBO.DGO", - "DGO/THR.DGO", - "DGO/PRI.DGO", - "DGO/LKIDDOGE.DGO", - "DGO/NESTT.DGO", - "DGO/LWIDEC.DGO", - "DGO/SAG.DGO", - "DGO/NEB.DGO", - "DGO/COB.DGO", - "DGO/LBOMBBOT.DGO", - "DGO/DEMO.DGO", - "DGO/LRACEDF.DGO", - "DGO/LERLCHAL.DGO", - "DGO/LHIPOUT.DGO", - "DGO/OUTROCST.DGO", - "DGO/NES.DGO", - "DGO/PAR.DGO", - "DGO/LERBRNGD.DGO", - "DGO/MTX.DGO", - "DGO/FDA.DGO", - "DGO/LKEIRIFT.DGO", - "DGO/LWHACK.DGO", - "DGO/LJKDXASH.DGO", - "DGO/CAS.DGO", - "DGO/COA.DGO", - "DGO/LTESS.DGO", - "DGO/CFA.DGO", - "DGO/TOMBEXT.DGO", - "DGO/LCGUARD.DGO", - "DGO/TOE.DGO", - "DGO/PALBOSS.DGO", - "DGO/FRB.DGO", - "DGO/PAE.DGO", - "DGO/TITLE.DGO", - "DGO/FORDUMPD.DGO", - "DGO/D3A.DGO", - "DGO/DRILLMTN.DGO", - "DGO/PAC.DGO", - "DGO/LTENTOB.DGO", - "DGO/LRACEBF.DGO", - "DGO/LPROTECT.DGO", - "DGO/FEA.DGO", - "DGO/ONINTENT.DGO", - "DGO/STA.DGO", - "DGO/CGC.DGO", - "DGO/CMA.DGO", - "DGO/FDB.DGO", - "DGO/SKA.DGO", - "DGO/LTRNKRKD.DGO", - "DGO/CIA.DGO", - "DGO/TOB.DGO", - "DGO/LRACEDB.DGO", - "DGO/LDJAKBRN.DGO", - "DGO/TOA.DGO", - "DGO/STADBLMP.DGO", - "DGO/UND.DGO", - "DGO/LYSKDCD.DGO", - "DGO/HALFPIPE.DGO", - "DGO/LSAMERGD.DGO", - "DGO/PAS.DGO", - "DGO/LBBUSH.DGO", - "DGO/LPACKAGE.DGO", - "DGO/LINTCSTB.DGO", - "DGO/LPORTRUN.DGO", - "DGO/LASHGRD.DGO", - "DGO/CGB.DGO", - "DGO/D3B.DGO", - "DGO/STB.DGO", - "DGO/GARAGE.DGO", - "DGO/PORTWALL.DGO", - "DGO/LHELLDOG.DGO", - "DGO/SWE.DGO", - "DGO/LRACECB.DGO", - "DGO/GGA.DGO", - "DGO/TOD.DGO", - "DGO/MCN.DGO", - "DGO/SEW.DGO", - "DGO/VIN.DGO", - "DGO/CGA.DGO", - "DGO/CMB.DGO", - "DGO/LGUARD.DGO", - "DGO/CPA.DGO", - "DGO/LCITYLOW.DGO", - "DGO/LTENTOUT.DGO", - "DGO/UNB.DGO", - "DGO/CPO.DGO", - "DGO/CAP.DGO", - "DGO/CWI.DGO", - "DGO/CTYKORA.DGO", - "DGO/RUI.DGO", - "DGO/LSACK.DGO", - "DGO/CTYASHA.DGO", - "DGO/LPRTRACE.DGO", - "DGO/LWIDEA.DGO", - "DGO/HIPHOG.DGO", - "DGO/LSMYSBRT.DGO", - "DGO/LRACEBB.DGO", - "DGO/CASCITY.DGO", - "DGO/LYSAMSAM.DGO", - "DGO/VI1.DGO" + "CGO/COMMON.CGO" // , + // "DGO/LWIDEB.DGO", + // "DGO/LMEETBRT.DGO", + // "DGO/CTA.DGO", + // "DGO/PALOUT.DGO", + // "DGO/STD.DGO", + // "DGO/FOR.DGO", + // "DGO/CASEXT.DGO", + // "DGO/HIDEOUT.DGO", + // "DGO/LWIDESTA.DGO", + // "DGO/LRACELIT.DGO", + // "DGO/CTB.DGO", + // "DGO/KIOSK.DGO", + // "DGO/DG1.DGO", + // "DGO/FEB.DGO", + // "DGO/DMI.DGO", + // "DGO/ORACLE.DGO", + // "DGO/LERLTESS.DGO", + // "DGO/DRI.DGO", + // "DGO/LBRNERMK.DGO", + // "DGO/LRACECF.DGO", + // "DGO/CTC.DGO", + // "DGO/LTHRNOUT.DGO", + // "DGO/FRA.DGO", + // "DGO/LGARCSTA.DGO", + // "DGO/MTN.DGO", + // "DGO/INTROCST.DGO", + // "DGO/DRB.DGO", + // "DGO/ATE.DGO", + // "DGO/LERROL.DGO", + // "DGO/LTRNYSAM.DGO", + // "DGO/LOUTCSTB.DGO", + // "DGO/LASHTHRN.DGO", + // "DGO/TOC.DGO", + // "DGO/CFB.DGO", + // "DGO/CAB.DGO", + // "DGO/STC.DGO", + // "DGO/STR.DGO", + // "DGO/ATO.DGO", + // "DGO/SEB.DGO", + // "DGO/LPRSNCST.DGO", + // "DGO/SWB.DGO", + // "DGO/LPOWER.DGO", + // "DGO/FOB.DGO", + // "DGO/CIB.DGO", + // "DGO/LSHUTTLE.DGO", + // "DGO/LJAKDAX.DGO", + // "DGO/FORDUMPC.DGO", + // "DGO/LTRNTESS.DGO", + // "DGO/TBO.DGO", + // "DGO/THR.DGO", + // "DGO/PRI.DGO", + // "DGO/LKIDDOGE.DGO", + // "DGO/NESTT.DGO", + // "DGO/LWIDEC.DGO", + // "DGO/SAG.DGO", + // "DGO/NEB.DGO", + // "DGO/COB.DGO", + // "DGO/LBOMBBOT.DGO", + // "DGO/DEMO.DGO", + // "DGO/LRACEDF.DGO", + // "DGO/LERLCHAL.DGO", + // "DGO/LHIPOUT.DGO", + // "DGO/OUTROCST.DGO", + // "DGO/NES.DGO", + // "DGO/PAR.DGO", + // "DGO/LERBRNGD.DGO", + // "DGO/MTX.DGO", + // "DGO/FDA.DGO", + // "DGO/LKEIRIFT.DGO", + // "DGO/LWHACK.DGO", + // "DGO/LJKDXASH.DGO", + // "DGO/CAS.DGO", + // "DGO/COA.DGO", + // "DGO/LTESS.DGO", + // "DGO/CFA.DGO", + // "DGO/TOMBEXT.DGO", + // "DGO/LCGUARD.DGO", + // "DGO/TOE.DGO", + // "DGO/PALBOSS.DGO", + // "DGO/FRB.DGO", + // "DGO/PAE.DGO", + // "DGO/TITLE.DGO", + // "DGO/FORDUMPD.DGO", + // "DGO/D3A.DGO", + // "DGO/DRILLMTN.DGO", + // "DGO/PAC.DGO", + // "DGO/LTENTOB.DGO", + // "DGO/LRACEBF.DGO", + // "DGO/LPROTECT.DGO", + // "DGO/FEA.DGO", + // "DGO/ONINTENT.DGO", + // "DGO/STA.DGO", + // "DGO/CGC.DGO", + // "DGO/CMA.DGO", + // "DGO/FDB.DGO", + // "DGO/SKA.DGO", + // "DGO/LTRNKRKD.DGO", + // "DGO/CIA.DGO", + // "DGO/TOB.DGO", + // "DGO/LRACEDB.DGO", + // "DGO/LDJAKBRN.DGO", + // "DGO/TOA.DGO", + // "DGO/STADBLMP.DGO", + // "DGO/UND.DGO", + // "DGO/LYSKDCD.DGO", + // "DGO/HALFPIPE.DGO", + // "DGO/LSAMERGD.DGO", + // "DGO/PAS.DGO", + // "DGO/LBBUSH.DGO", + // "DGO/LPACKAGE.DGO", + // "DGO/LINTCSTB.DGO", + // "DGO/LPORTRUN.DGO", + // "DGO/LASHGRD.DGO", + // "DGO/CGB.DGO", + // "DGO/D3B.DGO", + // "DGO/STB.DGO", + // "DGO/GARAGE.DGO", + // "DGO/PORTWALL.DGO", + // "DGO/LHELLDOG.DGO", + // "DGO/SWE.DGO", + // "DGO/LRACECB.DGO", + // "DGO/GGA.DGO", + // "DGO/TOD.DGO", + // "DGO/MCN.DGO", + // "DGO/SEW.DGO", + // "DGO/VIN.DGO", + // "DGO/CGA.DGO", + // "DGO/CMB.DGO", + // "DGO/LGUARD.DGO", + // "DGO/CPA.DGO", + // "DGO/LCITYLOW.DGO", + // "DGO/LTENTOUT.DGO", + // "DGO/UNB.DGO", + // "DGO/CPO.DGO", + // "DGO/CAP.DGO", + // "DGO/CWI.DGO", + // "DGO/CTYKORA.DGO", + // "DGO/RUI.DGO", + // "DGO/LSACK.DGO", + // "DGO/CTYASHA.DGO", + // "DGO/LPRTRACE.DGO", + // "DGO/LWIDEA.DGO", + // "DGO/HIPHOG.DGO", + // "DGO/LSMYSBRT.DGO", + // "DGO/LRACEBB.DGO", + // "DGO/CASCITY.DGO", + // "DGO/LYSAMSAM.DGO" //, + // "DGO/VI1.DGO" ], // some objects are part of STR files (streaming data). diff --git a/decompiler/config/jak2/label_types.jsonc b/decompiler/config/jak2/label_types.jsonc index fd258bcaea..613aff2ef2 100644 --- a/decompiler/config/jak2/label_types.jsonc +++ b/decompiler/config/jak2/label_types.jsonc @@ -89,6 +89,7 @@ ["L95", "matrix"], ["L96", "vector4w"] ], + "joint-mod": [["L189", "(inline-array quaternion)", 3]], "sky-data": [ ["L26", "(inline-array sky-vertex)", 12], ["L25", "(inline-array sky-vertex)", 12], diff --git a/decompiler/config/jak2/stack_structures.jsonc b/decompiler/config/jak2/stack_structures.jsonc index f3ce00f43b..a4d7ed7d57 100644 --- a/decompiler/config/jak2/stack_structures.jsonc +++ b/decompiler/config/jak2/stack_structures.jsonc @@ -345,5 +345,62 @@ [16, "bounding-box"] ], // placeholder - "placeholder-do-not-add-below": [] + "placeholder-do-not-add-below": [], + "joint-mod-ik-callback": [ + [16, "matrix"], + [80, "matrix"], + [144, "vector"], + [160, "vector"], + [176, "vector"], + [192, "vector"], + [208, "vector"], + [224, "vector"], + [272, "vector"], + [256, "vector"], + [288, "vector"], + [304, "vector"], + [320, "quaternion"], + [336, "quaternion"], + [352, "vector"], + [448, "vector"], + [464, "vector"], + [480, "vector"], + [496, "quaternion"], + [512, "matrix"], + [576, "vector"], + [592, "matrix"], + [656, "matrix"], + [720, "matrix"] + ], + "joint-mod-look-at-handler": [ + [16, "vector"], + [32, "vector"], + [48, "vector"], + [64, "vector"], + [96, "vector"], + [112, "vector"], + [128, "vector"] + ], + "joint-mod-polar-look-at-guts": [[32, "vector"]], + "joint-mod-world-look-at-handler": [[16, "vector"]], + "joint-mod-joint-set-world-handler": [ + [32, "vector"], + [48, "vector"] + ], + "joint-mod-joint-set*-world-handler": [[16, "matrix"]], + "(method 11 chain-physics)": [ + [16, "matrix"], + [80, "vector"], + [128, "vector"], + [144, "vector"], + [160, "vector"], + [176, "vector"], + [192, "vector"], + [208, "vector"], + [224, "vector"], + [240, "vector"], + [256, "vector"] + ], + "(method 13 gui-control)": [[16, ["array", "sound-id", 4]]], + "ja-play-spooled-anim": [[96, "event-message-block"]] } diff --git a/decompiler/config/jak2/type_casts.jsonc b/decompiler/config/jak2/type_casts.jsonc index 467408e0a4..1ea6847784 100644 --- a/decompiler/config/jak2/type_casts.jsonc +++ b/decompiler/config/jak2/type_casts.jsonc @@ -654,6 +654,11 @@ [[285, 289], "a1", "vector4w"], [[293, 298], "v1", "dma-packet"] ], + "(method 10 history)": [[[8, 10], "a1", "history-elt"]], + "(method 10 history-iterator)": [[[20, 35], "a2", "history-elt"]], + "command-get-time": [[119, "gp", "(pointer float)"]], + "command-get-param": [[122, "gp", "(pointer float)"]], + "command-get-entity": [[10, "gp", "process"]], "print-game-text": [ [225, "v1", "float"], [241, "v1", "float"] @@ -900,6 +905,40 @@ [34, "v1", "texture-id"], [[42, 44], "v1", "adgif-shader"] ], + "joint-mod-ik-callback": [ + [6, "gp", "joint-mod-ik"], + [9, "gp", "joint-mod-ik"], + [[1, 35], "gp", "joint-mod-ik"], + [[1, 433], "gp", "joint-mod-ik"] + ], + "(method 11 joint-mod)": [ + [20, "s0", "fact-info-enemy"], + [12, "s2", "process-drawable"] + ], + "joint-mod-look-at-handler": [[[2, 406], "gp", "joint-mod"]], + "real-joint-mod-gun-look-at-handler": [ + [1, "v1", "joint-mod"], + [2, "v1", "joint-mod"] + ], + "joint-mod-foot-rot-handler": [ + [[0, 7], "s5", "joint-mod"], + [[36, 59], "s5", "joint-mod"], + [[63, 97], "s5", "joint-mod"], + [119, "s5", "joint-mod"], + [[119, 152], "s5", "joint-mod"] + ], + "joint-mod-polar-look-at-guts": [ + [1, "gp", "joint-mod"], + [[1, 334], "gp", "joint-mod"], + [334, "gp", "joint-mod"] + ], + "joint-mod-world-look-at-handler": [[[0, 217], "gp", "joint-mod"]], + "joint-mod-rotate-handler": [[[2, 114], "s5", "joint-mod"]], + "joint-mod-scale-handler": [[[1, 14], "s5", "joint-mod"]], + "joint-mod-joint-set-handler": [[[2, 23], "s4", "joint-mod"]], + "joint-mod-joint-set-world-handler": [[[6, 197], "s5", "joint-mod"]], + "joint-mod-joint-set*-handler": [[[2, 39], "s5", "joint-mod"]], + "joint-mod-joint-set*-world-handler": [[[4, 53], "s5", "joint-mod"]], "glst-find-node-by-name": [ [6, "s5", "glst-named-node"], [7, "v1", "glst-named-node"] @@ -1383,5 +1422,45 @@ [137, "f0", "float"] ], // placeholder - "placeholder-do-not-add-below": [] + "placeholder-do-not-add-below": [], + "drawable-load": [[[25, 28], "s5", "drawable"]], + "art-load": [[[13, 16], "s5", "art"]], + "art-group-load-check": [[[43, 53], "s3", "art-group"]], + "(method 13 art-group)": [[13, "s3", "art-joint-anim"]], + "(method 14 art-group)": [[13, "s3", "art-joint-anim"]], + "(method 13 gui-control)": [ + [[52, 81], "s3", "gui-connection"], + [[202, 228], "a0", "connection"] + ], + "(method 21 gui-control)": [[43, "s2", "process-drawable"]], + "(method 12 gui-control)": [ + [128, "v1", "gui-connection"], + [214, "v1", "gui-connection"], + [167, "s2", "process-drawable"] + ], + "(method 16 gui-control)": [[[10, 119], "s1", "gui-connection"]], + "(method 17 gui-control)": [ + [[1, 262], "gp", "gui-connection"], + [13, "v1", "gui-connection"] + ], + "(method 14 gui-control)": [[[5, 41], "s2", "gui-connection"]], + "(method 15 gui-control)": [[[6, 56], "s1", "gui-connection"]], + "(method 11 external-art-control)": [[19, "s5", "process-drawable"]], + "ja-abort-spooled-anim": [[[3, 24], "s3", "sound-id"]], + "(method 19 gui-control)": [ + [[32, 35], "a2", "gui-channel"], + [113, "a2", "gui-channel"] + ], + "(method 9 gui-control)": [ + [110, "v0", "gui-connection"], + [10, "v1", "gui-connection"], + [17, "v1", "gui-connection"], + [24, "v1", "gui-connection"], + [131, "v1", "gui-connection"], + [35, "v1", "gui-connection"], + [40, "v1", "gui-connection"], + [44, "v1", "gui-connection"], + [14, "v1", "gui-connection"] + ], + "(method 10 gui-control)": [[[4, 32], "s3", "gui-connection"]] } diff --git a/decompiler/config/jak2/var_names.jsonc b/decompiler/config/jak2/var_names.jsonc index b9956bb0b1..2c4759a796 100644 --- a/decompiler/config/jak2/var_names.jsonc +++ b/decompiler/config/jak2/var_names.jsonc @@ -7,19 +7,16 @@ "v1-25": "resource-mem" } }, - "(method 0 lightning-control)": { "vars": { "gp-0": ["obj", "lightning-control"] } }, - "(method 0 align-control)": { "vars": { "v0-0": ["obj", "align-control"] } }, - "(method 16 nav-mesh)": { "args": ["obj", "ray"], "vars": { @@ -220,15 +217,12 @@ "v0-3": ["lightning-sound-id", "sound-id"] } }, - "(method 10 mood-control)": { "args": ["obj", "cloud-target", "fog-target", "cloud-speed", "fog-speed"] }, - "(method 11 mood-control)": { "args": ["obj", "min-cloud", "max-cloud", "min-fog", "max-fog"] }, - "copy-mood-exterior": { "vars": { "a1-4": ["a1-4", "(inline-array vector)"], @@ -236,19 +230,16 @@ "a0-2": ["a0-2", "(inline-array vector)"] } }, - "update-mood-strip": { "vars": { "s4-1": ["s4-1", "(pointer float)"] } }, - "update-mood-ruins": { "vars": { "gp-1": ["gp-1", "(pointer float)"] } }, - "desaturate-mood-colors": { "vars": { "a0-8": ["mood-colors", "(inline-array mood-color)"] @@ -259,19 +250,15 @@ "v1-2": "current-gun" } }, - "(method 10 cylinder)": { "args": ["obj", "ray1", "ray2"] }, - "ripple-make-request": { "args": ["waveform", "effect"] }, - "command-get-entity": { "args": ["search", "fallback"] }, - "(method 10 cam-setting-data)": { "vars": { "v1-5": ["v1-5", "handle"], @@ -282,13 +269,11 @@ "v1-112": ["v1-112", "handle"] } }, - "(method 17 setting-control)": { "vars": { "v1-84": ["v1-84", "task-mask"] } }, - "(method 18 setting-control)": { "vars": { "a0-147": ["a0-147", "process-focusable"] diff --git a/decompiler/config/jak2_ntsc_v1.jsonc b/decompiler/config/jak2_ntsc_v1.jsonc index 0f56c255b9..cca07de9e1 100644 --- a/decompiler/config/jak2_ntsc_v1.jsonc +++ b/decompiler/config/jak2_ntsc_v1.jsonc @@ -92,7 +92,7 @@ // optional: a predetermined object file name map from a file. // this will make decompilation naming consistent even if you only run on some objects. - // "obj_file_name_map_file": "goal_src/jak2/build/all_objs.json", + "obj_file_name_map_file": "goal_src/jak2/build/all_objs.json", //////////////////////////// // LEVEL EXTRACTION diff --git a/decompiler/util/DecompilerTypeSystem.cpp b/decompiler/util/DecompilerTypeSystem.cpp index 9f18c8fb1a..d830dc02f6 100644 --- a/decompiler/util/DecompilerTypeSystem.cpp +++ b/decompiler/util/DecompilerTypeSystem.cpp @@ -421,8 +421,8 @@ int DecompilerTypeSystem::get_format_arg_count(const std::string& str) const { } static const std::vector single_char_ignore_list = {'%', 'T'}; - static const std::vector multi_char_ignore_list = {"0L", "1L", "3L", "1K", "2j", - "0k", "30L", "1T", "2T"}; + static const std::vector multi_char_ignore_list = { + "0L", "1L", "3L", "1k", "1K", "2j", "0k", "0K", "30L", "1T", "2T"}; int arg_count = 0; for (size_t i = 0; i < str.length(); i++) { diff --git a/decompiler/util/data_decompile.cpp b/decompiler/util/data_decompile.cpp index 64669e9827..f83fe9c293 100644 --- a/decompiler/util/data_decompile.cpp +++ b/decompiler/util/data_decompile.cpp @@ -756,7 +756,8 @@ goos::Object decompile_structure(const TypeSpec& type, const LinkedObjectFile* file, bool use_fancy_macros) { // some structures we want to decompile to fancy macros instead of a raw static definiton - if (use_fancy_macros) { + // temp hack!! + if (use_fancy_macros && file && file->version == GameVersion::Jak1) { if (type == TypeSpec("sp-field-init-spec")) { ASSERT(file->version == GameVersion::Jak1); // need to update enums return decompile_sparticle_field_init(type, label, labels, words, ts, file); diff --git a/goal_src/jak1/kernel-defs.gc b/goal_src/jak1/kernel-defs.gc index 7895cd0acb..963701247d 100644 --- a/goal_src/jak1/kernel-defs.gc +++ b/goal_src/jak1/kernel-defs.gc @@ -53,7 +53,7 @@ (define-extern process-level-heap kheap) ;; not a kheap at boot (define-extern stack symbol) (define-extern scratch symbol) -(define-extern *stratch-top* pointer) +(define-extern *scratch-top* pointer) (define-extern zero-func (function int)) ;; asize-of-basic-func - has a bug ;; copy-basic-func - has a bug diff --git a/goal_src/jak2/engine/ambient/ambient-h.gc b/goal_src/jak2/engine/ambient/ambient-h.gc index 754113b7bf..d4f2c9123f 100644 --- a/goal_src/jak2/engine/ambient/ambient-h.gc +++ b/goal_src/jak2/engine/ambient/ambient-h.gc @@ -991,6 +991,7 @@ ) ) +(define-extern talker-surpress! (function none)) diff --git a/goal_src/jak2/engine/anim/joint-h.gc b/goal_src/jak2/engine/anim/joint-h.gc index 2c45faec38..ed3405d622 100644 --- a/goal_src/jak2/engine/anim/joint-h.gc +++ b/goal_src/jak2/engine/anim/joint-h.gc @@ -52,6 +52,7 @@ :flag-assert #x900000040 ) + (deftype top-anim-joint-control (basic) ((process uint32 :offset-assert 4) (interp-select uint64 2 :offset-assert 8) @@ -84,6 +85,7 @@ ) ) + (deftype joint-control (basic) ((status joint-control-status :offset-assert 4) (allocated-length uint8 :offset-assert 6) @@ -137,6 +139,7 @@ :flag-assert #x900000018 ) + (deftype joint-work (structure) ((temp-mtx matrix :inline :offset-assert 0) (joint-stack matrix-stack :inline :offset-assert 64) @@ -157,3 +160,10 @@ :size-assert #x3640 :flag-assert #x900003640 ) + + +0 + + + + diff --git a/goal_src/jak2/engine/anim/joint-mod-h.gc b/goal_src/jak2/engine/anim/joint-mod-h.gc index 35e962d582..139669c696 100644 --- a/goal_src/jak2/engine/anim/joint-mod-h.gc +++ b/goal_src/jak2/engine/anim/joint-mod-h.gc @@ -5,17 +5,38 @@ ;; name in dgo: joint-mod-h ;; dgos: ENGINE, GAME +(defenum joint-mod-blend-flags + :bitfield #t + :type uint32 + (trans) + (scale) + (rotation) + ) + (defenum joint-mod-mode - :bitfield #t - :type uint32 - (flex-blend 0) ;; 1 - (look-at 1) ;; 2 - (world-look-at 2) ;; 4 - (rotate 3) ;; 8 - (joint-set 4) ;; 16 - (joint-set* 5) ;; 32 - ;; ?? ;; 64 - (reset 7) ;; 128 + :bitfield #t + :type uint32 + (flex-blend) + (look-at) + (world-look-at) + (rotate) + (joint-set) + (joint-set*) + (rotate2) ;; ?? + (reset) + (polar-look-at) + (joint-set*-world) + (gun-look-at) + (foot-rot) + (joint-set-world) + ) + +(defenum joint-mod-ik-flags + :bitfield #t + :type uint32 + (enable) + (elbow-trans-neg) + (elbow-rot-neg) ) ;; +++track-mode @@ -39,56 +60,56 @@ ;; DECOMP BEGINS (deftype joint-mod (basic) - ((mode joint-mod-mode :offset-assert 4) - (process process :offset-assert 8) - (joint cspace :offset-assert 12) - (target vector :inline :offset 16) - (twist vector :inline :offset 32) - (twist-max float 4 :offset-assert 48) - (extra-twist degrees :offset 40) - (track-mode track-mode :offset 44) - (loock-at-count uint16 :offset 46) - (twist-range-x meters :offset 56) - (twist-range-y meters :offset 60) - (twist-speed-x float :offset 64) - (twist-speed-y float :offset 68) - (twist-min-x float :offset 72) - (twist-min-y float :offset 76) - (trans vector :inline :offset-assert 80) - (shmushy-old float :offset 80) - (smushy-off float :offset 84) - (smushyv float :offset 88) - (quat quaternion :inline :offset-assert 96) - (scale vector :inline :offset-assert 112) - (notice-time time-frame :offset-assert 128) - (flex-blend float :offset-assert 136) - (blend float :offset-assert 140) - (max-dist meters :offset-assert 144) - (ignore-angle degrees :offset-assert 148) - (up uint8 :offset-assert 152) - (nose uint8 :offset-assert 153) - (ear uint8 :offset-assert 154) - (base-joint uint8 :offset-assert 155) - (base-nose uint8 :offset-assert 156) - (shutting-down? symbol :offset-assert 160) - (parented-scale? symbol :offset-assert 164) - (polar-internal-tilt-max float :offset-assert 168) - (polar-internal-radius float :offset-assert 172) - (polar-external-tilt-max float :offset-assert 176) - (polar-external-radius float :offset-assert 180) + ((mode joint-mod-mode :offset-assert 4) + (process process-drawable :offset-assert 8) + (joint cspace :offset-assert 12) + (target vector :inline :offset-assert 16) + (twist vector :inline :offset-assert 32) + (twist-max vector :inline :offset-assert 48) + (extra-twist degrees :offset 40) + (track-mode track-mode :offset 44) + (loock-at-count uint16 :offset 46) + (twist-range-x meters :offset 56) + (twist-range-y meters :offset 60) + (twist-speed-x float :offset 64) + (twist-speed-y float :offset 68) + (twist-min-x float :offset 72) + (twist-min-y float :offset 76) + (trans vector :inline :offset-assert 80) + (shmushy-old float :offset 80) + (smushy-off float :offset 84) + (smushyv float :offset 88) + (quat quaternion :inline :offset-assert 96) + (scale vector :inline :offset-assert 112) + (notice-time time-frame :offset-assert 128) + (flex-blend float :offset-assert 136) + (blend float :offset-assert 140) + (max-dist meters :offset-assert 144) + (ignore-angle degrees :offset-assert 148) + (up uint8 :offset-assert 152) + (nose uint8 :offset-assert 153) + (ear uint8 :offset-assert 154) + (base-joint uint8 :offset-assert 155) + (base-nose uint8 :offset-assert 156) + (shutting-down? symbol :offset-assert 160) + (parented-scale? symbol :offset-assert 164) + (polar-internal-tilt-max float :offset-assert 168) + (polar-internal-radius float :offset-assert 172) + (polar-external-tilt-max float :offset-assert 176) + (polar-external-radius float :offset-assert 180) ) :method-count-assert 16 :size-assert #xb8 :flag-assert #x10000000b8 (:methods (new (symbol type joint-mod-mode process-drawable int) _type_ 0) - (joint-mod-method-9 () none 9) - (joint-mod-method-10 () none 10) - (joint-mod-method-11 () none 11) + (mode-set! (_type_ joint-mod-mode) none 9) + (target-set! (_type_ vector) none 10) + (look-at! (_type_ vector symbol process) none :behavior process 11) (reset-blend! (_type_) _type_ 12) - (joint-mod-method-13 () none 13) - (joint-mod-method-14 () none 14) - (joint-mod-method-15 () none 15) + (twist-set! (_type_ float float float) vector 13) + (trs-set! (_type_ vector quaternion vector) none 14) + (shut-down (_type_) none 15) ) ) @@ -447,12 +468,12 @@ ) (deftype joint-mod-blend-world (basic) - ((transform transformq :inline :offset-assert 16) - (blend-transform transformq :inline :offset-assert 64) - (blend-flags uint32 :offset-assert 112) - (node-index int32 :offset-assert 116) - (blend float :offset-assert 120) - (enable symbol :offset-assert 124) + ((transform transformq :inline :offset-assert 16) + (blend-transform transformq :inline :offset-assert 64) + (blend-flags joint-mod-blend-flags :offset-assert 112) + (node-index int32 :offset-assert 116) + (blend float :offset-assert 120) + (enable symbol :offset-assert 124) ) :method-count-assert 9 :size-assert #x80 @@ -473,17 +494,17 @@ (let ((gp-0 (the-as joint-mod-blend-world (-> arg0 param1)))) (cond ((-> gp-0 enable) - (let ((f30-0 (if (logtest? (-> gp-0 blend-flags) 1) + (let ((f30-0 (if (logtest? (-> gp-0 blend-flags) (joint-mod-blend-flags trans)) (-> gp-0 blend) 0.0 ) ) - (f28-0 (if (logtest? (-> gp-0 blend-flags) 2) + (f28-0 (if (logtest? (-> gp-0 blend-flags) (joint-mod-blend-flags scale)) (-> gp-0 blend) 0.0 ) ) - (f26-0 (if (logtest? (-> gp-0 blend-flags) 4) + (f26-0 (if (logtest? (-> gp-0 blend-flags) (joint-mod-blend-flags rotation)) (-> gp-0 blend) 0.0 ) @@ -593,28 +614,29 @@ ) (deftype joint-mod-ik (basic) - ((flags uint32 :offset-assert 4) - (process basic :offset-assert 8) - (hand-dist float :offset-assert 12) - (handle-pos vector :inline :offset-assert 16) - (elbow-pole-vector-axis uint32 :offset-assert 32) - (elbow-rotation-axis uint32 :offset-assert 36) - (user-position vector :inline :offset-assert 48) - (user-normal vector :inline :offset-assert 64) - (user-blend float :offset-assert 80) - (user-float float :offset-assert 84) - (callback basic :offset-assert 88) - (shoulder-matrix-no-ik matrix :inline :offset-assert 96) - (elbow-matrix-no-ik matrix :inline :offset-assert 160) - (blend float :offset-assert 224) - (blend-interp float :offset-assert 228) + ((flags joint-mod-ik-flags :offset-assert 4) + (process process-drawable :offset-assert 8) + (hand-dist float :offset-assert 12) + (handle-pos vector :inline :offset-assert 16) + (elbow-pole-vector-axis uint32 :offset-assert 32) + (elbow-rotation-axis uint32 :offset-assert 36) + (user-position vector :inline :offset-assert 48) + (user-normal vector :inline :offset-assert 64) + (user-blend float :offset-assert 80) + (user-float float :offset-assert 84) + (callback (function joint-mod-ik matrix matrix vector object) :offset-assert 88) + (shoulder-matrix-no-ik matrix :inline :offset-assert 96) + (elbow-matrix-no-ik matrix :inline :offset-assert 160) + (blend float :offset-assert 224) + (blend-interp float :offset-assert 228) ) :method-count-assert 11 :size-assert #xe8 :flag-assert #xb000000e8 (:methods - (joint-mod-ik-method-9 () none 9) - (joint-mod-ik-method-10 () none 10) + (new (symbol type process-drawable int float) _type_ 0) + (handle-copy! (_type_ vector) none 9) + (enable-set! (_type_ symbol) none 10) ) ) diff --git a/goal_src/jak2/engine/anim/joint-mod.gc b/goal_src/jak2/engine/anim/joint-mod.gc index c374c52646..b3cd35c927 100644 --- a/goal_src/jak2/engine/anim/joint-mod.gc +++ b/goal_src/jak2/engine/anim/joint-mod.gc @@ -5,5 +5,1486 @@ ;; name in dgo: joint-mod ;; dgos: ENGINE, GAME +(define-extern real-joint-mod-gun-look-at-handler (function cspace transformq none :behavior process)) +(define-extern joint-mod-gun-look-at-handler (function cspace transformq none :behavior process)) +(define-extern joint-mod-foot-rot-handler (function cspace transformq none :behavior process)) +(define-extern joint-mod-look-at-handler (function cspace transformq none :behavior process)) +(define-extern joint-mod-polar-look-at-handler (function cspace transformq none :behavior process)) +(define-extern joint-mod-world-look-at-handler (function cspace transformq none :behavior process)) +(define-extern joint-mod-rotate-handler (function cspace transformq none :behavior process)) +(define-extern joint-mod-scale-handler (function cspace transformq none :behavior process)) +(define-extern joint-mod-joint-set-handler (function cspace transformq none :behavior process)) +(define-extern joint-mod-joint-set-world-handler (function cspace transformq none :behavior process)) +(define-extern joint-mod-joint-set*-handler (function cspace transformq none :behavior process)) +(define-extern joint-mod-joint-set*-world-handler (function cspace transformq none :behavior process)) + ;; DECOMP BEGINS +;; WARN: Function joint-mod-ik-callback has a return type of none, but the expression builder found a return statement. +;; ERROR: Unsupported inline assembly instruction kind - [mula.s f0, f3] +;; ERROR: Unsupported inline assembly instruction kind - [madda.s f1, f4] +;; ERROR: Unsupported inline assembly instruction kind - [madd.s f0, f2, f5] +(defbehavior joint-mod-ik-callback process ((arg0 cspace) (arg1 transformq)) + (local-vars + (f0-24 float) + (sv-736 vector) + (sv-752 vector) + (sv-768 vector) + (sv-784 vector) + (sv-800 (function quaternion vector vector quaternion)) + (sv-816 quaternion) + (sv-832 vector) + (sv-848 vector) + (sv-864 vector) + (sv-880 vector) + (sv-896 vector) + (sv-912 quaternion) + (sv-928 quaternion) + ) + (rlet ((acc :class vf) + (vf0 :class vf) + (vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + (vf7 :class vf) + ) + (init-vf0-vector) + (let ((gp-0 (the-as joint-mod-ik (-> arg0 param1)))) + (-> arg0 param2) + (cspace<-parented-transformq-joint! arg0 arg1) + (cond + ((logtest? (-> gp-0 flags) (joint-mod-ik-flags enable)) + (+! (-> gp-0 blend) (* 4.0 (-> self clock seconds-per-frame))) + (if (< 1.0 (-> gp-0 blend)) + (set! (-> gp-0 blend) 1.0) + ) + ) + (else + (set! (-> gp-0 blend) (- (-> gp-0 blend) (* 4.0 (-> self clock seconds-per-frame)))) + (if (< (-> gp-0 blend) 0.0) + (set! (-> gp-0 blend) 0.0) + ) + ) + ) + (if (= (-> gp-0 blend) 0.0) + (return #f) + ) + (let ((s5-0 (-> arg0 parent bone transform)) + (s4-1 (-> arg0 bone transform)) + ) + (new 'stack-no-clear 'matrix) + (new 'stack-no-clear 'matrix) + (let ((s3-0 (new 'stack-no-clear 'vector))) + (matrix->trans s5-0 s3-0) + (set! (-> s5-0 trans quad) (-> s3-0 quad)) + (matrix->trans s4-1 s3-0) + (set! (-> s4-1 trans quad) (-> s3-0 quad)) + ) + (let* ((a2-0 (-> gp-0 shoulder-matrix-no-ik)) + (a3-0 s5-0) + (v1-22 (-> a3-0 vector 0 quad)) + (a0-7 (-> a3-0 vector 1 quad)) + (a1-3 (-> a3-0 vector 2 quad)) + (a3-1 (-> a3-0 trans quad)) + ) + (set! (-> a2-0 vector 0 quad) v1-22) + (set! (-> a2-0 vector 1 quad) a0-7) + (set! (-> a2-0 vector 2 quad) a1-3) + (set! (-> a2-0 trans quad) a3-1) + ) + (let* ((a2-1 (-> gp-0 elbow-matrix-no-ik)) + (a3-2 s4-1) + (v1-23 (-> a3-2 vector 0 quad)) + (a0-8 (-> a3-2 vector 1 quad)) + (a1-4 (-> a3-2 vector 2 quad)) + (a3-3 (-> a3-2 trans quad)) + ) + (set! (-> a2-1 vector 0 quad) v1-23) + (set! (-> a2-1 vector 1 quad) a0-8) + (set! (-> a2-1 vector 2 quad) a1-4) + (set! (-> a2-1 trans quad) a3-3) + ) + (set! sv-752 (new 'stack-no-clear 'vector)) + (set! sv-736 (new 'stack-no-clear 'vector)) + (let ((s0-0 (new 'stack-no-clear 'vector)) + (s1-0 (new 'stack-no-clear 'vector)) + (s3-1 (new 'stack-no-clear 'vector)) + ) + 0.0 + 0.0 + (set! (-> sv-752 quad) (-> s5-0 trans quad)) + (set! (-> sv-736 quad) (-> s4-1 trans quad)) + (let ((a1-5 s0-0)) + (let ((v1-28 sv-736)) + (let ((a0-13 (-> s4-1 vector 1))) + (let ((a2-2 (-> gp-0 hand-dist))) + (.mov vf7 a2-2) + ) + (.lvf vf5 (&-> a0-13 quad)) + ) + (.lvf vf4 (&-> v1-28 quad)) + ) + (.add.x.vf vf6 vf0 vf0 :mask #b1000) + (.mul.x.vf acc vf5 vf7 :mask #b111) + (.add.mul.w.vf vf6 vf4 vf0 acc :mask #b111) + (.svf (&-> a1-5 quad) vf6) + ) + (if (-> gp-0 callback) + ((-> gp-0 callback) gp-0 s5-0 s4-1 s0-0) + ) + (set! (-> s1-0 quad) (-> gp-0 handle-pos quad)) + (let ((f30-0 (vector-vector-distance sv-752 sv-736)) + (f0-12 (vector-vector-distance sv-736 s0-0)) + (s2-1 (vector-! (new 'stack-no-clear 'vector) s1-0 sv-752)) + ) + (vector-length s2-1) + (+ -4.096 f0-12 f30-0) + (let ((f0-15 (+ 4.096 (fabs (- f30-0 f0-12))))) + (cond + ((< f0-15 f0-15) + (vector-normalize! s2-1 f0-15) + (vector+! s1-0 sv-752 s2-1) + ) + ((< f0-15 f0-15) + (vector-normalize! s2-1 f0-15) + (vector+! s1-0 sv-752 s2-1) + ) + ) + ) + ) + (let ((s2-3 (vector-! (new 'stack-no-clear 'vector) sv-736 sv-752))) + (set! sv-784 (new 'stack-no-clear 'vector)) + (.lvf vf4 (&-> s0-0 quad)) + (.lvf vf5 (&-> sv-736 quad)) + (.mov.vf vf6 vf0 :mask #b1000) + (.sub.vf vf6 vf4 vf5 :mask #b111) + (.svf (&-> sv-784 quad) vf6) + (set! sv-832 (new 'stack-no-clear 'vector)) + (let ((v1-49 sv-752)) + (.lvf vf4 (&-> s0-0 quad)) + (.lvf vf5 (&-> v1-49 quad)) + ) + (.mov.vf vf6 vf0 :mask #b1000) + (.sub.vf vf6 vf4 vf5 :mask #b111) + (.svf (&-> sv-832 quad) vf6) + (let ((s0-1 (new 'stack-no-clear 'vector))) + (.lvf vf4 (&-> s1-0 quad)) + (.lvf vf5 (&-> sv-752 quad)) + (.mov.vf vf6 vf0 :mask #b1000) + (.sub.vf vf6 vf4 vf5 :mask #b111) + (.svf (&-> s0-1 quad) vf6) + (set! sv-928 (new 'stack-no-clear 'quaternion)) + (let ((s1-1 (new 'stack-no-clear 'quaternion))) + (let ((f26-0 (vector-length s2-3)) + (f24-0 (vector-length sv-784)) + (f30-1 (vector-length s0-1)) + ) + (set! sv-768 (new 'stack-no-clear 'vector)) + (let* ((f28-0 (vector-vector-angle-safe s2-3 sv-784)) + (f0-17 (fmax -1.0 (fmin 1.0 (/ (- (- (* f30-1 f30-1) (* f26-0 f26-0)) (* f24-0 f24-0)) (* 2.0 f24-0 f26-0))))) + (f26-1 (acos f0-17)) + ) + (cond + ((= f28-0 0.0) + (set! (-> sv-768 quad) (-> s4-1 vector (-> gp-0 elbow-rotation-axis) quad)) + (when (logtest? (-> gp-0 flags) (joint-mod-ik-flags elbow-rot-neg)) + (vector-negate! sv-768 sv-768) + (set! f26-1 (- f26-1)) + ) + (set! (-> s3-1 quad) (-> s4-1 vector (-> gp-0 elbow-pole-vector-axis) quad)) + (if (logtest? (-> gp-0 flags) (joint-mod-ik-flags elbow-trans-neg)) + (vector-negate! s3-1 s3-1) + ) + ) + (else + (vector-cross! sv-768 s2-3 sv-784) + (vector-! + s3-1 + s2-3 + (the-as + vector + (vector-float*! (new 'stack-no-clear 'vector) sv-832 (/ (vector-dot sv-832 s2-3) (vector-dot sv-832 sv-832))) + ) + ) + ) + ) + (vector-normalize! s3-1 1.0) + (vector-normalize! sv-768 1.0) + (let ((t9-14 quaternion-vector-angle!) + (a0-44 sv-928) + (a2-5 (- f26-1 f28-0)) + ) + (t9-14 a0-44 sv-768 a2-5) + ) + ) + (vector-orient-by-quat! sv-784 sv-784 sv-928) + (let ((v1-74 sv-832)) + (let ((a0-46 s2-3)) + (.mov.vf vf6 vf0 :mask #b1000) + (.lvf vf4 (&-> a0-46 quad)) + ) + (.lvf vf5 (&-> sv-784 quad)) + (.add.vf vf6 vf4 vf5 :mask #b111) + (.svf (&-> v1-74 quad) vf6) + ) + (set! sv-800 quaternion-from-two-vectors!) + (set! sv-816 s1-1) + (let ((t9-16 vector-normalize-copy!) + (a0-48 (new 'stack-no-clear 'vector)) + (a2-7 1.0) + ) + (set! sv-848 (t9-16 a0-48 sv-832 a2-7)) + ) + (let ((a2-9 (vector-normalize-copy! (new 'stack-no-clear 'vector) s0-1 1.0))) + (sv-800 sv-816 sv-848 a2-9) + ) + (vector-orient-by-quat! s2-3 s2-3 s1-1) + (let ((f0-26 (fabs (vector-dot (vector-normalize-copy! (new 'stack-no-clear 'vector) s2-3 1.0) + (vector-normalize-copy! (new 'stack-no-clear 'vector) s0-1 1.0))))) + (if (< 0.98 f0-26) + (vector-orient-by-quat! s2-3 s3-1 s1-1) + ) + ) + (set! sv-880 (new 'stack-no-clear 'vector)) + (set! sv-896 (new 'stack-no-clear 'vector)) + (new 'stack-no-clear 'vector) + (* f30-1 f30-1) + ) + (set! sv-912 (new 'stack-no-clear 'quaternion)) + (vector-flatten! sv-880 s2-3 s0-1) + (vector-flatten! sv-896 s3-1 s0-1) + (vector-normalize! sv-880 1.0) + (vector-normalize! sv-896 1.0) + (quaternion-from-two-vectors! sv-912 sv-880 sv-896) + (let ((t9-28 quaternion*!) + (a0-63 s1-1) + (a2-17 s1-1) + ) + (t9-28 a0-63 sv-912 a2-17) + ) + (quaternion-pseudo-slerp! sv-928 *unity-quaternion* sv-928 (-> gp-0 blend)) + (quaternion-pseudo-slerp! s1-1 *unity-quaternion* s1-1 (-> gp-0 blend)) + (let ((a2-20 (quaternion->matrix (new 'stack-no-clear 'matrix) sv-928)) + (gp-1 (new 'stack-no-clear 'vector)) + ) + (set! (-> gp-1 quad) (-> s4-1 trans quad)) + (matrix*! s4-1 s4-1 a2-20) + (set! (-> s4-1 trans quad) (-> gp-1 quad)) + ) + (let ((s3-2 (quaternion->matrix (new 'stack-no-clear 'matrix) s1-1)) + (a2-21 (matrix-4x4-inverse! (new 'stack-no-clear 'matrix) s5-0)) + (gp-2 (new 'stack-no-clear 'matrix)) + ) + (set! (-> gp-2 vector 0 quad) (-> s5-0 trans quad)) + (matrix*! s4-1 s4-1 a2-21) + (matrix*! s5-0 s5-0 s3-2) + (set! (-> s5-0 trans quad) (-> gp-2 vector 0 quad)) + ) + ) + ) + ) + ) + (matrix*! s4-1 s4-1 s5-0) + ) + ) + (none) + ) + ) + +(defmethod new joint-mod-ik ((allocation symbol) (type-to-make type) (arg0 process-drawable) (arg1 int) (arg2 float)) + (let ((v0-0 (object-new allocation type-to-make (the-as int (-> type-to-make size))))) + (set! (-> v0-0 process) arg0) + (set! (-> v0-0 hand-dist) arg2) + (set! (-> v0-0 elbow-pole-vector-axis) (the-as uint 0)) + (logclear! (-> v0-0 flags) (joint-mod-ik-flags elbow-trans-neg)) + (set! (-> v0-0 elbow-rotation-axis) (the-as uint 2)) + (logclear! (-> v0-0 flags) (joint-mod-ik-flags elbow-rot-neg)) + (set! (-> v0-0 callback) #f) + (set! (-> v0-0 blend) 0.0) + (logclear! (-> v0-0 flags) (joint-mod-ik-flags enable)) + (let ((a0-5 (-> arg0 node-list data arg1))) + (set! (-> a0-5 param0) joint-mod-ik-callback) + (set! (-> a0-5 param1) v0-0) + (set! (-> a0-5 param2) (the-as basic arg1)) + ) + v0-0 + ) + ) + +(defmethod handle-copy! joint-mod-ik ((obj joint-mod-ik) (arg0 vector)) + (set! (-> obj handle-pos quad) (-> arg0 quad)) + 0 + (none) + ) + +(defmethod enable-set! joint-mod-ik ((obj joint-mod-ik) (arg0 symbol)) + (if arg0 + (logior! (-> obj flags) (joint-mod-ik-flags enable)) + (logclear! (-> obj flags) (joint-mod-ik-flags enable)) + ) + 0 + (none) + ) + +(defbehavior real-joint-mod-gun-look-at-handler process ((arg0 cspace) (arg1 transformq)) + (local-vars + (sv-16 joint-mod) + (sv-64 vector) + (sv-96 quaternion) + (sv-160 vector) + (sv-164 vector) + (sv-168 vector) + (sv-172 symbol) + ) + (rlet ((acc :class vf) + (vf0 :class vf) + (vf1 :class vf) + (vf2 :class vf) + (vf3 :class vf) + (vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + ) + (init-vf0-vector) + (set! sv-16 (the-as joint-mod (-> arg0 param1))) + (let ((a0-1 (-> arg1 scale))) + (let ((v1-1 (-> arg1 scale)) + (a2-1 (-> sv-16 scale)) + ) + (.lvf vf4 (&-> v1-1 quad)) + (.lvf vf5 (&-> a2-1 quad)) + ) + (.add.x.vf vf6 vf0 vf0 :mask #b1000) + (.mul.vf vf6 vf4 vf5 :mask #b111) + (.svf (&-> a0-1 quad) vf6) + ) + (cspace<-parented-transformq-joint! arg0 arg1) + (let ((s5-0 (-> arg0 bone transform))) + (let ((s4-0 (matrix->quat s5-0 (new 'stack-no-clear 'quaternion)))) + (set! sv-64 (matrix->trans s5-0 (new 'stack-no-clear 'vector))) + (quaternion-rotate-y! s4-0 s4-0 (-> sv-16 twist z)) + (set! sv-96 (quaternion-copy! (new 'stack-no-clear 'quaternion) s4-0)) + (when (!= (-> sv-16 flex-blend) 0.0) + (set! sv-160 (vector-y-quaternion! (new 'stack-no-clear 'vector) sv-96)) + (set! sv-164 (vector-z-quaternion! (new 'stack-no-clear 'vector) sv-96)) + (set! sv-168 (vector-normalize! (vector-! (new 'stack-no-clear 'vector) (-> sv-16 target) sv-64) 1.0)) + (set! sv-172 (the-as symbol #f)) + (let* ((f30-0 (vector-y-angle sv-164)) + (a0-13 (vector-flatten! (new 'stack-no-clear 'vector) sv-168 sv-160)) + (f0-2 (vector-y-angle a0-13)) + (f0-3 (deg-diff f30-0 f0-2)) + (f30-1 (* f0-3 (-> sv-16 blend))) + ) + (let ((f28-0 (fmax (fmin f30-1 (-> sv-16 twist-max y)) (- (-> sv-16 twist-max y))))) + (if (or (!= f30-1 f28-0) (= (-> sv-16 blend) 0.0)) + (logclear! (-> sv-16 track-mode) (track-mode lock-on)) + ) + (cond + ((or (< (-> sv-16 ignore-angle) (fabs f0-3)) + (< (-> sv-16 twist-max w) (vector-vector-distance (-> sv-16 target) sv-64)) + ) + (set! f30-1 0.0) + (set! f28-0 0.0) + (set! sv-172 #t) + ) + ((< 5461.3335 (fabs (deg-diff f30-1 f28-0))) + (set! (-> sv-16 blend) 0.0001) + ) + ((< 182.04445 (fabs (deg-diff f30-1 f28-0))) + (logclear! (-> sv-16 track-mode) (track-mode track-x)) + ) + ) + (if (or (and (logtest? (-> sv-16 track-mode) (track-mode track-y)) (= f30-1 f28-0)) + (< (-> sv-16 twist-max y) (fabs (-> sv-16 twist y))) + ) + (set! (-> sv-16 twist y) + (deg-seek (-> sv-16 twist y) f28-0 (* (fabs (deg-diff f28-0 (-> sv-16 twist y))) + (if (logtest? (-> sv-16 track-mode) (track-mode lock-on)) + 1.0 + (-> sv-16 twist-speed-y) + ) + (-> self clock time-adjust-ratio) + ) + ) + ) + ) + ) + (if (and (< (fabs (deg-diff f30-1 (-> sv-16 twist y))) 728.1778) (and (not sv-172) (!= (-> sv-16 blend) 0.0))) + (logior! (-> sv-16 track-mode) (track-mode lock-on)) + ) + ) + (quaternion-rotate-local-y! sv-96 sv-96 (-> sv-16 twist y)) + (let* ((s3-1 (vector-x-quaternion! (new 'stack-no-clear 'vector) sv-96)) + (f30-2 (vector-x-angle sv-164)) + (s3-2 (vector-flatten! (new 'stack-no-clear 'vector) sv-168 s3-1)) + (f0-24 (vector-x-angle s3-2)) + (f30-3 (fmax + (fmin (* (- (deg-diff f30-2 f0-24)) (-> sv-16 blend)) (-> sv-16 twist-max x)) + (- (-> sv-16 twist-max x)) + ) + ) + ) + (if (or (< (vector-dot s3-2 sv-164) 0.1) + (< (-> sv-16 twist-max z) (vector-vector-distance (-> sv-16 target) sv-64)) + ) + (set! f30-3 0.0) + ) + (if (or (logtest? (-> sv-16 track-mode) (track-mode track-x)) + (< (-> sv-16 twist-max x) (fabs (-> sv-16 twist x))) + ) + (set! (-> sv-16 twist x) + (deg-seek (-> sv-16 twist x) f30-3 (* (fabs (deg-diff f30-3 (-> sv-16 twist x))) + (if (logtest? (-> sv-16 track-mode) (track-mode lock-on)) + 1.0 + (-> sv-16 twist-speed-x) + ) + (-> self clock time-adjust-ratio) + ) + ) + ) + ) + ) + (quaternion-rotate-x! sv-96 sv-96 (-> sv-16 twist x)) + (quaternion-normalize! (quaternion*! sv-96 sv-96 (-> sv-16 quat))) + ) + (let ((a1-27 (quaternion-slerp! (new 'stack-no-clear 'quaternion) s4-0 sv-96 (-> sv-16 flex-blend)))) + (matrix<-quat s5-0 a1-27) + ) + ) + (let ((f30-4 (-> sv-16 trans x)) + (s4-1 (-> s5-0 vector 1)) + (v1-97 (vector<-matrix! (new 'stack-no-clear 'vector) s5-0)) + ) + (let ((f0-43 (- f30-4 (-> v1-97 y)))) + (if (< 614.4 (fabs f0-43)) + (+! (-> sv-16 trans z) (* 8.0 f0-43)) + ) + ) + (+! (-> sv-16 trans z) (* -260.0 (-> self clock seconds-per-frame) (-> sv-16 trans y))) + (let ((f0-48 (-> sv-16 trans y))) + (+! (-> sv-16 trans y) (* (-> sv-16 trans z) (-> self clock seconds-per-frame))) + (set! (-> sv-16 trans y) (* 0.95 (-> sv-16 trans y))) + (when (< (* f0-48 (-> sv-16 trans y)) 0.0) + (set! (-> sv-16 trans y) 0.0) + (set! (-> sv-16 trans z) 0.0) + ) + ) + (cond + ((< 409.6 (-> sv-16 trans y)) + (set! (-> sv-16 trans y) 409.6) + (set! (-> sv-16 trans z) 0.0) + ) + ((< (-> sv-16 trans y) -409.6) + (set! (-> sv-16 trans y) -409.6) + (set! (-> sv-16 trans z) 0.0) + ) + ) + (set! (-> sv-16 trans x) (-> v1-97 y)) + (let ((f0-60 (* (-> sv-16 trans y) (-> sv-16 flex-blend)))) + (when (!= f0-60 0.0) + (let ((a0-86 (-> s5-0 trans))) + (.lvf vf2 (&-> s4-1 quad)) + (.lvf vf1 (&-> v1-97 quad)) + (let ((v1-98 f0-60)) + (.mov vf3 v1-98) + ) + (.add.x.vf vf4 vf0 vf0 :mask #b1000) + (.mul.x.vf acc vf2 vf3) + (.add.mul.w.vf vf4 vf1 vf0 acc :mask #b111) + (.svf (&-> a0-86 quad) vf4) + ) + ) + ) + ) + ) + (if (-> sv-16 parented-scale?) + (set-vector! (-> arg0 bone scale) 1.0 1.0 1.0 1.0) + ) + 0 + (none) + ) + ) + +(defbehavior joint-mod-gun-look-at-handler process ((arg0 cspace) (arg1 transformq)) + (real-joint-mod-gun-look-at-handler arg0 arg1) + (none) + ) + +(defbehavior joint-mod-foot-rot-handler process ((arg0 cspace) (arg1 transformq)) + (let ((s5-0 (the-as joint-mod (-> arg0 param1))) + (gp-0 (-> arg0 bone transform)) + ) + (cspace<-parented-transformq-joint! arg0 arg1) + (let ((s3-0 (-> s5-0 target)) + (s4-0 (-> s5-0 twist-max)) + ) + 1.0 + (when (< 8192.0 (vector-vector-angle-safe s3-0 s4-0)) + (let* ((a1-4 (vector-normalize! (vector-cross! (new 'stack-no-clear 'vector) s3-0 s4-0) 1.0)) + (a2-1 (quaternion-vector-angle! (new 'stack-no-clear 'quaternion) a1-4 8192.0)) + ) + (vector-orient-by-quat! s4-0 s3-0 a2-1) + ) + ) + (let* ((f0-4 (/ (vector-dot *up-vector* (-> s5-0 joint bone transform vector 1)) + (vector-length (-> s5-0 joint bone transform vector 1)) + ) + ) + (f30-1 (lerp-scale 0.0 1.0 f0-4 0.85 1.0)) + ) + (vector-deg-slerp (-> s5-0 twist) (-> s5-0 twist) s4-0 0.3) + (set! (-> s4-0 quad) (-> s5-0 twist quad)) + (seek! (-> s5-0 blend) (-> s5-0 flex-blend) (* 4.0 (-> self clock seconds-per-frame))) + (let ((s3-1 (matrix->scale gp-0 (new 'stack-no-clear 'vector)))) + (let ((s2-0 (matrix->quat gp-0 (new 'stack-no-clear 'quaternion))) + (s0-0 (matrix->trans gp-0 (new 'stack-no-clear 'vector))) + ) + (set! (-> gp-0 vector 1 quad) (-> s5-0 twist-max quad)) + (vector-cross! (-> gp-0 vector 2) (the-as vector (-> gp-0 vector)) (-> gp-0 vector 1)) + (vector-cross! (the-as vector (-> gp-0 vector)) (-> gp-0 vector 1) (-> gp-0 vector 2)) + (set! (-> gp-0 vector 0 w) 0.0) + (set! (-> gp-0 vector 1 w) 0.0) + (set! (-> gp-0 vector 2 w) 0.0) + (let ((s1-0 (matrix->quat gp-0 (new 'stack-no-clear 'quaternion)))) + (let* ((f0-14 (vector-dot s4-0 (vector-! (new 'stack-no-clear 'vector) s0-0 (-> s5-0 trans)))) + (f0-15 (lerp-scale 1.0 0.0 f0-14 819.2 2048.0)) + ) + (seek! + (-> s5-0 polar-internal-tilt-max) + (* (-> s5-0 blend) f0-15 f30-1) + (* 15.0 (-> self clock seconds-per-frame)) + ) + ) + (quaternion-slerp! s1-0 s2-0 s1-0 (-> s5-0 polar-internal-tilt-max)) + (matrix<-quat gp-0 s1-0) + ) + ) + (matrix<-scale gp-0 s3-1) + ) + ) + ) + ) + 0 + (none) + ) + +(defmethod new joint-mod ((allocation symbol) (type-to-make type) (arg0 joint-mod-mode) (arg1 process-drawable) (arg2 int)) + (let ((gp-0 (object-new allocation type-to-make (the-as int (-> type-to-make size))))) + (set! (-> gp-0 process) arg1) + (set! (-> gp-0 joint) (-> arg1 node-list data arg2)) + (mode-set! gp-0 arg0) + (set-vector! (-> gp-0 twist-max) 8192.0 11832.889 0.0 1.0) + (set! (-> gp-0 twist-speed-x) 0.1) + (set! (-> gp-0 twist-speed-y) 0.1) + (set! (-> gp-0 twist-min-x) (-> gp-0 twist-max x)) + (set! (-> gp-0 twist-min-y) (-> gp-0 twist-max y)) + (set! (-> gp-0 up) (the-as uint 1)) + (set! (-> gp-0 nose) (the-as uint 2)) + (set! (-> gp-0 ear) (the-as uint 0)) + (set! (-> gp-0 base-joint) (the-as uint arg2)) + (set! (-> gp-0 base-nose) (the-as uint 2)) + (set! (-> gp-0 max-dist) 122880.0) + (set! (-> gp-0 ignore-angle) 65536.0) + (set! (-> gp-0 flex-blend) 1.0) + (set! (-> gp-0 shutting-down?) #f) + (set-vector! (-> gp-0 scale) 1.0 1.0 1.0 1.0) + (set! (-> gp-0 parented-scale?) #f) + (quaternion-identity! (-> gp-0 quat)) + gp-0 + ) + ) + +(defmethod mode-set! joint-mod ((obj joint-mod) (arg0 joint-mod-mode)) + (set! (-> obj mode) arg0) + (let ((v1-0 (-> obj joint))) + (case arg0 + (((joint-mod-mode flex-blend)) + (set! (-> v1-0 param0) #f) + (set! (-> obj blend) 0.0) + (set! (-> obj flex-blend) 1.0) + ) + (((joint-mod-mode reset)) + (set! (-> v1-0 param0) #f) + (set! (-> obj blend) 0.0) + (set! (-> obj shutting-down?) #f) + ) + (((joint-mod-mode look-at)) + (let ((a0-4 v1-0)) + (set! (-> a0-4 param0) joint-mod-look-at-handler) + (set! (-> a0-4 param1) obj) + ) + ) + (((joint-mod-mode gun-look-at)) + (let ((a0-5 v1-0)) + (set! (-> a0-5 param0) joint-mod-gun-look-at-handler) + (set! (-> a0-5 param1) obj) + ) + ) + (((joint-mod-mode foot-rot)) + (set-vector! (-> obj twist) 0.0 1.0 0.0 1.0) + (let ((a0-7 v1-0)) + (set! (-> a0-7 param0) + (lambda ((arg0 cspace) (arg1 transformq)) (joint-mod-foot-rot-handler arg0 arg1) (none)) + ) + (set! (-> a0-7 param1) obj) + ) + ) + (((joint-mod-mode world-look-at)) + (let ((a0-8 v1-0)) + (set! (-> a0-8 param0) joint-mod-world-look-at-handler) + (set! (-> a0-8 param1) obj) + ) + ) + (((joint-mod-mode polar-look-at)) + (let ((a0-9 v1-0)) + (set! (-> a0-9 param0) joint-mod-polar-look-at-handler) + (set! (-> a0-9 param1) obj) + ) + (set! (-> obj polar-internal-tilt-max) 32768.0) + (set! (-> obj polar-internal-radius) 32768.0) + (set! (-> obj polar-external-tilt-max) 32768.0) + (set! (-> obj polar-external-radius) 32768.0) + ) + (((joint-mod-mode rotate)) + (let ((a0-11 v1-0)) + (set! (-> a0-11 param0) joint-mod-rotate-handler) + (set! (-> a0-11 param1) obj) + ) + (set! (-> obj blend) 1.0) + ) + (((joint-mod-mode rotate2)) + (let ((a0-13 v1-0)) + (set! (-> a0-13 param0) joint-mod-rotate-handler) + (set! (-> a0-13 param1) obj) + ) + (set! (-> obj blend) 1.0) + ) + (((joint-mod-mode joint-set)) + (let ((a0-15 v1-0)) + (set! (-> a0-15 param0) joint-mod-joint-set-handler) + (set! (-> a0-15 param1) obj) + ) + (vector-reset! (-> obj trans)) + (quaternion-identity! (-> obj quat)) + (set-vector! (-> obj scale) 1.0 1.0 1.0 1.0) + ) + (((joint-mod-mode joint-set-world)) + (let ((a0-18 v1-0)) + (set! (-> a0-18 param0) joint-mod-joint-set-world-handler) + (set! (-> a0-18 param1) obj) + ) + (vector-reset! (-> obj trans)) + (quaternion-identity! (-> obj quat)) + (set-vector! (-> obj scale) 1.0 1.0 1.0 1.0) + (set! (-> obj flex-blend) 1.0) + ) + (((joint-mod-mode joint-set*)) + (let ((a0-25 v1-0)) + (set! (-> a0-25 param0) joint-mod-joint-set*-handler) + (set! (-> a0-25 param1) obj) + ) + (vector-reset! (-> obj trans)) + (quaternion-identity! (-> obj quat)) + (set-vector! (-> obj scale) 1.0 1.0 1.0 1.0) + ) + (((joint-mod-mode joint-set*-world)) + (let ((a0-29 v1-0)) + (set! (-> a0-29 param0) joint-mod-joint-set*-world-handler) + (set! (-> a0-29 param1) obj) + ) + (vector-reset! (-> obj trans)) + (quaternion-identity! (-> obj quat)) + (set-vector! (-> obj scale) 1.0 1.0 1.0 1.0) + ) + ) + ) + (none) + ) + +(defmethod shut-down joint-mod ((obj joint-mod)) + (set! (-> obj shutting-down?) #t) + (set! (-> obj blend) 0.0) + (none) + ) + +(defmethod twist-set! joint-mod ((obj joint-mod) (arg0 float) (arg1 float) (arg2 float)) + (if arg0 + (set! (-> obj twist x) arg0) + ) + (if arg1 + (set! (-> obj twist y) arg1) + ) + (if arg2 + (set! (-> obj twist z) arg2) + ) + (-> obj twist) + ) + +(defmethod trs-set! joint-mod ((obj joint-mod) (arg0 vector) (arg1 quaternion) (arg2 vector)) + (if arg0 + (set! (-> obj trans quad) (-> arg0 quad)) + ) + (if arg1 + (quaternion-copy! (-> obj quat) arg1) + ) + (if arg2 + (set! (-> obj scale quad) (-> arg2 quad)) + ) + 0 + (none) + ) + +(defmethod target-set! joint-mod ((obj joint-mod) (arg0 vector)) + (if (= (-> obj mode) (joint-mod-mode reset)) + (mode-set! obj (joint-mod-mode look-at)) + ) + (let ((f0-0 (vector-vector-distance (-> obj process root trans) arg0))) + (set! (-> obj shutting-down?) #f) + (set! (-> obj target quad) (-> arg0 quad)) + (if (< f0-0 (-> obj max-dist)) + (set! (-> obj blend) 1.0) + (set! (-> obj blend) 0.0) + ) + ) + 0 + (none) + ) + +(define last-try-to-look-at-data (new 'global 'try-to-look-at-info)) + +(defmethod look-at! joint-mod ((obj joint-mod) (arg0 vector) (arg1 symbol) (arg2 process)) + (when (= arg1 'attacking) + (let* ((s2-0 arg2) + (s1-0 (if (type? s2-0 process-drawable) + (the-as process-drawable s2-0) + ) + ) + ) + (when s1-0 + (let* ((s0-0 (-> s1-0 fact)) + (s2-1 (if (type? s0-0 fact-info-enemy) + (the-as fact-info-enemy s0-0) + ) + ) + ) + (when s2-1 + (when (< (vector-vector-distance (-> obj process root trans) (-> s1-0 root trans)) (-> s2-1 cam-notice-dist)) + (set! (-> obj notice-time) (-> self clock frame-counter)) + (set! (-> last-try-to-look-at-data who) (process->handle arg2)) + (if (< (-> last-try-to-look-at-data vert) (-> s2-1 cam-vert)) + (set! (-> last-try-to-look-at-data vert) (-> s2-1 cam-vert)) + ) + (if (< (-> last-try-to-look-at-data horz) (-> s2-1 cam-horz)) + (set! (-> last-try-to-look-at-data horz) (-> s2-1 cam-horz)) + ) + ) + ) + ) + ) + ) + ) + (let ((f30-0 (vector-vector-distance (-> obj process root trans) arg0))) + (if (logtest? (process-mask enemy) (-> arg2 mask)) + (+! (-> obj loock-at-count) (the int (lerp-scale 256.0 0.0 f30-0 20480.0 204800.0))) + ) + (when (and (or (= (-> obj blend) 0.0) + (or (< f30-0 (vector-vector-distance (-> obj process root trans) (-> obj target))) (= arg1 'force)) + ) + (< f30-0 (-> obj max-dist)) + ) + (if (= (-> obj mode) (joint-mod-mode reset)) + (mode-set! obj (joint-mod-mode look-at)) + ) + (set! (-> obj target quad) (-> arg0 quad)) + (set! (-> obj blend) 1.0) + (set! (-> obj shutting-down?) #f) + ) + ) + 0 + (none) + ) + +;; ERROR: Stack slot load at 176 mismatch: defined as size 4, got size 16 +;; ERROR: Stack slot load at 176 mismatch: defined as size 4, got size 16 +;; ERROR: Stack slot load at 176 mismatch: defined as size 4, got size 16 +;; ERROR: Stack slot load at 176 mismatch: defined as size 4, got size 16 +;; ERROR: Unsupported inline assembly instruction kind - [mula.s f0, f3] +;; ERROR: Unsupported inline assembly instruction kind - [madda.s f1, f4] +;; ERROR: Unsupported inline assembly instruction kind - [madd.s f0, f2, f5] +(defbehavior joint-mod-look-at-handler process ((arg0 cspace) (arg1 transformq)) + (local-vars (f0-1 float) (sv-80 symbol) (sv-144 vector) (sv-160 vector) (sv-176 float)) + (rlet ((vf0 :class vf) + (vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + ) + (init-vf0-vector) + (let ((gp-0 (the-as joint-mod (-> arg0 param1)))) + (cspace<-parented-transformq-joint! arg0 arg1) + (let ((s1-0 (vector-normalize-copy! + (new 'stack-no-clear 'vector) + (-> gp-0 process node-list data 0 bone transform vector 1) + 1.0 + ) + ) + (s2-0 (matrix->trans (-> arg0 bone transform) (new 'stack-no-clear 'vector))) + (s3-0 (vector-normalize! (-> arg0 bone transform vector (-> gp-0 nose)) 1.0)) + (s0-0 (vector-normalize! (-> arg0 bone transform vector (-> gp-0 ear)) 1.0)) + ) + (set! sv-144 (vector-normalize! + (vector-cross! + (new 'stack-no-clear 'vector) + (-> arg0 bone transform vector (-> gp-0 up)) + (-> arg0 bone transform vector (-> gp-0 nose)) + ) + 1.0 + ) + ) + (let ((s2-1 (vector-normalize! (vector-! (new 'stack-no-clear 'vector) (-> gp-0 target) s2-0) 1.0))) + (set! sv-160 (-> gp-0 process node-list data (-> gp-0 base-joint) bone transform vector (-> gp-0 base-nose))) + (set! sv-80 (the-as symbol #f)) + (if (< (vector-dot sv-144 s0-0) 0.0) + (set! sv-80 #t) + ) + (let* ((f30-0 (vector-y-angle s3-0)) + (a0-18 (vector-flatten! (new-stack-vector0) s2-1 s1-0)) + (f0-3 (vector-y-angle a0-18)) + (f30-1 (deg-diff f30-0 f0-3)) + (f0-4 (if (= (-> gp-0 base-joint) (+ (-> arg0 joint number) 1)) + 0.0 + (deg-diff (vector-y-angle s3-0) (vector-y-angle sv-160)) + ) + ) + ) + (if (< (-> gp-0 ignore-angle) (fabs f30-1)) + (set! f30-1 0.0) + ) + (let ((f30-2 + (fmax + (fmin (* f30-1 (-> gp-0 blend) (-> gp-0 flex-blend)) (+ (-> gp-0 twist-max y) (* f0-4 (-> gp-0 flex-blend)))) + (+ (- (-> gp-0 twist-max y)) (* f0-4 (-> gp-0 flex-blend))) + ) + ) + ) + (when (and (-> gp-0 shutting-down?) (< (fabs (- (-> gp-0 twist y) f30-2)) 18.204445)) + (if (and (= (-> gp-0 scale x) 1.0) (= (-> gp-0 scale y) 1.0) (= (-> gp-0 scale z) 1.0)) + (mode-set! gp-0 (joint-mod-mode reset)) + (mode-set! gp-0 (joint-mod-mode rotate2)) + ) + ) + (let ((s1-2 deg-seek) + (s0-2 (-> gp-0 twist y)) + ) + (set! sv-176 f30-2) + (let ((a2-3 (* (fabs (deg-diff f30-2 (-> gp-0 twist y))) (-> gp-0 twist-speed-y) (-> self clock time-adjust-ratio))) + ) + (set! (-> gp-0 twist y) (s1-2 s0-2 sv-176 a2-3)) + ) + ) + ) + ) + 0.0 + (let ((f0-25 (if sv-80 + (- (-> gp-0 twist y)) + (-> gp-0 twist y) + ) + ) + (v1-49 (-> gp-0 up)) + ) + (cond + ((zero? v1-49) + (quaternion-rotate-x! (-> arg1 quat) (-> arg1 quat) f0-25) + ) + ((= v1-49 1) + (quaternion-rotate-local-y! (-> arg1 quat) (-> arg1 quat) f0-25) + ) + (else + (quaternion-rotate-z! (-> arg1 quat) (-> arg1 quat) f0-25) + ) + ) + ) + (let* ((s1-3 + (vector-normalize-copy! + (new 'stack-no-clear 'vector) + (the-as vector (-> gp-0 process node-list data 0 bone transform)) + 1.0 + ) + ) + (f30-3 (vector-x-angle s3-0)) + (s2-2 (vector-flatten! (new-stack-vector0) s2-1 s1-3)) + (f0-26 (vector-x-angle s2-2)) + (f0-32 + (fmax + (fmin (* (- (deg-diff f30-3 f0-26)) (-> gp-0 blend) (-> gp-0 flex-blend)) (-> gp-0 twist-max x)) + (- (-> gp-0 twist-max x)) + ) + ) + ) + (if (< (vector-dot s2-2 s3-0) 0.1) + (set! f0-32 0.0) + ) + (set! (-> gp-0 twist x) + (deg-seek + (-> gp-0 twist x) + f0-32 + (* (fabs (deg-diff f0-32 (-> gp-0 twist x))) (-> gp-0 twist-speed-x) (-> self clock time-adjust-ratio)) + ) + ) + ) + ) + ) + (let ((v1-60 (-> gp-0 ear))) + (cond + ((zero? v1-60) + (quaternion-rotate-x! (-> arg1 quat) (-> arg1 quat) (-> gp-0 twist x)) + ) + ((= v1-60 1) + (quaternion-rotate-local-y! (-> arg1 quat) (-> arg1 quat) (-> gp-0 twist x)) + ) + (else + (quaternion-rotate-z! (-> arg1 quat) (-> arg1 quat) (-> gp-0 twist x)) + ) + ) + ) + (vector+! (-> arg1 trans) (-> arg1 trans) (-> gp-0 trans)) + (quaternion-normalize! (quaternion*! (-> arg1 quat) (-> arg1 quat) (-> gp-0 quat))) + (let ((a1-36 (-> arg1 scale))) + (let ((v1-63 (-> arg1 scale)) + (a0-46 (-> gp-0 scale)) + ) + (.lvf vf4 (&-> v1-63 quad)) + (.lvf vf5 (&-> a0-46 quad)) + ) + (.add.x.vf vf6 vf0 vf0 :mask #b1000) + (.mul.vf vf6 vf4 vf5 :mask #b111) + (.svf (&-> a1-36 quad) vf6) + ) + (cspace<-parented-transformq-joint! arg0 arg1) + (if (-> gp-0 parented-scale?) + (set-vector! (-> arg0 bone scale) 1.0 1.0 1.0 1.0) + ) + (if (and (= (-> gp-0 process type) target) (!= (-> gp-0 blend) 0.0)) + (add-debug-text-sphere + *display-target-marks* + (bucket-id bucket-318) + (-> gp-0 target) + 819.2 + "look" + (new 'static 'rgba :r #xff :g #xff :a #x80) + ) + ) + ) + 0 + (none) + ) + ) + +(defbehavior joint-mod-polar-look-at-guts process ((arg0 cspace) (arg1 transformq)) + (let ((gp-0 (the-as joint-mod (-> arg0 param1)))) + (cspace<-parented-transformq-joint! arg0 arg1) + (let ((s3-0 (vector-normalize-copy! (new 'stack-no-clear 'vector) (-> arg0 bone transform vector 2) 1.0)) + (s1-0 (vector-normalize! + (vector-! (new 'stack-no-clear 'vector) (-> gp-0 target) (-> arg0 bone transform trans)) + 1.0 + ) + ) + (s4-0 (new 'stack-no-clear 'matrix)) + ) + (let ((s2-0 (new 'stack-no-clear 'vector))) + (vector-normalize-copy! (the-as vector (-> s4-0 vector)) (the-as vector (-> arg0 bone transform)) 1.0) + (vector-normalize-copy! (-> s4-0 vector 1) (-> arg0 bone transform vector 1) 1.0) + (vector-normalize-copy! (-> s4-0 vector 2) (-> arg0 bone transform vector 2) 1.0) + (set-vector! (-> s4-0 trans) 0.0 0.0 0.0 1.0) + (matrix-transpose! s4-0 s4-0) + (set-vector! (-> s4-0 trans) 0.0 0.0 0.0 1.0) + (vector-matrix*! s2-0 s1-0 s4-0) + (let* ((t9-8 asin) + (f0-8 (-> s2-0 x)) + (f0-10 (* f0-8 f0-8)) + (f1-0 (-> s2-0 y)) + (f28-0 (t9-8 (sqrtf (+ f0-10 (* f1-0 f1-0))))) + (f30-0 (atan (-> s2-0 y) (-> s2-0 x))) + ) + (if (< (-> s2-0 z) 0.0) + (set! f28-0 (- 32768.0 f28-0)) + ) + (set! (-> gp-0 polar-internal-radius) f28-0) + (cond + ((< 16384.0 f30-0) + (set! (-> gp-0 polar-internal-tilt-max) (- 32768.0 f30-0)) + (if (and (< (-> gp-0 polar-external-radius) f28-0) (< 0.0 (-> gp-0 polar-external-tilt-max))) + (set! f30-0 (fmax f30-0 (- 32768.0 (-> gp-0 polar-external-tilt-max)))) + ) + ) + ((< f30-0 -16384.0) + (set! (-> gp-0 polar-internal-tilt-max) (- -32768.0 f30-0)) + (if (and (< (-> gp-0 polar-external-radius) f28-0) (< (-> gp-0 polar-external-tilt-max) 0.0)) + (set! f30-0 (fmin f30-0 (- -32768.0 (-> gp-0 polar-external-tilt-max)))) + ) + ) + ((< 0.0 f30-0) + (set! (-> gp-0 polar-internal-tilt-max) f30-0) + (if (and (< (-> gp-0 polar-external-radius) f28-0) (< 0.0 (-> gp-0 polar-external-tilt-max))) + (set! f30-0 (fmin f30-0 (-> gp-0 polar-external-tilt-max))) + ) + ) + (else + (set! (-> gp-0 polar-internal-tilt-max) f30-0) + (if (and (< (-> gp-0 polar-external-radius) f28-0) (< (-> gp-0 polar-external-tilt-max) 0.0)) + (set! f30-0 (fmax f30-0 (-> gp-0 polar-external-tilt-max))) + ) + ) + ) + (let* ((f0-38 (sin f30-0)) + (f26-0 (* f0-38 f0-38)) + (f0-40 (cos f30-0)) + (f0-42 (* f0-40 f0-40)) + ) + 32768.0 + (let ((f0-44 (cond + ((< 16384.0 f30-0) + (+ (* f26-0 (-> gp-0 twist-max x)) (* f0-42 (-> gp-0 twist-min-y))) + ) + ((< f30-0 -16384.0) + (+ (* f26-0 (-> gp-0 twist-min-x)) (* f0-42 (-> gp-0 twist-min-y))) + ) + ((< 0.0 f30-0) + (+ (* f26-0 (-> gp-0 twist-max x)) (* f0-42 (-> gp-0 twist-max y))) + ) + (else + (+ (* f26-0 (-> gp-0 twist-min-x)) (* f0-42 (-> gp-0 twist-max y))) + ) + ) + ) + ) + (if (< f0-44 f28-0) + (set! f28-0 f0-44) + ) + ) + ) + (let ((f28-1 (cos f28-0))) + (set-vector! s2-0 (cos f30-0) (sin f30-0) 0.0 1.0) + (let ((t9-15 vector-normalize!) + (a0-19 s2-0) + (f0-52 1.0) + (f1-22 f28-1) + ) + (t9-15 a0-19 (sqrtf (- f0-52 (* f1-22 f1-22)))) + ) + (set! (-> s2-0 z) f28-1) + ) + ) + (matrix-transpose! s4-0 s4-0) + (vector-matrix*! s2-0 s2-0 s4-0) + (matrix-from-two-vectors! s4-0 s3-0 s2-0) + ) + (let ((s2-1 (vector-normalize-copy! (new 'stack-no-clear 'vector) (-> arg0 bone transform vector 1) -1.0)) + (s3-1 (matrix->trans (-> arg0 bone transform) (new 'stack-no-clear 'vector))) + ) + (set-vector! (-> arg0 bone transform trans) 0.0 0.0 0.0 1.0) + (matrix*! (-> arg0 bone transform) (-> arg0 bone transform) s4-0) + (matrix-remove-z-rot (-> arg0 bone transform) s2-1) + (set! (-> arg0 bone transform trans quad) (-> s3-1 quad)) + ) + ) + (if (and (= (-> gp-0 process type) target) (!= (-> gp-0 blend) 0.0)) + (add-debug-text-sphere + *display-target-marks* + (bucket-id bucket-318) + (-> gp-0 target) + 819.2 + "look" + (new 'static 'rgba :r #xff :g #xff :a #x80) + ) + ) + ) + (none) + ) + +(defbehavior joint-mod-polar-look-at-handler process ((arg0 cspace) (arg1 transformq)) + (joint-mod-polar-look-at-guts arg0 arg1) + 0 + (none) + ) + +(defbehavior joint-mod-world-look-at-handler process ((arg0 cspace) (arg1 transformq)) + (local-vars (sv-48 vector) (sv-52 vector) (sv-56 vector)) + (let ((gp-0 (the-as joint-mod (-> arg0 param1)))) + (let ((s5-0 (-> arg0 bone transform))) + (cspace<-parented-transformq-joint! arg0 arg1) + (set! sv-48 (vector-normalize-copy! + (new 'stack-no-clear 'vector) + (-> gp-0 process node-list data 0 bone transform vector 1) + 1.0 + ) + ) + (set! sv-52 (vector-normalize! (-> s5-0 vector (-> gp-0 nose)) 1.0)) + (set! sv-56 (vector-normalize! (vector-! (new 'stack-no-clear 'vector) (-> gp-0 target) (-> s5-0 trans)) 1.0)) + (let* ((f30-0 (vector-y-angle sv-52)) + (a0-7 (vector-flatten! (new-stack-vector0) sv-56 sv-48)) + (f0-0 (vector-y-angle a0-7)) + (f0-1 (deg-diff f30-0 f0-0)) + ) + (if (< (-> gp-0 ignore-angle) (fabs f0-1)) + (set! f0-1 0.0) + ) + (let ((f0-5 + (fmax (fmin (* f0-1 (-> gp-0 blend) (-> gp-0 flex-blend)) (-> gp-0 twist-max y)) (- (-> gp-0 twist-max y))) + ) + ) + (set! (-> gp-0 twist y) (deg-seek + (-> gp-0 twist y) + f0-5 + (* (fmax 1.0 (* (fabs (deg-diff f0-5 (-> gp-0 twist y))) (-> gp-0 twist-speed-y))) + (-> self clock time-adjust-ratio) + ) + ) + ) + ) + ) + (when (!= (-> gp-0 twist y) 0.0) + (let ((a2-3 (matrix-rotate-y! (new 'stack-no-clear 'matrix) (-> gp-0 twist y))) + (s4-2 (-> s5-0 trans quad)) + ) + (matrix*! s5-0 s5-0 a2-3) + (set! (-> s5-0 trans quad) s4-2) + ) + ) + (let* ((s4-3 (vector-normalize-copy! + (new 'stack-no-clear 'vector) + (the-as vector (-> gp-0 process node-list data 0 bone transform)) + 1.0 + ) + ) + (f30-2 (vector-x-angle sv-52)) + (s4-4 (vector-flatten! (new-stack-vector0) sv-56 s4-3)) + (f0-15 (vector-x-angle s4-4)) + (f0-21 (fmax + (fmin (* (- (deg-diff f30-2 f0-15)) (-> gp-0 blend) (-> gp-0 flex-blend)) (-> gp-0 twist-max x)) + (- (-> gp-0 twist-max x)) + ) + ) + ) + (if (< (vector-dot s4-4 sv-52) 0.1) + (set! f0-21 0.0) + ) + (set! (-> gp-0 twist x) (deg-seek + (-> gp-0 twist x) + f0-21 + (* (fmax 1.0 (* (fabs (deg-diff f0-21 (-> gp-0 twist x))) (-> gp-0 twist-speed-x))) + (-> self clock time-adjust-ratio) + ) + ) + ) + ) + (when (!= (-> gp-0 twist x) 0.0) + (let* ((v1-25 (-> gp-0 ear)) + (a1-17 ((cond + ((zero? v1-25) + matrix-rotate-x! + ) + ((= v1-25 1) + matrix-rotate-y! + ) + (else + matrix-rotate-z! + ) + ) + (new 'stack-no-clear 'matrix) + (-> gp-0 twist x) + ) + ) + ) + (matrix*! s5-0 a1-17 s5-0) + ) + ) + ) + (if (and (= (-> gp-0 process type) target) (!= (-> gp-0 blend) 0.0)) + (add-debug-text-sphere + *display-target-marks* + (bucket-id bucket-318) + (-> gp-0 target) + 819.2 + "look" + (new 'static 'rgba :r #xff :g #xff :a #x80) + ) + ) + ) + 0 + (none) + ) + +(defbehavior joint-mod-rotate-handler process ((arg0 cspace) (arg1 transformq)) + (rlet ((vf0 :class vf) + (vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + ) + (init-vf0-vector) + (let ((s5-0 (the-as joint-mod (-> arg0 param1)))) + (let ((s3-0 (new 'static 'inline-array quaternion 3 + (new 'static 'quaternion :x 1.0 :w 1.0) + (new 'static 'quaternion :y 1.0 :w 1.0) + (new 'static 'quaternion :z 1.0 :w 1.0) + ) + ) + ) + (if (zero? (logand (-> s5-0 track-mode) (track-mode no-trans))) + (vector+! (-> arg1 trans) (-> arg1 trans) (-> s5-0 trans)) + ) + (when (zero? (logand (-> s5-0 track-mode) (track-mode no-rotate))) + (let* ((v1-9 (-> s3-0 (-> s5-0 ear))) + (a1-4 (quaternion-axis-angle! + (new 'stack-no-clear 'quaternion) + (-> v1-9 x) + (-> v1-9 y) + (-> v1-9 z) + (* (-> s5-0 twist x) (-> s5-0 blend) (-> s5-0 flex-blend)) + ) + ) + ) + (quaternion-normalize! (quaternion*! (-> arg1 quat) a1-4 (-> arg1 quat))) + ) + (let* ((v1-13 (-> s3-0 (-> s5-0 up))) + (a1-6 (quaternion-axis-angle! + (new 'stack-no-clear 'quaternion) + (-> v1-13 x) + (-> v1-13 y) + (-> v1-13 z) + (* (-> s5-0 twist y) (-> s5-0 blend) (-> s5-0 flex-blend)) + ) + ) + ) + (quaternion-normalize! (quaternion*! (-> arg1 quat) a1-6 (-> arg1 quat))) + ) + (let* ((v1-17 (-> s3-0 (-> s5-0 nose))) + (a1-8 (quaternion-axis-angle! + (new 'stack-no-clear 'quaternion) + (-> v1-17 x) + (-> v1-17 y) + (-> v1-17 z) + (* (-> s5-0 twist z) (-> s5-0 blend) (-> s5-0 flex-blend)) + ) + ) + ) + (quaternion-normalize! (quaternion*! (-> arg1 quat) a1-8 (-> arg1 quat))) + ) + ) + ) + (when (zero? (logand (-> s5-0 track-mode) (track-mode no-scale))) + (let ((a1-9 (-> arg1 scale))) + (let ((v1-22 (-> arg1 scale)) + (a0-11 (-> s5-0 scale)) + ) + (.lvf vf4 (&-> v1-22 quad)) + (.lvf vf5 (&-> a0-11 quad)) + ) + (.add.x.vf vf6 vf0 vf0 :mask #b1000) + (.mul.vf vf6 vf4 vf5 :mask #b111) + (.svf (&-> a1-9 quad) vf6) + ) + ) + (cspace<-parented-transformq-joint! arg0 arg1) + (if (-> s5-0 parented-scale?) + (set-vector! (-> arg0 bone scale) 1.0 1.0 1.0 1.0) + ) + ) + 0 + (none) + ) + ) + +(defbehavior joint-mod-scale-handler process ((arg0 cspace) (arg1 transformq)) + (rlet ((vf0 :class vf) + (vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + ) + (init-vf0-vector) + (let ((s5-0 (the-as joint-mod (-> arg0 param1)))) + (let ((a2-0 (-> arg1 scale))) + (let ((v1-0 (-> arg1 scale)) + (a0-1 (-> s5-0 scale)) + ) + (.lvf vf4 (&-> v1-0 quad)) + (.lvf vf5 (&-> a0-1 quad)) + ) + (.add.x.vf vf6 vf0 vf0 :mask #b1000) + (.mul.vf vf6 vf4 vf5 :mask #b111) + (.svf (&-> a2-0 quad) vf6) + ) + (cspace<-parented-transformq-joint! arg0 arg1) + (if (-> s5-0 parented-scale?) + (set-vector! (-> arg0 bone scale) 1.0 1.0 1.0 1.0) + ) + ) + 0 + (none) + ) + ) + +(defbehavior joint-mod-joint-set-handler process ((arg0 cspace) (arg1 transformq)) + (let ((s4-0 (the-as joint-mod (-> arg0 param1)))) + (if (zero? (logand (-> s4-0 track-mode) (track-mode no-trans))) + (set! (-> arg1 trans quad) (-> s4-0 trans quad)) + ) + (if (zero? (logand (-> s4-0 track-mode) (track-mode no-rotate))) + (quaternion-copy! (-> arg1 quat) (-> s4-0 quat)) + ) + (if (zero? (logand (-> s4-0 track-mode) (track-mode no-scale))) + (set! (-> arg1 scale quad) (-> s4-0 scale quad)) + ) + ) + (cspace<-parented-transformq-joint! arg0 arg1) + 0 + (none) + ) + +;; WARN: Function joint-mod-joint-set-world-handler has a return type of none, but the expression builder found a return statement. +(defbehavior joint-mod-joint-set-world-handler process ((arg0 cspace) (arg1 transformq)) + (cspace<-parented-transformq-joint! arg0 arg1) + (let ((s5-0 (the-as joint-mod (-> arg0 param1))) + (s4-0 (matrix->trans (-> arg0 bone transform) (new 'stack-no-clear 'vector))) + ) + (let ((s3-0 (new 'stack-no-clear 'vector))) + (if (>= 0.0 (-> s5-0 flex-blend)) + (return #f) + ) + (cond + ((logtest? (-> s5-0 track-mode) (track-mode no-scale)) + (set! (-> s3-0 quad) (-> arg1 scale quad)) + ) + ((>= (-> s5-0 flex-blend) 1.0) + (set! (-> s3-0 quad) (-> s5-0 scale quad)) + ) + (else + (vector-lerp! s3-0 (-> arg1 scale) (-> s5-0 scale) (-> s5-0 flex-blend)) + ) + ) + (cond + ((logtest? (-> s5-0 track-mode) (track-mode no-rotate)) + ) + ((>= (-> s5-0 flex-blend) 1.0) + (quaternion->matrix (-> arg0 bone transform) (-> s5-0 quat)) + ) + (else + (let ((v1-15 (new 'stack-no-clear 'vector))) + (set! (-> v1-15 quad) (-> arg1 scale quad)) + (set! (-> v1-15 x) (/ 1.0 (-> v1-15 x))) + (set! (-> v1-15 y) (/ 1.0 (-> v1-15 y))) + (set! (-> v1-15 z) (/ 1.0 (-> v1-15 z))) + (vector-float*! + (the-as vector (-> arg0 bone transform)) + (the-as vector (-> arg0 bone transform)) + (-> v1-15 x) + ) + (vector-float*! (-> arg0 bone transform vector 1) (-> arg0 bone transform vector 1) (-> v1-15 y)) + (vector-float*! (-> arg0 bone transform vector 2) (-> arg0 bone transform vector 2) (-> v1-15 z)) + ) + (let ((a1-12 (matrix->quaternion (new 'stack-no-clear 'quaternion) (-> arg0 bone transform)))) + (quaternion->matrix + (-> arg0 bone transform) + (quaternion-slerp! (new 'stack-no-clear 'quaternion) a1-12 (-> s5-0 quat) (-> s5-0 flex-blend)) + ) + ) + ) + ) + (cond + ((logtest? (-> s5-0 track-mode) (track-mode no-rotate)) + (vector-normalize! (the-as vector (-> arg0 bone transform)) (-> s3-0 x)) + (vector-normalize! (-> arg0 bone transform vector 1) (-> s3-0 y)) + (vector-normalize! (-> arg0 bone transform vector 2) (-> s3-0 z)) + ) + (else + (vector-float*! (the-as vector (-> arg0 bone transform)) (the-as vector (-> arg0 bone transform)) (-> s3-0 x)) + (vector-float*! (-> arg0 bone transform vector 1) (-> arg0 bone transform vector 1) (-> s3-0 y)) + (vector-float*! (-> arg0 bone transform vector 2) (-> arg0 bone transform vector 2) (-> s3-0 z)) + ) + ) + ) + (set! (-> arg0 bone transform vector 0 w) 0.0) + (set! (-> arg0 bone transform vector 1 w) 0.0) + (set! (-> arg0 bone transform vector 2 w) 0.0) + (cond + ((logtest? (-> s5-0 track-mode) (track-mode no-trans)) + (set! (-> arg0 bone transform trans quad) (-> s4-0 quad)) + ) + ((>= (-> s5-0 flex-blend) 1.0) + (set! (-> arg0 bone transform trans quad) (-> s5-0 trans quad)) + (set! (-> arg0 bone transform trans w) 1.0) + ) + (else + (vector-lerp! (-> arg0 bone transform trans) s4-0 (-> s5-0 trans) (-> s5-0 flex-blend)) + (set! (-> arg0 bone transform trans w) 1.0) + ) + ) + ) + 0 + (none) + ) + +(defbehavior joint-mod-joint-set*-handler process ((arg0 cspace) (arg1 transformq)) + (rlet ((vf0 :class vf) + (vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + ) + (init-vf0-vector) + (let ((s5-0 (the-as joint-mod (-> arg0 param1)))) + (if (zero? (logand (-> s5-0 track-mode) (track-mode no-trans))) + (vector+! (-> arg1 trans) (-> arg1 trans) (-> s5-0 trans)) + ) + (if (zero? (logand (-> s5-0 track-mode) (track-mode no-rotate))) + (quaternion-normalize! (quaternion*! (-> arg1 quat) (-> arg1 quat) (-> s5-0 quat))) + ) + (when (zero? (logand (-> s5-0 track-mode) (track-mode no-scale))) + (let ((a1-4 (-> arg1 scale))) + (let ((v1-11 (-> arg1 scale)) + (a0-4 (-> s5-0 scale)) + ) + (.lvf vf4 (&-> v1-11 quad)) + (.lvf vf5 (&-> a0-4 quad)) + ) + (.add.x.vf vf6 vf0 vf0 :mask #b1000) + (.mul.vf vf6 vf4 vf5 :mask #b111) + (.svf (&-> a1-4 quad) vf6) + ) + ) + (cspace<-parented-transformq-joint! arg0 arg1) + (if (-> s5-0 parented-scale?) + (set-vector! (-> arg0 bone scale) 1.0 1.0 1.0 1.0) + ) + ) + 0 + (none) + ) + ) + +(defbehavior joint-mod-joint-set*-world-handler process ((arg0 cspace) (arg1 transformq)) + (cspace<-parented-transformq-joint! arg0 arg1) + (let ((s5-0 (the-as joint-mod (-> arg0 param1)))) + (let ((s3-0 (quaternion->matrix (new 'stack-no-clear 'matrix) (-> s5-0 quat))) + (s4-0 (matrix->trans (-> arg0 bone transform) (new 'stack-no-clear 'vector))) + ) + (vector-reset! (-> arg0 bone transform trans)) + (set! (-> arg0 bone transform trans w) 1.0) + (vector-float*! (the-as vector (-> s3-0 vector)) (the-as vector (-> s3-0 vector)) (-> s5-0 scale x)) + (vector-float*! (-> s3-0 vector 1) (-> s3-0 vector 1) (-> s5-0 scale y)) + (vector-float*! (-> s3-0 vector 2) (-> s3-0 vector 2) (-> s5-0 scale z)) + (set! (-> s3-0 vector 0 w) 0.0) + (set! (-> s3-0 vector 1 w) 0.0) + (set! (-> s3-0 vector 2 w) 0.0) + (matrix*! (-> arg0 bone transform) (-> arg0 bone transform) s3-0) + (vector+! (-> arg0 bone transform trans) s4-0 (-> s5-0 trans)) + ) + (if (-> s5-0 parented-scale?) + (set-vector! (-> arg0 bone scale) 1.0 1.0 1.0 1.0) + ) + ) + 0 + (none) + ) + + + + diff --git a/goal_src/jak2/engine/anim/joint.gc b/goal_src/jak2/engine/anim/joint.gc index 474ae129f1..bf3dae8667 100644 --- a/goal_src/jak2/engine/anim/joint.gc +++ b/goal_src/jak2/engine/anim/joint.gc @@ -158,7 +158,7 @@ (set! (-> v0-0 allocated-length) (the-as uint arg0)) (set! (-> v0-0 active-channels) (the-as uint 0)) (set! (-> v0-0 float-channels) (the-as uint 0)) - (set! (-> v0-0 root-channel) (the-as (inline-array joint-control-channel) (-> v0-0 channel))) + (set! (-> v0-0 root-channel) (-> 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) @@ -1138,9 +1138,9 @@ (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) + (vector-normalize! (the-as vector (-> gp-0 vector)) 1.0) + (vector-normalize! (-> gp-0 vector 1) 1.0) + (vector-normalize! (-> gp-0 vector 2) 1.0) gp-0 ) ) diff --git a/goal_src/jak2/engine/camera/camera-h.gc b/goal_src/jak2/engine/camera/camera-h.gc index 93c01383ff..97d25210e1 100644 --- a/goal_src/jak2/engine/camera/camera-h.gc +++ b/goal_src/jak2/engine/camera/camera-h.gc @@ -59,6 +59,8 @@ (declare-type camera-master process) (define-extern cam-master-init (function none :behavior camera-master)) +(define-extern parameter-ease-sin-clamp (function float float)) + ;; DECOMP BEGINS (deftype cam-index (structure) diff --git a/goal_src/jak2/engine/data/art-h.gc b/goal_src/jak2/engine/data/art-h.gc index fac097f91b..9934c7f968 100644 --- a/goal_src/jak2/engine/data/art-h.gc +++ b/goal_src/jak2/engine/data/art-h.gc @@ -221,7 +221,7 @@ (:methods (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) ) ) @@ -396,7 +396,7 @@ (defmethod get-skeleton-origin draw-control ((obj draw-control)) - (-> obj skeleton bones 0 transform vector 3) + (-> obj skeleton bones 0 transform trans) ) 0 diff --git a/goal_src/jak2/engine/debug/debug-h.gc b/goal_src/jak2/engine/debug/debug-h.gc index 88f88b434b..69df3694ce 100644 --- a/goal_src/jak2/engine/debug/debug-h.gc +++ b/goal_src/jak2/engine/debug/debug-h.gc @@ -11,6 +11,12 @@ (define-extern transform-float-point (function vector vector4w vector4w)) (define-extern add-debug-line (function symbol bucket-id vector vector rgba symbol rgba symbol)) + +(define-extern add-debug-line2d (function symbol bucket-id vector vector vector symbol)) +(define-extern add-debug-sphere (function symbol bucket-id vector float rgba symbol)) +(define-extern add-debug-text-3d (function symbol bucket-id string vector font-color vector2h symbol)) +(define-extern add-debug-text-sphere (function symbol bucket-id vector float string rgba symbol)) + ;; DECOMP BEGINS (deftype pos-history (structure) diff --git a/goal_src/jak2/engine/debug/debug.gc b/goal_src/jak2/engine/debug/debug.gc index 1ae7fae00a..9bcf4b10a6 100644 --- a/goal_src/jak2/engine/debug/debug.gc +++ b/goal_src/jak2/engine/debug/debug.gc @@ -5,7 +5,11 @@ ;; name in dgo: debug ;; dgos: ENGINE, GAME -(define-extern add-debug-line2d (function symbol bucket-id vector vector vector symbol)) +(defun add-debug-text-sphere ((arg0 symbol) (arg1 bucket-id) (arg2 vector) (arg3 float) (arg4 string) (arg5 rgba)) + (add-debug-sphere arg0 arg1 arg2 arg3 arg5) + (add-debug-text-3d arg0 arg1 arg4 arg2 (font-color default) (the-as vector2h #f)) + #f + ) ;; DECOMP BEGINS diff --git a/goal_src/jak2/engine/game/game-info-h.gc b/goal_src/jak2/engine/game/game-info-h.gc index d1cb3cf0ba..1b3571db0e 100644 --- a/goal_src/jak2/engine/game/game-info-h.gc +++ b/goal_src/jak2/engine/game/game-info-h.gc @@ -207,13 +207,13 @@ (want-sound-banks (_type_ (pointer symbol)) none 12) (want-display-level (_type_ symbol symbol) int 13) (want-vis-level (_type_ symbol) none 14) - (load-state-method-15 () none 15) - (load-state-method-16 () none 16) - (load-state-method-17 () none 17) - (load-state-method-18 () none 18) - (load-state-method-19 () none 19) - (load-state-method-20 () none 20) - (load-state-method-21 () none 21) + (want-force-vis (_type_ symbol symbol) int 15) + (execute-command (_type_ pair) none 16) + (execute-commands-up-to (_type_ float) none 17) + (backup-load-state-and-set-cmds (_type_ pair) int 18) + (restore-load-state-and-cleanup (_type_) int 19) + (restore-load-state (_type_) int 20) + (set-force-inside! (_type_ symbol symbol) none 21) ) ) diff --git a/goal_src/jak2/engine/game/settings-h.gc b/goal_src/jak2/engine/game/settings-h.gc index 465b983aa4..f80a1ee814 100644 --- a/goal_src/jak2/engine/game/settings-h.gc +++ b/goal_src/jak2/engine/game/settings-h.gc @@ -136,7 +136,7 @@ (stereo-mode int32 :offset-assert 228) (music symbol :offset-assert 232) (sound-stinger int32 :offset-assert 236) - (spool-anim symbol :offset-assert 240) + (spool-anim spool-anim :offset-assert 240) (sound-mode uint32 :offset-assert 244) (task-manager (pointer process) :offset-assert 248) (task symbol :offset-assert 252) diff --git a/goal_src/jak2/engine/game/settings.gc b/goal_src/jak2/engine/game/settings.gc index b3ed6994cb..e906b877c4 100644 --- a/goal_src/jak2/engine/game/settings.gc +++ b/goal_src/jak2/engine/game/settings.gc @@ -357,7 +357,7 @@ (set! (-> obj spooling) (the-as (pointer process) arg1)) ) (('spool-anim) - (set! (-> obj spool-anim) arg1) + (set! (-> obj spool-anim) (the-as spool-anim arg1)) ) (('hint) (set! (-> obj hint) (the-as (pointer process) arg1)) diff --git a/goal_src/jak2/engine/geometry/geometry.gc b/goal_src/jak2/engine/geometry/geometry.gc index 46f37729f8..b44630005b 100644 --- a/goal_src/jak2/engine/geometry/geometry.gc +++ b/goal_src/jak2/engine/geometry/geometry.gc @@ -370,35 +370,31 @@ (defun forward-down->inv-matrix ((arg0 matrix) (arg1 vector) (arg2 vector)) "Create a matrix representing an inverse transform where arg1 is forward (+z) and arg2 is down (-y). Will have the pitch of forward" - (vector-normalize-copy! (the-as vector (&-> arg0 data 8)) arg1 1.0) - (vector-cross! (the-as vector (-> arg0 data)) (the-as vector (&-> arg0 data 8)) arg2) - (vector-normalize! (the-as vector (-> arg0 data)) 1.0) - (vector-cross! (the-as vector (&-> arg0 data 4)) arg1 (the-as vector (-> arg0 data))) - (vector-normalize! (the-as vector (&-> arg0 data 4)) 1.0) + (vector-normalize-copy! (-> arg0 vector 2) arg1 1.0) + (vector-cross! (the-as vector (-> arg0 vector)) (-> arg0 vector 2) arg2) + (vector-normalize! (the-as vector (-> arg0 vector)) 1.0) + (vector-cross! (-> arg0 vector 1) arg1 (the-as vector (-> arg0 vector))) + (vector-normalize! (-> arg0 vector 1) 1.0) (set! (-> arg0 trans quad) (the-as uint128 0)) - (set! (-> arg0 data 3) 0.0) - (set! (-> arg0 data 7) 0.0) - (set! (-> arg0 data 11) 0.0) + (set! (-> arg0 vector 0 w) 0.0) + (set! (-> arg0 vector 1 w) 0.0) + (set! (-> arg0 vector 2 w) 0.0) (set! (-> arg0 trans w) 1.0) arg0 ) (defun forward-down-nopitch->inv-matrix ((arg0 matrix) (arg1 vector) (arg2 vector)) "Create a matrix representing an inverse transform where arg1 is forward (+z) and arg2 is down (-y). Will not use the pitch of forward" - (vector-normalize-copy! (the-as vector (&-> arg0 data 4)) arg2 1.0) - (vector-negate! (the-as vector (&-> arg0 data 4)) (the-as vector (&-> arg0 data 4))) - (vector-cross! (the-as vector (-> arg0 data)) (the-as vector (&-> arg0 data 4)) arg1) - (vector-normalize! (the-as vector (-> arg0 data)) 1.0) - (vector-cross! - (the-as vector (&-> arg0 data 8)) - (the-as vector (-> arg0 data)) - (the-as vector (&-> arg0 data 4)) - ) - (vector-normalize! (the-as vector (&-> arg0 data 8)) 1.0) + (vector-normalize-copy! (-> arg0 vector 1) arg2 1.0) + (vector-negate! (-> arg0 vector 1) (-> arg0 vector 1)) + (vector-cross! (the-as vector (-> arg0 vector)) (-> arg0 vector 1) arg1) + (vector-normalize! (the-as vector (-> arg0 vector)) 1.0) + (vector-cross! (-> arg0 vector 2) (the-as vector (-> arg0 vector)) (-> arg0 vector 1)) + (vector-normalize! (-> arg0 vector 2) 1.0) (set! (-> arg0 trans quad) (the-as uint128 0)) - (set! (-> arg0 data 3) 0.0) - (set! (-> arg0 data 7) 0.0) - (set! (-> arg0 data 11) 0.0) + (set! (-> arg0 vector 0 w) 0.0) + (set! (-> arg0 vector 1 w) 0.0) + (set! (-> arg0 vector 2 w) 0.0) (set! (-> arg0 trans w) 1.0) arg0 ) @@ -639,23 +635,23 @@ ) ) -(defun matrix-remove-z-rot ((arg0 matrix) (arg1 matrix)) +(defun matrix-remove-z-rot ((arg0 matrix) (arg1 vector)) "Remove the z rotation component of a rotation." (let ((s4-0 (new-stack-vector0))) 0.0 0.0 (let ((s5-0 (new-stack-matrix0))) - (vector-negate! s4-0 (the-as vector arg1)) - (vector-flatten! s4-0 s4-0 (the-as vector (&-> arg0 data 8))) + (vector-negate! s4-0 arg1) + (vector-flatten! s4-0 s4-0 (-> arg0 vector 2)) (vector-normalize! s4-0 1.0) - (let ((f30-0 (vector-dot (the-as vector (&-> arg0 data 4)) s4-0))) + (let ((f30-0 (vector-dot (-> arg0 vector 1) s4-0))) (when (< f30-0 0.99999) - (vector-cross! s4-0 (the-as vector (&-> arg0 data 4)) s4-0) + (vector-cross! s4-0 (-> arg0 vector 1) s4-0) (let ((f0-4 (vector-length s4-0))) - (if (< 0.0 (vector-dot s4-0 (the-as vector (&-> arg0 data 8)))) + (if (< 0.0 (vector-dot s4-0 (-> arg0 vector 2))) (set! f0-4 (- f0-4)) ) - (matrix-axis-sin-cos! s5-0 (the-as vector (&-> arg0 data 8)) f0-4 f30-0) + (matrix-axis-sin-cos! s5-0 (-> arg0 vector 2) f0-4 f30-0) ) (matrix*! arg0 arg0 s5-0) ) @@ -699,12 +695,7 @@ (quaternion->matrix s5-0 arg1) (quaternion->matrix s4-0 arg2) (let ((s2-1 (new-stack-quaternion0))) - (quaternion-from-two-vectors-max-angle! - s2-1 - (the-as vector (&-> s5-0 data 8)) - (the-as vector (&-> s4-0 data 8)) - arg4 - ) + (quaternion-from-two-vectors-max-angle! s2-1 (-> s5-0 vector 2) (-> s4-0 vector 2) arg4) (quaternion-normalize! (quaternion*! arg0 arg0 s2-1)) ) ) @@ -917,96 +908,42 @@ (b! #t cfg-24 :delay (.svf (&-> arg0 quad) vf18)) (nop!) (label cfg-3) - (b! (nonzero? v1-4) cfg-6 :delay (set! v1-5 (the-as uint (+ v1-4 -1)))) - (vector-segment-distance-point! - arg1 - (the-as vector (-> arg2 vector)) - (-> arg2 vector 1) - arg0 - ) + (b! (nonzero? v1-4) cfg-6 :delay (set! v1-5 (+ v1-4 -1))) + (vector-segment-distance-point! arg1 (the-as vector (-> arg2 vector)) (-> arg2 vector 1) arg0) (goto cfg-24) (label cfg-6) - (b! (nonzero? v1-5) cfg-9 :delay (set! v1-6 (the-as uint (+ v1-5 -1)))) - (vector-segment-distance-point! - arg1 - (-> arg2 vector 1) - (-> arg2 vector 2) - arg0 - ) + (b! (nonzero? v1-5) cfg-9 :delay (set! v1-6 (+ v1-5 -1))) + (vector-segment-distance-point! arg1 (-> arg2 vector 1) (-> arg2 vector 2) arg0) (goto cfg-24) (label cfg-9) - (b! (nonzero? v1-6) cfg-14 :delay (set! v1-7 (the-as uint (+ v1-6 -1)))) - (let ((f30-0 (vector-segment-distance-point! - arg1 - (-> arg2 vector 1) - (the-as vector (-> arg2 vector)) - arg0 - ) - ) + (b! (nonzero? v1-6) cfg-14 :delay (set! v1-7 (+ v1-6 -1))) + (let ((f30-0 (vector-segment-distance-point! arg1 (-> arg2 vector 1) (the-as vector (-> arg2 vector)) arg0)) (s3-0 (new 'stack-no-clear 'vector)) ) - (if (< (vector-segment-distance-point! - arg1 - (-> arg2 vector 1) - (-> arg2 vector 2) - s3-0 - ) - f30-0 - ) + (if (< (vector-segment-distance-point! arg1 (-> arg2 vector 1) (-> arg2 vector 2) s3-0) f30-0) (set! (-> arg0 quad) (-> s3-0 quad)) ) ) (goto cfg-24) (label cfg-14) - (b! (nonzero? v1-7) cfg-17 :delay (set! v1-10 (the-as uint (+ v1-7 -1)))) - (vector-segment-distance-point! - arg1 - (-> arg2 vector 2) - (the-as vector (-> arg2 vector)) - arg0 - ) + (b! (nonzero? v1-7) cfg-17 :delay (set! v1-10 (+ v1-7 -1))) + (vector-segment-distance-point! arg1 (-> arg2 vector 2) (the-as vector (-> arg2 vector)) arg0) (goto cfg-24) (label cfg-17) - (b! (nonzero? v1-10) cfg-22) - (let ((f30-1 (vector-segment-distance-point! - arg1 - (the-as vector (-> arg2 vector)) - (-> arg2 vector 1) - arg0 - ) - ) + (b! (nonzero? v1-10) cfg-22 :delay (nop!)) + (let ((f30-1 (vector-segment-distance-point! arg1 (the-as vector (-> arg2 vector)) (-> arg2 vector 1) arg0)) (s3-1 (new 'stack-no-clear 'vector)) ) - (if (< (vector-segment-distance-point! - arg1 - (the-as vector (-> arg2 vector)) - (-> arg2 vector 2) - s3-1 - ) - f30-1 - ) + (if (< (vector-segment-distance-point! arg1 (the-as vector (-> arg2 vector)) (-> arg2 vector 2) s3-1) f30-1) (set! (-> arg0 quad) (-> s3-1 quad)) ) ) (goto cfg-24) (label cfg-22) - (let ((f30-2 (vector-segment-distance-point! - arg1 - (-> arg2 vector 2) - (the-as vector (-> arg2 vector)) - arg0 - ) - ) + (let ((f30-2 (vector-segment-distance-point! arg1 (-> arg2 vector 2) (the-as vector (-> arg2 vector)) arg0)) (s3-2 (new 'stack-no-clear 'vector)) ) - (if (< (vector-segment-distance-point! - arg1 - (-> arg2 vector 2) - (-> arg2 vector 1) - s3-2 - ) - f30-2 - ) + (if (< (vector-segment-distance-point! arg1 (-> arg2 vector 2) (-> arg2 vector 1) s3-2) f30-2) (set! (-> arg0 quad) (-> s3-2 quad)) ) ) diff --git a/goal_src/jak2/engine/load/loader-h.gc b/goal_src/jak2/engine/load/loader-h.gc index 81a1992619..837766fdb0 100644 --- a/goal_src/jak2/engine/load/loader-h.gc +++ b/goal_src/jak2/engine/load/loader-h.gc @@ -7,8 +7,7 @@ ;; TODO: document this stuff when doing loader.gc -;; todo: more specific -(define-extern external-art-buffer-init function) +(define-extern external-art-buffer-init (function external-art-buffer int)) (declare-type art basic) (declare-type art-group art) @@ -24,7 +23,7 @@ :flag-assert #xb00000010 (:methods (new (symbol type int level) _type_ 0) - (load-dir-method-9 () none 9) + (load-to-heap-by-name (_type_ string symbol kheap int) art-group 9) (set-loaded-art (_type_ art-group) art-group 10) ) ) @@ -61,46 +60,47 @@ ) (deftype external-art-buffer (basic) - ((index int32 :offset-assert 4) - (other external-art-buffer :offset-assert 8) - (status symbol :offset-assert 12) - (locked? symbol :offset-assert 16) - (login? symbol :offset-assert 20) - (frame-lock symbol :offset-assert 24) - (init-heap function :offset-assert 28) - (heap kheap :inline :offset-assert 32) - (pending-load-file string :offset-assert 48) - (pending-load-file-part int32 :offset-assert 52) - (pending-load-file-owner handle :offset-assert 56) - (pending-load-file-priority float :offset-assert 64) - (load-file string :offset-assert 68) - (load-file-part int32 :offset-assert 72) - (load-file-owner handle :offset-assert 80) - (load-file-priority float :offset-assert 88) - (buf pointer :offset-assert 92) - (len int32 :offset-assert 96) - (art-group art-group :offset-assert 100) - (art-data uint32 :offset 100) + ((index int32 :offset-assert 4) + (other external-art-buffer :offset-assert 8) + (status symbol :offset-assert 12) + (locked? symbol :offset-assert 16) + (login? symbol :offset-assert 20) + (frame-lock symbol :offset-assert 24) + (init-heap (function external-art-buffer object) :offset-assert 28) + (heap kheap :inline :offset-assert 32) + (pending-load-file string :offset-assert 48) + (pending-load-file-part int32 :offset-assert 52) + (pending-load-file-owner handle :offset-assert 56) + (pending-load-file-priority float :offset-assert 64) + (load-file string :offset-assert 68) + (load-file-part int32 :offset-assert 72) + (load-file-owner handle :offset-assert 80) + (load-file-priority float :offset-assert 88) + (buf pointer :offset-assert 92) + (len int32 :offset-assert 96) + (art-group art-group :offset-assert 100) + (art-data uint32 :offset 100) ) :method-count-assert 16 :size-assert #x68 :flag-assert #x1000000068 (:methods (new (symbol type int function symbol) _type_ 0) - (external-art-buffer-method-9 () none 9) - (external-art-buffer-method-10 () none 10) - (external-art-buffer-method-11 () none 11) - (external-art-buffer-method-12 () none 12) - (external-art-buffer-method-13 () none 13) - (external-art-buffer-method-14 () none 14) - (external-art-buffer-method-15 () none 15) + (set-pending-file (_type_ string int handle float) int 9) + (update (_type_) int 10) + (inactive? (_type_) symbol 11) + (file-status (_type_ string int) symbol 12) + (link-file (_type_ art-group) art-group 13) + (unlink-file (_type_ art-group) int 14) + (unlock! (_type_) int 15) ) ) + (defmethod new external-art-buffer ((allocation symbol) (type-to-make type) (arg0 int) (arg1 function) (arg2 symbol)) (let ((v0-0 (object-new allocation type-to-make (the-as int (-> type-to-make size))))) (set! (-> v0-0 index) arg0) - (set! (-> v0-0 init-heap) arg1) + (set! (-> v0-0 init-heap) (the-as (function external-art-buffer object) arg1)) (set! (-> v0-0 login?) arg2) (set! (-> v0-0 load-file) #f) (set! (-> v0-0 load-file-part) -1) @@ -119,19 +119,21 @@ ) (deftype spool-anim (basic) - ((name string :offset 16) - (anim-name basic :offset-assert 20) - (parts int32 :offset-assert 24) - (hint-id int32 :offset 24) - (priority float :offset-assert 28) - (owner uint64 :offset-assert 32) - (command-list pair :offset-assert 40) + ((name string :offset 16) + (anim-name basic :offset-assert 20) + (buffer external-art-buffer :offset 20) + (parts int32 :offset-assert 24) + (hint-id int32 :offset 24) + (priority float :offset-assert 28) + (owner handle :offset-assert 32) + (command-list pair :offset-assert 40) ) :method-count-assert 9 :size-assert #x2c :flag-assert #x90000002c ) + (deftype external-art-control (basic) ((buffer external-art-buffer 2 :offset-assert 4) (rec spool-anim 3 :inline :offset-assert 16) @@ -151,14 +153,15 @@ (new (symbol type) _type_ 0) (update (_type_ symbol) int 9) (clear-rec (_type_) int 10) - (external-art-control-method-11 () none 11) - (external-art-control-method-12 () none 12) - (external-art-control-method-13 () none 13) - (external-art-control-method-14 () none 14) - (external-art-control-method-15 () none 15) + (spool-push (_type_ string int process float) int 11) + (file-status (_type_ string int) symbol 12) + (reserve-alloc (_type_) kheap 13) + (reserve-free (_type_ kheap) int 14) + (none-reserved? (_type_) symbol 15) ) ) + (defmethod new external-art-control ((allocation symbol) (type-to-make type)) (let ((gp-0 (object-new allocation type-to-make (the-as int (-> type-to-make size))))) (dotimes (s4-0 2) @@ -171,7 +174,7 @@ (dotimes (v1-9 3) (set! (-> gp-0 rec v1-9 name) #f) (set! (-> gp-0 rec v1-9 priority) 100000000.0) - (set! (-> gp-0 rec v1-9 owner) (the-as uint #f)) + (set! (-> gp-0 rec v1-9 owner) (the-as handle #f)) ) (set! (-> gp-0 spool-lock) (the-as handle #f)) (set! (-> gp-0 reserve-buffer) #f) @@ -195,19 +198,6 @@ :flag-assert #x90000002c ) -(defmethod inspect subtitle-range ((obj subtitle-range)) - (when (not obj) - (return obj) - ) - (format #t "[~8x] ~A~%" obj (-> obj type)) - (format #t "~1Tstart-frame: ~f~%" (-> obj start-frame)) - (format #t "~1Tend-frame: ~f~%" (-> obj end-frame)) - (format #t "~1Tmessage[8] @ #x~X~%" (-> obj message)) - (dotimes (s5-0 8) - (format #t "~T [~D]~1Tmessage: ~`object`P~%" s5-0 (-> obj message s5-0)) - ) - obj - ) (deftype subtitle-image (basic) ((width uint16 :offset-assert 4) @@ -220,14 +210,9 @@ :flag-assert #x900000050 ) -(defmethod inspect subtitle-image ((obj subtitle-image)) - (when (not obj) - (return obj) - ) - (format #t "[~8x] ~A~%" obj (-> obj type)) - (format #t "~1Twidth: ~D~%" (-> obj width)) - (format #t "~1Theight: ~D~%" (-> obj height)) - (format #t "~1Tpalette[16] @ #x~X~%" (-> obj palette)) - (format #t "~1Tdata[0] @ #x~X~%" (-> obj data)) - obj - ) + +(define-extern *art-control* external-art-control) + + + + diff --git a/goal_src/jak2/engine/load/loader.gc b/goal_src/jak2/engine/load/loader.gc index f204d56d46..3b25294913 100644 --- a/goal_src/jak2/engine/load/loader.gc +++ b/goal_src/jak2/engine/load/loader.gc @@ -5,7 +5,75 @@ ;; name in dgo: loader ;; dgos: ENGINE, GAME -;; temporary hack to avoid crash at startup +(define-extern art-group-load-check (function string kheap int art-group)) + +;; DECOMP BEGINS + +(defmethod mem-usage subtitle-range ((obj subtitle-range) (arg0 memory-usage-block) (arg1 int)) + (set! (-> arg0 length) (max 73 (-> arg0 length))) + (set! (-> arg0 data 72 name) "subtitle") + (+! (-> arg0 data 72 count) 1) + (let ((v1-6 (asize-of obj))) + (+! (-> arg0 data 72 used) v1-6) + (+! (-> arg0 data 72 total) (logand -16 (+ v1-6 15))) + ) + obj + ) + + +(defmethod mem-usage load-dir ((obj load-dir) (arg0 memory-usage-block) (arg1 int)) + (set! (-> arg0 length) (max 85 (-> arg0 length))) + (set! (-> arg0 data 84 name) "array") + (+! (-> arg0 data 84 count) 1) + (let ((v1-6 (asize-of obj))) + (+! (-> arg0 data 84 used) v1-6) + (+! (-> arg0 data 84 total) (logand -16 (+ v1-6 15))) + ) + (set! (-> arg0 length) (max 85 (-> arg0 length))) + (set! (-> arg0 data 84 name) "array") + (set! (-> arg0 data 84 count) (-> arg0 data 84 count)) + (let ((v1-15 (asize-of (-> obj string-array)))) + (+! (-> arg0 data 84 used) v1-15) + (+! (-> arg0 data 84 total) (logand -16 (+ v1-15 15))) + ) + (set! (-> arg0 length) (max 85 (-> arg0 length))) + (set! (-> arg0 data 84 name) "array") + (set! (-> arg0 data 84 count) (-> arg0 data 84 count)) + (let ((v1-24 (asize-of (-> obj data-array)))) + (+! (-> arg0 data 84 used) v1-24) + (+! (-> arg0 data 84 total) (logand -16 (+ v1-24 15))) + ) + (dotimes (s3-0 (-> obj data-array length)) + (mem-usage (-> obj data-array s3-0) arg0 arg1) + ) + (the-as load-dir #f) + ) + +(defmethod load-to-heap-by-name load-dir-art-group ((obj load-dir-art-group) (arg0 string) (arg1 symbol) (arg2 kheap) (arg3 int)) + (let ((s5-0 (-> obj string-array))) + (dotimes (s3-0 (-> s5-0 length)) + (when (string= arg0 (-> s5-0 s3-0)) + (when arg1 + (let ((v1-4 (art-group-load-check arg0 arg2 arg3))) + (if v1-4 + (set! (-> obj art-group-array s3-0) v1-4) + ) + ) + ) + (return (-> obj art-group-array s3-0)) + ) + ) + (let ((v0-2 (art-group-load-check arg0 arg2 arg3))) + (when v0-2 + (set! (-> s5-0 (-> s5-0 length)) arg0) + (set! (-> obj art-group-array (-> s5-0 length)) v0-2) + (+! (-> s5-0 length) 1) + (+! (-> obj art-group-array length) 1) + ) + v0-2 + ) + ) + ) (defmethod set-loaded-art load-dir-art-group ((obj load-dir-art-group) (arg0 art-group)) (let ((s4-0 (-> obj string-array))) @@ -25,5 +93,2377 @@ arg0 ) -;; DECOMP BEGINS +(defun drawable-load ((arg0 drawable) (arg1 kheap)) + ;; (local-vars (sp-0 pointer)) + (cond + ((type? arg0 string) + ;; (the-as none sp-0) + ;; (if (< (the-as uint sp-0) (the-as uint *stack-top*)) + ;; (set! sp-0 (&+ *kernel-sp* -1024)) + ;; ) + (let ((s5-1 (loado (the-as string arg0) arg1))) + (if (and s5-1 (type? s5-1 drawable)) + (login (the-as drawable s5-1)) + ) + ) + ) + ((type? arg0 drawable) + (login arg0) + ) + ) + ) + +(defun art-load ((arg0 string) (arg1 kheap)) + ;; (local-vars (sp-0 pointer)) + ;; (the-as none sp-0) + ;; (if (< (the-as uint sp-0) (the-as uint *stack-top*)) + ;; (set! sp-0 (&+ *kernel-sp* -1024)) + ;; ) + (let ((s5-0 (loado arg0 arg1))) + (if (type? s5-0 art) + (login (the-as art s5-0)) + (the-as art #f) + ) + ) + ) + +(defun art-group-load-check ((arg0 string) (arg1 kheap) (arg2 int)) + ;; (local-vars (sp-0 pointer)) + (when *debug-segment* + ;; (the-as none sp-0) + ;; (if (< (the-as uint sp-0) (the-as uint *stack-top*)) + ;; (set! sp-0 (&+ *kernel-sp* -1024)) + ;; ) + (let ((s3-1 (loado (make-file-name (file-kind art-group) arg0 arg2 #f) arg1))) + (cond + ((not s3-1) + (format 0 "ERROR: art-group ~A is not a valid file.~%" arg0) + (the-as art-group #f) + ) + ((not (type? s3-1 art-group)) + (format 0 "ERROR: art-group ~A is not a art-group.~%" arg0) + (the-as art-group #f) + ) + ((not (file-info-correct-version? (-> (the-as art-group s3-1) info) (file-kind art-group) arg2)) + (the-as art-group #f) + ) + (else + (login (the-as art-group s3-1)) + ) + ) + ) + ) + ) + +(defmethod print external-art-buffer ((obj external-art-buffer)) + (format + #t + "#<~A ~S ~D ~A @ #x~X>" + (-> obj type) + (-> obj pending-load-file) + (-> obj pending-load-file-part) + (-> obj status) + obj + ) + obj + ) + +(defun external-art-buffer-init ((arg0 external-art-buffer)) + (let ((v1-0 (-> arg0 heap))) + (set! (-> v1-0 base) (the-as pointer (+ #x84000 (* #x3dc00 (-> arg0 index))))) + (set! (-> v1-0 current) (-> v1-0 base)) + (set! (-> v1-0 top-base) (&+ (-> v1-0 base) #x3dc00)) + (set! (-> v1-0 top) (-> v1-0 top-base)) + ) + 0 + ) + +(defmethod set-pending-file external-art-buffer ((obj external-art-buffer) (arg0 string) (arg1 int) (arg2 handle) (arg3 float)) + (set! (-> obj pending-load-file) arg0) + (set! (-> obj pending-load-file-part) arg1) + (set! (-> obj pending-load-file-owner) arg2) + (set! (-> obj pending-load-file-priority) arg3) + 0 + ) + +(defmethod unlock! external-art-buffer ((obj external-art-buffer)) + (set! (-> obj locked?) #f) + 0 + ) + +(defmethod inactive? external-art-buffer ((obj external-art-buffer)) + (!= (-> obj status) 'active) + ) + +(defmethod file-status external-art-buffer ((obj external-art-buffer) (arg0 string) (arg1 int)) + (when (and (name= (-> obj pending-load-file) arg0) (= (-> obj pending-load-file-part) arg1)) + (if (and (name= (-> obj load-file) arg0) (= (-> obj load-file-part) arg1)) + (-> obj status) + 'pending + ) + ) + ) + +(defmethod link-art! art-group ((obj art-group)) + (when obj + (countdown (s5-0 (-> obj length)) + (let* ((s3-0 (-> obj data s5-0)) + (s4-0 (if (type? s3-0 art-joint-anim) + (the-as art-joint-anim s3-0) + ) + ) + (s2-0 #f) + ) + (when s4-0 + (let ((s3-1 7)) + (while (begin (label cfg-24) (nonzero? s3-1)) + (+! s3-1 -1) + (let ((v1-8 (get-art-group-by-name (-> *level* level s3-1) (-> s4-0 master-art-group-name)))) + (when v1-8 + (countdown (a0-5 (-> v1-8 length)) + (if (= (-> v1-8 data a0-5) s4-0) + (goto cfg-24) + ) + ) + (cond + ((and (< (-> s4-0 master-art-group-index) (-> v1-8 length)) + (not (-> v1-8 data (-> s4-0 master-art-group-index))) + ) + (set! (-> v1-8 data (-> s4-0 master-art-group-index)) s4-0) + (set! s2-0 #t) + ) + (else + (countdown (a0-17 (-> v1-8 length)) + (when (not (-> v1-8 data a0-17)) + (set! (-> v1-8 data a0-17) s4-0) + (set! s2-0 #t) + (goto cfg-24) + ) + ) + ) + ) + ) + ) + ) + ) + (if (not s2-0) + (format 0 "ERROR: ~A could not find a master slot to link for ~A.~%" (-> obj name) s4-0) + ) + ) + ) + ) + ) + obj + ) + +(defmethod unlink-art! art-group ((obj art-group)) + (when obj + (countdown (s5-0 (-> obj length)) + (let* ((s3-0 (-> obj data s5-0)) + (s4-0 (if (type? s3-0 art-joint-anim) + (the-as art-joint-anim s3-0) + ) + ) + (s3-1 #f) + ) + (when s4-0 + (let ((s2-0 7)) + (while (begin (label cfg-13) (nonzero? s2-0)) + (+! s2-0 -1) + (let ((v1-8 (get-art-group-by-name (-> *level* level s2-0) (-> s4-0 master-art-group-name)))) + (when v1-8 + (countdown (a0-5 (-> v1-8 length)) + (when (= s4-0 (-> v1-8 data a0-5)) + (set! (-> v1-8 data a0-5) #f) + (set! s3-1 #t) + (goto cfg-13) + ) + ) + ) + ) + ) + ) + (if (not s3-1) + (format 0 "ERROR: ~A could not find a master slot to unlink for ~A.~%" (-> obj name) s4-0) + ) + ) + ) + ) + ) + 0 + ) + +(defmethod link-file external-art-buffer ((obj external-art-buffer) (arg0 art-group)) + (when arg0 + (link-art! arg0) + (set! (-> obj art-group) arg0) + ) + arg0 + ) + +(defmethod unlink-file external-art-buffer ((obj external-art-buffer) (arg0 art-group)) + (when arg0 + (unlink-art! arg0) + (set! (-> obj art-group) #f) + ) + 0 + ) + +;; WARN: Found some very strange gotos. Check result carefully, this is not well tested. +(defmethod update external-art-buffer ((obj external-art-buffer)) + (when (or (not (name= (-> obj pending-load-file) (-> obj load-file))) + (!= (-> obj pending-load-file-part) (-> obj load-file-part)) + ) + (when (not (handle->process (-> obj pending-load-file-owner))) + (set! (-> obj pending-load-file) #f) + (set! (-> obj pending-load-file-part) -1) + (set! (-> obj pending-load-file-owner) (the-as handle #f)) + (set! (-> obj pending-load-file-priority) 100000000.0) + ) + (when (= (-> obj status) 'initialize) + ((-> obj init-heap) obj) + (set! (-> obj status) 'inactive) + ) + (cond + ((-> obj load-file) + (if (= (-> obj status) 'loading) + (str-load-cancel) + ) + (set! (-> obj load-file) #f) + (set! (-> obj load-file-part) -1) + (set! (-> obj load-file-owner) (the-as handle #f)) + (set! (-> obj load-file-priority) 100000000.0) + ) + (else + (set! (-> obj load-file) (-> obj pending-load-file)) + (set! (-> obj load-file-part) (-> obj pending-load-file-part)) + (set! (-> obj load-file-owner) (-> obj pending-load-file-owner)) + (set! (-> obj load-file-priority) (-> obj pending-load-file-priority)) + ) + ) + ) + (label cfg-18) + (cond + ((-> obj load-file) + (case (-> obj status) + (('active 'reserved) + ) + (('error) + (set! (-> obj status) 'inactive) + (set! (-> obj load-file) #f) + (set! (-> obj load-file-part) -1) + (set! (-> obj load-file-owner) (the-as handle #f)) + (set! (-> obj load-file-priority) 100000000.0) + (set! (-> obj pending-load-file) #f) + (set! (-> obj pending-load-file-part) -1) + (set! (-> obj pending-load-file-owner) (the-as handle #f)) + (set! (-> obj pending-load-file-priority) 100000000.0) + (set! (-> obj art-group) #f) + ) + (('inactive) + (let ((v1-31 (-> obj heap))) + (set! (-> v1-31 current) (-> v1-31 base)) + ) + (cond + ((string= (-> obj load-file) "reserved") + (cond + ((-> *art-control* reserve-buffer) + (format 0 "ERROR: trying double reserve ~A when ~A is reserved~%" obj (-> *art-control* reserve-buffer)) + ) + (else + (set! (-> obj status) 'reserved) + (set! (-> *art-control* reserve-buffer) obj) + ) + ) + ) + ((and (!= (-> *level* loading-level) (-> *level* default-level)) (< 81920.0 (-> obj load-file-priority))) + ) + ((let ((v1-44 (logand -64 (&+ (-> obj heap current) 63)))) + (str-load (-> obj load-file) (-> obj load-file-part) v1-44 (&- (-> obj heap top) (the-as uint v1-44))) + ) + (set! (-> obj status) 'loading) + 0 + ) + ) + ) + (('loading) + (case (str-load-status (&-> obj len)) + (('error) + (set! (-> obj status) 'error) + ) + (('busy) + ) + (else + (set! (-> obj buf) (logand -64 (&+ (-> obj heap current) 63))) + (set! (-> obj status) 'loaded) + (goto cfg-18) + ) + ) + ) + (('loaded) + (let ((a0-34 (-> obj buf))) + (cond + ((-> obj login?) + (set! (-> obj art-group) (the-as art-group (link a0-34 (-> obj load-file data) (-> obj len) (-> obj heap) 0))) + (let ((s4-0 (-> obj art-group)) + (s3-0 (-> obj load-file)) + ) + (cond + ((not s4-0) + (format 0 "ERROR: art-group ~A part ~D is not a valid file.~%" s3-0 (-> obj load-file-part)) + (set! (-> obj status) 'error) + ) + ((not (type? s4-0 art-group)) + (format 0 "ERROR: art-group ~A part ~D is not a art-group.~%" s3-0 (-> obj load-file-part)) + (set! (-> obj status) 'error) + ) + ((not (file-info-correct-version? (-> s4-0 info) (file-kind art-group) 0)) + (set! (-> obj status) 'error) + ) + (else + (login s4-0) + (set! (-> obj status) 'locked) + ) + ) + ) + ) + (else + (set! (-> obj status) 'locked) + (set! (-> obj art-group) (the-as art-group a0-34)) + ) + ) + ) + ) + (('locked) + (when (and (not (-> obj locked?)) (handle->process (-> obj load-file-owner))) + (if (-> obj login?) + (link-file obj (-> obj art-group)) + ) + (if (-> obj other) + (set! (-> obj other locked?) #t) + ) + (set! (-> obj status) 'active) + (goto cfg-18) + ) + ) + ) + ) + (else + (case (-> obj status) + (('initialize) + ) + (('reserved) + (cond + ((= (-> *art-control* reserve-buffer) obj) + (set! (-> *art-control* reserve-buffer) #f) + (set! (-> obj status) 'inactive) + ) + (else + (format 0 "ERROR: trying tro free ~A when ~A is reserved~%" obj (-> *art-control* reserve-buffer)) + ) + ) + ) + (('active) + (if (-> obj login?) + (unlink-file obj (-> obj art-group)) + ) + (let ((v1-86 (-> obj heap))) + (set! (-> v1-86 current) (-> v1-86 base)) + ) + (set! (-> obj art-group) #f) + (set! (-> obj status) 'inactive) + (when (and (-> obj other) (-> obj other locked?)) + (unlock! (-> obj other)) + (update (-> obj other)) + ) + ) + (else + (let ((v1-96 (-> obj heap))) + (set! (-> v1-96 current) (-> v1-96 base)) + ) + (set! (-> obj art-group) #f) + (set! (-> obj status) 'inactive) + ) + ) + ) + ) + 0 + ) + +(define *preload-spool-anims* #t) + +(defmethod file-status external-art-control ((obj external-art-control) (arg0 string) (arg1 int)) + (dotimes (s3-0 2) + (let ((v1-3 (file-status (-> obj buffer s3-0) arg0 arg1))) + (if v1-3 + (return v1-3) + ) + ) + ) + #f + ) + +(defmethod update external-art-control ((obj external-art-control) (arg0 symbol)) + (if (nonzero? (-> obj reserve-buffer-count)) + (spool-push obj "reserved" 0 *dproc* (if (-> obj reserve-buffer) + -110.0 + -0.5 + ) + ) + ) + (dotimes (v1-5 2) + (set! (-> obj buffer v1-5 frame-lock) #f) + ) + (dotimes (v1-8 3) + (set! (-> obj rec v1-8 buffer) #f) + ) + (dotimes (s4-0 2) + (let ((s3-0 (-> obj rec s4-0))) + (when (-> s3-0 name) + (dotimes (s2-0 2) + (when (and (file-status (-> obj buffer s2-0) (-> s3-0 name) (the-as int (-> s3-0 parts))) + (not (-> obj buffer s2-0 frame-lock)) + ) + (set! (-> obj buffer s2-0 frame-lock) #t) + (set! (-> s3-0 buffer) (-> obj buffer s2-0)) + (set! (-> obj buffer s2-0 pending-load-file-owner) (-> s3-0 owner)) + (set! (-> obj buffer s2-0 load-file-owner) (-> s3-0 owner)) + (set! (-> obj buffer s2-0 pending-load-file-priority) (-> s3-0 priority)) + (set! (-> obj buffer s2-0 load-file-priority) (-> s3-0 priority)) + (goto cfg-24) + ) + ) + ) + ) + (label cfg-24) + ) + (dotimes (s4-1 2) + (let ((s3-1 (-> obj rec s4-1))) + (when (and (-> s3-1 name) (not (-> s3-1 buffer))) + (if (and (not *preload-spool-anims*) (>= (-> s3-1 priority) 0.0)) + (goto cfg-46) + ) + (dotimes (s2-1 2) + (when (not (-> obj buffer s2-1 frame-lock)) + (set! (-> obj buffer s2-1 frame-lock) #t) + (set-pending-file + (-> obj buffer s2-1) + (-> s3-1 name) + (the-as int (-> s3-1 parts)) + (-> s3-1 owner) + (-> s3-1 priority) + ) + (set! (-> s3-1 buffer) (-> obj buffer s2-1)) + (goto cfg-46) + ) + ) + ) + ) + (label cfg-46) + ) + (when (not (-> obj reserve-buffer)) + (let ((s4-2 (-> obj rec 0 buffer))) + (if (and s4-2 + (-> s4-2 locked?) + (not (string= (-> s4-2 pending-load-file) "reserved")) + (not (string= (-> s4-2 other pending-load-file) "reserved")) + ) + (set-pending-file (-> s4-2 other) (the-as string #f) -1 (the-as handle #f) 100000000.0) + ) + ) + ) + (dotimes (s4-3 2) + (update (-> obj buffer s4-3)) + ) + (let ((s4-4 (-> obj queue-stream))) + (set! (-> s4-4 length) 0) + (dotimes (s3-2 3) + (when (-> obj rec s3-2 name) + (mem-copy! (&-> (-> s4-4 (-> s4-4 length)) type) (&-> (-> obj rec s3-2) type) 44) + (+! (-> s4-4 length) 1) + ) + ) + ) + (when (and arg0 *display-art-control*) + (dotimes (s5-1 3) + (let ((t9-8 format) + (a0-27 *stdcon*) + (a1-8 "rec ~d ~S ~D ~f ~A~%") + (a2-5 s5-1) + (a3-3 (-> obj rec s5-1 name)) + (t0-3 (-> obj rec s5-1 parts)) + (t1-0 (-> obj rec s5-1 priority)) + (v1-121 (handle->process (-> obj rec s5-1 owner))) + ) + (t9-8 a0-27 a1-8 a2-5 a3-3 t0-3 t1-0 (if v1-121 + (-> v1-121 name) + ) + ) + ) + ) + (dotimes (s5-2 2) + (let ((t9-9 format) + (a0-28 *stdcon*) + (a1-9 "buf ~d ~C ~S ~D ~A ~A~%") + (a2-6 s5-2) + (a3-4 (if (-> obj buffer s5-2 locked?) + 108 + 32 + ) + ) + (t0-4 (-> obj buffer s5-2 pending-load-file)) + (t1-1 (-> obj buffer s5-2 pending-load-file-part)) + (t2-5 (-> obj buffer s5-2 status)) + (v1-142 (handle->process (-> obj buffer s5-2 pending-load-file-owner))) + ) + (t9-9 a0-28 a1-9 a2-6 a3-4 t0-4 t1-1 t2-5 (if v1-142 + (-> v1-142 name) + ) + ) + ) + ) + (format *stdcon* " a: ~S~%" (-> obj active-stream)) + ) + 0 + ) + +(defmethod none-reserved? external-art-control ((obj external-art-control)) + (zero? (-> obj reserve-buffer-count)) + ) + +(defmethod reserve-alloc external-art-control ((obj external-art-control)) + (cond + ((or (nonzero? (-> obj dma-reserve-buffer-count)) (= *master-mode* 'progress)) + (set! (-> obj dma-reserve-buffer-count) 1) + (when (and (-> *bigmap* drawing-flag) (zero? (-> *blit-displays-work* count-down))) + (let ((v1-8 (-> obj dma-reserve-heap))) + (set! (-> v1-8 base) (logand -64 (&+ (&+ (-> *display* frames 1 global-buf end) -252992) 63))) + (set! (-> v1-8 current) (-> v1-8 base)) + (set! (-> v1-8 top-base) (&+ (-> v1-8 base) #x3dc00)) + (set! (-> v1-8 top) (-> v1-8 top-base)) + ) + (set! (-> *display* frames 1 global-buf end) (-> obj dma-reserve-heap base)) + (-> obj dma-reserve-heap) + ) + ) + (else + (set! (-> obj reserve-buffer-count) 1) + (if (and (-> obj reserve-buffer) (not (check-busy *load-str-rpc*))) + (-> obj reserve-buffer heap) + ) + ) + ) + ) + +(defmethod reserve-free external-art-control ((obj external-art-control) (arg0 kheap)) + (cond + ((nonzero? (-> obj dma-reserve-buffer-count)) + (set! (-> obj dma-reserve-buffer-count) 0) + (let ((v1-3 (-> *display* frames 1 global-buf))) + (set! (-> v1-3 end) (&-> v1-3 data-buffer (-> v1-3 allocated-length))) + ) + ) + ((and (zero? (-> obj reserve-buffer-count)) (zero? (-> obj dma-reserve-buffer-count))) + (format 0 "ERROR: illegal attempt to free a buffer #x~X which had not been reserved (none reserved).~%" arg0) + ) + ((not (-> obj reserve-buffer)) + (set! (-> obj reserve-buffer-count) 0) + 0 + ) + ((= (-> obj reserve-buffer heap) arg0) + (set-pending-file (-> obj reserve-buffer) (the-as string #f) -1 (the-as handle #f) 100000000.0) + (update (-> obj reserve-buffer)) + (set! (-> obj reserve-buffer-count) 0) + 0 + ) + (else + (format 0 "ERROR: illegal attempt to free a buffer #x~X which had not been reserved (buffer unknown).~%" arg0) + ) + ) + 0 + ) + +(defmethod clear-rec external-art-control ((obj external-art-control)) + (dotimes (v1-0 3) + (set! (-> obj rec v1-0 type) spool-anim) + (set! (-> obj rec v1-0 name) #f) + (set! (-> obj rec v1-0 priority) 100000000.0) + (set! (-> obj rec v1-0 owner) (the-as handle #f)) + ) + (set! (-> obj frame-mask) (the-as uint (-> *setting-control* user-current process-mask))) + 0 + ) + +(defmethod spool-push external-art-control ((obj external-art-control) (arg0 string) (arg1 int) (arg2 process) (arg3 float)) + (when (and (= arg3 -99.0) arg2) + (let ((a0-2 (target-pos 0))) + (set! arg3 (vector-vector-distance a0-2 (-> (the-as process-drawable arg2) root trans))) + ) + ) + (cond + ((and (= arg1 (-> obj rec 0 parts)) (name= arg0 (-> obj rec 0 name))) + (if (>= arg3 (-> obj rec 0 priority)) + (return (the-as int #f)) + ) + (mem-copy! (&-> (-> obj rec) 0 type) (&-> (-> obj rec 1) type) 44) + (mem-copy! (&-> (-> obj rec 1) type) (&-> (-> obj rec 2) type) 44) + (set! (-> obj rec 2 name) #f) + (set! (-> obj rec 2 owner) (the-as handle #f)) + ) + ((and (= arg1 (-> obj rec 1 parts)) (name= arg0 (-> obj rec 1 name))) + (if (>= arg3 (-> obj rec 1 priority)) + (return (the-as int #f)) + ) + (mem-copy! (&-> (-> obj rec 1) type) (&-> (-> obj rec 2) type) 44) + (set! (-> obj rec 2 name) #f) + (set! (-> obj rec 2 owner) (the-as handle #f)) + ) + ((and (= arg1 (-> obj rec 2 parts)) (name= arg0 (-> obj rec 2 name))) + (if (>= arg3 (-> obj rec 2 priority)) + (return (the-as int #f)) + ) + (set! (-> obj rec 2 name) #f) + (set! (-> obj rec 2 owner) (the-as handle #f)) + ) + ) + (cond + ((< arg3 (-> obj rec 0 priority)) + (mem-copy! (&-> (-> obj rec 2) type) (&-> (-> obj rec 1) type) 44) + (mem-copy! (&-> (-> obj rec 1) type) (&-> (-> obj rec) 0 type) 44) + (set! (-> obj rec 0 name) arg0) + (set! (-> obj rec 0 parts) arg1) + (set! (-> obj rec 0 priority) arg3) + (set! (-> obj rec 0 owner) (process->handle arg2)) + ) + ((< arg3 (-> obj rec 1 priority)) + (mem-copy! (&-> (-> obj rec 2) type) (&-> (-> obj rec 1) type) 44) + (set! (-> obj rec 1 name) arg0) + (set! (-> obj rec 1 parts) arg1) + (set! (-> obj rec 1 priority) arg3) + (set! (-> obj rec 1 owner) (process->handle arg2)) + ) + ((< arg3 (-> obj rec 2 priority)) + (set! (-> obj rec 2 name) arg0) + (set! (-> obj rec 2 parts) arg1) + (set! (-> obj rec 2 priority) arg3) + (set! (-> obj rec 2 owner) (process->handle arg2)) + ) + ) + 0 + ) + +(deftype spooler-block (basic) + ((anim spool-anim :offset-assert 4) + (idle art-joint-anim :offset-assert 8) + (exit art-joint-anim :offset-assert 12) + (break-func (function process-drawable object) :offset-assert 16) + (part int32 :offset-assert 20) + (part-audio-start float :offset-assert 24) + (old-status uint16 :offset-assert 28) + (old-pos int32 :offset-assert 32) + (good-time time-frame :offset-assert 40) + (old-time time-frame :offset-assert 48) + (good-count int32 :offset-assert 56) + (sid sound-id :offset-assert 60) + (real-start-time time-frame :offset-assert 64) + (paused? symbol :offset-assert 72) + ) + :method-count-assert 9 + :size-assert #x4c + :flag-assert #x90000004c + (:methods + (new (symbol type art-joint-anim (function process-drawable symbol)) _type_ 0) + ) + ) + + +(define-extern ja-abort-spooled-anim (function spool-anim art-joint-anim int int :behavior process-drawable)) +(defbehavior ja-play-spooled-anim process-drawable ((arg0 spool-anim) (arg1 art-joint-anim) (arg2 art-joint-anim) (arg3 (function process-drawable symbol))) + (local-vars (v0-59 int) (sv-176 int)) + (let ((s2-0 arg2) + (s1-0 arg3) + (gp-0 (new 'stack 'spooler-block arg2 arg3)) + ) + (let ((s5-0 gp-0)) + (set! (-> s5-0 anim) arg0) + (set! (-> s5-0 idle) arg1) + (set! (-> s5-0 exit) s2-0) + (set! (-> s5-0 break-func) s1-0) + (set! (-> s5-0 part-audio-start) -17.0) + (set! (-> s5-0 old-status) (the-as uint (-> self skel status))) + (set! (-> s5-0 old-pos) -2) + (set! (-> s5-0 sid) (new-sound-id)) + (set! (-> s5-0 paused?) #f) + ) + (let ((v1-7 + (gui-control-method-15 *gui-control* self (gui-channel art-load) (-> gp-0 anim name) (new 'static 'sound-id)) + ) + ) + (if v1-7 + (set! (-> gp-0 sid) (-> v1-7 id)) + ) + ) + (if (!= self *target*) + (send-event *target* 'movie) + ) + (backup-load-state-and-set-cmds *load-state* (-> gp-0 anim command-list)) + (logior! (-> self skel status) (joint-control-status sync-math spooling spooling-not-last-block)) + (talker-surpress!) + (apply-settings *setting-control*) + (when (or (and (-> *setting-control* user-current spooling) + (or (< 2 (the-as int (-> gp-0 anim parts))) + (not (string= (-> *setting-control* user-current spool-anim name) (-> gp-0 anim name))) + ) + ) + (logtest? (-> *art-control* frame-mask) 28) + (!= *master-mode* 'game) + ) + (cond + ((-> gp-0 idle) + (when (!= (ja-group) (-> gp-0 idle)) + (ja-channel-push! 1 (seconds 0.05)) + (ja :group! (-> gp-0 idle) :num! min) + ) + ) + (else + (ja-channel-set! 0) + ) + ) + (while (or (and (-> *setting-control* user-current spooling) + (or (< 2 (the-as int (-> gp-0 anim parts))) + (not (string= (-> *setting-control* user-current spool-anim name) (-> gp-0 anim name))) + ) + ) + (logtest? (-> *art-control* frame-mask) 28) + (!= *master-mode* 'game) + ) + (format #t "WARNING: ---------------------> loader stall on lock~%") + (if ((-> gp-0 break-func) self) + (goto cfg-130) + ) + (gui-control-method-12 + *gui-control* + self + (gui-channel art-load) + (gui-action queue) + (-> gp-0 anim name) + (-> gp-0 part) + -9.0 + (-> gp-0 sid) + ) + (suspend) + (if (-> gp-0 idle) + (ja :num! (loop!)) + ) + ) + ) + (set-setting! 'spooling (process->ppointer self) 0 0) + (set-setting! 'spool-anim (-> gp-0 anim) 0 0) + (apply-settings *setting-control*) + (set! (-> gp-0 old-time) (-> self clock frame-counter)) + (while (< (-> gp-0 part) (the-as int (-> gp-0 anim parts))) + (when (> (-> gp-0 part) 0) + (while (let ((v1-99 (file-status *art-control* (-> gp-0 anim name) (-> gp-0 part)))) + (not (or (= v1-99 'active) (= v1-99 'locked))) + ) + (if ((-> gp-0 break-func) self) + (goto cfg-130) + ) + (gui-control-method-12 + *gui-control* + self + (gui-channel art-load) + (gui-action queue) + (-> gp-0 anim name) + (+ (-> gp-0 part) -1) + -20.0 + (-> gp-0 sid) + ) + (gui-control-method-12 + *gui-control* + self + (gui-channel art-load) + (gui-action queue) + (-> gp-0 anim name) + (-> gp-0 part) + -10.0 + (-> gp-0 sid) + ) + (when (and (not (-> gp-0 paused?)) (< (-> *setting-control* user-current movie-skip-frame) 0.0)) + (format + #t + "WARNING: ---------------------> loader pre stall on art ~S ~D ~A~%" + (-> gp-0 anim name) + (-> gp-0 part) + (file-status *art-control* (-> gp-0 anim name) (-> gp-0 part)) + ) + (set! (-> gp-0 paused?) #t) + (if (nonzero? (-> gp-0 part)) + (sound-pause (-> gp-0 sid)) + ) + ) + (suspend) + ) + ) + (gui-control-method-12 + *gui-control* + self + (gui-channel art-load) + (gui-action queue) + (-> gp-0 anim name) + (-> gp-0 part) + -20.0 + (-> gp-0 sid) + ) + (update *gui-control* #f) + (update *art-control* #f) + (gui-control-method-12 + *gui-control* + self + (gui-channel art-load) + (gui-action queue) + (-> gp-0 anim name) + (-> gp-0 part) + -20.0 + (-> gp-0 sid) + ) + (when (!= (file-status *art-control* (-> gp-0 anim name) (-> gp-0 part)) 'active) + (cond + ((-> gp-0 idle) + (when (!= (ja-group) (-> gp-0 idle)) + (ja-channel-set! 1) + (ja :group! (-> gp-0 idle) :num! min) + ) + ) + (else + (ja-channel-set! 0) + ) + ) + (while (!= (file-status *art-control* (-> gp-0 anim name) (-> gp-0 part)) 'active) + (if ((-> gp-0 break-func) self) + (goto cfg-130) + ) + (gui-control-method-12 + *gui-control* + self + (gui-channel art-load) + (gui-action queue) + (-> gp-0 anim name) + (-> gp-0 part) + -20.0 + (-> gp-0 sid) + ) + (when (not (-> gp-0 paused?)) + (format + #t + "WARNING: ---------------------> loader stall on art ~S ~D ~A~%" + (-> gp-0 anim name) + (-> gp-0 part) + (file-status *art-control* (-> gp-0 anim name) (-> gp-0 part)) + ) + (set! (-> gp-0 paused?) #t) + (if (nonzero? (-> gp-0 part)) + (sound-pause (-> gp-0 sid)) + ) + ) + (suspend) + (if (-> gp-0 idle) + (ja :num! (loop!)) + ) + ) + ) + (when (-> gp-0 paused?) + (set! (-> gp-0 paused?) #f) + (sound-continue (-> gp-0 sid)) + (format + #t + "WARNING: ---------------------> loader release lock on art ~S ~D ~A~%" + (-> gp-0 anim name) + (-> gp-0 part) + (file-status *art-control* (-> gp-0 anim name) (-> gp-0 part)) + ) + ) + (gui-control-method-12 + *gui-control* + self + (gui-channel art-load) + (gui-action queue) + (-> gp-0 anim name) + (-> gp-0 part) + -20.0 + (-> gp-0 sid) + ) + (let ((s5-8 (get-art-by-name (-> self draw art-group) (the-as string (-> gp-0 anim buffer)) art-joint-anim))) + (cond + (s5-8 + (ja-channel-set! 1) + (ja-no-eval :group! s5-8 :num! (seek! (the float (+ (-> s5-8 frames num-frames) -1))) :frame-num 0.0) + (when (zero? (-> gp-0 part)) + (str-play-async (-> gp-0 anim name) (-> gp-0 sid)) + (set! (-> *art-control* active-stream) (-> gp-0 anim name)) + ) + (let* ((f30-0 (* 0.05859375 (-> s5-8 speed))) + (f28-0 (+ (-> gp-0 part-audio-start) (/ (the float (+ (-> s5-8 frames num-frames) -1)) f30-0))) + ) + (set! sv-176 (current-str-pos (-> gp-0 sid))) + (set! (-> gp-0 good-time) (-> self clock frame-counter)) + (until (>= (the float v0-59) f28-0) + (if (= (-> self skel root-channel 0) (-> self skel channel)) + (logior! (-> self skel status) (joint-control-status valid-spooled-frame)) + ) + (if (or ((-> gp-0 break-func) self) + (and (<= sv-176 0) (>= (- (-> self clock frame-counter) (-> gp-0 good-time)) (seconds 4))) + (and (< 300 (-> gp-0 good-count)) (<= sv-176 0)) + ) + (goto cfg-130) + ) + (gui-control-method-12 + *gui-control* + self + (gui-channel art-load) + (gui-action queue) + (-> gp-0 anim name) + (-> gp-0 part) + -20.0 + (-> gp-0 sid) + ) + (if (< (+ (-> gp-0 part) 1) (the-as int (-> gp-0 anim parts))) + (gui-control-method-12 + *gui-control* + self + (gui-channel art-load) + (gui-action queue) + (-> gp-0 anim name) + (+ (-> gp-0 part) 1) + -10.0 + (-> gp-0 sid) + ) + (logclear! (-> self skel status) (joint-control-status spooling-not-last-block)) + ) + (execute-commands-up-to *load-state* (ja-aframe-num 0)) + (cond + ((and (< (-> gp-0 old-pos) sv-176) (< -1 sv-176)) + (+! (-> gp-0 good-count) (- (-> self clock frame-counter) (-> self clock old-frame-counter))) + (set! (-> gp-0 good-time) (-> self clock frame-counter)) + ) + (else + 0 + ) + ) + (set! (-> gp-0 old-pos) sv-176) + (set! (-> gp-0 old-time) (-> self clock frame-counter)) + (suspend) + (let* ((f26-0 (* (- (the float (current-str-pos (-> gp-0 sid))) (-> gp-0 part-audio-start)) f30-0)) + (f0-16 (if (str-id-is-playing? (the-as int (-> gp-0 sid))) + (fmax 0.0 (fmin f26-0 (the float (+ (-> (ja-group) frames num-frames) -1)))) + (fmax 0.0 (fmin (ja-frame-num 0) (the float (+ (-> (ja-group) frames num-frames) -1)))) + ) + ) + ) + (ja-no-eval :num! (seek!) :frame-num f0-16) + ) + (set! v0-59 (current-str-pos (-> gp-0 sid))) + (set! sv-176 v0-59) + ) + (set! (-> gp-0 part-audio-start) f28-0) + ) + (logclear! (-> self skel status) (joint-control-status valid-spooled-frame)) + ) + (else + (format + 0 + "ERROR: ~A in spool anim loop for ~A ~D, but not loaded.~" + self + (-> gp-0 anim name) + (-> gp-0 part) + ) + (goto cfg-130) + ) + ) + ) + (+! (-> gp-0 part) 1) + ) + (+! (-> gp-0 part) -1) + (label cfg-130) + (ja-abort-spooled-anim (-> gp-0 anim) (-> gp-0 exit) (-> gp-0 part)) + ) + 0 + ) + +(defbehavior ja-abort-spooled-anim process-drawable ((arg0 spool-anim) (arg1 art-joint-anim) (arg2 int)) + (let ((s3-0 (new 'static 'sound-id))) + (let ((v1-1 + (gui-control-method-15 *gui-control* self (gui-channel art-load) (-> arg0 name) (new 'static 'sound-id)) + ) + ) + (when v1-1 + (set! s3-0 (-> v1-1 id)) + (set! (-> v1-1 action) (gui-action abort)) + ) + ) + (if (zero? s3-0) + (return (the-as int #f)) + ) + (str-play-stop (-> arg0 name) s3-0) + ) + (restore-load-state-and-cleanup *load-state*) + (set! (-> *art-control* active-stream) #f) + (logclear! (-> self skel status) (joint-control-status spooling spooling-not-last-block)) + (if (zero? (logand (-> self skel status) (joint-control-status sync-math))) + (logclear! (-> self skel status) (joint-control-status sync-math)) + ) + (cond + ((and arg1 (>= arg2 0)) + (ja-channel-push! 1 (seconds 0.03)) + (set! (-> self skel root-channel 0 frame-group) arg1) + (while (!= (-> self skel root-channel 0) (-> self skel channel)) + (gui-control-method-12 + *gui-control* + self + (gui-channel art-load) + (gui-action queue) + (-> arg0 name) + arg2 + -20.0 + (new 'static 'sound-id) + ) + (suspend) + (ja :num! (seek!)) + ) + ) + (else + (ja-channel-set! 0) + ) + ) + (remove-setting! 'spooling) + (remove-setting! 'spool-anim) + 0 + ) + + +(defmethod print gui-connection ((obj gui-connection)) + (let* ((t9-0 format) + (a0-1 #t) + (a1-0 "# obj name)) + (a3-0 (-> obj anim-part)) + (t0-0 (-> obj id)) + (t1-0 (-> obj priority)) + (v1-0 (-> obj channel)) + (t2-1 (cond + ((= v1-0 (gui-channel hud-lower-left)) + "hud-lower-left" + ) + ((= v1-0 (gui-channel citizen)) + "citizen" + ) + ((= v1-0 (gui-channel ashelin)) + "ashelin" + ) + ((= v1-0 (gui-channel hud-lower-left-1)) + "hud-lower-left-1" + ) + ((= v1-0 (gui-channel message)) + "message" + ) + ((= v1-0 (gui-channel hud-middle-left)) + "hud-middle-left" + ) + ((= v1-0 (gui-channel hud-upper-center-2)) + "hud-upper-center-2" + ) + ((= v1-0 (gui-channel hud-middle-right)) + "hud-middle-right" + ) + ((= v1-0 (gui-channel subtitle)) + "subtitle" + ) + ((= v1-0 (gui-channel notice)) + "notice" + ) + ((= v1-0 (gui-channel voicebox)) + "voicebox" + ) + ((= v1-0 (gui-channel art-load-next)) + "art-load-next" + ) + ((= v1-0 (gui-channel mog)) + "mog" + ) + ((= v1-0 (gui-channel sig)) + "sig" + ) + ((= v1-0 (gui-channel hud-center-left)) + "hud-center-left" + ) + ((= v1-0 (gui-channel hud-upper-right)) + "hud-upper-right" + ) + ((= v1-0 (gui-channel hud-center-right)) + "hud-center-right" + ) + ((= v1-0 (gui-channel alert)) + "alert" + ) + ((= v1-0 (gui-channel jinx)) + "jinx" + ) + ((= v1-0 (gui-channel hud-upper-left)) + "hud-upper-left" + ) + ((= v1-0 (gui-channel query)) + "query" + ) + ((= v1-0 (gui-channel grim)) + "grim" + ) + ((= v1-0 (gui-channel kor)) + "kor" + ) + ((= v1-0 (gui-channel hud-lower-right)) + "hud-lower-right" + ) + ((= v1-0 (gui-channel screen)) + "screen" + ) + ((= v1-0 (gui-channel guard)) + "guard" + ) + ((= v1-0 (gui-channel supertitle)) + "supertitle" + ) + ((= v1-0 (gui-channel hal)) + "hal" + ) + ((= v1-0 (gui-channel hud-upper-center)) + "hud-upper-center" + ) + ((= v1-0 (gui-channel blackout)) + "blackout" + ) + ((= v1-0 (gui-channel bbush)) + "bbush" + ) + ((= v1-0 (gui-channel hud)) + "hud" + ) + ((= v1-0 (gui-channel voice)) + "voice" + ) + ((= v1-0 (gui-channel max)) + "max" + ) + ((= v1-0 (gui-channel none)) + "none" + ) + ((= v1-0 (gui-channel notice-low)) + "notice-low" + ) + ((= v1-0 (gui-channel art-load)) + "art-load" + ) + ((= v1-0 (gui-channel kid)) + "kid" + ) + ((= v1-0 (gui-channel jak)) + "jak" + ) + ((= v1-0 (gui-channel daxter)) + "daxter" + ) + ((= v1-0 (gui-channel krew)) + "krew" + ) + ((= v1-0 (gui-channel hud-lower-left-2)) + "hud-lower-left-2" + ) + ((= v1-0 (gui-channel background)) + "background" + ) + ((= v1-0 (gui-channel crocadog)) + "crocadog" + ) + ((= v1-0 (gui-channel movie)) + "movie" + ) + (else + "*unknown*" + ) + ) + ) + (v1-1 (-> obj action)) + ) + (t9-0 a0-1 a1-0 a2-0 a3-0 t0-0 t1-0 t2-1 (cond + ((= v1-1 (gui-action queue)) + "queue" + ) + ((= v1-1 (gui-action stop)) + "stop" + ) + ((= v1-1 (gui-action play)) + "play" + ) + ((= v1-1 (gui-action hide)) + "hide" + ) + ((= v1-1 (gui-action fade)) + "fade" + ) + ((= v1-1 (gui-action none)) + "none" + ) + ((= v1-1 (gui-action abort)) + "abort" + ) + ((= v1-1 (gui-action stopping)) + "stopping" + ) + ((= v1-1 (gui-action hidden)) + "hidden" + ) + ((= v1-1 (gui-action playing)) + "playing" + ) + (else + "*unknown*" + ) + ) + ) + ) + (let ((s5-0 format) + (s4-0 #t) + (s3-0 " ~6S <@ #x~A>") + (v1-3 (gui-control-method-17 *gui-control* (-> obj id))) + ) + (s5-0 + s4-0 + s3-0 + (cond + ((= v1-3 (gui-action play)) + "ready" + ) + ((= v1-3 (gui-action playing)) + "active" + ) + ((= v1-3 (gui-action stopping)) + "stop" + ) + ((= v1-3 (gui-action none)) + "unknown" + ) + ((= v1-3 (gui-action stop)) + "hide" + ) + ((= v1-3 (gui-action queue)) + "pending" + ) + (else + "*unknown*" + ) + ) + obj + ) + ) + obj + ) + +(defmethod channel-id-set! gui-control ((obj gui-control) (arg0 gui-connection) (arg1 sound-id)) + (set! (-> obj ids (-> arg0 channel)) arg1) + 0 + ) + +(defmethod gui-control-method-15 gui-control ((obj gui-control) (arg0 process) (arg1 gui-channel) (arg2 string) (arg3 sound-id)) + (let ((s1-0 (the-as gui-connection (-> obj engine alive-list next0)))) + (-> obj engine) + (let ((s0-0 (-> s1-0 next0))) + (while (!= s1-0 (-> obj engine alive-list-end)) + (if (and (or (= arg1 (gui-channel none)) (= (-> s1-0 channel) arg1)) + (or (not arg0) (= (-> arg0 type) scene-player) (= arg0 (get-process s1-0))) + (or (not arg2) (string= arg2 (-> s1-0 name))) + (or (zero? arg3) (= (-> s1-0 id) arg3)) + ) + (return s1-0) + ) + (set! s1-0 (the-as gui-connection s0-0)) + (-> obj engine) + (set! s0-0 (-> s0-0 next0)) + ) + ) + ) + (countdown (s1-1 32) + (let ((s0-1 (-> obj connections s1-1))) + (if (and (nonzero? (-> s0-1 id)) + (or (= arg1 (gui-channel none)) (= (-> s0-1 channel) arg1)) + (and (or (not arg0) (= (-> arg0 type) scene-player) (= arg0 (handle->process (-> s0-1 handle)))) + (or (not arg2) (string= arg2 (-> s0-1 name))) + (or (zero? arg3) (= (-> s0-1 id) arg3)) + ) + ) + (return s0-1) + ) + ) + ) + (the-as gui-connection #f) + ) + +(defmethod gui-control-method-14 gui-control ((obj gui-control) (arg0 string) (arg1 gui-channel) (arg2 gui-action)) + (let ((s2-0 (the-as gui-connection (-> obj engine alive-list next0)))) + (-> obj engine) + (let ((s1-0 (-> s2-0 next0))) + (while (!= s2-0 (-> obj engine alive-list-end)) + (if (and (or (= arg1 (gui-channel none)) (= arg1 (-> s2-0 channel))) + (or (= arg2 (gui-action none)) (= arg2 (-> s2-0 action))) + (or (not arg0) (string= arg0 (-> s2-0 name))) + ) + (return (the-as int (-> s2-0 id))) + ) + (set! s2-0 (the-as gui-connection s1-0)) + (-> obj engine) + (set! s1-0 (-> s1-0 next0)) + ) + ) + ) + (countdown (s2-1 32) + (let ((s1-1 (-> obj connections s2-1))) + (if (and (nonzero? (-> s1-1 id)) + (or (= arg1 (gui-channel none)) (= arg1 (-> s1-1 channel))) + (or (= arg2 (gui-action none)) (= arg2 (-> s1-1 action))) + (or (not arg0) (string= arg0 (-> s1-1 name))) + ) + (return (the-as int (-> s1-1 id))) + ) + ) + ) + 0 + ) + +(defmethod gui-control-method-20 gui-control ((obj gui-control) (arg0 sound-id) (arg1 symbol) (arg2 int) (arg3 int) (arg4 int)) + (when (nonzero? arg0) + (let ((v1-2 (gui-control-method-15 *gui-control* (the-as process #f) (gui-channel none) (the-as string #f) arg0))) + (when v1-2 + (if arg1 + (logior! (-> v1-2 flags) 2) + ) + (when (>= arg2 0) + (logior! (-> v1-2 flags) 8) + (set! (-> v1-2 fo-min) arg2) + ) + (when (>= arg3 0) + (logior! (-> v1-2 flags) 16) + (set! (-> v1-2 fo-max) arg3) + ) + (when (>= arg4 0) + (logior! (-> v1-2 flags) 4) + (set! (-> v1-2 fo-curve) arg4) + ) + v1-2 + ) + ) + ) + ) + +;; WARN: disable def twice: 34. This may happen when a cond (no else) is nested inside of another conditional, but it should be rare. +(defmethod gui-control-method-18 gui-control ((obj gui-control) (arg0 gui-channel)) + (let ((v1-0 arg0)) + (the-as + symbol + (cond + ((or (= v1-0 (gui-channel message)) (= v1-0 (gui-channel notice)) (= v1-0 (gui-channel notice-low))) + (not (or (logtest? (-> *art-control* frame-mask) 28) (!= *master-mode* 'game))) + ) + ((= v1-0 (gui-channel query)) + (and (not (or (logtest? (-> *art-control* frame-mask) 28) (!= *master-mode* 'game))) + (and *target* (zero? (logand (-> *target* focus-status) (focus-status fs1 fs6)))) + ) + ) + (else + #t + ) + ) + ) + ) + ) + +(defmethod gui-control-method-23 gui-control ((obj gui-control) (arg0 gui-channel) (arg1 gui-channel) (arg2 symbol) (arg3 gui-connection)) + (let ((s5-0 (-> obj ids arg1))) + (cond + ((nonzero? s5-0) + (case arg2 + (('wait) + (if (nonzero? (gui-control-method-17 obj s5-0)) + (return #f) + ) + ) + (('stop 'priority-stop) + (when (nonzero? (-> obj ids arg1)) + (let ((s2-0 (gui-control-method-15 obj (the-as process #f) arg1 (the-as string #f) s5-0))) + (when (and s2-0 (or (= arg2 'priority) (= s2-0 arg3) (and arg3 (< (-> arg3 priority) (-> s2-0 priority))))) + (gui-control-method-11 obj s2-0) + (cond + ((= (shr (the-as int arg1) 4) 5) + (set! (-> obj times arg1) + (the-as time-frame (max (-> obj times arg1) (+ (-> *display* base-clock frame-counter) (seconds 0.1)))) + ) + (set! (-> s2-0 action) (gui-action hidden)) + ) + ((= arg1 (gui-channel query)) + (set! (-> s2-0 action) (gui-action play)) + ) + (else + (set! (-> s2-0 action) (gui-action hidden)) + ) + ) + ) + ) + ) + (if (nonzero? (gui-control-method-17 obj s5-0)) + (return #f) + ) + ) + (('hide) + (let ((v1-34 (gui-control-method-15 obj (the-as process #f) arg1 (the-as string #f) s5-0))) + (when (and v1-34 (!= (-> v1-34 action) 8)) + (gui-control-method-16 + obj + (gui-action hide) + s5-0 + (gui-channel none) + (gui-action none) + (the-as string #f) + (the-as (function gui-connection symbol) #f) + (the-as process #f) + ) + (set! (-> obj times arg1) + (the-as time-frame (max (-> obj times arg1) (+ (-> *display* base-clock frame-counter) (seconds 0.1)))) + ) + ) + ) + (if (nonzero? (gui-control-method-17 obj s5-0)) + (return #f) + ) + ) + ) + ) + ((< (-> *display* base-clock frame-counter) (-> obj times arg1)) + (if (= arg2 'wait) + (return #f) + ) + ) + ) + ) + #t + ) + +(defmethod gui-control-method-19 gui-control ((obj gui-control) (arg0 gui-channel) (arg1 gui-connection)) + (local-vars (sv-16 int) (sv-32 int) (sv-48 int)) + (let ((gp-0 #t)) + (cond + ((or (not (gui-control-method-18 obj arg0)) (< (-> *display* base-clock frame-counter) (-> obj times arg0))) + #f + ) + ((not (null? (-> obj cmd arg0))) + (let* ((s2-0 (-> obj cmd arg0)) + (v1-9 (car s2-0)) + ) + (while (not (null? s2-0)) + (let ((a2-1 (the-as gui-channel (/ (the-as int (car v1-9)) 8))) + (s1-0 (cdr v1-9)) + ) + (case a2-1 + (((gui-channel hud)) + (let ((s0-0 80)) + (set! sv-16 90) + (while (>= (the-as uint sv-16) (the-as uint s0-0)) + (if (not (gui-control-method-23 obj arg0 (the-as gui-channel s0-0) (the-as symbol s1-0) arg1)) + (set! gp-0 #f) + ) + (+! s0-0 1) + ) + ) + ) + (((gui-channel screen)) + (let ((s0-1 66)) + (set! sv-32 70) + (while (>= (the-as uint sv-32) (the-as uint s0-1)) + (if (not (gui-control-method-23 obj arg0 (the-as gui-channel s0-1) (the-as symbol s1-0) arg1)) + (set! gp-0 #f) + ) + (+! s0-1 1) + ) + ) + ) + (((gui-channel voice)) + (let ((s0-2 18)) + (set! sv-48 32) + (while (>= (the-as uint sv-48) (the-as uint s0-2)) + (if (not (gui-control-method-23 obj arg0 (the-as gui-channel s0-2) (the-as symbol s1-0) arg1)) + (set! gp-0 #f) + ) + (+! s0-2 1) + ) + ) + ) + (else + (if (not (gui-control-method-23 obj arg0 a2-1 (the-as symbol s1-0) arg1)) + (set! gp-0 #f) + ) + ) + ) + ) + (set! s2-0 (cdr s2-0)) + (set! v1-9 (car s2-0)) + ) + ) + gp-0 + ) + ) + ) + ) + +(defmethod gui-control-method-17 gui-control ((obj gui-control) (arg0 sound-id)) + (let ((gp-0 (the-as gui-connection #f))) + (if (zero? arg0) + (return (gui-action none)) + ) + (let ((v1-4 (-> obj engine alive-list next0))) + (-> obj engine) + (let ((a0-3 (-> v1-4 next0))) + (while (!= v1-4 (-> obj engine alive-list-end)) + (when (= arg0 (-> (the-as gui-connection v1-4) id)) + (set! gp-0 (the-as gui-connection v1-4)) + (goto cfg-15) + ) + (set! v1-4 a0-3) + (-> obj engine) + (set! a0-3 (-> a0-3 next0)) + ) + ) + ) + #t + (countdown (v1-10 32) + (let ((a0-7 (-> obj connections v1-10))) + (when (= arg0 (-> a0-7 id)) + (set! gp-0 a0-7) + (goto cfg-15) + ) + ) + ) + (label cfg-15) + (the-as + gui-action + (cond + ((= (-> gp-0 channel) (gui-channel movie)) + (cond + ((= (-> gp-0 id) (-> obj ids (-> gp-0 channel))) + 3 + ) + ((gui-control-method-19 obj (-> gp-0 channel) gp-0) + 2 + ) + (else + 1 + ) + ) + ) + ((let ((v1-22 (shr (the-as int (-> gp-0 channel)) 4))) + (or (= v1-22 1) (= v1-22 2)) + ) + (case (-> gp-0 action) + (((gui-action queue) (gui-action play) (gui-action playing) (gui-action fade) (gui-action stop)) + (cond + (gp-0 + (dotimes (s4-0 4) + (when (and (string-charp= (-> gp-0 name) (the-as (pointer uint8) (-> *sound-iop-info* stream-name s4-0))) + (or (= (-> gp-0 id) (-> *sound-iop-info* stream-id s4-0)) (zero? (-> *sound-iop-info* stream-id s4-0))) + (logtest? (-> *sound-iop-info* stream-status s4-0) (stream-status ststatus-one ststatus-six)) + (if (and (>= (the-as uint (-> gp-0 channel)) (the-as uint 16)) + (>= (the-as uint 17) (the-as uint (-> gp-0 channel))) + ) + (= (file-status *art-control* (-> gp-0 name) (the-as int (-> gp-0 anim-part))) 'active) + #t + ) + ) + (cond + ((logtest? (-> *sound-iop-info* stream-status s4-0) (stream-status ststatus-four)) + (return (gui-action playing)) + ) + ((logtest? (-> *sound-iop-info* stream-status s4-0) (stream-status ststatus-nine)) + (return (gui-action stopping)) + ) + ((or (= (-> gp-0 id) (-> obj ids (-> gp-0 channel))) (gui-control-method-19 obj (-> gp-0 channel) gp-0)) + (return (gui-action play)) + ) + (else + (return (gui-action queue)) + ) + ) + (the-as none 0) + ) + ) + 1 + ) + (else + 0 + ) + ) + ) + (else + 0 + ) + ) + ) + ((= (shr (the-as int (-> gp-0 channel)) 4) 5) + (cond + ((= (-> gp-0 id) (-> obj ids (-> gp-0 channel))) + (if (or (= (-> gp-0 action) (gui-action hide)) (= (-> gp-0 action) (gui-action hidden))) + 4 + 3 + ) + ) + ((gui-control-method-19 obj (-> gp-0 channel) gp-0) + 2 + ) + (else + 1 + ) + ) + ) + (else + (case (shr (the-as int (-> gp-0 channel)) 4) + ((4 5) + (cond + ((= (-> gp-0 id) (-> obj ids (-> gp-0 channel))) + 3 + ) + ((gui-control-method-19 obj (-> gp-0 channel) gp-0) + 2 + ) + (else + 1 + ) + ) + ) + (else + 0 + ) + ) + ) + ) + ) + ) + ) + +(defmethod gui-control-method-16 gui-control ((obj gui-control) + (arg0 gui-action) + (arg1 sound-id) + (arg2 gui-channel) + (arg3 gui-action) + (arg4 string) + (arg5 (function gui-connection symbol)) + (arg6 process) + ) + (local-vars (sv-16 gui-action) (sv-17 gui-action) (sv-20 string) (sv-24 (function gui-connection symbol))) + (set! sv-16 arg0) + (set! sv-17 arg3) + (set! sv-20 arg4) + (set! sv-24 arg5) + (let ((s1-0 (the-as gui-connection (-> obj engine alive-list next0)))) + (-> obj engine) + (let ((s0-0 (-> s1-0 next0))) + (while (!= s1-0 (-> obj engine alive-list-end)) + (when (and (or (= arg1 1) (= arg1 (-> s1-0 id))) + (or (= arg2 (gui-channel none)) (= arg2 (-> s1-0 channel))) + (or (= sv-17 (gui-action none)) (= sv-17 (-> s1-0 action))) + (or (not sv-20) (string= sv-20 (-> s1-0 name))) + (or (not arg5) (arg5 s1-0)) + (or (not arg6) (= arg6 (get-process s1-0))) + ) + (cond + ((and (= sv-16 (gui-action hide)) (!= (-> obj ids (-> s1-0 channel)) (-> s1-0 id))) + (set! (-> s1-0 action) (gui-action hidden)) + ) + ((and (= sv-16 (gui-action play)) (= (-> s1-0 action) (gui-action playing))) + ) + (else + (set! (-> s1-0 action) sv-16) + (if (and (= sv-16 'play) (gui-control-method-19 obj (-> s1-0 channel) s1-0)) + (channel-id-set! obj s1-0 (-> s1-0 id)) + ) + ) + ) + ) + (set! s1-0 (the-as gui-connection s0-0)) + (-> obj engine) + (set! s0-0 (-> s0-0 next0)) + ) + ) + ) + 0 + ) + +(defmethod gui-control-method-9 gui-control ((obj gui-control) + (arg0 process) + (arg1 gui-channel) + (arg2 gui-action) + (arg3 int) + (arg4 float) + (arg5 time-frame) + ) + (local-vars + (sv-16 int) + (sv-20 gui-connection) + (sv-32 gui-connection) + (sv-48 gui-connection) + (sv-64 gui-connection) + (sv-80 int) + ) + (set! sv-32 (the-as gui-connection #f)) + (set! sv-48 (the-as gui-connection (-> obj engine alive-list next0))) + (-> obj engine) + (set! sv-64 (the-as gui-connection (-> sv-48 next0))) + (while (!= sv-48 (-> obj engine alive-list-end)) + (when (and (= arg1 (-> (the-as gui-connection sv-48) channel)) + (string= (the-as string arg3) (-> (the-as gui-connection sv-48) name)) + (= (get-process sv-48) arg0) + ) + (set! sv-32 (the-as gui-connection sv-48)) + (goto cfg-12) + ) + (set! sv-48 (the-as gui-connection sv-64)) + (-> obj engine) + (set! sv-64 (the-as gui-connection (-> sv-64 next0))) + ) + (label cfg-12) + (when (not sv-32) + (set! sv-16 0) + (set! sv-80 32) + (while (nonzero? sv-80) + (set! sv-80 (+ sv-80 -1)) + (set! sv-20 (-> obj connections sv-80)) + (if (and (nonzero? (-> sv-20 id)) + (= arg1 (-> sv-20 channel)) + (string= (the-as string arg3) (-> sv-20 name)) + (>= (-> sv-20 priority) -1.0) + ) + (set! sv-16 (the-as int (-> sv-20 id))) + ) + ) + (if (zero? sv-16) + (set! sv-16 (the-as int (new-sound-id))) + ) + (set! sv-32 (the-as gui-connection (add-connection (-> obj engine) arg0 arg4 0 arg3 sv-16))) + sv-32 + ) + (the-as sound-id (cond + (sv-32 + (set! (-> sv-32 priority) arg4) + (set! (-> sv-32 channel) arg1) + (set! (-> sv-32 action) arg2) + (set! (-> sv-32 param2) arg3) + (set! (-> sv-32 hold-time) arg5) + (set! (-> sv-32 flags) (the-as uint 1)) + (set! (-> sv-32 fade) (the-as uint 0)) + (the-as int (-> (the-as gui-connection sv-32) id)) + ) + (else + (format 0 "ERROR: could not connection ~A to gui engine.~%" arg0) + 0 + ) + ) + ) + ) + +(defmethod gui-control-method-10 gui-control ((obj gui-control) (arg0 process) (arg1 gui-channel)) + (let ((s3-0 (the-as gui-connection (-> obj engine alive-list next0)))) + (-> obj engine) + (let ((s2-0 (-> s3-0 next0))) + (while (!= s3-0 (-> obj engine alive-list-end)) + (if (and (= arg1 (-> s3-0 channel)) (= arg0 (get-process s3-0))) + (move-to-dead s3-0) + ) + (set! s3-0 (the-as gui-connection s2-0)) + (-> obj engine) + (set! s2-0 (-> s2-0 next0)) + ) + ) + ) + 0 + (none) + ) + +(defmethod gui-control-method-12 gui-control ((obj gui-control) + (arg0 process) + (arg1 gui-channel) + (arg2 gui-action) + (arg3 string) + (arg4 int) + (arg5 float) + (arg6 sound-id) + ) + (local-vars + (sv-16 gui-connection) + (sv-20 int) + (sv-24 gui-connection) + (sv-28 process-drawable) + (sv-32 int) + (sv-48 sound-id) + ) + (set! sv-48 arg6) + (set! sv-16 (the-as gui-connection #f)) + (set! sv-20 0) + (set! sv-32 32) + (while (nonzero? sv-32) + (set! sv-32 (+ sv-32 -1)) + (set! sv-24 (-> obj connections sv-32)) + (when (and (nonzero? (-> sv-24 id)) + (= arg1 (-> sv-24 channel)) + (let ((v1-14 (handle->process (-> sv-24 handle)))) + (and (or (= v1-14 arg0) (= (-> arg0 type) scene-player) (and v1-14 (= (-> v1-14 type) scene-player))) + (and (string= arg3 (-> sv-24 name)) (= arg4 (-> sv-24 anim-part))) + ) + ) + ) + (when (< (-> sv-24 priority) arg5) + (set! (-> sv-24 time-stamp) (-> obj update-time)) + (return (the-as sound-id (-> sv-24 id))) + ) + (set! sv-16 sv-24) + (goto cfg-44) + ) + ) + (countdown (v1-33 32) + (let ((a0-15 (-> obj connections v1-33))) + (when (or (zero? (-> a0-15 id)) (not (handle->process (-> a0-15 handle)))) + (set! sv-16 a0-15) + (set! (-> sv-16 param3) 0) + (set! (-> sv-16 flags) (the-as uint 0)) + (goto cfg-44) + ) + ) + ) + (label cfg-44) + (the-as sound-id (cond + (sv-16 + (when (zero? (-> (the-as gui-connection sv-16) id)) + (when (zero? sv-20) + (let ((v1-46 (gui-control-method-15 obj arg0 arg1 arg3 (new 'static 'sound-id)))) + (if v1-46 + (set! sv-20 (the-as int (-> v1-46 id))) + ) + ) + ) + (if (zero? sv-20) + (set! sv-20 (the-as int sv-48)) + ) + (set! (-> sv-16 param3) (if (nonzero? sv-20) + sv-20 + (the-as int (new-sound-id)) + ) + ) + ) + (when (= arg5 -99.0) + (let ((s2-1 arg0)) + (set! sv-28 (if (type? s2-1 process-drawable) + (the-as process-drawable s2-1) + ) + ) + ) + (set! arg5 (if sv-28 + (vector-vector-distance (target-pos 0) (-> sv-28 root trans)) + -1.0 + ) + ) + ) + (set! (-> sv-16 time-stamp) (-> obj update-time)) + (set! (-> sv-16 handle) (process->handle arg0)) + (set! (-> sv-16 priority) arg5) + (set! (-> sv-16 channel) arg1) + (set! (-> sv-16 action) arg2) + (set! (-> sv-16 anim-part) (the-as uint arg4)) + (set! (-> sv-16 param2) (the-as int arg3)) + (set! (-> sv-16 fade) (the-as uint 0)) + (the-as int (-> (the-as gui-connection sv-16) id)) + ) + (else + 0 + ) + ) + ) + ) + +(defmethod gui-control-method-21 gui-control ((obj gui-control) (arg0 gui-connection) (arg1 vector)) + (case (shr (the-as int (-> arg0 channel)) 4) + ((1 2) + (let ((s5-0 (-> obj spool-connections))) + (case (-> arg0 action) + (((gui-action queue) (gui-action play) (gui-action playing) (gui-action fade)) + (let ((f30-0 (-> arg0 priority))) + (when (= f30-0 -99.0) + (let* ((s2-0 (get-process arg0)) + (v1-10 (if (type? s2-0 process-drawable) + (the-as process-drawable s2-0) + ) + ) + ) + (set! f30-0 (cond + ((= (-> arg0 id) (-> obj ids (-> arg0 channel))) + -1.0 + ) + (v1-10 + (vector-vector-distance arg1 (-> v1-10 root trans)) + ) + (else + -1.0 + ) + ) + ) + ) + ) + (dotimes (s4-1 4) + (cond + ((>= (-> s5-0 s4-1 priority) f30-0) + (let ((s3-1 s4-1)) + (while (< s3-1 4) + (when (= (-> s5-0 s3-1 id) (-> arg0 id)) + (let ((s2-1 s3-1)) + (while (< s2-1 3) + (mem-copy! (the-as pointer (-> s5-0 s2-1)) (the-as pointer (-> s5-0 (+ s2-1 1))) 48) + (+! s2-1 1) + ) + ) + (set! (-> s5-0 3 param2) (the-as int "")) + (set! (-> s5-0 3 priority) 100000000.0) + ) + (+! s3-1 1) + ) + ) + (let ((s3-2 3)) + (while (!= s3-2 s4-1) + (mem-copy! (the-as pointer (-> s5-0 s3-2)) (the-as pointer (-> s5-0 (+ s3-2 -1))) 48) + (+! s3-2 -1) + ) + ) + (mem-copy! (the-as pointer (-> s5-0 s4-1)) (the-as pointer arg0) 48) + (set! (-> s5-0 s4-1 priority) f30-0) + (goto cfg-42) + ) + ((= (-> s5-0 s4-1 id) (-> arg0 id)) + (goto cfg-42) + ) + ) + ) + ) + ) + ) + ) + ) + ) + (label cfg-42) + 0 + ) + +(defmethod gui-control-method-11 gui-control ((obj gui-control) (arg0 gui-connection)) + (case (shr (the-as int (-> arg0 channel)) 4) + ((1 2) + (if (= (gui-control-method-17 obj (-> arg0 id)) (gui-action playing)) + (str-play-stop (-> arg0 name) (-> arg0 id)) + ) + ) + ) + (if (= (-> obj ids (-> arg0 channel)) (-> arg0 id)) + (channel-id-set! obj arg0 (new 'static 'sound-id)) + ) + 0 + ) + +;; ERROR: function was not converted to expressions. Cannot decompile. + +(defmethod update gui-control ((obj gui-control) (arg0 symbol)) + (set! (-> obj ids 65) + (the-as sound-id (if (and (>= (-> *display* base-clock frame-counter) (-> *game-info* blackout-time)) + (= (-> *setting-control* user-current bg-a) 0.0) + (= (-> *setting-control* user-current bg-a-force) 0.0) + ) + 0 + 1 + ) + ) + ) + (let ((s4-0 (target-pos 0))) + (dotimes (v1-8 4) + (set! (-> obj spool-connections v1-8 param2) (the-as int #f)) + (set! (-> obj spool-connections v1-8 param3) 0) + (set! (-> obj spool-connections v1-8 priority) 100000000.0) + ) + (let ((s3-0 (the-as gui-connection (-> obj engine alive-list next0)))) + (-> obj engine) + (let ((s2-0 (-> s3-0 next0))) + (while (!= s3-0 (-> obj engine alive-list-end)) + (gui-control-method-21 obj s3-0 s4-0) + (case (-> s3-0 action) + (((gui-action playing)) + (channel-id-set! obj s3-0 (-> s3-0 id)) + ) + ) + (set! s3-0 (the-as gui-connection s2-0)) + (-> obj engine) + (set! s2-0 (-> s2-0 next0)) + ) + ) + ) + (let ((s3-1 (-> obj update-time))) + (countdown (s2-1 32) + (let ((s1-0 (-> obj connections s2-1))) + (when (nonzero? (-> s1-0 id)) + (cond + ((= (-> s1-0 time-stamp) s3-1) + (gui-control-method-21 obj s1-0 s4-0) + ) + (else + (if (= (-> obj ids (-> s1-0 channel)) (-> s1-0 id)) + (channel-id-set! obj s1-0 (new 'static 'sound-id)) + ) + (set! (-> s1-0 param3) 0) + 0 + ) + ) + ) + ) + ) + ) + ) + (let ((s4-1 (new 'stack-no-clear 'array 'sound-id 4)) + (s3-2 0) + ) + (let ((s2-2 (-> *setting-control* user-current movie-name))) + (dotimes (s1-1 4) + (set! (-> s4-1 s1-1) (-> obj spool-connections s1-1 id)) + (when (and (-> obj spool-connections s1-1 name) (case (-> obj spool-connections s1-1 channel) + (((gui-channel art-load) (gui-channel art-load-next)) + #t + ) + ) + ) + (set! s3-2 (logior s3-2 (ash 1 s1-1))) + (if (and s2-2 (string= (-> obj spool-connections s1-1 name) (the-as string s2-2))) + (set! s3-2 (logior s3-2 (ash 1 (+ s1-1 4)))) + ) + ) + ) + ) + (let* ((t9-6 str-play-queue) + (v1-69 (-> obj spool-connections 0 name)) + (a0-32 (if v1-69 + v1-69 + ) + ) + (v1-70 (-> obj spool-connections 1 name)) + (a1-7 (if v1-70 + v1-70 + ) + ) + (v1-71 (-> obj spool-connections 2 name)) + (a2-4 (if v1-71 + v1-71 + ) + ) + (v1-72 (-> obj spool-connections 3 name)) + ) + (t9-6 + a0-32 + a1-7 + a2-4 + (if v1-72 + v1-72 + ) + s4-1 + (the-as pointer s3-2) + ) + ) + ) + (-> obj engine) + (let ((a0-33 (the-as connection (-> obj engine alive-list-end prev0)))) + (-> obj engine) + (let ((s4-2 (-> a0-33 prev0))) + (while (!= a0-33 (-> obj engine alive-list)) + (gui-control-method-22 obj (the-as gui-connection a0-33) (get-process a0-33) #t) + (set! a0-33 (the-as connection s4-2)) + (-> obj engine) + (set! s4-2 (-> s4-2 prev0)) + ) + ) + ) + (countdown (s4-3 32) + (let ((v1-91 (-> obj connections s4-3))) + (if (nonzero? (-> v1-91 id)) + (gui-control-method-22 obj v1-91 (handle->process (-> v1-91 handle)) #f) + ) + ) + ) + (when arg0 + (when *display-art-control* + (dotimes (s5-1 4) + (let ((a3-4 (-> obj spool-connections s5-1))) + (if (-> a3-4 name) + (format *stdcon* "~D: ~`gui-connection`P~%" s5-1 a3-4) + ) + ) + ) + (dotimes (s5-2 4) + (format + *stdcon* + "~0KCh ~D: ~8D ~5X ~6D ~G~1K~%" + s5-2 + (-> *sound-iop-info* stream-id-int32 s5-2) + (-> *sound-iop-info* stream-status s5-2) + (-> *sound-iop-info* stream-position s5-2) + (-> *sound-iop-info* stream-name s5-2) + ) + ) + ) + (when *display-gui-control* + (-> obj engine) + (let ((a2-12 (-> obj engine alive-list-end prev0))) + (-> obj engine) + (let ((s5-3 (-> a2-12 prev0))) + (while (!= a2-12 (-> obj engine alive-list)) + (format *stdcon* "c: ~`gui-connection`P~%" a2-12) + (set! a2-12 s5-3) + (-> obj engine) + (set! s5-3 (-> s5-3 prev0)) + ) + ) + ) + (countdown (s5-4 32) + (let ((a2-13 (-> obj connections s5-4))) + (if (nonzero? (-> a2-13 id)) + (format *stdcon* "l: ~`gui-connection`P~%" a2-13) + ) + ) + ) + ) + ) + (set! (-> obj update-time) (-> *display* base-clock frame-counter)) + 0 + ) + +(defmethod new gui-control ((allocation symbol) (type-to-make type) (arg0 int)) + (let ((gp-0 (object-new allocation type-to-make (the-as int (-> type-to-make size))))) + (set! (-> gp-0 engine) ((method-of-type engine new) allocation engine 'gui-control arg0 gui-connection)) + (dotimes (v1-3 32) + (set! (-> gp-0 connections v1-3 handle) (the-as handle #f)) + ) + (dotimes (v1-6 96) + (set! (-> gp-0 cmd v1-6) '()) + ) + (set! (-> gp-0 cmd 64) '((64 . wait) (65 . wait) (66 . stop) (95 . stop))) + (set! (-> gp-0 cmd 66) + '((64 . wait) + (65 . wait) + (68 . wait) + (71 . wait) + (67 . wait) + (66 . wait) + (69 . wait) + (83 . hide) + (84 . hide) + (85 . hide) + ) + ) + (set! (-> gp-0 cmd 67) + '((64 . wait) + (65 . wait) + (68 . wait) + (71 . wait) + (67 . wait) + (66 . wait) + (69 . wait) + (83 . hide) + (84 . hide) + (85 . hide) + (82 . hide) + ) + ) + (set! (-> gp-0 cmd 68) + '((65 . wait) (68 . wait) (67 . wait) (66 . wait) (69 . wait) (83 . hide) (84 . hide) (85 . hide) (82 . hide)) + ) + (set! (-> gp-0 cmd 71) + '((65 . wait) (71 . wait) (67 . wait) (66 . wait) (69 . wait) (83 . hide) (84 . hide) (85 . hide) (82 . hide)) + ) + (set! (-> gp-0 cmd 69) '((65 . wait) (71 . wait) (67 . wait) (66 . wait))) + (set! (-> gp-0 cmd 70) '((65 . wait) (90 . hide) (91 . hide) (81 . hide) (80 . hide))) + (set! (-> gp-0 cmd 80) '((64 . wait) (65 . wait) (80 . wait) (70 . wait))) + (set! (-> gp-0 cmd 81) '((64 . wait) (65 . wait) (81 . wait) (70 . wait))) + (set! (-> gp-0 cmd 82) '((64 . wait) (65 . wait) (67 . wait) (71 . wait) (69 . wait) (82 . wait))) + (set! (-> gp-0 cmd 83) + '((64 . wait) (65 . wait) (67 . wait) (71 . wait) (69 . wait) (66 . wait) (83 . wait) (84 . hide) (85 . hide)) + ) + (set! (-> gp-0 cmd 84) + '((64 . wait) (65 . wait) (67 . wait) (71 . wait) (69 . wait) (66 . wait) (83 . wait) (84 . wait)) + ) + (set! (-> gp-0 cmd 85) + '((64 . wait) (65 . wait) (67 . wait) (71 . wait) (69 . wait) (66 . wait) (83 . wait) (85 . wait)) + ) + (set! (-> gp-0 cmd 86) '((64 . wait) (65 . wait) (86 . wait))) + (set! (-> gp-0 cmd 87) '((64 . wait) (65 . wait) (87 . wait))) + (set! (-> gp-0 cmd 88) '((64 . wait) (65 . wait) (88 . wait))) + (set! (-> gp-0 cmd 89) '((64 . wait) (65 . wait) (89 . wait))) + (set! (-> gp-0 cmd 90) '((64 . wait) (65 . wait) (90 . wait) (70 . wait))) + (set! (-> gp-0 cmd 91) '((64 . wait) (65 . wait) (91 . wait) (70 . wait))) + (set! (-> gp-0 cmd 16) '((16 . wait))) + (set! (-> gp-0 cmd 17) '((17 . wait))) + (set! (-> gp-0 cmd 18) '((18 . wait))) + (set! (-> gp-0 cmd 32) '((64 . wait) (32 . wait))) + (set! (-> gp-0 cmd 30) '((64 . wait) (30 . wait))) + (set! (-> gp-0 cmd 33) '((64 . wait) (33 . wait))) + (set! (-> gp-0 cmd 34) '((64 . wait) (34 . wait))) + (set! (-> gp-0 cmd 20) '((64 . wait) (20 . wait) (19 . wait) (29 . wait))) + (set! (-> gp-0 cmd 19) '((64 . wait) (20 . wait) (19 . wait) (29 . wait))) + (set! (-> gp-0 cmd 29) '((64 . wait) (20 . wait) (19 . wait) (29 . wait))) + (set! (-> gp-0 cmd 21) '((64 . wait) + (21 . wait) + (22 . wait) + (23 . wait) + (24 . wait) + (25 . wait) + (27 . wait) + (26 . wait) + (28 . wait) + (31 . wait) + (35 . wait) + ) + ) + (set! (-> gp-0 cmd 22) '((64 . wait) + (21 . wait) + (22 . wait) + (23 . wait) + (24 . wait) + (25 . wait) + (27 . wait) + (26 . wait) + (28 . wait) + (31 . wait) + (35 . wait) + ) + ) + (set! (-> gp-0 cmd 23) '((64 . wait) + (21 . wait) + (22 . wait) + (23 . wait) + (24 . wait) + (25 . wait) + (27 . wait) + (26 . wait) + (28 . wait) + (31 . wait) + (35 . wait) + ) + ) + (set! (-> gp-0 cmd 24) '((64 . wait) + (21 . wait) + (22 . wait) + (23 . wait) + (24 . wait) + (25 . wait) + (27 . wait) + (26 . wait) + (28 . wait) + (31 . wait) + (35 . wait) + ) + ) + (set! (-> gp-0 cmd 25) '((64 . wait) + (21 . wait) + (22 . wait) + (23 . wait) + (24 . wait) + (25 . wait) + (27 . wait) + (26 . wait) + (28 . wait) + (31 . wait) + (35 . wait) + ) + ) + (set! (-> gp-0 cmd 27) '((64 . wait) + (21 . wait) + (22 . wait) + (23 . wait) + (24 . wait) + (25 . wait) + (27 . wait) + (26 . wait) + (28 . wait) + (31 . wait) + (35 . wait) + ) + ) + (set! (-> gp-0 cmd 26) '((64 . wait) + (21 . wait) + (22 . wait) + (23 . wait) + (24 . wait) + (25 . wait) + (27 . wait) + (26 . wait) + (28 . wait) + (31 . wait) + (35 . wait) + ) + ) + (set! (-> gp-0 cmd 28) '((64 . wait) + (21 . wait) + (22 . wait) + (23 . wait) + (24 . wait) + (25 . wait) + (27 . wait) + (26 . wait) + (28 . wait) + (31 . wait) + (35 . wait) + ) + ) + (set! (-> gp-0 cmd 31) '((64 . wait) + (21 . wait) + (22 . wait) + (23 . wait) + (24 . wait) + (25 . wait) + (27 . wait) + (26 . wait) + (28 . wait) + (31 . wait) + (35 . wait) + ) + ) + (set! (-> gp-0 cmd 35) '((64 . wait) + (21 . wait) + (22 . wait) + (23 . wait) + (24 . wait) + (25 . wait) + (27 . wait) + (26 . wait) + (28 . wait) + (31 . wait) + (35 . wait) + ) + ) + gp-0 + ) + ) + +(kmemopen global "gui-controls") + +(define *gui-control* (new 'global 'gui-control 64)) + +(if (zero? *art-control*) + (set! *art-control* (new 'global 'external-art-control)) + ) + +(kmemclose) + + + diff --git a/goal_src/jak2/engine/physics/chain-physics-h.gc b/goal_src/jak2/engine/physics/chain-physics-h.gc index 53ad1c417b..cb5eaca99f 100644 --- a/goal_src/jak2/engine/physics/chain-physics-h.gc +++ b/goal_src/jak2/engine/physics/chain-physics-h.gc @@ -15,17 +15,19 @@ :flag-assert #x900000004 ) + (deftype chain-physics-joint (structure) - ((position vector :inline :offset-assert 0) - (velocity vector :inline :offset-assert 16) - (old-x vector :inline :offset-assert 32) - (joint-mod basic :offset-assert 48) + ((position vector :inline :offset-assert 0) + (velocity vector :inline :offset-assert 16) + (old-x vector :inline :offset-assert 32) + (joint-mod joint-mod :offset-assert 48) ) :method-count-assert 9 :size-assert #x34 :flag-assert #x900000034 ) + (deftype chain-physics (basic) ((chain-joints chain-physics-joint 20 :inline :offset-assert 16) (num-joints uint8 :offset-assert 1296) @@ -40,21 +42,28 @@ (negate-y basic :offset-assert 1360) (axial-slop float :offset-assert 1364) (maximum-stretch float :offset-assert 1368) - (turn-off-start uint64 :offset-assert 1376) - (turn-off-duration uint64 :offset-assert 1384) + (turn-off-start time-frame :offset-assert 1376) + (turn-off-duration time-frame :offset-assert 1384) ) :method-count-assert 18 :size-assert #x570 :flag-assert #x1200000570 (:methods - (chain-physics-method-9 () none 9) - (chain-physics-method-10 () none 10) - (chain-physics-method-11 () none 11) - (chain-physics-method-12 () none 12) - (chain-physics-method-13 () none 13) - (chain-physics-method-14 () none 14) - (chain-physics-method-15 () none 15) - (chain-physics-method-16 () none 16) - (chain-physics-method-17 () none 17) + (initialize-chain-joints (_type_) symbol 9) + (turn-off (_type_ time-frame) none :behavior process 10) + (update (_type_ process-drawable) none :behavior process 11) + (gravity-update (_type_) none 12) + (apply-gravity (_type_ vector int) none :behavior process 13) + (chain-physics-method-14 (_type_ vector int) none 14) + (clamp-length (_type_ vector vector) vector 15) + (chain-physics-method-16 (_type_ int) float 16) + (chain-physics-method-17 (_type_ vector) none 17) ) ) + + +0 + + + + diff --git a/goal_src/jak2/engine/physics/chain-physics.gc b/goal_src/jak2/engine/physics/chain-physics.gc index 76eadc9daf..8bc5b54d3d 100644 --- a/goal_src/jak2/engine/physics/chain-physics.gc +++ b/goal_src/jak2/engine/physics/chain-physics.gc @@ -7,3 +7,390 @@ ;; DECOMP BEGINS +(defmethod gravity-update chain-physics ((obj chain-physics)) + (vector-seek-3d-smooth! (-> obj gravity) (-> obj gravity-target) 0.05 0.1) + 0 + (none) + ) + +(defmethod apply-gravity chain-physics ((obj chain-physics) (arg0 vector) (arg1 int)) + (vector-float*! + arg0 + (-> obj gravity) + (* 4096.0 (-> self clock time-adjust-ratio) (fmax 0.2 (lerp-scale 0.38 0.18 (the float arg1) 0.0 5.0))) + ) + 0 + (none) + ) + +(defmethod chain-physics-method-14 chain-physics ((obj chain-physics) (arg0 vector) (arg1 int)) + (vector-float*! + arg0 + (the-as vector (+ (the-as uint (-> obj chain-joints 0 velocity)) (* (+ arg1 1) 64))) + (fmin 0.9 (lerp-scale 0.2 1.0 (the float arg1) 0.0 4.0)) + ) + 0 + (none) + ) + +(defmethod clamp-length chain-physics ((obj chain-physics) (arg0 vector) (arg1 vector)) + (let ((gp-0 (new 'stack-no-clear 'vector))) + (vector-! gp-0 arg0 arg1) + (vector-normalize! gp-0 (-> obj joint-length)) + (vector+! arg0 gp-0 arg1) + ) + ) + +(defmethod chain-physics-method-16 chain-physics ((obj chain-physics) (arg0 int)) + (lerp-scale 5461.3335 10922.667 (the float arg0) 0.0 8.0) + ) + +(defmethod chain-physics-method-17 chain-physics ((obj chain-physics) (arg0 vector)) + 0 + (none) + ) + +(defmethod initialize-chain-joints chain-physics ((obj chain-physics)) + (set! (-> obj turn-off-start) 0) + (dotimes (s5-0 (the-as int (-> obj num-joints))) + (let ((s4-0 (-> obj chain-joints s5-0))) + (vector<-cspace! (-> s4-0 position) (-> s4-0 joint-mod joint)) + (vector-reset! (-> s4-0 velocity)) + (mode-set! (-> s4-0 joint-mod) (joint-mod-mode joint-set-world)) + ) + ) + #f + ) + +(defmethod turn-off chain-physics ((obj chain-physics) (arg0 time-frame)) + (set! (-> obj turn-off-start) (-> self clock frame-counter)) + (set! (-> obj turn-off-duration) arg0) + 0 + (none) + ) + +(defmethod update chain-physics ((obj chain-physics) (arg0 process-drawable)) + (local-vars + (v1-77 float) + (f0-11 float) + (sv-272 chain-physics-joint) + (sv-288 vector) + (sv-304 vector) + (sv-320 (function vector float vector)) + (sv-336 vector) + (sv-352 vector) + (sv-368 vector) + (sv-384 vector) + (sv-400 vector) + (sv-416 vector) + (sv-432 vector) + (sv-448 (inline-array vector)) + (sv-464 (inline-array vector)) + (sv-480 (inline-array vector)) + (sv-496 vector) + (sv-512 (inline-array vector)) + (sv-528 vector) + ) + (rlet ((acc :class vf) + (vf0 :class vf) + (vf1 :class vf) + (vf2 :class vf) + (vf3 :class vf) + (vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + ) + (init-vf0-vector) + (gravity-update obj) + (let ((s4-0 (new 'stack-no-clear 'matrix)) + (s3-0 (vector<-cspace! (new 'stack-no-clear 'vector) (-> arg0 node-list data (-> obj root-joint-index)))) + (s2-0 (vector-normalize-copy! + (new 'stack-no-clear 'vector) + (-> arg0 node-list data (-> obj root-joint-index) bone transform vector 2) + 1.0 + ) + ) + (s1-0 (vector-normalize-copy! + (new 'stack-no-clear 'vector) + (-> arg0 node-list data (-> obj root-joint-index) bone transform vector 1) + 1.0 + ) + ) + ) + (new 'stack-no-clear 'vector) + (let ((f30-0 1.0)) + (if (nonzero? (-> obj turn-off-start)) + (set! f30-0 + (fmax + 0.0 + (fmin + 1.0 + (parameter-ease-sin-clamp (- 1.0 (/ (the float (- (-> self clock frame-counter) (-> obj turn-off-start))) + (the float (-> obj turn-off-duration)) + ) + ) + ) + ) + ) + ) + ) + (dotimes (s0-0 (the-as int (-> obj num-joints))) + (set! sv-272 (-> obj chain-joints s0-0)) + (set! sv-528 (new 'stack-no-clear 'vector)) + (let ((v1-27 (-> sv-272 position quad))) + (set! (-> sv-528 quad) v1-27) + ) + (set! (-> sv-272 joint-mod flex-blend) f30-0) + (if (-> obj negate-y) + (vector-negate! s1-0 s1-0) + ) + (set! sv-288 (new 'stack-no-clear 'vector)) + (apply-gravity obj sv-288 s0-0) + (let ((v1-34 sv-528)) + (let ((a0-10 sv-528)) + (.mov.vf vf6 vf0 :mask #b1000) + (.lvf vf4 (&-> a0-10 quad)) + ) + (.lvf vf5 (&-> sv-288 quad)) + (.add.vf vf6 vf4 vf5 :mask #b111) + (.svf (&-> v1-34 quad) vf6) + ) + (when (< s0-0 (the-as int (+ (-> obj root-joint-index) -1))) + (set! sv-304 (new 'stack-no-clear 'vector)) + (chain-physics-method-14 obj sv-304 s0-0) + (let ((v1-40 sv-528)) + (let ((a0-13 sv-528)) + (.mov.vf vf6 vf0 :mask #b1000) + (.lvf vf4 (&-> a0-13 quad)) + ) + (.lvf vf5 (&-> sv-304 quad)) + (.add.vf vf6 vf4 vf5 :mask #b111) + (.svf (&-> v1-40 quad) vf6) + ) + ) + (clamp-length obj sv-528 s3-0) + (set! sv-400 (new 'stack-no-clear 'vector)) + (let ((v1-43 sv-528) + (a0-16 s3-0) + ) + (.lvf vf4 (&-> v1-43 quad)) + (.lvf vf5 (&-> a0-16 quad)) + ) + (.mov.vf vf6 vf0 :mask #b1000) + (.sub.vf vf6 vf4 vf5 :mask #b111) + (.svf (&-> sv-400 quad) vf6) + (let ((f28-1 (vector-normalize-ret-len! sv-400 1.0)) + (f24-0 (vector-dot sv-400 s1-0)) + (f26-0 (chain-physics-method-16 obj s0-0)) + ) + (when (< f24-0 (cos f26-0)) + (vector--float*! sv-400 sv-400 s1-0 f24-0) + (set! sv-320 vector-normalize!) + (set! sv-336 sv-400) + (let ((a1-17 (sin f26-0))) + (sv-320 sv-336 a1-17) + ) + (set! sv-384 sv-400) + (set! sv-352 sv-400) + (set! sv-368 s1-0) + (let ((f0-6 (cos f26-0))) + (.lvf vf2 (&-> sv-368 quad)) + (.lvf vf1 (&-> sv-352 quad)) + (let ((v1-55 f0-6)) + (.mov vf3 v1-55) + ) + ) + (.add.x.vf vf4 vf0 vf0 :mask #b1000) + (.mul.x.vf acc vf2 vf3) + (.add.mul.w.vf vf4 vf1 vf0 acc :mask #b111) + (.svf (&-> sv-384 quad) vf4) + (let ((v1-57 sv-528)) + (let ((a0-25 s3-0)) + (.lvf vf2 (&-> sv-400 quad)) + (.lvf vf1 (&-> a0-25 quad)) + ) + (let ((a0-26 f28-1)) + (.mov vf3 a0-26) + ) + (.add.x.vf vf4 vf0 vf0 :mask #b1000) + (.mul.x.vf acc vf2 vf3) + (.add.mul.w.vf vf4 vf1 vf0 acc :mask #b111) + (.svf (&-> v1-57 quad) vf4) + ) + ) + ) + (chain-physics-method-17 obj sv-528) + (set! sv-432 (new 'stack-no-clear 'vector)) + (let ((v1-60 s3-0) + (a0-28 sv-528) + ) + (.lvf vf4 (&-> v1-60 quad)) + (.lvf vf5 (&-> a0-28 quad)) + ) + (.mov.vf vf6 vf0 :mask #b1000) + (.sub.vf vf6 vf4 vf5 :mask #b111) + (.svf (&-> sv-432 quad) vf6) + (vector-normalize-ret-len! sv-432 1.0) + (set! sv-416 (new 'stack-no-clear 'vector)) + (let ((v1-63 sv-528) + (a0-31 (-> sv-272 position)) + ) + (.lvf vf4 (&-> v1-63 quad)) + (.lvf vf5 (&-> a0-31 quad)) + ) + (.mov.vf vf6 vf0 :mask #b1000) + (.sub.vf vf6 vf4 vf5 :mask #b111) + (.svf (&-> sv-416 quad) vf6) + (let ((f28-2 (vector-dot sv-432 sv-416))) + (vector--float*! sv-416 sv-416 sv-432 f28-2) + (cond + ((< f28-2 0.0) + (set! f0-11 (* f28-2 (-> obj compress-vel-parallel))) + (vector-float*! sv-416 sv-416 (-> obj compress-vel)) + ) + (else + (set! f0-11 (* f28-2 (-> obj stretch-vel-parallel))) + (vector-float*! sv-416 sv-416 (-> obj stretch-vel)) + ) + ) + ) + (let ((v1-72 (-> sv-272 velocity))) + (.lvf vf2 (&-> sv-432 quad)) + (.lvf vf1 (&-> sv-416 quad)) + (let ((a0-38 f0-11)) + (.mov vf3 a0-38) + ) + (.add.x.vf vf4 vf0 vf0 :mask #b1000) + (.mul.x.vf acc vf2 vf3) + (.add.mul.w.vf vf4 vf1 vf0 acc :mask #b111) + (.svf (&-> v1-72 quad) vf4) + ) + (vector+! sv-528 (-> sv-272 position) (-> sv-272 velocity)) + (let ((a2-9 (vector-! (new 'stack-no-clear 'vector) s3-0 sv-528))) + (.lvf vf1 (&-> a2-9 quad)) + (.add.w.vf vf2 vf0 vf0 :mask #b1) + (.mul.vf vf1 vf1 vf1) + (.mul.x.vf acc vf2 vf1 :mask #b1) + (.add.mul.y.vf acc vf2 vf1 acc :mask #b1) + (.add.mul.z.vf vf1 vf2 vf1 acc :mask #b1) + (.mov v1-77 vf1) + (let* ((f0-13 v1-77) + (f1-6 (* (-> obj maximum-stretch) (-> obj joint-length))) + (f2-3 f1-6) + ) + (if (< (* f2-3 f2-3) f0-13) + (vector--float*! sv-528 s3-0 a2-9 (/ f1-6 (sqrtf f0-13))) + ) + ) + ) + (set! (-> sv-272 position quad) (-> sv-528 quad)) + (if (-> sv-272 joint-mod) + (set! (-> sv-272 joint-mod trans quad) (-> sv-528 quad)) + ) + (when (< s0-0 (the-as int (-> obj num-joints))) + (vector-! (-> s4-0 vector 1) sv-528 s3-0) + (vector-normalize! (-> s4-0 vector 1) 1.0) + (if (-> obj negate-y) + (vector-negate! (-> s4-0 vector 1) (-> s4-0 vector 1)) + ) + (vector-cross! (the-as vector (-> s4-0 vector)) (-> s4-0 vector 1) s2-0) + (vector-normalize! (the-as vector (-> s4-0 vector)) 1.0) + (set! sv-496 (new 'stack-no-clear 'vector)) + (let ((v1-96 (-> sv-272 old-x)) + (a0-52 (-> s4-0 vector)) + ) + (.lvf vf1 (&-> v1-96 quad)) + (.lvf vf2 (&-> a0-52 0 quad)) + ) + (.outer.product.a.vf acc vf1 vf2) + (.outer.product.b.vf vf3 vf2 vf1 acc) + (.svf (&-> sv-496 quad) vf3) + (vector-flatten! sv-496 (-> sv-272 old-x) (-> s4-0 vector 1)) + (vector-normalize! sv-496 1.0) + (cond + ((< (vector-dot (the-as vector (-> s4-0 vector)) sv-496) (cos (-> obj axial-slop))) + (vector-cross! sv-496 sv-496 (the-as vector (-> s4-0 vector))) + (vector-cross! sv-496 (the-as vector (-> s4-0 vector)) sv-496) + (vector-normalize! sv-496 1.0) + (set! sv-464 (-> s4-0 vector)) + (set! sv-448 (-> s4-0 vector)) + (let ((f0-20 (cos (-> obj axial-slop)))) + (.lvf vf1 (&-> sv-448 0 quad)) + (let ((v1-106 f0-20)) + (.mov vf2 v1-106) + ) + ) + (.add.x.vf vf1 vf0 vf0 :mask #b1000) + (.mul.x.vf vf1 vf1 vf2 :mask #b111) + (.svf (&-> sv-464 0 quad) vf1) + (set! sv-512 (-> s4-0 vector)) + (set! sv-480 (-> s4-0 vector)) + (let ((f0-22 (sin (-> obj axial-slop)))) + (.lvf vf2 (&-> sv-496 quad)) + (.lvf vf1 (&-> sv-480 0 quad)) + (let ((v1-112 f0-22)) + (.mov vf3 v1-112) + ) + ) + (.add.x.vf vf4 vf0 vf0 :mask #b1000) + (.mul.x.vf acc vf2 vf3) + (.add.mul.w.vf vf4 vf1 vf0 acc :mask #b111) + (.svf (&-> sv-512 0 quad) vf4) + (set! (-> sv-272 old-x quad) (-> s4-0 vector 0 quad)) + ) + (else + (set! (-> s4-0 vector 0 quad) (-> sv-496 quad)) + (set! (-> sv-272 old-x quad) (-> s4-0 vector 0 quad)) + ) + ) + (vector-cross! (-> s4-0 vector 2) (the-as vector (-> s4-0 vector)) (-> s4-0 vector 1)) + (matrix->quaternion (-> sv-272 joint-mod quat) s4-0) + (set! (-> s1-0 quad) (-> s4-0 vector 1 quad)) + (set! (-> s2-0 quad) (-> s4-0 vector 2 quad)) + 0 + ) + (set! (-> s3-0 quad) (-> sv-528 quad)) + 0 + ) + ) + ) + 0 + (none) + ) + ) + +(defmethod relocate chain-physics ((obj chain-physics) (arg0 int)) + (dotimes (v1-0 (the-as int (-> obj num-joints))) + (if (nonzero? (-> obj chain-joints v1-0 joint-mod)) + (&+! (-> obj chain-joints v1-0 joint-mod) arg0) + ) + ) + obj + ) + +(defun chain-physics-initialize ((arg0 process-drawable) (arg1 chain-physics) (arg2 int) (arg3 float) (arg4 (array chain-physics-setup))) + (set! (-> arg1 num-joints) (the-as uint (min 20 (-> arg4 length)))) + (dotimes (s1-0 (the-as int (-> arg1 num-joints))) + (set! (-> arg1 chain-joints s1-0 joint-mod) + (new 'process 'joint-mod (joint-mod-mode flex-blend) arg0 (-> arg4 s1-0 joint-index)) + ) + (set! (-> arg1 chain-joints s1-0 joint-mod track-mode) (track-mode no-scale)) + ) + (set! (-> arg1 root-joint-index) (the-as uint arg2)) + (set! (-> arg1 joint-length) arg3) + (set-vector! (-> arg1 gravity) 0.0 -1.0 0.0 1.0) + (set! (-> arg1 gravity-target quad) (-> arg1 gravity quad)) + (set! (-> arg1 stretch-vel) 0.7) + (set! (-> arg1 stretch-vel-parallel) 0.8) + (set! (-> arg1 compress-vel) 0.85) + (set! (-> arg1 compress-vel-parallel) 0.75) + (set! (-> arg1 negate-y) #f) + (set! (-> arg1 axial-slop) 3640.889) + (set! (-> arg1 maximum-stretch) 1.5) + (set! (-> arg1 turn-off-start) 0) + 0 + ) + + + + diff --git a/goal_src/jak2/engine/process-drawable/process-drawable-h.gc b/goal_src/jak2/engine/process-drawable/process-drawable-h.gc index ec68cc4758..acb0a85186 100644 --- a/goal_src/jak2/engine/process-drawable/process-drawable-h.gc +++ b/goal_src/jak2/engine/process-drawable/process-drawable-h.gc @@ -8,6 +8,12 @@ (define-extern cspace-by-name (function process-drawable string cspace)) (define-extern cspace-index-by-name (function process-drawable string int)) (define-extern joint-control-reset! (function joint-control joint-control-channel none :behavior process-drawable)) +(define-extern ja-channel-push! (function int time-frame int :behavior process-drawable)) +(define-extern ja-channel-set! (function int int :behavior process-drawable)) +(define-extern ja-aframe-num (function int float :behavior process-drawable)) +(define-extern ja-frame-num (function int float :behavior process-drawable)) +(define-extern ja-aframe (function float int float :behavior process-drawable)) +(define-extern vector<-matrix! (function vector matrix vector)) ;; DECOMP BEGINS @@ -42,11 +48,11 @@ ) ) -(defun num-func-none ((arg0 joint-control-channel) (arg1 float) (arg2 float)) +(defbehavior num-func-none process ((arg0 joint-control-channel) (arg1 float) (arg2 float) (arg3 float)) (-> arg0 frame-num) ) -(defun num-func-+! ((arg0 joint-control-channel) (arg1 float) (arg2 float)) +(defbehavior num-func-+! process ((arg0 joint-control-channel) (arg1 float) (arg2 float) (arg3 float)) (with-pp (let ((f0-1 (+ (-> arg0 frame-num) (* arg1 (* (-> arg0 frame-group speed) (-> pp clock time-adjust-ratio)))))) (set! (-> arg0 frame-num) f0-1) @@ -55,7 +61,7 @@ ) ) -(defun num-func--! ((arg0 joint-control-channel) (arg1 float) (arg2 float)) +(defbehavior num-func--! process ((arg0 joint-control-channel) (arg1 float) (arg2 float) (arg3 float)) (with-pp (let ((f0-1 (- (-> arg0 frame-num) (* arg1 (* (-> arg0 frame-group speed) (-> pp clock time-adjust-ratio)))))) (set! (-> arg0 frame-num) f0-1) @@ -64,7 +70,7 @@ ) ) -(defun num-func-loop! ((arg0 joint-control-channel) (arg1 float) (arg2 float)) +(defbehavior num-func-loop! process ((arg0 joint-control-channel) (arg1 float) (arg2 float) (arg3 float)) (with-pp (let* ((f0-1 (the float (+ (-> arg0 frame-group frames num-frames) -1))) (f1-2 (+ (-> arg0 frame-num) f0-1 (* arg1 (* (-> arg0 frame-group speed) (-> pp clock time-adjust-ratio))))) @@ -76,7 +82,7 @@ ) ) -(defun num-func-loop-speedless! ((arg0 joint-control-channel) (arg1 float) (arg2 float)) +(defbehavior num-func-loop-speedless! process ((arg0 joint-control-channel) (arg1 float) (arg2 float) (arg3 float)) (let* ((f0-1 (the float (+ (-> arg0 frame-group frames num-frames) -1))) (f1-2 (+ (-> arg0 frame-num) f0-1 arg1)) (f0-3 (- f1-2 (* (the float (the int (/ f1-2 f0-1))) f0-1))) @@ -86,7 +92,7 @@ ) ) -(defun num-func-seek! ((arg0 joint-control-channel) (arg1 float) (arg2 float)) +(defbehavior num-func-seek! process ((arg0 joint-control-channel) (arg1 float) (arg2 float) (arg3 float)) (with-pp (let ((f0-3 (seek (-> arg0 frame-num) arg1 (* arg2 (* (-> arg0 frame-group speed) (-> pp clock time-adjust-ratio)))) @@ -98,7 +104,7 @@ ) ) -(defun num-func-blend-in! ((arg0 joint-control-channel) (arg1 float) (arg2 float)) +(defbehavior num-func-blend-in! process ((arg0 joint-control-channel) (arg1 float) (arg2 float) (arg3 float)) (with-pp (let ((f30-0 (seek (-> arg0 frame-interp 0) 1.0 (* arg1 (-> pp clock time-adjust-ratio))))) (set! (-> arg0 frame-interp 0) f30-0) @@ -130,7 +136,7 @@ (none) ) -(defun num-func-interp-play! ((arg0 joint-control-channel) (arg1 float) (arg2 float) (arg3 float)) +(defbehavior num-func-interp-play! process ((arg0 joint-control-channel) (arg1 float) (arg2 float) (arg3 float)) (with-pp (let ((f30-0 (the float (+ (-> arg0 frame-group frames num-frames) -1))) (f28-0 (* arg3 (-> arg0 frame-group speed))) @@ -157,7 +163,7 @@ ) ) -(defun num-func-interp1-play! ((arg0 joint-control-channel) (arg1 float) (arg2 float) (arg3 float)) +(defbehavior num-func-interp1-play! process ((arg0 joint-control-channel) (arg1 float) (arg2 float) (arg3 float)) (with-pp (let ((f30-0 (the float (+ (-> arg0 frame-group frames num-frames) -1))) (f28-0 (* arg3 (-> arg0 frame-group speed))) @@ -183,7 +189,7 @@ ) ) -(defun num-func-chan ((arg0 joint-control-channel) (arg1 float) (arg2 float)) +(defbehavior num-func-chan process ((arg0 joint-control-channel) (arg1 float) (arg2 float) (arg3 float)) (let ((f0-2 (-> (the-as joint-control-channel (+ (the-as uint arg0) (* (- (the int arg1) (-> arg0 group-sub-index)) 64))) frame-num @@ -195,6 +201,138 @@ ) ) -(defun num-func-identity ((arg0 joint-control-channel) (arg1 float) (arg2 float)) +(defbehavior num-func-identity process ((arg0 joint-control-channel) (arg1 float) (arg2 float) (arg3 float)) (-> arg0 frame-num) ) + +;; these are mostly the same as jak 1? +(defmacro ja-group (&key (chan 0)) + "get the frame group for self. default channel is 0, the base channel. returns #f if no frame group." + `(if (> (-> self skel active-channels) ,chan) + (-> self skel root-channel ,chan frame-group)) + ) + +(defmacro ja-group? (group &key (chan 0)) + "is self in this frame group on this channel? default is channel 0, which is the base channel." + `(= (ja-group) ,group) + ) + +(defmacro ja (&key (chan 0) + &key (group! #f) + &key (num! #f) + &key (param0 #f) + &key (param1 #f) + &key (num-func #f) + &key (frame-num #f) + &key (frame-interp #f) + &key (dist #f) + &key (eval? #t) + ) + "set various joint anim parameters for self and eval them. + you can use this for playing animations! + chan = the channel to modify. defaults to 0 (base channel). this is usually what you want. + group! = when not #f, set this as the new frame-group. defaults to #f + num! = set the frame playback function. this is what determines what frame an animation is at. funcs below. + #f = no func will be set, and there wont be a frame eval. + num-func = sets the num-func field for the channel. this lets you change the function with eval'ing. + param0 = 1st parameter for the playback function. ONLY USE THESE WITH num-func !! + param1 = 2nd parameter for the playback function. ONLY USE THESE WITH num-func !! + frame-num = set the frame-num field. + frame-interp = set the frame-interp field. + dist = set the dist field. + available num! functions: + - (+!) = advance anim. + - (-!) = reverse anim. + - (identity num) = play 'num' frame. + - (seek! target speed) = animate towards frame target at a speed. + speed is optional and defaults to 1.0 when not provided. + target is optional and defaults to the last frame of the animation. + if you want to set the speed, you therefore must also set the target. + target can be max (no quote), which is just the same as the default value. + - (loop! speed) = loop animation at a speed. default speed is 1.0 when not provided. + - (chan channel) = copy frame from another channel. + - min = the start of the animation. + - max = the end of the animation. + " + + (let* ((num-args (if (pair? num!) (cdr num!) '())) + (num! (if (pair? num!) (car num!) num!)) + (nf (cond + ((or (eq? num! 'identity) + (eq? num! 'min) + (eq? num! 'max) + ) + 'num-func-identity) + ((eq? num! 'none) 'num-func-none) + ((eq? num! '+!) 'num-func-+!) + ((eq? num! '-!) 'num-func--!) + ((eq? num! 'seek!) 'num-func-seek!) + ((eq? num! 'loop!) 'num-func-loop!) + ((eq? num! 'blend-in!) 'num-func-blend-in!) + ((eq? num! 'chan) 'num-func-chan) + )) + (p0 (if param0 param0 + (cond + ((eq? num! 'chan) `(the float ,(car num-args))) + ((eq? num! '+!) (if (null? num-args) 1.0 (car num-args))) + ((eq? num! '-!) (if (null? num-args) 1.0 (car num-args))) + ((eq? num! 'loop!) (if (null? num-args) 1.0 (if (eq? 'max (car num-args)) + (if group! + `(the float (1- (-> (the art-joint-anim ,group!) frames num-frames))) + `(the float (1- (-> ja-ch frame-group frames num-frames))) + ) + (car num-args)))) + ((eq? num! 'seek!) (if (or (null? num-args) (eq? (car num-args) 'max)) + (if group! + `(the float (1- (-> (the art-joint-anim ,group!) frames num-frames))) + `(the float (1- (-> ja-ch frame-group frames num-frames))) + ) + (car num-args))) + ))) + (p1 (if param1 param1 + (cond + ((eq? num! 'seek!) (if (or (null? num-args) (null? (cdr num-args))) 1.0 (cadr num-args))) + ))) + (frame-num (if (eq? 'max frame-num) (if group! + `(the float (1- (-> (the art-joint-anim ,group!) frames num-frames))) + `(the float (1- (-> ja-ch frame-group frames num-frames))) + ) + frame-num)) + (frame-group (if (or p0 p1 frame-num (not nf)) group! #f)) + ) + `(let ((ja-ch (-> self skel root-channel ,chan))) + ,(if frame-interp `(set! (-> ja-ch frame-interp) ,frame-interp) `(none)) + ,(if dist `(set! (-> ja-ch dist) ,dist) `(none)) + ,(if frame-group `(set! (-> ja-ch frame-group) (the art-joint-anim ,frame-group)) `(none)) + ,(if p0 `(set! (-> ja-ch param 0) ,p0) `(none)) + ,(if p1 `(set! (-> ja-ch param 1) ,p1) `(none)) + ,(if num-func `(set! (-> ja-ch num-func) ,num-func) `(none)) + ,(if frame-num `(set! (-> ja-ch frame-num) ,frame-num) `(none)) + ,(if nf + `(,(if eval? 'joint-control-channel-group-eval! 'joint-control-channel-group!) + ja-ch (the art-joint-anim ,group!) ,nf) + `(none)) + ,(cond + ((eq? num! 'min) `(set! (-> ja-ch frame-num) 0.0)) + ((eq? num! 'max) (if group! + `(set! (-> ja-ch frame-num) (the float (1- (-> (the art-joint-anim ,group!) frames num-frames)))) + `(set! (-> ja-ch frame-num) (the float (1- (-> ja-ch frame-group frames num-frames)))) + )) + ((eq? num! 'identity) `(set! (-> ja-ch frame-num) ,(car num-args))) + (#t `(none)) + ) + )) + ) + +(defmacro ja-no-eval (&key (chan 0) + &key (group! #f) + &key (num! #f) + &key (param0 #f) + &key (param1 #f) + &key (num-func #f) + &key (frame-num #f) + &key (frame-interp #f) + &key (dist #f) + ) + `(ja :eval? #f :chan ,chan :group! ,group! :num! ,num! :param0 ,param0 :param1 ,param1 :num-func ,num-func :frame-num ,frame-num :frame-interp ,frame-interp :dist ,dist) + ) diff --git a/goal_src/jak2/engine/process-drawable/process-drawable.gc b/goal_src/jak2/engine/process-drawable/process-drawable.gc index cb00e4c93b..675d64b30f 100644 --- a/goal_src/jak2/engine/process-drawable/process-drawable.gc +++ b/goal_src/jak2/engine/process-drawable/process-drawable.gc @@ -15,5 +15,28 @@ obj ) +(defun vector<-matrix! ((arg0 vector) (arg1 matrix)) + (rlet ((Q :class vf) + (vf0 :class vf) + (vf2 :class vf) + ) + (init-vf0-vector) + (.lvf vf2 (&-> arg1 trans quad)) + (.div.vf Q vf0 vf2 :fsf #b11 :ftf #b11) + (.wait.vf) + (.mul.vf vf2 vf2 Q :mask #b111) + (.nop.vf) + (.nop.vf) + (.mov.vf vf2 vf0 :mask #b1000) + (.svf (&-> arg0 quad) vf2) + arg0 + ) + ) + ;; DECOMP BEGINS +;; ERROR: top level function was not converted to expressions. Cannot decompile. + + + + diff --git a/goal_src/jak2/engine/sound/gsound-h.gc b/goal_src/jak2/engine/sound/gsound-h.gc index 6fd01dbbe8..72418bc66f 100644 --- a/goal_src/jak2/engine/sound/gsound-h.gc +++ b/goal_src/jak2/engine/sound/gsound-h.gc @@ -98,14 +98,16 @@ (defenum stream-status :type uint32 :bitfield #t - (zero 0) - (one 1) ;; another way to be playing - (two 2) - (three 3) - (four 4) ;; is playing? - (five 5) - (six 6) ;; another way to be playing. - (seven 7) + (ststatus-zero 0) + (ststatus-one 1) ;; another way to be playing + (ststatus-two 2) + (ststatus-three 3) + (ststatus-four 4) ;; is playing? + (ststatus-five 5) + (ststatus-six 6) ;; another way to be playing. + (ststatus-seven 7) + (ststatus-eight 8) + (ststatus-nine 9) ) (defenum stereo-mode diff --git a/goal_src/jak2/engine/sound/gsound.gc b/goal_src/jak2/engine/sound/gsound.gc index 417f463335..19862645f7 100644 --- a/goal_src/jak2/engine/sound/gsound.gc +++ b/goal_src/jak2/engine/sound/gsound.gc @@ -60,7 +60,8 @@ (stream-position uint32 4 :offset 272) (stream-status stream-status 4 :offset-assert 288) (stream-name sound-stream-name 4 :inline :offset-assert 304) - (stream-id uint32 4 :offset-assert 496) + (stream-id sound-id 4 :offset-assert 496) + (stream-id-int32 int32 4 :overlay-at stream-id) (music-register uint8 17 :offset-assert 512) (music-excite int8 :offset 528) (ramdisk-name uint8 48 :offset-assert 529) @@ -75,7 +76,7 @@ (defun str-is-playing? () (countdown (v1-0 4) (if (and (>= (-> *sound-iop-info* stream-id v1-0) 0) - (logtest? (-> *sound-iop-info* stream-status v1-0) (stream-status four)) + (logtest? (-> *sound-iop-info* stream-status v1-0) (stream-status ststatus-four)) ) (return #t) ) @@ -86,7 +87,7 @@ (defun str-id-is-playing? ((arg0 int)) (countdown (v1-0 4) (if (and (= arg0 (-> *sound-iop-info* stream-id v1-0)) - (logtest? (-> *sound-iop-info* stream-status v1-0) (stream-status one six)) + (logtest? (-> *sound-iop-info* stream-status v1-0) (stream-status ststatus-one ststatus-six)) ) (return #t) ) diff --git a/goal_src/jak2/engine/ui/bigmap-h.gc b/goal_src/jak2/engine/ui/bigmap-h.gc index 9414577eb8..eb6d9f00e7 100644 --- a/goal_src/jak2/engine/ui/bigmap-h.gc +++ b/goal_src/jak2/engine/ui/bigmap-h.gc @@ -294,5 +294,6 @@ ) +(define-extern *bigmap* bigmap) diff --git a/goal_src/jak2/engine/ui/gui-h.gc b/goal_src/jak2/engine/ui/gui-h.gc index 7ab41d94fe..682912dd4a 100644 --- a/goal_src/jak2/engine/ui/gui-h.gc +++ b/goal_src/jak2/engine/ui/gui-h.gc @@ -78,8 +78,8 @@ (channel gui-channel :offset 21) (anim-part uint8 :offset 22) (flags uint8 :offset 23) - (name object :offset 24) - (id uint32 :offset 28) + (name string :offset 24) + (id sound-id :offset 28) (handle handle :offset 0) (time-stamp time-frame :offset 8) (hold-time time-frame :offset-assert 32) @@ -94,29 +94,43 @@ :flag-assert #xe00000030 ) + (deftype gui-control (basic) - ((engine engine :offset-assert 4) - (data uint8 3272 :offset-assert 8) + ((engine engine :offset-assert 4) + (update-time time-frame :offset-assert 8) + (connections gui-connection 32 :inline :offset-assert 16) + (spool-connections gui-connection 4 :inline :offset-assert 1552) + (ids sound-id 96 :offset-assert 1744) + (times time-frame 96 :offset-assert 2128) + (cmd pair 96 :offset-assert 2896) ) :method-count-assert 25 :size-assert #xcd0 :flag-assert #x1900000cd0 (:methods - (gui-control-method-9 () none 9) - (gui-control-method-10 () none 10) - (gui-control-method-11 () none 11) - (gui-control-method-12 () none 12) - (update (_type_ symbol) none 13) - (gui-control-method-14 () none 14) - (gui-control-method-15 () none 15) - (gui-control-method-16 () none 16) - (gui-control-method-17 () none 17) - (gui-control-method-18 () none 18) - (gui-control-method-19 () none 19) - (gui-control-method-20 () none 20) - (gui-control-method-21 () none 21) - (gui-control-method-22 () none 22) - (gui-control-method-23 () none 23) - (gui-control-method-24 () none 24) + (new (symbol type int) _type_ 0) + (gui-control-method-9 (_type_ process gui-channel gui-action int float time-frame) sound-id 9) + (gui-control-method-10 (_type_ process gui-channel) none 10) + (gui-control-method-11 (_type_ gui-connection) int 11) + (gui-control-method-12 (_type_ process gui-channel gui-action string int float sound-id) sound-id 12) + (update (_type_ symbol) int 13) + (gui-control-method-14 (_type_ string gui-channel gui-action) int 14) + (gui-control-method-15 (_type_ process gui-channel string sound-id) gui-connection 15) + (gui-control-method-16 (_type_ gui-action sound-id gui-channel gui-action string (function gui-connection symbol) process) int 16) + (gui-control-method-17 (_type_ sound-id) gui-action 17) + (gui-control-method-18 (_type_ gui-channel) symbol 18) + (gui-control-method-19 (_type_ gui-channel gui-connection) symbol 19) + (gui-control-method-20 (_type_ sound-id symbol int int int) gui-connection 20) + (gui-control-method-21 (_type_ gui-connection vector) int 21) + (gui-control-method-22 (_type_ gui-connection process symbol) none 22) + (gui-control-method-23 (_type_ gui-channel gui-channel symbol gui-connection) symbol 23) + (channel-id-set! (_type_ gui-connection sound-id) int 24) ) - ) \ No newline at end of file + ) + + +(define-extern *gui-control* gui-control) + + + + diff --git a/goal_src/jak2/kernel-defs.gc b/goal_src/jak2/kernel-defs.gc index bcfb47ef2b..f4870bcd33 100644 --- a/goal_src/jak2/kernel-defs.gc +++ b/goal_src/jak2/kernel-defs.gc @@ -86,7 +86,7 @@ (define-extern process-level-heap kheap) ;; not a kheap at boot (define-extern stack symbol) (define-extern scratch symbol) -(define-extern *stratch-top* pointer) +(define-extern *scratch-top* pointer) (define-extern zero-func (function int)) ;; InitHeapAndSymbol @@ -102,6 +102,8 @@ (define-extern dgo-load (function string kheap link-flag int none)) (define-extern malloc (function symbol int pointer)) +(define-extern loado (function string kheap object)) +(define-extern link (function pointer pointer int kheap int pointer)) (declare-type cpad-info basic) (define-extern cpad-open (function cpad-info int cpad-info)) diff --git a/scripts/batch/gc-lt.bat b/scripts/batch/gc-lt.bat new file mode 100644 index 0000000000..f7f2d4455b --- /dev/null +++ b/scripts/batch/gc-lt.bat @@ -0,0 +1,4 @@ +@echo off +cd ..\.. +out\build\Release\bin\goalc --auto-lt --user-auto +pause diff --git a/scripts/batch/gc-no-lt.bat b/scripts/batch/gc-no-lt.bat deleted file mode 100644 index 59bc6c053f..0000000000 --- a/scripts/batch/gc-no-lt.bat +++ /dev/null @@ -1,4 +0,0 @@ -@echo off -cd ..\.. -out\build\Release\bin\goalc --user-auto -pause diff --git a/scripts/batch/gc.bat b/scripts/batch/gc.bat index f7f2d4455b..59bc6c053f 100644 --- a/scripts/batch/gc.bat +++ b/scripts/batch/gc.bat @@ -1,4 +1,4 @@ @echo off cd ..\.. -out\build\Release\bin\goalc --auto-lt --user-auto +out\build\Release\bin\goalc --user-auto pause diff --git a/scripts/batch/gc2.bat b/scripts/batch/gc2.bat new file mode 100644 index 0000000000..1204c3c465 --- /dev/null +++ b/scripts/batch/gc2.bat @@ -0,0 +1,4 @@ +@echo off +cd ..\.. +out\build\Release\bin\goalc --user-auto --game jak2 +pause diff --git a/scripts/batch/repo-settings-mark.bat b/scripts/batch/repo-settings-mark.bat index b112fa806b..2fb91f95b6 100644 --- a/scripts/batch/repo-settings-mark.bat +++ b/scripts/batch/repo-settings-mark.bat @@ -1,2 +1,2 @@ cd ..\.. -git update-index --assume-unchanged decompiler\config\jak1_ntsc_black_label.jsonc +git update-index --assume-unchanged decompiler\config\jak1_ntsc_black_label.jsonc decompiler\config\jak2_ntsc_v1.jsonc diff --git a/scripts/batch/repo-settings-unmark.bat b/scripts/batch/repo-settings-unmark.bat index 75b2a4777c..80100575ee 100644 --- a/scripts/batch/repo-settings-unmark.bat +++ b/scripts/batch/repo-settings-unmark.bat @@ -1,2 +1,2 @@ cd ..\.. -git update-index --no-assume-unchanged decompiler\config\jak1_ntsc_black_label.jsonc +git update-index --no-assume-unchanged decompiler\config\jak1_ntsc_black_label.jsonc decompiler\config\jak2_ntsc_v1.jsonc diff --git a/scripts/batch/test-types2.bat b/scripts/batch/test-types2.bat new file mode 100644 index 0000000000..79dc746c12 --- /dev/null +++ b/scripts/batch/test-types2.bat @@ -0,0 +1,4 @@ +@echo off +cd ..\.. +out\build\Release\bin\goalc-test --gtest_filter="Jak2TypeConsistency.TypeConsistency" +pause \ No newline at end of file diff --git a/scripts/batch/test2-offline-and-update.bat b/scripts/batch/test2-offline-and-update.bat new file mode 100644 index 0000000000..a48185e822 --- /dev/null +++ b/scripts/batch/test2-offline-and-update.bat @@ -0,0 +1,6 @@ +@echo off +cd ..\.. +out\build\Release\bin\offline-test -d --iso_data_path iso_data\jak2\ --game jak2 +scripts\update_decomp_reference.py failures\ test\decompiler\reference\ +RMDIR /Q/S failures +pause \ 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 8d8375314b..aca44fb11f 100644 --- a/test/decompiler/reference/jak2/decompiler-macros.gc +++ b/test/decompiler/reference/jak2/decompiler-macros.gc @@ -766,3 +766,135 @@ "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)) ) + +(defmacro ja-group (&key (chan 0)) + "get the frame group for self. default channel is 0, the base channel. returns #f if no frame group." + `(if (> (-> self skel active-channels) ,chan) + (-> self skel root-channel ,chan frame-group)) + ) + +(defmacro ja-group? (group &key (chan 0)) + "is self in this frame group on this channel? default is channel 0, which is the base channel." + `(= (ja-group) ,group) + ) + +(defmacro ja (&key (chan 0) + &key (group! #f) + &key (num! #f) + &key (param0 #f) + &key (param1 #f) + &key (num-func #f) + &key (frame-num #f) + &key (frame-interp #f) + &key (dist #f) + &key (eval? #t) + ) + "set various joint anim parameters for self and eval them. + you can use this for playing animations! + chan = the channel to modify. defaults to 0 (base channel). this is usually what you want. + group! = when not #f, set this as the new frame-group. defaults to #f + num! = set the frame playback function. this is what determines what frame an animation is at. funcs below. + #f = no func will be set, and there wont be a frame eval. + num-func = sets the num-func field for the channel. this lets you change the function with eval'ing. + param0 = 1st parameter for the playback function. ONLY USE THESE WITH num-func !! + param1 = 2nd parameter for the playback function. ONLY USE THESE WITH num-func !! + frame-num = set the frame-num field. + frame-interp = set the frame-interp field. + dist = set the dist field. + available num! functions: + - (+!) = advance anim. + - (-!) = reverse anim. + - (identity num) = play 'num' frame. + - (seek! target speed) = animate towards frame target at a speed. + speed is optional and defaults to 1.0 when not provided. + target is optional and defaults to the last frame of the animation. + if you want to set the speed, you therefore must also set the target. + target can be max (no quote), which is just the same as the default value. + - (loop! speed) = loop animation at a speed. default speed is 1.0 when not provided. + - (chan channel) = copy frame from another channel. + - min = the start of the animation. + - max = the end of the animation. + " + + (let* ((num-args (if (pair? num!) (cdr num!) '())) + (num! (if (pair? num!) (car num!) num!)) + (nf (cond + ((or (eq? num! 'identity) + (eq? num! 'min) + (eq? num! 'max) + ) + 'num-func-identity) + ((eq? num! 'none) 'num-func-none) + ((eq? num! '+!) 'num-func-+!) + ((eq? num! '-!) 'num-func--!) + ((eq? num! 'seek!) 'num-func-seek!) + ((eq? num! 'loop!) 'num-func-loop!) + ((eq? num! 'blend-in!) 'num-func-blend-in!) + ((eq? num! 'chan) 'num-func-chan) + )) + (p0 (if param0 param0 + (cond + ((eq? num! 'chan) `(the float ,(car num-args))) + ((eq? num! '+!) (if (null? num-args) 1.0 (car num-args))) + ((eq? num! '-!) (if (null? num-args) 1.0 (car num-args))) + ((eq? num! 'loop!) (if (null? num-args) 1.0 (if (eq? 'max (car num-args)) + (if group! + `(the float (1- (-> (the art-joint-anim ,group!) frames num-frames))) + `(the float (1- (-> ja-ch frame-group frames num-frames))) + ) + (car num-args)))) + ((eq? num! 'seek!) (if (or (null? num-args) (eq? (car num-args) 'max)) + (if group! + `(the float (1- (-> (the art-joint-anim ,group!) frames num-frames))) + `(the float (1- (-> ja-ch frame-group frames num-frames))) + ) + (car num-args))) + ))) + (p1 (if param1 param1 + (cond + ((eq? num! 'seek!) (if (or (null? num-args) (null? (cdr num-args))) 1.0 (cadr num-args))) + ))) + (frame-num (if (eq? 'max frame-num) (if group! + `(the float (1- (-> (the art-joint-anim ,group!) frames num-frames))) + `(the float (1- (-> ja-ch frame-group frames num-frames))) + ) + frame-num)) + (frame-group (if (or p0 p1 frame-num (not nf)) group! #f)) + ) + `(let ((ja-ch (-> self skel root-channel ,chan))) + ,(if frame-interp `(set! (-> ja-ch frame-interp) ,frame-interp) `(none)) + ,(if dist `(set! (-> ja-ch dist) ,dist) `(none)) + ,(if frame-group `(set! (-> ja-ch frame-group) (the art-joint-anim ,frame-group)) `(none)) + ,(if p0 `(set! (-> ja-ch param 0) ,p0) `(none)) + ,(if p1 `(set! (-> ja-ch param 1) ,p1) `(none)) + ,(if num-func `(set! (-> ja-ch num-func) ,num-func) `(none)) + ,(if frame-num `(set! (-> ja-ch frame-num) ,frame-num) `(none)) + ,(if nf + `(,(if eval? 'joint-control-channel-group-eval! 'joint-control-channel-group!) + ja-ch (the art-joint-anim ,group!) ,nf) + `(none)) + ,(cond + ((eq? num! 'min) `(set! (-> ja-ch frame-num) 0.0)) + ((eq? num! 'max) (if group! + `(set! (-> ja-ch frame-num) (the float (1- (-> (the art-joint-anim ,group!) frames num-frames)))) + `(set! (-> ja-ch frame-num) (the float (1- (-> ja-ch frame-group frames num-frames)))) + )) + ((eq? num! 'identity) `(set! (-> ja-ch frame-num) ,(car num-args))) + (#t `(none)) + ) + )) + ) + +(defmacro ja-no-eval (&key (chan 0) + &key (group! #f) + &key (num! #f) + &key (param0 #f) + &key (param1 #f) + &key (num-func #f) + &key (frame-num #f) + &key (frame-interp #f) + &key (dist #f) + ) + `(ja :eval? #f :chan ,chan :group! ,group! :num! ,num! :param0 ,param0 :param1 ,param1 :num-func ,num-func :frame-num ,frame-num :frame-interp ,frame-interp :dist ,dist) + ) + diff --git a/test/decompiler/reference/jak2/engine/anim/joint-mod-h_REF.gc b/test/decompiler/reference/jak2/engine/anim/joint-mod-h_REF.gc index 8348613753..128f925fb0 100644 --- a/test/decompiler/reference/jak2/engine/anim/joint-mod-h_REF.gc +++ b/test/decompiler/reference/jak2/engine/anim/joint-mod-h_REF.gc @@ -3,56 +3,56 @@ ;; definition of type joint-mod (deftype joint-mod (basic) - ((mode joint-mod-mode :offset-assert 4) - (process process :offset-assert 8) - (joint cspace :offset-assert 12) - (target vector :inline :offset 16) - (twist vector :inline :offset 32) - (twist-max float 4 :offset-assert 48) - (extra-twist degrees :offset 40) - (track-mode track-mode :offset 44) - (loock-at-count uint16 :offset 46) - (twist-range-x meters :offset 56) - (twist-range-y meters :offset 60) - (twist-speed-x float :offset 64) - (twist-speed-y float :offset 68) - (twist-min-x float :offset 72) - (twist-min-y float :offset 76) - (trans vector :inline :offset-assert 80) - (shmushy-old float :offset 80) - (smushy-off float :offset 84) - (smushyv float :offset 88) - (quat quaternion :inline :offset-assert 96) - (scale vector :inline :offset-assert 112) - (notice-time time-frame :offset-assert 128) - (flex-blend float :offset-assert 136) - (blend float :offset-assert 140) - (max-dist meters :offset-assert 144) - (ignore-angle degrees :offset-assert 148) - (up uint8 :offset-assert 152) - (nose uint8 :offset-assert 153) - (ear uint8 :offset-assert 154) - (base-joint uint8 :offset-assert 155) - (base-nose uint8 :offset-assert 156) - (shutting-down? symbol :offset-assert 160) - (parented-scale? symbol :offset-assert 164) - (polar-internal-tilt-max float :offset-assert 168) - (polar-internal-radius float :offset-assert 172) - (polar-external-tilt-max float :offset-assert 176) - (polar-external-radius float :offset-assert 180) + ((mode joint-mod-mode :offset-assert 4) + (process process-drawable :offset-assert 8) + (joint cspace :offset-assert 12) + (target vector :inline :offset-assert 16) + (twist vector :inline :offset-assert 32) + (twist-max vector :inline :offset-assert 48) + (extra-twist degrees :offset 40) + (track-mode track-mode :offset 44) + (loock-at-count uint16 :offset 46) + (twist-range-x meters :offset 56) + (twist-range-y meters :offset 60) + (twist-speed-x float :offset 64) + (twist-speed-y float :offset 68) + (twist-min-x float :offset 72) + (twist-min-y float :offset 76) + (trans vector :inline :offset-assert 80) + (shmushy-old float :offset 80) + (smushy-off float :offset 84) + (smushyv float :offset 88) + (quat quaternion :inline :offset-assert 96) + (scale vector :inline :offset-assert 112) + (notice-time time-frame :offset-assert 128) + (flex-blend float :offset-assert 136) + (blend float :offset-assert 140) + (max-dist meters :offset-assert 144) + (ignore-angle degrees :offset-assert 148) + (up uint8 :offset-assert 152) + (nose uint8 :offset-assert 153) + (ear uint8 :offset-assert 154) + (base-joint uint8 :offset-assert 155) + (base-nose uint8 :offset-assert 156) + (shutting-down? symbol :offset-assert 160) + (parented-scale? symbol :offset-assert 164) + (polar-internal-tilt-max float :offset-assert 168) + (polar-internal-radius float :offset-assert 172) + (polar-external-tilt-max float :offset-assert 176) + (polar-external-radius float :offset-assert 180) ) :method-count-assert 16 :size-assert #xb8 :flag-assert #x10000000b8 (:methods (new (symbol type joint-mod-mode process-drawable int) _type_ 0) - (joint-mod-method-9 () none 9) - (joint-mod-method-10 () none 10) - (joint-mod-method-11 () none 11) + (mode-set! (_type_ joint-mod-mode) none 9) + (target-set! (_type_ vector) none 10) + (look-at! (_type_ vector symbol process) none :behavior process 11) (reset-blend! (_type_) _type_ 12) - (joint-mod-method-13 () none 13) - (joint-mod-method-14 () none 14) - (joint-mod-method-15 () none 15) + (twist-set! (_type_ float float float) vector 13) + (trs-set! (_type_ vector quaternion vector) none 14) + (shut-down (_type_) none 15) ) ) @@ -96,8 +96,8 @@ ) (format #t ")~%") (format #t "~1Tlook-at-count: ~D~%" (-> obj loock-at-count)) - (format #t "~1Ttwist-range-x: (meters ~m)~%" (-> obj twist-range-x)) - (format #t "~1Ttwist-range-y: (meters ~m)~%" (-> obj twist-range-y)) + (format #t "~1Ttwist-range-x: (meters ~m)~%" (-> obj twist-max z)) + (format #t "~1Ttwist-range-y: (meters ~m)~%" (-> obj twist-max w)) (format #t "~1Ttwist-speed-x: ~f~%" (-> obj twist-speed-x)) (format #t "~1Ttwist-speed-y: ~f~%" (-> obj twist-speed-y)) (format #t "~1Ttwist-min-x: ~f~%" (-> obj twist-min-x)) @@ -613,12 +613,12 @@ ;; definition of type joint-mod-blend-world (deftype joint-mod-blend-world (basic) - ((transform transformq :inline :offset-assert 16) - (blend-transform transformq :inline :offset-assert 64) - (blend-flags uint32 :offset-assert 112) - (node-index int32 :offset-assert 116) - (blend float :offset-assert 120) - (enable symbol :offset-assert 124) + ((transform transformq :inline :offset-assert 16) + (blend-transform transformq :inline :offset-assert 64) + (blend-flags joint-mod-blend-flags :offset-assert 112) + (node-index int32 :offset-assert 116) + (blend float :offset-assert 120) + (enable symbol :offset-assert 124) ) :method-count-assert 9 :size-assert #x80 @@ -656,17 +656,17 @@ (let ((gp-0 (the-as joint-mod-blend-world (-> arg0 param1)))) (cond ((-> gp-0 enable) - (let ((f30-0 (if (logtest? (-> gp-0 blend-flags) 1) + (let ((f30-0 (if (logtest? (-> gp-0 blend-flags) (joint-mod-blend-flags trans)) (-> gp-0 blend) 0.0 ) ) - (f28-0 (if (logtest? (-> gp-0 blend-flags) 2) + (f28-0 (if (logtest? (-> gp-0 blend-flags) (joint-mod-blend-flags scale)) (-> gp-0 blend) 0.0 ) ) - (f26-0 (if (logtest? (-> gp-0 blend-flags) 4) + (f26-0 (if (logtest? (-> gp-0 blend-flags) (joint-mod-blend-flags rotation)) (-> gp-0 blend) 0.0 ) @@ -794,28 +794,29 @@ ;; definition of type joint-mod-ik (deftype joint-mod-ik (basic) - ((flags uint32 :offset-assert 4) - (process basic :offset-assert 8) - (hand-dist float :offset-assert 12) - (handle-pos vector :inline :offset-assert 16) - (elbow-pole-vector-axis uint32 :offset-assert 32) - (elbow-rotation-axis uint32 :offset-assert 36) - (user-position vector :inline :offset-assert 48) - (user-normal vector :inline :offset-assert 64) - (user-blend float :offset-assert 80) - (user-float float :offset-assert 84) - (callback basic :offset-assert 88) - (shoulder-matrix-no-ik matrix :inline :offset-assert 96) - (elbow-matrix-no-ik matrix :inline :offset-assert 160) - (blend float :offset-assert 224) - (blend-interp float :offset-assert 228) + ((flags joint-mod-ik-flags :offset-assert 4) + (process process-drawable :offset-assert 8) + (hand-dist float :offset-assert 12) + (handle-pos vector :inline :offset-assert 16) + (elbow-pole-vector-axis uint32 :offset-assert 32) + (elbow-rotation-axis uint32 :offset-assert 36) + (user-position vector :inline :offset-assert 48) + (user-normal vector :inline :offset-assert 64) + (user-blend float :offset-assert 80) + (user-float float :offset-assert 84) + (callback (function joint-mod-ik matrix matrix vector object) :offset-assert 88) + (shoulder-matrix-no-ik matrix :inline :offset-assert 96) + (elbow-matrix-no-ik matrix :inline :offset-assert 160) + (blend float :offset-assert 224) + (blend-interp float :offset-assert 228) ) :method-count-assert 11 :size-assert #xe8 :flag-assert #xb000000e8 (:methods - (joint-mod-ik-method-9 () none 9) - (joint-mod-ik-method-10 () none 10) + (new (symbol type process-drawable int float) _type_ 0) + (handle-copy! (_type_ vector) none 9) + (enable-set! (_type_ symbol) none 10) ) ) diff --git a/test/decompiler/reference/jak2/engine/anim/joint-mod_REF.gc b/test/decompiler/reference/jak2/engine/anim/joint-mod_REF.gc new file mode 100644 index 0000000000..6d8b553a82 --- /dev/null +++ b/test/decompiler/reference/jak2/engine/anim/joint-mod_REF.gc @@ -0,0 +1,1546 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition for function joint-mod-ik-callback +;; INFO: Used lq/sq +;; INFO: Return type mismatch matrix vs none. +;; WARN: Function joint-mod-ik-callback has a return type of none, but the expression builder found a return statement. +;; ERROR: Unsupported inline assembly instruction kind - [mula.s f0, f3] +;; ERROR: Unsupported inline assembly instruction kind - [madda.s f1, f4] +;; ERROR: Unsupported inline assembly instruction kind - [madd.s f0, f2, f5] +(defbehavior joint-mod-ik-callback process ((arg0 cspace) (arg1 transformq)) + (local-vars + (f0-24 float) + (sv-736 vector) + (sv-752 vector) + (sv-768 vector) + (sv-784 vector) + (sv-800 (function quaternion vector vector quaternion)) + (sv-816 quaternion) + (sv-832 vector) + (sv-848 vector) + (sv-864 vector) + (sv-880 vector) + (sv-896 vector) + (sv-912 quaternion) + (sv-928 quaternion) + ) + (rlet ((acc :class vf) + (vf0 :class vf) + (vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + (vf7 :class vf) + ) + (init-vf0-vector) + (let ((gp-0 (the-as joint-mod-ik (-> arg0 param1)))) + (-> arg0 param2) + (cspace<-parented-transformq-joint! arg0 arg1) + (cond + ((logtest? (-> gp-0 flags) (joint-mod-ik-flags enable)) + (+! (-> gp-0 blend) (* 4.0 (-> self clock seconds-per-frame))) + (if (< 1.0 (-> gp-0 blend)) + (set! (-> gp-0 blend) 1.0) + ) + ) + (else + (set! (-> gp-0 blend) (- (-> gp-0 blend) (* 4.0 (-> self clock seconds-per-frame)))) + (if (< (-> gp-0 blend) 0.0) + (set! (-> gp-0 blend) 0.0) + ) + ) + ) + (if (= (-> gp-0 blend) 0.0) + (return #f) + ) + (let ((s5-0 (-> arg0 parent bone transform)) + (s4-1 (-> arg0 bone transform)) + ) + (new 'stack-no-clear 'matrix) + (new 'stack-no-clear 'matrix) + (let ((s3-0 (new 'stack-no-clear 'vector))) + (matrix->trans s5-0 s3-0) + (set! (-> s5-0 trans quad) (-> s3-0 quad)) + (matrix->trans s4-1 s3-0) + (set! (-> s4-1 trans quad) (-> s3-0 quad)) + ) + (let* ((a2-0 (-> gp-0 shoulder-matrix-no-ik)) + (a3-0 s5-0) + (v1-22 (-> a3-0 vector 0 quad)) + (a0-7 (-> a3-0 vector 1 quad)) + (a1-3 (-> a3-0 vector 2 quad)) + (a3-1 (-> a3-0 trans quad)) + ) + (set! (-> a2-0 vector 0 quad) v1-22) + (set! (-> a2-0 vector 1 quad) a0-7) + (set! (-> a2-0 vector 2 quad) a1-3) + (set! (-> a2-0 trans quad) a3-1) + ) + (let* ((a2-1 (-> gp-0 elbow-matrix-no-ik)) + (a3-2 s4-1) + (v1-23 (-> a3-2 vector 0 quad)) + (a0-8 (-> a3-2 vector 1 quad)) + (a1-4 (-> a3-2 vector 2 quad)) + (a3-3 (-> a3-2 trans quad)) + ) + (set! (-> a2-1 vector 0 quad) v1-23) + (set! (-> a2-1 vector 1 quad) a0-8) + (set! (-> a2-1 vector 2 quad) a1-4) + (set! (-> a2-1 trans quad) a3-3) + ) + (set! sv-752 (new 'stack-no-clear 'vector)) + (set! sv-736 (new 'stack-no-clear 'vector)) + (let ((s0-0 (new 'stack-no-clear 'vector)) + (s1-0 (new 'stack-no-clear 'vector)) + (s3-1 (new 'stack-no-clear 'vector)) + ) + 0.0 + 0.0 + (set! (-> sv-752 quad) (-> s5-0 trans quad)) + (set! (-> sv-736 quad) (-> s4-1 trans quad)) + (let ((a1-5 s0-0)) + (let ((v1-28 sv-736)) + (let ((a0-13 (-> s4-1 vector 1))) + (let ((a2-2 (-> gp-0 hand-dist))) + (.mov vf7 a2-2) + ) + (.lvf vf5 (&-> a0-13 quad)) + ) + (.lvf vf4 (&-> v1-28 quad)) + ) + (.add.x.vf vf6 vf0 vf0 :mask #b1000) + (.mul.x.vf acc vf5 vf7 :mask #b111) + (.add.mul.w.vf vf6 vf4 vf0 acc :mask #b111) + (.svf (&-> a1-5 quad) vf6) + ) + (if (-> gp-0 callback) + ((-> gp-0 callback) gp-0 s5-0 s4-1 s0-0) + ) + (set! (-> s1-0 quad) (-> gp-0 handle-pos quad)) + (let ((f30-0 (vector-vector-distance sv-752 sv-736)) + (f0-12 (vector-vector-distance sv-736 s0-0)) + (s2-1 (vector-! (new 'stack-no-clear 'vector) s1-0 sv-752)) + ) + (vector-length s2-1) + (+ -4.096 f0-12 f30-0) + (let ((f0-15 (+ 4.096 (fabs (- f30-0 f0-12))))) + (cond + ((< f0-15 f0-15) + (vector-normalize! s2-1 f0-15) + (vector+! s1-0 sv-752 s2-1) + ) + ((< f0-15 f0-15) + (vector-normalize! s2-1 f0-15) + (vector+! s1-0 sv-752 s2-1) + ) + ) + ) + ) + (let ((s2-3 (vector-! (new 'stack-no-clear 'vector) sv-736 sv-752))) + (set! sv-784 (new 'stack-no-clear 'vector)) + (.lvf vf4 (&-> s0-0 quad)) + (.lvf vf5 (&-> sv-736 quad)) + (.mov.vf vf6 vf0 :mask #b1000) + (.sub.vf vf6 vf4 vf5 :mask #b111) + (.svf (&-> sv-784 quad) vf6) + (set! sv-832 (new 'stack-no-clear 'vector)) + (let ((v1-49 sv-752)) + (.lvf vf4 (&-> s0-0 quad)) + (.lvf vf5 (&-> v1-49 quad)) + ) + (.mov.vf vf6 vf0 :mask #b1000) + (.sub.vf vf6 vf4 vf5 :mask #b111) + (.svf (&-> sv-832 quad) vf6) + (let ((s0-1 (new 'stack-no-clear 'vector))) + (.lvf vf4 (&-> s1-0 quad)) + (.lvf vf5 (&-> sv-752 quad)) + (.mov.vf vf6 vf0 :mask #b1000) + (.sub.vf vf6 vf4 vf5 :mask #b111) + (.svf (&-> s0-1 quad) vf6) + (set! sv-928 (new 'stack-no-clear 'quaternion)) + (let ((s1-1 (new 'stack-no-clear 'quaternion))) + (let ((f26-0 (vector-length s2-3)) + (f24-0 (vector-length sv-784)) + (f30-1 (vector-length s0-1)) + ) + (set! sv-768 (new 'stack-no-clear 'vector)) + (let* ((f28-0 (vector-vector-angle-safe s2-3 sv-784)) + (f0-17 (fmax -1.0 (fmin 1.0 (/ (- (- (* f30-1 f30-1) (* f26-0 f26-0)) (* f24-0 f24-0)) (* 2.0 f24-0 f26-0))))) + (f26-1 (acos f0-17)) + ) + (cond + ((= f28-0 0.0) + (set! (-> sv-768 quad) (-> s4-1 vector (-> gp-0 elbow-rotation-axis) quad)) + (when (logtest? (-> gp-0 flags) (joint-mod-ik-flags elbow-rot-neg)) + (vector-negate! sv-768 sv-768) + (set! f26-1 (- f26-1)) + ) + (set! (-> s3-1 quad) (-> s4-1 vector (-> gp-0 elbow-pole-vector-axis) quad)) + (if (logtest? (-> gp-0 flags) (joint-mod-ik-flags elbow-trans-neg)) + (vector-negate! s3-1 s3-1) + ) + ) + (else + (vector-cross! sv-768 s2-3 sv-784) + (vector-! + s3-1 + s2-3 + (the-as + vector + (vector-float*! (new 'stack-no-clear 'vector) sv-832 (/ (vector-dot sv-832 s2-3) (vector-dot sv-832 sv-832))) + ) + ) + ) + ) + (vector-normalize! s3-1 1.0) + (vector-normalize! sv-768 1.0) + (let ((t9-14 quaternion-vector-angle!) + (a0-44 sv-928) + (a2-5 (- f26-1 f28-0)) + ) + (t9-14 a0-44 sv-768 a2-5) + ) + ) + (vector-orient-by-quat! sv-784 sv-784 sv-928) + (let ((v1-74 sv-832)) + (let ((a0-46 s2-3)) + (.mov.vf vf6 vf0 :mask #b1000) + (.lvf vf4 (&-> a0-46 quad)) + ) + (.lvf vf5 (&-> sv-784 quad)) + (.add.vf vf6 vf4 vf5 :mask #b111) + (.svf (&-> v1-74 quad) vf6) + ) + (set! sv-800 quaternion-from-two-vectors!) + (set! sv-816 s1-1) + (let ((t9-16 vector-normalize-copy!) + (a0-48 (new 'stack-no-clear 'vector)) + (a2-7 1.0) + ) + (set! sv-848 (t9-16 a0-48 sv-832 a2-7)) + ) + (let ((a2-9 (vector-normalize-copy! (new 'stack-no-clear 'vector) s0-1 1.0))) + (sv-800 sv-816 sv-848 a2-9) + ) + (vector-orient-by-quat! s2-3 s2-3 s1-1) + (set! sv-864 (vector-normalize-copy! (new 'stack-no-clear 'vector) s2-3 1.0)) + (let* ((v1-76 (vector-normalize-copy! (new 'stack-no-clear 'vector) s0-1 1.0)) + (f0-23 (-> sv-864 x)) + (f1-16 (-> sv-864 y)) + (f2-6 (-> sv-864 z)) + (f3-5 (-> v1-76 x)) + (f4-0 (-> v1-76 y)) + (f5-0 (-> v1-76 z)) + ) + (.mula.s f0-23 f3-5) + (.madda.s f1-16 f4-0) + (.madd.s f0-24 f2-6 f5-0) + ) + (let ((f0-26 (fabs f0-24))) + (if (< 0.98 f0-26) + (vector-orient-by-quat! s2-3 s3-1 s1-1) + ) + ) + (set! sv-880 (new 'stack-no-clear 'vector)) + (set! sv-896 (new 'stack-no-clear 'vector)) + (new 'stack-no-clear 'vector) + (* f30-1 f30-1) + ) + (set! sv-912 (new 'stack-no-clear 'quaternion)) + (vector-flatten! sv-880 s2-3 s0-1) + (vector-flatten! sv-896 s3-1 s0-1) + (vector-normalize! sv-880 1.0) + (vector-normalize! sv-896 1.0) + (quaternion-from-two-vectors! sv-912 sv-880 sv-896) + (let ((t9-28 quaternion*!) + (a0-63 s1-1) + (a2-17 s1-1) + ) + (t9-28 a0-63 sv-912 a2-17) + ) + (quaternion-pseudo-slerp! sv-928 *unity-quaternion* sv-928 (-> gp-0 blend)) + (quaternion-pseudo-slerp! s1-1 *unity-quaternion* s1-1 (-> gp-0 blend)) + (let ((a2-20 (quaternion->matrix (new 'stack-no-clear 'matrix) sv-928)) + (gp-1 (new 'stack-no-clear 'vector)) + ) + (set! (-> gp-1 quad) (-> s4-1 trans quad)) + (matrix*! s4-1 s4-1 a2-20) + (set! (-> s4-1 trans quad) (-> gp-1 quad)) + ) + (let ((s3-2 (quaternion->matrix (new 'stack-no-clear 'matrix) s1-1)) + (a2-21 (matrix-4x4-inverse! (new 'stack-no-clear 'matrix) s5-0)) + (gp-2 (new 'stack-no-clear 'matrix)) + ) + (set! (-> gp-2 vector 0 quad) (-> s5-0 trans quad)) + (matrix*! s4-1 s4-1 a2-21) + (matrix*! s5-0 s5-0 s3-2) + (set! (-> s5-0 trans quad) (-> gp-2 vector 0 quad)) + ) + ) + ) + ) + ) + (matrix*! s4-1 s4-1 s5-0) + ) + ) + (none) + ) + ) + +;; definition for method 0 of type joint-mod-ik +(defmethod new joint-mod-ik ((allocation symbol) (type-to-make type) (arg0 process-drawable) (arg1 int) (arg2 float)) + (let ((v0-0 (object-new allocation type-to-make (the-as int (-> type-to-make size))))) + (set! (-> v0-0 process) arg0) + (set! (-> v0-0 hand-dist) arg2) + (set! (-> v0-0 elbow-pole-vector-axis) (the-as uint 0)) + (logclear! (-> v0-0 flags) (joint-mod-ik-flags elbow-trans-neg)) + (set! (-> v0-0 elbow-rotation-axis) (the-as uint 2)) + (logclear! (-> v0-0 flags) (joint-mod-ik-flags elbow-rot-neg)) + (set! (-> v0-0 callback) #f) + (set! (-> v0-0 blend) 0.0) + (logclear! (-> v0-0 flags) (joint-mod-ik-flags enable)) + (let ((a0-5 (-> arg0 node-list data arg1))) + (set! (-> a0-5 param0) joint-mod-ik-callback) + (set! (-> a0-5 param1) v0-0) + (set! (-> a0-5 param2) (the-as basic arg1)) + ) + v0-0 + ) + ) + +;; definition for method 9 of type joint-mod-ik +;; INFO: Used lq/sq +;; INFO: Return type mismatch int vs none. +(defmethod handle-copy! joint-mod-ik ((obj joint-mod-ik) (arg0 vector)) + (set! (-> obj handle-pos quad) (-> arg0 quad)) + 0 + (none) + ) + +;; definition for method 10 of type joint-mod-ik +;; INFO: Return type mismatch int vs none. +(defmethod enable-set! joint-mod-ik ((obj joint-mod-ik) (arg0 symbol)) + (if arg0 + (logior! (-> obj flags) (joint-mod-ik-flags enable)) + (logclear! (-> obj flags) (joint-mod-ik-flags enable)) + ) + 0 + (none) + ) + +;; definition for function real-joint-mod-gun-look-at-handler +;; INFO: Return type mismatch int vs none. +(defbehavior real-joint-mod-gun-look-at-handler process ((arg0 cspace) (arg1 transformq)) + (local-vars + (sv-16 joint-mod) + (sv-64 vector) + (sv-96 quaternion) + (sv-160 vector) + (sv-164 vector) + (sv-168 vector) + (sv-172 symbol) + ) + (rlet ((acc :class vf) + (vf0 :class vf) + (vf1 :class vf) + (vf2 :class vf) + (vf3 :class vf) + (vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + ) + (init-vf0-vector) + (set! sv-16 (the-as joint-mod (-> arg0 param1))) + (let ((a0-1 (-> arg1 scale))) + (let ((v1-1 (-> arg1 scale)) + (a2-1 (-> sv-16 scale)) + ) + (.lvf vf4 (&-> v1-1 quad)) + (.lvf vf5 (&-> a2-1 quad)) + ) + (.add.x.vf vf6 vf0 vf0 :mask #b1000) + (.mul.vf vf6 vf4 vf5 :mask #b111) + (.svf (&-> a0-1 quad) vf6) + ) + (cspace<-parented-transformq-joint! arg0 arg1) + (let ((s5-0 (-> arg0 bone transform))) + (let ((s4-0 (matrix->quat s5-0 (new 'stack-no-clear 'quaternion)))) + (set! sv-64 (matrix->trans s5-0 (new 'stack-no-clear 'vector))) + (quaternion-rotate-y! s4-0 s4-0 (-> sv-16 twist z)) + (set! sv-96 (quaternion-copy! (new 'stack-no-clear 'quaternion) s4-0)) + (when (!= (-> sv-16 flex-blend) 0.0) + (set! sv-160 (vector-y-quaternion! (new 'stack-no-clear 'vector) sv-96)) + (set! sv-164 (vector-z-quaternion! (new 'stack-no-clear 'vector) sv-96)) + (set! sv-168 (vector-normalize! (vector-! (new 'stack-no-clear 'vector) (-> sv-16 target) sv-64) 1.0)) + (set! sv-172 (the-as symbol #f)) + (let* ((f30-0 (vector-y-angle sv-164)) + (a0-13 (vector-flatten! (new 'stack-no-clear 'vector) sv-168 sv-160)) + (f0-2 (vector-y-angle a0-13)) + (f0-3 (deg-diff f30-0 f0-2)) + (f30-1 (* f0-3 (-> sv-16 blend))) + ) + (let ((f28-0 (fmax (fmin f30-1 (-> sv-16 twist-max y)) (- (-> sv-16 twist-max y))))) + (if (or (!= f30-1 f28-0) (= (-> sv-16 blend) 0.0)) + (logclear! (-> sv-16 track-mode) (track-mode lock-on)) + ) + (cond + ((or (< (-> sv-16 ignore-angle) (fabs f0-3)) + (< (-> sv-16 twist-max w) (vector-vector-distance (-> sv-16 target) sv-64)) + ) + (set! f30-1 0.0) + (set! f28-0 0.0) + (set! sv-172 #t) + ) + ((< 5461.3335 (fabs (deg-diff f30-1 f28-0))) + (set! (-> sv-16 blend) 0.0001) + ) + ((< 182.04445 (fabs (deg-diff f30-1 f28-0))) + (logclear! (-> sv-16 track-mode) (track-mode track-x)) + ) + ) + (if (or (and (logtest? (-> sv-16 track-mode) (track-mode track-y)) (= f30-1 f28-0)) + (< (-> sv-16 twist-max y) (fabs (-> sv-16 twist y))) + ) + (set! (-> sv-16 twist y) + (deg-seek (-> sv-16 twist y) f28-0 (* (fabs (deg-diff f28-0 (-> sv-16 twist y))) + (if (logtest? (-> sv-16 track-mode) (track-mode lock-on)) + 1.0 + (-> sv-16 twist-speed-y) + ) + (-> self clock time-adjust-ratio) + ) + ) + ) + ) + ) + (if (and (< (fabs (deg-diff f30-1 (-> sv-16 twist y))) 728.1778) (and (not sv-172) (!= (-> sv-16 blend) 0.0))) + (logior! (-> sv-16 track-mode) (track-mode lock-on)) + ) + ) + (quaternion-rotate-local-y! sv-96 sv-96 (-> sv-16 twist y)) + (let* ((s3-1 (vector-x-quaternion! (new 'stack-no-clear 'vector) sv-96)) + (f30-2 (vector-x-angle sv-164)) + (s3-2 (vector-flatten! (new 'stack-no-clear 'vector) sv-168 s3-1)) + (f0-24 (vector-x-angle s3-2)) + (f30-3 (fmax + (fmin (* (- (deg-diff f30-2 f0-24)) (-> sv-16 blend)) (-> sv-16 twist-max x)) + (- (-> sv-16 twist-max x)) + ) + ) + ) + (if (or (< (vector-dot s3-2 sv-164) 0.1) + (< (-> sv-16 twist-max z) (vector-vector-distance (-> sv-16 target) sv-64)) + ) + (set! f30-3 0.0) + ) + (if (or (logtest? (-> sv-16 track-mode) (track-mode track-x)) + (< (-> sv-16 twist-max x) (fabs (-> sv-16 twist x))) + ) + (set! (-> sv-16 twist x) + (deg-seek (-> sv-16 twist x) f30-3 (* (fabs (deg-diff f30-3 (-> sv-16 twist x))) + (if (logtest? (-> sv-16 track-mode) (track-mode lock-on)) + 1.0 + (-> sv-16 twist-speed-x) + ) + (-> self clock time-adjust-ratio) + ) + ) + ) + ) + ) + (quaternion-rotate-x! sv-96 sv-96 (-> sv-16 twist x)) + (quaternion-normalize! (quaternion*! sv-96 sv-96 (-> sv-16 quat))) + ) + (let ((a1-27 (quaternion-slerp! (new 'stack-no-clear 'quaternion) s4-0 sv-96 (-> sv-16 flex-blend)))) + (matrix<-quat s5-0 a1-27) + ) + ) + (let ((f30-4 (-> sv-16 trans x)) + (s4-1 (-> s5-0 vector 1)) + (v1-97 (vector<-matrix! (new 'stack-no-clear 'vector) s5-0)) + ) + (let ((f0-43 (- f30-4 (-> v1-97 y)))) + (if (< 614.4 (fabs f0-43)) + (+! (-> sv-16 trans z) (* 8.0 f0-43)) + ) + ) + (+! (-> sv-16 trans z) (* -260.0 (-> self clock seconds-per-frame) (-> sv-16 trans y))) + (let ((f0-48 (-> sv-16 trans y))) + (+! (-> sv-16 trans y) (* (-> sv-16 trans z) (-> self clock seconds-per-frame))) + (set! (-> sv-16 trans y) (* 0.95 (-> sv-16 trans y))) + (when (< (* f0-48 (-> sv-16 trans y)) 0.0) + (set! (-> sv-16 trans y) 0.0) + (set! (-> sv-16 trans z) 0.0) + ) + ) + (cond + ((< 409.6 (-> sv-16 trans y)) + (set! (-> sv-16 trans y) 409.6) + (set! (-> sv-16 trans z) 0.0) + ) + ((< (-> sv-16 trans y) -409.6) + (set! (-> sv-16 trans y) -409.6) + (set! (-> sv-16 trans z) 0.0) + ) + ) + (set! (-> sv-16 trans x) (-> v1-97 y)) + (let ((f0-60 (* (-> sv-16 trans y) (-> sv-16 flex-blend)))) + (when (!= f0-60 0.0) + (let ((a0-86 (-> s5-0 trans))) + (.lvf vf2 (&-> s4-1 quad)) + (.lvf vf1 (&-> v1-97 quad)) + (let ((v1-98 f0-60)) + (.mov vf3 v1-98) + ) + (.add.x.vf vf4 vf0 vf0 :mask #b1000) + (.mul.x.vf acc vf2 vf3) + (.add.mul.w.vf vf4 vf1 vf0 acc :mask #b111) + (.svf (&-> a0-86 quad) vf4) + ) + ) + ) + ) + ) + (if (-> sv-16 parented-scale?) + (set-vector! (-> arg0 bone scale) 1.0 1.0 1.0 1.0) + ) + 0 + (none) + ) + ) + +;; definition for function joint-mod-gun-look-at-handler +(defbehavior joint-mod-gun-look-at-handler process ((arg0 cspace) (arg1 transformq)) + (real-joint-mod-gun-look-at-handler arg0 arg1) + (none) + ) + +;; definition for function joint-mod-foot-rot-handler +;; INFO: Used lq/sq +;; INFO: Return type mismatch int vs none. +(defbehavior joint-mod-foot-rot-handler process ((arg0 cspace) (arg1 transformq)) + (let ((s5-0 (the-as joint-mod (-> arg0 param1))) + (gp-0 (-> arg0 bone transform)) + ) + (cspace<-parented-transformq-joint! arg0 arg1) + (let ((s3-0 (-> s5-0 target)) + (s4-0 (-> s5-0 twist-max)) + ) + 1.0 + (when (< 8192.0 (vector-vector-angle-safe s3-0 s4-0)) + (let* ((a1-4 (vector-normalize! (vector-cross! (new 'stack-no-clear 'vector) s3-0 s4-0) 1.0)) + (a2-1 (quaternion-vector-angle! (new 'stack-no-clear 'quaternion) a1-4 8192.0)) + ) + (vector-orient-by-quat! s4-0 s3-0 a2-1) + ) + ) + (let* ((f0-4 (/ (vector-dot *up-vector* (-> s5-0 joint bone transform vector 1)) + (vector-length (-> s5-0 joint bone transform vector 1)) + ) + ) + (f30-1 (lerp-scale 0.0 1.0 f0-4 0.85 1.0)) + ) + (vector-deg-slerp (-> s5-0 twist) (-> s5-0 twist) s4-0 0.3) + (set! (-> s4-0 quad) (-> s5-0 twist quad)) + (seek! (-> s5-0 blend) (-> s5-0 flex-blend) (* 4.0 (-> self clock seconds-per-frame))) + (let ((s3-1 (matrix->scale gp-0 (new 'stack-no-clear 'vector)))) + (let ((s2-0 (matrix->quat gp-0 (new 'stack-no-clear 'quaternion))) + (s0-0 (matrix->trans gp-0 (new 'stack-no-clear 'vector))) + ) + (set! (-> gp-0 vector 1 quad) (-> s5-0 twist-max quad)) + (vector-cross! (-> gp-0 vector 2) (the-as vector (-> gp-0 vector)) (-> gp-0 vector 1)) + (vector-cross! (the-as vector (-> gp-0 vector)) (-> gp-0 vector 1) (-> gp-0 vector 2)) + (set! (-> gp-0 vector 0 w) 0.0) + (set! (-> gp-0 vector 1 w) 0.0) + (set! (-> gp-0 vector 2 w) 0.0) + (let ((s1-0 (matrix->quat gp-0 (new 'stack-no-clear 'quaternion)))) + (let* ((f0-14 (vector-dot s4-0 (vector-! (new 'stack-no-clear 'vector) s0-0 (-> s5-0 trans)))) + (f0-15 (lerp-scale 1.0 0.0 f0-14 819.2 2048.0)) + ) + (seek! + (-> s5-0 polar-internal-tilt-max) + (* (-> s5-0 blend) f0-15 f30-1) + (* 15.0 (-> self clock seconds-per-frame)) + ) + ) + (quaternion-slerp! s1-0 s2-0 s1-0 (-> s5-0 polar-internal-tilt-max)) + (matrix<-quat gp-0 s1-0) + ) + ) + (matrix<-scale gp-0 s3-1) + ) + ) + ) + ) + 0 + (none) + ) + +;; definition for method 0 of type joint-mod +(defmethod new joint-mod ((allocation symbol) (type-to-make type) (arg0 joint-mod-mode) (arg1 process-drawable) (arg2 int)) + (let ((gp-0 (object-new allocation type-to-make (the-as int (-> type-to-make size))))) + (set! (-> gp-0 process) arg1) + (set! (-> gp-0 joint) (-> arg1 node-list data arg2)) + (mode-set! gp-0 arg0) + (set-vector! (-> gp-0 twist-max) 8192.0 11832.889 0.0 1.0) + (set! (-> gp-0 twist-speed-x) 0.1) + (set! (-> gp-0 twist-speed-y) 0.1) + (set! (-> gp-0 twist-min-x) (-> gp-0 twist-max x)) + (set! (-> gp-0 twist-min-y) (-> gp-0 twist-max y)) + (set! (-> gp-0 up) (the-as uint 1)) + (set! (-> gp-0 nose) (the-as uint 2)) + (set! (-> gp-0 ear) (the-as uint 0)) + (set! (-> gp-0 base-joint) (the-as uint arg2)) + (set! (-> gp-0 base-nose) (the-as uint 2)) + (set! (-> gp-0 max-dist) 122880.0) + (set! (-> gp-0 ignore-angle) 65536.0) + (set! (-> gp-0 flex-blend) 1.0) + (set! (-> gp-0 shutting-down?) #f) + (set-vector! (-> gp-0 scale) 1.0 1.0 1.0 1.0) + (set! (-> gp-0 parented-scale?) #f) + (quaternion-identity! (-> gp-0 quat)) + gp-0 + ) + ) + +;; definition for method 9 of type joint-mod +;; INFO: Return type mismatch joint-mod vs none. +(defmethod mode-set! joint-mod ((obj joint-mod) (arg0 joint-mod-mode)) + (set! (-> obj mode) arg0) + (let ((v1-0 (-> obj joint))) + (case arg0 + (((joint-mod-mode flex-blend)) + (set! (-> v1-0 param0) #f) + (set! (-> obj blend) 0.0) + (set! (-> obj flex-blend) 1.0) + ) + (((joint-mod-mode reset)) + (set! (-> v1-0 param0) #f) + (set! (-> obj blend) 0.0) + (set! (-> obj shutting-down?) #f) + ) + (((joint-mod-mode look-at)) + (let ((a0-4 v1-0)) + (set! (-> a0-4 param0) joint-mod-look-at-handler) + (set! (-> a0-4 param1) obj) + ) + ) + (((joint-mod-mode gun-look-at)) + (let ((a0-5 v1-0)) + (set! (-> a0-5 param0) joint-mod-gun-look-at-handler) + (set! (-> a0-5 param1) obj) + ) + ) + (((joint-mod-mode foot-rot)) + (set-vector! (-> obj twist) 0.0 1.0 0.0 1.0) + (let ((a0-7 v1-0)) + (set! (-> a0-7 param0) + (lambda ((arg0 cspace) (arg1 transformq)) (joint-mod-foot-rot-handler arg0 arg1) (none)) + ) + (set! (-> a0-7 param1) obj) + ) + ) + (((joint-mod-mode world-look-at)) + (let ((a0-8 v1-0)) + (set! (-> a0-8 param0) joint-mod-world-look-at-handler) + (set! (-> a0-8 param1) obj) + ) + ) + (((joint-mod-mode polar-look-at)) + (let ((a0-9 v1-0)) + (set! (-> a0-9 param0) joint-mod-polar-look-at-handler) + (set! (-> a0-9 param1) obj) + ) + (set! (-> obj polar-internal-tilt-max) 32768.0) + (set! (-> obj polar-internal-radius) 32768.0) + (set! (-> obj polar-external-tilt-max) 32768.0) + (set! (-> obj polar-external-radius) 32768.0) + ) + (((joint-mod-mode rotate)) + (let ((a0-11 v1-0)) + (set! (-> a0-11 param0) joint-mod-rotate-handler) + (set! (-> a0-11 param1) obj) + ) + (set! (-> obj blend) 1.0) + ) + (((joint-mod-mode rotate2)) + (let ((a0-13 v1-0)) + (set! (-> a0-13 param0) joint-mod-rotate-handler) + (set! (-> a0-13 param1) obj) + ) + (set! (-> obj blend) 1.0) + ) + (((joint-mod-mode joint-set)) + (let ((a0-15 v1-0)) + (set! (-> a0-15 param0) joint-mod-joint-set-handler) + (set! (-> a0-15 param1) obj) + ) + (vector-reset! (-> obj trans)) + (quaternion-identity! (-> obj quat)) + (set-vector! (-> obj scale) 1.0 1.0 1.0 1.0) + ) + (((joint-mod-mode joint-set-world)) + (let ((a0-18 v1-0)) + (set! (-> a0-18 param0) joint-mod-joint-set-world-handler) + (set! (-> a0-18 param1) obj) + ) + (vector-reset! (-> obj trans)) + (quaternion-identity! (-> obj quat)) + (set-vector! (-> obj scale) 1.0 1.0 1.0 1.0) + (set! (-> obj flex-blend) 1.0) + ) + (((joint-mod-mode joint-set*)) + (let ((a0-25 v1-0)) + (set! (-> a0-25 param0) joint-mod-joint-set*-handler) + (set! (-> a0-25 param1) obj) + ) + (vector-reset! (-> obj trans)) + (quaternion-identity! (-> obj quat)) + (set-vector! (-> obj scale) 1.0 1.0 1.0 1.0) + ) + (((joint-mod-mode joint-set*-world)) + (let ((a0-29 v1-0)) + (set! (-> a0-29 param0) joint-mod-joint-set*-world-handler) + (set! (-> a0-29 param1) obj) + ) + (vector-reset! (-> obj trans)) + (quaternion-identity! (-> obj quat)) + (set-vector! (-> obj scale) 1.0 1.0 1.0 1.0) + ) + ) + ) + (none) + ) + +;; definition for method 15 of type joint-mod +;; INFO: Return type mismatch joint-mod vs none. +(defmethod shut-down joint-mod ((obj joint-mod)) + (set! (-> obj shutting-down?) #t) + (set! (-> obj blend) 0.0) + (none) + ) + +;; definition for method 13 of type joint-mod +(defmethod twist-set! joint-mod ((obj joint-mod) (arg0 float) (arg1 float) (arg2 float)) + (if arg0 + (set! (-> obj twist x) arg0) + ) + (if arg1 + (set! (-> obj twist y) arg1) + ) + (if arg2 + (set! (-> obj twist z) arg2) + ) + (-> obj twist) + ) + +;; definition for method 14 of type joint-mod +;; INFO: Used lq/sq +;; INFO: Return type mismatch int vs none. +(defmethod trs-set! joint-mod ((obj joint-mod) (arg0 vector) (arg1 quaternion) (arg2 vector)) + (if arg0 + (set! (-> obj trans quad) (-> arg0 quad)) + ) + (if arg1 + (quaternion-copy! (-> obj quat) arg1) + ) + (if arg2 + (set! (-> obj scale quad) (-> arg2 quad)) + ) + 0 + (none) + ) + +;; definition for method 10 of type joint-mod +;; INFO: Used lq/sq +;; INFO: Return type mismatch int vs none. +(defmethod target-set! joint-mod ((obj joint-mod) (arg0 vector)) + (if (= (-> obj mode) (joint-mod-mode reset)) + (mode-set! obj (joint-mod-mode look-at)) + ) + (let ((f0-0 (vector-vector-distance (-> obj process root trans) arg0))) + (set! (-> obj shutting-down?) #f) + (set! (-> obj target quad) (-> arg0 quad)) + (if (< f0-0 (-> obj max-dist)) + (set! (-> obj blend) 1.0) + (set! (-> obj blend) 0.0) + ) + ) + 0 + (none) + ) + +;; definition for symbol last-try-to-look-at-data, type try-to-look-at-info +(define last-try-to-look-at-data (new 'global 'try-to-look-at-info)) + +;; definition for method 11 of type joint-mod +;; INFO: Used lq/sq +;; INFO: Return type mismatch int vs none. +(defmethod look-at! joint-mod ((obj joint-mod) (arg0 vector) (arg1 symbol) (arg2 process)) + (when (= arg1 'attacking) + (let* ((s2-0 arg2) + (s1-0 (if (type? s2-0 process-drawable) + (the-as process-drawable s2-0) + ) + ) + ) + (when s1-0 + (let* ((s0-0 (-> s1-0 fact)) + (s2-1 (if (type? s0-0 fact-info-enemy) + (the-as fact-info-enemy s0-0) + ) + ) + ) + (when s2-1 + (when (< (vector-vector-distance (-> obj process root trans) (-> s1-0 root trans)) (-> s2-1 cam-notice-dist)) + (set! (-> obj notice-time) (-> self clock frame-counter)) + (set! (-> last-try-to-look-at-data who) (process->handle arg2)) + (if (< (-> last-try-to-look-at-data vert) (-> s2-1 cam-vert)) + (set! (-> last-try-to-look-at-data vert) (-> s2-1 cam-vert)) + ) + (if (< (-> last-try-to-look-at-data horz) (-> s2-1 cam-horz)) + (set! (-> last-try-to-look-at-data horz) (-> s2-1 cam-horz)) + ) + ) + ) + ) + ) + ) + ) + (let ((f30-0 (vector-vector-distance (-> obj process root trans) arg0))) + (if (logtest? (process-mask enemy) (-> arg2 mask)) + (+! (-> obj loock-at-count) (the int (lerp-scale 256.0 0.0 f30-0 20480.0 204800.0))) + ) + (when (and (or (= (-> obj blend) 0.0) + (or (< f30-0 (vector-vector-distance (-> obj process root trans) (-> obj target))) (= arg1 'force)) + ) + (< f30-0 (-> obj max-dist)) + ) + (if (= (-> obj mode) (joint-mod-mode reset)) + (mode-set! obj (joint-mod-mode look-at)) + ) + (set! (-> obj target quad) (-> arg0 quad)) + (set! (-> obj blend) 1.0) + (set! (-> obj shutting-down?) #f) + ) + ) + 0 + (none) + ) + +;; definition for function joint-mod-look-at-handler +;; INFO: Used lq/sq +;; ERROR: Stack slot load at 176 mismatch: defined as size 4, got size 16 +;; ERROR: Stack slot load at 176 mismatch: defined as size 4, got size 16 +;; ERROR: Stack slot load at 176 mismatch: defined as size 4, got size 16 +;; ERROR: Stack slot load at 176 mismatch: defined as size 4, got size 16 +;; INFO: Return type mismatch int vs none. +;; ERROR: Unsupported inline assembly instruction kind - [mula.s f0, f3] +;; ERROR: Unsupported inline assembly instruction kind - [madda.s f1, f4] +;; ERROR: Unsupported inline assembly instruction kind - [madd.s f0, f2, f5] +(defbehavior joint-mod-look-at-handler process ((arg0 cspace) (arg1 transformq)) + (local-vars (f0-1 float) (sv-80 symbol) (sv-144 vector) (sv-160 vector) (sv-176 float)) + (rlet ((vf0 :class vf) + (vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + ) + (init-vf0-vector) + (let ((gp-0 (the-as joint-mod (-> arg0 param1)))) + (cspace<-parented-transformq-joint! arg0 arg1) + (let ((s1-0 (vector-normalize-copy! + (new 'stack-no-clear 'vector) + (-> gp-0 process node-list data 0 bone transform vector 1) + 1.0 + ) + ) + (s2-0 (matrix->trans (-> arg0 bone transform) (new 'stack-no-clear 'vector))) + (s3-0 (vector-normalize! (-> arg0 bone transform vector (-> gp-0 nose)) 1.0)) + (s0-0 (vector-normalize! (-> arg0 bone transform vector (-> gp-0 ear)) 1.0)) + ) + (set! sv-144 (vector-normalize! + (vector-cross! + (new 'stack-no-clear 'vector) + (-> arg0 bone transform vector (-> gp-0 up)) + (-> arg0 bone transform vector (-> gp-0 nose)) + ) + 1.0 + ) + ) + (let ((s2-1 (vector-normalize! (vector-! (new 'stack-no-clear 'vector) (-> gp-0 target) s2-0) 1.0))) + (set! sv-160 (-> gp-0 process node-list data (-> gp-0 base-joint) bone transform vector (-> gp-0 base-nose))) + (set! sv-80 (the-as symbol #f)) + (let ((f0-0 (-> sv-144 x)) + (f1-0 (-> sv-144 y)) + (f2-0 (-> sv-144 z)) + (f3-0 (-> s0-0 x)) + (f4-0 (-> s0-0 y)) + (f5-0 (-> s0-0 z)) + ) + (.mula.s f0-0 f3-0) + (.madda.s f1-0 f4-0) + (.madd.s f0-1 f2-0 f5-0) + ) + (if (< f0-1 0.0) + (set! sv-80 #t) + ) + (let* ((f30-0 (vector-y-angle s3-0)) + (a0-18 (vector-flatten! (new-stack-vector0) s2-1 s1-0)) + (f0-3 (vector-y-angle a0-18)) + (f30-1 (deg-diff f30-0 f0-3)) + (f0-4 (if (= (-> gp-0 base-joint) (+ (-> arg0 joint number) 1)) + 0.0 + (deg-diff (vector-y-angle s3-0) (vector-y-angle sv-160)) + ) + ) + ) + (if (< (-> gp-0 ignore-angle) (fabs f30-1)) + (set! f30-1 0.0) + ) + (let ((f30-2 + (fmax + (fmin (* f30-1 (-> gp-0 blend) (-> gp-0 flex-blend)) (+ (-> gp-0 twist-max y) (* f0-4 (-> gp-0 flex-blend)))) + (+ (- (-> gp-0 twist-max y)) (* f0-4 (-> gp-0 flex-blend))) + ) + ) + ) + (when (and (-> gp-0 shutting-down?) (< (fabs (- (-> gp-0 twist y) f30-2)) 18.204445)) + (if (and (= (-> gp-0 scale x) 1.0) (= (-> gp-0 scale y) 1.0) (= (-> gp-0 scale z) 1.0)) + (mode-set! gp-0 (joint-mod-mode reset)) + (mode-set! gp-0 (joint-mod-mode rotate2)) + ) + ) + (let ((s1-2 deg-seek) + (s0-2 (-> gp-0 twist y)) + ) + (set! sv-176 f30-2) + (let ((a2-3 (* (fabs (deg-diff f30-2 (-> gp-0 twist y))) (-> gp-0 twist-speed-y) (-> self clock time-adjust-ratio))) + ) + (set! (-> gp-0 twist y) (s1-2 s0-2 sv-176 a2-3)) + ) + ) + ) + ) + 0.0 + (let ((f0-25 (if sv-80 + (- (-> gp-0 twist y)) + (-> gp-0 twist y) + ) + ) + (v1-49 (-> gp-0 up)) + ) + (cond + ((zero? v1-49) + (quaternion-rotate-x! (-> arg1 quat) (-> arg1 quat) f0-25) + ) + ((= v1-49 1) + (quaternion-rotate-local-y! (-> arg1 quat) (-> arg1 quat) f0-25) + ) + (else + (quaternion-rotate-z! (-> arg1 quat) (-> arg1 quat) f0-25) + ) + ) + ) + (let* ((s1-3 + (vector-normalize-copy! + (new 'stack-no-clear 'vector) + (the-as vector (-> gp-0 process node-list data 0 bone transform)) + 1.0 + ) + ) + (f30-3 (vector-x-angle s3-0)) + (s2-2 (vector-flatten! (new-stack-vector0) s2-1 s1-3)) + (f0-26 (vector-x-angle s2-2)) + (f0-32 + (fmax + (fmin (* (- (deg-diff f30-3 f0-26)) (-> gp-0 blend) (-> gp-0 flex-blend)) (-> gp-0 twist-max x)) + (- (-> gp-0 twist-max x)) + ) + ) + ) + (if (< (vector-dot s2-2 s3-0) 0.1) + (set! f0-32 0.0) + ) + (set! (-> gp-0 twist x) + (deg-seek + (-> gp-0 twist x) + f0-32 + (* (fabs (deg-diff f0-32 (-> gp-0 twist x))) (-> gp-0 twist-speed-x) (-> self clock time-adjust-ratio)) + ) + ) + ) + ) + ) + (let ((v1-60 (-> gp-0 ear))) + (cond + ((zero? v1-60) + (quaternion-rotate-x! (-> arg1 quat) (-> arg1 quat) (-> gp-0 twist x)) + ) + ((= v1-60 1) + (quaternion-rotate-local-y! (-> arg1 quat) (-> arg1 quat) (-> gp-0 twist x)) + ) + (else + (quaternion-rotate-z! (-> arg1 quat) (-> arg1 quat) (-> gp-0 twist x)) + ) + ) + ) + (vector+! (-> arg1 trans) (-> arg1 trans) (-> gp-0 trans)) + (quaternion-normalize! (quaternion*! (-> arg1 quat) (-> arg1 quat) (-> gp-0 quat))) + (let ((a1-36 (-> arg1 scale))) + (let ((v1-63 (-> arg1 scale)) + (a0-46 (-> gp-0 scale)) + ) + (.lvf vf4 (&-> v1-63 quad)) + (.lvf vf5 (&-> a0-46 quad)) + ) + (.add.x.vf vf6 vf0 vf0 :mask #b1000) + (.mul.vf vf6 vf4 vf5 :mask #b111) + (.svf (&-> a1-36 quad) vf6) + ) + (cspace<-parented-transformq-joint! arg0 arg1) + (if (-> gp-0 parented-scale?) + (set-vector! (-> arg0 bone scale) 1.0 1.0 1.0 1.0) + ) + (if (and (= (-> gp-0 process type) target) (!= (-> gp-0 blend) 0.0)) + (add-debug-text-sphere + *display-target-marks* + (bucket-id bucket-318) + (-> gp-0 target) + 819.2 + "look" + (new 'static 'rgba :r #xff :g #xff :a #x80) + ) + ) + ) + 0 + (none) + ) + ) + +;; definition for function joint-mod-polar-look-at-guts +;; INFO: Used lq/sq +;; INFO: Return type mismatch symbol vs none. +(defbehavior joint-mod-polar-look-at-guts process ((arg0 cspace) (arg1 transformq)) + (let ((gp-0 (the-as joint-mod (-> arg0 param1)))) + (cspace<-parented-transformq-joint! arg0 arg1) + (let ((s3-0 (vector-normalize-copy! (new 'stack-no-clear 'vector) (-> arg0 bone transform vector 2) 1.0)) + (s1-0 (vector-normalize! + (vector-! (new 'stack-no-clear 'vector) (-> gp-0 target) (-> arg0 bone transform trans)) + 1.0 + ) + ) + (s4-0 (new 'stack-no-clear 'matrix)) + ) + (let ((s2-0 (new 'stack-no-clear 'vector))) + (vector-normalize-copy! (the-as vector (-> s4-0 vector)) (the-as vector (-> arg0 bone transform)) 1.0) + (vector-normalize-copy! (-> s4-0 vector 1) (-> arg0 bone transform vector 1) 1.0) + (vector-normalize-copy! (-> s4-0 vector 2) (-> arg0 bone transform vector 2) 1.0) + (set-vector! (-> s4-0 trans) 0.0 0.0 0.0 1.0) + (matrix-transpose! s4-0 s4-0) + (set-vector! (-> s4-0 trans) 0.0 0.0 0.0 1.0) + (vector-matrix*! s2-0 s1-0 s4-0) + (let* ((t9-8 asin) + (f0-8 (-> s2-0 x)) + (f0-10 (* f0-8 f0-8)) + (f1-0 (-> s2-0 y)) + (f28-0 (t9-8 (sqrtf (+ f0-10 (* f1-0 f1-0))))) + (f30-0 (atan (-> s2-0 y) (-> s2-0 x))) + ) + (if (< (-> s2-0 z) 0.0) + (set! f28-0 (- 32768.0 f28-0)) + ) + (set! (-> gp-0 polar-internal-radius) f28-0) + (cond + ((< 16384.0 f30-0) + (set! (-> gp-0 polar-internal-tilt-max) (- 32768.0 f30-0)) + (if (and (< (-> gp-0 polar-external-radius) f28-0) (< 0.0 (-> gp-0 polar-external-tilt-max))) + (set! f30-0 (fmax f30-0 (- 32768.0 (-> gp-0 polar-external-tilt-max)))) + ) + ) + ((< f30-0 -16384.0) + (set! (-> gp-0 polar-internal-tilt-max) (- -32768.0 f30-0)) + (if (and (< (-> gp-0 polar-external-radius) f28-0) (< (-> gp-0 polar-external-tilt-max) 0.0)) + (set! f30-0 (fmin f30-0 (- -32768.0 (-> gp-0 polar-external-tilt-max)))) + ) + ) + ((< 0.0 f30-0) + (set! (-> gp-0 polar-internal-tilt-max) f30-0) + (if (and (< (-> gp-0 polar-external-radius) f28-0) (< 0.0 (-> gp-0 polar-external-tilt-max))) + (set! f30-0 (fmin f30-0 (-> gp-0 polar-external-tilt-max))) + ) + ) + (else + (set! (-> gp-0 polar-internal-tilt-max) f30-0) + (if (and (< (-> gp-0 polar-external-radius) f28-0) (< (-> gp-0 polar-external-tilt-max) 0.0)) + (set! f30-0 (fmax f30-0 (-> gp-0 polar-external-tilt-max))) + ) + ) + ) + (let* ((f0-38 (sin f30-0)) + (f26-0 (* f0-38 f0-38)) + (f0-40 (cos f30-0)) + (f0-42 (* f0-40 f0-40)) + ) + 32768.0 + (let ((f0-44 (cond + ((< 16384.0 f30-0) + (+ (* f26-0 (-> gp-0 twist-max x)) (* f0-42 (-> gp-0 twist-min-y))) + ) + ((< f30-0 -16384.0) + (+ (* f26-0 (-> gp-0 twist-min-x)) (* f0-42 (-> gp-0 twist-min-y))) + ) + ((< 0.0 f30-0) + (+ (* f26-0 (-> gp-0 twist-max x)) (* f0-42 (-> gp-0 twist-max y))) + ) + (else + (+ (* f26-0 (-> gp-0 twist-min-x)) (* f0-42 (-> gp-0 twist-max y))) + ) + ) + ) + ) + (if (< f0-44 f28-0) + (set! f28-0 f0-44) + ) + ) + ) + (let ((f28-1 (cos f28-0))) + (set-vector! s2-0 (cos f30-0) (sin f30-0) 0.0 1.0) + (let ((t9-15 vector-normalize!) + (a0-19 s2-0) + (f0-52 1.0) + (f1-22 f28-1) + ) + (t9-15 a0-19 (sqrtf (- f0-52 (* f1-22 f1-22)))) + ) + (set! (-> s2-0 z) f28-1) + ) + ) + (matrix-transpose! s4-0 s4-0) + (vector-matrix*! s2-0 s2-0 s4-0) + (matrix-from-two-vectors! s4-0 s3-0 s2-0) + ) + (let ((s2-1 (vector-normalize-copy! (new 'stack-no-clear 'vector) (-> arg0 bone transform vector 1) -1.0)) + (s3-1 (matrix->trans (-> arg0 bone transform) (new 'stack-no-clear 'vector))) + ) + (set-vector! (-> arg0 bone transform trans) 0.0 0.0 0.0 1.0) + (matrix*! (-> arg0 bone transform) (-> arg0 bone transform) s4-0) + (matrix-remove-z-rot (-> arg0 bone transform) s2-1) + (set! (-> arg0 bone transform trans quad) (-> s3-1 quad)) + ) + ) + (if (and (= (-> gp-0 process type) target) (!= (-> gp-0 blend) 0.0)) + (add-debug-text-sphere + *display-target-marks* + (bucket-id bucket-318) + (-> gp-0 target) + 819.2 + "look" + (new 'static 'rgba :r #xff :g #xff :a #x80) + ) + ) + ) + (none) + ) + +;; definition for function joint-mod-polar-look-at-handler +;; INFO: Return type mismatch int vs none. +(defbehavior joint-mod-polar-look-at-handler process ((arg0 cspace) (arg1 transformq)) + (joint-mod-polar-look-at-guts arg0 arg1) + 0 + (none) + ) + +;; definition for function joint-mod-world-look-at-handler +;; INFO: Used lq/sq +;; INFO: Return type mismatch int vs none. +(defbehavior joint-mod-world-look-at-handler process ((arg0 cspace) (arg1 transformq)) + (local-vars (sv-48 vector) (sv-52 vector) (sv-56 vector)) + (let ((gp-0 (the-as joint-mod (-> arg0 param1)))) + (let ((s5-0 (-> arg0 bone transform))) + (cspace<-parented-transformq-joint! arg0 arg1) + (set! sv-48 (vector-normalize-copy! + (new 'stack-no-clear 'vector) + (-> gp-0 process node-list data 0 bone transform vector 1) + 1.0 + ) + ) + (set! sv-52 (vector-normalize! (-> s5-0 vector (-> gp-0 nose)) 1.0)) + (set! sv-56 (vector-normalize! (vector-! (new 'stack-no-clear 'vector) (-> gp-0 target) (-> s5-0 trans)) 1.0)) + (let* ((f30-0 (vector-y-angle sv-52)) + (a0-7 (vector-flatten! (new-stack-vector0) sv-56 sv-48)) + (f0-0 (vector-y-angle a0-7)) + (f0-1 (deg-diff f30-0 f0-0)) + ) + (if (< (-> gp-0 ignore-angle) (fabs f0-1)) + (set! f0-1 0.0) + ) + (let ((f0-5 + (fmax (fmin (* f0-1 (-> gp-0 blend) (-> gp-0 flex-blend)) (-> gp-0 twist-max y)) (- (-> gp-0 twist-max y))) + ) + ) + (set! (-> gp-0 twist y) (deg-seek + (-> gp-0 twist y) + f0-5 + (* (fmax 1.0 (* (fabs (deg-diff f0-5 (-> gp-0 twist y))) (-> gp-0 twist-speed-y))) + (-> self clock time-adjust-ratio) + ) + ) + ) + ) + ) + (when (!= (-> gp-0 twist y) 0.0) + (let ((a2-3 (matrix-rotate-y! (new 'stack-no-clear 'matrix) (-> gp-0 twist y))) + (s4-2 (-> s5-0 trans quad)) + ) + (matrix*! s5-0 s5-0 a2-3) + (set! (-> s5-0 trans quad) s4-2) + ) + ) + (let* ((s4-3 (vector-normalize-copy! + (new 'stack-no-clear 'vector) + (the-as vector (-> gp-0 process node-list data 0 bone transform)) + 1.0 + ) + ) + (f30-2 (vector-x-angle sv-52)) + (s4-4 (vector-flatten! (new-stack-vector0) sv-56 s4-3)) + (f0-15 (vector-x-angle s4-4)) + (f0-21 (fmax + (fmin (* (- (deg-diff f30-2 f0-15)) (-> gp-0 blend) (-> gp-0 flex-blend)) (-> gp-0 twist-max x)) + (- (-> gp-0 twist-max x)) + ) + ) + ) + (if (< (vector-dot s4-4 sv-52) 0.1) + (set! f0-21 0.0) + ) + (set! (-> gp-0 twist x) (deg-seek + (-> gp-0 twist x) + f0-21 + (* (fmax 1.0 (* (fabs (deg-diff f0-21 (-> gp-0 twist x))) (-> gp-0 twist-speed-x))) + (-> self clock time-adjust-ratio) + ) + ) + ) + ) + (when (!= (-> gp-0 twist x) 0.0) + (let* ((v1-25 (-> gp-0 ear)) + (a1-17 ((cond + ((zero? v1-25) + matrix-rotate-x! + ) + ((= v1-25 1) + matrix-rotate-y! + ) + (else + matrix-rotate-z! + ) + ) + (new 'stack-no-clear 'matrix) + (-> gp-0 twist x) + ) + ) + ) + (matrix*! s5-0 a1-17 s5-0) + ) + ) + ) + (if (and (= (-> gp-0 process type) target) (!= (-> gp-0 blend) 0.0)) + (add-debug-text-sphere + *display-target-marks* + (bucket-id bucket-318) + (-> gp-0 target) + 819.2 + "look" + (new 'static 'rgba :r #xff :g #xff :a #x80) + ) + ) + ) + 0 + (none) + ) + +;; definition for function joint-mod-rotate-handler +;; INFO: Return type mismatch int vs none. +(defbehavior joint-mod-rotate-handler process ((arg0 cspace) (arg1 transformq)) + (rlet ((vf0 :class vf) + (vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + ) + (init-vf0-vector) + (let ((s5-0 (the-as joint-mod (-> arg0 param1)))) + (let ((s3-0 (new 'static 'inline-array quaternion 3 + (new 'static 'quaternion :x 1.0 :w 1.0) + (new 'static 'quaternion :y 1.0 :w 1.0) + (new 'static 'quaternion :z 1.0 :w 1.0) + ) + ) + ) + (if (zero? (logand (-> s5-0 track-mode) (track-mode no-trans))) + (vector+! (-> arg1 trans) (-> arg1 trans) (-> s5-0 trans)) + ) + (when (zero? (logand (-> s5-0 track-mode) (track-mode no-rotate))) + (let* ((v1-9 (-> s3-0 (-> s5-0 ear))) + (a1-4 (quaternion-axis-angle! + (new 'stack-no-clear 'quaternion) + (-> v1-9 x) + (-> v1-9 y) + (-> v1-9 z) + (* (-> s5-0 twist x) (-> s5-0 blend) (-> s5-0 flex-blend)) + ) + ) + ) + (quaternion-normalize! (quaternion*! (-> arg1 quat) a1-4 (-> arg1 quat))) + ) + (let* ((v1-13 (-> s3-0 (-> s5-0 up))) + (a1-6 (quaternion-axis-angle! + (new 'stack-no-clear 'quaternion) + (-> v1-13 x) + (-> v1-13 y) + (-> v1-13 z) + (* (-> s5-0 twist y) (-> s5-0 blend) (-> s5-0 flex-blend)) + ) + ) + ) + (quaternion-normalize! (quaternion*! (-> arg1 quat) a1-6 (-> arg1 quat))) + ) + (let* ((v1-17 (-> s3-0 (-> s5-0 nose))) + (a1-8 (quaternion-axis-angle! + (new 'stack-no-clear 'quaternion) + (-> v1-17 x) + (-> v1-17 y) + (-> v1-17 z) + (* (-> s5-0 twist z) (-> s5-0 blend) (-> s5-0 flex-blend)) + ) + ) + ) + (quaternion-normalize! (quaternion*! (-> arg1 quat) a1-8 (-> arg1 quat))) + ) + ) + ) + (when (zero? (logand (-> s5-0 track-mode) (track-mode no-scale))) + (let ((a1-9 (-> arg1 scale))) + (let ((v1-22 (-> arg1 scale)) + (a0-11 (-> s5-0 scale)) + ) + (.lvf vf4 (&-> v1-22 quad)) + (.lvf vf5 (&-> a0-11 quad)) + ) + (.add.x.vf vf6 vf0 vf0 :mask #b1000) + (.mul.vf vf6 vf4 vf5 :mask #b111) + (.svf (&-> a1-9 quad) vf6) + ) + ) + (cspace<-parented-transformq-joint! arg0 arg1) + (if (-> s5-0 parented-scale?) + (set-vector! (-> arg0 bone scale) 1.0 1.0 1.0 1.0) + ) + ) + 0 + (none) + ) + ) + +;; definition for function joint-mod-scale-handler +;; INFO: Return type mismatch int vs none. +(defbehavior joint-mod-scale-handler process ((arg0 cspace) (arg1 transformq)) + (rlet ((vf0 :class vf) + (vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + ) + (init-vf0-vector) + (let ((s5-0 (the-as joint-mod (-> arg0 param1)))) + (let ((a2-0 (-> arg1 scale))) + (let ((v1-0 (-> arg1 scale)) + (a0-1 (-> s5-0 scale)) + ) + (.lvf vf4 (&-> v1-0 quad)) + (.lvf vf5 (&-> a0-1 quad)) + ) + (.add.x.vf vf6 vf0 vf0 :mask #b1000) + (.mul.vf vf6 vf4 vf5 :mask #b111) + (.svf (&-> a2-0 quad) vf6) + ) + (cspace<-parented-transformq-joint! arg0 arg1) + (if (-> s5-0 parented-scale?) + (set-vector! (-> arg0 bone scale) 1.0 1.0 1.0 1.0) + ) + ) + 0 + (none) + ) + ) + +;; definition for function joint-mod-joint-set-handler +;; INFO: Used lq/sq +;; INFO: Return type mismatch int vs none. +(defbehavior joint-mod-joint-set-handler process ((arg0 cspace) (arg1 transformq)) + (let ((s4-0 (the-as joint-mod (-> arg0 param1)))) + (if (zero? (logand (-> s4-0 track-mode) (track-mode no-trans))) + (set! (-> arg1 trans quad) (-> s4-0 trans quad)) + ) + (if (zero? (logand (-> s4-0 track-mode) (track-mode no-rotate))) + (quaternion-copy! (-> arg1 quat) (-> s4-0 quat)) + ) + (if (zero? (logand (-> s4-0 track-mode) (track-mode no-scale))) + (set! (-> arg1 scale quad) (-> s4-0 scale quad)) + ) + ) + (cspace<-parented-transformq-joint! arg0 arg1) + 0 + (none) + ) + +;; definition for function joint-mod-joint-set-world-handler +;; INFO: Used lq/sq +;; INFO: Return type mismatch int vs none. +;; WARN: Function joint-mod-joint-set-world-handler has a return type of none, but the expression builder found a return statement. +(defbehavior joint-mod-joint-set-world-handler process ((arg0 cspace) (arg1 transformq)) + (cspace<-parented-transformq-joint! arg0 arg1) + (let ((s5-0 (the-as joint-mod (-> arg0 param1))) + (s4-0 (matrix->trans (-> arg0 bone transform) (new 'stack-no-clear 'vector))) + ) + (let ((s3-0 (new 'stack-no-clear 'vector))) + (if (>= 0.0 (-> s5-0 flex-blend)) + (return #f) + ) + (cond + ((logtest? (-> s5-0 track-mode) (track-mode no-scale)) + (set! (-> s3-0 quad) (-> arg1 scale quad)) + ) + ((>= (-> s5-0 flex-blend) 1.0) + (set! (-> s3-0 quad) (-> s5-0 scale quad)) + ) + (else + (vector-lerp! s3-0 (-> arg1 scale) (-> s5-0 scale) (-> s5-0 flex-blend)) + ) + ) + (cond + ((logtest? (-> s5-0 track-mode) (track-mode no-rotate)) + ) + ((>= (-> s5-0 flex-blend) 1.0) + (quaternion->matrix (-> arg0 bone transform) (-> s5-0 quat)) + ) + (else + (let ((v1-15 (new 'stack-no-clear 'vector))) + (set! (-> v1-15 quad) (-> arg1 scale quad)) + (set! (-> v1-15 x) (/ 1.0 (-> v1-15 x))) + (set! (-> v1-15 y) (/ 1.0 (-> v1-15 y))) + (set! (-> v1-15 z) (/ 1.0 (-> v1-15 z))) + (vector-float*! + (the-as vector (-> arg0 bone transform)) + (the-as vector (-> arg0 bone transform)) + (-> v1-15 x) + ) + (vector-float*! (-> arg0 bone transform vector 1) (-> arg0 bone transform vector 1) (-> v1-15 y)) + (vector-float*! (-> arg0 bone transform vector 2) (-> arg0 bone transform vector 2) (-> v1-15 z)) + ) + (let ((a1-12 (matrix->quaternion (new 'stack-no-clear 'quaternion) (-> arg0 bone transform)))) + (quaternion->matrix + (-> arg0 bone transform) + (quaternion-slerp! (new 'stack-no-clear 'quaternion) a1-12 (-> s5-0 quat) (-> s5-0 flex-blend)) + ) + ) + ) + ) + (cond + ((logtest? (-> s5-0 track-mode) (track-mode no-rotate)) + (vector-normalize! (the-as vector (-> arg0 bone transform)) (-> s3-0 x)) + (vector-normalize! (-> arg0 bone transform vector 1) (-> s3-0 y)) + (vector-normalize! (-> arg0 bone transform vector 2) (-> s3-0 z)) + ) + (else + (vector-float*! (the-as vector (-> arg0 bone transform)) (the-as vector (-> arg0 bone transform)) (-> s3-0 x)) + (vector-float*! (-> arg0 bone transform vector 1) (-> arg0 bone transform vector 1) (-> s3-0 y)) + (vector-float*! (-> arg0 bone transform vector 2) (-> arg0 bone transform vector 2) (-> s3-0 z)) + ) + ) + ) + (set! (-> arg0 bone transform vector 0 w) 0.0) + (set! (-> arg0 bone transform vector 1 w) 0.0) + (set! (-> arg0 bone transform vector 2 w) 0.0) + (cond + ((logtest? (-> s5-0 track-mode) (track-mode no-trans)) + (set! (-> arg0 bone transform trans quad) (-> s4-0 quad)) + ) + ((>= (-> s5-0 flex-blend) 1.0) + (set! (-> arg0 bone transform trans quad) (-> s5-0 trans quad)) + (set! (-> arg0 bone transform trans w) 1.0) + ) + (else + (vector-lerp! (-> arg0 bone transform trans) s4-0 (-> s5-0 trans) (-> s5-0 flex-blend)) + (set! (-> arg0 bone transform trans w) 1.0) + ) + ) + ) + 0 + (none) + ) + +;; definition for function joint-mod-joint-set*-handler +;; INFO: Return type mismatch int vs none. +(defbehavior joint-mod-joint-set*-handler process ((arg0 cspace) (arg1 transformq)) + (rlet ((vf0 :class vf) + (vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + ) + (init-vf0-vector) + (let ((s5-0 (the-as joint-mod (-> arg0 param1)))) + (if (zero? (logand (-> s5-0 track-mode) (track-mode no-trans))) + (vector+! (-> arg1 trans) (-> arg1 trans) (-> s5-0 trans)) + ) + (if (zero? (logand (-> s5-0 track-mode) (track-mode no-rotate))) + (quaternion-normalize! (quaternion*! (-> arg1 quat) (-> arg1 quat) (-> s5-0 quat))) + ) + (when (zero? (logand (-> s5-0 track-mode) (track-mode no-scale))) + (let ((a1-4 (-> arg1 scale))) + (let ((v1-11 (-> arg1 scale)) + (a0-4 (-> s5-0 scale)) + ) + (.lvf vf4 (&-> v1-11 quad)) + (.lvf vf5 (&-> a0-4 quad)) + ) + (.add.x.vf vf6 vf0 vf0 :mask #b1000) + (.mul.vf vf6 vf4 vf5 :mask #b111) + (.svf (&-> a1-4 quad) vf6) + ) + ) + (cspace<-parented-transformq-joint! arg0 arg1) + (if (-> s5-0 parented-scale?) + (set-vector! (-> arg0 bone scale) 1.0 1.0 1.0 1.0) + ) + ) + 0 + (none) + ) + ) + +;; definition for function joint-mod-joint-set*-world-handler +;; INFO: Return type mismatch int vs none. +(defbehavior joint-mod-joint-set*-world-handler process ((arg0 cspace) (arg1 transformq)) + (cspace<-parented-transformq-joint! arg0 arg1) + (let ((s5-0 (the-as joint-mod (-> arg0 param1)))) + (let ((s3-0 (quaternion->matrix (new 'stack-no-clear 'matrix) (-> s5-0 quat))) + (s4-0 (matrix->trans (-> arg0 bone transform) (new 'stack-no-clear 'vector))) + ) + (vector-reset! (-> arg0 bone transform trans)) + (set! (-> arg0 bone transform trans w) 1.0) + (vector-float*! (the-as vector (-> s3-0 vector)) (the-as vector (-> s3-0 vector)) (-> s5-0 scale x)) + (vector-float*! (-> s3-0 vector 1) (-> s3-0 vector 1) (-> s5-0 scale y)) + (vector-float*! (-> s3-0 vector 2) (-> s3-0 vector 2) (-> s5-0 scale z)) + (set! (-> s3-0 vector 0 w) 0.0) + (set! (-> s3-0 vector 1 w) 0.0) + (set! (-> s3-0 vector 2 w) 0.0) + (matrix*! (-> arg0 bone transform) (-> arg0 bone transform) s3-0) + (vector+! (-> arg0 bone transform trans) s4-0 (-> s5-0 trans)) + ) + (if (-> s5-0 parented-scale?) + (set-vector! (-> arg0 bone scale) 1.0 1.0 1.0 1.0) + ) + ) + 0 + (none) + ) 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 913eabb851..fd1181f064 100644 --- a/test/decompiler/reference/jak2/engine/data/art-h_REF.gc +++ b/test/decompiler/reference/jak2/engine/data/art-h_REF.gc @@ -351,7 +351,7 @@ (:methods (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) ) ) diff --git a/test/decompiler/reference/jak2/engine/game/game-info-h_REF.gc b/test/decompiler/reference/jak2/engine/game/game-info-h_REF.gc index 8fb7cd8603..72a300aecd 100644 --- a/test/decompiler/reference/jak2/engine/game/game-info-h_REF.gc +++ b/test/decompiler/reference/jak2/engine/game/game-info-h_REF.gc @@ -130,13 +130,13 @@ (want-sound-banks (_type_ (pointer symbol)) none 12) (want-display-level (_type_ symbol symbol) int 13) (want-vis-level (_type_ symbol) none 14) - (load-state-method-15 () none 15) - (load-state-method-16 () none 16) - (load-state-method-17 () none 17) - (load-state-method-18 () none 18) - (load-state-method-19 () none 19) - (load-state-method-20 () none 20) - (load-state-method-21 () none 21) + (want-force-vis (_type_ symbol symbol) int 15) + (execute-command (_type_ pair) none 16) + (execute-commands-up-to (_type_ float) none 17) + (backup-load-state-and-set-cmds (_type_ pair) int 18) + (restore-load-state-and-cleanup (_type_) int 19) + (restore-load-state (_type_) int 20) + (set-force-inside! (_type_ symbol symbol) none 21) ) ) diff --git a/test/decompiler/reference/jak2/engine/game/settings-h_REF.gc b/test/decompiler/reference/jak2/engine/game/settings-h_REF.gc index 2e6d6c76f9..21f1b02c1a 100644 --- a/test/decompiler/reference/jak2/engine/game/settings-h_REF.gc +++ b/test/decompiler/reference/jak2/engine/game/settings-h_REF.gc @@ -60,7 +60,7 @@ (stereo-mode int32 :offset-assert 228) (music symbol :offset-assert 232) (sound-stinger int32 :offset-assert 236) - (spool-anim symbol :offset-assert 240) + (spool-anim spool-anim :offset-assert 240) (sound-mode uint32 :offset-assert 244) (task-manager (pointer process) :offset-assert 248) (task symbol :offset-assert 252) diff --git a/test/decompiler/reference/jak2/engine/game/settings_REF.gc b/test/decompiler/reference/jak2/engine/game/settings_REF.gc index 6ed6d9379d..276434bbee 100644 --- a/test/decompiler/reference/jak2/engine/game/settings_REF.gc +++ b/test/decompiler/reference/jak2/engine/game/settings_REF.gc @@ -351,7 +351,7 @@ (set! (-> obj spooling) (the-as (pointer process) arg1)) ) (('spool-anim) - (set! (-> obj spool-anim) arg1) + (set! (-> obj spool-anim) (the-as spool-anim arg1)) ) (('hint) (set! (-> obj hint) (the-as (pointer process) arg1)) diff --git a/test/decompiler/reference/jak2/engine/geometry/geometry_REF.gc b/test/decompiler/reference/jak2/engine/geometry/geometry_REF.gc index f43f3d383a..9fbdd74195 100644 --- a/test/decompiler/reference/jak2/engine/geometry/geometry_REF.gc +++ b/test/decompiler/reference/jak2/engine/geometry/geometry_REF.gc @@ -624,12 +624,12 @@ ;; definition for function matrix-remove-z-rot ;; INFO: Used lq/sq -(defun matrix-remove-z-rot ((arg0 matrix) (arg1 matrix)) +(defun matrix-remove-z-rot ((arg0 matrix) (arg1 vector)) (let ((s4-0 (new-stack-vector0))) 0.0 0.0 (let ((s5-0 (new-stack-matrix0))) - (vector-negate! s4-0 (the-as vector arg1)) + (vector-negate! s4-0 arg1) (vector-flatten! s4-0 s4-0 (-> arg0 vector 2)) (vector-normalize! s4-0 1.0) (let ((f30-0 (vector-dot (-> arg0 vector 1) s4-0))) diff --git a/test/decompiler/reference/jak2/engine/load/loader-h_REF.gc b/test/decompiler/reference/jak2/engine/load/loader-h_REF.gc index 14d58b1ebf..bf39034c35 100644 --- a/test/decompiler/reference/jak2/engine/load/loader-h_REF.gc +++ b/test/decompiler/reference/jak2/engine/load/loader-h_REF.gc @@ -12,7 +12,7 @@ :flag-assert #xb00000010 (:methods (new (symbol type int level) _type_ 0) - (load-dir-method-9 () none 9) + (load-to-heap-by-name (_type_ string symbol kheap int) art-group 9) (set-loaded-art (_type_ art-group) art-group 10) ) ) @@ -54,39 +54,39 @@ ;; definition of type external-art-buffer (deftype external-art-buffer (basic) - ((index int32 :offset-assert 4) - (other external-art-buffer :offset-assert 8) - (status symbol :offset-assert 12) - (locked? symbol :offset-assert 16) - (login? symbol :offset-assert 20) - (frame-lock symbol :offset-assert 24) - (init-heap function :offset-assert 28) - (heap kheap :inline :offset-assert 32) - (pending-load-file string :offset-assert 48) - (pending-load-file-part int32 :offset-assert 52) - (pending-load-file-owner handle :offset-assert 56) - (pending-load-file-priority float :offset-assert 64) - (load-file string :offset-assert 68) - (load-file-part int32 :offset-assert 72) - (load-file-owner handle :offset-assert 80) - (load-file-priority float :offset-assert 88) - (buf pointer :offset-assert 92) - (len int32 :offset-assert 96) - (art-group art-group :offset-assert 100) - (art-data uint32 :offset 100) + ((index int32 :offset-assert 4) + (other external-art-buffer :offset-assert 8) + (status symbol :offset-assert 12) + (locked? symbol :offset-assert 16) + (login? symbol :offset-assert 20) + (frame-lock symbol :offset-assert 24) + (init-heap (function external-art-buffer object) :offset-assert 28) + (heap kheap :inline :offset-assert 32) + (pending-load-file string :offset-assert 48) + (pending-load-file-part int32 :offset-assert 52) + (pending-load-file-owner handle :offset-assert 56) + (pending-load-file-priority float :offset-assert 64) + (load-file string :offset-assert 68) + (load-file-part int32 :offset-assert 72) + (load-file-owner handle :offset-assert 80) + (load-file-priority float :offset-assert 88) + (buf pointer :offset-assert 92) + (len int32 :offset-assert 96) + (art-group art-group :offset-assert 100) + (art-data uint32 :offset 100) ) :method-count-assert 16 :size-assert #x68 :flag-assert #x1000000068 (:methods (new (symbol type int function symbol) _type_ 0) - (external-art-buffer-method-9 () none 9) - (external-art-buffer-method-10 () none 10) - (external-art-buffer-method-11 () none 11) - (external-art-buffer-method-12 () none 12) - (external-art-buffer-method-13 () none 13) - (external-art-buffer-method-14 () none 14) - (external-art-buffer-method-15 () none 15) + (set-pending-file (_type_ string int handle float) int 9) + (update (_type_) int 10) + (inactive? (_type_) symbol 11) + (file-status (_type_ string int) symbol 12) + (link-file (_type_ art-group) art-group 13) + (unlink-file (_type_ art-group) int 14) + (unlock! (_type_) int 15) ) ) @@ -125,7 +125,7 @@ (defmethod new external-art-buffer ((allocation symbol) (type-to-make type) (arg0 int) (arg1 function) (arg2 symbol)) (let ((v0-0 (object-new allocation type-to-make (the-as int (-> type-to-make size))))) (set! (-> v0-0 index) arg0) - (set! (-> v0-0 init-heap) arg1) + (set! (-> v0-0 init-heap) (the-as (function external-art-buffer object) arg1)) (set! (-> v0-0 login?) arg2) (set! (-> v0-0 load-file) #f) (set! (-> v0-0 load-file-part) -1) @@ -145,13 +145,14 @@ ;; definition of type spool-anim (deftype spool-anim (basic) - ((name string :offset 16) - (anim-name basic :offset-assert 20) - (parts int32 :offset-assert 24) - (hint-id int32 :offset 24) - (priority float :offset-assert 28) - (owner uint64 :offset-assert 32) - (command-list pair :offset-assert 40) + ((name string :offset 16) + (anim-name basic :offset-assert 20) + (buffer external-art-buffer :offset 20) + (parts int32 :offset-assert 24) + (hint-id int32 :offset 24) + (priority float :offset-assert 28) + (owner handle :offset-assert 32) + (command-list pair :offset-assert 40) ) :method-count-assert 9 :size-assert #x2c @@ -166,7 +167,7 @@ ) (format #t "[~8x] ~A~%" obj (-> obj type)) (format #t "~1Tname: ~A~%" (-> obj name)) - (format #t "~1Tanim-name: ~A~%" (-> obj anim-name)) + (format #t "~1Tanim-name: ~A~%" (-> obj buffer)) (format #t "~1Tparts: ~D~%" (-> obj parts)) (format #t "~1Thint-id: ~D~%" (-> obj parts)) (format #t "~1Tpriority: ~f~%" (-> obj priority)) @@ -196,11 +197,11 @@ (new (symbol type) _type_ 0) (update (_type_ symbol) int 9) (clear-rec (_type_) int 10) - (external-art-control-method-11 () none 11) - (external-art-control-method-12 () none 12) - (external-art-control-method-13 () none 13) - (external-art-control-method-14 () none 14) - (external-art-control-method-15 () none 15) + (spool-push (_type_ string int process float) int 11) + (file-status (_type_ string int) symbol 12) + (reserve-alloc (_type_) kheap 13) + (reserve-free (_type_ kheap) int 14) + (none-reserved? (_type_) symbol 15) ) ) @@ -238,7 +239,7 @@ (dotimes (v1-9 3) (set! (-> gp-0 rec v1-9 name) #f) (set! (-> gp-0 rec v1-9 priority) 100000000.0) - (set! (-> gp-0 rec v1-9 owner) (the-as uint #f)) + (set! (-> gp-0 rec v1-9 owner) (the-as handle #f)) ) (set! (-> gp-0 spool-lock) (the-as handle #f)) (set! (-> gp-0 reserve-buffer) #f) diff --git a/test/decompiler/reference/jak2/engine/load/loader_REF.gc b/test/decompiler/reference/jak2/engine/load/loader_REF.gc new file mode 100644 index 0000000000..48089c5e6b --- /dev/null +++ b/test/decompiler/reference/jak2/engine/load/loader_REF.gc @@ -0,0 +1,2580 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition for method 8 of type subtitle-range +(defmethod mem-usage subtitle-range ((obj subtitle-range) (arg0 memory-usage-block) (arg1 int)) + (set! (-> arg0 length) (max 73 (-> arg0 length))) + (set! (-> arg0 data 72 name) "subtitle") + (+! (-> arg0 data 72 count) 1) + (let ((v1-6 (asize-of obj))) + (+! (-> arg0 data 72 used) v1-6) + (+! (-> arg0 data 72 total) (logand -16 (+ v1-6 15))) + ) + obj + ) + +;; definition for method 3 of type load-dir +;; INFO: Used lq/sq +(defmethod inspect load-dir ((obj load-dir)) + (local-vars (sv-16 basic)) + (format #t "[~8x] ~A~%" obj (-> obj type)) + (format #t "~Tlevel: ~A~%" (-> obj lev)) + (format #t "~Tallocated-length: ~D~%" (-> obj string-array allocated-length)) + (format #t "~Tlength: ~D~%" (-> obj string-array length)) + (dotimes (s5-0 (-> obj string-array length)) + (let ((s4-0 format) + (s3-0 #t) + (s2-0 "~T [~D] ~S ~A (~D bytes)~%") + (s1-0 s5-0) + (s0-0 (-> obj string-array s5-0)) + ) + (set! sv-16 (-> obj data-array s5-0)) + (let ((t1-0 (mem-size (-> obj data-array s5-0) #f 0))) + (s4-0 s3-0 s2-0 s1-0 s0-0 sv-16 t1-0) + ) + ) + ) + obj + ) + +;; definition for method 8 of type load-dir +;; INFO: Return type mismatch symbol vs load-dir. +(defmethod mem-usage load-dir ((obj load-dir) (arg0 memory-usage-block) (arg1 int)) + (set! (-> arg0 length) (max 85 (-> arg0 length))) + (set! (-> arg0 data 84 name) "array") + (+! (-> arg0 data 84 count) 1) + (let ((v1-6 (asize-of obj))) + (+! (-> arg0 data 84 used) v1-6) + (+! (-> arg0 data 84 total) (logand -16 (+ v1-6 15))) + ) + (set! (-> arg0 length) (max 85 (-> arg0 length))) + (set! (-> arg0 data 84 name) "array") + (set! (-> arg0 data 84 count) (-> arg0 data 84 count)) + (let ((v1-15 (asize-of (-> obj string-array)))) + (+! (-> arg0 data 84 used) v1-15) + (+! (-> arg0 data 84 total) (logand -16 (+ v1-15 15))) + ) + (set! (-> arg0 length) (max 85 (-> arg0 length))) + (set! (-> arg0 data 84 name) "array") + (set! (-> arg0 data 84 count) (-> arg0 data 84 count)) + (let ((v1-24 (asize-of (-> obj data-array)))) + (+! (-> arg0 data 84 used) v1-24) + (+! (-> arg0 data 84 total) (logand -16 (+ v1-24 15))) + ) + (dotimes (s3-0 (-> obj data-array length)) + (mem-usage (-> obj data-array s3-0) arg0 arg1) + ) + (the-as load-dir #f) + ) + +;; definition for method 9 of type load-dir-art-group +(defmethod load-to-heap-by-name load-dir-art-group ((obj load-dir-art-group) (arg0 string) (arg1 symbol) (arg2 kheap) (arg3 int)) + (let ((s5-0 (-> obj string-array))) + (dotimes (s3-0 (-> s5-0 length)) + (when (string= arg0 (-> s5-0 s3-0)) + (when arg1 + (let ((v1-4 (art-group-load-check arg0 arg2 arg3))) + (if v1-4 + (set! (-> obj art-group-array s3-0) v1-4) + ) + ) + ) + (return (-> obj art-group-array s3-0)) + ) + ) + (let ((v0-2 (art-group-load-check arg0 arg2 arg3))) + (when v0-2 + (set! (-> s5-0 (-> s5-0 length)) arg0) + (set! (-> obj art-group-array (-> s5-0 length)) v0-2) + (+! (-> s5-0 length) 1) + (+! (-> obj art-group-array length) 1) + ) + v0-2 + ) + ) + ) + +;; definition for method 10 of type load-dir-art-group +(defmethod set-loaded-art load-dir-art-group ((obj load-dir-art-group) (arg0 art-group)) + (let ((s4-0 (-> obj string-array))) + (dotimes (s3-0 (-> s4-0 length)) + (when (string= (-> arg0 name) (-> s4-0 s3-0)) + (set! (-> obj art-group-array s3-0) arg0) + (set! arg0 (-> obj art-group-array s3-0)) + (goto cfg-7) + ) + ) + (set! (-> s4-0 (-> s4-0 length)) (-> arg0 name)) + (set! (-> obj art-group-array (-> s4-0 length)) arg0) + (+! (-> s4-0 length) 1) + ) + (+! (-> obj art-group-array length) 1) + (label cfg-7) + arg0 + ) + +;; definition for function drawable-load +(defun drawable-load ((arg0 drawable) (arg1 kheap)) + (local-vars (sp-0 pointer)) + (cond + ((type? arg0 string) + (the-as none sp-0) + (if (< (the-as uint sp-0) (the-as uint *stack-top*)) + (set! sp-0 (&+ *kernel-sp* -1024)) + ) + (let ((s5-1 (loado (the-as string arg0) arg1))) + (if (and s5-1 (type? s5-1 drawable)) + (login (the-as drawable s5-1)) + ) + ) + ) + ((type? arg0 drawable) + (login arg0) + ) + ) + ) + +;; definition for function art-load +(defun art-load ((arg0 string) (arg1 kheap)) + (local-vars (sp-0 pointer)) + (the-as none sp-0) + (if (< (the-as uint sp-0) (the-as uint *stack-top*)) + (set! sp-0 (&+ *kernel-sp* -1024)) + ) + (let ((s5-0 (loado arg0 arg1))) + (if (type? s5-0 art) + (login (the-as art s5-0)) + (the-as art #f) + ) + ) + ) + +;; definition for function art-group-load-check +(defun art-group-load-check ((arg0 string) (arg1 kheap) (arg2 int)) + (local-vars (sp-0 pointer)) + (when *debug-segment* + (the-as none sp-0) + (if (< (the-as uint sp-0) (the-as uint *stack-top*)) + (set! sp-0 (&+ *kernel-sp* -1024)) + ) + (let ((s3-1 (loado (make-file-name (file-kind art-group) arg0 arg2 #f) arg1))) + (cond + ((not s3-1) + (format 0 "ERROR: art-group ~A is not a valid file.~%" arg0) + (the-as art-group #f) + ) + ((not (type? s3-1 art-group)) + (format 0 "ERROR: art-group ~A is not a art-group.~%" arg0) + (the-as art-group #f) + ) + ((not (file-info-correct-version? (-> (the-as art-group s3-1) info) (file-kind art-group) arg2)) + (the-as art-group #f) + ) + (else + (login (the-as art-group s3-1)) + ) + ) + ) + ) + ) + +;; definition for method 2 of type external-art-buffer +(defmethod print external-art-buffer ((obj external-art-buffer)) + (format + #t + "#<~A ~S ~D ~A @ #x~X>" + (-> obj type) + (-> obj pending-load-file) + (-> obj pending-load-file-part) + (-> obj status) + obj + ) + obj + ) + +;; definition for function external-art-buffer-init +(defun external-art-buffer-init ((arg0 external-art-buffer)) + (let ((v1-0 (-> arg0 heap))) + (set! (-> v1-0 base) (the-as pointer (+ #x84000 (* #x3dc00 (-> arg0 index))))) + (set! (-> v1-0 current) (-> v1-0 base)) + (set! (-> v1-0 top-base) (&+ (-> v1-0 base) #x3dc00)) + (set! (-> v1-0 top) (-> v1-0 top-base)) + ) + 0 + ) + +;; definition for method 9 of type external-art-buffer +(defmethod set-pending-file external-art-buffer ((obj external-art-buffer) (arg0 string) (arg1 int) (arg2 handle) (arg3 float)) + (set! (-> obj pending-load-file) arg0) + (set! (-> obj pending-load-file-part) arg1) + (set! (-> obj pending-load-file-owner) arg2) + (set! (-> obj pending-load-file-priority) arg3) + 0 + ) + +;; definition for method 15 of type external-art-buffer +(defmethod unlock! external-art-buffer ((obj external-art-buffer)) + (set! (-> obj locked?) #f) + 0 + ) + +;; definition for method 11 of type external-art-buffer +(defmethod inactive? external-art-buffer ((obj external-art-buffer)) + (!= (-> obj status) 'active) + ) + +;; definition for method 12 of type external-art-buffer +(defmethod file-status external-art-buffer ((obj external-art-buffer) (arg0 string) (arg1 int)) + (when (and (name= (-> obj pending-load-file) arg0) (= (-> obj pending-load-file-part) arg1)) + (if (and (name= (-> obj load-file) arg0) (= (-> obj load-file-part) arg1)) + (-> obj status) + 'pending + ) + ) + ) + +;; definition for method 13 of type art-group +(defmethod link-art! art-group ((obj art-group)) + (when obj + (countdown (s5-0 (-> obj length)) + (let* ((s3-0 (-> obj data s5-0)) + (s4-0 (if (type? s3-0 art-joint-anim) + (the-as art-joint-anim s3-0) + ) + ) + (s2-0 #f) + ) + (when s4-0 + (let ((s3-1 7)) + (while (begin (label cfg-24) (nonzero? s3-1)) + (+! s3-1 -1) + (let ((v1-8 (get-art-group-by-name (-> *level* level s3-1) (-> s4-0 master-art-group-name)))) + (when v1-8 + (countdown (a0-5 (-> v1-8 length)) + (if (= (-> v1-8 data a0-5) s4-0) + (goto cfg-24) + ) + ) + (cond + ((and (< (-> s4-0 master-art-group-index) (-> v1-8 length)) + (not (-> v1-8 data (-> s4-0 master-art-group-index))) + ) + (set! (-> v1-8 data (-> s4-0 master-art-group-index)) s4-0) + (set! s2-0 #t) + ) + (else + (countdown (a0-17 (-> v1-8 length)) + (when (not (-> v1-8 data a0-17)) + (set! (-> v1-8 data a0-17) s4-0) + (set! s2-0 #t) + (goto cfg-24) + ) + ) + ) + ) + ) + ) + ) + ) + (if (not s2-0) + (format 0 "ERROR: ~A could not find a master slot to link for ~A.~%" (-> obj name) s4-0) + ) + ) + ) + ) + ) + obj + ) + +;; definition for method 14 of type art-group +(defmethod unlink-art! art-group ((obj art-group)) + (when obj + (countdown (s5-0 (-> obj length)) + (let* ((s3-0 (-> obj data s5-0)) + (s4-0 (if (type? s3-0 art-joint-anim) + (the-as art-joint-anim s3-0) + ) + ) + (s3-1 #f) + ) + (when s4-0 + (let ((s2-0 7)) + (while (begin (label cfg-13) (nonzero? s2-0)) + (+! s2-0 -1) + (let ((v1-8 (get-art-group-by-name (-> *level* level s2-0) (-> s4-0 master-art-group-name)))) + (when v1-8 + (countdown (a0-5 (-> v1-8 length)) + (when (= s4-0 (-> v1-8 data a0-5)) + (set! (-> v1-8 data a0-5) #f) + (set! s3-1 #t) + (goto cfg-13) + ) + ) + ) + ) + ) + ) + (if (not s3-1) + (format 0 "ERROR: ~A could not find a master slot to unlink for ~A.~%" (-> obj name) s4-0) + ) + ) + ) + ) + ) + 0 + ) + +;; definition for method 13 of type external-art-buffer +(defmethod link-file external-art-buffer ((obj external-art-buffer) (arg0 art-group)) + (when arg0 + (link-art! arg0) + (set! (-> obj art-group) arg0) + ) + arg0 + ) + +;; definition for method 14 of type external-art-buffer +(defmethod unlink-file external-art-buffer ((obj external-art-buffer) (arg0 art-group)) + (when arg0 + (unlink-art! arg0) + (set! (-> obj art-group) #f) + ) + 0 + ) + +;; definition for method 10 of type external-art-buffer +;; WARN: Found some very strange gotos. Check result carefully, this is not well tested. +(defmethod update external-art-buffer ((obj external-art-buffer)) + (when (or (not (name= (-> obj pending-load-file) (-> obj load-file))) + (!= (-> obj pending-load-file-part) (-> obj load-file-part)) + ) + (when (not (handle->process (-> obj pending-load-file-owner))) + (set! (-> obj pending-load-file) #f) + (set! (-> obj pending-load-file-part) -1) + (set! (-> obj pending-load-file-owner) (the-as handle #f)) + (set! (-> obj pending-load-file-priority) 100000000.0) + ) + (when (= (-> obj status) 'initialize) + ((-> obj init-heap) obj) + (set! (-> obj status) 'inactive) + ) + (cond + ((-> obj load-file) + (if (= (-> obj status) 'loading) + (str-load-cancel) + ) + (set! (-> obj load-file) #f) + (set! (-> obj load-file-part) -1) + (set! (-> obj load-file-owner) (the-as handle #f)) + (set! (-> obj load-file-priority) 100000000.0) + ) + (else + (set! (-> obj load-file) (-> obj pending-load-file)) + (set! (-> obj load-file-part) (-> obj pending-load-file-part)) + (set! (-> obj load-file-owner) (-> obj pending-load-file-owner)) + (set! (-> obj load-file-priority) (-> obj pending-load-file-priority)) + ) + ) + ) + (label cfg-18) + (cond + ((-> obj load-file) + (case (-> obj status) + (('active 'reserved) + ) + (('error) + (set! (-> obj status) 'inactive) + (set! (-> obj load-file) #f) + (set! (-> obj load-file-part) -1) + (set! (-> obj load-file-owner) (the-as handle #f)) + (set! (-> obj load-file-priority) 100000000.0) + (set! (-> obj pending-load-file) #f) + (set! (-> obj pending-load-file-part) -1) + (set! (-> obj pending-load-file-owner) (the-as handle #f)) + (set! (-> obj pending-load-file-priority) 100000000.0) + (set! (-> obj art-group) #f) + ) + (('inactive) + (let ((v1-31 (-> obj heap))) + (set! (-> v1-31 current) (-> v1-31 base)) + ) + (cond + ((string= (-> obj load-file) "reserved") + (cond + ((-> *art-control* reserve-buffer) + (format 0 "ERROR: trying double reserve ~A when ~A is reserved~%" obj (-> *art-control* reserve-buffer)) + ) + (else + (set! (-> obj status) 'reserved) + (set! (-> *art-control* reserve-buffer) obj) + ) + ) + ) + ((and (!= (-> *level* loading-level) (-> *level* default-level)) (< 81920.0 (-> obj load-file-priority))) + ) + ((let ((v1-44 (logand -64 (&+ (-> obj heap current) 63)))) + (str-load (-> obj load-file) (-> obj load-file-part) v1-44 (&- (-> obj heap top) (the-as uint v1-44))) + ) + (set! (-> obj status) 'loading) + 0 + ) + ) + ) + (('loading) + (case (str-load-status (&-> obj len)) + (('error) + (set! (-> obj status) 'error) + ) + (('busy) + ) + (else + (set! (-> obj buf) (logand -64 (&+ (-> obj heap current) 63))) + (set! (-> obj status) 'loaded) + (goto cfg-18) + ) + ) + ) + (('loaded) + (let ((a0-34 (-> obj buf))) + (cond + ((-> obj login?) + (set! (-> obj art-group) (the-as art-group (link a0-34 (-> obj load-file data) (-> obj len) (-> obj heap) 0))) + (let ((s4-0 (-> obj art-group)) + (s3-0 (-> obj load-file)) + ) + (cond + ((not s4-0) + (format 0 "ERROR: art-group ~A part ~D is not a valid file.~%" s3-0 (-> obj load-file-part)) + (set! (-> obj status) 'error) + ) + ((not (type? s4-0 art-group)) + (format 0 "ERROR: art-group ~A part ~D is not a art-group.~%" s3-0 (-> obj load-file-part)) + (set! (-> obj status) 'error) + ) + ((not (file-info-correct-version? (-> s4-0 info) (file-kind art-group) 0)) + (set! (-> obj status) 'error) + ) + (else + (login s4-0) + (set! (-> obj status) 'locked) + ) + ) + ) + ) + (else + (set! (-> obj status) 'locked) + (set! (-> obj art-group) (the-as art-group a0-34)) + ) + ) + ) + ) + (('locked) + (when (and (not (-> obj locked?)) (handle->process (-> obj load-file-owner))) + (if (-> obj login?) + (link-file obj (-> obj art-group)) + ) + (if (-> obj other) + (set! (-> obj other locked?) #t) + ) + (set! (-> obj status) 'active) + (goto cfg-18) + ) + ) + ) + ) + (else + (case (-> obj status) + (('initialize) + ) + (('reserved) + (cond + ((= (-> *art-control* reserve-buffer) obj) + (set! (-> *art-control* reserve-buffer) #f) + (set! (-> obj status) 'inactive) + ) + (else + (format 0 "ERROR: trying tro free ~A when ~A is reserved~%" obj (-> *art-control* reserve-buffer)) + ) + ) + ) + (('active) + (if (-> obj login?) + (unlink-file obj (-> obj art-group)) + ) + (let ((v1-86 (-> obj heap))) + (set! (-> v1-86 current) (-> v1-86 base)) + ) + (set! (-> obj art-group) #f) + (set! (-> obj status) 'inactive) + (when (and (-> obj other) (-> obj other locked?)) + (unlock! (-> obj other)) + (update (-> obj other)) + ) + ) + (else + (let ((v1-96 (-> obj heap))) + (set! (-> v1-96 current) (-> v1-96 base)) + ) + (set! (-> obj art-group) #f) + (set! (-> obj status) 'inactive) + ) + ) + ) + ) + 0 + ) + +;; definition for symbol *preload-spool-anims*, type symbol +(define *preload-spool-anims* #t) + +;; definition for method 12 of type external-art-control +(defmethod file-status external-art-control ((obj external-art-control) (arg0 string) (arg1 int)) + (dotimes (s3-0 2) + (let ((v1-3 (file-status (-> obj buffer s3-0) arg0 arg1))) + (if v1-3 + (return v1-3) + ) + ) + ) + #f + ) + +;; definition for method 9 of type external-art-control +(defmethod update external-art-control ((obj external-art-control) (arg0 symbol)) + (if (nonzero? (-> obj reserve-buffer-count)) + (spool-push obj "reserved" 0 *dproc* (if (-> obj reserve-buffer) + -110.0 + -0.5 + ) + ) + ) + (dotimes (v1-5 2) + (set! (-> obj buffer v1-5 frame-lock) #f) + ) + (dotimes (v1-8 3) + (set! (-> obj rec v1-8 buffer) #f) + ) + (dotimes (s4-0 2) + (let ((s3-0 (-> obj rec s4-0))) + (when (-> s3-0 name) + (dotimes (s2-0 2) + (when (and (file-status (-> obj buffer s2-0) (-> s3-0 name) (the-as int (-> s3-0 parts))) + (not (-> obj buffer s2-0 frame-lock)) + ) + (set! (-> obj buffer s2-0 frame-lock) #t) + (set! (-> s3-0 buffer) (-> obj buffer s2-0)) + (set! (-> obj buffer s2-0 pending-load-file-owner) (-> s3-0 owner)) + (set! (-> obj buffer s2-0 load-file-owner) (-> s3-0 owner)) + (set! (-> obj buffer s2-0 pending-load-file-priority) (-> s3-0 priority)) + (set! (-> obj buffer s2-0 load-file-priority) (-> s3-0 priority)) + (goto cfg-24) + ) + ) + ) + ) + (label cfg-24) + ) + (dotimes (s4-1 2) + (let ((s3-1 (-> obj rec s4-1))) + (when (and (-> s3-1 name) (not (-> s3-1 buffer))) + (if (and (not *preload-spool-anims*) (>= (-> s3-1 priority) 0.0)) + (goto cfg-46) + ) + (dotimes (s2-1 2) + (when (not (-> obj buffer s2-1 frame-lock)) + (set! (-> obj buffer s2-1 frame-lock) #t) + (set-pending-file + (-> obj buffer s2-1) + (-> s3-1 name) + (the-as int (-> s3-1 parts)) + (-> s3-1 owner) + (-> s3-1 priority) + ) + (set! (-> s3-1 buffer) (-> obj buffer s2-1)) + (goto cfg-46) + ) + ) + ) + ) + (label cfg-46) + ) + (when (not (-> obj reserve-buffer)) + (let ((s4-2 (-> obj rec 0 buffer))) + (if (and s4-2 + (-> s4-2 locked?) + (not (string= (-> s4-2 pending-load-file) "reserved")) + (not (string= (-> s4-2 other pending-load-file) "reserved")) + ) + (set-pending-file (-> s4-2 other) (the-as string #f) -1 (the-as handle #f) 100000000.0) + ) + ) + ) + (dotimes (s4-3 2) + (update (-> obj buffer s4-3)) + ) + (let ((s4-4 (-> obj queue-stream))) + (set! (-> s4-4 length) 0) + (dotimes (s3-2 3) + (when (-> obj rec s3-2 name) + (mem-copy! (&-> (-> s4-4 (-> s4-4 length)) type) (&-> (-> obj rec s3-2) type) 44) + (+! (-> s4-4 length) 1) + ) + ) + ) + (when (and arg0 *display-art-control*) + (dotimes (s5-1 3) + (let ((t9-8 format) + (a0-27 *stdcon*) + (a1-8 "rec ~d ~S ~D ~f ~A~%") + (a2-5 s5-1) + (a3-3 (-> obj rec s5-1 name)) + (t0-3 (-> obj rec s5-1 parts)) + (t1-0 (-> obj rec s5-1 priority)) + (v1-121 (handle->process (-> obj rec s5-1 owner))) + ) + (t9-8 a0-27 a1-8 a2-5 a3-3 t0-3 t1-0 (if v1-121 + (-> v1-121 name) + ) + ) + ) + ) + (dotimes (s5-2 2) + (let ((t9-9 format) + (a0-28 *stdcon*) + (a1-9 "buf ~d ~C ~S ~D ~A ~A~%") + (a2-6 s5-2) + (a3-4 (if (-> obj buffer s5-2 locked?) + 108 + 32 + ) + ) + (t0-4 (-> obj buffer s5-2 pending-load-file)) + (t1-1 (-> obj buffer s5-2 pending-load-file-part)) + (t2-5 (-> obj buffer s5-2 status)) + (v1-142 (handle->process (-> obj buffer s5-2 pending-load-file-owner))) + ) + (t9-9 a0-28 a1-9 a2-6 a3-4 t0-4 t1-1 t2-5 (if v1-142 + (-> v1-142 name) + ) + ) + ) + ) + (format *stdcon* " a: ~S~%" (-> obj active-stream)) + ) + 0 + ) + +;; definition for method 15 of type external-art-control +(defmethod none-reserved? external-art-control ((obj external-art-control)) + (zero? (-> obj reserve-buffer-count)) + ) + +;; definition for method 13 of type external-art-control +(defmethod reserve-alloc external-art-control ((obj external-art-control)) + (cond + ((or (nonzero? (-> obj dma-reserve-buffer-count)) (= *master-mode* 'progress)) + (set! (-> obj dma-reserve-buffer-count) 1) + (when (and (-> *bigmap* drawing-flag) (zero? (-> *blit-displays-work* count-down))) + (let ((v1-8 (-> obj dma-reserve-heap))) + (set! (-> v1-8 base) (logand -64 (&+ (&+ (-> *display* frames 1 global-buf end) -252992) 63))) + (set! (-> v1-8 current) (-> v1-8 base)) + (set! (-> v1-8 top-base) (&+ (-> v1-8 base) #x3dc00)) + (set! (-> v1-8 top) (-> v1-8 top-base)) + ) + (set! (-> *display* frames 1 global-buf end) (-> obj dma-reserve-heap base)) + (-> obj dma-reserve-heap) + ) + ) + (else + (set! (-> obj reserve-buffer-count) 1) + (if (and (-> obj reserve-buffer) (not (check-busy *load-str-rpc*))) + (-> obj reserve-buffer heap) + ) + ) + ) + ) + +;; definition for method 14 of type external-art-control +(defmethod reserve-free external-art-control ((obj external-art-control) (arg0 kheap)) + (cond + ((nonzero? (-> obj dma-reserve-buffer-count)) + (set! (-> obj dma-reserve-buffer-count) 0) + (let ((v1-3 (-> *display* frames 1 global-buf))) + (set! (-> v1-3 end) (&-> v1-3 data-buffer (-> v1-3 allocated-length))) + ) + ) + ((and (zero? (-> obj reserve-buffer-count)) (zero? (-> obj dma-reserve-buffer-count))) + (format 0 "ERROR: illegal attempt to free a buffer #x~X which had not been reserved (none reserved).~%" arg0) + ) + ((not (-> obj reserve-buffer)) + (set! (-> obj reserve-buffer-count) 0) + 0 + ) + ((= (-> obj reserve-buffer heap) arg0) + (set-pending-file (-> obj reserve-buffer) (the-as string #f) -1 (the-as handle #f) 100000000.0) + (update (-> obj reserve-buffer)) + (set! (-> obj reserve-buffer-count) 0) + 0 + ) + (else + (format 0 "ERROR: illegal attempt to free a buffer #x~X which had not been reserved (buffer unknown).~%" arg0) + ) + ) + 0 + ) + +;; definition for method 10 of type external-art-control +(defmethod clear-rec external-art-control ((obj external-art-control)) + (dotimes (v1-0 3) + (set! (-> obj rec v1-0 type) spool-anim) + (set! (-> obj rec v1-0 name) #f) + (set! (-> obj rec v1-0 priority) 100000000.0) + (set! (-> obj rec v1-0 owner) (the-as handle #f)) + ) + (set! (-> obj frame-mask) (the-as uint (-> *setting-control* user-current process-mask))) + 0 + ) + +;; definition for method 11 of type external-art-control +(defmethod spool-push external-art-control ((obj external-art-control) (arg0 string) (arg1 int) (arg2 process) (arg3 float)) + (when (and (= arg3 -99.0) arg2) + (let ((a0-2 (target-pos 0))) + (set! arg3 (vector-vector-distance a0-2 (-> (the-as process-drawable arg2) root trans))) + ) + ) + (cond + ((and (= arg1 (-> obj rec 0 parts)) (name= arg0 (-> obj rec 0 name))) + (if (>= arg3 (-> obj rec 0 priority)) + (return (the-as int #f)) + ) + (mem-copy! (&-> (-> obj rec) 0 type) (&-> (-> obj rec 1) type) 44) + (mem-copy! (&-> (-> obj rec 1) type) (&-> (-> obj rec 2) type) 44) + (set! (-> obj rec 2 name) #f) + (set! (-> obj rec 2 owner) (the-as handle #f)) + ) + ((and (= arg1 (-> obj rec 1 parts)) (name= arg0 (-> obj rec 1 name))) + (if (>= arg3 (-> obj rec 1 priority)) + (return (the-as int #f)) + ) + (mem-copy! (&-> (-> obj rec 1) type) (&-> (-> obj rec 2) type) 44) + (set! (-> obj rec 2 name) #f) + (set! (-> obj rec 2 owner) (the-as handle #f)) + ) + ((and (= arg1 (-> obj rec 2 parts)) (name= arg0 (-> obj rec 2 name))) + (if (>= arg3 (-> obj rec 2 priority)) + (return (the-as int #f)) + ) + (set! (-> obj rec 2 name) #f) + (set! (-> obj rec 2 owner) (the-as handle #f)) + ) + ) + (cond + ((< arg3 (-> obj rec 0 priority)) + (mem-copy! (&-> (-> obj rec 2) type) (&-> (-> obj rec 1) type) 44) + (mem-copy! (&-> (-> obj rec 1) type) (&-> (-> obj rec) 0 type) 44) + (set! (-> obj rec 0 name) arg0) + (set! (-> obj rec 0 parts) arg1) + (set! (-> obj rec 0 priority) arg3) + (set! (-> obj rec 0 owner) (process->handle arg2)) + ) + ((< arg3 (-> obj rec 1 priority)) + (mem-copy! (&-> (-> obj rec 2) type) (&-> (-> obj rec 1) type) 44) + (set! (-> obj rec 1 name) arg0) + (set! (-> obj rec 1 parts) arg1) + (set! (-> obj rec 1 priority) arg3) + (set! (-> obj rec 1 owner) (process->handle arg2)) + ) + ((< arg3 (-> obj rec 2 priority)) + (set! (-> obj rec 2 name) arg0) + (set! (-> obj rec 2 parts) arg1) + (set! (-> obj rec 2 priority) arg3) + (set! (-> obj rec 2 owner) (process->handle arg2)) + ) + ) + 0 + ) + +;; definition of type spooler-block +(deftype spooler-block (basic) + ((anim spool-anim :offset-assert 4) + (idle art-joint-anim :offset-assert 8) + (exit art-joint-anim :offset-assert 12) + (break-func (function process-drawable object) :offset-assert 16) + (part int32 :offset-assert 20) + (part-audio-start float :offset-assert 24) + (old-status uint16 :offset-assert 28) + (old-pos int32 :offset-assert 32) + (good-time time-frame :offset-assert 40) + (old-time time-frame :offset-assert 48) + (good-count int32 :offset-assert 56) + (sid sound-id :offset-assert 60) + (real-start-time time-frame :offset-assert 64) + (paused? symbol :offset-assert 72) + ) + :method-count-assert 9 + :size-assert #x4c + :flag-assert #x90000004c + (:methods + (new (symbol type art-joint-anim (function process-drawable symbol)) _type_ 0) + ) + ) + +;; definition for method 3 of type spooler-block +(defmethod inspect spooler-block ((obj spooler-block)) + (when (not obj) + (set! obj obj) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" obj (-> obj type)) + (format #t "~1Tanim: ~A~%" (-> obj anim)) + (format #t "~1Tidle: ~A~%" (-> obj idle)) + (format #t "~1Texit: ~A~%" (-> obj exit)) + (format #t "~1Tbreak-func: ~A~%" (-> obj break-func)) + (format #t "~1Tpart: ~D~%" (-> obj part)) + (format #t "~1Tpart-audio-start: ~f~%" (-> obj part-audio-start)) + (format #t "~1Told-status: ~D~%" (-> obj old-status)) + (format #t "~1Told-pos: ~D~%" (-> obj old-pos)) + (format #t "~1Tgood-time: ~D~%" (-> obj good-time)) + (format #t "~1Told-time: ~D~%" (-> obj old-time)) + (format #t "~1Tgood-count: ~D~%" (-> obj good-count)) + (format #t "~1Tsid: ~D~%" (-> obj sid)) + (format #t "~1Treal-start-time: ~D~%" (-> obj real-start-time)) + (format #t "~1Tpaused?: ~A~%" (-> obj paused?)) + (label cfg-4) + obj + ) + +;; definition for function ja-play-spooled-anim +(defbehavior ja-play-spooled-anim process-drawable ((arg0 spool-anim) (arg1 art-joint-anim) (arg2 art-joint-anim) (arg3 (function process-drawable symbol))) + (local-vars (v0-59 int) (sv-176 int)) + (let ((s2-0 arg2) + (s1-0 arg3) + (gp-0 ((method-of-type spooler-block new) (new 'stack-no-clear 'symbol) spooler-block arg2 arg3)) + ) + (let ((s5-0 gp-0)) + (set! (-> s5-0 anim) arg0) + (set! (-> s5-0 idle) arg1) + (set! (-> s5-0 exit) s2-0) + (set! (-> s5-0 break-func) s1-0) + (set! (-> s5-0 part-audio-start) -17.0) + (set! (-> s5-0 old-status) (the-as uint (-> self skel status))) + (set! (-> s5-0 old-pos) -2) + (set! (-> s5-0 sid) (new-sound-id)) + (set! (-> s5-0 paused?) #f) + ) + (let ((v1-7 + (gui-control-method-15 *gui-control* self (gui-channel art-load) (-> gp-0 anim name) (new 'static 'sound-id)) + ) + ) + (if v1-7 + (set! (-> gp-0 sid) (-> v1-7 id)) + ) + ) + (if (!= self *target*) + (send-event *target* 'movie) + ) + (backup-load-state-and-set-cmds *load-state* (-> gp-0 anim command-list)) + (logior! (-> self skel status) (joint-control-status sync-math spooling spooling-not-last-block)) + (talker-surpress!) + (apply-settings *setting-control*) + (when (or (and (-> *setting-control* user-current spooling) + (or (< 2 (the-as int (-> gp-0 anim parts))) + (not (string= (-> *setting-control* user-current spool-anim name) (-> gp-0 anim name))) + ) + ) + (logtest? (-> *art-control* frame-mask) 28) + (!= *master-mode* 'game) + ) + (cond + ((-> gp-0 idle) + (when (!= (ja-group) (-> gp-0 idle)) + (ja-channel-push! 1 (seconds 0.05)) + (ja :group! (-> gp-0 idle) :num! min) + ) + ) + (else + (ja-channel-set! 0) + ) + ) + (while (or (and (-> *setting-control* user-current spooling) + (or (< 2 (the-as int (-> gp-0 anim parts))) + (not (string= (-> *setting-control* user-current spool-anim name) (-> gp-0 anim name))) + ) + ) + (logtest? (-> *art-control* frame-mask) 28) + (!= *master-mode* 'game) + ) + (format #t "WARNING: ---------------------> loader stall on lock~%") + (if ((-> gp-0 break-func) self) + (goto cfg-130) + ) + (gui-control-method-12 + *gui-control* + self + (gui-channel art-load) + (gui-action queue) + (-> gp-0 anim name) + (-> gp-0 part) + -9.0 + (-> gp-0 sid) + ) + (suspend) + (if (-> gp-0 idle) + (ja :num! (loop!)) + ) + ) + ) + (set-setting! 'spooling (process->ppointer self) 0 0) + (set-setting! 'spool-anim (-> gp-0 anim) 0 0) + (apply-settings *setting-control*) + (set! (-> gp-0 old-time) (-> self clock frame-counter)) + (while (< (-> gp-0 part) (the-as int (-> gp-0 anim parts))) + (when (> (-> gp-0 part) 0) + (while (let ((v1-99 (file-status *art-control* (-> gp-0 anim name) (-> gp-0 part)))) + (not (or (= v1-99 'active) (= v1-99 'locked))) + ) + (if ((-> gp-0 break-func) self) + (goto cfg-130) + ) + (gui-control-method-12 + *gui-control* + self + (gui-channel art-load) + (gui-action queue) + (-> gp-0 anim name) + (+ (-> gp-0 part) -1) + -20.0 + (-> gp-0 sid) + ) + (gui-control-method-12 + *gui-control* + self + (gui-channel art-load) + (gui-action queue) + (-> gp-0 anim name) + (-> gp-0 part) + -10.0 + (-> gp-0 sid) + ) + (when (and (not (-> gp-0 paused?)) (< (-> *setting-control* user-current movie-skip-frame) 0.0)) + (format + #t + "WARNING: ---------------------> loader pre stall on art ~S ~D ~A~%" + (-> gp-0 anim name) + (-> gp-0 part) + (file-status *art-control* (-> gp-0 anim name) (-> gp-0 part)) + ) + (set! (-> gp-0 paused?) #t) + (if (nonzero? (-> gp-0 part)) + (sound-pause (-> gp-0 sid)) + ) + ) + (suspend) + ) + ) + (gui-control-method-12 + *gui-control* + self + (gui-channel art-load) + (gui-action queue) + (-> gp-0 anim name) + (-> gp-0 part) + -20.0 + (-> gp-0 sid) + ) + (update *gui-control* #f) + (update *art-control* #f) + (gui-control-method-12 + *gui-control* + self + (gui-channel art-load) + (gui-action queue) + (-> gp-0 anim name) + (-> gp-0 part) + -20.0 + (-> gp-0 sid) + ) + (when (!= (file-status *art-control* (-> gp-0 anim name) (-> gp-0 part)) 'active) + (cond + ((-> gp-0 idle) + (when (!= (ja-group) (-> gp-0 idle)) + (ja-channel-set! 1) + (ja :group! (-> gp-0 idle) :num! min) + ) + ) + (else + (ja-channel-set! 0) + ) + ) + (while (!= (file-status *art-control* (-> gp-0 anim name) (-> gp-0 part)) 'active) + (if ((-> gp-0 break-func) self) + (goto cfg-130) + ) + (gui-control-method-12 + *gui-control* + self + (gui-channel art-load) + (gui-action queue) + (-> gp-0 anim name) + (-> gp-0 part) + -20.0 + (-> gp-0 sid) + ) + (when (not (-> gp-0 paused?)) + (format + #t + "WARNING: ---------------------> loader stall on art ~S ~D ~A~%" + (-> gp-0 anim name) + (-> gp-0 part) + (file-status *art-control* (-> gp-0 anim name) (-> gp-0 part)) + ) + (set! (-> gp-0 paused?) #t) + (if (nonzero? (-> gp-0 part)) + (sound-pause (-> gp-0 sid)) + ) + ) + (suspend) + (if (-> gp-0 idle) + (ja :num! (loop!)) + ) + ) + ) + (when (-> gp-0 paused?) + (set! (-> gp-0 paused?) #f) + (sound-continue (-> gp-0 sid)) + (format + #t + "WARNING: ---------------------> loader release lock on art ~S ~D ~A~%" + (-> gp-0 anim name) + (-> gp-0 part) + (file-status *art-control* (-> gp-0 anim name) (-> gp-0 part)) + ) + ) + (gui-control-method-12 + *gui-control* + self + (gui-channel art-load) + (gui-action queue) + (-> gp-0 anim name) + (-> gp-0 part) + -20.0 + (-> gp-0 sid) + ) + (let ((s5-8 (get-art-by-name (-> self draw art-group) (the-as string (-> gp-0 anim buffer)) art-joint-anim))) + (cond + (s5-8 + (ja-channel-set! 1) + (ja-no-eval :group! s5-8 :num! (seek! (the float (+ (-> s5-8 frames num-frames) -1))) :frame-num 0.0) + (when (zero? (-> gp-0 part)) + (str-play-async (-> gp-0 anim name) (-> gp-0 sid)) + (set! (-> *art-control* active-stream) (-> gp-0 anim name)) + ) + (let* ((f30-0 (* 0.05859375 (-> s5-8 speed))) + (f28-0 (+ (-> gp-0 part-audio-start) (/ (the float (+ (-> s5-8 frames num-frames) -1)) f30-0))) + ) + (set! sv-176 (current-str-pos (-> gp-0 sid))) + (set! (-> gp-0 good-time) (-> self clock frame-counter)) + (until (>= (the float v0-59) f28-0) + (if (= (-> self skel root-channel 0) (-> self skel channel)) + (logior! (-> self skel status) (joint-control-status valid-spooled-frame)) + ) + (if (or ((-> gp-0 break-func) self) + (and (<= sv-176 0) (>= (- (-> self clock frame-counter) (-> gp-0 good-time)) (seconds 4))) + (and (< 300 (-> gp-0 good-count)) (<= sv-176 0)) + ) + (goto cfg-130) + ) + (gui-control-method-12 + *gui-control* + self + (gui-channel art-load) + (gui-action queue) + (-> gp-0 anim name) + (-> gp-0 part) + -20.0 + (-> gp-0 sid) + ) + (if (< (+ (-> gp-0 part) 1) (the-as int (-> gp-0 anim parts))) + (gui-control-method-12 + *gui-control* + self + (gui-channel art-load) + (gui-action queue) + (-> gp-0 anim name) + (+ (-> gp-0 part) 1) + -10.0 + (-> gp-0 sid) + ) + (logclear! (-> self skel status) (joint-control-status spooling-not-last-block)) + ) + (execute-commands-up-to *load-state* (ja-aframe-num 0)) + (cond + ((and (< (-> gp-0 old-pos) sv-176) (< -1 sv-176)) + (+! (-> gp-0 good-count) (- (-> self clock frame-counter) (-> self clock old-frame-counter))) + (set! (-> gp-0 good-time) (-> self clock frame-counter)) + ) + (else + 0 + ) + ) + (set! (-> gp-0 old-pos) sv-176) + (set! (-> gp-0 old-time) (-> self clock frame-counter)) + (suspend) + (let* ((f26-0 (* (- (the float (current-str-pos (-> gp-0 sid))) (-> gp-0 part-audio-start)) f30-0)) + (f0-16 (if (str-id-is-playing? (the-as int (-> gp-0 sid))) + (fmax 0.0 (fmin f26-0 (the float (+ (-> (ja-group) frames num-frames) -1)))) + (fmax 0.0 (fmin (ja-frame-num 0) (the float (+ (-> (ja-group) frames num-frames) -1)))) + ) + ) + ) + (ja-no-eval :num! (seek!) :frame-num f0-16) + ) + (set! v0-59 (current-str-pos (-> gp-0 sid))) + (set! sv-176 v0-59) + ) + (set! (-> gp-0 part-audio-start) f28-0) + ) + (logclear! (-> self skel status) (joint-control-status valid-spooled-frame)) + ) + (else + (format + 0 + "ERROR: ~A in spool anim loop for ~A ~D, but not loaded.~" + self + (-> gp-0 anim name) + (-> gp-0 part) + ) + (goto cfg-130) + ) + ) + ) + (+! (-> gp-0 part) 1) + ) + (+! (-> gp-0 part) -1) + (label cfg-130) + (ja-abort-spooled-anim (-> gp-0 anim) (-> gp-0 exit) (-> gp-0 part)) + ) + 0 + ) + +;; definition for function ja-abort-spooled-anim +(defbehavior ja-abort-spooled-anim process-drawable ((arg0 spool-anim) (arg1 art-joint-anim) (arg2 int)) + (let ((s3-0 (new 'static 'sound-id))) + (let ((v1-1 + (gui-control-method-15 *gui-control* self (gui-channel art-load) (-> arg0 name) (new 'static 'sound-id)) + ) + ) + (when v1-1 + (set! s3-0 (-> v1-1 id)) + (set! (-> v1-1 action) (gui-action abort)) + ) + ) + (if (zero? s3-0) + (return (the-as int #f)) + ) + (str-play-stop (-> arg0 name) s3-0) + ) + (restore-load-state-and-cleanup *load-state*) + (set! (-> *art-control* active-stream) #f) + (logclear! (-> self skel status) (joint-control-status spooling spooling-not-last-block)) + (if (zero? (logand (-> self skel status) (joint-control-status sync-math))) + (logclear! (-> self skel status) (joint-control-status sync-math)) + ) + (cond + ((and arg1 (>= arg2 0)) + (ja-channel-push! 1 (seconds 0.03)) + (set! (-> self skel root-channel 0 frame-group) arg1) + (while (!= (-> self skel root-channel 0) (-> self skel channel)) + (gui-control-method-12 + *gui-control* + self + (gui-channel art-load) + (gui-action queue) + (-> arg0 name) + arg2 + -20.0 + (new 'static 'sound-id) + ) + (suspend) + (ja :num! (seek!)) + ) + ) + (else + (ja-channel-set! 0) + ) + ) + (remove-setting! 'spooling) + (remove-setting! 'spool-anim) + 0 + ) + +;; definition for method 3 of type gui-control +(defmethod inspect gui-control ((obj gui-control)) + (format #t "[~8x] ~A~%" obj (-> obj type)) + (format #t "~Tengine: ~A~%" (-> obj engine)) + (let ((a2-2 (-> obj engine alive-list next0))) + (-> obj engine) + (let ((s5-0 (-> a2-2 next0))) + (while (!= a2-2 (-> obj engine alive-list-end)) + (format #t "~T~T~`gui-connection`P~%" a2-2) + (set! a2-2 s5-0) + (-> obj engine) + (set! s5-0 (-> s5-0 next0)) + ) + ) + ) + obj + ) + +;; definition for method 2 of type gui-connection +(defmethod print gui-connection ((obj gui-connection)) + (let* ((t9-0 format) + (a0-1 #t) + (a1-0 "# obj name)) + (a3-0 (-> obj anim-part)) + (t0-0 (-> obj id)) + (t1-0 (-> obj priority)) + (v1-0 (-> obj channel)) + (t2-1 (cond + ((= v1-0 (gui-channel hud-lower-left)) + "hud-lower-left" + ) + ((= v1-0 (gui-channel citizen)) + "citizen" + ) + ((= v1-0 (gui-channel ashelin)) + "ashelin" + ) + ((= v1-0 (gui-channel hud-lower-left-1)) + "hud-lower-left-1" + ) + ((= v1-0 (gui-channel message)) + "message" + ) + ((= v1-0 (gui-channel hud-middle-left)) + "hud-middle-left" + ) + ((= v1-0 (gui-channel hud-upper-center-2)) + "hud-upper-center-2" + ) + ((= v1-0 (gui-channel hud-middle-right)) + "hud-middle-right" + ) + ((= v1-0 (gui-channel subtitle)) + "subtitle" + ) + ((= v1-0 (gui-channel notice)) + "notice" + ) + ((= v1-0 (gui-channel voicebox)) + "voicebox" + ) + ((= v1-0 (gui-channel art-load-next)) + "art-load-next" + ) + ((= v1-0 (gui-channel mog)) + "mog" + ) + ((= v1-0 (gui-channel sig)) + "sig" + ) + ((= v1-0 (gui-channel hud-center-left)) + "hud-center-left" + ) + ((= v1-0 (gui-channel hud-upper-right)) + "hud-upper-right" + ) + ((= v1-0 (gui-channel hud-center-right)) + "hud-center-right" + ) + ((= v1-0 (gui-channel alert)) + "alert" + ) + ((= v1-0 (gui-channel jinx)) + "jinx" + ) + ((= v1-0 (gui-channel hud-upper-left)) + "hud-upper-left" + ) + ((= v1-0 (gui-channel query)) + "query" + ) + ((= v1-0 (gui-channel grim)) + "grim" + ) + ((= v1-0 (gui-channel kor)) + "kor" + ) + ((= v1-0 (gui-channel hud-lower-right)) + "hud-lower-right" + ) + ((= v1-0 (gui-channel screen)) + "screen" + ) + ((= v1-0 (gui-channel guard)) + "guard" + ) + ((= v1-0 (gui-channel supertitle)) + "supertitle" + ) + ((= v1-0 (gui-channel hal)) + "hal" + ) + ((= v1-0 (gui-channel hud-upper-center)) + "hud-upper-center" + ) + ((= v1-0 (gui-channel blackout)) + "blackout" + ) + ((= v1-0 (gui-channel bbush)) + "bbush" + ) + ((= v1-0 (gui-channel hud)) + "hud" + ) + ((= v1-0 (gui-channel voice)) + "voice" + ) + ((= v1-0 (gui-channel max)) + "max" + ) + ((= v1-0 (gui-channel none)) + "none" + ) + ((= v1-0 (gui-channel notice-low)) + "notice-low" + ) + ((= v1-0 (gui-channel art-load)) + "art-load" + ) + ((= v1-0 (gui-channel kid)) + "kid" + ) + ((= v1-0 (gui-channel jak)) + "jak" + ) + ((= v1-0 (gui-channel daxter)) + "daxter" + ) + ((= v1-0 (gui-channel krew)) + "krew" + ) + ((= v1-0 (gui-channel hud-lower-left-2)) + "hud-lower-left-2" + ) + ((= v1-0 (gui-channel background)) + "background" + ) + ((= v1-0 (gui-channel crocadog)) + "crocadog" + ) + ((= v1-0 (gui-channel movie)) + "movie" + ) + (else + "*unknown*" + ) + ) + ) + (v1-1 (-> obj action)) + ) + (t9-0 a0-1 a1-0 a2-0 a3-0 t0-0 t1-0 t2-1 (cond + ((= v1-1 (gui-action queue)) + "queue" + ) + ((= v1-1 (gui-action stop)) + "stop" + ) + ((= v1-1 (gui-action play)) + "play" + ) + ((= v1-1 (gui-action hide)) + "hide" + ) + ((= v1-1 (gui-action fade)) + "fade" + ) + ((= v1-1 (gui-action none)) + "none" + ) + ((= v1-1 (gui-action abort)) + "abort" + ) + ((= v1-1 (gui-action stopping)) + "stopping" + ) + ((= v1-1 (gui-action hidden)) + "hidden" + ) + ((= v1-1 (gui-action playing)) + "playing" + ) + (else + "*unknown*" + ) + ) + ) + ) + (let ((s5-0 format) + (s4-0 #t) + (s3-0 " ~6S <@ #x~A>") + (v1-3 (gui-control-method-17 *gui-control* (-> obj id))) + ) + (s5-0 + s4-0 + s3-0 + (cond + ((= v1-3 (gui-action play)) + "ready" + ) + ((= v1-3 (gui-action playing)) + "active" + ) + ((= v1-3 (gui-action stopping)) + "stop" + ) + ((= v1-3 (gui-action none)) + "unknown" + ) + ((= v1-3 (gui-action stop)) + "hide" + ) + ((= v1-3 (gui-action queue)) + "pending" + ) + (else + "*unknown*" + ) + ) + obj + ) + ) + obj + ) + +;; definition for method 24 of type gui-control +(defmethod channel-id-set! gui-control ((obj gui-control) (arg0 gui-connection) (arg1 sound-id)) + (set! (-> obj ids (-> arg0 channel)) arg1) + 0 + ) + +;; definition for method 15 of type gui-control +(defmethod gui-control-method-15 gui-control ((obj gui-control) (arg0 process) (arg1 gui-channel) (arg2 string) (arg3 sound-id)) + (let ((s1-0 (the-as gui-connection (-> obj engine alive-list next0)))) + (-> obj engine) + (let ((s0-0 (-> s1-0 next0))) + (while (!= s1-0 (-> obj engine alive-list-end)) + (if (and (or (= arg1 (gui-channel none)) (= (-> s1-0 channel) arg1)) + (or (not arg0) (= (-> arg0 type) scene-player) (= arg0 (get-process s1-0))) + (or (not arg2) (string= arg2 (-> s1-0 name))) + (or (zero? arg3) (= (-> s1-0 id) arg3)) + ) + (return s1-0) + ) + (set! s1-0 (the-as gui-connection s0-0)) + (-> obj engine) + (set! s0-0 (-> s0-0 next0)) + ) + ) + ) + (countdown (s1-1 32) + (let ((s0-1 (-> obj connections s1-1))) + (if (and (nonzero? (-> s0-1 id)) + (or (= arg1 (gui-channel none)) (= (-> s0-1 channel) arg1)) + (and (or (not arg0) (= (-> arg0 type) scene-player) (= arg0 (handle->process (-> s0-1 handle)))) + (or (not arg2) (string= arg2 (-> s0-1 name))) + (or (zero? arg3) (= (-> s0-1 id) arg3)) + ) + ) + (return s0-1) + ) + ) + ) + (the-as gui-connection #f) + ) + +;; definition for method 14 of type gui-control +(defmethod gui-control-method-14 gui-control ((obj gui-control) (arg0 string) (arg1 gui-channel) (arg2 gui-action)) + (let ((s2-0 (the-as gui-connection (-> obj engine alive-list next0)))) + (-> obj engine) + (let ((s1-0 (-> s2-0 next0))) + (while (!= s2-0 (-> obj engine alive-list-end)) + (if (and (or (= arg1 (gui-channel none)) (= arg1 (-> s2-0 channel))) + (or (= arg2 (gui-action none)) (= arg2 (-> s2-0 action))) + (or (not arg0) (string= arg0 (-> s2-0 name))) + ) + (return (the-as int (-> s2-0 id))) + ) + (set! s2-0 (the-as gui-connection s1-0)) + (-> obj engine) + (set! s1-0 (-> s1-0 next0)) + ) + ) + ) + (countdown (s2-1 32) + (let ((s1-1 (-> obj connections s2-1))) + (if (and (nonzero? (-> s1-1 id)) + (or (= arg1 (gui-channel none)) (= arg1 (-> s1-1 channel))) + (or (= arg2 (gui-action none)) (= arg2 (-> s1-1 action))) + (or (not arg0) (string= arg0 (-> s1-1 name))) + ) + (return (the-as int (-> s1-1 id))) + ) + ) + ) + 0 + ) + +;; definition for method 20 of type gui-control +(defmethod gui-control-method-20 gui-control ((obj gui-control) (arg0 sound-id) (arg1 symbol) (arg2 int) (arg3 int) (arg4 int)) + (when (nonzero? arg0) + (let ((v1-2 (gui-control-method-15 *gui-control* (the-as process #f) (gui-channel none) (the-as string #f) arg0))) + (when v1-2 + (if arg1 + (logior! (-> v1-2 flags) 2) + ) + (when (>= arg2 0) + (logior! (-> v1-2 flags) 8) + (set! (-> v1-2 fo-min) arg2) + ) + (when (>= arg3 0) + (logior! (-> v1-2 flags) 16) + (set! (-> v1-2 fo-max) arg3) + ) + (when (>= arg4 0) + (logior! (-> v1-2 flags) 4) + (set! (-> v1-2 fo-curve) arg4) + ) + v1-2 + ) + ) + ) + ) + +;; definition for method 18 of type gui-control +;; INFO: Return type mismatch object vs symbol. +;; WARN: disable def twice: 34. This may happen when a cond (no else) is nested inside of another conditional, but it should be rare. +(defmethod gui-control-method-18 gui-control ((obj gui-control) (arg0 gui-channel)) + (let ((v1-0 arg0)) + (the-as + symbol + (cond + ((or (= v1-0 (gui-channel message)) (= v1-0 (gui-channel notice)) (= v1-0 (gui-channel notice-low))) + (not (or (logtest? (-> *art-control* frame-mask) 28) (!= *master-mode* 'game))) + ) + ((= v1-0 (gui-channel query)) + (and (not (or (logtest? (-> *art-control* frame-mask) 28) (!= *master-mode* 'game))) + (and *target* (zero? (logand (-> *target* focus-status) (focus-status fs1 fs6)))) + ) + ) + (else + #t + ) + ) + ) + ) + ) + +;; definition for method 23 of type gui-control +(defmethod gui-control-method-23 gui-control ((obj gui-control) (arg0 gui-channel) (arg1 gui-channel) (arg2 symbol) (arg3 gui-connection)) + (let ((s5-0 (-> obj ids arg1))) + (cond + ((nonzero? s5-0) + (case arg2 + (('wait) + (if (nonzero? (gui-control-method-17 obj s5-0)) + (return #f) + ) + ) + (('stop 'priority-stop) + (when (nonzero? (-> obj ids arg1)) + (let ((s2-0 (gui-control-method-15 obj (the-as process #f) arg1 (the-as string #f) s5-0))) + (when (and s2-0 (or (= arg2 'priority) (= s2-0 arg3) (and arg3 (< (-> arg3 priority) (-> s2-0 priority))))) + (gui-control-method-11 obj s2-0) + (cond + ((= (shr (the-as int arg1) 4) 5) + (set! (-> obj times arg1) + (the-as time-frame (max (-> obj times arg1) (+ (-> *display* base-clock frame-counter) (seconds 0.1)))) + ) + (set! (-> s2-0 action) (gui-action hidden)) + ) + ((= arg1 (gui-channel query)) + (set! (-> s2-0 action) (gui-action play)) + ) + (else + (set! (-> s2-0 action) (gui-action hidden)) + ) + ) + ) + ) + ) + (if (nonzero? (gui-control-method-17 obj s5-0)) + (return #f) + ) + ) + (('hide) + (let ((v1-34 (gui-control-method-15 obj (the-as process #f) arg1 (the-as string #f) s5-0))) + (when (and v1-34 (!= (-> v1-34 action) 8)) + (gui-control-method-16 + obj + (gui-action hide) + s5-0 + (gui-channel none) + (gui-action none) + (the-as string #f) + (the-as (function gui-connection symbol) #f) + (the-as process #f) + ) + (set! (-> obj times arg1) + (the-as time-frame (max (-> obj times arg1) (+ (-> *display* base-clock frame-counter) (seconds 0.1)))) + ) + ) + ) + (if (nonzero? (gui-control-method-17 obj s5-0)) + (return #f) + ) + ) + ) + ) + ((< (-> *display* base-clock frame-counter) (-> obj times arg1)) + (if (= arg2 'wait) + (return #f) + ) + ) + ) + ) + #t + ) + +;; definition for method 19 of type gui-control +;; INFO: Used lq/sq +(defmethod gui-control-method-19 gui-control ((obj gui-control) (arg0 gui-channel) (arg1 gui-connection)) + (local-vars (sv-16 int) (sv-32 int) (sv-48 int)) + (let ((gp-0 #t)) + (cond + ((or (not (gui-control-method-18 obj arg0)) (< (-> *display* base-clock frame-counter) (-> obj times arg0))) + #f + ) + ((not (null? (-> obj cmd arg0))) + (let* ((s2-0 (-> obj cmd arg0)) + (v1-9 (car s2-0)) + ) + (while (not (null? s2-0)) + (let ((a2-1 (the-as gui-channel (/ (the-as int (car v1-9)) 8))) + (s1-0 (cdr v1-9)) + ) + (case a2-1 + (((gui-channel hud)) + (let ((s0-0 80)) + (set! sv-16 90) + (while (>= (the-as uint sv-16) (the-as uint s0-0)) + (if (not (gui-control-method-23 obj arg0 (the-as gui-channel s0-0) (the-as symbol s1-0) arg1)) + (set! gp-0 #f) + ) + (+! s0-0 1) + ) + ) + ) + (((gui-channel screen)) + (let ((s0-1 66)) + (set! sv-32 70) + (while (>= (the-as uint sv-32) (the-as uint s0-1)) + (if (not (gui-control-method-23 obj arg0 (the-as gui-channel s0-1) (the-as symbol s1-0) arg1)) + (set! gp-0 #f) + ) + (+! s0-1 1) + ) + ) + ) + (((gui-channel voice)) + (let ((s0-2 18)) + (set! sv-48 32) + (while (>= (the-as uint sv-48) (the-as uint s0-2)) + (if (not (gui-control-method-23 obj arg0 (the-as gui-channel s0-2) (the-as symbol s1-0) arg1)) + (set! gp-0 #f) + ) + (+! s0-2 1) + ) + ) + ) + (else + (if (not (gui-control-method-23 obj arg0 a2-1 (the-as symbol s1-0) arg1)) + (set! gp-0 #f) + ) + ) + ) + ) + (set! s2-0 (cdr s2-0)) + (set! v1-9 (car s2-0)) + ) + ) + gp-0 + ) + ) + ) + ) + +;; definition for method 17 of type gui-control +;; INFO: Return type mismatch int vs gui-action. +(defmethod gui-control-method-17 gui-control ((obj gui-control) (arg0 sound-id)) + (let ((gp-0 (the-as gui-connection #f))) + (if (zero? arg0) + (return (gui-action none)) + ) + (let ((v1-4 (-> obj engine alive-list next0))) + (-> obj engine) + (let ((a0-3 (-> v1-4 next0))) + (while (!= v1-4 (-> obj engine alive-list-end)) + (when (= arg0 (-> (the-as gui-connection v1-4) id)) + (set! gp-0 (the-as gui-connection v1-4)) + (goto cfg-15) + ) + (set! v1-4 a0-3) + (-> obj engine) + (set! a0-3 (-> a0-3 next0)) + ) + ) + ) + #t + (countdown (v1-10 32) + (let ((a0-7 (-> obj connections v1-10))) + (when (= arg0 (-> a0-7 id)) + (set! gp-0 a0-7) + (goto cfg-15) + ) + ) + ) + (label cfg-15) + (the-as + gui-action + (cond + ((= (-> gp-0 channel) (gui-channel movie)) + (cond + ((= (-> gp-0 id) (-> obj ids (-> gp-0 channel))) + 3 + ) + ((gui-control-method-19 obj (-> gp-0 channel) gp-0) + 2 + ) + (else + 1 + ) + ) + ) + ((let ((v1-22 (shr (the-as int (-> gp-0 channel)) 4))) + (or (= v1-22 1) (= v1-22 2)) + ) + (case (-> gp-0 action) + (((gui-action queue) (gui-action play) (gui-action playing) (gui-action fade) (gui-action stop)) + (cond + (gp-0 + (dotimes (s4-0 4) + (when (and (string-charp= (-> gp-0 name) (the-as (pointer uint8) (-> *sound-iop-info* stream-name s4-0))) + (or (= (-> gp-0 id) (-> *sound-iop-info* stream-id s4-0)) (zero? (-> *sound-iop-info* stream-id s4-0))) + (logtest? (-> *sound-iop-info* stream-status s4-0) (stream-status ststatus-one ststatus-six)) + (if (and (>= (the-as uint (-> gp-0 channel)) (the-as uint 16)) + (>= (the-as uint 17) (the-as uint (-> gp-0 channel))) + ) + (= (file-status *art-control* (-> gp-0 name) (the-as int (-> gp-0 anim-part))) 'active) + #t + ) + ) + (cond + ((logtest? (-> *sound-iop-info* stream-status s4-0) (stream-status ststatus-four)) + (return (gui-action playing)) + ) + ((logtest? (-> *sound-iop-info* stream-status s4-0) (stream-status ststatus-nine)) + (return (gui-action stopping)) + ) + ((or (= (-> gp-0 id) (-> obj ids (-> gp-0 channel))) (gui-control-method-19 obj (-> gp-0 channel) gp-0)) + (return (gui-action play)) + ) + (else + (return (gui-action queue)) + ) + ) + (the-as none 0) + ) + ) + 1 + ) + (else + 0 + ) + ) + ) + (else + 0 + ) + ) + ) + ((= (shr (the-as int (-> gp-0 channel)) 4) 5) + (cond + ((= (-> gp-0 id) (-> obj ids (-> gp-0 channel))) + (if (or (= (-> gp-0 action) (gui-action hide)) (= (-> gp-0 action) (gui-action hidden))) + 4 + 3 + ) + ) + ((gui-control-method-19 obj (-> gp-0 channel) gp-0) + 2 + ) + (else + 1 + ) + ) + ) + (else + (case (shr (the-as int (-> gp-0 channel)) 4) + ((4 5) + (cond + ((= (-> gp-0 id) (-> obj ids (-> gp-0 channel))) + 3 + ) + ((gui-control-method-19 obj (-> gp-0 channel) gp-0) + 2 + ) + (else + 1 + ) + ) + ) + (else + 0 + ) + ) + ) + ) + ) + ) + ) + +;; definition for method 16 of type gui-control +(defmethod gui-control-method-16 gui-control ((obj gui-control) + (arg0 gui-action) + (arg1 sound-id) + (arg2 gui-channel) + (arg3 gui-action) + (arg4 string) + (arg5 (function gui-connection symbol)) + (arg6 process) + ) + (local-vars (sv-16 gui-action) (sv-17 gui-action) (sv-20 string) (sv-24 (function gui-connection symbol))) + (set! sv-16 arg0) + (set! sv-17 arg3) + (set! sv-20 arg4) + (set! sv-24 arg5) + (let ((s1-0 (the-as gui-connection (-> obj engine alive-list next0)))) + (-> obj engine) + (let ((s0-0 (-> s1-0 next0))) + (while (!= s1-0 (-> obj engine alive-list-end)) + (when (and (or (= arg1 1) (= arg1 (-> s1-0 id))) + (or (= arg2 (gui-channel none)) (= arg2 (-> s1-0 channel))) + (or (= sv-17 (gui-action none)) (= sv-17 (-> s1-0 action))) + (or (not sv-20) (string= sv-20 (-> s1-0 name))) + (or (not arg5) (arg5 s1-0)) + (or (not arg6) (= arg6 (get-process s1-0))) + ) + (cond + ((and (= sv-16 (gui-action hide)) (!= (-> obj ids (-> s1-0 channel)) (-> s1-0 id))) + (set! (-> s1-0 action) (gui-action hidden)) + ) + ((and (= sv-16 (gui-action play)) (= (-> s1-0 action) (gui-action playing))) + ) + (else + (set! (-> s1-0 action) sv-16) + (if (and (= sv-16 'play) (gui-control-method-19 obj (-> s1-0 channel) s1-0)) + (channel-id-set! obj s1-0 (-> s1-0 id)) + ) + ) + ) + ) + (set! s1-0 (the-as gui-connection s0-0)) + (-> obj engine) + (set! s0-0 (-> s0-0 next0)) + ) + ) + ) + 0 + ) + +;; definition for method 9 of type gui-control +;; INFO: Used lq/sq +;; INFO: Return type mismatch int vs sound-id. +(defmethod gui-control-method-9 gui-control ((obj gui-control) + (arg0 process) + (arg1 gui-channel) + (arg2 gui-action) + (arg3 int) + (arg4 float) + (arg5 time-frame) + ) + (local-vars + (sv-16 int) + (sv-20 gui-connection) + (sv-32 gui-connection) + (sv-48 gui-connection) + (sv-64 gui-connection) + (sv-80 int) + ) + (set! sv-32 (the-as gui-connection #f)) + (set! sv-48 (the-as gui-connection (-> obj engine alive-list next0))) + (-> obj engine) + (set! sv-64 (the-as gui-connection (-> sv-48 next0))) + (while (!= sv-48 (-> obj engine alive-list-end)) + (when (and (= arg1 (-> (the-as gui-connection sv-48) channel)) + (string= (the-as string arg3) (-> (the-as gui-connection sv-48) name)) + (= (get-process sv-48) arg0) + ) + (set! sv-32 (the-as gui-connection sv-48)) + (goto cfg-12) + ) + (set! sv-48 (the-as gui-connection sv-64)) + (-> obj engine) + (set! sv-64 (the-as gui-connection (-> sv-64 next0))) + ) + (label cfg-12) + (when (not sv-32) + (set! sv-16 0) + (set! sv-80 32) + (while (nonzero? sv-80) + (set! sv-80 (+ sv-80 -1)) + (set! sv-20 (-> obj connections sv-80)) + (if (and (nonzero? (-> sv-20 id)) + (= arg1 (-> sv-20 channel)) + (string= (the-as string arg3) (-> sv-20 name)) + (>= (-> sv-20 priority) -1.0) + ) + (set! sv-16 (the-as int (-> sv-20 id))) + ) + ) + (if (zero? sv-16) + (set! sv-16 (the-as int (new-sound-id))) + ) + (set! sv-32 (the-as gui-connection (add-connection (-> obj engine) arg0 arg4 0 arg3 sv-16))) + sv-32 + ) + (the-as sound-id (cond + (sv-32 + (set! (-> sv-32 priority) arg4) + (set! (-> sv-32 channel) arg1) + (set! (-> sv-32 action) arg2) + (set! (-> sv-32 param2) arg3) + (set! (-> sv-32 hold-time) arg5) + (set! (-> sv-32 flags) (the-as uint 1)) + (set! (-> sv-32 fade) (the-as uint 0)) + (the-as int (-> (the-as gui-connection sv-32) id)) + ) + (else + (format 0 "ERROR: could not connection ~A to gui engine.~%" arg0) + 0 + ) + ) + ) + ) + +;; definition for method 10 of type gui-control +;; INFO: Return type mismatch int vs none. +(defmethod gui-control-method-10 gui-control ((obj gui-control) (arg0 process) (arg1 gui-channel)) + (let ((s3-0 (the-as gui-connection (-> obj engine alive-list next0)))) + (-> obj engine) + (let ((s2-0 (-> s3-0 next0))) + (while (!= s3-0 (-> obj engine alive-list-end)) + (if (and (= arg1 (-> s3-0 channel)) (= arg0 (get-process s3-0))) + (move-to-dead s3-0) + ) + (set! s3-0 (the-as gui-connection s2-0)) + (-> obj engine) + (set! s2-0 (-> s2-0 next0)) + ) + ) + ) + 0 + (none) + ) + +;; definition for method 12 of type gui-control +;; INFO: Used lq/sq +;; INFO: Return type mismatch int vs sound-id. +(defmethod gui-control-method-12 gui-control ((obj gui-control) + (arg0 process) + (arg1 gui-channel) + (arg2 gui-action) + (arg3 string) + (arg4 int) + (arg5 float) + (arg6 sound-id) + ) + (local-vars + (sv-16 gui-connection) + (sv-20 int) + (sv-24 gui-connection) + (sv-28 process-drawable) + (sv-32 int) + (sv-48 sound-id) + ) + (set! sv-48 arg6) + (set! sv-16 (the-as gui-connection #f)) + (set! sv-20 0) + (set! sv-32 32) + (while (nonzero? sv-32) + (set! sv-32 (+ sv-32 -1)) + (set! sv-24 (-> obj connections sv-32)) + (when (and (nonzero? (-> sv-24 id)) + (= arg1 (-> sv-24 channel)) + (let ((v1-14 (handle->process (-> sv-24 handle)))) + (and (or (= v1-14 arg0) (= (-> arg0 type) scene-player) (and v1-14 (= (-> v1-14 type) scene-player))) + (and (string= arg3 (-> sv-24 name)) (= arg4 (-> sv-24 anim-part))) + ) + ) + ) + (when (< (-> sv-24 priority) arg5) + (set! (-> sv-24 time-stamp) (-> obj update-time)) + (return (the-as sound-id (-> sv-24 id))) + ) + (set! sv-16 sv-24) + (goto cfg-44) + ) + ) + (countdown (v1-33 32) + (let ((a0-15 (-> obj connections v1-33))) + (when (or (zero? (-> a0-15 id)) (not (handle->process (-> a0-15 handle)))) + (set! sv-16 a0-15) + (set! (-> sv-16 param3) 0) + (set! (-> sv-16 flags) (the-as uint 0)) + (goto cfg-44) + ) + ) + ) + (label cfg-44) + (the-as sound-id (cond + (sv-16 + (when (zero? (-> (the-as gui-connection sv-16) id)) + (when (zero? sv-20) + (let ((v1-46 (gui-control-method-15 obj arg0 arg1 arg3 (new 'static 'sound-id)))) + (if v1-46 + (set! sv-20 (the-as int (-> v1-46 id))) + ) + ) + ) + (if (zero? sv-20) + (set! sv-20 (the-as int sv-48)) + ) + (set! (-> sv-16 param3) (if (nonzero? sv-20) + sv-20 + (the-as int (new-sound-id)) + ) + ) + ) + (when (= arg5 -99.0) + (let ((s2-1 arg0)) + (set! sv-28 (if (type? s2-1 process-drawable) + (the-as process-drawable s2-1) + ) + ) + ) + (set! arg5 (if sv-28 + (vector-vector-distance (target-pos 0) (-> sv-28 root trans)) + -1.0 + ) + ) + ) + (set! (-> sv-16 time-stamp) (-> obj update-time)) + (set! (-> sv-16 handle) (process->handle arg0)) + (set! (-> sv-16 priority) arg5) + (set! (-> sv-16 channel) arg1) + (set! (-> sv-16 action) arg2) + (set! (-> sv-16 anim-part) (the-as uint arg4)) + (set! (-> sv-16 param2) (the-as int arg3)) + (set! (-> sv-16 fade) (the-as uint 0)) + (the-as int (-> (the-as gui-connection sv-16) id)) + ) + (else + 0 + ) + ) + ) + ) + +;; definition for method 21 of type gui-control +(defmethod gui-control-method-21 gui-control ((obj gui-control) (arg0 gui-connection) (arg1 vector)) + (case (shr (the-as int (-> arg0 channel)) 4) + ((1 2) + (let ((s5-0 (-> obj spool-connections))) + (case (-> arg0 action) + (((gui-action queue) (gui-action play) (gui-action playing) (gui-action fade)) + (let ((f30-0 (-> arg0 priority))) + (when (= f30-0 -99.0) + (let* ((s2-0 (get-process arg0)) + (v1-10 (if (type? s2-0 process-drawable) + (the-as process-drawable s2-0) + ) + ) + ) + (set! f30-0 (cond + ((= (-> arg0 id) (-> obj ids (-> arg0 channel))) + -1.0 + ) + (v1-10 + (vector-vector-distance arg1 (-> v1-10 root trans)) + ) + (else + -1.0 + ) + ) + ) + ) + ) + (dotimes (s4-1 4) + (cond + ((>= (-> s5-0 s4-1 priority) f30-0) + (let ((s3-1 s4-1)) + (while (< s3-1 4) + (when (= (-> s5-0 s3-1 id) (-> arg0 id)) + (let ((s2-1 s3-1)) + (while (< s2-1 3) + (mem-copy! (the-as pointer (-> s5-0 s2-1)) (the-as pointer (-> s5-0 (+ s2-1 1))) 48) + (+! s2-1 1) + ) + ) + (set! (-> s5-0 3 param2) (the-as int "")) + (set! (-> s5-0 3 priority) 100000000.0) + ) + (+! s3-1 1) + ) + ) + (let ((s3-2 3)) + (while (!= s3-2 s4-1) + (mem-copy! (the-as pointer (-> s5-0 s3-2)) (the-as pointer (-> s5-0 (+ s3-2 -1))) 48) + (+! s3-2 -1) + ) + ) + (mem-copy! (the-as pointer (-> s5-0 s4-1)) (the-as pointer arg0) 48) + (set! (-> s5-0 s4-1 priority) f30-0) + (goto cfg-42) + ) + ((= (-> s5-0 s4-1 id) (-> arg0 id)) + (goto cfg-42) + ) + ) + ) + ) + ) + ) + ) + ) + ) + (label cfg-42) + 0 + ) + +;; definition for method 11 of type gui-control +(defmethod gui-control-method-11 gui-control ((obj gui-control) (arg0 gui-connection)) + (case (shr (the-as int (-> arg0 channel)) 4) + ((1 2) + (if (= (gui-control-method-17 obj (-> arg0 id)) (gui-action playing)) + (str-play-stop (-> arg0 name) (-> arg0 id)) + ) + ) + ) + (if (= (-> obj ids (-> arg0 channel)) (-> arg0 id)) + (channel-id-set! obj arg0 (new 'static 'sound-id)) + ) + 0 + ) + +;; definition for method 22 of type gui-control +;; ERROR: function was not converted to expressions. Cannot decompile. + +;; definition for method 13 of type gui-control +(defmethod update gui-control ((obj gui-control) (arg0 symbol)) + (set! (-> obj ids 65) + (the-as sound-id (if (and (>= (-> *display* base-clock frame-counter) (-> *game-info* blackout-time)) + (= (-> *setting-control* user-current bg-a) 0.0) + (= (-> *setting-control* user-current bg-a-force) 0.0) + ) + 0 + 1 + ) + ) + ) + (let ((s4-0 (target-pos 0))) + (dotimes (v1-8 4) + (set! (-> obj spool-connections v1-8 param2) (the-as int #f)) + (set! (-> obj spool-connections v1-8 param3) 0) + (set! (-> obj spool-connections v1-8 priority) 100000000.0) + ) + (let ((s3-0 (the-as gui-connection (-> obj engine alive-list next0)))) + (-> obj engine) + (let ((s2-0 (-> s3-0 next0))) + (while (!= s3-0 (-> obj engine alive-list-end)) + (gui-control-method-21 obj s3-0 s4-0) + (case (-> s3-0 action) + (((gui-action playing)) + (channel-id-set! obj s3-0 (-> s3-0 id)) + ) + ) + (set! s3-0 (the-as gui-connection s2-0)) + (-> obj engine) + (set! s2-0 (-> s2-0 next0)) + ) + ) + ) + (let ((s3-1 (-> obj update-time))) + (countdown (s2-1 32) + (let ((s1-0 (-> obj connections s2-1))) + (when (nonzero? (-> s1-0 id)) + (cond + ((= (-> s1-0 time-stamp) s3-1) + (gui-control-method-21 obj s1-0 s4-0) + ) + (else + (if (= (-> obj ids (-> s1-0 channel)) (-> s1-0 id)) + (channel-id-set! obj s1-0 (new 'static 'sound-id)) + ) + (set! (-> s1-0 param3) 0) + 0 + ) + ) + ) + ) + ) + ) + ) + (let ((s4-1 (new 'stack-no-clear 'array 'sound-id 4)) + (s3-2 0) + ) + (let ((s2-2 (-> *setting-control* user-current movie-name))) + (dotimes (s1-1 4) + (set! (-> s4-1 s1-1) (-> obj spool-connections s1-1 id)) + (when (and (-> obj spool-connections s1-1 name) (case (-> obj spool-connections s1-1 channel) + (((gui-channel art-load) (gui-channel art-load-next)) + #t + ) + ) + ) + (set! s3-2 (logior s3-2 (ash 1 s1-1))) + (if (and s2-2 (string= (-> obj spool-connections s1-1 name) (the-as string s2-2))) + (set! s3-2 (logior s3-2 (ash 1 (+ s1-1 4)))) + ) + ) + ) + ) + (let* ((t9-6 str-play-queue) + (v1-69 (-> obj spool-connections 0 name)) + (a0-32 (if v1-69 + v1-69 + ) + ) + (v1-70 (-> obj spool-connections 1 name)) + (a1-7 (if v1-70 + v1-70 + ) + ) + (v1-71 (-> obj spool-connections 2 name)) + (a2-4 (if v1-71 + v1-71 + ) + ) + (v1-72 (-> obj spool-connections 3 name)) + ) + (t9-6 + a0-32 + a1-7 + a2-4 + (if v1-72 + v1-72 + ) + s4-1 + (the-as pointer s3-2) + ) + ) + ) + (-> obj engine) + (let ((a0-33 (the-as connection (-> obj engine alive-list-end prev0)))) + (-> obj engine) + (let ((s4-2 (-> a0-33 prev0))) + (while (!= a0-33 (-> obj engine alive-list)) + (gui-control-method-22 obj (the-as gui-connection a0-33) (get-process a0-33) #t) + (set! a0-33 (the-as connection s4-2)) + (-> obj engine) + (set! s4-2 (-> s4-2 prev0)) + ) + ) + ) + (countdown (s4-3 32) + (let ((v1-91 (-> obj connections s4-3))) + (if (nonzero? (-> v1-91 id)) + (gui-control-method-22 obj v1-91 (handle->process (-> v1-91 handle)) #f) + ) + ) + ) + (when arg0 + (when *display-art-control* + (dotimes (s5-1 4) + (let ((a3-4 (-> obj spool-connections s5-1))) + (if (-> a3-4 name) + (format *stdcon* "~D: ~`gui-connection`P~%" s5-1 a3-4) + ) + ) + ) + (dotimes (s5-2 4) + (format + *stdcon* + "~0KCh ~D: ~8D ~5X ~6D ~G~1K~%" + s5-2 + (-> *sound-iop-info* stream-id-int32 s5-2) + (-> *sound-iop-info* stream-status s5-2) + (-> *sound-iop-info* stream-position s5-2) + (-> *sound-iop-info* stream-name s5-2) + ) + ) + ) + (when *display-gui-control* + (-> obj engine) + (let ((a2-12 (-> obj engine alive-list-end prev0))) + (-> obj engine) + (let ((s5-3 (-> a2-12 prev0))) + (while (!= a2-12 (-> obj engine alive-list)) + (format *stdcon* "c: ~`gui-connection`P~%" a2-12) + (set! a2-12 s5-3) + (-> obj engine) + (set! s5-3 (-> s5-3 prev0)) + ) + ) + ) + (countdown (s5-4 32) + (let ((a2-13 (-> obj connections s5-4))) + (if (nonzero? (-> a2-13 id)) + (format *stdcon* "l: ~`gui-connection`P~%" a2-13) + ) + ) + ) + ) + ) + (set! (-> obj update-time) (-> *display* base-clock frame-counter)) + 0 + ) + +;; definition for method 0 of type gui-control +(defmethod new gui-control ((allocation symbol) (type-to-make type) (arg0 int)) + (let ((gp-0 (object-new allocation type-to-make (the-as int (-> type-to-make size))))) + (set! (-> gp-0 engine) ((method-of-type engine new) allocation engine 'gui-control arg0 gui-connection)) + (dotimes (v1-3 32) + (set! (-> gp-0 connections v1-3 handle) (the-as handle #f)) + ) + (dotimes (v1-6 96) + (set! (-> gp-0 cmd v1-6) '()) + ) + (set! (-> gp-0 cmd 64) '((64 . wait) (65 . wait) (66 . stop) (95 . stop))) + (set! (-> gp-0 cmd 66) + '((64 . wait) + (65 . wait) + (68 . wait) + (71 . wait) + (67 . wait) + (66 . wait) + (69 . wait) + (83 . hide) + (84 . hide) + (85 . hide) + ) + ) + (set! (-> gp-0 cmd 67) + '((64 . wait) + (65 . wait) + (68 . wait) + (71 . wait) + (67 . wait) + (66 . wait) + (69 . wait) + (83 . hide) + (84 . hide) + (85 . hide) + (82 . hide) + ) + ) + (set! (-> gp-0 cmd 68) + '((65 . wait) (68 . wait) (67 . wait) (66 . wait) (69 . wait) (83 . hide) (84 . hide) (85 . hide) (82 . hide)) + ) + (set! (-> gp-0 cmd 71) + '((65 . wait) (71 . wait) (67 . wait) (66 . wait) (69 . wait) (83 . hide) (84 . hide) (85 . hide) (82 . hide)) + ) + (set! (-> gp-0 cmd 69) '((65 . wait) (71 . wait) (67 . wait) (66 . wait))) + (set! (-> gp-0 cmd 70) '((65 . wait) (90 . hide) (91 . hide) (81 . hide) (80 . hide))) + (set! (-> gp-0 cmd 80) '((64 . wait) (65 . wait) (80 . wait) (70 . wait))) + (set! (-> gp-0 cmd 81) '((64 . wait) (65 . wait) (81 . wait) (70 . wait))) + (set! (-> gp-0 cmd 82) '((64 . wait) (65 . wait) (67 . wait) (71 . wait) (69 . wait) (82 . wait))) + (set! (-> gp-0 cmd 83) + '((64 . wait) (65 . wait) (67 . wait) (71 . wait) (69 . wait) (66 . wait) (83 . wait) (84 . hide) (85 . hide)) + ) + (set! (-> gp-0 cmd 84) + '((64 . wait) (65 . wait) (67 . wait) (71 . wait) (69 . wait) (66 . wait) (83 . wait) (84 . wait)) + ) + (set! (-> gp-0 cmd 85) + '((64 . wait) (65 . wait) (67 . wait) (71 . wait) (69 . wait) (66 . wait) (83 . wait) (85 . wait)) + ) + (set! (-> gp-0 cmd 86) '((64 . wait) (65 . wait) (86 . wait))) + (set! (-> gp-0 cmd 87) '((64 . wait) (65 . wait) (87 . wait))) + (set! (-> gp-0 cmd 88) '((64 . wait) (65 . wait) (88 . wait))) + (set! (-> gp-0 cmd 89) '((64 . wait) (65 . wait) (89 . wait))) + (set! (-> gp-0 cmd 90) '((64 . wait) (65 . wait) (90 . wait) (70 . wait))) + (set! (-> gp-0 cmd 91) '((64 . wait) (65 . wait) (91 . wait) (70 . wait))) + (set! (-> gp-0 cmd 16) '((16 . wait))) + (set! (-> gp-0 cmd 17) '((17 . wait))) + (set! (-> gp-0 cmd 18) '((18 . wait))) + (set! (-> gp-0 cmd 32) '((64 . wait) (32 . wait))) + (set! (-> gp-0 cmd 30) '((64 . wait) (30 . wait))) + (set! (-> gp-0 cmd 33) '((64 . wait) (33 . wait))) + (set! (-> gp-0 cmd 34) '((64 . wait) (34 . wait))) + (set! (-> gp-0 cmd 20) '((64 . wait) (20 . wait) (19 . wait) (29 . wait))) + (set! (-> gp-0 cmd 19) '((64 . wait) (20 . wait) (19 . wait) (29 . wait))) + (set! (-> gp-0 cmd 29) '((64 . wait) (20 . wait) (19 . wait) (29 . wait))) + (set! (-> gp-0 cmd 21) '((64 . wait) + (21 . wait) + (22 . wait) + (23 . wait) + (24 . wait) + (25 . wait) + (27 . wait) + (26 . wait) + (28 . wait) + (31 . wait) + (35 . wait) + ) + ) + (set! (-> gp-0 cmd 22) '((64 . wait) + (21 . wait) + (22 . wait) + (23 . wait) + (24 . wait) + (25 . wait) + (27 . wait) + (26 . wait) + (28 . wait) + (31 . wait) + (35 . wait) + ) + ) + (set! (-> gp-0 cmd 23) '((64 . wait) + (21 . wait) + (22 . wait) + (23 . wait) + (24 . wait) + (25 . wait) + (27 . wait) + (26 . wait) + (28 . wait) + (31 . wait) + (35 . wait) + ) + ) + (set! (-> gp-0 cmd 24) '((64 . wait) + (21 . wait) + (22 . wait) + (23 . wait) + (24 . wait) + (25 . wait) + (27 . wait) + (26 . wait) + (28 . wait) + (31 . wait) + (35 . wait) + ) + ) + (set! (-> gp-0 cmd 25) '((64 . wait) + (21 . wait) + (22 . wait) + (23 . wait) + (24 . wait) + (25 . wait) + (27 . wait) + (26 . wait) + (28 . wait) + (31 . wait) + (35 . wait) + ) + ) + (set! (-> gp-0 cmd 27) '((64 . wait) + (21 . wait) + (22 . wait) + (23 . wait) + (24 . wait) + (25 . wait) + (27 . wait) + (26 . wait) + (28 . wait) + (31 . wait) + (35 . wait) + ) + ) + (set! (-> gp-0 cmd 26) '((64 . wait) + (21 . wait) + (22 . wait) + (23 . wait) + (24 . wait) + (25 . wait) + (27 . wait) + (26 . wait) + (28 . wait) + (31 . wait) + (35 . wait) + ) + ) + (set! (-> gp-0 cmd 28) '((64 . wait) + (21 . wait) + (22 . wait) + (23 . wait) + (24 . wait) + (25 . wait) + (27 . wait) + (26 . wait) + (28 . wait) + (31 . wait) + (35 . wait) + ) + ) + (set! (-> gp-0 cmd 31) '((64 . wait) + (21 . wait) + (22 . wait) + (23 . wait) + (24 . wait) + (25 . wait) + (27 . wait) + (26 . wait) + (28 . wait) + (31 . wait) + (35 . wait) + ) + ) + (set! (-> gp-0 cmd 35) '((64 . wait) + (21 . wait) + (22 . wait) + (23 . wait) + (24 . wait) + (25 . wait) + (27 . wait) + (26 . wait) + (28 . wait) + (31 . wait) + (35 . wait) + ) + ) + gp-0 + ) + ) + +;; failed to figure out what this is: +(kmemopen global "gui-controls") + +;; definition for symbol *gui-control*, type gui-control +(define *gui-control* (new 'global 'gui-control 64)) + +;; failed to figure out what this is: +(if (zero? *art-control*) + (set! *art-control* (new 'global 'external-art-control)) + ) + +;; failed to figure out what this is: +(kmemclose) diff --git a/test/decompiler/reference/jak2/engine/physics/chain-physics-h_REF.gc b/test/decompiler/reference/jak2/engine/physics/chain-physics-h_REF.gc index 93987961fd..5f7ca6eba4 100644 --- a/test/decompiler/reference/jak2/engine/physics/chain-physics-h_REF.gc +++ b/test/decompiler/reference/jak2/engine/physics/chain-physics-h_REF.gc @@ -24,10 +24,10 @@ ;; definition of type chain-physics-joint (deftype chain-physics-joint (structure) - ((position vector :inline :offset-assert 0) - (velocity vector :inline :offset-assert 16) - (old-x vector :inline :offset-assert 32) - (joint-mod basic :offset-assert 48) + ((position vector :inline :offset-assert 0) + (velocity vector :inline :offset-assert 16) + (old-x vector :inline :offset-assert 32) + (joint-mod joint-mod :offset-assert 48) ) :method-count-assert 9 :size-assert #x34 @@ -64,22 +64,22 @@ (negate-y basic :offset-assert 1360) (axial-slop float :offset-assert 1364) (maximum-stretch float :offset-assert 1368) - (turn-off-start uint64 :offset-assert 1376) - (turn-off-duration uint64 :offset-assert 1384) + (turn-off-start time-frame :offset-assert 1376) + (turn-off-duration time-frame :offset-assert 1384) ) :method-count-assert 18 :size-assert #x570 :flag-assert #x1200000570 (:methods - (chain-physics-method-9 () none 9) - (chain-physics-method-10 () none 10) - (chain-physics-method-11 () none 11) - (chain-physics-method-12 () none 12) - (chain-physics-method-13 () none 13) - (chain-physics-method-14 () none 14) - (chain-physics-method-15 () none 15) - (chain-physics-method-16 () none 16) - (chain-physics-method-17 () none 17) + (initialize-chain-joints (_type_) symbol 9) + (turn-off (_type_ time-frame) none :behavior process 10) + (update (_type_ process-drawable) none :behavior process 11) + (gravity-update (_type_) none 12) + (apply-gravity (_type_ vector int) none :behavior process 13) + (chain-physics-method-14 (_type_ vector int) none 14) + (clamp-length (_type_ vector vector) vector 15) + (chain-physics-method-16 (_type_ int) float 16) + (chain-physics-method-17 (_type_ vector) none 17) ) ) @@ -111,7 +111,3 @@ ;; failed to figure out what this is: 0 - - - - diff --git a/test/decompiler/reference/jak2/engine/physics/chain-physics_REF.gc b/test/decompiler/reference/jak2/engine/physics/chain-physics_REF.gc new file mode 100644 index 0000000000..441c0cebe4 --- /dev/null +++ b/test/decompiler/reference/jak2/engine/physics/chain-physics_REF.gc @@ -0,0 +1,409 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition for method 12 of type chain-physics +;; INFO: Return type mismatch int vs none. +(defmethod gravity-update chain-physics ((obj chain-physics)) + (vector-seek-3d-smooth! (-> obj gravity) (-> obj gravity-target) 0.05 0.1) + 0 + (none) + ) + +;; definition for method 13 of type chain-physics +;; INFO: Return type mismatch int vs none. +(defmethod apply-gravity chain-physics ((obj chain-physics) (arg0 vector) (arg1 int)) + (vector-float*! + arg0 + (-> obj gravity) + (* 4096.0 (-> self clock time-adjust-ratio) (fmax 0.2 (lerp-scale 0.38 0.18 (the float arg1) 0.0 5.0))) + ) + 0 + (none) + ) + +;; definition for method 14 of type chain-physics +;; INFO: Return type mismatch int vs none. +(defmethod chain-physics-method-14 chain-physics ((obj chain-physics) (arg0 vector) (arg1 int)) + (vector-float*! + arg0 + (the-as vector (+ (the-as uint (-> obj chain-joints 0 velocity)) (* (+ arg1 1) 64))) + (fmin 0.9 (lerp-scale 0.2 1.0 (the float arg1) 0.0 4.0)) + ) + 0 + (none) + ) + +;; definition for method 15 of type chain-physics +(defmethod clamp-length chain-physics ((obj chain-physics) (arg0 vector) (arg1 vector)) + (let ((gp-0 (new 'stack-no-clear 'vector))) + (vector-! gp-0 arg0 arg1) + (vector-normalize! gp-0 (-> obj joint-length)) + (vector+! arg0 gp-0 arg1) + ) + ) + +;; definition for method 16 of type chain-physics +(defmethod chain-physics-method-16 chain-physics ((obj chain-physics) (arg0 int)) + (lerp-scale 5461.3335 10922.667 (the float arg0) 0.0 8.0) + ) + +;; definition for method 17 of type chain-physics +;; INFO: Return type mismatch int vs none. +(defmethod chain-physics-method-17 chain-physics ((obj chain-physics) (arg0 vector)) + 0 + (none) + ) + +;; definition for method 9 of type chain-physics +(defmethod initialize-chain-joints chain-physics ((obj chain-physics)) + (set! (-> obj turn-off-start) 0) + (dotimes (s5-0 (the-as int (-> obj num-joints))) + (let ((s4-0 (-> obj chain-joints s5-0))) + (vector<-cspace! (-> s4-0 position) (-> s4-0 joint-mod joint)) + (vector-reset! (-> s4-0 velocity)) + (mode-set! (-> s4-0 joint-mod) (joint-mod-mode joint-set-world)) + ) + ) + #f + ) + +;; definition for method 10 of type chain-physics +;; INFO: Return type mismatch int vs none. +(defmethod turn-off chain-physics ((obj chain-physics) (arg0 time-frame)) + (set! (-> obj turn-off-start) (-> self clock frame-counter)) + (set! (-> obj turn-off-duration) arg0) + 0 + (none) + ) + +;; definition for method 11 of type chain-physics +;; INFO: Used lq/sq +;; INFO: Return type mismatch int vs none. +(defmethod update chain-physics ((obj chain-physics) (arg0 process-drawable)) + (local-vars + (v1-77 float) + (f0-11 float) + (sv-272 chain-physics-joint) + (sv-288 vector) + (sv-304 vector) + (sv-320 (function vector float vector)) + (sv-336 vector) + (sv-352 vector) + (sv-368 vector) + (sv-384 vector) + (sv-400 vector) + (sv-416 vector) + (sv-432 vector) + (sv-448 (inline-array vector)) + (sv-464 (inline-array vector)) + (sv-480 (inline-array vector)) + (sv-496 vector) + (sv-512 (inline-array vector)) + (sv-528 vector) + ) + (rlet ((acc :class vf) + (vf0 :class vf) + (vf1 :class vf) + (vf2 :class vf) + (vf3 :class vf) + (vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + ) + (init-vf0-vector) + (gravity-update obj) + (let ((s4-0 (new 'stack-no-clear 'matrix)) + (s3-0 (vector<-cspace! (new 'stack-no-clear 'vector) (-> arg0 node-list data (-> obj root-joint-index)))) + (s2-0 (vector-normalize-copy! + (new 'stack-no-clear 'vector) + (-> arg0 node-list data (-> obj root-joint-index) bone transform vector 2) + 1.0 + ) + ) + (s1-0 (vector-normalize-copy! + (new 'stack-no-clear 'vector) + (-> arg0 node-list data (-> obj root-joint-index) bone transform vector 1) + 1.0 + ) + ) + ) + (new 'stack-no-clear 'vector) + (let ((f30-0 1.0)) + (if (nonzero? (-> obj turn-off-start)) + (set! f30-0 + (fmax + 0.0 + (fmin + 1.0 + (parameter-ease-sin-clamp (- 1.0 (/ (the float (- (-> self clock frame-counter) (-> obj turn-off-start))) + (the float (-> obj turn-off-duration)) + ) + ) + ) + ) + ) + ) + ) + (dotimes (s0-0 (the-as int (-> obj num-joints))) + (set! sv-272 (-> obj chain-joints s0-0)) + (set! sv-528 (new 'stack-no-clear 'vector)) + (let ((v1-27 (-> sv-272 position quad))) + (set! (-> sv-528 quad) v1-27) + ) + (set! (-> sv-272 joint-mod flex-blend) f30-0) + (if (-> obj negate-y) + (vector-negate! s1-0 s1-0) + ) + (set! sv-288 (new 'stack-no-clear 'vector)) + (apply-gravity obj sv-288 s0-0) + (let ((v1-34 sv-528)) + (let ((a0-10 sv-528)) + (.mov.vf vf6 vf0 :mask #b1000) + (.lvf vf4 (&-> a0-10 quad)) + ) + (.lvf vf5 (&-> sv-288 quad)) + (.add.vf vf6 vf4 vf5 :mask #b111) + (.svf (&-> v1-34 quad) vf6) + ) + (when (< s0-0 (the-as int (+ (-> obj root-joint-index) -1))) + (set! sv-304 (new 'stack-no-clear 'vector)) + (chain-physics-method-14 obj sv-304 s0-0) + (let ((v1-40 sv-528)) + (let ((a0-13 sv-528)) + (.mov.vf vf6 vf0 :mask #b1000) + (.lvf vf4 (&-> a0-13 quad)) + ) + (.lvf vf5 (&-> sv-304 quad)) + (.add.vf vf6 vf4 vf5 :mask #b111) + (.svf (&-> v1-40 quad) vf6) + ) + ) + (clamp-length obj sv-528 s3-0) + (set! sv-400 (new 'stack-no-clear 'vector)) + (let ((v1-43 sv-528) + (a0-16 s3-0) + ) + (.lvf vf4 (&-> v1-43 quad)) + (.lvf vf5 (&-> a0-16 quad)) + ) + (.mov.vf vf6 vf0 :mask #b1000) + (.sub.vf vf6 vf4 vf5 :mask #b111) + (.svf (&-> sv-400 quad) vf6) + (let ((f28-1 (vector-normalize-ret-len! sv-400 1.0)) + (f24-0 (vector-dot sv-400 s1-0)) + (f26-0 (chain-physics-method-16 obj s0-0)) + ) + (when (< f24-0 (cos f26-0)) + (vector--float*! sv-400 sv-400 s1-0 f24-0) + (set! sv-320 vector-normalize!) + (set! sv-336 sv-400) + (let ((a1-17 (sin f26-0))) + (sv-320 sv-336 a1-17) + ) + (set! sv-384 sv-400) + (set! sv-352 sv-400) + (set! sv-368 s1-0) + (let ((f0-6 (cos f26-0))) + (.lvf vf2 (&-> sv-368 quad)) + (.lvf vf1 (&-> sv-352 quad)) + (let ((v1-55 f0-6)) + (.mov vf3 v1-55) + ) + ) + (.add.x.vf vf4 vf0 vf0 :mask #b1000) + (.mul.x.vf acc vf2 vf3) + (.add.mul.w.vf vf4 vf1 vf0 acc :mask #b111) + (.svf (&-> sv-384 quad) vf4) + (let ((v1-57 sv-528)) + (let ((a0-25 s3-0)) + (.lvf vf2 (&-> sv-400 quad)) + (.lvf vf1 (&-> a0-25 quad)) + ) + (let ((a0-26 f28-1)) + (.mov vf3 a0-26) + ) + (.add.x.vf vf4 vf0 vf0 :mask #b1000) + (.mul.x.vf acc vf2 vf3) + (.add.mul.w.vf vf4 vf1 vf0 acc :mask #b111) + (.svf (&-> v1-57 quad) vf4) + ) + ) + ) + (chain-physics-method-17 obj sv-528) + (set! sv-432 (new 'stack-no-clear 'vector)) + (let ((v1-60 s3-0) + (a0-28 sv-528) + ) + (.lvf vf4 (&-> v1-60 quad)) + (.lvf vf5 (&-> a0-28 quad)) + ) + (.mov.vf vf6 vf0 :mask #b1000) + (.sub.vf vf6 vf4 vf5 :mask #b111) + (.svf (&-> sv-432 quad) vf6) + (vector-normalize-ret-len! sv-432 1.0) + (set! sv-416 (new 'stack-no-clear 'vector)) + (let ((v1-63 sv-528) + (a0-31 (-> sv-272 position)) + ) + (.lvf vf4 (&-> v1-63 quad)) + (.lvf vf5 (&-> a0-31 quad)) + ) + (.mov.vf vf6 vf0 :mask #b1000) + (.sub.vf vf6 vf4 vf5 :mask #b111) + (.svf (&-> sv-416 quad) vf6) + (let ((f28-2 (vector-dot sv-432 sv-416))) + (vector--float*! sv-416 sv-416 sv-432 f28-2) + (cond + ((< f28-2 0.0) + (set! f0-11 (* f28-2 (-> obj compress-vel-parallel))) + (vector-float*! sv-416 sv-416 (-> obj compress-vel)) + ) + (else + (set! f0-11 (* f28-2 (-> obj stretch-vel-parallel))) + (vector-float*! sv-416 sv-416 (-> obj stretch-vel)) + ) + ) + ) + (let ((v1-72 (-> sv-272 velocity))) + (.lvf vf2 (&-> sv-432 quad)) + (.lvf vf1 (&-> sv-416 quad)) + (let ((a0-38 f0-11)) + (.mov vf3 a0-38) + ) + (.add.x.vf vf4 vf0 vf0 :mask #b1000) + (.mul.x.vf acc vf2 vf3) + (.add.mul.w.vf vf4 vf1 vf0 acc :mask #b111) + (.svf (&-> v1-72 quad) vf4) + ) + (vector+! sv-528 (-> sv-272 position) (-> sv-272 velocity)) + (let ((a2-9 (vector-! (new 'stack-no-clear 'vector) s3-0 sv-528))) + (.lvf vf1 (&-> a2-9 quad)) + (.add.w.vf vf2 vf0 vf0 :mask #b1) + (.mul.vf vf1 vf1 vf1) + (.mul.x.vf acc vf2 vf1 :mask #b1) + (.add.mul.y.vf acc vf2 vf1 acc :mask #b1) + (.add.mul.z.vf vf1 vf2 vf1 acc :mask #b1) + (.mov v1-77 vf1) + (let* ((f0-13 v1-77) + (f1-6 (* (-> obj maximum-stretch) (-> obj joint-length))) + (f2-3 f1-6) + ) + (if (< (* f2-3 f2-3) f0-13) + (vector--float*! sv-528 s3-0 a2-9 (/ f1-6 (sqrtf f0-13))) + ) + ) + ) + (set! (-> sv-272 position quad) (-> sv-528 quad)) + (if (-> sv-272 joint-mod) + (set! (-> sv-272 joint-mod trans quad) (-> sv-528 quad)) + ) + (when (< s0-0 (the-as int (-> obj num-joints))) + (vector-! (-> s4-0 vector 1) sv-528 s3-0) + (vector-normalize! (-> s4-0 vector 1) 1.0) + (if (-> obj negate-y) + (vector-negate! (-> s4-0 vector 1) (-> s4-0 vector 1)) + ) + (vector-cross! (the-as vector (-> s4-0 vector)) (-> s4-0 vector 1) s2-0) + (vector-normalize! (the-as vector (-> s4-0 vector)) 1.0) + (set! sv-496 (new 'stack-no-clear 'vector)) + (let ((v1-96 (-> sv-272 old-x)) + (a0-52 (-> s4-0 vector)) + ) + (.lvf vf1 (&-> v1-96 quad)) + (.lvf vf2 (&-> a0-52 0 quad)) + ) + (.outer.product.a.vf acc vf1 vf2) + (.outer.product.b.vf vf3 vf2 vf1 acc) + (.svf (&-> sv-496 quad) vf3) + (vector-flatten! sv-496 (-> sv-272 old-x) (-> s4-0 vector 1)) + (vector-normalize! sv-496 1.0) + (cond + ((< (vector-dot (the-as vector (-> s4-0 vector)) sv-496) (cos (-> obj axial-slop))) + (vector-cross! sv-496 sv-496 (the-as vector (-> s4-0 vector))) + (vector-cross! sv-496 (the-as vector (-> s4-0 vector)) sv-496) + (vector-normalize! sv-496 1.0) + (set! sv-464 (-> s4-0 vector)) + (set! sv-448 (-> s4-0 vector)) + (let ((f0-20 (cos (-> obj axial-slop)))) + (.lvf vf1 (&-> sv-448 0 quad)) + (let ((v1-106 f0-20)) + (.mov vf2 v1-106) + ) + ) + (.add.x.vf vf1 vf0 vf0 :mask #b1000) + (.mul.x.vf vf1 vf1 vf2 :mask #b111) + (.svf (&-> sv-464 0 quad) vf1) + (set! sv-512 (-> s4-0 vector)) + (set! sv-480 (-> s4-0 vector)) + (let ((f0-22 (sin (-> obj axial-slop)))) + (.lvf vf2 (&-> sv-496 quad)) + (.lvf vf1 (&-> sv-480 0 quad)) + (let ((v1-112 f0-22)) + (.mov vf3 v1-112) + ) + ) + (.add.x.vf vf4 vf0 vf0 :mask #b1000) + (.mul.x.vf acc vf2 vf3) + (.add.mul.w.vf vf4 vf1 vf0 acc :mask #b111) + (.svf (&-> sv-512 0 quad) vf4) + (set! (-> sv-272 old-x quad) (-> s4-0 vector 0 quad)) + ) + (else + (set! (-> s4-0 vector 0 quad) (-> sv-496 quad)) + (set! (-> sv-272 old-x quad) (-> s4-0 vector 0 quad)) + ) + ) + (vector-cross! (-> s4-0 vector 2) (the-as vector (-> s4-0 vector)) (-> s4-0 vector 1)) + (matrix->quaternion (-> sv-272 joint-mod quat) s4-0) + (set! (-> s1-0 quad) (-> s4-0 vector 1 quad)) + (set! (-> s2-0 quad) (-> s4-0 vector 2 quad)) + 0 + ) + (set! (-> s3-0 quad) (-> sv-528 quad)) + 0 + ) + ) + ) + 0 + (none) + ) + ) + +;; definition for method 7 of type chain-physics +(defmethod relocate chain-physics ((obj chain-physics) (arg0 int)) + (dotimes (v1-0 (the-as int (-> obj num-joints))) + (if (nonzero? (-> obj chain-joints v1-0 joint-mod)) + (&+! (-> obj chain-joints v1-0 joint-mod) arg0) + ) + ) + obj + ) + +;; definition for function chain-physics-initialize +;; INFO: Used lq/sq +(defun chain-physics-initialize ((arg0 process-drawable) (arg1 chain-physics) (arg2 int) (arg3 float) (arg4 (array chain-physics-setup))) + (set! (-> arg1 num-joints) (the-as uint (min 20 (-> arg4 length)))) + (dotimes (s1-0 (the-as int (-> arg1 num-joints))) + (set! (-> arg1 chain-joints s1-0 joint-mod) + (new 'process 'joint-mod (joint-mod-mode flex-blend) arg0 (-> arg4 s1-0 joint-index)) + ) + (set! (-> arg1 chain-joints s1-0 joint-mod track-mode) (track-mode no-scale)) + ) + (set! (-> arg1 root-joint-index) (the-as uint arg2)) + (set! (-> arg1 joint-length) arg3) + (set-vector! (-> arg1 gravity) 0.0 -1.0 0.0 1.0) + (set! (-> arg1 gravity-target quad) (-> arg1 gravity quad)) + (set! (-> arg1 stretch-vel) 0.7) + (set! (-> arg1 stretch-vel-parallel) 0.8) + (set! (-> arg1 compress-vel) 0.85) + (set! (-> arg1 compress-vel-parallel) 0.75) + (set! (-> arg1 negate-y) #f) + (set! (-> arg1 axial-slop) 3640.889) + (set! (-> arg1 maximum-stretch) 1.5) + (set! (-> arg1 turn-off-start) 0) + 0 + ) + + + + diff --git a/test/decompiler/reference/jak2/engine/process-drawable/process-drawable-h_REF.gc b/test/decompiler/reference/jak2/engine/process-drawable/process-drawable-h_REF.gc index 28f6169c3f..9fc682cc72 100644 --- a/test/decompiler/reference/jak2/engine/process-drawable/process-drawable-h_REF.gc +++ b/test/decompiler/reference/jak2/engine/process-drawable/process-drawable-h_REF.gc @@ -36,45 +36,39 @@ ) ;; definition for function num-func-none -(defun num-func-none ((arg0 joint-control-channel) (arg1 float) (arg2 float)) +(defbehavior num-func-none process ((arg0 joint-control-channel) (arg1 float) (arg2 float) (arg3 float)) (-> arg0 frame-num) ) ;; definition for function num-func-+! -(defun num-func-+! ((arg0 joint-control-channel) (arg1 float) (arg2 float)) - (with-pp - (let ((f0-1 (+ (-> arg0 frame-num) (* arg1 (* (-> arg0 frame-group speed) (-> pp clock time-adjust-ratio)))))) - (set! (-> arg0 frame-num) f0-1) - f0-1 - ) +(defbehavior num-func-+! process ((arg0 joint-control-channel) (arg1 float) (arg2 float) (arg3 float)) + (let ((f0-1 (+ (-> arg0 frame-num) (* arg1 (* (-> arg0 frame-group speed) (-> self clock time-adjust-ratio)))))) + (set! (-> arg0 frame-num) f0-1) + f0-1 ) ) ;; definition for function num-func--! -(defun num-func--! ((arg0 joint-control-channel) (arg1 float) (arg2 float)) - (with-pp - (let ((f0-1 (- (-> arg0 frame-num) (* arg1 (* (-> arg0 frame-group speed) (-> pp clock time-adjust-ratio)))))) - (set! (-> arg0 frame-num) f0-1) - f0-1 - ) +(defbehavior num-func--! process ((arg0 joint-control-channel) (arg1 float) (arg2 float) (arg3 float)) + (let ((f0-1 (- (-> arg0 frame-num) (* arg1 (* (-> arg0 frame-group speed) (-> self clock time-adjust-ratio)))))) + (set! (-> arg0 frame-num) f0-1) + f0-1 ) ) ;; definition for function num-func-loop! -(defun num-func-loop! ((arg0 joint-control-channel) (arg1 float) (arg2 float)) - (with-pp - (let* ((f0-1 (the float (+ (-> arg0 frame-group frames num-frames) -1))) - (f1-2 (+ (-> arg0 frame-num) f0-1 (* arg1 (* (-> arg0 frame-group speed) (-> pp clock time-adjust-ratio))))) - (f0-3 (- f1-2 (* (the float (the int (/ f1-2 f0-1))) f0-1))) - ) - (set! (-> arg0 frame-num) f0-3) - f0-3 - ) +(defbehavior num-func-loop! process ((arg0 joint-control-channel) (arg1 float) (arg2 float) (arg3 float)) + (let* ((f0-1 (the float (+ (-> arg0 frame-group frames num-frames) -1))) + (f1-2 (+ (-> arg0 frame-num) f0-1 (* arg1 (* (-> arg0 frame-group speed) (-> self clock time-adjust-ratio))))) + (f0-3 (- f1-2 (* (the float (the int (/ f1-2 f0-1))) f0-1))) + ) + (set! (-> arg0 frame-num) f0-3) + f0-3 ) ) ;; definition for function num-func-loop-speedless! -(defun num-func-loop-speedless! ((arg0 joint-control-channel) (arg1 float) (arg2 float)) +(defbehavior num-func-loop-speedless! process ((arg0 joint-control-channel) (arg1 float) (arg2 float) (arg3 float)) (let* ((f0-1 (the float (+ (-> arg0 frame-group frames num-frames) -1))) (f1-2 (+ (-> arg0 frame-num) f0-1 arg1)) (f0-3 (- f1-2 (* (the float (the int (/ f1-2 f0-1))) f0-1))) @@ -85,29 +79,25 @@ ) ;; definition for function num-func-seek! -(defun num-func-seek! ((arg0 joint-control-channel) (arg1 float) (arg2 float)) - (with-pp - (let ((f0-3 - (seek (-> arg0 frame-num) arg1 (* arg2 (* (-> arg0 frame-group speed) (-> pp clock time-adjust-ratio)))) - ) +(defbehavior num-func-seek! process ((arg0 joint-control-channel) (arg1 float) (arg2 float) (arg3 float)) + (let ((f0-3 + (seek (-> arg0 frame-num) arg1 (* arg2 (* (-> arg0 frame-group speed) (-> self clock time-adjust-ratio)))) ) - (set! (-> arg0 frame-num) f0-3) - f0-3 - ) + ) + (set! (-> arg0 frame-num) f0-3) + f0-3 ) ) ;; definition for function num-func-blend-in! -(defun num-func-blend-in! ((arg0 joint-control-channel) (arg1 float) (arg2 float)) - (with-pp - (let ((f30-0 (seek (-> arg0 frame-interp 0) 1.0 (* arg1 (-> pp clock time-adjust-ratio))))) - (set! (-> arg0 frame-interp 0) f30-0) - (set! (-> arg0 frame-interp 1) f30-0) - (if (= f30-0 1.0) - (joint-control-reset! (-> arg0 parent) arg0) - ) - f30-0 - ) +(defbehavior num-func-blend-in! process ((arg0 joint-control-channel) (arg1 float) (arg2 float) (arg3 float)) + (let ((f30-0 (seek (-> arg0 frame-interp 0) 1.0 (* arg1 (-> self clock time-adjust-ratio))))) + (set! (-> arg0 frame-interp 0) f30-0) + (set! (-> arg0 frame-interp 1) f30-0) + (if (= f30-0 1.0) + (joint-control-reset! (-> arg0 parent) arg0) + ) + f30-0 ) ) @@ -133,62 +123,58 @@ ) ;; definition for function num-func-interp-play! -(defun num-func-interp-play! ((arg0 joint-control-channel) (arg1 float) (arg2 float) (arg3 float)) - (with-pp - (let ((f30-0 (the float (+ (-> arg0 frame-group frames num-frames) -1))) - (f28-0 (* arg3 (-> arg0 frame-group speed))) - ) - (seek! (-> arg0 frame-num) f30-0 (* arg1 (* (-> arg0 frame-group speed) (-> pp clock time-adjust-ratio)))) - (cond - ((< (-> arg0 frame-num) f28-0) - (set! (-> arg0 frame-interp 0) (/ (* (-> arg0 frame-num) arg2) f28-0)) +(defbehavior num-func-interp-play! process ((arg0 joint-control-channel) (arg1 float) (arg2 float) (arg3 float)) + (let ((f30-0 (the float (+ (-> arg0 frame-group frames num-frames) -1))) + (f28-0 (* arg3 (-> arg0 frame-group speed))) + ) + (seek! (-> arg0 frame-num) f30-0 (* arg1 (* (-> arg0 frame-group speed) (-> self clock time-adjust-ratio)))) + (cond + ((< (-> arg0 frame-num) f28-0) + (set! (-> arg0 frame-interp 0) (/ (* (-> arg0 frame-num) arg2) f28-0)) + ) + ((< (- f30-0 f28-0) (-> arg0 frame-num)) + (set! (-> arg0 frame-interp 0) (/ (* (- f30-0 (-> arg0 frame-num)) arg2) f28-0)) + (when (and (= (-> arg0 frame-num) f30-0) (logtest? (-> arg0 command) (joint-control-command eight))) + (joint-channel-float-delete! arg0) + (return 0.0) ) - ((< (- f30-0 f28-0) (-> arg0 frame-num)) - (set! (-> arg0 frame-interp 0) (/ (* (- f30-0 (-> arg0 frame-num)) arg2) f28-0)) - (when (and (= (-> arg0 frame-num) f30-0) (logtest? (-> arg0 command) (joint-control-command eight))) - (joint-channel-float-delete! arg0) - (return 0.0) - ) - ) - (else - (set! (-> arg0 frame-interp 0) arg2) - ) + ) + (else + (set! (-> arg0 frame-interp 0) arg2) ) ) - (set! (-> arg0 frame-interp 1) (-> arg0 frame-interp 0)) - (-> arg0 frame-num) ) + (set! (-> arg0 frame-interp 1) (-> arg0 frame-interp 0)) + (-> arg0 frame-num) ) ;; definition for function num-func-interp1-play! -(defun num-func-interp1-play! ((arg0 joint-control-channel) (arg1 float) (arg2 float) (arg3 float)) - (with-pp - (let ((f30-0 (the float (+ (-> arg0 frame-group frames num-frames) -1))) - (f28-0 (* arg3 (-> arg0 frame-group speed))) - ) - (seek! (-> arg0 frame-num) f30-0 (* arg1 (* (-> arg0 frame-group speed) (-> pp clock time-adjust-ratio)))) - (cond - ((< (-> arg0 frame-num) f28-0) - (set! (-> arg0 frame-interp 1) (/ (* (-> arg0 frame-num) arg2) f28-0)) +(defbehavior num-func-interp1-play! process ((arg0 joint-control-channel) (arg1 float) (arg2 float) (arg3 float)) + (let ((f30-0 (the float (+ (-> arg0 frame-group frames num-frames) -1))) + (f28-0 (* arg3 (-> arg0 frame-group speed))) + ) + (seek! (-> arg0 frame-num) f30-0 (* arg1 (* (-> arg0 frame-group speed) (-> self clock time-adjust-ratio)))) + (cond + ((< (-> arg0 frame-num) f28-0) + (set! (-> arg0 frame-interp 1) (/ (* (-> arg0 frame-num) arg2) f28-0)) + ) + ((< (- f30-0 f28-0) (-> arg0 frame-num)) + (set! (-> arg0 frame-interp 1) (/ (* (- f30-0 (-> arg0 frame-num)) arg2) f28-0)) + (when (and (= (-> arg0 frame-num) f30-0) (logtest? (-> arg0 command) (joint-control-command eight))) + (joint-channel-float-delete! arg0) + (return 0.0) ) - ((< (- f30-0 f28-0) (-> arg0 frame-num)) - (set! (-> arg0 frame-interp 1) (/ (* (- f30-0 (-> arg0 frame-num)) arg2) f28-0)) - (when (and (= (-> arg0 frame-num) f30-0) (logtest? (-> arg0 command) (joint-control-command eight))) - (joint-channel-float-delete! arg0) - (return 0.0) - ) - ) - (else - (set! (-> arg0 frame-interp 1) arg2) - ) + ) + (else + (set! (-> arg0 frame-interp 1) arg2) ) ) - (-> arg0 frame-num) ) + (-> arg0 frame-num) ) ;; definition for function num-func-chan -(defun num-func-chan ((arg0 joint-control-channel) (arg1 float) (arg2 float)) +(defbehavior num-func-chan process ((arg0 joint-control-channel) (arg1 float) (arg2 float) (arg3 float)) (let ((f0-2 (-> (the-as joint-control-channel (+ (the-as uint arg0) (* (- (the int arg1) (-> arg0 group-sub-index)) 64))) frame-num @@ -201,13 +187,9 @@ ) ;; definition for function num-func-identity -(defun num-func-identity ((arg0 joint-control-channel) (arg1 float) (arg2 float)) +(defbehavior num-func-identity process ((arg0 joint-control-channel) (arg1 float) (arg2 float) (arg3 float)) (-> arg0 frame-num) ) ;; failed to figure out what this is: 0 - - - - diff --git a/test/decompiler/reference/jak2/engine/process-drawable/process-drawable_REF.gc b/test/decompiler/reference/jak2/engine/process-drawable/process-drawable_REF.gc new file mode 100644 index 0000000000..7e439f9a96 --- /dev/null +++ b/test/decompiler/reference/jak2/engine/process-drawable/process-drawable_REF.gc @@ -0,0 +1,8 @@ +;;-*-Lisp-*- +(in-package goal) + +;; ERROR: top level function was not converted to expressions. Cannot decompile. + + + + diff --git a/test/decompiler/reference/jak2/engine/sound/gsound_REF.gc b/test/decompiler/reference/jak2/engine/sound/gsound_REF.gc index a3d27dbeba..f9db292b2f 100644 --- a/test/decompiler/reference/jak2/engine/sound/gsound_REF.gc +++ b/test/decompiler/reference/jak2/engine/sound/gsound_REF.gc @@ -90,7 +90,8 @@ (stream-position uint32 4 :offset 272) (stream-status stream-status 4 :offset-assert 288) (stream-name sound-stream-name 4 :inline :offset-assert 304) - (stream-id uint32 4 :offset-assert 496) + (stream-id sound-id 4 :offset-assert 496) + (stream-id-int32 int32 4 :offset 496) (music-register uint8 17 :offset-assert 512) (music-excite int8 :offset 528) (ramdisk-name uint8 48 :offset-assert 529) @@ -151,8 +152,8 @@ ;; definition for function str-is-playing? (defun str-is-playing? () (countdown (v1-0 4) - (if (and (>= (-> *sound-iop-info* stream-id v1-0) 0) - (logtest? (-> *sound-iop-info* stream-status v1-0) (stream-status four)) + (if (and (>= (the-as uint (-> *sound-iop-info* stream-id v1-0)) 0) + (logtest? (-> *sound-iop-info* stream-status v1-0) (stream-status ststatus-four)) ) (return #t) ) @@ -164,7 +165,7 @@ (defun str-id-is-playing? ((arg0 int)) (countdown (v1-0 4) (if (and (= arg0 (-> *sound-iop-info* stream-id v1-0)) - (logtest? (-> *sound-iop-info* stream-status v1-0) (stream-status one six)) + (logtest? (-> *sound-iop-info* stream-status v1-0) (stream-status ststatus-one ststatus-six)) ) (return #t) ) diff --git a/test/decompiler/reference/jak2/engine/target/board/board-util_REF.gc b/test/decompiler/reference/jak2/engine/target/board/board-util_REF.gc index d98a4adbb4..ba07c5a1d7 100644 --- a/test/decompiler/reference/jak2/engine/target/board/board-util_REF.gc +++ b/test/decompiler/reference/jak2/engine/target/board/board-util_REF.gc @@ -115,42 +115,18 @@ (ja-channel-push! 1 (seconds 0.1)) (cond (arg0 - (let ((gp-1 (-> self skel root-channel 0))) - (joint-control-channel-group-eval! - gp-1 - (the-as art-joint-anim (-> self draw art-group data 4)) - (the-as (function joint-control-channel float float float float) num-func-identity) + (ja :group! (-> self draw art-group data 4) + :num! (identity (the float (+ (-> (the-as art-joint-anim (-> self draw art-group data 4)) frames num-frames) -1))) ) - (set! (-> gp-1 frame-num) - (the float (+ (-> (the-as art-joint-anim (-> self draw art-group data 4)) frames num-frames) -1)) - ) - ) ) (else - (let ((a0-3 (-> self skel root-channel 0))) - (set! (-> a0-3 frame-group) (the-as art-joint-anim (-> self draw art-group data 4))) - (set! (-> a0-3 param 0) - (the float (+ (-> (the-as art-joint-anim (-> self draw art-group data 4)) frames num-frames) -1)) - ) - (set! (-> a0-3 param 1) 1.0) - (set! (-> a0-3 frame-num) 0.0) - (joint-control-channel-group! - a0-3 - (the-as art-joint-anim (-> self draw art-group data 4)) - (the-as (function joint-control-channel float float float float) num-func-seek!) - ) - ) + (ja-no-eval :group! (-> self draw art-group data 4) + :num! (seek! (the float (+ (-> (the-as art-joint-anim (-> self draw art-group data 4)) frames num-frames) -1))) + :frame-num 0.0 + ) (until (ja-done? 0) (suspend) - (let ((a0-4 (-> self skel root-channel 0))) - (set! (-> a0-4 param 0) (the float (+ (-> a0-4 frame-group frames num-frames) -1))) - (set! (-> a0-4 param 1) 1.0) - (joint-control-channel-group-eval! - a0-4 - (the-as art-joint-anim #f) - (the-as (function joint-control-channel float float float float) num-func-seek!) - ) - ) + (ja :num! (seek!)) ) ) ) @@ -210,30 +186,13 @@ :code (behavior () (set! (-> self draw shadow) (-> self shadow-backup)) (ja-channel-push! 1 (seconds 0.1)) - (let ((a0-2 (-> self skel root-channel 0))) - (set! (-> a0-2 frame-group) (the-as art-joint-anim (-> self draw art-group data 3))) - (set! (-> a0-2 param 0) - (the float (+ (-> (the-as art-joint-anim (-> self draw art-group data 3)) frames num-frames) -1)) - ) - (set! (-> a0-2 param 1) 1.0) - (set! (-> a0-2 frame-num) 0.0) - (joint-control-channel-group! - a0-2 - (the-as art-joint-anim (-> self draw art-group data 3)) - (the-as (function joint-control-channel float float float float) num-func-seek!) - ) - ) + (ja-no-eval :group! (-> self draw art-group data 3) + :num! (seek! (the float (+ (-> (the-as art-joint-anim (-> self draw art-group data 3)) frames num-frames) -1))) + :frame-num 0.0 + ) (until (ja-done? 0) (suspend) - (let ((a0-3 (-> self skel root-channel 0))) - (set! (-> a0-3 param 0) (the float (+ (-> a0-3 frame-group frames num-frames) -1))) - (set! (-> a0-3 param 1) 1.0) - (joint-control-channel-group-eval! - a0-3 - (the-as art-joint-anim #f) - (the-as (function joint-control-channel float float float float) num-func-seek!) - ) - ) + (ja :num! (seek!)) ) (sleep-code) (none) diff --git a/test/decompiler/reference/jak2/engine/ui/gui-h_REF.gc b/test/decompiler/reference/jak2/engine/ui/gui-h_REF.gc index 743f01c696..3ba08b9869 100644 --- a/test/decompiler/reference/jak2/engine/ui/gui-h_REF.gc +++ b/test/decompiler/reference/jak2/engine/ui/gui-h_REF.gc @@ -8,8 +8,8 @@ (channel gui-channel :offset 21) (anim-part uint8 :offset 22) (flags uint8 :offset 23) - (name object :offset 24) - (id uint32 :offset 28) + (name string :offset 24) + (id sound-id :offset 28) (handle handle :offset 0) (time-stamp time-frame :offset 8) (hold-time time-frame :offset-assert 32) @@ -249,29 +249,35 @@ ;; definition of type gui-control (deftype gui-control (basic) - ((engine engine :offset-assert 4) - (data uint8 3272 :offset-assert 8) + ((engine engine :offset-assert 4) + (update-time time-frame :offset-assert 8) + (connections gui-connection 32 :inline :offset-assert 16) + (spool-connections gui-connection 4 :inline :offset-assert 1552) + (ids sound-id 96 :offset-assert 1744) + (times time-frame 96 :offset-assert 2128) + (cmd pair 96 :offset-assert 2896) ) :method-count-assert 25 :size-assert #xcd0 :flag-assert #x1900000cd0 (:methods - (gui-control-method-9 () none 9) - (gui-control-method-10 () none 10) - (gui-control-method-11 () none 11) - (gui-control-method-12 () none 12) - (update (_type_ symbol) none 13) - (gui-control-method-14 () none 14) - (gui-control-method-15 () none 15) - (gui-control-method-16 () none 16) - (gui-control-method-17 () none 17) - (gui-control-method-18 () none 18) - (gui-control-method-19 () none 19) - (gui-control-method-20 () none 20) - (gui-control-method-21 () none 21) - (gui-control-method-22 () none 22) - (gui-control-method-23 () none 23) - (gui-control-method-24 () none 24) + (new (symbol type int) _type_ 0) + (gui-control-method-9 (_type_ process gui-channel gui-action int float time-frame) sound-id 9) + (gui-control-method-10 (_type_ process gui-channel) none 10) + (gui-control-method-11 (_type_ gui-connection) int 11) + (gui-control-method-12 (_type_ process gui-channel gui-action string int float sound-id) sound-id 12) + (update (_type_ symbol) int 13) + (gui-control-method-14 (_type_ string gui-channel gui-action) int 14) + (gui-control-method-15 (_type_ process gui-channel string sound-id) gui-connection 15) + (gui-control-method-16 (_type_ gui-action sound-id gui-channel gui-action string (function gui-connection symbol) process) int 16) + (gui-control-method-17 (_type_ sound-id) gui-action 17) + (gui-control-method-18 (_type_ gui-channel) symbol 18) + (gui-control-method-19 (_type_ gui-channel gui-connection) symbol 19) + (gui-control-method-20 (_type_ sound-id symbol int int int) gui-connection 20) + (gui-control-method-21 (_type_ gui-connection vector) int 21) + (gui-control-method-22 (_type_ gui-connection process symbol) none 22) + (gui-control-method-23 (_type_ gui-channel gui-channel symbol gui-connection) symbol 23) + (channel-id-set! (_type_ gui-connection sound-id) int 24) ) ) diff --git a/test/offline/config/jak2/config.jsonc b/test/offline/config/jak2/config.jsonc index e3848e4278..2dc45e8e94 100644 --- a/test/offline/config/jak2/config.jsonc +++ b/test/offline/config/jak2/config.jsonc @@ -50,6 +50,12 @@ "print-game-text", // joint asm "cspace<-parented-transformq-joint!", "(method 11 art-joint-anim-manager)", "make-joint-jump-tables", "joint-channel-copy!", + // vector-dot in stack vars + "joint-mod-ik-callback", + "joint-mod-look-at-handler", + // bad stack-no-clear decomp + "ja-play-spooled-anim", + // default menu // - causes a decompiler hang "dm-cam-setting-float",