From 5a8b4e81f911d42fe6bfc9956e00c64ed3b72756 Mon Sep 17 00:00:00 2001 From: Hat Kid <6624576+Hat-Kid@users.noreply.github.com> Date: Sat, 16 Mar 2024 01:28:26 +0100 Subject: [PATCH] decomp3: more engine stuff, support boxed stack arrays in compiler (#3424) - `sync-info` - `trajectory` - `camera` - `cam-update` - `cam-states` - `cam-states-dbg` - `cam-master` - `cam-layout` - `cam-interface` - `cam-combiner` Closes #2016 --- decompiler/IR2/FormExpressionAnalysis.cpp | 8 +- decompiler/config/jak3/all-types.gc | 633 ++- .../ntsc_v1/anonymous_function_types.jsonc | 3 +- decompiler/config/jak3/ntsc_v1/hacks.jsonc | 2 - .../config/jak3/ntsc_v1/label_types.jsonc | 31 +- .../jak3/ntsc_v1/stack_structures.jsonc | 65 +- .../config/jak3/ntsc_v1/type_casts.jsonc | 228 +- .../config/jak3/ntsc_v1/var_names.jsonc | 219 +- goal_src/jak3/engine/camera/cam-combiner.gc | 438 ++ goal_src/jak3/engine/camera/cam-interface.gc | 101 + goal_src/jak3/engine/camera/cam-layout.gc | 3482 +++++++++++++++ goal_src/jak3/engine/camera/cam-master.gc | 1072 +++++ goal_src/jak3/engine/camera/cam-states-dbg.gc | 413 ++ goal_src/jak3/engine/camera/cam-states.gc | 3780 ++++++++++++++++ goal_src/jak3/engine/camera/cam-update-h.gc | 4 +- goal_src/jak3/engine/camera/cam-update.gc | 692 +++ goal_src/jak3/engine/camera/camera-h.gc | 80 +- goal_src/jak3/engine/camera/camera.gc | 1978 ++++++++ .../jak3/engine/collide/find-nearest-h.gc | 2 + .../jak3/engine/common-obs/collectables.gc | 35 +- .../jak3/engine/common-obs/generic-obs.gc | 6 +- .../engine/gfx/background/tie/tie-work.gc | 2 + goal_src/jak3/engine/gfx/shrub/shrub-work.gc | 2 + goal_src/jak3/engine/gfx/shrub/shrubbery-h.gc | 2 + goal_src/jak3/engine/level/bsp-h.gc | 2 + goal_src/jak3/engine/level/level-h.gc | 4 +- goal_src/jak3/engine/nav/nav-control-h.gc | 2 +- goal_src/jak3/engine/physics/trajectory-h.gc | 33 +- goal_src/jak3/engine/physics/trajectory.gc | 508 +++ goal_src/jak3/engine/target/logic-target.gc | 164 +- goal_src/jak3/engine/util/sync-info-h.gc | 42 +- goal_src/jak3/engine/util/sync-info.gc | 576 +++ goalc/compiler/compilation/Type.cpp | 50 +- .../jak1/engine/gfx/mood/time-of-day_REF.gc | 2 +- .../jak2/engine/load/load-state_REF.gc | 2 +- .../jak2/engine/target/target-part_REF.gc | 2 +- .../levels/city/traffic/traffic-engine_REF.gc | 4 +- .../jak3/engine/camera/cam-combiner_REF.gc | 451 ++ .../jak3/engine/camera/cam-interface_REF.gc | 124 + .../jak3/engine/camera/cam-layout_REF.gc | 3727 ++++++++++++++++ .../jak3/engine/camera/cam-master_REF.gc | 1097 +++++ .../jak3/engine/camera/cam-states-dbg_REF.gc | 468 ++ .../jak3/engine/camera/cam-states_REF.gc | 3970 +++++++++++++++++ .../jak3/engine/camera/cam-update-h_REF.gc | 12 +- .../jak3/engine/camera/cam-update_REF.gc | 720 +++ .../jak3/engine/camera/camera-h_REF.gc | 42 +- .../jak3/engine/camera/camera_REF.gc | 2073 +++++++++ .../engine/common-obs/collectables_REF.gc | 35 +- .../jak3/engine/common-obs/generic-obs_REF.gc | 6 +- .../reference/jak3/engine/level/bsp-h_REF.gc | 2 + .../jak3/engine/level/level-h_REF.gc | 4 +- .../jak3/engine/nav/nav-control-h_REF.gc | 6 +- .../jak3/engine/physics/trajectory-h_REF.gc | 35 +- .../jak3/engine/physics/trajectory_REF.gc | 554 +++ .../jak3/engine/target/logic-target_REF.gc | 164 +- .../jak3/engine/util/sync-info-h_REF.gc | 42 +- .../jak3/engine/util/sync-info_REF.gc | 620 +++ .../variables/stack-boxed-array.gc | 26 + test/goalc/test_variables.cpp | 4 + test/offline/config/jak3/config.jsonc | 13 +- 60 files changed, 28132 insertions(+), 732 deletions(-) create mode 100644 test/decompiler/reference/jak3/engine/camera/cam-combiner_REF.gc create mode 100644 test/decompiler/reference/jak3/engine/camera/cam-interface_REF.gc create mode 100644 test/decompiler/reference/jak3/engine/camera/cam-layout_REF.gc create mode 100644 test/decompiler/reference/jak3/engine/camera/cam-master_REF.gc create mode 100644 test/decompiler/reference/jak3/engine/camera/cam-states-dbg_REF.gc create mode 100644 test/decompiler/reference/jak3/engine/camera/cam-states_REF.gc create mode 100644 test/decompiler/reference/jak3/engine/camera/cam-update_REF.gc create mode 100644 test/decompiler/reference/jak3/engine/camera/camera_REF.gc create mode 100644 test/decompiler/reference/jak3/engine/physics/trajectory_REF.gc create mode 100644 test/decompiler/reference/jak3/engine/util/sync-info_REF.gc create mode 100644 test/goalc/source_templates/variables/stack-boxed-array.gc diff --git a/decompiler/IR2/FormExpressionAnalysis.cpp b/decompiler/IR2/FormExpressionAnalysis.cpp index be4549fba1f..d8457c4fb3d 100644 --- a/decompiler/IR2/FormExpressionAnalysis.cpp +++ b/decompiler/IR2/FormExpressionAnalysis.cpp @@ -3863,8 +3863,12 @@ void FunctionCallElement::update_from_stack(const Env& env, if (got_stack_new) { std::vector stack_new_args; stack_new_args.push_back(pool.form("'stack")); - stack_new_args.push_back(pool.form( - fmt::format("'{}", type_source_form->to_string(env)))); + if (type_source_form->to_string(env) == "array") { + stack_new_args.push_back(pool.form("'boxed-array")); + } else { + stack_new_args.push_back(pool.form( + fmt::format("'{}", type_source_form->to_string(env)))); + } for (size_t i = 2; i < arg_forms.size(); i++) { stack_new_args.push_back(arg_forms.at(i)); } diff --git a/decompiler/config/jak3/all-types.gc b/decompiler/config/jak3/all-types.gc index 076465f175d..7ffcebdfaaa 100644 --- a/decompiler/config/jak3/all-types.gc +++ b/decompiler/config/jak3/all-types.gc @@ -7630,7 +7630,7 @@ (level-method-13 () none) ;; 13 ;; (bsp-name (_type_) symbol) (compute-memory-usage! (_type_ symbol) memory-usage-block) ;; 14 (level-method-15 () none) ;; 15 ;; (inside-boxes-check (_type_ vector) symbol) - (level-method-16 () none) ;; 16 ;; (update-vis! (_type_ level-vis-info uint (pointer uint8)) symbol) + (update-vis! (_type_ level-vis-info uint (pointer uint8)) symbol) ;; 16 (level-method-17 () none) ;; 17 ;; (load-continue (_type_) _type_) (level-method-18 () none) ;; 18 ;; (load-begin (_type_) _type_) (level-method-19 () none) ;; 19 ;; (login-begin (_type_) _type_) @@ -7705,7 +7705,7 @@ (level-group-method-16 () none) ;; 16 ;; (assign-draw-indices (_type_) none) (level-group-method-17 () none) ;; 17 ;; (actors-update (_type_) none) (level-group-method-18 () none) ;; 18 ;; (update-nav-meshes-method (_type_) none) - (level-group-method-19 () none) ;; 19 ;; (level-update (_type_) none) + (level-update (_type_) none) ;; 19 (level-get-target-inside (_type_) level) ;; 20 (level-group-method-21 () none) ;; 21 ;; (alloc-levels-if-needed (_type_ symbol) none) (art-group-get-by-name (_type_ string (pointer level)) art-group) ;; 22 ;; (load-commands-set! (_type_ pair) none) @@ -19381,13 +19381,13 @@ :size-assert #x10 :flag-assert #x1000000010 (:methods - (sync-info-method-9 () none) ;; 9 ;; (get-current-phase-no-mod (_type_) float) - (sync-info-method-10 () none) ;; 10 ;; (get-phase-offset (_type_) float) + (get-current-phase-no-mod (_type_) float) ;; 9 + (get-phase-offset (_type_) float) ;; 10 (get-norm! (_type_ int) float) ;; 11 - (sync-info-method-12 () none) ;; 12 ;; (get-scaled-val! (_type_ float int) float) + (get-scaled-val! (_type_ float int) float) ;; 12 (initialize! (_type_ sync-info-params) none) ;; 13 - (sync-info-method-14 () none) ;; 14 ;; (get-timeframe-offset! (_type_ time-frame) time-frame) - (sync-info-method-15 () none) ;; 15 ;; (sync-now! (_type_ float) none) + (get-timeframe-offset! (_type_ time-frame) time-frame) ;; 14 + (sync-now! (_type_ float) none) ;; 15 ) ) @@ -19436,10 +19436,10 @@ :size-assert #x1c :flag-assert #xd0000001c (:methods - (delayed-rand-float-method-9 () none) ;; 9 ;; (set-params! (_type_ int int float) float) - (delayed-rand-float-method-10 () none) ;; 10 ;; (reset! (_type_) float) - (delayed-rand-float-method-11 () none) ;; 11 ;; (update! (_type_) float) - (delayed-rand-float-method-12 () none) ;; 12 ;; (update-and-clear! (_type_) none) + (set-params! (_type_ int int float) float) ;; 9 + (reset! (_type_) float) ;; 10 + (update! (_type_) float) ;; 11 + (update-and-clear! (_type_) float) ;; 12 ) ) @@ -19456,8 +19456,8 @@ :size-assert #x18 :flag-assert #xb00000018 (:methods - (oscillating-float-method-9 () none) ;; 9 ;; (set-params! (_type_ float float float float) float) - (oscillating-float-method-10 () none) ;; 10 ;; (update! (_type_ float) float) + (set-params! (_type_ float float float float) float) ;; 9 + (update! (_type_ float) float) ;; 10 ) ) @@ -19473,10 +19473,10 @@ :size-assert #x28 :flag-assert #xd00000028 (:methods - (bouncing-float-method-9 () none) ;; 9 ;; (set-params! (_type_ float float float float float float float) float) - (bouncing-float-method-10 () none) ;; 10 ;; (update! (_type_ float) float) - (bouncing-float-method-11 () none) ;; 11 ;; (at-min? (_type_) symbol) - (bouncing-float-method-12 () none) ;; 12 ;; (at-max? (_type_) symbol) + (set-params! (_type_ float float float float float float float) float) ;; 9 + (update! (_type_ float) float) ;; 10 + (at-min? (_type_) symbol) ;; 11 + (at-max? (_type_) symbol) ;; 12 ) ) @@ -19493,10 +19493,10 @@ :size-assert #x30 :flag-assert #xd00000030 (:methods - (delayed-rand-vector-method-9 () none) ;; 9 ;; (set-params! (_type_ int int float float) vector) - (delayed-rand-vector-method-10 () none) ;; 10 ;; (update-now! (_type_) vector) - (delayed-rand-vector-method-11 () none) ;; 11 ;; (update-with-delay! (_type_) vector) - (delayed-rand-vector-method-12 () none) ;; 12 ;; (update-with-delay-or-reset! (_type_) vector) + (set-params! (_type_ int int float float) vector) ;; 9 + (update-now! (_type_) vector) ;; 10 + (update-with-delay! (_type_) vector) ;; 11 + (update-with-delay-or-reset! (_type_) vector) ;; 12 ) ) @@ -19512,8 +19512,8 @@ :size-assert #x3c :flag-assert #xb0000003c (:methods - (oscillating-vector-method-9 () none) ;; 9 ;; (set-params! (_type_ vector float float float) vector) - (oscillating-vector-method-10 () none) ;; 10 ;; (update! (_type_ vector) vector) + (set-params! (_type_ vector float float float) vector) ;; 9 + (update! (_type_ vector) vector) ;; 10 ) ) @@ -20867,15 +20867,15 @@ :size-assert #x28 :flag-assert #x1200000028 (:methods - (trajectory-method-9 () none) ;; 9 ;; (compute-trans-at-time (_type_ float vector) vector) - (trajectory-method-10 () none) ;; 10 ;; (compute-transv-at-time (_type_ float vector) vector) - (trajectory-method-11 () none) ;; 11 ;; (compute-time-until-apex (_type_) float) - (trajectory-method-12 () none) ;; 12 ;; (setup-from-to-duration! (_type_ vector vector float float) none) - (trajectory-method-13 () none) ;; 13 ;; (setup-from-to-xz-vel! (_type_ vector vector float float) none) - (trajectory-method-14 () none) ;; 14 ;; (setup-from-to-y-vel! (_type_ vector vector float float) none) - (trajectory-method-15 () none) ;; 15 ;; (setup-from-to-height! (_type_ vector vector float float) none) - (trajectory-method-16 () none) ;; 16 ;; (setup-from-to-duration-and-height! (_type_ vector vector float float) none) - (trajectory-method-17 () none) ;; 17 ;; (debug-draw (_type_) none) + (compute-trans-at-time (_type_ float vector) vector) ;; 9 + (compute-transv-at-time (_type_ float vector) vector) ;; 10 + (compute-time-until-apex (_type_) float) ;; 11 + (setup-from-to-duration! (_type_ vector vector float float) none) ;; 12 + (setup-from-to-xz-vel! (_type_ vector vector float float) none) ;; 13 + (setup-from-to-y-vel! (_type_ vector vector float float) none) ;; 14 + (setup-from-to-height! (_type_ vector vector float float) none) ;; 15 + (setup-from-to-duration-and-height! (_type_ vector vector float float) none) ;; 16 + (debug-draw (_type_) none) ;; 17 ) ) @@ -20894,7 +20894,7 @@ (:methods (new (symbol type process-drawable int float collide-spec) _type_) ;; 0 (initialize (_type_ process-drawable int float collide-spec) impact-control) ;; 9 - (impact-control-method-10 () none) ;; 10 ;; (update-from-cspace (_type_) none) + (update-from-cspace (_type_) none) ;; 10 (impact-control-method-11 (_type_ collide-query process pat-surface) float) ;; 11 ) ) @@ -20908,7 +20908,7 @@ (:methods (new (symbol type vector vector) _type_) ;; 0 (initialize (_type_ vector vector) point-tracker) ;; 9 - (point-tracker-method-10 () none) ;; 10 ;; (point-tracker-method-10 (_type_ vector vector vector float) vector) + (point-tracker-method-10 (_type_ vector vector vector float) vector) ;; 10 (point-tracker-method-11 (_type_ vector vector vector float) vector) ;; 11 ) ) @@ -20956,16 +20956,17 @@ (deftype cubic-curve (structure) ((mat matrix :inline :offset-assert 0) + (vec vector 4 :inline :offset 0 :score 1) ;; added ) :method-count-assert 14 :size-assert #x40 :flag-assert #xe00000040 (:methods - (cubic-curve-method-9 () none) ;; 9 ;; (cubic-curve-method-9 (_type_ vector vector vector vector) none) - (cubic-curve-method-10 () none) ;; 10 ;; (cubic-curve-method-10 (_type_ vector float) vector) - (cubic-curve-method-11 () none) ;; 11 ;; (cubic-curve-method-11 (_type_ vector float) vector) - (cubic-curve-method-12 () none) ;; 12 ;; (cubic-curve-method-12 (_type_ vector float) vector) - (cubic-curve-method-13 () none) ;; 13 ;; (debug-draw-curve (_type_) none) + (cubic-curve-method-9 (_type_ vector vector vector vector) none) ;; 9 + (cubic-curve-method-10 (_type_ vector float) vector) ;; 10 + (cubic-curve-method-11 (_type_ vector float) vector) ;; 11 + (cubic-curve-method-12 (_type_ vector float) vector) ;; 12 + (debug-draw-curve (_type_) none) ;; 13 ) ) @@ -23058,8 +23059,8 @@ ; ;; 204 is maybe that array's length ; (wind-array-length int32 :offset 204) ; (city-level-info city-level-info :offset 208) - ; (vis-spheres vector-array :offset 216) - ; (vis-spheres-length uint32 :offset 248) + (vis-spheres vector-array :offset 216) + (vis-spheres-length uint32 :offset 248) ; (region-tree drawable-tree-region-prim :offset 252) (tfrag-masks texture-masks-array :offset 256) @@ -25228,8 +25229,8 @@ (defenum cam-index-options :type uint32 :bitfield #t - (RADIAL) (SPHERICAL) + (RADIAL) ) ;; ---camera-h:cam-index-options @@ -25251,8 +25252,8 @@ :size-assert #x30 :flag-assert #xb00000030 (:methods - (cam-index-method-9 () none) ;; 9 ;; (cam-index-method-9 (_type_ symbol entity vector curve) symbol) - (cam-index-method-10 () none) ;; 10 ;; (cam-index-method-10 (_type_ vector) float) + (cam-index-method-9 (_type_ symbol entity vector curve) symbol) ;; 9 + (cam-index-method-10 (_type_ vector) float) ;; 10 ) ) @@ -25297,21 +25298,21 @@ :size-assert #x664 :flag-assert #x1800000664 (:methods - (tracking-spline-method-9 () none) ;; 9 ;; (tracking-spline-method-9 (_type_) none) - (tracking-spline-method-10 () none) ;; 10 ;; (tracking-spline-method-10 (_type_ vector) none) - (tracking-spline-method-11 () none) ;; 11 ;; (debug-point-info (_type_ int) none) - (tracking-spline-method-12 () none) ;; 12 ;; (debug-all-points (_type_) none) - (tracking-spline-method-13 () none) ;; 13 ;; (tracking-spline-method-13 (_type_ int) none) - (tracking-spline-method-14 () none) ;; 14 ;; (tracking-spline-method-14 (_type_ tracking-spline-sampler) none) - (tracking-spline-method-15 () none) ;; 15 ;; (tracking-spline-method-15 (_type_) none) - (tracking-spline-method-16 () none) ;; 16 ;; (tracking-spline-method-16 (_type_ float) none) - (tracking-spline-method-17 () none) ;; 17 ;; (tracking-spline-method-17 (_type_ vector float float symbol) int) - (tracking-spline-method-18 () none) ;; 18 ;; (tracking-spline-method-18 (_type_ float vector tracking-spline-sampler) vector) - (tracking-spline-method-19 () none) ;; 19 ;; (tracking-spline-method-19 (_type_ float vector tracking-spline-sampler) vector) - (tracking-spline-method-20 () none) ;; 20 ;; (tracking-spline-method-20 (_type_ vector int) none) - (tracking-spline-method-21 () none) ;; 21 ;; (tracking-spline-method-21 (_type_ vector float float float) vector) - (tracking-spline-method-22 () none) ;; 22 ;; (tracking-spline-method-22 (_type_ float) symbol) - (tracking-spline-method-23 () none) ;; 23 ;; (debug-draw-spline (_type_) none) + (tracking-spline-method-9 (_type_) none) ;; 9 + (tracking-spline-method-10 (_type_ vector) none) ;; 10 + (debug-point-info (_type_ int) none) ;; 11 + (debug-all-points (_type_) none) ;; 12 + (tracking-spline-method-13 (_type_ int) none) ;; 13 + (tracking-spline-method-14 (_type_ tracking-spline-sampler) none) ;; 14 + (tracking-spline-method-15 (_type_) none) ;; 15 + (tracking-spline-method-16 (_type_ float) none) ;; 16 + (tracking-spline-method-17 (_type_ vector float float symbol) int) ;; 17 + (tracking-spline-method-18 (_type_ float vector vector tracking-spline-sampler) vector) ;; 18 + (tracking-spline-method-19 (_type_ float vector vector tracking-spline-sampler) vector) ;; 19 + (tracking-spline-method-20 (_type_ vector int) none) ;; 20 + (tracking-spline-method-21 (_type_ vector float float float float vector) vector) ;; 21 + (tracking-spline-method-22 (_type_ float) symbol) ;; 22 + (debug-draw-spline (_type_) none) ;; 23 ) ) @@ -25389,6 +25390,9 @@ :method-count-assert 14 :size-assert #x22c :flag-assert #xe01b0022c + (:states + cam-combiner-active + ) ) ;; +++camera-h:camera-blend-to-type @@ -25567,7 +25571,10 @@ (:methods (camera-master-method-14 (_type_ vector) vector) ;; 14 (camera-master-method-15 (_type_ vector) vector) ;; 15 - (camera-master-method-16 () none) ;; 16 ;; (camera-master-method-16 (_type_ symbol) int) + (camera-master-method-16 (_type_ symbol) int) ;; 16 + ) + (:states + cam-master-active ) ) @@ -26154,8 +26161,8 @@ (define-extern *camera-other-trans* vector) (define-extern *camera-other-matrix* matrix) (define-extern *camera-smush-control* smush-control) -(define-extern *camera-smush-control-horizontal* object) -(define-extern *camera-smush-control-into* object) +(define-extern *camera-smush-control-horizontal* smush-control) +(define-extern *camera-smush-control-into* smush-control) (define-extern *camera-other-root* vector) (define-extern *fix-visible-level-mask* int) (define-extern *manual-sample-point* symbol) @@ -28080,7 +28087,7 @@ (:methods (nav-control-method-9 () none) ;; 9 ;; (debug-draw (_type_) none) (nav-control-method-10 () none) ;; 10 ;; (point-in-bsphere? (_type_ vector) symbol) - (nav-control-method-11 () none) ;; 11 ;; (find-poly-containing-point-1 (_type_ vector) nav-poly) + (find-poly-containing-point-1 (_type_ vector) nav-poly) ;; 11 (nav-control-method-12 () none) ;; 12 ;; (cloest-point-on-mesh (_type_ vector vector nav-poly) nav-poly) (nav-control-method-13 () none) ;; 13 ;; (find-nearest-poly-to-point (_type_ vector) nav-poly) (nav-control-method-14 () none) ;; 14 ;; (project-point-onto-plane-of-poly (_type_ nav-poly vector vector vector) none) @@ -30047,7 +30054,7 @@ ;; (define-extern cloud-texture-anim-layer-func function) ;; (function dma-buffer uint int int texture-anim-layer float int) ;; (define-extern cloud-texture-anim-func function) ;; (function dma-buffer texture-anim int) ;; (define-extern fog-texture-anim-init function) ;; (function texture-anim int) -;; (define-extern *fog-texture-work* object) ;; fog-texture-work +(define-extern *fog-texture-work* fog-texture-work) ;; (define-extern real-fog-texture-anim-func function) ;; (function dma-buffer texture-anim int) ;; (define-extern fog-texture-anim-func function) ;; (function dma-buffer texture-anim int) @@ -30190,7 +30197,7 @@ ;; (define-extern highres-shrub-login function) ;; (define-extern shrub-vu1-block object) ;; vu-function ;; (define-extern shrub-num-tris function) ;; (function shrubbery uint) -;; (define-extern shrub-make-perspective-matrix function) ;; (function matrix matrix matrix) +(define-extern shrub-make-perspective-matrix (function matrix matrix matrix)) ;; (define-extern shrub-init-view-data function) ;; (function shrub-view-data symbol) ;; (define-extern shrub-upload-view-data function) ;; (function dma-buffer symbol) ;; (define-extern shrub-time function) ;; (function int int int int int int) @@ -30210,7 +30217,7 @@ ;; shrub-work ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; (define-extern *instance-shrub-work* object) ;; instance-shrub-work +(define-extern *instance-shrub-work* instance-shrub-work) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; tfrag-near ;; @@ -30509,7 +30516,7 @@ ;; tie-work ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; (define-extern *instance-tie-work* object) ;; instance-tie-work +(define-extern *instance-tie-work* instance-tie-work) (define-extern *prototype-tie-work* prototype-tie-work) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -30585,8 +30592,8 @@ ;; trajectory ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; (define-extern traj2d-calc-initial-speed-using-tilt function) ;; (function traj2d-params symbol) -;; (define-extern traj3d-calc-initial-velocity-using-tilt function) ;; (function traj3d-params symbol) +(define-extern traj2d-calc-initial-speed-using-tilt (function traj2d-params symbol)) +(define-extern traj3d-calc-initial-velocity-using-tilt (function traj3d-params symbol)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; sparticle-launcher ;; @@ -30777,8 +30784,8 @@ ;; entity-table ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; (define-extern *entity-info* array) ;; (array entity-info) -;; (define-extern entity-info-lookup function) ;; (function type entity-info) +(define-extern *entity-info* (array entity-info)) +(define-extern entity-info-lookup (function type entity-info)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; loader ;; @@ -31565,7 +31572,7 @@ ;; weather-part ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; (define-extern group-rain-screend-drop object) ;; sparticle-launch-group +(define-extern group-rain-screend-drop sparticle-launch-group) ;; (define-extern update-snow function) ;; (function float vector vector none) ;; (define-extern birth-func-omega-normal-orient function) ;; (function sparticle-system sparticle-cpuinfo sprite-vec-data-3d sparticle-launcher sparticle-launch-state none) ;; (define-extern birth-func-rain function) ;; (function sparticle-system sparticle-cpuinfo sprite-vec-data-3d sparticle-launcher sparticle-launch-state none) @@ -31573,7 +31580,7 @@ ;; (define-extern check-drop-level-rain2 function) ;; (function sparticle-system sparticle-cpuinfo vector none) ;; (define-extern check-drop-level-splash function) ;; (function sparticle-system sparticle-cpuinfo vector none) ;; (define-extern update-rain function) ;; (function float vector vector none) -;; (define-extern cam-master-effect function) ;; (function none :behavior camera-master) +(define-extern cam-master-effect (function none :behavior camera-master)) ;; (define-extern sparticle-track-sun function) ;; (function int sparticle-cpuinfo matrix none) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -32340,76 +32347,74 @@ ;; camera ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; (define-extern cam-slave-get-vector-with-offset function) ;; (function entity-actor vector symbol symbol) -;; (define-extern cam-slave-get-flags function) ;; (function entity symbol uint) -;; (define-extern cam-slave-get-float function) ;; (function entity symbol float float) -;; (define-extern cam-slave-get-fov function) ;; (function entity float) -;; (define-extern cam-slave-get-intro-step function) ;; (function entity float) -;; (define-extern cam-slave-get-interp-time function) ;; (function entity float) -;; (define-extern cam-slave-get-rot function) ;; (function entity-actor matrix matrix) -;; (define-extern cam-state-from-entity function) ;; (function entity (state camera-slave)) -;; (define-extern parameter-ease-none function) ;; (function object object) -;; (define-extern parameter-ease-clamp function) ;; (function float float) -;; (define-extern parameter-ease-lerp-clamp function) ;; (function float float) -;; (define-extern parameter-ease-sqrt-clamp function) ;; (function float float) -;; (define-extern fourth-power function) ;; (function float float) -;; (define-extern third-power function) ;; (function float float) -;; (define-extern parameter-ease-sqr-clamp function) ;; (function float float) -;; (define-extern parameter-ease-cube-clamp function) ;; (function float float) -;; (define-extern parameter-ease-sin-clamp function) ;; (function float float) -;; (define-extern *cam-res-string* object) ;; string -;; (define-extern cam-slave-init-vars function) ;; (function none :behavior camera-slave) +(define-extern cam-slave-get-vector-with-offset (function entity-actor vector symbol symbol)) +(define-extern cam-slave-get-flags (function entity symbol uint)) +(define-extern cam-slave-get-float (function entity symbol float float)) +(define-extern cam-slave-get-fov (function entity float)) +(define-extern cam-slave-get-intro-step (function entity float)) +(define-extern cam-slave-get-interp-time (function entity float)) +(define-extern cam-slave-get-rot (function entity-actor matrix matrix)) +(define-extern cam-state-from-entity (function entity (state camera-slave))) +(define-extern parameter-ease-none (function object object)) +(define-extern parameter-ease-clamp (function float float)) +(define-extern parameter-ease-lerp-clamp (function float float)) +(define-extern parameter-ease-sqrt-clamp (function float float)) +(define-extern fourth-power (function float float)) +(define-extern third-power (function float float)) +(define-extern parameter-ease-sqr-clamp (function float float)) +(define-extern parameter-ease-cube-clamp (function float float)) +(define-extern parameter-ease-sin-clamp (function float float)) +(define-extern *cam-res-string* string) +(define-extern cam-slave-init-vars (function none :behavior camera-slave)) (define-extern cam-slave-go (function (state camera-slave) none :behavior camera-slave)) (define-extern cam-slave-init (function (state camera-slave) entity none :behavior camera-slave)) (define-extern cam-standard-event-handler (function process int symbol event-message-block object :behavior camera-slave)) -;; (define-extern cam-curve-pos function) ;; (function vector vector curve symbol vector :behavior camera-slave) -;; (define-extern cam-curve-setup function) ;; (function vector none :behavior camera-slave) +(define-extern cam-curve-pos (function vector vector curve symbol vector :behavior camera-slave)) +(define-extern cam-curve-setup (function vector none :behavior camera-slave)) (define-extern cam-calc-follow! (function cam-rotation-tracker vector symbol vector)) -;; (define-extern mat-remove-z-rot function) ;; (function matrix vector matrix) -;; (define-extern slave-matrix-blend-2 function) ;; (function matrix cam-slave-options-u32 vector matrix matrix) -;; (define-extern vector-into-frustum-nosmooth! function) ;; (function matrix vector float vector) +(define-extern mat-remove-z-rot (function matrix vector matrix)) +(define-extern slave-matrix-blend-2 (function matrix cam-slave-options-u32 vector matrix matrix)) +(define-extern vector-into-frustum-nosmooth! (function matrix vector float vector)) (define-extern slave-set-rotation! (function cam-rotation-tracker vector cam-slave-options-u32 float symbol none)) -;; (define-extern v-slrp2! function) ;; (function vector vector vector float vector float vector) -;; (define-extern v-slrp3! function) ;; (function vector vector vector vector float vector) +(define-extern v-slrp2! (function vector vector vector float vector float vector)) +(define-extern v-slrp3! (function vector vector vector vector float vector)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; cam-interface ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (define-extern position-in-front-of-camera! (function vector float float vector)) -;; (define-extern position-in-front-of-screen! function) ;; (function vector float vector vector) +(define-extern position-in-front-of-screen! (function vector float vector vector)) (define-extern matrix-local->world (function symbol symbol matrix)) (define-extern matrix-world->local (function symbol object matrix)) -;; (define-extern *camera-dummy-vector* object) ;; vector +(define-extern *camera-dummy-vector* vector) (define-extern camera-pos (function vector)) (define-extern math-camera-pos (function vector)) (define-extern camera-matrix (function matrix)) (define-extern math-camera-matrix (function matrix)) -;; (define-extern camera-angle function) ;; (function float) -;; (define-extern camera-teleport-to-entity function) ;; (function entity-actor symbol :behavior process) -;; (define-extern camera-teleport-to-entity-named function) -;; (define-extern camera-teleport-to-location function) +(define-extern camera-angle (function float)) +(define-extern camera-teleport-to-entity (function entity-actor symbol :behavior process)) +(define-extern camera-teleport-to-entity-named (function string none)) +(define-extern camera-teleport-to-location (function float float float none)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; cam-master ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; (define-extern reset-follow function) ;; (function float :behavior camera-master) -;; (define-extern reset-target-tracking function) ;; (function symbol :behavior camera-master) -;; (define-extern master-track-target function) ;; (function symbol :behavior camera-master) -;; (define-extern setup-slave-for-hopefull function) ;; (function camera-slave none) -;; (define-extern master-is-hopeful-better? function) ;; (function camera-slave camera-slave symbol :behavior camera-master) -;; (define-extern master-choose-entity function) ;; (function cam-setting-data symbol :behavior camera-master) +(define-extern reset-follow (function symbol object :behavior camera-master)) +(define-extern reset-target-tracking (function object :behavior camera-master)) +(define-extern master-track-target (function object :behavior camera-master)) +(define-extern setup-slave-for-hopefull (function camera-slave none)) +(define-extern master-is-hopeful-better? (function camera-slave camera-slave symbol :behavior camera-master)) +(define-extern master-choose-entity (function cam-setting-data symbol :behavior camera-master)) (define-extern cam-master-set-entity (function cam-setting-data none)) (define-extern cam-master-activate-slave (function symbol none)) -;; (define-extern cam-master-active state) ;; (state camera-master) -;; (define-extern cam-master-init function) ;; (function none :behavior camera-master) +(define-extern cam-master-init (function none :behavior camera-master)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; cam-states ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype cam-eye-bank (basic) ((rot-speed float :offset-assert 4) (max-degrees float :offset-assert 8) @@ -32420,9 +32425,7 @@ :size-assert #x14 :flag-assert #x900000014 ) -|# -#| (deftype cam-string-bank (basic) ((los-coll-rad meters :offset-assert 4) (los-coll-rad2 meters :offset-assert 8) @@ -32431,9 +32434,7 @@ :size-assert #xc :flag-assert #x90000000c ) -|# -#| (deftype los-dist (structure) ((par-dist float :offset-assert 0) (lat-dist float :offset-assert 4) @@ -32443,9 +32444,7 @@ :size-assert #xc :flag-assert #x90000000c ) -|# -#| (deftype collide-los-dist-info (structure) ((min-par float :offset-assert 0) (max-par float :offset-assert 4) @@ -32461,9 +32460,7 @@ :size-assert #x24 :flag-assert #x900000024 ) -|# -#| (deftype collide-los-result (structure) ((lateral vector :inline :offset-assert 0) (cw collide-los-dist-info :inline :offset-assert 16) @@ -32475,9 +32472,7 @@ :size-assert #x98 :flag-assert #x900000098 ) -|# -#| (deftype cam-stick-bank (basic) ((max-z meters :offset-assert 4) (min-z meters :offset-assert 8) @@ -32488,9 +32483,7 @@ :size-assert #x14 :flag-assert #x900000014 ) -|# -#| (deftype cam-bike-bank (basic) ((min-z meters :offset-assert 4) (max-z meters :offset-assert 8) @@ -32501,68 +32494,62 @@ :size-assert #x14 :flag-assert #x900000014 ) -|# -;; (define-extern cam-standoff-calc-trans function) ;; (function vector :behavior camera-slave) -;; (define-extern *CAM_EYE-bank* cam-eye-bank) ;; cam-eye-bank -;; (define-extern cam-curve-closest-point function) -;; (define-extern cam-circular-position-into-max-angle function) ;; (function vector vector float vector :behavior camera-slave) -;; (define-extern cam-circular-position function) ;; (function symbol vector :behavior camera-slave) -;; (define-extern cam-circular-code function) ;; (function float :behavior camera-slave) -;; (define-extern *CAM_STRING-bank* cam-string-bank) ;; cam-string-bank -;; (define-extern cam-string-find-position-rel! function) ;; (function vector symbol) -;; (define-extern cam-string-set-position-rel! function) ;; (function vector cam-slave-options :behavior camera-slave) -;; (define-extern string-push-help function) ;; (function float) -;; (define-extern cam-draw-collide-cache function) ;; (function collide-cache none) -;; (define-extern dist-info-init function) ;; (function collide-los-dist-info none) -;; (define-extern dist-info-valid? function) ;; (function collide-los-dist-info symbol) -;; (define-extern dist-info-append function) ;; (function collide-los-dist-info vector none) -;; (define-extern dist-info-print function) ;; (function collide-los-dist-info string object) -;; (define-extern los-cw-ccw function) ;; (function (inline-array collide-cache-tri) vector vector float collide-los-result vector float symbol :behavior camera-slave) -;; (define-extern cam-los-spline-collide function) ;; (function vector vector pat-surface float) -;; (define-extern cam-los-setup-lateral function) ;; (function collide-los-result vector vector symbol :behavior camera-slave) -;; (define-extern cam-los-collide function) ;; (function vector vector collide-los-result pat-surface symbol :behavior camera-slave) -;; (define-extern cam-string-follow function) ;; (function object :behavior camera-slave) -;; (define-extern cam-string-line-of-sight function) ;; (function vector :behavior camera-slave) -;; (define-extern cam-dist-analog-input function) ;; (function int float float) -;; (define-extern cam-string-joystick function) ;; (function float :behavior camera-slave) -;; (define-extern cam-string-find-hidden function) ;; (function none :behavior camera-slave) -;; (define-extern cam-string-move function) ;; (function object :behavior camera-slave) -;; (define-extern cam-string-code function) ;; (function vector :behavior camera-slave) -;; (define-extern set-string-params function) ;; (function vector :behavior camera-slave) -;; (define-extern *CAM_STICK-bank* cam-stick-bank) ;; cam-stick-bank -;; (define-extern cam-stick-code function) ;; (function none :behavior camera-slave) -;; (define-extern *CAM_BIKE-bank* cam-bike-bank) ;; cam-bike-bank -;; (define-extern cam-calc-bike-follow! function) ;; (function cam-rotation-tracker vector symbol vector :behavior camera-slave) -;; (define-extern cam-bike-code function) ;; (function none :behavior camera-slave) +(define-extern cam-standoff-calc-trans (function vector :behavior camera-slave)) +(define-extern *CAM_EYE-bank* cam-eye-bank) +(define-extern cam-curve-closest-point (function curve vector float float int float)) +(define-extern cam-circular-position-into-max-angle (function vector vector float vector :behavior camera-slave)) +(define-extern cam-circular-position (function symbol vector :behavior camera-slave)) +(define-extern cam-circular-code (function float :behavior camera-slave)) +(define-extern *CAM_STRING-bank* cam-string-bank) +(define-extern cam-string-find-position-rel! (function vector symbol)) +(define-extern cam-string-set-position-rel! (function vector cam-slave-options :behavior camera-slave)) +(define-extern string-push-help (function float)) +(define-extern cam-draw-collide-cache (function collide-cache none)) +(define-extern dist-info-init (function collide-los-dist-info none)) +(define-extern dist-info-valid? (function collide-los-dist-info symbol)) +(define-extern dist-info-append (function collide-los-dist-info vector none)) +(define-extern dist-info-print (function collide-los-dist-info string object)) +(define-extern los-cw-ccw (function (inline-array collide-cache-tri) vector vector float collide-los-result vector float symbol :behavior camera-slave)) +(define-extern cam-los-spline-collide (function vector vector pat-surface float)) +(define-extern cam-los-setup-lateral (function collide-los-result vector vector symbol :behavior camera-slave)) +(define-extern cam-los-collide (function vector vector collide-los-result pat-surface symbol :behavior camera-slave)) +(define-extern cam-string-follow (function object :behavior camera-slave)) +(define-extern cam-string-line-of-sight (function vector :behavior camera-slave)) +(define-extern cam-dist-analog-input (function int float float)) +(define-extern cam-string-joystick (function float :behavior camera-slave)) +(define-extern cam-string-find-hidden (function none :behavior camera-slave)) +(define-extern cam-string-move (function object :behavior camera-slave)) +(define-extern cam-string-code (function object :behavior camera-slave)) +(define-extern set-string-params (function vector :behavior camera-slave)) +(define-extern *CAM_STICK-bank* cam-stick-bank) +(define-extern cam-stick-code (function none :behavior camera-slave)) +(define-extern *CAM_BIKE-bank* cam-bike-bank) +(define-extern cam-calc-bike-follow! (function cam-rotation-tracker vector symbol vector :behavior camera-slave)) +(define-extern cam-bike-code (function none :behavior camera-slave)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; cam-states-dbg ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype cam-point-watch-bank (basic) - ((speed float :offset-assert 4) - (rot-speed deg :offset-assert 8) ;; degrees + ((speed float :offset-assert 4) + (rot-speed degrees :offset-assert 8) ;; degrees ) :method-count-assert 9 :size-assert #xc :flag-assert #x90000000c ) -|# -#| (deftype cam-free-bank (basic) - ((speed float :offset-assert 4) - (rot-speed deg :offset-assert 8) ;; degrees + ((speed float :offset-assert 4) + (rot-speed degrees :offset-assert 8) ;; degrees ) :method-count-assert 9 :size-assert #xc :flag-assert #x90000000c ) -|# -#| (deftype camera-free-floating-move-info (structure) ((rv vector :inline :offset-assert 0) (tv vector :inline :offset-assert 16) @@ -32573,40 +32560,38 @@ :size-assert #x70 :flag-assert #x900000070 ) -|# -;; (define-extern *CAM_POINT_WATCH-bank* cam-point-watch-bank) ;; cam-point-watch-bank -;; (define-extern *CAM_FREE-bank* cam-free-bank) ;; cam-free-bank -;; (define-extern cam-mouse-input function) ;; (function vector vector float) -;; (define-extern cam-free-floating-input function) ;; (function vector vector symbol int vector) -;; (define-extern cam-free-floating-move function) ;; (function matrix vector vector int vector) +(define-extern *CAM_POINT_WATCH-bank* cam-point-watch-bank) +(define-extern *CAM_FREE-bank* cam-free-bank) +(define-extern cam-mouse-input (function matrix vector vector object)) +(define-extern cam-free-floating-input (function matrix vector vector int int vector)) +(define-extern cam-free-floating-move (function matrix vector vector int vector)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; cam-combiner ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; (define-extern cam-helper-temp function) ;; (function (pointer camera-slave) (pointer camera-slave) float matrix :behavior camera-combiner) -;; (define-extern cam-combiner-active state) ;; (state camera-combiner) -;; (define-extern cam-combiner-init function) ;; (function none :behavior camera-combiner) +(define-extern cam-helper-temp (function (pointer camera-slave) (pointer camera-slave) float matrix :behavior camera-combiner)) +(define-extern cam-combiner-init (function none :behavior camera-combiner)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; cam-update ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; (define-extern plane-from-points function) ;; (function (inline-array plane) vector vector vector int float) -;; (define-extern set-point function) ;; (function vector float float float float) -;; (define-extern update-view-planes function) ;; (function math-camera (inline-array plane) float matrix float) -;; (define-extern *update-leaf-when-outside-bsp* object) ;; symbol -;; (define-extern update-visible function) ;; (function math-camera symbol) -;; (define-extern *save-camera-inv-rot* object) ;; matrix -;; (define-extern move-camera-from-pad function) ;; (function math-camera math-camera) -;; (define-extern external-cam-reset! function) ;; (function none) -;; (define-extern *start-timer* object) ;; int -;; (define-extern *timer-value* object) ;; int -;; (define-extern *start-pos* object) ;; vector -;; (define-extern update-camera function) ;; (function symbol) -;; (define-extern move-level-by-name function) ;; (function symbol float float float vector) -;; (define-extern execute-cam-post-hook-engine function) +(define-extern plane-from-points (function (inline-array plane) vector vector vector int float)) +(define-extern set-point (function vector float float float float)) +(define-extern update-view-planes (function math-camera (inline-array plane) float matrix float)) +(define-extern *update-leaf-when-outside-bsp* symbol) +(define-extern update-visible (function math-camera symbol)) +(define-extern *save-camera-inv-rot* matrix) +(define-extern move-camera-from-pad (function math-camera math-camera)) +(define-extern external-cam-reset! (function none)) +(define-extern *start-timer* int) +(define-extern *timer-value* int) +(define-extern *start-pos* vector) +(define-extern update-camera (function symbol)) +(define-extern move-level-by-name (function symbol float float float vector)) +(define-extern execute-cam-post-hook-engine (function int)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; vol-h ;; @@ -32666,7 +32651,6 @@ ;; cam-layout ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype cam-layout-bank (basic) ((spline-t float :offset-assert 4) (spline-step float :offset-assert 8) @@ -32679,33 +32663,52 @@ :size-assert #x1c :flag-assert #x90000001c ) -|# -#| (deftype clm-basic (basic) () :method-count-assert 9 :size-assert #x4 :flag-assert #x900000004 ) -|# -#| +;; +++cam-layout:clm-item-action-options +(defenum clm-item-action-options + :type uint64 + :bitfield #t + (clm0 0) + (clm1 1) + (clm2 2) + (clm3 3) + (clm4 4) + (clm5 5) + (clm6 6) + (clm7 7) + ) +;; ---cam-layout:clm-item-action-options + +;; +++cam-layout:pad-buttons-u64 +(defenum pad-buttons-u64 + :type uint64 + :bitfield #t + :copy-entries pad-buttons + ) +;; ---cam-layout:pad-buttons-u64 + (deftype clm-item-action (structure) - ((button uint64 :offset-assert 0) - (options uint64 :offset-assert 8) + ((button pad-buttons-u64 :offset-assert 0) + (options clm-item-action-options :offset-assert 8) (func symbol :offset-assert 16) ;; guessed by decompiler (parm0 int32 :offset-assert 20) ;; guessed by decompiler + (parm0-sym symbol :offset 20) (parm1 symbol :offset-assert 24) ;; guessed by decompiler + (parm1-basic basic :offset 24) ) :method-count-assert 9 :size-assert #x1c :flag-assert #x90000001c ;; field parm0 uses ~A with a signed load. field parm1 uses ~A with a signed load. ) -|# -#| (deftype clm-item (clm-basic) ((description string :offset-assert 4) ;; guessed by decompiler (button-symbol symbol :offset-assert 8) ;; guessed by decompiler @@ -32715,14 +32718,13 @@ :size-assert #x2c :flag-assert #x90000002c ) -|# -#| (deftype clm-list-item (basic) ((description string :offset-assert 4) ;; guessed by decompiler (track-val symbol :offset-assert 8) ;; guessed by decompiler (val-func symbol :offset-assert 12) ;; guessed by decompiler (val-parm0 int32 :offset-assert 16) ;; guessed by decompiler + (val-parm0-sym symbol :offset 16) (val-parm1 symbol :offset-assert 20) ;; guessed by decompiler (actions (array clm-item-action) :offset-assert 24) ;; guessed by decompiler ) @@ -32731,9 +32733,7 @@ :flag-assert #x90000001c ;; field track-val uses ~A with a signed load. field val-parm0 uses ~A with a signed load. field val-parm1 uses ~A with a signed load. ) -|# -#| (deftype clm-list (clm-basic) ((tracker symbol :offset-assert 4) ;; guessed by decompiler (cur-list-item int32 :offset-assert 8) @@ -32743,9 +32743,7 @@ :size-assert #x10 :flag-assert #x900000010 ) -|# -#| (deftype clm (basic) ((title string :offset-assert 4) ;; guessed by decompiler (items (array clm-basic) :offset-assert 8) ;; guessed by decompiler @@ -32754,19 +32752,15 @@ :size-assert #xc :flag-assert #x90000000c ) -|# -#| (deftype volume-descriptor-array (inline-array-class) - ((data plane-volume :dynamic :offset-assert 16) ;; guessed by decompiler + ((data plane-volume :dynamic :inline :offset-assert 16) ;; guessed by decompiler ) :method-count-assert 14 :size-assert #x10 :flag-assert #xe00000010 ) -|# -#| (deftype cam-layout (process) ((cam-entity entity-camera :offset-assert 128) ;; guessed by decompiler (num-entities int32 :offset-assert 132) @@ -32781,12 +32775,10 @@ :size-assert #xa0 :flag-assert #xe002000a0 (:states - cam-layout-active ;; associated process guessed by decompiler, old: (state cam-layout) + cam-layout-active ) ) -|# -#| (deftype interp-test-info (structure) ((from vector :inline :offset-assert 0) (to vector :inline :offset-assert 16) @@ -32799,9 +32791,7 @@ :size-assert #x3c :flag-assert #x90000003c ) -|# -#| (deftype clmf-cam-flag-toggle-info (structure) ((key float :offset-assert 0) (force-on int32 :offset-assert 4) @@ -32811,97 +32801,96 @@ :size-assert #xc :flag-assert #x90000000c ) -|# -;; (define-extern *camera-layout-blink* object) ;; symbol -;; (define-extern *CAM_LAYOUT-bank* cam-layout-bank) ;; cam-layout-bank -;; (define-extern *camera-layout-message-ypos* object) ;; int -;; (define-extern *volume-point-current* object) ;; int -;; (define-extern *volume-point* object) ;; vector-array -;; (define-extern *volume-normal-current* object) ;; int -;; (define-extern *volume-normal* object) ;; vector-array -;; (define-extern *volume-descriptor-current* object) ;; int -;; (define-extern *volume-descriptor* object) ;; vol-control -;; (define-extern cam-layout-print function) ;; (function int int string pointer) -;; (define-extern cam-layout-intersect-dist function) ;; (function vector vector vector float) -;; (define-extern cam-layout-entity-volume-info-create function) ;; (function entity-camera symbol symbol :behavior cam-layout) -;; (define-extern cam-layout-entity-volume-info function) ;; (function symbol :behavior cam-layout) -;; (define-extern v-slrp! function) ;; (function vector vector vector float vector) -;; (define-extern interp-test function) ;; (function (function vector vector vector float vector float none) interp-test-info none) -;; (define-extern interp-test-deg function) ;; (function (function vector vector vector vector float none) interp-test-info none) -;; (define-extern cam-layout-entity-info function) ;; (function entity-actor none) -;; (define-extern clmf-button-test function) ;; (function symbol) -;; (define-extern clmf-bna function) ;; (function symbol) -;; (define-extern clmf-implement function) ;; (function symbol) -;; (define-extern clmf-input function) ;; (function vector vector int vector) -;; (define-extern clmf-pos-rot function) ;; (function symbol symbol symbol :behavior cam-layout) -;; (define-extern clmf-next-volume function) ;; (function int symbol :behavior cam-layout) -;; (define-extern clmf-next-vol-dpad function) ;; (function symbol) -;; (define-extern clmf-to-edit-cam function) ;; (function symbol) -;; (define-extern *last-cur-entity* object) ;; int -;; (define-extern clmf-next-entity function) ;; (function int symbol :behavior cam-layout) -;; (define-extern clmf-to-spline-attr function) ;; (function symbol) -;; (define-extern clmf-to-intro-attr function) ;; (function symbol) -;; (define-extern clmf-to-index-attr function) ;; (function symbol) -;; (define-extern clmf-to-focalpull-attr function) ;; (function symbol) -;; (define-extern clmf-to-edit function) ;; (function symbol :behavior cam-layout) -;; (define-extern clmf-to-select function) ;; (function symbol) -;; (define-extern clmf-look-through function) ;; (function symbol :behavior cam-layout) -;; (define-extern fov->maya function) ;; (function float float) -;; (define-extern cam-layout-save-cam-rot function) ;; (function symbol string entity-actor none) -;; (define-extern cam-layout-save-cam-trans function) ;; (function symbol string entity-actor none) -;; (define-extern cam-layout-save-pivot function) ;; (function symbol string entity-actor none) -;; (define-extern cam-layout-save-align function) ;; (function symbol string entity-actor none) -;; (define-extern cam-layout-save-interesting function) ;; (function symbol string entity-actor none) -;; (define-extern cam-layout-save-fov function) ;; (function symbol string entity-actor none) -;; (define-extern cam-layout-save-focalpull function) ;; (function symbol string entity-actor none) -;; (define-extern cam-layout-save-flags function) ;; (function symbol string entity-actor none) -;; (define-extern cam-layout-save-focalpull-flags function) ;; (function symbol string entity-actor none) -;; (define-extern cam-layout-save-campoints-flags function) ;; (function symbol string entity-actor none) -;; (define-extern cam-layout-save-introsplinetime function) ;; (function symbol string entity-actor none) -;; (define-extern cam-layout-save-introsplineexitval function) ;; (function symbol string entity-actor none) -;; (define-extern cam-layout-save-interptime function) ;; (function symbol string entity-actor none) -;; (define-extern cam-layout-save-splineoffset function) ;; (function symbol string entity-actor none) -;; (define-extern cam-layout-save-spline-follow-dist-offset function) ;; (function symbol string entity-actor none) -;; (define-extern cam-layout-save-campointsoffset function) ;; (function symbol string entity-actor none) -;; (define-extern cam-layout-save-tiltAdjust function) ;; (function symbol string entity-actor none) -;; (define-extern cam-layout-save-stringMinLength function) ;; (function symbol string entity-actor none) -;; (define-extern cam-layout-save-stringMaxLength function) ;; (function symbol string entity-actor none) -;; (define-extern cam-layout-save-stringMinHeight function) ;; (function symbol string entity-actor none) -;; (define-extern cam-layout-save-stringMaxHeight function) ;; (function symbol string entity-actor none) -;; (define-extern cam-layout-save-stringCliffHeight function) ;; (function symbol string entity-actor none) -;; (define-extern cam-layout-save-maxAngle function) ;; (function symbol string entity-actor none) -;; (define-extern clmf-save-single function) ;; (function entity-camera symbol symbol file-stream :behavior cam-layout) -;; (define-extern clmf-save-one function) ;; (function symbol symbol :behavior cam-layout) -;; (define-extern clmf-save-all function) ;; (function symbol symbol :behavior cam-layout) -;; (define-extern clmf-cam-flag-toggle function) ;; (function int int symbol :behavior cam-layout) -;; (define-extern clmf-cam-flag function) ;; (function string uint uint symbol :behavior cam-layout) -;; (define-extern clmf-cam-float-adjust function) ;; (function symbol (pointer float) symbol :behavior cam-layout) -;; (define-extern clmf-cam-meters function) ;; (function meters symbol symbol :behavior cam-layout) -;; (define-extern clmf-cam-fov function) ;; (function degrees symbol symbol :behavior cam-layout) -;; (define-extern clmf-cam-deg function) ;; (function degrees symbol symbol :behavior cam-layout) -;; (define-extern clmf-cam-intro-time function) ;; (function float symbol symbol :behavior cam-layout) -;; (define-extern clmf-cam-interp-time function) ;; (function float symbol symbol :behavior cam-layout) -;; (define-extern clmf-cam-float function) ;; (function float symbol symbol :behavior cam-layout) -;; (define-extern clmf-cam-string function) ;; (function string symbol symbol :behavior cam-layout) -;; (define-extern *clm-focalpull-attr* clm) ;; clm -;; (define-extern *clm-index-attr* clm) ;; clm -;; (define-extern *clm-intro-attr* clm) ;; clm -;; (define-extern *clm-spline-attr* clm) ;; clm -;; (define-extern *clm-cam-attr* clm) ;; clm -;; (define-extern *clm-cam-lookthrough* clm) ;; clm -;; (define-extern *clm-edit* clm) ;; clm -;; (define-extern *clm-save-all* clm) ;; clm -;; (define-extern *clm-save-one* clm) ;; clm -;; (define-extern *clm-select* clm) ;; clm -;; (define-extern *clm* object) ;; clm -;; (define-extern cam-layout-do-action function) ;; (function clm-item-action symbol :behavior cam-layout) -;; (define-extern cam-layout-function-call function) ;; (function symbol string int basic symbol :behavior cam-layout) -;; (define-extern cam-layout-do-menu function) ;; (function clm symbol :behavior cam-layout) -;; (define-extern cam-layout-init function) ;; (function object :behavior cam-layout) -;; (define-extern cam-layout-stop function) ;; (function symbol) -;; (define-extern cam-layout-start function) ;; (function symbol) -;; (define-extern cam-layout-restart function) ;; (function symbol) +(define-extern *camera-layout-blink* symbol) +(define-extern *CAM_LAYOUT-bank* cam-layout-bank) +(define-extern *camera-layout-message-ypos* int) +(define-extern *volume-point-current* int) +(define-extern *volume-point* vector-array) +(define-extern *volume-normal-current* int) +(define-extern *volume-normal* vector-array) +(define-extern *volume-descriptor-current* int) +(define-extern *volume-descriptor* vol-control) +(define-extern cam-layout-print (function int int string pointer)) +(define-extern cam-layout-intersect-dist (function vector vector vector float)) +(define-extern cam-layout-entity-volume-info-create (function entity-camera symbol symbol :behavior cam-layout)) +(define-extern cam-layout-entity-volume-info (function symbol :behavior cam-layout)) +(define-extern v-slrp! (function vector vector vector float vector)) +(define-extern interp-test (function (function vector vector vector float vector float none) interp-test-info none)) +(define-extern interp-test-deg (function (function vector vector vector vector float none) interp-test-info none)) +(define-extern cam-layout-entity-info (function entity-actor none)) +(define-extern clmf-button-test (function symbol)) +(define-extern clmf-bna (function symbol)) +(define-extern clmf-implement (function symbol)) +(define-extern clmf-input (function vector vector int vector)) +(define-extern clmf-pos-rot (function symbol symbol symbol :behavior cam-layout)) +(define-extern clmf-next-volume (function int symbol :behavior cam-layout)) +(define-extern clmf-next-vol-dpad (function symbol)) +(define-extern clmf-to-edit-cam (function symbol)) +(define-extern *last-cur-entity* int) +(define-extern clmf-next-entity (function int symbol :behavior cam-layout)) +(define-extern clmf-to-spline-attr (function symbol)) +(define-extern clmf-to-intro-attr (function symbol)) +(define-extern clmf-to-index-attr (function symbol)) +(define-extern clmf-to-focalpull-attr (function symbol)) +(define-extern clmf-to-edit (function symbol :behavior cam-layout)) +(define-extern clmf-to-select (function symbol)) +(define-extern clmf-look-through (function symbol :behavior cam-layout)) +(define-extern fov->maya (function float float)) +(define-extern cam-layout-save-cam-rot (function symbol string entity-actor none)) +(define-extern cam-layout-save-cam-trans (function symbol string entity-actor none)) +(define-extern cam-layout-save-pivot (function symbol string entity-actor none)) +(define-extern cam-layout-save-align (function symbol string entity-actor none)) +(define-extern cam-layout-save-interesting (function symbol string entity-actor none)) +(define-extern cam-layout-save-fov (function symbol string entity-actor none)) +(define-extern cam-layout-save-focalpull (function symbol string entity-actor none)) +(define-extern cam-layout-save-flags (function symbol string entity-actor none)) +(define-extern cam-layout-save-focalpull-flags (function symbol string entity-actor none)) +(define-extern cam-layout-save-campoints-flags (function symbol string entity-actor none)) +(define-extern cam-layout-save-introsplinetime (function symbol string entity-actor none)) +(define-extern cam-layout-save-introsplineexitval (function symbol string entity-actor none)) +(define-extern cam-layout-save-interptime (function symbol string entity-actor none)) +(define-extern cam-layout-save-splineoffset (function symbol string entity-actor none)) +(define-extern cam-layout-save-spline-follow-dist-offset (function symbol string entity-actor none)) +(define-extern cam-layout-save-campointsoffset (function symbol string entity-actor none)) +(define-extern cam-layout-save-tiltAdjust (function symbol string entity-actor none)) +(define-extern cam-layout-save-stringMinLength (function symbol string entity-actor none)) +(define-extern cam-layout-save-stringMaxLength (function symbol string entity-actor none)) +(define-extern cam-layout-save-stringMinHeight (function symbol string entity-actor none)) +(define-extern cam-layout-save-stringMaxHeight (function symbol string entity-actor none)) +(define-extern cam-layout-save-stringCliffHeight (function symbol string entity-actor none)) +(define-extern cam-layout-save-maxAngle (function symbol string entity-actor none)) +(define-extern clmf-save-single (function entity-camera symbol symbol file-stream :behavior cam-layout)) +(define-extern clmf-save-one (function symbol symbol :behavior cam-layout)) +(define-extern clmf-save-all (function symbol symbol :behavior cam-layout)) +(define-extern clmf-cam-flag-toggle (function int int symbol :behavior cam-layout)) +(define-extern clmf-cam-flag (function string uint uint symbol :behavior cam-layout)) +(define-extern clmf-cam-float-adjust (function symbol (pointer float) symbol :behavior cam-layout)) +(define-extern clmf-cam-meters (function meters symbol symbol :behavior cam-layout)) +(define-extern clmf-cam-fov (function degrees symbol symbol :behavior cam-layout)) +(define-extern clmf-cam-deg (function degrees symbol symbol :behavior cam-layout)) +(define-extern clmf-cam-intro-time (function float symbol symbol :behavior cam-layout)) +(define-extern clmf-cam-interp-time (function float symbol symbol :behavior cam-layout)) +(define-extern clmf-cam-float (function float symbol symbol :behavior cam-layout)) +(define-extern clmf-cam-string (function string symbol symbol :behavior cam-layout)) +(define-extern *clm-focalpull-attr* clm) +(define-extern *clm-index-attr* clm) +(define-extern *clm-intro-attr* clm) +(define-extern *clm-spline-attr* clm) +(define-extern *clm-cam-attr* clm) +(define-extern *clm-cam-lookthrough* clm) +(define-extern *clm-edit* clm) +(define-extern *clm-save-all* clm) +(define-extern *clm-save-one* clm) +(define-extern *clm-select* clm) +(define-extern *clm* clm) +(define-extern cam-layout-do-action (function clm-item-action object :behavior cam-layout)) +(define-extern cam-layout-function-call (function symbol string int basic symbol :behavior cam-layout)) +(define-extern cam-layout-do-menu (function clm symbol :behavior cam-layout)) +(define-extern cam-layout-init (function object :behavior cam-layout)) +(define-extern cam-layout-stop (function symbol)) +(define-extern cam-layout-start (function symbol)) +(define-extern cam-layout-restart (function symbol)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; cam-debug ;; @@ -32985,42 +32974,42 @@ ;; (define-extern *camera-old-stat-string-tfrag* object) ;; string ;; (define-extern *camera-old-stat-string-tfrag-near* object) ;; string ;; (define-extern *camera-old-stat-string-total* object) ;; string -;; (define-extern cam-slave-options->string function) ;; (function cam-slave-options object string) -;; (define-extern cam-index-options->string function) ;; (function cam-index-options object string) -;; (define-extern slave-los-state->string function) ;; (function slave-los-state string) +(define-extern cam-slave-options->string (function cam-slave-options object string)) +(define-extern cam-index-options->string (function cam-index-options object string)) +(define-extern slave-los-state->string (function slave-los-state string)) ;; (define-extern cam-line-dma function) ;; (function pointer) ;; (define-extern camera-line2d function) ;; (function vector4w vector4w pointer) ;; (define-extern camera-plot-float-func function) ;; (function float float float float (function float float) vector4w none) -;; (define-extern camera-line-setup function) ;; (function vector4w none) -;; (define-extern camera-line-draw function) ;; (function vector vector none) -;; (define-extern camera-line function) ;; (function vector vector vector4w none) -;; (define-extern camera-line-rel function) ;; (function vector vector vector4w none) -;; (define-extern camera-line-rel-len function) ;; (function vector vector float vector4w none) +(define-extern camera-line-setup (function vector4w none)) +(define-extern camera-line-draw (function vector vector none)) +(define-extern camera-line (function vector vector vector4w none)) +(define-extern camera-line-rel (function vector vector vector4w none)) +(define-extern camera-line-rel-len (function vector vector float vector4w none)) ;; (define-extern camera-sphere function) ;; (function vector float vector4w none) -;; (define-extern camera-cross function) ;; (function vector vector vector vector4w meters none) +(define-extern camera-cross (function vector vector vector vector4w meters none)) ;; (define-extern camera-bounding-box-draw function) ;; (function bounding-box basic rgba none) ;; (define-extern *cam-debug-los-tri-current* object) ;; int ;; (define-extern *cam-debug-los-tri* object) ;; (inline-array cam-debug-tri) ;; (define-extern *cam-debug-coll-tri-current* object) ;; int ;; (define-extern *cam-debug-coll-tri* object) ;; (inline-array cam-debug-tri) -;; (define-extern cam-debug-reset-coll-tri function) ;; (function none) -;; (define-extern cam-debug-add-los-tri function) ;; (function (inline-array collide-cache-tri) vector vector none) +(define-extern cam-debug-reset-coll-tri (function none)) +(define-extern cam-debug-add-los-tri (function (inline-array collide-cache-tri) vector vector none)) ;; (define-extern cam-debug-add-coll-tri function) ;; (function cam-debug-tri vector cam-debug-tri none) ;; (define-extern cam-debug-draw-tris function) ;; (function symbol) ;; (define-extern camera-fov-draw function) ;; (function int int vector float float vector4w none) -;; (define-extern camera-fov-frame function) ;; (function matrix vector float float float vector4w symbol) +(define-extern camera-fov-frame (function matrix vector float float float vector4w symbol)) ;; (define-extern debug-euler function) ;; (function cam-dbg-scratch object) ;; (define-extern bike-cam-limit function) ;; (function float float) -;; (define-extern camera-slave-debug function) ;; (function camera-slave none) +(define-extern camera-slave-debug (function camera-slave none)) ;; (define-extern master-draw-coordinates function) ;; (function vector none) ;; (define-extern *cam-collision-record-first* object) ;; int ;; (define-extern *cam-collision-record-last* object) ;; int ;; (define-extern *cam-collision-record-show* object) ;; int ;; (define-extern *cam-collision-record* object) ;; cam-collision-record-array -;; (define-extern cam-collision-record-save function) ;; (function vector vector int symbol camera-slave none) +(define-extern cam-collision-record-save (function vector vector int symbol camera-slave none)) ;; (define-extern cam-collision-record-step function) ;; (function int none) ;; (define-extern cam-collision-record-draw function) ;; (function none) -;; (define-extern camera-master-debug function) ;; (function camera-master none) +(define-extern camera-master-debug (function camera-master none)) (define-extern debug-set-camera-pos-rot! (function vector matrix vector)) ;; (define-extern cam-restore function) ;; (function none) ;; (define-extern cam-restore-generic-bug function) @@ -35233,7 +35222,7 @@ (define-extern vector-turn-to (function vector vector :behavior target)) (define-extern reverse-conversions (function vector none :behavior target)) (define-extern draw-history (function control-info none)) -(define-extern target-history-print function) +(define-extern target-history-print (function history-iterator symbol)) (define-extern target-print-stats (function target symbol symbol)) (define-extern read-pad (function vector vector :behavior target)) (define-extern set-pad (function vector vector :behavior target)) diff --git a/decompiler/config/jak3/ntsc_v1/anonymous_function_types.jsonc b/decompiler/config/jak3/ntsc_v1/anonymous_function_types.jsonc index 8681a584f84..c6647d3353e 100644 --- a/decompiler/config/jak3/ntsc_v1/anonymous_function_types.jsonc +++ b/decompiler/config/jak3/ntsc_v1/anonymous_function_types.jsonc @@ -123,5 +123,6 @@ "collectables": [ [77, "(function part-tracker vector)"], [78, "(function part-tracker vector)"] - ] + ], + "trajectory": [[15, "(function trajectory none)"]] } diff --git a/decompiler/config/jak3/ntsc_v1/hacks.jsonc b/decompiler/config/jak3/ntsc_v1/hacks.jsonc index bdb8a930e43..05cde607495 100644 --- a/decompiler/config/jak3/ntsc_v1/hacks.jsonc +++ b/decompiler/config/jak3/ntsc_v1/hacks.jsonc @@ -37,8 +37,6 @@ // checking boxed type is different now - these make the cfg stuff sad "name=", "(method 77 grenadier)", - // until loop without nop: - "target-history-print", "display-list-control", "anim-test-anim-list-handler", "anim-test-sequence-list-handler", diff --git a/decompiler/config/jak3/ntsc_v1/label_types.jsonc b/decompiler/config/jak3/ntsc_v1/label_types.jsonc index d47b6de9592..ca3dcf5eb71 100644 --- a/decompiler/config/jak3/ntsc_v1/label_types.jsonc +++ b/decompiler/config/jak3/ntsc_v1/label_types.jsonc @@ -285,5 +285,34 @@ ["L287", "(inline-array vector)", 3], ["L283", "(inline-array vector)", 32], ["L265", "(inline-array vector)", 4] - ] + ], + "cam-states": [ + ["L821", "uint64", true], + ["L818", "uint64", true], + ["L820", "uint64", true], + ["L819", "uint64", true] + ], + "cam-states-dbg": [ + ["L59", "vector"], + ["L60", "vector"] + ], + "cam-layout": [ + ["L893", "uint64", true], + ["L899", "uint64", true], + ["L897", "uint64", true], + ["L892", "uint64", true], + ["L895", "uint64", true], + ["L894", "uint64", true], + ["L898", "uint64", true], + ["L896", "uint64", true], + ["L889", "uint64", true], + ["L785", "vector"], + ["L802", "vector4w"], + ["L800", "vector4w"], + ["L798", "vector4w"], + ["L796", "vector4w"], + ["L794", "vector4w"], + ["L792", "vector4w"] + ], + "level": [["L1003", "uint64", true]] } diff --git a/decompiler/config/jak3/ntsc_v1/stack_structures.jsonc b/decompiler/config/jak3/ntsc_v1/stack_structures.jsonc index d24cb7cd668..564070dd995 100644 --- a/decompiler/config/jak3/ntsc_v1/stack_structures.jsonc +++ b/decompiler/config/jak3/ntsc_v1/stack_structures.jsonc @@ -296,5 +296,68 @@ [32, "vector"] ], "add-debug-points": [[16, "vector"]], - "add-debug-cursor": [[16, "vector"]] + "add-debug-cursor": [[16, "vector"]], + "(method 11 impact-control)": [[16, "touching-shapes-entry"]], + "(method 9 cubic-curve)": [[16, "trajectory"]], + "(method 10 cubic-curve)": [[16, "trajectory"]], + "(method 11 cubic-curve)": [[16, "trajectory"]], + "(method 12 cubic-curve)": [[16, "trajectory"]], + "(method 13 cubic-curve)": [[16, "trajectory"]], + "slave-set-rotation!": [ + [96, "vector"], + [112, "matrix"], + [176, "vector"] + ], + "v-slrp2!": [ + [32, "vector"], + [64, "matrix"] + ], + "v-slrp3!": [[32, "vector"]], + "(method 15 tracking-spline)": [ + [16, "tracking-spline-sampler"], + [32, "vector"] + ], + "(method 16 tracking-spline)": [ + [16, "tracking-spline-sampler"], + [32, "tracking-spline-sampler"] + ], + "(method 18 tracking-spline)": [[16, "tracking-spline-sampler"]], + "(code cam-eye)": [[112, "vector"]], + "(enter cam-circular)": [[32, "vector"]], + "cam-string-joystick": [ + [32, "vector"], + [48, "vector"] + ], + "cam-string-line-of-sight": [[192, "vector"]], + "cam-los-collide": [ + [592, "vector"], + [608, "vector"] + ], + "los-cw-ccw": [ + [48, ["inline-array", "vector", 4]], + [16, "vector"], + [32, "vector"], + [112, "vector"] + ], + "master-track-target": [[16, "vector"]], + "(code cam-point-watch)": [[16, "vector"]], + "cam-helper-temp": [[16, ["inline-array", "vector", 3]]], + "update-view-planes": [ + [208, "vector"], + [224, "vector"] + ], + "clmf-pos-rot": [[112, "matrix"]], + "cam-layout-entity-info": [[208, "vector"]], + "cam-layout-entity-volume-info-create": [ + [80, "vector"], + [128, "vector"], + [32, "vector"], + [48, "vector"], + [64, "vector"], + [96, "vector"], + [144, "vector"], + [112, "vector"] + ], + "(method 23 tracking-spline)": [[32, "vector"]], + "(method 21 tracking-spline)": [[16, "tracking-spline-sampler"]] } diff --git a/decompiler/config/jak3/ntsc_v1/type_casts.jsonc b/decompiler/config/jak3/ntsc_v1/type_casts.jsonc index adead7458cc..a0e5394c968 100644 --- a/decompiler/config/jak3/ntsc_v1/type_casts.jsonc +++ b/decompiler/config/jak3/ntsc_v1/type_casts.jsonc @@ -2156,5 +2156,231 @@ //[85, "a0", "dma-packet"], ["_stack_", 16, "dma-packet"], [91, "v1", "dma-packet"] - ] + ], + "target-history-print": [["_stack_", 32, "collide-status"]], + "(method 13 sync-linear)": [ + ["_stack_", 16, "res-tag"], + [27, "v0", "(pointer float)"] + ], + "(method 13 sync-eased)": [ + ["_stack_", 16, "res-tag"], + [31, "v0", "(pointer float)"] + ], + "(method 13 sync-paused)": [ + ["_stack_", 16, "res-tag"], + [29, "v0", "(pointer float)"] + ], + "(method 11 impact-control)": [ + [58, "v1", "collide-shape-prim"], + [66, "v1", "collide-shape-prim"] + ], + "cam-slave-get-vector-with-offset": [ + [59, "v0", "vector"], + [24, "v0", "vector"], + [69, "s3", "vector"] + ], + "cam-slave-get-interp-time": [[29, "f0", "float"]], + "cam-standard-event-handler": [ + [13, "gp", "(state camera-slave)"], + [19, "gp", "(state camera-slave)"], + [22, "gp", "(state camera-slave)"] + ], + "cam-calc-follow!": [ + ["_stack_", 144, "float"], + ["_stack_", 160, "float"] + ], + "(method 15 tracking-spline)": [ + [28, "a0", "int"], + [38, "a0", "int"] + ], + "(code cam-pov)": [ + [15, "a1", "process-drawable"], + [24, "a0", "process-drawable"] + ], + "(code cam-pov180)": [ + [15, "a1", "process-drawable"], + [23, "v1", "process-drawable"], + [45, "v1", "process-drawable"], + [58, "v1", "process-drawable"], + [80, "a1", "process-drawable"] + ], + "(code cam-pov-track)": [ + [19, "a1", "process-drawable"], + [30, "a0", "process-drawable"] + ], + "(event cam-string)": [ + [11, "v1", "vector"], + [44, "s5", "vector"], + [51, "s5", "vector"], + [53, "s5", "vector"], + [62, "s5", "vector"], + [69, "s5", "vector"], + [71, "s5", "vector"], + [80, "gp", "vector"], + [87, "gp", "vector"], + [89, "gp", "vector"], + [98, "gp", "vector"], + [105, "gp", "vector"], + [107, "gp", "vector"], + [141, "a0", "vector"], + [145, "a0", "vector"], + [174, "v1", "vector"], + [184, "v1", "float"], + [28, "v1", "float"], + [31, "v1", "float"] + ], + "set-string-params": [[30, "v0", "entity-camera"]], + "cam-string-joystick": [[842, "v1", "process-drawable"]], + "cam-dist-analog-input": [[32, "f0", "float"]], + "cam-los-collide": [ + [92, "s1", "(inline-array collide-cache-tri)"], + [205, "s1", "(inline-array collide-cache-tri)"], + [135, "s1", "(inline-array collide-cache-tri)"], + [140, "s1", "(inline-array collide-cache-tri)"], + [175, "s1", "(inline-array collide-cache-tri)"], + [375, "v1", "(inline-array tracking-spline)"] + ], + "cam-los-spline-collide": [ + [70, "s3", "(inline-array collide-cache-tri)"], + [88, "s3", "(inline-array collide-cache-tri)"] + ], + "cam-draw-collide-cache": [ + [[8, 14], "gp", "(inline-array collide-cache-tri)"] + ], + "(method 16 camera-master)": [ + [14, "a2", "process-focusable"], + [16, "v1", "int"] + ], + "reset-follow": [ + [14, "a0", "process-focusable"], + [17, "a0", "process-focusable"] + ], + "(event cam-master-active)": [ + [80, "gp", "matrix"], + [170, "s5", "vector"], + [275, "v1", "process"], + [330, "a0", "camera-slave"], + [448, "v1", "camera-slave"], + [512, "v1", "camera-slave"], + [542, "v1", "camera-slave"], + [611, "a0", "vector"], + [799, "v1", "float"], + [784, "v1", "vector"], + [589, "v1", "float"], + [593, "v1", "float"], + [602, "v1", "float"], + [606, "v1", "float"], + [796, "v1", "float"] + ], + "master-track-target": [ + [53, "gp", "process-focusable"], + [100, "gp", "process-focusable"], + [121, "gp", "process-focusable"], + [132, "gp", "process-focusable"], + [203, "gp", "process-focusable"], + [273, "gp", "process-focusable"], + [280, "gp", "process-focusable"], + [286, "gp", "process-focusable"], + [366, "gp", "process-focusable"], + [480, "gp", "process-focusable"], + [486, "gp", "process-focusable"], + [490, "gp", "process-focusable"], + [528, "gp", "process-focusable"], + [531, "gp", "process-focusable"], + [409, "gp", "process-focusable"], + [415, "gp", "process-focusable"], + [171, "gp", "process-focusable"], + [195, "gp", "process-focusable"] + ], + "reset-target-tracking": [ + [14, "gp", "process-focusable"], + [40, "gp", "process-focusable"], + [51, "gp", "process-focusable"], + [65, "gp", "process-focusable"], + [86, "gp", "process-focusable"], + [131, "gp", "process-focusable"] + ], + "cam-free-floating-input": [ + [179, "v1", "cpad-list"], + [191, "v1", "cpad-list"], + [203, "v1", "cpad-list"], + [215, "v1", "cpad-list"], + [229, "a0", "cpad-list"], + [237, "v1", "cpad-list"] + ], + "(event cam-combiner-active)": [ + [103, "gp", "camera-slave"], + [105, "gp", "camera-slave"], + [189, "gp", "camera-slave"], + [191, "gp", "camera-slave"], + [206, "gp", "camera-slave"], + [210, "gp", "camera-slave"], + [214, "gp", "camera-slave"], + [230, "gp", "camera-slave"], + [234, "gp", "camera-slave"] + ], + "execute-cam-post-hook-engine": [ + [8, "s5", "connection"], + [[14, 17], "s5", "connection"], + [18, "t9", "(function object object object object object)"], + [9, "s5", "connection"] + ], + "cam-layout-init": [[10, "v1", "connection"]], + "cam-layout-function-call": [ + [15, "gp", "(function string int basic object)"] + ], + "cam-layout-do-action": [[99, "s5", "(function int symbol object)"]], + "cam-layout-do-menu": [ + [[280, 363], "s4", "clm-list"], + [374, "v1", "clm-item"], + [[136, 182], "s3", "clm-list"], + [209, "a0", "clm-item"], + [219, "v1", "clm-item"], + [234, "s3", "clm-item"], + [239, "v1", "clm-item"], + [244, "s3", "clm-item"] + ], + "clmf-save-all": [[18, "v1", "connection"]], + "cam-layout-save-campointsoffset": [[12, "v0", "vector"]], + "cam-layout-save-splineoffset": [ + [37, "v0", "vector"], + [25, "v0", "vector"] + ], + "cam-layout-save-interesting": [ + [13, "v0", "vector"], + [38, "v0", "vector"] + ], + "cam-layout-save-align": [ + [38, "v0", "vector"], + [13, "v0", "vector"] + ], + "cam-layout-save-pivot": [ + [13, "v0", "vector"], + [38, "v0", "vector"] + ], + "cam-layout-save-cam-trans": [ + [29, "v0", "vector"], + [40, "v0", "vector"], + [93, "s5", "symbol"], + [95, "s2", "symbol"], + [94, "s2", "symbol"] + ], + "cam-layout-save-cam-rot": [[13, "v0", "vector"]], + "clmf-next-entity": [[38, "a0", "connection"]], + "cam-layout-entity-info": [[202, "v1", "vector"]], + "cam-layout-entity-volume-info-create": [ + ["_stack_", 16, "res-tag"], + ["_stack_", 164, "float"], + [16, "v0", "(inline-array vector)"] + ], + "cam-layout-print": [[[22, 25], "v1", "dma-packet"]], + "(method 19 level-group)": [ + [237, "s2", "continue-point"], + [191, "s0", "continue-point"], + [196, "s2", "continue-point"], + [207, "s0", "continue-point"], + [213, "s0", "continue-point"], + [222, "s0", "continue-point"] + ], + "master-choose-entity": [[162, "s0", "(pointer camera-slave)"]] } diff --git a/decompiler/config/jak3/ntsc_v1/var_names.jsonc b/decompiler/config/jak3/ntsc_v1/var_names.jsonc index b411023d5e2..7cba2bcf452 100644 --- a/decompiler/config/jak3/ntsc_v1/var_names.jsonc +++ b/decompiler/config/jak3/ntsc_v1/var_names.jsonc @@ -1735,249 +1735,84 @@ } }, "transform-float-point": { - "args": [ - "src-world-pt", - "dst-gs-screen-pt" - ] + "args": ["src-world-pt", "dst-gs-screen-pt"] }, "add-debug-point": { - "args": [ - "enable", - "bucket", - "pt" - ] + "args": ["enable", "bucket", "pt"] }, "internal-draw-debug-line": { - "args": [ - "bucket", - "p0", - "p1", - "color", - "mode", - "color2" - ] + "args": ["bucket", "p0", "p1", "color", "mode", "color2"] }, "internal-draw-debug-text-3d": { - "args": [ - "bucket", - "text", - "pos", - "color", - "offset" - ] + "args": ["bucket", "text", "pos", "color", "offset"] }, "add-debug-outline-triangle": { - "args": [ - "enable", - "bucket", - "p0", - "p1", - "p2", - "color" - ] + "args": ["enable", "bucket", "p0", "p1", "p2", "color"] }, "add-debug-triangle-normal": { - "args": [ - "enable", - "bucket", - "p0", - "p1", - "p2", - "color" - ] + "args": ["enable", "bucket", "p0", "p1", "p2", "color"] }, "add-debug-flat-triangle": { - "args": [ - "enable", - "bucket", - "p0", - "p1", - "p2", - "color" - ] + "args": ["enable", "bucket", "p0", "p1", "p2", "color"] }, "get-debug-text-3d": { - "args": [ - "enable", - "bucket", - "p0", - "p1", - "color", - "mode", - "color2" - ] + "args": ["enable", "bucket", "p0", "p1", "color", "mode", "color2"] }, "debug-reset-buffers": { - "args": [ - "enable", - "bucket", - "p0", - "p1", - "color" - ] + "args": ["enable", "bucket", "p0", "p1", "color"] }, "add-debug-line": { - "args": [ - "enable", - "bucket", - "p0", - "p1", - "color", - "mode", - "color2" - ] + "args": ["enable", "bucket", "p0", "p1", "color", "mode", "color2"] }, "add-debug-line2d": { - "args": [ - "enable", - "bucket", - "p0", - "p1", - "color" - ] + "args": ["enable", "bucket", "p0", "p1", "color"] }, "add-debug-box": { - "args": [ - "enable", - "bucket", - "p0", - "p1", - "color" - ] + "args": ["enable", "bucket", "p0", "p1", "color"] }, "add-debug-box-with-transform": { - "args": [ - "enable", - "bucket", - "box", - "mat", - "color" - ] + "args": ["enable", "bucket", "box", "mat", "color"] }, "add-debug-x": { - "args": [ - "enable", - "bucket", - "pos", - "color" - ] + "args": ["enable", "bucket", "pos", "color"] }, "add-debug-cross": { - "args": [ - "enable", - "bucket", - "pos", - "len" - ] + "args": ["enable", "bucket", "pos", "len"] }, "add-debug-text-3d": { - "args": [ - "enable", - "bucket", - "text", - "pos", - "color", - "offset" - ] + "args": ["enable", "bucket", "text", "pos", "color", "offset"] }, "add-debug-sphere-with-transform": { - "args": [ - "enable", - "bucket", - "pos", - "radius", - "mat", - "color" - ] + "args": ["enable", "bucket", "pos", "radius", "mat", "color"] }, "add-debug-sphere": { - "args": [ - "enable", - "bucket", - "pos", - "radius", - "color" - ] + "args": ["enable", "bucket", "pos", "radius", "color"] }, "add-debug-text-sphere": { - "args": [ - "enable", - "bucket", - "pos", - "radius", - "text", - "color" - ] + "args": ["enable", "bucket", "pos", "radius", "text", "color"] }, "add-debug-spheres": { - "args": [ - "enable", - "bucket", - "spheres", - "count", - "color" - ] + "args": ["enable", "bucket", "spheres", "count", "color"] }, "add-debug-line-sphere": { - "args": [ - "enable", - "bucket", - "base", - "dir", - "rad", - "color" - ] + "args": ["enable", "bucket", "base", "dir", "rad", "color"] }, "add-debug-circle": { - "args": [ - "enable", - "bucket", - "origin", - "radius", - "color", - "mat" - ] + "args": ["enable", "bucket", "origin", "radius", "color", "mat"] }, "add-debug-vector": { - "args": [ - "enable", - "bucket", - "base", - "dir", - "len-scale", - "color" - ] + "args": ["enable", "bucket", "base", "dir", "len-scale", "color"] }, "add-debug-matrix": { - "args": [ - "enable", - "bucket", - "mat", - "len" - ] + "args": ["enable", "bucket", "mat", "len"] }, "add-debug-rot-matrix": { - "args": [ - "enable", - "bucket", - "mat", - "len", - "trans" - ] + "args": ["enable", "bucket", "mat", "len", "trans"] }, "add-debug-quaternion": { - "args": [ - "enable", - "bucket", - "trans", - "quat" - ] + "args": ["enable", "bucket", "trans", "quat"] }, "add-debug-cspace": { - "args": [ - "enable", - "bucket", - "cs" - ] + "args": ["enable", "bucket", "cs"] } } diff --git a/goal_src/jak3/engine/camera/cam-combiner.gc b/goal_src/jak3/engine/camera/cam-combiner.gc index 19f50cfc835..b67e42ed4cc 100644 --- a/goal_src/jak3/engine/camera/cam-combiner.gc +++ b/goal_src/jak3/engine/camera/cam-combiner.gc @@ -7,3 +7,441 @@ ;; DECOMP BEGINS +(defbehavior cam-helper-temp camera-combiner ((arg0 (pointer camera-slave)) (arg1 (pointer camera-slave)) (arg2 float)) + (local-vars (sv-144 cam-rotation-tracker)) + (set! sv-144 (-> arg0 0 tracking)) + (let ((s1-0 (-> arg0 0 trans)) + (gp-0 (-> arg1 0 tracking)) + (s0-0 (-> arg1 0 trans)) + ) + (cond + ((= (-> self tracking-status) 3) + (cam-calc-follow! (-> self tracking) s1-0 #t) + (slave-set-rotation! + (-> self tracking) + s1-0 + (the-as cam-slave-options-u32 (-> self tracking-options)) + (-> self fov) + #t + ) + (set! sv-144 (-> self tracking)) + (set! s1-0 (-> self trans)) + ) + ((= (-> self tracking-status) 2) + (cam-calc-follow! (-> self tracking) s0-0 #t) + (slave-set-rotation! + (-> self tracking) + s0-0 + (the-as cam-slave-options-u32 (-> self tracking-options)) + (-> self fov) + #t + ) + (set! gp-0 (-> self tracking)) + (set! s0-0 (-> self trans)) + ) + ) + (let ((s2-0 (new 'stack-no-clear 'inline-array 'vector 3))) + (dotimes (v1-14 3) + (set! (-> s2-0 v1-14 quad) (the-as uint128 0)) + ) + 0.0 + 0.0 + 0.0 + (let ((s4-0 (new-stack-vector0))) + 0.0 + (let ((s3-0 (new 'stack-no-clear 'matrix))) + (set! (-> s3-0 rvec quad) (the-as uint128 0)) + (set! (-> s3-0 uvec quad) (the-as uint128 0)) + (set! (-> s3-0 fvec quad) (the-as uint128 0)) + (set! (-> s3-0 trans quad) (the-as uint128 0)) + (vector-! (-> s2-0 0) (the-as vector (-> sv-144 inv-mat)) (the-as vector (-> gp-0 inv-mat))) + (vector-! (-> s2-0 1) (-> sv-144 inv-mat uvec) (-> gp-0 inv-mat uvec)) + (vector-! (-> s2-0 2) (-> sv-144 inv-mat fvec) (-> gp-0 inv-mat fvec)) + (let ((f0-6 (vector-length (-> s2-0 0))) + (f1-0 (vector-length (-> s2-0 1))) + (f2-0 (vector-length (-> s2-0 2))) + ) + (cond + ((and (< f0-6 f1-0) (< f0-6 f2-0)) + (vector-cross! s4-0 (-> s2-0 1) (-> s2-0 2)) + ) + ((and (< f1-0 f0-6) (< f1-0 f2-0)) + (vector-cross! s4-0 (-> s2-0 0) (-> s2-0 2)) + ) + (else + (vector-cross! s4-0 (-> s2-0 0) (-> s2-0 1)) + ) + ) + ) + (vector-normalize! s4-0 1.0) + (let ((f0-9 (fabs (vector-dot (the-as vector (-> sv-144 inv-mat)) s4-0))) + (f1-3 (fabs (vector-dot (-> sv-144 inv-mat uvec) s4-0))) + (f2-3 (fabs (vector-dot (-> sv-144 inv-mat fvec) s4-0))) + ) + (cond + ((and (< f0-9 f1-3) (< f0-9 f2-3)) + (vector-flatten! (-> s2-0 0) (the-as vector (-> sv-144 inv-mat)) s4-0) + (vector-flatten! (-> s2-0 1) (the-as vector (-> gp-0 inv-mat)) s4-0) + ) + ((< f1-3 f2-3) + (vector-flatten! (-> s2-0 0) (-> sv-144 inv-mat uvec) s4-0) + (vector-flatten! (-> s2-0 1) (-> gp-0 inv-mat uvec) s4-0) + ) + (else + (vector-flatten! (-> s2-0 0) (-> sv-144 inv-mat fvec) s4-0) + (vector-flatten! (-> s2-0 1) (-> gp-0 inv-mat fvec) s4-0) + ) + ) + ) + (vector-normalize! (-> s2-0 0) 1.0) + (vector-normalize! (-> s2-0 1) 1.0) + (vector-cross! (-> s2-0 2) (-> s2-0 0) (-> s2-0 1)) + (if (< (vector-dot (-> s2-0 2) s4-0) 0.0) + (vector-negate! s4-0 s4-0) + ) + (let ((f30-0 (acos (vector-dot (-> s2-0 0) (-> s2-0 1))))) + (cond + ((logtest? (-> *camera* master-options) (cam-master-options-u32 SET_COMBINER_AXIS)) + (logclear! (-> *camera* master-options) (cam-master-options-u32 SET_COMBINER_AXIS FLIP_COMBINER)) + (when (and (< 8192.0 f30-0) (logtest? (-> *camera* master-options) (cam-master-options-u32 HAVE_TARGET))) + (vector-! (-> s2-0 0) (-> *camera* tpos-curr) s1-0) + (vector-! (-> s2-0 1) s0-0 s1-0) + (vector-flatten! (-> s2-0 0) (-> s2-0 0) (-> *camera* local-down)) + (vector-flatten! (-> s2-0 1) (-> s2-0 1) (-> *camera* local-down)) + (when (and (< 4096.0 (vector-normalize-ret-len! (-> s2-0 0) 1.0)) + (< 4096.0 (vector-normalize-ret-len! (-> s2-0 1) 1.0)) + ) + (vector-cross! (-> s2-0 2) (-> s2-0 1) (-> s2-0 0)) + (when (< (vector-dot (-> s2-0 2) s4-0) -0.01) + ) + ) + ) + ) + ((and (< 16384.0 f30-0) (< (vector-dot (-> self flip-control-axis) s4-0) 0.0)) + (logxor! (-> *camera* master-options) (cam-master-options-u32 FLIP_COMBINER)) + ) + ) + (set! (-> self flip-control-axis quad) (-> s4-0 quad)) + (when (logtest? (-> *camera* master-options) (cam-master-options-u32 FLIP_COMBINER)) + (set! f30-0 (- 65536.0 f30-0)) + (vector-negate! s4-0 s4-0) + ) + (let ((f30-1 (* f30-0 (- 1.0 arg2)))) + (matrix-axis-sin-cos! s3-0 s4-0 (sin f30-1) (cos f30-1)) + ) + ) + (matrix*! (-> self inv-camera-rot) (the-as matrix gp-0) s3-0) + ) + ) + ) + ) + ) + +(defstate cam-combiner-active (camera-combiner) + :event (behavior ((proc process) (argc int) (message symbol) (block event-message-block)) + (local-vars (v0-0 object)) + (case message + (('fast-rot) + (set! v0-0 #t) + (set! (-> self fast-rot) (the-as basic v0-0)) + v0-0 + ) + (('set-interpolation) + (let ((f0-1 (the float (-> block param 0)))) + (cond + ((>= 0.0 f0-1) + (set! (-> self interp-val) 1.0) + ) + (else + (set! (-> self interp-val) 0.0) + (set! (-> self interp-step) (/ 5.0 f0-1)) + ) + ) + ) + ) + (('teleport) + (when (nonzero? (-> self tracking-status)) + (jump-to-target! (-> self tracking point-of-interest-blend) 0.0) + (cam-calc-follow! (-> self tracking) (-> self trans) #f) + (slave-set-rotation! + (-> self tracking) + (-> self trans) + (the-as cam-slave-options-u32 (-> self tracking-options)) + (-> self fov) + #f + ) + ) + ) + (('stop-tracking) + (set! (-> self tracking-status) (the-as uint 0)) + 0 + ) + (('start-tracking) + (cond + ((< argc 1) + (let ((t9-3 format) + (a0-14 0) + (a1-4 "ERROR : missing camera-slave parameter to *camera-combiner* start-tracking~%") + ) + (let ((v1-8 (-> block param 0))) + (rtype-of v1-8) + ) + (t9-3 a0-14 a1-4) + ) + ) + ((not (type? (-> block param 0) camera-slave)) + (let ((t9-5 format) + (a0-16 0) + (a1-6 "ERROR : invalid type '~A' to *camera-combiner* start-tracking~%") + (v1-11 (-> block param 0)) + ) + (t9-5 a0-16 a1-6 (rtype-of v1-11)) + ) + ) + ((zero? (-> self tracking-status)) + (set! (-> self tracking-status) (the-as uint 1)) + (let ((gp-1 (the-as object (-> block param 0)))) + (set! (-> self tracking-options) (the-as int (-> (the-as camera-slave gp-1) options))) + (set! (-> self tracking no-follow) (-> (the-as camera-slave gp-1) tracking no-follow)) + (copy-to (-> self tracking tilt-adjust) (the-as cam-float-seeker (+ (the-as uint gp-1) 320))) + (copy-to (-> self tracking underwater-blend) (the-as cam-float-seeker (+ (the-as uint gp-1) 368))) + (copy-to (-> self tracking point-of-interest-blend) (the-as cam-float-seeker (+ (the-as uint gp-1) 344))) + (let ((gp-2 (+ (the-as uint gp-1) 124))) + (cam-calc-follow! (-> self tracking) (the-as vector gp-2) #f) + (slave-set-rotation! + (-> self tracking) + (the-as vector gp-2) + (the-as cam-slave-options-u32 (-> self tracking-options)) + (-> self fov) + #f + ) + ) + ) + ) + ) + ) + (('copy-tracking) + (cond + ((< argc 1) + (let ((t9-11 format) + (a0-23 0) + (a1-12 "ERROR : missing camera-slave parameter to *camera-combiner* copy-tracking~%") + ) + (let ((v1-23 (-> block param 0))) + (rtype-of v1-23) + ) + (t9-11 a0-23 a1-12) + ) + ) + ((not (type? (-> block param 0) camera-slave)) + (let ((t9-13 format) + (a0-25 0) + (a1-14 "ERROR : invalid type '~A' to *camera-combiner* copy-tracking~%") + (v1-25 (-> block param 0)) + ) + (t9-13 a0-25 a1-14 (rtype-of v1-25)) + ) + ) + ((nonzero? (-> self tracking-status)) + #f + ) + (else + (set! (-> self tracking-status) (the-as uint 1)) + (let ((gp-3 (the-as object (-> block param 0)))) + (set! (-> self tracking-options) (the-as int (-> (the-as camera-slave gp-3) options))) + (set! (-> self tracking no-follow) (-> (the-as camera-slave gp-3) tracking no-follow)) + (copy-to (-> self tracking tilt-adjust) (the-as cam-float-seeker (+ (the-as uint gp-3) 320))) + (copy-to (-> self tracking underwater-blend) (the-as cam-float-seeker (+ (the-as uint gp-3) 368))) + (set! (-> self tracking follow-off quad) (-> (the-as camera-slave gp-3) tracking follow-off quad)) + (set! (-> self tracking follow-pt quad) (-> (the-as camera-slave gp-3) tracking follow-pt quad)) + (let* ((a2-23 (-> self tracking)) + (a3-7 (-> (the-as camera-slave gp-3) tracking)) + (v1-37 (-> a3-7 inv-mat rvec quad)) + (a0-32 (-> a3-7 inv-mat uvec quad)) + (a1-17 (-> a3-7 inv-mat fvec quad)) + (a3-8 (-> a3-7 inv-mat trans quad)) + ) + (set! (-> a2-23 inv-mat rvec quad) v1-37) + (set! (-> a2-23 inv-mat uvec quad) a0-32) + (set! (-> a2-23 inv-mat fvec quad) a1-17) + (set! (-> a2-23 inv-mat trans quad) a3-8) + ) + (copy-to (-> self tracking point-of-interest-blend) (the-as cam-float-seeker (+ (the-as uint gp-3) 344))) + (set! (-> self tracking looking-at quad) (-> (the-as camera-slave gp-3) tracking looking-at quad)) + (set! v0-0 (-> self tracking looking-interesting)) + (set! (-> (the-as vector v0-0) quad) (-> (the-as camera-slave gp-3) tracking looking-interesting quad)) + ) + v0-0 + ) + ) + ) + ) + ) + :code (behavior () + (until #f + (when (and (not (logtest? (-> *camera* master-options) (cam-master-options-u32 HAVE_TARGET))) + (!= (-> self tracking-status) 0) + ) + (set! (-> self tracking-status) (the-as uint 0)) + 0 + ) + (when *camera* + (let ((s5-0 (-> *camera* slave)) + (s4-0 (-> *camera* decel)) + (f30-0 (parameter-ease-sin-clamp (-> self interp-val))) + (gp-0 (new-stack-vector0)) + ) + (set! (-> gp-0 quad) (-> self trans quad)) + (when s5-0 + (cond + ((< (-> self interp-val) 1.0) + (vector-lerp-clamp! (-> self trans) (-> s4-0 0 trans) (-> s5-0 0 trans) f30-0) + (set! (-> self fov) (lerp-clamp (-> s4-0 0 fov) (-> s5-0 0 fov) f30-0)) + (set! (-> self dist-from-src) (vector-vector-distance (-> self trans) (-> s4-0 0 trans))) + (set! (-> self dist-from-dest) (vector-vector-distance (-> self trans) (-> s5-0 0 trans))) + (cond + ((= (-> self tracking-status) 1) + (cam-calc-follow! (-> self tracking) (-> self trans) #t) + (slave-set-rotation! + (-> self tracking) + (-> self trans) + (the-as cam-slave-options-u32 (-> self tracking-options)) + (-> self fov) + (not (-> self fast-rot)) + ) + (let* ((a2-4 (-> self inv-camera-rot)) + (a3-2 (-> self tracking)) + (v1-22 (-> a3-2 inv-mat rvec quad)) + (a0-10 (-> a3-2 inv-mat uvec quad)) + (a1-6 (-> a3-2 inv-mat fvec quad)) + (a3-3 (-> a3-2 inv-mat trans quad)) + ) + (set! (-> a2-4 rvec quad) v1-22) + (set! (-> a2-4 uvec quad) a0-10) + (set! (-> a2-4 fvec quad) a1-6) + (set! (-> a2-4 trans quad) a3-3) + ) + ) + (else + (cam-helper-temp s4-0 s5-0 f30-0) + ) + ) + (cond + ((and (< 0.0 (-> *camera* outro-t-step)) (< (-> *camera* outro-t) (-> *camera* outro-exit-value))) + ) + ((and (< (-> *camera* outro-t-step) 0.0) (< (-> *camera* outro-exit-value) (-> *camera* outro-t))) + ) + ((paused?) + ) + (else + (+! (-> self interp-val) (* (-> self interp-step) (-> self clock time-adjust-ratio))) + ) + ) + ) + (else + (set! (-> self dist-from-src) 409600.0) + (set! (-> self dist-from-dest) 0.0) + (set! (-> self trans quad) (-> s5-0 0 trans quad)) + (set! (-> self fov) (-> s5-0 0 fov)) + (cond + ((= (-> self tracking-status) 2) + (set! (-> self tracking-status) (the-as uint 1)) + ) + ((= (-> self tracking-status) 3) + (set! (-> self tracking-status) (the-as uint 0)) + 0 + ) + ) + (cond + ((= (-> self tracking-status) 1) + (cam-calc-follow! (-> self tracking) (-> self trans) #t) + (slave-set-rotation! + (-> self tracking) + (-> self trans) + (the-as cam-slave-options-u32 (-> self tracking-options)) + (-> self fov) + (not (-> self fast-rot)) + ) + (let* ((v1-51 (-> self inv-camera-rot)) + (a3-5 (-> self tracking)) + (a0-17 (-> a3-5 inv-mat rvec quad)) + (a1-10 (-> a3-5 inv-mat uvec quad)) + (a2-8 (-> a3-5 inv-mat fvec quad)) + (a3-6 (-> a3-5 inv-mat trans quad)) + ) + (set! (-> v1-51 rvec quad) a0-17) + (set! (-> v1-51 uvec quad) a1-10) + (set! (-> v1-51 fvec quad) a2-8) + (set! (-> v1-51 trans quad) a3-6) + ) + ) + (else + (let* ((v1-52 (-> self inv-camera-rot)) + (a3-7 (-> s5-0 0 tracking)) + (a0-19 (-> a3-7 inv-mat rvec quad)) + (a1-11 (-> a3-7 inv-mat uvec quad)) + (a2-9 (-> a3-7 inv-mat fvec quad)) + (a3-8 (-> a3-7 inv-mat trans quad)) + ) + (set! (-> v1-52 rvec quad) a0-19) + (set! (-> v1-52 uvec quad) a1-11) + (set! (-> v1-52 fvec quad) a2-9) + (set! (-> v1-52 trans quad) a3-8) + ) + ) + ) + ) + ) + ) + (vector-! (-> self velocity) (-> self trans) gp-0) + ) + ) + (set! (-> self fast-rot) #f) + (suspend) + ) + #f + ) + ) + +(defbehavior cam-combiner-init camera-combiner () + (stack-size-set! (-> self main-thread) 512) + (vector-reset! (-> self trans)) + (matrix-identity! (-> self inv-camera-rot)) + (cond + (*math-camera* + (set! (-> self fov) (-> *math-camera* fov)) + (set! (-> self trans quad) (-> *math-camera* trans quad)) + (let* ((v1-6 (-> self inv-camera-rot)) + (a3-0 (-> *math-camera* inv-camera-rot)) + (a0-6 (-> a3-0 rvec quad)) + (a1-1 (-> a3-0 uvec quad)) + (a2-0 (-> a3-0 fvec quad)) + (a3-1 (-> a3-0 trans quad)) + ) + (set! (-> v1-6 rvec quad) a0-6) + (set! (-> v1-6 uvec quad) a1-1) + (set! (-> v1-6 fvec quad) a2-0) + (set! (-> v1-6 trans quad) a3-1) + ) + ) + (else + (set! (-> self fov) 11650.845) + ) + ) + (set! (-> self interp-val) 1.0) + (set! (-> self interp-step) 0.125) + (set! (-> self tracking-status) (the-as uint 0)) + (set! (-> self fast-rot) #f) + (init (-> self tracking tilt-adjust) (-> *CAMERA-bank* default-tilt-adjust) 9.102222 91.022224 0.25) + (init + (-> self tracking follow-height-extra) + (-> *setting-control* cam-current extra-follow-height) + 81.92 + 819.2 + 0.5 + ) + (vector-reset! (-> self velocity)) + (go cam-combiner-active) + 0 + (none) + ) diff --git a/goal_src/jak3/engine/camera/cam-interface.gc b/goal_src/jak3/engine/camera/cam-interface.gc index 055d68e2fcf..c17e4c46855 100644 --- a/goal_src/jak3/engine/camera/cam-interface.gc +++ b/goal_src/jak3/engine/camera/cam-interface.gc @@ -7,3 +7,104 @@ ;; DECOMP BEGINS +(defun position-in-front-of-camera! ((arg0 vector) (arg1 float) (arg2 float)) + (vector-float*! arg0 (-> *math-camera* inv-camera-rot fvec) arg1) + (vector+float*! arg0 arg0 (-> *math-camera* inv-camera-rot uvec) arg2) + (vector+! arg0 arg0 (-> *math-camera* trans)) + arg0 + ) + +(defun position-in-front-of-screen! ((arg0 vector) (arg1 float) (arg2 vector)) + (let ((a2-1 (vector-negate! (new 'stack-no-clear 'vector) (-> *math-camera* inv-camera-rot fvec))) + (a1-3 (vector-float*! (new 'stack-no-clear 'vector) (-> *math-camera* inv-camera-rot fvec) arg1)) + ) + (vector+! a1-3 a1-3 (-> *math-camera* trans)) + (reverse-transform-point! arg0 a1-3 a2-1 arg2) + ) + arg0 + ) + +(defun matrix-local->world ((arg0 symbol) (arg1 symbol)) + (if arg0 + (-> *math-camera* inv-camera-rot-smooth) + (-> *math-camera* inv-camera-rot) + ) + ) + +(defun matrix-world->local ((arg0 symbol) (arg1 object)) + (-> *math-camera* camera-rot) + ) + +(define-perm *camera-dummy-vector* vector (vector-reset! (new 'global 'vector))) + +(defun camera-pos () + (cond + (*camera-combiner* + (-> *camera-combiner* trans) + ) + (*math-camera* + (-> *math-camera* trans) + ) + (else + *camera-dummy-vector* + ) + ) + ) + +(defun math-camera-pos () + (-> *math-camera* trans) + ) + +(defun camera-matrix () + (if *camera-combiner* + (-> *camera-combiner* inv-camera-rot) + (-> *math-camera* inv-camera-rot) + ) + ) + +(defun math-camera-matrix () + (-> *math-camera* inv-camera-rot) + ) + +(defun camera-angle () + (let ((f0-0 (-> *math-camera* camera-rot rvec x)) + (f1-0 (-> *math-camera* camera-rot rvec z)) + ) + (atan f1-0 f0-0) + ) + ) + +;; WARN: Return type mismatch object vs symbol. +(defbehavior camera-teleport-to-entity process ((arg0 entity-actor)) + (let ((gp-0 (new 'stack 'transformq))) + (set! (-> gp-0 trans quad) (-> arg0 extra trans quad)) + (quaternion-copy! (-> gp-0 quat) (-> arg0 quat)) + (vector-identity! (-> gp-0 scale)) + (the-as symbol (send-event *camera* 'teleport-to-transformq gp-0)) + ) + ) + +(defun camera-teleport-to-entity-named ((arg0 string)) + (let* ((gp-0 (entity-by-name arg0)) + (a0-3 (if (type? gp-0 entity-actor) + gp-0 + ) + ) + ) + (if a0-3 + (camera-teleport-to-entity (the-as entity-actor a0-3)) + (format #t "sorry, couldn't find an actor named '~S'~%" arg0) + ) + ) + 0 + (none) + ) + +(defun camera-teleport-to-location ((arg0 float) (arg1 float) (arg2 float)) + (let ((v1-1 (new 'stack 'transformq))) + (set-vector! (-> v1-1 trans) (* 4096.0 arg0) (* 4096.0 arg1) (* 4096.0 arg2) 1.0) + (send-event *camera* 'teleport-to-transformq v1-1) + ) + 0 + (none) + ) diff --git a/goal_src/jak3/engine/camera/cam-layout.gc b/goal_src/jak3/engine/camera/cam-layout.gc index 19ce08e1036..bd0fc8ca043 100644 --- a/goal_src/jak3/engine/camera/cam-layout.gc +++ b/goal_src/jak3/engine/camera/cam-layout.gc @@ -5,5 +5,3487 @@ ;; name in dgo: cam-layout ;; dgos: GAME +;; +++pad-buttons-u64 +(defenum pad-buttons-u64 + :type uint64 + :bitfield #t + :copy-entries pad-buttons + ) +;; ---pad-buttons-u64 + + +;; +++clm-item-action-options +(defenum clm-item-action-options + :type uint64 + :bitfield #t + (clm0 0) + (clm1 1) + (clm2 2) + (clm3 3) + (clm4 4) + (clm5 5) + (clm6 6) + (clm7 7) + ) +;; ---clm-item-action-options + + +(declare-type clm basic) +(define-extern *clm-edit* clm) +(define-extern *clm* clm) +(define-extern *clm-spline-attr* clm) +(define-extern *clm-intro-attr* clm) +(define-extern *clm-index-attr* clm) +(define-extern *clm-focalpull-attr* clm) +(define-extern *clm-select* clm) + ;; DECOMP BEGINS +;; this file is debug only +(declare-file (debug)) + +(define *camera-layout-blink* #f) + +(deftype cam-layout-bank (basic) + ((spline-t float) + (spline-step float) + (intro-t float) + (intro-step float) + (debug-t float) + (debug-step float) + ) + ) + + +(define *CAM_LAYOUT-bank* (new 'static 'cam-layout-bank + :spline-t 0.01 + :spline-step 0.0016666667 + :intro-t 0.01 + :intro-step 0.0016666667 + :debug-t 0.01 + :debug-step 0.0033333334 + ) + ) + +(define *camera-layout-message-ypos* 30) + +(deftype clm-basic (basic) + () + ) + + +(deftype clm-item-action (structure) + ((button pad-buttons-u64) + (options clm-item-action-options) + (func symbol) + (parm0 int32) + (parm0-sym symbol :overlay-at parm0) + (parm1 symbol) + (parm1-basic basic :overlay-at parm1) + ) + ) + + +(deftype clm-item (clm-basic) + ((description string) + (button-symbol symbol) + (action clm-item-action :inline) + ) + ) + + +(deftype clm-list-item (basic) + ((description string) + (track-val symbol) + (val-func symbol) + (val-parm0 int32) + (val-parm0-sym symbol :overlay-at val-parm0) + (val-parm1 symbol) + (actions (array clm-item-action)) + ) + ) + + +(deftype clm-list (clm-basic) + ((tracker symbol) + (cur-list-item int32) + (items (array clm-list-item)) + ) + ) + + +(deftype clm (basic) + ((title string) + (items (array clm-basic)) + ) + ) + + +(define *volume-point-current* 0) + +(define *volume-point* (new 'debug 'vector-array 1000)) + +(define *volume-normal-current* 0) + +(define *volume-normal* (new 'debug 'vector-array 600)) + +(deftype volume-descriptor-array (inline-array-class) + ((data plane-volume :inline :dynamic) + ) + ) + + +(set! (-> volume-descriptor-array heap-base) (the-as uint 24)) + +(define *volume-descriptor-current* 0) + +(define *volume-descriptor* (the-as vol-control (new 'debug 'volume-descriptor-array 100))) + +(deftype cam-layout (process) + ((cam-entity entity-camera) + (num-entities int32) + (cur-entity int32) + (num-volumes int32) + (cur-volume int32) + (first-pvol int32) + (first-cutoutvol int32) + (res-key float) + ) + (:states + cam-layout-active + ) + ) + + +(defun cam-layout-print ((arg0 int) (arg1 int) (arg2 string)) + (let* ((s5-0 (-> *display* frames (-> *display* on-screen) debug-buf)) + (gp-0 (-> s5-0 base)) + ) + (draw-string-xy arg2 s5-0 arg0 arg1 (font-color white) (font-flags shadow kerning)) + (let ((a3-2 (-> s5-0 base))) + (when (!= gp-0 a3-2) + (let ((v1-6 (the-as object (-> s5-0 base)))) + (set! (-> (the-as dma-packet v1-6) dma) (new 'static 'dma-tag :id (dma-tag-id next))) + (set! (-> (the-as dma-packet v1-6) vif0) (new 'static 'vif-tag)) + (set! (-> (the-as dma-packet v1-6) vif1) (new 'static 'vif-tag)) + (set! (-> s5-0 base) (&+ (the-as pointer v1-6) 16)) + ) + (dma-bucket-insert-tag + (-> *display* frames (-> *display* on-screen) bucket-group) + (bucket-id bucket583) + gp-0 + (the-as (pointer dma-tag) a3-2) + ) + ) + ) + ) + ) + +(defun cam-layout-intersect-dist ((arg0 vector) (arg1 vector) (arg2 vector)) + (let ((f0-1 (vector-dot arg1 arg0)) + (f1-1 (vector-dot arg2 arg0)) + ) + (if (< 0.00001 (fabs f1-1)) + (/ (- (-> arg0 w) f0-1) f1-1) + 409600000.0 + ) + ) + ) + +;; WARN: new jak 2 until loop case, check carefully +(defbehavior cam-layout-entity-volume-info-create cam-layout ((arg0 entity-camera) (arg1 symbol)) + (local-vars + (sv-16 res-tag) + (sv-160 vector) + (sv-164 float) + (sv-168 int) + (sv-176 vector) + (sv-192 vector) + (sv-208 vector) + (sv-224 vector) + (sv-240 vector) + (sv-256 int) + (sv-272 int) + (sv-288 int) + ) + (let ((s4-0 0)) + (until #f + (set! sv-16 (new 'static 'res-tag)) + (let ((s3-0 (the-as (inline-array vector) ((method-of-type res-lump get-property-data) + arg0 + arg1 + 'exact + (the float s4-0) + (the-as pointer #f) + (& sv-16) + *res-static-buf* + ) + ) + ) + ) + (cond + (s3-0 + (when (>= *volume-descriptor-current* 100) + (format 0 "ERROR : camera editing out of volume descriptors~%") + (return #f) + ) + (let ((s2-0 (-> *volume-descriptor* pos-vol *volume-descriptor-current*))) + (set! (-> s2-0 volume-type) arg1) + (set! (-> s2-0 point-count) 0) + (set! (-> s2-0 first-point) (the-as (pointer vector) (-> *volume-point* data *volume-point-current*))) + (set! (-> s2-0 normal-count) 0) + (set! (-> s2-0 first-normal) (the-as (pointer vector) (-> *volume-normal* data *volume-normal-current*))) + (set! *volume-descriptor-current* (+ *volume-descriptor-current* 1)) + (+! (-> self num-volumes) 1) + (dotimes (s1-0 (the-as int (-> sv-16 elt-count))) + (set! sv-192 (new 'stack-no-clear 'vector)) + (set! (-> sv-192 quad) (the-as uint128 0)) + (set! sv-208 (new 'stack-no-clear 'vector)) + (set! (-> sv-208 quad) (the-as uint128 0)) + (set! sv-224 (new 'stack-no-clear 'vector)) + (set! (-> sv-224 quad) (the-as uint128 0)) + (set! sv-240 (new 'stack-no-clear 'vector)) + (set! (-> sv-240 quad) (the-as uint128 0)) + 0.0 + 0.0 + 0.0 + (set! (-> (new 'stack-no-clear 'vector) quad) (the-as uint128 0)) + (let ((s0-0 (new-stack-vector0))) + (set! sv-256 0) + (set! sv-272 0) + (while (< sv-272 (the-as int (-> sv-16 elt-count))) + (when (!= s1-0 sv-272) + (vector-float*! sv-192 (-> s3-0 sv-272) (-> s3-0 sv-272 w)) + (vector-cross! sv-208 (-> s3-0 sv-272) (-> s3-0 s1-0)) + (vector-normalize! sv-208 1.0) + (vector-cross! sv-224 sv-208 (-> s3-0 sv-272)) + (vector-normalize! sv-224 1.0) + (let ((f0-6 (cam-layout-intersect-dist (-> s3-0 s1-0) sv-192 sv-224))) + (when (!= f0-6 409600000.0) + (vector+float*! sv-240 sv-192 sv-224 f0-6) + (set! sv-160 (new-stack-vector0)) + (set! sv-164 (the-as float 0.0)) + (set! sv-168 0) + (set! sv-176 (new-stack-vector0)) + (set! (-> sv-160 quad) (-> sv-240 quad)) + (set! sv-288 0) + (while (< sv-288 (the-as int (-> sv-16 elt-count))) + (when (and (!= sv-288 s1-0) (!= sv-288 sv-272)) + (let ((f0-8 (cam-layout-intersect-dist (-> s3-0 sv-288) sv-160 sv-208))) + (cond + ((= f0-8 409600000.0) + ) + ((zero? sv-168) + (vector+float*! sv-160 sv-160 sv-208 f0-8) + (set! (-> sv-176 quad) (-> s3-0 sv-288 quad)) + (set! sv-164 (the-as float 8192000.0)) + (set! sv-168 1) + ) + ((begin (vector-float*! sv-240 sv-208 f0-8) (>= (vector-dot sv-240 sv-176) 0.0)) + ) + ((>= (vector-dot sv-240 (-> s3-0 sv-288)) 0.0) + (when (< (fabs f0-8) (fabs sv-164)) + (set! sv-164 f0-8) + (set! sv-168 (+ sv-168 1)) + ) + ) + (else + (vector+float*! sv-160 sv-160 sv-208 f0-8) + (set! (-> sv-176 quad) (-> s3-0 sv-288 quad)) + (set! sv-168 (+ sv-168 1)) + (if (< (fabs f0-8) (fabs sv-164)) + (set! sv-164 (- sv-164 f0-8)) + (set! sv-164 (the-as float 0.0)) + ) + ) + ) + ) + ) + (set! sv-288 (+ sv-288 1)) + ) + (cond + ((zero? sv-168) + ) + ((= sv-164 0.0) + ) + (else + (dotimes (v1-87 (the-as int (-> sv-16 elt-count))) + (when (and (!= v1-87 s1-0) (!= v1-87 sv-272)) + (if (< 4096.0 (- (vector-dot sv-160 (-> s3-0 v1-87)) (-> s3-0 v1-87 w))) + (goto cfg-47) + ) + ) + ) + (vector+float*! sv-240 sv-160 sv-208 sv-164) + (cond + ((>= *volume-point-current* 999) + (format 0 "ERROR : camera editing out of volume points~%") + ) + (else + (set! (-> *volume-point* data *volume-point-current* quad) (-> sv-160 quad)) + (set! (-> *volume-point* data (+ *volume-point-current* 1) quad) (-> sv-240 quad)) + (set! *volume-point-current* (+ *volume-point-current* 2)) + (+! (-> s2-0 point-count) 2) + ) + ) + (vector+! s0-0 s0-0 sv-160) + (vector+! s0-0 s0-0 sv-240) + (set! sv-256 (+ sv-256 2)) + sv-256 + ) + ) + ) + ) + ) + (label cfg-47) + (set! sv-272 (+ sv-272 1)) + ) + (when (nonzero? sv-256) + (vector-float*! s0-0 s0-0 (/ 1.0 (the float sv-256))) + (cond + ((>= *volume-normal-current* 599) + (format 0 "ERROR : camera editing out of volume normals~%") + ) + (else + (set! (-> *volume-normal* data *volume-normal-current* quad) (-> s0-0 quad)) + (set! (-> *volume-normal* data (+ *volume-normal-current* 1) quad) (-> s3-0 s1-0 quad)) + (set! *volume-normal-current* (+ *volume-normal-current* 2)) + (set! (-> s2-0 normal-count) (+ (-> s2-0 normal-count) 2)) + ) + ) + ) + ) + ) + ) + ) + (else + (return #f) + ) + ) + ) + (+! s4-0 1) + ) + ) + #f + ) + +(defbehavior cam-layout-entity-volume-info cam-layout () + (dotimes (gp-0 (-> self num-volumes)) + (cond + ((and (= gp-0 (-> self cur-volume)) + (= *camera-layout-blink* 'volume) + (not (logtest? (-> *display* real-frame-clock integral-frame-counter) 8)) + ) + ) + (else + (let ((s5-0 (-> *volume-descriptor* pos-vol gp-0))) + (let ((a0-8 (new 'static 'vector4w :w #x80))) + (cond + ((= (-> s5-0 volume-type) 'vol) + (set! (-> a0-8 x) 0) + (set! (-> a0-8 y) 192) + (set! (-> a0-8 z) 0) + 0 + ) + ((= (-> s5-0 volume-type) 'pvol) + (set! (-> a0-8 x) 128) + (set! (-> a0-8 y) 128) + (set! (-> a0-8 z) 128) + ) + ((= (-> s5-0 volume-type) 'cutoutvol) + (set! (-> a0-8 x) 192) + (set! (-> a0-8 y) 0) + (set! (-> a0-8 z) 0) + 0 + ) + ) + (camera-line-setup a0-8) + ) + (let ((s4-0 (-> s5-0 first-point))) + (dotimes (s3-0 (/ (-> s5-0 point-count) 2)) + (camera-line-draw (the-as vector s4-0) (the-as vector (&-> s4-0 4))) + (set! s4-0 (&-> s4-0 8)) + ) + ) + ) + ) + ) + ) + #f + ) + +(defun v-slrp! ((arg0 vector) (arg1 vector) (arg2 vector) (arg3 float)) + (let ((s2-0 (new-stack-vector0)) + (s1-0 (new-stack-vector0)) + (s0-0 (new-stack-vector0)) + ) + 0.0 + 0.0 + 0.0 + 0.0 + (cond + ((< 1.0 arg3) + (set! arg3 1.0) + ) + ((< arg3 0.0) + (set! arg3 0.0) + ) + ) + (vector-normalize-copy! s2-0 arg1 1.0) + (vector-normalize-copy! s1-0 arg2 1.0) + (vector-cross! s0-0 s2-0 s1-0) + (let* ((f30-0 (vector-length s0-0)) + (f28-0 (asin f30-0)) + ) + (vector-float*! arg0 arg1 (/ (sin (* (- 1.0 arg3) f28-0)) f30-0)) + (vector+float*! arg0 arg0 arg2 (/ (sin (* arg3 f28-0)) f30-0)) + ) + ) + ) + +(deftype interp-test-info (structure) + ((from vector :inline) + (to vector :inline) + (origin vector :inline) + (color vector4w) + (axis vector) + (disp string) + ) + ) + + +(defun interp-test ((arg0 (function vector vector vector float vector float none)) (arg1 interp-test-info)) + (let ((s3-0 (new-stack-vector0)) + (s5-0 (new-stack-vector0)) + ) + (arg0 s3-0 (-> arg1 from) (-> arg1 to) 0.0 (-> arg1 axis) 65536.0) + (vector+! s3-0 s3-0 (-> arg1 origin)) + (dotimes (s2-0 10) + (set! (-> s5-0 quad) (-> s3-0 quad)) + (arg0 s3-0 (-> arg1 from) (-> arg1 to) (* 0.1 (+ 1.0 (the float s2-0))) (-> arg1 axis) 65536.0) + (vector+! s3-0 s3-0 (-> arg1 origin)) + (camera-line s3-0 s5-0 (-> arg1 color)) + ) + (arg0 s5-0 (-> arg1 from) (-> arg1 to) (-> *CAM_LAYOUT-bank* debug-t) (-> arg1 axis) 65536.0) + (format *stdcon* "~S ~f~%" (-> arg1 disp) (vector-length s5-0)) + (vector+! s5-0 s5-0 (-> arg1 origin)) + (camera-line (-> arg1 origin) s5-0 (-> arg1 color)) + (camera-cross (new 'static 'vector :y 1024.0) (new 'static 'vector :z 1024.0) s5-0 (-> arg1 color) (meters 1)) + ) + (none) + ) + +(defun interp-test-deg ((arg0 (function vector vector vector vector float none)) (arg1 interp-test-info)) + (let ((s3-0 (new-stack-vector0)) + (s5-0 (new-stack-vector0)) + ) + (arg0 s3-0 (-> arg1 from) (-> arg1 to) (-> arg1 axis) 0.0) + (vector+! s3-0 s3-0 (-> arg1 origin)) + (dotimes (s2-0 10) + (set! (-> s5-0 quad) (-> s3-0 quad)) + (arg0 s3-0 (-> arg1 from) (-> arg1 to) (-> arg1 axis) (* 182.04445 (* 18.0 (+ 1.0 (the float s2-0))))) + (vector+! s3-0 s3-0 (-> arg1 origin)) + (camera-line s3-0 s5-0 (-> arg1 color)) + ) + (arg0 s5-0 (-> arg1 from) (-> arg1 to) (-> arg1 axis) (* 182.04445 (* 180.0 (-> *CAM_LAYOUT-bank* debug-t)))) + (format *stdcon* "~S ~f~%" (-> arg1 disp) (vector-length s5-0)) + (vector+! s5-0 s5-0 (-> arg1 origin)) + (camera-line (-> arg1 origin) s5-0 (-> arg1 color)) + (camera-cross (new 'static 'vector :y 1024.0) (new 'static 'vector :z 1024.0) s5-0 (-> arg1 color) (meters 1)) + ) + (none) + ) + +;; WARN: Function cam-layout-entity-info has a return type of none, but the expression builder found a return statement. +(defun cam-layout-entity-info ((arg0 entity-actor)) + (if (not arg0) + (return #f) + ) + (let ((s5-0 (new 'stack-no-clear 'matrix))) + (set! (-> s5-0 rvec quad) (the-as uint128 0)) + (set! (-> s5-0 uvec quad) (the-as uint128 0)) + (set! (-> s5-0 fvec quad) (the-as uint128 0)) + (set! (-> s5-0 trans quad) (the-as uint128 0)) + (let ((s4-0 (new-stack-vector0))) + (when (and (cam-slave-get-vector-with-offset arg0 s4-0 'trans) + (or (!= *camera-layout-blink* 'camera) (logtest? (-> *display* real-frame-clock integral-frame-counter) 8)) + ) + (cam-slave-get-rot arg0 s5-0) + (camera-fov-frame s5-0 s4-0 (* 0.5 (cam-slave-get-fov arg0)) 0.75 1.0 (new 'static 'vector4w :z #xff :w #x80)) + ) + ) + ) + (let ((s5-1 (new-stack-vector0))) + (if (and (cam-slave-get-vector-with-offset arg0 s5-1 'pivot) + (or (!= *camera-layout-blink* 'pivot) (logtest? (-> *display* real-frame-clock integral-frame-counter) 8)) + ) + (camera-cross + (new 'static 'vector :y 1024.0) + (new 'static 'vector :z 1024.0) + s5-1 + (new 'static 'vector4w :x #x80 :w #x80) + (meters 1) + ) + ) + ) + (let ((s5-2 (new-stack-vector0))) + (if (and (cam-slave-get-vector-with-offset arg0 s5-2 'align) + (or (!= *camera-layout-blink* 'align) (logtest? (-> *display* real-frame-clock integral-frame-counter) 8)) + ) + (camera-cross + (new 'static 'vector :y 1024.0) + (new 'static 'vector :z 1024.0) + s5-2 + (new 'static 'vector4w :y #x80 :w #x80) + (meters 1) + ) + ) + ) + (let ((s5-3 (new-stack-vector0))) + (if (and (cam-slave-get-vector-with-offset arg0 s5-3 'interesting) + (or (!= *camera-layout-blink* 'interesting) + (logtest? (-> *display* real-frame-clock integral-frame-counter) 8) + ) + ) + (camera-cross + (new 'static 'vector :y 1024.0) + (new 'static 'vector :z 1024.0) + s5-3 + (new 'static 'vector4w :x #x80 :z #x80 :w #x80) + (meters 1) + ) + ) + ) + (let ((s3-1 (new 'stack 'curve)) + (s2-0 (new-stack-vector0)) + (s5-4 (new-stack-vector0)) + (s4-1 (new-stack-vector0)) + ) + (when (and (get-curve-data! arg0 s3-1 'campath 'campath-k -1000000000.0) + (or (!= *camera-layout-blink* 'spline) (logtest? (-> *display* real-frame-clock integral-frame-counter) 8)) + ) + (cond + ((cam-slave-get-vector-with-offset arg0 s4-1 'pivot) + (curve-get-pos! s5-4 0.0 s3-1) + (vector-! s4-1 s4-1 s5-4) + ) + (else + (set! (-> s4-1 quad) + (-> (the-as + vector + ((method-of-type res-lump get-property-struct) + arg0 + 'spline-offset + 'interp + -1000000000.0 + s4-1 + (the-as (pointer res-tag) #f) + *res-static-buf* + ) + ) + quad + ) + ) + ) + ) + (curve-get-pos! s5-4 0.0 s3-1) + (vector+! s5-4 s5-4 s4-1) + (dotimes (s1-1 8) + (set! (-> s2-0 quad) (-> s5-4 quad)) + (curve-get-pos! s5-4 (* 0.125 (the float (+ s1-1 1))) s3-1) + (vector+! s5-4 s5-4 s4-1) + (camera-line s2-0 s5-4 (new 'static 'vector4w :x #xff :y #xff :w #x80)) + ) + (curve-get-pos! s5-4 (-> *CAM_LAYOUT-bank* spline-t) s3-1) + (vector+! s5-4 s5-4 s4-1) + (camera-cross + (new 'static 'vector :y 1024.0) + (new 'static 'vector :z 1024.0) + s5-4 + (new 'static 'vector4w :x #xff :y #xff :w #x80) + (meters 1) + ) + ) + ) + (let ((s3-2 (new 'stack 'curve)) + (s2-1 (new-stack-vector0)) + (s5-5 (new-stack-vector0)) + (s4-2 (new-stack-vector0)) + (s1-2 (new 'stack 'curve)) + ) + (when (and (get-curve-data! arg0 s3-2 'intro 'intro-k -1000000000.0) + (or (!= *camera-layout-blink* 'intro) (logtest? (-> *display* real-frame-clock integral-frame-counter) 8)) + ) + (cond + ((cam-slave-get-vector-with-offset arg0 s4-2 'pivot) + (curve-get-pos! s5-5 1.0 s3-2) + (vector-! s4-2 s4-2 s5-5) + ) + ((get-curve-data! arg0 s1-2 'campath 'campath-k -1000000000.0) + (curve-get-pos! s4-2 0.0 s1-2) + (curve-get-pos! s5-5 1.0 s3-2) + (vector-! s4-2 s4-2 s5-5) + ) + ((cam-slave-get-vector-with-offset arg0 s4-2 'trans) + (curve-get-pos! s5-5 1.0 s3-2) + (vector-! s4-2 s4-2 s5-5) + ) + ) + (curve-get-pos! s5-5 0.0 s3-2) + (vector+! s5-5 s5-5 s4-2) + (dotimes (s1-3 8) + (set! (-> s2-1 quad) (-> s5-5 quad)) + (curve-get-pos! s5-5 (* 0.125 (the float (+ s1-3 1))) s3-2) + (vector+! s5-5 s5-5 s4-2) + (camera-line s2-1 s5-5 (new 'static 'vector4w :z #xff :w #x80)) + ) + (curve-get-pos! s5-5 (-> *CAM_LAYOUT-bank* intro-t) s3-2) + (vector+! s5-5 s5-5 s4-2) + (camera-cross + (new 'static 'vector :y 1024.0) + (new 'static 'vector :z 1024.0) + s5-5 + (new 'static 'vector4w :z #xff :w #x80) + (meters 1) + ) + (curve-get-pos! s5-5 (cam-slave-get-float arg0 'intro-exitValue 0.0) s3-2) + (vector+! s5-5 s5-5 s4-2) + (camera-cross + (new 'static 'vector :y 1024.0) + (new 'static 'vector :z 1024.0) + s5-5 + (new 'static 'vector4w :z #xff :w #x80) + (meters 1) + ) + ) + ) + (let ((s2-3 (res-lump-data arg0 'campoints pointer :time 1.0)) + (v1-73 (res-lump-struct arg0 'campoints-offset structure)) + (s4-3 (new 'stack-no-clear 'vector)) + (s3-3 (new 'stack-no-clear 'vector)) + (s5-6 (new 'static 'vector)) + ) + (when (and s2-3 + (or (!= *camera-layout-blink* 'index) (logtest? (-> *display* real-frame-clock integral-frame-counter) 8)) + ) + (cond + (v1-73 + (vector+! s4-3 (the-as vector (&+ s2-3 0)) (the-as vector v1-73)) + (vector+! s3-3 (the-as vector (&+ s2-3 16)) (the-as vector v1-73)) + ) + (else + (set! (-> s4-3 quad) (-> (the-as (pointer uint128) (&+ s2-3 0)))) + (set! (-> s3-3 quad) (-> (the-as (pointer uint128) (&+ s2-3 16)))) + ) + ) + (camera-line s4-3 s3-3 (new 'static 'vector4w :y #x80 :w #x80)) + (vector-lerp-clamp! s5-6 s4-3 s3-3 (-> *CAM_LAYOUT-bank* spline-t)) + (camera-cross + (new 'static 'vector :y 1024.0) + (new 'static 'vector :z 1024.0) + s5-6 + (new 'static 'vector4w :x #xff :y #xff :w #x80) + (meters 1) + ) + ) + ) + (let ((s4-4 (res-lump-data arg0 'focalpull pointer :time 1.0)) + (s5-7 (new 'static 'vector)) + ) + (when (and s4-4 + (or (!= *camera-layout-blink* 'focalpull) (logtest? (-> *display* real-frame-clock integral-frame-counter) 8)) + ) + (camera-line + (the-as vector (&+ s4-4 0)) + (the-as vector (&+ s4-4 16)) + (new 'static 'vector4w :y #xff :z #xff :w #x80) + ) + (vector-lerp-clamp! + s5-7 + (the-as vector (&+ s4-4 0)) + (the-as vector (&+ s4-4 16)) + (-> *CAM_LAYOUT-bank* spline-t) + ) + (camera-cross + (new 'static 'vector :y 1024.0) + (new 'static 'vector :z 1024.0) + s5-7 + (new 'static 'vector4w :y #xff :z #xff :w #x80) + (meters 1) + ) + ) + ) + (let ((s5-8 (new 'stack 'interp-test-info)) + (s4-5 (new-stack-vector0)) + ) + (when (and (cam-slave-get-vector-with-offset arg0 (-> s5-8 origin) 'pivot) + (cam-slave-get-vector-with-offset arg0 (-> s5-8 to) 'align) + (cam-slave-get-vector-with-offset arg0 (-> s5-8 from) 'trans) + ) + (camera-line (-> s5-8 from) (-> s5-8 origin) (new 'static 'vector4w :x #x80 :y #x80 :z #x80 :w #x80)) + (camera-line (-> s5-8 to) (-> s5-8 origin) (new 'static 'vector4w :x #x80 :y #x80 :z #x80 :w #x80)) + (vector-! (-> s5-8 from) (-> s5-8 from) (-> s5-8 origin)) + (vector-! (-> s5-8 to) (-> s5-8 to) (-> s5-8 origin)) + (vector-cross! s4-5 (-> s5-8 from) (-> s5-8 to)) + (vector-normalize! s4-5 8192.0) + (vector+! s4-5 s4-5 (-> s5-8 origin)) + (camera-line (-> s5-8 origin) s4-5 (new 'static 'vector4w :x #x80 :y #x80 :z #x80 :w #x80)) + (when (not (paused?)) + (+! (-> *CAM_LAYOUT-bank* debug-t) (-> *CAM_LAYOUT-bank* debug-step)) + (if (< 1.0 (-> *CAM_LAYOUT-bank* debug-t)) + (set! (-> *CAM_LAYOUT-bank* debug-t) 0.0) + ) + ) + (set! (-> s5-8 axis) #f) + (set! (-> s5-8 disp) "li") + (set! (-> s5-8 color) (new 'static 'vector4w :x #xff :w #x80)) + (interp-test (the-as (function vector vector vector float vector float none) vector-lerp!) s5-8) + (set! (-> s5-8 disp) "si") + (set! (-> s5-8 color) (new 'static 'vector4w :y #xff :w #x80)) + (interp-test (the-as (function vector vector vector float vector float none) v-slrp!) s5-8) + (set! (-> s5-8 disp) "si2") + (set! (-> s5-8 color) (new 'static 'vector4w :z #xff :w #x80)) + (interp-test (the-as (function vector vector vector float vector float none) v-slrp2!) s5-8) + (set! (-> s5-8 disp) "si3") + (set! (-> s5-8 color) (new 'static 'vector4w :x #xff :z #xff :w #x80)) + (interp-test-deg (the-as (function vector vector vector vector float none) v-slrp3!) s5-8) + (set! (-> s5-8 axis) (-> *camera* local-down)) + (set! (-> s5-8 disp) "si2d") + (set! (-> s5-8 color) (new 'static 'vector4w :y #xff :z #xff :w #x80)) + (interp-test (the-as (function vector vector vector float vector float none) v-slrp2!) s5-8) + (set! (-> s5-8 disp) "si3d") + (set! (-> s5-8 color) (new 'static 'vector4w :x #xff :y #xff :w #x80)) + (interp-test-deg (the-as (function vector vector vector vector float none) v-slrp3!) s5-8) + ) + ) + (none) + ) + +(defun clmf-button-test () + (cam-layout-print 16 *camera-layout-message-ypos* "button test") + (set! *camera-layout-message-ypos* (+ *camera-layout-message-ypos* 14)) + (set-setting! 'master-options 'set 0.0 32) + #f + ) + +(defun clmf-bna () + (cam-layout-print 16 *camera-layout-message-ypos* "button not applicable") + (set! *camera-layout-message-ypos* (+ *camera-layout-message-ypos* 14)) + (set-setting! 'master-options 'set 0.0 32) + #t + ) + +(defun clmf-implement () + (cam-layout-print 16 *camera-layout-message-ypos* "button not implemented yet") + (set! *camera-layout-message-ypos* (+ *camera-layout-message-ypos* 14)) + (set-setting! 'master-options 'set 0.0 32) + #t + ) + +(defun clmf-input ((arg0 vector) (arg1 vector) (arg2 int)) + (vector-reset! arg0) + (vector-reset! arg1) + (cond + ((cpad-hold? arg2 l3) + (set! (-> arg0 z) + (- (-> arg0 z) (analog-input (the-as int (-> *cpad-list* cpads arg2 rightx)) 128.0 48.0 110.0 1.0)) + ) + ) + (else + (set! (-> arg0 y) + (- (-> arg0 y) (analog-input (the-as int (-> *cpad-list* cpads arg2 rightx)) 128.0 48.0 110.0 1.0)) + ) + (+! (-> arg0 x) (analog-input (the-as int (-> *cpad-list* cpads arg2 righty)) 128.0 48.0 110.0 1.0)) + (set! (-> arg1 x) + (- (-> arg1 x) (analog-input (the-as int (-> *cpad-list* cpads arg2 leftx)) 128.0 48.0 110.0 1.0)) + ) + (when (logtest? (-> *camera* settings master-options) (cam-master-options READ_BUTTONS)) + (if (cpad-hold? arg2 r1) + (set! (-> arg1 y) + (+ 0.5 (analog-input (the-as int (-> *cpad-list* cpads arg2 abutton 9)) 0.0 32.0 230.0 0.5) (-> arg1 y)) + ) + ) + ) + (when (logtest? (-> *camera* settings master-options) (cam-master-options READ_BUTTONS)) + (if (cpad-hold? arg2 l1) + (set! (-> arg1 y) + (- (-> arg1 y) (+ 0.5 (analog-input (the-as int (-> *cpad-list* cpads arg2 abutton 8)) 0.0 32.0 230.0 0.5))) + ) + ) + ) + (set! (-> arg1 z) + (- (-> arg1 z) (analog-input (the-as int (-> *cpad-list* cpads arg2 lefty)) 128.0 48.0 110.0 1.0)) + ) + ) + ) + (let ((s5-1 (new 'stack-no-clear 'matrix))) + (set! (-> s5-1 rvec quad) (the-as uint128 0)) + (set! (-> s5-1 uvec quad) (the-as uint128 0)) + (set! (-> s5-1 fvec quad) (the-as uint128 0)) + (set! (-> s5-1 trans quad) (the-as uint128 0)) + (let ((a2-8 (new-stack-vector0))) + (set! (-> a2-8 y) -1.0) + (forward-down-nopitch->inv-matrix s5-1 (-> *math-camera* inv-camera-rot fvec) a2-8) + ) + (vector-matrix*! arg1 arg1 s5-1) + ) + arg1 + ) + +(defbehavior clmf-pos-rot cam-layout ((arg0 symbol) (arg1 symbol)) + (local-vars (s2-0 structure) (s3-1 structure) (sv-192 matrix)) + (cam-layout-print 16 *camera-layout-message-ypos* "x/z pos: left stick, down: l1, up: r1") + (set! *camera-layout-message-ypos* (+ *camera-layout-message-ypos* 14)) + (when (and arg1 (nonzero? arg1)) + (cam-layout-print 16 *camera-layout-message-ypos* "x/y rot: right stick") + (set! *camera-layout-message-ypos* (+ *camera-layout-message-ypos* 14)) + (cam-layout-print 16 *camera-layout-message-ypos* "z rot: press left stick & move right") + (set! *camera-layout-message-ypos* (+ *camera-layout-message-ypos* 14)) + ) + (let ((s5-0 (new-stack-vector0)) + (s4-0 (new-stack-vector0)) + ) + (set! s3-1 + (cond + ((or (zero? arg0) (not arg0)) + (the-as structure #f) + ) + (else + (if (not (res-lump-struct (-> self cam-entity) arg0 structure)) + (add-data! + (-> self cam-entity) + (new 'static 'res-tag :name arg0 :key-frame -1000000000.0 :elt-count #x1 :inlined? #x1 :elt-type vector) + (the-as pointer (new 'static 'vector)) + ) + ) + (set! s3-1 (res-lump-struct (-> self cam-entity) arg0 structure)) + (when (and (not s3-1) (logtest? (-> *display* real-frame-clock integral-frame-counter) 8)) + (clear *temp-string*) + (format *temp-string* "ERROR : can't add ~A" 'vector) + (cam-layout-print 120 100 *temp-string*) + ) + s3-1 + ) + ) + ) + (set! s2-0 + (cond + ((or (zero? arg1) (not arg1)) + (the-as structure #f) + ) + (else + (if (not (res-lump-struct (-> self cam-entity) arg1 structure)) + (add-data! + (-> self cam-entity) + (new 'static 'res-tag :name arg1 :key-frame -1000000000.0 :elt-count #x1 :inlined? #x1 :elt-type quaternion) + (the-as pointer (quaternion-identity! (new 'static 'quaternion))) + ) + ) + (set! s2-0 (res-lump-struct (-> self cam-entity) arg1 structure)) + (when (and (not s2-0) (logtest? (-> *display* real-frame-clock integral-frame-counter) 8)) + (clear *temp-string*) + (format *temp-string* "ERROR : can't add ~A" 'quaternion) + (cam-layout-print 120 100 *temp-string*) + ) + s2-0 + ) + ) + ) + (let ((s1-1 (new 'stack-no-clear 'matrix))) + (set! sv-192 (new 'stack-no-clear 'matrix)) + (let ((s0-1 (new 'stack-no-clear 'quaternion))) + (if (not s3-1) + (return #f) + ) + (clmf-input s5-0 s4-0 0) + (vector+float*! (the-as vector s3-1) (the-as vector s3-1) s4-0 409.6) + (cond + ((not arg1) + (the-as quaternion #f) + ) + ((zero? arg1) + (the-as quaternion #f) + ) + (else + (cam-slave-get-rot (the-as entity-actor (-> self cam-entity)) sv-192) + (vector-float*! s5-0 s5-0 100.0) + (matrix-rotate-x! s1-1 (- (-> s5-0 x))) + (matrix*! sv-192 s1-1 sv-192) + (matrix-rotate-y! s1-1 (-> s5-0 y)) + (matrix*! sv-192 sv-192 s1-1) + (matrix-rotate-z! s1-1 (- (-> s5-0 z))) + (matrix*! sv-192 s1-1 sv-192) + (matrix->quaternion s0-1 sv-192) + (quaternion-inverse! (the-as quaternion s2-0) (the-as quaternion (-> self cam-entity connect))) + (quaternion*! (the-as quaternion s2-0) s0-1 (the-as quaternion s2-0)) + (quaternion-normalize! (the-as quaternion s2-0)) + ) + ) + ) + ) + ) + (set-setting! 'master-options 'set 0.0 32) + #t + ) + +(defbehavior clmf-next-volume cam-layout ((arg0 int)) + (if (zero? (-> self num-volumes)) + (return #f) + ) + (set! (-> self cur-volume) (mod (+ arg0 (-> self cur-volume)) (-> self num-volumes))) + (while (< (-> self cur-volume) 0) + (+! (-> self cur-volume) (-> self num-volumes)) + ) + #t + ) + +(defun clmf-next-vol-dpad () + (local-vars (a0-1 int)) + (cam-layout-print 16 *camera-layout-message-ypos* "dpad selects volume") + (set! *camera-layout-message-ypos* (+ *camera-layout-message-ypos* 14)) + (cond + ((cpad-pressed? 0 down) + (set! a0-1 1) + ) + ((cpad-pressed? 0 right) + (set! a0-1 1) + ) + ((cpad-pressed? 0 up) + (set! a0-1 -1) + ) + ((cpad-pressed? 0 left) + (set! a0-1 -1) + ) + (else + (set! a0-1 0) + ) + ) + (clmf-next-volume a0-1) + (set-setting! 'master-options 'set 0.0 32) + #t + ) + +(defun clmf-to-edit-cam () + (clmf-next-volume 0) + (set! *clm* *clm-edit*) + #t + ) + +(define *last-cur-entity* -1) + +(defbehavior clmf-next-entity cam-layout ((arg0 int)) + (let ((v1-0 (/ arg0 8))) + (when (zero? (-> self num-entities)) + (set! (-> self cam-entity) #f) + (return #f) + ) + (if (= (- v1-0) (-> self num-entities)) + (set! v1-0 -1) + ) + (if (= v1-0 (-> self num-entities)) + (set! v1-0 1) + ) + (set! (-> self cur-entity) (mod (+ v1-0 (-> self cur-entity)) (-> self num-entities))) + ) + (while (< (-> self cur-entity) 0) + (+! (-> self cur-entity) (-> self num-entities)) + ) + (set! *last-cur-entity* (-> self cur-entity)) + (let ((v1-8 (-> self cur-entity)) + (a0-13 (-> *camera-engine* alive-list next0)) + ) + *camera-engine* + (let ((a1-3 (-> a0-13 next0))) + (while (!= a0-13 (-> *camera-engine* alive-list-end)) + (let ((a0-14 (-> (the-as connection a0-13) param1))) + (cond + ((zero? v1-8) + (set! (-> self cam-entity) (the-as entity-camera a0-14)) + (set! *volume-descriptor-current* 0) + (set! *volume-point-current* 0) + (set! *volume-normal-current* 0) + (set! (-> self num-volumes) 0) + (cam-layout-entity-volume-info-create (-> self cam-entity) 'vol) + (set! (-> self first-pvol) (-> self num-volumes)) + (cam-layout-entity-volume-info-create (-> self cam-entity) 'pvol) + (set! (-> self first-cutoutvol) (-> self num-volumes)) + (cam-layout-entity-volume-info-create (-> self cam-entity) 'cutoutvol) + (set! (-> *CAM_LAYOUT-bank* intro-step) (cam-slave-get-intro-step (-> self cam-entity))) + (return #f) + ) + (else + (+! v1-8 -1) + ) + ) + ) + (set! a0-13 a1-3) + *camera-engine* + (set! a1-3 (-> a1-3 next0)) + ) + ) + ) + #t + ) + +(defun clmf-to-spline-attr () + (set! *clm* *clm-spline-attr*) + #t + ) + +(defun clmf-to-intro-attr () + (set! *clm* *clm-intro-attr*) + #t + ) + +(defun clmf-to-index-attr () + (set! *clm* *clm-index-attr*) + #t + ) + +(defun clmf-to-focalpull-attr () + (set! *clm* *clm-focalpull-attr*) + #t + ) + +(defbehavior clmf-to-edit cam-layout () + (set! (-> self res-key) -1000000000.0) + (set! *clm* *clm-edit*) + #t + ) + +(defun clmf-to-select () + (set! *camera-layout-blink* #f) + (set! *clm* *clm-select*) + #t + ) + +(defbehavior clmf-look-through cam-layout () + (set! (-> *camera-other-fov* data) (cam-slave-get-fov (-> self cam-entity))) + (cam-slave-get-vector-with-offset (the-as entity-actor (-> self cam-entity)) *camera-other-trans* 'trans) + (set! (-> *camera-other-root* quad) (-> *camera-other-trans* quad)) + (cam-slave-get-rot (the-as entity-actor (-> self cam-entity)) *camera-other-matrix*) + (set! *camera-look-through-other* 10) + (set-setting! 'master-options 'set 0.0 32) + #f + ) + +(defun fov->maya ((arg0 float)) + (if (= arg0 0.0) + 0.0 + (/ 12.700255 (tan (* 0.5 arg0))) + ) + ) + +;; WARN: Return type mismatch object vs none. +(defun cam-layout-save-cam-rot ((arg0 symbol) (arg1 string) (arg2 entity-actor)) + (let ((s3-0 (-> arg2 quat)) + (s5-0 (res-lump-struct arg2 'rot-offset vector)) + ) + (if arg0 + (format #t "setup rot ~f ~f ~f ~f~%" (-> s3-0 x) (-> s3-0 y) (-> s3-0 z) (-> s3-0 w)) + ) + (when s5-0 + (if arg0 + (format #t "rot offset ~f ~f ~f ~f~%" (-> s5-0 x) (-> s5-0 y) (-> s5-0 z) (-> s5-0 w)) + ) + (format + arg1 + " tag rot-offset ~f ~f ~f ~f // vector (quaternion)~%" + (-> s5-0 x) + (-> s5-0 y) + (-> s5-0 z) + (-> s5-0 w) + ) + ) + ) + (none) + ) + +;; WARN: Return type mismatch object vs none. +(defun cam-layout-save-cam-trans ((arg0 symbol) (arg1 string) (arg2 entity-actor)) + (let ((s1-0 (-> arg2 trans)) + (s5-0 (method-of-type res-lump get-property-struct)) + (s2-0 arg2) + ) + (format (clear *res-key-string*) "~S~S" 'trans '-offset) + (let ((s5-1 (the-as object (s5-0 + s2-0 + (string->symbol *res-key-string*) + 'interp + -1000000000.0 + (the-as structure #f) + (the-as (pointer res-tag) #f) + *res-static-buf* + ) + ) + ) + ) + (let ((s2-1 (the-as object (res-lump-struct arg2 'translation_info vector))) + (s3-1 (new-stack-vector0)) + ) + (if arg0 + (format #t "setup trans ~M ~M ~M (maya)~%" (-> s1-0 x) (-> s1-0 y) (-> s1-0 z)) + ) + (set! (-> s3-1 quad) (-> s1-0 quad)) + (when (the-as vector s5-1) + (if arg0 + (format + #t + "offset ~M ~M ~M (added)~%" + (-> (the-as vector s5-1) x) + (-> (the-as vector s5-1) y) + (-> (the-as vector s5-1) z) + ) + ) + (vector+! s3-1 s3-1 (the-as vector s5-1)) + ) + (when (the-as vector s2-1) + (if arg0 + (format + #t + "level-trans ~M ~M ~M (subtracted)~%" + (-> (the-as vector s2-1) x) + (-> (the-as vector s2-1) y) + (-> (the-as vector s2-1) z) + ) + ) + (vector-! s3-1 s3-1 (the-as vector s2-1)) + ) + (set! s2-1 (or (the-as vector s5-1) s2-1)) + (set! arg0 (and (the-as symbol s2-1) arg0)) + (if arg0 + (format #t "final trans ~M ~M ~M (maya)~%" (-> s3-1 x) (-> s3-1 y) (-> s3-1 z)) + ) + ) + (if (the-as vector s5-1) + (format + arg1 + " tag trans-offset METERS(~M) METERS(~M) METERS(~M) 1.0 // vector~%" + (-> (the-as vector s5-1) x) + (-> (the-as vector s5-1) y) + (-> (the-as vector s5-1) z) + ) + ) + ) + ) + (none) + ) + +;; WARN: Return type mismatch object vs none. +(defun cam-layout-save-pivot ((arg0 symbol) (arg1 string) (arg2 entity-actor)) + (let ((s2-0 (res-lump-struct arg2 'pivot vector)) + (s4-0 (method-of-type res-lump get-property-struct)) + ) + (format (clear *res-key-string*) "~S~S" 'pivot '-offset) + (let ((s5-1 (the-as vector (s4-0 + arg2 + (string->symbol *res-key-string*) + 'interp + -1000000000.0 + (the-as structure #f) + (the-as (pointer res-tag) #f) + *res-static-buf* + ) + ) + ) + (s4-1 (new-stack-vector0)) + ) + (when s2-0 + (if s5-1 + (vector+! s4-1 s2-0 s5-1) + (set! (-> s4-1 quad) (-> s2-0 quad)) + ) + (if arg0 + (format #t "setup pivot ~M ~M ~M~%" (-> s2-0 x) (-> s2-0 y) (-> s2-0 z)) + ) + (when s5-1 + (when arg0 + (format #t "offset ~M ~M ~M~%" (-> s5-1 x) (-> s5-1 y) (-> s5-1 z)) + (format #t "final pivot ~M ~M ~M~%" (-> s4-1 x) (-> s4-1 y) (-> s4-1 z)) + ) + (format + arg1 + " tag pivot-offset METERS(~M) METERS(~M) METERS(~M) 1.0 // vector~%" + (-> s5-1 x) + (-> s5-1 y) + (-> s5-1 z) + ) + ) + ) + ) + ) + (none) + ) + +;; WARN: Return type mismatch object vs none. +(defun cam-layout-save-align ((arg0 symbol) (arg1 string) (arg2 entity-actor)) + (let ((s2-0 (res-lump-struct arg2 'align vector)) + (s4-0 (method-of-type res-lump get-property-struct)) + ) + (format (clear *res-key-string*) "~S~S" 'align '-offset) + (let ((s5-1 (the-as vector (s4-0 + arg2 + (string->symbol *res-key-string*) + 'interp + -1000000000.0 + (the-as structure #f) + (the-as (pointer res-tag) #f) + *res-static-buf* + ) + ) + ) + (s4-1 (new-stack-vector0)) + ) + (when s2-0 + (if s5-1 + (vector+! s4-1 s2-0 s5-1) + (set! (-> s4-1 quad) (-> s2-0 quad)) + ) + (if arg0 + (format #t "setup align ~M ~M ~M~%" (-> s2-0 x) (-> s2-0 y) (-> s2-0 z)) + ) + (when s5-1 + (when arg0 + (format #t "offset ~M ~M ~M~%" (-> s5-1 x) (-> s5-1 y) (-> s5-1 z)) + (format #t "final align ~M ~M ~M~%" (-> s4-1 x) (-> s4-1 y) (-> s4-1 z)) + ) + (format + arg1 + " tag align-offset METERS(~M) METERS(~M) METERS(~M) 1.0 // vector~%" + (-> s5-1 x) + (-> s5-1 y) + (-> s5-1 z) + ) + ) + ) + ) + ) + (none) + ) + +;; WARN: Return type mismatch object vs none. +(defun cam-layout-save-interesting ((arg0 symbol) (arg1 string) (arg2 entity-actor)) + (let ((s2-0 (res-lump-struct arg2 'interesting vector)) + (s4-0 (method-of-type res-lump get-property-struct)) + ) + (format (clear *res-key-string*) "~S~S" 'interesting '-offset) + (let ((s5-1 (the-as vector (s4-0 + arg2 + (string->symbol *res-key-string*) + 'interp + -1000000000.0 + (the-as structure #f) + (the-as (pointer res-tag) #f) + *res-static-buf* + ) + ) + ) + (s4-1 (new-stack-vector0)) + ) + (when s2-0 + (if s5-1 + (vector+! s4-1 s2-0 s5-1) + (set! (-> s4-1 quad) (-> s2-0 quad)) + ) + (if arg0 + (format #t "setup interesting ~M ~M ~M~%" (-> s2-0 x) (-> s2-0 y) (-> s2-0 z)) + ) + (when s5-1 + (when arg0 + (format #t "offset ~M ~M ~M~%" (-> s5-1 x) (-> s5-1 y) (-> s5-1 z)) + (format #t "final interesting ~M ~M ~M~%" (-> s4-1 x) (-> s4-1 y) (-> s4-1 z)) + ) + (format + arg1 + " tag interesting-offset METERS(~M) METERS(~M) METERS(~M) 1.0 // vector~%" + (-> s5-1 x) + (-> s5-1 y) + (-> s5-1 z) + ) + ) + ) + ) + ) + (none) + ) + +;; WARN: Return type mismatch object vs none. +(defun cam-layout-save-fov ((arg0 symbol) (arg1 string) (arg2 entity-actor)) + (let ((f28-0 (res-lump-float arg2 'fov)) + (s3-0 (method-of-type res-lump get-property-value-float)) + ) + (format (clear *res-key-string*) "~S~S" 'fov '-offset) + (let ((f30-0 (s3-0 + arg2 + (string->symbol *res-key-string*) + 'interp + -1000000000.0 + 0.0 + (the-as (pointer res-tag) #f) + *res-static-buf* + ) + ) + ) + (cond + ((= f28-0 0.0) + (if arg0 + (format #t "setup fov deg 0.0 (defaults to 64.0)~%") + ) + (set! f28-0 11650.845) + ) + (arg0 + (format #t "setup fov deg ~R (~f in maya)~%" f28-0 (fov->maya f28-0)) + ) + ) + (when (!= f30-0 0.0) + (when arg0 + (format #t "offset ~R~%" f30-0) + (format #t "final ~R (~f in maya) ~%" (+ f28-0 f30-0) (fov->maya (+ f28-0 f30-0))) + ) + (format arg1 " tag fov-offset DEG(~R) // float~%" f30-0) + ) + ) + ) + (none) + ) + +;; WARN: Return type mismatch object vs none. +(defun cam-layout-save-focalpull ((arg0 symbol) (arg1 string) (arg2 entity-actor)) + (let ((f30-0 (res-lump-float arg2 'focalpull)) + (s3-0 (method-of-type res-lump get-property-value-float)) + ) + (format (clear *res-key-string*) "~S~S" 'focalpull '-offset) + (let ((f28-0 (s3-0 + arg2 + (string->symbol *res-key-string*) + 'interp + -1000000000.0 + 0.0 + (the-as (pointer res-tag) #f) + *res-static-buf* + ) + ) + ) + (if arg0 + (format #t "setup focalpull deg ~R (~f in maya)~%" f30-0 (fov->maya f30-0)) + ) + (when (!= f28-0 0.0) + (when arg0 + (format #t "offset ~R~%" f28-0) + (format #t "final ~R (~f in maya) ~%" (+ f30-0 f28-0) (fov->maya (+ f30-0 f28-0))) + ) + (format arg1 " tag focalpull-offset DEG(~R) // float~%" f28-0) + ) + ) + ) + (none) + ) + +;; WARN: Return type mismatch object vs none. +(defun cam-layout-save-flags ((arg0 symbol) (arg1 string) (arg2 entity-actor)) + (let ((s4-0 (res-lump-value arg2 'flags uint128 :time -1000000000.0)) + (s5-0 (method-of-type res-lump get-property-value)) + (s1-0 arg2) + ) + (format (clear *res-key-string*) "~S~S" 'flags '-on) + (let ((s5-1 (s5-0 + s1-0 + (string->symbol *res-key-string*) + 'interp + -1000000000.0 + (the-as uint128 0) + (the-as (pointer res-tag) #f) + *res-static-buf* + ) + ) + (s1-1 (method-of-type res-lump get-property-value)) + ) + (format (clear *res-key-string*) "~S~S" 'flags '-off) + (let ((s3-1 (s1-1 + arg2 + (string->symbol *res-key-string*) + 'interp + -1000000000.0 + (the-as uint128 0) + (the-as (pointer res-tag) #f) + *res-static-buf* + ) + ) + ) + (when arg0 + (format #t "setup flags ") + (cam-slave-options->string (the-as cam-slave-options s4-0) #t) + (format #t "~%") + (format #t "forced on ") + (cam-slave-options->string (the-as cam-slave-options s5-1) #t) + (format #t "~%") + (format #t "forced off ") + (cam-slave-options->string (the-as cam-slave-options s3-1) #t) + (format #t "~%") + (let ((s4-1 (logclear (logior s4-0 s5-1) s3-1))) + (format #t "final ") + (cam-slave-options->string (the-as cam-slave-options s4-1) #t) + ) + (format #t "~%") + ) + (format arg1 " tag flags-on 0x~X // int32~%" s5-1) + (format arg1 " tag flags-off 0x~X // int32~%" s3-1) + ) + ) + ) + (none) + ) + +;; WARN: Return type mismatch object vs none. +(defun cam-layout-save-focalpull-flags ((arg0 symbol) (arg1 string) (arg2 entity-actor)) + (let ((s4-0 (res-lump-value arg2 'focalpull-flags uint128 :time -1000000000.0)) + (s5-0 (method-of-type res-lump get-property-value)) + (s1-0 arg2) + ) + (format (clear *res-key-string*) "~S~S" 'focalpull-flags '-on) + (let ((s5-1 (s5-0 + s1-0 + (string->symbol *res-key-string*) + 'interp + -1000000000.0 + (the-as uint128 0) + (the-as (pointer res-tag) #f) + *res-static-buf* + ) + ) + (s1-1 (method-of-type res-lump get-property-value)) + ) + (format (clear *res-key-string*) "~S~S" 'focalpull-flags '-off) + (let ((s3-1 (s1-1 + arg2 + (string->symbol *res-key-string*) + 'interp + -1000000000.0 + (the-as uint128 0) + (the-as (pointer res-tag) #f) + *res-static-buf* + ) + ) + ) + (when arg0 + (format #t "setup focalpull-flags ") + (cam-index-options->string (the-as cam-index-options s4-0) #t) + (format #t "~%") + (format #t "forced on ") + (cam-index-options->string (the-as cam-index-options s5-1) #t) + (format #t "~%") + (format #t "forced off ") + (cam-index-options->string (the-as cam-index-options s3-1) #t) + (format #t "~%") + (let ((s4-1 (logclear (logior s4-0 s5-1) s3-1))) + (format #t "final ") + (cam-index-options->string (the-as cam-index-options s4-1) #t) + ) + (format #t "~%") + ) + (format arg1 " tag focalpull-flags-on 0x~X // int32~%" s5-1) + (format arg1 " tag focalpull-flags-off 0x~X // int32~%" s3-1) + ) + ) + ) + (none) + ) + +;; WARN: Return type mismatch object vs none. +(defun cam-layout-save-campoints-flags ((arg0 symbol) (arg1 string) (arg2 entity-actor)) + (let ((s4-0 (res-lump-value arg2 'campoints-flags uint128 :time -1000000000.0)) + (s5-0 (method-of-type res-lump get-property-value)) + (s1-0 arg2) + ) + (format (clear *res-key-string*) "~S~S" 'campoints-flags '-on) + (let ((s5-1 (s5-0 + s1-0 + (string->symbol *res-key-string*) + 'interp + -1000000000.0 + (the-as uint128 0) + (the-as (pointer res-tag) #f) + *res-static-buf* + ) + ) + (s1-1 (method-of-type res-lump get-property-value)) + ) + (format (clear *res-key-string*) "~S~S" 'campoints-flags '-off) + (let ((s3-1 (s1-1 + arg2 + (string->symbol *res-key-string*) + 'interp + -1000000000.0 + (the-as uint128 0) + (the-as (pointer res-tag) #f) + *res-static-buf* + ) + ) + ) + (when arg0 + (format #t "setup campoints-flags ") + (cam-index-options->string (the-as cam-index-options s4-0) #t) + (format #t "~%") + (format #t "forced on ") + (cam-index-options->string (the-as cam-index-options s5-1) #t) + (format #t "~%") + (format #t "forced off ") + (cam-index-options->string (the-as cam-index-options s3-1) #t) + (format #t "~%") + (let ((s4-1 (logclear (logior s4-0 s5-1) s3-1))) + (format #t "final ") + (cam-index-options->string (the-as cam-index-options s4-1) #t) + ) + (format #t "~%") + ) + (format arg1 " tag campoints-flags-on 0x~X // int32~%" s5-1) + (format arg1 " tag campoints-flags-off 0x~X // int32~%" s3-1) + ) + ) + ) + (none) + ) + +;; WARN: Return type mismatch object vs none. +(defun cam-layout-save-introsplinetime ((arg0 symbol) (arg1 string) (arg2 entity-actor)) + (let ((f28-0 (res-lump-float arg2 'intro-time)) + (s3-0 (method-of-type res-lump get-property-value-float)) + ) + (format (clear *res-key-string*) "~S~S" 'intro-time '-offset) + (let ((f30-0 (s3-0 + arg2 + (string->symbol *res-key-string*) + 'interp + -1000000000.0 + 0.0 + (the-as (pointer res-tag) #f) + *res-static-buf* + ) + ) + ) + (cond + ((= f28-0 0.0) + (if arg0 + (format #t "setup intro-time 0.0 (defaults to 1 sec)~%") + ) + (set! f28-0 1.0) + ) + (arg0 + (format #t "setup intro-time ~f~%" f28-0) + ) + ) + (when (!= f30-0 0.0) + (when arg0 + (format #t "offset ~f~%" f30-0) + (format #t "final ~f~%" (+ f28-0 f30-0)) + ) + (format arg1 " tag intro-time-offset SECONDS(~f) // float~%" f30-0) + ) + ) + ) + (none) + ) + +;; WARN: Return type mismatch object vs none. +(defun cam-layout-save-introsplineexitval ((arg0 symbol) (arg1 string) (arg2 entity-actor)) + (let ((f30-0 (res-lump-float arg2 'intro-exitValue)) + (s3-0 (method-of-type res-lump get-property-value-float)) + ) + (format (clear *res-key-string*) "~S~S" 'intro-exitValue '-offset) + (let ((f28-0 (s3-0 + arg2 + (string->symbol *res-key-string*) + 'interp + -1000000000.0 + 0.0 + (the-as (pointer res-tag) #f) + *res-static-buf* + ) + ) + ) + (when arg0 + (if (= f30-0 0.0) + (format #t "setup intro-exitValue 0.0 (defaults to 0.5)~%") + (format #t "setup intro-exitValue ~f~%" f30-0) + ) + ) + (when (!= f28-0 0.0) + (when arg0 + (format #t "offset ~f~%" f28-0) + (format #t "final ~f~%" (+ f30-0 f28-0)) + ) + (format arg1 " tag intro-exitValue-offset ~f // float~%" f28-0) + ) + ) + ) + (none) + ) + +;; WARN: Return type mismatch object vs none. +(defun cam-layout-save-interptime ((arg0 symbol) (arg1 string) (arg2 entity-actor)) + (let ((f30-0 (res-lump-float arg2 'interpTime)) + (s3-0 (method-of-type res-lump get-property-value-float)) + ) + (format (clear *res-key-string*) "~S~S" 'interpTime '-offset) + (let ((f28-0 (s3-0 + arg2 + (string->symbol *res-key-string*) + 'interp + -1000000000.0 + 0.0 + (the-as (pointer res-tag) #f) + *res-static-buf* + ) + ) + ) + (if arg0 + (format #t "setup interpTime ~f~%" f30-0) + ) + (when (!= f28-0 0.0) + (when arg0 + (format #t "offset ~f~%" f28-0) + (format #t "final ~f~%" (+ f30-0 f28-0)) + ) + (format arg1 " tag interpTime-offset SECONDS(~f) // float~%" f28-0) + ) + ) + ) + (none) + ) + +;; WARN: Return type mismatch object vs none. +(defun cam-layout-save-splineoffset ((arg0 symbol) (arg1 string) (arg2 entity-actor)) + (when (and (not (res-lump-struct arg2 'pivot structure)) (res-lump-struct arg2 'spline-offset vector)) + (let ((s5-1 (res-lump-struct arg2 'spline-offset vector))) + (when s5-1 + (if arg0 + (format #t "spline offset ~M ~M ~M~%" (-> s5-1 x) (-> s5-1 y) (-> s5-1 z)) + ) + (format + arg1 + " tag spline-offset METERS(~M) METERS(~M) METERS(~M) 1.0 // vector~%" + (-> s5-1 x) + (-> s5-1 y) + (-> s5-1 z) + ) + ) + ) + ) + (none) + ) + +;; WARN: Return type mismatch object vs none. +(defun cam-layout-save-spline-follow-dist-offset ((arg0 symbol) (arg1 string) (arg2 entity-actor)) + (let ((f30-0 (res-lump-float arg2 'spline-follow-dist-offset))) + (when (the int f30-0) + (if arg0 + (format #t "spline follow dist offset ~M~%" f30-0) + ) + (format arg1 " tag spline-follow-dist-offset METERS(~M)~%" f30-0) + ) + ) + (none) + ) + +;; WARN: Return type mismatch object vs none. +(defun cam-layout-save-campointsoffset ((arg0 symbol) (arg1 string) (arg2 entity-actor)) + (let ((s5-0 (res-lump-struct arg2 'campoints-offset vector))) + (when s5-0 + (if arg0 + (format #t "index offset ~M ~M ~M~%" (-> s5-0 x) (-> s5-0 y) (-> s5-0 z)) + ) + (format + arg1 + " tag campoints-offset METERS(~M) METERS(~M) METERS(~M) 1.0 // vector~%" + (-> s5-0 x) + (-> s5-0 y) + (-> s5-0 z) + ) + ) + ) + (none) + ) + +;; WARN: Return type mismatch object vs none. +(defun cam-layout-save-tiltAdjust ((arg0 symbol) (arg1 string) (arg2 entity-actor)) + (let ((f30-0 (res-lump-float arg2 'tiltAdjust)) + (s3-0 (method-of-type res-lump get-property-value-float)) + ) + (format (clear *res-key-string*) "~S~S" 'tiltAdjust '-offset) + (let ((f28-0 (s3-0 + arg2 + (string->symbol *res-key-string*) + 'interp + -1000000000.0 + 0.0 + (the-as (pointer res-tag) #f) + *res-static-buf* + ) + ) + ) + (if arg0 + (format #t "setup tiltAdjust deg ~R~%" f30-0) + ) + (when (!= f28-0 0.0) + (when arg0 + (format #t "offset ~R~%" f28-0) + (format #t "final ~R~%" (+ f30-0 f28-0)) + ) + (format arg1 " tag tiltAdjust-offset DEG(~R) // float~%" f28-0) + ) + ) + ) + (none) + ) + +;; WARN: Return type mismatch object vs none. +(defun cam-layout-save-stringMinLength ((arg0 symbol) (arg1 string) (arg2 entity-actor)) + (let ((f30-0 (res-lump-float arg2 'stringMinLength)) + (s3-0 (method-of-type res-lump get-property-value-float)) + ) + (format (clear *res-key-string*) "~S~S" 'stringMinLength '-offset) + (let ((f28-0 (s3-0 + arg2 + (string->symbol *res-key-string*) + 'interp + -1000000000.0 + 0.0 + (the-as (pointer res-tag) #f) + *res-static-buf* + ) + ) + ) + (if arg0 + (format #t "setup stringMinLength ~M~%" f30-0) + ) + (when (!= f28-0 0.0) + (when arg0 + (format #t "offset ~M~%" f28-0) + (format #t "final ~M~%" (+ f30-0 f28-0)) + ) + (format arg1 " tag stringMinLength-offset METERS(~M) // float~%" f28-0) + ) + ) + ) + (none) + ) + +;; WARN: Return type mismatch object vs none. +(defun cam-layout-save-stringMaxLength ((arg0 symbol) (arg1 string) (arg2 entity-actor)) + (let ((f30-0 (res-lump-float arg2 'stringMaxLength)) + (s3-0 (method-of-type res-lump get-property-value-float)) + ) + (format (clear *res-key-string*) "~S~S" 'stringMaxLength '-offset) + (let ((f28-0 (s3-0 + arg2 + (string->symbol *res-key-string*) + 'interp + -1000000000.0 + 0.0 + (the-as (pointer res-tag) #f) + *res-static-buf* + ) + ) + ) + (if arg0 + (format #t "setup stringMaxLength ~M~%" f30-0) + ) + (when (!= f28-0 0.0) + (when arg0 + (format #t "offset ~M~%" f28-0) + (format #t "final ~M~%" (+ f30-0 f28-0)) + ) + (format arg1 " tag stringMaxLength-offset METERS(~M) // float~%" f28-0) + ) + ) + ) + (none) + ) + +;; WARN: Return type mismatch object vs none. +(defun cam-layout-save-stringMinHeight ((arg0 symbol) (arg1 string) (arg2 entity-actor)) + (let ((f30-0 (res-lump-float arg2 'stringMinHeight)) + (s3-0 (method-of-type res-lump get-property-value-float)) + ) + (format (clear *res-key-string*) "~S~S" 'stringMinHeight '-offset) + (let ((f28-0 (s3-0 + arg2 + (string->symbol *res-key-string*) + 'interp + -1000000000.0 + 0.0 + (the-as (pointer res-tag) #f) + *res-static-buf* + ) + ) + ) + (if arg0 + (format #t "setup stringMinHeight ~M~%" f30-0) + ) + (when (!= f28-0 0.0) + (when arg0 + (format #t "offset ~M~%" f28-0) + (format #t "final ~M~%" (+ f30-0 f28-0)) + ) + (format arg1 " tag stringMinHeight-offset METERS(~M) // float~%" f28-0) + ) + ) + ) + (none) + ) + +;; WARN: Return type mismatch object vs none. +(defun cam-layout-save-stringMaxHeight ((arg0 symbol) (arg1 string) (arg2 entity-actor)) + (let ((f30-0 (res-lump-float arg2 'stringMaxHeight)) + (s3-0 (method-of-type res-lump get-property-value-float)) + ) + (format (clear *res-key-string*) "~S~S" 'stringMaxHeight '-offset) + (let ((f28-0 (s3-0 + arg2 + (string->symbol *res-key-string*) + 'interp + -1000000000.0 + 0.0 + (the-as (pointer res-tag) #f) + *res-static-buf* + ) + ) + ) + (if arg0 + (format #t "setup stringMaxHeight ~M~%" f30-0) + ) + (when (!= f28-0 0.0) + (when arg0 + (format #t "offset ~M~%" f28-0) + (format #t "final ~M~%" (+ f30-0 f28-0)) + ) + (format arg1 " tag stringMaxHeight-offset METERS(~M) // float~%" f28-0) + ) + ) + ) + (none) + ) + +;; WARN: Return type mismatch object vs none. +(defun cam-layout-save-stringCliffHeight ((arg0 symbol) (arg1 string) (arg2 entity-actor)) + (let ((f30-0 (res-lump-float arg2 'stringCliffHeight)) + (s3-0 (method-of-type res-lump get-property-value-float)) + ) + (format (clear *res-key-string*) "~S~S" 'stringCliffHeight '-offset) + (let ((f28-0 (s3-0 + arg2 + (string->symbol *res-key-string*) + 'interp + -1000000000.0 + 0.0 + (the-as (pointer res-tag) #f) + *res-static-buf* + ) + ) + ) + (if arg0 + (format #t "setup stringCliffHeight ~M~%" f30-0) + ) + (when (!= f28-0 0.0) + (when arg0 + (format #t "offset ~M~%" f28-0) + (format #t "final ~M~%" (+ f30-0 f28-0)) + ) + (format arg1 " tag stringCliffHeight-offset METERS(~M) // float~%" f28-0) + ) + ) + ) + (none) + ) + +;; WARN: Return type mismatch object vs none. +(defun cam-layout-save-maxAngle ((arg0 symbol) (arg1 string) (arg2 entity-actor)) + (let ((f30-0 (res-lump-float arg2 'maxAngle)) + (s3-0 (method-of-type res-lump get-property-value-float)) + ) + (format (clear *res-key-string*) "~S~S" 'maxAngle '-offset) + (let ((f28-0 (s3-0 + arg2 + (string->symbol *res-key-string*) + 'interp + -1000000000.0 + 0.0 + (the-as (pointer res-tag) #f) + *res-static-buf* + ) + ) + ) + (if arg0 + (format #t "setup maxAngle ~R~%" f30-0) + ) + (when (!= f28-0 0.0) + (when arg0 + (format #t "offset ~R~%" f28-0) + (format #t "final ~R~%" (+ f30-0 f28-0)) + ) + (format arg1 " tag maxAngle-offset DEG(~R) // float~%" f28-0) + ) + ) + ) + (none) + ) + +(defbehavior clmf-save-single cam-layout ((arg0 entity-camera) (arg1 symbol) (arg2 symbol)) + (clear *temp-string*) + (if arg2 + (format *temp-string* "db/caminfo/~s.cam" (res-lump-struct arg0 'name structure)) + (format *temp-string* "db/caminfo/garbage") + ) + (let ((s4-2 (new 'stack 'file-stream *temp-string* 'write))) + (if arg1 + (format #t "---------camera '~S'------------~%" (res-lump-struct arg0 'name structure)) + ) + (format s4-2 "#include /jak3/db/config/standard.m2d~%") + (format s4-2 "camera ~s {~%" (res-lump-struct arg0 'name structure)) + (cam-layout-save-cam-rot arg1 (the-as string s4-2) (the-as entity-actor arg0)) + (cam-layout-save-cam-trans arg1 (the-as string s4-2) (the-as entity-actor arg0)) + (cam-layout-save-pivot arg1 (the-as string s4-2) (the-as entity-actor arg0)) + (cam-layout-save-align arg1 (the-as string s4-2) (the-as entity-actor arg0)) + (cam-layout-save-interesting arg1 (the-as string s4-2) (the-as entity-actor arg0)) + (cam-layout-save-fov arg1 (the-as string s4-2) (the-as entity-actor arg0)) + (cam-layout-save-focalpull arg1 (the-as string s4-2) (the-as entity-actor arg0)) + (cam-layout-save-flags arg1 (the-as string s4-2) (the-as entity-actor arg0)) + (cam-layout-save-introsplinetime arg1 (the-as string s4-2) (the-as entity-actor arg0)) + (cam-layout-save-introsplineexitval arg1 (the-as string s4-2) (the-as entity-actor arg0)) + (cam-layout-save-interptime arg1 (the-as string s4-2) (the-as entity-actor arg0)) + (cam-layout-save-splineoffset arg1 (the-as string s4-2) (the-as entity-actor arg0)) + (cam-layout-save-spline-follow-dist-offset arg1 (the-as string s4-2) (the-as entity-actor arg0)) + (cam-layout-save-campointsoffset arg1 (the-as string s4-2) (the-as entity-actor arg0)) + (cam-layout-save-tiltAdjust arg1 (the-as string s4-2) (the-as entity-actor arg0)) + (cam-layout-save-stringMinLength arg1 (the-as string s4-2) (the-as entity-actor arg0)) + (cam-layout-save-stringMaxLength arg1 (the-as string s4-2) (the-as entity-actor arg0)) + (cam-layout-save-stringMinHeight arg1 (the-as string s4-2) (the-as entity-actor arg0)) + (cam-layout-save-stringMaxHeight arg1 (the-as string s4-2) (the-as entity-actor arg0)) + (cam-layout-save-stringCliffHeight arg1 (the-as string s4-2) (the-as entity-actor arg0)) + (cam-layout-save-maxAngle arg1 (the-as string s4-2) (the-as entity-actor arg0)) + (cam-layout-save-campoints-flags arg1 (the-as string s4-2) (the-as entity-actor arg0)) + (cam-layout-save-focalpull-flags arg1 (the-as string s4-2) (the-as entity-actor arg0)) + (format s4-2 "}~%") + (file-stream-close s4-2) + ) + ) + +(defbehavior clmf-save-one cam-layout ((arg0 symbol)) + (let ((s5-1 (logtest? (the-as int arg0) 8)) + (gp-1 (logtest? (the-as int arg0) 16)) + ) + (if s5-1 + (format #t "~%~%~%=================================~%") + ) + (clmf-save-single (-> self cam-entity) s5-1 gp-1) + (if s5-1 + (format #t "===============================~%~%~%~%") + ) + (if gp-1 + (format #t "'~S' save completed~%" (res-lump-struct (-> self cam-entity) 'name structure)) + ) + ) + #t + ) + +(defbehavior clmf-save-all cam-layout ((arg0 symbol)) + (let ((s5-1 (logtest? (the-as int arg0) 8)) + (gp-1 (logtest? (the-as int arg0) 16)) + ) + (if s5-1 + (format #t "~%~%~%=================================~%") + ) + (let ((v1-5 (-> *camera-engine* alive-list next0))) + *camera-engine* + (let ((s4-0 (-> v1-5 next0))) + (while (!= v1-5 (-> *camera-engine* alive-list-end)) + (let ((a0-4 (-> (the-as connection v1-5) param1))) + (clmf-save-single (the-as entity-camera a0-4) s5-1 gp-1) + ) + (set! v1-5 s4-0) + *camera-engine* + (set! s4-0 (-> s4-0 next0)) + ) + ) + ) + (if s5-1 + (format #t "===============================~%~%~%~%") + ) + (if gp-1 + (format #t "camera save all completed~%") + ) + ) + #t + ) + +(deftype clmf-cam-flag-toggle-info (structure) + ((key float) + (force-on int32) + (force-off int32) + ) + ) + + +(defbehavior clmf-cam-flag-toggle cam-layout ((arg0 int) (arg1 int)) + (let ((s4-0 (/ arg0 8)) + (gp-0 (new 'stack 'clmf-cam-flag-toggle-info)) + ) + (set! (-> gp-0 key) (-> self res-key)) + (cond + ((and (= arg1 'vol-flags) (>= (-> self res-key) (the float (-> self first-cutoutvol)))) + (set! (-> gp-0 key) (- (-> gp-0 key) (the float (-> self first-cutoutvol)))) + (set! arg1 (the-as int 'cutoutvol-flags)) + ) + ((and (= arg1 'vol-flags) (>= (-> self res-key) (the float (-> self first-pvol)))) + (set! (-> gp-0 key) (- (-> gp-0 key) (the float (-> self first-pvol)))) + (set! arg1 (the-as int 'pvol-flags)) + ) + ) + (let ((s3-0 (method-of-type res-lump get-property-value)) + (s2-0 (-> self cam-entity)) + ) + (format (clear *res-key-string*) "~S~S" (the-as object arg1) '-on) + (set! (-> gp-0 force-on) (the-as int (s3-0 + s2-0 + (string->symbol *res-key-string*) + 'exact + (-> gp-0 key) + (the-as uint128 0) + (the-as (pointer res-tag) #f) + *res-static-buf* + ) + ) + ) + ) + (let ((s3-1 (method-of-type res-lump get-property-value)) + (s2-1 (-> self cam-entity)) + ) + (format (clear *res-key-string*) "~S~S" (the-as object arg1) '-off) + (set! (-> gp-0 force-off) (the-as int (s3-1 + s2-1 + (string->symbol *res-key-string*) + 'exact + (-> gp-0 key) + (the-as uint128 0) + (the-as (pointer res-tag) #f) + *res-static-buf* + ) + ) + ) + ) + (cond + ((logtest? (-> gp-0 force-off) s4-0) + (logclear! (-> gp-0 force-off) s4-0) + (logior! (-> gp-0 force-on) s4-0) + (let* ((s4-1 (-> self cam-entity)) + (s3-2 (method-of-object s4-1 add-32bit-data!)) + (s2-2 (logior (shl #x10000 32) (shr (shl (the-as int int32) 32) 32))) + (s1-2 (shl (the-as int (-> gp-0 key)) 32)) + ) + (format (clear *res-key-string*) "~S~S" (the-as object arg1) '-off) + (s3-2 + s4-1 + (the-as + res-tag + (make-u128 s2-2 (logior s1-2 (shr (shl (the-as int (string->symbol *res-key-string*)) 32) 32))) + ) + (-> gp-0 force-off) + ) + ) + (let* ((s4-2 (-> self cam-entity)) + (s3-3 (method-of-object s4-2 add-32bit-data!)) + (s2-3 (logior (shl #x10000 32) (shr (shl (the-as int int32) 32) 32))) + (s1-3 (shl (the-as int (-> gp-0 key)) 32)) + ) + (format (clear *res-key-string*) "~S~S" (the-as object arg1) '-on) + (s3-3 + s4-2 + (the-as + res-tag + (make-u128 s2-3 (logior s1-3 (shr (shl (the-as int (string->symbol *res-key-string*)) 32) 32))) + ) + (-> gp-0 force-on) + ) + ) + ) + ((logtest? (-> gp-0 force-on) s4-0) + (logclear! (-> gp-0 force-on) s4-0) + (let* ((s4-3 (-> self cam-entity)) + (s3-4 (method-of-object s4-3 add-32bit-data!)) + (s2-4 (logior (shl #x10000 32) (shr (shl (the-as int int32) 32) 32))) + (s1-4 (shl (the-as int (-> gp-0 key)) 32)) + ) + (format (clear *res-key-string*) "~S~S" (the-as object arg1) '-on) + (s3-4 + s4-3 + (the-as + res-tag + (make-u128 s2-4 (logior s1-4 (shr (shl (the-as int (string->symbol *res-key-string*)) 32) 32))) + ) + (-> gp-0 force-on) + ) + ) + ) + (else + (logior! (-> gp-0 force-off) s4-0) + (let* ((s4-4 (-> self cam-entity)) + (s3-5 (method-of-object s4-4 add-32bit-data!)) + (s2-5 (logior (shl #x10000 32) (shr (shl (the-as int int32) 32) 32))) + (s1-5 (shl (the-as int (-> gp-0 key)) 32)) + ) + (format (clear *res-key-string*) "~S~S" (the-as object arg1) '-off) + (s3-5 + s4-4 + (the-as + res-tag + (make-u128 s2-5 (logior s1-5 (shr (shl (the-as int (string->symbol *res-key-string*)) 32) 32))) + ) + (-> gp-0 force-off) + ) + ) + ) + ) + ) + #t + ) + +(defbehavior clmf-cam-flag cam-layout ((arg0 string) (arg1 uint) (arg2 uint)) + (let ((s5-0 (/ (the-as int arg1) 8)) + (f30-0 (-> self res-key)) + ) + (cond + ((and (= arg2 'vol-flags) (>= (-> self res-key) (the float (-> self first-cutoutvol)))) + (set! f30-0 (- f30-0 (the float (-> self first-cutoutvol)))) + (set! arg2 (the-as uint 'cutoutvol-flags)) + ) + ((and (= arg2 'vol-flags) (>= (-> self res-key) (the float (-> self first-pvol)))) + (set! f30-0 (- f30-0 (the float (-> self first-pvol)))) + (set! arg2 (the-as uint 'pvol-flags)) + ) + ) + (let ((s3-0 (method-of-type res-lump get-property-value)) + (s2-0 (-> self cam-entity)) + ) + (format (clear *res-key-string*) "~S~S" (the-as object arg2) '-off) + (cond + ((logtest? (s3-0 + s2-0 + (string->symbol *res-key-string*) + 'exact + f30-0 + (the-as uint128 0) + (the-as (pointer res-tag) #f) + *res-static-buf* + ) + s5-0 + ) + (format arg0 ": off") + ) + ((let ((s3-1 (method-of-type res-lump get-property-value)) + (s2-1 (-> self cam-entity)) + ) + (format (clear *res-key-string*) "~S~S" (the-as object arg2) '-on) + (logtest? (s3-1 + s2-1 + (string->symbol *res-key-string*) + 'exact + f30-0 + (the-as uint128 0) + (the-as (pointer res-tag) #f) + *res-static-buf* + ) + s5-0 + ) + ) + (format arg0 ": on") + ) + ((not (logtest? ((method-of-type res-lump get-property-value) + (-> self cam-entity) + (the-as symbol arg2) + 'exact + f30-0 + (the-as uint128 0) + (the-as (pointer res-tag) #f) + *res-static-buf* + ) + s5-0 + ) + ) + (format arg0 ": off(maya)") + ) + (else + (format arg0 ": on(maya)") + ) + ) + ) + ) + #t + ) + +(defbehavior clmf-cam-float-adjust cam-layout ((arg0 symbol) (arg1 (pointer float))) + (cam-layout-print 16 *camera-layout-message-ypos* "left stick adjusts value") + (set! *camera-layout-message-ypos* (+ *camera-layout-message-ypos* 14)) + (let ((f30-0 (res-lump-float (-> self cam-entity) arg0)) + (f0-0 (-> arg1 0)) + ) + (if (= f0-0 0.0) + (set! f0-0 1.0) + ) + (let ((f0-2 (+ f30-0 (analog-input (the-as int (-> *cpad-list* cpads 0 leftx)) 128.0 48.0 110.0 f0-0)))) + (add-32bit-data! + (-> self cam-entity) + (new 'static 'res-tag :name arg0 :key-frame -1000000000.0 :elt-count #x1 :elt-type float) + f0-2 + ) + ) + ) + (set-setting! 'master-options 'set 0.0 32) + #t + ) + +(defbehavior clmf-cam-meters cam-layout ((arg0 meters) (arg1 symbol)) + (let ((f0-0 (cam-slave-get-float (-> self cam-entity) arg1 0.0))) + (format arg0 ": ~M" f0-0) + ) + #t + ) + +(defbehavior clmf-cam-fov cam-layout ((arg0 degrees) (arg1 symbol)) + (format arg0 ": ~R" (cam-slave-get-fov (-> self cam-entity))) + #t + ) + +(defbehavior clmf-cam-deg cam-layout ((arg0 degrees) (arg1 symbol)) + (format arg0 ": ~R" (cam-slave-get-float (-> self cam-entity) arg1 0.0)) + #t + ) + +(defbehavior clmf-cam-intro-time cam-layout ((arg0 float) (arg1 symbol)) + (let ((f30-0 (cam-slave-get-intro-step (-> self cam-entity)))) + (format arg0 ": ~f" (/ 0.016666668 f30-0)) + (set! (-> *CAM_LAYOUT-bank* intro-step) f30-0) + ) + #t + ) + +(defbehavior clmf-cam-interp-time cam-layout ((arg0 float) (arg1 symbol)) + (format arg0 ": ~f" (cam-slave-get-interp-time (-> self cam-entity))) + #t + ) + +(defbehavior clmf-cam-float cam-layout ((arg0 float) (arg1 symbol)) + (format arg0 ": ~f" (cam-slave-get-float (-> self cam-entity) arg1 0.0)) + #t + ) + +(defbehavior clmf-cam-string cam-layout ((arg0 string) (arg1 symbol)) + (local-vars (r0-0 uint128) (v1-5 uint128) (sv-16 int)) + (format arg0 ":") + (set! sv-16 0) + (let ((s5-1 (res-lump-data (-> self cam-entity) arg1 pointer :tag-ptr (the-as (pointer res-tag) (& sv-16))))) + (when s5-1 + (let ((s4-0 0)) + (while (begin + (let ((v1-4 (the-as uint128 sv-16))) + (.pcpyud v1-5 v1-4 r0-0) + ) + (< s4-0 (shr (* (the-as int v1-5) 2) 49)) + ) + (format arg0 " ~S" (-> (the-as (pointer uint32) (&+ s5-1 (* s4-0 4))))) + (+! s4-0 1) + ) + ) + ) + ) + #t + ) + +(define *clm-focalpull-attr* + (new 'static 'clm + :title "---focalpull attributes--" + :items (new 'static 'boxed-array :type clm-basic + (new 'static 'clm-item + :description " ok" + :button-symbol 'square + :action (new 'static 'clm-item-action + :button (pad-buttons-u64 square) + :options (clm-item-action-options clm0) + :func '*clm-edit* + ) + ) + (new 'static 'clm-item + :description "adjust" + :button-symbol 'x + :action (new 'static 'clm-item-action :button (pad-buttons-u64 x) :func #f) + ) + (new 'static 'clm-list + :tracker #f + :items (new 'static 'boxed-array :type clm-list-item + (new 'static 'clm-list-item + :description "radial " + :track-val #f + :val-func 'clmf-cam-flag + :val-parm0 16 + :val-parm1 'focalpull-flags + :actions (new 'static 'boxed-array :type clm-item-action + (new 'static 'clm-item-action + :button (pad-buttons-u64 x) + :options (clm-item-action-options clm0) + :func 'clmf-cam-flag-toggle + :parm0 16 + :parm1 'focalpull-flags + ) + ) + ) + (new 'static 'clm-list-item + :description "spherical " + :track-val #f + :val-func 'clmf-cam-flag + :val-parm0 8 + :val-parm1 'focalpull-flags + :actions (new 'static 'boxed-array :type clm-item-action (new 'static 'clm-item-action + :button (pad-buttons-u64 x) + :options (clm-item-action-options clm0) + :func 'clmf-cam-flag-toggle + :parm0 8 + :parm1 'focalpull-flags + ) + ) + ) + ) + ) + ) + ) + ) + +(define *clm-index-attr* + (new 'static 'clm + :title "---index attributes--" + :items (new 'static 'boxed-array :type clm-basic + (new 'static 'clm-item + :description " ok" + :button-symbol 'square + :action (new 'static 'clm-item-action + :button (pad-buttons-u64 square) + :options (clm-item-action-options clm0) + :func '*clm-edit* + ) + ) + (new 'static 'clm-item + :description "adjust" + :button-symbol 'x + :action (new 'static 'clm-item-action :button (pad-buttons-u64 x) :func #f) + ) + (new 'static 'clm-list + :tracker #f + :items (new 'static 'boxed-array :type clm-list-item + (new 'static 'clm-list-item + :description "radial " + :track-val #f + :val-func 'clmf-cam-flag + :val-parm0 16 + :val-parm1 'campoints-flags + :actions (new 'static 'boxed-array :type clm-item-action + (new 'static 'clm-item-action + :button (pad-buttons-u64 x) + :options (clm-item-action-options clm0) + :func 'clmf-cam-flag-toggle + :parm0 16 + :parm1 'campoints-flags + ) + ) + ) + (new 'static 'clm-list-item + :description "spherical " + :track-val #f + :val-func 'clmf-cam-flag + :val-parm0 8 + :val-parm1 'campoints-flags + :actions (new 'static 'boxed-array :type clm-item-action (new 'static 'clm-item-action + :button (pad-buttons-u64 x) + :options (clm-item-action-options clm0) + :func 'clmf-cam-flag-toggle + :parm0 8 + :parm1 'campoints-flags + ) + ) + ) + ) + ) + ) + ) + ) + +(define *clm-intro-attr* + (new 'static 'clm + :title "---intro attributes--" + :items (new 'static 'boxed-array :type clm-basic + (new 'static 'clm-item + :description " ok" + :button-symbol 'square + :action (new 'static 'clm-item-action + :button (pad-buttons-u64 square) + :options (clm-item-action-options clm0) + :func '*clm-edit* + ) + ) + (new 'static 'clm-item + :description "adjust" + :button-symbol 'x + :action (new 'static 'clm-item-action :button (pad-buttons-u64 x) :func #f) + ) + (new 'static 'clm-list + :tracker #f + :items (new 'static 'boxed-array :type clm-list-item + (new 'static 'clm-list-item + :description "time " + :track-val #f + :val-func 'clmf-cam-intro-time + :val-parm0-sym 'intro-time + :actions (new 'static 'boxed-array :type clm-item-action + (new 'static 'clm-item-action + :button (pad-buttons-u64 x) + :func 'clmf-cam-float-adjust + :parm0-sym 'intro-time-offset + :parm1-basic (new 'static 'bfloat :data 0.01) + ) + ) + ) + (new 'static 'clm-list-item + :description "exitValue" + :track-val #f + :val-func 'clmf-cam-float + :val-parm0-sym 'intro-exitValue + :actions (new 'static 'boxed-array :type clm-item-action (new 'static 'clm-item-action + :button (pad-buttons-u64 x) + :func 'clmf-cam-float-adjust + :parm0-sym 'intro-exitValue-offset + :parm1-basic (new 'static 'bfloat :data 0.001) + ) + ) + ) + ) + ) + ) + ) + ) + +(define *clm-spline-attr* + (new 'static 'clm + :title "---spline attributes--" + :items (new 'static 'boxed-array :type clm-basic + (new 'static 'clm-item + :description " ok" + :button-symbol 'square + :action (new 'static 'clm-item-action + :button (pad-buttons-u64 square) + :options (clm-item-action-options clm0) + :func '*clm-edit* + ) + ) + (new 'static 'clm-item + :description "adjust" + :button-symbol 'x + :action (new 'static 'clm-item-action :button (pad-buttons-u64 x) :func #f) + ) + (new 'static 'clm-list + :tracker #f + :items (new 'static 'boxed-array :type clm-list-item + (new 'static 'clm-list-item + :description "followDist" + :track-val #f + :val-func 'clmf-cam-meters + :val-parm0-sym 'spline-follow-dist + :actions (new 'static 'boxed-array :type clm-item-action (new 'static 'clm-item-action + :button (pad-buttons-u64 x) + :func 'clmf-cam-float-adjust + :parm0-sym 'spline-follow-dist-offset + :parm1-basic (new 'static 'bfloat :data 409.6) + ) + ) + ) + ) + ) + ) + ) + ) + +(define *clm-cam-attr* + (new 'static 'clm + :title "---camera attributes--" + :items (new 'static 'boxed-array :type clm-basic + (new 'static 'clm-item + :description " ok" + :button-symbol 'square + :action (new 'static 'clm-item-action + :button (pad-buttons-u64 square) + :options (clm-item-action-options clm0) + :func '*clm-edit* + ) + ) + (new 'static 'clm-item + :description "adjust" + :button-symbol 'x + :action (new 'static 'clm-item-action :button (pad-buttons-u64 x) :func #f) + ) + (new 'static 'clm-list + :tracker #f + :items (new 'static 'boxed-array :type clm-list-item + (new 'static 'clm-list-item + :description "drag " + :track-val #f + :val-func 'clmf-cam-flag + :val-parm0 #x400 + :val-parm1 'flags + :actions (new 'static 'boxed-array :type clm-item-action + (new 'static 'clm-item-action + :button (pad-buttons-u64 x) + :options (clm-item-action-options clm0) + :func 'clmf-cam-flag-toggle + :parm0 #x400 + :parm1 'flags + ) + ) + ) + (new 'static 'clm-list-item + :description "fov " + :track-val #f + :val-func 'clmf-cam-fov + :val-parm0-sym 'fov + :actions (new 'static 'boxed-array :type clm-item-action + (new 'static 'clm-item-action + :button (pad-buttons-u64 x) + :func 'clmf-cam-float-adjust + :parm0-sym 'fov-offset + :parm1-basic (new 'static 'bfloat :data 91.022224) + ) + ) + ) + (new 'static 'clm-list-item + :description "focalpull " + :track-val #f + :val-func 'clmf-cam-deg + :val-parm0-sym 'focalpull + :actions (new 'static 'boxed-array :type clm-item-action + (new 'static 'clm-item-action + :button (pad-buttons-u64 x) + :func 'clmf-cam-float-adjust + :parm0-sym 'focalpull-offset + :parm1-basic (new 'static 'bfloat :data 91.022224) + ) + ) + ) + (new 'static 'clm-list-item + :description "interpTime " + :track-val #f + :val-func 'clmf-cam-interp-time + :val-parm0-sym 'interpTime + :actions (new 'static 'boxed-array :type clm-item-action + (new 'static 'clm-item-action + :button (pad-buttons-u64 x) + :func 'clmf-cam-float-adjust + :parm0-sym 'interpTime-offset + :parm1-basic (new 'static 'bfloat :data 0.01) + ) + ) + ) + (new 'static 'clm-list-item + :description "sameSide " + :track-val #f + :val-func 'clmf-cam-flag + :val-parm0 16 + :val-parm1 'flags + :actions (new 'static 'boxed-array :type clm-item-action + (new 'static 'clm-item-action + :button (pad-buttons-u64 x) + :options (clm-item-action-options clm0) + :func 'clmf-cam-flag-toggle + :parm0 16 + :parm1 'flags + ) + ) + ) + (new 'static 'clm-list-item + :description "spherical " + :track-val #f + :val-func 'clmf-cam-flag + :val-parm0 32 + :val-parm1 'flags + :actions (new 'static 'boxed-array :type clm-item-action + (new 'static 'clm-item-action + :button (pad-buttons-u64 x) + :options (clm-item-action-options clm0) + :func 'clmf-cam-flag-toggle + :parm0 32 + :parm1 'flags + ) + ) + ) + (new 'static 'clm-list-item + :description "MinLength " + :track-val #f + :val-func 'clmf-cam-meters + :val-parm0-sym 'stringMinLength + :actions (new 'static 'boxed-array :type clm-item-action + (new 'static 'clm-item-action + :button (pad-buttons-u64 x) + :func 'clmf-cam-float-adjust + :parm0-sym 'stringMinLength-offset + :parm1-basic (new 'static 'bfloat :data 409.6) + ) + ) + ) + (new 'static 'clm-list-item + :description "MaxLength " + :track-val #f + :val-func 'clmf-cam-meters + :val-parm0-sym 'stringMaxLength + :actions (new 'static 'boxed-array :type clm-item-action + (new 'static 'clm-item-action + :button (pad-buttons-u64 x) + :func 'clmf-cam-float-adjust + :parm0-sym 'stringMaxLength-offset + :parm1-basic (new 'static 'bfloat :data 409.6) + ) + ) + ) + (new 'static 'clm-list-item + :description "MinHeight " + :track-val #f + :val-func 'clmf-cam-meters + :val-parm0-sym 'stringMinHeight + :actions (new 'static 'boxed-array :type clm-item-action + (new 'static 'clm-item-action + :button (pad-buttons-u64 x) + :func 'clmf-cam-float-adjust + :parm0-sym 'stringMinHeight-offset + :parm1-basic (new 'static 'bfloat :data 409.6) + ) + ) + ) + (new 'static 'clm-list-item + :description "MaxHeight " + :track-val #f + :val-func 'clmf-cam-meters + :val-parm0-sym 'stringMaxHeight + :actions (new 'static 'boxed-array :type clm-item-action + (new 'static 'clm-item-action + :button (pad-buttons-u64 x) + :func 'clmf-cam-float-adjust + :parm0-sym 'stringMaxHeight-offset + :parm1-basic (new 'static 'bfloat :data 409.6) + ) + ) + ) + (new 'static 'clm-list-item + :description "cliffHeight" + :track-val #f + :val-func 'clmf-cam-meters + :val-parm0-sym 'stringCliffHeight + :actions (new 'static 'boxed-array :type clm-item-action + (new 'static 'clm-item-action + :button (pad-buttons-u64 x) + :func 'clmf-cam-float-adjust + :parm0-sym 'stringCliffHeight-offset + :parm1-basic (new 'static 'bfloat :data 409.6) + ) + ) + ) + (new 'static 'clm-list-item + :description "alternates " + :track-val #f + :val-func 'clmf-cam-string + :val-parm0-sym 'alternates + :actions (new 'static 'boxed-array :type clm-item-action) + ) + (new 'static 'clm-list-item + :description "maxAngle " + :track-val #f + :val-func 'clmf-cam-deg + :val-parm0-sym 'maxAngle + :actions (new 'static 'boxed-array :type clm-item-action + (new 'static 'clm-item-action + :button (pad-buttons-u64 x) + :func 'clmf-cam-float-adjust + :parm0-sym 'maxAngle-offset + :parm1-basic (new 'static 'bfloat :data 91.022224) + ) + ) + ) + (new 'static 'clm-list-item + :description "shrinkAngle" + :track-val #f + :val-func 'clmf-cam-flag + :val-parm0 #x4000 + :val-parm1 'flags + :actions (new 'static 'boxed-array :type clm-item-action + (new 'static 'clm-item-action + :button (pad-buttons-u64 x) + :options (clm-item-action-options clm0) + :func 'clmf-cam-flag-toggle + :parm0 #x4000 + :parm1 'flags + ) + ) + ) + (new 'static 'clm-list-item + :description "noRotate " + :track-val #f + :val-func 'clmf-cam-flag + :val-parm0 #x20000 + :val-parm1 'flags + :actions (new 'static 'boxed-array :type clm-item-action + (new 'static 'clm-item-action + :button (pad-buttons-u64 x) + :options (clm-item-action-options clm0) + :func 'clmf-cam-flag-toggle + :parm0 #x20000 + :parm1 'flags + ) + ) + ) + (new 'static 'clm-list-item + :description "tiltAdjust " + :track-val #f + :val-func 'clmf-cam-deg + :val-parm0-sym 'tiltAdjust + :actions (new 'static 'boxed-array :type clm-item-action + (new 'static 'clm-item-action + :button (pad-buttons-u64 x) + :func 'clmf-cam-float-adjust + :parm0-sym 'tiltAdjust-offset + :parm1-basic (new 'static 'bfloat :data 91.022224) + ) + ) + ) + (new 'static 'clm-list-item + :description "stickyAngle" + :track-val #f + :val-func 'clmf-cam-flag + :val-parm0 #x40000 + :val-parm1 'flags + :actions (new 'static 'boxed-array :type clm-item-action + (new 'static 'clm-item-action + :button (pad-buttons-u64 x) + :options (clm-item-action-options clm0) + :func 'clmf-cam-flag-toggle + :parm0 #x40000 + :parm1 'flags + ) + ) + ) + (new 'static 'clm-list-item + :description "easeSpline " + :track-val #f + :val-func 'clmf-cam-flag + :val-parm0 #x1000000 + :val-parm1 'flags + :actions (new 'static 'boxed-array :type clm-item-action + (new 'static 'clm-item-action + :button (pad-buttons-u64 x) + :options (clm-item-action-options clm0) + :func 'clmf-cam-flag-toggle + :parm0 #x1000000 + :parm1 'flags + ) + ) + ) + (new 'static 'clm-list-item + :description "jumpPitch " + :track-val #f + :val-func 'clmf-cam-flag + :val-parm0 #x80 + :val-parm1 'flags + :actions (new 'static 'boxed-array :type clm-item-action + (new 'static 'clm-item-action + :button (pad-buttons-u64 x) + :options (clm-item-action-options clm0) + :func 'clmf-cam-flag-toggle + :parm0 #x80 + :parm1 'flags + ) + ) + ) + (new 'static 'clm-list-item + :description "rapid " + :track-val #f + :val-func 'clmf-cam-flag + :val-parm0 #x800000 + :val-parm1 'flags + :actions (new 'static 'boxed-array :type clm-item-action (new 'static 'clm-item-action + :button (pad-buttons-u64 x) + :options (clm-item-action-options clm0) + :func 'clmf-cam-flag-toggle + :parm0 #x800000 + :parm1 'flags + ) + ) + ) + ) + ) + ) + ) + ) + +(define *clm-cam-lookthrough* + (new 'static 'clm + :title "---cam-lookthrough---" + :items (new 'static 'boxed-array :type clm-basic + (new 'static 'clm-item + :description " " + :button-symbol 'x + :action (new 'static 'clm-item-action + :button (pad-buttons-u64 x) + :options (clm-item-action-options clm2) + :func 'clmf-look-through + ) + ) + (new 'static 'clm-item + :description " ok" + :button-symbol 'square + :action (new 'static 'clm-item-action + :button (pad-buttons-u64 square) + :options (clm-item-action-options clm0) + :func 'clmf-to-edit + ) + ) + (new 'static 'clm-item + :description "pos/rot" + :button-symbol 'x + :action (new 'static 'clm-item-action + :button (pad-buttons-u64 x) + :options (clm-item-action-options clm3) + :func 'clmf-pos-rot + :parm0-sym 'trans-offset + :parm1 'rot-offset + ) + ) + (new 'static 'clm-item + :description " adjust" + :button-symbol 'x + :action (new 'static 'clm-item-action :button (pad-buttons-u64 x) :func #f) + ) + (new 'static 'clm-list + :tracker #f + :items (new 'static 'boxed-array :type clm-list-item + (new 'static 'clm-list-item + :description "fov" + :track-val #f + :val-func 'clmf-cam-fov + :val-parm0-sym 'fov + :actions (new 'static 'boxed-array :type clm-item-action (new 'static 'clm-item-action + :button (pad-buttons-u64 x) + :func 'clmf-cam-float-adjust + :parm0-sym 'fov-offset + :parm1-basic (new 'static 'bfloat :data 91.022224) + ) + ) + ) + ) + ) + ) + ) + ) + +(define *clm-edit* + (new 'static 'clm + :title "---edit---" + :items (new 'static 'boxed-array :type clm-basic + (new 'static 'clm-item + :description " ok" + :button-symbol 'square + :action (new 'static 'clm-item-action + :button (pad-buttons-u64 square) + :options (clm-item-action-options clm0) + :func 'clmf-to-select + ) + ) + (new 'static 'clm-item + :description "attributes" + :button-symbol 'x + :action (new 'static 'clm-item-action :button (pad-buttons-u64 x) :options (clm-item-action-options clm0) :func #f) + ) + (new 'static 'clm-item + :description " edit part" + :button-symbol 'circle + :action (new 'static 'clm-item-action + :button (pad-buttons-u64 circle) + :options (clm-item-action-options clm0) + :func #f + ) + ) + (new 'static 'clm-item + :description "scale/next" + :button-symbol 'r2 + :action (new 'static 'clm-item-action :button (pad-buttons-u64 r2) :func #f) + ) + (new 'static 'clm-item + :description " pos/rot" + :button-symbol 'l2 + :action (new 'static 'clm-item-action :button (pad-buttons-u64 l2) :func #f) + ) + (new 'static 'clm-list + :tracker '*camera-layout-blink* + :items (new 'static 'boxed-array :type clm-list-item + (new 'static 'clm-list-item + :description "camera " + :track-val 'camera + :val-func #f + :actions (new 'static 'boxed-array :type clm-item-action + (new 'static 'clm-item-action + :button (pad-buttons-u64 x) + :options (clm-item-action-options clm0) + :func '*clm-cam-attr* + ) + (new 'static 'clm-item-action :button (pad-buttons-u64 circle) :func '*clm-cam-lookthrough*) + (new 'static 'clm-item-action :button (pad-buttons-u64 r2) :func 'clmf-bna) + (new 'static 'clm-item-action + :button (pad-buttons-u64 l2) + :func 'clmf-pos-rot + :parm0-sym 'trans-offset + :parm1 'rot-offset + ) + ) + ) + (new 'static 'clm-list-item + :description "align " + :track-val 'align + :val-func #f + :actions (new 'static 'boxed-array :type clm-item-action + (new 'static 'clm-item-action :button (pad-buttons-u64 x) :func 'clmf-bna) + (new 'static 'clm-item-action :button (pad-buttons-u64 circle) :func 'clmf-bna) + (new 'static 'clm-item-action :button (pad-buttons-u64 r2) :func 'clmf-bna) + (new 'static 'clm-item-action + :button (pad-buttons-u64 l2) + :func 'clmf-pos-rot + :parm0-sym 'align-offset + :parm1 #f + ) + ) + ) + (new 'static 'clm-list-item + :description "pivot " + :track-val 'pivot + :val-func #f + :actions (new 'static 'boxed-array :type clm-item-action + (new 'static 'clm-item-action :button (pad-buttons-u64 x) :func 'clmf-bna) + (new 'static 'clm-item-action :button (pad-buttons-u64 circle) :func 'clmf-bna) + (new 'static 'clm-item-action :button (pad-buttons-u64 r2) :func 'clmf-bna) + (new 'static 'clm-item-action + :button (pad-buttons-u64 l2) + :func 'clmf-pos-rot + :parm0-sym 'pivot-offset + :parm1 #f + ) + ) + ) + (new 'static 'clm-list-item + :description "interesting" + :track-val 'interesting + :val-func #f + :actions (new 'static 'boxed-array :type clm-item-action + (new 'static 'clm-item-action :button (pad-buttons-u64 x) :func 'clmf-bna) + (new 'static 'clm-item-action :button (pad-buttons-u64 circle) :func 'clmf-bna) + (new 'static 'clm-item-action :button (pad-buttons-u64 r2) :func 'clmf-bna) + (new 'static 'clm-item-action + :button (pad-buttons-u64 l2) + :func 'clmf-pos-rot + :parm0-sym 'interesting-offset + :parm1 #f + ) + ) + ) + (new 'static 'clm-list-item + :description "spline " + :track-val 'spline + :val-func #f + :actions (new 'static 'boxed-array :type clm-item-action + (new 'static 'clm-item-action + :button (pad-buttons-u64 x) + :options (clm-item-action-options clm0) + :func 'clmf-to-spline-attr + ) + (new 'static 'clm-item-action :button (pad-buttons-u64 circle) :func 'clmf-implement) + (new 'static 'clm-item-action :button (pad-buttons-u64 r2) :func 'clmf-implement) + (new 'static 'clm-item-action + :button (pad-buttons-u64 l2) + :func 'clmf-pos-rot + :parm0-sym 'spline-offset + :parm1 #f + ) + ) + ) + (new 'static 'clm-list-item + :description "intro " + :track-val 'intro + :val-func #f + :actions (new 'static 'boxed-array :type clm-item-action + (new 'static 'clm-item-action + :button (pad-buttons-u64 x) + :options (clm-item-action-options clm0) + :func 'clmf-to-intro-attr + ) + (new 'static 'clm-item-action :button (pad-buttons-u64 circle) :func 'clmf-implement) + (new 'static 'clm-item-action :button (pad-buttons-u64 r2) :func 'clmf-implement) + (new 'static 'clm-item-action :button (pad-buttons-u64 l2) :func 'clmf-implement) + ) + ) + (new 'static 'clm-list-item + :description "index " + :track-val 'index + :val-func #f + :actions (new 'static 'boxed-array :type clm-item-action + (new 'static 'clm-item-action + :button (pad-buttons-u64 x) + :options (clm-item-action-options clm0) + :func 'clmf-to-index-attr + ) + (new 'static 'clm-item-action :button (pad-buttons-u64 circle) :func 'clmf-implement) + (new 'static 'clm-item-action :button (pad-buttons-u64 r2) :func 'clmf-implement) + (new 'static 'clm-item-action :button (pad-buttons-u64 l2) :func 'clmf-pos-rot :parm0-sym 'campoints-offset) + ) + ) + (new 'static 'clm-list-item + :description "focalpull" + :track-val 'focalpull + :val-func #f + :actions (new 'static 'boxed-array :type clm-item-action + (new 'static 'clm-item-action + :button (pad-buttons-u64 x) + :options (clm-item-action-options clm0) + :func 'clmf-to-focalpull-attr + ) + (new 'static 'clm-item-action :button (pad-buttons-u64 circle) :func 'clmf-implement) + (new 'static 'clm-item-action :button (pad-buttons-u64 r2) :func 'clmf-implement) + (new 'static 'clm-item-action :button (pad-buttons-u64 l2) :func 'clmf-implement) + ) + ) + ) + ) + ) + ) + ) + +(define *clm-save-all* + (new 'static 'clm :title "---save all?---" :items (new 'static 'boxed-array :type clm-basic + (new 'static 'clm-item + :description " save all" + :button-symbol 'x + :action (new 'static 'clm-item-action + :button (pad-buttons-u64 x) + :options (clm-item-action-options clm0) + :func 'clmf-save-all + :parm0 16 + ) + ) + (new 'static 'clm-item + :description "print all" + :button-symbol 'square + :action (new 'static 'clm-item-action + :button (pad-buttons-u64 square) + :options (clm-item-action-options clm0) + :func 'clmf-save-all + :parm0 8 + ) + ) + (new 'static 'clm-item + :description " done" + :button-symbol 'triangle + :action (new 'static 'clm-item-action + :button (pad-buttons-u64 triangle) + :options (clm-item-action-options clm0) + :func 'clmf-to-select + ) + ) + ) + ) + ) + +(define *clm-save-one* + (new 'static 'clm :title "---single save?---" :items (new 'static 'boxed-array :type clm-basic + (new 'static 'clm-item + :description " single save" + :button-symbol 'x + :action (new 'static 'clm-item-action + :button (pad-buttons-u64 x) + :options (clm-item-action-options clm0) + :func 'clmf-save-one + :parm0 16 + ) + ) + (new 'static 'clm-item + :description "single print" + :button-symbol 'square + :action (new 'static 'clm-item-action + :button (pad-buttons-u64 square) + :options (clm-item-action-options clm0) + :func 'clmf-save-one + :parm0 8 + ) + ) + (new 'static 'clm-item + :description " done" + :button-symbol 'triangle + :action (new 'static 'clm-item-action + :button (pad-buttons-u64 triangle) + :options (clm-item-action-options clm0) + :func 'clmf-to-select + ) + ) + ) + ) + ) + +(define *clm-select* + (new 'static 'clm :title "---camera---" :items (new 'static 'boxed-array :type clm-basic + (new 'static 'clm-item + :description " edit" + :button-symbol 'x + :action (new 'static 'clm-item-action + :button (pad-buttons-u64 x) + :options (clm-item-action-options clm0 clm1) + :func 'clmf-to-edit-cam + ) + ) + (new 'static 'clm-item + :description "save one" + :button-symbol 'triangle + :action (new 'static 'clm-item-action + :button (pad-buttons-u64 triangle) + :options (clm-item-action-options clm0 clm1) + :func '*clm-save-one* + ) + ) + (new 'static 'clm-item + :description " quit" + :button-symbol 'circle + :action (new 'static 'clm-item-action + :button (pad-buttons-u64 circle) + :options (clm-item-action-options clm0 clm4) + :func 'cam-layout-stop + ) + ) + (new 'static 'clm-item + :description " next" + :button-symbol 'down + :action (new 'static 'clm-item-action + :button (pad-buttons-u64 down) + :options (clm-item-action-options clm0 clm1) + :func 'clmf-next-entity + :parm0 8 + ) + ) + (new 'static 'clm-item + :description " prev" + :button-symbol 'up + :action (new 'static 'clm-item-action + :button (pad-buttons-u64 up) + :options (clm-item-action-options clm0 clm1) + :func 'clmf-next-entity + :parm0 -8 + ) + ) + (new 'static 'clm-item + :description " next 5" + :button-symbol 'right + :action (new 'static 'clm-item-action + :button (pad-buttons-u64 right) + :options (clm-item-action-options clm0 clm1) + :func 'clmf-next-entity + :parm0 40 + ) + ) + (new 'static 'clm-item + :description " prev 5" + :button-symbol 'left + :action (new 'static 'clm-item-action + :button (pad-buttons-u64 left) + :options (clm-item-action-options clm0 clm1) + :func 'clmf-next-entity + :parm0 -40 + ) + ) + ) + ) + ) + +(define *clm* *clm-select*) + +(defbehavior cam-layout-do-action cam-layout ((arg0 clm-item-action)) + (let ((s5-0 (-> arg0 func value))) + (cond + ((not s5-0) + #f + ) + ((zero? s5-0) + #f + ) + ((and (not (-> self cam-entity)) (logtest? (-> arg0 options) (clm-item-action-options clm1))) + #f + ) + ((and (logtest? (-> arg0 options) (clm-item-action-options clm3)) + (logtest? (the-as pad-buttons-u64 (-> *cpad-list* cpads 0 button0-abs 0)) (-> arg0 button)) + ) + #f + ) + ((and (not (logtest? (-> arg0 options) (clm-item-action-options clm2 clm3 clm4))) + (logtest? (-> arg0 options) (clm-item-action-options clm0)) + (not (logtest? (the-as pad-buttons-u64 (-> *cpad-list* cpads 0 button0-rel 0)) (-> arg0 button))) + ) + #f + ) + ((and (not (logtest? (-> arg0 options) (clm-item-action-options clm0 clm2 clm3 clm4))) + (not (logtest? (the-as pad-buttons-u64 (-> *cpad-list* cpads 0 button0-abs 0)) (-> arg0 button))) + ) + #f + ) + ((and (logtest? (-> arg0 options) (clm-item-action-options clm4)) + (let ((a1-3 (-> *cpad-list* cpads 0))) + (not (logtest? (the-as pad-buttons-u64 (logclear (-> a1-3 button0-abs 1) (-> a1-3 button0-abs 0))) + (-> arg0 button) + ) + ) + ) + ) + #f + ) + ((type? s5-0 clm) + (set! *clm* (the-as clm s5-0)) + #t + ) + ((type? s5-0 function) + ((the-as (function int symbol object) s5-0) (-> arg0 parm0) (-> arg0 parm1)) + ) + ) + ) + ) + +(defbehavior cam-layout-function-call cam-layout ((arg0 symbol) (arg1 string) (arg2 int) (arg3 basic)) + (let ((gp-0 (-> arg0 value))) + (cond + ((not gp-0) + ) + ((zero? gp-0) + ) + ((type? gp-0 function) + ((the-as (function string int basic object) gp-0) arg1 arg2 arg3) + ) + ) + ) + #f + ) + +(defbehavior cam-layout-do-menu cam-layout ((arg0 clm)) + (set! *camera-layout-message-ypos* 30) + (+! (-> *CAM_LAYOUT-bank* spline-t) (-> *CAM_LAYOUT-bank* spline-step)) + (if (< 1.01 (-> *CAM_LAYOUT-bank* spline-t)) + (set! (-> *CAM_LAYOUT-bank* spline-t) -0.09) + ) + (+! (-> *CAM_LAYOUT-bank* intro-t) (-> *CAM_LAYOUT-bank* intro-step)) + (if (< 1.01 (-> *CAM_LAYOUT-bank* intro-t)) + (set! (-> *CAM_LAYOUT-bank* intro-t) -0.09) + ) + (let ((s5-0 30)) + (let ((s4-0 (cam-state-from-entity (-> self cam-entity)))) + (set-setting! 'master-options 'clear 0.0 32) + (let ((s3-0 (-> self cam-entity))) + (clear *temp-string*) + (if s3-0 + (format *temp-string* "\"~S\"~%" (res-lump-struct s3-0 'name structure)) + ) + ) + (if (not s4-0) + (format *temp-string* "no cameras in this level") + (format *temp-string* "~S" (-> s4-0 name)) + ) + ) + (cam-layout-print 320 s5-0 *temp-string*) + (let ((s5-1 (+ s5-0 28))) + (clear *temp-string*) + (format *temp-string* "~S~%" (-> arg0 title)) + (cam-layout-print 320 s5-1 *temp-string*) + (let ((s4-1 (+ s5-1 14))) + (dotimes (s5-2 (-> arg0 items length)) + (cond + ((type? (-> arg0 items s5-2) clm-list) + (clear *temp-string*) + (format *temp-string* "------------") + (cam-layout-print 320 s4-1 *temp-string*) + (let ((s4-2 (+ s4-1 14))) + (let ((s3-1 (the-as clm-list (-> arg0 items s5-2)))) + (dotimes (s2-1 (-> s3-1 items length)) + (clear *temp-string*) + (format + *temp-string* + "~S~S" + (if (= s2-1 (-> s3-1 cur-list-item)) + "> " + " " + ) + (-> s3-1 items s2-1 description) + ) + (cam-layout-function-call + (-> s3-1 items s2-1 val-func) + *temp-string* + (-> s3-1 items s2-1 val-parm0) + (the-as basic (-> s3-1 items s2-1 val-parm1)) + ) + (cam-layout-print 320 s4-2 *temp-string*) + (+! s4-2 14) + ) + ) + (clear *temp-string*) + (format *temp-string* "------------") + (cam-layout-print 320 s4-2 *temp-string*) + (set! s4-1 (+ s4-2 14)) + ) + ) + ((and (not (-> self cam-entity)) + (logtest? (-> (the-as clm-item (-> arg0 items s5-2)) action options) (clm-item-action-options clm1)) + ) + ) + ((logtest? (-> (the-as clm-item (-> arg0 items s5-2)) action options) (clm-item-action-options clm2)) + ) + (else + (let ((s3-2 (-> arg0 items s5-2))) + (clear *temp-string*) + (format + *temp-string* + "~S: ~A~%" + (-> (the-as clm-item s3-2) description) + (if (logtest? (-> (the-as clm-item (-> arg0 items s5-2)) action options) (clm-item-action-options clm3)) + 'default + (-> (the-as clm-item s3-2) button-symbol) + ) + ) + ) + (cam-layout-print 320 s4-1 *temp-string*) + (+! s4-1 14) + ) + ) + ) + ) + ) + ) + (if (= *master-mode* 'menu) + (goto cfg-65) + ) + (dotimes (s5-3 (-> arg0 items length)) + (cond + ((type? (-> arg0 items s5-3) clm-list) + (let ((s4-3 (-> arg0 items s5-3)) + (s3-3 0) + ) + (if (-> (the-as clm-list s4-3) tracker) + (set! (-> (the-as clm-list s4-3) tracker value) + (-> (the-as clm-list s4-3) items (-> (the-as clm-list s4-3) cur-list-item) track-val) + ) + ) + (dotimes (s2-2 (-> (the-as clm-list s4-3) items (-> (the-as clm-list s4-3) cur-list-item) actions length)) + (if (cam-layout-do-action + (-> (the-as clm-list s4-3) items (-> (the-as clm-list s4-3) cur-list-item) actions s2-2) + ) + (goto cfg-65) + ) + ) + (cond + ((cpad-pressed? 0 down) + (set! s3-3 1) + ) + ((cpad-pressed? 0 right) + (set! s3-3 1) + ) + ((cpad-pressed? 0 up) + (set! s3-3 -1) + ) + ((cpad-pressed? 0 left) + (set! s3-3 -1) + ) + ) + (when (nonzero? s3-3) + (set! (-> (the-as clm-list s4-3) cur-list-item) + (mod (+ (-> (the-as clm-list s4-3) cur-list-item) s3-3) (-> (the-as clm-list s4-3) items length)) + ) + (while (< (-> (the-as clm-list s4-3) cur-list-item) 0) + (+! (-> (the-as clm-list s4-3) cur-list-item) (-> (the-as clm-list s4-3) items length)) + ) + (goto cfg-65) + ) + ) + ) + ((cam-layout-do-action (-> (the-as clm-item (-> arg0 items s5-3)) action)) + (goto cfg-65) + ) + ) + ) + (label cfg-65) + #f + ) + +(defstate cam-layout-active (cam-layout) + :code (behavior () + (until #f + (cam-layout-entity-info (the-as entity-actor (-> self cam-entity))) + (cam-layout-do-menu *clm*) + (suspend) + ) + #f + ) + ) + +(defbehavior cam-layout-init cam-layout () + (set! (-> self res-key) -1000000000.0) + (set! (-> self num-entities) 0) + (let ((v1-2 (-> *camera-engine* alive-list next0))) + *camera-engine* + (let ((a0-2 (-> v1-2 next0))) + (while (!= v1-2 (-> *camera-engine* alive-list-end)) + (-> (the-as connection v1-2) param1) + (+! (-> self num-entities) 1) + (set! v1-2 a0-2) + *camera-engine* + (set! a0-2 (-> a0-2 next0)) + ) + ) + ) + (set! (-> self cur-entity) *last-cur-entity*) + (clmf-next-entity 0) + (set! *clm* *clm-select*) + (go cam-layout-active) + ) + +(defun cam-layout-stop () + (set! *cam-layout* #f) + (kill-by-name "cam-layout" *active-pool*) + ) + +(defun cam-layout-start () + (let ((a0-1 (new 'global 'file-stream "dd_next/caminfo/garbage" 'read))) + (file-stream-close a0-1) + ) + (cond + ((not *cam-layout*) + (let ((v1-4 (process-spawn-function cam-layout cam-layout-init :name "cam-layout" :from *camera-dead-pool*))) + (cond + (v1-4 + (logclear! (-> v1-4 0 mask) (process-mask freeze pause menu)) + (set! *cam-layout* #t) + (set! *camera-layout-blink* #f) + ) + (else + (format 0 "ERROR : no process available to start cam editing mode~%") + ) + ) + ) + ) + (else + (format 0 "ERROR : cam editing mode already started~%") + ) + ) + *cam-layout* + ) + +(defun cam-layout-restart () + (cam-layout-stop) + (cam-layout-start) + ) diff --git a/goal_src/jak3/engine/camera/cam-master.gc b/goal_src/jak3/engine/camera/cam-master.gc index 3ad7be584d2..9e4416de39b 100644 --- a/goal_src/jak3/engine/camera/cam-master.gc +++ b/goal_src/jak3/engine/camera/cam-master.gc @@ -7,3 +7,1075 @@ ;; DECOMP BEGINS +(defmethod camera-master-method-16 ((this camera-master) (arg0 symbol)) + (let ((a2-0 (handle->process (-> this focus handle))) + (v1-4 0) + ) + (if a2-0 + (set! v1-4 (logand (the-as int (-> (the-as process-focusable a2-0) root pat-ignore-mask)) 112)) + ) + (logior (if arg0 + #x9010002 + #x9000002 + ) + v1-4 + ) + ) + ) + +(defbehavior reset-follow camera-master ((arg0 symbol)) + (let ((a0-2 (handle->process (-> self focus handle)))) + (when a0-2 + (let ((v1-5 (get-trans (the-as process-focusable a0-2) 4))) + (cond + (arg0 + (set! (-> self tpos-old x) (-> v1-5 x)) + (set! (-> self tpos-old z) (-> v1-5 z)) + (if (< (-> self tpos-old y) (-> v1-5 y)) + (set! (-> self tpos-old y) (lerp (-> self tpos-old y) (-> v1-5 y) (* 3.0 (seconds-per-frame)))) + (set! (-> self tpos-old y) (lerp (-> self tpos-old y) (-> v1-5 y) (* 8.0 (seconds-per-frame)))) + ) + (set! (-> self tpos-curr quad) (-> self tpos-old quad)) + (set! (-> self tpos-old-adj quad) (-> self tpos-old quad)) + (set! (-> self tpos-curr-adj quad) (-> self tpos-old quad)) + (let ((v0-0 (the-as object (-> self tpos-tgt)))) + (set! (-> (the-as vector v0-0) quad) (-> self tpos-old quad)) + v0-0 + ) + ) + (else + (set! (-> self tpos-old quad) (-> v1-5 quad)) + (set! (-> self tpos-curr quad) (-> self tpos-old quad)) + (set! (-> self tpos-old-adj quad) (-> self tpos-old quad)) + (set! (-> self tpos-curr-adj quad) (-> self tpos-old quad)) + (set! (-> self tpos-tgt quad) (-> self tpos-old quad)) + (set! (-> self upspeed) 0.0) + ) + ) + ) + ) + ) + ) + +;; WARN: Return type mismatch none vs object. +(defbehavior reset-target-tracking camera-master () + (let ((gp-0 (handle->process (-> self focus handle)))) + (when gp-0 + (set! (-> self tpos-old quad) (-> (get-trans (the-as process-focusable gp-0) 4) quad)) + (set! (-> self tpos-curr quad) (-> self tpos-old quad)) + (set! (-> self tpos-old-adj quad) (-> self tpos-old quad)) + (set! (-> self tpos-curr-adj quad) (-> self tpos-old quad)) + (set! (-> self tpos-tgt quad) (-> self tpos-old quad)) + (quaternion->matrix (-> self tgt-rot-mat) (get-quat (the-as process-focusable gp-0) 2)) + (quaternion->matrix (-> self tgt-face-mat) (get-quat (the-as process-focusable gp-0) 1)) + (vector-reset! (-> self pitch-off)) + (set! (-> self upspeed) 0.0) + (set! (-> self on-ground) + (not (logtest? (-> (the-as process-focusable gp-0) focus-status) (focus-status in-air))) + ) + (set! (-> self on-pole) #f) + (set! (-> self ease-t) 1.0) + (set! (-> self string-max target y) (-> self settings string-max-height)) + (set! (-> self string-max target z) (-> self settings string-max-length)) + (set! (-> self string-push-z) (fmax (-> self string-min value z) (-> *CAMERA-bank* default-string-push-z))) + (cond + ((time-elapsed? (get-notice-time (the-as process-focusable gp-0)) (-> *CAMERA-bank* attack-timeout)) + (set! (-> self being-attacked) #f) + ) + (else + (set-time! (-> self attack-start)) + (set! (-> self being-attacked) #t) + (when (or (!= (-> last-try-to-look-at-data horz) 0.0) (!= (-> last-try-to-look-at-data vert) 0.0)) + (set! (-> self string-max target y) (fmax (-> self string-max target y) (-> last-try-to-look-at-data vert))) + (set! (-> self string-max target z) (fmax (-> self string-max target z) (-> last-try-to-look-at-data horz))) + (set! (-> self string-push-z) (fmax (-> self string-push-z) (-> self string-max target z))) + ) + ) + ) + (cond + ((focus-test? (the-as process-focusable gp-0) under-water) + (set! (-> self under-water) 2) + ) + (else + (set! (-> self under-water) 0) + 0 + ) + ) + (let ((gp-1 (new 'stack-no-clear 'vector))) + (set! (-> *setting-control* cam-current target-height) (-> *setting-control* cam-target target-height)) + (vector--float*! gp-1 (-> self tpos-curr-adj) (-> self local-down) (-> self settings target-height)) + (tracking-spline-method-10 (-> self target-spline) gp-1) + ) + ) + ) + ) + +(defbehavior master-track-target camera-master () + (let ((gp-0 (handle->process (-> self focus handle)))) + (cond + ((and *target* (not gp-0)) + (try-update-focus (-> self focus) *target*) + (logior! (-> self master-options) (cam-master-options-u32 HAVE_TARGET)) + (reset-target-tracking) + ) + ((and (logtest? (-> self master-options) (cam-master-options-u32 HAVE_TARGET)) (not gp-0)) + (let ((v0-1 (the-as object (logclear (-> self master-options) (cam-master-options-u32 HAVE_TARGET))))) + (set! (-> self master-options) (the-as cam-master-options-u32 v0-1)) + v0-1 + ) + ) + ((paused?) + #f + ) + (gp-0 + (logior! (-> self master-options) (cam-master-options-u32 HAVE_TARGET)) + (cond + ((time-elapsed? (get-notice-time (the-as process-focusable gp-0)) (-> *CAMERA-bank* attack-timeout)) + (set! (-> self being-attacked) #f) + ) + (else + (if (not (-> self being-attacked)) + (set-time! (-> self attack-start)) + ) + (set! (-> self being-attacked) #t) + (when (or (!= (-> last-try-to-look-at-data horz) 0.0) (!= (-> last-try-to-look-at-data vert) 0.0)) + (set! (-> self string-max target y) (fmax (-> self string-max target y) (-> last-try-to-look-at-data vert))) + (set! (-> self string-max target z) (fmax (-> self string-max target z) (-> last-try-to-look-at-data horz))) + (set! (-> self string-push-z) (fmax (-> self string-push-z) (-> self string-max target z))) + ) + ) + ) + (cond + ((focus-test? (the-as process-focusable gp-0) under-water) + (set! (-> self under-water) 2) + ) + ((> (-> self under-water) 0) + (+! (-> self under-water) -1) + ) + ) + (set! (-> self tpos-old quad) (-> self tpos-curr quad)) + (set! (-> self tpos-old-adj quad) (-> self tpos-curr-adj quad)) + (quaternion->matrix (-> self tgt-rot-mat) (get-quat (the-as process-focusable gp-0) 2)) + (quaternion->matrix (-> self tgt-face-mat) (get-quat (the-as process-focusable gp-0) 1)) + (cond + ((< (-> self ease-t) 1.0) + (new 'stack-no-clear 'vector) + (cond + ((logtest? (-> self master-options) (cam-master-options-u32 HAVE_EASE_TO_POS)) + (vector-lerp! + (-> self tpos-curr) + (-> self ease-from) + (-> self ease-to) + (parameter-ease-sin-clamp (-> self ease-t)) + ) + (logclear! (-> self master-options) (cam-master-options-u32 HAVE_EASE_TO_POS)) + ) + (else + (vector-lerp! + (-> self tpos-curr) + (-> self ease-from) + (get-trans (the-as process-focusable gp-0) 4) + (parameter-ease-sin-clamp (-> self ease-t)) + ) + ) + ) + (+! (-> self ease-t) (-> self ease-step)) + ) + (else + (set! (-> self tpos-curr quad) (-> (get-trans (the-as process-focusable gp-0) 4) quad)) + ) + ) + (when (focus-test? (the-as process-focusable gp-0) edge-grab) + (if *display-cam-los-debug* + (format *stdcon* "ride edge~%") + ) + (let ((s5-6 (new 'stack-no-clear 'collide-query))) + (vector--float*! + (-> s5-6 start-pos) + (-> self tpos-curr) + (-> self local-down) + (-> self settings target-height) + ) + (vector-float*! (-> s5-6 move-dist) (-> self tgt-rot-mat fvec) 4915.2) + (vector-! (-> s5-6 start-pos) (-> s5-6 start-pos) (-> s5-6 move-dist)) + (let ((s4-4 s5-6)) + (set! (-> s4-4 radius) 4300.8) + (set! (-> s4-4 collide-with) (collide-spec backgnd obstacle hit-by-others-list camera-blocker pusher)) + (set! (-> s4-4 ignore-process0) #f) + (set! (-> s4-4 ignore-process1) #f) + (set! (-> s4-4 ignore-pat) (the-as pat-surface (camera-master-method-16 self #t))) + (set! (-> s4-4 action-mask) (collide-action solid)) + ) + (let ((f0-16 (fill-and-probe-using-line-sphere *collide-cache* s5-6))) + (if (and (< 0.0 f0-16) (< f0-16 1.0)) + (vector+float*! (-> self tpos-curr) (-> self tpos-curr) (-> s5-6 move-dist) (+ -1.0 f0-16)) + ) + ) + ) + ) + (set! (-> self on-ground) + (not (logtest? (-> (the-as process-focusable gp-0) focus-status) (focus-status in-air))) + ) + (let ((s5-7 (new-stack-vector0))) + 0.0 + (cond + ((and (focus-test? (the-as process-focusable gp-0) in-air) + (not (logtest? (focus-status halfpipe super) (-> (the-as process-focusable gp-0) focus-status))) + ) + (if *display-cam-los-debug* + (format *stdcon* "air tracking~%") + ) + (vector+float*! (-> self tpos-curr-adj) (-> self tpos-curr-adj) (-> self local-down) (-> self upspeed)) + (vector+float*! (-> self tpos-tgt) (-> self tpos-tgt) (-> self local-down) (-> self upspeed)) + (vector-! s5-7 (-> self tpos-curr) (-> self tpos-tgt)) + (let ((f30-0 (vector-dot s5-7 (-> self local-down)))) + (vector--float*! s5-7 s5-7 (-> self local-down) f30-0) + (if (< 0.0 f30-0) + (set! (-> self upspeed) (* 0.5 (-> self upspeed))) + ) + (vector+! (-> self tpos-tgt) (-> self tpos-tgt) s5-7) + (let ((f0-26 (* 0.05 f30-0))) + (vector+float*! (-> self tpos-tgt) (-> self tpos-tgt) (-> self local-down) f0-26) + ) + ) + (vector-! s5-7 (-> self tpos-curr-adj) (-> self tpos-tgt)) + (let* ((f0-28 (vector-dot s5-7 (-> self local-down))) + (f0-29 (if (< 0.0 f0-28) + (* f0-28 (-> *CAMERA_MASTER-bank* up-move-to-pitch-ratio-in-air)) + (* f0-28 (-> *CAMERA_MASTER-bank* down-move-to-pitch-ratio-in-air)) + ) + ) + ) + (vector+float*! (-> self tpos-curr-adj) (-> self tpos-tgt) (-> self local-down) f0-29) + ) + (vector-! s5-7 (get-trans (the-as process-focusable gp-0) 1) (-> self tpos-curr-adj)) + (let* ((f0-31 (vector-dot s5-7 (-> self local-down))) + (f0-32 (* 0.03 f0-31)) + ) + (if (and (< f0-32 0.0) (< f0-32 (-> self upspeed))) + (set! (-> self upspeed) f0-32) + ) + ) + ) + (else + (if *display-cam-los-debug* + (format *stdcon* "ground tracking~%") + ) + (vector-! s5-7 (-> self tpos-curr) (-> self tpos-old)) + (let ((f0-34 (vector-dot s5-7 (-> self local-down)))) + (cond + ((and (focus-test? (the-as process-focusable gp-0) touch-water) + (not (logtest? (focus-status mech) (-> (the-as process-focusable gp-0) focus-status))) + ) + (set! (-> self upspeed) 0.0) + ) + ((< 0.0 f0-34) + (set! (-> self upspeed) 0.0) + ) + (else + (set! (-> self upspeed) f0-34) + ) + ) + ) + (set! (-> self tpos-tgt quad) (-> self tpos-curr quad)) + (vector-! s5-7 (-> self tpos-curr-adj) (-> self tpos-curr)) + (let* ((f0-38 (vector-dot s5-7 (-> self local-down))) + (f0-39 (cond + ((logtest? (cam-slave-options RAPID_TRACKING) (-> self settings slave-options)) + 0.0 + ) + ((< 0.0 f0-38) + (* f0-38 (-> *CAMERA_MASTER-bank* up-move-to-pitch-on-ground)) + ) + (else + (* f0-38 (-> *CAMERA_MASTER-bank* down-move-to-pitch-on-ground)) + ) + ) + ) + ) + (vector+float*! (-> self tpos-curr-adj) (-> self tpos-curr) (-> self local-down) f0-39) + ) + ) + ) + ) + (if (not (logtest? (-> self settings slave-options) (cam-slave-options JUMP_PITCHES))) + (reset-follow (logtest? (cam-slave-options JUMP_LAG) (-> self settings slave-options))) + ) + (when (and (focus-test? (the-as process-focusable gp-0) on-water under-water) + (not (logtest? (focus-status mech) (-> (the-as process-focusable gp-0) focus-status))) + ) + (let ((f0-41 (- (get-water-height (the-as process-focusable gp-0)) (-> self settings target-height)))) + (if (< (-> self tpos-curr-adj y) f0-41) + (set! (-> self tpos-curr-adj y) f0-41) + ) + ) + ) + (vector+! (-> self pitch-off) (-> self pitch-off) (-> self tpos-curr)) + (vector-! (-> self pitch-off) (-> self pitch-off) (-> self tpos-old)) + (vector-float*! (-> self pitch-off) (-> self pitch-off) (-> *CAMERA_MASTER-bank* pitch-off-blend)) + (let ((s5-8 (new 'stack-no-clear 'vector))) + (vector--float*! s5-8 (-> self tpos-curr-adj) (-> self local-down) (-> self settings target-height)) + (let ((s4-7 (new 'stack-no-clear 'vector))) + 0.0 + (vector-! s4-7 (get-trans (the-as process-focusable gp-0) 1) s5-8) + (let* ((f0-46 (vector-dot s4-7 (-> self local-down))) + (f0-47 (+ -4096.0 f0-46)) + ) + (if (< f0-47 0.0) + (vector+float*! s5-8 s5-8 (-> self local-down) f0-47) + ) + ) + ) + (tracking-spline-method-17 (-> self target-spline) s5-8 2048.0 0.0 #f) + ) + (tracking-spline-method-22 (-> self target-spline) 40960.0) + ) + ) + ) + ) + +(defun setup-slave-for-hopefull ((arg0 camera-slave)) + (when (= (-> arg0 blend-to-type) (camera-blend-to-type unknown-2)) + (cam-calc-follow! (-> arg0 tracking) (-> arg0 trans) #f) + (slave-set-rotation! (-> arg0 tracking) (-> arg0 trans) (-> arg0 options) (-> arg0 fov) #f) + ) + (none) + ) + +(defbehavior master-is-hopeful-better? camera-master ((arg0 camera-slave) (arg1 camera-slave)) + (cond + ((not *camera-combiner*) + #f + ) + ((not arg0) + #t + ) + (else + (< (vector-dot (-> arg0 tracking inv-mat fvec) (-> *camera-combiner* inv-camera-rot fvec)) + (vector-dot (-> arg1 tracking inv-mat fvec) (-> *camera-combiner* inv-camera-rot fvec)) + ) + ) + ) + ) + +(defbehavior master-choose-entity camera-master ((arg0 cam-setting-data)) + (local-vars + (r0-0 uint128) + (v1-44 uint128) + (sv-96 int) + (sv-112 process) + (sv-128 entity) + (sv-144 string) + (sv-160 string) + (sv-176 uint) + ) + (let ((s5-0 (entity-by-name (-> arg0 entity-name)))) + (set! (-> arg0 real-entity-name) #f) + (when s5-0 + (let ((s2-0 (cam-state-from-entity s5-0))) + (cond + (s2-0 + (set! (-> arg0 real-entity-name) (-> arg0 entity-name)) + (set! (-> arg0 cam-mode) (the-as symbol s2-0)) + (if (-> arg0 teleport-on-entity-change) + (send-event *camera* 'teleport) + ) + ) + (else + (format 0 "ERROR : camera entity '~S' didn't produce a state~%" (res-lump-struct s5-0 'name structure)) + ) + ) + (set! sv-96 0) + (let ((s4-1 (res-lump-data s5-0 'alternates pointer :tag-ptr (the-as (pointer res-tag) (& sv-96))))) + (when s4-1 + (let ((s3-1 (process-spawn + camera-slave + :init cam-slave-init + s2-0 + s5-0 + :name "camera-slave" + :from *camera-dead-pool* + :to *camera* + ) + ) + ) + (if s3-1 + (setup-slave-for-hopefull (the-as camera-slave (ppointer->process s3-1))) + (format 0 "ERROR : primary region activate failed~%") + ) + (let ((s2-1 0)) + (while (begin + (let ((v1-43 (the-as uint128 sv-96))) + (.pcpyud v1-44 v1-43 r0-0) + ) + (< s2-1 (shr (* (the-as int v1-44) 2) 49)) + ) + (set! sv-128 (entity-by-name (the-as string (-> (the-as (pointer uint32) (&+ s4-1 (* s2-1 4))))))) + (cond + (sv-128 + (let ((s1-2 (cam-state-from-entity sv-128))) + (cond + (s1-2 + (set! sv-112 (get-process *camera-dead-pool* camera-slave #x4000 1)) + (let ((s0-0 (when sv-112 + (let ((t9-14 (method-of-type camera-slave activate))) + (t9-14 (the-as camera-slave sv-112) *camera* "camera-slave" (the-as pointer #x70004000)) + ) + (run-now-in-process sv-112 cam-slave-init s1-2 sv-128) + (-> sv-112 ppointer) + ) + ) + ) + (cond + (s0-0 + (setup-slave-for-hopefull (the-as camera-slave (ppointer->process s0-0))) + (cond + ((master-is-hopeful-better? + (the-as camera-slave (ppointer->process s3-1)) + (the-as camera-slave (ppointer->process s0-0)) + ) + (if s3-1 + (deactivate (-> s3-1 0)) + ) + (set! s3-1 (the-as (pointer camera-slave) s0-0)) + (set! (-> arg0 real-entity-name) (the-as string (-> (the-as (pointer uint32) (&+ s4-1 (* s2-1 4)))))) + (set! (-> arg0 cam-mode) (the-as symbol s1-2)) + ) + (else + (deactivate (-> s0-0 0)) + ) + ) + ) + (else + (format 0 "ERROR : alternate region activate failed~%") + ) + ) + ) + ) + (else + (let ((s1-5 format) + (s0-1 0) + ) + (set! sv-144 "ERROR : alternate camera region '~S' didn't produce a state~%") + (let ((a2-10 (res-lump-struct sv-128 'name structure))) + (s1-5 s0-1 sv-144 a2-10) + ) + ) + ) + ) + ) + ) + (else + (let ((s1-7 format) + (s0-2 0) + ) + (set! sv-160 "ERROR : alternate '~S' not found for '~S'~%") + (set! sv-176 (-> (the-as (pointer uint32) (&+ s4-1 (* s2-1 4))))) + (let ((a3-10 (res-lump-struct s5-0 'name structure))) + (s1-7 s0-2 sv-160 sv-176 a3-10) + ) + ) + ) + ) + (+! s2-1 1) + ) + ) + (if s3-1 + (deactivate (-> s3-1 0)) + ) + ) + ) + ) + ) + ) + ) + (cond + ((-> arg0 real-entity-name) + #f + ) + ((-> arg0 mode-name) + (let ((s5-1 (-> arg0 mode-name value))) + (set! (-> arg0 cam-mode) (the-as symbol (if (type? s5-1 state) + s5-1 + ) + ) + ) + ) + (set! (-> arg0 real-entity-name) #f) + #f + ) + (else + (set! (-> arg0 cam-mode) (the-as symbol cam-free-floating)) + (set! (-> arg0 real-entity-name) #f) + #f + ) + ) + ) + +(defun cam-master-set-entity ((arg0 cam-setting-data)) + (if (-> arg0 entity-or-mode-changed) + (master-choose-entity arg0) + ) + (let ((s5-0 (entity-by-name (-> arg0 entity-name)))) + (when s5-0 + (if (< (-> arg0 fov-priority) 10.0) + (set! (-> arg0 fov) (cam-slave-get-fov s5-0)) + ) + (set! (-> arg0 string-min-height) + (cam-slave-get-float s5-0 'stringMinHeight (-> *CAMERA-bank* default-string-min-y)) + ) + (set! (-> arg0 string-max-height) + (cam-slave-get-float s5-0 'stringMaxHeight (-> *CAMERA-bank* default-string-max-y)) + ) + (set! (-> arg0 string-min-length) + (cam-slave-get-float s5-0 'stringMinLength (-> *CAMERA-bank* default-string-min-z)) + ) + (let ((f0-9 (cam-slave-get-float s5-0 'stringMaxLength (-> *CAMERA-bank* default-string-max-z)))) + (if (< 405504.0 f0-9) + (set! f0-9 (-> *CAMERA-bank* default-string-max-z)) + ) + (set! (-> arg0 string-max-length) f0-9) + ) + (set! (-> arg0 string-default) #f) + (set! (-> arg0 string-cliff-height) (cam-slave-get-float s5-0 'stringCliffHeight 163840.0)) + (let ((a1-5 (new 'stack-no-clear 'vector))) + (when (cam-slave-get-vector-with-offset (the-as entity-actor s5-0) a1-5 'interesting) + ) + ) + (set! (-> arg0 interp-time) (the-as uint (the int (* 300.0 (cam-slave-get-interp-time s5-0))))) + (let ((s4-0 (res-lump-value s5-0 'flags-on uint128 :time -1000000000.0)) + (v1-22 (res-lump-value s5-0 'flags-off uint128 :time -1000000000.0)) + ) + (logior! (-> arg0 slave-options) s4-0) + (logclear! (-> arg0 slave-options) v1-22) + ) + ) + ) + 0 + (none) + ) + +(defun cam-master-activate-slave ((arg0 symbol)) + (when (and *camera* (or arg0 (not (-> *camera* slave)) (-> *camera* settings entity-or-mode-changed))) + (when (and arg0 (-> *camera* slave)) + (deactivate (-> *camera* slave 0)) + (set! (-> *camera* slave) (the-as (pointer camera-slave) #f)) + ) + (let* ((s5-0 (-> *camera* settings)) + (gp-0 (entity-by-name (-> s5-0 real-entity-name))) + (s5-1 (the-as object (-> s5-0 cam-mode))) + ) + (if (not (the-as symbol s5-1)) + (set! s5-1 cam-free-floating) + ) + (send-event *camera* 'set-slave (ppointer->process (process-spawn + camera-slave + :init cam-slave-init + s5-1 + gp-0 + :name "camera-slave" + :from *camera-dead-pool* + :to *camera* + ) + ) + ) + ) + ) + 0 + (none) + ) + +(defstate cam-master-active (camera-master) + :event (behavior ((proc process) (argc int) (message symbol) (block event-message-block)) + (local-vars (v0-0 object) (v1-125 uint)) + (rlet ((acc :class vf) + (vf0 :class vf) + (vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + (vf7 :class vf) + ) + (init-vf0-vector) + (case message + (('dist-from-interp-src) + (cond + ((not *camera-combiner*) + #x48c80000 + ) + ((= (-> *camera-combiner* interp-val) 0.0) + 0 + ) + (else + (-> *camera-combiner* dist-from-src) + ) + ) + ) + (('dist-from-interp-dest) + (cond + ((not *camera-combiner*) + 0 + ) + ((= (-> *camera-combiner* interp-val) 0.0) + #x48c80000 + ) + (else + (-> *camera-combiner* dist-from-dest) + ) + ) + ) + (('level-deactivate) + (format 0 "ERROR : *camera* level-deactivate event not supported anymore~%") + ) + (('clear-entity) + (format 0 "ERROR : *camera* clear-entity event not supported anymore~%") + ) + (('no-intro) + (format 0 "ERROR : *camera* no-intro event not supported anymore '~S'~%" (-> block param 0)) + ) + (('force-blend) + (format 0 "ERROR : *camera* force-blend event not supported anymore '~S'~%" (-> block param 0)) + ) + (('teleport-to-transformq) + (when (> argc 0) + (let ((gp-1 (the-as object (-> block param 0)))) + (when (-> self slave) + (deactivate (-> self slave 0)) + (set! (-> self slave) (the-as (pointer camera-slave) #f)) + ) + (set! (-> *camera-combiner* trans quad) (-> (the-as matrix gp-1) rvec quad)) + (quaternion->matrix (-> *camera-combiner* inv-camera-rot) (the-as quaternion (+ (the-as uint gp-1) 16))) + ) + (send-event self 'teleport) + (cam-master-activate-slave #f) + #t + ) + ) + (('teleport-to-other-start-string) + (let ((gp-2 (new 'stack-no-clear 'vector))) + (when (-> self slave) + (deactivate (-> self slave 0)) + (set! (-> self slave) (the-as (pointer camera-slave) #f)) + ) + (set! (-> *camera-combiner* trans quad) (-> *camera-other-trans* quad)) + (vector-! gp-2 (-> self tpos-curr-adj) *camera-other-trans*) + (vector-normalize! gp-2 1.0) + (forward-down->inv-matrix (-> *camera-combiner* inv-camera-rot) gp-2 (new 'static 'vector :y -1.0)) + ) + (send-event self 'teleport) + (cam-master-activate-slave #f) + ) + (('teleport-to-vector-start-string) + (when (> argc 0) + (let ((s5-0 (the-as object (-> block param 0))) + (gp-3 (new 'stack-no-clear 'vector)) + ) + (when (-> self slave) + (deactivate (-> self slave 0)) + (set! (-> self slave) (the-as (pointer camera-slave) #f)) + ) + (set! (-> *camera-combiner* trans quad) (-> (the-as vector s5-0) quad)) + (vector-! gp-3 (-> self tpos-curr-adj) (the-as vector s5-0)) + (vector-normalize! gp-3 1.0) + (forward-down->inv-matrix (-> *camera-combiner* inv-camera-rot) gp-3 (new 'static 'vector :y -1.0)) + ) + (send-event self 'teleport) + (cam-master-activate-slave #f) + ) + ) + (('change-target) + (let ((a1-15 (-> block param 0))) + (cond + ((not a1-15) + (clear-focused (-> self focus)) + (logclear! (-> self master-options) (cam-master-options-u32 HAVE_TARGET)) + ) + (else + (try-update-focus (-> self focus) (the-as process-focusable a1-15)) + (logior! (-> self master-options) (cam-master-options-u32 HAVE_TARGET)) + (reset-target-tracking) + ) + ) + ) + (set! (-> *camera-combiner* tracking no-follow) #f) + #f + ) + (('intro-done?) + (or (not (-> self slave)) (>= (-> self slave 0 intro-t) 1.0)) + ) + (('query-state) + (and (-> self slave) (= (-> self slave 0 next-state) (-> block param 0))) + ) + (('change-to-entity-by-name) + (format + 0 + "ERROR : *camera* change-to-entity-by-name event not supported anymore '~S'~%" + (-> block param 0) + ) + ) + (('change-state) + (format 0 "ERROR : *camera* change-state event not supported anymore ~A~%" (-> block param 0)) + ) + (('set-slave) + (let ((s5-1 (process->ppointer (the-as process (-> block param 0)))) + (s4-0 (-> self settings interp-time)) + (gp-4 (-> self slave)) + ) + (when (and s5-1 (!= s5-1 gp-4)) + (set! (-> self slave) (the-as (pointer camera-slave) s5-1)) + (logior! (-> self master-options) (cam-master-options-u32 SET_COMBINER_AXIS)) + (set! (-> *camera-combiner* tracking tilt-adjust target) (-> self slave 0 tracking tilt-adjust target)) + (cond + ((or (zero? s4-0) (not gp-4)) + (if *math-camera* + (set! (-> *math-camera* reset) 1) + ) + (send-event *camera-combiner* 'set-interpolation 0) + (send-event *camera-combiner* 'stop-tracking) + (if (= (-> (the-as camera-slave (-> s5-1 0)) blend-to-type) (camera-blend-to-type unknown-2)) + (send-event *camera-combiner* 'start-tracking (ppointer->process s5-1)) + ) + ) + ((begin + (when (< 0.0 (-> gp-4 0 intro-t-step)) + (set! (-> self outro-t) (-> gp-4 0 intro-t)) + (set! (-> self outro-t-step) (/ -5.0 (the float s4-0))) + (set! (-> self outro-exit-value) (-> gp-4 0 outro-exit-value)) + (curve-copy! (-> self outro-curve) (-> gp-4 0 intro-curve)) + ) + (if (-> self settings no-intro) + (set! (-> self outro-t) 0.0) + ) + (send-event *camera-combiner* 'set-interpolation s4-0) + (cond + ((= (-> gp-4 0 blend-from-type) (camera-blend-from-type unknown-0)) + (send-event (ppointer->process (-> self decel)) 'change-state cam-fixed) + (send-event *camera-combiner* 'stop-tracking) + ) + (else + (send-event (ppointer->process (-> self decel)) 'change-state cam-decel) + ) + ) + (set! v1-125 (-> *camera-combiner* tracking-status)) + (zero? v1-125) + ) + (case (-> (the-as camera-slave (-> s5-1 0)) blend-to-type) + (((camera-blend-to-type unknown-0)) + ) + (((camera-blend-to-type unknown-1)) + ) + (((camera-blend-to-type unknown-2)) + (if (= (-> gp-4 0 blend-from-type) (camera-blend-from-type unknown-1)) + (send-event *camera-combiner* 'copy-tracking (ppointer->process gp-4)) + (send-event *camera-combiner* 'start-tracking (ppointer->process s5-1)) + ) + (set! (-> *camera-combiner* tracking-status) (the-as uint 2)) + ) + (else + (format 0 "unknown blend-to type~%") + ) + ) + ) + ((= v1-125 1) + (case (-> (the-as camera-slave (-> s5-1 0)) blend-to-type) + (((camera-blend-to-type unknown-0)) + (set! (-> *camera-combiner* tracking-status) (the-as uint 3)) + ) + (((camera-blend-to-type unknown-1)) + (set! (-> *camera-combiner* tracking-status) (the-as uint 3)) + ) + (((camera-blend-to-type unknown-2)) + ) + (else + (format 0 "unknown blend-to type~%") + ) + ) + ) + ((or (= v1-125 2) (= v1-125 3)) + (case (-> (the-as camera-slave (-> s5-1 0)) blend-to-type) + (((camera-blend-to-type unknown-0)) + (set! (-> *camera-combiner* tracking-status) (the-as uint 0)) + 0 + ) + (((camera-blend-to-type unknown-1)) + (set! (-> *camera-combiner* tracking-status) (the-as uint 0)) + 0 + ) + (((camera-blend-to-type unknown-2)) + (set! (-> *camera-combiner* tracking-status) (the-as uint 2)) + ) + (else + (format 0 "unknown blend-to type~%") + ) + ) + ) + (else + (format 0 "unknown combiner status~%") + ) + ) + (if gp-4 + (deactivate (-> gp-4 0)) + ) + ) + ) + ) + (('ease-in) + (cond + ((< argc 1) + (set! (-> self ease-t) 0.0) + (logclear! (-> self master-options) (cam-master-options-u32 HAVE_EASE_TO_POS)) + ) + ((< argc 2) + (if (< (the-as float (-> block param 0)) (-> self ease-t)) + (set! (-> self ease-t) (the-as float (-> block param 0))) + ) + (logclear! (-> self master-options) (cam-master-options-u32 HAVE_EASE_TO_POS)) + ) + (else + (if (< (the-as float (-> block param 0)) (-> self ease-t)) + (set! (-> self ease-t) (the-as float (-> block param 0))) + ) + (set! (-> self ease-to quad) (-> (the-as vector (-> block param 1)) quad)) + (logior! (-> self master-options) (cam-master-options-u32 HAVE_EASE_TO_POS)) + ) + ) + (set! (-> self ease-step) 0.033333335) + (set! v0-0 (-> self ease-from)) + (set! (-> (the-as vector v0-0) quad) (-> self tpos-curr-adj quad)) + v0-0 + ) + (('damp-up) + (set! (-> self upspeed) 0.0) + ) + (('reset-follow) + (reset-follow #f) + ) + (('teleport) + (reset-target-tracking) + (if (-> self slave) + (send-event (ppointer->process (-> self slave)) message) + ) + (send-event *camera-combiner* message) + ) + (('toggle-slave-option) + (logxor! (-> self slave-options) (the-as uint (-> block param 0))) + (if (-> self slave) + (logxor! (-> self slave 0 options) (the-as uint (-> block param 0))) + ) + (when (-> self decel) + (set! v0-0 (logxor (-> self decel 0 options) (the-as uint (-> block param 0)))) + (set! (-> self decel 0 options) (the-as cam-slave-options-u32 v0-0)) + v0-0 + ) + ) + (('slave-option?) + (and (-> self slave) (logtest? (-> self slave 0 options) (-> block param 0))) + ) + (('set-slave-option) + (when (-> self slave) + (set! v0-0 (logior (-> self slave 0 options) (-> block param 0))) + (set! (-> self slave 0 options) (the-as cam-slave-options-u32 v0-0)) + v0-0 + ) + ) + (('clear-slave-option) + (when (-> self slave) + (set! v0-0 (logclear (-> self slave 0 options) (-> block param 0))) + (set! (-> self slave 0 options) (the-as cam-slave-options-u32 v0-0)) + v0-0 + ) + ) + (('no-follow) + (when (-> self slave) + (set! (-> self slave 0 tracking no-follow) (the-as basic #t)) + (vector-reset! (-> self slave 0 tracking follow-off)) + ) + (set! (-> *camera-combiner* tracking no-follow) (the-as basic #t)) + (set! v0-0 (-> *camera-combiner* tracking follow-off)) + (.svf (&-> (the-as vector v0-0) quad) vf0) + v0-0 + ) + (('yes-follow) + (if (-> self slave) + (set! (-> self slave 0 tracking no-follow) #f) + ) + (set! (-> *camera-combiner* tracking no-follow) #f) + #f + ) + (('blend-from-as-fixed) + (let ((t9-42 format) + (a0-102 0) + (a1-35 "ERROR : *camera* blend-from-as-fixed event not supported anymore~%") + ) + (-> block param 0) + (t9-42 a0-102 a1-35) + ) + ) + (('point-of-interest) + (let ((v1-232 (the-as object (-> block param 0)))) + (let ((a0-103 *math-camera*)) + (set! v0-0 (-> a0-103 trans)) + (let ((a0-104 (-> a0-103 inv-camera-rot fvec))) + (let ((a1-36 (- (-> self interest-dist)))) + (.mov vf7 a1-36) + ) + (.lvf vf5 (&-> a0-104 quad)) + ) + ) + (.lvf vf4 (&-> (the-as vector v1-232) 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 (&-> (the-as vector v0-0) quad) vf6) + v0-0 + ) + (('part-water-drip) + (set-time! (-> self water-drip-time)) + (set! (-> self water-drip-mult) (the-as float (-> block param 0))) + (set! (-> self water-drip-speed) (the-as float (-> block param 1))) + ) + (else + (and (-> self slave) (let ((v1-238 (new 'stack-no-clear 'event-message-block))) + (set! (-> v1-238 from) (process->ppointer proc)) + (set! (-> v1-238 num-params) argc) + (set! (-> v1-238 message) message) + (set! (-> v1-238 param 0) (-> block param 0)) + (set! (-> v1-238 param 1) (-> block param 1)) + (set! (-> v1-238 param 2) (-> block param 2)) + (set! (-> v1-238 param 3) (-> block param 3)) + (set! (-> v1-238 param 4) (-> block param 4)) + (set! (-> v1-238 param 5) (-> block param 5)) + (send-event-function (ppointer->process (-> self slave)) v1-238) + ) + ) + ) + ) + ) + ) + :enter (behavior () + (let ((v1-1 (process-spawn + camera-slave + :init cam-slave-init + cam-free-floating + #f + :name "camera-slave" + :from *camera-dead-pool* + :to self + ) + ) + ) + (set! (-> self slave) (the-as (pointer camera-slave) v1-1)) + (if (not v1-1) + (format 0 "ERROR : first slave failed to activate~%") + ) + ) + (let ((v1-6 (process-spawn + camera-slave + :init cam-slave-init + cam-fixed + #f + :name "camera-slave" + :from *camera-dead-pool* + :to self + ) + ) + ) + (set! (-> self decel) (the-as (pointer camera-slave) v1-6)) + (if (not v1-6) + (format 0 "ERROR : decel failed to activate~%") + ) + ) + (if (and (nonzero? camera-master-debug) *debug-segment*) + (add-connection *debug-engine* self camera-master-debug self #f #f) + ) + ) + :trans (behavior () + (when (not (paused?)) + (vector-negate! + (-> self local-down) + (vector-normalize-copy! (-> self local-down) (-> *standard-dynamics* gravity) 1.0) + ) + (cam-master-effect) + ) + ) + :code (behavior () + (until #f + (set! (-> self string-min target y) (-> self settings string-min-height)) + (set! (-> self string-max target y) (-> self settings string-max-height)) + (set! (-> self string-min target z) (-> self settings string-min-length)) + (set! (-> self string-max target z) (-> self settings string-max-length)) + (when (logtest? (-> *camera* settings master-options) (cam-master-options IMMEDIATE_STRING_MIN_MAX)) + (set! (-> self string-min value y) (-> self settings string-min-height)) + (set! (-> self string-max value y) (-> self settings string-max-height)) + (set! (-> self string-min value z) (-> self settings string-min-length)) + (set! (-> self string-max value z) (-> self settings string-max-length)) + ) + (set! (-> self string-push-z) (fmax (-> self string-min value z) (-> *CAMERA-bank* default-string-push-z))) + (master-track-target) + (set! (-> last-try-to-look-at-data horz) 0.0) + (set! (-> last-try-to-look-at-data vert) 0.0) + (when (not (paused?)) + (update! (-> self string-min) (the-as vector #f)) + (update! (-> self string-max) (the-as vector #f)) + ) + (set! (-> self string-min value x) + (fmin (-> self string-min value x) (+ -4.096 (-> self string-max value x))) + ) + (set! (-> self string-min value y) + (fmin (-> self string-min value y) (+ -4.096 (-> self string-max value y))) + ) + (set! (-> self string-min value z) + (fmin (-> self string-min value z) (+ -4.096 (-> self string-max value z))) + ) + (suspend) + ) + #f + ) + ) + +(defbehavior cam-master-init camera-master () + (stack-size-set! (-> self main-thread) 512) + (logclear! (-> self mask) (process-mask menu)) + (set! (-> self master-options) (cam-master-options-u32)) + (set! (-> self settings) (-> *setting-control* cam-current)) + (set! (-> self slave) (the-as (pointer camera-slave) #f)) + (set! (-> self decel) (the-as (pointer camera-slave) #f)) + (set! (-> self slave-options) (cam-slave-options-u32 JUMP_PITCHES COLLIDE LINE_OF_SIGHT)) + (set! (-> self view-off-param-save) 1.0) + (set! (-> self changer) (the-as uint (process->ppointer self))) + (set! (-> self string-push-z) (-> *CAMERA-bank* default-string-push-z)) + (let ((gp-0 (new-stack-vector0))) + (set! (-> gp-0 y) (-> self settings string-min-height)) + (set! (-> gp-0 z) (-> self settings string-min-length)) + (init (-> self string-min) gp-0 40.96 409.6 0.9) + (set! (-> gp-0 y) (-> self settings string-max-height)) + (set! (-> gp-0 z) (-> self settings string-max-length)) + (init (-> self string-max) gp-0 40.96 409.6 0.9) + ) + (set! (-> self outro-t-step) 0.0) + (reset-to-collide-spec (-> self focus) (collide-spec jak player-list)) + (let ((a1-4 (new-stack-vector0))) + (tracking-spline-method-10 (-> self target-spline) a1-4) + ) + (set! (-> self water-drip) (create-launch-control group-rain-screend-drop self)) + (set! (-> self water-drip-time) (seconds -60)) + (go cam-master-active) + 0 + (none) + ) + +(defmethod camera-master-method-14 ((this camera-master) (arg0 vector)) + (if (handle->process (-> this focus handle)) + (vector-! arg0 (-> this tpos-curr) (-> this tpos-old)) + (vector-reset! arg0) + ) + arg0 + ) + +(defmethod camera-master-method-15 ((this camera-master) (arg0 vector)) + (if (and (-> this slave) (-> this slave 0 next-state) (= (-> this slave 0 next-state name) 'cam-string)) + (set! (-> arg0 quad) (-> this slave 0 view-flat quad)) + (vector-reset! arg0) + ) + arg0 + ) diff --git a/goal_src/jak3/engine/camera/cam-states-dbg.gc b/goal_src/jak3/engine/camera/cam-states-dbg.gc index 94a875d6820..c7f1464b70e 100644 --- a/goal_src/jak3/engine/camera/cam-states-dbg.gc +++ b/goal_src/jak3/engine/camera/cam-states-dbg.gc @@ -7,3 +7,416 @@ ;; DECOMP BEGINS +(deftype cam-point-watch-bank (basic) + ((speed float) + (rot-speed degrees) + ) + ) + + +(define *CAM_POINT_WATCH-bank* (new 'static 'cam-point-watch-bank :speed 1600.0 :rot-speed (degrees 0.6))) + +(defstate cam-point-watch (camera-slave) + :event (behavior ((proc process) (argc int) (message symbol) (block event-message-block)) + (case message + (('teleport) + #f + ) + (else + (cam-standard-event-handler proc argc message block) + ) + ) + ) + :enter (behavior () + (when (not (-> self enter-has-run)) + (set! (-> self pivot-rad) 40960.0) + (set! (-> self blend-from-type) (camera-blend-from-type unknown-1)) + (set! (-> self blend-to-type) (camera-blend-to-type unknown-1)) + ) + ) + :code (behavior () + (until #f + (let ((s5-0 (new-stack-vector0)) + (gp-0 (new-stack-vector0)) + ) + (when (not (logtest? (-> *camera* settings master-options) (cam-master-options IGNORE_ANALOG))) + (let ((f28-0 (analog-input (the-as int (-> *cpad-list* cpads 0 leftx)) 128.0 48.0 110.0 -1.0)) + (f30-0 (analog-input (the-as int (-> *cpad-list* cpads 0 lefty)) 128.0 48.0 110.0 -1.0)) + (f26-0 (analog-input (the-as int (-> *cpad-list* cpads 0 rightx)) 128.0 48.0 110.0 -1.0)) + (f0-0 (analog-input (the-as int (-> *cpad-list* cpads 0 righty)) 128.0 48.0 110.0 -1.0)) + ) + (cond + ((cpad-hold? (-> *CAMERA-bank* joypad) r2) + (set! (-> s5-0 y) (- (-> s5-0 y) (* 0.2 (-> *CAM_POINT_WATCH-bank* rot-speed) (- f26-0)))) + (set! (-> s5-0 x) (- (-> s5-0 x) (* 0.2 (-> *CAM_POINT_WATCH-bank* rot-speed) (- f0-0)))) + (+! (-> gp-0 x) (* 0.2 (-> *CAM_POINT_WATCH-bank* speed) f28-0)) + (+! (-> gp-0 z) (* 0.2 (-> *CAM_POINT_WATCH-bank* speed) f30-0)) + ) + (else + (set! (-> s5-0 y) (- (-> s5-0 y) (* 2.0 (-> *CAM_POINT_WATCH-bank* rot-speed) (- f26-0)))) + (set! (-> s5-0 x) (- (-> s5-0 x) (* 2.0 (-> *CAM_POINT_WATCH-bank* rot-speed) (- f0-0)))) + (+! (-> gp-0 x) (* 2.0 (-> *CAM_POINT_WATCH-bank* speed) f28-0)) + (+! (-> gp-0 z) (* 2.0 (-> *CAM_POINT_WATCH-bank* speed) f30-0)) + ) + ) + ) + (let ((s4-0 (new-stack-vector0))) + (let ((s3-0 (new 'stack-no-clear 'matrix))) + (set! (-> s3-0 rvec quad) (the-as uint128 0)) + (set! (-> s3-0 uvec quad) (the-as uint128 0)) + (set! (-> s3-0 fvec quad) (the-as uint128 0)) + (set! (-> s3-0 trans quad) (the-as uint128 0)) + (matrix-axis-angle! s3-0 (the-as vector (-> self tracking)) (- (-> s5-0 x))) + (vector-matrix*! s4-0 (-> self tracking inv-mat fvec) s3-0) + (matrix-axis-angle! s3-0 (-> *camera* local-down) (- (-> s5-0 y))) + (vector-matrix*! s4-0 s4-0 s3-0) + ) + (forward-down->inv-matrix (the-as matrix (-> self tracking)) s4-0 (-> *camera* local-down)) + ) + (set! (-> self pivot-rad) (- (-> self pivot-rad) (-> gp-0 z))) + (if (< (-> self pivot-rad) 4096.0) + (set! (-> self pivot-rad) 4096.0) + ) + (set-vector! gp-0 0.0 0.0 (- (-> self pivot-rad)) 1.0) + (vector-matrix*! (-> self trans) gp-0 (the-as matrix (-> self tracking))) + ) + ) + (suspend) + 0 + ) + #f + ) + ) + +(deftype cam-free-bank (basic) + ((speed float) + (rot-speed degrees) + ) + ) + + +(define *CAM_FREE-bank* (new 'static 'cam-free-bank :speed 1600.0 :rot-speed (degrees 0.6))) + +(defun cam-mouse-input ((arg0 matrix) (arg1 vector) (arg2 vector)) + (rlet ((acc :class vf) + (vf0 :class vf) + (vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + (vf7 :class vf) + ) + (init-vf0-vector) + (let ((v1-0 (new 'stack-no-clear 'vector))) + (vector-! v1-0 (the-as vector (-> *mouse* pos)) (-> *mouse* pos 1)) + (if (< (-> *camera* interest-dist) 409.6) + (set! (-> *camera* interest-dist) 409.6) + ) + (let ((s3-0 (new 'stack-no-clear 'vector)) + (s2-0 (new 'stack-no-clear 'vector)) + ) + (let ((a0-9 (new 'stack-no-clear 'vector))) + 0.0 + (let ((a1-3 a0-9)) + (let ((a2-4 (-> *math-camera* trans))) + (let ((a3-0 (-> arg0 fvec))) + (let ((t0-1 (-> *camera* interest-dist))) + (.mov vf7 t0-1) + ) + (.lvf vf5 (&-> a3-0 quad)) + ) + (.lvf vf4 (&-> a2-4 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-3 quad) vf6) + ) + (vector-! s3-0 (-> *math-camera* trans) a0-9) + ) + (vector-length s3-0) + (cond + ((mouse-hold? left) + (let ((f30-0 (* 72.81778 (-> *mouse* speedy))) + (f28-0 (* -72.81778 (-> *mouse* speedx))) + ) + (let ((a2-8 (quaternion-vector-angle! (new 'stack-no-clear 'quaternion) (-> arg0 rvec) f30-0))) + (vector-orient-by-quat! s2-0 s3-0 a2-8) + ) + (let ((a2-10 (quaternion-vector-angle! (new 'stack-no-clear 'quaternion) *y-vector* f28-0))) + (vector-orient-by-quat! s2-0 s2-0 a2-10) + ) + (vector-! s2-0 s2-0 s3-0) + (vector-matrix*! s2-0 s2-0 (matrix-4x4-inverse! (new 'stack-no-clear 'matrix) arg0)) + (+! (-> arg2 x) (-> s2-0 x)) + (+! (-> arg2 y) (-> s2-0 y)) + (+! (-> arg2 z) (-> s2-0 z)) + (+! (-> arg1 x) f30-0) + (set! (-> arg1 y) (+ (-> arg1 y) f28-0)) + ) + ) + ((mouse-hold? right) + (+! (-> arg2 z) (* (-> v1-0 x) (-> *CAM_FREE-bank* speed))) + (set! (-> *camera* interest-dist) (- (-> *camera* interest-dist) (* (-> *CAM_FREE-bank* speed) (-> v1-0 x)))) + (if (< (-> *camera* interest-dist) 409.6) + (set! (-> *camera* interest-dist) 409.6) + ) + (when (< -8192.0 (vector-dot (-> arg0 fvec) s3-0)) + (let ((t0-2 (new 'static 'vector :w 1.0))) + (let ((v1-18 t0-2)) + (let ((a0-33 (-> *setting-control* cam-current mouse-tumble-point))) + (let ((a1-12 (-> arg0 fvec))) + (let ((a2-13 8192.0)) + (.mov vf7 a2-13) + ) + (.lvf vf5 (&-> a1-12 quad)) + ) + (.lvf vf4 (&-> a0-33 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 (&-> v1-18 quad) vf6) + ) + (set-setting! 'mouse-tumble-point 'abs t0-2 0) + ) + ) + ) + ((mouse-hold? middle) + (+! (-> arg2 x) (* (-> v1-0 x) (-> *CAM_FREE-bank* speed))) + (+! (-> arg2 y) (* (-> v1-0 y) (-> *CAM_FREE-bank* speed))) + (new 'static 'vector :w 1.0) + #f + ) + ) + ) + ) + ) + ) + +(defun cam-free-floating-input ((arg0 matrix) (arg1 vector) (arg2 vector) (arg3 int) (arg4 int)) + (with-pp + (when *camera* + (if (-> *setting-control* cam-current mouse-input) + (cam-mouse-input arg0 arg1 arg2) + ) + (let ((s3-0 (and (-> *setting-control* cam-current cpad1-skip-buttons) (= arg4 1))) + (f30-0 (-> *CAM_FREE-bank* speed)) + ) + (if *camera-turbo-free* + (set! f30-0 (* 10.0 f30-0)) + ) + (cond + ((logtest? (-> *camera* settings master-options) (cam-master-options IGNORE_ANALOG)) + ) + ((cpad-hold? arg4 r2) + (when (logtest? (-> *camera* settings master-options) (cam-master-options READ_BUTTONS)) + (if (cpad-hold? arg4 r1) + (+! (-> arg2 y) + (+ (* 0.2 f30-0) + (analog-input (the-as int (-> *cpad-list* cpads arg4 abutton 9)) 0.0 32.0 230.0 (* 0.2 f30-0)) + ) + ) + ) + ) + (when (logtest? (-> *camera* settings master-options) (cam-master-options READ_BUTTONS)) + (if (cpad-hold? arg4 l1) + (set! (-> arg2 y) + (- (-> arg2 y) + (+ (* 0.2 f30-0) + (analog-input (the-as int (-> *cpad-list* cpads arg4 abutton 8)) 0.0 32.0 230.0 (* 0.2 f30-0)) + ) + ) + ) + ) + ) + ) + (else + (when (logtest? (-> *camera* settings master-options) (cam-master-options READ_BUTTONS)) + (if (cpad-hold? arg4 r1) + (+! (-> arg2 y) + (+ f30-0 (analog-input (the-as int (-> *cpad-list* cpads arg4 abutton 9)) 0.0 32.0 230.0 f30-0)) + ) + ) + ) + (when (logtest? (-> *camera* settings master-options) (cam-master-options READ_BUTTONS)) + (if (cpad-hold? arg4 l1) + (set! (-> arg2 y) + (- (-> arg2 y) + (+ f30-0 (analog-input (the-as int (-> *cpad-list* cpads arg4 abutton 8)) 0.0 32.0 230.0 f30-0)) + ) + ) + ) + ) + ) + ) + (when (not (logtest? (-> *camera* settings master-options) (cam-master-options IGNORE_ANALOG))) + (let ((f26-2 (analog-input + (the-as int (-> (the-as cpad-list (+ (* arg4 4) (the-as int *cpad-list*))) cpads 0 leftx)) + 128.0 + 48.0 + 110.0 + -1.0 + ) + ) + (f28-4 (analog-input + (the-as int (-> (the-as cpad-list (+ (* arg4 4) (the-as int *cpad-list*))) cpads 0 lefty)) + 128.0 + 48.0 + 110.0 + -1.0 + ) + ) + (f24-0 (analog-input + (the-as int (-> (the-as cpad-list (+ (* arg4 4) (the-as int *cpad-list*))) cpads 0 rightx)) + 128.0 + 48.0 + 110.0 + -1.0 + ) + ) + (f0-19 (analog-input + (the-as int (-> (the-as cpad-list (+ (* arg4 4) (the-as int *cpad-list*))) cpads 0 righty)) + 128.0 + 48.0 + 110.0 + -1.0 + ) + ) + ) + (cond + ((and (not s3-0) + (logtest? (-> (the-as cpad-list (+ (* arg4 4) (the-as int *cpad-list*))) cpads 0 button0-abs 0) + (pad-buttons r2) + ) + ) + (cond + ((logtest? (-> (the-as cpad-list (+ (* arg4 4) (the-as int *cpad-list*))) cpads 0 button0-abs 0) + (pad-buttons l2) + ) + (set! (-> arg1 y) (- (-> arg1 y) (* 0.5 (-> *CAM_FREE-bank* rot-speed) (- f24-0)))) + (set! (-> arg1 x) (- (-> arg1 x) (* 0.5 (-> *CAM_FREE-bank* rot-speed) (- f0-19)))) + ) + (else + (set! (-> arg1 y) (- (-> arg1 y) (* (- f24-0) (-> *CAM_FREE-bank* rot-speed)))) + (set! (-> arg1 x) (- (-> arg1 x) (* (- f0-19) (-> *CAM_FREE-bank* rot-speed)))) + ) + ) + (+! (-> arg2 x) (* 0.2 f30-0 f26-2)) + (+! (-> arg2 z) (* 0.2 f30-0 f28-4)) + ) + ((and (not s3-0) (cpad-hold? arg4 l2)) + (+! (-> arg2 x) (* f26-2 f30-0)) + (+! (-> arg2 y) (* f0-19 f30-0)) + (+! (-> arg2 z) (* f28-4 f30-0)) + ) + (else + (set! (-> arg1 y) (- (-> arg1 y) (* 2.0 (-> *CAM_FREE-bank* rot-speed) (- f24-0)))) + (set! (-> arg1 x) (- (-> arg1 x) (* 2.0 (-> *CAM_FREE-bank* rot-speed) (- f0-19)))) + (+! (-> arg2 x) (* 2.0 f30-0 f26-2)) + (+! (-> arg2 z) (* 2.0 f30-0 f28-4)) + ) + ) + ) + ) + ) + (when (not (-> *setting-control* cam-current mouse-input)) + (vector-float*! arg1 arg1 (-> pp clock time-adjust-ratio)) + (vector-float*! arg2 arg2 (-> pp clock time-adjust-ratio)) + ) + ) + ) + ) + +(deftype camera-free-floating-move-info (structure) + ((rv vector :inline) + (tv vector :inline) + (up vector :inline) + (tm matrix :inline) + ) + ) + + +(defun cam-free-floating-move ((arg0 matrix) (arg1 vector) (arg2 vector) (arg3 int)) + (if (logtest? (-> *cpad-list* cpads arg3 valid) 128) + (return (the-as vector #f)) + ) + (if (= *master-mode* 'menu) + (return (the-as vector #f)) + ) + (let ((s3-0 (new 'stack 'camera-free-floating-move-info))) + (cam-free-floating-input arg0 (-> s3-0 rv) (-> s3-0 tv) (the-as int (not arg2)) arg3) + (vector-matrix*! (-> s3-0 tv) (-> s3-0 tv) arg0) + (cond + (arg2 + (matrix-axis-angle! (-> s3-0 tm) arg2 (-> s3-0 rv y)) + (matrix*! arg0 arg0 (-> s3-0 tm)) + (cond + ((< (vector-dot (-> arg0 uvec) arg2) 0.0) + (forward-down->inv-matrix arg0 (-> arg0 fvec) arg2) + ) + (else + (vector-negate! (-> s3-0 up) arg2) + (forward-down->inv-matrix arg0 (-> arg0 fvec) (-> s3-0 up)) + ) + ) + ) + (else + (matrix-axis-angle! (-> s3-0 tm) (-> arg0 uvec) (- (-> s3-0 rv y))) + (matrix*! arg0 arg0 (-> s3-0 tm)) + ) + ) + (matrix-axis-angle! (-> s3-0 tm) (-> arg0 rvec) (- (-> s3-0 rv x))) + (matrix*! arg0 arg0 (-> s3-0 tm)) + (matrix-axis-angle! (-> s3-0 tm) (-> arg0 fvec) (- (-> s3-0 rv z))) + (matrix*! arg0 arg0 (-> s3-0 tm)) + (vector+! arg1 arg1 (-> s3-0 tv)) + ) + ) + +(defstate cam-free-floating (camera-slave) + :event (behavior ((proc process) (argc int) (message symbol) (block event-message-block)) + (case message + (('teleport) + #f + ) + (else + (cam-standard-event-handler proc argc message block) + ) + ) + ) + :enter (behavior () + (when (not (-> self enter-has-run)) + (set! (-> self blend-from-type) (camera-blend-from-type unknown-1)) + (set! (-> self blend-to-type) (camera-blend-to-type unknown-1)) + (send-event *camera-combiner* 'stop-tracking) + ) + ) + :code (behavior () + (until #f + (let ((gp-0 (-> *camera* local-down))) + (if (logtest? (-> self options) (cam-slave-options-u32 ALLOW_Z_ROT)) + (set! gp-0 (the-as vector #f)) + ) + (when (not (-> *setting-control* cam-current mouse-input)) + (if *amy-cam* + (matrix-rotate-y! (the-as matrix (-> self tracking)) 32768.0) + ) + (cam-free-floating-move + (the-as matrix (-> self tracking)) + (-> self trans) + gp-0 + (the-as int (-> *CAMERA-bank* joypad)) + ) + (when *amy-cam* + (matrix-rotate-y! (the-as matrix (-> self tracking)) 32768.0) + (let ((a1-4 (matrix-rotate-x! (new 'stack-no-clear 'matrix) 16384.0))) + (matrix*! (the-as matrix (-> self tracking)) a1-4 (the-as matrix (-> self tracking))) + ) + ) + ) + ) + (suspend) + ) + #f + ) + ) diff --git a/goal_src/jak3/engine/camera/cam-states.gc b/goal_src/jak3/engine/camera/cam-states.gc index 75245cdc4f8..3bbf82cb095 100644 --- a/goal_src/jak3/engine/camera/cam-states.gc +++ b/goal_src/jak3/engine/camera/cam-states.gc @@ -7,3 +7,3783 @@ ;; DECOMP BEGINS +(defstate cam-no-trans (camera-slave) + :event cam-standard-event-handler + :enter (behavior () + (when (not (-> self enter-has-run)) + (set! (-> self blend-from-type) (camera-blend-from-type unknown-2)) + (set! (-> self blend-to-type) (camera-blend-to-type unknown-2)) + ) + ) + :trans (behavior () + (if (not (logtest? (-> *camera* master-options) (cam-master-options-u32 HAVE_TARGET))) + (cam-slave-go cam-free-floating) + ) + ) + :code (behavior () + (until #f + (if (not (paused?)) + (set! (-> self fov) (-> *camera* settings fov)) + ) + (suspend) + ) + #f + ) + ) + +(defstate cam-really-fixed (camera-slave) + :event (behavior ((proc process) (argc int) (message symbol) (block event-message-block)) + (case message + (('teleport) + #f + ) + (else + (cam-standard-event-handler proc argc message block) + ) + ) + ) + :enter (behavior () + (when (not (-> self enter-has-run)) + (set! (-> self saved-pt quad) (-> self trans quad)) + (set! (-> self blend-from-type) (camera-blend-from-type unknown-1)) + (set! (-> self blend-to-type) (camera-blend-to-type unknown-0)) + 0 + ) + ) + :code (behavior () + (until #f + (suspend) + ) + #f + ) + ) + +(defstate cam-fixed (camera-slave) + :event (behavior ((proc process) (argc int) (message symbol) (block event-message-block)) + (case message + (('teleport) + #f + ) + (else + (cam-standard-event-handler proc argc message block) + ) + ) + ) + :enter (behavior () + (when (not (-> self enter-has-run)) + (set! (-> self saved-pt quad) (-> self trans quad)) + (set! (-> self blend-from-type) (camera-blend-from-type unknown-1)) + (set! (-> self blend-to-type) (camera-blend-to-type unknown-0)) + 0 + ) + ) + :code (behavior () + (until #f + (when (not (paused?)) + (let ((gp-0 (new 'stack-no-clear 'vector))) + (set! (-> self fov) (-> *camera* slave 0 fov)) + (set! (-> self trans quad) (-> self saved-pt quad)) + (cam-curve-pos (-> self trans) gp-0 (the-as curve #f) #f) + (when (!= (-> gp-0 w) 0.0) + (vector-normalize! gp-0 1.0) + (forward-down->inv-matrix (the-as matrix (-> self tracking)) gp-0 (-> *camera* local-down)) + ) + ) + ) + (suspend) + ) + #f + ) + ) + +(defstate cam-fixed-read-entity (camera-slave) + :event (behavior ((proc process) (argc int) (message symbol) (block event-message-block)) + (case message + (('teleport) + #f + ) + (else + (cam-standard-event-handler proc argc message block) + ) + ) + ) + :enter (behavior () + (cond + ((-> self enter-has-run) + ) + ((-> self cam-entity) + (cam-slave-get-vector-with-offset (the-as entity-actor (-> self cam-entity)) (-> self trans) 'trans) + (cam-slave-get-rot (the-as entity-actor (-> self cam-entity)) (the-as matrix (-> self tracking))) + (set! (-> self fov) (cam-slave-get-fov (-> self cam-entity))) + (cam-curve-setup (-> self trans)) + ((-> cam-fixed enter)) + ) + (else + (format #t "ERROR : cam-fixed-read-entity enter without entity~%") + ) + ) + (go cam-fixed) + ) + :code (behavior () + (until #f + (format *stdcon* "ERROR : stayed in cam-fixed-read-entity~%") + (suspend) + ) + #f + ) + ) + +(defstate cam-pov (camera-slave) + :event (behavior ((proc process) (argc int) (message symbol) (block event-message-block)) + (case message + (('teleport) + #f + ) + (else + (cam-standard-event-handler proc argc message block) + ) + ) + ) + :enter (behavior () + (when (not (-> self enter-has-run)) + (set! (-> self blend-from-type) (camera-blend-from-type unknown-1)) + (set! (-> self blend-to-type) (camera-blend-to-type unknown-1)) + ) + ) + :trans (behavior () + (when (not (handle->process (-> *camera* settings pov-handle))) + (set! (-> self blend-from-type) (camera-blend-from-type unknown-0)) + (cam-slave-go cam-fixed) + ) + ) + :code (behavior () + (until #f + (when (not (paused?)) + (vector<-cspace! (-> self trans) (-> (the-as process-drawable (-> *camera* settings pov-handle process 0)) + node-list + data + (-> *camera* settings pov-bone) + ) + ) + (let* ((v1-6 (-> self tracking)) + (a3-0 (-> (the-as process-drawable (-> *camera* settings pov-handle process 0)) + node-list + data + (-> *camera* settings pov-bone) + bone + transform + ) + ) + (a0-9 (-> a3-0 rvec quad)) + (a1-11 (-> a3-0 uvec quad)) + (a2-0 (-> a3-0 fvec quad)) + (a3-1 (-> a3-0 trans quad)) + ) + (set! (-> v1-6 inv-mat rvec quad) a0-9) + (set! (-> v1-6 inv-mat uvec quad) a1-11) + (set! (-> v1-6 inv-mat fvec quad) a2-0) + (set! (-> v1-6 inv-mat trans quad) a3-1) + ) + (vector-reset! (-> self tracking inv-mat trans)) + (let ((gp-0 (new 'stack-no-clear 'vector))) + (vector-matrix*! gp-0 (-> *camera* settings pov-offset) (the-as matrix (-> self tracking))) + (vector+! (-> self trans) (-> self trans) gp-0) + ) + ) + (suspend) + ) + #f + ) + ) + +(defstate cam-pov180 (camera-slave) + :event (behavior ((proc process) (argc int) (message symbol) (block event-message-block)) + (case message + (('teleport) + #f + ) + (else + (cam-standard-event-handler proc argc message block) + ) + ) + ) + :enter (behavior () + (when (not (-> self enter-has-run)) + (set! (-> self blend-from-type) (camera-blend-from-type unknown-1)) + (set! (-> self blend-to-type) (camera-blend-to-type unknown-1)) + ) + ) + :trans (behavior () + (when (not (handle->process (-> *camera* settings pov-handle))) + (set! (-> self blend-from-type) (camera-blend-from-type unknown-0)) + (cam-slave-go cam-fixed) + ) + ) + :code (behavior () + (let ((gp-0 (new 'stack-no-clear 'vector)) + (s5-0 (new 'stack-no-clear 'vector)) + (s4-0 #t) + ) + (vector<-cspace! gp-0 (-> (the-as process-drawable (-> *camera* settings pov-handle process 0)) + node-list + data + (-> *camera* settings pov-bone) + ) + ) + (let ((v1-13 (-> (the-as process-drawable (-> *camera* settings pov-handle process 0)) + node-list + data + (-> *camera* settings pov-bone) + bone + transform + ) + ) + ) + (vector-normalize-copy! s5-0 (-> v1-13 fvec) 1.0) + ) + (until #f + (when (not (paused?)) + (let ((s0-0 (-> (the-as process-drawable (-> *camera* settings pov-handle process 0)) + node-list + data + (-> *camera* settings pov-bone) + bone + transform + ) + ) + (s1-0 (-> (the-as process-drawable (-> *camera* settings pov-handle process 0)) + node-list + data + (-> *camera* settings pov-bone) + bone + scale + ) + ) + (s3-0 (new 'stack-no-clear 'vector)) + ) + (let ((s2-0 (new 'stack-no-clear 'vector))) + (vector<-cspace! + s2-0 + (-> (the-as process-drawable (-> *camera* settings pov-handle process 0)) + node-list + data + (-> *camera* settings pov-bone) + ) + ) + (vector-normalize-copy! s3-0 (-> s0-0 fvec) 1.0) + (set! s4-0 + (cond + ((and (< (vector-vector-distance s2-0 gp-0) 40960.0) (< (cos 3640.889) (vector-dot s5-0 s3-0))) + (set! (-> self trans quad) (-> s2-0 quad)) + (vector-negate! (the-as vector (-> self tracking)) (-> s0-0 rvec)) + (set! (-> self tracking inv-mat uvec quad) (-> s0-0 uvec quad)) + (vector-negate! (-> self tracking inv-mat fvec) (-> s0-0 fvec)) + (set! (-> self fov) (* 2.0 (atan (/ 12.700255 (* 20.3 (-> s1-0 x))) 1.0))) + (vector-float*! (the-as vector (-> self tracking)) (the-as vector (-> self tracking)) (/ 1.0 (-> s1-0 x))) + (vector-reset! (-> self tracking inv-mat trans)) + (if s4-0 + (set! s4-0 #f) + ) + s4-0 + ) + (else + #t + ) + ) + ) + (set! (-> gp-0 quad) (-> s2-0 quad)) + ) + (set! (-> s5-0 quad) (-> s3-0 quad)) + ) + ) + (suspend) + ) + ) + #f + ) + ) + +(defstate cam-pov-track (camera-slave) + :event cam-standard-event-handler + :enter (behavior () + (when (not (-> self enter-has-run)) + (set! (-> self blend-from-type) (camera-blend-from-type unknown-2)) + (set! (-> self blend-to-type) (camera-blend-to-type unknown-2)) + ) + ) + :trans (behavior () + (if (or (not (handle->process (-> *camera* settings pov-handle))) + (not (logtest? (-> *camera* master-options) (cam-master-options-u32 HAVE_TARGET))) + ) + (cam-slave-go cam-free-floating) + ) + ) + :code (behavior () + (until #f + (when (not (paused?)) + (set! (-> self fov) (-> *camera* settings fov)) + (vector<-cspace! (-> self trans) (-> (the-as process-drawable (-> *camera* settings pov-handle process 0)) + node-list + data + (-> *camera* settings pov-bone) + ) + ) + (let ((gp-0 (new 'stack-no-clear 'vector))) + (let ((a2-0 (new 'stack-no-clear 'matrix))) + (let* ((v1-8 a2-0) + (t0-0 (-> (the-as process-drawable (-> *camera* settings pov-handle process 0)) + node-list + data + (-> *camera* settings pov-bone) + bone + transform + ) + ) + (a0-9 (-> t0-0 rvec quad)) + (a1-11 (-> t0-0 uvec quad)) + (a3-0 (-> t0-0 fvec quad)) + (t0-1 (-> t0-0 trans quad)) + ) + (set! (-> v1-8 rvec quad) a0-9) + (set! (-> v1-8 uvec quad) a1-11) + (set! (-> v1-8 fvec quad) a3-0) + (set! (-> v1-8 trans quad) t0-1) + ) + (vector-reset! (-> a2-0 trans)) + (vector-matrix*! gp-0 (-> *camera* settings pov-offset) a2-0) + ) + (vector+! (-> self trans) (-> self trans) gp-0) + ) + ) + (suspend) + ) + #f + ) + ) + +(defbehavior cam-standoff-calc-trans camera-slave () + (if (-> self tracking no-follow) + (vector+! (-> self trans) (-> *camera* tpos-curr-adj) (-> self pivot-pt)) + (vector+! (-> self trans) (-> self tracking follow-pt) (-> self pivot-pt)) + ) + ) + +(defstate cam-standoff (camera-slave) + :event (behavior ((proc process) (argc int) (message symbol) (block event-message-block)) + (case message + (('set-standoff-dist) + (vector-normalize! (-> self pivot-pt) (the-as float (-> block param 0))) + (cam-standoff-calc-trans) + ) + (('set-standoff-height) + (vector-flatten! (-> self pivot-pt) (-> self pivot-pt) (-> *camera* local-down)) + (vector--float*! + (-> self pivot-pt) + (-> self pivot-pt) + (-> *camera* local-down) + (the-as float (-> block param 0)) + ) + (cam-standoff-calc-trans) + ) + (else + (cam-standard-event-handler proc argc message block) + ) + ) + ) + :enter (behavior () + (when (not (-> self enter-has-run)) + (vector-! (-> self pivot-pt) (-> self trans) (-> *camera* tpos-curr-adj)) + (cond + ((logtest? (-> self options) (cam-slave-options-u32 NO_ROTATE)) + (set! (-> self blend-from-type) (camera-blend-from-type unknown-0)) + (set! (-> self blend-to-type) (camera-blend-to-type unknown-0)) + 0 + ) + (else + (set! (-> self blend-from-type) (camera-blend-from-type unknown-2)) + (set! (-> self blend-to-type) (camera-blend-to-type unknown-2)) + ) + ) + ) + (cam-calc-follow! (-> self tracking) (-> self trans) #f) + ) + :trans (behavior () + (if (not (logtest? (-> *camera* master-options) (cam-master-options-u32 HAVE_TARGET))) + (cam-slave-go cam-free-floating) + ) + ) + :code (behavior () + (until #f + (when (not (paused?)) + (cam-calc-follow! (-> self tracking) (-> self trans) #t) + (cam-standoff-calc-trans) + ) + (suspend) + ) + #f + ) + ) + +(defstate cam-standoff-read-entity (camera-slave) + :event cam-standard-event-handler + :enter (behavior () + (cond + ((-> self enter-has-run) + ) + ((-> self cam-entity) + (let ((gp-0 (new-stack-vector0)) + (s5-0 (new-stack-vector0)) + ) + (cam-slave-get-vector-with-offset (the-as entity-actor (-> self cam-entity)) gp-0 'trans) + (cam-slave-get-vector-with-offset (the-as entity-actor (-> self cam-entity)) s5-0 'align) + (vector-! (-> self pivot-pt) gp-0 s5-0) + ) + (vector+! (-> self trans) (-> *camera* tpos-curr-adj) (-> self pivot-pt)) + (set! (-> self fov) (cam-slave-get-fov (-> self cam-entity))) + (logior! (-> self options) (cam-slave-get-flags (-> self cam-entity) 'flags)) + (if (logtest? (-> self options) (cam-slave-options-u32 NO_ROTATE)) + (cam-slave-get-rot (the-as entity-actor (-> self cam-entity)) (the-as matrix (-> self tracking))) + (set! (-> self tracking tilt-adjust target) + (cam-slave-get-float (-> self cam-entity) 'tiltAdjust (-> *CAMERA-bank* default-tilt-adjust)) + ) + ) + ((-> cam-standoff enter)) + ) + (else + (format #t "ERROR : cam-standoff-read-entity enter without entity~%") + ) + ) + (go cam-standoff) + ) + :code (behavior () + (until #f + (format *stdcon* "ERROR : stayed in cam-standoff-read-entity~%") + (suspend) + ) + #f + ) + ) + +(deftype cam-eye-bank (basic) + ((rot-speed float) + (max-degrees float) + (max-fov float) + (min-fov float) + ) + ) + + +(define *CAM_EYE-bank* + (new 'static 'cam-eye-bank :rot-speed 364.0889 :max-degrees 12743.111 :max-fov 11650.845 :min-fov 6189.511) + ) + +(defstate cam-eye (camera-slave) + :event (behavior ((proc process) (argc int) (message symbol) (block event-message-block)) + (case message + (('teleport) + #f + ) + (else + (cam-standard-event-handler proc argc message block) + ) + ) + ) + :enter (behavior () + (when (not (-> self enter-has-run)) + (let ((v1-3 + (vector-float*! (new-stack-vector0) (-> *camera* local-down) (+ 1024.0 (-> *camera* settings target-height))) + ) + ) + (vector-! (-> self trans) (-> *camera* tpos-curr) v1-3) + ) + (set! (-> self blend-from-type) (camera-blend-from-type unknown-0)) + (set! (-> self blend-to-type) (camera-blend-to-type unknown-0)) + 0 + ) + (set! (-> self fov) 11650.845) + ) + :exit (behavior () + (if (and *target* + (logtest? (-> *camera* master-options) (cam-master-options-u32 HAVE_TARGET)) + (focus-test? *target* in-head) + ) + (send-event *target* 'end-mode 'in-head) + ) + ) + :trans (behavior () + (if (not (logtest? (-> *camera* master-options) (cam-master-options-u32 HAVE_TARGET))) + (go cam-free-floating) + ) + ) + :code (behavior () + (let ((gp-0 (current-time))) + (until #f + (when (not (paused?)) + (let ((s4-0 (vector-reset! (new-stack-vector0))) + (s5-0 (new 'stack-no-clear 'matrix)) + ) + (set! (-> s5-0 rvec quad) (the-as uint128 0)) + (set! (-> s5-0 uvec quad) (the-as uint128 0)) + (set! (-> s5-0 fvec quad) (the-as uint128 0)) + (set! (-> s5-0 trans quad) (the-as uint128 0)) + (when (not (logtest? (-> *camera* settings master-options) (cam-master-options IGNORE_ANALOG))) + (let ((f30-0 (analog-input + (the-as int (+ (-> *cpad-list* cpads 0 rightx) -256 (-> *cpad-list* cpads 0 leftx))) + 0.0 + 48.0 + 110.0 + -1.0 + ) + ) + (f0-0 (analog-input + (the-as int (+ (-> *cpad-list* cpads 0 righty) -256 (-> *cpad-list* cpads 0 lefty))) + 0.0 + 48.0 + 110.0 + -1.0 + ) + ) + ) + (if (-> *camera* settings flip-vertical) + (set! f0-0 (- f0-0)) + ) + (set! (-> s4-0 y) (- (-> s4-0 y) (* (- f30-0) (-> *CAM_EYE-bank* rot-speed)))) + (set! (-> s4-0 x) (- (-> s4-0 x) (* (- f0-0) (-> *CAM_EYE-bank* rot-speed)))) + ) + ) + (cond + ((< (-> *CAM_EYE-bank* rot-speed) (-> s4-0 x)) + (set! (-> s4-0 x) (-> *CAM_EYE-bank* rot-speed)) + ) + ((< (-> s4-0 x) (- (-> *CAM_EYE-bank* rot-speed))) + (set! (-> s4-0 x) (- (-> *CAM_EYE-bank* rot-speed))) + ) + ) + (cond + ((< (-> *CAM_EYE-bank* rot-speed) (-> s4-0 y)) + (set! (-> s4-0 y) (-> *CAM_EYE-bank* rot-speed)) + ) + ((< (-> s4-0 y) (- (-> *CAM_EYE-bank* rot-speed))) + (set! (-> s4-0 y) (- (-> *CAM_EYE-bank* rot-speed))) + ) + ) + (cond + ((and (= (-> s4-0 x) 0.0) (= (-> s4-0 y) 0.0)) + (set! gp-0 (current-time)) + ) + (else + (let ((v1-44 (min 10 (max 1 (- (current-time) gp-0))))) + (vector-float*! s4-0 s4-0 (* 0.1 (the float v1-44))) + ) + ) + ) + (matrix-axis-angle! s5-0 (-> *camera* local-down) (-> s4-0 y)) + (matrix*! (the-as matrix (-> self tracking)) (the-as matrix (-> self tracking)) s5-0) + (when (not (logtest? (-> self options) (cam-slave-options-u32 ALLOW_Z_ROT))) + (if (< (vector-dot (-> self tracking inv-mat uvec) (-> *camera* local-down)) 0.0) + (forward-down->inv-matrix + (the-as matrix (-> self tracking)) + (-> self tracking inv-mat fvec) + (-> *camera* local-down) + ) + (forward-down->inv-matrix + (the-as matrix (-> self tracking)) + (-> self tracking inv-mat fvec) + (vector-negate! (new-stack-vector0) (-> *camera* local-down)) + ) + ) + ) + (matrix-axis-angle! s5-0 (the-as vector (-> self tracking)) (- (-> s4-0 x))) + (matrix*! (the-as matrix (-> self tracking)) (the-as matrix (-> self tracking)) s5-0) + ) + (when (not (logtest? (-> self options) (cam-slave-options-u32 ALLOW_Z_ROT))) + (let ((f30-1 (vector-dot (-> *camera* local-down) (-> self tracking inv-mat fvec)))) + (set! (-> (new 'stack-no-clear 'vector) quad) (the-as uint128 0)) + (when (< (sin (-> *CAM_EYE-bank* max-degrees)) (fabs f30-1)) + (vector--float*! + (-> self tracking inv-mat fvec) + (-> self tracking inv-mat fvec) + (-> *camera* local-down) + f30-1 + ) + (vector-normalize! (-> self tracking inv-mat fvec) (cos (-> *CAM_EYE-bank* max-degrees))) + (if (< f30-1 0.0) + (vector--float*! + (-> self tracking inv-mat fvec) + (-> self tracking inv-mat fvec) + (-> *camera* local-down) + (sin (-> *CAM_EYE-bank* max-degrees)) + ) + (vector+float*! + (-> self tracking inv-mat fvec) + (-> self tracking inv-mat fvec) + (-> *camera* local-down) + (sin (-> *CAM_EYE-bank* max-degrees)) + ) + ) + (vector-cross! + (-> self tracking inv-mat uvec) + (-> self tracking inv-mat fvec) + (the-as vector (-> self tracking)) + ) + (set! (-> self tracking inv-mat uvec w) 0.0) + ) + ) + ) + ) + (let ((v1-75 + (vector-float*! (new-stack-vector0) (-> *camera* local-down) (+ 1024.0 (-> *camera* settings target-height))) + ) + ) + (vector-! (-> self trans) (-> *camera* tpos-curr) v1-75) + ) + (suspend) + ) + ) + #f + ) + ) + +(defun cam-curve-closest-point ((arg0 curve) (arg1 vector) (arg2 float) (arg3 float) (arg4 int)) + (let ((s4-0 1) + (s2-0 40.96) + (f30-1 (/ 1.0 (* 3.0 (curve-length arg0)))) + (f28-1 0.01) + ) + (if (< 0.0 s2-0) + (set! f28-1 (* s2-0 f30-1)) + ) + (while (> s4-0 0) + (+! s4-0 -1) + (let* ((v1-6 (fmax 0.0 (fmin 1.0 arg2))) + (f26-0 (fmax 0.0 (- v1-6 f28-1))) + (f24-0 (fmin 1.0 (+ v1-6 f28-1))) + (s3-1 (new 'stack-no-clear 'vector)) + (s2-1 (new 'stack-no-clear 'vector)) + (s1-0 (new 'stack-no-clear 'vector)) + (s0-0 (* 0.5 (+ f26-0 f24-0))) + ) + (curve-get-pos! s3-1 s0-0 arg0) + (vector-! s3-1 arg1 s3-1) + (curve-get-pos! s2-1 f24-0 arg0) + (curve-get-pos! s1-0 f26-0 arg0) + (vector-! s2-1 s2-1 s1-0) + (vector-normalize! s2-1 1.0) + (let ((v1-11 (+ s0-0 (* (vector-dot s2-1 s3-1) f30-1)))) + (set! arg2 (fmax 0.0 (fmin 1.0 v1-11))) + ) + ) + ) + ) + arg2 + ) + +(defstate cam-tube-sled (camera-slave) + :event cam-standard-event-handler + :enter (behavior () + (cond + ((-> self enter-has-run) + ) + ((-> self cam-entity) + (set! (-> self fov) (cam-slave-get-fov (-> self cam-entity))) + (logior! (-> self options) (cam-slave-get-flags (-> self cam-entity) 'flags)) + (set! (-> self spline-follow-dist) + (fmax 0.0 (cam-slave-get-float (-> self cam-entity) 'spline-follow-dist 0.0)) + ) + (when (get-curve-data! (-> self cam-entity) (-> self spline-curve) 'campath 'campath-k -1000000000.0) + (set! (-> self spline-tt) (curve-closest-point (-> self spline-curve) (-> self saved-pt) 0.5 -4096.0 30 0.0)) + (set! (-> self spline-tt) (fmin 1.0 (fmax 0.0 (-> self spline-tt)))) + (set! (-> self spline-exists) #t) + ) + (set! (-> self blend-from-type) (camera-blend-from-type unknown-1)) + (set! (-> self blend-to-type) (camera-blend-to-type unknown-1)) + ) + (else + (format 0 "ERROR : cam-tube-sled enter without entity~%") + ) + ) + ) + :trans (behavior () + (if (not (logtest? (-> *camera* master-options) (cam-master-options-u32 HAVE_TARGET))) + (cam-slave-go cam-free-floating) + ) + ) + :code (behavior () + (until #f + (let ((v1-0 (or (paused?) (not (-> self spline-exists))))) + (cond + (v1-0 + ) + (else + (let ((s4-0 (new 'stack-no-clear 'vector))) + (set! (-> s4-0 quad) (-> *camera* tpos-curr quad)) + (let ((s5-0 (new 'stack-no-clear 'vector)) + (gp-0 (new 'stack-no-clear 'vector)) + ) + (let ((f30-1 (/ 1.0 (curve-length (-> self spline-curve))))) + (set! (-> self spline-tt) (cam-curve-closest-point (-> self spline-curve) s4-0 (-> self spline-tt) 40.96 1)) + (curve-get-pos! s5-0 (-> self spline-tt) (-> self spline-curve)) + (vector-lerp! (-> self trans) s5-0 s4-0 0.75) + (cond + ((< (-> self spline-tt) 0.5) + (curve-get-pos! gp-0 (+ (-> self spline-tt) (* 4096.0 f30-1)) (-> self spline-curve)) + (vector-! gp-0 gp-0 s5-0) + ) + (else + (curve-get-pos! gp-0 (- (-> self spline-tt) (* 4096.0 f30-1)) (-> self spline-curve)) + (vector-! gp-0 s5-0 gp-0) + ) + ) + (vector-normalize! gp-0 1.0) + (vector+float*! (-> self trans) (-> self trans) gp-0 (-> self spline-follow-dist)) + (curve-get-pos! gp-0 (- (-> self spline-tt) (* 122880.0 f30-1)) (-> self spline-curve)) + ) + (vector-! gp-0 s5-0 gp-0) + (vector-negate! gp-0 gp-0) + (vector-normalize! gp-0 1.0) + (forward-down->inv-matrix (the-as matrix (-> self tracking)) gp-0 (-> *camera* local-down)) + ) + ) + (vector-into-frustum-nosmooth! (the-as matrix (-> self tracking)) (-> self trans) (-> self fov)) + ) + ) + ) + (suspend) + ) + #f + ) + ) + +(defstate cam-spline (camera-slave) + :event cam-standard-event-handler + :enter (behavior () + (cond + ((-> self enter-has-run) + ) + ((-> self cam-entity) + (let ((gp-0 (new-stack-vector0))) + (set! (-> self fov) (cam-slave-get-fov (-> self cam-entity))) + (logior! (-> self options) (cam-slave-get-flags (-> self cam-entity) 'flags)) + (if (logtest? (-> self options) (cam-slave-options-u32 NO_ROTATE)) + (cam-slave-get-rot (the-as entity-actor (-> self cam-entity)) (the-as matrix (-> self tracking))) + (set! (-> self tracking tilt-adjust target) + (cam-slave-get-float (-> self cam-entity) 'tiltAdjust (-> *CAMERA-bank* default-tilt-adjust)) + ) + ) + (cam-slave-get-vector-with-offset (the-as entity-actor (-> self cam-entity)) gp-0 'trans) + (cam-curve-setup gp-0) + ) + (vector-negate! (-> self saved-pt) (-> self spline-offset)) + (let ((a0-8 (res-lump-struct (-> self cam-entity) 'spline-offset structure))) + (if a0-8 + (vector+! (-> self spline-offset) (-> self spline-offset) (the-as vector a0-8)) + ) + ) + (set! (-> self trans quad) (-> self saved-pt quad)) + (cam-calc-follow! (-> self tracking) (-> self trans) #f) + (set! (-> self spline-follow-dist) (cam-slave-get-float (-> self cam-entity) 'spline-follow-dist 0.0)) + (cond + ((< 0.0 (-> self spline-follow-dist)) + (let ((s5-1 (new 'stack-no-clear 'vector)) + (gp-1 (new 'stack-no-clear 'vector)) + ) + (curve-get-pos! s5-1 0.0 (-> self spline-curve)) + (curve-get-pos! gp-1 1.0 (-> self spline-curve)) + (if (< (vector-vector-distance-squared s5-1 (-> self tracking follow-pt)) + (vector-vector-distance-squared gp-1 (-> self tracking follow-pt)) + ) + (set! (-> self spline-follow-dist) (- (-> self spline-follow-dist))) + ) + ) + (set! (-> self spline-tt) (curve-closest-point + (-> self spline-curve) + (-> self tracking follow-pt) + 0.5 + -4096.0 + 10 + (-> self spline-follow-dist) + ) + ) + ) + (else + (set! (-> self spline-follow-dist) 0.0) + ) + ) + (cam-curve-pos (-> self trans) (the-as vector #f) (the-as curve #f) #t) + (cond + ((logtest? (-> self options) (cam-slave-options-u32 NO_ROTATE)) + (set! (-> self blend-from-type) (camera-blend-from-type unknown-0)) + (set! (-> self blend-to-type) (camera-blend-to-type unknown-0)) + 0 + ) + (else + (set! (-> self blend-from-type) (camera-blend-from-type unknown-2)) + (set! (-> self blend-to-type) (camera-blend-to-type unknown-2)) + ) + ) + ) + (else + (format #t "ERROR : cam-spline enter without entity~%") + ) + ) + ) + :trans (behavior () + (if (not (logtest? (-> *camera* master-options) (cam-master-options-u32 HAVE_TARGET))) + (cam-slave-go cam-free-floating) + ) + ) + :code (behavior () + (until #f + (when (not (paused?)) + (cam-calc-follow! (-> self tracking) (-> self trans) #t) + (new 'stack 'curve) + (set! (-> self trans quad) (-> self saved-pt quad)) + (cam-curve-pos (-> self trans) (the-as vector #f) (the-as curve #f) #t) + ) + (suspend) + ) + #f + ) + ) + +(defstate cam-decel (camera-slave) + :event (behavior ((proc process) (argc int) (message symbol) (block event-message-block)) + (case message + (('teleport) + #f + ) + (else + (cam-standard-event-handler proc argc message block) + ) + ) + ) + :enter (behavior () + (when (not (-> self enter-has-run)) + (set! (-> self saved-pt quad) (-> self trans quad)) + (set! (-> self blend-from-type) (camera-blend-from-type unknown-1)) + (set! (-> self blend-to-type) (camera-blend-to-type unknown-1)) + ) + ) + :code (behavior () + (until #f + (when (not (paused?)) + (let ((s5-0 (new-stack-vector0)) + (gp-0 (new-stack-vector0)) + ) + (when (!= (-> *camera* outro-t-step) 0.0) + (curve-get-pos! s5-0 (parameter-ease-sin-clamp (-> *camera* outro-t)) (-> *camera* outro-curve)) + (+! (-> *camera* outro-t) (* (-> *camera* outro-t-step) (-> self clock time-adjust-ratio))) + (curve-get-pos! gp-0 (parameter-ease-sin-clamp (-> *camera* outro-t)) (-> *camera* outro-curve)) + (vector-! gp-0 gp-0 s5-0) + (cond + ((or (and (< (-> *camera* outro-t-step) 0.0) (>= (-> *camera* outro-exit-value) (-> *camera* outro-t))) + (and (< 0.0 (-> *camera* outro-t-step)) (>= (-> *camera* outro-t) (-> *camera* outro-exit-value))) + ) + (set! (-> *camera* outro-t) (-> *camera* outro-exit-value)) + (set! (-> *camera* outro-t-step) 0.0) + (vector+! (-> self velocity) (-> self velocity) gp-0) + (send-event *camera* 'outro-done) + ) + (else + (vector+! (-> self trans) (-> self trans) gp-0) + ) + ) + ) + ) + (vector-float*! (-> self velocity) (-> self velocity) 0.9) + (vector+! (-> self trans) (-> self trans) (-> self velocity)) + ) + (suspend) + ) + #f + ) + ) + +(defstate cam-endlessfall (camera-slave) + :event (behavior ((proc process) (argc int) (message symbol) (block event-message-block)) + (case message + (('teleport) + #f + ) + (else + (cam-standard-event-handler proc argc message block) + ) + ) + ) + :enter (behavior () + (when (not (-> self enter-has-run)) + (set! (-> self blend-from-type) (camera-blend-from-type unknown-2)) + (set! (-> self blend-to-type) (camera-blend-to-type unknown-2)) + ) + ) + :code (behavior () + (let ((gp-0 (new 'stack-no-clear 'cam-vector-seeker)) + (f30-0 (-> self velocity y)) + ) + (let ((a1-0 (new 'stack-no-clear 'vector)) + (s5-0 (new 'stack-no-clear 'vector)) + ) + (set! (-> a1-0 quad) (-> self trans quad)) + (set! (-> a1-0 y) 0.0) + (set! (-> s5-0 quad) (-> self velocity quad)) + (set! (-> s5-0 y) 0.0) + (init gp-0 a1-0 81.92 (fmax 819.2 (vector-length s5-0)) 0.75) + (set! (-> gp-0 vel quad) (-> s5-0 quad)) + ) + (until #f + (when (not (paused?)) + (set! (-> gp-0 target x) (-> (target-pos 0) x)) + (set! (-> gp-0 target z) (-> (target-pos 0) z)) + (update! gp-0 (the-as vector #f)) + (when (< 819.2 (-> gp-0 max-vel)) + (set! (-> gp-0 max-vel) (* 0.9 (-> gp-0 max-vel))) + (if (< (-> gp-0 max-vel) 819.2) + (set! (-> gp-0 max-vel) 819.2) + ) + ) + (set! f30-0 (* 0.9 f30-0)) + (+! (-> self trans y) f30-0) + (set! (-> self trans x) (-> gp-0 value x)) + (set! (-> self trans z) (-> gp-0 value z)) + ) + (suspend) + ) + ) + #f + ) + ) + +(defbehavior cam-circular-position-into-max-angle camera-slave ((arg0 vector) (arg1 vector) (arg2 float)) + (let* ((f30-0 (vector-normalize-ret-len! arg0 1.0)) + (f26-0 (vector-normalize-ret-len! arg1 1.0)) + (f0-1 (vector-dot arg0 arg1)) + (f28-0 (acos f0-1)) + (s4-0 (new 'stack-no-clear 'matrix)) + ) + (when (not (logtest? (-> *camera* settings master-options) (cam-master-options IGNORE_ANALOG))) + (let ((f24-0 + (analog-input (the-as int (-> *cpad-list* cpads 0 rightx)) 128.0 32.0 110.0 (* 8192.0 (seconds-per-frame))) + ) + (f1-2 + (analog-input (the-as int (-> *cpad-list* cpads 0 righty)) 128.0 32.0 110.0 (* 8192.0 (seconds-per-frame))) + ) + (s2-0 (new 'stack-no-clear 'matrix)) + ) + (set! (-> s2-0 rvec quad) (the-as uint128 0)) + (set! (-> s2-0 uvec quad) (the-as uint128 0)) + (set! (-> s2-0 fvec quad) (the-as uint128 0)) + (set! (-> s2-0 trans quad) (the-as uint128 0)) + (let ((v1-15 (new 'stack-no-clear 'vector))) + 0.0 + (if (-> *camera* settings flip-horizontal) + (set! f24-0 (- f24-0)) + ) + (if (-> *camera* settings flip-vertical) + (set! f1-2 (- f1-2)) + ) + (when (< (-> self max-angle-offset) 1820.4445) + (set! f24-0 0.0) + (set! f1-2 0.0) + ) + (if (< (-> self pivot-rad) f30-0) + (set! f24-0 (- f24-0)) + ) + (vector-cross! v1-15 arg1 arg0) + (let ((f0-10 (vector-dot v1-15 (-> *camera* local-down)))) + (if (< f1-2 0.0) + (set! f1-2 (fmax f1-2 (* -0.15 f28-0))) + ) + (if (< f0-10 0.0) + (set! f1-2 (- f1-2)) + ) + (let* ((f1-3 (+ f24-0 f1-2)) + (f1-5 (fmin (* 8192.0 (seconds-per-frame)) (fmax (* -8192.0 (seconds-per-frame)) f1-3))) + ) + (cond + ((and (< 0.0 f1-5) (< 0.0 f0-10) (< (-> self max-angle-curr) f28-0)) + (set! f1-5 0.0) + ) + ((and (< 0.0 f1-5) (< 0.0 f0-10)) + (set! f1-5 (fmin f1-5 (* 0.15 (- (-> self max-angle-curr) f28-0)))) + ) + ((and (< f1-5 0.0) (< f0-10 0.0) (< (-> self max-angle-curr) f28-0)) + (set! f1-5 0.0) + ) + ((and (< f1-5 0.0) (< f0-10 0.0)) + (set! f1-5 (fmax f1-5 (* 0.15 (- f28-0 (-> self max-angle-curr))))) + ) + ) + (matrix-axis-angle! s2-0 (-> *camera* local-down) f1-5) + ) + ) + ) + (vector-matrix*! arg1 arg1 s2-0) + ) + (let ((f0-16 (vector-dot arg0 arg1))) + (set! f28-0 (acos f0-16)) + ) + ) + (cond + ((< (-> self max-angle-curr) f28-0) + (matrix-from-two-vectors-max-angle! + s4-0 + arg1 + arg0 + (* (fmin 1.0 (* arg2 (-> self clock time-adjust-ratio))) (- f28-0 (-> self max-angle-curr))) + ) + (vector-matrix*! arg0 arg1 s4-0) + ) + ((and (logtest? (-> self options) (cam-slave-options-u32 SAME_SIDE)) + (or (and (>= f26-0 (+ -8192.0 f30-0)) (>= f30-0 (+ -8192.0 (-> self pivot-rad)))) + (and (>= (+ 8192.0 f30-0) f26-0) (>= (+ 8192.0 (-> self pivot-rad)) f30-0)) + ) + ) + (let ((s2-1 (new 'stack-no-clear 'vector))) + (vector-cross! s2-1 arg1 arg0) + (vector-normalize! s2-1 1.0) + (matrix-axis-angle! + s4-0 + s2-1 + (* (fmin 1.0 (* arg2 (-> self clock time-adjust-ratio))) (- (-> self max-angle-curr) f28-0)) + ) + ) + (vector-matrix*! arg0 arg1 s4-0) + ) + (else + (set! (-> arg0 quad) (-> arg1 quad)) + (if (logtest? (-> self options) (cam-slave-options-u32 SHRINK_MAX_ANGLE)) + (set! (-> self max-angle-curr) f28-0) + ) + ) + ) + ) + (vector-normalize! arg0 (-> self pivot-rad)) + ) + +(defbehavior cam-circular-position camera-slave ((arg0 symbol)) + (let ((gp-0 (new 'stack-no-clear 'vector))) + (let ((s5-0 (new 'stack-no-clear 'vector))) + (if (logtest? (-> self options) (cam-slave-options-u32 SAME_SIDE DRAG)) + (vector-! gp-0 (-> self circular-follow) (-> self pivot-pt)) + (vector-! gp-0 (-> self pivot-pt) (-> self circular-follow)) + ) + (vector-! s5-0 (-> self trans) (-> self pivot-pt)) + (when (not (logtest? (-> self options) (cam-slave-options-u32 MOVE_SPHERICAL))) + (vector-flatten! gp-0 gp-0 (-> *camera* local-down)) + (vector-flatten! s5-0 s5-0 (-> *camera* local-down)) + ) + (cond + ((and (logtest? (-> self options) (cam-slave-options-u32 SAME_SIDE)) + (logtest? (-> self options) (cam-slave-options-u32 DRAG)) + (string= (-> *camera* settings real-entity-name) "camera-426") + ) + (let ((a0-8 (vector-normalize-copy! (new 'stack-no-clear 'vector) gp-0 (-> self pivot-rad)))) + (vector+! gp-0 gp-0 a0-8) + ) + ) + ((logtest? (-> self options) (cam-slave-options-u32 DRAG)) + (let ((f30-0 (- (vector-length gp-0) (-> self pivot-rad)))) + (when (< 0.0001 (-> *camera-combiner* tracking point-of-interest-blend value)) + (let ((s5-1 (new 'stack-no-clear 'vector)) + (s3-0 (new 'stack-no-clear 'vector)) + (s4-1 (new 'stack-no-clear 'vector)) + ) + 0.0 + 0.0 + 0.0 + (vector-! s5-1 (-> *camera-combiner* tracking looking-interesting) (-> self pivot-pt)) + (vector-normalize-copy! s3-0 gp-0 1.0) + (let ((f28-0 (vector-dot s5-1 s3-0))) + (vector-float*! s4-1 s3-0 f28-0) + (let ((f0-12 + (/ (* (vector-vector-distance s5-1 s4-1) (cos (-> *camera-combiner* fov))) (sin (-> *camera-combiner* fov))) + ) + ) + (set! f30-0 (fmin f30-0 (if (>= 16384.0 (-> *camera-combiner* fov)) + (- f28-0 f0-12) + (+ f28-0 f0-12) + ) + ) + ) + ) + ) + ) + ) + (if (>= 0.0 f30-0) + (vector-reset! gp-0) + (vector-normalize! gp-0 f30-0) + ) + ) + ) + ((not arg0) + (set! (-> self max-angle-curr) (-> self max-angle-offset)) + (cam-circular-position-into-max-angle gp-0 s5-0 1.0) + ) + (else + (cam-circular-position-into-max-angle gp-0 s5-0 0.05) + ) + ) + ) + (vector+! (-> self trans) gp-0 (-> self pivot-pt)) + ) + ) + +(defbehavior cam-circular-code camera-slave () + (set! (-> self pivot-pt quad) (-> self saved-pt quad)) + (cam-curve-pos (-> self pivot-pt) (the-as vector #f) (the-as curve #f) #f) + (let ((a2-1 (new-stack-vector0)) + (f0-0 182.04445) + ) + (if (logtest? (cam-slave-options RAPID_TRACKING) (-> *camera* settings slave-options)) + (set! f0-0 546.13336) + ) + (vector-! a2-1 (-> *camera* tpos-curr-adj) (-> self pivot-pt)) + (vector-! (-> self circular-follow) (-> self circular-follow) (-> self pivot-pt)) + (if (logtest? (-> self options) (cam-slave-options-u32 MOVE_SPHERICAL)) + (v-slrp3! + (-> self circular-follow) + (-> self circular-follow) + a2-1 + (the-as vector #f) + (* f0-0 (-> self clock time-adjust-ratio)) + ) + (v-slrp3! + (-> self circular-follow) + (-> self circular-follow) + a2-1 + (-> *camera* local-down) + (* f0-0 (-> self clock time-adjust-ratio)) + ) + ) + ) + (vector+! (-> self circular-follow) (-> self circular-follow) (-> self pivot-pt)) + (cam-circular-position #t) + (if (!= (-> self fov1) 0.0) + (set! (-> self fov) + (lerp-clamp + (-> self fov0) + (-> self fov1) + (parameter-ease-sin-clamp (cam-index-method-10 (-> self fov-index) (-> *camera* tpos-curr-adj))) + ) + ) + ) + ) + +(defstate cam-circular (camera-slave) + :event (behavior ((proc process) (argc int) (message symbol) (block event-message-block)) + (case message + (('teleport) + #f + ) + (('outro-done) + (set! (-> self trans quad) (-> *camera-combiner* trans quad)) + (cam-circular-position #f) + ) + (else + (cam-standard-event-handler proc argc message block) + ) + ) + ) + :enter (behavior () + (cond + ((-> self enter-has-run) + ) + (else + (let ((gp-0 (new-stack-vector0))) + (set! (-> (new 'stack-no-clear 'vector) quad) (the-as uint128 0)) + (set! (-> self view-off-param) 1.0) + (set! (-> self circular-follow quad) (-> *camera* tpos-curr-adj quad)) + (set! (-> self max-angle-offset) 0.0) + (cond + ((-> self cam-entity) + (cam-slave-get-vector-with-offset (the-as entity-actor (-> self cam-entity)) (-> self saved-pt) 'pivot) + (cam-slave-get-vector-with-offset (the-as entity-actor (-> self cam-entity)) gp-0 'trans) + (set! (-> self pivot-rad) (vector-length (vector-! gp-0 gp-0 (-> self saved-pt)))) + (logior! (-> self options) (cam-slave-get-flags (-> self cam-entity) 'flags)) + (set! (-> self fov) (cam-slave-get-fov (-> self cam-entity))) + (set! (-> self tracking tilt-adjust target) + (cam-slave-get-float (-> self cam-entity) 'tiltAdjust (-> *CAMERA-bank* default-tilt-adjust)) + ) + (set! (-> self max-angle-offset) (cam-slave-get-float (-> self cam-entity) 'maxAngle 0.0)) + (if (< (-> self max-angle-offset) 0.0) + (set! (-> self max-angle-offset) 0.0) + ) + (set! (-> self fov1) (cam-slave-get-float (-> self cam-entity) 'focalpull 0.0)) + (cond + ((and (!= (-> self fov1) 0.0) + (cam-index-method-9 (-> self fov-index) 'focalpull (-> self cam-entity) (-> self saved-pt) (the-as curve #f)) + ) + (set! (-> self fov0) (-> self fov)) + (set! (-> self fov) (lerp-clamp + (-> self fov0) + (-> self fov1) + (cam-index-method-10 (-> self fov-index) (-> *camera* tpos-curr-adj)) + ) + ) + ) + (else + (set! (-> self fov1) 0.0) + ) + ) + (set! (-> self spline-follow-dist) (cam-slave-get-float (-> self cam-entity) 'spline-follow-dist 0.0)) + (cam-curve-setup (-> self saved-pt)) + (cond + ((< 0.0 (-> self spline-follow-dist)) + (let ((a0-17 (new 'stack-no-clear 'vector)) + (gp-3 (new 'stack-no-clear 'vector)) + ) + (curve-get-pos! a0-17 0.0 (-> self spline-curve)) + (curve-get-pos! gp-3 1.0 (-> self spline-curve)) + ) + (set! (-> self spline-tt) (curve-closest-point + (-> self spline-curve) + (-> self circular-follow) + 0.5 + -4096.0 + 10 + (-> self spline-follow-dist) + ) + ) + (curve-get-pos! (-> self pivot-pt) (-> self spline-tt) (-> self spline-curve)) + ) + (else + (set! (-> self spline-follow-dist) 0.0) + (set! (-> self pivot-pt quad) (-> self saved-pt quad)) + (cam-curve-pos (-> self pivot-pt) (the-as vector #f) (the-as curve #f) #f) + ) + ) + ) + ((logtest? (-> self options) (cam-slave-options-u32 DRAG)) + (vector-! (-> self pivot-pt) (-> *camera* tpos-curr-adj) (-> self trans)) + (vector-flatten! (-> self pivot-pt) (-> self pivot-pt) (-> *camera* local-down)) + (set! (-> self pivot-rad) (vector-length (-> self pivot-pt))) + (set! (-> self pivot-pt quad) (-> self trans quad)) + (set! (-> self saved-pt quad) (-> self pivot-pt quad)) + ) + (else + (vector-! (-> self pivot-pt) (-> *camera* tpos-curr-adj) (-> self trans)) + (vector-float*! (-> self pivot-pt) (-> self pivot-pt) 0.5) + (vector-flatten! (-> self pivot-pt) (-> self pivot-pt) (-> *camera* local-down)) + (set! (-> self pivot-rad) (vector-length (-> self pivot-pt))) + (vector+! (-> self pivot-pt) (-> self trans) (-> self pivot-pt)) + (set! (-> self saved-pt quad) (-> self pivot-pt quad)) + ) + ) + ) + (cam-circular-position #f) + (cond + ((logtest? (-> self options) (cam-slave-options-u32 NO_ROTATE)) + (set! (-> self blend-from-type) (camera-blend-from-type unknown-0)) + (set! (-> self blend-to-type) (camera-blend-to-type unknown-0)) + (cam-slave-get-rot (the-as entity-actor (-> self cam-entity)) (the-as matrix (-> self tracking))) + ) + (else + (set! (-> self blend-from-type) (camera-blend-from-type unknown-2)) + (set! (-> self blend-to-type) (camera-blend-to-type unknown-2)) + ) + ) + ) + ) + ) + :trans (behavior () + (if (not (logtest? (-> *camera* master-options) (cam-master-options-u32 HAVE_TARGET))) + (cam-slave-go cam-free-floating) + ) + ) + :code (behavior () + (until #f + (if (not (paused?)) + (cam-circular-code) + ) + (suspend) + ) + #f + ) + ) + +(defstate cam-lookat (camera-slave) + :event cam-standard-event-handler + :enter (behavior () + (when (not (-> self enter-has-run)) + (set! (-> self blend-from-type) (camera-blend-from-type unknown-2)) + (set! (-> self blend-to-type) (camera-blend-to-type unknown-2)) + ) + ) + :trans (behavior () + (if (not (logtest? (-> *camera* master-options) (cam-master-options-u32 HAVE_TARGET))) + (cam-slave-go cam-free-floating) + ) + ) + :code (behavior () + (until #f + (suspend) + ) + #f + ) + ) + +(deftype cam-string-bank (basic) + ((los-coll-rad meters) + (los-coll-rad2 meters) + ) + ) + + +(define *CAM_STRING-bank* (new 'static 'cam-string-bank :los-coll-rad (meters 1) :los-coll-rad2 (meters 0.5))) + +;; WARN: new jak 2 until loop case, check carefully +(defun cam-string-find-position-rel! ((arg0 vector)) + (let ((s5-0 (new 'stack-no-clear 'vector)) + (s4-0 (new 'stack-no-clear 'vector)) + (s3-0 (new 'stack-no-clear 'collide-query)) + (f30-0 0.0) + (s2-0 (new 'stack-no-clear 'matrix)) + ) + (let ((s1-0 s3-0)) + (set! (-> s1-0 radius) 409.6) + (set! (-> s1-0 collide-with) (collide-spec backgnd obstacle hit-by-others-list camera-blocker pusher)) + (set! (-> s1-0 ignore-process0) #f) + (set! (-> s1-0 ignore-process1) #f) + (set! (-> s1-0 ignore-pat) (the-as pat-surface (camera-master-method-16 *camera* #f))) + (set! (-> s1-0 action-mask) (collide-action solid)) + ) + (vector-flatten! s5-0 (-> *camera-combiner* inv-camera-rot fvec) (-> *camera* local-down)) + (if (= (vector-normalize-ret-len! s5-0 (- (+ 1024.0 (-> *CAMERA-bank* default-string-min-z)))) 0.0) + (set! (-> s5-0 z) (+ 1024.0 (-> *CAMERA-bank* default-string-min-z))) + ) + (vector--float*! s5-0 s5-0 (-> *camera* local-down) (-> *CAMERA-bank* default-string-min-y)) + (set! (-> arg0 quad) (-> s5-0 quad)) + (until #f + (vector--float*! s4-0 arg0 (-> *camera* local-down) (-> *camera* settings target-height)) + (set! (-> s3-0 start-pos quad) (-> *camera* tpos-curr-adj quad)) + (set! (-> s3-0 move-dist quad) (-> arg0 quad)) + (if (< (fill-and-probe-using-line-sphere *collide-cache* s3-0) 0.0) + (return #t) + ) + (set! f30-0 (cond + ((>= -32768.0 f30-0) + (format #t "cam-string didn't find a spot~%") + (set! (-> arg0 quad) (-> s5-0 quad)) + (return #f) + f30-0 + ) + ((< 0.0 f30-0) + (- f30-0) + ) + (else + (- 5461.3335 f30-0) + ) + ) + ) + (matrix-axis-angle! s2-0 (-> *camera* local-down) f30-0) + (vector-matrix*! arg0 s5-0 s2-0) + ) + ) + #f + ) + +;; WARN: Return type mismatch cam-slave-options-u32 vs cam-slave-options. +(defbehavior cam-string-set-position-rel! camera-slave ((arg0 vector)) + (vector-flatten! (-> self view-flat) arg0 (-> *camera* local-down)) + (set! (-> self min-z-override) (vector-length (-> self view-flat))) + (vector+! (-> self desired-pos) arg0 (-> *camera* tpos-curr-adj)) + (set! (-> self string-trans quad) (-> self desired-pos quad)) + (tracking-spline-method-10 (-> self position-spline) (-> self desired-pos)) + (vector-reset! (-> self velocity)) + (let ((v0-2 (logclear (-> self options) (cam-slave-options-u32 GOTO_GOOD_POINT)))) + (set! (-> self options) v0-2) + (the-as cam-slave-options v0-2) + ) + ) + +(defun string-push-help () + 409.6 + ) + +(defun-debug cam-draw-collide-cache ((arg0 collide-cache)) + (let ((gp-0 (-> arg0 tris))) + (countdown (s5-0 (-> arg0 num-tris)) + (let ((t1-0 #x40000080)) + (add-debug-flat-triangle + #t + (bucket-id debug-no-zbuf1) + (the-as vector (-> gp-0 0)) + (-> gp-0 0 vertex 1) + (-> gp-0 0 vertex 2) + (the-as rgba t1-0) + ) + ) + (set! gp-0 (the-as (inline-array collide-cache-tri) (-> gp-0 1))) + ) + ) + 0 + (none) + ) + +(deftype los-dist (structure) + ((par-dist float) + (lat-dist float) + (vert-dist float) + ) + ) + + +(deftype collide-los-dist-info (structure) + ((min-par float) + (max-par float) + (min-lat float) + (max-lat float) + (min-vp float) + (max-vp float) + (min-vn float) + (max-vn float) + (count int32) + ) + ) + + +(defun dist-info-init ((arg0 collide-los-dist-info)) + (set! (-> arg0 min-par) 1.0) + (set! (-> arg0 max-par) 0.0) + (set! (-> arg0 count) 0) + 0 + (none) + ) + +(defun dist-info-valid? ((arg0 collide-los-dist-info)) + (>= (-> arg0 max-par) (-> arg0 min-par)) + ) + +(defun dist-info-append ((arg0 collide-los-dist-info) (arg1 vector)) + (cond + ((dist-info-valid? arg0) + (if (< (-> arg1 x) (-> arg0 min-par)) + (set! (-> arg0 min-par) (-> arg1 x)) + ) + (if (< (-> arg0 max-par) (-> arg1 x)) + (set! (-> arg0 max-par) (-> arg1 x)) + ) + (if (< (-> arg1 y) (-> arg0 min-lat)) + (set! (-> arg0 min-lat) (-> arg1 y)) + ) + (if (< (-> arg0 max-lat) (-> arg1 y)) + (set! (-> arg0 max-lat) (-> arg1 y)) + ) + (cond + ((< (-> arg1 y) 0.0) + (if (< (-> arg1 z) (-> arg0 min-vn)) + (set! (-> arg0 min-vn) (-> arg1 z)) + ) + (if (< (-> arg0 max-vn) (-> arg1 z)) + (set! (-> arg0 max-vn) (-> arg1 z)) + ) + ) + (else + (if (< (-> arg1 z) (-> arg0 min-vp)) + (set! (-> arg0 min-vp) (-> arg1 z)) + ) + (if (< (-> arg0 max-vp) (-> arg1 z)) + (set! (-> arg0 max-vp) (-> arg1 z)) + ) + ) + ) + ) + (else + (set! (-> arg0 min-par) (-> arg1 x)) + (set! (-> arg0 max-par) (-> arg1 x)) + (set! (-> arg0 min-lat) (-> arg1 y)) + (set! (-> arg0 max-lat) (-> arg1 y)) + (set! (-> arg0 min-vp) 0.0) + (set! (-> arg0 max-vp) 0.0) + (set! (-> arg0 min-vn) 0.0) + (set! (-> arg0 max-vn) 0.0) + (cond + ((< (-> arg1 y) 0.0) + (set! (-> arg0 min-vn) (-> arg1 z)) + (set! (-> arg0 max-vn) (-> arg1 z)) + ) + (else + (set! (-> arg0 min-vp) (-> arg1 z)) + (set! (-> arg0 max-vp) (-> arg1 z)) + ) + ) + ) + ) + (+! (-> arg0 count) 1) + (none) + ) + +(defun dist-info-print ((arg0 collide-los-dist-info) (arg1 string)) + (cond + ((dist-info-valid? arg0) + (format + *stdcon* + "~S ~2,D mn ~,,2M mx ~,,2M mnl ~,,2M mxl ~,,2M~%" + arg1 + (-> arg0 count) + (-> arg0 min-par) + (-> arg0 max-par) + (-> arg0 min-lat) + (-> arg0 max-lat) + ) + (format + *stdcon* + " mnvp ~,,2M mxvp ~,,2M mnvn ~,,2M mxvn ~,,2M~%" + (-> arg0 min-vp) + (-> arg0 max-vp) + (-> arg0 min-vn) + (-> arg0 max-vn) + ) + ) + (else + (format *stdcon* "~S invalid~%" arg1) + ) + ) + ) + +(deftype collide-los-result (structure) + ((lateral vector :inline) + (cw collide-los-dist-info :inline) + (ccw collide-los-dist-info :inline) + (straddle collide-los-dist-info :inline) + (lateral-valid symbol) + ) + ) + + +(defbehavior los-cw-ccw camera-slave ((arg0 (inline-array collide-cache-tri)) + (arg1 vector) + (arg2 vector) + (arg3 float) + (arg4 collide-los-result) + (arg5 vector) + (arg6 float) + ) + (local-vars (sv-128 float) (sv-144 vector) (sv-160 vector) (sv-176 vector) (sv-192 vector) (sv-208 int)) + (set! sv-128 arg3) + (let ((gp-0 arg4)) + (set! sv-144 arg5) + (let ((s4-0 arg6)) + (set! sv-160 (new 'stack-no-clear 'vector)) + (set! sv-176 (new 'stack-no-clear 'vector)) + (let ((s5-0 (new 'stack-no-clear 'inline-array 'vector 4))) + (set! sv-192 (new 'stack-no-clear 'vector)) + (let ((f30-0 0.0) + (s0-0 #f) + ) + (set! sv-208 0) + (while (< sv-208 4) + (cond + ((= sv-208 3) + (vector-! sv-160 sv-144 (-> self string-trans)) + (set! (-> s5-0 sv-208 z) 0.0) + ) + (else + (vector-! sv-160 sv-144 (-> arg0 0 vertex sv-208)) + (set! (-> s5-0 sv-208 z) (vector-dot sv-160 (-> *camera* local-down))) + (vector-! sv-160 (-> arg0 0 vertex sv-208) (-> self string-trans)) + ) + ) + (vector-flatten! sv-160 sv-160 (-> *camera* local-down)) + (vector-cross! sv-176 sv-160 arg2) + (let ((f28-0 (vector-dot sv-176 (-> *camera* local-down)))) + (cond + ((< (* f28-0 f30-0) 0.0) + (set! s0-0 #t) + ) + ((!= f28-0 0.0) + (set! f30-0 f28-0) + ) + ) + (set! (-> s5-0 sv-208 x) (vector-dot sv-160 arg2)) + (cond + ((= sv-208 3) + (vector-! sv-192 sv-144 (-> self string-trans)) + (vector-flatten! sv-192 sv-192 arg1) + ) + (else + (vector--float*! sv-192 sv-160 arg2 (-> s5-0 sv-208 x)) + ) + ) + (if (< f28-0 0.0) + (set! (-> s5-0 sv-208 y) (- (vector-length sv-192))) + (set! (-> s5-0 sv-208 y) (vector-length sv-192)) + ) + ) + (set! (-> s5-0 sv-208 x) (- sv-128 (-> s5-0 sv-208 x))) + (set! sv-208 (+ sv-208 1)) + ) + (cond + ((and s0-0 (!= (the-as int s4-0) -859915232)) + (dotimes (s4-1 4) + (dist-info-append (-> gp-0 straddle) (-> s5-0 s4-1)) + ) + #f + ) + ((< (-> s5-0 3 y) 0.0) + (dotimes (s4-2 4) + (when (>= (-> s5-0 3 y) (-> s5-0 s4-2 y)) + (set! (-> s5-0 s4-2 y) (- (-> s5-0 s4-2 y))) + (dist-info-append (-> gp-0 ccw) (-> s5-0 s4-2)) + ) + ) + #f + ) + (else + (dotimes (s4-3 4) + (if (>= (-> s5-0 s4-3 y) (-> s5-0 3 y)) + (dist-info-append (-> gp-0 cw) (-> s5-0 s4-3)) + ) + ) + #f + ) + ) + ) + ) + ) + ) + ) + +(defun cam-los-spline-collide ((arg0 vector) (arg1 vector) (arg2 pat-surface)) + (let ((s5-0 (new 'stack-no-clear 'collide-query)) + (s4-0 *collide-cache*) + (f30-0 2.0) + ) + 0.0 + (set! (-> s5-0 start-pos quad) (-> arg0 quad)) + (vector-! (-> s5-0 move-dist) arg1 arg0) + (let ((v1-4 s5-0)) + (set! (-> v1-4 radius) (-> *CAM_STRING-bank* los-coll-rad2)) + (set! (-> v1-4 collide-with) (collide-spec backgnd obstacle hit-by-others-list camera-blocker pusher)) + (set! (-> v1-4 ignore-process0) #f) + (set! (-> v1-4 ignore-process1) #f) + (set! (-> v1-4 ignore-pat) arg2) + (set! (-> v1-4 action-mask) (collide-action solid)) + ) + (fill-using-line-sphere s4-0 s5-0) + (let* ((f0-2 (vector-length (-> s5-0 move-dist))) + (f28-0 + (cond + ((< f0-2 (-> *CAMERA-bank* min-detectable-velocity)) + 0.0 + ) + (else + (let* ((f0-3 (/ (* 3.0 (- (-> *CAM_STRING-bank* los-coll-rad2) (-> *CAMERA-bank* collide-move-rad))) f0-2)) + (f0-4 (- 1.0 f0-3)) + ) + (fmin 1.0 (fmax 0.0 f0-4)) + ) + ) + ) + ) + (s3-0 (the-as object (-> s4-0 tris))) + (s2-0 (new 'stack-no-clear 'vector)) + (s1-0 (new 'stack-no-clear 'vector)) + ) + (countdown (s4-1 (-> s4-0 num-tris)) + (let ((f0-7 (moving-sphere-triangle-intersect + arg0 + (-> s5-0 move-dist) + (-> *CAM_STRING-bank* los-coll-rad2) + (-> (the-as (inline-array collide-cache-tri) s3-0) 0) + s2-0 + s1-0 + ) + ) + ) + (cond + ((or (< f0-7 0.0) (< f28-0 f0-7)) + ) + ((< f0-7 f30-0) + (set! f30-0 f0-7) + ) + ) + ) + (set! s3-0 (-> (the-as (inline-array collide-cache-tri) s3-0) 1)) + ) + ) + (if (= (the-as int f30-0) #x40000000) + (set! f30-0 -1.0) + ) + f30-0 + ) + ) + +(defbehavior cam-los-setup-lateral camera-slave ((arg0 collide-los-result) (arg1 vector) (arg2 vector)) + (cond + ((dist-info-valid? (-> arg0 straddle)) + (let ((f30-0 (-> arg0 straddle min-lat)) + (f28-0 (-> arg0 straddle max-lat)) + ) + (if (dist-info-valid? (-> arg0 cw)) + (set! f28-0 (fmax f28-0 (-> arg0 cw max-lat))) + ) + (if (dist-info-valid? (-> arg0 ccw)) + (set! f30-0 (fmin f30-0 (- (-> arg0 ccw max-lat)))) + ) + (cond + ((= (-> self los-state) (slave-los-state ccw)) + (if *display-cam-los-debug* + (format *stdcon* "straddle stick ccw~%") + ) + (vector-normalize! arg1 (+ f28-0 (-> *CAM_STRING-bank* los-coll-rad))) + ) + ((= (-> self los-state) (slave-los-state cw)) + (if *display-cam-los-debug* + (format *stdcon* "straddle stick cw~%") + ) + (vector-normalize! arg1 (- f30-0 (-> *CAM_STRING-bank* los-coll-rad))) + ) + ((and (or (< 0.01 (-> arg0 straddle max-vp)) (and (dist-info-valid? (-> arg0 ccw)) (< 0.01 (-> arg0 ccw max-vp)))) + (or (< (-> arg0 straddle min-vp) -0.01) (and (dist-info-valid? (-> arg0 ccw)) (< (-> arg0 ccw min-vp) -0.01))) + (and (dist-info-valid? (-> arg0 cw)) (or (< (-> arg0 cw max-vp) 0.01) (< -0.01 (-> arg0 cw min-vp)))) + ) + (when (not (dist-info-valid? (-> arg0 ccw))) + ) + (if (not (dist-info-valid? (-> arg0 cw))) + (format #t "s diag ccw invalid cw~%") + ) + (if *display-cam-los-debug* + (format *stdcon* "straddle diagonal ccw~%") + ) + (set! (-> self los-state) (slave-los-state ccw)) + (vector-normalize! arg1 (+ f28-0 (-> *CAM_STRING-bank* los-coll-rad))) + ) + ((and (or (< 0.01 (-> arg0 straddle max-vn)) (and (dist-info-valid? (-> arg0 cw)) (< 0.01 (-> arg0 cw max-vp)))) + (or (< (-> arg0 straddle min-vn) -0.01) (and (dist-info-valid? (-> arg0 cw)) (< (-> arg0 cw min-vp) -0.01))) + (and (dist-info-valid? (-> arg0 ccw)) (or (< (-> arg0 ccw max-vp) 0.01) (< -0.01 (-> arg0 ccw min-vp)))) + ) + (if (not (dist-info-valid? (-> arg0 ccw))) + (format #t "s diag cw invalid ccw~%") + ) + (when (not (dist-info-valid? (-> arg0 cw))) + ) + (if *display-cam-los-debug* + (format *stdcon* "straddle diagonal cw~%") + ) + (set! (-> self los-state) (slave-los-state cw)) + (vector-normalize! arg1 (- f30-0 (-> *CAM_STRING-bank* los-coll-rad))) + ) + ((< f28-0 (- f30-0)) + (if *display-cam-los-debug* + (format *stdcon* "straddle ccw~%") + ) + (set! (-> self los-state) (slave-los-state ccw)) + (vector-normalize! arg1 (+ f28-0 (-> *CAM_STRING-bank* los-coll-rad))) + ) + (else + (if *display-cam-los-debug* + (format *stdcon* "straddle cw~%") + ) + (set! (-> self los-state) (slave-los-state cw)) + (vector-normalize! arg1 (- f30-0 (-> *CAM_STRING-bank* los-coll-rad))) + ) + ) + ) + ) + ((and (dist-info-valid? (-> arg0 cw)) + (dist-info-valid? (-> arg0 ccw)) + (< 0.01 (-> arg0 ccw max-vp)) + (< (-> arg0 ccw min-vp) -0.01) + (or (< (-> arg0 cw max-vp) 0.01) (< -0.01 (-> arg0 cw min-vp))) + ) + (if *display-cam-los-debug* + (format *stdcon* "diagonal ccw~%") + ) + (set! (-> self los-state) (slave-los-state ccw)) + (vector-normalize! arg1 (- (-> *CAM_STRING-bank* los-coll-rad) (-> arg0 ccw min-lat))) + ) + ((and (dist-info-valid? (-> arg0 cw)) + (dist-info-valid? (-> arg0 ccw)) + (< 0.01 (-> arg0 cw max-vp)) + (< (-> arg0 cw min-vp) -0.01) + (or (< (-> arg0 ccw max-vp) 0.01) (< -0.01 (-> arg0 ccw min-vp))) + ) + (if *display-cam-los-debug* + (format *stdcon* "diagonal cw~%") + ) + (set! (-> self los-state) (slave-los-state cw)) + (vector-normalize! arg1 (- (-> arg0 cw min-lat) (-> *CAM_STRING-bank* los-coll-rad))) + ) + ((and (dist-info-valid? (-> arg0 cw)) (dist-info-valid? (-> arg0 ccw))) + (set! (-> self los-state) (slave-los-state between)) + (vector-normalize! arg1 0.0001) + ) + ((dist-info-valid? (-> arg0 cw)) + (if *display-cam-los-debug* + (format *stdcon* "regular cw~%") + ) + (set! (-> self los-state) (slave-los-state cw)) + (vector-normalize! arg1 (- (-> arg0 cw min-lat) (-> *CAM_STRING-bank* los-coll-rad))) + ) + ((dist-info-valid? (-> arg0 ccw)) + (if *display-cam-los-debug* + (format *stdcon* "regular ccw~%") + ) + (set! (-> self los-state) (slave-los-state ccw)) + (vector-normalize! arg1 (- (-> *CAM_STRING-bank* los-coll-rad) (-> arg0 ccw min-lat))) + ) + (else + (set! (-> self los-state) (slave-los-state none)) + (vector-reset! arg1) + ) + ) + (cond + ((= (vector-length arg1) 0.0) + (set! (-> arg0 lateral-valid) #f) + #f + ) + (else + (vector-! (-> arg0 lateral) arg1 arg2) + (vector-normalize! (-> arg0 lateral) 1.0) + (let ((v0-44 #t)) + (set! (-> arg0 lateral-valid) v0-44) + v0-44 + ) + ) + ) + ) + +;; WARN: Return type mismatch int vs symbol. +;; ERROR: Unsupported inline assembly instruction kind - [mula.s f2, f5] +;; ERROR: Unsupported inline assembly instruction kind - [madda.s f3, f6] +;; ERROR: Unsupported inline assembly instruction kind - [madd.s f2, f4, f7] +(defbehavior cam-los-collide camera-slave ((arg0 vector) (arg1 vector) (arg2 collide-los-result) (arg3 pat-surface)) + (local-vars + (s1-3 int) + (s2-2 int) + (f2-1 float) + (sv-768 pat-surface) + (sv-784 vector) + (sv-800 vector) + (sv-816 tracking-point) + (sv-832 vector) + ) + (set! sv-768 arg3) + (dist-info-init (-> arg2 cw)) + (dist-info-init (-> arg2 ccw)) + (dist-info-init (-> arg2 straddle)) + (let ((s1-0 (new 'stack-no-clear 'collide-query)) + (s4-0 (new 'stack-no-clear 'vector)) + (s2-0 (new 'stack-no-clear 'vector)) + ) + (vector-normalize-copy! s2-0 arg1 1.0) + (vector-flatten! s4-0 arg1 (-> *camera* local-down)) + (let ((s0-0 *collide-cache*) + (f26-0 (vector-length arg1)) + (f30-0 (vector-normalize-ret-len! s4-0 1.0)) + ) + (set! (-> s1-0 start-pos quad) (-> arg0 quad)) + (set! (-> s1-0 move-dist quad) (-> arg1 quad)) + (let ((v1-5 s1-0)) + (set! (-> v1-5 radius) (-> *CAM_STRING-bank* los-coll-rad)) + (set! (-> v1-5 collide-with) (collide-spec backgnd obstacle hit-by-others-list camera-blocker pusher)) + (set! (-> v1-5 ignore-process0) #f) + (set! (-> v1-5 ignore-process1) #f) + (set! (-> v1-5 ignore-pat) sv-768) + (set! (-> v1-5 action-mask) (collide-action solid)) + ) + (fill-using-line-sphere s0-0 s1-0) + (let ((s1-1 (the-as object (-> s0-0 tris))) + (f28-0 (/ 2048.0 f26-0)) + (f26-1 (/ (+ -8192.0 f26-0) f26-0)) + ) + (if (< f26-1 0.0) + (set! f26-1 0.0) + ) + (if (< 1.0 f28-0) + (set! f28-0 1.0) + ) + (countdown (s0-1 (-> s0-0 num-tris)) + (set! sv-800 (new 'stack-no-clear 'vector)) + (set! sv-784 (new 'stack-no-clear 'vector)) + (let ((f0-7 (moving-sphere-triangle-intersect + arg0 + arg1 + (-> *CAM_STRING-bank* los-coll-rad) + (-> (the-as (inline-array collide-cache-tri) s1-1) 0) + sv-800 + sv-784 + ) + ) + ) + (cond + ((or (< f0-7 0.0) (< 1.0 f0-7)) + ) + ((let ((f1-2 0.0)) + (let* ((v1-23 arg1) + ; (f2-0 (-> v1-23 x)) + ; (f3-0 (-> v1-23 y)) + ; (f4-0 (-> v1-23 z)) + ; (f5-0 (-> sv-784 x)) + ; (f6-0 (-> sv-784 y)) + ; (f7-0 (-> sv-784 z)) + ) + ;; og:preserve-this vector-dot + ; (.mula.s f2-0 f5-0) + ; (.madda.s f3-0 f6-0) + ; (.madd.s f2-1 f4-0 f7-0) + (set! f2-1 (vector-dot v1-23 sv-784)) + ) + (< f1-2 f2-1) + ) + (when (< f28-0 f0-7) + (let* ((t1-1 (new 'stack-no-clear 'vector)) + (t0-1 (new 'stack-no-clear 'vector)) + (f24-0 (moving-sphere-triangle-intersect + arg0 + arg1 + (-> *CAM_STRING-bank* los-coll-rad2) + (-> (the-as (inline-array collide-cache-tri) s1-1) 0) + t0-1 + t1-1 + ) + ) + ) + (los-cw-ccw (the-as (inline-array collide-cache-tri) s1-1) s2-0 s4-0 f30-0 arg2 sv-800 f24-0) + (when *debug-segment* + (cond + ((= (the-as int f24-0) -859915232) + (let ((t9-10 cam-debug-add-los-tri) + (a0-20 s1-1) + (a2-6 (new 'static 'vector :x (the-as float #x80) :w (the-as float #x80))) + ) + (t9-10 (the-as (inline-array collide-cache-tri) a0-20) sv-800 a2-6) + ) + ) + (else + (cam-debug-add-los-tri + (the-as (inline-array collide-cache-tri) s1-1) + sv-800 + (new 'static 'vector :x (the-as float #x80) :y (the-as float #x80) :w (the-as float #x80)) + ) + ) + ) + ) + ) + ) + ) + ((< f0-7 f26-1) + (let* ((t1-3 (new 'stack-no-clear 'vector)) + (t0-3 (new 'stack-no-clear 'vector)) + (f24-1 (moving-sphere-triangle-intersect + arg0 + arg1 + (-> *CAM_STRING-bank* los-coll-rad2) + (-> (the-as (inline-array collide-cache-tri) s1-1) 0) + t0-3 + t1-3 + ) + ) + ) + (los-cw-ccw (the-as (inline-array collide-cache-tri) s1-1) s2-0 s4-0 f30-0 arg2 sv-800 f24-1) + (when *debug-segment* + (if (= (the-as int f24-1) -859915232) + (cam-debug-add-los-tri + (the-as (inline-array collide-cache-tri) s1-1) + sv-800 + (new 'static 'vector :y (the-as float #x80) :w (the-as float #x80)) + ) + (cam-debug-add-los-tri + (the-as (inline-array collide-cache-tri) s1-1) + sv-800 + (new 'static 'vector :z (the-as float #x80) :w (the-as float #x80)) + ) + ) + ) + ) + ) + ) + ) + (set! s1-1 (-> (the-as (inline-array collide-cache-tri) s1-1) 1)) + ) + ) + ) + ) + (let ((s4-1 (new 'stack-no-clear 'vector))) + 0.0 + (vector-cross! s4-1 arg1 (-> *camera* local-down)) + (cond + ((!= (-> self los-tgt-spline-pt-incarnation) + (-> *camera* target-spline point (-> self los-tgt-spline-pt) incarnation) + ) + (when *display-cam-los-debug* + (format *stdcon* "emergency point jump~%") + (format 0 "emergency point jump~%") + ) + (set! (-> self los-tgt-spline-pt) (-> *camera* target-spline used-point)) + (set! (-> self los-tgt-spline-pt-incarnation) + (-> *camera* target-spline point (-> self los-tgt-spline-pt) incarnation) + ) + (logior! (-> self options) (cam-slave-options-u32 GOTO_GOOD_POINT)) + (set! (-> self good-point quad) + (-> *camera* target-spline point (-> *camera* target-spline used-point) position quad) + ) + (set! (-> self los-last-pos quad) (-> self good-point quad)) + (when *debug-segment* + (let ((a1-22 (new 'stack-no-clear 'vector))) + (vector-! a1-22 (-> self good-point) (-> self string-trans)) + (cam-collision-record-save (-> self string-trans) a1-22 -3 'jump self) + ) + ) + (set! (-> self desired-pos quad) (-> self good-point quad)) + (set! (-> self string-trans quad) (-> self good-point quad)) + (vector-! (-> self view-flat) (-> self string-trans) (-> *camera* tpos-curr-adj)) + (vector-flatten! (-> self view-flat) (-> self view-flat) (-> *camera* local-down)) + (vector-reset! (-> self velocity)) + (let ((f0-11 (vector-length (-> self view-flat)))) + (if (< f0-11 (-> self min-z-override)) + (set! (-> self min-z-override) f0-11) + ) + ) + ) + (else + (let ((f30-1 + (cam-los-spline-collide + (the-as vector (+ (the-as uint (-> *camera* target-spline)) (* 48 (-> *camera* target-spline end-point)))) + arg0 + (the-as pat-surface (camera-master-method-16 *camera* #t)) + ) + ) + ) + (cond + ((< f30-1 0.0) + (if *display-cam-los-debug* + (format *stdcon* "good ~f~%" f30-1) + ) + (set! (-> self los-tgt-spline-pt) (-> *camera* target-spline end-point)) + (set! (-> self los-tgt-spline-pt-incarnation) + (-> *camera* target-spline point (-> self los-tgt-spline-pt) incarnation) + ) + (set! (-> self los-last-pos quad) (-> arg0 quad)) + ) + ((begin + (if *display-cam-los-debug* + (format + *stdcon* + "looking vel ~M u ~f pt ~D" + (vector-length (-> self velocity)) + f30-1 + (-> self los-tgt-spline-pt) + ) + ) + (set! s2-2 (-> self los-tgt-spline-pt)) + (set! s1-3 -134250495) + (while (and (!= s2-2 -134250495) + (begin + (let ((s0-3 cam-los-spline-collide)) + (set! sv-816 (-> (the-as (inline-array tracking-spline) (-> *camera* target-spline)) 0 point s2-2)) + (set! sv-832 arg0) + (let ((a2-21 (camera-master-method-16 *camera* #t))) + (set! f30-1 (s0-3 (the-as vector sv-816) sv-832 (the-as pat-surface a2-21))) + ) + ) + (< f30-1 0.0) + ) + ) + (set! s1-3 s2-2) + (set! s2-2 (-> *camera* target-spline point s2-2 next)) + ) + (and (= s2-2 (-> *camera* target-spline used-point)) + (!= (-> *camera* target-spline point s2-2 next) -134250495) + ) + ) + (when *display-cam-los-debug* + (format 0 "looking at used point~%") + (format *stdcon* " at used point~%") + ) + (set! (-> self los-tgt-spline-pt) (-> *camera* target-spline point s2-2 next)) + (set! (-> self los-tgt-spline-pt-incarnation) + (-> *camera* target-spline point (-> self los-tgt-spline-pt) incarnation) + ) + (logior! (-> self options) (cam-slave-options-u32 GOTO_GOOD_POINT)) + (set! (-> self good-point quad) (-> *camera* target-spline point s2-2 position quad)) + (set! (-> self los-last-pos quad) (-> self good-point quad)) + (when *debug-segment* + (let ((a1-40 (new 'stack-no-clear 'vector))) + (vector-! a1-40 (-> self good-point) (-> self string-trans)) + (cam-collision-record-save (-> self string-trans) a1-40 -3 'jump self) + ) + ) + (set! (-> self desired-pos quad) (-> self good-point quad)) + (set! (-> self string-trans quad) (-> self good-point quad)) + (vector-! (-> self view-flat) (-> self string-trans) (-> *camera* tpos-curr-adj)) + (vector-flatten! (-> self view-flat) (-> self view-flat) (-> *camera* local-down)) + (vector-reset! (-> self velocity)) + (let ((f0-14 (vector-length (-> self view-flat)))) + (if (< f0-14 (-> self min-z-override)) + (set! (-> self min-z-override) f0-14) + ) + ) + ) + ((!= s1-3 -134250495) + (if *display-cam-los-debug* + (format *stdcon* " ok~%") + ) + (set! (-> self los-tgt-spline-pt) s1-3) + (set! (-> self los-tgt-spline-pt-incarnation) + (-> *camera* target-spline point (-> self los-tgt-spline-pt) incarnation) + ) + (set! (-> self los-last-pos quad) (-> arg0 quad)) + ) + (else + (if *display-cam-los-debug* + (format *stdcon* "~%failed u ~f cur ~D seen ~D tgt-pt ~D~%" f30-1 s2-2 s1-3 (-> self los-tgt-spline-pt)) + ) + (let ((s3-1 (new 'stack-no-clear 'vector))) + 0.0 + (vector-! + s3-1 + (-> self los-last-pos) + (the-as vector (+ (the-as uint (-> *camera* target-spline)) (* 48 (-> self los-tgt-spline-pt)))) + ) + (let ((f28-1 (vector-length s3-1))) + (if (= f28-1 0.0) + (set! f28-1 0.4096) + ) + (let ((f30-2 (cond + ((and (= (-> self string-vel-dir) 6) + (< (-> *CAMERA-bank* min-detectable-velocity) (vector-length (-> self velocity))) + ) + (fmin 1.0 (+ 0.001 f30-1)) + ) + ((= (-> self string-vel-dir) 6) + (fmin 0.9999 f30-1) + ) + (else + (fmax 0.001 (+ -0.001 f30-1)) + ) + ) + ) + ) + (let ((s2-3 (new 'stack-no-clear 'vector))) + (vector-! + s2-3 + (-> *camera* tpos-curr-adj) + (the-as vector (+ (the-as uint (-> *camera* target-spline)) (* 48 (-> self los-tgt-spline-pt)))) + ) + (vector-flatten! s2-3 s2-3 (-> *camera* local-down)) + (cond + ((and (< (fabs (- (-> self desired-pos y) (-> self trans y))) 8192.0) + (< f28-1 (+ 1024.0 (-> self string-min-val z))) + (< (vector-length s2-3) 8192.0) + ) + (set! f30-2 0.0) + ) + ((< f28-1 (+ 1024.0 (-> self string-min-val z))) + ) + ((< (* f28-1 f30-2) (-> self string-min-val z)) + (set! f30-2 (/ (-> self string-min-val z) f28-1)) + ) + ) + ) + (when (< 0.0 f30-2) + (vector-! s3-1 (-> *camera* tpos-curr) (-> *camera* tpos-old)) + (vector-! + (-> self good-point) + (-> self los-last-pos) + (the-as vector (+ (the-as uint (-> *camera* target-spline)) (* 48 (-> self los-tgt-spline-pt)))) + ) + (vector-float*! (-> self good-point) (-> self good-point) f30-2) + (vector+! + (-> self good-point) + (-> self good-point) + (the-as vector (+ (the-as uint (-> *camera* target-spline)) (* 48 (-> self los-tgt-spline-pt)))) + ) + (set! (-> self los-last-pos quad) (-> self good-point quad)) + (when *display-cam-los-debug* + (format 0 "going because u(~f) > 0 frame ~D~%" f30-2 (current-time)) + (format *stdcon* " going because u(~f) > 0 frame ~D~%" f30-2 (current-time)) + ) + (logior! (-> self options) (cam-slave-options-u32 GOTO_GOOD_POINT)) + ) + ) + ) + ) + ) + ) + ) + ) + ) + (if *display-cam-los-debug* + (format + *stdcon* + "los-last ~M ~M ~M~%" + (-> self los-last-pos x) + (-> self los-last-pos y) + (-> self los-last-pos z) + ) + ) + (cam-los-setup-lateral arg2 s4-1 arg1) + ) + (cond + ((not (logtest? (-> self options) (cam-slave-options-u32 MOVEMENT_BLOCKED))) + ) + ((= (-> self string-vel-dir) 5) + ) + ((and (= (-> self string-vel-dir) 2) (= (-> self los-state) (slave-los-state cw))) + ) + ((and (= (-> self string-vel-dir) 1) (= (-> self los-state) (slave-los-state ccw))) + ) + ) + (when *display-cam-los-debug* + (format *stdcon* "state ~S" (slave-los-state->string (-> self los-state))) + (cond + ((zero? (-> self string-vel-dir)) + (format *stdcon* " vzero") + ) + ((= (-> self string-vel-dir) 2) + (format *stdcon* " vcw") + ) + ((= (-> self string-vel-dir) 1) + (format *stdcon* " vccw") + ) + ((= (-> self string-vel-dir) 3) + (format *stdcon* " up") + ) + ((= (-> self string-vel-dir) 4) + (format *stdcon* " down") + ) + ((= (-> self string-vel-dir) 6) + (format *stdcon* " long") + ) + ((= (-> self string-vel-dir) 5) + (format *stdcon* " short") + ) + ) + (format *stdcon* "~%") + ) + (when *display-cam-los-info* + (dist-info-print (-> arg2 cw) "cw ") + (dist-info-print (-> arg2 ccw) "ccw ") + (dist-info-print (-> arg2 straddle) "strdl") + ) + (the-as symbol 0) + ) + +(defbehavior cam-string-follow camera-slave () + (let ((f30-0 (vector-length (-> self view-flat)))) + (cond + ((logtest? (-> self options) (cam-slave-options-u32 STICKY_ANGLE)) + (let ((gp-0 (new 'stack-no-clear 'vector))) + (let ((s5-0 (new 'stack-no-clear 'vector))) + (vector-cross! s5-0 (-> self view-flat) (-> *camera* local-down)) + (vector-normalize! s5-0 1.0) + (vector-! gp-0 (-> *camera* tpos-curr-adj) (-> *camera* tpos-old-adj)) + (vector-flatten! gp-0 gp-0 s5-0) + ) + (if (< (vector-dot gp-0 (-> self view-flat)) 0.0) + (vector-! (-> self view-flat) (-> self view-flat) gp-0) + ) + ) + ) + (else + (let ((v1-10 (new 'stack-no-clear 'vector))) + (vector-! v1-10 (-> *camera* tpos-curr-adj) (-> *camera* tpos-old-adj)) + (vector-! (-> self view-flat) (-> self view-flat) v1-10) + ) + ) + ) + (vector-flatten! (-> self view-flat) (-> self view-flat) (-> *camera* local-down)) + (let* ((f28-0 (vector-length (-> self view-flat))) + (f0-3 (fmin (-> *camera* string-push-z) (-> self view-off z))) + (f26-0 (-> self view-off z)) + (f0-4 (fmin f0-3 (-> self min-z-override))) + ) + (when (logtest? (cam-slave-options WIDE_FOV) (-> *camera* settings slave-options)) + (let ((v1-18 (new-stack-vector0))) + 0.0 + (vector-! v1-18 (-> *camera* tpos-curr-adj) (-> *camera* tpos-old-adj)) + (let ((f0-6 (vector-length v1-18))) + (set! f0-4 (lerp-clamp 28672.0 32768.0 (parameter-ease-sin-clamp (* 0.00081380206 (+ -409.6 f0-6))))) + ) + ) + (set! f26-0 f0-4) + ) + (set! (-> self fov) (-> *camera* settings fov)) + (cond + ((< f28-0 f0-4) + (vector-normalize! (-> self view-flat) f0-4) + ) + ((and (< f30-0 f28-0) + (or (= (-> self los-state) (slave-los-state ccw)) (= (-> self los-state) (slave-los-state cw))) + ) + (vector-normalize! (-> self view-flat) f30-0) + ) + ((< f26-0 f28-0) + (vector-normalize! (-> self view-flat) f26-0) + (set! (-> self min-z-override) f26-0) + f26-0 + ) + (else + (set! (-> self min-z-override) f28-0) + f28-0 + ) + ) + ) + ) + ) + +(defbehavior cam-string-line-of-sight camera-slave () + (let ((gp-0 (new 'stack-no-clear 'collide-los-result)) + (s5-0 (new 'stack-no-clear 'vector)) + ) + (new 'stack-no-clear 'vector) + (let ((f30-0 (vector-length (-> self view-flat)))) + (vector--float*! s5-0 (-> *camera* tpos-curr) (-> *camera* local-down) (-> *camera* settings target-height)) + (vector-! s5-0 s5-0 (-> self string-trans)) + (let ((f0-1 (vector-length s5-0))) + (if (< 2048.0 f0-1) + (vector-float*! s5-0 s5-0 (/ (+ -2048.0 f0-1) f0-1)) + (vector-reset! s5-0) + ) + ) + (cam-los-collide (-> self string-trans) s5-0 gp-0 (the-as pat-surface (camera-master-method-16 *camera* #t))) + (when (-> gp-0 lateral-valid) + (when (or (= (-> self los-state) (slave-los-state ccw)) (= (-> self los-state) (slave-los-state cw))) + (let ((v1-21 (new 'stack-no-clear 'vector))) + (vector-! v1-21 (-> *camera* tpos-curr) (-> *camera* tpos-old)) + (if (and (< (-> self string-min-val z) f30-0) + (< (-> *CAMERA-bank* min-detectable-velocity) (vector-length v1-21)) + ) + (set! f30-0 (+ -204.8 f30-0)) + ) + ) + ) + (if (< f30-0 (fmin (-> self string-min-val z) (-> self min-z-override))) + (set! f30-0 (fmin (-> self string-min-val z) (-> self min-z-override))) + ) + (if (< f30-0 (-> self min-z-override)) + (set! (-> self min-z-override) f30-0) + ) + (let ((s4-1 (new 'stack-no-clear 'vector)) + (s5-1 (new 'stack-no-clear 'vector)) + (s3-1 (new 'stack-no-clear 'matrix)) + ) + 0.0 + (vector-flatten! s4-1 (-> gp-0 lateral) (-> *camera* local-down)) + (vector-normalize! s4-1 1.0) + (vector-normalize-copy! s5-1 (-> self view-flat) 1.0) + (let ((f0-14 (lerp-clamp + 418.7022 + 364.0889 + (/ (- f30-0 (-> self string-min-val z)) (- (-> self string-max-val z) (-> self string-min-val z))) + ) + ) + ) + (matrix-from-two-vectors-max-angle-partial! s3-1 s5-1 s4-1 f0-14 0.5) + ) + (vector-matrix*! (-> self view-flat) (-> self view-flat) s3-1) + ) + (vector-normalize! (-> self view-flat) f30-0) + ) + ) + ) + ) + +(defun cam-dist-analog-input ((arg0 int) (arg1 float)) + (let ((f0-0 (the-as number 0.0))) + (cond + ((< arg0 28) + (set! f0-0 (- (fmin arg1 (* 0.083333336 (- 28.0 (the float arg0)) arg1)))) + ) + ((< 160 arg0) + (set! f0-0 (fmin arg1 (* 0.0125 (+ -160.0 (the float arg0)) arg1))) + ) + ) + (the-as float f0-0) + ) + ) + +(defbehavior cam-string-joystick camera-slave () + (logclear! (-> self options) (cam-slave-options-u32 PLAYER_MOVING_CAMERA)) + (when (-> self string-relative) + (let ((s5-0 (new 'stack-no-clear 'vector)) + (gp-0 (new 'stack-no-clear 'vector)) + ) + 0.0 + (let ((f30-0 0.5)) + (new 'stack-no-clear 'vector) + (vector-flatten! s5-0 (-> self relative-position) (-> *camera* local-down)) + (let ((f0-4 + (acos (/ (vector-dot s5-0 (-> self view-flat)) (* (vector-length s5-0) (vector-length (-> self view-flat))))) + ) + ) + (if (< 1456.3556 (* f30-0 f0-4)) + (set! f30-0 (/ 1456.3556 f0-4)) + ) + ) + (vector-deg-slerp (-> self view-flat) (-> self view-flat) s5-0 f30-0) + (set! (-> gp-0 y) (- (vector-dot (-> self relative-position) (-> *camera* local-down)))) + (set! (-> gp-0 z) (vector-length s5-0)) + (set! (-> self view-off y) (lerp (-> self view-off y) (-> gp-0 y) f30-0)) + (set! (-> self view-off z) (lerp (-> self view-off z) (-> gp-0 z) f30-0)) + ) + ) + (vector-normalize! (-> self view-flat) (-> self view-off z)) + (set! (-> self string-min-val y) (-> self view-off y)) + (set! (-> self string-min-val z) (-> self view-off z)) + (set! (-> self string-max-val y) (-> self view-off y)) + (set! (-> self string-max-val z) (-> self view-off z)) + (return (the-as float #f)) + ) + (let ((f28-0 (cam-dist-analog-input (the-as int (-> *cpad-list* cpads 0 righty)) 0.05)) + (f0-22 (/ (- (vector-length (-> self view-flat)) (-> self string-min-val z)) + (- (-> self string-max-val z) (-> self string-min-val z)) + ) + ) + (f30-1 (-> self view-off-param)) + ) + (if (logtest? (cam-slave-options BOMBBOT) (-> *camera* settings slave-options)) + (set! f28-0 0.0) + ) + (if (or (logtest? (cam-slave-options-u32 BLOCK_RIGHT_STICK) (-> self options)) + (logtest? (-> *camera* settings master-options) (cam-master-options BLOCK_RIGHT_STICK)) + ) + (set! f28-0 0.0) + ) + (if (-> self have-phony-joystick) + (set! f28-0 (* 0.05 (-> self phony-joystick-y))) + ) + (if (and (-> *camera* being-attacked) (not (time-elapsed? (-> *camera* attack-start) (seconds 0.25)))) + (set! f28-0 0.05) + ) + (when (logtest? (cam-slave-options-u32 GUN_CAM) (-> self options)) + (if (and (or (< (-> *cpad-list* cpads 0 rightx) (the-as uint 64)) + (< (the-as uint 192) (-> *cpad-list* cpads 0 rightx)) + ) + (let ((v1-62 (abs (the-as int (+ (-> *cpad-list* cpads 0 righty) -128))))) + (< (the-as uint v1-62) (the-as uint 64)) + ) + ) + (set! f28-0 0.0) + ) + ) + (if (!= f28-0 0.0) + (logior! (-> self options) (cam-slave-options-u32 PLAYER_MOVING_CAMERA)) + ) + (let ((f26-0 (fmin 1.0 f0-22))) + (let ((f0-23 f26-0)) + (when (and (< f26-0 0.0) (not (logtest? (cam-slave-options BOMBBOT) (-> *camera* settings slave-options)))) + (let ((f0-26 + (/ (- (-> self string-min-val z) (vector-length (-> self view-flat))) (* 0.5 (-> self string-min-val z))) + ) + ) + (set! f0-23 (fmin 0.75 f0-26)) + ) + ) + (let ((f1-15 (-> self string-min-val y)) + (f2-5 (-> self string-max-val y)) + ) + (set! (-> self view-off y) (lerp f1-15 f2-5 f0-23)) + ) + ) + (when (< f26-0 0.0) + (let ((v1-80 (new 'stack-no-clear 'vector))) + (vector-! v1-80 (-> self string-trans) (-> *camera* tpos-curr-adj)) + (let ((f0-32 (- (- (vector-dot v1-80 (-> *camera* local-down))) (-> *camera* settings target-height)))) + (set! (-> self view-off y) + (fmin (-> *camera* settings string-cliff-height) (fmax f0-32 (-> self view-off y))) + ) + ) + ) + ) + (let ((f0-36 (fmax 0.0 f26-0))) + (cond + ((logtest? (-> *camera* settings slave-options) (cam-slave-options BIKE_MODE)) + ) + ((logtest? (-> *camera* settings master-options) (cam-master-options IGNORE_ANALOG)) + ) + ((and (>= 0.0 f28-0) (>= 0.0 f0-36)) + ) + ((and (>= f28-0 0.0) (>= f0-36 1.0)) + ) + ((and (< 0.0 f28-0) + (or (= (-> self los-state) (slave-los-state ccw)) (= (-> self los-state) (slave-los-state cw))) + ) + ) + ((and (logtest? (cam-slave-options-u32 GUN_CAM) (-> self options)) (< 0.0 f28-0)) + (set! (-> self string-min-val y) + (fmax (-> *camera* settings gun-min-height) (- (-> self string-min-val y) (* 24576.0 f28-0))) + ) + (set! (-> self string-max-val y) + (fmin + (+ 16384.0 (-> self string-min-val y)) + (fmax (+ 8192.0 (-> self string-min-val y)) (- (-> self string-max-val y) (* 24576.0 f28-0))) + ) + ) + ) + ((and (logtest? (cam-slave-options-u32 GUN_CAM) (-> self options)) (< f28-0 0.0)) + (set! (-> self string-max-val y) + (fmin (-> *camera* settings gun-max-height) (- (-> self string-max-val y) (* 24576.0 f28-0))) + ) + (set! (-> self string-min-val y) + (fmin + (+ -8192.0 (-> self string-max-val y)) + (fmax (+ -16384.0 (-> self string-max-val y)) (- (-> self string-min-val y) (* 24576.0 f28-0))) + ) + ) + ) + ((logtest? (cam-slave-options-u32 GUN_CAM) (-> self options)) + (set! (-> self string-max-val y) + (fmax + (+ 8192.0 (-> *camera* settings gun-min-height)) + (fmin (-> *camera* settings gun-max-height) (-> self string-max-val y)) + ) + ) + (set! (-> self string-min-val y) + (fmax + (-> *camera* settings gun-min-height) + (fmin (+ -8192.0 (-> *camera* settings gun-max-height)) (-> self string-min-val y)) + ) + ) + (set! (-> self string-min-val y) (fmax (+ -16384.0 (-> self string-max-val y)) (-> self string-min-val y))) + ) + ((< (* 0.05 (- 1.0 f0-36)) f28-0) + (let ((f0-55 (+ f0-36 (* 0.05 (- 1.0 f0-36))))) + (set! (-> self view-off-param) (fmax (-> self view-off-param) f0-55)) + (vector-normalize! (-> self view-flat) (lerp (-> self string-min-val z) (-> self string-max-val z) f0-55)) + ) + ) + ((< f28-0 (* 0.05 (- f0-36))) + (set! (-> self view-off-param) (+ f0-36 (* 0.05 (- f0-36)))) + ) + ((< 0.0 f28-0) + (let ((f0-57 (+ f0-36 (* f28-0 (-> self clock time-adjust-ratio))))) + (set! (-> self view-off-param) (fmax (-> self view-off-param) f0-57)) + (vector-normalize! (-> self view-flat) (lerp (-> self string-min-val z) (-> self string-max-val z) f0-57)) + ) + ) + ((< f28-0 0.0) + (set! (-> self view-off-param) (+ f0-36 (* f28-0 (-> self clock time-adjust-ratio)))) + ) + ) + ) + ) + (cond + ((logtest? (cam-slave-options-u32 GUN_CAM) (-> self options)) + ) + ((= f28-0 0.0) + (set! (-> self view-off z) (-> self string-max-val z)) + ) + (else + (set! (-> self view-off z) + (lerp (-> self string-min-val z) (-> self string-max-val z) (-> self view-off-param)) + ) + ) + ) + (if (-> *camera* being-attacked) + (set! (-> self view-off-param) f30-1) + ) + ) + (when (not (logtest? (-> *camera* settings master-options) (cam-master-options IGNORE_ANALOG))) + (let ((f30-2 (analog-input + (the-as int (-> *cpad-list* cpads 0 rightx)) + 128.0 + 32.0 + 110.0 + (* 182.04445 + (seconds-per-frame) + (cond + ((logtest? (cam-slave-options-u32 GUN_CAM) (-> self options)) + 120.0 + ) + ((logtest? (cam-slave-options BOMBBOT) (-> *camera* settings slave-options)) + 120.0 + ) + (else + 120.0 + ) + ) + ) + ) + ) + (s4-0 (new 'stack-no-clear 'matrix)) + ) + (set! (-> s4-0 rvec quad) (the-as uint128 0)) + (set! (-> s4-0 uvec quad) (the-as uint128 0)) + (set! (-> s4-0 fvec quad) (the-as uint128 0)) + (set! (-> s4-0 trans quad) (the-as uint128 0)) + (let ((gp-3 (new-stack-vector0)) + (s5-3 (new-stack-vector0)) + ) + (if (-> *camera* settings flip-horizontal) + (set! f30-2 (- f30-2)) + ) + (if (or (logtest? (cam-slave-options-u32 BLOCK_RIGHT_STICK) (-> self options)) + (logtest? (-> *camera* settings master-options) (cam-master-options BLOCK_RIGHT_STICK)) + ) + (set! f30-2 0.0) + ) + (if (-> *setting-control* user-default camera-stick-dir) + (set! f30-2 (- f30-2)) + ) + (if (-> self have-phony-joystick) + (set! f30-2 (* 21845.334 (-> self phony-joystick-x) (seconds-per-frame))) + ) + (when (or (logtest? (cam-slave-options-u32 ALLOW_SHIFT_BUTTONS) (-> self options)) + (logtest? (-> *camera* settings master-options) (cam-master-options USE_L1_R1)) + ) + (when (logtest? (-> *camera* settings master-options) (cam-master-options READ_BUTTONS)) + (if (cpad-hold? (-> *CAMERA-bank* joypad) r1) + (+! f30-2 (+ (* 10922.667 (seconds-per-frame)) + (analog-input + (the-as int (-> *cpad-list* cpads (-> *CAMERA-bank* joypad) abutton 9)) + 0.0 + 32.0 + 230.0 + (* 21845.334 (seconds-per-frame)) + ) + ) + ) + ) + ) + (when (logtest? (-> *camera* settings master-options) (cam-master-options READ_BUTTONS)) + (if (cpad-hold? (-> *CAMERA-bank* joypad) l1) + (set! f30-2 (- f30-2 (+ (* 10922.667 (seconds-per-frame)) + (analog-input + (the-as int (-> *cpad-list* cpads (-> *CAMERA-bank* joypad) abutton 8)) + 0.0 + 32.0 + 230.0 + (* 21845.334 (seconds-per-frame)) + ) + ) + ) + ) + ) + ) + ) + (cond + ((and (= (-> self los-state) (slave-los-state ccw)) (< 0.0 f30-2)) + (let ((f0-82 + (fmax (-> self string-min-val z) (fmin (-> self string-max-val z) (vector-length (-> self view-flat)))) + ) + ) + (set! f30-2 (* 21845.334 (+ 0.1 (/ (-> self string-min-val z) f0-82)) (seconds-per-frame))) + ) + ) + ((and (= (-> self los-state) (slave-los-state cw)) (< f30-2 0.0)) + (let ((f0-88 + (fmax (-> self string-min-val z) (fmin (-> self string-max-val z) (vector-length (-> self view-flat)))) + ) + ) + (set! f30-2 (* -21845.334 (+ 0.1 (/ (-> self string-min-val z) f0-88)) (seconds-per-frame))) + ) + ) + ) + (cond + ((!= f30-2 0.0) + (logior! (-> self options) (cam-slave-options-u32 PLAYER_MOVING_CAMERA)) + (matrix-axis-angle! s4-0 (-> *camera* local-down) f30-2) + (vector-matrix*! (-> self view-flat) (-> self view-flat) s4-0) + (set! (-> self butt-timer) 0) + (set! (-> self butt-seek) #f) + (when (logtest? (cam-slave-options-u32 HAVE_BUTT_HANDLE) (-> self options)) + (kill-persister *setting-control* (the-as engine-pers 'butt-handle) 'butt-handle) + (logclear! (-> self options) (cam-slave-options-u32 HAVE_BUTT_HANDLE)) + ) + ) + ((or (logtest? (-> self options) (cam-slave-options-u32 BUTT_CAM)) + (let ((s3-0 (handle->process (-> *camera* settings butt-handle)))) + (if (type? s3-0 process-drawable) + s3-0 + ) + ) + ) + (vector-normalize-copy! gp-3 (-> self view-flat) 1.0) + (let ((v1-303 (handle->process (-> *camera* settings butt-handle)))) + (cond + (v1-303 + (logior! (-> self options) (cam-slave-options-u32 HAVE_BUTT_HANDLE)) + (let* ((s3-1 (quaternion->matrix (new 'stack-no-clear 'matrix) (-> (the-as process-drawable v1-303) root quat))) + (a2-18 (matrix-axis-angle! + (new 'stack-no-clear 'matrix) + (-> s3-1 uvec) + (+ 32768.0 (-> *camera* settings butt-angle)) + ) + ) + ) + (vector-matrix*! s5-3 (-> s3-1 fvec) a2-18) + ) + (vector-flatten! s5-3 s5-3 (-> *camera* local-down)) + ) + ((< (- (current-time) (-> self butt-timer)) 0) + (vector-flatten! s5-3 (-> self butt-vector) (-> *camera* local-down)) + ) + (else + (vector-flatten! s5-3 (-> *camera* tgt-rot-mat fvec) (-> *camera* local-down)) + ) + ) + ) + (vector-normalize! s5-3 -1.0) + (when (and (logtest? (cam-slave-options-u32 HAVE_BUTT_HANDLE) (-> self options)) + (< (cos 910.2222) (vector-dot gp-3 s5-3)) + ) + (kill-persister *setting-control* (the-as engine-pers 'butt-handle) 'butt-handle) + (logclear! (-> self options) (cam-slave-options-u32 HAVE_BUTT_HANDLE)) + ) + (matrix-from-two-vectors-max-angle! s4-0 gp-3 s5-3 546.13336) + (vector-matrix*! (-> self view-flat) (-> self view-flat) s4-0) + ) + (else + (logclear! (-> self options) (cam-slave-options-u32 HAVE_BUTT_HANDLE)) + ) + ) + (when (logtest? (-> *camera* settings slave-options) (cam-slave-options BIKE_MODE)) + (vector-normalize-copy! gp-3 (-> self view-flat) 1.0) + (vector-flatten! s5-3 (-> *camera* tgt-rot-mat fvec) (-> *camera* local-down)) + (vector-normalize! s5-3 -1.0) + (let ((f0-97 (acos (vector-dot s5-3 gp-3)))) + (when (and (< (-> self max-angle-offset) f0-97) (< f0-97 32585.955)) + (matrix-from-two-vectors-max-angle! + s4-0 + gp-3 + s5-3 + (fmin 546.13336 (* 0.5 (- f0-97 (-> self max-angle-offset)))) + ) + (vector-matrix*! (-> self view-flat) (-> self view-flat) s4-0) + ) + ) + ) + ) + ) + ) + (when (not (logtest? (cam-slave-options WIDE_FOV) (-> *camera* settings slave-options))) + (let ((f0-101 (vector-length (-> self view-flat)))) + (let ((f1-89 (-> self view-off z))) + (when (< f1-89 f0-101) + (vector-float*! (-> self view-flat) (-> self view-flat) (/ f1-89 f0-101)) + (set! (-> self min-z-override) f1-89) + (set! f0-101 f1-89) + ) + ) + (if (and (< (-> self joystick-saved-view-off z) f0-101) + (and (< (-> self view-off y) (-> self joystick-saved-view-off y)) + (not (logtest? (cam-slave-options BOMBBOT) (-> *camera* settings slave-options))) + ) + ) + (set! (-> self view-off y) (fmin + (-> *camera* settings string-cliff-height) + (fmax (-> self string-min-val y) (-> self joystick-saved-view-off y)) + ) + ) + ) + (set! (-> self joystick-saved-view-off y) (-> self view-off y)) + (set! (-> self joystick-saved-view-off z) f0-101) + f0-101 + ) + ) + ) + +(defbehavior cam-string-find-hidden camera-slave () + (let ((s5-0 (new 'stack-no-clear 'collide-query)) + (gp-0 (new 'stack-no-clear 'vector)) + ) + (vector--float*! + (-> s5-0 move-dist) + (-> *camera* tpos-curr-adj) + (-> *camera* local-down) + (-> *camera* settings target-height) + ) + (vector-! (-> s5-0 move-dist) (-> s5-0 move-dist) (-> self string-trans)) + (set! (-> s5-0 start-pos quad) (-> self string-trans quad)) + (let ((s4-0 s5-0)) + (set! (-> s4-0 radius) 409.6) + (set! (-> s4-0 collide-with) (collide-spec backgnd obstacle hit-by-others-list camera-blocker pusher)) + (set! (-> s4-0 ignore-process0) #f) + (set! (-> s4-0 ignore-process1) #f) + (set! (-> s4-0 ignore-pat) (the-as pat-surface (camera-master-method-16 *camera* #f))) + (set! (-> s4-0 action-mask) (collide-action solid)) + ) + (cond + ((< (fill-and-probe-using-line-sphere *collide-cache* s5-0) 0.0) + (set! (-> self time-dist-too-far) (the-as uint 0)) + 0 + ) + ((< (-> self time-dist-too-far) (the-as uint 600)) + (+! (-> self time-dist-too-far) 1) + ) + ((cam-string-find-position-rel! gp-0) + (cam-string-set-position-rel! gp-0) + (set! (-> self time-dist-too-far) (the-as uint 0)) + 0 + ) + (else + (format 0 "camera position search failed~%") + (set! (-> self time-dist-too-far) (the-as uint 0)) + 0 + ) + ) + ) + (none) + ) + +(defbehavior cam-string-move camera-slave () + (vector-! (-> self velocity) (-> self desired-pos) (-> self string-trans)) + (if *display-cam-los-debug* + (format *stdcon* "vel ~M~%" (vector-length (-> self velocity))) + ) + (let ((s5-0 (new 'stack-no-clear 'vector)) + (s4-0 (new 'stack-no-clear 'vector)) + (gp-0 (new 'stack-no-clear 'vector)) + (s3-0 (new 'stack-no-clear 'vector)) + ) + (vector-! s3-0 (-> *camera* tpos-curr-adj) (-> *camera* tpos-old-adj)) + (vector+float*! s5-0 (-> self velocity) s3-0 0.5) + (vector-normalize! s5-0 1.0) + (vector-normalize-copy! s4-0 (-> self view-flat) 1.0) + (vector-cross! gp-0 s4-0 s5-0) + (cond + ((and (< (vector-length (-> self velocity)) (-> *CAMERA-bank* min-detectable-velocity)) + (< (vector-length s3-0) (-> *CAMERA-bank* min-detectable-velocity)) + ) + (set! (-> self string-vel-dir) (the-as uint 0)) + 0 + ) + ((< (cos 5461.3335) (vector-dot (-> *camera* local-down) s5-0)) + (set! (-> self string-vel-dir) (the-as uint 4)) + ) + ((< (vector-dot (-> *camera* local-down) s5-0) (- (cos 5461.3335))) + (set! (-> self string-vel-dir) (the-as uint 3)) + ) + ((< (cos 5461.3335) (vector-dot s4-0 s5-0)) + (set! (-> self string-vel-dir) (the-as uint 6)) + ) + ((< (vector-dot s4-0 s5-0) (- (cos 5461.3335))) + (set! (-> self string-vel-dir) (the-as uint 5)) + ) + ((< (vector-dot (-> *camera* local-down) gp-0) 0.0) + (set! (-> self string-vel-dir) (the-as uint 1)) + ) + (else + (set! (-> self string-vel-dir) (the-as uint 2)) + ) + ) + ) + (let ((s5-1 (new 'stack-no-clear 'collide-query))) + 0.0 + (let ((f30-2 1.0) + (s4-1 (-> s5-1 move-dist)) + (gp-1 0) + ) + (let ((s3-1 (new 'stack-no-clear 'vector))) + (when *debug-segment* + (if (>= (-> *CAMERA-bank* min-detectable-velocity) (vector-length (-> self velocity))) + (cam-collision-record-save (-> self string-trans) (-> self velocity) -1 'no-hit self) + ) + ) + (while (and (< 0.01 f30-2) + (and (< (-> *CAMERA-bank* min-detectable-velocity) (vector-length (-> self velocity))) (< gp-1 4)) + ) + (vector-float*! s4-1 (-> self velocity) f30-2) + (if *debug-segment* + (cam-collision-record-save (-> self string-trans) s4-1 gp-1 'normal self) + ) + (let ((f28-0 + (cond + ((logtest? (-> self options) (cam-slave-options-u32 COLLIDE)) + (set! (-> s5-1 start-pos quad) (-> self string-trans quad)) + (let ((s2-0 s5-1)) + (set! (-> s2-0 radius) (-> *CAMERA-bank* collide-move-rad)) + (set! (-> s2-0 collide-with) (collide-spec backgnd obstacle hit-by-others-list camera-blocker pusher)) + (set! (-> s2-0 ignore-process0) #f) + (set! (-> s2-0 ignore-process1) #f) + (set! (-> s2-0 ignore-pat) (the-as pat-surface (camera-master-method-16 *camera* #f))) + (set! (-> s2-0 action-mask) (collide-action solid)) + ) + (fill-and-probe-using-line-sphere *collide-cache* s5-1) + ) + (else + -100000000.0 + ) + ) + ) + ) + (if *display-cam-los-debug* + (format *stdcon* "vp ~f vr ~f r ~f ta ~f~%" (vector-length s4-1) f30-2 (/ (vector-length s4-1) f30-2) f28-0) + ) + (cond + ((>= f28-0 0.0) + (let* ((f1-10 (fmax 0.01 (/ 40.96 (vector-length s4-1)))) + (f0-22 (fmax 0.0 (- f28-0 f1-10))) + ) + (vector+float*! (-> self string-trans) (-> self string-trans) s4-1 f0-22) + ) + (vector-! s3-1 (-> self string-trans) (-> s5-1 best-other-tri intersect)) + (vector-normalize! s3-1 1.0) + (vector-flatten! (-> self velocity) (-> self velocity) s3-1) + (set! f30-2 (- f30-2 (* f30-2 f28-0))) + (+! gp-1 1) + ) + (else + (vector+! (-> self string-trans) (-> self string-trans) s4-1) + (set! f30-2 0.0) + ) + ) + ) + ) + ) + (cond + ((zero? gp-1) + (logclear! (-> self options) (cam-slave-options-u32 MOVEMENT_BLOCKED)) + (if *display-cam-los-debug* + (format *stdcon* "not blocked~%") + ) + ) + (else + (logior! (-> self options) (cam-slave-options-u32 MOVEMENT_BLOCKED)) + (if *display-cam-los-debug* + (format *stdcon* "blocked ~D ~f~%" gp-1 f30-2) + ) + (let ((gp-2 (new-stack-vector0)) + (f30-3 (vector-length (-> self view-flat))) + ) + (vector-! gp-2 (-> self string-trans) (-> *camera* tpos-curr-adj)) + (vector-flatten! gp-2 gp-2 (-> *camera* local-down)) + (let ((f28-1 (vector-length gp-2))) + (cond + ((< f28-1 f30-3) + (vector-normalize-copy! (-> self view-flat) gp-2 f28-1) + (set! (-> self min-z-override) f28-1) + ) + (else + (vector-normalize-copy! (-> self view-flat) gp-2 f30-3) + ) + ) + ) + ) + ) + ) + ) + ) + (when *display-cam-los-debug* + (let ((v1-105 (new-stack-vector0))) + (vector-! v1-105 (-> self desired-pos) (-> self string-trans)) + (format *stdcon* "vel ~M~%" (vector-length v1-105)) + ) + ) + ) + +;; WARN: Return type mismatch float vs object. +(defbehavior cam-string-code camera-slave () + (if *debug-segment* + (cam-debug-reset-coll-tri) + ) + (cam-string-follow) + (if (logtest? (-> self options) (cam-slave-options-u32 LINE_OF_SIGHT)) + (cam-string-line-of-sight) + ) + (if (not (paused?)) + (cam-string-joystick) + ) + (let ((gp-0 (new-stack-vector0))) + (vector--float*! + gp-0 + (-> self view-flat) + (-> *camera* local-down) + (+ (-> *camera* settings target-height) (-> self view-off y)) + ) + (vector+! (-> self desired-pos) (-> *camera* tpos-curr-adj) gp-0) + ) + (set! (-> self desired-pos y) (fmax + (fmin (-> self desired-pos y) (-> *camera* settings string-camera-ceiling)) + (-> *camera* settings string-camera-floor) + ) + ) + (if (logtest? (-> self options) (cam-slave-options-u32 FIND_HIDDEN_TARGET)) + (cam-string-find-hidden) + ) + (cond + ((logtest? (-> self options) (cam-slave-options-u32 GOTO_GOOD_POINT)) + (when *debug-segment* + (let ((a1-1 (new 'stack-no-clear 'vector))) + (vector-! a1-1 (-> self good-point) (-> self string-trans)) + (cam-collision-record-save (-> self string-trans) a1-1 -2 'jump self) + ) + ) + (logclear! (-> self options) (cam-slave-options-u32 GOTO_GOOD_POINT)) + (set! (-> self desired-pos quad) (-> self good-point quad)) + (cam-string-move) + (vector-! (-> self view-flat) (-> self string-trans) (-> *camera* tpos-curr-adj)) + (vector-flatten! (-> self view-flat) (-> self view-flat) (-> *camera* local-down)) + (let ((f0-5 (vector-length (-> self view-flat)))) + (if (< f0-5 (-> self min-z-override)) + (set! (-> self min-z-override) f0-5) + ) + ) + ) + (else + (cam-string-move) + ) + ) + (tracking-spline-method-17 (-> self position-spline) (-> self string-trans) 0.04096 4096.0 #t) + (let ((f30-0 (-> self clock clock-ratio))) + (let ((gp-2 (max 2 (the int (+ 0.5 (-> self clock time-adjust-ratio)))))) + (update-rates! (-> self clock) (/ f30-0 (the float gp-2))) + (while (nonzero? gp-2) + (+! gp-2 -1) + (cond + ((-> self butt-seek) + (tracking-spline-method-21 (-> self position-spline) (-> self trans) 163.84 8192.0 0.1 0.0 (the-as vector #f)) + (send-event *camera-combiner* 'fast-rot) + (if (< (-> self position-spline summed-len) 4096.0) + (set! (-> self butt-seek) #f) + ) + ) + ((logtest? (cam-slave-options RAPID_TRACKING) (-> *camera* settings slave-options)) + (tracking-spline-method-21 + (-> self position-spline) + (-> self trans) + 4096.0 + 40960.0 + 0.1 + 0.0 + (the-as vector #f) + ) + ) + ((and (logtest? (-> *camera* settings slave-options) (cam-slave-options BIKE_MODE)) + (logtest? (-> self options) (cam-slave-options-u32 PLAYER_MOVING_CAMERA)) + ) + (tracking-spline-method-21 (-> self position-spline) (-> self trans) 102.4 4096.0 0.1 0.0 (the-as vector #f)) + ) + ((logtest? (-> *camera* settings slave-options) (cam-slave-options BIKE_MODE)) + (tracking-spline-method-21 (-> self position-spline) (-> self trans) 40.96 4096.0 0.1 0.0 (the-as vector #f)) + ) + ((logtest? (-> self options) (cam-slave-options-u32 PLAYER_MOVING_CAMERA)) + (tracking-spline-method-21 + (-> self position-spline) + (-> self trans) + (-> *camera* settings string-spline-accel-player) + (-> *camera* settings string-spline-max-move-player) + 0.1 + 0.0 + (the-as vector #f) + ) + ) + (else + (tracking-spline-method-21 + (-> self position-spline) + (-> self trans) + (-> *camera* settings string-spline-accel) + (-> *camera* settings string-spline-max-move) + 0.1 + 0.0 + (the-as vector #f) + ) + ) + ) + ) + ) + (update-rates! (-> self clock) f30-0) + ) + ) + +;; WARN: Return type mismatch float vs vector. +(defbehavior set-string-params camera-slave () + (the-as + vector + (when (not (or (-> self string-val-locked) (logtest? (cam-slave-options-u32 GUN_CAM) (-> self options)))) + (set! (-> self string-min-val quad) (-> *camera* string-min value quad)) + (set! (-> self string-max-val quad) (-> *camera* string-max value quad)) + (set! (-> self slope-adjust target) 0.0) + (when (-> *camera* settings cam-slope) + (let ((gp-0 (the-as entity-camera (entity-by-name (-> *camera* settings cam-slope))))) + (when gp-0 + (set! (-> self slope-adjust target) (res-lump-float gp-0 'scale-factor :default 0.6)) + (quaternion-copy! (-> self slope-quat) (the-as quaternion (-> gp-0 connect))) + ) + ) + ) + (update! (-> self slope-adjust) 0.0) + (let ((f30-0 (- (-> self slope-adjust value)))) + (when (< f30-0 -0.001) + (let* ((gp-1 (vector-normalize-copy! (new 'stack-no-clear 'vector) (-> self view-flat) 1.0)) + (f0-6 + (* f30-0 (vector-dot (-> (quaternion->matrix (new 'stack-no-clear 'matrix) (-> self slope-quat)) uvec) gp-1)) + ) + ) + (+! (-> self string-min-val y) (* (-> self string-min-val z) f0-6)) + (set! (-> self string-max-val y) (+ (-> self string-max-val y) (* (-> self string-max-val z) f0-6))) + ) + ) + ) + ) + ) + ) + +(defstate cam-string (camera-slave) + :event (behavior ((proc process) (argc int) (message symbol) (block event-message-block)) + (local-vars (v0-0 object)) + (case message + (('get-behind) + (set! (-> self butt-timer) (+ (current-time) (seconds 0.25))) + (set! (-> self butt-seek) (the-as basic #t)) + (set! v0-0 (-> self butt-vector)) + (set! (-> (the-as vector v0-0) quad) (-> (the-as vector (-> block param 0)) quad)) + v0-0 + ) + (('teleport) + (let ((gp-0 (new-stack-vector0))) + (cam-string-find-position-rel! gp-0) + (cam-string-set-position-rel! gp-0) + ) + ) + (('joystick) + (set! (-> self phony-joystick-x) (the-as float (-> block param 0))) + (set! (-> self phony-joystick-y) (the-as float (-> block param 1))) + (set! v0-0 #t) + (set! (-> self have-phony-joystick) (the-as basic v0-0)) + v0-0 + ) + (('tween-dist) + (cond + ((-> block param 0) + (set! (-> self string-val-locked) (the-as basic #t)) + (let ((s5-0 (the-as object (-> block param 0))) + (gp-1 (the-as object (-> block param 1))) + ) + (if (!= (-> (the-as vector s5-0) y) 4095996000.0) + (seek! + (-> self string-min-val y) + (-> (the-as vector s5-0) y) + (* (-> (the-as vector s5-0) w) (seconds-per-frame)) + ) + ) + (if (!= (-> (the-as vector s5-0) z) 4095996000.0) + (seek! + (-> self string-min-val z) + (-> (the-as vector s5-0) z) + (* (-> (the-as vector s5-0) w) (seconds-per-frame)) + ) + ) + (if (!= (-> (the-as vector gp-1) y) 4095996000.0) + (seek! + (-> self string-max-val y) + (-> (the-as vector gp-1) y) + (* (-> (the-as vector gp-1) w) (seconds-per-frame)) + ) + ) + (if (!= (-> (the-as vector gp-1) z) 4095996000.0) + (seek! + (-> self string-max-val z) + (-> (the-as vector gp-1) z) + (* (-> (the-as vector gp-1) w) (seconds-per-frame)) + ) + ) + ) + (set! (-> self string-max-val x) (fmax (-> self string-max-val x) (-> self string-min-val x))) + (set! (-> self string-max-val y) (fmax (-> self string-max-val y) (-> self string-min-val y))) + (set! (-> self string-max-val z) (fmax (-> self string-max-val z) (-> self string-min-val z))) + ) + (else + (set! (-> self string-val-locked) #f) + #f + ) + ) + ) + (('set-dist) + (cond + ((-> block param 0) + (set! (-> self string-val-locked) (the-as basic #t)) + (set! (-> self string-min-val quad) (-> (the-as vector (-> block param 0)) quad)) + (set! (-> self string-max-val quad) (-> (the-as vector (-> block param 1)) quad)) + (set! (-> self string-max-val x) (fmax (-> self string-max-val x) (-> self string-min-val x))) + (set! (-> self string-max-val y) (fmax (-> self string-max-val y) (-> self string-min-val y))) + (set! (-> self string-max-val z) (fmax (-> self string-max-val z) (-> self string-min-val z))) + ) + (else + (set! (-> self string-val-locked) #f) + #f + ) + ) + ) + (('relative-position) + (cond + ((-> block param 0) + (set! (-> self string-val-locked) (the-as basic #t)) + (set! (-> self string-relative) (the-as basic #t)) + (set! v0-0 (-> self relative-position)) + (set! (-> (the-as vector v0-0) quad) (-> (the-as vector (-> block param 0)) quad)) + v0-0 + ) + (else + (set! (-> self string-val-locked) #f) + (set! (-> self string-relative) #f) + #f + ) + ) + ) + (('set-max-angle-offset) + (set! (-> self max-angle-offset) (the-as float (-> block param 0))) + ) + (('blocked-side?) + (-> self los-state) + ) + (else + (cam-standard-event-handler proc argc message block) + ) + ) + ) + :enter (behavior () + (when (not (-> self enter-has-run)) + (if (-> self cam-entity) + (logior! (-> self options) (cam-slave-get-flags (-> self cam-entity) 'flags)) + ) + (vector-reset! (-> self joystick-saved-view-off)) + (set-string-params) + (set! (-> self string-vel-dir) (the-as uint 0)) + (set! (-> self fov) 11650.845) + (set! (-> self los-tgt-spline-pt) (-> *camera* target-spline end-point)) + (set! (-> self los-tgt-spline-pt-incarnation) + (-> *camera* target-spline point (-> self los-tgt-spline-pt) incarnation) + ) + (set! (-> self min-z-override) (-> self string-max-val z)) + (if (!= (-> *camera* outro-t-step) 0.0) + (set! (-> self min-z-override) (-> self string-min-val z)) + ) + (let ((gp-1 (new-stack-vector0))) + 0.0 + (set! (-> self view-off-param) (-> *camera* view-off-param-save)) + (set! (-> self view-off x) 0.0) + (let ((f0-7 (-> self string-min-val y)) + (f1-1 (-> self string-max-val y)) + ) + (set! (-> self view-off y) (lerp f0-7 f1-1 (-> self view-off-param))) + ) + (set! (-> self view-off z) + (lerp (-> self string-min-val z) (-> self string-max-val z) (-> self view-off-param)) + ) + (let ((f30-0 + (cond + ((!= (-> *camera* outro-t-step) 0.0) + (curve-get-pos! gp-1 (-> *camera* outro-exit-value) (-> *camera* outro-curve)) + (vector-! gp-1 gp-1 (-> *camera* tpos-curr-adj)) + (vector-flatten! (-> self view-flat) gp-1 (-> *camera* local-down)) + (vector-length (-> self view-flat)) + ) + ((-> *camera* settings use-string-startup-vector) + (vector-flatten! (-> self view-flat) (-> *camera* settings string-startup-vector) (-> *camera* local-down)) + (vector-length (-> self view-flat)) + ) + (else + (vector-flatten! (-> self view-flat) (-> self tracking inv-mat fvec) (-> *camera* local-down)) + (vector-negate! (-> self view-flat) (-> self view-flat)) + (-> self view-off z) + ) + ) + ) + ) + (let ((f1-4 (fmin (-> *camera* string-push-z) (-> self min-z-override))) + (f0-17 (-> self view-off z)) + ) + (cond + ((< f30-0 f1-4) + (set! f30-0 f1-4) + ) + ((< f0-17 f30-0) + (set! f30-0 f0-17) + ) + ) + ) + (vector-normalize! (-> self view-flat) f30-0) + (let ((f30-1 (/ (- f30-0 (-> self string-min-val z)) (- (-> self string-max-val z) (-> self string-min-val z))))) + (if (< 1.0 f30-1) + (set! f30-1 1.0) + ) + (if (< f30-1 0.0) + (set! f30-1 0.0) + ) + (let ((f0-22 (-> self string-min-val y)) + (f1-7 (-> self string-max-val y)) + ) + (set! (-> self view-off y) (lerp f0-22 f1-7 f30-1)) + ) + (set! (-> self view-off z) (lerp (-> self string-min-val z) (-> self string-max-val z) f30-1)) + ) + ) + ) + (vector--float*! + (-> self desired-pos) + (-> self view-flat) + (-> *camera* local-down) + (+ (-> *camera* settings target-height) (-> self view-off y)) + ) + (vector+! (-> self desired-pos) (-> self desired-pos) (-> *camera* tpos-curr-adj)) + (set! (-> self string-trans quad) (-> self desired-pos quad)) + (vector-reset! (-> self velocity)) + (let ((gp-2 (new 'stack-no-clear 'collide-query))) + (vector--float*! + (-> gp-2 start-pos) + (-> *camera* tpos-curr-adj) + (-> *camera* local-down) + (-> *camera* settings target-height) + ) + (vector-! (-> gp-2 move-dist) (-> self string-trans) (-> gp-2 start-pos)) + (let ((s5-0 gp-2)) + (set! (-> s5-0 radius) (-> *CAMERA-bank* collide-move-rad)) + (set! (-> s5-0 collide-with) (collide-spec backgnd obstacle hit-by-others-list camera-blocker pusher)) + (set! (-> s5-0 ignore-process0) #f) + (set! (-> s5-0 ignore-process1) #f) + (set! (-> s5-0 ignore-pat) (the-as pat-surface (camera-master-method-16 *camera* #f))) + (set! (-> s5-0 action-mask) (collide-action solid)) + ) + (let ((f0-31 (fill-and-probe-using-line-sphere *collide-cache* gp-2))) + (when (and (< 0.0 f0-31) (< f0-31 1.0)) + (vector-float*! (-> gp-2 move-dist) (-> gp-2 move-dist) f0-31) + (vector-flatten! (-> self view-flat) (-> gp-2 move-dist) (-> *camera* local-down)) + (let ((f0-32 (vector-length (-> self view-flat)))) + (cond + ((< f0-32 8192.0) + (let ((gp-3 (new-stack-vector0))) + (cam-string-find-position-rel! gp-3) + (cam-string-set-position-rel! gp-3) + ) + ) + (else + (if (< f0-32 (-> self min-z-override)) + (set! (-> self min-z-override) f0-32) + ) + (let ((f30-2 (/ (- f0-32 (-> self string-min-val z)) (- (-> self string-max-val z) (-> self string-min-val z))))) + (if (< 1.0 f30-2) + (set! f30-2 1.0) + ) + (if (< f30-2 0.0) + (set! f30-2 0.0) + ) + (let ((f0-36 (-> self string-min-val y)) + (f1-16 (-> self string-max-val y)) + ) + (set! (-> self view-off y) (lerp f0-36 f1-16 f30-2)) + ) + (set! (-> self view-off z) (lerp (-> self string-min-val z) (-> self string-max-val z) f30-2)) + ) + (vector--float*! + (-> self desired-pos) + (-> self view-flat) + (-> *camera* local-down) + (+ (-> *camera* settings target-height) (-> self view-off y)) + ) + (vector+! (-> self desired-pos) (-> self desired-pos) (-> *camera* tpos-curr-adj)) + (set! (-> self string-trans quad) (-> self desired-pos quad)) + (vector-reset! (-> self velocity)) + ) + ) + ) + ) + ) + ) + (set! (-> self trans quad) (-> self string-trans quad)) + (set! (-> self los-last-pos quad) (-> self string-trans quad)) + (tracking-spline-method-10 (-> self position-spline) (-> self string-trans)) + (set! (-> self blend-from-type) (camera-blend-from-type unknown-2)) + (set! (-> self blend-to-type) (camera-blend-to-type unknown-2)) + ) + ) + :trans (behavior () + (if (not (logtest? (-> *camera* master-options) (cam-master-options-u32 HAVE_TARGET))) + (cam-slave-go cam-free-floating) + ) + ) + :code (behavior () + (until #f + (when (not (paused?)) + (set-string-params) + (cam-string-code) + (tracking-spline-method-9 (-> self position-spline)) + (set! (-> self have-phony-joystick) #f) + ) + (suspend) + ) + #f + ) + ) + +(deftype cam-stick-bank (basic) + ((max-z meters) + (min-z meters) + (max-y meters) + (min-y meters) + ) + ) + + +(define *CAM_STICK-bank* + (new 'static 'cam-stick-bank :max-z (meters 30) :min-z (meters 5) :max-y (meters 15) :min-y (meters 2)) + ) + +(defbehavior cam-stick-code camera-slave () + (cam-calc-follow! (-> self tracking) (-> self trans) #t) + (let ((gp-0 (new-stack-vector0))) + (vector-flatten! (-> self view-flat) (-> self view-flat) (-> *camera* local-down)) + (vector-normalize! (-> self view-flat) (-> self view-off z)) + (vector-! gp-0 (-> self view-flat) (vector-float*! gp-0 (-> *camera* local-down) (-> self view-off y))) + (vector+! (-> self desired-pos) (-> self tracking follow-pt) gp-0) + ) + (let ((v1-3 (new-stack-vector0)) + (gp-1 (new-stack-vector0)) + ) + (vector-! v1-3 (-> self desired-pos) (-> self trans)) + (vector-float*! v1-3 v1-3 0.2) + (vector-! gp-1 v1-3 (-> self velocity)) + (if (< 409.6 (vector-length gp-1)) + (vector-normalize! gp-1 409.6) + ) + (vector+! (-> self velocity) (-> self velocity) gp-1) + ) + (let ((gp-2 (new 'stack-no-clear 'collide-query))) + 0.0 + (let ((f30-0 1.0) + (s5-0 (-> gp-2 move-dist)) + (s4-0 (new-stack-vector0)) + (s3-0 4) + (s2-0 0) + ) + (while (and (< 0.01 f30-0) + (and (< (-> *CAMERA-bank* min-detectable-velocity) (vector-length (-> self velocity))) (> s3-0 0)) + ) + (+! s3-0 -1) + (vector-float*! s5-0 (-> self velocity) f30-0) + (let ((f28-0 + (cond + ((logtest? (-> self options) (cam-slave-options-u32 COLLIDE)) + (set! (-> gp-2 start-pos quad) (-> self trans quad)) + (let ((s1-0 gp-2)) + (set! (-> s1-0 radius) (-> *CAMERA-bank* collide-move-rad)) + (set! (-> s1-0 collide-with) (collide-spec backgnd obstacle hit-by-others-list camera-blocker pusher)) + (set! (-> s1-0 ignore-process0) #f) + (set! (-> s1-0 ignore-process1) #f) + (set! (-> s1-0 ignore-pat) (the-as pat-surface (camera-master-method-16 *camera* #f))) + (set! (-> s1-0 action-mask) (collide-action solid)) + ) + (fill-and-probe-using-line-sphere *collide-cache* gp-2) + ) + (else + -100000000.0 + ) + ) + ) + ) + (cond + ((>= f28-0 0.0) + (vector+float*! (-> self trans) (-> self trans) s5-0 f28-0) + (set! (-> s4-0 quad) (-> gp-2 best-other-tri normal quad)) + (vector-flatten! (-> self velocity) (-> self velocity) s4-0) + (set! f30-0 (- f30-0 (* f30-0 f28-0))) + (set! s2-0 1) + ) + (else + (vector+! (-> self trans) (-> self trans) s5-0) + (set! f30-0 0.0) + ) + ) + ) + ) + (when (nonzero? s2-0) + 0 + (let ((gp-3 (new-stack-vector0))) + 0.0 + (vector-! gp-3 (-> self trans) (-> self tracking follow-pt)) + (vector-flatten! gp-3 gp-3 (-> *camera* local-down)) + (let ((f0-15 (/ (- (vector-length gp-3) (-> *CAM_STICK-bank* min-z)) + (- (-> *CAM_STICK-bank* max-z) (-> *CAM_STICK-bank* min-z)) + ) + ) + ) + (cond + ((< f0-15 0.0) + (set! f0-15 0.0) + ) + ((< 1.0 f0-15) + (set! f0-15 1.0) + ) + ) + (cond + ((< (- f0-15 (-> self view-off-param)) -0.001) + (set! (-> self view-off-param) f0-15) + ) + ((< 0.001 (- f0-15 (-> self view-off-param))) + (vector-normalize-copy! (-> self view-flat) gp-3 (-> self view-off z)) + ) + ) + ) + ) + ) + ) + ) + (slave-set-rotation! (-> self tracking) (-> self trans) (-> self options) (-> self fov) #t) + (none) + ) + +(defstate cam-stick (camera-slave) + :event cam-standard-event-handler + :enter (behavior () + (when (not (-> self enter-has-run)) + (set! (-> self view-off-param) (-> *camera* view-off-param-save)) + (set! (-> self view-off x) 0.0) + (set! (-> self view-off y) + (lerp (-> *CAM_STICK-bank* min-y) (-> *CAM_STICK-bank* max-y) (-> self view-off-param)) + ) + (set! (-> self view-off z) + (lerp (-> *CAM_STICK-bank* min-z) (-> *CAM_STICK-bank* max-z) (-> self view-off-param)) + ) + (cam-calc-follow! (-> self tracking) (-> self trans) #f) + (vector-flatten! (-> self view-flat) (-> self tracking inv-mat fvec) (-> *camera* local-down)) + (vector-negate! (-> self view-flat) (-> self view-flat)) + (vector-normalize! (-> self view-flat) (-> self view-off z)) + (vector--float*! (-> self desired-pos) (-> self view-flat) (-> *camera* local-down) (-> self view-off y)) + (vector+! (-> self desired-pos) (-> self desired-pos) (-> self tracking follow-pt)) + (set! (-> self trans quad) (-> self desired-pos quad)) + (vector-reset! (-> self velocity)) + (set! (-> self blend-from-type) (camera-blend-from-type unknown-2)) + (set! (-> self blend-to-type) (camera-blend-to-type unknown-2)) + (slave-set-rotation! (-> self tracking) (-> self trans) (-> self options) (-> self fov) #f) + ) + ) + :trans (behavior () + (if (not (logtest? (-> *camera* master-options) (cam-master-options-u32 HAVE_TARGET))) + (cam-slave-go cam-free-floating) + ) + (when (not (paused?)) + (when (not (logtest? (-> *camera* settings master-options) (cam-master-options IGNORE_ANALOG))) + (let ((f0-0 (analog-input (the-as int (-> *cpad-list* cpads 0 righty)) 128.0 32.0 110.0 0.05))) + (cond + ((< (* 0.05 (- 1.0 (-> self view-off-param))) f0-0) + (+! (-> self view-off-param) (* 0.05 (- 1.0 (-> self view-off-param)))) + ) + ((< f0-0 (* 0.05 (- (-> self view-off-param)))) + (+! (-> self view-off-param) (* 0.05 (- (-> self view-off-param)))) + ) + (else + (+! (-> self view-off-param) f0-0) + ) + ) + ) + ) + (set! (-> self view-off y) + (lerp (-> *CAM_STICK-bank* min-y) (-> *CAM_STICK-bank* max-y) (-> self view-off-param)) + ) + (set! (-> self view-off z) + (lerp (-> *CAM_STICK-bank* min-z) (-> *CAM_STICK-bank* max-z) (-> self view-off-param)) + ) + (when (not (logtest? (-> *camera* settings master-options) (cam-master-options IGNORE_ANALOG))) + (let ((f0-16 + (analog-input (the-as int (-> *cpad-list* cpads 0 rightx)) 128.0 32.0 110.0 (* 21845.334 (seconds-per-frame))) + ) + (gp-0 (new 'stack-no-clear 'matrix)) + ) + (set! (-> gp-0 rvec quad) (the-as uint128 0)) + (set! (-> gp-0 uvec quad) (the-as uint128 0)) + (set! (-> gp-0 fvec quad) (the-as uint128 0)) + (set! (-> gp-0 trans quad) (the-as uint128 0)) + (let ((s3-0 (new-stack-vector0)) + (s5-0 (new-stack-vector0)) + (s4-0 (new-stack-vector0)) + ) + (if (-> *camera* settings flip-horizontal) + (set! f0-16 (- f0-16)) + ) + (cond + ((!= f0-16 0.0) + (matrix-axis-angle! gp-0 (-> *camera* local-down) f0-16) + (vector-matrix*! (-> self view-flat) (-> self view-flat) gp-0) + ) + ((logtest? (-> self options) (cam-slave-options-u32 BUTT_CAM)) + (set-vector! s5-0 0.0 0.0 1.0 1.0) + (vector-normalize-copy! s5-0 (-> self view-flat) 1.0) + (set! (-> s3-0 quad) (-> *camera* tgt-rot-mat fvec quad)) + (vector-flatten! s3-0 s3-0 (-> *camera* local-down)) + (vector-negate! s3-0 s3-0) + (set! (-> s4-0 quad) (-> s5-0 quad)) + (vector-normalize-copy! s4-0 s3-0 1.0) + (matrix-from-two-vectors-max-angle-partial! gp-0 s5-0 s4-0 (* 10922.667 (seconds-per-frame)) 0.05) + (vector-matrix*! (-> self view-flat) (-> self view-flat) gp-0) + ) + ) + ) + ) + ) + ) + ) + :code (behavior () + (until #f + (if (not (paused?)) + (cam-stick-code) + ) + (suspend) + ) + #f + ) + ) + +(deftype cam-bike-bank (basic) + ((min-z meters) + (max-z meters) + (min-y meters) + (max-y meters) + ) + ) + + +(define *CAM_BIKE-bank* + (new 'static 'cam-bike-bank :min-z (meters 6) :max-z (meters 10) :min-y (meters 3) :max-y (meters 5)) + ) + +(defbehavior cam-calc-bike-follow! camera-slave ((arg0 cam-rotation-tracker) (arg1 vector) (arg2 symbol)) + (vector-float*! (-> arg0 follow-off) (-> *camera* tgt-face-mat fvec) 155648.0) + (vector+! (-> arg0 follow-pt) (-> *camera* tpos-curr-adj) (-> arg0 follow-off)) + (vector--float*! + (-> arg0 follow-pt) + (-> arg0 follow-pt) + (-> *camera* local-down) + (+ 12288.0 (-> *camera* settings target-height)) + ) + (-> arg0 follow-pt) + ) + +(defbehavior cam-bike-code camera-slave () + (let ((s4-0 (new 'stack-no-clear 'matrix))) + (set! (-> s4-0 rvec quad) (the-as uint128 0)) + (set! (-> s4-0 uvec quad) (the-as uint128 0)) + (set! (-> s4-0 fvec quad) (the-as uint128 0)) + (set! (-> s4-0 trans quad) (the-as uint128 0)) + (let ((gp-0 (new-stack-vector0)) + (s5-0 (new-stack-vector0)) + ) + (vector-normalize-copy! gp-0 (-> self view-flat) 1.0) + (vector-flatten! s5-0 (-> *camera* tgt-rot-mat fvec) (-> *camera* local-down)) + (vector-normalize! s5-0 -1.0) + (matrix-from-two-vectors-partial-linear! s4-0 gp-0 s5-0 0.2) + ) + (vector-matrix*! (-> self view-flat) (-> self view-flat) s4-0) + ) + (let ((gp-1 (new-stack-vector0))) + 0.0 + (vector-! gp-1 (-> *camera* tpos-curr-adj) (-> *camera* tpos-old-adj)) + (let ((f30-0 (vector-length gp-1))) + (set! (-> self view-off z) (lerp-clamp + (-> *CAM_BIKE-bank* min-z) + (-> *CAM_BIKE-bank* max-z) + (parameter-ease-sin-clamp (* 0.00081380206 (+ -409.6 f30-0))) + ) + ) + (set! (-> self view-off y) (lerp-clamp + (-> *CAM_BIKE-bank* min-y) + (-> *CAM_BIKE-bank* max-y) + (parameter-ease-sin-clamp (* 0.00081380206 (+ -409.6 f30-0))) + ) + ) + ) + (vector-flatten! (-> self view-flat) (-> self view-flat) (-> *camera* local-down)) + (vector-normalize! (-> self view-flat) (-> self view-off z)) + (vector-! gp-1 (-> self view-flat) (vector-float*! gp-1 (-> *camera* local-down) (-> self view-off y))) + (vector+! (-> self desired-pos) (-> *camera* tpos-curr-adj) gp-1) + ) + (let ((v1-19 (new-stack-vector0)) + (gp-2 (new-stack-vector0)) + ) + (vector-! v1-19 (-> self desired-pos) (-> self trans)) + (vector-float*! v1-19 v1-19 0.2) + (vector-! gp-2 v1-19 (-> self velocity)) + (if (< 409.6 (vector-length gp-2)) + (vector-normalize! gp-2 409.6) + ) + (vector+! (-> self velocity) (-> self velocity) gp-2) + ) + (let ((gp-3 (new 'stack-no-clear 'collide-query))) + 0.0 + (let ((f30-1 1.0) + (s5-3 (-> gp-3 move-dist)) + (s4-3 4) + ) + (while (and (< 0.01 f30-1) + (and (< (-> *CAMERA-bank* min-detectable-velocity) (vector-length (-> self velocity))) (> s4-3 0)) + ) + (+! s4-3 -1) + (vector-float*! s5-3 (-> self velocity) f30-1) + (let ((f28-0 + (cond + ((logtest? (-> self options) (cam-slave-options-u32 COLLIDE)) + (set! (-> gp-3 start-pos quad) (-> self trans quad)) + (let ((s3-2 gp-3)) + (set! (-> s3-2 radius) 4096.0) + (set! (-> s3-2 collide-with) (collide-spec backgnd obstacle hit-by-others-list camera-blocker pusher)) + (set! (-> s3-2 ignore-process0) #f) + (set! (-> s3-2 ignore-process1) #f) + (set! (-> s3-2 ignore-pat) (the-as pat-surface (camera-master-method-16 *camera* #f))) + (set! (-> s3-2 action-mask) (collide-action solid)) + ) + (fill-and-probe-using-line-sphere *collide-cache* gp-3) + ) + (else + -100000000.0 + ) + ) + ) + ) + (cond + ((>= f28-0 0.0) + (vector+float*! (-> self trans) (-> self trans) s5-3 f28-0) + (vector-flatten! (-> self velocity) (-> self velocity) (-> gp-3 best-other-tri normal)) + (set! f30-1 (- f30-1 (* f30-1 f28-0))) + (let ((s3-3 (new-stack-vector0))) + (vector-! s3-3 (-> self trans) (-> *camera* tpos-curr-adj)) + (vector-flatten! s3-3 s3-3 (-> *camera* local-down)) + (vector-normalize-copy! (-> self view-flat) s3-3 (-> self view-off z)) + ) + ) + (else + (vector+! (-> self trans) (-> self trans) s5-3) + (set! f30-1 0.0) + ) + ) + ) + ) + ) + ) + (cam-calc-bike-follow! (-> self tracking) (-> self trans) #t) + (slave-set-rotation! (-> self tracking) (-> self trans) (-> self options) (-> self fov) #t) + (none) + ) + +(defstate cam-bike (camera-slave) + :event cam-standard-event-handler + :enter (behavior () + (when (not (-> self enter-has-run)) + (set-setting! 'head-offset 'abs (meters 4) 0) + (set-setting! 'foot-offset 'abs (meters 1) 0) + (set! (-> self view-off x) 0.0) + (set! (-> self view-off y) (-> *CAM_BIKE-bank* min-y)) + (set! (-> self view-off z) (-> *CAM_BIKE-bank* min-z)) + (vector-flatten! (-> self view-flat) (-> self tracking inv-mat fvec) (-> *camera* local-down)) + (vector-negate! (-> self view-flat) (-> self view-flat)) + (vector-normalize! (-> self view-flat) (-> self view-off z)) + (vector--float*! (-> self desired-pos) (-> self view-flat) (-> *camera* local-down) (-> self view-off y)) + (vector+! (-> self desired-pos) (-> self desired-pos) (-> *camera* tpos-curr-adj)) + (set! (-> self trans quad) (-> self desired-pos quad)) + (vector-reset! (-> self velocity)) + (set! (-> self blend-from-type) (camera-blend-from-type unknown-0)) + (set! (-> self blend-to-type) (camera-blend-to-type unknown-1)) + (cam-calc-bike-follow! (-> self tracking) (-> self trans) #f) + (slave-set-rotation! (-> self tracking) (-> self trans) (-> self options) (-> self fov) #f) + ) + ) + :exit (behavior () + (remove-setting! 'head-offset) + (remove-setting! 'foot-offset) + ) + :trans (behavior () + (if (not (logtest? (-> *camera* master-options) (cam-master-options-u32 HAVE_TARGET))) + (cam-slave-go cam-free-floating) + ) + ) + :code (behavior () + (until #f + (if (not (paused?)) + (cam-bike-code) + ) + (suspend) + ) + #f + ) + ) diff --git a/goal_src/jak3/engine/camera/cam-update-h.gc b/goal_src/jak3/engine/camera/cam-update-h.gc index 006df63d1de..552aea2b59a 100644 --- a/goal_src/jak3/engine/camera/cam-update-h.gc +++ b/goal_src/jak3/engine/camera/cam-update-h.gc @@ -34,9 +34,9 @@ (define-perm *camera-smush-control* smush-control (set-zero! (new 'global 'smush-control))) -(define-perm *camera-smush-control-horizontal* object (set-zero! (new 'global 'smush-control))) +(define-perm *camera-smush-control-horizontal* smush-control (set-zero! (new 'global 'smush-control))) -(define-perm *camera-smush-control-into* object (set-zero! (new 'global 'smush-control))) +(define-perm *camera-smush-control-into* smush-control (set-zero! (new 'global 'smush-control))) (define-perm *camera-other-root* vector (vector-reset! (new 'global 'vector))) diff --git a/goal_src/jak3/engine/camera/cam-update.gc b/goal_src/jak3/engine/camera/cam-update.gc index 9fe1fe7115f..32c8eda102e 100644 --- a/goal_src/jak3/engine/camera/cam-update.gc +++ b/goal_src/jak3/engine/camera/cam-update.gc @@ -7,3 +7,695 @@ ;; DECOMP BEGINS +(defun plane-from-points ((arg0 (inline-array plane)) (arg1 vector) (arg2 vector) (arg3 vector) (arg4 int)) + (let ((s4-0 (new 'stack-no-clear 'vector))) + (vector-cross! s4-0 arg1 arg2) + (vector-normalize! s4-0 1.0) + (set! (-> s4-0 w) (vector-dot s4-0 arg3)) + (set! (-> (&-> arg0 0 data arg4) 0) (-> s4-0 x)) + (set! (-> (&-> arg0 0 data arg4) 4) (-> s4-0 y)) + (set! (-> (&-> arg0 0 data arg4) 8) (-> s4-0 z)) + (set! (-> (&-> arg0 0 data arg4) 12) (-> s4-0 w)) + ) + ) + +(defun set-point ((arg0 vector) (arg1 float) (arg2 float) (arg3 float)) + (set! (-> arg0 x) arg1) + (set! (-> arg0 y) arg2) + (set! (-> arg0 z) arg3) + (set! (-> arg0 w) 1.0) + ) + +(defun update-view-planes ((arg0 math-camera) (arg1 (inline-array plane)) (arg2 float) (arg3 matrix)) + (local-vars (sv-240 vector)) + (when (not *artist-fix-frustum*) + (let ((s5-0 (new 'stack 'view-frustum))) + (let ((f30-0 (* arg2 (-> arg0 x-ratio) (-> arg0 d))) + (f26-0 (* arg2 (-> arg0 y-ratio) (-> arg0 d))) + (f28-0 (* arg2 (-> arg0 x-ratio) (-> arg0 f))) + (f24-0 (* arg2 (-> arg0 y-ratio) (-> arg0 f))) + ) + (set-point (-> s5-0 hither-top-left) (- f30-0) f26-0 (-> arg0 d)) + (set-point (-> s5-0 hither-top-right) f30-0 f26-0 (-> arg0 d)) + (set-point (-> s5-0 hither-bottom-left) (- f30-0) (- f26-0) (-> arg0 d)) + (set-point (-> s5-0 hither-bottom-right) f30-0 (- f26-0) (-> arg0 d)) + (set-point (-> s5-0 yon-top-left) (- f28-0) f24-0 (-> arg0 f)) + (set-point (-> s5-0 yon-top-right) f28-0 f24-0 (-> arg0 f)) + (set-point (-> s5-0 yon-bottom-left) (- f28-0) (- f24-0) (-> arg0 f)) + (set-point (-> s5-0 yon-bottom-right) f28-0 (- f24-0) (-> arg0 f)) + ) + (vector-matrix*! (-> s5-0 hither-top-left) (-> s5-0 hither-top-left) arg3) + (vector-matrix*! (-> s5-0 hither-top-right) (-> s5-0 hither-top-right) arg3) + (vector-matrix*! (-> s5-0 hither-bottom-left) (-> s5-0 hither-bottom-left) arg3) + (vector-matrix*! (-> s5-0 hither-bottom-right) (-> s5-0 hither-bottom-right) arg3) + (vector-matrix*! (-> s5-0 yon-top-left) (-> s5-0 yon-top-left) arg3) + (vector-matrix*! (-> s5-0 yon-top-right) (-> s5-0 yon-top-right) arg3) + (vector-matrix*! (-> s5-0 yon-bottom-left) (-> s5-0 yon-bottom-left) arg3) + (vector-matrix*! (-> s5-0 yon-bottom-right) (-> s5-0 yon-bottom-right) arg3) + (when (= arg2 1.0) + (let ((v1-4 *fog-texture-work*)) + (vector-! (the-as vector (-> v1-4 corner)) (-> s5-0 yon-top-left) (-> arg3 trans)) + (vector-! (-> v1-4 corner 1) (-> s5-0 yon-top-right) (-> arg3 trans)) + (vector-! (-> v1-4 corner 2) (-> s5-0 yon-bottom-left) (-> arg3 trans)) + (vector-! (-> v1-4 corner 3) (-> s5-0 yon-bottom-right) (-> arg3 trans)) + ) + ) + (let ((s2-1 (new-stack-vector0)) + (s3-1 (new-stack-vector0)) + (s1-0 (new-stack-vector0)) + (s0-0 (new-stack-vector0)) + ) + (set! (-> (new 'stack-no-clear 'vector) quad) (the-as uint128 0)) + (set! sv-240 (new 'stack-no-clear 'vector)) + (set! (-> sv-240 quad) (the-as uint128 0)) + (let ((v1-9 (-> arg3 trans quad))) + (set! (-> sv-240 quad) v1-9) + ) + (vector-! s2-1 (-> s5-0 yon-top-left) sv-240) + (vector-! s3-1 (-> s5-0 yon-top-right) sv-240) + (vector-! s1-0 (-> s5-0 yon-bottom-left) sv-240) + (vector-! s0-0 (-> s5-0 yon-bottom-right) sv-240) + (plane-from-points arg1 s2-1 s1-0 sv-240 0) + (plane-from-points arg1 s0-0 s3-1 sv-240 1) + (plane-from-points arg1 s3-1 s2-1 sv-240 2) + (let ((t9-20 plane-from-points) + (t0-3 3) + ) + (t9-20 arg1 s1-0 s0-0 sv-240 t0-3) + ) + ) + ) + ) + ) + +(define *update-leaf-when-outside-bsp* #t) + +(defun update-visible ((arg0 math-camera)) + (local-vars (s4-0 level-vis-info)) + (when (not *artist-fix-visible*) + (dotimes (s5-0 (-> *level* length)) + (let ((v1-5 (-> *level* level s5-0))) + (when (= (-> v1-5 status) 'active) + (if (and (nonzero? (-> v1-5 bsp nodes)) (or *update-leaf-when-outside-bsp* (-> v1-5 inside-boxes?))) + (bsp-camera-asm (-> v1-5 bsp) (-> arg0 trans)) + ) + ) + ) + ) + (dotimes (gp-1 (-> *level* length)) + (let ((s5-1 (-> *level* level gp-1))) + (when (= (-> s5-1 status) 'active) + (let ((a2-0 (/ (+ (-> s5-1 bsp visible-list-length) 15) 16))) + (set! (-> s5-1 all-visible?) (if (-> s5-1 all-visible?) + (-> s5-1 all-visible?) + #t + ) + ) + (cond + ((or (not (-> s5-1 force-all-visible?)) (-> s5-1 inside-boxes?)) + (cond + ((or *artist-all-visible* (not (-> s5-1 vis-info 0))) + (quad-copy! (-> s5-1 vis-bits) (-> s5-1 bsp all-visible-list) a2-0) + (if (= (-> s5-1 all-visible?) 'loading) + (set! (-> s5-1 all-visible?) #t) + ) + ) + ((begin + (set! s4-0 (-> s5-1 vis-info (-> s5-1 vis-self-index))) + (let ((v1-32 #f)) + (when (and s4-0 (-> s4-0 from-bsp)) + (set! v1-32 (logtest? (vis-info-flag vis-valid) (-> s4-0 flags))) + (if (< (-> s4-0 length) (-> s4-0 from-bsp current-leaf-idx)) + (set! v1-32 #f) + ) + ) + v1-32 + ) + ) + (if (!= (-> s5-1 all-visible?) 'loading) + (set! (-> s5-1 all-visible?) #f) + ) + (when (update-vis! s5-1 s4-0 (-> s4-0 ramdisk) (the-as (pointer uint8) (-> s4-0 string-block))) + (countdown (v1-40 8) + (let ((a0-27 (-> s5-1 vis-info v1-40))) + (when a0-27 + (if (!= a0-27 s4-0) + (set! (-> a0-27 current-vis-string) (the-as uint -1)) + ) + ) + ) + ) + (set! (-> s5-1 all-visible?) #f) + ) + ) + ((and (= (-> s5-1 all-visible?) 'loading) (-> *level* play?)) + ) + (else + (quad-copy! (-> s5-1 vis-bits) (-> s5-1 bsp all-visible-list) a2-0) + ) + ) + ) + (else + (quad-copy! (-> s5-1 vis-bits) (-> s5-1 bsp all-visible-list) a2-0) + ) + ) + ) + ) + ) + ) + ) + (let ((gp-2 0)) + (if (and *artist-fix-visible* (cpad-pressed? 0 r2)) + (set! *fix-visible-level-mask* (logand (+ *fix-visible-level-mask* 1) 127)) + ) + (dotimes (s5-2 (-> *level* length)) + (let ((s4-1 (-> *level* level s5-2))) + (when (= (-> s4-1 status) 'active) + (cond + ((or *artist-fix-visible* *stats-bsp*) + (set! (-> s4-1 render?) (not (logtest? *fix-visible-level-mask* (ash 1 gp-2)))) + (if (!= (-> s4-1 bsp visible-list-length) 4) + (format + *stdcon* + "~0kleaf-index ~8S ~C = ~d node ~d ~S ~S~%" + (-> s4-1 name) + (if (not (logtest? *fix-visible-level-mask* (ash 1 gp-2))) + 88 + 32 + ) + (-> s4-1 bsp current-leaf-idx) + (-> s4-1 bsp cam-box-idx) + (if (zero? (-> s4-1 bsp cam-using-back)) + "front" + "back" + ) + (if (nonzero? (-> s4-1 bsp cam-outside-bsp)) + "outside" + "" + ) + ) + ) + ) + (else + (set! (-> s4-1 render?) #t) + ) + ) + (when (and *artist-fix-visible* (not (logtest? *fix-visible-level-mask* (ash 1 gp-2)))) + (let ((s3-0 (-> s4-1 bsp current-leaf-idx)) + (s2-0 (-> s4-1 bsp vis-spheres)) + ) + (-> s4-1 bsp vis-spheres-length) + (when (nonzero? s2-0) + (dotimes (s1-0 (-> s2-0 length)) + (let* ((v1-95 (the int (-> s2-0 data s1-0 w))) + (a0-45 (abs v1-95)) + ) + (when (= a0-45 s3-0) + (if (>= v1-95 0) + (add-debug-sphere #t (bucket-id bucket583) (-> s2-0 data s1-0) (meters 1) (new 'static 'rgba :b #xff :a #x80)) + (add-debug-sphere #t (bucket-id bucket583) (-> s2-0 data s1-0) (meters 1) (new 'static 'rgba :r #xff :a #x80)) + ) + ) + ) + ) + ) + ) + (when (nonzero? (-> s4-1 bsp nodes)) + (let ((v1-109 (-> s4-1 bsp nodes (-> s4-1 bsp cam-box-idx))) + (a2-7 (new 'stack-no-clear 'vector)) + ) + (set! (-> a2-7 quad) (-> s4-1 bsp bsp-offset quad)) + (let ((a3-6 (new 'stack-no-clear 'vector))) + (set! (-> a3-6 quad) (-> s4-1 bsp bsp-offset quad)) + (cond + ((zero? (-> s4-1 bsp cam-using-back)) + (+! (-> a2-7 x) (the float (* (-> v1-109 front-box-min x) (the int (-> s4-1 bsp bsp-scale x))))) + (+! (-> a2-7 y) (the float (* (-> v1-109 front-box-min y) (the int (-> s4-1 bsp bsp-scale y))))) + (+! (-> a2-7 z) (the float (* (-> v1-109 front-box-min z) (the int (-> s4-1 bsp bsp-scale z))))) + (+! (-> a3-6 x) (the float (* (-> v1-109 front-box-max x) (the int (-> s4-1 bsp bsp-scale x))))) + (+! (-> a3-6 y) (the float (* (-> v1-109 front-box-max y) (the int (-> s4-1 bsp bsp-scale y))))) + (+! (-> a3-6 z) (the float (* (-> v1-109 front-box-max z) (the int (-> s4-1 bsp bsp-scale z))))) + ) + (else + (+! (-> a2-7 x) (the float (* (-> v1-109 back-box-min x) (the int (-> s4-1 bsp bsp-scale x))))) + (+! (-> a2-7 y) (the float (* (-> v1-109 back-box-min y) (the int (-> s4-1 bsp bsp-scale y))))) + (+! (-> a2-7 z) (the float (* (-> v1-109 back-box-min z) (the int (-> s4-1 bsp bsp-scale z))))) + (+! (-> a3-6 x) (the float (* (-> v1-109 back-box-max x) (the int (-> s4-1 bsp bsp-scale x))))) + (+! (-> a3-6 y) (the float (* (-> v1-109 back-box-max y) (the int (-> s4-1 bsp bsp-scale y))))) + (+! (-> a3-6 z) (the float (* (-> v1-109 back-box-max z) (the int (-> s4-1 bsp bsp-scale z))))) + ) + ) + (add-debug-box #t (bucket-id bucket583) a2-7 a3-6 (new 'static 'rgba :g #xff :b #xff :a #x80)) + ) + ) + ) + ) + (if (!= (-> s4-1 bsp visible-list-length) 4) + (+! gp-2 1) + ) + ) + ) + ) + ) + #f + ) + +(define *save-camera-inv-rot* (new 'global 'matrix)) + +(matrix-identity! *save-camera-inv-rot*) + +(defun move-camera-from-pad ((arg0 math-camera)) + (let ((v1-0 *external-cam-mode*) + (s5-0 0) + ) + (cond + ((= v1-0 'locked) + (set! v1-0 #f) + ) + ((= v1-0 'pad-1) + (set! s5-0 1) + ) + ((not *camera-combiner*) + (set! v1-0 'pad-0) + ) + ) + (when v1-0 + (let ((a2-1 + (vector-negate-in-place! (vector-normalize-copy! (new-stack-vector0) (-> *standard-dynamics* gravity) 1.0)) + ) + ) + (if (= (vector-length a2-1) 0.0) + (set! (-> a2-1 y) -1.0) + ) + (if (logtest? *external-cam-options* (external-cam-option allow-z)) + (set! a2-1 (the-as vector #f)) + ) + (cam-free-floating-move *save-camera-inv-rot* (-> arg0 trans) a2-1 s5-0) + ) + ) + ) + (let* ((a2-2 (-> *math-camera* inv-camera-rot)) + (a3-1 *save-camera-inv-rot*) + (v1-14 (-> a3-1 rvec quad)) + (a0-13 (-> a3-1 uvec quad)) + (a1-2 (-> a3-1 fvec quad)) + (a3-2 (-> a3-1 trans quad)) + ) + (set! (-> a2-2 rvec quad) v1-14) + (set! (-> a2-2 uvec quad) a0-13) + (set! (-> a2-2 fvec quad) a1-2) + (set! (-> a2-2 trans quad) a3-2) + ) + arg0 + ) + +(defun external-cam-reset! () + (when (not (movie?)) + (vector-reset! (-> *math-camera* trans)) + (matrix-identity! (-> *math-camera* inv-camera-rot)) + (when *camera-combiner* + (let* ((v1-7 (-> *math-camera* inv-camera-rot)) + (a3-0 (-> *camera-combiner* inv-camera-rot)) + (a0-2 (-> a3-0 rvec quad)) + (a1-0 (-> a3-0 uvec quad)) + (a2-0 (-> a3-0 fvec quad)) + (a3-1 (-> a3-0 trans quad)) + ) + (set! (-> v1-7 rvec quad) a0-2) + (set! (-> v1-7 uvec quad) a1-0) + (set! (-> v1-7 fvec quad) a2-0) + (set! (-> v1-7 trans quad) a3-1) + ) + (set! (-> *math-camera* trans quad) (-> *camera-combiner* trans quad)) + ) + ) + 0 + (none) + ) + +(define *start-timer* (the-as int #f)) + +(define *timer-value* 0) + +(define *start-pos* (new 'global 'vector)) + +(defun update-camera () + (with-pp + (let ((gp-0 *math-camera*)) + (let* ((a2-0 (-> gp-0 prev-inv-camera-rot)) + (a3-0 (-> gp-0 inv-camera-rot)) + (v1-0 (-> a3-0 rvec quad)) + (a0-0 (-> a3-0 uvec quad)) + (a1-0 (-> a3-0 fvec quad)) + (a3-1 (-> a3-0 trans quad)) + ) + (set! (-> a2-0 rvec quad) v1-0) + (set! (-> a2-0 uvec quad) a0-0) + (set! (-> a2-0 fvec quad) a1-0) + (set! (-> a2-0 trans quad) a3-1) + ) + (set! (-> gp-0 prev-trans quad) (-> gp-0 trans quad)) + (when *start-timer* + (when (= *timer-value* 180) + (format + #t + "Player pos = ~F ~F ~F~%" + (-> *target* control trans x) + (-> *target* control trans y) + (-> *target* control trans z) + ) + (set! (-> *start-pos* quad) (-> *target* control trans quad)) + ) + (when (= *timer-value* 480) + (format + #t + "Player pos = ~F ~F ~F~%" + (-> *target* control trans x) + (-> *target* control trans y) + (-> *target* control trans z) + ) + (format + #t + "Dist = ~F~%" + (* 0.00024414062 (vector-vector-xz-distance (-> *target* control trans) *start-pos*)) + ) + (set! *start-timer* (the-as int #f)) + ) + (if (< 179 *timer-value*) + (format *stdcon* "~%~%Time = ~D~%" *timer-value*) + ) + (set! *timer-value* (+ *timer-value* 1)) + ) + (when (not *start-timer*) + (set! *timer-value* 0) + 0 + ) + (let ((f0-9 (if (get-menu-mode *blit-displays-work*) + 11650.845 + (-> gp-0 fov) + ) + ) + ) + (update-math-camera + gp-0 + (-> *setting-control* user-current video-mode) + (-> *setting-control* user-current aspect-ratio) + f0-9 + ) + ) + (cond + ((or (= *master-mode* 'pause) (or (= *master-mode* 'freeze) (= *master-mode* 'progress) *progress-process*)) + ) + ((>= *camera-look-through-other* 2) + (set! *camera-look-through-other* 1) + ) + ((and (= *camera-look-through-other* 1) (!= *master-mode* 'menu)) + (set! *camera-look-through-other* 0) + 0 + ) + ) + 0.0 + 0.0 + 0.0 + (let ((s5-1 (new 'stack-no-clear 'vector)) + (s4-1 (-> pp clock)) + ) + (set! (-> pp clock) (-> *display* camera-clock)) + (update! *camera-smush-control*) + (let ((f28-0 (get-no-update *camera-smush-control*))) + (update! *camera-smush-control-horizontal*) + (let ((f30-1 (get-no-update *camera-smush-control-horizontal*))) + (update! *camera-smush-control-into*) + (get-no-update *camera-smush-control-into*) + (set! (-> pp clock) s4-1) + (cond + (*external-cam-mode* + (move-camera-from-pad gp-0) + ) + ((nonzero? *camera-look-through-other*) + (set! (-> gp-0 fov) (-> *camera-other-fov* data)) + (set! (-> gp-0 trans quad) (-> *camera-other-trans* quad)) + (+! (-> gp-0 trans y) f28-0) + (let* ((a2-6 (-> gp-0 inv-camera-rot)) + (a3-5 *camera-other-matrix*) + (v1-76 (-> a3-5 rvec quad)) + (a0-34 (-> a3-5 uvec quad)) + (a1-7 (-> a3-5 fvec quad)) + (a3-6 (-> a3-5 trans quad)) + ) + (set! (-> a2-6 rvec quad) v1-76) + (set! (-> a2-6 uvec quad) a0-34) + (set! (-> a2-6 fvec quad) a1-7) + (set! (-> a2-6 trans quad) a3-6) + ) + (let* ((a2-7 *save-camera-inv-rot*) + (a3-7 *camera-other-matrix*) + (v1-77 (-> a3-7 rvec quad)) + (a0-35 (-> a3-7 uvec quad)) + (a1-8 (-> a3-7 fvec quad)) + (a3-8 (-> a3-7 trans quad)) + ) + (set! (-> a2-7 rvec quad) v1-77) + (set! (-> a2-7 uvec quad) a0-35) + (set! (-> a2-7 fvec quad) a1-8) + (set! (-> a2-7 trans quad) a3-8) + ) + ) + ((and *camera-combiner* (not *external-cam-mode*)) + (set! (-> gp-0 fov) (-> *camera-combiner* fov)) + (set! (-> gp-0 trans quad) (-> *camera-combiner* trans quad)) + (+! (-> gp-0 trans y) f28-0) + (let* ((v1-84 (-> gp-0 inv-camera-rot)) + (a3-9 (-> *camera-combiner* inv-camera-rot)) + (a0-40 (-> a3-9 rvec quad)) + (a1-9 (-> a3-9 uvec quad)) + (a2-8 (-> a3-9 fvec quad)) + (a3-10 (-> a3-9 trans quad)) + ) + (set! (-> v1-84 rvec quad) a0-40) + (set! (-> v1-84 uvec quad) a1-9) + (set! (-> v1-84 fvec quad) a2-8) + (set! (-> v1-84 trans quad) a3-10) + ) + (let* ((v1-85 *save-camera-inv-rot*) + (a3-11 (-> *camera-combiner* inv-camera-rot)) + (a0-42 (-> a3-11 rvec quad)) + (a1-10 (-> a3-11 uvec quad)) + (a2-9 (-> a3-11 fvec quad)) + (a3-12 (-> a3-11 trans quad)) + ) + (set! (-> v1-85 rvec quad) a0-42) + (set! (-> v1-85 uvec quad) a1-10) + (set! (-> v1-85 fvec quad) a2-9) + (set! (-> v1-85 trans quad) a3-12) + ) + ) + (*camera* + (move-camera-from-pad gp-0) + ) + ) + (when (or (nonzero? *camera-look-through-other*) (and *camera-combiner* (not *external-cam-mode*))) + 0.0 + (set-vector! s5-1 f30-1 0.0 0.0 1.0) + (vector-rotate*! s5-1 s5-1 (-> gp-0 inv-camera-rot)) + (set! (-> s5-1 y) 0.0) + (vector+! (-> gp-0 trans) (-> gp-0 trans) s5-1) + ) + ) + ) + ) + (matrix-transpose! (-> gp-0 camera-rot) (-> gp-0 inv-camera-rot)) + (cond + (*camera-no-mip-correction* + (set! (-> gp-0 fov-correction-factor) 1.0) + ) + (else + (let ((f0-27 (fmin 11650.845 (-> gp-0 fov)))) + (set! (-> gp-0 fov-correction-factor) (* 0.00008583069 f0-27)) + ) + ) + ) + (if (< 0.0 (-> gp-0 smooth-t)) + (set! (-> gp-0 smooth-t) (- (-> gp-0 smooth-t) (-> gp-0 smooth-step))) + ) + (cond + ((< 0.0 (-> gp-0 smooth-t)) + (let ((s5-2 (new-stack-quaternion0))) + (matrix->quaternion s5-2 (-> gp-0 inv-camera-rot)) + (quaternion-slerp! s5-2 s5-2 (-> gp-0 inv-camera-rot-smooth-from) (-> gp-0 smooth-t)) + (quaternion->matrix (-> gp-0 inv-camera-rot-smooth) s5-2) + ) + ) + (else + (let* ((a2-12 (-> gp-0 inv-camera-rot-smooth)) + (a3-14 (-> gp-0 inv-camera-rot)) + (v1-106 (-> a3-14 rvec quad)) + (a0-51 (-> a3-14 uvec quad)) + (a1-16 (-> a3-14 fvec quad)) + (a3-15 (-> a3-14 trans quad)) + ) + (set! (-> a2-12 rvec quad) v1-106) + (set! (-> a2-12 uvec quad) a0-51) + (set! (-> a2-12 fvec quad) a1-16) + (set! (-> a2-12 trans quad) a3-15) + ) + ) + ) + (when (and (!= *master-mode* 'menu) *display-camera-info*) + (when *target* + (let ((v1-112 (target-pos 0))) + (format *stdcon* "targ pos ~M ~M ~M~%" (-> v1-112 x) (-> v1-112 y) (-> v1-112 z)) + ) + ) + (format + *stdcon* + "cam pos ~M ~M ~M fov ~R~%" + (-> gp-0 trans x) + (-> gp-0 trans y) + (-> gp-0 trans z) + (-> gp-0 fov) + ) + (let ((v1-115 (-> *setting-control* cam-current))) + (format + *stdcon* + "string info min-l ~M max-l ~M min-h ~M max-h ~M~%" + (-> v1-115 string-min-length) + (-> v1-115 string-max-length) + (-> v1-115 string-min-height) + (-> v1-115 string-max-height) + ) + ) + ) + (when (zero? (-> gp-0 reset)) + (let* ((a2-16 (-> gp-0 prev-camera-temp)) + (a3-19 (-> gp-0 camera-temp)) + (v1-119 (-> a3-19 rvec quad)) + (a0-58 (-> a3-19 uvec quad)) + (a1-20 (-> a3-19 fvec quad)) + (a3-20 (-> a3-19 trans quad)) + ) + (set! (-> a2-16 rvec quad) v1-119) + (set! (-> a2-16 uvec quad) a0-58) + (set! (-> a2-16 fvec quad) a1-20) + (set! (-> a2-16 trans quad) a3-20) + ) + ) + (let ((s3-1 (-> gp-0 camera-temp)) + (s2-0 (-> gp-0 camera-rot)) + (s5-3 (-> gp-0 inv-camera-rot)) + (s4-2 (-> gp-0 trans)) + ) + (let ((s1-0 (new-stack-vector0))) + (set! (-> s1-0 x) (- (-> s4-2 x))) + (set! (-> s1-0 y) (- (-> s4-2 y))) + (set! (-> s1-0 z) (- (-> s4-2 z))) + (set! (-> s1-0 w) 1.0) + (vector-matrix*! s1-0 s1-0 s2-0) + (set! (-> s2-0 trans quad) (-> s1-0 quad)) + ) + (matrix*! s3-1 s2-0 (-> gp-0 perspective)) + (set! (-> s5-3 trans quad) (-> s4-2 quad)) + ) + (when (nonzero? (-> gp-0 reset)) + (let* ((a2-19 (-> gp-0 prev-camera-temp)) + (a3-21 (-> gp-0 camera-temp)) + (v1-125 (-> a3-21 rvec quad)) + (a0-61 (-> a3-21 uvec quad)) + (a1-23 (-> a3-21 fvec quad)) + (a3-22 (-> a3-21 trans quad)) + ) + (set! (-> a2-19 rvec quad) v1-125) + (set! (-> a2-19 uvec quad) a0-61) + (set! (-> a2-19 fvec quad) a1-23) + (set! (-> a2-19 trans quad) a3-22) + ) + (set! (-> gp-0 reset) 0) + 0 + ) + (let ((f1-5 (-> gp-0 fog-min)) + (f0-52 (-> gp-0 fog-max)) + ) + (let ((f2-0 (-> gp-0 d))) + (set! (-> *instance-tie-work* hmge-d x) f1-5) + (set! (-> *instance-tie-work* hmge-d y) f0-52) + (set! (-> *instance-tie-work* hmge-d z) (* 32.0 f2-0)) + (set! (-> *instance-tie-work* hmge-d w) (* f2-0 (-> gp-0 hmge-scale w))) + (let ((v1-132 (-> gp-0 hvdf-off quad))) + (set! (-> *instance-tie-work* hvdf-offset quad) v1-132) + ) + (set! (-> *instance-shrub-work* hmge-d x) f1-5) + (set! (-> *instance-shrub-work* hmge-d y) f0-52) + (set! (-> *instance-shrub-work* hmge-d z) (* 3.0 f2-0)) + (set! (-> *instance-shrub-work* hmge-d w) (* f2-0 (-> gp-0 hmge-scale w))) + (set! (-> *instance-shrub-work* billboard-const x) (/ (-> gp-0 x-pix) (* f2-0 (-> gp-0 x-ratio)))) + (set! (-> *instance-shrub-work* billboard-const y) (/ (-> gp-0 y-pix) (* f2-0 (-> gp-0 y-ratio)))) + ) + (set! (-> *instance-shrub-work* billboard-const z) f1-5) + (set! (-> *instance-shrub-work* billboard-const w) f0-52) + ) + (set! (-> *instance-shrub-work* constants w) (the-as float (-> gp-0 vis-gifs 0))) + (let ((a0-63 (-> gp-0 hvdf-off quad))) + (set! (-> *instance-shrub-work* hvdf-offset quad) a0-63) + ) + (update-view-planes gp-0 (-> gp-0 plane) 1.0 (-> gp-0 inv-camera-rot)) + (update-view-planes gp-0 (-> gp-0 guard-plane) 2.0 (-> gp-0 inv-camera-rot)) + (shrub-make-perspective-matrix (-> gp-0 shrub-mat) (-> gp-0 camera-temp)) + (update-visible gp-0) + (when (-> *time-of-day-context* use-camera-other) + (let ((s4-3 (-> gp-0 camera-rot)) + (s0-0 (-> gp-0 camera-rot-other-sky)) + (s5-4 (-> gp-0 camera-rot-other-sprite)) + (s3-2 (-> gp-0 camera-rot-other)) + (s2-1 (-> gp-0 inv-camera-rot-other)) + (s1-1 (-> gp-0 camera-temp-other)) + ) + (quaternion->matrix s0-0 (-> gp-0 quat-other)) + (mem-copy! (the-as pointer s5-4) (the-as pointer s0-0) 64) + (set! (-> s5-4 trans quad) (-> gp-0 trans-other quad)) + (set! (-> s5-4 trans w) 1.0) + (matrix*! s3-2 s5-4 s4-3) + (matrix-inverse-of-rot-trans! s2-1 s3-2) + (matrix*! s1-1 s3-2 (-> gp-0 perspective)) + (update-view-planes gp-0 (-> gp-0 plane-other) 1.0 s2-1) + (update-view-planes gp-0 (-> gp-0 guard-plane-other) 2.0 s2-1) + (shrub-make-perspective-matrix (-> gp-0 shrub-mat-other) s1-1) + ) + ) + ) + #f + ) + ) + +(defun-debug move-level-by-name ((arg0 symbol) (arg1 float) (arg2 float) (arg3 float)) + (let ((v1-1 (level-get *level* arg0))) + (when v1-1 + (logior! (-> v1-1 info level-flags) (level-flags lf10)) + (let ((v0-1 (-> *math-camera* trans-other))) + (set! (-> v0-1 x) (* 4096.0 arg1)) + (set! (-> v0-1 y) (* 4096.0 arg2)) + (set! (-> v0-1 z) (* 4096.0 arg3)) + (set! (-> v0-1 w) 1.0) + v0-1 + ) + ) + ) + ) + +(defun execute-cam-post-hook-engine () + (let* ((gp-0 *cam-post-hook-engine*) + (s5-0 (-> gp-0 alive-list next0)) + (s4-0 (-> s5-0 next0)) + ) + (while (!= s5-0 (-> gp-0 alive-list-end)) + ((the-as (function object object object object object) (-> (the-as connection s5-0) param0)) + (get-process (the-as connection s5-0)) + (-> (the-as connection s5-0) param1) + (-> (the-as connection s5-0) param2) + (-> (the-as connection s5-0) param2) + ) + (set! s5-0 s4-0) + (set! s4-0 (-> s4-0 next0)) + ) + ) + 0 + ) diff --git a/goal_src/jak3/engine/camera/camera-h.gc b/goal_src/jak3/engine/camera/camera-h.gc index 24898bca340..6c9d28060a1 100644 --- a/goal_src/jak3/engine/camera/camera-h.gc +++ b/goal_src/jak3/engine/camera/camera-h.gc @@ -9,8 +9,8 @@ (defenum cam-index-options :type uint32 :bitfield #t - (RADIAL) (SPHERICAL) + (RADIAL) ) ;; ---cam-index-options @@ -66,6 +66,36 @@ (define-extern cam-stop (function symbol)) (define-extern cam-start (function symbol none)) +(declare-type camera-slave process) +(declare-type cam-rotation-tracker structure) +(declare-type camera-master process) + +;; camera +(define-extern camera-line-rel-len (function vector vector float vector4w none)) +(define-extern camera-slave-debug (function camera-slave none)) +(define-extern cam-calc-follow! (function cam-rotation-tracker vector symbol vector)) +(define-extern slave-set-rotation! (function cam-rotation-tracker vector cam-slave-options-u32 float symbol none)) +(define-extern cam-master-effect (function none :behavior camera-master)) +(define-extern camera-master-debug (function camera-master none)) + +;; cam-master +(define-extern group-rain-screend-drop sparticle-launch-group) + +;; cam-states +(define-extern cam-debug-reset-coll-tri (function none)) +(define-extern cam-debug-add-los-tri (function (inline-array collide-cache-tri) vector vector none)) +(define-extern cam-collision-record-save (function vector vector int symbol camera-slave none)) +(define-extern slave-los-state->string (function slave-los-state string)) + +;; cam-layout +(define-extern camera-line-setup (function vector4w none)) +(define-extern camera-line-draw (function vector vector none)) +(define-extern camera-line (function vector vector vector4w none)) +(define-extern camera-cross (function vector vector vector vector4w meters none)) +(define-extern camera-fov-frame (function matrix vector float float float vector4w symbol)) +(define-extern cam-slave-options->string (function cam-slave-options object string)) +(define-extern cam-index-options->string (function cam-index-options object string)) + ;; DECOMP BEGINS (deftype cam-index (structure) @@ -73,8 +103,8 @@ (vec vector 2 :inline) ) (:methods - (cam-index-method-9 () none) - (cam-index-method-10 () none) + (cam-index-method-9 (_type_ symbol entity vector curve) symbol) + (cam-index-method-10 (_type_ vector) float) ) ) @@ -113,21 +143,21 @@ (debug-last-point int32) ) (:methods - (tracking-spline-method-9 () none) - (tracking-spline-method-10 () none) - (tracking-spline-method-11 () none) - (tracking-spline-method-12 () none) - (tracking-spline-method-13 () none) - (tracking-spline-method-14 () none) - (tracking-spline-method-15 () none) - (tracking-spline-method-16 () none) - (tracking-spline-method-17 () none) - (tracking-spline-method-18 () none) - (tracking-spline-method-19 () none) - (tracking-spline-method-20 () none) - (tracking-spline-method-21 () none) - (tracking-spline-method-22 () none) - (tracking-spline-method-23 () none) + (tracking-spline-method-9 (_type_) none) + (tracking-spline-method-10 (_type_ vector) none) + (debug-point-info (_type_ int) none) + (debug-all-points (_type_) none) + (tracking-spline-method-13 (_type_ int) none) + (tracking-spline-method-14 (_type_ tracking-spline-sampler) none) + (tracking-spline-method-15 (_type_) none) + (tracking-spline-method-16 (_type_ float) none) + (tracking-spline-method-17 (_type_ vector float float symbol) int) + (tracking-spline-method-18 (_type_ float vector vector tracking-spline-sampler) vector) + (tracking-spline-method-19 (_type_ float vector vector tracking-spline-sampler) vector) + (tracking-spline-method-20 (_type_ vector int) none) + (tracking-spline-method-21 (_type_ vector float float float float vector) vector) + (tracking-spline-method-22 (_type_ float) symbol) + (debug-draw-spline (_type_) none) ) ) @@ -324,6 +354,9 @@ (tracking cam-rotation-tracker :inline) (fast-rot basic) ) + (:states + cam-combiner-active + ) ) @@ -464,12 +497,9 @@ (:methods (camera-master-method-14 (_type_ vector) vector) (camera-master-method-15 (_type_ vector) vector) - (camera-master-method-16 () none) + (camera-master-method-16 (_type_ symbol) int) + ) + (:states + cam-master-active ) ) - -(define-extern cam-slave-go (function (state camera-slave) none :behavior camera-slave)) -(define-extern cam-slave-init (function (state camera-slave) entity none :behavior camera-slave)) -(define-extern cam-standard-event-handler (function process int symbol event-message-block object :behavior camera-slave)) -(define-extern cam-calc-follow! (function cam-rotation-tracker vector symbol vector)) -(define-extern slave-set-rotation! (function cam-rotation-tracker vector cam-slave-options-u32 float symbol none)) \ No newline at end of file diff --git a/goal_src/jak3/engine/camera/camera.gc b/goal_src/jak3/engine/camera/camera.gc index bbd282bf7ac..f094a459b66 100644 --- a/goal_src/jak3/engine/camera/camera.gc +++ b/goal_src/jak3/engine/camera/camera.gc @@ -7,3 +7,1981 @@ ;; DECOMP BEGINS +(defun cam-slave-get-vector-with-offset ((arg0 entity-actor) (arg1 vector) (arg2 symbol)) + (local-vars (s3-0 structure)) + (cond + ((= arg2 'trans) + (set! s3-0 (-> arg0 trans)) + ) + ((= arg2 'rot) + (set! s3-0 (-> arg0 quat)) + ) + (else + (set! s3-0 (res-lump-struct arg0 arg2 vector)) + ) + ) + (let* ((s2-0 (method-of-type res-lump get-property-struct)) + (v1-8 arg2) + (a0-8 + (the-as + vector + (s2-0 + arg0 + (cond + ((= v1-8 'trans) + 'trans-offset + ) + ((= v1-8 'pivot) + 'pivot-offset + ) + ((= v1-8 'align) + 'align-offset + ) + ((= v1-8 'interesting) + 'interesting-offset + ) + (else + (format 0 "WARNING: cam-slave-get-vector-with-offset has been passed an unknown symbol ~A.~%" arg2) + #f + ) + ) + 'interp + -1000000000.0 + (the-as structure #f) + (the-as (pointer res-tag) #f) + *res-static-buf* + ) + ) + ) + ) + (cond + ((and s3-0 a0-8) + (vector+! arg1 (the-as vector s3-0) a0-8) + #t + ) + (s3-0 + (set! (-> arg1 quad) (-> (the-as vector s3-0) quad)) + #t + ) + (else + #f + ) + ) + ) + ) + +;; WARN: Return type mismatch uint128 vs uint. +(defun cam-slave-get-flags ((arg0 entity) (arg1 symbol)) + (let* ((s5-0 (res-lump-value arg0 arg1 uint128 :time -1000000000.0)) + (s3-0 (method-of-type res-lump get-property-value)) + (s2-0 arg0) + (v1-2 arg1) + (s3-1 (s3-0 + s2-0 + (cond + ((= v1-2 'flags) + 'flags-on + ) + ((= v1-2 'focalpull-flags) + 'focalpull-flags-on + ) + ((= v1-2 'campoints-flags) + 'campoints-flags-on + ) + (else + (format 0 "WARNING: cam-slave-get-flags has been passed an unknown symbol ~A.~%" arg1) + #f + ) + ) + 'interp + -1000000000.0 + (the-as uint128 0) + (the-as (pointer res-tag) #f) + *res-static-buf* + ) + ) + (s2-1 (method-of-type res-lump get-property-value)) + (v1-4 arg1) + (v1-5 (s2-1 + arg0 + (cond + ((= v1-4 'flags) + 'flags-off + ) + ((= v1-4 'focalpull-flags) + 'focalpull-flags-off + ) + ((= v1-4 'campoints-flags) + 'campoints-flags-off + ) + (else + (format 0 "WARNING: cam-slave-get-flags has been passed an unknown symbol ~A.~%" arg1) + #f + ) + ) + 'interp + -1000000000.0 + (the-as uint128 0) + (the-as (pointer res-tag) #f) + *res-static-buf* + ) + ) + ) + (the-as uint (logclear (logior s5-0 s3-1) v1-5)) + ) + ) + +(defun cam-slave-get-float ((arg0 entity) (arg1 symbol) (arg2 float)) + (let ((f30-0 (res-lump-float arg0 arg1 :default arg2)) + (s4-0 (method-of-type res-lump get-property-value-float)) + (v1-3 arg1) + ) + (+ f30-0 + (s4-0 + arg0 + (cond + ((= v1-3 'intro-exitValue) + 'intro-exitValue-offset + ) + ((= v1-3 'stringMinHeight) + 'stringMinHeight-offset + ) + ((= v1-3 'stringMaxHeight) + 'stringMaxHeight-offset + ) + ((= v1-3 'stringMinLength) + 'stringMinLength-offset + ) + ((= v1-3 'stringMaxLength) + 'stringMaxLength-offset + ) + ((= v1-3 'stringCliffHeight) + 'stringCliffHeight-offset + ) + ((= v1-3 'tiltAdjust) + 'tiltAdjust-offset + ) + ((= v1-3 'spline-follow-dist) + 'spline-follow-dist-offset + ) + ((= v1-3 'maxAngle) + 'maxAngle-offset + ) + ((= v1-3 'focalpull) + 'focuspull-offset + ) + (else + (format 0 "WARNING: cam-slave-get-float has been passed an unknown symbol ~A #x~X.~%" arg1 arg1) + #f + ) + ) + 'interp + -1000000000.0 + 0.0 + (the-as (pointer res-tag) #f) + *res-static-buf* + ) + ) + ) + ) + +(defun cam-slave-get-fov ((arg0 entity)) + (let ((f30-0 (res-lump-float arg0 'fov)) + (f0-0 (res-lump-float arg0 'fov-offset)) + ) + (if (= f30-0 0.0) + (+ 11650.845 f0-0) + (+ f30-0 f0-0) + ) + ) + ) + +(defun cam-slave-get-intro-step ((arg0 entity)) + (let ((f0-1 (+ (res-lump-float arg0 'intro-time) (res-lump-float arg0 'intro-time-offset)))) + (if (>= 0.0 f0-1) + 0.004166667 + (/ 0.016666668 f0-1) + ) + ) + ) + +(defun cam-slave-get-interp-time ((arg0 entity)) + (let ((f0-1 (the-as number (+ (res-lump-float arg0 'interpTime) (res-lump-float arg0 'interpTime-offset))))) + (if (>= 0.001 (the-as float f0-1)) + (set! f0-1 0.0) + ) + (the-as float f0-1) + ) + ) + +(defun cam-slave-get-rot ((arg0 entity-actor) (arg1 matrix)) + (let ((a1-2 (res-lump-struct arg0 'rot-offset structure))) + (cond + (a1-2 + (let ((s4-0 (new 'stack-no-clear 'quaternion))) + (quaternion*! s4-0 (the-as quaternion a1-2) (-> arg0 quat)) + (quaternion-normalize! s4-0) + (quaternion->matrix arg1 s4-0) + ) + ) + (else + (quaternion->matrix arg1 (-> arg0 quat)) + ) + ) + ) + arg1 + ) + +(defun cam-state-from-entity ((arg0 entity)) + (let ((s5-0 (new 'stack 'curve))) + (cond + ((not arg0) + (the-as (state camera-slave) #f) + ) + ((res-lump-struct arg0 'pivot structure) + cam-circular + ) + ((res-lump-struct arg0 'align structure) + cam-standoff-read-entity + ) + ((get-curve-data! arg0 s5-0 'campath 'campath-k -1000000000.0) + (if (logtest? (cam-slave-get-flags arg0 'flags) 4) + cam-tube-sled + cam-spline + ) + ) + ((< 0.0 (cam-slave-get-float arg0 'stringMaxLength 0.0)) + cam-string + ) + (else + cam-fixed-read-entity + ) + ) + ) + ) + +(defun parameter-ease-none ((arg0 object)) + arg0 + ) + +(defun parameter-ease-clamp ((arg0 float)) + (cond + ((>= arg0 1.0) + (set! arg0 1.0) + ) + ((>= 0.0 arg0) + (set! arg0 0.0) + ) + ) + arg0 + ) + +(defun parameter-ease-lerp-clamp ((arg0 float)) + (cond + ((>= arg0 1.0) + 1.0 + ) + ((>= 0.0 arg0) + 0.0 + ) + ((>= 0.25 arg0) + (* 0.5 arg0) + ) + ((>= arg0 0.75) + (- 1.0 (* 0.5 (- 1.0 arg0))) + ) + (else + (+ 0.125 (* 1.5 (+ -0.25 arg0))) + ) + ) + ) + +(defun parameter-ease-sqrt-clamp ((arg0 float)) + (cond + ((>= arg0 1.0) + 1.0 + ) + ((>= 0.0 arg0) + 0.0 + ) + ((>= 0.5 arg0) + (* 0.5 (- 1.0 (sqrtf (- 1.0 (* 2.0 arg0))))) + ) + (else + (* 0.5 (+ 1.0 (sqrtf (+ -1.0 (* 2.0 arg0))))) + ) + ) + ) + +(defun fourth-power ((arg0 float)) + (let ((f0-2 (* arg0 arg0))) + (* f0-2 f0-2) + ) + ) + +(defun third-power ((arg0 float)) + (* arg0 arg0 arg0) + ) + +(defun parameter-ease-sqr-clamp ((arg0 float)) + (cond + ((>= arg0 1.0) + 1.0 + ) + ((>= 0.0 arg0) + 0.0 + ) + ((>= 0.5 arg0) + (let ((f0-3 0.5) + (f1-4 (* 2.0 arg0)) + ) + (* f0-3 (* f1-4 f1-4)) + ) + ) + (else + (let ((f0-5 1.0) + (f1-7 0.5) + (f2-2 (* 2.0 (- 1.0 arg0))) + ) + (- f0-5 (* f1-7 (* f2-2 f2-2))) + ) + ) + ) + ) + +(defun parameter-ease-cube-clamp ((arg0 float)) + (cond + ((>= arg0 1.0) + 1.0 + ) + ((>= 0.0 arg0) + 0.0 + ) + ((>= 0.5 arg0) + (* 0.5 (third-power (* 2.0 arg0))) + ) + (else + (- 1.0 (* 0.5 (third-power (* 2.0 (- 1.0 arg0))))) + ) + ) + ) + +(defun parameter-ease-sin-clamp ((arg0 float)) + (cond + ((>= arg0 1.0) + 1.0 + ) + ((>= 0.0 arg0) + 0.0 + ) + (else + (+ 0.5 (* 0.5 (sin (* 182.04445 (+ -90.0 (* 180.0 arg0)))))) + ) + ) + ) + +(define *cam-res-string* (new 'global 'string 64 (the-as string #f))) + +(defmethod cam-index-method-9 ((this cam-index) (arg0 symbol) (arg1 entity) (arg2 vector) (arg3 curve)) + (local-vars (sv-32 (function _varargs_ object)) (sv-48 (function _varargs_ object))) + (let* ((s2-0 cam-slave-get-flags) + (s0-0 arg1) + (v1-0 arg0) + (a1-1 + (cond + ((= v1-0 'focalpull) + 'focalpull-flags + ) + ((= v1-0 'campoints) + 'campoints-flags + ) + (else + (set! sv-32 format) + (let ((a0-4 (clear *cam-res-string*)) + (a1-2 "~S-flags") + (a2-1 arg0) + ) + (sv-32 a0-4 a1-2 a2-1) + ) + (format 0 "WARNING: cam-index-init is using string->symbol to build symbol ~A at runtime.~%" *cam-res-string*) + (string->symbol *cam-res-string*) + ) + ) + ) + ) + (set! (-> this flags) (the-as cam-index-options (s2-0 s0-0 a1-1))) + ) + (let* ((s2-1 (res-lump-data arg1 arg0 pointer)) + (s0-1 (method-of-type res-lump get-property-struct)) + (v1-4 arg0) + (a1-5 + (cond + ((= v1-4 'focalpull) + 'focalpull-offset + ) + ((= v1-4 'campoints) + 'campoints-offset + ) + (else + (set! sv-48 format) + (let ((a0-12 (clear *cam-res-string*)) + (a1-6 "~S-offset") + ) + (sv-48 a0-12 a1-6 arg0) + ) + (format 0 "WARNING: cam-index-init is using string->symbol to build symbol ~A at runtime.~%" *cam-res-string*) + (string->symbol *cam-res-string*) + ) + ) + ) + (v0-10 + (s0-1 arg1 a1-5 'interp -1000000000.0 (the-as structure #f) (the-as (pointer res-tag) #f) *res-static-buf*) + ) + ) + (cond + (s2-1 + (cond + (v0-10 + (vector+! (the-as vector (-> this vec)) (the-as vector (&+ s2-1 0)) (the-as vector v0-10)) + (vector+! (-> this vec 1) (the-as vector (&+ s2-1 16)) (the-as vector v0-10)) + ) + (else + (set! (-> this vec 0 quad) (-> (the-as (pointer uint128) (&+ s2-1 0)))) + (set! (-> this vec 1 quad) (-> (the-as (pointer uint128) (&+ s2-1 16)))) + ) + ) + ) + (arg3 + (set! (-> this vec 0 quad) (-> arg3 cverts 0 quad)) + (set! (-> this vec 1 quad) (-> arg3 cverts (+ (-> arg3 num-cverts) -1) quad)) + ) + (else + (return #f) + ) + ) + ) + (let ((v1-14 (new-stack-vector0))) + 0.0 + (cond + ((logtest? (-> this flags) (cam-index-options RADIAL)) + (vector-! v1-14 (-> this vec 1) arg2) + (set! (-> this vec 1 w) (vector-length v1-14)) + (vector-! v1-14 (the-as vector (-> this vec)) arg2) + (set! (-> this vec 1 x) (vector-length v1-14)) + (set! (-> this vec 1 w) (- (-> this vec 1 w) (-> this vec 1 x))) + (set! (-> this vec 0 quad) (-> arg2 quad)) + ) + ((logtest? (-> this flags) (cam-index-options SPHERICAL)) + (vector-! v1-14 (-> this vec 1) arg2) + (set! (-> this vec 1 w) (vector-length v1-14)) + (vector-! v1-14 (the-as vector (-> this vec)) arg2) + (set! (-> this vec 1 x) (vector-length v1-14)) + (set! (-> this vec 1 w) (- (-> this vec 1 w) (-> this vec 1 x))) + (set! (-> this vec 0 quad) (-> arg2 quad)) + ) + (else + (vector-! (-> this vec 1) (-> this vec 1) (the-as vector (-> this vec))) + (set! (-> this vec 1 w) (vector-normalize-ret-len! (-> this vec 1) 1.0)) + ) + ) + ) + #t + ) + +(defmethod cam-index-method-10 ((this cam-index) (arg0 vector)) + (let ((s5-0 (new-stack-vector0))) + 0.0 + (vector-! s5-0 arg0 (the-as vector (-> this vec))) + (cond + ((logtest? (-> this flags) (cam-index-options RADIAL)) + (vector-flatten! s5-0 s5-0 (-> *camera* local-down)) + (/ (- (vector-length s5-0) (-> this vec 1 x)) (-> this vec 1 w)) + ) + ((logtest? (-> this flags) (cam-index-options SPHERICAL)) + (/ (- (vector-length s5-0) (-> this vec 1 x)) (-> this vec 1 w)) + ) + (else + (/ (vector-dot s5-0 (-> this vec 1)) (-> this vec 1 w)) + ) + ) + ) + ) + +(defmethod tracking-spline-method-10 ((this tracking-spline) (arg0 vector)) + (set! (-> this point 0 position quad) (-> arg0 quad)) + (set! (-> this point 0 next) -134250495) + (set! (-> this summed-len) 0.0) + (set! (-> this free-point) 1) + (set! (-> this used-point) 0) + (set! (-> this partial-point) 0.0) + (set! (-> this end-point) 0) + (set! (-> this next-to-last-point) -134250495) + (set! (-> this max-move) 0.0) + (set! (-> this sample-len) 0.0) + (set! (-> this used-count) 1) + (set! (-> this old-position quad) (-> arg0 quad)) + (let ((v1-6 1)) + (while (!= v1-6 31) + (set! (-> this point v1-6 next) (+ v1-6 1)) + (+! v1-6 1) + ) + (set! (-> this point v1-6 next) -134250495) + ) + 0 + (none) + ) + +(defmethod tracking-spline-method-13 ((this tracking-spline) (arg0 int)) + (let ((v1-3 (-> this point arg0 next))) + (cond + ((= v1-3 -134250495) + ) + ((= (-> this point v1-3 next) -134250495) + ) + (else + (set! (-> this point arg0 next) (-> this point v1-3 next)) + (set! (-> this summed-len) (- (-> this summed-len) (-> this point v1-3 tp-length))) + (set! (-> this point v1-3 next) (-> this free-point)) + (set! (-> this free-point) v1-3) + (+! (-> this point v1-3 incarnation) 1) + (let ((v1-11 (-> this point arg0 next))) + (set! (-> this summed-len) (- (-> this summed-len) (-> this point arg0 tp-length))) + (vector-! + (the-as vector (+ (the-as uint (-> this point 0 direction)) (* 48 arg0))) + (the-as vector (-> this point v1-11)) + (the-as vector (-> this point arg0)) + ) + ) + (set! (-> this point arg0 tp-length) + (vector-normalize-ret-len! (the-as vector (+ (the-as uint (-> this point 0 direction)) (* 48 arg0))) 1.0) + ) + (+! (-> this summed-len) (-> this point arg0 tp-length)) + (+! (-> this used-count) -1) + ) + ) + ) + 0 + (none) + ) + +(defmethod tracking-spline-method-14 ((this tracking-spline) (arg0 tracking-spline-sampler)) + (let ((v1-0 (-> this used-point))) + (set! (-> this partial-point) (-> arg0 partial-pt)) + (when (= (-> this next-to-last-point) v1-0) + (set! (-> this summed-len) (-> this point v1-0 tp-length)) + (if (= (-> arg0 cur-pt) (-> this end-point)) + (set! (-> this partial-point) 0.99999) + ) + ) + (when (!= (-> arg0 cur-pt) v1-0) + (while (and (!= (-> this point v1-0 next) (-> arg0 cur-pt)) + (!= (-> this point v1-0 next) (-> this next-to-last-point)) + ) + (set! (-> this summed-len) (- (-> this summed-len) (-> this point v1-0 tp-length))) + (+! (-> this point v1-0 incarnation) 1) + (+! (-> this used-count) -1) + (set! v1-0 (-> this point v1-0 next)) + ) + (set! (-> this summed-len) (- (-> this summed-len) (-> this point v1-0 tp-length))) + (+! (-> this point v1-0 incarnation) 1) + (+! (-> this used-count) -1) + (set! (-> this point v1-0 next) (-> this free-point)) + (set! (-> this free-point) (-> this used-point)) + (set! (-> this used-point) (-> arg0 cur-pt)) + (cond + ((= (-> arg0 cur-pt) (-> this end-point)) + (set! (-> this partial-point) 0.0) + (set! (-> this summed-len) 0.0) + ) + ((= (-> arg0 cur-pt) (-> this next-to-last-point)) + (set! (-> this summed-len) (-> this point (-> this next-to-last-point) tp-length)) + ) + ) + ) + ) + 0 + (none) + ) + +(defmethod tracking-spline-method-15 ((this tracking-spline)) + (let ((s5-0 (new 'stack-no-clear 'tracking-spline-sampler))) + (let ((a3-0 (new 'stack-no-clear 'vector))) + (set! (-> s5-0 cur-pt) (-> this used-point)) + (set! (-> s5-0 partial-pt) (-> this partial-point)) + (tracking-spline-method-19 this (-> this sample-len) a3-0 a3-0 s5-0) + ) + (if (or (= (-> s5-0 cur-pt) (-> this end-point)) + (= (-> s5-0 cur-pt) (-> this next-to-last-point)) + (= (-> this point (the-as int (-> s5-0 cur-pt)) next) (-> this next-to-last-point)) + ) + (set! (-> s5-0 cur-pt) (-> this used-point)) + ) + (let ((v1-15 (-> this point (the-as int (-> s5-0 cur-pt)) next))) + (when (!= v1-15 -134250495) + (let ((a0-14 (-> this point v1-15 next)) + (a1-1 v1-15) + (f0-2 -2.0) + ) + 0.0 + (while (not (or (= a0-14 -134250495) (= a0-14 (-> this end-point)))) + (let ((f1-2 (vector-dot + (the-as vector (+ (the-as uint (-> this point 0 direction)) (* 48 v1-15))) + (the-as vector (+ (the-as uint (-> this point 0 direction)) (* 48 a0-14))) + ) + ) + ) + (when (>= f1-2 f0-2) + (set! f0-2 f1-2) + (set! a1-1 v1-15) + ) + ) + (set! v1-15 a0-14) + (set! a0-14 (-> this point v1-15 next)) + ) + (if (< -2.0 f0-2) + (tracking-spline-method-13 this a1-1) + ) + ) + ) + ) + ) + 0 + (none) + ) + +(defmethod tracking-spline-method-16 ((this tracking-spline) (arg0 float)) + (let ((s4-0 (new 'stack-no-clear 'tracking-spline-sampler))) + (let ((a3-0 (new 'stack-no-clear 'tracking-spline-sampler))) + (set! (-> s4-0 cur-pt) (-> this used-point)) + (set! (-> s4-0 partial-pt) (-> this partial-point)) + (tracking-spline-method-19 this (-> this sample-len) (the-as vector a3-0) (the-as vector a3-0) s4-0) + ) + (let ((s4-1 (-> this point (-> s4-0 cur-pt) next))) + (when (!= s4-1 -134250495) + (let ((v1-11 (-> this point s4-1 next))) + (while (not (or (= v1-11 -134250495) + (= (-> this point v1-11 next) -134250495) + (= (-> this point v1-11 next) (-> this end-point)) + (= (-> this point v1-11 next) (-> this next-to-last-point)) + ) + ) + (if (< (* (-> this point s4-1 tp-length) + (+ 1.0 (vector-dot + (the-as vector (+ (the-as uint (-> this point 0 direction)) (* 48 s4-1))) + (the-as vector (+ (the-as uint (-> this point 0 direction)) (* 48 v1-11))) + ) + ) + ) + arg0 + ) + (tracking-spline-method-13 this s4-1) + (set! s4-1 v1-11) + ) + (set! v1-11 (-> this point s4-1 next)) + ) + ) + ) + ) + ) + 0 + (none) + ) + +(defmethod tracking-spline-method-17 ((this tracking-spline) (arg0 vector) (arg1 float) (arg2 float) (arg3 symbol)) + (let ((s3-0 (-> this free-point)) + (s2-0 (-> this end-point)) + ) + (vector-! + (the-as vector (+ (the-as uint (-> this point 0 direction)) (* 48 s2-0))) + arg0 + (the-as vector (-> this point s2-0)) + ) + (set! (-> this point s2-0 tp-length) + (vector-normalize-ret-len! (the-as vector (+ (the-as uint (-> this point 0 direction)) (* 48 s2-0))) 1.0) + ) + (if (< (-> this point s2-0 tp-length) arg1) + (return 0) + ) + (when (and arg3 (= s3-0 -134250495)) + (tracking-spline-method-15 this) + (set! s3-0 (-> this free-point)) + ) + (cond + ((= s3-0 -134250495) + (format 0 "ERROR : pos spline overflow~%") + ) + (else + (+! (-> this summed-len) (-> this point s2-0 tp-length)) + (set! (-> this free-point) (-> this point s3-0 next)) + (set! (-> this point s2-0 next) s3-0) + (set! (-> this end-point) s3-0) + (set! (-> this next-to-last-point) s2-0) + (set! (-> this point s3-0 next) -134250495) + (set! (-> this point s3-0 position quad) (-> arg0 quad)) + (+! (-> this used-count) 1) + (if (< 0.0 arg2) + (tracking-spline-method-16 this arg2) + ) + ) + ) + ) + 0 + ) + +;; WARN: new jak 2 until loop case, check carefully +(defmethod tracking-spline-method-18 ((this tracking-spline) (arg0 float) (arg1 vector) (arg2 vector) (arg3 tracking-spline-sampler)) + (local-vars (f0-4 float)) + (when (not arg3) + (set! arg3 (new 'stack-no-clear 'tracking-spline-sampler)) + (set! (-> arg3 cur-pt) (-> this used-point)) + (set! (-> arg3 partial-pt) (-> this partial-point)) + ) + 0.0 + (until #f + (cond + ((= (-> arg3 cur-pt) (-> this end-point)) + (set! (-> arg3 partial-pt) 0.0) + (vector+! arg1 arg1 (the-as vector (-> this point (-> arg3 cur-pt)))) + (return arg1) + ) + ((begin (set! f0-4 (+ (-> arg3 partial-pt) (/ arg0 (-> this point (-> arg3 cur-pt) tp-length)))) (< f0-4 1.0)) + (set! (-> arg3 partial-pt) f0-4) + (let ((s2-0 (new 'stack-no-clear 'vector))) + (let ((v1-13 (-> this point (-> arg3 cur-pt) next))) + (vector-lerp! + s2-0 + (the-as vector (-> this point (-> arg3 cur-pt))) + (the-as vector (-> this point v1-13)) + f0-4 + ) + ) + (vector+! arg1 arg1 s2-0) + ) + (vector+! arg2 arg2 (the-as vector (+ (the-as uint (-> this point 0 direction)) (* 48 (-> arg3 cur-pt))))) + (return arg1) + ) + (else + (let ((f0-7 (* (- 1.0 (-> arg3 partial-pt)) (-> this point (-> arg3 cur-pt) tp-length)))) + (set! arg0 (- arg0 f0-7)) + ) + (set! (-> arg3 partial-pt) 0.0) + (set! (-> arg3 cur-pt) (-> this point (-> arg3 cur-pt) next)) + ) + ) + ) + #f + (the-as vector #f) + ) + +(defmethod tracking-spline-method-19 ((this tracking-spline) (arg0 float) (arg1 vector) (arg2 vector) (arg3 tracking-spline-sampler)) + (vector-reset! arg1) + (vector-reset! arg2) + (tracking-spline-method-18 this arg0 arg1 arg2 arg3) + arg1 + ) + +(defmethod tracking-spline-method-20 ((this tracking-spline) (arg0 vector) (arg1 int)) + (let ((s3-0 (new 'stack-no-clear 'vector))) + (vector-! + s3-0 + (the-as vector (-> this point (-> this used-point))) + (the-as vector (-> this point (-> this end-point))) + ) + (let* ((f0-0 (vector-length s3-0)) + (f1-1 (* 0.33333334 (- 1.5 (* 0.00024414062 f0-0)))) + ) + 0.0 + (let* ((f1-2 (fmax 0.0 f1-1)) + (f30-0 (+ 0.3 f1-2)) + (f0-1 (cond + ((< (-> *CAMERA-bank* min-detectable-velocity) (-> this summed-len)) + (vector-float*! s3-0 s3-0 (/ 1.0 f0-0)) + (/ f0-0 (-> this summed-len)) + ) + (else + (vector-reset! s3-0) + 0.0 + ) + ) + ) + (f0-2 (+ -0.2 f0-1)) + (f0-3 (* 2.0 f0-2)) + (f28-0 (fmin 1.0 (fmax 0.05 f0-3))) + (v1-18 (-> this used-point)) + (s2-0 (new 'stack-no-clear 'vector)) + ) + (while (and (!= v1-18 (-> this end-point)) (!= v1-18 (-> this next-to-last-point)) (!= v1-18 arg1)) + (let ((s1-0 (-> this point v1-18 next))) + (vector-! + s2-0 + (the-as vector (+ (the-as uint (-> this point 0 direction)) (* 48 s1-0))) + (the-as vector (+ (the-as uint (-> this point 0 direction)) (* 48 v1-18))) + ) + (let* ((f0-5 (vector-normalize-ret-len! s2-0 1.0)) + (f0-6 (* 0.5 f0-5)) + (f26-0 (* (fmin 1.0 f0-6) f30-0 (vector-dot arg0 s2-0))) + ) + (let ((f1-14 (vector-dot s2-0 s3-0))) + (cond + ((>= 0.0 f1-14) + ) + (else + (set! f26-0 (* f26-0 (fmax 0.0 (- 0.75 (fabs (* f28-0 f1-14)))))) + ) + ) + ) + (cond + ((< f26-0 0.0) + (if (and *debug-segment* *display-camera-marks*) + (camera-line-rel-len + (the-as vector (-> this point s1-0)) + s2-0 + (* -40.96 f26-0) + (new 'static 'vector4w :x #xff :y #xff :w #x80) + ) + ) + (vector--float*! arg0 arg0 s2-0 f26-0) + ) + ((and *debug-segment* *display-camera-marks*) + (camera-line-rel-len + (the-as vector (-> this point s1-0)) + s2-0 + (* 40.96 f26-0) + (new 'static 'vector4w :x #x80 :y #x80 :w #x80) + ) + ) + ) + ) + (set! v1-18 s1-0) + ) + ) + ) + ) + ) + 0 + (none) + ) + +(defmethod tracking-spline-method-21 ((this tracking-spline) (arg0 vector) (arg1 float) (arg2 float) (arg3 float) (arg4 float) (arg5 vector)) + (with-pp + (let ((v1-0 (-> this used-point)) + (f0-0 (-> this partial-point)) + ) + (let ((f1-0 (-> this summed-len))) + 0.0 + 0.0 + (let* ((f2-6 (* (- (- f1-0 (* f0-0 (-> this point v1-0 tp-length))) arg4) arg3)) + (f2-9 (* (fmin arg1 (- f2-6 (-> this max-move))) (-> pp clock time-adjust-ratio))) + ) + (set! (-> this max-move) (fmin arg2 (+ (-> this max-move) f2-9))) + ) + ) + (set! (-> this max-move) (fmax 0.0 (-> this max-move))) + (let ((f1-9 (-> this summed-len))) + 0.0 + (let* ((f1-10 (- f1-9 (* f0-0 (-> this point v1-0 tp-length)))) + (f1-12 (fmin 204.8 (- f1-10 (-> this sample-len)))) + ) + (set! (-> this sample-len) (fmin 16384.0 (+ (-> this sample-len) f1-12))) + ) + ) + (let ((s3-0 (new 'stack-no-clear 'tracking-spline-sampler))) + (set! (-> s3-0 cur-pt) v1-0) + (set! (-> s3-0 partial-pt) f0-0) + (if (not arg5) + (set! arg5 (new 'static 'vector)) + ) + (tracking-spline-method-19 this (* (-> this max-move) (-> pp clock time-adjust-ratio)) arg0 arg5 s3-0) + (tracking-spline-method-14 this s3-0) + (dotimes (s2-0 63) + (tracking-spline-method-18 this (* 0.015625 (-> this sample-len)) arg0 arg5 s3-0) + ) + (vector-float*! arg0 arg0 0.015625) + (vector-float*! arg5 arg5 0.015625) + (let ((a2-3 (-> s3-0 cur-pt))) + (set! (-> this debug-last-point) a2-3) + (let ((s4-1 (new 'stack-no-clear 'vector))) + (set! (-> this debug-old-position quad) (-> this old-position quad)) + (set! (-> this debug-out-position quad) (-> arg0 quad)) + (vector-! s4-1 arg0 (-> this old-position)) + (tracking-spline-method-20 this s4-1 a2-3) + (vector+! arg0 (-> this old-position) s4-1) + ) + ) + ) + ) + (set! (-> this old-position quad) (-> arg0 quad)) + arg0 + ) + ) + +;; WARN: Return type mismatch int vs symbol. +(defmethod tracking-spline-method-22 ((this tracking-spline) (arg0 float)) + (when (< arg0 (-> this summed-len)) + (let ((s5-0 (new 'stack-no-clear 'tracking-spline-sampler))) + (let ((a3-0 (new 'stack-no-clear 'vector))) + (set! (-> s5-0 cur-pt) (-> this used-point)) + (set! (-> s5-0 partial-pt) 0.0) + (tracking-spline-method-19 this (- (-> this summed-len) arg0) a3-0 a3-0 s5-0) + ) + (tracking-spline-method-14 this s5-0) + ) + ) + (the-as symbol 0) + ) + +(defmethod tracking-spline-method-9 ((this tracking-spline)) + (let ((v1-0 (-> this used-point)) + (s4-0 0) + (s5-0 0) + ) + (while (!= v1-0 -134250495) + (set! s5-0 (logior s5-0 (ash 1 v1-0))) + (+! s4-0 1) + (set! v1-0 (-> this point v1-0 next)) + ) + (when (!= s4-0 (-> this used-count)) + (if *debug-segment* + (format 0 "ERROR: tracking spline used count ~D actual ~D~%" (-> this used-count) s4-0) + ) + (set! (-> this used-count) s4-0) + ) + (let ((v1-9 (-> this free-point)) + (a3-1 0) + ) + (while (!= v1-9 -134250495) + (+! a3-1 1) + (set! v1-9 (-> this point v1-9 next)) + ) + (when (!= a3-1 (- 32 (-> this used-count))) + (if *debug-segment* + (format 0 "ERROR: tracking spline free count ~D actual ~D~%" (- 32 (-> this used-count)) a3-1) + ) + (set! (-> this free-point) -134250495) + (dotimes (v1-21 32) + (when (not (logtest? s5-0 1)) + (set! (-> this point v1-21 next) (-> this free-point)) + (set! (-> this free-point) v1-21) + ) + (set! s5-0 (shr s5-0 1)) + ) + ) + ) + ) + 0 + (none) + ) + +;; WARN: Return type mismatch quaternion vs none. +(defbehavior cam-slave-init-vars camera-slave () + (cond + (*camera* + (set! (-> self options) (-> *camera* slave-options)) + ) + (else + (set! (-> self options) (cam-slave-options-u32)) + 0 + ) + ) + (cond + (*camera-combiner* + (set! (-> self trans quad) (-> *camera-combiner* trans quad)) + (let* ((v1-7 (-> self tracking)) + (a3-0 (-> *camera-combiner* inv-camera-rot)) + (a0-1 (-> a3-0 rvec quad)) + (a1-0 (-> a3-0 uvec quad)) + (a2-0 (-> a3-0 fvec quad)) + (a3-1 (-> a3-0 trans quad)) + ) + (set! (-> v1-7 inv-mat rvec quad) a0-1) + (set! (-> v1-7 inv-mat uvec quad) a1-0) + (set! (-> v1-7 inv-mat fvec quad) a2-0) + (set! (-> v1-7 inv-mat trans quad) a3-1) + ) + (when *camera-init-mat* + (let* ((a2-1 (-> self tracking)) + (a3-2 *camera-init-mat*) + (v1-10 (-> a3-2 rvec quad)) + (a0-2 (-> a3-2 uvec quad)) + (a1-1 (-> a3-2 fvec quad)) + (a3-3 (-> a3-2 trans quad)) + ) + (set! (-> a2-1 inv-mat rvec quad) v1-10) + (set! (-> a2-1 inv-mat uvec quad) a0-2) + (set! (-> a2-1 inv-mat fvec quad) a1-1) + (set! (-> a2-1 inv-mat trans quad) a3-3) + ) + ) + (set! (-> self fov) (-> *camera-combiner* fov)) + (set! (-> self velocity quad) (-> *camera-combiner* velocity quad)) + ) + (else + (vector-reset! (-> self trans)) + (matrix-identity! (the-as matrix (-> self tracking))) + (set! (-> self fov) 11650.845) + (vector-reset! (-> self velocity)) + ) + ) + (set! (-> self time-dist-too-far) (the-as uint 0)) + (set! (-> self intro-t) 1.0) + (set! (-> self intro-t-step) 0.0) + (set! (-> self spline-exists) #f) + (set! (-> self los-state) (slave-los-state none)) + (set! (-> self enter-has-run) #f) + (set! (-> self cam-entity) #f) + (set! (-> self tracking no-follow) #f) + (init (-> self tracking tilt-adjust) (-> *CAMERA-bank* default-tilt-adjust) 9.102222 91.022224 0.25) + (init + (-> self tracking follow-height-extra) + (-> *setting-control* cam-current extra-follow-height) + 81.92 + 819.2 + 0.5 + ) + (set! (-> self tracking follow-blend) 1.0) + (set! (-> self have-phony-joystick) #f) + (set! (-> self string-val-locked) #f) + (set! (-> self string-relative) #f) + (set! (-> self butt-timer) 0) + (set! (-> self butt-seek) #f) + (init (-> self tracking point-of-interest-blend) 0.0 0.005 0.02 0.125) + (init (-> self tracking underwater-blend) 0.0 0.007 0.03 0.125) + (tracking-spline-method-10 (-> self position-spline) (-> self trans)) + (init (-> self slope-adjust) 0.0 0.001 0.01 0.9) + (quaternion-identity! (-> self slope-quat)) + (none) + ) + +(defbehavior cam-slave-go camera-slave ((arg0 (state camera-slave))) + (cam-slave-init-vars) + (go arg0) + 0 + (none) + ) + +(defbehavior cam-slave-init camera-slave ((arg0 (state camera-slave)) (arg1 entity)) + (stack-size-set! (-> self main-thread) 512) + (if (and (nonzero? camera-slave-debug) *debug-segment*) + (add-connection *debug-engine* self camera-slave-debug self #f #f) + ) + (cam-slave-init-vars) + (set! (-> self cam-entity) arg1) + (let ((t9-3 (-> arg0 enter))) + (if t9-3 + (t9-3) + ) + ) + (set! (-> self enter-has-run) #t) + (set! (-> self event-hook) (-> arg0 event)) + (go arg0) + 0 + (none) + ) + +(defbehavior cam-standard-event-handler camera-slave ((arg0 process) (arg1 int) (arg2 symbol) (arg3 event-message-block)) + (case arg2 + (('go) + (format 0 "ERROR : slave cameras no longer support the 'go' event~%") + ) + (('change-state) + (let ((gp-0 (the-as object (-> arg3 param 0)))) + (cam-slave-init-vars) + (let ((t9-2 (-> (the-as (state camera-slave) gp-0) enter))) + (if t9-2 + (t9-2) + ) + ) + (set! (-> self enter-has-run) #t) + (set! (-> self event-hook) (-> (the-as (state camera-slave) gp-0) event)) + (go (the-as (state camera-slave) gp-0)) + ) + ) + (('teleport) + (jump-to-target! (-> self tracking point-of-interest-blend) 0.0) + (cam-calc-follow! (-> self tracking) (-> self trans) #f) + (slave-set-rotation! (-> self tracking) (-> self trans) (-> self options) (-> self fov) #f) + ) + ) + ) + +(defbehavior cam-curve-pos camera-slave ((arg0 vector) (arg1 vector) (arg2 curve) (arg3 symbol)) + (let ((s5-0 (new-stack-vector0))) + 0.0 + (let ((s2-0 (new-stack-vector0))) + (if arg1 + (set! (-> arg1 w) 0.0) + ) + (when (< (-> self intro-t) 1.0) + (+! (-> self intro-t) (* (-> self intro-t-step) (-> self clock time-adjust-ratio))) + (if (< 1.0 (-> self intro-t)) + (set! (-> self intro-t) 1.0) + ) + (curve-get-pos! s5-0 (parameter-ease-sin-clamp (-> self intro-t)) (-> self intro-curve)) + (vector+! s5-0 s5-0 (-> self intro-offset)) + (vector+! arg0 arg0 s5-0) + (cond + ((not arg1) + ) + ((< (-> self intro-t) 0.5) + (curve-get-pos! s2-0 (+ 0.0001 (parameter-ease-sin-clamp (-> self intro-t))) (-> self intro-curve)) + (vector+! s2-0 s2-0 (-> self intro-offset)) + (vector-! arg1 s2-0 s5-0) + (set! (-> arg1 w) 1.0) + ) + (else + (curve-get-pos! s2-0 (+ -0.0001 (parameter-ease-sin-clamp (-> self intro-t))) (-> self intro-curve)) + (vector+! s2-0 s2-0 (-> self intro-offset)) + (vector-! arg1 s5-0 s2-0) + (set! (-> arg1 w) 1.0) + ) + ) + ) + ) + (cond + ((not (-> self spline-exists)) + ) + ((= (-> self spline-follow-dist) 0.0) + (let ((f0-18 (if arg3 + (cam-index-method-10 (-> self index) (-> self tracking follow-pt)) + (cam-index-method-10 (-> self index) (-> *camera* tpos-curr-adj)) + ) + ) + ) + (if (logtest? (cam-slave-options-u32 EASE_SPLINE_IDX) (-> self options)) + (set! f0-18 (parameter-ease-sin-clamp f0-18)) + ) + (curve-get-pos! s5-0 f0-18 (-> self spline-curve)) + ) + (vector+! s5-0 s5-0 (-> self spline-offset)) + (vector+! arg0 arg0 s5-0) + ) + (else + (let ((s3-1 (new 'stack-no-clear 'vector))) + (curve-length (-> self spline-curve)) + (if arg3 + (set! (-> s3-1 quad) (-> self tracking follow-pt quad)) + (set! (-> s3-1 quad) (-> *camera* tpos-curr-adj quad)) + ) + (let ((f0-22 + (curve-closest-point (-> self spline-curve) s3-1 (-> self spline-tt) 40960.0 10 (-> self spline-follow-dist)) + ) + ) + (set! (-> self spline-tt) (fmin 1.0 f0-22)) + ) + ) + (curve-get-pos! s5-0 (-> self spline-tt) (-> self spline-curve)) + (vector+! s5-0 s5-0 (-> self spline-offset)) + (vector+! arg0 arg0 s5-0) + ) + ) + ) + arg0 + ) + +(defbehavior cam-curve-setup camera-slave ((arg0 vector)) + (when (get-curve-data! (-> self cam-entity) (-> self spline-curve) 'campath 'campath-k -1000000000.0) + (curve-get-pos! (-> self spline-offset) 0.0 (-> self spline-curve)) + (vector-negate! (-> self spline-offset) (-> self spline-offset)) + (cam-index-method-9 (-> self index) 'campoints (-> self cam-entity) arg0 (-> self spline-curve)) + (set! (-> self spline-exists) #t) + ) + (cond + ((get-curve-data! (-> self cam-entity) (-> self intro-curve) 'intro 'intro-k -1000000000.0) + (curve-get-pos! (-> self intro-offset) 1.0 (-> self intro-curve)) + (vector-negate! (-> self intro-offset) (-> self intro-offset)) + (set! (-> self intro-t) 0.0) + (set! (-> self intro-t-step) (cam-slave-get-intro-step (-> self cam-entity))) + (set! (-> self outro-exit-value) (cam-slave-get-float (-> self cam-entity) 'intro-exitValue 0.0)) + (if (= (-> self outro-exit-value) 0.0) + (set! (-> self outro-exit-value) 0.5) + ) + ) + (else + (set! (-> self intro-t) 1.0) + (set! (-> self intro-t-step) 0.0) + ) + ) + (if (-> *camera* settings no-intro) + (set! (-> self intro-t) 1.0) + ) + 0 + (none) + ) + +;; ERROR: Stack slot load at 144 mismatch: defined as size 4, got size 16 +;; ERROR: Stack slot load at 160 mismatch: defined as size 4, got size 16 +;; ERROR: Stack slot load at 144 mismatch: defined as size 4, got size 16 +;; ERROR: Stack slot load at 160 mismatch: defined as size 4, got size 16 +;; ERROR: Stack slot load at 144 mismatch: defined as size 4, got size 16 +;; ERROR: Stack slot load at 160 mismatch: defined as size 4, got size 16 +;; ERROR: Stack slot load at 144 mismatch: defined as size 4, got size 16 +;; ERROR: Stack slot load at 160 mismatch: defined as size 4, got size 16 +;; ERROR: Stack slot load at 144 mismatch: defined as size 4, got size 16 +;; ERROR: Stack slot load at 160 mismatch: defined as size 4, got size 16 +;; ERROR: Stack slot load at 144 mismatch: defined as size 4, got size 16 +;; ERROR: Stack slot load at 160 mismatch: defined as size 4, got size 16 +;; ERROR: Stack slot load at 144 mismatch: defined as size 4, got size 16 +;; ERROR: Stack slot load at 160 mismatch: defined as size 4, got size 16 +(defun cam-calc-follow! ((arg0 cam-rotation-tracker) (arg1 vector) (arg2 symbol)) + (local-vars (sv-128 (function float float float float)) (sv-144 float) (sv-160 float)) + (with-pp + (cond + (arg2 + (update! (-> arg0 tilt-adjust) 0.0) + (update! (-> arg0 point-of-interest-blend) 0.0) + (update! (-> arg0 underwater-blend) 0.0) + ) + (else + (set! (-> arg0 old-cam-trans quad) (-> arg1 quad)) + (jump-to-target! (-> arg0 tilt-adjust) 0.0) + (jump-to-target! (-> arg0 point-of-interest-blend) 0.0) + (jump-to-target! (-> arg0 underwater-blend) 0.0) + ) + ) + (set! (-> arg0 follow-height-extra target) (-> *camera* settings extra-follow-height)) + (let ((s4-0 (new 'stack-no-clear 'vector))) + (set! (-> s4-0 quad) (-> arg0 follow-pt quad)) + (cond + ((logtest? (-> *camera* settings slave-options) (cam-slave-options BIKE_MODE)) + (let ((s1-0 (new 'stack-no-clear 'vector)) + (s0-0 (new 'stack-no-clear 'vector)) + (f30-0 (vector-vector-distance (-> *camera* tpos-curr-adj) (-> *camera* tpos-old-adj))) + (s2-0 (new 'stack-no-clear 'vector)) + ) + (vector-flatten! s1-0 (-> *camera* tgt-face-mat fvec) (-> *camera* local-down)) + (vector-normalize! s1-0 1.0) + (vector-! s0-0 (-> *camera* tpos-curr-adj) arg1) + (vector-flatten! s0-0 s0-0 (-> *camera* local-down)) + (vector-normalize! s0-0 1.0) + (vector-float*! s2-0 (-> *camera* tgt-face-mat fvec) 32768.0) + (set! sv-128 lerp-clamp) + (set! sv-144 (the-as float 0.7)) + (set! sv-160 (the-as float 0.4)) + (let* ((a2-3 (parameter-ease-sin-clamp (* 0.00081380206 (+ -409.6 f30-0)))) + (f30-1 (sv-128 sv-144 sv-160 a2-3)) + (f0-7 (acos (vector-dot s0-0 s1-0))) + (f28-0 (fmax 1820.4445 f0-7)) + ) + (if (< f28-0 8192.0) + (vector-float*! + s2-0 + s2-0 + (+ f30-1 + (* (/ (- 1.0 f30-1) (- 1.0 (cos 32768.0))) (+ (- (cos 32768.0)) (cos (* 5.142857 (- 8192.0 f28-0))))) + ) + ) + ) + ) + (cond + ((< (-> *camera* ease-t) 1.0) + ) + ((< (-> arg0 follow-blend) 1.0) + (let* ((f0-21 (-> arg0 follow-blend)) + (f0-22 (* f0-21 f0-21)) + (f0-23 (* f0-22 f0-22)) + ) + (vector-! s2-0 s2-0 (-> arg0 follow-off)) + (vector-float*! s2-0 s2-0 f0-23) + ) + (+! (-> arg0 follow-blend) (* 0.016666668 (-> pp clock time-adjust-ratio))) + (vector+! (-> arg0 follow-off) (-> arg0 follow-off) s2-0) + ) + (else + (set! (-> arg0 follow-off quad) (-> s2-0 quad)) + ) + ) + ) + (cond + (arg2 + (if (logtest? (cam-slave-options VERTICAL_FOLLOW_MATCHES_CAMERA) (-> *camera* settings slave-options)) + (set! (-> arg0 follow-height-extra vel) 0.0) + (update! (-> arg0 follow-height-extra) 0.0) + ) + ) + (else + (jump-to-target! (-> arg0 follow-height-extra) 0.0) + ) + ) + (vector+! (-> arg0 follow-pt) (-> *camera* tpos-curr-adj) (-> arg0 follow-off)) + (vector--float*! + (-> arg0 follow-pt) + (-> arg0 follow-pt) + (-> *camera* local-down) + (+ (-> arg0 follow-height-extra value) (-> *camera* settings target-height)) + ) + ) + (else + 0.0 + (let ((s2-1 (new-stack-vector0))) + (set! (-> arg0 follow-blend) 0.0) + (cond + ((-> arg0 no-follow) + (vector-reset! s2-1) + ) + (else + (vector-! s2-1 (-> *camera* tpos-curr-adj) arg1) + (vector-normalize! s2-1 1.0) + (let* ((f0-32 (vector-dot (-> *camera* tgt-rot-mat fvec) s2-1)) + (f30-2 (cond + ((< f0-32 0.0) + 1.0 + ) + (else + (let* ((f0-33 (* f0-32 f0-32)) + (f0-34 (- 1.0 f0-33)) + ) + (* f0-34 (* f0-34 f0-34)) + ) + ) + ) + ) + ) + (vector-! s2-1 arg1 (-> *camera* tpos-curr-adj)) + (vector-flatten! s2-1 s2-1 (-> *camera* local-down)) + (let* ((f1-15 (* 0.000022194603 (+ -20480.0 (vector-length s2-1)))) + (f0-37 (fmax 0.0 (fmin 1.0 f1-15))) + ) + (vector-float*! s2-1 (-> *camera* tgt-rot-mat fvec) (* (lerp 2048.0 8192.0 f0-37) f30-2)) + ) + ) + ) + ) + (cond + (arg2 + (vector-seek-3d-smooth! (-> arg0 follow-off) s2-1 (* 20480.0 (seconds-per-frame)) 0.05) + (if (logtest? (cam-slave-options VERTICAL_FOLLOW_MATCHES_CAMERA) (-> *camera* settings slave-options)) + (set! (-> arg0 follow-height-extra vel) 0.0) + (update! (-> arg0 follow-height-extra) 0.0) + ) + ) + (else + (set! (-> arg0 follow-off quad) (-> s2-1 quad)) + (jump-to-target! (-> arg0 follow-height-extra) 0.0) + ) + ) + ) + (vector+! (-> arg0 follow-pt) (-> *camera* tpos-curr-adj) (-> arg0 follow-off)) + (vector--float*! + (-> arg0 follow-pt) + (-> arg0 follow-pt) + (-> *camera* local-down) + (+ (-> arg0 follow-height-extra value) (-> *camera* settings target-height)) + ) + ) + ) + (when (and arg2 (logtest? (cam-slave-options VERTICAL_FOLLOW_MATCHES_CAMERA) (-> *camera* settings slave-options))) + (let ((f0-46 + (vector-dot (-> *camera* local-down) (vector-! (new 'stack-no-clear 'vector) arg1 (-> arg0 old-cam-trans))) + ) + (f1-20 + (vector-dot (-> *camera* local-down) (vector-! (new 'stack-no-clear 'vector) (-> arg0 follow-pt) s4-0)) + ) + ) + (vector--float*! (-> arg0 follow-pt) (-> arg0 follow-pt) (-> *camera* local-down) (- f1-20 f0-46)) + ) + (vector+float*! + (-> arg0 follow-off) + (-> arg0 follow-pt) + (-> *camera* local-down) + (+ (-> arg0 follow-height-extra value) (-> *camera* settings target-height)) + ) + (vector-! (-> arg0 follow-off) (-> arg0 follow-off) (-> *camera* tpos-curr-adj)) + ) + ) + (set! (-> arg0 old-cam-trans quad) (-> arg1 quad)) + (-> arg0 follow-pt) + ) + ) + +(defun mat-remove-z-rot ((arg0 matrix) (arg1 vector)) + (let ((s4-0 (new-stack-vector0))) + 0.0 + 0.0 + (let ((s5-0 (new 'stack-no-clear 'matrix))) + (set! (-> s5-0 rvec quad) (the-as uint128 0)) + (set! (-> s5-0 uvec quad) (the-as uint128 0)) + (set! (-> s5-0 fvec quad) (the-as uint128 0)) + (set! (-> s5-0 trans quad) (the-as uint128 0)) + (vector-negate! s4-0 arg1) + (vector-flatten! s4-0 s4-0 (-> arg0 fvec)) + (vector-normalize! s4-0 1.0) + (let ((f0-3 (vector-dot (-> arg0 uvec) s4-0))) + (when (< f0-3 0.99999) + (vector-cross! s4-0 (-> arg0 uvec) s4-0) + (let ((f1-1 (vector-length s4-0))) + (if (< 0.0 (vector-dot s4-0 (-> arg0 fvec))) + (set! f1-1 (- f1-1)) + ) + (matrix-axis-sin-cos! s5-0 (-> arg0 fvec) f1-1 f0-3) + ) + (matrix*! arg0 arg0 s5-0) + ) + ) + ) + ) + arg0 + ) + +(defun slave-matrix-blend-2 ((arg0 matrix) (arg1 cam-slave-options-u32) (arg2 vector) (arg3 matrix)) + (with-pp + (let ((s1-0 (new-stack-vector0)) + (s4-0 (new-stack-quaternion0)) + ) + (let ((s2-0 (new-stack-quaternion0)) + (gp-0 (new-stack-quaternion0)) + ) + 0.0 + (let* ((f0-1 (cond + ((logtest? arg1 (cam-slave-options-u32 MOVE_SPHERICAL)) + (vector-length arg2) + ) + (else + (vector-flatten! s1-0 arg2 (-> *camera* local-down)) + (vector-length s1-0) + ) + ) + ) + (f0-3 (* 0.00048828125 (+ -1024.0 f0-1))) + ) + (cond + ((< f0-3 0.0) + (set! f0-3 0.0) + ) + ((< 1.0 f0-3) + (set! f0-3 1.0) + ) + ) + (let ((f30-0 (* f0-3 (* (-> *setting-control* cam-current matrix-blend-max-angle) (-> pp clock time-adjust-ratio)))) + ) + (matrix->quaternion s4-0 arg0) + (matrix->quaternion s2-0 arg3) + (quaternion-conjugate! gp-0 s4-0) + (quaternion*! gp-0 gp-0 s2-0) + (quaternion-normalize! gp-0) + (if (< (-> gp-0 w) 0.0) + (quaternion-negate! gp-0 gp-0) + ) + (let ((f28-0 (acos (-> gp-0 w)))) + (if (< (* f28-0 (-> *setting-control* cam-current matrix-blend-max-partial) (-> pp clock time-adjust-ratio)) + f30-0 + ) + (set! f30-0 + (* f28-0 (-> *setting-control* cam-current matrix-blend-max-partial) (-> pp clock time-adjust-ratio)) + ) + ) + (cond + ((< (-> gp-0 w) 0.9999999) + (quaternion-float*! gp-0 gp-0 (/ (sin f30-0) (sin f28-0))) + (set! (-> gp-0 w) (cos f30-0)) + ) + (else + (quaternion-identity! gp-0) + ) + ) + ) + ) + ) + (quaternion*! s4-0 s4-0 gp-0) + ) + (quaternion-normalize! s4-0) + (quaternion->matrix arg0 s4-0) + ) + ) + ) + +;; WARN: Return type mismatch int vs vector. +(defun vector-into-frustum-nosmooth! ((arg0 matrix) (arg1 vector) (arg2 float)) + (local-vars (sv-112 vector) (sv-128 vector) (sv-144 vector) (sv-160 vector) (sv-176 vector)) + (rlet ((vf0 :class vf) + (vf1 :class vf) + (vf2 :class vf) + ) + (init-vf0-vector) + (let ((s5-0 (new 'stack-no-clear 'matrix))) + (set! (-> s5-0 rvec quad) (the-as uint128 0)) + (set! (-> s5-0 uvec quad) (the-as uint128 0)) + (set! (-> s5-0 fvec quad) (the-as uint128 0)) + (set! (-> s5-0 trans quad) (the-as uint128 0)) + (let ((s3-0 (new-stack-vector0)) + (s2-0 (new-stack-vector0)) + ) + 0.0 + 0.0 + (let ((f30-0 1.0) + (s4-0 #t) + ) + 0.0 + (vector-! s3-0 (-> *camera* tpos-curr) arg1) + (let ((f26-0 (vector-length s3-0))) + (vector-flatten! s3-0 s3-0 (-> arg0 uvec)) + (vector-normalize! s3-0 1.0) + (let ((f28-0 (vector-dot s3-0 (-> arg0 rvec)))) + (set! sv-128 s2-0) + (set! sv-112 (-> arg0 rvec)) + (let ((f0-7 (* 0.8 (tan (* 0.5 arg2))))) + (.lvf vf1 (&-> sv-112 quad)) + (let ((v1-11 f0-7)) + (.mov vf2 v1-11) + ) + ) + (.add.x.vf vf1 vf0 vf0 :mask #b1000) + (.mul.x.vf vf1 vf1 vf2 :mask #b111) + (.svf (&-> sv-128 quad) vf1) + (vector+! s2-0 s2-0 (-> arg0 fvec)) + (vector-normalize! s2-0 f26-0) + (vector--float*! s2-0 s2-0 (-> arg0 rvec) 6144.0) + (vector-normalize! s2-0 1.0) + (let ((f0-9 (fmax 0.0 (vector-dot s2-0 (-> arg0 rvec))))) + (when (< f0-9 (fabs f28-0)) + (if (< f28-0 0.0) + (vector--float*! s2-0 s2-0 (-> arg0 rvec) (* 2.0 f0-9)) + ) + (matrix-from-two-vectors! s5-0 s2-0 s3-0) + (vector-matrix*! (-> arg0 fvec) (-> arg0 fvec) s5-0) + (vector-cross! (-> arg0 rvec) (-> arg0 uvec) (-> arg0 fvec)) + ) + ) + ) + ) + (vector-! s3-0 (-> *camera* tpos-curr) (-> *camera* pitch-off)) + (vector-! s3-0 s3-0 arg1) + (vector--float*! s3-0 s3-0 (-> *camera* local-down) (-> *camera* settings foot-offset)) + (vector-flatten! s3-0 s3-0 (-> arg0 rvec)) + (vector-normalize! s3-0 1.0) + (let ((f28-1 (vector-dot s3-0 (-> arg0 uvec)))) + (set! sv-160 s2-0) + (set! sv-144 (-> arg0 uvec)) + (let ((f0-16 (* 0.525 (tan (* 0.5 arg2))))) + (.lvf vf1 (&-> sv-144 quad)) + (let ((v1-32 f0-16)) + (.mov vf2 v1-32) + ) + ) + (.add.x.vf vf1 vf0 vf0 :mask #b1000) + (.mul.x.vf vf1 vf1 vf2 :mask #b111) + (.svf (&-> sv-160 quad) vf1) + (vector+! s2-0 s2-0 (-> arg0 fvec)) + (vector-normalize! s2-0 1.0) + (let ((f0-18 (vector-dot s2-0 (-> arg0 uvec)))) + (when (and (< f28-1 0.0) (< f0-18 (- f28-1))) + (vector--float*! s2-0 s2-0 (-> arg0 uvec) (* 2.0 f0-18)) + (set! f30-0 (vector-dot s2-0 s3-0)) + ) + ) + ) + (vector-! s3-0 (-> *camera* tpos-curr) (-> *camera* pitch-off)) + (vector-! s3-0 s3-0 arg1) + (vector--float*! s3-0 s3-0 (-> *camera* local-down) (-> *camera* settings head-offset)) + (vector-flatten! s3-0 s3-0 (-> arg0 rvec)) + (vector-normalize! s3-0 1.0) + (let ((f28-2 (vector-dot s3-0 (-> arg0 uvec)))) + (let ((s0-1 s2-0)) + (set! sv-176 (-> arg0 uvec)) + (let ((f0-26 (* 0.525 (tan (* 0.5 arg2))))) + (vector-float*! s0-1 sv-176 f0-26) + ) + ) + (vector+! s2-0 s2-0 (-> arg0 fvec)) + (vector-normalize! s2-0 1.0) + (let ((f0-28 (vector-dot s2-0 (-> arg0 uvec)))) + (cond + ((and (< 0.0 f28-2) (< f0-28 f28-2)) + (set! f30-0 (vector-dot s2-0 s3-0)) + (set! s4-0 #f) + ) + ((< f30-0 0.0) + (let ((f0-33 (- (vector-dot s2-0 s3-0)))) + (if (< f0-33 f30-0) + (set! f30-0 f0-33) + ) + ) + ) + ) + ) + ) + (let ((f0-35 (if s4-0 + (- (acos f30-0)) + (acos f30-0) + ) + ) + ) + (matrix-axis-angle! s5-0 (-> arg0 rvec) f0-35) + ) + ) + ) + (vector-matrix*! (-> arg0 fvec) (-> arg0 fvec) s5-0) + ) + (vector-cross! (-> arg0 uvec) (-> arg0 fvec) (-> arg0 rvec)) + (the-as vector 0) + ) + ) + +;; 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] +(defun slave-set-rotation! ((arg0 cam-rotation-tracker) (arg1 vector) (arg2 cam-slave-options-u32) (arg3 float) (arg4 symbol)) + (local-vars + (f0-9 float) + (sv-208 vector) + (sv-224 vector) + (sv-240 matrix) + (sv-256 (function matrix vector float vector)) + (sv-272 matrix) + (sv-288 vector) + ) + (rlet ((vf0 :class vf) + (vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + ) + (init-vf0-vector) + (if (-> *camera* settings use-look-at-point) + (set! (-> arg0 follow-pt quad) (-> *camera* settings look-at-point quad)) + ) + (let ((s0-0 (new-stack-vector0)) + (s1-0 (new 'stack-no-clear 'matrix)) + ) + (set! (-> s1-0 rvec quad) (the-as uint128 0)) + (set! (-> s1-0 uvec quad) (the-as uint128 0)) + (set! (-> s1-0 fvec quad) (the-as uint128 0)) + (set! (-> s1-0 trans quad) (the-as uint128 0)) + (let ((f30-0 (-> arg0 tilt-adjust value))) + (cond + ((< 0.0001 (-> arg0 point-of-interest-blend value)) + (set! sv-208 (new 'stack-no-clear 'vector)) + 0.0 + (vector-! s0-0 (-> arg0 follow-pt) arg1) + (let ((f28-0 (vector-length s0-0))) + (vector-! sv-208 (-> *camera* settings point-of-interest) arg1) + (vector-normalize! sv-208 (* f28-0 (-> arg0 point-of-interest-blend value))) + (let ((v1-12 s0-0)) + (let ((a0-10 s0-0)) + (.mov.vf vf6 vf0 :mask #b1000) + (.lvf vf4 (&-> a0-10 quad)) + ) + (.lvf vf5 (&-> sv-208 quad)) + (.add.vf vf6 vf4 vf5 :mask #b111) + (.svf (&-> v1-12 quad) vf6) + ) + (vector-normalize! s0-0 f28-0) + ) + (vector-! (-> arg0 looking-interesting) (-> *camera* settings point-of-interest) (-> arg0 follow-pt)) + (vector+float*! + (-> arg0 looking-interesting) + (-> arg0 follow-pt) + (-> arg0 looking-interesting) + (-> arg0 point-of-interest-blend value) + ) + ) + (else + (vector-! s0-0 (-> arg0 follow-pt) arg1) + (set! (-> arg0 looking-interesting quad) (-> arg1 quad)) + ) + ) + (vector+! (-> arg0 looking-at) s0-0 arg1) + (forward-down->inv-matrix s1-0 s0-0 (-> *camera* local-down)) + (when (!= f30-0 0.0) + 0.0 + 0.0 + (set! sv-240 (new 'stack-no-clear 'matrix)) + (set! sv-224 (new 'stack-no-clear 'vector)) + (vector-normalize-copy! sv-224 s0-0 1.0) + (let* ((v1-25 (-> *camera* local-down)) + ; (f0-8 (-> sv-224 x)) + ; (f1-1 (-> sv-224 y)) + ; (f2-0 (-> sv-224 z)) + ; (f3-0 (-> v1-25 x)) + ; (f4-0 (-> v1-25 y)) + ; (f5-0 (-> v1-25 z)) + ) + ;; og:preserve-this vector-dot + ; (.mula.s f0-8 f3-0) + ; (.madda.s f1-1 f4-0) + ; (.madd.s f0-9 f2-0 f5-0) + (set! f0-9 (vector-dot v1-25 sv-224)) + ) + (let* ((f28-1 f0-9) + (f0-11 (acos (fabs f28-1))) + ) + (cond + ((< 0.0 f30-0) + (set! f30-0 (if (< 0.0 f28-1) + (fmin f30-0 (fmax 0.0 (+ -2730.6667 f0-11))) + (fmin f30-0 (fmax 0.0 (- 32768.0 (+ 2730.6667 f0-11)))) + ) + ) + ) + ((< f30-0 0.0) + (set! f30-0 (if (< 0.0 f28-1) + (fmax f30-0 (- (fmax 0.0 (- 32768.0 (+ 2730.6667 f0-11))))) + (fmax f30-0 (- (fmax 0.0 (+ -2730.6667 f0-11)))) + ) + ) + ) + ) + ) + (matrix-rotate-x! sv-240 f30-0) + (let ((t9-6 matrix*!) + (a0-28 s1-0) + (a2-3 s1-0) + ) + (t9-6 a0-28 sv-240 a2-3) + ) + ) + ) + (when (not (-> *camera* settings use-look-at-point)) + (if (and (= (-> *camera* under-water) 2) + *target* + (not (and (-> *target* next-state) (= (-> *target* next-state name) 'target-swim-up))) + ) + (set! (-> arg0 underwater-blend target) 1.0) + (set! (-> arg0 underwater-blend target) 0.0) + ) + ) + (set! sv-256 vector-into-frustum-nosmooth!) + (set! sv-272 s1-0) + (set! sv-288 arg1) + (let ((a2-5 (lerp-clamp arg3 (* 0.25 arg3) (-> arg0 underwater-blend value)))) + (sv-256 sv-272 sv-288 a2-5) + ) + (cond + (arg4 + (slave-matrix-blend-2 (-> arg0 inv-mat) arg2 s0-0 s1-0) + ) + (else + (let* ((v1-60 (-> arg0 inv-mat)) + (a3-2 s1-0) + (a0-34 (-> a3-2 rvec quad)) + (a1-19 (-> a3-2 uvec quad)) + (a2-7 (-> a3-2 fvec quad)) + (a3-3 (-> a3-2 trans quad)) + ) + (set! (-> v1-60 rvec quad) a0-34) + (set! (-> v1-60 uvec quad) a1-19) + (set! (-> v1-60 fvec quad) a2-7) + (set! (-> v1-60 trans quad) a3-3) + ) + ) + ) + ) + (mat-remove-z-rot (-> arg0 inv-mat) (-> *camera* local-down)) + (cond + ((not (-> *camera* settings use-point-of-interest)) + (set! (-> arg0 point-of-interest-blend target) 0.0) + ) + (else + (let ((s4-2 (vector-! (new 'stack-no-clear 'vector) (-> *camera* settings point-of-interest) arg1))) + 0.0 + (vector-flatten! s4-2 s4-2 (-> arg0 inv-mat uvec)) + (vector-normalize! s4-2 1.0) + (let ((f30-1 (vector-dot s4-2 (-> arg0 inv-mat fvec)))) + (cond + ((< (cos 12743.111) f30-1) + (set! (-> arg0 point-of-interest-blend target) 1.0) + ) + ((and (< 0.0 (-> arg0 point-of-interest-blend target)) (< (cos 8192.0) f30-1)) + (set! (-> arg0 point-of-interest-blend target) 1.0) + ) + (else + (set! (-> arg0 point-of-interest-blend target) 0.0) + ) + ) + ) + ) + ) + ) + 0 + (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] +(defun v-slrp2! ((arg0 vector) (arg1 vector) (arg2 vector) (arg3 float) (arg4 vector) (arg5 float)) + (local-vars + (f0-10 float) + (f28-0 float) + (f30-0 float) + (sv-144 float) + (sv-160 vector) + (sv-176 matrix) + (sv-192 vector) + ) + (set! sv-144 arg5) + (let ((s0-0 (new-stack-vector0))) + (set! sv-160 (new 'stack-no-clear 'vector)) + (set! (-> sv-160 quad) (the-as uint128 0)) + 1.0 + 1.0 + (let ((s3-0 (new-stack-vector0))) + 0.0 + 1.0 + (set! sv-176 (new 'stack-no-clear 'matrix)) + (set! (-> sv-176 rvec quad) (the-as uint128 0)) + (set! (-> sv-176 uvec quad) (the-as uint128 0)) + (set! (-> sv-176 fvec quad) (the-as uint128 0)) + (set! (-> sv-176 trans quad) (the-as uint128 0)) + (cond + ((< 1.0 arg3) + (set! arg3 1.0) + ) + ((< arg3 0.0) + (set! arg3 0.0) + ) + ) + (cond + (arg4 + (vector-flatten! s0-0 arg1 arg4) + (vector-flatten! sv-160 arg2 arg4) + (set! f30-0 (vector-normalize-ret-len! s0-0 1.0)) + (set! f28-0 (vector-normalize-ret-len! sv-160 1.0)) + (vector-normalize! (vector-cross! s3-0 sv-160 s0-0) 1.0) + (let ((f26-0 (vector-dot arg4 s3-0))) + (vector-normalize-copy! s3-0 arg4 1.0) + (if (< f26-0 0.0) + (vector-negate! s3-0 s3-0) + ) + ) + ) + (else + (set! (-> s0-0 quad) (-> arg1 quad)) + (set! (-> sv-160 quad) (-> arg2 quad)) + (set! f30-0 (vector-normalize-ret-len! s0-0 1.0)) + (set! f28-0 (vector-normalize-ret-len! sv-160 1.0)) + (vector-normalize! (vector-cross! s3-0 arg2 arg1) 1.0) + ) + ) + (let ((t9-10 acos)) + (let* ((v1-22 s0-0) + ; (f0-9 (-> v1-22 x)) + ; (f1-2 (-> v1-22 y)) + ; (f2-0 (-> v1-22 z)) + ; (f3-0 (-> sv-160 x)) + ; (f4-0 (-> sv-160 y)) + ; (f5-0 (-> sv-160 z)) + ) + ;; og:preserve-this vector-dot + ; (.mula.s f0-9 f3-0) + ; (.madda.s f1-2 f4-0) + ; (.madd.s f0-10 f2-0 f5-0) + (set! f0-10 (vector-dot v1-22 sv-160)) + ) + (let* ((f1-3 (t9-10 f0-10)) + (f0-12 (* arg3 f1-3)) + ) + (when (< sv-144 f0-12) + (set! f0-12 sv-144) + (set! arg3 (/ sv-144 f1-3)) + ) + (let* ((f0-13 (cos f0-12)) + (t9-12 matrix-axis-sin-cos!) + (a0-20 sv-176) + (a1-13 s3-0) + (f1-5 1.0) + (f2-3 f0-13) + ) + (t9-12 a0-20 a1-13 (sqrtf (- f1-5 (* f2-3 f2-3))) f0-13) + ) + ) + ) + (vector-matrix*! arg0 s0-0 sv-176) + (let ((s0-1 vector-normalize!)) + (set! sv-192 arg0) + (let ((a1-16 (lerp f30-0 f28-0 arg3))) + (s0-1 sv-192 a1-16) + ) + ) + (when arg4 + (vector+float*! arg0 arg0 s3-0 (vector-dot arg1 s3-0)) + (vector+float*! arg0 arg0 s3-0 (* arg3 (vector-dot (vector-! (new-stack-vector0) arg2 arg1) s3-0))) + ) + ) + ) + arg0 + ) + +;; 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] +(defun v-slrp3! ((arg0 vector) (arg1 vector) (arg2 vector) (arg3 vector) (arg4 float)) + (local-vars (f0-7 float) (f26-0 float) (f28-0 float) (sv-144 float) (sv-160 vector)) + (set! sv-144 arg4) + (let ((s1-0 (new-stack-vector0))) + (set! sv-160 (new 'stack-no-clear 'vector)) + (set! (-> sv-160 quad) (the-as uint128 0)) + 0.0 + 0.0 + (let ((s3-0 (new-stack-vector0)) + (f30-0 1.0) + ) + 0.0 + (let ((s0-0 (new 'stack-no-clear 'matrix))) + (set! (-> s0-0 rvec quad) (the-as uint128 0)) + (set! (-> s0-0 uvec quad) (the-as uint128 0)) + (set! (-> s0-0 fvec quad) (the-as uint128 0)) + (set! (-> s0-0 trans quad) (the-as uint128 0)) + (cond + (arg3 + (vector-flatten! s1-0 arg1 arg3) + (vector-flatten! sv-160 arg2 arg3) + (set! f28-0 (vector-normalize-ret-len! s1-0 1.0)) + (set! f26-0 (vector-normalize-ret-len! sv-160 1.0)) + (vector-normalize! (vector-cross! s3-0 sv-160 s1-0) 1.0) + (let ((f24-0 (vector-dot arg3 s3-0))) + (vector-normalize-copy! s3-0 arg3 1.0) + (if (< f24-0 0.0) + (vector-negate! s3-0 s3-0) + ) + ) + ) + (else + (set! (-> s1-0 quad) (-> arg1 quad)) + (set! (-> sv-160 quad) (-> arg2 quad)) + (set! f28-0 (vector-normalize-ret-len! s1-0 1.0)) + (set! f26-0 (vector-normalize-ret-len! sv-160 1.0)) + (vector-normalize! (vector-cross! s3-0 arg2 arg1) 1.0) + ) + ) + (let ((t9-10 acos)) + (let* ((v1-10 s1-0) + ; (f0-6 (-> v1-10 x)) + ; (f1-0 (-> v1-10 y)) + ; (f2-0 (-> v1-10 z)) + ; (f3-0 (-> sv-160 x)) + ; (f4-0 (-> sv-160 y)) + ; (f5-0 (-> sv-160 z)) + ) + ;; og:preserve-this vector-dot + ; (.mula.s f0-6 f3-0) + ; (.madda.s f1-0 f4-0) + ; (.madd.s f0-7 f2-0 f5-0) + (set! f0-7 (vector-dot v1-10 sv-160)) + ) + (let ((f0-8 (t9-10 f0-7))) + (when (< sv-144 f0-8) + (set! f30-0 (/ sv-144 f0-8)) + (set! f0-8 sv-144) + ) + (let* ((f0-9 (cos f0-8)) + (t9-12 matrix-axis-sin-cos!) + (a0-20 s0-0) + (a1-13 s3-0) + (f1-3 1.0) + (f2-1 f0-9) + ) + (t9-12 a0-20 a1-13 (sqrtf (- f1-3 (* f2-1 f2-1))) f0-9) + ) + ) + ) + (vector-matrix*! arg0 s1-0 s0-0) + ) + (vector-normalize! arg0 (lerp f28-0 f26-0 f30-0)) + (when arg3 + (vector+float*! arg0 arg0 s3-0 (vector-dot arg1 s3-0)) + (vector+float*! arg0 arg0 s3-0 (* f30-0 (vector-dot (vector-! (new-stack-vector0) arg2 arg1) s3-0))) + ) + ) + ) + arg0 + ) diff --git a/goal_src/jak3/engine/collide/find-nearest-h.gc b/goal_src/jak3/engine/collide/find-nearest-h.gc index e255805b402..a5da0e8204c 100644 --- a/goal_src/jak3/engine/collide/find-nearest-h.gc +++ b/goal_src/jak3/engine/collide/find-nearest-h.gc @@ -5,5 +5,7 @@ ;; name in dgo: find-nearest-h ;; dgos: GAME +(define-extern find-nearest-focusable (function (array collide-shape) vector float search-info-flag search-info-flag vector vector float process-focusable)) + ;; DECOMP BEGINS diff --git a/goal_src/jak3/engine/common-obs/collectables.gc b/goal_src/jak3/engine/common-obs/collectables.gc index 2d16c97c11b..4c99de329b9 100644 --- a/goal_src/jak3/engine/common-obs/collectables.gc +++ b/goal_src/jak3/engine/common-obs/collectables.gc @@ -911,28 +911,21 @@ :virtual #t :code (behavior () (logclear! (-> self mask) (process-mask actor-pause)) - (new 'stack 'trajectory) - (set! (-> self base y) (-> self jump-pos y)) - (let ((t9-1 (method-of-type trajectory trajectory-method-12))) - (-> self root trans) - (-> self jump-pos) - #x43960000 - -1072586060 - (t9-1) - ) - (set-time! (-> self state-time)) - (until (time-elapsed? (-> self state-time) (seconds 1)) - (the float (- (current-time) (-> self state-time))) - (let ((t9-2 (method-of-type trajectory trajectory-method-9))) - (-> self root trans) - (t9-2) - ) - (transform-post) - (common-post self) - (suspend) - (if (nonzero? (-> self skel)) - (ja :num! (loop! 0.5)) + (let ((gp-0 (new 'stack 'trajectory))) + (set! (-> self base y) (-> self jump-pos y)) + (setup-from-to-duration! gp-0 (-> self root trans) (-> self jump-pos) 300.0 -2.2755556) + (set-time! (-> self state-time)) + (until (time-elapsed? (-> self state-time) (seconds 1)) + (let ((f0-2 (the float (- (current-time) (-> self state-time))))) + (compute-trans-at-time gp-0 f0-2 (-> self root trans)) ) + (transform-post) + (common-post self) + (suspend) + (if (nonzero? (-> self skel)) + (ja :num! (loop! 0.5)) + ) + ) ) (set! (-> self root trans quad) (-> self jump-pos quad)) (set! (-> self base quad) (-> self root trans quad)) diff --git a/goal_src/jak3/engine/common-obs/generic-obs.gc b/goal_src/jak3/engine/common-obs/generic-obs.gc index f3312713c64..a6fdc29555e 100644 --- a/goal_src/jak3/engine/common-obs/generic-obs.gc +++ b/goal_src/jak3/engine/common-obs/generic-obs.gc @@ -3792,11 +3792,7 @@ (go-virtual die) ) (('reset) - (-> self sync) - (let ((t9-1 (method-of-type sync-linear sync-info-method-15))) - 0 - (t9-1) - ) + (sync-now! (-> self sync) 0.0) ) (('play) (sound-play-by-name (-> self spawn-sound) (new-sound-id) 1024 0 0 (sound-group) (-> self pos)) diff --git a/goal_src/jak3/engine/gfx/background/tie/tie-work.gc b/goal_src/jak3/engine/gfx/background/tie/tie-work.gc index e243b065b2a..1f4a6b66e71 100644 --- a/goal_src/jak3/engine/gfx/background/tie/tie-work.gc +++ b/goal_src/jak3/engine/gfx/background/tie/tie-work.gc @@ -5,5 +5,7 @@ ;; name in dgo: tie-work ;; dgos: GAME +(define-extern *instance-tie-work* instance-tie-work) + ;; DECOMP BEGINS diff --git a/goal_src/jak3/engine/gfx/shrub/shrub-work.gc b/goal_src/jak3/engine/gfx/shrub/shrub-work.gc index 0214ed1c810..0949c41213f 100644 --- a/goal_src/jak3/engine/gfx/shrub/shrub-work.gc +++ b/goal_src/jak3/engine/gfx/shrub/shrub-work.gc @@ -5,5 +5,7 @@ ;; name in dgo: shrub-work ;; dgos: GAME +(define-extern *instance-shrub-work* instance-shrub-work) + ;; DECOMP BEGINS diff --git a/goal_src/jak3/engine/gfx/shrub/shrubbery-h.gc b/goal_src/jak3/engine/gfx/shrub/shrubbery-h.gc index de7a49b9d25..1e28f9dddf0 100644 --- a/goal_src/jak3/engine/gfx/shrub/shrubbery-h.gc +++ b/goal_src/jak3/engine/gfx/shrub/shrubbery-h.gc @@ -5,6 +5,8 @@ ;; name in dgo: shrubbery-h ;; dgos: GAME +(define-extern shrub-make-perspective-matrix (function matrix matrix matrix)) + ;; DECOMP BEGINS (deftype billboard (drawable) diff --git a/goal_src/jak3/engine/level/bsp-h.gc b/goal_src/jak3/engine/level/bsp-h.gc index abe185f40f2..f1d6a49e06f 100644 --- a/goal_src/jak3/engine/level/bsp-h.gc +++ b/goal_src/jak3/engine/level/bsp-h.gc @@ -62,6 +62,8 @@ This probably started as a very simple structure, but now it is extremely compli (actor-birth-order (pointer uint32) :offset 172) (region-trees (array drawable-tree-region-prim) :offset 188) (collide-hash collide-hash :offset 196) + (vis-spheres vector-array :offset 216) + (vis-spheres-length uint32 :offset 248) (tfrag-masks texture-masks-array :offset 256) (tfrag-closest (pointer float)) (tfrag-mask-count uint32 :overlay-at tfrag-closest) diff --git a/goal_src/jak3/engine/level/level-h.gc b/goal_src/jak3/engine/level/level-h.gc index 2757b3de141..7cbe2996ead 100644 --- a/goal_src/jak3/engine/level/level-h.gc +++ b/goal_src/jak3/engine/level/level-h.gc @@ -403,7 +403,7 @@ (level-method-13 () none) (compute-memory-usage! (_type_ symbol) memory-usage-block) (level-method-15 () none) - (level-method-16 () none) + (update-vis! (_type_ level-vis-info uint (pointer uint8)) symbol) (level-method-17 () none) (level-method-18 () none) (level-method-19 () none) @@ -471,7 +471,7 @@ (level-group-method-16 () none) (level-group-method-17 () none) (level-group-method-18 () none) - (level-group-method-19 () none) + (level-update (_type_) none) (level-get-target-inside (_type_) level) (level-group-method-21 () none) (art-group-get-by-name (_type_ string (pointer level)) art-group) diff --git a/goal_src/jak3/engine/nav/nav-control-h.gc b/goal_src/jak3/engine/nav/nav-control-h.gc index eafc08fe729..177ac40cb15 100644 --- a/goal_src/jak3/engine/nav/nav-control-h.gc +++ b/goal_src/jak3/engine/nav/nav-control-h.gc @@ -179,7 +179,7 @@ (:methods (nav-control-method-9 () none) (nav-control-method-10 () none) - (nav-control-method-11 () none) + (find-poly-containing-point-1 (_type_ vector) nav-poly) (nav-control-method-12 () none) (nav-control-method-13 () none) (nav-control-method-14 () none) diff --git a/goal_src/jak3/engine/physics/trajectory-h.gc b/goal_src/jak3/engine/physics/trajectory-h.gc index 8c155bfa974..8c609e31e48 100644 --- a/goal_src/jak3/engine/physics/trajectory-h.gc +++ b/goal_src/jak3/engine/physics/trajectory-h.gc @@ -14,15 +14,15 @@ (gravity meters) ) (:methods - (trajectory-method-9 () none) - (trajectory-method-10 () none) - (trajectory-method-11 () none) - (trajectory-method-12 () none) - (trajectory-method-13 () none) - (trajectory-method-14 () none) - (trajectory-method-15 () none) - (trajectory-method-16 () none) - (trajectory-method-17 () none) + (compute-trans-at-time (_type_ float vector) vector) + (compute-transv-at-time (_type_ float vector) vector) + (compute-time-until-apex (_type_) float) + (setup-from-to-duration! (_type_ vector vector float float) none) + (setup-from-to-xz-vel! (_type_ vector vector float float) none) + (setup-from-to-y-vel! (_type_ vector vector float float) none) + (setup-from-to-height! (_type_ vector vector float float) none) + (setup-from-to-duration-and-height! (_type_ vector vector float float) none) + (debug-draw (_type_) none) ) ) @@ -39,7 +39,7 @@ (:methods (new (symbol type process-drawable int float collide-spec) _type_) (initialize (_type_ process-drawable int float collide-spec) impact-control) - (impact-control-method-10 () none) + (update-from-cspace (_type_) none) (impact-control-method-11 (_type_ collide-query process pat-surface) float) ) ) @@ -66,7 +66,7 @@ (:methods (new (symbol type vector vector) _type_) (initialize (_type_ vector vector) point-tracker) - (point-tracker-method-10 () none) + (point-tracker-method-10 (_type_ vector vector vector float) vector) (point-tracker-method-11 (_type_ vector vector vector float) vector) ) ) @@ -118,12 +118,13 @@ (deftype cubic-curve (structure) ((mat matrix :inline) + (vec vector 4 :inline :overlay-at (-> mat data 0)) ) (:methods - (cubic-curve-method-9 () none) - (cubic-curve-method-10 () none) - (cubic-curve-method-11 () none) - (cubic-curve-method-12 () none) - (cubic-curve-method-13 () none) + (cubic-curve-method-9 (_type_ vector vector vector vector) none) + (cubic-curve-method-10 (_type_ vector float) vector) + (cubic-curve-method-11 (_type_ vector float) vector) + (cubic-curve-method-12 (_type_ vector float) vector) + (debug-draw-curve (_type_) none) ) ) diff --git a/goal_src/jak3/engine/physics/trajectory.gc b/goal_src/jak3/engine/physics/trajectory.gc index 2e0929f19cc..442d31f5c39 100644 --- a/goal_src/jak3/engine/physics/trajectory.gc +++ b/goal_src/jak3/engine/physics/trajectory.gc @@ -7,3 +7,511 @@ ;; DECOMP BEGINS +(defmethod compute-trans-at-time ((this trajectory) (arg0 float) (arg1 vector)) + (vector+float*! arg1 (-> this initial-position) (-> this initial-velocity) arg0) + (+! (-> arg1 y) (* 0.5 arg0 arg0 (-> this gravity))) + arg1 + ) + +(defmethod compute-transv-at-time ((this trajectory) (arg0 float) (arg1 vector)) + (set! (-> arg1 quad) (-> this initial-velocity quad)) + (+! (-> arg1 y) (* arg0 (-> this gravity))) + arg1 + ) + +(defmethod compute-time-until-apex ((this trajectory)) + (/ (- (-> this initial-velocity y)) (-> this gravity)) + ) + +(defmethod setup-from-to-duration! ((this trajectory) (arg0 vector) (arg1 vector) (arg2 float) (arg3 float)) + (set! (-> this initial-position quad) (-> arg0 quad)) + (set! (-> this gravity) arg3) + (set! (-> this time) arg2) + (let ((f0-3 (/ (vector-vector-xz-distance arg1 arg0) arg2))) + (vector-! (-> this initial-velocity) arg1 arg0) + (vector-xz-normalize! (-> this initial-velocity) f0-3) + ) + (set! (-> this initial-velocity y) (- (/ (- (-> arg1 y) (-> arg0 y)) arg2) (* 0.5 arg2 (-> this gravity)))) + 0 + (none) + ) + +(defmethod setup-from-to-xz-vel! ((this trajectory) (arg0 vector) (arg1 vector) (arg2 float) (arg3 float)) + (let ((f0-1 (/ (vector-vector-xz-distance arg1 arg0) arg2))) + (setup-from-to-duration! this arg0 arg1 f0-1 arg3) + ) + 0 + (none) + ) + +(defmethod setup-from-to-y-vel! ((this trajectory) (arg0 vector) (arg1 vector) (arg2 float) (arg3 float)) + (let* ((f0-0 arg2) + (f1-3 (- (* f0-0 f0-0) (* 2.0 (- (-> arg0 y) (-> arg1 y)) arg3))) + (f0-3 900.0) + ) + (when (>= f1-3 0.0) + (let ((f0-4 (sqrtf f1-3))) + (set! f0-3 (fmax (/ (- (- arg2) f0-4) arg3) (/ (+ (- arg2) f0-4) arg3))) + ) + ) + (setup-from-to-duration! this arg0 arg1 f0-3 arg3) + ) + 0 + (none) + ) + +(defmethod setup-from-to-height! ((this trajectory) (arg0 vector) (arg1 vector) (arg2 float) (arg3 float)) + (let* ((f0-1 (+ arg2 (fmax (-> arg0 y) (-> arg1 y)))) + (f1-4 (* 2.0 (- (-> arg0 y) f0-1) arg3)) + (f0-4 4096.0) + ) + (if (< 0.0 f1-4) + (set! f0-4 (sqrtf f1-4)) + ) + (setup-from-to-y-vel! this arg0 arg1 f0-4 arg3) + ) + 0 + (none) + ) + +;; WARN: Function (method 16 trajectory) has a return type of none, but the expression builder found a return statement. +(defmethod setup-from-to-duration-and-height! ((this trajectory) (arg0 vector) (arg1 vector) (arg2 float) (arg3 float)) + (let ((f0-1 (- (-> arg1 y) (-> arg0 y)))) + (cond + ((= f0-1 0.0) + (let ((t9-0 (method-of-type trajectory setup-from-to-duration!)) + (v1-2 arg2) + (f0-3 (* -8.0 arg3)) + (f1-3 arg2) + ) + (t9-0 this arg0 arg1 v1-2 (/ f0-3 (* f1-3 f1-3))) + ) + (return 0) + ) + ((and (< 0.0 f0-1) (< 0.0 arg3) (< arg3 f0-1)) + (set! arg3 f0-1) + ) + ((and (< f0-1 0.0) (< arg3 0.0) (< f0-1 arg3)) + (set! arg3 f0-1) + ) + ) + (let* ((f1-14 (/ (- arg3 f0-1) arg3)) + (f0-6 -2.0) + (f1-18 (/ (- 1.0 f1-14) (- arg2 (* arg2 (sqrtf f1-14))))) + (f0-8 (* f0-6 (* f1-18 f1-18) arg3)) + ) + (setup-from-to-duration! this arg0 arg1 arg2 f0-8) + ) + ) + 0 + (none) + ) + +(method-set! + trajectory + 17 + (if *debug-segment* + (lambda ((arg0 trajectory)) + (let ((s5-0 (new 'stack-no-clear 'vector)) + (s4-0 (new 'stack-no-clear 'vector)) + (s3-0 10) + ) + (set! (-> s4-0 quad) (-> arg0 initial-position quad)) + (dotimes (s2-0 s3-0) + (set! (-> s5-0 quad) (-> s4-0 quad)) + (let ((f0-1 (* (-> arg0 time) (/ (+ 1.0 (the float s2-0)) (the float s3-0))))) + (compute-trans-at-time arg0 f0-1 s4-0) + ) + (add-debug-line + #t + (bucket-id debug-no-zbuf1) + s5-0 + s4-0 + (new 'static 'rgba :r #xff :a #x80) + #f + (the-as rgba -1) + ) + ) + ) + 0 + (none) + ) + nothing + ) + ) + +(defmethod initialize ((this impact-control) (arg0 process-drawable) (arg1 int) (arg2 float) (arg3 collide-spec)) + (set! (-> this start-time) (the-as uint (current-time))) + (set! (-> this process) (the-as (pointer process-drawable) (process->ppointer arg0))) + (set! (-> this joint) arg1) + (set! (-> this radius) arg2) + (set! (-> this collide-with) (logclear arg3 (collide-spec water))) + (set! (-> this trans 0 quad) (the-as uint128 0)) + (set! (-> this trans 1 quad) (the-as uint128 0)) + this + ) + +(defmethod update-from-cspace ((this impact-control)) + (when (>= (-> this joint) 0) + (set! (-> this trans 1 quad) (-> this trans 0 quad)) + (vector<-cspace! (the-as vector (-> this trans)) (-> this process 0 node-list data (-> this joint))) + (vector-! (-> this dir) (the-as vector (-> this trans)) (-> this trans 1)) + ) + 0 + (none) + ) + +(defmethod impact-control-method-11 ((this impact-control) (arg0 collide-query) (arg1 process) (arg2 pat-surface)) + (set! (-> arg0 start-pos quad) (-> this trans 1 quad)) + (set! (-> arg0 move-dist quad) (-> this dir quad)) + (let ((v1-2 (ppointer->process (-> this process))) + (a0-6 arg0) + ) + (set! (-> a0-6 radius) (-> this radius)) + (set! (-> a0-6 collide-with) (-> this collide-with)) + (set! (-> a0-6 ignore-process0) v1-2) + (set! (-> a0-6 ignore-process1) #f) + (set! (-> a0-6 ignore-pat) arg2) + (set! (-> a0-6 action-mask) (collide-action solid)) + ) + (let ((f30-0 (fill-and-probe-using-line-sphere *collide-cache* arg0))) + (when (and arg1 (>= f30-0 0.0) (>= 0.0 (vector-dot (-> arg0 best-other-tri normal) (-> this dir)))) + (let* ((s3-0 (new 'stack-no-clear 'touching-shapes-entry)) + (s2-0 (-> arg0 best-other-tri collide-ptr)) + (v1-12 (if (type? s2-0 collide-shape-prim) + s2-0 + ) + ) + ) + (set! (-> s3-0 cshape1) #f) + (set! (-> s3-0 cshape2) (if v1-12 + (-> (the-as collide-shape-prim v1-12) cshape) + ) + ) + (set! (-> s3-0 resolve-u) (the int f30-0)) + (set! (-> s3-0 head) #f) + (send-event + arg1 + 'impact-control + :from (if v1-12 + (-> (the-as collide-shape-prim v1-12) cshape process) + arg1 + ) + #f + s3-0 + this + arg0 + ) + ) + ) + f30-0 + ) + ) + +(defmethod initialize ((this point-tracker) (arg0 vector) (arg1 vector)) + (set! (-> this trans 0 quad) (-> arg0 quad)) + (set! (-> this trans 1 quad) (-> arg1 quad)) + this + ) + +(defmethod point-tracker-method-10 ((this point-tracker) (arg0 vector) (arg1 vector) (arg2 vector) (arg3 float)) + (cond + ((>= 0.0 arg3) + (set! (-> arg0 quad) (-> arg1 quad)) + ) + ((>= arg3 1.0) + (set! (-> arg0 quad) (-> arg2 quad)) + ) + (else + (let ((a1-2 (vector+float*! arg0 arg2 (vector-! (new 'stack-no-clear 'vector) arg1 arg2) (- 1.0 arg3)))) + (vector-lerp! arg0 a1-2 arg2 arg3) + ) + ) + ) + arg0 + ) + +(defmethod point-tracker-method-11 ((this point-tracker) (arg0 vector) (arg1 vector) (arg2 vector) (arg3 float)) + (with-pp + (let ((v1-1 (point-tracker-method-10 this (new 'stack-no-clear 'vector) arg1 arg2 arg3))) + (vector-! arg0 v1-1 arg1) + ) + (vector-float*! arg0 arg0 (-> pp clock frames-per-second)) + arg0 + ) + ) + +;; WARN: Return type mismatch process vs process-focusable. +(defmethod combo-tracker-method-13 ((this combo-tracker) (arg0 handle) (arg1 vector) (arg2 float) (arg3 vector) (arg4 float)) + (the-as + process-focusable + (cond + ((send-event (handle->process arg0) 'combo) + (let ((gp-1 (handle->process arg0))) + (if (type? gp-1 process-focusable) + gp-1 + ) + ) + ) + (else + (let ((s1-0 (new 'stack-no-clear 'bounding-box)) + (s2-1 (new 'stack 'boxed-array collide-shape 32)) + ) + (sphere<-vector+r! (the-as sphere s1-0) arg1 arg2) + (set! (-> s2-1 length) (fill-actor-list-for-box + *actor-hash* + s1-0 + (the-as (pointer collide-shape) (-> s2-1 data)) + (-> s2-1 allocated-length) + ) + ) + (let ((gp-2 (find-nearest-focusable + (the-as (array collide-shape) s2-1) + arg1 + arg2 + (if (= arg4 65536.0) + (search-info-flag crate enemy combo) + (search-info-flag crate enemy prefer-angle cull-angle combo) + ) + (search-info-flag) + arg3 + (the-as vector #f) + arg4 + ) + ) + ) + (if (type? gp-2 process-focusable) + gp-2 + ) + ) + ) + ) + ) + ) + ) + +(defmethod combo-tracker-method-12 ((this combo-tracker) (arg0 vector) (arg1 vector) (arg2 process) (arg3 time-frame)) + (initialize this arg0 arg1) + (set! (-> this target) (process->handle arg2)) + (set! (-> this move-start-time) arg3) + this + ) + +(defmethod point-tracker-method-11 ((this combo-tracker) (arg0 vector) (arg1 vector) (arg2 vector) (arg3 float)) + (local-vars (at-0 int)) + (with-pp + (rlet ((vf0 :class vf) + (vf1 :class vf) + (vf2 :class vf) + ) + (init-vf0-vector) + (let ((v1-1 (point-tracker-method-10 this (new 'stack-no-clear 'vector) arg1 arg2 arg3))) + (vector-! arg0 v1-1 arg1) + ) + (let ((a1-4 (new 'stack-no-clear 'event-message-block))) + (set! (-> a1-4 from) (process->ppointer pp)) + (set! (-> a1-4 num-params) 0) + (set! (-> a1-4 message) 'nav-control) + (let* ((s3-0 (send-event-function (handle->process (-> this target)) a1-4)) + (s4-1 (if (type? s3-0 nav-control) + s3-0 + ) + ) + ) + (when s4-1 + (cond + (((method-of-type nav-control find-poly-containing-point-1) (the-as nav-control s4-1) arg1) + (let ((t9-4 (method-of-type nav-control nav-control-method-20))) + #x45000000 + (t9-4) + ) + ) + (else + (set! (-> arg0 quad) (the-as uint128 0)) + ) + ) + ) + ) + ) + (let ((v1-12 arg0)) + (.lvf vf1 (&-> arg0 quad)) + (let ((f0-0 (-> pp clock frames-per-second))) + (.mov at-0 f0-0) + ) + (.mov vf2 at-0) + (.mov.vf vf1 vf0 :mask #b1000) + (.mul.x.vf vf1 vf1 vf2 :mask #b111) + (.svf (&-> v1-12 quad) vf1) + ) + arg0 + ) + ) + ) + +(defun traj2d-calc-initial-speed-using-tilt ((arg0 traj2d-params)) + (let ((f0-4 (* (- (* (-> arg0 x) (tan (-> arg0 initial-tilt))) (-> arg0 y)) (/ 2.0 (-> arg0 gravity))))) + (cond + ((< 0.0 f0-4) + (set! (-> arg0 time) (sqrtf f0-4)) + (set! (-> arg0 initial-speed) (/ (-> arg0 x) (* (-> arg0 time) (cos (-> arg0 initial-tilt))))) + #t + ) + (else + (set! (-> arg0 time) 0.0) + (set! (-> arg0 initial-speed) 0.0) + #f + ) + ) + ) + ) + +(defun traj3d-calc-initial-velocity-using-tilt ((arg0 traj3d-params)) + (vector-! (-> arg0 diff) (-> arg0 dest) (-> arg0 src)) + (let ((s5-0 (new 'stack-no-clear 'traj2d-params))) + (let ((v1-1 (-> arg0 diff))) + (set! (-> s5-0 x) (sqrtf (+ (* (-> v1-1 x) (-> v1-1 x)) (* (-> v1-1 z) (-> v1-1 z))))) + ) + (set! (-> s5-0 y) (-> arg0 diff y)) + (set! (-> s5-0 gravity) (-> arg0 gravity)) + (set! (-> s5-0 initial-tilt) (-> arg0 initial-tilt)) + (cond + ((traj2d-calc-initial-speed-using-tilt s5-0) + (set! (-> arg0 time) (-> s5-0 time)) + (let* ((f26-0 (atan (-> arg0 diff x) (-> arg0 diff z))) + (f30-0 (-> arg0 initial-tilt)) + (f24-0 (cos f30-0)) + (f28-0 (-> s5-0 initial-speed)) + ) + (set! (-> arg0 initial-speed) f28-0) + (set! (-> arg0 initial-velocity x) (* f28-0 f24-0 (sin f26-0))) + (set! (-> arg0 initial-velocity z) (* f28-0 f24-0 (cos f26-0))) + (set! (-> arg0 initial-velocity y) (* f28-0 (sin f30-0))) + ) + (set! (-> arg0 initial-velocity w) 1.0) + #t + ) + (else + (set! (-> arg0 time) 0.0) + (set! (-> arg0 initial-speed) 0.0) + (vector-reset! (-> arg0 initial-velocity)) + #f + ) + ) + ) + ) + +(defmethod cubic-curve-method-9 ((this cubic-curve) (arg0 vector) (arg1 vector) (arg2 vector) (arg3 vector)) + (rlet ((acc :class vf) + (vf0 :class vf) + (vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + (vf7 :class vf) + ) + (init-vf0-vector) + (set! (-> this vec 0 quad) (-> arg0 quad)) + (set! (-> this mat uvec quad) (-> arg1 quad)) + (let ((v1-2 (new 'stack-no-clear 'trajectory))) + (vector-! (-> v1-2 initial-velocity) arg2 arg0) + (vector-float*! (-> v1-2 initial-position) (-> v1-2 initial-velocity) 3.0) + (let ((t1-7 (-> v1-2 initial-position))) + (let ((a1-3 (-> v1-2 initial-position))) + (let ((a3-2 arg1)) + (let ((t2-1 -2.0)) + (.mov vf7 t2-1) + ) + (.lvf vf5 (&-> a3-2 quad)) + ) + (.lvf vf4 (&-> a1-3 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 (&-> t1-7 quad) vf6) + ) + (vector-! (-> v1-2 initial-position) (-> v1-2 initial-position) arg3) + (set! (-> this mat fvec quad) (-> v1-2 initial-position quad)) + (vector-float*! (-> v1-2 initial-position) (-> v1-2 initial-velocity) -2.0) + (vector+! (-> v1-2 initial-position) (-> v1-2 initial-position) arg1) + (vector+! (-> v1-2 initial-position) (-> v1-2 initial-position) arg3) + (set! (-> this mat trans quad) (-> v1-2 initial-position quad)) + ) + (dotimes (v1-5 4) + (set! (-> this vec v1-5 w) 0.0) + ) + 0 + (none) + ) + ) + +(defmethod cubic-curve-method-10 ((this cubic-curve) (arg0 vector) (arg1 float)) + (let ((v1-0 (new 'stack-no-clear 'trajectory))) + (let ((f0-1 (* arg1 arg1))) + (set-vector! (-> v1-0 initial-position) 1.0 arg1 f0-1 (* f0-1 arg1)) + ) + (vector-matrix*! arg0 (-> v1-0 initial-position) (the-as matrix (-> this vec))) + ) + (set! (-> arg0 w) 1.0) + arg0 + ) + +(defmethod cubic-curve-method-11 ((this cubic-curve) (arg0 vector) (arg1 float)) + (let ((v1-0 (new 'stack-no-clear 'trajectory))) + (set-vector! (-> v1-0 initial-position) 0.0 1.0 (* 2.0 arg1) (* 3.0 arg1 arg1)) + (vector-matrix*! arg0 (-> v1-0 initial-position) (the-as matrix (-> this vec))) + ) + (set! (-> arg0 w) 1.0) + arg0 + ) + +(defmethod cubic-curve-method-12 ((this cubic-curve) (arg0 vector) (arg1 float)) + (let ((v1-0 (new 'stack-no-clear 'trajectory))) + (set-vector! (-> v1-0 initial-position) 0.0 0.0 2.0 (* 6.0 arg1)) + (vector-matrix*! arg0 (-> v1-0 initial-position) (the-as matrix (-> this vec))) + ) + (set! (-> arg0 w) 1.0) + arg0 + ) + +(defmethod debug-draw-curve ((this cubic-curve)) + (let ((s5-0 (new 'stack-no-clear 'trajectory)) + (s4-0 10) + ) + (cubic-curve-method-10 this (-> s5-0 initial-velocity) 0.0) + (add-debug-x #t (bucket-id debug-no-zbuf1) (-> s5-0 initial-velocity) *color-red*) + (dotimes (s3-0 s4-0) + (set! (-> s5-0 initial-position quad) (-> s5-0 initial-velocity quad)) + (let ((f0-2 (/ (+ 1.0 (the float s3-0)) (the float s4-0)))) + (cubic-curve-method-10 this (-> s5-0 initial-velocity) f0-2) + ) + (add-debug-x #t (bucket-id debug-no-zbuf1) (-> s5-0 initial-velocity) *color-red*) + (add-debug-line + #t + (bucket-id debug-no-zbuf1) + (-> s5-0 initial-position) + (-> s5-0 initial-velocity) + *color-red* + #f + (the-as rgba -1) + ) + ) + ) + (add-debug-vector + #t + (bucket-id debug-no-zbuf1) + (cubic-curve-method-10 this (new 'stack-no-clear 'vector) 0.0) + (cubic-curve-method-11 this (new 'stack-no-clear 'vector) 0.0) + (meters 0.00024414062) + *color-white* + ) + (add-debug-vector + #t + (bucket-id debug-no-zbuf1) + (cubic-curve-method-10 this (new 'stack-no-clear 'vector) 1.0) + (vector-negate! (new 'stack-no-clear 'vector) (cubic-curve-method-11 this (new 'stack-no-clear 'vector) 1.0)) + (meters 0.00024414062) + *color-white* + ) + 0 + (none) + ) diff --git a/goal_src/jak3/engine/target/logic-target.gc b/goal_src/jak3/engine/target/logic-target.gc index a463cc95208..3ea7267992a 100644 --- a/goal_src/jak3/engine/target/logic-target.gc +++ b/goal_src/jak3/engine/target/logic-target.gc @@ -111,7 +111,166 @@ (none) ) -;; ERROR: function was not converted to expressions. Cannot decompile. +;; WARN: new jak 2 until loop case, check carefully +(defun-debug target-history-print ((arg0 history-iterator)) + (local-vars + (sv-16 object) + (sv-24 int) + (sv-32 collide-status) + (sv-40 number) + (sv-44 vector) + (sv-48 vector) + (sv-52 vector) + (sv-56 vector) + (sv-60 vector) + (sv-64 vector) + (sv-68 number) + (sv-72 history-elt) + (sv-80 time-frame) + (sv-88 uint) + ) + (set! sv-16 (-> arg0 out)) + (set! sv-24 0) + (set! sv-32 (collide-status)) + (set! sv-40 0) + (set! sv-44 *zero-vector*) + (set! sv-48 *zero-vector*) + (set! sv-52 *zero-vector*) + (set! sv-56 *zero-vector*) + (set! sv-60 *zero-vector*) + (set! sv-64 *zero-vector*) + (set! sv-68 0) + (until #f + (set! sv-72 (update-entries! arg0)) + (if (not sv-72) + (return #f) + ) + (set! sv-80 (frame-counter-delta arg0 sv-72)) + (set! sv-88 (-> sv-72 record-id)) + (when (!= sv-24 sv-88) + (set! sv-24 (the-as int sv-88)) + (format + (-> arg0 out) + "~6D ~8S #x~8X " + sv-80 + (if (logtest? sv-32 (collide-status no-touch)) + "air" + (-> *pat-mode-info* (shr (shl (the-as int sv-68) 54) 61) name) + ) + sv-32 + ) + (format + (-> arg0 out) + "~C~C~C~C~C~C" + (if (not (logtest? (the-as int sv-40) 1)) + 103 + 87 + ) + (if (not (logtest? (the-as int sv-40) 2)) + 103 + 87 + ) + (cond + ((logtest? (the-as int sv-40) 2048) + 71 + ) + ((not (logtest? (the-as int sv-40) 4)) + 103 + ) + (else + 87 + ) + ) + (cond + ((logtest? (the-as int sv-40) 512) + 66 + ) + ((logtest? (the-as int sv-40) 8) + 76 + ) + (else + 99 + ) + ) + (if (not (logtest? (the-as int sv-40) 16)) + 110 + 66 + ) + (if (not (logtest? (the-as int sv-40) 32)) + 103 + 65 + ) + ) + (format + (-> arg0 out) + "~C~C " + (cond + ((logtest? #x10000 (the-as int sv-40)) + 80 + ) + ((logtest? (the-as int sv-40) #x8000) + 85 + ) + ((logtest? (the-as int sv-40) 64) + 78 + ) + (else + 95 + ) + ) + (cond + ((logtest? (the-as int sv-40) 1024) + 76 + ) + ((logtest? (the-as int sv-40) 256) + 67 + ) + ((logtest? (the-as int sv-40) 128) + 108 + ) + (else + 95 + ) + ) + ) + (format (-> arg0 out) "trans: ~6,,2m ~6,,2m ~6,,2m " (-> sv-44 x) (-> sv-44 y) (-> sv-44 z)) + (format (-> arg0 out) "int: ~6,,2m ~6,,2m ~6,,2m " (-> sv-56 x) (-> sv-56 y) (-> sv-56 z)) + (format (-> arg0 out) "vel: ~6,,2m ~6,,2m ~6,,2m " (-> sv-48 x) (-> sv-48 y) (-> sv-48 z)) + (format (-> arg0 out) "vel-out: ~6,,2m ~6,,2m ~6,,2m " (-> sv-52 x) (-> sv-52 y) (-> sv-52 z)) + (format (-> arg0 out) "normal: ~6,,2f ~6,,2f ~6,,2f " (-> sv-60 x) (-> sv-60 y) (-> sv-60 z)) + (format (-> arg0 out) "local: ~6,,2f ~6,,2f ~6,,2f " (-> sv-64 x) (-> sv-64 y) (-> sv-64 z)) + (format (-> arg0 out) "~%") + ) + (case (-> sv-72 channel) + (((history-channel trans)) + (set! sv-44 (-> sv-72 vector)) + ) + (((history-channel transv-in)) + (set! sv-48 (-> sv-72 vector)) + ) + (((history-channel transv-out)) + (set! sv-52 (-> sv-72 vector)) + ) + (((history-channel intersect)) + (set! sv-56 (-> sv-72 vector)) + ) + (((history-channel pat)) + (set! sv-68 (-> sv-72 vector x)) + ) + (((history-channel collide-status)) + (set! sv-32 (-> sv-72 collide-status)) + (set! sv-40 (-> sv-72 vector z)) + ) + (((history-channel surface-normal)) + (set! sv-60 (-> sv-72 vector)) + ) + (((history-channel local-normal)) + (set! sv-64 (-> sv-72 vector)) + ) + ) + ) + #f + ) (defun-debug target-print-stats ((arg0 target) (arg1 symbol)) (local-vars @@ -2469,8 +2628,7 @@ (vector-average! (-> self control midpoint-of-hands) gp-0 s5-0) ) (vector-! (-> self control ctrl-to-hands-offset) (-> self control midpoint-of-hands) (-> self control trans)) - (-> self control impact-ctrl) - ((method-of-type impact-control impact-control-method-10)) + (update-from-cspace (-> self control impact-ctrl)) (cond ((focus-test? self edge-grab) (target-compute-edge) diff --git a/goal_src/jak3/engine/util/sync-info-h.gc b/goal_src/jak3/engine/util/sync-info-h.gc index 70ee7aaad59..3831d582c05 100644 --- a/goal_src/jak3/engine/util/sync-info-h.gc +++ b/goal_src/jak3/engine/util/sync-info-h.gc @@ -37,13 +37,13 @@ (period uint32) ) (:methods - (sync-info-method-9 () none) - (sync-info-method-10 () none) + (get-current-phase-no-mod (_type_) float) + (get-phase-offset (_type_) float) (get-norm! (_type_ int) float) - (sync-info-method-12 () none) + (get-scaled-val! (_type_ float int) float) (initialize! (_type_ sync-info-params) none) - (sync-info-method-14 () none) - (sync-info-method-15 () none) + (get-timeframe-offset! (_type_ time-frame) time-frame) + (sync-now! (_type_ float) none) ) ) @@ -84,10 +84,10 @@ ) :pack-me (:methods - (delayed-rand-float-method-9 () none) - (delayed-rand-float-method-10 () none) - (delayed-rand-float-method-11 () none) - (delayed-rand-float-method-12 () none) + (set-params! (_type_ int int float) float) + (reset! (_type_) float) + (update! (_type_) float) + (update-and-clear! (_type_) float) ) ) @@ -102,8 +102,8 @@ ) :allow-misaligned (:methods - (oscillating-float-method-9 () none) - (oscillating-float-method-10 () none) + (set-params! (_type_ float float float float) float) + (update! (_type_ float) float) ) ) @@ -117,10 +117,10 @@ ) :allow-misaligned (:methods - (bouncing-float-method-9 () none) - (bouncing-float-method-10 () none) - (bouncing-float-method-11 () none) - (bouncing-float-method-12 () none) + (set-params! (_type_ float float float float float float float) float) + (update! (_type_ float) float) + (at-min? (_type_) symbol) + (at-max? (_type_) symbol) ) ) @@ -135,10 +135,10 @@ (value vector :inline) ) (:methods - (delayed-rand-vector-method-9 () none) - (delayed-rand-vector-method-10 () none) - (delayed-rand-vector-method-11 () none) - (delayed-rand-vector-method-12 () none) + (set-params! (_type_ int int float float) vector) + (update-now! (_type_) vector) + (update-with-delay! (_type_) vector) + (update-with-delay-or-reset! (_type_) vector) ) ) @@ -152,7 +152,7 @@ (accel float) ) (:methods - (oscillating-vector-method-9 () none) - (oscillating-vector-method-10 () none) + (set-params! (_type_ vector float float float) vector) + (update! (_type_ vector) vector) ) ) diff --git a/goal_src/jak3/engine/util/sync-info.gc b/goal_src/jak3/engine/util/sync-info.gc index 70ee22fddc9..d88fc2b22f9 100644 --- a/goal_src/jak3/engine/util/sync-info.gc +++ b/goal_src/jak3/engine/util/sync-info.gc @@ -7,3 +7,579 @@ ;; DECOMP BEGINS +;; WARN: Return type mismatch object vs none. +(defmethod initialize! ((this sync-info) (arg0 sync-info-params)) + (format 0 "ERROR: Invalid call to sync-info::initialize!~%") + (none) + ) + +(defmethod get-current-phase-no-mod ((this sync-info)) + (let* ((v1-0 (-> this period)) + (f0-1 (the float v1-0)) + (f1-2 (+ (the float (mod (the-as uint (current-time)) v1-0)) (-> this offset))) + ) + (/ (- f1-2 (* (the float (the int (/ f1-2 f0-1))) f0-1)) f0-1) + ) + ) + +(defmethod get-phase-offset ((this sync-info)) + (/ (-> this offset) (the float (-> this period))) + ) + +(defmethod sync-now! ((this sync-info) (arg0 float)) + (let* ((a2-0 (-> this period)) + (f0-1 (the float a2-0)) + (v1-0 (- arg0 (* (the float (the int (/ arg0 f0-1))) f0-1))) + (f1-4 (+ (the float (mod (the-as uint (current-time)) a2-0)) (-> this offset))) + (f1-6 (/ (- f1-4 (* (the float (the int (/ f1-4 f0-1))) f0-1)) f0-1)) + (f1-10 (+ (* (- v1-0 f1-6) f0-1) f0-1 (-> this offset))) + ) + (set! (-> this offset) (- f1-10 (* (the float (the int (/ f1-10 f0-1))) f0-1))) + ) + 0 + (none) + ) + +(defmethod get-norm! ((this sync-info) (arg0 int)) + (format 0 "ERROR: Unsupported sync-info::get-norm!~%") + 0.0 + ) + +(defmethod get-scaled-val! ((this sync-info) (arg0 float) (arg1 int)) + (* (get-norm! this arg1) arg0) + ) + +(defmethod get-timeframe-offset! ((this sync-info) (arg0 time-frame)) + (if (zero? arg0) + (set! arg0 (current-time)) + ) + (let* ((v1-4 (-> this period)) + (f0-1 (the float v1-4)) + (f1-2 (+ (the float (mod arg0 (the-as time-frame v1-4))) (-> this offset))) + ) + (+ arg0 (the int (- f0-1 (* (/ (- f1-2 (* (the float (the int (/ f1-2 f0-1))) f0-1)) f0-1) f0-1)))) + ) + ) + +;; WARN: Return type mismatch float vs none. +(defmethod initialize! ((this sync-linear) (arg0 sync-info-params)) + (local-vars (sv-16 res-tag)) + (if (!= (-> arg0 sync-type) 'sync-linear) + (format + 0 + "ERROR: Using wrong sync params in sync-linear::initialize (got ~A)! Fix this!~%" + (-> arg0 sync-type) + ) + ) + (set! (-> this sync-flags) (-> arg0 sync-flags)) + (let ((s4-0 (the-as int (-> arg0 period))) + (f30-0 (-> arg0 percent)) + ) + (let ((a0-3 (-> arg0 entity))) + (when a0-3 + (set! sv-16 (new 'static 'res-tag)) + (let ((v1-6 (res-lump-data a0-3 'sync (pointer float) :tag-ptr (& sv-16)))) + (when v1-6 + (set! s4-0 (the int (* 300.0 (-> v1-6 0)))) + (set! f30-0 (-> v1-6 1)) + ) + ) + ) + ) + (set! (-> this period) (the-as uint s4-0)) + (let* ((f0-4 (the float s4-0)) + (f1-1 (* f30-0 f0-4)) + ) + (set! (-> this offset) (- f1-1 (* (the float (the int (/ f1-1 f0-4))) f0-4))) + ) + ) + (none) + ) + +(defmethod get-norm! ((this sync-linear) (arg0 int)) + (if (zero? arg0) + (set! arg0 (the-as int (current-time))) + ) + (let* ((v1-4 (-> this period)) + (f0-1 (the float v1-4)) + ) + (cond + ((logtest? (-> this sync-flags) (sync-flags pong)) + (let* ((f1-0 2.0) + (f2-2 (+ (the float (mod arg0 (the-as int v1-4))) (-> this offset))) + (f0-3 (* f1-0 (/ (- f2-2 (* (the float (the int (/ f2-2 f0-1))) f0-1)) f0-1))) + ) + (if (>= f0-3 1.0) + (set! f0-3 (- 2.0 f0-3)) + ) + f0-3 + ) + ) + (else + (let ((f1-5 (+ (the float (mod arg0 (the-as int v1-4))) (-> this offset)))) + (/ (- f1-5 (* (the float (the int (/ f1-5 f0-1))) f0-1)) f0-1) + ) + ) + ) + ) + ) + +(defmethod get-scaled-val! ((this sync-linear) (arg0 float) (arg1 int)) + (* (get-norm! this arg1) arg0) + ) + +;; WARN: Return type mismatch float vs none. +(defmethod initialize! ((this sync-eased) (arg0 sync-info-params)) + (local-vars (sv-16 res-tag)) + (if (!= (-> arg0 sync-type) 'sync-eased) + (format + 0 + "ERROR: Using wrong sync params in sync-eased::initialize (got ~A)! Fix this!~%" + (-> arg0 sync-type) + ) + ) + (set! (-> this sync-flags) (-> arg0 sync-flags)) + (let ((s5-0 (the-as int (-> arg0 period))) + (f22-0 (-> arg0 percent)) + (f24-0 (-> arg0 pause-in)) + (f26-0 (-> arg0 pause-out)) + (f30-0 (-> arg0 ease-in)) + (f28-0 (-> arg0 ease-out)) + ) + (let ((a0-3 (-> arg0 entity))) + (when a0-3 + (set! sv-16 (new 'static 'res-tag)) + (let ((v1-6 (res-lump-data a0-3 'sync (pointer float) :tag-ptr (& sv-16)))) + (when v1-6 + (set! s5-0 (the int (* 300.0 (-> v1-6 0)))) + (set! f22-0 (-> v1-6 1)) + (when (>= (-> sv-16 elt-count) (the-as uint 4)) + (set! f30-0 (-> v1-6 2)) + (set! f28-0 (-> v1-6 3)) + (when (>= (-> sv-16 elt-count) (the-as uint 6)) + (set! f24-0 (-> v1-6 4)) + (set! f26-0 (-> v1-6 5)) + ) + ) + ) + ) + ) + ) + (set! (-> this period) (the-as uint s5-0)) + (let* ((f0-4 (the float s5-0)) + (f1-1 (* f22-0 f0-4)) + ) + (set! (-> this offset) (- f1-1 (* (the float (the int (/ f1-1 f0-4))) f0-4))) + ) + (cond + ((< f26-0 0.0) + (set! f26-0 0.0) + ) + ((< 1.0 f26-0) + (set! f26-0 1.0) + ) + ) + (cond + ((< f24-0 0.0) + (set! f24-0 0.0) + ) + ((< (- 1.0 f26-0) f24-0) + (set! f24-0 (- 1.0 f26-0)) + ) + ) + (let ((f0-14 (the float s5-0))) + (set! (-> this pause-in) (* f24-0 f0-14)) + (set! (-> this pause-out) (* f26-0 f0-14)) + ) + (if (< f30-0 0.0) + (set! f30-0 0.0) + ) + (if (< 1.0 f30-0) + (set! f30-0 1.0) + ) + (if (< f28-0 0.001) + (set! f28-0 0.001) + ) + (if (< 1.0 f28-0) + (set! f28-0 1.0) + ) + (let ((f0-20 (+ f30-0 f28-0))) + (when (< 1.0 f0-20) + (set! f0-20 1.0) + (set! f30-0 (- 1.0 f28-0)) + ) + (let* ((f1-6 (- 1.0 f0-20)) + (f0-21 f30-0) + (f1-7 (+ f30-0 f1-6)) + (f2-3 (* f0-21 f0-21)) + (f3-3 (+ (* 2.0 f0-21 (- f1-7 f0-21)) f2-3)) + (f4-3 (/ f0-21 (- 1.0 f1-7))) + (f3-4 (+ (* (- 1.0 f1-7) (- 1.0 f1-7) f4-3) f3-3)) + ) + (set! (-> this tlo) f0-21) + (set! (-> this thi) f1-7) + (set! (-> this ylo) f2-3) + (set! (-> this m2) f4-3) + (set! (-> this yend) f3-4) + ) + ) + ) + (none) + ) + +(defmethod get-norm! ((this sync-eased) (arg0 int)) + (if (zero? arg0) + (set! arg0 (the-as int (current-time))) + ) + (let* ((v1-4 (-> this period)) + (f3-0 (the float v1-4)) + (f0-1 (-> this pause-in)) + (f2-0 (-> this pause-out)) + (f1-1 (* 0.5 (- f3-0 (+ f0-1 f2-0)))) + ) + (the int (+ f0-1 f2-0 f3-0)) + (cond + ((logtest? (-> this sync-flags) (sync-flags pong)) + (let* ((f4-7 (+ (the float (mod arg0 (the-as int v1-4))) (-> this offset))) + (f3-2 (- f4-7 (* (the float (the int (/ f4-7 f3-0))) f3-0))) + (v1-6 #f) + ) + (when (>= f3-2 (+ f1-1 f0-1)) + (set! v1-6 #t) + (set! f3-2 (- f3-2 (+ f1-1 f0-1))) + f0-1 + (set! f0-1 f2-0) + ) + (cond + ((< f3-2 f0-1) + (set! f3-2 f0-1) + ) + ((< (+ f0-1 f1-1) f3-2) + (set! f3-2 (+ f0-1 f1-1)) + ) + ) + (let* ((f0-3 (/ (- f3-2 f0-1) f1-1)) + (f1-2 (-> this tlo)) + (f0-8 (/ (cond + ((< f0-3 f1-2) + (* f0-3 f0-3) + ) + ((< f0-3 (-> this thi)) + (+ (* 2.0 f1-2 (- f0-3 f1-2)) (-> this ylo)) + ) + (else + (let ((f1-5 (- 1.0 f0-3))) + (- (-> this yend) (* f1-5 f1-5 (-> this m2))) + ) + ) + ) + (-> this yend) + ) + ) + ) + (if v1-6 + (set! f0-8 (- 1.0 f0-8)) + ) + f0-8 + ) + ) + ) + (else + (format 0 "ERROR: Attempting to use sync-eased in unsupported non-pong mode.~%") + 0.0 + ) + ) + ) + ) + +(defmethod get-scaled-val! ((this sync-eased) (arg0 float) (arg1 int)) + (* (get-norm! this arg1) arg0) + ) + +;; WARN: Return type mismatch float vs none. +(defmethod initialize! ((this sync-paused) (arg0 sync-info-params)) + (local-vars (sv-16 res-tag)) + (if (!= (-> arg0 sync-type) 'sync-paused) + (format + 0 + "ERROR: Using wrong sync params in sync-paused::initialize (got ~A)! Fix this!~%" + (-> arg0 sync-type) + ) + ) + (set! (-> this sync-flags) (-> arg0 sync-flags)) + (let ((s5-0 (the-as int (-> arg0 period))) + (f26-0 (-> arg0 percent)) + (f28-0 (-> arg0 pause-in)) + (f30-0 (-> arg0 pause-out)) + ) + (let ((a0-3 (-> arg0 entity))) + (when a0-3 + (set! sv-16 (new 'static 'res-tag)) + (let ((v1-6 (res-lump-data a0-3 'sync (pointer float) :tag-ptr (& sv-16)))) + (when v1-6 + (set! s5-0 (the int (* 300.0 (-> v1-6 0)))) + (set! f26-0 (-> v1-6 1)) + (when (>= (-> sv-16 elt-count) (the-as uint 4)) + (set! f28-0 (-> v1-6 2)) + (set! f30-0 (-> v1-6 3)) + ) + ) + ) + ) + ) + (set! (-> this period) (the-as uint s5-0)) + (let* ((f0-4 (the float s5-0)) + (f1-1 (* f26-0 f0-4)) + ) + (set! (-> this offset) (- f1-1 (* (the float (the int (/ f1-1 f0-4))) f0-4))) + ) + (cond + ((< f30-0 0.0) + (set! f30-0 0.0) + ) + ((< 1.0 f30-0) + (set! f30-0 1.0) + ) + ) + (cond + ((< f28-0 0.0) + (set! f28-0 0.0) + ) + ((< (- 1.0 f30-0) f28-0) + (set! f28-0 (- 1.0 f30-0)) + ) + ) + (let ((f0-14 (the float s5-0))) + (set! (-> this pause-in) (* f28-0 f0-14)) + (set! (-> this pause-out) (* f30-0 f0-14)) + ) + ) + (none) + ) + +(defmethod get-norm! ((this sync-paused) (arg0 int)) + (if (zero? arg0) + (set! arg0 (the-as int (current-time))) + ) + (let* ((v1-4 (-> this period)) + (f2-0 (the float v1-4)) + (f0-1 (-> this pause-in)) + (f1-0 (-> this pause-out)) + ) + (the int (+ f0-1 f1-0 f2-0)) + (cond + ((logtest? (-> this sync-flags) (sync-flags pong)) + (let* ((f3-5 (+ (the float (mod arg0 (the-as int v1-4))) (-> this offset))) + (f3-6 (- f3-5 (* (the float (the int (/ f3-5 f2-0))) f2-0))) + (f2-2 (* 0.5 (- f2-0 (+ f0-1 f1-0)))) + (v1-7 #f) + ) + (when (>= f3-6 (+ f2-2 f0-1)) + (set! v1-7 #t) + (set! f3-6 (- f3-6 (+ f2-2 f0-1))) + (set! f0-1 f1-0) + ) + (let* ((f1-1 (/ (- f3-6 f0-1) f2-2)) + (f0-5 (fmax 0.0 (fmin 1.0 f1-1))) + ) + (if v1-7 + (set! f0-5 (- 1.0 f0-5)) + ) + f0-5 + ) + ) + ) + (else + (let* ((f3-9 (+ (the float (mod arg0 (the-as int v1-4))) (-> this offset))) + (f3-10 (- f3-9 (* (the float (the int (/ f3-9 f2-0))) f2-0))) + (f1-5 (- f2-0 (+ f0-1 f1-0))) + (f1-6 (/ (- f3-10 f0-1) f1-5)) + ) + (fmax 0.0 (fmin 1.0 f1-6)) + ) + ) + ) + ) + ) + +(defmethod get-scaled-val! ((this sync-paused) (arg0 float) (arg1 int)) + (* (get-norm! this arg1) arg0) + ) + +(defmethod set-params! ((this delayed-rand-float) (arg0 int) (arg1 int) (arg2 float)) + (set! (-> this min-time) arg0) + (set! (-> this max-time) arg1) + (set! (-> this max-val) (* 0.5 arg2)) + (set! (-> this start-time) 0) + (set! (-> this timer) 0) + (set! (-> this value) 0.0) + (-> this value) + ) + +(defmethod reset! ((this delayed-rand-float)) + (set-time! (-> this start-time)) + (set! (-> this timer) (rand-vu-int-range (-> this min-time) (-> this max-time))) + (set! (-> this value) (rand-vu-float-range (- (-> this max-val)) (-> this max-val))) + ) + +(defmethod update! ((this delayed-rand-float)) + (if (time-elapsed? (-> this start-time) (-> this timer)) + (reset! this) + ) + (-> this value) + ) + +(defmethod update-and-clear! ((this delayed-rand-float)) + (if (time-elapsed? (-> this start-time) (-> this timer)) + (reset! this) + (set! (-> this value) 0.0) + ) + (-> this value) + ) + +(defmethod set-params! ((this oscillating-float) (arg0 float) (arg1 float) (arg2 float) (arg3 float)) + (set! (-> this value) arg0) + (set! (-> this target) arg0) + (set! (-> this vel) 0.0) + (set! (-> this max-vel) arg2) + (set! (-> this damping) arg3) + (set! (-> this accel) arg1) + (-> this value) + ) + +(defmethod update! ((this oscillating-float) (arg0 float)) + (with-pp + (let ((f0-3 (* (- (+ (-> this target) arg0) (-> this value)) (* (-> this accel) (-> pp clock time-adjust-ratio))))) + (+! (-> this vel) f0-3) + ) + (set! (-> this vel) (fmin (-> this max-vel) (fmax (- (-> this max-vel)) (-> this vel)))) + (set! (-> this vel) (* (-> this vel) (-> this damping))) + (+! (-> this value) (* (-> this vel) (-> pp clock time-adjust-ratio))) + (-> this value) + ) + ) + +(defmethod set-params! ((this bouncing-float) + (arg0 float) + (arg1 float) + (arg2 float) + (arg3 float) + (arg4 float) + (arg5 float) + (arg6 float) + ) + (set-params! (-> this osc) arg0 arg4 arg5 arg6) + (set! (-> this max-value) arg1) + (set! (-> this min-value) arg2) + (set! (-> this elasticity) arg3) + (set! (-> this state) 0) + (-> this osc value) + ) + +(defmethod update! ((this bouncing-float) (arg0 float)) + (update! (-> this osc) arg0) + (set! (-> this state) 0) + (when (>= (-> this osc value) (-> this max-value)) + (set! (-> this osc value) (-> this max-value)) + (if (< 0.0 (-> this osc vel)) + (set! (-> this osc vel) (* (-> this osc vel) (- (-> this elasticity)))) + ) + (set! (-> this state) 1) + ) + (when (>= (-> this min-value) (-> this osc value)) + (set! (-> this osc value) (-> this min-value)) + (if (< (-> this osc vel) 0.0) + (set! (-> this osc vel) (* (-> this osc vel) (- (-> this elasticity)))) + ) + (set! (-> this state) -1) + ) + (-> this osc value) + ) + +(defmethod at-min? ((this bouncing-float)) + (= (-> this state) -1) + ) + +(defmethod at-max? ((this bouncing-float)) + (= (-> this state) 1) + ) + +(defmethod set-params! ((this delayed-rand-vector) (arg0 int) (arg1 int) (arg2 float) (arg3 float)) + (set! (-> this min-time) arg0) + (set! (-> this max-time) arg1) + (set! (-> this xz-max) (* 0.5 arg2)) + (set! (-> this y-max) (* 0.5 arg3)) + (set! (-> this start-time) 0) + (set! (-> this timer) 0) + (vector-reset! (-> this value)) + (-> this value) + ) + +(defmethod update-now! ((this delayed-rand-vector)) + (set-time! (-> this start-time)) + (set! (-> this timer) (rand-vu-int-range (-> this min-time) (-> this max-time))) + (set! (-> this value x) (rand-vu-float-range (- (-> this xz-max)) (-> this xz-max))) + (set! (-> this value y) (rand-vu-float-range (- (-> this y-max)) (-> this y-max))) + (set! (-> this value z) (rand-vu-float-range (- (-> this xz-max)) (-> this xz-max))) + (-> this value) + ) + +(defmethod update-with-delay! ((this delayed-rand-vector)) + (if (time-elapsed? (-> this start-time) (-> this timer)) + (update-now! this) + ) + (-> this value) + ) + +(defmethod update-with-delay-or-reset! ((this delayed-rand-vector)) + (if (time-elapsed? (-> this start-time) (-> this timer)) + (update-now! this) + (vector-reset! (-> this value)) + ) + (-> this value) + ) + +(defmethod set-params! ((this oscillating-vector) (arg0 vector) (arg1 float) (arg2 float) (arg3 float)) + (cond + (arg0 + (set! (-> this value quad) (-> arg0 quad)) + (set! (-> this target quad) (-> arg0 quad)) + ) + (else + (vector-reset! (-> this value)) + (vector-reset! (-> this target)) + ) + ) + (vector-reset! (-> this vel)) + (set! (-> this max-vel) arg2) + (set! (-> this damping) arg3) + (set! (-> this accel) arg1) + (-> this value) + ) + +(defmethod update! ((this oscillating-vector) (arg0 vector)) + (with-pp + (let ((v1-0 (new 'stack-no-clear 'vector))) + (cond + (arg0 + (vector+! v1-0 (-> this target) arg0) + (vector-! v1-0 v1-0 (-> this value)) + ) + (else + (vector-! v1-0 (-> this target) (-> this value)) + ) + ) + (vector-float*! v1-0 v1-0 (* (-> this accel) (-> pp clock time-adjust-ratio))) + (vector+! (-> this vel) (-> this vel) v1-0) + (let ((f0-2 (vector-length (-> this vel)))) + (if (< (-> this max-vel) f0-2) + (vector-float*! (-> this vel) (-> this vel) (/ (-> this max-vel) f0-2)) + ) + ) + (vector-float*! (-> this vel) (-> this vel) (-> this damping)) + (vector-float*! v1-0 (-> this vel) (-> pp clock time-adjust-ratio)) + (vector+! (-> this value) (-> this value) v1-0) + ) + (-> this value) + ) + ) diff --git a/goalc/compiler/compilation/Type.cpp b/goalc/compiler/compilation/Type.cpp index 6f8bbaa2872..d62948b9939 100644 --- a/goalc/compiler/compilation/Type.cpp +++ b/goalc/compiler/compilation/Type.cpp @@ -1120,7 +1120,9 @@ Val* Compiler::compile_stack_new(const goos::Object& form, Env* env, bool call_constructor, bool use_singleton) { - auto type_of_object = parse_typespec(unquote(type), env); + auto type_str = symbol_string(unquote(type)); + auto type_of_object = + type_str == "boxed-array" ? TypeSpec("array") : parse_typespec(unquote(type), env); auto fe = env->function_env(); auto st_type_info = dynamic_cast(m_ts.lookup_type(type_of_object)); if (st_type_info && st_type_info->is_always_stack_singleton()) { @@ -1131,14 +1133,16 @@ Val* Compiler::compile_stack_new(const goos::Object& form, } } if (type_of_object == TypeSpec("inline-array") || type_of_object == TypeSpec("array")) { - if (call_constructor) { - throw_compiler_error(form, "Constructing stack arrays is not yet supported"); + if (type_str == "array" && call_constructor && type_of_object == TypeSpec("array")) { + throw_compiler_error(form, "Use 'boxed-array instead of 'array for boxed stack arrays."); } if (use_singleton) { throw_compiler_error(form, "Singleton stack arrays are not yet supported"); } bool is_inline = type_of_object == TypeSpec("inline-array"); - auto elt_type = quoted_sym_as_string(pair_car(*rest)); + auto elt_type = call_constructor && type_of_object == TypeSpec("array") + ? symbol_string(pair_car(*rest)) + : quoted_sym_as_string(pair_car(*rest)); rest = &pair_cdr(*rest); auto count_obj = pair_car(*rest); @@ -1155,8 +1159,42 @@ Val* Compiler::compile_stack_new(const goos::Object& form, throw_compiler_error(form, "New array form got more arguments than expected"); } - auto ts = is_inline ? m_ts.make_inline_array_typespec(elt_type) - : m_ts.make_pointer_typespec(elt_type); + TypeSpec ts; + if (call_constructor && type_of_object == TypeSpec("array")) { + ts = m_ts.make_array_typespec("array", elt_type); + } else if (is_inline) { + ts = m_ts.make_inline_array_typespec(elt_type); + } else { + ts = m_ts.make_pointer_typespec(elt_type); + } + + if (type_str == "boxed-array" && call_constructor && type_of_object == TypeSpec("array")) { + auto ti = m_ts.lookup_type(elt_type); + RegVal* mem; + std::vector args; + int elt_size = ti->is_reference() ? 4 : ti->get_size_in_memory(); + int mem_size = + m_ts.lookup_type(type_of_object)->get_size_in_memory() + constant_count * elt_size; + mem = fe->allocate_aligned_stack_variable(ts, mem_size, 16)->to_gpr(form, env); + + // the new method actually takes a "symbol" according to the type system. So we have to cheat + // it. + mem->set_type(TypeSpec("symbol")); + args.push_back(mem); + // type + args.push_back( + compile_get_symbol_value(form, type_of_object.base_type(), env)->to_reg(form, env)); + // element type + args.push_back(compile_get_symbol_value(form, elt_type, env)->to_reg(form, env)); + // size + args.push_back(compile_integer(constant_count, env)->to_reg(form, env)); + + auto new_method = compile_get_method_of_type(form, type_of_object, "new", env); + auto new_obj = compile_real_function_call(form, new_method, args, env); + new_obj->set_type(ts); + return new_obj; + } + auto info = m_ts.get_deref_info(ts); if (!info.can_deref) { throw_compiler_error(form, "Cannot make an {} of {}\n", type_of_object.print(), ts.print()); diff --git a/test/decompiler/reference/jak1/engine/gfx/mood/time-of-day_REF.gc b/test/decompiler/reference/jak1/engine/gfx/mood/time-of-day_REF.gc index 2276c1528f8..90b7296d98b 100644 --- a/test/decompiler/reference/jak1/engine/gfx/mood/time-of-day_REF.gc +++ b/test/decompiler/reference/jak1/engine/gfx/mood/time-of-day_REF.gc @@ -253,7 +253,7 @@ ) ) ) - (let ((s4-0 (the-as (array float) (new 'stack 'array float 2)))) + (let ((s4-0 (the-as (array float) (new 'stack 'boxed-array float 2)))) 0.0 (let ((s5-0 0) (f30-0 (-> arg0 current-interp)) diff --git a/test/decompiler/reference/jak2/engine/load/load-state_REF.gc b/test/decompiler/reference/jak2/engine/load/load-state_REF.gc index 3e70e39770e..1bc94833662 100644 --- a/test/decompiler/reference/jak2/engine/load/load-state_REF.gc +++ b/test/decompiler/reference/jak2/engine/load/load-state_REF.gc @@ -165,7 +165,7 @@ ) ) ) - (let ((s5-1 (new 'stack 'array symbol 24))) + (let ((s5-1 (new 'stack 'boxed-array symbol 24))) (set! (-> s5-1 length) 0) (dotimes (s4-0 6) (let ((a0-5 (-> this want s4-0 name))) diff --git a/test/decompiler/reference/jak2/engine/target/target-part_REF.gc b/test/decompiler/reference/jak2/engine/target/target-part_REF.gc index 322f51da61e..17229953044 100644 --- a/test/decompiler/reference/jak2/engine/target/target-part_REF.gc +++ b/test/decompiler/reference/jak2/engine/target/target-part_REF.gc @@ -2870,7 +2870,7 @@ #f (label cfg-24) (when v1-18 - (let ((s5-1 (the-as (array cspace) (new 'stack 'array cspace 32)))) + (let ((s5-1 (the-as (array cspace) (new 'stack 'boxed-array cspace 32)))) (let ((v1-21 0)) (set! (-> s5-1 length) 0) (let ((a1-12 (-> arg0 node-list data sv-416)) diff --git a/test/decompiler/reference/jak2/levels/city/traffic/traffic-engine_REF.gc b/test/decompiler/reference/jak2/levels/city/traffic/traffic-engine_REF.gc index 7bf6d72eec3..7930a2bcfdd 100644 --- a/test/decompiler/reference/jak2/levels/city/traffic/traffic-engine_REF.gc +++ b/test/decompiler/reference/jak2/levels/city/traffic/traffic-engine_REF.gc @@ -2330,8 +2330,8 @@ Process is recycled and moved to reserved, if it deactivates." (when (not (update-guard-status-spots target-pos)) ) (when (update-guard-status-spots target-pos) - (set! guards (the-as (array crimson-guard) (new 'stack 'array crimson-guard 16))) - (set! guard-target-dists (the-as (array float) (new 'stack 'array float 16))) + (set! guards (the-as (array crimson-guard) (new 'stack 'boxed-array crimson-guard 16))) + (set! guard-target-dists (the-as (array float) (new 'stack 'boxed-array float 16))) (set! guard-idx 0) (dotimes (guard-count (the-as int (-> this vehicle-tracker-array active-object-count))) (case (-> this vehicle-tracker-array active-object-type-list guard-count) diff --git a/test/decompiler/reference/jak3/engine/camera/cam-combiner_REF.gc b/test/decompiler/reference/jak3/engine/camera/cam-combiner_REF.gc new file mode 100644 index 00000000000..969239c0811 --- /dev/null +++ b/test/decompiler/reference/jak3/engine/camera/cam-combiner_REF.gc @@ -0,0 +1,451 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition for function cam-helper-temp +;; INFO: Used lq/sq +(defbehavior cam-helper-temp camera-combiner ((arg0 (pointer camera-slave)) (arg1 (pointer camera-slave)) (arg2 float)) + (local-vars (sv-144 cam-rotation-tracker)) + (set! sv-144 (-> arg0 0 tracking)) + (let ((s1-0 (-> arg0 0 trans)) + (gp-0 (-> arg1 0 tracking)) + (s0-0 (-> arg1 0 trans)) + ) + (cond + ((= (-> self tracking-status) 3) + (cam-calc-follow! (-> self tracking) s1-0 #t) + (slave-set-rotation! + (-> self tracking) + s1-0 + (the-as cam-slave-options-u32 (-> self tracking-options)) + (-> self fov) + #t + ) + (set! sv-144 (-> self tracking)) + (set! s1-0 (-> self trans)) + ) + ((= (-> self tracking-status) 2) + (cam-calc-follow! (-> self tracking) s0-0 #t) + (slave-set-rotation! + (-> self tracking) + s0-0 + (the-as cam-slave-options-u32 (-> self tracking-options)) + (-> self fov) + #t + ) + (set! gp-0 (-> self tracking)) + (set! s0-0 (-> self trans)) + ) + ) + (let ((s2-0 (new 'stack-no-clear 'inline-array 'vector 3))) + (dotimes (v1-14 3) + (set! (-> s2-0 v1-14 quad) (the-as uint128 0)) + ) + 0.0 + 0.0 + 0.0 + (let ((s4-0 (new-stack-vector0))) + 0.0 + (let ((s3-0 (new 'stack-no-clear 'matrix))) + (set! (-> s3-0 rvec quad) (the-as uint128 0)) + (set! (-> s3-0 uvec quad) (the-as uint128 0)) + (set! (-> s3-0 fvec quad) (the-as uint128 0)) + (set! (-> s3-0 trans quad) (the-as uint128 0)) + (vector-! (-> s2-0 0) (the-as vector (-> sv-144 inv-mat)) (the-as vector (-> gp-0 inv-mat))) + (vector-! (-> s2-0 1) (-> sv-144 inv-mat uvec) (-> gp-0 inv-mat uvec)) + (vector-! (-> s2-0 2) (-> sv-144 inv-mat fvec) (-> gp-0 inv-mat fvec)) + (let ((f0-6 (vector-length (-> s2-0 0))) + (f1-0 (vector-length (-> s2-0 1))) + (f2-0 (vector-length (-> s2-0 2))) + ) + (cond + ((and (< f0-6 f1-0) (< f0-6 f2-0)) + (vector-cross! s4-0 (-> s2-0 1) (-> s2-0 2)) + ) + ((and (< f1-0 f0-6) (< f1-0 f2-0)) + (vector-cross! s4-0 (-> s2-0 0) (-> s2-0 2)) + ) + (else + (vector-cross! s4-0 (-> s2-0 0) (-> s2-0 1)) + ) + ) + ) + (vector-normalize! s4-0 1.0) + (let ((f0-9 (fabs (vector-dot (the-as vector (-> sv-144 inv-mat)) s4-0))) + (f1-3 (fabs (vector-dot (-> sv-144 inv-mat uvec) s4-0))) + (f2-3 (fabs (vector-dot (-> sv-144 inv-mat fvec) s4-0))) + ) + (cond + ((and (< f0-9 f1-3) (< f0-9 f2-3)) + (vector-flatten! (-> s2-0 0) (the-as vector (-> sv-144 inv-mat)) s4-0) + (vector-flatten! (-> s2-0 1) (the-as vector (-> gp-0 inv-mat)) s4-0) + ) + ((< f1-3 f2-3) + (vector-flatten! (-> s2-0 0) (-> sv-144 inv-mat uvec) s4-0) + (vector-flatten! (-> s2-0 1) (-> gp-0 inv-mat uvec) s4-0) + ) + (else + (vector-flatten! (-> s2-0 0) (-> sv-144 inv-mat fvec) s4-0) + (vector-flatten! (-> s2-0 1) (-> gp-0 inv-mat fvec) s4-0) + ) + ) + ) + (vector-normalize! (-> s2-0 0) 1.0) + (vector-normalize! (-> s2-0 1) 1.0) + (vector-cross! (-> s2-0 2) (-> s2-0 0) (-> s2-0 1)) + (if (< (vector-dot (-> s2-0 2) s4-0) 0.0) + (vector-negate! s4-0 s4-0) + ) + (let ((f30-0 (acos (vector-dot (-> s2-0 0) (-> s2-0 1))))) + (cond + ((logtest? (-> *camera* master-options) (cam-master-options-u32 SET_COMBINER_AXIS)) + (logclear! (-> *camera* master-options) (cam-master-options-u32 SET_COMBINER_AXIS FLIP_COMBINER)) + (when (and (< 8192.0 f30-0) (logtest? (-> *camera* master-options) (cam-master-options-u32 HAVE_TARGET))) + (vector-! (-> s2-0 0) (-> *camera* tpos-curr) s1-0) + (vector-! (-> s2-0 1) s0-0 s1-0) + (vector-flatten! (-> s2-0 0) (-> s2-0 0) (-> *camera* local-down)) + (vector-flatten! (-> s2-0 1) (-> s2-0 1) (-> *camera* local-down)) + (when (and (< 4096.0 (vector-normalize-ret-len! (-> s2-0 0) 1.0)) + (< 4096.0 (vector-normalize-ret-len! (-> s2-0 1) 1.0)) + ) + (vector-cross! (-> s2-0 2) (-> s2-0 1) (-> s2-0 0)) + (when (< (vector-dot (-> s2-0 2) s4-0) -0.01) + ) + ) + ) + ) + ((and (< 16384.0 f30-0) (< (vector-dot (-> self flip-control-axis) s4-0) 0.0)) + (logxor! (-> *camera* master-options) (cam-master-options-u32 FLIP_COMBINER)) + ) + ) + (set! (-> self flip-control-axis quad) (-> s4-0 quad)) + (when (logtest? (-> *camera* master-options) (cam-master-options-u32 FLIP_COMBINER)) + (set! f30-0 (- 65536.0 f30-0)) + (vector-negate! s4-0 s4-0) + ) + (let ((f30-1 (* f30-0 (- 1.0 arg2)))) + (matrix-axis-sin-cos! s3-0 s4-0 (sin f30-1) (cos f30-1)) + ) + ) + (matrix*! (-> self inv-camera-rot) (the-as matrix gp-0) s3-0) + ) + ) + ) + ) + ) + +;; failed to figure out what this is: +(defstate cam-combiner-active (camera-combiner) + :event (behavior ((proc process) (argc int) (message symbol) (block event-message-block)) + (local-vars (v0-0 object)) + (case message + (('fast-rot) + (set! v0-0 #t) + (set! (-> self fast-rot) (the-as basic v0-0)) + v0-0 + ) + (('set-interpolation) + (let ((f0-1 (the float (-> block param 0)))) + (cond + ((>= 0.0 f0-1) + (set! (-> self interp-val) 1.0) + ) + (else + (set! (-> self interp-val) 0.0) + (set! (-> self interp-step) (/ 5.0 f0-1)) + ) + ) + ) + ) + (('teleport) + (when (nonzero? (-> self tracking-status)) + (jump-to-target! (-> self tracking point-of-interest-blend) 0.0) + (cam-calc-follow! (-> self tracking) (-> self trans) #f) + (slave-set-rotation! + (-> self tracking) + (-> self trans) + (the-as cam-slave-options-u32 (-> self tracking-options)) + (-> self fov) + #f + ) + ) + ) + (('stop-tracking) + (set! (-> self tracking-status) (the-as uint 0)) + 0 + ) + (('start-tracking) + (cond + ((< argc 1) + (let ((t9-3 format) + (a0-14 0) + (a1-4 "ERROR : missing camera-slave parameter to *camera-combiner* start-tracking~%") + ) + (let ((v1-8 (-> block param 0))) + (rtype-of v1-8) + ) + (t9-3 a0-14 a1-4) + ) + ) + ((not (type? (-> block param 0) camera-slave)) + (let ((t9-5 format) + (a0-16 0) + (a1-6 "ERROR : invalid type '~A' to *camera-combiner* start-tracking~%") + (v1-11 (-> block param 0)) + ) + (t9-5 a0-16 a1-6 (rtype-of v1-11)) + ) + ) + ((zero? (-> self tracking-status)) + (set! (-> self tracking-status) (the-as uint 1)) + (let ((gp-1 (the-as object (-> block param 0)))) + (set! (-> self tracking-options) (the-as int (-> (the-as camera-slave gp-1) options))) + (set! (-> self tracking no-follow) (-> (the-as camera-slave gp-1) tracking no-follow)) + (copy-to (-> self tracking tilt-adjust) (the-as cam-float-seeker (+ (the-as uint gp-1) 320))) + (copy-to (-> self tracking underwater-blend) (the-as cam-float-seeker (+ (the-as uint gp-1) 368))) + (copy-to (-> self tracking point-of-interest-blend) (the-as cam-float-seeker (+ (the-as uint gp-1) 344))) + (let ((gp-2 (+ (the-as uint gp-1) 124))) + (cam-calc-follow! (-> self tracking) (the-as vector gp-2) #f) + (slave-set-rotation! + (-> self tracking) + (the-as vector gp-2) + (the-as cam-slave-options-u32 (-> self tracking-options)) + (-> self fov) + #f + ) + ) + ) + ) + ) + ) + (('copy-tracking) + (cond + ((< argc 1) + (let ((t9-11 format) + (a0-23 0) + (a1-12 "ERROR : missing camera-slave parameter to *camera-combiner* copy-tracking~%") + ) + (let ((v1-23 (-> block param 0))) + (rtype-of v1-23) + ) + (t9-11 a0-23 a1-12) + ) + ) + ((not (type? (-> block param 0) camera-slave)) + (let ((t9-13 format) + (a0-25 0) + (a1-14 "ERROR : invalid type '~A' to *camera-combiner* copy-tracking~%") + (v1-25 (-> block param 0)) + ) + (t9-13 a0-25 a1-14 (rtype-of v1-25)) + ) + ) + ((nonzero? (-> self tracking-status)) + #f + ) + (else + (set! (-> self tracking-status) (the-as uint 1)) + (let ((gp-3 (the-as object (-> block param 0)))) + (set! (-> self tracking-options) (the-as int (-> (the-as camera-slave gp-3) options))) + (set! (-> self tracking no-follow) (-> (the-as camera-slave gp-3) tracking no-follow)) + (copy-to (-> self tracking tilt-adjust) (the-as cam-float-seeker (+ (the-as uint gp-3) 320))) + (copy-to (-> self tracking underwater-blend) (the-as cam-float-seeker (+ (the-as uint gp-3) 368))) + (set! (-> self tracking follow-off quad) (-> (the-as camera-slave gp-3) tracking follow-off quad)) + (set! (-> self tracking follow-pt quad) (-> (the-as camera-slave gp-3) tracking follow-pt quad)) + (let* ((a2-23 (-> self tracking)) + (a3-7 (-> (the-as camera-slave gp-3) tracking)) + (v1-37 (-> a3-7 inv-mat rvec quad)) + (a0-32 (-> a3-7 inv-mat uvec quad)) + (a1-17 (-> a3-7 inv-mat fvec quad)) + (a3-8 (-> a3-7 inv-mat trans quad)) + ) + (set! (-> a2-23 inv-mat rvec quad) v1-37) + (set! (-> a2-23 inv-mat uvec quad) a0-32) + (set! (-> a2-23 inv-mat fvec quad) a1-17) + (set! (-> a2-23 inv-mat trans quad) a3-8) + ) + (copy-to (-> self tracking point-of-interest-blend) (the-as cam-float-seeker (+ (the-as uint gp-3) 344))) + (set! (-> self tracking looking-at quad) (-> (the-as camera-slave gp-3) tracking looking-at quad)) + (set! v0-0 (-> self tracking looking-interesting)) + (set! (-> (the-as vector v0-0) quad) (-> (the-as camera-slave gp-3) tracking looking-interesting quad)) + ) + v0-0 + ) + ) + ) + ) + ) + :code (behavior () + (until #f + (when (and (not (logtest? (-> *camera* master-options) (cam-master-options-u32 HAVE_TARGET))) + (!= (-> self tracking-status) 0) + ) + (set! (-> self tracking-status) (the-as uint 0)) + 0 + ) + (when *camera* + (let ((s5-0 (-> *camera* slave)) + (s4-0 (-> *camera* decel)) + (f30-0 (parameter-ease-sin-clamp (-> self interp-val))) + (gp-0 (new-stack-vector0)) + ) + (set! (-> gp-0 quad) (-> self trans quad)) + (when s5-0 + (cond + ((< (-> self interp-val) 1.0) + (vector-lerp-clamp! (-> self trans) (-> s4-0 0 trans) (-> s5-0 0 trans) f30-0) + (set! (-> self fov) (lerp-clamp (-> s4-0 0 fov) (-> s5-0 0 fov) f30-0)) + (set! (-> self dist-from-src) (vector-vector-distance (-> self trans) (-> s4-0 0 trans))) + (set! (-> self dist-from-dest) (vector-vector-distance (-> self trans) (-> s5-0 0 trans))) + (cond + ((= (-> self tracking-status) 1) + (cam-calc-follow! (-> self tracking) (-> self trans) #t) + (slave-set-rotation! + (-> self tracking) + (-> self trans) + (the-as cam-slave-options-u32 (-> self tracking-options)) + (-> self fov) + (not (-> self fast-rot)) + ) + (let* ((a2-4 (-> self inv-camera-rot)) + (a3-2 (-> self tracking)) + (v1-22 (-> a3-2 inv-mat rvec quad)) + (a0-10 (-> a3-2 inv-mat uvec quad)) + (a1-6 (-> a3-2 inv-mat fvec quad)) + (a3-3 (-> a3-2 inv-mat trans quad)) + ) + (set! (-> a2-4 rvec quad) v1-22) + (set! (-> a2-4 uvec quad) a0-10) + (set! (-> a2-4 fvec quad) a1-6) + (set! (-> a2-4 trans quad) a3-3) + ) + ) + (else + (cam-helper-temp s4-0 s5-0 f30-0) + ) + ) + (cond + ((and (< 0.0 (-> *camera* outro-t-step)) (< (-> *camera* outro-t) (-> *camera* outro-exit-value))) + ) + ((and (< (-> *camera* outro-t-step) 0.0) (< (-> *camera* outro-exit-value) (-> *camera* outro-t))) + ) + ((paused?) + ) + (else + (+! (-> self interp-val) (* (-> self interp-step) (-> self clock time-adjust-ratio))) + ) + ) + ) + (else + (set! (-> self dist-from-src) 409600.0) + (set! (-> self dist-from-dest) 0.0) + (set! (-> self trans quad) (-> s5-0 0 trans quad)) + (set! (-> self fov) (-> s5-0 0 fov)) + (cond + ((= (-> self tracking-status) 2) + (set! (-> self tracking-status) (the-as uint 1)) + ) + ((= (-> self tracking-status) 3) + (set! (-> self tracking-status) (the-as uint 0)) + 0 + ) + ) + (cond + ((= (-> self tracking-status) 1) + (cam-calc-follow! (-> self tracking) (-> self trans) #t) + (slave-set-rotation! + (-> self tracking) + (-> self trans) + (the-as cam-slave-options-u32 (-> self tracking-options)) + (-> self fov) + (not (-> self fast-rot)) + ) + (let* ((v1-51 (-> self inv-camera-rot)) + (a3-5 (-> self tracking)) + (a0-17 (-> a3-5 inv-mat rvec quad)) + (a1-10 (-> a3-5 inv-mat uvec quad)) + (a2-8 (-> a3-5 inv-mat fvec quad)) + (a3-6 (-> a3-5 inv-mat trans quad)) + ) + (set! (-> v1-51 rvec quad) a0-17) + (set! (-> v1-51 uvec quad) a1-10) + (set! (-> v1-51 fvec quad) a2-8) + (set! (-> v1-51 trans quad) a3-6) + ) + ) + (else + (let* ((v1-52 (-> self inv-camera-rot)) + (a3-7 (-> s5-0 0 tracking)) + (a0-19 (-> a3-7 inv-mat rvec quad)) + (a1-11 (-> a3-7 inv-mat uvec quad)) + (a2-9 (-> a3-7 inv-mat fvec quad)) + (a3-8 (-> a3-7 inv-mat trans quad)) + ) + (set! (-> v1-52 rvec quad) a0-19) + (set! (-> v1-52 uvec quad) a1-11) + (set! (-> v1-52 fvec quad) a2-9) + (set! (-> v1-52 trans quad) a3-8) + ) + ) + ) + ) + ) + ) + (vector-! (-> self velocity) (-> self trans) gp-0) + ) + ) + (set! (-> self fast-rot) #f) + (suspend) + ) + #f + ) + ) + +;; definition for function cam-combiner-init +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs none. +(defbehavior cam-combiner-init camera-combiner () + (stack-size-set! (-> self main-thread) 512) + (vector-reset! (-> self trans)) + (matrix-identity! (-> self inv-camera-rot)) + (cond + (*math-camera* + (set! (-> self fov) (-> *math-camera* fov)) + (set! (-> self trans quad) (-> *math-camera* trans quad)) + (let* ((v1-6 (-> self inv-camera-rot)) + (a3-0 (-> *math-camera* inv-camera-rot)) + (a0-6 (-> a3-0 rvec quad)) + (a1-1 (-> a3-0 uvec quad)) + (a2-0 (-> a3-0 fvec quad)) + (a3-1 (-> a3-0 trans quad)) + ) + (set! (-> v1-6 rvec quad) a0-6) + (set! (-> v1-6 uvec quad) a1-1) + (set! (-> v1-6 fvec quad) a2-0) + (set! (-> v1-6 trans quad) a3-1) + ) + ) + (else + (set! (-> self fov) 11650.845) + ) + ) + (set! (-> self interp-val) 1.0) + (set! (-> self interp-step) 0.125) + (set! (-> self tracking-status) (the-as uint 0)) + (set! (-> self fast-rot) #f) + (init (-> self tracking tilt-adjust) (-> *CAMERA-bank* default-tilt-adjust) 9.102222 91.022224 0.25) + (init + (-> self tracking follow-height-extra) + (-> *setting-control* cam-current extra-follow-height) + 81.92 + 819.2 + 0.5 + ) + (vector-reset! (-> self velocity)) + (go cam-combiner-active) + 0 + (none) + ) + + + + diff --git a/test/decompiler/reference/jak3/engine/camera/cam-interface_REF.gc b/test/decompiler/reference/jak3/engine/camera/cam-interface_REF.gc new file mode 100644 index 00000000000..df5cf241da6 --- /dev/null +++ b/test/decompiler/reference/jak3/engine/camera/cam-interface_REF.gc @@ -0,0 +1,124 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition for function position-in-front-of-camera! +(defun position-in-front-of-camera! ((arg0 vector) (arg1 float) (arg2 float)) + (vector-float*! arg0 (-> *math-camera* inv-camera-rot fvec) arg1) + (vector+float*! arg0 arg0 (-> *math-camera* inv-camera-rot uvec) arg2) + (vector+! arg0 arg0 (-> *math-camera* trans)) + arg0 + ) + +;; definition for function position-in-front-of-screen! +(defun position-in-front-of-screen! ((arg0 vector) (arg1 float) (arg2 vector)) + (let ((a2-1 (vector-negate! (new 'stack-no-clear 'vector) (-> *math-camera* inv-camera-rot fvec))) + (a1-3 (vector-float*! (new 'stack-no-clear 'vector) (-> *math-camera* inv-camera-rot fvec) arg1)) + ) + (vector+! a1-3 a1-3 (-> *math-camera* trans)) + (reverse-transform-point! arg0 a1-3 a2-1 arg2) + ) + arg0 + ) + +;; definition for function matrix-local->world +(defun matrix-local->world ((arg0 symbol) (arg1 symbol)) + (if arg0 + (-> *math-camera* inv-camera-rot-smooth) + (-> *math-camera* inv-camera-rot) + ) + ) + +;; definition for function matrix-world->local +(defun matrix-world->local ((arg0 symbol) (arg1 object)) + (-> *math-camera* camera-rot) + ) + +;; definition (perm) for symbol *camera-dummy-vector*, type vector +(define-perm *camera-dummy-vector* vector (vector-reset! (new 'global 'vector))) + +;; definition for function camera-pos +(defun camera-pos () + (cond + (*camera-combiner* + (-> *camera-combiner* trans) + ) + (*math-camera* + (-> *math-camera* trans) + ) + (else + *camera-dummy-vector* + ) + ) + ) + +;; definition for function math-camera-pos +(defun math-camera-pos () + (-> *math-camera* trans) + ) + +;; definition for function camera-matrix +(defun camera-matrix () + (if *camera-combiner* + (-> *camera-combiner* inv-camera-rot) + (-> *math-camera* inv-camera-rot) + ) + ) + +;; definition for function math-camera-matrix +(defun math-camera-matrix () + (-> *math-camera* inv-camera-rot) + ) + +;; definition for function camera-angle +(defun camera-angle () + (let ((f0-0 (-> *math-camera* camera-rot rvec x)) + (f1-0 (-> *math-camera* camera-rot rvec z)) + ) + (atan f1-0 f0-0) + ) + ) + +;; definition for function camera-teleport-to-entity +;; INFO: Used lq/sq +;; WARN: Return type mismatch object vs symbol. +(defbehavior camera-teleport-to-entity process ((arg0 entity-actor)) + (let ((gp-0 (new 'stack 'transformq))) + (set! (-> gp-0 trans quad) (-> arg0 extra trans quad)) + (quaternion-copy! (-> gp-0 quat) (-> arg0 quat)) + (vector-identity! (-> gp-0 scale)) + (the-as symbol (send-event *camera* 'teleport-to-transformq gp-0)) + ) + ) + +;; definition for function camera-teleport-to-entity-named +;; WARN: Return type mismatch int vs none. +(defun camera-teleport-to-entity-named ((arg0 string)) + (let* ((gp-0 (entity-by-name arg0)) + (a0-3 (if (type? gp-0 entity-actor) + gp-0 + ) + ) + ) + (if a0-3 + (camera-teleport-to-entity (the-as entity-actor a0-3)) + (format #t "sorry, couldn't find an actor named '~S'~%" arg0) + ) + ) + 0 + (none) + ) + +;; definition for function camera-teleport-to-location +;; WARN: Return type mismatch int vs none. +(defun camera-teleport-to-location ((arg0 float) (arg1 float) (arg2 float)) + (let ((v1-1 (new 'stack 'transformq))) + (set-vector! (-> v1-1 trans) (* 4096.0 arg0) (* 4096.0 arg1) (* 4096.0 arg2) 1.0) + (send-event *camera* 'teleport-to-transformq v1-1) + ) + 0 + (none) + ) + + + + diff --git a/test/decompiler/reference/jak3/engine/camera/cam-layout_REF.gc b/test/decompiler/reference/jak3/engine/camera/cam-layout_REF.gc new file mode 100644 index 00000000000..52489920d01 --- /dev/null +++ b/test/decompiler/reference/jak3/engine/camera/cam-layout_REF.gc @@ -0,0 +1,3727 @@ +;;-*-Lisp-*- +(in-package goal) + +;; this file is debug only +(declare-file (debug)) + +;; definition for symbol *camera-layout-blink*, type symbol +(define *camera-layout-blink* #f) + +;; definition of type cam-layout-bank +(deftype cam-layout-bank (basic) + ((spline-t float) + (spline-step float) + (intro-t float) + (intro-step float) + (debug-t float) + (debug-step float) + ) + ) + +;; definition for method 3 of type cam-layout-bank +(defmethod inspect ((this cam-layout-bank)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tspline-t: ~f~%" (-> this spline-t)) + (format #t "~1Tspline-step: ~f~%" (-> this spline-step)) + (format #t "~1Tintro-t: ~f~%" (-> this intro-t)) + (format #t "~1Tintro-step: ~f~%" (-> this intro-step)) + (format #t "~1Tdebug-t: ~f~%" (-> this debug-t)) + (format #t "~1Tdebug-step: ~f~%" (-> this debug-step)) + (label cfg-4) + this + ) + +;; definition for symbol *CAM_LAYOUT-bank*, type cam-layout-bank +(define *CAM_LAYOUT-bank* (new 'static 'cam-layout-bank + :spline-t 0.01 + :spline-step 0.0016666667 + :intro-t 0.01 + :intro-step 0.0016666667 + :debug-t 0.01 + :debug-step 0.0033333334 + ) + ) + +;; definition for symbol *camera-layout-message-ypos*, type int +(define *camera-layout-message-ypos* 30) + +;; definition of type clm-basic +(deftype clm-basic (basic) + () + ) + +;; definition for method 3 of type clm-basic +(defmethod inspect ((this clm-basic)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (label cfg-4) + this + ) + +;; definition of type clm-item-action +(deftype clm-item-action (structure) + ((button pad-buttons-u64) + (options clm-item-action-options) + (func symbol) + (parm0 int32) + (parm0-sym symbol :overlay-at parm0) + (parm1 symbol) + (parm1-basic basic :overlay-at parm1) + ) + ) + +;; definition for method 3 of type clm-item-action +(defmethod inspect ((this clm-item-action)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'clm-item-action) + (format #t "~1Tbutton: ~D~%" (-> this button)) + (format #t "~1Toptions: ~D~%" (-> this options)) + (format #t "~1Tfunc: ~A~%" (-> this func)) + (format #t "~1Tparm0: ~A~%" (-> this parm0)) + (format #t "~1Tparm1: ~A~%" (-> this parm1)) + (label cfg-4) + this + ) + +;; definition of type clm-item +(deftype clm-item (clm-basic) + ((description string) + (button-symbol symbol) + (action clm-item-action :inline) + ) + ) + +;; definition for method 3 of type clm-item +(defmethod inspect ((this clm-item)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tdescription: ~A~%" (-> this description)) + (format #t "~1Tbutton-symbol: ~A~%" (-> this button-symbol)) + (format #t "~1Taction: #~%" (-> this action)) + (label cfg-4) + this + ) + +;; definition of type clm-list-item +(deftype clm-list-item (basic) + ((description string) + (track-val symbol) + (val-func symbol) + (val-parm0 int32) + (val-parm0-sym symbol :overlay-at val-parm0) + (val-parm1 symbol) + (actions (array clm-item-action)) + ) + ) + +;; definition for method 3 of type clm-list-item +(defmethod inspect ((this clm-list-item)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tdescription: ~A~%" (-> this description)) + (format #t "~1Ttrack-val: ~A~%" (-> this track-val)) + (format #t "~1Tval-func: ~A~%" (-> this val-func)) + (format #t "~1Tval-parm0: ~A~%" (-> this val-parm0)) + (format #t "~1Tval-parm1: ~A~%" (-> this val-parm1)) + (format #t "~1Tactions: ~A~%" (-> this actions)) + (label cfg-4) + this + ) + +;; definition of type clm-list +(deftype clm-list (clm-basic) + ((tracker symbol) + (cur-list-item int32) + (items (array clm-list-item)) + ) + ) + +;; definition for method 3 of type clm-list +(defmethod inspect ((this clm-list)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Ttracker: ~A~%" (-> this tracker)) + (format #t "~1Tcur-list-item: ~D~%" (-> this cur-list-item)) + (format #t "~1Titems: ~A~%" (-> this items)) + (label cfg-4) + this + ) + +;; definition of type clm +(deftype clm (basic) + ((title string) + (items (array clm-basic)) + ) + ) + +;; definition for method 3 of type clm +(defmethod inspect ((this clm)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Ttitle: ~A~%" (-> this title)) + (format #t "~1Titems: ~A~%" (-> this items)) + (label cfg-4) + this + ) + +;; definition for symbol *volume-point-current*, type int +(define *volume-point-current* 0) + +;; definition for symbol *volume-point*, type vector-array +(define *volume-point* (new 'debug 'vector-array 1000)) + +;; definition for symbol *volume-normal-current*, type int +(define *volume-normal-current* 0) + +;; definition for symbol *volume-normal*, type vector-array +(define *volume-normal* (new 'debug 'vector-array 600)) + +;; definition of type volume-descriptor-array +(deftype volume-descriptor-array (inline-array-class) + ((data plane-volume :inline :dynamic) + ) + ) + +;; definition for method 3 of type volume-descriptor-array +(defmethod inspect ((this volume-descriptor-array)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tlength: ~D~%" (-> this length)) + (format #t "~1Tallocated-length: ~D~%" (-> this allocated-length)) + (format #t "~1Tdata[0] @ #x~X~%" (-> this data)) + (label cfg-4) + this + ) + +;; failed to figure out what this is: +(set! (-> volume-descriptor-array heap-base) (the-as uint 24)) + +;; definition for symbol *volume-descriptor-current*, type int +(define *volume-descriptor-current* 0) + +;; definition for symbol *volume-descriptor*, type vol-control +(define *volume-descriptor* (the-as vol-control (new 'debug 'volume-descriptor-array 100))) + +;; definition of type cam-layout +(deftype cam-layout (process) + ((cam-entity entity-camera) + (num-entities int32) + (cur-entity int32) + (num-volumes int32) + (cur-volume int32) + (first-pvol int32) + (first-cutoutvol int32) + (res-key float) + ) + (:states + cam-layout-active + ) + ) + +;; definition for method 3 of type cam-layout +(defmethod inspect ((this cam-layout)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (let ((t9-0 (method-of-type process inspect))) + (t9-0 this) + ) + (format #t "~2Tcam-entity: ~A~%" (-> this cam-entity)) + (format #t "~2Tnum-entities: ~D~%" (-> this num-entities)) + (format #t "~2Tcur-entity: ~D~%" (-> this cur-entity)) + (format #t "~2Tnum-volumes: ~D~%" (-> this num-volumes)) + (format #t "~2Tcur-volume: ~D~%" (-> this cur-volume)) + (format #t "~2Tfirst-pvol: ~D~%" (-> this first-pvol)) + (format #t "~2Tfirst-cutoutvol: ~D~%" (-> this first-cutoutvol)) + (format #t "~2Tres-key: ~f~%" (-> this res-key)) + (label cfg-4) + this + ) + +;; definition for function cam-layout-print +(defun cam-layout-print ((arg0 int) (arg1 int) (arg2 string)) + (let* ((s5-0 (-> *display* frames (-> *display* on-screen) debug-buf)) + (gp-0 (-> s5-0 base)) + ) + (draw-string-xy arg2 s5-0 arg0 arg1 (font-color white) (font-flags shadow kerning)) + (let ((a3-2 (-> s5-0 base))) + (when (!= gp-0 a3-2) + (let ((v1-6 (the-as object (-> s5-0 base)))) + (set! (-> (the-as dma-packet v1-6) dma) (new 'static 'dma-tag :id (dma-tag-id next))) + (set! (-> (the-as dma-packet v1-6) vif0) (new 'static 'vif-tag)) + (set! (-> (the-as dma-packet v1-6) vif1) (new 'static 'vif-tag)) + (set! (-> s5-0 base) (&+ (the-as pointer v1-6) 16)) + ) + (dma-bucket-insert-tag + (-> *display* frames (-> *display* on-screen) bucket-group) + (bucket-id bucket583) + gp-0 + (the-as (pointer dma-tag) a3-2) + ) + ) + ) + ) + ) + +;; definition for function cam-layout-intersect-dist +(defun cam-layout-intersect-dist ((arg0 vector) (arg1 vector) (arg2 vector)) + (let ((f0-1 (vector-dot arg1 arg0)) + (f1-1 (vector-dot arg2 arg0)) + ) + (if (< 0.00001 (fabs f1-1)) + (/ (- (-> arg0 w) f0-1) f1-1) + 409600000.0 + ) + ) + ) + +;; definition for function cam-layout-entity-volume-info-create +;; INFO: Used lq/sq +;; WARN: new jak 2 until loop case, check carefully +(defbehavior cam-layout-entity-volume-info-create cam-layout ((arg0 entity-camera) (arg1 symbol)) + (local-vars + (sv-16 res-tag) + (sv-160 vector) + (sv-164 float) + (sv-168 int) + (sv-176 vector) + (sv-192 vector) + (sv-208 vector) + (sv-224 vector) + (sv-240 vector) + (sv-256 int) + (sv-272 int) + (sv-288 int) + ) + (let ((s4-0 0)) + (until #f + (set! sv-16 (new 'static 'res-tag)) + (let ((s3-0 (the-as (inline-array vector) ((method-of-type res-lump get-property-data) + arg0 + arg1 + 'exact + (the float s4-0) + (the-as pointer #f) + (& sv-16) + *res-static-buf* + ) + ) + ) + ) + (cond + (s3-0 + (when (>= *volume-descriptor-current* 100) + (format 0 "ERROR : camera editing out of volume descriptors~%") + (return #f) + ) + (let ((s2-0 (-> *volume-descriptor* pos-vol *volume-descriptor-current*))) + (set! (-> s2-0 volume-type) arg1) + (set! (-> s2-0 point-count) 0) + (set! (-> s2-0 first-point) (the-as (pointer vector) (-> *volume-point* data *volume-point-current*))) + (set! (-> s2-0 normal-count) 0) + (set! (-> s2-0 first-normal) (the-as (pointer vector) (-> *volume-normal* data *volume-normal-current*))) + (set! *volume-descriptor-current* (+ *volume-descriptor-current* 1)) + (+! (-> self num-volumes) 1) + (dotimes (s1-0 (the-as int (-> sv-16 elt-count))) + (set! sv-192 (new 'stack-no-clear 'vector)) + (set! (-> sv-192 quad) (the-as uint128 0)) + (set! sv-208 (new 'stack-no-clear 'vector)) + (set! (-> sv-208 quad) (the-as uint128 0)) + (set! sv-224 (new 'stack-no-clear 'vector)) + (set! (-> sv-224 quad) (the-as uint128 0)) + (set! sv-240 (new 'stack-no-clear 'vector)) + (set! (-> sv-240 quad) (the-as uint128 0)) + 0.0 + 0.0 + 0.0 + (set! (-> (new 'stack-no-clear 'vector) quad) (the-as uint128 0)) + (let ((s0-0 (new-stack-vector0))) + (set! sv-256 0) + (set! sv-272 0) + (while (< sv-272 (the-as int (-> sv-16 elt-count))) + (when (!= s1-0 sv-272) + (vector-float*! sv-192 (-> s3-0 sv-272) (-> s3-0 sv-272 w)) + (vector-cross! sv-208 (-> s3-0 sv-272) (-> s3-0 s1-0)) + (vector-normalize! sv-208 1.0) + (vector-cross! sv-224 sv-208 (-> s3-0 sv-272)) + (vector-normalize! sv-224 1.0) + (let ((f0-6 (cam-layout-intersect-dist (-> s3-0 s1-0) sv-192 sv-224))) + (when (!= f0-6 409600000.0) + (vector+float*! sv-240 sv-192 sv-224 f0-6) + (set! sv-160 (new-stack-vector0)) + (set! sv-164 (the-as float 0.0)) + (set! sv-168 0) + (set! sv-176 (new-stack-vector0)) + (set! (-> sv-160 quad) (-> sv-240 quad)) + (set! sv-288 0) + (while (< sv-288 (the-as int (-> sv-16 elt-count))) + (when (and (!= sv-288 s1-0) (!= sv-288 sv-272)) + (let ((f0-8 (cam-layout-intersect-dist (-> s3-0 sv-288) sv-160 sv-208))) + (cond + ((= f0-8 409600000.0) + ) + ((zero? sv-168) + (vector+float*! sv-160 sv-160 sv-208 f0-8) + (set! (-> sv-176 quad) (-> s3-0 sv-288 quad)) + (set! sv-164 (the-as float 8192000.0)) + (set! sv-168 1) + ) + ((begin (vector-float*! sv-240 sv-208 f0-8) (>= (vector-dot sv-240 sv-176) 0.0)) + ) + ((>= (vector-dot sv-240 (-> s3-0 sv-288)) 0.0) + (when (< (fabs f0-8) (fabs sv-164)) + (set! sv-164 f0-8) + (set! sv-168 (+ sv-168 1)) + ) + ) + (else + (vector+float*! sv-160 sv-160 sv-208 f0-8) + (set! (-> sv-176 quad) (-> s3-0 sv-288 quad)) + (set! sv-168 (+ sv-168 1)) + (if (< (fabs f0-8) (fabs sv-164)) + (set! sv-164 (- sv-164 f0-8)) + (set! sv-164 (the-as float 0.0)) + ) + ) + ) + ) + ) + (set! sv-288 (+ sv-288 1)) + ) + (cond + ((zero? sv-168) + ) + ((= sv-164 0.0) + ) + (else + (dotimes (v1-87 (the-as int (-> sv-16 elt-count))) + (when (and (!= v1-87 s1-0) (!= v1-87 sv-272)) + (if (< 4096.0 (- (vector-dot sv-160 (-> s3-0 v1-87)) (-> s3-0 v1-87 w))) + (goto cfg-47) + ) + ) + ) + (vector+float*! sv-240 sv-160 sv-208 sv-164) + (cond + ((>= *volume-point-current* 999) + (format 0 "ERROR : camera editing out of volume points~%") + ) + (else + (set! (-> *volume-point* data *volume-point-current* quad) (-> sv-160 quad)) + (set! (-> *volume-point* data (+ *volume-point-current* 1) quad) (-> sv-240 quad)) + (set! *volume-point-current* (+ *volume-point-current* 2)) + (+! (-> s2-0 point-count) 2) + ) + ) + (vector+! s0-0 s0-0 sv-160) + (vector+! s0-0 s0-0 sv-240) + (set! sv-256 (+ sv-256 2)) + sv-256 + ) + ) + ) + ) + ) + (label cfg-47) + (set! sv-272 (+ sv-272 1)) + ) + (when (nonzero? sv-256) + (vector-float*! s0-0 s0-0 (/ 1.0 (the float sv-256))) + (cond + ((>= *volume-normal-current* 599) + (format 0 "ERROR : camera editing out of volume normals~%") + ) + (else + (set! (-> *volume-normal* data *volume-normal-current* quad) (-> s0-0 quad)) + (set! (-> *volume-normal* data (+ *volume-normal-current* 1) quad) (-> s3-0 s1-0 quad)) + (set! *volume-normal-current* (+ *volume-normal-current* 2)) + (set! (-> s2-0 normal-count) (+ (-> s2-0 normal-count) 2)) + ) + ) + ) + ) + ) + ) + ) + (else + (return #f) + ) + ) + ) + (+! s4-0 1) + ) + ) + #f + ) + +;; definition for function cam-layout-entity-volume-info +(defbehavior cam-layout-entity-volume-info cam-layout () + (dotimes (gp-0 (-> self num-volumes)) + (cond + ((and (= gp-0 (-> self cur-volume)) + (= *camera-layout-blink* 'volume) + (not (logtest? (-> *display* real-frame-clock integral-frame-counter) 8)) + ) + ) + (else + (let ((s5-0 (-> *volume-descriptor* pos-vol gp-0))) + (let ((a0-8 (new 'static 'vector4w :w #x80))) + (cond + ((= (-> s5-0 volume-type) 'vol) + (set! (-> a0-8 x) 0) + (set! (-> a0-8 y) 192) + (set! (-> a0-8 z) 0) + 0 + ) + ((= (-> s5-0 volume-type) 'pvol) + (set! (-> a0-8 x) 128) + (set! (-> a0-8 y) 128) + (set! (-> a0-8 z) 128) + ) + ((= (-> s5-0 volume-type) 'cutoutvol) + (set! (-> a0-8 x) 192) + (set! (-> a0-8 y) 0) + (set! (-> a0-8 z) 0) + 0 + ) + ) + (camera-line-setup a0-8) + ) + (let ((s4-0 (-> s5-0 first-point))) + (dotimes (s3-0 (/ (-> s5-0 point-count) 2)) + (camera-line-draw (the-as vector s4-0) (the-as vector (&-> s4-0 4))) + (set! s4-0 (&-> s4-0 8)) + ) + ) + ) + ) + ) + ) + #f + ) + +;; definition for function v-slrp! +;; INFO: Used lq/sq +(defun v-slrp! ((arg0 vector) (arg1 vector) (arg2 vector) (arg3 float)) + (let ((s2-0 (new-stack-vector0)) + (s1-0 (new-stack-vector0)) + (s0-0 (new-stack-vector0)) + ) + 0.0 + 0.0 + 0.0 + 0.0 + (cond + ((< 1.0 arg3) + (set! arg3 1.0) + ) + ((< arg3 0.0) + (set! arg3 0.0) + ) + ) + (vector-normalize-copy! s2-0 arg1 1.0) + (vector-normalize-copy! s1-0 arg2 1.0) + (vector-cross! s0-0 s2-0 s1-0) + (let* ((f30-0 (vector-length s0-0)) + (f28-0 (asin f30-0)) + ) + (vector-float*! arg0 arg1 (/ (sin (* (- 1.0 arg3) f28-0)) f30-0)) + (vector+float*! arg0 arg0 arg2 (/ (sin (* arg3 f28-0)) f30-0)) + ) + ) + ) + +;; definition of type interp-test-info +(deftype interp-test-info (structure) + ((from vector :inline) + (to vector :inline) + (origin vector :inline) + (color vector4w) + (axis vector) + (disp string) + ) + ) + +;; definition for method 3 of type interp-test-info +(defmethod inspect ((this interp-test-info)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'interp-test-info) + (format #t "~1Tfrom: #~%" (-> this from)) + (format #t "~1Tto: #~%" (-> this to)) + (format #t "~1Torigin: #~%" (-> this origin)) + (format #t "~1Tcolor: #~%" (-> this color)) + (format #t "~1Taxis: #~%" (-> this axis)) + (format #t "~1Tdisp: ~A~%" (-> this disp)) + (label cfg-4) + this + ) + +;; definition for function interp-test +;; INFO: Used lq/sq +(defun interp-test ((arg0 (function vector vector vector float vector float none)) (arg1 interp-test-info)) + (let ((s3-0 (new-stack-vector0)) + (s5-0 (new-stack-vector0)) + ) + (arg0 s3-0 (-> arg1 from) (-> arg1 to) 0.0 (-> arg1 axis) 65536.0) + (vector+! s3-0 s3-0 (-> arg1 origin)) + (dotimes (s2-0 10) + (set! (-> s5-0 quad) (-> s3-0 quad)) + (arg0 s3-0 (-> arg1 from) (-> arg1 to) (* 0.1 (+ 1.0 (the float s2-0))) (-> arg1 axis) 65536.0) + (vector+! s3-0 s3-0 (-> arg1 origin)) + (camera-line s3-0 s5-0 (-> arg1 color)) + ) + (arg0 s5-0 (-> arg1 from) (-> arg1 to) (-> *CAM_LAYOUT-bank* debug-t) (-> arg1 axis) 65536.0) + (format *stdcon* "~S ~f~%" (-> arg1 disp) (vector-length s5-0)) + (vector+! s5-0 s5-0 (-> arg1 origin)) + (camera-line (-> arg1 origin) s5-0 (-> arg1 color)) + (camera-cross (new 'static 'vector :y 1024.0) (new 'static 'vector :z 1024.0) s5-0 (-> arg1 color) (meters 1)) + ) + (none) + ) + +;; definition for function interp-test-deg +;; INFO: Used lq/sq +(defun interp-test-deg ((arg0 (function vector vector vector vector float none)) (arg1 interp-test-info)) + (let ((s3-0 (new-stack-vector0)) + (s5-0 (new-stack-vector0)) + ) + (arg0 s3-0 (-> arg1 from) (-> arg1 to) (-> arg1 axis) 0.0) + (vector+! s3-0 s3-0 (-> arg1 origin)) + (dotimes (s2-0 10) + (set! (-> s5-0 quad) (-> s3-0 quad)) + (arg0 s3-0 (-> arg1 from) (-> arg1 to) (-> arg1 axis) (* 182.04445 (* 18.0 (+ 1.0 (the float s2-0))))) + (vector+! s3-0 s3-0 (-> arg1 origin)) + (camera-line s3-0 s5-0 (-> arg1 color)) + ) + (arg0 s5-0 (-> arg1 from) (-> arg1 to) (-> arg1 axis) (* 182.04445 (* 180.0 (-> *CAM_LAYOUT-bank* debug-t)))) + (format *stdcon* "~S ~f~%" (-> arg1 disp) (vector-length s5-0)) + (vector+! s5-0 s5-0 (-> arg1 origin)) + (camera-line (-> arg1 origin) s5-0 (-> arg1 color)) + (camera-cross (new 'static 'vector :y 1024.0) (new 'static 'vector :z 1024.0) s5-0 (-> arg1 color) (meters 1)) + ) + (none) + ) + +;; definition for function cam-layout-entity-info +;; INFO: Used lq/sq +;; WARN: Function cam-layout-entity-info has a return type of none, but the expression builder found a return statement. +(defun cam-layout-entity-info ((arg0 entity-actor)) + (if (not arg0) + (return #f) + ) + (let ((s5-0 (new 'stack-no-clear 'matrix))) + (set! (-> s5-0 rvec quad) (the-as uint128 0)) + (set! (-> s5-0 uvec quad) (the-as uint128 0)) + (set! (-> s5-0 fvec quad) (the-as uint128 0)) + (set! (-> s5-0 trans quad) (the-as uint128 0)) + (let ((s4-0 (new-stack-vector0))) + (when (and (cam-slave-get-vector-with-offset arg0 s4-0 'trans) + (or (!= *camera-layout-blink* 'camera) (logtest? (-> *display* real-frame-clock integral-frame-counter) 8)) + ) + (cam-slave-get-rot arg0 s5-0) + (camera-fov-frame s5-0 s4-0 (* 0.5 (cam-slave-get-fov arg0)) 0.75 1.0 (new 'static 'vector4w :z #xff :w #x80)) + ) + ) + ) + (let ((s5-1 (new-stack-vector0))) + (if (and (cam-slave-get-vector-with-offset arg0 s5-1 'pivot) + (or (!= *camera-layout-blink* 'pivot) (logtest? (-> *display* real-frame-clock integral-frame-counter) 8)) + ) + (camera-cross + (new 'static 'vector :y 1024.0) + (new 'static 'vector :z 1024.0) + s5-1 + (new 'static 'vector4w :x #x80 :w #x80) + (meters 1) + ) + ) + ) + (let ((s5-2 (new-stack-vector0))) + (if (and (cam-slave-get-vector-with-offset arg0 s5-2 'align) + (or (!= *camera-layout-blink* 'align) (logtest? (-> *display* real-frame-clock integral-frame-counter) 8)) + ) + (camera-cross + (new 'static 'vector :y 1024.0) + (new 'static 'vector :z 1024.0) + s5-2 + (new 'static 'vector4w :y #x80 :w #x80) + (meters 1) + ) + ) + ) + (let ((s5-3 (new-stack-vector0))) + (if (and (cam-slave-get-vector-with-offset arg0 s5-3 'interesting) + (or (!= *camera-layout-blink* 'interesting) + (logtest? (-> *display* real-frame-clock integral-frame-counter) 8) + ) + ) + (camera-cross + (new 'static 'vector :y 1024.0) + (new 'static 'vector :z 1024.0) + s5-3 + (new 'static 'vector4w :x #x80 :z #x80 :w #x80) + (meters 1) + ) + ) + ) + (let ((s3-1 (new 'stack 'curve)) + (s2-0 (new-stack-vector0)) + (s5-4 (new-stack-vector0)) + (s4-1 (new-stack-vector0)) + ) + (when (and (get-curve-data! arg0 s3-1 'campath 'campath-k -1000000000.0) + (or (!= *camera-layout-blink* 'spline) (logtest? (-> *display* real-frame-clock integral-frame-counter) 8)) + ) + (cond + ((cam-slave-get-vector-with-offset arg0 s4-1 'pivot) + (curve-get-pos! s5-4 0.0 s3-1) + (vector-! s4-1 s4-1 s5-4) + ) + (else + (set! (-> s4-1 quad) + (-> (the-as + vector + ((method-of-type res-lump get-property-struct) + arg0 + 'spline-offset + 'interp + -1000000000.0 + s4-1 + (the-as (pointer res-tag) #f) + *res-static-buf* + ) + ) + quad + ) + ) + ) + ) + (curve-get-pos! s5-4 0.0 s3-1) + (vector+! s5-4 s5-4 s4-1) + (dotimes (s1-1 8) + (set! (-> s2-0 quad) (-> s5-4 quad)) + (curve-get-pos! s5-4 (* 0.125 (the float (+ s1-1 1))) s3-1) + (vector+! s5-4 s5-4 s4-1) + (camera-line s2-0 s5-4 (new 'static 'vector4w :x #xff :y #xff :w #x80)) + ) + (curve-get-pos! s5-4 (-> *CAM_LAYOUT-bank* spline-t) s3-1) + (vector+! s5-4 s5-4 s4-1) + (camera-cross + (new 'static 'vector :y 1024.0) + (new 'static 'vector :z 1024.0) + s5-4 + (new 'static 'vector4w :x #xff :y #xff :w #x80) + (meters 1) + ) + ) + ) + (let ((s3-2 (new 'stack 'curve)) + (s2-1 (new-stack-vector0)) + (s5-5 (new-stack-vector0)) + (s4-2 (new-stack-vector0)) + (s1-2 (new 'stack 'curve)) + ) + (when (and (get-curve-data! arg0 s3-2 'intro 'intro-k -1000000000.0) + (or (!= *camera-layout-blink* 'intro) (logtest? (-> *display* real-frame-clock integral-frame-counter) 8)) + ) + (cond + ((cam-slave-get-vector-with-offset arg0 s4-2 'pivot) + (curve-get-pos! s5-5 1.0 s3-2) + (vector-! s4-2 s4-2 s5-5) + ) + ((get-curve-data! arg0 s1-2 'campath 'campath-k -1000000000.0) + (curve-get-pos! s4-2 0.0 s1-2) + (curve-get-pos! s5-5 1.0 s3-2) + (vector-! s4-2 s4-2 s5-5) + ) + ((cam-slave-get-vector-with-offset arg0 s4-2 'trans) + (curve-get-pos! s5-5 1.0 s3-2) + (vector-! s4-2 s4-2 s5-5) + ) + ) + (curve-get-pos! s5-5 0.0 s3-2) + (vector+! s5-5 s5-5 s4-2) + (dotimes (s1-3 8) + (set! (-> s2-1 quad) (-> s5-5 quad)) + (curve-get-pos! s5-5 (* 0.125 (the float (+ s1-3 1))) s3-2) + (vector+! s5-5 s5-5 s4-2) + (camera-line s2-1 s5-5 (new 'static 'vector4w :z #xff :w #x80)) + ) + (curve-get-pos! s5-5 (-> *CAM_LAYOUT-bank* intro-t) s3-2) + (vector+! s5-5 s5-5 s4-2) + (camera-cross + (new 'static 'vector :y 1024.0) + (new 'static 'vector :z 1024.0) + s5-5 + (new 'static 'vector4w :z #xff :w #x80) + (meters 1) + ) + (curve-get-pos! s5-5 (cam-slave-get-float arg0 'intro-exitValue 0.0) s3-2) + (vector+! s5-5 s5-5 s4-2) + (camera-cross + (new 'static 'vector :y 1024.0) + (new 'static 'vector :z 1024.0) + s5-5 + (new 'static 'vector4w :z #xff :w #x80) + (meters 1) + ) + ) + ) + (let ((s2-3 (res-lump-data arg0 'campoints pointer :time 1.0)) + (v1-73 (res-lump-struct arg0 'campoints-offset structure)) + (s4-3 (new 'stack-no-clear 'vector)) + (s3-3 (new 'stack-no-clear 'vector)) + (s5-6 (new 'static 'vector)) + ) + (when (and s2-3 + (or (!= *camera-layout-blink* 'index) (logtest? (-> *display* real-frame-clock integral-frame-counter) 8)) + ) + (cond + (v1-73 + (vector+! s4-3 (the-as vector (&+ s2-3 0)) (the-as vector v1-73)) + (vector+! s3-3 (the-as vector (&+ s2-3 16)) (the-as vector v1-73)) + ) + (else + (set! (-> s4-3 quad) (-> (the-as (pointer uint128) (&+ s2-3 0)))) + (set! (-> s3-3 quad) (-> (the-as (pointer uint128) (&+ s2-3 16)))) + ) + ) + (camera-line s4-3 s3-3 (new 'static 'vector4w :y #x80 :w #x80)) + (vector-lerp-clamp! s5-6 s4-3 s3-3 (-> *CAM_LAYOUT-bank* spline-t)) + (camera-cross + (new 'static 'vector :y 1024.0) + (new 'static 'vector :z 1024.0) + s5-6 + (new 'static 'vector4w :x #xff :y #xff :w #x80) + (meters 1) + ) + ) + ) + (let ((s4-4 (res-lump-data arg0 'focalpull pointer :time 1.0)) + (s5-7 (new 'static 'vector)) + ) + (when (and s4-4 + (or (!= *camera-layout-blink* 'focalpull) (logtest? (-> *display* real-frame-clock integral-frame-counter) 8)) + ) + (camera-line + (the-as vector (&+ s4-4 0)) + (the-as vector (&+ s4-4 16)) + (new 'static 'vector4w :y #xff :z #xff :w #x80) + ) + (vector-lerp-clamp! + s5-7 + (the-as vector (&+ s4-4 0)) + (the-as vector (&+ s4-4 16)) + (-> *CAM_LAYOUT-bank* spline-t) + ) + (camera-cross + (new 'static 'vector :y 1024.0) + (new 'static 'vector :z 1024.0) + s5-7 + (new 'static 'vector4w :y #xff :z #xff :w #x80) + (meters 1) + ) + ) + ) + (let ((s5-8 (new 'stack 'interp-test-info)) + (s4-5 (new-stack-vector0)) + ) + (when (and (cam-slave-get-vector-with-offset arg0 (-> s5-8 origin) 'pivot) + (cam-slave-get-vector-with-offset arg0 (-> s5-8 to) 'align) + (cam-slave-get-vector-with-offset arg0 (-> s5-8 from) 'trans) + ) + (camera-line (-> s5-8 from) (-> s5-8 origin) (new 'static 'vector4w :x #x80 :y #x80 :z #x80 :w #x80)) + (camera-line (-> s5-8 to) (-> s5-8 origin) (new 'static 'vector4w :x #x80 :y #x80 :z #x80 :w #x80)) + (vector-! (-> s5-8 from) (-> s5-8 from) (-> s5-8 origin)) + (vector-! (-> s5-8 to) (-> s5-8 to) (-> s5-8 origin)) + (vector-cross! s4-5 (-> s5-8 from) (-> s5-8 to)) + (vector-normalize! s4-5 8192.0) + (vector+! s4-5 s4-5 (-> s5-8 origin)) + (camera-line (-> s5-8 origin) s4-5 (new 'static 'vector4w :x #x80 :y #x80 :z #x80 :w #x80)) + (when (not (paused?)) + (+! (-> *CAM_LAYOUT-bank* debug-t) (-> *CAM_LAYOUT-bank* debug-step)) + (if (< 1.0 (-> *CAM_LAYOUT-bank* debug-t)) + (set! (-> *CAM_LAYOUT-bank* debug-t) 0.0) + ) + ) + (set! (-> s5-8 axis) #f) + (set! (-> s5-8 disp) "li") + (set! (-> s5-8 color) (new 'static 'vector4w :x #xff :w #x80)) + (interp-test (the-as (function vector vector vector float vector float none) vector-lerp!) s5-8) + (set! (-> s5-8 disp) "si") + (set! (-> s5-8 color) (new 'static 'vector4w :y #xff :w #x80)) + (interp-test (the-as (function vector vector vector float vector float none) v-slrp!) s5-8) + (set! (-> s5-8 disp) "si2") + (set! (-> s5-8 color) (new 'static 'vector4w :z #xff :w #x80)) + (interp-test (the-as (function vector vector vector float vector float none) v-slrp2!) s5-8) + (set! (-> s5-8 disp) "si3") + (set! (-> s5-8 color) (new 'static 'vector4w :x #xff :z #xff :w #x80)) + (interp-test-deg (the-as (function vector vector vector vector float none) v-slrp3!) s5-8) + (set! (-> s5-8 axis) (-> *camera* local-down)) + (set! (-> s5-8 disp) "si2d") + (set! (-> s5-8 color) (new 'static 'vector4w :y #xff :z #xff :w #x80)) + (interp-test (the-as (function vector vector vector float vector float none) v-slrp2!) s5-8) + (set! (-> s5-8 disp) "si3d") + (set! (-> s5-8 color) (new 'static 'vector4w :x #xff :y #xff :w #x80)) + (interp-test-deg (the-as (function vector vector vector vector float none) v-slrp3!) s5-8) + ) + ) + (none) + ) + +;; definition for function clmf-button-test +(defun clmf-button-test () + (cam-layout-print 16 *camera-layout-message-ypos* "button test") + (set! *camera-layout-message-ypos* (+ *camera-layout-message-ypos* 14)) + (set-setting! 'master-options 'set 0.0 32) + #f + ) + +;; definition for function clmf-bna +(defun clmf-bna () + (cam-layout-print 16 *camera-layout-message-ypos* "button not applicable") + (set! *camera-layout-message-ypos* (+ *camera-layout-message-ypos* 14)) + (set-setting! 'master-options 'set 0.0 32) + #t + ) + +;; definition for function clmf-implement +(defun clmf-implement () + (cam-layout-print 16 *camera-layout-message-ypos* "button not implemented yet") + (set! *camera-layout-message-ypos* (+ *camera-layout-message-ypos* 14)) + (set-setting! 'master-options 'set 0.0 32) + #t + ) + +;; definition for function clmf-input +;; INFO: Used lq/sq +(defun clmf-input ((arg0 vector) (arg1 vector) (arg2 int)) + (vector-reset! arg0) + (vector-reset! arg1) + (cond + ((cpad-hold? arg2 l3) + (set! (-> arg0 z) + (- (-> arg0 z) (analog-input (the-as int (-> *cpad-list* cpads arg2 rightx)) 128.0 48.0 110.0 1.0)) + ) + ) + (else + (set! (-> arg0 y) + (- (-> arg0 y) (analog-input (the-as int (-> *cpad-list* cpads arg2 rightx)) 128.0 48.0 110.0 1.0)) + ) + (+! (-> arg0 x) (analog-input (the-as int (-> *cpad-list* cpads arg2 righty)) 128.0 48.0 110.0 1.0)) + (set! (-> arg1 x) + (- (-> arg1 x) (analog-input (the-as int (-> *cpad-list* cpads arg2 leftx)) 128.0 48.0 110.0 1.0)) + ) + (when (logtest? (-> *camera* settings master-options) (cam-master-options READ_BUTTONS)) + (if (cpad-hold? arg2 r1) + (set! (-> arg1 y) + (+ 0.5 (analog-input (the-as int (-> *cpad-list* cpads arg2 abutton 9)) 0.0 32.0 230.0 0.5) (-> arg1 y)) + ) + ) + ) + (when (logtest? (-> *camera* settings master-options) (cam-master-options READ_BUTTONS)) + (if (cpad-hold? arg2 l1) + (set! (-> arg1 y) + (- (-> arg1 y) (+ 0.5 (analog-input (the-as int (-> *cpad-list* cpads arg2 abutton 8)) 0.0 32.0 230.0 0.5))) + ) + ) + ) + (set! (-> arg1 z) + (- (-> arg1 z) (analog-input (the-as int (-> *cpad-list* cpads arg2 lefty)) 128.0 48.0 110.0 1.0)) + ) + ) + ) + (let ((s5-1 (new 'stack-no-clear 'matrix))) + (set! (-> s5-1 rvec quad) (the-as uint128 0)) + (set! (-> s5-1 uvec quad) (the-as uint128 0)) + (set! (-> s5-1 fvec quad) (the-as uint128 0)) + (set! (-> s5-1 trans quad) (the-as uint128 0)) + (let ((a2-8 (new-stack-vector0))) + (set! (-> a2-8 y) -1.0) + (forward-down-nopitch->inv-matrix s5-1 (-> *math-camera* inv-camera-rot fvec) a2-8) + ) + (vector-matrix*! arg1 arg1 s5-1) + ) + arg1 + ) + +;; definition for function clmf-pos-rot +;; INFO: Used lq/sq +(defbehavior clmf-pos-rot cam-layout ((arg0 symbol) (arg1 symbol)) + (local-vars (s2-0 structure) (s3-1 structure) (sv-192 matrix)) + (cam-layout-print 16 *camera-layout-message-ypos* "x/z pos: left stick, down: l1, up: r1") + (set! *camera-layout-message-ypos* (+ *camera-layout-message-ypos* 14)) + (when (and arg1 (nonzero? arg1)) + (cam-layout-print 16 *camera-layout-message-ypos* "x/y rot: right stick") + (set! *camera-layout-message-ypos* (+ *camera-layout-message-ypos* 14)) + (cam-layout-print 16 *camera-layout-message-ypos* "z rot: press left stick & move right") + (set! *camera-layout-message-ypos* (+ *camera-layout-message-ypos* 14)) + ) + (let ((s5-0 (new-stack-vector0)) + (s4-0 (new-stack-vector0)) + ) + (set! s3-1 + (cond + ((or (zero? arg0) (not arg0)) + (the-as structure #f) + ) + (else + (if (not (res-lump-struct (-> self cam-entity) arg0 structure)) + (add-data! + (-> self cam-entity) + (new 'static 'res-tag :name arg0 :key-frame -1000000000.0 :elt-count #x1 :inlined? #x1 :elt-type vector) + (the-as pointer (new 'static 'vector)) + ) + ) + (set! s3-1 (res-lump-struct (-> self cam-entity) arg0 structure)) + (when (and (not s3-1) (logtest? (-> *display* real-frame-clock integral-frame-counter) 8)) + (clear *temp-string*) + (format *temp-string* "ERROR : can't add ~A" 'vector) + (cam-layout-print 120 100 *temp-string*) + ) + s3-1 + ) + ) + ) + (set! s2-0 + (cond + ((or (zero? arg1) (not arg1)) + (the-as structure #f) + ) + (else + (if (not (res-lump-struct (-> self cam-entity) arg1 structure)) + (add-data! + (-> self cam-entity) + (new 'static 'res-tag :name arg1 :key-frame -1000000000.0 :elt-count #x1 :inlined? #x1 :elt-type quaternion) + (the-as pointer (quaternion-identity! (new 'static 'quaternion))) + ) + ) + (set! s2-0 (res-lump-struct (-> self cam-entity) arg1 structure)) + (when (and (not s2-0) (logtest? (-> *display* real-frame-clock integral-frame-counter) 8)) + (clear *temp-string*) + (format *temp-string* "ERROR : can't add ~A" 'quaternion) + (cam-layout-print 120 100 *temp-string*) + ) + s2-0 + ) + ) + ) + (let ((s1-1 (new 'stack-no-clear 'matrix))) + (set! sv-192 (new 'stack-no-clear 'matrix)) + (let ((s0-1 (new 'stack-no-clear 'quaternion))) + (if (not s3-1) + (return #f) + ) + (clmf-input s5-0 s4-0 0) + (vector+float*! (the-as vector s3-1) (the-as vector s3-1) s4-0 409.6) + (cond + ((not arg1) + (the-as quaternion #f) + ) + ((zero? arg1) + (the-as quaternion #f) + ) + (else + (cam-slave-get-rot (the-as entity-actor (-> self cam-entity)) sv-192) + (vector-float*! s5-0 s5-0 100.0) + (matrix-rotate-x! s1-1 (- (-> s5-0 x))) + (matrix*! sv-192 s1-1 sv-192) + (matrix-rotate-y! s1-1 (-> s5-0 y)) + (matrix*! sv-192 sv-192 s1-1) + (matrix-rotate-z! s1-1 (- (-> s5-0 z))) + (matrix*! sv-192 s1-1 sv-192) + (matrix->quaternion s0-1 sv-192) + (quaternion-inverse! (the-as quaternion s2-0) (the-as quaternion (-> self cam-entity connect))) + (quaternion*! (the-as quaternion s2-0) s0-1 (the-as quaternion s2-0)) + (quaternion-normalize! (the-as quaternion s2-0)) + ) + ) + ) + ) + ) + (set-setting! 'master-options 'set 0.0 32) + #t + ) + +;; definition for function clmf-next-volume +(defbehavior clmf-next-volume cam-layout ((arg0 int)) + (if (zero? (-> self num-volumes)) + (return #f) + ) + (set! (-> self cur-volume) (mod (+ arg0 (-> self cur-volume)) (-> self num-volumes))) + (while (< (-> self cur-volume) 0) + (+! (-> self cur-volume) (-> self num-volumes)) + ) + #t + ) + +;; definition for function clmf-next-vol-dpad +(defun clmf-next-vol-dpad () + (local-vars (a0-1 int)) + (cam-layout-print 16 *camera-layout-message-ypos* "dpad selects volume") + (set! *camera-layout-message-ypos* (+ *camera-layout-message-ypos* 14)) + (cond + ((cpad-pressed? 0 down) + (set! a0-1 1) + ) + ((cpad-pressed? 0 right) + (set! a0-1 1) + ) + ((cpad-pressed? 0 up) + (set! a0-1 -1) + ) + ((cpad-pressed? 0 left) + (set! a0-1 -1) + ) + (else + (set! a0-1 0) + ) + ) + (clmf-next-volume a0-1) + (set-setting! 'master-options 'set 0.0 32) + #t + ) + +;; definition for function clmf-to-edit-cam +(defun clmf-to-edit-cam () + (clmf-next-volume 0) + (set! *clm* *clm-edit*) + #t + ) + +;; definition for symbol *last-cur-entity*, type int +(define *last-cur-entity* -1) + +;; definition for function clmf-next-entity +(defbehavior clmf-next-entity cam-layout ((arg0 int)) + (let ((v1-0 (/ arg0 8))) + (when (zero? (-> self num-entities)) + (set! (-> self cam-entity) #f) + (return #f) + ) + (if (= (- v1-0) (-> self num-entities)) + (set! v1-0 -1) + ) + (if (= v1-0 (-> self num-entities)) + (set! v1-0 1) + ) + (set! (-> self cur-entity) (mod (+ v1-0 (-> self cur-entity)) (-> self num-entities))) + ) + (while (< (-> self cur-entity) 0) + (+! (-> self cur-entity) (-> self num-entities)) + ) + (set! *last-cur-entity* (-> self cur-entity)) + (let ((v1-8 (-> self cur-entity)) + (a0-13 (-> *camera-engine* alive-list next0)) + ) + *camera-engine* + (let ((a1-3 (-> a0-13 next0))) + (while (!= a0-13 (-> *camera-engine* alive-list-end)) + (let ((a0-14 (-> (the-as connection a0-13) param1))) + (cond + ((zero? v1-8) + (set! (-> self cam-entity) (the-as entity-camera a0-14)) + (set! *volume-descriptor-current* 0) + (set! *volume-point-current* 0) + (set! *volume-normal-current* 0) + (set! (-> self num-volumes) 0) + (cam-layout-entity-volume-info-create (-> self cam-entity) 'vol) + (set! (-> self first-pvol) (-> self num-volumes)) + (cam-layout-entity-volume-info-create (-> self cam-entity) 'pvol) + (set! (-> self first-cutoutvol) (-> self num-volumes)) + (cam-layout-entity-volume-info-create (-> self cam-entity) 'cutoutvol) + (set! (-> *CAM_LAYOUT-bank* intro-step) (cam-slave-get-intro-step (-> self cam-entity))) + (return #f) + ) + (else + (+! v1-8 -1) + ) + ) + ) + (set! a0-13 a1-3) + *camera-engine* + (set! a1-3 (-> a1-3 next0)) + ) + ) + ) + #t + ) + +;; definition for function clmf-to-spline-attr +(defun clmf-to-spline-attr () + (set! *clm* *clm-spline-attr*) + #t + ) + +;; definition for function clmf-to-intro-attr +(defun clmf-to-intro-attr () + (set! *clm* *clm-intro-attr*) + #t + ) + +;; definition for function clmf-to-index-attr +(defun clmf-to-index-attr () + (set! *clm* *clm-index-attr*) + #t + ) + +;; definition for function clmf-to-focalpull-attr +(defun clmf-to-focalpull-attr () + (set! *clm* *clm-focalpull-attr*) + #t + ) + +;; definition for function clmf-to-edit +(defbehavior clmf-to-edit cam-layout () + (set! (-> self res-key) -1000000000.0) + (set! *clm* *clm-edit*) + #t + ) + +;; definition for function clmf-to-select +(defun clmf-to-select () + (set! *camera-layout-blink* #f) + (set! *clm* *clm-select*) + #t + ) + +;; definition for function clmf-look-through +;; INFO: Used lq/sq +(defbehavior clmf-look-through cam-layout () + (set! (-> *camera-other-fov* data) (cam-slave-get-fov (-> self cam-entity))) + (cam-slave-get-vector-with-offset (the-as entity-actor (-> self cam-entity)) *camera-other-trans* 'trans) + (set! (-> *camera-other-root* quad) (-> *camera-other-trans* quad)) + (cam-slave-get-rot (the-as entity-actor (-> self cam-entity)) *camera-other-matrix*) + (set! *camera-look-through-other* 10) + (set-setting! 'master-options 'set 0.0 32) + #f + ) + +;; definition for function fov->maya +(defun fov->maya ((arg0 float)) + (if (= arg0 0.0) + 0.0 + (/ 12.700255 (tan (* 0.5 arg0))) + ) + ) + +;; definition for function cam-layout-save-cam-rot +;; WARN: Return type mismatch object vs none. +(defun cam-layout-save-cam-rot ((arg0 symbol) (arg1 string) (arg2 entity-actor)) + (let ((s3-0 (-> arg2 quat)) + (s5-0 (res-lump-struct arg2 'rot-offset vector)) + ) + (if arg0 + (format #t "setup rot ~f ~f ~f ~f~%" (-> s3-0 x) (-> s3-0 y) (-> s3-0 z) (-> s3-0 w)) + ) + (when s5-0 + (if arg0 + (format #t "rot offset ~f ~f ~f ~f~%" (-> s5-0 x) (-> s5-0 y) (-> s5-0 z) (-> s5-0 w)) + ) + (format + arg1 + " tag rot-offset ~f ~f ~f ~f // vector (quaternion)~%" + (-> s5-0 x) + (-> s5-0 y) + (-> s5-0 z) + (-> s5-0 w) + ) + ) + ) + (none) + ) + +;; definition for function cam-layout-save-cam-trans +;; INFO: Used lq/sq +;; WARN: Return type mismatch object vs none. +(defun cam-layout-save-cam-trans ((arg0 symbol) (arg1 string) (arg2 entity-actor)) + (let ((s1-0 (-> arg2 trans)) + (s5-0 (method-of-type res-lump get-property-struct)) + (s2-0 arg2) + ) + (format (clear *res-key-string*) "~S~S" 'trans '-offset) + (let ((s5-1 (the-as object (s5-0 + s2-0 + (string->symbol *res-key-string*) + 'interp + -1000000000.0 + (the-as structure #f) + (the-as (pointer res-tag) #f) + *res-static-buf* + ) + ) + ) + ) + (let ((s2-1 (the-as object (res-lump-struct arg2 'translation_info vector))) + (s3-1 (new-stack-vector0)) + ) + (if arg0 + (format #t "setup trans ~M ~M ~M (maya)~%" (-> s1-0 x) (-> s1-0 y) (-> s1-0 z)) + ) + (set! (-> s3-1 quad) (-> s1-0 quad)) + (when (the-as vector s5-1) + (if arg0 + (format + #t + "offset ~M ~M ~M (added)~%" + (-> (the-as vector s5-1) x) + (-> (the-as vector s5-1) y) + (-> (the-as vector s5-1) z) + ) + ) + (vector+! s3-1 s3-1 (the-as vector s5-1)) + ) + (when (the-as vector s2-1) + (if arg0 + (format + #t + "level-trans ~M ~M ~M (subtracted)~%" + (-> (the-as vector s2-1) x) + (-> (the-as vector s2-1) y) + (-> (the-as vector s2-1) z) + ) + ) + (vector-! s3-1 s3-1 (the-as vector s2-1)) + ) + (set! s2-1 (or (the-as vector s5-1) s2-1)) + (set! arg0 (and (the-as symbol s2-1) arg0)) + (if arg0 + (format #t "final trans ~M ~M ~M (maya)~%" (-> s3-1 x) (-> s3-1 y) (-> s3-1 z)) + ) + ) + (if (the-as vector s5-1) + (format + arg1 + " tag trans-offset METERS(~M) METERS(~M) METERS(~M) 1.0 // vector~%" + (-> (the-as vector s5-1) x) + (-> (the-as vector s5-1) y) + (-> (the-as vector s5-1) z) + ) + ) + ) + ) + (none) + ) + +;; definition for function cam-layout-save-pivot +;; INFO: Used lq/sq +;; WARN: Return type mismatch object vs none. +(defun cam-layout-save-pivot ((arg0 symbol) (arg1 string) (arg2 entity-actor)) + (let ((s2-0 (res-lump-struct arg2 'pivot vector)) + (s4-0 (method-of-type res-lump get-property-struct)) + ) + (format (clear *res-key-string*) "~S~S" 'pivot '-offset) + (let ((s5-1 (the-as vector (s4-0 + arg2 + (string->symbol *res-key-string*) + 'interp + -1000000000.0 + (the-as structure #f) + (the-as (pointer res-tag) #f) + *res-static-buf* + ) + ) + ) + (s4-1 (new-stack-vector0)) + ) + (when s2-0 + (if s5-1 + (vector+! s4-1 s2-0 s5-1) + (set! (-> s4-1 quad) (-> s2-0 quad)) + ) + (if arg0 + (format #t "setup pivot ~M ~M ~M~%" (-> s2-0 x) (-> s2-0 y) (-> s2-0 z)) + ) + (when s5-1 + (when arg0 + (format #t "offset ~M ~M ~M~%" (-> s5-1 x) (-> s5-1 y) (-> s5-1 z)) + (format #t "final pivot ~M ~M ~M~%" (-> s4-1 x) (-> s4-1 y) (-> s4-1 z)) + ) + (format + arg1 + " tag pivot-offset METERS(~M) METERS(~M) METERS(~M) 1.0 // vector~%" + (-> s5-1 x) + (-> s5-1 y) + (-> s5-1 z) + ) + ) + ) + ) + ) + (none) + ) + +;; definition for function cam-layout-save-align +;; INFO: Used lq/sq +;; WARN: Return type mismatch object vs none. +(defun cam-layout-save-align ((arg0 symbol) (arg1 string) (arg2 entity-actor)) + (let ((s2-0 (res-lump-struct arg2 'align vector)) + (s4-0 (method-of-type res-lump get-property-struct)) + ) + (format (clear *res-key-string*) "~S~S" 'align '-offset) + (let ((s5-1 (the-as vector (s4-0 + arg2 + (string->symbol *res-key-string*) + 'interp + -1000000000.0 + (the-as structure #f) + (the-as (pointer res-tag) #f) + *res-static-buf* + ) + ) + ) + (s4-1 (new-stack-vector0)) + ) + (when s2-0 + (if s5-1 + (vector+! s4-1 s2-0 s5-1) + (set! (-> s4-1 quad) (-> s2-0 quad)) + ) + (if arg0 + (format #t "setup align ~M ~M ~M~%" (-> s2-0 x) (-> s2-0 y) (-> s2-0 z)) + ) + (when s5-1 + (when arg0 + (format #t "offset ~M ~M ~M~%" (-> s5-1 x) (-> s5-1 y) (-> s5-1 z)) + (format #t "final align ~M ~M ~M~%" (-> s4-1 x) (-> s4-1 y) (-> s4-1 z)) + ) + (format + arg1 + " tag align-offset METERS(~M) METERS(~M) METERS(~M) 1.0 // vector~%" + (-> s5-1 x) + (-> s5-1 y) + (-> s5-1 z) + ) + ) + ) + ) + ) + (none) + ) + +;; definition for function cam-layout-save-interesting +;; INFO: Used lq/sq +;; WARN: Return type mismatch object vs none. +(defun cam-layout-save-interesting ((arg0 symbol) (arg1 string) (arg2 entity-actor)) + (let ((s2-0 (res-lump-struct arg2 'interesting vector)) + (s4-0 (method-of-type res-lump get-property-struct)) + ) + (format (clear *res-key-string*) "~S~S" 'interesting '-offset) + (let ((s5-1 (the-as vector (s4-0 + arg2 + (string->symbol *res-key-string*) + 'interp + -1000000000.0 + (the-as structure #f) + (the-as (pointer res-tag) #f) + *res-static-buf* + ) + ) + ) + (s4-1 (new-stack-vector0)) + ) + (when s2-0 + (if s5-1 + (vector+! s4-1 s2-0 s5-1) + (set! (-> s4-1 quad) (-> s2-0 quad)) + ) + (if arg0 + (format #t "setup interesting ~M ~M ~M~%" (-> s2-0 x) (-> s2-0 y) (-> s2-0 z)) + ) + (when s5-1 + (when arg0 + (format #t "offset ~M ~M ~M~%" (-> s5-1 x) (-> s5-1 y) (-> s5-1 z)) + (format #t "final interesting ~M ~M ~M~%" (-> s4-1 x) (-> s4-1 y) (-> s4-1 z)) + ) + (format + arg1 + " tag interesting-offset METERS(~M) METERS(~M) METERS(~M) 1.0 // vector~%" + (-> s5-1 x) + (-> s5-1 y) + (-> s5-1 z) + ) + ) + ) + ) + ) + (none) + ) + +;; definition for function cam-layout-save-fov +;; WARN: Return type mismatch object vs none. +(defun cam-layout-save-fov ((arg0 symbol) (arg1 string) (arg2 entity-actor)) + (let ((f28-0 (res-lump-float arg2 'fov)) + (s3-0 (method-of-type res-lump get-property-value-float)) + ) + (format (clear *res-key-string*) "~S~S" 'fov '-offset) + (let ((f30-0 (s3-0 + arg2 + (string->symbol *res-key-string*) + 'interp + -1000000000.0 + 0.0 + (the-as (pointer res-tag) #f) + *res-static-buf* + ) + ) + ) + (cond + ((= f28-0 0.0) + (if arg0 + (format #t "setup fov deg 0.0 (defaults to 64.0)~%") + ) + (set! f28-0 11650.845) + ) + (arg0 + (format #t "setup fov deg ~R (~f in maya)~%" f28-0 (fov->maya f28-0)) + ) + ) + (when (!= f30-0 0.0) + (when arg0 + (format #t "offset ~R~%" f30-0) + (format #t "final ~R (~f in maya) ~%" (+ f28-0 f30-0) (fov->maya (+ f28-0 f30-0))) + ) + (format arg1 " tag fov-offset DEG(~R) // float~%" f30-0) + ) + ) + ) + (none) + ) + +;; definition for function cam-layout-save-focalpull +;; WARN: Return type mismatch object vs none. +(defun cam-layout-save-focalpull ((arg0 symbol) (arg1 string) (arg2 entity-actor)) + (let ((f30-0 (res-lump-float arg2 'focalpull)) + (s3-0 (method-of-type res-lump get-property-value-float)) + ) + (format (clear *res-key-string*) "~S~S" 'focalpull '-offset) + (let ((f28-0 (s3-0 + arg2 + (string->symbol *res-key-string*) + 'interp + -1000000000.0 + 0.0 + (the-as (pointer res-tag) #f) + *res-static-buf* + ) + ) + ) + (if arg0 + (format #t "setup focalpull deg ~R (~f in maya)~%" f30-0 (fov->maya f30-0)) + ) + (when (!= f28-0 0.0) + (when arg0 + (format #t "offset ~R~%" f28-0) + (format #t "final ~R (~f in maya) ~%" (+ f30-0 f28-0) (fov->maya (+ f30-0 f28-0))) + ) + (format arg1 " tag focalpull-offset DEG(~R) // float~%" f28-0) + ) + ) + ) + (none) + ) + +;; definition for function cam-layout-save-flags +;; WARN: Return type mismatch object vs none. +(defun cam-layout-save-flags ((arg0 symbol) (arg1 string) (arg2 entity-actor)) + (let ((s4-0 (res-lump-value arg2 'flags uint128 :time -1000000000.0)) + (s5-0 (method-of-type res-lump get-property-value)) + (s1-0 arg2) + ) + (format (clear *res-key-string*) "~S~S" 'flags '-on) + (let ((s5-1 (s5-0 + s1-0 + (string->symbol *res-key-string*) + 'interp + -1000000000.0 + (the-as uint128 0) + (the-as (pointer res-tag) #f) + *res-static-buf* + ) + ) + (s1-1 (method-of-type res-lump get-property-value)) + ) + (format (clear *res-key-string*) "~S~S" 'flags '-off) + (let ((s3-1 (s1-1 + arg2 + (string->symbol *res-key-string*) + 'interp + -1000000000.0 + (the-as uint128 0) + (the-as (pointer res-tag) #f) + *res-static-buf* + ) + ) + ) + (when arg0 + (format #t "setup flags ") + (cam-slave-options->string (the-as cam-slave-options s4-0) #t) + (format #t "~%") + (format #t "forced on ") + (cam-slave-options->string (the-as cam-slave-options s5-1) #t) + (format #t "~%") + (format #t "forced off ") + (cam-slave-options->string (the-as cam-slave-options s3-1) #t) + (format #t "~%") + (let ((s4-1 (logclear (logior s4-0 s5-1) s3-1))) + (format #t "final ") + (cam-slave-options->string (the-as cam-slave-options s4-1) #t) + ) + (format #t "~%") + ) + (format arg1 " tag flags-on 0x~X // int32~%" s5-1) + (format arg1 " tag flags-off 0x~X // int32~%" s3-1) + ) + ) + ) + (none) + ) + +;; definition for function cam-layout-save-focalpull-flags +;; WARN: Return type mismatch object vs none. +(defun cam-layout-save-focalpull-flags ((arg0 symbol) (arg1 string) (arg2 entity-actor)) + (let ((s4-0 (res-lump-value arg2 'focalpull-flags uint128 :time -1000000000.0)) + (s5-0 (method-of-type res-lump get-property-value)) + (s1-0 arg2) + ) + (format (clear *res-key-string*) "~S~S" 'focalpull-flags '-on) + (let ((s5-1 (s5-0 + s1-0 + (string->symbol *res-key-string*) + 'interp + -1000000000.0 + (the-as uint128 0) + (the-as (pointer res-tag) #f) + *res-static-buf* + ) + ) + (s1-1 (method-of-type res-lump get-property-value)) + ) + (format (clear *res-key-string*) "~S~S" 'focalpull-flags '-off) + (let ((s3-1 (s1-1 + arg2 + (string->symbol *res-key-string*) + 'interp + -1000000000.0 + (the-as uint128 0) + (the-as (pointer res-tag) #f) + *res-static-buf* + ) + ) + ) + (when arg0 + (format #t "setup focalpull-flags ") + (cam-index-options->string (the-as cam-index-options s4-0) #t) + (format #t "~%") + (format #t "forced on ") + (cam-index-options->string (the-as cam-index-options s5-1) #t) + (format #t "~%") + (format #t "forced off ") + (cam-index-options->string (the-as cam-index-options s3-1) #t) + (format #t "~%") + (let ((s4-1 (logclear (logior s4-0 s5-1) s3-1))) + (format #t "final ") + (cam-index-options->string (the-as cam-index-options s4-1) #t) + ) + (format #t "~%") + ) + (format arg1 " tag focalpull-flags-on 0x~X // int32~%" s5-1) + (format arg1 " tag focalpull-flags-off 0x~X // int32~%" s3-1) + ) + ) + ) + (none) + ) + +;; definition for function cam-layout-save-campoints-flags +;; WARN: Return type mismatch object vs none. +(defun cam-layout-save-campoints-flags ((arg0 symbol) (arg1 string) (arg2 entity-actor)) + (let ((s4-0 (res-lump-value arg2 'campoints-flags uint128 :time -1000000000.0)) + (s5-0 (method-of-type res-lump get-property-value)) + (s1-0 arg2) + ) + (format (clear *res-key-string*) "~S~S" 'campoints-flags '-on) + (let ((s5-1 (s5-0 + s1-0 + (string->symbol *res-key-string*) + 'interp + -1000000000.0 + (the-as uint128 0) + (the-as (pointer res-tag) #f) + *res-static-buf* + ) + ) + (s1-1 (method-of-type res-lump get-property-value)) + ) + (format (clear *res-key-string*) "~S~S" 'campoints-flags '-off) + (let ((s3-1 (s1-1 + arg2 + (string->symbol *res-key-string*) + 'interp + -1000000000.0 + (the-as uint128 0) + (the-as (pointer res-tag) #f) + *res-static-buf* + ) + ) + ) + (when arg0 + (format #t "setup campoints-flags ") + (cam-index-options->string (the-as cam-index-options s4-0) #t) + (format #t "~%") + (format #t "forced on ") + (cam-index-options->string (the-as cam-index-options s5-1) #t) + (format #t "~%") + (format #t "forced off ") + (cam-index-options->string (the-as cam-index-options s3-1) #t) + (format #t "~%") + (let ((s4-1 (logclear (logior s4-0 s5-1) s3-1))) + (format #t "final ") + (cam-index-options->string (the-as cam-index-options s4-1) #t) + ) + (format #t "~%") + ) + (format arg1 " tag campoints-flags-on 0x~X // int32~%" s5-1) + (format arg1 " tag campoints-flags-off 0x~X // int32~%" s3-1) + ) + ) + ) + (none) + ) + +;; definition for function cam-layout-save-introsplinetime +;; WARN: Return type mismatch object vs none. +(defun cam-layout-save-introsplinetime ((arg0 symbol) (arg1 string) (arg2 entity-actor)) + (let ((f28-0 (res-lump-float arg2 'intro-time)) + (s3-0 (method-of-type res-lump get-property-value-float)) + ) + (format (clear *res-key-string*) "~S~S" 'intro-time '-offset) + (let ((f30-0 (s3-0 + arg2 + (string->symbol *res-key-string*) + 'interp + -1000000000.0 + 0.0 + (the-as (pointer res-tag) #f) + *res-static-buf* + ) + ) + ) + (cond + ((= f28-0 0.0) + (if arg0 + (format #t "setup intro-time 0.0 (defaults to 1 sec)~%") + ) + (set! f28-0 1.0) + ) + (arg0 + (format #t "setup intro-time ~f~%" f28-0) + ) + ) + (when (!= f30-0 0.0) + (when arg0 + (format #t "offset ~f~%" f30-0) + (format #t "final ~f~%" (+ f28-0 f30-0)) + ) + (format arg1 " tag intro-time-offset SECONDS(~f) // float~%" f30-0) + ) + ) + ) + (none) + ) + +;; definition for function cam-layout-save-introsplineexitval +;; WARN: Return type mismatch object vs none. +(defun cam-layout-save-introsplineexitval ((arg0 symbol) (arg1 string) (arg2 entity-actor)) + (let ((f30-0 (res-lump-float arg2 'intro-exitValue)) + (s3-0 (method-of-type res-lump get-property-value-float)) + ) + (format (clear *res-key-string*) "~S~S" 'intro-exitValue '-offset) + (let ((f28-0 (s3-0 + arg2 + (string->symbol *res-key-string*) + 'interp + -1000000000.0 + 0.0 + (the-as (pointer res-tag) #f) + *res-static-buf* + ) + ) + ) + (when arg0 + (if (= f30-0 0.0) + (format #t "setup intro-exitValue 0.0 (defaults to 0.5)~%") + (format #t "setup intro-exitValue ~f~%" f30-0) + ) + ) + (when (!= f28-0 0.0) + (when arg0 + (format #t "offset ~f~%" f28-0) + (format #t "final ~f~%" (+ f30-0 f28-0)) + ) + (format arg1 " tag intro-exitValue-offset ~f // float~%" f28-0) + ) + ) + ) + (none) + ) + +;; definition for function cam-layout-save-interptime +;; WARN: Return type mismatch object vs none. +(defun cam-layout-save-interptime ((arg0 symbol) (arg1 string) (arg2 entity-actor)) + (let ((f30-0 (res-lump-float arg2 'interpTime)) + (s3-0 (method-of-type res-lump get-property-value-float)) + ) + (format (clear *res-key-string*) "~S~S" 'interpTime '-offset) + (let ((f28-0 (s3-0 + arg2 + (string->symbol *res-key-string*) + 'interp + -1000000000.0 + 0.0 + (the-as (pointer res-tag) #f) + *res-static-buf* + ) + ) + ) + (if arg0 + (format #t "setup interpTime ~f~%" f30-0) + ) + (when (!= f28-0 0.0) + (when arg0 + (format #t "offset ~f~%" f28-0) + (format #t "final ~f~%" (+ f30-0 f28-0)) + ) + (format arg1 " tag interpTime-offset SECONDS(~f) // float~%" f28-0) + ) + ) + ) + (none) + ) + +;; definition for function cam-layout-save-splineoffset +;; WARN: Return type mismatch object vs none. +(defun cam-layout-save-splineoffset ((arg0 symbol) (arg1 string) (arg2 entity-actor)) + (when (and (not (res-lump-struct arg2 'pivot structure)) (res-lump-struct arg2 'spline-offset vector)) + (let ((s5-1 (res-lump-struct arg2 'spline-offset vector))) + (when s5-1 + (if arg0 + (format #t "spline offset ~M ~M ~M~%" (-> s5-1 x) (-> s5-1 y) (-> s5-1 z)) + ) + (format + arg1 + " tag spline-offset METERS(~M) METERS(~M) METERS(~M) 1.0 // vector~%" + (-> s5-1 x) + (-> s5-1 y) + (-> s5-1 z) + ) + ) + ) + ) + (none) + ) + +;; definition for function cam-layout-save-spline-follow-dist-offset +;; WARN: Return type mismatch object vs none. +(defun cam-layout-save-spline-follow-dist-offset ((arg0 symbol) (arg1 string) (arg2 entity-actor)) + (let ((f30-0 (res-lump-float arg2 'spline-follow-dist-offset))) + (when (the int f30-0) + (if arg0 + (format #t "spline follow dist offset ~M~%" f30-0) + ) + (format arg1 " tag spline-follow-dist-offset METERS(~M)~%" f30-0) + ) + ) + (none) + ) + +;; definition for function cam-layout-save-campointsoffset +;; WARN: Return type mismatch object vs none. +(defun cam-layout-save-campointsoffset ((arg0 symbol) (arg1 string) (arg2 entity-actor)) + (let ((s5-0 (res-lump-struct arg2 'campoints-offset vector))) + (when s5-0 + (if arg0 + (format #t "index offset ~M ~M ~M~%" (-> s5-0 x) (-> s5-0 y) (-> s5-0 z)) + ) + (format + arg1 + " tag campoints-offset METERS(~M) METERS(~M) METERS(~M) 1.0 // vector~%" + (-> s5-0 x) + (-> s5-0 y) + (-> s5-0 z) + ) + ) + ) + (none) + ) + +;; definition for function cam-layout-save-tiltAdjust +;; WARN: Return type mismatch object vs none. +(defun cam-layout-save-tiltAdjust ((arg0 symbol) (arg1 string) (arg2 entity-actor)) + (let ((f30-0 (res-lump-float arg2 'tiltAdjust)) + (s3-0 (method-of-type res-lump get-property-value-float)) + ) + (format (clear *res-key-string*) "~S~S" 'tiltAdjust '-offset) + (let ((f28-0 (s3-0 + arg2 + (string->symbol *res-key-string*) + 'interp + -1000000000.0 + 0.0 + (the-as (pointer res-tag) #f) + *res-static-buf* + ) + ) + ) + (if arg0 + (format #t "setup tiltAdjust deg ~R~%" f30-0) + ) + (when (!= f28-0 0.0) + (when arg0 + (format #t "offset ~R~%" f28-0) + (format #t "final ~R~%" (+ f30-0 f28-0)) + ) + (format arg1 " tag tiltAdjust-offset DEG(~R) // float~%" f28-0) + ) + ) + ) + (none) + ) + +;; definition for function cam-layout-save-stringMinLength +;; WARN: Return type mismatch object vs none. +(defun cam-layout-save-stringMinLength ((arg0 symbol) (arg1 string) (arg2 entity-actor)) + (let ((f30-0 (res-lump-float arg2 'stringMinLength)) + (s3-0 (method-of-type res-lump get-property-value-float)) + ) + (format (clear *res-key-string*) "~S~S" 'stringMinLength '-offset) + (let ((f28-0 (s3-0 + arg2 + (string->symbol *res-key-string*) + 'interp + -1000000000.0 + 0.0 + (the-as (pointer res-tag) #f) + *res-static-buf* + ) + ) + ) + (if arg0 + (format #t "setup stringMinLength ~M~%" f30-0) + ) + (when (!= f28-0 0.0) + (when arg0 + (format #t "offset ~M~%" f28-0) + (format #t "final ~M~%" (+ f30-0 f28-0)) + ) + (format arg1 " tag stringMinLength-offset METERS(~M) // float~%" f28-0) + ) + ) + ) + (none) + ) + +;; definition for function cam-layout-save-stringMaxLength +;; WARN: Return type mismatch object vs none. +(defun cam-layout-save-stringMaxLength ((arg0 symbol) (arg1 string) (arg2 entity-actor)) + (let ((f30-0 (res-lump-float arg2 'stringMaxLength)) + (s3-0 (method-of-type res-lump get-property-value-float)) + ) + (format (clear *res-key-string*) "~S~S" 'stringMaxLength '-offset) + (let ((f28-0 (s3-0 + arg2 + (string->symbol *res-key-string*) + 'interp + -1000000000.0 + 0.0 + (the-as (pointer res-tag) #f) + *res-static-buf* + ) + ) + ) + (if arg0 + (format #t "setup stringMaxLength ~M~%" f30-0) + ) + (when (!= f28-0 0.0) + (when arg0 + (format #t "offset ~M~%" f28-0) + (format #t "final ~M~%" (+ f30-0 f28-0)) + ) + (format arg1 " tag stringMaxLength-offset METERS(~M) // float~%" f28-0) + ) + ) + ) + (none) + ) + +;; definition for function cam-layout-save-stringMinHeight +;; WARN: Return type mismatch object vs none. +(defun cam-layout-save-stringMinHeight ((arg0 symbol) (arg1 string) (arg2 entity-actor)) + (let ((f30-0 (res-lump-float arg2 'stringMinHeight)) + (s3-0 (method-of-type res-lump get-property-value-float)) + ) + (format (clear *res-key-string*) "~S~S" 'stringMinHeight '-offset) + (let ((f28-0 (s3-0 + arg2 + (string->symbol *res-key-string*) + 'interp + -1000000000.0 + 0.0 + (the-as (pointer res-tag) #f) + *res-static-buf* + ) + ) + ) + (if arg0 + (format #t "setup stringMinHeight ~M~%" f30-0) + ) + (when (!= f28-0 0.0) + (when arg0 + (format #t "offset ~M~%" f28-0) + (format #t "final ~M~%" (+ f30-0 f28-0)) + ) + (format arg1 " tag stringMinHeight-offset METERS(~M) // float~%" f28-0) + ) + ) + ) + (none) + ) + +;; definition for function cam-layout-save-stringMaxHeight +;; WARN: Return type mismatch object vs none. +(defun cam-layout-save-stringMaxHeight ((arg0 symbol) (arg1 string) (arg2 entity-actor)) + (let ((f30-0 (res-lump-float arg2 'stringMaxHeight)) + (s3-0 (method-of-type res-lump get-property-value-float)) + ) + (format (clear *res-key-string*) "~S~S" 'stringMaxHeight '-offset) + (let ((f28-0 (s3-0 + arg2 + (string->symbol *res-key-string*) + 'interp + -1000000000.0 + 0.0 + (the-as (pointer res-tag) #f) + *res-static-buf* + ) + ) + ) + (if arg0 + (format #t "setup stringMaxHeight ~M~%" f30-0) + ) + (when (!= f28-0 0.0) + (when arg0 + (format #t "offset ~M~%" f28-0) + (format #t "final ~M~%" (+ f30-0 f28-0)) + ) + (format arg1 " tag stringMaxHeight-offset METERS(~M) // float~%" f28-0) + ) + ) + ) + (none) + ) + +;; definition for function cam-layout-save-stringCliffHeight +;; WARN: Return type mismatch object vs none. +(defun cam-layout-save-stringCliffHeight ((arg0 symbol) (arg1 string) (arg2 entity-actor)) + (let ((f30-0 (res-lump-float arg2 'stringCliffHeight)) + (s3-0 (method-of-type res-lump get-property-value-float)) + ) + (format (clear *res-key-string*) "~S~S" 'stringCliffHeight '-offset) + (let ((f28-0 (s3-0 + arg2 + (string->symbol *res-key-string*) + 'interp + -1000000000.0 + 0.0 + (the-as (pointer res-tag) #f) + *res-static-buf* + ) + ) + ) + (if arg0 + (format #t "setup stringCliffHeight ~M~%" f30-0) + ) + (when (!= f28-0 0.0) + (when arg0 + (format #t "offset ~M~%" f28-0) + (format #t "final ~M~%" (+ f30-0 f28-0)) + ) + (format arg1 " tag stringCliffHeight-offset METERS(~M) // float~%" f28-0) + ) + ) + ) + (none) + ) + +;; definition for function cam-layout-save-maxAngle +;; WARN: Return type mismatch object vs none. +(defun cam-layout-save-maxAngle ((arg0 symbol) (arg1 string) (arg2 entity-actor)) + (let ((f30-0 (res-lump-float arg2 'maxAngle)) + (s3-0 (method-of-type res-lump get-property-value-float)) + ) + (format (clear *res-key-string*) "~S~S" 'maxAngle '-offset) + (let ((f28-0 (s3-0 + arg2 + (string->symbol *res-key-string*) + 'interp + -1000000000.0 + 0.0 + (the-as (pointer res-tag) #f) + *res-static-buf* + ) + ) + ) + (if arg0 + (format #t "setup maxAngle ~R~%" f30-0) + ) + (when (!= f28-0 0.0) + (when arg0 + (format #t "offset ~R~%" f28-0) + (format #t "final ~R~%" (+ f30-0 f28-0)) + ) + (format arg1 " tag maxAngle-offset DEG(~R) // float~%" f28-0) + ) + ) + ) + (none) + ) + +;; definition for function clmf-save-single +(defbehavior clmf-save-single cam-layout ((arg0 entity-camera) (arg1 symbol) (arg2 symbol)) + (clear *temp-string*) + (if arg2 + (format *temp-string* "db/caminfo/~s.cam" (res-lump-struct arg0 'name structure)) + (format *temp-string* "db/caminfo/garbage") + ) + (let ((s4-2 (new 'stack 'file-stream *temp-string* 'write))) + (if arg1 + (format #t "---------camera '~S'------------~%" (res-lump-struct arg0 'name structure)) + ) + (format s4-2 "#include /jak3/db/config/standard.m2d~%") + (format s4-2 "camera ~s {~%" (res-lump-struct arg0 'name structure)) + (cam-layout-save-cam-rot arg1 (the-as string s4-2) (the-as entity-actor arg0)) + (cam-layout-save-cam-trans arg1 (the-as string s4-2) (the-as entity-actor arg0)) + (cam-layout-save-pivot arg1 (the-as string s4-2) (the-as entity-actor arg0)) + (cam-layout-save-align arg1 (the-as string s4-2) (the-as entity-actor arg0)) + (cam-layout-save-interesting arg1 (the-as string s4-2) (the-as entity-actor arg0)) + (cam-layout-save-fov arg1 (the-as string s4-2) (the-as entity-actor arg0)) + (cam-layout-save-focalpull arg1 (the-as string s4-2) (the-as entity-actor arg0)) + (cam-layout-save-flags arg1 (the-as string s4-2) (the-as entity-actor arg0)) + (cam-layout-save-introsplinetime arg1 (the-as string s4-2) (the-as entity-actor arg0)) + (cam-layout-save-introsplineexitval arg1 (the-as string s4-2) (the-as entity-actor arg0)) + (cam-layout-save-interptime arg1 (the-as string s4-2) (the-as entity-actor arg0)) + (cam-layout-save-splineoffset arg1 (the-as string s4-2) (the-as entity-actor arg0)) + (cam-layout-save-spline-follow-dist-offset arg1 (the-as string s4-2) (the-as entity-actor arg0)) + (cam-layout-save-campointsoffset arg1 (the-as string s4-2) (the-as entity-actor arg0)) + (cam-layout-save-tiltAdjust arg1 (the-as string s4-2) (the-as entity-actor arg0)) + (cam-layout-save-stringMinLength arg1 (the-as string s4-2) (the-as entity-actor arg0)) + (cam-layout-save-stringMaxLength arg1 (the-as string s4-2) (the-as entity-actor arg0)) + (cam-layout-save-stringMinHeight arg1 (the-as string s4-2) (the-as entity-actor arg0)) + (cam-layout-save-stringMaxHeight arg1 (the-as string s4-2) (the-as entity-actor arg0)) + (cam-layout-save-stringCliffHeight arg1 (the-as string s4-2) (the-as entity-actor arg0)) + (cam-layout-save-maxAngle arg1 (the-as string s4-2) (the-as entity-actor arg0)) + (cam-layout-save-campoints-flags arg1 (the-as string s4-2) (the-as entity-actor arg0)) + (cam-layout-save-focalpull-flags arg1 (the-as string s4-2) (the-as entity-actor arg0)) + (format s4-2 "}~%") + (file-stream-close s4-2) + ) + ) + +;; definition for function clmf-save-one +(defbehavior clmf-save-one cam-layout ((arg0 symbol)) + (let ((s5-1 (logtest? (the-as int arg0) 8)) + (gp-1 (logtest? (the-as int arg0) 16)) + ) + (if s5-1 + (format #t "~%~%~%=================================~%") + ) + (clmf-save-single (-> self cam-entity) s5-1 gp-1) + (if s5-1 + (format #t "===============================~%~%~%~%") + ) + (if gp-1 + (format #t "'~S' save completed~%" (res-lump-struct (-> self cam-entity) 'name structure)) + ) + ) + #t + ) + +;; definition for function clmf-save-all +(defbehavior clmf-save-all cam-layout ((arg0 symbol)) + (let ((s5-1 (logtest? (the-as int arg0) 8)) + (gp-1 (logtest? (the-as int arg0) 16)) + ) + (if s5-1 + (format #t "~%~%~%=================================~%") + ) + (let ((v1-5 (-> *camera-engine* alive-list next0))) + *camera-engine* + (let ((s4-0 (-> v1-5 next0))) + (while (!= v1-5 (-> *camera-engine* alive-list-end)) + (let ((a0-4 (-> (the-as connection v1-5) param1))) + (clmf-save-single (the-as entity-camera a0-4) s5-1 gp-1) + ) + (set! v1-5 s4-0) + *camera-engine* + (set! s4-0 (-> s4-0 next0)) + ) + ) + ) + (if s5-1 + (format #t "===============================~%~%~%~%") + ) + (if gp-1 + (format #t "camera save all completed~%") + ) + ) + #t + ) + +;; definition of type clmf-cam-flag-toggle-info +(deftype clmf-cam-flag-toggle-info (structure) + ((key float) + (force-on int32) + (force-off int32) + ) + ) + +;; definition for method 3 of type clmf-cam-flag-toggle-info +(defmethod inspect ((this clmf-cam-flag-toggle-info)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'clmf-cam-flag-toggle-info) + (format #t "~1Tkey: ~f~%" (-> this key)) + (format #t "~1Tforce-on: ~D~%" (-> this force-on)) + (format #t "~1Tforce-off: ~D~%" (-> this force-off)) + (label cfg-4) + this + ) + +;; definition for function clmf-cam-flag-toggle +(defbehavior clmf-cam-flag-toggle cam-layout ((arg0 int) (arg1 int)) + (let ((s4-0 (/ arg0 8)) + (gp-0 (new 'stack 'clmf-cam-flag-toggle-info)) + ) + (set! (-> gp-0 key) (-> self res-key)) + (cond + ((and (= arg1 'vol-flags) (>= (-> self res-key) (the float (-> self first-cutoutvol)))) + (set! (-> gp-0 key) (- (-> gp-0 key) (the float (-> self first-cutoutvol)))) + (set! arg1 (the-as int 'cutoutvol-flags)) + ) + ((and (= arg1 'vol-flags) (>= (-> self res-key) (the float (-> self first-pvol)))) + (set! (-> gp-0 key) (- (-> gp-0 key) (the float (-> self first-pvol)))) + (set! arg1 (the-as int 'pvol-flags)) + ) + ) + (let ((s3-0 (method-of-type res-lump get-property-value)) + (s2-0 (-> self cam-entity)) + ) + (format (clear *res-key-string*) "~S~S" (the-as object arg1) '-on) + (set! (-> gp-0 force-on) (the-as int (s3-0 + s2-0 + (string->symbol *res-key-string*) + 'exact + (-> gp-0 key) + (the-as uint128 0) + (the-as (pointer res-tag) #f) + *res-static-buf* + ) + ) + ) + ) + (let ((s3-1 (method-of-type res-lump get-property-value)) + (s2-1 (-> self cam-entity)) + ) + (format (clear *res-key-string*) "~S~S" (the-as object arg1) '-off) + (set! (-> gp-0 force-off) (the-as int (s3-1 + s2-1 + (string->symbol *res-key-string*) + 'exact + (-> gp-0 key) + (the-as uint128 0) + (the-as (pointer res-tag) #f) + *res-static-buf* + ) + ) + ) + ) + (cond + ((logtest? (-> gp-0 force-off) s4-0) + (logclear! (-> gp-0 force-off) s4-0) + (logior! (-> gp-0 force-on) s4-0) + (let* ((s4-1 (-> self cam-entity)) + (s3-2 (method-of-object s4-1 add-32bit-data!)) + (s2-2 (logior (shl #x10000 32) (shr (shl (the-as int int32) 32) 32))) + (s1-2 (shl (the-as int (-> gp-0 key)) 32)) + ) + (format (clear *res-key-string*) "~S~S" (the-as object arg1) '-off) + (s3-2 + s4-1 + (the-as + res-tag + (make-u128 s2-2 (logior s1-2 (shr (shl (the-as int (string->symbol *res-key-string*)) 32) 32))) + ) + (-> gp-0 force-off) + ) + ) + (let* ((s4-2 (-> self cam-entity)) + (s3-3 (method-of-object s4-2 add-32bit-data!)) + (s2-3 (logior (shl #x10000 32) (shr (shl (the-as int int32) 32) 32))) + (s1-3 (shl (the-as int (-> gp-0 key)) 32)) + ) + (format (clear *res-key-string*) "~S~S" (the-as object arg1) '-on) + (s3-3 + s4-2 + (the-as + res-tag + (make-u128 s2-3 (logior s1-3 (shr (shl (the-as int (string->symbol *res-key-string*)) 32) 32))) + ) + (-> gp-0 force-on) + ) + ) + ) + ((logtest? (-> gp-0 force-on) s4-0) + (logclear! (-> gp-0 force-on) s4-0) + (let* ((s4-3 (-> self cam-entity)) + (s3-4 (method-of-object s4-3 add-32bit-data!)) + (s2-4 (logior (shl #x10000 32) (shr (shl (the-as int int32) 32) 32))) + (s1-4 (shl (the-as int (-> gp-0 key)) 32)) + ) + (format (clear *res-key-string*) "~S~S" (the-as object arg1) '-on) + (s3-4 + s4-3 + (the-as + res-tag + (make-u128 s2-4 (logior s1-4 (shr (shl (the-as int (string->symbol *res-key-string*)) 32) 32))) + ) + (-> gp-0 force-on) + ) + ) + ) + (else + (logior! (-> gp-0 force-off) s4-0) + (let* ((s4-4 (-> self cam-entity)) + (s3-5 (method-of-object s4-4 add-32bit-data!)) + (s2-5 (logior (shl #x10000 32) (shr (shl (the-as int int32) 32) 32))) + (s1-5 (shl (the-as int (-> gp-0 key)) 32)) + ) + (format (clear *res-key-string*) "~S~S" (the-as object arg1) '-off) + (s3-5 + s4-4 + (the-as + res-tag + (make-u128 s2-5 (logior s1-5 (shr (shl (the-as int (string->symbol *res-key-string*)) 32) 32))) + ) + (-> gp-0 force-off) + ) + ) + ) + ) + ) + #t + ) + +;; definition for function clmf-cam-flag +(defbehavior clmf-cam-flag cam-layout ((arg0 string) (arg1 uint) (arg2 uint)) + (let ((s5-0 (/ (the-as int arg1) 8)) + (f30-0 (-> self res-key)) + ) + (cond + ((and (= arg2 'vol-flags) (>= (-> self res-key) (the float (-> self first-cutoutvol)))) + (set! f30-0 (- f30-0 (the float (-> self first-cutoutvol)))) + (set! arg2 (the-as uint 'cutoutvol-flags)) + ) + ((and (= arg2 'vol-flags) (>= (-> self res-key) (the float (-> self first-pvol)))) + (set! f30-0 (- f30-0 (the float (-> self first-pvol)))) + (set! arg2 (the-as uint 'pvol-flags)) + ) + ) + (let ((s3-0 (method-of-type res-lump get-property-value)) + (s2-0 (-> self cam-entity)) + ) + (format (clear *res-key-string*) "~S~S" (the-as object arg2) '-off) + (cond + ((logtest? (s3-0 + s2-0 + (string->symbol *res-key-string*) + 'exact + f30-0 + (the-as uint128 0) + (the-as (pointer res-tag) #f) + *res-static-buf* + ) + s5-0 + ) + (format arg0 ": off") + ) + ((let ((s3-1 (method-of-type res-lump get-property-value)) + (s2-1 (-> self cam-entity)) + ) + (format (clear *res-key-string*) "~S~S" (the-as object arg2) '-on) + (logtest? (s3-1 + s2-1 + (string->symbol *res-key-string*) + 'exact + f30-0 + (the-as uint128 0) + (the-as (pointer res-tag) #f) + *res-static-buf* + ) + s5-0 + ) + ) + (format arg0 ": on") + ) + ((not (logtest? ((method-of-type res-lump get-property-value) + (-> self cam-entity) + (the-as symbol arg2) + 'exact + f30-0 + (the-as uint128 0) + (the-as (pointer res-tag) #f) + *res-static-buf* + ) + s5-0 + ) + ) + (format arg0 ": off(maya)") + ) + (else + (format arg0 ": on(maya)") + ) + ) + ) + ) + #t + ) + +;; definition for function clmf-cam-float-adjust +(defbehavior clmf-cam-float-adjust cam-layout ((arg0 symbol) (arg1 (pointer float))) + (cam-layout-print 16 *camera-layout-message-ypos* "left stick adjusts value") + (set! *camera-layout-message-ypos* (+ *camera-layout-message-ypos* 14)) + (let ((f30-0 (res-lump-float (-> self cam-entity) arg0)) + (f0-0 (-> arg1 0)) + ) + (if (= f0-0 0.0) + (set! f0-0 1.0) + ) + (let ((f0-2 (+ f30-0 (analog-input (the-as int (-> *cpad-list* cpads 0 leftx)) 128.0 48.0 110.0 f0-0)))) + (add-32bit-data! + (-> self cam-entity) + (new 'static 'res-tag :name arg0 :key-frame -1000000000.0 :elt-count #x1 :elt-type float) + f0-2 + ) + ) + ) + (set-setting! 'master-options 'set 0.0 32) + #t + ) + +;; definition for function clmf-cam-meters +(defbehavior clmf-cam-meters cam-layout ((arg0 meters) (arg1 symbol)) + (let ((f0-0 (cam-slave-get-float (-> self cam-entity) arg1 0.0))) + (format arg0 ": ~M" f0-0) + ) + #t + ) + +;; definition for function clmf-cam-fov +(defbehavior clmf-cam-fov cam-layout ((arg0 degrees) (arg1 symbol)) + (format arg0 ": ~R" (cam-slave-get-fov (-> self cam-entity))) + #t + ) + +;; definition for function clmf-cam-deg +(defbehavior clmf-cam-deg cam-layout ((arg0 degrees) (arg1 symbol)) + (format arg0 ": ~R" (cam-slave-get-float (-> self cam-entity) arg1 0.0)) + #t + ) + +;; definition for function clmf-cam-intro-time +(defbehavior clmf-cam-intro-time cam-layout ((arg0 float) (arg1 symbol)) + (let ((f30-0 (cam-slave-get-intro-step (-> self cam-entity)))) + (format arg0 ": ~f" (/ 0.016666668 f30-0)) + (set! (-> *CAM_LAYOUT-bank* intro-step) f30-0) + ) + #t + ) + +;; definition for function clmf-cam-interp-time +(defbehavior clmf-cam-interp-time cam-layout ((arg0 float) (arg1 symbol)) + (format arg0 ": ~f" (cam-slave-get-interp-time (-> self cam-entity))) + #t + ) + +;; definition for function clmf-cam-float +(defbehavior clmf-cam-float cam-layout ((arg0 float) (arg1 symbol)) + (format arg0 ": ~f" (cam-slave-get-float (-> self cam-entity) arg1 0.0)) + #t + ) + +;; definition for function clmf-cam-string +;; INFO: Used lq/sq +(defbehavior clmf-cam-string cam-layout ((arg0 string) (arg1 symbol)) + (local-vars (r0-0 uint128) (v1-5 uint128) (sv-16 int)) + (format arg0 ":") + (set! sv-16 0) + (let ((s5-1 (res-lump-data (-> self cam-entity) arg1 pointer :tag-ptr (the-as (pointer res-tag) (& sv-16))))) + (when s5-1 + (let ((s4-0 0)) + (while (begin + (let ((v1-4 (the-as uint128 sv-16))) + (.pcpyud v1-5 v1-4 r0-0) + ) + (< s4-0 (shr (* (the-as int v1-5) 2) 49)) + ) + (format arg0 " ~S" (-> (the-as (pointer uint32) (&+ s5-1 (* s4-0 4))))) + (+! s4-0 1) + ) + ) + ) + ) + #t + ) + +;; definition for symbol *clm-focalpull-attr*, type clm +(define *clm-focalpull-attr* + (new 'static 'clm + :title "---focalpull attributes--" + :items (new 'static 'boxed-array :type clm-basic + (new 'static 'clm-item + :description " ok" + :button-symbol 'square + :action (new 'static 'clm-item-action + :button (pad-buttons-u64 square) + :options (clm-item-action-options clm0) + :func '*clm-edit* + ) + ) + (new 'static 'clm-item + :description "adjust" + :button-symbol 'x + :action (new 'static 'clm-item-action :button (pad-buttons-u64 x) :func #f) + ) + (new 'static 'clm-list + :tracker #f + :items (new 'static 'boxed-array :type clm-list-item + (new 'static 'clm-list-item + :description "radial " + :track-val #f + :val-func 'clmf-cam-flag + :val-parm0 16 + :val-parm1 'focalpull-flags + :actions (new 'static 'boxed-array :type clm-item-action + (new 'static 'clm-item-action + :button (pad-buttons-u64 x) + :options (clm-item-action-options clm0) + :func 'clmf-cam-flag-toggle + :parm0 16 + :parm1 'focalpull-flags + ) + ) + ) + (new 'static 'clm-list-item + :description "spherical " + :track-val #f + :val-func 'clmf-cam-flag + :val-parm0 8 + :val-parm1 'focalpull-flags + :actions (new 'static 'boxed-array :type clm-item-action (new 'static 'clm-item-action + :button (pad-buttons-u64 x) + :options (clm-item-action-options clm0) + :func 'clmf-cam-flag-toggle + :parm0 8 + :parm1 'focalpull-flags + ) + ) + ) + ) + ) + ) + ) + ) + +;; definition for symbol *clm-index-attr*, type clm +(define *clm-index-attr* + (new 'static 'clm + :title "---index attributes--" + :items (new 'static 'boxed-array :type clm-basic + (new 'static 'clm-item + :description " ok" + :button-symbol 'square + :action (new 'static 'clm-item-action + :button (pad-buttons-u64 square) + :options (clm-item-action-options clm0) + :func '*clm-edit* + ) + ) + (new 'static 'clm-item + :description "adjust" + :button-symbol 'x + :action (new 'static 'clm-item-action :button (pad-buttons-u64 x) :func #f) + ) + (new 'static 'clm-list + :tracker #f + :items (new 'static 'boxed-array :type clm-list-item + (new 'static 'clm-list-item + :description "radial " + :track-val #f + :val-func 'clmf-cam-flag + :val-parm0 16 + :val-parm1 'campoints-flags + :actions (new 'static 'boxed-array :type clm-item-action + (new 'static 'clm-item-action + :button (pad-buttons-u64 x) + :options (clm-item-action-options clm0) + :func 'clmf-cam-flag-toggle + :parm0 16 + :parm1 'campoints-flags + ) + ) + ) + (new 'static 'clm-list-item + :description "spherical " + :track-val #f + :val-func 'clmf-cam-flag + :val-parm0 8 + :val-parm1 'campoints-flags + :actions (new 'static 'boxed-array :type clm-item-action (new 'static 'clm-item-action + :button (pad-buttons-u64 x) + :options (clm-item-action-options clm0) + :func 'clmf-cam-flag-toggle + :parm0 8 + :parm1 'campoints-flags + ) + ) + ) + ) + ) + ) + ) + ) + +;; definition for symbol *clm-intro-attr*, type clm +(define *clm-intro-attr* + (new 'static 'clm + :title "---intro attributes--" + :items (new 'static 'boxed-array :type clm-basic + (new 'static 'clm-item + :description " ok" + :button-symbol 'square + :action (new 'static 'clm-item-action + :button (pad-buttons-u64 square) + :options (clm-item-action-options clm0) + :func '*clm-edit* + ) + ) + (new 'static 'clm-item + :description "adjust" + :button-symbol 'x + :action (new 'static 'clm-item-action :button (pad-buttons-u64 x) :func #f) + ) + (new 'static 'clm-list + :tracker #f + :items (new 'static 'boxed-array :type clm-list-item + (new 'static 'clm-list-item + :description "time " + :track-val #f + :val-func 'clmf-cam-intro-time + :val-parm0-sym 'intro-time + :actions (new 'static 'boxed-array :type clm-item-action + (new 'static 'clm-item-action + :button (pad-buttons-u64 x) + :func 'clmf-cam-float-adjust + :parm0-sym 'intro-time-offset + :parm1-basic (new 'static 'bfloat :data 0.01) + ) + ) + ) + (new 'static 'clm-list-item + :description "exitValue" + :track-val #f + :val-func 'clmf-cam-float + :val-parm0-sym 'intro-exitValue + :actions (new 'static 'boxed-array :type clm-item-action (new 'static 'clm-item-action + :button (pad-buttons-u64 x) + :func 'clmf-cam-float-adjust + :parm0-sym 'intro-exitValue-offset + :parm1-basic (new 'static 'bfloat :data 0.001) + ) + ) + ) + ) + ) + ) + ) + ) + +;; definition for symbol *clm-spline-attr*, type clm +(define *clm-spline-attr* + (new 'static 'clm + :title "---spline attributes--" + :items (new 'static 'boxed-array :type clm-basic + (new 'static 'clm-item + :description " ok" + :button-symbol 'square + :action (new 'static 'clm-item-action + :button (pad-buttons-u64 square) + :options (clm-item-action-options clm0) + :func '*clm-edit* + ) + ) + (new 'static 'clm-item + :description "adjust" + :button-symbol 'x + :action (new 'static 'clm-item-action :button (pad-buttons-u64 x) :func #f) + ) + (new 'static 'clm-list + :tracker #f + :items (new 'static 'boxed-array :type clm-list-item + (new 'static 'clm-list-item + :description "followDist" + :track-val #f + :val-func 'clmf-cam-meters + :val-parm0-sym 'spline-follow-dist + :actions (new 'static 'boxed-array :type clm-item-action (new 'static 'clm-item-action + :button (pad-buttons-u64 x) + :func 'clmf-cam-float-adjust + :parm0-sym 'spline-follow-dist-offset + :parm1-basic (new 'static 'bfloat :data 409.6) + ) + ) + ) + ) + ) + ) + ) + ) + +;; definition for symbol *clm-cam-attr*, type clm +(define *clm-cam-attr* + (new 'static 'clm + :title "---camera attributes--" + :items (new 'static 'boxed-array :type clm-basic + (new 'static 'clm-item + :description " ok" + :button-symbol 'square + :action (new 'static 'clm-item-action + :button (pad-buttons-u64 square) + :options (clm-item-action-options clm0) + :func '*clm-edit* + ) + ) + (new 'static 'clm-item + :description "adjust" + :button-symbol 'x + :action (new 'static 'clm-item-action :button (pad-buttons-u64 x) :func #f) + ) + (new 'static 'clm-list + :tracker #f + :items (new 'static 'boxed-array :type clm-list-item + (new 'static 'clm-list-item + :description "drag " + :track-val #f + :val-func 'clmf-cam-flag + :val-parm0 #x400 + :val-parm1 'flags + :actions (new 'static 'boxed-array :type clm-item-action + (new 'static 'clm-item-action + :button (pad-buttons-u64 x) + :options (clm-item-action-options clm0) + :func 'clmf-cam-flag-toggle + :parm0 #x400 + :parm1 'flags + ) + ) + ) + (new 'static 'clm-list-item + :description "fov " + :track-val #f + :val-func 'clmf-cam-fov + :val-parm0-sym 'fov + :actions (new 'static 'boxed-array :type clm-item-action + (new 'static 'clm-item-action + :button (pad-buttons-u64 x) + :func 'clmf-cam-float-adjust + :parm0-sym 'fov-offset + :parm1-basic (new 'static 'bfloat :data 91.022224) + ) + ) + ) + (new 'static 'clm-list-item + :description "focalpull " + :track-val #f + :val-func 'clmf-cam-deg + :val-parm0-sym 'focalpull + :actions (new 'static 'boxed-array :type clm-item-action + (new 'static 'clm-item-action + :button (pad-buttons-u64 x) + :func 'clmf-cam-float-adjust + :parm0-sym 'focalpull-offset + :parm1-basic (new 'static 'bfloat :data 91.022224) + ) + ) + ) + (new 'static 'clm-list-item + :description "interpTime " + :track-val #f + :val-func 'clmf-cam-interp-time + :val-parm0-sym 'interpTime + :actions (new 'static 'boxed-array :type clm-item-action + (new 'static 'clm-item-action + :button (pad-buttons-u64 x) + :func 'clmf-cam-float-adjust + :parm0-sym 'interpTime-offset + :parm1-basic (new 'static 'bfloat :data 0.01) + ) + ) + ) + (new 'static 'clm-list-item + :description "sameSide " + :track-val #f + :val-func 'clmf-cam-flag + :val-parm0 16 + :val-parm1 'flags + :actions (new 'static 'boxed-array :type clm-item-action + (new 'static 'clm-item-action + :button (pad-buttons-u64 x) + :options (clm-item-action-options clm0) + :func 'clmf-cam-flag-toggle + :parm0 16 + :parm1 'flags + ) + ) + ) + (new 'static 'clm-list-item + :description "spherical " + :track-val #f + :val-func 'clmf-cam-flag + :val-parm0 32 + :val-parm1 'flags + :actions (new 'static 'boxed-array :type clm-item-action + (new 'static 'clm-item-action + :button (pad-buttons-u64 x) + :options (clm-item-action-options clm0) + :func 'clmf-cam-flag-toggle + :parm0 32 + :parm1 'flags + ) + ) + ) + (new 'static 'clm-list-item + :description "MinLength " + :track-val #f + :val-func 'clmf-cam-meters + :val-parm0-sym 'stringMinLength + :actions (new 'static 'boxed-array :type clm-item-action + (new 'static 'clm-item-action + :button (pad-buttons-u64 x) + :func 'clmf-cam-float-adjust + :parm0-sym 'stringMinLength-offset + :parm1-basic (new 'static 'bfloat :data 409.6) + ) + ) + ) + (new 'static 'clm-list-item + :description "MaxLength " + :track-val #f + :val-func 'clmf-cam-meters + :val-parm0-sym 'stringMaxLength + :actions (new 'static 'boxed-array :type clm-item-action + (new 'static 'clm-item-action + :button (pad-buttons-u64 x) + :func 'clmf-cam-float-adjust + :parm0-sym 'stringMaxLength-offset + :parm1-basic (new 'static 'bfloat :data 409.6) + ) + ) + ) + (new 'static 'clm-list-item + :description "MinHeight " + :track-val #f + :val-func 'clmf-cam-meters + :val-parm0-sym 'stringMinHeight + :actions (new 'static 'boxed-array :type clm-item-action + (new 'static 'clm-item-action + :button (pad-buttons-u64 x) + :func 'clmf-cam-float-adjust + :parm0-sym 'stringMinHeight-offset + :parm1-basic (new 'static 'bfloat :data 409.6) + ) + ) + ) + (new 'static 'clm-list-item + :description "MaxHeight " + :track-val #f + :val-func 'clmf-cam-meters + :val-parm0-sym 'stringMaxHeight + :actions (new 'static 'boxed-array :type clm-item-action + (new 'static 'clm-item-action + :button (pad-buttons-u64 x) + :func 'clmf-cam-float-adjust + :parm0-sym 'stringMaxHeight-offset + :parm1-basic (new 'static 'bfloat :data 409.6) + ) + ) + ) + (new 'static 'clm-list-item + :description "cliffHeight" + :track-val #f + :val-func 'clmf-cam-meters + :val-parm0-sym 'stringCliffHeight + :actions (new 'static 'boxed-array :type clm-item-action + (new 'static 'clm-item-action + :button (pad-buttons-u64 x) + :func 'clmf-cam-float-adjust + :parm0-sym 'stringCliffHeight-offset + :parm1-basic (new 'static 'bfloat :data 409.6) + ) + ) + ) + (new 'static 'clm-list-item + :description "alternates " + :track-val #f + :val-func 'clmf-cam-string + :val-parm0-sym 'alternates + :actions (new 'static 'boxed-array :type clm-item-action) + ) + (new 'static 'clm-list-item + :description "maxAngle " + :track-val #f + :val-func 'clmf-cam-deg + :val-parm0-sym 'maxAngle + :actions (new 'static 'boxed-array :type clm-item-action + (new 'static 'clm-item-action + :button (pad-buttons-u64 x) + :func 'clmf-cam-float-adjust + :parm0-sym 'maxAngle-offset + :parm1-basic (new 'static 'bfloat :data 91.022224) + ) + ) + ) + (new 'static 'clm-list-item + :description "shrinkAngle" + :track-val #f + :val-func 'clmf-cam-flag + :val-parm0 #x4000 + :val-parm1 'flags + :actions (new 'static 'boxed-array :type clm-item-action + (new 'static 'clm-item-action + :button (pad-buttons-u64 x) + :options (clm-item-action-options clm0) + :func 'clmf-cam-flag-toggle + :parm0 #x4000 + :parm1 'flags + ) + ) + ) + (new 'static 'clm-list-item + :description "noRotate " + :track-val #f + :val-func 'clmf-cam-flag + :val-parm0 #x20000 + :val-parm1 'flags + :actions (new 'static 'boxed-array :type clm-item-action + (new 'static 'clm-item-action + :button (pad-buttons-u64 x) + :options (clm-item-action-options clm0) + :func 'clmf-cam-flag-toggle + :parm0 #x20000 + :parm1 'flags + ) + ) + ) + (new 'static 'clm-list-item + :description "tiltAdjust " + :track-val #f + :val-func 'clmf-cam-deg + :val-parm0-sym 'tiltAdjust + :actions (new 'static 'boxed-array :type clm-item-action + (new 'static 'clm-item-action + :button (pad-buttons-u64 x) + :func 'clmf-cam-float-adjust + :parm0-sym 'tiltAdjust-offset + :parm1-basic (new 'static 'bfloat :data 91.022224) + ) + ) + ) + (new 'static 'clm-list-item + :description "stickyAngle" + :track-val #f + :val-func 'clmf-cam-flag + :val-parm0 #x40000 + :val-parm1 'flags + :actions (new 'static 'boxed-array :type clm-item-action + (new 'static 'clm-item-action + :button (pad-buttons-u64 x) + :options (clm-item-action-options clm0) + :func 'clmf-cam-flag-toggle + :parm0 #x40000 + :parm1 'flags + ) + ) + ) + (new 'static 'clm-list-item + :description "easeSpline " + :track-val #f + :val-func 'clmf-cam-flag + :val-parm0 #x1000000 + :val-parm1 'flags + :actions (new 'static 'boxed-array :type clm-item-action + (new 'static 'clm-item-action + :button (pad-buttons-u64 x) + :options (clm-item-action-options clm0) + :func 'clmf-cam-flag-toggle + :parm0 #x1000000 + :parm1 'flags + ) + ) + ) + (new 'static 'clm-list-item + :description "jumpPitch " + :track-val #f + :val-func 'clmf-cam-flag + :val-parm0 #x80 + :val-parm1 'flags + :actions (new 'static 'boxed-array :type clm-item-action + (new 'static 'clm-item-action + :button (pad-buttons-u64 x) + :options (clm-item-action-options clm0) + :func 'clmf-cam-flag-toggle + :parm0 #x80 + :parm1 'flags + ) + ) + ) + (new 'static 'clm-list-item + :description "rapid " + :track-val #f + :val-func 'clmf-cam-flag + :val-parm0 #x800000 + :val-parm1 'flags + :actions (new 'static 'boxed-array :type clm-item-action (new 'static 'clm-item-action + :button (pad-buttons-u64 x) + :options (clm-item-action-options clm0) + :func 'clmf-cam-flag-toggle + :parm0 #x800000 + :parm1 'flags + ) + ) + ) + ) + ) + ) + ) + ) + +;; definition for symbol *clm-cam-lookthrough*, type clm +(define *clm-cam-lookthrough* + (new 'static 'clm + :title "---cam-lookthrough---" + :items (new 'static 'boxed-array :type clm-basic + (new 'static 'clm-item + :description " " + :button-symbol 'x + :action (new 'static 'clm-item-action + :button (pad-buttons-u64 x) + :options (clm-item-action-options clm2) + :func 'clmf-look-through + ) + ) + (new 'static 'clm-item + :description " ok" + :button-symbol 'square + :action (new 'static 'clm-item-action + :button (pad-buttons-u64 square) + :options (clm-item-action-options clm0) + :func 'clmf-to-edit + ) + ) + (new 'static 'clm-item + :description "pos/rot" + :button-symbol 'x + :action (new 'static 'clm-item-action + :button (pad-buttons-u64 x) + :options (clm-item-action-options clm3) + :func 'clmf-pos-rot + :parm0-sym 'trans-offset + :parm1 'rot-offset + ) + ) + (new 'static 'clm-item + :description " adjust" + :button-symbol 'x + :action (new 'static 'clm-item-action :button (pad-buttons-u64 x) :func #f) + ) + (new 'static 'clm-list + :tracker #f + :items (new 'static 'boxed-array :type clm-list-item + (new 'static 'clm-list-item + :description "fov" + :track-val #f + :val-func 'clmf-cam-fov + :val-parm0-sym 'fov + :actions (new 'static 'boxed-array :type clm-item-action (new 'static 'clm-item-action + :button (pad-buttons-u64 x) + :func 'clmf-cam-float-adjust + :parm0-sym 'fov-offset + :parm1-basic (new 'static 'bfloat :data 91.022224) + ) + ) + ) + ) + ) + ) + ) + ) + +;; definition for symbol *clm-edit*, type clm +(define *clm-edit* + (new 'static 'clm + :title "---edit---" + :items (new 'static 'boxed-array :type clm-basic + (new 'static 'clm-item + :description " ok" + :button-symbol 'square + :action (new 'static 'clm-item-action + :button (pad-buttons-u64 square) + :options (clm-item-action-options clm0) + :func 'clmf-to-select + ) + ) + (new 'static 'clm-item + :description "attributes" + :button-symbol 'x + :action (new 'static 'clm-item-action :button (pad-buttons-u64 x) :options (clm-item-action-options clm0) :func #f) + ) + (new 'static 'clm-item + :description " edit part" + :button-symbol 'circle + :action (new 'static 'clm-item-action + :button (pad-buttons-u64 circle) + :options (clm-item-action-options clm0) + :func #f + ) + ) + (new 'static 'clm-item + :description "scale/next" + :button-symbol 'r2 + :action (new 'static 'clm-item-action :button (pad-buttons-u64 r2) :func #f) + ) + (new 'static 'clm-item + :description " pos/rot" + :button-symbol 'l2 + :action (new 'static 'clm-item-action :button (pad-buttons-u64 l2) :func #f) + ) + (new 'static 'clm-list + :tracker '*camera-layout-blink* + :items (new 'static 'boxed-array :type clm-list-item + (new 'static 'clm-list-item + :description "camera " + :track-val 'camera + :val-func #f + :actions (new 'static 'boxed-array :type clm-item-action + (new 'static 'clm-item-action + :button (pad-buttons-u64 x) + :options (clm-item-action-options clm0) + :func '*clm-cam-attr* + ) + (new 'static 'clm-item-action :button (pad-buttons-u64 circle) :func '*clm-cam-lookthrough*) + (new 'static 'clm-item-action :button (pad-buttons-u64 r2) :func 'clmf-bna) + (new 'static 'clm-item-action + :button (pad-buttons-u64 l2) + :func 'clmf-pos-rot + :parm0-sym 'trans-offset + :parm1 'rot-offset + ) + ) + ) + (new 'static 'clm-list-item + :description "align " + :track-val 'align + :val-func #f + :actions (new 'static 'boxed-array :type clm-item-action + (new 'static 'clm-item-action :button (pad-buttons-u64 x) :func 'clmf-bna) + (new 'static 'clm-item-action :button (pad-buttons-u64 circle) :func 'clmf-bna) + (new 'static 'clm-item-action :button (pad-buttons-u64 r2) :func 'clmf-bna) + (new 'static 'clm-item-action + :button (pad-buttons-u64 l2) + :func 'clmf-pos-rot + :parm0-sym 'align-offset + :parm1 #f + ) + ) + ) + (new 'static 'clm-list-item + :description "pivot " + :track-val 'pivot + :val-func #f + :actions (new 'static 'boxed-array :type clm-item-action + (new 'static 'clm-item-action :button (pad-buttons-u64 x) :func 'clmf-bna) + (new 'static 'clm-item-action :button (pad-buttons-u64 circle) :func 'clmf-bna) + (new 'static 'clm-item-action :button (pad-buttons-u64 r2) :func 'clmf-bna) + (new 'static 'clm-item-action + :button (pad-buttons-u64 l2) + :func 'clmf-pos-rot + :parm0-sym 'pivot-offset + :parm1 #f + ) + ) + ) + (new 'static 'clm-list-item + :description "interesting" + :track-val 'interesting + :val-func #f + :actions (new 'static 'boxed-array :type clm-item-action + (new 'static 'clm-item-action :button (pad-buttons-u64 x) :func 'clmf-bna) + (new 'static 'clm-item-action :button (pad-buttons-u64 circle) :func 'clmf-bna) + (new 'static 'clm-item-action :button (pad-buttons-u64 r2) :func 'clmf-bna) + (new 'static 'clm-item-action + :button (pad-buttons-u64 l2) + :func 'clmf-pos-rot + :parm0-sym 'interesting-offset + :parm1 #f + ) + ) + ) + (new 'static 'clm-list-item + :description "spline " + :track-val 'spline + :val-func #f + :actions (new 'static 'boxed-array :type clm-item-action + (new 'static 'clm-item-action + :button (pad-buttons-u64 x) + :options (clm-item-action-options clm0) + :func 'clmf-to-spline-attr + ) + (new 'static 'clm-item-action :button (pad-buttons-u64 circle) :func 'clmf-implement) + (new 'static 'clm-item-action :button (pad-buttons-u64 r2) :func 'clmf-implement) + (new 'static 'clm-item-action + :button (pad-buttons-u64 l2) + :func 'clmf-pos-rot + :parm0-sym 'spline-offset + :parm1 #f + ) + ) + ) + (new 'static 'clm-list-item + :description "intro " + :track-val 'intro + :val-func #f + :actions (new 'static 'boxed-array :type clm-item-action + (new 'static 'clm-item-action + :button (pad-buttons-u64 x) + :options (clm-item-action-options clm0) + :func 'clmf-to-intro-attr + ) + (new 'static 'clm-item-action :button (pad-buttons-u64 circle) :func 'clmf-implement) + (new 'static 'clm-item-action :button (pad-buttons-u64 r2) :func 'clmf-implement) + (new 'static 'clm-item-action :button (pad-buttons-u64 l2) :func 'clmf-implement) + ) + ) + (new 'static 'clm-list-item + :description "index " + :track-val 'index + :val-func #f + :actions (new 'static 'boxed-array :type clm-item-action + (new 'static 'clm-item-action + :button (pad-buttons-u64 x) + :options (clm-item-action-options clm0) + :func 'clmf-to-index-attr + ) + (new 'static 'clm-item-action :button (pad-buttons-u64 circle) :func 'clmf-implement) + (new 'static 'clm-item-action :button (pad-buttons-u64 r2) :func 'clmf-implement) + (new 'static 'clm-item-action :button (pad-buttons-u64 l2) :func 'clmf-pos-rot :parm0-sym 'campoints-offset) + ) + ) + (new 'static 'clm-list-item + :description "focalpull" + :track-val 'focalpull + :val-func #f + :actions (new 'static 'boxed-array :type clm-item-action + (new 'static 'clm-item-action + :button (pad-buttons-u64 x) + :options (clm-item-action-options clm0) + :func 'clmf-to-focalpull-attr + ) + (new 'static 'clm-item-action :button (pad-buttons-u64 circle) :func 'clmf-implement) + (new 'static 'clm-item-action :button (pad-buttons-u64 r2) :func 'clmf-implement) + (new 'static 'clm-item-action :button (pad-buttons-u64 l2) :func 'clmf-implement) + ) + ) + ) + ) + ) + ) + ) + +;; definition for symbol *clm-save-all*, type clm +(define *clm-save-all* + (new 'static 'clm :title "---save all?---" :items (new 'static 'boxed-array :type clm-basic + (new 'static 'clm-item + :description " save all" + :button-symbol 'x + :action (new 'static 'clm-item-action + :button (pad-buttons-u64 x) + :options (clm-item-action-options clm0) + :func 'clmf-save-all + :parm0 16 + ) + ) + (new 'static 'clm-item + :description "print all" + :button-symbol 'square + :action (new 'static 'clm-item-action + :button (pad-buttons-u64 square) + :options (clm-item-action-options clm0) + :func 'clmf-save-all + :parm0 8 + ) + ) + (new 'static 'clm-item + :description " done" + :button-symbol 'triangle + :action (new 'static 'clm-item-action + :button (pad-buttons-u64 triangle) + :options (clm-item-action-options clm0) + :func 'clmf-to-select + ) + ) + ) + ) + ) + +;; definition for symbol *clm-save-one*, type clm +(define *clm-save-one* + (new 'static 'clm :title "---single save?---" :items (new 'static 'boxed-array :type clm-basic + (new 'static 'clm-item + :description " single save" + :button-symbol 'x + :action (new 'static 'clm-item-action + :button (pad-buttons-u64 x) + :options (clm-item-action-options clm0) + :func 'clmf-save-one + :parm0 16 + ) + ) + (new 'static 'clm-item + :description "single print" + :button-symbol 'square + :action (new 'static 'clm-item-action + :button (pad-buttons-u64 square) + :options (clm-item-action-options clm0) + :func 'clmf-save-one + :parm0 8 + ) + ) + (new 'static 'clm-item + :description " done" + :button-symbol 'triangle + :action (new 'static 'clm-item-action + :button (pad-buttons-u64 triangle) + :options (clm-item-action-options clm0) + :func 'clmf-to-select + ) + ) + ) + ) + ) + +;; definition for symbol *clm-select*, type clm +(define *clm-select* + (new 'static 'clm :title "---camera---" :items (new 'static 'boxed-array :type clm-basic + (new 'static 'clm-item + :description " edit" + :button-symbol 'x + :action (new 'static 'clm-item-action + :button (pad-buttons-u64 x) + :options (clm-item-action-options clm0 clm1) + :func 'clmf-to-edit-cam + ) + ) + (new 'static 'clm-item + :description "save one" + :button-symbol 'triangle + :action (new 'static 'clm-item-action + :button (pad-buttons-u64 triangle) + :options (clm-item-action-options clm0 clm1) + :func '*clm-save-one* + ) + ) + (new 'static 'clm-item + :description " quit" + :button-symbol 'circle + :action (new 'static 'clm-item-action + :button (pad-buttons-u64 circle) + :options (clm-item-action-options clm0 clm4) + :func 'cam-layout-stop + ) + ) + (new 'static 'clm-item + :description " next" + :button-symbol 'down + :action (new 'static 'clm-item-action + :button (pad-buttons-u64 down) + :options (clm-item-action-options clm0 clm1) + :func 'clmf-next-entity + :parm0 8 + ) + ) + (new 'static 'clm-item + :description " prev" + :button-symbol 'up + :action (new 'static 'clm-item-action + :button (pad-buttons-u64 up) + :options (clm-item-action-options clm0 clm1) + :func 'clmf-next-entity + :parm0 -8 + ) + ) + (new 'static 'clm-item + :description " next 5" + :button-symbol 'right + :action (new 'static 'clm-item-action + :button (pad-buttons-u64 right) + :options (clm-item-action-options clm0 clm1) + :func 'clmf-next-entity + :parm0 40 + ) + ) + (new 'static 'clm-item + :description " prev 5" + :button-symbol 'left + :action (new 'static 'clm-item-action + :button (pad-buttons-u64 left) + :options (clm-item-action-options clm0 clm1) + :func 'clmf-next-entity + :parm0 -40 + ) + ) + ) + ) + ) + +;; definition for symbol *clm*, type clm +(define *clm* *clm-select*) + +;; definition for function cam-layout-do-action +(defbehavior cam-layout-do-action cam-layout ((arg0 clm-item-action)) + (let ((s5-0 (-> arg0 func value))) + (cond + ((not s5-0) + #f + ) + ((zero? s5-0) + #f + ) + ((and (not (-> self cam-entity)) (logtest? (-> arg0 options) (clm-item-action-options clm1))) + #f + ) + ((and (logtest? (-> arg0 options) (clm-item-action-options clm3)) + (logtest? (the-as pad-buttons-u64 (-> *cpad-list* cpads 0 button0-abs 0)) (-> arg0 button)) + ) + #f + ) + ((and (not (logtest? (-> arg0 options) (clm-item-action-options clm2 clm3 clm4))) + (logtest? (-> arg0 options) (clm-item-action-options clm0)) + (not (logtest? (the-as pad-buttons-u64 (-> *cpad-list* cpads 0 button0-rel 0)) (-> arg0 button))) + ) + #f + ) + ((and (not (logtest? (-> arg0 options) (clm-item-action-options clm0 clm2 clm3 clm4))) + (not (logtest? (the-as pad-buttons-u64 (-> *cpad-list* cpads 0 button0-abs 0)) (-> arg0 button))) + ) + #f + ) + ((and (logtest? (-> arg0 options) (clm-item-action-options clm4)) + (let ((a1-3 (-> *cpad-list* cpads 0))) + (not (logtest? (the-as pad-buttons-u64 (logclear (-> a1-3 button0-abs 1) (-> a1-3 button0-abs 0))) + (-> arg0 button) + ) + ) + ) + ) + #f + ) + ((type? s5-0 clm) + (set! *clm* (the-as clm s5-0)) + #t + ) + ((type? s5-0 function) + ((the-as (function int symbol object) s5-0) (-> arg0 parm0) (-> arg0 parm1)) + ) + ) + ) + ) + +;; definition for function cam-layout-function-call +(defbehavior cam-layout-function-call cam-layout ((arg0 symbol) (arg1 string) (arg2 int) (arg3 basic)) + (let ((gp-0 (-> arg0 value))) + (cond + ((not gp-0) + ) + ((zero? gp-0) + ) + ((type? gp-0 function) + ((the-as (function string int basic object) gp-0) arg1 arg2 arg3) + ) + ) + ) + #f + ) + +;; definition for function cam-layout-do-menu +(defbehavior cam-layout-do-menu cam-layout ((arg0 clm)) + (set! *camera-layout-message-ypos* 30) + (+! (-> *CAM_LAYOUT-bank* spline-t) (-> *CAM_LAYOUT-bank* spline-step)) + (if (< 1.01 (-> *CAM_LAYOUT-bank* spline-t)) + (set! (-> *CAM_LAYOUT-bank* spline-t) -0.09) + ) + (+! (-> *CAM_LAYOUT-bank* intro-t) (-> *CAM_LAYOUT-bank* intro-step)) + (if (< 1.01 (-> *CAM_LAYOUT-bank* intro-t)) + (set! (-> *CAM_LAYOUT-bank* intro-t) -0.09) + ) + (let ((s5-0 30)) + (let ((s4-0 (cam-state-from-entity (-> self cam-entity)))) + (set-setting! 'master-options 'clear 0.0 32) + (let ((s3-0 (-> self cam-entity))) + (clear *temp-string*) + (if s3-0 + (format *temp-string* "\"~S\"~%" (res-lump-struct s3-0 'name structure)) + ) + ) + (if (not s4-0) + (format *temp-string* "no cameras in this level") + (format *temp-string* "~S" (-> s4-0 name)) + ) + ) + (cam-layout-print 320 s5-0 *temp-string*) + (let ((s5-1 (+ s5-0 28))) + (clear *temp-string*) + (format *temp-string* "~S~%" (-> arg0 title)) + (cam-layout-print 320 s5-1 *temp-string*) + (let ((s4-1 (+ s5-1 14))) + (dotimes (s5-2 (-> arg0 items length)) + (cond + ((type? (-> arg0 items s5-2) clm-list) + (clear *temp-string*) + (format *temp-string* "------------") + (cam-layout-print 320 s4-1 *temp-string*) + (let ((s4-2 (+ s4-1 14))) + (let ((s3-1 (the-as clm-list (-> arg0 items s5-2)))) + (dotimes (s2-1 (-> s3-1 items length)) + (clear *temp-string*) + (format + *temp-string* + "~S~S" + (if (= s2-1 (-> s3-1 cur-list-item)) + "> " + " " + ) + (-> s3-1 items s2-1 description) + ) + (cam-layout-function-call + (-> s3-1 items s2-1 val-func) + *temp-string* + (-> s3-1 items s2-1 val-parm0) + (the-as basic (-> s3-1 items s2-1 val-parm1)) + ) + (cam-layout-print 320 s4-2 *temp-string*) + (+! s4-2 14) + ) + ) + (clear *temp-string*) + (format *temp-string* "------------") + (cam-layout-print 320 s4-2 *temp-string*) + (set! s4-1 (+ s4-2 14)) + ) + ) + ((and (not (-> self cam-entity)) + (logtest? (-> (the-as clm-item (-> arg0 items s5-2)) action options) (clm-item-action-options clm1)) + ) + ) + ((logtest? (-> (the-as clm-item (-> arg0 items s5-2)) action options) (clm-item-action-options clm2)) + ) + (else + (let ((s3-2 (-> arg0 items s5-2))) + (clear *temp-string*) + (format + *temp-string* + "~S: ~A~%" + (-> (the-as clm-item s3-2) description) + (if (logtest? (-> (the-as clm-item (-> arg0 items s5-2)) action options) (clm-item-action-options clm3)) + 'default + (-> (the-as clm-item s3-2) button-symbol) + ) + ) + ) + (cam-layout-print 320 s4-1 *temp-string*) + (+! s4-1 14) + ) + ) + ) + ) + ) + ) + (if (= *master-mode* 'menu) + (goto cfg-65) + ) + (dotimes (s5-3 (-> arg0 items length)) + (cond + ((type? (-> arg0 items s5-3) clm-list) + (let ((s4-3 (-> arg0 items s5-3)) + (s3-3 0) + ) + (if (-> (the-as clm-list s4-3) tracker) + (set! (-> (the-as clm-list s4-3) tracker value) + (-> (the-as clm-list s4-3) items (-> (the-as clm-list s4-3) cur-list-item) track-val) + ) + ) + (dotimes (s2-2 (-> (the-as clm-list s4-3) items (-> (the-as clm-list s4-3) cur-list-item) actions length)) + (if (cam-layout-do-action + (-> (the-as clm-list s4-3) items (-> (the-as clm-list s4-3) cur-list-item) actions s2-2) + ) + (goto cfg-65) + ) + ) + (cond + ((cpad-pressed? 0 down) + (set! s3-3 1) + ) + ((cpad-pressed? 0 right) + (set! s3-3 1) + ) + ((cpad-pressed? 0 up) + (set! s3-3 -1) + ) + ((cpad-pressed? 0 left) + (set! s3-3 -1) + ) + ) + (when (nonzero? s3-3) + (set! (-> (the-as clm-list s4-3) cur-list-item) + (mod (+ (-> (the-as clm-list s4-3) cur-list-item) s3-3) (-> (the-as clm-list s4-3) items length)) + ) + (while (< (-> (the-as clm-list s4-3) cur-list-item) 0) + (+! (-> (the-as clm-list s4-3) cur-list-item) (-> (the-as clm-list s4-3) items length)) + ) + (goto cfg-65) + ) + ) + ) + ((cam-layout-do-action (-> (the-as clm-item (-> arg0 items s5-3)) action)) + (goto cfg-65) + ) + ) + ) + (label cfg-65) + #f + ) + +;; failed to figure out what this is: +(defstate cam-layout-active (cam-layout) + :code (behavior () + (until #f + (cam-layout-entity-info (the-as entity-actor (-> self cam-entity))) + (cam-layout-do-menu *clm*) + (suspend) + ) + #f + ) + ) + +;; definition for function cam-layout-init +(defbehavior cam-layout-init cam-layout () + (set! (-> self res-key) -1000000000.0) + (set! (-> self num-entities) 0) + (let ((v1-2 (-> *camera-engine* alive-list next0))) + *camera-engine* + (let ((a0-2 (-> v1-2 next0))) + (while (!= v1-2 (-> *camera-engine* alive-list-end)) + (-> (the-as connection v1-2) param1) + (+! (-> self num-entities) 1) + (set! v1-2 a0-2) + *camera-engine* + (set! a0-2 (-> a0-2 next0)) + ) + ) + ) + (set! (-> self cur-entity) *last-cur-entity*) + (clmf-next-entity 0) + (set! *clm* *clm-select*) + (go cam-layout-active) + ) + +;; definition for function cam-layout-stop +(defun cam-layout-stop () + (set! *cam-layout* #f) + (kill-by-name "cam-layout" *active-pool*) + ) + +;; definition for function cam-layout-start +(defun cam-layout-start () + (let ((a0-1 (new 'global 'file-stream "dd_next/caminfo/garbage" 'read))) + (file-stream-close a0-1) + ) + (cond + ((not *cam-layout*) + (let ((v1-4 (process-spawn-function cam-layout cam-layout-init :name "cam-layout" :from *camera-dead-pool*))) + (cond + (v1-4 + (logclear! (-> v1-4 0 mask) (process-mask freeze pause menu)) + (set! *cam-layout* #t) + (set! *camera-layout-blink* #f) + ) + (else + (format 0 "ERROR : no process available to start cam editing mode~%") + ) + ) + ) + ) + (else + (format 0 "ERROR : cam editing mode already started~%") + ) + ) + *cam-layout* + ) + +;; definition for function cam-layout-restart +(defun cam-layout-restart () + (cam-layout-stop) + (cam-layout-start) + ) + + + + diff --git a/test/decompiler/reference/jak3/engine/camera/cam-master_REF.gc b/test/decompiler/reference/jak3/engine/camera/cam-master_REF.gc new file mode 100644 index 00000000000..a4427ce911d --- /dev/null +++ b/test/decompiler/reference/jak3/engine/camera/cam-master_REF.gc @@ -0,0 +1,1097 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition for method 16 of type camera-master +(defmethod camera-master-method-16 ((this camera-master) (arg0 symbol)) + (let ((a2-0 (handle->process (-> this focus handle))) + (v1-4 0) + ) + (if a2-0 + (set! v1-4 (logand (the-as int (-> (the-as process-focusable a2-0) root pat-ignore-mask)) 112)) + ) + (logior (if arg0 + #x9010002 + #x9000002 + ) + v1-4 + ) + ) + ) + +;; definition for function reset-follow +;; INFO: Used lq/sq +(defbehavior reset-follow camera-master ((arg0 symbol)) + (let ((a0-2 (handle->process (-> self focus handle)))) + (when a0-2 + (let ((v1-5 (get-trans (the-as process-focusable a0-2) 4))) + (cond + (arg0 + (set! (-> self tpos-old x) (-> v1-5 x)) + (set! (-> self tpos-old z) (-> v1-5 z)) + (if (< (-> self tpos-old y) (-> v1-5 y)) + (set! (-> self tpos-old y) (lerp (-> self tpos-old y) (-> v1-5 y) (* 3.0 (seconds-per-frame)))) + (set! (-> self tpos-old y) (lerp (-> self tpos-old y) (-> v1-5 y) (* 8.0 (seconds-per-frame)))) + ) + (set! (-> self tpos-curr quad) (-> self tpos-old quad)) + (set! (-> self tpos-old-adj quad) (-> self tpos-old quad)) + (set! (-> self tpos-curr-adj quad) (-> self tpos-old quad)) + (let ((v0-0 (the-as object (-> self tpos-tgt)))) + (set! (-> (the-as vector v0-0) quad) (-> self tpos-old quad)) + v0-0 + ) + ) + (else + (set! (-> self tpos-old quad) (-> v1-5 quad)) + (set! (-> self tpos-curr quad) (-> self tpos-old quad)) + (set! (-> self tpos-old-adj quad) (-> self tpos-old quad)) + (set! (-> self tpos-curr-adj quad) (-> self tpos-old quad)) + (set! (-> self tpos-tgt quad) (-> self tpos-old quad)) + (set! (-> self upspeed) 0.0) + ) + ) + ) + ) + ) + ) + +;; definition for function reset-target-tracking +;; INFO: Used lq/sq +;; WARN: Return type mismatch none vs object. +(defbehavior reset-target-tracking camera-master () + (let ((gp-0 (handle->process (-> self focus handle)))) + (when gp-0 + (set! (-> self tpos-old quad) (-> (get-trans (the-as process-focusable gp-0) 4) quad)) + (set! (-> self tpos-curr quad) (-> self tpos-old quad)) + (set! (-> self tpos-old-adj quad) (-> self tpos-old quad)) + (set! (-> self tpos-curr-adj quad) (-> self tpos-old quad)) + (set! (-> self tpos-tgt quad) (-> self tpos-old quad)) + (quaternion->matrix (-> self tgt-rot-mat) (get-quat (the-as process-focusable gp-0) 2)) + (quaternion->matrix (-> self tgt-face-mat) (get-quat (the-as process-focusable gp-0) 1)) + (vector-reset! (-> self pitch-off)) + (set! (-> self upspeed) 0.0) + (set! (-> self on-ground) + (not (logtest? (-> (the-as process-focusable gp-0) focus-status) (focus-status in-air))) + ) + (set! (-> self on-pole) #f) + (set! (-> self ease-t) 1.0) + (set! (-> self string-max target y) (-> self settings string-max-height)) + (set! (-> self string-max target z) (-> self settings string-max-length)) + (set! (-> self string-push-z) (fmax (-> self string-min value z) (-> *CAMERA-bank* default-string-push-z))) + (cond + ((time-elapsed? (get-notice-time (the-as process-focusable gp-0)) (-> *CAMERA-bank* attack-timeout)) + (set! (-> self being-attacked) #f) + ) + (else + (set-time! (-> self attack-start)) + (set! (-> self being-attacked) #t) + (when (or (!= (-> last-try-to-look-at-data horz) 0.0) (!= (-> last-try-to-look-at-data vert) 0.0)) + (set! (-> self string-max target y) (fmax (-> self string-max target y) (-> last-try-to-look-at-data vert))) + (set! (-> self string-max target z) (fmax (-> self string-max target z) (-> last-try-to-look-at-data horz))) + (set! (-> self string-push-z) (fmax (-> self string-push-z) (-> self string-max target z))) + ) + ) + ) + (cond + ((focus-test? (the-as process-focusable gp-0) under-water) + (set! (-> self under-water) 2) + ) + (else + (set! (-> self under-water) 0) + 0 + ) + ) + (let ((gp-1 (new 'stack-no-clear 'vector))) + (set! (-> *setting-control* cam-current target-height) (-> *setting-control* cam-target target-height)) + (vector--float*! gp-1 (-> self tpos-curr-adj) (-> self local-down) (-> self settings target-height)) + (tracking-spline-method-10 (-> self target-spline) gp-1) + ) + ) + ) + ) + +;; definition for function master-track-target +;; INFO: Used lq/sq +(defbehavior master-track-target camera-master () + (let ((gp-0 (handle->process (-> self focus handle)))) + (cond + ((and *target* (not gp-0)) + (try-update-focus (-> self focus) *target*) + (logior! (-> self master-options) (cam-master-options-u32 HAVE_TARGET)) + (reset-target-tracking) + ) + ((and (logtest? (-> self master-options) (cam-master-options-u32 HAVE_TARGET)) (not gp-0)) + (let ((v0-1 (the-as object (logclear (-> self master-options) (cam-master-options-u32 HAVE_TARGET))))) + (set! (-> self master-options) (the-as cam-master-options-u32 v0-1)) + v0-1 + ) + ) + ((paused?) + #f + ) + (gp-0 + (logior! (-> self master-options) (cam-master-options-u32 HAVE_TARGET)) + (cond + ((time-elapsed? (get-notice-time (the-as process-focusable gp-0)) (-> *CAMERA-bank* attack-timeout)) + (set! (-> self being-attacked) #f) + ) + (else + (if (not (-> self being-attacked)) + (set-time! (-> self attack-start)) + ) + (set! (-> self being-attacked) #t) + (when (or (!= (-> last-try-to-look-at-data horz) 0.0) (!= (-> last-try-to-look-at-data vert) 0.0)) + (set! (-> self string-max target y) (fmax (-> self string-max target y) (-> last-try-to-look-at-data vert))) + (set! (-> self string-max target z) (fmax (-> self string-max target z) (-> last-try-to-look-at-data horz))) + (set! (-> self string-push-z) (fmax (-> self string-push-z) (-> self string-max target z))) + ) + ) + ) + (cond + ((focus-test? (the-as process-focusable gp-0) under-water) + (set! (-> self under-water) 2) + ) + ((> (-> self under-water) 0) + (+! (-> self under-water) -1) + ) + ) + (set! (-> self tpos-old quad) (-> self tpos-curr quad)) + (set! (-> self tpos-old-adj quad) (-> self tpos-curr-adj quad)) + (quaternion->matrix (-> self tgt-rot-mat) (get-quat (the-as process-focusable gp-0) 2)) + (quaternion->matrix (-> self tgt-face-mat) (get-quat (the-as process-focusable gp-0) 1)) + (cond + ((< (-> self ease-t) 1.0) + (new 'stack-no-clear 'vector) + (cond + ((logtest? (-> self master-options) (cam-master-options-u32 HAVE_EASE_TO_POS)) + (vector-lerp! + (-> self tpos-curr) + (-> self ease-from) + (-> self ease-to) + (parameter-ease-sin-clamp (-> self ease-t)) + ) + (logclear! (-> self master-options) (cam-master-options-u32 HAVE_EASE_TO_POS)) + ) + (else + (vector-lerp! + (-> self tpos-curr) + (-> self ease-from) + (get-trans (the-as process-focusable gp-0) 4) + (parameter-ease-sin-clamp (-> self ease-t)) + ) + ) + ) + (+! (-> self ease-t) (-> self ease-step)) + ) + (else + (set! (-> self tpos-curr quad) (-> (get-trans (the-as process-focusable gp-0) 4) quad)) + ) + ) + (when (focus-test? (the-as process-focusable gp-0) edge-grab) + (if *display-cam-los-debug* + (format *stdcon* "ride edge~%") + ) + (let ((s5-6 (new 'stack-no-clear 'collide-query))) + (vector--float*! + (-> s5-6 start-pos) + (-> self tpos-curr) + (-> self local-down) + (-> self settings target-height) + ) + (vector-float*! (-> s5-6 move-dist) (-> self tgt-rot-mat fvec) 4915.2) + (vector-! (-> s5-6 start-pos) (-> s5-6 start-pos) (-> s5-6 move-dist)) + (let ((s4-4 s5-6)) + (set! (-> s4-4 radius) 4300.8) + (set! (-> s4-4 collide-with) (collide-spec backgnd obstacle hit-by-others-list camera-blocker pusher)) + (set! (-> s4-4 ignore-process0) #f) + (set! (-> s4-4 ignore-process1) #f) + (set! (-> s4-4 ignore-pat) (the-as pat-surface (camera-master-method-16 self #t))) + (set! (-> s4-4 action-mask) (collide-action solid)) + ) + (let ((f0-16 (fill-and-probe-using-line-sphere *collide-cache* s5-6))) + (if (and (< 0.0 f0-16) (< f0-16 1.0)) + (vector+float*! (-> self tpos-curr) (-> self tpos-curr) (-> s5-6 move-dist) (+ -1.0 f0-16)) + ) + ) + ) + ) + (set! (-> self on-ground) + (not (logtest? (-> (the-as process-focusable gp-0) focus-status) (focus-status in-air))) + ) + (let ((s5-7 (new-stack-vector0))) + 0.0 + (cond + ((and (focus-test? (the-as process-focusable gp-0) in-air) + (not (logtest? (focus-status halfpipe super) (-> (the-as process-focusable gp-0) focus-status))) + ) + (if *display-cam-los-debug* + (format *stdcon* "air tracking~%") + ) + (vector+float*! (-> self tpos-curr-adj) (-> self tpos-curr-adj) (-> self local-down) (-> self upspeed)) + (vector+float*! (-> self tpos-tgt) (-> self tpos-tgt) (-> self local-down) (-> self upspeed)) + (vector-! s5-7 (-> self tpos-curr) (-> self tpos-tgt)) + (let ((f30-0 (vector-dot s5-7 (-> self local-down)))) + (vector--float*! s5-7 s5-7 (-> self local-down) f30-0) + (if (< 0.0 f30-0) + (set! (-> self upspeed) (* 0.5 (-> self upspeed))) + ) + (vector+! (-> self tpos-tgt) (-> self tpos-tgt) s5-7) + (let ((f0-26 (* 0.05 f30-0))) + (vector+float*! (-> self tpos-tgt) (-> self tpos-tgt) (-> self local-down) f0-26) + ) + ) + (vector-! s5-7 (-> self tpos-curr-adj) (-> self tpos-tgt)) + (let* ((f0-28 (vector-dot s5-7 (-> self local-down))) + (f0-29 (if (< 0.0 f0-28) + (* f0-28 (-> *CAMERA_MASTER-bank* up-move-to-pitch-ratio-in-air)) + (* f0-28 (-> *CAMERA_MASTER-bank* down-move-to-pitch-ratio-in-air)) + ) + ) + ) + (vector+float*! (-> self tpos-curr-adj) (-> self tpos-tgt) (-> self local-down) f0-29) + ) + (vector-! s5-7 (get-trans (the-as process-focusable gp-0) 1) (-> self tpos-curr-adj)) + (let* ((f0-31 (vector-dot s5-7 (-> self local-down))) + (f0-32 (* 0.03 f0-31)) + ) + (if (and (< f0-32 0.0) (< f0-32 (-> self upspeed))) + (set! (-> self upspeed) f0-32) + ) + ) + ) + (else + (if *display-cam-los-debug* + (format *stdcon* "ground tracking~%") + ) + (vector-! s5-7 (-> self tpos-curr) (-> self tpos-old)) + (let ((f0-34 (vector-dot s5-7 (-> self local-down)))) + (cond + ((and (focus-test? (the-as process-focusable gp-0) touch-water) + (not (logtest? (focus-status mech) (-> (the-as process-focusable gp-0) focus-status))) + ) + (set! (-> self upspeed) 0.0) + ) + ((< 0.0 f0-34) + (set! (-> self upspeed) 0.0) + ) + (else + (set! (-> self upspeed) f0-34) + ) + ) + ) + (set! (-> self tpos-tgt quad) (-> self tpos-curr quad)) + (vector-! s5-7 (-> self tpos-curr-adj) (-> self tpos-curr)) + (let* ((f0-38 (vector-dot s5-7 (-> self local-down))) + (f0-39 (cond + ((logtest? (cam-slave-options RAPID_TRACKING) (-> self settings slave-options)) + 0.0 + ) + ((< 0.0 f0-38) + (* f0-38 (-> *CAMERA_MASTER-bank* up-move-to-pitch-on-ground)) + ) + (else + (* f0-38 (-> *CAMERA_MASTER-bank* down-move-to-pitch-on-ground)) + ) + ) + ) + ) + (vector+float*! (-> self tpos-curr-adj) (-> self tpos-curr) (-> self local-down) f0-39) + ) + ) + ) + ) + (if (not (logtest? (-> self settings slave-options) (cam-slave-options JUMP_PITCHES))) + (reset-follow (logtest? (cam-slave-options JUMP_LAG) (-> self settings slave-options))) + ) + (when (and (focus-test? (the-as process-focusable gp-0) on-water under-water) + (not (logtest? (focus-status mech) (-> (the-as process-focusable gp-0) focus-status))) + ) + (let ((f0-41 (- (get-water-height (the-as process-focusable gp-0)) (-> self settings target-height)))) + (if (< (-> self tpos-curr-adj y) f0-41) + (set! (-> self tpos-curr-adj y) f0-41) + ) + ) + ) + (vector+! (-> self pitch-off) (-> self pitch-off) (-> self tpos-curr)) + (vector-! (-> self pitch-off) (-> self pitch-off) (-> self tpos-old)) + (vector-float*! (-> self pitch-off) (-> self pitch-off) (-> *CAMERA_MASTER-bank* pitch-off-blend)) + (let ((s5-8 (new 'stack-no-clear 'vector))) + (vector--float*! s5-8 (-> self tpos-curr-adj) (-> self local-down) (-> self settings target-height)) + (let ((s4-7 (new 'stack-no-clear 'vector))) + 0.0 + (vector-! s4-7 (get-trans (the-as process-focusable gp-0) 1) s5-8) + (let* ((f0-46 (vector-dot s4-7 (-> self local-down))) + (f0-47 (+ -4096.0 f0-46)) + ) + (if (< f0-47 0.0) + (vector+float*! s5-8 s5-8 (-> self local-down) f0-47) + ) + ) + ) + (tracking-spline-method-17 (-> self target-spline) s5-8 2048.0 0.0 #f) + ) + (tracking-spline-method-22 (-> self target-spline) 40960.0) + ) + ) + ) + ) + +;; definition for function setup-slave-for-hopefull +(defun setup-slave-for-hopefull ((arg0 camera-slave)) + (when (= (-> arg0 blend-to-type) (camera-blend-to-type unknown-2)) + (cam-calc-follow! (-> arg0 tracking) (-> arg0 trans) #f) + (slave-set-rotation! (-> arg0 tracking) (-> arg0 trans) (-> arg0 options) (-> arg0 fov) #f) + ) + (none) + ) + +;; definition for function master-is-hopeful-better? +(defbehavior master-is-hopeful-better? camera-master ((arg0 camera-slave) (arg1 camera-slave)) + (cond + ((not *camera-combiner*) + #f + ) + ((not arg0) + #t + ) + (else + (< (vector-dot (-> arg0 tracking inv-mat fvec) (-> *camera-combiner* inv-camera-rot fvec)) + (vector-dot (-> arg1 tracking inv-mat fvec) (-> *camera-combiner* inv-camera-rot fvec)) + ) + ) + ) + ) + +;; definition for function master-choose-entity +;; INFO: Used lq/sq +(defbehavior master-choose-entity camera-master ((arg0 cam-setting-data)) + (local-vars + (r0-0 uint128) + (v1-44 uint128) + (sv-96 int) + (sv-112 process) + (sv-128 entity) + (sv-144 string) + (sv-160 string) + (sv-176 uint) + ) + (let ((s5-0 (entity-by-name (-> arg0 entity-name)))) + (set! (-> arg0 real-entity-name) #f) + (when s5-0 + (let ((s2-0 (cam-state-from-entity s5-0))) + (cond + (s2-0 + (set! (-> arg0 real-entity-name) (-> arg0 entity-name)) + (set! (-> arg0 cam-mode) (the-as symbol s2-0)) + (if (-> arg0 teleport-on-entity-change) + (send-event *camera* 'teleport) + ) + ) + (else + (format 0 "ERROR : camera entity '~S' didn't produce a state~%" (res-lump-struct s5-0 'name structure)) + ) + ) + (set! sv-96 0) + (let ((s4-1 (res-lump-data s5-0 'alternates pointer :tag-ptr (the-as (pointer res-tag) (& sv-96))))) + (when s4-1 + (let ((s3-1 (process-spawn + camera-slave + :init cam-slave-init + s2-0 + s5-0 + :name "camera-slave" + :from *camera-dead-pool* + :to *camera* + ) + ) + ) + (if s3-1 + (setup-slave-for-hopefull (the-as camera-slave (ppointer->process s3-1))) + (format 0 "ERROR : primary region activate failed~%") + ) + (let ((s2-1 0)) + (while (begin + (let ((v1-43 (the-as uint128 sv-96))) + (.pcpyud v1-44 v1-43 r0-0) + ) + (< s2-1 (shr (* (the-as int v1-44) 2) 49)) + ) + (set! sv-128 (entity-by-name (the-as string (-> (the-as (pointer uint32) (&+ s4-1 (* s2-1 4))))))) + (cond + (sv-128 + (let ((s1-2 (cam-state-from-entity sv-128))) + (cond + (s1-2 + (set! sv-112 (get-process *camera-dead-pool* camera-slave #x4000 1)) + (let ((s0-0 (when sv-112 + (let ((t9-14 (method-of-type camera-slave activate))) + (t9-14 (the-as camera-slave sv-112) *camera* "camera-slave" (the-as pointer #x70004000)) + ) + (run-now-in-process sv-112 cam-slave-init s1-2 sv-128) + (-> sv-112 ppointer) + ) + ) + ) + (cond + (s0-0 + (setup-slave-for-hopefull (the-as camera-slave (ppointer->process s0-0))) + (cond + ((master-is-hopeful-better? + (the-as camera-slave (ppointer->process s3-1)) + (the-as camera-slave (ppointer->process s0-0)) + ) + (if s3-1 + (deactivate (-> s3-1 0)) + ) + (set! s3-1 (the-as (pointer camera-slave) s0-0)) + (set! (-> arg0 real-entity-name) (the-as string (-> (the-as (pointer uint32) (&+ s4-1 (* s2-1 4)))))) + (set! (-> arg0 cam-mode) (the-as symbol s1-2)) + ) + (else + (deactivate (-> s0-0 0)) + ) + ) + ) + (else + (format 0 "ERROR : alternate region activate failed~%") + ) + ) + ) + ) + (else + (let ((s1-5 format) + (s0-1 0) + ) + (set! sv-144 "ERROR : alternate camera region '~S' didn't produce a state~%") + (let ((a2-10 (res-lump-struct sv-128 'name structure))) + (s1-5 s0-1 sv-144 a2-10) + ) + ) + ) + ) + ) + ) + (else + (let ((s1-7 format) + (s0-2 0) + ) + (set! sv-160 "ERROR : alternate '~S' not found for '~S'~%") + (set! sv-176 (-> (the-as (pointer uint32) (&+ s4-1 (* s2-1 4))))) + (let ((a3-10 (res-lump-struct s5-0 'name structure))) + (s1-7 s0-2 sv-160 sv-176 a3-10) + ) + ) + ) + ) + (+! s2-1 1) + ) + ) + (if s3-1 + (deactivate (-> s3-1 0)) + ) + ) + ) + ) + ) + ) + ) + (cond + ((-> arg0 real-entity-name) + #f + ) + ((-> arg0 mode-name) + (let ((s5-1 (-> arg0 mode-name value))) + (set! (-> arg0 cam-mode) (the-as symbol (if (type? s5-1 state) + s5-1 + ) + ) + ) + ) + (set! (-> arg0 real-entity-name) #f) + #f + ) + (else + (set! (-> arg0 cam-mode) (the-as symbol cam-free-floating)) + (set! (-> arg0 real-entity-name) #f) + #f + ) + ) + ) + +;; definition for function cam-master-set-entity +;; WARN: Return type mismatch int vs none. +(defun cam-master-set-entity ((arg0 cam-setting-data)) + (if (-> arg0 entity-or-mode-changed) + (master-choose-entity arg0) + ) + (let ((s5-0 (entity-by-name (-> arg0 entity-name)))) + (when s5-0 + (if (< (-> arg0 fov-priority) 10.0) + (set! (-> arg0 fov) (cam-slave-get-fov s5-0)) + ) + (set! (-> arg0 string-min-height) + (cam-slave-get-float s5-0 'stringMinHeight (-> *CAMERA-bank* default-string-min-y)) + ) + (set! (-> arg0 string-max-height) + (cam-slave-get-float s5-0 'stringMaxHeight (-> *CAMERA-bank* default-string-max-y)) + ) + (set! (-> arg0 string-min-length) + (cam-slave-get-float s5-0 'stringMinLength (-> *CAMERA-bank* default-string-min-z)) + ) + (let ((f0-9 (cam-slave-get-float s5-0 'stringMaxLength (-> *CAMERA-bank* default-string-max-z)))) + (if (< 405504.0 f0-9) + (set! f0-9 (-> *CAMERA-bank* default-string-max-z)) + ) + (set! (-> arg0 string-max-length) f0-9) + ) + (set! (-> arg0 string-default) #f) + (set! (-> arg0 string-cliff-height) (cam-slave-get-float s5-0 'stringCliffHeight 163840.0)) + (let ((a1-5 (new 'stack-no-clear 'vector))) + (when (cam-slave-get-vector-with-offset (the-as entity-actor s5-0) a1-5 'interesting) + ) + ) + (set! (-> arg0 interp-time) (the-as uint (the int (* 300.0 (cam-slave-get-interp-time s5-0))))) + (let ((s4-0 (res-lump-value s5-0 'flags-on uint128 :time -1000000000.0)) + (v1-22 (res-lump-value s5-0 'flags-off uint128 :time -1000000000.0)) + ) + (logior! (-> arg0 slave-options) s4-0) + (logclear! (-> arg0 slave-options) v1-22) + ) + ) + ) + 0 + (none) + ) + +;; definition for function cam-master-activate-slave +;; WARN: Return type mismatch int vs none. +(defun cam-master-activate-slave ((arg0 symbol)) + (when (and *camera* (or arg0 (not (-> *camera* slave)) (-> *camera* settings entity-or-mode-changed))) + (when (and arg0 (-> *camera* slave)) + (deactivate (-> *camera* slave 0)) + (set! (-> *camera* slave) (the-as (pointer camera-slave) #f)) + ) + (let* ((s5-0 (-> *camera* settings)) + (gp-0 (entity-by-name (-> s5-0 real-entity-name))) + (s5-1 (the-as object (-> s5-0 cam-mode))) + ) + (if (not (the-as symbol s5-1)) + (set! s5-1 cam-free-floating) + ) + (send-event *camera* 'set-slave (ppointer->process (process-spawn + camera-slave + :init cam-slave-init + s5-1 + gp-0 + :name "camera-slave" + :from *camera-dead-pool* + :to *camera* + ) + ) + ) + ) + ) + 0 + (none) + ) + +;; failed to figure out what this is: +(defstate cam-master-active (camera-master) + :event (behavior ((proc process) (argc int) (message symbol) (block event-message-block)) + (local-vars (v0-0 object) (v1-125 uint)) + (rlet ((acc :class vf) + (vf0 :class vf) + (vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + (vf7 :class vf) + ) + (init-vf0-vector) + (case message + (('dist-from-interp-src) + (cond + ((not *camera-combiner*) + #x48c80000 + ) + ((= (-> *camera-combiner* interp-val) 0.0) + 0 + ) + (else + (-> *camera-combiner* dist-from-src) + ) + ) + ) + (('dist-from-interp-dest) + (cond + ((not *camera-combiner*) + 0 + ) + ((= (-> *camera-combiner* interp-val) 0.0) + #x48c80000 + ) + (else + (-> *camera-combiner* dist-from-dest) + ) + ) + ) + (('level-deactivate) + (format 0 "ERROR : *camera* level-deactivate event not supported anymore~%") + ) + (('clear-entity) + (format 0 "ERROR : *camera* clear-entity event not supported anymore~%") + ) + (('no-intro) + (format 0 "ERROR : *camera* no-intro event not supported anymore '~S'~%" (-> block param 0)) + ) + (('force-blend) + (format 0 "ERROR : *camera* force-blend event not supported anymore '~S'~%" (-> block param 0)) + ) + (('teleport-to-transformq) + (when (> argc 0) + (let ((gp-1 (the-as object (-> block param 0)))) + (when (-> self slave) + (deactivate (-> self slave 0)) + (set! (-> self slave) (the-as (pointer camera-slave) #f)) + ) + (set! (-> *camera-combiner* trans quad) (-> (the-as matrix gp-1) rvec quad)) + (quaternion->matrix (-> *camera-combiner* inv-camera-rot) (the-as quaternion (+ (the-as uint gp-1) 16))) + ) + (send-event self 'teleport) + (cam-master-activate-slave #f) + #t + ) + ) + (('teleport-to-other-start-string) + (let ((gp-2 (new 'stack-no-clear 'vector))) + (when (-> self slave) + (deactivate (-> self slave 0)) + (set! (-> self slave) (the-as (pointer camera-slave) #f)) + ) + (set! (-> *camera-combiner* trans quad) (-> *camera-other-trans* quad)) + (vector-! gp-2 (-> self tpos-curr-adj) *camera-other-trans*) + (vector-normalize! gp-2 1.0) + (forward-down->inv-matrix (-> *camera-combiner* inv-camera-rot) gp-2 (new 'static 'vector :y -1.0)) + ) + (send-event self 'teleport) + (cam-master-activate-slave #f) + ) + (('teleport-to-vector-start-string) + (when (> argc 0) + (let ((s5-0 (the-as object (-> block param 0))) + (gp-3 (new 'stack-no-clear 'vector)) + ) + (when (-> self slave) + (deactivate (-> self slave 0)) + (set! (-> self slave) (the-as (pointer camera-slave) #f)) + ) + (set! (-> *camera-combiner* trans quad) (-> (the-as vector s5-0) quad)) + (vector-! gp-3 (-> self tpos-curr-adj) (the-as vector s5-0)) + (vector-normalize! gp-3 1.0) + (forward-down->inv-matrix (-> *camera-combiner* inv-camera-rot) gp-3 (new 'static 'vector :y -1.0)) + ) + (send-event self 'teleport) + (cam-master-activate-slave #f) + ) + ) + (('change-target) + (let ((a1-15 (-> block param 0))) + (cond + ((not a1-15) + (clear-focused (-> self focus)) + (logclear! (-> self master-options) (cam-master-options-u32 HAVE_TARGET)) + ) + (else + (try-update-focus (-> self focus) (the-as process-focusable a1-15)) + (logior! (-> self master-options) (cam-master-options-u32 HAVE_TARGET)) + (reset-target-tracking) + ) + ) + ) + (set! (-> *camera-combiner* tracking no-follow) #f) + #f + ) + (('intro-done?) + (or (not (-> self slave)) (>= (-> self slave 0 intro-t) 1.0)) + ) + (('query-state) + (and (-> self slave) (= (-> self slave 0 next-state) (-> block param 0))) + ) + (('change-to-entity-by-name) + (format + 0 + "ERROR : *camera* change-to-entity-by-name event not supported anymore '~S'~%" + (-> block param 0) + ) + ) + (('change-state) + (format 0 "ERROR : *camera* change-state event not supported anymore ~A~%" (-> block param 0)) + ) + (('set-slave) + (let ((s5-1 (process->ppointer (the-as process (-> block param 0)))) + (s4-0 (-> self settings interp-time)) + (gp-4 (-> self slave)) + ) + (when (and s5-1 (!= s5-1 gp-4)) + (set! (-> self slave) (the-as (pointer camera-slave) s5-1)) + (logior! (-> self master-options) (cam-master-options-u32 SET_COMBINER_AXIS)) + (set! (-> *camera-combiner* tracking tilt-adjust target) (-> self slave 0 tracking tilt-adjust target)) + (cond + ((or (zero? s4-0) (not gp-4)) + (if *math-camera* + (set! (-> *math-camera* reset) 1) + ) + (send-event *camera-combiner* 'set-interpolation 0) + (send-event *camera-combiner* 'stop-tracking) + (if (= (-> (the-as camera-slave (-> s5-1 0)) blend-to-type) (camera-blend-to-type unknown-2)) + (send-event *camera-combiner* 'start-tracking (ppointer->process s5-1)) + ) + ) + ((begin + (when (< 0.0 (-> gp-4 0 intro-t-step)) + (set! (-> self outro-t) (-> gp-4 0 intro-t)) + (set! (-> self outro-t-step) (/ -5.0 (the float s4-0))) + (set! (-> self outro-exit-value) (-> gp-4 0 outro-exit-value)) + (curve-copy! (-> self outro-curve) (-> gp-4 0 intro-curve)) + ) + (if (-> self settings no-intro) + (set! (-> self outro-t) 0.0) + ) + (send-event *camera-combiner* 'set-interpolation s4-0) + (cond + ((= (-> gp-4 0 blend-from-type) (camera-blend-from-type unknown-0)) + (send-event (ppointer->process (-> self decel)) 'change-state cam-fixed) + (send-event *camera-combiner* 'stop-tracking) + ) + (else + (send-event (ppointer->process (-> self decel)) 'change-state cam-decel) + ) + ) + (set! v1-125 (-> *camera-combiner* tracking-status)) + (zero? v1-125) + ) + (case (-> (the-as camera-slave (-> s5-1 0)) blend-to-type) + (((camera-blend-to-type unknown-0)) + ) + (((camera-blend-to-type unknown-1)) + ) + (((camera-blend-to-type unknown-2)) + (if (= (-> gp-4 0 blend-from-type) (camera-blend-from-type unknown-1)) + (send-event *camera-combiner* 'copy-tracking (ppointer->process gp-4)) + (send-event *camera-combiner* 'start-tracking (ppointer->process s5-1)) + ) + (set! (-> *camera-combiner* tracking-status) (the-as uint 2)) + ) + (else + (format 0 "unknown blend-to type~%") + ) + ) + ) + ((= v1-125 1) + (case (-> (the-as camera-slave (-> s5-1 0)) blend-to-type) + (((camera-blend-to-type unknown-0)) + (set! (-> *camera-combiner* tracking-status) (the-as uint 3)) + ) + (((camera-blend-to-type unknown-1)) + (set! (-> *camera-combiner* tracking-status) (the-as uint 3)) + ) + (((camera-blend-to-type unknown-2)) + ) + (else + (format 0 "unknown blend-to type~%") + ) + ) + ) + ((or (= v1-125 2) (= v1-125 3)) + (case (-> (the-as camera-slave (-> s5-1 0)) blend-to-type) + (((camera-blend-to-type unknown-0)) + (set! (-> *camera-combiner* tracking-status) (the-as uint 0)) + 0 + ) + (((camera-blend-to-type unknown-1)) + (set! (-> *camera-combiner* tracking-status) (the-as uint 0)) + 0 + ) + (((camera-blend-to-type unknown-2)) + (set! (-> *camera-combiner* tracking-status) (the-as uint 2)) + ) + (else + (format 0 "unknown blend-to type~%") + ) + ) + ) + (else + (format 0 "unknown combiner status~%") + ) + ) + (if gp-4 + (deactivate (-> gp-4 0)) + ) + ) + ) + ) + (('ease-in) + (cond + ((< argc 1) + (set! (-> self ease-t) 0.0) + (logclear! (-> self master-options) (cam-master-options-u32 HAVE_EASE_TO_POS)) + ) + ((< argc 2) + (if (< (the-as float (-> block param 0)) (-> self ease-t)) + (set! (-> self ease-t) (the-as float (-> block param 0))) + ) + (logclear! (-> self master-options) (cam-master-options-u32 HAVE_EASE_TO_POS)) + ) + (else + (if (< (the-as float (-> block param 0)) (-> self ease-t)) + (set! (-> self ease-t) (the-as float (-> block param 0))) + ) + (set! (-> self ease-to quad) (-> (the-as vector (-> block param 1)) quad)) + (logior! (-> self master-options) (cam-master-options-u32 HAVE_EASE_TO_POS)) + ) + ) + (set! (-> self ease-step) 0.033333335) + (set! v0-0 (-> self ease-from)) + (set! (-> (the-as vector v0-0) quad) (-> self tpos-curr-adj quad)) + v0-0 + ) + (('damp-up) + (set! (-> self upspeed) 0.0) + ) + (('reset-follow) + (reset-follow #f) + ) + (('teleport) + (reset-target-tracking) + (if (-> self slave) + (send-event (ppointer->process (-> self slave)) message) + ) + (send-event *camera-combiner* message) + ) + (('toggle-slave-option) + (logxor! (-> self slave-options) (the-as uint (-> block param 0))) + (if (-> self slave) + (logxor! (-> self slave 0 options) (the-as uint (-> block param 0))) + ) + (when (-> self decel) + (set! v0-0 (logxor (-> self decel 0 options) (the-as uint (-> block param 0)))) + (set! (-> self decel 0 options) (the-as cam-slave-options-u32 v0-0)) + v0-0 + ) + ) + (('slave-option?) + (and (-> self slave) (logtest? (-> self slave 0 options) (-> block param 0))) + ) + (('set-slave-option) + (when (-> self slave) + (set! v0-0 (logior (-> self slave 0 options) (-> block param 0))) + (set! (-> self slave 0 options) (the-as cam-slave-options-u32 v0-0)) + v0-0 + ) + ) + (('clear-slave-option) + (when (-> self slave) + (set! v0-0 (logclear (-> self slave 0 options) (-> block param 0))) + (set! (-> self slave 0 options) (the-as cam-slave-options-u32 v0-0)) + v0-0 + ) + ) + (('no-follow) + (when (-> self slave) + (set! (-> self slave 0 tracking no-follow) (the-as basic #t)) + (vector-reset! (-> self slave 0 tracking follow-off)) + ) + (set! (-> *camera-combiner* tracking no-follow) (the-as basic #t)) + (set! v0-0 (-> *camera-combiner* tracking follow-off)) + (.svf (&-> (the-as vector v0-0) quad) vf0) + v0-0 + ) + (('yes-follow) + (if (-> self slave) + (set! (-> self slave 0 tracking no-follow) #f) + ) + (set! (-> *camera-combiner* tracking no-follow) #f) + #f + ) + (('blend-from-as-fixed) + (let ((t9-42 format) + (a0-102 0) + (a1-35 "ERROR : *camera* blend-from-as-fixed event not supported anymore~%") + ) + (-> block param 0) + (t9-42 a0-102 a1-35) + ) + ) + (('point-of-interest) + (let ((v1-232 (the-as object (-> block param 0)))) + (let ((a0-103 *math-camera*)) + (set! v0-0 (-> a0-103 trans)) + (let ((a0-104 (-> a0-103 inv-camera-rot fvec))) + (let ((a1-36 (- (-> self interest-dist)))) + (.mov vf7 a1-36) + ) + (.lvf vf5 (&-> a0-104 quad)) + ) + ) + (.lvf vf4 (&-> (the-as vector v1-232) 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 (&-> (the-as vector v0-0) quad) vf6) + v0-0 + ) + (('part-water-drip) + (set-time! (-> self water-drip-time)) + (set! (-> self water-drip-mult) (the-as float (-> block param 0))) + (set! (-> self water-drip-speed) (the-as float (-> block param 1))) + ) + (else + (and (-> self slave) (let ((v1-238 (new 'stack-no-clear 'event-message-block))) + (set! (-> v1-238 from) (process->ppointer proc)) + (set! (-> v1-238 num-params) argc) + (set! (-> v1-238 message) message) + (set! (-> v1-238 param 0) (-> block param 0)) + (set! (-> v1-238 param 1) (-> block param 1)) + (set! (-> v1-238 param 2) (-> block param 2)) + (set! (-> v1-238 param 3) (-> block param 3)) + (set! (-> v1-238 param 4) (-> block param 4)) + (set! (-> v1-238 param 5) (-> block param 5)) + (send-event-function (ppointer->process (-> self slave)) v1-238) + ) + ) + ) + ) + ) + ) + :enter (behavior () + (let ((v1-1 (process-spawn + camera-slave + :init cam-slave-init + cam-free-floating + #f + :name "camera-slave" + :from *camera-dead-pool* + :to self + ) + ) + ) + (set! (-> self slave) (the-as (pointer camera-slave) v1-1)) + (if (not v1-1) + (format 0 "ERROR : first slave failed to activate~%") + ) + ) + (let ((v1-6 (process-spawn + camera-slave + :init cam-slave-init + cam-fixed + #f + :name "camera-slave" + :from *camera-dead-pool* + :to self + ) + ) + ) + (set! (-> self decel) (the-as (pointer camera-slave) v1-6)) + (if (not v1-6) + (format 0 "ERROR : decel failed to activate~%") + ) + ) + (if (and (nonzero? camera-master-debug) *debug-segment*) + (add-connection *debug-engine* self camera-master-debug self #f #f) + ) + ) + :trans (behavior () + (when (not (paused?)) + (vector-negate! + (-> self local-down) + (vector-normalize-copy! (-> self local-down) (-> *standard-dynamics* gravity) 1.0) + ) + (cam-master-effect) + ) + ) + :code (behavior () + (until #f + (set! (-> self string-min target y) (-> self settings string-min-height)) + (set! (-> self string-max target y) (-> self settings string-max-height)) + (set! (-> self string-min target z) (-> self settings string-min-length)) + (set! (-> self string-max target z) (-> self settings string-max-length)) + (when (logtest? (-> *camera* settings master-options) (cam-master-options IMMEDIATE_STRING_MIN_MAX)) + (set! (-> self string-min value y) (-> self settings string-min-height)) + (set! (-> self string-max value y) (-> self settings string-max-height)) + (set! (-> self string-min value z) (-> self settings string-min-length)) + (set! (-> self string-max value z) (-> self settings string-max-length)) + ) + (set! (-> self string-push-z) (fmax (-> self string-min value z) (-> *CAMERA-bank* default-string-push-z))) + (master-track-target) + (set! (-> last-try-to-look-at-data horz) 0.0) + (set! (-> last-try-to-look-at-data vert) 0.0) + (when (not (paused?)) + (update! (-> self string-min) (the-as vector #f)) + (update! (-> self string-max) (the-as vector #f)) + ) + (set! (-> self string-min value x) + (fmin (-> self string-min value x) (+ -4.096 (-> self string-max value x))) + ) + (set! (-> self string-min value y) + (fmin (-> self string-min value y) (+ -4.096 (-> self string-max value y))) + ) + (set! (-> self string-min value z) + (fmin (-> self string-min value z) (+ -4.096 (-> self string-max value z))) + ) + (suspend) + ) + #f + ) + ) + +;; definition for function cam-master-init +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs none. +(defbehavior cam-master-init camera-master () + (stack-size-set! (-> self main-thread) 512) + (logclear! (-> self mask) (process-mask menu)) + (set! (-> self master-options) (cam-master-options-u32)) + (set! (-> self settings) (-> *setting-control* cam-current)) + (set! (-> self slave) (the-as (pointer camera-slave) #f)) + (set! (-> self decel) (the-as (pointer camera-slave) #f)) + (set! (-> self slave-options) (cam-slave-options-u32 JUMP_PITCHES COLLIDE LINE_OF_SIGHT)) + (set! (-> self view-off-param-save) 1.0) + (set! (-> self changer) (the-as uint (process->ppointer self))) + (set! (-> self string-push-z) (-> *CAMERA-bank* default-string-push-z)) + (let ((gp-0 (new-stack-vector0))) + (set! (-> gp-0 y) (-> self settings string-min-height)) + (set! (-> gp-0 z) (-> self settings string-min-length)) + (init (-> self string-min) gp-0 40.96 409.6 0.9) + (set! (-> gp-0 y) (-> self settings string-max-height)) + (set! (-> gp-0 z) (-> self settings string-max-length)) + (init (-> self string-max) gp-0 40.96 409.6 0.9) + ) + (set! (-> self outro-t-step) 0.0) + (reset-to-collide-spec (-> self focus) (collide-spec jak player-list)) + (let ((a1-4 (new-stack-vector0))) + (tracking-spline-method-10 (-> self target-spline) a1-4) + ) + (set! (-> self water-drip) (create-launch-control group-rain-screend-drop self)) + (set! (-> self water-drip-time) (seconds -60)) + (go cam-master-active) + 0 + (none) + ) + +;; definition for method 14 of type camera-master +(defmethod camera-master-method-14 ((this camera-master) (arg0 vector)) + (if (handle->process (-> this focus handle)) + (vector-! arg0 (-> this tpos-curr) (-> this tpos-old)) + (vector-reset! arg0) + ) + arg0 + ) + +;; definition for method 15 of type camera-master +;; INFO: Used lq/sq +(defmethod camera-master-method-15 ((this camera-master) (arg0 vector)) + (if (and (-> this slave) (-> this slave 0 next-state) (= (-> this slave 0 next-state name) 'cam-string)) + (set! (-> arg0 quad) (-> this slave 0 view-flat quad)) + (vector-reset! arg0) + ) + arg0 + ) diff --git a/test/decompiler/reference/jak3/engine/camera/cam-states-dbg_REF.gc b/test/decompiler/reference/jak3/engine/camera/cam-states-dbg_REF.gc new file mode 100644 index 00000000000..209260bb2aa --- /dev/null +++ b/test/decompiler/reference/jak3/engine/camera/cam-states-dbg_REF.gc @@ -0,0 +1,468 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition of type cam-point-watch-bank +(deftype cam-point-watch-bank (basic) + ((speed float) + (rot-speed degrees) + ) + ) + +;; definition for method 3 of type cam-point-watch-bank +(defmethod inspect ((this cam-point-watch-bank)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tspeed: ~f~%" (-> this speed)) + (format #t "~1Trot-speed: (deg ~r)~%" (-> this rot-speed)) + (label cfg-4) + this + ) + +;; definition for symbol *CAM_POINT_WATCH-bank*, type cam-point-watch-bank +(define *CAM_POINT_WATCH-bank* (new 'static 'cam-point-watch-bank :speed 1600.0 :rot-speed (degrees 0.6))) + +;; failed to figure out what this is: +(defstate cam-point-watch (camera-slave) + :event (behavior ((proc process) (argc int) (message symbol) (block event-message-block)) + (case message + (('teleport) + #f + ) + (else + (cam-standard-event-handler proc argc message block) + ) + ) + ) + :enter (behavior () + (when (not (-> self enter-has-run)) + (set! (-> self pivot-rad) 40960.0) + (set! (-> self blend-from-type) (camera-blend-from-type unknown-1)) + (set! (-> self blend-to-type) (camera-blend-to-type unknown-1)) + ) + ) + :code (behavior () + (until #f + (let ((s5-0 (new-stack-vector0)) + (gp-0 (new-stack-vector0)) + ) + (when (not (logtest? (-> *camera* settings master-options) (cam-master-options IGNORE_ANALOG))) + (let ((f28-0 (analog-input (the-as int (-> *cpad-list* cpads 0 leftx)) 128.0 48.0 110.0 -1.0)) + (f30-0 (analog-input (the-as int (-> *cpad-list* cpads 0 lefty)) 128.0 48.0 110.0 -1.0)) + (f26-0 (analog-input (the-as int (-> *cpad-list* cpads 0 rightx)) 128.0 48.0 110.0 -1.0)) + (f0-0 (analog-input (the-as int (-> *cpad-list* cpads 0 righty)) 128.0 48.0 110.0 -1.0)) + ) + (cond + ((cpad-hold? (-> *CAMERA-bank* joypad) r2) + (set! (-> s5-0 y) (- (-> s5-0 y) (* 0.2 (-> *CAM_POINT_WATCH-bank* rot-speed) (- f26-0)))) + (set! (-> s5-0 x) (- (-> s5-0 x) (* 0.2 (-> *CAM_POINT_WATCH-bank* rot-speed) (- f0-0)))) + (+! (-> gp-0 x) (* 0.2 (-> *CAM_POINT_WATCH-bank* speed) f28-0)) + (+! (-> gp-0 z) (* 0.2 (-> *CAM_POINT_WATCH-bank* speed) f30-0)) + ) + (else + (set! (-> s5-0 y) (- (-> s5-0 y) (* 2.0 (-> *CAM_POINT_WATCH-bank* rot-speed) (- f26-0)))) + (set! (-> s5-0 x) (- (-> s5-0 x) (* 2.0 (-> *CAM_POINT_WATCH-bank* rot-speed) (- f0-0)))) + (+! (-> gp-0 x) (* 2.0 (-> *CAM_POINT_WATCH-bank* speed) f28-0)) + (+! (-> gp-0 z) (* 2.0 (-> *CAM_POINT_WATCH-bank* speed) f30-0)) + ) + ) + ) + (let ((s4-0 (new-stack-vector0))) + (let ((s3-0 (new 'stack-no-clear 'matrix))) + (set! (-> s3-0 rvec quad) (the-as uint128 0)) + (set! (-> s3-0 uvec quad) (the-as uint128 0)) + (set! (-> s3-0 fvec quad) (the-as uint128 0)) + (set! (-> s3-0 trans quad) (the-as uint128 0)) + (matrix-axis-angle! s3-0 (the-as vector (-> self tracking)) (- (-> s5-0 x))) + (vector-matrix*! s4-0 (-> self tracking inv-mat fvec) s3-0) + (matrix-axis-angle! s3-0 (-> *camera* local-down) (- (-> s5-0 y))) + (vector-matrix*! s4-0 s4-0 s3-0) + ) + (forward-down->inv-matrix (the-as matrix (-> self tracking)) s4-0 (-> *camera* local-down)) + ) + (set! (-> self pivot-rad) (- (-> self pivot-rad) (-> gp-0 z))) + (if (< (-> self pivot-rad) 4096.0) + (set! (-> self pivot-rad) 4096.0) + ) + (set-vector! gp-0 0.0 0.0 (- (-> self pivot-rad)) 1.0) + (vector-matrix*! (-> self trans) gp-0 (the-as matrix (-> self tracking))) + ) + ) + (suspend) + 0 + ) + #f + ) + ) + +;; definition of type cam-free-bank +(deftype cam-free-bank (basic) + ((speed float) + (rot-speed degrees) + ) + ) + +;; definition for method 3 of type cam-free-bank +(defmethod inspect ((this cam-free-bank)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tspeed: ~f~%" (-> this speed)) + (format #t "~1Trot-speed: (deg ~r)~%" (-> this rot-speed)) + (label cfg-4) + this + ) + +;; definition for symbol *CAM_FREE-bank*, type cam-free-bank +(define *CAM_FREE-bank* (new 'static 'cam-free-bank :speed 1600.0 :rot-speed (degrees 0.6))) + +;; definition for function cam-mouse-input +(defun cam-mouse-input ((arg0 matrix) (arg1 vector) (arg2 vector)) + (rlet ((acc :class vf) + (vf0 :class vf) + (vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + (vf7 :class vf) + ) + (init-vf0-vector) + (let ((v1-0 (new 'stack-no-clear 'vector))) + (vector-! v1-0 (the-as vector (-> *mouse* pos)) (-> *mouse* pos 1)) + (if (< (-> *camera* interest-dist) 409.6) + (set! (-> *camera* interest-dist) 409.6) + ) + (let ((s3-0 (new 'stack-no-clear 'vector)) + (s2-0 (new 'stack-no-clear 'vector)) + ) + (let ((a0-9 (new 'stack-no-clear 'vector))) + 0.0 + (let ((a1-3 a0-9)) + (let ((a2-4 (-> *math-camera* trans))) + (let ((a3-0 (-> arg0 fvec))) + (let ((t0-1 (-> *camera* interest-dist))) + (.mov vf7 t0-1) + ) + (.lvf vf5 (&-> a3-0 quad)) + ) + (.lvf vf4 (&-> a2-4 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-3 quad) vf6) + ) + (vector-! s3-0 (-> *math-camera* trans) a0-9) + ) + (vector-length s3-0) + (cond + ((mouse-hold? left) + (let ((f30-0 (* 72.81778 (-> *mouse* speedy))) + (f28-0 (* -72.81778 (-> *mouse* speedx))) + ) + (let ((a2-8 (quaternion-vector-angle! (new 'stack-no-clear 'quaternion) (-> arg0 rvec) f30-0))) + (vector-orient-by-quat! s2-0 s3-0 a2-8) + ) + (let ((a2-10 (quaternion-vector-angle! (new 'stack-no-clear 'quaternion) *y-vector* f28-0))) + (vector-orient-by-quat! s2-0 s2-0 a2-10) + ) + (vector-! s2-0 s2-0 s3-0) + (vector-matrix*! s2-0 s2-0 (matrix-4x4-inverse! (new 'stack-no-clear 'matrix) arg0)) + (+! (-> arg2 x) (-> s2-0 x)) + (+! (-> arg2 y) (-> s2-0 y)) + (+! (-> arg2 z) (-> s2-0 z)) + (+! (-> arg1 x) f30-0) + (set! (-> arg1 y) (+ (-> arg1 y) f28-0)) + ) + ) + ((mouse-hold? right) + (+! (-> arg2 z) (* (-> v1-0 x) (-> *CAM_FREE-bank* speed))) + (set! (-> *camera* interest-dist) (- (-> *camera* interest-dist) (* (-> *CAM_FREE-bank* speed) (-> v1-0 x)))) + (if (< (-> *camera* interest-dist) 409.6) + (set! (-> *camera* interest-dist) 409.6) + ) + (when (< -8192.0 (vector-dot (-> arg0 fvec) s3-0)) + (let ((t0-2 (new 'static 'vector :w 1.0))) + (let ((v1-18 t0-2)) + (let ((a0-33 (-> *setting-control* cam-current mouse-tumble-point))) + (let ((a1-12 (-> arg0 fvec))) + (let ((a2-13 8192.0)) + (.mov vf7 a2-13) + ) + (.lvf vf5 (&-> a1-12 quad)) + ) + (.lvf vf4 (&-> a0-33 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 (&-> v1-18 quad) vf6) + ) + (set-setting! 'mouse-tumble-point 'abs t0-2 0) + ) + ) + ) + ((mouse-hold? middle) + (+! (-> arg2 x) (* (-> v1-0 x) (-> *CAM_FREE-bank* speed))) + (+! (-> arg2 y) (* (-> v1-0 y) (-> *CAM_FREE-bank* speed))) + (new 'static 'vector :w 1.0) + #f + ) + ) + ) + ) + ) + ) + +;; definition for function cam-free-floating-input +(defun cam-free-floating-input ((arg0 matrix) (arg1 vector) (arg2 vector) (arg3 int) (arg4 int)) + (with-pp + (when *camera* + (if (-> *setting-control* cam-current mouse-input) + (cam-mouse-input arg0 arg1 arg2) + ) + (let ((s3-0 (and (-> *setting-control* cam-current cpad1-skip-buttons) (= arg4 1))) + (f30-0 (-> *CAM_FREE-bank* speed)) + ) + (if *camera-turbo-free* + (set! f30-0 (* 10.0 f30-0)) + ) + (cond + ((logtest? (-> *camera* settings master-options) (cam-master-options IGNORE_ANALOG)) + ) + ((cpad-hold? arg4 r2) + (when (logtest? (-> *camera* settings master-options) (cam-master-options READ_BUTTONS)) + (if (cpad-hold? arg4 r1) + (+! (-> arg2 y) + (+ (* 0.2 f30-0) + (analog-input (the-as int (-> *cpad-list* cpads arg4 abutton 9)) 0.0 32.0 230.0 (* 0.2 f30-0)) + ) + ) + ) + ) + (when (logtest? (-> *camera* settings master-options) (cam-master-options READ_BUTTONS)) + (if (cpad-hold? arg4 l1) + (set! (-> arg2 y) + (- (-> arg2 y) + (+ (* 0.2 f30-0) + (analog-input (the-as int (-> *cpad-list* cpads arg4 abutton 8)) 0.0 32.0 230.0 (* 0.2 f30-0)) + ) + ) + ) + ) + ) + ) + (else + (when (logtest? (-> *camera* settings master-options) (cam-master-options READ_BUTTONS)) + (if (cpad-hold? arg4 r1) + (+! (-> arg2 y) + (+ f30-0 (analog-input (the-as int (-> *cpad-list* cpads arg4 abutton 9)) 0.0 32.0 230.0 f30-0)) + ) + ) + ) + (when (logtest? (-> *camera* settings master-options) (cam-master-options READ_BUTTONS)) + (if (cpad-hold? arg4 l1) + (set! (-> arg2 y) + (- (-> arg2 y) + (+ f30-0 (analog-input (the-as int (-> *cpad-list* cpads arg4 abutton 8)) 0.0 32.0 230.0 f30-0)) + ) + ) + ) + ) + ) + ) + (when (not (logtest? (-> *camera* settings master-options) (cam-master-options IGNORE_ANALOG))) + (let ((f26-2 (analog-input + (the-as int (-> (the-as cpad-list (+ (* arg4 4) (the-as int *cpad-list*))) cpads 0 leftx)) + 128.0 + 48.0 + 110.0 + -1.0 + ) + ) + (f28-4 (analog-input + (the-as int (-> (the-as cpad-list (+ (* arg4 4) (the-as int *cpad-list*))) cpads 0 lefty)) + 128.0 + 48.0 + 110.0 + -1.0 + ) + ) + (f24-0 (analog-input + (the-as int (-> (the-as cpad-list (+ (* arg4 4) (the-as int *cpad-list*))) cpads 0 rightx)) + 128.0 + 48.0 + 110.0 + -1.0 + ) + ) + (f0-19 (analog-input + (the-as int (-> (the-as cpad-list (+ (* arg4 4) (the-as int *cpad-list*))) cpads 0 righty)) + 128.0 + 48.0 + 110.0 + -1.0 + ) + ) + ) + (cond + ((and (not s3-0) + (logtest? (-> (the-as cpad-list (+ (* arg4 4) (the-as int *cpad-list*))) cpads 0 button0-abs 0) + (pad-buttons r2) + ) + ) + (cond + ((logtest? (-> (the-as cpad-list (+ (* arg4 4) (the-as int *cpad-list*))) cpads 0 button0-abs 0) + (pad-buttons l2) + ) + (set! (-> arg1 y) (- (-> arg1 y) (* 0.5 (-> *CAM_FREE-bank* rot-speed) (- f24-0)))) + (set! (-> arg1 x) (- (-> arg1 x) (* 0.5 (-> *CAM_FREE-bank* rot-speed) (- f0-19)))) + ) + (else + (set! (-> arg1 y) (- (-> arg1 y) (* (- f24-0) (-> *CAM_FREE-bank* rot-speed)))) + (set! (-> arg1 x) (- (-> arg1 x) (* (- f0-19) (-> *CAM_FREE-bank* rot-speed)))) + ) + ) + (+! (-> arg2 x) (* 0.2 f30-0 f26-2)) + (+! (-> arg2 z) (* 0.2 f30-0 f28-4)) + ) + ((and (not s3-0) (cpad-hold? arg4 l2)) + (+! (-> arg2 x) (* f26-2 f30-0)) + (+! (-> arg2 y) (* f0-19 f30-0)) + (+! (-> arg2 z) (* f28-4 f30-0)) + ) + (else + (set! (-> arg1 y) (- (-> arg1 y) (* 2.0 (-> *CAM_FREE-bank* rot-speed) (- f24-0)))) + (set! (-> arg1 x) (- (-> arg1 x) (* 2.0 (-> *CAM_FREE-bank* rot-speed) (- f0-19)))) + (+! (-> arg2 x) (* 2.0 f30-0 f26-2)) + (+! (-> arg2 z) (* 2.0 f30-0 f28-4)) + ) + ) + ) + ) + ) + (when (not (-> *setting-control* cam-current mouse-input)) + (vector-float*! arg1 arg1 (-> pp clock time-adjust-ratio)) + (vector-float*! arg2 arg2 (-> pp clock time-adjust-ratio)) + ) + ) + ) + ) + +;; definition of type camera-free-floating-move-info +(deftype camera-free-floating-move-info (structure) + ((rv vector :inline) + (tv vector :inline) + (up vector :inline) + (tm matrix :inline) + ) + ) + +;; definition for method 3 of type camera-free-floating-move-info +(defmethod inspect ((this camera-free-floating-move-info)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'camera-free-floating-move-info) + (format #t "~1Trv: #~%" (-> this rv)) + (format #t "~1Ttv: #~%" (-> this tv)) + (format #t "~1Tup: #~%" (-> this up)) + (format #t "~1Ttm: #~%" (-> this tm)) + (label cfg-4) + this + ) + +;; definition for function cam-free-floating-move +(defun cam-free-floating-move ((arg0 matrix) (arg1 vector) (arg2 vector) (arg3 int)) + (if (logtest? (-> *cpad-list* cpads arg3 valid) 128) + (return (the-as vector #f)) + ) + (if (= *master-mode* 'menu) + (return (the-as vector #f)) + ) + (let ((s3-0 (new 'stack 'camera-free-floating-move-info))) + (cam-free-floating-input arg0 (-> s3-0 rv) (-> s3-0 tv) (the-as int (not arg2)) arg3) + (vector-matrix*! (-> s3-0 tv) (-> s3-0 tv) arg0) + (cond + (arg2 + (matrix-axis-angle! (-> s3-0 tm) arg2 (-> s3-0 rv y)) + (matrix*! arg0 arg0 (-> s3-0 tm)) + (cond + ((< (vector-dot (-> arg0 uvec) arg2) 0.0) + (forward-down->inv-matrix arg0 (-> arg0 fvec) arg2) + ) + (else + (vector-negate! (-> s3-0 up) arg2) + (forward-down->inv-matrix arg0 (-> arg0 fvec) (-> s3-0 up)) + ) + ) + ) + (else + (matrix-axis-angle! (-> s3-0 tm) (-> arg0 uvec) (- (-> s3-0 rv y))) + (matrix*! arg0 arg0 (-> s3-0 tm)) + ) + ) + (matrix-axis-angle! (-> s3-0 tm) (-> arg0 rvec) (- (-> s3-0 rv x))) + (matrix*! arg0 arg0 (-> s3-0 tm)) + (matrix-axis-angle! (-> s3-0 tm) (-> arg0 fvec) (- (-> s3-0 rv z))) + (matrix*! arg0 arg0 (-> s3-0 tm)) + (vector+! arg1 arg1 (-> s3-0 tv)) + ) + ) + +;; failed to figure out what this is: +(defstate cam-free-floating (camera-slave) + :event (behavior ((proc process) (argc int) (message symbol) (block event-message-block)) + (case message + (('teleport) + #f + ) + (else + (cam-standard-event-handler proc argc message block) + ) + ) + ) + :enter (behavior () + (when (not (-> self enter-has-run)) + (set! (-> self blend-from-type) (camera-blend-from-type unknown-1)) + (set! (-> self blend-to-type) (camera-blend-to-type unknown-1)) + (send-event *camera-combiner* 'stop-tracking) + ) + ) + :code (behavior () + (until #f + (let ((gp-0 (-> *camera* local-down))) + (if (logtest? (-> self options) (cam-slave-options-u32 ALLOW_Z_ROT)) + (set! gp-0 (the-as vector #f)) + ) + (when (not (-> *setting-control* cam-current mouse-input)) + (if *amy-cam* + (matrix-rotate-y! (the-as matrix (-> self tracking)) 32768.0) + ) + (cam-free-floating-move + (the-as matrix (-> self tracking)) + (-> self trans) + gp-0 + (the-as int (-> *CAMERA-bank* joypad)) + ) + (when *amy-cam* + (matrix-rotate-y! (the-as matrix (-> self tracking)) 32768.0) + (let ((a1-4 (matrix-rotate-x! (new 'stack-no-clear 'matrix) 16384.0))) + (matrix*! (the-as matrix (-> self tracking)) a1-4 (the-as matrix (-> self tracking))) + ) + ) + ) + ) + (suspend) + ) + #f + ) + ) + + + + diff --git a/test/decompiler/reference/jak3/engine/camera/cam-states_REF.gc b/test/decompiler/reference/jak3/engine/camera/cam-states_REF.gc new file mode 100644 index 00000000000..fb6000c50b1 --- /dev/null +++ b/test/decompiler/reference/jak3/engine/camera/cam-states_REF.gc @@ -0,0 +1,3970 @@ +;;-*-Lisp-*- +(in-package goal) + +;; failed to figure out what this is: +(defstate cam-no-trans (camera-slave) + :event cam-standard-event-handler + :enter (behavior () + (when (not (-> self enter-has-run)) + (set! (-> self blend-from-type) (camera-blend-from-type unknown-2)) + (set! (-> self blend-to-type) (camera-blend-to-type unknown-2)) + ) + ) + :trans (behavior () + (if (not (logtest? (-> *camera* master-options) (cam-master-options-u32 HAVE_TARGET))) + (cam-slave-go cam-free-floating) + ) + ) + :code (behavior () + (until #f + (if (not (paused?)) + (set! (-> self fov) (-> *camera* settings fov)) + ) + (suspend) + ) + #f + ) + ) + +;; failed to figure out what this is: +(defstate cam-really-fixed (camera-slave) + :event (behavior ((proc process) (argc int) (message symbol) (block event-message-block)) + (case message + (('teleport) + #f + ) + (else + (cam-standard-event-handler proc argc message block) + ) + ) + ) + :enter (behavior () + (when (not (-> self enter-has-run)) + (set! (-> self saved-pt quad) (-> self trans quad)) + (set! (-> self blend-from-type) (camera-blend-from-type unknown-1)) + (set! (-> self blend-to-type) (camera-blend-to-type unknown-0)) + 0 + ) + ) + :code (behavior () + (until #f + (suspend) + ) + #f + ) + ) + +;; failed to figure out what this is: +(defstate cam-fixed (camera-slave) + :event (behavior ((proc process) (argc int) (message symbol) (block event-message-block)) + (case message + (('teleport) + #f + ) + (else + (cam-standard-event-handler proc argc message block) + ) + ) + ) + :enter (behavior () + (when (not (-> self enter-has-run)) + (set! (-> self saved-pt quad) (-> self trans quad)) + (set! (-> self blend-from-type) (camera-blend-from-type unknown-1)) + (set! (-> self blend-to-type) (camera-blend-to-type unknown-0)) + 0 + ) + ) + :code (behavior () + (until #f + (when (not (paused?)) + (let ((gp-0 (new 'stack-no-clear 'vector))) + (set! (-> self fov) (-> *camera* slave 0 fov)) + (set! (-> self trans quad) (-> self saved-pt quad)) + (cam-curve-pos (-> self trans) gp-0 (the-as curve #f) #f) + (when (!= (-> gp-0 w) 0.0) + (vector-normalize! gp-0 1.0) + (forward-down->inv-matrix (the-as matrix (-> self tracking)) gp-0 (-> *camera* local-down)) + ) + ) + ) + (suspend) + ) + #f + ) + ) + +;; failed to figure out what this is: +(defstate cam-fixed-read-entity (camera-slave) + :event (behavior ((proc process) (argc int) (message symbol) (block event-message-block)) + (case message + (('teleport) + #f + ) + (else + (cam-standard-event-handler proc argc message block) + ) + ) + ) + :enter (behavior () + (cond + ((-> self enter-has-run) + ) + ((-> self cam-entity) + (cam-slave-get-vector-with-offset (the-as entity-actor (-> self cam-entity)) (-> self trans) 'trans) + (cam-slave-get-rot (the-as entity-actor (-> self cam-entity)) (the-as matrix (-> self tracking))) + (set! (-> self fov) (cam-slave-get-fov (-> self cam-entity))) + (cam-curve-setup (-> self trans)) + ((-> cam-fixed enter)) + ) + (else + (format #t "ERROR : cam-fixed-read-entity enter without entity~%") + ) + ) + (go cam-fixed) + ) + :code (behavior () + (until #f + (format *stdcon* "ERROR : stayed in cam-fixed-read-entity~%") + (suspend) + ) + #f + ) + ) + +;; failed to figure out what this is: +(defstate cam-pov (camera-slave) + :event (behavior ((proc process) (argc int) (message symbol) (block event-message-block)) + (case message + (('teleport) + #f + ) + (else + (cam-standard-event-handler proc argc message block) + ) + ) + ) + :enter (behavior () + (when (not (-> self enter-has-run)) + (set! (-> self blend-from-type) (camera-blend-from-type unknown-1)) + (set! (-> self blend-to-type) (camera-blend-to-type unknown-1)) + ) + ) + :trans (behavior () + (when (not (handle->process (-> *camera* settings pov-handle))) + (set! (-> self blend-from-type) (camera-blend-from-type unknown-0)) + (cam-slave-go cam-fixed) + ) + ) + :code (behavior () + (until #f + (when (not (paused?)) + (vector<-cspace! (-> self trans) (-> (the-as process-drawable (-> *camera* settings pov-handle process 0)) + node-list + data + (-> *camera* settings pov-bone) + ) + ) + (let* ((v1-6 (-> self tracking)) + (a3-0 (-> (the-as process-drawable (-> *camera* settings pov-handle process 0)) + node-list + data + (-> *camera* settings pov-bone) + bone + transform + ) + ) + (a0-9 (-> a3-0 rvec quad)) + (a1-11 (-> a3-0 uvec quad)) + (a2-0 (-> a3-0 fvec quad)) + (a3-1 (-> a3-0 trans quad)) + ) + (set! (-> v1-6 inv-mat rvec quad) a0-9) + (set! (-> v1-6 inv-mat uvec quad) a1-11) + (set! (-> v1-6 inv-mat fvec quad) a2-0) + (set! (-> v1-6 inv-mat trans quad) a3-1) + ) + (vector-reset! (-> self tracking inv-mat trans)) + (let ((gp-0 (new 'stack-no-clear 'vector))) + (vector-matrix*! gp-0 (-> *camera* settings pov-offset) (the-as matrix (-> self tracking))) + (vector+! (-> self trans) (-> self trans) gp-0) + ) + ) + (suspend) + ) + #f + ) + ) + +;; failed to figure out what this is: +(defstate cam-pov180 (camera-slave) + :event (behavior ((proc process) (argc int) (message symbol) (block event-message-block)) + (case message + (('teleport) + #f + ) + (else + (cam-standard-event-handler proc argc message block) + ) + ) + ) + :enter (behavior () + (when (not (-> self enter-has-run)) + (set! (-> self blend-from-type) (camera-blend-from-type unknown-1)) + (set! (-> self blend-to-type) (camera-blend-to-type unknown-1)) + ) + ) + :trans (behavior () + (when (not (handle->process (-> *camera* settings pov-handle))) + (set! (-> self blend-from-type) (camera-blend-from-type unknown-0)) + (cam-slave-go cam-fixed) + ) + ) + :code (behavior () + (let ((gp-0 (new 'stack-no-clear 'vector)) + (s5-0 (new 'stack-no-clear 'vector)) + (s4-0 #t) + ) + (vector<-cspace! gp-0 (-> (the-as process-drawable (-> *camera* settings pov-handle process 0)) + node-list + data + (-> *camera* settings pov-bone) + ) + ) + (let ((v1-13 (-> (the-as process-drawable (-> *camera* settings pov-handle process 0)) + node-list + data + (-> *camera* settings pov-bone) + bone + transform + ) + ) + ) + (vector-normalize-copy! s5-0 (-> v1-13 fvec) 1.0) + ) + (until #f + (when (not (paused?)) + (let ((s0-0 (-> (the-as process-drawable (-> *camera* settings pov-handle process 0)) + node-list + data + (-> *camera* settings pov-bone) + bone + transform + ) + ) + (s1-0 (-> (the-as process-drawable (-> *camera* settings pov-handle process 0)) + node-list + data + (-> *camera* settings pov-bone) + bone + scale + ) + ) + (s3-0 (new 'stack-no-clear 'vector)) + ) + (let ((s2-0 (new 'stack-no-clear 'vector))) + (vector<-cspace! + s2-0 + (-> (the-as process-drawable (-> *camera* settings pov-handle process 0)) + node-list + data + (-> *camera* settings pov-bone) + ) + ) + (vector-normalize-copy! s3-0 (-> s0-0 fvec) 1.0) + (set! s4-0 + (cond + ((and (< (vector-vector-distance s2-0 gp-0) 40960.0) (< (cos 3640.889) (vector-dot s5-0 s3-0))) + (set! (-> self trans quad) (-> s2-0 quad)) + (vector-negate! (the-as vector (-> self tracking)) (-> s0-0 rvec)) + (set! (-> self tracking inv-mat uvec quad) (-> s0-0 uvec quad)) + (vector-negate! (-> self tracking inv-mat fvec) (-> s0-0 fvec)) + (set! (-> self fov) (* 2.0 (atan (/ 12.700255 (* 20.3 (-> s1-0 x))) 1.0))) + (vector-float*! (the-as vector (-> self tracking)) (the-as vector (-> self tracking)) (/ 1.0 (-> s1-0 x))) + (vector-reset! (-> self tracking inv-mat trans)) + (if s4-0 + (set! s4-0 #f) + ) + s4-0 + ) + (else + #t + ) + ) + ) + (set! (-> gp-0 quad) (-> s2-0 quad)) + ) + (set! (-> s5-0 quad) (-> s3-0 quad)) + ) + ) + (suspend) + ) + ) + #f + ) + ) + +;; failed to figure out what this is: +(defstate cam-pov-track (camera-slave) + :event cam-standard-event-handler + :enter (behavior () + (when (not (-> self enter-has-run)) + (set! (-> self blend-from-type) (camera-blend-from-type unknown-2)) + (set! (-> self blend-to-type) (camera-blend-to-type unknown-2)) + ) + ) + :trans (behavior () + (if (or (not (handle->process (-> *camera* settings pov-handle))) + (not (logtest? (-> *camera* master-options) (cam-master-options-u32 HAVE_TARGET))) + ) + (cam-slave-go cam-free-floating) + ) + ) + :code (behavior () + (until #f + (when (not (paused?)) + (set! (-> self fov) (-> *camera* settings fov)) + (vector<-cspace! (-> self trans) (-> (the-as process-drawable (-> *camera* settings pov-handle process 0)) + node-list + data + (-> *camera* settings pov-bone) + ) + ) + (let ((gp-0 (new 'stack-no-clear 'vector))) + (let ((a2-0 (new 'stack-no-clear 'matrix))) + (let* ((v1-8 a2-0) + (t0-0 (-> (the-as process-drawable (-> *camera* settings pov-handle process 0)) + node-list + data + (-> *camera* settings pov-bone) + bone + transform + ) + ) + (a0-9 (-> t0-0 rvec quad)) + (a1-11 (-> t0-0 uvec quad)) + (a3-0 (-> t0-0 fvec quad)) + (t0-1 (-> t0-0 trans quad)) + ) + (set! (-> v1-8 rvec quad) a0-9) + (set! (-> v1-8 uvec quad) a1-11) + (set! (-> v1-8 fvec quad) a3-0) + (set! (-> v1-8 trans quad) t0-1) + ) + (vector-reset! (-> a2-0 trans)) + (vector-matrix*! gp-0 (-> *camera* settings pov-offset) a2-0) + ) + (vector+! (-> self trans) (-> self trans) gp-0) + ) + ) + (suspend) + ) + #f + ) + ) + +;; definition for function cam-standoff-calc-trans +(defbehavior cam-standoff-calc-trans camera-slave () + (if (-> self tracking no-follow) + (vector+! (-> self trans) (-> *camera* tpos-curr-adj) (-> self pivot-pt)) + (vector+! (-> self trans) (-> self tracking follow-pt) (-> self pivot-pt)) + ) + ) + +;; failed to figure out what this is: +(defstate cam-standoff (camera-slave) + :event (behavior ((proc process) (argc int) (message symbol) (block event-message-block)) + (case message + (('set-standoff-dist) + (vector-normalize! (-> self pivot-pt) (the-as float (-> block param 0))) + (cam-standoff-calc-trans) + ) + (('set-standoff-height) + (vector-flatten! (-> self pivot-pt) (-> self pivot-pt) (-> *camera* local-down)) + (vector--float*! + (-> self pivot-pt) + (-> self pivot-pt) + (-> *camera* local-down) + (the-as float (-> block param 0)) + ) + (cam-standoff-calc-trans) + ) + (else + (cam-standard-event-handler proc argc message block) + ) + ) + ) + :enter (behavior () + (when (not (-> self enter-has-run)) + (vector-! (-> self pivot-pt) (-> self trans) (-> *camera* tpos-curr-adj)) + (cond + ((logtest? (-> self options) (cam-slave-options-u32 NO_ROTATE)) + (set! (-> self blend-from-type) (camera-blend-from-type unknown-0)) + (set! (-> self blend-to-type) (camera-blend-to-type unknown-0)) + 0 + ) + (else + (set! (-> self blend-from-type) (camera-blend-from-type unknown-2)) + (set! (-> self blend-to-type) (camera-blend-to-type unknown-2)) + ) + ) + ) + (cam-calc-follow! (-> self tracking) (-> self trans) #f) + ) + :trans (behavior () + (if (not (logtest? (-> *camera* master-options) (cam-master-options-u32 HAVE_TARGET))) + (cam-slave-go cam-free-floating) + ) + ) + :code (behavior () + (until #f + (when (not (paused?)) + (cam-calc-follow! (-> self tracking) (-> self trans) #t) + (cam-standoff-calc-trans) + ) + (suspend) + ) + #f + ) + ) + +;; failed to figure out what this is: +(defstate cam-standoff-read-entity (camera-slave) + :event cam-standard-event-handler + :enter (behavior () + (cond + ((-> self enter-has-run) + ) + ((-> self cam-entity) + (let ((gp-0 (new-stack-vector0)) + (s5-0 (new-stack-vector0)) + ) + (cam-slave-get-vector-with-offset (the-as entity-actor (-> self cam-entity)) gp-0 'trans) + (cam-slave-get-vector-with-offset (the-as entity-actor (-> self cam-entity)) s5-0 'align) + (vector-! (-> self pivot-pt) gp-0 s5-0) + ) + (vector+! (-> self trans) (-> *camera* tpos-curr-adj) (-> self pivot-pt)) + (set! (-> self fov) (cam-slave-get-fov (-> self cam-entity))) + (logior! (-> self options) (cam-slave-get-flags (-> self cam-entity) 'flags)) + (if (logtest? (-> self options) (cam-slave-options-u32 NO_ROTATE)) + (cam-slave-get-rot (the-as entity-actor (-> self cam-entity)) (the-as matrix (-> self tracking))) + (set! (-> self tracking tilt-adjust target) + (cam-slave-get-float (-> self cam-entity) 'tiltAdjust (-> *CAMERA-bank* default-tilt-adjust)) + ) + ) + ((-> cam-standoff enter)) + ) + (else + (format #t "ERROR : cam-standoff-read-entity enter without entity~%") + ) + ) + (go cam-standoff) + ) + :code (behavior () + (until #f + (format *stdcon* "ERROR : stayed in cam-standoff-read-entity~%") + (suspend) + ) + #f + ) + ) + +;; definition of type cam-eye-bank +(deftype cam-eye-bank (basic) + ((rot-speed float) + (max-degrees float) + (max-fov float) + (min-fov float) + ) + ) + +;; definition for method 3 of type cam-eye-bank +(defmethod inspect ((this cam-eye-bank)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Trot-speed: ~f~%" (-> this rot-speed)) + (format #t "~1Tmax-degrees: ~f~%" (-> this max-degrees)) + (format #t "~1Tmax-fov: ~f~%" (-> this max-fov)) + (format #t "~1Tmin-fov: ~f~%" (-> this min-fov)) + (label cfg-4) + this + ) + +;; definition for symbol *CAM_EYE-bank*, type cam-eye-bank +(define *CAM_EYE-bank* + (new 'static 'cam-eye-bank :rot-speed 364.0889 :max-degrees 12743.111 :max-fov 11650.845 :min-fov 6189.511) + ) + +;; failed to figure out what this is: +(defstate cam-eye (camera-slave) + :event (behavior ((proc process) (argc int) (message symbol) (block event-message-block)) + (case message + (('teleport) + #f + ) + (else + (cam-standard-event-handler proc argc message block) + ) + ) + ) + :enter (behavior () + (when (not (-> self enter-has-run)) + (let ((v1-3 + (vector-float*! (new-stack-vector0) (-> *camera* local-down) (+ 1024.0 (-> *camera* settings target-height))) + ) + ) + (vector-! (-> self trans) (-> *camera* tpos-curr) v1-3) + ) + (set! (-> self blend-from-type) (camera-blend-from-type unknown-0)) + (set! (-> self blend-to-type) (camera-blend-to-type unknown-0)) + 0 + ) + (set! (-> self fov) 11650.845) + ) + :exit (behavior () + (if (and *target* + (logtest? (-> *camera* master-options) (cam-master-options-u32 HAVE_TARGET)) + (focus-test? *target* in-head) + ) + (send-event *target* 'end-mode 'in-head) + ) + ) + :trans (behavior () + (if (not (logtest? (-> *camera* master-options) (cam-master-options-u32 HAVE_TARGET))) + (go cam-free-floating) + ) + ) + :code (behavior () + (let ((gp-0 (current-time))) + (until #f + (when (not (paused?)) + (let ((s4-0 (vector-reset! (new-stack-vector0))) + (s5-0 (new 'stack-no-clear 'matrix)) + ) + (set! (-> s5-0 rvec quad) (the-as uint128 0)) + (set! (-> s5-0 uvec quad) (the-as uint128 0)) + (set! (-> s5-0 fvec quad) (the-as uint128 0)) + (set! (-> s5-0 trans quad) (the-as uint128 0)) + (when (not (logtest? (-> *camera* settings master-options) (cam-master-options IGNORE_ANALOG))) + (let ((f30-0 (analog-input + (the-as int (+ (-> *cpad-list* cpads 0 rightx) -256 (-> *cpad-list* cpads 0 leftx))) + 0.0 + 48.0 + 110.0 + -1.0 + ) + ) + (f0-0 (analog-input + (the-as int (+ (-> *cpad-list* cpads 0 righty) -256 (-> *cpad-list* cpads 0 lefty))) + 0.0 + 48.0 + 110.0 + -1.0 + ) + ) + ) + (if (-> *camera* settings flip-vertical) + (set! f0-0 (- f0-0)) + ) + (set! (-> s4-0 y) (- (-> s4-0 y) (* (- f30-0) (-> *CAM_EYE-bank* rot-speed)))) + (set! (-> s4-0 x) (- (-> s4-0 x) (* (- f0-0) (-> *CAM_EYE-bank* rot-speed)))) + ) + ) + (cond + ((< (-> *CAM_EYE-bank* rot-speed) (-> s4-0 x)) + (set! (-> s4-0 x) (-> *CAM_EYE-bank* rot-speed)) + ) + ((< (-> s4-0 x) (- (-> *CAM_EYE-bank* rot-speed))) + (set! (-> s4-0 x) (- (-> *CAM_EYE-bank* rot-speed))) + ) + ) + (cond + ((< (-> *CAM_EYE-bank* rot-speed) (-> s4-0 y)) + (set! (-> s4-0 y) (-> *CAM_EYE-bank* rot-speed)) + ) + ((< (-> s4-0 y) (- (-> *CAM_EYE-bank* rot-speed))) + (set! (-> s4-0 y) (- (-> *CAM_EYE-bank* rot-speed))) + ) + ) + (cond + ((and (= (-> s4-0 x) 0.0) (= (-> s4-0 y) 0.0)) + (set! gp-0 (current-time)) + ) + (else + (let ((v1-44 (min 10 (max 1 (- (current-time) gp-0))))) + (vector-float*! s4-0 s4-0 (* 0.1 (the float v1-44))) + ) + ) + ) + (matrix-axis-angle! s5-0 (-> *camera* local-down) (-> s4-0 y)) + (matrix*! (the-as matrix (-> self tracking)) (the-as matrix (-> self tracking)) s5-0) + (when (not (logtest? (-> self options) (cam-slave-options-u32 ALLOW_Z_ROT))) + (if (< (vector-dot (-> self tracking inv-mat uvec) (-> *camera* local-down)) 0.0) + (forward-down->inv-matrix + (the-as matrix (-> self tracking)) + (-> self tracking inv-mat fvec) + (-> *camera* local-down) + ) + (forward-down->inv-matrix + (the-as matrix (-> self tracking)) + (-> self tracking inv-mat fvec) + (vector-negate! (new-stack-vector0) (-> *camera* local-down)) + ) + ) + ) + (matrix-axis-angle! s5-0 (the-as vector (-> self tracking)) (- (-> s4-0 x))) + (matrix*! (the-as matrix (-> self tracking)) (the-as matrix (-> self tracking)) s5-0) + ) + (when (not (logtest? (-> self options) (cam-slave-options-u32 ALLOW_Z_ROT))) + (let ((f30-1 (vector-dot (-> *camera* local-down) (-> self tracking inv-mat fvec)))) + (set! (-> (new 'stack-no-clear 'vector) quad) (the-as uint128 0)) + (when (< (sin (-> *CAM_EYE-bank* max-degrees)) (fabs f30-1)) + (vector--float*! + (-> self tracking inv-mat fvec) + (-> self tracking inv-mat fvec) + (-> *camera* local-down) + f30-1 + ) + (vector-normalize! (-> self tracking inv-mat fvec) (cos (-> *CAM_EYE-bank* max-degrees))) + (if (< f30-1 0.0) + (vector--float*! + (-> self tracking inv-mat fvec) + (-> self tracking inv-mat fvec) + (-> *camera* local-down) + (sin (-> *CAM_EYE-bank* max-degrees)) + ) + (vector+float*! + (-> self tracking inv-mat fvec) + (-> self tracking inv-mat fvec) + (-> *camera* local-down) + (sin (-> *CAM_EYE-bank* max-degrees)) + ) + ) + (vector-cross! + (-> self tracking inv-mat uvec) + (-> self tracking inv-mat fvec) + (the-as vector (-> self tracking)) + ) + (set! (-> self tracking inv-mat uvec w) 0.0) + ) + ) + ) + ) + (let ((v1-75 + (vector-float*! (new-stack-vector0) (-> *camera* local-down) (+ 1024.0 (-> *camera* settings target-height))) + ) + ) + (vector-! (-> self trans) (-> *camera* tpos-curr) v1-75) + ) + (suspend) + ) + ) + #f + ) + ) + +;; definition for function cam-curve-closest-point +(defun cam-curve-closest-point ((arg0 curve) (arg1 vector) (arg2 float) (arg3 float) (arg4 int)) + (let ((s4-0 1) + (s2-0 40.96) + (f30-1 (/ 1.0 (* 3.0 (curve-length arg0)))) + (f28-1 0.01) + ) + (if (< 0.0 s2-0) + (set! f28-1 (* s2-0 f30-1)) + ) + (while (> s4-0 0) + (+! s4-0 -1) + (let* ((v1-6 (fmax 0.0 (fmin 1.0 arg2))) + (f26-0 (fmax 0.0 (- v1-6 f28-1))) + (f24-0 (fmin 1.0 (+ v1-6 f28-1))) + (s3-1 (new 'stack-no-clear 'vector)) + (s2-1 (new 'stack-no-clear 'vector)) + (s1-0 (new 'stack-no-clear 'vector)) + (s0-0 (* 0.5 (+ f26-0 f24-0))) + ) + (curve-get-pos! s3-1 s0-0 arg0) + (vector-! s3-1 arg1 s3-1) + (curve-get-pos! s2-1 f24-0 arg0) + (curve-get-pos! s1-0 f26-0 arg0) + (vector-! s2-1 s2-1 s1-0) + (vector-normalize! s2-1 1.0) + (let ((v1-11 (+ s0-0 (* (vector-dot s2-1 s3-1) f30-1)))) + (set! arg2 (fmax 0.0 (fmin 1.0 v1-11))) + ) + ) + ) + ) + arg2 + ) + +;; failed to figure out what this is: +(defstate cam-tube-sled (camera-slave) + :event cam-standard-event-handler + :enter (behavior () + (cond + ((-> self enter-has-run) + ) + ((-> self cam-entity) + (set! (-> self fov) (cam-slave-get-fov (-> self cam-entity))) + (logior! (-> self options) (cam-slave-get-flags (-> self cam-entity) 'flags)) + (set! (-> self spline-follow-dist) + (fmax 0.0 (cam-slave-get-float (-> self cam-entity) 'spline-follow-dist 0.0)) + ) + (when (get-curve-data! (-> self cam-entity) (-> self spline-curve) 'campath 'campath-k -1000000000.0) + (set! (-> self spline-tt) (curve-closest-point (-> self spline-curve) (-> self saved-pt) 0.5 -4096.0 30 0.0)) + (set! (-> self spline-tt) (fmin 1.0 (fmax 0.0 (-> self spline-tt)))) + (set! (-> self spline-exists) #t) + ) + (set! (-> self blend-from-type) (camera-blend-from-type unknown-1)) + (set! (-> self blend-to-type) (camera-blend-to-type unknown-1)) + ) + (else + (format 0 "ERROR : cam-tube-sled enter without entity~%") + ) + ) + ) + :trans (behavior () + (if (not (logtest? (-> *camera* master-options) (cam-master-options-u32 HAVE_TARGET))) + (cam-slave-go cam-free-floating) + ) + ) + :code (behavior () + (until #f + (let ((v1-0 (or (paused?) (not (-> self spline-exists))))) + (cond + (v1-0 + ) + (else + (let ((s4-0 (new 'stack-no-clear 'vector))) + (set! (-> s4-0 quad) (-> *camera* tpos-curr quad)) + (let ((s5-0 (new 'stack-no-clear 'vector)) + (gp-0 (new 'stack-no-clear 'vector)) + ) + (let ((f30-1 (/ 1.0 (curve-length (-> self spline-curve))))) + (set! (-> self spline-tt) (cam-curve-closest-point (-> self spline-curve) s4-0 (-> self spline-tt) 40.96 1)) + (curve-get-pos! s5-0 (-> self spline-tt) (-> self spline-curve)) + (vector-lerp! (-> self trans) s5-0 s4-0 0.75) + (cond + ((< (-> self spline-tt) 0.5) + (curve-get-pos! gp-0 (+ (-> self spline-tt) (* 4096.0 f30-1)) (-> self spline-curve)) + (vector-! gp-0 gp-0 s5-0) + ) + (else + (curve-get-pos! gp-0 (- (-> self spline-tt) (* 4096.0 f30-1)) (-> self spline-curve)) + (vector-! gp-0 s5-0 gp-0) + ) + ) + (vector-normalize! gp-0 1.0) + (vector+float*! (-> self trans) (-> self trans) gp-0 (-> self spline-follow-dist)) + (curve-get-pos! gp-0 (- (-> self spline-tt) (* 122880.0 f30-1)) (-> self spline-curve)) + ) + (vector-! gp-0 s5-0 gp-0) + (vector-negate! gp-0 gp-0) + (vector-normalize! gp-0 1.0) + (forward-down->inv-matrix (the-as matrix (-> self tracking)) gp-0 (-> *camera* local-down)) + ) + ) + (vector-into-frustum-nosmooth! (the-as matrix (-> self tracking)) (-> self trans) (-> self fov)) + ) + ) + ) + (suspend) + ) + #f + ) + ) + +;; failed to figure out what this is: +(defstate cam-spline (camera-slave) + :event cam-standard-event-handler + :enter (behavior () + (cond + ((-> self enter-has-run) + ) + ((-> self cam-entity) + (let ((gp-0 (new-stack-vector0))) + (set! (-> self fov) (cam-slave-get-fov (-> self cam-entity))) + (logior! (-> self options) (cam-slave-get-flags (-> self cam-entity) 'flags)) + (if (logtest? (-> self options) (cam-slave-options-u32 NO_ROTATE)) + (cam-slave-get-rot (the-as entity-actor (-> self cam-entity)) (the-as matrix (-> self tracking))) + (set! (-> self tracking tilt-adjust target) + (cam-slave-get-float (-> self cam-entity) 'tiltAdjust (-> *CAMERA-bank* default-tilt-adjust)) + ) + ) + (cam-slave-get-vector-with-offset (the-as entity-actor (-> self cam-entity)) gp-0 'trans) + (cam-curve-setup gp-0) + ) + (vector-negate! (-> self saved-pt) (-> self spline-offset)) + (let ((a0-8 (res-lump-struct (-> self cam-entity) 'spline-offset structure))) + (if a0-8 + (vector+! (-> self spline-offset) (-> self spline-offset) (the-as vector a0-8)) + ) + ) + (set! (-> self trans quad) (-> self saved-pt quad)) + (cam-calc-follow! (-> self tracking) (-> self trans) #f) + (set! (-> self spline-follow-dist) (cam-slave-get-float (-> self cam-entity) 'spline-follow-dist 0.0)) + (cond + ((< 0.0 (-> self spline-follow-dist)) + (let ((s5-1 (new 'stack-no-clear 'vector)) + (gp-1 (new 'stack-no-clear 'vector)) + ) + (curve-get-pos! s5-1 0.0 (-> self spline-curve)) + (curve-get-pos! gp-1 1.0 (-> self spline-curve)) + (if (< (vector-vector-distance-squared s5-1 (-> self tracking follow-pt)) + (vector-vector-distance-squared gp-1 (-> self tracking follow-pt)) + ) + (set! (-> self spline-follow-dist) (- (-> self spline-follow-dist))) + ) + ) + (set! (-> self spline-tt) (curve-closest-point + (-> self spline-curve) + (-> self tracking follow-pt) + 0.5 + -4096.0 + 10 + (-> self spline-follow-dist) + ) + ) + ) + (else + (set! (-> self spline-follow-dist) 0.0) + ) + ) + (cam-curve-pos (-> self trans) (the-as vector #f) (the-as curve #f) #t) + (cond + ((logtest? (-> self options) (cam-slave-options-u32 NO_ROTATE)) + (set! (-> self blend-from-type) (camera-blend-from-type unknown-0)) + (set! (-> self blend-to-type) (camera-blend-to-type unknown-0)) + 0 + ) + (else + (set! (-> self blend-from-type) (camera-blend-from-type unknown-2)) + (set! (-> self blend-to-type) (camera-blend-to-type unknown-2)) + ) + ) + ) + (else + (format #t "ERROR : cam-spline enter without entity~%") + ) + ) + ) + :trans (behavior () + (if (not (logtest? (-> *camera* master-options) (cam-master-options-u32 HAVE_TARGET))) + (cam-slave-go cam-free-floating) + ) + ) + :code (behavior () + (until #f + (when (not (paused?)) + (cam-calc-follow! (-> self tracking) (-> self trans) #t) + (new 'stack 'curve) + (set! (-> self trans quad) (-> self saved-pt quad)) + (cam-curve-pos (-> self trans) (the-as vector #f) (the-as curve #f) #t) + ) + (suspend) + ) + #f + ) + ) + +;; failed to figure out what this is: +(defstate cam-decel (camera-slave) + :event (behavior ((proc process) (argc int) (message symbol) (block event-message-block)) + (case message + (('teleport) + #f + ) + (else + (cam-standard-event-handler proc argc message block) + ) + ) + ) + :enter (behavior () + (when (not (-> self enter-has-run)) + (set! (-> self saved-pt quad) (-> self trans quad)) + (set! (-> self blend-from-type) (camera-blend-from-type unknown-1)) + (set! (-> self blend-to-type) (camera-blend-to-type unknown-1)) + ) + ) + :code (behavior () + (until #f + (when (not (paused?)) + (let ((s5-0 (new-stack-vector0)) + (gp-0 (new-stack-vector0)) + ) + (when (!= (-> *camera* outro-t-step) 0.0) + (curve-get-pos! s5-0 (parameter-ease-sin-clamp (-> *camera* outro-t)) (-> *camera* outro-curve)) + (+! (-> *camera* outro-t) (* (-> *camera* outro-t-step) (-> self clock time-adjust-ratio))) + (curve-get-pos! gp-0 (parameter-ease-sin-clamp (-> *camera* outro-t)) (-> *camera* outro-curve)) + (vector-! gp-0 gp-0 s5-0) + (cond + ((or (and (< (-> *camera* outro-t-step) 0.0) (>= (-> *camera* outro-exit-value) (-> *camera* outro-t))) + (and (< 0.0 (-> *camera* outro-t-step)) (>= (-> *camera* outro-t) (-> *camera* outro-exit-value))) + ) + (set! (-> *camera* outro-t) (-> *camera* outro-exit-value)) + (set! (-> *camera* outro-t-step) 0.0) + (vector+! (-> self velocity) (-> self velocity) gp-0) + (send-event *camera* 'outro-done) + ) + (else + (vector+! (-> self trans) (-> self trans) gp-0) + ) + ) + ) + ) + (vector-float*! (-> self velocity) (-> self velocity) 0.9) + (vector+! (-> self trans) (-> self trans) (-> self velocity)) + ) + (suspend) + ) + #f + ) + ) + +;; failed to figure out what this is: +(defstate cam-endlessfall (camera-slave) + :event (behavior ((proc process) (argc int) (message symbol) (block event-message-block)) + (case message + (('teleport) + #f + ) + (else + (cam-standard-event-handler proc argc message block) + ) + ) + ) + :enter (behavior () + (when (not (-> self enter-has-run)) + (set! (-> self blend-from-type) (camera-blend-from-type unknown-2)) + (set! (-> self blend-to-type) (camera-blend-to-type unknown-2)) + ) + ) + :code (behavior () + (let ((gp-0 (new 'stack-no-clear 'cam-vector-seeker)) + (f30-0 (-> self velocity y)) + ) + (let ((a1-0 (new 'stack-no-clear 'vector)) + (s5-0 (new 'stack-no-clear 'vector)) + ) + (set! (-> a1-0 quad) (-> self trans quad)) + (set! (-> a1-0 y) 0.0) + (set! (-> s5-0 quad) (-> self velocity quad)) + (set! (-> s5-0 y) 0.0) + (init gp-0 a1-0 81.92 (fmax 819.2 (vector-length s5-0)) 0.75) + (set! (-> gp-0 vel quad) (-> s5-0 quad)) + ) + (until #f + (when (not (paused?)) + (set! (-> gp-0 target x) (-> (target-pos 0) x)) + (set! (-> gp-0 target z) (-> (target-pos 0) z)) + (update! gp-0 (the-as vector #f)) + (when (< 819.2 (-> gp-0 max-vel)) + (set! (-> gp-0 max-vel) (* 0.9 (-> gp-0 max-vel))) + (if (< (-> gp-0 max-vel) 819.2) + (set! (-> gp-0 max-vel) 819.2) + ) + ) + (set! f30-0 (* 0.9 f30-0)) + (+! (-> self trans y) f30-0) + (set! (-> self trans x) (-> gp-0 value x)) + (set! (-> self trans z) (-> gp-0 value z)) + ) + (suspend) + ) + ) + #f + ) + ) + +;; definition for function cam-circular-position-into-max-angle +;; INFO: Used lq/sq +(defbehavior cam-circular-position-into-max-angle camera-slave ((arg0 vector) (arg1 vector) (arg2 float)) + (let* ((f30-0 (vector-normalize-ret-len! arg0 1.0)) + (f26-0 (vector-normalize-ret-len! arg1 1.0)) + (f0-1 (vector-dot arg0 arg1)) + (f28-0 (acos f0-1)) + (s4-0 (new 'stack-no-clear 'matrix)) + ) + (when (not (logtest? (-> *camera* settings master-options) (cam-master-options IGNORE_ANALOG))) + (let ((f24-0 + (analog-input (the-as int (-> *cpad-list* cpads 0 rightx)) 128.0 32.0 110.0 (* 8192.0 (seconds-per-frame))) + ) + (f1-2 + (analog-input (the-as int (-> *cpad-list* cpads 0 righty)) 128.0 32.0 110.0 (* 8192.0 (seconds-per-frame))) + ) + (s2-0 (new 'stack-no-clear 'matrix)) + ) + (set! (-> s2-0 rvec quad) (the-as uint128 0)) + (set! (-> s2-0 uvec quad) (the-as uint128 0)) + (set! (-> s2-0 fvec quad) (the-as uint128 0)) + (set! (-> s2-0 trans quad) (the-as uint128 0)) + (let ((v1-15 (new 'stack-no-clear 'vector))) + 0.0 + (if (-> *camera* settings flip-horizontal) + (set! f24-0 (- f24-0)) + ) + (if (-> *camera* settings flip-vertical) + (set! f1-2 (- f1-2)) + ) + (when (< (-> self max-angle-offset) 1820.4445) + (set! f24-0 0.0) + (set! f1-2 0.0) + ) + (if (< (-> self pivot-rad) f30-0) + (set! f24-0 (- f24-0)) + ) + (vector-cross! v1-15 arg1 arg0) + (let ((f0-10 (vector-dot v1-15 (-> *camera* local-down)))) + (if (< f1-2 0.0) + (set! f1-2 (fmax f1-2 (* -0.15 f28-0))) + ) + (if (< f0-10 0.0) + (set! f1-2 (- f1-2)) + ) + (let* ((f1-3 (+ f24-0 f1-2)) + (f1-5 (fmin (* 8192.0 (seconds-per-frame)) (fmax (* -8192.0 (seconds-per-frame)) f1-3))) + ) + (cond + ((and (< 0.0 f1-5) (< 0.0 f0-10) (< (-> self max-angle-curr) f28-0)) + (set! f1-5 0.0) + ) + ((and (< 0.0 f1-5) (< 0.0 f0-10)) + (set! f1-5 (fmin f1-5 (* 0.15 (- (-> self max-angle-curr) f28-0)))) + ) + ((and (< f1-5 0.0) (< f0-10 0.0) (< (-> self max-angle-curr) f28-0)) + (set! f1-5 0.0) + ) + ((and (< f1-5 0.0) (< f0-10 0.0)) + (set! f1-5 (fmax f1-5 (* 0.15 (- f28-0 (-> self max-angle-curr))))) + ) + ) + (matrix-axis-angle! s2-0 (-> *camera* local-down) f1-5) + ) + ) + ) + (vector-matrix*! arg1 arg1 s2-0) + ) + (let ((f0-16 (vector-dot arg0 arg1))) + (set! f28-0 (acos f0-16)) + ) + ) + (cond + ((< (-> self max-angle-curr) f28-0) + (matrix-from-two-vectors-max-angle! + s4-0 + arg1 + arg0 + (* (fmin 1.0 (* arg2 (-> self clock time-adjust-ratio))) (- f28-0 (-> self max-angle-curr))) + ) + (vector-matrix*! arg0 arg1 s4-0) + ) + ((and (logtest? (-> self options) (cam-slave-options-u32 SAME_SIDE)) + (or (and (>= f26-0 (+ -8192.0 f30-0)) (>= f30-0 (+ -8192.0 (-> self pivot-rad)))) + (and (>= (+ 8192.0 f30-0) f26-0) (>= (+ 8192.0 (-> self pivot-rad)) f30-0)) + ) + ) + (let ((s2-1 (new 'stack-no-clear 'vector))) + (vector-cross! s2-1 arg1 arg0) + (vector-normalize! s2-1 1.0) + (matrix-axis-angle! + s4-0 + s2-1 + (* (fmin 1.0 (* arg2 (-> self clock time-adjust-ratio))) (- (-> self max-angle-curr) f28-0)) + ) + ) + (vector-matrix*! arg0 arg1 s4-0) + ) + (else + (set! (-> arg0 quad) (-> arg1 quad)) + (if (logtest? (-> self options) (cam-slave-options-u32 SHRINK_MAX_ANGLE)) + (set! (-> self max-angle-curr) f28-0) + ) + ) + ) + ) + (vector-normalize! arg0 (-> self pivot-rad)) + ) + +;; definition for function cam-circular-position +(defbehavior cam-circular-position camera-slave ((arg0 symbol)) + (let ((gp-0 (new 'stack-no-clear 'vector))) + (let ((s5-0 (new 'stack-no-clear 'vector))) + (if (logtest? (-> self options) (cam-slave-options-u32 SAME_SIDE DRAG)) + (vector-! gp-0 (-> self circular-follow) (-> self pivot-pt)) + (vector-! gp-0 (-> self pivot-pt) (-> self circular-follow)) + ) + (vector-! s5-0 (-> self trans) (-> self pivot-pt)) + (when (not (logtest? (-> self options) (cam-slave-options-u32 MOVE_SPHERICAL))) + (vector-flatten! gp-0 gp-0 (-> *camera* local-down)) + (vector-flatten! s5-0 s5-0 (-> *camera* local-down)) + ) + (cond + ((and (logtest? (-> self options) (cam-slave-options-u32 SAME_SIDE)) + (logtest? (-> self options) (cam-slave-options-u32 DRAG)) + (string= (-> *camera* settings real-entity-name) "camera-426") + ) + (let ((a0-8 (vector-normalize-copy! (new 'stack-no-clear 'vector) gp-0 (-> self pivot-rad)))) + (vector+! gp-0 gp-0 a0-8) + ) + ) + ((logtest? (-> self options) (cam-slave-options-u32 DRAG)) + (let ((f30-0 (- (vector-length gp-0) (-> self pivot-rad)))) + (when (< 0.0001 (-> *camera-combiner* tracking point-of-interest-blend value)) + (let ((s5-1 (new 'stack-no-clear 'vector)) + (s3-0 (new 'stack-no-clear 'vector)) + (s4-1 (new 'stack-no-clear 'vector)) + ) + 0.0 + 0.0 + 0.0 + (vector-! s5-1 (-> *camera-combiner* tracking looking-interesting) (-> self pivot-pt)) + (vector-normalize-copy! s3-0 gp-0 1.0) + (let ((f28-0 (vector-dot s5-1 s3-0))) + (vector-float*! s4-1 s3-0 f28-0) + (let ((f0-12 + (/ (* (vector-vector-distance s5-1 s4-1) (cos (-> *camera-combiner* fov))) (sin (-> *camera-combiner* fov))) + ) + ) + (set! f30-0 (fmin f30-0 (if (>= 16384.0 (-> *camera-combiner* fov)) + (- f28-0 f0-12) + (+ f28-0 f0-12) + ) + ) + ) + ) + ) + ) + ) + (if (>= 0.0 f30-0) + (vector-reset! gp-0) + (vector-normalize! gp-0 f30-0) + ) + ) + ) + ((not arg0) + (set! (-> self max-angle-curr) (-> self max-angle-offset)) + (cam-circular-position-into-max-angle gp-0 s5-0 1.0) + ) + (else + (cam-circular-position-into-max-angle gp-0 s5-0 0.05) + ) + ) + ) + (vector+! (-> self trans) gp-0 (-> self pivot-pt)) + ) + ) + +;; definition for function cam-circular-code +;; INFO: Used lq/sq +(defbehavior cam-circular-code camera-slave () + (set! (-> self pivot-pt quad) (-> self saved-pt quad)) + (cam-curve-pos (-> self pivot-pt) (the-as vector #f) (the-as curve #f) #f) + (let ((a2-1 (new-stack-vector0)) + (f0-0 182.04445) + ) + (if (logtest? (cam-slave-options RAPID_TRACKING) (-> *camera* settings slave-options)) + (set! f0-0 546.13336) + ) + (vector-! a2-1 (-> *camera* tpos-curr-adj) (-> self pivot-pt)) + (vector-! (-> self circular-follow) (-> self circular-follow) (-> self pivot-pt)) + (if (logtest? (-> self options) (cam-slave-options-u32 MOVE_SPHERICAL)) + (v-slrp3! + (-> self circular-follow) + (-> self circular-follow) + a2-1 + (the-as vector #f) + (* f0-0 (-> self clock time-adjust-ratio)) + ) + (v-slrp3! + (-> self circular-follow) + (-> self circular-follow) + a2-1 + (-> *camera* local-down) + (* f0-0 (-> self clock time-adjust-ratio)) + ) + ) + ) + (vector+! (-> self circular-follow) (-> self circular-follow) (-> self pivot-pt)) + (cam-circular-position #t) + (if (!= (-> self fov1) 0.0) + (set! (-> self fov) + (lerp-clamp + (-> self fov0) + (-> self fov1) + (parameter-ease-sin-clamp (cam-index-method-10 (-> self fov-index) (-> *camera* tpos-curr-adj))) + ) + ) + ) + ) + +;; failed to figure out what this is: +(defstate cam-circular (camera-slave) + :event (behavior ((proc process) (argc int) (message symbol) (block event-message-block)) + (case message + (('teleport) + #f + ) + (('outro-done) + (set! (-> self trans quad) (-> *camera-combiner* trans quad)) + (cam-circular-position #f) + ) + (else + (cam-standard-event-handler proc argc message block) + ) + ) + ) + :enter (behavior () + (cond + ((-> self enter-has-run) + ) + (else + (let ((gp-0 (new-stack-vector0))) + (set! (-> (new 'stack-no-clear 'vector) quad) (the-as uint128 0)) + (set! (-> self view-off-param) 1.0) + (set! (-> self circular-follow quad) (-> *camera* tpos-curr-adj quad)) + (set! (-> self max-angle-offset) 0.0) + (cond + ((-> self cam-entity) + (cam-slave-get-vector-with-offset (the-as entity-actor (-> self cam-entity)) (-> self saved-pt) 'pivot) + (cam-slave-get-vector-with-offset (the-as entity-actor (-> self cam-entity)) gp-0 'trans) + (set! (-> self pivot-rad) (vector-length (vector-! gp-0 gp-0 (-> self saved-pt)))) + (logior! (-> self options) (cam-slave-get-flags (-> self cam-entity) 'flags)) + (set! (-> self fov) (cam-slave-get-fov (-> self cam-entity))) + (set! (-> self tracking tilt-adjust target) + (cam-slave-get-float (-> self cam-entity) 'tiltAdjust (-> *CAMERA-bank* default-tilt-adjust)) + ) + (set! (-> self max-angle-offset) (cam-slave-get-float (-> self cam-entity) 'maxAngle 0.0)) + (if (< (-> self max-angle-offset) 0.0) + (set! (-> self max-angle-offset) 0.0) + ) + (set! (-> self fov1) (cam-slave-get-float (-> self cam-entity) 'focalpull 0.0)) + (cond + ((and (!= (-> self fov1) 0.0) + (cam-index-method-9 (-> self fov-index) 'focalpull (-> self cam-entity) (-> self saved-pt) (the-as curve #f)) + ) + (set! (-> self fov0) (-> self fov)) + (set! (-> self fov) (lerp-clamp + (-> self fov0) + (-> self fov1) + (cam-index-method-10 (-> self fov-index) (-> *camera* tpos-curr-adj)) + ) + ) + ) + (else + (set! (-> self fov1) 0.0) + ) + ) + (set! (-> self spline-follow-dist) (cam-slave-get-float (-> self cam-entity) 'spline-follow-dist 0.0)) + (cam-curve-setup (-> self saved-pt)) + (cond + ((< 0.0 (-> self spline-follow-dist)) + (let ((a0-17 (new 'stack-no-clear 'vector)) + (gp-3 (new 'stack-no-clear 'vector)) + ) + (curve-get-pos! a0-17 0.0 (-> self spline-curve)) + (curve-get-pos! gp-3 1.0 (-> self spline-curve)) + ) + (set! (-> self spline-tt) (curve-closest-point + (-> self spline-curve) + (-> self circular-follow) + 0.5 + -4096.0 + 10 + (-> self spline-follow-dist) + ) + ) + (curve-get-pos! (-> self pivot-pt) (-> self spline-tt) (-> self spline-curve)) + ) + (else + (set! (-> self spline-follow-dist) 0.0) + (set! (-> self pivot-pt quad) (-> self saved-pt quad)) + (cam-curve-pos (-> self pivot-pt) (the-as vector #f) (the-as curve #f) #f) + ) + ) + ) + ((logtest? (-> self options) (cam-slave-options-u32 DRAG)) + (vector-! (-> self pivot-pt) (-> *camera* tpos-curr-adj) (-> self trans)) + (vector-flatten! (-> self pivot-pt) (-> self pivot-pt) (-> *camera* local-down)) + (set! (-> self pivot-rad) (vector-length (-> self pivot-pt))) + (set! (-> self pivot-pt quad) (-> self trans quad)) + (set! (-> self saved-pt quad) (-> self pivot-pt quad)) + ) + (else + (vector-! (-> self pivot-pt) (-> *camera* tpos-curr-adj) (-> self trans)) + (vector-float*! (-> self pivot-pt) (-> self pivot-pt) 0.5) + (vector-flatten! (-> self pivot-pt) (-> self pivot-pt) (-> *camera* local-down)) + (set! (-> self pivot-rad) (vector-length (-> self pivot-pt))) + (vector+! (-> self pivot-pt) (-> self trans) (-> self pivot-pt)) + (set! (-> self saved-pt quad) (-> self pivot-pt quad)) + ) + ) + ) + (cam-circular-position #f) + (cond + ((logtest? (-> self options) (cam-slave-options-u32 NO_ROTATE)) + (set! (-> self blend-from-type) (camera-blend-from-type unknown-0)) + (set! (-> self blend-to-type) (camera-blend-to-type unknown-0)) + (cam-slave-get-rot (the-as entity-actor (-> self cam-entity)) (the-as matrix (-> self tracking))) + ) + (else + (set! (-> self blend-from-type) (camera-blend-from-type unknown-2)) + (set! (-> self blend-to-type) (camera-blend-to-type unknown-2)) + ) + ) + ) + ) + ) + :trans (behavior () + (if (not (logtest? (-> *camera* master-options) (cam-master-options-u32 HAVE_TARGET))) + (cam-slave-go cam-free-floating) + ) + ) + :code (behavior () + (until #f + (if (not (paused?)) + (cam-circular-code) + ) + (suspend) + ) + #f + ) + ) + +;; failed to figure out what this is: +(defstate cam-lookat (camera-slave) + :event cam-standard-event-handler + :enter (behavior () + (when (not (-> self enter-has-run)) + (set! (-> self blend-from-type) (camera-blend-from-type unknown-2)) + (set! (-> self blend-to-type) (camera-blend-to-type unknown-2)) + ) + ) + :trans (behavior () + (if (not (logtest? (-> *camera* master-options) (cam-master-options-u32 HAVE_TARGET))) + (cam-slave-go cam-free-floating) + ) + ) + :code (behavior () + (until #f + (suspend) + ) + #f + ) + ) + +;; definition of type cam-string-bank +(deftype cam-string-bank (basic) + ((los-coll-rad meters) + (los-coll-rad2 meters) + ) + ) + +;; definition for method 3 of type cam-string-bank +(defmethod inspect ((this cam-string-bank)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tlos-coll-rad: (meters ~m)~%" (-> this los-coll-rad)) + (format #t "~1Tlos-coll-rad2: (meters ~m)~%" (-> this los-coll-rad2)) + (label cfg-4) + this + ) + +;; definition for symbol *CAM_STRING-bank*, type cam-string-bank +(define *CAM_STRING-bank* (new 'static 'cam-string-bank :los-coll-rad (meters 1) :los-coll-rad2 (meters 0.5))) + +;; definition for function cam-string-find-position-rel! +;; INFO: Used lq/sq +;; WARN: new jak 2 until loop case, check carefully +(defun cam-string-find-position-rel! ((arg0 vector)) + (let ((s5-0 (new 'stack-no-clear 'vector)) + (s4-0 (new 'stack-no-clear 'vector)) + (s3-0 (new 'stack-no-clear 'collide-query)) + (f30-0 0.0) + (s2-0 (new 'stack-no-clear 'matrix)) + ) + (let ((s1-0 s3-0)) + (set! (-> s1-0 radius) 409.6) + (set! (-> s1-0 collide-with) (collide-spec backgnd obstacle hit-by-others-list camera-blocker pusher)) + (set! (-> s1-0 ignore-process0) #f) + (set! (-> s1-0 ignore-process1) #f) + (set! (-> s1-0 ignore-pat) (the-as pat-surface (camera-master-method-16 *camera* #f))) + (set! (-> s1-0 action-mask) (collide-action solid)) + ) + (vector-flatten! s5-0 (-> *camera-combiner* inv-camera-rot fvec) (-> *camera* local-down)) + (if (= (vector-normalize-ret-len! s5-0 (- (+ 1024.0 (-> *CAMERA-bank* default-string-min-z)))) 0.0) + (set! (-> s5-0 z) (+ 1024.0 (-> *CAMERA-bank* default-string-min-z))) + ) + (vector--float*! s5-0 s5-0 (-> *camera* local-down) (-> *CAMERA-bank* default-string-min-y)) + (set! (-> arg0 quad) (-> s5-0 quad)) + (until #f + (vector--float*! s4-0 arg0 (-> *camera* local-down) (-> *camera* settings target-height)) + (set! (-> s3-0 start-pos quad) (-> *camera* tpos-curr-adj quad)) + (set! (-> s3-0 move-dist quad) (-> arg0 quad)) + (if (< (fill-and-probe-using-line-sphere *collide-cache* s3-0) 0.0) + (return #t) + ) + (set! f30-0 (cond + ((>= -32768.0 f30-0) + (format #t "cam-string didn't find a spot~%") + (set! (-> arg0 quad) (-> s5-0 quad)) + (return #f) + f30-0 + ) + ((< 0.0 f30-0) + (- f30-0) + ) + (else + (- 5461.3335 f30-0) + ) + ) + ) + (matrix-axis-angle! s2-0 (-> *camera* local-down) f30-0) + (vector-matrix*! arg0 s5-0 s2-0) + ) + ) + #f + ) + +;; definition for function cam-string-set-position-rel! +;; INFO: Used lq/sq +;; WARN: Return type mismatch cam-slave-options-u32 vs cam-slave-options. +(defbehavior cam-string-set-position-rel! camera-slave ((arg0 vector)) + (vector-flatten! (-> self view-flat) arg0 (-> *camera* local-down)) + (set! (-> self min-z-override) (vector-length (-> self view-flat))) + (vector+! (-> self desired-pos) arg0 (-> *camera* tpos-curr-adj)) + (set! (-> self string-trans quad) (-> self desired-pos quad)) + (tracking-spline-method-10 (-> self position-spline) (-> self desired-pos)) + (vector-reset! (-> self velocity)) + (let ((v0-2 (logclear (-> self options) (cam-slave-options-u32 GOTO_GOOD_POINT)))) + (set! (-> self options) v0-2) + (the-as cam-slave-options v0-2) + ) + ) + +;; definition for function string-push-help +(defun string-push-help () + 409.6 + ) + +;; definition (debug) for function cam-draw-collide-cache +;; WARN: Return type mismatch int vs none. +(defun-debug cam-draw-collide-cache ((arg0 collide-cache)) + (let ((gp-0 (-> arg0 tris))) + (countdown (s5-0 (-> arg0 num-tris)) + (let ((t1-0 #x40000080)) + (add-debug-flat-triangle + #t + (bucket-id debug-no-zbuf1) + (the-as vector (-> gp-0 0)) + (-> gp-0 0 vertex 1) + (-> gp-0 0 vertex 2) + (the-as rgba t1-0) + ) + ) + (set! gp-0 (the-as (inline-array collide-cache-tri) (-> gp-0 1))) + ) + ) + 0 + (none) + ) + +;; definition of type los-dist +(deftype los-dist (structure) + ((par-dist float) + (lat-dist float) + (vert-dist float) + ) + ) + +;; definition for method 3 of type los-dist +(defmethod inspect ((this los-dist)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'los-dist) + (format #t "~1Tpar-dist: ~f~%" (-> this par-dist)) + (format #t "~1Tlat-dist: ~f~%" (-> this lat-dist)) + (format #t "~1Tvert-dist: ~f~%" (-> this vert-dist)) + (label cfg-4) + this + ) + +;; definition of type collide-los-dist-info +(deftype collide-los-dist-info (structure) + ((min-par float) + (max-par float) + (min-lat float) + (max-lat float) + (min-vp float) + (max-vp float) + (min-vn float) + (max-vn float) + (count int32) + ) + ) + +;; definition for method 3 of type collide-los-dist-info +(defmethod inspect ((this collide-los-dist-info)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'collide-los-dist-info) + (format #t "~1Tmin-par: ~f~%" (-> this min-par)) + (format #t "~1Tmax-par: ~f~%" (-> this max-par)) + (format #t "~1Tmin-lat: ~f~%" (-> this min-lat)) + (format #t "~1Tmax-lat: ~f~%" (-> this max-lat)) + (format #t "~1Tmin-vp: ~f~%" (-> this min-vp)) + (format #t "~1Tmax-vp: ~f~%" (-> this max-vp)) + (format #t "~1Tmin-vn: ~f~%" (-> this min-vn)) + (format #t "~1Tmax-vn: ~f~%" (-> this max-vn)) + (format #t "~1Tcount: ~D~%" (-> this count)) + (label cfg-4) + this + ) + +;; definition for function dist-info-init +;; WARN: Return type mismatch int vs none. +(defun dist-info-init ((arg0 collide-los-dist-info)) + (set! (-> arg0 min-par) 1.0) + (set! (-> arg0 max-par) 0.0) + (set! (-> arg0 count) 0) + 0 + (none) + ) + +;; definition for function dist-info-valid? +(defun dist-info-valid? ((arg0 collide-los-dist-info)) + (>= (-> arg0 max-par) (-> arg0 min-par)) + ) + +;; definition for function dist-info-append +;; WARN: Return type mismatch int vs none. +(defun dist-info-append ((arg0 collide-los-dist-info) (arg1 vector)) + (cond + ((dist-info-valid? arg0) + (if (< (-> arg1 x) (-> arg0 min-par)) + (set! (-> arg0 min-par) (-> arg1 x)) + ) + (if (< (-> arg0 max-par) (-> arg1 x)) + (set! (-> arg0 max-par) (-> arg1 x)) + ) + (if (< (-> arg1 y) (-> arg0 min-lat)) + (set! (-> arg0 min-lat) (-> arg1 y)) + ) + (if (< (-> arg0 max-lat) (-> arg1 y)) + (set! (-> arg0 max-lat) (-> arg1 y)) + ) + (cond + ((< (-> arg1 y) 0.0) + (if (< (-> arg1 z) (-> arg0 min-vn)) + (set! (-> arg0 min-vn) (-> arg1 z)) + ) + (if (< (-> arg0 max-vn) (-> arg1 z)) + (set! (-> arg0 max-vn) (-> arg1 z)) + ) + ) + (else + (if (< (-> arg1 z) (-> arg0 min-vp)) + (set! (-> arg0 min-vp) (-> arg1 z)) + ) + (if (< (-> arg0 max-vp) (-> arg1 z)) + (set! (-> arg0 max-vp) (-> arg1 z)) + ) + ) + ) + ) + (else + (set! (-> arg0 min-par) (-> arg1 x)) + (set! (-> arg0 max-par) (-> arg1 x)) + (set! (-> arg0 min-lat) (-> arg1 y)) + (set! (-> arg0 max-lat) (-> arg1 y)) + (set! (-> arg0 min-vp) 0.0) + (set! (-> arg0 max-vp) 0.0) + (set! (-> arg0 min-vn) 0.0) + (set! (-> arg0 max-vn) 0.0) + (cond + ((< (-> arg1 y) 0.0) + (set! (-> arg0 min-vn) (-> arg1 z)) + (set! (-> arg0 max-vn) (-> arg1 z)) + ) + (else + (set! (-> arg0 min-vp) (-> arg1 z)) + (set! (-> arg0 max-vp) (-> arg1 z)) + ) + ) + ) + ) + (+! (-> arg0 count) 1) + (none) + ) + +;; definition for function dist-info-print +(defun dist-info-print ((arg0 collide-los-dist-info) (arg1 string)) + (cond + ((dist-info-valid? arg0) + (format + *stdcon* + "~S ~2,D mn ~,,2M mx ~,,2M mnl ~,,2M mxl ~,,2M~%" + arg1 + (-> arg0 count) + (-> arg0 min-par) + (-> arg0 max-par) + (-> arg0 min-lat) + (-> arg0 max-lat) + ) + (format + *stdcon* + " mnvp ~,,2M mxvp ~,,2M mnvn ~,,2M mxvn ~,,2M~%" + (-> arg0 min-vp) + (-> arg0 max-vp) + (-> arg0 min-vn) + (-> arg0 max-vn) + ) + ) + (else + (format *stdcon* "~S invalid~%" arg1) + ) + ) + ) + +;; definition of type collide-los-result +(deftype collide-los-result (structure) + ((lateral vector :inline) + (cw collide-los-dist-info :inline) + (ccw collide-los-dist-info :inline) + (straddle collide-los-dist-info :inline) + (lateral-valid symbol) + ) + ) + +;; definition for method 3 of type collide-los-result +(defmethod inspect ((this collide-los-result)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'collide-los-result) + (format #t "~1Tlateral: ~`vector`P~%" (-> this lateral)) + (format #t "~1Tcw: #~%" (-> this cw)) + (format #t "~1Tccw: #~%" (-> this ccw)) + (format #t "~1Tstraddle: #~%" (-> this straddle)) + (format #t "~1Tlateral-valid: ~A~%" (-> this lateral-valid)) + (label cfg-4) + this + ) + +;; definition for function los-cw-ccw +;; INFO: Used lq/sq +;; WARN: Stack slot offset 128 signed mismatch +;; WARN: Stack slot offset 128 signed mismatch +;; WARN: Stack slot offset 128 signed mismatch +;; WARN: Stack slot offset 128 signed mismatch +;; WARN: Stack slot offset 128 signed mismatch +;; WARN: Stack slot offset 128 signed mismatch +;; WARN: Stack slot offset 128 signed mismatch +(defbehavior los-cw-ccw camera-slave ((arg0 (inline-array collide-cache-tri)) + (arg1 vector) + (arg2 vector) + (arg3 float) + (arg4 collide-los-result) + (arg5 vector) + (arg6 float) + ) + (local-vars (sv-128 float) (sv-144 vector) (sv-160 vector) (sv-176 vector) (sv-192 vector) (sv-208 int)) + (set! sv-128 arg3) + (let ((gp-0 arg4)) + (set! sv-144 arg5) + (let ((s4-0 arg6)) + (set! sv-160 (new 'stack-no-clear 'vector)) + (set! sv-176 (new 'stack-no-clear 'vector)) + (let ((s5-0 (new 'stack-no-clear 'inline-array 'vector 4))) + (set! sv-192 (new 'stack-no-clear 'vector)) + (let ((f30-0 0.0) + (s0-0 #f) + ) + (set! sv-208 0) + (while (< sv-208 4) + (cond + ((= sv-208 3) + (vector-! sv-160 sv-144 (-> self string-trans)) + (set! (-> s5-0 sv-208 z) 0.0) + ) + (else + (vector-! sv-160 sv-144 (-> arg0 0 vertex sv-208)) + (set! (-> s5-0 sv-208 z) (vector-dot sv-160 (-> *camera* local-down))) + (vector-! sv-160 (-> arg0 0 vertex sv-208) (-> self string-trans)) + ) + ) + (vector-flatten! sv-160 sv-160 (-> *camera* local-down)) + (vector-cross! sv-176 sv-160 arg2) + (let ((f28-0 (vector-dot sv-176 (-> *camera* local-down)))) + (cond + ((< (* f28-0 f30-0) 0.0) + (set! s0-0 #t) + ) + ((!= f28-0 0.0) + (set! f30-0 f28-0) + ) + ) + (set! (-> s5-0 sv-208 x) (vector-dot sv-160 arg2)) + (cond + ((= sv-208 3) + (vector-! sv-192 sv-144 (-> self string-trans)) + (vector-flatten! sv-192 sv-192 arg1) + ) + (else + (vector--float*! sv-192 sv-160 arg2 (-> s5-0 sv-208 x)) + ) + ) + (if (< f28-0 0.0) + (set! (-> s5-0 sv-208 y) (- (vector-length sv-192))) + (set! (-> s5-0 sv-208 y) (vector-length sv-192)) + ) + ) + (set! (-> s5-0 sv-208 x) (- sv-128 (-> s5-0 sv-208 x))) + (set! sv-208 (+ sv-208 1)) + ) + (cond + ((and s0-0 (!= (the-as int s4-0) -859915232)) + (dotimes (s4-1 4) + (dist-info-append (-> gp-0 straddle) (-> s5-0 s4-1)) + ) + #f + ) + ((< (-> s5-0 3 y) 0.0) + (dotimes (s4-2 4) + (when (>= (-> s5-0 3 y) (-> s5-0 s4-2 y)) + (set! (-> s5-0 s4-2 y) (- (-> s5-0 s4-2 y))) + (dist-info-append (-> gp-0 ccw) (-> s5-0 s4-2)) + ) + ) + #f + ) + (else + (dotimes (s4-3 4) + (if (>= (-> s5-0 s4-3 y) (-> s5-0 3 y)) + (dist-info-append (-> gp-0 cw) (-> s5-0 s4-3)) + ) + ) + #f + ) + ) + ) + ) + ) + ) + ) + +;; definition for function cam-los-spline-collide +;; INFO: Used lq/sq +(defun cam-los-spline-collide ((arg0 vector) (arg1 vector) (arg2 pat-surface)) + (let ((s5-0 (new 'stack-no-clear 'collide-query)) + (s4-0 *collide-cache*) + (f30-0 2.0) + ) + 0.0 + (set! (-> s5-0 start-pos quad) (-> arg0 quad)) + (vector-! (-> s5-0 move-dist) arg1 arg0) + (let ((v1-4 s5-0)) + (set! (-> v1-4 radius) (-> *CAM_STRING-bank* los-coll-rad2)) + (set! (-> v1-4 collide-with) (collide-spec backgnd obstacle hit-by-others-list camera-blocker pusher)) + (set! (-> v1-4 ignore-process0) #f) + (set! (-> v1-4 ignore-process1) #f) + (set! (-> v1-4 ignore-pat) arg2) + (set! (-> v1-4 action-mask) (collide-action solid)) + ) + (fill-using-line-sphere s4-0 s5-0) + (let* ((f0-2 (vector-length (-> s5-0 move-dist))) + (f28-0 + (cond + ((< f0-2 (-> *CAMERA-bank* min-detectable-velocity)) + 0.0 + ) + (else + (let* ((f0-3 (/ (* 3.0 (- (-> *CAM_STRING-bank* los-coll-rad2) (-> *CAMERA-bank* collide-move-rad))) f0-2)) + (f0-4 (- 1.0 f0-3)) + ) + (fmin 1.0 (fmax 0.0 f0-4)) + ) + ) + ) + ) + (s3-0 (the-as object (-> s4-0 tris))) + (s2-0 (new 'stack-no-clear 'vector)) + (s1-0 (new 'stack-no-clear 'vector)) + ) + (countdown (s4-1 (-> s4-0 num-tris)) + (let ((f0-7 (moving-sphere-triangle-intersect + arg0 + (-> s5-0 move-dist) + (-> *CAM_STRING-bank* los-coll-rad2) + (-> (the-as (inline-array collide-cache-tri) s3-0) 0) + s2-0 + s1-0 + ) + ) + ) + (cond + ((or (< f0-7 0.0) (< f28-0 f0-7)) + ) + ((< f0-7 f30-0) + (set! f30-0 f0-7) + ) + ) + ) + (set! s3-0 (-> (the-as (inline-array collide-cache-tri) s3-0) 1)) + ) + ) + (if (= (the-as int f30-0) #x40000000) + (set! f30-0 -1.0) + ) + f30-0 + ) + ) + +;; definition for function cam-los-setup-lateral +(defbehavior cam-los-setup-lateral camera-slave ((arg0 collide-los-result) (arg1 vector) (arg2 vector)) + (cond + ((dist-info-valid? (-> arg0 straddle)) + (let ((f30-0 (-> arg0 straddle min-lat)) + (f28-0 (-> arg0 straddle max-lat)) + ) + (if (dist-info-valid? (-> arg0 cw)) + (set! f28-0 (fmax f28-0 (-> arg0 cw max-lat))) + ) + (if (dist-info-valid? (-> arg0 ccw)) + (set! f30-0 (fmin f30-0 (- (-> arg0 ccw max-lat)))) + ) + (cond + ((= (-> self los-state) (slave-los-state ccw)) + (if *display-cam-los-debug* + (format *stdcon* "straddle stick ccw~%") + ) + (vector-normalize! arg1 (+ f28-0 (-> *CAM_STRING-bank* los-coll-rad))) + ) + ((= (-> self los-state) (slave-los-state cw)) + (if *display-cam-los-debug* + (format *stdcon* "straddle stick cw~%") + ) + (vector-normalize! arg1 (- f30-0 (-> *CAM_STRING-bank* los-coll-rad))) + ) + ((and (or (< 0.01 (-> arg0 straddle max-vp)) (and (dist-info-valid? (-> arg0 ccw)) (< 0.01 (-> arg0 ccw max-vp)))) + (or (< (-> arg0 straddle min-vp) -0.01) (and (dist-info-valid? (-> arg0 ccw)) (< (-> arg0 ccw min-vp) -0.01))) + (and (dist-info-valid? (-> arg0 cw)) (or (< (-> arg0 cw max-vp) 0.01) (< -0.01 (-> arg0 cw min-vp)))) + ) + (when (not (dist-info-valid? (-> arg0 ccw))) + ) + (if (not (dist-info-valid? (-> arg0 cw))) + (format #t "s diag ccw invalid cw~%") + ) + (if *display-cam-los-debug* + (format *stdcon* "straddle diagonal ccw~%") + ) + (set! (-> self los-state) (slave-los-state ccw)) + (vector-normalize! arg1 (+ f28-0 (-> *CAM_STRING-bank* los-coll-rad))) + ) + ((and (or (< 0.01 (-> arg0 straddle max-vn)) (and (dist-info-valid? (-> arg0 cw)) (< 0.01 (-> arg0 cw max-vp)))) + (or (< (-> arg0 straddle min-vn) -0.01) (and (dist-info-valid? (-> arg0 cw)) (< (-> arg0 cw min-vp) -0.01))) + (and (dist-info-valid? (-> arg0 ccw)) (or (< (-> arg0 ccw max-vp) 0.01) (< -0.01 (-> arg0 ccw min-vp)))) + ) + (if (not (dist-info-valid? (-> arg0 ccw))) + (format #t "s diag cw invalid ccw~%") + ) + (when (not (dist-info-valid? (-> arg0 cw))) + ) + (if *display-cam-los-debug* + (format *stdcon* "straddle diagonal cw~%") + ) + (set! (-> self los-state) (slave-los-state cw)) + (vector-normalize! arg1 (- f30-0 (-> *CAM_STRING-bank* los-coll-rad))) + ) + ((< f28-0 (- f30-0)) + (if *display-cam-los-debug* + (format *stdcon* "straddle ccw~%") + ) + (set! (-> self los-state) (slave-los-state ccw)) + (vector-normalize! arg1 (+ f28-0 (-> *CAM_STRING-bank* los-coll-rad))) + ) + (else + (if *display-cam-los-debug* + (format *stdcon* "straddle cw~%") + ) + (set! (-> self los-state) (slave-los-state cw)) + (vector-normalize! arg1 (- f30-0 (-> *CAM_STRING-bank* los-coll-rad))) + ) + ) + ) + ) + ((and (dist-info-valid? (-> arg0 cw)) + (dist-info-valid? (-> arg0 ccw)) + (< 0.01 (-> arg0 ccw max-vp)) + (< (-> arg0 ccw min-vp) -0.01) + (or (< (-> arg0 cw max-vp) 0.01) (< -0.01 (-> arg0 cw min-vp))) + ) + (if *display-cam-los-debug* + (format *stdcon* "diagonal ccw~%") + ) + (set! (-> self los-state) (slave-los-state ccw)) + (vector-normalize! arg1 (- (-> *CAM_STRING-bank* los-coll-rad) (-> arg0 ccw min-lat))) + ) + ((and (dist-info-valid? (-> arg0 cw)) + (dist-info-valid? (-> arg0 ccw)) + (< 0.01 (-> arg0 cw max-vp)) + (< (-> arg0 cw min-vp) -0.01) + (or (< (-> arg0 ccw max-vp) 0.01) (< -0.01 (-> arg0 ccw min-vp))) + ) + (if *display-cam-los-debug* + (format *stdcon* "diagonal cw~%") + ) + (set! (-> self los-state) (slave-los-state cw)) + (vector-normalize! arg1 (- (-> arg0 cw min-lat) (-> *CAM_STRING-bank* los-coll-rad))) + ) + ((and (dist-info-valid? (-> arg0 cw)) (dist-info-valid? (-> arg0 ccw))) + (set! (-> self los-state) (slave-los-state between)) + (vector-normalize! arg1 0.0001) + ) + ((dist-info-valid? (-> arg0 cw)) + (if *display-cam-los-debug* + (format *stdcon* "regular cw~%") + ) + (set! (-> self los-state) (slave-los-state cw)) + (vector-normalize! arg1 (- (-> arg0 cw min-lat) (-> *CAM_STRING-bank* los-coll-rad))) + ) + ((dist-info-valid? (-> arg0 ccw)) + (if *display-cam-los-debug* + (format *stdcon* "regular ccw~%") + ) + (set! (-> self los-state) (slave-los-state ccw)) + (vector-normalize! arg1 (- (-> *CAM_STRING-bank* los-coll-rad) (-> arg0 ccw min-lat))) + ) + (else + (set! (-> self los-state) (slave-los-state none)) + (vector-reset! arg1) + ) + ) + (cond + ((= (vector-length arg1) 0.0) + (set! (-> arg0 lateral-valid) #f) + #f + ) + (else + (vector-! (-> arg0 lateral) arg1 arg2) + (vector-normalize! (-> arg0 lateral) 1.0) + (let ((v0-44 #t)) + (set! (-> arg0 lateral-valid) v0-44) + v0-44 + ) + ) + ) + ) + +;; definition for function cam-los-collide +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs symbol. +;; ERROR: Unsupported inline assembly instruction kind - [mula.s f2, f5] +;; ERROR: Unsupported inline assembly instruction kind - [madda.s f3, f6] +;; ERROR: Unsupported inline assembly instruction kind - [madd.s f2, f4, f7] +(defbehavior cam-los-collide camera-slave ((arg0 vector) (arg1 vector) (arg2 collide-los-result) (arg3 pat-surface)) + (local-vars + (s1-3 int) + (s2-2 int) + (f2-1 float) + (sv-768 pat-surface) + (sv-784 vector) + (sv-800 vector) + (sv-816 tracking-point) + (sv-832 vector) + ) + (set! sv-768 arg3) + (dist-info-init (-> arg2 cw)) + (dist-info-init (-> arg2 ccw)) + (dist-info-init (-> arg2 straddle)) + (let ((s1-0 (new 'stack-no-clear 'collide-query)) + (s4-0 (new 'stack-no-clear 'vector)) + (s2-0 (new 'stack-no-clear 'vector)) + ) + (vector-normalize-copy! s2-0 arg1 1.0) + (vector-flatten! s4-0 arg1 (-> *camera* local-down)) + (let ((s0-0 *collide-cache*) + (f26-0 (vector-length arg1)) + (f30-0 (vector-normalize-ret-len! s4-0 1.0)) + ) + (set! (-> s1-0 start-pos quad) (-> arg0 quad)) + (set! (-> s1-0 move-dist quad) (-> arg1 quad)) + (let ((v1-5 s1-0)) + (set! (-> v1-5 radius) (-> *CAM_STRING-bank* los-coll-rad)) + (set! (-> v1-5 collide-with) (collide-spec backgnd obstacle hit-by-others-list camera-blocker pusher)) + (set! (-> v1-5 ignore-process0) #f) + (set! (-> v1-5 ignore-process1) #f) + (set! (-> v1-5 ignore-pat) sv-768) + (set! (-> v1-5 action-mask) (collide-action solid)) + ) + (fill-using-line-sphere s0-0 s1-0) + (let ((s1-1 (the-as object (-> s0-0 tris))) + (f28-0 (/ 2048.0 f26-0)) + (f26-1 (/ (+ -8192.0 f26-0) f26-0)) + ) + (if (< f26-1 0.0) + (set! f26-1 0.0) + ) + (if (< 1.0 f28-0) + (set! f28-0 1.0) + ) + (countdown (s0-1 (-> s0-0 num-tris)) + (set! sv-800 (new 'stack-no-clear 'vector)) + (set! sv-784 (new 'stack-no-clear 'vector)) + (let ((f0-7 (moving-sphere-triangle-intersect + arg0 + arg1 + (-> *CAM_STRING-bank* los-coll-rad) + (-> (the-as (inline-array collide-cache-tri) s1-1) 0) + sv-800 + sv-784 + ) + ) + ) + (cond + ((or (< f0-7 0.0) (< 1.0 f0-7)) + ) + ((let ((f1-2 0.0)) + (let* ((v1-23 arg1) + (f2-0 (-> v1-23 x)) + (f3-0 (-> v1-23 y)) + (f4-0 (-> v1-23 z)) + (f5-0 (-> sv-784 x)) + (f6-0 (-> sv-784 y)) + (f7-0 (-> sv-784 z)) + ) + (.mula.s f2-0 f5-0) + (.madda.s f3-0 f6-0) + (.madd.s f2-1 f4-0 f7-0) + ) + (< f1-2 f2-1) + ) + (when (< f28-0 f0-7) + (let* ((t1-1 (new 'stack-no-clear 'vector)) + (t0-1 (new 'stack-no-clear 'vector)) + (f24-0 (moving-sphere-triangle-intersect + arg0 + arg1 + (-> *CAM_STRING-bank* los-coll-rad2) + (-> (the-as (inline-array collide-cache-tri) s1-1) 0) + t0-1 + t1-1 + ) + ) + ) + (los-cw-ccw (the-as (inline-array collide-cache-tri) s1-1) s2-0 s4-0 f30-0 arg2 sv-800 f24-0) + (when *debug-segment* + (cond + ((= (the-as int f24-0) -859915232) + (let ((t9-10 cam-debug-add-los-tri) + (a0-20 s1-1) + (a2-6 (new 'static 'vector :x (the-as float #x80) :w (the-as float #x80))) + ) + (t9-10 (the-as (inline-array collide-cache-tri) a0-20) sv-800 a2-6) + ) + ) + (else + (cam-debug-add-los-tri + (the-as (inline-array collide-cache-tri) s1-1) + sv-800 + (new 'static 'vector :x (the-as float #x80) :y (the-as float #x80) :w (the-as float #x80)) + ) + ) + ) + ) + ) + ) + ) + ((< f0-7 f26-1) + (let* ((t1-3 (new 'stack-no-clear 'vector)) + (t0-3 (new 'stack-no-clear 'vector)) + (f24-1 (moving-sphere-triangle-intersect + arg0 + arg1 + (-> *CAM_STRING-bank* los-coll-rad2) + (-> (the-as (inline-array collide-cache-tri) s1-1) 0) + t0-3 + t1-3 + ) + ) + ) + (los-cw-ccw (the-as (inline-array collide-cache-tri) s1-1) s2-0 s4-0 f30-0 arg2 sv-800 f24-1) + (when *debug-segment* + (if (= (the-as int f24-1) -859915232) + (cam-debug-add-los-tri + (the-as (inline-array collide-cache-tri) s1-1) + sv-800 + (new 'static 'vector :y (the-as float #x80) :w (the-as float #x80)) + ) + (cam-debug-add-los-tri + (the-as (inline-array collide-cache-tri) s1-1) + sv-800 + (new 'static 'vector :z (the-as float #x80) :w (the-as float #x80)) + ) + ) + ) + ) + ) + ) + ) + (set! s1-1 (-> (the-as (inline-array collide-cache-tri) s1-1) 1)) + ) + ) + ) + ) + (let ((s4-1 (new 'stack-no-clear 'vector))) + 0.0 + (vector-cross! s4-1 arg1 (-> *camera* local-down)) + (cond + ((!= (-> self los-tgt-spline-pt-incarnation) + (-> *camera* target-spline point (-> self los-tgt-spline-pt) incarnation) + ) + (when *display-cam-los-debug* + (format *stdcon* "emergency point jump~%") + (format 0 "emergency point jump~%") + ) + (set! (-> self los-tgt-spline-pt) (-> *camera* target-spline used-point)) + (set! (-> self los-tgt-spline-pt-incarnation) + (-> *camera* target-spline point (-> self los-tgt-spline-pt) incarnation) + ) + (logior! (-> self options) (cam-slave-options-u32 GOTO_GOOD_POINT)) + (set! (-> self good-point quad) + (-> *camera* target-spline point (-> *camera* target-spline used-point) position quad) + ) + (set! (-> self los-last-pos quad) (-> self good-point quad)) + (when *debug-segment* + (let ((a1-22 (new 'stack-no-clear 'vector))) + (vector-! a1-22 (-> self good-point) (-> self string-trans)) + (cam-collision-record-save (-> self string-trans) a1-22 -3 'jump self) + ) + ) + (set! (-> self desired-pos quad) (-> self good-point quad)) + (set! (-> self string-trans quad) (-> self good-point quad)) + (vector-! (-> self view-flat) (-> self string-trans) (-> *camera* tpos-curr-adj)) + (vector-flatten! (-> self view-flat) (-> self view-flat) (-> *camera* local-down)) + (vector-reset! (-> self velocity)) + (let ((f0-11 (vector-length (-> self view-flat)))) + (if (< f0-11 (-> self min-z-override)) + (set! (-> self min-z-override) f0-11) + ) + ) + ) + (else + (let ((f30-1 + (cam-los-spline-collide + (the-as vector (+ (the-as uint (-> *camera* target-spline)) (* 48 (-> *camera* target-spline end-point)))) + arg0 + (the-as pat-surface (camera-master-method-16 *camera* #t)) + ) + ) + ) + (cond + ((< f30-1 0.0) + (if *display-cam-los-debug* + (format *stdcon* "good ~f~%" f30-1) + ) + (set! (-> self los-tgt-spline-pt) (-> *camera* target-spline end-point)) + (set! (-> self los-tgt-spline-pt-incarnation) + (-> *camera* target-spline point (-> self los-tgt-spline-pt) incarnation) + ) + (set! (-> self los-last-pos quad) (-> arg0 quad)) + ) + ((begin + (if *display-cam-los-debug* + (format + *stdcon* + "looking vel ~M u ~f pt ~D" + (vector-length (-> self velocity)) + f30-1 + (-> self los-tgt-spline-pt) + ) + ) + (set! s2-2 (-> self los-tgt-spline-pt)) + (set! s1-3 -134250495) + (while (and (!= s2-2 -134250495) + (begin + (let ((s0-3 cam-los-spline-collide)) + (set! sv-816 (-> (the-as (inline-array tracking-spline) (-> *camera* target-spline)) 0 point s2-2)) + (set! sv-832 arg0) + (let ((a2-21 (camera-master-method-16 *camera* #t))) + (set! f30-1 (s0-3 (the-as vector sv-816) sv-832 (the-as pat-surface a2-21))) + ) + ) + (< f30-1 0.0) + ) + ) + (set! s1-3 s2-2) + (set! s2-2 (-> *camera* target-spline point s2-2 next)) + ) + (and (= s2-2 (-> *camera* target-spline used-point)) + (!= (-> *camera* target-spline point s2-2 next) -134250495) + ) + ) + (when *display-cam-los-debug* + (format 0 "looking at used point~%") + (format *stdcon* " at used point~%") + ) + (set! (-> self los-tgt-spline-pt) (-> *camera* target-spline point s2-2 next)) + (set! (-> self los-tgt-spline-pt-incarnation) + (-> *camera* target-spline point (-> self los-tgt-spline-pt) incarnation) + ) + (logior! (-> self options) (cam-slave-options-u32 GOTO_GOOD_POINT)) + (set! (-> self good-point quad) (-> *camera* target-spline point s2-2 position quad)) + (set! (-> self los-last-pos quad) (-> self good-point quad)) + (when *debug-segment* + (let ((a1-40 (new 'stack-no-clear 'vector))) + (vector-! a1-40 (-> self good-point) (-> self string-trans)) + (cam-collision-record-save (-> self string-trans) a1-40 -3 'jump self) + ) + ) + (set! (-> self desired-pos quad) (-> self good-point quad)) + (set! (-> self string-trans quad) (-> self good-point quad)) + (vector-! (-> self view-flat) (-> self string-trans) (-> *camera* tpos-curr-adj)) + (vector-flatten! (-> self view-flat) (-> self view-flat) (-> *camera* local-down)) + (vector-reset! (-> self velocity)) + (let ((f0-14 (vector-length (-> self view-flat)))) + (if (< f0-14 (-> self min-z-override)) + (set! (-> self min-z-override) f0-14) + ) + ) + ) + ((!= s1-3 -134250495) + (if *display-cam-los-debug* + (format *stdcon* " ok~%") + ) + (set! (-> self los-tgt-spline-pt) s1-3) + (set! (-> self los-tgt-spline-pt-incarnation) + (-> *camera* target-spline point (-> self los-tgt-spline-pt) incarnation) + ) + (set! (-> self los-last-pos quad) (-> arg0 quad)) + ) + (else + (if *display-cam-los-debug* + (format *stdcon* "~%failed u ~f cur ~D seen ~D tgt-pt ~D~%" f30-1 s2-2 s1-3 (-> self los-tgt-spline-pt)) + ) + (let ((s3-1 (new 'stack-no-clear 'vector))) + 0.0 + (vector-! + s3-1 + (-> self los-last-pos) + (the-as vector (+ (the-as uint (-> *camera* target-spline)) (* 48 (-> self los-tgt-spline-pt)))) + ) + (let ((f28-1 (vector-length s3-1))) + (if (= f28-1 0.0) + (set! f28-1 0.4096) + ) + (let ((f30-2 (cond + ((and (= (-> self string-vel-dir) 6) + (< (-> *CAMERA-bank* min-detectable-velocity) (vector-length (-> self velocity))) + ) + (fmin 1.0 (+ 0.001 f30-1)) + ) + ((= (-> self string-vel-dir) 6) + (fmin 0.9999 f30-1) + ) + (else + (fmax 0.001 (+ -0.001 f30-1)) + ) + ) + ) + ) + (let ((s2-3 (new 'stack-no-clear 'vector))) + (vector-! + s2-3 + (-> *camera* tpos-curr-adj) + (the-as vector (+ (the-as uint (-> *camera* target-spline)) (* 48 (-> self los-tgt-spline-pt)))) + ) + (vector-flatten! s2-3 s2-3 (-> *camera* local-down)) + (cond + ((and (< (fabs (- (-> self desired-pos y) (-> self trans y))) 8192.0) + (< f28-1 (+ 1024.0 (-> self string-min-val z))) + (< (vector-length s2-3) 8192.0) + ) + (set! f30-2 0.0) + ) + ((< f28-1 (+ 1024.0 (-> self string-min-val z))) + ) + ((< (* f28-1 f30-2) (-> self string-min-val z)) + (set! f30-2 (/ (-> self string-min-val z) f28-1)) + ) + ) + ) + (when (< 0.0 f30-2) + (vector-! s3-1 (-> *camera* tpos-curr) (-> *camera* tpos-old)) + (vector-! + (-> self good-point) + (-> self los-last-pos) + (the-as vector (+ (the-as uint (-> *camera* target-spline)) (* 48 (-> self los-tgt-spline-pt)))) + ) + (vector-float*! (-> self good-point) (-> self good-point) f30-2) + (vector+! + (-> self good-point) + (-> self good-point) + (the-as vector (+ (the-as uint (-> *camera* target-spline)) (* 48 (-> self los-tgt-spline-pt)))) + ) + (set! (-> self los-last-pos quad) (-> self good-point quad)) + (when *display-cam-los-debug* + (format 0 "going because u(~f) > 0 frame ~D~%" f30-2 (current-time)) + (format *stdcon* " going because u(~f) > 0 frame ~D~%" f30-2 (current-time)) + ) + (logior! (-> self options) (cam-slave-options-u32 GOTO_GOOD_POINT)) + ) + ) + ) + ) + ) + ) + ) + ) + ) + (if *display-cam-los-debug* + (format + *stdcon* + "los-last ~M ~M ~M~%" + (-> self los-last-pos x) + (-> self los-last-pos y) + (-> self los-last-pos z) + ) + ) + (cam-los-setup-lateral arg2 s4-1 arg1) + ) + (cond + ((not (logtest? (-> self options) (cam-slave-options-u32 MOVEMENT_BLOCKED))) + ) + ((= (-> self string-vel-dir) 5) + ) + ((and (= (-> self string-vel-dir) 2) (= (-> self los-state) (slave-los-state cw))) + ) + ((and (= (-> self string-vel-dir) 1) (= (-> self los-state) (slave-los-state ccw))) + ) + ) + (when *display-cam-los-debug* + (format *stdcon* "state ~S" (slave-los-state->string (-> self los-state))) + (cond + ((zero? (-> self string-vel-dir)) + (format *stdcon* " vzero") + ) + ((= (-> self string-vel-dir) 2) + (format *stdcon* " vcw") + ) + ((= (-> self string-vel-dir) 1) + (format *stdcon* " vccw") + ) + ((= (-> self string-vel-dir) 3) + (format *stdcon* " up") + ) + ((= (-> self string-vel-dir) 4) + (format *stdcon* " down") + ) + ((= (-> self string-vel-dir) 6) + (format *stdcon* " long") + ) + ((= (-> self string-vel-dir) 5) + (format *stdcon* " short") + ) + ) + (format *stdcon* "~%") + ) + (when *display-cam-los-info* + (dist-info-print (-> arg2 cw) "cw ") + (dist-info-print (-> arg2 ccw) "ccw ") + (dist-info-print (-> arg2 straddle) "strdl") + ) + (the-as symbol 0) + ) + +;; definition for function cam-string-follow +;; INFO: Used lq/sq +(defbehavior cam-string-follow camera-slave () + (let ((f30-0 (vector-length (-> self view-flat)))) + (cond + ((logtest? (-> self options) (cam-slave-options-u32 STICKY_ANGLE)) + (let ((gp-0 (new 'stack-no-clear 'vector))) + (let ((s5-0 (new 'stack-no-clear 'vector))) + (vector-cross! s5-0 (-> self view-flat) (-> *camera* local-down)) + (vector-normalize! s5-0 1.0) + (vector-! gp-0 (-> *camera* tpos-curr-adj) (-> *camera* tpos-old-adj)) + (vector-flatten! gp-0 gp-0 s5-0) + ) + (if (< (vector-dot gp-0 (-> self view-flat)) 0.0) + (vector-! (-> self view-flat) (-> self view-flat) gp-0) + ) + ) + ) + (else + (let ((v1-10 (new 'stack-no-clear 'vector))) + (vector-! v1-10 (-> *camera* tpos-curr-adj) (-> *camera* tpos-old-adj)) + (vector-! (-> self view-flat) (-> self view-flat) v1-10) + ) + ) + ) + (vector-flatten! (-> self view-flat) (-> self view-flat) (-> *camera* local-down)) + (let* ((f28-0 (vector-length (-> self view-flat))) + (f0-3 (fmin (-> *camera* string-push-z) (-> self view-off z))) + (f26-0 (-> self view-off z)) + (f0-4 (fmin f0-3 (-> self min-z-override))) + ) + (when (logtest? (cam-slave-options WIDE_FOV) (-> *camera* settings slave-options)) + (let ((v1-18 (new-stack-vector0))) + 0.0 + (vector-! v1-18 (-> *camera* tpos-curr-adj) (-> *camera* tpos-old-adj)) + (let ((f0-6 (vector-length v1-18))) + (set! f0-4 (lerp-clamp 28672.0 32768.0 (parameter-ease-sin-clamp (* 0.00081380206 (+ -409.6 f0-6))))) + ) + ) + (set! f26-0 f0-4) + ) + (set! (-> self fov) (-> *camera* settings fov)) + (cond + ((< f28-0 f0-4) + (vector-normalize! (-> self view-flat) f0-4) + ) + ((and (< f30-0 f28-0) + (or (= (-> self los-state) (slave-los-state ccw)) (= (-> self los-state) (slave-los-state cw))) + ) + (vector-normalize! (-> self view-flat) f30-0) + ) + ((< f26-0 f28-0) + (vector-normalize! (-> self view-flat) f26-0) + (set! (-> self min-z-override) f26-0) + f26-0 + ) + (else + (set! (-> self min-z-override) f28-0) + f28-0 + ) + ) + ) + ) + ) + +;; definition for function cam-string-line-of-sight +(defbehavior cam-string-line-of-sight camera-slave () + (let ((gp-0 (new 'stack-no-clear 'collide-los-result)) + (s5-0 (new 'stack-no-clear 'vector)) + ) + (new 'stack-no-clear 'vector) + (let ((f30-0 (vector-length (-> self view-flat)))) + (vector--float*! s5-0 (-> *camera* tpos-curr) (-> *camera* local-down) (-> *camera* settings target-height)) + (vector-! s5-0 s5-0 (-> self string-trans)) + (let ((f0-1 (vector-length s5-0))) + (if (< 2048.0 f0-1) + (vector-float*! s5-0 s5-0 (/ (+ -2048.0 f0-1) f0-1)) + (vector-reset! s5-0) + ) + ) + (cam-los-collide (-> self string-trans) s5-0 gp-0 (the-as pat-surface (camera-master-method-16 *camera* #t))) + (when (-> gp-0 lateral-valid) + (when (or (= (-> self los-state) (slave-los-state ccw)) (= (-> self los-state) (slave-los-state cw))) + (let ((v1-21 (new 'stack-no-clear 'vector))) + (vector-! v1-21 (-> *camera* tpos-curr) (-> *camera* tpos-old)) + (if (and (< (-> self string-min-val z) f30-0) + (< (-> *CAMERA-bank* min-detectable-velocity) (vector-length v1-21)) + ) + (set! f30-0 (+ -204.8 f30-0)) + ) + ) + ) + (if (< f30-0 (fmin (-> self string-min-val z) (-> self min-z-override))) + (set! f30-0 (fmin (-> self string-min-val z) (-> self min-z-override))) + ) + (if (< f30-0 (-> self min-z-override)) + (set! (-> self min-z-override) f30-0) + ) + (let ((s4-1 (new 'stack-no-clear 'vector)) + (s5-1 (new 'stack-no-clear 'vector)) + (s3-1 (new 'stack-no-clear 'matrix)) + ) + 0.0 + (vector-flatten! s4-1 (-> gp-0 lateral) (-> *camera* local-down)) + (vector-normalize! s4-1 1.0) + (vector-normalize-copy! s5-1 (-> self view-flat) 1.0) + (let ((f0-14 (lerp-clamp + 418.7022 + 364.0889 + (/ (- f30-0 (-> self string-min-val z)) (- (-> self string-max-val z) (-> self string-min-val z))) + ) + ) + ) + (matrix-from-two-vectors-max-angle-partial! s3-1 s5-1 s4-1 f0-14 0.5) + ) + (vector-matrix*! (-> self view-flat) (-> self view-flat) s3-1) + ) + (vector-normalize! (-> self view-flat) f30-0) + ) + ) + ) + ) + +;; definition for function cam-dist-analog-input +(defun cam-dist-analog-input ((arg0 int) (arg1 float)) + (let ((f0-0 (the-as number 0.0))) + (cond + ((< arg0 28) + (set! f0-0 (- (fmin arg1 (* 0.083333336 (- 28.0 (the float arg0)) arg1)))) + ) + ((< 160 arg0) + (set! f0-0 (fmin arg1 (* 0.0125 (+ -160.0 (the float arg0)) arg1))) + ) + ) + (the-as float f0-0) + ) + ) + +;; definition for function cam-string-joystick +;; INFO: Used lq/sq +(defbehavior cam-string-joystick camera-slave () + (logclear! (-> self options) (cam-slave-options-u32 PLAYER_MOVING_CAMERA)) + (when (-> self string-relative) + (let ((s5-0 (new 'stack-no-clear 'vector)) + (gp-0 (new 'stack-no-clear 'vector)) + ) + 0.0 + (let ((f30-0 0.5)) + (new 'stack-no-clear 'vector) + (vector-flatten! s5-0 (-> self relative-position) (-> *camera* local-down)) + (let ((f0-4 + (acos (/ (vector-dot s5-0 (-> self view-flat)) (* (vector-length s5-0) (vector-length (-> self view-flat))))) + ) + ) + (if (< 1456.3556 (* f30-0 f0-4)) + (set! f30-0 (/ 1456.3556 f0-4)) + ) + ) + (vector-deg-slerp (-> self view-flat) (-> self view-flat) s5-0 f30-0) + (set! (-> gp-0 y) (- (vector-dot (-> self relative-position) (-> *camera* local-down)))) + (set! (-> gp-0 z) (vector-length s5-0)) + (set! (-> self view-off y) (lerp (-> self view-off y) (-> gp-0 y) f30-0)) + (set! (-> self view-off z) (lerp (-> self view-off z) (-> gp-0 z) f30-0)) + ) + ) + (vector-normalize! (-> self view-flat) (-> self view-off z)) + (set! (-> self string-min-val y) (-> self view-off y)) + (set! (-> self string-min-val z) (-> self view-off z)) + (set! (-> self string-max-val y) (-> self view-off y)) + (set! (-> self string-max-val z) (-> self view-off z)) + (return (the-as float #f)) + ) + (let ((f28-0 (cam-dist-analog-input (the-as int (-> *cpad-list* cpads 0 righty)) 0.05)) + (f0-22 (/ (- (vector-length (-> self view-flat)) (-> self string-min-val z)) + (- (-> self string-max-val z) (-> self string-min-val z)) + ) + ) + (f30-1 (-> self view-off-param)) + ) + (if (logtest? (cam-slave-options BOMBBOT) (-> *camera* settings slave-options)) + (set! f28-0 0.0) + ) + (if (or (logtest? (cam-slave-options-u32 BLOCK_RIGHT_STICK) (-> self options)) + (logtest? (-> *camera* settings master-options) (cam-master-options BLOCK_RIGHT_STICK)) + ) + (set! f28-0 0.0) + ) + (if (-> self have-phony-joystick) + (set! f28-0 (* 0.05 (-> self phony-joystick-y))) + ) + (if (and (-> *camera* being-attacked) (not (time-elapsed? (-> *camera* attack-start) (seconds 0.25)))) + (set! f28-0 0.05) + ) + (when (logtest? (cam-slave-options-u32 GUN_CAM) (-> self options)) + (if (and (or (< (-> *cpad-list* cpads 0 rightx) (the-as uint 64)) + (< (the-as uint 192) (-> *cpad-list* cpads 0 rightx)) + ) + (let ((v1-62 (abs (the-as int (+ (-> *cpad-list* cpads 0 righty) -128))))) + (< (the-as uint v1-62) (the-as uint 64)) + ) + ) + (set! f28-0 0.0) + ) + ) + (if (!= f28-0 0.0) + (logior! (-> self options) (cam-slave-options-u32 PLAYER_MOVING_CAMERA)) + ) + (let ((f26-0 (fmin 1.0 f0-22))) + (let ((f0-23 f26-0)) + (when (and (< f26-0 0.0) (not (logtest? (cam-slave-options BOMBBOT) (-> *camera* settings slave-options)))) + (let ((f0-26 + (/ (- (-> self string-min-val z) (vector-length (-> self view-flat))) (* 0.5 (-> self string-min-val z))) + ) + ) + (set! f0-23 (fmin 0.75 f0-26)) + ) + ) + (let ((f1-15 (-> self string-min-val y)) + (f2-5 (-> self string-max-val y)) + ) + (set! (-> self view-off y) (lerp f1-15 f2-5 f0-23)) + ) + ) + (when (< f26-0 0.0) + (let ((v1-80 (new 'stack-no-clear 'vector))) + (vector-! v1-80 (-> self string-trans) (-> *camera* tpos-curr-adj)) + (let ((f0-32 (- (- (vector-dot v1-80 (-> *camera* local-down))) (-> *camera* settings target-height)))) + (set! (-> self view-off y) + (fmin (-> *camera* settings string-cliff-height) (fmax f0-32 (-> self view-off y))) + ) + ) + ) + ) + (let ((f0-36 (fmax 0.0 f26-0))) + (cond + ((logtest? (-> *camera* settings slave-options) (cam-slave-options BIKE_MODE)) + ) + ((logtest? (-> *camera* settings master-options) (cam-master-options IGNORE_ANALOG)) + ) + ((and (>= 0.0 f28-0) (>= 0.0 f0-36)) + ) + ((and (>= f28-0 0.0) (>= f0-36 1.0)) + ) + ((and (< 0.0 f28-0) + (or (= (-> self los-state) (slave-los-state ccw)) (= (-> self los-state) (slave-los-state cw))) + ) + ) + ((and (logtest? (cam-slave-options-u32 GUN_CAM) (-> self options)) (< 0.0 f28-0)) + (set! (-> self string-min-val y) + (fmax (-> *camera* settings gun-min-height) (- (-> self string-min-val y) (* 24576.0 f28-0))) + ) + (set! (-> self string-max-val y) + (fmin + (+ 16384.0 (-> self string-min-val y)) + (fmax (+ 8192.0 (-> self string-min-val y)) (- (-> self string-max-val y) (* 24576.0 f28-0))) + ) + ) + ) + ((and (logtest? (cam-slave-options-u32 GUN_CAM) (-> self options)) (< f28-0 0.0)) + (set! (-> self string-max-val y) + (fmin (-> *camera* settings gun-max-height) (- (-> self string-max-val y) (* 24576.0 f28-0))) + ) + (set! (-> self string-min-val y) + (fmin + (+ -8192.0 (-> self string-max-val y)) + (fmax (+ -16384.0 (-> self string-max-val y)) (- (-> self string-min-val y) (* 24576.0 f28-0))) + ) + ) + ) + ((logtest? (cam-slave-options-u32 GUN_CAM) (-> self options)) + (set! (-> self string-max-val y) + (fmax + (+ 8192.0 (-> *camera* settings gun-min-height)) + (fmin (-> *camera* settings gun-max-height) (-> self string-max-val y)) + ) + ) + (set! (-> self string-min-val y) + (fmax + (-> *camera* settings gun-min-height) + (fmin (+ -8192.0 (-> *camera* settings gun-max-height)) (-> self string-min-val y)) + ) + ) + (set! (-> self string-min-val y) (fmax (+ -16384.0 (-> self string-max-val y)) (-> self string-min-val y))) + ) + ((< (* 0.05 (- 1.0 f0-36)) f28-0) + (let ((f0-55 (+ f0-36 (* 0.05 (- 1.0 f0-36))))) + (set! (-> self view-off-param) (fmax (-> self view-off-param) f0-55)) + (vector-normalize! (-> self view-flat) (lerp (-> self string-min-val z) (-> self string-max-val z) f0-55)) + ) + ) + ((< f28-0 (* 0.05 (- f0-36))) + (set! (-> self view-off-param) (+ f0-36 (* 0.05 (- f0-36)))) + ) + ((< 0.0 f28-0) + (let ((f0-57 (+ f0-36 (* f28-0 (-> self clock time-adjust-ratio))))) + (set! (-> self view-off-param) (fmax (-> self view-off-param) f0-57)) + (vector-normalize! (-> self view-flat) (lerp (-> self string-min-val z) (-> self string-max-val z) f0-57)) + ) + ) + ((< f28-0 0.0) + (set! (-> self view-off-param) (+ f0-36 (* f28-0 (-> self clock time-adjust-ratio)))) + ) + ) + ) + ) + (cond + ((logtest? (cam-slave-options-u32 GUN_CAM) (-> self options)) + ) + ((= f28-0 0.0) + (set! (-> self view-off z) (-> self string-max-val z)) + ) + (else + (set! (-> self view-off z) + (lerp (-> self string-min-val z) (-> self string-max-val z) (-> self view-off-param)) + ) + ) + ) + (if (-> *camera* being-attacked) + (set! (-> self view-off-param) f30-1) + ) + ) + (when (not (logtest? (-> *camera* settings master-options) (cam-master-options IGNORE_ANALOG))) + (let ((f30-2 (analog-input + (the-as int (-> *cpad-list* cpads 0 rightx)) + 128.0 + 32.0 + 110.0 + (* 182.04445 + (seconds-per-frame) + (cond + ((logtest? (cam-slave-options-u32 GUN_CAM) (-> self options)) + 120.0 + ) + ((logtest? (cam-slave-options BOMBBOT) (-> *camera* settings slave-options)) + 120.0 + ) + (else + 120.0 + ) + ) + ) + ) + ) + (s4-0 (new 'stack-no-clear 'matrix)) + ) + (set! (-> s4-0 rvec quad) (the-as uint128 0)) + (set! (-> s4-0 uvec quad) (the-as uint128 0)) + (set! (-> s4-0 fvec quad) (the-as uint128 0)) + (set! (-> s4-0 trans quad) (the-as uint128 0)) + (let ((gp-3 (new-stack-vector0)) + (s5-3 (new-stack-vector0)) + ) + (if (-> *camera* settings flip-horizontal) + (set! f30-2 (- f30-2)) + ) + (if (or (logtest? (cam-slave-options-u32 BLOCK_RIGHT_STICK) (-> self options)) + (logtest? (-> *camera* settings master-options) (cam-master-options BLOCK_RIGHT_STICK)) + ) + (set! f30-2 0.0) + ) + (if (-> *setting-control* user-default camera-stick-dir) + (set! f30-2 (- f30-2)) + ) + (if (-> self have-phony-joystick) + (set! f30-2 (* 21845.334 (-> self phony-joystick-x) (seconds-per-frame))) + ) + (when (or (logtest? (cam-slave-options-u32 ALLOW_SHIFT_BUTTONS) (-> self options)) + (logtest? (-> *camera* settings master-options) (cam-master-options USE_L1_R1)) + ) + (when (logtest? (-> *camera* settings master-options) (cam-master-options READ_BUTTONS)) + (if (cpad-hold? (-> *CAMERA-bank* joypad) r1) + (+! f30-2 (+ (* 10922.667 (seconds-per-frame)) + (analog-input + (the-as int (-> *cpad-list* cpads (-> *CAMERA-bank* joypad) abutton 9)) + 0.0 + 32.0 + 230.0 + (* 21845.334 (seconds-per-frame)) + ) + ) + ) + ) + ) + (when (logtest? (-> *camera* settings master-options) (cam-master-options READ_BUTTONS)) + (if (cpad-hold? (-> *CAMERA-bank* joypad) l1) + (set! f30-2 (- f30-2 (+ (* 10922.667 (seconds-per-frame)) + (analog-input + (the-as int (-> *cpad-list* cpads (-> *CAMERA-bank* joypad) abutton 8)) + 0.0 + 32.0 + 230.0 + (* 21845.334 (seconds-per-frame)) + ) + ) + ) + ) + ) + ) + ) + (cond + ((and (= (-> self los-state) (slave-los-state ccw)) (< 0.0 f30-2)) + (let ((f0-82 + (fmax (-> self string-min-val z) (fmin (-> self string-max-val z) (vector-length (-> self view-flat)))) + ) + ) + (set! f30-2 (* 21845.334 (+ 0.1 (/ (-> self string-min-val z) f0-82)) (seconds-per-frame))) + ) + ) + ((and (= (-> self los-state) (slave-los-state cw)) (< f30-2 0.0)) + (let ((f0-88 + (fmax (-> self string-min-val z) (fmin (-> self string-max-val z) (vector-length (-> self view-flat)))) + ) + ) + (set! f30-2 (* -21845.334 (+ 0.1 (/ (-> self string-min-val z) f0-88)) (seconds-per-frame))) + ) + ) + ) + (cond + ((!= f30-2 0.0) + (logior! (-> self options) (cam-slave-options-u32 PLAYER_MOVING_CAMERA)) + (matrix-axis-angle! s4-0 (-> *camera* local-down) f30-2) + (vector-matrix*! (-> self view-flat) (-> self view-flat) s4-0) + (set! (-> self butt-timer) 0) + (set! (-> self butt-seek) #f) + (when (logtest? (cam-slave-options-u32 HAVE_BUTT_HANDLE) (-> self options)) + (kill-persister *setting-control* (the-as engine-pers 'butt-handle) 'butt-handle) + (logclear! (-> self options) (cam-slave-options-u32 HAVE_BUTT_HANDLE)) + ) + ) + ((or (logtest? (-> self options) (cam-slave-options-u32 BUTT_CAM)) + (let ((s3-0 (handle->process (-> *camera* settings butt-handle)))) + (if (type? s3-0 process-drawable) + s3-0 + ) + ) + ) + (vector-normalize-copy! gp-3 (-> self view-flat) 1.0) + (let ((v1-303 (handle->process (-> *camera* settings butt-handle)))) + (cond + (v1-303 + (logior! (-> self options) (cam-slave-options-u32 HAVE_BUTT_HANDLE)) + (let* ((s3-1 (quaternion->matrix (new 'stack-no-clear 'matrix) (-> (the-as process-drawable v1-303) root quat))) + (a2-18 (matrix-axis-angle! + (new 'stack-no-clear 'matrix) + (-> s3-1 uvec) + (+ 32768.0 (-> *camera* settings butt-angle)) + ) + ) + ) + (vector-matrix*! s5-3 (-> s3-1 fvec) a2-18) + ) + (vector-flatten! s5-3 s5-3 (-> *camera* local-down)) + ) + ((< (- (current-time) (-> self butt-timer)) 0) + (vector-flatten! s5-3 (-> self butt-vector) (-> *camera* local-down)) + ) + (else + (vector-flatten! s5-3 (-> *camera* tgt-rot-mat fvec) (-> *camera* local-down)) + ) + ) + ) + (vector-normalize! s5-3 -1.0) + (when (and (logtest? (cam-slave-options-u32 HAVE_BUTT_HANDLE) (-> self options)) + (< (cos 910.2222) (vector-dot gp-3 s5-3)) + ) + (kill-persister *setting-control* (the-as engine-pers 'butt-handle) 'butt-handle) + (logclear! (-> self options) (cam-slave-options-u32 HAVE_BUTT_HANDLE)) + ) + (matrix-from-two-vectors-max-angle! s4-0 gp-3 s5-3 546.13336) + (vector-matrix*! (-> self view-flat) (-> self view-flat) s4-0) + ) + (else + (logclear! (-> self options) (cam-slave-options-u32 HAVE_BUTT_HANDLE)) + ) + ) + (when (logtest? (-> *camera* settings slave-options) (cam-slave-options BIKE_MODE)) + (vector-normalize-copy! gp-3 (-> self view-flat) 1.0) + (vector-flatten! s5-3 (-> *camera* tgt-rot-mat fvec) (-> *camera* local-down)) + (vector-normalize! s5-3 -1.0) + (let ((f0-97 (acos (vector-dot s5-3 gp-3)))) + (when (and (< (-> self max-angle-offset) f0-97) (< f0-97 32585.955)) + (matrix-from-two-vectors-max-angle! + s4-0 + gp-3 + s5-3 + (fmin 546.13336 (* 0.5 (- f0-97 (-> self max-angle-offset)))) + ) + (vector-matrix*! (-> self view-flat) (-> self view-flat) s4-0) + ) + ) + ) + ) + ) + ) + (when (not (logtest? (cam-slave-options WIDE_FOV) (-> *camera* settings slave-options))) + (let ((f0-101 (vector-length (-> self view-flat)))) + (let ((f1-89 (-> self view-off z))) + (when (< f1-89 f0-101) + (vector-float*! (-> self view-flat) (-> self view-flat) (/ f1-89 f0-101)) + (set! (-> self min-z-override) f1-89) + (set! f0-101 f1-89) + ) + ) + (if (and (< (-> self joystick-saved-view-off z) f0-101) + (and (< (-> self view-off y) (-> self joystick-saved-view-off y)) + (not (logtest? (cam-slave-options BOMBBOT) (-> *camera* settings slave-options))) + ) + ) + (set! (-> self view-off y) (fmin + (-> *camera* settings string-cliff-height) + (fmax (-> self string-min-val y) (-> self joystick-saved-view-off y)) + ) + ) + ) + (set! (-> self joystick-saved-view-off y) (-> self view-off y)) + (set! (-> self joystick-saved-view-off z) f0-101) + f0-101 + ) + ) + ) + +;; definition for function cam-string-find-hidden +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs none. +(defbehavior cam-string-find-hidden camera-slave () + (let ((s5-0 (new 'stack-no-clear 'collide-query)) + (gp-0 (new 'stack-no-clear 'vector)) + ) + (vector--float*! + (-> s5-0 move-dist) + (-> *camera* tpos-curr-adj) + (-> *camera* local-down) + (-> *camera* settings target-height) + ) + (vector-! (-> s5-0 move-dist) (-> s5-0 move-dist) (-> self string-trans)) + (set! (-> s5-0 start-pos quad) (-> self string-trans quad)) + (let ((s4-0 s5-0)) + (set! (-> s4-0 radius) 409.6) + (set! (-> s4-0 collide-with) (collide-spec backgnd obstacle hit-by-others-list camera-blocker pusher)) + (set! (-> s4-0 ignore-process0) #f) + (set! (-> s4-0 ignore-process1) #f) + (set! (-> s4-0 ignore-pat) (the-as pat-surface (camera-master-method-16 *camera* #f))) + (set! (-> s4-0 action-mask) (collide-action solid)) + ) + (cond + ((< (fill-and-probe-using-line-sphere *collide-cache* s5-0) 0.0) + (set! (-> self time-dist-too-far) (the-as uint 0)) + 0 + ) + ((< (-> self time-dist-too-far) (the-as uint 600)) + (+! (-> self time-dist-too-far) 1) + ) + ((cam-string-find-position-rel! gp-0) + (cam-string-set-position-rel! gp-0) + (set! (-> self time-dist-too-far) (the-as uint 0)) + 0 + ) + (else + (format 0 "camera position search failed~%") + (set! (-> self time-dist-too-far) (the-as uint 0)) + 0 + ) + ) + ) + (none) + ) + +;; definition for function cam-string-move +;; INFO: Used lq/sq +(defbehavior cam-string-move camera-slave () + (vector-! (-> self velocity) (-> self desired-pos) (-> self string-trans)) + (if *display-cam-los-debug* + (format *stdcon* "vel ~M~%" (vector-length (-> self velocity))) + ) + (let ((s5-0 (new 'stack-no-clear 'vector)) + (s4-0 (new 'stack-no-clear 'vector)) + (gp-0 (new 'stack-no-clear 'vector)) + (s3-0 (new 'stack-no-clear 'vector)) + ) + (vector-! s3-0 (-> *camera* tpos-curr-adj) (-> *camera* tpos-old-adj)) + (vector+float*! s5-0 (-> self velocity) s3-0 0.5) + (vector-normalize! s5-0 1.0) + (vector-normalize-copy! s4-0 (-> self view-flat) 1.0) + (vector-cross! gp-0 s4-0 s5-0) + (cond + ((and (< (vector-length (-> self velocity)) (-> *CAMERA-bank* min-detectable-velocity)) + (< (vector-length s3-0) (-> *CAMERA-bank* min-detectable-velocity)) + ) + (set! (-> self string-vel-dir) (the-as uint 0)) + 0 + ) + ((< (cos 5461.3335) (vector-dot (-> *camera* local-down) s5-0)) + (set! (-> self string-vel-dir) (the-as uint 4)) + ) + ((< (vector-dot (-> *camera* local-down) s5-0) (- (cos 5461.3335))) + (set! (-> self string-vel-dir) (the-as uint 3)) + ) + ((< (cos 5461.3335) (vector-dot s4-0 s5-0)) + (set! (-> self string-vel-dir) (the-as uint 6)) + ) + ((< (vector-dot s4-0 s5-0) (- (cos 5461.3335))) + (set! (-> self string-vel-dir) (the-as uint 5)) + ) + ((< (vector-dot (-> *camera* local-down) gp-0) 0.0) + (set! (-> self string-vel-dir) (the-as uint 1)) + ) + (else + (set! (-> self string-vel-dir) (the-as uint 2)) + ) + ) + ) + (let ((s5-1 (new 'stack-no-clear 'collide-query))) + 0.0 + (let ((f30-2 1.0) + (s4-1 (-> s5-1 move-dist)) + (gp-1 0) + ) + (let ((s3-1 (new 'stack-no-clear 'vector))) + (when *debug-segment* + (if (>= (-> *CAMERA-bank* min-detectable-velocity) (vector-length (-> self velocity))) + (cam-collision-record-save (-> self string-trans) (-> self velocity) -1 'no-hit self) + ) + ) + (while (and (< 0.01 f30-2) + (and (< (-> *CAMERA-bank* min-detectable-velocity) (vector-length (-> self velocity))) (< gp-1 4)) + ) + (vector-float*! s4-1 (-> self velocity) f30-2) + (if *debug-segment* + (cam-collision-record-save (-> self string-trans) s4-1 gp-1 'normal self) + ) + (let ((f28-0 + (cond + ((logtest? (-> self options) (cam-slave-options-u32 COLLIDE)) + (set! (-> s5-1 start-pos quad) (-> self string-trans quad)) + (let ((s2-0 s5-1)) + (set! (-> s2-0 radius) (-> *CAMERA-bank* collide-move-rad)) + (set! (-> s2-0 collide-with) (collide-spec backgnd obstacle hit-by-others-list camera-blocker pusher)) + (set! (-> s2-0 ignore-process0) #f) + (set! (-> s2-0 ignore-process1) #f) + (set! (-> s2-0 ignore-pat) (the-as pat-surface (camera-master-method-16 *camera* #f))) + (set! (-> s2-0 action-mask) (collide-action solid)) + ) + (fill-and-probe-using-line-sphere *collide-cache* s5-1) + ) + (else + -100000000.0 + ) + ) + ) + ) + (if *display-cam-los-debug* + (format *stdcon* "vp ~f vr ~f r ~f ta ~f~%" (vector-length s4-1) f30-2 (/ (vector-length s4-1) f30-2) f28-0) + ) + (cond + ((>= f28-0 0.0) + (let* ((f1-10 (fmax 0.01 (/ 40.96 (vector-length s4-1)))) + (f0-22 (fmax 0.0 (- f28-0 f1-10))) + ) + (vector+float*! (-> self string-trans) (-> self string-trans) s4-1 f0-22) + ) + (vector-! s3-1 (-> self string-trans) (-> s5-1 best-other-tri intersect)) + (vector-normalize! s3-1 1.0) + (vector-flatten! (-> self velocity) (-> self velocity) s3-1) + (set! f30-2 (- f30-2 (* f30-2 f28-0))) + (+! gp-1 1) + ) + (else + (vector+! (-> self string-trans) (-> self string-trans) s4-1) + (set! f30-2 0.0) + ) + ) + ) + ) + ) + (cond + ((zero? gp-1) + (logclear! (-> self options) (cam-slave-options-u32 MOVEMENT_BLOCKED)) + (if *display-cam-los-debug* + (format *stdcon* "not blocked~%") + ) + ) + (else + (logior! (-> self options) (cam-slave-options-u32 MOVEMENT_BLOCKED)) + (if *display-cam-los-debug* + (format *stdcon* "blocked ~D ~f~%" gp-1 f30-2) + ) + (let ((gp-2 (new-stack-vector0)) + (f30-3 (vector-length (-> self view-flat))) + ) + (vector-! gp-2 (-> self string-trans) (-> *camera* tpos-curr-adj)) + (vector-flatten! gp-2 gp-2 (-> *camera* local-down)) + (let ((f28-1 (vector-length gp-2))) + (cond + ((< f28-1 f30-3) + (vector-normalize-copy! (-> self view-flat) gp-2 f28-1) + (set! (-> self min-z-override) f28-1) + ) + (else + (vector-normalize-copy! (-> self view-flat) gp-2 f30-3) + ) + ) + ) + ) + ) + ) + ) + ) + (when *display-cam-los-debug* + (let ((v1-105 (new-stack-vector0))) + (vector-! v1-105 (-> self desired-pos) (-> self string-trans)) + (format *stdcon* "vel ~M~%" (vector-length v1-105)) + ) + ) + ) + +;; definition for function cam-string-code +;; INFO: Used lq/sq +;; WARN: Return type mismatch float vs object. +(defbehavior cam-string-code camera-slave () + (if *debug-segment* + (cam-debug-reset-coll-tri) + ) + (cam-string-follow) + (if (logtest? (-> self options) (cam-slave-options-u32 LINE_OF_SIGHT)) + (cam-string-line-of-sight) + ) + (if (not (paused?)) + (cam-string-joystick) + ) + (let ((gp-0 (new-stack-vector0))) + (vector--float*! + gp-0 + (-> self view-flat) + (-> *camera* local-down) + (+ (-> *camera* settings target-height) (-> self view-off y)) + ) + (vector+! (-> self desired-pos) (-> *camera* tpos-curr-adj) gp-0) + ) + (set! (-> self desired-pos y) (fmax + (fmin (-> self desired-pos y) (-> *camera* settings string-camera-ceiling)) + (-> *camera* settings string-camera-floor) + ) + ) + (if (logtest? (-> self options) (cam-slave-options-u32 FIND_HIDDEN_TARGET)) + (cam-string-find-hidden) + ) + (cond + ((logtest? (-> self options) (cam-slave-options-u32 GOTO_GOOD_POINT)) + (when *debug-segment* + (let ((a1-1 (new 'stack-no-clear 'vector))) + (vector-! a1-1 (-> self good-point) (-> self string-trans)) + (cam-collision-record-save (-> self string-trans) a1-1 -2 'jump self) + ) + ) + (logclear! (-> self options) (cam-slave-options-u32 GOTO_GOOD_POINT)) + (set! (-> self desired-pos quad) (-> self good-point quad)) + (cam-string-move) + (vector-! (-> self view-flat) (-> self string-trans) (-> *camera* tpos-curr-adj)) + (vector-flatten! (-> self view-flat) (-> self view-flat) (-> *camera* local-down)) + (let ((f0-5 (vector-length (-> self view-flat)))) + (if (< f0-5 (-> self min-z-override)) + (set! (-> self min-z-override) f0-5) + ) + ) + ) + (else + (cam-string-move) + ) + ) + (tracking-spline-method-17 (-> self position-spline) (-> self string-trans) 0.04096 4096.0 #t) + (let ((f30-0 (-> self clock clock-ratio))) + (let ((gp-2 (max 2 (the int (+ 0.5 (-> self clock time-adjust-ratio)))))) + (update-rates! (-> self clock) (/ f30-0 (the float gp-2))) + (while (nonzero? gp-2) + (+! gp-2 -1) + (cond + ((-> self butt-seek) + (tracking-spline-method-21 (-> self position-spline) (-> self trans) 163.84 8192.0 0.1 0.0 (the-as vector #f)) + (send-event *camera-combiner* 'fast-rot) + (if (< (-> self position-spline summed-len) 4096.0) + (set! (-> self butt-seek) #f) + ) + ) + ((logtest? (cam-slave-options RAPID_TRACKING) (-> *camera* settings slave-options)) + (tracking-spline-method-21 + (-> self position-spline) + (-> self trans) + 4096.0 + 40960.0 + 0.1 + 0.0 + (the-as vector #f) + ) + ) + ((and (logtest? (-> *camera* settings slave-options) (cam-slave-options BIKE_MODE)) + (logtest? (-> self options) (cam-slave-options-u32 PLAYER_MOVING_CAMERA)) + ) + (tracking-spline-method-21 (-> self position-spline) (-> self trans) 102.4 4096.0 0.1 0.0 (the-as vector #f)) + ) + ((logtest? (-> *camera* settings slave-options) (cam-slave-options BIKE_MODE)) + (tracking-spline-method-21 (-> self position-spline) (-> self trans) 40.96 4096.0 0.1 0.0 (the-as vector #f)) + ) + ((logtest? (-> self options) (cam-slave-options-u32 PLAYER_MOVING_CAMERA)) + (tracking-spline-method-21 + (-> self position-spline) + (-> self trans) + (-> *camera* settings string-spline-accel-player) + (-> *camera* settings string-spline-max-move-player) + 0.1 + 0.0 + (the-as vector #f) + ) + ) + (else + (tracking-spline-method-21 + (-> self position-spline) + (-> self trans) + (-> *camera* settings string-spline-accel) + (-> *camera* settings string-spline-max-move) + 0.1 + 0.0 + (the-as vector #f) + ) + ) + ) + ) + ) + (update-rates! (-> self clock) f30-0) + ) + ) + +;; definition for function set-string-params +;; INFO: Used lq/sq +;; WARN: Return type mismatch float vs vector. +(defbehavior set-string-params camera-slave () + (the-as + vector + (when (not (or (-> self string-val-locked) (logtest? (cam-slave-options-u32 GUN_CAM) (-> self options)))) + (set! (-> self string-min-val quad) (-> *camera* string-min value quad)) + (set! (-> self string-max-val quad) (-> *camera* string-max value quad)) + (set! (-> self slope-adjust target) 0.0) + (when (-> *camera* settings cam-slope) + (let ((gp-0 (the-as entity-camera (entity-by-name (-> *camera* settings cam-slope))))) + (when gp-0 + (set! (-> self slope-adjust target) (res-lump-float gp-0 'scale-factor :default 0.6)) + (quaternion-copy! (-> self slope-quat) (the-as quaternion (-> gp-0 connect))) + ) + ) + ) + (update! (-> self slope-adjust) 0.0) + (let ((f30-0 (- (-> self slope-adjust value)))) + (when (< f30-0 -0.001) + (let* ((gp-1 (vector-normalize-copy! (new 'stack-no-clear 'vector) (-> self view-flat) 1.0)) + (f0-6 + (* f30-0 (vector-dot (-> (quaternion->matrix (new 'stack-no-clear 'matrix) (-> self slope-quat)) uvec) gp-1)) + ) + ) + (+! (-> self string-min-val y) (* (-> self string-min-val z) f0-6)) + (set! (-> self string-max-val y) (+ (-> self string-max-val y) (* (-> self string-max-val z) f0-6))) + ) + ) + ) + ) + ) + ) + +;; failed to figure out what this is: +(defstate cam-string (camera-slave) + :event (behavior ((proc process) (argc int) (message symbol) (block event-message-block)) + (local-vars (v0-0 object)) + (case message + (('get-behind) + (set! (-> self butt-timer) (+ (current-time) (seconds 0.25))) + (set! (-> self butt-seek) (the-as basic #t)) + (set! v0-0 (-> self butt-vector)) + (set! (-> (the-as vector v0-0) quad) (-> (the-as vector (-> block param 0)) quad)) + v0-0 + ) + (('teleport) + (let ((gp-0 (new-stack-vector0))) + (cam-string-find-position-rel! gp-0) + (cam-string-set-position-rel! gp-0) + ) + ) + (('joystick) + (set! (-> self phony-joystick-x) (the-as float (-> block param 0))) + (set! (-> self phony-joystick-y) (the-as float (-> block param 1))) + (set! v0-0 #t) + (set! (-> self have-phony-joystick) (the-as basic v0-0)) + v0-0 + ) + (('tween-dist) + (cond + ((-> block param 0) + (set! (-> self string-val-locked) (the-as basic #t)) + (let ((s5-0 (the-as object (-> block param 0))) + (gp-1 (the-as object (-> block param 1))) + ) + (if (!= (-> (the-as vector s5-0) y) 4095996000.0) + (seek! + (-> self string-min-val y) + (-> (the-as vector s5-0) y) + (* (-> (the-as vector s5-0) w) (seconds-per-frame)) + ) + ) + (if (!= (-> (the-as vector s5-0) z) 4095996000.0) + (seek! + (-> self string-min-val z) + (-> (the-as vector s5-0) z) + (* (-> (the-as vector s5-0) w) (seconds-per-frame)) + ) + ) + (if (!= (-> (the-as vector gp-1) y) 4095996000.0) + (seek! + (-> self string-max-val y) + (-> (the-as vector gp-1) y) + (* (-> (the-as vector gp-1) w) (seconds-per-frame)) + ) + ) + (if (!= (-> (the-as vector gp-1) z) 4095996000.0) + (seek! + (-> self string-max-val z) + (-> (the-as vector gp-1) z) + (* (-> (the-as vector gp-1) w) (seconds-per-frame)) + ) + ) + ) + (set! (-> self string-max-val x) (fmax (-> self string-max-val x) (-> self string-min-val x))) + (set! (-> self string-max-val y) (fmax (-> self string-max-val y) (-> self string-min-val y))) + (set! (-> self string-max-val z) (fmax (-> self string-max-val z) (-> self string-min-val z))) + ) + (else + (set! (-> self string-val-locked) #f) + #f + ) + ) + ) + (('set-dist) + (cond + ((-> block param 0) + (set! (-> self string-val-locked) (the-as basic #t)) + (set! (-> self string-min-val quad) (-> (the-as vector (-> block param 0)) quad)) + (set! (-> self string-max-val quad) (-> (the-as vector (-> block param 1)) quad)) + (set! (-> self string-max-val x) (fmax (-> self string-max-val x) (-> self string-min-val x))) + (set! (-> self string-max-val y) (fmax (-> self string-max-val y) (-> self string-min-val y))) + (set! (-> self string-max-val z) (fmax (-> self string-max-val z) (-> self string-min-val z))) + ) + (else + (set! (-> self string-val-locked) #f) + #f + ) + ) + ) + (('relative-position) + (cond + ((-> block param 0) + (set! (-> self string-val-locked) (the-as basic #t)) + (set! (-> self string-relative) (the-as basic #t)) + (set! v0-0 (-> self relative-position)) + (set! (-> (the-as vector v0-0) quad) (-> (the-as vector (-> block param 0)) quad)) + v0-0 + ) + (else + (set! (-> self string-val-locked) #f) + (set! (-> self string-relative) #f) + #f + ) + ) + ) + (('set-max-angle-offset) + (set! (-> self max-angle-offset) (the-as float (-> block param 0))) + ) + (('blocked-side?) + (-> self los-state) + ) + (else + (cam-standard-event-handler proc argc message block) + ) + ) + ) + :enter (behavior () + (when (not (-> self enter-has-run)) + (if (-> self cam-entity) + (logior! (-> self options) (cam-slave-get-flags (-> self cam-entity) 'flags)) + ) + (vector-reset! (-> self joystick-saved-view-off)) + (set-string-params) + (set! (-> self string-vel-dir) (the-as uint 0)) + (set! (-> self fov) 11650.845) + (set! (-> self los-tgt-spline-pt) (-> *camera* target-spline end-point)) + (set! (-> self los-tgt-spline-pt-incarnation) + (-> *camera* target-spline point (-> self los-tgt-spline-pt) incarnation) + ) + (set! (-> self min-z-override) (-> self string-max-val z)) + (if (!= (-> *camera* outro-t-step) 0.0) + (set! (-> self min-z-override) (-> self string-min-val z)) + ) + (let ((gp-1 (new-stack-vector0))) + 0.0 + (set! (-> self view-off-param) (-> *camera* view-off-param-save)) + (set! (-> self view-off x) 0.0) + (let ((f0-7 (-> self string-min-val y)) + (f1-1 (-> self string-max-val y)) + ) + (set! (-> self view-off y) (lerp f0-7 f1-1 (-> self view-off-param))) + ) + (set! (-> self view-off z) + (lerp (-> self string-min-val z) (-> self string-max-val z) (-> self view-off-param)) + ) + (let ((f30-0 + (cond + ((!= (-> *camera* outro-t-step) 0.0) + (curve-get-pos! gp-1 (-> *camera* outro-exit-value) (-> *camera* outro-curve)) + (vector-! gp-1 gp-1 (-> *camera* tpos-curr-adj)) + (vector-flatten! (-> self view-flat) gp-1 (-> *camera* local-down)) + (vector-length (-> self view-flat)) + ) + ((-> *camera* settings use-string-startup-vector) + (vector-flatten! (-> self view-flat) (-> *camera* settings string-startup-vector) (-> *camera* local-down)) + (vector-length (-> self view-flat)) + ) + (else + (vector-flatten! (-> self view-flat) (-> self tracking inv-mat fvec) (-> *camera* local-down)) + (vector-negate! (-> self view-flat) (-> self view-flat)) + (-> self view-off z) + ) + ) + ) + ) + (let ((f1-4 (fmin (-> *camera* string-push-z) (-> self min-z-override))) + (f0-17 (-> self view-off z)) + ) + (cond + ((< f30-0 f1-4) + (set! f30-0 f1-4) + ) + ((< f0-17 f30-0) + (set! f30-0 f0-17) + ) + ) + ) + (vector-normalize! (-> self view-flat) f30-0) + (let ((f30-1 (/ (- f30-0 (-> self string-min-val z)) (- (-> self string-max-val z) (-> self string-min-val z))))) + (if (< 1.0 f30-1) + (set! f30-1 1.0) + ) + (if (< f30-1 0.0) + (set! f30-1 0.0) + ) + (let ((f0-22 (-> self string-min-val y)) + (f1-7 (-> self string-max-val y)) + ) + (set! (-> self view-off y) (lerp f0-22 f1-7 f30-1)) + ) + (set! (-> self view-off z) (lerp (-> self string-min-val z) (-> self string-max-val z) f30-1)) + ) + ) + ) + (vector--float*! + (-> self desired-pos) + (-> self view-flat) + (-> *camera* local-down) + (+ (-> *camera* settings target-height) (-> self view-off y)) + ) + (vector+! (-> self desired-pos) (-> self desired-pos) (-> *camera* tpos-curr-adj)) + (set! (-> self string-trans quad) (-> self desired-pos quad)) + (vector-reset! (-> self velocity)) + (let ((gp-2 (new 'stack-no-clear 'collide-query))) + (vector--float*! + (-> gp-2 start-pos) + (-> *camera* tpos-curr-adj) + (-> *camera* local-down) + (-> *camera* settings target-height) + ) + (vector-! (-> gp-2 move-dist) (-> self string-trans) (-> gp-2 start-pos)) + (let ((s5-0 gp-2)) + (set! (-> s5-0 radius) (-> *CAMERA-bank* collide-move-rad)) + (set! (-> s5-0 collide-with) (collide-spec backgnd obstacle hit-by-others-list camera-blocker pusher)) + (set! (-> s5-0 ignore-process0) #f) + (set! (-> s5-0 ignore-process1) #f) + (set! (-> s5-0 ignore-pat) (the-as pat-surface (camera-master-method-16 *camera* #f))) + (set! (-> s5-0 action-mask) (collide-action solid)) + ) + (let ((f0-31 (fill-and-probe-using-line-sphere *collide-cache* gp-2))) + (when (and (< 0.0 f0-31) (< f0-31 1.0)) + (vector-float*! (-> gp-2 move-dist) (-> gp-2 move-dist) f0-31) + (vector-flatten! (-> self view-flat) (-> gp-2 move-dist) (-> *camera* local-down)) + (let ((f0-32 (vector-length (-> self view-flat)))) + (cond + ((< f0-32 8192.0) + (let ((gp-3 (new-stack-vector0))) + (cam-string-find-position-rel! gp-3) + (cam-string-set-position-rel! gp-3) + ) + ) + (else + (if (< f0-32 (-> self min-z-override)) + (set! (-> self min-z-override) f0-32) + ) + (let ((f30-2 (/ (- f0-32 (-> self string-min-val z)) (- (-> self string-max-val z) (-> self string-min-val z))))) + (if (< 1.0 f30-2) + (set! f30-2 1.0) + ) + (if (< f30-2 0.0) + (set! f30-2 0.0) + ) + (let ((f0-36 (-> self string-min-val y)) + (f1-16 (-> self string-max-val y)) + ) + (set! (-> self view-off y) (lerp f0-36 f1-16 f30-2)) + ) + (set! (-> self view-off z) (lerp (-> self string-min-val z) (-> self string-max-val z) f30-2)) + ) + (vector--float*! + (-> self desired-pos) + (-> self view-flat) + (-> *camera* local-down) + (+ (-> *camera* settings target-height) (-> self view-off y)) + ) + (vector+! (-> self desired-pos) (-> self desired-pos) (-> *camera* tpos-curr-adj)) + (set! (-> self string-trans quad) (-> self desired-pos quad)) + (vector-reset! (-> self velocity)) + ) + ) + ) + ) + ) + ) + (set! (-> self trans quad) (-> self string-trans quad)) + (set! (-> self los-last-pos quad) (-> self string-trans quad)) + (tracking-spline-method-10 (-> self position-spline) (-> self string-trans)) + (set! (-> self blend-from-type) (camera-blend-from-type unknown-2)) + (set! (-> self blend-to-type) (camera-blend-to-type unknown-2)) + ) + ) + :trans (behavior () + (if (not (logtest? (-> *camera* master-options) (cam-master-options-u32 HAVE_TARGET))) + (cam-slave-go cam-free-floating) + ) + ) + :code (behavior () + (until #f + (when (not (paused?)) + (set-string-params) + (cam-string-code) + (tracking-spline-method-9 (-> self position-spline)) + (set! (-> self have-phony-joystick) #f) + ) + (suspend) + ) + #f + ) + ) + +;; definition of type cam-stick-bank +(deftype cam-stick-bank (basic) + ((max-z meters) + (min-z meters) + (max-y meters) + (min-y meters) + ) + ) + +;; definition for method 3 of type cam-stick-bank +(defmethod inspect ((this cam-stick-bank)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tmax-z: (meters ~m)~%" (-> this max-z)) + (format #t "~1Tmin-z: (meters ~m)~%" (-> this min-z)) + (format #t "~1Tmax-y: (meters ~m)~%" (-> this max-y)) + (format #t "~1Tmin-y: (meters ~m)~%" (-> this min-y)) + (label cfg-4) + this + ) + +;; definition for symbol *CAM_STICK-bank*, type cam-stick-bank +(define *CAM_STICK-bank* + (new 'static 'cam-stick-bank :max-z (meters 30) :min-z (meters 5) :max-y (meters 15) :min-y (meters 2)) + ) + +;; definition for function cam-stick-code +;; INFO: Used lq/sq +(defbehavior cam-stick-code camera-slave () + (cam-calc-follow! (-> self tracking) (-> self trans) #t) + (let ((gp-0 (new-stack-vector0))) + (vector-flatten! (-> self view-flat) (-> self view-flat) (-> *camera* local-down)) + (vector-normalize! (-> self view-flat) (-> self view-off z)) + (vector-! gp-0 (-> self view-flat) (vector-float*! gp-0 (-> *camera* local-down) (-> self view-off y))) + (vector+! (-> self desired-pos) (-> self tracking follow-pt) gp-0) + ) + (let ((v1-3 (new-stack-vector0)) + (gp-1 (new-stack-vector0)) + ) + (vector-! v1-3 (-> self desired-pos) (-> self trans)) + (vector-float*! v1-3 v1-3 0.2) + (vector-! gp-1 v1-3 (-> self velocity)) + (if (< 409.6 (vector-length gp-1)) + (vector-normalize! gp-1 409.6) + ) + (vector+! (-> self velocity) (-> self velocity) gp-1) + ) + (let ((gp-2 (new 'stack-no-clear 'collide-query))) + 0.0 + (let ((f30-0 1.0) + (s5-0 (-> gp-2 move-dist)) + (s4-0 (new-stack-vector0)) + (s3-0 4) + (s2-0 0) + ) + (while (and (< 0.01 f30-0) + (and (< (-> *CAMERA-bank* min-detectable-velocity) (vector-length (-> self velocity))) (> s3-0 0)) + ) + (+! s3-0 -1) + (vector-float*! s5-0 (-> self velocity) f30-0) + (let ((f28-0 + (cond + ((logtest? (-> self options) (cam-slave-options-u32 COLLIDE)) + (set! (-> gp-2 start-pos quad) (-> self trans quad)) + (let ((s1-0 gp-2)) + (set! (-> s1-0 radius) (-> *CAMERA-bank* collide-move-rad)) + (set! (-> s1-0 collide-with) (collide-spec backgnd obstacle hit-by-others-list camera-blocker pusher)) + (set! (-> s1-0 ignore-process0) #f) + (set! (-> s1-0 ignore-process1) #f) + (set! (-> s1-0 ignore-pat) (the-as pat-surface (camera-master-method-16 *camera* #f))) + (set! (-> s1-0 action-mask) (collide-action solid)) + ) + (fill-and-probe-using-line-sphere *collide-cache* gp-2) + ) + (else + -100000000.0 + ) + ) + ) + ) + (cond + ((>= f28-0 0.0) + (vector+float*! (-> self trans) (-> self trans) s5-0 f28-0) + (set! (-> s4-0 quad) (-> gp-2 best-other-tri normal quad)) + (vector-flatten! (-> self velocity) (-> self velocity) s4-0) + (set! f30-0 (- f30-0 (* f30-0 f28-0))) + (set! s2-0 1) + ) + (else + (vector+! (-> self trans) (-> self trans) s5-0) + (set! f30-0 0.0) + ) + ) + ) + ) + (when (nonzero? s2-0) + 0 + (let ((gp-3 (new-stack-vector0))) + 0.0 + (vector-! gp-3 (-> self trans) (-> self tracking follow-pt)) + (vector-flatten! gp-3 gp-3 (-> *camera* local-down)) + (let ((f0-15 (/ (- (vector-length gp-3) (-> *CAM_STICK-bank* min-z)) + (- (-> *CAM_STICK-bank* max-z) (-> *CAM_STICK-bank* min-z)) + ) + ) + ) + (cond + ((< f0-15 0.0) + (set! f0-15 0.0) + ) + ((< 1.0 f0-15) + (set! f0-15 1.0) + ) + ) + (cond + ((< (- f0-15 (-> self view-off-param)) -0.001) + (set! (-> self view-off-param) f0-15) + ) + ((< 0.001 (- f0-15 (-> self view-off-param))) + (vector-normalize-copy! (-> self view-flat) gp-3 (-> self view-off z)) + ) + ) + ) + ) + ) + ) + ) + (slave-set-rotation! (-> self tracking) (-> self trans) (-> self options) (-> self fov) #t) + (none) + ) + +;; failed to figure out what this is: +(defstate cam-stick (camera-slave) + :event cam-standard-event-handler + :enter (behavior () + (when (not (-> self enter-has-run)) + (set! (-> self view-off-param) (-> *camera* view-off-param-save)) + (set! (-> self view-off x) 0.0) + (set! (-> self view-off y) + (lerp (-> *CAM_STICK-bank* min-y) (-> *CAM_STICK-bank* max-y) (-> self view-off-param)) + ) + (set! (-> self view-off z) + (lerp (-> *CAM_STICK-bank* min-z) (-> *CAM_STICK-bank* max-z) (-> self view-off-param)) + ) + (cam-calc-follow! (-> self tracking) (-> self trans) #f) + (vector-flatten! (-> self view-flat) (-> self tracking inv-mat fvec) (-> *camera* local-down)) + (vector-negate! (-> self view-flat) (-> self view-flat)) + (vector-normalize! (-> self view-flat) (-> self view-off z)) + (vector--float*! (-> self desired-pos) (-> self view-flat) (-> *camera* local-down) (-> self view-off y)) + (vector+! (-> self desired-pos) (-> self desired-pos) (-> self tracking follow-pt)) + (set! (-> self trans quad) (-> self desired-pos quad)) + (vector-reset! (-> self velocity)) + (set! (-> self blend-from-type) (camera-blend-from-type unknown-2)) + (set! (-> self blend-to-type) (camera-blend-to-type unknown-2)) + (slave-set-rotation! (-> self tracking) (-> self trans) (-> self options) (-> self fov) #f) + ) + ) + :trans (behavior () + (if (not (logtest? (-> *camera* master-options) (cam-master-options-u32 HAVE_TARGET))) + (cam-slave-go cam-free-floating) + ) + (when (not (paused?)) + (when (not (logtest? (-> *camera* settings master-options) (cam-master-options IGNORE_ANALOG))) + (let ((f0-0 (analog-input (the-as int (-> *cpad-list* cpads 0 righty)) 128.0 32.0 110.0 0.05))) + (cond + ((< (* 0.05 (- 1.0 (-> self view-off-param))) f0-0) + (+! (-> self view-off-param) (* 0.05 (- 1.0 (-> self view-off-param)))) + ) + ((< f0-0 (* 0.05 (- (-> self view-off-param)))) + (+! (-> self view-off-param) (* 0.05 (- (-> self view-off-param)))) + ) + (else + (+! (-> self view-off-param) f0-0) + ) + ) + ) + ) + (set! (-> self view-off y) + (lerp (-> *CAM_STICK-bank* min-y) (-> *CAM_STICK-bank* max-y) (-> self view-off-param)) + ) + (set! (-> self view-off z) + (lerp (-> *CAM_STICK-bank* min-z) (-> *CAM_STICK-bank* max-z) (-> self view-off-param)) + ) + (when (not (logtest? (-> *camera* settings master-options) (cam-master-options IGNORE_ANALOG))) + (let ((f0-16 + (analog-input (the-as int (-> *cpad-list* cpads 0 rightx)) 128.0 32.0 110.0 (* 21845.334 (seconds-per-frame))) + ) + (gp-0 (new 'stack-no-clear 'matrix)) + ) + (set! (-> gp-0 rvec quad) (the-as uint128 0)) + (set! (-> gp-0 uvec quad) (the-as uint128 0)) + (set! (-> gp-0 fvec quad) (the-as uint128 0)) + (set! (-> gp-0 trans quad) (the-as uint128 0)) + (let ((s3-0 (new-stack-vector0)) + (s5-0 (new-stack-vector0)) + (s4-0 (new-stack-vector0)) + ) + (if (-> *camera* settings flip-horizontal) + (set! f0-16 (- f0-16)) + ) + (cond + ((!= f0-16 0.0) + (matrix-axis-angle! gp-0 (-> *camera* local-down) f0-16) + (vector-matrix*! (-> self view-flat) (-> self view-flat) gp-0) + ) + ((logtest? (-> self options) (cam-slave-options-u32 BUTT_CAM)) + (set-vector! s5-0 0.0 0.0 1.0 1.0) + (vector-normalize-copy! s5-0 (-> self view-flat) 1.0) + (set! (-> s3-0 quad) (-> *camera* tgt-rot-mat fvec quad)) + (vector-flatten! s3-0 s3-0 (-> *camera* local-down)) + (vector-negate! s3-0 s3-0) + (set! (-> s4-0 quad) (-> s5-0 quad)) + (vector-normalize-copy! s4-0 s3-0 1.0) + (matrix-from-two-vectors-max-angle-partial! gp-0 s5-0 s4-0 (* 10922.667 (seconds-per-frame)) 0.05) + (vector-matrix*! (-> self view-flat) (-> self view-flat) gp-0) + ) + ) + ) + ) + ) + ) + ) + :code (behavior () + (until #f + (if (not (paused?)) + (cam-stick-code) + ) + (suspend) + ) + #f + ) + ) + +;; definition of type cam-bike-bank +(deftype cam-bike-bank (basic) + ((min-z meters) + (max-z meters) + (min-y meters) + (max-y meters) + ) + ) + +;; definition for method 3 of type cam-bike-bank +(defmethod inspect ((this cam-bike-bank)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tmin-z: (meters ~m)~%" (-> this min-z)) + (format #t "~1Tmax-z: (meters ~m)~%" (-> this max-z)) + (format #t "~1Tmin-y: (meters ~m)~%" (-> this min-y)) + (format #t "~1Tmax-y: (meters ~m)~%" (-> this max-y)) + (label cfg-4) + this + ) + +;; definition for symbol *CAM_BIKE-bank*, type cam-bike-bank +(define *CAM_BIKE-bank* + (new 'static 'cam-bike-bank :min-z (meters 6) :max-z (meters 10) :min-y (meters 3) :max-y (meters 5)) + ) + +;; definition for function cam-calc-bike-follow! +(defbehavior cam-calc-bike-follow! camera-slave ((arg0 cam-rotation-tracker) (arg1 vector) (arg2 symbol)) + (vector-float*! (-> arg0 follow-off) (-> *camera* tgt-face-mat fvec) 155648.0) + (vector+! (-> arg0 follow-pt) (-> *camera* tpos-curr-adj) (-> arg0 follow-off)) + (vector--float*! + (-> arg0 follow-pt) + (-> arg0 follow-pt) + (-> *camera* local-down) + (+ 12288.0 (-> *camera* settings target-height)) + ) + (-> arg0 follow-pt) + ) + +;; definition for function cam-bike-code +;; INFO: Used lq/sq +(defbehavior cam-bike-code camera-slave () + (let ((s4-0 (new 'stack-no-clear 'matrix))) + (set! (-> s4-0 rvec quad) (the-as uint128 0)) + (set! (-> s4-0 uvec quad) (the-as uint128 0)) + (set! (-> s4-0 fvec quad) (the-as uint128 0)) + (set! (-> s4-0 trans quad) (the-as uint128 0)) + (let ((gp-0 (new-stack-vector0)) + (s5-0 (new-stack-vector0)) + ) + (vector-normalize-copy! gp-0 (-> self view-flat) 1.0) + (vector-flatten! s5-0 (-> *camera* tgt-rot-mat fvec) (-> *camera* local-down)) + (vector-normalize! s5-0 -1.0) + (matrix-from-two-vectors-partial-linear! s4-0 gp-0 s5-0 0.2) + ) + (vector-matrix*! (-> self view-flat) (-> self view-flat) s4-0) + ) + (let ((gp-1 (new-stack-vector0))) + 0.0 + (vector-! gp-1 (-> *camera* tpos-curr-adj) (-> *camera* tpos-old-adj)) + (let ((f30-0 (vector-length gp-1))) + (set! (-> self view-off z) (lerp-clamp + (-> *CAM_BIKE-bank* min-z) + (-> *CAM_BIKE-bank* max-z) + (parameter-ease-sin-clamp (* 0.00081380206 (+ -409.6 f30-0))) + ) + ) + (set! (-> self view-off y) (lerp-clamp + (-> *CAM_BIKE-bank* min-y) + (-> *CAM_BIKE-bank* max-y) + (parameter-ease-sin-clamp (* 0.00081380206 (+ -409.6 f30-0))) + ) + ) + ) + (vector-flatten! (-> self view-flat) (-> self view-flat) (-> *camera* local-down)) + (vector-normalize! (-> self view-flat) (-> self view-off z)) + (vector-! gp-1 (-> self view-flat) (vector-float*! gp-1 (-> *camera* local-down) (-> self view-off y))) + (vector+! (-> self desired-pos) (-> *camera* tpos-curr-adj) gp-1) + ) + (let ((v1-19 (new-stack-vector0)) + (gp-2 (new-stack-vector0)) + ) + (vector-! v1-19 (-> self desired-pos) (-> self trans)) + (vector-float*! v1-19 v1-19 0.2) + (vector-! gp-2 v1-19 (-> self velocity)) + (if (< 409.6 (vector-length gp-2)) + (vector-normalize! gp-2 409.6) + ) + (vector+! (-> self velocity) (-> self velocity) gp-2) + ) + (let ((gp-3 (new 'stack-no-clear 'collide-query))) + 0.0 + (let ((f30-1 1.0) + (s5-3 (-> gp-3 move-dist)) + (s4-3 4) + ) + (while (and (< 0.01 f30-1) + (and (< (-> *CAMERA-bank* min-detectable-velocity) (vector-length (-> self velocity))) (> s4-3 0)) + ) + (+! s4-3 -1) + (vector-float*! s5-3 (-> self velocity) f30-1) + (let ((f28-0 + (cond + ((logtest? (-> self options) (cam-slave-options-u32 COLLIDE)) + (set! (-> gp-3 start-pos quad) (-> self trans quad)) + (let ((s3-2 gp-3)) + (set! (-> s3-2 radius) 4096.0) + (set! (-> s3-2 collide-with) (collide-spec backgnd obstacle hit-by-others-list camera-blocker pusher)) + (set! (-> s3-2 ignore-process0) #f) + (set! (-> s3-2 ignore-process1) #f) + (set! (-> s3-2 ignore-pat) (the-as pat-surface (camera-master-method-16 *camera* #f))) + (set! (-> s3-2 action-mask) (collide-action solid)) + ) + (fill-and-probe-using-line-sphere *collide-cache* gp-3) + ) + (else + -100000000.0 + ) + ) + ) + ) + (cond + ((>= f28-0 0.0) + (vector+float*! (-> self trans) (-> self trans) s5-3 f28-0) + (vector-flatten! (-> self velocity) (-> self velocity) (-> gp-3 best-other-tri normal)) + (set! f30-1 (- f30-1 (* f30-1 f28-0))) + (let ((s3-3 (new-stack-vector0))) + (vector-! s3-3 (-> self trans) (-> *camera* tpos-curr-adj)) + (vector-flatten! s3-3 s3-3 (-> *camera* local-down)) + (vector-normalize-copy! (-> self view-flat) s3-3 (-> self view-off z)) + ) + ) + (else + (vector+! (-> self trans) (-> self trans) s5-3) + (set! f30-1 0.0) + ) + ) + ) + ) + ) + ) + (cam-calc-bike-follow! (-> self tracking) (-> self trans) #t) + (slave-set-rotation! (-> self tracking) (-> self trans) (-> self options) (-> self fov) #t) + (none) + ) + +;; failed to figure out what this is: +(defstate cam-bike (camera-slave) + :event cam-standard-event-handler + :enter (behavior () + (when (not (-> self enter-has-run)) + (set-setting! 'head-offset 'abs (meters 4) 0) + (set-setting! 'foot-offset 'abs (meters 1) 0) + (set! (-> self view-off x) 0.0) + (set! (-> self view-off y) (-> *CAM_BIKE-bank* min-y)) + (set! (-> self view-off z) (-> *CAM_BIKE-bank* min-z)) + (vector-flatten! (-> self view-flat) (-> self tracking inv-mat fvec) (-> *camera* local-down)) + (vector-negate! (-> self view-flat) (-> self view-flat)) + (vector-normalize! (-> self view-flat) (-> self view-off z)) + (vector--float*! (-> self desired-pos) (-> self view-flat) (-> *camera* local-down) (-> self view-off y)) + (vector+! (-> self desired-pos) (-> self desired-pos) (-> *camera* tpos-curr-adj)) + (set! (-> self trans quad) (-> self desired-pos quad)) + (vector-reset! (-> self velocity)) + (set! (-> self blend-from-type) (camera-blend-from-type unknown-0)) + (set! (-> self blend-to-type) (camera-blend-to-type unknown-1)) + (cam-calc-bike-follow! (-> self tracking) (-> self trans) #f) + (slave-set-rotation! (-> self tracking) (-> self trans) (-> self options) (-> self fov) #f) + ) + ) + :exit (behavior () + (remove-setting! 'head-offset) + (remove-setting! 'foot-offset) + ) + :trans (behavior () + (if (not (logtest? (-> *camera* master-options) (cam-master-options-u32 HAVE_TARGET))) + (cam-slave-go cam-free-floating) + ) + ) + :code (behavior () + (until #f + (if (not (paused?)) + (cam-bike-code) + ) + (suspend) + ) + #f + ) + ) + + + + diff --git a/test/decompiler/reference/jak3/engine/camera/cam-update-h_REF.gc b/test/decompiler/reference/jak3/engine/camera/cam-update-h_REF.gc index 8799ae74b2a..9f44bd0b2b8 100644 --- a/test/decompiler/reference/jak3/engine/camera/cam-update-h_REF.gc +++ b/test/decompiler/reference/jak3/engine/camera/cam-update-h_REF.gc @@ -25,11 +25,11 @@ ;; definition (perm) for symbol *camera-smush-control*, type smush-control (define-perm *camera-smush-control* smush-control (set-zero! (new 'global 'smush-control))) -;; definition (perm) for symbol *camera-smush-control-horizontal*, type object -(define-perm *camera-smush-control-horizontal* object (set-zero! (new 'global 'smush-control))) +;; definition (perm) for symbol *camera-smush-control-horizontal*, type smush-control +(define-perm *camera-smush-control-horizontal* smush-control (set-zero! (new 'global 'smush-control))) -;; definition (perm) for symbol *camera-smush-control-into*, type object -(define-perm *camera-smush-control-into* object (set-zero! (new 'global 'smush-control))) +;; definition (perm) for symbol *camera-smush-control-into*, type smush-control +(define-perm *camera-smush-control-into* smush-control (set-zero! (new 'global 'smush-control))) ;; definition (perm) for symbol *camera-other-root*, type vector (define-perm *camera-other-root* vector (vector-reset! (new 'global 'vector))) @@ -39,7 +39,3 @@ ;; definition for symbol *manual-sample-point*, type symbol (define *manual-sample-point* #f) - - - - diff --git a/test/decompiler/reference/jak3/engine/camera/cam-update_REF.gc b/test/decompiler/reference/jak3/engine/camera/cam-update_REF.gc new file mode 100644 index 00000000000..d76e0b801a1 --- /dev/null +++ b/test/decompiler/reference/jak3/engine/camera/cam-update_REF.gc @@ -0,0 +1,720 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition for function plane-from-points +(defun plane-from-points ((arg0 (inline-array plane)) (arg1 vector) (arg2 vector) (arg3 vector) (arg4 int)) + (let ((s4-0 (new 'stack-no-clear 'vector))) + (vector-cross! s4-0 arg1 arg2) + (vector-normalize! s4-0 1.0) + (set! (-> s4-0 w) (vector-dot s4-0 arg3)) + (set! (-> (&-> arg0 0 data arg4) 0) (-> s4-0 x)) + (set! (-> (&-> arg0 0 data arg4) 4) (-> s4-0 y)) + (set! (-> (&-> arg0 0 data arg4) 8) (-> s4-0 z)) + (set! (-> (&-> arg0 0 data arg4) 12) (-> s4-0 w)) + ) + ) + +;; definition for function set-point +(defun set-point ((arg0 vector) (arg1 float) (arg2 float) (arg3 float)) + (set! (-> arg0 x) arg1) + (set! (-> arg0 y) arg2) + (set! (-> arg0 z) arg3) + (set! (-> arg0 w) 1.0) + ) + +;; definition for function update-view-planes +;; INFO: Used lq/sq +(defun update-view-planes ((arg0 math-camera) (arg1 (inline-array plane)) (arg2 float) (arg3 matrix)) + (local-vars (sv-240 vector)) + (when (not *artist-fix-frustum*) + (let ((s5-0 (new 'stack 'view-frustum))) + (let ((f30-0 (* arg2 (-> arg0 x-ratio) (-> arg0 d))) + (f26-0 (* arg2 (-> arg0 y-ratio) (-> arg0 d))) + (f28-0 (* arg2 (-> arg0 x-ratio) (-> arg0 f))) + (f24-0 (* arg2 (-> arg0 y-ratio) (-> arg0 f))) + ) + (set-point (-> s5-0 hither-top-left) (- f30-0) f26-0 (-> arg0 d)) + (set-point (-> s5-0 hither-top-right) f30-0 f26-0 (-> arg0 d)) + (set-point (-> s5-0 hither-bottom-left) (- f30-0) (- f26-0) (-> arg0 d)) + (set-point (-> s5-0 hither-bottom-right) f30-0 (- f26-0) (-> arg0 d)) + (set-point (-> s5-0 yon-top-left) (- f28-0) f24-0 (-> arg0 f)) + (set-point (-> s5-0 yon-top-right) f28-0 f24-0 (-> arg0 f)) + (set-point (-> s5-0 yon-bottom-left) (- f28-0) (- f24-0) (-> arg0 f)) + (set-point (-> s5-0 yon-bottom-right) f28-0 (- f24-0) (-> arg0 f)) + ) + (vector-matrix*! (-> s5-0 hither-top-left) (-> s5-0 hither-top-left) arg3) + (vector-matrix*! (-> s5-0 hither-top-right) (-> s5-0 hither-top-right) arg3) + (vector-matrix*! (-> s5-0 hither-bottom-left) (-> s5-0 hither-bottom-left) arg3) + (vector-matrix*! (-> s5-0 hither-bottom-right) (-> s5-0 hither-bottom-right) arg3) + (vector-matrix*! (-> s5-0 yon-top-left) (-> s5-0 yon-top-left) arg3) + (vector-matrix*! (-> s5-0 yon-top-right) (-> s5-0 yon-top-right) arg3) + (vector-matrix*! (-> s5-0 yon-bottom-left) (-> s5-0 yon-bottom-left) arg3) + (vector-matrix*! (-> s5-0 yon-bottom-right) (-> s5-0 yon-bottom-right) arg3) + (when (= arg2 1.0) + (let ((v1-4 *fog-texture-work*)) + (vector-! (the-as vector (-> v1-4 corner)) (-> s5-0 yon-top-left) (-> arg3 trans)) + (vector-! (-> v1-4 corner 1) (-> s5-0 yon-top-right) (-> arg3 trans)) + (vector-! (-> v1-4 corner 2) (-> s5-0 yon-bottom-left) (-> arg3 trans)) + (vector-! (-> v1-4 corner 3) (-> s5-0 yon-bottom-right) (-> arg3 trans)) + ) + ) + (let ((s2-1 (new-stack-vector0)) + (s3-1 (new-stack-vector0)) + (s1-0 (new-stack-vector0)) + (s0-0 (new-stack-vector0)) + ) + (set! (-> (new 'stack-no-clear 'vector) quad) (the-as uint128 0)) + (set! sv-240 (new 'stack-no-clear 'vector)) + (set! (-> sv-240 quad) (the-as uint128 0)) + (let ((v1-9 (-> arg3 trans quad))) + (set! (-> sv-240 quad) v1-9) + ) + (vector-! s2-1 (-> s5-0 yon-top-left) sv-240) + (vector-! s3-1 (-> s5-0 yon-top-right) sv-240) + (vector-! s1-0 (-> s5-0 yon-bottom-left) sv-240) + (vector-! s0-0 (-> s5-0 yon-bottom-right) sv-240) + (plane-from-points arg1 s2-1 s1-0 sv-240 0) + (plane-from-points arg1 s0-0 s3-1 sv-240 1) + (plane-from-points arg1 s3-1 s2-1 sv-240 2) + (let ((t9-20 plane-from-points) + (t0-3 3) + ) + (t9-20 arg1 s1-0 s0-0 sv-240 t0-3) + ) + ) + ) + ) + ) + +;; definition for symbol *update-leaf-when-outside-bsp*, type symbol +(define *update-leaf-when-outside-bsp* #t) + +;; definition for function update-visible +;; INFO: Used lq/sq +(defun update-visible ((arg0 math-camera)) + (local-vars (s4-0 level-vis-info)) + (when (not *artist-fix-visible*) + (dotimes (s5-0 (-> *level* length)) + (let ((v1-5 (-> *level* level s5-0))) + (when (= (-> v1-5 status) 'active) + (if (and (nonzero? (-> v1-5 bsp nodes)) (or *update-leaf-when-outside-bsp* (-> v1-5 inside-boxes?))) + (bsp-camera-asm (-> v1-5 bsp) (-> arg0 trans)) + ) + ) + ) + ) + (dotimes (gp-1 (-> *level* length)) + (let ((s5-1 (-> *level* level gp-1))) + (when (= (-> s5-1 status) 'active) + (let ((a2-0 (/ (+ (-> s5-1 bsp visible-list-length) 15) 16))) + (set! (-> s5-1 all-visible?) (if (-> s5-1 all-visible?) + (-> s5-1 all-visible?) + #t + ) + ) + (cond + ((or (not (-> s5-1 force-all-visible?)) (-> s5-1 inside-boxes?)) + (cond + ((or *artist-all-visible* (not (-> s5-1 vis-info 0))) + (quad-copy! (-> s5-1 vis-bits) (-> s5-1 bsp all-visible-list) a2-0) + (if (= (-> s5-1 all-visible?) 'loading) + (set! (-> s5-1 all-visible?) #t) + ) + ) + ((begin + (set! s4-0 (-> s5-1 vis-info (-> s5-1 vis-self-index))) + (let ((v1-32 #f)) + (when (and s4-0 (-> s4-0 from-bsp)) + (set! v1-32 (logtest? (vis-info-flag vis-valid) (-> s4-0 flags))) + (if (< (-> s4-0 length) (-> s4-0 from-bsp current-leaf-idx)) + (set! v1-32 #f) + ) + ) + v1-32 + ) + ) + (if (!= (-> s5-1 all-visible?) 'loading) + (set! (-> s5-1 all-visible?) #f) + ) + (when (update-vis! s5-1 s4-0 (-> s4-0 ramdisk) (the-as (pointer uint8) (-> s4-0 string-block))) + (countdown (v1-40 8) + (let ((a0-27 (-> s5-1 vis-info v1-40))) + (when a0-27 + (if (!= a0-27 s4-0) + (set! (-> a0-27 current-vis-string) (the-as uint -1)) + ) + ) + ) + ) + (set! (-> s5-1 all-visible?) #f) + ) + ) + ((and (= (-> s5-1 all-visible?) 'loading) (-> *level* play?)) + ) + (else + (quad-copy! (-> s5-1 vis-bits) (-> s5-1 bsp all-visible-list) a2-0) + ) + ) + ) + (else + (quad-copy! (-> s5-1 vis-bits) (-> s5-1 bsp all-visible-list) a2-0) + ) + ) + ) + ) + ) + ) + ) + (let ((gp-2 0)) + (if (and *artist-fix-visible* (cpad-pressed? 0 r2)) + (set! *fix-visible-level-mask* (logand (+ *fix-visible-level-mask* 1) 127)) + ) + (dotimes (s5-2 (-> *level* length)) + (let ((s4-1 (-> *level* level s5-2))) + (when (= (-> s4-1 status) 'active) + (cond + ((or *artist-fix-visible* *stats-bsp*) + (set! (-> s4-1 render?) (not (logtest? *fix-visible-level-mask* (ash 1 gp-2)))) + (if (!= (-> s4-1 bsp visible-list-length) 4) + (format + *stdcon* + "~0kleaf-index ~8S ~C = ~d node ~d ~S ~S~%" + (-> s4-1 name) + (if (not (logtest? *fix-visible-level-mask* (ash 1 gp-2))) + 88 + 32 + ) + (-> s4-1 bsp current-leaf-idx) + (-> s4-1 bsp cam-box-idx) + (if (zero? (-> s4-1 bsp cam-using-back)) + "front" + "back" + ) + (if (nonzero? (-> s4-1 bsp cam-outside-bsp)) + "outside" + "" + ) + ) + ) + ) + (else + (set! (-> s4-1 render?) #t) + ) + ) + (when (and *artist-fix-visible* (not (logtest? *fix-visible-level-mask* (ash 1 gp-2)))) + (let ((s3-0 (-> s4-1 bsp current-leaf-idx)) + (s2-0 (-> s4-1 bsp vis-spheres)) + ) + (-> s4-1 bsp vis-spheres-length) + (when (nonzero? s2-0) + (dotimes (s1-0 (-> s2-0 length)) + (let* ((v1-95 (the int (-> s2-0 data s1-0 w))) + (a0-45 (abs v1-95)) + ) + (when (= a0-45 s3-0) + (if (>= v1-95 0) + (add-debug-sphere #t (bucket-id bucket583) (-> s2-0 data s1-0) (meters 1) (new 'static 'rgba :b #xff :a #x80)) + (add-debug-sphere #t (bucket-id bucket583) (-> s2-0 data s1-0) (meters 1) (new 'static 'rgba :r #xff :a #x80)) + ) + ) + ) + ) + ) + ) + (when (nonzero? (-> s4-1 bsp nodes)) + (let ((v1-109 (-> s4-1 bsp nodes (-> s4-1 bsp cam-box-idx))) + (a2-7 (new 'stack-no-clear 'vector)) + ) + (set! (-> a2-7 quad) (-> s4-1 bsp bsp-offset quad)) + (let ((a3-6 (new 'stack-no-clear 'vector))) + (set! (-> a3-6 quad) (-> s4-1 bsp bsp-offset quad)) + (cond + ((zero? (-> s4-1 bsp cam-using-back)) + (+! (-> a2-7 x) (the float (* (-> v1-109 front-box-min x) (the int (-> s4-1 bsp bsp-scale x))))) + (+! (-> a2-7 y) (the float (* (-> v1-109 front-box-min y) (the int (-> s4-1 bsp bsp-scale y))))) + (+! (-> a2-7 z) (the float (* (-> v1-109 front-box-min z) (the int (-> s4-1 bsp bsp-scale z))))) + (+! (-> a3-6 x) (the float (* (-> v1-109 front-box-max x) (the int (-> s4-1 bsp bsp-scale x))))) + (+! (-> a3-6 y) (the float (* (-> v1-109 front-box-max y) (the int (-> s4-1 bsp bsp-scale y))))) + (+! (-> a3-6 z) (the float (* (-> v1-109 front-box-max z) (the int (-> s4-1 bsp bsp-scale z))))) + ) + (else + (+! (-> a2-7 x) (the float (* (-> v1-109 back-box-min x) (the int (-> s4-1 bsp bsp-scale x))))) + (+! (-> a2-7 y) (the float (* (-> v1-109 back-box-min y) (the int (-> s4-1 bsp bsp-scale y))))) + (+! (-> a2-7 z) (the float (* (-> v1-109 back-box-min z) (the int (-> s4-1 bsp bsp-scale z))))) + (+! (-> a3-6 x) (the float (* (-> v1-109 back-box-max x) (the int (-> s4-1 bsp bsp-scale x))))) + (+! (-> a3-6 y) (the float (* (-> v1-109 back-box-max y) (the int (-> s4-1 bsp bsp-scale y))))) + (+! (-> a3-6 z) (the float (* (-> v1-109 back-box-max z) (the int (-> s4-1 bsp bsp-scale z))))) + ) + ) + (add-debug-box #t (bucket-id bucket583) a2-7 a3-6 (new 'static 'rgba :g #xff :b #xff :a #x80)) + ) + ) + ) + ) + (if (!= (-> s4-1 bsp visible-list-length) 4) + (+! gp-2 1) + ) + ) + ) + ) + ) + #f + ) + +;; definition for symbol *save-camera-inv-rot*, type matrix +(define *save-camera-inv-rot* (new 'global 'matrix)) + +;; failed to figure out what this is: +(matrix-identity! *save-camera-inv-rot*) + +;; definition for function move-camera-from-pad +;; INFO: Used lq/sq +(defun move-camera-from-pad ((arg0 math-camera)) + (let ((v1-0 *external-cam-mode*) + (s5-0 0) + ) + (cond + ((= v1-0 'locked) + (set! v1-0 #f) + ) + ((= v1-0 'pad-1) + (set! s5-0 1) + ) + ((not *camera-combiner*) + (set! v1-0 'pad-0) + ) + ) + (when v1-0 + (let ((a2-1 + (vector-negate-in-place! (vector-normalize-copy! (new-stack-vector0) (-> *standard-dynamics* gravity) 1.0)) + ) + ) + (if (= (vector-length a2-1) 0.0) + (set! (-> a2-1 y) -1.0) + ) + (if (logtest? *external-cam-options* (external-cam-option allow-z)) + (set! a2-1 (the-as vector #f)) + ) + (cam-free-floating-move *save-camera-inv-rot* (-> arg0 trans) a2-1 s5-0) + ) + ) + ) + (let* ((a2-2 (-> *math-camera* inv-camera-rot)) + (a3-1 *save-camera-inv-rot*) + (v1-14 (-> a3-1 rvec quad)) + (a0-13 (-> a3-1 uvec quad)) + (a1-2 (-> a3-1 fvec quad)) + (a3-2 (-> a3-1 trans quad)) + ) + (set! (-> a2-2 rvec quad) v1-14) + (set! (-> a2-2 uvec quad) a0-13) + (set! (-> a2-2 fvec quad) a1-2) + (set! (-> a2-2 trans quad) a3-2) + ) + arg0 + ) + +;; definition for function external-cam-reset! +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs none. +(defun external-cam-reset! () + (when (not (movie?)) + (vector-reset! (-> *math-camera* trans)) + (matrix-identity! (-> *math-camera* inv-camera-rot)) + (when *camera-combiner* + (let* ((v1-7 (-> *math-camera* inv-camera-rot)) + (a3-0 (-> *camera-combiner* inv-camera-rot)) + (a0-2 (-> a3-0 rvec quad)) + (a1-0 (-> a3-0 uvec quad)) + (a2-0 (-> a3-0 fvec quad)) + (a3-1 (-> a3-0 trans quad)) + ) + (set! (-> v1-7 rvec quad) a0-2) + (set! (-> v1-7 uvec quad) a1-0) + (set! (-> v1-7 fvec quad) a2-0) + (set! (-> v1-7 trans quad) a3-1) + ) + (set! (-> *math-camera* trans quad) (-> *camera-combiner* trans quad)) + ) + ) + 0 + (none) + ) + +;; definition for symbol *start-timer*, type int +(define *start-timer* (the-as int #f)) + +;; definition for symbol *timer-value*, type int +(define *timer-value* 0) + +;; definition for symbol *start-pos*, type vector +(define *start-pos* (new 'global 'vector)) + +;; definition for function update-camera +;; INFO: Used lq/sq +(defun update-camera () + (with-pp + (let ((gp-0 *math-camera*)) + (let* ((a2-0 (-> gp-0 prev-inv-camera-rot)) + (a3-0 (-> gp-0 inv-camera-rot)) + (v1-0 (-> a3-0 rvec quad)) + (a0-0 (-> a3-0 uvec quad)) + (a1-0 (-> a3-0 fvec quad)) + (a3-1 (-> a3-0 trans quad)) + ) + (set! (-> a2-0 rvec quad) v1-0) + (set! (-> a2-0 uvec quad) a0-0) + (set! (-> a2-0 fvec quad) a1-0) + (set! (-> a2-0 trans quad) a3-1) + ) + (set! (-> gp-0 prev-trans quad) (-> gp-0 trans quad)) + (when *start-timer* + (when (= *timer-value* 180) + (format + #t + "Player pos = ~F ~F ~F~%" + (-> *target* control trans x) + (-> *target* control trans y) + (-> *target* control trans z) + ) + (set! (-> *start-pos* quad) (-> *target* control trans quad)) + ) + (when (= *timer-value* 480) + (format + #t + "Player pos = ~F ~F ~F~%" + (-> *target* control trans x) + (-> *target* control trans y) + (-> *target* control trans z) + ) + (format + #t + "Dist = ~F~%" + (* 0.00024414062 (vector-vector-xz-distance (-> *target* control trans) *start-pos*)) + ) + (set! *start-timer* (the-as int #f)) + ) + (if (< 179 *timer-value*) + (format *stdcon* "~%~%Time = ~D~%" *timer-value*) + ) + (set! *timer-value* (+ *timer-value* 1)) + ) + (when (not *start-timer*) + (set! *timer-value* 0) + 0 + ) + (let ((f0-9 (if (get-menu-mode *blit-displays-work*) + 11650.845 + (-> gp-0 fov) + ) + ) + ) + (update-math-camera + gp-0 + (-> *setting-control* user-current video-mode) + (-> *setting-control* user-current aspect-ratio) + f0-9 + ) + ) + (cond + ((or (= *master-mode* 'pause) (or (= *master-mode* 'freeze) (= *master-mode* 'progress) *progress-process*)) + ) + ((>= *camera-look-through-other* 2) + (set! *camera-look-through-other* 1) + ) + ((and (= *camera-look-through-other* 1) (!= *master-mode* 'menu)) + (set! *camera-look-through-other* 0) + 0 + ) + ) + 0.0 + 0.0 + 0.0 + (let ((s5-1 (new 'stack-no-clear 'vector)) + (s4-1 (-> pp clock)) + ) + (set! (-> pp clock) (-> *display* camera-clock)) + (update! *camera-smush-control*) + (let ((f28-0 (get-no-update *camera-smush-control*))) + (update! *camera-smush-control-horizontal*) + (let ((f30-1 (get-no-update *camera-smush-control-horizontal*))) + (update! *camera-smush-control-into*) + (get-no-update *camera-smush-control-into*) + (set! (-> pp clock) s4-1) + (cond + (*external-cam-mode* + (move-camera-from-pad gp-0) + ) + ((nonzero? *camera-look-through-other*) + (set! (-> gp-0 fov) (-> *camera-other-fov* data)) + (set! (-> gp-0 trans quad) (-> *camera-other-trans* quad)) + (+! (-> gp-0 trans y) f28-0) + (let* ((a2-6 (-> gp-0 inv-camera-rot)) + (a3-5 *camera-other-matrix*) + (v1-76 (-> a3-5 rvec quad)) + (a0-34 (-> a3-5 uvec quad)) + (a1-7 (-> a3-5 fvec quad)) + (a3-6 (-> a3-5 trans quad)) + ) + (set! (-> a2-6 rvec quad) v1-76) + (set! (-> a2-6 uvec quad) a0-34) + (set! (-> a2-6 fvec quad) a1-7) + (set! (-> a2-6 trans quad) a3-6) + ) + (let* ((a2-7 *save-camera-inv-rot*) + (a3-7 *camera-other-matrix*) + (v1-77 (-> a3-7 rvec quad)) + (a0-35 (-> a3-7 uvec quad)) + (a1-8 (-> a3-7 fvec quad)) + (a3-8 (-> a3-7 trans quad)) + ) + (set! (-> a2-7 rvec quad) v1-77) + (set! (-> a2-7 uvec quad) a0-35) + (set! (-> a2-7 fvec quad) a1-8) + (set! (-> a2-7 trans quad) a3-8) + ) + ) + ((and *camera-combiner* (not *external-cam-mode*)) + (set! (-> gp-0 fov) (-> *camera-combiner* fov)) + (set! (-> gp-0 trans quad) (-> *camera-combiner* trans quad)) + (+! (-> gp-0 trans y) f28-0) + (let* ((v1-84 (-> gp-0 inv-camera-rot)) + (a3-9 (-> *camera-combiner* inv-camera-rot)) + (a0-40 (-> a3-9 rvec quad)) + (a1-9 (-> a3-9 uvec quad)) + (a2-8 (-> a3-9 fvec quad)) + (a3-10 (-> a3-9 trans quad)) + ) + (set! (-> v1-84 rvec quad) a0-40) + (set! (-> v1-84 uvec quad) a1-9) + (set! (-> v1-84 fvec quad) a2-8) + (set! (-> v1-84 trans quad) a3-10) + ) + (let* ((v1-85 *save-camera-inv-rot*) + (a3-11 (-> *camera-combiner* inv-camera-rot)) + (a0-42 (-> a3-11 rvec quad)) + (a1-10 (-> a3-11 uvec quad)) + (a2-9 (-> a3-11 fvec quad)) + (a3-12 (-> a3-11 trans quad)) + ) + (set! (-> v1-85 rvec quad) a0-42) + (set! (-> v1-85 uvec quad) a1-10) + (set! (-> v1-85 fvec quad) a2-9) + (set! (-> v1-85 trans quad) a3-12) + ) + ) + (*camera* + (move-camera-from-pad gp-0) + ) + ) + (when (or (nonzero? *camera-look-through-other*) (and *camera-combiner* (not *external-cam-mode*))) + 0.0 + (set-vector! s5-1 f30-1 0.0 0.0 1.0) + (vector-rotate*! s5-1 s5-1 (-> gp-0 inv-camera-rot)) + (set! (-> s5-1 y) 0.0) + (vector+! (-> gp-0 trans) (-> gp-0 trans) s5-1) + ) + ) + ) + ) + (matrix-transpose! (-> gp-0 camera-rot) (-> gp-0 inv-camera-rot)) + (cond + (*camera-no-mip-correction* + (set! (-> gp-0 fov-correction-factor) 1.0) + ) + (else + (let ((f0-27 (fmin 11650.845 (-> gp-0 fov)))) + (set! (-> gp-0 fov-correction-factor) (* 0.00008583069 f0-27)) + ) + ) + ) + (if (< 0.0 (-> gp-0 smooth-t)) + (set! (-> gp-0 smooth-t) (- (-> gp-0 smooth-t) (-> gp-0 smooth-step))) + ) + (cond + ((< 0.0 (-> gp-0 smooth-t)) + (let ((s5-2 (new-stack-quaternion0))) + (matrix->quaternion s5-2 (-> gp-0 inv-camera-rot)) + (quaternion-slerp! s5-2 s5-2 (-> gp-0 inv-camera-rot-smooth-from) (-> gp-0 smooth-t)) + (quaternion->matrix (-> gp-0 inv-camera-rot-smooth) s5-2) + ) + ) + (else + (let* ((a2-12 (-> gp-0 inv-camera-rot-smooth)) + (a3-14 (-> gp-0 inv-camera-rot)) + (v1-106 (-> a3-14 rvec quad)) + (a0-51 (-> a3-14 uvec quad)) + (a1-16 (-> a3-14 fvec quad)) + (a3-15 (-> a3-14 trans quad)) + ) + (set! (-> a2-12 rvec quad) v1-106) + (set! (-> a2-12 uvec quad) a0-51) + (set! (-> a2-12 fvec quad) a1-16) + (set! (-> a2-12 trans quad) a3-15) + ) + ) + ) + (when (and (!= *master-mode* 'menu) *display-camera-info*) + (when *target* + (let ((v1-112 (target-pos 0))) + (format *stdcon* "targ pos ~M ~M ~M~%" (-> v1-112 x) (-> v1-112 y) (-> v1-112 z)) + ) + ) + (format + *stdcon* + "cam pos ~M ~M ~M fov ~R~%" + (-> gp-0 trans x) + (-> gp-0 trans y) + (-> gp-0 trans z) + (-> gp-0 fov) + ) + (let ((v1-115 (-> *setting-control* cam-current))) + (format + *stdcon* + "string info min-l ~M max-l ~M min-h ~M max-h ~M~%" + (-> v1-115 string-min-length) + (-> v1-115 string-max-length) + (-> v1-115 string-min-height) + (-> v1-115 string-max-height) + ) + ) + ) + (when (zero? (-> gp-0 reset)) + (let* ((a2-16 (-> gp-0 prev-camera-temp)) + (a3-19 (-> gp-0 camera-temp)) + (v1-119 (-> a3-19 rvec quad)) + (a0-58 (-> a3-19 uvec quad)) + (a1-20 (-> a3-19 fvec quad)) + (a3-20 (-> a3-19 trans quad)) + ) + (set! (-> a2-16 rvec quad) v1-119) + (set! (-> a2-16 uvec quad) a0-58) + (set! (-> a2-16 fvec quad) a1-20) + (set! (-> a2-16 trans quad) a3-20) + ) + ) + (let ((s3-1 (-> gp-0 camera-temp)) + (s2-0 (-> gp-0 camera-rot)) + (s5-3 (-> gp-0 inv-camera-rot)) + (s4-2 (-> gp-0 trans)) + ) + (let ((s1-0 (new-stack-vector0))) + (set! (-> s1-0 x) (- (-> s4-2 x))) + (set! (-> s1-0 y) (- (-> s4-2 y))) + (set! (-> s1-0 z) (- (-> s4-2 z))) + (set! (-> s1-0 w) 1.0) + (vector-matrix*! s1-0 s1-0 s2-0) + (set! (-> s2-0 trans quad) (-> s1-0 quad)) + ) + (matrix*! s3-1 s2-0 (-> gp-0 perspective)) + (set! (-> s5-3 trans quad) (-> s4-2 quad)) + ) + (when (nonzero? (-> gp-0 reset)) + (let* ((a2-19 (-> gp-0 prev-camera-temp)) + (a3-21 (-> gp-0 camera-temp)) + (v1-125 (-> a3-21 rvec quad)) + (a0-61 (-> a3-21 uvec quad)) + (a1-23 (-> a3-21 fvec quad)) + (a3-22 (-> a3-21 trans quad)) + ) + (set! (-> a2-19 rvec quad) v1-125) + (set! (-> a2-19 uvec quad) a0-61) + (set! (-> a2-19 fvec quad) a1-23) + (set! (-> a2-19 trans quad) a3-22) + ) + (set! (-> gp-0 reset) 0) + 0 + ) + (let ((f1-5 (-> gp-0 fog-min)) + (f0-52 (-> gp-0 fog-max)) + ) + (let ((f2-0 (-> gp-0 d))) + (set! (-> *instance-tie-work* hmge-d x) f1-5) + (set! (-> *instance-tie-work* hmge-d y) f0-52) + (set! (-> *instance-tie-work* hmge-d z) (* 32.0 f2-0)) + (set! (-> *instance-tie-work* hmge-d w) (* f2-0 (-> gp-0 hmge-scale w))) + (let ((v1-132 (-> gp-0 hvdf-off quad))) + (set! (-> *instance-tie-work* hvdf-offset quad) v1-132) + ) + (set! (-> *instance-shrub-work* hmge-d x) f1-5) + (set! (-> *instance-shrub-work* hmge-d y) f0-52) + (set! (-> *instance-shrub-work* hmge-d z) (* 3.0 f2-0)) + (set! (-> *instance-shrub-work* hmge-d w) (* f2-0 (-> gp-0 hmge-scale w))) + (set! (-> *instance-shrub-work* billboard-const x) (/ (-> gp-0 x-pix) (* f2-0 (-> gp-0 x-ratio)))) + (set! (-> *instance-shrub-work* billboard-const y) (/ (-> gp-0 y-pix) (* f2-0 (-> gp-0 y-ratio)))) + ) + (set! (-> *instance-shrub-work* billboard-const z) f1-5) + (set! (-> *instance-shrub-work* billboard-const w) f0-52) + ) + (set! (-> *instance-shrub-work* constants w) (the-as float (-> gp-0 vis-gifs 0))) + (let ((a0-63 (-> gp-0 hvdf-off quad))) + (set! (-> *instance-shrub-work* hvdf-offset quad) a0-63) + ) + (update-view-planes gp-0 (-> gp-0 plane) 1.0 (-> gp-0 inv-camera-rot)) + (update-view-planes gp-0 (-> gp-0 guard-plane) 2.0 (-> gp-0 inv-camera-rot)) + (shrub-make-perspective-matrix (-> gp-0 shrub-mat) (-> gp-0 camera-temp)) + (update-visible gp-0) + (when (-> *time-of-day-context* use-camera-other) + (let ((s4-3 (-> gp-0 camera-rot)) + (s0-0 (-> gp-0 camera-rot-other-sky)) + (s5-4 (-> gp-0 camera-rot-other-sprite)) + (s3-2 (-> gp-0 camera-rot-other)) + (s2-1 (-> gp-0 inv-camera-rot-other)) + (s1-1 (-> gp-0 camera-temp-other)) + ) + (quaternion->matrix s0-0 (-> gp-0 quat-other)) + (mem-copy! (the-as pointer s5-4) (the-as pointer s0-0) 64) + (set! (-> s5-4 trans quad) (-> gp-0 trans-other quad)) + (set! (-> s5-4 trans w) 1.0) + (matrix*! s3-2 s5-4 s4-3) + (matrix-inverse-of-rot-trans! s2-1 s3-2) + (matrix*! s1-1 s3-2 (-> gp-0 perspective)) + (update-view-planes gp-0 (-> gp-0 plane-other) 1.0 s2-1) + (update-view-planes gp-0 (-> gp-0 guard-plane-other) 2.0 s2-1) + (shrub-make-perspective-matrix (-> gp-0 shrub-mat-other) s1-1) + ) + ) + ) + #f + ) + ) + +;; definition (debug) for function move-level-by-name +(defun-debug move-level-by-name ((arg0 symbol) (arg1 float) (arg2 float) (arg3 float)) + (let ((v1-1 (level-get *level* arg0))) + (when v1-1 + (logior! (-> v1-1 info level-flags) (level-flags lf10)) + (let ((v0-1 (-> *math-camera* trans-other))) + (set! (-> v0-1 x) (* 4096.0 arg1)) + (set! (-> v0-1 y) (* 4096.0 arg2)) + (set! (-> v0-1 z) (* 4096.0 arg3)) + (set! (-> v0-1 w) 1.0) + v0-1 + ) + ) + ) + ) + +;; definition for function execute-cam-post-hook-engine +(defun execute-cam-post-hook-engine () + (let* ((gp-0 *cam-post-hook-engine*) + (s5-0 (-> gp-0 alive-list next0)) + (s4-0 (-> s5-0 next0)) + ) + (while (!= s5-0 (-> gp-0 alive-list-end)) + ((the-as (function object object object object object) (-> (the-as connection s5-0) param0)) + (get-process (the-as connection s5-0)) + (-> (the-as connection s5-0) param1) + (-> (the-as connection s5-0) param2) + (-> (the-as connection s5-0) param2) + ) + (set! s5-0 s4-0) + (set! s4-0 (-> s4-0 next0)) + ) + ) + 0 + ) + + + + diff --git a/test/decompiler/reference/jak3/engine/camera/camera-h_REF.gc b/test/decompiler/reference/jak3/engine/camera/camera-h_REF.gc index 8eb777431f4..8d50a78dc0a 100644 --- a/test/decompiler/reference/jak3/engine/camera/camera-h_REF.gc +++ b/test/decompiler/reference/jak3/engine/camera/camera-h_REF.gc @@ -7,8 +7,8 @@ (vec vector 2 :inline) ) (:methods - (cam-index-method-9 () none) - (cam-index-method-10 () none) + (cam-index-method-9 (_type_ symbol entity vector curve) symbol) + (cam-index-method-10 (_type_ vector) float) ) ) @@ -89,21 +89,21 @@ (debug-last-point int32) ) (:methods - (tracking-spline-method-9 () none) - (tracking-spline-method-10 () none) - (tracking-spline-method-11 () none) - (tracking-spline-method-12 () none) - (tracking-spline-method-13 () none) - (tracking-spline-method-14 () none) - (tracking-spline-method-15 () none) - (tracking-spline-method-16 () none) - (tracking-spline-method-17 () none) - (tracking-spline-method-18 () none) - (tracking-spline-method-19 () none) - (tracking-spline-method-20 () none) - (tracking-spline-method-21 () none) - (tracking-spline-method-22 () none) - (tracking-spline-method-23 () none) + (tracking-spline-method-9 (_type_) none) + (tracking-spline-method-10 (_type_ vector) none) + (debug-point-info (_type_ int) none) + (debug-all-points (_type_) none) + (tracking-spline-method-13 (_type_ int) none) + (tracking-spline-method-14 (_type_ tracking-spline-sampler) none) + (tracking-spline-method-15 (_type_) none) + (tracking-spline-method-16 (_type_ float) none) + (tracking-spline-method-17 (_type_ vector float float symbol) int) + (tracking-spline-method-18 (_type_ float vector vector tracking-spline-sampler) vector) + (tracking-spline-method-19 (_type_ float vector vector tracking-spline-sampler) vector) + (tracking-spline-method-20 (_type_ vector int) none) + (tracking-spline-method-21 (_type_ vector float float float float vector) vector) + (tracking-spline-method-22 (_type_ float) symbol) + (debug-draw-spline (_type_) none) ) ) @@ -394,6 +394,9 @@ (tracking cam-rotation-tracker :inline) (fast-rot basic) ) + (:states + cam-combiner-active + ) ) ;; definition for method 3 of type camera-combiner @@ -630,7 +633,10 @@ (:methods (camera-master-method-14 (_type_ vector) vector) (camera-master-method-15 (_type_ vector) vector) - (camera-master-method-16 () none) + (camera-master-method-16 (_type_ symbol) int) + ) + (:states + cam-master-active ) ) diff --git a/test/decompiler/reference/jak3/engine/camera/camera_REF.gc b/test/decompiler/reference/jak3/engine/camera/camera_REF.gc new file mode 100644 index 00000000000..a05873c5807 --- /dev/null +++ b/test/decompiler/reference/jak3/engine/camera/camera_REF.gc @@ -0,0 +1,2073 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition for function cam-slave-get-vector-with-offset +;; INFO: Used lq/sq +(defun cam-slave-get-vector-with-offset ((arg0 entity-actor) (arg1 vector) (arg2 symbol)) + (local-vars (s3-0 structure)) + (cond + ((= arg2 'trans) + (set! s3-0 (-> arg0 trans)) + ) + ((= arg2 'rot) + (set! s3-0 (-> arg0 quat)) + ) + (else + (set! s3-0 (res-lump-struct arg0 arg2 vector)) + ) + ) + (let* ((s2-0 (method-of-type res-lump get-property-struct)) + (v1-8 arg2) + (a0-8 + (the-as + vector + (s2-0 + arg0 + (cond + ((= v1-8 'trans) + 'trans-offset + ) + ((= v1-8 'pivot) + 'pivot-offset + ) + ((= v1-8 'align) + 'align-offset + ) + ((= v1-8 'interesting) + 'interesting-offset + ) + (else + (format 0 "WARNING: cam-slave-get-vector-with-offset has been passed an unknown symbol ~A.~%" arg2) + #f + ) + ) + 'interp + -1000000000.0 + (the-as structure #f) + (the-as (pointer res-tag) #f) + *res-static-buf* + ) + ) + ) + ) + (cond + ((and s3-0 a0-8) + (vector+! arg1 (the-as vector s3-0) a0-8) + #t + ) + (s3-0 + (set! (-> arg1 quad) (-> (the-as vector s3-0) quad)) + #t + ) + (else + #f + ) + ) + ) + ) + +;; definition for function cam-slave-get-flags +;; WARN: Return type mismatch uint128 vs uint. +(defun cam-slave-get-flags ((arg0 entity) (arg1 symbol)) + (let* ((s5-0 (res-lump-value arg0 arg1 uint128 :time -1000000000.0)) + (s3-0 (method-of-type res-lump get-property-value)) + (s2-0 arg0) + (v1-2 arg1) + (s3-1 (s3-0 + s2-0 + (cond + ((= v1-2 'flags) + 'flags-on + ) + ((= v1-2 'focalpull-flags) + 'focalpull-flags-on + ) + ((= v1-2 'campoints-flags) + 'campoints-flags-on + ) + (else + (format 0 "WARNING: cam-slave-get-flags has been passed an unknown symbol ~A.~%" arg1) + #f + ) + ) + 'interp + -1000000000.0 + (the-as uint128 0) + (the-as (pointer res-tag) #f) + *res-static-buf* + ) + ) + (s2-1 (method-of-type res-lump get-property-value)) + (v1-4 arg1) + (v1-5 (s2-1 + arg0 + (cond + ((= v1-4 'flags) + 'flags-off + ) + ((= v1-4 'focalpull-flags) + 'focalpull-flags-off + ) + ((= v1-4 'campoints-flags) + 'campoints-flags-off + ) + (else + (format 0 "WARNING: cam-slave-get-flags has been passed an unknown symbol ~A.~%" arg1) + #f + ) + ) + 'interp + -1000000000.0 + (the-as uint128 0) + (the-as (pointer res-tag) #f) + *res-static-buf* + ) + ) + ) + (the-as uint (logclear (logior s5-0 s3-1) v1-5)) + ) + ) + +;; definition for function cam-slave-get-float +(defun cam-slave-get-float ((arg0 entity) (arg1 symbol) (arg2 float)) + (let ((f30-0 (res-lump-float arg0 arg1 :default arg2)) + (s4-0 (method-of-type res-lump get-property-value-float)) + (v1-3 arg1) + ) + (+ f30-0 + (s4-0 + arg0 + (cond + ((= v1-3 'intro-exitValue) + 'intro-exitValue-offset + ) + ((= v1-3 'stringMinHeight) + 'stringMinHeight-offset + ) + ((= v1-3 'stringMaxHeight) + 'stringMaxHeight-offset + ) + ((= v1-3 'stringMinLength) + 'stringMinLength-offset + ) + ((= v1-3 'stringMaxLength) + 'stringMaxLength-offset + ) + ((= v1-3 'stringCliffHeight) + 'stringCliffHeight-offset + ) + ((= v1-3 'tiltAdjust) + 'tiltAdjust-offset + ) + ((= v1-3 'spline-follow-dist) + 'spline-follow-dist-offset + ) + ((= v1-3 'maxAngle) + 'maxAngle-offset + ) + ((= v1-3 'focalpull) + 'focuspull-offset + ) + (else + (format 0 "WARNING: cam-slave-get-float has been passed an unknown symbol ~A #x~X.~%" arg1 arg1) + #f + ) + ) + 'interp + -1000000000.0 + 0.0 + (the-as (pointer res-tag) #f) + *res-static-buf* + ) + ) + ) + ) + +;; definition for function cam-slave-get-fov +(defun cam-slave-get-fov ((arg0 entity)) + (let ((f30-0 (res-lump-float arg0 'fov)) + (f0-0 (res-lump-float arg0 'fov-offset)) + ) + (if (= f30-0 0.0) + (+ 11650.845 f0-0) + (+ f30-0 f0-0) + ) + ) + ) + +;; definition for function cam-slave-get-intro-step +(defun cam-slave-get-intro-step ((arg0 entity)) + (let ((f0-1 (+ (res-lump-float arg0 'intro-time) (res-lump-float arg0 'intro-time-offset)))) + (if (>= 0.0 f0-1) + 0.004166667 + (/ 0.016666668 f0-1) + ) + ) + ) + +;; definition for function cam-slave-get-interp-time +(defun cam-slave-get-interp-time ((arg0 entity)) + (let ((f0-1 (the-as number (+ (res-lump-float arg0 'interpTime) (res-lump-float arg0 'interpTime-offset))))) + (if (>= 0.001 (the-as float f0-1)) + (set! f0-1 0.0) + ) + (the-as float f0-1) + ) + ) + +;; definition for function cam-slave-get-rot +(defun cam-slave-get-rot ((arg0 entity-actor) (arg1 matrix)) + (let ((a1-2 (res-lump-struct arg0 'rot-offset structure))) + (cond + (a1-2 + (let ((s4-0 (new 'stack-no-clear 'quaternion))) + (quaternion*! s4-0 (the-as quaternion a1-2) (-> arg0 quat)) + (quaternion-normalize! s4-0) + (quaternion->matrix arg1 s4-0) + ) + ) + (else + (quaternion->matrix arg1 (-> arg0 quat)) + ) + ) + ) + arg1 + ) + +;; definition for function cam-state-from-entity +(defun cam-state-from-entity ((arg0 entity)) + (let ((s5-0 (new 'stack 'curve))) + (cond + ((not arg0) + (the-as (state camera-slave) #f) + ) + ((res-lump-struct arg0 'pivot structure) + cam-circular + ) + ((res-lump-struct arg0 'align structure) + cam-standoff-read-entity + ) + ((get-curve-data! arg0 s5-0 'campath 'campath-k -1000000000.0) + (if (logtest? (cam-slave-get-flags arg0 'flags) 4) + cam-tube-sled + cam-spline + ) + ) + ((< 0.0 (cam-slave-get-float arg0 'stringMaxLength 0.0)) + cam-string + ) + (else + cam-fixed-read-entity + ) + ) + ) + ) + +;; definition for function parameter-ease-none +(defun parameter-ease-none ((arg0 object)) + arg0 + ) + +;; definition for function parameter-ease-clamp +(defun parameter-ease-clamp ((arg0 float)) + (cond + ((>= arg0 1.0) + (set! arg0 1.0) + ) + ((>= 0.0 arg0) + (set! arg0 0.0) + ) + ) + arg0 + ) + +;; definition for function parameter-ease-lerp-clamp +(defun parameter-ease-lerp-clamp ((arg0 float)) + (cond + ((>= arg0 1.0) + 1.0 + ) + ((>= 0.0 arg0) + 0.0 + ) + ((>= 0.25 arg0) + (* 0.5 arg0) + ) + ((>= arg0 0.75) + (- 1.0 (* 0.5 (- 1.0 arg0))) + ) + (else + (+ 0.125 (* 1.5 (+ -0.25 arg0))) + ) + ) + ) + +;; definition for function parameter-ease-sqrt-clamp +(defun parameter-ease-sqrt-clamp ((arg0 float)) + (cond + ((>= arg0 1.0) + 1.0 + ) + ((>= 0.0 arg0) + 0.0 + ) + ((>= 0.5 arg0) + (* 0.5 (- 1.0 (sqrtf (- 1.0 (* 2.0 arg0))))) + ) + (else + (* 0.5 (+ 1.0 (sqrtf (+ -1.0 (* 2.0 arg0))))) + ) + ) + ) + +;; definition for function fourth-power +(defun fourth-power ((arg0 float)) + (let ((f0-2 (* arg0 arg0))) + (* f0-2 f0-2) + ) + ) + +;; definition for function third-power +(defun third-power ((arg0 float)) + (* arg0 arg0 arg0) + ) + +;; definition for function parameter-ease-sqr-clamp +(defun parameter-ease-sqr-clamp ((arg0 float)) + (cond + ((>= arg0 1.0) + 1.0 + ) + ((>= 0.0 arg0) + 0.0 + ) + ((>= 0.5 arg0) + (let ((f0-3 0.5) + (f1-4 (* 2.0 arg0)) + ) + (* f0-3 (* f1-4 f1-4)) + ) + ) + (else + (let ((f0-5 1.0) + (f1-7 0.5) + (f2-2 (* 2.0 (- 1.0 arg0))) + ) + (- f0-5 (* f1-7 (* f2-2 f2-2))) + ) + ) + ) + ) + +;; definition for function parameter-ease-cube-clamp +(defun parameter-ease-cube-clamp ((arg0 float)) + (cond + ((>= arg0 1.0) + 1.0 + ) + ((>= 0.0 arg0) + 0.0 + ) + ((>= 0.5 arg0) + (* 0.5 (third-power (* 2.0 arg0))) + ) + (else + (- 1.0 (* 0.5 (third-power (* 2.0 (- 1.0 arg0))))) + ) + ) + ) + +;; definition for function parameter-ease-sin-clamp +(defun parameter-ease-sin-clamp ((arg0 float)) + (cond + ((>= arg0 1.0) + 1.0 + ) + ((>= 0.0 arg0) + 0.0 + ) + (else + (+ 0.5 (* 0.5 (sin (* 182.04445 (+ -90.0 (* 180.0 arg0)))))) + ) + ) + ) + +;; definition for symbol *cam-res-string*, type string +(define *cam-res-string* (new 'global 'string 64 (the-as string #f))) + +;; definition for method 9 of type cam-index +;; INFO: Used lq/sq +(defmethod cam-index-method-9 ((this cam-index) (arg0 symbol) (arg1 entity) (arg2 vector) (arg3 curve)) + (local-vars (sv-32 (function _varargs_ object)) (sv-48 (function _varargs_ object))) + (let* ((s2-0 cam-slave-get-flags) + (s0-0 arg1) + (v1-0 arg0) + (a1-1 + (cond + ((= v1-0 'focalpull) + 'focalpull-flags + ) + ((= v1-0 'campoints) + 'campoints-flags + ) + (else + (set! sv-32 format) + (let ((a0-4 (clear *cam-res-string*)) + (a1-2 "~S-flags") + (a2-1 arg0) + ) + (sv-32 a0-4 a1-2 a2-1) + ) + (format 0 "WARNING: cam-index-init is using string->symbol to build symbol ~A at runtime.~%" *cam-res-string*) + (string->symbol *cam-res-string*) + ) + ) + ) + ) + (set! (-> this flags) (the-as cam-index-options (s2-0 s0-0 a1-1))) + ) + (let* ((s2-1 (res-lump-data arg1 arg0 pointer)) + (s0-1 (method-of-type res-lump get-property-struct)) + (v1-4 arg0) + (a1-5 + (cond + ((= v1-4 'focalpull) + 'focalpull-offset + ) + ((= v1-4 'campoints) + 'campoints-offset + ) + (else + (set! sv-48 format) + (let ((a0-12 (clear *cam-res-string*)) + (a1-6 "~S-offset") + ) + (sv-48 a0-12 a1-6 arg0) + ) + (format 0 "WARNING: cam-index-init is using string->symbol to build symbol ~A at runtime.~%" *cam-res-string*) + (string->symbol *cam-res-string*) + ) + ) + ) + (v0-10 + (s0-1 arg1 a1-5 'interp -1000000000.0 (the-as structure #f) (the-as (pointer res-tag) #f) *res-static-buf*) + ) + ) + (cond + (s2-1 + (cond + (v0-10 + (vector+! (the-as vector (-> this vec)) (the-as vector (&+ s2-1 0)) (the-as vector v0-10)) + (vector+! (-> this vec 1) (the-as vector (&+ s2-1 16)) (the-as vector v0-10)) + ) + (else + (set! (-> this vec 0 quad) (-> (the-as (pointer uint128) (&+ s2-1 0)))) + (set! (-> this vec 1 quad) (-> (the-as (pointer uint128) (&+ s2-1 16)))) + ) + ) + ) + (arg3 + (set! (-> this vec 0 quad) (-> arg3 cverts 0 quad)) + (set! (-> this vec 1 quad) (-> arg3 cverts (+ (-> arg3 num-cverts) -1) quad)) + ) + (else + (return #f) + ) + ) + ) + (let ((v1-14 (new-stack-vector0))) + 0.0 + (cond + ((logtest? (-> this flags) (cam-index-options RADIAL)) + (vector-! v1-14 (-> this vec 1) arg2) + (set! (-> this vec 1 w) (vector-length v1-14)) + (vector-! v1-14 (the-as vector (-> this vec)) arg2) + (set! (-> this vec 1 x) (vector-length v1-14)) + (set! (-> this vec 1 w) (- (-> this vec 1 w) (-> this vec 1 x))) + (set! (-> this vec 0 quad) (-> arg2 quad)) + ) + ((logtest? (-> this flags) (cam-index-options SPHERICAL)) + (vector-! v1-14 (-> this vec 1) arg2) + (set! (-> this vec 1 w) (vector-length v1-14)) + (vector-! v1-14 (the-as vector (-> this vec)) arg2) + (set! (-> this vec 1 x) (vector-length v1-14)) + (set! (-> this vec 1 w) (- (-> this vec 1 w) (-> this vec 1 x))) + (set! (-> this vec 0 quad) (-> arg2 quad)) + ) + (else + (vector-! (-> this vec 1) (-> this vec 1) (the-as vector (-> this vec))) + (set! (-> this vec 1 w) (vector-normalize-ret-len! (-> this vec 1) 1.0)) + ) + ) + ) + #t + ) + +;; definition for method 10 of type cam-index +;; INFO: Used lq/sq +(defmethod cam-index-method-10 ((this cam-index) (arg0 vector)) + (let ((s5-0 (new-stack-vector0))) + 0.0 + (vector-! s5-0 arg0 (the-as vector (-> this vec))) + (cond + ((logtest? (-> this flags) (cam-index-options RADIAL)) + (vector-flatten! s5-0 s5-0 (-> *camera* local-down)) + (/ (- (vector-length s5-0) (-> this vec 1 x)) (-> this vec 1 w)) + ) + ((logtest? (-> this flags) (cam-index-options SPHERICAL)) + (/ (- (vector-length s5-0) (-> this vec 1 x)) (-> this vec 1 w)) + ) + (else + (/ (vector-dot s5-0 (-> this vec 1)) (-> this vec 1 w)) + ) + ) + ) + ) + +;; definition for method 10 of type tracking-spline +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs none. +(defmethod tracking-spline-method-10 ((this tracking-spline) (arg0 vector)) + (set! (-> this point 0 position quad) (-> arg0 quad)) + (set! (-> this point 0 next) -134250495) + (set! (-> this summed-len) 0.0) + (set! (-> this free-point) 1) + (set! (-> this used-point) 0) + (set! (-> this partial-point) 0.0) + (set! (-> this end-point) 0) + (set! (-> this next-to-last-point) -134250495) + (set! (-> this max-move) 0.0) + (set! (-> this sample-len) 0.0) + (set! (-> this used-count) 1) + (set! (-> this old-position quad) (-> arg0 quad)) + (let ((v1-6 1)) + (while (!= v1-6 31) + (set! (-> this point v1-6 next) (+ v1-6 1)) + (+! v1-6 1) + ) + (set! (-> this point v1-6 next) -134250495) + ) + 0 + (none) + ) + +;; definition for method 13 of type tracking-spline +;; WARN: Return type mismatch int vs none. +(defmethod tracking-spline-method-13 ((this tracking-spline) (arg0 int)) + (let ((v1-3 (-> this point arg0 next))) + (cond + ((= v1-3 -134250495) + ) + ((= (-> this point v1-3 next) -134250495) + ) + (else + (set! (-> this point arg0 next) (-> this point v1-3 next)) + (set! (-> this summed-len) (- (-> this summed-len) (-> this point v1-3 tp-length))) + (set! (-> this point v1-3 next) (-> this free-point)) + (set! (-> this free-point) v1-3) + (+! (-> this point v1-3 incarnation) 1) + (let ((v1-11 (-> this point arg0 next))) + (set! (-> this summed-len) (- (-> this summed-len) (-> this point arg0 tp-length))) + (vector-! + (the-as vector (+ (the-as uint (-> this point 0 direction)) (* 48 arg0))) + (the-as vector (-> this point v1-11)) + (the-as vector (-> this point arg0)) + ) + ) + (set! (-> this point arg0 tp-length) + (vector-normalize-ret-len! (the-as vector (+ (the-as uint (-> this point 0 direction)) (* 48 arg0))) 1.0) + ) + (+! (-> this summed-len) (-> this point arg0 tp-length)) + (+! (-> this used-count) -1) + ) + ) + ) + 0 + (none) + ) + +;; definition for method 14 of type tracking-spline +;; WARN: Return type mismatch int vs none. +(defmethod tracking-spline-method-14 ((this tracking-spline) (arg0 tracking-spline-sampler)) + (let ((v1-0 (-> this used-point))) + (set! (-> this partial-point) (-> arg0 partial-pt)) + (when (= (-> this next-to-last-point) v1-0) + (set! (-> this summed-len) (-> this point v1-0 tp-length)) + (if (= (-> arg0 cur-pt) (-> this end-point)) + (set! (-> this partial-point) 0.99999) + ) + ) + (when (!= (-> arg0 cur-pt) v1-0) + (while (and (!= (-> this point v1-0 next) (-> arg0 cur-pt)) + (!= (-> this point v1-0 next) (-> this next-to-last-point)) + ) + (set! (-> this summed-len) (- (-> this summed-len) (-> this point v1-0 tp-length))) + (+! (-> this point v1-0 incarnation) 1) + (+! (-> this used-count) -1) + (set! v1-0 (-> this point v1-0 next)) + ) + (set! (-> this summed-len) (- (-> this summed-len) (-> this point v1-0 tp-length))) + (+! (-> this point v1-0 incarnation) 1) + (+! (-> this used-count) -1) + (set! (-> this point v1-0 next) (-> this free-point)) + (set! (-> this free-point) (-> this used-point)) + (set! (-> this used-point) (-> arg0 cur-pt)) + (cond + ((= (-> arg0 cur-pt) (-> this end-point)) + (set! (-> this partial-point) 0.0) + (set! (-> this summed-len) 0.0) + ) + ((= (-> arg0 cur-pt) (-> this next-to-last-point)) + (set! (-> this summed-len) (-> this point (-> this next-to-last-point) tp-length)) + ) + ) + ) + ) + 0 + (none) + ) + +;; definition for method 15 of type tracking-spline +;; WARN: Return type mismatch int vs none. +(defmethod tracking-spline-method-15 ((this tracking-spline)) + (let ((s5-0 (new 'stack-no-clear 'tracking-spline-sampler))) + (let ((a3-0 (new 'stack-no-clear 'vector))) + (set! (-> s5-0 cur-pt) (-> this used-point)) + (set! (-> s5-0 partial-pt) (-> this partial-point)) + (tracking-spline-method-19 this (-> this sample-len) a3-0 a3-0 s5-0) + ) + (if (or (= (-> s5-0 cur-pt) (-> this end-point)) + (= (-> s5-0 cur-pt) (-> this next-to-last-point)) + (= (-> this point (the-as int (-> s5-0 cur-pt)) next) (-> this next-to-last-point)) + ) + (set! (-> s5-0 cur-pt) (-> this used-point)) + ) + (let ((v1-15 (-> this point (the-as int (-> s5-0 cur-pt)) next))) + (when (!= v1-15 -134250495) + (let ((a0-14 (-> this point v1-15 next)) + (a1-1 v1-15) + (f0-2 -2.0) + ) + 0.0 + (while (not (or (= a0-14 -134250495) (= a0-14 (-> this end-point)))) + (let ((f1-2 (vector-dot + (the-as vector (+ (the-as uint (-> this point 0 direction)) (* 48 v1-15))) + (the-as vector (+ (the-as uint (-> this point 0 direction)) (* 48 a0-14))) + ) + ) + ) + (when (>= f1-2 f0-2) + (set! f0-2 f1-2) + (set! a1-1 v1-15) + ) + ) + (set! v1-15 a0-14) + (set! a0-14 (-> this point v1-15 next)) + ) + (if (< -2.0 f0-2) + (tracking-spline-method-13 this a1-1) + ) + ) + ) + ) + ) + 0 + (none) + ) + +;; definition for method 16 of type tracking-spline +;; WARN: Return type mismatch int vs none. +(defmethod tracking-spline-method-16 ((this tracking-spline) (arg0 float)) + (let ((s4-0 (new 'stack-no-clear 'tracking-spline-sampler))) + (let ((a3-0 (new 'stack-no-clear 'tracking-spline-sampler))) + (set! (-> s4-0 cur-pt) (-> this used-point)) + (set! (-> s4-0 partial-pt) (-> this partial-point)) + (tracking-spline-method-19 this (-> this sample-len) (the-as vector a3-0) (the-as vector a3-0) s4-0) + ) + (let ((s4-1 (-> this point (-> s4-0 cur-pt) next))) + (when (!= s4-1 -134250495) + (let ((v1-11 (-> this point s4-1 next))) + (while (not (or (= v1-11 -134250495) + (= (-> this point v1-11 next) -134250495) + (= (-> this point v1-11 next) (-> this end-point)) + (= (-> this point v1-11 next) (-> this next-to-last-point)) + ) + ) + (if (< (* (-> this point s4-1 tp-length) + (+ 1.0 (vector-dot + (the-as vector (+ (the-as uint (-> this point 0 direction)) (* 48 s4-1))) + (the-as vector (+ (the-as uint (-> this point 0 direction)) (* 48 v1-11))) + ) + ) + ) + arg0 + ) + (tracking-spline-method-13 this s4-1) + (set! s4-1 v1-11) + ) + (set! v1-11 (-> this point s4-1 next)) + ) + ) + ) + ) + ) + 0 + (none) + ) + +;; definition for method 17 of type tracking-spline +;; INFO: Used lq/sq +(defmethod tracking-spline-method-17 ((this tracking-spline) (arg0 vector) (arg1 float) (arg2 float) (arg3 symbol)) + (let ((s3-0 (-> this free-point)) + (s2-0 (-> this end-point)) + ) + (vector-! + (the-as vector (+ (the-as uint (-> this point 0 direction)) (* 48 s2-0))) + arg0 + (the-as vector (-> this point s2-0)) + ) + (set! (-> this point s2-0 tp-length) + (vector-normalize-ret-len! (the-as vector (+ (the-as uint (-> this point 0 direction)) (* 48 s2-0))) 1.0) + ) + (if (< (-> this point s2-0 tp-length) arg1) + (return 0) + ) + (when (and arg3 (= s3-0 -134250495)) + (tracking-spline-method-15 this) + (set! s3-0 (-> this free-point)) + ) + (cond + ((= s3-0 -134250495) + (format 0 "ERROR : pos spline overflow~%") + ) + (else + (+! (-> this summed-len) (-> this point s2-0 tp-length)) + (set! (-> this free-point) (-> this point s3-0 next)) + (set! (-> this point s2-0 next) s3-0) + (set! (-> this end-point) s3-0) + (set! (-> this next-to-last-point) s2-0) + (set! (-> this point s3-0 next) -134250495) + (set! (-> this point s3-0 position quad) (-> arg0 quad)) + (+! (-> this used-count) 1) + (if (< 0.0 arg2) + (tracking-spline-method-16 this arg2) + ) + ) + ) + ) + 0 + ) + +;; definition for method 18 of type tracking-spline +;; WARN: new jak 2 until loop case, check carefully +(defmethod tracking-spline-method-18 ((this tracking-spline) (arg0 float) (arg1 vector) (arg2 vector) (arg3 tracking-spline-sampler)) + (local-vars (f0-4 float)) + (when (not arg3) + (set! arg3 (new 'stack-no-clear 'tracking-spline-sampler)) + (set! (-> arg3 cur-pt) (-> this used-point)) + (set! (-> arg3 partial-pt) (-> this partial-point)) + ) + 0.0 + (until #f + (cond + ((= (-> arg3 cur-pt) (-> this end-point)) + (set! (-> arg3 partial-pt) 0.0) + (vector+! arg1 arg1 (the-as vector (-> this point (-> arg3 cur-pt)))) + (return arg1) + ) + ((begin (set! f0-4 (+ (-> arg3 partial-pt) (/ arg0 (-> this point (-> arg3 cur-pt) tp-length)))) (< f0-4 1.0)) + (set! (-> arg3 partial-pt) f0-4) + (let ((s2-0 (new 'stack-no-clear 'vector))) + (let ((v1-13 (-> this point (-> arg3 cur-pt) next))) + (vector-lerp! + s2-0 + (the-as vector (-> this point (-> arg3 cur-pt))) + (the-as vector (-> this point v1-13)) + f0-4 + ) + ) + (vector+! arg1 arg1 s2-0) + ) + (vector+! arg2 arg2 (the-as vector (+ (the-as uint (-> this point 0 direction)) (* 48 (-> arg3 cur-pt))))) + (return arg1) + ) + (else + (let ((f0-7 (* (- 1.0 (-> arg3 partial-pt)) (-> this point (-> arg3 cur-pt) tp-length)))) + (set! arg0 (- arg0 f0-7)) + ) + (set! (-> arg3 partial-pt) 0.0) + (set! (-> arg3 cur-pt) (-> this point (-> arg3 cur-pt) next)) + ) + ) + ) + #f + (the-as vector #f) + ) + +;; definition for method 19 of type tracking-spline +(defmethod tracking-spline-method-19 ((this tracking-spline) (arg0 float) (arg1 vector) (arg2 vector) (arg3 tracking-spline-sampler)) + (vector-reset! arg1) + (vector-reset! arg2) + (tracking-spline-method-18 this arg0 arg1 arg2 arg3) + arg1 + ) + +;; definition for method 20 of type tracking-spline +;; WARN: Return type mismatch int vs none. +(defmethod tracking-spline-method-20 ((this tracking-spline) (arg0 vector) (arg1 int)) + (let ((s3-0 (new 'stack-no-clear 'vector))) + (vector-! + s3-0 + (the-as vector (-> this point (-> this used-point))) + (the-as vector (-> this point (-> this end-point))) + ) + (let* ((f0-0 (vector-length s3-0)) + (f1-1 (* 0.33333334 (- 1.5 (* 0.00024414062 f0-0)))) + ) + 0.0 + (let* ((f1-2 (fmax 0.0 f1-1)) + (f30-0 (+ 0.3 f1-2)) + (f0-1 (cond + ((< (-> *CAMERA-bank* min-detectable-velocity) (-> this summed-len)) + (vector-float*! s3-0 s3-0 (/ 1.0 f0-0)) + (/ f0-0 (-> this summed-len)) + ) + (else + (vector-reset! s3-0) + 0.0 + ) + ) + ) + (f0-2 (+ -0.2 f0-1)) + (f0-3 (* 2.0 f0-2)) + (f28-0 (fmin 1.0 (fmax 0.05 f0-3))) + (v1-18 (-> this used-point)) + (s2-0 (new 'stack-no-clear 'vector)) + ) + (while (and (!= v1-18 (-> this end-point)) (!= v1-18 (-> this next-to-last-point)) (!= v1-18 arg1)) + (let ((s1-0 (-> this point v1-18 next))) + (vector-! + s2-0 + (the-as vector (+ (the-as uint (-> this point 0 direction)) (* 48 s1-0))) + (the-as vector (+ (the-as uint (-> this point 0 direction)) (* 48 v1-18))) + ) + (let* ((f0-5 (vector-normalize-ret-len! s2-0 1.0)) + (f0-6 (* 0.5 f0-5)) + (f26-0 (* (fmin 1.0 f0-6) f30-0 (vector-dot arg0 s2-0))) + ) + (let ((f1-14 (vector-dot s2-0 s3-0))) + (cond + ((>= 0.0 f1-14) + ) + (else + (set! f26-0 (* f26-0 (fmax 0.0 (- 0.75 (fabs (* f28-0 f1-14)))))) + ) + ) + ) + (cond + ((< f26-0 0.0) + (if (and *debug-segment* *display-camera-marks*) + (camera-line-rel-len + (the-as vector (-> this point s1-0)) + s2-0 + (* -40.96 f26-0) + (new 'static 'vector4w :x #xff :y #xff :w #x80) + ) + ) + (vector--float*! arg0 arg0 s2-0 f26-0) + ) + ((and *debug-segment* *display-camera-marks*) + (camera-line-rel-len + (the-as vector (-> this point s1-0)) + s2-0 + (* 40.96 f26-0) + (new 'static 'vector4w :x #x80 :y #x80 :w #x80) + ) + ) + ) + ) + (set! v1-18 s1-0) + ) + ) + ) + ) + ) + 0 + (none) + ) + +;; definition for method 21 of type tracking-spline +;; INFO: Used lq/sq +(defmethod tracking-spline-method-21 ((this tracking-spline) (arg0 vector) (arg1 float) (arg2 float) (arg3 float) (arg4 float) (arg5 vector)) + (with-pp + (let ((v1-0 (-> this used-point)) + (f0-0 (-> this partial-point)) + ) + (let ((f1-0 (-> this summed-len))) + 0.0 + 0.0 + (let* ((f2-6 (* (- (- f1-0 (* f0-0 (-> this point v1-0 tp-length))) arg4) arg3)) + (f2-9 (* (fmin arg1 (- f2-6 (-> this max-move))) (-> pp clock time-adjust-ratio))) + ) + (set! (-> this max-move) (fmin arg2 (+ (-> this max-move) f2-9))) + ) + ) + (set! (-> this max-move) (fmax 0.0 (-> this max-move))) + (let ((f1-9 (-> this summed-len))) + 0.0 + (let* ((f1-10 (- f1-9 (* f0-0 (-> this point v1-0 tp-length)))) + (f1-12 (fmin 204.8 (- f1-10 (-> this sample-len)))) + ) + (set! (-> this sample-len) (fmin 16384.0 (+ (-> this sample-len) f1-12))) + ) + ) + (let ((s3-0 (new 'stack-no-clear 'tracking-spline-sampler))) + (set! (-> s3-0 cur-pt) v1-0) + (set! (-> s3-0 partial-pt) f0-0) + (if (not arg5) + (set! arg5 (new 'static 'vector)) + ) + (tracking-spline-method-19 this (* (-> this max-move) (-> pp clock time-adjust-ratio)) arg0 arg5 s3-0) + (tracking-spline-method-14 this s3-0) + (dotimes (s2-0 63) + (tracking-spline-method-18 this (* 0.015625 (-> this sample-len)) arg0 arg5 s3-0) + ) + (vector-float*! arg0 arg0 0.015625) + (vector-float*! arg5 arg5 0.015625) + (let ((a2-3 (-> s3-0 cur-pt))) + (set! (-> this debug-last-point) a2-3) + (let ((s4-1 (new 'stack-no-clear 'vector))) + (set! (-> this debug-old-position quad) (-> this old-position quad)) + (set! (-> this debug-out-position quad) (-> arg0 quad)) + (vector-! s4-1 arg0 (-> this old-position)) + (tracking-spline-method-20 this s4-1 a2-3) + (vector+! arg0 (-> this old-position) s4-1) + ) + ) + ) + ) + (set! (-> this old-position quad) (-> arg0 quad)) + arg0 + ) + ) + +;; definition for method 22 of type tracking-spline +;; WARN: Return type mismatch int vs symbol. +(defmethod tracking-spline-method-22 ((this tracking-spline) (arg0 float)) + (when (< arg0 (-> this summed-len)) + (let ((s5-0 (new 'stack-no-clear 'tracking-spline-sampler))) + (let ((a3-0 (new 'stack-no-clear 'vector))) + (set! (-> s5-0 cur-pt) (-> this used-point)) + (set! (-> s5-0 partial-pt) 0.0) + (tracking-spline-method-19 this (- (-> this summed-len) arg0) a3-0 a3-0 s5-0) + ) + (tracking-spline-method-14 this s5-0) + ) + ) + (the-as symbol 0) + ) + +;; definition for method 9 of type tracking-spline +;; WARN: Return type mismatch int vs none. +(defmethod tracking-spline-method-9 ((this tracking-spline)) + (let ((v1-0 (-> this used-point)) + (s4-0 0) + (s5-0 0) + ) + (while (!= v1-0 -134250495) + (set! s5-0 (logior s5-0 (ash 1 v1-0))) + (+! s4-0 1) + (set! v1-0 (-> this point v1-0 next)) + ) + (when (!= s4-0 (-> this used-count)) + (if *debug-segment* + (format 0 "ERROR: tracking spline used count ~D actual ~D~%" (-> this used-count) s4-0) + ) + (set! (-> this used-count) s4-0) + ) + (let ((v1-9 (-> this free-point)) + (a3-1 0) + ) + (while (!= v1-9 -134250495) + (+! a3-1 1) + (set! v1-9 (-> this point v1-9 next)) + ) + (when (!= a3-1 (- 32 (-> this used-count))) + (if *debug-segment* + (format 0 "ERROR: tracking spline free count ~D actual ~D~%" (- 32 (-> this used-count)) a3-1) + ) + (set! (-> this free-point) -134250495) + (dotimes (v1-21 32) + (when (not (logtest? s5-0 1)) + (set! (-> this point v1-21 next) (-> this free-point)) + (set! (-> this free-point) v1-21) + ) + (set! s5-0 (shr s5-0 1)) + ) + ) + ) + ) + 0 + (none) + ) + +;; definition for function cam-slave-init-vars +;; INFO: Used lq/sq +;; WARN: Return type mismatch quaternion vs none. +(defbehavior cam-slave-init-vars camera-slave () + (cond + (*camera* + (set! (-> self options) (-> *camera* slave-options)) + ) + (else + (set! (-> self options) (cam-slave-options-u32)) + 0 + ) + ) + (cond + (*camera-combiner* + (set! (-> self trans quad) (-> *camera-combiner* trans quad)) + (let* ((v1-7 (-> self tracking)) + (a3-0 (-> *camera-combiner* inv-camera-rot)) + (a0-1 (-> a3-0 rvec quad)) + (a1-0 (-> a3-0 uvec quad)) + (a2-0 (-> a3-0 fvec quad)) + (a3-1 (-> a3-0 trans quad)) + ) + (set! (-> v1-7 inv-mat rvec quad) a0-1) + (set! (-> v1-7 inv-mat uvec quad) a1-0) + (set! (-> v1-7 inv-mat fvec quad) a2-0) + (set! (-> v1-7 inv-mat trans quad) a3-1) + ) + (when *camera-init-mat* + (let* ((a2-1 (-> self tracking)) + (a3-2 *camera-init-mat*) + (v1-10 (-> a3-2 rvec quad)) + (a0-2 (-> a3-2 uvec quad)) + (a1-1 (-> a3-2 fvec quad)) + (a3-3 (-> a3-2 trans quad)) + ) + (set! (-> a2-1 inv-mat rvec quad) v1-10) + (set! (-> a2-1 inv-mat uvec quad) a0-2) + (set! (-> a2-1 inv-mat fvec quad) a1-1) + (set! (-> a2-1 inv-mat trans quad) a3-3) + ) + ) + (set! (-> self fov) (-> *camera-combiner* fov)) + (set! (-> self velocity quad) (-> *camera-combiner* velocity quad)) + ) + (else + (vector-reset! (-> self trans)) + (matrix-identity! (the-as matrix (-> self tracking))) + (set! (-> self fov) 11650.845) + (vector-reset! (-> self velocity)) + ) + ) + (set! (-> self time-dist-too-far) (the-as uint 0)) + (set! (-> self intro-t) 1.0) + (set! (-> self intro-t-step) 0.0) + (set! (-> self spline-exists) #f) + (set! (-> self los-state) (slave-los-state none)) + (set! (-> self enter-has-run) #f) + (set! (-> self cam-entity) #f) + (set! (-> self tracking no-follow) #f) + (init (-> self tracking tilt-adjust) (-> *CAMERA-bank* default-tilt-adjust) 9.102222 91.022224 0.25) + (init + (-> self tracking follow-height-extra) + (-> *setting-control* cam-current extra-follow-height) + 81.92 + 819.2 + 0.5 + ) + (set! (-> self tracking follow-blend) 1.0) + (set! (-> self have-phony-joystick) #f) + (set! (-> self string-val-locked) #f) + (set! (-> self string-relative) #f) + (set! (-> self butt-timer) 0) + (set! (-> self butt-seek) #f) + (init (-> self tracking point-of-interest-blend) 0.0 0.005 0.02 0.125) + (init (-> self tracking underwater-blend) 0.0 0.007 0.03 0.125) + (tracking-spline-method-10 (-> self position-spline) (-> self trans)) + (init (-> self slope-adjust) 0.0 0.001 0.01 0.9) + (quaternion-identity! (-> self slope-quat)) + (none) + ) + +;; definition for function cam-slave-go +;; WARN: Return type mismatch int vs none. +(defbehavior cam-slave-go camera-slave ((arg0 (state camera-slave))) + (cam-slave-init-vars) + (go arg0) + 0 + (none) + ) + +;; definition for function cam-slave-init +;; WARN: Return type mismatch int vs none. +(defbehavior cam-slave-init camera-slave ((arg0 (state camera-slave)) (arg1 entity)) + (stack-size-set! (-> self main-thread) 512) + (if (and (nonzero? camera-slave-debug) *debug-segment*) + (add-connection *debug-engine* self camera-slave-debug self #f #f) + ) + (cam-slave-init-vars) + (set! (-> self cam-entity) arg1) + (let ((t9-3 (-> arg0 enter))) + (if t9-3 + (t9-3) + ) + ) + (set! (-> self enter-has-run) #t) + (set! (-> self event-hook) (-> arg0 event)) + (go arg0) + 0 + (none) + ) + +;; definition for function cam-standard-event-handler +(defbehavior cam-standard-event-handler camera-slave ((arg0 process) (arg1 int) (arg2 symbol) (arg3 event-message-block)) + (case arg2 + (('go) + (format 0 "ERROR : slave cameras no longer support the 'go' event~%") + ) + (('change-state) + (let ((gp-0 (the-as object (-> arg3 param 0)))) + (cam-slave-init-vars) + (let ((t9-2 (-> (the-as (state camera-slave) gp-0) enter))) + (if t9-2 + (t9-2) + ) + ) + (set! (-> self enter-has-run) #t) + (set! (-> self event-hook) (-> (the-as (state camera-slave) gp-0) event)) + (go (the-as (state camera-slave) gp-0)) + ) + ) + (('teleport) + (jump-to-target! (-> self tracking point-of-interest-blend) 0.0) + (cam-calc-follow! (-> self tracking) (-> self trans) #f) + (slave-set-rotation! (-> self tracking) (-> self trans) (-> self options) (-> self fov) #f) + ) + ) + ) + +;; definition for function cam-curve-pos +;; INFO: Used lq/sq +(defbehavior cam-curve-pos camera-slave ((arg0 vector) (arg1 vector) (arg2 curve) (arg3 symbol)) + (let ((s5-0 (new-stack-vector0))) + 0.0 + (let ((s2-0 (new-stack-vector0))) + (if arg1 + (set! (-> arg1 w) 0.0) + ) + (when (< (-> self intro-t) 1.0) + (+! (-> self intro-t) (* (-> self intro-t-step) (-> self clock time-adjust-ratio))) + (if (< 1.0 (-> self intro-t)) + (set! (-> self intro-t) 1.0) + ) + (curve-get-pos! s5-0 (parameter-ease-sin-clamp (-> self intro-t)) (-> self intro-curve)) + (vector+! s5-0 s5-0 (-> self intro-offset)) + (vector+! arg0 arg0 s5-0) + (cond + ((not arg1) + ) + ((< (-> self intro-t) 0.5) + (curve-get-pos! s2-0 (+ 0.0001 (parameter-ease-sin-clamp (-> self intro-t))) (-> self intro-curve)) + (vector+! s2-0 s2-0 (-> self intro-offset)) + (vector-! arg1 s2-0 s5-0) + (set! (-> arg1 w) 1.0) + ) + (else + (curve-get-pos! s2-0 (+ -0.0001 (parameter-ease-sin-clamp (-> self intro-t))) (-> self intro-curve)) + (vector+! s2-0 s2-0 (-> self intro-offset)) + (vector-! arg1 s5-0 s2-0) + (set! (-> arg1 w) 1.0) + ) + ) + ) + ) + (cond + ((not (-> self spline-exists)) + ) + ((= (-> self spline-follow-dist) 0.0) + (let ((f0-18 (if arg3 + (cam-index-method-10 (-> self index) (-> self tracking follow-pt)) + (cam-index-method-10 (-> self index) (-> *camera* tpos-curr-adj)) + ) + ) + ) + (if (logtest? (cam-slave-options-u32 EASE_SPLINE_IDX) (-> self options)) + (set! f0-18 (parameter-ease-sin-clamp f0-18)) + ) + (curve-get-pos! s5-0 f0-18 (-> self spline-curve)) + ) + (vector+! s5-0 s5-0 (-> self spline-offset)) + (vector+! arg0 arg0 s5-0) + ) + (else + (let ((s3-1 (new 'stack-no-clear 'vector))) + (curve-length (-> self spline-curve)) + (if arg3 + (set! (-> s3-1 quad) (-> self tracking follow-pt quad)) + (set! (-> s3-1 quad) (-> *camera* tpos-curr-adj quad)) + ) + (let ((f0-22 + (curve-closest-point (-> self spline-curve) s3-1 (-> self spline-tt) 40960.0 10 (-> self spline-follow-dist)) + ) + ) + (set! (-> self spline-tt) (fmin 1.0 f0-22)) + ) + ) + (curve-get-pos! s5-0 (-> self spline-tt) (-> self spline-curve)) + (vector+! s5-0 s5-0 (-> self spline-offset)) + (vector+! arg0 arg0 s5-0) + ) + ) + ) + arg0 + ) + +;; definition for function cam-curve-setup +;; WARN: Return type mismatch int vs none. +(defbehavior cam-curve-setup camera-slave ((arg0 vector)) + (when (get-curve-data! (-> self cam-entity) (-> self spline-curve) 'campath 'campath-k -1000000000.0) + (curve-get-pos! (-> self spline-offset) 0.0 (-> self spline-curve)) + (vector-negate! (-> self spline-offset) (-> self spline-offset)) + (cam-index-method-9 (-> self index) 'campoints (-> self cam-entity) arg0 (-> self spline-curve)) + (set! (-> self spline-exists) #t) + ) + (cond + ((get-curve-data! (-> self cam-entity) (-> self intro-curve) 'intro 'intro-k -1000000000.0) + (curve-get-pos! (-> self intro-offset) 1.0 (-> self intro-curve)) + (vector-negate! (-> self intro-offset) (-> self intro-offset)) + (set! (-> self intro-t) 0.0) + (set! (-> self intro-t-step) (cam-slave-get-intro-step (-> self cam-entity))) + (set! (-> self outro-exit-value) (cam-slave-get-float (-> self cam-entity) 'intro-exitValue 0.0)) + (if (= (-> self outro-exit-value) 0.0) + (set! (-> self outro-exit-value) 0.5) + ) + ) + (else + (set! (-> self intro-t) 1.0) + (set! (-> self intro-t-step) 0.0) + ) + ) + (if (-> *camera* settings no-intro) + (set! (-> self intro-t) 1.0) + ) + 0 + (none) + ) + +;; definition for function cam-calc-follow! +;; INFO: Used lq/sq +;; ERROR: Stack slot load at 144 mismatch: defined as size 4, got size 16 +;; ERROR: Stack slot load at 160 mismatch: defined as size 4, got size 16 +;; ERROR: Stack slot load at 144 mismatch: defined as size 4, got size 16 +;; ERROR: Stack slot load at 160 mismatch: defined as size 4, got size 16 +;; ERROR: Stack slot load at 144 mismatch: defined as size 4, got size 16 +;; ERROR: Stack slot load at 160 mismatch: defined as size 4, got size 16 +;; ERROR: Stack slot load at 144 mismatch: defined as size 4, got size 16 +;; ERROR: Stack slot load at 160 mismatch: defined as size 4, got size 16 +;; ERROR: Stack slot load at 144 mismatch: defined as size 4, got size 16 +;; ERROR: Stack slot load at 160 mismatch: defined as size 4, got size 16 +;; ERROR: Stack slot load at 144 mismatch: defined as size 4, got size 16 +;; ERROR: Stack slot load at 160 mismatch: defined as size 4, got size 16 +;; ERROR: Stack slot load at 144 mismatch: defined as size 4, got size 16 +;; ERROR: Stack slot load at 160 mismatch: defined as size 4, got size 16 +(defun cam-calc-follow! ((arg0 cam-rotation-tracker) (arg1 vector) (arg2 symbol)) + (local-vars (sv-128 (function float float float float)) (sv-144 float) (sv-160 float)) + (with-pp + (cond + (arg2 + (update! (-> arg0 tilt-adjust) 0.0) + (update! (-> arg0 point-of-interest-blend) 0.0) + (update! (-> arg0 underwater-blend) 0.0) + ) + (else + (set! (-> arg0 old-cam-trans quad) (-> arg1 quad)) + (jump-to-target! (-> arg0 tilt-adjust) 0.0) + (jump-to-target! (-> arg0 point-of-interest-blend) 0.0) + (jump-to-target! (-> arg0 underwater-blend) 0.0) + ) + ) + (set! (-> arg0 follow-height-extra target) (-> *camera* settings extra-follow-height)) + (let ((s4-0 (new 'stack-no-clear 'vector))) + (set! (-> s4-0 quad) (-> arg0 follow-pt quad)) + (cond + ((logtest? (-> *camera* settings slave-options) (cam-slave-options BIKE_MODE)) + (let ((s1-0 (new 'stack-no-clear 'vector)) + (s0-0 (new 'stack-no-clear 'vector)) + (f30-0 (vector-vector-distance (-> *camera* tpos-curr-adj) (-> *camera* tpos-old-adj))) + (s2-0 (new 'stack-no-clear 'vector)) + ) + (vector-flatten! s1-0 (-> *camera* tgt-face-mat fvec) (-> *camera* local-down)) + (vector-normalize! s1-0 1.0) + (vector-! s0-0 (-> *camera* tpos-curr-adj) arg1) + (vector-flatten! s0-0 s0-0 (-> *camera* local-down)) + (vector-normalize! s0-0 1.0) + (vector-float*! s2-0 (-> *camera* tgt-face-mat fvec) 32768.0) + (set! sv-128 lerp-clamp) + (set! sv-144 (the-as float 0.7)) + (set! sv-160 (the-as float 0.4)) + (let* ((a2-3 (parameter-ease-sin-clamp (* 0.00081380206 (+ -409.6 f30-0)))) + (f30-1 (sv-128 sv-144 sv-160 a2-3)) + (f0-7 (acos (vector-dot s0-0 s1-0))) + (f28-0 (fmax 1820.4445 f0-7)) + ) + (if (< f28-0 8192.0) + (vector-float*! + s2-0 + s2-0 + (+ f30-1 + (* (/ (- 1.0 f30-1) (- 1.0 (cos 32768.0))) (+ (- (cos 32768.0)) (cos (* 5.142857 (- 8192.0 f28-0))))) + ) + ) + ) + ) + (cond + ((< (-> *camera* ease-t) 1.0) + ) + ((< (-> arg0 follow-blend) 1.0) + (let* ((f0-21 (-> arg0 follow-blend)) + (f0-22 (* f0-21 f0-21)) + (f0-23 (* f0-22 f0-22)) + ) + (vector-! s2-0 s2-0 (-> arg0 follow-off)) + (vector-float*! s2-0 s2-0 f0-23) + ) + (+! (-> arg0 follow-blend) (* 0.016666668 (-> pp clock time-adjust-ratio))) + (vector+! (-> arg0 follow-off) (-> arg0 follow-off) s2-0) + ) + (else + (set! (-> arg0 follow-off quad) (-> s2-0 quad)) + ) + ) + ) + (cond + (arg2 + (if (logtest? (cam-slave-options VERTICAL_FOLLOW_MATCHES_CAMERA) (-> *camera* settings slave-options)) + (set! (-> arg0 follow-height-extra vel) 0.0) + (update! (-> arg0 follow-height-extra) 0.0) + ) + ) + (else + (jump-to-target! (-> arg0 follow-height-extra) 0.0) + ) + ) + (vector+! (-> arg0 follow-pt) (-> *camera* tpos-curr-adj) (-> arg0 follow-off)) + (vector--float*! + (-> arg0 follow-pt) + (-> arg0 follow-pt) + (-> *camera* local-down) + (+ (-> arg0 follow-height-extra value) (-> *camera* settings target-height)) + ) + ) + (else + 0.0 + (let ((s2-1 (new-stack-vector0))) + (set! (-> arg0 follow-blend) 0.0) + (cond + ((-> arg0 no-follow) + (vector-reset! s2-1) + ) + (else + (vector-! s2-1 (-> *camera* tpos-curr-adj) arg1) + (vector-normalize! s2-1 1.0) + (let* ((f0-32 (vector-dot (-> *camera* tgt-rot-mat fvec) s2-1)) + (f30-2 (cond + ((< f0-32 0.0) + 1.0 + ) + (else + (let* ((f0-33 (* f0-32 f0-32)) + (f0-34 (- 1.0 f0-33)) + ) + (* f0-34 (* f0-34 f0-34)) + ) + ) + ) + ) + ) + (vector-! s2-1 arg1 (-> *camera* tpos-curr-adj)) + (vector-flatten! s2-1 s2-1 (-> *camera* local-down)) + (let* ((f1-15 (* 0.000022194603 (+ -20480.0 (vector-length s2-1)))) + (f0-37 (fmax 0.0 (fmin 1.0 f1-15))) + ) + (vector-float*! s2-1 (-> *camera* tgt-rot-mat fvec) (* (lerp 2048.0 8192.0 f0-37) f30-2)) + ) + ) + ) + ) + (cond + (arg2 + (vector-seek-3d-smooth! (-> arg0 follow-off) s2-1 (* 20480.0 (seconds-per-frame)) 0.05) + (if (logtest? (cam-slave-options VERTICAL_FOLLOW_MATCHES_CAMERA) (-> *camera* settings slave-options)) + (set! (-> arg0 follow-height-extra vel) 0.0) + (update! (-> arg0 follow-height-extra) 0.0) + ) + ) + (else + (set! (-> arg0 follow-off quad) (-> s2-1 quad)) + (jump-to-target! (-> arg0 follow-height-extra) 0.0) + ) + ) + ) + (vector+! (-> arg0 follow-pt) (-> *camera* tpos-curr-adj) (-> arg0 follow-off)) + (vector--float*! + (-> arg0 follow-pt) + (-> arg0 follow-pt) + (-> *camera* local-down) + (+ (-> arg0 follow-height-extra value) (-> *camera* settings target-height)) + ) + ) + ) + (when (and arg2 (logtest? (cam-slave-options VERTICAL_FOLLOW_MATCHES_CAMERA) (-> *camera* settings slave-options))) + (let ((f0-46 + (vector-dot (-> *camera* local-down) (vector-! (new 'stack-no-clear 'vector) arg1 (-> arg0 old-cam-trans))) + ) + (f1-20 + (vector-dot (-> *camera* local-down) (vector-! (new 'stack-no-clear 'vector) (-> arg0 follow-pt) s4-0)) + ) + ) + (vector--float*! (-> arg0 follow-pt) (-> arg0 follow-pt) (-> *camera* local-down) (- f1-20 f0-46)) + ) + (vector+float*! + (-> arg0 follow-off) + (-> arg0 follow-pt) + (-> *camera* local-down) + (+ (-> arg0 follow-height-extra value) (-> *camera* settings target-height)) + ) + (vector-! (-> arg0 follow-off) (-> arg0 follow-off) (-> *camera* tpos-curr-adj)) + ) + ) + (set! (-> arg0 old-cam-trans quad) (-> arg1 quad)) + (-> arg0 follow-pt) + ) + ) + +;; definition for function mat-remove-z-rot +;; INFO: Used lq/sq +(defun mat-remove-z-rot ((arg0 matrix) (arg1 vector)) + (let ((s4-0 (new-stack-vector0))) + 0.0 + 0.0 + (let ((s5-0 (new 'stack-no-clear 'matrix))) + (set! (-> s5-0 rvec quad) (the-as uint128 0)) + (set! (-> s5-0 uvec quad) (the-as uint128 0)) + (set! (-> s5-0 fvec quad) (the-as uint128 0)) + (set! (-> s5-0 trans quad) (the-as uint128 0)) + (vector-negate! s4-0 arg1) + (vector-flatten! s4-0 s4-0 (-> arg0 fvec)) + (vector-normalize! s4-0 1.0) + (let ((f0-3 (vector-dot (-> arg0 uvec) s4-0))) + (when (< f0-3 0.99999) + (vector-cross! s4-0 (-> arg0 uvec) s4-0) + (let ((f1-1 (vector-length s4-0))) + (if (< 0.0 (vector-dot s4-0 (-> arg0 fvec))) + (set! f1-1 (- f1-1)) + ) + (matrix-axis-sin-cos! s5-0 (-> arg0 fvec) f1-1 f0-3) + ) + (matrix*! arg0 arg0 s5-0) + ) + ) + ) + ) + arg0 + ) + +;; definition for function slave-matrix-blend-2 +;; INFO: Used lq/sq +(defun slave-matrix-blend-2 ((arg0 matrix) (arg1 cam-slave-options-u32) (arg2 vector) (arg3 matrix)) + (with-pp + (let ((s1-0 (new-stack-vector0)) + (s4-0 (new-stack-quaternion0)) + ) + (let ((s2-0 (new-stack-quaternion0)) + (gp-0 (new-stack-quaternion0)) + ) + 0.0 + (let* ((f0-1 (cond + ((logtest? arg1 (cam-slave-options-u32 MOVE_SPHERICAL)) + (vector-length arg2) + ) + (else + (vector-flatten! s1-0 arg2 (-> *camera* local-down)) + (vector-length s1-0) + ) + ) + ) + (f0-3 (* 0.00048828125 (+ -1024.0 f0-1))) + ) + (cond + ((< f0-3 0.0) + (set! f0-3 0.0) + ) + ((< 1.0 f0-3) + (set! f0-3 1.0) + ) + ) + (let ((f30-0 (* f0-3 (* (-> *setting-control* cam-current matrix-blend-max-angle) (-> pp clock time-adjust-ratio)))) + ) + (matrix->quaternion s4-0 arg0) + (matrix->quaternion s2-0 arg3) + (quaternion-conjugate! gp-0 s4-0) + (quaternion*! gp-0 gp-0 s2-0) + (quaternion-normalize! gp-0) + (if (< (-> gp-0 w) 0.0) + (quaternion-negate! gp-0 gp-0) + ) + (let ((f28-0 (acos (-> gp-0 w)))) + (if (< (* f28-0 (-> *setting-control* cam-current matrix-blend-max-partial) (-> pp clock time-adjust-ratio)) + f30-0 + ) + (set! f30-0 + (* f28-0 (-> *setting-control* cam-current matrix-blend-max-partial) (-> pp clock time-adjust-ratio)) + ) + ) + (cond + ((< (-> gp-0 w) 0.9999999) + (quaternion-float*! gp-0 gp-0 (/ (sin f30-0) (sin f28-0))) + (set! (-> gp-0 w) (cos f30-0)) + ) + (else + (quaternion-identity! gp-0) + ) + ) + ) + ) + ) + (quaternion*! s4-0 s4-0 gp-0) + ) + (quaternion-normalize! s4-0) + (quaternion->matrix arg0 s4-0) + ) + ) + ) + +;; definition for function vector-into-frustum-nosmooth! +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs vector. +(defun vector-into-frustum-nosmooth! ((arg0 matrix) (arg1 vector) (arg2 float)) + (local-vars (sv-112 vector) (sv-128 vector) (sv-144 vector) (sv-160 vector) (sv-176 vector)) + (rlet ((vf0 :class vf) + (vf1 :class vf) + (vf2 :class vf) + ) + (init-vf0-vector) + (let ((s5-0 (new 'stack-no-clear 'matrix))) + (set! (-> s5-0 rvec quad) (the-as uint128 0)) + (set! (-> s5-0 uvec quad) (the-as uint128 0)) + (set! (-> s5-0 fvec quad) (the-as uint128 0)) + (set! (-> s5-0 trans quad) (the-as uint128 0)) + (let ((s3-0 (new-stack-vector0)) + (s2-0 (new-stack-vector0)) + ) + 0.0 + 0.0 + (let ((f30-0 1.0) + (s4-0 #t) + ) + 0.0 + (vector-! s3-0 (-> *camera* tpos-curr) arg1) + (let ((f26-0 (vector-length s3-0))) + (vector-flatten! s3-0 s3-0 (-> arg0 uvec)) + (vector-normalize! s3-0 1.0) + (let ((f28-0 (vector-dot s3-0 (-> arg0 rvec)))) + (set! sv-128 s2-0) + (set! sv-112 (-> arg0 rvec)) + (let ((f0-7 (* 0.8 (tan (* 0.5 arg2))))) + (.lvf vf1 (&-> sv-112 quad)) + (let ((v1-11 f0-7)) + (.mov vf2 v1-11) + ) + ) + (.add.x.vf vf1 vf0 vf0 :mask #b1000) + (.mul.x.vf vf1 vf1 vf2 :mask #b111) + (.svf (&-> sv-128 quad) vf1) + (vector+! s2-0 s2-0 (-> arg0 fvec)) + (vector-normalize! s2-0 f26-0) + (vector--float*! s2-0 s2-0 (-> arg0 rvec) 6144.0) + (vector-normalize! s2-0 1.0) + (let ((f0-9 (fmax 0.0 (vector-dot s2-0 (-> arg0 rvec))))) + (when (< f0-9 (fabs f28-0)) + (if (< f28-0 0.0) + (vector--float*! s2-0 s2-0 (-> arg0 rvec) (* 2.0 f0-9)) + ) + (matrix-from-two-vectors! s5-0 s2-0 s3-0) + (vector-matrix*! (-> arg0 fvec) (-> arg0 fvec) s5-0) + (vector-cross! (-> arg0 rvec) (-> arg0 uvec) (-> arg0 fvec)) + ) + ) + ) + ) + (vector-! s3-0 (-> *camera* tpos-curr) (-> *camera* pitch-off)) + (vector-! s3-0 s3-0 arg1) + (vector--float*! s3-0 s3-0 (-> *camera* local-down) (-> *camera* settings foot-offset)) + (vector-flatten! s3-0 s3-0 (-> arg0 rvec)) + (vector-normalize! s3-0 1.0) + (let ((f28-1 (vector-dot s3-0 (-> arg0 uvec)))) + (set! sv-160 s2-0) + (set! sv-144 (-> arg0 uvec)) + (let ((f0-16 (* 0.525 (tan (* 0.5 arg2))))) + (.lvf vf1 (&-> sv-144 quad)) + (let ((v1-32 f0-16)) + (.mov vf2 v1-32) + ) + ) + (.add.x.vf vf1 vf0 vf0 :mask #b1000) + (.mul.x.vf vf1 vf1 vf2 :mask #b111) + (.svf (&-> sv-160 quad) vf1) + (vector+! s2-0 s2-0 (-> arg0 fvec)) + (vector-normalize! s2-0 1.0) + (let ((f0-18 (vector-dot s2-0 (-> arg0 uvec)))) + (when (and (< f28-1 0.0) (< f0-18 (- f28-1))) + (vector--float*! s2-0 s2-0 (-> arg0 uvec) (* 2.0 f0-18)) + (set! f30-0 (vector-dot s2-0 s3-0)) + ) + ) + ) + (vector-! s3-0 (-> *camera* tpos-curr) (-> *camera* pitch-off)) + (vector-! s3-0 s3-0 arg1) + (vector--float*! s3-0 s3-0 (-> *camera* local-down) (-> *camera* settings head-offset)) + (vector-flatten! s3-0 s3-0 (-> arg0 rvec)) + (vector-normalize! s3-0 1.0) + (let ((f28-2 (vector-dot s3-0 (-> arg0 uvec)))) + (let ((s0-1 s2-0)) + (set! sv-176 (-> arg0 uvec)) + (let ((f0-26 (* 0.525 (tan (* 0.5 arg2))))) + (vector-float*! s0-1 sv-176 f0-26) + ) + ) + (vector+! s2-0 s2-0 (-> arg0 fvec)) + (vector-normalize! s2-0 1.0) + (let ((f0-28 (vector-dot s2-0 (-> arg0 uvec)))) + (cond + ((and (< 0.0 f28-2) (< f0-28 f28-2)) + (set! f30-0 (vector-dot s2-0 s3-0)) + (set! s4-0 #f) + ) + ((< f30-0 0.0) + (let ((f0-33 (- (vector-dot s2-0 s3-0)))) + (if (< f0-33 f30-0) + (set! f30-0 f0-33) + ) + ) + ) + ) + ) + ) + (let ((f0-35 (if s4-0 + (- (acos f30-0)) + (acos f30-0) + ) + ) + ) + (matrix-axis-angle! s5-0 (-> arg0 rvec) f0-35) + ) + ) + ) + (vector-matrix*! (-> arg0 fvec) (-> arg0 fvec) s5-0) + ) + (vector-cross! (-> arg0 uvec) (-> arg0 fvec) (-> arg0 rvec)) + (the-as vector 0) + ) + ) + +;; definition for function slave-set-rotation! +;; INFO: Used lq/sq +;; WARN: 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] +(defun slave-set-rotation! ((arg0 cam-rotation-tracker) (arg1 vector) (arg2 cam-slave-options-u32) (arg3 float) (arg4 symbol)) + (local-vars + (f0-9 float) + (sv-208 vector) + (sv-224 vector) + (sv-240 matrix) + (sv-256 (function matrix vector float vector)) + (sv-272 matrix) + (sv-288 vector) + ) + (rlet ((vf0 :class vf) + (vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + ) + (init-vf0-vector) + (if (-> *camera* settings use-look-at-point) + (set! (-> arg0 follow-pt quad) (-> *camera* settings look-at-point quad)) + ) + (let ((s0-0 (new-stack-vector0)) + (s1-0 (new 'stack-no-clear 'matrix)) + ) + (set! (-> s1-0 rvec quad) (the-as uint128 0)) + (set! (-> s1-0 uvec quad) (the-as uint128 0)) + (set! (-> s1-0 fvec quad) (the-as uint128 0)) + (set! (-> s1-0 trans quad) (the-as uint128 0)) + (let ((f30-0 (-> arg0 tilt-adjust value))) + (cond + ((< 0.0001 (-> arg0 point-of-interest-blend value)) + (set! sv-208 (new 'stack-no-clear 'vector)) + 0.0 + (vector-! s0-0 (-> arg0 follow-pt) arg1) + (let ((f28-0 (vector-length s0-0))) + (vector-! sv-208 (-> *camera* settings point-of-interest) arg1) + (vector-normalize! sv-208 (* f28-0 (-> arg0 point-of-interest-blend value))) + (let ((v1-12 s0-0)) + (let ((a0-10 s0-0)) + (.mov.vf vf6 vf0 :mask #b1000) + (.lvf vf4 (&-> a0-10 quad)) + ) + (.lvf vf5 (&-> sv-208 quad)) + (.add.vf vf6 vf4 vf5 :mask #b111) + (.svf (&-> v1-12 quad) vf6) + ) + (vector-normalize! s0-0 f28-0) + ) + (vector-! (-> arg0 looking-interesting) (-> *camera* settings point-of-interest) (-> arg0 follow-pt)) + (vector+float*! + (-> arg0 looking-interesting) + (-> arg0 follow-pt) + (-> arg0 looking-interesting) + (-> arg0 point-of-interest-blend value) + ) + ) + (else + (vector-! s0-0 (-> arg0 follow-pt) arg1) + (set! (-> arg0 looking-interesting quad) (-> arg1 quad)) + ) + ) + (vector+! (-> arg0 looking-at) s0-0 arg1) + (forward-down->inv-matrix s1-0 s0-0 (-> *camera* local-down)) + (when (!= f30-0 0.0) + 0.0 + 0.0 + (set! sv-240 (new 'stack-no-clear 'matrix)) + (set! sv-224 (new 'stack-no-clear 'vector)) + (vector-normalize-copy! sv-224 s0-0 1.0) + (let* ((v1-25 (-> *camera* local-down)) + (f0-8 (-> sv-224 x)) + (f1-1 (-> sv-224 y)) + (f2-0 (-> sv-224 z)) + (f3-0 (-> v1-25 x)) + (f4-0 (-> v1-25 y)) + (f5-0 (-> v1-25 z)) + ) + (.mula.s f0-8 f3-0) + (.madda.s f1-1 f4-0) + (.madd.s f0-9 f2-0 f5-0) + ) + (let* ((f28-1 f0-9) + (f0-11 (acos (fabs f28-1))) + ) + (cond + ((< 0.0 f30-0) + (set! f30-0 (if (< 0.0 f28-1) + (fmin f30-0 (fmax 0.0 (+ -2730.6667 f0-11))) + (fmin f30-0 (fmax 0.0 (- 32768.0 (+ 2730.6667 f0-11)))) + ) + ) + ) + ((< f30-0 0.0) + (set! f30-0 (if (< 0.0 f28-1) + (fmax f30-0 (- (fmax 0.0 (- 32768.0 (+ 2730.6667 f0-11))))) + (fmax f30-0 (- (fmax 0.0 (+ -2730.6667 f0-11)))) + ) + ) + ) + ) + ) + (matrix-rotate-x! sv-240 f30-0) + (let ((t9-6 matrix*!) + (a0-28 s1-0) + (a2-3 s1-0) + ) + (t9-6 a0-28 sv-240 a2-3) + ) + ) + ) + (when (not (-> *camera* settings use-look-at-point)) + (if (and (= (-> *camera* under-water) 2) + *target* + (not (and (-> *target* next-state) (= (-> *target* next-state name) 'target-swim-up))) + ) + (set! (-> arg0 underwater-blend target) 1.0) + (set! (-> arg0 underwater-blend target) 0.0) + ) + ) + (set! sv-256 vector-into-frustum-nosmooth!) + (set! sv-272 s1-0) + (set! sv-288 arg1) + (let ((a2-5 (lerp-clamp arg3 (* 0.25 arg3) (-> arg0 underwater-blend value)))) + (sv-256 sv-272 sv-288 a2-5) + ) + (cond + (arg4 + (slave-matrix-blend-2 (-> arg0 inv-mat) arg2 s0-0 s1-0) + ) + (else + (let* ((v1-60 (-> arg0 inv-mat)) + (a3-2 s1-0) + (a0-34 (-> a3-2 rvec quad)) + (a1-19 (-> a3-2 uvec quad)) + (a2-7 (-> a3-2 fvec quad)) + (a3-3 (-> a3-2 trans quad)) + ) + (set! (-> v1-60 rvec quad) a0-34) + (set! (-> v1-60 uvec quad) a1-19) + (set! (-> v1-60 fvec quad) a2-7) + (set! (-> v1-60 trans quad) a3-3) + ) + ) + ) + ) + (mat-remove-z-rot (-> arg0 inv-mat) (-> *camera* local-down)) + (cond + ((not (-> *camera* settings use-point-of-interest)) + (set! (-> arg0 point-of-interest-blend target) 0.0) + ) + (else + (let ((s4-2 (vector-! (new 'stack-no-clear 'vector) (-> *camera* settings point-of-interest) arg1))) + 0.0 + (vector-flatten! s4-2 s4-2 (-> arg0 inv-mat uvec)) + (vector-normalize! s4-2 1.0) + (let ((f30-1 (vector-dot s4-2 (-> arg0 inv-mat fvec)))) + (cond + ((< (cos 12743.111) f30-1) + (set! (-> arg0 point-of-interest-blend target) 1.0) + ) + ((and (< 0.0 (-> arg0 point-of-interest-blend target)) (< (cos 8192.0) f30-1)) + (set! (-> arg0 point-of-interest-blend target) 1.0) + ) + (else + (set! (-> arg0 point-of-interest-blend target) 0.0) + ) + ) + ) + ) + ) + ) + 0 + (none) + ) + ) + +;; definition for function v-slrp2! +;; INFO: Used lq/sq +;; WARN: Stack slot offset 144 signed mismatch +;; WARN: Stack slot offset 144 signed mismatch +;; WARN: Stack slot offset 144 signed mismatch +;; WARN: Stack slot offset 144 signed mismatch +;; WARN: Stack slot offset 144 signed mismatch +;; WARN: Stack slot offset 144 signed mismatch +;; WARN: Stack slot offset 144 signed mismatch +;; WARN: Stack slot offset 144 signed mismatch +;; WARN: Stack slot offset 144 signed mismatch +;; WARN: Stack slot offset 144 signed mismatch +;; 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] +(defun v-slrp2! ((arg0 vector) (arg1 vector) (arg2 vector) (arg3 float) (arg4 vector) (arg5 float)) + (local-vars + (f0-10 float) + (f28-0 float) + (f30-0 float) + (sv-144 float) + (sv-160 vector) + (sv-176 matrix) + (sv-192 vector) + ) + (set! sv-144 arg5) + (let ((s0-0 (new-stack-vector0))) + (set! sv-160 (new 'stack-no-clear 'vector)) + (set! (-> sv-160 quad) (the-as uint128 0)) + 1.0 + 1.0 + (let ((s3-0 (new-stack-vector0))) + 0.0 + 1.0 + (set! sv-176 (new 'stack-no-clear 'matrix)) + (set! (-> sv-176 rvec quad) (the-as uint128 0)) + (set! (-> sv-176 uvec quad) (the-as uint128 0)) + (set! (-> sv-176 fvec quad) (the-as uint128 0)) + (set! (-> sv-176 trans quad) (the-as uint128 0)) + (cond + ((< 1.0 arg3) + (set! arg3 1.0) + ) + ((< arg3 0.0) + (set! arg3 0.0) + ) + ) + (cond + (arg4 + (vector-flatten! s0-0 arg1 arg4) + (vector-flatten! sv-160 arg2 arg4) + (set! f30-0 (vector-normalize-ret-len! s0-0 1.0)) + (set! f28-0 (vector-normalize-ret-len! sv-160 1.0)) + (vector-normalize! (vector-cross! s3-0 sv-160 s0-0) 1.0) + (let ((f26-0 (vector-dot arg4 s3-0))) + (vector-normalize-copy! s3-0 arg4 1.0) + (if (< f26-0 0.0) + (vector-negate! s3-0 s3-0) + ) + ) + ) + (else + (set! (-> s0-0 quad) (-> arg1 quad)) + (set! (-> sv-160 quad) (-> arg2 quad)) + (set! f30-0 (vector-normalize-ret-len! s0-0 1.0)) + (set! f28-0 (vector-normalize-ret-len! sv-160 1.0)) + (vector-normalize! (vector-cross! s3-0 arg2 arg1) 1.0) + ) + ) + (let ((t9-10 acos)) + (let* ((v1-22 s0-0) + (f0-9 (-> v1-22 x)) + (f1-2 (-> v1-22 y)) + (f2-0 (-> v1-22 z)) + (f3-0 (-> sv-160 x)) + (f4-0 (-> sv-160 y)) + (f5-0 (-> sv-160 z)) + ) + (.mula.s f0-9 f3-0) + (.madda.s f1-2 f4-0) + (.madd.s f0-10 f2-0 f5-0) + ) + (let* ((f1-3 (t9-10 f0-10)) + (f0-12 (* arg3 f1-3)) + ) + (when (< sv-144 f0-12) + (set! f0-12 sv-144) + (set! arg3 (/ sv-144 f1-3)) + ) + (let* ((f0-13 (cos f0-12)) + (t9-12 matrix-axis-sin-cos!) + (a0-20 sv-176) + (a1-13 s3-0) + (f1-5 1.0) + (f2-3 f0-13) + ) + (t9-12 a0-20 a1-13 (sqrtf (- f1-5 (* f2-3 f2-3))) f0-13) + ) + ) + ) + (vector-matrix*! arg0 s0-0 sv-176) + (let ((s0-1 vector-normalize!)) + (set! sv-192 arg0) + (let ((a1-16 (lerp f30-0 f28-0 arg3))) + (s0-1 sv-192 a1-16) + ) + ) + (when arg4 + (vector+float*! arg0 arg0 s3-0 (vector-dot arg1 s3-0)) + (vector+float*! arg0 arg0 s3-0 (* arg3 (vector-dot (vector-! (new-stack-vector0) arg2 arg1) s3-0))) + ) + ) + ) + arg0 + ) + +;; definition for function v-slrp3! +;; INFO: Used lq/sq +;; WARN: Stack slot offset 144 signed mismatch +;; WARN: Stack slot offset 144 signed mismatch +;; WARN: Stack slot offset 144 signed mismatch +;; WARN: Stack slot offset 144 signed mismatch +;; WARN: Stack slot offset 144 signed mismatch +;; WARN: Stack slot offset 144 signed mismatch +;; WARN: Stack slot offset 144 signed mismatch +;; WARN: Stack slot offset 144 signed mismatch +;; WARN: Stack slot offset 144 signed mismatch +;; WARN: Stack slot offset 144 signed mismatch +;; WARN: Stack slot offset 144 signed mismatch +;; WARN: Stack slot offset 144 signed mismatch +;; WARN: Stack slot offset 144 signed mismatch +;; 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] +(defun v-slrp3! ((arg0 vector) (arg1 vector) (arg2 vector) (arg3 vector) (arg4 float)) + (local-vars (f0-7 float) (f26-0 float) (f28-0 float) (sv-144 float) (sv-160 vector)) + (set! sv-144 arg4) + (let ((s1-0 (new-stack-vector0))) + (set! sv-160 (new 'stack-no-clear 'vector)) + (set! (-> sv-160 quad) (the-as uint128 0)) + 0.0 + 0.0 + (let ((s3-0 (new-stack-vector0)) + (f30-0 1.0) + ) + 0.0 + (let ((s0-0 (new 'stack-no-clear 'matrix))) + (set! (-> s0-0 rvec quad) (the-as uint128 0)) + (set! (-> s0-0 uvec quad) (the-as uint128 0)) + (set! (-> s0-0 fvec quad) (the-as uint128 0)) + (set! (-> s0-0 trans quad) (the-as uint128 0)) + (cond + (arg3 + (vector-flatten! s1-0 arg1 arg3) + (vector-flatten! sv-160 arg2 arg3) + (set! f28-0 (vector-normalize-ret-len! s1-0 1.0)) + (set! f26-0 (vector-normalize-ret-len! sv-160 1.0)) + (vector-normalize! (vector-cross! s3-0 sv-160 s1-0) 1.0) + (let ((f24-0 (vector-dot arg3 s3-0))) + (vector-normalize-copy! s3-0 arg3 1.0) + (if (< f24-0 0.0) + (vector-negate! s3-0 s3-0) + ) + ) + ) + (else + (set! (-> s1-0 quad) (-> arg1 quad)) + (set! (-> sv-160 quad) (-> arg2 quad)) + (set! f28-0 (vector-normalize-ret-len! s1-0 1.0)) + (set! f26-0 (vector-normalize-ret-len! sv-160 1.0)) + (vector-normalize! (vector-cross! s3-0 arg2 arg1) 1.0) + ) + ) + (let ((t9-10 acos)) + (let* ((v1-10 s1-0) + (f0-6 (-> v1-10 x)) + (f1-0 (-> v1-10 y)) + (f2-0 (-> v1-10 z)) + (f3-0 (-> sv-160 x)) + (f4-0 (-> sv-160 y)) + (f5-0 (-> sv-160 z)) + ) + (.mula.s f0-6 f3-0) + (.madda.s f1-0 f4-0) + (.madd.s f0-7 f2-0 f5-0) + ) + (let ((f0-8 (t9-10 f0-7))) + (when (< sv-144 f0-8) + (set! f30-0 (/ sv-144 f0-8)) + (set! f0-8 sv-144) + ) + (let* ((f0-9 (cos f0-8)) + (t9-12 matrix-axis-sin-cos!) + (a0-20 s0-0) + (a1-13 s3-0) + (f1-3 1.0) + (f2-1 f0-9) + ) + (t9-12 a0-20 a1-13 (sqrtf (- f1-3 (* f2-1 f2-1))) f0-9) + ) + ) + ) + (vector-matrix*! arg0 s1-0 s0-0) + ) + (vector-normalize! arg0 (lerp f28-0 f26-0 f30-0)) + (when arg3 + (vector+float*! arg0 arg0 s3-0 (vector-dot arg1 s3-0)) + (vector+float*! arg0 arg0 s3-0 (* f30-0 (vector-dot (vector-! (new-stack-vector0) arg2 arg1) s3-0))) + ) + ) + ) + arg0 + ) + + + + diff --git a/test/decompiler/reference/jak3/engine/common-obs/collectables_REF.gc b/test/decompiler/reference/jak3/engine/common-obs/collectables_REF.gc index cbe00759577..a8e7eb4934e 100644 --- a/test/decompiler/reference/jak3/engine/common-obs/collectables_REF.gc +++ b/test/decompiler/reference/jak3/engine/common-obs/collectables_REF.gc @@ -972,28 +972,21 @@ :virtual #t :code (behavior () (logclear! (-> self mask) (process-mask actor-pause)) - (new 'stack 'trajectory) - (set! (-> self base y) (-> self jump-pos y)) - (let ((t9-1 (method-of-type trajectory trajectory-method-12))) - (-> self root trans) - (-> self jump-pos) - #x43960000 - -1072586060 - (t9-1) - ) - (set-time! (-> self state-time)) - (until (time-elapsed? (-> self state-time) (seconds 1)) - (the float (- (current-time) (-> self state-time))) - (let ((t9-2 (method-of-type trajectory trajectory-method-9))) - (-> self root trans) - (t9-2) - ) - (transform-post) - (common-post self) - (suspend) - (if (nonzero? (-> self skel)) - (ja :num! (loop! 0.5)) + (let ((gp-0 (new 'stack 'trajectory))) + (set! (-> self base y) (-> self jump-pos y)) + (setup-from-to-duration! gp-0 (-> self root trans) (-> self jump-pos) 300.0 -2.2755556) + (set-time! (-> self state-time)) + (until (time-elapsed? (-> self state-time) (seconds 1)) + (let ((f0-2 (the float (- (current-time) (-> self state-time))))) + (compute-trans-at-time gp-0 f0-2 (-> self root trans)) ) + (transform-post) + (common-post self) + (suspend) + (if (nonzero? (-> self skel)) + (ja :num! (loop! 0.5)) + ) + ) ) (set! (-> self root trans quad) (-> self jump-pos quad)) (set! (-> self base quad) (-> self root trans quad)) diff --git a/test/decompiler/reference/jak3/engine/common-obs/generic-obs_REF.gc b/test/decompiler/reference/jak3/engine/common-obs/generic-obs_REF.gc index 56949d23776..7ad768d1f49 100644 --- a/test/decompiler/reference/jak3/engine/common-obs/generic-obs_REF.gc +++ b/test/decompiler/reference/jak3/engine/common-obs/generic-obs_REF.gc @@ -4451,11 +4451,7 @@ (go-virtual die) ) (('reset) - (-> self sync) - (let ((t9-1 (method-of-type sync-linear sync-info-method-15))) - 0 - (t9-1) - ) + (sync-now! (-> self sync) 0.0) ) (('play) (sound-play-by-name (-> self spawn-sound) (new-sound-id) 1024 0 0 (sound-group) (-> self pos)) diff --git a/test/decompiler/reference/jak3/engine/level/bsp-h_REF.gc b/test/decompiler/reference/jak3/engine/level/bsp-h_REF.gc index cf6ea2b6df9..057300a88bd 100644 --- a/test/decompiler/reference/jak3/engine/level/bsp-h_REF.gc +++ b/test/decompiler/reference/jak3/engine/level/bsp-h_REF.gc @@ -59,6 +59,8 @@ This probably started as a very simple structure, but now it is extremely compli (actor-birth-order (pointer uint32) :offset 172) (region-trees (array drawable-tree-region-prim) :offset 188) (collide-hash collide-hash :offset 196) + (vis-spheres vector-array :offset 216) + (vis-spheres-length uint32 :offset 248) (tfrag-masks texture-masks-array :offset 256) (tfrag-closest (pointer float)) (tfrag-mask-count uint32 :overlay-at tfrag-closest) diff --git a/test/decompiler/reference/jak3/engine/level/level-h_REF.gc b/test/decompiler/reference/jak3/engine/level/level-h_REF.gc index b82a0a1f0e9..6d55cbe393f 100644 --- a/test/decompiler/reference/jak3/engine/level/level-h_REF.gc +++ b/test/decompiler/reference/jak3/engine/level/level-h_REF.gc @@ -441,7 +441,7 @@ (level-method-13 () none) (compute-memory-usage! (_type_ symbol) memory-usage-block) (level-method-15 () none) - (level-method-16 () none) + (update-vis! (_type_ level-vis-info uint (pointer uint8)) symbol) (level-method-17 () none) (level-method-18 () none) (level-method-19 () none) @@ -665,7 +665,7 @@ (level-group-method-16 () none) (level-group-method-17 () none) (level-group-method-18 () none) - (level-group-method-19 () none) + (level-update (_type_) none) (level-get-target-inside (_type_) level) (level-group-method-21 () none) (art-group-get-by-name (_type_ string (pointer level)) art-group) diff --git a/test/decompiler/reference/jak3/engine/nav/nav-control-h_REF.gc b/test/decompiler/reference/jak3/engine/nav/nav-control-h_REF.gc index 3fd3f67069f..f647b66b17f 100644 --- a/test/decompiler/reference/jak3/engine/nav/nav-control-h_REF.gc +++ b/test/decompiler/reference/jak3/engine/nav/nav-control-h_REF.gc @@ -280,7 +280,7 @@ (:methods (nav-control-method-9 () none) (nav-control-method-10 () none) - (nav-control-method-11 () none) + (find-poly-containing-point-1 (_type_ vector) nav-poly) (nav-control-method-12 () none) (nav-control-method-13 () none) (nav-control-method-14 () none) @@ -388,7 +388,3 @@ ;; failed to figure out what this is: 0 - - - - diff --git a/test/decompiler/reference/jak3/engine/physics/trajectory-h_REF.gc b/test/decompiler/reference/jak3/engine/physics/trajectory-h_REF.gc index d301cd45efc..00e54333786 100644 --- a/test/decompiler/reference/jak3/engine/physics/trajectory-h_REF.gc +++ b/test/decompiler/reference/jak3/engine/physics/trajectory-h_REF.gc @@ -9,15 +9,15 @@ (gravity meters) ) (:methods - (trajectory-method-9 () none) - (trajectory-method-10 () none) - (trajectory-method-11 () none) - (trajectory-method-12 () none) - (trajectory-method-13 () none) - (trajectory-method-14 () none) - (trajectory-method-15 () none) - (trajectory-method-16 () none) - (trajectory-method-17 () none) + (compute-trans-at-time (_type_ float vector) vector) + (compute-transv-at-time (_type_ float vector) vector) + (compute-time-until-apex (_type_) float) + (setup-from-to-duration! (_type_ vector vector float float) none) + (setup-from-to-xz-vel! (_type_ vector vector float float) none) + (setup-from-to-y-vel! (_type_ vector vector float float) none) + (setup-from-to-height! (_type_ vector vector float float) none) + (setup-from-to-duration-and-height! (_type_ vector vector float float) none) + (debug-draw (_type_) none) ) ) @@ -49,7 +49,7 @@ (:methods (new (symbol type process-drawable int float collide-spec) _type_) (initialize (_type_ process-drawable int float collide-spec) impact-control) - (impact-control-method-10 () none) + (update-from-cspace (_type_) none) (impact-control-method-11 (_type_ collide-query process pat-surface) float) ) ) @@ -98,7 +98,7 @@ (:methods (new (symbol type vector vector) _type_) (initialize (_type_ vector vector) point-tracker) - (point-tracker-method-10 () none) + (point-tracker-method-10 (_type_ vector vector vector float) vector) (point-tracker-method-11 (_type_ vector vector vector float) vector) ) ) @@ -219,13 +219,14 @@ ;; definition of type cubic-curve (deftype cubic-curve (structure) ((mat matrix :inline) + (vec vector 4 :inline :overlay-at (-> mat data 0)) ) (:methods - (cubic-curve-method-9 () none) - (cubic-curve-method-10 () none) - (cubic-curve-method-11 () none) - (cubic-curve-method-12 () none) - (cubic-curve-method-13 () none) + (cubic-curve-method-9 (_type_ vector vector vector vector) none) + (cubic-curve-method-10 (_type_ vector float) vector) + (cubic-curve-method-11 (_type_ vector float) vector) + (cubic-curve-method-12 (_type_ vector float) vector) + (debug-draw-curve (_type_) none) ) ) @@ -236,7 +237,7 @@ (goto cfg-4) ) (format #t "[~8x] ~A~%" this 'cubic-curve) - (format #t "~1Tmat: #~%" (-> this mat)) + (format #t "~1Tmat: #~%" (-> this vec)) (label cfg-4) this ) diff --git a/test/decompiler/reference/jak3/engine/physics/trajectory_REF.gc b/test/decompiler/reference/jak3/engine/physics/trajectory_REF.gc new file mode 100644 index 00000000000..4934134e9c0 --- /dev/null +++ b/test/decompiler/reference/jak3/engine/physics/trajectory_REF.gc @@ -0,0 +1,554 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition for method 9 of type trajectory +(defmethod compute-trans-at-time ((this trajectory) (arg0 float) (arg1 vector)) + (vector+float*! arg1 (-> this initial-position) (-> this initial-velocity) arg0) + (+! (-> arg1 y) (* 0.5 arg0 arg0 (-> this gravity))) + arg1 + ) + +;; definition for method 10 of type trajectory +;; INFO: Used lq/sq +(defmethod compute-transv-at-time ((this trajectory) (arg0 float) (arg1 vector)) + (set! (-> arg1 quad) (-> this initial-velocity quad)) + (+! (-> arg1 y) (* arg0 (-> this gravity))) + arg1 + ) + +;; definition for method 11 of type trajectory +(defmethod compute-time-until-apex ((this trajectory)) + (/ (- (-> this initial-velocity y)) (-> this gravity)) + ) + +;; definition for method 12 of type trajectory +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs none. +(defmethod setup-from-to-duration! ((this trajectory) (arg0 vector) (arg1 vector) (arg2 float) (arg3 float)) + (set! (-> this initial-position quad) (-> arg0 quad)) + (set! (-> this gravity) arg3) + (set! (-> this time) arg2) + (let ((f0-3 (/ (vector-vector-xz-distance arg1 arg0) arg2))) + (vector-! (-> this initial-velocity) arg1 arg0) + (vector-xz-normalize! (-> this initial-velocity) f0-3) + ) + (set! (-> this initial-velocity y) (- (/ (- (-> arg1 y) (-> arg0 y)) arg2) (* 0.5 arg2 (-> this gravity)))) + 0 + (none) + ) + +;; definition for method 13 of type trajectory +;; WARN: Return type mismatch int vs none. +(defmethod setup-from-to-xz-vel! ((this trajectory) (arg0 vector) (arg1 vector) (arg2 float) (arg3 float)) + (let ((f0-1 (/ (vector-vector-xz-distance arg1 arg0) arg2))) + (setup-from-to-duration! this arg0 arg1 f0-1 arg3) + ) + 0 + (none) + ) + +;; definition for method 14 of type trajectory +;; WARN: Return type mismatch int vs none. +(defmethod setup-from-to-y-vel! ((this trajectory) (arg0 vector) (arg1 vector) (arg2 float) (arg3 float)) + (let* ((f0-0 arg2) + (f1-3 (- (* f0-0 f0-0) (* 2.0 (- (-> arg0 y) (-> arg1 y)) arg3))) + (f0-3 900.0) + ) + (when (>= f1-3 0.0) + (let ((f0-4 (sqrtf f1-3))) + (set! f0-3 (fmax (/ (- (- arg2) f0-4) arg3) (/ (+ (- arg2) f0-4) arg3))) + ) + ) + (setup-from-to-duration! this arg0 arg1 f0-3 arg3) + ) + 0 + (none) + ) + +;; definition for method 15 of type trajectory +;; WARN: Return type mismatch int vs none. +(defmethod setup-from-to-height! ((this trajectory) (arg0 vector) (arg1 vector) (arg2 float) (arg3 float)) + (let* ((f0-1 (+ arg2 (fmax (-> arg0 y) (-> arg1 y)))) + (f1-4 (* 2.0 (- (-> arg0 y) f0-1) arg3)) + (f0-4 4096.0) + ) + (if (< 0.0 f1-4) + (set! f0-4 (sqrtf f1-4)) + ) + (setup-from-to-y-vel! this arg0 arg1 f0-4 arg3) + ) + 0 + (none) + ) + +;; definition for method 16 of type trajectory +;; WARN: Return type mismatch int vs none. +;; WARN: Function (method 16 trajectory) has a return type of none, but the expression builder found a return statement. +(defmethod setup-from-to-duration-and-height! ((this trajectory) (arg0 vector) (arg1 vector) (arg2 float) (arg3 float)) + (let ((f0-1 (- (-> arg1 y) (-> arg0 y)))) + (cond + ((= f0-1 0.0) + (let ((t9-0 (method-of-type trajectory setup-from-to-duration!)) + (v1-2 arg2) + (f0-3 (* -8.0 arg3)) + (f1-3 arg2) + ) + (t9-0 this arg0 arg1 v1-2 (/ f0-3 (* f1-3 f1-3))) + ) + (return 0) + ) + ((and (< 0.0 f0-1) (< 0.0 arg3) (< arg3 f0-1)) + (set! arg3 f0-1) + ) + ((and (< f0-1 0.0) (< arg3 0.0) (< f0-1 arg3)) + (set! arg3 f0-1) + ) + ) + (let* ((f1-14 (/ (- arg3 f0-1) arg3)) + (f0-6 -2.0) + (f1-18 (/ (- 1.0 f1-14) (- arg2 (* arg2 (sqrtf f1-14))))) + (f0-8 (* f0-6 (* f1-18 f1-18) arg3)) + ) + (setup-from-to-duration! this arg0 arg1 arg2 f0-8) + ) + ) + 0 + (none) + ) + +;; failed to figure out what this is: +(method-set! + trajectory + 17 + (if *debug-segment* + (lambda ((arg0 trajectory)) + (let ((s5-0 (new 'stack-no-clear 'vector)) + (s4-0 (new 'stack-no-clear 'vector)) + (s3-0 10) + ) + (set! (-> s4-0 quad) (-> arg0 initial-position quad)) + (dotimes (s2-0 s3-0) + (set! (-> s5-0 quad) (-> s4-0 quad)) + (let ((f0-1 (* (-> arg0 time) (/ (+ 1.0 (the float s2-0)) (the float s3-0))))) + (compute-trans-at-time arg0 f0-1 s4-0) + ) + (add-debug-line + #t + (bucket-id debug-no-zbuf1) + s5-0 + s4-0 + (new 'static 'rgba :r #xff :a #x80) + #f + (the-as rgba -1) + ) + ) + ) + 0 + (none) + ) + nothing + ) + ) + +;; definition for method 9 of type impact-control +;; INFO: Used lq/sq +(defmethod initialize ((this impact-control) (arg0 process-drawable) (arg1 int) (arg2 float) (arg3 collide-spec)) + (set! (-> this start-time) (the-as uint (current-time))) + (set! (-> this process) (the-as (pointer process-drawable) (process->ppointer arg0))) + (set! (-> this joint) arg1) + (set! (-> this radius) arg2) + (set! (-> this collide-with) (logclear arg3 (collide-spec water))) + (set! (-> this trans 0 quad) (the-as uint128 0)) + (set! (-> this trans 1 quad) (the-as uint128 0)) + this + ) + +;; definition for method 10 of type impact-control +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs none. +(defmethod update-from-cspace ((this impact-control)) + (when (>= (-> this joint) 0) + (set! (-> this trans 1 quad) (-> this trans 0 quad)) + (vector<-cspace! (the-as vector (-> this trans)) (-> this process 0 node-list data (-> this joint))) + (vector-! (-> this dir) (the-as vector (-> this trans)) (-> this trans 1)) + ) + 0 + (none) + ) + +;; definition for method 11 of type impact-control +;; INFO: Used lq/sq +(defmethod impact-control-method-11 ((this impact-control) (arg0 collide-query) (arg1 process) (arg2 pat-surface)) + (set! (-> arg0 start-pos quad) (-> this trans 1 quad)) + (set! (-> arg0 move-dist quad) (-> this dir quad)) + (let ((v1-2 (ppointer->process (-> this process))) + (a0-6 arg0) + ) + (set! (-> a0-6 radius) (-> this radius)) + (set! (-> a0-6 collide-with) (-> this collide-with)) + (set! (-> a0-6 ignore-process0) v1-2) + (set! (-> a0-6 ignore-process1) #f) + (set! (-> a0-6 ignore-pat) arg2) + (set! (-> a0-6 action-mask) (collide-action solid)) + ) + (let ((f30-0 (fill-and-probe-using-line-sphere *collide-cache* arg0))) + (when (and arg1 (>= f30-0 0.0) (>= 0.0 (vector-dot (-> arg0 best-other-tri normal) (-> this dir)))) + (let* ((s3-0 (new 'stack-no-clear 'touching-shapes-entry)) + (s2-0 (-> arg0 best-other-tri collide-ptr)) + (v1-12 (if (type? s2-0 collide-shape-prim) + s2-0 + ) + ) + ) + (set! (-> s3-0 cshape1) #f) + (set! (-> s3-0 cshape2) (if v1-12 + (-> (the-as collide-shape-prim v1-12) cshape) + ) + ) + (set! (-> s3-0 resolve-u) (the int f30-0)) + (set! (-> s3-0 head) #f) + (send-event + arg1 + 'impact-control + :from (if v1-12 + (-> (the-as collide-shape-prim v1-12) cshape process) + arg1 + ) + #f + s3-0 + this + arg0 + ) + ) + ) + f30-0 + ) + ) + +;; definition for method 9 of type point-tracker +;; INFO: Used lq/sq +(defmethod initialize ((this point-tracker) (arg0 vector) (arg1 vector)) + (set! (-> this trans 0 quad) (-> arg0 quad)) + (set! (-> this trans 1 quad) (-> arg1 quad)) + this + ) + +;; definition for method 10 of type point-tracker +;; INFO: Used lq/sq +(defmethod point-tracker-method-10 ((this point-tracker) (arg0 vector) (arg1 vector) (arg2 vector) (arg3 float)) + (cond + ((>= 0.0 arg3) + (set! (-> arg0 quad) (-> arg1 quad)) + ) + ((>= arg3 1.0) + (set! (-> arg0 quad) (-> arg2 quad)) + ) + (else + (let ((a1-2 (vector+float*! arg0 arg2 (vector-! (new 'stack-no-clear 'vector) arg1 arg2) (- 1.0 arg3)))) + (vector-lerp! arg0 a1-2 arg2 arg3) + ) + ) + ) + arg0 + ) + +;; definition for method 11 of type point-tracker +(defmethod point-tracker-method-11 ((this point-tracker) (arg0 vector) (arg1 vector) (arg2 vector) (arg3 float)) + (with-pp + (let ((v1-1 (point-tracker-method-10 this (new 'stack-no-clear 'vector) arg1 arg2 arg3))) + (vector-! arg0 v1-1 arg1) + ) + (vector-float*! arg0 arg0 (-> pp clock frames-per-second)) + arg0 + ) + ) + +;; definition for method 13 of type combo-tracker +;; WARN: Return type mismatch process vs process-focusable. +(defmethod combo-tracker-method-13 ((this combo-tracker) (arg0 handle) (arg1 vector) (arg2 float) (arg3 vector) (arg4 float)) + (the-as + process-focusable + (cond + ((send-event (handle->process arg0) 'combo) + (let ((gp-1 (handle->process arg0))) + (if (type? gp-1 process-focusable) + gp-1 + ) + ) + ) + (else + (let ((s1-0 (new 'stack-no-clear 'bounding-box)) + (s2-1 (new 'stack 'boxed-array collide-shape 32)) + ) + (sphere<-vector+r! (the-as sphere s1-0) arg1 arg2) + (set! (-> s2-1 length) (fill-actor-list-for-box + *actor-hash* + s1-0 + (the-as (pointer collide-shape) (-> s2-1 data)) + (-> s2-1 allocated-length) + ) + ) + (let ((gp-2 (find-nearest-focusable + (the-as (array collide-shape) s2-1) + arg1 + arg2 + (if (= arg4 65536.0) + (search-info-flag crate enemy combo) + (search-info-flag crate enemy prefer-angle cull-angle combo) + ) + (search-info-flag) + arg3 + (the-as vector #f) + arg4 + ) + ) + ) + (if (type? gp-2 process-focusable) + gp-2 + ) + ) + ) + ) + ) + ) + ) + +;; definition for method 12 of type combo-tracker +(defmethod combo-tracker-method-12 ((this combo-tracker) (arg0 vector) (arg1 vector) (arg2 process) (arg3 time-frame)) + (initialize this arg0 arg1) + (set! (-> this target) (process->handle arg2)) + (set! (-> this move-start-time) arg3) + this + ) + +;; definition for method 11 of type combo-tracker +;; INFO: Used lq/sq +(defmethod point-tracker-method-11 ((this combo-tracker) (arg0 vector) (arg1 vector) (arg2 vector) (arg3 float)) + (local-vars (at-0 int)) + (with-pp + (rlet ((vf0 :class vf) + (vf1 :class vf) + (vf2 :class vf) + ) + (init-vf0-vector) + (let ((v1-1 (point-tracker-method-10 this (new 'stack-no-clear 'vector) arg1 arg2 arg3))) + (vector-! arg0 v1-1 arg1) + ) + (let ((a1-4 (new 'stack-no-clear 'event-message-block))) + (set! (-> a1-4 from) (process->ppointer pp)) + (set! (-> a1-4 num-params) 0) + (set! (-> a1-4 message) 'nav-control) + (let* ((s3-0 (send-event-function (handle->process (-> this target)) a1-4)) + (s4-1 (if (type? s3-0 nav-control) + s3-0 + ) + ) + ) + (when s4-1 + (cond + (((method-of-type nav-control find-poly-containing-point-1) (the-as nav-control s4-1) arg1) + (let ((t9-4 (method-of-type nav-control nav-control-method-20))) + #x45000000 + (t9-4) + ) + ) + (else + (set! (-> arg0 quad) (the-as uint128 0)) + ) + ) + ) + ) + ) + (let ((v1-12 arg0)) + (.lvf vf1 (&-> arg0 quad)) + (let ((f0-0 (-> pp clock frames-per-second))) + (.mov at-0 f0-0) + ) + (.mov vf2 at-0) + (.mov.vf vf1 vf0 :mask #b1000) + (.mul.x.vf vf1 vf1 vf2 :mask #b111) + (.svf (&-> v1-12 quad) vf1) + ) + arg0 + ) + ) + ) + +;; definition for function traj2d-calc-initial-speed-using-tilt +(defun traj2d-calc-initial-speed-using-tilt ((arg0 traj2d-params)) + (let ((f0-4 (* (- (* (-> arg0 x) (tan (-> arg0 initial-tilt))) (-> arg0 y)) (/ 2.0 (-> arg0 gravity))))) + (cond + ((< 0.0 f0-4) + (set! (-> arg0 time) (sqrtf f0-4)) + (set! (-> arg0 initial-speed) (/ (-> arg0 x) (* (-> arg0 time) (cos (-> arg0 initial-tilt))))) + #t + ) + (else + (set! (-> arg0 time) 0.0) + (set! (-> arg0 initial-speed) 0.0) + #f + ) + ) + ) + ) + +;; definition for function traj3d-calc-initial-velocity-using-tilt +(defun traj3d-calc-initial-velocity-using-tilt ((arg0 traj3d-params)) + (vector-! (-> arg0 diff) (-> arg0 dest) (-> arg0 src)) + (let ((s5-0 (new 'stack-no-clear 'traj2d-params))) + (let ((v1-1 (-> arg0 diff))) + (set! (-> s5-0 x) (sqrtf (+ (* (-> v1-1 x) (-> v1-1 x)) (* (-> v1-1 z) (-> v1-1 z))))) + ) + (set! (-> s5-0 y) (-> arg0 diff y)) + (set! (-> s5-0 gravity) (-> arg0 gravity)) + (set! (-> s5-0 initial-tilt) (-> arg0 initial-tilt)) + (cond + ((traj2d-calc-initial-speed-using-tilt s5-0) + (set! (-> arg0 time) (-> s5-0 time)) + (let* ((f26-0 (atan (-> arg0 diff x) (-> arg0 diff z))) + (f30-0 (-> arg0 initial-tilt)) + (f24-0 (cos f30-0)) + (f28-0 (-> s5-0 initial-speed)) + ) + (set! (-> arg0 initial-speed) f28-0) + (set! (-> arg0 initial-velocity x) (* f28-0 f24-0 (sin f26-0))) + (set! (-> arg0 initial-velocity z) (* f28-0 f24-0 (cos f26-0))) + (set! (-> arg0 initial-velocity y) (* f28-0 (sin f30-0))) + ) + (set! (-> arg0 initial-velocity w) 1.0) + #t + ) + (else + (set! (-> arg0 time) 0.0) + (set! (-> arg0 initial-speed) 0.0) + (vector-reset! (-> arg0 initial-velocity)) + #f + ) + ) + ) + ) + +;; definition for method 9 of type cubic-curve +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs none. +(defmethod cubic-curve-method-9 ((this cubic-curve) (arg0 vector) (arg1 vector) (arg2 vector) (arg3 vector)) + (rlet ((acc :class vf) + (vf0 :class vf) + (vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + (vf7 :class vf) + ) + (init-vf0-vector) + (set! (-> this vec 0 quad) (-> arg0 quad)) + (set! (-> this mat uvec quad) (-> arg1 quad)) + (let ((v1-2 (new 'stack-no-clear 'trajectory))) + (vector-! (-> v1-2 initial-velocity) arg2 arg0) + (vector-float*! (-> v1-2 initial-position) (-> v1-2 initial-velocity) 3.0) + (let ((t1-7 (-> v1-2 initial-position))) + (let ((a1-3 (-> v1-2 initial-position))) + (let ((a3-2 arg1)) + (let ((t2-1 -2.0)) + (.mov vf7 t2-1) + ) + (.lvf vf5 (&-> a3-2 quad)) + ) + (.lvf vf4 (&-> a1-3 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 (&-> t1-7 quad) vf6) + ) + (vector-! (-> v1-2 initial-position) (-> v1-2 initial-position) arg3) + (set! (-> this mat fvec quad) (-> v1-2 initial-position quad)) + (vector-float*! (-> v1-2 initial-position) (-> v1-2 initial-velocity) -2.0) + (vector+! (-> v1-2 initial-position) (-> v1-2 initial-position) arg1) + (vector+! (-> v1-2 initial-position) (-> v1-2 initial-position) arg3) + (set! (-> this mat trans quad) (-> v1-2 initial-position quad)) + ) + (dotimes (v1-5 4) + (set! (-> this vec v1-5 w) 0.0) + ) + 0 + (none) + ) + ) + +;; definition for method 10 of type cubic-curve +(defmethod cubic-curve-method-10 ((this cubic-curve) (arg0 vector) (arg1 float)) + (let ((v1-0 (new 'stack-no-clear 'trajectory))) + (let ((f0-1 (* arg1 arg1))) + (set-vector! (-> v1-0 initial-position) 1.0 arg1 f0-1 (* f0-1 arg1)) + ) + (vector-matrix*! arg0 (-> v1-0 initial-position) (the-as matrix (-> this vec))) + ) + (set! (-> arg0 w) 1.0) + arg0 + ) + +;; definition for method 11 of type cubic-curve +(defmethod cubic-curve-method-11 ((this cubic-curve) (arg0 vector) (arg1 float)) + (let ((v1-0 (new 'stack-no-clear 'trajectory))) + (set-vector! (-> v1-0 initial-position) 0.0 1.0 (* 2.0 arg1) (* 3.0 arg1 arg1)) + (vector-matrix*! arg0 (-> v1-0 initial-position) (the-as matrix (-> this vec))) + ) + (set! (-> arg0 w) 1.0) + arg0 + ) + +;; definition for method 12 of type cubic-curve +(defmethod cubic-curve-method-12 ((this cubic-curve) (arg0 vector) (arg1 float)) + (let ((v1-0 (new 'stack-no-clear 'trajectory))) + (set-vector! (-> v1-0 initial-position) 0.0 0.0 2.0 (* 6.0 arg1)) + (vector-matrix*! arg0 (-> v1-0 initial-position) (the-as matrix (-> this vec))) + ) + (set! (-> arg0 w) 1.0) + arg0 + ) + +;; definition for method 13 of type cubic-curve +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs none. +(defmethod debug-draw-curve ((this cubic-curve)) + (let ((s5-0 (new 'stack-no-clear 'trajectory)) + (s4-0 10) + ) + (cubic-curve-method-10 this (-> s5-0 initial-velocity) 0.0) + (add-debug-x #t (bucket-id debug-no-zbuf1) (-> s5-0 initial-velocity) *color-red*) + (dotimes (s3-0 s4-0) + (set! (-> s5-0 initial-position quad) (-> s5-0 initial-velocity quad)) + (let ((f0-2 (/ (+ 1.0 (the float s3-0)) (the float s4-0)))) + (cubic-curve-method-10 this (-> s5-0 initial-velocity) f0-2) + ) + (add-debug-x #t (bucket-id debug-no-zbuf1) (-> s5-0 initial-velocity) *color-red*) + (add-debug-line + #t + (bucket-id debug-no-zbuf1) + (-> s5-0 initial-position) + (-> s5-0 initial-velocity) + *color-red* + #f + (the-as rgba -1) + ) + ) + ) + (add-debug-vector + #t + (bucket-id debug-no-zbuf1) + (cubic-curve-method-10 this (new 'stack-no-clear 'vector) 0.0) + (cubic-curve-method-11 this (new 'stack-no-clear 'vector) 0.0) + (meters 0.00024414062) + *color-white* + ) + (add-debug-vector + #t + (bucket-id debug-no-zbuf1) + (cubic-curve-method-10 this (new 'stack-no-clear 'vector) 1.0) + (vector-negate! (new 'stack-no-clear 'vector) (cubic-curve-method-11 this (new 'stack-no-clear 'vector) 1.0)) + (meters 0.00024414062) + *color-white* + ) + 0 + (none) + ) diff --git a/test/decompiler/reference/jak3/engine/target/logic-target_REF.gc b/test/decompiler/reference/jak3/engine/target/logic-target_REF.gc index fe8fe19d72a..05a33c98f18 100644 --- a/test/decompiler/reference/jak3/engine/target/logic-target_REF.gc +++ b/test/decompiler/reference/jak3/engine/target/logic-target_REF.gc @@ -112,7 +112,166 @@ ) ;; definition (debug) for function target-history-print -;; ERROR: function was not converted to expressions. Cannot decompile. +;; WARN: new jak 2 until loop case, check carefully +(defun-debug target-history-print ((arg0 history-iterator)) + (local-vars + (sv-16 object) + (sv-24 int) + (sv-32 collide-status) + (sv-40 number) + (sv-44 vector) + (sv-48 vector) + (sv-52 vector) + (sv-56 vector) + (sv-60 vector) + (sv-64 vector) + (sv-68 number) + (sv-72 history-elt) + (sv-80 time-frame) + (sv-88 uint) + ) + (set! sv-16 (-> arg0 out)) + (set! sv-24 0) + (set! sv-32 (collide-status)) + (set! sv-40 0) + (set! sv-44 *zero-vector*) + (set! sv-48 *zero-vector*) + (set! sv-52 *zero-vector*) + (set! sv-56 *zero-vector*) + (set! sv-60 *zero-vector*) + (set! sv-64 *zero-vector*) + (set! sv-68 0) + (until #f + (set! sv-72 (update-entries! arg0)) + (if (not sv-72) + (return #f) + ) + (set! sv-80 (frame-counter-delta arg0 sv-72)) + (set! sv-88 (-> sv-72 record-id)) + (when (!= sv-24 sv-88) + (set! sv-24 (the-as int sv-88)) + (format + (-> arg0 out) + "~6D ~8S #x~8X " + sv-80 + (if (logtest? sv-32 (collide-status no-touch)) + "air" + (-> *pat-mode-info* (shr (shl (the-as int sv-68) 54) 61) name) + ) + sv-32 + ) + (format + (-> arg0 out) + "~C~C~C~C~C~C" + (if (not (logtest? (the-as int sv-40) 1)) + 103 + 87 + ) + (if (not (logtest? (the-as int sv-40) 2)) + 103 + 87 + ) + (cond + ((logtest? (the-as int sv-40) 2048) + 71 + ) + ((not (logtest? (the-as int sv-40) 4)) + 103 + ) + (else + 87 + ) + ) + (cond + ((logtest? (the-as int sv-40) 512) + 66 + ) + ((logtest? (the-as int sv-40) 8) + 76 + ) + (else + 99 + ) + ) + (if (not (logtest? (the-as int sv-40) 16)) + 110 + 66 + ) + (if (not (logtest? (the-as int sv-40) 32)) + 103 + 65 + ) + ) + (format + (-> arg0 out) + "~C~C " + (cond + ((logtest? #x10000 (the-as int sv-40)) + 80 + ) + ((logtest? (the-as int sv-40) #x8000) + 85 + ) + ((logtest? (the-as int sv-40) 64) + 78 + ) + (else + 95 + ) + ) + (cond + ((logtest? (the-as int sv-40) 1024) + 76 + ) + ((logtest? (the-as int sv-40) 256) + 67 + ) + ((logtest? (the-as int sv-40) 128) + 108 + ) + (else + 95 + ) + ) + ) + (format (-> arg0 out) "trans: ~6,,2m ~6,,2m ~6,,2m " (-> sv-44 x) (-> sv-44 y) (-> sv-44 z)) + (format (-> arg0 out) "int: ~6,,2m ~6,,2m ~6,,2m " (-> sv-56 x) (-> sv-56 y) (-> sv-56 z)) + (format (-> arg0 out) "vel: ~6,,2m ~6,,2m ~6,,2m " (-> sv-48 x) (-> sv-48 y) (-> sv-48 z)) + (format (-> arg0 out) "vel-out: ~6,,2m ~6,,2m ~6,,2m " (-> sv-52 x) (-> sv-52 y) (-> sv-52 z)) + (format (-> arg0 out) "normal: ~6,,2f ~6,,2f ~6,,2f " (-> sv-60 x) (-> sv-60 y) (-> sv-60 z)) + (format (-> arg0 out) "local: ~6,,2f ~6,,2f ~6,,2f " (-> sv-64 x) (-> sv-64 y) (-> sv-64 z)) + (format (-> arg0 out) "~%") + ) + (case (-> sv-72 channel) + (((history-channel trans)) + (set! sv-44 (-> sv-72 vector)) + ) + (((history-channel transv-in)) + (set! sv-48 (-> sv-72 vector)) + ) + (((history-channel transv-out)) + (set! sv-52 (-> sv-72 vector)) + ) + (((history-channel intersect)) + (set! sv-56 (-> sv-72 vector)) + ) + (((history-channel pat)) + (set! sv-68 (-> sv-72 vector x)) + ) + (((history-channel collide-status)) + (set! sv-32 (-> sv-72 collide-status)) + (set! sv-40 (-> sv-72 vector z)) + ) + (((history-channel surface-normal)) + (set! sv-60 (-> sv-72 vector)) + ) + (((history-channel local-normal)) + (set! sv-64 (-> sv-72 vector)) + ) + ) + ) + #f + ) ;; definition (debug) for function target-print-stats ;; INFO: Used lq/sq @@ -2534,8 +2693,7 @@ (vector-average! (-> self control midpoint-of-hands) gp-0 s5-0) ) (vector-! (-> self control ctrl-to-hands-offset) (-> self control midpoint-of-hands) (-> self control trans)) - (-> self control impact-ctrl) - ((method-of-type impact-control impact-control-method-10)) + (update-from-cspace (-> self control impact-ctrl)) (cond ((focus-test? self edge-grab) (target-compute-edge) diff --git a/test/decompiler/reference/jak3/engine/util/sync-info-h_REF.gc b/test/decompiler/reference/jak3/engine/util/sync-info-h_REF.gc index 2b02f1ede31..b128e52c402 100644 --- a/test/decompiler/reference/jak3/engine/util/sync-info-h_REF.gc +++ b/test/decompiler/reference/jak3/engine/util/sync-info-h_REF.gc @@ -43,13 +43,13 @@ (period uint32) ) (:methods - (sync-info-method-9 () none) - (sync-info-method-10 () none) + (get-current-phase-no-mod (_type_) float) + (get-phase-offset (_type_) float) (get-norm! (_type_ int) float) - (sync-info-method-12 () none) + (get-scaled-val! (_type_ float int) float) (initialize! (_type_ sync-info-params) none) - (sync-info-method-14 () none) - (sync-info-method-15 () none) + (get-timeframe-offset! (_type_ time-frame) time-frame) + (sync-now! (_type_ float) none) ) ) @@ -155,10 +155,10 @@ ) :pack-me (:methods - (delayed-rand-float-method-9 () none) - (delayed-rand-float-method-10 () none) - (delayed-rand-float-method-11 () none) - (delayed-rand-float-method-12 () none) + (set-params! (_type_ int int float) float) + (reset! (_type_) float) + (update! (_type_) float) + (update-and-clear! (_type_) float) ) ) @@ -190,8 +190,8 @@ ) :allow-misaligned (:methods - (oscillating-float-method-9 () none) - (oscillating-float-method-10 () none) + (set-params! (_type_ float float float float) float) + (update! (_type_ float) float) ) ) @@ -222,10 +222,10 @@ ) :allow-misaligned (:methods - (bouncing-float-method-9 () none) - (bouncing-float-method-10 () none) - (bouncing-float-method-11 () none) - (bouncing-float-method-12 () none) + (set-params! (_type_ float float float float float float float) float) + (update! (_type_ float) float) + (at-min? (_type_) symbol) + (at-max? (_type_) symbol) ) ) @@ -256,10 +256,10 @@ (value vector :inline) ) (:methods - (delayed-rand-vector-method-9 () none) - (delayed-rand-vector-method-10 () none) - (delayed-rand-vector-method-11 () none) - (delayed-rand-vector-method-12 () none) + (set-params! (_type_ int int float float) vector) + (update-now! (_type_) vector) + (update-with-delay! (_type_) vector) + (update-with-delay-or-reset! (_type_) vector) ) ) @@ -291,8 +291,8 @@ (accel float) ) (:methods - (oscillating-vector-method-9 () none) - (oscillating-vector-method-10 () none) + (set-params! (_type_ vector float float float) vector) + (update! (_type_ vector) vector) ) ) diff --git a/test/decompiler/reference/jak3/engine/util/sync-info_REF.gc b/test/decompiler/reference/jak3/engine/util/sync-info_REF.gc new file mode 100644 index 00000000000..22ce8b1d866 --- /dev/null +++ b/test/decompiler/reference/jak3/engine/util/sync-info_REF.gc @@ -0,0 +1,620 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition for method 13 of type sync-info +;; WARN: Return type mismatch object vs none. +(defmethod initialize! ((this sync-info) (arg0 sync-info-params)) + (format 0 "ERROR: Invalid call to sync-info::initialize!~%") + (none) + ) + +;; definition for method 9 of type sync-info +(defmethod get-current-phase-no-mod ((this sync-info)) + (let* ((v1-0 (-> this period)) + (f0-1 (the float v1-0)) + (f1-2 (+ (the float (mod (the-as uint (current-time)) v1-0)) (-> this offset))) + ) + (/ (- f1-2 (* (the float (the int (/ f1-2 f0-1))) f0-1)) f0-1) + ) + ) + +;; definition for method 10 of type sync-info +(defmethod get-phase-offset ((this sync-info)) + (/ (-> this offset) (the float (-> this period))) + ) + +;; definition for method 15 of type sync-info +;; WARN: Return type mismatch int vs none. +(defmethod sync-now! ((this sync-info) (arg0 float)) + (let* ((a2-0 (-> this period)) + (f0-1 (the float a2-0)) + (v1-0 (- arg0 (* (the float (the int (/ arg0 f0-1))) f0-1))) + (f1-4 (+ (the float (mod (the-as uint (current-time)) a2-0)) (-> this offset))) + (f1-6 (/ (- f1-4 (* (the float (the int (/ f1-4 f0-1))) f0-1)) f0-1)) + (f1-10 (+ (* (- v1-0 f1-6) f0-1) f0-1 (-> this offset))) + ) + (set! (-> this offset) (- f1-10 (* (the float (the int (/ f1-10 f0-1))) f0-1))) + ) + 0 + (none) + ) + +;; definition for method 11 of type sync-info +(defmethod get-norm! ((this sync-info) (arg0 int)) + (format 0 "ERROR: Unsupported sync-info::get-norm!~%") + 0.0 + ) + +;; definition for method 12 of type sync-info +(defmethod get-scaled-val! ((this sync-info) (arg0 float) (arg1 int)) + (* (get-norm! this arg1) arg0) + ) + +;; definition for method 14 of type sync-info +(defmethod get-timeframe-offset! ((this sync-info) (arg0 time-frame)) + (if (zero? arg0) + (set! arg0 (current-time)) + ) + (let* ((v1-4 (-> this period)) + (f0-1 (the float v1-4)) + (f1-2 (+ (the float (mod arg0 (the-as time-frame v1-4))) (-> this offset))) + ) + (+ arg0 (the int (- f0-1 (* (/ (- f1-2 (* (the float (the int (/ f1-2 f0-1))) f0-1)) f0-1) f0-1)))) + ) + ) + +;; definition for method 13 of type sync-linear +;; INFO: Used lq/sq +;; WARN: Return type mismatch float vs none. +(defmethod initialize! ((this sync-linear) (arg0 sync-info-params)) + (local-vars (sv-16 res-tag)) + (if (!= (-> arg0 sync-type) 'sync-linear) + (format + 0 + "ERROR: Using wrong sync params in sync-linear::initialize (got ~A)! Fix this!~%" + (-> arg0 sync-type) + ) + ) + (set! (-> this sync-flags) (-> arg0 sync-flags)) + (let ((s4-0 (the-as int (-> arg0 period))) + (f30-0 (-> arg0 percent)) + ) + (let ((a0-3 (-> arg0 entity))) + (when a0-3 + (set! sv-16 (new 'static 'res-tag)) + (let ((v1-6 (res-lump-data a0-3 'sync (pointer float) :tag-ptr (& sv-16)))) + (when v1-6 + (set! s4-0 (the int (* 300.0 (-> v1-6 0)))) + (set! f30-0 (-> v1-6 1)) + ) + ) + ) + ) + (set! (-> this period) (the-as uint s4-0)) + (let* ((f0-4 (the float s4-0)) + (f1-1 (* f30-0 f0-4)) + ) + (set! (-> this offset) (- f1-1 (* (the float (the int (/ f1-1 f0-4))) f0-4))) + ) + ) + (none) + ) + +;; definition for method 11 of type sync-linear +(defmethod get-norm! ((this sync-linear) (arg0 int)) + (if (zero? arg0) + (set! arg0 (the-as int (current-time))) + ) + (let* ((v1-4 (-> this period)) + (f0-1 (the float v1-4)) + ) + (cond + ((logtest? (-> this sync-flags) (sync-flags pong)) + (let* ((f1-0 2.0) + (f2-2 (+ (the float (mod arg0 (the-as int v1-4))) (-> this offset))) + (f0-3 (* f1-0 (/ (- f2-2 (* (the float (the int (/ f2-2 f0-1))) f0-1)) f0-1))) + ) + (if (>= f0-3 1.0) + (set! f0-3 (- 2.0 f0-3)) + ) + f0-3 + ) + ) + (else + (let ((f1-5 (+ (the float (mod arg0 (the-as int v1-4))) (-> this offset)))) + (/ (- f1-5 (* (the float (the int (/ f1-5 f0-1))) f0-1)) f0-1) + ) + ) + ) + ) + ) + +;; definition for method 12 of type sync-linear +(defmethod get-scaled-val! ((this sync-linear) (arg0 float) (arg1 int)) + (* (get-norm! this arg1) arg0) + ) + +;; definition for method 13 of type sync-eased +;; INFO: Used lq/sq +;; WARN: Return type mismatch float vs none. +(defmethod initialize! ((this sync-eased) (arg0 sync-info-params)) + (local-vars (sv-16 res-tag)) + (if (!= (-> arg0 sync-type) 'sync-eased) + (format + 0 + "ERROR: Using wrong sync params in sync-eased::initialize (got ~A)! Fix this!~%" + (-> arg0 sync-type) + ) + ) + (set! (-> this sync-flags) (-> arg0 sync-flags)) + (let ((s5-0 (the-as int (-> arg0 period))) + (f22-0 (-> arg0 percent)) + (f24-0 (-> arg0 pause-in)) + (f26-0 (-> arg0 pause-out)) + (f30-0 (-> arg0 ease-in)) + (f28-0 (-> arg0 ease-out)) + ) + (let ((a0-3 (-> arg0 entity))) + (when a0-3 + (set! sv-16 (new 'static 'res-tag)) + (let ((v1-6 (res-lump-data a0-3 'sync (pointer float) :tag-ptr (& sv-16)))) + (when v1-6 + (set! s5-0 (the int (* 300.0 (-> v1-6 0)))) + (set! f22-0 (-> v1-6 1)) + (when (>= (-> sv-16 elt-count) (the-as uint 4)) + (set! f30-0 (-> v1-6 2)) + (set! f28-0 (-> v1-6 3)) + (when (>= (-> sv-16 elt-count) (the-as uint 6)) + (set! f24-0 (-> v1-6 4)) + (set! f26-0 (-> v1-6 5)) + ) + ) + ) + ) + ) + ) + (set! (-> this period) (the-as uint s5-0)) + (let* ((f0-4 (the float s5-0)) + (f1-1 (* f22-0 f0-4)) + ) + (set! (-> this offset) (- f1-1 (* (the float (the int (/ f1-1 f0-4))) f0-4))) + ) + (cond + ((< f26-0 0.0) + (set! f26-0 0.0) + ) + ((< 1.0 f26-0) + (set! f26-0 1.0) + ) + ) + (cond + ((< f24-0 0.0) + (set! f24-0 0.0) + ) + ((< (- 1.0 f26-0) f24-0) + (set! f24-0 (- 1.0 f26-0)) + ) + ) + (let ((f0-14 (the float s5-0))) + (set! (-> this pause-in) (* f24-0 f0-14)) + (set! (-> this pause-out) (* f26-0 f0-14)) + ) + (if (< f30-0 0.0) + (set! f30-0 0.0) + ) + (if (< 1.0 f30-0) + (set! f30-0 1.0) + ) + (if (< f28-0 0.001) + (set! f28-0 0.001) + ) + (if (< 1.0 f28-0) + (set! f28-0 1.0) + ) + (let ((f0-20 (+ f30-0 f28-0))) + (when (< 1.0 f0-20) + (set! f0-20 1.0) + (set! f30-0 (- 1.0 f28-0)) + ) + (let* ((f1-6 (- 1.0 f0-20)) + (f0-21 f30-0) + (f1-7 (+ f30-0 f1-6)) + (f2-3 (* f0-21 f0-21)) + (f3-3 (+ (* 2.0 f0-21 (- f1-7 f0-21)) f2-3)) + (f4-3 (/ f0-21 (- 1.0 f1-7))) + (f3-4 (+ (* (- 1.0 f1-7) (- 1.0 f1-7) f4-3) f3-3)) + ) + (set! (-> this tlo) f0-21) + (set! (-> this thi) f1-7) + (set! (-> this ylo) f2-3) + (set! (-> this m2) f4-3) + (set! (-> this yend) f3-4) + ) + ) + ) + (none) + ) + +;; definition for method 11 of type sync-eased +(defmethod get-norm! ((this sync-eased) (arg0 int)) + (if (zero? arg0) + (set! arg0 (the-as int (current-time))) + ) + (let* ((v1-4 (-> this period)) + (f3-0 (the float v1-4)) + (f0-1 (-> this pause-in)) + (f2-0 (-> this pause-out)) + (f1-1 (* 0.5 (- f3-0 (+ f0-1 f2-0)))) + ) + (the int (+ f0-1 f2-0 f3-0)) + (cond + ((logtest? (-> this sync-flags) (sync-flags pong)) + (let* ((f4-7 (+ (the float (mod arg0 (the-as int v1-4))) (-> this offset))) + (f3-2 (- f4-7 (* (the float (the int (/ f4-7 f3-0))) f3-0))) + (v1-6 #f) + ) + (when (>= f3-2 (+ f1-1 f0-1)) + (set! v1-6 #t) + (set! f3-2 (- f3-2 (+ f1-1 f0-1))) + f0-1 + (set! f0-1 f2-0) + ) + (cond + ((< f3-2 f0-1) + (set! f3-2 f0-1) + ) + ((< (+ f0-1 f1-1) f3-2) + (set! f3-2 (+ f0-1 f1-1)) + ) + ) + (let* ((f0-3 (/ (- f3-2 f0-1) f1-1)) + (f1-2 (-> this tlo)) + (f0-8 (/ (cond + ((< f0-3 f1-2) + (* f0-3 f0-3) + ) + ((< f0-3 (-> this thi)) + (+ (* 2.0 f1-2 (- f0-3 f1-2)) (-> this ylo)) + ) + (else + (let ((f1-5 (- 1.0 f0-3))) + (- (-> this yend) (* f1-5 f1-5 (-> this m2))) + ) + ) + ) + (-> this yend) + ) + ) + ) + (if v1-6 + (set! f0-8 (- 1.0 f0-8)) + ) + f0-8 + ) + ) + ) + (else + (format 0 "ERROR: Attempting to use sync-eased in unsupported non-pong mode.~%") + 0.0 + ) + ) + ) + ) + +;; definition for method 12 of type sync-eased +(defmethod get-scaled-val! ((this sync-eased) (arg0 float) (arg1 int)) + (* (get-norm! this arg1) arg0) + ) + +;; definition for method 13 of type sync-paused +;; INFO: Used lq/sq +;; WARN: Return type mismatch float vs none. +(defmethod initialize! ((this sync-paused) (arg0 sync-info-params)) + (local-vars (sv-16 res-tag)) + (if (!= (-> arg0 sync-type) 'sync-paused) + (format + 0 + "ERROR: Using wrong sync params in sync-paused::initialize (got ~A)! Fix this!~%" + (-> arg0 sync-type) + ) + ) + (set! (-> this sync-flags) (-> arg0 sync-flags)) + (let ((s5-0 (the-as int (-> arg0 period))) + (f26-0 (-> arg0 percent)) + (f28-0 (-> arg0 pause-in)) + (f30-0 (-> arg0 pause-out)) + ) + (let ((a0-3 (-> arg0 entity))) + (when a0-3 + (set! sv-16 (new 'static 'res-tag)) + (let ((v1-6 (res-lump-data a0-3 'sync (pointer float) :tag-ptr (& sv-16)))) + (when v1-6 + (set! s5-0 (the int (* 300.0 (-> v1-6 0)))) + (set! f26-0 (-> v1-6 1)) + (when (>= (-> sv-16 elt-count) (the-as uint 4)) + (set! f28-0 (-> v1-6 2)) + (set! f30-0 (-> v1-6 3)) + ) + ) + ) + ) + ) + (set! (-> this period) (the-as uint s5-0)) + (let* ((f0-4 (the float s5-0)) + (f1-1 (* f26-0 f0-4)) + ) + (set! (-> this offset) (- f1-1 (* (the float (the int (/ f1-1 f0-4))) f0-4))) + ) + (cond + ((< f30-0 0.0) + (set! f30-0 0.0) + ) + ((< 1.0 f30-0) + (set! f30-0 1.0) + ) + ) + (cond + ((< f28-0 0.0) + (set! f28-0 0.0) + ) + ((< (- 1.0 f30-0) f28-0) + (set! f28-0 (- 1.0 f30-0)) + ) + ) + (let ((f0-14 (the float s5-0))) + (set! (-> this pause-in) (* f28-0 f0-14)) + (set! (-> this pause-out) (* f30-0 f0-14)) + ) + ) + (none) + ) + +;; definition for method 11 of type sync-paused +(defmethod get-norm! ((this sync-paused) (arg0 int)) + (if (zero? arg0) + (set! arg0 (the-as int (current-time))) + ) + (let* ((v1-4 (-> this period)) + (f2-0 (the float v1-4)) + (f0-1 (-> this pause-in)) + (f1-0 (-> this pause-out)) + ) + (the int (+ f0-1 f1-0 f2-0)) + (cond + ((logtest? (-> this sync-flags) (sync-flags pong)) + (let* ((f3-5 (+ (the float (mod arg0 (the-as int v1-4))) (-> this offset))) + (f3-6 (- f3-5 (* (the float (the int (/ f3-5 f2-0))) f2-0))) + (f2-2 (* 0.5 (- f2-0 (+ f0-1 f1-0)))) + (v1-7 #f) + ) + (when (>= f3-6 (+ f2-2 f0-1)) + (set! v1-7 #t) + (set! f3-6 (- f3-6 (+ f2-2 f0-1))) + (set! f0-1 f1-0) + ) + (let* ((f1-1 (/ (- f3-6 f0-1) f2-2)) + (f0-5 (fmax 0.0 (fmin 1.0 f1-1))) + ) + (if v1-7 + (set! f0-5 (- 1.0 f0-5)) + ) + f0-5 + ) + ) + ) + (else + (let* ((f3-9 (+ (the float (mod arg0 (the-as int v1-4))) (-> this offset))) + (f3-10 (- f3-9 (* (the float (the int (/ f3-9 f2-0))) f2-0))) + (f1-5 (- f2-0 (+ f0-1 f1-0))) + (f1-6 (/ (- f3-10 f0-1) f1-5)) + ) + (fmax 0.0 (fmin 1.0 f1-6)) + ) + ) + ) + ) + ) + +;; definition for method 12 of type sync-paused +(defmethod get-scaled-val! ((this sync-paused) (arg0 float) (arg1 int)) + (* (get-norm! this arg1) arg0) + ) + +;; definition for method 9 of type delayed-rand-float +(defmethod set-params! ((this delayed-rand-float) (arg0 int) (arg1 int) (arg2 float)) + (set! (-> this min-time) arg0) + (set! (-> this max-time) arg1) + (set! (-> this max-val) (* 0.5 arg2)) + (set! (-> this start-time) 0) + (set! (-> this timer) 0) + (set! (-> this value) 0.0) + (-> this value) + ) + +;; definition for method 10 of type delayed-rand-float +(defmethod reset! ((this delayed-rand-float)) + (set-time! (-> this start-time)) + (set! (-> this timer) (rand-vu-int-range (-> this min-time) (-> this max-time))) + (set! (-> this value) (rand-vu-float-range (- (-> this max-val)) (-> this max-val))) + ) + +;; definition for method 11 of type delayed-rand-float +(defmethod update! ((this delayed-rand-float)) + (if (time-elapsed? (-> this start-time) (-> this timer)) + (reset! this) + ) + (-> this value) + ) + +;; definition for method 12 of type delayed-rand-float +(defmethod update-and-clear! ((this delayed-rand-float)) + (if (time-elapsed? (-> this start-time) (-> this timer)) + (reset! this) + (set! (-> this value) 0.0) + ) + (-> this value) + ) + +;; definition for method 9 of type oscillating-float +(defmethod set-params! ((this oscillating-float) (arg0 float) (arg1 float) (arg2 float) (arg3 float)) + (set! (-> this value) arg0) + (set! (-> this target) arg0) + (set! (-> this vel) 0.0) + (set! (-> this max-vel) arg2) + (set! (-> this damping) arg3) + (set! (-> this accel) arg1) + (-> this value) + ) + +;; definition for method 10 of type oscillating-float +(defmethod update! ((this oscillating-float) (arg0 float)) + (with-pp + (let ((f0-3 (* (- (+ (-> this target) arg0) (-> this value)) (* (-> this accel) (-> pp clock time-adjust-ratio))))) + (+! (-> this vel) f0-3) + ) + (set! (-> this vel) (fmin (-> this max-vel) (fmax (- (-> this max-vel)) (-> this vel)))) + (set! (-> this vel) (* (-> this vel) (-> this damping))) + (+! (-> this value) (* (-> this vel) (-> pp clock time-adjust-ratio))) + (-> this value) + ) + ) + +;; definition for method 9 of type bouncing-float +(defmethod set-params! ((this bouncing-float) + (arg0 float) + (arg1 float) + (arg2 float) + (arg3 float) + (arg4 float) + (arg5 float) + (arg6 float) + ) + (set-params! (-> this osc) arg0 arg4 arg5 arg6) + (set! (-> this max-value) arg1) + (set! (-> this min-value) arg2) + (set! (-> this elasticity) arg3) + (set! (-> this state) 0) + (-> this osc value) + ) + +;; definition for method 10 of type bouncing-float +(defmethod update! ((this bouncing-float) (arg0 float)) + (update! (-> this osc) arg0) + (set! (-> this state) 0) + (when (>= (-> this osc value) (-> this max-value)) + (set! (-> this osc value) (-> this max-value)) + (if (< 0.0 (-> this osc vel)) + (set! (-> this osc vel) (* (-> this osc vel) (- (-> this elasticity)))) + ) + (set! (-> this state) 1) + ) + (when (>= (-> this min-value) (-> this osc value)) + (set! (-> this osc value) (-> this min-value)) + (if (< (-> this osc vel) 0.0) + (set! (-> this osc vel) (* (-> this osc vel) (- (-> this elasticity)))) + ) + (set! (-> this state) -1) + ) + (-> this osc value) + ) + +;; definition for method 11 of type bouncing-float +(defmethod at-min? ((this bouncing-float)) + (= (-> this state) -1) + ) + +;; definition for method 12 of type bouncing-float +(defmethod at-max? ((this bouncing-float)) + (= (-> this state) 1) + ) + +;; definition for method 9 of type delayed-rand-vector +(defmethod set-params! ((this delayed-rand-vector) (arg0 int) (arg1 int) (arg2 float) (arg3 float)) + (set! (-> this min-time) arg0) + (set! (-> this max-time) arg1) + (set! (-> this xz-max) (* 0.5 arg2)) + (set! (-> this y-max) (* 0.5 arg3)) + (set! (-> this start-time) 0) + (set! (-> this timer) 0) + (vector-reset! (-> this value)) + (-> this value) + ) + +;; definition for method 10 of type delayed-rand-vector +(defmethod update-now! ((this delayed-rand-vector)) + (set-time! (-> this start-time)) + (set! (-> this timer) (rand-vu-int-range (-> this min-time) (-> this max-time))) + (set! (-> this value x) (rand-vu-float-range (- (-> this xz-max)) (-> this xz-max))) + (set! (-> this value y) (rand-vu-float-range (- (-> this y-max)) (-> this y-max))) + (set! (-> this value z) (rand-vu-float-range (- (-> this xz-max)) (-> this xz-max))) + (-> this value) + ) + +;; definition for method 11 of type delayed-rand-vector +(defmethod update-with-delay! ((this delayed-rand-vector)) + (if (time-elapsed? (-> this start-time) (-> this timer)) + (update-now! this) + ) + (-> this value) + ) + +;; definition for method 12 of type delayed-rand-vector +(defmethod update-with-delay-or-reset! ((this delayed-rand-vector)) + (if (time-elapsed? (-> this start-time) (-> this timer)) + (update-now! this) + (vector-reset! (-> this value)) + ) + (-> this value) + ) + +;; definition for method 9 of type oscillating-vector +;; INFO: Used lq/sq +(defmethod set-params! ((this oscillating-vector) (arg0 vector) (arg1 float) (arg2 float) (arg3 float)) + (cond + (arg0 + (set! (-> this value quad) (-> arg0 quad)) + (set! (-> this target quad) (-> arg0 quad)) + ) + (else + (vector-reset! (-> this value)) + (vector-reset! (-> this target)) + ) + ) + (vector-reset! (-> this vel)) + (set! (-> this max-vel) arg2) + (set! (-> this damping) arg3) + (set! (-> this accel) arg1) + (-> this value) + ) + +;; definition for method 10 of type oscillating-vector +(defmethod update! ((this oscillating-vector) (arg0 vector)) + (with-pp + (let ((v1-0 (new 'stack-no-clear 'vector))) + (cond + (arg0 + (vector+! v1-0 (-> this target) arg0) + (vector-! v1-0 v1-0 (-> this value)) + ) + (else + (vector-! v1-0 (-> this target) (-> this value)) + ) + ) + (vector-float*! v1-0 v1-0 (* (-> this accel) (-> pp clock time-adjust-ratio))) + (vector+! (-> this vel) (-> this vel) v1-0) + (let ((f0-2 (vector-length (-> this vel)))) + (if (< (-> this max-vel) f0-2) + (vector-float*! (-> this vel) (-> this vel) (/ (-> this max-vel) f0-2)) + ) + ) + (vector-float*! (-> this vel) (-> this vel) (-> this damping)) + (vector-float*! v1-0 (-> this vel) (-> pp clock time-adjust-ratio)) + (vector+! (-> this value) (-> this value) v1-0) + ) + (-> this value) + ) + ) + + + + diff --git a/test/goalc/source_templates/variables/stack-boxed-array.gc b/test/goalc/source_templates/variables/stack-boxed-array.gc new file mode 100644 index 00000000000..e65bd721c36 --- /dev/null +++ b/test/goalc/source_templates/variables/stack-boxed-array.gc @@ -0,0 +1,26 @@ +(deftype test-stack-array-basic (basic) + ((a uint32) + (b uint32) + ) + ) + +(let ((x (new 'stack 'boxed-array uint32 2)) + (y (new 'stack 'boxed-array test-stack-array-basic 2)) + (z (new 'stack 'boxed-array uint64 2)) + (a (new 'stack 'test-stack-array-basic)) + (b (new 'stack 'test-stack-array-basic))) + (set! (-> x 0) 1) + (set! (-> x 1) 2) + (set! (-> a a) 3) + (set! (-> a b) 4) + (set! (-> b a) 5) + (set! (-> b b) 6) + (set! (-> y 0) a) + (set! (-> y 1) b) + (set! (-> z 0) 7) + (set! (-> z 1) 8) + ;; 36 + (+ (-> x 0) (-> x 1) + (-> y 0 a) (-> y 0 b) (-> y 1 a) (-> y 1 b) + (-> z 0) (-> z 1)) + ) diff --git a/test/goalc/test_variables.cpp b/test/goalc/test_variables.cpp index a0c312f9520..554a4987767 100644 --- a/test/goalc/test_variables.cpp +++ b/test/goalc/test_variables.cpp @@ -86,6 +86,10 @@ TEST_F(VariableTests, StackStructureAlignment) { shared_compiler->runner.run_static_test(testCategory, "stack-structure-align.gc", {"1234\n"}); } +TEST_F(VariableTests, StackBoxedArray) { + shared_compiler->runner.run_static_test(testCategory, "stack-boxed-array.gc", {"36\n"}); +} + TEST_F(VariableTests, GetSymbol) { shared_compiler->runner.run_static_test(testCategory, "get-symbol-1.static.gc", {"1375524\n"}); // 0x14fd24 in hex diff --git a/test/offline/config/jak3/config.jsonc b/test/offline/config/jak3/config.jsonc index c3702b4ce7e..6577987afd7 100644 --- a/test/offline/config/jak3/config.jsonc +++ b/test/offline/config/jak3/config.jsonc @@ -81,11 +81,18 @@ "target-send-attack", // find-nearest "find-nearest-focusable", - + // sprite "(method 3 sprite-aux-list)", // appears twice. + // sprite-distort "sprite-draw-distorters", // asm - "bugfix?" - + // debug + "bugfix?", + // camera-states + "cam-los-collide", + // camera + "v-slrp3!", + "v-slrp2!", + "slave-set-rotation!" ], "skip_compile_states": {}