Files
jak-project/goal_src/jak1/levels/demo/static-screen.gc
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

158 lines
4.4 KiB
Common Lisp

;;-*-Lisp-*-
(in-package goal)
;; name: static-screen.gc
;; name in dgo: static-screen
;; dgos: DEM, L1, TIT
;; DECOMP BEGINS
(deftype static-screen (process)
((part sparticle-launch-control 1)
(state-time time-frame)
)
(:state-methods
(idle int time-frame symbol)
)
)
(defmethod relocate ((this static-screen) (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)
)
(dotimes (v1-2 1)
(if (nonzero? (-> this part v1-2))
(&+! (-> this part v1-2) arg0)
)
)
(the-as static-screen ((method-of-type process relocate) this arg0))
)
(defmethod deactivate ((this static-screen))
(dotimes (s5-0 1)
(if (nonzero? (-> this part s5-0))
(kill-and-free-particles (-> this part s5-0))
)
)
((method-of-type process deactivate) this)
(none)
)
(defpart 2966
:init-specs ((:texture (new 'static 'texture-id :page #x5c6))
(:num 1.0)
(:y (meters 1.18))
(:scale-x (meters 15))
(:scale-y (meters 6.5))
(:r 128.0)
(:g 128.0)
(:b 128.0)
(:a 128.0)
(:timer (seconds -0.005))
(:flags (bit2 bit9 bit13))
)
)
(defpart 2967
:init-specs ((:texture (new 'static 'texture-id :index #x1 :page #x5c6))
(:num 1.0)
(:y (meters -1.264))
(:scale-x (meters 15))
(:scale-y (meters 3.25))
(:r 128.0)
(:g 128.0)
(:b 128.0)
(:a 128.0)
(:timer (seconds -0.005))
(:flags (bit2 bit9 bit13))
)
)
(defpart 2968
:init-specs ((:texture (new 'static 'texture-id :index #x2 :page #x5c6))
(:num 1.0)
(:y (meters -2.482))
(:scale-x (meters 15))
(:scale-y (meters 1.625))
(:r 128.0)
(:g 128.0)
(:b 128.0)
(:a 128.0)
(:timer (seconds -0.005))
(:flags (bit2 bit9 bit13))
)
)
(defpartgroup group-part-screen1
:id 707
:flags (screen-space)
:bounds (static-bspherem 0 0 0 1)
:parts ((sp-item 2966 :flags (launch-asap)) (sp-item 2967 :flags (launch-asap)) (sp-item 2968 :flags (launch-asap)))
)
(defstate idle (static-screen)
:virtual #t
:enter (behavior ((arg0 int) (arg1 time-frame) (arg2 symbol))
(set! (-> *setting-control* current bg-a) 1.0)
(set! (-> *setting-control* default bg-a) 0.0)
(add-setting! 'common-page 'set 0.0 (ash 1 (+ arg0 1)))
)
:trans (behavior ()
(hide-hud-quick)
(spawn (-> self part 0) *zero-vector*)
0
)
:code (behavior ((arg0 int) (arg1 time-frame) (arg2 symbol))
(local-vars (v1-6 symbol))
(set-time! (-> self state-time))
(until v1-6
(suspend)
(set! v1-6 (or (and (> arg1 0) (time-elapsed? (-> self state-time) arg1))
(and arg2
(time-elapsed? (-> self state-time) (seconds 1))
(cpad-pressed? 0 select start triangle circle x square)
)
)
)
)
(set! (-> *setting-control* default bg-a) 1.0)
(while (!= (-> *setting-control* current bg-a) (-> *setting-control* default bg-a))
(suspend)
)
(remove-setting! 'common-page)
(suspend)
0
)
)
(defbehavior static-screen-init-by-other static-screen ((arg0 int) (arg1 texture-id) (arg2 texture-id) (arg3 texture-id) (arg4 time-frame) (arg5 symbol))
(let ((s3-0 (lookup-part-group-by-name "group-part-screen1")))
(when (and s3-0 (nonzero? s3-0) (type-type? (-> s3-0 type) sparticle-launch-group))
(set! (-> *part-id-table* 2966 init-specs 0 initial-valuef) (the-as float arg1))
(set! (-> *part-id-table* 2967 init-specs 0 initial-valuef) (the-as float arg2))
(set! (-> *part-id-table* 2968 init-specs 0 initial-valuef) (the-as float arg3))
(set! (-> self part 0) (create-launch-control (the-as sparticle-launch-group s3-0) self))
(go-virtual idle arg0 arg4 arg5)
)
)
0
(none)
)
(defun static-screen-spawn ((arg0 int)
(arg1 texture-id)
(arg2 texture-id)
(arg3 texture-id)
(arg4 time-frame)
(arg5 symbol)
(arg6 process-tree)
)
(process-spawn static-screen arg0 arg1 arg2 arg3 arg4 arg5 :to arg6)
)