Files
jak-project/test/decompiler/reference/jak1/engine/common-obs/voicebox_REF.gc
T
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

244 lines
7.3 KiB
Common Lisp
Vendored
Generated

;;-*-Lisp-*-
(in-package goal)
;; definition of type camera-voicebox
(deftype camera-voicebox (camera-slave)
()
(:states
cam-voicebox
)
)
;; definition for method 3 of type camera-voicebox
(defmethod inspect ((this camera-voicebox))
(let ((t9-0 (method-of-type camera-slave inspect)))
(t9-0 this)
)
this
)
;; definition of type voicebox
(deftype voicebox (process-drawable)
((parent-override (pointer camera-voicebox) :overlay-at parent)
(base-trans vector :inline)
(seeker cam-float-seeker :inline)
(blend float)
(twist float)
(hint handle)
)
(:state-methods
enter
idle
exit
)
)
;; definition for method 3 of type voicebox
(defmethod inspect ((this voicebox))
(let ((t9-0 (method-of-type process-drawable inspect)))
(t9-0 this)
)
(format #t "~T~Tbase-trans: ~`vector`P~%" (-> this base-trans))
(format #t "~T~Tseeker: #<cam-float-seeker @ #x~X>~%" (-> this seeker))
(format #t "~T~Tblend: ~f~%" (-> this blend))
(format #t "~T~Ttwist: ~f~%" (-> this twist))
(format #t "~T~Thint: ~D~%" (-> this hint))
this
)
;; failed to figure out what this is:
(defstate empty-state (process)
:code nothing
)
;; failed to figure out what this is:
(defskelgroup *voicebox-sg* speaker speaker-lod0-jg speaker-idle-ja
((speaker-lod0-mg (meters 999999)))
:bounds (static-spherem 0 0 0 4)
)
;; definition for function voicebox-track
;; INFO: Used lq/sq
;; INFO: Return type mismatch int vs none.
(defbehavior voicebox-track voicebox ()
(let ((gp-0 (new 'stack-no-clear 'vector))
(s5-0 (new 'stack-no-clear 'vector))
)
(set! (-> gp-0 quad) (-> self parent-override 0 trans quad))
(set! (-> s5-0 quad) (-> (target-pos 68) quad))
(when *target*
(let ((a2-0 (vector-z-quaternion! (new-stack-vector0) (-> *target* control unknown-quaternion00))))
(vector+float*! s5-0 s5-0 a2-0 (* -16384.0 (- 1.0 (-> self blend))))
)
)
(vector-lerp! (-> self root trans) gp-0 s5-0 (-> self blend))
)
(+! (-> self root trans y) (* 1638.4 (sin (* 54.613335 (the float (mod (current-time) 1200))))))
(let ((gp-1 (new 'stack-no-clear 'quaternion)))
(forward-up->quaternion
gp-1
(vector-normalize! (vector-! (new 'stack-no-clear 'vector) (target-pos 37) (-> self root trans)) 1.0)
(new 'static 'vector :y 1.0 :w 1.0)
)
(rotate-toward-orientation! (-> self root) gp-1 65536.0 5461.3335)
)
(when *target*
(let* ((gp-2 (-> *target* control))
(s4-2 (-> self root trans))
(f0-8
(deg-diff (y-angle gp-2) (vector-y-angle (vector-! (new 'stack-no-clear 'vector) s4-2 (-> gp-2 trans))))
)
)
(if (< 0.0 f0-8)
(seek! (-> self twist) -0.4 (* 0.3 (seconds-per-frame)))
(seek! (-> self twist) 0.4 (* 0.3 (seconds-per-frame)))
)
)
(let ((a1-9 (new 'stack-no-clear 'event-message-block)))
(set! (-> a1-9 from) self)
(set! (-> a1-9 num-params) 0)
(set! (-> a1-9 message) 'blocked-side?)
(case (send-event-function (ppointer->process (-> self parent-override)) a1-9)
((1)
(set! (-> self twist) 0.5)
)
((2)
(set! (-> self twist) -0.5)
)
((3)
(set! (-> self twist) 0.0)
)
)
)
(send-event (ppointer->process (-> self parent-override)) 'joystick (-> self twist) -1.0)
)
(set! (-> self root scale x) (lerp-scale 1.0 0.0 (-> self blend) 0.8 1.0))
(set! (-> self root scale y) (-> self root scale x))
(set! (-> self root scale z) (-> self root scale x))
0
(none)
)
;; failed to figure out what this is:
(defstate enter (voicebox)
:virtual #t
:event (behavior ((proc process) (argc int) (message symbol) (block event-message-block))
(case message
(('die)
(go-virtual exit)
)
)
)
:trans (behavior ()
(voicebox-track)
(if (< 0.1 (-> self blend))
(point-toward-point-clear-roll-pitch! (-> self root) (target-pos 0))
)
)
:code (behavior ()
(set-setting! 'sound-flava #f 20.0 (music-flava assistant))
(if (and *target* (logtest? (-> *target* control root-prim prim-core action) (collide-action racer)))
(send-event
(ppointer->process (-> self parent-override))
'set-dist
(new 'static 'vector :z 8192.0 :w 1.0)
(new 'static 'vector :y 20480.0 :z 12288.0 :w 1.0)
)
(send-event
(ppointer->process (-> self parent-override))
'set-dist
(new 'static 'vector :z 16384.0 :w 1.0)
(new 'static 'vector :y 20480.0 :z 40960.0 :w 1.0)
)
)
(init-cam-float-seeker (-> self seeker) 1.0 0.01 0.022222223 0.1)
(set! (-> self seeker target) 0.0)
(while (< 0.0001 (-> self blend))
(update! (-> self seeker) 0.0)
(set! (-> self blend) (-> self seeker value))
(suspend)
)
(set! (-> self blend) 0.0)
(go-virtual idle)
)
:post ja-post
)
;; failed to figure out what this is:
(defstate idle (voicebox)
:virtual #t
:event (-> (method-of-type voicebox enter) event)
:trans voicebox-track
:code (behavior ()
(loop
(suspend)
(ja :num! (loop!))
)
)
:post ja-post
)
;; failed to figure out what this is:
(defstate exit (voicebox)
:virtual #t
:trans voicebox-track
:code (behavior ()
(remove-setting! 'sound-flava)
(set-time! (-> self state-time))
(set! (-> self seeker target) 1.0)
(while (and (< (-> self blend) 0.9999) (not (and (not (handle->process (-> self hint)))
(time-elapsed? (-> self state-time) (seconds 0.05))
(-> *setting-control* current hint)
)
)
)
(update! (-> self seeker) 0.0)
(set! (-> self blend) (-> self seeker value))
(suspend)
)
(set! (-> self blend) 1.0)
(send-event (ppointer->process (-> self parent-override)) 'go empty-state)
(suspend)
0
)
:post ja-post
)
;; definition for function voicebox-init-by-other
;; INFO: Used lq/sq
;; INFO: Return type mismatch object vs none.
(defbehavior voicebox-init-by-other voicebox ((arg0 vector) (arg1 handle))
(set! (-> self root) (new 'process 'trsqv))
(set! (-> self hint) arg1)
(set! (-> self root trans quad) (-> arg0 quad))
(set! (-> self base-trans quad) (-> arg0 quad))
(initialize-skeleton self *voicebox-sg* '())
(set! (-> self blend) 1.0)
(go-virtual enter)
(none)
)
;; failed to figure out what this is:
(defstate cam-voicebox (camera-voicebox)
:event (-> cam-string event)
:enter (-> cam-string enter)
:trans (behavior ()
(if (not (logtest? (-> *camera* master-options) 2))
(deactivate self)
)
)
:code (-> cam-string code)
)
;; definition for function voicebox-spawn
(defun voicebox-spawn ((arg0 process) (arg1 vector))
(with-pp
(let ((s4-0 (process-spawn camera-voicebox :init cam-slave-init cam-voicebox #f :from *camera-dead-pool* :to arg0))
)
(if s4-0
(process-spawn voicebox arg1 (process->handle pp) :to (ppointer->process s4-0))
)
)
)
)