mirror of
https://github.com/open-goal/jak-project.git
synced 2024-10-20 21:27:52 -04:00
a4e629ebf9
- `transformq` - `wind-work` - `progress-static` - `merc-vu1` - `emerc-vu1` - `merc` - `emerc` - `cloth-h` - Most of `cloth`, not added to gsrc yet Art group dumps were incorrect for Jak 3 because the master art group fields were at different offsets.
414 lines
11 KiB
Common Lisp
414 lines
11 KiB
Common Lisp
;;-*-Lisp-*-
|
|
(in-package goal)
|
|
|
|
;; name: merc-h.gc
|
|
;; name in dgo: merc-h
|
|
;; dgos: GAME
|
|
|
|
;; +++effect-bits
|
|
(defenum effect-bits
|
|
:type uint8
|
|
:bitfield #t
|
|
(texscroll 0)
|
|
(no-fade-out 1) ;; translucent.
|
|
(ripple 2)
|
|
(emerc 3) ;; envmap??
|
|
(ignore-tod-for-envmap-tint 4) ;; color thing
|
|
(force-mercneric 5) ;; some mercneric-only effect
|
|
(cross-fade 6) ;; WARP?
|
|
(ignore-alpha 7)
|
|
)
|
|
;; ---effect-bits
|
|
|
|
|
|
;; DECOMP BEGINS
|
|
|
|
(deftype ripple-merc-query (inline-array-class)
|
|
"Information about which merc vertices to apply the 'ripple' effect to."
|
|
((start-vertex int32)
|
|
(vertex-skip int32)
|
|
(vertex-count int32)
|
|
(current-loc int32)
|
|
(data vector :inline :dynamic)
|
|
)
|
|
)
|
|
|
|
|
|
(set! (-> ripple-merc-query heap-base) (the-as uint 16))
|
|
|
|
(deftype merc-byte-header (structure)
|
|
"Header for a single [[merc-fragment]] uploaded to the VU."
|
|
((srcdest-off uint8)
|
|
(rgba-off uint8)
|
|
(lump-off uint8)
|
|
(fp-off uint8)
|
|
(mat1-cnt uint8)
|
|
(mat2-cnt uint8)
|
|
(mat3-cnt uint8)
|
|
(samecopy-cnt uint8)
|
|
(crosscopy-cnt uint8)
|
|
(strip-len uint8)
|
|
(mm-quadword-fp-off uint8)
|
|
(mm-quadword-size uint8)
|
|
(perc-off uint8)
|
|
(mat-slot uint8 10)
|
|
)
|
|
)
|
|
|
|
|
|
(deftype merc-fragment (structure)
|
|
"A single merc fragment that fits into VU memory."
|
|
((header merc-byte-header :inline)
|
|
(rest uint8 1)
|
|
)
|
|
(:methods
|
|
(login-adgifs (_type_) merc-fragment)
|
|
)
|
|
)
|
|
|
|
|
|
(deftype merc-vtx (structure)
|
|
"A packed merc vertex."
|
|
((mat-0 uint8)
|
|
(mat-1 uint8)
|
|
(nrm-x uint8)
|
|
(pos-x uint8)
|
|
(dst-0 uint8)
|
|
(dst-1 uint8)
|
|
(nrm-y uint8)
|
|
(pos-y uint8)
|
|
(tex-s uint8)
|
|
(tex-t uint8)
|
|
(nrm-z uint8)
|
|
(pos-z uint8)
|
|
)
|
|
)
|
|
|
|
|
|
(deftype merc-fp-header (structure)
|
|
"Merc header for a [[merc-fragment]]'s floating point data."
|
|
((x-add float)
|
|
(y-add float)
|
|
(z-add float)
|
|
(shader-cnt uint8)
|
|
(kick-info-offset uint8)
|
|
(kick-info-step uint8)
|
|
(hword-cnt uint8)
|
|
)
|
|
)
|
|
|
|
|
|
;; WARN: Return type mismatch int vs merc-fp-header.
|
|
(defun merc-fragment-fp-data ((frag merc-fragment))
|
|
"Get the floating point data of a [[merc-fragment]]."
|
|
(the-as merc-fp-header (+ (the-as uint frag) (* (-> frag header mm-quadword-fp-off) 16)))
|
|
)
|
|
|
|
(deftype merc-mat-dest (structure)
|
|
"Metadata for a merc matrix upload."
|
|
((matrix-number uint8)
|
|
(matrix-dest uint8)
|
|
)
|
|
:pack-me
|
|
)
|
|
|
|
|
|
(deftype merc-fragment-control (structure)
|
|
"Data about a [[merc-fragment]] needed for merc DMA generation."
|
|
((unsigned-four-count uint8)
|
|
(lump-four-count uint8)
|
|
(fp-qwc uint8)
|
|
(mat-xfer-count uint8)
|
|
(mat-dest-data merc-mat-dest :inline :dynamic)
|
|
)
|
|
)
|
|
|
|
|
|
(deftype merc-blend-data (structure)
|
|
"Packed BLERC data."
|
|
((int8-data int8 :dynamic)
|
|
)
|
|
)
|
|
|
|
|
|
(deftype merc-blend-ctrl (structure)
|
|
"Information about the vertices of a model modified by BLERC."
|
|
((blend-vtx-count uint8)
|
|
(nonzero-index-count uint8)
|
|
(bt-index uint8 :dynamic)
|
|
)
|
|
)
|
|
|
|
|
|
(deftype mei-envmap-tint (structure)
|
|
"Data for the extra 'envmap tint' effect."
|
|
((fade0 float)
|
|
(fade1 float)
|
|
(tint rgba)
|
|
(dummy int32)
|
|
)
|
|
)
|
|
|
|
|
|
(deftype mei-texture-scroll (structure)
|
|
"Data for the extra 'texscroll' effect."
|
|
((max-dist float)
|
|
(st-int-scale uint8)
|
|
(time-factor uint8)
|
|
(scroll-dir uint8)
|
|
(cached-time uint8)
|
|
(time-delta uint8)
|
|
(dummy uint8 7)
|
|
)
|
|
)
|
|
|
|
|
|
(deftype mei-ripple (structure)
|
|
"Data for the extra 'ripple' effect."
|
|
((x-base float)
|
|
(z-base float)
|
|
(grid-size float)
|
|
(angle float)
|
|
)
|
|
)
|
|
|
|
|
|
(deftype merc-extra-info (structure)
|
|
"Info for merc extra effects."
|
|
((envmap-tint-offset uint8)
|
|
(shader-offset uint8)
|
|
(texture-scroll-offset uint8)
|
|
(ripple-offset uint8)
|
|
(dummy uint8 12)
|
|
)
|
|
)
|
|
|
|
|
|
(deftype merc-effect (structure)
|
|
"A collection of [[merc-fragment]]s with data for any extra effects."
|
|
((frag-geo merc-fragment)
|
|
(frag-ctrl merc-fragment-control)
|
|
(blend-data merc-blend-data)
|
|
(blend-ctrl merc-blend-ctrl)
|
|
(merc-effect-version uint8)
|
|
(effect-bits uint8)
|
|
(frag-count uint16)
|
|
(blend-frag-count uint16)
|
|
(tri-count uint16)
|
|
(dvert-count uint16)
|
|
(texture-index uint8)
|
|
(effect-usage uint8)
|
|
(extra-info merc-extra-info)
|
|
)
|
|
(:methods
|
|
(login-adgifs (_type_) none)
|
|
)
|
|
)
|
|
|
|
|
|
(deftype merc-eye-ctrl (structure)
|
|
"Eye info for both eyes of a merc model."
|
|
((eye-slot int8)
|
|
(shader-offset int8)
|
|
(shader-count int8)
|
|
(eye-ctrl-index int8)
|
|
(shader adgif-shader 6 :inline)
|
|
(left-iris-shader adgif-shader :inline :overlay-at (-> shader 0))
|
|
(left-pupil-shader adgif-shader :inline :overlay-at (-> shader 1))
|
|
(left-lid-shader adgif-shader :inline :overlay-at (-> shader 2))
|
|
(right-iris-shader adgif-shader :inline :overlay-at (-> shader 3))
|
|
(right-pupil-shader adgif-shader :inline :overlay-at (-> shader 4))
|
|
(right-lid-shader adgif-shader :inline :overlay-at (-> shader 5))
|
|
)
|
|
)
|
|
|
|
|
|
(deftype merc-eye-anim-frame (structure)
|
|
"A single frame of a merc eye animation."
|
|
((pupil-trans-x int8)
|
|
(pupil-trans-y int8)
|
|
(blink int8)
|
|
(iris-scale int8 :offset 4)
|
|
(pupil-scale int8 :offset 5)
|
|
(lid-scale int8 :offset 6)
|
|
(dword uint64 :overlay-at pupil-trans-x)
|
|
)
|
|
:pack-me
|
|
)
|
|
|
|
|
|
(deftype merc-eye-anim-block (structure)
|
|
"A list of eye animation frames."
|
|
((max-frame int16)
|
|
(data merc-eye-anim-frame :inline :dynamic)
|
|
)
|
|
)
|
|
|
|
|
|
(deftype texture-usage-group (structure)
|
|
((data texture-masks 7 :inline)
|
|
)
|
|
)
|
|
|
|
|
|
(deftype merc-ctrl-header (structure)
|
|
"The header for a [[merc-ctrl]],
|
|
containing metadata about the model used for drawing."
|
|
((xyz-scale float)
|
|
(st-magic uint32)
|
|
(st-out-a uint32)
|
|
(st-out-b uint32)
|
|
(st-vif-add uint32)
|
|
(st-int-off uint16)
|
|
(st-int-scale uint16)
|
|
(effect-count uint32)
|
|
(blend-target-count uint32)
|
|
(fragment-count uint16)
|
|
(tri-count uint16)
|
|
(matrix-count uint8)
|
|
(shader-count uint8)
|
|
(transform-vertex-count uint16)
|
|
(dvert-count uint16)
|
|
(one-mat-count uint16)
|
|
(two-mat-count uint16)
|
|
(two-mat-reuse-count uint16)
|
|
(three-mat-count uint16)
|
|
(three-mat-reuse-count uint16)
|
|
(shader-upload-count uint8)
|
|
(matrix-upload-count uint8)
|
|
(same-copy-count uint16)
|
|
(cross-copy-count uint16)
|
|
(num-verts uint16)
|
|
(longest-edge float)
|
|
(eye-ctrl merc-eye-ctrl)
|
|
(pad uint32 3)
|
|
(masks-padding texture-masks :inline)
|
|
(texture-usage-group texture-usage-group :overlay-at (-> masks-padding data 0 mask data 0))
|
|
(dummy-bytes uint8 :dynamic :overlay-at fragment-count)
|
|
(envmap-tint uint32 :overlay-at fragment-count)
|
|
(query basic :overlay-at matrix-count)
|
|
(needs-clip uint8 :overlay-at dvert-count)
|
|
(use-isometric uint8 :offset 41)
|
|
(use-attached-shader uint8 :overlay-at one-mat-count)
|
|
(display-triangles uint8 :offset 43)
|
|
(death-vertex-skip uint16 :overlay-at two-mat-count)
|
|
(death-start-vertex uint16 :overlay-at two-mat-reuse-count)
|
|
(death-effect uint32 :overlay-at three-mat-count)
|
|
(use-translucent uint8 :overlay-at shader-upload-count)
|
|
(display-this-fragment uint8 :overlay-at matrix-upload-count)
|
|
(use-warp uint8 :overlay-at same-copy-count)
|
|
(ignore-alpha uint8 :offset 55)
|
|
(force-fade uint8 :overlay-at cross-copy-count)
|
|
(disable-fog uint8 :offset 57)
|
|
(disable-envmap uint8 :overlay-at num-verts)
|
|
)
|
|
)
|
|
|
|
|
|
(deftype merc-ctrl (art-element)
|
|
"The merc data for a single model as it's stored in an art group.
|
|
Consists of a header and a list of [[merc-effect]]s."
|
|
((num-joints int32 :overlay-at length)
|
|
(seg-table (array uint64) :overlay-at (-> pad 0))
|
|
(header merc-ctrl-header :inline)
|
|
(effect merc-effect :inline :dynamic)
|
|
)
|
|
)
|
|
|
|
|
|
(deftype merc-vu1-low-mem (structure)
|
|
((tri-strip-gif gs-gif-tag :inline)
|
|
(ad-gif gs-gif-tag :inline)
|
|
(hvdf-offset vector :inline)
|
|
(perspective uint128 4)
|
|
(fog vector :inline)
|
|
)
|
|
)
|
|
|
|
|
|
(deftype emerc-vu1-low-mem (structure)
|
|
((tri-strip-gif gs-gif-tag :inline)
|
|
(ad-gif gs-gif-tag :inline)
|
|
(hvdf-offset vector :inline)
|
|
(perspective vector 4 :inline)
|
|
(fog vector :inline)
|
|
(unperspect vector :inline)
|
|
)
|
|
)
|
|
|
|
|
|
(deftype texture-login-data (structure)
|
|
((default-texture-index int32)
|
|
(current-texture-index int32)
|
|
(texture-usage-group texture-usage-group)
|
|
(merc-ctrl-header merc-ctrl-header)
|
|
(name basic)
|
|
)
|
|
)
|
|
|
|
|
|
(deftype ripple-wave (structure)
|
|
((scale float)
|
|
(offs float)
|
|
(xdiv int16)
|
|
(zdiv int16)
|
|
(speed float)
|
|
(xmul float)
|
|
(zmul float)
|
|
(delta float)
|
|
)
|
|
:pack-me
|
|
)
|
|
|
|
|
|
(deftype ripple-wave-set (basic)
|
|
((count int32)
|
|
(converted basic)
|
|
(normal-scale float)
|
|
(wave ripple-wave 4 :inline)
|
|
(frame-save uint64)
|
|
)
|
|
)
|
|
|
|
|
|
(deftype ripple-control (basic)
|
|
((global-scale float)
|
|
(last-frame-scale float)
|
|
(close-fade-dist float)
|
|
(far-fade-dist float)
|
|
(faded-scale float)
|
|
(individual-normal-scale float)
|
|
(waveform ripple-wave-set)
|
|
(send-query symbol)
|
|
(query ripple-merc-query)
|
|
)
|
|
(:methods
|
|
(new (symbol type) _type_)
|
|
)
|
|
)
|
|
|
|
|
|
(defmethod new ripple-control ((allocation symbol) (type-to-make type))
|
|
(let ((v0-0 (object-new allocation type-to-make (the-as int (-> type-to-make size)))))
|
|
(set! (-> v0-0 global-scale) 0.0)
|
|
(set! (-> v0-0 last-frame-scale) -0.001)
|
|
(set! (-> v0-0 close-fade-dist) 4096000000.0)
|
|
(set! (-> v0-0 far-fade-dist) 8192000000.0)
|
|
(set! (-> v0-0 faded-scale) -0.001)
|
|
(set! (-> v0-0 waveform) #f)
|
|
(set! (-> v0-0 individual-normal-scale) 1.0)
|
|
(set! (-> v0-0 send-query) #f)
|
|
(set! (-> v0-0 query) #f)
|
|
v0-0
|
|
)
|
|
)
|
|
|
|
(deftype death-info (basic)
|
|
((vertex-skip uint16)
|
|
(timer uint8)
|
|
(overlap uint8)
|
|
(effect uint32)
|
|
(sound symbol)
|
|
)
|
|
)
|