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

;; definition of type sp-field-init-spec
(deftype sp-field-init-spec (structure)
  ((field          sp-field-id  :offset-assert   0)
   (flags          sp-flag      :offset-assert   2)
   (initial-valuef float        :offset-assert   4)
   (random-rangef  float        :offset-assert   8)
   (random-multf   float        :offset-assert  12)
   (initial-value  int32        :offset          4)
   (random-range   int32        :offset          8)
   (random-mult    int32        :offset         12)
   (sym            symbol       :offset          4)
   (func           symbol       :offset          4)
   (tex            texture-id   :offset          4)
   (pntr           pointer      :offset          4)
   (sound          sound-spec   :offset          4)
   )
  :method-count-assert 9
  :size-assert         #x10
  :flag-assert         #x900000010
  )

;; definition for method 3 of type sp-field-init-spec
(defmethod inspect sp-field-init-spec ((obj sp-field-init-spec))
  (format #t "[~8x] ~A~%" obj 'sp-field-init-spec)
  (format #t "~Tfield: ~D~%" (-> obj field))
  (format #t "~Tflags: ~D~%" (-> obj flags))
  (format #t "~Tinitial-valuef: ~f~%" (-> obj initial-valuef))
  (format #t "~Trandom-rangef: ~f~%" (-> obj random-rangef))
  (format #t "~Trandom-multf: ~f~%" (-> obj random-multf))
  (format #t "~Tinitial-value: ~D~%" (-> obj initial-valuef))
  (format #t "~Trandom-range: ~D~%" (-> obj random-rangef))
  (format #t "~Trandom-mult: ~D~%" (-> obj random-multf))
  (format #t "~Tfunc: ~A~%" (-> obj initial-valuef))
  (format #t "~Ttex: ~D~%" (-> obj initial-valuef))
  (format #t "~Tpntr: #x~X~%" (-> obj initial-valuef))
  (format #t "~Tsym: ~A~%" (-> obj initial-valuef))
  (format #t "~Tsound: ~A~%" (-> obj initial-valuef))
  obj
  )

;; definition of type sparticle-launcher
(deftype sparticle-launcher (basic)
  ((birthaccum float                              :offset-assert   4)
   (soundaccum float                              :offset-assert   8)
   (init-specs (inline-array sp-field-init-spec)  :offset-assert  12)
   )
  :method-count-assert 9
  :size-assert         #x10
  :flag-assert         #x900000010
  )

;; definition for method 3 of type sparticle-launcher
;; INFO: this function exists in multiple non-identical object files
(defmethod inspect sparticle-launcher ((obj sparticle-launcher))
  (format #t "[~8x] ~A~%" obj (-> obj type))
  (format #t "~Tbirthaccum: ~f~%" (-> obj birthaccum))
  (format #t "~Tsoundaccum: ~f~%" (-> obj soundaccum))
  (format #t "~Tinit-specs: #x~X~%" (-> obj init-specs))
  obj
  )

;; definition of type sparticle-group-item
(deftype sparticle-group-item (structure)
  ((launcher   uint32              :offset-assert   0)
   (fade-after meters              :offset-assert   4)
   (falloff-to meters              :offset-assert   8)
   (flags      sp-group-item-flag  :offset-assert  12)
   (period     uint16              :offset-assert  14)
   (length     uint16              :offset-assert  16)
   (offset     uint16              :offset-assert  18)
   (hour-mask  uint32              :offset-assert  20)
   (binding    uint32              :offset-assert  24)
   )
  :method-count-assert 9
  :size-assert         #x1c
  :flag-assert         #x90000001c
  )

;; definition for method 3 of type sparticle-group-item
(defmethod inspect sparticle-group-item ((obj sparticle-group-item))
  (format #t "[~8x] ~A~%" obj 'sparticle-group-item)
  (format #t "~Tlauncher: ~D~%" (-> obj launcher))
  (format #t "~Tfade-after: (meters ~m)~%" (-> obj fade-after))
  (format #t "~Tfalloff-to: (meters ~m)~%" (-> obj falloff-to))
  (format #t "~Tflags: ~D~%" (-> obj flags))
  (format #t "~Tperiod: ~D~%" (-> obj period))
  (format #t "~Tlength: ~D~%" (-> obj length))
  (format #t "~Toffset: ~D~%" (-> obj offset))
  (format #t "~Thour-mask: ~D~%" (-> obj hour-mask))
  (format #t "~Tbinding: ~D~%" (-> obj binding))
  obj
  )

;; definition of type sparticle-launch-state
(deftype sparticle-launch-state (structure)
  ((group-item sparticle-group-item   :offset-assert   0)
   (flags      sp-launch-state-flags  :offset-assert   4)
   (randomize  uint16                 :offset-assert   6)
   (origin     vector                 :offset-assert   8)
   (sprite3d   sprite-vec-data-3d     :offset-assert  12)
   (sprite     sparticle-cpuinfo      :offset-assert  16)
   (offset     uint32                 :offset-assert  20)
   (accum      float                  :offset-assert  24)
   (spawn-time uint32                 :offset-assert  28)
   (swarm      basic                  :offset         20)
   (seed       uint32                 :offset         24)
   (time       uint32                 :offset         28)
   (spec       basic                  :offset         16)
   (id         uint32                 :offset         12)
   )
  :method-count-assert 9
  :size-assert         #x20
  :flag-assert         #x900000020
  )

;; definition for method 3 of type sparticle-launch-state
(defmethod inspect sparticle-launch-state ((obj sparticle-launch-state))
  (format #t "[~8x] ~A~%" obj 'sparticle-launch-state)
  (format #t "~Tgroup-item: #<sparticle-group-item @ #x~X>~%" (-> obj group-item))
  (format #t "~Tflags: ~D~%" (-> obj flags))
  (format #t "~Trandomize: ~D~%" (-> obj randomize))
  (format #t "~Torigin: #<vector @ #x~X>~%" (-> obj origin))
  (format #t "~Tsprite3d: #<sprite-vec-data-3d @ #x~X>~%" (-> obj sprite3d))
  (format #t "~Tsprite: ~A~%" (-> obj sprite))
  (format #t "~Toffset: ~D~%" (-> obj offset))
  (format #t "~Taccum: ~f~%" (-> obj accum))
  (format #t "~Tspawn-time: ~D~%" (-> obj spawn-time))
  (format #t "~Tswarm: ~A~%" (-> obj offset))
  (format #t "~Tseed: ~D~%" (-> obj accum))
  (format #t "~Ttime: ~D~%" (-> obj spawn-time))
  (format #t "~Tspec: ~A~%" (-> obj sprite))
  (format #t "~Tid: ~D~%" (-> obj sprite3d))
  obj
  )

;; definition of type sparticle-launch-group
(deftype sparticle-launch-group (basic)
  ((length          int16                                       :offset-assert   4)
   (duration        uint16                                      :offset-assert   6)
   (linger-duration uint16                                      :offset-assert   8)
   (flags           sp-group-flag                               :offset-assert  10)
   (name            string                                      :offset-assert  12)
   (launcher        (inline-array sparticle-group-item)         :offset-assert  16)
   (bounds          sphere                              :inline :offset-assert  32)
   )
  :method-count-assert 10
  :size-assert         #x30
  :flag-assert         #xa00000030
  (:methods
    (create-launch-control (_type_ process) sparticle-launch-control 9)
    )
  )

;; definition for method 3 of type sparticle-launch-group
(defmethod inspect sparticle-launch-group ((obj sparticle-launch-group))
  (format #t "[~8x] ~A~%" obj (-> obj type))
  (format #t "~Tlength: ~D~%" (-> obj length))
  (format #t "~Tduration: ~D~%" (-> obj duration))
  (format #t "~Tlinger-duration: ~D~%" (-> obj linger-duration))
  (format #t "~Tflags: ~D~%" (-> obj flags))
  (format #t "~Tname: ~A~%" (-> obj name))
  (format #t "~Tlauncher: #x~X~%" (-> obj launcher))
  (format #t "~Tbounds: #<sphere @ #x~X>~%" (-> obj bounds))
  obj
  )

;; definition of type sparticle-launch-control
(deftype sparticle-launch-control (inline-array-class)
  ((group            sparticle-launch-group                  :offset-assert  16)
   (proc             process                                 :offset-assert  20)
   (local-clock      int32                                   :offset-assert  24)
   (fade             float                                   :offset-assert  28)
   (matrix           int32                                   :offset-assert  32)
   (last-spawn-frame int32                                   :offset-assert  36)
   (last-spawn-time  int32                                   :offset-assert  40)
   (center           vector                 :inline          :offset-assert  48)
   (data             sparticle-launch-state :inline :dynamic :offset-assert  64)
   )
  :method-count-assert 14
  :size-assert         #x40
  :flag-assert         #xe00000040
  (:methods
    (initialize (_type_ sparticle-launch-group process) none 9)
    (is-visible? (_type_ vector) symbol 10)
    (spawn (_type_ vector) object 11)
    (kill-and-free-particles (_type_) none 12)
    (kill-particles (_type_) none 13)
    )
  )

;; definition for method 3 of type sparticle-launch-control
(defmethod inspect sparticle-launch-control ((obj sparticle-launch-control))
  (format #t "[~8x] ~A~%" obj (-> obj type))
  (format #t "~Tlength: ~D~%" (-> obj length))
  (format #t "~Tallocated-length: ~D~%" (-> obj allocated-length))
  (format #t "~Tgroup: ~A~%" (-> obj group))
  (format #t "~Tproc: ~A~%" (-> obj proc))
  (format #t "~Tlocal-clock: ~D~%" (-> obj local-clock))
  (format #t "~Tfade: ~f~%" (-> obj fade))
  (format #t "~Tmatrix: ~D~%" (-> obj matrix))
  (format #t "~Tlast-spawn-frame: ~D~%" (-> obj last-spawn-frame))
  (format #t "~Tlast-spawn-time: ~D~%" (-> obj last-spawn-time))
  (format #t "~Tcenter: ~`vector`P~%" (-> obj center))
  (format #t "~Tdata[0] @ #x~X~%" (-> obj data))
  obj
  )

;; failed to figure out what this is:
(set! (-> sparticle-launch-control heap-base) (the-as uint 32))

;; failed to figure out what this is:
0
