diff --git a/goal_src/jak2/engine/camera/cam-master.gc b/goal_src/jak2/engine/camera/cam-master.gc index bfffe588d4..c9c84020d0 100644 --- a/goal_src/jak2/engine/camera/cam-master.gc +++ b/goal_src/jak2/engine/camera/cam-master.gc @@ -5,5 +5,1129 @@ ;; name in dgo: cam-master ;; dgos: ENGINE, GAME +;;og:ignore-form:camera-master-method-16 + ;; DECOMP BEGINS + +(defbehavior reset-follow camera-master () + (let ((a0-1 (handle->process (-> self focus handle)))) + (when (the-as process-focusable a0-1) + (set! (-> self tpos-old quad) (-> (get-trans (the-as process-focusable a0-1) 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)) + (set! (-> self upspeed) 0.0) + ) + ) + ) + +;; WARN: Return type mismatch none vs symbol. +(defbehavior reset-target-tracking camera-master () + (let ((gp-0 (handle->process (-> self focus handle)))) + (the-as + symbol + (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)) + (let* ((s5-1 quaternion->matrix) + (s4-0 (-> self tgt-rot-mat)) + (a0-12 (the-as process-focusable gp-0)) + (t9-1 (method-of-object a0-12 get-quat)) + ) + 2 + (s5-1 s4-0 (t9-1 a0-12)) + ) + (let* ((s5-2 quaternion->matrix) + (s4-1 (-> self tgt-face-mat)) + (a0-14 (the-as process-focusable gp-0)) + (t9-3 (method-of-object a0-14 get-quat)) + ) + 1 + (s5-2 s4-1 (t9-3 a0-14)) + ) + (vector-reset! (-> self pitch-off)) + (set! (-> self upspeed) 0.0) + (set! (-> self on-ground) + (zero? (logand (-> (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 + ((>= (- (-> self clock frame-counter) (process-focusable-method-25 (the-as process-focusable gp-0))) + (-> *CAMERA-bank* attack-timeout) + ) + (set! (-> self being-attacked) #f) + ) + (else + (set! (-> self attack-start) (-> self clock frame-counter)) + (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 + ((logtest? (-> (the-as process-focusable gp-0) focus-status) (focus-status under-water)) + (set! (-> self under-water) 2) + ) + (else + (set! (-> self under-water) 0) + 0 + ) + ) + (let ((gp-1 (the-as process-focusable (new 'stack-no-clear 'vector)))) + (vector--float*! + (the-as vector gp-1) + (-> self tpos-curr-adj) + (-> self local-down) + (-> self settings target-height) + ) + (tracking-spline-method-10 (-> self target-spline) (the-as vector gp-1)) + ) + ) + ) + ) + ) + +;; WARN: Return type mismatch object vs symbol. +(defbehavior master-track-target camera-master () + (let ((gp-0 (handle->process (-> self focus handle)))) + (the-as + symbol + (cond + ((and *target* (not gp-0)) + (try-update-focus (-> self focus) *target*) + (logior! (-> self master-options) 1) + (reset-target-tracking) + ) + ((and (logtest? (-> self master-options) 1) (not gp-0)) + (let ((v0-1 (the-as object (logand -2 (-> self master-options))))) + (set! (-> self master-options) (the-as uint v0-1)) + v0-1 + ) + ) + ((paused?) + #f + ) + (gp-0 + (logior! (-> self master-options) 1) + (cond + ((>= (- (-> self clock frame-counter) (process-focusable-method-25 (the-as target gp-0))) + (-> *CAMERA-bank* attack-timeout) + ) + (set! (-> self being-attacked) #f) + ) + (else + (if (not (-> self being-attacked)) + (set! (-> self attack-start) (-> self clock frame-counter)) + ) + (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 + ((logtest? (-> (the-as target gp-0) focus-status) (focus-status 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)) + (let* ((s5-1 quaternion->matrix) + (s4-0 (-> self tgt-rot-mat)) + (a0-12 (the-as target gp-0)) + (t9-4 (method-of-object a0-12 get-quat)) + ) + 2 + (s5-1 s4-0 (t9-4 a0-12)) + ) + (let* ((s5-2 quaternion->matrix) + (s4-1 (-> self tgt-face-mat)) + (a0-14 (the-as target gp-0)) + (t9-6 (method-of-object a0-14 get-quat)) + ) + 1 + (s5-2 s4-1 (t9-6 a0-14)) + ) + (cond + ((< (-> self ease-t) 1.0) + (new 'stack-no-clear 'vector) + (cond + ((logtest? (-> self master-options) 8) + (vector-lerp! + (-> self tpos-curr) + (-> self ease-from) + (-> self ease-to) + (parameter-ease-sin-clamp (-> self ease-t)) + ) + (set! (-> self master-options) (logand -9 (-> self master-options))) + ) + (else + (vector-lerp! + (-> self tpos-curr) + (-> self ease-from) + (get-trans (the-as target 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 target gp-0) 4) quad)) + ) + ) + (when (logtest? (-> (the-as target gp-0) focus-status) (focus-status 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) (the-as vector (&-> self stack 256)) 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) (zero? (logand (-> (the-as target gp-0) focus-status) (focus-status in-air)))) + (let ((s5-7 (new-stack-vector0))) + 0.0 + (cond + ((and (logtest? (-> (the-as target gp-0) focus-status) (focus-status in-air)) + (zero? (logand (focus-status halfpipe super) (-> (the-as target 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 target 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 (logtest? (-> (the-as target gp-0) focus-status) (focus-status touch-water)) + (zero? (logand (focus-status mech) (-> (the-as target 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 (zero? (logand (-> self settings slave-options) (cam-slave-options JUMP_PITCHES))) + (reset-follow) + ) + (when (and (logtest? (-> (the-as target gp-0) focus-status) (focus-status on-water under-water)) + (zero? (logand (focus-status mech) (-> (the-as target gp-0) focus-status))) + ) + (let ((f0-41 (- (process-focusable-method-24 (the-as target 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 target 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) (the-as float (-> 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 (the-as vector (&-> arg0 stack 112)) (-> *camera-combiner* inv-camera-rot vector 2)) + (vector-dot (the-as vector (&-> arg1 stack 112)) (-> *camera-combiner* inv-camera-rot vector 2)) + ) + ) + ) + ) + +(defbehavior master-choose-entity camera-master ((arg0 cam-setting-data)) + (local-vars + (r0-0 uint128) + (v1-22 symbol) + (v1-52 uint128) + (sv-96 int) + (sv-112 process) + (sv-128 (pointer process)) + (sv-144 int) + (sv-160 string) + (sv-176 string) + (sv-192 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* ((s1-1 (get-process *camera-dead-pool* camera-slave #x4000)) + (s3-1 (when s1-1 + (let ((t9-7 (method-of-type camera-slave activate))) + (t9-7 + (the-as camera-slave s1-1) + *camera* + (symbol->string (-> camera-slave symbol)) + (the-as pointer #x70004000) + ) + ) + (run-now-in-process s1-1 cam-slave-init s2-0 s5-0) + (the-as (pointer camera-slave) (-> s1-1 ppointer)) + ) + ) + ) + (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-51 (the-as uint128 sv-96))) + (.pcpyud v1-52 v1-51 r0-0) + ) + (< s2-1 (shr (* (the-as int v1-52) 2) 49)) + ) + (let ((s0-0 (entity-by-name (the-as string (-> (the-as (pointer uint32) (&+ s4-1 (* s2-1 4)))))))) + (cond + (s0-0 + (let ((s1-2 (cam-state-from-entity s0-0))) + (cond + (s1-2 + (set! sv-112 (get-process *camera-dead-pool* camera-slave #x4000)) + (set! v1-22 (when sv-112 + (set! sv-128 (the-as (pointer process) v1-22)) + (let ((t9-14 (method-of-type camera-slave activate))) + (t9-14 + (the-as camera-slave sv-112) + *camera* + (symbol->string (-> camera-slave symbol)) + (the-as pointer #x70004000) + ) + ) + (run-now-in-process sv-112 cam-slave-init s1-2 s0-0) + (set! sv-128 (-> sv-112 ppointer)) + v1-22 + ) + ) + (cond + (sv-128 + (setup-slave-for-hopefull (the-as camera-slave (ppointer->process sv-128))) + (cond + ((master-is-hopeful-better? + (the-as camera-slave (ppointer->process s3-1)) + (the-as camera-slave (ppointer->process sv-128)) + ) + (if s3-1 + (deactivate (-> s3-1 0)) + ) + (set! s3-1 (the-as (pointer camera-slave) sv-128)) + (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 (-> sv-128 0)) + ) + ) + ) + (else + (format 0 "ERROR : alternate region activate failed~%") + ) + ) + ) + (else + (let ((s1-5 format)) + (set! sv-144 0) + (set! sv-160 "ERROR : alternate camera region '~S' didn't produce a state~%") + (let ((a2-14 (res-lump-struct s0-0 'name structure))) + (s1-5 sv-144 sv-160 a2-14) + ) + ) + ) + ) + ) + ) + (else + (let ((s1-7 format) + (s0-1 0) + ) + (set! sv-176 "ERROR : alternate '~S' not found for '~S'~%") + (set! sv-192 (-> (the-as (pointer uint32) (&+ s4-1 (* s2-1 4))))) + (let ((a3-8 (res-lump-struct s5-0 'name structure))) + (s1-7 s0-1 sv-176 sv-192 a3-8) + ) + ) + ) + ) + ) + (+! 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 + (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-8 (cam-slave-get-float s5-0 'stringMaxLength (-> *CAMERA-bank* default-string-max-z)))) + (if (< 405504.0 f0-8) + (set! f0-8 (-> *CAMERA-bank* default-string-max-z)) + ) + (set! (-> arg0 string-max-length) f0-8) + ) + (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 (method-of-type res-lump get-property-value)) + (s3-0 s5-0) + ) + (format (clear *res-key-string*) "~S~S" 'flags '-on) + (let ((s4-1 (s4-0 + s3-0 + (string->symbol *res-key-string*) + 'interp + -1000000000.0 + (the-as uint128 0) + (the-as (pointer res-tag) #f) + *res-static-buf* + ) + ) + (s3-1 (method-of-type res-lump get-property-value)) + ) + (format (clear *res-key-string*) "~S~S" 'flags '-off) + (let ((v1-19 (s3-1 + s5-0 + (string->symbol *res-key-string*) + 'interp + -1000000000.0 + (the-as uint128 0) + (the-as (pointer res-tag) #f) + *res-static-buf* + ) + ) + ) + (logior! (-> arg0 slave-options) s4-1) + (logclear! (-> arg0 slave-options) v1-19) + ) + ) + ) + ) + ) + 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 :from *camera-dead-pool* :to *camera*) + ) + ) + ) + ) + 0 + (none) + ) + +(defstate cam-master-active (camera-master) + :event (behavior ((arg0 process) (arg1 int) (arg2 symbol) (arg3 event-message-block)) + (local-vars (v0-0 none) (v1-125 uint)) + (rlet ((vf0 :class vf)) + (init-vf0-vector) + (let ((v1-0 arg2)) + (the-as + object + (cond + ((= v1-0 'dist-from-interp-src) + (cond + ((not *camera-combiner*) + #x48c80000 + ) + ((= (-> *camera-combiner* interp-val) 0.0) + 0 + ) + (else + (-> *camera-combiner* dist-from-src) + ) + ) + ) + ((= v1-0 'dist-from-interp-dest) + (cond + ((not *camera-combiner*) + 0 + ) + ((= (-> *camera-combiner* interp-val) 0.0) + #x48c80000 + ) + (else + (-> *camera-combiner* dist-from-dest) + ) + ) + ) + ((= v1-0 'level-deactivate) + (format 0 "ERROR : *camera* level-deactivate event not supported anymore~%") + ) + ((= v1-0 'clear-entity) + (format 0 "ERROR : *camera* clear-entity event not supported anymore~%") + ) + ((= v1-0 'no-intro) + (format 0 "ERROR : *camera* no-intro event not supported anymore '~S'~%" (-> arg3 param 0)) + ) + ((= v1-0 'force-blend) + (format 0 "ERROR : *camera* force-blend event not supported anymore '~S'~%" (-> arg3 param 0)) + ) + ((= v1-0 'teleport-to-transformq) + (when (> arg1 0) + (let ((gp-1 (the-as object (-> arg3 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) vector 0 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 + ) + ) + ((= v1-0 '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) + ) + ((= v1-0 'teleport-to-vector-start-string) + (when (> arg1 0) + (let ((s5-0 (the-as object (-> arg3 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) + ) + ) + ((= v1-0 'change-target) + (let ((a1-15 (-> arg3 param 0))) + (cond + ((not a1-15) + (clear-focused (-> self focus)) + (set! (-> self master-options) (logand -2 (-> self master-options))) + ) + (else + (try-update-focus (-> self focus) (the-as process-focusable a1-15)) + (logior! (-> self master-options) 1) + (reset-target-tracking) + ) + ) + ) + (set! (-> *camera-combiner* tracking no-follow) #f) + #f + ) + ((= v1-0 'intro-done?) + (or (not (-> self slave)) (>= (-> self slave 0 intro-t) 1.0)) + ) + ((= v1-0 'query-state) + (and (-> self slave) (= (-> self slave 0 next-state) (-> arg3 param 0))) + ) + ((= v1-0 'change-to-entity-by-name) + (format + 0 + "ERROR : *camera* change-to-entity-by-name event not supported anymore '~S'~%" + (-> arg3 param 0) + ) + ) + ((= v1-0 'change-state) + (format 0 "ERROR : *camera* change-state event not supported anymore ~A~%" (-> arg3 param 0)) + ) + ((= v1-0 'set-slave) + (let ((s5-1 (process->ppointer (the-as process (-> arg3 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) 2) + (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 + ((zero? (-> gp-4 0 blend-from-type)) + (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) 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)) + ) + ) + ) + ) + ((= v1-0 'ease-in) + (cond + ((< arg1 1) + (set! (-> self ease-t) 0.0) + (set! (-> self master-options) (logand -9 (-> self master-options))) + ) + ((< arg1 2) + (if (< (the-as float (-> arg3 param 0)) (-> self ease-t)) + (set! (-> self ease-t) (the-as float (-> arg3 param 0))) + ) + (set! (-> self master-options) (logand -9 (-> self master-options))) + ) + (else + (if (< (the-as float (-> arg3 param 0)) (-> self ease-t)) + (set! (-> self ease-t) (the-as float (-> arg3 param 0))) + ) + (set! (-> self ease-to quad) (-> (the-as vector (-> arg3 param 1)) quad)) + (logior! (-> self master-options) 8) + ) + ) + (set! (-> self ease-step) 0.033333335) + (set! v0-0 (the-as none (-> self ease-from))) + (set! (-> (the-as vector v0-0) quad) (-> self tpos-curr-adj quad)) + v0-0 + ) + ((= v1-0 'damp-up) + (set! (-> self upspeed) 0.0) + ) + ((= v1-0 'reset-follow) + (reset-follow) + ) + ((= v1-0 'teleport) + (reset-target-tracking) + (if (-> self slave) + (send-event (ppointer->process (-> self slave)) arg2) + ) + (send-event *camera-combiner* arg2) + ) + ((= v1-0 'toggle-slave-option) + (logxor! (-> self slave-options) (-> arg3 param 0)) + (if (-> self slave) + (logxor! (-> self slave 0 options) (-> arg3 param 0)) + ) + (when (-> self decel) + (set! v0-0 (the-as none (logxor (-> self decel 0 options) (-> arg3 param 0)))) + (set! (-> self decel 0 options) (the-as uint v0-0)) + v0-0 + ) + ) + ((= v1-0 'slave-option?) + (and (-> self slave) (logtest? (-> self slave 0 options) (-> arg3 param 0))) + ) + ((= v1-0 'set-slave-option) + (when (-> self slave) + (set! v0-0 (the-as none (logior (-> self slave 0 options) (-> arg3 param 0)))) + (set! (-> self slave 0 options) (the-as uint v0-0)) + v0-0 + ) + ) + ((= v1-0 'clear-slave-option) + (when (-> self slave) + (set! v0-0 (the-as none (logclear (-> self slave 0 options) (-> arg3 param 0)))) + (set! (-> self slave 0 options) (the-as uint v0-0)) + v0-0 + ) + ) + ((= v1-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 (the-as none (-> *camera-combiner* tracking follow-off))) + (.svf (&-> (the-as vector v0-0) quad) vf0) + v0-0 + ) + ((= v1-0 'yes-follow) + (if (-> self slave) + (set! (-> self slave 0 tracking no-follow) #f) + ) + (set! (-> *camera-combiner* tracking no-follow) #f) + #f + ) + ((= v1-0 'blend-from-as-fixed) + (let ((t9-42 format) + (a0-101 0) + (a1-35 "ERROR : *camera* blend-from-as-fixed event not supported anymore~%") + ) + (-> arg3 param 0) + (t9-42 a0-101 a1-35) + ) + ) + ((= v1-0 'point-of-interest) + (let ((t9-43 format) + (a0-102 0) + (a1-36 "ERROR : *camera* point-of-interest event not supported anymore~%") + ) + (-> arg3 param 0) + (t9-43 a0-102 a1-36) + ) + ) + ((= v1-0 'part-water-drip) + (set! (-> self water-drip-time) (-> self clock frame-counter)) + (set! (-> self water-drip-mult) (the-as float (-> arg3 param 0))) + (set! (-> self water-drip-speed) (the-as float (-> arg3 param 1))) + ) + (else + (and (-> self slave) (let ((v1-237 (new 'stack-no-clear 'event-message-block))) + (set! (-> v1-237 from) (process->ppointer arg0)) + (set! (-> v1-237 num-params) arg1) + (set! (-> v1-237 message) arg2) + (set! (-> v1-237 param 0) (-> arg3 param 0)) + (set! (-> v1-237 param 1) (-> arg3 param 1)) + (set! (-> v1-237 param 2) (-> arg3 param 2)) + (set! (-> v1-237 param 3) (-> arg3 param 3)) + (set! (-> v1-237 param 4) (-> arg3 param 4)) + (set! (-> v1-237 param 5) (-> arg3 param 5)) + (send-event-function (ppointer->process (-> self slave)) v1-237) + ) + ) + ) + ) + ) + ) + ) + ) + :enter (behavior () + (let ((v1-1 + (process-spawn camera-slave :init cam-slave-init cam-free-floating #f :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-8 (process-spawn camera-slave :init cam-slave-init cam-fixed #f :from *camera-dead-pool* :to self))) + (set! (-> self decel) (the-as (pointer camera-slave) v1-8)) + (if (not v1-8) + (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) + ) + (none) + ) + :trans (behavior () + (when (not (paused?)) + (vector-negate! + (-> self local-down) + (vector-normalize-copy! (-> self local-down) (-> *standard-dynamics* gravity) 1.0) + ) + (cam-master-effect) + ) + (none) + ) + :code (behavior () + (until #f + (when *debug-segment* + (let ((gp-0 (-> *display* frames (-> *display* on-screen) profile-array data 0)) + (v1-7 'camera) + (s5-0 *profile-camera-color*) + ) + (when (and *dproc* *debug-segment*) + (let ((s4-0 (-> gp-0 data (-> gp-0 count)))) + (let ((s3-0 (-> gp-0 base-time))) + (set! (-> s4-0 name) v1-7) + (set! (-> s4-0 start-time) (the-as int (- (timer-count (the-as timer-bank #x10000800)) (the-as uint s3-0)))) + ) + (set! (-> s4-0 depth) (the-as uint (-> gp-0 depth))) + (set! (-> s4-0 color) s5-0) + (set! (-> gp-0 segment (-> gp-0 depth)) s4-0) + ) + (+! (-> gp-0 count) 1) + (+! (-> gp-0 depth) 1) + (set! (-> gp-0 max-depth) (max (-> gp-0 max-depth) (-> gp-0 depth))) + ) + ) + 0 + ) + (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))) + ) + (when *debug-segment* + (let ((gp-1 (-> *display* frames (-> *display* on-screen) profile-array data 0))) + (when (and *dproc* *debug-segment*) + (let* ((v1-56 (+ (-> gp-1 depth) -1)) + (s5-1 (-> gp-1 segment v1-56)) + (s4-1 (-> gp-1 base-time)) + ) + (when (>= v1-56 0) + (set! (-> s5-1 end-time) (the-as int (- (timer-count (the-as timer-bank #x10000800)) (the-as uint s4-1)))) + (+! (-> gp-1 depth) -1) + ) + ) + ) + ) + 0 + ) + (suspend) + ) + #f + (none) + ) + ) + +(defbehavior cam-master-init camera-master () + (stack-size-set! (-> self main-thread) 512) + (logclear! (-> self mask) (process-mask menu)) + (set! (-> self master-options) (the-as uint 0)) + (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) (the-as uint 560)) + (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 camera-master ((obj camera-master) (arg0 vector)) + (if (handle->process (-> obj focus handle)) + (vector-! arg0 (-> obj tpos-curr) (-> obj tpos-old)) + (vector-reset! arg0) + ) + arg0 + ) + +(defmethod camera-master-method-15 camera-master ((obj camera-master) (arg0 vector)) + (if (and (-> obj slave) (-> obj slave 0 next-state) (= (-> obj slave 0 next-state name) 'cam-string)) + (set! (-> arg0 quad) (-> obj slave 0 view-flat quad)) + (vector-reset! arg0) + ) + arg0 + ) diff --git a/goal_src/jak2/engine/camera/camera-h.gc b/goal_src/jak2/engine/camera/camera-h.gc index cad4804b49..05bce6dbd2 100644 --- a/goal_src/jak2/engine/camera/camera-h.gc +++ b/goal_src/jak2/engine/camera/camera-h.gc @@ -48,6 +48,11 @@ (declare-type camera-master process) (define-extern cam-master-init (function none :behavior camera-master)) +;; NOTE - for cam-master +(define-extern cam-master-effect (function none :behavior camera-master)) +(define-extern camera-master-debug (function camera-master none)) +(define-extern group-rain-screend-drop sparticle-launch-group) + (define-extern parameter-ease-sin-clamp (function float float)) ;; DECOMP BEGINS @@ -122,7 +127,7 @@ (tracking-spline-method-19 (_type_ float vector tracking-spline-sampler) vector 19) (tracking-spline-method-20 (_type_ vector int) none 20) (tracking-spline-method-21 (_type_ vector float float float) vector 21) - (tracking-spline-method-22 (_type_ float) none 22) + (tracking-spline-method-22 (_type_ float) symbol 22) (debug-draw-spline (_type_) none 23) ) ) @@ -448,13 +453,6 @@ (:methods (camera-master-method-14 (_type_ vector) vector 14) (camera-master-method-15 (_type_ vector) vector 15) - (camera-master-method-16 (_type_ symbol) none 16) + (camera-master-method-16 (_type_ symbol) int 16) ) ) - - -0 - - - - diff --git a/goal_src/jak2/engine/camera/camera.gc b/goal_src/jak2/engine/camera/camera.gc index 1e8619856c..9fea451264 100644 --- a/goal_src/jak2/engine/camera/camera.gc +++ b/goal_src/jak2/engine/camera/camera.gc @@ -52,6 +52,7 @@ ) ) +;; 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)) @@ -854,6 +855,7 @@ ) ) +;; WARN: Return type mismatch int vs symbol. (defmethod tracking-spline-method-22 tracking-spline ((obj tracking-spline) (arg0 float)) (when (< arg0 (-> obj summed-len)) (let ((s5-0 (new 'stack-no-clear 'tracking-spline-sampler))) @@ -865,8 +867,7 @@ (tracking-spline-method-14 obj s5-0) ) ) - 0 - (none) + (the-as symbol 0) ) (defmethod tracking-spline-method-9 tracking-spline ((obj tracking-spline)) @@ -1545,11 +1546,7 @@ (sv-272 matrix) (sv-288 vector) ) - (rlet ((acc :class vf) - (vf0 :class vf) - (vf1 :class vf) - (vf2 :class vf) - (vf3 :class vf) + (rlet ((vf0 :class vf) (vf4 :class vf) (vf5 :class vf) (vf6 :class vf) @@ -1582,21 +1579,11 @@ (vector-normalize! s0-0 f28-0) ) (vector-! (-> arg0 looking-interesting) (-> *camera* settings point-of-interest) (-> arg0 follow-pt)) - (let ((v1-15 (-> arg0 looking-interesting))) - (let ((a0-16 (-> arg0 follow-pt)) - (a1-7 (-> arg0 looking-interesting)) - (f0-4 (-> arg0 point-of-interest-blend value)) - ) - (.lvf vf2 (&-> a1-7 quad)) - (.lvf vf1 (&-> a0-16 quad)) - (let ((a0-17 f0-4)) - (.mov vf3 a0-17) - ) - ) - (.add.x.vf vf4 vf0 vf0 :mask #b1000) - (.mul.x.vf acc vf2 vf3) - (.add.mul.w.vf vf4 vf1 vf0 acc :mask #b111) - (.svf (&-> v1-15 quad) vf4) + (vector+float*! + (-> arg0 looking-interesting) + (-> arg0 follow-pt) + (-> arg0 looking-interesting) + (-> arg0 point-of-interest-blend value) ) ) (else @@ -1637,10 +1624,10 @@ ) (matrix-rotate-x! sv-240 f30-0) (let ((t9-6 matrix*!) - (a0-29 s1-0) + (a0-28 s1-0) (a2-3 s1-0) ) - (t9-6 a0-29 sv-240 a2-3) + (t9-6 a0-28 sv-240 a2-3) ) ) ) @@ -1664,17 +1651,17 @@ (slave-matrix-blend-2 (-> arg0 inv-mat) arg2 s0-0 s1-0) ) (else - (let* ((v1-59 (-> arg0 inv-mat)) + (let* ((v1-60 (-> arg0 inv-mat)) (a3-2 s1-0) - (a0-35 (-> a3-2 vector 0 quad)) + (a0-34 (-> a3-2 vector 0 quad)) (a1-19 (-> a3-2 vector 1 quad)) (a2-7 (-> a3-2 vector 2 quad)) (a3-3 (-> a3-2 trans quad)) ) - (set! (-> v1-59 vector 0 quad) a0-35) - (set! (-> v1-59 vector 1 quad) a1-19) - (set! (-> v1-59 vector 2 quad) a2-7) - (set! (-> v1-59 trans quad) a3-3) + (set! (-> v1-60 vector 0 quad) a0-34) + (set! (-> v1-60 vector 1 quad) a1-19) + (set! (-> v1-60 vector 2 quad) a2-7) + (set! (-> v1-60 trans quad) a3-3) ) ) ) @@ -1710,16 +1697,6 @@ ) ) -;; 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] @@ -1733,14 +1710,6 @@ (sv-176 matrix) (sv-192 vector) ) - (rlet ((acc :class vf) - (vf0 :class vf) - (vf1 :class vf) - (vf2 :class vf) - (vf3 :class vf) - (vf4 :class vf) - ) - (init-vf0-vector) (set! sv-144 arg5) (let ((s0-0 (new-stack-vector0))) (set! sv-160 (new 'stack-no-clear 'vector)) @@ -1815,71 +1784,19 @@ ) ) (when arg4 - (let ((v1-33 arg0)) - (let ((a0-24 arg0) - (a1-17 s3-0) - (f0-15 (vector-dot arg1 s3-0)) - ) - (.lvf vf2 (&-> a1-17 quad)) - (.lvf vf1 (&-> a0-24 quad)) - (let ((a0-25 f0-15)) - (.mov vf3 a0-25) - ) - ) - (.add.x.vf vf4 vf0 vf0 :mask #b1000) - (.mul.x.vf acc vf2 vf3) - (.add.mul.w.vf vf4 vf1 vf0 acc :mask #b111) - (.svf (&-> v1-33 quad) vf4) - ) - (let ((v1-34 arg0)) - (let ((a0-26 arg0) - (a1-18 s3-0) - (f0-17 (* arg3 (vector-dot (vector-! (new-stack-vector0) arg2 arg1) s3-0))) - ) - (.lvf vf2 (&-> a1-18 quad)) - (.lvf vf1 (&-> a0-26 quad)) - (let ((a0-27 f0-17)) - (.mov vf3 a0-27) - ) - ) - (.add.x.vf vf4 vf0 vf0 :mask #b1000) - (.mul.x.vf acc vf2 vf3) - (.add.mul.w.vf vf4 vf1 vf0 acc :mask #b111) - (.svf (&-> v1-34 quad) vf4) - ) - ) + (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 ) + arg0 ) -;; 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)) - (rlet ((acc :class vf) - (vf0 :class vf) - (vf1 :class vf) - (vf2 :class vf) - (vf3 :class vf) - (vf4 :class vf) - ) - (init-vf0-vector) (set! sv-144 arg4) (let ((s1-0 (new-stack-vector0))) (set! sv-160 (new 'stack-no-clear 'vector)) @@ -1937,45 +1854,10 @@ ) (vector-normalize! arg0 (lerp f28-0 f26-0 f30-0)) (when arg3 - (let ((v1-21 arg0)) - (let ((a0-24 arg0) - (a1-17 s3-0) - (f0-11 (vector-dot arg1 s3-0)) - ) - (.lvf vf2 (&-> a1-17 quad)) - (.lvf vf1 (&-> a0-24 quad)) - (let ((a0-25 f0-11)) - (.mov vf3 a0-25) - ) - ) - (.add.x.vf vf4 vf0 vf0 :mask #b1000) - (.mul.x.vf acc vf2 vf3) - (.add.mul.w.vf vf4 vf1 vf0 acc :mask #b111) - (.svf (&-> v1-21 quad) vf4) - ) - (let ((v1-22 arg0)) - (let ((a0-26 arg0) - (a1-18 s3-0) - (f0-14 (* f30-0 (vector-dot (vector-! (new-stack-vector0) arg2 arg1) s3-0))) - ) - (.lvf vf2 (&-> a1-18 quad)) - (.lvf vf1 (&-> a0-26 quad)) - (let ((a0-27 f0-14)) - (.mov vf3 a0-27) - ) - ) - (.add.x.vf vf4 vf0 vf0 :mask #b1000) - (.mul.x.vf acc vf2 vf3) - (.add.mul.w.vf vf4 vf1 vf0 acc :mask #b111) - (.svf (&-> v1-22 quad) vf4) - ) - ) + (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 ) + arg0 ) - - - - diff --git a/goal_src/jak2/engine/game/main.gc b/goal_src/jak2/engine/game/main.gc index d3be46e6e3..71f2cf4645 100644 --- a/goal_src/jak2/engine/game/main.gc +++ b/goal_src/jak2/engine/game/main.gc @@ -719,7 +719,7 @@ ; ) (let ((gp-1 *display*)) (set! *teleport* #t) - ; (update *setting-control*) + (update *setting-control*) ; (init-time-of-day-context *time-of-day-context*) (format 0 "about to display-sync~%") (display-sync gp-1) diff --git a/goal_src/jak2/engine/process-drawable/process-focusable.gc b/goal_src/jak2/engine/process-drawable/process-focusable.gc index 3030812c8c..7c9911197c 100644 --- a/goal_src/jak2/engine/process-drawable/process-focusable.gc +++ b/goal_src/jak2/engine/process-drawable/process-focusable.gc @@ -56,13 +56,14 @@ (get-quat (_type_) quaternion 21) (get-transv (_type_) vector 22) (process-focusable-method-23 (_type_) none 23) - (process-focusable-method-24 (_type_) none 24) - (process-focusable-method-25 (_type_) int 25) + (process-focusable-method-24 (_type_) float 24) + (process-focusable-method-25 (_type_) time-frame 25) (process-focusable-method-26 (_type_) none 26) ) ) +;; WARN: Return type mismatch structure vs vector. (defmethod get-trans process-focusable ((obj process-focusable) (arg0 int)) (let ((gp-0 (-> obj root))) (the-as vector (cond @@ -97,8 +98,7 @@ ) (defmethod process-focusable-method-24 process-focusable ((obj process-focusable)) - 0 - (none) + 0.0 ) (defmethod process-focusable-method-26 process-focusable ((obj process-focusable)) @@ -106,12 +106,7 @@ (none) ) +;; WARN: Return type mismatch int vs time-frame. (defmethod process-focusable-method-25 process-focusable ((obj process-focusable)) - 0 + (the-as time-frame 0) ) - -0 - - - - diff --git a/goal_src/jak2/engine/ui/text-h.gc b/goal_src/jak2/engine/ui/text-h.gc index e1f6e43d9c..95fff7d8d5 100644 --- a/goal_src/jak2/engine/ui/text-h.gc +++ b/goal_src/jak2/engine/ui/text-h.gc @@ -11,7 +11,7 @@ (define-extern load-game-text-info "Load text, if needed. txt-name is the group name, curr-text is the _symbol_ for the game-text-info, and heap is the heap to load to. The heap will be cleared." - (function string (pointer game-text-info) kheap int)) + (function string symbol kheap int)) (define-extern print-game-text-scaled "Print text, with a given scaling" (function string float font-context int none)) (define-extern print-game-text "Print text." (function string font-context symbol int int float)) diff --git a/goal_src/jak2/engine/ui/text.gc b/goal_src/jak2/engine/ui/text.gc index 85c599c6f5..d0437fe70a 100644 --- a/goal_src/jak2/engine/ui/text.gc +++ b/goal_src/jak2/engine/ui/text.gc @@ -168,7 +168,6 @@ ) (defmethod lookup-text! game-text-info ((obj game-text-info) (arg0 game-text-id) (arg1 symbol)) - (format 0 "hello world") (cond ((= obj #f) (cond @@ -234,11 +233,11 @@ (define text-is-loading #f) ;; WARN: Found some very strange gotos. Check result carefully, this is not well tested. -(defun load-game-text-info ((arg0 string) (arg1 (pointer game-text-info)) (arg2 kheap)) +(defun load-game-text-info ((arg0 string) (arg1 symbol) (arg2 kheap)) "Load text, if needed. txt-name is the group name, curr-text is the _symbol_ for the game-text-info, and heap is the heap to load to. The heap will be cleared." (local-vars (v0-3 int) (sv-16 game-text-info) (sv-24 int) (sv-32 int) (sv-40 int)) - (set! sv-16 (-> arg1 0)) + (set! sv-16 (the-as game-text-info (-> arg1 value))) (set! sv-24 (the-as int (-> *setting-control* user-current language))) (set! sv-32 0) (set! sv-40 (&- (-> arg2 top) (the-as uint (-> arg2 base)))) @@ -298,11 +297,11 @@ (flush-cache 0) (let ((s3-1 link)) (format (clear *temp-string*) "~D~S.TXT" sv-24 arg0) - (set! (-> arg1 0) (the-as game-text-info (s3-1 s2-1 (-> *temp-string* data) sv-32 arg2 0))) + (set! (-> arg1 value) (s3-1 s2-1 (-> *temp-string* data) sv-32 arg2 0)) ) ) - (if (<= (the-as int (-> arg1 0)) 0) - (set! (-> arg1 0) #f) + (if (<= (the-as int (-> arg1 value)) 0) + (set! (-> arg1 value) (the-as object #f)) ) ) (set! v0-3 0) @@ -315,7 +314,7 @@ This function made more sense back when text files were split up, but in the end they put everything in a single text group and file." (if (or *level-text-file-load-flag* (>= arg0 0)) - (load-game-text-info "common" (the-as (pointer game-text-info) '*common-text*) *common-text-heap*) + (load-game-text-info "common" '*common-text* *common-text-heap*) ) 0 (none) diff --git a/test/decompiler/reference/jak2/engine/camera/cam-master_REF.gc b/test/decompiler/reference/jak2/engine/camera/cam-master_REF.gc new file mode 100644 index 0000000000..6e37341fbe --- /dev/null +++ b/test/decompiler/reference/jak2/engine/camera/cam-master_REF.gc @@ -0,0 +1,1162 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition for method 16 of type camera-master +(defmethod camera-master-method-16 camera-master ((obj camera-master) (arg0 symbol)) + (let ((a2-0 (the-as target (handle->process (-> obj focus handle)))) + (v1-4 0) + ) + (if a2-0 + (set! v1-4 (the-as int (incomplete-bitfield-access (-> a2-0 control pat-ignore-mask)))) + ) + (logior (if arg0 + #x9010002 + #x9000002 + ) + v1-4 + ) + ) + ) + +;; definition for function reset-follow +;; INFO: Used lq/sq +(defbehavior reset-follow camera-master () + (let ((a0-1 (handle->process (-> self focus handle)))) + (when (the-as process-focusable a0-1) + (set! (-> self tpos-old quad) (-> (get-trans (the-as process-focusable a0-1) 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)) + (set! (-> self upspeed) 0.0) + ) + ) + ) + +;; definition for function reset-target-tracking +;; INFO: Used lq/sq +;; WARN: Return type mismatch none vs symbol. +(defbehavior reset-target-tracking camera-master () + (let ((gp-0 (handle->process (-> self focus handle)))) + (the-as + symbol + (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)) + (let* ((s5-1 quaternion->matrix) + (s4-0 (-> self tgt-rot-mat)) + (a0-12 (the-as process-focusable gp-0)) + (t9-1 (method-of-object a0-12 get-quat)) + ) + 2 + (s5-1 s4-0 (t9-1 a0-12)) + ) + (let* ((s5-2 quaternion->matrix) + (s4-1 (-> self tgt-face-mat)) + (a0-14 (the-as process-focusable gp-0)) + (t9-3 (method-of-object a0-14 get-quat)) + ) + 1 + (s5-2 s4-1 (t9-3 a0-14)) + ) + (vector-reset! (-> self pitch-off)) + (set! (-> self upspeed) 0.0) + (set! (-> self on-ground) + (zero? (logand (-> (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 + ((>= (- (-> self clock frame-counter) (process-focusable-method-25 (the-as process-focusable gp-0))) + (-> *CAMERA-bank* attack-timeout) + ) + (set! (-> self being-attacked) #f) + ) + (else + (set! (-> self attack-start) (-> self clock frame-counter)) + (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 + ((logtest? (-> (the-as process-focusable gp-0) focus-status) (focus-status under-water)) + (set! (-> self under-water) 2) + ) + (else + (set! (-> self under-water) 0) + 0 + ) + ) + (let ((gp-1 (the-as process-focusable (new 'stack-no-clear 'vector)))) + (vector--float*! + (the-as vector gp-1) + (-> self tpos-curr-adj) + (-> self local-down) + (-> self settings target-height) + ) + (tracking-spline-method-10 (-> self target-spline) (the-as vector gp-1)) + ) + ) + ) + ) + ) + +;; definition for function master-track-target +;; INFO: Used lq/sq +;; WARN: Return type mismatch object vs symbol. +(defbehavior master-track-target camera-master () + (let ((gp-0 (handle->process (-> self focus handle)))) + (the-as + symbol + (cond + ((and *target* (not gp-0)) + (try-update-focus (-> self focus) *target*) + (logior! (-> self master-options) 1) + (reset-target-tracking) + ) + ((and (logtest? (-> self master-options) 1) (not gp-0)) + (let ((v0-1 (the-as object (logand -2 (-> self master-options))))) + (set! (-> self master-options) (the-as uint v0-1)) + v0-1 + ) + ) + ((paused?) + #f + ) + (gp-0 + (logior! (-> self master-options) 1) + (cond + ((>= (- (-> self clock frame-counter) (process-focusable-method-25 (the-as target gp-0))) + (-> *CAMERA-bank* attack-timeout) + ) + (set! (-> self being-attacked) #f) + ) + (else + (if (not (-> self being-attacked)) + (set! (-> self attack-start) (-> self clock frame-counter)) + ) + (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 + ((logtest? (-> (the-as target gp-0) focus-status) (focus-status 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)) + (let* ((s5-1 quaternion->matrix) + (s4-0 (-> self tgt-rot-mat)) + (a0-12 (the-as target gp-0)) + (t9-4 (method-of-object a0-12 get-quat)) + ) + 2 + (s5-1 s4-0 (t9-4 a0-12)) + ) + (let* ((s5-2 quaternion->matrix) + (s4-1 (-> self tgt-face-mat)) + (a0-14 (the-as target gp-0)) + (t9-6 (method-of-object a0-14 get-quat)) + ) + 1 + (s5-2 s4-1 (t9-6 a0-14)) + ) + (cond + ((< (-> self ease-t) 1.0) + (new 'stack-no-clear 'vector) + (cond + ((logtest? (-> self master-options) 8) + (vector-lerp! + (-> self tpos-curr) + (-> self ease-from) + (-> self ease-to) + (parameter-ease-sin-clamp (-> self ease-t)) + ) + (set! (-> self master-options) (logand -9 (-> self master-options))) + ) + (else + (vector-lerp! + (-> self tpos-curr) + (-> self ease-from) + (get-trans (the-as target 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 target gp-0) 4) quad)) + ) + ) + (when (logtest? (-> (the-as target gp-0) focus-status) (focus-status 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) (the-as vector (&-> self stack 256)) 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) (zero? (logand (-> (the-as target gp-0) focus-status) (focus-status in-air)))) + (let ((s5-7 (new-stack-vector0))) + 0.0 + (cond + ((and (logtest? (-> (the-as target gp-0) focus-status) (focus-status in-air)) + (zero? (logand (focus-status halfpipe super) (-> (the-as target 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 target 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 (logtest? (-> (the-as target gp-0) focus-status) (focus-status touch-water)) + (zero? (logand (focus-status mech) (-> (the-as target 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 (zero? (logand (-> self settings slave-options) (cam-slave-options JUMP_PITCHES))) + (reset-follow) + ) + (when (and (logtest? (-> (the-as target gp-0) focus-status) (focus-status on-water under-water)) + (zero? (logand (focus-status mech) (-> (the-as target gp-0) focus-status))) + ) + (let ((f0-41 (- (process-focusable-method-24 (the-as target 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 target 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) (the-as float (-> 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 (the-as vector (&-> arg0 stack 112)) (-> *camera-combiner* inv-camera-rot vector 2)) + (vector-dot (the-as vector (&-> arg1 stack 112)) (-> *camera-combiner* inv-camera-rot vector 2)) + ) + ) + ) + ) + +;; 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-22 symbol) + (v1-52 uint128) + (sv-96 int) + (sv-112 process) + (sv-128 (pointer process)) + (sv-144 int) + (sv-160 string) + (sv-176 string) + (sv-192 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* ((s1-1 (get-process *camera-dead-pool* camera-slave #x4000)) + (s3-1 (when s1-1 + (let ((t9-7 (method-of-type camera-slave activate))) + (t9-7 + (the-as camera-slave s1-1) + *camera* + (symbol->string (-> camera-slave symbol)) + (the-as pointer #x70004000) + ) + ) + (run-now-in-process s1-1 cam-slave-init s2-0 s5-0) + (the-as (pointer camera-slave) (-> s1-1 ppointer)) + ) + ) + ) + (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-51 (the-as uint128 sv-96))) + (.pcpyud v1-52 v1-51 r0-0) + ) + (< s2-1 (shr (* (the-as int v1-52) 2) 49)) + ) + (let ((s0-0 (entity-by-name (the-as string (-> (the-as (pointer uint32) (&+ s4-1 (* s2-1 4)))))))) + (cond + (s0-0 + (let ((s1-2 (cam-state-from-entity s0-0))) + (cond + (s1-2 + (set! sv-112 (get-process *camera-dead-pool* camera-slave #x4000)) + (set! v1-22 (when sv-112 + (set! sv-128 (the-as (pointer process) v1-22)) + (let ((t9-14 (method-of-type camera-slave activate))) + (t9-14 + (the-as camera-slave sv-112) + *camera* + (symbol->string (-> camera-slave symbol)) + (the-as pointer #x70004000) + ) + ) + (run-now-in-process sv-112 cam-slave-init s1-2 s0-0) + (set! sv-128 (-> sv-112 ppointer)) + v1-22 + ) + ) + (cond + (sv-128 + (setup-slave-for-hopefull (the-as camera-slave (ppointer->process sv-128))) + (cond + ((master-is-hopeful-better? + (the-as camera-slave (ppointer->process s3-1)) + (the-as camera-slave (ppointer->process sv-128)) + ) + (if s3-1 + (deactivate (-> s3-1 0)) + ) + (set! s3-1 (the-as (pointer camera-slave) sv-128)) + (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 (-> sv-128 0)) + ) + ) + ) + (else + (format 0 "ERROR : alternate region activate failed~%") + ) + ) + ) + (else + (let ((s1-5 format)) + (set! sv-144 0) + (set! sv-160 "ERROR : alternate camera region '~S' didn't produce a state~%") + (let ((a2-14 (res-lump-struct s0-0 'name structure))) + (s1-5 sv-144 sv-160 a2-14) + ) + ) + ) + ) + ) + ) + (else + (let ((s1-7 format) + (s0-1 0) + ) + (set! sv-176 "ERROR : alternate '~S' not found for '~S'~%") + (set! sv-192 (-> (the-as (pointer uint32) (&+ s4-1 (* s2-1 4))))) + (let ((a3-8 (res-lump-struct s5-0 'name structure))) + (s1-7 s0-1 sv-176 sv-192 a3-8) + ) + ) + ) + ) + ) + (+! 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 + (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-8 (cam-slave-get-float s5-0 'stringMaxLength (-> *CAMERA-bank* default-string-max-z)))) + (if (< 405504.0 f0-8) + (set! f0-8 (-> *CAMERA-bank* default-string-max-z)) + ) + (set! (-> arg0 string-max-length) f0-8) + ) + (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 (method-of-type res-lump get-property-value)) + (s3-0 s5-0) + ) + (format (clear *res-key-string*) "~S~S" 'flags '-on) + (let ((s4-1 (s4-0 + s3-0 + (string->symbol *res-key-string*) + 'interp + -1000000000.0 + (the-as uint128 0) + (the-as (pointer res-tag) #f) + *res-static-buf* + ) + ) + (s3-1 (method-of-type res-lump get-property-value)) + ) + (format (clear *res-key-string*) "~S~S" 'flags '-off) + (let ((v1-19 (s3-1 + s5-0 + (string->symbol *res-key-string*) + 'interp + -1000000000.0 + (the-as uint128 0) + (the-as (pointer res-tag) #f) + *res-static-buf* + ) + ) + ) + (logior! (-> arg0 slave-options) s4-1) + (logclear! (-> arg0 slave-options) v1-19) + ) + ) + ) + ) + ) + 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 :from *camera-dead-pool* :to *camera*) + ) + ) + ) + ) + 0 + (none) + ) + +;; failed to figure out what this is: +(defstate cam-master-active (camera-master) + :event (behavior ((arg0 process) (arg1 int) (arg2 symbol) (arg3 event-message-block)) + (local-vars (v0-0 none) (v1-125 uint)) + (rlet ((vf0 :class vf)) + (init-vf0-vector) + (let ((v1-0 arg2)) + (the-as + object + (cond + ((= v1-0 'dist-from-interp-src) + (cond + ((not *camera-combiner*) + #x48c80000 + ) + ((= (-> *camera-combiner* interp-val) 0.0) + 0 + ) + (else + (-> *camera-combiner* dist-from-src) + ) + ) + ) + ((= v1-0 'dist-from-interp-dest) + (cond + ((not *camera-combiner*) + 0 + ) + ((= (-> *camera-combiner* interp-val) 0.0) + #x48c80000 + ) + (else + (-> *camera-combiner* dist-from-dest) + ) + ) + ) + ((= v1-0 'level-deactivate) + (format 0 "ERROR : *camera* level-deactivate event not supported anymore~%") + ) + ((= v1-0 'clear-entity) + (format 0 "ERROR : *camera* clear-entity event not supported anymore~%") + ) + ((= v1-0 'no-intro) + (format 0 "ERROR : *camera* no-intro event not supported anymore '~S'~%" (-> arg3 param 0)) + ) + ((= v1-0 'force-blend) + (format 0 "ERROR : *camera* force-blend event not supported anymore '~S'~%" (-> arg3 param 0)) + ) + ((= v1-0 'teleport-to-transformq) + (when (> arg1 0) + (let ((gp-1 (the-as object (-> arg3 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) vector 0 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 + ) + ) + ((= v1-0 '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) + ) + ((= v1-0 'teleport-to-vector-start-string) + (when (> arg1 0) + (let ((s5-0 (the-as object (-> arg3 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) + ) + ) + ((= v1-0 'change-target) + (let ((a1-15 (-> arg3 param 0))) + (cond + ((not a1-15) + (clear-focused (-> self focus)) + (set! (-> self master-options) (logand -2 (-> self master-options))) + ) + (else + (try-update-focus (-> self focus) (the-as process-focusable a1-15)) + (logior! (-> self master-options) 1) + (reset-target-tracking) + ) + ) + ) + (set! (-> *camera-combiner* tracking no-follow) #f) + #f + ) + ((= v1-0 'intro-done?) + (or (not (-> self slave)) (>= (-> self slave 0 intro-t) 1.0)) + ) + ((= v1-0 'query-state) + (and (-> self slave) (= (-> self slave 0 next-state) (-> arg3 param 0))) + ) + ((= v1-0 'change-to-entity-by-name) + (format + 0 + "ERROR : *camera* change-to-entity-by-name event not supported anymore '~S'~%" + (-> arg3 param 0) + ) + ) + ((= v1-0 'change-state) + (format 0 "ERROR : *camera* change-state event not supported anymore ~A~%" (-> arg3 param 0)) + ) + ((= v1-0 'set-slave) + (let ((s5-1 (process->ppointer (the-as process (-> arg3 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) 2) + (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 + ((zero? (-> gp-4 0 blend-from-type)) + (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) 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)) + ) + ) + ) + ) + ((= v1-0 'ease-in) + (cond + ((< arg1 1) + (set! (-> self ease-t) 0.0) + (set! (-> self master-options) (logand -9 (-> self master-options))) + ) + ((< arg1 2) + (if (< (the-as float (-> arg3 param 0)) (-> self ease-t)) + (set! (-> self ease-t) (the-as float (-> arg3 param 0))) + ) + (set! (-> self master-options) (logand -9 (-> self master-options))) + ) + (else + (if (< (the-as float (-> arg3 param 0)) (-> self ease-t)) + (set! (-> self ease-t) (the-as float (-> arg3 param 0))) + ) + (set! (-> self ease-to quad) (-> (the-as vector (-> arg3 param 1)) quad)) + (logior! (-> self master-options) 8) + ) + ) + (set! (-> self ease-step) 0.033333335) + (set! v0-0 (the-as none (-> self ease-from))) + (set! (-> (the-as vector v0-0) quad) (-> self tpos-curr-adj quad)) + v0-0 + ) + ((= v1-0 'damp-up) + (set! (-> self upspeed) 0.0) + ) + ((= v1-0 'reset-follow) + (reset-follow) + ) + ((= v1-0 'teleport) + (reset-target-tracking) + (if (-> self slave) + (send-event (ppointer->process (-> self slave)) arg2) + ) + (send-event *camera-combiner* arg2) + ) + ((= v1-0 'toggle-slave-option) + (logxor! (-> self slave-options) (-> arg3 param 0)) + (if (-> self slave) + (logxor! (-> self slave 0 options) (-> arg3 param 0)) + ) + (when (-> self decel) + (set! v0-0 (the-as none (logxor (-> self decel 0 options) (-> arg3 param 0)))) + (set! (-> self decel 0 options) (the-as uint v0-0)) + v0-0 + ) + ) + ((= v1-0 'slave-option?) + (and (-> self slave) (logtest? (-> self slave 0 options) (-> arg3 param 0))) + ) + ((= v1-0 'set-slave-option) + (when (-> self slave) + (set! v0-0 (the-as none (logior (-> self slave 0 options) (-> arg3 param 0)))) + (set! (-> self slave 0 options) (the-as uint v0-0)) + v0-0 + ) + ) + ((= v1-0 'clear-slave-option) + (when (-> self slave) + (set! v0-0 (the-as none (logclear (-> self slave 0 options) (-> arg3 param 0)))) + (set! (-> self slave 0 options) (the-as uint v0-0)) + v0-0 + ) + ) + ((= v1-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 (the-as none (-> *camera-combiner* tracking follow-off))) + (.svf (&-> (the-as vector v0-0) quad) vf0) + v0-0 + ) + ((= v1-0 'yes-follow) + (if (-> self slave) + (set! (-> self slave 0 tracking no-follow) #f) + ) + (set! (-> *camera-combiner* tracking no-follow) #f) + #f + ) + ((= v1-0 'blend-from-as-fixed) + (let ((t9-42 format) + (a0-101 0) + (a1-35 "ERROR : *camera* blend-from-as-fixed event not supported anymore~%") + ) + (-> arg3 param 0) + (t9-42 a0-101 a1-35) + ) + ) + ((= v1-0 'point-of-interest) + (let ((t9-43 format) + (a0-102 0) + (a1-36 "ERROR : *camera* point-of-interest event not supported anymore~%") + ) + (-> arg3 param 0) + (t9-43 a0-102 a1-36) + ) + ) + ((= v1-0 'part-water-drip) + (set! (-> self water-drip-time) (-> self clock frame-counter)) + (set! (-> self water-drip-mult) (the-as float (-> arg3 param 0))) + (set! (-> self water-drip-speed) (the-as float (-> arg3 param 1))) + ) + (else + (and (-> self slave) (let ((v1-237 (new 'stack-no-clear 'event-message-block))) + (set! (-> v1-237 from) (process->ppointer arg0)) + (set! (-> v1-237 num-params) arg1) + (set! (-> v1-237 message) arg2) + (set! (-> v1-237 param 0) (-> arg3 param 0)) + (set! (-> v1-237 param 1) (-> arg3 param 1)) + (set! (-> v1-237 param 2) (-> arg3 param 2)) + (set! (-> v1-237 param 3) (-> arg3 param 3)) + (set! (-> v1-237 param 4) (-> arg3 param 4)) + (set! (-> v1-237 param 5) (-> arg3 param 5)) + (send-event-function (ppointer->process (-> self slave)) v1-237) + ) + ) + ) + ) + ) + ) + ) + ) + :enter (behavior () + (let ((v1-1 + (process-spawn camera-slave :init cam-slave-init cam-free-floating #f :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-8 (process-spawn camera-slave :init cam-slave-init cam-fixed #f :from *camera-dead-pool* :to self))) + (set! (-> self decel) (the-as (pointer camera-slave) v1-8)) + (if (not v1-8) + (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) + ) + (none) + ) + :trans (behavior () + (when (not (paused?)) + (vector-negate! + (-> self local-down) + (vector-normalize-copy! (-> self local-down) (-> *standard-dynamics* gravity) 1.0) + ) + (cam-master-effect) + ) + (none) + ) + :code (behavior () + (until #f + (when *debug-segment* + (let ((gp-0 (-> *display* frames (-> *display* on-screen) profile-array data 0)) + (v1-7 'camera) + (s5-0 *profile-camera-color*) + ) + (when (and *dproc* *debug-segment*) + (let ((s4-0 (-> gp-0 data (-> gp-0 count)))) + (let ((s3-0 (-> gp-0 base-time))) + (set! (-> s4-0 name) v1-7) + (set! (-> s4-0 start-time) (the-as int (- (timer-count (the-as timer-bank #x10000800)) (the-as uint s3-0)))) + ) + (set! (-> s4-0 depth) (the-as uint (-> gp-0 depth))) + (set! (-> s4-0 color) s5-0) + (set! (-> gp-0 segment (-> gp-0 depth)) s4-0) + ) + (+! (-> gp-0 count) 1) + (+! (-> gp-0 depth) 1) + (set! (-> gp-0 max-depth) (max (-> gp-0 max-depth) (-> gp-0 depth))) + ) + ) + 0 + ) + (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))) + ) + (when *debug-segment* + (let ((gp-1 (-> *display* frames (-> *display* on-screen) profile-array data 0))) + (when (and *dproc* *debug-segment*) + (let* ((v1-56 (+ (-> gp-1 depth) -1)) + (s5-1 (-> gp-1 segment v1-56)) + (s4-1 (-> gp-1 base-time)) + ) + (when (>= v1-56 0) + (set! (-> s5-1 end-time) (the-as int (- (timer-count (the-as timer-bank #x10000800)) (the-as uint s4-1)))) + (+! (-> gp-1 depth) -1) + ) + ) + ) + ) + 0 + ) + (suspend) + ) + #f + (none) + ) + ) + +;; 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) (the-as uint 0)) + (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) (the-as uint 560)) + (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 camera-master ((obj camera-master) (arg0 vector)) + (if (handle->process (-> obj focus handle)) + (vector-! arg0 (-> obj tpos-curr) (-> obj tpos-old)) + (vector-reset! arg0) + ) + arg0 + ) + +;; definition for method 15 of type camera-master +;; INFO: Used lq/sq +(defmethod camera-master-method-15 camera-master ((obj camera-master) (arg0 vector)) + (if (and (-> obj slave) (-> obj slave 0 next-state) (= (-> obj slave 0 next-state name) 'cam-string)) + (set! (-> arg0 quad) (-> obj slave 0 view-flat quad)) + (vector-reset! arg0) + ) + arg0 + ) diff --git a/test/decompiler/reference/jak2/engine/camera/camera-h_REF.gc b/test/decompiler/reference/jak2/engine/camera/camera-h_REF.gc index 3918475167..1db1d4b71e 100644 --- a/test/decompiler/reference/jak2/engine/camera/camera-h_REF.gc +++ b/test/decompiler/reference/jak2/engine/camera/camera-h_REF.gc @@ -114,7 +114,7 @@ (tracking-spline-method-19 (_type_ float vector tracking-spline-sampler) vector 19) (tracking-spline-method-20 (_type_ vector int) none 20) (tracking-spline-method-21 (_type_ vector float float float) vector 21) - (tracking-spline-method-22 (_type_ float) none 22) + (tracking-spline-method-22 (_type_ float) symbol 22) (debug-draw-spline (_type_) none 23) ) ) @@ -628,7 +628,7 @@ (:methods (camera-master-method-14 (_type_ vector) vector 14) (camera-master-method-15 (_type_ vector) vector 15) - (camera-master-method-16 (_type_ symbol) none 16) + (camera-master-method-16 (_type_ symbol) int 16) ) ) diff --git a/test/decompiler/reference/jak2/engine/camera/camera_REF.gc b/test/decompiler/reference/jak2/engine/camera/camera_REF.gc index 8f339d38d0..2013c9287a 100644 --- a/test/decompiler/reference/jak2/engine/camera/camera_REF.gc +++ b/test/decompiler/reference/jak2/engine/camera/camera_REF.gc @@ -892,7 +892,7 @@ ) ;; definition for method 22 of type tracking-spline -;; WARN: Return type mismatch int vs none. +;; WARN: Return type mismatch int vs symbol. (defmethod tracking-spline-method-22 tracking-spline ((obj tracking-spline) (arg0 float)) (when (< arg0 (-> obj summed-len)) (let ((s5-0 (new 'stack-no-clear 'tracking-spline-sampler))) @@ -904,8 +904,7 @@ (tracking-spline-method-14 obj s5-0) ) ) - 0 - (none) + (the-as symbol 0) ) ;; definition for method 9 of type tracking-spline diff --git a/test/decompiler/reference/jak2/engine/process-drawable/process-focusable_REF.gc b/test/decompiler/reference/jak2/engine/process-drawable/process-focusable_REF.gc index ee7316bbb8..7e33b3bbdb 100644 --- a/test/decompiler/reference/jak2/engine/process-drawable/process-focusable_REF.gc +++ b/test/decompiler/reference/jak2/engine/process-drawable/process-focusable_REF.gc @@ -14,8 +14,8 @@ (get-quat (_type_) quaternion 21) (get-transv (_type_) vector 22) (process-focusable-method-23 (_type_) none 23) - (process-focusable-method-24 (_type_) none 24) - (process-focusable-method-25 (_type_) int 25) + (process-focusable-method-24 (_type_) float 24) + (process-focusable-method-25 (_type_) time-frame 25) (process-focusable-method-26 (_type_) none 26) ) ) @@ -74,10 +74,8 @@ ) ;; definition for method 24 of type process-focusable -;; WARN: Return type mismatch int vs none. (defmethod process-focusable-method-24 process-focusable ((obj process-focusable)) - 0 - (none) + 0.0 ) ;; definition for method 26 of type process-focusable @@ -88,8 +86,9 @@ ) ;; definition for method 25 of type process-focusable +;; WARN: Return type mismatch int vs time-frame. (defmethod process-focusable-method-25 process-focusable ((obj process-focusable)) - 0 + (the-as time-frame 0) ) ;; failed to figure out what this is: diff --git a/test/decompiler/reference/jak2/engine/ui/text_REF.gc b/test/decompiler/reference/jak2/engine/ui/text_REF.gc index 9903bd38e5..66b5e726f9 100644 --- a/test/decompiler/reference/jak2/engine/ui/text_REF.gc +++ b/test/decompiler/reference/jak2/engine/ui/text_REF.gc @@ -58,6 +58,7 @@ ) ;; definition for method 3 of type game-text-info +;; INFO: this function exists in multiple non-identical object files (defmethod inspect game-text-info ((obj game-text-info)) (format #t "[~8x] ~A~%" obj (-> obj type)) (format #t "~Tlength: ~D~%" (-> obj length)) @@ -257,80 +258,259 @@ ;; definition for function load-game-text-info ;; WARN: Found some very strange gotos. Check result carefully, this is not well tested. -(defun load-game-text-info ((arg0 string) (arg1 (pointer game-text-info)) (arg2 kheap)) +;; ERROR: failed type prop at 3: Could not figure out load: (set! v1 (l.wu gp)) +;; WARN: Return type mismatch none vs int. +(defun load-game-text-info ((a0-0 string) (a1-0 symbol) (a2-0 kheap)) "Load text, if needed. txt-name is the group name, curr-text is the _symbol_ for the game-text-info, and heap is the heap to load to. The heap will be cleared." - (local-vars (v0-3 int) (sv-16 game-text-info) (sv-24 int) (sv-32 int) (sv-40 int)) - (set! sv-16 (-> arg1 0)) - (set! sv-24 (the-as int (-> *setting-control* user-current language))) - (set! sv-32 0) - (set! sv-40 (&- (-> arg2 top) (the-as uint (-> arg2 base)))) - (if (and (= (scf-get-territory) 1) (= sv-24 (language-enum english)) (not (demo?))) - (set! sv-24 7) - ) - (when (or (= sv-16 #f) (!= (-> sv-16 language-id) sv-24) (not (string= (-> sv-16 group-name) arg0))) - (let ((v1-16 arg2)) - (set! (-> v1-16 current) (-> v1-16 base)) - ) - (b! #t cfg-17 :delay (nop!)) - (label cfg-16) - (set! v0-3 0) - (b! #t cfg-30 :delay (nop!)) - (label cfg-17) - (let ((s3-0 str-load)) - (format (clear *temp-string*) "~D~S.TXT" sv-24 arg0) - (b! - (not (s3-0 - *temp-string* - -1 - (logand -64 (&+ (-> arg2 current) 63)) - (&- (-> arg2 top) (the-as uint (-> arg2 current))) + (local-vars + (v0-0 none) + (v0-1 none) + (v0-2 none) + (v0-3 none) + (v0-4 none) + (v0-5 none) + (v0-6 none) + (v0-7 none) + (v0-8 none) + (v0-9 none) + (v0-10 none) + (v0-11 none) + (v0-12 none) + (v0-13 none) + (v1-0 game-text-info) + (v1-1 none) + (v1-2 none) + (v1-3 none) + (v1-4 none) + (v1-5 none) + (v1-6 none) + (v1-7 none) + (v1-9 none) + (v1-10 none) + (v1-11 none) + (v1-12 none) + (v1-13 none) + (v1-14 none) + (v1-16 none) + (v1-17 none) + (v1-18 none) + (v1-20 none) + (v1-21 none) + (v1-24 none) + (v1-25 none) + (v1-26 none) + (a0-1 none) + (a0-2 none) + (a0-3 none) + (a0-4 none) + (a0-5 none) + (a0-6 none) + (a0-7 none) + (a0-8 none) + (a0-10 none) + (a0-11 none) + (a0-12 none) + (a0-13 none) + (a0-14 none) + (a0-15 none) + (a0-17 none) + (a0-18 none) + (a0-19 none) + (a0-20 none) + (a0-21 none) + (a0-22 none) + (a1-2 none) + (a1-3 none) + (a1-4 none) + (a1-5 none) + (a1-6 none) + (a1-7 none) + (a1-8 none) + (a1-9 none) + (a2-1 none) + (a2-2 none) + (a2-3 none) + (a2-4 none) + (a2-5 none) + (a2-6 none) + (a3-1 none) + (a3-2 none) + (t0-0 none) + (s1-0 none) + (s2-0 none) + (s2-1 none) + (s3-0 none) + (s3-1 none) + (t9-0 none) + (t9-1 none) + (t9-2 none) + (t9-3 none) + (t9-4 none) + (t9-5 none) + (t9-6 none) + (t9-7 none) + (t9-8 none) + (t9-9 none) + (t9-10 none) + (t9-11 none) + (t9-12 none) + (sv-16 none) + (sv-24 none) + (sv-32 none) + (sv-40 none) + ) + (when (begin + (when (begin + (and (begin + (set! v1-0 (the-as game-text-info (l.wu a1-0))) + (set! sv-16 v1-0) + (set! v1-1 (the-as none *setting-control*)) + (set! v1-2 (the-as none (l.d (+ v1-1 28)))) + (set! sv-24 v1-2) + (set! sv-32 0) + (set! v1-3 (the-as none (-> a2-0 top))) + (set! a0-1 (the-as none (-> a2-0 base))) + (set! v1-4 (the-as none (- v1-3 a0-1))) + (set! sv-40 v1-4) + (set! t9-0 (the-as none scf-get-territory)) + (set! v0-0 (the-as none (call!))) + (set! v1-5 (the-as none (+ v0-0 -1))) + (set! a0-2 (the-as none (zero? v1-5))) + a0-2 + ) + (begin (set! v1-7 sv-24) (zero? v1-7)) + (begin (set! t9-1 (the-as none demo?)) (set! v0-1 (the-as none (call!))) (set! v1-6 (the-as none (not v0-1)))) + ) + v1-6 + ) + (set! v1-9 (the-as none 7)) + (set! sv-24 v1-9) + ) + (or (begin (set! v1-10 sv-16) (set! a0-3 (the-as none (= v1-10 #f))) a0-3) + (begin + (set! v1-12 sv-16) + (set! v1-13 (the-as none (l.w (+ v1-12 4)))) + (set! a0-4 sv-24) + (set! a0-5 (the-as none (!= v1-13 a0-4))) + a0-5 + ) + (begin + (set! t9-2 (the-as none string=)) + (set! v1-14 sv-16) + (set! a0-6 (the-as none (l.wu (+ v1-14 8)))) + (set! a1-1 (the-as none a0-0)) + (set! v0-2 (the-as none (call!))) + (set! v1-11 (the-as none (not v0-2))) + ) + ) + v1-11 + ) + (cond + ((begin + (set! v1-16 (the-as none a2-0)) + (set! a0-7 (the-as none (l.wu v1-16))) + (s.w! (+ v1-16 8) a0-7) + ((b! #t L50 (nop!)) (nop!)) + (label cfg-16) + (set! v0-3 (the-as none 0)) + ((b! #t L56 (nop!)) (nop!)) + (label cfg-17) + (set! s3-0 (the-as none str-load)) + (set! s2-0 (the-as none format)) + (set! t9-3 (the-as none clear)) + (set! a0-8 (the-as none *temp-string*)) + (call!) + (set! a0-9 (the-as none v0-4)) + (set! a1-2 (the-as none L100)) + (set! a2-1 sv-24) + (set! a3-0 (the-as none a0-0)) + (set! t9-4 (the-as none s2-0)) + (call!) + (set! a0-10 (the-as none *temp-string*)) + (set! a1-3 (the-as none -1)) + (set! v1-17 (the-as none -64)) + (set! a2-2 (the-as none (l.wu (+ a2-0 8)))) + (set! a2-3 (the-as none (+ a2-2 63))) + (set! a2-4 (the-as none (logand v1-17 a2-3))) + (set! v1-18 (the-as none (l.wu (+ a2-0 4)))) + (set! a3-1 (the-as none (l.wu (+ a2-0 8)))) + (set! a3-2 (the-as none (- v1-18 a3-1))) + (set! t9-5 (the-as none s3-0)) + (set! v0-6 (the-as none (call!))) + ((b! (not v0-6) L49 (nop!)) (nop!)) + (label cfg-19) + (set! t9-6 (the-as none str-load-status)) + (set! a0-11 (& sv-32)) + (set! v0-7 (the-as none (call!))) + (set! v1-20 (the-as none v0-7)) + (set! a0-12 (the-as none 'error)) + ((b! (!= v1-20 a0-12) L52 (set! a0-13 #f)) (empty-form)) + (set! t9-7 (the-as none format)) + (set! a0-14 (the-as none 0)) + (set! a1-4 (the-as none L99)) + (call!) + (set! v0-3 (the-as none 0)) + ((b! #t L56 (nop!)) (nop!)) + (set! v1-21 (the-as none 0)) + ((b! #t L54 (nop!)) (nop!)) + (label cfg-22) + (set! a0-15 sv-32) + (set! a1-5 sv-40) + (set! a1-6 (the-as none (+ a1-5 -300))) + (>=.si a0-15 a1-6) + ) + (return (begin + (set! t9-8 (the-as none format)) + (set! a0-17 (the-as none 0)) + (set! a1-7 (the-as none L98)) + (call!) + (set! v0-3 (the-as none 0)) + ) ) - ) - cfg-16 - :delay (nop!) - ) + ) + ((begin (set! a0-18 (the-as none 'busy)) (= v1-20 a0-18)) + (begin (nop!) (nop!) (nop!) (nop!) (nop!) (nop!) (goto cfg-19)) + ) ) - (label cfg-19) - (let ((v1-20 (str-load-status (the-as (pointer int32) (& sv-32))))) - (b! (!= v1-20 'error) cfg-22 :delay (empty-form)) - (format 0 "Error loading text~%") - (set! v0-3 0) - (b! #t cfg-30 :delay (nop!)) - (the-as none 0) - (b! #t cfg-27 :delay (nop!)) - (label cfg-22) - (cond - ((>= sv-32 (+ sv-40 -300)) - (format 0 "Game text heap overrun!~%") - (return 0) - ) - ((= v1-20 'busy) - (nop!) - (nop!) - (nop!) - (nop!) - (nop!) - (nop!) - (goto cfg-19) - ) - ) - ) - (label cfg-27) - (let ((s2-1 (logand -64 (&+ (-> arg2 current) 63)))) - (flush-cache 0) - (let ((s3-1 link)) - (format (clear *temp-string*) "~D~S.TXT" sv-24 arg0) - (set! (-> arg1 0) (the-as game-text-info (s3-1 s2-1 (-> *temp-string* data) sv-32 arg2 0))) - ) - ) - (if (<= (the-as int (-> arg1 0)) 0) - (set! (-> arg1 0) #f) + (if (begin + (label cfg-27) + (set! v1-24 (the-as none -64)) + (set! a0-19 (the-as none (l.wu (+ a2-0 8)))) + (set! a0-20 (the-as none (+ a0-19 63))) + (set! s2-1 (the-as none (logand v1-24 a0-20))) + (set! t9-9 (the-as none flush-cache)) + (set! a0-21 (the-as none 0)) + (call!) + (set! s3-1 (the-as none link)) + (set! s1-0 (the-as none format)) + (set! t9-10 (the-as none clear)) + (set! a0-22 (the-as none *temp-string*)) + (call!) + (set! a0-23 (the-as none v0-11)) + (set! a1-8 (the-as none L100)) + (set! a2-5 sv-24) + (set! t9-11 (the-as none s1-0)) + (set! a3-3 (the-as none a0-0)) + (call!) + (set! v1-25 (the-as none *temp-string*)) + (set! a1-9 (the-as none (+ v1-25 4))) + (set! a2-6 sv-32) + (set! t0-0 (the-as none 0)) + (set! t9-12 (the-as none s3-1)) + (set! a0-24 (the-as none s2-1)) + (set! a3-4 (the-as none a2-0)) + (set! v0-13 (the-as none (call!))) + (s.w! a1-0 v0-13) + (set! v1-26 (the-as none (l.wu a1-0))) + (<=0.si v1-26) + ) + (s.w! a1-0 #f) ) ) - (set! v0-3 0) + (set! v0-3 (the-as none 0)) (label cfg-30) - v0-3 + (ret-value v0-3) ) ;; definition for function load-level-text-files @@ -340,7 +520,7 @@ This function made more sense back when text files were split up, but in the end they put everything in a single text group and file." (if (or *level-text-file-load-flag* (>= arg0 0)) - (load-game-text-info "common" (the-as (pointer game-text-info) '*common-text*) *common-text-heap*) + (load-game-text-info "common" '*common-text* *common-text-heap*) ) 0 (none) diff --git a/test/offline/config/jak2/config.jsonc b/test/offline/config/jak2/config.jsonc index e7952c77cd..32e4f51bda 100644 --- a/test/offline/config/jak2/config.jsonc +++ b/test/offline/config/jak2/config.jsonc @@ -27,6 +27,8 @@ "rand-vu-init", "rand-vu", "rand-vu-nostep", + // text - TODO - https://github.com/open-goal/jak-project/issues/1939 + "load-game-text-info", // MATRIX "matrix-axis-sin-cos-vu!", "matrix-axis-sin-cos!", @@ -85,10 +87,8 @@ "v-slrp2!", "v-slrp3!", // cam-master - // - focus understanding / decomp crashes - "reset-target-tracking", + // - incomplete bitfield? "(method 16 camera-master)", - "master-track-target", // cam-states // - mostly decompiler crashes/hangs "cam-bike-code",