mirror of
https://github.com/open-goal/jak-project
synced 2026-08-07 02:06:59 -04:00
c162c66118
This PR does two main things: 1. Work through the main low-hanging fruit issues in the formatter keeping it from feeling mature and usable 2. Iterate and prove that point by formatting all of the Jak 1 code base. **This has removed around 100K lines in total.** - The decompiler will now format it's results for jak 1 to keep things from drifting back to where they were. This is controlled by a new config flag `format_code`. How am I confident this hasn't broken anything?: - I compiled the entire project and stored it's `out/jak1/obj` files separately - I then recompiled the project after formatting and wrote a script that md5's each file and compares it (`compare-compilation-outputs.py` - The results (eventually) were the same:  > This proves that the only difference before and after is non-critical whitespace for all code/macros that is actually in use. I'm still aware of improvements that could be made to the formatter, as well as general optimization of it's performance. But in general these are for rare or non-critical situations in my opinion and I'll work through them before doing Jak 2. The vast majority looks great and is working properly at this point. Those known issues are the following if you are curious: 
69 lines
3.0 KiB
Common Lisp
69 lines
3.0 KiB
Common Lisp
;;-*-Lisp-*-
|
|
(in-package goal)
|
|
(bundles "ENGINE.CGO" "GAME.CGO")
|
|
(require "kernel/gkernel-h.gc")
|
|
(declare-type ambient-list structure)
|
|
|
|
(declare-type collide-list structure)
|
|
|
|
(declare-type drawable-error drawable)
|
|
|
|
;; These is the base class for the scene graph node.
|
|
;; Note that it doesn't always make sense to call all of these methods on all types,
|
|
;; and that certain methods should only be called at certain times, and may require coordination
|
|
;; with having certain VU0 or scratchpad data present.
|
|
;; In many cases, "draw" simply adds data to a buffer that must later be converted to dma in finish-background
|
|
;; or similar. Or just does nothing.
|
|
|
|
;; DECOMP BEGINS
|
|
|
|
(deftype drawable (basic)
|
|
((id int16) ;; ID number for visibility (not always used)
|
|
(bsphere vector :inline) ;; bounding sphere
|
|
)
|
|
(:methods
|
|
;; initialize the drawable after it has been loaded.
|
|
(login (_type_) _type_)
|
|
;; do some sort of drawing... this really does different things for different types.
|
|
(draw (_type_ _type_ display-frame) none)
|
|
;; add collision meshes to the given collide list if they intersect the bounding box in *collide-work*
|
|
;; the integer argument can be used to call this method on an inline-array of drawables (only some support this)
|
|
;; this avoids the dynamic dispatch on each element of the array.
|
|
(collide-with-box (_type_ int collide-list) none)
|
|
;; similar to above, but only add if the collision mesh intersects with a "y probe"
|
|
(collide-y-probe (_type_ int collide-list) none)
|
|
;; similar to above, but only add if the collision mesh intersects a ray of spheres.
|
|
(collide-ray (_type_ int collide-list) none)
|
|
;; different for different types, but generally collects debug statistics like numbers of triangles
|
|
(collect-stats (_type_) none)
|
|
;; different for different types, but usually does nothing.
|
|
(debug-draw (_type_ drawable display-frame) none)
|
|
;; given VIS data (uncompressed), compute the visiblity bit string.
|
|
(unpack-vis (_type_ (pointer int8) (pointer int8)) (pointer int8))
|
|
;; find "ambients" inside the given sphere and add to list.
|
|
(collect-ambients (_type_ sphere int ambient-list) none)))
|
|
|
|
;; A drawable that simply draws a sphere and an error message at the origin of the bounding sphere.
|
|
(deftype drawable-error (drawable)
|
|
((name string)))
|
|
|
|
(declare-type process-drawable process)
|
|
|
|
(define-extern process-drawable-art-error (state string process-drawable))
|
|
|
|
(define-extern foreground-engine-execute (function engine display-frame int int none))
|
|
|
|
(define-extern sphere-in-view-frustum? (function sphere symbol))
|
|
|
|
(declare-type draw-control basic)
|
|
|
|
(define-extern add-process-drawable (function process-drawable draw-control symbol dma-buffer none))
|
|
|
|
(define-extern dma-add-process-drawable-hud (function process-drawable draw-control symbol dma-buffer none))
|
|
|
|
(define-extern dma-add-process-drawable (function process-drawable draw-control symbol dma-buffer none))
|
|
|
|
(define-extern vis-cull (function int symbol))
|
|
|
|
(define-extern line-in-view-frustum? (function vector vector symbol)) ;; TODO - not confirmed
|