jak-project/goal_src/jak3/engine/collide/main-collide.gc
Hat Kid 93afb02cf4
decomp3: spawn target, add merc and particle buckets and some temporary hacks (#3445)
This includes all the collision stuff needed to spawn `target`,
decompiles the sparticle code and adds some of the PC hacks needed for
merc to run (it doesn't work quite right and looks bad, likely due to a
combination of code copied from Jak 2 and the time of day hacks).

There are a bunch of temporary hacks (see commits) in place to prevent
the game from crashing quite as much, but it is still extremely prone to
doing so due to lots of missing functions/potentially bad decomp.

---------

Co-authored-by: water <awaterford111445@gmail.com>
2024-04-05 00:07:39 -04:00

198 lines
4.7 KiB
Common Lisp

;;-*-Lisp-*-
(in-package goal)
;; name: main-collide.gc
;; name in dgo: main-collide
;; dgos: GAME
;; DECOMP BEGINS
(defun drawable-sphere-box-intersect? ((arg0 drawable) (arg1 bounding-box4w))
(local-vars (v1-1 uint128) (v1-2 uint128) (v1-3 uint128) (a0-1 uint128) (a1-2 uint128) (a2-0 uint128))
(rlet ((vf1 :class vf)
(vf2 :class vf)
(vf3 :class vf)
(vf4 :class vf)
)
(nop!)
(nop!)
(.lvf vf1 (&-> arg0 bsphere quad))
(.add.w.vf vf2 vf1 vf1 :mask #b111)
(let ((v1-0 (-> arg1 min quad)))
(.sub.w.vf vf1 vf1 vf1 :mask #b111)
(let ((a1-1 (-> arg1 max quad)))
(.ftoi.vf vf4 vf2)
(nop!)
(.ftoi.vf vf3 vf1)
(nop!)
(.mov a0-1 vf4)
(nop!)
(.mov a2-0 vf3)
(nop!)
(.pcgtw a1-2 a2-0 a1-1)
)
(nop!)
(.pcgtw v1-1 v1-0 a0-1)
)
(nop!)
(.por v1-2 a1-2 v1-1)
(nop!)
(.ppach v1-3 (the-as uint128 0) v1-2)
(nop!)
(let ((v1-4 (shl (the-as int v1-3) 16)))
(nop!)
(zero? v1-4)
)
)
)
(defun instance-sphere-box-intersect? ((arg0 drawable) (arg1 instance-tie) (arg2 bounding-box4w))
(local-vars
(v1-3 uint128)
(v1-4 uint128)
(v1-5 uint128)
(a0-2 uint128)
(a1-2 uint128)
(a2-1 uint128)
(a3-1 uint128)
(a3-3 uint128)
(a3-4 uint128)
(t0-1 uint128)
(t0-2 uint128)
(t1-0 uint128)
(t2-1 uint128)
(t2-2 uint128)
)
(rlet ((acc :class vf)
(vf0 :class vf)
(vf1 :class vf)
(vf10 :class vf)
(vf2 :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)
(nop!)
(let ((v1-0 (-> arg1 max-scale)))
(nop!)
(let ((a3-0 (the-as uint128 (-> arg1 origin long 3))))
(nop!)
(let ((t2-0 (the-as uint128 (-> arg1 origin long 0))))
(.pextlh a3-1 a3-0 0)
(let ((t0-0 (the-as uint128 (-> arg1 origin long 1))))
(.pw.sra t1-0 a3-1 10)
(let ((a3-2 (the-as uint128 (-> arg1 origin long 2))))
(.pextlh t2-1 t2-0 0)
(nop!)
(.pw.sra t2-2 t2-1 16)
(nop!)
(.pextlh t0-1 t0-0 0)
(.mov vf8 t1-0)
(.pw.sra t0-2 t0-1 16)
(.mov vf5 t2-2)
(.pextlh a3-3 a3-2 0)
)
)
)
)
(.mov vf6 t0-2)
(.pw.sra a3-4 a3-3 16)
(.lvf vf9 (&-> arg1 bsphere quad))
(nop!)
(.mov vf7 a3-4)
(nop!)
(.mov vf10 v1-0)
)
(.itof.vf vf8 vf8)
(nop!)
(vitof12.xyzw vf5 vf5)
(nop!)
(vitof12.xyzw vf6 vf6)
(nop!)
(vitof12.xyzw vf7 vf7)
(nop!)
(.add.vf vf8 vf8 vf9 :mask #b111)
(nop!)
(nop!)
(.lvf vf9 (&-> arg0 bsphere quad))
(vitof12.xyzw vf10 vf10)
(nop!)
(.mul.w.vf vf10 vf10 vf9 :mask #b1)
(nop!)
(.mul.x.vf acc vf5 vf9)
(nop!)
(.add.mul.y.vf acc vf6 vf9 acc)
(let ((v1-2 (-> arg2 min quad)))
(.add.mul.z.vf acc vf7 vf9 acc)
(let ((a1-1 (-> arg2 max quad)))
(.add.mul.w.vf vf1 vf8 vf0 acc)
(nop!)
(.add.x.vf vf2 vf1 vf10 :mask #b111)
(nop!)
(.sub.x.vf vf1 vf1 vf10 :mask #b111)
(nop!)
(.ftoi.vf vf4 vf2)
(nop!)
(.ftoi.vf vf3 vf1)
(nop!)
(.mov a0-2 vf4)
(nop!)
(.mov a2-1 vf3)
(nop!)
(.pcgtw a1-2 a2-1 a1-1)
)
(nop!)
(.pcgtw v1-3 v1-2 a0-2)
)
(nop!)
(.por v1-4 a1-2 v1-3)
(nop!)
(.ppach v1-5 (the-as uint128 0) v1-4)
(nop!)
(let ((v1-6 (shl (the-as int v1-5) 16)))
(nop!)
(zero? v1-6)
)
)
)
(defun instance-tfragment-add-debug-sphere ((arg0 drawable) (arg1 instance-tie))
(local-vars (v1-1 uint128) (v1-2 uint128) (a3-0 float))
(rlet ((vf0 :class vf)
(vf10 :class vf)
(vf11 :class vf)
(vf12 :class vf)
(vf9 :class vf)
)
(init-vf0-vector)
(nop!)
(let ((v1-0 (the-as uint128 (-> arg1 origin long 3))))
(.pextlh v1-1 v1-0 0)
)
(.lvf vf9 (&-> arg0 bsphere quad))
(.pw.sra v1-2 v1-1 10)
(.lvf vf10 (&-> arg1 bsphere quad))
(nop!)
(.mov vf12 v1-2)
(.itof.vf vf12 vf12)
(nop!)
(.add.vf vf10 vf10 vf12 :mask #b111)
(nop!)
(.add.vf vf9 vf9 vf10 :mask #b111)
(nop!)
(.add.w.vf vf11 vf0 vf9 :mask #b1)
(nop!)
(.mov a3-0 vf11)
(nop!)
(let ((a2-0 (new-stack-vector0)))
(.svf (&-> a2-0 quad) vf9)
(add-debug-sphere #t (bucket-id debug) a2-0 a3-0 (new 'static 'rgba :r #x80 :g #x80 :b #x80 :a #x80))
)
)
)