From ae22ba42d0db530798621fdce80b6fd304d5c4ee Mon Sep 17 00:00:00 2001 From: ManDude <7569514+ManDude@users.noreply.github.com> Date: Wed, 10 Nov 2021 04:22:31 +0000 Subject: [PATCH] [decomp] `orb-cache` (#956) * begin * tests * missing stuff --- decompiler/config/all-types.gc | 125 ++-- .../config/jak1_ntsc_black_label/hacks.jsonc | 6 - .../stack_structures.jsonc | 11 + .../jak1_ntsc_black_label/type_casts.jsonc | 12 + goal_src/engine/anim/joint.gc | 4 +- goal_src/engine/collide/collide-mesh-h.gc | 3 +- goal_src/engine/data/art-h.gc | 7 +- goal_src/engine/game/collectables.gc | 34 +- goal_src/engine/ui/text-h.gc | 32 +- goal_src/levels/common/orb-cache.gc | 542 +++++++++++++++++ .../reference/engine/anim/joint_REF.gc | 8 +- .../engine/collide/collide-mesh-h_REF.gc | 10 +- .../reference/engine/data/art-h_REF.gc | 6 +- .../engine/draw/process-drawable_REF.gc | 6 +- .../engine/game/effect-control_REF.gc | 7 +- .../reference/levels/common/orb-cache_REF.gc | 568 ++++++++++++++++++ 16 files changed, 1255 insertions(+), 126 deletions(-) create mode 100644 test/decompiler/reference/levels/common/orb-cache_REF.gc diff --git a/decompiler/config/all-types.gc b/decompiler/config/all-types.gc index 88a48ebeb1..67402f90b3 100644 --- a/decompiler/config/all-types.gc +++ b/decompiler/config/all-types.gc @@ -496,7 +496,7 @@ (defenum bucket-id :type int32 :bitfield #f - + (bucket-1 1) (bucket-2 2) (sky-draw 3) @@ -939,6 +939,8 @@ (firecanyon-not-enough-cells #x24f) + (sidekick-hint-orb-cache-top #x251) + (jungle-precursorbridge-hint #x25b) (beach-gimmie #x262) @@ -953,7 +955,7 @@ (beach-seagulls-avalanche #x273) (beach-flutflutegg-hint #x275) - + (sidekick-hint-fish-powerup #x278) (sidekick-speech-hint-crate-darkeco1 #x281) @@ -961,14 +963,14 @@ (sidekick-speech-crate-steel-break1 #x283) (sidekick-speech-hint-crate-iron #x284) (sidekick-speech-hint-crate-steel #x285) - + (jungleb-eco-vents-opened #x289) (sidekick-speech-crate-steel-break2 #x28e) (sidekick-speech-hint-crate-darkeco2 #x28f) - + (yakow-owed-powercell #x297) - + (misty-teetertotter-bonk-dax-tutorial #x2a4) (daxter-blue-eco-plat-tutorial #x2a7) @@ -1032,7 +1034,7 @@ (rolling-ring-hint-one-ring-down #x33f) (rolling-ring-hint-be-quick-to-next #x340) (rolling-ring-hint-be-quick-all #x341) - + (sunken-blue-eco-charger-hint #x345) (sunken-qbert-plat-hint #x34a) @@ -1043,19 +1045,19 @@ (swamp-bats-hint #x364) ;; maybe we can ???? the bats. lol (flutflut-reminder #x368) - + (village2-warp-gate-reminder #x36f) (village2-warp-gate-reminder-annoyed #x370) (village2-warp-gate-reminder-very-annoyed #x371) - + (village2-not-enough-cells-levitator #x36c) (villlage2-levitator-cell-req-text #x372) - + (rolling-race-time-string-prefix #x373) (rolling-race-record-string-prefix #x374) (rolling-race-new-record-string-prefix #x375) (rolling-race-try-again-string #x376) - + (village3-miner-money #x400) (village3-oracle-money #x401) (snow-ram-3-left #x402) @@ -1091,23 +1093,23 @@ (assistant-lavatube-powercell-hint #x428) (village3-gondola-malfunctioning #x429) (village3-gondola-reactivated #x42a) - + (snow-frozen-crate #x42b) ;; task name? (snow-bumpers #x42c) (darkcave-light-crystal-low-light-hint #x437) (darkcave-light-crystal-hint #x438) - + (cave-trap-nest-hint #x440) (snow-fort-reminder #x443) - + (ice-cube-hint #x448) - + (village3-warp-gate-reminder #x452) (village3-warp-gate-reminder=annoyed #x453) (village3-warp-gate-reminder-very-annoyed #x454) (lavatube-powercell-req-text #x455) - + (fire-canyon-end #x500) (fire-canyon-buzzer #x501) @@ -1147,7 +1149,7 @@ (training-eco-blue #x909) (training-precursor-door #x90b) (training-double-jump #x90e) - + (sage-voicebox-hint-crate-iron #x917) (training-warp-gate-blocked #x919) @@ -7803,11 +7805,10 @@ :flag-assert #x900000014 ) -(declare-type art-element art) (deftype art (basic) - ((name string :offset 8) - (length int32 :offset-assert 12) - (extra entity :offset-assert 16) ; possible types: [res-lump] + ((name string :offset 8) + (length int32 :offset-assert 12) + (extra res-lump :offset-assert 16) ; possible types: [res-lump] ; this field is very strange ) :method-count-assert 13 @@ -8140,8 +8141,8 @@ (deftype merc-fragment-control (structure) ((unsigned-four-count uint8 :offset-assert 0) - (lump-four-count uint8 :offset-assert 1) - (fp-qwc uint8 :offset-assert 2) + (lump-four-count uint8 :offset-assert 1) ;; merc-vtx + (fp-qwc uint8 :offset-assert 2) ;; merc-fp-header (mat-xfer-count uint8 :offset-assert 3) (mat-dest-data merc-mat-dest :inline :dynamic :offset-assert 4) ) @@ -8196,12 +8197,15 @@ :flag-assert #x900000010 ) +;; implicitly also the start of an array of mei (merc extra info's) +;; this means that an offset of 0 will point to this structure itself +;; an offset of 1 will point to 16 bytes after this structure, etc. (deftype merc-extra-info (structure) ((envmap-tint-offset uint8 :offset-assert 0) (shader-offset uint8 :offset-assert 1) (texture-scroll-offset uint8 :offset-assert 2) (ripple-offset uint8 :offset-assert 3) - (dummy uint8 12 :offset-assert 4) + (dummy uint8 12 :offset-assert 4) ;; pad size to 16 bytes ) :method-count-assert 9 :size-assert #x10 @@ -8212,7 +8216,7 @@ ;; 1 - swap with last effect. (deftype merc-effect (structure) - ((frag-geo merc-fragment :offset-assert 0) + ((frag-geo merc-fragment :offset-assert 0) ;; ? (frag-ctrl merc-fragment-control :offset-assert 4) (blend-data merc-blend-data :offset-assert 8) (blend-ctrl merc-blend-ctrl :offset-assert 12) @@ -10913,8 +10917,7 @@ ((joint-id int32 :offset-assert 4) (num-tris uint32 :offset-assert 8) (num-verts uint32 :offset-assert 12) - (vertex-data uint32 :offset-assert 16) - ;; todo - this could be wrong + (vertex-data (inline-array vector) :offset-assert 16) (tris collide-mesh-tri 1 :inline :offset 32) ) :method-count-assert 16 @@ -20823,7 +20826,7 @@ (define-extern initialize-eco-by-other (function eco vector none :behavior eco)) (define-extern add-blue-shake (function vector vector vector vector)) (define-extern money-init-by-other function) -(define-extern money-init-by-other-no-bob function) +(define-extern money-init-by-other-no-bob (function vector vector int float entity none)) (define-extern fuel-cell-init-by-other function) (define-extern fuel-cell-init-as-clone (function handle object none)) ;; TODO - unconfirmed - see beach-rocks (define-extern buzzer-init-by-other function) @@ -23108,52 +23111,36 @@ ;; - Types -; (deftype orb-cache-top (baseplat) -; ((active-distance float :offset-assert 228) -; (inactive-distance float :offset-assert 232) -; (money-list UNKNOWN 60 :offset-assert 240) -; (money-pos-list UNKNOWN 60 :offset-assert 720) -; (money-pos-actual UNKNOWN 60 :offset-assert 960) -; (platform-pos float :offset-assert 1200) -; (root-pos float :offset-assert 1204) -; (money int32 :offset-assert 1208) -; (activated basic :offset-assert 1212) -; ) -; :method-count-assert 29 -; :size-assert #x4c0 -; :heap-base #x450 -; :flag-assert #x1d045004c0 -; ;; inherited inspect of baseplat -; (: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) -; (dummy-28 () none 28) -; ) -; ) +(deftype orb-cache-top (baseplat) + ((active-distance float :offset-assert 228) + (inactive-distance float :offset-assert 232) + (money-list handle 60 :offset-assert 240) + (money-pos-list float 60 :offset-assert 720) + (money-pos-actual float 60 :offset-assert 960) + (platform-pos float :offset-assert 1200) + (root-pos float :offset-assert 1204) + (money int32 :offset-assert 1208) + (activated symbol :offset-assert 1212) + ) + :method-count-assert 29 + :size-assert #x4c0 + :heap-base #x450 + :flag-assert #x1d045004c0 + ;; inherited inspect of baseplat + (:methods + (pos-logic (_type_ symbol) symbol 27) + (calculate-pos (_type_ symbol) none 28) + ) + (:states + (orb-cache-top-complete symbol) + (orb-cache-top-activate symbol) + ) + ) ;; - Unknowns (define-extern *orb-cache-top-sg* skeleton-group) -;;(define-extern orb-cache-top-complete object) ;; unknown type -;;(define-extern orb-cache-top-activate object) ;; unknown type -;;(define-extern orb-cache-top-idle object) ;; unknown type +(define-extern orb-cache-top-idle (state symbol orb-cache-top)) ;; ---------------------- diff --git a/decompiler/config/jak1_ntsc_black_label/hacks.jsonc b/decompiler/config/jak1_ntsc_black_label/hacks.jsonc index a7e102124b..d0ddaaf1ed 100644 --- a/decompiler/config/jak1_ntsc_black_label/hacks.jsonc +++ b/decompiler/config/jak1_ntsc_black_label/hacks.jsonc @@ -336,12 +336,6 @@ "ocean-generate-verts", // crash "ocean-interp-wave", - // nav-enemy BUG - // "(anon-function 28 nav-enemy)", - - // orb-cache BUG - "(method 27 orb-cache-top)", - // ropebridge BUG "(method 27 ropebridge)", diff --git a/decompiler/config/jak1_ntsc_black_label/stack_structures.jsonc b/decompiler/config/jak1_ntsc_black_label/stack_structures.jsonc index 46d2f14308..fecd288df3 100644 --- a/decompiler/config/jak1_ntsc_black_label/stack_structures.jsonc +++ b/decompiler/config/jak1_ntsc_black_label/stack_structures.jsonc @@ -3442,5 +3442,16 @@ [16, "joint-exploder-tuning"] ], + "(trans orb-cache-top-idle)": [[16, "event-message-block"]], + "(code orb-cache-top-activate)": [ + [16, "vector"], + [32, "event-message-block"] + ], + "(code orb-cache-top-complete)": [[16, "vector"]], + "(method 27 orb-cache-top)": [ + [16, "vector"], + [32, "event-message-block"] + ], + "placeholder-do-not-add-below!": [] } diff --git a/decompiler/config/jak1_ntsc_black_label/type_casts.jsonc b/decompiler/config/jak1_ntsc_black_label/type_casts.jsonc index 68a0c3f190..544ca2deed 100644 --- a/decompiler/config/jak1_ntsc_black_label/type_casts.jsonc +++ b/decompiler/config/jak1_ntsc_black_label/type_casts.jsonc @@ -4865,5 +4865,17 @@ [143, "v1", "art-joint-anim"] ], + "(method 27 orb-cache-top)": [ + [155, "a0", "process-drawable"] + ], + + "(method 9 art)": [ + [9, "v1", "(pointer res-tag)"] + ], + + "(method 9 art-joint-anim)": [ + [9, "v1", "(pointer res-tag)"] + ], + "placeholder-do-not-add-below": [] } diff --git a/goal_src/engine/anim/joint.gc b/goal_src/engine/anim/joint.gc index 0aa22dce0c..1da69f19f8 100644 --- a/goal_src/engine/anim/joint.gc +++ b/goal_src/engine/anim/joint.gc @@ -329,7 +329,7 @@ ;; definition for method 9 of type art (defmethod login art ((obj art)) (if (and (-> obj extra) (zero? (-> obj extra tag))) - (set! (-> obj extra tag) (the-as (pointer res-tag) (-> obj extra trans))) + (set! (-> obj extra tag) (&+ (the-as (pointer res-tag) (-> obj extra)) 28)) ) obj ) @@ -636,7 +636,7 @@ ;; definition for method 9 of type art-joint-anim (defmethod login art-joint-anim ((obj art-joint-anim)) (if (and (-> obj extra) (zero? (-> obj extra tag))) - (set! (-> obj extra tag) (the-as (pointer res-tag) (-> obj extra trans))) + (set! (-> obj extra tag) (&+ (the-as (pointer res-tag) (-> obj extra)) 28)) ) obj ) diff --git a/goal_src/engine/collide/collide-mesh-h.gc b/goal_src/engine/collide/collide-mesh-h.gc index 4af6ed71cf..f053edf4ab 100644 --- a/goal_src/engine/collide/collide-mesh-h.gc +++ b/goal_src/engine/collide/collide-mesh-h.gc @@ -31,8 +31,7 @@ ((joint-id int32 :offset-assert 4) (num-tris uint32 :offset-assert 8) (num-verts uint32 :offset-assert 12) - (vertex-data uint32 :offset-assert 16) - ;; todo - this could be wrong + (vertex-data (inline-array vector) :offset-assert 16) (tris collide-mesh-tri 1 :inline :offset 32) ) :method-count-assert 16 diff --git a/goal_src/engine/data/art-h.gc b/goal_src/engine/data/art-h.gc index d31382b692..bdc48208a5 100644 --- a/goal_src/engine/data/art-h.gc +++ b/goal_src/engine/data/art-h.gc @@ -119,11 +119,10 @@ :flag-assert #x900000014 ) -(declare-type art-element basic) (deftype art (basic) - ((name string :offset 8) - (length int32 :offset-assert 12) - (extra entity :offset-assert 16) + ((name string :offset 8) + (length int32 :offset-assert 12) + (extra res-lump :offset-assert 16) ) :method-count-assert 13 :size-assert #x14 diff --git a/goal_src/engine/game/collectables.gc b/goal_src/engine/game/collectables.gc index b5a6d71069..bf1aad0773 100644 --- a/goal_src/engine/game/collectables.gc +++ b/goal_src/engine/game/collectables.gc @@ -7,9 +7,7 @@ ;; TODO - for nav-enemy (define-extern birth-pickup-at-point (function vector int float symbol process-drawable fact-info (pointer process))) -;; TODO - for oracle -(define-extern *fuel-cell-sg* skeleton-group) ;; unknown type -(define-extern *money-sg* skeleton-group) ;; unknown type + ;; TODO - for entity and beach-rocks (deftype collectable (process-drawable) ((root-override collide-shape-moving :score 100 :offset 112) @@ -78,3 +76,33 @@ ) (define-extern fuel-cell-init-as-clone (function handle object none)) (define-extern fuel-cell-pick-anim (function process-drawable spool-anim)) + +(defskelgroup *money-sg* money + 0 + 4 + ((1 (meters 20)) (2 (meters 40)) (3 (meters 999999))) + :bounds (static-spherem 0 0 0 0.6000000238418579) + :longest-edge (meters 0) + :texture-level 2 + ) + +;; failed to figure out what this is: +(defskelgroup *fuel-cell-sg* fuel-cell + 0 + 2 + ((1 (meters 999999))) + :bounds (static-spherem 0 1 0 1.600000023841858) + :longest-edge (meters 0) + :texture-level 2 + ) + +;; definition of type money +(deftype money (eco-collectable) + () + :heap-base #x130 + :method-count-assert 31 + :size-assert #x194 + :flag-assert #x1f01300194 + ) + +(define-extern money-init-by-other-no-bob (function vector vector int float entity none)) diff --git a/goal_src/engine/ui/text-h.gc b/goal_src/engine/ui/text-h.gc index f55240d831..4e57aaa4c6 100644 --- a/goal_src/engine/ui/text-h.gc +++ b/goal_src/engine/ui/text-h.gc @@ -151,6 +151,8 @@ (firecanyon-not-enough-cells #x24f) + (sidekick-hint-orb-cache-top #x251) + (jungle-precursorbridge-hint #x25b) (beach-gimmie #x262) @@ -165,7 +167,7 @@ (beach-seagulls-avalanche #x273) (beach-flutflutegg-hint #x275) - + (sidekick-hint-fish-powerup #x278) (sidekick-speech-hint-crate-darkeco1 #x281) @@ -173,14 +175,14 @@ (sidekick-speech-crate-steel-break1 #x283) (sidekick-speech-hint-crate-iron #x284) (sidekick-speech-hint-crate-steel #x285) - + (jungleb-eco-vents-opened #x289) (sidekick-speech-crate-steel-break2 #x28e) (sidekick-speech-hint-crate-darkeco2 #x28f) - + (yakow-owed-powercell #x297) - + (misty-teetertotter-bonk-dax-tutorial #x2a4) (daxter-blue-eco-plat-tutorial #x2a7) @@ -244,7 +246,7 @@ (rolling-ring-hint-one-ring-down #x33f) (rolling-ring-hint-be-quick-to-next #x340) (rolling-ring-hint-be-quick-all #x341) - + (sunken-blue-eco-charger-hint #x345) (sunken-qbert-plat-hint #x34a) @@ -255,19 +257,19 @@ (swamp-bats-hint #x364) ;; maybe we can ???? the bats. lol (flutflut-reminder #x368) - + (village2-warp-gate-reminder #x36f) (village2-warp-gate-reminder-annoyed #x370) (village2-warp-gate-reminder-very-annoyed #x371) - + (village2-not-enough-cells-levitator #x36c) (villlage2-levitator-cell-req-text #x372) - + (rolling-race-time-string-prefix #x373) (rolling-race-record-string-prefix #x374) (rolling-race-new-record-string-prefix #x375) (rolling-race-try-again-string #x376) - + (village3-miner-money #x400) (village3-oracle-money #x401) (snow-ram-3-left #x402) @@ -303,23 +305,23 @@ (assistant-lavatube-powercell-hint #x428) (village3-gondola-malfunctioning #x429) (village3-gondola-reactivated #x42a) - + (snow-frozen-crate #x42b) ;; task name? (snow-bumpers #x42c) (darkcave-light-crystal-low-light-hint #x437) (darkcave-light-crystal-hint #x438) - + (cave-trap-nest-hint #x440) (snow-fort-reminder #x443) - + (ice-cube-hint #x448) - + (village3-warp-gate-reminder #x452) (village3-warp-gate-reminder=annoyed #x453) (village3-warp-gate-reminder-very-annoyed #x454) (lavatube-powercell-req-text #x455) - + (fire-canyon-end #x500) (fire-canyon-buzzer #x501) @@ -359,7 +361,7 @@ (training-eco-blue #x909) (training-precursor-door #x90b) (training-double-jump #x90e) - + (sage-voicebox-hint-crate-iron #x917) (training-warp-gate-blocked #x919) diff --git a/goal_src/levels/common/orb-cache.gc b/goal_src/levels/common/orb-cache.gc index 39527462b9..02e0408a59 100644 --- a/goal_src/levels/common/orb-cache.gc +++ b/goal_src/levels/common/orb-cache.gc @@ -5,3 +5,545 @@ ;; name in dgo: orb-cache ;; dgos: GAME, COMMON, L1 +;; DECOMP BEGINS + +(deftype orb-cache-top (baseplat) + ((active-distance float :offset-assert 228) + (inactive-distance float :offset-assert 232) + (money-list handle 60 :offset-assert 240) + (money-pos-list float 60 :offset-assert 720) + (money-pos-actual float 60 :offset-assert 960) + (platform-pos float :offset-assert 1200) + (root-pos float :offset-assert 1204) + (money int32 :offset-assert 1208) + (activated symbol :offset-assert 1212) + ) + :heap-base #x450 + :method-count-assert 29 + :size-assert #x4c0 + :flag-assert #x1d045004c0 + (:methods + (pos-logic (_type_ symbol) symbol 27) + (calculate-pos (_type_ symbol) none 28) + ) + (:states + (orb-cache-top-activate symbol) + (orb-cache-top-complete symbol) + ) + ) + + +(defskelgroup *orb-cache-top-sg* orb-cache-top + 0 + 3 + ((1 (meters 20)) (2 (meters 999999))) + :bounds (static-spherem 0 0 0 4) + :longest-edge (meters 0) + ) + +(defstate orb-cache-top-idle (orb-cache-top) + :event + (behavior ((arg0 process) (arg1 int) (arg2 symbol) (arg3 event-message-block)) + (case arg2 + (('eco-blue) + (process-entity-status! self (entity-perm-status complete) #t) + (dotimes (gp-0 5) + (spawn-projectile-blue *target*) + ) + (increment-success-for-hint (game-text-id sidekick-hint-orb-cache-top)) + (go orb-cache-top-activate #f) + ) + (else + (plat-event arg0 arg1 arg2 arg3) + ) + ) + ) + :trans + (behavior () + (if + (and + (and + *target* + (>= + 20480.0 + (vector-vector-distance + (-> self root-override trans) + (-> *target* control trans) + ) + ) + ) + (let ((a1-1 (new 'stack-no-clear 'event-message-block))) + (set! (-> a1-1 from) self) + (set! (-> a1-1 num-params) 2) + (set! (-> a1-1 message) 'query) + (set! (-> a1-1 param 0) (the-as uint 'powerup)) + (set! (-> a1-1 param 1) (the-as uint 3)) + (not (send-event-function *target* a1-1)) + ) + ) + (level-hint-spawn + (game-text-id sidekick-hint-orb-cache-top) + "sksp0009" + (the-as entity #f) + *entity-pool* + (game-task none) + ) + ) + (none) + ) + :code + (behavior ((arg0 symbol)) + (if (and (not arg0) (-> self child)) + (sound-play-by-name + (static-sound-name "close-orb-cash") + (new-sound-id) + 1024 + 0 + 0 + 1 + #t + ) + ) + (dotimes (gp-1 (-> self money)) + (let ((a0-4 (handle->process (-> self money-list gp-1)))) + (if a0-4 + (deactivate a0-4) + ) + ) + ) + (process-entity-status! self (entity-perm-status complete) #f) + (let ((gp-2 (-> self skel root-channel 0))) + (joint-control-channel-group-eval! + gp-2 + (the-as art-joint-anim (-> self draw art-group data 3)) + num-func-identity + ) + (set! (-> gp-2 frame-num) (ja-aframe 0.0 0)) + ) + (transform-post) + (anim-loop) + (none) + ) + ) + +(defmethod dummy-22 orb-cache-top ((obj orb-cache-top)) + (if (< 4096.0 (- (-> obj basetrans y) (-> obj root-pos))) + (activate! (-> obj smush) -1.0 60 150 1.0 1.0) + (activate! (-> obj smush) -0.5 60 150 1.0 1.0) + ) + (set! (-> obj bouncing) #t) + (logclear! (-> obj mask) (process-mask sleep)) + 0 + (none) + ) + +(defmethod calculate-pos orb-cache-top ((obj orb-cache-top) (arg0 symbol)) + (let ((f0-0 0.0)) + (when arg0 + (set! f0-0 (+ 10240.0 (* 6144.0 (the float (+ (-> obj money) -1))))) + (if (< f0-0 2048.0) + (set! f0-0 2048.0) + ) + ) + (set! (-> obj platform-pos) (+ (-> obj root-pos) f0-0)) + (let ((f0-2 (+ -6144.0 f0-0))) + (dotimes (v1-5 (-> obj money)) + (set! (-> obj money-pos-list v1-5) (+ (-> obj root-pos) f0-2)) + (set! f0-2 (+ -6144.0 f0-2)) + ) + ) + ) + 0 + (none) + ) + +(defmethod pos-logic orb-cache-top ((obj orb-cache-top) (arg0 symbol)) + (dotimes (s4-0 (-> obj money)) + (when (not (handle->process (-> obj money-list s4-0))) + (dotimes (v1-6 (-> obj money)) + (when (< s4-0 v1-6) + (set! (-> obj money-list (+ v1-6 -1)) (-> obj money-list v1-6)) + (set! + (-> obj money-pos-actual (+ v1-6 -1)) + (-> obj money-pos-actual v1-6) + ) + ) + ) + (+! (-> obj money) -1) + (calculate-pos obj arg0) + (+! s4-0 -1) + (let ((v1-15 (-> obj entity extra perm))) + (logior! (-> v1-15 status) (entity-perm-status user-set-from-cstage)) + (+! (-> v1-15 user-int16 0) 1) + ) + ) + ) + (let ((s4-1 (new 'stack-no-clear 'vector)) + (s5-1 #t) + ) + (let ((s3-0 #f)) + (let ((f28-0 (- (-> obj basetrans y) (-> obj root-pos))) + (f30-0 (- (-> obj platform-pos) (-> obj root-pos))) + ) + (when (zero? (-> obj money)) + (set! f30-0 2048.0) + (set! s3-0 #t) + ) + (when + (and + (< f30-0 15155.2) + (and + *target* + (>= + 16384.0 + (vector-vector-distance + (-> obj root-override trans) + (-> *target* control trans) + ) + ) + ) + (< (-> (target-pos 0) y) (-> obj basetrans y)) + ) + (set! f30-0 (if (< 14131.2 f28-0) + 15155.2 + f28-0 + ) + ) + (set! s3-0 #f) + ) + (set! + (-> obj basetrans y) + (seek + (-> obj basetrans y) + (+ (-> obj root-pos) f30-0) + (* 40960.0 (-> *display* seconds-per-frame)) + ) + ) + (if (not (= (-> obj basetrans y) (+ (-> obj root-pos) f30-0))) + (set! s5-1 #f) + ) + ) + (dotimes (s2-0 (-> obj money)) + (set! + (-> s4-1 quad) + (-> + (the-as process-drawable (handle->process (-> obj money-list s2-0))) + root + trans + quad + ) + ) + (set! + (-> obj money-pos-actual s2-0) + (seek + (-> obj money-pos-actual s2-0) + (-> obj money-pos-list s2-0) + (* 40960.0 (-> *display* seconds-per-frame)) + ) + ) + (if (not (= (-> obj money-pos-actual s2-0) (-> obj money-pos-list s2-0))) + (set! s5-1 #f) + ) + (if (>= (-> obj money-pos-actual s2-0) (+ -8192.0 (-> obj root-pos))) + (set! (-> s4-1 y) (-> obj money-pos-actual s2-0)) + (set! (-> s4-1 y) (+ -8192.0 (-> obj root-pos))) + ) + (send-event (handle->process (-> obj money-list s2-0)) 'trans s4-1) + ) + (set! s3-0 (and s5-1 s3-0)) + (if s3-0 + (go orb-cache-top-complete #f) + ) + ) + s5-1 + ) + ) + +(defstate orb-cache-top-activate (orb-cache-top) + :event + (the-as + (function process int symbol event-message-block object :behavior orb-cache-top) + plat-event + ) + :exit + (behavior () + (process-entity-status! self (entity-perm-status bit-3) #f) + (none) + ) + :trans + (the-as (function none :behavior orb-cache-top) plat-trans) + :code + (behavior ((arg0 symbol)) + (process-entity-status! self (entity-perm-status bit-3) #t) + (calculate-pos self arg0) + (if arg0 + (set! (-> self basetrans y) (-> self platform-pos)) + (sound-play-by-name + (static-sound-name "open-orb-cash") + (new-sound-id) + 1024 + 0 + 0 + 1 + #t + ) + ) + (dotimes (s5-1 (-> self money)) + (let ((s4-1 (new 'stack-no-clear 'vector))) + (set! (-> s4-1 quad) (-> self basetrans quad)) + (set! (-> s4-1 y) (-> self money-pos-list s5-1)) + (set! (-> self money-pos-actual s5-1) (-> s4-1 y)) + (let ((s3-0 (get-process *default-dead-pool* money #x4000))) + (set! (-> self money-list s5-1) (ppointer->handle (when s3-0 + (let + ((t9-5 + (method-of-type + money + activate + ) + ) + ) + (t9-5 + (the-as money s3-0) + self + 'money + (the-as + pointer + #x70004000 + ) + ) + ) + (run-now-in-process + s3-0 + money-init-by-other-no-bob + s4-1 + *null-vector* + 5 + 1.0 + (-> self entity) + ) + (-> s3-0 ppointer) + ) + ) + ) + ) + ) + ) + (while #t + (calculate-pos self #t) + (while + (not + (or + (not *target*) + (< + (-> self inactive-distance) + (vector-vector-xz-distance + (-> self root-override trans) + (-> *target* control trans) + ) + ) + ) + ) + (pos-logic self #t) + (suspend) + ) + (calculate-pos self #f) + (while + (and + (not + (and + (and + *target* + (>= + (-> self active-distance) + (vector-vector-xz-distance + (-> self root-override trans) + (-> *target* control trans) + ) + ) + ) + (let ((a1-11 (new 'stack-no-clear 'event-message-block))) + (set! (-> a1-11 from) self) + (set! (-> a1-11 num-params) 2) + (set! (-> a1-11 message) 'query) + (set! (-> a1-11 param 0) (the-as uint 'powerup)) + (set! (-> a1-11 param 1) (the-as uint 3)) + (or (send-event-function *target* a1-11) (-> self activated)) + ) + ) + ) + (not (pos-logic self #f)) + ) + (suspend) + ) + (if + (not + (and + (and + *target* + (>= + (-> self active-distance) + (vector-vector-xz-distance + (-> self root-override trans) + (-> *target* control trans) + ) + ) + ) + (let ((a1-14 (new 'stack-no-clear 'event-message-block))) + (set! (-> a1-14 from) self) + (set! (-> a1-14 num-params) 2) + (set! (-> a1-14 message) 'query) + (set! (-> a1-14 param 0) (the-as uint 'powerup)) + (set! (-> a1-14 param 1) (the-as uint 3)) + (or (send-event-function *target* a1-14) (-> self activated)) + ) + ) + ) + (go orb-cache-top-idle arg0) + ) + ) + (none) + ) + :post + (the-as (function none :behavior orb-cache-top) plat-post) + ) + +(defstate orb-cache-top-complete (orb-cache-top) + :event + (the-as + (function process int symbol event-message-block object :behavior orb-cache-top) + plat-event + ) + :trans + (the-as (function none :behavior orb-cache-top) plat-trans) + :code + (behavior ((arg0 symbol)) + (if (not arg0) + (sound-play-by-name + (static-sound-name "close-orb-cash") + (new-sound-id) + 1024 + 0 + 0 + 1 + #t + ) + ) + (let ((gp-1 (-> self skel root-channel 0))) + (joint-control-channel-group-eval! + gp-1 + (the-as art-joint-anim (-> self draw art-group data 3)) + num-func-identity + ) + (set! (-> gp-1 frame-num) (ja-aframe 0.0 0)) + ) + (new 'stack-no-clear 'vector) + (set! (-> self basetrans y) (+ 2048.0 (-> self root-pos))) + (anim-loop) + (none) + ) + :post + (the-as (function none :behavior orb-cache-top) plat-post) + ) + +(defmethod copy-defaults! orb-cache-top ((obj orb-cache-top) (arg0 res-lump)) + (let ((a0-1 (-> obj entity))) + (if (when a0-1 + (let ((a0-2 (-> a0-1 extra perm task))) + (if a0-2 + (= a0-2 (game-task none)) + ) + ) + ) + (set! (-> obj entity extra perm task) (game-task complete)) + ) + ) + (let + ((s4-0 + (new 'process 'collide-shape-moving obj (collide-list-enum hit-by-player)) + ) + ) + (set! (-> s4-0 dynam) (copy *standard-dynamics* 'process)) + (set! (-> s4-0 reaction) default-collision-reaction) + (set! (-> s4-0 no-reaction) nothing) + (dummy-29 s4-0 1) + (let + ((s3-0 + (new + 'process + 'collide-shape-prim-mesh + s4-0 + (the-as uint 0) + (the-as uint 0) + ) + ) + ) + (set! (-> s3-0 prim-core collide-as) (the-as uint #x8800)) + (set! (-> s3-0 collide-with) (the-as uint 16)) + (set! (-> s3-0 prim-core action) (the-as uint 3)) + (set! (-> s3-0 prim-core offense) 4) + (set! (-> s3-0 transform-index) 0) + (set-vector! (-> s3-0 local-sphere) 0.0 0.0 0.0 11468.8) + ) + (dummy-46 s4-0) + (set! (-> s4-0 nav-radius) (* 0.75 (-> s4-0 root-prim local-sphere w))) + (dummy-50 s4-0) + (set! (-> obj root-override) s4-0) + ) + (process-drawable-from-entity! obj arg0) + (logclear! (-> obj mask) (process-mask actor-pause)) + (initialize-skeleton obj *orb-cache-top-sg* '()) + (logior! (-> obj skel status) 1) + (dummy-47 (-> obj root-override)) + (dummy-21 obj) + (set! + (-> obj money) + (res-lump-value + (-> obj entity) + 'orb-cache-count + int + :default + (the-as uint128 20) + ) + ) + (set! (-> obj active-distance) 61440.0) + (set! (-> obj inactive-distance) 245760.0) + (set! (-> obj root-pos) (-> obj basetrans y)) + (set! (-> obj platform-pos) (-> obj root-pos)) + (set! + (-> obj activated) + (the-as + symbol + (and + (-> obj entity) + (logtest? (-> obj entity extra perm status) (entity-perm-status complete)) + ) + ) + ) + (let ((v1-39 (-> obj entity extra perm))) + (logior! (-> v1-39 status) (entity-perm-status user-set-from-cstage)) + (set! (-> obj money) (- (-> obj money) (-> v1-39 user-int16 0))) + ) + (dotimes (v1-42 (-> obj money)) + (set! (-> obj money-list v1-42) (the-as handle #f)) + ) + (cond + ((zero? (-> obj money)) + (go orb-cache-top-complete #t) + ) + ((and + (-> obj entity) + (logtest? (-> obj entity extra perm status) (entity-perm-status complete)) + ) + (go orb-cache-top-activate #t) + ) + (else + (go orb-cache-top-idle #f) + ) + ) + (none) + ) + + + + diff --git a/test/decompiler/reference/engine/anim/joint_REF.gc b/test/decompiler/reference/engine/anim/joint_REF.gc index 33f3c7339f..8c101d1b3e 100644 --- a/test/decompiler/reference/engine/anim/joint_REF.gc +++ b/test/decompiler/reference/engine/anim/joint_REF.gc @@ -325,7 +325,7 @@ ;; definition for method 9 of type art (defmethod login art ((obj art)) (if (and (-> obj extra) (zero? (-> obj extra tag))) - (set! (-> obj extra tag) (the-as (pointer res-tag) (-> obj extra trans))) + (set! (-> obj extra tag) (&+ (the-as (pointer res-tag) (-> obj extra)) 28)) ) obj ) @@ -697,7 +697,7 @@ ;; definition for method 9 of type art-joint-anim (defmethod login art-joint-anim ((obj art-joint-anim)) (if (and (-> obj extra) (zero? (-> obj extra tag))) - (set! (-> obj extra tag) (the-as (pointer res-tag) (-> obj extra trans))) + (set! (-> obj extra tag) (&+ (the-as (pointer res-tag) (-> obj extra)) 28)) ) obj ) @@ -1923,7 +1923,3 @@ (calc-animation-from-spr arg0 arg1) 0 ) - - - - diff --git a/test/decompiler/reference/engine/collide/collide-mesh-h_REF.gc b/test/decompiler/reference/engine/collide/collide-mesh-h_REF.gc index e75c44497b..b7ec11e73f 100644 --- a/test/decompiler/reference/engine/collide/collide-mesh-h_REF.gc +++ b/test/decompiler/reference/engine/collide/collide-mesh-h_REF.gc @@ -46,11 +46,11 @@ ;; definition of type collide-mesh (deftype collide-mesh (basic) - ((joint-id int32 :offset-assert 4) - (num-tris uint32 :offset-assert 8) - (num-verts uint32 :offset-assert 12) - (vertex-data uint32 :offset-assert 16) - (tris collide-mesh-tri 1 :inline :offset 32) + ((joint-id int32 :offset-assert 4) + (num-tris uint32 :offset-assert 8) + (num-verts uint32 :offset-assert 12) + (vertex-data (inline-array vector) :offset-assert 16) + (tris collide-mesh-tri 1 :inline :offset 32) ) :method-count-assert 16 :size-assert #x28 diff --git a/test/decompiler/reference/engine/data/art-h_REF.gc b/test/decompiler/reference/engine/data/art-h_REF.gc index 726d94f312..89fcb6d09f 100644 --- a/test/decompiler/reference/engine/data/art-h_REF.gc +++ b/test/decompiler/reference/engine/data/art-h_REF.gc @@ -221,9 +221,9 @@ ;; definition of type art (deftype art (basic) - ((name string :offset 8) - (length int32 :offset-assert 12) - (extra entity :offset-assert 16) + ((name string :offset 8) + (length int32 :offset-assert 12) + (extra res-lump :offset-assert 16) ) :method-count-assert 13 :size-assert #x14 diff --git a/test/decompiler/reference/engine/draw/process-drawable_REF.gc b/test/decompiler/reference/engine/draw/process-drawable_REF.gc index 3329e2ff4f..f9d5766251 100644 --- a/test/decompiler/reference/engine/draw/process-drawable_REF.gc +++ b/test/decompiler/reference/engine/draw/process-drawable_REF.gc @@ -732,7 +732,7 @@ (-> (the-as vector - ((method-of-type res-lump get-property-struct) + (get-property-struct (-> sv-16 extra) 'trans-offset 'interp @@ -1480,7 +1480,3 @@ s5-0 ) ) - - - - diff --git a/test/decompiler/reference/engine/game/effect-control_REF.gc b/test/decompiler/reference/engine/game/effect-control_REF.gc index 66edc17f63..213a8b78a0 100644 --- a/test/decompiler/reference/engine/game/effect-control_REF.gc +++ b/test/decompiler/reference/engine/game/effect-control_REF.gc @@ -153,12 +153,7 @@ (let ((v1-6 (-> - ((method-of-type res-lump lookup-tag-idx) - (-> s5-0 extra) - 'effect-name - 'base - -1000000000.0 - ) + (lookup-tag-idx (-> s5-0 extra) 'effect-name 'base -1000000000.0) lo ) ) diff --git a/test/decompiler/reference/levels/common/orb-cache_REF.gc b/test/decompiler/reference/levels/common/orb-cache_REF.gc new file mode 100644 index 0000000000..91be56dcfb --- /dev/null +++ b/test/decompiler/reference/levels/common/orb-cache_REF.gc @@ -0,0 +1,568 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition of type orb-cache-top +(deftype orb-cache-top (baseplat) + ((active-distance float :offset-assert 228) + (inactive-distance float :offset-assert 232) + (money-list handle 60 :offset-assert 240) + (money-pos-list float 60 :offset-assert 720) + (money-pos-actual float 60 :offset-assert 960) + (platform-pos float :offset-assert 1200) + (root-pos float :offset-assert 1204) + (money int32 :offset-assert 1208) + (activated symbol :offset-assert 1212) + ) + :heap-base #x450 + :method-count-assert 29 + :size-assert #x4c0 + :flag-assert #x1d045004c0 + (:methods + (pos-logic (_type_ symbol) symbol 27) + (calculate-pos (_type_ symbol) none 28) + ) + (:states + (orb-cache-top-activate symbol) + (orb-cache-top-complete symbol) + ) + ) + +;; definition for method 3 of type orb-cache-top +(defmethod inspect orb-cache-top ((obj orb-cache-top)) + (let ((t9-0 (method-of-type baseplat inspect))) + (t9-0 obj) + ) + (format #t "~T~Tactive-distance: ~f~%" (-> obj active-distance)) + (format #t "~T~Tinactive-distance: ~f~%" (-> obj inactive-distance)) + (format #t "~T~Tmoney-list[60] @ #x~X~%" (-> obj money-list)) + (format #t "~T~Tmoney-pos-list[60] @ #x~X~%" (-> obj money-pos-list)) + (format #t "~T~Tmoney-pos-actual[60] @ #x~X~%" (-> obj money-pos-actual)) + (format #t "~T~Tplatform-pos: ~f~%" (-> obj platform-pos)) + (format #t "~T~Troot-pos: ~f~%" (-> obj root-pos)) + (format #t "~T~Tmoney: ~D~%" (-> obj money)) + (format #t "~T~Tactivated: ~A~%" (-> obj activated)) + obj + ) + +;; failed to figure out what this is: +(defskelgroup *orb-cache-top-sg* orb-cache-top + 0 + 3 + ((1 (meters 20)) (2 (meters 999999))) + :bounds (static-spherem 0 0 0 4) + :longest-edge (meters 0) + ) + +;; failed to figure out what this is: +(defstate orb-cache-top-idle (orb-cache-top) + :event + (behavior ((arg0 process) (arg1 int) (arg2 symbol) (arg3 event-message-block)) + (case arg2 + (('eco-blue) + (process-entity-status! self (entity-perm-status complete) #t) + (dotimes (gp-0 5) + (spawn-projectile-blue *target*) + ) + (increment-success-for-hint (game-text-id sidekick-hint-orb-cache-top)) + (go orb-cache-top-activate #f) + ) + (else + (plat-event arg0 arg1 arg2 arg3) + ) + ) + ) + :trans + (behavior () + (if + (and + (and + *target* + (>= + 20480.0 + (vector-vector-distance + (-> self root-override trans) + (-> *target* control trans) + ) + ) + ) + (let ((a1-1 (new 'stack-no-clear 'event-message-block))) + (set! (-> a1-1 from) self) + (set! (-> a1-1 num-params) 2) + (set! (-> a1-1 message) 'query) + (set! (-> a1-1 param 0) (the-as uint 'powerup)) + (set! (-> a1-1 param 1) (the-as uint 3)) + (not (send-event-function *target* a1-1)) + ) + ) + (level-hint-spawn + (game-text-id sidekick-hint-orb-cache-top) + "sksp0009" + (the-as entity #f) + *entity-pool* + (game-task none) + ) + ) + (none) + ) + :code + (behavior ((arg0 symbol)) + (if (and (not arg0) (-> self child)) + (sound-play-by-name + (static-sound-name "close-orb-cash") + (new-sound-id) + 1024 + 0 + 0 + 1 + #t + ) + ) + (dotimes (gp-1 (-> self money)) + (let ((a0-4 (handle->process (-> self money-list gp-1)))) + (if a0-4 + (deactivate a0-4) + ) + ) + ) + (process-entity-status! self (entity-perm-status complete) #f) + (let ((gp-2 (-> self skel root-channel 0))) + (joint-control-channel-group-eval! + gp-2 + (the-as art-joint-anim (-> self draw art-group data 3)) + num-func-identity + ) + (set! (-> gp-2 frame-num) (ja-aframe 0.0 0)) + ) + (transform-post) + (anim-loop) + (none) + ) + ) + +;; definition for method 22 of type orb-cache-top +;; INFO: Return type mismatch int vs none. +(defmethod dummy-22 orb-cache-top ((obj orb-cache-top)) + (if (< 4096.0 (- (-> obj basetrans y) (-> obj root-pos))) + (activate! (-> obj smush) -1.0 60 150 1.0 1.0) + (activate! (-> obj smush) -0.5 60 150 1.0 1.0) + ) + (set! (-> obj bouncing) #t) + (logclear! (-> obj mask) (process-mask sleep)) + 0 + (none) + ) + +;; definition for method 28 of type orb-cache-top +;; INFO: Return type mismatch int vs none. +(defmethod calculate-pos orb-cache-top ((obj orb-cache-top) (arg0 symbol)) + (let ((f0-0 0.0)) + (when arg0 + (set! f0-0 (+ 10240.0 (* 6144.0 (the float (+ (-> obj money) -1))))) + (if (< f0-0 2048.0) + (set! f0-0 2048.0) + ) + ) + (set! (-> obj platform-pos) (+ (-> obj root-pos) f0-0)) + (let ((f0-2 (+ -6144.0 f0-0))) + (dotimes (v1-5 (-> obj money)) + (set! (-> obj money-pos-list v1-5) (+ (-> obj root-pos) f0-2)) + (set! f0-2 (+ -6144.0 f0-2)) + ) + ) + ) + 0 + (none) + ) + +;; definition for method 27 of type orb-cache-top +;; Used lq/sq +(defmethod pos-logic orb-cache-top ((obj orb-cache-top) (arg0 symbol)) + (dotimes (s4-0 (-> obj money)) + (when (not (handle->process (-> obj money-list s4-0))) + (dotimes (v1-6 (-> obj money)) + (when (< s4-0 v1-6) + (set! (-> obj money-list (+ v1-6 -1)) (-> obj money-list v1-6)) + (set! + (-> obj money-pos-actual (+ v1-6 -1)) + (-> obj money-pos-actual v1-6) + ) + ) + ) + (+! (-> obj money) -1) + (calculate-pos obj arg0) + (+! s4-0 -1) + (let ((v1-15 (-> obj entity extra perm))) + (logior! (-> v1-15 status) (entity-perm-status user-set-from-cstage)) + (+! (-> v1-15 user-int16 0) 1) + ) + ) + ) + (let ((s4-1 (new 'stack-no-clear 'vector)) + (s5-1 #t) + ) + (let ((s3-0 #f)) + (let ((f28-0 (- (-> obj basetrans y) (-> obj root-pos))) + (f30-0 (- (-> obj platform-pos) (-> obj root-pos))) + ) + (when (zero? (-> obj money)) + (set! f30-0 2048.0) + (set! s3-0 #t) + ) + (when + (and + (< f30-0 15155.2) + (and + *target* + (>= + 16384.0 + (vector-vector-distance + (-> obj root-override trans) + (-> *target* control trans) + ) + ) + ) + (< (-> (target-pos 0) y) (-> obj basetrans y)) + ) + (set! f30-0 (if (< 14131.2 f28-0) + 15155.2 + f28-0 + ) + ) + (set! s3-0 #f) + ) + (set! + (-> obj basetrans y) + (seek + (-> obj basetrans y) + (+ (-> obj root-pos) f30-0) + (* 40960.0 (-> *display* seconds-per-frame)) + ) + ) + (if (not (= (-> obj basetrans y) (+ (-> obj root-pos) f30-0))) + (set! s5-1 #f) + ) + ) + (dotimes (s2-0 (-> obj money)) + (set! + (-> s4-1 quad) + (-> + (the-as process-drawable (handle->process (-> obj money-list s2-0))) + root + trans + quad + ) + ) + (set! + (-> obj money-pos-actual s2-0) + (seek + (-> obj money-pos-actual s2-0) + (-> obj money-pos-list s2-0) + (* 40960.0 (-> *display* seconds-per-frame)) + ) + ) + (if (not (= (-> obj money-pos-actual s2-0) (-> obj money-pos-list s2-0))) + (set! s5-1 #f) + ) + (if (>= (-> obj money-pos-actual s2-0) (+ -8192.0 (-> obj root-pos))) + (set! (-> s4-1 y) (-> obj money-pos-actual s2-0)) + (set! (-> s4-1 y) (+ -8192.0 (-> obj root-pos))) + ) + (send-event (handle->process (-> obj money-list s2-0)) 'trans s4-1) + ) + (set! s3-0 (and s5-1 s3-0)) + (if s3-0 + (go orb-cache-top-complete #f) + ) + ) + s5-1 + ) + ) + +;; failed to figure out what this is: +(defstate orb-cache-top-activate (orb-cache-top) + :event + (the-as + (function process int symbol event-message-block object :behavior orb-cache-top) + plat-event + ) + :exit + (behavior () + (process-entity-status! self (entity-perm-status bit-3) #f) + (none) + ) + :trans + (the-as (function none :behavior orb-cache-top) plat-trans) + :code + (behavior ((arg0 symbol)) + (process-entity-status! self (entity-perm-status bit-3) #t) + (calculate-pos self arg0) + (if arg0 + (set! (-> self basetrans y) (-> self platform-pos)) + (sound-play-by-name + (static-sound-name "open-orb-cash") + (new-sound-id) + 1024 + 0 + 0 + 1 + #t + ) + ) + (dotimes (s5-1 (-> self money)) + (let ((s4-1 (new 'stack-no-clear 'vector))) + (set! (-> s4-1 quad) (-> self basetrans quad)) + (set! (-> s4-1 y) (-> self money-pos-list s5-1)) + (set! (-> self money-pos-actual s5-1) (-> s4-1 y)) + (let ((s3-0 (get-process *default-dead-pool* money #x4000))) + (set! (-> self money-list s5-1) (ppointer->handle (when s3-0 + (let + ((t9-5 + (method-of-type + money + activate + ) + ) + ) + (t9-5 + (the-as money s3-0) + self + 'money + (the-as + pointer + #x70004000 + ) + ) + ) + (run-now-in-process + s3-0 + money-init-by-other-no-bob + s4-1 + *null-vector* + 5 + 1.0 + (-> self entity) + ) + (-> s3-0 ppointer) + ) + ) + ) + ) + ) + ) + (while #t + (calculate-pos self #t) + (while + (not + (or + (not *target*) + (< + (-> self inactive-distance) + (vector-vector-xz-distance + (-> self root-override trans) + (-> *target* control trans) + ) + ) + ) + ) + (pos-logic self #t) + (suspend) + ) + (calculate-pos self #f) + (while + (and + (not + (and + (and + *target* + (>= + (-> self active-distance) + (vector-vector-xz-distance + (-> self root-override trans) + (-> *target* control trans) + ) + ) + ) + (let ((a1-11 (new 'stack-no-clear 'event-message-block))) + (set! (-> a1-11 from) self) + (set! (-> a1-11 num-params) 2) + (set! (-> a1-11 message) 'query) + (set! (-> a1-11 param 0) (the-as uint 'powerup)) + (set! (-> a1-11 param 1) (the-as uint 3)) + (or (send-event-function *target* a1-11) (-> self activated)) + ) + ) + ) + (not (pos-logic self #f)) + ) + (suspend) + ) + (if + (not + (and + (and + *target* + (>= + (-> self active-distance) + (vector-vector-xz-distance + (-> self root-override trans) + (-> *target* control trans) + ) + ) + ) + (let ((a1-14 (new 'stack-no-clear 'event-message-block))) + (set! (-> a1-14 from) self) + (set! (-> a1-14 num-params) 2) + (set! (-> a1-14 message) 'query) + (set! (-> a1-14 param 0) (the-as uint 'powerup)) + (set! (-> a1-14 param 1) (the-as uint 3)) + (or (send-event-function *target* a1-14) (-> self activated)) + ) + ) + ) + (go orb-cache-top-idle arg0) + ) + ) + (none) + ) + :post + (the-as (function none :behavior orb-cache-top) plat-post) + ) + +;; failed to figure out what this is: +(defstate orb-cache-top-complete (orb-cache-top) + :event + (the-as + (function process int symbol event-message-block object :behavior orb-cache-top) + plat-event + ) + :trans + (the-as (function none :behavior orb-cache-top) plat-trans) + :code + (behavior ((arg0 symbol)) + (if (not arg0) + (sound-play-by-name + (static-sound-name "close-orb-cash") + (new-sound-id) + 1024 + 0 + 0 + 1 + #t + ) + ) + (let ((gp-1 (-> self skel root-channel 0))) + (joint-control-channel-group-eval! + gp-1 + (the-as art-joint-anim (-> self draw art-group data 3)) + num-func-identity + ) + (set! (-> gp-1 frame-num) (ja-aframe 0.0 0)) + ) + (new 'stack-no-clear 'vector) + (set! (-> self basetrans y) (+ 2048.0 (-> self root-pos))) + (anim-loop) + (none) + ) + :post + (the-as (function none :behavior orb-cache-top) plat-post) + ) + +;; definition for method 11 of type orb-cache-top +;; INFO: Return type mismatch object vs none. +(defmethod copy-defaults! orb-cache-top ((obj orb-cache-top) (arg0 res-lump)) + (let ((a0-1 (-> obj entity))) + (if (when a0-1 + (let ((a0-2 (-> a0-1 extra perm task))) + (if a0-2 + (= a0-2 (game-task none)) + ) + ) + ) + (set! (-> obj entity extra perm task) (game-task complete)) + ) + ) + (let + ((s4-0 + (new 'process 'collide-shape-moving obj (collide-list-enum hit-by-player)) + ) + ) + (set! (-> s4-0 dynam) (copy *standard-dynamics* 'process)) + (set! (-> s4-0 reaction) default-collision-reaction) + (set! (-> s4-0 no-reaction) nothing) + (dummy-29 s4-0 1) + (let + ((s3-0 + (new + 'process + 'collide-shape-prim-mesh + s4-0 + (the-as uint 0) + (the-as uint 0) + ) + ) + ) + (set! (-> s3-0 prim-core collide-as) (the-as uint #x8800)) + (set! (-> s3-0 collide-with) (the-as uint 16)) + (set! (-> s3-0 prim-core action) (the-as uint 3)) + (set! (-> s3-0 prim-core offense) 4) + (set! (-> s3-0 transform-index) 0) + (set-vector! (-> s3-0 local-sphere) 0.0 0.0 0.0 11468.8) + ) + (dummy-46 s4-0) + (set! (-> s4-0 nav-radius) (* 0.75 (-> s4-0 root-prim local-sphere w))) + (dummy-50 s4-0) + (set! (-> obj root-override) s4-0) + ) + (process-drawable-from-entity! obj arg0) + (logclear! (-> obj mask) (process-mask actor-pause)) + (initialize-skeleton obj *orb-cache-top-sg* '()) + (logior! (-> obj skel status) 1) + (dummy-47 (-> obj root-override)) + (dummy-21 obj) + (set! + (-> obj money) + (res-lump-value + (-> obj entity) + 'orb-cache-count + int + :default + (the-as uint128 20) + ) + ) + (set! (-> obj active-distance) 61440.0) + (set! (-> obj inactive-distance) 245760.0) + (set! (-> obj root-pos) (-> obj basetrans y)) + (set! (-> obj platform-pos) (-> obj root-pos)) + (set! + (-> obj activated) + (the-as + symbol + (and + (-> obj entity) + (logtest? (-> obj entity extra perm status) (entity-perm-status complete)) + ) + ) + ) + (let ((v1-39 (-> obj entity extra perm))) + (logior! (-> v1-39 status) (entity-perm-status user-set-from-cstage)) + (set! (-> obj money) (- (-> obj money) (-> v1-39 user-int16 0))) + ) + (dotimes (v1-42 (-> obj money)) + (set! (-> obj money-list v1-42) (the-as handle #f)) + ) + (cond + ((zero? (-> obj money)) + (go orb-cache-top-complete #t) + ) + ((and + (-> obj entity) + (logtest? (-> obj entity extra perm status) (entity-perm-status complete)) + ) + (go orb-cache-top-activate #t) + ) + (else + (go orb-cache-top-idle #f) + ) + ) + (none) + )