mirror of
https://github.com/open-goal/jak-project
synced 2026-08-19 06:02:15 -04:00
d1ece445d4
Relates to #1353 This adds no new functionality or overhead to the compiler, yet. This is the preliminary work that has: - added code to the compiler in several spots to flag when something is used without being properly required/imported/whatever (disabled by default) - that was used to generate project wide file dependencies (some circulars were manually fixed) - then that graph underwent a transitive reduction and the result was written to all `jak1` source files. The next step will be making this actually produce and use a dependency graph. Some of the reasons why I'm working on this: - eliminates more `game.gp` boilerplate. This includes the `.gd` files to some extent (`*-ag` files and `tpage` files will still need to be handled) this is the point of the new `bundles` form. This should make it even easier to add a new file into the source tree. - a build order that is actually informed from something real and compiler warnings that tell you when you are using something that won't be available at build time. - narrows the search space for doing LSP actions -- like searching for references. Since it would be way too much work to store in the compiler every location where every symbol/function/etc is used, I have to do ad-hoc searches. By having a dependency graph i can significantly reduce that search space. - opens the doors for common shared code with a legitimate pattern. Right now jak 2 shares code from the jak 1 folder. This is basically a hack -- but by having an explicit require syntax, it would be possible to reference arbitrary file paths, such as a `common` folder. Some stats: - Jak 1 has about 2500 edges between files, including transitives - With transitives reduced at the source code level, each file seems to have a modest amount of explicit requirements. Known issues: - Tracking the location for where `defmacro`s and virtual state definitions were defined (and therefore the file) is still problematic. Because those forms are in a macro environment, the reader does not track them. I'm wondering if a workaround could be to search the reader's text_db by not just the `goos::Object` but by the text position. But for the purposes of finishing this work, I just statically analyzed and searched the code with throwaway python code.
207 lines
6.1 KiB
Common Lisp
207 lines
6.1 KiB
Common Lisp
;;-*-Lisp-*-
|
|
(in-package goal)
|
|
(bundles "ENGINE.CGO" "GAME.CGO")
|
|
|
|
(require "engine/gfx/sprite/sparticle/sparticle-h.gc")
|
|
(require "engine/physics/dynamics-h.gc")
|
|
(require "engine/collide/collide-cache.gc")
|
|
(require "engine/gfx/shadow/shadow-h.gc")
|
|
(require "engine/gfx/sprite/sparticle/sparticle-launcher-h.gc")
|
|
|
|
;; name: shadow.gc
|
|
;; name in dgo: shadow
|
|
;; dgos: GAME, ENGINE
|
|
|
|
;; DECOMP BEGINS
|
|
|
|
(defun add-fake-shadow-to-buffer ((arg0 vector) (arg1 vector) (arg2 float) (arg3 int))
|
|
(let ((v1-0 *fake-shadow-buffer*))
|
|
(when (< (-> v1-0 num-shadows) 32)
|
|
(let ((t0-5 (-> v1-0 data (-> v1-0 num-shadows))))
|
|
(set! (-> t0-5 px) (-> arg0 x))
|
|
(set! (-> t0-5 py) (-> arg0 y))
|
|
(set! (-> t0-5 pz) (-> arg0 z))
|
|
(set! (-> t0-5 scale) arg2)
|
|
(set! (-> t0-5 qx) (-> arg1 x))
|
|
(set! (-> t0-5 qy) (-> arg1 y))
|
|
(set! (-> t0-5 qz) (-> arg1 z))
|
|
(set! (-> t0-5 flags) arg3)
|
|
)
|
|
(+! (-> v1-0 num-shadows) 1)
|
|
)
|
|
)
|
|
0
|
|
(none)
|
|
)
|
|
|
|
(defun swap-fake-shadow-buffers ()
|
|
(set! *fake-shadow-buffer* (if (= *fake-shadow-buffer* *fake-shadow-buffer-1*)
|
|
*fake-shadow-buffer-2*
|
|
*fake-shadow-buffer-1*
|
|
)
|
|
)
|
|
(set! (-> *fake-shadow-buffer* num-shadows) 0)
|
|
0
|
|
(none)
|
|
)
|
|
|
|
(defun draw-shadow ((arg0 vector) (arg1 vector) (arg2 vector) (arg3 float) (arg4 float) (arg5 float))
|
|
(let ((f0-1 (- (-> arg0 y) (-> arg1 y))))
|
|
(if (< f0-1 arg4)
|
|
(add-fake-shadow-to-buffer arg1 arg2 (* (- 1.0 (/ f0-1 arg4)) arg3) (the-as int arg5))
|
|
)
|
|
)
|
|
0
|
|
(none)
|
|
)
|
|
|
|
(defun compute-and-draw-shadow ((arg0 vector) (arg1 vector) (arg2 vector) (arg3 vector) (arg4 float) (arg5 float))
|
|
(local-vars
|
|
(v1-10 float)
|
|
(v1-11 float)
|
|
(sv-96 vector)
|
|
(sv-112 (function quaternion vector float quaternion))
|
|
(sv-128 vector)
|
|
(sv-144 vector)
|
|
)
|
|
(rlet ((vf0 :class vf)
|
|
(vf1 :class vf)
|
|
(vf2 :class vf)
|
|
)
|
|
(init-vf0-vector)
|
|
(set! sv-96 arg2)
|
|
(let ((s4-0 arg3)
|
|
(s3-0 arg4)
|
|
(s2-0 arg5)
|
|
)
|
|
(when (< (- (-> arg0 y) (-> arg1 y)) s3-0)
|
|
(set! sv-144 (new 'stack-no-clear 'vector))
|
|
(let ((s0-0 (new 'stack-no-clear 'vector))
|
|
(s1-0 (new 'stack-no-clear 'sparticle-cpuinfo))
|
|
)
|
|
(+! (-> arg1 y) 40.96)
|
|
(set! (-> sv-144 x) (-> sv-96 z))
|
|
(set! (-> sv-144 y) 0.0)
|
|
(set! (-> sv-144 z) (- (-> sv-96 x)))
|
|
(vector-normalize! sv-144 1.0)
|
|
(set! sv-112 quaternion-vector-angle!)
|
|
(set! sv-128 s0-0)
|
|
(let ((a2-1 (acos (-> sv-96 y))))
|
|
(sv-112 (the-as quaternion sv-128) sv-144 a2-1)
|
|
)
|
|
(let ((v1-9 s1-0))
|
|
(cond
|
|
((< (-> s0-0 w) 0.0)
|
|
(.lvf vf1 (&-> v1-9 vel-sxvel quad))
|
|
(.lvf vf2 (&-> s0-0 quad))
|
|
(.sub.vf vf1 vf0 vf2 :mask #b111)
|
|
(.svf (&-> v1-9 vel-sxvel quad) vf1)
|
|
(.mov v1-10 vf1)
|
|
)
|
|
(else
|
|
(.lvf vf1 (&-> v1-9 vel-sxvel quad))
|
|
(.lvf vf2 (&-> s0-0 quad))
|
|
(.add.vf vf1 vf0 vf2 :mask #b111)
|
|
(.svf (&-> v1-9 vel-sxvel quad) vf1)
|
|
(.mov v1-11 vf1)
|
|
)
|
|
)
|
|
)
|
|
(draw-shadow arg0 arg1 (-> s1-0 vel-sxvel) (the-as float s4-0) s3-0 s2-0)
|
|
)
|
|
)
|
|
)
|
|
0
|
|
(none)
|
|
)
|
|
)
|
|
|
|
(defun find-ground-and-draw-shadow ((arg0 vector)
|
|
(arg1 vector)
|
|
(arg2 float)
|
|
(arg3 collide-kind)
|
|
(arg4 process-drawable)
|
|
(arg5 float)
|
|
(arg6 float)
|
|
)
|
|
(let ((s2-0 (new 'stack-no-clear 'vector)))
|
|
(set! (-> s2-0 quad) (-> arg0 quad))
|
|
(new 'stack-no-clear 'vector)
|
|
(+! (-> s2-0 y) arg5)
|
|
(let ((s4-0 (new 'stack-no-clear 'collide-tri-result)))
|
|
(cond
|
|
((>= (fill-and-probe-using-y-probe
|
|
*collide-cache*
|
|
s2-0
|
|
arg6
|
|
arg3
|
|
arg4
|
|
s4-0
|
|
(new 'static 'pat-surface :noentity #x1)
|
|
)
|
|
0.0
|
|
)
|
|
(if (!= arg2 0.0)
|
|
(compute-and-draw-shadow s2-0 (-> s4-0 intersect) (-> s4-0 normal) (the-as vector arg2) arg6 (the-as float 0))
|
|
)
|
|
(if (and arg1 (!= (-> s4-0 pat material) 3))
|
|
(set! (-> arg1 quad) (-> s4-0 intersect quad))
|
|
)
|
|
)
|
|
(else
|
|
(if arg1
|
|
(vector+float*! arg1 arg0 (-> *standard-dynamics* gravity-normal) (- arg6))
|
|
)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
0
|
|
(none)
|
|
)
|
|
|
|
(defbehavior do-target-shadow target ()
|
|
(if (and (logtest? (-> self control status) (cshape-moving-flags onsurf))
|
|
(!= (-> self control unknown-surface00 mode) 'swim)
|
|
(!= (-> self control unknown-surface00 mode) 'dive)
|
|
(!= (-> self next-state name) 'target-flop)
|
|
(not (logtest? (-> self draw status) (draw-status hidden no-anim skip-bones)))
|
|
)
|
|
(set! (-> self control shadow-pos quad) (-> self control trans quad))
|
|
(find-ground-and-draw-shadow
|
|
(-> self control trans)
|
|
(-> self control shadow-pos)
|
|
0.0
|
|
(-> (the-as collide-shape-prim (-> self control root-prim)) collide-with)
|
|
self
|
|
0.0
|
|
81920.0
|
|
)
|
|
)
|
|
0
|
|
(none)
|
|
)
|
|
|
|
(defpart 362
|
|
:init-specs ((:texture (new 'static 'texture-id :page #x2))
|
|
(:num 8.0)
|
|
(:scale-x (meters 0.3))
|
|
(:rot-z (degrees -180) (degrees 360))
|
|
(:scale-y :copy scale-x)
|
|
(:r 90.0)
|
|
(:g 90.0)
|
|
(:b 90.0)
|
|
(:a 20.0 20.0)
|
|
(:vel-y (meters 0.002))
|
|
(:scalevel-x (meters 0.004166667))
|
|
(:scalevel-y :copy scalevel-x)
|
|
(:fade-a -0.3)
|
|
(:timer (seconds 16.68))
|
|
(:flags (bit2 bit3))
|
|
(:launchrot-x (degrees -20) (degrees 15))
|
|
(:conerot-x (degrees 90))
|
|
(:conerot-y (degrees -180) (degrees 360))
|
|
(:conerot-radius (meters 0.2))
|
|
)
|
|
)
|