jak-project/goal_src/jak2/engine/ui/gui-h.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

149 lines
3.6 KiB
Common Lisp

;;-*-Lisp-*-
(in-package goal)
;; name: gui-h.gc
;; name in dgo: gui-h
;; dgos: ENGINE, GAME
(defenum gui-action
:type uint8
:bitfield #f
(none 0)
(queue 1)
(play 2)
(playing 3)
(stop 4)
(stopping 5)
(abort 6)
(hide 7)
(hidden 8)
(fade 9)
)
(defenum gui-channel
:type uint8
:bitfield #f
(none 0)
(art-load 16)
(art-load-next 17)
(background 18)
(jak 19)
(daxter 20)
(sig 21)
(ashelin 22)
(mog 23)
(jinx 24)
(grim 25)
(kid 26)
(kor 27)
(hal 28)
(voicebox 29)
(guard 30)
(crocadog 31)
(alert 32)
(citizen 33)
(bbush 34)
(krew 35)
(voice 47)
(movie 64)
(blackout 65)
(query 66)
(message 67)
(notice 68)
(subtitle 69)
(supertitle 70)
(notice-low 71)
(subtitle-pc 78) ;; custom
(screen 79)
(hud-upper-right 80)
(hud-upper-left 81)
(hud-lower-right 82)
(hud-lower-left 83)
(hud-lower-left-1 84)
(hud-lower-left-2 85)
(hud-center-right 86)
(hud-center-left 87)
(hud-middle-right 88)
(hud-middle-left 89)
(hud-upper-center 90)
(hud-upper-center-2 91)
(hud 95)
(max 96)
)
(defenum gui-connection-flags
:type uint8
:bitfield #t
(gcf0 0)
(gcf1 1)
(fo-curve 2)
(fo-min 3)
(fo-max 4)
)
(defenum gui-status
:type uint8 ;; not sure
:bitfield #f
(unknown 0)
(pending 1)
(ready 2)
(active 3)
(hide 4)
(stop 5)
)
(declare-type gui-control basic)
(define-extern *gui-control* gui-control)
;; DECOMP BEGINS
(deftype gui-connection (connection)
((priority float :overlay-at param0)
(action gui-action :overlay-at param1)
(channel gui-channel :offset 21)
(anim-part uint8 :offset 22)
(flags gui-connection-flags :offset 23)
(name string :overlay-at param2)
(id sound-id :overlay-at param3)
(handle handle :overlay-at next0)
(time-stamp time-frame :overlay-at next1)
(hold-time time-frame)
(fo-min int16)
(fo-max int16)
(fo-curve int8)
(fade uint8)
(pad uint8 2)
)
)
(deftype gui-control (basic)
((engine engine)
(update-time time-frame)
(connections gui-connection 32 :inline)
(spool-connections gui-connection 4 :inline)
(ids sound-id 96)
(times time-frame 96)
(cmd pair 96)
)
(:methods
(new (symbol type int) _type_)
(add-process (_type_ process gui-channel gui-action string float time-frame) sound-id)
(remove-process (_type_ process gui-channel) none)
(stop-str (_type_ gui-connection) int)
(gui-control-method-12 (_type_ process gui-channel gui-action string int float sound-id) sound-id)
(update (_type_ symbol) int)
(lookup-gui-connection-id (_type_ string gui-channel gui-action) sound-id)
(lookup-gui-connection (_type_ process gui-channel string sound-id) gui-connection)
(set-action! (_type_ gui-action sound-id gui-channel gui-action string (function gui-connection symbol) process) int)
(get-status (_type_ sound-id) gui-status)
(gui-control-method-18 (_type_ gui-channel) symbol)
(handle-command-list (_type_ gui-channel gui-connection) symbol)
(set-falloff! (_type_ sound-id symbol int int int) gui-connection)
(gui-control-method-21 (_type_ gui-connection vector) int)
(gui-control-method-22 (_type_ gui-connection process symbol) none)
(handle-command (_type_ gui-channel gui-channel symbol gui-connection) symbol)
(channel-id-set! (_type_ gui-connection sound-id) int)
)
)