mirror of
https://github.com/open-goal/jak-project
synced 2026-08-08 10:34:30 -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: 
98 lines
3.6 KiB
Common Lisp
98 lines
3.6 KiB
Common Lisp
;;-*-Lisp-*-
|
|
(in-package goal)
|
|
(bundles "ENGINE.CGO" "GAME.CGO")
|
|
(require "kernel-defs.gc")
|
|
|
|
;; The "math-camera" is responsible for computing the projection matrix used in the renderer
|
|
;; from the position of the in-game camera. It also computes some other common camera info.
|
|
;; See cam-update.gc for how the game camera updates the math-camera.
|
|
|
|
;; It also contains some GIF stuff, but these seem to be wrong/unused.
|
|
;; Some of the code here may be extremely old and unused, but this does compute the camera projection
|
|
;; matrix used almost everywhere.
|
|
|
|
;; DECOMP BEGINS
|
|
|
|
(deftype vis-gif-tag (structure)
|
|
((fog0 uint32)
|
|
(strip uint32)
|
|
(regs uint32)
|
|
(fan uint32)))
|
|
|
|
(deftype cull-info (structure)
|
|
((x-fact float)
|
|
(y-fact float)
|
|
(z-fact float)
|
|
(cam-radius float)
|
|
(cam-x float)
|
|
(cam-y float)
|
|
(xz-dir-ax float)
|
|
(xz-dir-az float)
|
|
(xz-dir-bx float)
|
|
(xz-dir-bz float)
|
|
(xz-cross-ab float)
|
|
(yz-dir-ay float)
|
|
(yz-dir-az float)
|
|
(yz-dir-by float)
|
|
(yz-dir-bz float)
|
|
(yz-cross-ab float))
|
|
:pack-me)
|
|
|
|
(deftype math-camera (basic)
|
|
((d meters)
|
|
(f meters)
|
|
(fov degrees)
|
|
(x-ratio float)
|
|
(y-ratio float)
|
|
(x-pix float)
|
|
(x-clip float)
|
|
(x-clip-ratio-in float)
|
|
(x-clip-ratio-over float)
|
|
(y-pix float)
|
|
(y-clip float)
|
|
(y-clip-ratio-in float)
|
|
(y-clip-ratio-over float)
|
|
(cull-info cull-info :inline)
|
|
(fog-start meters)
|
|
(fog-end meters)
|
|
(fog-max float)
|
|
(fog-min float)
|
|
(reset int32)
|
|
(smooth-step float)
|
|
(smooth-t float)
|
|
(perspective matrix :inline)
|
|
(isometric matrix :inline)
|
|
(sprite-2d matrix :inline)
|
|
(sprite-2d-hvdf vector :inline)
|
|
(camera-rot matrix :inline)
|
|
(inv-camera-rot matrix :inline)
|
|
(inv-camera-rot-smooth matrix :inline)
|
|
(inv-camera-rot-smooth-from quaternion :inline)
|
|
;; this camera-temp is the main matrix used for renderers.
|
|
;; the camera code will set this.
|
|
;; it's designed so the renderers can do a single matrix-vector multiply
|
|
;; and then get fog, clipping, and final vertex position from the result.
|
|
(camera-temp matrix :inline)
|
|
(prev-camera-temp matrix :inline)
|
|
(hmge-scale vector :inline)
|
|
(inv-hmge-scale vector :inline)
|
|
(hvdf-off vector :inline)
|
|
(guard vector :inline)
|
|
(vis-gifs vis-gif-tag 4 :inline)
|
|
(vis-gifs-quads uint128 4 :overlay-at vis-gifs)
|
|
(giftex vis-gif-tag :overlay-at (-> vis-gifs 0))
|
|
(gifgr vis-gif-tag :overlay-at (-> vis-gifs 1))
|
|
(giftex-trans vis-gif-tag :overlay-at (-> vis-gifs 2))
|
|
(gifgr-trans vis-gif-tag :overlay-at (-> vis-gifs 3))
|
|
(pfog0 float)
|
|
(pfog1 float)
|
|
(trans vector :inline)
|
|
(plane plane 4 :inline)
|
|
(guard-plane plane 4 :inline)
|
|
(shrub-mat matrix :inline)
|
|
(fov-correction-factor float))
|
|
(:methods
|
|
(new (symbol type) _type_)))
|
|
|
|
(define-extern *math-camera* math-camera)
|