mirror of
https://github.com/open-goal/jak-project.git
synced 2024-10-20 11:26:18 -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: ![Screenshot 2024-05-25 132900](https://github.com/open-goal/jak-project/assets/13153231/015e6f20-8d19-49b7-9951-97fa88ddc6c2) > 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: ![image](https://github.com/open-goal/jak-project/assets/13153231/0edfaba1-6d36-40f5-ab23-0642209867c4)
82 lines
3.4 KiB
Common Lisp
82 lines
3.4 KiB
Common Lisp
;;-*-Lisp-*-
|
|
(in-package goal)
|
|
(bundles "ENGINE.CGO" "GAME.CGO")
|
|
(require "engine/entity/res.gc")
|
|
(require "kernel/gstate.gc")
|
|
(require "engine/draw/drawable-h.gc")
|
|
(require "engine/game/main-h.gc")
|
|
(require "engine/entity/entity-h.gc")
|
|
(require "engine/game/game-h.gc")
|
|
|
|
;; DECOMP BEGINS
|
|
|
|
(deftype plane-volume (structure)
|
|
((volume-type symbol)
|
|
(point-count int16)
|
|
(normal-count int16)
|
|
(first-point (pointer vector))
|
|
(first-normal (pointer vector))
|
|
(num-planes int32)
|
|
(plane (inline-array plane)))
|
|
:pack-me
|
|
(:methods
|
|
(init-vol! (_type_ symbol vector-array vector-array) symbol)
|
|
(debug-draw (_type_) none)
|
|
(point-in-vol? (_type_ vector float) symbol)))
|
|
|
|
(deftype vol-control (basic)
|
|
((flags uint32)
|
|
(process process-drawable)
|
|
(pos-vol-count int32)
|
|
(pos-vol plane-volume 32 :inline)
|
|
(neg-vol-count int32)
|
|
(neg-vol plane-volume 32 :inline)
|
|
(debug-point vector-array)
|
|
(debug-normal vector-array))
|
|
(:methods
|
|
(new (symbol type process-drawable) _type_)
|
|
(init! (_type_) symbol)
|
|
(point-in-vol? (_type_ vector) symbol)
|
|
(vol-control-method-11 (_type_) symbol)))
|
|
|
|
(defmethod new vol-control ((allocation symbol) (type-to-make type) (arg0 process-drawable))
|
|
(let ((gp-0 (the-as object (object-new allocation type-to-make (the-as int (-> type-to-make size))))))
|
|
(when (zero? (the-as vol-control gp-0))
|
|
(go process-drawable-art-error "memory")
|
|
(set! gp-0 0)
|
|
(goto cfg-13))
|
|
(set! (-> (the-as vol-control gp-0) process) arg0)
|
|
(let* ((s5-1 (the-as res-lump (-> (the-as vol-control gp-0) process entity)))
|
|
(s4-0 (-> ((method-of-type res-lump lookup-tag-idx) (the-as entity-actor s5-1) 'vol 'exact 0.0) lo)))
|
|
(when (>= (the-as int s4-0) 0)
|
|
(let ((s3-0 (the-as int s4-0))
|
|
(s2-0 (-> s5-1 tag s4-0)))
|
|
0
|
|
(while (= (-> s2-0 name) (-> s5-1 tag s4-0 name))
|
|
(let ((v1-12 (make-property-data s5-1 0.0 (the-as res-tag-pair s3-0) (the-as pointer #f)))
|
|
(a0-8 (-> (the-as vol-control gp-0) pos-vol (-> (the-as vol-control gp-0) pos-vol-count))))
|
|
(set! (-> a0-8 num-planes) (the-as int (-> s2-0 elt-count)))
|
|
(set! (-> a0-8 plane) (the-as (inline-array plane) v1-12)))
|
|
(+! (-> (the-as vol-control gp-0) pos-vol-count) 1)
|
|
(+! s3-0 1)
|
|
(set! s2-0 (-> s5-1 tag s3-0))))))
|
|
(let* ((s5-2 (the-as res-lump (-> (the-as vol-control gp-0) process entity)))
|
|
(s4-1 (-> ((method-of-type res-lump lookup-tag-idx) (the-as entity-actor s5-2) 'cutoutvol 'exact 0.0) lo)))
|
|
(when (>= (the-as int s4-1) 0)
|
|
(let ((s3-1 (the-as int s4-1))
|
|
(s2-1 (-> s5-2 tag s4-1)))
|
|
0
|
|
(while (= (-> s2-1 name) (-> s5-2 tag s4-1 name))
|
|
(let ((v1-31 (make-property-data s5-2 0.0 (the-as res-tag-pair s3-1) (the-as pointer #f)))
|
|
(a0-19 (-> (the-as vol-control gp-0) neg-vol (-> (the-as vol-control gp-0) neg-vol-count))))
|
|
(set! (-> a0-19 num-planes) (the-as int (-> s2-1 elt-count)))
|
|
(set! (-> a0-19 plane) (the-as (inline-array plane) v1-31)))
|
|
(+! (-> (the-as vol-control gp-0) neg-vol-count) 1)
|
|
(+! s3-1 1)
|
|
(set! s2-1 (-> s5-2 tag s3-1))))))
|
|
(label cfg-13)
|
|
(the-as vol-control gp-0)))
|
|
|
|
(defmethod vol-control-method-11 ((this vol-control))
|
|
(and *display-vol-marks* (logtest? (-> this flags) 1)))
|