diff --git a/decompiler/IR2/FormExpressionAnalysis.cpp b/decompiler/IR2/FormExpressionAnalysis.cpp index 7d737c4bf4..21c23b1b38 100644 --- a/decompiler/IR2/FormExpressionAnalysis.cpp +++ b/decompiler/IR2/FormExpressionAnalysis.cpp @@ -2419,20 +2419,26 @@ void SetFormFormElement::push_to_stack(const Env& env, FormPool& pool, FormStack } } - const static std::pair in_place_ops[] = { - {FixedOperatorKind::ADDITION, FixedOperatorKind::ADDITION_IN_PLACE}, - {FixedOperatorKind::ADDITION_PTR, FixedOperatorKind::ADDITION_PTR_IN_PLACE}, - {FixedOperatorKind::LOGAND, FixedOperatorKind::LOGAND_IN_PLACE}, - {FixedOperatorKind::LOGIOR, FixedOperatorKind::LOGIOR_IN_PLACE}, - {FixedOperatorKind::LOGCLEAR, FixedOperatorKind::LOGCLEAR_IN_PLACE}}; + typedef struct { + FixedOperatorKind kind; + FixedOperatorKind inplace_kind; + int inplace_arg; + } InplaceOpInfo; + + const static InplaceOpInfo in_place_ops[] = { + {FixedOperatorKind::ADDITION, FixedOperatorKind::ADDITION_IN_PLACE, 0}, + {FixedOperatorKind::ADDITION_PTR, FixedOperatorKind::ADDITION_PTR_IN_PLACE, 0}, + {FixedOperatorKind::LOGAND, FixedOperatorKind::LOGAND_IN_PLACE, 0}, + {FixedOperatorKind::LOGIOR, FixedOperatorKind::LOGIOR_IN_PLACE, 0}, + {FixedOperatorKind::LOGCLEAR, FixedOperatorKind::LOGCLEAR_IN_PLACE, 0}}; typedef struct { std::string orig_name; - int inplace_arg; std::string inplace_name; + int inplace_arg; } InplaceCallInfo; - const static InplaceCallInfo in_place_calls[] = {{"seek", 0, "seek!"}, {"seekl", 0, "seekl!"}}; + const static InplaceCallInfo in_place_calls[] = {{"seek", "seek!", 0}, {"seekl", "seekl!", 0}}; auto src_as_generic = m_src->try_as_element(); if (src_as_generic) { @@ -2446,35 +2452,37 @@ void SetFormFormElement::push_to_stack(const Env& env, FormPool& pool, FormStack auto src_form_in_func = src_as_generic->elts().at(call_info.inplace_arg)->to_form(env); if (dst_form == src_form_in_func) { - const auto& inplace_name = call_info.inplace_name; + auto new_func_op = GenericOperator::make_function( + pool.alloc_single_element_form(nullptr, + call_info.inplace_name)); GenericElement* inplace_call = nullptr; if (funcname == "seek" || funcname == "seekl") { inplace_call = pool.alloc_single_element_form( - nullptr, - GenericOperator::make_function( - pool.alloc_single_element_form( - nullptr, inplace_name)), + nullptr, new_func_op, std::vector{m_dst, src_as_generic->elts().at(1), src_as_generic->elts().at(2)}) ->try_as_element(); } - if (inplace_call) { - stack.push_form_element(inplace_call, true); - return; - } + ASSERT_MSG( + inplace_call, + fmt::format( + "Somehow, no appropriate inplace call was generated for (set! {}) -> {}", + call_info.orig_name, call_info.inplace_name)); + stack.push_form_element(inplace_call, true); + return; } } } } } else { - for (auto& op_pair : in_place_ops) { - if (src_as_generic->op().is_fixed(op_pair.first)) { + for (const auto& op_info : in_place_ops) { + if (src_as_generic->op().is_fixed(op_info.kind)) { auto dst_form = m_dst->to_form(env); - auto add_form_0 = src_as_generic->elts().at(0)->to_form(env); + auto add_form_0 = src_as_generic->elts().at(op_info.inplace_arg)->to_form(env); if (dst_form == add_form_0) { - src_as_generic->op() = GenericOperator::make_fixed(op_pair.second); + src_as_generic->op() = GenericOperator::make_fixed(op_info.inplace_kind); stack.push_form_element(src_as_generic, true); return; } diff --git a/decompiler/analysis/insert_lets.cpp b/decompiler/analysis/insert_lets.cpp index 0f6d583966..3a043fef13 100644 --- a/decompiler/analysis/insert_lets.cpp +++ b/decompiler/analysis/insert_lets.cpp @@ -200,6 +200,7 @@ FormElement* rewrite_as_send_event(LetElement* in, const Env& env, FormPool& poo //////////////////////////////////////////////////////// // (set! (-> block-var from) ) + bool not_proc = false; Matcher set_from_matcher = Matcher::set(Matcher::deref(Matcher::any_reg(0), false, {DerefTokenMatcher::string("from")}), Matcher::any_reg(1)); @@ -207,8 +208,15 @@ FormElement* rewrite_as_send_event(LetElement* in, const Env& env, FormPool& poo set_from_hack_body.elts().push_back(body->at(0)); auto from_mr = match(set_from_matcher, &set_from_hack_body); if (!from_mr.matched) { - // fmt::print(" fail: from1\n"); - return nullptr; + // initial matcher failed. try more advanced "from" matcher now. + Matcher set_from_form_matcher = Matcher::set( + Matcher::deref(Matcher::any_reg(0), false, {DerefTokenMatcher::string("from")}), + Matcher::any(1)); + from_mr = match(set_from_form_matcher, &set_from_hack_body); + if (!from_mr.matched) { + return nullptr; + } + not_proc = true; } if (env.get_variable_name(*from_mr.maps.regs.at(0)) != block_var_name) { @@ -216,10 +224,13 @@ FormElement* rewrite_as_send_event(LetElement* in, const Env& env, FormPool& poo return nullptr; } - auto from_var = *from_mr.maps.regs.at(1); - if (from_var.reg() != Register(Reg::GPR, Reg::S6)) { - // fmt::print(" fail: from3\n"); - return nullptr; + // if we couldnt match with simple reg matching that means it's a more complex form. + if (!not_proc) { + auto from_var = *from_mr.maps.regs.at(1); + if (from_var.reg() != Register(Reg::GPR, Reg::S6)) { + // it's OK to not be the s6 register, just means we have to manually specify it later. + not_proc = true; + } } //////////////////////////////////////////////////////// @@ -314,6 +325,18 @@ FormElement* rewrite_as_send_event(LetElement* in, const Env& env, FormPool& poo // time to build the macro! std::vector macro_args = {send_destination, message_name}; + if (not_proc) { + // something was going on with from. build :from key. + macro_args.push_back(pool.form(":from")); + // fill in the value for it + if (from_mr.maps.forms.find(1) != from_mr.maps.forms.end()) { + // matched some form. we can just copy it. + macro_args.push_back(from_mr.maps.forms.at(1)); + } else { + // matched reg but it wasnt s6 + macro_args.push_back(alloc_var_form(*from_mr.maps.regs.at(1), pool)); + } + } for (int i = 0; i < param_count; i++) { macro_args.push_back(param_values.at(i)); } diff --git a/decompiler/config/all-types.gc b/decompiler/config/all-types.gc index f26d98d8a7..611a26134d 100644 --- a/decompiler/config/all-types.gc +++ b/decompiler/config/all-types.gc @@ -11579,8 +11579,8 @@ (nav-flags nav-flags :offset-assert 145) (pad-byte uint8 2 :offset-assert 146) (pat-ignore-mask pat-surface :offset-assert 148) - (event-self basic :offset-assert 152) - (event-other basic :offset-assert 156) + (event-self symbol :offset-assert 152) + (event-other symbol :offset-assert 156) (root-prim collide-shape-prim :offset-assert 160) ;; i think this can be any subtype of collide-shape-prim as well! (riders collide-sticky-rider-group :offset-assert 164) (backup-collide-as collide-kind :offset-assert 168) diff --git a/decompiler/config/jak1_ntsc_black_label/type_casts.jsonc b/decompiler/config/jak1_ntsc_black_label/type_casts.jsonc index c88f2bc0bf..4df68ea367 100644 --- a/decompiler/config/jak1_ntsc_black_label/type_casts.jsonc +++ b/decompiler/config/jak1_ntsc_black_label/type_casts.jsonc @@ -5241,9 +5241,8 @@ ], "(method 12 touching-list)": [ - [4, "gp", "touching-shapes-entry"], - [6, "gp", "touching-shapes-entry"], - [67, "gp", "touching-shapes-entry"] + [[4, 67], "gp", "touching-shapes-entry"], + [67, "gp", "(inline-array touching-shapes-entry)"] ], "(method 35 collide-shape)": [ diff --git a/decompiler/config/jak1_ntsc_black_label/var_names.jsonc b/decompiler/config/jak1_ntsc_black_label/var_names.jsonc index efd68a5e95..3575d78cc3 100644 --- a/decompiler/config/jak1_ntsc_black_label/var_names.jsonc +++ b/decompiler/config/jak1_ntsc_black_label/var_names.jsonc @@ -4034,5 +4034,14 @@ } }, + "(method 12 touching-list)": { + "vars": { + "gp-0": ["entry", "touching-shapes-entry"], + "s5-0": "i", + "s4-0": "c1", + "s3-0": "c2" + } + }, + "aaaaaaaaaaaaaaaaaaaaaaa": {} } diff --git a/goal_src/engine/collide/collide-shape-h.gc b/goal_src/engine/collide/collide-shape-h.gc index 7e79589629..77f736256d 100644 --- a/goal_src/engine/collide/collide-shape-h.gc +++ b/goal_src/engine/collide/collide-shape-h.gc @@ -496,8 +496,8 @@ (nav-flags nav-flags :offset-assert 145) (pad-byte uint8 2 :offset-assert 146) (pat-ignore-mask pat-surface :offset-assert 148) - (event-self basic :offset-assert 152) - (event-other basic :offset-assert 156) + (event-self symbol :offset-assert 152) + (event-other symbol :offset-assert 156) (root-prim collide-shape-prim :offset-assert 160) (riders collide-sticky-rider-group :offset-assert 164) (backup-collide-as collide-kind :offset-assert 168) diff --git a/goal_src/engine/collide/collide-touch-h.gc b/goal_src/engine/collide/collide-touch-h.gc index 1e8dcbc572..6a87e4e155 100644 --- a/goal_src/engine/collide/collide-touch-h.gc +++ b/goal_src/engine/collide/collide-touch-h.gc @@ -13,6 +13,9 @@ ;; As the collision is resolved, shapes are added and removed from the touching list. ;; Once collision is done solving, you can send events or inspect what you touched! + +(defconstant TOUCHING_LIST_LENGTH 32) + ;; A record of a primitive which is touching another, possibly including the triangle that is involved. (deftype touching-prim (structure) ((cprim collide-shape-prim :offset-assert 0) @@ -123,11 +126,11 @@ ) ) -;; A list of (up to) 32 pairs of colliding shapes +;; A list of (up to) TOUCHING_LIST_LENGTH pairs of colliding shapes (deftype touching-list (structure) ((num-touching-shapes int32 :offset-assert 0) (resolve-u int8 :offset-assert 4) - (touching-shapes touching-shapes-entry 32 :inline :offset-assert 8) + (touching-shapes touching-shapes-entry TOUCHING_LIST_LENGTH :inline :offset-assert 8) ) :method-count-assert 15 :size-assert #x208 @@ -171,6 +174,6 @@ ;; We have a pool of prim pairs that can be used in any shape pair (define-perm *touching-prims-entry-pool* touching-prims-entry-pool (new 'global 'touching-prims-entry-pool)) -;; and a list of up to 32 shape pairs +;; and a list of up to TOUCHING_LIST_LENGTH shape pairs (define-perm *touching-list* touching-list (new 'global 'touching-list)) diff --git a/goal_src/engine/collide/collide-touch.gc b/goal_src/engine/collide/collide-touch.gc index 783f1cdbcc..371fe58ee2 100644 --- a/goal_src/engine/collide/collide-touch.gc +++ b/goal_src/engine/collide/collide-touch.gc @@ -71,9 +71,8 @@ (set! (-> arg0 next) v1-1) (set! (-> arg0 prev) #f) (set! (-> obj head) arg0) - (when v1-1 + (if v1-1 (set! (-> v1-1 prev) arg0) - arg0 ) ) ) @@ -111,7 +110,7 @@ ;; Touching List ;;;;;;;;;;;;;;;;;;;;;; -;; A touching list is a list up to 32 pairs of colliding collide-shapes. +;; A touching list is a list up to TOUCHING_LIST_LENGTH pairs of colliding collide-shapes. (defmethod free-all-prim-nodes touching-list ((obj touching-list)) "Free all prim nodes used by all touching shapes in this touching-list." @@ -163,7 +162,7 @@ ) (else ;; need to add a new one - (when (>= (-> obj num-touching-shapes) 32) + (when (>= (-> obj num-touching-shapes) TOUCHING_LIST_LENGTH) ;; but there's no room! (format 0 "ERROR: touching-list::get-shapes-entry() failed!~%") (return (the-as touching-shapes-entry #f)) @@ -429,72 +428,84 @@ "Send all events for touching shapes. Note that the order of event sending is basically random. (this could explain lava walks's unreliable behavior)" - (let ((gp-0 (the-as object (-> obj touching-shapes)))) - (countdown (s5-0 (-> obj num-touching-shapes)) - (let ((s4-0 (-> (the-as touching-shapes-entry gp-0) cshape1))) - (when s4-0 - (let ((s3-0 (-> (the-as touching-shapes-entry gp-0) cshape2))) + + ;; PC port note : there is a fatal bug here where the processes are NOT SAFE to use without a handle. + ;; this can lead to crashes if for example target hits 2 things at once, and one of those things kills the other. + ;; e.g.: target hits eco1 and eco2. eco1 gets processed first and kills eco2 as a result. eco2 is now dead, but + ;; the touching list will run its logic on it regardless. + ;; this is fixed here by creating a really large list of 2 handles per collide shape and storing all collided + ;; process handles there. (process->handle) is then safe to use. + + ; (* 2 TOUCHING_LIST_LENGTH) -> 64 + (let ((handles (new 'stack-no-clear 'array 'handle 64))) + + (let ((entry (the-as touching-shapes-entry (-> obj touching-shapes)))) + (countdown (i (-> obj num-touching-shapes)) + (let ((c1 (-> entry cshape1))) + (when c1 + (let ((c2 (-> entry cshape2))) ;; not quite sure why, but we make it look like cshape1 (s4) is target always. ;; I guess this makes it so the target/enemy events are always sent in the same order. - (when (= (-> s3-0 process type) target) - (let ((v1-2 s4-0)) - (set! s4-0 s3-0) - (set! s3-0 v1-2) - ) + (when (= (-> c2 process type) target) + (swap! c1 c2) + ) + + (set! (-> handles (+ 0 (* 2 i))) (process->handle (-> c1 process))) + (set! (-> handles (+ 1 (* 2 i))) (process->handle (-> c2 process))) + ) + ) + ) + (set! entry (-> (the-as (inline-array touching-shapes-entry) entry) 1)) + ) + ) + + (let ((entry (the-as touching-shapes-entry (-> obj touching-shapes)))) + (countdown (i (-> obj num-touching-shapes)) + (let ((c1 (-> entry cshape1))) + (when c1 + (let ((c2 (-> entry cshape2))) + + ;; not quite sure why, but we make it look like cshape1 (s4) is target always. + ;; I guess this makes it so the target/enemy events are always sent in the same order. + (when (= (-> c2 process type) target) + (swap! c1 c2) ) ;; send events! - (let ((v1-4 (-> s4-0 event-self))) - (when v1-4 - (let ((a1-0 (new 'stack-no-clear 'event-message-block))) - (set! (-> a1-0 from) (-> s3-0 process)) - (set! (-> a1-0 num-params) 1) - (set! (-> a1-0 message) (the-as symbol v1-4)) - (set! (-> a1-0 param 0) (the-as uint gp-0)) - (send-event-function (-> s4-0 process) a1-0) + (let ( + (c1-proc (handle->process (-> handles (+ 0 (* 2 i))))) + (c2-proc (handle->process (-> handles (+ 1 (* 2 i))))) ) + (let ((v1-4 (-> c1 event-self))) + (if v1-4 + (send-event c1-proc v1-4 :from c2-proc entry) + ) ) - ) - (let ((v1-5 (-> s4-0 event-other))) - (when v1-5 - (let ((a1-1 (new 'stack-no-clear 'event-message-block))) - (set! (-> a1-1 from) (-> s4-0 process)) - (set! (-> a1-1 num-params) 1) - (set! (-> a1-1 message) (the-as symbol v1-5)) - (set! (-> a1-1 param 0) (the-as uint gp-0)) - (send-event-function (-> s3-0 process) a1-1) - ) + (let ((v1-5 (-> c1 event-other))) + (if v1-5 + (send-event c2-proc v1-5 :from c1-proc entry) + ) ) - ) - (let ((v1-6 (-> s3-0 event-self))) - (when v1-6 - (let ((a1-2 (new 'stack-no-clear 'event-message-block))) - (set! (-> a1-2 from) (-> s4-0 process)) - (set! (-> a1-2 num-params) 1) - (set! (-> a1-2 message) (the-as symbol v1-6)) - (set! (-> a1-2 param 0) (the-as uint gp-0)) - (send-event-function (-> s3-0 process) a1-2) - ) + (let ((v1-6 (-> c2 event-self))) + (if v1-6 + (send-event c2-proc v1-6 :from c1-proc entry) + ) ) - ) - (let ((v1-7 (-> s3-0 event-other))) - (when v1-7 - (let ((a1-3 (new 'stack-no-clear 'event-message-block))) - (set! (-> a1-3 from) (-> s3-0 process)) - (set! (-> a1-3 num-params) 1) - (set! (-> a1-3 message) (the-as symbol v1-7)) - (set! (-> a1-3 param 0) (the-as uint gp-0)) - (send-event-function (-> s4-0 process) a1-3) - ) + (let ((v1-7 (-> c2 event-other))) + (if v1-7 + (send-event c1-proc v1-7 :from c2-proc entry) + ) ) ) ) ) ) - (set! gp-0 (&+ (the-as touching-shapes-entry gp-0) 16)) + (set! entry (-> (the-as (inline-array touching-shapes-entry) entry) 1)) ) ) + + ) 0 (none) ) diff --git a/goal_src/engine/game/generic-obs.gc b/goal_src/engine/game/generic-obs.gc index d490ce7032..29b7ccd943 100644 --- a/goal_src/engine/game/generic-obs.gc +++ b/goal_src/engine/game/generic-obs.gc @@ -2240,15 +2240,15 @@ ) ) ((= (-> v1-1 type) target) - (let ((a1-4 (new 'stack-no-clear 'event-message-block))) - (set! (-> a1-4 from) (the-as process v1-1)) - (set! (-> a1-4 num-params) 4) - (set! (-> a1-4 message) (-> self event)) - (set! (-> a1-4 param 0) (the-as uint #f)) - (set! (-> a1-4 param 1) (the-as uint (-> self event-mode))) - (set! (-> a1-4 param 2) (the-as uint (-> *target* control unknown-dword50))) - (set! (-> a1-4 param 3) (the-as uint (-> *target* control unknown-dword51))) - (send-event-function arg0 a1-4) + (send-event + arg0 + (-> self event) + :from + (the-as process v1-1) + #f + (-> self event-mode) + (-> *target* control unknown-dword50) + (-> *target* control unknown-dword51) ) ) (else @@ -2269,12 +2269,7 @@ ) ) ((-> self event) - (let ((a1-6 (new 'stack-no-clear 'event-message-block))) - (set! (-> a1-6 from) (the-as process v1-1)) - (set! (-> a1-6 num-params) 0) - (set! (-> a1-6 message) (-> self event)) - (send-event-function arg0 a1-6) - ) + (send-event arg0 (-> self event) :from (the-as process v1-1)) ) (else (let ((t0-5 (new 'stack-no-clear 'event-message-block))) diff --git a/goal_src/goal-lib.gc b/goal_src/goal-lib.gc index 2f27a0201d..ea27a67973 100644 --- a/goal_src/goal-lib.gc +++ b/goal_src/goal-lib.gc @@ -776,6 +776,18 @@ `(new 'debug 'pair ,a ,b) ) +(defmacro cons! (lst val) + `(set! ,lst (cons ,val ,lst)) + ) + +(defmacro swap! (a b) + "macro for swapping 2 variables" + `(let ((temp ,a)) + (set! ,a ,b) + (set! ,b temp) + ) + ) + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ARRAYS ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -905,6 +917,7 @@ "Make hub1" `(make-group "hub1") ) + ;;;;;;;;;;;;;;;;;;; ;; enum stuff ;;;;;;;;;;;;;;;;;;; diff --git a/goal_src/kernel/gstate.gc b/goal_src/kernel/gstate.gc index 68adfe52f2..3bb319fec8 100644 --- a/goal_src/kernel/gstate.gc +++ b/goal_src/kernel/gstate.gc @@ -460,18 +460,16 @@ It type checks the arguments for the entry function. ) ) -(defmacro send-event (proc msg &rest params) +(defmacro send-event (proc msg &key (from (with-pp pp)) &rest params) "Send an event to a process. This should be used over send-event-function" - `(with-pp - (let ((event-data (new 'stack-no-clear 'event-message-block))) - (set! (-> event-data from) pp) + `(let ((event-data (new 'stack-no-clear 'event-message-block))) + (set! (-> event-data from) ,from) (set! (-> event-data num-params) ,(length params)) (set! (-> event-data message) ,msg) ,@(apply-i (lambda (x i) `(set! (-> event-data param ,i) (the-as uint ,x))) params) (send-event-function ,proc event-data) ) - ) ) (defun looping-code () diff --git a/goal_src/levels/finalboss/light-eco.gc b/goal_src/levels/finalboss/light-eco.gc index 30d8517887..0369874410 100644 --- a/goal_src/levels/finalboss/light-eco.gc +++ b/goal_src/levels/finalboss/light-eco.gc @@ -663,13 +663,13 @@ (cond ((and *target* (logtest? (-> *target* state-flags) 256)) (set! (-> obj last-spawned-time) (-> *display* base-frame-counter)) - (set! (-> obj delay-til-spawn) 2400) + (set! (-> obj delay-til-spawn) (seconds 8)) ) (else (when (>= (- (-> *display* base-frame-counter) (-> obj last-spawned-time)) (-> obj delay-til-spawn)) (when (spawn-child-eco obj) (set! (-> obj last-spawned-time) (-> *display* base-frame-counter)) - (set! (-> obj delay-til-spawn) (rand-vu-int-range 300 600)) + (set! (-> obj delay-til-spawn) (rand-vu-int-range (seconds 1) (seconds 2))) ) ) ) @@ -848,7 +848,7 @@ (set! (-> self entity) arg0) (set! (-> self last-update-time) 0) (set! (-> self last-spawned-time) (-> *display* base-frame-counter)) - (set! (-> self delay-til-spawn) 2400) + (set! (-> self delay-til-spawn) (seconds 8)) (set! (-> self angle-mask) 0) (set! (-> self player-got-eco?) #f) (set! (-> self root) (new 'process 'trsqv)) diff --git a/test/decompiler/reference/decompiler-macros.gc b/test/decompiler/reference/decompiler-macros.gc index 1fff2a582f..b4540efc46 100644 --- a/test/decompiler/reference/decompiler-macros.gc +++ b/test/decompiler/reference/decompiler-macros.gc @@ -840,20 +840,16 @@ ) ) -(defmacro send-event (proc msg &rest params) +(defmacro send-event (proc msg &key (from (with-pp pp)) &rest params) "Send an event to a process. This should be used over send-event-function" - `(with-pp - (let ((event-data (new 'stack-singleton-no-clear 'event-message-block))) - (set! (-> event-data from) pp) + `(let ((event-data (new 'stack-no-clear 'event-message-block))) + (set! (-> event-data from) ,from) (set! (-> event-data num-params) ,(length params)) (set! (-> event-data message) ,msg) - ,@(let ((ep 0)) - (apply (lambda (x) `(set! (-> event-data param ep) (the-as uint ,x)) (inc! ep)) params) - ) + ,@(apply-i (lambda (x i) `(set! (-> event-data param ,i) (the-as uint ,x))) params) (send-event-function ,proc event-data) ) - ) ) ;; vector-h diff --git a/test/decompiler/reference/engine/collide/collide-shape-h_REF.gc b/test/decompiler/reference/engine/collide/collide-shape-h_REF.gc index 424b12a51d..f0e6f51b55 100644 --- a/test/decompiler/reference/engine/collide/collide-shape-h_REF.gc +++ b/test/decompiler/reference/engine/collide/collide-shape-h_REF.gc @@ -380,8 +380,8 @@ (nav-flags nav-flags :offset-assert 145) (pad-byte uint8 2 :offset-assert 146) (pat-ignore-mask pat-surface :offset-assert 148) - (event-self basic :offset-assert 152) - (event-other basic :offset-assert 156) + (event-self symbol :offset-assert 152) + (event-other symbol :offset-assert 156) (root-prim collide-shape-prim :offset-assert 160) (riders collide-sticky-rider-group :offset-assert 164) (backup-collide-as collide-kind :offset-assert 168) diff --git a/test/decompiler/reference/engine/collide/collide-touch_REF.gc b/test/decompiler/reference/engine/collide/collide-touch_REF.gc index 632ad5d9c7..6dec9ed64c 100644 --- a/test/decompiler/reference/engine/collide/collide-touch_REF.gc +++ b/test/decompiler/reference/engine/collide/collide-touch_REF.gc @@ -329,65 +329,41 @@ ;; definition for method 12 of type touching-list ;; INFO: Return type mismatch int vs none. (defmethod send-events-for-touching-shapes touching-list ((obj touching-list)) - (let ((gp-0 (the-as object (-> obj touching-shapes)))) - (countdown (s5-0 (-> obj num-touching-shapes)) - (let ((s4-0 (-> (the-as touching-shapes-entry gp-0) cshape1))) - (when s4-0 - (let ((s3-0 (-> (the-as touching-shapes-entry gp-0) cshape2))) - (when (= (-> s3-0 process type) target) - (let ((v1-2 s4-0)) - (set! s4-0 s3-0) - (set! s3-0 v1-2) + (let ((entry (the-as touching-shapes-entry (-> obj touching-shapes)))) + (countdown (i (-> obj num-touching-shapes)) + (let ((c1 (-> entry cshape1))) + (when c1 + (let ((c2 (-> entry cshape2))) + (when (= (-> c2 process type) target) + (let ((v1-2 c1)) + (set! c1 c2) + (set! c2 v1-2) ) ) - (let ((v1-4 (-> s4-0 event-self))) - (when v1-4 - (let ((a1-0 (new 'stack-no-clear 'event-message-block))) - (set! (-> a1-0 from) (-> s3-0 process)) - (set! (-> a1-0 num-params) 1) - (set! (-> a1-0 message) (the-as symbol v1-4)) - (set! (-> a1-0 param 0) (the-as uint gp-0)) - (send-event-function (-> s4-0 process) a1-0) + (let ((v1-4 (-> c1 event-self))) + (if v1-4 + (send-event (-> c1 process) v1-4 :from (-> c2 process) entry) ) - ) ) - (let ((v1-5 (-> s4-0 event-other))) - (when v1-5 - (let ((a1-1 (new 'stack-no-clear 'event-message-block))) - (set! (-> a1-1 from) (-> s4-0 process)) - (set! (-> a1-1 num-params) 1) - (set! (-> a1-1 message) (the-as symbol v1-5)) - (set! (-> a1-1 param 0) (the-as uint gp-0)) - (send-event-function (-> s3-0 process) a1-1) + (let ((v1-5 (-> c1 event-other))) + (if v1-5 + (send-event (-> c2 process) v1-5 :from (-> c1 process) entry) ) - ) ) - (let ((v1-6 (-> s3-0 event-self))) - (when v1-6 - (let ((a1-2 (new 'stack-no-clear 'event-message-block))) - (set! (-> a1-2 from) (-> s4-0 process)) - (set! (-> a1-2 num-params) 1) - (set! (-> a1-2 message) (the-as symbol v1-6)) - (set! (-> a1-2 param 0) (the-as uint gp-0)) - (send-event-function (-> s3-0 process) a1-2) + (let ((v1-6 (-> c2 event-self))) + (if v1-6 + (send-event (-> c2 process) v1-6 :from (-> c1 process) entry) ) - ) ) - (let ((v1-7 (-> s3-0 event-other))) - (when v1-7 - (let ((a1-3 (new 'stack-no-clear 'event-message-block))) - (set! (-> a1-3 from) (-> s3-0 process)) - (set! (-> a1-3 num-params) 1) - (set! (-> a1-3 message) (the-as symbol v1-7)) - (set! (-> a1-3 param 0) (the-as uint gp-0)) - (send-event-function (-> s4-0 process) a1-3) + (let ((v1-7 (-> c2 event-other))) + (if v1-7 + (send-event (-> c1 process) v1-7 :from (-> c2 process) entry) ) - ) ) ) ) ) - (set! gp-0 (&+ (the-as touching-shapes-entry gp-0) 16)) + (set! entry (-> (the-as (inline-array touching-shapes-entry) entry) 1)) ) ) 0 diff --git a/test/decompiler/reference/engine/game/generic-obs_REF.gc b/test/decompiler/reference/engine/game/generic-obs_REF.gc index 05ed572bc2..2054c63bac 100644 --- a/test/decompiler/reference/engine/game/generic-obs_REF.gc +++ b/test/decompiler/reference/engine/game/generic-obs_REF.gc @@ -2384,15 +2384,15 @@ ) ) ((= (-> v1-1 type) target) - (let ((a1-4 (new 'stack-no-clear 'event-message-block))) - (set! (-> a1-4 from) (the-as process v1-1)) - (set! (-> a1-4 num-params) 4) - (set! (-> a1-4 message) (-> self event)) - (set! (-> a1-4 param 0) (the-as uint #f)) - (set! (-> a1-4 param 1) (the-as uint (-> self event-mode))) - (set! (-> a1-4 param 2) (the-as uint (-> *target* control unknown-dword50))) - (set! (-> a1-4 param 3) (the-as uint (-> *target* control unknown-dword51))) - (send-event-function arg0 a1-4) + (send-event + arg0 + (-> self event) + :from + (the-as process v1-1) + #f + (-> self event-mode) + (-> *target* control unknown-dword50) + (-> *target* control unknown-dword51) ) ) (else @@ -2413,12 +2413,7 @@ ) ) ((-> self event) - (let ((a1-6 (new 'stack-no-clear 'event-message-block))) - (set! (-> a1-6 from) (the-as process v1-1)) - (set! (-> a1-6 num-params) 0) - (set! (-> a1-6 message) (-> self event)) - (send-event-function arg0 a1-6) - ) + (send-event arg0 (-> self event) :from (the-as process v1-1)) ) (else (let ((t0-5 (new 'stack-no-clear 'event-message-block)))