mirror of
https://github.com/open-goal/jak-project
synced 2026-08-15 12:59:39 -04:00
deftype and defmethod syntax major changes (#3094)
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>
This commit is contained in:
+19
-19
@@ -2,7 +2,7 @@
|
||||
(in-package goal)
|
||||
|
||||
;; definition for method 17 of type bigmap
|
||||
(defmethod set-pos! bigmap ((this bigmap) (arg0 vector))
|
||||
(defmethod set-pos! ((this bigmap) (arg0 vector))
|
||||
(rlet ((vf0 :class vf)
|
||||
(vf1 :class vf)
|
||||
(vf2 :class vf)
|
||||
@@ -21,7 +21,7 @@
|
||||
|
||||
;; definition for method 18 of type bigmap
|
||||
;; INFO: Used lq/sq
|
||||
(defmethod decompress-current-masks! bigmap ((this bigmap))
|
||||
(defmethod decompress-current-masks! ((this bigmap))
|
||||
(let ((compressed-mask-data (-> this compressed-masks (-> this mask-index))))
|
||||
(set! (-> this compressed-masks (-> this mask-index)) (the-as (pointer int8) #f))
|
||||
(cond
|
||||
@@ -62,7 +62,7 @@
|
||||
)
|
||||
|
||||
;; definition for method 19 of type bigmap
|
||||
(defmethod compress-current-masks! bigmap ((this bigmap))
|
||||
(defmethod compress-current-masks! ((this bigmap))
|
||||
(let* ((compressed-data-dest (+ (-> this compressed-next-index) 0 (-> this compressed-data)))
|
||||
(compressed-data-size
|
||||
(pack-comp-rle
|
||||
@@ -143,7 +143,7 @@
|
||||
)
|
||||
|
||||
;; definition for method 20 of type bigmap
|
||||
(defmethod set-enable-from-position! bigmap ((this bigmap))
|
||||
(defmethod set-enable-from-position! ((this bigmap))
|
||||
(let ((v1-4 (-> this layer-mask data (+ (* (-> this pos y) 128) (/ (-> this pos x) 2)))))
|
||||
(if (not (logtest? (-> this pos x) 1))
|
||||
(set! (-> this layer-mask-enable) (shr v1-4 4))
|
||||
@@ -154,7 +154,7 @@
|
||||
)
|
||||
|
||||
;; definition for method 21 of type bigmap
|
||||
(defmethod maybe-fill-for-position bigmap ((this bigmap) (arg0 int) (arg1 int))
|
||||
(defmethod maybe-fill-for-position ((this bigmap) (arg0 int) (arg1 int))
|
||||
(local-vars (v1-3 uint))
|
||||
(let* ((v1-1 (+ (* arg1 128) (/ arg0 2)))
|
||||
(a3-3 (-> this layer-mask data v1-1))
|
||||
@@ -198,7 +198,7 @@
|
||||
|
||||
;; definition for method 23 of type bigmap
|
||||
;; WARN: Return type mismatch int vs none.
|
||||
(defmethod mask-image-from-bit-mask bigmap ((this bigmap))
|
||||
(defmethod mask-image-from-bit-mask ((this bigmap))
|
||||
(let* ((v1-0 (the-as object (-> this bit-mask)))
|
||||
(a1-0 *image-mask-table*)
|
||||
(a0-2 (the-as object (-> this bigmap-image art-group)))
|
||||
@@ -233,7 +233,7 @@
|
||||
|
||||
;; definition for method 22 of type bigmap
|
||||
;; WARN: Return type mismatch int vs none.
|
||||
(defmethod texture-upload-dma bigmap ((this bigmap) (arg0 dma-buffer) (arg1 (pointer uint32)) (arg2 int) (arg3 int) (arg4 int) (arg5 gs-psm))
|
||||
(defmethod texture-upload-dma ((this bigmap) (arg0 dma-buffer) (arg1 (pointer uint32)) (arg2 int) (arg3 int) (arg4 int) (arg5 gs-psm))
|
||||
(local-vars (sv-16 int))
|
||||
(set! sv-16 arg2)
|
||||
(dma-buffer-add-gs-set arg0
|
||||
@@ -250,7 +250,7 @@
|
||||
;; definition for method 26 of type bigmap
|
||||
;; INFO: Used lq/sq
|
||||
;; WARN: Return type mismatch pointer vs none.
|
||||
(defmethod sprite-dma bigmap ((this bigmap) (arg0 dma-buffer) (arg1 int) (arg2 int) (arg3 int) (arg4 int))
|
||||
(defmethod sprite-dma ((this bigmap) (arg0 dma-buffer) (arg1 int) (arg2 int) (arg3 int) (arg4 int))
|
||||
(let ((v1-0 (-> arg0 base)))
|
||||
(set! (-> (the-as (pointer uint128) v1-0) 0) (-> this sprite-tmpl dma-vif quad))
|
||||
(set! (-> (the-as (pointer uint128) v1-0) 1) (-> this sprite-tmpl quad 1))
|
||||
@@ -265,7 +265,7 @@
|
||||
)
|
||||
|
||||
;; definition for method 24 of type bigmap
|
||||
(defmethod draw-non-city-map bigmap ((this bigmap) (arg0 dma-buffer))
|
||||
(defmethod draw-non-city-map ((this bigmap) (arg0 dma-buffer))
|
||||
(let ((s4-0 (the-as (pointer uint32) (-> this bigmap-image art-group))))
|
||||
(let ((v1-1 (-> s4-0 0))
|
||||
(s3-0 (-> s4-0 1))
|
||||
@@ -307,7 +307,7 @@
|
||||
)
|
||||
|
||||
;; definition for method 25 of type bigmap
|
||||
(defmethod draw-city-map bigmap ((this bigmap) (arg0 dma-buffer))
|
||||
(defmethod draw-city-map ((this bigmap) (arg0 dma-buffer))
|
||||
(let ((s4-0 (the-as (pointer uint32) (-> this bigmap-image art-group))))
|
||||
(texture-upload-dma this arg0 (+ (+ (-> s4-0 0) 16) (the-as uint s4-0)) 0 16 16 (gs-psm ct32))
|
||||
(dma-buffer-add-gs-set arg0 (texflush 0))
|
||||
@@ -331,7 +331,7 @@
|
||||
|
||||
;; definition for method 27 of type bigmap
|
||||
;; INFO: Used lq/sq
|
||||
(defmethod draw-from-minimap bigmap ((this bigmap) (arg0 dma-buffer) (arg1 connection-minimap))
|
||||
(defmethod draw-from-minimap ((this bigmap) (arg0 dma-buffer) (arg1 connection-minimap))
|
||||
(rlet ((vf0 :class vf)
|
||||
(vf1 :class vf)
|
||||
(vf2 :class vf)
|
||||
@@ -446,7 +446,7 @@
|
||||
|
||||
;; definition for method 9 of type bigmap
|
||||
;; WARN: Return type mismatch int vs none.
|
||||
(defmethod initialize bigmap ((this bigmap))
|
||||
(defmethod initialize ((this bigmap))
|
||||
(set! (-> this bigmap-index) (the-as uint 20))
|
||||
(set-pending-file (-> this bigmap-image) (the-as string #f) 0 (process->handle *dproc*) 0.0)
|
||||
(set! (-> this compressed-next-index) (the-as uint 0))
|
||||
@@ -464,7 +464,7 @@
|
||||
;; definition for method 10 of type bigmap
|
||||
;; INFO: Used lq/sq
|
||||
;; WARN: Return type mismatch int vs none.
|
||||
(defmethod update bigmap ((this bigmap))
|
||||
(defmethod update ((this bigmap))
|
||||
(let ((v1-1 (level-get-target-inside *level*)))
|
||||
(if v1-1
|
||||
(set! (-> this bigmap-index) (the-as uint (-> v1-1 info bigmap-id)))
|
||||
@@ -585,7 +585,7 @@
|
||||
|
||||
;; definition for method 11 of type bigmap
|
||||
;; INFO: Used lq/sq
|
||||
(defmethod draw bigmap ((this bigmap) (arg0 int) (arg1 int) (arg2 int) (arg3 int))
|
||||
(defmethod draw ((this bigmap) (arg0 int) (arg1 int) (arg2 int) (arg3 int))
|
||||
(local-vars (sv-96 pointer) (sv-100 texture) (sv-104 matrix) (sv-112 int))
|
||||
(when (and (= (file-status (-> this bigmap-image) "world-map" (the-as int (-> this load-index))) 'active)
|
||||
(not (-> this loading-flag))
|
||||
@@ -747,7 +747,7 @@
|
||||
|
||||
;; definition for method 12 of type bigmap
|
||||
;; INFO: Used lq/sq
|
||||
(defmethod handle-cpad-inputs bigmap ((this bigmap))
|
||||
(defmethod handle-cpad-inputs ((this bigmap))
|
||||
(cond
|
||||
((= (-> this bigmap-index) 20)
|
||||
(let* ((v1-2 (-> *cpad-list* cpads 0))
|
||||
@@ -765,7 +765,7 @@
|
||||
)
|
||||
|
||||
;; definition for method 13 of type bigmap
|
||||
(defmethod compress-all bigmap ((this bigmap))
|
||||
(defmethod compress-all ((this bigmap))
|
||||
(when (!= (-> this mask-index) 20)
|
||||
(compress-current-masks! this)
|
||||
(set! (-> this mask-index) (the-as uint 20))
|
||||
@@ -776,7 +776,7 @@
|
||||
;; definition for method 14 of type bigmap
|
||||
;; INFO: Used lq/sq
|
||||
;; WARN: Return type mismatch symbol vs none.
|
||||
(defmethod enable-drawing bigmap ((this bigmap))
|
||||
(defmethod enable-drawing ((this bigmap))
|
||||
(set! (-> this bigmap-index) (the-as uint (-> (level-get-target-inside *level*) info bigmap-id)))
|
||||
(cond
|
||||
((= (-> this bigmap-index) 20)
|
||||
@@ -818,7 +818,7 @@
|
||||
)
|
||||
|
||||
;; definition for method 15 of type bigmap
|
||||
(defmethod disable-drawing bigmap ((this bigmap))
|
||||
(defmethod disable-drawing ((this bigmap))
|
||||
(set-pending-file
|
||||
(-> this bigmap-image)
|
||||
(the-as string #f)
|
||||
@@ -848,7 +848,7 @@
|
||||
(define *map-save-ptr* (the-as (pointer uint64) #f))
|
||||
|
||||
;; definition for method 16 of type bigmap
|
||||
(defmethod dump-to-file bigmap ((this bigmap))
|
||||
(defmethod dump-to-file ((this bigmap))
|
||||
(if (not *map-save-ptr*)
|
||||
(set! *map-save-ptr* (the-as (pointer uint64) (malloc 'debug #xd0000)))
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user