Files
water111 7348e6a4ff [decompiler] Update vector ops, reduce casts (#3849)
Update the decompiler to use the new vf macros.

Also, fix a bunch of silly casting issues where accessing inline fields
with an offset of 0 would be better than a cast:

![image](https://github.com/user-attachments/assets/885bbb07-634f-47b8-99f5-5a947941cdde)

---------

Co-authored-by: water111 <awaterford1111445@gmail.com>
2025-01-20 16:32:58 -05:00

761 lines
28 KiB
Common Lisp
Vendored
Generated

;;-*-Lisp-*-
(in-package goal)
;; definition for function mem-usage-bsp-tree
;; WARN: Return type mismatch bsp-header vs none.
(defun mem-usage-bsp-tree ((arg0 bsp-header) (arg1 bsp-node) (arg2 memory-usage-block) (arg3 int))
(cond
((zero? arg1)
)
(else
(+! (-> arg2 data 60 count) 1)
(let ((v1-3 20))
(+! (-> arg2 data 60 used) v1-3)
(+! (-> arg2 data 60 total) v1-3)
)
(if (zero? (-> arg1 front-box-min w))
(mem-usage-bsp-tree arg0 (-> arg0 nodes (-> arg1 front)) arg2 arg3)
)
(when (zero? (-> arg1 back-box-min w))
(if (> (-> arg1 back) 0)
(mem-usage-bsp-tree arg0 (-> arg0 nodes (-> arg1 back)) arg2 arg3)
)
)
)
)
(none)
)
;; definition for method 8 of type bsp-header
(defmethod mem-usage ((this bsp-header) (usage memory-usage-block) (flags int))
(set! (-> usage work-bsp) this)
(when (nonzero? (-> this info))
(set! (-> usage length) (max 85 (-> usage length)))
(set! (-> usage data 84 name) "array")
(+! (-> usage data 84 count) 1)
(let ((v1-8 (asize-of (-> this info))))
(+! (-> usage data 84 used) v1-8)
(+! (-> usage data 84 total) (logand -16 (+ v1-8 15)))
)
)
(if (nonzero? (-> this drawable-trees))
(mem-usage (-> this drawable-trees) usage flags)
)
(if (nonzero? (-> this collide-hash))
(mem-usage (-> this collide-hash) usage flags)
)
(set! (-> usage length) (max 65 (-> usage length)))
(set! (-> usage data 43 name) "entity")
(set! (-> usage data 44 name) "camera")
(set! (-> usage data 64 name) "pat")
(set! (-> usage data 60 name) "bsp-node")
(set! (-> usage length) (max 59 (-> usage length)))
(set! (-> usage data 58 name) "bsp-main")
(+! (-> usage data 58 count) 1)
(let ((v1-31 400))
(+! (-> usage data 58 used) v1-31)
(+! (-> usage data 58 total) (logand -16 (+ v1-31 15)))
)
(set! (-> usage length) (max 62 (-> usage length)))
(set! (-> usage data 61 name) "bsp-leaf-vis-self")
(+! (-> usage data 61 count) 1)
(let ((v1-40 (-> this visible-list-length)))
(+! (-> usage data 61 used) v1-40)
(+! (-> usage data 61 total) (logand -16 (+ v1-40 15)))
)
(set! (-> usage length) (max 60 (-> usage length)))
(set! (-> usage data 59 name) "bsp-misc")
(+! (-> usage data 59 count) 1)
(let ((v1-50 (* (-> this texture-remap-table-len) 8)))
(+! (-> usage data 59 used) v1-50)
(+! (-> usage data 59 total) (logand -16 (+ v1-50 15)))
)
(set! (-> usage length) (max 60 (-> usage length)))
(set! (-> usage data 59 name) "bsp-misc")
(+! (-> usage data 59 count) 1)
(let ((v1-60 (* (-> this texture-page-count) 4)))
(+! (-> usage data 59 used) v1-60)
(+! (-> usage data 59 total) (logand -16 (+ v1-60 15)))
)
(when (nonzero? (-> this unknown-basic))
(set! (-> usage length) (max 60 (-> usage length)))
(set! (-> usage data 59 name) "bsp-misc")
(+! (-> usage data 59 count) 1)
(let ((v1-72 (asize-of (-> this unknown-basic))))
(+! (-> usage data 59 used) v1-72)
(+! (-> usage data 59 total) (logand -16 (+ v1-72 15)))
)
)
(when (nonzero? (-> this actor-birth-order))
(set! (-> usage length) (max 60 (-> usage length)))
(set! (-> usage data 59 name) "bsp-misc")
(+! (-> usage data 59 count) 1)
(let ((v1-85 (* (-> this actors length) 4)))
(+! (-> usage data 59 used) v1-85)
(+! (-> usage data 59 total) (logand -16 (+ v1-85 15)))
)
)
(+! (-> usage data 64 count) (-> this pat-length))
(let ((v1-92 (* (-> this pat-length) 4)))
(+! (-> usage data 64 used) v1-92)
(+! (-> usage data 64 total) (logand -16 (+ v1-92 15)))
)
(when (nonzero? (-> this region-trees))
(let* ((s3-0 (-> this region-trees length))
(s2-0 0)
(a0-39 (-> this region-trees s2-0))
)
(while (< s2-0 s3-0)
(mem-usage a0-39 usage (logior flags 128))
(+! s2-0 1)
(set! a0-39 (-> this region-trees s2-0))
)
)
)
(let ((s3-1 (-> this cameras)))
(when (nonzero? s3-1)
(dotimes (s2-1 (-> s3-1 length))
(mem-usage (-> s3-1 s2-1) usage (logior flags 256))
)
)
)
(if (nonzero? (-> this nodes))
(mem-usage-bsp-tree this (-> this nodes 0) usage flags)
)
this
)
;; definition for method 9 of type bsp-header
(defmethod login ((this bsp-header))
"Initialize the object after it is loaded."
(if (nonzero? (-> this drawable-trees))
(login (-> this drawable-trees))
)
(set! (-> this level tfrag-gs-test)
(if (logtest? (-> this texture-flags 0) (texture-page-flag alpha-enable))
(new 'static 'gs-test :ate #x1 :atst (gs-atest always) :zte #x1 :ztst (gs-ztest greater-equal))
(new 'static 'gs-test
:ate #x1
:atst (gs-atest greater-equal)
:aref #x26
:zte #x1
:ztst (gs-ztest greater-equal)
)
)
)
this
)
;; definition for symbol *test-shrub*, type int
(define *test-shrub* 0)
;; definition for method 10 of type bsp-header
;; INFO: Used lq/sq
;; WARN: Return type mismatch int vs none.
(defmethod draw ((this bsp-header) (arg0 bsp-header) (arg1 display-frame))
(local-vars (a3-4 uint128) (a3-5 uint128))
(rlet ((vf16 :class vf)
(vf17 :class vf)
(vf18 :class vf)
(vf19 :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)
(vf30 :class vf)
(vf31 :class vf)
)
(let ((s4-0 (-> this level)))
(when (-> s4-0 render?)
(set! *draw-index* (-> s4-0 draw-index))
(set! (-> *prototype-tie-work* mood) (-> s4-0 mood-context))
(if *artist-use-menu-subdiv*
(update-subdivide-settings! *subdivide-settings* *math-camera* 7)
(update-subdivide-settings! *subdivide-settings* *math-camera* (-> s4-0 index))
)
(let ((a2-3 (/ (+ (-> this visible-list-length) 15) 16)))
(dma-send-to-spr-no-flush
(the-as uint (-> (the-as terrain-context #x70000000) work background vis-list))
(the-as uint (-> s4-0 vis-bits))
(the-as uint a2-3)
#f
)
)
(when *artist-flip-visible*
(let ((v1-15 (/ (+ (-> this visible-list-length) 15) 16))
(a0-7 (-> (the-as terrain-context #x70000000) work background vis-list))
(a1-5 (-> this all-visible-list))
)
(dotimes (a2-4 v1-15)
(let ((a3-3 (-> (the-as (pointer uint128) (+ (the-as uint a0-7) (* a2-4 16))))))
(.pnor a3-4 a3-3 0)
)
(let ((t0-2 (-> (the-as (pointer uint128) (&+ a1-5 (* a2-4 16))))))
(.pand a3-5 a3-4 t0-2)
)
(set! (-> (the-as (pointer uint128) (+ (the-as uint a0-7) (* a2-4 16)))) a3-5)
)
)
)
(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 shrub-mat quad 0))
(.lvf vf21 (&-> at-0 shrub-mat quad 1))
(.lvf vf22 (&-> at-0 shrub-mat quad 2))
(.lvf vf23 (&-> at-0 shrub-mat trans 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))
(.lvf vf28 (&-> at-0 camera-temp quad 0))
(.lvf vf29 (&-> at-0 camera-temp quad 1))
(.lvf vf30 (&-> at-0 camera-temp quad 2))
(.lvf vf31 (&-> at-0 camera-temp trans quad))
)
(when (nonzero? (-> this drawable-trees))
(when *debug-segment*
(let ((s4-1 (-> *display* frames (-> *display* on-screen) profile-array data 0))
(v1-27 'bsp)
(s3-0 *profile-bsp-color*)
)
(when (and *dproc* *debug-segment*)
(let ((s2-0 (-> s4-1 data (-> s4-1 count))))
(let ((s1-0 (-> s4-1 base-time)))
(set! (-> s2-0 name) v1-27)
(set! (-> s2-0 start-time) (the-as int (- (timer-count (the-as timer-bank #x10000800)) (the-as uint s1-0))))
)
(set! (-> s2-0 depth) (the-as uint (-> s4-1 depth)))
(set! (-> s2-0 color) s3-0)
(set! (-> s4-1 segment (-> s4-1 depth)) s2-0)
)
(+! (-> s4-1 count) 1)
(+! (-> s4-1 depth) 1)
(set! (-> s4-1 max-depth) (max (-> s4-1 max-depth) (-> s4-1 depth)))
)
)
0
)
(let ((a1-8 (-> this drawable-trees)))
(draw a1-8 a1-8 arg1)
)
(when *debug-segment*
(let ((gp-1 (-> *display* frames (-> *display* on-screen) profile-array data 0)))
(when (and *dproc* *debug-segment*)
(let* ((v1-53 (+ (-> gp-1 depth) -1))
(s5-1 (-> gp-1 segment v1-53))
(s4-2 (-> gp-1 base-time))
)
(when (>= v1-53 0)
(set! (-> s5-1 end-time) (the-as int (- (timer-count (the-as timer-bank #x10000800)) (the-as uint s4-2))))
(+! (-> gp-1 depth) -1)
)
)
)
)
0
)
)
)
)
0
(none)
)
)
;; definition for method 14 of type bsp-header
;; WARN: Return type mismatch int vs none.
(defmethod debug-draw ((this bsp-header) (arg0 drawable) (arg1 display-frame))
(rlet ((vf16 :class vf)
(vf17 :class vf)
(vf18 :class vf)
(vf19 :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)
(vf30 :class vf)
(vf31 :class vf)
)
(let ((v1-0 (-> this level)))
(set! *draw-index* (-> v1-0 draw-index))
(set! (-> *prototype-tie-work* mood) (-> v1-0 mood-context))
(let ((a2-1 (/ (+ (-> this visible-list-length) 15) 16)))
(dma-send-to-spr-no-flush
(the-as uint (+ #x38a0 #x70000000))
(the-as uint (-> v1-0 vis-bits))
(the-as uint a2-1)
#f
)
)
)
(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 shrub-mat quad 0))
(.lvf vf21 (&-> at-0 shrub-mat quad 1))
(.lvf vf22 (&-> at-0 shrub-mat quad 2))
(.lvf vf23 (&-> at-0 shrub-mat trans 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))
(.lvf vf28 (&-> at-0 camera-temp quad 0))
(.lvf vf29 (&-> at-0 camera-temp quad 1))
(.lvf vf30 (&-> at-0 camera-temp quad 2))
(.lvf vf31 (&-> at-0 camera-temp trans quad))
)
(when (nonzero? (-> this drawable-trees))
(let ((a1-4 (-> this drawable-trees)))
(debug-draw a1-4 a1-4 arg1)
)
)
0
(none)
)
)
;; definition for method 13 of type bsp-header
;; WARN: Return type mismatch int vs none.
(defmethod collect-stats ((this bsp-header))
(rlet ((vf16 :class vf)
(vf17 :class vf)
(vf18 :class vf)
(vf19 :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)
(vf30 :class vf)
(vf31 :class vf)
)
(let ((v1-0 (-> this level))
(a2-0 (/ (+ (-> this visible-list-length) 15) 16))
)
(dma-send-to-spr-no-flush
(the-as uint (+ #x38a0 #x70000000))
(the-as uint (-> v1-0 vis-bits))
(the-as uint a2-0)
#f
)
)
(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 shrub-mat quad 0))
(.lvf vf21 (&-> at-0 shrub-mat quad 1))
(.lvf vf22 (&-> at-0 shrub-mat quad 2))
(.lvf vf23 (&-> at-0 shrub-mat trans 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))
(.lvf vf28 (&-> at-0 camera-temp quad 0))
(.lvf vf29 (&-> at-0 camera-temp quad 1))
(.lvf vf30 (&-> at-0 camera-temp quad 2))
(.lvf vf31 (&-> at-0 camera-temp trans quad))
)
(if (nonzero? (-> this drawable-trees))
(collect-stats (-> this drawable-trees))
)
0
(none)
)
)
;; definition for function bsp-camera-asm
;; WARN: Return type mismatch int vs none.
;; ERROR: Unsupported inline assembly instruction kind - [srl t3, t3, 24]
;; ERROR: Unsupported inline assembly instruction kind - [srl t2, t2, 24]
(defun bsp-camera-asm ((arg0 bsp-header) (arg1 vector))
(local-vars
(a2-1 object)
(cam-pos-i1 uint128)
(cam-pos-32 uint128)
(cam-pos-16 uint128)
(cam-pos-8 uint128)
(t0-5 uint)
(b-flag uint)
(f-flag int)
(front-max-compare uint128)
(back-max-compare uint128)
(front-min-compare uint128)
(back-min-compare uint128)
)
(rlet ((Q :class vf)
(vf0 :class vf)
(vf1 :class vf)
(vf2 :class vf)
(vf3 :class vf)
)
(init-vf0-vector)
(nop!)
(.lvf vf3 (&-> arg0 bsp-scale quad))
(let ((nodes (the-as object (-> arg0 nodes))))
(.lvf vf1 (&-> arg1 quad))
(.lvf vf2 (&-> arg0 bsp-offset quad))
(.sub.vf.xyz vf1 vf1 vf2)
(.div.vf Q vf0 vf3 :fsf #b11 :ftf #b0)
(.wait.vf)
(.mul.vf.x vf1 vf1 Q)
(.div.vf Q vf0 vf3 :fsf #b11 :ftf #b1)
(.wait.vf)
(.mul.vf.y vf1 vf1 Q)
(.div.vf Q vf0 vf3 :fsf #b11 :ftf #b10)
(.wait.vf)
(.mul.vf.z vf1 vf1 Q)
(let ((a1-1 #xffffff)
(nidx (the-as object 0))
)
(vftoi15.xyzw vf1 vf1)
(.mov cam-pos-i1 vf1)
(.pw.sra cam-pos-32 cam-pos-i1 15)
(.ppach cam-pos-16 (the-as uint128 0) cam-pos-32)
(.ppacb cam-pos-8 (the-as uint128 0) cam-pos-16)
(let ((cam-pos-8m (the-as uint128 (logand (the-as int cam-pos-8) a1-1))))
(label cfg-1)
(let ((node (the-as bsp-node (&+ (the-as pointer nodes) (+ (* nidx 16) (* nidx 4))))))
(nop!)
(let ((front-min (the-as uint128 (-> node front-box-min clr))))
(.pcgtb front-min-compare front-min cam-pos-8m)
(let ((front-max (the-as uint128 (-> node front-box-max clr))))
(.pcgtb front-max-compare front-max cam-pos-8m)
)
(let ((back-min (the-as uint128 (-> node back-box-min clr))))
(.pcgtb back-min-compare back-min cam-pos-8m)
(let ((back-max (the-as uint128 (-> node back-box-max clr))))
(.pcgtb back-max-compare back-max cam-pos-8m)
)
(let* ((front-idx (-> node front))
(not-f-min (lognot (the-as int front-min-compare)))
(not-b-min (lognot (the-as int back-min-compare)))
(t4-1 (logand not-f-min (the-as int front-max-compare)))
(t5-1 (logand not-b-min (the-as int back-max-compare)))
(f-in-box (logand t4-1 a1-1))
(b-in-box (logand t5-1 a1-1))
)
(.srl f-flag (the-as uint front-min) 24)
(let ((back-idx (the-as bsp-node (-> node back))))
(b! (= f-in-box a1-1) cfg-4 :delay (.srl b-flag (the-as int back-min) 24))
(b! (= b-in-box a1-1) cfg-7 :delay (set! t0-5 (the-as uint 1)))
(b! #t cfg-11 :delay (set! (-> arg0 cam-outside-bsp) t0-5))
(label cfg-4)
(b! (zero? f-flag) cfg-1 :likely-delay (set! nidx front-idx))
(let ((v1-1 nidx))
(set! (-> arg0 cam-using-back) (the-as uint 0))
(b! #t cfg-10 :delay (set! a2-1 front-idx))
(label cfg-7)
(b! (zero? b-flag) cfg-1 :likely-delay (set! nidx back-idx))
(set! v1-1 nidx)
(set! a2-1 back-idx)
(set! (-> arg0 cam-using-back) (the-as uint 1))
(label cfg-10)
(set! (-> arg0 current-leaf-idx) (the-as uint a2-1))
(set! (-> arg0 cam-box-idx) (the-as uint v1-1))
)
)
)
)
)
)
)
)
)
(set! (-> arg0 cam-outside-bsp) (the-as uint 0))
(label cfg-11)
0
(none)
)
)
;; definition for method 16 of type bsp-header
;; WARN: Return type mismatch int vs none.
(defmethod collect-regions ((this bsp-header) (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"
(let ((s3-0 (-> this region-trees)))
(dotimes (s2-0 (-> s3-0 length))
(collect-regions (-> s3-0 s2-0) arg0 arg1 arg2)
)
)
0
(none)
)
;; definition for function print-collide-stats
;; WARN: Return type mismatch int vs none.
;; ERROR: Function may read a register that is not set: t0
(defun print-collide-stats ()
(local-vars (t0-0 none))
(format *stdcon* "~0k~%count cycles instr icache dcache vu0/to/from~%")
(print-to-stream (-> *perf-stats* data 3) "collide" *stdcon*)
(print-to-stream (-> *perf-stats* data 4) "collide-list" *stdcon*)
(print-to-stream (-> *perf-stats* data 5) "collide-fill" *stdcon*)
(format *stdcon* "~0k---------------------------------------------------------------~%")
(format *stdcon* "~0kcalls = ~d~%" (-> *collide-stats* calls))
(format
*stdcon*
"~0kspheres = ~d~256hspheres/call = ~f~%"
(-> *collide-stats* spheres)
(/ (the float (-> *collide-stats* spheres)) (the float (-> *collide-stats* calls)))
t0-0
)
(format
*stdcon*
"~0knodes = ~d~256hnodes/call = ~f~%"
(-> *collide-stats* nodes)
(/ (the float (-> *collide-stats* nodes)) (the float (-> *collide-stats* calls)))
t0-0
)
(format
*stdcon*
"~0kfrags = ~d~256hfrags/call = ~f~%"
(-> *collide-stats* frags)
(/ (the float (-> *collide-stats* frags)) (the float (-> *collide-stats* calls)))
t0-0
)
(format
*stdcon*
"~0ktris = ~d~256htris/frag = ~f~%"
(-> *collide-stats* tris)
(/ (the float (-> *collide-stats* tris)) (the float (-> *collide-stats* frags)))
t0-0
)
(format
*stdcon*
"~0koutput = ~d~256houtput/call = ~f~%"
(-> *collide-stats* output)
(/ (the float (-> *collide-stats* output)) (the float (-> *collide-stats* calls)))
t0-0
)
(format *stdcon* "~0k---------------------------------------------------------------~%")
(let ((gp-0 (stopwatch-elapsed-ticks (the-as stopwatch (&-> *collide-stats* pad0 1))))
(s4-0 (stopwatch-elapsed-ticks (the-as stopwatch (&-> *collide-stats* total-target 7))))
(s5-0 (stopwatch-elapsed-ticks (the-as stopwatch (&-> *collide-stats* target-cache-fill 7))))
)
(format *stdcon* "~0ktotal-target ~D~%" gp-0)
(format *stdcon* "~0ktarget-cache-fill ~D ~0,,2f%~%" s4-0 (/ (* 100.0 (the float s4-0)) (the float gp-0)))
(format *stdcon* "~0ktarget-ray-poly ~D ~0,,2f%~%" s5-0 (/ (* 100.0 (the float s5-0)) (the float gp-0)))
)
(set! (-> *collide-stats* calls) (the-as uint 0))
(set! (-> *collide-stats* spheres) (the-as uint 0))
(set! (-> *collide-stats* nodes) (the-as uint 0))
(set! (-> *collide-stats* frags) (the-as uint 0))
(set! (-> *collide-stats* tris) (the-as uint 0))
(set! (-> *collide-stats* output) (the-as uint 0))
(stopwatch-init (the-as stopwatch (&-> *collide-stats* pad0 1)))
(stopwatch-init (the-as stopwatch (&-> *collide-stats* total-target 7)))
(stopwatch-init (the-as stopwatch (&-> *collide-stats* target-cache-fill 7)))
0
(none)
)
;; definition for function level-remap-texture
;; WARN: Return type mismatch uint vs texture-id.
(defun level-remap-texture ((arg0 texture-id))
(let ((v1-1 (-> *level* log-in-level-bsp)))
(when v1-1
(let* ((a3-0 (-> v1-1 texture-remap-table-len))
(v1-2 (the-as object (-> v1-1 texture-remap-table)))
(t0-0 (the-as (pointer uint64) v1-2))
(a1-1 (the-as uint #xfffffff8))
(a2-1 (logand (new 'static 'texture-id :index #xfff :page #xfff) arg0))
(a3-2 (the-as object (&+ t0-0 (* a3-0 8))))
)
(label cfg-2)
(b! (= v1-2 a3-2) cfg-8 :delay (nop!))
(let ((t0-3 (the-as object (logand (/ (+ (the-as int v1-2) (the-as int a3-2)) 2) a1-1))))
(let ((t1-1 (- (-> (the-as (pointer uint32) t0-3) 0) a2-1)))
(b! (zero? t1-1) cfg-7 :delay (nop!))
(b! (< (the-as int t1-1) 0) cfg-6 :delay (nop!))
)
(b! #t cfg-2 :delay (set! a3-2 (the-as (pointer uint64) t0-3)))
(label cfg-6)
(b! #t cfg-2 :delay (set! v1-2 (+ (the-as int t0-3) 8)))
(label cfg-7)
(set! arg0 (the-as texture-id (logior (-> (the-as (pointer uint32) t0-3) 1) 20)))
)
)
(label cfg-8)
0
)
)
(the-as texture-id arg0)
)
;; definition for function build-masks
;; INFO: Used lq/sq
;; WARN: Return type mismatch int vs none.
(defun build-masks ((arg0 bsp-header))
(let ((v1-0 (-> arg0 drawable-trees))
(s2-0 (-> arg0 tfrag-closest))
(s3-0 (-> arg0 shrub-closest))
(s4-0 (-> arg0 alpha-closest))
(gp-0 (-> arg0 water-closest))
)
(when (zero? (&+ (+ (&+ s2-0 s3-0) (the-as int s4-0)) gp-0))
(dotimes (a0-5 (-> v1-0 length))
(let ((a1-2 (-> v1-0 trees a0-5)))
(cond
((= (-> a1-2 type) drawable-tree-tfrag)
(let* ((a2-5 (-> (the-as drawable-tree-tfrag a1-2) arrays (+ (-> (the-as drawable-tree-tfrag a1-2) length) -1)))
(a1-4 (-> a2-5 length))
(a2-6 (-> (the-as drawable-inline-array-tfrag a2-5) data))
)
(dotimes (a3-1 a1-4)
(set! (-> a2-6 0 texture-masks-index) (the-as uint s2-0))
(&+! s2-0 1)
(set! a2-6 (the-as (inline-array tfragment) (-> a2-6 1)))
)
)
)
((= (-> a1-2 type) drawable-tree-tfrag-trans)
(let* ((a2-13
(-> (the-as drawable-tree-tfrag-trans a1-2) arrays (+ (-> (the-as drawable-tree-tfrag-trans a1-2) length) -1))
)
(a1-7 (-> a2-13 length))
(a2-14 (-> (the-as drawable-inline-array-tfrag a2-13) data))
)
(dotimes (a3-3 a1-7)
(set! (-> a2-14 0 texture-masks-index) (the-as uint s4-0))
(&+! s4-0 1)
(set! a2-14 (the-as (inline-array tfragment) (-> a2-14 1)))
)
)
)
((= (-> a1-2 type) drawable-tree-tfrag-water)
(let* ((a2-21
(-> (the-as drawable-tree-tfrag-water a1-2) arrays (+ (-> (the-as drawable-tree-tfrag-water a1-2) length) -1))
)
(a1-10 (-> a2-21 length))
(a2-22 (-> (the-as drawable-inline-array-tfrag a2-21) data))
)
(dotimes (a3-5 a1-10)
(set! (-> a2-22 0 texture-masks-index) (the-as uint gp-0))
(&+! gp-0 1)
(set! a2-22 (the-as (inline-array tfragment) (-> a2-22 1)))
)
)
)
((= (-> a1-2 type) drawable-tree-instance-tie)
(let* ((a1-13 (-> (the-as drawable-tree-instance-tie a1-2) prototypes prototype-array-tie))
(a2-26 (-> a1-13 length))
)
(dotimes (a3-7 a2-26)
(cond
((logtest? (-> a1-13 array-data a3-7 flags) (prototype-flags tpage-water))
(set! (-> a1-13 array-data a3-7 texture-masks-index) (the-as uint gp-0))
(&+! gp-0 1)
)
((logtest? (-> a1-13 array-data a3-7 flags) (prototype-flags tpage-alpha))
(set! (-> a1-13 array-data a3-7 texture-masks-index) (the-as uint s4-0))
(&+! s4-0 1)
)
(else
(set! (-> a1-13 array-data a3-7 texture-masks-index) (the-as uint s2-0))
(&+! s2-0 1)
)
)
)
)
)
((= (-> a1-2 type) drawable-tree-instance-shrub)
(let* ((a2-30 (-> (the-as drawable-tree-instance-shrub a1-2) info prototype-inline-array-shrub))
(a1-16 (-> a2-30 length))
(a2-31 (-> a2-30 data))
)
(dotimes (a3-9 a1-16)
(set! (-> a2-31 0 texture-masks-index) (the-as uint s3-0))
(&+! s3-0 1)
(set! a2-31 (the-as (inline-array prototype-bucket-shrub) (-> a2-31 1)))
)
)
)
)
)
)
)
(when (nonzero? s2-0)
(set! (-> arg0 tfrag-masks) (new 'loading-level 'texture-masks-array (the-as int s2-0)))
(set! (-> arg0 tfrag-closest) (the-as (pointer float) (malloc 'loading-level (the-as int (* s2-0 4)))))
(let ((v1-5 (-> arg0 tfrag-masks)))
(dotimes (a0-8 (the-as int s2-0))
(let ((a1-24 (-> v1-5 data a0-8)))
(dotimes (a2-34 3)
(set! (-> a1-24 data a2-34 mask quad) (the-as uint128 0))
)
)
)
)
)
(when (nonzero? s3-0)
(set! (-> arg0 shrub-masks) (new 'loading-level 'texture-masks-array (the-as int s3-0)))
(set! (-> arg0 shrub-closest) (the-as (pointer float) (malloc 'loading-level (the-as int (* s3-0 4)))))
(let ((v1-10 (-> arg0 shrub-masks)))
(dotimes (a0-11 (the-as int s3-0))
(let ((a1-32 (-> v1-10 data a0-11)))
(dotimes (a2-36 3)
(set! (-> a1-32 data a2-36 mask quad) (the-as uint128 0))
)
)
)
)
)
(when (nonzero? s4-0)
(set! (-> arg0 alpha-masks) (new 'loading-level 'texture-masks-array (the-as int s4-0)))
(set! (-> arg0 alpha-closest) (the-as (pointer float) (malloc 'loading-level (the-as int (* s4-0 4)))))
(let ((v1-15 (-> arg0 alpha-masks)))
(dotimes (a0-14 (the-as int s4-0))
(let ((a1-40 (-> v1-15 data a0-14)))
(dotimes (a2-38 3)
(set! (-> a1-40 data a2-38 mask quad) (the-as uint128 0))
)
)
)
)
)
(when (nonzero? gp-0)
(set! (-> arg0 water-masks) (new 'loading-level 'texture-masks-array (the-as int gp-0)))
(set! (-> arg0 water-closest) (the-as (pointer float) (malloc 'loading-level (the-as int (* gp-0 4)))))
(let ((v1-20 (-> arg0 water-masks)))
(dotimes (a0-17 (the-as int gp-0))
(let ((a1-48 (-> v1-20 data a0-17)))
(dotimes (a2-40 3)
(set! (-> a1-48 data a2-40 mask quad) (the-as uint128 0))
)
)
)
)
)
)
0
(none)
)