Skip to content

Commit

Permalink
decomp: projectiles (#777)
Browse files Browse the repository at this point in the history
* decomp: close to finishing `projectile`

blocked by #754

* decomp: finish `projectiles`

* decompiler: Add support for `sparticle-launch-group` from static data

* fix sparticle-launch-group instances

* decomp: change arg0 to `entity`
  • Loading branch information
xTVaser authored Sep 3, 2021
1 parent 22b1d26 commit 442d5ed
Show file tree
Hide file tree
Showing 14 changed files with 6,951 additions and 90 deletions.
86 changes: 44 additions & 42 deletions decompiler/config/all-types.gc
Original file line number Diff line number Diff line change
Expand Up @@ -10017,13 +10017,13 @@
(attacker handle :offset-assert 48)
(invinc-time uint64 :offset-assert 56) ;; likely useconds?
(mask uint32 :offset-assert 64)
(mode symbol :offset-assert 68)
(mode symbol :offset-assert 68)
(shove-back meters :offset-assert 72)
(shove-up meters :offset-assert 76)
(speed meters :offset-assert 80)
(dist meters :offset-assert 84)
(control float :offset-assert 88)
(angle symbol :offset-assert 92)
(angle symbol :offset-assert 92)
(rotate-to degrees :offset-assert 96)
(prev-state state :offset-assert 100)
)
Expand Down Expand Up @@ -10937,6 +10937,7 @@
)
)

(declare-type collide-edge-hold-list structure)
(deftype collide-shape (trsqv)
((process process :offset-assert 140)
(max-iteration-count uint8 :offset-assert 144)
Expand Down Expand Up @@ -10967,7 +10968,7 @@
(dummy-37 () none 37)
(dummy-38 () none 38)
(dummy-39 () none 39)
(dummy-40 (_type_ object) none 40) ;; TODO - object unknown, asm function, passed to a method 15...of a type ??
(dummy-40 (_type_ collide-edge-hold-list) none 40) ;; a guess!
(dummy-41 () none 41)
(dummy-42 () none 42)
(dummy-43 () none 43)
Expand Down Expand Up @@ -11017,7 +11018,7 @@
:size-assert #x1bc
:flag-assert #x41000001bc
(:methods
(dummy-56 () none 56)
(dummy-56 (_type_ pat-surface) none 56)
(dummy-57 (_type_ vector) none 57)
(dummy-58 (_type_ vector) none 58)
(dummy-59 (_type_ vector uint float symbol symbol symbol) none 59)
Expand Down Expand Up @@ -11540,25 +11541,26 @@
;; - Types

(deftype projectile (process-drawable)
((base-trans vector :inline :offset-assert 176)
((root-override collide-shape-moving :score 100 :offset 112)
(base-trans vector :inline :offset-assert 176)
(target vector :inline :offset-assert 192)
(target-base vector :inline :offset-assert 208)
(parent-base vector :inline :offset-assert 224)
(parent-quat vector :inline :offset-assert 240)
(base-vector vector :inline :offset-assert 256)
(timeout uint64 :offset-assert 272)
(options uint64 :offset-assert 280)
(last-target uint64 :offset-assert 288)
(notify-handle uint64 :offset-assert 296)
(last-target handle :offset-assert 288)
(notify-handle handle :offset-assert 296)
(max-speed float :offset-assert 304)
(max-turn float :offset-assert 308)
(old-dist float 16 :offset-assert 312)
(old-dist-count int32 :offset-assert 376)
(hits int32 :offset-assert 380)
(max-hits int32 :offset-assert 384)
(tween float :offset-assert 388)
(attack-mode basic :offset-assert 392)
(update-velocity basic :offset-assert 396)
(attack-mode symbol :offset-assert 392)
(update-velocity (function projectile none) :offset-assert 396)
(counter int32 :offset-assert 400)
(target-count int32 :offset-assert 404)
(sound-id sound-id :offset-assert 408)
Expand All @@ -11569,15 +11571,15 @@
:flag-assert #x1d0130019c
;; inherited inspect of process-drawable
(:methods
(dummy-20 () none 20)
(projectile-dissipate () none 21) ;; state
(projectile-impact () none 22) ;; state
(dummy-23 () none 23)
(dummy-24 (_type_ ) none 24)
(dummy-25 () none 25)
(dummy-26 () none 26)
(dummy-27 () none 27)
(dummy-28 () none 28)
(projectile-die () _type_ :state 20) ;; state - sound related?
(projectile-dissipate () _type_ :state 21) ;; state
(projectile-impact () _type_ :state 22) ;; state
(projectile-moving () _type_ :state 23) ;; state
(dummy-24 (_type_) none 24)
(dummy-25 (_type_) none 25)
(dummy-26 (_type_) none 26)
(dummy-27 (_type_) none 27)
(dummy-28 (_type_) none 28)
)
)

Expand Down Expand Up @@ -19382,7 +19384,7 @@
;; - Functions

(define-extern target-swim-tilt function)
(define-extern projectile-init-by-other function)
(define-extern projectile-init-by-other (function entity vector vector uint handle none :behavior projectile)) ;; 4th arg is `options`, 5th is `last-target`
(define-extern first-person-hud-init-by-other function)
(define-extern disable-hud function)
(define-extern enable-hud function)
Expand Down Expand Up @@ -20418,7 +20420,7 @@

;; - Functions

(define-extern eco-blue-glow function)
(define-extern eco-blue-glow (function collide-shape-prim none))
(define-extern cloud-track (function none))


Expand Down Expand Up @@ -20933,35 +20935,35 @@

;; - Types

; (deftype search-info (structure)
; ((point vector :inline :offset-assert 0)
; (best-point vector :inline :offset-assert 16)
; (match-handle uint64 :offset-assert 32)
; (match basic :offset-assert 40)
; (best float :offset-assert 44)
; (radius float :offset-assert 48)
; (rating uint32 :offset-assert 52)
; (require uint32 :offset-assert 56)
; (mask uint32 :offset-assert 60)
; (rot-base vector :inline :offset-assert 64)
; (rot-range float :offset-assert 80)
; )
; :method-count-assert 9
; :size-assert #x54
; :flag-assert #x900000054
; )
(deftype search-info (structure)
((point vector :inline :offset-assert 0)
(best-point vector :inline :offset-assert 16)
(match-handle uint64 :offset-assert 32)
(match projectile :offset-assert 40)
(best float :offset-assert 44)
(radius float :offset-assert 48)
(rating uint32 :offset-assert 52)
(require uint32 :offset-assert 56)
(mask uint32 :offset-assert 60)
(rot-base vector :inline :offset-assert 64)
(rot-range float :offset-assert 80)
)
:method-count-assert 9
:size-assert #x54
:flag-assert #x900000054
)

;; - Functions

(define-extern projectile-collision-reaction function)
(define-extern projectile-update-velocity-space-wars function)
(define-extern find-nearest-attackable function)
(define-extern projectile-collision-reaction (function collide-shape-moving collide-shape-intersect vector vector none))
(define-extern projectile-update-velocity-space-wars (function projectile none))
(define-extern find-nearest-attackable (function vector float uint uint vector float projectile)) ;; Whatever te search returns (match from search-info)
(define-extern find-ground-and-draw-shadow (function vector vector float uint process float float none))
(define-extern spawn-projectile-blue function)
(define-extern spawn-projectile-blue (function target none))

;; - Unknowns

;;(define-extern *search-info* object) ;; unknown type
(define-extern *search-info* search-info) ;; unknown type


;; ----------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -694,5 +694,9 @@
[7, "(function process int symbol event-message-block none :behavior beach-rock)"]
],

"projectiles": [
[27, "(function projectile int)"]
],

"placeholder-do-not-add-below": []
}
4 changes: 4 additions & 0 deletions decompiler/config/jak1_ntsc_black_label/label_types.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,10 @@
["L341", "uint64", true]
],

"projectiles": [
["L150", "attack-info"]
],

// please do not add things after this entry! git is dumb.
"object-file-that-doesnt-actually-exist-and-i-just-put-this-here-to-prevent-merge-conflicts-with-this-file": []
}
46 changes: 46 additions & 0 deletions decompiler/config/jak1_ntsc_black_label/stack_structures.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -1480,5 +1480,51 @@
[48, "vector"]
],

"(anon-function 27 projectiles)": [
[16, "vector"]
],

"projectile-collision-reaction": [
[16, "vector"],
[32, "vector"],
[48, "matrix"],
[96, "vector"],
[112, "event-message-block"],
[192, "vector"],
[208, "vector"]
],

"(event projectile-moving projectile)": [
[16, "event-message-block"]
],

"(code projectile-moving projectile)": [
[16, "vector"]
],

"projectile-update-velocity-space-wars": [
[16, "vector"],
[32, "vector"],
[48, "vector"],
[64, "vector"]
],

"(code projectile-die projectile)": [
[16, "event-message-block"]
],

"projectile-init-by-other": [
[16, "collide-edge-hold-list"]
],

"(method 27 projectile-yellow)": [
[16, "vector"]
],

"spawn-projectile-blue": [
[16, "vector"],
[32, "vector"]
],

"placeholder-do-not-add-below!": []
}
42 changes: 42 additions & 0 deletions decompiler/config/jak1_ntsc_black_label/type_casts.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -2577,5 +2577,47 @@
[77, "v1", "int"]
],

"(anon-function 27 projectiles)": [
[27, "s4", "collide-shape"],
[36, "s4", "collide-shape"]
],

"projectile-update-velocity-space-wars": [
[60, "a0", "target"]
],

"projectile-init-by-other": [
[70, "v1", "process-drawable"],
[77, "v1", "process-drawable"]
],

"(method 24 projectile-yellow)": [
[[81, 999], "s5", "sound-rpc-set-param"],
[99, "gp", "process-drawable"],
[102, "gp", "process-drawable"]
],

"(method 28 projectile-yellow)": [
[26, "a0", "target"],
[118, "a1", "target"]
],

"(method 27 projectile-blue)": [
[51, "v1", "process-mask"],
[87, "v1", "process-drawable"]
],

"spawn-projectile-blue": [
[69, "s2", "(function process function object object object object object object)"]
],

"(method 28 projectile-blue)": [
[27, "v1", "process-drawable"]
],

"(method 27 projectile-yellow)": [
[70, "v1", "process-mask"]
],

"placeholder-do-not-add-below": []
}
5 changes: 3 additions & 2 deletions goal_src/engine/collide/collide-shape-h.gc
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@
)
;; an actual instance of a collision primitive.
;; it's based on a transform (q means quaternion, v means with derivatives)
(declare-type collide-edge-hold-list structure)
(deftype collide-shape (trsqv)
((process process :offset-assert 140)
(max-iteration-count uint8 :offset-assert 144)
Expand Down Expand Up @@ -260,7 +261,7 @@
(dummy-37 () none 37)
(dummy-38 () none 38)
(dummy-39 () none 39)
(dummy-40 (_type_ object) none 40)
(dummy-40 (_type_ collide-edge-hold-list) none 40)
(dummy-41 () none 41)
(dummy-42 () none 42)
(dummy-43 () none 43)
Expand Down Expand Up @@ -311,7 +312,7 @@
:size-assert #x1bc
:flag-assert #x41000001bc
(:methods
(dummy-56 () none 56)
(dummy-56 (_type_ pat-surface) none 56)
(dummy-57 (_type_ vector) none 57)
(dummy-58 (_type_ vector) none 58)
(dummy-59 (_type_ vector uint float symbol symbol symbol) none 59)
Expand Down
2 changes: 1 addition & 1 deletion goal_src/engine/game/game-save.gc
Original file line number Diff line number Diff line change
Expand Up @@ -1628,7 +1628,7 @@
)
)

;; failed to figure out what this is:
;; todo floats/ints for these values.
(set!
(-> *part-id-table* 2662)
(new 'static 'sparticle-launcher
Expand Down
2 changes: 2 additions & 0 deletions goal_src/engine/game/powerups.gc
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@
;; name in dgo: powerups
;; dgos: GAME, ENGINE

;; TODO - for projectiles
(define-extern eco-blue-glow (function collide-shape-prim none))
28 changes: 15 additions & 13 deletions goal_src/engine/game/projectiles-h.gc
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,26 @@
;; dgos: GAME, ENGINE

(deftype projectile (process-drawable)
((base-trans vector :inline :offset-assert 176)
((root-override collide-shape-moving :score 100 :offset 112)
(base-trans vector :inline :offset-assert 176)
(target vector :inline :offset-assert 192)
(target-base vector :inline :offset-assert 208)
(parent-base vector :inline :offset-assert 224)
(parent-quat vector :inline :offset-assert 240)
(base-vector vector :inline :offset-assert 256)
(timeout uint64 :offset-assert 272)
(options uint64 :offset-assert 280)
(last-target uint64 :offset-assert 288)
(notify-handle uint64 :offset-assert 296)
(last-target handle :offset-assert 288)
(notify-handle handle :offset-assert 296)
(max-speed float :offset-assert 304)
(max-turn float :offset-assert 308)
(old-dist float 16 :offset-assert 312)
(old-dist-count int32 :offset-assert 376)
(hits int32 :offset-assert 380)
(max-hits int32 :offset-assert 384)
(tween float :offset-assert 388)
(attack-mode basic :offset-assert 392)
(update-velocity basic :offset-assert 396)
(attack-mode symbol :offset-assert 392)
(update-velocity (function projectile none) :offset-assert 396)
(counter int32 :offset-assert 400)
(target-count int32 :offset-assert 404)
(sound-id sound-id :offset-assert 408)
Expand All @@ -33,16 +34,17 @@
:method-count-assert 29
:size-assert #x19c
:flag-assert #x1d0130019c
;; inherited inspect of process-drawable
(:methods
(dummy-20 () none 20)
(projectile-dissipate () none 21) ;; state
(projectile-impact () none 22) ;; state
(dummy-23 () none 23)
(projectile-die () _type_ :state 20) ;; state - sound related?
(projectile-dissipate () _type_ :state 21) ;; state
(projectile-impact () _type_ :state 22) ;; state
(projectile-moving () _type_ :state 23) ;; state
(dummy-24 (_type_) none 24)
(dummy-25 () none 25)
(dummy-26 () none 26)
(dummy-27 () none 27)
(dummy-28 () none 28)
(dummy-25 (_type_) none 25)
(dummy-26 (_type_) none 26)
(dummy-27 (_type_) none 27)
(dummy-28 (_type_) none 28)
)
)

Expand Down
Loading

0 comments on commit 442d5ed

Please sign in to comment.