jak-project/goal_src/jak3/engine/gfx/sprite/particles/sparticle-h.gc
Hat Kid 93afb02cf4
decomp3: spawn target, add merc and particle buckets and some temporary hacks (#3445)
This includes all the collision stuff needed to spawn `target`,
decompiles the sparticle code and adds some of the PC hacks needed for
merc to run (it doesn't work quite right and looks bad, likely due to a
combination of code copied from Jak 2 and the time of day hacks).

There are a bunch of temporary hacks (see commits) in place to prevent
the game from crashing quite as much, but it is still extremely prone to
doing so due to lots of missing functions/potentially bad decomp.

---------

Co-authored-by: water <awaterford111445@gmail.com>
2024-04-05 00:07:39 -04:00

141 lines
4.9 KiB
Common Lisp

;;-*-Lisp-*-
(in-package goal)
;; name: sparticle-h.gc
;; name in dgo: sparticle-h
;; dgos: GAME
(declare-type sprite-vec-data-2d structure)
(define-extern sp-get-particle (function sparticle-system int sparticle-launch-state sparticle-cpuinfo))
(define-extern kill-all-particles-with-key (function sparticle-launch-control none))
;; +++sp-cpuinfo-flag
(defenum sp-cpuinfo-flag
:bitfield #t
:type uint32
;; todo copied from jak 2
(sp-cpuinfo-flag-0 0)
(sp-cpuinfo-flag-1 1)
(sp-cpuinfo-flag-2 2) ;; cleared after an aux has its func set to add-to-sprite-aux-lst
(sp-cpuinfo-flag-3 3)
(sp-cpuinfo-flag-4 4)
(sp-cpuinfo-flag-5 5)
(ready-to-launch 6) ;; maybe just just death?
(distort 7) ;; distort sprite
(aux-list 8) ;; prevents relaunch, adds to aux
(sp-cpuinfo-flag-9 9)
(level0 10)
(level1 11)
(sp-cpuinfo-flag-12 12) ;; required to relaunch
(sp-cpuinfo-flag-13 13)
(sp-cpuinfo-flag-14 14)
(glow 15) ;; glow sprite
(use-global-acc 16)
(launch-along-z 17)
(left-multiply-quat 18)
(right-multiply-quat 19)
(set-conerot 20)
(sp-cpuinfo-flag-21 21)
)
;; ---sp-cpuinfo-flag
(defmacro .movz (result value check original)
`(if (= ,check 0)
(set! ,result (the-as int ,value))
(set! ,result (the-as int ,original))
)
)
(define-extern kill-all-particles-in-level (function level int))
(define-extern remap-all-particles (function none))
(define-extern process-particles (function none))
;; DECOMP BEGINS
(define *sp-60-hz* #t)
(deftype sparticle-cpuinfo (structure)
"The per-particle information. This stays on the CPU, and isn't uploaded to the VU."
((sprite sprite-vec-data-2d)
(adgif adgif-shader)
(radius float)
(omega float)
(vel-sxvel vector :inline)
(rot-syvel vector :inline)
(fade rgbaf :inline)
(acc vector :inline)
(rotvel3d quaternion :inline)
(vel vector3s :inline :overlay-at (-> vel-sxvel data 0))
(accel vector3s :inline :overlay-at (-> acc data 0))
(scalevelx float :overlay-at (-> vel-sxvel data 3))
(scalevely float :overlay-at (-> rot-syvel data 3))
(friction float)
(timer int32)
(flags sp-cpuinfo-flag)
(flags-s32 int32 :overlay-at flags)
(user-int32 int32)
(user-uint32 uint32 :overlay-at user-int32)
(user-float float :overlay-at user-int32)
(user-pntr uint32 :overlay-at user-int32)
(user-object basic :overlay-at user-int32)
(user-sprite sprite-vec-data-2d :overlay-at user-int32)
(sp-func (function sparticle-system sparticle-cpuinfo sprite-vec-data-3d uint none))
(next-time uint32)
(next-launcher basic)
(cache-alpha float)
(valid uint8)
(clock-index uint8)
(user1-int16 uint16)
(key sparticle-launch-control)
(binding sparticle-launch-state)
(data uint32 1 :overlay-at omega)
(datab int8 4 :overlay-at omega)
(dataf float 1 :overlay-at omega)
(datac uint8 1 :overlay-at omega)
)
)
(deftype sparticle-launchinfo (structure)
"Settings for launching a particle. These are a temporary thing consumed by the assembly particle code, and modified by particle callbacks."
((launchrot vector :inline)
(conerot vector :inline)
(rotate-x float)
(rotate-y float)
(rotate-z float)
(coneradius float)
(rotate vector :inline :overlay-at rotate-x)
(scale-x float)
(scale-y float)
(scale-z float)
(dummy float)
(scale vector :inline :overlay-at scale-x)
(data uint8 1 :overlay-at (-> launchrot data 0))
)
)
(deftype sparticle-system (basic)
"An entire particle 'system', which is a pipeline for spawning, updating, and generating sprite-renderer DMA data.
There are separate systems for different modes of sprite rendering: 2D/billboard, full 3D, and screen-space (HUD)"
((blocks int32 2)
(length int32 2)
(num-alloc int32 2)
(is-3d basic)
(flags uint32)
(alloc-table (pointer uint64))
(cpuinfo-table (inline-array sparticle-cpuinfo))
(vecdata-table pointer)
(adgifdata-table (inline-array adgif-shader))
)
(:methods
(new (symbol type int int symbol pointer (inline-array adgif-shader)) _type_)
)
)
(define-extern sp-kill-particle (function sparticle-system sparticle-cpuinfo symbol))
(define-extern *sp-particle-system-2d* sparticle-system)
(define-extern *sp-particle-system-3d* sparticle-system)