Files
ManDude cd68cb671e 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>
2023-10-30 03:20:02 +00:00

192 lines
6.9 KiB
Common Lisp
Vendored
Generated

;;-*-Lisp-*-
(in-package goal)
;; definition for method 9 of type align-control
;; INFO: Used lq/sq
;; ERROR: Unsupported inline assembly instruction kind - [lw ra, return-from-thread(s7)]
;; ERROR: Unsupported inline assembly instruction kind - [jr ra]
(defmethod compute-alignment! ((this align-control))
(local-vars (a0-9 symbol) (s7-0 none) (ra-0 int))
(with-pp
(let ((s5-0 (-> this process skel active-channels)))
(dotimes (s4-0 s5-0)
(let* ((a0-3 (-> this process skel channel s4-0))
(v1-5 (-> a0-3 frame-group))
(a0-4 (-> a0-3 command))
(a1-0 'stack)
(a2-0 (= a0-4 a1-0))
)
(cond
((or a2-0 (begin (set! a1-0 'stack1) (= a0-4 a1-0)))
)
(else
(when (!= (-> v1-5 type) art-joint-anim)
(let ((t9-0 (the-as (function object object object object) enter-state))
(a0-7 "align joint-anim")
)
(set! (-> pp next-state) process-drawable-art-error)
(t9-0 a0-7 (the-as none a1-0) a2-0)
)
(.lw ra-0 return-from-thread s7-0)
(.jr ra-0)
(nop!)
0
)
)
)
)
)
)
(let* ((a0-8 (-> this process skel root-channel 0))
(v1-16 (-> a0-8 frame-group))
(f0-0 (-> a0-8 frame-num))
)
(= (-> a0-8 num-func) num-func-loop!)
(cond
((or (not v1-16) (!= (-> this frame-group) v1-16))
(set! a0-9 #t)
)
((= (-> a0-8 num-func) num-func-loop!)
(set! a0-9 (< (* (-> a0-8 param 0) (- f0-0 (-> this frame-num))) 0.0))
)
(else
(set! a0-9 (= f0-0 0.0))
)
)
(if a0-9
(logior! (-> this flags) (align-flags disabled))
(logclear! (-> this flags) (align-flags disabled))
)
(set! (-> this frame-group) v1-16)
(set! (-> this frame-num) f0-0)
)
(mem-copy! (the-as pointer (-> this transform 1)) (the-as pointer (-> this transform)) 48)
(quaternion-copy! (the-as quaternion (-> this transform 1 rot)) (-> this align quat))
(set! (-> this transform 1 scale quad) (-> this align scale quad))
(let* ((a2-5 (-> this matrix 1 vector))
(a3-0 (-> this matrix))
(v1-19 (-> a3-0 0 vector 0 quad))
(a0-18 (-> a3-0 0 vector 1 quad))
(a1-12 (-> a3-0 0 vector 2 quad))
(a3-1 (-> a3-0 0 vector 3 quad))
)
(set! (-> a2-5 0 quad) v1-19)
(set! (-> a2-5 1 quad) a0-18)
(set! (-> a2-5 2 quad) a1-12)
(set! (-> a2-5 3 quad) a3-1)
)
(let ((s5-1 (-> this process node-list data 1)))
(cspace<-matrix-no-push-joint! s5-1 (-> this process skel))
(let* ((v1-23 (-> this matrix))
(a3-2 (-> s5-1 bone transform))
(a0-21 (-> a3-2 vector 0 quad))
(a1-14 (-> a3-2 vector 1 quad))
(a2-6 (-> a3-2 vector 2 quad))
(a3-3 (-> a3-2 vector 3 quad))
)
(set! (-> v1-23 0 vector 0 quad) a0-21)
(set! (-> v1-23 0 vector 1 quad) a1-14)
(set! (-> v1-23 0 vector 2 quad) a2-6)
(set! (-> v1-23 0 vector 3 quad) a3-3)
)
(vector*! (the-as vector (-> this transform)) (-> s5-1 bone transform vector 3) (-> this process root scale))
)
(vector-!
(the-as vector (-> this delta))
(the-as vector (-> this transform))
(the-as vector (-> this transform 1))
)
(set-vector!
(-> this align scale)
(vector-length (the-as vector (-> this matrix)))
(vector-length (-> this matrix 0 vector 1))
(vector-length (-> this matrix 0 vector 2))
1.0
)
(vector-! (-> this delta scale) (-> this align scale) (-> this transform 1 scale))
(let ((a2-8 (matrix-inv-scale! (new 'stack-no-clear 'matrix) (-> this align scale))))
(quaternion-normalize!
(matrix->quaternion (-> this align quat) (matrix*! a2-8 (the-as matrix (-> this matrix)) a2-8))
)
)
(let ((a1-24 (quaternion-inverse! (new 'stack-no-clear 'quaternion) (the-as quaternion (-> this transform 1 rot))))
)
(quaternion-normalize! (quaternion*! (-> this delta quat) a1-24 (-> this align quat)))
)
(-> this delta)
)
)
;; definition for method 12 of type align-control
;; INFO: Return type mismatch (inline-array transform) vs transform.
(defmethod first-transform ((this align-control))
(the-as transform (-> this transform))
)
;; definition for method 13 of type align-control
(defmethod snd-transform ((this align-control))
(-> this transform 1)
)
;; definition for method 10 of type align-control
(defmethod align! ((this align-control) (arg0 align-opts) (arg1 float) (arg2 float) (arg3 float))
(when (not (logtest? (-> this flags) (align-flags disabled)))
(let* ((a0-1 (-> this process))
(t9-0 (method-of-object a0-1 apply-alignment))
(v1-4 (-> this delta))
(t1-0 (new 'stack-no-clear 'vector))
)
(set! (-> t1-0 x) arg1)
(set! (-> t1-0 y) arg2)
(set! (-> t1-0 z) arg3)
(set! (-> t1-0 w) 1.0)
(t9-0 a0-1 arg0 v1-4 t1-0)
)
)
(-> this process root)
)
;; definition for method 26 of type trsqv
(defmethod set-and-limit-velocity ((this trsqv) (arg0 int) (arg1 vector) (arg2 float))
(let ((gp-0 (-> this transv)))
(when (logtest? arg0 4)
(set! (-> gp-0 x) (-> arg1 x))
(set! (-> gp-0 z) (-> arg1 z))
(let ((f0-4 (fmin (* (vector-xz-length arg1) (-> *display* frames-per-second)) arg2)))
(vector-xz-normalize! gp-0 f0-4)
)
)
)
this
)
;; definition for method 11 of type align-control
(defmethod align-vel-and-quat-only! ((this align-control) (arg0 align-opts) (arg1 vector) (arg2 int) (arg3 float) (arg4 float))
(when (not (logtest? (-> this flags) (align-flags disabled)))
(let ((s5-0 (-> this delta)))
(let ((s3-0 (-> this process root transv)))
(if (logtest? arg0 (align-opts adjust-y-vel))
(set! (-> s3-0 y) (* (-> s5-0 trans y) arg3 (-> *display* frames-per-second)))
)
(when (logtest? arg0 (align-opts adjust-xz-vel))
(set! (-> s3-0 x) (-> arg1 x))
(set! (-> s3-0 z) (-> arg1 z))
(let ((f0-8 (* (fmin (vector-xz-length arg1) (* (vector-xz-length (-> s5-0 trans)) arg4))
(-> *display* frames-per-second)
)
)
(t9-2 vector-xz-normalize!)
)
(set! (-> this last-speed) f0-8)
(t9-2 s3-0 f0-8)
)
)
)
(if (logtest? arg0 (align-opts adjust-quat))
(quaternion-normalize! (quaternion*! (-> this process root quat) (-> this process root quat) (-> s5-0 quat)))
)
)
)
(-> this process root)
)