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: 
78 lines
2.6 KiB
Common Lisp
78 lines
2.6 KiB
Common Lisp
;;-*-Lisp-*-
|
|
(in-package goal)
|
|
(bundles "ENGINE.CGO" "GAME.CGO")
|
|
(require "engine/draw/drawable.gc")
|
|
|
|
;; DECOMP BEGINS
|
|
|
|
(defmethod new drawable-group ((allocation symbol) (type-to-make type) (arg0 int))
|
|
"Allocate a drawable-group with enough room for arg0 drawables"
|
|
(let ((v0-0 (object-new allocation type-to-make (the-as int (+ (-> type-to-make size) (* (+ arg0 -1) 4))))))
|
|
(set! (-> v0-0 length) arg0)
|
|
v0-0))
|
|
|
|
(defmethod inspect ((this drawable-group))
|
|
(format #t "[~8x] ~A~%" this (-> this type))
|
|
(format #t "~Tid: ~D~%" (-> this id))
|
|
(format #t "~Tlength: ~D~%" (-> this length))
|
|
(format #t "~Tdata[~D]: @ #x~X~%" (-> this length) (-> this data))
|
|
(dotimes (s5-0 (-> this length))
|
|
(format #t "~T [~D] ~A~%" s5-0 (-> this data s5-0)))
|
|
this)
|
|
|
|
(defmethod print ((this drawable-group))
|
|
(format #t "#<~A @ #x~X [~D]" (-> this type) this (-> this length))
|
|
(dotimes (s5-0 (-> this length))
|
|
(format #t " ~A" (-> this data s5-0)))
|
|
(format #t ">")
|
|
this)
|
|
|
|
(defmethod length ((this drawable-group))
|
|
(-> this length))
|
|
|
|
(defmethod asize-of ((this drawable-group))
|
|
(the-as int (+ (-> drawable-group size) (* (+ (-> this length) -1) 4))))
|
|
|
|
(defmethod mem-usage ((this drawable-group) (arg0 memory-usage-block) (arg1 int))
|
|
(set! (-> arg0 length) (max 1 (-> arg0 length)))
|
|
(set! (-> arg0 data 0 name) "drawable-group")
|
|
(+! (-> arg0 data 0 count) 1)
|
|
(let ((v1-6 (asize-of this))) (+! (-> arg0 data 0 used) v1-6) (+! (-> arg0 data 0 total) (logand -16 (+ v1-6 15))))
|
|
(dotimes (s3-0 (-> this length))
|
|
(mem-usage (-> this data s3-0) arg0 arg1))
|
|
this)
|
|
|
|
(defmethod login ((this drawable-group))
|
|
(dotimes (s5-0 (-> this length))
|
|
(login (-> this data s5-0)))
|
|
this)
|
|
|
|
(defmethod draw ((this drawable-group) (arg0 drawable-group) (arg1 display-frame))
|
|
(when (vis-cull (-> this id))
|
|
(when (sphere-cull (-> this bsphere))
|
|
(dotimes (s3-0 (-> this length))
|
|
(draw (-> this data s3-0) (-> arg0 data s3-0) arg1))))
|
|
0
|
|
(none))
|
|
|
|
(defmethod collect-stats ((this drawable-group))
|
|
(when (vis-cull (-> this id))
|
|
(when (sphere-cull (-> this bsphere))
|
|
(dotimes (s5-0 (-> this length))
|
|
(collect-stats (-> this data s5-0)))))
|
|
0
|
|
(none))
|
|
|
|
(defmethod debug-draw ((this drawable-group) (arg0 drawable) (arg1 display-frame))
|
|
(when (vis-cull (-> this id))
|
|
(when (sphere-cull (-> this bsphere))
|
|
(dotimes (s3-0 (-> this length))
|
|
(debug-draw (-> this data s3-0) (-> (the-as drawable-group arg0) data s3-0) arg1))))
|
|
0
|
|
(none))
|
|
|
|
(defmethod unpack-vis ((this drawable-group) (arg0 (pointer int8)) (arg1 (pointer int8)))
|
|
(dotimes (s4-0 (-> this length))
|
|
(set! arg1 (unpack-vis (-> this data s4-0) arg0 arg1)))
|
|
arg1)
|