From 8696eeb39ee91fb4670fce84e0c740a07786d77c Mon Sep 17 00:00:00 2001 From: water111 <48171810+water111@users.noreply.github.com> Date: Sun, 10 Apr 2022 18:37:57 -0400 Subject: [PATCH] fix decomp (#1293) --- .../jak1_ntsc_black_label/type_casts.jsonc | 4 +++ goal_src/engine/game/effect-control.gc | 28 ++++--------------- .../engine/game/effect-control_REF.gc | 28 ++++--------------- 3 files changed, 16 insertions(+), 44 deletions(-) diff --git a/decompiler/config/jak1_ntsc_black_label/type_casts.jsonc b/decompiler/config/jak1_ntsc_black_label/type_casts.jsonc index 4eea47e2b7..2b01113675 100644 --- a/decompiler/config/jak1_ntsc_black_label/type_casts.jsonc +++ b/decompiler/config/jak1_ntsc_black_label/type_casts.jsonc @@ -7775,5 +7775,9 @@ [[33, 41], "a0", "dma-packet"], [[47, 55], "a0", "dma-packet"] ], + + "(method 12 effect-control)": [ + ["_stack_", 112, "res-tag"] + ], "placeholder-do-not-add-below": [] } diff --git a/goal_src/engine/game/effect-control.gc b/goal_src/engine/game/effect-control.gc index 535905d644..efaf7a3532 100644 --- a/goal_src/engine/game/effect-control.gc +++ b/goal_src/engine/game/effect-control.gc @@ -1064,14 +1064,7 @@ ) (defmethod dummy-12 effect-control ((obj effect-control) (arg0 symbol) (arg1 float) (arg2 int) (arg3 basic) (arg4 sound-name)) - (local-vars - (r0-0 uint128) - (v1-10 uint128) - (sv-112 int) - (sv-128 sound-name) - (sv-144 basic) - (sv-160 (function vector vector float)) - ) + (local-vars (sv-112 res-tag) (sv-128 sound-name) (sv-144 basic) (sv-160 (function vector vector float))) (set! sv-144 arg3) (let ((s0-0 arg4) (gp-0 (new 'stack 'sound-spec)) @@ -1086,28 +1079,19 @@ (set! (-> gp-0 volume) 1024) (logior! (-> gp-0 mask) 4) (set! (-> gp-0 bend) (the int (* 327.66998 (rand-vu-float-range -100.0 100.0)))) - (set! sv-112 0) + (set! sv-112 (new 'static 'res-tag)) (let* ((t9-3 (method-of-type res-lump get-property-data)) (a1-6 'effect-param) (a2-1 'exact) (a3-1 arg1) (t0-1 #f) - (t1-1 (the-as (pointer int) (& sv-112))) + (t1-1 (the-as (pointer res-tag) (& sv-112))) (t2-0 *res-static-buf*) - (a1-7 - (t9-3 (the-as res-lump sv-144) a1-6 a2-1 a3-1 (the-as pointer t0-1) (the-as (pointer res-tag) t1-1) t2-0) - ) + (a1-7 (t9-3 (the-as res-lump sv-144) a1-6 a2-1 a3-1 (the-as pointer t0-1) t1-1 t2-0)) ) - (when a1-7 - (let ((t9-4 effect-param->sound-spec) - (a0-5 gp-0) - ) - (let ((v1-9 (the-as uint128 sv-112))) - (.pcpyud v1-10 v1-9 r0-0) - ) - (t9-4 a0-5 (the-as (pointer float) a1-7) (shr (* (the-as int v1-10) 2) 49)) + (if a1-7 + (effect-param->sound-spec gp-0 (the-as (pointer float) a1-7) (the-as int (-> sv-112 elt-count))) ) - ) ) (if (and (nonzero? (-> gp-0 fo-max)) (let ((f30-1 (* 4096.0 (the float (-> gp-0 fo-max))))) (set! sv-160 vector-vector-distance) diff --git a/test/decompiler/reference/engine/game/effect-control_REF.gc b/test/decompiler/reference/engine/game/effect-control_REF.gc index faecadbfd4..63bba2302e 100644 --- a/test/decompiler/reference/engine/game/effect-control_REF.gc +++ b/test/decompiler/reference/engine/game/effect-control_REF.gc @@ -1079,14 +1079,7 @@ ;; definition for method 12 of type effect-control ;; Used lq/sq (defmethod dummy-12 effect-control ((obj effect-control) (arg0 symbol) (arg1 float) (arg2 int) (arg3 basic) (arg4 sound-name)) - (local-vars - (r0-0 uint128) - (v1-10 uint128) - (sv-112 int) - (sv-128 sound-name) - (sv-144 basic) - (sv-160 (function vector vector float)) - ) + (local-vars (sv-112 res-tag) (sv-128 sound-name) (sv-144 basic) (sv-160 (function vector vector float))) (set! sv-144 arg3) (let ((s0-0 arg4) (gp-0 (new 'stack 'sound-spec)) @@ -1101,28 +1094,19 @@ (set! (-> gp-0 volume) 1024) (logior! (-> gp-0 mask) 4) (set! (-> gp-0 bend) (the int (* 327.66998 (rand-vu-float-range -100.0 100.0)))) - (set! sv-112 0) + (set! sv-112 (new 'static 'res-tag)) (let* ((t9-3 (method-of-type res-lump get-property-data)) (a1-6 'effect-param) (a2-1 'exact) (a3-1 arg1) (t0-1 #f) - (t1-1 (the-as (pointer int) (& sv-112))) + (t1-1 (the-as (pointer res-tag) (& sv-112))) (t2-0 *res-static-buf*) - (a1-7 - (t9-3 (the-as res-lump sv-144) a1-6 a2-1 a3-1 (the-as pointer t0-1) (the-as (pointer res-tag) t1-1) t2-0) - ) + (a1-7 (t9-3 (the-as res-lump sv-144) a1-6 a2-1 a3-1 (the-as pointer t0-1) t1-1 t2-0)) ) - (when a1-7 - (let ((t9-4 effect-param->sound-spec) - (a0-5 gp-0) - ) - (let ((v1-9 (the-as uint128 sv-112))) - (.pcpyud v1-10 v1-9 r0-0) - ) - (t9-4 a0-5 (the-as (pointer float) a1-7) (shr (* (the-as int v1-10) 2) 49)) + (if a1-7 + (effect-param->sound-spec gp-0 (the-as (pointer float) a1-7) (the-as int (-> sv-112 elt-count))) ) - ) ) (if (and (nonzero? (-> gp-0 fo-max)) (let ((f30-1 (* 4096.0 (the float (-> gp-0 fo-max))))) (set! sv-160 vector-vector-distance)