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

d/jak2: finish the majority of sparticle and sparticle-launcher #1840

Merged
merged 7 commits into from
Sep 5, 2022
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"program": "${workspaceFolder}/scripts/gsrc/update-from-decomp.py",
"console": "integratedTerminal",
"cwd": "${workspaceFolder}",
"args": ["--game", "jak2", "--file", "sky-data"]
"args": ["--game", "jak2", "--file", "sparticle-h"]
},
]
}
2 changes: 1 addition & 1 deletion decompiler/config/jak1_ntsc_black_label.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"disassemble_code": false,

// Run the decompiler
"decompile_code": false,
"decompile_code": true,
ManDude marked this conversation as resolved.
Show resolved Hide resolved

// run the first pass of the decompiler
"find_functions": true,
Expand Down
284 changes: 151 additions & 133 deletions decompiler/config/jak2/all-types.gc

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion decompiler/config/jak2/hacks.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@
"(method 224 bot)",
"(method 77 rapid-gunner)",
// until loop without nop:
"(method 9 sparticle-launcher)",
"cam-layout-entity-volume-info-create",
"process-drawable-shock-skel-effect",
"target-history-print",
Expand Down
8 changes: 2 additions & 6 deletions decompiler/config/jak2/label_types.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,6 @@
["L774", "(pointer uint64)", 1],
["L775", "(pointer uint64)", 1]
],
"collide-cache": [
["L171", "vector"]
],
"emerc-vu1": [
["L1", "vu-function"]
]
"collide-cache": [["L171", "vector"]],
"emerc-vu1": [["L1", "vu-function"]]
}
28 changes: 21 additions & 7 deletions decompiler/config/jak2/stack_structures.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,6 @@
[32, "vector4w"]
],
"cam-debug-draw-tris": [[16, "vector4w"]],

"(code die gun)": [
[16, "matrix"],
[112, "vector"],
Expand Down Expand Up @@ -340,12 +339,25 @@
[16, "matrix"],
[112, "event-message-block"]
],

"(method 14 collide-cache)": [
[16, "bounding-box"]

"(method 14 collide-cache)": [[16, "bounding-box"]],
"sp-adjust-launch": [[16, "matrix"]],
"sp-launch-particles-death": [[16, "matrix"]],
"sp-relaunch-particle-3d": [[16, "quaternion"]],
"execute-part-engine": [
[16, "matrix"],
[80, "vector"]
],
"sparticle-motion-blur-old": [
[16, "vector"],
[32, "vector4w"],
[48, "vector4w"]
],
"sp-orbiter": [
[16, "vector"],
[32, "vector"],
[48, "matrix"]
],
// placeholder
"placeholder-do-not-add-below": [],
"joint-mod-ik-callback": [
[16, "matrix"],
[80, "matrix"],
Expand Down Expand Up @@ -402,5 +414,7 @@
[256, "vector"]
],
"(method 13 gui-control)": [[16, ["array", "sound-id", 4]]],
"ja-play-spooled-anim": [[96, "event-message-block"]]
"ja-play-spooled-anim": [[96, "event-message-block"]],
// placeholder
"placeholder-do-not-add-below": []
}
63 changes: 34 additions & 29 deletions decompiler/config/jak2/type_casts.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -654,11 +654,6 @@
[[285, 289], "a1", "vector4w"],
[[293, 298], "v1", "dma-packet"]
],
"(method 10 history)": [[[8, 10], "a1", "history-elt"]],
"(method 10 history-iterator)": [[[20, 35], "a2", "history-elt"]],
"command-get-time": [[119, "gp", "(pointer float)"]],
"command-get-param": [[122, "gp", "(pointer float)"]],
"command-get-entity": [[10, "gp", "process"]],
"print-game-text": [
[225, "v1", "float"],
[241, "v1", "float"]
Expand Down Expand Up @@ -1278,15 +1273,9 @@
],
"cam-collision-record-save": [[[8, 56], "v1", "cam-collision-record"]],
"(trans cam-stick)": [[157, "a0", "vector"]],
"(method 9 darkjak-info)": [
[71, "v0", "sound-rpc-set-param"]
],
"(trans idle board)": [
[4, "a0", "target"]
],
"(trans hidden board)": [
[4, "a0", "target"]
],
"(method 9 darkjak-info)": [[71, "v0", "sound-rpc-set-param"]],
"(trans idle board)": [[4, "a0", "target"]],
"(trans hidden board)": [[4, "a0", "target"]],
"(trans use board)": [
[8, "a0", "target"],
[22, "a1", "target"]
Expand All @@ -1300,16 +1289,12 @@
[62, "a0", "target"],
[94, "v1", "target"]
],
"(code use board)": [
[17, "v1", "art-joint-anim"]
],
"(code use board)": [[17, "v1", "art-joint-anim"]],
"(code idle board)": [
[19, "v1", "art-joint-anim"],
[37, "v1", "art-joint-anim"]
],
"gun-init": [
[85, "a1", "target"]
],
"gun-init": [[85, "a1", "target"]],
"gun-post": [
[7, "a0", "target"],
[12, "gp", "target"],
Expand All @@ -1332,12 +1317,8 @@
[148, "gp", "target"],
[169, "a0", "target"]
],
"(trans hidden gun)": [
[4, "a0", "target"]
],
"(code idle gun)": [
[16, "v1", "art-joint-anim"]
],
"(trans hidden gun)": [[4, "a0", "target"]],
"(code idle gun)": [[16, "v1", "art-joint-anim"]],
"(trans idle gun)": [
[2, "v1", "target"],
[9, "a0", "target"],
Expand Down Expand Up @@ -1433,8 +1414,30 @@
[46, "a0", "(pointer gs-reg64)"],
[[49, 61], "v1", "dma-packet"]
],
// placeholder
"placeholder-do-not-add-below": [],
"sparticle-track-root-prim": [[3, "v1", "collide-shape"]],
"(method 10 sparticle-launcher)": [[41, "gp", "(array float)"]],
"birth-func-texture-group": [[3, "s5", "(pointer int32)"]],
"(method 9 sparticle-launch-control)": [[22, "a2", "process-drawable"]],
"execute-part-engine": [
[11, "v1", "connection"],
[137, "a3", "vector"]
],
"(method 2 sparticle-cpuinfo)": [[14, "f0", "float"]],
"sp-kill-particle": [
[7, "a1", "uint"],
[7, "v1", "uint"]
],
"sp-orbiter": [[[78, 89], "v1", "sprite-vec-data-2d"]],
"forall-particles-with-key-runner": [
[32, "s3", "(inline-array sparticle-cpuinfo)"],
[42, "s3", "(inline-array sparticle-cpuinfo)"]
],
"forall-particles-runner": [
[[19, 28], "s4", "sparticle-cpuinfo"],
[34, "s4", "pointer"],
[35, "s3", "pointer"]
],
"sp-process-particle-system": [[14, "a1", "vector"]],
"drawable-load": [[[25, 28], "s5", "drawable"]],
"art-load": [[[13, 16], "s5", "art"]],
"art-group-load-check": [[[43, 53], "s3", "art-group"]],
Expand Down Expand Up @@ -1474,5 +1477,7 @@
[44, "v1", "gui-connection"],
[14, "v1", "gui-connection"]
],
"(method 10 gui-control)": [[[4, 32], "s3", "gui-connection"]]
"(method 10 gui-control)": [[[4, 32], "s3", "gui-connection"]],
// placeholder
"placeholder-do-not-add-below": []
}
3 changes: 2 additions & 1 deletion decompiler/util/DecompilerTypeSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ int DecompilerTypeSystem::get_format_arg_count(const std::string& str) const {

static const std::vector<char> single_char_ignore_list = {'%', 'T'};
static const std::vector<std::string> multi_char_ignore_list = {
"0L", "1L", "3L", "1k", "1K", "2j", "0k", "0K", "30L", "1T", "2T"};
"0L", "1L", "3L", "1k", "1K", "2j", "0k", "30L", "1T", "2T", "100", "200", "350"};
ManDude marked this conversation as resolved.
Show resolved Hide resolved

int arg_count = 0;
for (size_t i = 0; i < str.length(); i++) {
Expand All @@ -438,6 +438,7 @@ int DecompilerTypeSystem::get_format_arg_count(const std::string& str) const {
}
}

// TODO - this is dumb, make this not depend on hard-coded lengths
for (auto& code : multi_char_ignore_list) {
if (i + 1 < str.length() && code.length() == 2 && (str.at(i) == code.at(0)) &&
str.at(i + 1) == code.at(1)) {
Expand Down
5 changes: 5 additions & 0 deletions goal_src/jak2/engine/camera/cam-interface-h.gc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@

(define-extern camera-pos (function vector))

;; NOTE - for sparticle-launcher
(define-extern math-camera-matrix
"Returns [[*math-camera*]]'s `inv-camera-rot`"
(function matrix))

;; DECOMP BEGINS

(define-perm *camera-init-mat* matrix #f)
Expand Down
49 changes: 20 additions & 29 deletions goal_src/jak2/engine/camera/camera-h.gc
Original file line number Diff line number Diff line change
Expand Up @@ -5,43 +5,32 @@
;; name in dgo: camera-h
;; dgos: ENGINE, GAME

;; +++cam-index-options
(defenum cam-index-options
:type uint32
:bitfield #t
(RADIAL)
(SPHERICAL)
)
;; ---cam-index-options

;; +++slave-los-state
(defenum slave-los-state
:type uint32
(none 0)
(cw 1)
(ccw 2)
(between 3)
)

(defenum camera-slave-options
:type uint32
:bitfield #t
(butt-cam)
(same-side)
(move-spherical)
(allow-z-rot)
(pitch-for-jump)
(collide)
(find-hidden-target)
(drag)
(line-of-sight)
(no-rotate)
(sticky-angle))
;; ---slave-los-state

;; +++camera-blend-to-type
(defenum camera-blend-to-type
:type uint64
(unknown-0 0)
(unknown-1 1)
(unknown-2 2))
;; ---camera-h:camera-blend-to-type
;; ---camera-blend-to-type

;; NOTE - for settings
(declare-type camera-slave process)
Expand Down Expand Up @@ -387,26 +376,28 @@
:size-assert #xa94
:flag-assert #xe0a200a94
(:states
cam-really-fixed
cam-bike
cam-circular
cam-decel
cam-endlessfall
cam-eye
cam-fixed
cam-fixed-read-entity
cam-free-floating
cam-lookat
cam-point-watch
cam-pov
cam-pov180
cam-pov-track
cam-pov180
cam-really-fixed
cam-robotboss
cam-spline
cam-standoff
cam-standoff-read-entity
cam-eye
cam-spline
cam-decel
cam-endlessfall
cam-circular
cam-lookat
cam-string
cam-stick
cam-bike
cam-robotboss ;; TODO - state docstrings "A holdout from jak 1?"
cam-point-watch
cam-free-floating))
cam-string
)
)


(deftype camera-master (process)
Expand Down
2 changes: 2 additions & 0 deletions goal_src/jak2/engine/debug/debug-h.gc
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
;; NOTE - for cam-debug
(define-extern transform-float-point (function vector vector4w vector4w))
(define-extern add-debug-line (function symbol bucket-id vector vector rgba symbol rgba symbol))
;; NOTE - for sparticle-launcher
(define-extern add-debug-sphere (function symbol bucket-id vector float rgba symbol))


(define-extern add-debug-line2d (function symbol bucket-id vector vector vector symbol))
Expand Down
3 changes: 3 additions & 0 deletions goal_src/jak2/engine/draw/drawable-h.gc
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
;; name in dgo: drawable-h
;; dgos: ENGINE, GAME

;; NOTE - for sparticle-launcher
(define-extern sphere-in-view-frustum? (function sphere symbol))

;; DECOMP BEGINS

(deftype drawable (basic)
Expand Down
Loading