diff --git a/decompiler/config/jak3/all-types.gc b/decompiler/config/jak3/all-types.gc index 9f539027b8..10fc91d211 100644 --- a/decompiler/config/jak3/all-types.gc +++ b/decompiler/config/jak3/all-types.gc @@ -34140,34 +34140,31 @@ ;; cam-debug ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype cam-dbg-scratch (structure) - ((linevec4w vector :inline :offset-assert 0) ;; vector4w 2 :inline - (color vector :inline :offset-assert 32) ;; vector4w :inline - (plotvec vector :inline :offset-assert 48) ;; vector4w 2 :inline - (linevec vector :inline :offset-assert 80) ;; vector4w 2 :inline - (rel-vec vector :inline :offset-assert 112) - (sphere-v-start vector :inline :offset-assert 128) - (sphere-v-end vector :inline :offset-assert 144) - (sphere-v-down vector :inline :offset-assert 160) - (sphere-vec vector :inline :offset-assert 176) - (crossvec vector :inline :offset-assert 192) - (bboxvec vector :inline :offset-assert 240) - (fov-vv vector :inline :offset-assert 336) - (fov-src vector :inline :offset-assert 400) - (fov-dest vector :inline :offset-assert 416) - (fov-vert vector :inline :offset-assert 432) - (fov-horz vector :inline :offset-assert 448) + ((linevec4w vector4w 2 :inline :offset-assert 0) ;; vector4w 2 :inline + (color vector4w :inline :offset-assert 32) ;; vector4w :inline + (plotvec vector4w 2 :inline :offset-assert 48) ;; vector4w 2 :inline + (linevec vector4w 2 :inline :offset-assert 80) ;; vector4w 2 :inline + (rel-vec vector :inline :offset-assert 112) + (sphere-v-start vector :inline :offset-assert 128) + (sphere-v-end vector :inline :offset-assert 144) + (sphere-v-down vector :inline :offset-assert 160) + (sphere-vec vector :inline :offset-assert 176) + (crossvec vector 3 :inline :offset-assert 192) + (bboxvec vector 6 :inline :offset-assert 240) + (fov-vv vector 4 :inline :offset-assert 336) + (fov-src vector :inline :offset-assert 400) + (fov-dest vector :inline :offset-assert 416) + (fov-vert vector :inline :offset-assert 432) + (fov-horz vector :inline :offset-assert 448) ) :method-count-assert 9 :size-assert #x1d0 :flag-assert #x9000001d0 ) -|# -#| (deftype cam-debug-tri (structure) - ((vertex vector 3 :offset-assert 0) ;; guessed by decompiler + ((vertex vector 3 :inline :offset-assert 0) ;; guessed by decompiler (intersect vector :inline :offset-assert 48) (color vector4w :offset-assert 64) ) @@ -34175,9 +34172,7 @@ :size-assert #x44 :flag-assert #x900000044 ) -|# -#| (deftype cam-collision-record (structure) ((pos vector :inline :offset-assert 0) (vel vector :inline :offset-assert 16) @@ -34199,9 +34194,7 @@ :size-assert #xa8 :flag-assert #x9000000a8 ) -|# -#| (deftype cam-collision-record-array (inline-array-class) ((data cam-collision-record :dynamic :offset-assert 16) ;; guessed by decompiler ) @@ -34209,54 +34202,53 @@ :size-assert #x10 :flag-assert #xe00000010 ) -|# -;; (define-extern *camera-old-cpu* object) ;; int -;; (define-extern *camera-old-vu* object) ;; int -;; (define-extern *camera-old-tfrag-bytes* object) ;; int -;; (define-extern *camera-old-level* object) ;; string -;; (define-extern *camera-old-stat-string-tfrag* object) ;; string -;; (define-extern *camera-old-stat-string-tfrag-near* object) ;; string -;; (define-extern *camera-old-stat-string-total* object) ;; string +(define-extern *camera-old-cpu* int) +(define-extern *camera-old-vu* int) +(define-extern *camera-old-tfrag-bytes* int) +(define-extern *camera-old-level* string) +(define-extern *camera-old-stat-string-tfrag* string) +(define-extern *camera-old-stat-string-tfrag-near* string) +(define-extern *camera-old-stat-string-total* string) (define-extern cam-slave-options->string (function cam-slave-options object string)) (define-extern cam-index-options->string (function cam-index-options object string)) (define-extern slave-los-state->string (function slave-los-state string)) -;; (define-extern cam-line-dma function) ;; (function pointer) -;; (define-extern camera-line2d function) ;; (function vector4w vector4w pointer) +(define-extern cam-line-dma (function pointer)) +(define-extern camera-line2d (function vector4w vector4w pointer)) (define-extern camera-plot-float-func (function float float float float (function float float) vector4w none)) (define-extern camera-line-setup (function vector4w none)) (define-extern camera-line-draw (function vector vector none)) (define-extern camera-line (function vector vector vector4w none)) (define-extern camera-line-rel (function vector vector vector4w none)) (define-extern camera-line-rel-len (function vector vector float vector4w none)) -;; (define-extern camera-sphere function) ;; (function vector float vector4w none) +(define-extern camera-sphere (function vector float vector4w none)) (define-extern camera-cross (function vector vector vector vector4w meters none)) -;; (define-extern camera-bounding-box-draw function) ;; (function bounding-box basic rgba none) -;; (define-extern *cam-debug-los-tri-current* object) ;; int -;; (define-extern *cam-debug-los-tri* object) ;; (inline-array cam-debug-tri) -;; (define-extern *cam-debug-coll-tri-current* object) ;; int -;; (define-extern *cam-debug-coll-tri* object) ;; (inline-array cam-debug-tri) +(define-extern camera-bounding-box-draw (function bounding-box basic rgba none)) +(define-extern *cam-debug-los-tri-current* int) +(define-extern *cam-debug-los-tri* (inline-array cam-debug-tri)) +(define-extern *cam-debug-coll-tri-current* int) +(define-extern *cam-debug-coll-tri* (inline-array cam-debug-tri)) (define-extern cam-debug-reset-coll-tri (function none)) (define-extern cam-debug-add-los-tri (function (inline-array collide-cache-tri) vector vector none)) -;; (define-extern cam-debug-add-coll-tri function) ;; (function cam-debug-tri vector cam-debug-tri none) -;; (define-extern cam-debug-draw-tris function) ;; (function symbol) -;; (define-extern camera-fov-draw function) ;; (function int int vector float float vector4w none) +(define-extern cam-debug-add-coll-tri (function cam-debug-tri vector cam-debug-tri none)) +(define-extern cam-debug-draw-tris (function symbol)) +(define-extern camera-fov-draw (function int int vector float float vector4w none)) (define-extern camera-fov-frame (function matrix vector float float float vector4w symbol)) -;; (define-extern debug-euler function) ;; (function cam-dbg-scratch object) -;; (define-extern bike-cam-limit function) ;; (function float float) +(define-extern debug-euler (function cam-dbg-scratch object)) +(define-extern bike-cam-limit (function float float)) (define-extern camera-slave-debug (function camera-slave none)) -;; (define-extern master-draw-coordinates function) ;; (function vector none) -;; (define-extern *cam-collision-record-first* object) ;; int -;; (define-extern *cam-collision-record-last* object) ;; int -;; (define-extern *cam-collision-record-show* object) ;; int -;; (define-extern *cam-collision-record* object) ;; cam-collision-record-array +(define-extern master-draw-coordinates (function vector none)) +(define-extern *cam-collision-record-first* int) +(define-extern *cam-collision-record-last* int) +(define-extern *cam-collision-record-show* int) +(define-extern *cam-collision-record* cam-collision-record-array) (define-extern cam-collision-record-save (function vector vector int symbol camera-slave none)) -;; (define-extern cam-collision-record-step function) ;; (function int none) -;; (define-extern cam-collision-record-draw function) ;; (function none) +(define-extern cam-collision-record-step (function int none)) +(define-extern cam-collision-record-draw (function none)) (define-extern camera-master-debug (function camera-master none)) (define-extern debug-set-camera-pos-rot! (function vector matrix vector)) -;; (define-extern cam-restore function) ;; (function none) -;; (define-extern cam-restore-generic-bug function) +(define-extern cam-restore (function none)) +(define-extern cam-restore-generic-bug (function none)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; cam-start ;; @@ -41061,12 +41053,12 @@ ;; sampler ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; (define-extern *sampler-mem* object) ;; pointer -;; (define-extern *sampler-compare* object) ;; uint -;; (define-extern *sampler-count* object) ;; int -;; (define-extern timer0-handler function) ;; (function none) -;; (define-extern sampler-start function) ;; (function none) -;; (define-extern sampler-stop function) ;; (function none) +(define-extern *sampler-mem* pointer) +(define-extern *sampler-compare* uint) +(define-extern *sampler-count* int) +(define-extern timer0-handler (function none)) +(define-extern sampler-start (function none)) +(define-extern sampler-stop (function none)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; default-menu ;; @@ -44321,7 +44313,6 @@ ;; hover-nav-edit ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype hover-nav-bsp-point (list-node) ((index int32 :offset-assert 8) (pos vector :inline :offset-assert 16) @@ -44329,10 +44320,11 @@ :method-count-assert 9 :size-assert #x20 :flag-assert #x900000020 + (:methods + (new (symbol type) _type_) ;; 0 + ) ) -|# -#| (deftype hover-nav-bsp-node (structure) ((split-plane vector :inline :offset-assert 0) (point-list hover-nav-bsp-point :offset-assert 16) @@ -44343,14 +44335,12 @@ :size-assert #x1c :flag-assert #xb0000001c (:methods - (new (symbol type) _type_) ;; 0 ;; (new (symbol type) _type_) - (hover-nav-bsp-node-method-9 () none) ;; 9 ;; (hover-nav-bsp-node-method-9 (_type_) none) - (hover-nav-bsp-node-method-10 () none) ;; 10 ;; (hover-nav-bsp-node-method-10 (_type_ int) none) + (new (symbol type) _type_) ;; 0 + (hover-nav-bsp-node-method-9 (_type_) none) ;; 9 + (hover-nav-bsp-node-method-10 (_type_ int) none) ;; 10 ) ) -|# -#| (deftype hover-nav-bsp (structure) ((root hover-nav-bsp-node :offset-assert 0) ) @@ -44358,16 +44348,15 @@ :size-assert #x4 :flag-assert #x900000004 ) -|# -;; (define-extern probe-for-clear-collision? function) ;; (function vector vector symbol) -;; (define-extern hover-nav-graph-process-points function) ;; (function none) -;; (define-extern hover-nav-graph-output function) ;; (function symbol) -;; (define-extern *axes-table* array) ;; (array vector) -;; (define-extern *hover-bsp* object) ;; hover-nav-bsp -;; (define-extern hover-nav-graph-output-bsp function) ;; (function hover-nav-bsp) -;; (define-extern hover-nav-network-build-bsp function) ;; (function (array hover-nav-bsp-point) hover-nav-bsp) -;; (define-extern hover-nav-bsp-output function) ;; (function hover-nav-bsp none) +(define-extern probe-for-clear-collision? (function vector vector symbol)) +(define-extern hover-nav-graph-process-points (function none)) +(define-extern hover-nav-graph-output (function string object)) +(define-extern *axes-table* (array vector)) +(define-extern *hover-bsp* hover-nav-bsp) +(define-extern hover-nav-graph-output-bsp (function hover-nav-bsp)) +(define-extern hover-nav-network-build-bsp (function (array hover-nav-bsp-point) hover-nav-bsp)) +(define-extern hover-nav-bsp-output (function hover-nav-bsp none)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; dp-bipedal-part ;; @@ -56758,23 +56747,30 @@ ;; pilot-recorder ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| +;; +++pilot-recorder:pilrec-sample-flag +(defenum pilrec-sample-flag + :type uint8 + :bitfield #t + (square 0) + (l1 1) + (x 2) + ) +;; ---pilot-recorder:pilrec-sample-flag + (deftype pilrec-sample (structure) - ((sample-time uint64 :offset-assert 0) ;; time-frame + ((sample-time time-frame :offset-assert 0) ;; time-frame (pos vector :inline :offset-assert 16) (quat quaternion :inline :offset-assert 32) (stick-x float :offset-assert 48) (stick-y float :offset-assert 52) (throttle float :offset-assert 56) - (flags uint8 :offset-assert 60) + (flags pilrec-sample-flag :offset-assert 60) ) :method-count-assert 9 :size-assert #x3d :flag-assert #x90000003d ) -|# -#| (deftype pilot-recorder-samples (basic) ((samples (inline-array pilrec-sample) :offset-assert 4) ;; guessed by decompiler ) @@ -56782,18 +56778,16 @@ :size-assert #x8 :flag-assert #x900000008 ) -|# -#| (deftype pilot-recorder (process) ((info race-info :offset-assert 128) ;; guessed by decompiler (mesh race-mesh :offset-assert 132) ;; guessed by decompiler (select-race uint64 :offset-assert 136) (path-num int32 :offset-assert 144) (sample-count int32 :offset-assert 148) - (samples pilot-recorder-samples :offset-assert 152) ;; guessed by decompiler - (state-time uint64 :offset-assert 160) ;; time-frame - (start-time uint64 :offset-assert 168) ;; time-frame + (samples (inline-array pilrec-sample) :offset-assert 152) ;; guessed by decompiler + (state-time time-frame :offset-assert 160) ;; time-frame + (start-time time-frame :offset-assert 168) ;; time-frame (start-record-plane plane :inline :offset-assert 176) (start-record-center vector :inline :offset-assert 192) (finish-record-plane plane :inline :offset-assert 208) @@ -56803,34 +56797,33 @@ :method-count-assert 31 :size-assert #x100 :flag-assert #x1f00800100 - (:methods - (pilot-recorder-method-22 () none) ;; 22 ;; (pilot-recorder-method-22 () none) - (pilot-recorder-method-23 () none) ;; 23 ;; (pilot-recorder-method-23 () none) - (pilot-recorder-method-24 () none) ;; 24 ;; (pilot-recorder-method-24 () none) - (pilot-recorder-method-25 () none) ;; 25 ;; (pilot-recorder-method-25 () none) - (pilot-recorder-method-26 () none) ;; 26 ;; (pilot-recorder-method-26 () none) - (pilot-recorder-method-27 () none) ;; 27 ;; (pilot-recorder-method-27 () none) - (pilot-recorder-method-28 () none) ;; 28 ;; (pilot-recorder-method-28 () none) - (pilot-recorder-method-29 () none) ;; 29 ;; (pilot-recorder-method-29 () none) - (pilot-recorder-method-30 () none) ;; 30 ;; (pilot-recorder-method-30 () none) - ) (:state-methods - die-fast ;; 14, old: (die-fast () _type_ :state) - fail-full ;; 18, old: (fail-full () _type_ :state) - fail-save ;; 21, old: (fail-save () _type_ :state) - save ;; 20, old: (save () _type_ :state) - finished ;; 19, old: (finished () _type_ :state) - recording ;; 17, old: (recording () _type_ :state) - active ;; 16, old: (active () _type_ :state) - idle ;; 15, old: (idle () _type_ :state) + die-fast ;; 14 + idle ;; 15 + active ;; 16 + recording ;; 17 + fail-full ;; 18 + finished ;; 19 + save ;; 20 + fail-save ;; 21 + ) + (:methods + (pilot-recorder-method-22 (_type_) symbol) ;; 22 + (passed-starting-line? (_type_ vector vector) symbol) ;; 23 + (recording-finished? (_type_ vector vector) symbol) ;; 24 + (draw-starting-line (_type_ vector vector) none) ;; 25 + (draw-recorded-path (_type_) none) ;; 26 + (pilot-recorder-method-27 (_type_) none) ;; 27 + (record-input-sample! (_type_ pilrec-sample) pilrec-sample-flag) ;; 28 + (lerp-samples! (_type_ pilrec-sample pilrec-sample pilrec-sample float time-frame) none) ;; 29 + (save-to-db! (_type_) symbol) ;; 30 ) ) -|# -;; (define-extern *pilot-recorder-samples* object) -;; (define-extern delete-race-path function) -;; (define-extern *pilot-recorder* object) -;; (define-extern pilot-recorder-init-by-other function) +(define-extern *pilot-recorder-samples* pilot-recorder-samples) +(define-extern delete-race-path (function int int object)) +(define-extern *pilot-recorder* (pointer pilot-recorder)) +(define-extern pilot-recorder-init-by-other (function uint int object :behavior pilot-recorder)) (define-extern start-pilot-recorder (function none)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; diff --git a/decompiler/config/jak3/ntsc_v1/hacks.jsonc b/decompiler/config/jak3/ntsc_v1/hacks.jsonc index 773688d881..125378450e 100644 --- a/decompiler/config/jak3/ntsc_v1/hacks.jsonc +++ b/decompiler/config/jak3/ntsc_v1/hacks.jsonc @@ -41,9 +41,6 @@ "anim-test-anim-list-handler", "anim-test-sequence-list-handler", "anim-tester-get-playing-item", - "start-pilot-recorder", - "(anon-function 10 pilot-recorder)", - "(anon-function 10 sig-recorder)", // actual asm "quad-copy!", "return-from-thread", @@ -584,7 +581,8 @@ [378, 0], [413, 0] ], - "(trans carry precur-bomb)": [[60, 0]] + "(trans carry precur-bomb)": [[60, 0]], + "hover-nav-graph-output": [[319, 0]] }, "mips2c_functions_by_name": [ diff --git a/decompiler/config/jak3/ntsc_v1/stack_structures.jsonc b/decompiler/config/jak3/ntsc_v1/stack_structures.jsonc index 2e5f4d1f42..4138d2091e 100644 --- a/decompiler/config/jak3/ntsc_v1/stack_structures.jsonc +++ b/decompiler/config/jak3/ntsc_v1/stack_structures.jsonc @@ -2631,5 +2631,20 @@ "(method 14 nav-mesh-editable)": [ [16, ["inline-array", "vector", 4]], [80, ["inline-array", "vector", 4]] + ], + "camera-slave-debug": [ + [16, "vector"], + [32, "vector"], + [48, "matrix"], + [128, "curve"] + ], + "hover-nav-graph-output": [ + [32, "vector"], + [48, "vector"] + ], + "(method 25 pilot-recorder)": [[16, ["inline-array", "vector", 2]]], + "(method 22 pilot-recorder)": [ + [16, ["inline-array", "vector", 4]], + [80, ["inline-array", "vector", 4]] ] } diff --git a/decompiler/config/jak3/ntsc_v1/type_casts.jsonc b/decompiler/config/jak3/ntsc_v1/type_casts.jsonc index 7fa036182a..27b838535f 100644 --- a/decompiler/config/jak3/ntsc_v1/type_casts.jsonc +++ b/decompiler/config/jak3/ntsc_v1/type_casts.jsonc @@ -11482,5 +11482,267 @@ "(trans idle nav-mesh-editor)": [ [423, "v0", "int"], [476, "v0", "int"] + ], + "cam-collision-record-draw": [[[45, 240], "s5", "cam-collision-record"]], + "camera-fov-frame": [ + [87, "a0", "vector4w"], + [128, "a0", "vector4w"], + [169, "a0", "vector4w"], + [7, "a0", "cam-dbg-scratch"], + [18, "a0", "cam-dbg-scratch"], + [29, "a0", "cam-dbg-scratch"], + [33, "a2", "cam-dbg-scratch"], + [36, "a3", "cam-dbg-scratch"], + [39, "t0", "cam-dbg-scratch"], + [45, "a0", "cam-dbg-scratch"], + [50, "a0", "cam-dbg-scratch"], + [54, "a2", "cam-dbg-scratch"], + [57, "a3", "cam-dbg-scratch"], + [60, "t0", "cam-dbg-scratch"], + [66, "a0", "cam-dbg-scratch"], + [72, "a0", "cam-dbg-scratch"], + [75, "a1", "cam-dbg-scratch"], + [83, "a0", "cam-dbg-scratch"], + [86, "a1", "cam-dbg-scratch"], + [91, "a0", "cam-dbg-scratch"], + [95, "a2", "cam-dbg-scratch"], + [101, "t0", "cam-dbg-scratch"], + [98, "a3", "cam-dbg-scratch"], + [107, "a0", "cam-dbg-scratch"], + [113, "a0", "cam-dbg-scratch"], + [116, "a1", "cam-dbg-scratch"], + [124, "a0", "cam-dbg-scratch"], + [127, "a1", "cam-dbg-scratch"], + [132, "a0", "cam-dbg-scratch"], + [136, "a2", "cam-dbg-scratch"], + [139, "a3", "cam-dbg-scratch"], + [142, "t0", "cam-dbg-scratch"], + [148, "a0", "cam-dbg-scratch"], + [154, "a0", "cam-dbg-scratch"], + [157, "a1", "cam-dbg-scratch"], + [165, "a0", "cam-dbg-scratch"], + [168, "a1", "cam-dbg-scratch"], + [173, "a0", "cam-dbg-scratch"], + [177, "a2", "cam-dbg-scratch"], + [180, "a3", "cam-dbg-scratch"], + [183, "t0", "cam-dbg-scratch"], + [189, "a0", "cam-dbg-scratch"], + [195, "a0", "cam-dbg-scratch"], + [198, "a1", "cam-dbg-scratch"] + ], + "camera-sphere": [ + [[43, 49], "v1", "cam-dbg-scratch"], + [64, "v1", "cam-dbg-scratch"], + [80, "v1", "cam-dbg-scratch"], + [94, "v1", "cam-dbg-scratch"], + [109, "v1", "cam-dbg-scratch"], + [124, "v1", "cam-dbg-scratch"], + [138, "v1", "cam-dbg-scratch"], + [152, "v1", "cam-dbg-scratch"], + [156, "a0", "cam-dbg-scratch"], + [159, "a1", "cam-dbg-scratch"], + [164, "a0", "cam-dbg-scratch"], + [167, "a1", "cam-dbg-scratch"] + ], + "camera-line-draw": [ + [36, "a0", "cam-dbg-scratch"], + [44, "a0", "cam-dbg-scratch"], + [2, "a2", "cam-dbg-scratch"], + [7, "a0", "cam-dbg-scratch"], + [14, "v1", "cam-dbg-scratch"], + [18, "v1", "cam-dbg-scratch"], + [22, "a0", "cam-dbg-scratch"], + [24, "v1", "cam-dbg-scratch"], + [29, "a0", "cam-dbg-scratch"], + [32, "a1", "cam-dbg-scratch"], + [36, "a0", "cam-dbg-scratch"], + [44, "a0", "cam-dbg-scratch"] + ], + "camera-plot-float-func": [ + [56, "v1", "cam-dbg-scratch"], + [64, "a0", "cam-dbg-scratch"], + [68, "a0", "cam-dbg-scratch"], + [105, "v1", "cam-dbg-scratch"], + [242, "v1", "cam-dbg-scratch"], + [21, "a0", "cam-dbg-scratch"], + [24, "a0", "cam-dbg-scratch"], + [27, "a0", "cam-dbg-scratch"], + [30, "a0", "cam-dbg-scratch"], + [51, "a0", "cam-dbg-scratch"], + [54, "a0", "cam-dbg-scratch"], + [56, "v1", "cam-dbg-scratch"], + [58, "a0", "cam-dbg-scratch"], + [64, "a0", "cam-dbg-scratch"], + [87, "a0", "cam-dbg-scratch"], + [97, "a0", "cam-dbg-scratch"], + [103, "a0", "cam-dbg-scratch"], + [105, "v1", "cam-dbg-scratch"], + [107, "a0", "cam-dbg-scratch"], + [111, "a0", "cam-dbg-scratch"], + [114, "a1", "cam-dbg-scratch"], + [119, "a0", "cam-dbg-scratch"], + [122, "a0", "cam-dbg-scratch"], + [128, "a0", "cam-dbg-scratch"], + [131, "a0", "cam-dbg-scratch"], + [135, "a0", "cam-dbg-scratch"], + [138, "a1", "cam-dbg-scratch"], + [142, "a0", "cam-dbg-scratch"], + [148, "a0", "cam-dbg-scratch"], + [154, "a0", "cam-dbg-scratch"], + [160, "a0", "cam-dbg-scratch"], + [164, "a0", "cam-dbg-scratch"], + [167, "a1", "cam-dbg-scratch"], + [171, "a0", "cam-dbg-scratch"], + [174, "a0", "cam-dbg-scratch"], + [177, "a0", "cam-dbg-scratch"], + [183, "a0", "cam-dbg-scratch"], + [187, "a0", "cam-dbg-scratch"], + [190, "a1", "cam-dbg-scratch"], + [197, "a0", "cam-dbg-scratch"], + [200, "a0", "cam-dbg-scratch"], + [206, "a0", "cam-dbg-scratch"], + [212, "a0", "cam-dbg-scratch"], + [216, "a0", "cam-dbg-scratch"], + [219, "a1", "cam-dbg-scratch"], + [223, "a0", "cam-dbg-scratch"], + [226, "a0", "cam-dbg-scratch"], + [238, "a0", "cam-dbg-scratch"], + [242, "v1", "cam-dbg-scratch"], + [244, "a0", "cam-dbg-scratch"], + [247, "a0", "cam-dbg-scratch"], + [266, "a0", "cam-dbg-scratch"], + [270, "a0", "cam-dbg-scratch"], + [273, "a1", "cam-dbg-scratch"] + ], + "cam-line-dma": [ + [32, "t0", "vector"], + [36, "t0", "vector"], + [45, "t0", "vector"], + [50, "t0", "vector"], + [[12, 16], "a3", "dma-packet"], + [[22, 25], "a3", "gs-gif-tag"], + [[33, 38], "a3", "(pointer uint128)"], + [[46, 52], "a1", "(pointer uint128)"], + [[60, 65], "a0", "dma-packet"], + [[65, 74], "a0", "(pointer uint64)"] + ], + "camera-line2d": [ + [4, "a2", "cam-dbg-scratch"], + [6, "a0", "cam-dbg-scratch"], + [10, "a0", "cam-dbg-scratch"], + [13, "a0", "cam-dbg-scratch"], + [14, "a1", "cam-dbg-scratch"], + [18, "a0", "cam-dbg-scratch"], + [20, "a1", "cam-dbg-scratch"], + [24, "a0", "cam-dbg-scratch"], + [27, "a0", "cam-dbg-scratch"] + ], + "camera-line-setup": [[2, "a0", "cam-dbg-scratch"]], + "camera-line-rel-len": [ + [9, "a0", "cam-dbg-scratch"], + [5, "a0", "cam-dbg-scratch"], + [12, "a1", "cam-dbg-scratch"], + [18, "a0", "cam-dbg-scratch"] + ], + "camera-line-rel": [ + [2, "a3", "cam-dbg-scratch"], + [8, "a1", "cam-dbg-scratch"] + ], + "camera-bounding-box-draw": [ + [6, "a0", "cam-dbg-scratch"], + [15, "a0", "cam-dbg-scratch"], + [21, "v1", "cam-dbg-scratch"], + [24, "a0", "cam-dbg-scratch"], + [30, "v1", "cam-dbg-scratch"], + [33, "a0", "cam-dbg-scratch"], + [39, "v1", "cam-dbg-scratch"], + [42, "a0", "cam-dbg-scratch"], + [48, "v1", "cam-dbg-scratch"], + [51, "a0", "cam-dbg-scratch"], + [57, "v1", "cam-dbg-scratch"], + [62, "a1", "cam-dbg-scratch"], + [68, "a1", "cam-dbg-scratch"], + [74, "a1", "cam-dbg-scratch"], + [80, "a1", "cam-dbg-scratch"], + [86, "a1", "cam-dbg-scratch"], + [92, "a1", "cam-dbg-scratch"], + [97, "a0", "cam-dbg-scratch"], + [100, "a1", "cam-dbg-scratch"], + [105, "a0", "cam-dbg-scratch"], + [108, "a1", "cam-dbg-scratch"], + [113, "a0", "cam-dbg-scratch"], + [116, "a1", "cam-dbg-scratch"], + [121, "a0", "cam-dbg-scratch"], + [124, "a1", "cam-dbg-scratch"], + [129, "a0", "cam-dbg-scratch"], + [132, "a1", "cam-dbg-scratch"], + [137, "a0", "cam-dbg-scratch"], + [140, "a1", "cam-dbg-scratch"], + [12, "v1", "cam-dbg-scratch"] + ], + "camera-cross": [ + [8, "a0", "cam-dbg-scratch"], + [14, "a0", "cam-dbg-scratch"], + [18, "a2", "cam-dbg-scratch"], + [22, "a0", "cam-dbg-scratch"], + [26, "a2", "cam-dbg-scratch"], + [31, "a0", "cam-dbg-scratch"], + [34, "a1", "cam-dbg-scratch"], + [39, "a0", "cam-dbg-scratch"], + [42, "a1", "cam-dbg-scratch"], + [47, "a0", "cam-dbg-scratch"], + [52, "a0", "cam-dbg-scratch"], + [52, "a0", "cam-dbg-scratch"], + [56, "a2", "cam-dbg-scratch"], + [60, "a0", "cam-dbg-scratch"], + [64, "a2", "cam-dbg-scratch"], + [69, "a0", "cam-dbg-scratch"], + [72, "a1", "cam-dbg-scratch"], + [77, "a0", "cam-dbg-scratch"], + [80, "a1", "cam-dbg-scratch"], + [85, "a0", "cam-dbg-scratch"], + [90, "a0", "cam-dbg-scratch"], + [94, "a2", "cam-dbg-scratch"], + [98, "a0", "cam-dbg-scratch"], + [101, "a1", "cam-dbg-scratch"], + [106, "a0", "cam-dbg-scratch"], + [109, "a1", "cam-dbg-scratch"] + ], + "cam-debug-draw-tris": [ + [20, "a0", "cam-dbg-scratch"], + [88, "a0", "cam-dbg-scratch"] + ], + "camera-fov-draw": [ + [16, "t2", "cam-dbg-scratch"], + [30, "a3", "cam-dbg-scratch"], + [43, "a0", "cam-dbg-scratch"], + [60, "a0", "cam-dbg-scratch"], + [63, "a1", "cam-dbg-scratch"], + [68, "a0", "cam-dbg-scratch"], + [71, "a1", "cam-dbg-scratch"], + [76, "a0", "cam-dbg-scratch"], + [79, "a1", "cam-dbg-scratch"], + [2, "t2", "cam-dbg-scratch"], + [13, "v1", "(pointer vector)"], + [27, "v1", "(pointer vector)"], + [40, "v1", "(pointer vector)"], + [53, "v1", "(pointer vector)"] + ], + "cam-collision-record-save": [[[8, 56], "v1", "cam-collision-record"]], + "(method 9 hover-nav-bsp-node)": [[[22, 28], "v1", "hover-nav-bsp-point"]], + "(method 0 hover-nav-bsp-node)": [[[6, 9], "v0", "hover-nav-bsp-node"]], + "(method 0 hover-nav-bsp-point)": [[[6, 8], "v0", "hover-nav-bsp-point"]], + "(method 28 pilot-recorder)": [[20, "v1", "vehicle"]], + "hover-nav-network-build-bsp": [ + [26, "a0", "(pointer int32)"], + [33, "a1", "vector"] + ], + "sampler-stop": [[1, "v1", "timer-bank"]], + "(top-level-login sampler)": [[14, "v1", "timer-bank"]], + "sampler-start": [ + [3, "v1", "timer-bank"], + [6, "a0", "timer-bank"], + [24, "a0", "timer-bank"], + [1, "v1", "timer-bank"] ] } diff --git a/decompiler/config/jak3/ntsc_v1/var_names.jsonc b/decompiler/config/jak3/ntsc_v1/var_names.jsonc index 49154343ac..2611452c37 100644 --- a/decompiler/config/jak3/ntsc_v1/var_names.jsonc +++ b/decompiler/config/jak3/ntsc_v1/var_names.jsonc @@ -2174,5 +2174,10 @@ "vars": { "v0-3": ["filter", "editable-filter"] } + }, + "(method 28 pilot-recorder)": { + "vars": { + "v0-0": ["flag", "pilrec-sample-flag"] + } } } diff --git a/goal_src/jak3/engine/camera/cam-debug.gc b/goal_src/jak3/engine/camera/cam-debug.gc index da31051c08..8f45dd6915 100644 --- a/goal_src/jak3/engine/camera/cam-debug.gc +++ b/goal_src/jak3/engine/camera/cam-debug.gc @@ -5,19 +5,1687 @@ ;; name in dgo: cam-debug ;; dgos: GAME -(define-extern camera-plot-float-func (function float float float float (function float float) vector4w none)) +(define-extern *camera-old-cpu* int) +(define-extern *camera-old-vu* int) +(define-extern *camera-old-tfrag-bytes* int) +(define-extern *camera-old-level* string) +(define-extern *camera-old-stat-string-tfrag* string) +(define-extern *camera-old-stat-string-tfrag-near* string) +(define-extern *camera-old-stat-string-total* string) ;; DECOMP BEGINS -;; TODO stubs -(defun cam-collision-record-save ((arg0 vector) (arg1 vector) (arg2 int) (arg3 symbol) (arg4 camera-slave)) +;; this file is debug only +(declare-file (debug)) + +(when (or (not *camera-old-cpu*) (zero? *camera-old-cpu*)) + (set! *camera-old-cpu* 0) + 0 + ) + +(when (or (not *camera-old-vu*) (zero? *camera-old-vu*)) + (set! *camera-old-vu* 0) + 0 + ) + +(when (or (not *camera-old-tfrag-bytes*) (zero? *camera-old-tfrag-bytes*)) + (set! *camera-old-tfrag-bytes* 0) + 0 + ) + +(define-perm *camera-old-level* string (new 'global 'string 128 (the-as string #f))) + +(define-perm *camera-old-stat-string-tfrag* string (new 'global 'string 128 (the-as string #f))) + +(define-perm *camera-old-stat-string-tfrag-near* string (new 'global 'string 128 (the-as string #f))) + +(define-perm *camera-old-stat-string-total* string (new 'global 'string 128 (the-as string #f))) + +(deftype cam-dbg-scratch (structure) + ((linevec4w vector4w 2 :inline) + (color vector4w :inline) + (plotvec vector4w 2 :inline) + (linevec vector4w 2 :inline) + (rel-vec vector :inline) + (sphere-v-start vector :inline) + (sphere-v-end vector :inline) + (sphere-v-down vector :inline) + (sphere-vec vector :inline) + (crossvec vector 3 :inline) + (bboxvec vector 6 :inline) + (fov-vv vector 4 :inline) + (fov-src vector :inline) + (fov-dest vector :inline) + (fov-vert vector :inline) + (fov-horz vector :inline) + ) + ) + + +;; WARN: Return type mismatch object vs string. +(defun cam-slave-options->string ((arg0 cam-slave-options) (arg1 object)) + (if (= (logand arg0 (cam-slave-options SAME_SIDE)) (cam-slave-options SAME_SIDE)) + (format arg1 "SAME_SIDE ") + ) + (if (= (logand (cam-slave-options GUN_CAM) arg0) (cam-slave-options GUN_CAM)) + (format arg1 "GUN_CAM ") + ) + (if (= (logand (cam-slave-options BOMBBOT) arg0) (cam-slave-options BOMBBOT)) + (format arg1 "BOMBBOT ") + ) + (if (= (logand arg0 (cam-slave-options STICKY_ANGLE)) (cam-slave-options STICKY_ANGLE)) + (format arg1 "STICKY_ANGLE ") + ) + (if (= (logand arg0 (cam-slave-options FIND_HIDDEN_TARGET)) (cam-slave-options FIND_HIDDEN_TARGET)) + (format arg1 "FIND_HIDDEN_TARGET ") + ) + (if (= (logand (cam-slave-options RAPID_TRACKING) arg0) (cam-slave-options RAPID_TRACKING)) + (format arg1 "RAPID_TRACKING ") + ) + (if (= (logand arg0 (cam-slave-options SHRINK_MAX_ANGLE)) (cam-slave-options SHRINK_MAX_ANGLE)) + (format arg1 "SHRINK_MAX_ANGLE ") + ) + (if (= (logand arg0 (cam-slave-options JUMP_PITCHES)) (cam-slave-options JUMP_PITCHES)) + (format arg1 "JUMP_PITCHES ") + ) + (if (= (logand arg0 (cam-slave-options LINE_OF_SIGHT)) (cam-slave-options LINE_OF_SIGHT)) + (format arg1 "LINE_OF_SIGHT ") + ) + (if (= (logand arg0 (cam-slave-options PLAYER_MOVING_CAMERA)) (cam-slave-options PLAYER_MOVING_CAMERA)) + (format arg1 "PLAYER_MOVING_CAMERA ") + ) + (if (= (logand (cam-slave-options ALLOW_SHIFT_BUTTONS) arg0) (cam-slave-options ALLOW_SHIFT_BUTTONS)) + (format arg1 "ALLOW_SHIFT_BUTTONS ") + ) + (if (= (logand arg0 (cam-slave-options NO_ROTATE)) (cam-slave-options NO_ROTATE)) + (format arg1 "NO_ROTATE ") + ) + (if (= (logand (cam-slave-options WIDE_FOV) arg0) (cam-slave-options WIDE_FOV)) + (format arg1 "WIDE_FOV ") + ) + (if (= (logand arg0 (cam-slave-options MOVE_SPHERICAL)) (cam-slave-options MOVE_SPHERICAL)) + (format arg1 "MOVE_SPHERICAL ") + ) + (if (= (logand arg0 (cam-slave-options DRAG)) (cam-slave-options DRAG)) + (format arg1 "DRAG ") + ) + (if (= (logand arg0 (cam-slave-options MOVEMENT_BLOCKED)) (cam-slave-options MOVEMENT_BLOCKED)) + (format arg1 "MOVEMENT_BLOCKED ") + ) + (if (= (logand (cam-slave-options BLOCK_RIGHT_STICK) arg0) (cam-slave-options BLOCK_RIGHT_STICK)) + (format arg1 "BLOCK_RIGHT_STICK ") + ) + (if (= (logand arg0 (cam-slave-options COLLIDE)) (cam-slave-options COLLIDE)) + (format arg1 "COLLIDE ") + ) + (if (= (logand arg0 (cam-slave-options ALLOW_Z_ROT)) (cam-slave-options ALLOW_Z_ROT)) + (format arg1 "ALLOW_Z_ROT ") + ) + (if (= (logand (cam-slave-options JUMP_LAG) arg0) (cam-slave-options JUMP_LAG)) + (format arg1 "JUMP_LAG ") + ) + (if (= (logand arg0 (cam-slave-options BIKE_MODE)) (cam-slave-options BIKE_MODE)) + (format arg1 "BIKE_MODE ") + ) + (if (= (logand (cam-slave-options EASE_SPLINE_IDX) arg0) (cam-slave-options EASE_SPLINE_IDX)) + (format arg1 "EASE_SPLINE_IDX ") + ) + (if (= (logand arg0 (cam-slave-options GOTO_GOOD_POINT)) (cam-slave-options GOTO_GOOD_POINT)) + (format arg1 "GOTO_GOOD_POINT ") + ) + (if (= (logand arg0 (cam-slave-options BUTT_CAM)) (cam-slave-options BUTT_CAM)) + (format arg1 "BUTT_CAM ") + ) + (if (= (logand (cam-slave-options VERTICAL_FOLLOW_MATCHES_CAMERA) arg0) + (cam-slave-options VERTICAL_FOLLOW_MATCHES_CAMERA) + ) + (format arg1 "VERTICAL_FOLLOW_MATCHES_CAMERA ") + ) + (if (= (logand (cam-slave-options HAVE_BUTT_HANDLE) arg0) (cam-slave-options HAVE_BUTT_HANDLE)) + (format arg1 "HAVE_BUTT_HANDLE ") + ) + (the-as string arg1) + ) + +;; WARN: Return type mismatch object vs string. +(defun cam-index-options->string ((arg0 cam-index-options) (arg1 object)) + (if (= (logand arg0 (cam-index-options RADIAL)) (cam-index-options RADIAL)) + (format arg1 "RADIAL ") + ) + (if (= (logand arg0 (cam-index-options SPHERICAL)) (cam-index-options SPHERICAL)) + (format arg1 "SPHERICAL ") + ) + (the-as string arg1) + ) + +(defun slave-los-state->string ((arg0 slave-los-state)) + (case arg0 + (((slave-los-state between)) + "between" + ) + (((slave-los-state none)) + "none" + ) + (((slave-los-state cw)) + "cw" + ) + (((slave-los-state ccw)) + "ccw" + ) + (else + "*unknown*" + ) + ) + ) + +(defun cam-line-dma () + (with-dma-buffer-add-bucket ((v1-5 (-> *display* frames (-> *display* on-screen) debug-buf)) + (bucket-id debug-no-zbuf1) + ) + (let ((a0-1 (the-as object (-> v1-5 base)))) + (let* ((a1-0 v1-5) + (a3-0 (the-as object (-> a1-0 base))) + ) + (set! (-> (the-as dma-packet a3-0) dma) (new 'static 'dma-tag :id (dma-tag-id cnt))) + (set! (-> (the-as dma-packet a3-0) vif0) (new 'static 'vif-tag)) + (set! (-> (the-as dma-packet a3-0) vif1) (new 'static 'vif-tag :cmd (vif-cmd direct) :msk #x1)) + (set! (-> a1-0 base) (&+ (the-as pointer a3-0) 16)) + ) + (let* ((a1-1 v1-5) + (a3-2 (the-as object (-> a1-1 base))) + ) + (set! (-> (the-as gs-gif-tag a3-2) tag) + (new 'static 'gif-tag64 + :nloop #x1 + :eop #x1 + :pre #x1 + :prim (new 'static 'gs-prim :prim (gs-prim-type line) :iip #x1 :abe #x1) + :nreg #x4 + ) + ) + (set! (-> (the-as gs-gif-tag a3-2) regs) (new 'static 'gif-tag-regs + :regs0 (gif-reg-id rgbaq) + :regs1 (gif-reg-id xyzf2) + :regs2 (gif-reg-id rgbaq) + :regs3 (gif-reg-id xyzf2) + ) + ) + (set! (-> a1-1 base) (&+ (the-as pointer a3-2) 16)) + ) + (let* ((a1-2 v1-5) + (a3-4 (-> a1-2 base)) + ) + ;; og:preserve-this + (set! (-> (the-as (pointer uint128) a3-4) 0) (-> (the-as vector (+ 32 (scratchpad-object int))) quad)) + (set! (-> (the-as (pointer uint128) a3-4) 1) (-> (the-as vector (+ (scratchpad-object int) 0)) quad)) + (set! (-> a1-2 base) (&+ a3-4 32)) + ) + (let* ((a3-6 v1-5) + (a1-3 (-> a3-6 base)) + ) + ;; og:preserve-this + (set! (-> (the-as (pointer uint128) a1-3) 0) (-> (the-as vector (+ 32 (scratchpad-object int))) quad)) + (set! (-> (the-as (pointer uint128) a1-3) 1) (-> (the-as vector (+ 16 (scratchpad-object int))) quad)) + (set! (-> a3-6 base) (&+ a1-3 32)) + ) + (let ((a3-10 (/ (the-as int (+ (- -16 (the-as int a0-1)) (the-as int (-> v1-5 base)))) 16))) + (cond + ((nonzero? a3-10) + (logior! (-> (the-as dma-packet a0-1) dma) (shr (shl a3-10 48) 48)) + (logior! (-> (the-as (pointer uint64) a0-1) 1) (shl (shr (shl a3-10 48) 48) 32)) + ) + (else + (set! (-> v1-5 base) (the-as (pointer uint64) a0-1)) + ) + ) + ) + ) + ) + ) + +(defun camera-line2d ((arg0 vector4w) (arg1 vector4w)) + ;; og:preserve-this + (set! (-> (scratchpad-object cam-dbg-scratch) linevec4w 0 x) (* (+ (-> arg0 x) 1792) 16)) + (set! (-> (scratchpad-object cam-dbg-scratch) linevec4w 0 y) + (* (- 2256 (-> (the-as cam-dbg-scratch arg0) linevec4w 0 y)) 16) + ) + (set! (-> (scratchpad-object cam-dbg-scratch) linevec4w 0 z) #x7fffff) + (set! (-> (scratchpad-object cam-dbg-scratch) linevec4w 1 x) + (* (+ (-> (the-as cam-dbg-scratch arg1) linevec4w 0 x) 1792) 16) + ) + (set! (-> (scratchpad-object cam-dbg-scratch) linevec4w 1 y) + (* (- 2256 (-> (the-as cam-dbg-scratch arg1) linevec4w 0 y)) 16) + ) + (set! (-> (scratchpad-object cam-dbg-scratch) linevec4w 1 z) #x7fffff) + (cam-line-dma) + ) + +(defun camera-plot-float-func ((arg0 float) (arg1 float) (arg2 float) (arg3 float) (arg4 (function float float)) (arg5 vector4w)) + (let ((f30-0 (- arg1 arg0)) + (f24-0 (- arg3 arg2)) + ) + 0.0 + 0.0 + (let ((f28-0 (/ 200.0 f24-0)) + (f26-0 (/ 400.0 f30-0)) + ) + ;; og:preserve-this + (set! (-> (scratchpad-object cam-dbg-scratch) color x) 128) + (set! (-> (scratchpad-object cam-dbg-scratch) color y) 128) + (set! (-> (scratchpad-object cam-dbg-scratch) color z) 128) + (set! (-> (scratchpad-object cam-dbg-scratch) color w) 128) + (when (and (< arg0 0.0) (< 0.0 arg1)) + (set! (-> (scratchpad-object cam-dbg-scratch) plotvec 0 x) + (+ (the int (* f26-0 f30-0 (/ (- arg0) f30-0))) 20) + ) + ;; og:preserve-this + (set! (-> (scratchpad-object cam-dbg-scratch) plotvec 0 y) 20) + (set! (-> (scratchpad-object cam-dbg-scratch) plotvec 1 x) + (-> (scratchpad-object cam-dbg-scratch) plotvec 0 x) + ) + (set! (-> (scratchpad-object cam-dbg-scratch) plotvec 1 y) (+ (the int (* f28-0 f24-0)) 20)) + (camera-line2d (-> (scratchpad-object cam-dbg-scratch) plotvec 0) (the-as vector4w (+ 64 (scratchpad-object int)))) + ) + (when (and (< arg2 0.0) (< 0.0 arg3)) + ;; og:preserve-this + (set! (-> (scratchpad-object cam-dbg-scratch) plotvec 0 x) 20) + (set! (-> (scratchpad-object cam-dbg-scratch) plotvec 0 y) + (+ (the int (* f28-0 f24-0 (/ (- arg2) f24-0))) 20) + ) + (set! (-> (scratchpad-object cam-dbg-scratch) plotvec 1 x) (+ (the int (* f26-0 f30-0)) 20)) + (set! (-> (scratchpad-object cam-dbg-scratch) plotvec 1 y) + (-> (scratchpad-object cam-dbg-scratch) plotvec 0 y) + ) + ;; og:preserve-this + (camera-line2d + (-> (scratchpad-object cam-dbg-scratch) plotvec 0) + (-> (scratchpad-object cam-dbg-scratch) plotvec 1) + ) + ) + ;; og:preserve-this + (set! (-> (scratchpad-object cam-dbg-scratch) plotvec 0 x) 20) + (set! (-> (scratchpad-object cam-dbg-scratch) plotvec 0 y) 20) + (set! (-> (scratchpad-object cam-dbg-scratch) plotvec 1 x) (+ (the int (* f26-0 f30-0)) 20)) + (set! (-> (scratchpad-object cam-dbg-scratch) plotvec 1 y) 20) + (camera-line2d + (-> (scratchpad-object cam-dbg-scratch) plotvec 0) + (-> (scratchpad-object cam-dbg-scratch) plotvec 1) + ) + ;; og:preserve-this + (set! (-> (scratchpad-object cam-dbg-scratch) plotvec 0 x) 20) + (set! (-> (scratchpad-object cam-dbg-scratch) plotvec 0 y) (+ (the int (* f28-0 f24-0)) 20)) + (set! (-> (scratchpad-object cam-dbg-scratch) plotvec 1 x) (+ (the int (* f26-0 f30-0)) 20)) + (set! (-> (scratchpad-object cam-dbg-scratch) plotvec 1 y) (+ (the int (* f28-0 f24-0)) 20)) + (camera-line2d + (-> (scratchpad-object cam-dbg-scratch) plotvec 0) + (-> (scratchpad-object cam-dbg-scratch) plotvec 1) + ) + ;; og:preserve-this + (set! (-> (scratchpad-object cam-dbg-scratch) plotvec 0 x) 20) + (set! (-> (scratchpad-object cam-dbg-scratch) plotvec 0 y) 20) + (set! (-> (scratchpad-object cam-dbg-scratch) plotvec 1 x) 20) + (set! (-> (scratchpad-object cam-dbg-scratch) plotvec 1 y) (+ (the int (* f28-0 f24-0)) 20)) + (camera-line2d + (-> (scratchpad-object cam-dbg-scratch) plotvec 0) + (-> (scratchpad-object cam-dbg-scratch) plotvec 1) + ) + ;; og:preserve-this + (set! (-> (scratchpad-object cam-dbg-scratch) plotvec 0 x) (+ (the int (* f26-0 f30-0)) 20)) + (set! (-> (scratchpad-object cam-dbg-scratch) plotvec 0 y) 20) + (set! (-> (scratchpad-object cam-dbg-scratch) plotvec 1 x) (+ (the int (* f26-0 f30-0)) 20)) + (set! (-> (scratchpad-object cam-dbg-scratch) plotvec 1 y) (+ (the int (* f28-0 f24-0)) 20)) + (camera-line2d + (-> (scratchpad-object cam-dbg-scratch) plotvec 0) + (-> (scratchpad-object cam-dbg-scratch) plotvec 1) + ) + (let ((v1-64 (-> arg5 quad))) + (set! (-> (scratchpad-object cam-dbg-scratch) color quad) v1-64) + ) + ;; og:preserve-this + (set! (-> (scratchpad-object cam-dbg-scratch) plotvec 1 x) 20) + (set! (-> (scratchpad-object cam-dbg-scratch) plotvec 1 y) (+ (the int (* f28-0 (- (arg4 arg0) arg2))) 20)) + (let ((s3-1 1)) + (while (>= (the int (* f26-0 f30-0)) s3-1) + (let ((v1-69 (-> (scratchpad-object cam-dbg-scratch) plotvec 1 quad))) + (set! (-> (scratchpad-object cam-dbg-scratch) plotvec 0 quad) v1-69) + ) + (set! (-> (scratchpad-object cam-dbg-scratch) plotvec 1 x) (+ s3-1 20)) + (set! (-> (scratchpad-object cam-dbg-scratch) plotvec 1 y) + (+ (the int (* f28-0 (- (arg4 (+ arg0 (* f30-0 (/ (the float s3-1) (* f26-0 f30-0))))) arg2))) 20) + ) + (camera-line2d + (-> (scratchpad-object cam-dbg-scratch) plotvec 0) + (-> (scratchpad-object cam-dbg-scratch) plotvec 1) + ) + (+! s3-1 1) + ) + ) + ) + ) + 0 + (none) + ) + +(defun camera-line-setup ((arg0 vector4w)) + (let ((v1-0 (-> arg0 quad))) + (set! (-> (scratchpad-object cam-dbg-scratch) color quad) v1-0) + ) + (init-for-transform *identity-matrix*) + 0 + (none) + ) + +;; WARN: Function camera-line-draw has a return type of none, but the expression builder found a return statement. +(defun camera-line-draw ((arg0 vector) (arg1 vector)) + ;; og:preserve-this + (set! (-> (scratchpad-object cam-dbg-scratch) linevec 0 quad) (-> arg0 quad)) + (set! (-> (scratchpad-object cam-dbg-scratch) linevec 1 quad) (-> arg1 quad)) + (set! (-> (scratchpad-object cam-dbg-scratch) linevec 0 w) (the-as int 1.0)) + (set! (-> (scratchpad-object cam-dbg-scratch) linevec 1 w) (the-as int 1.0)) + (transform-float-point + (the-as vector (-> (scratchpad-object cam-dbg-scratch) linevec)) + (-> (scratchpad-object cam-dbg-scratch) linevec4w 0) + ) + (transform-float-point + (the-as vector (-> (scratchpad-object cam-dbg-scratch) linevec 1)) + (-> (scratchpad-object cam-dbg-scratch) linevec4w 1) + ) + (cond + ((< (the-as uint #xe00000) (the-as uint (-> (scratchpad-object cam-dbg-scratch) linevec4w 0 z))) + (return #f) + ) + ((< (the-as uint #xe00000) (the-as uint (-> (scratchpad-object cam-dbg-scratch) linevec4w 1 z))) + (return #f) + ) + ) + (cam-line-dma) + 0 + (none) + ) + +(defun camera-line ((arg0 vector) (arg1 vector) (arg2 vector4w)) + (camera-line-setup arg2) + (camera-line-draw arg0 arg1) + 0 + (none) + ) + +(defun camera-line-rel ((arg0 vector) (arg1 vector) (arg2 vector4w)) + ;; og:preserve-this + (vector+! (-> (scratchpad-object cam-dbg-scratch) rel-vec) arg0 arg1) + (camera-line arg0 (-> (scratchpad-object cam-dbg-scratch) rel-vec) arg2) + (none) + ) + +(defun camera-line-rel-len ((arg0 vector) (arg1 vector) (arg2 float) (arg3 vector4w)) + (vector-normalize-copy! (-> (scratchpad-object cam-dbg-scratch) rel-vec) arg1 arg2) + (vector+! + ;; og:preserve-this + (-> (scratchpad-object cam-dbg-scratch) rel-vec) + (-> (scratchpad-object cam-dbg-scratch) rel-vec) + arg0 + ) + (camera-line arg0 (-> (scratchpad-object cam-dbg-scratch) rel-vec) arg3) + (none) + ) + +(defun camera-sphere ((arg0 vector) (arg1 float) (arg2 vector4w)) + (camera-line-setup arg2) + (dotimes (s4-0 10) + (let ((f30-1 (* arg1 (sin (* 3276.8 (the float s4-0))))) + (f28-1 (* arg1 (sin (* 3276.8 (the float (+ s4-0 1)))))) + ) + ;; og:preserve-this + (set! (-> (scratchpad-object cam-dbg-scratch) sphere-v-start y) + (+ (-> arg0 y) (* (cos (* 3276.8 (the float s4-0))) arg1)) + ) + (set! (-> (scratchpad-object cam-dbg-scratch) sphere-v-end y) + (-> (scratchpad-object cam-dbg-scratch) sphere-v-start y) + ) + (set! (-> (scratchpad-object cam-dbg-scratch) sphere-v-down y) + (+ (-> arg0 y) (* (cos (* 3276.8 (the float (+ s4-0 1)))) arg1)) + ) + (dotimes (s3-0 10) + ;; og:preserve-this + (set! (-> (scratchpad-object cam-dbg-scratch) sphere-v-start x) + (+ (-> arg0 x) (* (cos (* 6553.6 (the float s3-0))) f30-1)) + ) + (set! (-> (scratchpad-object cam-dbg-scratch) sphere-v-start z) + (+ (-> arg0 z) (* (sin (* 6553.6 (the float s3-0))) f30-1)) + ) + (set! (-> (scratchpad-object cam-dbg-scratch) sphere-v-end x) + (+ (-> arg0 x) (* (cos (* 6553.6 (the float (+ s3-0 1)))) f30-1)) + ) + (set! (-> (scratchpad-object cam-dbg-scratch) sphere-v-end z) + (+ (-> arg0 z) (* (sin (* 6553.6 (the float (+ s3-0 1)))) f30-1)) + ) + (set! (-> (scratchpad-object cam-dbg-scratch) sphere-v-down x) + (+ (-> arg0 x) (* (cos (* 6553.6 (the float s3-0))) f28-1)) + ) + (set! (-> (scratchpad-object cam-dbg-scratch) sphere-v-down z) + (+ (-> arg0 z) (* (sin (* 6553.6 (the float s3-0))) f28-1)) + ) + ;; og:preserve-this + (camera-line-draw + (-> (scratchpad-object cam-dbg-scratch) sphere-v-start) + (-> (scratchpad-object cam-dbg-scratch) sphere-v-end) + ) + (camera-line-draw + (-> (scratchpad-object cam-dbg-scratch) sphere-v-start) + (-> (scratchpad-object cam-dbg-scratch) sphere-v-down) + ) + ) + ) + ) + 0 + (none) + ) + +(defun camera-cross ((arg0 vector) (arg1 vector) (arg2 vector) (arg3 vector4w) (arg4 meters)) + ;; og:preserve-this + (vector-normalize-copy! (-> (scratchpad-object cam-dbg-scratch) crossvec 0) arg0 arg4) + (vector+! + (-> (scratchpad-object cam-dbg-scratch) crossvec 1) + arg2 + (-> (scratchpad-object cam-dbg-scratch) crossvec 0) + ) + (vector-! + (-> (scratchpad-object cam-dbg-scratch) crossvec 2) + arg2 + (-> (scratchpad-object cam-dbg-scratch) crossvec 0) + ) + (camera-line + (-> (scratchpad-object cam-dbg-scratch) crossvec 1) + (-> (scratchpad-object cam-dbg-scratch) crossvec 2) + arg3 + ) + (vector-cross! + (-> (scratchpad-object cam-dbg-scratch) crossvec 0) + (-> (scratchpad-object cam-dbg-scratch) crossvec 0) + arg1 + ) + ;; og:preserve-this + (vector-normalize! (-> (scratchpad-object cam-dbg-scratch) crossvec 0) arg4) + (vector+! + (-> (scratchpad-object cam-dbg-scratch) crossvec 1) + arg2 + (-> (scratchpad-object cam-dbg-scratch) crossvec 0) + ) + (vector-! + (-> (scratchpad-object cam-dbg-scratch) crossvec 2) + arg2 + (-> (scratchpad-object cam-dbg-scratch) crossvec 0) + ) + (camera-line + (-> (scratchpad-object cam-dbg-scratch) crossvec 1) + (-> (scratchpad-object cam-dbg-scratch) crossvec 2) + arg3 + ) + (vector-cross! + (-> (scratchpad-object cam-dbg-scratch) crossvec 0) + (-> (scratchpad-object cam-dbg-scratch) crossvec 0) + arg0 + ) + ;; og:preserve-this + (vector-normalize! (-> (scratchpad-object cam-dbg-scratch) crossvec 0) arg4) + (vector+! + (-> (scratchpad-object cam-dbg-scratch) crossvec 1) + arg2 + (-> (scratchpad-object cam-dbg-scratch) crossvec 0) + ) + (vector-! + (-> (scratchpad-object cam-dbg-scratch) crossvec 2) + arg2 + (-> (scratchpad-object cam-dbg-scratch) crossvec 0) + ) + (camera-line + (-> (scratchpad-object cam-dbg-scratch) crossvec 1) + (-> (scratchpad-object cam-dbg-scratch) crossvec 2) + arg3 + ) + (none) + ) + +(defun camera-bounding-box-draw ((arg0 bounding-box) (arg1 basic) (arg2 rgba)) + (camera-line-setup (new 'static 'vector4w :x #x7f :y #x7f :z #x7f :w #x80)) + ;; og:preserve-this + (set! (-> (scratchpad-object cam-dbg-scratch) bboxvec 0 quad) (-> arg0 min quad)) + (set! (-> (scratchpad-object cam-dbg-scratch) bboxvec 0 x) (-> arg0 max x)) + (vector-copy! (-> (scratchpad-object cam-dbg-scratch) bboxvec 1) (-> arg0 min)) + (set! (-> (scratchpad-object cam-dbg-scratch) bboxvec 1 y) (-> arg0 max y)) + (vector-copy! (-> (scratchpad-object cam-dbg-scratch) bboxvec 2) (-> arg0 min)) + (set! (-> (scratchpad-object cam-dbg-scratch) bboxvec 2 z) (-> arg0 max z)) + (vector-copy! (-> (scratchpad-object cam-dbg-scratch) bboxvec 3) (-> arg0 max)) + (set! (-> (scratchpad-object cam-dbg-scratch) bboxvec 3 x) (-> arg0 min x)) + (vector-copy! (-> (scratchpad-object cam-dbg-scratch) bboxvec 4) (-> arg0 max)) + (set! (-> (scratchpad-object cam-dbg-scratch) bboxvec 4 y) (-> arg0 min y)) + (vector-copy! (-> (scratchpad-object cam-dbg-scratch) bboxvec 5) (-> arg0 max)) + (set! (-> (scratchpad-object cam-dbg-scratch) bboxvec 5 z) (-> arg0 min z)) + ;; og:preserve-this + (camera-line-draw (-> arg0 min) (-> (scratchpad-object cam-dbg-scratch) bboxvec 0)) + (camera-line-draw (-> arg0 min) (-> (scratchpad-object cam-dbg-scratch) bboxvec 1)) + (camera-line-draw (-> arg0 min) (-> (scratchpad-object cam-dbg-scratch) bboxvec 2)) + (camera-line-draw (-> arg0 max) (-> (scratchpad-object cam-dbg-scratch) bboxvec 3)) + (camera-line-draw (-> arg0 max) (-> (scratchpad-object cam-dbg-scratch) bboxvec 4)) + (camera-line-draw (-> arg0 max) (-> (scratchpad-object cam-dbg-scratch) bboxvec 5)) + (camera-line-draw + (-> (scratchpad-object cam-dbg-scratch) bboxvec 0) + (-> (scratchpad-object cam-dbg-scratch) bboxvec 4) + ) + ;; og:preserve-this + (camera-line-draw + (-> (scratchpad-object cam-dbg-scratch) bboxvec 4) + (-> (scratchpad-object cam-dbg-scratch) bboxvec 2) + ) + (camera-line-draw + (-> (scratchpad-object cam-dbg-scratch) bboxvec 2) + (-> (scratchpad-object cam-dbg-scratch) bboxvec 3) + ) + (camera-line-draw + (-> (scratchpad-object cam-dbg-scratch) bboxvec 3) + (-> (scratchpad-object cam-dbg-scratch) bboxvec 1) + ) + (camera-line-draw + (-> (scratchpad-object cam-dbg-scratch) bboxvec 1) + (-> (scratchpad-object cam-dbg-scratch) bboxvec 5) + ) + (camera-line-draw + (-> (scratchpad-object cam-dbg-scratch) bboxvec 5) + (-> (scratchpad-object cam-dbg-scratch) bboxvec 0) + ) + 0 + (none) + ) + +(deftype cam-debug-tri (structure) + ((vertex vector 3 :inline) + (intersect vector :inline) + (color vector4w) + ) + ) + + +(define *cam-debug-los-tri-current* 0) + +(define *cam-debug-los-tri* (the-as (inline-array cam-debug-tri) (malloc 'debug #x8fc0))) + +(define *cam-debug-coll-tri-current* 0) + +(define *cam-debug-coll-tri* (the-as (inline-array cam-debug-tri) (malloc 'debug #x8fc0))) + +(defun cam-debug-reset-coll-tri () + (set! *cam-debug-los-tri-current* 0) + (set! *cam-debug-coll-tri-current* 0) + 0 (none) ) (defun cam-debug-add-los-tri ((arg0 (inline-array collide-cache-tri)) (arg1 vector) (arg2 vector)) + (cond + ((>= *cam-debug-los-tri-current* 460) + ) + (else + (let ((v1-3 (-> *cam-debug-los-tri* *cam-debug-los-tri-current*))) + (set! (-> v1-3 vertex 0 quad) (-> arg0 0 vertex 0 quad)) + (vector-copy! (-> v1-3 vertex 1) (-> arg0 0 vertex 1)) + (vector-copy! (-> v1-3 vertex 2) (-> arg0 0 vertex 2)) + (vector-copy! (-> v1-3 intersect) arg1) + (set! (-> v1-3 color) (the-as vector4w arg2)) + ) + (set! *cam-debug-los-tri-current* (+ *cam-debug-los-tri-current* 1)) + (if (= *cam-debug-los-tri-current* 460) + (format 0 "ERROR : cam-debug-add-los-tri overflow~%") + ) + ) + ) + 0 (none) ) -(defun cam-debug-reset-coll-tri () +(defun cam-debug-add-coll-tri ((arg0 cam-debug-tri) (arg1 vector) (arg2 cam-debug-tri)) + (cond + ((>= *cam-debug-coll-tri-current* 460) + ) + (else + (let ((v1-3 (-> *cam-debug-coll-tri* *cam-debug-coll-tri-current*))) + (set! (-> v1-3 vertex 0 quad) (-> arg0 vertex 0 quad)) + (vector-copy! (-> v1-3 vertex 1) (-> arg0 vertex 1)) + (vector-copy! (-> v1-3 vertex 2) (-> arg0 vertex 2)) + (vector-copy! (-> v1-3 intersect) arg1) + (set! (-> v1-3 color) (the-as vector4w arg2)) + ) + (set! *cam-debug-coll-tri-current* (+ *cam-debug-coll-tri-current* 1)) + (if (>= *cam-debug-coll-tri-current* 460) + (format 0 "ERROR : cam-debug-add-coll-tri overflow~%") + ) + ) + ) + 0 (none) - ) \ No newline at end of file + ) + +(defun cam-debug-draw-tris () + (camera-line-setup (new 'stack 'vector4w)) + (when *display-cam-los-marks* + (dotimes (gp-1 *cam-debug-los-tri-current*) + ;; og:preserve-this + (let ((v1-7 (-> *cam-debug-los-tri* gp-1 color quad))) + (set! (-> (scratchpad-object cam-dbg-scratch) color quad) v1-7) + ) + (camera-line-draw + (the-as vector (+ (the-as uint (-> *cam-debug-los-tri* 0)) (* 80 gp-1))) + (the-as vector (+ (the-as uint (-> *cam-debug-los-tri* 0 vertex 1)) (* 80 gp-1))) + ) + (camera-line-draw + (the-as vector (+ (the-as uint (-> *cam-debug-los-tri* 0 vertex 1)) (* 80 gp-1))) + (the-as vector (+ (the-as uint (-> *cam-debug-los-tri* 0 vertex 2)) (* 80 gp-1))) + ) + (camera-line-draw + (the-as vector (+ (the-as uint (-> *cam-debug-los-tri* 0 vertex 2)) (* 80 gp-1))) + (the-as vector (+ (the-as uint (-> *cam-debug-los-tri* 0)) (* 80 gp-1))) + ) + (camera-cross + (new 'static 'vector :y 1024.0) + (new 'static 'vector :z 1024.0) + (-> *cam-debug-los-tri* gp-1 intersect) + (-> *cam-debug-los-tri* gp-1 color) + (meters 0.25) + ) + ) + ) + (when *display-cam-coll-marks* + (dotimes (gp-2 *cam-debug-coll-tri-current*) + ;; og:preserve-this + (let ((v1-34 (-> *cam-debug-coll-tri* gp-2 color quad))) + (set! (-> (scratchpad-object cam-dbg-scratch) color quad) v1-34) + ) + (camera-line-draw + (the-as vector (+ (the-as uint (-> *cam-debug-coll-tri* 0)) (* 80 gp-2))) + (the-as vector (+ (the-as uint (-> *cam-debug-coll-tri* 0 vertex 1)) (* 80 gp-2))) + ) + (camera-line-draw + (the-as vector (+ (the-as uint (-> *cam-debug-coll-tri* 0 vertex 1)) (* 80 gp-2))) + (the-as vector (+ (the-as uint (-> *cam-debug-coll-tri* 0 vertex 2)) (* 80 gp-2))) + ) + (camera-line-draw + (the-as vector (+ (the-as uint (-> *cam-debug-coll-tri* 0 vertex 2)) (* 80 gp-2))) + (the-as vector (+ (the-as uint (-> *cam-debug-coll-tri* 0)) (* 80 gp-2))) + ) + (camera-cross + (new 'static 'vector :y 1024.0) + (new 'static 'vector :z 1024.0) + (-> *cam-debug-coll-tri* gp-2 intersect) + (-> *cam-debug-coll-tri* gp-2 color) + (meters 0.25) + ) + ) + #f + ) + ) + +(defun camera-fov-draw ((arg0 int) (arg1 int) (arg2 vector) (arg3 float) (arg4 float) (arg5 vector4w)) + ;; og:preserve-this + (vector+float*! (-> (scratchpad-object cam-dbg-scratch) fov-vv 0) arg2 (the-as vector arg1) arg3) + (vector+float*! (the-as vector (the-as (pointer vector) (+ 352 (scratchpad-object int)))) arg2 (the-as vector arg0) arg3) + (vector+float*! (the-as vector (+ 368 (scratchpad-object int))) arg2 (the-as vector arg0) arg4) + (vector+float*! (the-as vector (+ 384 (scratchpad-object int))) arg2 (the-as vector arg1) arg4) + (camera-line-setup arg5) + (camera-line-draw (the-as vector (+ 336 (scratchpad-object int))) (the-as vector (+ 352 (scratchpad-object int)))) + ;; og:preserve-this + (camera-line-draw + (the-as vector (&+ (the-as (pointer vector) 352) (scratchpad-object int))) + (the-as vector (+ 368 (scratchpad-object int))) + ) + (camera-line-draw (the-as vector (+ 368 (scratchpad-object int))) (the-as vector (+ 384 (scratchpad-object int)))) + (none) + ) + +;; WARN: Return type mismatch none vs symbol. +(defun camera-fov-frame ((arg0 matrix) (arg1 vector) (arg2 float) (arg3 float) (arg4 float) (arg5 vector4w)) + ;; og:preserve-this + (vector-float*! (-> (scratchpad-object cam-dbg-scratch) fov-vert) (-> arg0 uvec) (* arg3 (tan arg2))) + (vector-float*! (-> (scratchpad-object cam-dbg-scratch) fov-horz) (-> arg0 rvec) (* arg4 (tan arg2))) + (vector+! + (-> (scratchpad-object cam-dbg-scratch) fov-src) + (-> arg0 fvec) + (vector+! + (-> (scratchpad-object cam-dbg-scratch) fov-src) + (-> (scratchpad-object cam-dbg-scratch) fov-vert) + (-> (scratchpad-object cam-dbg-scratch) fov-horz) + ) + ) + ;; og:preserve-this + (vector-normalize! (-> (scratchpad-object cam-dbg-scratch) fov-src) 1.0) + (vector+! + (-> (scratchpad-object cam-dbg-scratch) fov-dest) + (-> arg0 fvec) + (vector-! + (-> (scratchpad-object cam-dbg-scratch) fov-dest) + (-> (scratchpad-object cam-dbg-scratch) fov-vert) + (-> (scratchpad-object cam-dbg-scratch) fov-horz) + ) + ) + ;; og:preserve-this + (vector-normalize! (-> (scratchpad-object cam-dbg-scratch) fov-dest) 1.0) + (camera-fov-draw + (the-as int (-> (scratchpad-object cam-dbg-scratch) fov-src)) + (the-as int (-> (scratchpad-object cam-dbg-scratch) fov-dest)) + arg1 + 4096.0 + 20480.0 + arg5 + ) + (vector-copy! + (-> (scratchpad-object cam-dbg-scratch) fov-src) + (the-as vector4w (-> (scratchpad-object cam-dbg-scratch) fov-dest)) + ) + ;; og:preserve-this + (vector-! + (-> (scratchpad-object cam-dbg-scratch) fov-dest) + (-> arg0 fvec) + (vector+! + (-> (scratchpad-object cam-dbg-scratch) fov-dest) + (-> (scratchpad-object cam-dbg-scratch) fov-vert) + (-> (scratchpad-object cam-dbg-scratch) fov-horz) + ) + ) + ;; og:preserve-this + (vector-normalize! (-> (scratchpad-object cam-dbg-scratch) fov-dest) 1.0) + (camera-fov-draw + (the-as int (-> (scratchpad-object cam-dbg-scratch) fov-src)) + (the-as int (-> (scratchpad-object cam-dbg-scratch) fov-dest)) + arg1 + 4096.0 + 20480.0 + arg5 + ) + (vector-copy! + (-> (scratchpad-object cam-dbg-scratch) fov-src) + (the-as vector4w (-> (scratchpad-object cam-dbg-scratch) fov-dest)) + ) + ;; og:preserve-this + (vector-! + (-> (scratchpad-object cam-dbg-scratch) fov-dest) + (-> arg0 fvec) + (vector-! + (-> (scratchpad-object cam-dbg-scratch) fov-dest) + (-> (scratchpad-object cam-dbg-scratch) fov-vert) + (-> (scratchpad-object cam-dbg-scratch) fov-horz) + ) + ) + (vector-normalize! (-> (scratchpad-object cam-dbg-scratch) fov-dest) 1.0) + (camera-fov-draw + (the-as int (-> (scratchpad-object cam-dbg-scratch) fov-src)) + (the-as int (-> (scratchpad-object cam-dbg-scratch) fov-dest)) + arg1 + 4096.0 + 20480.0 + arg5 + ) + ;; og:preserve-this + (vector-copy! + (-> (scratchpad-object cam-dbg-scratch) fov-src) + (the-as vector4w (-> (scratchpad-object cam-dbg-scratch) fov-dest)) + ) + (vector+! + (-> (scratchpad-object cam-dbg-scratch) fov-dest) + (-> arg0 fvec) + (vector+! + (-> (scratchpad-object cam-dbg-scratch) fov-dest) + (-> (scratchpad-object cam-dbg-scratch) fov-vert) + (-> (scratchpad-object cam-dbg-scratch) fov-horz) + ) + ) + ;; og:preserve-this + (vector-normalize! (-> (scratchpad-object cam-dbg-scratch) fov-dest) 1.0) + (the-as symbol (camera-fov-draw + (the-as int (-> (scratchpad-object cam-dbg-scratch) fov-src)) + (the-as int (-> (scratchpad-object cam-dbg-scratch) fov-dest)) + arg1 + 4096.0 + 20480.0 + arg5 + ) + ) + ) + +(defmethod debug-point-info ((this tracking-spline) (arg0 int)) + (if (= arg0 (-> this used-point)) + (format 0 "u") + (format 0 " ") + ) + (if (= arg0 (-> this next-to-last-point)) + (format 0 "n") + (format 0 " ") + ) + (if (= arg0 (-> this end-point)) + (format 0 "e") + (format 0 " ") + ) + (if (= arg0 -134250495) + (format 0 " ~D~%" arg0) + (format + 0 + " ~D ~M ~M ~M~%" + arg0 + (-> this point arg0 position x) + (-> this point arg0 position y) + (-> this point arg0 position z) + ) + ) + 0 + (none) + ) + +(defmethod debug-all-points ((this tracking-spline)) + (let ((s5-0 (-> this used-point))) + (while (!= s5-0 -134250495) + (debug-point-info this s5-0) + (set! s5-0 (-> this point s5-0 next)) + ) + (debug-point-info this s5-0) + ) + 0 + (none) + ) + +(defmethod debug-draw-spline ((this tracking-spline)) + (let ((s5-0 (-> this used-point))) + (let ((s4-0 (-> this point (-> this used-point) next))) + (let ((s3-0 (new 'stack-no-clear 'vector)) + (s2-0 (new 'stack-no-clear 'vector)) + ) + (when (!= s4-0 -134250495) + (tracking-spline-method-19 this 0.0 s3-0 s2-0 (the-as tracking-spline-sampler #f)) + (camera-cross + (new 'static 'vector :y 1024.0) + (new 'static 'vector :z 1024.0) + s3-0 + (new 'static 'vector4w :x #xff :w #x80) + (meters 0.25) + ) + (tracking-spline-method-19 this (-> this sample-len) s3-0 s2-0 (the-as tracking-spline-sampler #f)) + (camera-cross + (new 'static 'vector :y 1024.0) + (new 'static 'vector :z 1024.0) + s3-0 + (new 'static 'vector4w :x #xff :w #x80) + (meters 0.25) + ) + ) + ) + (while (!= s4-0 -134250495) + (camera-line + (-> this point s5-0 position) + (-> this point s4-0 position) + (new 'static 'vector4w :x #x80 :y #x80 :z #x80 :w #x80) + ) + (set! s5-0 s4-0) + (set! s4-0 (-> this point s4-0 next)) + ) + ) + (if (!= s5-0 -134250495) + (camera-cross + (new 'static 'vector :y 1024.0) + (new 'static 'vector :z 1024.0) + (-> this point s5-0 position) + (new 'static 'vector4w :x #xff :w #x80) + (meters 0.25) + ) + ) + ) + (let ((s5-1 (new 'stack-no-clear 'vector))) + (camera-line + (-> this debug-out-position) + (-> this debug-old-position) + (new 'static 'vector4w :x #xff :y #xff :w #x80) + ) + (vector-! s5-1 (-> this debug-out-position) (-> this debug-old-position)) + (tracking-spline-method-20 this s5-1 (-> this debug-last-point)) + (camera-line-rel (-> this debug-old-position) s5-1 (new 'static 'vector4w :x #xff :z #xff :w #x80)) + ) + 0 + (none) + ) + +(defun debug-euler ((arg0 cam-dbg-scratch)) + (let ((s4-0 (new 'stack-no-clear 'euler-angles)) + (gp-0 (new 'stack-no-clear 'matrix)) + ) + (matrix->eul s4-0 (the-as matrix (&-> arg0 crossvec 0 w)) 21) + (format *stdcon* "euler angles x ~R y ~R z ~R~%" (-> s4-0 x) (-> s4-0 y) (-> s4-0 z)) + (format + *stdcon* + "~f ~f ~f ~f~%" + (-> arg0 crossvec 0 w) + (-> arg0 crossvec 1 x) + (-> arg0 crossvec 1 y) + (-> arg0 crossvec 1 z) + ) + (format + *stdcon* + "~f ~f ~f ~f~%" + (-> arg0 crossvec 1 w) + (-> arg0 crossvec 2 x) + (-> arg0 crossvec 2 y) + (-> arg0 crossvec 2 z) + ) + (format + *stdcon* + "~f ~f ~f ~f~%" + (-> arg0 crossvec 2 w) + (-> arg0 bboxvec 0 x) + (-> arg0 bboxvec 0 y) + (-> arg0 bboxvec 0 z) + ) + (format + *stdcon* + "~f ~f ~f ~f~%" + (-> arg0 bboxvec 0 w) + (-> arg0 bboxvec 1 x) + (-> arg0 bboxvec 1 y) + (-> arg0 bboxvec 1 z) + ) + (eul->matrix gp-0 s4-0) + (format *stdcon* "~f ~f ~f ~f~%" (-> gp-0 rvec x) (-> gp-0 rvec y) (-> gp-0 rvec z) (-> gp-0 rvec w)) + (format *stdcon* "~f ~f ~f ~f~%" (-> gp-0 uvec x) (-> gp-0 uvec y) (-> gp-0 uvec z) (-> gp-0 uvec w)) + (format *stdcon* "~f ~f ~f ~f~%" (-> gp-0 fvec x) (-> gp-0 fvec y) (-> gp-0 fvec z) (-> gp-0 fvec w)) + (format *stdcon* "~f ~f ~f ~f~%" (-> gp-0 trans x) (-> gp-0 trans y) (-> gp-0 trans z) (-> gp-0 trans w)) + (if (or (< 0.001 (fabs (- (-> arg0 crossvec 0 w) (-> gp-0 rvec x)))) + (< 0.001 (fabs (- (-> arg0 crossvec 1 x) (-> gp-0 rvec y)))) + (< 0.001 (fabs (- (-> arg0 crossvec 1 y) (-> gp-0 rvec z)))) + (< 0.001 (fabs (- (-> arg0 crossvec 1 z) (-> gp-0 rvec w)))) + (< 0.001 (fabs (- (-> arg0 crossvec 1 w) (-> gp-0 uvec x)))) + (< 0.001 (fabs (- (-> arg0 crossvec 2 x) (-> gp-0 uvec y)))) + (< 0.001 (fabs (- (-> arg0 crossvec 2 y) (-> gp-0 uvec z)))) + (< 0.001 (fabs (- (-> arg0 crossvec 2 z) (-> gp-0 uvec w)))) + (< 0.001 (fabs (- (-> arg0 crossvec 2 w) (-> gp-0 fvec x)))) + (< 0.001 (fabs (- (-> arg0 bboxvec 0 x) (-> gp-0 fvec y)))) + (< 0.001 (fabs (- (-> arg0 bboxvec 0 y) (-> gp-0 fvec z)))) + (< 0.001 (fabs (- (-> arg0 bboxvec 0 z) (-> gp-0 fvec w)))) + (< 0.001 (fabs (- (-> arg0 bboxvec 0 w) (-> gp-0 trans x)))) + (< 0.001 (fabs (- (-> arg0 bboxvec 1 x) (-> gp-0 trans y)))) + (< 0.001 (fabs (- (-> arg0 bboxvec 1 y) (-> gp-0 trans z)))) + (< 0.001 (fabs (- (-> arg0 bboxvec 1 z) (-> gp-0 trans w)))) + ) + (format *stdcon* "different~%") + (format *stdcon* "same~%") + ) + ) + ) + +(defun bike-cam-limit ((arg0 float)) + (let* ((f0-1 (* 10012.444 arg0)) + (f30-0 (fmax 0.0 f0-1)) + ) + (if (< f30-0 8192.0) + (* (/ 1.0 (- 1.0 (cos 21845.334))) (+ (- (cos 21845.334)) (cos (* 2.6666667 (- 8192.0 f30-0))))) + 1.0 + ) + ) + ) + +(defun camera-slave-debug ((arg0 camera-slave)) + (when *display-camera-marks* + (if (-> *setting-control* cam-current use-point-of-interest) + (camera-cross + (new 'static 'vector :y 1024.0) + (new 'static 'vector :z 1024.0) + (-> *setting-control* cam-current point-of-interest) + (new 'static 'vector4w :x #x80 :z #x80 :w #x80) + (meters 0.25) + ) + ) + (let ((f30-0 (/ (-> *camera-combiner* fov) 2))) + (camera-fov-frame + (-> *camera-combiner* inv-camera-rot) + (camera-pos) + f30-0 + 0.75 + 1.0 + (new 'static 'vector4w :z #xff :w #x80) + ) + ) + (cond + ((= (-> arg0 blend-to-type) (camera-blend-to-type unknown-2)) + (let ((f0-2 (/ (-> arg0 fov) 2))) + (camera-fov-frame + (-> *camera-combiner* tracking inv-mat) + (-> arg0 trans) + f0-2 + 0.75 + 1.0 + (new 'static 'vector4w :y #xff :w #x80) + ) + ) + ) + (else + (let ((f0-4 (/ (-> arg0 fov) 2))) + (camera-fov-frame + (-> arg0 tracking inv-mat) + (-> arg0 trans) + f0-4 + 0.75 + 1.0 + (new 'static 'vector4w :y #xff :w #x80) + ) + ) + ) + ) + (debug-draw-spline (-> arg0 position-spline)) + (let ((s5-1 (new-stack-vector0))) + (let ((s4-1 (new-stack-vector0))) + (new-stack-matrix0) + (cond + ((and (-> arg0 next-state) + (let ((v1-23 (-> arg0 next-state name))) + (or (= v1-23 'cam-fixed) (= v1-23 'cam-eye) (= v1-23 'cam-point-watch) (= v1-23 'cam-free-floating)) + ) + ) + (vector+float*! s5-1 (-> arg0 trans) (-> *camera* local-down) 4096.0) + (camera-line (-> arg0 trans) s5-1 (new 'static 'vector4w :x #xff :y #xff :z #xff :w #x80)) + ) + ((= (-> arg0 blend-to-type) (camera-blend-to-type unknown-2)) + (camera-line + (-> *camera-combiner* tracking follow-pt) + (-> arg0 trans) + (new 'static 'vector4w :x #xff :y #xff :z #xff :w #x80) + ) + (vector+float*! s5-1 (-> *camera-combiner* tracking follow-pt) (-> *camera* local-down) 4096.0) + (camera-line + (-> *camera-combiner* tracking follow-pt) + s5-1 + (new 'static 'vector4w :x #xff :y #xff :z #xff :w #x80) + ) + ) + (else + (camera-line + (-> arg0 tracking follow-pt) + (-> arg0 trans) + (new 'static 'vector4w :x #xff :y #xff :z #xff :w #x80) + ) + (vector+float*! s5-1 (-> arg0 tracking follow-pt) (-> *camera* local-down) 4096.0) + (camera-line (-> arg0 tracking follow-pt) s5-1 (new 'static 'vector4w :x #xff :y #xff :z #xff :w #x80)) + ) + ) + (vector-copy! s4-1 (-> arg0 trans)) + (cond + ((= (-> arg0 blend-to-type) (camera-blend-to-type unknown-2)) + (vector+float*! s5-1 s4-1 (the-as vector (-> *camera-combiner* tracking)) 2048.0) + (camera-line s4-1 s5-1 (new 'static 'vector4w :x #xff :w #x80)) + (vector+float*! s5-1 s4-1 (-> *camera-combiner* tracking inv-mat uvec) 2048.0) + (camera-line s4-1 s5-1 (new 'static 'vector4w :y #xff :w #x80)) + (vector+float*! s5-1 s4-1 (-> *camera-combiner* tracking inv-mat fvec) 2048.0) + (camera-line s4-1 s5-1 (new 'static 'vector4w :z #xff :w #x80)) + ) + (else + (vector+float*! s5-1 s4-1 (the-as vector (-> arg0 tracking)) 2048.0) + (camera-line s4-1 s5-1 (new 'static 'vector4w :x #xff :w #x80)) + (vector+float*! s5-1 s4-1 (-> arg0 tracking inv-mat uvec) 2048.0) + (camera-line s4-1 s5-1 (new 'static 'vector4w :y #xff :w #x80)) + (vector+float*! s5-1 s4-1 (-> arg0 tracking inv-mat fvec) 2048.0) + (camera-line s4-1 s5-1 (new 'static 'vector4w :z #xff :w #x80)) + ) + ) + ) + (vector--float*! + s5-1 + (-> *camera* tpos-curr) + (-> *camera* local-down) + (-> *setting-control* cam-current foot-offset) + ) + (camera-sphere s5-1 512.0 (new 'static 'vector4w :y #xff :w #x80)) + (vector--float*! + s5-1 + (-> *camera* tpos-curr) + (-> *camera* local-down) + (-> *setting-control* cam-current head-offset) + ) + (camera-sphere s5-1 512.0 (new 'static 'vector4w :y #xff :w #x80)) + ) + (cond + ((and (-> arg0 next-state) (= (-> arg0 next-state name) 'cam-string)) + (camera-sphere (-> arg0 desired-pos) 512.0 (new 'static 'vector4w :z #xff :w #x80)) + (camera-line-rel (-> *camera* tpos-curr-adj) (-> arg0 view-flat) (new 'static 'vector4w :z #xff :w #x80)) + (camera-line + (-> arg0 string-trans) + (the-as vector (+ (the-as uint (-> *camera* target-spline)) (* 48 (-> arg0 los-tgt-spline-pt)))) + (new 'static 'vector4w :y #xff :w #x80) + ) + (camera-line + (-> arg0 los-last-pos) + (the-as vector (+ (the-as uint (-> *camera* target-spline)) (* 48 (-> arg0 los-tgt-spline-pt)))) + (new 'static 'vector4w :x #xff :w #x80) + ) + ) + ((and (-> arg0 next-state) (= (-> arg0 next-state name) 'cam-circular)) + (let ((a1-45 (new-stack-vector0))) + (vector+float*! a1-45 (-> arg0 pivot-pt) (-> *camera* local-down) 4096.0) + (camera-line (-> arg0 pivot-pt) a1-45 (new 'static 'vector4w :x #xff :y #xff :z #xff :w #x80)) + ) + (camera-line (-> arg0 pivot-pt) (-> arg0 trans) (new 'static 'vector4w :x #xff :y #xff :z #xff :w #x80)) + ) + ((and (-> arg0 next-state) (= (-> arg0 next-state name) 'cam-spline)) + (let ((s5-2 (new 'stack 'curve)) + (s4-2 (res-lump-struct (-> arg0 cam-entity) 'spline-offset structure)) + ) + (if (not s4-2) + (set! s4-2 (new-stack-vector0)) + ) + (when (get-curve-data! (-> arg0 cam-entity) s5-2 'campath 'campath-k -1000000000.0) + (let ((s3-0 (new-stack-vector0)) + (s2-0 (new-stack-vector0)) + (gp-1 (res-lump-data (-> arg0 cam-entity) 'campoints pointer :time 1.0)) + ) + (curve-get-pos! s2-0 0.0 s5-2) + (vector+! s2-0 s2-0 (the-as vector s4-2)) + (dotimes (s1-0 8) + (vector-copy! s3-0 s2-0) + (curve-get-pos! s2-0 (* 0.125 (the float (+ s1-0 1))) s5-2) + (vector+! s2-0 s2-0 (the-as vector s4-2)) + (camera-line s3-0 s2-0 (new 'static 'vector4w :x #xff :y #xff :w #x80)) + ) + (dotimes (s1-1 (-> s5-2 num-cverts)) + (vector+! s3-0 (-> s5-2 cverts s1-1) (the-as vector s4-2)) + (vector+! s2-0 (-> s5-2 cverts (mod (+ s1-1 1) (-> s5-2 num-cverts))) (the-as vector s4-2)) + (camera-line s3-0 s2-0 (new 'static 'vector4w :y #xff :z #xff :w #x80)) + ) + (if gp-1 + (camera-line + (the-as vector (&+ gp-1 0)) + (the-as vector (&+ gp-1 16)) + (new 'static 'vector4w :x #xff :y #xff :z #xff :w #x80) + ) + (camera-line + (-> s5-2 cverts 0) + (-> s5-2 cverts (+ (-> s5-2 num-cverts) -1)) + (new 'static 'vector4w :x #xff :y #xff :z #xff :w #x80) + ) + ) + ) + ) + ) + ) + ) + ) + 0 + (none) + ) + +(defun master-draw-coordinates ((arg0 vector)) + (let ((s5-0 (new-stack-vector0)) + (gp-0 (new-stack-vector0)) + ) + (let ((a0-1 (new-stack-matrix0))) + (set-vector! s5-0 0.0 8192.0 0.0 1.0) + (matrix-rotate-yxz! a0-1 s5-0) + ) + (position-in-front-of-camera! gp-0 24576.0 0.0) + (let ((a1-4 s5-0) + (v1-1 gp-0) + (a0-3 s5-0) + ) + (set! (-> a0-3 x) 4096.0) + (set! (-> a0-3 y) 0.0) + (set! (-> a0-3 z) 0.0) + (set! (-> a0-3 w) 1.0) + (vector+! a1-4 v1-1 a0-3) + ) + (add-debug-line + #t + (bucket-id debug-no-zbuf1) + gp-0 + s5-0 + (new 'static 'rgba :r #xff :a #x80) + #f + (the-as rgba -1) + ) + (let ((a1-7 s5-0) + (v1-2 gp-0) + (a0-5 s5-0) + ) + (set! (-> a0-5 x) 0.0) + (set! (-> a0-5 y) 4096.0) + (set! (-> a0-5 z) 0.0) + (set! (-> a0-5 w) 1.0) + (vector+! a1-7 v1-2 a0-5) + ) + (add-debug-line + #t + (bucket-id debug-no-zbuf1) + gp-0 + s5-0 + (new 'static 'rgba :g #xff :a #x80) + #f + (the-as rgba -1) + ) + (let ((a1-10 s5-0) + (v1-3 gp-0) + (a0-7 s5-0) + ) + (set! (-> a0-7 x) 0.0) + (set! (-> a0-7 y) 0.0) + (set! (-> a0-7 z) 4096.0) + (set! (-> a0-7 w) 1.0) + (vector+! a1-10 v1-3 a0-7) + ) + (add-debug-line + #t + (bucket-id debug-no-zbuf1) + gp-0 + s5-0 + (new 'static 'rgba :b #xff :a #x80) + #f + (the-as rgba -1) + ) + (when arg0 + (vector-copy! s5-0 arg0) + (vector-normalize! s5-0 4096.0) + (vector+! s5-0 gp-0 s5-0) + (add-debug-line + #t + (bucket-id debug-no-zbuf1) + gp-0 + s5-0 + (new 'static 'rgba :r #x7f :g #x7f :a #x80) + #f + (the-as rgba -1) + ) + ) + ) + 0 + (none) + ) + +(deftype cam-collision-record (structure) + ((pos vector :inline) + (vel vector :inline) + (desired-pos vector :inline) + (cam-tpos-cur vector :inline) + (cam-tpos-old vector :inline) + (view-flat vector :inline) + (string-min-val vector :inline) + (string-max-val vector :inline) + (view-off vector :inline) + (min-z-override float) + (string-push-z float) + (view-off-param float) + (frame int32) + (iteration int32) + (move-type symbol) + ) + ) + + +(deftype cam-collision-record-array (inline-array-class) + ((data cam-collision-record :dynamic) + ) + ) + + +(set! (-> cam-collision-record-array heap-base) (the-as uint 176)) + +(define *cam-collision-record-first* 0) + +(define *cam-collision-record-last* 0) + +(define *cam-collision-record-show* 0) + +(define *cam-collision-record* (new 'debug 'cam-collision-record-array 600)) + +(defun cam-collision-record-save ((arg0 vector) (arg1 vector) (arg2 int) (arg3 symbol) (arg4 camera-slave)) + (when *record-cam-collide-history* + (let ((v1-5 (the-as + cam-collision-record + (+ (+ (* 176 *cam-collision-record-last*) 12) (the-as int *cam-collision-record*)) + ) + ) + ) + (vector-copy! (-> v1-5 pos) arg0) + (vector-copy! (-> v1-5 vel) arg1) + (vector-copy! (-> v1-5 view-flat) (-> arg4 view-flat)) + (vector-copy! (-> v1-5 desired-pos) (-> arg4 desired-pos)) + (vector-copy! (-> v1-5 cam-tpos-cur) (-> *camera* tpos-curr-adj)) + (vector-copy! (-> v1-5 cam-tpos-old) (-> *camera* tpos-old-adj)) + (vector-copy! (-> v1-5 string-min-val) (-> arg4 string-min-val)) + (vector-copy! (-> v1-5 string-max-val) (-> arg4 string-max-val)) + (vector-copy! (-> v1-5 view-off) (-> arg4 view-off)) + (set! (-> v1-5 frame) (the-as int (current-time))) + (set! (-> v1-5 iteration) arg2) + (set! (-> v1-5 move-type) arg3) + (set! (-> v1-5 min-z-override) (-> arg4 min-z-override)) + (set! (-> v1-5 string-push-z) (-> *camera* string-push-z)) + (set! (-> v1-5 view-off-param) (-> arg4 view-off-param)) + ) + (set! *cam-collision-record-show* *cam-collision-record-last*) + (set! *cam-collision-record-last* (+ *cam-collision-record-last* 1)) + (set! *cam-collision-record-last* (mod *cam-collision-record-last* 600)) + (when (= *cam-collision-record-last* *cam-collision-record-first*) + (set! *cam-collision-record-first* (+ *cam-collision-record-first* 1)) + (set! *cam-collision-record-first* (mod *cam-collision-record-first* 600)) + ) + ) + 0 + (none) + ) + +(defun cam-collision-record-step ((arg0 int)) + (set! *cam-collision-record-show* (+ *cam-collision-record-show* arg0)) + (while (>= *cam-collision-record-show* 600) + (set! *cam-collision-record-show* (+ *cam-collision-record-show* -600)) + ) + (while (< *cam-collision-record-show* 0) + (set! *cam-collision-record-show* (+ *cam-collision-record-show* 600)) + ) + 0 + (none) + ) + +(defun cam-collision-record-draw () + (cond + ((cpad-pressed? 0 down) + (cam-collision-record-step 1) + ) + ((cpad-hold? 0 right) + (cam-collision-record-step 1) + ) + ((cpad-pressed? 0 up) + (cam-collision-record-step -1) + ) + ((cpad-hold? 0 left) + (cam-collision-record-step -1) + ) + ) + (let ((s5-0 (the-as object (+ (+ (* 176 *cam-collision-record-show*) 12) (the-as int *cam-collision-record*)))) + (s4-0 (new 'stack 'vector4w)) + (gp-0 (new 'stack 'vector4w)) + ) + (format *stdcon* "move-type ~A~%" (-> (the-as cam-collision-record s5-0) move-type)) + (cond + ((= (-> (the-as cam-collision-record s5-0) move-type) 'normal) + (set! (-> s4-0 x) 255) + (set! (-> s4-0 y) 255) + ) + ((= (-> (the-as cam-collision-record s5-0) move-type) 'jump) + (set! (-> s4-0 x) 255) + ) + ((= (-> (the-as cam-collision-record s5-0) move-type) 'no-hit) + (set! (-> s4-0 y) 255) + ) + (else + (set! (-> s4-0 z) 255) + ) + ) + (set! (-> s4-0 w) 128) + (set! (-> gp-0 x) 127) + (set! (-> gp-0 y) 127) + (set! (-> gp-0 z) 127) + (set! (-> gp-0 w) 128) + (camera-line-rel-len + (-> (the-as cam-collision-record s5-0) pos) + (-> (the-as cam-collision-record s5-0) vel) + (fmax 81.92 (vector-length (-> (the-as cam-collision-record s5-0) vel))) + s4-0 + ) + (let ((s3-0 (new 'stack-no-clear 'collide-query))) + (vector-copy! (-> s3-0 start-pos) (-> (the-as cam-collision-record s5-0) pos)) + (vector-copy! (-> s3-0 move-dist) (-> (the-as cam-collision-record s5-0) vel)) + (let ((v1-47 s3-0)) + (set! (-> v1-47 radius) (-> *CAMERA-bank* collide-move-rad)) + (set! (-> v1-47 collide-with) (collide-spec backgnd)) + (set! (-> v1-47 ignore-process0) #f) + (set! (-> v1-47 ignore-process1) #f) + (set! (-> v1-47 ignore-pat) (new 'static 'pat-surface :nocamera #x1 :probe #x1 :noendlessfall #x1)) + (set! (-> v1-47 action-mask) (collide-action solid)) + ) + (let ((f30-0 (fill-and-probe-using-line-sphere *collide-cache* s3-0)) + (s2-0 (new 'stack-no-clear 'vector)) + ) + (format + *stdcon* + "frame ~D iteration ~D travel ~f~%" + (-> (the-as cam-collision-record s5-0) frame) + (-> (the-as cam-collision-record s5-0) iteration) + f30-0 + ) + (format + *stdcon* + "mzo ~M psz ~M vop ~f~%" + (-> (the-as cam-collision-record s5-0) min-z-override) + (-> (the-as cam-collision-record s5-0) string-push-z) + (-> (the-as cam-collision-record s5-0) view-off-param) + ) + (format + *stdcon* + "pos ~M ~M ~M~%" + (-> (the-as cam-collision-record s5-0) pos x) + (-> (the-as cam-collision-record s5-0) pos y) + (-> (the-as cam-collision-record s5-0) pos z) + ) + (format + *stdcon* + "vel ~M ~M ~M~%" + (-> (the-as cam-collision-record s5-0) vel x) + (-> (the-as cam-collision-record s5-0) vel y) + (-> (the-as cam-collision-record s5-0) vel z) + ) + (format + *stdcon* + "des ~M ~M ~M~%" + (-> (the-as cam-collision-record s5-0) desired-pos x) + (-> (the-as cam-collision-record s5-0) desired-pos y) + (-> (the-as cam-collision-record s5-0) desired-pos z) + ) + (format + *stdcon* + "flt ~M ~M ~M~%" + (-> (the-as cam-collision-record s5-0) view-flat x) + (-> (the-as cam-collision-record s5-0) view-flat y) + (-> (the-as cam-collision-record s5-0) view-flat z) + ) + (format + *stdcon* + "cur ~M ~M ~M~%" + (-> (the-as cam-collision-record s5-0) cam-tpos-cur x) + (-> (the-as cam-collision-record s5-0) cam-tpos-cur y) + (-> (the-as cam-collision-record s5-0) cam-tpos-cur z) + ) + (format + *stdcon* + "old ~M ~M ~M~%" + (-> (the-as cam-collision-record s5-0) cam-tpos-old x) + (-> (the-as cam-collision-record s5-0) cam-tpos-old y) + (-> (the-as cam-collision-record s5-0) cam-tpos-old z) + ) + (format + *stdcon* + "smn ~M ~M ~M~%" + (-> (the-as cam-collision-record s5-0) string-min-val x) + (-> (the-as cam-collision-record s5-0) string-min-val y) + (-> (the-as cam-collision-record s5-0) string-min-val z) + ) + (format + *stdcon* + "smx ~M ~M ~M~%" + (-> (the-as cam-collision-record s5-0) string-max-val x) + (-> (the-as cam-collision-record s5-0) string-max-val y) + (-> (the-as cam-collision-record s5-0) string-max-val z) + ) + (format + *stdcon* + "vof ~M ~M ~M~%" + (-> (the-as cam-collision-record s5-0) view-off x) + (-> (the-as cam-collision-record s5-0) view-off y) + (-> (the-as cam-collision-record s5-0) view-off z) + ) + (when (>= f30-0 0.0) + (camera-line (the-as vector (-> s3-0 best-other-tri)) (-> s3-0 best-other-tri vertex 1) s4-0) + (camera-line (-> s3-0 best-other-tri vertex 1) (-> s3-0 best-other-tri vertex 2) s4-0) + (camera-line (-> s3-0 best-other-tri vertex 2) (the-as vector (-> s3-0 best-other-tri)) s4-0) + (vector-! s2-0 (the-as vector (+ (the-as int s5-0) 0)) (-> s3-0 best-other-tri intersect)) + (vector-normalize! s2-0 1.0) + (camera-line-rel-len (-> s3-0 best-other-tri intersect) s2-0 (-> *CAMERA-bank* collide-move-rad) gp-0) + (camera-line-rel-len + (-> s3-0 best-other-tri intersect) + (-> s3-0 best-other-tri normal) + (-> *CAMERA-bank* collide-move-rad) + gp-0 + ) + ) + ) + ) + ) + 0 + (none) + ) + +(defun camera-master-debug ((arg0 camera-master)) + (when *display-cam-other* + (let ((f0-1 (/ (-> *camera-other-fov* data) 2))) + (camera-fov-frame + *camera-other-matrix* + *camera-other-trans* + f0-1 + 0.75 + 1.0 + (new 'static 'vector4w :x #xff :w #x80) + ) + ) + (camera-line *camera-other-trans* *camera-other-root* (new 'static 'vector4w :x #xff :y #xff :z #xff :w #x80)) + (let ((s4-0 (new 'stack-no-clear 'vector)) + (s5-0 *camera-other-trans*) + ) + (vector+float*! s4-0 s5-0 (-> *camera-other-matrix* rvec) 2048.0) + (camera-line s5-0 s4-0 (new 'static 'vector4w :x #xff :w #x80)) + (vector+float*! s4-0 s5-0 (-> *camera-other-matrix* uvec) 2048.0) + (camera-line s5-0 s4-0 (new 'static 'vector4w :y #xff :w #x80)) + (vector+float*! s4-0 s5-0 (-> *camera-other-matrix* fvec) 2048.0) + (camera-line s5-0 s4-0 (new 'static 'vector4w :z #xff :w #x80)) + ) + ) + (when *display-camera-last-attacker* + (format *stdcon* "last attacker '") + (let ((v1-16 (handle->process (-> last-try-to-look-at-data who)))) + (if v1-16 + (format *stdcon* "~S" (-> v1-16 name)) + ) + ) + (format *stdcon* "'~%") + ) + (when *display-camera-old-stats* + (format + *stdcon* + "old ~S cpu ~D old vu ~D (go to menu before comparing)~%" + *camera-old-level* + *camera-old-cpu* + *camera-old-vu* + ) + (format *stdcon* "old tfrag-mem ~D~%" (sar *camera-old-tfrag-bytes* 10)) + (format *stdcon* "~S~%" *camera-old-stat-string-tfrag-near*) + (format *stdcon* "~S~%" *camera-old-stat-string-tfrag*) + (format *stdcon* "~S~%" *camera-old-stat-string-total*) + ) + (if *display-cam-collide-history* + (cam-collision-record-draw) + ) + (if *display-cam-master-marks* + (debug-draw-spline (-> arg0 target-spline)) + ) + (if *display-xyz-axes* + (master-draw-coordinates (the-as vector #f)) + ) + (cam-debug-draw-tris) + 0 + (none) + ) + +(defun debug-set-camera-pos-rot! ((arg0 vector) (arg1 matrix)) + (when (and *camera* *camera-combiner*) + (vector-copy! (-> *camera-combiner* trans) arg0) + (matrix-copy! (-> *camera-combiner* inv-camera-rot) arg1) + (set-setting-by-param *setting-control* 'mode-name 'cam-fixed 0 0) + (cam-master-activate-slave #t) + ) + arg0 + ) + +(defun-debug cam-restore () + (let ((a0-0 (new-stack-vector0)) + (a1-0 (new-stack-matrix0)) + ) + (set! (-> a0-0 x) 1538892.5) + (set! (-> a0-0 y) -274716.78) + (set! (-> a0-0 z) -8318042.5) + (set! (-> a0-0 w) 1.0) + (set! (-> a1-0 rvec x) 0.4915) + (set! (-> a1-0 rvec y) 0.0) + (set! (-> a1-0 rvec z) -0.8708) + (set! (-> a1-0 rvec w) 0.0) + (set! (-> a1-0 uvec x) 0.7179) + (set! (-> a1-0 uvec y) 0.5659) + (set! (-> a1-0 uvec z) 0.4052) + (set! (-> a1-0 uvec w) 0.0) + (set! (-> a1-0 fvec x) 0.4928) + (set! (-> a1-0 fvec y) -0.8244) + (set! (-> a1-0 fvec z) 0.2782) + (set! (-> a1-0 fvec w) 0.0) + (set! (-> a1-0 trans x) 0.0) + (set! (-> a1-0 trans y) 0.0) + (set! (-> a1-0 trans z) 0.0) + (set! (-> a1-0 trans w) 1.0) + (debug-set-camera-pos-rot! a0-0 a1-0) + ) + (send-event *camera* 'set-fov 11650.845) + (clear *camera-old-level*) + (format *camera-old-level* "dig3a") + (set! *camera-old-cpu* 4815) + (set! *camera-old-vu* 6110) + (set! *camera-old-tfrag-bytes* #xa0130) + (clear *camera-old-stat-string-tfrag*) + (clear *camera-old-stat-string-tfrag-near*) + (clear *camera-old-stat-string-total*) + (set! *display-camera-old-stats* #t) + (set! (-> *tfrag-work* min-fragment) (the-as uint 318)) + (set! (-> *tfrag-work* max-fragment) (the-as uint 319)) + (none) + ) + +;; WARN: Return type mismatch symbol vs none. +(defun-debug cam-restore-generic-bug () + (let ((a0-0 (new-stack-vector0)) + (a1-0 (new-stack-matrix0)) + ) + (set! (-> a0-0 x) 9918803.0) + (set! (-> a0-0 y) 142780.03) + (set! (-> a0-0 z) 1278966.1) + (set! (-> a0-0 w) 1.0) + (set! (-> a1-0 rvec x) -0.5371) + (set! (-> a1-0 rvec y) 0.0) + (set! (-> a1-0 rvec z) 0.8434) + (set! (-> a1-0 rvec w) 0.0) + (set! (-> a1-0 uvec x) -0.2917) + (set! (-> a1-0 uvec y) 0.9382) + (set! (-> a1-0 uvec z) -0.1857) + (set! (-> a1-0 uvec w) 0.0) + (set! (-> a1-0 fvec x) -0.7914) + (set! (-> a1-0 fvec y) -0.3458) + (set! (-> a1-0 fvec z) -0.5039) + (set! (-> a1-0 fvec w) 0.0) + (set! (-> a1-0 trans x) 0.0) + (set! (-> a1-0 trans y) 0.0) + (set! (-> a1-0 trans z) 0.0) + (set! (-> a1-0 trans w) 1.0) + (debug-set-camera-pos-rot! a0-0 a1-0) + ) + (send-event *camera* 'set-fov 15152.451) + (clear *camera-old-level*) + (format *camera-old-level* "wasall") + (set! *camera-old-cpu* 8453) + (set! *camera-old-vu* -30883) + (set! *camera-old-tfrag-bytes* 0) + (clear *camera-old-stat-string-tfrag*) + (clear *camera-old-stat-string-tfrag-near*) + (clear *camera-old-stat-string-total*) + (set! *display-camera-old-stats* #t) + (none) + ) diff --git a/goal_src/jak3/engine/debug/sampler.gc b/goal_src/jak3/engine/debug/sampler.gc index a84eab4006..11bb241bae 100644 --- a/goal_src/jak3/engine/debug/sampler.gc +++ b/goal_src/jak3/engine/debug/sampler.gc @@ -5,5 +5,44 @@ ;; name in dgo: sampler ;; dgos: GAME +;; og:ignore-form:install-handler 9 timer0-handler + ;; DECOMP BEGINS +;; this file is debug only +(declare-file (debug)) + +(define *sampler-mem* (the-as pointer #f)) + +(define *sampler-compare* (the-as uint 1)) + +(define *sampler-count* 0) + +;; ERROR: function was not converted to expressions. Cannot decompile. + +;; og:preserve-this +; (set! (-> (the-as timer-bank #x10000000) mode) (new 'static 'timer-mode)) + +(defun-debug sampler-start () + (set! (-> (the-as timer-bank #x10000000) mode) (new 'static 'timer-mode)) + (set! (-> (the-as timer-bank #x10000000) count) (the-as uint 0)) + (set! (-> (the-as timer-bank #x10000000) comp) *sampler-compare*) + (if (not *sampler-mem*) + (set! *sampler-mem* (malloc 'debug #x1000000)) + ) + (when (nonzero? *sampler-mem*) + (mem-set32! *sampler-mem* #x400000 0) + (set! (-> (the-as timer-bank #x10000000) mode) + (new 'static 'timer-mode :clks (timer-clock-selection busclk/256) :zret #x1 :cue #x1 :cmpe #x1 :equf #x1) + ) + (set! *sampler-count* 0) + 0 + ) + (none) + ) + +(defun-debug sampler-stop () + (set! (-> (the-as timer-bank #x10000000) mode) (new 'static 'timer-mode)) + 0 + (none) + ) diff --git a/goal_src/jak3/levels/common/enemy/hover/hover-nav-edit.gc b/goal_src/jak3/levels/common/enemy/hover/hover-nav-edit.gc index 7bd8e0a6cd..162d6da37a 100644 --- a/goal_src/jak3/levels/common/enemy/hover/hover-nav-edit.gc +++ b/goal_src/jak3/levels/common/enemy/hover/hover-nav-edit.gc @@ -7,3 +7,655 @@ ;; DECOMP BEGINS +;; this file is debug only +(declare-file (debug)) + +(defun probe-for-clear-collision? ((arg0 vector) (arg1 vector)) + (let ((s5-0 (new 'stack-no-clear 'collide-query))) + (vector-copy! (-> s5-0 start-pos) arg0) + (vector-! (-> s5-0 move-dist) arg1 arg0) + (let ((v1-2 s5-0)) + (set! (-> v1-2 radius) 4096.0) + (set! (-> v1-2 collide-with) (collide-spec backgnd)) + (set! (-> v1-2 ignore-process0) #f) + (set! (-> v1-2 ignore-process1) #f) + (set! (-> v1-2 ignore-pat) + (new 'static 'pat-surface :noentity #x1 :nojak #x1 :probe #x1 :noendlessfall #x1 :board #x1) + ) + (set! (-> v1-2 action-mask) (collide-action solid)) + ) + (when (< (fill-and-probe-using-line-sphere *collide-cache* s5-0) 0.0) + (let ((s4-0 (new 'stack-no-clear 'vector))) + (vector-copy! s4-0 arg0) + (let* ((f0-2 (vector-vector-distance s4-0 arg1)) + (s3-1 (+ (the int (/ f0-2 (meters 30))) 1)) + (s2-0 (vector-normalize-copy! (new 'stack-no-clear 'vector) (-> s5-0 move-dist) 110592.0)) + ) + (dotimes (s1-0 s3-1) + (vector-copy! (-> s5-0 start-pos) s4-0) + (vector-! (-> s5-0 move-dist) arg1 s4-0) + (if (< 122880.0 (vector-length (-> s5-0 move-dist))) + (vector-normalize! (-> s5-0 move-dist) 122880.0) + ) + (let ((v1-15 s5-0)) + (set! (-> v1-15 radius) 12288.0) + (set! (-> v1-15 collide-with) (collide-spec backgnd)) + (set! (-> v1-15 ignore-process0) #f) + (set! (-> v1-15 ignore-process1) #f) + (set! (-> v1-15 ignore-pat) + (new 'static 'pat-surface :noentity #x1 :nojak #x1 :probe #x1 :noendlessfall #x1 :board #x1) + ) + (set! (-> v1-15 action-mask) (collide-action solid)) + ) + (if (>= (fill-and-probe-using-line-sphere *collide-cache* s5-0) 0.0) + (return #f) + ) + (vector+! s4-0 s4-0 s2-0) + ) + ) + ) + #t + ) + ) + ) + +(defun hover-nav-graph-process-points () + (local-vars (v1-10 symbol)) + (let ((v1-0 (get-nav-graph-editor))) + (when v1-0 + (let* ((gp-0 (-> v1-0 nav-graph)) + (s5-0 (-> gp-0 node-array length)) + ) + (dotimes (s4-0 s5-0) + (let ((s3-0 (+ (the-as uint (-> gp-0 node-array data 0 position)) (* 80 s4-0)))) + (when (< s4-0 (+ s5-0 -1)) + (let ((s2-0 (+ s4-0 1))) + (while (< s2-0 s5-0) + (let ((s1-0 (+ (the-as uint (-> gp-0 node-array data 0 position)) (* 80 s2-0)))) + (dotimes (v1-8 (-> gp-0 edge-array length)) + (let* ((a1-1 (-> gp-0 edge-array data v1-8)) + (a0-8 (-> a1-1 runtime-node-id-1)) + (a1-2 (-> a1-1 runtime-node-id-2)) + ) + (when (or (and (= s4-0 a0-8) (= s2-0 a1-2)) (and (= s4-0 a1-2) (= s2-0 a0-8))) + (set! v1-10 #t) + (goto cfg-19) + ) + ) + ) + (set! v1-10 #f) + (label cfg-19) + (when (not v1-10) + (when (and (< (vector-vector-distance (the-as vector s3-0) (the-as vector s1-0)) 204800.0) + (probe-for-clear-collision? (the-as vector s3-0) (the-as vector s1-0)) + (probe-for-clear-collision? (the-as vector s1-0) (the-as vector s3-0)) + ) + (let ((v1-17 (alloc-new-edge! gp-0))) + (when (!= v1-17 -1) + (let ((v1-20 (-> gp-0 edge-array data v1-17))) + (set! (-> v1-20 runtime-node-id-1) s4-0) + (set! (-> v1-20 runtime-node-id-2) s2-0) + (set! (-> v1-20 directionality) (nav-directionality bi_directional)) + (set! (-> v1-20 speed_limit) 122880.0) + (set! (-> v1-20 density) 1.0) + (set! (-> v1-20 traffic_edge_flag) 0) + (set! (-> v1-20 nav_clock_mask) (nav-clock-mask)) + (set! (-> v1-20 nav_clock_type) (nav-clock-type no-clock)) + (set! (-> v1-20 width) 0.0) + (set! (-> v1-20 minimap_edge_flag) (nav-minimap-edge-flag)) + ) + 0 + ) + ) + ) + ) + ) + (+! s2-0 1) + ) + ) + ) + ) + ) + ) + ) + ) + 0 + (none) + ) + +;; WARN: Return type mismatch file-stream vs object. +(defun hover-nav-graph-output ((arg0 string)) + (local-vars + (sv-96 vector) + (sv-112 vector) + (sv-128 int) + (sv-144 int) + (sv-160 (function _varargs_ object)) + (sv-176 string) + (sv-192 string) + (sv-208 int) + (sv-224 (function _varargs_ object)) + (sv-240 string) + (sv-256 string) + (sv-272 int) + ) + (rlet ((vf0 :class vf) + (vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + ) + (init-vf0-vector) + (let ((s4-0 (new 'stack-no-clear 'vector)) + (gp-0 (new 'debug 'string #x7a120 (the-as string #f))) + ) + (let ((s3-0 (clear *temp-string*))) + (format s3-0 "select translate_x,translate_y,translate_z from level_info where name='~S'" arg0) + (format 0 "~S~%" s3-0) + (let ((s2-0 (sql-query s3-0))) + (when (!= (-> s2-0 content-type) 'select) + (format 0 "ERROR: sql: select error ~A~%" s2-0) + (return (the-as object #f)) + ) + (set-vector! + s4-0 + (* 4096.0 (string->float (the-as string (-> s2-0 sql-data 0)))) + (* 4096.0 (string->float (the-as string (-> s2-0 sql-data 1)))) + (* 4096.0 (string->float (the-as string (-> s2-0 sql-data 2)))) + 1.0 + ) + ) + ) + (format 0 "level offset: ~m ~m ~m~%" (-> s4-0 x) (-> s4-0 y) (-> s4-0 z)) + (let ((s3-2 (new 'debug 'mysql-nav-graph (the-as string 'hover)))) + (when (or (not s3-2) (not (init-from-sql! s3-2 'hover arg0))) + (format 0 "ERROR: Failed to load hover graph (level ~s) from MySQL!~%" arg0) + (return (the-as object #f)) + ) + (format gp-0 ";-*-Lisp-*-~%(in-package goal)~%~%;;~%") + (format + gp-0 + ";; WARNING: This file was generated by running (hover-nav-graph-output ...) found in hover-nav-edit.gc.~%;;~%~%" + ) + (format gp-0 "(def-nav-network-adjacency-table *~S-adjacency*~% (~%" arg0) + (let ((s2-1 (-> s3-2 node-array length)) + (s1-0 0) + ) + (dotimes (s0-0 s2-1) + (when (nonzero? (-> s3-2 node-array data s0-0 nav_node_id)) + (set! sv-96 (new 'stack-no-clear 'vector)) + (let ((v1-22 (+ (the-as uint (-> s3-2 node-array data 0 position)) (* 80 s0-0))) + (a0-22 s4-0) + ) + (.mov.vf.w vf6 vf0) + (.lvf vf4 (&-> (the-as (pointer int128) v1-22))) + (.lvf vf5 (&-> a0-22 quad)) + ) + (.add.vf.xyz vf6 vf4 vf5) + (.svf (&-> sv-96 quad) vf6) + (set! sv-112 (new 'stack-no-clear 'vector)) + (format gp-0 " (~d (~m ~m ~m) (" s1-0 (-> sv-96 x) (-> sv-96 y) (-> sv-96 z)) + (set! sv-128 0) + (while (< sv-128 (-> s3-2 edge-array length)) + (let ((v1-32 (-> s3-2 edge-array data sv-128))) + (set! sv-272 (-> v1-32 runtime-node-id-1)) + (set! sv-144 (-> v1-32 runtime-node-id-2)) + ) + (when (= s0-0 sv-272) + (vector+! sv-112 (the-as vector (+ (the-as uint (-> s3-2 node-array data 0 position)) (* 80 sv-144))) s4-0) + (set! sv-160 format) + (set! sv-176 gp-0) + (set! sv-192 "(~d ~m) ") + (set! sv-208 sv-144) + (let ((a3-3 (vector-vector-distance sv-96 sv-112))) + (sv-160 sv-176 sv-192 sv-208 a3-3) + ) + ) + (when (= s0-0 sv-144) + (vector+! sv-112 (the-as vector (+ (the-as uint (-> s3-2 node-array data 0 position)) (* 80 sv-272))) s4-0) + (set! sv-224 format) + (set! sv-240 gp-0) + (set! sv-256 "(~d ~m) ") + (let ((a3-4 (vector-vector-distance sv-96 sv-112))) + (sv-224 sv-240 sv-256 sv-272 a3-4) + ) + ) + (set! sv-128 (+ sv-128 1)) + ) + (format gp-0 "))~%") + (+! s1-0 1) + ) + ) + ) + (format gp-0 " )~% (") + (dotimes (s4-1 (-> s3-2 edge-array length)) + (let ((v1-58 (-> s3-2 edge-array data s4-1))) + (format + gp-0 + "(~d ~d ~m) " + (-> v1-58 runtime-node-id-1) + (-> v1-58 runtime-node-id-2) + (if (!= 0.0 (-> v1-58 width)) + (-> v1-58 width) + #x46800000 + ) + ) + ) + (if (= (logand (+ s4-1 -1) 7) 7) + (format gp-0 "~% ") + ) + ) + ) + (format gp-0 ")~%") + (format gp-0 " )~%") + (format (clear *temp-string*) "game/hover-nav-graph-~s.gc" arg0) + *temp-string* + (format 0 "Writing nav-graph as file ~S...~%" *temp-string*) + (let ((s5-1 (new 'stack 'file-stream *temp-string* 'write))) + (format s5-1 gp-0) + (file-stream-close s5-1) + ) + ) + ) + ) + +(define *axes-table* (new 'static 'boxed-array :type vector + (new 'static 'vector :x 1.0 :w 1.0) + (new 'static 'vector :y 1.0 :w 1.0) + (new 'static 'vector :z 1.0 :w 1.0) + ) + ) + +(deftype hover-nav-bsp-point (list-node) + ((index int32) + (pos vector :inline) + ) + (:methods + (new (symbol type) _type_) + ) + ) + +(defmethod inspect ((this hover-nav-bsp-point)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'hover-nav-bsp-point) + (format #t "~1Tnext: #~%" (-> this next)) + (format #t "~1Tprev: #~%" (-> this prev)) + (format #t "~1Tindex: ~D~%" (-> this index)) + (format #t "~1Tpos: #~%" (-> this pos)) + (label cfg-4) + this + ) + +;; WARN: Return type mismatch structure vs hover-nav-bsp-point. +(defmethod new hover-nav-bsp-point ((allocation symbol) (type-to-make type)) + (let ((t9-0 (method-of-type structure new)) + (v1-1 type-to-make) + ) + (-> type-to-make size) + (let ((v0-0 (t9-0 allocation v1-1))) + (set! (-> (the-as hover-nav-bsp-point v0-0) next) #f) + (set! (-> (the-as hover-nav-bsp-point v0-0) prev) #f) + (the-as hover-nav-bsp-point v0-0) + ) + ) + ) + +(deftype hover-nav-bsp-node (structure) + ((split-plane vector :inline) + (point-list hover-nav-bsp-point) + (left hover-nav-bsp-node) + (right hover-nav-bsp-node) + ) + (:methods + (new (symbol type) _type_) + (hover-nav-bsp-node-method-9 (_type_) none) + (hover-nav-bsp-node-method-10 (_type_ int) none) + ) + ) + +(defmethod inspect ((this hover-nav-bsp-node)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'hover-nav-bsp-node) + (format #t "~1Tsplit-plane: #~%" (-> this split-plane)) + (format #t "~1Tpoint-list: #~%" (-> this point-list)) + (format #t "~1Tleft: #~%" (-> this left)) + (format #t "~1Tright: #~%" (-> this right)) + (label cfg-4) + this + ) + +;; WARN: Return type mismatch structure vs hover-nav-bsp-node. +(defmethod new hover-nav-bsp-node ((allocation symbol) (type-to-make type)) + (let ((t9-0 (method-of-type structure new)) + (v1-1 type-to-make) + ) + (-> type-to-make size) + (let ((v0-0 (t9-0 allocation v1-1))) + (set! (-> (the-as hover-nav-bsp-node v0-0) point-list) #f) + (set! (-> (the-as hover-nav-bsp-node v0-0) left) #f) + (set! (-> (the-as hover-nav-bsp-node v0-0) right) #f) + (the-as hover-nav-bsp-node v0-0) + ) + ) + ) + +(deftype hover-nav-bsp (structure) + ((root hover-nav-bsp-node) + ) + ) + +(defmethod inspect ((this hover-nav-bsp)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'hover-nav-bsp) + (format #t "~1Troot: #~%" (-> this root)) + (label cfg-4) + this + ) + +(defmethod hover-nav-bsp-node-method-9 ((this hover-nav-bsp-node)) + (let ((v1-0 (-> this split-plane))) + (format #t "((~,,1f ~,,1f ~,,1f ~m)~% " (-> v1-0 x) (-> v1-0 y) (-> v1-0 z) (-> v1-0 w)) + ) + (let ((v1-2 (the-as list-node (-> this point-list)))) + (while v1-2 + (let ((s5-0 (-> v1-2 next))) + (format + #t + "(~d (~m ~m ~m)) " + (-> (the-as hover-nav-bsp-point v1-2) index) + (-> (the-as hover-nav-bsp-point v1-2) pos x) + (-> (the-as hover-nav-bsp-point v1-2) pos y) + (-> (the-as hover-nav-bsp-point v1-2) pos z) + ) + (set! v1-2 s5-0) + ) + ) + ) + (if (-> this left) + (hover-nav-bsp-node-method-9 (-> this left)) + ) + (if (-> this right) + (hover-nav-bsp-node-method-9 (-> this right)) + ) + (format #t ")~%") + 0 + (none) + ) + +(defmethod hover-nav-bsp-node-method-10 ((this hover-nav-bsp-node) (arg0 int)) + (when (-> this point-list) + (format 0 "build-bsp: ") + (let ((s4-0 (new 'stack-no-clear 'vector)) + (s3-0 0) + ) + (let ((v1-2 (the-as list-node (-> this point-list)))) + (while v1-2 + (set! v1-2 (-> v1-2 next)) + (+! s3-0 1) + ) + ) + (format 0 "count ~d ~%" s3-0) + (when (< 1 s3-0) + (vector-reset! s4-0) + (let ((f0-1 (/ 1.0 (the float s3-0))) + (a2-1 (the-as list-node (-> this point-list))) + ) + (while a2-1 + (let ((v1-9 (-> a2-1 next))) + (vector+float*! s4-0 s4-0 (the-as vector (+ (the-as uint a2-1) 16)) f0-1) + (set! a2-1 v1-9) + ) + ) + ) + (vector-copy! (-> this split-plane) (-> *axes-table* arg0)) + (set! (-> this split-plane w) (- (vector-dot s4-0 (-> this split-plane)))) + (let ((s3-1 (the-as list-node (-> this point-list)))) + (while s3-1 + (let ((s4-1 (-> s3-1 next))) + (let ((f0-7 (- (vector-dot (the-as vector (+ (the-as uint s3-1) 16)) (-> this split-plane))))) + (cond + ((= f0-7 (-> this split-plane w)) + ) + ((< f0-7 (-> this split-plane w)) + (if (not (-> this left)) + (set! (-> this left) (new 'global 'hover-nav-bsp-node)) + ) + (let ((v1-21 s3-1)) + (let ((a0-12 (&-> this point-list))) + (if (= (-> a0-12 0) v1-21) + (set! (-> a0-12 0) (the-as hover-nav-bsp-point (-> v1-21 next))) + ) + ) + (if (-> v1-21 prev) + (set! (-> v1-21 prev next) (-> v1-21 next)) + ) + (if (-> v1-21 next) + (set! (-> v1-21 next prev) (-> v1-21 prev)) + ) + (set! (-> v1-21 prev) #f) + (set! (-> v1-21 next) #f) + ) + (let ((a0-19 (-> this left point-list)) + (v1-25 (&-> this left point-list)) + ) + (when (zero? s3-1) + (break!) + 0 + ) + (when (or (= s3-1 a0-19) (= s3-1 v1-25)) + (break!) + 0 + ) + (when (not (or (not a0-19) (!= (-> a0-19 prev) s3-1))) + (break!) + 0 + ) + (when a0-19 + (set! (-> s3-1 next) a0-19) + (set! (-> s3-1 prev) (-> a0-19 prev)) + (if (-> s3-1 prev) + (set! (-> s3-1 prev next) s3-1) + ) + (if (-> s3-1 next) + (set! (-> s3-1 next prev) s3-1) + ) + ) + (if (or (not a0-19) (= a0-19 (-> v1-25 0))) + (set! (-> v1-25 0) (the-as hover-nav-bsp-point s3-1)) + ) + ) + ) + (else + (if (not (-> this right)) + (set! (-> this right) (new 'global 'hover-nav-bsp-node)) + ) + (let ((v1-30 s3-1)) + (let ((a0-22 (&-> this point-list))) + (if (= (-> a0-22 0) v1-30) + (set! (-> a0-22 0) (the-as hover-nav-bsp-point (-> v1-30 next))) + ) + ) + (if (-> v1-30 prev) + (set! (-> v1-30 prev next) (-> v1-30 next)) + ) + (if (-> v1-30 next) + (set! (-> v1-30 next prev) (-> v1-30 prev)) + ) + (set! (-> v1-30 prev) #f) + (set! (-> v1-30 next) #f) + ) + (let ((v1-32 s3-1) + (a1-40 (-> this right point-list)) + (a0-31 (&-> this right point-list)) + ) + (when (zero? v1-32) + (break!) + 0 + ) + (when (or (= v1-32 a1-40) (= v1-32 a0-31)) + (break!) + 0 + ) + (when (not (or (not a1-40) (!= (-> a1-40 prev) v1-32))) + (break!) + 0 + ) + (when a1-40 + (set! (-> v1-32 next) a1-40) + (set! (-> v1-32 prev) (-> a1-40 prev)) + (if (-> v1-32 prev) + (set! (-> v1-32 prev next) v1-32) + ) + (if (-> v1-32 next) + (set! (-> v1-32 next prev) v1-32) + ) + ) + (if (or (not a1-40) (= a1-40 (-> a0-31 0))) + (set! (-> a0-31 0) (the-as hover-nav-bsp-point v1-32)) + ) + ) + ) + ) + ) + (set! s3-1 s4-1) + ) + ) + ) + (if (-> this left) + (hover-nav-bsp-node-method-10 (-> this left) (mod (+ arg0 1) 3)) + ) + (if (-> this right) + (hover-nav-bsp-node-method-10 (-> this right) (mod (+ arg0 1) 3)) + ) + ) + ) + ) + 0 + (none) + ) + +(define *hover-bsp* (the-as hover-nav-bsp #f)) + +(defun hover-nav-graph-output-bsp () + (let ((v1-0 (get-nav-graph-editor))) + (when v1-0 + (let ((s5-0 (-> v1-0 nav-graph)) + (gp-0 (new 'global 'hover-nav-bsp)) + ) + (let ((s4-0 (-> s5-0 node-array length)) + (s3-0 0) + ) + (set! (-> gp-0 root) (new 'global 'hover-nav-bsp-node)) + (dotimes (s2-0 s4-0) + (when (nonzero? (-> s5-0 node-array data s2-0 nav_node_id)) + (let ((v1-9 (new 'global 'hover-nav-bsp-point))) + (set! (-> v1-9 index) s3-0) + (set! (-> v1-9 pos quad) + (-> (the-as (pointer uint128) (+ (the-as uint (-> s5-0 node-array data 0 position)) (* 80 s2-0)))) + ) + (let ((a1-7 (-> gp-0 root point-list)) + (a0-8 (&-> gp-0 root point-list)) + ) + (when (zero? v1-9) + (break!) + 0 + ) + (when (or (= v1-9 a1-7) (= v1-9 a0-8)) + (break!) + 0 + ) + (when (not (or (not a1-7) (!= (-> a1-7 prev) v1-9))) + (break!) + 0 + ) + (when a1-7 + (set! (-> v1-9 next) a1-7) + (set! (-> v1-9 prev) (-> a1-7 prev)) + (if (-> v1-9 prev) + (set! (-> v1-9 prev next) v1-9) + ) + (if (-> v1-9 next) + (set! (-> v1-9 next prev) v1-9) + ) + ) + (if (or (not a1-7) (= a1-7 (-> a0-8 0))) + (set! (-> a0-8 0) v1-9) + ) + ) + ) + (+! s3-0 1) + ) + ) + ) + (hover-nav-bsp-node-method-10 (-> gp-0 root) 0) + (set! *hover-bsp* gp-0) + gp-0 + ) + ) + ) + ) + +(defun hover-nav-network-build-bsp ((arg0 (array hover-nav-bsp-point))) + (let ((gp-0 (new 'global 'hover-nav-bsp))) + (let ((s4-0 (-> arg0 length)) + (s3-0 0) + ) + (set! (-> gp-0 root) (new 'global 'hover-nav-bsp-node)) + (dotimes (s2-0 s4-0) + (let ((v1-3 (new 'global 'hover-nav-bsp-point))) + (set! (-> v1-3 index) (-> (the-as (pointer int32) (-> arg0 s2-0)) 12)) + (vector-copy! (-> v1-3 pos) (the-as vector (&+ (-> arg0 s2-0) 32))) + (let ((a1-8 (-> gp-0 root point-list)) + (a0-11 (&-> gp-0 root point-list)) + ) + (when (zero? v1-3) + (break!) + 0 + ) + (when (or (= v1-3 a1-8) (= v1-3 a0-11)) + (break!) + 0 + ) + (when (not (or (not a1-8) (!= (-> a1-8 prev) v1-3))) + (break!) + 0 + ) + (when a1-8 + (set! (-> v1-3 next) a1-8) + (set! (-> v1-3 prev) (-> a1-8 prev)) + (if (-> v1-3 prev) + (set! (-> v1-3 prev next) v1-3) + ) + (if (-> v1-3 next) + (set! (-> v1-3 next prev) v1-3) + ) + ) + (if (or (not a1-8) (= a1-8 (-> a0-11 0))) + (set! (-> a0-11 0) v1-3) + ) + ) + ) + (+! s3-0 1) + ) + ) + (hover-nav-bsp-node-method-10 (-> gp-0 root) 0) + (set! *hover-bsp* gp-0) + gp-0 + ) + ) + +;; WARN: Return type mismatch object vs none. +(defun hover-nav-bsp-output ((arg0 hover-nav-bsp)) + (format #t "(") + (hover-nav-bsp-node-method-9 (-> arg0 root)) + (format #t ")~%") + (none) + ) diff --git a/goal_src/jak3/levels/common/race/pilot-recorder.gc b/goal_src/jak3/levels/common/race/pilot-recorder.gc index ff971db68b..356d6c8062 100644 --- a/goal_src/jak3/levels/common/race/pilot-recorder.gc +++ b/goal_src/jak3/levels/common/race/pilot-recorder.gc @@ -5,5 +5,671 @@ ;; name in dgo: pilot-recorder ;; dgos: WASLEAPR, DESRALLY, DESTRACK +;; +++pilrec-sample-flag +(defenum pilrec-sample-flag + :type uint8 + :bitfield #t + (square 0) + (l1 1) + (x 2) + ) +;; ---pilrec-sample-flag + +(declare-type pilot-recorder-samples basic) +(define-extern *pilot-recorder-samples* pilot-recorder-samples) + ;; DECOMP BEGINS +;; this file is debug only +(declare-file (debug)) + +(deftype pilrec-sample (structure) + ((sample-time time-frame) + (pos vector :inline) + (quat quaternion :inline) + (stick-x float) + (stick-y float) + (throttle float) + (flags pilrec-sample-flag) + ) + ) + + +(deftype pilot-recorder-samples (basic) + ((samples (inline-array pilrec-sample)) + ) + ) + + +(when (or (not *pilot-recorder-samples*) (zero? *pilot-recorder-samples*)) + (let ((gp-0 (new 'debug 'pilot-recorder-samples))) + (set! *pilot-recorder-samples* gp-0) + (set! (-> gp-0 samples) (the-as (inline-array pilrec-sample) (malloc 'debug #xe1000))) + ) + ) + +(deftype pilot-recorder (process) + ((info race-info) + (mesh race-mesh) + (select-race uint64) + (path-num int32) + (sample-count int32) + (samples (inline-array pilrec-sample)) + (state-time time-frame) + (start-time time-frame) + (start-record-plane plane :inline) + (start-record-center vector :inline) + (finish-record-plane plane :inline) + (finish-record-center vector :inline) + (prev-pos vector :inline) + ) + (:state-methods + die-fast + idle + active + recording + fail-full + finished + save + fail-save + ) + (:methods + (pilot-recorder-method-22 (_type_) symbol) + (passed-starting-line? (_type_ vector vector) symbol) + (recording-finished? (_type_ vector vector) symbol) + (draw-starting-line (_type_ vector vector) none) + (draw-recorded-path (_type_) none) + (pilot-recorder-method-27 (_type_) none) + (record-input-sample! (_type_ pilrec-sample) pilrec-sample-flag) + (lerp-samples! (_type_ pilrec-sample pilrec-sample pilrec-sample float time-frame) none) + (save-to-db! (_type_) symbol) + ) + ) + + +;; WARN: Return type mismatch int vs object. +(defun delete-race-path ((arg0 int) (arg1 int)) + (let ((s5-0 (-> *race-info-array* arg0 path-group-name))) + (format #t "Attempting to delete path ~s.[~d]~%" s5-0 arg1) + (let ((s4-0 (clear *temp-string*))) + (format s4-0 "delete from race_path where race='~s' and path=~d~%" s5-0 arg1) + (let ((a2-2 (sql-query s4-0))) + (cond + ((= (-> a2-2 content-type) 'modify) + (format #t "Success!~%") + ) + (else + (format 0 "ERROR: sql: modify error ~A~%" a2-2) + (return (the-as object #f)) + ) + ) + ) + ) + ) + 0 + ) + +(define *pilot-recorder* (the-as (pointer pilot-recorder) #f)) + +;; WARN: Return type mismatch int vs pilrec-sample-flag. +(defmethod record-input-sample! ((this pilot-recorder) (arg0 pilrec-sample)) + (let ((v1-0 *target*)) + (the-as + pilrec-sample-flag + (when v1-0 + (let ((v1-1 (-> v1-0 pilot))) + (the-as + pilrec-sample-flag + (when (nonzero? v1-1) + (let ((v1-3 (handle->process (-> v1-1 vehicle)))) + (the-as + pilrec-sample-flag + (when v1-3 + (set-time! (-> arg0 sample-time)) + (let ((v1-5 (-> (the-as vehicle v1-3) rbody))) + (vector-copy! (-> arg0 pos) (-> v1-5 position)) + (quaternion-copy! (-> arg0 quat) (the-as quaternion (-> v1-5 rot))) + ) + (set! (-> arg0 stick-x) (analog-input (the-as int (-> *cpad-list* cpads 0 leftx)) 128.0 48.0 110.0 -1.0)) + (set! (-> arg0 stick-y) (analog-input (the-as int (-> *cpad-list* cpads 0 lefty)) 128.0 48.0 110.0 -1.0)) + (set! (-> arg0 throttle) (fmin 1.0 (* 0.023529412 (the float (-> *cpad-list* cpads 0 abutton 6))))) + (let ((flag (pilrec-sample-flag))) + (if (>= (fmin 1.0 (* 0.023529412 (the float (-> *cpad-list* cpads 0 abutton 7)))) 0.5) + (set! flag (the-as pilrec-sample-flag (logior (the-as int flag) (pilrec-sample-flag square)))) + ) + (if (cpad-hold? 0 l1) + (set! flag (the-as pilrec-sample-flag (logior (the-as int flag) (pilrec-sample-flag l1)))) + ) + (if (>= (fmin 1.0 (* 0.023529412 (the float (-> *cpad-list* cpads 0 abutton 6)))) 0.5) + (set! flag (the-as pilrec-sample-flag (logior (the-as int flag) (pilrec-sample-flag x)))) + ) + (set! (-> arg0 flags) (the-as pilrec-sample-flag flag)) + flag + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + +;; WARN: Return type mismatch pilrec-sample-flag vs none. +(defmethod lerp-samples! ((this pilot-recorder) + (arg0 pilrec-sample) + (arg1 pilrec-sample) + (arg2 pilrec-sample) + (arg3 float) + (arg4 time-frame) + ) + (set! (-> arg0 sample-time) arg4) + (vector-lerp! (-> arg0 pos) (-> arg1 pos) (-> arg2 pos) arg3) + (quaternion-slerp! (-> arg0 quat) (-> arg1 quat) (-> arg2 quat) arg3) + (set! (-> arg0 stick-x) (lerp (-> arg1 stick-x) (-> arg2 stick-x) arg3)) + (set! (-> arg0 stick-y) (lerp (-> arg1 stick-y) (-> arg2 stick-y) arg3)) + (set! (-> arg0 throttle) (lerp (-> arg1 throttle) (-> arg2 throttle) arg3)) + (if (>= arg3 0.5) + (set! (-> arg0 flags) (-> arg2 flags)) + (set! (-> arg0 flags) (-> arg1 flags)) + ) + (none) + ) + +(defmethod passed-starting-line? ((this pilot-recorder) (arg0 vector) (arg1 vector)) + (when (and (< (vector4-dot arg0 (the-as vector (-> this start-record-plane))) 0.0) + (>= (vector4-dot arg1 (the-as vector (-> this start-record-plane))) 0.0) + ) + (let ((s4-0 (new 'stack-no-clear 'vector))) + (vector-! s4-0 arg1 arg0) + (let ((f0-4 (intersect-ray-plane arg0 s4-0 (-> this start-record-center) (-> this start-record-plane))) + (a0-5 (new 'stack-no-clear 'vector)) + ) + (vector+float*! a0-5 arg0 s4-0 f0-4) + (let ((f0-5 184320.0)) + (if (>= (* f0-5 f0-5) (vector-vector-xz-distance-squared a0-5 (-> this start-record-center))) + #t + ) + ) + ) + ) + ) + ) + +(defmethod recording-finished? ((this pilot-recorder) (arg0 vector) (arg1 vector)) + (when (and (< (vector4-dot arg0 (the-as vector (-> this finish-record-plane))) 0.0) + (>= (vector4-dot arg1 (the-as vector (-> this finish-record-plane))) 0.0) + ) + (let ((s4-0 (new 'stack-no-clear 'vector))) + (vector-! s4-0 arg1 arg0) + (let ((f0-4 (intersect-ray-plane arg0 s4-0 (-> this finish-record-center) (-> this finish-record-plane))) + (a0-5 (new 'stack-no-clear 'vector)) + ) + (vector+float*! a0-5 arg0 s4-0 f0-4) + (let ((f0-5 184320.0)) + (if (>= (* f0-5 f0-5) (vector-vector-xz-distance-squared a0-5 (-> this finish-record-center))) + #t + ) + ) + ) + ) + ) + ) + +(defmethod draw-starting-line ((this pilot-recorder) (arg0 vector) (arg1 vector)) + (let ((gp-0 (new 'stack-no-clear 'inline-array 'vector 2))) + (vector-copy! (-> gp-0 0) arg0) + (vector-float*! (-> gp-0 0) (-> gp-0 0) 184320.0) + (vector-copy! (-> gp-0 1) (-> gp-0 0)) + (vector-rotate-around-y! (-> gp-0 0) (-> gp-0 0) 16384.0) + (vector-rotate-around-y! (-> gp-0 1) (-> gp-0 1) -16384.0) + (vector+! (-> gp-0 0) (-> gp-0 0) arg1) + (vector+! (-> gp-0 1) (-> gp-0 1) arg1) + (+! (-> gp-0 0 y) 1638.4) + (+! (-> gp-0 1 y) 1638.4) + (countdown (s5-1 10) + (add-debug-line + #t + (bucket-id debug-no-zbuf1) + (-> gp-0 0) + (-> gp-0 1) + (new 'static 'rgba :g #x80 :a #x80) + #f + (the-as rgba -1) + ) + (+! (-> gp-0 0 y) 1638.4) + (+! (-> gp-0 1 y) 1638.4) + ) + ) + 0 + (none) + ) + +(defmethod draw-recorded-path ((this pilot-recorder)) + (let ((s2-0 0) + (s5-0 1) + (s4-0 (+ (-> this sample-count) -1)) + (s3-0 (new 'stack-no-clear 'vector)) + ) + (vector-copy! s3-0 (math-camera-pos)) + (while (< s2-0 s4-0) + (let* ((s2-1 (-> this samples s2-0)) + (s1-1 (-> this samples s5-0)) + (f0-0 (vector-vector-distance-squared (-> s2-1 pos) s3-0)) + (f1-0 819200.0) + ) + (if (< f0-0 (* f1-0 f1-0)) + (add-debug-line + #t + (bucket-id debug) + (-> s2-1 pos) + (-> s1-1 pos) + (new 'static 'rgba :r #xff :a #x80) + #f + (new 'static 'rgba :r #xff :g #xff :b #xff :a #x80) + ) + ) + ) + (set! s2-0 s5-0) + (set! s5-0 (min (+ s5-0 1) s4-0)) + ) + ) + (format + *stdcon* + "recorded path ~d time ~5,,3f~%" + (-> this path-num) + (* 0.016666668 (the float (-> this sample-count))) + ) + 0 + (none) + ) + +;; WARN: Return type mismatch symbol vs none. +(defmethod pilot-recorder-method-27 ((this pilot-recorder)) + (let ((gp-0 (new 'stack-no-clear 'matrix)) + (s5-0 (new 'static 'boxed-array :type vector + (new 'static 'vector :y 4096.0 :w 1.0) + (new 'static 'vector :x 4096.0 :w 1.0) + (new 'static 'vector :x 4096.0 :w 1.0) + (new 'static 'vector :y -4096.0 :w 1.0) + (new 'static 'vector :y -4096.0 :w 1.0) + (new 'static 'vector :x -4096.0 :w 1.0) + (new 'static 'vector :x -4096.0 :w 1.0) + (new 'static 'vector :y 4096.0 :w 1.0) + (new 'static 'vector :y 4096.0 :w 1.0) + (new 'static 'vector :z 40960.0 :w 1.0) + (new 'static 'vector :x 4096.0 :w 1.0) + (new 'static 'vector :z 40960.0 :w 1.0) + (new 'static 'vector :y -4096.0 :w 1.0) + (new 'static 'vector :z 40960.0 :w 1.0) + (new 'static 'vector :x -4096.0 :w 1.0) + (new 'static 'vector :z 40960.0 :w 1.0) + ) + ) + ) + (vector-! (-> gp-0 fvec) (-> this samples 1 pos) (-> this samples 0 pos)) + (vector-normalize! (-> gp-0 fvec) 1.0) + (vector-cross! (-> gp-0 rvec) *up-vector* (-> gp-0 fvec)) + (vector-normalize! (-> gp-0 rvec) 1.0) + (vector-cross! (-> gp-0 uvec) (-> gp-0 fvec) (-> gp-0 rvec)) + (vector-normalize! (-> gp-0 uvec) 1.0) + (vector-copy! (-> gp-0 trans) (-> this samples 0 pos)) + (let ((s4-1 0)) + (while (< s4-1 (-> s5-0 length)) + (let ((a1-9 (-> s5-0 s4-1)) + (s3-0 (-> s5-0 (+ s4-1 1))) + (s2-0 (new 'stack-no-clear 'vector)) + (s1-0 (new 'stack-no-clear 'vector)) + ) + (+! s4-1 2) + (vector-matrix*! s2-0 a1-9 gp-0) + (vector-matrix*! s1-0 s3-0 gp-0) + (add-debug-line + #t + (bucket-id debug) + s2-0 + s1-0 + (new 'static 'rgba :r #xff :g #xff :b #xff :a #x80) + #f + (the-as rgba -1) + ) + ) + ) + ) + ) + (none) + ) + +(defmethod pilot-recorder-method-22 ((this pilot-recorder)) + (let* ((s5-0 (-> this samples 0)) + (s4-0 (+ (-> this sample-count) -45)) + (s3-0 (-> this samples s4-0)) + (s2-0 (new 'stack-no-clear 'inline-array 'vector 4)) + ) + (vector-! (-> s2-0 0) (-> s3-0 pos) (-> this samples (+ s4-0 -1) pos)) + (vector-float*! (-> s2-0 0) (-> s2-0 0) 60.0) + (vector-! (-> s2-0 1) (-> this samples 1 pos) (-> s5-0 pos)) + (vector-float*! (-> s2-0 1) (-> s2-0 1) 60.0) + (vector-float*! (-> s2-0 2) (-> s3-0 pos) -3.0) + (vector+float*! (-> s2-0 2) (-> s2-0 2) (-> s5-0 pos) 3.0) + (vector+float*! (-> s2-0 2) (-> s2-0 2) (-> s2-0 0) -2.0) + (vector-! (-> s2-0 2) (-> s2-0 2) (-> s2-0 1)) + (vector+! (-> s2-0 3) (-> s2-0 1) (-> s2-0 0)) + (vector+float*! (-> s2-0 3) (-> s2-0 3) (-> s5-0 pos) -2.0) + (vector+float*! (-> s2-0 3) (-> s2-0 3) (-> s3-0 pos) 2.0) + (let ((s1-0 1) + (s0-0 (new 'stack-no-clear 'inline-array 'vector 4)) + ) + (while (< s1-0 45) + (let ((f0-8 (* 0.022222223 (the float s1-0))) + (v1-24 (-> this samples (+ s4-0 s1-0))) + ) + (vector+float*! (-> s0-0 1) (-> s3-0 pos) (-> s2-0 0) f0-8) + (vector+float*! (-> s0-0 1) (-> s0-0 1) (-> s2-0 2) (* f0-8 f0-8)) + (vector+float*! (-> s0-0 1) (-> s0-0 1) (-> s2-0 3) (* f0-8 f0-8 f0-8)) + (vector-copy! (-> v1-24 pos) (-> s0-0 1)) + (quaternion-slerp! (-> v1-24 quat) (-> s3-0 quat) (-> s5-0 quat) f0-8) + ) + (+! s1-0 1) + ) + ) + ) + #f + ) + +(defmethod save-to-db! ((this pilot-recorder)) + (local-vars (sv-16 pilrec-sample-flag)) + (let ((gp-0 (clear *temp-string*)) + (s4-0 (-> *race-info-array* *select-race* path-group-name)) + (s3-0 *select-race-path*) + ) + (format gp-0 "delete from race_path where race='~s' and path=~d~%" s4-0 s3-0) + (let ((a2-1 (sql-query gp-0))) + (when (!= (-> a2-1 content-type) 'modify) + (format 0 "ERROR: sql: modify error ~A for ~A~%" a2-1 this) + (return #f) + ) + ) + (dotimes (s2-0 (-> this sample-count)) + (let ((s1-0 (-> this samples s2-0))) + (clear gp-0) + (format gp-0 "insert into race_path set ") + (format gp-0 "race='~s'," s4-0) + (format gp-0 "path=~d," s3-0) + (format gp-0 "pos_x=~f," (/ (-> s1-0 pos x) METER_LENGTH)) + (format gp-0 "pos_y=~f," (/ (-> s1-0 pos y) METER_LENGTH)) + (format gp-0 "pos_z=~f," (/ (-> s1-0 pos z) METER_LENGTH)) + (format gp-0 "quat_x=~f," (-> s1-0 quat x)) + (format gp-0 "quat_y=~f," (-> s1-0 quat y)) + (format gp-0 "quat_z=~f," (-> s1-0 quat z)) + (format gp-0 "quat_w=~f," (-> s1-0 quat w)) + (set! sv-16 (-> s1-0 flags)) + (let ((s0-0 #f)) + (format gp-0 "flags='") + (when (logtest? sv-16 (pilrec-sample-flag square)) + (set! s0-0 (cond + (s0-0 + (format gp-0 ",") + s0-0 + ) + (else + #t + ) + ) + ) + (format gp-0 "break") + ) + (when (logtest? sv-16 (pilrec-sample-flag l1)) + (set! s0-0 (cond + (s0-0 + (format gp-0 ",") + s0-0 + ) + (else + #t + ) + ) + ) + (format gp-0 "jump") + ) + (when (logtest? sv-16 (pilrec-sample-flag x)) + (if s0-0 + (format gp-0 ",") + #t + ) + (format gp-0 "throttle") + ) + ) + (format gp-0 "',") + (format gp-0 "stick_x=~f," (-> s1-0 stick-x)) + (format gp-0 "stick_y=~f," (-> s1-0 stick-y)) + (format gp-0 "throttle=~f~%" (-> s1-0 throttle)) + ) + (let ((a2-14 (sql-query gp-0))) + (when (!= (-> a2-14 content-type) 'modify) + (format 0 "ERROR: sql: modify error ~A for ~A~%" a2-14 this) + (return #f) + ) + ) + ) + ) + #t + ) + +(defstate idle (pilot-recorder) + :virtual #t + :trans (behavior () + (let ((a1-0 (new 'stack-no-clear 'pilrec-sample))) + (if (record-input-sample! self a1-0) + (go-virtual active) + ) + ) + ) + :code sleep-code + ) + +(defstate active (pilot-recorder) + :virtual #t + :enter (behavior () + (let ((gp-0 (new 'stack-no-clear 'pilrec-sample))) + (if (not (record-input-sample! self gp-0)) + (go-virtual die-fast) + ) + (vector-copy! (-> self prev-pos) (-> gp-0 pos)) + ) + ) + :trans (behavior () + (let ((gp-0 (new 'stack-no-clear 'pilrec-sample))) + (if (not (record-input-sample! self gp-0)) + (go-virtual die-fast) + ) + (if (passed-starting-line? self (-> self prev-pos) (-> gp-0 pos)) + (go-virtual recording) + (vector-copy! (-> self prev-pos) (-> gp-0 pos)) + ) + ) + (if (>= (mod (current-time) 240) 120) + (format *stdcon* " Cross starting line to begin recording.~%") + ) + (draw-starting-line self (-> self start-record-plane) (-> self start-record-center)) + ) + :code sleep-code + ) + +(defstate recording (pilot-recorder) + :virtual #t + :enter (behavior () + (set-time! (-> self start-time)) + (set! (-> self samples) (-> *pilot-recorder-samples* samples)) + (let ((gp-0 (-> self samples 0))) + (if (not (record-input-sample! self gp-0)) + (go-virtual die-fast) + ) + (set! (-> self sample-count) 1) + (vector-copy! (-> self prev-pos) (-> gp-0 pos)) + ) + ) + :trans (behavior () + (let ((gp-0 (new 'stack-no-clear 'pilrec-sample))) + (if (not (record-input-sample! self gp-0)) + (go-virtual die-fast) + ) + (if (recording-finished? self (-> self prev-pos) (-> gp-0 pos)) + (go-virtual finished) + (vector-copy! (-> self prev-pos) (-> gp-0 pos)) + ) + (let* ((s5-0 (-> self samples (+ (-> self sample-count) -1))) + (s4-0 (- (-> gp-0 sample-time) (-> s5-0 sample-time))) + (s3-0 0) + ) + (until #f + (+! s3-0 5) + (if (< s4-0 s3-0) + (goto cfg-12) + ) + (let ((s2-0 (-> self sample-count))) + (if (>= s2-0 #x3840) + (go-virtual fail-full) + ) + (lerp-samples! + self + (-> self samples s2-0) + s5-0 + gp-0 + (/ (the float s3-0) (the float s4-0)) + (+ (-> s5-0 sample-time) s3-0) + ) + (set! (-> self sample-count) (+ s2-0 1)) + ) + ) + ) + ) + #f + (label cfg-12) + (if (>= (mod (current-time) 240) 120) + (format *stdcon* " Recording~%") + ) + (draw-starting-line self (-> self finish-record-plane) (-> self finish-record-center)) + (if (time-elapsed? (-> self start-time) (seconds 4)) + (pilot-recorder-method-27 self) + ) + 0 + ) + :code sleep-code + ) + +(defstate finished (pilot-recorder) + :virtual #t + :enter (behavior () + (set-time! (-> self state-time)) + (change-parent self *entity-pool*) + (if (logtest? (-> self mesh flags) (race-mesh-flag rmf0)) + (pilot-recorder-method-22 self) + ) + ) + :trans (behavior () + (when (time-elapsed? (-> self state-time) (seconds 0.5)) + (cond + ((cpad-pressed? 1 triangle) + (go-virtual die-fast) + ) + ((cpad-pressed? 1 x) + (go-virtual save) + ) + ) + ) + (if (>= (mod (current-time) 240) 120) + (format *stdcon* " Finished.~%") + (format *stdcon* "~%") + ) + (format *stdcon* " Press pad1 X to save, or triangle to discard.~%") + (draw-recorded-path self) + 0 + ) + :code sleep-code + ) + +(defstate save (pilot-recorder) + :virtual #t + :enter (behavior () + (set-time! (-> self state-time)) + (if (not (save-to-db! self)) + (go-virtual fail-save) + ) + ) + :trans (behavior () + (if (time-elapsed? (-> self state-time) (seconds 4)) + (go-virtual die-fast) + ) + (if (>= (mod (current-time) 240) 120) + (format *stdcon* " Save complete!~%") + ) + ) + :code sleep-code + ) + +(defstate fail-save (pilot-recorder) + :virtual #t + :enter (behavior () + (set-time! (-> self state-time)) + ) + :trans (behavior () + (if (time-elapsed? (-> self state-time) (seconds 15)) + (go-virtual die-fast) + ) + (if (>= (mod (current-time) 60) 30) + (format *stdcon* " SAVE FAILED!!!~%") + ) + ) + :code sleep-code + ) + +(defstate fail-full (pilot-recorder) + :virtual #t + :enter (behavior () + (set-time! (-> self state-time)) + ) + :trans (behavior () + (if (time-elapsed? (-> self state-time) (seconds 15)) + (go-virtual die-fast) + ) + (if (>= (mod (current-time) 60) 30) + (format *stdcon* " FAILED!!! BUFFER FULL!!!~%") + ) + ) + :code sleep-code + ) + +(defstate die-fast (pilot-recorder) + :virtual #t + :code nothing + ) + +(defbehavior pilot-recorder-init-by-other pilot-recorder ((arg0 uint) (arg1 int)) + (set! (-> self select-race) arg0) + (set! (-> self path-num) arg1) + (let ((v1-2 (-> *race-info-array* arg0))) + (set! (-> self info) v1-2) + (set! (-> self mesh) (-> v1-2 mesh)) + (vector-copy! (-> self start-record-center) (-> v1-2 start-sphere)) + (set! (-> self start-record-plane quad) (-> v1-2 start-dir quad)) + (set! (-> self start-record-plane w) + (- (vector-dot (the-as vector (-> self start-record-plane)) (-> self start-record-center))) + ) + (vector-copy! (-> self finish-record-center) (-> v1-2 finish-sphere)) + (set! (-> self finish-record-plane quad) (-> v1-2 finish-dir quad)) + ) + (set! (-> self finish-record-plane w) + (- (vector-dot (the-as vector (-> self finish-record-plane)) (-> self finish-record-center))) + ) + (set! *pilot-recorder* (the-as (pointer pilot-recorder) self)) + (go-virtual idle) + ) + +(defun start-pilot-recorder () + (process-spawn pilot-recorder *select-race* *select-race-path* :name "pilot-recorder" :to *target*) + 0 + (none) + ) diff --git a/goal_src/jak3/levels/desert/race/course-race.gc b/goal_src/jak3/levels/desert/race/course-race.gc index 968b2e3af1..7109008dd4 100644 --- a/goal_src/jak3/levels/desert/race/course-race.gc +++ b/goal_src/jak3/levels/desert/race/course-race.gc @@ -12,8 +12,6 @@ ) ) -(define-extern start-pilot-recorder (function none)) - ;; DECOMP BEGINS (define *v-snake-racer-constants* (new 'static 'rigid-body-vehicle-constants)) diff --git a/test/decompiler/reference/jak3/engine/camera/cam-debug_REF.gc b/test/decompiler/reference/jak3/engine/camera/cam-debug_REF.gc new file mode 100644 index 0000000000..a881e7cd66 --- /dev/null +++ b/test/decompiler/reference/jak3/engine/camera/cam-debug_REF.gc @@ -0,0 +1,1811 @@ +;;-*-Lisp-*- +(in-package goal) + +;; this file is debug only +(declare-file (debug)) + +;; failed to figure out what this is: +(when (or (not *camera-old-cpu*) (zero? *camera-old-cpu*)) + (set! *camera-old-cpu* 0) + 0 + ) + +;; failed to figure out what this is: +(when (or (not *camera-old-vu*) (zero? *camera-old-vu*)) + (set! *camera-old-vu* 0) + 0 + ) + +;; failed to figure out what this is: +(when (or (not *camera-old-tfrag-bytes*) (zero? *camera-old-tfrag-bytes*)) + (set! *camera-old-tfrag-bytes* 0) + 0 + ) + +;; definition (perm) for symbol *camera-old-level*, type string +(define-perm *camera-old-level* string (new 'global 'string 128 (the-as string #f))) + +;; definition (perm) for symbol *camera-old-stat-string-tfrag*, type string +(define-perm *camera-old-stat-string-tfrag* string (new 'global 'string 128 (the-as string #f))) + +;; definition (perm) for symbol *camera-old-stat-string-tfrag-near*, type string +(define-perm *camera-old-stat-string-tfrag-near* string (new 'global 'string 128 (the-as string #f))) + +;; definition (perm) for symbol *camera-old-stat-string-total*, type string +(define-perm *camera-old-stat-string-total* string (new 'global 'string 128 (the-as string #f))) + +;; definition of type cam-dbg-scratch +(deftype cam-dbg-scratch (structure) + ((linevec4w vector4w 2 :inline) + (color vector4w :inline) + (plotvec vector4w 2 :inline) + (linevec vector4w 2 :inline) + (rel-vec vector :inline) + (sphere-v-start vector :inline) + (sphere-v-end vector :inline) + (sphere-v-down vector :inline) + (sphere-vec vector :inline) + (crossvec vector 3 :inline) + (bboxvec vector 6 :inline) + (fov-vv vector 4 :inline) + (fov-src vector :inline) + (fov-dest vector :inline) + (fov-vert vector :inline) + (fov-horz vector :inline) + ) + ) + +;; definition for method 3 of type cam-dbg-scratch +(defmethod inspect ((this cam-dbg-scratch)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'cam-dbg-scratch) + (format #t "~1Tlinevec4w: ~`vector`P~%" (-> this linevec4w)) + (format #t "~1Tcolor: ~`vector`P~%" (-> this color)) + (format #t "~1Tplotvec: ~`vector`P~%" (-> this plotvec)) + (format #t "~1Tlinevec: ~`vector`P~%" (-> this linevec)) + (format #t "~1Trel-vec: ~`vector`P~%" (-> this rel-vec)) + (format #t "~1Tsphere-v-start: ~`vector`P~%" (-> this sphere-v-start)) + (format #t "~1Tsphere-v-end: ~`vector`P~%" (-> this sphere-v-end)) + (format #t "~1Tsphere-v-down: ~`vector`P~%" (-> this sphere-v-down)) + (format #t "~1Tsphere-vec: ~`vector`P~%" (-> this sphere-vec)) + (format #t "~1Tcrossvec: ~`vector`P~%" (-> this crossvec)) + (format #t "~1Tbboxvec: ~`vector`P~%" (-> this bboxvec)) + (format #t "~1Tfov-vv: ~`vector`P~%" (-> this fov-vv)) + (format #t "~1Tfov-src: ~`vector`P~%" (-> this fov-src)) + (format #t "~1Tfov-dest: ~`vector`P~%" (-> this fov-dest)) + (format #t "~1Tfov-vert: ~`vector`P~%" (-> this fov-vert)) + (format #t "~1Tfov-horz: ~`vector`P~%" (-> this fov-horz)) + (label cfg-4) + this + ) + +;; definition for function cam-slave-options->string +;; WARN: Return type mismatch object vs string. +(defun cam-slave-options->string ((arg0 cam-slave-options) (arg1 object)) + (if (= (logand arg0 (cam-slave-options SAME_SIDE)) (cam-slave-options SAME_SIDE)) + (format arg1 "SAME_SIDE ") + ) + (if (= (logand (cam-slave-options GUN_CAM) arg0) (cam-slave-options GUN_CAM)) + (format arg1 "GUN_CAM ") + ) + (if (= (logand (cam-slave-options BOMBBOT) arg0) (cam-slave-options BOMBBOT)) + (format arg1 "BOMBBOT ") + ) + (if (= (logand arg0 (cam-slave-options STICKY_ANGLE)) (cam-slave-options STICKY_ANGLE)) + (format arg1 "STICKY_ANGLE ") + ) + (if (= (logand arg0 (cam-slave-options FIND_HIDDEN_TARGET)) (cam-slave-options FIND_HIDDEN_TARGET)) + (format arg1 "FIND_HIDDEN_TARGET ") + ) + (if (= (logand (cam-slave-options RAPID_TRACKING) arg0) (cam-slave-options RAPID_TRACKING)) + (format arg1 "RAPID_TRACKING ") + ) + (if (= (logand arg0 (cam-slave-options SHRINK_MAX_ANGLE)) (cam-slave-options SHRINK_MAX_ANGLE)) + (format arg1 "SHRINK_MAX_ANGLE ") + ) + (if (= (logand arg0 (cam-slave-options JUMP_PITCHES)) (cam-slave-options JUMP_PITCHES)) + (format arg1 "JUMP_PITCHES ") + ) + (if (= (logand arg0 (cam-slave-options LINE_OF_SIGHT)) (cam-slave-options LINE_OF_SIGHT)) + (format arg1 "LINE_OF_SIGHT ") + ) + (if (= (logand arg0 (cam-slave-options PLAYER_MOVING_CAMERA)) (cam-slave-options PLAYER_MOVING_CAMERA)) + (format arg1 "PLAYER_MOVING_CAMERA ") + ) + (if (= (logand (cam-slave-options ALLOW_SHIFT_BUTTONS) arg0) (cam-slave-options ALLOW_SHIFT_BUTTONS)) + (format arg1 "ALLOW_SHIFT_BUTTONS ") + ) + (if (= (logand arg0 (cam-slave-options NO_ROTATE)) (cam-slave-options NO_ROTATE)) + (format arg1 "NO_ROTATE ") + ) + (if (= (logand (cam-slave-options WIDE_FOV) arg0) (cam-slave-options WIDE_FOV)) + (format arg1 "WIDE_FOV ") + ) + (if (= (logand arg0 (cam-slave-options MOVE_SPHERICAL)) (cam-slave-options MOVE_SPHERICAL)) + (format arg1 "MOVE_SPHERICAL ") + ) + (if (= (logand arg0 (cam-slave-options DRAG)) (cam-slave-options DRAG)) + (format arg1 "DRAG ") + ) + (if (= (logand arg0 (cam-slave-options MOVEMENT_BLOCKED)) (cam-slave-options MOVEMENT_BLOCKED)) + (format arg1 "MOVEMENT_BLOCKED ") + ) + (if (= (logand (cam-slave-options BLOCK_RIGHT_STICK) arg0) (cam-slave-options BLOCK_RIGHT_STICK)) + (format arg1 "BLOCK_RIGHT_STICK ") + ) + (if (= (logand arg0 (cam-slave-options COLLIDE)) (cam-slave-options COLLIDE)) + (format arg1 "COLLIDE ") + ) + (if (= (logand arg0 (cam-slave-options ALLOW_Z_ROT)) (cam-slave-options ALLOW_Z_ROT)) + (format arg1 "ALLOW_Z_ROT ") + ) + (if (= (logand (cam-slave-options JUMP_LAG) arg0) (cam-slave-options JUMP_LAG)) + (format arg1 "JUMP_LAG ") + ) + (if (= (logand arg0 (cam-slave-options BIKE_MODE)) (cam-slave-options BIKE_MODE)) + (format arg1 "BIKE_MODE ") + ) + (if (= (logand (cam-slave-options EASE_SPLINE_IDX) arg0) (cam-slave-options EASE_SPLINE_IDX)) + (format arg1 "EASE_SPLINE_IDX ") + ) + (if (= (logand arg0 (cam-slave-options GOTO_GOOD_POINT)) (cam-slave-options GOTO_GOOD_POINT)) + (format arg1 "GOTO_GOOD_POINT ") + ) + (if (= (logand arg0 (cam-slave-options BUTT_CAM)) (cam-slave-options BUTT_CAM)) + (format arg1 "BUTT_CAM ") + ) + (if (= (logand (cam-slave-options VERTICAL_FOLLOW_MATCHES_CAMERA) arg0) + (cam-slave-options VERTICAL_FOLLOW_MATCHES_CAMERA) + ) + (format arg1 "VERTICAL_FOLLOW_MATCHES_CAMERA ") + ) + (if (= (logand (cam-slave-options HAVE_BUTT_HANDLE) arg0) (cam-slave-options HAVE_BUTT_HANDLE)) + (format arg1 "HAVE_BUTT_HANDLE ") + ) + (the-as string arg1) + ) + +;; definition for function cam-index-options->string +;; WARN: Return type mismatch object vs string. +(defun cam-index-options->string ((arg0 cam-index-options) (arg1 object)) + (if (= (logand arg0 (cam-index-options RADIAL)) (cam-index-options RADIAL)) + (format arg1 "RADIAL ") + ) + (if (= (logand arg0 (cam-index-options SPHERICAL)) (cam-index-options SPHERICAL)) + (format arg1 "SPHERICAL ") + ) + (the-as string arg1) + ) + +;; definition for function slave-los-state->string +(defun slave-los-state->string ((arg0 slave-los-state)) + (case arg0 + (((slave-los-state between)) + "between" + ) + (((slave-los-state none)) + "none" + ) + (((slave-los-state cw)) + "cw" + ) + (((slave-los-state ccw)) + "ccw" + ) + (else + "*unknown*" + ) + ) + ) + +;; definition for function cam-line-dma +;; INFO: Used lq/sq +(defun cam-line-dma () + (with-dma-buffer-add-bucket ((v1-5 (-> *display* frames (-> *display* on-screen) debug-buf)) + (bucket-id debug-no-zbuf1) + ) + (let ((a0-1 (the-as object (-> v1-5 base)))) + (let* ((a1-0 v1-5) + (a3-0 (the-as object (-> a1-0 base))) + ) + (set! (-> (the-as dma-packet a3-0) dma) (new 'static 'dma-tag :id (dma-tag-id cnt))) + (set! (-> (the-as dma-packet a3-0) vif0) (new 'static 'vif-tag)) + (set! (-> (the-as dma-packet a3-0) vif1) (new 'static 'vif-tag :cmd (vif-cmd direct) :msk #x1)) + (set! (-> a1-0 base) (&+ (the-as pointer a3-0) 16)) + ) + (let* ((a1-1 v1-5) + (a3-2 (the-as object (-> a1-1 base))) + ) + (set! (-> (the-as gs-gif-tag a3-2) tag) + (new 'static 'gif-tag64 + :nloop #x1 + :eop #x1 + :pre #x1 + :prim (new 'static 'gs-prim :prim (gs-prim-type line) :iip #x1 :abe #x1) + :nreg #x4 + ) + ) + (set! (-> (the-as gs-gif-tag a3-2) regs) (new 'static 'gif-tag-regs + :regs0 (gif-reg-id rgbaq) + :regs1 (gif-reg-id xyzf2) + :regs2 (gif-reg-id rgbaq) + :regs3 (gif-reg-id xyzf2) + ) + ) + (set! (-> a1-1 base) (&+ (the-as pointer a3-2) 16)) + ) + (let* ((a1-2 v1-5) + (a3-4 (-> a1-2 base)) + ) + (set! (-> (the-as (pointer uint128) a3-4) 0) (-> (the-as vector (+ 32 #x70000000)) quad)) + (set! (-> (the-as (pointer uint128) a3-4) 1) (-> (the-as vector (+ #x70000000 0)) quad)) + (set! (-> a1-2 base) (&+ a3-4 32)) + ) + (let* ((a3-6 v1-5) + (a1-3 (-> a3-6 base)) + ) + (set! (-> (the-as (pointer uint128) a1-3) 0) (-> (the-as vector (+ 32 #x70000000)) quad)) + (set! (-> (the-as (pointer uint128) a1-3) 1) (-> (the-as vector (+ 16 #x70000000)) quad)) + (set! (-> a3-6 base) (&+ a1-3 32)) + ) + (let ((a3-10 (/ (the-as int (+ (- -16 (the-as int a0-1)) (the-as int (-> v1-5 base)))) 16))) + (cond + ((nonzero? a3-10) + (logior! (-> (the-as dma-packet a0-1) dma) (shr (shl a3-10 48) 48)) + (logior! (-> (the-as (pointer uint64) a0-1) 1) (shl (shr (shl a3-10 48) 48) 32)) + ) + (else + (set! (-> v1-5 base) (the-as (pointer uint64) a0-1)) + ) + ) + ) + ) + ) + ) + +;; definition for function camera-line2d +(defun camera-line2d ((arg0 vector4w) (arg1 vector4w)) + (set! (-> (the-as cam-dbg-scratch #x70000000) linevec4w 0 x) (* (+ (-> arg0 x) 1792) 16)) + (set! (-> (the-as cam-dbg-scratch #x70000000) linevec4w 0 y) + (* (- 2256 (-> (the-as cam-dbg-scratch arg0) linevec4w 0 y)) 16) + ) + (set! (-> (the-as cam-dbg-scratch #x70000000) linevec4w 0 z) #x7fffff) + (set! (-> (the-as cam-dbg-scratch #x70000000) linevec4w 1 x) + (* (+ (-> (the-as cam-dbg-scratch arg1) linevec4w 0 x) 1792) 16) + ) + (set! (-> (the-as cam-dbg-scratch #x70000000) linevec4w 1 y) + (* (- 2256 (-> (the-as cam-dbg-scratch arg1) linevec4w 0 y)) 16) + ) + (set! (-> (the-as cam-dbg-scratch #x70000000) linevec4w 1 z) #x7fffff) + (cam-line-dma) + ) + +;; definition for function camera-plot-float-func +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs none. +(defun camera-plot-float-func ((arg0 float) (arg1 float) (arg2 float) (arg3 float) (arg4 (function float float)) (arg5 vector4w)) + (let ((f30-0 (- arg1 arg0)) + (f24-0 (- arg3 arg2)) + ) + 0.0 + 0.0 + (let ((f28-0 (/ 200.0 f24-0)) + (f26-0 (/ 400.0 f30-0)) + ) + (set! (-> (the-as cam-dbg-scratch #x70000000) color x) 128) + (set! (-> (the-as cam-dbg-scratch #x70000000) color y) 128) + (set! (-> (the-as cam-dbg-scratch #x70000000) color z) 128) + (set! (-> (the-as cam-dbg-scratch #x70000000) color w) 128) + (when (and (< arg0 0.0) (< 0.0 arg1)) + (set! (-> (the-as cam-dbg-scratch #x70000000) plotvec 0 x) + (+ (the int (* f26-0 f30-0 (/ (- arg0) f30-0))) 20) + ) + (set! (-> (the-as cam-dbg-scratch #x70000000) plotvec 0 y) 20) + (set! (-> (the-as cam-dbg-scratch #x70000000) plotvec 1 x) + (-> (the-as cam-dbg-scratch #x70000000) plotvec 0 x) + ) + (set! (-> (the-as cam-dbg-scratch #x70000000) plotvec 1 y) (+ (the int (* f28-0 f24-0)) 20)) + (camera-line2d (-> (the-as cam-dbg-scratch #x70000000) plotvec 0) (the-as vector4w (+ 64 #x70000000))) + ) + (when (and (< arg2 0.0) (< 0.0 arg3)) + (set! (-> (the-as cam-dbg-scratch #x70000000) plotvec 0 x) 20) + (set! (-> (the-as cam-dbg-scratch #x70000000) plotvec 0 y) + (+ (the int (* f28-0 f24-0 (/ (- arg2) f24-0))) 20) + ) + (set! (-> (the-as cam-dbg-scratch #x70000000) plotvec 1 x) (+ (the int (* f26-0 f30-0)) 20)) + (set! (-> (the-as cam-dbg-scratch #x70000000) plotvec 1 y) + (-> (the-as cam-dbg-scratch #x70000000) plotvec 0 y) + ) + (camera-line2d + (-> (the-as cam-dbg-scratch #x70000000) plotvec 0) + (-> (the-as cam-dbg-scratch #x70000000) plotvec 1) + ) + ) + (set! (-> (the-as cam-dbg-scratch #x70000000) plotvec 0 x) 20) + (set! (-> (the-as cam-dbg-scratch #x70000000) plotvec 0 y) 20) + (set! (-> (the-as cam-dbg-scratch #x70000000) plotvec 1 x) (+ (the int (* f26-0 f30-0)) 20)) + (set! (-> (the-as cam-dbg-scratch #x70000000) plotvec 1 y) 20) + (camera-line2d + (-> (the-as cam-dbg-scratch #x70000000) plotvec 0) + (-> (the-as cam-dbg-scratch #x70000000) plotvec 1) + ) + (set! (-> (the-as cam-dbg-scratch #x70000000) plotvec 0 x) 20) + (set! (-> (the-as cam-dbg-scratch #x70000000) plotvec 0 y) (+ (the int (* f28-0 f24-0)) 20)) + (set! (-> (the-as cam-dbg-scratch #x70000000) plotvec 1 x) (+ (the int (* f26-0 f30-0)) 20)) + (set! (-> (the-as cam-dbg-scratch #x70000000) plotvec 1 y) (+ (the int (* f28-0 f24-0)) 20)) + (camera-line2d + (-> (the-as cam-dbg-scratch #x70000000) plotvec 0) + (-> (the-as cam-dbg-scratch #x70000000) plotvec 1) + ) + (set! (-> (the-as cam-dbg-scratch #x70000000) plotvec 0 x) 20) + (set! (-> (the-as cam-dbg-scratch #x70000000) plotvec 0 y) 20) + (set! (-> (the-as cam-dbg-scratch #x70000000) plotvec 1 x) 20) + (set! (-> (the-as cam-dbg-scratch #x70000000) plotvec 1 y) (+ (the int (* f28-0 f24-0)) 20)) + (camera-line2d + (-> (the-as cam-dbg-scratch #x70000000) plotvec 0) + (-> (the-as cam-dbg-scratch #x70000000) plotvec 1) + ) + (set! (-> (the-as cam-dbg-scratch #x70000000) plotvec 0 x) (+ (the int (* f26-0 f30-0)) 20)) + (set! (-> (the-as cam-dbg-scratch #x70000000) plotvec 0 y) 20) + (set! (-> (the-as cam-dbg-scratch #x70000000) plotvec 1 x) (+ (the int (* f26-0 f30-0)) 20)) + (set! (-> (the-as cam-dbg-scratch #x70000000) plotvec 1 y) (+ (the int (* f28-0 f24-0)) 20)) + (camera-line2d + (-> (the-as cam-dbg-scratch #x70000000) plotvec 0) + (-> (the-as cam-dbg-scratch #x70000000) plotvec 1) + ) + (let ((v1-64 (-> arg5 quad))) + (set! (-> (the-as cam-dbg-scratch #x70000000) color quad) v1-64) + ) + (set! (-> (the-as cam-dbg-scratch #x70000000) plotvec 1 x) 20) + (set! (-> (the-as cam-dbg-scratch #x70000000) plotvec 1 y) (+ (the int (* f28-0 (- (arg4 arg0) arg2))) 20)) + (let ((s3-1 1)) + (while (>= (the int (* f26-0 f30-0)) s3-1) + (let ((v1-69 (-> (the-as cam-dbg-scratch #x70000000) plotvec 1 quad))) + (set! (-> (the-as cam-dbg-scratch #x70000000) plotvec 0 quad) v1-69) + ) + (set! (-> (the-as cam-dbg-scratch #x70000000) plotvec 1 x) (+ s3-1 20)) + (set! (-> (the-as cam-dbg-scratch #x70000000) plotvec 1 y) + (+ (the int (* f28-0 (- (arg4 (+ arg0 (* f30-0 (/ (the float s3-1) (* f26-0 f30-0))))) arg2))) 20) + ) + (camera-line2d + (-> (the-as cam-dbg-scratch #x70000000) plotvec 0) + (-> (the-as cam-dbg-scratch #x70000000) plotvec 1) + ) + (+! s3-1 1) + ) + ) + ) + ) + 0 + (none) + ) + +;; definition for function camera-line-setup +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs none. +(defun camera-line-setup ((arg0 vector4w)) + (let ((v1-0 (-> arg0 quad))) + (set! (-> (the-as cam-dbg-scratch #x70000000) color quad) v1-0) + ) + (init-for-transform *identity-matrix*) + 0 + (none) + ) + +;; definition for function camera-line-draw +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs none. +;; WARN: Function camera-line-draw has a return type of none, but the expression builder found a return statement. +(defun camera-line-draw ((arg0 vector) (arg1 vector)) + (set! (-> (the-as cam-dbg-scratch #x70000000) linevec 0 quad) (-> arg0 quad)) + (set! (-> (the-as cam-dbg-scratch #x70000000) linevec 1 quad) (-> arg1 quad)) + (set! (-> (the-as cam-dbg-scratch #x70000000) linevec 0 w) (the-as int 1.0)) + (set! (-> (the-as cam-dbg-scratch #x70000000) linevec 1 w) (the-as int 1.0)) + (transform-float-point + (the-as vector (-> (the-as cam-dbg-scratch #x70000000) linevec)) + (-> (the-as cam-dbg-scratch #x70000000) linevec4w 0) + ) + (transform-float-point + (the-as vector (-> (the-as cam-dbg-scratch #x70000000) linevec 1)) + (-> (the-as cam-dbg-scratch #x70000000) linevec4w 1) + ) + (cond + ((< (the-as uint #xe00000) (the-as uint (-> (the-as cam-dbg-scratch #x70000000) linevec4w 0 z))) + (return #f) + ) + ((< (the-as uint #xe00000) (the-as uint (-> (the-as cam-dbg-scratch #x70000000) linevec4w 1 z))) + (return #f) + ) + ) + (cam-line-dma) + 0 + (none) + ) + +;; definition for function camera-line +;; WARN: Return type mismatch int vs none. +(defun camera-line ((arg0 vector) (arg1 vector) (arg2 vector4w)) + (camera-line-setup arg2) + (camera-line-draw arg0 arg1) + 0 + (none) + ) + +;; definition for function camera-line-rel +(defun camera-line-rel ((arg0 vector) (arg1 vector) (arg2 vector4w)) + (vector+! (-> (the-as cam-dbg-scratch #x70000000) rel-vec) arg0 arg1) + (camera-line arg0 (-> (the-as cam-dbg-scratch #x70000000) rel-vec) arg2) + (none) + ) + +;; definition for function camera-line-rel-len +(defun camera-line-rel-len ((arg0 vector) (arg1 vector) (arg2 float) (arg3 vector4w)) + (vector-normalize-copy! (-> (the-as cam-dbg-scratch #x70000000) rel-vec) arg1 arg2) + (vector+! + (-> (the-as cam-dbg-scratch #x70000000) rel-vec) + (-> (the-as cam-dbg-scratch #x70000000) rel-vec) + arg0 + ) + (camera-line arg0 (-> (the-as cam-dbg-scratch #x70000000) rel-vec) arg3) + (none) + ) + +;; definition for function camera-sphere +;; WARN: Return type mismatch int vs none. +(defun camera-sphere ((arg0 vector) (arg1 float) (arg2 vector4w)) + (camera-line-setup arg2) + (dotimes (s4-0 10) + (let ((f30-1 (* arg1 (sin (* 3276.8 (the float s4-0))))) + (f28-1 (* arg1 (sin (* 3276.8 (the float (+ s4-0 1)))))) + ) + (set! (-> (the-as cam-dbg-scratch #x70000000) sphere-v-start y) + (+ (-> arg0 y) (* (cos (* 3276.8 (the float s4-0))) arg1)) + ) + (set! (-> (the-as cam-dbg-scratch #x70000000) sphere-v-end y) + (-> (the-as cam-dbg-scratch #x70000000) sphere-v-start y) + ) + (set! (-> (the-as cam-dbg-scratch #x70000000) sphere-v-down y) + (+ (-> arg0 y) (* (cos (* 3276.8 (the float (+ s4-0 1)))) arg1)) + ) + (dotimes (s3-0 10) + (set! (-> (the-as cam-dbg-scratch #x70000000) sphere-v-start x) + (+ (-> arg0 x) (* (cos (* 6553.6 (the float s3-0))) f30-1)) + ) + (set! (-> (the-as cam-dbg-scratch #x70000000) sphere-v-start z) + (+ (-> arg0 z) (* (sin (* 6553.6 (the float s3-0))) f30-1)) + ) + (set! (-> (the-as cam-dbg-scratch #x70000000) sphere-v-end x) + (+ (-> arg0 x) (* (cos (* 6553.6 (the float (+ s3-0 1)))) f30-1)) + ) + (set! (-> (the-as cam-dbg-scratch #x70000000) sphere-v-end z) + (+ (-> arg0 z) (* (sin (* 6553.6 (the float (+ s3-0 1)))) f30-1)) + ) + (set! (-> (the-as cam-dbg-scratch #x70000000) sphere-v-down x) + (+ (-> arg0 x) (* (cos (* 6553.6 (the float s3-0))) f28-1)) + ) + (set! (-> (the-as cam-dbg-scratch #x70000000) sphere-v-down z) + (+ (-> arg0 z) (* (sin (* 6553.6 (the float s3-0))) f28-1)) + ) + (camera-line-draw + (-> (the-as cam-dbg-scratch #x70000000) sphere-v-start) + (-> (the-as cam-dbg-scratch #x70000000) sphere-v-end) + ) + (camera-line-draw + (-> (the-as cam-dbg-scratch #x70000000) sphere-v-start) + (-> (the-as cam-dbg-scratch #x70000000) sphere-v-down) + ) + ) + ) + ) + 0 + (none) + ) + +;; definition for function camera-cross +(defun camera-cross ((arg0 vector) (arg1 vector) (arg2 vector) (arg3 vector4w) (arg4 meters)) + (vector-normalize-copy! (-> (the-as cam-dbg-scratch #x70000000) crossvec 0) arg0 arg4) + (vector+! + (-> (the-as cam-dbg-scratch #x70000000) crossvec 1) + arg2 + (-> (the-as cam-dbg-scratch #x70000000) crossvec 0) + ) + (vector-! + (-> (the-as cam-dbg-scratch #x70000000) crossvec 2) + arg2 + (-> (the-as cam-dbg-scratch #x70000000) crossvec 0) + ) + (camera-line + (-> (the-as cam-dbg-scratch #x70000000) crossvec 1) + (-> (the-as cam-dbg-scratch #x70000000) crossvec 2) + arg3 + ) + (vector-cross! + (-> (the-as cam-dbg-scratch #x70000000) crossvec 0) + (-> (the-as cam-dbg-scratch #x70000000) crossvec 0) + arg1 + ) + (vector-normalize! (-> (the-as cam-dbg-scratch #x70000000) crossvec 0) arg4) + (vector+! + (-> (the-as cam-dbg-scratch #x70000000) crossvec 1) + arg2 + (-> (the-as cam-dbg-scratch #x70000000) crossvec 0) + ) + (vector-! + (-> (the-as cam-dbg-scratch #x70000000) crossvec 2) + arg2 + (-> (the-as cam-dbg-scratch #x70000000) crossvec 0) + ) + (camera-line + (-> (the-as cam-dbg-scratch #x70000000) crossvec 1) + (-> (the-as cam-dbg-scratch #x70000000) crossvec 2) + arg3 + ) + (vector-cross! + (-> (the-as cam-dbg-scratch #x70000000) crossvec 0) + (-> (the-as cam-dbg-scratch #x70000000) crossvec 0) + arg0 + ) + (vector-normalize! (-> (the-as cam-dbg-scratch #x70000000) crossvec 0) arg4) + (vector+! + (-> (the-as cam-dbg-scratch #x70000000) crossvec 1) + arg2 + (-> (the-as cam-dbg-scratch #x70000000) crossvec 0) + ) + (vector-! + (-> (the-as cam-dbg-scratch #x70000000) crossvec 2) + arg2 + (-> (the-as cam-dbg-scratch #x70000000) crossvec 0) + ) + (camera-line + (-> (the-as cam-dbg-scratch #x70000000) crossvec 1) + (-> (the-as cam-dbg-scratch #x70000000) crossvec 2) + arg3 + ) + (none) + ) + +;; definition for function camera-bounding-box-draw +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs none. +(defun camera-bounding-box-draw ((arg0 bounding-box) (arg1 basic) (arg2 rgba)) + (camera-line-setup (new 'static 'vector4w :x #x7f :y #x7f :z #x7f :w #x80)) + (set! (-> (the-as cam-dbg-scratch #x70000000) bboxvec 0 quad) (-> arg0 min quad)) + (set! (-> (the-as cam-dbg-scratch #x70000000) bboxvec 0 x) (-> arg0 max x)) + (vector-copy! (-> (the-as cam-dbg-scratch #x70000000) bboxvec 1) (-> arg0 min)) + (set! (-> (the-as cam-dbg-scratch #x70000000) bboxvec 1 y) (-> arg0 max y)) + (vector-copy! (-> (the-as cam-dbg-scratch #x70000000) bboxvec 2) (-> arg0 min)) + (set! (-> (the-as cam-dbg-scratch #x70000000) bboxvec 2 z) (-> arg0 max z)) + (vector-copy! (-> (the-as cam-dbg-scratch #x70000000) bboxvec 3) (-> arg0 max)) + (set! (-> (the-as cam-dbg-scratch #x70000000) bboxvec 3 x) (-> arg0 min x)) + (vector-copy! (-> (the-as cam-dbg-scratch #x70000000) bboxvec 4) (-> arg0 max)) + (set! (-> (the-as cam-dbg-scratch #x70000000) bboxvec 4 y) (-> arg0 min y)) + (vector-copy! (-> (the-as cam-dbg-scratch #x70000000) bboxvec 5) (-> arg0 max)) + (set! (-> (the-as cam-dbg-scratch #x70000000) bboxvec 5 z) (-> arg0 min z)) + (camera-line-draw (-> arg0 min) (-> (the-as cam-dbg-scratch #x70000000) bboxvec 0)) + (camera-line-draw (-> arg0 min) (-> (the-as cam-dbg-scratch #x70000000) bboxvec 1)) + (camera-line-draw (-> arg0 min) (-> (the-as cam-dbg-scratch #x70000000) bboxvec 2)) + (camera-line-draw (-> arg0 max) (-> (the-as cam-dbg-scratch #x70000000) bboxvec 3)) + (camera-line-draw (-> arg0 max) (-> (the-as cam-dbg-scratch #x70000000) bboxvec 4)) + (camera-line-draw (-> arg0 max) (-> (the-as cam-dbg-scratch #x70000000) bboxvec 5)) + (camera-line-draw + (-> (the-as cam-dbg-scratch #x70000000) bboxvec 0) + (-> (the-as cam-dbg-scratch #x70000000) bboxvec 4) + ) + (camera-line-draw + (-> (the-as cam-dbg-scratch #x70000000) bboxvec 4) + (-> (the-as cam-dbg-scratch #x70000000) bboxvec 2) + ) + (camera-line-draw + (-> (the-as cam-dbg-scratch #x70000000) bboxvec 2) + (-> (the-as cam-dbg-scratch #x70000000) bboxvec 3) + ) + (camera-line-draw + (-> (the-as cam-dbg-scratch #x70000000) bboxvec 3) + (-> (the-as cam-dbg-scratch #x70000000) bboxvec 1) + ) + (camera-line-draw + (-> (the-as cam-dbg-scratch #x70000000) bboxvec 1) + (-> (the-as cam-dbg-scratch #x70000000) bboxvec 5) + ) + (camera-line-draw + (-> (the-as cam-dbg-scratch #x70000000) bboxvec 5) + (-> (the-as cam-dbg-scratch #x70000000) bboxvec 0) + ) + 0 + (none) + ) + +;; definition of type cam-debug-tri +(deftype cam-debug-tri (structure) + ((vertex vector 3 :inline) + (intersect vector :inline) + (color vector4w) + ) + ) + +;; definition for method 3 of type cam-debug-tri +(defmethod inspect ((this cam-debug-tri)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'cam-debug-tri) + (format #t "~1Tvertex[3] @ #x~X~%" (-> this vertex)) + (format #t "~1Tintersect: #~%" (-> this intersect)) + (format #t "~1Tcolor: #~%" (-> this color)) + (label cfg-4) + this + ) + +;; definition for symbol *cam-debug-los-tri-current*, type int +(define *cam-debug-los-tri-current* 0) + +;; definition for symbol *cam-debug-los-tri*, type (inline-array cam-debug-tri) +(define *cam-debug-los-tri* (the-as (inline-array cam-debug-tri) (malloc 'debug #x8fc0))) + +;; definition for symbol *cam-debug-coll-tri-current*, type int +(define *cam-debug-coll-tri-current* 0) + +;; definition for symbol *cam-debug-coll-tri*, type (inline-array cam-debug-tri) +(define *cam-debug-coll-tri* (the-as (inline-array cam-debug-tri) (malloc 'debug #x8fc0))) + +;; definition for function cam-debug-reset-coll-tri +;; WARN: Return type mismatch int vs none. +(defun cam-debug-reset-coll-tri () + (set! *cam-debug-los-tri-current* 0) + (set! *cam-debug-coll-tri-current* 0) + 0 + (none) + ) + +;; definition for function cam-debug-add-los-tri +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs none. +(defun cam-debug-add-los-tri ((arg0 (inline-array collide-cache-tri)) (arg1 vector) (arg2 vector)) + (cond + ((>= *cam-debug-los-tri-current* 460) + ) + (else + (let ((v1-3 (-> *cam-debug-los-tri* *cam-debug-los-tri-current*))) + (set! (-> v1-3 vertex 0 quad) (-> arg0 0 vertex 0 quad)) + (vector-copy! (-> v1-3 vertex 1) (-> arg0 0 vertex 1)) + (vector-copy! (-> v1-3 vertex 2) (-> arg0 0 vertex 2)) + (vector-copy! (-> v1-3 intersect) arg1) + (set! (-> v1-3 color) (the-as vector4w arg2)) + ) + (set! *cam-debug-los-tri-current* (+ *cam-debug-los-tri-current* 1)) + (if (= *cam-debug-los-tri-current* 460) + (format 0 "ERROR : cam-debug-add-los-tri overflow~%") + ) + ) + ) + 0 + (none) + ) + +;; definition for function cam-debug-add-coll-tri +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs none. +(defun cam-debug-add-coll-tri ((arg0 cam-debug-tri) (arg1 vector) (arg2 cam-debug-tri)) + (cond + ((>= *cam-debug-coll-tri-current* 460) + ) + (else + (let ((v1-3 (-> *cam-debug-coll-tri* *cam-debug-coll-tri-current*))) + (set! (-> v1-3 vertex 0 quad) (-> arg0 vertex 0 quad)) + (vector-copy! (-> v1-3 vertex 1) (-> arg0 vertex 1)) + (vector-copy! (-> v1-3 vertex 2) (-> arg0 vertex 2)) + (vector-copy! (-> v1-3 intersect) arg1) + (set! (-> v1-3 color) (the-as vector4w arg2)) + ) + (set! *cam-debug-coll-tri-current* (+ *cam-debug-coll-tri-current* 1)) + (if (>= *cam-debug-coll-tri-current* 460) + (format 0 "ERROR : cam-debug-add-coll-tri overflow~%") + ) + ) + ) + 0 + (none) + ) + +;; definition for function cam-debug-draw-tris +;; INFO: Used lq/sq +(defun cam-debug-draw-tris () + (camera-line-setup (new 'stack 'vector4w)) + (when *display-cam-los-marks* + (dotimes (gp-1 *cam-debug-los-tri-current*) + (let ((v1-7 (-> *cam-debug-los-tri* gp-1 color quad))) + (set! (-> (the-as cam-dbg-scratch #x70000000) color quad) v1-7) + ) + (camera-line-draw + (the-as vector (+ (the-as uint (-> *cam-debug-los-tri* 0)) (* 80 gp-1))) + (the-as vector (+ (the-as uint (-> *cam-debug-los-tri* 0 vertex 1)) (* 80 gp-1))) + ) + (camera-line-draw + (the-as vector (+ (the-as uint (-> *cam-debug-los-tri* 0 vertex 1)) (* 80 gp-1))) + (the-as vector (+ (the-as uint (-> *cam-debug-los-tri* 0 vertex 2)) (* 80 gp-1))) + ) + (camera-line-draw + (the-as vector (+ (the-as uint (-> *cam-debug-los-tri* 0 vertex 2)) (* 80 gp-1))) + (the-as vector (+ (the-as uint (-> *cam-debug-los-tri* 0)) (* 80 gp-1))) + ) + (camera-cross + (new 'static 'vector :y 1024.0) + (new 'static 'vector :z 1024.0) + (-> *cam-debug-los-tri* gp-1 intersect) + (-> *cam-debug-los-tri* gp-1 color) + (meters 0.25) + ) + ) + ) + (when *display-cam-coll-marks* + (dotimes (gp-2 *cam-debug-coll-tri-current*) + (let ((v1-34 (-> *cam-debug-coll-tri* gp-2 color quad))) + (set! (-> (the-as cam-dbg-scratch #x70000000) color quad) v1-34) + ) + (camera-line-draw + (the-as vector (+ (the-as uint (-> *cam-debug-coll-tri* 0)) (* 80 gp-2))) + (the-as vector (+ (the-as uint (-> *cam-debug-coll-tri* 0 vertex 1)) (* 80 gp-2))) + ) + (camera-line-draw + (the-as vector (+ (the-as uint (-> *cam-debug-coll-tri* 0 vertex 1)) (* 80 gp-2))) + (the-as vector (+ (the-as uint (-> *cam-debug-coll-tri* 0 vertex 2)) (* 80 gp-2))) + ) + (camera-line-draw + (the-as vector (+ (the-as uint (-> *cam-debug-coll-tri* 0 vertex 2)) (* 80 gp-2))) + (the-as vector (+ (the-as uint (-> *cam-debug-coll-tri* 0)) (* 80 gp-2))) + ) + (camera-cross + (new 'static 'vector :y 1024.0) + (new 'static 'vector :z 1024.0) + (-> *cam-debug-coll-tri* gp-2 intersect) + (-> *cam-debug-coll-tri* gp-2 color) + (meters 0.25) + ) + ) + #f + ) + ) + +;; definition for function camera-fov-draw +(defun camera-fov-draw ((arg0 int) (arg1 int) (arg2 vector) (arg3 float) (arg4 float) (arg5 vector4w)) + (vector+float*! (-> (the-as cam-dbg-scratch #x70000000) fov-vv 0) arg2 (the-as vector arg1) arg3) + (vector+float*! (the-as vector (the-as (pointer vector) (+ 352 #x70000000))) arg2 (the-as vector arg0) arg3) + (vector+float*! (the-as vector (+ 368 #x70000000)) arg2 (the-as vector arg0) arg4) + (vector+float*! (the-as vector (+ 384 #x70000000)) arg2 (the-as vector arg1) arg4) + (camera-line-setup arg5) + (camera-line-draw (the-as vector (+ 336 #x70000000)) (the-as vector (+ 352 #x70000000))) + (camera-line-draw + (the-as vector (&+ (the-as (pointer vector) 352) #x70000000)) + (the-as vector (+ 368 #x70000000)) + ) + (camera-line-draw (the-as vector (+ 368 #x70000000)) (the-as vector (+ 384 #x70000000))) + (none) + ) + +;; definition for function camera-fov-frame +;; INFO: Used lq/sq +;; WARN: Return type mismatch none vs symbol. +(defun camera-fov-frame ((arg0 matrix) (arg1 vector) (arg2 float) (arg3 float) (arg4 float) (arg5 vector4w)) + (vector-float*! (-> (the-as cam-dbg-scratch #x70000000) fov-vert) (-> arg0 uvec) (* arg3 (tan arg2))) + (vector-float*! (-> (the-as cam-dbg-scratch #x70000000) fov-horz) (-> arg0 rvec) (* arg4 (tan arg2))) + (vector+! + (-> (the-as cam-dbg-scratch #x70000000) fov-src) + (-> arg0 fvec) + (vector+! + (-> (the-as cam-dbg-scratch #x70000000) fov-src) + (-> (the-as cam-dbg-scratch #x70000000) fov-vert) + (-> (the-as cam-dbg-scratch #x70000000) fov-horz) + ) + ) + (vector-normalize! (-> (the-as cam-dbg-scratch #x70000000) fov-src) 1.0) + (vector+! + (-> (the-as cam-dbg-scratch #x70000000) fov-dest) + (-> arg0 fvec) + (vector-! + (-> (the-as cam-dbg-scratch #x70000000) fov-dest) + (-> (the-as cam-dbg-scratch #x70000000) fov-vert) + (-> (the-as cam-dbg-scratch #x70000000) fov-horz) + ) + ) + (vector-normalize! (-> (the-as cam-dbg-scratch #x70000000) fov-dest) 1.0) + (camera-fov-draw + (the-as int (-> (the-as cam-dbg-scratch #x70000000) fov-src)) + (the-as int (-> (the-as cam-dbg-scratch #x70000000) fov-dest)) + arg1 + 4096.0 + 20480.0 + arg5 + ) + (vector-copy! + (-> (the-as cam-dbg-scratch #x70000000) fov-src) + (the-as vector4w (-> (the-as cam-dbg-scratch #x70000000) fov-dest)) + ) + (vector-! + (-> (the-as cam-dbg-scratch #x70000000) fov-dest) + (-> arg0 fvec) + (vector+! + (-> (the-as cam-dbg-scratch #x70000000) fov-dest) + (-> (the-as cam-dbg-scratch #x70000000) fov-vert) + (-> (the-as cam-dbg-scratch #x70000000) fov-horz) + ) + ) + (vector-normalize! (-> (the-as cam-dbg-scratch #x70000000) fov-dest) 1.0) + (camera-fov-draw + (the-as int (-> (the-as cam-dbg-scratch #x70000000) fov-src)) + (the-as int (-> (the-as cam-dbg-scratch #x70000000) fov-dest)) + arg1 + 4096.0 + 20480.0 + arg5 + ) + (vector-copy! + (-> (the-as cam-dbg-scratch #x70000000) fov-src) + (the-as vector4w (-> (the-as cam-dbg-scratch #x70000000) fov-dest)) + ) + (vector-! + (-> (the-as cam-dbg-scratch #x70000000) fov-dest) + (-> arg0 fvec) + (vector-! + (-> (the-as cam-dbg-scratch #x70000000) fov-dest) + (-> (the-as cam-dbg-scratch #x70000000) fov-vert) + (-> (the-as cam-dbg-scratch #x70000000) fov-horz) + ) + ) + (vector-normalize! (-> (the-as cam-dbg-scratch #x70000000) fov-dest) 1.0) + (camera-fov-draw + (the-as int (-> (the-as cam-dbg-scratch #x70000000) fov-src)) + (the-as int (-> (the-as cam-dbg-scratch #x70000000) fov-dest)) + arg1 + 4096.0 + 20480.0 + arg5 + ) + (vector-copy! + (-> (the-as cam-dbg-scratch #x70000000) fov-src) + (the-as vector4w (-> (the-as cam-dbg-scratch #x70000000) fov-dest)) + ) + (vector+! + (-> (the-as cam-dbg-scratch #x70000000) fov-dest) + (-> arg0 fvec) + (vector+! + (-> (the-as cam-dbg-scratch #x70000000) fov-dest) + (-> (the-as cam-dbg-scratch #x70000000) fov-vert) + (-> (the-as cam-dbg-scratch #x70000000) fov-horz) + ) + ) + (vector-normalize! (-> (the-as cam-dbg-scratch #x70000000) fov-dest) 1.0) + (the-as symbol (camera-fov-draw + (the-as int (-> (the-as cam-dbg-scratch #x70000000) fov-src)) + (the-as int (-> (the-as cam-dbg-scratch #x70000000) fov-dest)) + arg1 + 4096.0 + 20480.0 + arg5 + ) + ) + ) + +;; definition for method 11 of type tracking-spline +;; WARN: Return type mismatch int vs none. +(defmethod debug-point-info ((this tracking-spline) (arg0 int)) + (if (= arg0 (-> this used-point)) + (format 0 "u") + (format 0 " ") + ) + (if (= arg0 (-> this next-to-last-point)) + (format 0 "n") + (format 0 " ") + ) + (if (= arg0 (-> this end-point)) + (format 0 "e") + (format 0 " ") + ) + (if (= arg0 -134250495) + (format 0 " ~D~%" arg0) + (format + 0 + " ~D ~M ~M ~M~%" + arg0 + (-> this point arg0 position x) + (-> this point arg0 position y) + (-> this point arg0 position z) + ) + ) + 0 + (none) + ) + +;; definition for method 12 of type tracking-spline +;; WARN: Return type mismatch int vs none. +(defmethod debug-all-points ((this tracking-spline)) + (let ((s5-0 (-> this used-point))) + (while (!= s5-0 -134250495) + (debug-point-info this s5-0) + (set! s5-0 (-> this point s5-0 next)) + ) + (debug-point-info this s5-0) + ) + 0 + (none) + ) + +;; definition for method 23 of type tracking-spline +;; WARN: Return type mismatch int vs none. +(defmethod debug-draw-spline ((this tracking-spline)) + (let ((s5-0 (-> this used-point))) + (let ((s4-0 (-> this point (-> this used-point) next))) + (let ((s3-0 (new 'stack-no-clear 'vector)) + (s2-0 (new 'stack-no-clear 'vector)) + ) + (when (!= s4-0 -134250495) + (tracking-spline-method-19 this 0.0 s3-0 s2-0 (the-as tracking-spline-sampler #f)) + (camera-cross + (new 'static 'vector :y 1024.0) + (new 'static 'vector :z 1024.0) + s3-0 + (new 'static 'vector4w :x #xff :w #x80) + (meters 0.25) + ) + (tracking-spline-method-19 this (-> this sample-len) s3-0 s2-0 (the-as tracking-spline-sampler #f)) + (camera-cross + (new 'static 'vector :y 1024.0) + (new 'static 'vector :z 1024.0) + s3-0 + (new 'static 'vector4w :x #xff :w #x80) + (meters 0.25) + ) + ) + ) + (while (!= s4-0 -134250495) + (camera-line + (-> this point s5-0 position) + (-> this point s4-0 position) + (new 'static 'vector4w :x #x80 :y #x80 :z #x80 :w #x80) + ) + (set! s5-0 s4-0) + (set! s4-0 (-> this point s4-0 next)) + ) + ) + (if (!= s5-0 -134250495) + (camera-cross + (new 'static 'vector :y 1024.0) + (new 'static 'vector :z 1024.0) + (-> this point s5-0 position) + (new 'static 'vector4w :x #xff :w #x80) + (meters 0.25) + ) + ) + ) + (let ((s5-1 (new 'stack-no-clear 'vector))) + (camera-line + (-> this debug-out-position) + (-> this debug-old-position) + (new 'static 'vector4w :x #xff :y #xff :w #x80) + ) + (vector-! s5-1 (-> this debug-out-position) (-> this debug-old-position)) + (tracking-spline-method-20 this s5-1 (-> this debug-last-point)) + (camera-line-rel (-> this debug-old-position) s5-1 (new 'static 'vector4w :x #xff :z #xff :w #x80)) + ) + 0 + (none) + ) + +;; definition for function debug-euler +(defun debug-euler ((arg0 cam-dbg-scratch)) + (let ((s4-0 (new 'stack-no-clear 'euler-angles)) + (gp-0 (new 'stack-no-clear 'matrix)) + ) + (matrix->eul s4-0 (the-as matrix (&-> arg0 crossvec 0 w)) 21) + (format *stdcon* "euler angles x ~R y ~R z ~R~%" (-> s4-0 x) (-> s4-0 y) (-> s4-0 z)) + (format + *stdcon* + "~f ~f ~f ~f~%" + (-> arg0 crossvec 0 w) + (-> arg0 crossvec 1 x) + (-> arg0 crossvec 1 y) + (-> arg0 crossvec 1 z) + ) + (format + *stdcon* + "~f ~f ~f ~f~%" + (-> arg0 crossvec 1 w) + (-> arg0 crossvec 2 x) + (-> arg0 crossvec 2 y) + (-> arg0 crossvec 2 z) + ) + (format + *stdcon* + "~f ~f ~f ~f~%" + (-> arg0 crossvec 2 w) + (-> arg0 bboxvec 0 x) + (-> arg0 bboxvec 0 y) + (-> arg0 bboxvec 0 z) + ) + (format + *stdcon* + "~f ~f ~f ~f~%" + (-> arg0 bboxvec 0 w) + (-> arg0 bboxvec 1 x) + (-> arg0 bboxvec 1 y) + (-> arg0 bboxvec 1 z) + ) + (eul->matrix gp-0 s4-0) + (format *stdcon* "~f ~f ~f ~f~%" (-> gp-0 rvec x) (-> gp-0 rvec y) (-> gp-0 rvec z) (-> gp-0 rvec w)) + (format *stdcon* "~f ~f ~f ~f~%" (-> gp-0 uvec x) (-> gp-0 uvec y) (-> gp-0 uvec z) (-> gp-0 uvec w)) + (format *stdcon* "~f ~f ~f ~f~%" (-> gp-0 fvec x) (-> gp-0 fvec y) (-> gp-0 fvec z) (-> gp-0 fvec w)) + (format *stdcon* "~f ~f ~f ~f~%" (-> gp-0 trans x) (-> gp-0 trans y) (-> gp-0 trans z) (-> gp-0 trans w)) + (if (or (< 0.001 (fabs (- (-> arg0 crossvec 0 w) (-> gp-0 rvec x)))) + (< 0.001 (fabs (- (-> arg0 crossvec 1 x) (-> gp-0 rvec y)))) + (< 0.001 (fabs (- (-> arg0 crossvec 1 y) (-> gp-0 rvec z)))) + (< 0.001 (fabs (- (-> arg0 crossvec 1 z) (-> gp-0 rvec w)))) + (< 0.001 (fabs (- (-> arg0 crossvec 1 w) (-> gp-0 uvec x)))) + (< 0.001 (fabs (- (-> arg0 crossvec 2 x) (-> gp-0 uvec y)))) + (< 0.001 (fabs (- (-> arg0 crossvec 2 y) (-> gp-0 uvec z)))) + (< 0.001 (fabs (- (-> arg0 crossvec 2 z) (-> gp-0 uvec w)))) + (< 0.001 (fabs (- (-> arg0 crossvec 2 w) (-> gp-0 fvec x)))) + (< 0.001 (fabs (- (-> arg0 bboxvec 0 x) (-> gp-0 fvec y)))) + (< 0.001 (fabs (- (-> arg0 bboxvec 0 y) (-> gp-0 fvec z)))) + (< 0.001 (fabs (- (-> arg0 bboxvec 0 z) (-> gp-0 fvec w)))) + (< 0.001 (fabs (- (-> arg0 bboxvec 0 w) (-> gp-0 trans x)))) + (< 0.001 (fabs (- (-> arg0 bboxvec 1 x) (-> gp-0 trans y)))) + (< 0.001 (fabs (- (-> arg0 bboxvec 1 y) (-> gp-0 trans z)))) + (< 0.001 (fabs (- (-> arg0 bboxvec 1 z) (-> gp-0 trans w)))) + ) + (format *stdcon* "different~%") + (format *stdcon* "same~%") + ) + ) + ) + +;; definition for function bike-cam-limit +(defun bike-cam-limit ((arg0 float)) + (let* ((f0-1 (* 10012.444 arg0)) + (f30-0 (fmax 0.0 f0-1)) + ) + (if (< f30-0 8192.0) + (* (/ 1.0 (- 1.0 (cos 21845.334))) (+ (- (cos 21845.334)) (cos (* 2.6666667 (- 8192.0 f30-0))))) + 1.0 + ) + ) + ) + +;; definition for function camera-slave-debug +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs none. +(defun camera-slave-debug ((arg0 camera-slave)) + (when *display-camera-marks* + (if (-> *setting-control* cam-current use-point-of-interest) + (camera-cross + (new 'static 'vector :y 1024.0) + (new 'static 'vector :z 1024.0) + (-> *setting-control* cam-current point-of-interest) + (new 'static 'vector4w :x #x80 :z #x80 :w #x80) + (meters 0.25) + ) + ) + (let ((f30-0 (/ (-> *camera-combiner* fov) 2))) + (camera-fov-frame + (-> *camera-combiner* inv-camera-rot) + (camera-pos) + f30-0 + 0.75 + 1.0 + (new 'static 'vector4w :z #xff :w #x80) + ) + ) + (cond + ((= (-> arg0 blend-to-type) (camera-blend-to-type unknown-2)) + (let ((f0-2 (/ (-> arg0 fov) 2))) + (camera-fov-frame + (-> *camera-combiner* tracking inv-mat) + (-> arg0 trans) + f0-2 + 0.75 + 1.0 + (new 'static 'vector4w :y #xff :w #x80) + ) + ) + ) + (else + (let ((f0-4 (/ (-> arg0 fov) 2))) + (camera-fov-frame + (-> arg0 tracking inv-mat) + (-> arg0 trans) + f0-4 + 0.75 + 1.0 + (new 'static 'vector4w :y #xff :w #x80) + ) + ) + ) + ) + (debug-draw-spline (-> arg0 position-spline)) + (let ((s5-1 (new-stack-vector0))) + (let ((s4-1 (new-stack-vector0))) + (new-stack-matrix0) + (cond + ((and (-> arg0 next-state) + (let ((v1-23 (-> arg0 next-state name))) + (or (= v1-23 'cam-fixed) (= v1-23 'cam-eye) (= v1-23 'cam-point-watch) (= v1-23 'cam-free-floating)) + ) + ) + (vector+float*! s5-1 (-> arg0 trans) (-> *camera* local-down) 4096.0) + (camera-line (-> arg0 trans) s5-1 (new 'static 'vector4w :x #xff :y #xff :z #xff :w #x80)) + ) + ((= (-> arg0 blend-to-type) (camera-blend-to-type unknown-2)) + (camera-line + (-> *camera-combiner* tracking follow-pt) + (-> arg0 trans) + (new 'static 'vector4w :x #xff :y #xff :z #xff :w #x80) + ) + (vector+float*! s5-1 (-> *camera-combiner* tracking follow-pt) (-> *camera* local-down) 4096.0) + (camera-line + (-> *camera-combiner* tracking follow-pt) + s5-1 + (new 'static 'vector4w :x #xff :y #xff :z #xff :w #x80) + ) + ) + (else + (camera-line + (-> arg0 tracking follow-pt) + (-> arg0 trans) + (new 'static 'vector4w :x #xff :y #xff :z #xff :w #x80) + ) + (vector+float*! s5-1 (-> arg0 tracking follow-pt) (-> *camera* local-down) 4096.0) + (camera-line (-> arg0 tracking follow-pt) s5-1 (new 'static 'vector4w :x #xff :y #xff :z #xff :w #x80)) + ) + ) + (vector-copy! s4-1 (-> arg0 trans)) + (cond + ((= (-> arg0 blend-to-type) (camera-blend-to-type unknown-2)) + (vector+float*! s5-1 s4-1 (the-as vector (-> *camera-combiner* tracking)) 2048.0) + (camera-line s4-1 s5-1 (new 'static 'vector4w :x #xff :w #x80)) + (vector+float*! s5-1 s4-1 (-> *camera-combiner* tracking inv-mat uvec) 2048.0) + (camera-line s4-1 s5-1 (new 'static 'vector4w :y #xff :w #x80)) + (vector+float*! s5-1 s4-1 (-> *camera-combiner* tracking inv-mat fvec) 2048.0) + (camera-line s4-1 s5-1 (new 'static 'vector4w :z #xff :w #x80)) + ) + (else + (vector+float*! s5-1 s4-1 (the-as vector (-> arg0 tracking)) 2048.0) + (camera-line s4-1 s5-1 (new 'static 'vector4w :x #xff :w #x80)) + (vector+float*! s5-1 s4-1 (-> arg0 tracking inv-mat uvec) 2048.0) + (camera-line s4-1 s5-1 (new 'static 'vector4w :y #xff :w #x80)) + (vector+float*! s5-1 s4-1 (-> arg0 tracking inv-mat fvec) 2048.0) + (camera-line s4-1 s5-1 (new 'static 'vector4w :z #xff :w #x80)) + ) + ) + ) + (vector--float*! + s5-1 + (-> *camera* tpos-curr) + (-> *camera* local-down) + (-> *setting-control* cam-current foot-offset) + ) + (camera-sphere s5-1 512.0 (new 'static 'vector4w :y #xff :w #x80)) + (vector--float*! + s5-1 + (-> *camera* tpos-curr) + (-> *camera* local-down) + (-> *setting-control* cam-current head-offset) + ) + (camera-sphere s5-1 512.0 (new 'static 'vector4w :y #xff :w #x80)) + ) + (cond + ((and (-> arg0 next-state) (= (-> arg0 next-state name) 'cam-string)) + (camera-sphere (-> arg0 desired-pos) 512.0 (new 'static 'vector4w :z #xff :w #x80)) + (camera-line-rel (-> *camera* tpos-curr-adj) (-> arg0 view-flat) (new 'static 'vector4w :z #xff :w #x80)) + (camera-line + (-> arg0 string-trans) + (the-as vector (+ (the-as uint (-> *camera* target-spline)) (* 48 (-> arg0 los-tgt-spline-pt)))) + (new 'static 'vector4w :y #xff :w #x80) + ) + (camera-line + (-> arg0 los-last-pos) + (the-as vector (+ (the-as uint (-> *camera* target-spline)) (* 48 (-> arg0 los-tgt-spline-pt)))) + (new 'static 'vector4w :x #xff :w #x80) + ) + ) + ((and (-> arg0 next-state) (= (-> arg0 next-state name) 'cam-circular)) + (let ((a1-45 (new-stack-vector0))) + (vector+float*! a1-45 (-> arg0 pivot-pt) (-> *camera* local-down) 4096.0) + (camera-line (-> arg0 pivot-pt) a1-45 (new 'static 'vector4w :x #xff :y #xff :z #xff :w #x80)) + ) + (camera-line (-> arg0 pivot-pt) (-> arg0 trans) (new 'static 'vector4w :x #xff :y #xff :z #xff :w #x80)) + ) + ((and (-> arg0 next-state) (= (-> arg0 next-state name) 'cam-spline)) + (let ((s5-2 (new 'stack 'curve)) + (s4-2 (res-lump-struct (-> arg0 cam-entity) 'spline-offset structure)) + ) + (if (not s4-2) + (set! s4-2 (new-stack-vector0)) + ) + (when (get-curve-data! (-> arg0 cam-entity) s5-2 'campath 'campath-k -1000000000.0) + (let ((s3-0 (new-stack-vector0)) + (s2-0 (new-stack-vector0)) + (gp-1 (res-lump-data (-> arg0 cam-entity) 'campoints pointer :time 1.0)) + ) + (curve-get-pos! s2-0 0.0 s5-2) + (vector+! s2-0 s2-0 (the-as vector s4-2)) + (dotimes (s1-0 8) + (vector-copy! s3-0 s2-0) + (curve-get-pos! s2-0 (* 0.125 (the float (+ s1-0 1))) s5-2) + (vector+! s2-0 s2-0 (the-as vector s4-2)) + (camera-line s3-0 s2-0 (new 'static 'vector4w :x #xff :y #xff :w #x80)) + ) + (dotimes (s1-1 (-> s5-2 num-cverts)) + (vector+! s3-0 (-> s5-2 cverts s1-1) (the-as vector s4-2)) + (vector+! s2-0 (-> s5-2 cverts (mod (+ s1-1 1) (-> s5-2 num-cverts))) (the-as vector s4-2)) + (camera-line s3-0 s2-0 (new 'static 'vector4w :y #xff :z #xff :w #x80)) + ) + (if gp-1 + (camera-line + (the-as vector (&+ gp-1 0)) + (the-as vector (&+ gp-1 16)) + (new 'static 'vector4w :x #xff :y #xff :z #xff :w #x80) + ) + (camera-line + (-> s5-2 cverts 0) + (-> s5-2 cverts (+ (-> s5-2 num-cverts) -1)) + (new 'static 'vector4w :x #xff :y #xff :z #xff :w #x80) + ) + ) + ) + ) + ) + ) + ) + ) + 0 + (none) + ) + +;; definition for function master-draw-coordinates +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs none. +(defun master-draw-coordinates ((arg0 vector)) + (let ((s5-0 (new-stack-vector0)) + (gp-0 (new-stack-vector0)) + ) + (let ((a0-1 (new-stack-matrix0))) + (set-vector! s5-0 0.0 8192.0 0.0 1.0) + (matrix-rotate-yxz! a0-1 s5-0) + ) + (position-in-front-of-camera! gp-0 24576.0 0.0) + (let ((a1-4 s5-0) + (v1-1 gp-0) + (a0-3 s5-0) + ) + (set! (-> a0-3 x) 4096.0) + (set! (-> a0-3 y) 0.0) + (set! (-> a0-3 z) 0.0) + (set! (-> a0-3 w) 1.0) + (vector+! a1-4 v1-1 a0-3) + ) + (add-debug-line + #t + (bucket-id debug-no-zbuf1) + gp-0 + s5-0 + (new 'static 'rgba :r #xff :a #x80) + #f + (the-as rgba -1) + ) + (let ((a1-7 s5-0) + (v1-2 gp-0) + (a0-5 s5-0) + ) + (set! (-> a0-5 x) 0.0) + (set! (-> a0-5 y) 4096.0) + (set! (-> a0-5 z) 0.0) + (set! (-> a0-5 w) 1.0) + (vector+! a1-7 v1-2 a0-5) + ) + (add-debug-line + #t + (bucket-id debug-no-zbuf1) + gp-0 + s5-0 + (new 'static 'rgba :g #xff :a #x80) + #f + (the-as rgba -1) + ) + (let ((a1-10 s5-0) + (v1-3 gp-0) + (a0-7 s5-0) + ) + (set! (-> a0-7 x) 0.0) + (set! (-> a0-7 y) 0.0) + (set! (-> a0-7 z) 4096.0) + (set! (-> a0-7 w) 1.0) + (vector+! a1-10 v1-3 a0-7) + ) + (add-debug-line + #t + (bucket-id debug-no-zbuf1) + gp-0 + s5-0 + (new 'static 'rgba :b #xff :a #x80) + #f + (the-as rgba -1) + ) + (when arg0 + (vector-copy! s5-0 arg0) + (vector-normalize! s5-0 4096.0) + (vector+! s5-0 gp-0 s5-0) + (add-debug-line + #t + (bucket-id debug-no-zbuf1) + gp-0 + s5-0 + (new 'static 'rgba :r #x7f :g #x7f :a #x80) + #f + (the-as rgba -1) + ) + ) + ) + 0 + (none) + ) + +;; definition of type cam-collision-record +(deftype cam-collision-record (structure) + ((pos vector :inline) + (vel vector :inline) + (desired-pos vector :inline) + (cam-tpos-cur vector :inline) + (cam-tpos-old vector :inline) + (view-flat vector :inline) + (string-min-val vector :inline) + (string-max-val vector :inline) + (view-off vector :inline) + (min-z-override float) + (string-push-z float) + (view-off-param float) + (frame int32) + (iteration int32) + (move-type symbol) + ) + ) + +;; definition for method 3 of type cam-collision-record +(defmethod inspect ((this cam-collision-record)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'cam-collision-record) + (format #t "~1Tpos: #~%" (-> this pos)) + (format #t "~1Tvel: #~%" (-> this vel)) + (format #t "~1Tdesired-pos: #~%" (-> this desired-pos)) + (format #t "~1Tcam-tpos-cur: #~%" (-> this cam-tpos-cur)) + (format #t "~1Tcam-tpos-old: #~%" (-> this cam-tpos-old)) + (format #t "~1Tview-flat: #~%" (-> this view-flat)) + (format #t "~1Tstring-min-val: #~%" (-> this string-min-val)) + (format #t "~1Tstring-max-val: #~%" (-> this string-max-val)) + (format #t "~1Tview-off: #~%" (-> this view-off)) + (format #t "~1Tmin-z-override: ~f~%" (-> this min-z-override)) + (format #t "~1Tstring-push-z: ~f~%" (-> this string-push-z)) + (format #t "~1Tview-off-param: ~f~%" (-> this view-off-param)) + (format #t "~1Tframe: ~D~%" (-> this frame)) + (format #t "~1Titeration: ~D~%" (-> this iteration)) + (format #t "~1Tmove-type: ~A~%" (-> this move-type)) + (label cfg-4) + this + ) + +;; definition of type cam-collision-record-array +(deftype cam-collision-record-array (inline-array-class) + ((data cam-collision-record :dynamic) + ) + ) + +;; definition for method 3 of type cam-collision-record-array +(defmethod inspect ((this cam-collision-record-array)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tlength: ~D~%" (-> this length)) + (format #t "~1Tallocated-length: ~D~%" (-> this allocated-length)) + (format #t "~1Tdata[0] @ #x~X~%" (-> this data)) + (label cfg-4) + this + ) + +;; failed to figure out what this is: +(set! (-> cam-collision-record-array heap-base) (the-as uint 176)) + +;; definition for symbol *cam-collision-record-first*, type int +(define *cam-collision-record-first* 0) + +;; definition for symbol *cam-collision-record-last*, type int +(define *cam-collision-record-last* 0) + +;; definition for symbol *cam-collision-record-show*, type int +(define *cam-collision-record-show* 0) + +;; definition for symbol *cam-collision-record*, type cam-collision-record-array +(define *cam-collision-record* (new 'debug 'cam-collision-record-array 600)) + +;; definition for function cam-collision-record-save +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs none. +(defun cam-collision-record-save ((arg0 vector) (arg1 vector) (arg2 int) (arg3 symbol) (arg4 camera-slave)) + (when *record-cam-collide-history* + (let ((v1-5 (the-as + cam-collision-record + (+ (+ (* 176 *cam-collision-record-last*) 12) (the-as int *cam-collision-record*)) + ) + ) + ) + (vector-copy! (-> v1-5 pos) arg0) + (vector-copy! (-> v1-5 vel) arg1) + (vector-copy! (-> v1-5 view-flat) (-> arg4 view-flat)) + (vector-copy! (-> v1-5 desired-pos) (-> arg4 desired-pos)) + (vector-copy! (-> v1-5 cam-tpos-cur) (-> *camera* tpos-curr-adj)) + (vector-copy! (-> v1-5 cam-tpos-old) (-> *camera* tpos-old-adj)) + (vector-copy! (-> v1-5 string-min-val) (-> arg4 string-min-val)) + (vector-copy! (-> v1-5 string-max-val) (-> arg4 string-max-val)) + (vector-copy! (-> v1-5 view-off) (-> arg4 view-off)) + (set! (-> v1-5 frame) (the-as int (current-time))) + (set! (-> v1-5 iteration) arg2) + (set! (-> v1-5 move-type) arg3) + (set! (-> v1-5 min-z-override) (-> arg4 min-z-override)) + (set! (-> v1-5 string-push-z) (-> *camera* string-push-z)) + (set! (-> v1-5 view-off-param) (-> arg4 view-off-param)) + ) + (set! *cam-collision-record-show* *cam-collision-record-last*) + (set! *cam-collision-record-last* (+ *cam-collision-record-last* 1)) + (set! *cam-collision-record-last* (mod *cam-collision-record-last* 600)) + (when (= *cam-collision-record-last* *cam-collision-record-first*) + (set! *cam-collision-record-first* (+ *cam-collision-record-first* 1)) + (set! *cam-collision-record-first* (mod *cam-collision-record-first* 600)) + ) + ) + 0 + (none) + ) + +;; definition for function cam-collision-record-step +;; WARN: Return type mismatch int vs none. +(defun cam-collision-record-step ((arg0 int)) + (set! *cam-collision-record-show* (+ *cam-collision-record-show* arg0)) + (while (>= *cam-collision-record-show* 600) + (set! *cam-collision-record-show* (+ *cam-collision-record-show* -600)) + ) + (while (< *cam-collision-record-show* 0) + (set! *cam-collision-record-show* (+ *cam-collision-record-show* 600)) + ) + 0 + (none) + ) + +;; definition for function cam-collision-record-draw +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs none. +(defun cam-collision-record-draw () + (cond + ((cpad-pressed? 0 down) + (cam-collision-record-step 1) + ) + ((cpad-hold? 0 right) + (cam-collision-record-step 1) + ) + ((cpad-pressed? 0 up) + (cam-collision-record-step -1) + ) + ((cpad-hold? 0 left) + (cam-collision-record-step -1) + ) + ) + (let ((s5-0 (the-as object (+ (+ (* 176 *cam-collision-record-show*) 12) (the-as int *cam-collision-record*)))) + (s4-0 (new 'stack 'vector4w)) + (gp-0 (new 'stack 'vector4w)) + ) + (format *stdcon* "move-type ~A~%" (-> (the-as cam-collision-record s5-0) move-type)) + (cond + ((= (-> (the-as cam-collision-record s5-0) move-type) 'normal) + (set! (-> s4-0 x) 255) + (set! (-> s4-0 y) 255) + ) + ((= (-> (the-as cam-collision-record s5-0) move-type) 'jump) + (set! (-> s4-0 x) 255) + ) + ((= (-> (the-as cam-collision-record s5-0) move-type) 'no-hit) + (set! (-> s4-0 y) 255) + ) + (else + (set! (-> s4-0 z) 255) + ) + ) + (set! (-> s4-0 w) 128) + (set! (-> gp-0 x) 127) + (set! (-> gp-0 y) 127) + (set! (-> gp-0 z) 127) + (set! (-> gp-0 w) 128) + (camera-line-rel-len + (-> (the-as cam-collision-record s5-0) pos) + (-> (the-as cam-collision-record s5-0) vel) + (fmax 81.92 (vector-length (-> (the-as cam-collision-record s5-0) vel))) + s4-0 + ) + (let ((s3-0 (new 'stack-no-clear 'collide-query))) + (vector-copy! (-> s3-0 start-pos) (-> (the-as cam-collision-record s5-0) pos)) + (vector-copy! (-> s3-0 move-dist) (-> (the-as cam-collision-record s5-0) vel)) + (let ((v1-47 s3-0)) + (set! (-> v1-47 radius) (-> *CAMERA-bank* collide-move-rad)) + (set! (-> v1-47 collide-with) (collide-spec backgnd)) + (set! (-> v1-47 ignore-process0) #f) + (set! (-> v1-47 ignore-process1) #f) + (set! (-> v1-47 ignore-pat) (new 'static 'pat-surface :nocamera #x1 :probe #x1 :noendlessfall #x1)) + (set! (-> v1-47 action-mask) (collide-action solid)) + ) + (let ((f30-0 (fill-and-probe-using-line-sphere *collide-cache* s3-0)) + (s2-0 (new 'stack-no-clear 'vector)) + ) + (format + *stdcon* + "frame ~D iteration ~D travel ~f~%" + (-> (the-as cam-collision-record s5-0) frame) + (-> (the-as cam-collision-record s5-0) iteration) + f30-0 + ) + (format + *stdcon* + "mzo ~M psz ~M vop ~f~%" + (-> (the-as cam-collision-record s5-0) min-z-override) + (-> (the-as cam-collision-record s5-0) string-push-z) + (-> (the-as cam-collision-record s5-0) view-off-param) + ) + (format + *stdcon* + "pos ~M ~M ~M~%" + (-> (the-as cam-collision-record s5-0) pos x) + (-> (the-as cam-collision-record s5-0) pos y) + (-> (the-as cam-collision-record s5-0) pos z) + ) + (format + *stdcon* + "vel ~M ~M ~M~%" + (-> (the-as cam-collision-record s5-0) vel x) + (-> (the-as cam-collision-record s5-0) vel y) + (-> (the-as cam-collision-record s5-0) vel z) + ) + (format + *stdcon* + "des ~M ~M ~M~%" + (-> (the-as cam-collision-record s5-0) desired-pos x) + (-> (the-as cam-collision-record s5-0) desired-pos y) + (-> (the-as cam-collision-record s5-0) desired-pos z) + ) + (format + *stdcon* + "flt ~M ~M ~M~%" + (-> (the-as cam-collision-record s5-0) view-flat x) + (-> (the-as cam-collision-record s5-0) view-flat y) + (-> (the-as cam-collision-record s5-0) view-flat z) + ) + (format + *stdcon* + "cur ~M ~M ~M~%" + (-> (the-as cam-collision-record s5-0) cam-tpos-cur x) + (-> (the-as cam-collision-record s5-0) cam-tpos-cur y) + (-> (the-as cam-collision-record s5-0) cam-tpos-cur z) + ) + (format + *stdcon* + "old ~M ~M ~M~%" + (-> (the-as cam-collision-record s5-0) cam-tpos-old x) + (-> (the-as cam-collision-record s5-0) cam-tpos-old y) + (-> (the-as cam-collision-record s5-0) cam-tpos-old z) + ) + (format + *stdcon* + "smn ~M ~M ~M~%" + (-> (the-as cam-collision-record s5-0) string-min-val x) + (-> (the-as cam-collision-record s5-0) string-min-val y) + (-> (the-as cam-collision-record s5-0) string-min-val z) + ) + (format + *stdcon* + "smx ~M ~M ~M~%" + (-> (the-as cam-collision-record s5-0) string-max-val x) + (-> (the-as cam-collision-record s5-0) string-max-val y) + (-> (the-as cam-collision-record s5-0) string-max-val z) + ) + (format + *stdcon* + "vof ~M ~M ~M~%" + (-> (the-as cam-collision-record s5-0) view-off x) + (-> (the-as cam-collision-record s5-0) view-off y) + (-> (the-as cam-collision-record s5-0) view-off z) + ) + (when (>= f30-0 0.0) + (camera-line (the-as vector (-> s3-0 best-other-tri)) (-> s3-0 best-other-tri vertex 1) s4-0) + (camera-line (-> s3-0 best-other-tri vertex 1) (-> s3-0 best-other-tri vertex 2) s4-0) + (camera-line (-> s3-0 best-other-tri vertex 2) (the-as vector (-> s3-0 best-other-tri)) s4-0) + (vector-! s2-0 (the-as vector (+ (the-as int s5-0) 0)) (-> s3-0 best-other-tri intersect)) + (vector-normalize! s2-0 1.0) + (camera-line-rel-len (-> s3-0 best-other-tri intersect) s2-0 (-> *CAMERA-bank* collide-move-rad) gp-0) + (camera-line-rel-len + (-> s3-0 best-other-tri intersect) + (-> s3-0 best-other-tri normal) + (-> *CAMERA-bank* collide-move-rad) + gp-0 + ) + ) + ) + ) + ) + 0 + (none) + ) + +;; definition for function camera-master-debug +;; WARN: Return type mismatch int vs none. +(defun camera-master-debug ((arg0 camera-master)) + (when *display-cam-other* + (let ((f0-1 (/ (-> *camera-other-fov* data) 2))) + (camera-fov-frame + *camera-other-matrix* + *camera-other-trans* + f0-1 + 0.75 + 1.0 + (new 'static 'vector4w :x #xff :w #x80) + ) + ) + (camera-line *camera-other-trans* *camera-other-root* (new 'static 'vector4w :x #xff :y #xff :z #xff :w #x80)) + (let ((s4-0 (new 'stack-no-clear 'vector)) + (s5-0 *camera-other-trans*) + ) + (vector+float*! s4-0 s5-0 (-> *camera-other-matrix* rvec) 2048.0) + (camera-line s5-0 s4-0 (new 'static 'vector4w :x #xff :w #x80)) + (vector+float*! s4-0 s5-0 (-> *camera-other-matrix* uvec) 2048.0) + (camera-line s5-0 s4-0 (new 'static 'vector4w :y #xff :w #x80)) + (vector+float*! s4-0 s5-0 (-> *camera-other-matrix* fvec) 2048.0) + (camera-line s5-0 s4-0 (new 'static 'vector4w :z #xff :w #x80)) + ) + ) + (when *display-camera-last-attacker* + (format *stdcon* "last attacker '") + (let ((v1-16 (handle->process (-> last-try-to-look-at-data who)))) + (if v1-16 + (format *stdcon* "~S" (-> v1-16 name)) + ) + ) + (format *stdcon* "'~%") + ) + (when *display-camera-old-stats* + (format + *stdcon* + "old ~S cpu ~D old vu ~D (go to menu before comparing)~%" + *camera-old-level* + *camera-old-cpu* + *camera-old-vu* + ) + (format *stdcon* "old tfrag-mem ~D~%" (sar *camera-old-tfrag-bytes* 10)) + (format *stdcon* "~S~%" *camera-old-stat-string-tfrag-near*) + (format *stdcon* "~S~%" *camera-old-stat-string-tfrag*) + (format *stdcon* "~S~%" *camera-old-stat-string-total*) + ) + (if *display-cam-collide-history* + (cam-collision-record-draw) + ) + (if *display-cam-master-marks* + (debug-draw-spline (-> arg0 target-spline)) + ) + (if *display-xyz-axes* + (master-draw-coordinates (the-as vector #f)) + ) + (cam-debug-draw-tris) + 0 + (none) + ) + +;; definition for function debug-set-camera-pos-rot! +;; INFO: Used lq/sq +(defun debug-set-camera-pos-rot! ((arg0 vector) (arg1 matrix)) + (when (and *camera* *camera-combiner*) + (vector-copy! (-> *camera-combiner* trans) arg0) + (matrix-copy! (-> *camera-combiner* inv-camera-rot) arg1) + (set-setting-by-param *setting-control* 'mode-name 'cam-fixed 0 0) + (cam-master-activate-slave #t) + ) + arg0 + ) + +;; definition (debug) for function cam-restore +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs none. +(defun-debug cam-restore () + (let ((a0-0 (new-stack-vector0)) + (a1-0 (new-stack-matrix0)) + ) + (set! (-> a0-0 x) 1538892.5) + (set! (-> a0-0 y) -274716.78) + (set! (-> a0-0 z) -8318042.5) + (set! (-> a0-0 w) 1.0) + (set! (-> a1-0 rvec x) 0.4915) + (set! (-> a1-0 rvec y) 0.0) + (set! (-> a1-0 rvec z) -0.8708) + (set! (-> a1-0 rvec w) 0.0) + (set! (-> a1-0 uvec x) 0.7179) + (set! (-> a1-0 uvec y) 0.5659) + (set! (-> a1-0 uvec z) 0.4052) + (set! (-> a1-0 uvec w) 0.0) + (set! (-> a1-0 fvec x) 0.4928) + (set! (-> a1-0 fvec y) -0.8244) + (set! (-> a1-0 fvec z) 0.2782) + (set! (-> a1-0 fvec w) 0.0) + (set! (-> a1-0 trans x) 0.0) + (set! (-> a1-0 trans y) 0.0) + (set! (-> a1-0 trans z) 0.0) + (set! (-> a1-0 trans w) 1.0) + (debug-set-camera-pos-rot! a0-0 a1-0) + ) + (send-event *camera* 'set-fov 11650.845) + (clear *camera-old-level*) + (format *camera-old-level* "dig3a") + (set! *camera-old-cpu* 4815) + (set! *camera-old-vu* 6110) + (set! *camera-old-tfrag-bytes* #xa0130) + (clear *camera-old-stat-string-tfrag*) + (clear *camera-old-stat-string-tfrag-near*) + (clear *camera-old-stat-string-total*) + (set! *display-camera-old-stats* #t) + (set! (-> *tfrag-work* min-fragment) (the-as uint 318)) + (set! (-> *tfrag-work* max-fragment) (the-as uint 319)) + (none) + ) + +;; definition (debug) for function cam-restore-generic-bug +;; INFO: Used lq/sq +;; WARN: Return type mismatch symbol vs none. +(defun-debug cam-restore-generic-bug () + (let ((a0-0 (new-stack-vector0)) + (a1-0 (new-stack-matrix0)) + ) + (set! (-> a0-0 x) 9918803.0) + (set! (-> a0-0 y) 142780.03) + (set! (-> a0-0 z) 1278966.1) + (set! (-> a0-0 w) 1.0) + (set! (-> a1-0 rvec x) -0.5371) + (set! (-> a1-0 rvec y) 0.0) + (set! (-> a1-0 rvec z) 0.8434) + (set! (-> a1-0 rvec w) 0.0) + (set! (-> a1-0 uvec x) -0.2917) + (set! (-> a1-0 uvec y) 0.9382) + (set! (-> a1-0 uvec z) -0.1857) + (set! (-> a1-0 uvec w) 0.0) + (set! (-> a1-0 fvec x) -0.7914) + (set! (-> a1-0 fvec y) -0.3458) + (set! (-> a1-0 fvec z) -0.5039) + (set! (-> a1-0 fvec w) 0.0) + (set! (-> a1-0 trans x) 0.0) + (set! (-> a1-0 trans y) 0.0) + (set! (-> a1-0 trans z) 0.0) + (set! (-> a1-0 trans w) 1.0) + (debug-set-camera-pos-rot! a0-0 a1-0) + ) + (send-event *camera* 'set-fov 15152.451) + (clear *camera-old-level*) + (format *camera-old-level* "wasall") + (set! *camera-old-cpu* 8453) + (set! *camera-old-vu* -30883) + (set! *camera-old-tfrag-bytes* 0) + (clear *camera-old-stat-string-tfrag*) + (clear *camera-old-stat-string-tfrag-near*) + (clear *camera-old-stat-string-total*) + (set! *display-camera-old-stats* #t) + (none) + ) + + + + diff --git a/test/decompiler/reference/jak3/engine/debug/memory-usage_REF.gc b/test/decompiler/reference/jak3/engine/debug/memory-usage_REF.gc new file mode 100644 index 0000000000..9124065c95 --- /dev/null +++ b/test/decompiler/reference/jak3/engine/debug/memory-usage_REF.gc @@ -0,0 +1,609 @@ +;;-*-Lisp-*- +(in-package goal) + +;; this file is debug only +(declare-file (debug)) + +;; definition for method 3 of type memory-usage-block +(defmethod inspect ((this memory-usage-block)) + (format #t "-------------------------------------------------------------~%") + (format #t " # name count bytes used aligned bytes~%") + (format #t "-------------------------------------------------------------~%") + (let ((s5-0 0) + (s4-0 0) + ) + (dotimes (s3-0 (-> this length)) + (let ((v1-2 (-> this data s3-0))) + (+! s5-0 (-> v1-2 used)) + (+! s4-0 (-> v1-2 total)) + (format + #t + "~3D: ~20S ~7D ~8D ~8D~%" + s3-0 + (-> v1-2 name) + (-> v1-2 count) + (-> v1-2 used) + (-> v1-2 total) + ) + ) + ) + (format #t "total: ~8D ~8D~%" s5-0 s4-0) + ) + (format #t "-------------------------------------------------------------~%") + this + ) + +;; definition for method 8 of type object +(defmethod mem-usage ((this object) (usage memory-usage-block) (flags int)) + this + ) + +;; definition for method 10 of type memory-usage-block +(defmethod calculate-total ((this memory-usage-block)) + (let ((v0-0 0)) + (dotimes (v1-0 (-> this length)) + (+! v0-0 (-> this data v1-0 total)) + ) + v0-0 + ) + ) + +;; definition for method 9 of type memory-usage-block +(defmethod reset! ((this memory-usage-block)) + (set! (-> this length) 0) + (dotimes (v1-0 113) + (set! (-> this data v1-0 used) 0) + (set! (-> this data v1-0 total) 0) + (set! (-> this data v1-0 count) 0) + ) + this + ) + +;; definition for function mem-size +(defun mem-size ((arg0 basic) (arg1 symbol) (arg2 int)) + (let ((gp-0 (new 'stack 'memory-usage-block))) + (mem-usage arg0 gp-0 arg2) + (if arg1 + (inspect gp-0) + ) + (calculate-total gp-0) + ) + ) + +;; definition for method 14 of type level +(defmethod compute-memory-usage! ((this level) (arg0 symbol)) + (if (zero? (-> this mem-usage-block)) + (set! (-> this mem-usage-block) (new 'debug 'memory-usage-block)) + ) + (set! arg0 (or (zero? (-> this mem-usage-block length)) arg0)) + (when arg0 + (mem-usage this (reset! (-> this mem-usage-block)) 0) + (set! (-> this mem-usage) (calculate-total (-> this mem-usage-block))) + 0 + ) + (-> this mem-usage-block) + ) + +;; definition for method 8 of type process-tree +(defmethod mem-usage ((this process-tree) (usage memory-usage-block) (flags int)) + (let ((s3-0 91)) + (let* ((s2-0 *dead-pool-list*) + (a0-1 (car s2-0)) + ) + (while (not (null? s2-0)) + (set! (-> usage data s3-0 name) (symbol->string-debug (the-as symbol a0-1))) + (+! s3-0 1) + (set! s2-0 (cdr s2-0)) + (set! a0-1 (car s2-0)) + ) + ) + (set! (-> usage length) (max (-> usage length) s3-0)) + ) + (set! (-> usage data 97 name) "*debug-dead-pool*") + (set! *temp-mem-usage* usage) + (when (logtest? flags 32) + (let* ((s5-1 91) + (s4-1 *dead-pool-list*) + (v1-10 (car s4-1)) + ) + (while (not (null? s4-1)) + (let ((a0-4 (-> (the-as symbol v1-10) value))) + (set! *global-search-count* s5-1) + (iterate-process-tree + (the-as process-tree a0-4) + (lambda ((arg0 basic)) + (let ((gp-0 *temp-mem-usage*) + (s5-0 *global-search-count*) + ) + (+! (-> gp-0 data s5-0 used) 1) + (+! (-> gp-0 data s5-0 total) (logand -16 (+ (asize-of arg0) 15))) + ) + #t + ) + *null-kernel-context* + ) + ) + (+! s5-1 1) + (set! s4-1 (cdr s4-1)) + (set! v1-10 (car s4-1)) + ) + ) + ) + (iterate-process-tree + this + (lambda ((arg0 process-drawable)) + (let ((gp-0 *temp-mem-usage*)) + (let ((s4-0 (cond + ((= (-> arg0 pool) *8k-dead-pool*) + 92 + ) + ((= (-> arg0 pool) *16k-dead-pool*) + 93 + ) + ((= (-> arg0 pool) *nk-dead-pool*) + 94 + ) + ((= (-> arg0 pool) *target-dead-pool*) + 95 + ) + ((= (-> arg0 pool) *camera-dead-pool*) + 96 + ) + ((= (-> arg0 pool) *debug-dead-pool*) + 97 + ) + (else + 91 + ) + ) + ) + ) + (+! (-> gp-0 data s4-0 count) 1) + (+! (-> gp-0 data s4-0 total) (logand -16 (+ (asize-of arg0) 15))) + ) + (set! (-> gp-0 length) (max 99 (-> gp-0 length))) + (set! (-> gp-0 data 98 name) "process-active") + (+! (-> gp-0 data 98 count) 1) + (let ((v1-23 (asize-of arg0))) + (+! (-> gp-0 data 98 used) v1-23) + (+! (-> gp-0 data 98 total) (logand -16 (+ v1-23 15))) + ) + (set! (-> gp-0 length) (max 100 (-> gp-0 length))) + (set! (-> gp-0 data 99 name) "heap-total") + (+! (-> gp-0 data 99 count) 1) + (let ((v1-34 (+ (- -4 (the-as int arg0)) (the-as int (-> arg0 heap-cur))))) + (+! (-> gp-0 data 99 used) v1-34) + (+! (-> gp-0 data 99 total) (logand -16 (+ v1-34 15))) + ) + (set! (-> gp-0 length) (max 101 (-> gp-0 length))) + (set! (-> gp-0 data 100 name) "heap-process") + (+! (-> gp-0 data 100 count) 1) + (let ((v1-45 (- (-> arg0 type size) (-> arg0 type heap-base)))) + (+! (-> gp-0 data 100 used) v1-45) + (+! (-> gp-0 data 100 total) (logand -16 (+ v1-45 15))) + ) + (set! (-> gp-0 length) (max 102 (-> gp-0 length))) + (set! (-> gp-0 data 101 name) "heap-header") + (+! (-> gp-0 data 101 count) 1) + (let ((v1-55 (-> arg0 type heap-base))) + (+! (-> gp-0 data 101 used) v1-55) + (+! (-> gp-0 data 101 total) (logand -16 (+ v1-55 15))) + ) + (set! (-> gp-0 length) (max 103 (-> gp-0 length))) + (set! (-> gp-0 data 102 name) "heap-thread") + (+! (-> gp-0 data 102 count) 1) + (let ((v1-65 (asize-of (-> arg0 main-thread)))) + (+! (-> gp-0 data 102 used) v1-65) + (+! (-> gp-0 data 102 total) (logand -16 (+ v1-65 15))) + ) + (when (type? arg0 process-drawable) + (when (nonzero? (-> arg0 root)) + (set! (-> gp-0 length) (max 104 (-> gp-0 length))) + (set! (-> gp-0 data 103 name) "heap-root") + (+! (-> gp-0 data 103 count) 1) + (let ((v1-78 (asize-of (-> arg0 root)))) + (+! (-> gp-0 data 103 used) v1-78) + (+! (-> gp-0 data 103 total) (logand -16 (+ v1-78 15))) + ) + (when (type? (-> arg0 root) collide-shape) + (set! (-> gp-0 length) (max 110 (-> gp-0 length))) + (set! (-> gp-0 data 109 name) "heap-collide-prim") + (+! (-> gp-0 data 109 count) 1) + (let ((v1-90 (asize-of (-> (the-as collide-shape-moving (-> arg0 root)) root-prim)))) + (+! (-> gp-0 data 109 used) v1-90) + (+! (-> gp-0 data 109 total) (logand -16 (+ v1-90 15))) + ) + ) + ) + (when (nonzero? (-> arg0 node-list)) + (set! (-> gp-0 length) (max 107 (-> gp-0 length))) + (set! (-> gp-0 data 106 name) "heap-cspace") + (+! (-> gp-0 data 106 count) 1) + (let ((v1-102 (asize-of (-> arg0 node-list)))) + (+! (-> gp-0 data 106 used) v1-102) + (+! (-> gp-0 data 106 total) (logand -16 (+ v1-102 15))) + ) + ) + (when (nonzero? (-> arg0 draw)) + (set! (-> gp-0 length) (max 105 (-> gp-0 length))) + (set! (-> gp-0 data 104 name) "heap-draw-control") + (+! (-> gp-0 data 104 count) 1) + (let ((v1-114 (asize-of (-> arg0 draw)))) + (+! (-> gp-0 data 104 used) v1-114) + (+! (-> gp-0 data 104 total) (logand -16 (+ v1-114 15))) + ) + (when (nonzero? (-> arg0 draw skeleton)) + (set! (-> gp-0 length) (max 108 (-> gp-0 length))) + (set! (-> gp-0 data 107 name) "heap-bone") + (+! (-> gp-0 data 107 count) 1) + (let ((v1-128 (asize-of (-> arg0 draw skeleton)))) + (+! (-> gp-0 data 107 used) v1-128) + (+! (-> gp-0 data 107 total) (logand -16 (+ v1-128 15))) + ) + ) + ) + (when (nonzero? (-> arg0 skel)) + (set! (-> gp-0 length) (max 106 (-> gp-0 length))) + (set! (-> gp-0 data 105 name) "heap-joint-control") + (+! (-> gp-0 data 105 count) 1) + (let ((v1-140 (asize-of (-> arg0 skel)))) + (+! (-> gp-0 data 105 used) v1-140) + (+! (-> gp-0 data 105 total) (logand -16 (+ v1-140 15))) + ) + ) + (when (nonzero? (-> arg0 part)) + (set! (-> gp-0 length) (max 109 (-> gp-0 length))) + (set! (-> gp-0 data 108 name) "heap-part") + (+! (-> gp-0 data 108 count) 1) + (let ((v1-152 (asize-of (-> arg0 part)))) + (+! (-> gp-0 data 108 used) v1-152) + (+! (-> gp-0 data 108 total) (logand -16 (+ v1-152 15))) + ) + ) + (when (nonzero? (-> arg0 nav)) + (set! (-> gp-0 length) (max 111 (-> gp-0 length))) + (set! (-> gp-0 data 110 name) "heap-misc") + (+! (-> gp-0 data 110 count) 1) + (let ((v1-164 (asize-of (-> arg0 nav)))) + (+! (-> gp-0 data 110 used) v1-164) + (+! (-> gp-0 data 110 total) (logand -16 (+ v1-164 15))) + ) + ) + (when (nonzero? (-> arg0 path)) + (set! (-> gp-0 length) (max 111 (-> gp-0 length))) + (set! (-> gp-0 data 110 name) "heap-misc") + (+! (-> gp-0 data 110 count) 1) + (let ((v1-176 (asize-of (-> arg0 path)))) + (+! (-> gp-0 data 110 used) v1-176) + (+! (-> gp-0 data 110 total) (logand -16 (+ v1-176 15))) + ) + ) + (when (nonzero? (-> arg0 vol)) + (set! (-> gp-0 length) (max 111 (-> gp-0 length))) + (set! (-> gp-0 data 110 name) "heap-misc") + (+! (-> gp-0 data 110 count) 1) + (let ((v1-188 (asize-of (-> arg0 vol)))) + (+! (-> gp-0 data 110 used) v1-188) + (+! (-> gp-0 data 110 total) (logand -16 (+ v1-188 15))) + ) + ) + ) + ) + #t + ) + *null-kernel-context* + ) + this + ) + +;; definition for symbol *max-dma*, type int +(define *max-dma* 0) + +;; definition for method 11 of type memory-usage-block +;; INFO: Used lq/sq +(defmethod print-mem-usage ((this memory-usage-block) (arg0 level) (arg1 object)) + (local-vars (sv-16 object) (sv-32 string) (sv-48 symbol)) + (let ((s3-0 (&- (-> arg0 heap current) (the-as uint (-> arg0 heap base))))) + (let ((v1-2 (+ (-> this data 62 total) (-> this data 63 total)))) + (< #x10000 v1-2) + ) + (let* ((v1-4 (-> arg0 info memory-mode)) + (v1-5 + (cond + ((= v1-4 (level-memory-mode large)) + #xbd0000 + ) + ((= v1-4 (level-memory-mode medium)) + #x8fb800 + ) + ((or (= v1-4 (level-memory-mode small-center)) (= v1-4 (level-memory-mode city-center))) + #x627000 + ) + ((or (= v1-4 (level-memory-mode borrow)) + (= v1-4 (level-memory-mode borrow0)) + (= v1-4 (level-memory-mode borrow1)) + (= v1-4 (level-memory-mode borrow2)) + (= v1-4 (level-memory-mode borrow3)) + (= v1-4 (level-memory-mode borrow4)) + (= v1-4 (level-memory-mode borrow-city-small)) + ) + (+ (- #xc000 (the-as int (-> arg0 heap base))) (the-as int (-> arg0 heap top-base))) + ) + ((or (= v1-4 (level-memory-mode tiny-center)) + (= v1-4 (level-memory-mode tiny-edge)) + (= v1-4 (level-memory-mode city-tiny-edge)) + (= v1-4 (level-memory-mode tiny)) + ) + #x3f0000 + ) + ((= v1-4 (level-memory-mode micro)) + #x1f8000 + ) + ((= v1-4 (level-memory-mode tiny-center-micro)) + #x2f4000 + ) + ((= v1-4 (level-memory-mode tiny-center-small)) + #x4ec000 + ) + (else + #x5e8000 + ) + ) + ) + (a0-25 (-> arg0 info memory-mode)) + (v1-8 + (- (the-as int v1-5) + (the-as + uint + (if (or (= a0-25 (level-memory-mode tiny-center)) (or (= a0-25 (level-memory-mode tiny-edge)) + (= a0-25 (level-memory-mode city-tiny-edge)) + (= a0-25 (level-memory-mode tiny)) + ) + ) + #x24000 + #xc000 + ) + ) + ) + ) + (a0-28 0) + ) + (when (-> arg0 info borrow) + (dotimes (a1-21 5) + (+! a0-28 (-> arg0 info borrow borrow-size a1-21)) + ) + ) + (let ((s1-0 (- v1-8 (shl a0-28 10))) + (s2-0 (* (dma-buffer-length (-> *display* frames (-> *display* last-screen) global-buf)) 16)) + ) + (set! *max-dma* (max s2-0 *max-dma*)) + (if (< (- s1-0 (the-as int (shl (-> arg0 info buffer-size) 10))) s3-0) + (format arg1 "~3L") + ) + (let ((s0-0 format)) + (set! sv-16 arg1) + (set! sv-32 "~0K~10,'-S--~5,'-DK-of-~5,'-DK--~5,'-DK-of-~5,'-DK--") + (set! sv-48 (-> arg0 name)) + (let* ((s3-1 (sar s3-0 10)) + (s4-1 (- (sar s1-0 10) (the-as int (-> arg0 info buffer-size)))) + (s1-1 (sar (memory-used *nk-dead-pool*) 10)) + (t2-0 (sar (memory-total *nk-dead-pool*) 10)) + (t0-0 s4-1) + (t1-0 s1-1) + ) + (s0-0 sv-16 sv-32 sv-48 s3-1 t0-0 t1-0 t2-0) + (format arg1 "~5,'-DK/~5,'-DK--~%" (shr s2-0 10) (sar *max-dma* 10)) + (when *stats-memory-short* + (let ((s3-2 (if (cpad-hold? 1 l3) + #t + arg1 + ) + ) + (s4-2 format) + (s2-1 "heap-~5,'-DK/~5,'-DK----~D---~D/~D~%") + (s1-2 (sar (memory-used *nk-dead-pool*) 10)) + (s0-1 (sar (memory-total *nk-dead-pool*) 10)) + ) + (set! t0-0 (the-as int (compact-time *nk-dead-pool*))) + (set! t1-0 (the-as int (-> *nk-dead-pool* compact-count))) + (set! t2-0 (the-as int (-> *nk-dead-pool* compact-count-targ))) + (s4-2 s3-2 s2-1 s1-2 s0-1 (the-as uint t0-0) (the-as uint t1-0) (the-as uint t2-0)) + ) + ) + (when (not *stats-memory-short*) + (set! (-> *dma-mem-usage* data 88 total) + (* (dma-buffer-length (-> *display* frames (-> *display* last-screen) debug-buf)) 16) + ) + (let ((t9-11 format) + (a0-47 arg1) + (a1-28 " bsp ~192H~5DK ~280Hdebug~456H~5DK~%") + (a2-12 (sar (+ (-> this data 59 total) (-> this data 60 total) (-> this data 61 total)) 10)) + (a3-5 (sar (-> *dma-mem-usage* data 88 total) 10)) + ) + (t9-11 a0-47 a1-28 a2-12 a3-5 (the-as none t0-0) (the-as none t1-0) (the-as none t2-0)) + (format + arg1 + " bsp-leaf-vis ~192H~5DK~%" + (sar (+ (-> this data 62 total) (-> this data 63 total)) 10) + (the-as none a3-5) + ) + (format arg1 " level-code ~192H~5DK~%" (sar (-> this data 66 total) 10) (the-as none a3-5)) + ) + (format + arg1 + " tfrag ~192H~5DK ~280Htfragment~456H~5DK~%" + (sar + (+ (-> this data 1 total) + (-> this data 2 total) + (-> this data 3 total) + (-> this data 4 total) + (-> this data 5 total) + (-> this data 6 total) + (-> this data 7 total) + (-> this data 8 total) + ) + 10 + ) + (sar (-> *dma-mem-usage* data 1 total) 10) + ) + (format + arg1 + " tie-proto ~192H~5DK ~280Hsky~456H~5DK~%" + (sar + (+ (-> this data 9 total) + (-> this data 10 total) + (-> this data 11 total) + (-> this data 12 total) + (-> this data 13 total) + (-> this data 14 total) + (-> this data 16 total) + (-> this data 17 total) + ) + 10 + ) + (sar (-> *dma-mem-usage* data 89 total) 10) + ) + (format + arg1 + " tie-instance ~192H~5DK ~280Htie-fragment~456H~5DK~%" + (sar (+ (-> this data 18 total) (-> this data 20 total) (-> this data 21 total) (-> this data 22 total)) 10) + (sar (-> *dma-mem-usage* data 9 total) 10) + ) + (format + arg1 + " shrub-proto ~192H~5DK ~280Htie-scissor~456H~5DK~%" + (sar + (+ (-> this data 25 total) + (-> this data 26 total) + (-> this data 27 total) + (-> this data 28 total) + (-> this data 29 total) + (-> this data 30 total) + (-> this data 31 total) + (-> this data 32 total) + (-> this data 33 total) + ) + 10 + ) + (sar (-> *dma-mem-usage* data 15 total) 10) + ) + (format + arg1 + " shrub-instance ~192H~5DK ~280Hshrubbery~456H~5DK~%" + (sar (-> this data 34 total) 10) + (sar (-> *dma-mem-usage* data 27 total) 10) + ) + (format + arg1 + " hfragment ~192H~5DK ~280Hhfragment~456H~5DK~%" + (sar (-> this data 43 total) 10) + (sar (-> *dma-mem-usage* data 43 total) 10) + (the-as none t0-0) + (the-as none t1-0) + (the-as none t2-0) + ) + (format + arg1 + " collision ~192H~5DK ~280Htie-generic~456H~5DK~%" + (sar + (+ (-> this data 51 total) + (-> this data 52 total) + (-> this data 53 total) + (-> this data 54 total) + (-> this data 55 total) + (-> this data 56 total) + (-> this data 57 total) + (-> this data 58 total) + ) + 10 + ) + (sar (-> *dma-mem-usage* data 17 total) 10) + ) + (format + arg1 + " pris-geo ~192H~5DK ~280Hpris-fragment~456H~5DK~%" + (sar + (+ (-> this data 35 total) + (-> this data 36 total) + (-> this data 37 total) + (-> this data 38 total) + (-> this data 39 total) + (-> this data 40 total) + (-> this data 41 total) + (-> this data 42 total) + (-> this data 74 total) + (-> this data 75 total) + (-> this data 76 total) + (-> this data 77 total) + (-> this data 79 total) + (-> this data 82 total) + (-> this data 81 total) + (-> this data 112 total) + ) + 10 + ) + (sar (-> *dma-mem-usage* data 35 total) 10) + ) + (format + arg1 + " pris-anim ~192H~5DK ~280Hpris-generic~456H~5DK~%" + (sar + (+ (-> this data 68 total) + (-> this data 69 total) + (-> this data 70 total) + (-> this data 71 total) + (-> this data 72 total) + (-> this data 78 total) + (-> this data 80 total) + (-> this data 73 total) + ) + 10 + ) + (sar (-> *dma-mem-usage* data 90 total) 10) + ) + (format + arg1 + " textures ~192H~5DK ~280Htextures~456H~5DK~%" + (sar (-> this data 83 total) 10) + (sar (-> *dma-mem-usage* data 83 total) 10) + ) + (format arg1 " entity ~192H~5DK~%" (sar + (+ (-> this data 67 total) + (-> this data 44 total) + (-> this data 45 total) + (-> this data 46 total) + (-> this data 50 total) + (-> this data 49 total) + (-> this data 47 total) + (-> this data 48 total) + ) + 10 + ) + ) + (format + arg1 + " misc ~192H~5DK ~280Hsprite~456H~5DK~%" + (sar + (+ (-> this data 0 total) + (-> this data 64 total) + (-> this data 65 total) + (-> this data 84 total) + (-> this data 85 total) + ) + 10 + ) + (sar (-> *dma-mem-usage* data 86 total) 10) + ) + ) + ) + ) + ) + ) + ) + (format arg1 "~1K~0L") + this + ) + + + + diff --git a/test/decompiler/reference/jak3/engine/debug/sampler_REF.gc b/test/decompiler/reference/jak3/engine/debug/sampler_REF.gc new file mode 100644 index 0000000000..ed65b9f988 --- /dev/null +++ b/test/decompiler/reference/jak3/engine/debug/sampler_REF.gc @@ -0,0 +1,55 @@ +;;-*-Lisp-*- +(in-package goal) + +;; this file is debug only +(declare-file (debug)) + +;; definition for symbol *sampler-mem*, type pointer +(define *sampler-mem* (the-as pointer #f)) + +;; definition for symbol *sampler-compare*, type uint +(define *sampler-compare* (the-as uint 1)) + +;; definition for symbol *sampler-count*, type int +(define *sampler-count* 0) + +;; definition (debug) for function timer0-handler +;; ERROR: function was not converted to expressions. Cannot decompile. + +;; failed to figure out what this is: +(set! (-> (the-as timer-bank #x10000000) mode) (new 'static 'timer-mode)) + +;; failed to figure out what this is: +(install-handler 9 timer0-handler) + +;; definition (debug) for function sampler-start +;; WARN: Return type mismatch int vs none. +(defun-debug sampler-start () + (set! (-> (the-as timer-bank #x10000000) mode) (new 'static 'timer-mode)) + (set! (-> (the-as timer-bank #x10000000) count) (the-as uint 0)) + (set! (-> (the-as timer-bank #x10000000) comp) *sampler-compare*) + (if (not *sampler-mem*) + (set! *sampler-mem* (malloc 'debug #x1000000)) + ) + (when (nonzero? *sampler-mem*) + (mem-set32! *sampler-mem* #x400000 0) + (set! (-> (the-as timer-bank #x10000000) mode) + (new 'static 'timer-mode :clks (timer-clock-selection busclk/256) :zret #x1 :cue #x1 :cmpe #x1 :equf #x1) + ) + (set! *sampler-count* 0) + 0 + ) + (none) + ) + +;; definition (debug) for function sampler-stop +;; WARN: Return type mismatch int vs none. +(defun-debug sampler-stop () + (set! (-> (the-as timer-bank #x10000000) mode) (new 'static 'timer-mode)) + 0 + (none) + ) + + + + diff --git a/test/decompiler/reference/jak3/engine/gfx/texture/texture-finish_REF.gc b/test/decompiler/reference/jak3/engine/gfx/texture/texture-finish_REF.gc new file mode 100644 index 0000000000..b48473bfd3 --- /dev/null +++ b/test/decompiler/reference/jak3/engine/gfx/texture/texture-finish_REF.gc @@ -0,0 +1,36 @@ +;;-*-Lisp-*- +(in-package goal) + +;; failed to figure out what this is: +(setup-font-texture *texture-pool*) + +;; failed to figure out what this is: +(let ((v1-2 (get-texture skull-gem-dest programmer))) + (when v1-2 + (set! (-> v1-2 w) 32) + (set! (-> v1-2 h) 32) + (set! (-> v1-2 dest 0) (-> *skull-gem-texture-base* vram-block)) + ) + ) + +;; failed to figure out what this is: +(init! *sky-texture-anim-array*) + +;; failed to figure out what this is: +(init! *darkjak-texture-anim-array*) + +;; failed to figure out what this is: +(init! *skull-gem-texture-anim-array*) + +;; failed to figure out what this is: +(init! *default-water-texture-anim-array*) + +;; failed to figure out what this is: +(init! *default-warp-texture-anim-array*) + +;; failed to figure out what this is: +(kmemclose) + + + + diff --git a/test/decompiler/reference/jak3/engine/gfx/texture/texture-upload_REF.gc b/test/decompiler/reference/jak3/engine/gfx/texture/texture-upload_REF.gc new file mode 100644 index 0000000000..478e1c6b9a --- /dev/null +++ b/test/decompiler/reference/jak3/engine/gfx/texture/texture-upload_REF.gc @@ -0,0 +1,33 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition for symbol *generic-envmap-texture*, type texture +(define *generic-envmap-texture* (get-texture pal-environment-front environment-generic)) + +;; definition for symbol *default-envmap-shader*, type adgif-shader +(define *default-envmap-shader* (new 'global 'adgif-shader)) + +;; failed to figure out what this is: +(let ((gp-0 *default-envmap-shader*)) + (let ((a1-1 *generic-envmap-texture*)) + (adgif-shader<-texture! gp-0 a1-1) + ) + (set! (-> gp-0 tex1) (new 'static 'gs-tex1 :mmag #x1 :mmin #x1)) + (set! (-> gp-0 clamp) (new 'static 'gs-clamp :wms (gs-tex-wrap-mode clamp) :wmt (gs-tex-wrap-mode clamp))) + (set! (-> gp-0 alpha) (new 'static 'gs-miptbp :tbp1 #x58)) + (set! (-> gp-0 prims 1) (gs-reg64 tex0-1)) + (set! (-> gp-0 prims 3) (gs-reg64 tex1-1)) + (set! (-> gp-0 prims 5) (gs-reg64 miptbp1-1)) + (set! (-> gp-0 clamp-reg) (gs-reg64 clamp-1)) + (set! (-> gp-0 prims 9) (gs-reg64 alpha-1)) + ) + +;; failed to figure out what this is: +(set! (-> *texture-pool* allocate-func) texture-page-common-boot-allocate) + +;; failed to figure out what this is: +(kmemopen global "tpages") + + + + diff --git a/test/decompiler/reference/jak3/levels/common/enemy/hover/hover-nav-edit_REF.gc b/test/decompiler/reference/jak3/levels/common/enemy/hover/hover-nav-edit_REF.gc new file mode 100644 index 0000000000..205bf16246 --- /dev/null +++ b/test/decompiler/reference/jak3/levels/common/enemy/hover/hover-nav-edit_REF.gc @@ -0,0 +1,685 @@ +;;-*-Lisp-*- +(in-package goal) + +;; this file is debug only +(declare-file (debug)) + +;; definition for function probe-for-clear-collision? +;; INFO: Used lq/sq +(defun probe-for-clear-collision? ((arg0 vector) (arg1 vector)) + (let ((s5-0 (new 'stack-no-clear 'collide-query))) + (vector-copy! (-> s5-0 start-pos) arg0) + (vector-! (-> s5-0 move-dist) arg1 arg0) + (let ((v1-2 s5-0)) + (set! (-> v1-2 radius) 4096.0) + (set! (-> v1-2 collide-with) (collide-spec backgnd)) + (set! (-> v1-2 ignore-process0) #f) + (set! (-> v1-2 ignore-process1) #f) + (set! (-> v1-2 ignore-pat) + (new 'static 'pat-surface :noentity #x1 :nojak #x1 :probe #x1 :noendlessfall #x1 :board #x1) + ) + (set! (-> v1-2 action-mask) (collide-action solid)) + ) + (when (< (fill-and-probe-using-line-sphere *collide-cache* s5-0) 0.0) + (let ((s4-0 (new 'stack-no-clear 'vector))) + (vector-copy! s4-0 arg0) + (let* ((f0-2 (vector-vector-distance s4-0 arg1)) + (s3-1 (+ (the int (/ f0-2 (meters 30))) 1)) + (s2-0 (vector-normalize-copy! (new 'stack-no-clear 'vector) (-> s5-0 move-dist) 110592.0)) + ) + (dotimes (s1-0 s3-1) + (vector-copy! (-> s5-0 start-pos) s4-0) + (vector-! (-> s5-0 move-dist) arg1 s4-0) + (if (< 122880.0 (vector-length (-> s5-0 move-dist))) + (vector-normalize! (-> s5-0 move-dist) 122880.0) + ) + (let ((v1-15 s5-0)) + (set! (-> v1-15 radius) 12288.0) + (set! (-> v1-15 collide-with) (collide-spec backgnd)) + (set! (-> v1-15 ignore-process0) #f) + (set! (-> v1-15 ignore-process1) #f) + (set! (-> v1-15 ignore-pat) + (new 'static 'pat-surface :noentity #x1 :nojak #x1 :probe #x1 :noendlessfall #x1 :board #x1) + ) + (set! (-> v1-15 action-mask) (collide-action solid)) + ) + (if (>= (fill-and-probe-using-line-sphere *collide-cache* s5-0) 0.0) + (return #f) + ) + (vector+! s4-0 s4-0 s2-0) + ) + ) + ) + #t + ) + ) + ) + +;; definition for function hover-nav-graph-process-points +;; WARN: Return type mismatch int vs none. +(defun hover-nav-graph-process-points () + (local-vars (v1-10 symbol)) + (let ((v1-0 (get-nav-graph-editor))) + (when v1-0 + (let* ((gp-0 (-> v1-0 nav-graph)) + (s5-0 (-> gp-0 node-array length)) + ) + (dotimes (s4-0 s5-0) + (let ((s3-0 (+ (the-as uint (-> gp-0 node-array data 0 position)) (* 80 s4-0)))) + (when (< s4-0 (+ s5-0 -1)) + (let ((s2-0 (+ s4-0 1))) + (while (< s2-0 s5-0) + (let ((s1-0 (+ (the-as uint (-> gp-0 node-array data 0 position)) (* 80 s2-0)))) + (dotimes (v1-8 (-> gp-0 edge-array length)) + (let* ((a1-1 (-> gp-0 edge-array data v1-8)) + (a0-8 (-> a1-1 runtime-node-id-1)) + (a1-2 (-> a1-1 runtime-node-id-2)) + ) + (when (or (and (= s4-0 a0-8) (= s2-0 a1-2)) (and (= s4-0 a1-2) (= s2-0 a0-8))) + (set! v1-10 #t) + (goto cfg-19) + ) + ) + ) + (set! v1-10 #f) + (label cfg-19) + (when (not v1-10) + (when (and (< (vector-vector-distance (the-as vector s3-0) (the-as vector s1-0)) 204800.0) + (probe-for-clear-collision? (the-as vector s3-0) (the-as vector s1-0)) + (probe-for-clear-collision? (the-as vector s1-0) (the-as vector s3-0)) + ) + (let ((v1-17 (alloc-new-edge! gp-0))) + (when (!= v1-17 -1) + (let ((v1-20 (-> gp-0 edge-array data v1-17))) + (set! (-> v1-20 runtime-node-id-1) s4-0) + (set! (-> v1-20 runtime-node-id-2) s2-0) + (set! (-> v1-20 directionality) (nav-directionality bi_directional)) + (set! (-> v1-20 speed_limit) 122880.0) + (set! (-> v1-20 density) 1.0) + (set! (-> v1-20 traffic_edge_flag) 0) + (set! (-> v1-20 nav_clock_mask) (nav-clock-mask)) + (set! (-> v1-20 nav_clock_type) (nav-clock-type no-clock)) + (set! (-> v1-20 width) 0.0) + (set! (-> v1-20 minimap_edge_flag) (nav-minimap-edge-flag)) + ) + 0 + ) + ) + ) + ) + ) + (+! s2-0 1) + ) + ) + ) + ) + ) + ) + ) + ) + 0 + (none) + ) + +;; definition for function hover-nav-graph-output +;; INFO: Used lq/sq +;; WARN: Return type mismatch file-stream vs object. +(defun hover-nav-graph-output ((arg0 string)) + (local-vars + (sv-96 vector) + (sv-112 vector) + (sv-128 int) + (sv-144 int) + (sv-160 (function _varargs_ object)) + (sv-176 string) + (sv-192 string) + (sv-208 int) + (sv-224 (function _varargs_ object)) + (sv-240 string) + (sv-256 string) + (sv-272 int) + ) + (rlet ((vf0 :class vf) + (vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + ) + (init-vf0-vector) + (let ((s4-0 (new 'stack-no-clear 'vector)) + (gp-0 (new 'debug 'string #x7a120 (the-as string #f))) + ) + (let ((s3-0 (clear *temp-string*))) + (format s3-0 "select translate_x,translate_y,translate_z from level_info where name='~S'" arg0) + (format 0 "~S~%" s3-0) + (let ((s2-0 (sql-query s3-0))) + (when (!= (-> s2-0 content-type) 'select) + (format 0 "ERROR: sql: select error ~A~%" s2-0) + (return (the-as object #f)) + ) + (set-vector! + s4-0 + (* 4096.0 (string->float (the-as string (-> s2-0 sql-data 0)))) + (* 4096.0 (string->float (the-as string (-> s2-0 sql-data 1)))) + (* 4096.0 (string->float (the-as string (-> s2-0 sql-data 2)))) + 1.0 + ) + ) + ) + (format 0 "level offset: ~m ~m ~m~%" (-> s4-0 x) (-> s4-0 y) (-> s4-0 z)) + (let ((s3-2 (new 'debug 'mysql-nav-graph (the-as string 'hover)))) + (when (or (not s3-2) (not (init-from-sql! s3-2 'hover arg0))) + (format 0 "ERROR: Failed to load hover graph (level ~s) from MySQL!~%" arg0) + (return (the-as object #f)) + ) + (format gp-0 ";-*-Lisp-*-~%(in-package goal)~%~%;;~%") + (format + gp-0 + ";; WARNING: This file was generated by running (hover-nav-graph-output ...) found in hover-nav-edit.gc.~%;;~%~%" + ) + (format gp-0 "(def-nav-network-adjacency-table *~S-adjacency*~% (~%" arg0) + (let ((s2-1 (-> s3-2 node-array length)) + (s1-0 0) + ) + (dotimes (s0-0 s2-1) + (when (nonzero? (-> s3-2 node-array data s0-0 nav_node_id)) + (set! sv-96 (new 'stack-no-clear 'vector)) + (let ((v1-22 (+ (the-as uint (-> s3-2 node-array data 0 position)) (* 80 s0-0))) + (a0-22 s4-0) + ) + (.mov.vf.w vf6 vf0) + (.lvf vf4 (&-> (the-as (pointer int128) v1-22))) + (.lvf vf5 (&-> a0-22 quad)) + ) + (.add.vf.xyz vf6 vf4 vf5) + (.svf (&-> sv-96 quad) vf6) + (set! sv-112 (new 'stack-no-clear 'vector)) + (format gp-0 " (~d (~m ~m ~m) (" s1-0 (-> sv-96 x) (-> sv-96 y) (-> sv-96 z)) + (set! sv-128 0) + (while (< sv-128 (-> s3-2 edge-array length)) + (let ((v1-32 (-> s3-2 edge-array data sv-128))) + (set! sv-272 (-> v1-32 runtime-node-id-1)) + (set! sv-144 (-> v1-32 runtime-node-id-2)) + ) + (when (= s0-0 sv-272) + (vector+! sv-112 (the-as vector (+ (the-as uint (-> s3-2 node-array data 0 position)) (* 80 sv-144))) s4-0) + (set! sv-160 format) + (set! sv-176 gp-0) + (set! sv-192 "(~d ~m) ") + (set! sv-208 sv-144) + (let ((a3-3 (vector-vector-distance sv-96 sv-112))) + (sv-160 sv-176 sv-192 sv-208 a3-3) + ) + ) + (when (= s0-0 sv-144) + (vector+! sv-112 (the-as vector (+ (the-as uint (-> s3-2 node-array data 0 position)) (* 80 sv-272))) s4-0) + (set! sv-224 format) + (set! sv-240 gp-0) + (set! sv-256 "(~d ~m) ") + (let ((a3-4 (vector-vector-distance sv-96 sv-112))) + (sv-224 sv-240 sv-256 sv-272 a3-4) + ) + ) + (set! sv-128 (+ sv-128 1)) + ) + (format gp-0 "))~%") + (+! s1-0 1) + ) + ) + ) + (format gp-0 " )~% (") + (dotimes (s4-1 (-> s3-2 edge-array length)) + (let ((v1-58 (-> s3-2 edge-array data s4-1))) + (format + gp-0 + "(~d ~d ~m) " + (-> v1-58 runtime-node-id-1) + (-> v1-58 runtime-node-id-2) + (if (!= 0.0 (-> v1-58 width)) + (-> v1-58 width) + #x46800000 + ) + ) + ) + (if (= (logand (+ s4-1 -1) 7) 7) + (format gp-0 "~% ") + ) + ) + ) + (format gp-0 ")~%") + (format gp-0 " )~%") + (format (clear *temp-string*) "game/hover-nav-graph-~s.gc" arg0) + *temp-string* + (format 0 "Writing nav-graph as file ~S...~%" *temp-string*) + (let ((s5-1 (new 'stack 'file-stream *temp-string* 'write))) + (format s5-1 gp-0) + (file-stream-close s5-1) + ) + ) + ) + ) + +;; definition for symbol *axes-table*, type (array vector) +(define *axes-table* (new 'static 'boxed-array :type vector + (new 'static 'vector :x 1.0 :w 1.0) + (new 'static 'vector :y 1.0 :w 1.0) + (new 'static 'vector :z 1.0 :w 1.0) + ) + ) + +;; definition of type hover-nav-bsp-point +(deftype hover-nav-bsp-point (list-node) + ((index int32) + (pos vector :inline) + ) + (:methods + (new (symbol type) _type_) + ) + ) + +;; definition for method 3 of type hover-nav-bsp-point +(defmethod inspect ((this hover-nav-bsp-point)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'hover-nav-bsp-point) + (format #t "~1Tnext: #~%" (-> this next)) + (format #t "~1Tprev: #~%" (-> this prev)) + (format #t "~1Tindex: ~D~%" (-> this index)) + (format #t "~1Tpos: #~%" (-> this pos)) + (label cfg-4) + this + ) + +;; definition for method 0 of type hover-nav-bsp-point +;; WARN: Return type mismatch structure vs hover-nav-bsp-point. +(defmethod new hover-nav-bsp-point ((allocation symbol) (type-to-make type)) + (let ((t9-0 (method-of-type structure new)) + (v1-1 type-to-make) + ) + (-> type-to-make size) + (let ((v0-0 (t9-0 allocation v1-1))) + (set! (-> (the-as hover-nav-bsp-point v0-0) next) #f) + (set! (-> (the-as hover-nav-bsp-point v0-0) prev) #f) + (the-as hover-nav-bsp-point v0-0) + ) + ) + ) + +;; definition of type hover-nav-bsp-node +(deftype hover-nav-bsp-node (structure) + ((split-plane vector :inline) + (point-list hover-nav-bsp-point) + (left hover-nav-bsp-node) + (right hover-nav-bsp-node) + ) + (:methods + (new (symbol type) _type_) + (hover-nav-bsp-node-method-9 (_type_) none) + (hover-nav-bsp-node-method-10 (_type_ int) none) + ) + ) + +;; definition for method 3 of type hover-nav-bsp-node +(defmethod inspect ((this hover-nav-bsp-node)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'hover-nav-bsp-node) + (format #t "~1Tsplit-plane: #~%" (-> this split-plane)) + (format #t "~1Tpoint-list: #~%" (-> this point-list)) + (format #t "~1Tleft: #~%" (-> this left)) + (format #t "~1Tright: #~%" (-> this right)) + (label cfg-4) + this + ) + +;; definition for method 0 of type hover-nav-bsp-node +;; WARN: Return type mismatch structure vs hover-nav-bsp-node. +(defmethod new hover-nav-bsp-node ((allocation symbol) (type-to-make type)) + (let ((t9-0 (method-of-type structure new)) + (v1-1 type-to-make) + ) + (-> type-to-make size) + (let ((v0-0 (t9-0 allocation v1-1))) + (set! (-> (the-as hover-nav-bsp-node v0-0) point-list) #f) + (set! (-> (the-as hover-nav-bsp-node v0-0) left) #f) + (set! (-> (the-as hover-nav-bsp-node v0-0) right) #f) + (the-as hover-nav-bsp-node v0-0) + ) + ) + ) + +;; definition of type hover-nav-bsp +(deftype hover-nav-bsp (structure) + ((root hover-nav-bsp-node) + ) + ) + +;; definition for method 3 of type hover-nav-bsp +(defmethod inspect ((this hover-nav-bsp)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'hover-nav-bsp) + (format #t "~1Troot: #~%" (-> this root)) + (label cfg-4) + this + ) + +;; definition for method 9 of type hover-nav-bsp-node +;; WARN: Return type mismatch int vs none. +(defmethod hover-nav-bsp-node-method-9 ((this hover-nav-bsp-node)) + (let ((v1-0 (-> this split-plane))) + (format #t "((~,,1f ~,,1f ~,,1f ~m)~% " (-> v1-0 x) (-> v1-0 y) (-> v1-0 z) (-> v1-0 w)) + ) + (let ((v1-2 (the-as list-node (-> this point-list)))) + (while v1-2 + (let ((s5-0 (-> v1-2 next))) + (format + #t + "(~d (~m ~m ~m)) " + (-> (the-as hover-nav-bsp-point v1-2) index) + (-> (the-as hover-nav-bsp-point v1-2) pos x) + (-> (the-as hover-nav-bsp-point v1-2) pos y) + (-> (the-as hover-nav-bsp-point v1-2) pos z) + ) + (set! v1-2 s5-0) + ) + ) + ) + (if (-> this left) + (hover-nav-bsp-node-method-9 (-> this left)) + ) + (if (-> this right) + (hover-nav-bsp-node-method-9 (-> this right)) + ) + (format #t ")~%") + 0 + (none) + ) + +;; definition for method 10 of type hover-nav-bsp-node +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs none. +(defmethod hover-nav-bsp-node-method-10 ((this hover-nav-bsp-node) (arg0 int)) + (when (-> this point-list) + (format 0 "build-bsp: ") + (let ((s4-0 (new 'stack-no-clear 'vector)) + (s3-0 0) + ) + (let ((v1-2 (the-as list-node (-> this point-list)))) + (while v1-2 + (set! v1-2 (-> v1-2 next)) + (+! s3-0 1) + ) + ) + (format 0 "count ~d ~%" s3-0) + (when (< 1 s3-0) + (vector-reset! s4-0) + (let ((f0-1 (/ 1.0 (the float s3-0))) + (a2-1 (the-as list-node (-> this point-list))) + ) + (while a2-1 + (let ((v1-9 (-> a2-1 next))) + (vector+float*! s4-0 s4-0 (the-as vector (+ (the-as uint a2-1) 16)) f0-1) + (set! a2-1 v1-9) + ) + ) + ) + (vector-copy! (-> this split-plane) (-> *axes-table* arg0)) + (set! (-> this split-plane w) (- (vector-dot s4-0 (-> this split-plane)))) + (let ((s3-1 (the-as list-node (-> this point-list)))) + (while s3-1 + (let ((s4-1 (-> s3-1 next))) + (let ((f0-7 (- (vector-dot (the-as vector (+ (the-as uint s3-1) 16)) (-> this split-plane))))) + (cond + ((= f0-7 (-> this split-plane w)) + ) + ((< f0-7 (-> this split-plane w)) + (if (not (-> this left)) + (set! (-> this left) (new 'global 'hover-nav-bsp-node)) + ) + (let ((v1-21 s3-1)) + (let ((a0-12 (&-> this point-list))) + (if (= (-> a0-12 0) v1-21) + (set! (-> a0-12 0) (the-as hover-nav-bsp-point (-> v1-21 next))) + ) + ) + (if (-> v1-21 prev) + (set! (-> v1-21 prev next) (-> v1-21 next)) + ) + (if (-> v1-21 next) + (set! (-> v1-21 next prev) (-> v1-21 prev)) + ) + (set! (-> v1-21 prev) #f) + (set! (-> v1-21 next) #f) + ) + (let ((a0-19 (-> this left point-list)) + (v1-25 (&-> this left point-list)) + ) + (when (zero? s3-1) + (break!) + 0 + ) + (when (or (= s3-1 a0-19) (= s3-1 v1-25)) + (break!) + 0 + ) + (when (not (or (not a0-19) (!= (-> a0-19 prev) s3-1))) + (break!) + 0 + ) + (when a0-19 + (set! (-> s3-1 next) a0-19) + (set! (-> s3-1 prev) (-> a0-19 prev)) + (if (-> s3-1 prev) + (set! (-> s3-1 prev next) s3-1) + ) + (if (-> s3-1 next) + (set! (-> s3-1 next prev) s3-1) + ) + ) + (if (or (not a0-19) (= a0-19 (-> v1-25 0))) + (set! (-> v1-25 0) (the-as hover-nav-bsp-point s3-1)) + ) + ) + ) + (else + (if (not (-> this right)) + (set! (-> this right) (new 'global 'hover-nav-bsp-node)) + ) + (let ((v1-30 s3-1)) + (let ((a0-22 (&-> this point-list))) + (if (= (-> a0-22 0) v1-30) + (set! (-> a0-22 0) (the-as hover-nav-bsp-point (-> v1-30 next))) + ) + ) + (if (-> v1-30 prev) + (set! (-> v1-30 prev next) (-> v1-30 next)) + ) + (if (-> v1-30 next) + (set! (-> v1-30 next prev) (-> v1-30 prev)) + ) + (set! (-> v1-30 prev) #f) + (set! (-> v1-30 next) #f) + ) + (let ((v1-32 s3-1) + (a1-40 (-> this right point-list)) + (a0-31 (&-> this right point-list)) + ) + (when (zero? v1-32) + (break!) + 0 + ) + (when (or (= v1-32 a1-40) (= v1-32 a0-31)) + (break!) + 0 + ) + (when (not (or (not a1-40) (!= (-> a1-40 prev) v1-32))) + (break!) + 0 + ) + (when a1-40 + (set! (-> v1-32 next) a1-40) + (set! (-> v1-32 prev) (-> a1-40 prev)) + (if (-> v1-32 prev) + (set! (-> v1-32 prev next) v1-32) + ) + (if (-> v1-32 next) + (set! (-> v1-32 next prev) v1-32) + ) + ) + (if (or (not a1-40) (= a1-40 (-> a0-31 0))) + (set! (-> a0-31 0) (the-as hover-nav-bsp-point v1-32)) + ) + ) + ) + ) + ) + (set! s3-1 s4-1) + ) + ) + ) + (if (-> this left) + (hover-nav-bsp-node-method-10 (-> this left) (mod (+ arg0 1) 3)) + ) + (if (-> this right) + (hover-nav-bsp-node-method-10 (-> this right) (mod (+ arg0 1) 3)) + ) + ) + ) + ) + 0 + (none) + ) + +;; definition for symbol *hover-bsp*, type hover-nav-bsp +(define *hover-bsp* (the-as hover-nav-bsp #f)) + +;; definition for function hover-nav-graph-output-bsp +;; INFO: Used lq/sq +(defun hover-nav-graph-output-bsp () + (let ((v1-0 (get-nav-graph-editor))) + (when v1-0 + (let ((s5-0 (-> v1-0 nav-graph)) + (gp-0 (new 'global 'hover-nav-bsp)) + ) + (let ((s4-0 (-> s5-0 node-array length)) + (s3-0 0) + ) + (set! (-> gp-0 root) (new 'global 'hover-nav-bsp-node)) + (dotimes (s2-0 s4-0) + (when (nonzero? (-> s5-0 node-array data s2-0 nav_node_id)) + (let ((v1-9 (new 'global 'hover-nav-bsp-point))) + (set! (-> v1-9 index) s3-0) + (set! (-> v1-9 pos quad) + (-> (the-as (pointer uint128) (+ (the-as uint (-> s5-0 node-array data 0 position)) (* 80 s2-0)))) + ) + (let ((a1-7 (-> gp-0 root point-list)) + (a0-8 (&-> gp-0 root point-list)) + ) + (when (zero? v1-9) + (break!) + 0 + ) + (when (or (= v1-9 a1-7) (= v1-9 a0-8)) + (break!) + 0 + ) + (when (not (or (not a1-7) (!= (-> a1-7 prev) v1-9))) + (break!) + 0 + ) + (when a1-7 + (set! (-> v1-9 next) a1-7) + (set! (-> v1-9 prev) (-> a1-7 prev)) + (if (-> v1-9 prev) + (set! (-> v1-9 prev next) v1-9) + ) + (if (-> v1-9 next) + (set! (-> v1-9 next prev) v1-9) + ) + ) + (if (or (not a1-7) (= a1-7 (-> a0-8 0))) + (set! (-> a0-8 0) v1-9) + ) + ) + ) + (+! s3-0 1) + ) + ) + ) + (hover-nav-bsp-node-method-10 (-> gp-0 root) 0) + (set! *hover-bsp* gp-0) + gp-0 + ) + ) + ) + ) + +;; definition for function hover-nav-network-build-bsp +;; INFO: Used lq/sq +(defun hover-nav-network-build-bsp ((arg0 (array hover-nav-bsp-point))) + (let ((gp-0 (new 'global 'hover-nav-bsp))) + (let ((s4-0 (-> arg0 length)) + (s3-0 0) + ) + (set! (-> gp-0 root) (new 'global 'hover-nav-bsp-node)) + (dotimes (s2-0 s4-0) + (let ((v1-3 (new 'global 'hover-nav-bsp-point))) + (set! (-> v1-3 index) (-> (the-as (pointer int32) (-> arg0 s2-0)) 12)) + (vector-copy! (-> v1-3 pos) (the-as vector (&+ (-> arg0 s2-0) 32))) + (let ((a1-8 (-> gp-0 root point-list)) + (a0-11 (&-> gp-0 root point-list)) + ) + (when (zero? v1-3) + (break!) + 0 + ) + (when (or (= v1-3 a1-8) (= v1-3 a0-11)) + (break!) + 0 + ) + (when (not (or (not a1-8) (!= (-> a1-8 prev) v1-3))) + (break!) + 0 + ) + (when a1-8 + (set! (-> v1-3 next) a1-8) + (set! (-> v1-3 prev) (-> a1-8 prev)) + (if (-> v1-3 prev) + (set! (-> v1-3 prev next) v1-3) + ) + (if (-> v1-3 next) + (set! (-> v1-3 next prev) v1-3) + ) + ) + (if (or (not a1-8) (= a1-8 (-> a0-11 0))) + (set! (-> a0-11 0) v1-3) + ) + ) + ) + (+! s3-0 1) + ) + ) + (hover-nav-bsp-node-method-10 (-> gp-0 root) 0) + (set! *hover-bsp* gp-0) + gp-0 + ) + ) + +;; definition for function hover-nav-bsp-output +;; WARN: Return type mismatch object vs none. +(defun hover-nav-bsp-output ((arg0 hover-nav-bsp)) + (format #t "(") + (hover-nav-bsp-node-method-9 (-> arg0 root)) + (format #t ")~%") + (none) + ) + + + + diff --git a/test/decompiler/reference/jak3/levels/common/race/pilot-recorder_REF.gc b/test/decompiler/reference/jak3/levels/common/race/pilot-recorder_REF.gc new file mode 100644 index 0000000000..5fe63d927f --- /dev/null +++ b/test/decompiler/reference/jak3/levels/common/race/pilot-recorder_REF.gc @@ -0,0 +1,744 @@ +;;-*-Lisp-*- +(in-package goal) + +;; this file is debug only +(declare-file (debug)) + +;; definition of type pilrec-sample +(deftype pilrec-sample (structure) + ((sample-time time-frame) + (pos vector :inline) + (quat quaternion :inline) + (stick-x float) + (stick-y float) + (throttle float) + (flags pilrec-sample-flag) + ) + ) + +;; definition for method 3 of type pilrec-sample +(defmethod inspect ((this pilrec-sample)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'pilrec-sample) + (format #t "~1Tsample-time: ~D~%" (-> this sample-time)) + (format #t "~1Tpos: ~`vector`P~%" (-> this pos)) + (format #t "~1Tquat: #~%" (-> this quat)) + (format #t "~1Tstick-x: ~f~%" (-> this stick-x)) + (format #t "~1Tstick-y: ~f~%" (-> this stick-y)) + (format #t "~1Tthrottle: ~f~%" (-> this throttle)) + (format #t "~1Tflags: ~D~%" (-> this flags)) + (label cfg-4) + this + ) + +;; definition of type pilot-recorder-samples +(deftype pilot-recorder-samples (basic) + ((samples (inline-array pilrec-sample)) + ) + ) + +;; definition for method 3 of type pilot-recorder-samples +(defmethod inspect ((this pilot-recorder-samples)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tsamples: #x~X~%" (-> this samples)) + (label cfg-4) + this + ) + +;; failed to figure out what this is: +(when (or (not *pilot-recorder-samples*) (zero? *pilot-recorder-samples*)) + (let ((gp-0 (new 'debug 'pilot-recorder-samples))) + (set! *pilot-recorder-samples* gp-0) + (set! (-> gp-0 samples) (the-as (inline-array pilrec-sample) (malloc 'debug #xe1000))) + ) + ) + +;; definition of type pilot-recorder +(deftype pilot-recorder (process) + ((info race-info) + (mesh race-mesh) + (select-race uint64) + (path-num int32) + (sample-count int32) + (samples (inline-array pilrec-sample)) + (state-time time-frame) + (start-time time-frame) + (start-record-plane plane :inline) + (start-record-center vector :inline) + (finish-record-plane plane :inline) + (finish-record-center vector :inline) + (prev-pos vector :inline) + ) + (:state-methods + die-fast + idle + active + recording + fail-full + finished + save + fail-save + ) + (:methods + (pilot-recorder-method-22 (_type_) symbol) + (passed-starting-line? (_type_ vector vector) symbol) + (recording-finished? (_type_ vector vector) symbol) + (draw-starting-line (_type_ vector vector) none) + (draw-recorded-path (_type_) none) + (pilot-recorder-method-27 (_type_) none) + (record-input-sample! (_type_ pilrec-sample) pilrec-sample-flag) + (lerp-samples! (_type_ pilrec-sample pilrec-sample pilrec-sample float time-frame) none) + (save-to-db! (_type_) symbol) + ) + ) + +;; definition for method 3 of type pilot-recorder +(defmethod inspect ((this pilot-recorder)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (let ((t9-0 (method-of-type process inspect))) + (t9-0 this) + ) + (format #t "~2Tinfo: ~A~%" (-> this info)) + (format #t "~2Tmesh: ~A~%" (-> this mesh)) + (format #t "~2Tselect-race: ~D~%" (-> this select-race)) + (format #t "~2Tpath-num: ~D~%" (-> this path-num)) + (format #t "~2Tsample-count: ~D~%" (-> this sample-count)) + (format #t "~2Tsamples: #x~X~%" (-> this samples)) + (format #t "~2Tstate-time: ~D~%" (-> this state-time)) + (format #t "~2Tstart-time: ~D~%" (-> this start-time)) + (format #t "~2Tstart-record-plane: #~%" (-> this start-record-plane)) + (format #t "~2Tstart-record-center: #~%" (-> this start-record-center)) + (format #t "~2Tfinish-record-plane: #~%" (-> this finish-record-plane)) + (format #t "~2Tfinish-record-center: #~%" (-> this finish-record-center)) + (format #t "~2Tprev-pos: #~%" (-> this prev-pos)) + (label cfg-4) + this + ) + +;; definition for function delete-race-path +;; WARN: Return type mismatch int vs object. +(defun delete-race-path ((arg0 int) (arg1 int)) + (let ((s5-0 (-> *race-info-array* arg0 path-group-name))) + (format #t "Attempting to delete path ~s.[~d]~%" s5-0 arg1) + (let ((s4-0 (clear *temp-string*))) + (format s4-0 "delete from race_path where race='~s' and path=~d~%" s5-0 arg1) + (let ((a2-2 (sql-query s4-0))) + (cond + ((= (-> a2-2 content-type) 'modify) + (format #t "Success!~%") + ) + (else + (format 0 "ERROR: sql: modify error ~A~%" a2-2) + (return (the-as object #f)) + ) + ) + ) + ) + ) + 0 + ) + +;; definition for symbol *pilot-recorder*, type (pointer pilot-recorder) +(define *pilot-recorder* (the-as (pointer pilot-recorder) #f)) + +;; definition for method 28 of type pilot-recorder +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs pilrec-sample-flag. +(defmethod record-input-sample! ((this pilot-recorder) (arg0 pilrec-sample)) + (let ((v1-0 *target*)) + (the-as + pilrec-sample-flag + (when v1-0 + (let ((v1-1 (-> v1-0 pilot))) + (the-as + pilrec-sample-flag + (when (nonzero? v1-1) + (let ((v1-3 (handle->process (-> v1-1 vehicle)))) + (the-as + pilrec-sample-flag + (when v1-3 + (set-time! (-> arg0 sample-time)) + (let ((v1-5 (-> (the-as vehicle v1-3) rbody))) + (vector-copy! (-> arg0 pos) (-> v1-5 position)) + (quaternion-copy! (-> arg0 quat) (the-as quaternion (-> v1-5 rot))) + ) + (set! (-> arg0 stick-x) (analog-input (the-as int (-> *cpad-list* cpads 0 leftx)) 128.0 48.0 110.0 -1.0)) + (set! (-> arg0 stick-y) (analog-input (the-as int (-> *cpad-list* cpads 0 lefty)) 128.0 48.0 110.0 -1.0)) + (set! (-> arg0 throttle) (fmin 1.0 (* 0.023529412 (the float (-> *cpad-list* cpads 0 abutton 6))))) + (let ((flag (pilrec-sample-flag))) + (if (>= (fmin 1.0 (* 0.023529412 (the float (-> *cpad-list* cpads 0 abutton 7)))) 0.5) + (set! flag (the-as pilrec-sample-flag (logior (the-as int flag) (pilrec-sample-flag square)))) + ) + (if (cpad-hold? 0 l1) + (set! flag (the-as pilrec-sample-flag (logior (the-as int flag) (pilrec-sample-flag l1)))) + ) + (if (>= (fmin 1.0 (* 0.023529412 (the float (-> *cpad-list* cpads 0 abutton 6)))) 0.5) + (set! flag (the-as pilrec-sample-flag (logior (the-as int flag) (pilrec-sample-flag x)))) + ) + (set! (-> arg0 flags) (the-as pilrec-sample-flag flag)) + flag + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + +;; definition for method 29 of type pilot-recorder +;; WARN: Return type mismatch pilrec-sample-flag vs none. +(defmethod lerp-samples! ((this pilot-recorder) + (arg0 pilrec-sample) + (arg1 pilrec-sample) + (arg2 pilrec-sample) + (arg3 float) + (arg4 time-frame) + ) + (set! (-> arg0 sample-time) arg4) + (vector-lerp! (-> arg0 pos) (-> arg1 pos) (-> arg2 pos) arg3) + (quaternion-slerp! (-> arg0 quat) (-> arg1 quat) (-> arg2 quat) arg3) + (set! (-> arg0 stick-x) (lerp (-> arg1 stick-x) (-> arg2 stick-x) arg3)) + (set! (-> arg0 stick-y) (lerp (-> arg1 stick-y) (-> arg2 stick-y) arg3)) + (set! (-> arg0 throttle) (lerp (-> arg1 throttle) (-> arg2 throttle) arg3)) + (if (>= arg3 0.5) + (set! (-> arg0 flags) (-> arg2 flags)) + (set! (-> arg0 flags) (-> arg1 flags)) + ) + (none) + ) + +;; definition for method 23 of type pilot-recorder +(defmethod passed-starting-line? ((this pilot-recorder) (arg0 vector) (arg1 vector)) + (when (and (< (vector4-dot arg0 (the-as vector (-> this start-record-plane))) 0.0) + (>= (vector4-dot arg1 (the-as vector (-> this start-record-plane))) 0.0) + ) + (let ((s4-0 (new 'stack-no-clear 'vector))) + (vector-! s4-0 arg1 arg0) + (let ((f0-4 (intersect-ray-plane arg0 s4-0 (-> this start-record-center) (-> this start-record-plane))) + (a0-5 (new 'stack-no-clear 'vector)) + ) + (vector+float*! a0-5 arg0 s4-0 f0-4) + (let ((f0-5 184320.0)) + (if (>= (* f0-5 f0-5) (vector-vector-xz-distance-squared a0-5 (-> this start-record-center))) + #t + ) + ) + ) + ) + ) + ) + +;; definition for method 24 of type pilot-recorder +(defmethod recording-finished? ((this pilot-recorder) (arg0 vector) (arg1 vector)) + (when (and (< (vector4-dot arg0 (the-as vector (-> this finish-record-plane))) 0.0) + (>= (vector4-dot arg1 (the-as vector (-> this finish-record-plane))) 0.0) + ) + (let ((s4-0 (new 'stack-no-clear 'vector))) + (vector-! s4-0 arg1 arg0) + (let ((f0-4 (intersect-ray-plane arg0 s4-0 (-> this finish-record-center) (-> this finish-record-plane))) + (a0-5 (new 'stack-no-clear 'vector)) + ) + (vector+float*! a0-5 arg0 s4-0 f0-4) + (let ((f0-5 184320.0)) + (if (>= (* f0-5 f0-5) (vector-vector-xz-distance-squared a0-5 (-> this finish-record-center))) + #t + ) + ) + ) + ) + ) + ) + +;; definition for method 25 of type pilot-recorder +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs none. +(defmethod draw-starting-line ((this pilot-recorder) (arg0 vector) (arg1 vector)) + (let ((gp-0 (new 'stack-no-clear 'inline-array 'vector 2))) + (vector-copy! (-> gp-0 0) arg0) + (vector-float*! (-> gp-0 0) (-> gp-0 0) 184320.0) + (vector-copy! (-> gp-0 1) (-> gp-0 0)) + (vector-rotate-around-y! (-> gp-0 0) (-> gp-0 0) 16384.0) + (vector-rotate-around-y! (-> gp-0 1) (-> gp-0 1) -16384.0) + (vector+! (-> gp-0 0) (-> gp-0 0) arg1) + (vector+! (-> gp-0 1) (-> gp-0 1) arg1) + (+! (-> gp-0 0 y) 1638.4) + (+! (-> gp-0 1 y) 1638.4) + (countdown (s5-1 10) + (add-debug-line + #t + (bucket-id debug-no-zbuf1) + (-> gp-0 0) + (-> gp-0 1) + (new 'static 'rgba :g #x80 :a #x80) + #f + (the-as rgba -1) + ) + (+! (-> gp-0 0 y) 1638.4) + (+! (-> gp-0 1 y) 1638.4) + ) + ) + 0 + (none) + ) + +;; definition for method 26 of type pilot-recorder +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs none. +(defmethod draw-recorded-path ((this pilot-recorder)) + (let ((s2-0 0) + (s5-0 1) + (s4-0 (+ (-> this sample-count) -1)) + (s3-0 (new 'stack-no-clear 'vector)) + ) + (vector-copy! s3-0 (math-camera-pos)) + (while (< s2-0 s4-0) + (let* ((s2-1 (-> this samples s2-0)) + (s1-1 (-> this samples s5-0)) + (f0-0 (vector-vector-distance-squared (-> s2-1 pos) s3-0)) + (f1-0 819200.0) + ) + (if (< f0-0 (* f1-0 f1-0)) + (add-debug-line + #t + (bucket-id debug) + (-> s2-1 pos) + (-> s1-1 pos) + (new 'static 'rgba :r #xff :a #x80) + #f + (new 'static 'rgba :r #xff :g #xff :b #xff :a #x80) + ) + ) + ) + (set! s2-0 s5-0) + (set! s5-0 (min (+ s5-0 1) s4-0)) + ) + ) + (format + *stdcon* + "recorded path ~d time ~5,,3f~%" + (-> this path-num) + (* 0.016666668 (the float (-> this sample-count))) + ) + 0 + (none) + ) + +;; definition for method 27 of type pilot-recorder +;; INFO: Used lq/sq +;; WARN: Return type mismatch symbol vs none. +(defmethod pilot-recorder-method-27 ((this pilot-recorder)) + (let ((gp-0 (new 'stack-no-clear 'matrix)) + (s5-0 (new 'static 'boxed-array :type vector + (new 'static 'vector :y 4096.0 :w 1.0) + (new 'static 'vector :x 4096.0 :w 1.0) + (new 'static 'vector :x 4096.0 :w 1.0) + (new 'static 'vector :y -4096.0 :w 1.0) + (new 'static 'vector :y -4096.0 :w 1.0) + (new 'static 'vector :x -4096.0 :w 1.0) + (new 'static 'vector :x -4096.0 :w 1.0) + (new 'static 'vector :y 4096.0 :w 1.0) + (new 'static 'vector :y 4096.0 :w 1.0) + (new 'static 'vector :z 40960.0 :w 1.0) + (new 'static 'vector :x 4096.0 :w 1.0) + (new 'static 'vector :z 40960.0 :w 1.0) + (new 'static 'vector :y -4096.0 :w 1.0) + (new 'static 'vector :z 40960.0 :w 1.0) + (new 'static 'vector :x -4096.0 :w 1.0) + (new 'static 'vector :z 40960.0 :w 1.0) + ) + ) + ) + (vector-! (-> gp-0 fvec) (-> this samples 1 pos) (-> this samples 0 pos)) + (vector-normalize! (-> gp-0 fvec) 1.0) + (vector-cross! (-> gp-0 rvec) *up-vector* (-> gp-0 fvec)) + (vector-normalize! (-> gp-0 rvec) 1.0) + (vector-cross! (-> gp-0 uvec) (-> gp-0 fvec) (-> gp-0 rvec)) + (vector-normalize! (-> gp-0 uvec) 1.0) + (vector-copy! (-> gp-0 trans) (-> this samples 0 pos)) + (let ((s4-1 0)) + (while (< s4-1 (-> s5-0 length)) + (let ((a1-9 (-> s5-0 s4-1)) + (s3-0 (-> s5-0 (+ s4-1 1))) + (s2-0 (new 'stack-no-clear 'vector)) + (s1-0 (new 'stack-no-clear 'vector)) + ) + (+! s4-1 2) + (vector-matrix*! s2-0 a1-9 gp-0) + (vector-matrix*! s1-0 s3-0 gp-0) + (add-debug-line + #t + (bucket-id debug) + s2-0 + s1-0 + (new 'static 'rgba :r #xff :g #xff :b #xff :a #x80) + #f + (the-as rgba -1) + ) + ) + ) + ) + ) + (none) + ) + +;; definition for method 22 of type pilot-recorder +;; INFO: Used lq/sq +(defmethod pilot-recorder-method-22 ((this pilot-recorder)) + (let* ((s5-0 (-> this samples 0)) + (s4-0 (+ (-> this sample-count) -45)) + (s3-0 (-> this samples s4-0)) + (s2-0 (new 'stack-no-clear 'inline-array 'vector 4)) + ) + (vector-! (-> s2-0 0) (-> s3-0 pos) (-> this samples (+ s4-0 -1) pos)) + (vector-float*! (-> s2-0 0) (-> s2-0 0) 60.0) + (vector-! (-> s2-0 1) (-> this samples 1 pos) (-> s5-0 pos)) + (vector-float*! (-> s2-0 1) (-> s2-0 1) 60.0) + (vector-float*! (-> s2-0 2) (-> s3-0 pos) -3.0) + (vector+float*! (-> s2-0 2) (-> s2-0 2) (-> s5-0 pos) 3.0) + (vector+float*! (-> s2-0 2) (-> s2-0 2) (-> s2-0 0) -2.0) + (vector-! (-> s2-0 2) (-> s2-0 2) (-> s2-0 1)) + (vector+! (-> s2-0 3) (-> s2-0 1) (-> s2-0 0)) + (vector+float*! (-> s2-0 3) (-> s2-0 3) (-> s5-0 pos) -2.0) + (vector+float*! (-> s2-0 3) (-> s2-0 3) (-> s3-0 pos) 2.0) + (let ((s1-0 1) + (s0-0 (new 'stack-no-clear 'inline-array 'vector 4)) + ) + (while (< s1-0 45) + (let ((f0-8 (* 0.022222223 (the float s1-0))) + (v1-24 (-> this samples (+ s4-0 s1-0))) + ) + (vector+float*! (-> s0-0 1) (-> s3-0 pos) (-> s2-0 0) f0-8) + (vector+float*! (-> s0-0 1) (-> s0-0 1) (-> s2-0 2) (* f0-8 f0-8)) + (vector+float*! (-> s0-0 1) (-> s0-0 1) (-> s2-0 3) (* f0-8 f0-8 f0-8)) + (vector-copy! (-> v1-24 pos) (-> s0-0 1)) + (quaternion-slerp! (-> v1-24 quat) (-> s3-0 quat) (-> s5-0 quat) f0-8) + ) + (+! s1-0 1) + ) + ) + ) + #f + ) + +;; definition for method 30 of type pilot-recorder +;; INFO: Used lq/sq +(defmethod save-to-db! ((this pilot-recorder)) + (local-vars (sv-16 pilrec-sample-flag)) + (let ((gp-0 (clear *temp-string*)) + (s4-0 (-> *race-info-array* *select-race* path-group-name)) + (s3-0 *select-race-path*) + ) + (format gp-0 "delete from race_path where race='~s' and path=~d~%" s4-0 s3-0) + (let ((a2-1 (sql-query gp-0))) + (when (!= (-> a2-1 content-type) 'modify) + (format 0 "ERROR: sql: modify error ~A for ~A~%" a2-1 this) + (return #f) + ) + ) + (dotimes (s2-0 (-> this sample-count)) + (let ((s1-0 (-> this samples s2-0))) + (clear gp-0) + (format gp-0 "insert into race_path set ") + (format gp-0 "race='~s'," s4-0) + (format gp-0 "path=~d," s3-0) + (format gp-0 "pos_x=~f," (/ (-> s1-0 pos x) METER_LENGTH)) + (format gp-0 "pos_y=~f," (/ (-> s1-0 pos y) METER_LENGTH)) + (format gp-0 "pos_z=~f," (/ (-> s1-0 pos z) METER_LENGTH)) + (format gp-0 "quat_x=~f," (-> s1-0 quat x)) + (format gp-0 "quat_y=~f," (-> s1-0 quat y)) + (format gp-0 "quat_z=~f," (-> s1-0 quat z)) + (format gp-0 "quat_w=~f," (-> s1-0 quat w)) + (set! sv-16 (-> s1-0 flags)) + (let ((s0-0 #f)) + (format gp-0 "flags='") + (when (logtest? sv-16 (pilrec-sample-flag square)) + (set! s0-0 (cond + (s0-0 + (format gp-0 ",") + s0-0 + ) + (else + #t + ) + ) + ) + (format gp-0 "break") + ) + (when (logtest? sv-16 (pilrec-sample-flag l1)) + (set! s0-0 (cond + (s0-0 + (format gp-0 ",") + s0-0 + ) + (else + #t + ) + ) + ) + (format gp-0 "jump") + ) + (when (logtest? sv-16 (pilrec-sample-flag x)) + (if s0-0 + (format gp-0 ",") + #t + ) + (format gp-0 "throttle") + ) + ) + (format gp-0 "',") + (format gp-0 "stick_x=~f," (-> s1-0 stick-x)) + (format gp-0 "stick_y=~f," (-> s1-0 stick-y)) + (format gp-0 "throttle=~f~%" (-> s1-0 throttle)) + ) + (let ((a2-14 (sql-query gp-0))) + (when (!= (-> a2-14 content-type) 'modify) + (format 0 "ERROR: sql: modify error ~A for ~A~%" a2-14 this) + (return #f) + ) + ) + ) + ) + #t + ) + +;; failed to figure out what this is: +(defstate idle (pilot-recorder) + :virtual #t + :trans (behavior () + (let ((a1-0 (new 'stack-no-clear 'pilrec-sample))) + (if (record-input-sample! self a1-0) + (go-virtual active) + ) + ) + ) + :code sleep-code + ) + +;; failed to figure out what this is: +(defstate active (pilot-recorder) + :virtual #t + :enter (behavior () + (let ((gp-0 (new 'stack-no-clear 'pilrec-sample))) + (if (not (record-input-sample! self gp-0)) + (go-virtual die-fast) + ) + (vector-copy! (-> self prev-pos) (-> gp-0 pos)) + ) + ) + :trans (behavior () + (let ((gp-0 (new 'stack-no-clear 'pilrec-sample))) + (if (not (record-input-sample! self gp-0)) + (go-virtual die-fast) + ) + (if (passed-starting-line? self (-> self prev-pos) (-> gp-0 pos)) + (go-virtual recording) + (vector-copy! (-> self prev-pos) (-> gp-0 pos)) + ) + ) + (if (>= (mod (current-time) 240) 120) + (format *stdcon* " Cross starting line to begin recording.~%") + ) + (draw-starting-line self (-> self start-record-plane) (-> self start-record-center)) + ) + :code sleep-code + ) + +;; failed to figure out what this is: +(defstate recording (pilot-recorder) + :virtual #t + :enter (behavior () + (set-time! (-> self start-time)) + (set! (-> self samples) (-> *pilot-recorder-samples* samples)) + (let ((gp-0 (-> self samples 0))) + (if (not (record-input-sample! self gp-0)) + (go-virtual die-fast) + ) + (set! (-> self sample-count) 1) + (vector-copy! (-> self prev-pos) (-> gp-0 pos)) + ) + ) + :trans (behavior () + (let ((gp-0 (new 'stack-no-clear 'pilrec-sample))) + (if (not (record-input-sample! self gp-0)) + (go-virtual die-fast) + ) + (if (recording-finished? self (-> self prev-pos) (-> gp-0 pos)) + (go-virtual finished) + (vector-copy! (-> self prev-pos) (-> gp-0 pos)) + ) + (let* ((s5-0 (-> self samples (+ (-> self sample-count) -1))) + (s4-0 (- (-> gp-0 sample-time) (-> s5-0 sample-time))) + (s3-0 0) + ) + (until #f + (+! s3-0 5) + (if (< s4-0 s3-0) + (goto cfg-12) + ) + (let ((s2-0 (-> self sample-count))) + (if (>= s2-0 #x3840) + (go-virtual fail-full) + ) + (lerp-samples! + self + (-> self samples s2-0) + s5-0 + gp-0 + (/ (the float s3-0) (the float s4-0)) + (+ (-> s5-0 sample-time) s3-0) + ) + (set! (-> self sample-count) (+ s2-0 1)) + ) + ) + ) + ) + #f + (label cfg-12) + (if (>= (mod (current-time) 240) 120) + (format *stdcon* " Recording~%") + ) + (draw-starting-line self (-> self finish-record-plane) (-> self finish-record-center)) + (if (time-elapsed? (-> self start-time) (seconds 4)) + (pilot-recorder-method-27 self) + ) + 0 + ) + :code sleep-code + ) + +;; failed to figure out what this is: +(defstate finished (pilot-recorder) + :virtual #t + :enter (behavior () + (set-time! (-> self state-time)) + (change-parent self *entity-pool*) + (if (logtest? (-> self mesh flags) (race-mesh-flag rmf0)) + (pilot-recorder-method-22 self) + ) + ) + :trans (behavior () + (when (time-elapsed? (-> self state-time) (seconds 0.5)) + (cond + ((cpad-pressed? 1 triangle) + (go-virtual die-fast) + ) + ((cpad-pressed? 1 x) + (go-virtual save) + ) + ) + ) + (if (>= (mod (current-time) 240) 120) + (format *stdcon* " Finished.~%") + (format *stdcon* "~%") + ) + (format *stdcon* " Press pad1 X to save, or triangle to discard.~%") + (draw-recorded-path self) + 0 + ) + :code sleep-code + ) + +;; failed to figure out what this is: +(defstate save (pilot-recorder) + :virtual #t + :enter (behavior () + (set-time! (-> self state-time)) + (if (not (save-to-db! self)) + (go-virtual fail-save) + ) + ) + :trans (behavior () + (if (time-elapsed? (-> self state-time) (seconds 4)) + (go-virtual die-fast) + ) + (if (>= (mod (current-time) 240) 120) + (format *stdcon* " Save complete!~%") + ) + ) + :code sleep-code + ) + +;; failed to figure out what this is: +(defstate fail-save (pilot-recorder) + :virtual #t + :enter (behavior () + (set-time! (-> self state-time)) + ) + :trans (behavior () + (if (time-elapsed? (-> self state-time) (seconds 15)) + (go-virtual die-fast) + ) + (if (>= (mod (current-time) 60) 30) + (format *stdcon* " SAVE FAILED!!!~%") + ) + ) + :code sleep-code + ) + +;; failed to figure out what this is: +(defstate fail-full (pilot-recorder) + :virtual #t + :enter (behavior () + (set-time! (-> self state-time)) + ) + :trans (behavior () + (if (time-elapsed? (-> self state-time) (seconds 15)) + (go-virtual die-fast) + ) + (if (>= (mod (current-time) 60) 30) + (format *stdcon* " FAILED!!! BUFFER FULL!!!~%") + ) + ) + :code sleep-code + ) + +;; failed to figure out what this is: +(defstate die-fast (pilot-recorder) + :virtual #t + :code nothing + ) + +;; definition for function pilot-recorder-init-by-other +;; INFO: Used lq/sq +(defbehavior pilot-recorder-init-by-other pilot-recorder ((arg0 uint) (arg1 int)) + (set! (-> self select-race) arg0) + (set! (-> self path-num) arg1) + (let ((v1-2 (-> *race-info-array* arg0))) + (set! (-> self info) v1-2) + (set! (-> self mesh) (-> v1-2 mesh)) + (vector-copy! (-> self start-record-center) (-> v1-2 start-sphere)) + (set! (-> self start-record-plane quad) (-> v1-2 start-dir quad)) + (set! (-> self start-record-plane w) + (- (vector-dot (the-as vector (-> self start-record-plane)) (-> self start-record-center))) + ) + (vector-copy! (-> self finish-record-center) (-> v1-2 finish-sphere)) + (set! (-> self finish-record-plane quad) (-> v1-2 finish-dir quad)) + ) + (set! (-> self finish-record-plane w) + (- (vector-dot (the-as vector (-> self finish-record-plane)) (-> self finish-record-center))) + ) + (set! *pilot-recorder* (the-as (pointer pilot-recorder) self)) + (go-virtual idle) + ) + +;; definition for function start-pilot-recorder +;; WARN: Return type mismatch int vs none. +(defun start-pilot-recorder () + (process-spawn pilot-recorder *select-race* *select-race-path* :name "pilot-recorder" :to *target*) + 0 + (none) + ) diff --git a/test/offline/config/jak3/config.jsonc b/test/offline/config/jak3/config.jsonc index 1316a8e682..cd6eb22215 100644 --- a/test/offline/config/jak3/config.jsonc +++ b/test/offline/config/jak3/config.jsonc @@ -391,7 +391,8 @@ "(method 19 rope-prim-system)", // funny casts with matrix. "sprite-add-matrix-data", - "(method 17 nav-mesh-editable)" // weird delay branch that tries to set a variable that doesn't exist + "(method 17 nav-mesh-editable)", // weird delay branch that tries to set a variable that doesn't exist + "camera-fov-frame" ], "skip_compile_states": {