From 3219180e602c89db2ab68fcbd0f090e0af7a3f76 Mon Sep 17 00:00:00 2001 From: Tyler Wilding Date: Fri, 9 Jul 2021 21:44:48 -0400 Subject: [PATCH] decomp: finish `air` (#683) --- decompiler/config/all-types.gc | 80 +++---- .../jak1_ntsc_black_label/label_types.jsonc | 5 + .../stack_structures.jsonc | 14 +- goal_src/levels/beach/air.gc | 207 +++++++++++++++++ .../reference/engine/geometry/geometry_REF.gc | 5 - .../reference/levels/beach/air_REF.gc | 214 ++++++++++++++++++ 6 files changed, 474 insertions(+), 51 deletions(-) create mode 100644 test/decompiler/reference/levels/beach/air_REF.gc diff --git a/decompiler/config/all-types.gc b/decompiler/config/all-types.gc index c872859908..43a13e8642 100644 --- a/decompiler/config/all-types.gc +++ b/decompiler/config/all-types.gc @@ -23329,9 +23329,9 @@ ;; - Functions -(define-extern point-in-air? function) -(define-extern points-in-air? function) -(define-extern add-debug-air-box function) +(define-extern point-in-air? (function vector (inline-array air-box) int symbol)) ;; Not used +(define-extern points-in-air? (function vector vector (inline-array air-box) int symbol)) +(define-extern add-debug-air-box (function bucket-id air-box symbol)) ;; ---------------------- @@ -24349,47 +24349,37 @@ ;; - Types -; (deftype seagull (process-drawable) -; ((index int32 :offset-assert 176) -; (flock uint32 :offset-assert 180) -; (heading float :offset-assert 184) -; (tilt float :offset-assert 188) -; (max-tilt float :offset-assert 192) -; (angletan float :offset-assert 196) -; (target-dist float :offset-assert 200) -; (scared int32 :offset-assert 204) -; (temp-heading float :offset-assert 208) -; (temp-heading-time int32 :offset-assert 212) -; (part-time uint64 :offset-assert 216) -; (thrust float :offset-assert 224) -; (teleport basic :offset-assert 228) -; ) -; :method-count-assert 28 -; :size-assert #xe8 -; :flag-assert #x1c008000e8 -; ;; inherited inspect of process-drawable -; (:methods -; (dummy-9 () none 9) -; (dummy-10 () none 10) -; (dummy-11 () none 11) -; (dummy-12 () none 12) -; (dummy-13 () none 13) -; (dummy-14 () none 14) -; (dummy-15 () none 15) -; (dummy-16 () none 16) -; (dummy-17 () none 17) -; (dummy-18 () none 18) -; (dummy-19 () none 19) -; (dummy-20 () none 20) -; (dummy-21 () none 21) -; (dummy-22 () none 22) -; (dummy-23 () none 23) -; (dummy-24 () none 24) -; (dummy-25 () none 25) -; (dummy-26 () none 26) -; (dummy-27 () none 27) -; ) -; ) +(deftype seagull (process-drawable) + ((index int32 :offset-assert 176) + (flock uint32 :offset-assert 180) + (heading float :offset-assert 184) + (tilt float :offset-assert 188) + (max-tilt float :offset-assert 192) + (angletan float :offset-assert 196) + (target-dist float :offset-assert 200) + (scared int32 :offset-assert 204) + (temp-heading float :offset-assert 208) + (temp-heading-time int32 :offset-assert 212) + (part-time uint64 :offset-assert 216) + (thrust float :offset-assert 224) + (teleport basic :offset-assert 228) + ) + :method-count-assert 28 + :heap-base #x80 + :size-assert #xe8 + :flag-assert #x1c008000e8 + ;; inherited inspect of process-drawable + (:methods + (dummy-20 () none 20) + (dummy-21 () none 21) + (dummy-22 () none 22) + (dummy-23 () none 23) + (dummy-24 () none 24) + (dummy-25 () none 25) + (dummy-26 () none 26) + (dummy-27 (_type_) none 27) + ) + ) ; (deftype seagullflock (process) ; ((path basic :offset-assert 112) @@ -24442,7 +24432,7 @@ ;;(define-extern seagull-soaring object) ;; unknown type ;;(define-extern seagull-flying object) ;; unknown type ;;(define-extern seagull-landing object) ;; unknown type -;;(define-extern *seagull-boxes* object) ;; unknown type +(define-extern *seagull-boxes* (inline-array air-box)) ;; unknown type ;;(define-extern seagull-takeoff 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 856e044138..7bc8a2b868 100644 --- a/decompiler/config/jak1_ntsc_black_label/label_types.jsonc +++ b/decompiler/config/jak1_ntsc_black_label/label_types.jsonc @@ -1151,6 +1151,11 @@ ["L100", "(array level-hint-control)", true] ], + "air": [ + ["L38", "uint64", true], + ["L39", "uint64", 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 2b59a2f189..926aed8c1d 100644 --- a/decompiler/config/jak1_ntsc_black_label/stack_structures.jsonc +++ b/decompiler/config/jak1_ntsc_black_label/stack_structures.jsonc @@ -509,5 +509,17 @@ "curve-closest-point": [ [16, "vector"], [32, "vector"] - ] + ], + + "(method 27 seagull)": [ + [16, "vector"], + [32, "vector"] + ], + + "add-debug-air-box": [ + [16, "vector"], + [32, "vector"] + ], + + "placeholder-do-not-add-below!": [] } diff --git a/goal_src/levels/beach/air.gc b/goal_src/levels/beach/air.gc index d30c6d4679..88b56ca722 100644 --- a/goal_src/levels/beach/air.gc +++ b/goal_src/levels/beach/air.gc @@ -5,3 +5,210 @@ ;; name in dgo: air ;; dgos: BEA, L1 +;; definition for function point-in-air? +(defun point-in-air? ((arg0 vector) (arg1 (inline-array air-box)) (arg2 int)) + (local-vars (t0-0 symbol)) + (dotimes (v1-0 arg2) + (let ((t1-0 arg0) + (a3-1 (-> arg1 v1-0)) + ) + (set! t0-0 (when (< (-> a3-1 height-level) (-> t1-0 y)) + (let ((f0-2 (- (-> t1-0 x) (-> a3-1 x-pos))) + (f2-1 (- (-> t1-0 z) (-> a3-1 z-pos))) + ) + (set! t0-0 #f) + (let + ((f1-5 + (+ + (* f0-2 (-> a3-1 cos-angle)) + (* f2-1 (-> a3-1 sin-angle)) + ) + ) + (f0-4 + (- + (* f2-1 (-> a3-1 cos-angle)) + (* f0-2 (-> a3-1 sin-angle)) + ) + ) + ) + (if + (and + (>= f1-5 0.0) + (>= f0-4 0.0) + (< f1-5 (-> a3-1 x-length)) + (< f0-4 (-> a3-1 z-length)) + ) + (set! t0-0 #t) + ) + ) + ) + t0-0 + ) + ) + ) + (if t0-0 + (return #t) + ) + ) + #f + ) + +;; definition for function points-in-air? +(defun + points-in-air? + ((arg0 vector) (arg1 vector) (arg2 (inline-array air-box)) (arg3 int)) + (local-vars (t1-4 symbol)) + (dotimes (v1-0 arg3) + (let* ((t0-1 (-> arg2 v1-0)) + (f0-0 (-> t0-1 height-level)) + ) + (when (and (< f0-0 (-> arg0 y)) (< f0-0 (-> arg1 y))) + (let ((f2-0 (- (-> arg0 x) (-> t0-1 x-pos))) + (f4-0 (- (-> arg0 z) (-> t0-1 z-pos))) + (f0-4 (- (-> arg1 x) (-> t0-1 x-pos))) + (f1-6 (- (-> arg1 z) (-> t0-1 z-pos))) + (t2-0 t0-1) + (t1-3 #f) + ) + (let ((f3-3 (+ (* f2-0 (-> t2-0 cos-angle)) (* f4-0 (-> t2-0 sin-angle)))) + (f2-2 (- (* f4-0 (-> t2-0 cos-angle)) (* f2-0 (-> t2-0 sin-angle)))) + ) + (if + (and + (>= f3-3 0.0) + (>= f2-2 0.0) + (< f3-3 (-> t2-0 x-length)) + (< f2-2 (-> t2-0 z-length)) + ) + (set! t1-3 #t) + ) + ) + (set! t1-4 (and t1-3 (begin + (set! t1-4 #f) + (let + ((f2-5 + (+ + (* f0-4 (-> t0-1 cos-angle)) + (* f1-6 (-> t0-1 sin-angle)) + ) + ) + (f0-6 + (- + (* f1-6 (-> t0-1 cos-angle)) + (* f0-4 (-> t0-1 sin-angle)) + ) + ) + ) + (if + (and + (>= f2-5 0.0) + (>= f0-6 0.0) + (< f2-5 (-> t0-1 x-length)) + (< f0-6 (-> t0-1 z-length)) + ) + (set! t1-4 #t) + ) + ) + t1-4 + ) + ) + ) + ) + (if t1-4 + (return #t) + ) + ) + ) + ) + #f + ) + +;; definition (debug) for function add-debug-air-box +;; Used lq/sq +(defun-debug add-debug-air-box ((arg0 bucket-id) (arg1 air-box)) + (local-vars (a0-1 symbol)) + (let ((a1-1 (camera-pos)) + (s5-0 (new 'stack-no-clear 'vector)) + (s4-0 (new 'stack-no-clear 'vector)) + ) + (-> arg1 cos-angle) + (-> arg1 sin-angle) + (let ((s2-0 (the-as uint #x800000ff))) + (let ((v1-0 arg1)) + (set! a0-1 (when (< (-> v1-0 height-level) (-> a1-1 y)) + (let ((f0-4 (- (-> a1-1 x) (-> v1-0 x-pos))) + (f2-1 (- (-> a1-1 z) (-> v1-0 z-pos))) + ) + (set! a0-1 #f) + (let + ((f1-5 + (+ + (* f0-4 (-> v1-0 cos-angle)) + (* f2-1 (-> v1-0 sin-angle)) + ) + ) + (f0-6 + (- + (* f2-1 (-> v1-0 cos-angle)) + (* f0-4 (-> v1-0 sin-angle)) + ) + ) + ) + (if + (and + (>= f1-5 0.0) + (>= f0-6 0.0) + (< f1-5 (-> v1-0 x-length)) + (< f0-6 (-> v1-0 z-length)) + ) + (set! a0-1 #t) + ) + ) + ) + a0-1 + ) + ) + ) + (if a0-1 + (set! s2-0 (the-as uint #x8000ff00)) + ) + (set! (-> s5-0 y) (-> arg1 height-level)) + (set! (-> s4-0 y) (-> arg1 height-level)) + (set! (-> s5-0 w) 1.0) + (set! (-> s4-0 w) 1.0) + (set! (-> s5-0 x) (-> arg1 x-pos)) + (set! (-> s5-0 z) (-> arg1 z-pos)) + (set! + (-> s4-0 x) + (+ (-> arg1 x-pos) (* (-> arg1 cos-angle) (-> arg1 x-length))) + ) + (set! + (-> s4-0 z) + (+ (-> arg1 z-pos) (* (-> arg1 sin-angle) (-> arg1 x-length))) + ) + (add-debug-line #t arg0 s5-0 s4-0 (the-as rgba s2-0) #f (the-as rgba -1)) + (set! (-> s5-0 quad) (-> s4-0 quad)) + (set! + (-> s4-0 x) + (+ (-> s5-0 x) (* (- (-> arg1 sin-angle)) (-> arg1 z-length))) + ) + (set! + (-> s4-0 z) + (+ (-> s5-0 z) (* (-> arg1 cos-angle) (-> arg1 z-length))) + ) + (add-debug-line #t arg0 s5-0 s4-0 (the-as rgba s2-0) #f (the-as rgba -1)) + (set! + (-> s5-0 x) + (+ (-> arg1 x-pos) (* (- (-> arg1 sin-angle)) (-> arg1 z-length))) + ) + (set! + (-> s5-0 z) + (+ (-> arg1 z-pos) (* (-> arg1 cos-angle) (-> arg1 z-length))) + ) + (add-debug-line #t arg0 s5-0 s4-0 (the-as rgba s2-0) #f (the-as rgba -1)) + (set! (-> s4-0 x) (-> arg1 x-pos)) + (set! (-> s4-0 z) (-> arg1 z-pos)) + (add-debug-line #t arg0 s5-0 s4-0 (the-as rgba s2-0) #f (the-as rgba -1)) + ) + ) + ) diff --git a/test/decompiler/reference/engine/geometry/geometry_REF.gc b/test/decompiler/reference/engine/geometry/geometry_REF.gc index f9c065dd51..deed2f32f7 100644 --- a/test/decompiler/reference/engine/geometry/geometry_REF.gc +++ b/test/decompiler/reference/engine/geometry/geometry_REF.gc @@ -1411,7 +1411,6 @@ ;; WARN: Stack slot offset 48 signed mismatch ;; WARN: Stack slot offset 48 signed mismatch ;; WARN: Stack slot offset 48 signed mismatch -;; INFO: Return type mismatch float vs object. (defun curve-closest-point ((arg0 curve) (arg1 vector) (arg2 float) (arg3 float) (arg4 int) (arg5 float)) @@ -1482,7 +1481,3 @@ arg2 ) ) - - - - diff --git a/test/decompiler/reference/levels/beach/air_REF.gc b/test/decompiler/reference/levels/beach/air_REF.gc new file mode 100644 index 0000000000..8037459286 --- /dev/null +++ b/test/decompiler/reference/levels/beach/air_REF.gc @@ -0,0 +1,214 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition for function point-in-air? +(defun point-in-air? ((arg0 vector) (arg1 (inline-array air-box)) (arg2 int)) + (local-vars (t0-0 symbol)) + (dotimes (v1-0 arg2) + (let ((t1-0 arg0) + (a3-1 (-> arg1 v1-0)) + ) + (set! t0-0 (when (< (-> a3-1 height-level) (-> t1-0 y)) + (let ((f0-2 (- (-> t1-0 x) (-> a3-1 x-pos))) + (f2-1 (- (-> t1-0 z) (-> a3-1 z-pos))) + ) + (set! t0-0 #f) + (let + ((f1-5 + (+ + (* f0-2 (-> a3-1 cos-angle)) + (* f2-1 (-> a3-1 sin-angle)) + ) + ) + (f0-4 + (- + (* f2-1 (-> a3-1 cos-angle)) + (* f0-2 (-> a3-1 sin-angle)) + ) + ) + ) + (if + (and + (>= f1-5 0.0) + (>= f0-4 0.0) + (< f1-5 (-> a3-1 x-length)) + (< f0-4 (-> a3-1 z-length)) + ) + (set! t0-0 #t) + ) + ) + ) + t0-0 + ) + ) + ) + (if t0-0 + (return #t) + ) + ) + #f + ) + +;; definition for function points-in-air? +(defun + points-in-air? + ((arg0 vector) (arg1 vector) (arg2 (inline-array air-box)) (arg3 int)) + (local-vars (t1-4 symbol)) + (dotimes (v1-0 arg3) + (let* ((t0-1 (-> arg2 v1-0)) + (f0-0 (-> t0-1 height-level)) + ) + (when (and (< f0-0 (-> arg0 y)) (< f0-0 (-> arg1 y))) + (let ((f2-0 (- (-> arg0 x) (-> t0-1 x-pos))) + (f4-0 (- (-> arg0 z) (-> t0-1 z-pos))) + (f0-4 (- (-> arg1 x) (-> t0-1 x-pos))) + (f1-6 (- (-> arg1 z) (-> t0-1 z-pos))) + (t2-0 t0-1) + (t1-3 #f) + ) + (let ((f3-3 (+ (* f2-0 (-> t2-0 cos-angle)) (* f4-0 (-> t2-0 sin-angle)))) + (f2-2 (- (* f4-0 (-> t2-0 cos-angle)) (* f2-0 (-> t2-0 sin-angle)))) + ) + (if + (and + (>= f3-3 0.0) + (>= f2-2 0.0) + (< f3-3 (-> t2-0 x-length)) + (< f2-2 (-> t2-0 z-length)) + ) + (set! t1-3 #t) + ) + ) + (set! t1-4 (and t1-3 (begin + (set! t1-4 #f) + (let + ((f2-5 + (+ + (* f0-4 (-> t0-1 cos-angle)) + (* f1-6 (-> t0-1 sin-angle)) + ) + ) + (f0-6 + (- + (* f1-6 (-> t0-1 cos-angle)) + (* f0-4 (-> t0-1 sin-angle)) + ) + ) + ) + (if + (and + (>= f2-5 0.0) + (>= f0-6 0.0) + (< f2-5 (-> t0-1 x-length)) + (< f0-6 (-> t0-1 z-length)) + ) + (set! t1-4 #t) + ) + ) + t1-4 + ) + ) + ) + ) + (if t1-4 + (return #t) + ) + ) + ) + ) + #f + ) + +;; definition (debug) for function add-debug-air-box +;; Used lq/sq +(defun-debug add-debug-air-box ((arg0 bucket-id) (arg1 air-box)) + (local-vars (a0-1 symbol)) + (let ((a1-1 (camera-pos)) + (s5-0 (new 'stack-no-clear 'vector)) + (s4-0 (new 'stack-no-clear 'vector)) + ) + (-> arg1 cos-angle) + (-> arg1 sin-angle) + (let ((s2-0 (the-as uint #x800000ff))) + (let ((v1-0 arg1)) + (set! a0-1 (when (< (-> v1-0 height-level) (-> a1-1 y)) + (let ((f0-4 (- (-> a1-1 x) (-> v1-0 x-pos))) + (f2-1 (- (-> a1-1 z) (-> v1-0 z-pos))) + ) + (set! a0-1 #f) + (let + ((f1-5 + (+ + (* f0-4 (-> v1-0 cos-angle)) + (* f2-1 (-> v1-0 sin-angle)) + ) + ) + (f0-6 + (- + (* f2-1 (-> v1-0 cos-angle)) + (* f0-4 (-> v1-0 sin-angle)) + ) + ) + ) + (if + (and + (>= f1-5 0.0) + (>= f0-6 0.0) + (< f1-5 (-> v1-0 x-length)) + (< f0-6 (-> v1-0 z-length)) + ) + (set! a0-1 #t) + ) + ) + ) + a0-1 + ) + ) + ) + (if a0-1 + (set! s2-0 (the-as uint #x8000ff00)) + ) + (set! (-> s5-0 y) (-> arg1 height-level)) + (set! (-> s4-0 y) (-> arg1 height-level)) + (set! (-> s5-0 w) 1.0) + (set! (-> s4-0 w) 1.0) + (set! (-> s5-0 x) (-> arg1 x-pos)) + (set! (-> s5-0 z) (-> arg1 z-pos)) + (set! + (-> s4-0 x) + (+ (-> arg1 x-pos) (* (-> arg1 cos-angle) (-> arg1 x-length))) + ) + (set! + (-> s4-0 z) + (+ (-> arg1 z-pos) (* (-> arg1 sin-angle) (-> arg1 x-length))) + ) + (add-debug-line #t arg0 s5-0 s4-0 (the-as rgba s2-0) #f (the-as rgba -1)) + (set! (-> s5-0 quad) (-> s4-0 quad)) + (set! + (-> s4-0 x) + (+ (-> s5-0 x) (* (- (-> arg1 sin-angle)) (-> arg1 z-length))) + ) + (set! + (-> s4-0 z) + (+ (-> s5-0 z) (* (-> arg1 cos-angle) (-> arg1 z-length))) + ) + (add-debug-line #t arg0 s5-0 s4-0 (the-as rgba s2-0) #f (the-as rgba -1)) + (set! + (-> s5-0 x) + (+ (-> arg1 x-pos) (* (- (-> arg1 sin-angle)) (-> arg1 z-length))) + ) + (set! + (-> s5-0 z) + (+ (-> arg1 z-pos) (* (-> arg1 cos-angle) (-> arg1 z-length))) + ) + (add-debug-line #t arg0 s5-0 s4-0 (the-as rgba s2-0) #f (the-as rgba -1)) + (set! (-> s4-0 x) (-> arg1 x-pos)) + (set! (-> s4-0 z) (-> arg1 z-pos)) + (add-debug-line #t arg0 s5-0 s4-0 (the-as rgba s2-0) #f (the-as rgba -1)) + ) + ) + ) + + + +