mirror of
https://github.com/open-goal/jak-project
synced 2026-06-20 08:13:33 -04:00
cd68cb671e
Major change to how `deftype` shows up in our code: - the decompiler will no longer emit the `offset-assert`, `method-count-assert`, `size-assert` and `flag-assert` parameters. There are extremely few cases where having this in the decompiled code is helpful, as the types there come from `all-types` which already has those parameters. This also doesn't break type consistency because: - the asserts aren't compared. - the first step of the test uses `all-types`, which has the asserts, which will throw an error if they're bad. - the decompiler won't emit the `heap-base` parameter unless necessary now. - the decompiler will try its hardest to turn a fixed-offset field into an `overlay-at` field. It falls back to the old offset if all else fails. - `overlay-at` now supports field "dereferencing" to specify the offset that's within a field that's a structure, e.g.: ```lisp (deftype foobar (structure) ((vec vector :inline) (flags int32 :overlay-at (-> vec w)) ) ) ``` in this structure, the offset of `flags` will be 12 because that is the final offset of `vec`'s `w` field within this structure. - **removed ID from all method declarations.** IDs are only ever automatically assigned now. Fixes #3068. - added an `:overlay` parameter to method declarations, in order to declare a new method that goes on top of a previously-defined method. Syntax is `:overlay <method-name>`. Please do not ever use this. - added `state-methods` list parameter. This lets you quickly specify a list of states to be put in the method table. Same syntax as the `states` list parameter. The decompiler will try to put as many states in this as it can without messing with the method ID order. Also changes `defmethod` to make the first type definition (before the arguments) optional. The type can now be inferred from the first argument. Fixes #3093. --------- Co-authored-by: Hat Kid <6624576+Hat-Kid@users.noreply.github.com>
407 lines
11 KiB
Common Lisp
407 lines
11 KiB
Common Lisp
;;-*-Lisp-*-
|
|
(in-package goal)
|
|
|
|
;; name: relocate.gc
|
|
;; name in dgo: relocate
|
|
;; dgos: ENGINE, GAME
|
|
|
|
;; 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 (>= (the-as int a0-19) (-> *kernel-context* relocating-min))
|
|
(< (the-as int 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)
|
|
)
|
|
)
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
;; Don't remove this cast
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
(let ((s4-0 (the-as 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
|
|
)
|
|
|
|
;; WARN: Return type mismatch process vs process-drawable.
|
|
(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)
|
|
)
|
|
(let ((a0-6 (-> this nav)))
|
|
(if (and (nonzero? a0-6) a0-6)
|
|
(relocate a0-6 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 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)
|
|
)
|
|
(if (nonzero? (-> this carry))
|
|
(&+! (-> this carry) arg0)
|
|
)
|
|
(if (nonzero? (-> this rbody))
|
|
(&+! (-> this rbody) 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)
|
|
this
|
|
)
|
|
|
|
;; WARN: Return type mismatch collide-shape vs collide-shape-moving.
|
|
(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-shape-prim) (arg0 int))
|
|
(&+! (-> this cshape) arg0)
|
|
this
|
|
)
|
|
|
|
(defmethod relocate ((this collide-shape-prim-group) (arg0 int))
|
|
(&+! (-> this cshape) arg0)
|
|
(set! (-> this child) (the-as (inline-array collide-shape-prim) (&+ (the-as pointer (-> this child)) 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)
|
|
)
|
|
(if (-> this top-anim)
|
|
(&+! (-> this top-anim) arg0)
|
|
)
|
|
(&+! (-> this root-channel) arg0)
|
|
(countdown (v1-10 (-> this allocated-length))
|
|
(&+! (-> this channel v1-10 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 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 joint-mod-ik) (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-4 (-> this data v1-2))
|
|
(a2-0 (-> a0-4 center))
|
|
)
|
|
(if (and (>= (the-as int a2-0) (-> *kernel-context* relocating-min))
|
|
(< (the-as int a2-0) (-> *kernel-context* relocating-max))
|
|
)
|
|
(&+! (-> a0-4 center) 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
|
|
)
|
|
|
|
;; WARN: Return type mismatch process vs camera-master.
|
|
(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))
|
|
)
|
|
|
|
;; WARN: Return type mismatch process vs time-of-day-proc.
|
|
(defmethod relocate ((this time-of-day-proc) (arg0 int))
|
|
(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))
|
|
)
|
|
|
|
;; WARN: Return type mismatch process vs part-tracker.
|
|
(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))
|
|
)
|
|
|
|
;; WARN: Return type mismatch process vs part-spawner.
|
|
(defmethod relocate ((this part-spawner) (arg0 int))
|
|
(if (nonzero? (-> this root))
|
|
(&+! (-> this root) arg0)
|
|
)
|
|
(if (nonzero? (-> this part))
|
|
(&+! (-> this part) arg0)
|
|
)
|
|
(if (nonzero? (-> this sound))
|
|
(&+! (-> this sound) arg0)
|
|
)
|
|
(the-as part-spawner ((method-of-type process relocate) this arg0))
|
|
)
|
|
|
|
;; WARN: Return type mismatch process vs lightning-tracker.
|
|
(defmethod relocate ((this lightning-tracker) (arg0 int))
|
|
(if (nonzero? (-> this root))
|
|
(&+! (-> this root) arg0)
|
|
)
|
|
(if (nonzero? (-> this lightning))
|
|
(&+! (-> this lightning) arg0)
|
|
)
|
|
(the-as lightning-tracker ((method-of-type process relocate) this arg0))
|
|
)
|
|
|
|
;; WARN: Return type mismatch process-drawable vs manipy.
|
|
(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))
|
|
)
|