;;-*-Lisp-*-
(in-package goal)

;; definition of type joint-anim
(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
  )

;; definition for method 3 of type joint-anim
(defmethod inspect joint-anim ((obj joint-anim))
  (format #t "[~8x] ~A~%" obj (-> obj type))
  (format #t "~Tname: ~A~%" (-> obj name))
  (format #t "~Tnumber: ~D~%" (-> obj number))
  (format #t "~Tlength: ~D~%" (-> obj length))
  obj
  )

;; definition of type joint-anim-matrix
(deftype joint-anim-matrix (joint-anim)
  ((data matrix :inline :dynamic :offset  16)
   )
  :method-count-assert 9
  :size-assert         #x10
  :flag-assert         #x900000010
  )

;; definition of type joint-anim-transformq
(deftype joint-anim-transformq (joint-anim)
  ((data transformq :inline :dynamic :offset  16)
   )
  :method-count-assert 9
  :size-assert         #x10
  :flag-assert         #x900000010
  )

;; definition of type joint-anim-drawable
(deftype joint-anim-drawable (joint-anim)
  ((data drawable :dynamic :offset-assert  12)
   )
  :method-count-assert 9
  :size-assert         #xc
  :flag-assert         #x90000000c
  )

;; definition for method 3 of type joint-anim-drawable
(defmethod inspect joint-anim-drawable ((obj joint-anim-drawable))
  (format #t "[~8x] ~A~%" obj (-> obj type))
  (format #t "~Tname: ~A~%" (-> obj name))
  (format #t "~Tnumber: ~D~%" (-> obj number))
  (format #t "~Tlength: ~D~%" (-> obj length))
  (format #t "~Tdata[0] @ #x~X~%" (-> obj data))
  obj
  )

;; definition of type joint-anim-compressed
(deftype joint-anim-compressed (joint-anim)
  ((data uint32 :dynamic :offset-assert  12)
   )
  :method-count-assert 9
  :size-assert         #xc
  :flag-assert         #x90000000c
  )

;; definition for method 3 of type joint-anim-compressed
(defmethod inspect joint-anim-compressed ((obj joint-anim-compressed))
  (format #t "[~8x] ~A~%" obj (-> obj type))
  (format #t "~Tname: ~A~%" (-> obj name))
  (format #t "~Tnumber: ~D~%" (-> obj number))
  (format #t "~Tlength: ~D~%" (-> obj length))
  obj
  )

;; definition of type joint-anim-frame
(deftype joint-anim-frame (structure)
  ((matrices matrix 2 :inline        :offset-assert   0)
   (data     matrix :inline :dynamic :offset-assert 128)
   )
  :method-count-assert 9
  :size-assert         #x80
  :flag-assert         #x900000080
  (:methods
    (new (symbol type int) _type_ 0)
    )
  )

;; definition for method 3 of type joint-anim-frame
(defmethod inspect joint-anim-frame ((obj joint-anim-frame))
  (format #t "[~8x] ~A~%" obj 'joint-anim-frame)
  (format #t "~Tmatrices[2] @ #x~X~%" (-> obj matrices))
  (format #t "~Tdata[0] @ #x~X~%" (-> obj data))
  obj
  )

;; definition for method 0 of type joint-anim-frame
;; INFO: Return type mismatch structure vs joint-anim-frame.
(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) (* 48 v1-1))))
      )
    )
  )

;; definition of type joint-anim-compressed-hdr
(deftype joint-anim-compressed-hdr (structure)
  ((control-bits uint32 14 :offset-assert   0)
   (num-joints   uint32    :offset-assert  56)
   (matrix-bits  uint32    :offset-assert  60)
   )
  :method-count-assert 9
  :size-assert         #x40
  :flag-assert         #x900000040
  )

;; definition for method 3 of type joint-anim-compressed-hdr
(defmethod inspect joint-anim-compressed-hdr ((obj joint-anim-compressed-hdr))
  (format #t "[~8x] ~A~%" obj 'joint-anim-compressed-hdr)
  (format #t "~Tcontrol-bits[14] @ #x~X~%" (-> obj control-bits))
  (format #t "~Tnum-joints: ~D~%" (-> obj num-joints))
  (format #t "~Tmatrix-bits: ~D~%" (-> obj matrix-bits))
  obj
  )

;; definition of type joint-anim-compressed-fixed
(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)
   )
  :method-count-assert 9
  :size-assert         #x8a0
  :flag-assert         #x9000008a0
  )

;; definition for method 3 of type joint-anim-compressed-fixed
(defmethod inspect joint-anim-compressed-fixed ((obj joint-anim-compressed-fixed))
  (format #t "[~8x] ~A~%" obj 'joint-anim-compressed-fixed)
  (format #t "~Thdr: #<joint-anim-compressed-hdr @ #x~X>~%" (-> obj hdr))
  (format #t "~Toffset-64: ~D~%" (-> obj offset-64))
  (format #t "~Toffset-32: ~D~%" (-> obj offset-32))
  (format #t "~Toffset-16: ~D~%" (-> obj offset-16))
  (format #t "~Treserved: ~D~%" (-> obj reserved))
  (format #t "~Tdata[133] @ #x~X~%" (-> obj data))
  obj
  )

;; definition of type joint-anim-compressed-frame
(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)
   )
  :method-count-assert 9
  :size-assert         #x860
  :flag-assert         #x900000860
  )

;; definition for method 3 of type joint-anim-compressed-frame
(defmethod inspect joint-anim-compressed-frame ((obj joint-anim-compressed-frame))
  (format #t "[~8x] ~A~%" obj 'joint-anim-compressed-frame)
  (format #t "~Toffset-64: ~D~%" (-> obj offset-64))
  (format #t "~Toffset-32: ~D~%" (-> obj offset-32))
  (format #t "~Toffset-16: ~D~%" (-> obj offset-16))
  (format #t "~Treserved: ~D~%" (-> obj reserved))
  (format #t "~Tdata[133] @ #x~X~%" (-> obj data))
  obj
  )

;; definition of type joint-anim-compressed-control
(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)
   )
  :method-count-assert 9
  :size-assert         #x14
  :flag-assert         #x900000014
  )

;; definition for method 3 of type joint-anim-compressed-control
(defmethod inspect joint-anim-compressed-control ((obj joint-anim-compressed-control))
  (format #t "[~8x] ~A~%" obj 'joint-anim-compressed-control)
  (format #t "~Tnum-frames: ~D~%" (-> obj num-frames))
  (format #t "~Tfixed-qwc: ~D~%" (-> obj fixed-qwc))
  (format #t "~Tframe-qwc: ~D~%" (-> obj frame-qwc))
  (format #t "~Tfixed: #<joint-anim-compressed-fixed @ #x~X>~%" (-> obj fixed))
  (format #t "~Tdata[1] @ #x~X~%" (-> obj data))
  obj
  )

;; definition of type art
(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)
    (lookup-art (_type_ string type) joint 10)
    (lookup-idx-of-art (_type_ string type) int 11)
    (needs-link? (_type_) symbol 12)
    )
  )

;; definition for method 3 of type art
(defmethod inspect art ((obj art))
  (format #t "[~8x] ~A~%" obj (-> obj type))
  (format #t "~Tname: ~A~%" (-> obj name))
  (format #t "~Tlength: ~D~%" (-> obj length))
  (format #t "~Textra: ~A~%" (-> obj extra))
  obj
  )

;; definition of type art-element
(deftype art-element (art)
  ((pad uint8 12 :offset-assert  20)
   )
  :method-count-assert 13
  :size-assert         #x20
  :flag-assert         #xd00000020
  )

;; definition for method 3 of type art-element
(defmethod inspect art-element ((obj art-element))
  (format #t "[~8x] ~A~%" obj (-> obj type))
  (format #t "~Tname: ~A~%" (-> obj name))
  (format #t "~Tlength: ~D~%" (-> obj length))
  (format #t "~Textra: ~A~%" (-> obj extra))
  obj
  )

;; definition of type art-mesh-anim
(deftype art-mesh-anim (art-element)
  ((data basic :dynamic :offset-assert  32)
   )
  :method-count-assert 13
  :size-assert         #x20
  :flag-assert         #xd00000020
  )

;; definition of type art-joint-anim
(deftype art-joint-anim (art-element)
  ((eye-anim-data          merc-eye-anim-block                    :offset          4)
   (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)
   (frames                 joint-anim-compressed-control          :offset         44)
   (data                   joint-anim-compressed         :dynamic :offset-assert  48)
   )
  :method-count-assert 13
  :size-assert         #x30
  :flag-assert         #xd00000030
  )

;; definition of type art-group
(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)
    )
  )

;; definition of type art-mesh-geo
(deftype art-mesh-geo (art-element)
  ((data basic :dynamic :offset-assert  32)
   )
  :method-count-assert 13
  :size-assert         #x20
  :flag-assert         #xd00000020
  )

;; definition of type art-joint-geo
(deftype art-joint-geo (art-element)
  ((data joint :dynamic :offset-assert  32)
   )
  :method-count-assert 13
  :size-assert         #x20
  :flag-assert         #xd00000020
  )

;; definition of type skeleton-group
(deftype skeleton-group (basic)
  ((art-group-name string         :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
  )

;; definition for method 3 of type skeleton-group
(defmethod inspect skeleton-group ((obj skeleton-group))
  (format #t "[~8x] ~A~%" obj (-> obj type))
  (format #t "~Tart-group-name: ~A~%" (-> obj art-group-name))
  (format #t "~Tjgeo: ~D~%" (-> obj jgeo))
  (format #t "~Tjanim: ~D~%" (-> obj janim))
  (format #t "~Tbounds: ~`vector`P~%" (-> obj bounds))
  (format #t "~Tradius: (meters ~m)~%" (-> obj bounds w))
  (format #t "~Tmgeo[4] @ #x~X~%" (-> obj mgeo))
  (format #t "~Tmax-lod: ~D~%" (-> obj max-lod))
  (format #t "~Tlod-dist[4] @ #x~X~%" (-> obj lod-dist))
  (format #t "~Tlongest-edge: (meters ~m)~%" (-> obj longest-edge))
  (format #t "~Ttexture-level: ~D~%" (-> obj texture-level))
  (format #t "~Tversion: ~D~%" (-> obj version))
  (format #t "~Tshadow: ~D~%" (-> obj shadow))
  (format #t "~Tsort: ~D~%" (-> obj sort))
  obj
  )

;; definition of type lod-group
(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
  )

;; definition for method 3 of type lod-group
(defmethod inspect lod-group ((obj lod-group))
  (format #t "[~8x] ~A~%" obj 'lod-group)
  (format #t "~Tgeo: ~A~%" (-> obj geo))
  (format #t "~Tdist: (meters ~m)~%" (-> obj dist))
  obj
  )

;; definition of type lod-set
(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
    (setup-lods! (_type_ skeleton-group art-group entity) _type_ 9)
    )
  )

;; definition for method 3 of type lod-set
(defmethod inspect lod-set ((obj lod-set))
  (format #t "[~8x] ~A~%" obj 'lod-set)
  (format #t "~Tlod[4] @ #x~X~%" (-> obj lod))
  (format #t "~Tmax-lod: ~D~%" (-> obj max-lod))
  obj
  )

;; definition of type draw-control
(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)
   (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)
   (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)
    (get-skeleton-origin (_type_) vector 9)
    (lod-set! (_type_ int) none 10)
    (lods-assign! (_type_ lod-set) none 11)
    )
  )

;; definition for method 3 of type draw-control
(defmethod inspect draw-control ((obj draw-control))
  (format #t "[~8x] ~A~%" obj (-> obj type))
  (format #t "~Tstatus: ~D~%" (-> obj status))
  (format #t "~Tmatrix-type: ~D~%" (-> obj matrix-type))
  (format #t "~Tdata-format: ~D~%" (-> obj data-format))
  (format #t "~Tglobal-effect: ~D~%" (-> obj global-effect))
  (format #t "~Tart-group: ~A~%" (-> obj art-group))
  (format #t "~Tjgeo: ~A~%" (-> obj jgeo))
  (format #t "~Tmgeo: ~A~%" (-> obj mgeo))
  (format #t "~Tdma-add-func: ~A~%" (-> obj dma-add-func))
  (format #t "~Tskeleton: ~A~%" (-> obj skeleton))
  (format #t "~Tlod-set: #<lod-set @ #x~X>~%" (-> obj lod-set))
  (format #t "~Tlod[4] @ #x~X~%" (-> obj lod-set))
  (format #t "~Tmax-lod: ~D~%" (-> obj lod-set max-lod))
  (format #t "~Tforce-lod: ~D~%" (-> obj force-lod))
  (format #t "~Tcur-lod: ~D~%" (-> obj cur-lod))
  (format #t "~Tdesired-lod: ~D~%" (-> obj desired-lod))
  (format #t "~Tripple: ~A~%" (-> obj ripple))
  (format #t "~Tlongest-edge: (meters ~m)~%" (-> obj longest-edge))
  (format #t "~Tlongest-edge?: ~D~%" (-> obj longest-edge))
  (format #t "~Tlight-index: ~D~%" (-> obj light-index))
  (format #t "~Tdummy[2] @ #x~X~%" (-> obj dummy))
  (format #t "~Tdeath-draw-overlap: ~D~%" (-> obj death-draw-overlap))
  (format #t "~Tdeath-timer: ~D~%" (-> obj death-timer))
  (format #t "~Tdeath-timer-org: ~D~%" (-> obj death-timer-org))
  (format #t "~Tdeath-vertex-skip: ~D~%" (-> obj death-vertex-skip))
  (format #t "~Tdeath-effect: ~D~%" (-> obj death-effect))
  (format #t "~Tsink-group: ~A~%" (-> obj sink-group))
  (format #t "~Tprocess: ~A~%" (-> obj process))
  (format #t "~Tshadow: ~A~%" (-> obj shadow))
  (format #t "~Tshadow-ctrl: ~A~%" (-> obj shadow-ctrl))
  (format #t "~Torigin: ~`vector`P~%" (-> obj origin))
  (format #t "~Tbounds: ~`vector`P~%" (-> obj bounds))
  (format #t "~Tradius: (meters ~m)~%" (-> obj bounds w))
  (format #t "~Tcolor-mult: #<rgbaf @ #x~X>~%" (-> obj color-mult))
  (format #t "~Tcolor-emissive: #<rgbaf @ #x~X>~%" (-> obj color-emissive))
  (format #t "~Tsecondary-interp: ~f~%" (-> obj secondary-interp))
  (format #t "~Tcurrent-secondary-interp: ~f~%" (-> obj current-secondary-interp))
  (format #t "~Tshadow-mask: ~D~%" (-> obj shadow-mask))
  (format #t "~Tlevel-index: ~D~%" (-> obj level-index))
  (format #t "~Torigin-joint-index: ~D~%" (-> obj origin-joint-index))
  (format #t "~Tshadow-joint-index: ~D~%" (-> obj shadow-joint-index))
  obj
  )

;; definition for method 9 of type draw-control
(defmethod get-skeleton-origin draw-control ((obj draw-control))
  (-> obj skeleton bones 0 transform vector 3)
  )

;; failed to figure out what this is:
0
