mirror of
https://github.com/open-goal/jak-project.git
synced 2024-10-20 21:27:52 -04:00
45318be063
* decomp: mostly finish `cam-master` * decomp/scripts: lots of work in cam-states * stash * Merge remote-tracking branch 'water111/master' into decomp/camera-master Updated submodule third-party/googletest * decompiler: Add support for non power of 2 offsets for inline arr access * decomp: mostly finish `cam-states` need to fix a macro issue * blocked: `cam-master` decompiler crash when adding casts * decomp: finish `cam-states-dbg` * decomp: mostly finish `pov-camera` with the exception of joint-related code * decomp: `cam-debug` finished decompiling, no way does this compile yet though * decomp: considerable work done in `cam-layout` * decomp: `cam-layout` almost done! * decomp: `pov-camera` finished, TC tests will fail for now * decomp: working on resolving issues * decomp: cam-layout decompiling * fixing more issues in cam-master...one event handler remains * skip problematic function in `cam-master` for now * gsrc: update res macros * decomp: finish `cam-states` * decomp: giving up on `cam-debug` * tests: allow skipping state handlers in ref tests * decomp: working through cam-layout bugs * decomp: allow for shifting non-integers * decomp: finalize `cam-layout` and `cam-master` * decomp: finalize `cam-states` * cleanup: bi-annual formatting of the casting files * formatting * address feedback - leave the float labels alone for now * address feedback * linting/formatting * update gsrc and ref tests Co-authored-by: ManDude <7569514+ManDude@users.noreply.github.com>
915 lines
21 KiB
Common Lisp
915 lines
21 KiB
Common Lisp
;;-*-Lisp-*-
|
|
(in-package goal)
|
|
|
|
;; name: cam-states-dbg.gc
|
|
;; name in dgo: cam-states-dbg
|
|
;; dgos: GAME, ENGINE
|
|
|
|
;; DECOMP BEGINS
|
|
|
|
(deftype cam-point-watch-bank (basic)
|
|
((speed float :offset-assert 4)
|
|
(rot-speed degrees :offset-assert 8)
|
|
)
|
|
:method-count-assert 9
|
|
:size-assert #xc
|
|
:flag-assert #x90000000c
|
|
)
|
|
|
|
|
|
(define
|
|
*CAM_POINT_WATCH-bank*
|
|
(new 'static 'cam-point-watch-bank :speed 1600.0 :rot-speed (degrees 0.6))
|
|
)
|
|
|
|
(defstate cam-point-watch (camera-slave)
|
|
:event
|
|
(behavior ((arg0 process) (arg1 int) (arg2 symbol) (arg3 event-message-block))
|
|
(case arg2
|
|
(('teleport)
|
|
#f
|
|
)
|
|
(else
|
|
(cam-standard-event-handler arg0 arg1 arg2 arg3)
|
|
)
|
|
)
|
|
)
|
|
: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) (the-as uint 1))
|
|
)
|
|
(none)
|
|
)
|
|
:code
|
|
(behavior ()
|
|
(while #t
|
|
(let ((s5-0 (new-stack-vector0))
|
|
(gp-0 (new-stack-vector0))
|
|
)
|
|
(when *camera-read-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
|
|
((logtest?
|
|
(-> *cpad-list* cpads (-> *CAMERA-bank* joypad) button0-abs 0)
|
|
(pad-buttons r2)
|
|
)
|
|
(set!
|
|
(-> s5-0 y)
|
|
(-
|
|
(-> s5-0 y)
|
|
(* 0.2 (-> *CAM_POINT_WATCH-bank* rot-speed) (- f26-0))
|
|
)
|
|
)
|
|
(set!
|
|
(-> s5-0 x)
|
|
(- (-> s5-0 x) (* 0.2 (-> *CAM_POINT_WATCH-bank* rot-speed) (- f0-0)))
|
|
)
|
|
(+! (-> gp-0 x) (* 0.2 (-> *CAM_POINT_WATCH-bank* speed) f28-0))
|
|
(+! (-> gp-0 z) (* 0.2 (-> *CAM_POINT_WATCH-bank* speed) f30-0))
|
|
)
|
|
(else
|
|
(set!
|
|
(-> s5-0 y)
|
|
(-
|
|
(-> s5-0 y)
|
|
(* 2.0 (-> *CAM_POINT_WATCH-bank* rot-speed) (- f26-0))
|
|
)
|
|
)
|
|
(set!
|
|
(-> s5-0 x)
|
|
(- (-> s5-0 x) (* 2.0 (-> *CAM_POINT_WATCH-bank* rot-speed) (- f0-0)))
|
|
)
|
|
(+! (-> gp-0 x) (* 2.0 (-> *CAM_POINT_WATCH-bank* speed) f28-0))
|
|
(+! (-> gp-0 z) (* 2.0 (-> *CAM_POINT_WATCH-bank* speed) f30-0))
|
|
)
|
|
)
|
|
)
|
|
(let ((s4-0 (new-stack-vector0)))
|
|
(let ((s3-0 (new-stack-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
|
|
(the-as matrix (-> self tracking))
|
|
s4-0
|
|
(-> *camera* local-down)
|
|
)
|
|
)
|
|
(set! (-> self pivot-rad) (- (-> self pivot-rad) (-> gp-0 z)))
|
|
(if (< (-> self pivot-rad) 4096.0)
|
|
(set! (-> self pivot-rad) 4096.0)
|
|
)
|
|
(set-vector! gp-0 0.0 0.0 (- (-> self pivot-rad)) 1.0)
|
|
(vector-matrix*! (-> self trans) gp-0 (the-as matrix (-> self tracking)))
|
|
)
|
|
)
|
|
(suspend)
|
|
0
|
|
)
|
|
(none)
|
|
)
|
|
)
|
|
|
|
(deftype cam-free-bank (basic)
|
|
((speed float :offset-assert 4)
|
|
(rot-speed degrees :offset-assert 8)
|
|
)
|
|
:method-count-assert 9
|
|
:size-assert #xc
|
|
:flag-assert #x90000000c
|
|
)
|
|
|
|
|
|
(define
|
|
*CAM_FREE-bank*
|
|
(new 'static 'cam-free-bank :speed 1600.0 :rot-speed (degrees 0.6))
|
|
)
|
|
|
|
(defun
|
|
cam-free-floating-input
|
|
((arg0 vector) (arg1 vector) (arg2 symbol) (arg3 int))
|
|
(when (and (!= *master-mode* 'menu) (not *cam-layout*))
|
|
(when *camera-read-buttons*
|
|
(if (logtest? (-> *cpad-list* cpads arg3 button0-abs 0) (pad-buttons 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 *camera-read-buttons*
|
|
(if
|
|
(logtest? (-> *cpad-list* cpads arg3 button0-abs 0) (pad-buttons 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 *camera-read-buttons*
|
|
(if
|
|
(logtest? (-> *cpad-list* cpads arg3 button0-abs 0) (pad-buttons 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 *camera-read-buttons*
|
|
(if
|
|
(logtest? (-> *cpad-list* cpads arg3 button0-abs 0) (pad-buttons 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 *camera-read-buttons*
|
|
(if (logtest? (-> *cpad-list* cpads arg3 button0-abs 0) (pad-buttons 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 *camera-read-buttons*
|
|
(if (logtest? (-> *cpad-list* cpads arg3 button0-abs 0) (pad-buttons 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)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
(cond
|
|
((not *cam-free-move-along-z*)
|
|
)
|
|
((not *camera-read-analog*)
|
|
)
|
|
((logtest? (-> *cpad-list* cpads arg3 button0-abs 0) (pad-buttons r2))
|
|
(when *camera-read-buttons*
|
|
(if (logtest? (-> *cpad-list* cpads arg3 button0-abs 0) (pad-buttons r1))
|
|
(+!
|
|
(-> arg1 y)
|
|
(+
|
|
(* 0.2 (-> *CAM_FREE-bank* speed))
|
|
(analog-input
|
|
(the-as int (-> *cpad-list* cpads arg3 abutton 9))
|
|
0.0
|
|
32.0
|
|
230.0
|
|
(* 0.2 (-> *CAM_FREE-bank* speed))
|
|
)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
(when *camera-read-buttons*
|
|
(if (logtest? (-> *cpad-list* cpads arg3 button0-abs 0) (pad-buttons l1))
|
|
(set!
|
|
(-> arg1 y)
|
|
(-
|
|
(-> arg1 y)
|
|
(+
|
|
(* 0.2 (-> *CAM_FREE-bank* speed))
|
|
(analog-input
|
|
(the-as int (-> *cpad-list* cpads arg3 abutton 8))
|
|
0.0
|
|
32.0
|
|
230.0
|
|
(* 0.2 (-> *CAM_FREE-bank* speed))
|
|
)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
(else
|
|
(when *camera-read-buttons*
|
|
(if (logtest? (-> *cpad-list* cpads arg3 button0-abs 0) (pad-buttons 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 *camera-read-buttons*
|
|
(if (logtest? (-> *cpad-list* cpads arg3 button0-abs 0) (pad-buttons 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 (and (!= *master-mode* 'menu) (not *cam-layout*))
|
|
(when *camera-read-buttons*
|
|
(if (logtest? (-> *cpad-list* cpads arg3 button0-abs 0) (pad-buttons 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 *camera-read-buttons*
|
|
(if (logtest? (-> *cpad-list* cpads arg3 button0-abs 0) (pad-buttons 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 *camera-read-buttons*
|
|
(if (logtest? (-> *cpad-list* cpads arg3 button0-abs 0) (pad-buttons 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 *camera-read-buttons*
|
|
(if (logtest? (-> *cpad-list* cpads arg3 button0-abs 0) (pad-buttons 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)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
(when *camera-read-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
|
|
)
|
|
)
|
|
(f24-0
|
|
(analog-input
|
|
(the-as int (-> *cpad-list* cpads arg3 rightx))
|
|
128.0
|
|
48.0
|
|
110.0
|
|
-1.0
|
|
)
|
|
)
|
|
(f26-0
|
|
(analog-input
|
|
(the-as int (-> *cpad-list* cpads arg3 righty))
|
|
128.0
|
|
48.0
|
|
110.0
|
|
-1.0
|
|
)
|
|
)
|
|
)
|
|
(when *display-load-boundaries*
|
|
(when
|
|
(and
|
|
(!= arg3 1)
|
|
(zero? (logand (-> *cpad-list* cpads 1 button0-abs 0) (pad-buttons x)))
|
|
(zero? (logand (-> *cpad-list* cpads 1 button0-abs 0) (pad-buttons r1)))
|
|
(zero? (logand (-> *cpad-list* cpads 1 button0-abs 0) (pad-buttons r2)))
|
|
)
|
|
(+!
|
|
f28-14
|
|
(analog-input
|
|
(the-as int (-> *cpad-list* cpads 1 leftx))
|
|
128.0
|
|
48.0
|
|
110.0
|
|
-1.0
|
|
)
|
|
)
|
|
(+!
|
|
f30-14
|
|
(analog-input
|
|
(the-as int (-> *cpad-list* cpads 1 lefty))
|
|
128.0
|
|
48.0
|
|
110.0
|
|
-1.0
|
|
)
|
|
)
|
|
(+!
|
|
f24-0
|
|
(analog-input
|
|
(the-as int (-> *cpad-list* cpads 1 rightx))
|
|
128.0
|
|
48.0
|
|
110.0
|
|
-1.0
|
|
)
|
|
)
|
|
(+!
|
|
f26-0
|
|
(analog-input
|
|
(the-as int (-> *cpad-list* cpads 1 righty))
|
|
128.0
|
|
48.0
|
|
110.0
|
|
-1.0
|
|
)
|
|
)
|
|
)
|
|
)
|
|
(cond
|
|
((logtest? (-> *cpad-list* cpads arg3 button0-abs 0) (pad-buttons r2))
|
|
(cond
|
|
((logtest? (-> *cpad-list* cpads arg3 button0-abs 0) (pad-buttons l2))
|
|
(set!
|
|
(-> arg0 y)
|
|
(- (-> arg0 y) (* 0.5 (-> *CAM_FREE-bank* rot-speed) (- f24-0)))
|
|
)
|
|
(set!
|
|
(-> arg0 x)
|
|
(- (-> arg0 x) (* 0.5 (-> *CAM_FREE-bank* rot-speed) (- f26-0)))
|
|
)
|
|
)
|
|
(else
|
|
(set!
|
|
(-> arg0 y)
|
|
(- (-> arg0 y) (* (- f24-0) (-> *CAM_FREE-bank* rot-speed)))
|
|
)
|
|
(set!
|
|
(-> arg0 x)
|
|
(- (-> arg0 x) (* (- f26-0) (-> *CAM_FREE-bank* rot-speed)))
|
|
)
|
|
)
|
|
)
|
|
(+! (-> arg1 x) (* 0.2 (-> *CAM_FREE-bank* speed) f28-14))
|
|
(+! (-> arg1 z) (* 0.2 (-> *CAM_FREE-bank* speed) f30-14))
|
|
)
|
|
((logtest? (-> *cpad-list* cpads arg3 button0-abs 0) (pad-buttons l2))
|
|
(+! (-> arg1 x) (* f28-14 (-> *CAM_FREE-bank* speed)))
|
|
(+! (-> arg1 y) (* f26-0 (-> *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) (- f24-0)))
|
|
)
|
|
(set!
|
|
(-> arg0 x)
|
|
(- (-> arg0 x) (* 2.0 (-> *CAM_FREE-bank* rot-speed) (- f26-0)))
|
|
)
|
|
(+! (-> arg1 x) (* 2.0 (-> *CAM_FREE-bank* speed) f28-14))
|
|
(+! (-> arg1 z) (* 2.0 (-> *CAM_FREE-bank* speed) f30-14))
|
|
)
|
|
)
|
|
)
|
|
)
|
|
(vector-float*! arg0 arg0 (-> *display* time-adjust-ratio))
|
|
(vector-float*! arg1 arg1 (-> *display* time-adjust-ratio))
|
|
)
|
|
|
|
(deftype camera-free-floating-move-info (structure)
|
|
((rv vector :inline :offset-assert 0)
|
|
(tv vector :inline :offset-assert 16)
|
|
(up vector :inline :offset-assert 32)
|
|
(tm matrix :inline :offset-assert 48)
|
|
)
|
|
:method-count-assert 9
|
|
:size-assert #x70
|
|
:flag-assert #x900000070
|
|
)
|
|
|
|
|
|
(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)
|
|
(the-as vector (-> arg0 vector))
|
|
(- (-> 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))
|
|
)
|
|
)
|
|
|
|
(defstate cam-free-floating (camera-slave)
|
|
:event
|
|
(behavior ((arg0 process) (arg1 int) (arg2 symbol) (arg3 event-message-block))
|
|
(case arg2
|
|
(('teleport)
|
|
#f
|
|
)
|
|
(else
|
|
(cam-standard-event-handler arg0 arg1 arg2 arg3)
|
|
)
|
|
)
|
|
)
|
|
:enter
|
|
(behavior ()
|
|
(when (not (-> self enter-has-run))
|
|
(set! (-> self blend-from-type) (the-as uint 1))
|
|
(set! (-> self blend-to-type) (the-as uint 1))
|
|
(send-event *camera-combiner* 'stop-tracking)
|
|
)
|
|
(none)
|
|
)
|
|
:code
|
|
(behavior ()
|
|
(while #t
|
|
(let ((a2-0 (-> *camera* local-down)))
|
|
(if (logtest? (-> self options) 8)
|
|
(set! a2-0 (the-as vector #f))
|
|
)
|
|
(cam-free-floating-move
|
|
(the-as matrix (-> self tracking))
|
|
(-> self trans)
|
|
a2-0
|
|
(the-as int (-> *CAMERA-bank* joypad))
|
|
)
|
|
)
|
|
(suspend)
|
|
)
|
|
(none)
|
|
)
|
|
)
|
|
|
|
(deftype camera-orbit-info (structure)
|
|
((radius float :offset-assert 0)
|
|
(rot float :offset-assert 4)
|
|
(target-off vector :inline :offset-assert 16)
|
|
(orbit-off vector :inline :offset-assert 32)
|
|
(radius-lerp float :offset-assert 48)
|
|
)
|
|
:method-count-assert 9
|
|
:size-assert #x34
|
|
:flag-assert #x900000034
|
|
)
|
|
|
|
|
|
(deftype CAM_ORBIT-bank (basic)
|
|
((RADIUS_MAX float :offset-assert 4)
|
|
(RADIUS_MIN float :offset-assert 8)
|
|
(TARGET_OFF_ADJUST float :offset-assert 12)
|
|
(ORBIT_OFF_ADJUST float :offset-assert 16)
|
|
)
|
|
:method-count-assert 9
|
|
:size-assert #x14
|
|
:flag-assert #x900000014
|
|
)
|
|
|
|
|
|
(define
|
|
*CAM_ORBIT-bank*
|
|
(new 'static 'CAM_ORBIT-bank
|
|
:RADIUS_MAX 61440.0
|
|
:RADIUS_MIN 409.6
|
|
:TARGET_OFF_ADJUST 81.92
|
|
:ORBIT_OFF_ADJUST 81.92
|
|
)
|
|
)
|
|
|
|
(define *camera-orbit-info* (new 'static 'camera-orbit-info))
|
|
|
|
(set! (-> *camera-orbit-info* radius-lerp) 0.45)
|
|
|
|
(set! (-> *camera-orbit-info* target-off y) 4096.0)
|
|
|
|
(set! (-> *camera-orbit-info* orbit-off y) 4096.0)
|
|
|
|
(defstate cam-orbit (camera-slave)
|
|
:event
|
|
(behavior ((arg0 process) (arg1 int) (arg2 symbol) (arg3 event-message-block))
|
|
(case arg2
|
|
(('teleport)
|
|
#f
|
|
)
|
|
(else
|
|
(cam-standard-event-handler arg0 arg1 arg2 arg3)
|
|
)
|
|
)
|
|
)
|
|
:enter
|
|
(behavior ()
|
|
(when (not (-> self enter-has-run))
|
|
(if (not *camera-orbit-target*)
|
|
(cam-slave-go cam-free-floating)
|
|
)
|
|
(let ((v1-4 (new-stack-vector0)))
|
|
(vector-! v1-4 (-> self trans) (-> *camera-orbit-target* 0 root trans))
|
|
(set! (-> *camera-orbit-info* rot) (atan (-> v1-4 x) (-> v1-4 z)))
|
|
)
|
|
(set! (-> self blend-from-type) (the-as uint 1))
|
|
(set! (-> self blend-to-type) (the-as uint 1))
|
|
)
|
|
(none)
|
|
)
|
|
:exit
|
|
(behavior ()
|
|
'()
|
|
(none)
|
|
)
|
|
:code
|
|
(behavior ()
|
|
(while #t
|
|
(if (not *camera-orbit-target*)
|
|
(cam-slave-go cam-free-floating)
|
|
)
|
|
(when *camera-read-analog*
|
|
(let
|
|
((f0-0
|
|
(analog-input
|
|
(the-as int (-> *cpad-list* cpads 0 righty))
|
|
128.0
|
|
32.0
|
|
110.0
|
|
0.05
|
|
)
|
|
)
|
|
)
|
|
(cond
|
|
((< (* 0.05 (- 1.0 (-> *camera-orbit-info* radius-lerp))) f0-0)
|
|
(+!
|
|
(-> *camera-orbit-info* radius-lerp)
|
|
(* 0.05 (- 1.0 (-> *camera-orbit-info* radius-lerp)))
|
|
)
|
|
)
|
|
((< f0-0 (* 0.05 (- (-> *camera-orbit-info* radius-lerp))))
|
|
(+!
|
|
(-> *camera-orbit-info* radius-lerp)
|
|
(* 0.05 (- (-> *camera-orbit-info* radius-lerp)))
|
|
)
|
|
)
|
|
(else
|
|
(+! (-> *camera-orbit-info* radius-lerp) f0-0)
|
|
)
|
|
)
|
|
)
|
|
(set!
|
|
(-> *camera-orbit-info* radius)
|
|
(lerp
|
|
(-> *CAM_ORBIT-bank* RADIUS_MIN)
|
|
(-> *CAM_ORBIT-bank* RADIUS_MAX)
|
|
(-> *camera-orbit-info* radius-lerp)
|
|
)
|
|
)
|
|
)
|
|
(cond
|
|
((logtest? (-> *cpad-list* cpads 0 button0-abs 0) (pad-buttons l2))
|
|
(if (logtest? (-> *cpad-list* cpads 0 button0-abs 0) (pad-buttons l1))
|
|
(set!
|
|
(-> *camera-orbit-info* target-off y)
|
|
(-
|
|
(-> *camera-orbit-info* target-off y)
|
|
(-> *CAM_ORBIT-bank* TARGET_OFF_ADJUST)
|
|
)
|
|
)
|
|
)
|
|
(if (logtest? (-> *cpad-list* cpads 0 button0-abs 0) (pad-buttons r1))
|
|
(+!
|
|
(-> *camera-orbit-info* target-off y)
|
|
(-> *CAM_ORBIT-bank* TARGET_OFF_ADJUST)
|
|
)
|
|
)
|
|
)
|
|
(else
|
|
(if (logtest? (-> *cpad-list* cpads 0 button0-abs 0) (pad-buttons l1))
|
|
(set!
|
|
(-> *camera-orbit-info* orbit-off y)
|
|
(-
|
|
(-> *camera-orbit-info* orbit-off y)
|
|
(-> *CAM_ORBIT-bank* ORBIT_OFF_ADJUST)
|
|
)
|
|
)
|
|
)
|
|
(if (logtest? (-> *cpad-list* cpads 0 button0-abs 0) (pad-buttons r1))
|
|
(+!
|
|
(-> *camera-orbit-info* orbit-off y)
|
|
(-> *CAM_ORBIT-bank* ORBIT_OFF_ADJUST)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
(when *camera-read-analog*
|
|
(let
|
|
((f0-20
|
|
(analog-input
|
|
(the-as int (-> *cpad-list* cpads 0 rightx))
|
|
128.0
|
|
32.0
|
|
110.0
|
|
(* 21845.334 (-> *display* seconds-per-frame))
|
|
)
|
|
)
|
|
)
|
|
(set!
|
|
(-> *camera-orbit-info* rot)
|
|
(the
|
|
float
|
|
(sar (shl (the int (+ (-> *camera-orbit-info* rot) f0-20)) 48) 48)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
(let ((gp-0 (new-stack-vector0)))
|
|
(let ((s5-0 (new-stack-vector0)))
|
|
(set-vector!
|
|
(-> self trans)
|
|
(+
|
|
(-> *camera-orbit-target* 0 root trans x)
|
|
(* (sin (-> *camera-orbit-info* rot)) (-> *camera-orbit-info* radius))
|
|
)
|
|
(-> *camera-orbit-target* 0 root trans y)
|
|
(+
|
|
(-> *camera-orbit-target* 0 root trans z)
|
|
(* (cos (-> *camera-orbit-info* rot)) (-> *camera-orbit-info* radius))
|
|
)
|
|
1.0
|
|
)
|
|
(vector+!
|
|
(-> self trans)
|
|
(-> self trans)
|
|
(-> *camera-orbit-info* orbit-off)
|
|
)
|
|
(vector+!
|
|
(-> self tracking follow-pt)
|
|
(-> *camera-orbit-target* 0 root trans)
|
|
(-> *camera-orbit-info* target-off)
|
|
)
|
|
(vector-! s5-0 (-> self trans) (-> self tracking follow-pt))
|
|
(set!
|
|
(-> gp-0 y)
|
|
(the
|
|
float
|
|
(sar (shl (the int (+ 32768.0 (atan (-> s5-0 x) (-> s5-0 z)))) 48) 48)
|
|
)
|
|
)
|
|
(set! (-> gp-0 x) (atan (-> s5-0 y) (vector-xz-length s5-0)))
|
|
)
|
|
(set! (-> gp-0 z) 0.0)
|
|
(matrix-rotate-zxy! (the-as matrix (-> self tracking)) gp-0)
|
|
)
|
|
(suspend)
|
|
)
|
|
(none)
|
|
)
|
|
)
|
|
|
|
|
|
|
|
|