From 1de0733d6450df665d14947c6e13f15a091f0c25 Mon Sep 17 00:00:00 2001 From: Tyler Wilding Date: Thu, 20 May 2021 22:29:07 -0400 Subject: [PATCH 1/3] decomp: Decompile `ripple` --- decompiler/config/all-types.gc | 87 ++++++++++--------- .../jak1_ntsc_black_label/label_types.jsonc | 5 ++ .../jak1_ntsc_black_label/stack_vars.jsonc | 4 + 3 files changed, 54 insertions(+), 42 deletions(-) diff --git a/decompiler/config/all-types.gc b/decompiler/config/all-types.gc index ed83867d1b..3d78677cf1 100644 --- a/decompiler/config/all-types.gc +++ b/decompiler/config/all-types.gc @@ -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 @@ -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) @@ -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) @@ -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 @@ -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 @@ -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) ) @@ -8888,9 +8892,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) @@ -13621,25 +13625,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 none)) +(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) @@ -33610,7 +33627,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 @@ -34137,7 +34153,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) @@ -34200,19 +34216,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 diff --git a/decompiler/config/jak1_ntsc_black_label/label_types.jsonc b/decompiler/config/jak1_ntsc_black_label/label_types.jsonc index 066c8dad44..f9fb79fe73 100644 --- a/decompiler/config/jak1_ntsc_black_label/label_types.jsonc +++ b/decompiler/config/jak1_ntsc_black_label/label_types.jsonc @@ -440,5 +440,10 @@ "trajectory": [ ["L18", "uint64", true] + ], + + "ripple": [ + ["L73", "float", true], + ["L74", "uint64", true] ] } diff --git a/decompiler/config/jak1_ntsc_black_label/stack_vars.jsonc b/decompiler/config/jak1_ntsc_black_label/stack_vars.jsonc index 5cad27fbd7..a823f7ab2a 100644 --- a/decompiler/config/jak1_ntsc_black_label/stack_vars.jsonc +++ b/decompiler/config/jak1_ntsc_black_label/stack_vars.jsonc @@ -246,5 +246,9 @@ "(method 15 trajectory)": [ [16, "vector"], [32, "vector"] + ], + + "ripple-add-debug-sphere": [ + [16, "vector"] ] } From a31060727ad81340b9937704d5ece1bb5ac4e7a9 Mon Sep 17 00:00:00 2001 From: Tyler Wilding Date: Sat, 22 May 2021 00:34:58 -0400 Subject: [PATCH 2/3] decomp: Finish decompiling `ripple` --- .gitignore | 1 + Taskfile.yml | 9 +- decompiler/config/all-types.gc | 2 +- .../jak1_ntsc_black_label/type_casts.jsonc | 4 + .../reference/all_forward_declarations.gc | 16 +- .../reference/engine/data/art-h_REF.gc | 88 +++--- .../reference/engine/gfx/merc/merc-h_REF.gc | 26 +- .../reference/engine/gfx/ripple_REF.gc | 269 ++++++++++++++++++ test/offline/offline_test_main.cpp | 36 ++- 9 files changed, 379 insertions(+), 72 deletions(-) create mode 100644 test/decompiler/reference/engine/gfx/ripple_REF.gc diff --git a/.gitignore b/.gitignore index e268967677..db29016934 100644 --- a/.gitignore +++ b/.gitignore @@ -21,3 +21,4 @@ logs/* *.log *.p2s savestate-out/ +failures/ diff --git a/Taskfile.yml b/Taskfile.yml index 2ed7e70d62..e901aee857 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -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 diff --git a/decompiler/config/all-types.gc b/decompiler/config/all-types.gc index aad91791f2..ca7c67786d 100644 --- a/decompiler/config/all-types.gc +++ b/decompiler/config/all-types.gc @@ -13652,7 +13652,7 @@ (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 none)) +(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)) diff --git a/decompiler/config/jak1_ntsc_black_label/type_casts.jsonc b/decompiler/config/jak1_ntsc_black_label/type_casts.jsonc index bfef2aee4f..943b06c381 100644 --- a/decompiler/config/jak1_ntsc_black_label/type_casts.jsonc +++ b/decompiler/config/jak1_ntsc_black_label/type_casts.jsonc @@ -453,5 +453,9 @@ "(method 3 generic-tie-interp-point)": [ [15, "gp", "(pointer uint128)"] + ], + + "ripple-find-height": [ + [[22, 72], "s4", "mei-ripple"] ] } diff --git a/test/decompiler/reference/all_forward_declarations.gc b/test/decompiler/reference/all_forward_declarations.gc index 05d445d80c..c06692ef60 100644 --- a/test/decompiler/reference/all_forward_declarations.gc +++ b/test/decompiler/reference/all_forward_declarations.gc @@ -436,10 +436,12 @@ (define-extern vu-lights<-light-group! (function vu-lights light-group none)) ;; game-h - TODO +(declare-type trsqv basic) +(declare-type draw-control basic) (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) @@ -659,3 +661,13 @@ ) (define-extern add-debug-line (function symbol int vector vector rgba symbol int int)) +;; early declarations for draw-control +(declare-type ripple-control basic) +(declare-type shadow-geo basic) +(declare-type shadow-control basic) + +;; early declarations for lod-group +(declare-type merc-ctrl basic) + +;; TODO - for ripple +(define-extern add-debug-sphere (function symbol int vector float int int)) diff --git a/test/decompiler/reference/engine/data/art-h_REF.gc b/test/decompiler/reference/engine/data/art-h_REF.gc index 7db53386bb..d9aa063fb9 100644 --- a/test/decompiler/reference/engine/data/art-h_REF.gc +++ b/test/decompiler/reference/engine/data/art-h_REF.gc @@ -350,8 +350,8 @@ ;; definition of type lod-group (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) ) :pack-me :method-count-assert 9 @@ -391,46 +391,46 @@ ;; definition of type draw-control (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) - (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) - (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) - (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) + (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) + (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 @@ -500,7 +500,3 @@ ;; failed to figure out what this is: (let ((v0-21 0)) ) - - - - diff --git a/test/decompiler/reference/engine/gfx/merc/merc-h_REF.gc b/test/decompiler/reference/engine/gfx/merc/merc-h_REF.gc index ee54e57b70..040ea225a9 100644 --- a/test/decompiler/reference/engine/gfx/merc/merc-h_REF.gc +++ b/test/decompiler/reference/engine/gfx/merc/merc-h_REF.gc @@ -563,8 +563,8 @@ ;; definition of type merc-ctrl (deftype merc-ctrl (art-element) ((num-joints int32 :offset 20) - (header merc-ctrl-header :inline :offset-assert 32) - (effect uint8 :dynamic :offset-assert 112) + (header merc-ctrl-header :inline :offset-assert 32) + (effect merc-effect :inline :dynamic :offset-assert 112) ) :method-count-assert 13 :size-assert #x70 @@ -664,15 +664,15 @@ ;; definition of type ripple-control (deftype ripple-control (basic) - ((global-scale float :offset-assert 4) - (last-frame-scale float :offset-assert 8) - (close-fade-dist float :offset-assert 12) - (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) - (send-query basic :offset-assert 32) - (query basic :offset-assert 36) + ((global-scale float :offset-assert 4) + (last-frame-scale float :offset-assert 8) + (close-fade-dist float :offset-assert 12) + (far-fade-dist float :offset-assert 16) + (faded-scale float :offset-assert 20) + (individual-normal-scale float :offset-assert 24) + (waveform ripple-wave-set :offset-assert 28) + (send-query basic :offset-assert 32) + (query basic :offset-assert 36) ) :method-count-assert 9 :size-assert #x28 @@ -720,7 +720,3 @@ ;; failed to figure out what this is: (let ((v0-23 0)) ) - - - - diff --git a/test/decompiler/reference/engine/gfx/ripple_REF.gc b/test/decompiler/reference/engine/gfx/ripple_REF.gc new file mode 100644 index 0000000000..81d51e8cd3 --- /dev/null +++ b/test/decompiler/reference/engine/gfx/ripple_REF.gc @@ -0,0 +1,269 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition of type ripple-request +(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 + ) + +;; definition for method 3 of type ripple-request +(defmethod inspect ripple-request ((obj ripple-request)) + (format #t "[~8x] ~A~%" obj 'ripple-request) + (format #t "~Twaveform: ~A~%" (-> obj waveform)) + (format #t "~Teffect: #~%" (-> obj effect)) + obj + ) + +;; definition of type ripple-globals +(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 + ) + +;; definition for method 3 of type ripple-globals +(defmethod inspect ripple-globals ((obj ripple-globals)) + (format #t "[~8x] ~A~%" obj 'ripple-globals) + (format #t "~Tcount: ~D~%" (-> obj count)) + (format #t "~Trequests[16] @ #x~X~%" (-> obj requests)) + obj + ) + +;; definition for symbol *ripple-globals*, type ripple-globals +(define *ripple-globals* (new 'global 'ripple-globals)) + +;; definition for function ripple-make-request +;; INFO: Return type mismatch int vs none. +(defun ripple-make-request ((arg0 ripple-wave) (arg1 merc-effect)) + (let ((v1-1 (-> *ripple-globals* count)) + (a2-1 (-> *ripple-globals* requests)) + (a3-0 0) + ) + (when (< v1-1 16) + (dotimes (t0-1 v1-1) + (if (= arg1 (-> a2-1 t0-1 effect)) + (set! a3-0 1) + ) + ) + (when (zero? a3-0) + (set! (-> a2-1 v1-1 effect) arg1) + (set! (-> a2-1 v1-1 waveform) arg0) + (set! (-> *ripple-globals* count) (+ (-> *ripple-globals* count) 1)) + ) + ) + ) + (let ((v0-0 0)) + ) + (none) + ) + +;; definition for function ripple-update-waveform-offs +;; INFO: Return type mismatch int vs none. +(defun ripple-update-waveform-offs ((arg0 ripple-wave-set)) + (let + ((f0-1 + (the float (- (-> *display* integral-frame-counter) (-> arg0 frame-save))) + ) + ) + (when (!= f0-1 0.0) + (dotimes (v1-4 (-> arg0 count)) + (let ((a1-4 (-> arg0 wave v1-4))) + (set! (-> a1-4 offs) (+ (-> a1-4 offs) (* f0-1 (-> a1-4 delta)))) + (set! (-> a1-4 offs) (the float (logand (the int (-> a1-4 offs)) #xffff))) + ) + ) + (set! (-> arg0 frame-save) (-> *display* integral-frame-counter)) + ) + ) + (let ((v0-0 0)) + ) + (none) + ) + +;; definition for function ripple-execute-init +;; ERROR: function was not converted to expressions. Cannot decompile. + +;; definition for function ripple-create-wave-table +;; ERROR: function was not converted to expressions. Cannot decompile. + +;; definition for function ripple-apply-wave-table +;; ERROR: function was not converted to expressions. Cannot decompile. + +;; definition for function ripple-execute +;; INFO: Return type mismatch int vs none. +(defun ripple-execute () + (when (-> *ripple-globals* count) + (ripple-execute-init) + (let ((gp-0 0) + (s5-0 (-> *ripple-globals* count)) + (s4-0 (-> *ripple-globals* requests)) + ) + (while (!= gp-0 s5-0) + (when (-> s4-0 gp-0 waveform) + (let ((s3-0 gp-0) + (s2-0 (-> s4-0 gp-0 waveform)) + ) + (ripple-create-wave-table (the-as ripple-wave-set s2-0)) + (while (!= s3-0 s5-0) + (when (= s2-0 (-> s4-0 s3-0 waveform)) + (ripple-apply-wave-table (-> s4-0 s3-0 effect)) + (set! (-> s4-0 s3-0 waveform) #f) + ) + (+! s3-0 1) + ) + ) + ) + (+! gp-0 1) + ) + ) + (set! (-> *ripple-globals* count) 0) + (let ((v0-3 0)) + ) + ) + (none) + ) + +;; definition for function ripple-matrix-scale +;; ERROR: function was not converted to expressions. Cannot decompile. + +;; definition (debug) for function ripple-add-debug-sphere +;; INFO: Return type mismatch int vs none. +;; Used lq/sq +(defun-debug + ripple-add-debug-sphere + ((arg0 process-drawable) (arg1 vector) (arg2 float) (arg3 float)) + (rlet ((vf0 :class vf) + (vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + ) + (init-vf0-vector) + (let ((f30-0 (- (quaternion-y-angle (the-as quaternion (-> arg0 root rot))))) + (s5-0 (new 'stack-no-clear 'vector)) + ) + (set! (-> s5-0 quad) (the-as uint128 0)) + (let ((f28-0 (+ (-> arg1 x) (* arg2 (-> arg1 z)))) + (f26-0 (+ (-> arg1 y) (* arg3 (-> arg1 z)))) + ) + (set! (-> s5-0 x) (- (* f28-0 (cos f30-0)) (* f26-0 (sin f30-0)))) + (set! (-> s5-0 y) 0.0) + (set! (-> s5-0 z) (+ (* f26-0 (cos f30-0)) (* f28-0 (sin f30-0)))) + ) + (set! (-> s5-0 w) 0.0) + (let ((a0-6 s5-0)) + (let ((v1-1 s5-0) + (a1-2 (-> arg0 root trans)) + ) + (.mov.vf vf6 vf0 :mask #b1000) + (.lvf vf4 (&-> v1-1 quad)) + (.lvf vf5 (&-> a1-2 quad)) + ) + (.add.vf vf6 vf4 vf5 :mask #b111) + (.svf (&-> a0-6 quad) vf6) + ) + (add-debug-sphere #t 67 s5-0 2048.0 (the-as int #x8000ffff)) + ) + (none) + ) + ) + +;; definition for function ripple-slow-add-sine-waves +(defun + ripple-slow-add-sine-waves + ((arg0 ripple-wave-set) (arg1 float) (arg2 float)) + (let ((f30-0 0.0)) + (dotimes (s3-0 (-> arg0 count)) + (let* ((v1-3 (-> arg0 wave s3-0)) + (f0-2 + (+ + (+ (-> v1-3 offs) (* arg1 (-> v1-3 xmul))) + (* arg2 (-> v1-3 zmul)) + ) + ) + ) + (+! f30-0 (* (-> v1-3 scale) (cos f0-2))) + ) + ) + (fmax -127.0 (fmin 127.0 f30-0)) + ) + ) + +;; definition for function ripple-find-height +(defun ripple-find-height ((arg0 process-drawable) (arg1 basic) (arg2 vector)) + (local-vars (sv-16 float) (sv-32 float)) + (let* ((f30-0 (-> arg0 root trans y)) + (v1-1 (-> arg0 draw)) + (a1-4 (-> v1-1 lod-set lod (-> v1-1 cur-lod) geo effect)) + ) + (if (or (zero? (logand (-> a1-4 0 effect-bits) 4)) (not (-> v1-1 ripple))) + (return f30-0) + ) + (let* ((a1-5 (-> a1-4 0 extra-info)) + (s4-0 + (the-as + mei-ripple + (+ (the-as uint a1-5) (the-as uint (* (-> a1-5 ripple-offset) 16))) + ) + ) + (gp-0 (-> v1-1 ripple)) + (s5-0 (-> gp-0 waveform)) + ) + (if (not (-> gp-0 waveform)) + (return f30-0) + ) + (if (not (-> s5-0 converted)) + (return f30-0) + ) + (let* ((f28-0 (- (-> arg2 x) (-> arg0 root trans x))) + (f26-0 (- (-> arg2 z) (-> arg0 root trans z))) + (f22-0 + (+ + (quaternion-y-angle (the-as quaternion (-> arg0 root rot))) + (-> s4-0 angle) + ) + ) + (f24-0 (cos f22-0)) + (f1-3 (sin f22-0)) + (f0-4 (- (* f28-0 f24-0) (* f26-0 f1-3))) + (f1-5 (+ (* f26-0 f24-0) (* f28-0 f1-3))) + (f2-3 (/ 1.0 (-> s4-0 grid-size))) + (f28-1 (* f2-3 (- f0-4 (-> s4-0 x-base)))) + (f26-1 (* f2-3 (- f1-5 (-> s4-0 z-base)))) + ) + (ripple-update-waveform-offs s5-0) + (let* ((f22-1 (the float (the int f28-1))) + (f24-1 (the float (the int f26-1))) + (f20-0 (ripple-slow-add-sine-waves s5-0 f22-1 f24-1)) + ) + (set! sv-16 (ripple-slow-add-sine-waves s5-0 (+ 1.0 f22-1) f24-1)) + (set! sv-32 (ripple-slow-add-sine-waves s5-0 f22-1 (+ 1.0 f24-1))) + (let* + ((f1-6 (ripple-slow-add-sine-waves s5-0 (+ 1.0 f22-1) (+ 1.0 f24-1))) + (f0-22 (+ f20-0 (* (- f28-1 f22-1) (- sv-16 f20-0)))) + (f1-9 (+ sv-32 (* (- f28-1 f22-1) (- f1-6 sv-32)))) + (f1-12 (+ f0-22 (* (- f26-1 f24-1) (- f1-9 f0-22)))) + (f0-23 (-> gp-0 faded-scale)) + ) + (if (< f0-23 0.0) + (set! f0-23 (-> gp-0 global-scale)) + ) + (+ f30-0 (* (* 0.0078125 f1-12) f0-23)) + ) + ) + ) + ) + ) + ) + + + + diff --git a/test/offline/offline_test_main.cpp b/test/offline/offline_test_main.cpp index ef4f824902..6841223c89 100644 --- a/test/offline/offline_test_main.cpp +++ b/test/offline/offline_test_main.cpp @@ -62,6 +62,11 @@ const std::unordered_set g_functions_expected_to_reject = { "vif1-handler", "vif1-handler-debug", // stats-h "(method 11 perf-stat)", "(method 12 perf-stat)", + // ripple - asm + "ripple-execute-init", "ripple-create-wave-table", "ripple-apply-wave-table", + "ripple-matrix-scale", + // ripple - calls an asm function + "ripple-execute", // sync-info "(method 15 sync-info)", // needs *res-static-buf* @@ -72,13 +77,20 @@ const std::unordered_set g_functions_expected_to_reject = { const std::unordered_set g_functions_to_skip_compiling = { /// GCOMMON // these functions are not implemented by the compiler in OpenGOAL, but are in GOAL. - "abs", "ash", "min", "max", "lognor", + "abs", + "ash", + "min", + "max", + "lognor", // weird PS2 specific debug registers: "breakpoint-range-set!", // int128 fancy stuff. - "(method 3 vec4s)", "(method 2 vec4s)", + "(method 3 vec4s)", + "(method 2 vec4s)", // does weird stuff with the type system. - "print", "printl", "inspect", + "print", + "printl", + "inspect", // inline assembly "valid?", @@ -95,8 +107,10 @@ const std::unordered_set g_functions_to_skip_compiling = { "send-event-function", // pp asm (eventually we should make this work) /// MATH - "rand-vu-init", "rand-vu", "rand-vu-nostep", // random hardware - "log2", // weird tricky int-as-float stuff + "rand-vu-init", + "rand-vu", + "rand-vu-nostep", // random hardware + "log2", // weird tricky int-as-float stuff // trig "sin-rad", // fpu acc @@ -123,14 +137,19 @@ const std::unordered_set g_functions_to_skip_compiling = { "(method 3 gif-tag)", // inspect for a 128-bit type. // math camera - "transform-point-vector!", "transform-point-qword!", "transform-point-vector-scale!", + "transform-point-vector!", + "transform-point-qword!", + "transform-point-vector-scale!", // display-h "put-draw-env", // vector // bad decisions on float vs int128 - "vector-degf", "vector-degmod", "vector-deg-diff", "vector-degi", + "vector-degf", + "vector-degmod", + "vector-deg-diff", + "vector-degi", // asm "invalidate-cache-line", @@ -142,6 +161,9 @@ const std::unordered_set g_functions_to_skip_compiling = { "(method 15 sync-info)", // needs display stuff first "(method 15 sync-info-eased)", // needs display stuff first "(method 15 sync-info-paused)", // needs display stuff first + + // ripple - calls an asm function + "ripple-execute", }; // default location for the data. It can be changed with a command line argument. From 7bfdbaf8d92a76e23c75b9636ef75517b5e771ee Mon Sep 17 00:00:00 2001 From: Tyler Wilding Date: Wed, 26 May 2021 01:02:44 -0400 Subject: [PATCH 3/3] update necessary src files --- goal_src/engine/data/art-h.gc | 88 ++++++++++++++++-------------- goal_src/engine/game/game-h.gc | 8 +-- goal_src/engine/gfx/merc/merc-h.gc | 10 ++-- 3 files changed, 55 insertions(+), 51 deletions(-) diff --git a/goal_src/engine/data/art-h.gc b/goal_src/engine/data/art-h.gc index ad3943e10d..5abde2ac46 100644 --- a/goal_src/engine/data/art-h.gc +++ b/goal_src/engine/data/art-h.gc @@ -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 @@ -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 diff --git a/goal_src/engine/game/game-h.gc b/goal_src/engine/game/game-h.gc index 38c43ce459..50aa1e4a36 100644 --- a/goal_src/engine/game/game-h.gc +++ b/goal_src/engine/game/game-h.gc @@ -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) @@ -63,4 +63,4 @@ (:methods (dummy-9 () none 9) ) - ) \ No newline at end of file + ) diff --git a/goal_src/engine/gfx/merc/merc-h.gc b/goal_src/engine/gfx/merc/merc-h.gc index 15bb685177..551086c136 100644 --- a/goal_src/engine/gfx/merc/merc-h.gc +++ b/goal_src/engine/gfx/merc/merc-h.gc @@ -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 @@ -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