jak-project/goal_src/jak2/engine/gfx/sky/sky-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

223 lines
6.5 KiB
Common Lisp

;;-*-Lisp-*-
(in-package goal)
;; name: sky-h.gc
;; name in dgo: sky-h
;; dgos: ENGINE, GAME
(define-extern close-sky-buffer (function dma-buffer none))
;; DECOMP BEGINS
(deftype sky-color-hour (structure)
((snapshot1 int32)
(snapshot2 int32)
(morph-start float)
(morph-end float)
)
)
(deftype sky-color-day (structure)
((hour sky-color-hour 24 :inline)
)
)
(deftype sky-sun-data (structure)
((data uint128 4)
(pos vector :inline :overlay-at (-> data 0))
(r-sun float :overlay-at (-> data 1))
(r-halo float :offset 20)
(r-aurora float :offset 24)
(c-sun-start rgba :overlay-at (-> data 2))
(c-sun-end rgba :overlay-at (-> data 3))
(c-halo-start rgba :offset 36)
(c-halo-end rgba :offset 52)
(c-aurora-start rgba :offset 40)
(c-aurora-end rgba :offset 56)
)
)
(deftype sky-moon-data (structure)
((data uint128 2)
(pos vector :inline :overlay-at (-> data 0))
(scale vector :inline :overlay-at (-> data 1))
)
)
(deftype sky-orbit (structure)
((high-noon float)
(tilt float)
(rise float)
(dist float)
(min-halo float)
(max-halo float)
)
:allow-misaligned
)
(deftype sky-upload-data (structure)
((data uint128 10)
(sun sky-sun-data 2 :inline :overlay-at (-> data 0))
(moon sky-moon-data :inline :overlay-at (-> data 8))
)
)
(deftype sky-vertex (structure)
((pos vector :inline)
(stq vector :inline)
(col vector :inline)
)
)
(deftype cloud-vertex (structure)
((pos vector :inline)
(stq vector :inline)
(col vector :inline)
(nrm vector :inline)
(stq2 vector :inline)
(col2 vector :inline)
(nrm2 vector :inline)
)
)
(deftype cloud-vert-array (structure)
((data cloud-vertex 100 :inline)
)
)
(deftype haze-vertex (structure)
((pos vector :inline)
(nrm vector :inline)
(col vector :inline)
)
)
(deftype haze-vert-array (structure)
((data haze-vertex 36 :inline)
)
)
(deftype cloud-lights (structure)
((sun0-normal vector :inline)
(sun1-normal vector :inline)
(moon-normal vector :inline)
(ambi-color vector :inline)
(ambi-color-lower vector :inline)
(sun0-color vector :inline)
(sun1-color vector :inline)
(moon-color vector :inline)
(sun0-color-lower vector :inline)
(sun0-scale float)
(sun1-scale float)
(moon-scale float)
)
)
(deftype haze-lights (structure)
((sun0-normal vector :inline)
(sun1-normal vector :inline)
(moon-normal vector :inline)
(ambi-color vector :inline)
(sun0-color vector :inline)
(sun1-color vector :inline)
(moon-color vector :inline)
(sun0-scale float)
(sun1-scale float)
(moon-scale float)
)
)
(deftype sky-work (structure)
((adgif-tmpl dma-gif-packet :inline)
(draw-tmpl dma-gif-packet :inline)
(draw-tmpl2 dma-gif-packet :inline)
(fog-tmpl dma-gif-packet :inline)
(blend-tmpl dma-gif-packet :inline)
(sprite-tmpl dma-gif-packet :inline)
(sprite-tmpl2 dma-gif-packet :inline)
(sun-coords vector 2 :inline)
(green-coords vector 2 :inline)
(moon0-coords vector 2 :inline)
(moon1-coords vector 2 :inline)
(moon2-coords vector 2 :inline)
(star-coords vector 2 :inline)
(sun-colors vector4w 2 :inline)
(green-colors vector4w 2 :inline)
(moon-colors vector4w 3 :inline)
(star-colors vector4w 16 :inline)
(st-coords vector 2 :inline)
(random vector4w 8 :inline)
(giftag-base dma-gif :inline)
(giftag-haze dma-gif :inline)
(giftag-roof dma-gif :inline)
(giftag-ocean dma-gif :inline)
(fog vector :inline)
(sky float 8)
(time float)
(off-s uint16)
(off-t uint16)
(orbit sky-orbit 3 :inline)
(upload-data sky-upload-data :inline)
(ambi-color vector4w :inline)
(ambi-color-lower vector4w :inline)
(sun0-color vector4w :inline)
(sun1-color vector4w :inline)
(moon-color vector4w :inline)
(sun0-color-lower vector4w :inline)
(cam-mat matrix :inline)
(star-mat matrix :inline)
(vec0 vector4w :inline)
(vec1 vector4w :inline)
(cloud-lights cloud-lights :inline)
(haze-lights haze-lights :inline)
(buf dma-buffer)
(draw-vortex basic)
(stars vector 512 :inline)
)
(:methods
(init-sun-data! (_type_ int float float float) none)
(init-orbit-settings! (_type_ int float float float float float float) none)
(update-colors-for-time (_type_ float) none)
(update-time-and-speed (_type_ float float) none)
(draw (_type_) none)
(update-matrix (_type_ matrix) none)
(update-template-colors (_type_) none)
(init-regs-for-large-polygon-draw (_type_) none)
(init-regs-for-sky-asm (_type_) none)
(cloud-vtx-light-update (_type_ vector vector cloud-lights vector vector) none)
(cloud-vtx-tex-update (_type_ vector vector vector cloud-lights) none)
(adjust-cloud-lighting (_type_) none)
(cloud-vtx1-to-sky (_type_ sky-vertex cloud-vertex) none)
(cloud-vtx2-to-sky (_type_ sky-vertex cloud-vertex) none)
(draw-clouds (_type_ dma-buffer) none)
(apply-haze-light (_type_ vector vector haze-lights) none)
(adjust-haze-lighting (_type_) none)
(haze-vtx-to-sky (_type_ sky-vertex sky-vertex haze-vertex) none)
(draw-haze (_type_ dma-buffer) none)
(sun-dma (_type_ dma-buffer) none)
(green-sun-dma (_type_ dma-buffer) none)
(moon-dma (_type_ dma-buffer) none)
(setup-stars (_type_ matrix sky-upload-data) none)
(stars-transform-asm (_type_) none)
(stars-dma (_type_ dma-buffer) none)
(draw-roof (_type_ dma-buffer) none)
(draw-base (_type_ dma-buffer) none)
(draw-fog (_type_ dma-buffer) none)
)
)
(define-extern *sky-work* sky-work)