Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

decomp: projectiles #777

Merged
merged 8 commits into from
Sep 3, 2021
90 changes: 46 additions & 44 deletions decompiler/config/all-types.gc
Original file line number Diff line number Diff line change
Expand Up @@ -10012,13 +10012,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 @@ -10932,6 +10932,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 @@ -10962,7 +10963,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 @@ -11012,7 +11013,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 @@ -11535,25 +11536,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 @@ -11564,15 +11566,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 @@ -13441,7 +13443,7 @@
(linger-duration uint16 :offset-assert 8)
(flags uint16 :offset-assert 10)
(name basic :offset-assert 12)
(launcher sparticle-group-item :offset-assert 16)
(launcher (inline-array sparticle-group-item) :offset-assert 16)
(bounds sphere :inline :offset-assert 32)
)
:method-count-assert 10
Expand Down Expand Up @@ -17430,7 +17432,7 @@
(define-extern load-state-want-force-vis (function symbol symbol int))
(define-extern command-get-param (function object symbol symbol))
(define-extern entity-birth-no-kill (function entity none))
(define-extern part-tracker-init function)
(define-extern part-tracker-init (function sparticle-launch-group int basic basic basic vector none)) ;; TODO - not confirmed
(define-extern command-list-get-process (function object process))
(define-extern command-get-quoted-param (function object symbol symbol))
(define-extern command-get-int (function object int int))
Expand Down Expand Up @@ -19374,7 +19376,7 @@
;; - Functions

(define-extern target-swim-tilt function)
(define-extern projectile-init-by-other function)
(define-extern projectile-init-by-other (function projectile 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 @@ -20410,7 +20412,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 @@ -20925,35 +20927,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 @@ -684,5 +684,17 @@
[10, "(function process-drawable none)"]
],

"projectiles": [
[0, "(function none :behavior projectile)"],
[1, "(function symbol :behavior projectile)"],
[13, "(function symbol :behavior projectile)"],
[17, "(function none :behavior projectile)"],
[18, "(function none :behavior projectile)"],
[20, "(function none :behavior projectile)"],
[21, "(function process int symbol event-message-block object :behavior projectile)"],
[22, "(function uint :behavior projectile)"],
[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 @@ -442,6 +442,10 @@
["L471", "vector4w"]
],

"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 @@ -1410,5 +1410,51 @@
[32, "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 @@ -2541,5 +2541,47 @@
[79, "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": []
}
17 changes: 17 additions & 0 deletions decompiler/util/data_decompile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,19 @@ goos::Object sp_field_init_spec_decompile(const std::vector<LinkedWord>& words,
TypeSpec("sp-field-init-spec"), 16);
}

goos::Object sp_launch_grp_launcher_decompile(const std::vector<LinkedWord>& words,
const std::vector<DecompilerLabel>& labels,
int my_seg,
int field_location,
const TypeSystem& ts,
const Field& data_field,
const std::vector<std::vector<LinkedWord>>& all_words,
const LinkedObjectFile* file) {
return decomp_ref_to_inline_array_guess_size(words, labels, my_seg, field_location, ts,
data_field, all_words, file,
TypeSpec("sparticle-group-item"), 32);
}

} // namespace

goos::Object decompile_structure(const TypeSpec& type,
Expand Down Expand Up @@ -634,6 +647,10 @@ goos::Object decompile_structure(const TypeSpec& type,
field_defs_out.emplace_back(
field.name(), sp_field_init_spec_decompile(obj_words, labels, label.target_segment,
field_start, ts, field, words, file));
} else if (field.name() == "launcher" && type.print() == "sparticle-launch-group") {
field_defs_out.emplace_back(field.name(), sp_launch_grp_launcher_decompile(
obj_words, labels, label.target_segment,
field_start, ts, field, words, file));
} else {
if (obj_words.at(field_start / 4).kind != LinkedWord::PLAIN_DATA) {
continue;
Expand Down
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
Loading