From bcae0d0b5f36f1d5a9156a356cff1f950aa46393 Mon Sep 17 00:00:00 2001 From: Tyler Wilding Date: Mon, 9 Aug 2021 22:07:39 -0400 Subject: [PATCH] decomp: finish `wobbler` (#745) Co-authored-by: water --- decompiler/config/all-types.gc | 38 +++---- .../jak1_ntsc_black_label/label_types.jsonc | 5 +- .../stack_structures.jsonc | 9 +- goal_src/levels/beach/wobbler.gc | 82 ++++++++++++++ .../reference/levels/beach/wobbler_REF.gc | 102 ++++++++++++++++++ 5 files changed, 214 insertions(+), 22 deletions(-) create mode 100644 test/decompiler/reference/levels/beach/wobbler_REF.gc diff --git a/decompiler/config/all-types.gc b/decompiler/config/all-types.gc index 5a44976bf..03cbb048a 100644 --- a/decompiler/config/all-types.gc +++ b/decompiler/config/all-types.gc @@ -23278,25 +23278,25 @@ ;; - Types -; (deftype wobbler (basic) -; ((posx float :offset-assert 4) -; (posy float :offset-assert 8) -; (velx float :offset-assert 12) -; (vely float :offset-assert 16) -; (spring float :offset-assert 20) -; (damping float :offset-assert 24) -; (height float :offset-assert 28) -; ) -; :method-count-assert 13 -; :size-assert #x20 -; :flag-assert #xd00000020 -; (:methods -; (dummy-9 () none 9) -; (dummy-10 () none 10) -; (dummy-11 () none 11) -; (dummy-12 () none 12) -; ) -; ) +(deftype wobbler (basic) + ((posx float :offset-assert 4) + (posy float :offset-assert 8) + (velx float :offset-assert 12) + (vely float :offset-assert 16) + (spring float :offset-assert 20) + (damping float :offset-assert 24) + (height float :offset-assert 28) + ) + :method-count-assert 13 + :size-assert #x20 + :flag-assert #xd00000020 + (:methods + (reset! (_type_ float float float) none 9) + (inc-xy-vel! (_type_ float float) none 10) + (move! (_type_) none 11) + (TODO-RENAME-12 (_type_ quaternion) none 12) + ) + ) ;; ---------------------- diff --git a/decompiler/config/jak1_ntsc_black_label/label_types.jsonc b/decompiler/config/jak1_ntsc_black_label/label_types.jsonc index 2544db748..286675857 100644 --- a/decompiler/config/jak1_ntsc_black_label/label_types.jsonc +++ b/decompiler/config/jak1_ntsc_black_label/label_types.jsonc @@ -1412,7 +1412,6 @@ ["L497", "float", true], ["L508", "float", true] ], - "shadow": [ ["L23", "sparticle-launcher", true], ["L26", "float", true], @@ -1430,6 +1429,10 @@ ["L10", "uint64", true] ], + "wobbler": [ + ["L6", "float", true] + ], + // 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": [] } diff --git a/decompiler/config/jak1_ntsc_black_label/stack_structures.jsonc b/decompiler/config/jak1_ntsc_black_label/stack_structures.jsonc index 49e870ac3..b8260a817 100644 --- a/decompiler/config/jak1_ntsc_black_label/stack_structures.jsonc +++ b/decompiler/config/jak1_ntsc_black_label/stack_structures.jsonc @@ -469,6 +469,7 @@ "(anon-function 286 task-control)": [[16, "event-message-block"]], "(anon-function 227 task-control)": [[16, "event-message-block"]], "(anon-function 38 task-control)": [[16, "event-message-block"]], + "(anon-function 28 task-control)": [[16, "event-message-block"]], "(method 10 border-plane)": [[16, "vector"]], "(method 9 game-info)": [[16, "event-message-block"]], "(method 9 continue-point)": [[16, "vector"]], @@ -819,8 +820,7 @@ "draw-ocean-transition-seams": [ [16, "sphere"] ], - - "(method 10 tippy)": [ + "(method 10 tippy)": [ [16, "vector"] ], @@ -840,5 +840,10 @@ [16, "vector"] ], + "(method 12 wobbler)": [ + [16, "vector"] + ], + + "placeholder-do-not-add-below!": [] } diff --git a/goal_src/levels/beach/wobbler.gc b/goal_src/levels/beach/wobbler.gc index 6b6917c67..15a415227 100644 --- a/goal_src/levels/beach/wobbler.gc +++ b/goal_src/levels/beach/wobbler.gc @@ -5,3 +5,85 @@ ;; name in dgo: wobbler ;; dgos: BEA, L1 +;; definition of type wobbler +(deftype wobbler (basic) + ((posx float :offset-assert 4) + (posy float :offset-assert 8) + (velx float :offset-assert 12) + (vely float :offset-assert 16) + (spring float :offset-assert 20) + (damping float :offset-assert 24) + (height float :offset-assert 28) + ) + :method-count-assert 13 + :size-assert #x20 + :flag-assert #xd00000020 + (:methods + (reset! (_type_ float float float) none 9) + (inc-xy-vel! (_type_ float float) none 10) + (move! (_type_) none 11) + (TODO-RENAME-12 (_type_ quaternion) none 12) + ) + ) + +;; definition for method 9 of type wobbler +;; INFO: Return type mismatch int vs none. +(defmethod reset! wobbler ((obj wobbler) (arg0 float) (arg1 float) (arg2 float)) + (set! (-> obj posx) 0.0) + (set! (-> obj posy) 0.0) + (set! (-> obj velx) 0.0) + (set! (-> obj vely) 0.0) + (set! (-> obj spring) arg0) + (set! (-> obj damping) arg1) + (set! (-> obj height) arg2) + 0 + (none) + ) + +;; definition for method 10 of type wobbler +;; INFO: Return type mismatch int vs none. +(defmethod inc-xy-vel! wobbler ((obj wobbler) (arg0 float) (arg1 float)) + (+! (-> obj velx) arg0) + (+! (-> obj vely) arg1) + 0 + (none) + ) + +;; definition for method 11 of type wobbler +;; INFO: Return type mismatch int vs none. +(defmethod move! wobbler ((obj wobbler)) + (+! (-> obj posx) (* (-> obj velx) (-> *display* seconds-per-frame))) + (+! (-> obj posy) (* (-> obj vely) (-> *display* seconds-per-frame))) + (set! (-> obj velx) (* (-> obj velx) (-> obj damping))) + (set! (-> obj vely) (* (-> obj vely) (-> obj damping))) + (+! (-> obj velx) (* (* -1.0 (-> obj posx)) (-> obj spring))) + (+! (-> obj vely) (* (* -1.0 (-> obj posy)) (-> obj spring))) + 0 + (none) + ) + +;; definition for method 12 of type wobbler +;; INFO: Return type mismatch int vs none. +(defmethod TODO-RENAME-12 wobbler ((obj wobbler) (arg0 quaternion)) + (let ((s5-0 (new 'stack-no-clear 'vector))) + (set! (-> s5-0 x) (-> obj posy)) + (set! (-> s5-0 y) 0.0) + (set! (-> s5-0 z) (- (-> obj posx))) + (vector-normalize! s5-0 1.0) + (let* + ((f0-8 + (/ + (sqrtf + (+ (* (-> obj posx) (-> obj posx)) (* (-> obj posy) (-> obj posy))) + ) + (-> obj height) + ) + ) + (f0-9 (atan f0-8 1.0)) + ) + (quaternion-vector-angle! arg0 s5-0 f0-9) + ) + ) + 0 + (none) + ) diff --git a/test/decompiler/reference/levels/beach/wobbler_REF.gc b/test/decompiler/reference/levels/beach/wobbler_REF.gc new file mode 100644 index 000000000..bb73ecb8c --- /dev/null +++ b/test/decompiler/reference/levels/beach/wobbler_REF.gc @@ -0,0 +1,102 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition of type wobbler +(deftype wobbler (basic) + ((posx float :offset-assert 4) + (posy float :offset-assert 8) + (velx float :offset-assert 12) + (vely float :offset-assert 16) + (spring float :offset-assert 20) + (damping float :offset-assert 24) + (height float :offset-assert 28) + ) + :method-count-assert 13 + :size-assert #x20 + :flag-assert #xd00000020 + (:methods + (reset! (_type_ float float float) none 9) + (inc-xy-vel! (_type_ float float) none 10) + (move! (_type_) none 11) + (TODO-RENAME-12 (_type_ quaternion) none 12) + ) + ) + +;; definition for method 3 of type wobbler +(defmethod inspect wobbler ((obj wobbler)) + (format #t "[~8x] ~A~%" obj (-> obj type)) + (format #t "~Tposx: ~f~%" (-> obj posx)) + (format #t "~Tposy: ~f~%" (-> obj posy)) + (format #t "~Tvelx: ~f~%" (-> obj velx)) + (format #t "~Tvely: ~f~%" (-> obj vely)) + (format #t "~Tspring: ~f~%" (-> obj spring)) + (format #t "~Tdamping: ~f~%" (-> obj damping)) + (format #t "~Theight: ~f~%" (-> obj height)) + obj + ) + +;; definition for method 9 of type wobbler +;; INFO: Return type mismatch int vs none. +(defmethod reset! wobbler ((obj wobbler) (arg0 float) (arg1 float) (arg2 float)) + (set! (-> obj posx) 0.0) + (set! (-> obj posy) 0.0) + (set! (-> obj velx) 0.0) + (set! (-> obj vely) 0.0) + (set! (-> obj spring) arg0) + (set! (-> obj damping) arg1) + (set! (-> obj height) arg2) + 0 + (none) + ) + +;; definition for method 10 of type wobbler +;; INFO: Return type mismatch int vs none. +(defmethod inc-xy-vel! wobbler ((obj wobbler) (arg0 float) (arg1 float)) + (+! (-> obj velx) arg0) + (+! (-> obj vely) arg1) + 0 + (none) + ) + +;; definition for method 11 of type wobbler +;; INFO: Return type mismatch int vs none. +(defmethod move! wobbler ((obj wobbler)) + (+! (-> obj posx) (* (-> obj velx) (-> *display* seconds-per-frame))) + (+! (-> obj posy) (* (-> obj vely) (-> *display* seconds-per-frame))) + (set! (-> obj velx) (* (-> obj velx) (-> obj damping))) + (set! (-> obj vely) (* (-> obj vely) (-> obj damping))) + (+! (-> obj velx) (* (* -1.0 (-> obj posx)) (-> obj spring))) + (+! (-> obj vely) (* (* -1.0 (-> obj posy)) (-> obj spring))) + 0 + (none) + ) + +;; definition for method 12 of type wobbler +;; INFO: Return type mismatch int vs none. +(defmethod TODO-RENAME-12 wobbler ((obj wobbler) (arg0 quaternion)) + (let ((s5-0 (new 'stack-no-clear 'vector))) + (set! (-> s5-0 x) (-> obj posy)) + (set! (-> s5-0 y) 0.0) + (set! (-> s5-0 z) (- (-> obj posx))) + (vector-normalize! s5-0 1.0) + (let* + ((f0-8 + (/ + (sqrtf + (+ (* (-> obj posx) (-> obj posx)) (* (-> obj posy) (-> obj posy))) + ) + (-> obj height) + ) + ) + (f0-9 (atan f0-8 1.0)) + ) + (quaternion-vector-angle! arg0 s5-0 f0-9) + ) + ) + 0 + (none) + ) + + + +