Files
jak-project/test/decompiler/reference/jak2/engine/camera/cam-states-dbg_REF.gc
T
water111 637990314b wip: better stack var support (#4222)
Closes #736

---------

Co-authored-by: Hat Kid <6624576+Hat-Kid@users.noreply.github.com>
2026-04-19 00:14:44 +02:00

501 lines
22 KiB
Common Lisp
Vendored
Generated

;;-*-Lisp-*-
(in-package goal)
;; definition of type cam-point-watch-bank
(deftype cam-point-watch-bank (basic)
((speed float)
(rot-speed degrees)
)
)
;; definition for method 3 of type cam-point-watch-bank
(defmethod inspect ((this cam-point-watch-bank))
(when (not this)
(set! this this)
(goto cfg-4)
)
(format #t "[~8x] ~A~%" this (-> this type))
(format #t "~1Tspeed: ~f~%" (-> this speed))
(format #t "~1Trot-speed: (deg ~r)~%" (-> this rot-speed))
(label cfg-4)
this
)
;; definition for symbol *CAM_POINT_WATCH-bank*, type cam-point-watch-bank
(define *CAM_POINT_WATCH-bank* (new 'static 'cam-point-watch-bank :speed 1600.0 :rot-speed (degrees 0.6)))
;; failed to figure out what this is:
(defstate cam-point-watch (camera-slave)
:event (behavior ((proc process) (argc int) (message symbol) (block event-message-block))
(case message
(('teleport)
#f
)
(else
(cam-standard-event-handler proc argc message block)
)
)
)
:enter (behavior ()
(when (not (-> self enter-has-run))
(set! (-> self pivot-rad) 40960.0)
(set! (-> self blend-from-type) (the-as uint 1))
(set! (-> self blend-to-type) (camera-blend-to-type unknown-1))
)
)
:code (behavior ()
(until #f
(let ((s5-0 (new-stack-vector0))
(gp-0 (new-stack-vector0))
)
(when (not (logtest? (-> *camera* settings master-options) (cam-master-options IGNORE_ANALOG)))
(let ((f28-0 (analog-input (the-as int (-> *cpad-list* cpads 0 leftx)) 128.0 48.0 110.0 -1.0))
(f30-0 (analog-input (the-as int (-> *cpad-list* cpads 0 lefty)) 128.0 48.0 110.0 -1.0))
(f26-0 (analog-input (the-as int (-> *cpad-list* cpads 0 rightx)) 128.0 48.0 110.0 -1.0))
(f0-0 (analog-input (the-as int (-> *cpad-list* cpads 0 righty)) 128.0 48.0 110.0 -1.0))
)
(cond
((cpad-hold? (-> *CAMERA-bank* joypad) r2)
(set! (-> s5-0 y) (- (-> s5-0 y) (* (/ (-> *CAM_POINT_WATCH-bank* rot-speed) 5) (- f26-0))))
(set! (-> s5-0 x) (- (-> s5-0 x) (* (/ (-> *CAM_POINT_WATCH-bank* rot-speed) 5) (- f0-0))))
(+! (-> gp-0 x) (* (/ (-> *CAM_POINT_WATCH-bank* speed) 5) f28-0))
(+! (-> gp-0 z) (* (/ (-> *CAM_POINT_WATCH-bank* speed) 5) f30-0))
)
(else
(set! (-> s5-0 y) (- (-> s5-0 y) (* 2.0 (-> *CAM_POINT_WATCH-bank* rot-speed) (- f26-0))))
(set! (-> s5-0 x) (- (-> s5-0 x) (* 2.0 (-> *CAM_POINT_WATCH-bank* rot-speed) (- f0-0))))
(+! (-> gp-0 x) (* 2.0 (-> *CAM_POINT_WATCH-bank* speed) f28-0))
(+! (-> gp-0 z) (* 2.0 (-> *CAM_POINT_WATCH-bank* speed) f30-0))
)
)
)
(let ((s4-0 (new-stack-vector0)))
(let ((s3-0 (new-stack-matrix0)))
(matrix-axis-angle! s3-0 (the-as vector (-> self tracking)) (- (-> s5-0 x)))
(vector-matrix*! s4-0 (-> self tracking inv-mat vector 2) s3-0)
(matrix-axis-angle! s3-0 (-> *camera* local-down) (- (-> s5-0 y)))
(vector-matrix*! s4-0 s4-0 s3-0)
)
(forward-down->inv-matrix (-> self tracking inv-mat) s4-0 (-> *camera* local-down))
)
(set! (-> self pivot-rad) (- (-> self pivot-rad) (-> gp-0 z)))
(if (< (-> self pivot-rad) 4096.0)
(set! (-> self pivot-rad) 4096.0)
)
(set-vector! gp-0 0.0 0.0 (- (-> self pivot-rad)) 1.0)
(vector-matrix*! (-> self trans) gp-0 (-> self tracking inv-mat))
)
)
(suspend)
0
)
#f
)
)
;; definition of type cam-free-bank
(deftype cam-free-bank (basic)
((speed float)
(rot-speed degrees)
)
)
;; definition for method 3 of type cam-free-bank
(defmethod inspect ((this cam-free-bank))
(when (not this)
(set! this this)
(goto cfg-4)
)
(format #t "[~8x] ~A~%" this (-> this type))
(format #t "~1Tspeed: ~f~%" (-> this speed))
(format #t "~1Trot-speed: (deg ~r)~%" (-> this rot-speed))
(label cfg-4)
this
)
;; definition for symbol *CAM_FREE-bank*, type cam-free-bank
(define *CAM_FREE-bank* (new 'static 'cam-free-bank :speed 1600.0 :rot-speed (degrees 0.6)))
;; definition for function cam-mouse-input
(defun cam-mouse-input ((arg0 vector) (arg1 vector))
(let ((v1-0 (new 'stack-no-clear 'vector)))
(vector-! v1-0 (-> *mouse* pos 0) (-> *mouse* pos 1))
(cond
((mouse-hold? left)
(let ((a0-7 (new 'stack-no-clear 'vector)))
0.0
(vector-! a0-7 (-> *math-camera* trans) (-> *setting-control* cam-current mouse-tumble-point))
(let ((f30-0 (vector-length a0-7)))
(cond
(#f
(let* ((f28-0 (* (/ f30-0 100) (-> v1-0 x)))
(f26-0 (* (/ f30-0 100) (-> v1-0 y)))
(f22-0 (- (sqrtf (+ (square f28-0) (square f26-0) (square f30-0))) f30-0))
(f24-0 (atan f26-0 f30-0))
(f0-12 (atan (- f28-0) f30-0))
)
(+! (-> arg1 x) f28-0)
(+! (-> arg1 y) f26-0)
(+! (-> arg1 z) f22-0)
(+! (-> arg0 x) f24-0)
(set! (-> arg0 y) (+ (-> arg0 y) f0-12))
)
)
(else
(+! (-> arg0 y) (* (- (-> v1-0 x)) (-> *CAM_FREE-bank* rot-speed)))
(set! (-> arg0 x) (+ (-> arg0 x) (* (-> v1-0 y) (-> *CAM_FREE-bank* rot-speed))))
)
)
)
)
)
((mouse-hold? right)
(+! (-> arg1 x) (* (-> v1-0 x) (-> *CAM_FREE-bank* speed)))
(set! (-> arg1 z) (+ (-> arg1 z) (* (-> v1-0 y) (-> *CAM_FREE-bank* speed))))
)
((mouse-hold? middle)
(+! (-> arg1 x) (* (-> v1-0 x) (-> *CAM_FREE-bank* speed)))
(set! (-> arg1 y) (+ (-> arg1 y) (* (-> v1-0 y) (-> *CAM_FREE-bank* speed))))
)
)
)
)
;; definition for function cam-free-floating-input
(defun cam-free-floating-input ((arg0 vector) (arg1 vector) (arg2 symbol) (arg3 int))
(with-pp
(when *camera*
(if (-> *setting-control* cam-current mouse-input)
(cam-mouse-input arg0 arg1)
)
(let ((s3-0 (and (-> *setting-control* cam-current cpad1-skip-buttons) (= arg3 1))))
(when (not s3-0)
(when (and (!= *master-mode* 'menu) (not *cam-layout*))
(when (logtest? (-> *camera* settings master-options) (cam-master-options READ_BUTTONS))
(if (cpad-hold? arg3 x)
(set! (-> arg0 x)
(- (-> arg0 x) (+ (-> *CAM_FREE-bank* rot-speed) (analog-input
(the-as int (-> *cpad-list* cpads arg3 abutton 6))
0.0
32.0
230.0
(-> *CAM_FREE-bank* rot-speed)
)
)
)
)
)
)
(when (logtest? (-> *camera* settings master-options) (cam-master-options READ_BUTTONS))
(if (cpad-hold? arg3 triangle)
(+! (-> arg0 x) (+ (-> *CAM_FREE-bank* rot-speed) (analog-input
(the-as int (-> *cpad-list* cpads arg3 abutton 4))
0.0
32.0
230.0
(-> *CAM_FREE-bank* rot-speed)
)
)
)
)
)
(when (logtest? (-> *camera* settings master-options) (cam-master-options READ_BUTTONS))
(if (cpad-hold? arg3 square)
(+! (-> arg0 y) (+ (-> *CAM_FREE-bank* rot-speed) (analog-input
(the-as int (-> *cpad-list* cpads arg3 abutton 7))
0.0
32.0
230.0
(-> *CAM_FREE-bank* rot-speed)
)
)
)
)
)
(when (logtest? (-> *camera* settings master-options) (cam-master-options READ_BUTTONS))
(if (cpad-hold? arg3 circle)
(set! (-> arg0 y)
(- (-> arg0 y) (+ (-> *CAM_FREE-bank* rot-speed) (analog-input
(the-as int (-> *cpad-list* cpads arg3 abutton 5))
0.0
32.0
230.0
(-> *CAM_FREE-bank* rot-speed)
)
)
)
)
)
)
)
(when arg2
(when (logtest? (-> *camera* settings master-options) (cam-master-options READ_BUTTONS))
(if (cpad-hold? arg3 l2)
(+! (-> arg0 z) (+ (-> *CAM_FREE-bank* rot-speed) (analog-input
(the-as int (-> *cpad-list* cpads arg3 abutton 10))
0.0
32.0
230.0
(-> *CAM_FREE-bank* rot-speed)
)
)
)
)
)
(when (logtest? (-> *camera* settings master-options) (cam-master-options READ_BUTTONS))
(if (cpad-hold? arg3 r2)
(set! (-> arg0 z)
(- (-> arg0 z) (+ (-> *CAM_FREE-bank* rot-speed) (analog-input
(the-as int (-> *cpad-list* cpads arg3 abutton 11))
0.0
32.0
230.0
(-> *CAM_FREE-bank* rot-speed)
)
)
)
)
)
)
)
(when (nonzero? arg3)
(when (logtest? (-> *camera* settings master-options) (cam-master-options READ_BUTTONS))
(if (cpad-hold? arg3 left)
(+! (-> arg1 x)
(+ (-> *CAM_FREE-bank* speed)
(analog-input (the-as int (-> *cpad-list* cpads arg3 abutton 1)) 0.0 32.0 230.0 (-> *CAM_FREE-bank* speed))
)
)
)
)
(when (logtest? (-> *camera* settings master-options) (cam-master-options READ_BUTTONS))
(if (cpad-hold? arg3 right)
(set! (-> arg1 x)
(- (-> arg1 x)
(+ (-> *CAM_FREE-bank* speed)
(analog-input (the-as int (-> *cpad-list* cpads arg3 abutton 0)) 0.0 32.0 230.0 (-> *CAM_FREE-bank* speed))
)
)
)
)
)
(when (logtest? (-> *camera* settings master-options) (cam-master-options READ_BUTTONS))
(if (cpad-hold? arg3 up)
(+! (-> arg1 z)
(+ (-> *CAM_FREE-bank* speed)
(analog-input (the-as int (-> *cpad-list* cpads arg3 abutton 2)) 0.0 32.0 230.0 (-> *CAM_FREE-bank* speed))
)
)
)
)
(when (logtest? (-> *camera* settings master-options) (cam-master-options READ_BUTTONS))
(if (cpad-hold? arg3 down)
(set! (-> arg1 z)
(- (-> arg1 z)
(+ (-> *CAM_FREE-bank* speed)
(analog-input (the-as int (-> *cpad-list* cpads arg3 abutton 3)) 0.0 32.0 230.0 (-> *CAM_FREE-bank* speed))
)
)
)
)
)
)
)
(cond
((logtest? (-> *camera* settings master-options) (cam-master-options IGNORE_ANALOG))
)
((cpad-hold? arg3 r2)
(when (logtest? (-> *camera* settings master-options) (cam-master-options READ_BUTTONS))
(if (cpad-hold? arg3 r1)
(+! (-> arg1 y) (+ (/ (-> *CAM_FREE-bank* speed) 5) (analog-input
(the-as int (-> *cpad-list* cpads arg3 abutton 9))
0.0
32.0
230.0
(/ (-> *CAM_FREE-bank* speed) 5)
)
)
)
)
)
(when (logtest? (-> *camera* settings master-options) (cam-master-options READ_BUTTONS))
(if (cpad-hold? arg3 l1)
(set! (-> arg1 y)
(- (-> arg1 y) (+ (/ (-> *CAM_FREE-bank* speed) 5) (analog-input
(the-as int (-> *cpad-list* cpads arg3 abutton 8))
0.0
32.0
230.0
(/ (-> *CAM_FREE-bank* speed) 5)
)
)
)
)
)
)
)
(else
(when (logtest? (-> *camera* settings master-options) (cam-master-options READ_BUTTONS))
(if (cpad-hold? arg3 r1)
(+! (-> arg1 y)
(+ (-> *CAM_FREE-bank* speed)
(analog-input (the-as int (-> *cpad-list* cpads arg3 abutton 9)) 0.0 32.0 230.0 (-> *CAM_FREE-bank* speed))
)
)
)
)
(when (logtest? (-> *camera* settings master-options) (cam-master-options READ_BUTTONS))
(if (cpad-hold? arg3 l1)
(set! (-> arg1 y)
(- (-> arg1 y)
(+ (-> *CAM_FREE-bank* speed)
(analog-input (the-as int (-> *cpad-list* cpads arg3 abutton 8)) 0.0 32.0 230.0 (-> *CAM_FREE-bank* speed))
)
)
)
)
)
)
)
(when (not (logtest? (-> *camera* settings master-options) (cam-master-options IGNORE_ANALOG)))
(let ((f28-14 (analog-input (the-as int (-> *cpad-list* cpads arg3 leftx)) 128.0 48.0 110.0 -1.0))
(f30-14 (analog-input (the-as int (-> *cpad-list* cpads arg3 lefty)) 128.0 48.0 110.0 -1.0))
(f26-0 (analog-input (the-as int (-> *cpad-list* cpads arg3 rightx)) 128.0 48.0 110.0 -1.0))
(f0-60 (analog-input (the-as int (-> *cpad-list* cpads arg3 righty)) 128.0 48.0 110.0 -1.0))
)
(cond
((and (not s3-0) (cpad-hold? arg3 r2))
(cond
((cpad-hold? arg3 l2)
(set! (-> arg0 y) (- (-> arg0 y) (* (/ (-> *CAM_FREE-bank* rot-speed) 2) (- f26-0))))
(set! (-> arg0 x) (- (-> arg0 x) (* (/ (-> *CAM_FREE-bank* rot-speed) 2) (- f0-60))))
)
(else
(set! (-> arg0 y) (- (-> arg0 y) (* (- f26-0) (-> *CAM_FREE-bank* rot-speed))))
(set! (-> arg0 x) (- (-> arg0 x) (* (- f0-60) (-> *CAM_FREE-bank* rot-speed))))
)
)
(+! (-> arg1 x) (* (/ (-> *CAM_FREE-bank* speed) 5) f28-14))
(+! (-> arg1 z) (* (/ (-> *CAM_FREE-bank* speed) 5) f30-14))
)
((and (not s3-0) (cpad-hold? arg3 l2))
(+! (-> arg1 x) (* f28-14 (-> *CAM_FREE-bank* speed)))
(+! (-> arg1 y) (* f0-60 (-> *CAM_FREE-bank* speed)))
(+! (-> arg1 z) (* f30-14 (-> *CAM_FREE-bank* speed)))
)
(else
(set! (-> arg0 y) (- (-> arg0 y) (* 2.0 (-> *CAM_FREE-bank* rot-speed) (- f26-0))))
(set! (-> arg0 x) (- (-> arg0 x) (* 2.0 (-> *CAM_FREE-bank* rot-speed) (- f0-60))))
(+! (-> arg1 x) (* 2.0 (-> *CAM_FREE-bank* speed) f28-14))
(+! (-> arg1 z) (* 2.0 (-> *CAM_FREE-bank* speed) f30-14))
)
)
)
)
)
(vector-float*! arg0 arg0 (-> pp clock time-adjust-ratio))
(vector-float*! arg1 arg1 (-> pp clock time-adjust-ratio))
)
)
)
;; definition of type camera-free-floating-move-info
(deftype camera-free-floating-move-info (structure)
((rv vector :inline)
(tv vector :inline)
(up vector :inline)
(tm matrix :inline)
)
)
;; definition for method 3 of type camera-free-floating-move-info
(defmethod inspect ((this camera-free-floating-move-info))
(when (not this)
(set! this this)
(goto cfg-4)
)
(format #t "[~8x] ~A~%" this 'camera-free-floating-move-info)
(format #t "~1Trv: #<vector @ #x~X>~%" (-> this rv))
(format #t "~1Ttv: #<vector @ #x~X>~%" (-> this tv))
(format #t "~1Tup: #<vector @ #x~X>~%" (-> this up))
(format #t "~1Ttm: #<matrix @ #x~X>~%" (-> this tm))
(label cfg-4)
this
)
;; definition for function cam-free-floating-move
(defun cam-free-floating-move ((arg0 matrix) (arg1 vector) (arg2 vector) (arg3 int))
(if (logtest? (-> *cpad-list* cpads arg3 valid) 128)
(return (the-as vector #f))
)
(if (= *master-mode* 'menu)
(return (the-as vector #f))
)
(let ((s3-0 (new 'stack 'camera-free-floating-move-info)))
(cam-free-floating-input (-> s3-0 rv) (-> s3-0 tv) (not arg2) arg3)
(cond
(arg2
(matrix-axis-angle! (-> s3-0 tm) arg2 (-> s3-0 rv y))
(matrix*! arg0 arg0 (-> s3-0 tm))
(cond
((< (vector-dot (-> arg0 vector 1) arg2) 0.0)
(forward-down->inv-matrix arg0 (-> arg0 vector 2) arg2)
)
(else
(vector-negate! (-> s3-0 up) arg2)
(forward-down->inv-matrix arg0 (-> arg0 vector 2) (-> s3-0 up))
)
)
)
(else
(matrix-axis-angle! (-> s3-0 tm) (-> arg0 vector 1) (- (-> s3-0 rv y)))
(matrix*! arg0 arg0 (-> s3-0 tm))
)
)
(matrix-axis-angle! (-> s3-0 tm) (-> arg0 vector 0) (- (-> s3-0 rv x)))
(matrix*! arg0 arg0 (-> s3-0 tm))
(matrix-axis-angle! (-> s3-0 tm) (-> arg0 vector 2) (- (-> s3-0 rv z)))
(matrix*! arg0 arg0 (-> s3-0 tm))
(vector-matrix*! (-> s3-0 tv) (-> s3-0 tv) arg0)
(vector+! arg1 arg1 (-> s3-0 tv))
)
)
;; failed to figure out what this is:
(defstate cam-free-floating (camera-slave)
:event (behavior ((proc process) (argc int) (message symbol) (block event-message-block))
(case message
(('teleport)
#f
)
(else
(cam-standard-event-handler proc argc message block)
)
)
)
:enter (behavior ()
(when (not (-> self enter-has-run))
(set! (-> self blend-from-type) (the-as uint 1))
(set! (-> self blend-to-type) (camera-blend-to-type unknown-1))
(send-event *camera-combiner* 'stop-tracking)
)
)
:code (behavior ()
(until #f
(let ((a2-0 (-> *camera* local-down)))
(if (logtest? (-> self options) (cam-slave-options-u32 ALLOW_Z_ROT))
(set! a2-0 (the-as vector #f))
)
(cam-free-floating-move
(-> self tracking inv-mat)
(-> self trans)
a2-0
(the-as int (-> *CAMERA-bank* joypad))
)
)
(suspend)
)
#f
)
)