mirror of
https://github.com/open-goal/jak-project
synced 2026-06-13 22:15:54 -04:00
c245f37feb
* update jak 2 config and hack to make game text dumpable * update stuff * update src * do `cspace<-parented-transformq-joint!` * progress.... kind of... * more drawable stuff * clagng * bones begin * more bones * even more bones * everything builds * touches * errors * ? * fix `quicksandlurker` * updates * update refs * more fixes * update refs
370 lines
12 KiB
Common Lisp
370 lines
12 KiB
Common Lisp
;;-*-Lisp-*-
|
|
(in-package goal)
|
|
|
|
;; name: art-h.gc
|
|
;; name in dgo: art-h
|
|
;; dgos: GAME, ENGINE
|
|
|
|
(deftype joint-anim (basic)
|
|
((name string :offset-assert 4)
|
|
(number int16 :offset-assert 8)
|
|
(length int16 :offset-assert 10)
|
|
)
|
|
:method-count-assert 9
|
|
:size-assert #xc
|
|
:flag-assert #x90000000c
|
|
)
|
|
|
|
(deftype joint-anim-matrix (joint-anim)
|
|
((data matrix :inline :dynamic :offset 16)
|
|
)
|
|
:method-count-assert 9
|
|
:size-assert #x10
|
|
:flag-assert #x900000010
|
|
)
|
|
|
|
(deftype joint-anim-transformq (joint-anim)
|
|
((data transformq :inline :dynamic :offset 16)
|
|
)
|
|
:method-count-assert 9
|
|
:size-assert #x10
|
|
:flag-assert #x900000010
|
|
)
|
|
|
|
(deftype joint-anim-drawable (joint-anim)
|
|
((data drawable :dynamic :offset-assert 12) ;; guess
|
|
)
|
|
:method-count-assert 9
|
|
:size-assert #xc
|
|
:flag-assert #x90000000c
|
|
)
|
|
|
|
(declare-type joint-anim-compressed-hdr structure)
|
|
(deftype joint-anim-compressed (joint-anim)
|
|
((data joint-anim-compressed-hdr :dynamic :offset-assert 12) ;; guess
|
|
)
|
|
:method-count-assert 9
|
|
:size-assert #xc
|
|
:flag-assert #x90000000c
|
|
)
|
|
|
|
(deftype joint-anim-frame (structure)
|
|
((matrices matrix 2 :inline :offset-assert 0)
|
|
(data uint32 :dynamic :offset-assert 128) ;; guess
|
|
)
|
|
:method-count-assert 9
|
|
:size-assert #x80
|
|
:flag-assert #x900000080
|
|
(:methods
|
|
(new (symbol type int) _type_ 0)
|
|
)
|
|
)
|
|
|
|
(defmethod new joint-anim-frame ((allocation symbol) (type-to-make type) (arg0 int))
|
|
(let ((v1-1 (max 0 (+ arg0 -2))))
|
|
(the-as joint-anim-frame
|
|
(new-dynamic-structure
|
|
allocation
|
|
type-to-make
|
|
(the-as int (+ (-> type-to-make size) (the-as uint (* 48 v1-1)))))
|
|
)
|
|
)
|
|
)
|
|
|
|
(deftype joint-anim-compressed-hdr (structure)
|
|
((control-bits uint32 14 :offset-assert 0)
|
|
(unknown-half int16 :offset 6)
|
|
(num-joints uint32 :offset-assert 56)
|
|
(matrix-bits uint32 :offset-assert 60)
|
|
)
|
|
:method-count-assert 9
|
|
:size-assert #x40
|
|
:flag-assert #x900000040
|
|
)
|
|
|
|
(deftype joint-anim-compressed-fixed (structure)
|
|
((hdr joint-anim-compressed-hdr :inline :offset-assert 0)
|
|
(offset-64 uint32 :offset-assert 64)
|
|
(offset-32 uint32 :offset-assert 68)
|
|
(offset-16 uint32 :offset-assert 72)
|
|
(reserved uint32 :offset-assert 76)
|
|
(data vector 133 :inline :offset-assert 80) ;; guess
|
|
)
|
|
:method-count-assert 9
|
|
:size-assert #x8a0
|
|
:flag-assert #x9000008a0
|
|
)
|
|
|
|
(deftype joint-anim-compressed-frame (structure)
|
|
((offset-64 uint32 :offset-assert 0)
|
|
(offset-32 uint32 :offset-assert 4)
|
|
(offset-16 uint32 :offset-assert 8)
|
|
(reserved uint32 :offset-assert 12)
|
|
(data vector 133 :inline :offset-assert 16) ;; guess
|
|
)
|
|
:method-count-assert 9
|
|
:size-assert #x860
|
|
:flag-assert #x900000860
|
|
)
|
|
|
|
(deftype joint-anim-compressed-control (structure)
|
|
((num-frames uint32 :offset-assert 0)
|
|
(fixed-qwc uint32 :offset-assert 4)
|
|
(frame-qwc uint32 :offset-assert 8)
|
|
(fixed joint-anim-compressed-fixed :offset-assert 12)
|
|
(data joint-anim-compressed-frame 1 :offset-assert 16) ;; guess
|
|
)
|
|
:method-count-assert 9
|
|
:size-assert #x14
|
|
:flag-assert #x900000014
|
|
)
|
|
|
|
(deftype art (basic)
|
|
((name string :offset 8)
|
|
(length int32 :offset-assert 12)
|
|
(extra res-lump :offset-assert 16)
|
|
)
|
|
:method-count-assert 13
|
|
:size-assert #x14
|
|
:flag-assert #xd00000014
|
|
(:methods
|
|
(login (_type_) _type_ 9)
|
|
(dummy-10 (_type_ string type) joint 10)
|
|
(dummy-11 (_type_ string type) int 11)
|
|
(needs-link? (_type_) symbol 12)
|
|
)
|
|
)
|
|
|
|
(deftype art-element (art)
|
|
((pad uint8 12))
|
|
:method-count-assert 13
|
|
:size-assert #x20
|
|
:flag-assert #xd00000020
|
|
)
|
|
|
|
(deftype art-mesh-anim (art-element)
|
|
((data basic :dynamic :offset-assert 32))
|
|
:method-count-assert 13
|
|
:size-assert #x20
|
|
:flag-assert #xd00000020
|
|
)
|
|
|
|
(deftype art-joint-anim (art-element)
|
|
;; figured out manually from custom inspect.
|
|
((_unknown (pointer int16) :offset 4) ;; no clue. used in mem-usage
|
|
(speed float :offset 20)
|
|
(artist-base float :offset 24)
|
|
(artist-step float :offset 28)
|
|
(master-art-group-name string :offset 32)
|
|
(master-art-group-index int32 :offset 36)
|
|
(blerc-data (pointer uint8) :offset 40) ;; todo, this is probably something else
|
|
(frames joint-anim-compressed-control :offset 44)
|
|
(data joint-anim-compressed :dynamic)
|
|
)
|
|
:method-count-assert 13
|
|
:size-assert #x30
|
|
:flag-assert #xd00000030
|
|
)
|
|
|
|
(deftype art-group (art)
|
|
((info file-info :offset 4)
|
|
(data art-element :dynamic :offset 32)
|
|
)
|
|
:method-count-assert 15
|
|
:size-assert #x20
|
|
:flag-assert #xf00000020
|
|
(:methods
|
|
(relocate (_type_ kheap (pointer uint8)) none :replace 7)
|
|
(link-art! (_type_) art-group 13)
|
|
(unlink-art! (_type_) int 14)
|
|
)
|
|
)
|
|
|
|
(deftype art-mesh-geo (art-element)
|
|
((data basic :dynamic :offset-assert 32)
|
|
)
|
|
:method-count-assert 13
|
|
:size-assert #x20
|
|
:flag-assert #xd00000020
|
|
)
|
|
|
|
(deftype art-joint-geo (art-element)
|
|
((data joint :dynamic :offset-assert 32)
|
|
)
|
|
:method-count-assert 13
|
|
:size-assert #x20
|
|
:flag-assert #xd00000020
|
|
)
|
|
|
|
(deftype skeleton-group (basic)
|
|
((art-group-name basic :offset-assert 4)
|
|
(jgeo int32 :offset-assert 8)
|
|
(janim int32 :offset-assert 12)
|
|
(bounds vector :inline :offset-assert 16)
|
|
(radius meters :offset 28)
|
|
(mgeo int16 4 :offset-assert 32)
|
|
(max-lod int32 :offset-assert 40)
|
|
(lod-dist float 4 :offset-assert 44)
|
|
(longest-edge meters :offset-assert 60)
|
|
(texture-level int8 :offset-assert 64)
|
|
(version int8 :offset-assert 65)
|
|
(shadow int8 :offset-assert 66)
|
|
(sort int8 :offset-assert 67)
|
|
(_pad uint8 4 :offset-assert 68)
|
|
)
|
|
:method-count-assert 9
|
|
:size-assert #x48
|
|
:flag-assert #x900000048
|
|
)
|
|
|
|
(declare-type merc-ctrl basic)
|
|
(deftype lod-group (structure)
|
|
((geo merc-ctrl :offset-assert 0)
|
|
(dist meters :offset-assert 4)
|
|
)
|
|
:pack-me
|
|
:method-count-assert 9
|
|
:size-assert #x8
|
|
:flag-assert #x900000008
|
|
)
|
|
|
|
(deftype lod-set (structure)
|
|
((lod lod-group 4 :inline :offset-assert 0)
|
|
(max-lod int8 :offset-assert 32)
|
|
)
|
|
:pack-me
|
|
:method-count-assert 10
|
|
:size-assert #x21
|
|
:flag-assert #xa00000021
|
|
(:methods
|
|
(dummy-9 (_type_ skeleton-group art-group entity) _type_ 9)
|
|
)
|
|
)
|
|
|
|
(defenum draw-status
|
|
:type uint8
|
|
:bitfield #t
|
|
(drwf00 0)
|
|
(drwf01 1)
|
|
(drwf02 2)
|
|
(drwf03 3)
|
|
(drwf04 4)
|
|
(drwf05 5)
|
|
(drwf06 6)
|
|
(drwf07 7)
|
|
)
|
|
|
|
(defenum draw-effect
|
|
:type uint8
|
|
(drweff0 0)
|
|
(drweff1 1)
|
|
(drweff2 2)
|
|
(title 3)
|
|
(drweff4 4)
|
|
(drweff5 5)
|
|
(drweff6 6)
|
|
(drweff7 7)
|
|
)
|
|
|
|
(declare-type ripple-control basic)
|
|
(declare-type shadow-geo basic)
|
|
(declare-type shadow-control basic)
|
|
(deftype draw-control (basic)
|
|
((status draw-status :offset-assert 4)
|
|
(matrix-type uint8 :offset-assert 5)
|
|
(data-format uint8 :offset-assert 6)
|
|
(global-effect draw-effect :offset-assert 7)
|
|
(art-group art-group :offset-assert 8)
|
|
(jgeo art-joint-geo :offset-assert 12)
|
|
(mgeo merc-ctrl :offset-assert 16)
|
|
(dma-add-func (function process-drawable draw-control symbol object none) :offset-assert 20)
|
|
(skeleton skeleton :offset-assert 24) ;; or cspace-array or shadow-control
|
|
(lod-set lod-set :inline :offset-assert 28)
|
|
(lod lod-group 4 :inline :offset 28)
|
|
(max-lod int8 :offset 60)
|
|
(force-lod int8 :offset-assert 61)
|
|
(cur-lod int8 :offset-assert 62)
|
|
(desired-lod int8 :offset-assert 63)
|
|
(ripple ripple-control :offset-assert 64)
|
|
(longest-edge meters :offset-assert 68)
|
|
(longest-edge? uint32 :offset 68)
|
|
(light-index uint8 :offset-assert 72)
|
|
(dummy uint8 2 :offset-assert 73)
|
|
(death-draw-overlap uint8 :offset-assert 75)
|
|
(death-timer uint8 :offset-assert 76)
|
|
(death-timer-org uint8 :offset-assert 77)
|
|
(death-vertex-skip uint16 :offset-assert 78)
|
|
(death-effect uint32 :offset-assert 80)
|
|
(sink-group dma-foreground-sink-group :offset-assert 84) ;; dma-foreground-sink-group?
|
|
(process process :offset-assert 88)
|
|
(shadow shadow-geo :offset-assert 92)
|
|
(shadow-ctrl shadow-control :offset-assert 96)
|
|
(origin vector :inline :offset-assert 112)
|
|
(bounds vector :inline :offset-assert 128)
|
|
(radius meters :offset 140)
|
|
(color-mult rgbaf :inline :offset-assert 144)
|
|
(color-emissive rgbaf :inline :offset-assert 160)
|
|
(secondary-interp float :offset-assert 176)
|
|
(current-secondary-interp float :offset-assert 180)
|
|
(shadow-mask uint8 :offset-assert 184)
|
|
(level-index uint8 :offset-assert 185)
|
|
(origin-joint-index uint8 :offset-assert 186)
|
|
(shadow-joint-index uint8 :offset-assert 187)
|
|
)
|
|
:method-count-assert 12
|
|
:size-assert #xbc
|
|
:flag-assert #xc000000bc
|
|
(:methods
|
|
(new (symbol type process art-joint-geo) _type_ 0)
|
|
(dummy-9 (_type_) vector 9)
|
|
(lod-set! (_type_ int) none 10)
|
|
(lods-assign! (_type_ lod-set) none 11)
|
|
)
|
|
)
|
|
|
|
(defmethod dummy-9 draw-control ((obj draw-control))
|
|
(-> obj skeleton bones 0 position)
|
|
)
|
|
|
|
|
|
(defmacro defskelgroup (name art-name joint-geom joint-anim lods
|
|
&key (shadow 0)
|
|
&key bounds
|
|
&key longest-edge
|
|
&key (texture-level 0)
|
|
&key (sort 0)
|
|
&key (version 6) ;; do NOT use this!
|
|
)
|
|
|
|
"define a new static skeleton group"
|
|
|
|
`(let ((skel (new 'static 'skeleton-group
|
|
:art-group-name ,(symbol->string art-name)
|
|
:bounds ,bounds
|
|
:longest-edge ,longest-edge
|
|
:version ,version
|
|
:max-lod ,(- (length lods) 1)
|
|
:shadow ,shadow
|
|
:texture-level ,texture-level
|
|
:sort ,sort
|
|
)))
|
|
;; set joint geometry and joint bones
|
|
(set! (-> skel jgeo) ,joint-geom)
|
|
(set! (-> skel janim) ,joint-anim)
|
|
|
|
;; set lods
|
|
,@(apply-i (lambda (x i)
|
|
`(begin
|
|
(set! (-> skel mgeo ,i) ,(car x))
|
|
(set! (-> skel lod-dist ,i) ,(cadr x))
|
|
)
|
|
) lods)
|
|
|
|
;; define skel group
|
|
(define ,name skel)
|
|
)
|
|
)
|
|
|
|
|
|
|