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: 
241 lines
10 KiB
Common Lisp
241 lines
10 KiB
Common Lisp
;;-*-Lisp-*-
|
|
(in-package goal)
|
|
(bundles "ENGINE.CGO" "GAME.CGO")
|
|
(require "engine/anim/aligner-h.gc")
|
|
(require "engine/anim/joint-mod-h.gc")
|
|
(require "engine/common-obs/generic-obs-h.gc")
|
|
(require "engine/geometry/vol-h.gc")
|
|
(require "engine/camera/camera-h.gc")
|
|
(require "engine/geometry/path-h.gc")
|
|
(require "engine/gfx/sprite/sparticle/sparticle.gc")
|
|
(require "engine/nav/navigate-h.gc")
|
|
(require "engine/data/art-h.gc")
|
|
(require "engine/common-obs/water-h.gc")
|
|
|
|
;; note: the while loop in this is changed to include a cast to basic.
|
|
|
|
;; DECOMP BEGINS
|
|
|
|
(defmethod relocate ((this process) (arg0 int))
|
|
(let ((v1-0 *kernel-context*))
|
|
(set! (-> v1-0 relocating-process) this)
|
|
(set! (-> v1-0 relocating-min) (the-as int (&-> this type)))
|
|
(set! (-> v1-0 relocating-max) (the-as int (+ (+ (-> this allocated-length) -4 (-> process size)) (the-as int this))))
|
|
(set! (-> v1-0 relocating-offset) arg0))
|
|
(&+! (-> this ppointer 0) arg0)
|
|
(let ((v1-5 (-> this entity))) (if (and v1-5 (= (-> v1-5 extra process) this)) (&+! (-> v1-5 extra process) arg0)))
|
|
(let ((v1-7 (-> this connection-list next1)))
|
|
(while (the-as connection v1-7)
|
|
(let ((a0-14 (-> v1-7 prev1)))
|
|
(if (and (>= (the-as int a0-14) (-> *kernel-context* relocating-min))
|
|
(< (the-as int a0-14) (-> *kernel-context* relocating-max)))
|
|
(&+! (-> v1-7 prev1) arg0)))
|
|
(let ((a0-19 (-> (the-as connection v1-7) param1)))
|
|
(if (and (>= a0-19 (-> *kernel-context* relocating-min)) (< a0-19 (-> *kernel-context* relocating-max)))
|
|
(+! (-> (the-as connection v1-7) param1) arg0)))
|
|
(let ((a0-24 (-> (the-as connection v1-7) param2)))
|
|
(if (and (>= a0-24 (-> *kernel-context* relocating-min)) (< a0-24 (-> *kernel-context* relocating-max)))
|
|
(+! (-> (the-as connection v1-7) param2) arg0)))
|
|
(let ((a0-29 (-> (the-as connection v1-7) param3)))
|
|
(if (and (>= a0-29 (-> *kernel-context* relocating-min)) (< a0-29 (-> *kernel-context* relocating-max)))
|
|
(+! (-> (the-as connection v1-7) param3) arg0)))
|
|
(set! v1-7 (-> (the-as connection v1-7) next1))))
|
|
(let ((v1-10 (-> this self)))
|
|
(if (and (>= (the-as int v1-10) (-> *kernel-context* relocating-min))
|
|
(< (the-as int v1-10) (-> *kernel-context* relocating-max)))
|
|
(&+! (-> this self) arg0)))
|
|
(let ((v1-15 (-> this ppointer)))
|
|
(if (and (>= (the-as int v1-15) (-> *kernel-context* relocating-min))
|
|
(< (the-as int v1-15) (-> *kernel-context* relocating-max)))
|
|
(&+! (-> this ppointer) arg0)))
|
|
;; og:preserve-this
|
|
(let ((s4-0 (the basic (&+ (-> this heap-base) 4))))
|
|
(while (< (the-as int s4-0) (the-as int (-> this heap-cur)))
|
|
(relocate s4-0 arg0)
|
|
(&+! s4-0 (logand -16 (+ (asize-of s4-0) 15)))))
|
|
(&+! (-> this main-thread) arg0)
|
|
(&+! (-> this top-thread) arg0)
|
|
(&+! (-> this heap-base) arg0)
|
|
(&+! (-> this heap-cur) arg0)
|
|
(&+! (-> this heap-top) arg0)
|
|
(let ((a2-4 (asize-of this))
|
|
(a1-22 (&-> this type)))
|
|
(cond
|
|
((>= arg0 0) (qmem-copy->! (&+ a1-22 arg0) a1-22 a2-4))
|
|
((< a2-4 2560) (qmem-copy<-! (&+ a1-22 arg0) a1-22 a2-4))
|
|
(else (ultimate-memcpy (&+ a1-22 arg0) a1-22 (the-as uint a2-4)))))
|
|
(set! (-> *kernel-context* relocating-process) #f)
|
|
(&+ this arg0))
|
|
|
|
(defmethod relocate ((this cpu-thread) (arg0 int))
|
|
(&+! (-> this process) arg0)
|
|
this)
|
|
|
|
(defmethod relocate ((this process-drawable) (arg0 int))
|
|
(let ((v1-0 *kernel-context*))
|
|
(set! (-> v1-0 relocating-process) this)
|
|
(set! (-> v1-0 relocating-min) (the-as int (&-> this type)))
|
|
(set! (-> v1-0 relocating-max) (the-as int (+ (+ (-> this allocated-length) -4 (-> process size)) (the-as int this))))
|
|
(set! (-> v1-0 relocating-offset) arg0))
|
|
(if (nonzero? (-> this root)) (&+! (-> this root) arg0))
|
|
(if (nonzero? (-> this node-list)) (&+! (-> this node-list) arg0))
|
|
(if (nonzero? (-> this draw)) (&+! (-> this draw) arg0))
|
|
(if (nonzero? (-> this skel)) (&+! (-> this skel) arg0))
|
|
(if (nonzero? (-> this nav)) (&+! (-> this nav) arg0))
|
|
(if (nonzero? (-> this align)) (&+! (-> this align) arg0))
|
|
(if (nonzero? (-> this path)) (&+! (-> this path) arg0))
|
|
(if (nonzero? (-> this vol)) (&+! (-> this vol) arg0))
|
|
(if (nonzero? (-> this fact)) (&+! (-> this fact) arg0))
|
|
(if (nonzero? (-> this link)) (&+! (-> this link) arg0))
|
|
(if (nonzero? (-> this part)) (&+! (-> this part) arg0))
|
|
(if (nonzero? (-> this water)) (&+! (-> this water) arg0))
|
|
(if (nonzero? (-> this sound)) (&+! (-> this sound) arg0))
|
|
(the-as process-drawable ((method-of-type process relocate) this arg0)))
|
|
|
|
(defmethod relocate ((this collide-shape) (arg0 int))
|
|
(&+! (-> this process) arg0)
|
|
(&+! (-> this root-prim) arg0)
|
|
(if (-> this riders) (&+! (-> this riders) arg0))
|
|
this)
|
|
|
|
(defmethod relocate ((this collide-shape-moving) (arg0 int))
|
|
(if (-> this dynam) (&+! (-> this dynam) arg0))
|
|
(the-as collide-shape-moving ((method-of-type collide-shape relocate) this arg0)))
|
|
|
|
(defmethod relocate ((this collide-sticky-rider-group) (arg0 int))
|
|
(countdown (v1-0 (-> this num-riders))
|
|
(let ((a2-2 (-> this rider v1-0))) (if (-> a2-2 sticky-prim) (&+! (-> a2-2 sticky-prim) arg0))))
|
|
this)
|
|
|
|
(defmethod relocate ((this collide-shape-prim) (arg0 int))
|
|
(&+! (-> this cshape) arg0)
|
|
this)
|
|
|
|
(defmethod relocate ((this collide-shape-prim-group) (arg0 int))
|
|
(&+! (-> this cshape) arg0)
|
|
(countdown (v1-2 (-> this num-prims))
|
|
(&+! (-> this prims v1-2) arg0))
|
|
this)
|
|
|
|
(defmethod relocate ((this fact-info) (arg0 int))
|
|
(&+! (-> this process) arg0)
|
|
this)
|
|
|
|
(defmethod relocate ((this draw-control) (arg0 int))
|
|
(&+! (-> this skeleton) arg0)
|
|
(&+! (-> this process) arg0)
|
|
(when (-> this ripple)
|
|
(if (-> this ripple query) (&+! (-> this ripple query) arg0))
|
|
(&+! (-> this ripple) arg0))
|
|
(let ((v1-14 (-> this shadow-ctrl)))
|
|
(if (and (>= (the-as int v1-14) (-> *kernel-context* relocating-min))
|
|
(< (the-as int v1-14) (-> *kernel-context* relocating-max)))
|
|
(&+! (-> this shadow-ctrl) arg0)))
|
|
this)
|
|
|
|
(defmethod relocate ((this joint-control) (arg0 int))
|
|
(if (-> this effect) (&+! (-> this effect) arg0))
|
|
(set! (-> this root-channel) (the-as (inline-array joint-control-channel) (&+ (-> this root-channel) arg0)))
|
|
(countdown (v1-6 (-> this allocated-length))
|
|
(&+! (-> this channel v1-6 parent) arg0))
|
|
this)
|
|
|
|
(defmethod relocate ((this cspace-array) (arg0 int))
|
|
(countdown (v1-0 (-> this length))
|
|
(let ((a2-2 (-> this data v1-0)))
|
|
(if (-> a2-2 parent) (&+! (-> a2-2 parent) arg0))
|
|
(&+! (-> a2-2 bone) arg0)
|
|
(let ((a3-6 (-> a2-2 param1)))
|
|
(if (and (>= (the-as int a3-6) (-> *kernel-context* relocating-min))
|
|
(< (the-as int a3-6) (-> *kernel-context* relocating-max)))
|
|
(&+! (-> a2-2 param1) arg0)))
|
|
(let ((a3-11 (-> a2-2 param2)))
|
|
(if (and (>= (the-as int a3-11) (-> *kernel-context* relocating-min))
|
|
(< (the-as int a3-11) (-> *kernel-context* relocating-max)))
|
|
(&+! (-> a2-2 param2) arg0)))))
|
|
this)
|
|
|
|
(defmethod relocate ((this nav-control) (arg0 int))
|
|
(&+! (-> this process) arg0)
|
|
(&+! (-> this shape) arg0)
|
|
this)
|
|
|
|
(defmethod relocate ((this path-control) (arg0 int))
|
|
(&+! (-> this process) arg0)
|
|
this)
|
|
|
|
(defmethod relocate ((this vol-control) (arg0 int))
|
|
(&+! (-> this process) arg0)
|
|
this)
|
|
|
|
(defmethod relocate ((this water-control) (arg0 int))
|
|
(&+! (-> this process) arg0)
|
|
this)
|
|
|
|
(defmethod relocate ((this actor-link-info) (arg0 int))
|
|
(&+! (-> this process) arg0)
|
|
this)
|
|
|
|
(defmethod relocate ((this align-control) (arg0 int))
|
|
(&+! (-> this process) arg0)
|
|
this)
|
|
|
|
(defmethod relocate ((this joint-mod) (arg0 int))
|
|
(&+! (-> this process) arg0)
|
|
(&+! (-> this joint) arg0)
|
|
this)
|
|
|
|
(defmethod relocate ((this joint-mod-wheel) (arg0 int))
|
|
(&+! (-> this process) arg0)
|
|
this)
|
|
|
|
(defmethod relocate ((this effect-control) (arg0 int))
|
|
(&+! (-> this process) arg0)
|
|
this)
|
|
|
|
(defmethod relocate ((this sparticle-launch-control) (arg0 int))
|
|
(&+! (-> this proc) arg0)
|
|
(countdown (v1-2 (-> this length))
|
|
(let* ((a0-3 (-> this data v1-2))
|
|
(a2-0 (-> a0-3 origin)))
|
|
(if (and (>= (the-as int a2-0) (-> *kernel-context* relocating-min))
|
|
(< (the-as int a2-0) (-> *kernel-context* relocating-max)))
|
|
(&+! (-> a0-3 origin) arg0))))
|
|
(forall-particles-with-key this
|
|
(lambda ((arg0 sparticle-system) (arg1 sparticle-cpuinfo))
|
|
(let ((v1-1 (-> *kernel-context* relocating-offset)))
|
|
(set! (-> arg1 key) (the-as sparticle-launch-control (+ (the-as int (-> arg1 key)) v1-1)))
|
|
(if (-> arg1 binding) (set! (-> arg1 binding) (the-as sparticle-launch-state (+ (the-as int (-> arg1 binding)) v1-1)))))
|
|
0
|
|
(none))
|
|
#t
|
|
#t)
|
|
this)
|
|
|
|
(defmethod relocate ((this camera-master) (arg0 int))
|
|
(if (nonzero? (-> this water-drip)) (&+! (-> this water-drip) arg0))
|
|
(the-as camera-master ((method-of-type process relocate) this arg0)))
|
|
|
|
(defmethod relocate ((this time-of-day-proc) (arg0 int))
|
|
(if (nonzero? (-> this stars)) (&+! (-> this stars) arg0))
|
|
(if (nonzero? (-> this sun)) (&+! (-> this sun) arg0))
|
|
(if (nonzero? (-> this green-sun)) (&+! (-> this green-sun) arg0))
|
|
(if (nonzero? (-> this moon)) (&+! (-> this moon) arg0))
|
|
(the-as time-of-day-proc ((method-of-type process relocate) this arg0)))
|
|
|
|
(defmethod relocate ((this swingpole) (arg0 int))
|
|
(if (nonzero? (-> this root)) (&+! (-> this root) arg0))
|
|
(the-as swingpole ((method-of-type process relocate) this arg0)))
|
|
|
|
(defmethod relocate ((this part-tracker) (arg0 int))
|
|
(if (nonzero? (-> this root)) (&+! (-> this root) arg0))
|
|
(if (nonzero? (-> this part)) (&+! (-> this part) arg0))
|
|
(the-as part-tracker ((method-of-type process relocate) this arg0)))
|
|
|
|
(defmethod relocate ((this manipy) (arg0 int))
|
|
(if (nonzero? (-> this joint 0)) (&+! (-> this joint 0) arg0))
|
|
(if (nonzero? (-> this joint 1)) (&+! (-> this joint 1) arg0))
|
|
(if (nonzero? (-> this joint 2)) (&+! (-> this joint 2) arg0))
|
|
(if (nonzero? (-> this joint 3)) (&+! (-> this joint 3) arg0))
|
|
(the-as manipy ((method-of-type process-drawable relocate) this arg0)))
|