mirror of
https://github.com/open-goal/jak-project
synced 2026-07-29 07:33:59 -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>
117 lines
3.4 KiB
Common Lisp
117 lines
3.4 KiB
Common Lisp
;;-*-Lisp-*-
|
|
(in-package goal)
|
|
|
|
;; name: idle-control.gc
|
|
;; name in dgo: idle-control
|
|
;; dgos: GAME, COMMON
|
|
|
|
(defenum ic-cmd
|
|
:type uint8
|
|
(restart 0)
|
|
(play 1)
|
|
(push 2)
|
|
)
|
|
|
|
;; DECOMP BEGINS
|
|
|
|
(deftype idle-control-frame (uint32)
|
|
((command ic-cmd :offset 0 :size 8)
|
|
(anim uint8 :offset 8 :size 8)
|
|
(param0 uint8 :offset 16 :size 8)
|
|
(param1 uint8 :offset 24 :size 8)
|
|
)
|
|
)
|
|
|
|
|
|
(deftype idle-control (structure)
|
|
((anim (pointer idle-control-frame))
|
|
(current (pointer idle-control-frame))
|
|
(counter int32)
|
|
(target int32)
|
|
)
|
|
(:methods
|
|
(idle-control-method-9 (_type_ (pointer idle-control-frame)) none)
|
|
(idle-control-method-10 (_type_ process-drawable) none :behavior process-drawable)
|
|
)
|
|
)
|
|
|
|
|
|
;; WARN: Return type mismatch idle-control vs none.
|
|
(defmethod idle-control-method-9 ((this idle-control) (arg0 (pointer idle-control-frame)))
|
|
(set! (-> this anim) arg0)
|
|
(set! (-> this current) arg0)
|
|
(set! (-> this counter) 0)
|
|
(set! (-> this target) 0)
|
|
(none)
|
|
)
|
|
|
|
;; TODO - method manually patched (maybe incorrectly) around `self` changing
|
|
;; WARN: Function (method 10 idle-control) has a return type of none, but the expression builder found a return statement.
|
|
(defmethod idle-control-method-10 ((this idle-control) (arg0 process-drawable))
|
|
(local-vars (a1-1 int) (backup-pp process))
|
|
(when (nonzero? (-> this anim))
|
|
(with-pp
|
|
(set! backup-pp pp)
|
|
(set! pp arg0)
|
|
(loop
|
|
(let ((s4-0 (-> this current 0)))
|
|
(case (-> s4-0 command)
|
|
(((ic-cmd play))
|
|
(if (< (-> s4-0 anim) 0)
|
|
(return #f)
|
|
)
|
|
(when (zero? (-> this target))
|
|
(let ((t9-0 rand-vu-int-range)
|
|
(a0-3 (-> s4-0 param0))
|
|
)
|
|
(shift-arith-right-32 a1-1 s4-0 24)
|
|
(set! (-> this target) (t9-0 (the-as int a0-3) a1-1))
|
|
)
|
|
(ja :group! (-> (the-as process-drawable self) draw art-group data (-> s4-0 anim)) :num! min)
|
|
(return #f)
|
|
)
|
|
(ja :group! (-> (the-as process-drawable self) draw art-group data (-> s4-0 anim)) :num! (seek!))
|
|
(cond
|
|
((ja-done? 0)
|
|
(+! (-> this counter) 1)
|
|
(cond
|
|
((>= (-> this counter) (-> this target))
|
|
(set! (-> this current) (&-> (-> this current) 1))
|
|
(set! (-> this counter) 0)
|
|
(set! (-> this target) 0)
|
|
0
|
|
)
|
|
(else
|
|
(ja :num-func num-func-identity :frame-num 0.0)
|
|
(return #f)
|
|
)
|
|
)
|
|
)
|
|
(else
|
|
(return #f)
|
|
)
|
|
)
|
|
)
|
|
(((ic-cmd push))
|
|
(ja-channel-push! 1 (the-as time-frame (-> s4-0 param0)))
|
|
(set! (-> this current) (&-> (-> this current) 1))
|
|
(set! (-> this counter) 0)
|
|
(set! (-> this target) 0)
|
|
0
|
|
)
|
|
(((ic-cmd restart))
|
|
(set! (-> this current) (-> this anim))
|
|
(set! (-> this counter) 0)
|
|
(set! (-> this target) 0)
|
|
0
|
|
)
|
|
)
|
|
)
|
|
)
|
|
(set! pp backup-pp)
|
|
)
|
|
)
|
|
0
|
|
(none)
|
|
)
|