diff --git a/decompiler/config/jak2/all-types.gc b/decompiler/config/jak2/all-types.gc index c95531cc5e..e78d797980 100644 --- a/decompiler/config/jak2/all-types.gc +++ b/decompiler/config/jak2/all-types.gc @@ -7943,11 +7943,17 @@ (instance-tie-colors3 22) (inst-tie-colors* 23) + ;; 25-33 is shrub stuff + + ;; + (entity 43) (camera 44) (res 48) + ;; 50-57 is collision + (bsp-main 58) (bsp-misc 59) (bsp-node 60) @@ -7977,6 +7983,29 @@ (array 84) + (unsorted-proc 90) + (8k-dead-pool 91) + (16k-dead-pool 92) + (nk-dead-pool 93) + (target-dead-pool 94) + (camera-dead-pool 95) + (debug-dead-pool 96) + (process-active 97) + (heap-total 98) + (heap-process 99) + (heap-header 100) + (heap-thread 101) + (heap-root 102) + + (heap-draw-control 103) + (heap-joint-control 104) + (heap-cspace 105) + (heap-bone 106) + (heap-part 107) + (heap-collide-prim 108) + (heap-misc 109) + + (eye-anim 111) ) @@ -12382,7 +12411,7 @@ ((first uint32 :offset-assert 0) (next uint32 :offset-assert 4) (bucket-id int32 :offset-assert 8) - (shadow-color uint32 :offset-assert 12) + (shadow-color rgba :offset-assert 12) (constants basic :offset-assert 16) ) :allow-misaligned @@ -12606,7 +12635,7 @@ (declare-type mc-slot-info structure) (define-extern mc-sync (function int)) (define-extern mc-get-slot-info (function int mc-slot-info none)) - +(define-extern show-mc-info (function dma-buffer none)) (define-extern mc-check-result (function mc-status-code)) ;; mc-makefile @@ -13294,9 +13323,10 @@ (defenum prototype-flags :bitfield #t :type uint16 - (disable 0) + (disable 0) ;; set from debug menu, for debugging (tpage-alpha 2) (vanish 3) + (visible 5) ;; set by prototypes-game-visible-set! to hide things on purpose (no-collide 6) (tpage-water 7) ) @@ -24035,7 +24065,7 @@ (define-extern foreground-check-longest-edge-asm (function draw-control float symbol)) (define-extern foreground-ripple (function draw-control merc-ctrl pointer int pointer)) (define-extern foreground-draw (function draw-control dma-buffer float none)) -;; (define-extern foreground-draw-hud function) +(define-extern foreground-draw-hud (function draw-control dma-buffer float none)) (define-extern *foreground-draw-engine* engine) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -29512,17 +29542,17 @@ (define-extern find-instance-by-name-level (function string level prototype-bucket)) (define-extern find-instance-by-name (function string prototype-bucket)) (define-extern prototypes-game-visible-set! (function pair symbol int)) -;; (define-extern find-instance-by-index function) ;; (function type int bsp-header prototype-bucket) +(define-extern find-instance-by-index (function type int bsp-header prototype-bucket)) (define-extern prototype-bucket-type (function prototype-bucket type)) (define-extern prototype-bucket-recalc-fields (function prototype-bucket prototype-bucket)) (define-extern print-prototype-list (function none)) (define-extern draw-instance-info (function string none)) -;; (define-extern set-shadow-by-name function) -;; (define-extern get-shadow-by-name function) -;; (define-extern teleport-camera-by-name function) +(define-extern set-shadow-by-name (function string int int none)) +(define-extern get-shadow-by-name (function string none)) +(define-extern teleport-camera-by-name (function string none)) (define-extern dma-add-process-drawable (function process-drawable draw-control symbol dma-buffer none)) (define-extern *hud-lights* vu-lights) -;; (define-extern dma-add-process-drawable-hud function) ;; (function process-drawable draw-control symbol dma-buffer none) +(define-extern dma-add-process-drawable-hud (function process-drawable draw-control float dma-buffer none)) (define-extern add-process-drawable (function process-drawable draw-control symbol dma-buffer none)) (define-extern foreground-engine-execute (function engine display-frame none)) (define-extern main-debug-hook (function none)) @@ -29536,8 +29566,8 @@ (define-extern *draw-hook* (function none)) (define-extern default-init-buffer (function bucket-id gs-zbuf gs-test none)) (define-extern default-end-buffer (function bucket-id gs-zbuf gs-test none)) -;; (define-extern screen-shot-scale function) -;; (define-extern screen-shot function) +(define-extern screen-shot-scale (function int string none)) +(define-extern screen-shot (function none)) (define-extern display-frame-start (function display int float none)) (define-extern display-frame-finish (function display display)) (define-extern determine-pause-mode (function int)) diff --git a/decompiler/config/jak2/anonymous_function_types.jsonc b/decompiler/config/jak2/anonymous_function_types.jsonc index adb07fd34e..51f2bedbea 100644 --- a/decompiler/config/jak2/anonymous_function_types.jsonc +++ b/decompiler/config/jak2/anonymous_function_types.jsonc @@ -373,7 +373,7 @@ [56, "(function process-drawable none)"] ], "memory-usage": [ - // [2, "(function process symbol)"], // TODO - crash / assertion hit + [2, "(function process-drawable symbol)"], [3, "(function basic symbol)"] ], "pov-camera": [ diff --git a/decompiler/config/jak2/hacks.jsonc b/decompiler/config/jak2/hacks.jsonc index 2018362070..586438a74c 100644 --- a/decompiler/config/jak2/hacks.jsonc +++ b/decompiler/config/jak2/hacks.jsonc @@ -220,7 +220,8 @@ "cspace-inspect-tree", "(method 11 mtn-step-plat-rocks-a)", "(method 11 mtn-step-plat-rocks-b)", - "(method 11 mtn-step-plat-rocks-c)" + "(method 11 mtn-step-plat-rocks-c)", + "prototypes-game-visible-set!" ], // If format is used with the wrong number of arguments, diff --git a/decompiler/config/jak2/type_casts.jsonc b/decompiler/config/jak2/type_casts.jsonc index eee132bd6b..bafc6fb6fd 100644 --- a/decompiler/config/jak2/type_casts.jsonc +++ b/decompiler/config/jak2/type_casts.jsonc @@ -5373,5 +5373,43 @@ [248, "v1", "art-joint-anim"], [345, "v1", "art-joint-anim"], [442, "v1", "art-joint-anim"] + ], + "find-instance-by-name-level": [ + [11, "v1", "drawable-tree-instance-shrub"], + [38, "v1", "drawable-tree-instance-tie"] + ], + "dma-add-process-drawable-hud": [ + [11, "a0", "foreground-work"] + ], + "find-instance-by-index": [ + [26, "t1", "drawable-tree-instance-shrub"], + [40, "t1", "drawable-tree-instance-tie"] + ], + "print-prototype-list": [ + [25, "v1", "drawable-tree-instance-shrub"], + [104, "v1", "drawable-tree-instance-tie"] + ], + "draw-instance-info": [ + [[188, 203], "s5", "prototype-bucket-shrub"], + [[192, 303], "s1", "prototype-shrubbery"], + [[359, 400], "v1", "prototype-tie"], + [[44, 64], "s1", "drawable-inline-array-instance-tie"], + [[331, 450], "s5", "prototype-bucket-tie"] + ], + "set-shadow-by-name": [ + [7, "v1", "process-drawable"] + ], + "get-shadow-by-name": [ + [7, "v1", "process-drawable"] + ], + "(anon-function 2 memory-usage)": [ + [211, "v1", "collide-shape-moving"] + ], + "(method 9 screen-filter)": [ + [[25, 31], "a0", "dma-packet"], + [[34, 40], "a0", "gs-gif-tag"], + [45, "a0", "(pointer gs-test)"], + [47, "a0", "(pointer gs-reg64)"], + [[72, 102], "t1", "rgba"] ] } diff --git a/decompiler/types2/ForwardProp.cpp b/decompiler/types2/ForwardProp.cpp index 904bf7089c..092e5a9c83 100644 --- a/decompiler/types2/ForwardProp.cpp +++ b/decompiler/types2/ForwardProp.cpp @@ -1099,8 +1099,9 @@ void types2_for_add(types2::Type& type_out, // honestly not sure why I have this one... let's have it abort for now. if (arg0_type.kind == TP_Type::Kind::OBJECT_PLUS_PRODUCT_WITH_CONSTANT && arg1_type.typespec().base_type() == "pointer") { - ASSERT(false); - // return TP_Type::make_from_ts(TypeSpec("int")); + // ASSERT(false); + type_out.type = TP_Type::make_from_ts(TypeSpec("int")); + return; } // special case: dynamic access to the method table, to look up a method by ID. diff --git a/goal_src/jak2/engine/debug/memory-usage-h.gc b/goal_src/jak2/engine/debug/memory-usage-h.gc index d3414d70da..9a2539b1e0 100644 --- a/goal_src/jak2/engine/debug/memory-usage-h.gc +++ b/goal_src/jak2/engine/debug/memory-usage-h.gc @@ -31,11 +31,17 @@ (instance-tie-colors3 22) (inst-tie-colors* 23) + ;; 25-33 is shrub stuff + + ;; + (entity 43) (camera 44) (res 48) + ;; 50-57 is collision + (bsp-main 58) (bsp-misc 59) (bsp-node 60) @@ -65,6 +71,29 @@ (array 84) + (unsorted-proc 90) + (8k-dead-pool 91) + (16k-dead-pool 92) + (nk-dead-pool 93) + (target-dead-pool 94) + (camera-dead-pool 95) + (debug-dead-pool 96) + (process-active 97) + (heap-total 98) + (heap-process 99) + (heap-header 100) + (heap-thread 101) + (heap-root 102) + + (heap-draw-control 103) + (heap-joint-control 104) + (heap-cspace 105) + (heap-bone 106) + (heap-part 107) + (heap-collide-prim 108) + (heap-misc 109) + + (eye-anim 111) ) diff --git a/goal_src/jak2/engine/debug/memory-usage.gc b/goal_src/jak2/engine/debug/memory-usage.gc index 053f3f26c8..de2c72cae1 100644 --- a/goal_src/jak2/engine/debug/memory-usage.gc +++ b/goal_src/jak2/engine/debug/memory-usage.gc @@ -7,3 +7,581 @@ ;; DECOMP BEGINS +;; this file is debug only +(declare-file (debug)) +(when *debug-segment* +;; definition for method 3 of type memory-usage-block +(defmethod inspect memory-usage-block ((obj 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 (-> obj length)) + (let ((v1-2 (-> obj 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 "-------------------------------------------------------------~%") + obj + ) + +;; definition for method 8 of type object +(defmethod mem-usage object ((obj object) (arg0 memory-usage-block) (arg1 int)) + obj + ) + +;; definition for method 10 of type memory-usage-block +(defmethod calculate-total memory-usage-block ((obj memory-usage-block)) + "@returns The total sum of all [[memory-usage-info]] `total`s" + (let ((sum 0)) + (dotimes (idx (-> obj length)) + (+! sum (-> obj data idx total)) + ) + sum + ) + ) + +;; definition for method 9 of type memory-usage-block +(defmethod reset! memory-usage-block ((obj memory-usage-block)) + "Sets `length` to 0 as well as resets all fields except `name` in the associated [[memory-usage-info]]" + (set! (-> obj length) 0) + (dotimes (idx 112) + (set! (-> obj data idx used) 0) + (set! (-> obj data idx total) 0) + (set! (-> obj data idx count) 0) + ) + obj + ) + +;; definition for function mem-size +(defun mem-size ((data basic) (inspect-usage? symbol) (arg2 int)) + "@param data The [[basic]] to call `mem-usage` on + @param inspect-usage? Set to [[#t]] if `inspect` should be called on the resulting [[memory-usage-block]] + @param arg2 TODO - unsure, some sort of bitfield + @returns The total memory footprint of the provided [[basic]]" + (let ((block (new 'stack 'memory-usage-block))) + (mem-usage data block arg2) + (if inspect-usage? + (inspect block) + ) + (calculate-total block) + ) + ) + +;; definition for method 14 of type level +(defmethod compute-memory-usage! level ((obj level) (force? symbol)) + "Calculates the memory usage of the level, returns and stores the [[memory-usage-block]] + in `mem-usage-block` as well as the total size in `mem-usage` + + @param force? - Will re-compute the usage if set to [[#t]], even if `mem-usage` has been set to a non-zero value + @returns The [[memory-usage-block]] representing the footprint of the level + @see [[memory-usage-block::10]]" + (if (zero? (-> obj mem-usage-block)) + (set! (-> obj mem-usage-block) (new 'debug 'memory-usage-block)) + ) + (set! force? (or (zero? (-> obj mem-usage-block length)) force?)) + (when force? + (mem-usage obj (reset! (-> obj mem-usage-block)) 0) + (set! (-> obj mem-usage) (calculate-total (-> obj mem-usage-block))) + 0 + ) + (-> obj mem-usage-block) + ) + +;; definition for method 8 of type process-tree +(defmethod mem-usage process-tree ((obj process-tree) (arg0 memory-usage-block) (arg1 int)) + (let ((v1-0 90)) + (let* ((a0-1 *dead-pool-list*) + (a3-0 (car a0-1)) + ) + (while (not (null? a0-1)) + (set! (-> arg0 data v1-0 name) (symbol->string (the-as symbol a3-0))) + (+! v1-0 1) + (set! a0-1 (cdr a0-1)) + (set! a3-0 (car a0-1)) + ) + ) + (set! (-> arg0 length) (max (-> arg0 length) v1-0)) + ) + (set! (-> arg0 data 96 name) "*debug-dead-pool*") + (set! *temp-mem-usage* arg0) + (when (logtest? arg1 32) + (let* ((s5-0 90) + (s4-0 *dead-pool-list*) + (v1-4 (car s4-0)) + ) + (while (not (null? s4-0)) + (let ((a0-5 (-> (the-as symbol v1-4) value))) + (set! *global-search-count* s5-0) + (iterate-process-tree + (the-as process-tree a0-5) + (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-0 1) + (set! s4-0 (cdr s4-0)) + (set! v1-4 (car s4-0)) + ) + ) + ) + (iterate-process-tree + obj + (lambda ((arg0 process-drawable)) + (let ((gp-0 *temp-mem-usage*)) + (let ((s4-0 (cond + ((= (-> arg0 pool) *8k-dead-pool*) + 91 + ) + ((= (-> arg0 pool) *16k-dead-pool*) + 92 + ) + ((= (-> arg0 pool) *nk-dead-pool*) + 93 + ) + ((= (-> arg0 pool) *target-dead-pool*) + 94 + ) + ((= (-> arg0 pool) *camera-dead-pool*) + 95 + ) + ((= (-> arg0 pool) *debug-dead-pool*) + 96 + ) + (else + 90 + ) + ) + ) + ) + (+! (-> gp-0 data s4-0 count) 1) + (+! (-> gp-0 data s4-0 total) (logand -16 (+ (asize-of arg0) 15))) + ) + (set! (-> gp-0 length) (max 98 (-> gp-0 length))) + (set! (-> gp-0 data 97 name) "process-active") + (+! (-> gp-0 data 97 count) 1) + (let ((v1-23 (asize-of arg0))) + (+! (-> gp-0 data 97 used) v1-23) + (+! (-> gp-0 data 97 total) (logand -16 (+ v1-23 15))) + ) + (set! (-> gp-0 length) (max 99 (-> gp-0 length))) + (set! (-> gp-0 data 98 name) "heap-total") + (+! (-> gp-0 data 98 count) 1) + (let ((v1-34 (+ (- -4 (the-as int arg0)) (the-as int (-> arg0 heap-cur))))) + (+! (-> gp-0 data 98 used) v1-34) + (+! (-> gp-0 data 98 total) (logand -16 (+ v1-34 15))) + ) + (set! (-> gp-0 length) (max 100 (-> gp-0 length))) + (set! (-> gp-0 data 99 name) "heap-process") + (+! (-> gp-0 data 99 count) 1) + (let ((v1-45 (- (-> arg0 type size) (-> arg0 type heap-base)))) + (+! (-> gp-0 data 99 used) v1-45) + (+! (-> gp-0 data 99 total) (logand -16 (+ v1-45 15))) + ) + (set! (-> gp-0 length) (max 101 (-> gp-0 length))) + (set! (-> gp-0 data 100 name) "heap-header") + (+! (-> gp-0 data 100 count) 1) + (let ((v1-55 (-> arg0 type heap-base))) + (+! (-> gp-0 data 100 used) v1-55) + (+! (-> gp-0 data 100 total) (logand -16 (+ v1-55 15))) + ) + (set! (-> gp-0 length) (max 102 (-> gp-0 length))) + (set! (-> gp-0 data 101 name) "heap-thread") + (+! (-> gp-0 data 101 count) 1) + (let ((v1-65 (asize-of (-> arg0 main-thread)))) + (+! (-> gp-0 data 101 used) v1-65) + (+! (-> gp-0 data 101 total) (logand -16 (+ v1-65 15))) + ) + (when (type? arg0 process-drawable) + (when (nonzero? (-> arg0 root)) + (set! (-> gp-0 length) (max 103 (-> gp-0 length))) + (set! (-> gp-0 data 102 name) "heap-root") + (+! (-> gp-0 data 102 count) 1) + (let ((v1-78 (asize-of (-> arg0 root)))) + (+! (-> gp-0 data 102 used) v1-78) + (+! (-> gp-0 data 102 total) (logand -16 (+ v1-78 15))) + ) + (when (type? (-> arg0 root) collide-shape) + (set! (-> gp-0 length) (max 109 (-> gp-0 length))) + (set! (-> gp-0 data 108 name) "heap-collide-prim") + (+! (-> gp-0 data 108 count) 1) + (let ((v1-90 (asize-of (-> (the-as collide-shape-moving (-> arg0 root)) root-prim)))) + (+! (-> gp-0 data 108 used) v1-90) + (+! (-> gp-0 data 108 total) (logand -16 (+ v1-90 15))) + ) + ) + ) + (when (nonzero? (-> arg0 node-list)) + (set! (-> gp-0 length) (max 106 (-> gp-0 length))) + (set! (-> gp-0 data 105 name) "heap-cspace") + (+! (-> gp-0 data 105 count) 1) + (let ((v1-102 (asize-of (-> arg0 node-list)))) + (+! (-> gp-0 data 105 used) v1-102) + (+! (-> gp-0 data 105 total) (logand -16 (+ v1-102 15))) + ) + ) + (when (nonzero? (-> arg0 draw)) + (set! (-> gp-0 length) (max 104 (-> gp-0 length))) + (set! (-> gp-0 data 103 name) "heap-draw-control") + (+! (-> gp-0 data 103 count) 1) + (let ((v1-114 (asize-of (-> arg0 draw)))) + (+! (-> gp-0 data 103 used) v1-114) + (+! (-> gp-0 data 103 total) (logand -16 (+ v1-114 15))) + ) + (when (nonzero? (-> arg0 draw skeleton)) + (set! (-> gp-0 length) (max 107 (-> gp-0 length))) + (set! (-> gp-0 data 106 name) "heap-bone") + (+! (-> gp-0 data 106 count) 1) + (let ((v1-128 (asize-of (-> arg0 draw skeleton)))) + (+! (-> gp-0 data 106 used) v1-128) + (+! (-> gp-0 data 106 total) (logand -16 (+ v1-128 15))) + ) + ) + ) + (when (nonzero? (-> arg0 skel)) + (set! (-> gp-0 length) (max 105 (-> gp-0 length))) + (set! (-> gp-0 data 104 name) "heap-joint-control") + (+! (-> gp-0 data 104 count) 1) + (let ((v1-140 (asize-of (-> arg0 skel)))) + (+! (-> gp-0 data 104 used) v1-140) + (+! (-> gp-0 data 104 total) (logand -16 (+ v1-140 15))) + ) + ) + (when (nonzero? (-> arg0 part)) + (set! (-> gp-0 length) (max 108 (-> gp-0 length))) + (set! (-> gp-0 data 107 name) "heap-part") + (+! (-> gp-0 data 107 count) 1) + (let ((v1-152 (asize-of (-> arg0 part)))) + (+! (-> gp-0 data 107 used) v1-152) + (+! (-> gp-0 data 107 total) (logand -16 (+ v1-152 15))) + ) + ) + (when (nonzero? (-> arg0 nav)) + (set! (-> gp-0 length) (max 110 (-> gp-0 length))) + (set! (-> gp-0 data 109 name) "heap-misc") + (+! (-> gp-0 data 109 count) 1) + (let ((v1-164 (asize-of (-> arg0 nav)))) + (+! (-> gp-0 data 109 used) v1-164) + (+! (-> gp-0 data 109 total) (logand -16 (+ v1-164 15))) + ) + ) + (when (nonzero? (-> arg0 path)) + (set! (-> gp-0 length) (max 110 (-> gp-0 length))) + (set! (-> gp-0 data 109 name) "heap-misc") + (+! (-> gp-0 data 109 count) 1) + (let ((v1-176 (asize-of (-> arg0 path)))) + (+! (-> gp-0 data 109 used) v1-176) + (+! (-> gp-0 data 109 total) (logand -16 (+ v1-176 15))) + ) + ) + (when (nonzero? (-> arg0 vol)) + (set! (-> gp-0 length) (max 110 (-> gp-0 length))) + (set! (-> gp-0 data 109 name) "heap-misc") + (+! (-> gp-0 data 109 count) 1) + (let ((v1-188 (asize-of (-> arg0 vol)))) + (+! (-> gp-0 data 109 used) v1-188) + (+! (-> gp-0 data 109 total) (logand -16 (+ v1-188 15))) + ) + ) + ) + ) + #t + ) + *null-kernel-context* + ) + obj + ) + +;; 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 memory-usage-block ((obj memory-usage-block) (level level) (fmt-dest object)) + (local-vars (sv-16 object) (sv-32 string) (sv-48 int)) + (let ((s3-0 (&- (-> level heap current) (the-as uint (-> level heap base))))) + (let ((v1-2 (+ (-> obj data 61 total) (-> obj data 62 total)))) + (< #x10000 v1-2) + ) + (let* ((v1-5 + (- (- -49152 (the-as int (shl (-> level info borrow-size 1) 10))) (shl (-> level info borrow-size 0) 10)) + ) + (a0-12 (-> level info memory-mode)) + (s2-0 + (+ v1-5 + (the-as int (cond + ((= a0-12 (load-buffer-mode large)) + #xbd0000 + ) + ((= a0-12 (load-buffer-mode medium)) + #x8fb800 + ) + ((= a0-12 (load-buffer-mode small-center)) + #x627000 + ) + ((= a0-12 (load-buffer-mode borrow)) + (+ (- #xc000 (the-as int (-> level heap base))) (the-as int (-> level heap top-base))) + ) + (else + #x5e8000 + ) + ) + ) + ) + ) + (s1-0 (* (dma-buffer-length (-> *display* frames (-> *display* last-screen) global-buf)) 16)) + ) + (set! *max-dma* (max s1-0 *max-dma*)) + (if (< (the-as int s2-0) s3-0) + (format fmt-dest "~3L") + ) + (let ((s0-0 format)) + (set! sv-16 fmt-dest) + (set! sv-32 "~0K~10,'-S--~5,'-DK-of-~5,'-DK--~5,'-DK-of-~5,'-DK--") + (let ((s4-1 (-> level name)) + (s3-1 (sar s3-0 10)) + (s2-1 (shr s2-0 10)) + ) + (set! sv-48 (sar (memory-used *nk-dead-pool*) 10)) + (let ((t2-0 (sar (memory-total *nk-dead-pool*) 10)) + (t9-4 s0-0) + (a0-22 sv-16) + (a1-8 sv-32) + (a2-1 s4-1) + (a3-0 s3-1) + (t0-0 s2-1) + (t1-0 sv-48) + ) + (t9-4 a0-22 a1-8 a2-1 a3-0 t0-0 t1-0 t2-0) + (format fmt-dest "~5,'-DK/~5,'-DK--~%" (shr s1-0 10) (sar *max-dma* 10)) + (when *stats-memory-short* + (let ((s3-2 (if (cpad-hold? 1 l3) + #t + fmt-dest + ) + ) + (s4-2 format) + (s2-2 "heap-~5,'-DK/~5,'-DK----~D---~D/~D~%") + (s1-1 (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-2 s1-1 s0-1 t0-0 (the-as uint t1-0) (the-as uint t2-0)) + ) + ) + (when (not *stats-memory-short*) + (set! (-> *dma-mem-usage* data 87 total) + (* (dma-buffer-length (-> *display* frames (-> *display* last-screen) debug-buf)) 16) + ) + (let ((t9-11 format) + (a0-31 fmt-dest) + (a1-11 " bsp ~192H~5DK ~280Hdebug~456H~5DK~%") + (a2-6 (sar (+ (-> obj data 58 total) (-> obj data 59 total) (-> obj data 60 total)) 10)) + (a3-3 (sar (-> *dma-mem-usage* data 87 total) 10)) + ) + (t9-11 a0-31 a1-11 a2-6 a3-3 (the-as none t0-0) (the-as none t1-0) (the-as none t2-0)) + (format + fmt-dest + " bsp-leaf-vis ~192H~5DK~%" + (sar (+ (-> obj data 61 total) (-> obj data 62 total)) 10) + (the-as none a3-3) + ) + (format fmt-dest " level-code ~192H~5DK~%" (sar (-> obj data 65 total) 10) (the-as none a3-3)) + ) + (format + fmt-dest + " tfrag ~192H~5DK ~280Htfragment~456H~5DK~%" + (sar + (+ (-> obj data 1 total) + (-> obj data 2 total) + (-> obj data 3 total) + (-> obj data 4 total) + (-> obj data 5 total) + (-> obj data 6 total) + (-> obj data 7 total) + (-> obj data 8 total) + ) + 10 + ) + (sar (-> *dma-mem-usage* data 1 total) 10) + ) + (format + fmt-dest + " tie-proto ~192H~5DK ~280Hsky~456H~5DK~%" + (sar + (+ (-> obj data 9 total) + (-> obj data 10 total) + (-> obj data 11 total) + (-> obj data 12 total) + (-> obj data 13 total) + (-> obj data 14 total) + (-> obj data 16 total) + (-> obj data 17 total) + ) + 10 + ) + (sar (-> *dma-mem-usage* data 88 total) 10) + ) + (format + fmt-dest + " tie-instance ~192H~5DK ~280Htie-fragment~456H~5DK~%" + (sar (+ (-> obj data 18 total) (-> obj data 20 total) (-> obj data 21 total) (-> obj data 22 total)) 10) + (sar (-> *dma-mem-usage* data 9 total) 10) + ) + (format + fmt-dest + " shrub-proto ~192H~5DK ~280Htie-scissor~456H~5DK~%" + (sar + (+ (-> obj data 25 total) + (-> obj data 26 total) + (-> obj data 27 total) + (-> obj data 28 total) + (-> obj data 29 total) + (-> obj data 30 total) + (-> obj data 31 total) + (-> obj data 32 total) + (-> obj data 33 total) + ) + 10 + ) + (sar (-> *dma-mem-usage* data 15 total) 10) + ) + (format + fmt-dest + " shrub-instance ~192H~5DK ~280Hshrubbery~456H~5DK~%" + (sar (-> obj data 34 total) 10) + (sar (-> *dma-mem-usage* data 27 total) 10) + ) + (format + fmt-dest + " collision ~192H~5DK ~280Htie-generic~456H~5DK~%" + (sar + (+ (-> obj data 50 total) + (-> obj data 51 total) + (-> obj data 52 total) + (-> obj data 53 total) + (-> obj data 54 total) + (-> obj data 55 total) + (-> obj data 56 total) + (-> obj data 57 total) + ) + 10 + ) + (sar (-> *dma-mem-usage* data 17 total) 10) + ) + (format + fmt-dest + " pris-geo ~192H~5DK ~280Hpris-fragment~456H~5DK~%" + (sar + (+ (-> obj data 35 total) + (-> obj data 36 total) + (-> obj data 37 total) + (-> obj data 38 total) + (-> obj data 39 total) + (-> obj data 40 total) + (-> obj data 41 total) + (-> obj data 42 total) + (-> obj data 73 total) + (-> obj data 74 total) + (-> obj data 75 total) + (-> obj data 76 total) + (-> obj data 78 total) + (-> obj data 81 total) + (-> obj data 80 total) + (-> obj data 111 total) + ) + 10 + ) + (sar (-> *dma-mem-usage* data 35 total) 10) + ) + (format + fmt-dest + " pris-anim ~192H~5DK ~280Hpris-generic~456H~5DK~%" + (sar + (+ (-> obj data 67 total) + (-> obj data 68 total) + (-> obj data 69 total) + (-> obj data 70 total) + (-> obj data 71 total) + (-> obj data 77 total) + (-> obj data 79 total) + (-> obj data 72 total) + ) + 10 + ) + (sar (-> *dma-mem-usage* data 89 total) 10) + ) + (format + fmt-dest + " textures ~192H~5DK ~280Htextures~456H~5DK~%" + (sar (-> obj data 82 total) 10) + (sar (-> *dma-mem-usage* data 82 total) 10) + ) + (format fmt-dest " entity ~192H~5DK~%" (sar + (+ (-> obj data 66 total) + (-> obj data 43 total) + (-> obj data 44 total) + (-> obj data 45 total) + (-> obj data 49 total) + (-> obj data 48 total) + (-> obj data 46 total) + (-> obj data 47 total) + ) + 10 + ) + ) + (format + fmt-dest + " misc ~192H~5DK ~280Hsprite~456H~5DK~%" + (sar + (+ (-> obj data 0 total) + (-> obj data 63 total) + (-> obj data 64 total) + (-> obj data 83 total) + (-> obj data 84 total) + ) + 10 + ) + (sar (-> *dma-mem-usage* data 85 total) 10) + ) + ) + ) + ) + ) + ) + ) + (format fmt-dest "~1K~0L") + obj + ) + +;; failed to figure out what this is: +0 + +) + + + diff --git a/goal_src/jak2/engine/draw/drawable.gc b/goal_src/jak2/engine/draw/drawable.gc index acdc54057f..d12ea2f53a 100644 --- a/goal_src/jak2/engine/draw/drawable.gc +++ b/goal_src/jak2/engine/draw/drawable.gc @@ -7,17 +7,19 @@ ;; DECOMP BEGINS -;; hack -(defun prototypes-game-visible-set! ((a0-0 pair) (a1-0 symbol)) - 1) - -;; TODO - (defmacro spr-work () `(the work-area *fake-scratchpad-data*)) +;;;;;;;;;;;;;;;;;;;; +;; culling +;;;;;;;;;;;;;;;;;;;; + +;; these functions check to see if objects are within view. +;; these use the math-camera values, which is calculated based on the in-game camera position/settings. + (defun sphere-cull ((arg0 vector)) - "Is the given sphere in the view frustum?" + "Is the given sphere in the view frustum? + Uses the planes in vf16-vf19." (local-vars (v1-0 uint128) (v1-1 uint128) (v1-2 uint128)) (rlet ((acc :class vf) (vf0 :class vf) @@ -30,10 +32,10 @@ ) ;; modified for PC: these register would be loaded by the draw method of bsp. (let ((at-0 *math-camera*)) - (.lvf vf16 (&-> at-0 guard-plane 0 quad)) - (.lvf vf17 (&-> at-0 guard-plane 1 quad)) - (.lvf vf18 (&-> at-0 guard-plane 2 quad)) - (.lvf vf19 (&-> at-0 guard-plane 3 quad)) + (.lvf vf16 (&-> at-0 plane 0 quad)) + (.lvf vf17 (&-> at-0 plane 1 quad)) + (.lvf vf18 (&-> at-0 plane 2 quad)) + (.lvf vf19 (&-> at-0 plane 3 quad)) ) (init-vf0-vector) (.lvf vf10 (&-> arg0 quad)) @@ -41,6 +43,10 @@ (.add.mul.y.vf acc vf17 vf10 acc) (.add.mul.z.vf acc vf18 vf10 acc) (.sub.mul.w.vf vf9 vf19 vf0 acc) + + ;; checking to see if we are inside all 4 planes. + + ;; using the inside part of the sphere (.add.w.vf vf9 vf9 vf10) (.mov v1-0 vf9) (.pcgtw v1-1 0 v1-0) @@ -75,6 +81,10 @@ (.add.mul.y.vf acc vf21 vf10 acc) (.add.mul.z.vf acc vf22 vf10 acc) (.sub.mul.w.vf vf9 vf23 vf0 acc) + + ;; checking to see if we are outside any 1 of the 4 planes + + ;; using the outside part of the sphere. (.sub.w.vf vf9 vf9 vf10) (.mov v1-0 vf9) (.pcgtw v1-1 0 v1-0) @@ -85,8 +95,8 @@ (defun sphere-in-view-frustum? ((arg0 sphere)) "Is the given sphere in the view frustum? - Safe to use anywhere (unlike sphere-cull, which only works if service-mouse - registers are still set from draw bsp.) + Safe to use anywhere, uses planes from math-camera. + Unlike sphere-cull, which assumes that the register are setup. " (local-vars (v1-1 uint128) (v1-2 uint128) (v1-3 uint128)) (rlet ((acc :class vf) @@ -119,7 +129,8 @@ ) (defun line-in-view-frustum? ((arg0 vector) (arg1 vector)) - "Is the line segment at least partially in the view frustum?" + "Is the line segment at least partially in the view frustum? + Safe to use anywhere, uses planes in math-camera." (local-vars (v1-1 uint128) (v1-2 uint128) (v1-3 uint128) (a0-1 uint128) (a0-2 uint128) (a0-3 uint128)) (rlet ((acc :class vf) (vf0 :class vf) @@ -157,6 +168,10 @@ ) ) +;;;;;;;;;;;;;;;;;;;;;;;;;; +;; precomputed visibility +;;;;;;;;;;;;;;;;;;;;;;;;;; + (defun vis-cull ((id int)) "Is this thing visible in the precomputed visiblity data? By draw-node id. Assumes the scratchpad has the vis-list loaded." @@ -268,27 +283,565 @@ arg1 ) +;;;;;;;;;;;;;;;;;;;;;;;; +;; instance system +;;;;;;;;;;;;;;;;;;;;;;;; + ;; instance debug (define *edit-instance* (the-as string #f)) (when *debug-segment* (define *instance-mem-usage* (new 'debug 'memory-usage-block)) ) -;; todo find-instance-by-name-level +(defun find-instance-by-name-level ((arg0 string) (arg1 level)) + "Look in the given level for prototypes with the given name. + Will find both tie and shrub. + Despite the name, returns the _prototype_, not the instance (the instances aren't named)." + (let ((s5-0 (-> arg1 bsp drawable-trees))) + (dotimes (s4-0 (-> s5-0 length)) + (let ((v1-3 (-> s5-0 trees s4-0))) + (case (-> v1-3 type) + ((drawable-tree-instance-shrub) + (let ((s3-0 (-> (the-as drawable-tree-instance-shrub v1-3) info prototype-inline-array-shrub))) + (dotimes (s2-0 (-> s3-0 length)) + (if (string= arg0 (-> s3-0 data s2-0 name)) + (return (-> s3-0 data s2-0)) + ) + ) + ) + ) + ((drawable-tree-instance-tie) + (let ((s3-1 (-> (the-as drawable-tree-instance-tie v1-3) prototypes prototype-array-tie))) + (dotimes (s2-1 (-> s3-1 length)) + (if (string= arg0 (-> s3-1 array-data s2-1 name)) + (return (-> s3-1 array-data s2-1)) + ) + ) + ) + ) + ) + ) + ) + ) + (the-as prototype-bucket #f) + ) -;; todo: hack -(defun find-instance-by-name ((a0-0 string)) - (the prototype-bucket #f)) +(defun find-instance-by-name ((arg0 string)) + "Look in all levels for prototypes with the given name. + Will find both tie and shrub. + Despite the name, returns the _prototype_, not the instance (the instances aren't named)." + (dotimes (s5-0 (-> *level* length)) + (let ((a1-0 (-> *level* level s5-0))) + (when (= (-> a1-0 status) 'active) + (let ((a0-4 (find-instance-by-name-level arg0 a1-0))) + (if a0-4 + (return a0-4) + ) + ) + ) + ) + ) + (the-as prototype-bucket #f) + ) + +(defun prototypes-game-visible-set! ((arg0 pair) (arg1 symbol)) + "Set the visibility of the given prototypes, to hide stuff in levels that shouldn't appear. + Also disables collision." + (let ((a0-1 (car arg0))) + (while (not (null? arg0)) + (let ((v1-0 (find-instance-by-name (the-as string a0-1)))) + (when v1-0 + (if arg1 + (logclear! (-> v1-0 flags) (prototype-flags visible no-collide)) + (logior! (-> v1-0 flags) (prototype-flags visible no-collide)) + ) + ) + ) + (set! arg0 (cdr arg0)) + (set! a0-1 (car arg0)) + ) + ) + 0 + ) + +(defun-debug find-instance-by-index ((arg0 type) (arg1 int) (arg2 bsp-header)) + "Find an instance by its index in the bsp's drawable-tree-instance array. + The type should be either drawable-tree-instance-shrub or drawable-tree-instance-tie. + If bsp-header isn't set, picks the first active level. Otherwise looks in the level with this bsp." + (dotimes (v1-0 (-> *level* length)) + (let ((a3-3 (-> *level* level v1-0))) + (when (= (-> a3-3 status) 'active) + (let ((a3-4 (-> a3-3 bsp))) + (when (or (not arg2) (= a3-4 arg2)) + (let ((a3-5 (-> a3-4 drawable-trees))) + (dotimes (t0-5 (-> a3-5 length)) + (let ((t1-3 (-> a3-5 trees t0-5))) + (case (-> t1-3 type) + ((drawable-tree-instance-shrub) + (when (= arg0 (-> t1-3 type)) + (let ((v1-2 (-> (the-as drawable-tree-instance-shrub t1-3) info prototype-inline-array-shrub))) + (return (-> v1-2 data arg1)) + ) + ) + ) + ((drawable-tree-instance-tie) + (when (= arg0 (-> t1-3 type)) + (let ((v1-5 (-> (the-as drawable-tree-instance-tie t1-3) prototypes prototype-array-tie))) + (return (-> v1-5 array-data arg1)) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + (the-as prototype-bucket #f) + ) + +(defun-debug prototype-bucket-type ((arg0 prototype-bucket)) + "Get the instance type for this bucket. Will always be instance-shrubbery/instance-tie, doesn't + consider generic/billboard stuff." + + ;; using 1 here to avoid generic stuff. + (case (-> arg0 geometry 1 type) + ((prototype-shrubbery shrubbery) + instance-shrubbery + ) + ((prototype-tie prototype-tie tie-fragment) + instance-tie + ) + ) + ) + +(defun-debug prototype-bucket-recalc-fields ((arg0 prototype-bucket)) + "Recalculate the dists for a prototype (either tie or shrub) after it has been adjusted." + (case (prototype-bucket-type arg0) + ((instance-shrubbery) + (set! (-> arg0 rdists x) (/ 1.0 (- (-> arg0 dists w) (-> arg0 dists x)))) + ) + (else + (set! (-> arg0 dists z) (+ (-> arg0 dists x) (* 0.33333334 (- (-> arg0 dists w) (-> arg0 dists x))))) + (set! (-> arg0 rdists x) (/ 1.0 (- (-> arg0 dists z) (-> arg0 dists x)))) + ) + ) + (set! (-> arg0 rdists z) (/ 1.0 (- (-> arg0 dists w) (-> arg0 dists z)))) + (set! (-> arg0 dists y) (* 0.5 (-> arg0 dists x))) + (set! (-> arg0 rdists y) (/ 1.0 (-> arg0 dists y))) + arg0 + ) + +(defun-debug print-prototype-list () + "Print all prototypes in all loaded levels." + (local-vars (sv-16 (function prototype-bucket-shrub memory-usage-block int prototype-bucket-shrub))) + (dotimes (gp-0 (-> *level* length)) + (let ((s5-0 (-> *level* level gp-0))) + (when (= (-> s5-0 status) 'active) + (format #t "-------- level ~S~%" (-> s5-0 name)) + (let ((s5-1 (-> s5-0 bsp drawable-trees))) + (dotimes (s4-0 (-> s5-1 length)) + (let ((v1-8 (-> s5-1 trees s4-0))) + (case (-> v1-8 type) + ((drawable-tree-instance-shrub) + (let ((s3-0 (-> (the-as drawable-tree-instance-shrub v1-8) info prototype-inline-array-shrub))) + (dotimes (s2-0 (-> s3-0 length)) + 0 + (let ((s1-0 (-> s3-0 data s2-0))) + (dotimes (s0-0 4) + (reset! *instance-mem-usage*) + (if (nonzero? (-> s1-0 geometry s0-0)) + (mem-usage (-> s1-0 geometry s0-0) *instance-mem-usage* 0) + ) + ) + (let ((s0-1 s1-0)) + (set! sv-16 (method-of-object s0-1 mem-usage)) + (let ((a1-4 (reset! *instance-mem-usage*)) + (a2-2 0) + ) + (sv-16 s0-1 a1-4 a2-2) + ) + ) + (let ((v1-29 (calculate-total *instance-mem-usage*))) + (format + #t + " ~-48S~4D shrub ~5,,2fK ~4,,2fK~%" + (-> s1-0 name) + (-> s1-0 in-level) + (* 0.0009765625 (the float v1-29)) + (* 0.0009765625 (the float (* (the-as uint 80) (-> s1-0 in-level)))) + ) + ) + ) + ) + ) + ) + ((drawable-tree-instance-tie) + (let ((s3-1 (-> (the-as drawable-tree-instance-tie v1-8) prototypes prototype-array-tie))) + (dotimes (s2-1 (-> s3-1 length)) + 0 + (let ((s1-1 (-> s3-1 array-data s2-1))) + (reset! *instance-mem-usage*) + (dotimes (s0-2 4) + (when (nonzero? (-> s1-1 tie-geom s0-2)) + (let* ((a0-13 (-> s1-1 tie-geom s0-2)) + (t9-8 (method-of-object a0-13 mem-usage)) + (a1-7 *instance-mem-usage*) + (v1-47 s0-2) + ) + (t9-8 a0-13 a1-7 (logior (cond + ((= v1-47 1) + 4 + ) + ((= v1-47 2) + 8 + ) + ((= v1-47 3) + 16 + ) + (else + 0 + ) + ) + 2 + ) + ) + ) + ) + ) + (mem-usage s1-1 *instance-mem-usage* 0) + (let ((v1-54 (calculate-total *instance-mem-usage*))) + (format + #t + " ~-48S~4D tie ~5,,2fK ~4,,2fK~%" + (-> s1-1 name) + (-> s1-1 in-level) + (* 0.0009765625 (the float v1-54)) + (* 0.0009765625 (the float (* (-> s1-1 in-level) 64))) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + 0 + (none) + ) + +(defun-debug draw-instance-info ((arg0 string)) + "Print info about a prototype." + (local-vars + (sv-16 uint) + (sv-32 uint32) + (sv-48 uint32) + (sv-64 int) + (sv-80 int) + (sv-96 int) + (sv-112 int) + (sv-128 int) + (sv-144 int) + ) + (when (and *display-instance-info* *edit-instance*) + (let ((s5-0 (find-instance-by-name *edit-instance*))) + (when s5-0 + (dotimes (s4-0 (-> *level* length)) + (let ((v1-5 (-> *level* level s4-0))) + (when (= (-> v1-5 status) 'active) + (let ((s3-0 (-> v1-5 bsp drawable-trees))) + (dotimes (s2-0 (-> s3-0 length)) + (let ((v1-9 (-> s3-0 trees s2-0))) + (case (-> v1-9 type) + ((drawable-tree-instance-shrub) + ) + ((drawable-tree-instance-tie) + (let ((s1-0 (-> v1-9 data (+ (-> v1-9 length) -1)))) + (dotimes (s0-0 (-> (the-as drawable-inline-array-instance-tie s1-0) length)) + (if (string= (-> (the-as drawable-inline-array-instance-tie s1-0) data s0-0 bucket-ptr name) *edit-instance*) + (add-debug-sphere + #t + (bucket-id debug-no-zbuf1) + (the-as + vector + (+ (the-as uint (-> (the-as drawable-inline-array-instance-tie s1-0) data 0 bsphere)) (* s0-0 64)) + ) + (-> (the-as drawable-inline-array-instance-tie s1-0) data s0-0 bsphere w) + (new 'static 'rgba :g #xff :a #x80) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + (let ((s2-1 (prototype-bucket-type s5-0))) + (let ((s4-1 0)) + 0 + (cond + ((= s2-1 instance-shrubbery) + (set! s4-1 80) + ) + ((= s2-1 instance-tie) + (reset! *instance-mem-usage*) + (dotimes (s4-2 4) + (when (nonzero? (-> s5-0 geometry s4-2)) + (let* ((a0-17 (-> s5-0 geometry s4-2)) + (t9-5 (method-of-object a0-17 mem-usage)) + (a1-6 *instance-mem-usage*) + (v1-40 s4-2) + ) + (t9-5 a0-17 a1-6 (logior (cond + ((= v1-40 1) + 4 + ) + ((= v1-40 2) + 8 + ) + ((= v1-40 3) + 16 + ) + (else + 0 + ) + ) + 2 + ) + ) + ) + ) + ) + (set! s4-1 (+ (calculate-total *instance-mem-usage*) 64)) + ) + ) + (mem-usage s5-0 (reset! *instance-mem-usage*) 0) + (let ((v1-50 (calculate-total *instance-mem-usage*))) + (format + arg0 + "~%~A ~A b @ #x~X ~,,2fK/~,,2fK~%" + s2-1 + (-> s5-0 name) + s5-0 + (* 0.0009765625 (the float v1-50)) + (* 0.0009765625 (the float s4-1)) + ) + ) + ) + (format arg0 "near: ~m mid: ~m far: ~m~%" (-> s5-0 dists x) (-> s5-0 dists z) (-> s5-0 dists w)) + (let ((s3-2 0) + (s4-3 0) + ) + (cond + ((= s2-1 instance-shrubbery) + (let ((f30-0 0.0)) + (format + arg0 + "usage: vis: ~D shrub: ~D trans-shrub ~D bill: ~D in level: ~D~%" + (-> (the-as prototype-bucket-shrub s5-0) count 0) + (-> (the-as prototype-bucket-shrub s5-0) count 1) + (-> (the-as prototype-bucket-shrub s5-0) count 2) + (-> (the-as prototype-bucket-shrub s5-0) count 3) + (-> (the-as prototype-bucket-shrub s5-0) in-level) + ) + (format arg0 "~%frag# tris dverts strlen tex~%") + (let ((s1-2 (the-as prototype-shrubbery (-> (the-as prototype-bucket-shrub s5-0) geometry 1))) + (s2-2 (+ (-> (the-as prototype-bucket-shrub s5-0) count 1) (-> (the-as prototype-bucket-shrub s5-0) count 2))) + ) + (dotimes (s0-1 (-> s1-2 length)) + (set! sv-16 (shrub-num-tris (-> s1-2 data s0-1))) + (set! sv-32 (-> s1-2 data s0-1 header data 2)) + (set! sv-48 (-> s1-2 data s0-1 header data 0)) + (format + arg0 + "~5D ~4D ~5D ~6f ~D~%" + s0-1 + sv-16 + sv-32 + (/ (* 2.0 (the float sv-16)) (the float (- sv-32 (the-as uint sv-16)))) + sv-48 + ) + (+! s3-2 sv-16) + (+! s4-3 (the-as int sv-32)) + (set! f30-0 + (+ 29.0 + (* 5.5 (the float (- sv-32 (the-as uint sv-16)))) + (* 22.0 (the float sv-48)) + (* 8.0 (the float sv-32)) + (* 53.0 (the float (/ (+ s2-2 9) (the-as uint 10)))) + (* (the float s2-2) (+ 15.0 (* 5.0 (the float sv-48)) (* 13.5 (the float sv-32)))) + f30-0 + ) + ) + ) + (format + arg0 + "total ~4D ~5D ~6f ~D speed: ~f~%" + s3-2 + s4-3 + (/ (* 2.0 (the float s3-2)) (the float (- s4-3 s3-2))) + (-> s5-0 utextures) + (/ f30-0 (* (the float s2-2) (the float s3-2))) + ) + ) + ) + ) + ((= s2-1 instance-tie) + (set! sv-144 0) + (let ((s1-3 0) + (s0-2 0) + (s2-3 0) + ) + (format arg0 "~%level visible frags tris dverts strlen tex ttris~%") + (set! sv-64 1) + (set! sv-80 3) + (while (>= sv-80 sv-64) + (let ((v1-100 (-> (the-as prototype-bucket-tie s5-0) tie-geom sv-64))) + (set! sv-96 0) + (set! sv-112 0) + (set! sv-128 0) + (dotimes (a0-36 (-> v1-100 length)) + (set! sv-96 (+ sv-96 (-> v1-100 data a0-36 debug num-tris))) + (set! sv-112 (+ sv-112 (-> v1-100 data a0-36 debug num-dverts))) + (set! sv-128 (+ sv-128 (-> v1-100 data a0-36 tex-count))) + ) + (set! sv-144 (+ sv-144 (the-as int (-> (the-as prototype-bucket-tie s5-0) count sv-64)))) + (format + arg0 + "~5D ~7D ~5D ~5D" + sv-64 + (-> (the-as prototype-bucket-tie s5-0) count sv-64) + (-> v1-100 length) + sv-96 + ) + ) + (format + arg0 + " ~5D ~6f ~3D ~5D~%" + sv-112 + (/ (* 2.0 (the float sv-96)) (the float (- sv-112 sv-96))) + sv-128 + (* (the-as uint sv-96) (the-as uint (-> (the-as prototype-bucket-tie s5-0) count sv-64))) + ) + (+! s1-3 (* (the-as uint sv-96) (the-as uint (-> (the-as prototype-bucket-tie s5-0) count sv-64)))) + (+! s0-2 (* (the-as uint sv-112) (the-as uint (-> (the-as prototype-bucket-tie s5-0) count sv-64)))) + (+! s3-2 sv-96) + (+! s4-3 sv-112) + (+! s2-3 sv-128) + (set! sv-64 (+ sv-64 1)) + ) + (let ((t9-20 format) + (a0-52 arg0) + (a1-28 "total ~7D/~3D ~5D") + (a3-12 (-> s5-0 in-level)) + ) + (t9-20 a0-52 a1-28 sv-144 a3-12 s3-2) + ) + (format + arg0 + " ~5D ~6f ~3D ~5D~%" + s4-3 + (/ (* 2.0 (the float s1-3)) (the float (- s0-2 s1-3))) + s2-3 + s1-3 + ) + ) + ) + ) + ) + ) + ) + ) + ) + (none) + ) + +(defun-debug set-shadow-by-name ((arg0 string) (arg1 int) (arg2 int)) + "Update the shadow masks and values for an active process-drawable." + (let ((v1-0 (process-by-name arg0 *active-pool*))) + (when v1-0 + (let ((v1-1 (-> (the-as process-drawable v1-0) draw))) + (cond + ((< arg2 16) + (logior! (-> v1-1 shadow-mask) (ash 1 arg1)) + (logclear! (-> v1-1 shadow-values) (ash 15 (* arg1 4))) + (logior! (-> v1-1 shadow-values) (ash arg2 (* arg1 4))) + ) + (else + (logclear! (-> v1-1 shadow-mask) (ash 1 arg1)) + (logclear! (-> v1-1 shadow-values) (ash 15 (* arg1 4))) + ) + ) + ) + ) + ) + (none) + ) + +(defun-debug get-shadow-by-name ((arg0 string)) + "Get the current mask/values for an active process-drawable" + (let ((v1-0 (process-by-name arg0 *active-pool*))) + (when v1-0 + (let ((s5-0 (-> (the-as process-drawable v1-0) draw))) + (format 0 "actor ~s {~%" arg0) + (format 0 " SHADOW_MASK(0x~02x)~%" (-> s5-0 shadow-mask)) + (format 0 " SHADOW_VALUES(0x~08x)~%" (-> s5-0 shadow-values)) + ) + (format 0 "}~%") + ) + ) + (none) + ) + +(defun-debug teleport-camera-by-name ((arg0 string)) + "Send the camera to an entity, switch to string mode." + (let* ((gp-0 (entity-by-name arg0)) + (v1-0 (if (type? gp-0 entity-actor) + gp-0 + ) + ) + ) + (if (and v1-0 *camera*) + (send-event *camera* 'teleport-to-vector-start-string (-> v1-0 trans)) + ) + ) + (none) + ) + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; foreground drawing system +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +;; processes will call ja-post, which adds them to the matrix engine +;; the matrix engine runs (there's a few ways), it computes joints, then kicks out the process from the matrix engine +;; all drawable processes belong to the foreground-draw-engine. +;; - foreground-initialize-engines runs, preparing for the foreground engine run +;; - foreground-engine-execute runs, +;; - foreground-init runs +;; - execute-connections runs on the foreground engine +;; it calls add-process-drawable which calls dma-add-func which is usually dma-add-process-drawable +;; - dma-add-process-drawable does culling, picking lights/shadow +;; - calls foreground-draw +;; picks merc/emerc/shadow/generic/effects, more light processing +;; adds the bone calculation, calls the foreground- to generate dma +;; - foreground-wrapup runs, patching up merc/emerc stuff +;; - foreground-execute-cpu-vu0-engines runs +;; - does bone calcs for merc +;; - does VU0/CPU stuff for generic/shadow/lightning -;; todo prototypes-game-visible-set! -;; todo find-instance-by-index -;; todo prototype-bucket-type -;; todo prototype-bucket-recalc-fields -;; todo print-prototype-list -;; todo draw-instance-info -;; todo set-shadow-by-name -;; todo get-shadow-by-name -;; todo teleport-camera-by-name (defun dma-add-process-drawable ((pd process-drawable) (dc draw-control) (flag symbol) (dma-buf dma-buffer)) "Draw a normal process-drawable. Set up lighting/shadow settings, then pass on to foreground renderer." @@ -672,7 +1225,55 @@ (set-vector! (-> *hud-lights* color 2) 0.5 0.5 0.5 1.0) (set-vector! (-> *hud-lights* ambient) 0.5 0.5 0.5 1.0) -;; todo dma-add-process-drawable-hud +(defun dma-add-process-drawable-hud ((arg0 process-drawable) (arg1 draw-control) (arg2 float) (arg3 dma-buffer)) + "Generate DMA for a foreground-hud process-drawable." + (local-vars (a3-4 uint128)) + + ;; clear old value of on-screen + (logclear! (-> arg1 status) (draw-control-status on-screen)) + + ;; only draw if we're enabled + (when (not (logtest? (-> arg1 status) (draw-control-status no-draw no-draw-temp uninited))) + + ;; copy *hud-lights* to the scratchpad lights. + (let ((v1-6 (-> (scratchpad-object foreground-work) lights)) + (a0-3 *hud-lights*) + ) + (set! (-> v1-6 direction 0 quad) (-> a0-3 direction 0 quad)) + (set! (-> v1-6 direction 1 quad) (-> a0-3 direction 1 quad)) + (set! (-> v1-6 direction 2 quad) (-> a0-3 direction 2 quad)) + (set! (-> v1-6 color 0 quad) (-> a0-3 color 0 quad)) + (set! (-> v1-6 color 1 quad) (-> a0-3 color 1 quad)) + (set! (-> v1-6 color 2 quad) (-> a0-3 color 2 quad)) + (set! (-> v1-6 ambient quad) (-> a0-3 ambient quad)) + ) + + ;; force lod0 and on-screen + (lod-set! arg1 0) + (logior! (-> arg1 status) (draw-control-status on-screen)) + + ;; send to foreground. + (foreground-draw-hud arg1 arg3 arg2) + + ;; update textures. + (let ((v1-12 (-> *level* default-level)) + (a0-8 (-> arg1 mgeo header texture-usage-group)) + ) + (dotimes (a1-9 7) + (let ((a2-1 (+ a1-9 11))) + (let ((a3-3 (-> v1-12 texture-mask a2-1 mask quad)) + (t0-3 (-> a0-8 data a1-9 data 2 mask quad)) + ) + (.por a3-4 a3-3 t0-3) + ) + (set! (-> v1-12 texture-mask a2-1 mask quad) a3-4) + ) + ) + ) + ) + 0 + (none) + ) (defun add-process-drawable ((arg0 process-drawable) (arg1 draw-control) (arg2 symbol) (arg3 dma-buffer)) "Call the dma-add-func callback on a draw-control to draw it." @@ -731,7 +1332,7 @@ ) ) (execute-connections *debug-engine* #f) - ;(draw-instance-info *stdcon*) + (draw-instance-info *stdcon*) ) (none) ) @@ -743,14 +1344,17 @@ (define *generic-effect-mode* 0) (defun foreground-initialize-engines () + "Called before dispatching foreground engine to set up." + + ;; initialize shadow lists. (let ((v1-0 *shadow-globals*)) (dotimes (a0-0 2) (let ((a1-2 (-> v1-0 bucket a0-0))) (set! (-> a1-2 first) (the-as uint 0)) (set! (-> a1-2 next) (the-as uint 0)) (set! (-> a1-2 shadow-color) (if (zero? a0-0) - (the-as uint #x80f0f0f0) - (the-as uint (-> *setting-control* user-current spotlight-color)) + (new 'static 'rgba :r #xf0 :g #xf0 :b #xf0 :a #x80) + (the-as rgba (-> *setting-control* user-current spotlight-color)) ) ) (set! (-> a1-2 constants) (the-as basic 0)) @@ -761,9 +1365,13 @@ ) (defun foreground-execute-cpu-vu0-engines () + "Run the CPU/VU0 part of foreground. Happens after the foreground-engine-execute is done (first pass dma done). + Generates bone matrices for VU1 renderers and does leftover stuff that depends on bones." (let ((gp-0 (-> *display* frames (-> *display* on-screen) global-buf))) + ;; do the bones (bones-init gp-0) (bones-mtx-calc-execute) + ;; generic-merc/shadow have VU0/CPU parts that need bones, run them here. ;;(generic-merc-execute-all gp-0) ;;(shadow-execute-all gp-0) ) @@ -773,6 +1381,7 @@ (defun real-main-draw-hook () + "Main function to run the drawable system, called from the display-loop in main.gc" (local-vars (a0-96 int) (a0-98 int)) (with-pp (when *slow-frame-rate* @@ -792,29 +1401,29 @@ (set! (-> *texture-pool* texture-enable-user) (-> *texture-pool* texture-enable-user-menu)) ;; display memory stats - ; (when *debug-segment* - ; (when (and *stats-memory* (!= *master-mode* 'menu)) - ; (cond - ; (*stats-memory-short* - ; (dotimes (gp-0 (-> *level* length)) - ; (let ((s5-0 (-> *level* level gp-0))) - ; (if (= (-> s5-0 status) 'active) - ; (print-mem-usage (compute-memory-usage s5-0 #f) s5-0 *stdcon*) - ; ) - ; ) - ; ) - ; ) - ; (else - ; (let ((gp-1 (-> *level* level *stats-memory-level-index*))) - ; (if (and gp-1 (= (-> gp-1 status) 'active)) - ; (print-mem-usage (compute-memory-usage gp-1 #f) gp-1 *stdcon*) - ; ) - ; ) - ; ) - ; ) - ; ) - ; (reset! *dma-mem-usage*) - ; ) + (when *debug-segment* + (when (and *stats-memory* (!= *master-mode* 'menu)) + (cond + (*stats-memory-short* + (dotimes (gp-0 (-> *level* length)) + (let ((s5-0 (-> *level* level gp-0))) + (if (= (-> s5-0 status) 'active) + (print-mem-usage (compute-memory-usage! s5-0 #f) s5-0 *stdcon*) + ) + ) + ) + ) + (else + (let ((gp-1 (-> *level* level *stats-memory-level-index*))) + (if (and gp-1 (= (-> gp-1 status) 'active)) + (print-mem-usage (compute-memory-usage! gp-1 #f) gp-1 *stdcon*) + ) + ) + ) + ) + ) + (reset! *dma-mem-usage*) + ) ;; set up foreground buckets (foreground-initialize-engines) @@ -930,6 +1539,7 @@ (end-perf-stat-collection) + ;; background stats (when (and (!= *master-mode* 'menu) *stats-poly*) (dotimes (gp-13 (-> *level* length)) (let ((v1-307 (-> *level* level gp-13))) @@ -941,6 +1551,8 @@ (print-terrain-stats) ) + + ;; perf and collide stats (when (not (paused?)) (if (and (!= *master-mode* 'menu) *stats-perf*) (print-perf-stats) @@ -1120,6 +1732,19 @@ (none) ) +(defun-debug screen-shot-scale ((arg0 int) (arg1 string)) + (set! (-> *screen-shot-work* size) arg0) + (set! (-> *screen-shot-work* name) arg1) + (set! *display-profile* #f) + 0 + (none) + ) + +(defun-debug screen-shot () + (screen-shot-scale 1 "image") + 0 + (none) + ) (defun display-frame-start ((arg0 display) (arg1 int) (arg2 float)) "Advance clocks, poll pads/mouse, set up buckets." @@ -1590,5 +2215,3 @@ (none) ) - -(define-extern prototypes-game-visible-set! (function pair symbol int)) diff --git a/goal_src/jak2/engine/game/main.gc b/goal_src/jak2/engine/game/main.gc index 65c570c3b1..b3ef7c9f4f 100644 --- a/goal_src/jak2/engine/game/main.gc +++ b/goal_src/jak2/engine/game/main.gc @@ -307,14 +307,960 @@ 0 ) -;; TODO screen filter +(define *screen-filter* (new 'static 'screen-filter :draw? #f :bucket (bucket-id screen-filter))) + +(defmethod draw screen-filter ((obj screen-filter)) + (local-vars (v1-1 float)) + (rlet ((vf0 :class vf) + (vf1 :class vf) + (vf2 :class vf) + (vf3 :class vf) + (vf4 :class vf) + ) + (init-vf0-vector) + (when (not (paused?)) + (.lvf vf4 (&-> obj extra quad)) + (.lvf vf1 (&-> obj color-dest quad)) + (.lvf vf2 (&-> obj color quad)) + (.sub.vf vf3 vf1 vf2) + (.add.x.vf vf4 vf4 vf4 :mask #b10) + (.min.w.vf vf4 vf4 vf0 :mask #b10) + (.max.y.vf vf4 vf4 vf0 :mask #b10) + (.mul.y.vf vf3 vf3 vf4) + (.add.vf vf1 vf2 vf3) + (.svf (&-> obj extra quad) vf4) + (.svf (&-> obj color quad) vf1) + (.mov v1-1 vf1) + ) + (with-dma-buffer-add-bucket ((s4-0 (-> *display* frames (-> *display* on-screen) global-buf)) + (-> obj bucket) + ) + (let ((v1-7 s4-0)) + (let ((a0-2 (the-as object (-> v1-7 base)))) + (set! (-> (the-as dma-packet a0-2) dma) (new 'static 'dma-tag :qwc #x2 :id (dma-tag-id cnt))) + (set! (-> (the-as dma-packet a0-2) vif0) (new 'static 'vif-tag)) + (set! (-> (the-as dma-packet a0-2) vif1) (new 'static 'vif-tag :imm #x2 :cmd (vif-cmd direct) :msk #x1)) + (set! (-> v1-7 base) (&+ (the-as pointer a0-2) 16)) + ) + ) + (let ((v1-8 s4-0)) + (let ((a0-4 (the-as object (-> v1-8 base)))) + (set! (-> (the-as gs-gif-tag a0-4) tag) (new 'static 'gif-tag64 :nloop #x1 :eop #x1 :nreg #x1)) + (set! (-> (the-as gs-gif-tag a0-4) regs) GIF_REGS_ALL_AD) + (set! (-> v1-8 base) (&+ (the-as pointer a0-4) 16)) + ) + ) + (let ((v1-9 s4-0)) + (let ((a0-6 (-> v1-9 base))) + (set! (-> (the-as (pointer gs-test) a0-6) 0) + (new 'static 'gs-test :ate #x1 :afail #x3 :zte #x1 :ztst (gs-ztest always)) + ) + (set! (-> (the-as (pointer gs-reg64) a0-6) 1) (gs-reg64 test-1)) + (set! (-> v1-9 base) (&+ a0-6 16)) + ) + ) + (let ((t1-0 (new 'static 'rgba + :r (the int (-> obj color x)) + :g (the int (-> obj color y)) + :b (the int (-> obj color z)) + :a (the int (-> obj color w)) + ) + ) + ) + (draw-sprite2d-xy s4-0 -256 -208 512 416 t1-0) + ) + ) + 0 + (none) + ) + ) + +(defmethod setup screen-filter ((obj screen-filter) (arg0 vector) (arg1 vector) (arg2 float) (arg3 bucket-id)) + (set! (-> obj draw?) #t) + (set! (-> obj color quad) (-> arg0 quad)) + (set! (-> obj color-src quad) (-> arg0 quad)) + (set! (-> obj color-dest quad) (-> arg1 quad)) + (set! (-> obj extra x) arg2) + (set! (-> obj extra y) 0.0) + (set! (-> obj bucket) arg3) + 0 + (none) + ) + +(defmethod disable screen-filter ((obj screen-filter)) + (set! (-> obj draw?) #f) + 0 + (none) + ) + (define *cheat-temp* (the-as (pointer int32) (malloc 'global 20))) (define *master-exit* #f) (define *progress-cheat* #f) (define *first-boot* #t) -;; TODO cheats +(defun main-cheats () + (when (and (cpad-hold? 0 l3) (or *cheat-mode* (not (demo?)))) + ((lambda () + (when (nonzero? (-> *cpad-list* cpads 0 button0-rel 0)) + (let ((v1-5 (-> *cheat-temp* 0))) + (cond + ((zero? v1-5) + (cond + ((cpad-pressed? 0 up) + (+! (-> *cheat-temp* 0) 1) + ) + (else + (set! (-> *cheat-temp* 0) 0) + 0 + ) + ) + ) + ((= v1-5 1) + (cond + ((cpad-pressed? 0 up) + (+! (-> *cheat-temp* 0) 1) + ) + (else + (set! (-> *cheat-temp* 0) 0) + 0 + ) + ) + ) + ((= v1-5 2) + (cond + ((cpad-pressed? 0 down) + (+! (-> *cheat-temp* 0) 1) + ) + (else + (set! (-> *cheat-temp* 0) 0) + 0 + ) + ) + ) + ((= v1-5 3) + (cond + ((cpad-pressed? 0 down) + (+! (-> *cheat-temp* 0) 1) + ) + (else + (set! (-> *cheat-temp* 0) 0) + 0 + ) + ) + ) + ((= v1-5 4) + (cond + ((cpad-pressed? 0 left) + (+! (-> *cheat-temp* 0) 1) + ) + (else + (set! (-> *cheat-temp* 0) 0) + 0 + ) + ) + ) + ((= v1-5 5) + (cond + ((cpad-pressed? 0 right) + (+! (-> *cheat-temp* 0) 1) + ) + (else + (set! (-> *cheat-temp* 0) 0) + 0 + ) + ) + ) + ((= v1-5 6) + (cond + ((cpad-pressed? 0 left) + (+! (-> *cheat-temp* 0) 1) + ) + (else + (set! (-> *cheat-temp* 0) 0) + 0 + ) + ) + ) + ((= v1-5 7) + (cond + ((cpad-pressed? 0 right) + (+! (-> *cheat-temp* 0) 1) + ) + (else + (set! (-> *cheat-temp* 0) 0) + 0 + ) + ) + ) + ((= v1-5 8) + (cond + ((cpad-pressed? 0 x) + (+! (-> *cheat-temp* 0) 1) + ) + (else + (set! (-> *cheat-temp* 0) 0) + 0 + ) + ) + ) + ((= v1-5 9) + (cond + ((cpad-pressed? 0 x) + (+! (-> *cheat-temp* 0) 1) + ) + (else + (set! (-> *cheat-temp* 0) 0) + 0 + ) + ) + ) + ((= v1-5 10) + (cond + ((cpad-pressed? 0 square) + (+! (-> *cheat-temp* 0) 1) + ) + (else + (set! (-> *cheat-temp* 0) 0) + 0 + ) + ) + ) + ((= v1-5 11) + (cond + ((cpad-pressed? 0 circle) + (+! (-> *cheat-temp* 0) 1) + ) + (else + (set! (-> *cheat-temp* 0) 0) + 0 + ) + ) + ) + ((= v1-5 12) + (cond + ((cpad-pressed? 0 square) + (+! (-> *cheat-temp* 0) 1) + ) + (else + (set! (-> *cheat-temp* 0) 0) + 0 + ) + ) + ) + ((= v1-5 13) + (cond + ((cpad-pressed? 0 circle) + (logclear! (-> *cpad-list* cpads 0 button0-abs 0) (pad-buttons r1)) + (logclear! (-> *cpad-list* cpads 0 button0-rel 0) (pad-buttons r1)) + (set! *cheat-mode* (not *cheat-mode*)) + (if *cheat-mode* + (sound-play-by-spec (static-sound-spec "menu-pick" :fo-curve 1) (new-sound-id) (the-as vector #t)) + (sound-play-by-spec (static-sound-spec "menu-back" :fo-curve 1) (new-sound-id) (the-as vector #t)) + ) + (set! (-> *cheat-temp* 0) 0) + 0 + ) + (else + (set! (-> *cheat-temp* 0) 0) + 0 + ) + ) + ) + ) + ) + ) + (when *cheat-mode* + (when (nonzero? (-> *cpad-list* cpads 0 button0-rel 0)) + (let ((v1-146 (-> *cheat-temp* 1))) + (cond + ((zero? v1-146) + (cond + ((cpad-pressed? 0 circle) + (+! (-> *cheat-temp* 1) 1) + ) + (else + (set! (-> *cheat-temp* 1) 0) + 0 + ) + ) + ) + ((= v1-146 1) + (cond + ((cpad-pressed? 0 square) + (+! (-> *cheat-temp* 1) 1) + ) + (else + (set! (-> *cheat-temp* 1) 0) + 0 + ) + ) + ) + ((= v1-146 2) + (cond + ((cpad-pressed? 0 circle) + (+! (-> *cheat-temp* 1) 1) + ) + (else + (set! (-> *cheat-temp* 1) 0) + 0 + ) + ) + ) + ((= v1-146 3) + (cond + ((cpad-pressed? 0 square) + (+! (-> *cheat-temp* 1) 1) + ) + (else + (set! (-> *cheat-temp* 1) 0) + 0 + ) + ) + ) + ((= v1-146 4) + (cond + ((cpad-pressed? 0 x) + (+! (-> *cheat-temp* 1) 1) + ) + (else + (set! (-> *cheat-temp* 1) 0) + 0 + ) + ) + ) + ((= v1-146 5) + (cond + ((cpad-pressed? 0 x) + (+! (-> *cheat-temp* 1) 1) + ) + (else + (set! (-> *cheat-temp* 1) 0) + 0 + ) + ) + ) + ((= v1-146 6) + (cond + ((cpad-pressed? 0 right) + (+! (-> *cheat-temp* 1) 1) + ) + (else + (set! (-> *cheat-temp* 1) 0) + 0 + ) + ) + ) + ((= v1-146 7) + (cond + ((cpad-pressed? 0 left) + (+! (-> *cheat-temp* 1) 1) + ) + (else + (set! (-> *cheat-temp* 1) 0) + 0 + ) + ) + ) + ((= v1-146 8) + (cond + ((cpad-pressed? 0 right) + (+! (-> *cheat-temp* 1) 1) + ) + (else + (set! (-> *cheat-temp* 1) 0) + 0 + ) + ) + ) + ((= v1-146 9) + (cond + ((cpad-pressed? 0 left) + (+! (-> *cheat-temp* 1) 1) + ) + (else + (set! (-> *cheat-temp* 1) 0) + 0 + ) + ) + ) + ((= v1-146 10) + (cond + ((cpad-pressed? 0 down) + (+! (-> *cheat-temp* 1) 1) + ) + (else + (set! (-> *cheat-temp* 1) 0) + 0 + ) + ) + ) + ((= v1-146 11) + (cond + ((cpad-pressed? 0 down) + (+! (-> *cheat-temp* 1) 1) + ) + (else + (set! (-> *cheat-temp* 1) 0) + 0 + ) + ) + ) + ((= v1-146 12) + (cond + ((cpad-pressed? 0 up) + (+! (-> *cheat-temp* 1) 1) + ) + (else + (set! (-> *cheat-temp* 1) 0) + 0 + ) + ) + ) + ((= v1-146 13) + (cond + ((cpad-pressed? 0 up) + (logclear! (-> *cpad-list* cpads 0 button0-abs 0) (pad-buttons r1)) + (logclear! (-> *cpad-list* cpads 0 button0-rel 0) (pad-buttons r1)) + (set! *cheat-mode* (if (= *cheat-mode* 'debug) + #t + 'debug + ) + ) + (if (= *cheat-mode* 'debug) + (sound-play-by-spec (static-sound-spec "menu-pick" :fo-curve 1) (new-sound-id) (the-as vector #t)) + (sound-play-by-spec (static-sound-spec "menu-back" :fo-curve 1) (new-sound-id) (the-as vector #t)) + ) + (set! (-> *cheat-temp* 1) 0) + 0 + ) + (else + (set! (-> *cheat-temp* 1) 0) + 0 + ) + ) + ) + ) + ) + ) + ) + (none) + ) + ) + ((lambda () + (case (scf-get-territory) + ((2) + (when (nonzero? (-> *cpad-list* cpads 0 button0-rel 0)) + (let ((v1-7 (-> *cheat-temp* 2))) + (cond + ((zero? v1-7) + (cond + ((cpad-pressed? 0 l1) + (+! (-> *cheat-temp* 2) 1) + ) + (else + (set! (-> *cheat-temp* 2) 0) + 0 + ) + ) + ) + ((= v1-7 1) + (cond + ((cpad-pressed? 0 r1) + (+! (-> *cheat-temp* 2) 1) + ) + (else + (set! (-> *cheat-temp* 2) 0) + 0 + ) + ) + ) + ((= v1-7 2) + (cond + ((cpad-pressed? 0 l1) + (+! (-> *cheat-temp* 2) 1) + ) + (else + (set! (-> *cheat-temp* 2) 0) + 0 + ) + ) + ) + ((= v1-7 3) + (cond + ((cpad-pressed? 0 r1) + (+! (-> *cheat-temp* 2) 1) + ) + (else + (set! (-> *cheat-temp* 2) 0) + 0 + ) + ) + ) + ((= v1-7 4) + (cond + ((cpad-pressed? 0 triangle) + (+! (-> *cheat-temp* 2) 1) + ) + (else + (set! (-> *cheat-temp* 2) 0) + 0 + ) + ) + ) + ((= v1-7 5) + (cond + ((cpad-pressed? 0 circle) + (+! (-> *cheat-temp* 2) 1) + ) + (else + (set! (-> *cheat-temp* 2) 0) + 0 + ) + ) + ) + ((= v1-7 6) + (cond + ((cpad-pressed? 0 x) + (+! (-> *cheat-temp* 2) 1) + ) + (else + (set! (-> *cheat-temp* 2) 0) + 0 + ) + ) + ) + ((= v1-7 7) + (cond + ((cpad-pressed? 0 square) + (logclear! (-> *cpad-list* cpads 0 button0-abs 0) (pad-buttons r1)) + (logclear! (-> *cpad-list* cpads 0 button0-rel 0) (pad-buttons r1)) + (set! *progress-cheat* (if *progress-cheat* + #f + 'language + ) + ) + (if *progress-cheat* + (sound-play-by-spec (static-sound-spec "menu-pick" :fo-curve 1) (new-sound-id) (the-as vector #t)) + (sound-play-by-spec (static-sound-spec "menu-back" :fo-curve 1) (new-sound-id) (the-as vector #t)) + ) + (set! (-> *cheat-temp* 2) 0) + 0 + ) + (else + (set! (-> *cheat-temp* 2) 0) + 0 + ) + ) + ) + ) + ) + ) + ) + ) + (when *debug-segment* + (when (nonzero? (-> *cpad-list* cpads 0 button0-rel 0)) + (let ((v1-95 (-> *cheat-temp* 3))) + (cond + ((zero? v1-95) + (cond + ((cpad-pressed? 0 x) + (+! (-> *cheat-temp* 3) 1) + ) + (else + (set! (-> *cheat-temp* 3) 0) + 0 + ) + ) + ) + ((= v1-95 1) + (cond + ((cpad-pressed? 0 square) + (+! (-> *cheat-temp* 3) 1) + ) + (else + (set! (-> *cheat-temp* 3) 0) + 0 + ) + ) + ) + ((= v1-95 2) + (cond + ((cpad-pressed? 0 triangle) + (+! (-> *cheat-temp* 3) 1) + ) + (else + (set! (-> *cheat-temp* 3) 0) + 0 + ) + ) + ) + ((= v1-95 3) + (cond + ((cpad-pressed? 0 circle) + (+! (-> *cheat-temp* 3) 1) + ) + (else + (set! (-> *cheat-temp* 3) 0) + 0 + ) + ) + ) + ((= v1-95 4) + (cond + ((cpad-pressed? 0 x) + (+! (-> *cheat-temp* 3) 1) + ) + (else + (set! (-> *cheat-temp* 3) 0) + 0 + ) + ) + ) + ((= v1-95 5) + (cond + ((cpad-pressed? 0 square) + (+! (-> *cheat-temp* 3) 1) + ) + (else + (set! (-> *cheat-temp* 3) 0) + 0 + ) + ) + ) + ((= v1-95 6) + (cond + ((cpad-pressed? 0 triangle) + (+! (-> *cheat-temp* 3) 1) + ) + (else + (set! (-> *cheat-temp* 3) 0) + 0 + ) + ) + ) + ((= v1-95 7) + (cond + ((cpad-pressed? 0 circle) + (logclear! (-> *cpad-list* cpads 0 button0-abs 0) (pad-buttons r1)) + (logclear! (-> *cpad-list* cpads 0 button0-rel 0) (pad-buttons r1)) + (set! *progress-cheat* (if *progress-cheat* + #f + 'pal + ) + ) + (if *progress-cheat* + (sound-play-by-spec (static-sound-spec "menu-pick" :fo-curve 1) (new-sound-id) (the-as vector #t)) + (sound-play-by-spec (static-sound-spec "menu-back" :fo-curve 1) (new-sound-id) (the-as vector #t)) + ) + (set! (-> *cheat-temp* 3) 0) + 0 + ) + (else + (set! (-> *cheat-temp* 3) 0) + 0 + ) + ) + ) + ) + ) + ) + (when (nonzero? (-> *cpad-list* cpads 1 button0-rel 0)) + (let ((v1-181 (-> *cheat-temp* 5))) + (cond + ((zero? v1-181) + (cond + ((cpad-pressed? 1 triangle) + (+! (-> *cheat-temp* 5) 1) + ) + (else + (set! (-> *cheat-temp* 5) 0) + 0 + ) + ) + ) + ((= v1-181 1) + (cond + ((cpad-pressed? 1 x) + (+! (-> *cheat-temp* 5) 1) + ) + (else + (set! (-> *cheat-temp* 5) 0) + 0 + ) + ) + ) + ((= v1-181 2) + (cond + ((cpad-pressed? 1 circle) + (+! (-> *cheat-temp* 5) 1) + ) + (else + (set! (-> *cheat-temp* 5) 0) + 0 + ) + ) + ) + ((= v1-181 3) + (cond + ((cpad-pressed? 1 square) + (+! (-> *cheat-temp* 5) 1) + ) + (else + (set! (-> *cheat-temp* 5) 0) + 0 + ) + ) + ) + ((= v1-181 4) + (cond + ((cpad-pressed? 1 triangle) + (+! (-> *cheat-temp* 5) 1) + ) + (else + (set! (-> *cheat-temp* 5) 0) + 0 + ) + ) + ) + ((= v1-181 5) + (cond + ((cpad-pressed? 1 x) + (+! (-> *cheat-temp* 5) 1) + ) + (else + (set! (-> *cheat-temp* 5) 0) + 0 + ) + ) + ) + ((= v1-181 6) + (cond + ((cpad-pressed? 1 circle) + (+! (-> *cheat-temp* 5) 1) + ) + (else + (set! (-> *cheat-temp* 5) 0) + 0 + ) + ) + ) + ((= v1-181 7) + (cond + ((cpad-pressed? 1 square) + (logclear! (-> *cpad-list* cpads 0 button0-abs 0) (pad-buttons r1)) + (logclear! (-> *cpad-list* cpads 0 button0-rel 0) (pad-buttons r1)) + (set! *cheat-mode* (if (= *cheat-mode* 'camera) + #f + 'camera + ) + ) + (cond + (*cheat-mode* + (if (not *external-cam-mode*) + (external-cam-reset!) + ) + (set! *external-cam-mode* 'pad-1) + (sound-play-by-spec (static-sound-spec "menu-pick" :fo-curve 1) (new-sound-id) (the-as vector #t)) + ) + (else + (set! *external-cam-mode* #f) + (sound-play-by-spec (static-sound-spec "menu-back" :fo-curve 1) (new-sound-id) (the-as vector #t)) + ) + ) + (set! (-> *cheat-temp* 5) 0) + 0 + ) + (else + (set! (-> *cheat-temp* 5) 0) + 0 + ) + ) + ) + ) + ) + ) + ) + (none) + ) + ) + ) + (if (and *cheat-mode* (not *debug-segment*) (cpad-hold? 1 l3)) + ((lambda () + (cond + ((cpad-pressed? 1 x) + (send-event *target* 'get-pickup 13 #x447a0000) + (send-event *target* 'get-pickup 14 #x447a0000) + (send-event *target* 'get-pickup 15 #x447a0000) + (send-event *target* 'get-pickup 16 #x447a0000) + (send-event *target* 'get-pickup 7 #x447a0000) + (send-event *target* 'get-pickup 22 #x447a0000) + (send-event *target* 'get-pickup 21 #x447a0000) + (set! (-> *game-info* features) + (logior (game-feature + gun + gun-yellow + gun-red + gun-blue + gun-dark + board + darkjak + darkjak-bomb0 + darkjak-bomb1 + darkjak-invinc + darkjak-giant + ) + (-> *game-info* features) + ) + ) + (logior! + (-> *game-info* debug-features) + (game-feature gun gun-yellow gun-red gun-blue gun-dark board darkjak) + ) + (sound-play-by-spec (static-sound-spec "menu-pick" :fo-curve 1) (new-sound-id) (the-as vector #t)) + ) + ((cpad-pressed? 1 square) + (set! (-> *level* disk-load-timing?) (not (-> *level* disk-load-timing?))) + (if (-> *level* disk-load-timing?) + (sound-play-by-spec (static-sound-spec "menu-pick" :fo-curve 1) (new-sound-id) (the-as vector #t)) + (sound-play-by-spec (static-sound-spec "menu-back" :fo-curve 1) (new-sound-id) (the-as vector #t)) + ) + ) + ((cpad-pressed? 1 r1) + (set! *display-scene-control* (logxor *display-scene-control* (scene-controls bounds-spheres))) + (if (logtest? *display-scene-control* (scene-controls bounds-spheres)) + (sound-play-by-spec (static-sound-spec "menu-pick" :fo-curve 1) (new-sound-id) (the-as vector #t)) + (sound-play-by-spec (static-sound-spec "menu-back" :fo-curve 1) (new-sound-id) (the-as vector #t)) + ) + ) + ((cpad-pressed? 1 circle) + (set! *display-bug-report* (not *display-bug-report*)) + (if *display-bug-report* + (sound-play-by-spec (static-sound-spec "menu-pick" :fo-curve 1) (new-sound-id) (the-as vector #t)) + (sound-play-by-spec (static-sound-spec "menu-back" :fo-curve 1) (new-sound-id) (the-as vector #t)) + ) + ) + ) + (none) + ) + ) + ) + (if *display-bug-report* + (position->stream *stdcon* '*stdcon* #t) + ) + (when (and (= *cheat-mode* 'debug) (not *debug-segment*)) + (when (and (cpad-hold? 0 l1) (cpad-hold? 0 l2) (cpad-hold? 0 r1) (cpad-pressed? 0 r2)) + (if *target* + (stop 'debug) + (start 'play (get-current-continue-forced *game-info*)) + ) + ) + (if (and (cpad-hold? 0 left) (cpad-hold? 0 up) (cpad-pressed? 0 select)) + (initialize! *game-info* 'game (the-as game-save #f) "title-restart") + ) + (if (cpad-pressed? 1 r3) + (inspect global) + ) + (when (cpad-hold? 1 r3) + (with-dma-buffer-add-bucket ((s5-1 (if *debug-segment* + (-> *display* frames (-> *display* on-screen) debug-buf) + (-> *display* frames (-> *display* on-screen) global-buf) + ) + ) + (bucket-id debug2) + ) + (show-iop-memory s5-1) + ) + ) + (if (cpad-pressed? 1 triangle) + (set! *display-level-border* (not *display-level-border*)) + ) + ) + (when (demo?) + (let ((gp-2 (scf-get-timeout)) + (v1-93 (scf-get-inactive-timeout)) + ) + (when (and (or (and (nonzero? gp-2) + (>= (+ -300000 (-> *display* real-clock frame-counter)) (the int (* 300.0 (the float gp-2)))) + ) + (and (nonzero? v1-93) + (or (and (>= (- (-> *display* base-clock frame-counter) (-> *cpad-list* cpads 0 change-time)) + (the int (* 300.0 (the float v1-93))) + ) + (>= (- (-> *display* game-clock frame-counter) (the-as int (-> *game-info* kiosk-timeout))) + (the int (* 300.0 (the float v1-93))) + ) + ) + (and (or (= *master-mode* 'pause) (= *master-mode* 'progress) (= *master-mode* 'freeze)) + (>= (- (-> *display* real-clock frame-counter) (-> *game-info* pause-start-time)) + (the int (* 300.0 (the float v1-93))) + ) + ) + ) + ) + (or (= *master-exit* 'force) (= *master-exit* 'movie)) + ) + (or *master-exit* (-> *setting-control* user-current allow-timeout)) + (!= *master-exit* #t) + ) + (cond + ((and (= *kernel-boot-message* 'demo) (not *master-exit*)) + (let ((v1-109 (level-get-target-inside *level*))) + (when (and v1-109 (!= (-> v1-109 name) 'demo) (zero? (logand (-> v1-109 info level-flags) 1))) + (persist-with-delay *setting-control* 'sfx-volume (seconds 0.5) 'sfx-volume 'abs 0.0 0) + (persist-with-delay *setting-control* 'music-volume (seconds 0.5) 'music-volume 'abs 0.0 0) + (persist-with-delay *setting-control* 'dialog-volume (seconds 0.5) 'dialog-volume 'abs 0.0 0) + (persist-with-delay *setting-control* 'ambient-volume (seconds 0.5) 'ambient-volume 'abs 0.0 0) + (set! (-> *setting-control* user-current sfx-volume) 0.01) + (set! (-> *setting-control* user-current music-volume) 0.01) + (set! (-> *setting-control* user-current dialog-volume) 0.01) + (set! (-> *setting-control* user-current ambient-volume) 0.01) + (apply-settings *setting-control*) + (set! (-> *game-info* mode) 'play) + (initialize! *game-info* 'game (the-as game-save #f) "demo-restart") + ) + ) + ) + (else + (when (process-spawn-function + process + (lambda ((arg0 time-frame)) (with-pp + (set-blackout-frames (seconds 100)) + (set! (-> *setting-control* user-default allow-pause) #f) + (set! (-> *setting-control* user-default allow-progress) #f) + (apply-settings *setting-control*) + (set! (-> *setting-control* user-default sfx-volume) 0.0) + (set! (-> *setting-control* user-default music-volume) 0.0) + (set! (-> *setting-control* user-default dialog-volume) 0.0) + (set! (-> *setting-control* user-default ambient-volume) 0.0) + (let ((s5-0 (-> pp clock frame-counter))) + (until (>= (- (-> pp clock frame-counter) s5-0) (seconds 0.1)) + (suspend) + ) + ) + (kernel-shutdown) + (none) + ) + ) + (if (= *master-exit* 'movie) + 2 + 1 + ) + :to *display-pool* + ) + (set! (-> *setting-control* user-default sfx-volume) 0.0) + (set! (-> *setting-control* user-default music-volume) 0.0) + (set! (-> *setting-control* user-default dialog-volume) 0.0) + (set! (-> *setting-control* user-default ambient-volume) 0.0) + (set! *master-exit* #t) + ) + ) + ) + ) + ) + ) + 0 + ) ;; Rough loop outline: ;; (while *run* @@ -503,7 +1449,7 @@ (set! t9-12 (car s5-5)) ) ) - ; (main-cheats) + (main-cheats) ) ;; using the position of the in-game camera, update visiblity and matrices for rendering. @@ -542,29 +1488,29 @@ (load-level-text-files -1) ;; post-processing filter drawing - ; (if (-> *screen-filter* draw?) - ; (draw *screen-filter*) - ; ) + (if (-> *screen-filter* draw?) + (draw *screen-filter*) + ) ;; letterbox drawing - ; (when (or (movie?) (< (-> *display* base-clock frame-counter) (-> *game-info* letterbox-time))) - ; (if (< (-> *game-info* letterbox-time) (-> *display* base-clock frame-counter)) - ; (set! (-> *game-info* letterbox-time) (-> *display* base-clock frame-counter)) - ; ) - ; (if (and (= (-> *setting-control* user-current aspect-ratio) 'aspect4x3) - ; (or (zero? *screen-shot-work*) (= (-> *screen-shot-work* count) -1)) - ; ) - ; (letterbox) - ; ) - ; ) + (when (or (movie?) (< (-> *display* base-clock frame-counter) (-> *game-info* letterbox-time))) + (if (< (-> *game-info* letterbox-time) (-> *display* base-clock frame-counter)) + (set! (-> *game-info* letterbox-time) (-> *display* base-clock frame-counter)) + ) + (if (and (= (-> *setting-control* user-current aspect-ratio) 'aspect4x3) + (or (zero? *screen-shot-work*) (= (-> *screen-shot-work* count) -1)) + ) + (letterbox) + ) + ) ;; blackout drawing - ; (when (-> *setting-control* user-current render) - ; (if (< (-> *display* base-clock frame-counter) (-> *game-info* blackout-time)) - ; (set! (-> *setting-control* user-default bg-a-force) 1.0) - ; (set! (-> *setting-control* user-default bg-a-force) 0.0) - ; ) - ; ) + (when (-> *setting-control* user-current render) + (if (< (-> *display* base-clock frame-counter) (-> *game-info* blackout-time)) + (set! (-> *setting-control* user-default bg-a-force) 1.0) + (set! (-> *setting-control* user-default bg-a-force) 0.0) + ) + ) ;; generate DMA data for doing the main blit ; (blit-displays) @@ -647,7 +1593,7 @@ (swap-sound-buffers (ear-trans 0) (ear-trans 1) (camera-pos) (camera-angle)) ;; advance streaming animation - ; (str-play-kick) + (str-play-kick) ;; handle spawning/despawning as needed. (level-update *level*) diff --git a/goal_src/jak2/engine/gfx/background/prototype-h.gc b/goal_src/jak2/engine/gfx/background/prototype-h.gc index 0069abfeca..e0005caf2e 100644 --- a/goal_src/jak2/engine/gfx/background/prototype-h.gc +++ b/goal_src/jak2/engine/gfx/background/prototype-h.gc @@ -11,15 +11,16 @@ (defenum prototype-flags :bitfield #t :type uint16 - (disable 0) - ;; (use-envmap 1) maybe + (disable 0) ;; set from debug menu, for debugging + ;; 1 is envmap related? (tpage-alpha 2) (vanish 3) + (visible 5) ;; set by prototypes-game-visible-set! to hide things on purpose (no-collide 6) (tpage-water 7) - ) + (defenum instance-flags :type uint16 :bitfield #t diff --git a/goal_src/jak2/engine/gfx/foreground/foreground-h.gc b/goal_src/jak2/engine/gfx/foreground/foreground-h.gc index cd27c68ec2..adb3653c16 100644 --- a/goal_src/jak2/engine/gfx/foreground/foreground-h.gc +++ b/goal_src/jak2/engine/gfx/foreground/foreground-h.gc @@ -7,6 +7,7 @@ (define-extern *foreground-draw-engine* engine) (define-extern vu-lights<-light-group! (function vu-lights light-group none)) +(define-extern foreground-draw-hud (function draw-control dma-buffer float none)) ;; DECOMP BEGINS diff --git a/goal_src/jak2/engine/gfx/foreground/shadow-cpu-h.gc b/goal_src/jak2/engine/gfx/foreground/shadow-cpu-h.gc index 274fc005c9..a394846c06 100644 --- a/goal_src/jak2/engine/gfx/foreground/shadow-cpu-h.gc +++ b/goal_src/jak2/engine/gfx/foreground/shadow-cpu-h.gc @@ -108,7 +108,7 @@ ((first uint32 :offset-assert 0) (next uint32 :offset-assert 4) (bucket-id int32 :offset-assert 8) - (shadow-color uint32 :offset-assert 12) + (shadow-color rgba :offset-assert 12) (constants basic :offset-assert 16) ) :allow-misaligned diff --git a/goal_src/jak2/kernel-defs.gc b/goal_src/jak2/kernel-defs.gc index 860afcaa99..4cc318558c 100644 --- a/goal_src/jak2/kernel-defs.gc +++ b/goal_src/jak2/kernel-defs.gc @@ -118,6 +118,9 @@ (define-extern scf-get-volume "Defined in the kernel" (function int)) (define-extern scf-get-language "Defined in the kernel" (function language-enum)) (define-extern scf-get-aspect "Defined in the kernel" (function uint)) +(define-extern scf-get-timeout (function int)) +(define-extern scf-get-inactive-timeout (function int)) +(define-extern kernel-shutdown (function none)) (define-extern *boot-video-mode* "Defined in the kernel" int) (define-extern *kernel-boot-message* symbol) diff --git a/test/decompiler/reference/jak2/engine/collide/collide-cache_REF.gc b/test/decompiler/reference/jak2/engine/collide/collide-cache_REF.gc new file mode 100644 index 0000000000..5772f39e8a --- /dev/null +++ b/test/decompiler/reference/jak2/engine/collide/collide-cache_REF.gc @@ -0,0 +1,1025 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition for method 15 of type collide-cache +;; WARN: Return type mismatch int vs none. +(defmethod reset collide-cache ((obj collide-cache)) + (set! (-> obj num-tris) 0) + (set! (-> obj num-prims) 0) + (set! (-> obj ignore-processes 0) #f) + (set! (-> obj ignore-processes 1) #f) + (set! *already-printed-exeeded-max-cache-tris* #f) + 0 + (none) + ) + +;; definition for method 18 of type collide-cache +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs none. +(defmethod fill-from-bg collide-cache ((obj collide-cache) + (arg0 (function collide-hash int collide-list collide-query int)) + (arg1 (function collide-cache collide-list collide-query none)) + (arg2 collide-query) + ) + (set! *already-printed-exeeded-max-cache-tris* #f) + (set! (-> *collide-list* num-items) 0) + (if *collide-list-boxes* + (add-debug-box + #t + (bucket-id debug2) + (the-as vector (-> arg2 bbox)) + (-> arg2 bbox max) + (new 'static 'rgba :g #xff :b #xff :a #x80) + ) + ) + (dotimes (s2-0 (-> *level* length)) + (let ((v1-7 (-> *level* level s2-0))) + (if (= (-> v1-7 status) 'active) + (arg0 (-> v1-7 bsp collide-hash) 0 *collide-list* arg2) + ) + ) + ) + (when (> (-> *collide-list* num-items) 0) + (arg1 *collide-cache* *collide-list* arg2) + (let ((a0-8 (-> obj num-tris))) + (when (> a0-8 0) + (let ((v1-16 (-> obj prims)) + (a1-6 *collide-shape-prim-backgnd*) + ) + (set! (-> v1-16 0 num-tris) (the-as uint a0-8)) + (set! (-> v1-16 0 prim) a1-6) + (set! (-> obj num-prims) 1) + (set! (-> v1-16 0 first-tri) (the-as uint 0)) + (set! (-> v1-16 0 ccache) obj) + (set! (-> v1-16 0 prim-core world-sphere quad) (-> a1-6 prim-core world-sphere quad)) + (set! (-> v1-16 0 prim-core quad 1) (-> a1-6 prim-core quad 1)) + ) + ) + ) + ) + 0 + (none) + ) + +;; definition for method 21 of type collide-cache +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs none. +;; WARN: Function (method 21 collide-cache) has a return type of none, but the expression builder found a return statement. +(defmethod fill-from-water collide-cache ((obj collide-cache) (arg0 water-control)) + (rlet ((vf0 :class vf) + (vf1 :class vf) + (vf2 :class vf) + (vf3 :class vf) + (vf4 :class vf) + (vf5 :class vf) + ) + (init-vf0-vector) + (when (= (-> obj num-prims) 100) + (if (= *cheat-mode* 'debug) + (format 0 "ERROR: Exceeded max number of collide-cache prims!~%") + ) + (return #f) + ) + (when (< 460 (+ (-> obj num-tris) 2)) + (if (= *cheat-mode* 'debug) + (print-exceeded-max-cache-tris) + ) + (return #f) + ) + (if (not (and (logtest? (-> arg0 flags) (water-flags active)) + (logtest? (-> arg0 flags) (water-flags can-ground)) + (logtest? (-> arg0 flags) (water-flags swim-ground under-water)) + (logtest? (water-flags over-water) (-> arg0 flags)) + (zero? (logand (water-flags jump-out) (-> arg0 flags))) + ) + ) + (return #f) + ) + (let ((v1-24 (-> arg0 collide-height))) + (.lvf vf1 (&-> obj collide-box min quad)) + (.lvf vf3 (&-> obj collide-box max quad)) + (let ((a2-6 (-> obj num-prims-u32)) + (a3-4 (the-as (inline-array collide-cache-tri) (-> obj tris (-> obj num-tris)))) + ) + (.mov vf5 v1-24) + (.add.x.vf vf1 vf0 vf5 :mask #b10) + (set! (-> a3-4 0 clear-flags) (the-as uint128 0)) + (set! (-> a3-4 0 prim-index) a2-6) + (.add.x.vf vf3 vf0 vf5 :mask #b10) + (set! (-> a3-4 1 clear-flags) (the-as uint128 0)) + (set! (-> a3-4 1 prim-index) a2-6) + (.mov.vf vf2 vf1) + (.mov.vf vf4 vf1) + (.add.z.vf vf2 vf0 vf3 :mask #b100) + (.add.x.vf vf4 vf0 vf3 :mask #b1) + (.svf (&-> a3-4 0 vertex 0 quad) vf1) + (.svf (&-> a3-4 0 vertex 1 quad) vf2) + (.svf (&-> a3-4 0 vertex 2 quad) vf3) + (set! (-> a3-4 0 pat) (new 'static 'pat-surface :material (pat-material waterbottom))) + (set! (-> a3-4 0 collide-ptr) arg0) + (.svf (&-> a3-4 1 vertex 0 quad) vf1) + (.svf (&-> a3-4 1 vertex 1 quad) vf3) + (.svf (&-> a3-4 1 vertex 2 quad) vf4) + (set! (-> a3-4 1 pat) (new 'static 'pat-surface :material (pat-material waterbottom))) + (set! (-> a3-4 1 collide-ptr) arg0) + ) + ) + (let ((v1-27 *collide-shape-prim-water*) + (a1-5 (-> obj prims (-> obj num-prims))) + ) + (set! (-> a1-5 first-tri) (the-as uint (-> obj num-tris))) + (set! (-> a1-5 num-tris) (the-as uint 2)) + (set! (-> a1-5 prim) v1-27) + (set! (-> a1-5 ccache) obj) + (set! (-> a1-5 prim-core world-sphere quad) (-> v1-27 prim-core world-sphere quad)) + (set! (-> a1-5 prim-core quad 1) (-> v1-27 prim-core quad 1)) + ) + (+! (-> obj num-prims) 1) + (+! (-> obj num-tris) 2) + 0 + (none) + ) + ) + +;; definition for method 12 of type collide-cache +;; WARN: Return type mismatch int vs none. +(defmethod fill-using-bounding-box collide-cache ((obj collide-cache) (arg0 collide-query)) + (rlet ((vf0 :class vf) + (vf1 :class vf) + (vf2 :class vf) + (vf3 :class vf) + (vf4 :class vf) + ) + (init-vf0-vector) + (+! (-> *collide-stats* calls) 1) + (new 'static 'vector :x 0.5) + (nop!) + (nop!) + (let ((v1-4 (-> arg0 collide-with-s32))) + (nop!) + (let ((a0-2 (-> arg0 ignore-process0))) + (nop!) + (let ((a1-1 (-> arg0 ignore-process1))) + (nop!) + (let ((a2-0 (-> arg0 ignore-pat-s32))) + (nop!) + (.lvf vf1 (&-> arg0 bbox min quad)) + (nop!) + (.lvf vf2 (&-> arg0 bbox max quad)) + (nop!) + (set! (-> obj ignore-processes 0) (the-as process a0-2)) + (nop!) + (set! (-> obj ignore-processes 1) (the-as process a1-1)) + (.mov.vf vf1 vf0 :mask #b1000) + (nop!) + (.mov.vf vf2 vf0 :mask #b1000) + (set! (-> obj ignore-mask) (the-as pat-surface a2-0)) + ) + ) + ) + (.ftoi.vf vf3 vf1) + (nop!) + (.ftoi.vf vf4 vf2) + (set! (-> obj num-tris) 0) + (nop!) + (.svf (&-> obj collide-box min quad) vf1) + (nop!) + (.svf (&-> obj collide-box max quad) vf2) + (nop!) + (.svf (&-> obj collide-box4w min quad) vf3) + (nop!) + (.svf (&-> obj collide-box4w max quad) vf4) + (nop!) + (.svf (&-> arg0 bbox4w min quad) vf3) + (nop!) + (.svf (&-> arg0 bbox4w max quad) vf4) + (nop!) + (set! (-> obj num-prims) 0) + (nop!) + (set! (-> obj collide-with) (the-as collide-spec v1-4)) + ) + 0 + (when (logtest? (-> arg0 collide-with) (collide-spec backgnd)) + (fill-from-bg + obj + (method-of-type collide-hash fill-collide-list-from-box) + collide-list-fill-bg-using-box + arg0 + ) + (+! (-> *collide-stats* output) (-> obj num-tris)) + ) + (when (logtest? (-> arg0 collide-with) (collide-spec water)) + (let ((v1-18 (-> arg0 ignore-process0))) + (if v1-18 + (fill-from-water obj (-> (the-as process-drawable v1-18) water)) + ) + ) + ) + (if (logtest? (-> arg0 collide-with) (collide-spec hit-by-player-list hit-by-others-list player-list)) + (fill-from-fg-boxes obj) + ) + 0 + (none) + ) + ) + +;; definition for method 13 of type collide-cache +;; WARN: Return type mismatch int vs none. +(defmethod fill-using-line-sphere collide-cache ((obj collide-cache) (arg0 collide-query)) + (local-vars (v1-11 float) (v1-20 float)) + (rlet ((acc :class vf) + (Q :class vf) + (vf0 :class vf) + (vf1 :class vf) + (vf10 :class vf) + (vf11 :class vf) + (vf12 :class vf) + (vf13 :class vf) + (vf14 :class vf) + (vf15 :class vf) + (vf16 :class vf) + (vf17 :class vf) + (vf18 :class vf) + (vf19 :class vf) + (vf2 :class vf) + (vf20 :class vf) + (vf22 :class vf) + (vf23 :class vf) + (vf3 :class vf) + (vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + (vf7 :class vf) + (vf8 :class vf) + (vf9 :class vf) + ) + (init-vf0-vector) + (+! (-> *collide-stats* calls) 1) + (let ((v1-3 0)) + (if (< (fabs (-> arg0 move-dist x)) 4096.0) + (+! v1-3 1) + ) + (if (< (fabs (-> arg0 move-dist y)) 4096.0) + (+! v1-3 1) + ) + (if (< (fabs (-> arg0 move-dist z)) 4096.0) + (+! v1-3 1) + ) + (when (< 1 v1-3) + (set-from-point-offset-pad! (-> arg0 bbox) (-> arg0 start-pos) (-> arg0 move-dist) (-> arg0 radius)) + (fill-using-bounding-box obj arg0) + (b! #t cfg-47 :delay (nop!)) + (the-as none 0) + (nop!) + ) + ) + (nop!) + (let ((v1-10 (-> arg0 ignore-pat-s32))) + (nop!) + (let ((a0-14 (-> arg0 ignore-process0))) + (nop!) + (let ((a1-3 (-> arg0 ignore-process1))) + (nop!) + (let ((a2-1 (-> arg0 collide-with-s32))) + (nop!) + (.lvf vf9 (&-> arg0 exit-planes 0 quad)) + (nop!) + (.lvf vf3 (&-> arg0 move-dist quad)) + (nop!) + (.mov.vf vf13 vf0) + (nop!) + (.lvf vf1 (&-> arg0 start-pos quad)) + (.mul.vf vf8 vf3 vf3) + (nop!) + (.add.vf vf2 vf1 vf3) + (set! (-> obj ignore-mask) (the-as pat-surface v1-10)) + (.add.y.vf vf8 vf8 vf8 :mask #b1) + (set! (-> obj num-tris) 0) + (.min.vf vf4 vf1 vf2) + (set! (-> obj num-prims) 0) + (.max.vf vf5 vf1 vf2) + (set! (-> obj collide-with) (the-as collide-spec a2-1)) + ) + (.sub.w.vf vf10 vf0 vf9 :mask #b111) + (set! (-> obj ignore-processes 0) (the-as process a0-14)) + (.add.z.vf vf8 vf8 vf8 :mask #b1) + (set! (-> obj ignore-processes 1) (the-as process a1-3)) + ) + ) + ) + (.sub.w.vf vf4 vf4 vf9 :mask #b111) + (nop!) + (.add.w.vf vf5 vf5 vf9 :mask #b111) + (nop!) + (.ftoi.vf vf15 vf10) + (nop!) + (.isqrt.vf Q vf0 vf8 :fsf #b11 :ftf #b0) + (nop!) + (.add.w.vf vf11 vf0 vf9 :mask #b111) + (nop!) + (nop!) + (nop!) + (nop!) + (.svf (&-> arg0 local-box4w min quad) vf15) + (.ftoi.vf vf6 vf4) + (.svf (&-> obj collide-box min quad) vf4) + (.ftoi.vf vf7 vf5) + (.svf (&-> obj collide-box max quad) vf5) + (nop!) + (.svf (&-> arg0 bbox min quad) vf4) + (nop!) + (.svf (&-> arg0 bbox max quad) vf5) + (nop!) + (.svf (&-> obj collide-box4w min quad) vf6) + (nop!) + (.svf (&-> obj collide-box4w max quad) vf7) + (nop!) + (.svf (&-> arg0 bbox4w min quad) vf6) + (nop!) + (.svf (&-> arg0 bbox4w max quad) vf7) + (.wait.vf) + (nop!) + (.add.vf vf8 vf0 Q :mask #b1) + (nop!) + (.mul.x.vf vf12 vf3 vf8) + (nop!) + (.nop.vf) + (nop!) + (.div.vf Q vf0 vf8 :fsf #b11 :ftf #b0) + (nop!) + (.mul.vf vf22 vf12 vf12) + (nop!) + (.abs.vf vf23 vf12) + (nop!) + (.add.y.vf vf22 vf22 vf22 :mask #b1) + (.mov v1-11 vf23) + (.wait.vf) + (nop!) + (.add.vf vf8 vf0 Q :mask #b1) + (nop!) + (b! (zero? v1-11) cfg-12 :likely-delay (.add.z.vf vf13 vf0 vf12 :mask #b1)) + (.sub.y.vf vf13 vf0 vf12 :mask #b1) + (nop!) + (.isqrt.vf Q vf0 vf22 :fsf #b11 :ftf #b0) + (nop!) + (.add.x.vf vf13 vf0 vf12 :mask #b10) + (nop!) + (.wait.vf) + (nop!) + (.mul.vf vf13 vf13 Q :mask #b11) + (nop!) + (label cfg-12) + (.outer.product.a.vf acc vf12 vf13) + (nop!) + (.add.x.vf vf11 vf11 vf8 :mask #b1) + (nop!) + (.outer.product.b.vf vf14 vf13 vf12 acc) + (nop!) + (.ftoi.vf vf16 vf11) + (nop!) + (.mov.vf vf17 vf12) + (nop!) + (.mov.vf vf18 vf13) + (nop!) + (.mov.vf vf19 vf14) + (nop!) + (.mov.vf vf17 vf0 :mask #b1110) + (.svf (&-> arg0 local-box4w max quad) vf16) + (.mov.vf vf18 vf0 :mask #b1101) + (nop!) + (.mov.vf vf19 vf0 :mask #b1011) + (nop!) + (.add.x.vf vf17 vf17 vf13 :mask #b10) + (nop!) + (.add.y.vf vf18 vf18 vf12 :mask #b1) + (nop!) + (.add.z.vf vf19 vf19 vf12 :mask #b1) + (nop!) + (.add.x.vf vf17 vf17 vf14 :mask #b100) + (nop!) + (.add.y.vf vf18 vf18 vf14 :mask #b100) + (nop!) + (.add.z.vf vf19 vf19 vf13 :mask #b10) + (nop!) + (.mul.x.vf acc vf17 vf1) + (nop!) + (.add.mul.y.vf acc vf18 vf1 acc) + (.svf (&-> arg0 inv-mat quad 0) vf17) + (.add.mul.z.vf vf20 vf19 vf1 acc) + (.svf (&-> arg0 inv-mat quad 1) vf18) + (.sub.vf vf20 vf0 vf20) + (.svf (&-> arg0 inv-mat quad 2) vf19) + (nop!) + (.svf (&-> arg0 inv-mat trans quad) vf20) + (set! (-> arg0 rlength x) (if (= (-> arg0 move-dist x) 0.0) + 0.0 + (/ 1.0 (-> arg0 move-dist x)) + ) + ) + (set! (-> arg0 rlength y) (if (= (-> arg0 move-dist y) 0.0) + 0.0 + (/ 1.0 (-> arg0 move-dist y)) + ) + ) + (set! (-> arg0 rlength z) (if (= (-> arg0 move-dist z) 0.0) + 0.0 + (/ 1.0 (-> arg0 move-dist z)) + ) + ) + (let ((f0-19 1.0)) + (.lvf vf1 (&-> (-> arg0 move-dist) quad)) + (.add.w.vf vf2 vf0 vf0 :mask #b1) + (.mul.vf vf1 vf1 vf1) + (.mul.x.vf acc vf2 vf1 :mask #b1) + (.add.mul.y.vf acc vf2 vf1 acc :mask #b1) + (.add.mul.z.vf vf1 vf2 vf1 acc :mask #b1) + (.mov v1-20 vf1) + (set! (-> arg0 rlength w) (/ f0-19 v1-20)) + ) + (set! (-> arg0 exit-planes 0 x) (if (< 0.0 (-> arg0 move-dist x)) + 0.0 + 100000000000000000000000000000000000000.0 + ) + ) + (set! (-> arg0 exit-planes 0 y) (if (< 0.0 (-> arg0 move-dist y)) + 0.0 + 100000000000000000000000000000000000000.0 + ) + ) + (set! (-> arg0 exit-planes 0 z) (if (< 0.0 (-> arg0 move-dist z)) + 0.0 + 100000000000000000000000000000000000000.0 + ) + ) + (set! (-> arg0 exit-planes 1 x) (if (< (-> arg0 move-dist x) 0.0) + 0.0 + 100000000000000000000000000000000000000.0 + ) + ) + (set! (-> arg0 exit-planes 1 y) (if (< (-> arg0 move-dist y) 0.0) + 0.0 + 100000000000000000000000000000000000000.0 + ) + ) + (set! (-> arg0 exit-planes 1 z) (if (< (-> arg0 move-dist z) 0.0) + 0.0 + 100000000000000000000000000000000000000.0 + ) + ) + (when (logtest? (-> arg0 collide-with) (collide-spec backgnd)) + (fill-from-bg + obj + (method-of-type collide-hash fill-collide-list-from-line-sphere) + collide-list-fill-bg-using-line-sphere + arg0 + ) + (+! (-> *collide-stats* output) (-> obj num-tris)) + ) + (when (logtest? (-> arg0 collide-with) (collide-spec water)) + (let ((a1-5 (-> (the-as process-drawable (-> arg0 ignore-process0)) water))) + (if (nonzero? a1-5) + (fill-from-water obj a1-5) + ) + ) + ) + (if (logtest? (-> arg0 collide-with) (collide-spec hit-by-player-list hit-by-others-list player-list)) + (fill-from-fg-line-sphere obj arg0) + ) + 0 + (label cfg-47) + (none) + ) + ) + +;; definition for method 19 of type collide-cache +;; WARN: Return type mismatch int vs none. +(defmethod fill-from-fg-boxes collide-cache ((obj collide-cache)) + (let ((s5-0 (-> obj collide-with))) + (set! *actor-list-length* 0) + (if (logtest? s5-0 (collide-spec hit-by-others-list)) + (set! *actor-list-length* (fill-actor-list-for-box *actor-hash* (-> obj collide-box) *actor-list* 256)) + ) + (when (logtest? s5-0 (collide-spec player-list)) + (let ((a0-2 (-> *collide-player-list* alive-list next0))) + *collide-player-list* + (let ((v1-13 (-> a0-2 next0))) + (while (!= a0-2 (-> *collide-player-list* alive-list-end)) + (let* ((a0-3 (-> (the-as connection a0-2) param1)) + (a1-1 (-> (the-as collide-shape a0-3) root-prim)) + ) + (when (logtest? s5-0 (-> a1-1 prim-core collide-as)) + (let ((a1-2 (-> a1-1 prim-core))) + (when (and (>= (+ (-> a1-2 world-sphere x) (-> a1-2 world-sphere w)) (-> obj collide-box min x)) + (>= (-> obj collide-box max x) (- (-> a1-2 world-sphere x) (-> a1-2 world-sphere w))) + (>= (+ (-> a1-2 world-sphere y) (-> a1-2 world-sphere w)) (-> obj collide-box min y)) + (>= (-> obj collide-box max y) (- (-> a1-2 world-sphere y) (-> a1-2 world-sphere w))) + (>= (+ (-> a1-2 world-sphere z) (-> a1-2 world-sphere w)) (-> obj collide-box min z)) + (>= (-> obj collide-box max z) (- (-> a1-2 world-sphere z) (-> a1-2 world-sphere w))) + ) + (when (< *actor-list-length* 256) + (set! (-> *actor-list* *actor-list-length*) (the-as collide-shape a0-3)) + (set! *actor-list-length* (+ *actor-list-length* 1)) + ) + ) + ) + ) + ) + (set! a0-2 v1-13) + *collide-player-list* + (set! v1-13 (-> v1-13 next0)) + ) + ) + ) + ) + (when (logtest? s5-0 (collide-spec hit-by-player-list)) + (let ((a0-5 (-> *collide-hit-by-player-list* alive-list next0))) + *collide-hit-by-player-list* + (let ((v1-21 (-> a0-5 next0))) + (while (!= a0-5 (-> *collide-hit-by-player-list* alive-list-end)) + (let* ((a0-6 (-> (the-as connection a0-5) param1)) + (a1-13 (-> (the-as collide-shape a0-6) root-prim)) + ) + (when (logtest? s5-0 (-> a1-13 prim-core collide-as)) + (let ((a1-14 (-> a1-13 prim-core))) + (when (and (>= (+ (-> a1-14 world-sphere x) (-> a1-14 world-sphere w)) (-> obj collide-box min x)) + (>= (-> obj collide-box max x) (- (-> a1-14 world-sphere x) (-> a1-14 world-sphere w))) + (>= (+ (-> a1-14 world-sphere y) (-> a1-14 world-sphere w)) (-> obj collide-box min y)) + (>= (-> obj collide-box max y) (- (-> a1-14 world-sphere y) (-> a1-14 world-sphere w))) + (>= (+ (-> a1-14 world-sphere z) (-> a1-14 world-sphere w)) (-> obj collide-box min z)) + (>= (-> obj collide-box max z) (- (-> a1-14 world-sphere z) (-> a1-14 world-sphere w))) + ) + (when (< *actor-list-length* 256) + (set! (-> *actor-list* *actor-list-length*) (the-as collide-shape a0-6)) + (set! *actor-list-length* (+ *actor-list-length* 1)) + ) + ) + ) + ) + ) + (set! a0-5 v1-21) + *collide-hit-by-player-list* + (set! v1-21 (-> v1-21 next0)) + ) + ) + ) + ) + (dotimes (s4-0 *actor-list-length*) + (let ((v1-26 (-> *actor-list* s4-0))) + (when (logtest? s5-0 (-> v1-26 root-prim prim-core collide-as)) + (let ((a0-13 (-> v1-26 process))) + (if (not (or (= a0-13 (-> obj ignore-processes 0)) (= a0-13 (-> obj ignore-processes 1)))) + (add-fg-prim-using-box (-> v1-26 root-prim) obj) + ) + ) + ) + ) + ) + ) + 0 + (none) + ) + +;; definition for method 10 of type collide-shape-prim +;; WARN: Return type mismatch object vs none. +(defmethod add-fg-prim-using-box collide-shape-prim ((obj collide-shape-prim) (arg0 collide-cache)) + (format 0 "ERROR: Illegal collide-shape-prim type passed to collide-shape-prim::add-fg-prim-using-box!~%") + (none) + ) + +;; definition for method 10 of type collide-shape-prim-mesh +;; INFO: function output is handled by mips2c +(defmethod-mips2c "(method 10 collide-shape-prim-mesh)" 10 collide-shape-prim-mesh) + +;; definition for method 10 of type collide-shape-prim-sphere +;; INFO: function output is handled by mips2c +(defmethod-mips2c "(method 10 collide-shape-prim-sphere)" 10 collide-shape-prim-sphere) + +;; definition for method 10 of type collide-shape-prim-group +;; INFO: function output is handled by mips2c +(defmethod-mips2c "(method 10 collide-shape-prim-group)" 10 collide-shape-prim-group) + +;; definition for method 20 of type collide-cache +;; WARN: Return type mismatch int vs none. +(defmethod fill-from-fg-line-sphere collide-cache ((obj collide-cache) (arg0 collide-query)) + (local-vars (v1-9 float)) + (rlet ((acc :class vf) + (vf0 :class vf) + (vf1 :class vf) + (vf2 :class vf) + ) + (init-vf0-vector) + (let ((s4-0 (-> arg0 collide-with))) + (set! *actor-list-length* 0) + (if (logtest? s4-0 (collide-spec hit-by-others-list)) + (set! *actor-list-length* (fill-actor-list-for-line-sphere + *actor-hash* + (-> arg0 start-pos) + (-> arg0 move-dist) + (-> arg0 radius) + *actor-list* + 256 + -1 + ) + ) + ) + (let ((f30-0 0.0) + (s3-0 (new 'stack-no-clear 'matrix)) + ) + (.lvf vf1 (&-> (-> arg0 move-dist) quad)) + (.add.w.vf vf2 vf0 vf0 :mask #b1) + (.mul.vf vf1 vf1 vf1) + (.mul.x.vf acc vf2 vf1 :mask #b1) + (.add.mul.y.vf acc vf2 vf1 acc :mask #b1) + (.add.mul.z.vf vf1 vf2 vf1 acc :mask #b1) + (.mov v1-9 vf1) + (let ((f0-1 v1-9)) + (if (< 0.0 f0-1) + (set! f30-0 (/ 1.0 f0-1)) + ) + ) + (when (logtest? s4-0 (collide-spec player-list)) + (let ((v1-17 (-> *collide-player-list* alive-list next0))) + *collide-player-list* + (let ((s2-0 (-> v1-17 next0))) + (while (!= v1-17 (-> *collide-player-list* alive-list-end)) + (let* ((s1-0 (-> (the-as connection v1-17) param1)) + (v1-18 (-> (the-as collide-shape s1-0) root-prim)) + ) + (when (logtest? s4-0 (-> v1-18 prim-core collide-as)) + (let ((s0-0 (-> v1-18 prim-core))) + (vector-! (-> s3-0 vector 1) (the-as vector s0-0) (-> arg0 start-pos)) + (let* ((f1-2 (* (vector-dot (-> arg0 move-dist) (-> s3-0 vector 1)) f30-0)) + (f0-6 (fmax 0.0 (fmin 1.0 f1-2))) + ) + (vector+float*! (the-as vector (-> s3-0 vector)) (-> arg0 start-pos) (-> arg0 move-dist) f0-6) + ) + (let ((f0-7 (vector-vector-distance-squared (the-as vector (-> s3-0 vector)) (the-as vector s0-0))) + (f1-5 (+ (-> arg0 radius) (-> s0-0 world-sphere w))) + ) + (when (< f0-7 (* f1-5 f1-5)) + (when (< *actor-list-length* 256) + (set! (-> *actor-list* *actor-list-length*) (the-as collide-shape s1-0)) + (set! *actor-list-length* (+ *actor-list-length* 1)) + ) + ) + ) + ) + ) + ) + (set! v1-17 s2-0) + *collide-player-list* + (set! s2-0 (-> s2-0 next0)) + ) + ) + ) + ) + (when (logtest? s4-0 (collide-spec hit-by-player-list)) + (let ((v1-38 (-> *collide-hit-by-player-list* alive-list next0))) + *collide-hit-by-player-list* + (let ((s2-1 (-> v1-38 next0))) + (while (!= v1-38 (-> *collide-hit-by-player-list* alive-list-end)) + (let* ((s1-1 (-> (the-as connection v1-38) param1)) + (v1-39 (-> (the-as collide-shape s1-1) root-prim)) + ) + (when (logtest? s4-0 (-> v1-39 prim-core collide-as)) + (let ((s0-1 (-> v1-39 prim-core))) + (vector-! (-> s3-0 vector 1) (the-as vector s0-1) (-> arg0 start-pos)) + (let* ((f1-8 (* (vector-dot (-> arg0 move-dist) (-> s3-0 vector 1)) f30-0)) + (f0-11 (fmax 0.0 (fmin 1.0 f1-8))) + ) + (vector+float*! (the-as vector (-> s3-0 vector)) (-> arg0 start-pos) (-> arg0 move-dist) f0-11) + ) + (let ((f0-12 (vector-vector-distance-squared (the-as vector (-> s3-0 vector)) (the-as vector s0-1))) + (f1-11 (+ (-> arg0 radius) (-> s0-1 world-sphere w))) + ) + (when (< f0-12 (* f1-11 f1-11)) + (when (< *actor-list-length* 256) + (set! (-> *actor-list* *actor-list-length*) (the-as collide-shape s1-1)) + (set! *actor-list-length* (+ *actor-list-length* 1)) + ) + ) + ) + ) + ) + ) + (set! v1-38 s2-1) + *collide-hit-by-player-list* + (set! s2-1 (-> s2-1 next0)) + ) + ) + ) + ) + ) + (dotimes (s3-1 *actor-list-length*) + (let ((v1-58 (-> *actor-list* s3-1))) + (when (logtest? s4-0 (-> v1-58 root-prim prim-core collide-as)) + (let ((a0-37 (-> v1-58 process))) + (if (not (or (= a0-37 (-> obj ignore-processes 0)) (= a0-37 (-> obj ignore-processes 1)))) + (add-fg-prim-using-line-sphere (-> v1-58 root-prim) obj arg0) + ) + ) + ) + ) + ) + ) + 0 + (none) + ) + ) + +;; definition for method 11 of type collide-shape-prim +;; WARN: Return type mismatch object vs none. +(defmethod add-fg-prim-using-line-sphere collide-shape-prim ((obj collide-shape-prim) (arg0 collide-cache) (arg1 object)) + (format + 0 + "ERROR: Illegal collide-shape-prim type passed to collide-shape-prim::add-fg-prim-using-line-sphere!~%" + ) + (none) + ) + +;; definition for method 11 of type collide-shape-prim-mesh +;; INFO: function output is handled by mips2c +(defmethod-mips2c "(method 11 collide-shape-prim-mesh)" 11 collide-shape-prim-mesh) + +;; definition for method 11 of type collide-shape-prim-sphere +;; INFO: function output is handled by mips2c +(defmethod-mips2c "(method 11 collide-shape-prim-sphere)" 11 collide-shape-prim-sphere) + +;; definition for method 11 of type collide-shape-prim-group +;; INFO: function output is handled by mips2c +(defmethod-mips2c "(method 11 collide-shape-prim-group)" 11 collide-shape-prim-group) + +;; definition for method 10 of type collide-cache +(defmethod fill-and-probe-using-line-sphere collide-cache ((obj collide-cache) (arg0 collide-query)) + (fill-using-line-sphere obj arg0) + (probe-using-line-sphere obj arg0) + ) + +;; definition of type collide-puls-work +(deftype collide-puls-work (structure) + ((ignore-pat pat-surface :offset-assert 0) + (bsphere sphere :inline :offset-assert 16) + (move-dist vector :inline :offset-assert 32) + ) + :method-count-assert 9 + :size-assert #x30 + :flag-assert #x900000030 + ) + +;; definition for method 3 of type collide-puls-work +(defmethod inspect collide-puls-work ((obj collide-puls-work)) + (when (not obj) + (set! obj obj) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" obj 'collide-puls-work) + (format #t "~1Tignore-pat: ~D~%" (-> obj ignore-pat)) + (format #t "~1Tbsphere: #~%" (-> obj bsphere)) + (format #t "~1Tmove-dist: #~%" (-> obj move-dist)) + (label cfg-4) + obj + ) + +;; definition for method 16 of type collide-cache +(defmethod probe-using-line-sphere collide-cache ((obj collide-cache) (arg0 collide-query)) + (rlet ((vf0 :class vf) + (vf2 :class vf) + (vf3 :class vf) + (vf4 :class vf) + ) + (init-vf0-vector) + (let ((s5-0 (new 'stack-no-clear 'collide-cache-tri))) + (.lvf vf4 (&-> arg0 exit-planes 0 quad)) + (.lvf vf3 (&-> arg0 start-pos quad)) + (.lvf vf2 (&-> arg0 move-dist quad)) + (set! (-> s5-0 vertex 0 x) (the-as float (-> arg0 ignore-pat))) + (.mul.w.vf vf3 vf0 vf4 :mask #b1000) + (.svf (&-> s5-0 vertex 2 quad) vf2) + (.svf (&-> s5-0 vertex 1 quad) vf3) + (let ((s4-0 (the-as object (-> obj prims))) + (f30-0 -100000000.0) + ) + (countdown (s3-0 (-> obj num-prims)) + (when (and (logtest? (-> arg0 collide-with) (-> (the-as collide-cache-prim s4-0) prim-core collide-as)) + (logtest? (-> arg0 action-mask) (-> (the-as collide-cache-prim s4-0) prim-core action)) + ) + (cond + ((>= (the-as int (-> (the-as collide-cache-prim s4-0) prim-core prim-type)) 0) + (let ((f0-0 ((method-of-type collide-cache-prim resolve-moving-sphere-tri) + (the-as collide-cache-prim s4-0) + (the-as collide-tri-result arg0) + (the-as collide-prim-core (-> s5-0 vertex 1)) + (-> s5-0 vertex 2) + f30-0 + (collide-action solid) + ) + ) + ) + (if (>= f0-0 0.0) + (set! f30-0 f0-0) + ) + ) + ) + (else + (when (not (logtest? (-> arg0 ignore-pat) + (-> (the-as collide-shape-prim-sphere (-> (the-as collide-cache-prim s4-0) prim)) pat) + ) + ) + (let ((f0-1 ((method-of-type collide-cache-prim resolve-moving-sphere-sphere) + (the-as collide-cache-prim s4-0) + (the-as collide-tri-result arg0) + (the-as collide-prim-core (-> s5-0 vertex 1)) + (-> s5-0 vertex 2) + f30-0 + (collide-action solid) + ) + ) + ) + (if (>= f0-1 0.0) + (set! f30-0 f0-1) + ) + ) + ) + ) + ) + ) + (set! s4-0 (-> (the-as (inline-array collide-cache-prim) s4-0) 1)) + ) + f30-0 + ) + ) + ) + ) + +;; definition of type lsmi-work +(deftype lsmi-work (structure) + ((best-u float :offset-assert 0) + (orig-best-u float :offset-assert 4) + (action uint32 :offset-assert 8) + (cquery collide-query :inline :offset-assert 16) + ) + :method-count-assert 9 + :size-assert #x22c + :flag-assert #x90000022c + ) + +;; definition for method 3 of type lsmi-work +(defmethod inspect lsmi-work ((obj lsmi-work)) + (when (not obj) + (set! obj obj) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" obj 'lsmi-work) + (format #t "~1Tbest-u: ~f~%" (-> obj best-u)) + (format #t "~1Torig-best-u: ~f~%" (-> obj orig-best-u)) + (format #t "~1Taction: ~D~%" (-> obj action)) + (format #t "~1Tcquery: #~%" (-> obj cquery)) + (label cfg-4) + obj + ) + +;; definition for method 9 of type collide-cache-prim +;; INFO: function output is handled by mips2c +(defmethod-mips2c "(method 9 collide-cache-prim)" 9 collide-cache-prim) + +;; definition for method 10 of type collide-cache-prim +;; INFO: function output is handled by mips2c +(defmethod-mips2c "(method 10 collide-cache-prim)" 10 collide-cache-prim) + +;; definition for method 11 of type collide-cache +(defmethod fill-and-probe-using-spheres collide-cache ((obj collide-cache) (arg0 collide-query)) + (fill-using-spheres obj arg0) + (probe-using-spheres obj arg0) + ) + +;; definition for method 14 of type collide-cache +(defmethod fill-using-spheres collide-cache ((obj collide-cache) (arg0 collide-query)) + (new 'stack-no-clear 'bounding-box) + (set-from-spheres! + (-> arg0 bbox) + (the-as (inline-array sphere) (-> arg0 best-dist)) + (the-as int (-> arg0 num-spheres)) + ) + (fill-using-bounding-box obj arg0) + (none) + ) + +;; definition for method 17 of type collide-cache +;; INFO: function output is handled by mips2c +(defmethod-mips2c "(method 17 collide-cache)" 17 collide-cache) + +;; definition for method 9 of type collide-puss-work +;; INFO: function output is handled by mips2c +(defmethod-mips2c "(method 9 collide-puss-work)" 9 collide-puss-work) + +;; definition for method 10 of type collide-puss-work +;; INFO: function output is handled by mips2c +(defmethod-mips2c "(method 10 collide-puss-work)" 10 collide-puss-work) + +;; definition for function test-closest-pt-in-triangle +;; INFO: Used lq/sq +;; ERROR: failed type prop at 20: add failed: object + +;; ERROR: Failed to guess stack use for 16 in test-closest-pt-in-triangle:0 +(defun test-closest-pt-in-triangle ((a0-0 collide-cache)) + (local-vars + (v0-0 vector) + (v0-1 vector) + (v0-2 none) + (v0-3 float) + (v0-4 symbol) + (v1-1 int) + (v1-2 vector) + (v1-3 uint128) + (v1-4 symbol) + (v1-5 symbol) + (v1-7 none) + (a0-1 int) + (a0-2 none) + (a0-3 none) + (a0-4 none) + (a0-5 none) + (a0-6 none) + (a1-0 collide-cache-tri) + (a1-1 none) + (a1-2 none) + (a2-0 vector) + (a2-1 collide-cache-tri) + (a3-0 vector) + (a3-1 none) + (s0-0 none) + (s1-0 int) + (s2-0 none) + (s3-0 none) + (s4-0 none) + (s5-0 object) + (t9-0 (function int vector)) + (t9-1 (function vector vector vector vector vector)) + (t9-2 (function vector vector matrix vector none)) + (t9-3 (function vector vector float)) + (gp-0 none) + (sp-0 none) + (f0-0 float) + (f1-0 float) + (f30-0 number) + ) + (set! gp-0 (the-as none (+ sp-0 16))) + (set! v1-1 -1082130432) + (set! f30-0 (gpr->fpr v1-1)) + (set! s5-0 (-> a0-0 tris)) + (set! s4-0 (the-as none (+ sp-0 32))) + (set! s3-0 (the-as none (+ sp-0 48))) + (set! s2-0 (the-as none (+ sp-0 64))) + (set! s1-0 (-> a0-0 num-tris)) + (set! s0-0 (the-as none s4-0)) + (set! t9-0 target-pos) + (set! a0-1 0) + (set! v0-0 (call! a0-1)) + (set! v1-2 v0-0) + (set! v1-3 (-> v1-2 quad)) + (s.q! s0-0 v1-3) + (while (nonzero? s1-0) + (when (begin + (or (begin + (set! s1-0 (+ s1-0 -1)) + (set! t9-1 normal-of-plane) + (set! a0-2 (the-as none s2-0)) + (set! a1-0 (+ s5-0 0)) + (set! a2-0 (+ s5-0 16)) + (set! a3-0 (+ s5-0 32)) + (call! a0-2 a1-0 a2-0 a3-0) + (set! t9-2 closest-pt-in-triangle) + (set! a0-3 (the-as none s3-0)) + (set! a1-1 (the-as none s4-0)) + (set! a2-1 (+ s5-0 0)) + (set! a3-1 (the-as none s2-0)) + (call! a0-3 a1-1 a2-1 a3-1) + (set! t9-3 vector-vector-distance-squared) + (set! a0-4 (the-as none s3-0)) + (set! a1-2 (the-as none s4-0)) + (set! v0-3 (call! a0-4 a1-2)) + (set! f0-0 (gpr->fpr v0-3)) + (set! f1-0 (the-as float 0)) + (set! v1-4 (<.s f30-0 f1-0)) + v1-4 + ) + (set! v1-5 (<.s f0-0 f30-0)) + ) + v1-5 + ) + (set! f30-0 f0-0) + (set! v1-7 (the-as none gp-0)) + (set! a0-5 (the-as none s3-0)) + (set! a0-6 (the-as none (l.q a0-5))) + (s.q! v1-7 a0-6) + (set! v1-8 s5-0) + ) + (set! s5-0 (-> s5-0 1)) + ) + (set! v0-4 #f) + (ret-value v0-4) + ) + + + + diff --git a/test/decompiler/reference/jak2/engine/debug/memory-usage_REF.gc b/test/decompiler/reference/jak2/engine/debug/memory-usage_REF.gc new file mode 100644 index 0000000000..1f90464115 --- /dev/null +++ b/test/decompiler/reference/jak2/engine/debug/memory-usage_REF.gc @@ -0,0 +1,580 @@ +(in-package goal) + +;; this file is debug only +(declare-file (debug)) +(when *debug-segment* +;; definition for method 3 of type memory-usage-block +(defmethod inspect memory-usage-block ((obj 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 (-> obj length)) + (let ((v1-2 (-> obj 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 "-------------------------------------------------------------~%") + obj + ) + +;; definition for method 8 of type object +(defmethod mem-usage object ((obj object) (arg0 memory-usage-block) (arg1 int)) + obj + ) + +;; definition for method 10 of type memory-usage-block +(defmethod calculate-total memory-usage-block ((obj memory-usage-block)) + "@returns The total sum of all [[memory-usage-info]] `total`s" + (let ((sum 0)) + (dotimes (idx (-> obj length)) + (+! sum (-> obj data idx total)) + ) + sum + ) + ) + +;; definition for method 9 of type memory-usage-block +(defmethod reset! memory-usage-block ((obj memory-usage-block)) + "Sets `length` to 0 as well as resets all fields except `name` in the associated [[memory-usage-info]]" + (set! (-> obj length) 0) + (dotimes (idx 112) + (set! (-> obj data idx used) 0) + (set! (-> obj data idx total) 0) + (set! (-> obj data idx count) 0) + ) + obj + ) + +;; definition for function mem-size +(defun mem-size ((data basic) (inspect-usage? symbol) (arg2 int)) + "@param data The [[basic]] to call `mem-usage` on + @param inspect-usage? Set to [[#t]] if `inspect` should be called on the resulting [[memory-usage-block]] + @param arg2 TODO - unsure, some sort of bitfield + @returns The total memory footprint of the provided [[basic]]" + (let ((block (new 'stack 'memory-usage-block))) + (mem-usage data block arg2) + (if inspect-usage? + (inspect block) + ) + (calculate-total block) + ) + ) + +;; definition for method 14 of type level +(defmethod compute-memory-usage! level ((obj level) (force? symbol)) + "Calculates the memory usage of the level, returns and stores the [[memory-usage-block]] + in `mem-usage-block` as well as the total size in `mem-usage` + + @param force? - Will re-compute the usage if set to [[#t]], even if `mem-usage` has been set to a non-zero value + @returns The [[memory-usage-block]] representing the footprint of the level + @see [[memory-usage-block::10]]" + (if (zero? (-> obj mem-usage-block)) + (set! (-> obj mem-usage-block) (new 'debug 'memory-usage-block)) + ) + (set! force? (or (zero? (-> obj mem-usage-block length)) force?)) + (when force? + (mem-usage obj (reset! (-> obj mem-usage-block)) 0) + (set! (-> obj mem-usage) (calculate-total (-> obj mem-usage-block))) + 0 + ) + (-> obj mem-usage-block) + ) + +;; definition for method 8 of type process-tree +(defmethod mem-usage process-tree ((obj process-tree) (arg0 memory-usage-block) (arg1 int)) + (let ((v1-0 90)) + (let* ((a0-1 *dead-pool-list*) + (a3-0 (car a0-1)) + ) + (while (not (null? a0-1)) + (set! (-> arg0 data v1-0 name) (symbol->string (the-as symbol a3-0))) + (+! v1-0 1) + (set! a0-1 (cdr a0-1)) + (set! a3-0 (car a0-1)) + ) + ) + (set! (-> arg0 length) (max (-> arg0 length) v1-0)) + ) + (set! (-> arg0 data 96 name) "*debug-dead-pool*") + (set! *temp-mem-usage* arg0) + (when (logtest? arg1 32) + (let* ((s5-0 90) + (s4-0 *dead-pool-list*) + (v1-4 (car s4-0)) + ) + (while (not (null? s4-0)) + (let ((a0-5 (-> (the-as symbol v1-4) value))) + (set! *global-search-count* s5-0) + (iterate-process-tree + (the-as process-tree a0-5) + (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-0 1) + (set! s4-0 (cdr s4-0)) + (set! v1-4 (car s4-0)) + ) + ) + ) + (iterate-process-tree + obj + (lambda ((arg0 process-drawable)) + (let ((gp-0 *temp-mem-usage*)) + (let ((s4-0 (cond + ((= (-> arg0 pool) *8k-dead-pool*) + 91 + ) + ((= (-> arg0 pool) *16k-dead-pool*) + 92 + ) + ((= (-> arg0 pool) *nk-dead-pool*) + 93 + ) + ((= (-> arg0 pool) *target-dead-pool*) + 94 + ) + ((= (-> arg0 pool) *camera-dead-pool*) + 95 + ) + ((= (-> arg0 pool) *debug-dead-pool*) + 96 + ) + (else + 90 + ) + ) + ) + ) + (+! (-> gp-0 data s4-0 count) 1) + (+! (-> gp-0 data s4-0 total) (logand -16 (+ (asize-of arg0) 15))) + ) + (set! (-> gp-0 length) (max 98 (-> gp-0 length))) + (set! (-> gp-0 data 97 name) "process-active") + (+! (-> gp-0 data 97 count) 1) + (let ((v1-23 (asize-of arg0))) + (+! (-> gp-0 data 97 used) v1-23) + (+! (-> gp-0 data 97 total) (logand -16 (+ v1-23 15))) + ) + (set! (-> gp-0 length) (max 99 (-> gp-0 length))) + (set! (-> gp-0 data 98 name) "heap-total") + (+! (-> gp-0 data 98 count) 1) + (let ((v1-34 (+ (- -4 (the-as int arg0)) (the-as int (-> arg0 heap-cur))))) + (+! (-> gp-0 data 98 used) v1-34) + (+! (-> gp-0 data 98 total) (logand -16 (+ v1-34 15))) + ) + (set! (-> gp-0 length) (max 100 (-> gp-0 length))) + (set! (-> gp-0 data 99 name) "heap-process") + (+! (-> gp-0 data 99 count) 1) + (let ((v1-45 (- (-> arg0 type size) (-> arg0 type heap-base)))) + (+! (-> gp-0 data 99 used) v1-45) + (+! (-> gp-0 data 99 total) (logand -16 (+ v1-45 15))) + ) + (set! (-> gp-0 length) (max 101 (-> gp-0 length))) + (set! (-> gp-0 data 100 name) "heap-header") + (+! (-> gp-0 data 100 count) 1) + (let ((v1-55 (-> arg0 type heap-base))) + (+! (-> gp-0 data 100 used) v1-55) + (+! (-> gp-0 data 100 total) (logand -16 (+ v1-55 15))) + ) + (set! (-> gp-0 length) (max 102 (-> gp-0 length))) + (set! (-> gp-0 data 101 name) "heap-thread") + (+! (-> gp-0 data 101 count) 1) + (let ((v1-65 (asize-of (-> arg0 main-thread)))) + (+! (-> gp-0 data 101 used) v1-65) + (+! (-> gp-0 data 101 total) (logand -16 (+ v1-65 15))) + ) + (when (type? arg0 process-drawable) + (when (nonzero? (-> arg0 root)) + (set! (-> gp-0 length) (max 103 (-> gp-0 length))) + (set! (-> gp-0 data 102 name) "heap-root") + (+! (-> gp-0 data 102 count) 1) + (let ((v1-78 (asize-of (-> arg0 root)))) + (+! (-> gp-0 data 102 used) v1-78) + (+! (-> gp-0 data 102 total) (logand -16 (+ v1-78 15))) + ) + (when (type? (-> arg0 root) collide-shape) + (set! (-> gp-0 length) (max 109 (-> gp-0 length))) + (set! (-> gp-0 data 108 name) "heap-collide-prim") + (+! (-> gp-0 data 108 count) 1) + (let ((v1-90 (asize-of (-> (the-as collide-shape-moving (-> arg0 root)) root-prim)))) + (+! (-> gp-0 data 108 used) v1-90) + (+! (-> gp-0 data 108 total) (logand -16 (+ v1-90 15))) + ) + ) + ) + (when (nonzero? (-> arg0 node-list)) + (set! (-> gp-0 length) (max 106 (-> gp-0 length))) + (set! (-> gp-0 data 105 name) "heap-cspace") + (+! (-> gp-0 data 105 count) 1) + (let ((v1-102 (asize-of (-> arg0 node-list)))) + (+! (-> gp-0 data 105 used) v1-102) + (+! (-> gp-0 data 105 total) (logand -16 (+ v1-102 15))) + ) + ) + (when (nonzero? (-> arg0 draw)) + (set! (-> gp-0 length) (max 104 (-> gp-0 length))) + (set! (-> gp-0 data 103 name) "heap-draw-control") + (+! (-> gp-0 data 103 count) 1) + (let ((v1-114 (asize-of (-> arg0 draw)))) + (+! (-> gp-0 data 103 used) v1-114) + (+! (-> gp-0 data 103 total) (logand -16 (+ v1-114 15))) + ) + (when (nonzero? (-> arg0 draw skeleton)) + (set! (-> gp-0 length) (max 107 (-> gp-0 length))) + (set! (-> gp-0 data 106 name) "heap-bone") + (+! (-> gp-0 data 106 count) 1) + (let ((v1-128 (asize-of (-> arg0 draw skeleton)))) + (+! (-> gp-0 data 106 used) v1-128) + (+! (-> gp-0 data 106 total) (logand -16 (+ v1-128 15))) + ) + ) + ) + (when (nonzero? (-> arg0 skel)) + (set! (-> gp-0 length) (max 105 (-> gp-0 length))) + (set! (-> gp-0 data 104 name) "heap-joint-control") + (+! (-> gp-0 data 104 count) 1) + (let ((v1-140 (asize-of (-> arg0 skel)))) + (+! (-> gp-0 data 104 used) v1-140) + (+! (-> gp-0 data 104 total) (logand -16 (+ v1-140 15))) + ) + ) + (when (nonzero? (-> arg0 part)) + (set! (-> gp-0 length) (max 108 (-> gp-0 length))) + (set! (-> gp-0 data 107 name) "heap-part") + (+! (-> gp-0 data 107 count) 1) + (let ((v1-152 (asize-of (-> arg0 part)))) + (+! (-> gp-0 data 107 used) v1-152) + (+! (-> gp-0 data 107 total) (logand -16 (+ v1-152 15))) + ) + ) + (when (nonzero? (-> arg0 nav)) + (set! (-> gp-0 length) (max 110 (-> gp-0 length))) + (set! (-> gp-0 data 109 name) "heap-misc") + (+! (-> gp-0 data 109 count) 1) + (let ((v1-164 (asize-of (-> arg0 nav)))) + (+! (-> gp-0 data 109 used) v1-164) + (+! (-> gp-0 data 109 total) (logand -16 (+ v1-164 15))) + ) + ) + (when (nonzero? (-> arg0 path)) + (set! (-> gp-0 length) (max 110 (-> gp-0 length))) + (set! (-> gp-0 data 109 name) "heap-misc") + (+! (-> gp-0 data 109 count) 1) + (let ((v1-176 (asize-of (-> arg0 path)))) + (+! (-> gp-0 data 109 used) v1-176) + (+! (-> gp-0 data 109 total) (logand -16 (+ v1-176 15))) + ) + ) + (when (nonzero? (-> arg0 vol)) + (set! (-> gp-0 length) (max 110 (-> gp-0 length))) + (set! (-> gp-0 data 109 name) "heap-misc") + (+! (-> gp-0 data 109 count) 1) + (let ((v1-188 (asize-of (-> arg0 vol)))) + (+! (-> gp-0 data 109 used) v1-188) + (+! (-> gp-0 data 109 total) (logand -16 (+ v1-188 15))) + ) + ) + ) + ) + #t + ) + *null-kernel-context* + ) + obj + ) + +;; 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 memory-usage-block ((obj memory-usage-block) (level level) (fmt-dest object)) + (local-vars (sv-16 object) (sv-32 string) (sv-48 int)) + (let ((s3-0 (&- (-> level heap current) (the-as uint (-> level heap base))))) + (let ((v1-2 (+ (-> obj data 61 total) (-> obj data 62 total)))) + (< #x10000 v1-2) + ) + (let* ((v1-5 + (- (- -49152 (the-as int (shl (-> level info borrow-size 1) 10))) (shl (-> level info borrow-size 0) 10)) + ) + (a0-12 (-> level info memory-mode)) + (s2-0 + (+ v1-5 + (the-as int (cond + ((= a0-12 (load-buffer-mode large)) + #xbd0000 + ) + ((= a0-12 (load-buffer-mode medium)) + #x8fb800 + ) + ((= a0-12 (load-buffer-mode small-center)) + #x627000 + ) + ((= a0-12 (load-buffer-mode borrow)) + (+ (- #xc000 (the-as int (-> level heap base))) (the-as int (-> level heap top-base))) + ) + (else + #x5e8000 + ) + ) + ) + ) + ) + (s1-0 (* (dma-buffer-length (-> *display* frames (-> *display* last-screen) global-buf)) 16)) + ) + (set! *max-dma* (max s1-0 *max-dma*)) + (if (< (the-as int s2-0) s3-0) + (format fmt-dest "~3L") + ) + (let ((s0-0 format)) + (set! sv-16 fmt-dest) + (set! sv-32 "~0K~10,'-S--~5,'-DK-of-~5,'-DK--~5,'-DK-of-~5,'-DK--") + (let ((s4-1 (-> level name)) + (s3-1 (sar s3-0 10)) + (s2-1 (shr s2-0 10)) + ) + (set! sv-48 (sar (memory-used *nk-dead-pool*) 10)) + (let ((t2-0 (sar (memory-total *nk-dead-pool*) 10)) + (t9-4 s0-0) + (a0-22 sv-16) + (a1-8 sv-32) + (a2-1 s4-1) + (a3-0 s3-1) + (t0-0 s2-1) + (t1-0 sv-48) + ) + (t9-4 a0-22 a1-8 a2-1 a3-0 t0-0 t1-0 t2-0) + (format fmt-dest "~5,'-DK/~5,'-DK--~%" (shr s1-0 10) (sar *max-dma* 10)) + (when *stats-memory-short* + (let ((s3-2 (if (cpad-hold? 1 l3) + #t + fmt-dest + ) + ) + (s4-2 format) + (s2-2 "heap-~5,'-DK/~5,'-DK----~D---~D/~D~%") + (s1-1 (sar (memory-used *nk-dead-pool*) 10)) + (s0-1 (sar (memory-total *nk-dead-pool*) 10)) + ) + (set! t0-0 (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-2 s1-1 s0-1 t0-0 (the-as uint t1-0) (the-as uint t2-0)) + ) + ) + (when (not *stats-memory-short*) + (set! (-> *dma-mem-usage* data 87 total) + (* (dma-buffer-length (-> *display* frames (-> *display* last-screen) debug-buf)) 16) + ) + (let ((t9-11 format) + (a0-31 fmt-dest) + (a1-11 " bsp ~192H~5DK ~280Hdebug~456H~5DK~%") + (a2-6 (sar (+ (-> obj data 58 total) (-> obj data 59 total) (-> obj data 60 total)) 10)) + (a3-3 (sar (-> *dma-mem-usage* data 87 total) 10)) + ) + (t9-11 a0-31 a1-11 a2-6 a3-3 (the-as none t0-0) (the-as none t1-0) (the-as none t2-0)) + (format + fmt-dest + " bsp-leaf-vis ~192H~5DK~%" + (sar (+ (-> obj data 61 total) (-> obj data 62 total)) 10) + (the-as none a3-3) + ) + (format fmt-dest " level-code ~192H~5DK~%" (sar (-> obj data 65 total) 10) (the-as none a3-3)) + ) + (format + fmt-dest + " tfrag ~192H~5DK ~280Htfragment~456H~5DK~%" + (sar + (+ (-> obj data 1 total) + (-> obj data 2 total) + (-> obj data 3 total) + (-> obj data 4 total) + (-> obj data 5 total) + (-> obj data 6 total) + (-> obj data 7 total) + (-> obj data 8 total) + ) + 10 + ) + (sar (-> *dma-mem-usage* data 1 total) 10) + ) + (format + fmt-dest + " tie-proto ~192H~5DK ~280Hsky~456H~5DK~%" + (sar + (+ (-> obj data 9 total) + (-> obj data 10 total) + (-> obj data 11 total) + (-> obj data 12 total) + (-> obj data 13 total) + (-> obj data 14 total) + (-> obj data 16 total) + (-> obj data 17 total) + ) + 10 + ) + (sar (-> *dma-mem-usage* data 88 total) 10) + ) + (format + fmt-dest + " tie-instance ~192H~5DK ~280Htie-fragment~456H~5DK~%" + (sar (+ (-> obj data 18 total) (-> obj data 20 total) (-> obj data 21 total) (-> obj data 22 total)) 10) + (sar (-> *dma-mem-usage* data 9 total) 10) + ) + (format + fmt-dest + " shrub-proto ~192H~5DK ~280Htie-scissor~456H~5DK~%" + (sar + (+ (-> obj data 25 total) + (-> obj data 26 total) + (-> obj data 27 total) + (-> obj data 28 total) + (-> obj data 29 total) + (-> obj data 30 total) + (-> obj data 31 total) + (-> obj data 32 total) + (-> obj data 33 total) + ) + 10 + ) + (sar (-> *dma-mem-usage* data 15 total) 10) + ) + (format + fmt-dest + " shrub-instance ~192H~5DK ~280Hshrubbery~456H~5DK~%" + (sar (-> obj data 34 total) 10) + (sar (-> *dma-mem-usage* data 27 total) 10) + ) + (format + fmt-dest + " collision ~192H~5DK ~280Htie-generic~456H~5DK~%" + (sar + (+ (-> obj data 50 total) + (-> obj data 51 total) + (-> obj data 52 total) + (-> obj data 53 total) + (-> obj data 54 total) + (-> obj data 55 total) + (-> obj data 56 total) + (-> obj data 57 total) + ) + 10 + ) + (sar (-> *dma-mem-usage* data 17 total) 10) + ) + (format + fmt-dest + " pris-geo ~192H~5DK ~280Hpris-fragment~456H~5DK~%" + (sar + (+ (-> obj data 35 total) + (-> obj data 36 total) + (-> obj data 37 total) + (-> obj data 38 total) + (-> obj data 39 total) + (-> obj data 40 total) + (-> obj data 41 total) + (-> obj data 42 total) + (-> obj data 73 total) + (-> obj data 74 total) + (-> obj data 75 total) + (-> obj data 76 total) + (-> obj data 78 total) + (-> obj data 81 total) + (-> obj data 80 total) + (-> obj data 111 total) + ) + 10 + ) + (sar (-> *dma-mem-usage* data 35 total) 10) + ) + (format + fmt-dest + " pris-anim ~192H~5DK ~280Hpris-generic~456H~5DK~%" + (sar + (+ (-> obj data 67 total) + (-> obj data 68 total) + (-> obj data 69 total) + (-> obj data 70 total) + (-> obj data 71 total) + (-> obj data 77 total) + (-> obj data 79 total) + (-> obj data 72 total) + ) + 10 + ) + (sar (-> *dma-mem-usage* data 89 total) 10) + ) + (format + fmt-dest + " textures ~192H~5DK ~280Htextures~456H~5DK~%" + (sar (-> obj data 82 total) 10) + (sar (-> *dma-mem-usage* data 82 total) 10) + ) + (format fmt-dest " entity ~192H~5DK~%" (sar + (+ (-> obj data 66 total) + (-> obj data 43 total) + (-> obj data 44 total) + (-> obj data 45 total) + (-> obj data 49 total) + (-> obj data 48 total) + (-> obj data 46 total) + (-> obj data 47 total) + ) + 10 + ) + ) + (format + fmt-dest + " misc ~192H~5DK ~280Hsprite~456H~5DK~%" + (sar + (+ (-> obj data 0 total) + (-> obj data 63 total) + (-> obj data 64 total) + (-> obj data 83 total) + (-> obj data 84 total) + ) + 10 + ) + (sar (-> *dma-mem-usage* data 85 total) 10) + ) + ) + ) + ) + ) + ) + ) + (format fmt-dest "~1K~0L") + obj + ) + +;; failed to figure out what this is: +0 + +) + + + diff --git a/test/decompiler/reference/jak2/engine/draw/drawable_REF.gc b/test/decompiler/reference/jak2/engine/draw/drawable_REF.gc new file mode 100644 index 0000000000..6732f8eec8 --- /dev/null +++ b/test/decompiler/reference/jak2/engine/draw/drawable_REF.gc @@ -0,0 +1,2240 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition for function sphere-cull +;; ERROR: Bad vector register dependency: vf16 +;; ERROR: Bad vector register dependency: vf17 +;; ERROR: Bad vector register dependency: vf18 +;; ERROR: Bad vector register dependency: vf19 +(defun sphere-cull ((arg0 vector)) + (local-vars (v1-0 uint128) (v1-1 uint128) (v1-2 uint128)) + (rlet ((acc :class vf) + (vf0 :class vf) + (vf10 :class vf) + (vf16 :class vf) + (vf17 :class vf) + (vf18 :class vf) + (vf19 :class vf) + (vf9 :class vf) + ) + (init-vf0-vector) + (.lvf vf10 (&-> arg0 quad)) + (.mul.x.vf acc vf16 vf10) + (.add.mul.y.vf acc vf17 vf10 acc) + (.add.mul.z.vf acc vf18 vf10 acc) + (.sub.mul.w.vf vf9 vf19 vf0 acc) + (.add.w.vf vf9 vf9 vf10) + (.mov v1-0 vf9) + (.pcgtw v1-1 0 v1-0) + (.ppach v1-2 (the-as uint128 0) v1-1) + (zero? (the-as int v1-2)) + ) + ) + +;; definition for function guard-band-cull +;; ERROR: Bad vector register dependency: vf20 +;; ERROR: Bad vector register dependency: vf21 +;; ERROR: Bad vector register dependency: vf22 +;; ERROR: Bad vector register dependency: vf23 +(defun guard-band-cull ((arg0 vector)) + (local-vars (v1-0 uint128) (v1-1 uint128) (v1-2 uint128)) + (rlet ((acc :class vf) + (vf0 :class vf) + (vf10 :class vf) + (vf20 :class vf) + (vf21 :class vf) + (vf22 :class vf) + (vf23 :class vf) + (vf9 :class vf) + ) + (init-vf0-vector) + (.lvf vf10 (&-> arg0 quad)) + (.mul.x.vf acc vf20 vf10) + (.add.mul.y.vf acc vf21 vf10 acc) + (.add.mul.z.vf acc vf22 vf10 acc) + (.sub.mul.w.vf vf9 vf23 vf0 acc) + (.sub.w.vf vf9 vf9 vf10) + (.mov v1-0 vf9) + (.pcgtw v1-1 0 v1-0) + (.ppach v1-2 (the-as uint128 0) v1-1) + (nonzero? (the-as int v1-2)) + ) + ) + +;; definition for function sphere-in-view-frustum? +(defun sphere-in-view-frustum? ((arg0 sphere)) + (local-vars (v1-1 uint128) (v1-2 uint128) (v1-3 uint128)) + (rlet ((acc :class vf) + (vf0 :class vf) + (vf1 :class vf) + (vf2 :class vf) + (vf3 :class vf) + (vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + ) + (init-vf0-vector) + (let ((v1-0 *math-camera*)) + (.lvf vf6 (&-> arg0 quad)) + (.lvf vf1 (&-> v1-0 plane 0 quad)) + (.lvf vf2 (&-> v1-0 plane 1 quad)) + (.lvf vf3 (&-> v1-0 plane 2 quad)) + (.lvf vf4 (&-> v1-0 plane 3 quad)) + ) + (.mul.x.vf acc vf1 vf6) + (.add.mul.y.vf acc vf2 vf6 acc) + (.add.mul.z.vf acc vf3 vf6 acc) + (.sub.mul.w.vf vf5 vf4 vf0 acc) + (.add.w.vf vf5 vf5 vf6) + (.mov v1-1 vf5) + (.pcgtw v1-2 0 v1-1) + (.ppach v1-3 (the-as uint128 0) v1-2) + (zero? (the-as int v1-3)) + ) + ) + +;; definition for function line-in-view-frustum? +(defun line-in-view-frustum? ((arg0 vector) (arg1 vector)) + (local-vars (v1-1 uint128) (v1-2 uint128) (v1-3 uint128) (a0-1 uint128) (a0-2 uint128) (a0-3 uint128)) + (rlet ((acc :class vf) + (vf0 :class vf) + (vf10 :class vf) + (vf16 :class vf) + (vf17 :class vf) + (vf18 :class vf) + (vf19 :class vf) + (vf9 :class vf) + ) + (init-vf0-vector) + (let ((v1-0 *math-camera*)) + (.lvf vf9 (&-> arg0 quad)) + (.lvf vf10 (&-> arg1 quad)) + (.lvf vf16 (&-> v1-0 plane 0 quad)) + (.lvf vf17 (&-> v1-0 plane 1 quad)) + (.lvf vf18 (&-> v1-0 plane 2 quad)) + (.lvf vf19 (&-> v1-0 plane 3 quad)) + ) + (.mul.x.vf acc vf16 vf9) + (.add.mul.y.vf acc vf17 vf9 acc) + (.add.mul.z.vf acc vf18 vf9 acc) + (.sub.mul.w.vf vf9 vf19 vf0 acc) + (.mul.x.vf acc vf16 vf10) + (.add.mul.y.vf acc vf17 vf10 acc) + (.add.mul.z.vf acc vf18 vf10 acc) + (.sub.mul.w.vf vf10 vf19 vf0 acc) + (.mov v1-1 vf9) + (.pcgtw v1-2 0 v1-1) + (.ppach v1-3 (the-as uint128 0) v1-2) + (.mov a0-1 vf10) + (.pcgtw a0-2 0 a0-1) + (.ppach a0-3 (the-as uint128 0) a0-2) + (not (logtest? (the-as int v1-3) (the-as int a0-3))) + ) + ) + +;; definition for function vis-cull +;; ERROR: failed type prop at 3: Could not figure out load: (set! v1 (l.b (+ v1 #x38a0))) +;; WARN: Return type mismatch none vs symbol. +;; ERROR: Unsupported inline assembly instruction kind - [addiu a0, a0, 56] +(defun vis-cull ((a0-0 int)) + (local-vars (v0-0 none) (v1-0 int) (v1-1 int) (v1-2 none) (v1-3 none) (a0-1 none) (a0-2 none) (a1-0 int)) + (set! v1-0 #x70000000) + (shift-arith-right-32 a1-0 a0-0 3) + (set! v1-1 (+ a1-0 v1-0)) + (set! v1-2 (the-as none (l.b (+ v1-1 #x38a0)))) + (set! a0-1 (the-as none (logand a0-0 7))) + (.addiu a0-2 a0-1 56) + (set! v1-3 (the-as none (sll v1-2 a0-2))) + (set! v0-0 (the-as none (<0.si v1-3))) + (ret-value v0-0) + ) + +;; definition (debug) for function vis-cull-debug +;; WARN: Failed load: (set! v1-2 (l.b (+ v1-1 #x38a0))) at op 2 +;; ERROR: Unsupported inline assembly instruction kind - [addiu a0, a0, 56] +(defun-debug vis-cull-debug ((arg0 work-area) (arg1 int)) + (local-vars (v1-0 int) (a0-2 int)) + (shift-arith-right-32 v1-0 arg1 3) + (let ((v1-2 (l.b (+ v1-0 (the-as int arg0) #x38a0)))) + (let ((a0-1 (logand arg1 7))) + (.addiu a0-2 a0-1 56) + ) + (< (shl v1-2 a0-2) 0) + ) + ) + +;; definition for function error-sphere +;; WARN: Return type mismatch int vs none. +(defun error-sphere ((arg0 drawable-error) (arg1 string)) + (when *artist-error-spheres* + (when (vis-cull (-> arg0 id)) + (when (sphere-cull (-> arg0 bsphere)) + (add-debug-sphere + #t + (bucket-id debug2) + (-> arg0 bsphere) + (-> arg0 bsphere w) + (new 'static 'rgba :r #x80 :a #x80) + ) + (add-debug-text-3d + #t + (bucket-id debug-no-zbuf1) + arg1 + (-> arg0 bsphere) + (font-color #dadada) + (the-as vector2h #f) + ) + ) + ) + ) + 0 + (none) + ) + +;; definition for method 9 of type drawable +(defmethod login drawable ((obj drawable)) + obj + ) + +;; definition for method 10 of type drawable +;; WARN: Return type mismatch int vs none. +(defmethod draw drawable ((obj drawable) (arg0 drawable) (arg1 display-frame)) + 0 + (none) + ) + +;; definition for method 11 of type drawable +(defmethod fill-collide-list-from-box drawable ((obj drawable) (arg0 int) (arg1 collide-list) (arg2 collide-query)) + 0 + ) + +;; definition for method 12 of type drawable +(defmethod fill-collide-list-from-line-sphere drawable ((obj drawable) (arg0 int) (arg1 collide-list) (arg2 collide-query)) + 0 + ) + +;; definition for method 16 of type drawable +;; WARN: Return type mismatch int vs none. +(defmethod collect-regions drawable ((obj drawable) (arg0 sphere) (arg1 int) (arg2 region-prim-list)) + "Determines the number of [[drawable]]s in the `obj` that overlap the given `area-of-interest` this number is stored in the `region-list`'s item count + @param area-of-interest The area defined by a sphere that we care about overlaps + @param _count The amount of [[drawable]]s in the object to enumerate through + @param! region-list Stores the overlapping regions and a count for how many were found + @returns none" + 0 + (none) + ) + +;; definition for method 13 of type drawable +;; WARN: Return type mismatch int vs none. +(defmethod collect-stats drawable ((obj drawable)) + 0 + (none) + ) + +;; definition for method 14 of type drawable +;; WARN: Return type mismatch int vs none. +(defmethod debug-draw drawable ((obj drawable) (arg0 drawable) (arg1 display-frame)) + 0 + (none) + ) + +;; definition for method 10 of type drawable-error +;; WARN: Return type mismatch int vs none. +(defmethod draw drawable-error ((obj drawable-error) (arg0 drawable-error) (arg1 display-frame)) + (error-sphere arg0 (-> arg0 name)) + 0 + (none) + ) + +;; definition for method 15 of type drawable +(defmethod unpack-vis drawable ((obj drawable) (arg0 (pointer int8)) (arg1 (pointer int8))) + arg1 + ) + +;; definition for symbol *edit-instance*, type string +(define *edit-instance* (the-as string #f)) + +;; this part is debug only +(when *debug-segment* +;; definition for symbol *instance-mem-usage*, type memory-usage-block +(define *instance-mem-usage* (new 'debug 'memory-usage-block)) + +) +;; definition for function find-instance-by-name-level +(defun find-instance-by-name-level ((arg0 string) (arg1 level)) + (let ((s5-0 (-> arg1 bsp drawable-trees))) + (dotimes (s4-0 (-> s5-0 length)) + (let ((v1-3 (-> s5-0 trees s4-0))) + (case (-> v1-3 type) + ((drawable-tree-instance-shrub) + (let ((s3-0 (-> (the-as drawable-tree-instance-shrub v1-3) info prototype-inline-array-shrub))) + (dotimes (s2-0 (-> s3-0 length)) + (if (string= arg0 (-> s3-0 data s2-0 name)) + (return (-> s3-0 data s2-0)) + ) + ) + ) + ) + ((drawable-tree-instance-tie) + (let ((s3-1 (-> (the-as drawable-tree-instance-tie v1-3) prototypes prototype-array-tie))) + (dotimes (s2-1 (-> s3-1 length)) + (if (string= arg0 (-> s3-1 array-data s2-1 name)) + (return (-> s3-1 array-data s2-1)) + ) + ) + ) + ) + ) + ) + ) + ) + (the-as prototype-bucket #f) + ) + +;; definition for function find-instance-by-name +(defun find-instance-by-name ((arg0 string)) + (dotimes (s5-0 (-> *level* length)) + (let ((a1-0 (-> *level* level s5-0))) + (when (= (-> a1-0 status) 'active) + (let ((a0-4 (find-instance-by-name-level arg0 a1-0))) + (if a0-4 + (return a0-4) + ) + ) + ) + ) + ) + (the-as prototype-bucket #f) + ) + +;; definition for function prototypes-game-visible-set! +(defun prototypes-game-visible-set! ((arg0 pair) (arg1 symbol)) + (let ((a0-1 (car arg0))) + (while (not (null? arg0)) + (let ((v1-0 (find-instance-by-name (the-as string a0-1)))) + (when v1-0 + (if arg1 + (logclear! (-> v1-0 flags) (prototype-flags visible no-collide)) + (logior! (-> v1-0 flags) (prototype-flags visible no-collide)) + ) + ) + ) + (set! arg0 (cdr arg0)) + (set! a0-1 (car arg0)) + ) + ) + 0 + ) + +;; definition (debug) for function find-instance-by-index +(defun-debug find-instance-by-index ((arg0 type) (arg1 int) (arg2 bsp-header)) + (dotimes (v1-0 (-> *level* length)) + (let ((a3-3 (-> *level* level v1-0))) + (when (= (-> a3-3 status) 'active) + (let ((a3-4 (-> a3-3 bsp))) + (when (or (not arg2) (= a3-4 arg2)) + (let ((a3-5 (-> a3-4 drawable-trees))) + (dotimes (t0-5 (-> a3-5 length)) + (let ((t1-3 (-> a3-5 trees t0-5))) + (case (-> t1-3 type) + ((drawable-tree-instance-shrub) + (when (= arg0 (-> t1-3 type)) + (let ((v1-2 (-> (the-as drawable-tree-instance-shrub t1-3) info prototype-inline-array-shrub))) + (return (-> v1-2 data arg1)) + ) + ) + ) + ((drawable-tree-instance-tie) + (when (= arg0 (-> t1-3 type)) + (let ((v1-5 (-> (the-as drawable-tree-instance-tie t1-3) prototypes prototype-array-tie))) + (return (-> v1-5 array-data arg1)) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + (the-as prototype-bucket #f) + ) + +;; definition (debug) for function prototype-bucket-type +(defun-debug prototype-bucket-type ((arg0 prototype-bucket)) + (case (-> arg0 geometry 1 type) + ((prototype-shrubbery shrubbery) + instance-shrubbery + ) + ((prototype-tie prototype-tie tie-fragment) + instance-tie + ) + ) + ) + +;; definition (debug) for function prototype-bucket-recalc-fields +(defun-debug prototype-bucket-recalc-fields ((arg0 prototype-bucket)) + (case (prototype-bucket-type arg0) + ((instance-shrubbery) + (set! (-> arg0 rdists x) (/ 1.0 (- (-> arg0 dists w) (-> arg0 dists x)))) + ) + (else + (set! (-> arg0 dists z) (+ (-> arg0 dists x) (* 0.33333334 (- (-> arg0 dists w) (-> arg0 dists x))))) + (set! (-> arg0 rdists x) (/ 1.0 (- (-> arg0 dists z) (-> arg0 dists x)))) + ) + ) + (set! (-> arg0 rdists z) (/ 1.0 (- (-> arg0 dists w) (-> arg0 dists z)))) + (set! (-> arg0 dists y) (* 0.5 (-> arg0 dists x))) + (set! (-> arg0 rdists y) (/ 1.0 (-> arg0 dists y))) + arg0 + ) + +;; definition (debug) for function print-prototype-list +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs none. +(defun-debug print-prototype-list () + (local-vars (sv-16 (function prototype-bucket-shrub memory-usage-block int prototype-bucket-shrub))) + (dotimes (gp-0 (-> *level* length)) + (let ((s5-0 (-> *level* level gp-0))) + (when (= (-> s5-0 status) 'active) + (format #t "-------- level ~S~%" (-> s5-0 name)) + (let ((s5-1 (-> s5-0 bsp drawable-trees))) + (dotimes (s4-0 (-> s5-1 length)) + (let ((v1-8 (-> s5-1 trees s4-0))) + (case (-> v1-8 type) + ((drawable-tree-instance-shrub) + (let ((s3-0 (-> (the-as drawable-tree-instance-shrub v1-8) info prototype-inline-array-shrub))) + (dotimes (s2-0 (-> s3-0 length)) + 0 + (let ((s1-0 (-> s3-0 data s2-0))) + (dotimes (s0-0 4) + (reset! *instance-mem-usage*) + (if (nonzero? (-> s1-0 geometry s0-0)) + (mem-usage (-> s1-0 geometry s0-0) *instance-mem-usage* 0) + ) + ) + (let ((s0-1 s1-0)) + (set! sv-16 (method-of-object s0-1 mem-usage)) + (let ((a1-4 (reset! *instance-mem-usage*)) + (a2-2 0) + ) + (sv-16 s0-1 a1-4 a2-2) + ) + ) + (let ((v1-29 (calculate-total *instance-mem-usage*))) + (format + #t + " ~-48S~4D shrub ~5,,2fK ~4,,2fK~%" + (-> s1-0 name) + (-> s1-0 in-level) + (* 0.0009765625 (the float v1-29)) + (* 0.0009765625 (the float (* (the-as uint 80) (-> s1-0 in-level)))) + ) + ) + ) + ) + ) + ) + ((drawable-tree-instance-tie) + (let ((s3-1 (-> (the-as drawable-tree-instance-tie v1-8) prototypes prototype-array-tie))) + (dotimes (s2-1 (-> s3-1 length)) + 0 + (let ((s1-1 (-> s3-1 array-data s2-1))) + (reset! *instance-mem-usage*) + (dotimes (s0-2 4) + (when (nonzero? (-> s1-1 tie-geom s0-2)) + (let* ((a0-13 (-> s1-1 tie-geom s0-2)) + (t9-8 (method-of-object a0-13 mem-usage)) + (a1-7 *instance-mem-usage*) + (v1-47 s0-2) + ) + (t9-8 a0-13 a1-7 (logior (cond + ((= v1-47 1) + 4 + ) + ((= v1-47 2) + 8 + ) + ((= v1-47 3) + 16 + ) + (else + 0 + ) + ) + 2 + ) + ) + ) + ) + ) + (mem-usage s1-1 *instance-mem-usage* 0) + (let ((v1-54 (calculate-total *instance-mem-usage*))) + (format + #t + " ~-48S~4D tie ~5,,2fK ~4,,2fK~%" + (-> s1-1 name) + (-> s1-1 in-level) + (* 0.0009765625 (the float v1-54)) + (* 0.0009765625 (the float (* (-> s1-1 in-level) 64))) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + 0 + (none) + ) + +;; definition (debug) for function draw-instance-info +;; INFO: Used lq/sq +;; WARN: Return type mismatch object vs none. +(defun-debug draw-instance-info ((arg0 string)) + (local-vars + (sv-16 uint) + (sv-32 uint32) + (sv-48 uint32) + (sv-64 int) + (sv-80 int) + (sv-96 int) + (sv-112 int) + (sv-128 int) + (sv-144 int) + ) + (when (and *display-instance-info* *edit-instance*) + (let ((s5-0 (find-instance-by-name *edit-instance*))) + (when s5-0 + (dotimes (s4-0 (-> *level* length)) + (let ((v1-5 (-> *level* level s4-0))) + (when (= (-> v1-5 status) 'active) + (let ((s3-0 (-> v1-5 bsp drawable-trees))) + (dotimes (s2-0 (-> s3-0 length)) + (let ((v1-9 (-> s3-0 trees s2-0))) + (case (-> v1-9 type) + ((drawable-tree-instance-shrub) + ) + ((drawable-tree-instance-tie) + (let ((s1-0 (-> v1-9 data (+ (-> v1-9 length) -1)))) + (dotimes (s0-0 (-> (the-as drawable-inline-array-instance-tie s1-0) length)) + (if (string= (-> (the-as drawable-inline-array-instance-tie s1-0) data s0-0 bucket-ptr name) *edit-instance*) + (add-debug-sphere + #t + (bucket-id debug-no-zbuf1) + (the-as + vector + (+ (the-as uint (-> (the-as drawable-inline-array-instance-tie s1-0) data 0 bsphere)) (* s0-0 64)) + ) + (-> (the-as drawable-inline-array-instance-tie s1-0) data s0-0 bsphere w) + (new 'static 'rgba :g #xff :a #x80) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + (let ((s2-1 (prototype-bucket-type s5-0))) + (let ((s4-1 0)) + 0 + (cond + ((= s2-1 instance-shrubbery) + (set! s4-1 80) + ) + ((= s2-1 instance-tie) + (reset! *instance-mem-usage*) + (dotimes (s4-2 4) + (when (nonzero? (-> s5-0 geometry s4-2)) + (let* ((a0-17 (-> s5-0 geometry s4-2)) + (t9-5 (method-of-object a0-17 mem-usage)) + (a1-6 *instance-mem-usage*) + (v1-40 s4-2) + ) + (t9-5 a0-17 a1-6 (logior (cond + ((= v1-40 1) + 4 + ) + ((= v1-40 2) + 8 + ) + ((= v1-40 3) + 16 + ) + (else + 0 + ) + ) + 2 + ) + ) + ) + ) + ) + (set! s4-1 (+ (calculate-total *instance-mem-usage*) 64)) + ) + ) + (mem-usage s5-0 (reset! *instance-mem-usage*) 0) + (let ((v1-50 (calculate-total *instance-mem-usage*))) + (format + arg0 + "~%~A ~A b @ #x~X ~,,2fK/~,,2fK~%" + s2-1 + (-> s5-0 name) + s5-0 + (* 0.0009765625 (the float v1-50)) + (* 0.0009765625 (the float s4-1)) + ) + ) + ) + (format arg0 "near: ~m mid: ~m far: ~m~%" (-> s5-0 dists x) (-> s5-0 dists z) (-> s5-0 dists w)) + (let ((s3-2 0) + (s4-3 0) + ) + (cond + ((= s2-1 instance-shrubbery) + (let ((f30-0 0.0)) + (format + arg0 + "usage: vis: ~D shrub: ~D trans-shrub ~D bill: ~D in level: ~D~%" + (-> (the-as prototype-bucket-shrub s5-0) count 0) + (-> (the-as prototype-bucket-shrub s5-0) count 1) + (-> (the-as prototype-bucket-shrub s5-0) count 2) + (-> (the-as prototype-bucket-shrub s5-0) count 3) + (-> (the-as prototype-bucket-shrub s5-0) in-level) + ) + (format arg0 "~%frag# tris dverts strlen tex~%") + (let ((s1-2 (the-as prototype-shrubbery (-> (the-as prototype-bucket-shrub s5-0) geometry 1))) + (s2-2 (+ (-> (the-as prototype-bucket-shrub s5-0) count 1) (-> (the-as prototype-bucket-shrub s5-0) count 2))) + ) + (dotimes (s0-1 (-> s1-2 length)) + (set! sv-16 (shrub-num-tris (-> s1-2 data s0-1))) + (set! sv-32 (-> s1-2 data s0-1 header data 2)) + (set! sv-48 (-> s1-2 data s0-1 header data 0)) + (format + arg0 + "~5D ~4D ~5D ~6f ~D~%" + s0-1 + sv-16 + sv-32 + (/ (* 2.0 (the float sv-16)) (the float (- sv-32 (the-as uint sv-16)))) + sv-48 + ) + (+! s3-2 sv-16) + (+! s4-3 (the-as int sv-32)) + (set! f30-0 + (+ 29.0 + (* 5.5 (the float (- sv-32 (the-as uint sv-16)))) + (* 22.0 (the float sv-48)) + (* 8.0 (the float sv-32)) + (* 53.0 (the float (/ (+ s2-2 9) (the-as uint 10)))) + (* (the float s2-2) (+ 15.0 (* 5.0 (the float sv-48)) (* 13.5 (the float sv-32)))) + f30-0 + ) + ) + ) + (format + arg0 + "total ~4D ~5D ~6f ~D speed: ~f~%" + s3-2 + s4-3 + (/ (* 2.0 (the float s3-2)) (the float (- s4-3 s3-2))) + (-> s5-0 utextures) + (/ f30-0 (* (the float s2-2) (the float s3-2))) + ) + ) + ) + ) + ((= s2-1 instance-tie) + (set! sv-144 0) + (let ((s1-3 0) + (s0-2 0) + (s2-3 0) + ) + (format arg0 "~%level visible frags tris dverts strlen tex ttris~%") + (set! sv-64 1) + (set! sv-80 3) + (while (>= sv-80 sv-64) + (let ((v1-100 (-> (the-as prototype-bucket-tie s5-0) tie-geom sv-64))) + (set! sv-96 0) + (set! sv-112 0) + (set! sv-128 0) + (dotimes (a0-36 (-> v1-100 length)) + (set! sv-96 (+ sv-96 (-> v1-100 data a0-36 debug num-tris))) + (set! sv-112 (+ sv-112 (-> v1-100 data a0-36 debug num-dverts))) + (set! sv-128 (+ sv-128 (-> v1-100 data a0-36 tex-count))) + ) + (set! sv-144 (+ sv-144 (the-as int (-> (the-as prototype-bucket-tie s5-0) count sv-64)))) + (format + arg0 + "~5D ~7D ~5D ~5D" + sv-64 + (-> (the-as prototype-bucket-tie s5-0) count sv-64) + (-> v1-100 length) + sv-96 + ) + ) + (format + arg0 + " ~5D ~6f ~3D ~5D~%" + sv-112 + (/ (* 2.0 (the float sv-96)) (the float (- sv-112 sv-96))) + sv-128 + (* (the-as uint sv-96) (the-as uint (-> (the-as prototype-bucket-tie s5-0) count sv-64))) + ) + (+! s1-3 (* (the-as uint sv-96) (the-as uint (-> (the-as prototype-bucket-tie s5-0) count sv-64)))) + (+! s0-2 (* (the-as uint sv-112) (the-as uint (-> (the-as prototype-bucket-tie s5-0) count sv-64)))) + (+! s3-2 sv-96) + (+! s4-3 sv-112) + (+! s2-3 sv-128) + (set! sv-64 (+ sv-64 1)) + ) + (let ((t9-20 format) + (a0-52 arg0) + (a1-28 "total ~7D/~3D ~5D") + (a3-12 (-> s5-0 in-level)) + ) + (t9-20 a0-52 a1-28 sv-144 a3-12 s3-2) + ) + (format + arg0 + " ~5D ~6f ~3D ~5D~%" + s4-3 + (/ (* 2.0 (the float s1-3)) (the float (- s0-2 s1-3))) + s2-3 + s1-3 + ) + ) + ) + ) + ) + ) + ) + ) + ) + (none) + ) + +;; definition (debug) for function set-shadow-by-name +;; WARN: Return type mismatch uint vs none. +(defun-debug set-shadow-by-name ((arg0 string) (arg1 int) (arg2 int)) + (let ((v1-0 (process-by-name arg0 *active-pool*))) + (when v1-0 + (let ((v1-1 (-> (the-as process-drawable v1-0) draw))) + (cond + ((< arg2 16) + (logior! (-> v1-1 shadow-mask) (ash 1 arg1)) + (logclear! (-> v1-1 shadow-values) (ash 15 (* arg1 4))) + (logior! (-> v1-1 shadow-values) (ash arg2 (* arg1 4))) + ) + (else + (logclear! (-> v1-1 shadow-mask) (ash 1 arg1)) + (logclear! (-> v1-1 shadow-values) (ash 15 (* arg1 4))) + ) + ) + ) + ) + ) + (none) + ) + +;; definition (debug) for function get-shadow-by-name +;; WARN: Return type mismatch object vs none. +(defun-debug get-shadow-by-name ((arg0 string)) + (let ((v1-0 (process-by-name arg0 *active-pool*))) + (when v1-0 + (let ((s5-0 (-> (the-as process-drawable v1-0) draw))) + (format 0 "actor ~s {~%" arg0) + (format 0 " SHADOW_MASK(0x~02x)~%" (-> s5-0 shadow-mask)) + (format 0 " SHADOW_VALUES(0x~08x)~%" (-> s5-0 shadow-values)) + ) + (format 0 "}~%") + ) + ) + (none) + ) + +;; definition (debug) for function teleport-camera-by-name +;; WARN: Return type mismatch object vs none. +(defun-debug teleport-camera-by-name ((arg0 string)) + (let* ((gp-0 (entity-by-name arg0)) + (v1-0 (if (type? gp-0 entity-actor) + gp-0 + ) + ) + ) + (if (and v1-0 *camera*) + (send-event *camera* 'teleport-to-vector-start-string (-> v1-0 trans)) + ) + ) + (none) + ) + +;; definition for function dma-add-process-drawable +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs none. +;; WARN: Function dma-add-process-drawable has a return type of none, but the expression builder found a return statement. +(defun dma-add-process-drawable ((pd process-drawable) (dc draw-control) (flag symbol) (dma-buf dma-buffer)) + (local-vars + (a0-82 int) + (a0-84 int) + (a3-11 uint128) + (sv-16 process-drawable) + (tod time-of-day-context) + (shadow-mask uint) + (lev-idx-for-mood uint) + (my-origin vector) + (lev-mood mood-context) + (light-result-bucket light-hash-bucket) + (index-ptr pointer) + (index-index int) + ) + (with-pp + (rlet ((acc :class vf) + (Q :class vf) + (vf0 :class vf) + (vf1 :class vf) + (vf15 :class vf) + (vf16 :class vf) + (vf17 :class vf) + (vf18 :class vf) + (vf19 :class vf) + (vf2 :class vf) + (vf20 :class vf) + (vf21 :class vf) + (vf22 :class vf) + (vf23 :class vf) + (vf24 :class vf) + (vf25 :class vf) + (vf26 :class vf) + (vf27 :class vf) + (vf28 :class vf) + (vf29 :class vf) + (vf3 :class vf) + (vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + ) + (init-vf0-vector) + (set! sv-16 pd) + (let* ((v1-1 (-> *perf-stats* data 50)) + (a0-1 (-> v1-1 ctrl)) + ) + (+! (-> v1-1 count) 1) + (b! (zero? a0-1) cfg-2 :delay (nop!)) + (.mtc0 Perf 0) + (.sync.l) + (.sync.p) + (.mtpc pcr0 0) + (.mtpc pcr1 0) + (.sync.l) + (.sync.p) + (.mtc0 Perf a0-1) + ) + (.sync.l) + (.sync.p) + (label cfg-2) + 0 + (when (-> *blit-displays-work* menu-mode) + (if (not (logtest? (-> dc status) (draw-control-status hud))) + (return #f) + ) + ) + (logclear! (-> dc status) (draw-control-status on-screen)) + (when (not (logtest? (-> dc status) (draw-control-status no-draw no-draw-temp uninited))) + (let ((fg-bounds (-> (the-as foreground-work #x70000000) bounds)) + (fg-lights (-> (the-as foreground-work #x70000000) lights)) + ) + (set! tod *time-of-day-context*) + (.lvf vf16 (&-> dc origin quad)) + (.svf (&-> fg-bounds quad) vf16) + (when (sphere-in-view-frustum? fg-bounds) + (cond + ((logtest? (-> dc global-effect) (draw-control-global-effect title-light)) + (when (not (-> tod title-updated)) + (set! (-> tod title-updated) #t) + (let ((s1-0 (-> *math-camera* inv-camera-rot)) + (a1-3 (new 'stack-no-clear 'vector)) + (s2-0 (new 'stack-no-clear 'vector)) + ) + (set-vector! a1-3 0.612 0.5 -0.612 0.0) + (set-vector! s2-0 -0.696 0.174 0.696 0.0) + (vector-matrix*! (the-as vector (-> tod title-light-group)) a1-3 s1-0) + (vector-matrix*! (the-as vector (-> tod title-light-group dir1)) s2-0 s1-0) + ) + ) + (vu-lights<-light-group! fg-lights (-> tod title-light-group)) + ) + (else + (set! shadow-mask (-> dc shadow-mask)) + (let ((shadow-mask-not (lognot shadow-mask))) + (set! lev-idx-for-mood (-> dc level-index)) + (let ((light-idx (-> dc light-index)) + (lg (new 'stack-no-clear 'light-group)) + ) + (if (and (>= lev-idx-for-mood (the-as uint 6)) (< light-idx (the-as uint 20))) + (+! light-idx 20) + ) + (let ((v1-40 (the-as + mood-context + (+ (the-as uint (-> *level* level0 mood-context)) (* (the-as uint 5232) lev-idx-for-mood)) + ) + ) + ) + (cond + ((< light-idx (the-as uint 8)) + (quad-copy! (the-as pointer lg) (the-as pointer (-> v1-40 light-group light-idx)) 12) + ) + ((< light-idx (the-as uint 18)) + (quad-copy! (the-as pointer lg) (the-as pointer (-> v1-40 light-group (+ light-idx -10))) 12) + ) + ((< light-idx (the-as uint 28)) + (quad-copy! (the-as pointer lg) (the-as pointer (-> tod light-group (+ light-idx -20))) 12) + ) + ((< light-idx (the-as uint 38)) + (quad-copy! (the-as pointer lg) (the-as pointer (-> tod light-group (+ light-idx -30))) 12) + ) + ) + ) + (when (not (or (>= lev-idx-for-mood (the-as uint 6)) (zero? shadow-mask))) + (let ((packed-shadow-vals (-> dc shadow-values))) + (set! light-idx 0) + (while (< light-idx 4) + (when (nonzero? (-> lg lights light-idx mask)) + (when (not (logtest? (-> lg lights light-idx mask) shadow-mask-not)) + (let ((light-pal-idx (-> lg lights light-idx palette-index))) + (set! (-> lg lights light-idx extra x) + (* 0.0625 + (the float (logand (ash packed-shadow-vals (* -4 light-pal-idx)) 15)) + (-> lg lights light-idx extra x) + ) + ) + ) + ) + ) + (+! light-idx 1) + ) + ) + ) + (when (or (and (>= light-idx (the-as uint 10)) (< light-idx (the-as uint 18))) + (and (>= light-idx (the-as uint 30)) (< light-idx (the-as uint 38))) + ) + (dotimes (fg-light-lev-idx (-> *level* length)) + (let ((lev (-> *level* level fg-light-lev-idx))) + (when (= (-> lev status) 'active) + (let ((light-hash (-> lev light-hash))) + (set! my-origin (-> dc origin)) + (set! lev-mood (-> lev mood-context)) + (when (nonzero? light-hash) + (let ((light-lookup-result (light-hash-get-bucket-index light-hash (-> dc origin)))) + (when (!= light-lookup-result -1) + (set! light-result-bucket (-> light-hash bucket-array light-lookup-result)) + (set! index-ptr (+ (+ (-> light-result-bucket index) 0) (the-as uint (-> light-hash index-array)))) + (set! index-index 0) + (while (< index-index (the-as int (-> light-result-bucket count))) + (let* ((light-sphere (-> light-hash light-sphere-array (-> (the-as (pointer uint8) (&+ index-ptr index-index))))) + (palette-idx (-> light-sphere palette-index)) + (interp (if (= palette-idx -1) + 1.0 + (-> lev-mood times palette-idx w) + ) + ) + ) + (if (!= (* (-> light-sphere brightness) interp) 0.0) + (add-light-sphere-to-light-group lg light-sphere my-origin lev-mood) + ) + ) + (set! index-index (+ index-index 1)) + ) + ) + ) + ) + ) + ) + ) + ) + ) + (vu-lights<-light-group! fg-lights lg) + (when (and (nonzero? (-> dc shadow-ctrl)) + (-> dc shadow-ctrl) + (not (logtest? (-> dc shadow-ctrl settings flags) (shadow-flags disable-draw))) + (zero? (logand (-> dc shadow-ctrl settings flags) (shadow-flags shdf07))) + ) + (let ((target-shadow-dir (new 'stack-no-clear 'vector)) + (current-shadow-dir (-> dc shadow-ctrl settings shadow-dir)) + (shadow-dir-w (-> dc shadow-ctrl settings shadow-dir w)) + ) + (.lvf vf1 (&-> lg dir0 direction quad)) + (.lvf vf2 (&-> lg dir1 direction quad)) + (.lvf vf3 (&-> lg dir2 direction quad)) + (.lvf vf4 (&-> lg dir0 extra quad)) + (.lvf vf5 (&-> lg dir1 extra quad)) + (.lvf vf6 (&-> lg dir2 extra quad)) + (.mul.x.vf acc vf1 vf4) + (.add.mul.x.vf acc vf2 vf5 acc) + (.add.mul.x.vf vf1 vf3 vf6 acc) + (.svf (&-> target-shadow-dir quad) vf1) + (vector-normalize! target-shadow-dir -1.0) + (when (< (- (-> target-shadow-dir y)) 0.9063) + (let* ((f0-16 0.4226) + (f1-6 (-> target-shadow-dir x)) + (f1-8 (* f1-6 f1-6)) + (f2-0 (-> target-shadow-dir z)) + (f0-17 (/ f0-16 (sqrtf (+ f1-8 (* f2-0 f2-0))))) + ) + (set! (-> target-shadow-dir x) (* (-> target-shadow-dir x) f0-17)) + (set! (-> target-shadow-dir y) -0.9063) + (set! (-> target-shadow-dir z) (* (-> target-shadow-dir z) f0-17)) + ) + ) + (when (not (paused?)) + (vector-seek! current-shadow-dir target-shadow-dir (* 0.2 (-> pp clock seconds-per-frame))) + (vector-normalize! current-shadow-dir 1.0) + ) + (set! (-> dc shadow-ctrl settings shadow-dir w) shadow-dir-w) + ) + ) + ) + ) + ) + ) + (.lvf vf28 (&-> dc color-mult quad)) + (.lvf vf29 (&-> dc color-emissive quad)) + (.lvf vf2 (&-> fg-lights color 0 quad)) + (.lvf vf3 (&-> fg-lights color 1 quad)) + (.lvf vf4 (&-> fg-lights color 2 quad)) + (.lvf vf5 (&-> fg-lights ambient quad)) + (.mul.vf vf5 vf5 vf28) + (.mul.vf vf2 vf2 vf28) + (.mul.vf vf3 vf3 vf28) + (.mul.vf vf4 vf4 vf28) + (.add.vf vf5 vf5 vf29) + (.svf (&-> fg-lights color 0 quad) vf2) + (.svf (&-> fg-lights color 1 quad) vf3) + (.svf (&-> fg-lights color 2 quad) vf4) + (.svf (&-> fg-lights ambient quad) vf5) + (let ((at-0 *math-camera*)) + (.lvf vf16 (&-> at-0 plane 0 quad)) + (.lvf vf17 (&-> at-0 plane 1 quad)) + (.lvf vf18 (&-> at-0 plane 2 quad)) + (.lvf vf19 (&-> at-0 plane 3 quad)) + (.lvf vf20 (&-> at-0 guard-plane 0 quad)) + (.lvf vf21 (&-> at-0 guard-plane 1 quad)) + (.lvf vf22 (&-> at-0 guard-plane 2 quad)) + (.lvf vf23 (&-> at-0 guard-plane 3 quad)) + (.lvf vf24 (&-> at-0 camera-rot quad 0)) + (.lvf vf25 (&-> at-0 camera-rot quad 1)) + (.lvf vf26 (&-> at-0 camera-rot quad 2)) + (.lvf vf27 (&-> at-0 camera-rot trans quad)) + ) + (let ((fg-dist (-> (the-as foreground-work #x70000000) distance))) + (.lvf vf15 (&-> fg-bounds quad)) + (.mul.w.vf acc vf27 vf0) + (.add.mul.x.vf acc vf24 vf15 acc) + (.add.mul.y.vf acc vf25 vf15 acc) + (.add.mul.z.vf vf15 vf26 vf15 acc :mask #b111) + (.mul.vf vf28 vf15 vf15) + (.max.w.vf vf29 vf0 vf0) + (.add.y.vf acc vf28 vf28) + (.add.mul.z.vf vf28 vf29 vf28 acc :mask #b1) + (.sqrt.vf Q vf28 :ftf #b0) + (.sub.w.vf vf28 vf0 vf15 :mask #b1000) + (.wait.vf) + (.add.vf vf15 vf28 Q :mask #b1000) + (.svf (&-> fg-dist quad) vf15) + (when (< 0.0 (+ (-> fg-dist z) (-> dc bounds w))) + (let ((lod-idx 0)) + (let ((dist-w (-> fg-dist w))) + (set! (-> dc distance) dist-w) + (when (nonzero? (-> dc lod-set max-lod)) + (cond + ((>= (-> dc force-lod) 0) + (set! lod-idx (-> dc force-lod)) + (if (< (-> dc lod-set lod (-> dc lod-set max-lod) dist) dist-w) + (return #f) + ) + ) + (else + (while (and (< lod-idx (the-as int (-> dc lod-set max-lod))) (< (-> dc lod-set lod lod-idx dist) dist-w)) + (+! lod-idx 1) + ) + ) + ) + ) + (if (and (< (-> dc lod-set lod lod-idx dist) dist-w) (< (-> dc force-lod) 0)) + (return #f) + ) + (let ((src-lev (-> *level* level (-> dc level-index))) + (corrected-dist (* dist-w (-> *math-camera* fov-correction-factor))) + (tex-use (-> dc mgeo header texture-usage-group)) + ) + (dotimes (use-fg-idx 7) + (let ((use-idx (+ use-fg-idx 11))) + (if (not (logtest? (-> dc status) (draw-control-status no-closest-distance))) + (set! (-> src-lev closest-object-array use-idx) (fmin (-> src-lev closest-object-array use-idx) dist-w)) + ) + ) + (let ((tex-lod (cond + ((>= corrected-dist (-> tex-use data use-fg-idx data 0 dist)) + 0 + ) + ((>= corrected-dist (-> tex-use data use-fg-idx data 1 dist)) + 1 + ) + (else + 2 + ) + ) + ) + (a2-23 (+ use-fg-idx 11)) + ) + (let ((a3-10 (-> src-lev texture-mask a2-23 mask quad)) + (t0-3 (-> (the-as (pointer uint128) (+ (the-as uint tex-use) (* 48 use-fg-idx) (* tex-lod 16))) 0)) + ) + (.por a3-11 a3-10 t0-3) + ) + (set! (-> src-lev texture-mask a2-23 mask quad) a3-11) + ) + ) + ) + (if (or (guard-band-cull fg-bounds) (< dist-w (* 1.2 (-> *math-camera* d)))) + (logior! (-> dc status) (draw-control-status close-to-screen)) + (logclear! (-> dc status) (draw-control-status close-to-screen)) + ) + (logior! (-> dc status) (draw-control-status on-screen)) + (if (logtest? (-> dc status) (draw-control-status no-draw-bounds no-draw-bounds2)) + (return #f) + ) + (set! (-> pp clock) (-> sv-16 clock)) + (if (or (= lod-idx (-> dc cur-lod)) (logtest? (-> dc status) (draw-control-status lod-set))) + (foreground-draw dc dma-buf dist-w) + ) + ) + (when (and (< lod-idx (-> dc cur-lod)) (logtest? (-> dc status) (draw-control-status math-skel))) + (let ((v1-159 *matrix-engine*)) + (set! (-> v1-159 (-> v1-159 length)) (process->handle sv-16)) + (+! (-> v1-159 length) 1) + ) + ) + (lod-set! dc lod-idx) + ) + (logior! (-> dc status) (draw-control-status lod-set)) + ) + ) + ) + ) + ) + (let ((v1-163 (-> *perf-stats* data 50))) + (b! (zero? (-> v1-163 ctrl)) cfg-138 :delay (nop!)) + (.mtc0 Perf 0) + (.sync.l) + (.sync.p) + (.mfpc a0-82 pcr0) + (+! (-> v1-163 accum0) a0-82) + (.mfpc a0-84 pcr1) + (+! (-> v1-163 accum1) a0-84) + ) + (label cfg-138) + 0 + 0 + (none) + ) + ) + ) + +;; definition for symbol *hud-lights*, type vu-lights +(define *hud-lights* (new 'global 'vu-lights)) + +;; failed to figure out what this is: +(set-vector! (-> *hud-lights* direction 0) 1.0 0.0 0.0 1.0) + +;; failed to figure out what this is: +(set-vector! (-> *hud-lights* direction 1) 0.0 1.0 0.0 1.0) + +;; failed to figure out what this is: +(set-vector! (-> *hud-lights* direction 2) 0.0 0.0 1.0 1.0) + +;; failed to figure out what this is: +(set-vector! (-> *hud-lights* color 0) 0.0 0.0 0.0 1.0) + +;; failed to figure out what this is: +(set-vector! (-> *hud-lights* color 1) 0.0 0.0 0.0 1.0) + +;; failed to figure out what this is: +(set-vector! (-> *hud-lights* color 2) 0.5 0.5 0.5 1.0) + +;; failed to figure out what this is: +(set-vector! (-> *hud-lights* ambient) 0.5 0.5 0.5 1.0) + +;; definition for function dma-add-process-drawable-hud +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs none. +(defun dma-add-process-drawable-hud ((arg0 process-drawable) (arg1 draw-control) (arg2 float) (arg3 dma-buffer)) + (local-vars (a3-4 uint128)) + (logclear! (-> arg1 status) (draw-control-status on-screen)) + (when (not (logtest? (-> arg1 status) (draw-control-status no-draw no-draw-temp uninited))) + (let ((v1-6 (-> (the-as foreground-work #x70000000) lights)) + (a0-3 *hud-lights*) + ) + (set! (-> v1-6 direction 0 quad) (-> a0-3 direction 0 quad)) + (set! (-> v1-6 direction 1 quad) (-> a0-3 direction 1 quad)) + (set! (-> v1-6 direction 2 quad) (-> a0-3 direction 2 quad)) + (set! (-> v1-6 color 0 quad) (-> a0-3 color 0 quad)) + (set! (-> v1-6 color 1 quad) (-> a0-3 color 1 quad)) + (set! (-> v1-6 color 2 quad) (-> a0-3 color 2 quad)) + (set! (-> v1-6 ambient quad) (-> a0-3 ambient quad)) + ) + (lod-set! arg1 0) + (logior! (-> arg1 status) (draw-control-status on-screen)) + (foreground-draw-hud arg1 arg3 arg2) + (let ((v1-12 (-> *level* default-level)) + (a0-8 (-> arg1 mgeo header texture-usage-group)) + ) + (dotimes (a1-9 7) + (let ((a2-1 (+ a1-9 11))) + (let ((a3-3 (-> v1-12 texture-mask a2-1 mask quad)) + (t0-3 (-> a0-8 data a1-9 data 2 mask quad)) + ) + (.por a3-4 a3-3 t0-3) + ) + (set! (-> v1-12 texture-mask a2-1 mask quad) a3-4) + ) + ) + ) + ) + 0 + (none) + ) + +;; definition for function add-process-drawable +;; WARN: Return type mismatch symbol vs none. +(defun add-process-drawable ((arg0 process-drawable) (arg1 draw-control) (arg2 symbol) (arg3 dma-buffer)) + ((-> arg1 dma-add-func) arg0 arg1 arg2 arg3) + (none) + ) + +;; definition for function foreground-engine-execute +;; WARN: Return type mismatch int vs none. +;; ERROR: Unsupported inline assembly instruction kind - [cache dxwbin v1, 0] +;; ERROR: Unsupported inline assembly instruction kind - [cache dxwbin v1, 1] +(defun foreground-engine-execute ((arg0 engine) (arg1 display-frame)) + (when (> (length arg0) 0) + (let ((gp-0 (-> *display* frames (-> *display* on-screen) global-buf base))) + (when *debug-segment* + (let ((s3-0 (-> *display* frames (-> *display* on-screen) profile-array data 0)) + (v1-16 'foreground) + (s2-0 *profile-foreground-color*) + ) + (when (and *dproc* *debug-segment*) + (let ((s1-0 (-> s3-0 data (-> s3-0 count)))) + (let ((s0-0 (-> s3-0 base-time))) + (set! (-> s1-0 name) v1-16) + (set! (-> s1-0 start-time) (the-as int (- (timer-count (the-as timer-bank #x10000800)) (the-as uint s0-0)))) + ) + (set! (-> s1-0 depth) (the-as uint (-> s3-0 depth))) + (set! (-> s1-0 color) s2-0) + (set! (-> s3-0 segment (-> s3-0 depth)) s1-0) + ) + (+! (-> s3-0 count) 1) + (+! (-> s3-0 depth) 1) + (set! (-> s3-0 max-depth) (max (-> s3-0 max-depth) (-> s3-0 depth))) + ) + ) + 0 + ) + (let ((s4-1 (-> arg1 global-buf))) + (let ((v1-29 (-> s4-1 base))) + (.sync.l) + (.cache dxwbin v1-29 0) + (.sync.l) + (.cache dxwbin v1-29 1) + ) + (.sync.l) + 0 + (foreground-init) + (execute-connections arg0 s4-1) + ) + (foreground-wrapup) + (when *debug-segment* + (let ((s5-1 (-> *display* frames (-> *display* on-screen) profile-array data 0))) + (when (and *dproc* *debug-segment*) + (let* ((v1-44 (+ (-> s5-1 depth) -1)) + (s4-2 (-> s5-1 segment v1-44)) + (s3-1 (-> s5-1 base-time)) + ) + (when (>= v1-44 0) + (set! (-> s4-2 end-time) (the-as int (- (timer-count (the-as timer-bank #x10000800)) (the-as uint s3-1)))) + (+! (-> s5-1 depth) -1) + ) + ) + ) + ) + 0 + ) + (let ((v1-49 *dma-mem-usage*)) + (when (nonzero? v1-49) + (set! (-> v1-49 length) (max 36 (-> v1-49 length))) + (set! (-> v1-49 data 35 name) "pris-fragment") + (+! (-> v1-49 data 35 count) 1) + (+! (-> v1-49 data 35 used) + (&- (-> *display* frames (-> *display* on-screen) global-buf base) (the-as uint gp-0)) + ) + (set! (-> v1-49 data 35 total) (-> v1-49 data 35 used)) + ) + ) + ) + ) + 0 + (none) + ) + +;; definition (debug) for function main-debug-hook +(defun-debug main-debug-hook () + (when (not (or (= *master-mode* 'menu) (= *master-mode* 'progress))) + (let ((a0-3 *col-rend*)) + (if (-> a0-3 draw?) + (col-rend-method-9 a0-3) + ) + ) + (execute-connections *debug-engine* #f) + (draw-instance-info *stdcon*) + ) + (none) + ) + +;; definition for symbol *debug-hook*, type pair +(define *debug-hook* (cons main-debug-hook '())) + +;; definition for symbol *add-sphere*, type symbol +(define *add-sphere* #f) + +;; definition for symbol *generic-effect-mode*, type int +(define *generic-effect-mode* 0) + +;; definition for function foreground-initialize-engines +;; WARN: Return type mismatch symbol vs none. +(defun foreground-initialize-engines () + (let ((v1-0 *shadow-globals*)) + (dotimes (a0-0 2) + (let ((a1-2 (-> v1-0 bucket a0-0))) + (set! (-> a1-2 first) (the-as uint 0)) + (set! (-> a1-2 next) (the-as uint 0)) + (set! (-> a1-2 shadow-color) (if (zero? a0-0) + (new 'static 'rgba :r #xf0 :g #xf0 :b #xf0 :a #x80) + (the-as rgba (-> *setting-control* user-current spotlight-color)) + ) + ) + (set! (-> a1-2 constants) (the-as basic 0)) + ) + ) + ) + (none) + ) + +;; definition for function foreground-execute-cpu-vu0-engines +(defun foreground-execute-cpu-vu0-engines () + (let ((gp-0 (-> *display* frames (-> *display* on-screen) global-buf))) + (bones-init gp-0) + (bones-mtx-calc-execute) + (generic-merc-execute-all gp-0) + (shadow-execute-all gp-0) + ) + (lightning-draw-all) + (none) + ) + +;; definition for function real-main-draw-hook +;; WARN: Return type mismatch int vs none. +(defun real-main-draw-hook () + (local-vars (a0-96 int) (a0-98 int)) + (with-pp + (when *slow-frame-rate* + (dotimes (v1-2 #xc3500) + (nop!) + (nop!) + (nop!) + (nop!) + (nop!) + (nop!) + ) + ) + "Function to be executed to set up for engine dma" + (set! (-> *display* vu1-enable-user) (-> *display* vu1-enable-user-menu)) + (set! (-> *texture-pool* texture-enable-user) (-> *texture-pool* texture-enable-user-menu)) + (when *debug-segment* + (when (and *stats-memory* (!= *master-mode* 'menu)) + (cond + (*stats-memory-short* + (dotimes (gp-0 (-> *level* length)) + (let ((s5-0 (-> *level* level gp-0))) + (if (= (-> s5-0 status) 'active) + (print-mem-usage (compute-memory-usage! s5-0 #f) s5-0 *stdcon*) + ) + ) + ) + ) + (else + (let ((gp-1 (-> *level* level *stats-memory-level-index*))) + (if (and gp-1 (= (-> gp-1 status) 'active)) + (print-mem-usage (compute-memory-usage! gp-1 #f) gp-1 *stdcon*) + ) + ) + ) + ) + ) + (reset! *dma-mem-usage*) + ) + (foreground-initialize-engines) + (let ((gp-2 (-> pp clock))) + (if (= (-> *time-of-day-context* mode) (time-of-day-palette-id unk3)) + (set! (-> pp clock) (-> *display* bg-clock)) + (set! (-> pp clock) (-> *display* real-clock)) + ) + (if (not (paused?)) + (update-wind *wind-work* *wind-scales*) + ) + (update-time-of-day *time-of-day-context*) + (set! (-> pp clock) gp-2) + ) + (when *debug-segment* + (let ((gp-3 (-> *display* frames (-> *display* on-screen) profile-array data 0)) + (v1-55 'sky) + (s5-1 *profile-sky-color*) + ) + (when (and *dproc* *debug-segment*) + (let ((s4-0 (-> gp-3 data (-> gp-3 count)))) + (let ((s3-0 (-> gp-3 base-time))) + (set! (-> s4-0 name) v1-55) + (set! (-> s4-0 start-time) (the-as int (- (timer-count (the-as timer-bank #x10000800)) (the-as uint s3-0)))) + ) + (set! (-> s4-0 depth) (the-as uint (-> gp-3 depth))) + (set! (-> s4-0 color) s5-1) + (set! (-> gp-3 segment (-> gp-3 depth)) s4-0) + ) + (+! (-> gp-3 count) 1) + (+! (-> gp-3 depth) 1) + (set! (-> gp-3 max-depth) (max (-> gp-3 max-depth) (-> gp-3 depth))) + ) + ) + 0 + ) + (if (-> *sky-work* draw-vortex) + (draw-vortex) + (draw *sky-work*) + ) + (flush-cache 0) + (when *debug-segment* + (let ((gp-4 (-> *display* frames (-> *display* on-screen) profile-array data 0))) + (when (and *dproc* *debug-segment*) + (let* ((v1-84 (+ (-> gp-4 depth) -1)) + (s5-2 (-> gp-4 segment v1-84)) + (s4-1 (-> gp-4 base-time)) + ) + (when (>= v1-84 0) + (set! (-> s5-2 end-time) (the-as int (- (timer-count (the-as timer-bank #x10000800)) (the-as uint s4-1)))) + (+! (-> gp-4 depth) -1) + ) + ) + ) + ) + 0 + ) + (let ((gp-5 (-> pp clock))) + (if (= (-> *time-of-day-context* mode) (time-of-day-palette-id unk3)) + (set! (-> pp clock) (-> *display* bg-clock)) + (set! (-> pp clock) (-> *display* real-clock)) + ) + (when *debug-segment* + (let ((s5-3 (-> *display* frames (-> *display* on-screen) profile-array data 0)) + (v1-102 'ocean) + (s4-2 *profile-ocean-color*) + ) + (when (and *dproc* *debug-segment*) + (let ((s3-1 (-> s5-3 data (-> s5-3 count)))) + (let ((s2-0 (-> s5-3 base-time))) + (set! (-> s3-1 name) v1-102) + (set! (-> s3-1 start-time) (the-as int (- (timer-count (the-as timer-bank #x10000800)) (the-as uint s2-0)))) + ) + (set! (-> s3-1 depth) (the-as uint (-> s5-3 depth))) + (set! (-> s3-1 color) s4-2) + (set! (-> s5-3 segment (-> s5-3 depth)) s3-1) + ) + (+! (-> s5-3 count) 1) + (+! (-> s5-3 depth) 1) + (set! (-> s5-3 max-depth) (max (-> s5-3 max-depth) (-> s5-3 depth))) + ) + ) + 0 + ) + (draw! *ocean*) + (if *ocean-map* + (update-map *ocean*) + ) + (when *debug-segment* + (let ((s5-4 (-> *display* frames (-> *display* on-screen) profile-array data 0))) + (when (and *dproc* *debug-segment*) + (let* ((v1-132 (+ (-> s5-4 depth) -1)) + (s4-3 (-> s5-4 segment v1-132)) + (s3-2 (-> s5-4 base-time)) + ) + (when (>= v1-132 0) + (set! (-> s4-3 end-time) (the-as int (- (timer-count (the-as timer-bank #x10000800)) (the-as uint s3-2)))) + (+! (-> s5-4 depth) -1) + ) + ) + ) + ) + 0 + ) + (set! (-> pp clock) gp-5) + ) + (foreground-engine-execute *foreground-draw-engine* (-> *display* frames (-> *display* on-screen))) + (let ((gp-6 (-> pp clock))) + (if (= (-> *time-of-day-context* mode) (time-of-day-palette-id unk3)) + (set! (-> pp clock) (-> *display* bg-clock)) + (set! (-> pp clock) (-> *display* real-clock)) + ) + (foreground-execute-cpu-vu0-engines) + (set! (-> pp clock) gp-6) + ) + (when *add-sphere* + ) + (if (not (paused?)) + (execute-part-engine) + ) + (if (logtest? (vu1-renderer-mask sprite) (-> *display* vu1-enable-user)) + (sprite-draw *display*) + ) + (when *debug-segment* + (debug-draw-actors *level* *display-actor-marks*) + (collide-shape-draw-debug-marks) + ) + (send-events-for-touching-shapes *touching-list*) + (free-nodes *touching-list*) + (prepare *collide-rider-pool*) + (send-all! *event-queue*) + (when *debug-segment* + (let ((gp-7 (-> *display* frames (-> *display* on-screen) profile-array data 0)) + (v1-177 'update-actors) + (s5-5 *profile-update-actors-color*) + ) + (when (and *dproc* *debug-segment*) + (let ((s4-4 (-> gp-7 data (-> gp-7 count)))) + (let ((s3-3 (-> gp-7 base-time))) + (set! (-> s4-4 name) v1-177) + (set! (-> s4-4 start-time) (the-as int (- (timer-count (the-as timer-bank #x10000800)) (the-as uint s3-3)))) + ) + (set! (-> s4-4 depth) (the-as uint (-> gp-7 depth))) + (set! (-> s4-4 color) s5-5) + (set! (-> gp-7 segment (-> gp-7 depth)) s4-4) + ) + (+! (-> gp-7 count) 1) + (+! (-> gp-7 depth) 1) + (set! (-> gp-7 max-depth) (max (-> gp-7 max-depth) (-> gp-7 depth))) + ) + ) + 0 + ) + (actors-update *level*) + (when *debug-segment* + (let ((gp-8 (-> *display* frames (-> *display* on-screen) profile-array data 0))) + (when (and *dproc* *debug-segment*) + (let* ((v1-203 (+ (-> gp-8 depth) -1)) + (s5-6 (-> gp-8 segment v1-203)) + (s4-5 (-> gp-8 base-time)) + ) + (when (>= v1-203 0) + (set! (-> s5-6 end-time) (the-as int (- (timer-count (the-as timer-bank #x10000800)) (the-as uint s4-5)))) + (+! (-> gp-8 depth) -1) + ) + ) + ) + ) + 0 + ) + (when *debug-segment* + (let ((gp-9 (-> *display* frames (-> *display* on-screen) profile-array data 0)) + (v1-216 'nav) + (s5-7 *profile-nav-color*) + ) + (when (and *dproc* *debug-segment*) + (let ((s4-6 (-> gp-9 data (-> gp-9 count)))) + (let ((s3-4 (-> gp-9 base-time))) + (set! (-> s4-6 name) v1-216) + (set! (-> s4-6 start-time) (the-as int (- (timer-count (the-as timer-bank #x10000800)) (the-as uint s3-4)))) + ) + (set! (-> s4-6 depth) (the-as uint (-> gp-9 depth))) + (set! (-> s4-6 color) s5-7) + (set! (-> gp-9 segment (-> gp-9 depth)) s4-6) + ) + (+! (-> gp-9 count) 1) + (+! (-> gp-9 depth) 1) + (set! (-> gp-9 max-depth) (max (-> gp-9 max-depth) (-> gp-9 depth))) + ) + ) + 0 + ) + (level-group-method-18 *level*) + (when *debug-segment* + (let ((gp-10 (-> *display* frames (-> *display* on-screen) profile-array data 0))) + (when (and *dproc* *debug-segment*) + (let* ((v1-242 (+ (-> gp-10 depth) -1)) + (s5-8 (-> gp-10 segment v1-242)) + (s4-7 (-> gp-10 base-time)) + ) + (when (>= v1-242 0) + (set! (-> s5-8 end-time) (the-as int (- (timer-count (the-as timer-bank #x10000800)) (the-as uint s4-7)))) + (+! (-> gp-10 depth) -1) + ) + ) + ) + ) + 0 + ) + (when *debug-segment* + (let ((gp-11 (-> *display* frames (-> *display* on-screen) profile-array data 0)) + (v1-255 'background) + (s5-9 *profile-background-color*) + ) + (when (and *dproc* *debug-segment*) + (let ((s4-8 (-> gp-11 data (-> gp-11 count)))) + (let ((s3-5 (-> gp-11 base-time))) + (set! (-> s4-8 name) v1-255) + (set! (-> s4-8 start-time) (the-as int (- (timer-count (the-as timer-bank #x10000800)) (the-as uint s3-5)))) + ) + (set! (-> s4-8 depth) (the-as uint (-> gp-11 depth))) + (set! (-> s4-8 color) s5-9) + (set! (-> gp-11 segment (-> gp-11 depth)) s4-8) + ) + (+! (-> gp-11 count) 1) + (+! (-> gp-11 depth) 1) + (set! (-> gp-11 max-depth) (max (-> gp-11 max-depth) (-> gp-11 depth))) + ) + ) + 0 + ) + (init-background) + (execute-connections *background-draw-engine* (-> *display* frames (-> *display* on-screen))) + (let* ((v1-275 (-> *perf-stats* data 40)) + (a0-94 (-> v1-275 ctrl)) + ) + (+! (-> v1-275 count) 1) + (b! (zero? a0-94) cfg-116 :delay (nop!)) + (.mtc0 Perf 0) + (.sync.l) + (.sync.p) + (.mtpc pcr0 0) + (.mtpc pcr1 0) + (.sync.l) + (.sync.p) + (.mtc0 Perf a0-94) + ) + (.sync.l) + (.sync.p) + (label cfg-116) + 0 + (finish-background) + (let ((v1-278 (-> *perf-stats* data 40))) + (b! (zero? (-> v1-278 ctrl)) cfg-118 :delay (nop!)) + (.mtc0 Perf 0) + (.sync.l) + (.sync.p) + (.mfpc a0-96 pcr0) + (+! (-> v1-278 accum0) a0-96) + (.mfpc a0-98 pcr1) + (+! (-> v1-278 accum1) a0-98) + ) + (label cfg-118) + 0 + (update-wait-stats + (-> *perf-stats* data 40) + (-> *background-work* wait-to-vu0) + (the-as uint 0) + (the-as uint 0) + ) + (b! (not *debug-segment*) cfg-126 :delay (empty-form)) + (let ((gp-12 (-> *display* frames (-> *display* on-screen) profile-array data 0))) + (when (and *dproc* *debug-segment*) + (let* ((v1-295 (+ (-> gp-12 depth) -1)) + (s5-10 (-> gp-12 segment v1-295)) + (s4-9 (-> gp-12 base-time)) + ) + (when (>= v1-295 0) + (set! (-> s5-10 end-time) (the-as int (- (timer-count (the-as timer-bank #x10000800)) (the-as uint s4-9)))) + (+! (-> gp-12 depth) -1) + ) + ) + ) + ) + 0 + (label cfg-126) + (end-perf-stat-collection) + (when (and (!= *master-mode* 'menu) *stats-poly*) + (dotimes (gp-13 (-> *level* length)) + (let ((v1-307 (-> *level* level gp-13))) + (if (= (-> v1-307 status) 'active) + (collect-stats (-> v1-307 bsp)) + ) + ) + ) + (print-terrain-stats) + ) + (when (not (paused?)) + (if (and (!= *master-mode* 'menu) *stats-perf*) + (print-perf-stats) + ) + (if (and (!= *master-mode* 'menu) *stats-collide*) + (print-collide-stats) + ) + ) + (start-perf-stat-collection) + 0 + (none) + ) + ) + +;; definition for function main-draw-hook +(defun main-draw-hook () + (real-main-draw-hook) + (none) + ) + +;; definition for symbol *draw-hook*, type (function none) +(define *draw-hook* main-draw-hook) + +;; definition for function default-init-buffer +;; WARN: Return type mismatch symbol vs none. +(defun default-init-buffer ((arg0 bucket-id) (arg1 gs-zbuf) (arg2 gs-test)) + (let ((v1-6 (-> *display* frames (-> *display* on-screen) bucket-group arg0))) + (when (!= v1-6 (-> v1-6 last)) + (let* ((a0-8 (-> *display* frames (-> *display* on-screen) global-buf)) + (a3-3 (-> a0-8 base)) + ) + (let* ((t0-0 a0-8) + (t1-0 (the-as dma-packet (-> t0-0 base))) + ) + (set! (-> t1-0 dma) (new 'static 'dma-tag :qwc #xa :id (dma-tag-id cnt))) + (set! (-> t1-0 vif0) (new 'static 'vif-tag :cmd (vif-cmd flusha) :msk #x1)) + (set! (-> t1-0 vif1) (new 'static 'vif-tag :imm #xa :cmd (vif-cmd direct) :msk #x1)) + (set! (-> t0-0 base) (the-as pointer (&+ t1-0 16))) + ) + (let* ((t0-1 a0-8) + (t1-2 (the-as object (-> t0-1 base))) + ) + (set! (-> (the-as gs-gif-tag t1-2) tag) (new 'static 'gif-tag64 :nloop #x1 :eop #x1 :nreg #x9)) + (set! (-> (the-as gs-gif-tag t1-2) regs) GIF_REGS_ALL_AD) + (set! (-> t0-1 base) (&+ (the-as pointer t1-2) 16)) + ) + (let* ((t0-2 a0-8) + (t1-4 (-> t0-2 base)) + ) + (set! (-> (the-as (pointer gs-zbuf) t1-4) 0) arg1) + (set! (-> (the-as (pointer gs-reg64) t1-4) 1) (gs-reg64 zbuf-1)) + (set! (-> (the-as (pointer gs-test) t1-4) 2) arg2) + (set! (-> (the-as (pointer gs-reg64) t1-4) 3) (gs-reg64 test-1)) + (set! (-> (the-as (pointer gs-alpha) t1-4) 4) (new 'static 'gs-alpha :b #x1 :d #x1)) + (set! (-> (the-as (pointer gs-reg64) t1-4) 5) (gs-reg64 alpha-1)) + (set! (-> (the-as (pointer uint64) t1-4) 6) (the-as uint 0)) + (set! (-> (the-as (pointer gs-reg64) t1-4) 7) (gs-reg64 pabe)) + (set! (-> (the-as (pointer gs-clamp) t1-4) 8) + (new 'static 'gs-clamp :wms (gs-tex-wrap-mode clamp) :wmt (gs-tex-wrap-mode clamp)) + ) + (set! (-> (the-as (pointer gs-reg64) t1-4) 9) (gs-reg64 clamp-1)) + (set! (-> (the-as (pointer gs-tex0) t1-4) 10) (new 'static 'gs-tex0 :tbp0 #x60)) + (set! (-> (the-as (pointer gs-reg64) t1-4) 11) (gs-reg64 tex1-1)) + (set! (-> (the-as (pointer gs-texa) t1-4) 12) (new 'static 'gs-texa :ta1 #x80)) + (set! (-> (the-as (pointer gs-reg64) t1-4) 13) (gs-reg64 texa)) + (set! (-> (the-as (pointer gs-texclut) t1-4) 14) (new 'static 'gs-texclut :cbw #x4)) + (set! (-> (the-as (pointer gs-reg64) t1-4) 15) (gs-reg64 texclut)) + (set! (-> (the-as (pointer uint64) t1-4) 16) (the-as uint *fog-color*)) + (set! (-> (the-as (pointer gs-reg64) t1-4) 17) (gs-reg64 fogcol)) + (set! (-> t0-2 base) (&+ t1-4 144)) + ) + (let ((a1-18 (the-as object (-> a0-8 base)))) + (set! (-> (the-as dma-packet a1-18) dma) (new 'static 'dma-tag :id (dma-tag-id next) :addr (-> v1-6 next))) + (set! (-> (the-as dma-packet a1-18) vif0) (new 'static 'vif-tag)) + (set! (-> (the-as dma-packet a1-18) vif1) (new 'static 'vif-tag)) + (set! (-> a0-8 base) (&+ (the-as pointer a1-18) 16)) + ) + (set! (-> v1-6 next) (the-as uint a3-3)) + ) + ) + ) + (none) + ) + +;; definition for function default-end-buffer +;; WARN: Return type mismatch symbol vs none. +(defun default-end-buffer ((arg0 bucket-id) (arg1 gs-zbuf) (arg2 gs-test)) + (let ((v1-6 (-> *display* frames (-> *display* on-screen) bucket-group arg0))) + (when (!= v1-6 (-> v1-6 last)) + (let* ((a3-2 (-> *display* frames (-> *display* on-screen) global-buf)) + (a0-8 (-> a3-2 base)) + ) + (let* ((t0-1 a3-2) + (t1-0 (the-as dma-packet (-> t0-1 base))) + ) + (set! (-> t1-0 dma) (new 'static 'dma-tag :qwc #xa :id (dma-tag-id cnt))) + (set! (-> t1-0 vif0) (new 'static 'vif-tag :cmd (vif-cmd flusha) :msk #x1)) + (set! (-> t1-0 vif1) (new 'static 'vif-tag :imm #xa :cmd (vif-cmd direct) :msk #x1)) + (set! (-> t0-1 base) (the-as pointer (&+ t1-0 16))) + ) + (let* ((t0-2 a3-2) + (t1-2 (the-as object (-> t0-2 base))) + ) + (set! (-> (the-as gs-gif-tag t1-2) tag) (new 'static 'gif-tag64 :nloop #x1 :eop #x1 :nreg #x9)) + (set! (-> (the-as gs-gif-tag t1-2) regs) GIF_REGS_ALL_AD) + (set! (-> t0-2 base) (&+ (the-as pointer t1-2) 16)) + ) + (let* ((t0-3 a3-2) + (t1-4 (-> t0-3 base)) + ) + (set! (-> (the-as (pointer gs-zbuf) t1-4) 0) arg1) + (set! (-> (the-as (pointer gs-reg64) t1-4) 1) (gs-reg64 zbuf-1)) + (set! (-> (the-as (pointer gs-test) t1-4) 2) arg2) + (set! (-> (the-as (pointer gs-reg64) t1-4) 3) (gs-reg64 test-1)) + (set! (-> (the-as (pointer gs-alpha) t1-4) 4) (new 'static 'gs-alpha :b #x1 :d #x1)) + (set! (-> (the-as (pointer gs-reg64) t1-4) 5) (gs-reg64 alpha-1)) + (set! (-> (the-as (pointer uint64) t1-4) 6) (the-as uint 0)) + (set! (-> (the-as (pointer gs-reg64) t1-4) 7) (gs-reg64 pabe)) + (set! (-> (the-as (pointer gs-clamp) t1-4) 8) + (new 'static 'gs-clamp :wms (gs-tex-wrap-mode clamp) :wmt (gs-tex-wrap-mode clamp)) + ) + (set! (-> (the-as (pointer gs-reg64) t1-4) 9) (gs-reg64 clamp-1)) + (set! (-> (the-as (pointer gs-tex0) t1-4) 10) (new 'static 'gs-tex0 :tbp0 #x60)) + (set! (-> (the-as (pointer gs-reg64) t1-4) 11) (gs-reg64 tex1-1)) + (set! (-> (the-as (pointer gs-texa) t1-4) 12) (new 'static 'gs-texa :ta1 #x80)) + (set! (-> (the-as (pointer gs-reg64) t1-4) 13) (gs-reg64 texa)) + (set! (-> (the-as (pointer gs-texclut) t1-4) 14) (new 'static 'gs-texclut :cbw #x4)) + (set! (-> (the-as (pointer gs-reg64) t1-4) 15) (gs-reg64 texclut)) + (set! (-> (the-as (pointer uint64) t1-4) 16) (the-as uint *fog-color*)) + (set! (-> (the-as (pointer gs-reg64) t1-4) 17) (gs-reg64 fogcol)) + (set! (-> t0-3 base) (&+ t1-4 144)) + ) + (let ((t0-4 (-> a3-2 base))) + (let ((a1-18 (the-as object (-> a3-2 base)))) + (set! (-> (the-as dma-packet a1-18) dma) (new 'static 'dma-tag :id (dma-tag-id next))) + (set! (-> (the-as dma-packet a1-18) vif0) (new 'static 'vif-tag)) + (set! (-> (the-as dma-packet a1-18) vif1) (new 'static 'vif-tag)) + (set! (-> a3-2 base) (&+ (the-as pointer a1-18) 16)) + ) + (set! (-> (the-as dma-bucket (-> v1-6 last)) next) (the-as uint a0-8)) + (set! (-> v1-6 last) (the-as (pointer dma-tag) t0-4)) + ) + ) + ) + ) + (none) + ) + +;; definition (debug) for function screen-shot-scale +;; WARN: Return type mismatch int vs none. +(defun-debug screen-shot-scale ((arg0 int) (arg1 string)) + (set! (-> *screen-shot-work* size) arg0) + (set! (-> *screen-shot-work* name) arg1) + (set! *display-profile* #f) + 0 + (none) + ) + +;; definition (debug) for function screen-shot +;; WARN: Return type mismatch int vs none. +(defun-debug screen-shot () + (screen-shot-scale 1 "image") + 0 + (none) + ) + +;; definition for function display-frame-start +;; WARN: Return type mismatch display vs none. +(defun display-frame-start ((arg0 display) (arg1 int) (arg2 float)) + (set! (-> (the-as vif-bank #x10003c00) err me0) 1) + (set-time-ratios *display* 1.0) + (tick! (-> arg0 frame-clock)) + (tick! (-> arg0 real-frame-clock)) + (set-time-ratios *display* arg2) + (tick! (-> arg0 session-clock)) + (tick! (-> arg0 game-clock)) + (tick! (-> arg0 total-game-clock)) + (tick! (-> arg0 base-clock)) + (tick! (-> arg0 real-clock)) + (tick! (-> arg0 target-clock)) + (tick! (-> arg0 camera-clock)) + (tick! (-> arg0 entity-clock)) + (tick! (-> arg0 user0-clock)) + (tick! (-> arg0 bg-clock)) + (set! (-> arg0 bg-clock frame-counter) (the-as time-frame (mod (-> arg0 bg-clock frame-counter) #x69780))) + (tick! (-> arg0 part-clock)) + (when (and (nonzero? *screen-shot-work*) (!= (-> *screen-shot-work* count) -1)) + (let ((v1-43 (-> *screen-shot-work* size))) + (if (!= (-> *screen-shot-work* count) (* v1-43 v1-43)) + (store-image *screen-shot-work*) + ) + ) + (+! (-> *screen-shot-work* count) -1) + (if (= (-> *screen-shot-work* count) -1) + (set! (-> *screen-shot-work* size) -1) + ) + ) + (let ((s5-1 (-> arg0 frames arg1))) + (if *sync-dma* + (sync-path 0 0) + ) + (let ((v1-57 (-> s5-1 global-buf))) + (set! (-> v1-57 base) (-> v1-57 data)) + (set! (-> v1-57 end) (&-> v1-57 data-buffer (-> v1-57 allocated-length))) + ) + (let ((v1-58 (-> s5-1 global-buf))) + (&+! (-> v1-58 end) -65536) + ) + (when *debug-segment* + (let ((v1-61 (-> s5-1 debug-buf))) + (set! (-> v1-61 base) (-> v1-61 data)) + (set! (-> v1-61 end) (&-> v1-61 data-buffer (-> v1-61 allocated-length))) + ) + ) + (let ((v1-62 (-> s5-1 calc-buf))) + (set! (-> v1-62 base) (-> v1-62 data)) + (set! (-> v1-62 end) (&-> v1-62 data-buffer (-> v1-62 allocated-length))) + ) + (*pre-draw-hook* (-> s5-1 calc-buf)) + (when (not (paused?)) + (clear *stdcon1*) + (debug-reset-buffers) + (clear! *simple-sprite-system*) + ) + (set! (-> s5-1 bucket-group) (dma-buffer-add-buckets (-> s5-1 calc-buf) 327)) + ) + (service-cpads) + (service-mouse) + (execute-connections *pad-engine* #f) + (none) + ) + +;; definition for function display-frame-finish +(defun display-frame-finish ((arg0 display)) + (with-pp + (let* ((s4-0 (-> arg0 frames (-> arg0 on-screen))) + (s5-0 (-> s4-0 calc-buf)) + ) + (-> s4-0 global-buf) + (tfrag-vu1-init-buffers) + (tie-vu1-init-buffers) + (merc-vu1-init-buffers) + (emerc-vu1-init-buffers) + (generic-vu1-init-buffers) + (when (-> *texture-pool* update-sprites-flag) + (update-sprites *texture-pool*) + (particle-adgif-cache-flush) + (remap-all-particles) + ) + (when *debug-segment* + (let ((s3-0 (-> *display* frames (-> *display* on-screen) profile-array data 0)) + (v1-17 'texture) + (s2-0 *profile-texture-color*) + ) + (when (and *dproc* *debug-segment*) + (let ((s1-0 (-> s3-0 data (-> s3-0 count)))) + (let ((s0-0 (-> s3-0 base-time))) + (set! (-> s1-0 name) v1-17) + (set! (-> s1-0 start-time) (the-as int (- (timer-count (the-as timer-bank #x10000800)) (the-as uint s0-0)))) + ) + (set! (-> s1-0 depth) (the-as uint (-> s3-0 depth))) + (set! (-> s1-0 color) s2-0) + (set! (-> s3-0 segment (-> s3-0 depth)) s1-0) + ) + (+! (-> s3-0 count) 1) + (+! (-> s3-0 depth) 1) + (set! (-> s3-0 max-depth) (max (-> s3-0 max-depth) (-> s3-0 depth))) + ) + ) + 0 + ) + (let ((s3-1 (-> pp clock))) + (if (= (-> *time-of-day-context* mode) (time-of-day-palette-id unk3)) + (set! (-> pp clock) (-> *display* bg-clock)) + (set! (-> pp clock) (-> *display* real-clock)) + ) + (upload-textures *texture-pool*) + (set! (-> pp clock) s3-1) + ) + (when *debug-segment* + (let ((s3-2 (-> *display* frames (-> *display* on-screen) profile-array data 0))) + (when (and *dproc* *debug-segment*) + (let* ((v1-47 (+ (-> s3-2 depth) -1)) + (s2-1 (-> s3-2 segment v1-47)) + (s1-1 (-> s3-2 base-time)) + ) + (when (>= v1-47 0) + (set! (-> s2-1 end-time) (the-as int (- (timer-count (the-as timer-bank #x10000800)) (the-as uint s1-1)))) + (+! (-> s3-2 depth) -1) + ) + ) + ) + ) + 0 + ) + (if (-> *texture-pool* update-flag) + (update-warp-and-hud *texture-pool*) + ) + (-> *display* frames (-> *display* on-screen) global-buf) + (update-eyes) + (let ((s3-3 6) + (s2-2 324) + ) + (while (>= s2-2 s3-3) + (default-end-buffer + (the-as bucket-id s3-3) + (new 'static 'gs-zbuf :zbp #x130 :psm (gs-psm ct24)) + (new 'static 'gs-test :zte #x1 :ztst (gs-ztest greater-equal)) + ) + (+! s3-3 1) + ) + ) + (default-init-buffer + (bucket-id debug-no-zbuf1) + (new 'static 'gs-zbuf :zbp #x130 :psm (gs-psm ct24) :zmsk #x1) + (new 'static 'gs-test :zte #x1 :ztst (gs-ztest always)) + ) + (default-init-buffer + (bucket-id debug-no-zbuf2) + (new 'static 'gs-zbuf :zbp #x130 :psm (gs-psm ct24) :zmsk #x1) + (new 'static 'gs-test :zte #x1 :ztst (gs-ztest always)) + ) + (default-init-buffer + (bucket-id screen-filter) + (new 'static 'gs-zbuf :zbp #x130 :psm (gs-psm ct24) :zmsk #x1) + (new 'static 'gs-test :zte #x1 :ztst (gs-ztest always)) + ) + (*post-draw-hook* (-> arg0 frames (-> arg0 on-screen) calc-buf)) + (let* ((v1-70 s5-0) + (a0-25 (the-as object (-> v1-70 base))) + ) + (set! (-> (the-as dma-packet a0-25) dma) (new 'static 'dma-tag :id (dma-tag-id cnt))) + (set! (-> (the-as dma-packet a0-25) vif0) (new 'static 'vif-tag :imm #x148 :cmd (vif-cmd mark))) + (set! (-> (the-as dma-packet a0-25) vif1) (new 'static 'vif-tag :cmd (vif-cmd flushe) :irq #x1 :msk #x1)) + (set! (-> v1-70 base) (the-as pointer (&+ (the-as dma-packet a0-25) 16))) + ) + (dma-buffer-patch-buckets (-> s4-0 bucket-group) 327) + (let* ((v1-71 s5-0) + (a0-28 (the-as object (-> v1-71 base))) + ) + (set! (-> (the-as dma-packet a0-28) dma) (new 'static 'dma-tag :id (dma-tag-id end))) + (set! (-> (the-as (pointer int64) a0-28) 1) 0) + (set! (-> v1-71 base) (&+ (the-as pointer a0-28) 16)) + ) + (flush-cache 0) + (when (not (paused?)) + (when *stats-buffer* + (let* ((a0-31 (-> s4-0 global-buf)) + (v1-75 (-> s5-0 base)) + (a2-4 (-> s5-0 data)) + (s4-1 (-> a0-31 base)) + (s5-1 (-> a0-31 data)) + (s3-4 (-> a0-31 end)) + ) + (format *stdcon* "~0kvu1 buf = ~d~%" (&- v1-75 (the-as uint a2-4))) + (format *stdcon* "~0kglobal buf = ~d~%" (&- s4-1 (the-as uint s5-1))) + (format *stdcon* "~0kbase = #x~x~%" s4-1) + (format *stdcon* "~0kend = #x~x~%" s3-4) + ) + ) + ) + ) + arg0 + ) + ) + +;; definition for function determine-pause-mode +(defun determine-pause-mode () + (when (and (or (not *progress-process*) (can-go-back? (-> *progress-process* 0))) + (or (!= *master-mode* 'freeze) (and *debug-segment* (cpad-pressed? 0 select start) (cpad-hold? 0 l3))) + ) + (if (or (cpad-pressed? 0 select start) + (cond + ((= *master-mode* 'menu) + (cpad-pressed? 0 r3 r2 triangle circle) + ) + (*cam-layout* + #f + ) + (else + #f + ) + ) + (or (and (logtest? (-> *cpad-list* cpads 0 valid) 128) + (= *master-mode* 'game) + (>= (-> *display* base-clock frame-counter) (-> *game-info* blackout-time)) + (= (-> *setting-control* user-current bg-a) 0.0) + (and (= (-> *setting-control* user-current bg-a-force) 0.0) + (< (seconds 1003) (-> *display* real-clock frame-counter)) + ) + ) + (and (cpad-pressed? 0 r2) (or (= *master-mode* 'pause) (= *master-mode* 'menu))) + *pause-lock* + ) + ) + (toggle-pause) + ) + ) + (if (and *progress-process* (!= *master-mode* 'progress)) + (deactivate-progress) + ) + 0 + ) + +;; definition for function display-sync +(defun display-sync ((arg0 display)) + (sync-path 0 0) + (let* ((just-rendered-frame (-> arg0 last-screen)) + (current-time (shl (timer-count (the-as timer-bank #x10000800)) 48)) + (just-rendered-frame-start-time (shl (-> arg0 frames just-rendered-frame start-time) 48)) + (prev-vblank-time-1 (shl (-> arg0 vblank-start-time 0) 48)) + (prev-vblank-time-2 (shl (-> arg0 vblank-start-time 1) 48)) + ) + (set! *ticks-per-frame* (sar (- prev-vblank-time-2 prev-vblank-time-1) 48)) + (let* ((ticks-per-frame-f (the float *ticks-per-frame*)) + (frame-duration (the float (sar (- current-time (the-as uint just-rendered-frame-start-time)) 48))) + (frame-time-ratio (/ frame-duration ticks-per-frame-f)) + ) + (/ (the float (sar (- current-time (the-as uint prev-vblank-time-2)) 48)) ticks-per-frame-f) + (let ((vysnc-progress (/ (the float (sar (- current-time (the-as uint prev-vblank-time-2)) 48)) ticks-per-frame-f)) + (last-dog (fmax 1.0 (fmin 4.0 (-> *display* dog-ratio)))) + ) + (set! (-> arg0 frames just-rendered-frame run-time) (the-as time-frame (the int frame-duration))) + (set! frame-time-ratio + (cond + ((-> arg0 run-half-speed) + (syncv 0) + (if (and (< (/ (the float + (sar + (- (shl (timer-count (the-as timer-bank #x10000800)) 48) (the-as uint just-rendered-frame-start-time)) + 48 + ) + ) + ticks-per-frame-f + ) + 2.0 + ) + (< vysnc-progress 0.9) + ) + (syncv 0) + ) + 2.0 + ) + (else + (cond + ((< 1.0 frame-time-ratio) + (when (not (or (zero? prev-vblank-time-1) (zero? prev-vblank-time-2))) + (when (> (-> arg0 force-sync) 0) + (syncv 0) + (+! (-> arg0 force-sync) -1) + (let ((v1-23 (shl (timer-count (the-as timer-bank #x10000800)) 48))) + (the float (sar (- v1-23 (the-as uint just-rendered-frame-start-time)) 48)) + (set! frame-time-ratio + (/ (the float (sar (- v1-23 (the-as uint just-rendered-frame-start-time)) 48)) ticks-per-frame-f) + ) + ) + ) + ) + (set! (-> arg0 dog-count) 0.0) + ) + ((or (= last-dog 1.0) (!= (-> arg0 dog-count) 0.0)) + (if (< vysnc-progress 0.9) + (syncv 0) + ) + (set! frame-time-ratio 1.0) + (set! (-> arg0 dog-count) 0.0) + ) + (else + (when (not (or (zero? prev-vblank-time-1) (zero? prev-vblank-time-2))) + (while (or (< frame-time-ratio last-dog) (and (< 0.333 vysnc-progress) (< vysnc-progress 0.667))) + (let ((v1-34 (shl (timer-count (the-as timer-bank #x10000800)) 48))) + (set! frame-time-ratio + (/ (the float (sar (- v1-34 (the-as uint just-rendered-frame-start-time)) 48)) ticks-per-frame-f) + ) + (if (< frame-time-ratio 0.0) + (set! frame-time-ratio last-dog) + ) + (set! vysnc-progress + (/ (the float (sar (- v1-34 (the-as uint (shl (-> arg0 vblank-start-time 1) 48))) 48)) ticks-per-frame-f) + ) + ) + ) + ) + (set! (-> arg0 dog-count) 1.0) + ) + ) + frame-time-ratio + ) + ) + ) + (if (< frame-time-ratio 0.0) + (set! frame-time-ratio last-dog) + ) + ) + (let ((next-dog (fmax 1.0 frame-time-ratio)) + (frame-to-render (-> arg0 on-screen)) + ) + (let ((time-after-vsync (timer-count (the-as timer-bank #x10000800)))) + (+! (-> arg0 total-run-time) + (the-as time-frame (sar (- (shl time-after-vsync 48) (the-as uint just-rendered-frame-start-time)) 48)) + ) + (set! (-> arg0 frames frame-to-render start-time) (the-as time-frame time-after-vsync)) + ) + (set-graphics-mode) + (let ((next-dma-buf (-> arg0 frames frame-to-render calc-buf))) + (when (nonzero? (dma-buffer-length next-dma-buf)) + (+! frame-to-render 1) + (if (< 1 frame-to-render) + (set! frame-to-render 0) + ) + (set! (-> arg0 last-screen) (-> arg0 on-screen)) + (set! (-> arg0 on-screen) frame-to-render) + (when *debug-segment* + (set! *profile-interrupt-segment* (-> *display* frames (-> *display* last-screen) profile-array data 1)) + (set! (-> *profile-interrupt-segment* depth) 0) + (set! (-> *profile-interrupt-segment* max-depth) 1) + ) + (dma-buffer-send-chain (the-as dma-bank-source #x10009000) next-dma-buf) + ) + ) + (determine-pause-mode) + (when (and (nonzero? *screen-shot-work*) (= (-> *screen-shot-work* count) -1) (!= (-> *screen-shot-work* size) -1)) + (let ((v1-77 (-> *screen-shot-work* size))) + (set! (-> *screen-shot-work* count) (* v1-77 v1-77)) + ) + (set-master-mode 'pause) + ) + (display-frame-start arg0 frame-to-render next-dog) + ) + ) + ) + (none) + ) + +;; definition for function swap-display +(defun swap-display ((arg0 display)) + (display-frame-finish arg0) + (display-sync arg0) + (none) + ) + + + + diff --git a/test/decompiler/reference/jak2/engine/game/main_REF.gc b/test/decompiler/reference/jak2/engine/game/main_REF.gc new file mode 100644 index 0000000000..7cc0e2d50e --- /dev/null +++ b/test/decompiler/reference/jak2/engine/game/main_REF.gc @@ -0,0 +1,1917 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition for function set-letterbox-frames +;; WARN: Return type mismatch time-frame vs none. +(defun set-letterbox-frames ((arg0 time-frame)) + (with-pp + (set! (-> *game-info* letterbox-time) + (+ (-> *display* base-clock frame-counter) + (the int (/ (* (the float arg0) (-> *display* game-clock clock-ratio)) (-> pp clock clock-ratio))) + ) + ) + (none) + ) + ) + +;; definition for function letterbox +;; WARN: Return type mismatch pointer vs none. +;; WARN: Failed store: (s.w! (+ v1-7 8) 0) at op 30 +;; WARN: Failed store: (s.w! (+ v1-7 12) 0) at op 31 +(defun letterbox () + (with-dma-buffer-add-bucket ((s5-0 (-> *display* frames (-> *display* on-screen) global-buf)) + (bucket-id screen-filter) + ) + (draw-sprite2d-xy-absolute s5-0 0 0 512 46 (new 'static 'rgba :a #x80)) + (draw-sprite2d-xy-absolute s5-0 0 370 512 47 (new 'static 'rgba :a #x80)) + ) + (none) + ) + +;; definition for function set-blackout-frames +;; WARN: Return type mismatch int vs none. +(defun set-blackout-frames ((arg0 time-frame)) + (with-pp + (if (zero? arg0) + (set! (-> *game-info* blackout-time) (-> *display* base-clock frame-counter)) + (set! (-> *game-info* blackout-time) + (the-as + time-frame + (max + (-> *game-info* blackout-time) + (+ (-> *display* base-clock frame-counter) + (the int (/ (* (the float arg0) (-> *display* game-clock clock-ratio)) (-> pp clock clock-ratio))) + arg0 + ) + ) + ) + ) + ) + (none) + ) + ) + +;; definition for function blackout +;; WARN: Return type mismatch pointer vs none. +;; WARN: Failed store: (s.w! (+ v1-6 8) 0) at op 21 +;; WARN: Failed store: (s.w! (+ v1-6 12) 0) at op 22 +(defun blackout () + (with-dma-buffer-add-bucket ((s5-0 (-> *display* frames (-> *display* on-screen) global-buf)) + (bucket-id debug-no-zbuf2) + ) + (draw-sprite2d-xy-absolute s5-0 0 0 512 416 (new 'static 'rgba :a #x80)) + ) + (none) + ) + +;; definition for function paused? +(defun paused? () + (or (= *master-mode* 'pause) (= *master-mode* 'progress) (= *master-mode* 'menu) (= *master-mode* 'freeze)) + ) + +;; definition for function movie? +(defun movie? () + (logtest? (-> *kernel-context* prevent-from-run) (process-mask movie)) + ) + +;; definition for function demo? +(defun demo? () + (or (= *kernel-boot-message* 'demo) (= *kernel-boot-message* 'demo-shared)) + ) + +;; definition for symbol *last-master-mode*, type symbol +(define *last-master-mode* 'game) + +;; definition for function set-master-mode +;; WARN: Return type mismatch int vs none. +(defun set-master-mode ((arg0 symbol)) + (when (!= arg0 *master-mode*) + (set! *last-master-mode* *master-mode*) + (set! *master-mode* arg0) + (case *master-mode* + (('pause) + (if (not *debug-pause*) + (logior! (-> *setting-control* user-default process-mask) (process-mask pause)) + ) + (logclear! (-> *setting-control* user-default process-mask) (process-mask freeze menu)) + (set! *pause-lock* #f) + (sound-group-pause (sound-group sfx music dialog sog3 ambient dialog2 sog6 sog7)) + (set! (-> *game-info* pause-start-time) (-> *display* real-clock frame-counter)) + ) + (('freeze) + (logior! (-> *setting-control* user-default process-mask) (process-mask freeze)) + (logclear! (-> *setting-control* user-default process-mask) (process-mask pause menu)) + (sound-group-pause (sound-group sfx ambient)) + (set! (-> *game-info* pause-start-time) (-> *display* real-clock frame-counter)) + ) + (('menu) + (logior! (-> *setting-control* user-default process-mask) (process-mask menu)) + (logclear! (-> *setting-control* user-default process-mask) (process-mask freeze pause progress)) + (sound-group-pause (sound-group sfx music dialog sog3 ambient dialog2 sog6 sog7)) + (set! *pause-lock* #f) + ) + (('progress) + (logclear! (-> *setting-control* user-default process-mask) (process-mask freeze pause menu)) + (sound-group-pause (sound-group sfx music dialog sog3 ambient dialog2 sog6 sog7)) + (when (not *progress-process*) + (activate-progress *dproc* 'main) + (if (not *progress-process*) + (set-master-mode 'game) + ) + ) + (set! (-> *game-info* pause-start-time) (-> *display* real-clock frame-counter)) + ) + (('game) + (logclear! (-> *setting-control* user-default process-mask) (process-mask freeze pause menu)) + (sound-group-continue (sound-group sfx music dialog sog3 ambient dialog2 sog6 sog7)) + ) + ) + (apply-settings *setting-control*) + ) + (if *debug-segment* + (menu-respond-to-pause) + ) + 0 + (none) + ) + +;; definition for function pause-allowed? +(defun pause-allowed? () + (not (or (< (-> *display* base-clock frame-counter) (-> *game-info* blackout-time)) + (!= (-> *setting-control* user-current bg-a) 0.0) + (!= (-> *setting-control* user-current bg-a-force) 0.0) + (not (-> *setting-control* user-current allow-pause)) + (handle->process (-> *game-info* auto-save-proc)) + (= *master-mode* 'freeze) + (not *target*) + *master-exit* + (not *common-text*) + ) + ) + ) + +;; definition for function toggle-pause +(defun toggle-pause () + (case *master-mode* + (('game) + (set-master-mode + (cond + ((and (logtest? (-> *cpad-list* cpads 0 valid) 128) + *target* + (>= (-> *display* base-clock frame-counter) (-> *game-info* blackout-time)) + (= (-> *setting-control* user-current bg-a) 0.0) + (and (= (-> *setting-control* user-current bg-a-force) 0.0) + (< (seconds 1003) (-> *display* real-clock frame-counter)) + ) + ) + (if (or *progress-process* (not (-> *setting-control* user-current allow-pause))) + *master-mode* + 'pause + ) + ) + ((and (cpad-pressed? 0 select start) (cpad-hold? 0 l3) *debug-segment*) + 'menu + ) + ((and (or (cpad-hold? 0 select) (cpad-hold? 0 r2)) *debug-segment*) + 'pause + ) + ((and (not *debug-segment*) (zero? (logand (-> *cpad-list* cpads 0 button0-abs 0) (pad-buttons start)))) + (if (pause-allowed?) + 'pause + *master-mode* + ) + ) + ((not (progress-allowed?)) + (if (pause-allowed?) + 'pause + *master-mode* + ) + ) + ((cpad-hold? 0 start) + 'progress + ) + (else + *master-mode* + ) + ) + ) + ) + (('menu) + (set-master-mode (cond + ((and *debug-segment* (cpad-hold? 0 l3) (cpad-pressed? 0 select start)) + 'menu + ) + ((cpad-hold? 0 select r2) + (if *debug-segment* + 'pause + *master-mode* + ) + ) + ((cpad-hold? 0 r3 r2 triangle circle) + 'game + ) + ((cpad-hold? 0 start) + 'game + ) + (else + *master-mode* + ) + ) + ) + (set! *pause-lock* #f) + ) + (('pause) + (set-master-mode (cond + ((and (cpad-pressed? 0 select start) (cpad-hold? 0 l3) *debug-segment*) + 'menu + ) + ((and (not *debug-segment*) (cpad-hold? 0 select)) + 'game + ) + ((and *cheat-mode* (cpad-hold? 0 select r2)) + 'game + ) + ((cpad-hold? 0 start) + 'game + ) + (else + *master-mode* + ) + ) + ) + (set! *pause-lock* (and *cheat-mode* (cpad-hold? 0 r2))) + ) + (('freeze) + (set-master-mode (if (and (cpad-pressed? 0 select start) (cpad-hold? 0 l3) *debug-segment*) + 'menu + *master-mode* + ) + ) + ) + (('progress) + (if (cpad-hold? 0 start) + (hide-progress-screen) + ) + (set! *pause-lock* (and *cheat-mode* (cpad-hold? 0 r2))) + ) + ) + 0 + ) + +;; definition for symbol *screen-filter*, type screen-filter +(define *screen-filter* (new 'static 'screen-filter :draw? #f :bucket (bucket-id screen-filter))) + +;; definition for method 9 of type screen-filter +;; WARN: Return type mismatch int vs none. +;; WARN: Failed store: (s.w! (+ v1-16 8) 0) at op 85 +;; WARN: Failed store: (s.w! (+ v1-16 12) 0) at op 86 +(defmethod draw screen-filter ((obj screen-filter)) + (local-vars (v1-1 float)) + (rlet ((vf0 :class vf) + (vf1 :class vf) + (vf2 :class vf) + (vf3 :class vf) + (vf4 :class vf) + ) + (init-vf0-vector) + (when (not (paused?)) + (.lvf vf4 (&-> obj extra quad)) + (.lvf vf1 (&-> obj color-dest quad)) + (.lvf vf2 (&-> obj color quad)) + (.sub.vf vf3 vf1 vf2) + (.add.x.vf vf4 vf4 vf4 :mask #b10) + (.min.w.vf vf4 vf4 vf0 :mask #b10) + (.max.y.vf vf4 vf4 vf0 :mask #b10) + (.mul.y.vf vf3 vf3 vf4) + (.add.vf vf1 vf2 vf3) + (.svf (&-> obj extra quad) vf4) + (.svf (&-> obj color quad) vf1) + (.mov v1-1 vf1) + ) + (with-dma-buffer-add-bucket ((s4-0 (-> *display* frames (-> *display* on-screen) global-buf)) + (-> obj bucket) + ) + (let ((v1-7 s4-0)) + (let ((a0-2 (the-as object (-> v1-7 base)))) + (set! (-> (the-as dma-packet a0-2) dma) (new 'static 'dma-tag :qwc #x2 :id (dma-tag-id cnt))) + (set! (-> (the-as dma-packet a0-2) vif0) (new 'static 'vif-tag)) + (set! (-> (the-as dma-packet a0-2) vif1) (new 'static 'vif-tag :imm #x2 :cmd (vif-cmd direct) :msk #x1)) + (set! (-> v1-7 base) (&+ (the-as pointer a0-2) 16)) + ) + ) + (let ((v1-8 s4-0)) + (let ((a0-4 (the-as object (-> v1-8 base)))) + (set! (-> (the-as gs-gif-tag a0-4) tag) (new 'static 'gif-tag64 :nloop #x1 :eop #x1 :nreg #x1)) + (set! (-> (the-as gs-gif-tag a0-4) regs) GIF_REGS_ALL_AD) + (set! (-> v1-8 base) (&+ (the-as pointer a0-4) 16)) + ) + ) + (let ((v1-9 s4-0)) + (let ((a0-6 (-> v1-9 base))) + (set! (-> (the-as (pointer gs-test) a0-6) 0) + (new 'static 'gs-test :ate #x1 :afail #x3 :zte #x1 :ztst (gs-ztest always)) + ) + (set! (-> (the-as (pointer gs-reg64) a0-6) 1) (gs-reg64 test-1)) + (set! (-> v1-9 base) (&+ a0-6 16)) + ) + ) + (let ((t1-0 (new 'static 'rgba + :r (the int (-> obj color x)) + :g (the int (-> obj color y)) + :b (the int (-> obj color z)) + :a (the int (-> obj color w)) + ) + ) + ) + (draw-sprite2d-xy s4-0 -256 -208 512 416 t1-0) + ) + ) + 0 + (none) + ) + ) + +;; definition for method 10 of type screen-filter +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs none. +(defmethod setup screen-filter ((obj screen-filter) (arg0 vector) (arg1 vector) (arg2 float) (arg3 bucket-id)) + (set! (-> obj draw?) #t) + (set! (-> obj color quad) (-> arg0 quad)) + (set! (-> obj color-src quad) (-> arg0 quad)) + (set! (-> obj color-dest quad) (-> arg1 quad)) + (set! (-> obj extra x) arg2) + (set! (-> obj extra y) 0.0) + (set! (-> obj bucket) arg3) + 0 + (none) + ) + +;; definition for method 11 of type screen-filter +;; WARN: Return type mismatch int vs none. +(defmethod disable screen-filter ((obj screen-filter)) + (set! (-> obj draw?) #f) + 0 + (none) + ) + +;; definition for symbol *cheat-temp*, type (pointer int32) +(define *cheat-temp* (the-as (pointer int32) (malloc 'global 20))) + +;; definition for symbol *master-exit*, type symbol +(define *master-exit* #f) + +;; definition for symbol *progress-cheat*, type symbol +(define *progress-cheat* #f) + +;; definition for symbol *first-boot*, type symbol +(define *first-boot* #t) + +;; definition for function main-cheats +;; WARN: Failed store: (s.w! (+ v1-77 8) 0) at op 163 +;; WARN: Failed store: (s.w! (+ v1-77 12) 0) at op 164 +(defun main-cheats () + (when (and (cpad-hold? 0 l3) (or *cheat-mode* (not (demo?)))) + ((lambda () + (when (nonzero? (-> *cpad-list* cpads 0 button0-rel 0)) + (let ((v1-5 (-> *cheat-temp* 0))) + (cond + ((zero? v1-5) + (cond + ((cpad-pressed? 0 up) + (+! (-> *cheat-temp* 0) 1) + ) + (else + (set! (-> *cheat-temp* 0) 0) + 0 + ) + ) + ) + ((= v1-5 1) + (cond + ((cpad-pressed? 0 up) + (+! (-> *cheat-temp* 0) 1) + ) + (else + (set! (-> *cheat-temp* 0) 0) + 0 + ) + ) + ) + ((= v1-5 2) + (cond + ((cpad-pressed? 0 down) + (+! (-> *cheat-temp* 0) 1) + ) + (else + (set! (-> *cheat-temp* 0) 0) + 0 + ) + ) + ) + ((= v1-5 3) + (cond + ((cpad-pressed? 0 down) + (+! (-> *cheat-temp* 0) 1) + ) + (else + (set! (-> *cheat-temp* 0) 0) + 0 + ) + ) + ) + ((= v1-5 4) + (cond + ((cpad-pressed? 0 left) + (+! (-> *cheat-temp* 0) 1) + ) + (else + (set! (-> *cheat-temp* 0) 0) + 0 + ) + ) + ) + ((= v1-5 5) + (cond + ((cpad-pressed? 0 right) + (+! (-> *cheat-temp* 0) 1) + ) + (else + (set! (-> *cheat-temp* 0) 0) + 0 + ) + ) + ) + ((= v1-5 6) + (cond + ((cpad-pressed? 0 left) + (+! (-> *cheat-temp* 0) 1) + ) + (else + (set! (-> *cheat-temp* 0) 0) + 0 + ) + ) + ) + ((= v1-5 7) + (cond + ((cpad-pressed? 0 right) + (+! (-> *cheat-temp* 0) 1) + ) + (else + (set! (-> *cheat-temp* 0) 0) + 0 + ) + ) + ) + ((= v1-5 8) + (cond + ((cpad-pressed? 0 x) + (+! (-> *cheat-temp* 0) 1) + ) + (else + (set! (-> *cheat-temp* 0) 0) + 0 + ) + ) + ) + ((= v1-5 9) + (cond + ((cpad-pressed? 0 x) + (+! (-> *cheat-temp* 0) 1) + ) + (else + (set! (-> *cheat-temp* 0) 0) + 0 + ) + ) + ) + ((= v1-5 10) + (cond + ((cpad-pressed? 0 square) + (+! (-> *cheat-temp* 0) 1) + ) + (else + (set! (-> *cheat-temp* 0) 0) + 0 + ) + ) + ) + ((= v1-5 11) + (cond + ((cpad-pressed? 0 circle) + (+! (-> *cheat-temp* 0) 1) + ) + (else + (set! (-> *cheat-temp* 0) 0) + 0 + ) + ) + ) + ((= v1-5 12) + (cond + ((cpad-pressed? 0 square) + (+! (-> *cheat-temp* 0) 1) + ) + (else + (set! (-> *cheat-temp* 0) 0) + 0 + ) + ) + ) + ((= v1-5 13) + (cond + ((cpad-pressed? 0 circle) + (logclear! (-> *cpad-list* cpads 0 button0-abs 0) (pad-buttons r1)) + (logclear! (-> *cpad-list* cpads 0 button0-rel 0) (pad-buttons r1)) + (set! *cheat-mode* (not *cheat-mode*)) + (if *cheat-mode* + (sound-play-by-spec (static-sound-spec "menu-pick" :fo-curve 1) (new-sound-id) (the-as vector #t)) + (sound-play-by-spec (static-sound-spec "menu-back" :fo-curve 1) (new-sound-id) (the-as vector #t)) + ) + (set! (-> *cheat-temp* 0) 0) + 0 + ) + (else + (set! (-> *cheat-temp* 0) 0) + 0 + ) + ) + ) + ) + ) + ) + (when *cheat-mode* + (when (nonzero? (-> *cpad-list* cpads 0 button0-rel 0)) + (let ((v1-146 (-> *cheat-temp* 1))) + (cond + ((zero? v1-146) + (cond + ((cpad-pressed? 0 circle) + (+! (-> *cheat-temp* 1) 1) + ) + (else + (set! (-> *cheat-temp* 1) 0) + 0 + ) + ) + ) + ((= v1-146 1) + (cond + ((cpad-pressed? 0 square) + (+! (-> *cheat-temp* 1) 1) + ) + (else + (set! (-> *cheat-temp* 1) 0) + 0 + ) + ) + ) + ((= v1-146 2) + (cond + ((cpad-pressed? 0 circle) + (+! (-> *cheat-temp* 1) 1) + ) + (else + (set! (-> *cheat-temp* 1) 0) + 0 + ) + ) + ) + ((= v1-146 3) + (cond + ((cpad-pressed? 0 square) + (+! (-> *cheat-temp* 1) 1) + ) + (else + (set! (-> *cheat-temp* 1) 0) + 0 + ) + ) + ) + ((= v1-146 4) + (cond + ((cpad-pressed? 0 x) + (+! (-> *cheat-temp* 1) 1) + ) + (else + (set! (-> *cheat-temp* 1) 0) + 0 + ) + ) + ) + ((= v1-146 5) + (cond + ((cpad-pressed? 0 x) + (+! (-> *cheat-temp* 1) 1) + ) + (else + (set! (-> *cheat-temp* 1) 0) + 0 + ) + ) + ) + ((= v1-146 6) + (cond + ((cpad-pressed? 0 right) + (+! (-> *cheat-temp* 1) 1) + ) + (else + (set! (-> *cheat-temp* 1) 0) + 0 + ) + ) + ) + ((= v1-146 7) + (cond + ((cpad-pressed? 0 left) + (+! (-> *cheat-temp* 1) 1) + ) + (else + (set! (-> *cheat-temp* 1) 0) + 0 + ) + ) + ) + ((= v1-146 8) + (cond + ((cpad-pressed? 0 right) + (+! (-> *cheat-temp* 1) 1) + ) + (else + (set! (-> *cheat-temp* 1) 0) + 0 + ) + ) + ) + ((= v1-146 9) + (cond + ((cpad-pressed? 0 left) + (+! (-> *cheat-temp* 1) 1) + ) + (else + (set! (-> *cheat-temp* 1) 0) + 0 + ) + ) + ) + ((= v1-146 10) + (cond + ((cpad-pressed? 0 down) + (+! (-> *cheat-temp* 1) 1) + ) + (else + (set! (-> *cheat-temp* 1) 0) + 0 + ) + ) + ) + ((= v1-146 11) + (cond + ((cpad-pressed? 0 down) + (+! (-> *cheat-temp* 1) 1) + ) + (else + (set! (-> *cheat-temp* 1) 0) + 0 + ) + ) + ) + ((= v1-146 12) + (cond + ((cpad-pressed? 0 up) + (+! (-> *cheat-temp* 1) 1) + ) + (else + (set! (-> *cheat-temp* 1) 0) + 0 + ) + ) + ) + ((= v1-146 13) + (cond + ((cpad-pressed? 0 up) + (logclear! (-> *cpad-list* cpads 0 button0-abs 0) (pad-buttons r1)) + (logclear! (-> *cpad-list* cpads 0 button0-rel 0) (pad-buttons r1)) + (set! *cheat-mode* (if (= *cheat-mode* 'debug) + #t + 'debug + ) + ) + (if (= *cheat-mode* 'debug) + (sound-play-by-spec (static-sound-spec "menu-pick" :fo-curve 1) (new-sound-id) (the-as vector #t)) + (sound-play-by-spec (static-sound-spec "menu-back" :fo-curve 1) (new-sound-id) (the-as vector #t)) + ) + (set! (-> *cheat-temp* 1) 0) + 0 + ) + (else + (set! (-> *cheat-temp* 1) 0) + 0 + ) + ) + ) + ) + ) + ) + ) + (none) + ) + ) + ((lambda () + (case (scf-get-territory) + ((2) + (when (nonzero? (-> *cpad-list* cpads 0 button0-rel 0)) + (let ((v1-7 (-> *cheat-temp* 2))) + (cond + ((zero? v1-7) + (cond + ((cpad-pressed? 0 l1) + (+! (-> *cheat-temp* 2) 1) + ) + (else + (set! (-> *cheat-temp* 2) 0) + 0 + ) + ) + ) + ((= v1-7 1) + (cond + ((cpad-pressed? 0 r1) + (+! (-> *cheat-temp* 2) 1) + ) + (else + (set! (-> *cheat-temp* 2) 0) + 0 + ) + ) + ) + ((= v1-7 2) + (cond + ((cpad-pressed? 0 l1) + (+! (-> *cheat-temp* 2) 1) + ) + (else + (set! (-> *cheat-temp* 2) 0) + 0 + ) + ) + ) + ((= v1-7 3) + (cond + ((cpad-pressed? 0 r1) + (+! (-> *cheat-temp* 2) 1) + ) + (else + (set! (-> *cheat-temp* 2) 0) + 0 + ) + ) + ) + ((= v1-7 4) + (cond + ((cpad-pressed? 0 triangle) + (+! (-> *cheat-temp* 2) 1) + ) + (else + (set! (-> *cheat-temp* 2) 0) + 0 + ) + ) + ) + ((= v1-7 5) + (cond + ((cpad-pressed? 0 circle) + (+! (-> *cheat-temp* 2) 1) + ) + (else + (set! (-> *cheat-temp* 2) 0) + 0 + ) + ) + ) + ((= v1-7 6) + (cond + ((cpad-pressed? 0 x) + (+! (-> *cheat-temp* 2) 1) + ) + (else + (set! (-> *cheat-temp* 2) 0) + 0 + ) + ) + ) + ((= v1-7 7) + (cond + ((cpad-pressed? 0 square) + (logclear! (-> *cpad-list* cpads 0 button0-abs 0) (pad-buttons r1)) + (logclear! (-> *cpad-list* cpads 0 button0-rel 0) (pad-buttons r1)) + (set! *progress-cheat* (if *progress-cheat* + #f + 'language + ) + ) + (if *progress-cheat* + (sound-play-by-spec (static-sound-spec "menu-pick" :fo-curve 1) (new-sound-id) (the-as vector #t)) + (sound-play-by-spec (static-sound-spec "menu-back" :fo-curve 1) (new-sound-id) (the-as vector #t)) + ) + (set! (-> *cheat-temp* 2) 0) + 0 + ) + (else + (set! (-> *cheat-temp* 2) 0) + 0 + ) + ) + ) + ) + ) + ) + ) + ) + (when *debug-segment* + (when (nonzero? (-> *cpad-list* cpads 0 button0-rel 0)) + (let ((v1-95 (-> *cheat-temp* 3))) + (cond + ((zero? v1-95) + (cond + ((cpad-pressed? 0 x) + (+! (-> *cheat-temp* 3) 1) + ) + (else + (set! (-> *cheat-temp* 3) 0) + 0 + ) + ) + ) + ((= v1-95 1) + (cond + ((cpad-pressed? 0 square) + (+! (-> *cheat-temp* 3) 1) + ) + (else + (set! (-> *cheat-temp* 3) 0) + 0 + ) + ) + ) + ((= v1-95 2) + (cond + ((cpad-pressed? 0 triangle) + (+! (-> *cheat-temp* 3) 1) + ) + (else + (set! (-> *cheat-temp* 3) 0) + 0 + ) + ) + ) + ((= v1-95 3) + (cond + ((cpad-pressed? 0 circle) + (+! (-> *cheat-temp* 3) 1) + ) + (else + (set! (-> *cheat-temp* 3) 0) + 0 + ) + ) + ) + ((= v1-95 4) + (cond + ((cpad-pressed? 0 x) + (+! (-> *cheat-temp* 3) 1) + ) + (else + (set! (-> *cheat-temp* 3) 0) + 0 + ) + ) + ) + ((= v1-95 5) + (cond + ((cpad-pressed? 0 square) + (+! (-> *cheat-temp* 3) 1) + ) + (else + (set! (-> *cheat-temp* 3) 0) + 0 + ) + ) + ) + ((= v1-95 6) + (cond + ((cpad-pressed? 0 triangle) + (+! (-> *cheat-temp* 3) 1) + ) + (else + (set! (-> *cheat-temp* 3) 0) + 0 + ) + ) + ) + ((= v1-95 7) + (cond + ((cpad-pressed? 0 circle) + (logclear! (-> *cpad-list* cpads 0 button0-abs 0) (pad-buttons r1)) + (logclear! (-> *cpad-list* cpads 0 button0-rel 0) (pad-buttons r1)) + (set! *progress-cheat* (if *progress-cheat* + #f + 'pal + ) + ) + (if *progress-cheat* + (sound-play-by-spec (static-sound-spec "menu-pick" :fo-curve 1) (new-sound-id) (the-as vector #t)) + (sound-play-by-spec (static-sound-spec "menu-back" :fo-curve 1) (new-sound-id) (the-as vector #t)) + ) + (set! (-> *cheat-temp* 3) 0) + 0 + ) + (else + (set! (-> *cheat-temp* 3) 0) + 0 + ) + ) + ) + ) + ) + ) + (when (nonzero? (-> *cpad-list* cpads 1 button0-rel 0)) + (let ((v1-181 (-> *cheat-temp* 5))) + (cond + ((zero? v1-181) + (cond + ((cpad-pressed? 1 triangle) + (+! (-> *cheat-temp* 5) 1) + ) + (else + (set! (-> *cheat-temp* 5) 0) + 0 + ) + ) + ) + ((= v1-181 1) + (cond + ((cpad-pressed? 1 x) + (+! (-> *cheat-temp* 5) 1) + ) + (else + (set! (-> *cheat-temp* 5) 0) + 0 + ) + ) + ) + ((= v1-181 2) + (cond + ((cpad-pressed? 1 circle) + (+! (-> *cheat-temp* 5) 1) + ) + (else + (set! (-> *cheat-temp* 5) 0) + 0 + ) + ) + ) + ((= v1-181 3) + (cond + ((cpad-pressed? 1 square) + (+! (-> *cheat-temp* 5) 1) + ) + (else + (set! (-> *cheat-temp* 5) 0) + 0 + ) + ) + ) + ((= v1-181 4) + (cond + ((cpad-pressed? 1 triangle) + (+! (-> *cheat-temp* 5) 1) + ) + (else + (set! (-> *cheat-temp* 5) 0) + 0 + ) + ) + ) + ((= v1-181 5) + (cond + ((cpad-pressed? 1 x) + (+! (-> *cheat-temp* 5) 1) + ) + (else + (set! (-> *cheat-temp* 5) 0) + 0 + ) + ) + ) + ((= v1-181 6) + (cond + ((cpad-pressed? 1 circle) + (+! (-> *cheat-temp* 5) 1) + ) + (else + (set! (-> *cheat-temp* 5) 0) + 0 + ) + ) + ) + ((= v1-181 7) + (cond + ((cpad-pressed? 1 square) + (logclear! (-> *cpad-list* cpads 0 button0-abs 0) (pad-buttons r1)) + (logclear! (-> *cpad-list* cpads 0 button0-rel 0) (pad-buttons r1)) + (set! *cheat-mode* (if (= *cheat-mode* 'camera) + #f + 'camera + ) + ) + (cond + (*cheat-mode* + (if (not *external-cam-mode*) + (external-cam-reset!) + ) + (set! *external-cam-mode* 'pad-1) + (sound-play-by-spec (static-sound-spec "menu-pick" :fo-curve 1) (new-sound-id) (the-as vector #t)) + ) + (else + (set! *external-cam-mode* #f) + (sound-play-by-spec (static-sound-spec "menu-back" :fo-curve 1) (new-sound-id) (the-as vector #t)) + ) + ) + (set! (-> *cheat-temp* 5) 0) + 0 + ) + (else + (set! (-> *cheat-temp* 5) 0) + 0 + ) + ) + ) + ) + ) + ) + ) + (none) + ) + ) + ) + (if (and *cheat-mode* (not *debug-segment*) (cpad-hold? 1 l3)) + ((lambda () + (cond + ((cpad-pressed? 1 x) + (send-event *target* 'get-pickup 13 #x447a0000) + (send-event *target* 'get-pickup 14 #x447a0000) + (send-event *target* 'get-pickup 15 #x447a0000) + (send-event *target* 'get-pickup 16 #x447a0000) + (send-event *target* 'get-pickup 7 #x447a0000) + (send-event *target* 'get-pickup 22 #x447a0000) + (send-event *target* 'get-pickup 21 #x447a0000) + (set! (-> *game-info* features) + (logior (game-feature + gun + gun-yellow + gun-red + gun-blue + gun-dark + board + darkjak + darkjak-bomb0 + darkjak-bomb1 + darkjak-invinc + darkjak-giant + ) + (-> *game-info* features) + ) + ) + (logior! + (-> *game-info* debug-features) + (game-feature gun gun-yellow gun-red gun-blue gun-dark board darkjak) + ) + (sound-play-by-spec (static-sound-spec "menu-pick" :fo-curve 1) (new-sound-id) (the-as vector #t)) + ) + ((cpad-pressed? 1 square) + (set! (-> *level* disk-load-timing?) (not (-> *level* disk-load-timing?))) + (if (-> *level* disk-load-timing?) + (sound-play-by-spec (static-sound-spec "menu-pick" :fo-curve 1) (new-sound-id) (the-as vector #t)) + (sound-play-by-spec (static-sound-spec "menu-back" :fo-curve 1) (new-sound-id) (the-as vector #t)) + ) + ) + ((cpad-pressed? 1 r1) + (set! *display-scene-control* (logxor *display-scene-control* (scene-controls bounds-spheres))) + (if (logtest? *display-scene-control* (scene-controls bounds-spheres)) + (sound-play-by-spec (static-sound-spec "menu-pick" :fo-curve 1) (new-sound-id) (the-as vector #t)) + (sound-play-by-spec (static-sound-spec "menu-back" :fo-curve 1) (new-sound-id) (the-as vector #t)) + ) + ) + ((cpad-pressed? 1 circle) + (set! *display-bug-report* (not *display-bug-report*)) + (if *display-bug-report* + (sound-play-by-spec (static-sound-spec "menu-pick" :fo-curve 1) (new-sound-id) (the-as vector #t)) + (sound-play-by-spec (static-sound-spec "menu-back" :fo-curve 1) (new-sound-id) (the-as vector #t)) + ) + ) + ) + (none) + ) + ) + ) + (if *display-bug-report* + (position->stream *stdcon* '*stdcon* #t) + ) + (when (and (= *cheat-mode* 'debug) (not *debug-segment*)) + (when (and (cpad-hold? 0 l1) (cpad-hold? 0 l2) (cpad-hold? 0 r1) (cpad-pressed? 0 r2)) + (if *target* + (stop 'debug) + (start 'play (get-current-continue-forced *game-info*)) + ) + ) + (if (and (cpad-hold? 0 left) (cpad-hold? 0 up) (cpad-pressed? 0 select)) + (initialize! *game-info* 'game (the-as game-save #f) "title-restart") + ) + (if (cpad-pressed? 1 r3) + (inspect global) + ) + (when (cpad-hold? 1 r3) + (with-dma-buffer-add-bucket ((s5-1 (if *debug-segment* + (-> *display* frames (-> *display* on-screen) debug-buf) + (-> *display* frames (-> *display* on-screen) global-buf) + ) + ) + (bucket-id debug2) + ) + (show-iop-memory s5-1) + ) + ) + (if (cpad-pressed? 1 triangle) + (set! *display-level-border* (not *display-level-border*)) + ) + ) + (when (demo?) + (let ((gp-2 (scf-get-timeout)) + (v1-93 (scf-get-inactive-timeout)) + ) + (when (and (or (and (nonzero? gp-2) + (>= (+ -300000 (-> *display* real-clock frame-counter)) (the int (* 300.0 (the float gp-2)))) + ) + (and (nonzero? v1-93) + (or (and (>= (- (-> *display* base-clock frame-counter) (-> *cpad-list* cpads 0 change-time)) + (the int (* 300.0 (the float v1-93))) + ) + (>= (- (-> *display* game-clock frame-counter) (the-as int (-> *game-info* kiosk-timeout))) + (the int (* 300.0 (the float v1-93))) + ) + ) + (and (or (= *master-mode* 'pause) (= *master-mode* 'progress) (= *master-mode* 'freeze)) + (>= (- (-> *display* real-clock frame-counter) (-> *game-info* pause-start-time)) + (the int (* 300.0 (the float v1-93))) + ) + ) + ) + ) + (or (= *master-exit* 'force) (= *master-exit* 'movie)) + ) + (or *master-exit* (-> *setting-control* user-current allow-timeout)) + (!= *master-exit* #t) + ) + (cond + ((and (= *kernel-boot-message* 'demo) (not *master-exit*)) + (let ((v1-109 (level-get-target-inside *level*))) + (when (and v1-109 (!= (-> v1-109 name) 'demo) (zero? (logand (-> v1-109 info level-flags) 1))) + (persist-with-delay *setting-control* 'sfx-volume (seconds 0.5) 'sfx-volume 'abs 0.0 0) + (persist-with-delay *setting-control* 'music-volume (seconds 0.5) 'music-volume 'abs 0.0 0) + (persist-with-delay *setting-control* 'dialog-volume (seconds 0.5) 'dialog-volume 'abs 0.0 0) + (persist-with-delay *setting-control* 'ambient-volume (seconds 0.5) 'ambient-volume 'abs 0.0 0) + (set! (-> *setting-control* user-current sfx-volume) 0.01) + (set! (-> *setting-control* user-current music-volume) 0.01) + (set! (-> *setting-control* user-current dialog-volume) 0.01) + (set! (-> *setting-control* user-current ambient-volume) 0.01) + (apply-settings *setting-control*) + (set! (-> *game-info* mode) 'play) + (initialize! *game-info* 'game (the-as game-save #f) "demo-restart") + ) + ) + ) + (else + (when (process-spawn-function + process + (lambda ((arg0 time-frame)) (with-pp + (set-blackout-frames (seconds 100)) + (set! (-> *setting-control* user-default allow-pause) #f) + (set! (-> *setting-control* user-default allow-progress) #f) + (apply-settings *setting-control*) + (set! (-> *setting-control* user-default sfx-volume) 0.0) + (set! (-> *setting-control* user-default music-volume) 0.0) + (set! (-> *setting-control* user-default dialog-volume) 0.0) + (set! (-> *setting-control* user-default ambient-volume) 0.0) + (let ((s5-0 (-> pp clock frame-counter))) + (until (>= (- (-> pp clock frame-counter) s5-0) (seconds 0.1)) + (suspend) + ) + ) + (kernel-shutdown) + (none) + ) + ) + (if (= *master-exit* 'movie) + 2 + 1 + ) + :to *display-pool* + ) + (set! (-> *setting-control* user-default sfx-volume) 0.0) + (set! (-> *setting-control* user-default music-volume) 0.0) + (set! (-> *setting-control* user-default dialog-volume) 0.0) + (set! (-> *setting-control* user-default ambient-volume) 0.0) + (set! *master-exit* #t) + ) + ) + ) + ) + ) + ) + 0 + ) + +;; definition for function end-display +;; WARN: Return type mismatch int vs none. +;; WARN: Failed store: (s.w! (+ v1-37 8) 0) at op 87 +;; WARN: Failed store: (s.w! (+ v1-37 12) 0) at op 88 +;; WARN: Failed store: (s.w! (+ v1-94 8) 0) at op 237 +;; WARN: Failed store: (s.w! (+ v1-94 12) 0) at op 238 +(defun end-display ((arg0 display)) + (let ((s5-0 (-> (if *debug-segment* + (-> arg0 frames (-> arg0 on-screen) debug-buf) + (-> arg0 frames (-> arg0 on-screen) global-buf) + ) + base + ) + ) + ) + (when *debug-segment* + (debug-draw-buffers) + (with-dma-buffer-add-bucket ((s3-0 (-> arg0 frames (-> arg0 on-screen) debug-buf)) + (bucket-id debug-no-zbuf2) + ) + (when (or *display-profile* *stats-profile-bars*) + (setup-categories! (-> arg0 frames (-> arg0 on-screen) profile-array)) + (let ((a2-0 7)) + (if *display-profile* + (draw-bars! *profile-array* s3-0 a2-0) + ) + ) + (if (and (!= *master-mode* 'menu) *stats-profile-bars*) + (draw-text! *profile-array*) + ) + ) + (when *display-deci-count* + (let ((s2-0 draw-string-xy)) + (format (clear *temp-string*) "~D" *deci-count*) + (s2-0 *temp-string* s3-0 448 210 (font-color default-#cddbcd) (font-flags shadow)) + ) + ) + (display-file-info) + ) + ) + (with-dma-buffer-add-bucket ((s3-1 (if *debug-segment* + (-> arg0 frames (-> arg0 on-screen) debug-buf) + (-> arg0 frames (-> arg0 on-screen) global-buf) + ) + ) + (bucket-id debug-no-zbuf2) + ) + (if (and (= *master-mode* 'pause) + (and (!= *cheat-mode* 'camera) (or (zero? *screen-shot-work*) (= (-> *screen-shot-work* count) -1))) + ) + (draw-string-xy + (lookup-text! *common-text* (game-text-id pause) #f) + s3-1 + 256 + (if (< (-> *display* base-clock frame-counter) (-> *game-info* letterbox-time)) + 352 + 320 + ) + (font-color precursor-#ec3b00) + (font-flags shadow kerning middle large) + ) + ) + (let ((s2-2 (the int (-> *font-context* origin y)))) + (cond + ((or (movie?) (< (-> *display* base-clock frame-counter) (-> *game-info* letterbox-time))) + (+! s2-2 56) + ) + (*display-profile* + (+! s2-2 48) + ) + ) + (when (or (zero? *screen-shot-work*) (= (-> *screen-shot-work* count) -1)) + (let* ((v1-82 + (draw-string-xy + *stdcon0* + s3-1 + (the int (-> *font-context* origin x)) + s2-2 + (font-color default-#cddbcd) + (font-flags shadow) + ) + ) + (a3-6 (+ s2-2 (the int (* 2.0 (the-as float (-> v1-82 b)))))) + ) + (draw-string-xy + *stdcon1* + s3-1 + (the int (-> *font-context* origin x)) + a3-6 + (font-color default-#cddbcd) + (font-flags shadow) + ) + ) + ) + ) + (if *display-iop-info* + (show-iop-info s3-1) + ) + (if *display-memcard-info* + (show-mc-info s3-1) + ) + ) + (let ((v1-101 *dma-mem-usage*)) + (when (nonzero? v1-101) + (set! (-> v1-101 length) (max 88 (-> v1-101 length))) + (set! (-> v1-101 data 87 name) "debug") + (+! (-> v1-101 data 87 count) 1) + (+! (-> v1-101 data 87 used) (&- + (-> (if *debug-segment* + (-> arg0 frames (-> arg0 on-screen) debug-buf) + (-> arg0 frames (-> arg0 on-screen) global-buf) + ) + base + ) + (the-as uint s5-0) + ) + ) + (set! (-> v1-101 data 87 total) (-> v1-101 data 87 used)) + ) + ) + ) + (set! *stdcon* (clear *stdcon0*)) + 0 + (none) + ) + +;; definition for function display-loop-main +;; WARN: Return type mismatch int vs none. +(defun display-loop-main ((arg0 display)) + (local-vars (a0-94 int) (a0-96 int)) + (with-pp + (if (-> *level* loading-level) + (load-continue (-> *level* loading-level)) + ) + (when *debug-segment* + (let ((s5-0 (-> *display* frames (-> *display* on-screen) profile-array data 0)) + (v1-13 'merc) + (s4-0 *profile-merc-color*) + ) + (when (and *dproc* *debug-segment*) + (let ((s3-0 (-> s5-0 data (-> s5-0 count)))) + (let ((s2-0 (-> s5-0 base-time))) + (set! (-> s3-0 name) v1-13) + (set! (-> s3-0 start-time) (the-as int (- (timer-count (the-as timer-bank #x10000800)) (the-as uint s2-0)))) + ) + (set! (-> s3-0 depth) (the-as uint (-> s5-0 depth))) + (set! (-> s3-0 color) s4-0) + (set! (-> s5-0 segment (-> s5-0 depth)) s3-0) + ) + (+! (-> s5-0 count) 1) + (+! (-> s5-0 depth) 1) + (set! (-> s5-0 max-depth) (max (-> s5-0 max-depth) (-> s5-0 depth))) + ) + ) + 0 + ) + (blerc-execute) + (blerc-init) + (when *debug-segment* + (let ((s5-1 (-> *display* frames (-> *display* on-screen) profile-array data 0))) + (when (and *dproc* *debug-segment*) + (let* ((v1-37 (+ (-> s5-1 depth) -1)) + (s4-1 (-> s5-1 segment v1-37)) + (s3-1 (-> s5-1 base-time)) + ) + (when (>= v1-37 0) + (set! (-> s4-1 end-time) (the-as int (- (timer-count (the-as timer-bank #x10000800)) (the-as uint s3-1)))) + (+! (-> s5-1 depth) -1) + ) + ) + ) + ) + 0 + ) + (texscroll-execute) + (ripple-execute) + (region-execute) + (when *debug-segment* + (let ((s5-2 (-> *display* frames (-> *display* on-screen) profile-array data 0)) + (v1-50 'joints) + (s4-2 *profile-joints-color*) + ) + (when (and *dproc* *debug-segment*) + (let ((s3-2 (-> s5-2 data (-> s5-2 count)))) + (let ((s2-1 (-> s5-2 base-time))) + (set! (-> s3-2 name) v1-50) + (set! (-> s3-2 start-time) (the-as int (- (timer-count (the-as timer-bank #x10000800)) (the-as uint s2-1)))) + ) + (set! (-> s3-2 depth) (the-as uint (-> s5-2 depth))) + (set! (-> s3-2 color) s4-2) + (set! (-> s5-2 segment (-> s5-2 depth)) s3-2) + ) + (+! (-> s5-2 count) 1) + (+! (-> s5-2 depth) 1) + (set! (-> s5-2 max-depth) (max (-> s5-2 max-depth) (-> s5-2 depth))) + ) + ) + 0 + ) + (execute-math-engine) + (when *debug-segment* + (let ((s5-3 (-> *display* frames (-> *display* on-screen) profile-array data 0))) + (when (and *dproc* *debug-segment*) + (let* ((v1-74 (+ (-> s5-3 depth) -1)) + (s4-3 (-> s5-3 segment v1-74)) + (s3-3 (-> s5-3 base-time)) + ) + (when (>= v1-74 0) + (set! (-> s4-3 end-time) (the-as int (- (timer-count (the-as timer-bank #x10000800)) (the-as uint s3-3)))) + (+! (-> s5-3 depth) -1) + ) + ) + ) + ) + 0 + ) + (when *debug-segment* + (let ((s5-4 (-> *display* frames (-> *display* on-screen) profile-array data 0)) + (v1-87 'debug) + (s4-4 *profile-debug-color*) + ) + (when (and *dproc* *debug-segment*) + (let ((s3-4 (-> s5-4 data (-> s5-4 count)))) + (let ((s2-2 (-> s5-4 base-time))) + (set! (-> s3-4 name) v1-87) + (set! (-> s3-4 start-time) (the-as int (- (timer-count (the-as timer-bank #x10000800)) (the-as uint s2-2)))) + ) + (set! (-> s3-4 depth) (the-as uint (-> s5-4 depth))) + (set! (-> s3-4 color) s4-4) + (set! (-> s5-4 segment (-> s5-4 depth)) s3-4) + ) + (+! (-> s5-4 count) 1) + (+! (-> s5-4 depth) 1) + (set! (-> s5-4 max-depth) (max (-> s5-4 max-depth) (-> s5-4 depth))) + ) + ) + 0 + ) + (let* ((s5-5 *debug-hook*) + (t9-12 (car s5-5)) + ) + (while (not (null? s5-5)) + ((the-as (function none) t9-12)) + (set! s5-5 (cdr s5-5)) + (set! t9-12 (car s5-5)) + ) + ) + (main-cheats) + (when *debug-segment* + (let ((s5-6 (-> *display* frames (-> *display* on-screen) profile-array data 0))) + (when (and *dproc* *debug-segment*) + (let* ((v1-115 (+ (-> s5-6 depth) -1)) + (s4-5 (-> s5-6 segment v1-115)) + (s3-5 (-> s5-6 base-time)) + ) + (when (>= v1-115 0) + (set! (-> s4-5 end-time) (the-as int (- (timer-count (the-as timer-bank #x10000800)) (the-as uint s3-5)))) + (+! (-> s5-6 depth) -1) + ) + ) + ) + ) + 0 + ) + (when *debug-segment* + (let ((s5-7 (-> *display* frames (-> *display* on-screen) profile-array data 0)) + (v1-128 'camera) + (s4-6 *profile-camera-color*) + ) + (when (and *dproc* *debug-segment*) + (let ((s3-6 (-> s5-7 data (-> s5-7 count)))) + (let ((s2-3 (-> s5-7 base-time))) + (set! (-> s3-6 name) v1-128) + (set! (-> s3-6 start-time) (the-as int (- (timer-count (the-as timer-bank #x10000800)) (the-as uint s2-3)))) + ) + (set! (-> s3-6 depth) (the-as uint (-> s5-7 depth))) + (set! (-> s3-6 color) s4-6) + (set! (-> s5-7 segment (-> s5-7 depth)) s3-6) + ) + (+! (-> s5-7 count) 1) + (+! (-> s5-7 depth) 1) + (set! (-> s5-7 max-depth) (max (-> s5-7 max-depth) (-> s5-7 depth))) + ) + ) + 0 + ) + (update-camera) + (when *debug-segment* + (let ((s5-8 (-> *display* frames (-> *display* on-screen) profile-array data 0))) + (when (and *dproc* *debug-segment*) + (let* ((v1-152 (+ (-> s5-8 depth) -1)) + (s4-7 (-> s5-8 segment v1-152)) + (s3-7 (-> s5-8 base-time)) + ) + (when (>= v1-152 0) + (set! (-> s4-7 end-time) (the-as int (- (timer-count (the-as timer-bank #x10000800)) (the-as uint s3-7)))) + (+! (-> s5-8 depth) -1) + ) + ) + ) + ) + 0 + ) + (update *bigmap*) + (if (-> *level* loading-level) + (load-continue (-> *level* loading-level)) + ) + (when *debug-segment* + (let ((s5-9 (-> *display* frames (-> *display* on-screen) profile-array data 0)) + (v1-173 'draw-hook) + (s4-8 *profile-draw-hook-color*) + ) + (when (and *dproc* *debug-segment*) + (let ((s3-8 (-> s5-9 data (-> s5-9 count)))) + (let ((s2-4 (-> s5-9 base-time))) + (set! (-> s3-8 name) v1-173) + (set! (-> s3-8 start-time) (the-as int (- (timer-count (the-as timer-bank #x10000800)) (the-as uint s2-4)))) + ) + (set! (-> s3-8 depth) (the-as uint (-> s5-9 depth))) + (set! (-> s3-8 color) s4-8) + (set! (-> s5-9 segment (-> s5-9 depth)) s3-8) + ) + (+! (-> s5-9 count) 1) + (+! (-> s5-9 depth) 1) + (set! (-> s5-9 max-depth) (max (-> s5-9 max-depth) (-> s5-9 depth))) + ) + ) + 0 + ) + (*draw-hook*) + (when *debug-segment* + (let ((s5-10 (-> *display* frames (-> *display* on-screen) profile-array data 0))) + (when (and *dproc* *debug-segment*) + (let* ((v1-197 (+ (-> s5-10 depth) -1)) + (s4-9 (-> s5-10 segment v1-197)) + (s3-9 (-> s5-10 base-time)) + ) + (when (>= v1-197 0) + (set! (-> s4-9 end-time) (the-as int (- (timer-count (the-as timer-bank #x10000800)) (the-as uint s3-9)))) + (+! (-> s5-10 depth) -1) + ) + ) + ) + ) + 0 + ) + (if (-> *level* loading-level) + (load-continue (-> *level* loading-level)) + ) + (if *display-color-bars* + (draw-color-bars) + ) + (when *debug-segment* + (let ((s5-11 (-> *display* frames (-> *display* on-screen) profile-array data 0)) + (v1-219 'menu-hook) + (s4-10 *profile-menu-hook-color*) + ) + (when (and *dproc* *debug-segment*) + (let ((s3-10 (-> s5-11 data (-> s5-11 count)))) + (let ((s2-5 (-> s5-11 base-time))) + (set! (-> s3-10 name) v1-219) + (set! (-> s3-10 start-time) (the-as int (- (timer-count (the-as timer-bank #x10000800)) (the-as uint s2-5)))) + ) + (set! (-> s3-10 depth) (the-as uint (-> s5-11 depth))) + (set! (-> s3-10 color) s4-10) + (set! (-> s5-11 segment (-> s5-11 depth)) s3-10) + ) + (+! (-> s5-11 count) 1) + (+! (-> s5-11 depth) 1) + (set! (-> s5-11 max-depth) (max (-> s5-11 max-depth) (-> s5-11 depth))) + ) + ) + 0 + ) + (*menu-hook*) + (when *debug-segment* + (let ((s5-12 (-> *display* frames (-> *display* on-screen) profile-array data 0))) + (when (and *dproc* *debug-segment*) + (let* ((v1-243 (+ (-> s5-12 depth) -1)) + (s4-11 (-> s5-12 segment v1-243)) + (s3-11 (-> s5-12 base-time)) + ) + (when (>= v1-243 0) + (set! (-> s4-11 end-time) (the-as int (- (timer-count (the-as timer-bank #x10000800)) (the-as uint s3-11)))) + (+! (-> s5-12 depth) -1) + ) + ) + ) + ) + 0 + ) + (load-level-text-files -1) + (if (-> *screen-filter* draw?) + (draw *screen-filter*) + ) + (when (or (movie?) (< (-> *display* base-clock frame-counter) (-> *game-info* letterbox-time))) + (if (< (-> *game-info* letterbox-time) (-> *display* base-clock frame-counter)) + (set! (-> *game-info* letterbox-time) (-> *display* base-clock frame-counter)) + ) + (if (and (= (-> *setting-control* user-current aspect-ratio) 'aspect4x3) + (or (zero? *screen-shot-work*) (= (-> *screen-shot-work* count) -1)) + ) + (letterbox) + ) + ) + (when (-> *setting-control* user-current render) + (if (< (-> *display* base-clock frame-counter) (-> *game-info* blackout-time)) + (set! (-> *setting-control* user-default bg-a-force) 1.0) + (set! (-> *setting-control* user-default bg-a-force) 0.0) + ) + ) + (blit-displays) + (when *debug-segment* + (let ((s5-13 (-> arg0 frames (-> arg0 on-screen) profile-array data 0))) + (when (and *dproc* *debug-segment*) + (let* ((v1-294 (+ (-> s5-13 depth) -1)) + (s4-12 (-> s5-13 segment v1-294)) + (s3-12 (-> s5-13 base-time)) + ) + (when (>= v1-294 0) + (set! (-> s4-12 end-time) (the-as int (- (timer-count (the-as timer-bank #x10000800)) (the-as uint s3-12)))) + (+! (-> s5-13 depth) -1) + ) + ) + ) + ) + 0 + (let ((v1-301 (-> *perf-stats* data))) + (b! (zero? (-> v1-301 0 ctrl)) cfg-129 :delay (nop!)) + (.mtc0 Perf 0) + (.sync.l) + (.sync.p) + (.mfpc a0-94 pcr0) + (+! (-> v1-301 0 accum0) a0-94) + (.mfpc a0-96 pcr1) + (+! (-> v1-301 0 accum1) a0-96) + ) + (label cfg-129) + 0 + ) + (b! (zero? (sync-path 0 0)) cfg-132 :delay (empty-form)) + (*dma-timeout-hook*) + (reset-vif1-path) + (label cfg-132) + (end-display arg0) + (swap-display arg0) + (when *debug-segment* + (start-frame! (-> arg0 frames (-> arg0 on-screen) profile-array data 0)) + (let* ((v1-314 (-> *perf-stats* data)) + (a0-102 (-> v1-314 0 ctrl)) + ) + (+! (-> v1-314 0 count) 1) + (b! (zero? a0-102) cfg-135 :delay (nop!)) + (.mtc0 Perf 0) + (.sync.l) + (.sync.p) + (.mtpc pcr0 0) + (.mtpc pcr1 0) + (.sync.l) + (.sync.p) + (.mtc0 Perf a0-102) + ) + (.sync.l) + (.sync.p) + (label cfg-135) + 0 + ) + (set! (-> *time-of-day-context* title-updated) #f) + (set! *teleport* #f) + (b! (zero? *teleport-count*) cfg-138 :delay (empty-form)) + (set! *teleport* #t) + (set! *teleport-count* (+ *teleport-count* -1)) + (label cfg-138) + (let ((gp-1 (-> pp clock))) + (set! (-> pp clock) (-> *display* part-clock)) + (process-particles) + (set! (-> pp clock) gp-1) + ) + (dma-send + (the-as dma-bank #x10008000) + (the-as uint (-> *collide-vif0-init* data)) + (the-as uint (/ (-> *collide-vif0-init* length) 4)) + ) + (swap-sound-buffers (ear-trans 0) (ear-trans 1) (camera-pos) (camera-angle)) + (str-play-kick) + (level-update *level*) + (mc-run) + (auto-save-check) + 0 + (none) + ) + ) + +;; definition for function display-loop +(defbehavior display-loop process () + (stack-size-set! (-> self main-thread) 512) + (process-spawn-function + process + (lambda :behavior process + () + (logclear! (-> self mask) (process-mask freeze pause menu progress entity)) + (until #f + (when *debug-segment* + (let ((gp-0 (-> *display* frames (-> *display* on-screen) profile-array data 0)) + (v1-9 'joints) + (s5-0 *profile-joints-color*) + ) + (when (and *dproc* *debug-segment*) + (let ((s4-0 (-> gp-0 data (-> gp-0 count)))) + (let ((s3-0 (-> gp-0 base-time))) + (set! (-> s4-0 name) v1-9) + (set! (-> s4-0 start-time) (the-as int (- (timer-count (the-as timer-bank #x10000800)) (the-as uint s3-0)))) + ) + (set! (-> s4-0 depth) (the-as uint (-> gp-0 depth))) + (set! (-> s4-0 color) s5-0) + (set! (-> gp-0 segment (-> gp-0 depth)) s4-0) + ) + (+! (-> gp-0 count) 1) + (+! (-> gp-0 depth) 1) + (set! (-> gp-0 max-depth) (max (-> gp-0 max-depth) (-> gp-0 depth))) + ) + ) + 0 + ) + (execute-math-engine) + (when *debug-segment* + (let ((gp-1 (-> *display* frames (-> *display* on-screen) profile-array data 0))) + (when (and *dproc* *debug-segment*) + (let* ((v1-33 (+ (-> gp-1 depth) -1)) + (s5-1 (-> gp-1 segment v1-33)) + (s4-1 (-> gp-1 base-time)) + ) + (when (>= v1-33 0) + (set! (-> s5-1 end-time) (the-as int (- (timer-count (the-as timer-bank #x10000800)) (the-as uint s4-1)))) + (+! (-> gp-1 depth) -1) + ) + ) + ) + ) + 0 + ) + (suspend) + ) + #f + (none) + ) + :name "matrix" + :from *4k-dead-pool* + :to *mid-pool* + ) + (let ((gp-1 *display*)) + (set! *teleport* #t) + (update *setting-control*) + (init-time-of-day-context *time-of-day-context*) + (display-sync gp-1) + (swap-display gp-1) + (install-handler 3 vblank-handler) + (free-nodes *touching-list*) + (prepare *collide-rider-pool*) + (update-actor-hash) + (blerc-init) + (dma-send + (the-as dma-bank #x10008000) + (the-as uint (-> *collide-vif0-init* data)) + (the-as uint (/ (-> *collide-vif0-init* length) 4)) + ) + (suspend) + (set! (-> *setting-control* user-default bg-a) 0.0) + (set! (-> gp-1 frames 0 start-time) (the-as time-frame (timer-count (the-as timer-bank #x10000800)))) + (set! (-> gp-1 frames 1 start-time) (the-as time-frame (timer-count (the-as timer-bank #x10000800)))) + (set! (-> gp-1 dog-ratio) 1.0) + (while *run* + (display-loop-main gp-1) + (when *debug-segment* + (let ((s5-0 (-> *display* frames (-> *display* on-screen) profile-array data 0)) + (v1-27 'actors) + (s4-0 *profile-actors-color*) + ) + (when (and *dproc* *debug-segment*) + (let ((s3-0 (-> s5-0 data (-> s5-0 count)))) + (let ((s2-0 (-> s5-0 base-time))) + (set! (-> s3-0 name) v1-27) + (set! (-> s3-0 start-time) (the-as int (- (timer-count (the-as timer-bank #x10000800)) (the-as uint s2-0)))) + ) + (set! (-> s3-0 depth) (the-as uint (-> s5-0 depth))) + (set! (-> s3-0 color) s4-0) + (set! (-> s5-0 segment (-> s5-0 depth)) s3-0) + ) + (+! (-> s5-0 count) 1) + (+! (-> s5-0 depth) 1) + (set! (-> s5-0 max-depth) (max (-> s5-0 max-depth) (-> s5-0 depth))) + ) + ) + 0 + ) + (suspend) + (when *debug-segment* + (let ((s5-1 (-> *display* frames (-> *display* on-screen) profile-array data 0))) + (when (and *dproc* *debug-segment*) + (let* ((v1-51 (+ (-> s5-1 depth) -1)) + (s4-1 (-> s5-1 segment v1-51)) + (s3-1 (-> s5-1 base-time)) + ) + (when (>= v1-51 0) + (set! (-> s4-1 end-time) (the-as int (- (timer-count (the-as timer-bank #x10000800)) (the-as uint s3-1)))) + (+! (-> s5-1 depth) -1) + ) + ) + ) + ) + 0 + ) + ) + ) + (set! *dproc* #f) + (format 0 "display is off #<#x~X>.~%" self) + 0 + ) + +;; definition for function on +(defun on ((arg0 symbol)) + (when (not *dproc*) + (when (not arg0) + (if (= (-> *level* level0 status) 'inactive) + (bg 'halfpipe) + ) + ) + (set! *run* #t) + (set! *dproc* (ppointer->process (process-spawn-function + process + display-loop + :name "display" + :from *4k-dead-pool* + :to *display-pool* + :stack *kernel-dram-stack* + ) + ) + ) + (cond + ((or (level-get-with-status *level* 'loaded) + (level-get-with-status *level* 'alive) + (level-get-with-status *level* 'active) + ) + (activate-levels! *level*) + (when (not arg0) + (let ((gp-1 (entity-by-type camera-start))) + (when (and gp-1 (type? gp-1 entity-actor)) + (while (not (camera-teleport-to-entity gp-1)) + (suspend) + ) + ) + ) + ) + (if (and (= *kernel-boot-message* 'art-group) *kernel-boot-art-group*) + (anim-tester-add-object *kernel-boot-art-group*) + ) + ) + (else + (kill-by-name "display" *active-pool*) + (set! *dproc* #f) + ) + ) + ) + *dproc* + ) + +;; definition for function off +(defun off () + (stop 'debug) + (dotimes (gp-0 (-> *level* length)) + (let ((a0-2 (-> *level* level gp-0))) + (if (= (-> a0-2 status) 'active) + (deactivate a0-2) + ) + ) + ) + (set! *run* #f) + 0 + ) + + + + diff --git a/test/decompiler/reference/jak2/engine/ps2/memcard-h_REF.gc b/test/decompiler/reference/jak2/engine/ps2/memcard-h_REF.gc index 0865845363..43a1843f4e 100644 --- a/test/decompiler/reference/jak2/engine/ps2/memcard-h_REF.gc +++ b/test/decompiler/reference/jak2/engine/ps2/memcard-h_REF.gc @@ -1,5 +1,7 @@ +;;-*-Lisp-*- (in-package goal) +;; definition of type mc-handle (deftype mc-handle (int32) () :method-count-assert 9 @@ -7,6 +9,7 @@ :flag-assert #x900000004 ) +;; definition of type mc-file-info (deftype mc-file-info (structure) ((present int32 :offset-assert 0) (blind-data float 16 :offset 4) @@ -32,6 +35,7 @@ :flag-assert #x900000044 ) +;; definition for method 3 of type mc-file-info (defmethod inspect mc-file-info ((obj mc-file-info)) (when (not obj) (set! obj obj) @@ -59,6 +63,7 @@ obj ) +;; definition of type mc-slot-info (deftype mc-slot-info (structure) ((handle int32 :offset-assert 0) (known int32 :offset-assert 4) @@ -75,6 +80,7 @@ :flag-assert #x90000012c ) +;; definition for method 3 of type mc-slot-info (defmethod inspect mc-slot-info ((obj mc-slot-info)) (when (not obj) (set! obj obj) @@ -93,6 +99,7 @@ obj ) +;; definition for function mc-sync (defun mc-sync () (let ((v0-0 0)) (while (zero? v0-0) @@ -103,5 +110,56 @@ ) ) +;; definition for function show-mc-info +;; WARN: Return type mismatch int vs none. +(defun show-mc-info ((arg0 dma-buffer)) + (let ((s5-0 (new 'stack-no-clear 'mc-slot-info))) + (dotimes (s4-0 2) + (mc-get-slot-info s4-0 s5-0) + (cond + ((zero? (-> s5-0 known)) + (format (clear *temp-string*) "SLOT ~D: EXAMINING SLOT~%" s4-0) + *temp-string* + ) + ((zero? (-> s5-0 handle)) + (format (clear *temp-string*) "SLOT ~D: NO CARD~%" s4-0) + *temp-string* + ) + ((zero? (-> s5-0 formatted)) + (format (clear *temp-string*) "SLOT ~D: CARD [~D] : NOT FORMATTED~%" s4-0 (-> s5-0 handle)) + *temp-string* + ) + ((zero? (-> s5-0 inited)) + (format + (clear *temp-string*) + "SLOT ~D: CARD [~D] : NO FILE [~D/~D]~%" + s4-0 + (-> s5-0 handle) + (-> s5-0 mem-required) + (-> s5-0 mem-actual) + ) + *temp-string* + ) + (else + (format (clear *temp-string*) "SLOT ~D: CARD [~D] : " s4-0 (-> s5-0 handle)) + *temp-string* + (format + *temp-string* + "SAVES ~D ~D ~D ~D : LAST ~D~%" + (-> s5-0 file 0 present) + (-> s5-0 file 1 present) + (-> s5-0 file 2 present) + (-> s5-0 file 3 present) + (-> s5-0 last-file) + ) + ) + ) + (draw-string-xy *temp-string* arg0 32 (+ (* 12 s4-0) 8) (font-color precursor-#ec3b00) (font-flags shadow)) + ) + ) + 0 + (none) + ) +;; failed to figure out what this is: 0 diff --git a/test/offline/config/jak2/config.jsonc b/test/offline/config/jak2/config.jsonc index 1c3f48130d..5380ef6c94 100644 --- a/test/offline/config/jak2/config.jsonc +++ b/test/offline/config/jak2/config.jsonc @@ -255,7 +255,10 @@ "target-send-attack", "bones-mtx-calc-execute", // asm "(method 32 fort-lift-plat)", // multiply defined - "target-board-handler" // very strange control flow + "target-board-handler", // very strange control flow + "(method 11 memory-usage-block)", "vis-cull", "vis-cull-debug", "dma-add-process-drawable", + "foreground-engine-execute", + "test-closest-pt-in-triangle", "on" ], "skip_compile_states": {