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: Decompile ripple #512

Merged
merged 5 commits into from
May 26, 2021
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ logs/*
*.log
*.p2s
savestate-out/
failures/
9 changes: 8 additions & 1 deletion Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,12 @@ tasks:
- watchmedo shell-command --drop --patterns="*.p2s" --recursive --command='task analyze-ee-memory FILE="${watch_src_path}"' "{{.SAVESTATE_DIR}}"
vars:
SAVESTATE_DIR: '{{default "." .SAVESTATE_DIR}}'

offline-tests:
cmds:
- ./out/build/Debug/bin/offline-test.exe "./iso_data/jak1"
update-reference-tests:
cmds:
- ./out/build/Debug/bin/offline-test.exe "./iso_data/jak1" --dump-mode
- python .\scripts\update_decomp_reference.py .\failures\ .\test\decompiler\reference\
- task: offline-tests

87 changes: 45 additions & 42 deletions decompiler/config/all-types.gc
Original file line number Diff line number Diff line change
Expand Up @@ -6804,8 +6804,9 @@
)

;; art-h
(declare-type merc-ctrl basic)
(deftype lod-group (structure)
((geo basic :offset-assert 0)
((geo merc-ctrl :offset-assert 0)
(dist float :offset-assert 4) ;; meters
)
:pack-me
Expand All @@ -6829,6 +6830,9 @@
)

;; art-h
(declare-type ripple-control basic)
(declare-type shadow-geo basic)
(declare-type shadow-control basic)
(deftype draw-control (basic)
((status uint8 :offset-assert 4)
(matrix-type uint8 :offset-assert 5)
Expand All @@ -6845,7 +6849,7 @@
(force-lod int8 :offset-assert 61)
(cur-lod int8 :offset-assert 62)
(desired-lod int8 :offset-assert 63)
(ripple basic :offset-assert 64)
(ripple ripple-control :offset-assert 64)
(longest-edge float :offset-assert 68) ;; meters
(longest-edge? uint32 :offset 68)
(light-index uint8 :offset-assert 72)
Expand All @@ -6855,10 +6859,10 @@
(death-timer-org uint8 :offset-assert 77)
(death-vertex-skip uint16 :offset-assert 78)
(death-effect uint32 :offset-assert 80)
(sink-group basic :offset-assert 84) ;; dma-foreground-sink-group?
(sink-group dma-foreground-sink-group :offset-assert 84) ;; dma-foreground-sink-group?
(process process :offset-assert 88)
(shadow basic :offset-assert 92)
(shadow-ctrl basic :offset-assert 96)
(shadow shadow-geo :offset-assert 92)
(shadow-ctrl shadow-control :offset-assert 96)
(origin vector :inline :offset-assert 112)
(bounds vector :inline :offset-assert 128)
(radius float :offset 140) ;; meters
Expand Down Expand Up @@ -7216,7 +7220,7 @@
(deftype merc-ctrl (art-element)
((num-joints int32 :offset 20)
(header merc-ctrl-header :inline :offset-assert 32)
(effect uint8 :dynamic :offset-assert 112)
(effect merc-effect :inline :dynamic :offset-assert 112)
)
:method-count-assert 13
:size-assert #x70
Expand Down Expand Up @@ -7280,7 +7284,7 @@
(far-fade-dist float :offset-assert 16)
(faded-scale float :offset-assert 20)
(individual-normal-scale float :offset-assert 24)
(waveform basic :offset-assert 28)
(waveform ripple-wave-set :offset-assert 28)
(send-query basic :offset-assert 32)
(query basic :offset-assert 36)
)
Expand Down Expand Up @@ -8897,9 +8901,9 @@

;; game-h
(deftype process-drawable (process)
((root basic :offset-assert 112)
((root trsqv :offset-assert 112)
(node-list basic :offset-assert 116)
(draw basic :offset-assert 120)
(draw draw-control :offset-assert 120)
(skel basic :offset-assert 124)
(nav basic :offset-assert 128)
(align basic :offset-assert 132)
Expand Down Expand Up @@ -13630,25 +13634,38 @@
; )
; )

; ;; ripple
; (deftype ripple-request (structure)
; ((waveform basic :offset-assert 0)
; (effect merc-effect :offset-assert 4)
; )
; :method-count-assert 9
; :size-assert #x8
; :flag-assert #x900000008
; )
;; ripple
(deftype ripple-request (structure)
((waveform ripple-wave :offset-assert 0)
(effect merc-effect :offset-assert 4)
)
:pack-me
:method-count-assert 9
:size-assert #x8
:flag-assert #x900000008
)

; ;; ripple
; (deftype ripple-globals (structure)
; ((count int32 :offset-assert 0)
; (requests UNKNOWN 16 :offset-assert 4)
; )
; :method-count-assert 9
; :size-assert #x84
; :flag-assert #x900000084
; )
;; ripple
(deftype ripple-globals (structure)
((count int32 :offset-assert 0)
(requests ripple-request 16 :inline :offset-assert 4)
)
:method-count-assert 9
:size-assert #x84
:flag-assert #x900000084
)

(define-extern ripple-execute-init (function none))
(define-extern *ripple-globals* ripple-globals)
(define-extern ripple-slow-add-sine-waves (function ripple-wave-set float float float))
(define-extern ripple-apply-wave-table (function merc-effect symbol))
(define-extern ripple-find-height (function process-drawable basic vector float))
(define-extern ripple-matrix-scale function)
(define-extern ripple-add-debug-sphere (function process-drawable vector float float none)) ; TODO - this could be a child type of process-drawable instead
(define-extern ripple-execute (function none))
(define-extern ripple-update-waveform-offs (function ripple-wave-set none))
(define-extern ripple-create-wave-table (function ripple-wave-set int))
(define-extern ripple-make-request (function ripple-wave merc-effect none))

; ;; bones
; (deftype bone-calculation (structure)
Expand Down Expand Up @@ -33619,7 +33636,6 @@
(define-extern art-joint-geo type)
(define-extern new-dynamic-structure (function symbol type int structure)) ;; unknown type
(define-extern merc-fragment-fp-data (function merc-fragment pointer))
(define-extern ripple-wave-set type)
(define-extern merc-ctrl type)
(define-extern *generic-debug* generic-debug) ;; unknown type

Expand Down Expand Up @@ -34146,7 +34162,7 @@
(define-extern history-init function)
(define-extern debug-draw-buffers function)
(define-extern display-file-info function)
(define-extern add-debug-sphere function)
(define-extern add-debug-sphere (function symbol int vector float int int))
(define-extern add-debug-outline-triangle function)
(define-extern add-debug-x function)
(define-extern add-debug-points function)
Expand Down Expand Up @@ -34209,19 +34225,6 @@
(define-extern merc-stats function)
(define-extern merc-stats-display function)
(define-extern get-eye-block function)
(define-extern ripple-execute-init function)
;;(define-extern *ripple-globals* object) ;; unknown type
(define-extern ripple-slow-add-sine-waves function)
;;(define-extern ripple-request object) ;; unknown type
(define-extern ripple-apply-wave-table function)
(define-extern ripple-find-height function)
(define-extern ripple-matrix-scale function)
(define-extern ripple-add-debug-sphere function)
(define-extern ripple-execute function)
(define-extern ripple-update-waveform-offs function)
(define-extern ripple-create-wave-table function)
(define-extern ripple-make-request function)
;;(define-extern ripple-globals object) ;; unknown type
(define-extern dump-qword function)
(define-extern bones-reset-sqwc function)
;;(define-extern bone-calculation-list object) ;; unknown type
Expand Down
5 changes: 5 additions & 0 deletions decompiler/config/jak1_ntsc_black_label/label_types.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -444,5 +444,10 @@

"res": [
["L150", "uint64", true]
],

"ripple": [
["L73", "float", true],
["L74", "uint64", true]
]
}
4 changes: 4 additions & 0 deletions decompiler/config/jak1_ntsc_black_label/stack_vars.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -246,5 +246,9 @@
"(method 15 trajectory)": [
[16, "vector"],
[32, "vector"]
],

"ripple-add-debug-sphere": [
[16, "vector"]
]
}
4 changes: 4 additions & 0 deletions decompiler/config/jak1_ntsc_black_label/type_casts.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -450,5 +450,9 @@

"(method 3 generic-tie-interp-point)": [
[15, "gp", "(pointer uint128)"]
],

"ripple-find-height": [
[[22, 72], "s4", "mei-ripple"]
]
}
88 changes: 46 additions & 42 deletions goal_src/engine/data/art-h.gc
Original file line number Diff line number Diff line change
Expand Up @@ -208,9 +208,10 @@
:flag-assert #x900000048
)

(declare-type merc-ctrl basic)
(deftype lod-group (structure)
((geo basic :offset-assert 0)
(dist float :offset-assert 4)
((geo merc-ctrl :offset-assert 0)
(dist float :offset-assert 4) ;; meters
)
:pack-me
:method-count-assert 9
Expand All @@ -231,47 +232,50 @@
)
)

(declare-type ripple-control basic)
(declare-type shadow-geo basic)
(declare-type shadow-control basic)
(deftype draw-control (basic)
((status uint8 :offset-assert 4)
(matrix-type uint8 :offset-assert 5)
(data-format uint8 :offset-assert 6)
(global-effect uint8 :offset-assert 7)
(art-group art-group :offset-assert 8)
(jgeo art-joint-geo :offset-assert 12)
(mgeo art-mesh-geo :offset-assert 16)
(dma-add-func function :offset-assert 20)
(skeleton skeleton-group :offset-assert 24)
(lod-set lod-set :inline :offset-assert 28)
(lod lod-group 4 :inline :offset 28)
(max-lod int8 :offset 60)
(force-lod int8 :offset-assert 61)
(cur-lod int8 :offset-assert 62)
(desired-lod int8 :offset-assert 63)
(ripple basic :offset-assert 64)
(longest-edge float :offset-assert 68) ;; meters
(longest-edge? uint32 :offset 68)
(light-index uint8 :offset-assert 72)
(dummy uint8 2 :offset-assert 73)
(death-draw-overlap uint8 :offset-assert 75)
(death-timer uint8 :offset-assert 76)
(death-timer-org uint8 :offset-assert 77)
(death-vertex-skip uint16 :offset-assert 78)
(death-effect uint32 :offset-assert 80)
(sink-group basic :offset-assert 84) ;; dma-foreground-sink-group?
(process process :offset-assert 88)
(shadow basic :offset-assert 92)
(shadow-ctrl basic :offset-assert 96)
(origin vector :inline :offset-assert 112)
(bounds vector :inline :offset-assert 128)
(radius float :offset 140) ;; meters
(color-mult rgbaf :inline :offset-assert 144)
(color-emissive rgbaf :inline :offset-assert 160)
(secondary-interp float :offset-assert 176)
(current-secondary-interp float :offset-assert 180)
(shadow-mask uint8 :offset-assert 184)
(level-index uint8 :offset-assert 185)
(origin-joint-index uint8 :offset-assert 186)
(shadow-joint-index uint8 :offset-assert 187)
((status uint8 :offset-assert 4)
(matrix-type uint8 :offset-assert 5)
(data-format uint8 :offset-assert 6)
(global-effect uint8 :offset-assert 7)
(art-group art-group :offset-assert 8)
(jgeo art-joint-geo :offset-assert 12)
(mgeo art-mesh-geo :offset-assert 16)
(dma-add-func function :offset-assert 20)
(skeleton skeleton-group :offset-assert 24)
(lod-set lod-set :inline :offset-assert 28)
(lod lod-group 4 :inline :offset 28)
(max-lod int8 :offset 60)
(force-lod int8 :offset-assert 61)
(cur-lod int8 :offset-assert 62)
(desired-lod int8 :offset-assert 63)
(ripple ripple-control :offset-assert 64)
(longest-edge float :offset-assert 68) ;; meters
(longest-edge? uint32 :offset 68)
(light-index uint8 :offset-assert 72)
(dummy uint8 2 :offset-assert 73)
(death-draw-overlap uint8 :offset-assert 75)
(death-timer uint8 :offset-assert 76)
(death-timer-org uint8 :offset-assert 77)
(death-vertex-skip uint16 :offset-assert 78)
(death-effect uint32 :offset-assert 80)
(sink-group dma-foreground-sink-group :offset-assert 84)
(process process :offset-assert 88)
(shadow shadow-geo :offset-assert 92)
(shadow-ctrl shadow-control :offset-assert 96)
(origin vector :inline :offset-assert 112)
(bounds vector :inline :offset-assert 128)
(radius float :offset 140) ;; meters
(color-mult rgbaf :inline :offset-assert 144)
(color-emissive rgbaf :inline :offset-assert 160)
(secondary-interp float :offset-assert 176)
(current-secondary-interp float :offset-assert 180)
(shadow-mask uint8 :offset-assert 184)
(level-index uint8 :offset-assert 185)
(origin-joint-index uint8 :offset-assert 186)
(shadow-joint-index uint8 :offset-assert 187)
)
:method-count-assert 12
:size-assert #xbc
Expand Down
8 changes: 4 additions & 4 deletions goal_src/engine/game/game-h.gc
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
;; name in dgo: game-h
;; dgos: GAME, ENGINE

; TODO - for hud-h.gc
; TODO - for hud-h.gc and ripple
(deftype process-drawable (process)
((root basic :offset-assert 112)
((root trsqv :offset-assert 112)
(node-list basic :offset-assert 116)
(draw basic :offset-assert 120)
(draw draw-control :offset-assert 120)
(skel basic :offset-assert 124)
(nav basic :offset-assert 128)
(align basic :offset-assert 132)
Expand Down Expand Up @@ -63,4 +63,4 @@
(:methods
(dummy-9 () none 9)
)
)
)
10 changes: 5 additions & 5 deletions goal_src/engine/gfx/merc/merc-h.gc
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@
(deftype merc-ctrl (art-element)
((num-joints int32 :offset 20)
(header merc-ctrl-header :inline :offset-assert 32)
(effect uint8 :dynamic :offset-assert 112)
(effect merc-effect :inline :dynamic :offset-assert 112)
)
:method-count-assert 13
:size-assert #x70
Expand Down Expand Up @@ -345,13 +345,13 @@
(far-fade-dist float :offset-assert 16)
(faded-scale float :offset-assert 20)
(individual-normal-scale float :offset-assert 24)
(waveform basic :offset-assert 28)
(waveform ripple-wave-set :offset-assert 28)
(send-query basic :offset-assert 32)
(query basic :offset-assert 36)
)
(:methods
(new (symbol type) _type_ 0)
)
(:methods
(new (symbol type) _type_ 0)
)
:method-count-assert 9
:size-assert #x28
:flag-assert #x900000028
Expand Down
Loading