diff --git a/decompiler/IR2/Form.h b/decompiler/IR2/Form.h index a56c208bed..7775e9f4c8 100644 --- a/decompiler/IR2/Form.h +++ b/decompiler/IR2/Form.h @@ -1766,6 +1766,7 @@ class DefpartElement : public FormElement { u16 flags; std::vector data; goos::Object sound_spec; + goos::Object userdata; // backup bool is_sp_end(GameVersion version) const { switch (version) { diff --git a/decompiler/analysis/find_defpartgroup.cpp b/decompiler/analysis/find_defpartgroup.cpp index b15ac17cb2..6b94558d13 100644 --- a/decompiler/analysis/find_defpartgroup.cpp +++ b/decompiler/analysis/find_defpartgroup.cpp @@ -181,6 +181,9 @@ L80: auto& fld = car(cur_field); item.sound_spec = cdr(cdr(cdr(cdr(&fld))))->as_pair()->car; } + if (item.field_id == 48) { + item.userdata = car(cur_field); + } if (item.is_sp_end(env.version)) { // sp-end break; diff --git a/decompiler/analysis/mips2c.cpp b/decompiler/analysis/mips2c.cpp index 9fdd63c4e6..e31abb7b09 100644 --- a/decompiler/analysis/mips2c.cpp +++ b/decompiler/analysis/mips2c.cpp @@ -616,11 +616,14 @@ Mips2C_Line handle_daddiu(Mips2C_Output& out, } } -Mips2C_Line handle_sw(Mips2C_Output& out, const Instruction& i0, const std::string& instr_str) { +Mips2C_Line handle_sw(Mips2C_Output& out, + const Instruction& i0, + const std::string& instr_str, + GameVersion version) { if (i0.get_src(1).is_sym() && i0.get_src(2).is_reg(rs7())) { out.require_symbol(i0.get_src(1).get_sym()); - return {fmt::format("c->store_symbol({}, cache.{});", reg_to_name(i0.get_src(0)), - goal_to_c_name(i0.get_src(1).get_sym())), + return {fmt::format("c->store_symbol{}({}, cache.{});", version == GameVersion::Jak1 ? "" : "2", + reg_to_name(i0.get_src(0)), goal_to_c_name(i0.get_src(1).get_sym())), instr_str}; return handle_unknown(instr_str); // auto name = i0.get_src(1).get_sym(); @@ -998,7 +1001,7 @@ Mips2C_Line handle_normal_instr(Mips2C_Output& output, case InstructionKind::OR: return handle_or(i0, instr_str); case InstructionKind::SW: - return handle_sw(output, i0, instr_str); + return handle_sw(output, i0, instr_str, version); case InstructionKind::VMOVE: return handle_generic_op2_mask(i0, instr_str, "vmove"); case InstructionKind::VITOF0: @@ -1071,6 +1074,7 @@ Mips2C_Line handle_normal_instr(Mips2C_Output& output, case InstructionKind::PAND: case InstructionKind::PCEQB: case InstructionKind::PPACW: + case InstructionKind::PCEQW: return handle_generic_op3(i0, instr_str, {}); case InstructionKind::MULS: return handle_generic_op3(i0, instr_str, "muls"); diff --git a/decompiler/config/jak2/all-types.gc b/decompiler/config/jak2/all-types.gc index 7e72ddef27..c5a3809053 100644 --- a/decompiler/config/jak2/all-types.gc +++ b/decompiler/config/jak2/all-types.gc @@ -3073,7 +3073,7 @@ (bucket-311 311) ;; depth-cue (tex-all-sprite 312) - (bucket-313 313) ;; particles + (particles 313) ;; particles (bucket-314 314) ;; shadow (bucket-315 315) ;; effects (tex-all-warp 316) ;; tex @@ -5008,6 +5008,7 @@ :bitfield #t (needs-log-in 8) (bit-9 9) + (backup-sprite-tex 10) ;; set when particle-setup-adgif fails texture lookup. ) @@ -19622,7 +19623,7 @@ (get-field-spec-by-id "Returns the [[sp-field-init-spec]] that has the matching [[sp-field-id]]" (_type_ sp-field-id) sp-field-init-spec 9) - (sparticle-launcher-method-10 (_type_ string) none 10) + (setup-user-array (_type_ string) none 10) ) ) @@ -19707,11 +19708,11 @@ :size-assert #x70 :flag-assert #x1000000070 (:methods - (initialize (_type_ sparticle-launch-group process) none 9) ;; - (sparticle-launch-control-method-10 (_type_ vector) symbol 10) ;; (is-visible? (_type_ vector) symbol 10) + (initialize (_type_ sparticle-launch-group process) none 9) + (is-visible? (_type_ vector) symbol 10) (spawn (_type_ vector) none 11) ;; TODO - CFG ;; (spawn (_type_ vector) object 11) - (sparticle-launch-control-method-12 (_type_ matrix) none 12) - (sparticle-launch-control-method-13 (_type_ cspace) none 13) + (spawn-with-matrix (_type_ matrix) none 12) + (spawn-with-cspace (_type_ cspace) none 13) (kill-and-free-particles (_type_) none 14) (kill-particles (_type_) none 15) ) @@ -19752,6 +19753,12 @@ ) ;; ---sparticle-h:sp-cpuinfo-flag +(defenum sp-cpuinfo-flag-s32 + :bitfield #t + :type int32 + :copy-entries sp-cpuinfo-flag + ) + (declare-type sparticle-system basic) (deftype sparticle-cpuinfo (structure) ((sprite sprite-vec-data-2d :offset-assert 0) @@ -19770,6 +19777,7 @@ (friction float :offset-assert 96) (timer int32 :offset-assert 100) (flags sp-cpuinfo-flag :offset-assert 104) ;; NOTE - loaded with lw and lwu? + (flags-s32 sp-cpuinfo-flag-s32 :offset 104) (user-int32 int32 :offset-assert 108) (user-uint32 uint32 :offset 108) (user-float float :offset 108 :score 1) @@ -19787,7 +19795,7 @@ (key-alt sparticle-launch-state :offset 132) (binding sparticle-launch-state :offset-assert 136) (data uint32 1 :offset 12) ;; guessed by decompiler - (datab uint8 4 :offset 12) + (datab int8 4 :offset 12) (dataf float 1 :offset 12) ;; guessed by decompiler (datac uint8 1 :offset 12) ;; guessed by decompiler ) @@ -24225,15 +24233,15 @@ "Verifies if the given pointer, points to a [[sparticle-launch-group]]" (function pointer symbol)) (define-extern unlink-part-group-by-heap (function kheap int)) ;; -(define-extern sp-init-fields! (function object (inline-array sp-field-init-spec) sp-field-id sp-field-id symbol object)) ;; TODO - mips2c +(define-extern sp-init-fields! (function object (inline-array sp-field-init-spec) sp-field-id sp-field-id symbol object)) (define-extern *sp-launcher-lock* symbol) ;; (define-extern *sp-launch-queue* sp-launch-queue) ;; (define-extern *sp-launcher-enable* symbol) ;; -;; (define-extern particle-setup-adgif (function adgif-shader texture-id none)) ;; TODO - assertion failure +(define-extern particle-setup-adgif (function adgif-shader int none)) ;; TODO - assertion failure (define-extern *particle-adgif-cache* particle-adgif-cache) ;; (define-extern particle-adgif-cache-flush "Clear [[*particle-adgif-cache*]]" (function none)) -(define-extern particle-adgif (function adgif-shader texture-id none)) ;; TODO - particle-adgif atomic ops, MIPS2C -(define-extern particle-adgif-callback (function adgif-shader none)) ;; TODO bad VF dependencies +(define-extern particle-adgif (function adgif-shader texture-id none)) +(define-extern particle-adgif-callback (function adgif-shader texture-id none)) (define-extern sp-queue-launch (function sparticle-system sparticle-launcher matrix int)) (define-extern sp-adjust-launch (function sparticle-launchinfo sparticle-cpuinfo (inline-array sp-field-init-spec) matrix symbol none)) ;; (define-extern sp-euler-convert (function sparticle-launchinfo sparticle-cpuinfo none)) ;; @@ -24258,8 +24266,8 @@ (define-extern sparticle-respawn-heights (function sparticle-system sparticle-cpuinfo vector none)) (define-extern sparticle-respawn-timer (function sparticle-system sparticle-cpuinfo vector none)) (define-extern sparticle-texture-animate (function sparticle-system sparticle-cpuinfo vector none)) -(define-extern sparticle-texture-day-night (function sparticle-system sparticle-cpuinfo vector none)) -(define-extern sparticle-mode-animate (function sparticle-system sparticle-cpuinfo vector none)) +(define-extern sparticle-texture-day-night (function sparticle-system sparticle-cpuinfo sprite-vec-data-2d none)) +(define-extern sparticle-mode-animate (function sparticle-system sparticle-cpuinfo sprite-vec-data-2d none)) (define-extern sparticle-motion-blur (function sparticle-system sparticle-cpuinfo vector none)) (define-extern sparticle-motion-blur-old "Unused" (function object sparticle-cpuinfo sprite-vec-data-3d object)) (define-extern sparticle-set-conerot (function sparticle-launcher vector none)) @@ -24280,16 +24288,16 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (define-extern sp-particle-copy! (function sparticle-cpuinfo sparticle-cpuinfo none)) ;; -(define-extern *sp-particle-system-2d* sparticle-system) ;; -(define-extern *sp-particle-system-3d* sparticle-system) ;; sparticle-system +(define-extern *sp-particle-system-2d* sparticle-system) +(define-extern *sp-particle-system-3d* sparticle-system) (define-extern sp-get-block-size (function sparticle-system int int)) ;; (define-extern sp-get-approx-alloc-size (function sparticle-system int int)) ;; (define-extern sp-free-particle (function sparticle-system int sparticle-cpuinfo sprite-vec-data-2d none)) ;; -(define-extern sp-get-particle (function sparticle-system int sparticle-launch-state sparticle-cpuinfo)) ;; TODO - manually fixed in jak 1? gross +(define-extern sp-get-particle (function sparticle-system int sparticle-launch-state sparticle-cpuinfo)) (define-extern sp-kill-particle (function sparticle-system sparticle-cpuinfo symbol)) ;; (define-extern sp-orbiter (function sparticle-system sparticle-cpuinfo vector none)) ;; -(define-extern sp-process-block-2d (function sparticle-system int int int int symbol none)) ;; TODO - mips2c -(define-extern sp-process-block-3d (function sparticle-system int int int int symbol none)) ;; TODO - mips2c +(define-extern sp-process-block-2d (function sparticle-system int int int int symbol none)) +(define-extern sp-process-block-3d (function sparticle-system int int int int symbol none)) (define-extern sp-copy-to-spr (function int pointer int none)) ;; TODO - these are all actually uints, but this is needed to get the casts right... (define-extern sp-copy-from-spr (function int pointer int none)) ;; TODO - these are all actually uints, but this is needed to get the casts right... (define-extern memcpy function) ;; TODO - was done manually as well? @@ -25548,15 +25556,15 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (define-extern group-rain-screend-drop sparticle-launch-group) ;; -(define-extern update-snow (function target none)) -;; (define-extern birth-func-omega-normal-orient function) -;; (define-extern birth-func-rain function) -;; (define-extern check-drop-level-rain function) ;; (function sparticle-system sparticle-cpuinfo vector none) -;; (define-extern check-drop-level-rain2 function) -;; (define-extern check-drop-level-splash function) -(define-extern update-rain (function target none)) +(define-extern update-snow (function float vector vector none)) +(define-extern birth-func-omega-normal-orient (function sparticle-system sparticle-cpuinfo sprite-vec-data-3d sparticle-launcher sparticle-launch-state none)) +(define-extern birth-func-rain (function sparticle-system sparticle-cpuinfo sprite-vec-data-3d sparticle-launcher sparticle-launch-state none)) +(define-extern check-drop-level-rain (function sparticle-system sparticle-cpuinfo vector none)) +(define-extern check-drop-level-rain2 (function sparticle-system sparticle-cpuinfo vector none)) +(define-extern check-drop-level-splash (function sparticle-system sparticle-cpuinfo vector none)) +(define-extern update-rain (function float vector vector none)) (define-extern cam-master-effect (function none :behavior camera-master)) ;; -;; (define-extern sparticle-track-sun function) ;; (function int sparticle-cpuinfo matrix none) +(define-extern sparticle-track-sun (function int sparticle-cpuinfo matrix none)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; time-of-day ;; @@ -30487,21 +30495,22 @@ ;; part-tester ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| -(deftype part-tester (UNKNOWN) - () - :method-count-assert 0 - :size-assert #x0 - :flag-assert #x0 +(deftype part-tester (process) + ((root trsqv) + (part sparticle-launch-control) + (old-group sparticle-launch-group)) + :heap-base 16 + :size-assert #x8c + :flag-assert #xe0010008c ;; Failed to read fields. ) -|# -;; (define-extern *part-tester-name* object) ;; string -;; (define-extern part-tester-idle state) ;; (state part-tester) -;; (define-extern part-tester-init-by-other function) ;; (function vector none :behavior process-drawable) -;; (define-extern *debug-part-dead-pool* object) ;; dead-pool -;; (define-extern start-part function) ;; (function none) +(define-extern *part-tester-name* string) +(define-extern part-tester-idle (state part-tester)) +(define-extern part-tester-init-by-other (function vector none :behavior process-drawable)) +(define-extern *debug-part-dead-pool* dead-pool) +(define-extern start-part (function none)) +(define-extern *part-tester* (pointer process)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; editable-h ;; diff --git a/decompiler/config/jak2/hacks.jsonc b/decompiler/config/jak2/hacks.jsonc index c7504758f4..537678d6f4 100644 --- a/decompiler/config/jak2/hacks.jsonc +++ b/decompiler/config/jak2/hacks.jsonc @@ -141,9 +141,6 @@ "(anon-function 4 gun-states)", "(anon-function 28 grenadier)", "(anon-function 24 grenadier)", - // no longer bug or asm, not done yet - "particle-adgif-callback", - // texture "adgif-shader<-texture!" ], @@ -363,7 +360,13 @@ "render-boundary-quad", "render-boundary-tri", "clip-polygon-against-negative-hyperplane", - "clip-polygon-against-positive-hyperplane" + "clip-polygon-against-positive-hyperplane", + "sp-init-fields!", + "particle-adgif", + "sp-launch-particles-var", + "sparticle-motion-blur", + "sp-process-block-2d", + "sp-process-block-3d" ], "mips2c_jump_table_functions": {}, diff --git a/decompiler/config/jak2/label_types.jsonc b/decompiler/config/jak2/label_types.jsonc index 912b980e6c..5d3bdd698c 100644 --- a/decompiler/config/jak2/label_types.jsonc +++ b/decompiler/config/jak2/label_types.jsonc @@ -274,5 +274,6 @@ "target-gun": [["L595", "uint64", true]], "tie-methods": [["L328", "(inline-array tie-init-data)", 6]], "blocking-plane": [["L43", "vector"]], - "elec-gate": [["L141", "attack-info"]] + "elec-gate": [["L141", "attack-info"]], + "part-tester": [["L35", "uint64", true], ["L30", "uint64", true]] } diff --git a/decompiler/config/jak2/stack_structures.jsonc b/decompiler/config/jak2/stack_structures.jsonc index 0793a7e9b9..ee969d1c35 100644 --- a/decompiler/config/jak2/stack_structures.jsonc +++ b/decompiler/config/jak2/stack_structures.jsonc @@ -927,5 +927,17 @@ "(method 18 drawable-region-face)": [ [16, "vector"], [32, "vector"] + ], + "particle-adgif-callback": [ + [16, ["inline-array", "vector", 4]] + ], + "sparticle-respawn-heights": [ + [16, "vector"] + ], + "sparticle-respawn-timer": [ + [16, "vector"] + ], + "check-drop-level-rain": [ + [16, "vector"] ] } diff --git a/decompiler/config/jak2/type_casts.jsonc b/decompiler/config/jak2/type_casts.jsonc index ae37f51dae..6fac9ead78 100644 --- a/decompiler/config/jak2/type_casts.jsonc +++ b/decompiler/config/jak2/type_casts.jsonc @@ -1437,13 +1437,50 @@ [[49, 61], "v1", "dma-packet"] ], "sparticle-track-root-prim": [[3, "v1", "collide-shape"]], - "(method 10 sparticle-launcher)": [[41, "gp", "(array float)"]], - "birth-func-texture-group": [[3, "s5", "(pointer int32)"]], + "(method 10 sparticle-launcher)": [[[41, 75], "gp", "(array int32)"]], + "birth-func-texture-group": [[[2, 10], "s5", "(array int32)"]], "(method 9 sparticle-launch-control)": [[22, "a2", "process-drawable"]], "(method 10 sparticle-launch-control)": [[42, "a3", "float"]], "execute-part-engine": [ [11, "v1", "connection"], - [137, "a3", "vector"] + [12, "a0", "process-drawable"], + [13, "v1", "connection"], + [[19, 53], "s0", "vector"], + [23, "v1", "connection"], + [28, "v1", "connection"], + [29, "v1", "int"], + [137, "a3", "vector"], + [35, "a0", "process-drawable"] + ], + "sparticle-respawn-heights": [ + [[0, 58], "gp", "(array int32)"], + [58, "gp", "(array int32)"], + [34, "v1", "int"] + ], + "sparticle-respawn-timer": [ + [[9, 15], "gp", "(array int32)"], + [34, "gp", "(array int32)"], + [10, "v1", "int"] + ], + "sparticle-texture-animate": [ + [[0, 31], "v1", "(array int32)"], + [47, "v1", "(array int32)"] + ], + "sparticle-texture-day-night": [ + [[21, 78], "s2", "(array int32)"] + ], + "sparticle-mode-animate": [ + [5, "v1", "(array symbol)"], + [[7, 16], "a1", "(array uint32)"], + [18, "a1", "vector4w"], + [21, "a1", "(pointer int32)"], + [26, "a1", "(array int32)"], + [28, "v1", "(array int32)"], + [32, "a0", "(pointer int64)"], + // [33, "a0", "(pointer int64)"], + [44, "v1", "(pointer int32)"], + [46, "v1", "(pointer int32)"] + ], "(method 2 sparticle-cpuinfo)": [[14, "f0", "float"]], "sp-kill-particle": [ @@ -2939,5 +2976,8 @@ [105, "v1", "dma-packet"], [99, "a0", "dma-packet"], [97, "a1", "dma-packet"] + ], + "(code part-tester-idle)": [ + [[16, 22], "s5", "process-drawable"] ] } diff --git a/decompiler/util/sparticle_decompile.cpp b/decompiler/util/sparticle_decompile.cpp index 85fcb6b258..2bc9574e27 100644 --- a/decompiler/util/sparticle_decompile.cpp +++ b/decompiler/util/sparticle_decompile.cpp @@ -781,12 +781,34 @@ goos::Object decompile_sparticle_field_init(const TypeSpec& type, return result; } +std::string debug_print(const LinkedWord& word) { + switch (word.kind()) { + case LinkedWord::PLAIN_DATA: + return fmt::format("0x{:08x}", word.data); + case LinkedWord::TYPE_PTR: + return fmt::format("type: {}\n", word.symbol_name()); + case LinkedWord::EMPTY_PTR: + return fmt::format("'()"); + case LinkedWord::HI_PTR: + return fmt::format("hi ptr"); + case LinkedWord::LO_PTR: + return fmt::format("lo ptr"); + case LinkedWord::PTR: + return fmt::format("ptr"); + case LinkedWord::SYM_OFFSET: + return fmt::format("offset '{}", word.symbol_name()); + case LinkedWord::SYM_PTR: + return fmt::format("ptr '{}", word.symbol_name()); + } +} + goos::Object decompile_sparticle_userdata_ASSERT(const std::vector& words, const std::string& field_name, const std::string& flag_name) { if (flag_name == "int-with-rand" || flag_name == "float-with-rand") { return decompile_sparticle_float_with_rand_init(words, field_name, flag_name); } else { + fmt::print("flag name is {}\n", flag_name); ASSERT(false); } } @@ -849,7 +871,7 @@ goos::Object decompile_sparticle_field_init(const DefpartElement::StaticInfo::Pa result = decompile_sparticle_func(field.data, field_name, flag_name); break; case FieldKind::USERDATA: - result = decompile_sparticle_userdata_ASSERT(field.data, field_name, flag_name); + result = decompile_sparticle_userdata(field.data, field_name, flag_name, field.userdata); break; case FieldKind::ROT_X: result = decompile_sparticle_rot_x(field.data, field_name, flag_name); diff --git a/game/CMakeLists.txt b/game/CMakeLists.txt index 7f6e1324d5..d3cb89bcdc 100644 --- a/game/CMakeLists.txt +++ b/game/CMakeLists.txt @@ -87,6 +87,8 @@ set(RUNTIME_SOURCE mips2c/jak2_functions/font.cpp mips2c/jak2_functions/joint.cpp mips2c/jak2_functions/sky.cpp + mips2c/jak2_functions/sparticle.cpp + mips2c/jak2_functions/sparticle_launcher.cpp mips2c/jak2_functions/texture.cpp overlord/dma.cpp overlord/fake_iso.cpp diff --git a/game/graphics/opengl_renderer/OpenGLRenderer.cpp b/game/graphics/opengl_renderer/OpenGLRenderer.cpp index b672a7cbd4..ff7c91720a 100644 --- a/game/graphics/opengl_renderer/OpenGLRenderer.cpp +++ b/game/graphics/opengl_renderer/OpenGLRenderer.cpp @@ -88,23 +88,94 @@ void OpenGLRenderer::init_bucket_renderers_jak2() { using namespace jak2; m_bucket_renderers.resize((int)BucketId::MAX_BUCKETS); m_bucket_categories.resize((int)BucketId::MAX_BUCKETS, BucketCategory::OTHER); + // 0 init_bucket_renderer("vis", BucketCategory::OTHER, BucketId::SPECIAL_BUCKET_2); + init_bucket_renderer("tex-lcom-sky-pre", BucketCategory::TEX, + BucketId::TEX_LCOM_SKY_PRE); + init_bucket_renderer("tex-l0-tfrag", BucketCategory::TEX, + BucketId::TEX_L0_TFRAG); init_bucket_renderer("tfrag-l0-tfrag", BucketCategory::TFRAG, BucketId::TFRAG_L0_TFRAG, std::vector{tfrag3::TFragmentTreeKind::NORMAL}, false, 0); init_bucket_renderer("tie-l0-tfrag", BucketCategory::TIE, BucketId::TIE_L0_TFRAG, 0); + // 10 + init_bucket_renderer("tex-l1-tfrag", BucketCategory::TEX, + BucketId::TEX_L1_TFRAG); init_bucket_renderer("tfrag-l1-tfrag", BucketCategory::TFRAG, BucketId::TFRAG_L1_TFRAG, std::vector{tfrag3::TFragmentTreeKind::NORMAL}, false, 1); + // 20 init_bucket_renderer("tie-l1-tfrag", BucketCategory::TIE, BucketId::TIE_L1_TFRAG, 1); + // 30 + // 40 + // 50 + // 60 + // 70 + init_bucket_renderer("tex-l0-shrub", BucketCategory::TEX, + BucketId::TEX_L0_SHRUB); init_bucket_renderer("shrub-l0-shrub", BucketCategory::SHRUB, BucketId::SHRUB_L0_SHRUB); + // 80 + init_bucket_renderer("tex-l1-shrub", BucketCategory::TEX, + BucketId::TEX_L1_SHRUB); init_bucket_renderer("shrub-l1-shrub", BucketCategory::SHRUB, BucketId::SHRUB_L1_SHRUB); + // 90 + // 100 + // 110 + // 120 init_bucket_renderer("tfrag-t-l0-alpha", BucketCategory::TFRAG, BucketId::TFRAG_T_L0_ALPHA, std::vector{tfrag3::TFragmentTreeKind::TRANS}, false, 0); + // 130 + // 140 + // 150 + // 160 + // 170 + // 180 + init_bucket_renderer("tex-lcom-tfrag", BucketCategory::TEX, + BucketId::TEX_LCOM_TFRAG); + // 190 + init_bucket_renderer("tex-lcom-shrub", BucketCategory::TEX, + BucketId::TEX_LCOM_SHRUB); + + init_bucket_renderer("tex-l0-pris", BucketCategory::TEX, + BucketId::TEX_L0_PRIS); + // 200 + init_bucket_renderer("tex-l2-pris", BucketCategory::TEX, + BucketId::TEX_L2_PRIS); + // 210 + // 220 + init_bucket_renderer("tex-lcom-pris", BucketCategory::TEX, + BucketId::TEX_LCOM_PRIS); + // 230 + // 240 + // 250 + init_bucket_renderer("tex-l0-water", BucketCategory::TEX, + BucketId::TEX_L0_WATER); init_bucket_renderer("tfrag-w-l0-alpha", BucketCategory::TFRAG, BucketId::TFRAG_W_L0_WATER, std::vector{tfrag3::TFragmentTreeKind::WATER}, false, 0); + // 260 + init_bucket_renderer("tex-l1-water", BucketCategory::TEX, + BucketId::TEX_L1_WATER); + // 270 + init_bucket_renderer("tex-l2-water", BucketCategory::TEX, + BucketId::TEX_L2_WATER); + // 280 + // 290 + // 300 + init_bucket_renderer("tex-lcom-water", BucketCategory::TEX, + BucketId::TEX_LCOM_WATER); + init_bucket_renderer("tex-lcom-sky-post", BucketCategory::TEX, + BucketId::TEX_LCOM_SKY_POST); + // 310 + init_bucket_renderer("tex-all-sprite", BucketCategory::TEX, + BucketId::TEX_ALL_SPRITE); + init_bucket_renderer("particles", BucketCategory::SPRITE, BucketId::PARTICLES); + init_bucket_renderer("tex-all-warp", BucketCategory::TEX, + BucketId::TEX_ALL_WARP); init_bucket_renderer("debug-no-zbuf1", BucketCategory::OTHER, BucketId::DEBUG_NO_ZBUF1, 0x8000); + init_bucket_renderer("tex-all-map", BucketCategory::TEX, + BucketId::TEX_ALL_MAP); + // 320 init_bucket_renderer("debug2", BucketCategory::OTHER, BucketId::DEBUG2, 0x8000); init_bucket_renderer("debug-no-zbuf2", BucketCategory::OTHER, BucketId::DEBUG_NO_ZBUF2, 0x8000); diff --git a/game/graphics/opengl_renderer/Sprite3.cpp b/game/graphics/opengl_renderer/Sprite3.cpp index a24bbf2ba8..301a23d09c 100644 --- a/game/graphics/opengl_renderer/Sprite3.cpp +++ b/game/graphics/opengl_renderer/Sprite3.cpp @@ -762,7 +762,7 @@ void Sprite3::distort_setup_framebuffer_dims(SharedRenderState* render_state) { * This should get the dma chain immediately after the call to sprite-draw-distorters. * It ends right before the sprite-add-matrix-data for the 3d's */ -void Sprite3::handle_sprite_frame_setup(DmaFollower& dma) { +void Sprite3::handle_sprite_frame_setup(DmaFollower& dma, GameVersion version) { // first is some direct data auto direct_data = dma.read_and_advance(); ASSERT(direct_data.size_bytes == 3 * 16); @@ -771,17 +771,38 @@ void Sprite3::handle_sprite_frame_setup(DmaFollower& dma) { // next would be the program, but it's 0 size on the PC and isn't sent. // next is the "frame data" - auto frame_data = dma.read_and_advance(); - ASSERT(frame_data.size_bytes == (int)sizeof(SpriteFrameData)); // very cool - ASSERT(frame_data.vifcode0().kind == VifCode::Kind::STCYCL); - VifCodeStcycl frame_data_stcycl(frame_data.vifcode0()); - ASSERT(frame_data_stcycl.cl == 4); - ASSERT(frame_data_stcycl.wl == 4); - ASSERT(frame_data.vifcode1().kind == VifCode::Kind::UNPACK_V4_32); - VifCodeUnpack frame_data_unpack(frame_data.vifcode1()); - ASSERT(frame_data_unpack.addr_qw == SpriteDataMem::FrameData); - ASSERT(frame_data_unpack.use_tops_flag == false); - memcpy(&m_frame_data, frame_data.data, sizeof(SpriteFrameData)); + switch (version) { + case GameVersion::Jak1: { + auto frame_data = dma.read_and_advance(); + ASSERT(frame_data.size_bytes == (int)sizeof(SpriteFrameDataJak1)); // very cool + ASSERT(frame_data.vifcode0().kind == VifCode::Kind::STCYCL); + VifCodeStcycl frame_data_stcycl(frame_data.vifcode0()); + ASSERT(frame_data_stcycl.cl == 4); + ASSERT(frame_data_stcycl.wl == 4); + ASSERT(frame_data.vifcode1().kind == VifCode::Kind::UNPACK_V4_32); + VifCodeUnpack frame_data_unpack(frame_data.vifcode1()); + ASSERT(frame_data_unpack.addr_qw == SpriteDataMem::FrameData); + ASSERT(frame_data_unpack.use_tops_flag == false); + SpriteFrameDataJak1 jak1_data; + memcpy(&jak1_data, frame_data.data, sizeof(SpriteFrameDataJak1)); + m_frame_data.from_jak1(jak1_data); + } break; + case GameVersion::Jak2: { + auto frame_data = dma.read_and_advance(); + ASSERT(frame_data.size_bytes == (int)sizeof(SpriteFrameData)); // very cool + ASSERT(frame_data.vifcode0().kind == VifCode::Kind::STCYCL); + VifCodeStcycl frame_data_stcycl(frame_data.vifcode0()); + ASSERT(frame_data_stcycl.cl == 4); + ASSERT(frame_data_stcycl.wl == 4); + ASSERT(frame_data.vifcode1().kind == VifCode::Kind::UNPACK_V4_32); + VifCodeUnpack frame_data_unpack(frame_data.vifcode1()); + ASSERT(frame_data_unpack.addr_qw == SpriteDataMem::FrameData); + ASSERT(frame_data_unpack.use_tops_flag == false); + memcpy(&m_frame_data, frame_data.data, sizeof(SpriteFrameData)); + } break; + default: + ASSERT_NOT_REACHED(); + } // next, a MSCALF. auto mscalf = dma.read_and_advance(); @@ -951,6 +972,84 @@ void Sprite3::render_2d_group1(DmaFollower& dma, } void Sprite3::render(DmaFollower& dma, SharedRenderState* render_state, ScopedProfilerNode& prof) { + switch (render_state->version) { + case GameVersion::Jak1: + render_jak1(dma, render_state, prof); + break; + case GameVersion::Jak2: + render_jak2(dma, render_state, prof); + break; + default: + ASSERT_NOT_REACHED(); + } +} + +void Sprite3::render_jak2(DmaFollower& dma, + SharedRenderState* render_state, + ScopedProfilerNode& prof) { + m_debug_stats = {}; + auto data0 = dma.read_and_advance(); + ASSERT(data0.vif1() == 0 || data0.vifcode1().kind == VifCode::Kind::NOP); + ASSERT(data0.vif0() == 0 || data0.vifcode0().kind == VifCode::Kind::MARK); + ASSERT(data0.size_bytes == 0); + + if (dma.current_tag_offset() == render_state->next_bucket) { + fmt::print("early exit!"); + return; + } + + // First is the distorter (temporarily disabled for jak 2) + { + // auto child = prof.make_scoped_child("distorter"); + // render_distorter(dma, render_state, child); + } + + // next, the normal sprite stuff + render_state->shaders[ShaderId::SPRITE3].activate(); + handle_sprite_frame_setup(dma, render_state->version); + + // 3d sprites + render_3d(dma); + + // 2d draw + // m_sprite_renderer.reset_state(); + { + auto child = prof.make_scoped_child("2d-group0"); + render_2d_group0(dma, render_state, child); + flush_sprites(render_state, prof, false); + } + + // shadow draw + render_fake_shadow(dma); + + // 2d draw (HUD) + { + auto child = prof.make_scoped_child("2d-group1"); + render_2d_group1(dma, render_state, child); + flush_sprites(render_state, prof, true); + } + + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glBlendEquation(GL_FUNC_ADD); + + // TODO finish this up. + // fmt::print("next bucket is 0x{}\n", render_state->next_bucket); + while (dma.current_tag_offset() != render_state->next_bucket) { + // auto tag = dma.current_tag(); + // fmt::print("@ 0x{:x} tag: {}", dma.current_tag_offset(), tag.print()); + auto data = dma.read_and_advance(); + VifCode code(data.vif0()); + // fmt::print(" vif0: {}\n", code.print()); + if (code.kind == VifCode::Kind::NOP) { + // fmt::print(" vif1: {}\n", VifCode(data.vif1()).print()); + } + } +} + +void Sprite3::render_jak1(DmaFollower& dma, + SharedRenderState* render_state, + ScopedProfilerNode& prof) { m_debug_stats = {}; // First thing should be a NEXT with two nops. this is a jump from buckets to sprite data auto data0 = dma.read_and_advance(); @@ -976,7 +1075,7 @@ void Sprite3::render(DmaFollower& dma, SharedRenderState* render_state, ScopedPr render_state->shaders[ShaderId::SPRITE3].activate(); // next, sprite frame setup. - handle_sprite_frame_setup(dma); + handle_sprite_frame_setup(dma, render_state->version); // 3d sprites render_3d(dma); @@ -1160,7 +1259,7 @@ void Sprite3::handle_zbuf(u64 val, // way - 24-bit, at offset 448. GsZbuf x(val); ASSERT(x.psm() == TextureFormat::PSMZ24); - ASSERT(x.zbp() == 448); + ASSERT(x.zbp() == 448 || x.zbp() == 304); // 304 for jak 2. m_current_mode.set_depth_write_enable(!x.zmsk()); } diff --git a/game/graphics/opengl_renderer/Sprite3.h b/game/graphics/opengl_renderer/Sprite3.h index e638ebb0d3..5b7777cffe 100644 --- a/game/graphics/opengl_renderer/Sprite3.h +++ b/game/graphics/opengl_renderer/Sprite3.h @@ -19,6 +19,9 @@ class Sprite3 : public BucketRenderer { static constexpr int SPRITES_PER_CHUNK = 48; private: + void render_jak1(DmaFollower& dma, SharedRenderState* render_state, ScopedProfilerNode& prof); + void render_jak2(DmaFollower& dma, SharedRenderState* render_state, ScopedProfilerNode& prof); + void opengl_setup(); void opengl_setup_normal(); void opengl_setup_distort(); @@ -33,7 +36,7 @@ class Sprite3 : public BucketRenderer { void distort_draw_instanced(SharedRenderState* render_state, ScopedProfilerNode& prof); void distort_draw_common(SharedRenderState* render_state, ScopedProfilerNode& prof); void distort_setup_framebuffer_dims(SharedRenderState* render_state); - void handle_sprite_frame_setup(DmaFollower& dma); + void handle_sprite_frame_setup(DmaFollower& dma, GameVersion version); void render_3d(DmaFollower& dma); void render_2d_group0(DmaFollower& dma, SharedRenderState* render_state, diff --git a/game/graphics/opengl_renderer/TextureUploadHandler.cpp b/game/graphics/opengl_renderer/TextureUploadHandler.cpp index e152b75644..97ee641aca 100644 --- a/game/graphics/opengl_renderer/TextureUploadHandler.cpp +++ b/game/graphics/opengl_renderer/TextureUploadHandler.cpp @@ -15,6 +15,7 @@ void TextureUploadHandler::render(DmaFollower& dma, SharedRenderState* render_state, ScopedProfilerNode& prof) { // this is the data we get from the PC Port modification. + m_upload_count = 0; std::vector uploads; // loop through all data, grabbing buckets @@ -60,38 +61,18 @@ void TextureUploadHandler::flush_uploads(std::vector& uploads, if (m_fake_uploads) { uploads.clear(); } else { + m_upload_count += uploads.size(); // NOTE: we don't actually copy the textures in the dma chain copying because they aren't // reference by DMA tag. So there's the potential for race conditions if the game gets messed // up and corrupts the texture memory. const u8* ee_mem = (const u8*)render_state->ee_main_memory; - if (uploads.size() == 2 && uploads[0].mode == 2 && uploads[1].mode == -2 && - uploads[0].page == uploads[1].page) { - render_state->texture_pool->handle_upload_now(ee_mem + uploads[0].page, -2, ee_mem, + for (auto& upload : uploads) { + render_state->texture_pool->handle_upload_now(ee_mem + upload.page, upload.mode, ee_mem, render_state->offset_of_s7); - render_state->texture_pool->handle_upload_now(ee_mem + uploads[0].page, 2, ee_mem, - render_state->offset_of_s7); - } else if (uploads.size() == 1 && uploads[0].mode == -1) { - render_state->texture_pool->handle_upload_now(ee_mem + uploads[0].page, -1, ee_mem, - render_state->offset_of_s7); - } else if (uploads.size() == 1 && uploads[0].mode == -2) { - render_state->texture_pool->handle_upload_now(ee_mem + uploads[0].page, -2, ee_mem, - render_state->offset_of_s7); - } else if (uploads.size() == 1 && uploads[0].mode == 0) { - render_state->texture_pool->handle_upload_now(ee_mem + uploads[0].page, 0, ee_mem, - render_state->offset_of_s7); - } - - else if (uploads.empty()) { - // do nothing. - } else { - lg::error("unhandled upload sequence in {}:", m_name); - for (auto& upload : uploads) { - lg::error(" page: 0x{:x} mode: {}", upload.page, upload.mode); - } - ASSERT(false); } } } void TextureUploadHandler::draw_debug_window() { ImGui::Checkbox("Fake Uploads", &m_fake_uploads); + ImGui::Text("Uploads: %d", m_upload_count); } diff --git a/game/graphics/opengl_renderer/TextureUploadHandler.h b/game/graphics/opengl_renderer/TextureUploadHandler.h index 1aa39ccffc..c275a347d1 100644 --- a/game/graphics/opengl_renderer/TextureUploadHandler.h +++ b/game/graphics/opengl_renderer/TextureUploadHandler.h @@ -21,4 +21,5 @@ class TextureUploadHandler : public BucketRenderer { }; void flush_uploads(std::vector& uploads, SharedRenderState* render_state); bool m_fake_uploads = false; + int m_upload_count = 0; }; diff --git a/game/graphics/opengl_renderer/buckets.h b/game/graphics/opengl_renderer/buckets.h index 69159412a2..1217bd5221 100644 --- a/game/graphics/opengl_renderer/buckets.h +++ b/game/graphics/opengl_renderer/buckets.h @@ -82,15 +82,34 @@ namespace jak2 { enum class BucketId { SPECIAL_BUCKET_2 = 2, + TEX_LCOM_SKY_PRE = 4, + TEX_L0_TFRAG = 7, TFRAG_L0_TFRAG = 8, TIE_L0_TFRAG = 9, + TEX_L1_TFRAG = 18, TFRAG_L1_TFRAG = 19, TIE_L1_TFRAG = 20, + TEX_L0_SHRUB = 73, SHRUB_L0_SHRUB = 74, + TEX_L1_SHRUB = 82, SHRUB_L1_SHRUB = 83, TFRAG_T_L0_ALPHA = 128, + TEX_LCOM_TFRAG = 187, + TEX_LCOM_SHRUB = 191, + TEX_L0_PRIS = 196, + TEX_L2_PRIS = 204, + TEX_LCOM_PRIS = 220, + TEX_L0_WATER = 252, TFRAG_W_L0_WATER = 255, + TEX_L1_WATER = 261, + TEX_L2_WATER = 270, + TEX_LCOM_WATER = 306, + TEX_LCOM_SKY_POST = 309, + TEX_ALL_SPRITE = 312, + PARTICLES = 313, + TEX_ALL_WARP = 316, DEBUG_NO_ZBUF1 = 318, + TEX_ALL_MAP = 319, DEBUG2 = 324, DEBUG_NO_ZBUF2 = 325, DEBUG3 = 326, diff --git a/game/graphics/opengl_renderer/shaders/sprite3_3d.vert b/game/graphics/opengl_renderer/shaders/sprite3_3d.vert index be42f88fd9..129ddcd18f 100644 --- a/game/graphics/opengl_renderer/shaders/sprite3_3d.vert +++ b/game/graphics/opengl_renderer/shaders/sprite3_3d.vert @@ -28,7 +28,7 @@ out flat vec4 fragment_color; out vec3 tex_coord; out flat uvec2 tex_info; -const float SCISSOR_ADJUST = 512.0/448.0; +const float SCISSOR_ADJUST = HEIGHT_SCALE * 512.0/448.0; vec4 matrix_transform(mat4 mtx, vec3 pt) { return mtx[3] diff --git a/game/graphics/opengl_renderer/sprite_common.h b/game/graphics/opengl_renderer/sprite_common.h index c26daf0a8f..619ee08d1e 100644 --- a/game/graphics/opengl_renderer/sprite_common.h +++ b/game/graphics/opengl_renderer/sprite_common.h @@ -12,7 +12,7 @@ using math::Vector4f; /*! * GOAL sprite-frame-data, all the data that's uploaded once per frame for the sprite system. */ -struct SpriteFrameData { +struct SpriteFrameDataJak1 { Vector4f xy_array[8]; Vector4f st_array[4]; Vector4f xyz_array[4]; @@ -41,6 +41,71 @@ struct SpriteFrameData { float bonus; }; +struct SpriteFrameData { + Vector4f xy_array[8]; + Vector4f st_array[4]; + Vector4f xyz_array[4]; + Vector4f hmge_scale; + float pfog0; + float deg_to_rad; + float min_scale; + float inv_area; + GifTag adgif_giftag; + GifTag sprite_2d_giftag; + GifTag sprite_2d_giftag2; + Vector4f sincos[5]; + Vector4f basis_x; + Vector4f basis_y; + GifTag sprite_3d_giftag; + GifTag sprite_3d_giftag_2; + AdGifData screen_shader; + GifTag clipped_giftag; + Vector4f inv_hmge_scale; + Vector4f stq_offset; + Vector4f stq_scale; + Vector4f rgba_plain; + GifTag warp_giftag; + float fog_min; + float fog_max; + float max_scale; + float bonus; + + void from_jak1(const SpriteFrameDataJak1& data) { + for (int i = 0; i < 8; i++) { + xy_array[i] = data.xy_array[i]; + } + for (int i = 0; i < 4; i++) { + st_array[i] = data.st_array[i]; + xyz_array[i] = data.xyz_array[i]; + } + hmge_scale = data.hmge_scale; + pfog0 = data.pfog0; + deg_to_rad = data.deg_to_rad; + min_scale = data.min_scale; + inv_area = data.inv_area; + adgif_giftag = data.adgif_giftag; + sprite_2d_giftag = data.sprite_2d_giftag; + sprite_2d_giftag2 = data.sprite_2d_giftag2; + for (int i = 0; i < 5; i++) { + sincos[i] = data.sincos[i]; + } + basis_x = data.basis_x; + basis_y = data.basis_y; + sprite_3d_giftag = data.sprite_3d_giftag; + screen_shader = data.screen_shader; + clipped_giftag = data.clipped_giftag; + inv_hmge_scale = data.inv_hmge_scale; + stq_offset = data.stq_offset; + stq_scale = data.stq_scale; + rgba_plain = data.rgba_plain; + warp_giftag = data.warp_giftag; + fog_min = data.fog_min; + fog_max = data.fog_max; + max_scale = data.max_scale; + bonus = data.bonus; + } +}; + /*! * "Matrix Data" for 3D sprites. This is shared for all 3D sprites */ @@ -143,4 +208,5 @@ enum SpriteProgMem { }; static_assert(offsetof(SpriteFrameData, hmge_scale) == 256); -static_assert(sizeof(SpriteFrameData) == 0x290, "SpriteFrameData size"); \ No newline at end of file +static_assert(sizeof(SpriteFrameDataJak1) == 0x290, "SpriteFrameData size"); +static_assert(sizeof(SpriteFrameData) == 0x2a0, "SpriteFrameData size"); \ No newline at end of file diff --git a/game/mips2c/jak2_functions/sparticle.cpp b/game/mips2c/jak2_functions/sparticle.cpp new file mode 100644 index 0000000000..feb8fa57c8 --- /dev/null +++ b/game/mips2c/jak2_functions/sparticle.cpp @@ -0,0 +1,712 @@ +//--------------------------MIPS2C--------------------- +// clang-format off +#include "game/mips2c/mips2c_private.h" +#include "game/kernel/jak2/kscheme.h" +using ::jak2::intern_from_c; +namespace Mips2C::jak2 { +namespace sp_process_block_2d { +struct Cache { + void* fake_scratchpad_data; // *fake-scratchpad-data* + void* add_to_sprite_aux_list; // add-to-sprite-aux-list + void* sp_free_particle; // sp-free-particle + void* sp_orbiter; // sp-orbiter + void* sp_relaunch_particle_2d; // sp-relaunch-particle-2d +} cache; + +u64 execute(void* ctxt) { + auto* c = (ExecutionContext*)ctxt; + bool bc = false; + u32 call_addr = 0; + c->daddiu(sp, sp, -128); // daddiu sp, sp, -128 + c->sd(ra, 0, sp); // sd ra, 0(sp) + c->sq(s0, 16, sp); // sq s0, 16(sp) + c->sq(s1, 32, sp); // sq s1, 32(sp) + c->sq(s2, 48, sp); // sq s2, 48(sp) + c->sq(s3, 64, sp); // sq s3, 64(sp) + c->sq(s4, 80, sp); // sq s4, 80(sp) + c->sq(s5, 96, sp); // sq s5, 96(sp) + c->sq(gp, 112, sp); // sq gp, 112(sp) + c->mov64(gp, a0); // or gp, a0, r0 + c->mov64(s5, a1); // or s5, a1, r0 + c->mov64(s4, a2); // or s4, a2, r0 + c->mov64(s1, a3); // or s1, a3, r0 + c->mov64(s3, t0); // or s3, t0, r0 + c->mov64(s2, t1); // or s2, t1, r0 + + block_1: + c->lb(v1, 128, s5); // lb v1, 128(s5) + bc = c->sgpr64(v1) == 0; // beq v1, r0, L113 + // nop // sll r0, r0, 0 + if (bc) {goto block_32;} // branch non-likely + + c->lb(a0, 129, s5); // lb a0, 129(s5) + get_fake_spad_addr2(v1, cache.fake_scratchpad_data, 0, c);// lui v1, 28672 + c->dsll(a0, a0, 4); // dsll a0, a0, 4 + c->daddu(v1, v1, a0); // daddu v1, v1, a0 + c->lqc2(vf9, 0, v1); // lqc2 vf9, 0(v1) + c->mov128_gpr_vf(v1, vf9); // qmfc2.i v1, vf9 + c->andi(s0, v1, 255); // andi s0, v1, 255 + bc = c->sgpr64(s0) != 0; // bne s0, r0, L103 + // nop // sll r0, r0, 0 + if (bc) {goto block_9;} // branch non-likely + + c->lw(v1, 104, s5); // lw v1, 104(s5) + // nop // sll r0, r0, 0 + c->andi(v1, v1, 32896); // andi v1, v1, 32896 + bc = c->sgpr64(v1) == 0; // beq v1, r0, L101 + // nop // sll r0, r0, 0 + if (bc) {goto block_5;} // branch non-likely + + c->load_symbol2(t9, cache.add_to_sprite_aux_list);// lw t9, add-to-sprite-aux-list(s7) + c->mov64(a0, gp); // or a0, gp, r0 + c->mov64(a1, s5); // or a1, s5, r0 + c->mov64(a2, s4); // or a2, s4, r0 + c->mov64(a3, s1); // or a3, s1, r0 + call_addr = c->gprs[t9].du32[0]; // function call: + c->sll(v0, ra, 0); // sll v0, ra, 0 + c->jalr(call_addr); // jalr ra, t9 + + block_5: + c->lw(v1, 100, s5); // lw v1, 100(s5) + c->addiu(a0, r0, -1); // addiu a0, r0, -1 + bc = c->sgpr64(v1) == c->sgpr64(a0); // beq v1, a0, L102 + // nop // sll r0, r0, 0 + if (bc) {goto block_7;} // branch non-likely + + bc = c->sgpr64(v1) == 0; // beq v1, r0, L112 + // nop // sll r0, r0, 0 + if (bc) {goto block_31;} // branch non-likely + + + block_7: + c->lw(a0, 104, s5); // lw a0, 104(s5) + c->andi(v1, a0, 32); // andi v1, a0, 32 + c->xor_(a0, a0, v1); // xor a0, a0, v1 + bc = c->sgpr64(v1) == 0; // beq v1, r0, L113 + c->sw(a0, 104, s5); // sw a0, 104(s5) + if (bc) {goto block_32;} // branch non-likely + + c->lw(v1, 124, s5); // lw v1, 124(s5) + //beq r0, r0, L113 // beq r0, r0, L113 + c->sw(v1, 44, s4); // sw v1, 44(s4) + goto block_32; // branch always + + + block_9: + c->lw(v1, 100, s5); // lw v1, 100(s5) + c->addiu(a0, r0, -1); // addiu a0, r0, -1 + bc = c->sgpr64(v1) == c->sgpr64(a0); // beq v1, a0, L104 + c->dsubu(a0, v1, s0); // dsubu a0, v1, s0 + if (bc) {goto block_12;} // branch non-likely + + bc = c->sgpr64(v1) == 0; // beq v1, r0, L112 + c->pmaxw(v1, a0, r0); // pmaxw v1, a0, r0 + if (bc) {goto block_31;} // branch non-likely + + c->sw(v1, 100, s5); // sw v1, 100(s5) + + block_12: + c->lw(v1, 104, s5); // lw v1, 104(s5) + c->andi(a0, v1, 32); // andi a0, v1, 32 + c->xor_(v1, v1, a0); // xor v1, v1, a0 + bc = c->sgpr64(a0) == 0; // beq a0, r0, L105 + c->sw(v1, 104, s5); // sw v1, 104(s5) + if (bc) {goto block_14;} // branch non-likely + + c->lw(a0, 124, s5); // lw a0, 124(s5) + c->sw(a0, 44, s4); // sw a0, 44(s4) + + block_14: + c->lw(t9, 112, s5); // lw t9, 112(s5) + c->andi(v1, v1, 32896); // andi v1, v1, 32896 + c->load_symbol2(a0, cache.add_to_sprite_aux_list);// lw a0, add-to-sprite-aux-list(s7) + c->movn(t9, a0, v1); // movn t9, a0, v1 + bc = c->sgpr64(t9) == 0; // beq t9, r0, L106 + // nop // sll r0, r0, 0 + if (bc) {goto block_16;} // branch non-likely + + c->daddiu(sp, sp, -80); // daddiu sp, sp, -80 + c->sq(gp, 0, sp); // sq gp, 0(sp) + c->sq(s5, 16, sp); // sq s5, 16(sp) + c->sq(s4, 32, sp); // sq s4, 32(sp) + c->sq(s1, 48, sp); // sq s1, 48(sp) + c->mov64(a0, gp); // or a0, gp, r0 + c->mov64(a1, s5); // or a1, s5, r0 + c->mov64(a2, s4); // or a2, s4, r0 + c->mov64(a3, s1); // or a3, s1, r0 + call_addr = c->gprs[t9].du32[0]; // function call: + c->sq(s3, 64, sp); // sq s3, 64(sp) + c->jalr(call_addr); // jalr ra, t9 + c->lq(gp, 0, sp); // lq gp, 0(sp) + c->lq(s5, 16, sp); // lq s5, 16(sp) + c->lq(s4, 32, sp); // lq s4, 32(sp) + c->lq(s1, 48, sp); // lq s1, 48(sp) + c->lq(s3, 64, sp); // lq s3, 64(sp) + c->daddiu(sp, sp, 80); // daddiu sp, sp, 80 + + block_16: + c->lw(a1, 120, s5); // lw a1, 120(s5) + c->lw(v1, 116, s5); // lw v1, 116(s5) + bc = c->sgpr64(a1) == 0; // beq a1, r0, L107 + c->dsubu(a0, v1, s0); // dsubu a0, v1, s0 + if (bc) {goto block_19;} // branch non-likely + + c->daddiu(v1, a0, -1); // daddiu v1, a0, -1 + bc = ((s64)c->sgpr64(v1)) >= 0; // bgez v1, L107 + c->sw(a0, 116, s5); // sw a0, 116(s5) + if (bc) {goto block_19;} // branch non-likely + + c->daddiu(sp, sp, -96); // daddiu sp, sp, -96 + c->sq(gp, 0, sp); // sq gp, 0(sp) + c->sq(s5, 16, sp); // sq s5, 16(sp) + c->sq(s4, 32, sp); // sq s4, 32(sp) + c->sq(s1, 48, sp); // sq s1, 48(sp) + c->sq(s3, 64, sp); // sq s3, 64(sp) + c->sq(s2, 80, sp); // sq s2, 80(sp) + c->mov64(a0, gp); // or a0, gp, r0 + c->mov64(a3, s4); // or a3, s4, r0 + c->mov64(a2, s5); // or a2, s5, r0 + c->load_symbol2(t9, cache.sp_relaunch_particle_2d);// lw t9, sp-relaunch-particle-2d(s7) + call_addr = c->gprs[t9].du32[0]; // function call: + c->sll(v0, ra, 0); // sll v0, ra, 0 + c->jalr(call_addr); // jalr ra, t9 + c->lq(gp, 0, sp); // lq gp, 0(sp) + c->lq(s5, 16, sp); // lq s5, 16(sp) + c->lq(s4, 32, sp); // lq s4, 32(sp) + c->lq(s1, 48, sp); // lq s1, 48(sp) + c->lq(s3, 64, sp); // lq s3, 64(sp) + c->lq(s2, 80, sp); // lq s2, 80(sp) + c->daddiu(sp, sp, 96); // daddiu sp, sp, 96 + + block_19: + c->lqc2(vf1, 0, s4); // lqc2 vf1, 0(s4) + c->lqc2(vf2, 16, s4); // lqc2 vf2, 16(s4) + c->lqc2(vf3, 32, s4); // lqc2 vf3, 32(s4) + c->lqc2(vf4, 16, s5); // lqc2 vf4, 16(s5) + c->lqc2(vf5, 32, s5); // lqc2 vf5, 32(s5) + c->lqc2(vf6, 48, s5); // lqc2 vf6, 48(s5) + c->lqc2(vf7, 64, s5); // lqc2 vf7, 64(s5) + c->lwc1(f0, 96, s5); // lwc1 f0, 96(s5) + c->mfc1(v1, f0); // mfc1 v1, f0 + c->vmul_bc(DEST::xyzw, BC::z, vf7, vf7, vf9); // vmulz.xyzw vf7, vf7, vf9 + bc = c->sgpr64(v1) == 0; // beq v1, r0, L108 + c->vadd(DEST::xyz, vf4, vf4, vf7); // vadd.xyz vf4, vf4, vf7 + if (bc) {goto block_21;} // branch non-likely + + c->mov128_vf_gpr(vf8, v1); // qmtc2.i vf8, v1 + c->vsub_bc(DEST::w, BC::x, vf8, vf0, vf8); // vsubx.w vf8, vf0, vf8 + c->vmul_bc(DEST::xyzw, BC::w, vf8, vf8, vf9); // vmulw.xyzw vf8, vf8, vf9 + c->vsub_bc(DEST::w, BC::w, vf8, vf0, vf8); // vsubw.w vf8, vf0, vf8 + c->vmul_bc(DEST::xyz, BC::w, vf4, vf4, vf8); // vmulw.xyz vf4, vf4, vf8 + + block_21: + c->vmul_bc(DEST::xyzw, BC::y, vf10, vf4, vf9); // vmuly.xyzw vf10, vf4, vf9 + c->vmul_bc(DEST::xyzw, BC::y, vf11, vf5, vf9); // vmuly.xyzw vf11, vf5, vf9 + c->vmul_bc(DEST::xyzw, BC::y, vf12, vf6, vf9); // vmuly.xyzw vf12, vf6, vf9 + c->vadd(DEST::xyzw, vf1, vf1, vf10); // vadd.xyzw vf1, vf1, vf10 + c->vadd(DEST::zw, vf2, vf2, vf11); // vadd.zw vf2, vf2, vf11 + c->vadd(DEST::xyzw, vf3, vf3, vf12); // vadd.xyzw vf3, vf3, vf12 + c->vmax_bc(DEST::xyzw, BC::x, vf3, vf3, vf0); // vmaxx.xyzw vf3, vf3, vf0 + c->sqc2(vf4, 16, s5); // sqc2 vf4, 16(s5) + c->sqc2(vf1, 0, s4); // sqc2 vf1, 0(s4) + c->sqc2(vf2, 16, s4); // sqc2 vf2, 16(s4) + c->sqc2(vf3, 32, s4); // sqc2 vf3, 32(s4) + c->lwc1(f0, 24, s4); // lwc1 f0, 24(s4) + c->cvtws(f0, f0); // cvt.w.s f0, f0 + c->mfc1(v1, f0); // mfc1 v1, f0 + c->dsll32(v1, v1, 16); // dsll32 v1, v1, 16 + c->dsra32(v1, v1, 16); // dsra32 v1, v1, 16 + c->mtc1(f0, v1); // mtc1 f0, v1 + c->cvtsw(f0, f0); // cvt.s.w f0, f0 + c->swc1(f0, 24, s4); // swc1 f0, 24(s4) + c->lw(v1, 104, s5); // lw v1, 104(s5) + c->andi(v1, v1, 64); // andi v1, v1, 64 + bc = c->sgpr64(v1) == 0; // beq v1, r0, L109 + c->load_symbol2(t9, cache.sp_orbiter); // lw t9, sp-orbiter(s7) + if (bc) {goto block_23;} // branch non-likely + + c->daddiu(sp, sp, -96); // daddiu sp, sp, -96 + c->sq(gp, 0, sp); // sq gp, 0(sp) + c->sq(s5, 16, sp); // sq s5, 16(sp) + c->sq(s4, 32, sp); // sq s4, 32(sp) + c->sq(s1, 48, sp); // sq s1, 48(sp) + c->sq(s3, 64, sp); // sq s3, 64(sp) + c->mov64(a0, gp); // or a0, gp, r0 + c->mov64(a1, s5); // or a1, s5, r0 + c->mov64(a2, s4); // or a2, s4, r0 + call_addr = c->gprs[t9].du32[0]; // function call: + c->sq(s2, 80, sp); // sq s2, 80(sp) + c->jalr(call_addr); // jalr ra, t9 + c->lq(gp, 0, sp); // lq gp, 0(sp) + c->lq(s5, 16, sp); // lq s5, 16(sp) + c->lq(s4, 32, sp); // lq s4, 32(sp) + c->lq(s1, 48, sp); // lq s1, 48(sp) + c->lq(s3, 64, sp); // lq s3, 64(sp) + c->lq(s2, 80, sp); // lq s2, 80(sp) + c->daddiu(sp, sp, 96); // daddiu sp, sp, 96 + + block_23: + c->lq(v1, 32, s4); // lq v1, 32(s4) + c->lw(a0, 104, s5); // lw a0, 104(s5) + c->andi(a1, a0, 2); // andi a1, a0, 2 + bc = c->sgpr64(a1) == 0; // beq a1, r0, L110 + c->andi(a1, a0, 4); // andi a1, a0, 4 + if (bc) {goto block_26;} // branch non-likely + + bc = c->sgpr64(v1) != 0; // bne v1, r0, L110 + c->pextuw(t4, v1, r0); // pextuw t4, v1, r0 + if (bc) {goto block_26;} // branch non-likely + + bc = c->sgpr64(t4) == 0; // beq t4, r0, L112 + // nop // sll r0, r0, 0 + if (bc) {goto block_31;} // branch non-likely + + + block_26: + bc = c->sgpr64(a1) == 0; // beq a1, r0, L111 + c->andi(a0, a0, 1); // andi a0, a0, 1 + if (bc) {goto block_28;} // branch non-likely + + c->pcpyud(t4, v1, r0); // pcpyud t4, v1, r0 + c->pexew(t4, t4); // pexew t4, t4 + bc = ((s64)c->sgpr64(t4)) <= 0; // blez t4, L112 + // nop // sll r0, r0, 0 + if (bc) {goto block_31;} // branch non-likely + + + block_28: + bc = c->sgpr64(a0) == 0; // beq a0, r0, L113 + // nop // sll r0, r0, 0 + if (bc) {goto block_32;} // branch non-likely + + c->mov128_gpr_vf(v1, vf1); // qmfc2.i v1, vf1 + c->pcpyud(v1, v1, r0); // pcpyud v1, v1, r0 + c->pexew(v1, v1); // pexew v1, v1 + bc = ((s64)c->sgpr64(v1)) < 0; // bltz v1, L112 + c->mov128_gpr_vf(v1, vf2); // qmfc2.i v1, vf2 + if (bc) {goto block_31;} // branch non-likely + + c->pcpyud(v1, v1, r0); // pcpyud v1, v1, r0 + c->pexew(v1, v1); // pexew v1, v1 + bc = ((s64)c->sgpr64(v1)) >= 0; // bgez v1, L113 + // nop // sll r0, r0, 0 + if (bc) {goto block_32;} // branch non-likely + + + block_31: + c->load_symbol2(t9, cache.sp_free_particle); // lw t9, sp-free-particle(s7) + c->mov64(a0, gp); // or a0, gp, r0 + c->mov64(a1, s1); // or a1, s1, r0 + c->mov64(a2, s5); // or a2, s5, r0 + c->mov64(a3, s4); // or a3, s4, r0 + call_addr = c->gprs[t9].du32[0]; // function call: + c->sll(v0, ra, 0); // sll v0, ra, 0 + c->jalr(call_addr); // jalr ra, t9 + + block_32: + c->daddiu(s3, s3, -1); // daddiu s3, s3, -1 + c->daddiu(s5, s5, 144); // daddiu s5, s5, 144 + c->daddiu(s4, s4, 48); // daddiu s4, s4, 48 + bc = c->sgpr64(s3) != 0; // bne s3, r0, L100 + c->daddiu(s1, s1, 1); // daddiu s1, s1, 1 + if (bc) {goto block_1;} // branch non-likely + + c->mov64(v0, s1); // or v0, s1, r0 + c->ld(ra, 0, sp); // ld ra, 0(sp) + c->lq(gp, 112, sp); // lq gp, 112(sp) + c->lq(s5, 96, sp); // lq s5, 96(sp) + c->lq(s4, 80, sp); // lq s4, 80(sp) + c->lq(s3, 64, sp); // lq s3, 64(sp) + c->lq(s2, 48, sp); // lq s2, 48(sp) + c->lq(s1, 32, sp); // lq s1, 32(sp) + c->lq(s0, 16, sp); // lq s0, 16(sp) + //jr ra // jr ra + c->daddiu(sp, sp, 128); // daddiu sp, sp, 128 + goto end_of_function; // return + + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + end_of_function: + return c->gprs[v0].du64[0]; +} + +void link() { + cache.fake_scratchpad_data = intern_from_c("*fake-scratchpad-data*").c(); + cache.add_to_sprite_aux_list = intern_from_c("add-to-sprite-aux-list").c(); + cache.sp_free_particle = intern_from_c("sp-free-particle").c(); + cache.sp_orbiter = intern_from_c("sp-orbiter").c(); + cache.sp_relaunch_particle_2d = intern_from_c("sp-relaunch-particle-2d").c(); + gLinkedFunctionTable.reg("sp-process-block-2d", execute, 256); +} + +} // namespace sp_process_block_2d +} // namespace Mips2C + +//--------------------------MIPS2C--------------------- +// clang-format off +#include "game/mips2c/mips2c_private.h" +#include "game/kernel/jak2/kscheme.h" +using ::jak2::intern_from_c; +namespace Mips2C::jak2 { +namespace sp_process_block_3d { +struct Cache { + void* fake_scratchpad_data; // *fake-scratchpad-data* + void* quaternion; // quaternion*! + void* quaternion_normalize; // quaternion-normalize! + void* sp_free_particle; // sp-free-particle + void* sp_relaunch_particle_3d; // sp-relaunch-particle-3d +} cache; + +u64 execute(void* ctxt) { + auto* c = (ExecutionContext*)ctxt; + bool bc = false; + u32 call_addr = 0; + bool cop1_bc = false; + c->daddiu(sp, sp, -176); // daddiu sp, sp, -176 + c->sd(ra, 0, sp); // sd ra, 0(sp) + c->sq(s0, 64, sp); // sq s0, 64(sp) + c->sq(s1, 80, sp); // sq s1, 80(sp) + c->sq(s2, 96, sp); // sq s2, 96(sp) + c->sq(s3, 112, sp); // sq s3, 112(sp) + c->sq(s4, 128, sp); // sq s4, 128(sp) + c->sq(s5, 144, sp); // sq s5, 144(sp) + c->sq(gp, 160, sp); // sq gp, 160(sp) + c->mov64(gp, a0); // or gp, a0, r0 + c->mov64(s5, a1); // or s5, a1, r0 + c->mov64(s4, a2); // or s4, a2, r0 + c->mov64(s0, a3); // or s0, a3, r0 + c->mov64(s3, t0); // or s3, t0, r0 + c->mov64(s2, t1); // or s2, t1, r0 + c->daddiu(s1, sp, 16); // daddiu s1, sp, 16 + c->sq(r0, 0, s1); // sq r0, 0(s1) + + block_1: + c->lb(v1, 128, s5); // lb v1, 128(s5) + bc = c->sgpr64(v1) == 0; // beq v1, r0, L98 + // nop // sll r0, r0, 0 + if (bc) {goto block_33;} // branch non-likely + + c->lb(a0, 129, s5); // lb a0, 129(s5) + get_fake_spad_addr2(v1, cache.fake_scratchpad_data, 0, c);// lui v1, 28672 + c->dsll(a0, a0, 4); // dsll a0, a0, 4 + c->daddu(v1, v1, a0); // daddu v1, v1, a0 + c->lqc2(vf16, 0, v1); // lqc2 vf16, 0(v1) + c->mov128_gpr_vf(v1, vf16); // qmfc2.i v1, vf16 + c->andi(v1, v1, 255); // andi v1, v1, 255 + c->sq(v1, 32, sp); // sq v1, 32(sp) + c->lq(v1, 32, sp); // lq v1, 32(sp) + bc = c->sgpr64(v1) != 0; // bne v1, r0, L86 + // nop // sll r0, r0, 0 + if (bc) {goto block_7;} // branch non-likely + + c->lw(v1, 100, s5); // lw v1, 100(s5) + c->addiu(a0, r0, -1); // addiu a0, r0, -1 + bc = c->sgpr64(v1) == c->sgpr64(a0); // beq v1, a0, L85 + // nop // sll r0, r0, 0 + if (bc) {goto block_5;} // branch non-likely + + bc = c->sgpr64(v1) == 0; // beq v1, r0, L97 + // nop // sll r0, r0, 0 + if (bc) {goto block_32;} // branch non-likely + + + block_5: + c->lw(a0, 104, s5); // lw a0, 104(s5) + c->andi(v1, a0, 32); // andi v1, a0, 32 + c->xor_(a0, a0, v1); // xor a0, a0, v1 + bc = c->sgpr64(v1) == 0; // beq v1, r0, L98 + c->sw(a0, 104, s5); // sw a0, 104(s5) + if (bc) {goto block_33;} // branch non-likely + + c->lw(v1, 124, s5); // lw v1, 124(s5) + //beq r0, r0, L98 // beq r0, r0, L98 + c->sw(v1, 44, s4); // sw v1, 44(s4) + goto block_33; // branch always + + + block_7: + c->lw(v1, 100, s5); // lw v1, 100(s5) + c->addiu(a0, r0, -1); // addiu a0, r0, -1 + bc = c->sgpr64(v1) == c->sgpr64(a0); // beq v1, a0, L87 + c->lq(a0, 32, sp); // lq a0, 32(sp) + if (bc) {goto block_10;} // branch non-likely + + c->dsubu(a0, v1, a0); // dsubu a0, v1, a0 + bc = c->sgpr64(v1) == 0; // beq v1, r0, L97 + c->pmaxw(v1, a0, r0); // pmaxw v1, a0, r0 + if (bc) {goto block_32;} // branch non-likely + + c->sw(v1, 100, s5); // sw v1, 100(s5) + + block_10: + c->lw(a0, 104, s5); // lw a0, 104(s5) + c->andi(v1, a0, 32); // andi v1, a0, 32 + c->xor_(a0, a0, v1); // xor a0, a0, v1 + bc = c->sgpr64(v1) == 0; // beq v1, r0, L88 + c->sw(a0, 104, s5); // sw a0, 104(s5) + if (bc) {goto block_12;} // branch non-likely + + c->lw(v1, 124, s5); // lw v1, 124(s5) + c->sw(v1, 44, s4); // sw v1, 44(s4) + + block_12: + c->lw(t9, 112, s5); // lw t9, 112(s5) + bc = c->sgpr64(t9) == 0; // beq t9, r0, L89 + // nop // sll r0, r0, 0 + if (bc) {goto block_14;} // branch non-likely + + c->daddiu(sp, sp, -96); // daddiu sp, sp, -96 + c->sq(gp, 0, sp); // sq gp, 0(sp) + c->sq(s5, 16, sp); // sq s5, 16(sp) + c->sq(s4, 32, sp); // sq s4, 32(sp) + c->sq(s0, 48, sp); // sq s0, 48(sp) + c->sq(s3, 64, sp); // sq s3, 64(sp) + c->mov64(a0, gp); // or a0, gp, r0 + c->mov64(a1, s5); // or a1, s5, r0 + c->mov64(a2, s4); // or a2, s4, r0 + call_addr = c->gprs[t9].du32[0]; // function call: + c->sq(s2, 80, sp); // sq s2, 80(sp) + c->jalr(call_addr); // jalr ra, t9 + c->lq(gp, 0, sp); // lq gp, 0(sp) + c->lq(s5, 16, sp); // lq s5, 16(sp) + c->lq(s4, 32, sp); // lq s4, 32(sp) + c->lq(s0, 48, sp); // lq s0, 48(sp) + c->lq(s3, 64, sp); // lq s3, 64(sp) + c->lq(s2, 80, sp); // lq s2, 80(sp) + c->daddiu(sp, sp, 96); // daddiu sp, sp, 96 + + block_14: + c->lw(a1, 120, s5); // lw a1, 120(s5) + c->lw(v1, 116, s5); // lw v1, 116(s5) + bc = c->sgpr64(a1) == 0; // beq a1, r0, L90 + c->lq(a0, 32, sp); // lq a0, 32(sp) + if (bc) {goto block_17;} // branch non-likely + + c->dsubu(v1, v1, a0); // dsubu v1, v1, a0 + bc = ((s64)c->sgpr64(v1)) >= 0; // bgez v1, L90 + c->sw(v1, 116, s5); // sw v1, 116(s5) + if (bc) {goto block_17;} // branch non-likely + + c->daddiu(sp, sp, -96); // daddiu sp, sp, -96 + c->sq(gp, 0, sp); // sq gp, 0(sp) + c->sq(s5, 16, sp); // sq s5, 16(sp) + c->sq(s4, 32, sp); // sq s4, 32(sp) + c->sq(s0, 48, sp); // sq s0, 48(sp) + c->sq(s3, 64, sp); // sq s3, 64(sp) + c->sq(s2, 80, sp); // sq s2, 80(sp) + c->mov64(a0, gp); // or a0, gp, r0 + c->mov64(a3, s4); // or a3, s4, r0 + c->mov64(a2, s5); // or a2, s5, r0 + c->load_symbol2(t9, cache.sp_relaunch_particle_3d);// lw t9, sp-relaunch-particle-3d(s7) + call_addr = c->gprs[t9].du32[0]; // function call: + c->sll(v0, ra, 0); // sll v0, ra, 0 + c->jalr(call_addr); // jalr ra, t9 + c->lq(gp, 0, sp); // lq gp, 0(sp) + c->lq(s5, 16, sp); // lq s5, 16(sp) + c->lq(s4, 32, sp); // lq s4, 32(sp) + c->lq(s0, 48, sp); // lq s0, 48(sp) + c->lq(s3, 64, sp); // lq s3, 64(sp) + c->lq(s2, 80, sp); // lq s2, 80(sp) + c->daddiu(sp, sp, 96); // daddiu sp, sp, 96 + + block_17: + c->lqc2(vf8, 0, s4); // lqc2 vf8, 0(s4) + c->lqc2(vf9, 16, s4); // lqc2 vf9, 16(s4) + c->lqc2(vf10, 32, s4); // lqc2 vf10, 32(s4) + c->lqc2(vf11, 16, s5); // lqc2 vf11, 16(s5) + c->lqc2(vf12, 32, s5); // lqc2 vf12, 32(s5) + c->lqc2(vf13, 48, s5); // lqc2 vf13, 48(s5) + c->lqc2(vf14, 64, s5); // lqc2 vf14, 64(s5) + c->lwc1(f0, 96, s5); // lwc1 f0, 96(s5) + c->mfc1(v1, f0); // mfc1 v1, f0 + c->vmul_bc(DEST::xyzw, BC::z, vf14, vf14, vf16); // vmulz.xyzw vf14, vf14, vf16 + bc = c->sgpr64(v1) == 0; // beq v1, r0, L91 + c->vadd(DEST::xyz, vf11, vf11, vf14); // vadd.xyz vf11, vf11, vf14 + if (bc) {goto block_19;} // branch non-likely + + c->mov128_vf_gpr(vf15, v1); // qmtc2.i vf15, v1 + c->vsub_bc(DEST::w, BC::x, vf15, vf0, vf15); // vsubx.w vf15, vf0, vf15 + c->vmul_bc(DEST::xyzw, BC::w, vf15, vf15, vf16); // vmulw.xyzw vf15, vf15, vf16 + c->vsub_bc(DEST::w, BC::w, vf15, vf0, vf15); // vsubw.w vf15, vf0, vf15 + c->vmul_bc(DEST::xyz, BC::w, vf11, vf11, vf15); // vmulw.xyz vf11, vf11, vf15 + + block_19: + c->vmul_bc(DEST::xyzw, BC::y, vf17, vf11, vf16); // vmuly.xyzw vf17, vf11, vf16 + c->vmul_bc(DEST::xyzw, BC::y, vf18, vf12, vf16); // vmuly.xyzw vf18, vf12, vf16 + c->vmul_bc(DEST::xyzw, BC::y, vf19, vf13, vf16); // vmuly.xyzw vf19, vf13, vf16 + c->vadd(DEST::xyzw, vf8, vf8, vf17); // vadd.xyzw vf8, vf8, vf17 + c->vadd_bc(DEST::w, BC::w, vf9, vf9, vf18); // vaddw.w vf9, vf9, vf18 + c->vadd(DEST::xyzw, vf10, vf10, vf19); // vadd.xyzw vf10, vf10, vf19 + c->vmax_bc(DEST::xyzw, BC::x, vf10, vf10, vf0); // vmaxx.xyzw vf10, vf10, vf0 + c->sqc2(vf11, 16, s5); // sqc2 vf11, 16(s5) + c->sqc2(vf8, 0, s4); // sqc2 vf8, 0(s4) + c->sqc2(vf9, 16, s4); // sqc2 vf9, 16(s4) + c->sqc2(vf10, 32, s4); // sqc2 vf10, 32(s4) + c->mov64(v1, s1); // or v1, s1, r0 + c->mov64(a0, s4); // or a0, s4, r0 + c->lwc1(f0, 16, a0); // lwc1 f0, 16(a0) + c->lwc1(f1, 20, a0); // lwc1 f1, 20(a0) + c->lwc1(f2, 24, a0); // lwc1 f2, 24(a0) + c->swc1(f0, 0, v1); // swc1 f0, 0(v1) + c->swc1(f1, 4, v1); // swc1 f1, 4(v1) + c->swc1(f2, 8, v1); // swc1 f2, 8(v1) + c->lui(a0, 16256); // lui a0, 16256 + c->mtc1(f3, a0); // mtc1 f3, a0 + c->muls(f2, f2, f2); // mul.s f2, f2, f2 + c->subs(f2, f3, f2); // sub.s f2, f3, f2 + c->muls(f1, f1, f1); // mul.s f1, f1, f1 + c->subs(f1, f2, f1); // sub.s f1, f2, f1 + c->muls(f0, f0, f0); // mul.s f0, f0, f0 + c->subs(f0, f1, f0); // sub.s f0, f1, f0 + c->sqrts(f0, f0); // sqrt.s f0, f0 + c->swc1(f0, 12, v1); // swc1 f0, 12(v1) + c->mfc1(a0, f0); // mfc1 a0, f0 + c->lq(v1, 32, sp); // lq v1, 32(sp) + c->mov64(v1, v1); // or v1, v1, r0 + c->sq(v1, 48, sp); // sq v1, 48(sp) + + block_20: + c->load_symbol2(t9, cache.quaternion); // lw t9, quaternion*!(s7) + c->mov64(a0, s1); // or a0, s1, r0 + c->mov64(a1, s1); // or a1, s1, r0 + c->daddiu(a2, s5, 80); // daddiu a2, s5, 80 + call_addr = c->gprs[t9].du32[0]; // function call: + c->sll(v0, ra, 0); // sll v0, ra, 0 + c->jalr(call_addr); // jalr ra, t9 + c->lq(v1, 48, sp); // lq v1, 48(sp) + c->daddiu(v1, v1, -10); // daddiu v1, v1, -10 + c->sq(v1, 48, sp); // sq v1, 48(sp) + // nop // sll r0, r0, 0 + c->lq(v1, 48, sp); // lq v1, 48(sp) + bc = ((s64)c->sgpr64(v1)) > 0; // bgtz v1, L92 + // nop // sll r0, r0, 0 + if (bc) {goto block_20;} // branch non-likely + + c->load_symbol2(t9, cache.quaternion_normalize); // lw t9, quaternion-normalize!(s7) + c->mov64(a0, s1); // or a0, s1, r0 + call_addr = c->gprs[t9].du32[0]; // function call: + c->sll(v0, ra, 0); // sll v0, ra, 0 + c->jalr(call_addr); // jalr ra, t9 + c->mov64(a0, s4); // or a0, s4, r0 + c->mov64(v1, s1); // or v1, s1, r0 + c->lwc1(f0, 12, v1); // lwc1 f0, 12(v1) + c->mtc1(f1, r0); // mtc1 f1, r0 + cop1_bc = c->fprs[f0] < c->fprs[f1]; // c.lt.s f0, f1 + bc = !cop1_bc; // bc1f L93 + // nop // sll r0, r0, 0 + if (bc) {goto block_23;} // branch non-likely + + c->lqc2(vf1, 16, a0); // lqc2 vf1, 16(a0) + c->lqc2(vf2, 0, v1); // lqc2 vf2, 0(v1) + c->vsub(DEST::xyz, vf1, vf0, vf2); // vsub.xyz vf1, vf0, vf2 + c->sqc2(vf1, 16, a0); // sqc2 vf1, 16(a0) + c->mov128_gpr_vf(a0, vf1); // qmfc2.i a0, vf1 + //beq r0, r0, L94 // beq r0, r0, L94 + // nop // sll r0, r0, 0 + goto block_24; // branch always + + + block_23: + c->lqc2(vf1, 16, a0); // lqc2 vf1, 16(a0) + c->lqc2(vf2, 0, v1); // lqc2 vf2, 0(v1) + c->vadd(DEST::xyz, vf1, vf0, vf2); // vadd.xyz vf1, vf0, vf2 + c->sqc2(vf1, 16, a0); // sqc2 vf1, 16(a0) + c->mov128_gpr_vf(a0, vf1); // qmfc2.i a0, vf1 + + block_24: + c->mov128_gpr_vf(v1, vf10); // qmfc2.i v1, vf10 + c->lw(a0, 104, s5); // lw a0, 104(s5) + c->andi(a1, a0, 2); // andi a1, a0, 2 + bc = c->sgpr64(a1) == 0; // beq a1, r0, L95 + c->andi(a1, a0, 4); // andi a1, a0, 4 + if (bc) {goto block_27;} // branch non-likely + + bc = c->sgpr64(v1) != 0; // bne v1, r0, L95 + c->pextuw(a2, v1, r0); // pextuw a2, v1, r0 + if (bc) {goto block_27;} // branch non-likely + + bc = c->sgpr64(a2) == 0; // beq a2, r0, L97 + // nop // sll r0, r0, 0 + if (bc) {goto block_32;} // branch non-likely + + + block_27: + bc = c->sgpr64(a1) == 0; // beq a1, r0, L96 + c->andi(a0, a0, 1); // andi a0, a0, 1 + if (bc) {goto block_29;} // branch non-likely + + c->pcpyud(v1, v1, r0); // pcpyud v1, v1, r0 + c->pexew(v1, v1); // pexew v1, v1 + bc = ((s64)c->sgpr64(v1)) <= 0; // blez v1, L97 + // nop // sll r0, r0, 0 + if (bc) {goto block_32;} // branch non-likely + + + block_29: + bc = c->sgpr64(a0) == 0; // beq a0, r0, L98 + // nop // sll r0, r0, 0 + if (bc) {goto block_33;} // branch non-likely + + c->mov128_gpr_vf(v1, vf8); // qmfc2.i v1, vf8 + c->pcpyud(v1, v1, r0); // pcpyud v1, v1, r0 + c->pexew(v1, v1); // pexew v1, v1 + bc = ((s64)c->sgpr64(v1)) < 0; // bltz v1, L97 + c->mov128_gpr_vf(v1, vf9); // qmfc2.i v1, vf9 + if (bc) {goto block_32;} // branch non-likely + + c->pcpyud(v1, v1, r0); // pcpyud v1, v1, r0 + c->pexew(v1, v1); // pexew v1, v1 + bc = ((s64)c->sgpr64(v1)) >= 0; // bgez v1, L98 + // nop // sll r0, r0, 0 + if (bc) {goto block_33;} // branch non-likely + + + block_32: + c->load_symbol2(t9, cache.sp_free_particle); // lw t9, sp-free-particle(s7) + c->mov64(a0, gp); // or a0, gp, r0 + c->mov64(a1, s0); // or a1, s0, r0 + c->mov64(a2, s5); // or a2, s5, r0 + c->mov64(a3, s4); // or a3, s4, r0 + call_addr = c->gprs[t9].du32[0]; // function call: + c->sll(v0, ra, 0); // sll v0, ra, 0 + c->jalr(call_addr); // jalr ra, t9 + + block_33: + c->daddiu(s3, s3, -1); // daddiu s3, s3, -1 + c->daddiu(s5, s5, 144); // daddiu s5, s5, 144 + c->daddiu(s4, s4, 48); // daddiu s4, s4, 48 + bc = c->sgpr64(s3) != 0; // bne s3, r0, L84 + c->daddiu(s0, s0, 1); // daddiu s0, s0, 1 + if (bc) {goto block_1;} // branch non-likely + + c->mov64(v0, s0); // or v0, s0, r0 + c->ld(ra, 0, sp); // ld ra, 0(sp) + c->lq(gp, 160, sp); // lq gp, 160(sp) + c->lq(s5, 144, sp); // lq s5, 144(sp) + c->lq(s4, 128, sp); // lq s4, 128(sp) + c->lq(s3, 112, sp); // lq s3, 112(sp) + c->lq(s2, 96, sp); // lq s2, 96(sp) + c->lq(s1, 80, sp); // lq s1, 80(sp) + c->lq(s0, 64, sp); // lq s0, 64(sp) + //jr ra // jr ra + c->daddiu(sp, sp, 176); // daddiu sp, sp, 176 + goto end_of_function; // return + + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + end_of_function: + return c->gprs[v0].du64[0]; +} + +void link() { + cache.fake_scratchpad_data = intern_from_c("*fake-scratchpad-data*").c(); + cache.quaternion = intern_from_c("quaternion*!").c(); + cache.quaternion_normalize = intern_from_c("quaternion-normalize!").c(); + cache.sp_free_particle = intern_from_c("sp-free-particle").c(); + cache.sp_relaunch_particle_3d = intern_from_c("sp-relaunch-particle-3d").c(); + gLinkedFunctionTable.reg("sp-process-block-3d", execute, 512); +} + +} // namespace sp_process_block_3d +} // namespace Mips2C diff --git a/game/mips2c/jak2_functions/sparticle_launcher.cpp b/game/mips2c/jak2_functions/sparticle_launcher.cpp new file mode 100644 index 0000000000..9d51f68421 --- /dev/null +++ b/game/mips2c/jak2_functions/sparticle_launcher.cpp @@ -0,0 +1,1557 @@ +//--------------------------MIPS2C--------------------- +// clang-format off +#include "game/mips2c/mips2c_private.h" +#include "game/kernel/jak2/kscheme.h" +using ::jak2::intern_from_c; +namespace Mips2C::jak2 { +namespace sp_init_fields { +struct Cache { + void* part_id_table; // *part-id-table* + void* sp_temp; // *sp-temp* +} cache; + +u64 execute(void* ctxt) { + auto* c = (ExecutionContext*)ctxt; + bool bc = false; + u32 call_addr = 0; + c->mov64(v1, a0); // or v1, a0, r0 + c->mov64(v1, a2); // or v1, a2, r0 + c->mov64(v1, a3); // or v1, a3, r0 + c->mov64(v1, t0); // or v1, t0, r0 + // nop // sll r0, r0, 0 + c->daddiu(a2, a2, 1); // daddiu a2, a2, 1 + c->mov64(v0, a1); // or v0, a1, r0 + + block_1: + c->lh(a1, 0, v0); // lh a1, 0(v0) + // nop // sll r0, r0, 0 + c->dsubu(a1, a1, a2); // dsubu a1, a1, a2 + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + if (((s64)c->sgpr64(a1)) < 0) { // bltzl a1, L277 + c->daddiu(v0, v0, 16); // daddiu v0, v0, 16 + goto block_1; + } + + block_3: + c->dsubu(a1, a2, a3); // dsubu a1, a2, a3 + // nop // sll r0, r0, 0 + bc = ((s64)c->sgpr64(a1)) >= 0; // bgez a1, L292 + // nop // sll r0, r0, 0 + if (bc) {goto block_44;} // branch non-likely + + + block_4: + c->lh(a1, 0, v0); // lh a1, 0(v0) + // nop // sll r0, r0, 0 + bc = c->sgpr64(a1) != c->sgpr64(a2); // bne a1, a2, L290 + c->vrget(DEST::xyzw, vf1); // vrget.xyzw vf1 + if (bc) {goto block_41;} // branch non-likely + + c->vsqrt(vf1, BC::x); // vsqrt Q, vf1.x + c->lh(a1, 2, v0); // lh a1, 2(v0) + c->vaddq(DEST::x, vf2, vf0); // vaddq.x vf2, vf0, Q + c->lw(t2, 8, v0); // lw t2, 8(v0) + c->addiu(v1, r0, 7); // addiu v1, r0, 7 + bc = c->sgpr64(a2) == c->sgpr64(v1); // beq a2, v1, L280 + c->addiu(t1, r0, 1); // addiu t1, r0, 1 + if (bc) {goto block_18;} // branch non-likely + + bc = c->sgpr64(a1) == c->sgpr64(t1); // beq a1, t1, L281 + c->addiu(t1, r0, 2); // addiu t1, r0, 2 + if (bc) {goto block_20;} // branch non-likely + + bc = c->sgpr64(a1) == c->sgpr64(t1); // beq a1, t1, L285 + c->addiu(t1, r0, 7); // addiu t1, r0, 7 + if (bc) {goto block_30;} // branch non-likely + + bc = c->sgpr64(a1) == c->sgpr64(t1); // beq a1, t1, L283 + c->addiu(t1, r0, 3); // addiu t1, r0, 3 + if (bc) {goto block_25;} // branch non-likely + + bc = c->sgpr64(a1) == c->sgpr64(t1); // beq a1, t1, L286 + c->addiu(t1, r0, 5); // addiu t1, r0, 5 + if (bc) {goto block_33;} // branch non-likely + + bc = c->sgpr64(a1) == c->sgpr64(t1); // beq a1, t1, L287 + c->addiu(t1, r0, 6); // addiu t1, r0, 6 + if (bc) {goto block_35;} // branch non-likely + + bc = c->sgpr64(a1) == c->sgpr64(t1); // beq a1, t1, L288 + c->addiu(t1, r0, 4); // addiu t1, r0, 4 + if (bc) {goto block_37;} // branch non-likely + + bc = c->sgpr64(a1) == c->sgpr64(t1); // beq a1, t1, L289 + // nop // sll r0, r0, 0 + if (bc) {goto block_39;} // branch non-likely + + bc = c->sgpr64(t2) == 0; // beq t2, r0, L279 + // nop // sll r0, r0, 0 + if (bc) {goto block_16;} // branch non-likely + + c->vrxor(vf2, BC::w); // vrxorw vf2 + c->lw(t1, 12, v0); // lw t1, 12(v0) + c->vrnext(DEST::xyzw, vf1); // vrnext.xyzw vf1 + c->lw(t3, 4, v0); // lw t3, 4(v0) + c->vsub_bc(DEST::xyzw, BC::w, vf1, vf1, vf0); // vsubw.xyzw vf1, vf1, vf0 + // nop // sll r0, r0, 0 + c->mov128_vf_gpr(vf2, t2); // qmtc2.i vf2, t2 + // nop // sll r0, r0, 0 + c->vitof0(DEST::xyzw, vf2, vf2); // vitof0.xyzw vf2, vf2 + // nop // sll r0, r0, 0 + c->vmul(DEST::xyzw, vf1, vf1, vf2); // vmul.xyzw vf1, vf1, vf2 + // nop // sll r0, r0, 0 + c->vftoi0(DEST::xyzw, vf1, vf1); // vftoi0.xyzw vf1, vf1 + // nop // sll r0, r0, 0 + c->mov128_gpr_vf(t2, vf1); // qmfc2.i t2, vf1 + // nop // sll r0, r0, 0 + c->mult3(t2, t2, t1); // mult3 t2, t2, t1 + // nop // sll r0, r0, 0 + c->daddu(t2, t2, t3); // daddu t2, t2, t3 + c->daddiu(a2, a2, 1); // daddiu a2, a2, 1 + c->sw(t2, 0, a0); // sw t2, 0(a0) + c->daddiu(a0, a0, 4); // daddiu a0, a0, 4 + bc = c->sgpr64(a2) != c->sgpr64(a3); // bne a2, a3, L278 + c->daddiu(v0, v0, 16); // daddiu v0, v0, 16 + if (bc) {goto block_4;} // branch non-likely + + //jr ra // jr ra + // nop // sll r0, r0, 0 + goto end_of_function; // return + + + block_16: + c->lw(t3, 4, v0); // lw t3, 4(v0) + c->daddiu(a2, a2, 1); // daddiu a2, a2, 1 + c->sw(t3, 0, a0); // sw t3, 0(a0) + c->daddiu(a0, a0, 4); // daddiu a0, a0, 4 + bc = c->sgpr64(a2) != c->sgpr64(a3); // bne a2, a3, L278 + c->daddiu(v0, v0, 16); // daddiu v0, v0, 16 + if (bc) {goto block_4;} // branch non-likely + + //jr ra // jr ra + // nop // sll r0, r0, 0 + goto end_of_function; // return + + + block_18: + c->lw(t3, 4, v0); // lw t3, 4(v0) + c->daddiu(a2, a2, 1); // daddiu a2, a2, 1 + c->sw(t3, 0, a0); // sw t3, 0(a0) + c->daddiu(a0, a0, 4); // daddiu a0, a0, 4 + bc = c->sgpr64(a2) != c->sgpr64(a3); // bne a2, a3, L278 + c->daddiu(v0, v0, 16); // daddiu v0, v0, 16 + if (bc) {goto block_4;} // branch non-likely + + //jr ra // jr ra + // nop // sll r0, r0, 0 + goto end_of_function; // return + + + block_20: + bc = c->sgpr64(t2) == 0; // beq t2, r0, L282 + c->vrxor(vf2, BC::w); // vrxorw vf2 + if (bc) {goto block_23;} // branch non-likely + + c->vrnext(DEST::xyzw, vf1); // vrnext.xyzw vf1 + c->lw(t1, 12, v0); // lw t1, 12(v0) + c->vsub_bc(DEST::xyzw, BC::w, vf1, vf1, vf0); // vsubw.xyzw vf1, vf1, vf0 + c->lw(t3, 4, v0); // lw t3, 4(v0) + c->mov128_vf_gpr(vf2, t2); // qmtc2.i vf2, t2 + // nop // sll r0, r0, 0 + c->vmul(DEST::xyzw, vf1, vf1, vf2); // vmul.xyzw vf1, vf1, vf2 + // nop // sll r0, r0, 0 + c->mov128_vf_gpr(vf2, t1); // qmtc2.i vf2, t1 + // nop // sll r0, r0, 0 + c->vmul(DEST::xyzw, vf1, vf1, vf2); // vmul.xyzw vf1, vf1, vf2 + // nop // sll r0, r0, 0 + c->mov128_vf_gpr(vf2, t3); // qmtc2.i vf2, t3 + // nop // sll r0, r0, 0 + c->vadd(DEST::xyzw, vf1, vf1, vf2); // vadd.xyzw vf1, vf1, vf2 + // nop // sll r0, r0, 0 + c->mov128_gpr_vf(t2, vf1); // qmfc2.i t2, vf1 + c->daddiu(a2, a2, 1); // daddiu a2, a2, 1 + c->sw(t2, 0, a0); // sw t2, 0(a0) + c->daddiu(a0, a0, 4); // daddiu a0, a0, 4 + bc = c->sgpr64(a2) != c->sgpr64(a3); // bne a2, a3, L278 + c->daddiu(v0, v0, 16); // daddiu v0, v0, 16 + if (bc) {goto block_4;} // branch non-likely + + //jr ra // jr ra + // nop // sll r0, r0, 0 + goto end_of_function; // return + + + block_23: + c->lw(t3, 4, v0); // lw t3, 4(v0) + c->daddiu(a2, a2, 1); // daddiu a2, a2, 1 + c->sw(t3, 0, a0); // sw t3, 0(a0) + c->daddiu(a0, a0, 4); // daddiu a0, a0, 4 + bc = c->sgpr64(a2) != c->sgpr64(a3); // bne a2, a3, L278 + c->daddiu(v0, v0, 16); // daddiu v0, v0, 16 + if (bc) {goto block_4;} // branch non-likely + + //jr ra // jr ra + // nop // sll r0, r0, 0 + goto end_of_function; // return + + + block_25: + bc = c->sgpr64(t2) == 0; // beq t2, r0, L284 + c->vrxor(vf2, BC::w); // vrxorw vf2 + if (bc) {goto block_28;} // branch non-likely + + c->vrnext(DEST::xyzw, vf1); // vrnext.xyzw vf1 + c->lw(t1, 12, v0); // lw t1, 12(v0) + c->vsub_bc(DEST::xyzw, BC::w, vf1, vf1, vf0); // vsubw.xyzw vf1, vf1, vf0 + c->lw(t3, 4, v0); // lw t3, 4(v0) + c->mov128_vf_gpr(vf2, t2); // qmtc2.i vf2, t2 + // nop // sll r0, r0, 0 + c->vmul(DEST::xyzw, vf1, vf1, vf2); // vmul.xyzw vf1, vf1, vf2 + // nop // sll r0, r0, 0 + c->mov128_vf_gpr(vf2, t1); // qmtc2.i vf2, t1 + // nop // sll r0, r0, 0 + c->vmul(DEST::xyzw, vf1, vf1, vf2); // vmul.xyzw vf1, vf1, vf2 + // nop // sll r0, r0, 0 + c->mov128_vf_gpr(vf2, t3); // qmtc2.i vf2, t3 + // nop // sll r0, r0, 0 + c->vadd(DEST::xyzw, vf1, vf1, vf2); // vadd.xyzw vf1, vf1, vf2 + // nop // sll r0, r0, 0 + c->mov128_gpr_vf(t2, vf1); // qmfc2.i t2, vf1 + c->daddiu(a2, a2, 1); // daddiu a2, a2, 1 + c->sw(t2, 0, a0); // sw t2, 0(a0) + c->daddiu(a0, a0, 4); // daddiu a0, a0, 4 + c->store_symbol2(t2, cache.sp_temp); // sw t2, *sp-temp*(s7) + // nop // sll r0, r0, 0 + bc = c->sgpr64(a2) != c->sgpr64(a3); // bne a2, a3, L278 + c->daddiu(v0, v0, 16); // daddiu v0, v0, 16 + if (bc) {goto block_4;} // branch non-likely + + //jr ra // jr ra + // nop // sll r0, r0, 0 + goto end_of_function; // return + + + block_28: + c->lw(t3, 4, v0); // lw t3, 4(v0) + c->daddiu(a2, a2, 1); // daddiu a2, a2, 1 + c->sw(t3, 0, a0); // sw t3, 0(a0) + c->daddiu(a0, a0, 4); // daddiu a0, a0, 4 + c->store_symbol2(t3, cache.sp_temp); // sw t3, *sp-temp*(s7) + // nop // sll r0, r0, 0 + bc = c->sgpr64(a2) != c->sgpr64(a3); // bne a2, a3, L278 + c->daddiu(v0, v0, 16); // daddiu v0, v0, 16 + if (bc) {goto block_4;} // branch non-likely + + //jr ra // jr ra + // nop // sll r0, r0, 0 + goto end_of_function; // return + + + block_30: + bc = c->sgpr64(t2) == 0; // beq t2, r0, L282 + c->vrxor(vf2, BC::w); // vrxorw vf2 + if (bc) {goto block_23;} // branch non-likely + + c->vrnext(DEST::xyzw, vf1); // vrnext.xyzw vf1 + c->lw(t1, 12, v0); // lw t1, 12(v0) + c->vsub_bc(DEST::xyzw, BC::w, vf1, vf1, vf0); // vsubw.xyzw vf1, vf1, vf0 + c->daddiu(t2, t2, 1); // daddiu t2, t2, 1 + c->mov128_vf_gpr(vf2, t2); // qmtc2.i vf2, t2 + c->lw(t3, 4, v0); // lw t3, 4(v0) + c->vitof0(DEST::xyzw, vf2, vf2); // vitof0.xyzw vf2, vf2 + // nop // sll r0, r0, 0 + c->vmul(DEST::xyzw, vf1, vf1, vf2); // vmul.xyzw vf1, vf1, vf2 + // nop // sll r0, r0, 0 + c->vftoi0(DEST::xyzw, vf1, vf1); // vftoi0.xyzw vf1, vf1 + // nop // sll r0, r0, 0 + c->vitof0(DEST::xyzw, vf1, vf1); // vitof0.xyzw vf1, vf1 + // nop // sll r0, r0, 0 + c->mov128_vf_gpr(vf2, t1); // qmtc2.i vf2, t1 + // nop // sll r0, r0, 0 + c->vmul(DEST::xyzw, vf1, vf1, vf2); // vmul.xyzw vf1, vf1, vf2 + // nop // sll r0, r0, 0 + c->mov128_vf_gpr(vf2, t3); // qmtc2.i vf2, t3 + // nop // sll r0, r0, 0 + c->vadd(DEST::xyzw, vf1, vf1, vf2); // vadd.xyzw vf1, vf1, vf2 + // nop // sll r0, r0, 0 + c->mov128_gpr_vf(t2, vf1); // qmfc2.i t2, vf1 + c->daddiu(a2, a2, 1); // daddiu a2, a2, 1 + c->sw(t2, 0, a0); // sw t2, 0(a0) + c->daddiu(a0, a0, 4); // daddiu a0, a0, 4 + bc = c->sgpr64(a2) != c->sgpr64(a3); // bne a2, a3, L278 + c->daddiu(v0, v0, 16); // daddiu v0, v0, 16 + if (bc) {goto block_4;} // branch non-likely + + //jr ra // jr ra + // nop // sll r0, r0, 0 + goto end_of_function; // return + + + block_33: + c->lw(t1, 4, v0); // lw t1, 4(v0) + // nop // sll r0, r0, 0 + c->dsll(t1, t1, 2); // dsll t1, t1, 2 + // nop // sll r0, r0, 0 + c->daddu(t1, t1, a0); // daddu t1, t1, a0 + // nop // sll r0, r0, 0 + c->lw(t3, 0, t1); // lw t3, 0(t1) + c->daddiu(a2, a2, 1); // daddiu a2, a2, 1 + c->sw(t3, 0, a0); // sw t3, 0(a0) + c->daddiu(a0, a0, 4); // daddiu a0, a0, 4 + bc = c->sgpr64(a2) != c->sgpr64(a3); // bne a2, a3, L278 + c->daddiu(v0, v0, 16); // daddiu v0, v0, 16 + if (bc) {goto block_4;} // branch non-likely + + //jr ra // jr ra + // nop // sll r0, r0, 0 + goto end_of_function; // return + + + block_35: + c->lw(t1, 4, v0); // lw t1, 4(v0) + // nop // sll r0, r0, 0 + c->lw(t3, -1, t1); // lw t3, -1(t1) + c->daddiu(a2, a2, 1); // daddiu a2, a2, 1 + c->sw(t3, 0, a0); // sw t3, 0(a0) + c->daddiu(a0, a0, 4); // daddiu a0, a0, 4 + bc = c->sgpr64(a2) != c->sgpr64(a3); // bne a2, a3, L278 + c->daddiu(v0, v0, 16); // daddiu v0, v0, 16 + if (bc) {goto block_4;} // branch non-likely + + //jr ra // jr ra + // nop // sll r0, r0, 0 + goto end_of_function; // return + + + block_37: + c->load_symbol2(t1, cache.part_id_table); // lw t1, *part-id-table*(s7) + // nop // sll r0, r0, 0 + c->lw(t3, 4, v0); // lw t3, 4(v0) + // nop // sll r0, r0, 0 + c->dsll(t3, t3, 2); // dsll t3, t3, 2 + c->daddiu(t1, t1, 12); // daddiu t1, t1, 12 + c->daddu(t3, t3, t1); // daddu t3, t3, t1 + // nop // sll r0, r0, 0 + c->lw(t2, 0, t3); // lw t2, 0(t3) + c->daddiu(a2, a2, 1); // daddiu a2, a2, 1 + c->sw(t2, 0, a0); // sw t2, 0(a0) + c->daddiu(a0, a0, 4); // daddiu a0, a0, 4 + bc = c->sgpr64(a2) != c->sgpr64(a3); // bne a2, a3, L278 + c->daddiu(v0, v0, 16); // daddiu v0, v0, 16 + if (bc) {goto block_4;} // branch non-likely + + //jr ra // jr ra + // nop // sll r0, r0, 0 + goto end_of_function; // return + + + block_39: + c->lw(t3, 4, v0); // lw t3, 4(v0) + c->daddiu(a2, a2, 1); // daddiu a2, a2, 1 + c->sw(t3, 0, a0); // sw t3, 0(a0) + c->daddiu(a0, a0, 4); // daddiu a0, a0, 4 + bc = c->sgpr64(a2) != c->sgpr64(a3); // bne a2, a3, L278 + c->daddiu(v0, v0, 16); // daddiu v0, v0, 16 + if (bc) {goto block_4;} // branch non-likely + + //jr ra // jr ra + // nop // sll r0, r0, 0 + goto end_of_function; // return + + + block_41: + if (((s64)c->sgpr64(t0)) != ((s64)c->sgpr64(s7))) {// bnel t0, s7, L291 + c->sw(r0, 0, a0); // sw r0, 0(a0) + goto block_43; + } + + block_43: + c->daddiu(a2, a2, 1); // daddiu a2, a2, 1 + c->daddiu(a0, a0, 4); // daddiu a0, a0, 4 + bc = c->sgpr64(a2) != c->sgpr64(a3); // bne a2, a3, L278 + // nop // sll r0, r0, 0 + if (bc) {goto block_4;} // branch non-likely + + + block_44: + //jr ra // jr ra + // nop // sll r0, r0, 0 + goto end_of_function; // return + + //jr ra // jr ra + c->daddu(sp, sp, r0); // daddu sp, sp, r0 + goto end_of_function; // return + + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + end_of_function: + return c->gprs[v0].du64[0]; +} + +void link() { + cache.part_id_table = intern_from_c("*part-id-table*").c(); + cache.sp_temp = intern_from_c("*sp-temp*").c(); + gLinkedFunctionTable.reg("sp-init-fields!", execute, 0); +} + +} // namespace sp_init_fields +} // namespace Mips2C + +namespace Mips2C::jak2 { +namespace particle_adgif { +struct Cache { + void* particle_adgif_cache; // *particle-adgif-cache* + void* particle_setup_adgif; // particle-setup-adgif +} cache; + +u64 execute(void* ctxt) { + auto* c = (ExecutionContext*)ctxt; + bool bc = false; + u32 call_addr = 0; + // nop // sll r0, r0, 0 + c->dsra(a3, a1, 20); // dsra a3, a1, 20 + c->load_symbol2(t1, cache.particle_adgif_cache); // lw t1, *particle-adgif-cache*(s7) + c->dsra(t0, a1, 8); // dsra t0, a1, 8 + c->lw(t2, 0, t1); // lw t2, 0(t1) + c->xor_(a3, a3, t0); // xor a3, a3, t0 + c->lhu(v1, 4, t1); // lhu v1, 4(t1) + c->andi(a3, a3, 65535); // andi a3, a3, 65535 + c->lw(t4, 8, t1); // lw t4, 8(t1) + bc = c->sgpr64(v1) == c->sgpr64(a3); // beq v1, a3, L270 + c->daddiu(t3, t1, 12); // daddiu t3, t1, 12 + if (bc) {goto block_7;} // branch non-likely + + bc = c->sgpr64(t2) == 0; // beq t2, r0, L269 + c->daddiu(t4, t1, 172); // daddiu t4, t1, 172 + if (bc) {goto block_4;} // branch non-likely + + + block_2: + c->lhu(v1, 0, t3); // lhu v1, 0(t3) + c->daddiu(t3, t3, 2); // daddiu t3, t3, 2 + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + bc = c->sgpr64(v1) == c->sgpr64(a3); // beq v1, a3, L270 + c->daddiu(t2, t2, -1); // daddiu t2, t2, -1 + if (bc) {goto block_7;} // branch non-likely + + bc = c->sgpr64(t2) != 0; // bne t2, r0, L268 + c->daddiu(t4, t4, 80); // daddiu t4, t4, 80 + if (bc) {goto block_2;} // branch non-likely + + + block_4: + c->daddiu(sp, sp, -16); // daddiu sp, sp, -16 + c->lw(v1, 0, t1); // lw v1, 0(t1) + c->daddiu(v1, v1, -80); // daddiu v1, v1, -80 + c->sw(a0, 0, sp); // sw a0, 0(sp) + bc = c->sgpr64(v1) == 0; // beq v1, r0, L271 + c->daddiu(v1, v1, 81); // daddiu v1, v1, 81 + if (bc) {goto block_8;} // branch non-likely + + c->sh(a3, 0, t3); // sh a3, 0(t3) + // nop // sll r0, r0, 0 + c->sw(t4, 4, sp); // sw t4, 4(sp) + c->mov64(a0, t4); // or a0, t4, r0 + c->load_symbol2(t9, cache.particle_setup_adgif); // lw t9, particle-setup-adgif(s7) + // nop // sll r0, r0, 0 + c->sw(ra, 8, sp); // sw ra, 8(sp) + // nop // sll r0, r0, 0 + call_addr = c->gprs[t9].du32[0]; // function call: + c->sw(v1, 0, t1); // sw v1, 0(t1) + c->jalr(call_addr); // jalr ra, t9 + // nop // sll r0, r0, 0 + c->lw(v1, 8, t4); // lw v1, 8(t4) + c->lw(a0, 0, sp); // lw a0, 0(sp) + // nop // sll r0, r0, 0 + c->lw(t4, 4, sp); // lw t4, 4(sp) + c->andi(v1, v1, 1024); // andi v1, v1, 1024 + c->lw(ra, 8, sp); // lw ra, 8(sp) + c->daddiu(sp, sp, 16); // daddiu sp, sp, 16 + bc = c->sgpr64(v1) == 0; // beq v1, r0, L270 + c->lw(v1, 0, t1); // lw v1, 0(t1) + if (bc) {goto block_7;} // branch non-likely + + c->daddiu(v1, v1, -1); // daddiu v1, v1, -1 + c->sw(v1, 0, t1); // sw v1, 0(t1) + + block_7: + c->lqc2(vf16, 0, t4); // lqc2 vf16, 0(t4) + c->lqc2(vf17, 16, t4); // lqc2 vf17, 16(t4) + c->lqc2(vf18, 32, t4); // lqc2 vf18, 32(t4) + c->lqc2(vf19, 48, t4); // lqc2 vf19, 48(t4) + c->lqc2(vf20, 64, t4); // lqc2 vf20, 64(t4) + c->sqc2(vf16, 0, a0); // sqc2 vf16, 0(a0) + c->sqc2(vf17, 16, a0); // sqc2 vf17, 16(a0) + c->sqc2(vf18, 32, a0); // sqc2 vf18, 32(a0) + c->sqc2(vf19, 48, a0); // sqc2 vf19, 48(a0) + c->sqc2(vf20, 64, a0); // sqc2 vf20, 64(a0) + c->sw(t4, 8, t1); // sw t4, 8(t1) + c->sh(a3, 4, t1); // sh a3, 4(t1) + //jr ra // jr ra + // nop // sll r0, r0, 0 + goto end_of_function; // return + + + block_8: + c->sw(t4, 4, sp); // sw t4, 4(sp) + // nop // sll r0, r0, 0 + c->load_symbol2(t9, cache.particle_setup_adgif); // lw t9, particle-setup-adgif(s7) + // nop // sll r0, r0, 0 + c->sw(ra, 8, sp); // sw ra, 8(sp) + // nop // sll r0, r0, 0 + call_addr = c->gprs[t9].du32[0]; // function call: + // nop // sll r0, r0, 0 + c->jalr(call_addr); // jalr ra, t9 + c->lw(t4, 4, sp); // lw t4, 4(sp) + // nop // sll r0, r0, 0 + c->lw(ra, 8, sp); // lw ra, 8(sp) + c->daddiu(sp, sp, 16); // daddiu sp, sp, 16 + //jr ra // jr ra + // nop // sll r0, r0, 0 + goto end_of_function; // return + + //jr ra // jr ra + c->daddu(sp, sp, r0); // daddu sp, sp, r0 + goto end_of_function; // return + + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + end_of_function: + return c->gprs[v0].du64[0]; +} + +void link() { + cache.particle_adgif_cache = intern_from_c("*particle-adgif-cache*").c(); + cache.particle_setup_adgif = intern_from_c("particle-setup-adgif").c(); + gLinkedFunctionTable.reg("particle-adgif", execute, 128); +} + +} // namespace particle_adgif +} // namespace Mips2C + +//--------------------------MIPS2C--------------------- +// clang-format off +#include "game/mips2c/mips2c_private.h" +#include "game/kernel/jak2/kscheme.h" +using ::jak2::intern_from_c; +namespace Mips2C::jak2 { +namespace sp_launch_particles_var { +struct Cache { + void* level; // *level* + void* sp_launcher_enable; // *sp-launcher-enable* + void* sp_launcher_lock; // *sp-launcher-lock* + void* time_of_day_context; // *time-of-day-context* + void* add_to_sprite_aux_list; // add-to-sprite-aux-list + void* cos; // cos + void* new_sound_id; // new-sound-id + void* particle_adgif; // particle-adgif + void* quaternion_axis_angle; // quaternion-axis-angle! + void* sin; // sin + void* sound_play_by_spec; // sound-play-by-spec + void* sp_adjust_launch; // sp-adjust-launch + void* sp_euler_convert; // sp-euler-convert + void* sp_get_particle; // sp-get-particle + void* sp_init_fields; // sp-init-fields! + void* sp_queue_launch; // sp-queue-launch + void* sp_rotate_system; // sp-rotate-system +} cache; + +u64 execute(void* ctxt) { + auto* c = (ExecutionContext*)ctxt; + bool bc = false; + u32 call_addr = 0; + c->mov64(v1, a0); // or v1, a0, r0 + c->mov64(v1, a1); // or v1, a1, r0 + c->mov64(v1, a2); // or v1, a2, r0 + c->mov64(v1, a3); // or v1, a3, r0 + c->mov64(v1, t0); // or v1, t0, r0 + c->mov64(v1, t1); // or v1, t1, r0 + // nop // sll r0, r0, 0 + c->daddiu(sp, sp, -304); // daddiu sp, sp, -304 + // nop // sll r0, r0, 0 + c->load_symbol2(v1, cache.sp_launcher_enable); // lw v1, *sp-launcher-enable*(s7) + c->sw(ra, 0, sp); // sw ra, 0(sp) + bc = c->sgpr64(v1) == c->sgpr64(s7); // beq v1, s7, L219 + c->sq(s0, 16, sp); // sq s0, 16(sp) + if (bc) {goto block_6;} // branch non-likely + + c->load_symbol2(v1, cache.sp_launcher_lock); // lw v1, *sp-launcher-lock*(s7) + c->sq(s1, 32, sp); // sq s1, 32(sp) + bc = c->sgpr64(v1) == c->sgpr64(s7); // beq v1, s7, L221 + c->sq(s2, 48, sp); // sq s2, 48(sp) + if (bc) {goto block_8;} // branch non-likely + + bc = c->sgpr64(a3) != c->sgpr64(s7); // bne a3, s7, L220 + c->lui(v1, 16256); // lui v1, 16256 + if (bc) {goto block_7;} // branch non-likely + + bc = c->sgpr64(t0) != c->sgpr64(s7); // bne t0, s7, L220 + // nop // sll r0, r0, 0 + if (bc) {goto block_7;} // branch non-likely + + bc = c->sgpr64(t1) != c->sgpr64(v1); // bne t1, v1, L220 + // nop // sll r0, r0, 0 + if (bc) {goto block_7;} // branch non-likely + + c->load_symbol2(t9, cache.sp_queue_launch); // lw t9, sp-queue-launch(s7) + // nop // sll r0, r0, 0 + call_addr = c->gprs[t9].du32[0]; // function call: + // nop // sll r0, r0, 0 + c->jalr(call_addr); // jalr ra, t9 + c->lw(ra, 0, sp); // lw ra, 0(sp) + // nop // sll r0, r0, 0 + + block_6: + //jr ra // jr ra + c->daddiu(sp, sp, 304); // daddiu sp, sp, 304 + goto end_of_function; // return + + + block_7: + c->sd(r0, 2, r0); // sd r0, 2(r0) + // nop // sll r0, r0, 0 + + block_8: + c->sq(s3, 240, sp); // sq s3, 240(sp) + // nop // sll r0, r0, 0 + c->sq(s4, 256, sp); // sq s4, 256(sp) + // nop // sll r0, r0, 0 + c->sq(s5, 272, sp); // sq s5, 272(sp) + // nop // sll r0, r0, 0 + c->sq(s6, 288, sp); // sq s6, 288(sp) + c->sqc2(vf0, 128, sp); // sqc2 vf0, 128(sp) + c->lqc2(vf30, 0, a2); // lqc2 vf30, 0(a2) + c->sqc2(vf30, 80, sp); // sqc2 vf30, 80(sp) + c->lqc2(vf30, 16, a2); // lqc2 vf30, 16(a2) + c->sqc2(vf30, 96, sp); // sqc2 vf30, 96(sp) + c->lqc2(vf30, 32, a2); // lqc2 vf30, 32(a2) + c->sqc2(vf30, 112, sp); // sqc2 vf30, 112(sp) + c->lqc2(vf30, 48, a2); // lqc2 vf30, 48(a2) + c->mtc1(f1, t1); // mtc1 f1, t1 + c->sqc2(vf30, 64, sp); // sqc2 vf30, 64(sp) + c->lui(v1, 17279); // lui v1, 17279 + c->mov64(s3, a0); // or s3, a0, r0 + c->mov128_vf_gpr(vf31, v1); // qmtc2.i vf31, v1 + c->mov64(s4, a1); // or s4, a1, r0 + c->lw(s6, 24, s3); // lw s6, 24(s3) + c->mov64(s0, a3); // or s0, a3, r0 + c->mov64(s1, t0); // or s1, t0, r0 + c->lw(a1, 8, a1); // lw a1, 8(a1) + c->daddiu(a0, sp, 160); // daddiu a0, sp, 160 + c->addiu(a2, r0, 0); // addiu a2, r0, 0 + c->addiu(a3, r0, 8); // addiu a3, r0, 8 + c->load_symbol2(t9, cache.sp_init_fields); // lw t9, sp-init-fields!(s7) + c->daddiu(t0, s7, 4); // daddiu t0, s7, 4 + call_addr = c->gprs[t9].du32[0]; // function call: + // nop // sll r0, r0, 0 + c->jalr(call_addr); // jalr ra, t9 + c->sw(v0, 12, sp); // sw v0, 12(sp) + // nop // sll r0, r0, 0 + c->lwc1(f2, 180, sp); // lwc1 f2, 180(sp) + // nop // sll r0, r0, 0 + bc = c->sgpr64(s0) == c->sgpr64(s7); // beq s0, s7, L222 + c->muls(f1, f2, f1); // mul.s f1, f2, f1 + if (bc) {goto block_11;} // branch non-likely + + c->lwc1(f2, 24, s0); // lwc1 f2, 24(s0) + // nop // sll r0, r0, 0 + c->adds(f2, f2, f1); // add.s f2, f2, f1 + // nop // sll r0, r0, 0 + c->swc1(f2, 24, s0); // swc1 f2, 24(s0) + // nop // sll r0, r0, 0 + c->cvtws(f2, f2); // cvt.w.s f2, f2 + // nop // sll r0, r0, 0 + c->sw(s1, 32, s0); // sw s1, 32(s0) + // nop // sll r0, r0, 0 + c->mfc1(v1, f2); // mfc1 v1, f2 + // nop // sll r0, r0, 0 + bc = c->sgpr64(v1) == 0; // beq v1, r0, L250 + // nop // sll r0, r0, 0 + if (bc) {goto block_79;} // branch non-likely + + //beq r0, r0, L223 // beq r0, r0, L223 + // nop // sll r0, r0, 0 + goto block_12; // branch always + + + block_11: + // nop // sll r0, r0, 0 + c->lwc1(f2, 0, s4); // lwc1 f2, 0(s4) + // nop // sll r0, r0, 0 + c->adds(f2, f2, f1); // add.s f2, f2, f1 + // nop // sll r0, r0, 0 + c->swc1(f2, 0, s4); // swc1 f2, 0(s4) + // nop // sll r0, r0, 0 + c->cvtws(f2, f2); // cvt.w.s f2, f2 + // nop // sll r0, r0, 0 + c->mfc1(v1, f2); // mfc1 v1, f2 + // nop // sll r0, r0, 0 + bc = c->sgpr64(v1) == 0; // beq v1, r0, L250 + // nop // sll r0, r0, 0 + if (bc) {goto block_79;} // branch non-likely + + + block_12: + c->addiu(a1, r0, 0); // addiu a1, r0, 0 + c->mov64(a2, s7); // or a2, s7, r0 + bc = c->sgpr64(s1) == c->sgpr64(s7); // beq s1, s7, L224 + // nop // sll r0, r0, 0 + if (bc) {goto block_15;} // branch non-likely + + c->lw(v1, 12, s1); // lw v1, 12(s1) + bc = c->sgpr64(v1) == c->sgpr64(s7); // beq v1, s7, L224 + // nop // sll r0, r0, 0 + if (bc) {goto block_15;} // branch non-likely + + c->lh(v1, 6, v1); // lh v1, 6(v1) + c->andi(a0, v1, 4); // andi a0, v1, 4 + c->addiu(a3, r0, 1); // addiu a3, r0, 1 + c->movn(a1, a3, a0); // movn a1, a3, a0 + c->andi(a0, v1, 8); // andi a0, v1, 8 + c->movn(a2, s0, a0); // movn a2, s0, a0 + // nop // sll r0, r0, 0 + + block_15: + c->load_symbol2(t9, cache.sp_get_particle); // lw t9, sp-get-particle(s7) + c->mov64(a0, s3); // or a0, s3, r0 + call_addr = c->gprs[t9].du32[0]; // function call: + // nop // sll r0, r0, 0 + c->jalr(call_addr); // jalr ra, t9 + bc = c->sgpr64(v0) == c->sgpr64(s7); // beq v0, s7, L250 + c->mov64(s2, v0); // or s2, v0, r0 + if (bc) {goto block_79;} // branch non-likely + + c->daddiu(a0, sp, 192); // daddiu a0, sp, 192 + c->lw(a1, 12, sp); // lw a1, 12(sp) + c->addiu(a2, r0, 9); // addiu a2, r0, 9 + c->addiu(a3, r0, 22); // addiu a3, r0, 22 + c->load_symbol2(t9, cache.sp_init_fields); // lw t9, sp-init-fields!(s7) + c->daddiu(t0, s7, 4); // daddiu t0, s7, 4 + call_addr = c->gprs[t9].du32[0]; // function call: + // nop // sll r0, r0, 0 + c->jalr(call_addr); // jalr ra, t9 + c->daddiu(a0, s2, 12); // daddiu a0, s2, 12 + c->mov64(a1, v0); // or a1, v0, r0 + c->addiu(a2, r0, 23); // addiu a2, r0, 23 + c->addiu(a3, r0, 52); // addiu a3, r0, 52 + call_addr = c->gprs[t9].du32[0]; // function call: + c->daddiu(t0, s7, 4); // daddiu t0, s7, 4 + c->jalr(call_addr); // jalr ra, t9 + c->sw(v0, 144, sp); // sw v0, 144(sp) + // nop // sll r0, r0, 0 + c->lw(s5, 104, s2); // lw s5, 104(s2) + // nop // sll r0, r0, 0 + bc = c->sgpr64(s6) != c->sgpr64(s7); // bne s6, s7, L227 + // nop // sll r0, r0, 0 + if (bc) {goto block_24;} // branch non-likely + + bc = c->sgpr64(s1) == c->sgpr64(s7); // beq s1, s7, L225 + // nop // sll r0, r0, 0 + if (bc) {goto block_22;} // branch non-likely + + c->lw(v1, 12, s1); // lw v1, 12(s1) + bc = c->sgpr64(v1) == c->sgpr64(s7); // beq v1, s7, L225 + // nop // sll r0, r0, 0 + if (bc) {goto block_22;} // branch non-likely + + c->lh(v1, 6, v1); // lh v1, 6(v1) + c->andi(v1, v1, 4); // andi v1, v1, 4 + c->mov64(a0, s5); // or a0, s5, r0 + bc = c->sgpr64(v1) == 0; // beq v1, r0, L225 + c->lb(v1, 28, s1); // lb v1, 28(s1) + if (bc) {goto block_22;} // branch non-likely + + c->andi(a1, a0, 32768); // andi a1, a0, 32768 + // nop // sll r0, r0, 0 + bc = c->sgpr64(a1) != 0; // bne a1, r0, L226 + // nop // sll r0, r0, 0 + if (bc) {goto block_23;} // branch non-likely + + c->andi(a0, a0, 128); // andi a0, a0, 128 + c->addiu(a1, r0, 1); // addiu a1, r0, 1 + c->movn(v1, a1, a0); // movn v1, a1, a0 + // nop // sll r0, r0, 0 + //beq r0, r0, L226 // beq r0, r0, L226 + c->sw(v1, 212, sp); // sw v1, 212(sp) + goto block_23; // branch always + + + block_22: + c->andi(v1, s5, 16384); // andi v1, s5, 16384 + // nop // sll r0, r0, 0 + c->dsra(v1, v1, 14); // dsra v1, v1, 14 + // nop // sll r0, r0, 0 + c->sw(v1, 212, sp); // sw v1, 212(sp) + // nop // sll r0, r0, 0 + + block_23: + c->lwc1(f2, 216, sp); // lwc1 f2, 216(sp) + // nop // sll r0, r0, 0 + c->cvtws(f2, f2); // cvt.w.s f2, f2 + // nop // sll r0, r0, 0 + c->mfc1(v1, f2); // mfc1 v1, f2 + // nop // sll r0, r0, 0 + c->dsll32(v1, v1, 16); // dsll32 v1, v1, 16 + // nop // sll r0, r0, 0 + c->dsra32(v1, v1, 16); // dsra32 v1, v1, 16 + // nop // sll r0, r0, 0 + c->mtc1(f2, v1); // mtc1 f2, v1 + // nop // sll r0, r0, 0 + c->cvtsw(f2, f2); // cvt.s.w f2, f2 + // nop // sll r0, r0, 0 + c->swc1(f2, 216, sp); // swc1 f2, 216(sp) + // nop // sll r0, r0, 0 + + block_24: + c->andi(v1, s5, 128); // andi v1, s5, 128 + c->lqc2(vf4, 224, sp); // lqc2 vf4, 224(sp) + bc = c->sgpr64(v1) != 0; // bne v1, r0, L228 + c->vmini_bc(DEST::xyz, BC::x, vf4, vf4, vf31); // vminix.xyz vf4, vf4, vf31 + if (bc) {goto block_26;} // branch non-likely + + // nop // sll r0, r0, 0 + c->vftoi0(DEST::xyzw, vf4, vf4); // vftoi0.xyzw vf4, vf4 + // nop // sll r0, r0, 0 + c->vitof0(DEST::xyzw, vf4, vf4); // vitof0.xyzw vf4, vf4 + c->addiu(v1, r0, -2); // addiu v1, r0, -2 + c->mov128_gpr_vf(a0, vf4); // qmfc2.i a0, vf4 + c->and_(a0, a0, v1); // and a0, a0, v1 + c->andi(v1, s5, 16384); // andi v1, s5, 16384 + c->sra(v1, v1, 14); // sra v1, v1, 14 + // nop // sll r0, r0, 0 + c->or_(a0, a0, v1); // or a0, a0, v1 + // nop // sll r0, r0, 0 + c->sq(a0, 224, sp); // sq a0, 224(sp) + // nop // sll r0, r0, 0 + + block_26: + c->addiu(v1, r0, 8); // addiu v1, r0, 8 + c->sb(v1, 129, s2); // sb v1, 129(s2) + bc = c->sgpr64(s1) == c->sgpr64(s7); // beq s1, s7, L229 + c->andi(v1, s5, 64); // andi v1, s5, 64 + if (bc) {goto block_29;} // branch non-likely + + c->lwu(a0, 16, s1); // lwu a0, 16(s1) + c->lwu(a0, 8, a0); // lwu a0, 8(a0) + c->lw(a0, 0, a0); // lw a0, 0(a0) + c->sb(a0, 129, s2); // sb a0, 129(s2) + bc = c->sgpr64(v1) == 0; // beq v1, r0, L229 + c->lw(a0, 192, sp); // lw a0, 192(sp) + if (bc) {goto block_29;} // branch non-likely + + c->load_symbol2(t9, cache.cos); // lw t9, cos(s7) + // nop // sll r0, r0, 0 + call_addr = c->gprs[t9].du32[0]; // function call: + // nop // sll r0, r0, 0 + c->jalr(call_addr); // jalr ra, t9 + c->mov64(a1, v0); // or a1, v0, r0 + c->lw(a0, 192, sp); // lw a0, 192(sp) + c->load_symbol2(t9, cache.sin); // lw t9, sin(s7) + // nop // sll r0, r0, 0 + call_addr = c->gprs[t9].du32[0]; // function call: + // nop // sll r0, r0, 0 + c->jalr(call_addr); // jalr ra, t9 + c->ori(v1, r0, 32768); // ori v1, r0, 32768 + c->dsll(v1, v1, 16); // dsll v1, v1, 16 + c->lw(a0, 200, sp); // lw a0, 200(sp) + c->xor_(a3, v0, v1); // xor a3, v0, v1 + c->sw(a0, 8, s2); // sw a0, 8(s2) + c->gprs[a2].du64[0] = 0; // or a2, r0, r0 + c->lw(t0, 196, sp); // lw t0, 196(sp) + c->load_symbol2(t9, cache.quaternion_axis_angle); // lw t9, quaternion-axis-angle!(s7) + c->daddiu(a0, s2, 80); // daddiu a0, s2, 80 + call_addr = c->gprs[t9].du32[0]; // function call: + // nop // sll r0, r0, 0 + c->jalr(call_addr); // jalr ra, t9 + c->lw(v1, 16, s0); // lw v1, 16(s0) + // nop // sll r0, r0, 0 + c->lw(v1, 0, v1); // lw v1, 0(v1) + // nop // sll r0, r0, 0 + c->sw(v1, 108, s2); // sw v1, 108(s2) + // nop // sll r0, r0, 0 + + block_29: + c->sw(s7, 136, s2); // sw s7, 136(s2) + // nop // sll r0, r0, 0 + bc = c->sgpr64(s0) == c->sgpr64(s7); // beq s0, s7, L233 + // nop // sll r0, r0, 0 + if (bc) {goto block_38;} // branch non-likely + + c->lw(a0, 0, s0); // lw a0, 0(s0) + // nop // sll r0, r0, 0 + c->lw(a1, 24, a0); // lw a1, 24(a0) + // nop // sll r0, r0, 0 + bc = c->sgpr64(a1) == 0; // beq a1, r0, L233 + // nop // sll r0, r0, 0 + if (bc) {goto block_38;} // branch non-likely + + c->lw(a2, 0, s1); // lw a2, 0(s1) + c->daddiu(a3, s1, 108); // daddiu a3, s1, 108 + + block_32: + c->lw(v1, 0, a3); // lw v1, 0(a3) + c->daddiu(a2, a2, -1); // daddiu a2, a2, -1 + c->lw(v1, 0, v1); // lw v1, 0(v1) + // nop // sll r0, r0, 0 + bc = c->sgpr64(v1) != c->sgpr64(a1); // bne v1, a1, L232 + c->lh(v1, 4, a3); // lh v1, 4(a3) + if (bc) {goto block_37;} // branch non-likely + + c->andi(a0, v1, 1); // andi a0, v1, 1 + c->ori(v1, v1, 1); // ori v1, v1, 1 + bc = c->sgpr64(a0) != 0; // bne a0, r0, L232 + // nop // sll r0, r0, 0 + if (bc) {goto block_37;} // branch non-likely + + c->sh(v1, 4, a3); // sh v1, 4(a3) + // nop // sll r0, r0, 0 + c->lw(v1, 0, s2); // lw v1, 0(s2) + // nop // sll r0, r0, 0 + c->sw(v1, 8, a3); // sw v1, 8(a3) + c->mov64(a0, s7); // or a0, s7, r0 + if (((s64)c->sgpr64(s6)) != ((s64)c->sgpr64(s7))) {// bnel s6, s7, L231 + c->lw(a0, 0, s2); // lw a0, 0(s2) + goto block_36; + } + + block_36: + c->sw(a0, 12, a3); // sw a0, 12(a3) + // nop // sll r0, r0, 0 + c->sw(s2, 16, a3); // sw s2, 16(a3) + // nop // sll r0, r0, 0 + c->sw(a3, 136, s2); // sw a3, 136(s2) + // nop // sll r0, r0, 0 + //beq r0, r0, L233 // beq r0, r0, L233 + // nop // sll r0, r0, 0 + goto block_38; // branch always + + + block_37: + bc = c->sgpr64(a2) != 0; // bne a2, r0, L230 + c->daddiu(a3, a3, 48); // daddiu a3, a3, 48 + if (bc) {goto block_32;} // branch non-likely + + + block_38: + c->lw(a2, 144, sp); // lw a2, 144(sp) + c->daddiu(a0, sp, 192); // daddiu a0, sp, 192 + c->lh(v1, 0, a2); // lh v1, 0(a2) + c->mov64(a1, s2); // or a1, s2, r0 + c->load_symbol2(t9, cache.sp_adjust_launch); // lw t9, sp-adjust-launch(s7) + c->daddiu(v1, v1, -64); // daddiu v1, v1, -64 + bc = ((s64)c->sgpr64(v1)) >= 0; // bgez v1, L234 + c->daddiu(a3, sp, 80); // daddiu a3, sp, 80 + if (bc) {goto block_40;} // branch non-likely + + call_addr = c->gprs[t9].du32[0]; // function call: + c->mov64(t0, s6); // or t0, s6, r0 + c->jalr(call_addr); // jalr ra, t9 + + block_40: + bc = c->sgpr64(s6) == c->sgpr64(s7); // beq s6, s7, L235 + // nop // sll r0, r0, 0 + if (bc) {goto block_42;} // branch non-likely + + c->load_symbol2(t9, cache.sp_euler_convert); // lw t9, sp-euler-convert(s7) + c->daddiu(a0, sp, 192); // daddiu a0, sp, 192 + call_addr = c->gprs[t9].du32[0]; // function call: + c->mov64(a1, s2); // or a1, s2, r0 + c->jalr(call_addr); // jalr ra, t9 + + block_42: + bc = c->sgpr64(s0) == c->sgpr64(s7); // beq s0, s7, L236 + // nop // sll r0, r0, 0 + if (bc) {goto block_46;} // branch non-likely + + c->lw(a2, 12, s0); // lw a2, 12(s0) + // nop // sll r0, r0, 0 + bc = c->sgpr64(a2) == c->sgpr64(s7); // beq a2, s7, L236 + c->daddiu(a0, sp, 192); // daddiu a0, sp, 192 + if (bc) {goto block_46;} // branch non-likely + + bc = c->sgpr64(a2) == 0; // beq a2, r0, L236 + c->mov64(a1, s2); // or a1, s2, r0 + if (bc) {goto block_46;} // branch non-likely + + c->load_symbol2(t9, cache.sp_rotate_system); // lw t9, sp-rotate-system(s7) + // nop // sll r0, r0, 0 + call_addr = c->gprs[t9].du32[0]; // function call: + // nop // sll r0, r0, 0 + c->jalr(call_addr); // jalr ra, t9 + + block_46: + c->lqc2(vf4, 192, sp); // lqc2 vf4, 192(sp) + // nop // sll r0, r0, 0 + c->vadd(DEST::xyz, vf4, vf4, vf30); // vadd.xyz vf4, vf4, vf30 + c->lw(a0, 4, s2); // lw a0, 4(s2) + c->lw(a1, 160, sp); // lw a1, 160(sp) + // nop // sll r0, r0, 0 + c->load_symbol2(t9, cache.particle_adgif); // lw t9, particle-adgif(s7) + // nop // sll r0, r0, 0 + c->sqc2(vf4, 192, sp); // sqc2 vf4, 192(sp) + // nop // sll r0, r0, 0 + call_addr = c->gprs[t9].du32[0]; // function call: + // nop // sll r0, r0, 0 + c->jalr(call_addr); // jalr ra, t9 + c->lw(a2, 4, s2); // lw a2, 4(s2) + c->lui(a3, 256); // lui a3, 256 + c->lw(v1, 64, a2); // lw v1, 64(a2) + c->andi(a0, s5, 16); // andi a0, s5, 16 + c->addiu(a1, r0, 66); // addiu a1, r0, 66 + // nop // sll r0, r0, 0 + c->movn(v1, a1, a0); // movn v1, a1, a0 + c->andi(a0, s5, 8); // andi a0, s5, 8 + c->addiu(a1, r0, 72); // addiu a1, r0, 72 + // nop // sll r0, r0, 0 + c->movn(v1, a1, a0); // movn v1, a1, a0 + c->andi(a0, s5, 256); // andi a0, s5, 256 + c->sw(v1, 64, a2); // sw v1, 64(a2) + c->ori(a1, a3, 304); // ori a1, a3, 304 + if (((s64)c->sgpr64(a0)) != ((s64)0)) { // bnel a0, r0, L237 + c->sd(a1, 48, a2); // sd a1, 48(a2) + goto block_48; + } + + block_48: + c->lw(t9, 172, sp); // lw t9, 172(sp) + c->mov64(a1, s2); // or a1, s2, r0 + c->mov64(a0, s3); // or a0, s3, r0 + c->mov64(t0, s0); // or t0, s0, r0 + bc = c->sgpr64(t9) == 0; // beq t9, r0, L238 + c->daddiu(a2, sp, 192); // daddiu a2, sp, 192 + if (bc) {goto block_50;} // branch non-likely + + call_addr = c->gprs[t9].du32[0]; // function call: + c->mov64(a3, s4); // or a3, s4, r0 + c->jalr(call_addr); // jalr ra, t9 + + block_50: + c->lw(a0, 184, sp); // lw a0, 184(sp) + // nop // sll r0, r0, 0 + c->lwc1(f2, 4, s4); // lwc1 f2, 4(s4) + c->lui(a1, 16256); // lui a1, 16256 + bc = c->sgpr64(a0) == 0; // beq a0, r0, L239 + // nop // sll r0, r0, 0 + if (bc) {goto block_53;} // branch non-likely + + c->lwc1(f3, 4, a0); // lwc1 f3, 4(a0) + // nop // sll r0, r0, 0 + c->adds(f2, f2, f3); // add.s f2, f2, f3 + // nop // sll r0, r0, 0 + c->swc1(f2, 4, s4); // swc1 f2, 4(s4) + c->mtc1(f3, a1); // mtc1 f3, a1 + c->subs(f2, f2, f3); // sub.s f2, f2, f3 + // nop // sll r0, r0, 0 + c->mfc1(a1, f2); // mfc1 a1, f2 + // nop // sll r0, r0, 0 + bc = ((s64)c->sgpr64(a1)) < 0; // bltz a1, L239 + c->load_symbol2(t9, cache.new_sound_id); // lw t9, new-sound-id(s7) + if (bc) {goto block_53;} // branch non-likely + + c->sw(a1, 4, s4); // sw a1, 4(s4) + // nop // sll r0, r0, 0 + call_addr = c->gprs[t9].du32[0]; // function call: + // nop // sll r0, r0, 0 + c->jalr(call_addr); // jalr ra, t9 + c->lw(a0, 184, sp); // lw a0, 184(sp) + c->mov64(a1, v0); // or a1, v0, r0 + c->load_symbol2(t9, cache.sound_play_by_spec); // lw t9, sound-play-by-spec(s7) + c->daddiu(a2, sp, 64); // daddiu a2, sp, 64 + call_addr = c->gprs[t9].du32[0]; // function call: + // nop // sll r0, r0, 0 + c->jalr(call_addr); // jalr ra, t9 + + block_53: + c->addiu(a0, r0, 4); // addiu a0, r0, 4 + c->andi(v1, s5, 128); // andi v1, s5, 128 + bc = c->sgpr64(v1) == 0; // beq v1, r0, L240 + c->dsubu(a0, r0, a0); // dsubu a0, r0, a0 + if (bc) {goto block_55;} // branch non-likely + + c->load_symbol2(v1, cache.add_to_sprite_aux_list);// lw v1, add-to-sprite-aux-list(s7) + c->daddiu(a0, a0, -1); // daddiu a0, a0, -1 + // nop // sll r0, r0, 0 + c->and_(s5, s5, a0); // and s5, s5, a0 + c->sw(r0, 236, sp); // sw r0, 236(sp) + // nop // sll r0, r0, 0 + c->sw(r0, 60, s2); // sw r0, 60(s2) + // nop // sll r0, r0, 0 + c->lw(v1, 208, sp); // lw v1, 208(sp) + c->addiu(a0, r0, 3); // addiu a0, r0, 3 + c->pmaxw(v1, v1, a0); // pmaxw v1, v1, a0 + c->addiu(a0, r0, 11); // addiu a0, r0, 11 + c->pminw(v1, v1, a0); // pminw v1, v1, a0 + // nop // sll r0, r0, 0 + c->sw(v1, 208, sp); // sw v1, 208(sp) + // nop // sll r0, r0, 0 + + block_55: + c->load_symbol2(a0, cache.level); // lw a0, *level*(s7) + // nop // sll r0, r0, 0 + c->lw(v1, 300, a0); // lw v1, 300(a0) + // nop // sll r0, r0, 0 + c->dsubu(v1, s4, v1); // dsubu v1, s4, v1 + // nop // sll r0, r0, 0 + bc = ((s64)c->sgpr64(v1)) < 0; // bltz v1, L241 + // nop // sll r0, r0, 0 + if (bc) {goto block_58;} // branch non-likely + + c->lw(v1, 304, a0); // lw v1, 304(a0) + // nop // sll r0, r0, 0 + c->dsubu(v1, s4, v1); // dsubu v1, s4, v1 + // nop // sll r0, r0, 0 + bc = ((s64)c->sgpr64(v1)) >= 0; // bgez v1, L241 + // nop // sll r0, r0, 0 + if (bc) {goto block_58;} // branch non-likely + + //beq r0, r0, L246 // beq r0, r0, L246 + c->mov64(s5, s5); // or s5, s5, r0 + goto block_71; // branch always + + + block_58: + c->lw(v1, 5532, a0); // lw v1, 5532(a0) + // nop // sll r0, r0, 0 + c->dsubu(v1, s4, v1); // dsubu v1, s4, v1 + // nop // sll r0, r0, 0 + bc = ((s64)c->sgpr64(v1)) < 0; // bltz v1, L242 + // nop // sll r0, r0, 0 + if (bc) {goto block_61;} // branch non-likely + + c->lw(v1, 5536, a0); // lw v1, 5536(a0) + // nop // sll r0, r0, 0 + c->dsubu(v1, s4, v1); // dsubu v1, s4, v1 + // nop // sll r0, r0, 0 + bc = ((s64)c->sgpr64(v1)) >= 0; // bgez v1, L242 + // nop // sll r0, r0, 0 + if (bc) {goto block_61;} // branch non-likely + + //beq r0, r0, L246 // beq r0, r0, L246 + c->ori(s5, s5, 512); // ori s5, s5, 512 + goto block_71; // branch always + + + block_61: + c->lw(v1, 10764, a0); // lw v1, 10764(a0) + // nop // sll r0, r0, 0 + c->dsubu(v1, s4, v1); // dsubu v1, s4, v1 + // nop // sll r0, r0, 0 + bc = ((s64)c->sgpr64(v1)) < 0; // bltz v1, L243 + // nop // sll r0, r0, 0 + if (bc) {goto block_64;} // branch non-likely + + c->lw(v1, 10768, a0); // lw v1, 10768(a0) + // nop // sll r0, r0, 0 + c->dsubu(v1, s4, v1); // dsubu v1, s4, v1 + // nop // sll r0, r0, 0 + bc = ((s64)c->sgpr64(v1)) >= 0; // bgez v1, L243 + // nop // sll r0, r0, 0 + if (bc) {goto block_64;} // branch non-likely + + //beq r0, r0, L246 // beq r0, r0, L246 + c->ori(s5, s5, 1024); // ori s5, s5, 1024 + goto block_71; // branch always + + + block_64: + c->lw(v1, 15996, a0); // lw v1, 15996(a0) + // nop // sll r0, r0, 0 + c->dsubu(v1, s4, v1); // dsubu v1, s4, v1 + // nop // sll r0, r0, 0 + bc = ((s64)c->sgpr64(v1)) < 0; // bltz v1, L244 + // nop // sll r0, r0, 0 + if (bc) {goto block_67;} // branch non-likely + + c->lw(v1, 16000, a0); // lw v1, 16000(a0) + // nop // sll r0, r0, 0 + c->dsubu(v1, s4, v1); // dsubu v1, s4, v1 + // nop // sll r0, r0, 0 + bc = ((s64)c->sgpr64(v1)) >= 0; // bgez v1, L244 + // nop // sll r0, r0, 0 + if (bc) {goto block_67;} // branch non-likely + + //beq r0, r0, L246 // beq r0, r0, L246 + c->ori(s5, s5, 1536); // ori s5, s5, 1536 + goto block_71; // branch always + + + block_67: + c->lw(v1, 21228, a0); // lw v1, 21228(a0) + // nop // sll r0, r0, 0 + c->dsubu(v1, s4, v1); // dsubu v1, s4, v1 + // nop // sll r0, r0, 0 + bc = ((s64)c->sgpr64(v1)) < 0; // bltz v1, L245 + // nop // sll r0, r0, 0 + if (bc) {goto block_70;} // branch non-likely + + c->lw(v1, 21232, a0); // lw v1, 21232(a0) + // nop // sll r0, r0, 0 + c->dsubu(v1, s4, v1); // dsubu v1, s4, v1 + // nop // sll r0, r0, 0 + bc = ((s64)c->sgpr64(v1)) >= 0; // bgez v1, L245 + // nop // sll r0, r0, 0 + if (bc) {goto block_70;} // branch non-likely + + //beq r0, r0, L246 // beq r0, r0, L246 + c->ori(s5, s5, 2048); // ori s5, s5, 2048 + goto block_71; // branch always + + + block_70: + c->ori(s5, s5, 2560); // ori s5, s5, 2560 + // nop // sll r0, r0, 0 + + block_71: + c->andi(v1, s5, 4224); // andi v1, s5, 4224 + c->addiu(a0, r0, 4096); // addiu a0, r0, 4096 + bc = c->sgpr64(v1) != c->sgpr64(a0); // bne v1, a0, L247 + c->load_symbol2(a0, cache.time_of_day_context); // lw a0, *time-of-day-context*(s7) + if (bc) {goto block_73;} // branch non-likely + + c->lqc2(vf4, 108, a0); // lqc2 vf4, 108(a0) + // nop // sll r0, r0, 0 + c->lqc2(vf5, 224, sp); // lqc2 vf5, 224(sp) + // nop // sll r0, r0, 0 + c->lqc2(vf6, 48, s2); // lqc2 vf6, 48(s2) + // nop // sll r0, r0, 0 + c->vmul(DEST::xyz, vf5, vf5, vf4); // vmul.xyz vf5, vf5, vf4 + // nop // sll r0, r0, 0 + c->vmul(DEST::xyz, vf6, vf6, vf4); // vmul.xyz vf6, vf6, vf4 + // nop // sll r0, r0, 0 + c->sqc2(vf5, 224, sp); // sqc2 vf5, 224(sp) + // nop // sll r0, r0, 0 + //beq r0, r0, L248 // beq r0, r0, L248 + c->sqc2(vf6, 48, s2); // sqc2 vf6, 48(s2) + goto block_75; // branch always + + + block_73: + // nop // sll r0, r0, 0 + c->andi(v1, s5, 128); // andi v1, s5, 128 + bc = c->sgpr64(v1) != 0; // bne v1, r0, L248 + c->lqc2(vf5, 224, sp); // lqc2 vf5, 224(sp) + if (bc) {goto block_75;} // branch non-likely + + c->lqc2(vf6, 48, s2); // lqc2 vf6, 48(s2) + // nop // sll r0, r0, 0 + c->sqc2(vf5, 224, sp); // sqc2 vf5, 224(sp) + // nop // sll r0, r0, 0 + c->sqc2(vf6, 48, s2); // sqc2 vf6, 48(s2) + // nop // sll r0, r0, 0 + + block_75: + c->mov64(v1, s1); // or v1, s1, r0 + c->dsubu(a0, s1, s7); // dsubu a0, s1, s7 + c->movz(v1, r0, a0); // movz v1, r0, a0 + // nop // sll r0, r0, 0 + c->sw(v1, 132, s2); // sw v1, 132(s2) + // nop // sll r0, r0, 0 + c->lw(v1, 0, s2); // lw v1, 0(s2) + // nop // sll r0, r0, 0 + c->lqc2(vf4, 192, sp); // lqc2 vf4, 192(sp) + // nop // sll r0, r0, 0 + c->lqc2(vf5, 208, sp); // lqc2 vf5, 208(sp) + // nop // sll r0, r0, 0 + c->lqc2(vf6, 224, sp); // lqc2 vf6, 224(sp) + // nop // sll r0, r0, 0 + c->sqc2(vf4, 0, v1); // sqc2 vf4, 0(v1) + // nop // sll r0, r0, 0 + c->sqc2(vf5, 16, v1); // sqc2 vf5, 16(v1) + // nop // sll r0, r0, 0 + c->vsub_bc(DEST::w, BC::w, vf6, vf0, vf0); // vsubw.w vf6, vf0, vf0 + // nop // sll r0, r0, 0 + c->sqc2(vf6, 32, v1); // sqc2 vf6, 32(v1) + // nop // sll r0, r0, 0 + c->ori(s5, s5, 32); // ori s5, s5, 32 + c->lw(a0, 236, sp); // lw a0, 236(sp) + c->sw(s5, 104, s2); // sw s5, 104(s2) + // nop // sll r0, r0, 0 + c->sw(a0, 124, s2); // sw a0, 124(s2) + // nop // sll r0, r0, 0 + bc = c->sgpr64(s0) == c->sgpr64(s7); // beq s0, s7, L249 + c->lui(v1, 16256); // lui v1, 16256 + if (bc) {goto block_78;} // branch non-likely + + c->lwc1(f2, 24, s0); // lwc1 f2, 24(s0) + c->mtc1(f3, v1); // mtc1 f3, v1 + c->subs(f2, f2, f3); // sub.s f2, f2, f3 + // nop // sll r0, r0, 0 + c->swc1(f2, 24, s0); // swc1 f2, 24(s0) + c->cvtws(f2, f2); // cvt.w.s f2, f2 + c->mfc1(v1, f2); // mfc1 v1, f2 + // nop // sll r0, r0, 0 + bc = c->sgpr64(v1) != 0; // bne v1, r0, L223 + // nop // sll r0, r0, 0 + if (bc) {goto block_12;} // branch non-likely + + //beq r0, r0, L250 // beq r0, r0, L250 + // nop // sll r0, r0, 0 + goto block_79; // branch always + + + block_78: + c->lwc1(f2, 0, s4); // lwc1 f2, 0(s4) + c->mtc1(f3, v1); // mtc1 f3, v1 + c->subs(f2, f2, f3); // sub.s f2, f2, f3 + // nop // sll r0, r0, 0 + c->swc1(f2, 0, s4); // swc1 f2, 0(s4) + c->cvtws(f2, f2); // cvt.w.s f2, f2 + c->mfc1(v1, f2); // mfc1 v1, f2 + // nop // sll r0, r0, 0 + bc = c->sgpr64(v1) != 0; // bne v1, r0, L223 + // nop // sll r0, r0, 0 + if (bc) {goto block_12;} // branch non-likely + + + block_79: + c->lw(ra, 0, sp); // lw ra, 0(sp) + // nop // sll r0, r0, 0 + c->lq(s0, 16, sp); // lq s0, 16(sp) + // nop // sll r0, r0, 0 + c->lq(s1, 32, sp); // lq s1, 32(sp) + // nop // sll r0, r0, 0 + c->lq(s2, 48, sp); // lq s2, 48(sp) + // nop // sll r0, r0, 0 + c->lq(s3, 240, sp); // lq s3, 240(sp) + // nop // sll r0, r0, 0 + c->lq(s4, 256, sp); // lq s4, 256(sp) + // nop // sll r0, r0, 0 + c->lq(s5, 272, sp); // lq s5, 272(sp) + // nop // sll r0, r0, 0 + c->lq(s6, 288, sp); // lq s6, 288(sp) + // nop // sll r0, r0, 0 + //jr ra // jr ra + c->daddiu(sp, sp, 304); // daddiu sp, sp, 304 + goto end_of_function; // return + + //jr ra // jr ra + c->daddu(sp, sp, r0); // daddu sp, sp, r0 + goto end_of_function; // return + + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + end_of_function: + return c->gprs[v0].du64[0]; +} + +void link() { + cache.level = intern_from_c("*level*").c(); + cache.sp_launcher_enable = intern_from_c("*sp-launcher-enable*").c(); + cache.sp_launcher_lock = intern_from_c("*sp-launcher-lock*").c(); + cache.time_of_day_context = intern_from_c("*time-of-day-context*").c(); + cache.add_to_sprite_aux_list = intern_from_c("add-to-sprite-aux-list").c(); + cache.cos = intern_from_c("cos").c(); + cache.new_sound_id = intern_from_c("new-sound-id").c(); + cache.particle_adgif = intern_from_c("particle-adgif").c(); + cache.quaternion_axis_angle = intern_from_c("quaternion-axis-angle!").c(); + cache.sin = intern_from_c("sin").c(); + cache.sound_play_by_spec = intern_from_c("sound-play-by-spec").c(); + cache.sp_adjust_launch = intern_from_c("sp-adjust-launch").c(); + cache.sp_euler_convert = intern_from_c("sp-euler-convert").c(); + cache.sp_get_particle = intern_from_c("sp-get-particle").c(); + cache.sp_init_fields = intern_from_c("sp-init-fields!").c(); + cache.sp_queue_launch = intern_from_c("sp-queue-launch").c(); + cache.sp_rotate_system = intern_from_c("sp-rotate-system").c(); + gLinkedFunctionTable.reg("sp-launch-particles-var", execute, 512); +} + +} // namespace sp_launch_particles_var +} // namespace Mips2C + +//--------------------------MIPS2C--------------------- +// clang-format off +#include "game/mips2c/mips2c_private.h" +#include "game/kernel/jak2/kscheme.h" +using ::jak2::intern_from_c; +namespace Mips2C::jak2 { +namespace sparticle_motion_blur { +struct Cache { + void* math_camera; // *math-camera* + void* atan; // atan +} cache; + + +u64 execute(void* ctxt) { + auto* c = (ExecutionContext*)ctxt; + bool bc = false; + u32 call_addr = 0; + bool cop1_bc = false; + uint32_t Clipping = 0; + c->daddiu(sp, sp, -80); // daddiu sp, sp, -80 + c->sd(ra, 0, sp); // sd ra, 0(sp) + c->sq(s3, 16, sp); // sq s3, 16(sp) + c->sq(s4, 32, sp); // sq s4, 32(sp) + c->sq(s5, 48, sp); // sq s5, 48(sp) + c->sq(gp, 64, sp); // sq gp, 64(sp) + c->mov64(s3, a1); // or s3, a1, r0 + c->mov64(gp, a2); // or gp, a2, r0 + c->ori(a0, r0, 65535); // ori a0, r0, 65535 + c->load_symbol2(v1, cache.math_camera); // lw v1, *math-camera*(s7) + c->dsll32(a1, a0, 16); // dsll32 a1, a0, 16 + c->lq(a0, 16, s3); // lq a0, 16(s3) + c->lqc2(vf1, 0, gp); // lqc2 vf1, 0(gp) + c->pceqw(a2, a0, r0); // pceqw a2, a0, r0 + c->lqc2(vf24, 572, v1); // lqc2 vf24, 572(v1) + c->ppach(a2, r0, a2); // ppach a2, r0, a2 + c->lqc2(vf25, 588, v1); // lqc2 vf25, 588(v1) + c->or_(a1, a2, a1); // or a1, a2, a1 + c->lqc2(vf26, 604, v1); // lqc2 vf26, 604(v1) + c->daddiu(a1, a1, 1); // daddiu a1, a1, 1 + c->lqc2(vf27, 620, v1); // lqc2 vf27, 620(v1) + bc = c->sgpr64(a1) == 0; // beq a1, r0, L36 + c->mov128_vf_gpr(vf4, a0); // qmtc2.i vf4, a0 + if (bc) {goto block_5;} // branch non-likely + + c->lui(a0, 16896); // lui a0, 16896 + c->lqc2(vf30, 812, v1); // lqc2 vf30, 812(v1) + c->lqc2(vf29, 780, v1); // lqc2 vf29, 780(v1) + c->vmula_bc(DEST::xyzw, BC::x, vf24, vf1); // vmulax.xyzw acc, vf24, vf1 + c->vmadda_bc(DEST::xyzw, BC::y, vf25, vf1); // vmadday.xyzw acc, vf25, vf1 + c->vmadda_bc(DEST::xyzw, BC::z, vf26, vf1); // vmaddaz.xyzw acc, vf26, vf1 + c->vmadd_bc(DEST::xyzw, BC::w, vf10, vf27, vf0); // vmaddw.xyzw vf10, vf27, vf0 + c->mov128_vf_gpr(vf5, a0); // qmtc2.i vf5, a0 + c->vmul(DEST::xyzw, vf12, vf10, vf29); // vmul.xyzw vf12, vf10, vf29 + c->vmula_bc(DEST::xyzw, BC::w, vf1, vf0); // vmulaw.xyzw acc, vf1, vf0 + c->vmadd_bc(DEST::xyzw, BC::x, vf1, vf4, vf5); // vmaddx.xyzw vf1, vf4, vf5 + c->vdiv(vf0, BC::w, vf12, BC::w); // vdiv Q, vf0.w, vf12.w + Clipping = c->clip(vf12, vf12, Clipping); // Unknown instr: vclip.xyz vf12, vf12 + c->vmula_bc(DEST::xyzw, BC::x, vf24, vf1); // vmulax.xyzw acc, vf24, vf1 + c->vmadda_bc(DEST::xyzw, BC::y, vf25, vf1); // vmadday.xyzw acc, vf25, vf1 + c->vmadda_bc(DEST::xyzw, BC::z, vf26, vf1); // vmaddaz.xyzw acc, vf26, vf1 + c->vmadd_bc(DEST::xyzw, BC::w, vf11, vf27, vf0); // vmaddw.xyzw vf11, vf27, vf0 + c->vwaitq(); // vwaitq + c->gprs[v1].du64[0] = Clipping; // cfc2.i v1, Clipping + c->vmulq(DEST::xyz, vf10, vf10); // vmulq.xyz vf10, vf10, Q + c->vmul(DEST::xyzw, vf13, vf11, vf29); // vmul.xyzw vf13, vf11, vf29 + c->andi(v1, v1, 63); // andi v1, v1, 63 + bc = c->sgpr64(v1) != 0; // bne v1, r0, L36 + c->vadd(DEST::xyzw, vf10, vf10, vf30); // vadd.xyzw vf10, vf10, vf30 + if (bc) {goto block_5;} // branch non-likely + + c->vdiv(vf0, BC::w, vf13, BC::w); // vdiv Q, vf0.w, vf13.w + Clipping = c->clip(vf13, vf13, Clipping); // Unknown instr: vclip.xyz vf13, vf13 + c->vmax_bc(DEST::w, BC::x, vf10, vf10, vf0); // vmaxx.w vf10, vf10, vf0 + c->vftoi4(DEST::xyzw, vf2, vf10); // vftoi4.xyzw vf2, vf10 + c->vwaitq(); // vwaitq + c->vmulq(DEST::xyz, vf11, vf11); // vmulq.xyz vf11, vf11, Q + c->gprs[v1].du64[0] = Clipping; // cfc2.i v1, Clipping + c->vitof0(DEST::xyzw, vf6, vf2); // vitof0.xyzw vf6, vf2 + c->vadd(DEST::xyzw, vf11, vf11, vf30); // vadd.xyzw vf11, vf11, vf30 + c->andi(v1, v1, 63); // andi v1, v1, 63 + bc = c->sgpr64(v1) != 0; // bne v1, r0, L36 + c->vdiv(vf0, BC::w, vf6, BC::z); // vdiv Q, vf0.w, vf6.z + if (bc) {goto block_5;} // branch non-likely + + c->vmax_bc(DEST::w, BC::x, vf11, vf11, vf0); // vmaxx.w vf11, vf11, vf0 + c->vadd_bc(DEST::x, BC::w, vf9, vf0, vf0); // vaddw.x vf9, vf0, vf0 + c->vftoi4(DEST::xyzw, vf3, vf11); // vftoi4.xyzw vf3, vf11 + c->vitof0(DEST::xyzw, vf7, vf3); // vitof0.xyzw vf7, vf3 + c->vsub(DEST::xy, vf8, vf7, vf6); // vsub.xy vf8, vf7, vf6 + c->mov128_gpr_vf(s4, vf8); // qmfc2.i s4, vf8 + c->dsra32(s5, s4, 0); // dsra32 s5, s4, 0 + c->vmulq(DEST::x, vf9, vf9); // vmulq.x vf9, vf9, Q + c->load_symbol2(t9, cache.atan); // lw t9, atan(s7) + c->mov64(a0, s4); // or a0, s4, r0 + c->mov64(a1, s5); // or a1, s5, r0 + call_addr = c->gprs[t9].du32[0]; // function call: + c->sll(v0, ra, 0); // sll v0, ra, 0 + c->jalr(call_addr); // jalr ra, t9 + c->mov64(a0, v0); // or a0, v0, r0 + c->lw(v1, 12, s3); // lw v1, 12(s3) + c->lui(a1, -14720); // lui a1, -14720 + c->mtc1(f0, a1); // mtc1 f0, a1 + c->mtc1(f1, a0); // mtc1 f1, a0 + c->adds(f0, f0, f1); // add.s f0, f0, f1 + c->swc1(f0, 24, gp); // swc1 f0, 24(gp) + bc = c->sgpr64(v1) == 0; // beq v1, r0, L37 + c->mov128_gpr_vf(a0, vf9); // qmfc2.i a0, vf9 + if (bc) {goto block_7;} // branch non-likely + + c->mtc1(f2, a0); // mtc1 f2, a0 + c->lui(a0, 16256); // lui a0, 16256 + c->mtc1(f1, r0); // mtc1 f1, r0 + c->lui(a1, 13702); // lui a1, 13702 + c->ori(a1, a1, 14269); // ori a1, a1, 14269 + c->lui(a2, 13337); // lui a2, 13337 + c->ori(a2, a2, 25670); // ori a2, a2, 25670 + c->mtc1(f0, a0); // mtc1 f0, a0 + c->mtc1(f3, a1); // mtc1 f3, a1 + c->mtc1(f4, a2); // mtc1 f4, a2 + c->subs(f2, f2, f3); // sub.s f2, f2, f3 + c->subs(f3, f4, f3); // sub.s f3, f4, f3 + c->divs(f2, f2, f3); // div.s f2, f2, f3 + c->mtc1(f3, s4); // mtc1 f3, s4 + c->mtc1(f4, s5); // mtc1 f4, s5 + // Unknown instr: mula.s f3, f3 + // Unknown instr: madd.s f3, f4, f4 + { + float f3 = c->fprs[3]; + float f4 = c->fprs[4]; + c->fprs[3] = (f3 * f3) + (f4 * f4); + } + c->maxs(f2, f2, f1); // max.s f2, f2, f1 + c->sqrts(f1, f3); // sqrt.s f1, f3 + c->mins(f2, f2, f0); // min.s f2, f2, f0 + c->lui(a0, 16448); // lui a0, 16448 + c->subs(f0, f0, f2); // sub.s f0, f0, f2 + c->lui(a1, 16000); // lui a1, 16000 + c->mtc1(f3, a0); // mtc1 f3, a0 + c->mtc1(f5, a1); // mtc1 f5, a1 + c->mtc1(f4, v1); // mtc1 f4, v1 + // Unknown instr: mula.s f0, f3 + // Unknown instr: madd.s f0, f2, f5 + { + float f0 = c->fprs[0]; + float f2 = c->fprs[2]; + float f3 = c->fprs[3]; + float f5 = c->fprs[5]; + c->fprs[0] = (f0 * f3) + (f2 * f5); + } + c->muls(f0, f0, f1); // mul.s f0, f0, f1 + c->muls(f0, f0, f4); // mul.s f0, f0, f4 + //beq r0, r0, L37 // beq r0, r0, L37 + c->swc1(f0, 12, gp); // swc1 f0, 12(gp) + goto block_7; // branch always + + + block_5: + c->lwc1(f0, 12, s3); // lwc1 f0, 12(s3) + c->mtc1(f1, r0); // mtc1 f1, r0 + cop1_bc = c->fprs[f0] == c->fprs[f1]; // c.eq.s f0, f1 + bc = cop1_bc; // bc1t L37 + c->mov64(v1, s7); // or v1, s7, r0 + if (bc) {goto block_7;} // branch non-likely + + c->mtc1(f0, r0); // mtc1 f0, r0 + c->swc1(f0, 12, gp); // swc1 f0, 12(gp) + c->mfc1(v1, f0); // mfc1 v1, f0 + + block_7: + c->gprs[v0].du64[0] = 0; // or v0, r0, r0 + c->ld(ra, 0, sp); // ld ra, 0(sp) + c->lq(gp, 64, sp); // lq gp, 64(sp) + c->lq(s5, 48, sp); // lq s5, 48(sp) + c->lq(s4, 32, sp); // lq s4, 32(sp) + c->lq(s3, 16, sp); // lq s3, 16(sp) + //jr ra // jr ra + c->daddiu(sp, sp, 80); // daddiu sp, sp, 80 + goto end_of_function; // return + + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + end_of_function: + return c->gprs[v0].du64[0]; +} + +void link() { + cache.math_camera = intern_from_c("*math-camera*").c(); + cache.atan = intern_from_c("atan").c(); + gLinkedFunctionTable.reg("sparticle-motion-blur", execute, 128); +} + +} // namespace sparticle_motion_blur +} // namespace Mips2C diff --git a/game/mips2c/mips2c_private.h b/game/mips2c/mips2c_private.h index a5da76deb9..9fc4a4ea77 100644 --- a/game/mips2c/mips2c_private.h +++ b/game/mips2c/mips2c_private.h @@ -274,6 +274,8 @@ struct ExecutionContext { gprs[gpr].ds64[0] = val; // sign extend and set } + void store_symbol2(int gpr, void* sym_addr) { memcpy((u8*)sym_addr - 1, &gprs[gpr].ds32[0], 4); } + void load_symbol_addr(int gpr, void* sym_addr) { gprs[gpr].du64[0] = ((const u8*)sym_addr) - g_ee_main_mem; } @@ -719,6 +721,14 @@ struct ExecutionContext { } } + void pceqw(int dst, int rs, int rt) { + auto s = gpr_src(rs); + auto t = gpr_src(rt); + for (int i = 0; i < 4; i++) { + gprs[dst].du32[i] = (s.du32[i] == t.du32[i]) ? 0xffffffff : 0; + } + } + void pmfhl_lh(int dest) { gprs[dest].du16[0] = lo.du16[0]; gprs[dest].du16[1] = lo.du16[2]; @@ -1430,6 +1440,37 @@ struct ExecutionContext { gprs[dst].du64[0] = (gprs[dst].du64[0] & LDR_MASK[shift]) | (mem >> LDR_SHIFT[shift]); } + u32 clip(int xyz_idx, int w_idx, u32 old_clip) { + u32 result = (old_clip << 6); + auto xyz_vec = vf_src(xyz_idx); + float w = vf_src(w_idx).f[3]; + + float plus = std::abs(w); + float minus = -plus; + + if (xyz_vec.f[0] > plus) { + result |= 0b1; + } + if (xyz_vec.f[0] < minus) { + result |= 0b10; + } + + if (xyz_vec.f[1] > plus) { + result |= 0b100; + } + if (xyz_vec.f[1] < minus) { + result |= 0b1000; + } + + if (xyz_vec.f[2] > plus) { + result |= 0b10000; + } + if (xyz_vec.f[2] < minus) { + result |= 0b100000; + } + return result & 0xffffff; // only 24 bits + } + std::string print_vf_float(int vf) { auto src = vf_src(vf); return fmt::format("{} {} {} {}", src.f[0], src.f[1], src.f[2], src.f[3]); diff --git a/game/mips2c/mips2c_table.cpp b/game/mips2c/mips2c_table.cpp index 41feb5b73d..656e70b22f 100644 --- a/game/mips2c/mips2c_table.cpp +++ b/game/mips2c/mips2c_table.cpp @@ -129,6 +129,12 @@ namespace render_boundary_tri { extern void link(); } namespace render_boundary_quad { extern void link(); } namespace set_sky_vf27 { extern void link(); } namespace draw_boundary_polygon { extern void link(); } +namespace sp_init_fields { extern void link(); } +namespace particle_adgif { extern void link(); } +namespace sp_launch_particles_var { extern void link(); } +namespace sparticle_motion_blur { extern void link(); } +namespace sp_process_block_2d { extern void link(); } +namespace sp_process_block_3d { extern void link(); } } // clang-format on @@ -213,7 +219,11 @@ PerGameVersion>> gMips2C {"debug", {jak2::debug_line_clip::link, jak2::init_boundary_regs::link, jak2::render_boundary_quad::link, jak2::render_boundary_tri::link, jak2::set_sky_vf27::link, - jak2::draw_boundary_polygon::link}}}, + jak2::draw_boundary_polygon::link}}, + {"sparticle-launcher", + {jak2::sp_init_fields::link, jak2::particle_adgif::link, jak2::sp_launch_particles_var::link, + jak2::sparticle_motion_blur::link}}, + {"sparticle", {jak2::sp_process_block_2d::link, jak2::sp_process_block_3d::link}}}, }; void LinkedFunctionTable::reg(const std::string& name, u64 (*exec)(void*), u32 stack_size) { diff --git a/goal_src/jak2/engine/camera/cam-interface-h.gc b/goal_src/jak2/engine/camera/cam-interface-h.gc index fc5909415c..7d9d61cef2 100644 --- a/goal_src/jak2/engine/camera/cam-interface-h.gc +++ b/goal_src/jak2/engine/camera/cam-interface-h.gc @@ -9,11 +9,13 @@ (define-extern position-in-front-of-camera! (function vector float float vector)) -;; NOTE - for sparticle-launcher + (define-extern math-camera-matrix "Returns [[*math-camera*]]'s `inv-camera-rot`" (function matrix)) +(define-extern matrix-local->world (function symbol matrix)) + ;; DECOMP BEGINS (define-perm *camera-init-mat* matrix #f) diff --git a/goal_src/jak2/engine/debug/part-tester.gc b/goal_src/jak2/engine/debug/part-tester.gc index 0e1f524a96..2db6228538 100644 --- a/goal_src/jak2/engine/debug/part-tester.gc +++ b/goal_src/jak2/engine/debug/part-tester.gc @@ -7,3 +7,141 @@ ;; DECOMP BEGINS +;; this file is debug only +(declare-file (debug)) +(when *debug-segment* +;; failed to figure out what this is: +(defpartgroup group-part-tester + :id 127 + :flags (unk-4 unk-6) + :bounds (static-bspherem 0 0 0 640) + :rotate ((degrees 2) (degrees 0) (degrees 0)) + :parts ((sp-item 209)) + ) + +;; definition of type part-tester +(deftype part-tester (process) + ((root trsqv :offset-assert 128) + (part sparticle-launch-control :offset-assert 132) + (old-group sparticle-launch-group :offset-assert 136) + ) + :heap-base #x10 + :method-count-assert 14 + :size-assert #x8c + :flag-assert #xe0010008c + ) +(define-extern *part-tester* (pointer process)) + +;; definition for method 3 of type part-tester +(defmethod inspect part-tester ((obj part-tester)) + (when (not obj) + (set! obj obj) + (goto cfg-4) + ) + (let ((t9-0 (method-of-type process inspect))) + (t9-0 obj) + ) + (format #t "~2Troot: ~A~%" (-> obj root)) + (format #t "~2Tpart: ~A~%" (-> obj part)) + (format #t "~2Told-group: ~A~%" (-> obj old-group)) + (label cfg-4) + obj + ) + +;; definition for symbol *part-tester-name*, type string +(define *part-tester-name* (the-as string #f)) + +;; definition for method 10 of type part-tester +(defmethod deactivate part-tester ((obj part-tester)) + (if (nonzero? (-> obj part)) + (kill-and-free-particles (-> obj part)) + ) + ((method-of-type process deactivate) obj) + (none) + ) + +;; failed to figure out what this is: +(defstate part-tester-idle (part-tester) + :code (behavior () + (until #f + (let ((gp-0 (entity-by-name *part-tester-name*))) + (when gp-0 + (let ((s5-0 (-> gp-0 extra process))) + (if (and s5-0 (type? s5-0 process-drawable) (nonzero? (-> (the-as process-drawable s5-0) root))) + (set! (-> self root trans quad) (-> (the-as process-drawable s5-0) root trans quad)) + (set! (-> self root trans quad) (-> gp-0 extra trans quad)) + ) + ) + ) + ) + (add-debug-x + #t + (bucket-id debug-no-zbuf1) + (-> self root trans) + (new 'static 'rgba :r #xff :g #xff :b #xff :a #x80) + ) + ;(let ((gp-1 (-> *part-group-id-table* 127))) + (let ((gp-1 (-> *part-group-id-table* 96))) + (let ((s5-1 (-> self root trans))) + (when (!= gp-1 (-> self old-group)) + (when (nonzero? (-> self part)) + (kill-and-free-particles (-> self part)) + (set! (-> self heap-cur) (&-> (-> self part) type)) + ) + (set! (-> self part) (create-launch-control gp-1 self)) + ) + (if (nonzero? (-> self part)) + (spawn (-> self part) (cond + ((logtest? (-> gp-1 flags) (sp-group-flag screen-space)) + *zero-vector* + ) + (else + (empty) + s5-1 + ) + ) + ) + ) + ) + (set! (-> self old-group) gp-1) + ) + (suspend) + ) + #f + (none) + ) + ) + +;; definition for function part-tester-init-by-other +;; INFO: Used lq/sq +;; WARN: Return type mismatch object vs none. +(defbehavior part-tester-init-by-other process-drawable ((arg0 vector)) + (set! (-> self root) (new 'process 'trsqv)) + (set! (-> self root trans quad) (-> arg0 quad)) + (set! *part-tester* (process->ppointer self)) + (go part-tester-idle) + (none) + ) + +;; definition (perm) for symbol *debug-part-dead-pool*, type dead-pool +(define-perm *debug-part-dead-pool* dead-pool (new 'debug 'dead-pool 1 #x10000 "*debug-part-dead-pool*")) + +;; definition for function start-part +;; WARN: Return type mismatch (pointer process) vs none. +(defun start-part () + (kill-by-type part-tester *active-pool*) + (process-spawn + part-tester + (if *anim-tester* + (-> *anim-tester* 0 root trans) + (target-pos 0) + ) + :from *debug-part-dead-pool* + ) + (none) + ) + +) + + + diff --git a/goal_src/jak2/engine/draw/drawable.gc b/goal_src/jak2/engine/draw/drawable.gc index 947af10092..a9641b7143 100644 --- a/goal_src/jak2/engine/draw/drawable.gc +++ b/goal_src/jak2/engine/draw/drawable.gc @@ -375,12 +375,12 @@ ; ) ;; run the sprite/particle system. - ; (if (not (paused?)) - ; (execute-part-engine) - ; ) - ; (if (logtest? (vu1-renderer-mask rn29) (-> *display* vu1-enable-user)) - ; (sprite-draw *display*) - ; ) + (if (not (paused?)) + (execute-part-engine) + ) + (if (logtest? (vu1-renderer-mask sprite) (-> *display* vu1-enable-user)) + (sprite-draw *display*) + ) ;; debug draw collision stuff before processing it. (when *debug-segment* @@ -684,7 +684,7 @@ (*pre-draw-hook* (-> s5-1 calc-buf)) (when (not (paused?)) (clear *stdcon1*) - ;(debug-reset-buffers) + (debug-reset-buffers) ;(clear! *simple-sprite-system*) ) (set! (-> s5-1 bucket-group) (dma-buffer-add-buckets (-> s5-1 calc-buf) 327)) @@ -940,23 +940,23 @@ ; (generic-vu1-init-buffers) ;; sprite texture remaps - ; (when (-> *texture-pool* update-sprites-flag) - ; (update-sprites *texture-pool*) - ; (particle-adgif-cache-flush) - ; (remap-all-particles) - ; ) + (when (-> *texture-pool* update-sprites-flag) + (update-sprites *texture-pool*) + (particle-adgif-cache-flush) + (remap-all-particles) + ) ;; texture uploads while GS is not doing anything. - ; (with-profiler 'texture *profile-texture-color* - ; (let ((s3-1 (-> pp clock))) - ; (if (= (-> *time-of-day-context* mode) (time-of-day-palette-id unk3)) - ; (set! (-> pp clock) (-> *display* bg-clock)) - ; (set! (-> pp clock) (-> *display* real-clock)) - ; ) - ; (upload-textures *texture-pool*) - ; (set! (-> pp clock) s3-1) - ; ) - ; ) + (with-profiler 'texture *profile-texture-color* + (let ((s3-1 (-> pp clock))) + (if (= (-> *time-of-day-context* mode) (time-of-day-palette-id unk3)) + (set! (-> pp clock) (-> *display* bg-clock)) + (set! (-> pp clock) (-> *display* real-clock)) + ) + (upload-textures *texture-pool*) + (set! (-> pp clock) s3-1) + ) + ) ;; more texture mapping. ; (if (-> *texture-pool* update-flag) diff --git a/goal_src/jak2/engine/game/main.gc b/goal_src/jak2/engine/game/main.gc index c7b467c37b..6e0515e9a9 100644 --- a/goal_src/jak2/engine/game/main.gc +++ b/goal_src/jak2/engine/game/main.gc @@ -620,7 +620,7 @@ ;; a few things before the actor updates... - ; (set! (-> *time-of-day-context* title-updated) #f) + (set! (-> *time-of-day-context* title-updated) #f) ;; update teleport counter ; (set! *teleport* #f) @@ -630,11 +630,11 @@ ; ) ;; update particles (we're racing the DMA transfer again, do this asap) - ; (let ((gp-1 (-> pp clock))) - ; (set! (-> pp clock) (-> *display* part-clock)) - ; (process-particles) - ; (set! (-> pp clock) gp-1) - ; ) + (let ((gp-1 (-> pp clock))) + (set! (-> pp clock) (-> *display* part-clock)) + (process-particles) + (set! (-> pp clock) gp-1) + ) ;; set up VU0's VIF for collision code run by actors ; (dma-send diff --git a/goal_src/jak2/engine/gfx/mood/time-of-day.gc b/goal_src/jak2/engine/gfx/mood/time-of-day.gc index 20a36790b7..f0137f9431 100644 --- a/goal_src/jak2/engine/gfx/mood/time-of-day.gc +++ b/goal_src/jak2/engine/gfx/mood/time-of-day.gc @@ -51,10 +51,10 @@ ) ) (when (and (-> *setting-control* user-current weather) gp-0) - (let ((s5-0 (new 'stack-no-clear 'vector))) - (let ((s4-0 (new 'stack-no-clear 'vector)) - (v1-8 (-> *math-camera* inv-camera-rot vector 2)) - ) + (let ((s5-0 (new 'stack-no-clear 'vector)) + (s4-0 (new 'stack-no-clear 'vector)) + ) + (let ((v1-8 (-> *math-camera* inv-camera-rot vector 2))) (set! (-> s5-0 quad) (-> *math-camera* trans quad)) (vector-! s4-0 s5-0 (-> *math-camera* prev-trans)) (let ((f0-1 (vector-dot s4-0 v1-8))) @@ -62,13 +62,13 @@ ) ) (set! (-> s5-0 y) (-> *math-camera* trans y)) + (if (< 0.0 (-> *setting-control* user-current rain)) + (update-rain (-> *setting-control* user-current rain) s5-0 s4-0) + ) + (if (< 0.0 (-> *setting-control* user-current snow)) + (update-snow (-> *setting-control* user-current snow) s5-0 s4-0) + ) ) - (if (< 0.0 (-> *setting-control* user-current rain)) - (update-rain (the-as target (-> *setting-control* user-current rain))) - ) - (if (< 0.0 (-> *setting-control* user-current snow)) - (update-snow (the-as target (-> *setting-control* user-current snow))) - ) ) (cond ((and (>= (-> self time-of-day) 6.25) @@ -124,6 +124,7 @@ (none) ) + ;; definition for function update-counters (defbehavior update-counters time-of-day-proc () (let ((v1-2 (-> *display* bg-clock frame-counter))) diff --git a/goal_src/jak2/engine/gfx/mood/weather-part.gc b/goal_src/jak2/engine/gfx/mood/weather-part.gc index 8dcc745bb0..259d499905 100644 --- a/goal_src/jak2/engine/gfx/mood/weather-part.gc +++ b/goal_src/jak2/engine/gfx/mood/weather-part.gc @@ -7,56 +7,959 @@ ;; DECOMP BEGINS -;; all these are stubbed out +(defpartgroup group-rain-screend-drop-real + :id 1 + :flags (screen-space) + :bounds (static-bspherem 0 0 0 16) + :parts ((sp-item 45 :binding 41) + (sp-item 41 :flags (start-dead launch-asap) :binding 42) + (sp-item 41 :flags (start-dead launch-asap) :binding 42) + (sp-item 41 :flags (start-dead launch-asap) :binding 42) + (sp-item 41 :flags (start-dead launch-asap) :binding 42) + (sp-item 41 :flags (start-dead launch-asap) :binding 42) + (sp-item 41 :flags (start-dead launch-asap) :binding 42) + (sp-item 41 :flags (start-dead launch-asap) :binding 42) + (sp-item 41 :flags (start-dead launch-asap) :binding 42) + (sp-item 41 :flags (start-dead launch-asap) :binding 42) + (sp-item 41 :flags (start-dead launch-asap) :binding 42) + (sp-item 41 :flags (start-dead launch-asap) :binding 42) + (sp-item 41 :flags (start-dead launch-asap) :binding 42) + (sp-item 41 :flags (start-dead launch-asap) :binding 42) + (sp-item 41 :flags (start-dead launch-asap) :binding 42) + (sp-item 41 :flags (start-dead launch-asap) :binding 42) + (sp-item 41 :flags (start-dead launch-asap) :binding 42) + (sp-item 42 :flags (start-dead launch-asap)) + (sp-item 42 :flags (start-dead launch-asap)) + (sp-item 42 :flags (start-dead launch-asap)) + (sp-item 42 :flags (start-dead launch-asap)) + (sp-item 42 :flags (start-dead launch-asap)) + (sp-item 42 :flags (start-dead launch-asap)) + (sp-item 42 :flags (start-dead launch-asap)) + (sp-item 42 :flags (start-dead launch-asap)) + (sp-item 42 :flags (start-dead launch-asap)) + (sp-item 42 :flags (start-dead launch-asap)) + (sp-item 42 :flags (start-dead launch-asap)) + (sp-item 42 :flags (start-dead launch-asap)) + (sp-item 42 :flags (start-dead launch-asap)) + (sp-item 42 :flags (start-dead launch-asap)) + (sp-item 42 :flags (start-dead launch-asap)) + (sp-item 42 :flags (start-dead launch-asap)) + (sp-item 46 :binding 43) + (sp-item 43 :flags (start-dead launch-asap) :binding 44) + (sp-item 43 :flags (start-dead launch-asap) :binding 44) + (sp-item 43 :flags (start-dead launch-asap) :binding 44) + (sp-item 43 :flags (start-dead launch-asap) :binding 44) + (sp-item 43 :flags (start-dead launch-asap) :binding 44) + (sp-item 43 :flags (start-dead launch-asap) :binding 44) + (sp-item 43 :flags (start-dead launch-asap) :binding 44) + (sp-item 43 :flags (start-dead launch-asap) :binding 44) + (sp-item 43 :flags (start-dead launch-asap) :binding 44) + (sp-item 43 :flags (start-dead launch-asap) :binding 44) + (sp-item 43 :flags (start-dead launch-asap) :binding 44) + (sp-item 43 :flags (start-dead launch-asap) :binding 44) + (sp-item 43 :flags (start-dead launch-asap) :binding 44) + (sp-item 43 :flags (start-dead launch-asap) :binding 44) + (sp-item 43 :flags (start-dead launch-asap) :binding 44) + (sp-item 43 :flags (start-dead launch-asap) :binding 44) + (sp-item 44 :flags (start-dead launch-asap)) + (sp-item 44 :flags (start-dead launch-asap)) + (sp-item 44 :flags (start-dead launch-asap)) + (sp-item 44 :flags (start-dead launch-asap)) + (sp-item 44 :flags (start-dead launch-asap)) + (sp-item 44 :flags (start-dead launch-asap)) + (sp-item 44 :flags (start-dead launch-asap)) + (sp-item 44 :flags (start-dead launch-asap)) + (sp-item 44 :flags (start-dead launch-asap)) + (sp-item 44 :flags (start-dead launch-asap)) + (sp-item 44 :flags (start-dead launch-asap)) + (sp-item 44 :flags (start-dead launch-asap)) + (sp-item 44 :flags (start-dead launch-asap)) + (sp-item 44 :flags (start-dead launch-asap)) + (sp-item 44 :flags (start-dead launch-asap)) + (sp-item 44 :flags (start-dead launch-asap)) + ) + ) -(defun update-rain ((a0-0 target)) +(define group-rain-screend-drop (-> *part-group-id-table* 1)) + +(defpart 46 + :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #x29 :page #xc)) + (sp-flt spt-num 0.1) + (sp-rnd-flt spt-x (meters -4.5) (meters 9) 1.0) + (sp-rnd-flt spt-y (meters -3) (meters 6) 1.0) + (sp-flt spt-scale-x (meters 2.5)) + (sp-rnd-flt spt-rot-z (degrees 0.0) (degrees 360.0) 1.0) + (sp-copy-from-other spt-scale-y -4) + (sp-flt spt-r 128.0) + (sp-flt spt-g 128.0) + (sp-flt spt-b 128.0) + (sp-flt spt-a 12.0) + (sp-flt spt-scalevel-x (meters 0.16666667)) + (sp-copy-from-other spt-scalevel-y -4) + (sp-flt spt-fade-a -0.8) + (sp-int spt-timer 10) + (sp-cpuinfo-flags sp-cpuinfo-flag-2 sp-cpuinfo-flag-3 sp-cpuinfo-flag-14) + ) + ) + +(defpart 43 + :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #x21 :page #xc)) + (sp-flt spt-num 1.0) + (sp-flt spt-scale-x (meters 1.5)) + (sp-copy-from-other spt-scale-y -4) + (sp-flt spt-r 128.0) + (sp-flt spt-g 128.0) + (sp-flt spt-b 255.0) + (sp-flt spt-a 20.0) + (sp-flt spt-scalevel-x (meters 0.033333335)) + (sp-copy-from-other spt-scalevel-y -4) + (sp-flt spt-fade-a -0.8) + (sp-flt spt-accel-y -2.7306666) + (sp-int spt-timer 270) + (sp-cpuinfo-flags sp-cpuinfo-flag-2 sp-cpuinfo-flag-3 sp-cpuinfo-flag-14) + (sp-int spt-next-time 15) + (sp-launcher-by-id spt-next-launcher 47) + ) + ) + +;; failed to figure out what this is: +(defpart 47 + :init-specs ((sp-flt spt-scalevel-x (meters 0.004166667)) + (sp-copy-from-other spt-scalevel-y -4) + (sp-flt spt-fade-a -0.06666667) + ) + ) + +;; failed to figure out what this is: +(defpart 44 + :init-specs ((sp-flt spt-num 1.0) + (sp-int spt-rot-x 12) + (sp-flt spt-r 4096.0) + (sp-flt spt-g 3276.8) + (sp-flt spt-b 3276.8) + (sp-flt spt-fade-r 6.068148) + (sp-flt spt-fade-g 68.26667) + (sp-flt spt-fade-b 3.034074) + (sp-flt spt-accel-y -2.7306666) + (sp-int spt-timer 270) + (sp-cpuinfo-flags distort) + (sp-int spt-next-time 30) + (sp-launcher-by-id spt-next-launcher 48) + ) + ) + +;; failed to figure out what this is: +(defpart 48 + :init-specs ((sp-flt spt-fade-g -5.1200004)) + ) + +;; failed to figure out what this is: +(defpart 45 + :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #x29 :page #xc)) + (sp-flt spt-num 0.1) + (sp-rnd-flt spt-x (meters -4.5) (meters 9) 1.0) + (sp-rnd-flt spt-y (meters -3) (meters 6) 1.0) + (sp-flt spt-scale-x (meters 4)) + (sp-rnd-flt spt-rot-z (degrees 0.0) (degrees 360.0) 1.0) + (sp-copy-from-other spt-scale-y -4) + (sp-flt spt-r 128.0) + (sp-flt spt-g 128.0) + (sp-flt spt-b 128.0) + (sp-flt spt-a 12.0) + (sp-flt spt-scalevel-x (meters 0.26666668)) + (sp-copy-from-other spt-scalevel-y -4) + (sp-flt spt-fade-a -0.8) + (sp-int spt-timer 10) + (sp-cpuinfo-flags sp-cpuinfo-flag-2 sp-cpuinfo-flag-3 sp-cpuinfo-flag-14) + ) + ) + +;; failed to figure out what this is: +(defpart 41 + :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #x21 :page #xc)) + (sp-flt spt-num 1.0) + (sp-flt spt-scale-x (meters 2.6)) + (sp-copy-from-other spt-scale-y -4) + (sp-flt spt-r 128.0) + (sp-flt spt-g 128.0) + (sp-flt spt-b 255.0) + (sp-flt spt-a 20.0) + (sp-flt spt-scalevel-x (meters 0.06666667)) + (sp-copy-from-other spt-scalevel-y -4) + (sp-flt spt-fade-a -0.8) + (sp-flt spt-accel-y -2.7306666) + (sp-int spt-timer 270) + (sp-cpuinfo-flags sp-cpuinfo-flag-2 sp-cpuinfo-flag-3 sp-cpuinfo-flag-14) + (sp-int spt-next-time 15) + (sp-launcher-by-id spt-next-launcher 49) + ) + ) + +;; failed to figure out what this is: +(defpart 49 + :init-specs ((sp-flt spt-scalevel-x (meters 0.008333334)) + (sp-copy-from-other spt-scalevel-y -4) + (sp-flt spt-fade-a -0.06666667) + ) + ) + +;; failed to figure out what this is: +(defpart 42 + :init-specs ((sp-flt spt-num 1.0) + (sp-int spt-rot-x 24) + (sp-flt spt-r 12288.0) + (sp-flt spt-g 6553.6) + (sp-flt spt-b 6553.6) + (sp-flt spt-fade-r 12.136296) + (sp-flt spt-fade-g 136.53334) + (sp-flt spt-fade-b 6.068148) + (sp-flt spt-accel-y -2.7306666) + (sp-int spt-timer 270) + (sp-cpuinfo-flags distort) + (sp-int spt-next-time 30) + (sp-launcher-by-id spt-next-launcher 50) + ) + ) + +;; failed to figure out what this is: +(defpart 50 + :init-specs ((sp-flt spt-fade-g -10.240001)) + ) + +;; failed to figure out what this is: +(defpartgroup group-stars + :id 2 + :flags (always-draw) + :bounds (static-bspherem 0 0 0 8) + :parts ((sp-item 51 :flags (bit6)) (sp-item 52 :flags (bit6)) (sp-item 53 :flags (bit6))) + ) + +;; failed to figure out what this is: +(defpart 51 + :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #xc9 :page #xc)) + (sp-flt spt-num 1.0) + (sp-rnd-flt spt-scale-x (meters 30) (meters 20) 1.0) + (sp-copy-from-other spt-scale-y -4) + (sp-flt spt-r 256.0) + (sp-flt spt-g 256.0) + (sp-flt spt-b 256.0) + (sp-flt spt-a 0.0) + (sp-flt spt-fade-a 0.42666668) + (sp-int spt-timer -1) + (sp-cpuinfo-flags sp-cpuinfo-flag-2 sp-cpuinfo-flag-3 sp-cpuinfo-flag-14) + (sp-int-plain-rnd spt-next-time 60 239 1) + (sp-launcher-by-id spt-next-launcher 54) + (sp-rnd-flt spt-conerot-x (degrees -89.0) (degrees 178.0) 1.0) + (sp-rnd-flt spt-conerot-y (degrees 0.0) (degrees 1440.0) 1.0) + (sp-rnd-flt spt-rotate-y (degrees 0.0) (degrees 3600.0) 1.0) + (sp-flt spt-conerot-radius (meters 5000)) + ) + ) + +;; failed to figure out what this is: +(defpart 54 + :init-specs ((sp-flt spt-fade-a 0.0) (sp-int spt-next-time 29999700) (sp-launcher-by-id spt-next-launcher 55)) + ) + +;; failed to figure out what this is: +(defpart 55 + :init-specs ((sp-flt spt-fade-a -0.42666668)) + ) + +;; failed to figure out what this is: +(defpart 52 + :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #xc9 :page #xc)) + (sp-flt spt-num 1.0) + (sp-rnd-flt spt-scale-x (meters 30) (meters 20) 1.0) + (sp-copy-from-other spt-scale-y -4) + (sp-flt spt-r 256.0) + (sp-flt spt-g 256.0) + (sp-flt spt-b 256.0) + (sp-flt spt-a 0.0) + (sp-flt spt-fade-a 0.42666668) + (sp-int spt-timer -1) + (sp-cpuinfo-flags sp-cpuinfo-flag-2 sp-cpuinfo-flag-3 sp-cpuinfo-flag-14) + (sp-int-plain-rnd spt-next-time 60 239 1) + (sp-launcher-by-id spt-next-launcher 54) + (sp-rnd-flt spt-conerot-x (degrees 30.0) (degrees 59.0) 1.0) + (sp-rnd-flt spt-conerot-y (degrees 0.0) (degrees 2880.0) 1.0) + (sp-rnd-flt spt-rotate-y (degrees 0.0) (degrees 3600.0) 1.0) + (sp-flt spt-conerot-radius (meters 5000)) + ) + ) + +;; failed to figure out what this is: +(defpart 53 + :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #xc9 :page #xc)) + (sp-flt spt-num 1.0) + (sp-rnd-flt spt-scale-x (meters 30) (meters 20) 1.0) + (sp-copy-from-other spt-scale-y -4) + (sp-flt spt-r 128.0) + (sp-flt spt-g 128.0) + (sp-flt spt-b 128.0) + (sp-flt spt-a 0.0) + (sp-flt spt-fade-a 0.42666668) + (sp-int spt-timer -1) + (sp-cpuinfo-flags sp-cpuinfo-flag-2 sp-cpuinfo-flag-3 sp-cpuinfo-flag-14) + (sp-int-plain-rnd spt-next-time 60 239 1) + (sp-launcher-by-id spt-next-launcher 54) + (sp-rnd-flt spt-conerot-x (degrees 60.0) (degrees 29.0) 1.0) + (sp-rnd-flt spt-conerot-y (degrees 0.0) (degrees 5760.0) 1.0) + (sp-rnd-flt spt-rotate-y (degrees 0.0) (degrees 3600.0) 1.0) + (sp-flt spt-conerot-radius (meters 5000)) + ) + ) + +;; failed to figure out what this is: +(defpart 56 + :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #xc9 :page #xc)) + (sp-flt spt-num 4.0) + (sp-rnd-flt spt-x (meters 10) (meters 10) 1.0) + (sp-rnd-flt spt-y (meters 2) (meters 14) 1.0) + (sp-rnd-flt spt-scale-x (meters 0.2) (meters 0.1) 1.0) + (sp-int spt-rot-x 4) + (sp-rnd-flt spt-rot-z (degrees 0.0) (degrees 360.0) 1.0) + (sp-copy-from-other spt-scale-y -4) + (sp-flt spt-r 255.0) + (sp-flt spt-g 255.0) + (sp-flt spt-b 255.0) + (sp-flt spt-a 0.0) + (sp-rnd-flt spt-vel-y (meters -0.01) (meters -0.0033333334) 1.0) + (sp-rnd-flt spt-rotvel-z (degrees -1.2) (degrees 2.4) 1.0) + (sp-flt spt-fade-a 0.85333335) + (sp-int spt-timer 1500) + (sp-cpuinfo-flags sp-cpuinfo-flag-2 sp-cpuinfo-flag-12 sp-cpuinfo-flag-14) + (sp-int-plain-rnd spt-next-time 75 74 1) + (sp-launcher-by-id spt-next-launcher 57) + (sp-rnd-flt spt-rotate-y (degrees 0.0) (degrees 180.0) 1.0) + ) + ) + +;; failed to figure out what this is: +(defpart 58 + :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #xc9 :page #xc)) + (sp-flt spt-num 0.0) + (sp-rnd-flt spt-x (meters 0) (meters 20) 1.0) + (sp-flt spt-y (meters 16)) + (sp-rnd-flt spt-scale-x (meters 0.2) (meters 0.1) 1.0) + (sp-int spt-rot-x 4) + (sp-rnd-flt spt-rot-z (degrees 0.0) (degrees 360.0) 1.0) + (sp-copy-from-other spt-scale-y -4) + (sp-flt spt-r 255.0) + (sp-flt spt-g 255.0) + (sp-flt spt-b 255.0) + (sp-flt spt-a 0.0) + (sp-rnd-flt spt-vel-y (meters -0.01) (meters -0.0033333334) 1.0) + (sp-rnd-flt spt-rotvel-z (degrees -1.2) (degrees 2.4) 1.0) + (sp-flt spt-fade-a 0.85333335) + (sp-int spt-timer 1500) + (sp-cpuinfo-flags sp-cpuinfo-flag-2 sp-cpuinfo-flag-12 sp-cpuinfo-flag-14) + (sp-int-plain-rnd spt-next-time 75 74 1) + (sp-launcher-by-id spt-next-launcher 57) + (sp-rnd-flt spt-rotate-y (degrees 0.0) (degrees 360.0) 1.0) + ) + ) + +;; failed to figure out what this is: +(defpart 57 + :init-specs ((sp-flt spt-fade-a 0.0) (sp-int spt-next-time 1200) (sp-launcher-by-id spt-next-launcher 59)) + ) + +;; failed to figure out what this is: +(defpart 59 + :init-specs ((sp-flt spt-fade-a -0.85333335)) + ) + +;; definition for function update-snow +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs none. +(defun update-snow ((arg0 float) (arg1 vector) (arg2 vector)) + (let ((f0-0 (lerp-scale 0.0 1.0 (vector-length arg2) 2048.0 40960.0))) + (set! (-> *part-id-table* 58 init-specs 1 initial-valuef) (- 1.0 f0-0)) + (set! (-> *part-id-table* 56 init-specs 1 initial-valuef) (* 4.0 f0-0)) + ) + (set! (-> *part-id-table* 56 init-specs 19 initial-valuef) (+ 32768.0 (vector-y-angle arg2))) + (let ((t9-2 sp-launch-particles-var) + (a0-3 *sp-particle-system-2d*) + (a1-2 (-> *part-id-table* 58)) + (a2-2 *launch-matrix*) + ) + (set! (-> a2-2 trans quad) (-> arg1 quad)) + (t9-2 a0-3 a1-2 a2-2 (the-as sparticle-launch-state #f) (the-as sparticle-launch-control #f) 1.0) + ) + (let ((t9-3 sp-launch-particles-var) + (a0-4 *sp-particle-system-2d*) + (a1-3 (-> *part-id-table* 56)) + (a2-3 *launch-matrix*) + ) + (set! (-> a2-3 trans quad) (-> arg1 quad)) + (t9-3 a0-4 a1-3 a2-3 (the-as sparticle-launch-state #f) (the-as sparticle-launch-control #f) 1.0) + ) + 0 (none) ) -(defun update-snow ((arg target)) - (none)) +;; failed to figure out what this is: +(defpart 60 + :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #x21 :page #xc)) + (sp-func spt-birth-func 'birth-func-rain) + (sp-flt spt-num 1.0) + (sp-rnd-flt spt-x (meters -20) (meters 40) 1.0) + (sp-flt spt-y (meters 30)) + (sp-rnd-flt spt-scale-x (meters 0.03) (meters 0.03) 1.0) + (sp-rnd-flt spt-scale-y (meters 0.5) (meters 0.5) 1.0) + (sp-rnd-flt spt-r 32.0 32.0 1.0) + (sp-copy-from-other spt-g -1) + (sp-rnd-flt spt-b 64.0 32.0 1.0) + (sp-rnd-flt spt-a 32.0 64.0 1.0) + (sp-rnd-flt spt-vel-y (meters -0.1) (meters -0.2) 1.0) + (sp-int spt-timer 900) + (sp-cpuinfo-flags sp-cpuinfo-flag-2 sp-cpuinfo-flag-3 sp-cpuinfo-flag-14) + (sp-flt spt-userdata 0.0) + (sp-func spt-func 'check-drop-level-rain) + (sp-rnd-flt spt-rotate-y (degrees 0.0) (degrees 3600.0) 1.0) + ) + ) -(set! (-> *part-group-id-table* 4) - (new 'static 'sparticle-launch-group - :length 0 - :duration #xbb8 - :linger-duration #x5dc - :flags (sp-group-flag always-draw) - :name "group-green-sun" - :launcher (new 'static 'inline-array sparticle-group-item 0) - :scale-x 1.0 - :scale-y 1.0 - :scale-z 1.0 - :bounds (new 'static 'sphere :w 286720.0) +;; failed to figure out what this is: +(defpart 61 + :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #x21 :page #xc)) + (sp-func spt-birth-func 'birth-func-rain) + (sp-flt spt-num 4.0) + (sp-rnd-flt spt-x (meters -20) (meters 40) 1.0) + (sp-flt spt-y (meters 30)) + (sp-rnd-flt spt-scale-x (meters 0.03) (meters 0.03) 1.0) + (sp-rnd-flt spt-scale-y (meters 0.5) (meters 0.5) 1.0) + (sp-rnd-flt spt-r 32.0 32.0 1.0) + (sp-copy-from-other spt-g -1) + (sp-rnd-flt spt-b 64.0 32.0 1.0) + (sp-rnd-flt spt-a 32.0 64.0 1.0) + (sp-rnd-flt spt-vel-y (meters -0.06666667) (meters -0.033333335) 1.0) + (sp-int spt-timer 900) + (sp-cpuinfo-flags sp-cpuinfo-flag-2 sp-cpuinfo-flag-3 sp-cpuinfo-flag-14) + (sp-flt spt-userdata 0.0) + (sp-func spt-func 'check-drop-level-rain2) + (sp-rnd-flt spt-rotate-y (degrees 0.0) (degrees 3600.0) 1.0) + ) + ) + +;; failed to figure out what this is: +(defpart 62 + :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #x21 :page #xc)) + (sp-rnd-flt spt-num 1.0 3.0 1.0) + (sp-rnd-flt spt-scale-x (meters 0.08) (meters 0.03) 1.0) + (sp-int spt-rot-x 4) + (sp-copy-from-other spt-scale-y -4) + (sp-rnd-flt spt-r 32.0 32.0 1.0) + (sp-copy-from-other spt-g -1) + (sp-rnd-flt spt-b 64.0 32.0 1.0) + (sp-rnd-flt spt-a 64.0 64.0 1.0) + (sp-rnd-flt spt-omega 2.8672 1.6384 1.0) + (sp-rnd-flt spt-vel-y (meters 0.033333335) (meters 0.06666667) 1.0) + (sp-rnd-flt spt-fade-a -0.21333334 -0.21333334 1.0) + (sp-rnd-flt spt-accel-y -20.48 -2.7306666 1.0) + (sp-flt spt-friction 0.98) + (sp-int spt-timer 300) + (sp-cpuinfo-flags sp-cpuinfo-flag-2 sp-cpuinfo-flag-3 sp-cpuinfo-flag-14 use-global-acc) + (sp-flt spt-userdata 0.0) + (sp-func spt-func 'check-drop-level-splash) + (sp-int-plain-rnd spt-next-time 0 99 1) + (sp-launcher-by-id spt-next-launcher 63) + (sp-rnd-flt spt-conerot-x (degrees 0.0) (degrees 50.000004) 1.0) + (sp-rnd-flt spt-conerot-y (degrees 0.0) (degrees 3600.0) 1.0) + (sp-flt spt-rotate-x (degrees 0.0)) + (sp-flt spt-rotate-y (degrees 0.0)) + ) + ) + +;; failed to figure out what this is: +(defpart 64 + :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #xc9 :page #xc)) + (sp-func spt-birth-func 'birth-func-omega-normal-orient) + (sp-flt spt-num 1.0) + (sp-flt spt-y (meters 0.2)) + (sp-rnd-flt spt-scale-x (meters 0.5) (meters 0.25) 1.0) + (sp-copy-from-other spt-scale-y -4) + (sp-rnd-flt spt-r 32.0 32.0 1.0) + (sp-copy-from-other spt-g -1) + (sp-rnd-flt spt-b 64.0 32.0 1.0) + (sp-rnd-flt spt-a 64.0 32.0 1.0) + (sp-flt spt-omega 0.0) + (sp-rnd-flt spt-scalevel-x (meters 0.006666667) (meters 0.006666667) 1.0) + (sp-copy-from-other spt-scalevel-y -4) + (sp-flt spt-fade-a -1.2) + (sp-int spt-timer 300) + (sp-cpuinfo-flags sp-cpuinfo-flag-2 sp-cpuinfo-flag-3 sp-cpuinfo-flag-14) + (new 'static 'sp-field-init-spec + :field (sp-field-id spt-userdata) + :flags (sp-flag plain-v2) + :object (new 'static 'boxed-array :type int32 10 0 0 #xc0c900 #xc02600 #xc03300 #xc02c00) + ) + (sp-func spt-func 'sparticle-texture-animate) + ) + ) + +;; failed to figure out what this is: +(defpart 65 + :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #x92 :page #xc)) + (sp-rnd-flt spt-num 2.0 4.0 1.0) + (sp-flt spt-scale-x (meters 2.5)) + (sp-int spt-rot-x 4) + (sp-rnd-flt spt-scale-y (meters 0.06) (meters 0.03) 1.0) + (sp-flt spt-r 255.0) + (sp-rnd-flt spt-g 128.0 128.0 1.0) + (sp-rnd-flt spt-b 0.0 128.0 1.0) + (sp-flt spt-a 128.0) + (sp-rnd-flt spt-omega 3.2768 2.048 1.0) + (sp-rnd-flt spt-vel-y (meters 0.1) (meters 0.06666667) 1.0) + (sp-rnd-flt spt-fade-g -2.55 -2.55 1.0) + (sp-flt spt-fade-b -8.0) + (sp-rnd-flt spt-fade-a -0.32 -0.64 1.0) + (sp-rnd-flt spt-friction 0.8 0.02 1.0) + (sp-int-plain-rnd spt-timer 100 99 1) + (sp-cpuinfo-flags sp-cpuinfo-flag-2 sp-cpuinfo-flag-3) + (sp-func spt-func 'sparticle-motion-blur) + (sp-rnd-flt spt-conerot-x (degrees 0.0) (degrees 80.0) 1.0) + (sp-rnd-flt spt-conerot-y (degrees 0.0) (degrees 3600.0) 1.0) + ) + ) + +;; failed to figure out what this is: +(defpart 66 + :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #xbb :page #xc)) + (sp-flt spt-num 1.0) + (sp-flt spt-scale-x (meters 0.25)) + (sp-flt spt-rot-x 40.96) + (sp-rnd-flt spt-rot-z (degrees 0.0) (degrees 3600.0) 1.0) + (sp-copy-from-other spt-scale-y -4) + (sp-flt spt-r 255.0) + (sp-rnd-flt spt-g 196.0 128.0 1.0) + (sp-rnd-flt spt-b 128.0 64.0 1.0) + (sp-rnd-flt spt-a 96.0 16.0 1.0) + (sp-flt spt-omega 656998.4) + (sp-flt spt-scalevel-x (meters 0.08)) + (sp-copy-from-other spt-scalevel-y -4) + (sp-flt spt-fade-g -6.375) + (sp-flt spt-fade-b -13.066667) + (sp-flt spt-fade-a -2.8) + (sp-int-plain-rnd spt-timer 15 9 1) + (sp-cpuinfo-flags sp-cpuinfo-flag-2 sp-cpuinfo-flag-3 glow) + (sp-flt spt-userdata 2048.0) + ) + ) + +;; definition for function birth-func-omega-normal-orient +;; WARN: Return type mismatch int vs none. +(defun birth-func-omega-normal-orient ((arg0 sparticle-system) + (arg1 sparticle-cpuinfo) + (arg2 sprite-vec-data-3d) + (arg3 sparticle-launcher) + (arg4 sparticle-launch-state) + ) + (local-vars (v1-6 float) (v1-7 float)) + (rlet ((vf0 :class vf) + (vf1 :class vf) + (vf2 :class vf) + ) + (init-vf0-vector) + (let ((s4-0 (new 'stack-no-clear 'vector)) + (gp-0 (new 'stack-no-clear 'quaternion)) + ) + (set! (-> s4-0 x) (* 0.007874016 (the float (-> arg1 datab 2)))) + (set! (-> s4-0 y) 0.0) + (set! (-> s4-0 z) (* -0.007874016 (the float (-> arg1 datab 0)))) + (vector-normalize! s4-0 1.0) + (quaternion-vector-angle! gp-0 s4-0 (acos (* 0.007874016 (the float (-> arg1 datab 1))))) + (cond + ((< (-> gp-0 w) 0.0) + (.lvf vf1 (&-> arg2 qx-qy-qz-sy quad)) + (.lvf vf2 (&-> gp-0 vec quad)) + (.sub.vf vf1 vf0 vf2 :mask #b111) + (.svf (&-> arg2 qx-qy-qz-sy quad) vf1) + (.mov v1-6 vf1) + ) + (else + (.lvf vf1 (&-> arg2 qx-qy-qz-sy quad)) + (.lvf vf2 (&-> gp-0 vec quad)) + (.add.vf vf1 vf0 vf2 :mask #b111) + (.svf (&-> arg2 qx-qy-qz-sy quad) vf1) + (.mov v1-7 vf1) + ) ) ) + 0 + (none) + ) + ) -(set! (-> *part-group-id-table* 3) - (new 'static 'sparticle-launch-group - :length 0 - :duration #xbb8 - :linger-duration #x5dc - :flags (sp-group-flag always-draw) - :name "group-sun" - :launcher (new 'static 'inline-array sparticle-group-item 0) - :scale-x 1.0 - :scale-y 1.0 - :scale-z 1.0 - :bounds (new 'static 'sphere :w 286720.0) +;; definition for function birth-func-rain +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs none. +(defun birth-func-rain ((arg0 sparticle-system) + (arg1 sparticle-cpuinfo) + (arg2 sprite-vec-data-3d) + (arg3 sparticle-launcher) + (arg4 sparticle-launch-state) + ) + (let ((s4-0 (new 'stack-no-clear 'collide-query))) + (set! (-> s4-0 start-pos quad) (-> arg2 x-y-z-sx quad)) + (set-vector! (-> s4-0 move-dist) 0.0 -163840.0 0.0 1.0) + (let ((v1-2 s4-0)) + (set! (-> v1-2 radius) 40.96) + (set! (-> v1-2 collide-with) (collide-spec backgnd)) + (set! (-> v1-2 ignore-process0) #f) + (set! (-> v1-2 ignore-process1) #f) + (set! (-> v1-2 ignore-pat) (new 'static 'pat-surface :noentity #x1 :nojak #x1 :probe #x1 :noendlessfall #x1)) + (set! (-> v1-2 action-mask) (collide-action solid)) + ) + (fill-using-line-sphere *collide-cache* s4-0) + (cond + ((>= (collide-cache-method-16 *collide-cache* s4-0) 0.0) + (set! (-> arg1 user-float) (-> s4-0 best-other-tri intersect y)) + (let ((f0-8 (+ 65536.0 (-> *math-camera* trans y)))) + (if (< (-> arg1 user-float) f0-8) + (set! (-> arg2 x-y-z-sx y) f0-8) + ) + ) + (set! (-> arg1 datab 0) (the int (* 127.0 (-> s4-0 best-other-tri normal x)))) + (set! (-> arg1 datab 1) (the int (* 127.0 (-> s4-0 best-other-tri normal y)))) + (set! (-> arg1 datab 2) (the int (* 127.0 (-> s4-0 best-other-tri normal z)))) + (set! (-> arg1 datab 3) (the-as int (-> s4-0 best-other-tri pat event))) + ) + (else + (set! (-> arg1 omega) 65280.0) + (set! (-> arg1 user-float) (+ -204800.0 (-> arg2 x-y-z-sx y))) ) ) - -(set! (-> *part-group-id-table* 5) - (new 'static 'sparticle-launch-group - :length 0 - :duration #xbb8 - :linger-duration #x5dc - :flags (sp-group-flag always-draw) - :name "group-moon" - :launcher (new 'static 'inline-array sparticle-group-item 0) - :scale-x 1.0 - :scale-y 1.0 - :scale-z 1.0 - :bounds (new 'static 'sphere :w 286720.0) + ) + (let ((f0-21 (ocean-method-11 *ocean* (the-as (inline-array vector) (-> arg2 x-y-z-sx)) #f))) + (when (!= f0-21 4095996000.0) + (when (< (-> arg1 user-float) f0-21) + (set! (-> arg1 user-float) f0-21) + (set! (-> arg1 datab 0) 0) + (set! (-> arg1 datab 1) 127) + (set! (-> arg1 datab 2) 0) + (set! (-> arg1 datab 3) 0) + 0 ) ) + ) + 0 + (none) + ) + +;; definition for function check-drop-level-rain +;; INFO: Used lq/sq +(defun check-drop-level-rain ((arg0 sparticle-system) (arg1 sparticle-cpuinfo) (arg2 vector)) + (when (< (-> arg2 y) (-> arg1 user-float)) + (let ((s4-0 (new 'stack-no-clear 'vector)) + (gp-0 (new 'stack-no-clear 'matrix)) + ) + (let ((f30-0 (-> arg1 user-float))) + (sp-kill-particle arg0 arg1) + (set-vector! s4-0 (-> arg2 x) (-> arg1 user-float) (-> arg2 z) 1.0) + (-> arg1 omega) + (set-vector! + (-> gp-0 vector 1) + (* 0.007874016 (the float (-> arg1 datab 0))) + (* 0.007874016 (the float (-> arg1 datab 1))) + (* 0.007874016 (the float (-> arg1 datab 2))) + 0.0 + ) + (set-vector! (-> gp-0 vector 2) 0.0 0.0 1.0 0.0) + (vector-cross! (the-as vector (-> gp-0 vector)) (-> gp-0 vector 1) (-> gp-0 vector 2)) + (set! (-> gp-0 trans quad) (-> s4-0 quad)) + (set! (-> *part-id-table* 62 init-specs 23 initial-valuef) (vector-y-angle (-> gp-0 vector 1))) + (set! (-> *part-id-table* 62 init-specs 22 initial-valuef) (- 16384.0 (vector-x-angle (-> gp-0 vector 1)))) + (set! (-> *part-id-table* 62 init-specs 16 initial-valuef) f30-0) + ) + (sp-launch-particles-var + *sp-particle-system-2d* + (-> *part-id-table* 62) + gp-0 + (the-as sparticle-launch-state #f) + (the-as sparticle-launch-control #f) + 1.0 + ) + (case (-> arg1 datab 3) + ((11 10) + (sound-play "sizzle-drips") + (sp-launch-particles-var + *sp-particle-system-2d* + (-> *part-id-table* 66) + gp-0 + (the-as sparticle-launch-state #f) + (the-as sparticle-launch-control #f) + 1.0 + ) + (sp-launch-particles-var + *sp-particle-system-2d* + (-> *part-id-table* 65) + gp-0 + (the-as sparticle-launch-state #f) + (the-as sparticle-launch-control #f) + 1.0 + ) + ) + (else + (sound-play "dry-drips") + (set! (-> *part-id-table* 64 init-specs 10 initial-valuef) (-> arg1 omega)) + (sp-launch-particles-var + *sp-particle-system-3d* + (-> *part-id-table* 64) + gp-0 + (the-as sparticle-launch-state #f) + (the-as sparticle-launch-control #f) + 1.0 + ) + ) + ) + ) + ) + (none) + ) + +;; definition for function check-drop-level-rain2 +;; WARN: Return type mismatch symbol vs none. +(defun check-drop-level-rain2 ((arg0 sparticle-system) (arg1 sparticle-cpuinfo) (arg2 vector)) + (if (< (-> arg2 y) (-> arg1 user-float)) + (sp-kill-particle arg0 arg1) + ) + (none) + ) + +;; definition for function check-drop-level-splash +;; WARN: Return type mismatch symbol vs none. +(defun check-drop-level-splash ((arg0 sparticle-system) (arg1 sparticle-cpuinfo) (arg2 vector)) + (sparticle-motion-blur arg0 arg1 arg2) + (if (< (-> arg2 y) (-> arg1 user-float)) + (sp-kill-particle arg0 arg1) + ) + (none) + ) + +;; definition for function update-rain +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs none. +(defun update-rain ((arg0 float) (arg1 vector) (arg2 vector)) + (let ((v1-0 (new 'stack-no-clear 'vector))) + (set! (-> v1-0 x) (-> arg2 x)) + (set! (-> v1-0 y) 0.0) + (set! (-> v1-0 z) (-> arg2 z)) + (set! (-> v1-0 w) 1.0) + (let ((gp-1 (vector+float*! (new 'stack-no-clear 'vector) arg1 v1-0 0.0))) + (let ((t9-0 matrix-local->world) + (a0-3 #f) + ) + (let* ((s4-0 (t9-0 a0-3)) + (f28-0 (lerp-scale 122.88 245.76 (fabs (-> s4-0 vector 2 y)) 0.0 0.7)) + (f30-0 (lerp-scale 2048.0 245.76 (fabs (-> s4-0 vector 2 y)) 0.0 0.7)) + ) + (let ((f26-0 (lerp-scale 0.0 0.1 (-> s4-0 vector 2 y) 0.3 0.7)) + (f0-11 (lerp-scale 1.0 0.1 (-> s4-0 vector 2 y) 0.3 0.7)) + ) + (if (< 0.0 f26-0) + (send-event *camera* 'part-water-drip f26-0 f0-11) + ) + ) + (set! (-> *part-id-table* 60 init-specs 5 initial-valuef) f28-0) + (set! (-> *part-id-table* 60 init-specs 5 random-rangef) f28-0) + (set! (-> *part-id-table* 61 init-specs 5 initial-valuef) f28-0) + (set! (-> *part-id-table* 61 init-specs 5 random-rangef) f28-0) + (set! (-> *part-id-table* 60 init-specs 6 initial-valuef) f30-0) + (set! (-> *part-id-table* 60 init-specs 6 random-rangef) f30-0) + (set! (-> *part-id-table* 61 init-specs 6 initial-valuef) f30-0) + (set! (-> *part-id-table* 61 init-specs 6 random-rangef) f30-0) + ) + ) + (set! (-> *part-id-table* 60 init-specs 2 initial-valuef) arg0) + (set! (-> *part-id-table* 61 init-specs 2 initial-valuef) (* 4.0 arg0)) + (let ((t9-6 sp-launch-particles-var) + (a0-10 *sp-particle-system-2d*) + (a1-7 (-> *part-id-table* 60)) + (a2-5 *launch-matrix*) + ) + (set! (-> a2-5 trans quad) (-> gp-1 quad)) + (t9-6 a0-10 a1-7 a2-5 (the-as sparticle-launch-state #f) (the-as sparticle-launch-control #f) 1.0) + ) + (let ((t9-7 sp-launch-particles-var) + (a0-11 *sp-particle-system-2d*) + (a1-8 (-> *part-id-table* 61)) + (a2-6 *launch-matrix*) + ) + (set! (-> a2-6 trans quad) (-> gp-1 quad)) + (t9-7 a0-11 a1-8 a2-6 (the-as sparticle-launch-state #f) (the-as sparticle-launch-control #f) 1.0) + ) + ) + ) + 0 + (none) + ) + +;; definition for function cam-master-effect +;; WARN: Return type mismatch int vs none. +(defbehavior cam-master-effect camera-master () + (when (not (or (movie?) (>= (+ (-> self clock frame-counter) (seconds -10)) (-> self water-drip-time)))) + (set! (-> *part-id-table* 46 init-specs 1 initial-valuef) (-> self water-drip-mult)) + (set! (-> *part-id-table* 45 init-specs 1 initial-valuef) (* 0.9 (-> self water-drip-mult))) + (set! (-> *part-id-table* 43 init-specs 11 initial-valuef) (* -2.7306666 (-> self water-drip-speed))) + (set! (-> *part-id-table* 44 init-specs 8 initial-valuef) (* -2.7306666 (-> self water-drip-speed))) + (set! (-> *part-id-table* 41 init-specs 11 initial-valuef) (* -2.7306666 (-> self water-drip-speed))) + (set! (-> *part-id-table* 42 init-specs 8 initial-valuef) (* -2.7306666 (-> self water-drip-speed))) + (spawn (-> self water-drip) *zero-vector*) + ) + 0 + (none) + ) + +;; definition for function sparticle-track-sun +;; WARN: Return type mismatch int vs none. +(defun sparticle-track-sun ((arg0 int) (arg1 sparticle-cpuinfo) (arg2 matrix)) + (-> arg1 key) + (let* ((s3-0 (the int (-> arg1 user-float))) + (s5-0 (math-camera-pos)) + (s4-0 (+ (the-as uint (-> *sky-work* upload-data)) (* (/ s3-0 4) 64))) + ) + (let ((v1-3 (/ s3-0 4))) + (cond + ((zero? v1-3) + (set! (-> arg2 vector 1 z) (+ 8192.0 (* 0.5 (vector-y-angle (-> (math-camera-matrix) vector 2))))) + ) + ((= v1-3 1) + (set! (-> arg2 vector 1 z) (+ -8192.0 (* 0.5 (vector-y-angle (-> (math-camera-matrix) vector 2))))) + ) + ) + ) + (let ((v1-12 (vector+float*! (new 'stack-no-clear 'vector) s5-0 (the-as vector s4-0) 4096.0))) + (set! (-> arg2 vector 0 x) (-> v1-12 x)) + (set! (-> arg2 vector 0 y) (-> v1-12 y)) + (set! (-> arg2 vector 0 z) (-> v1-12 z)) + ) + ) + 0 + (none) + ) + +;; failed to figure out what this is: +(defpartgroup group-sun + :id 3 + :flags (always-draw) + :bounds (static-bspherem 0 0 0 70) + :parts ((sp-item 67 :flags (bit6)) (sp-item 68 :flags (bit6))) + ) + +;; failed to figure out what this is: +(defpart 67 + :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #xbb :page #xc)) + (sp-flt spt-num 1.0) + (sp-flt spt-scale-x (meters 2550)) + (sp-flt spt-rot-x 307200.0) + (sp-flt spt-rot-z (degrees 30.0)) + (sp-flt spt-scale-y (meters 2550)) + (sp-flt spt-r 64.0) + (sp-flt spt-g 64.0) + (sp-flt spt-b 16.0) + (sp-flt spt-a 70.0) + (sp-flt spt-omega 0.0) + (sp-int spt-timer -1) + (sp-cpuinfo-flags sp-cpuinfo-flag-2 sp-cpuinfo-flag-3 sp-cpuinfo-flag-14 glow) + (sp-flt spt-userdata 1.0) + (sp-func spt-func 'sparticle-track-sun) + ) + ) + +;; failed to figure out what this is: +(defpart 68 + :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #xbb :page #xc)) + (sp-flt spt-num 1.0) + (sp-flt spt-scale-x (meters 12000)) + (sp-flt spt-rot-x 307200.0) + (sp-flt spt-rot-z (degrees 30.0)) + (sp-flt spt-scale-y (meters 12000)) + (sp-flt spt-r 64.0) + (sp-flt spt-g 32.0) + (sp-flt spt-b 0.0) + (sp-flt spt-a 80.0) + (sp-flt spt-omega 0.0) + (sp-int spt-timer -1) + (sp-cpuinfo-flags sp-cpuinfo-flag-2 sp-cpuinfo-flag-3 sp-cpuinfo-flag-14 glow) + (sp-flt spt-userdata 1.0) + (sp-func spt-func 'sparticle-track-sun) + ) + ) + +;; failed to figure out what this is: +(defpartgroup group-green-sun + :id 4 + :flags (always-draw) + :bounds (static-bspherem 0 0 0 70) + :parts ((sp-item 69 :flags (bit6)) (sp-item 70 :flags (bit6))) + ) + +;; failed to figure out what this is: +(defpart 69 + :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #xbb :page #xc)) + (sp-flt spt-num 1.0) + (sp-flt spt-scale-x (meters 1500)) + (sp-flt spt-rot-x 204800.0) + (sp-flt spt-rot-z (degrees 30.0)) + (sp-flt spt-scale-y (meters 1500)) + (sp-flt spt-r 16.0) + (sp-flt spt-g 64.0) + (sp-flt spt-b 32.0) + (sp-flt spt-a 64.0) + (sp-flt spt-omega 0.0) + (sp-int spt-timer -1) + (sp-cpuinfo-flags sp-cpuinfo-flag-2 sp-cpuinfo-flag-3 sp-cpuinfo-flag-14 glow) + (sp-flt spt-userdata 4.0) + (sp-func spt-func 'sparticle-track-sun) + ) + ) + +;; failed to figure out what this is: +(defpart 70 + :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #xbb :page #xc)) + (sp-flt spt-num 1.0) + (sp-flt spt-scale-x (meters 3000)) + (sp-flt spt-rot-x 204800.0) + (sp-flt spt-rot-z (degrees 30.0)) + (sp-flt spt-scale-y (meters 3000)) + (sp-flt spt-r 0.0) + (sp-flt spt-g 43.0) + (sp-flt spt-b 8.0) + (sp-flt spt-a 64.0) + (sp-flt spt-omega 0.0) + (sp-int spt-timer -1) + (sp-cpuinfo-flags sp-cpuinfo-flag-2 sp-cpuinfo-flag-3 sp-cpuinfo-flag-14 glow) + (sp-flt spt-userdata 4.0) + (sp-func spt-func 'sparticle-track-sun) + ) + ) + +;; failed to figure out what this is: +(defpartgroup group-moon + :id 5 + :flags (always-draw) + :bounds (static-bspherem 0 0 0 70) + :parts ((sp-item 71 :flags (bit6))) + ) + +;; failed to figure out what this is: +(defpart 71 + :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #xca :page #xc)) + (sp-flt spt-num 1.0) + (sp-flt spt-scale-x (meters 6000)) + (sp-flt spt-rot-x 544768.0) + (sp-flt spt-rot-z (degrees 30.0)) + (sp-flt spt-scale-y (meters 6000)) + (sp-flt spt-r 16.0) + (sp-flt spt-g 32.0) + (sp-flt spt-b 64.0) + (sp-flt spt-a 64.0) + (sp-flt spt-omega 0.0) + (sp-int spt-timer -1) + (sp-cpuinfo-flags sp-cpuinfo-flag-2 sp-cpuinfo-flag-3 sp-cpuinfo-flag-14 glow) + (sp-flt spt-userdata 8.0) + (sp-func spt-func 'sparticle-track-sun) + ) + ) diff --git a/goal_src/jak2/engine/gfx/sprite/particles/sparticle-h.gc b/goal_src/jak2/engine/gfx/sprite/particles/sparticle-h.gc index fc1f515a20..d26cff86b8 100644 --- a/goal_src/jak2/engine/gfx/sprite/particles/sparticle-h.gc +++ b/goal_src/jak2/engine/gfx/sprite/particles/sparticle-h.gc @@ -36,16 +36,20 @@ ) ;; ---sp-cpuinfo-flag -;; NOTE - for relocate +(defenum sp-cpuinfo-flag-s32 + :bitfield #t + :type int32 + :copy-entries sp-cpuinfo-flag + ) + + (declare-type sparticle-system basic) (declare-type sparticle-cpuinfo structure) (declare-type sparticle-launch-control inline-array-class) (define-extern forall-particles-with-key (function sparticle-launch-control (function sparticle-system sparticle-cpuinfo none) symbol symbol none)) -;; NOTE - for many things (define-extern *part-id-table* (array sparticle-launcher)) -;; NOTE - for sparticle-launcher (define-extern sp-get-particle (function sparticle-system int sparticle-launch-state sparticle-cpuinfo)) (define-extern kill-all-particles-with-key (function sparticle-launch-control none)) (define-extern sp-kill-particle (function sparticle-system sparticle-cpuinfo symbol)) @@ -70,7 +74,8 @@ (scalevely float :offset 44) (friction float :offset-assert 96) (timer int32 :offset-assert 100) - (flags sp-cpuinfo-flag :offset-assert 104) + (flags sp-cpuinfo-flag :offset-assert 104) ;; NOTE - loaded with lw and lwu? + (flags-s32 sp-cpuinfo-flag-s32 :offset 104) (user-int32 int32 :offset-assert 108) (user-uint32 uint32 :offset 108) (user-float float :offset 108) @@ -88,7 +93,7 @@ (key-alt sparticle-launch-state :offset 132) (binding sparticle-launch-state :offset-assert 136) (data uint32 1 :offset 12) - (datab uint8 4 :offset 12) + (datab int8 4 :offset 12) (dataf float 1 :offset 12) (datac uint8 1 :offset 12) ) @@ -144,3 +149,5 @@ +(define-extern *sp-particle-system-2d* sparticle-system) +(define-extern *sp-particle-system-3d* sparticle-system) \ No newline at end of file diff --git a/goal_src/jak2/engine/gfx/sprite/particles/sparticle-launcher-h.gc b/goal_src/jak2/engine/gfx/sprite/particles/sparticle-launcher-h.gc index 80c323e4d2..9a0b39383c 100644 --- a/goal_src/jak2/engine/gfx/sprite/particles/sparticle-launcher-h.gc +++ b/goal_src/jak2/engine/gfx/sprite/particles/sparticle-launcher-h.gc @@ -357,7 +357,7 @@ :flag-assert #xb00000010 (:methods (get-field-spec-by-id (_type_ sp-field-id) sp-field-init-spec 9) - (sparticle-launcher-method-10 (_type_ string) none 10) + (setup-user-array (_type_ string) none 10) ) ) @@ -447,10 +447,10 @@ :flag-assert #x1000000070 (:methods (initialize (_type_ sparticle-launch-group process) none 9) - (sparticle-launch-control-method-10 (_type_ vector) symbol 10) + (is-visible? (_type_ vector) symbol 10) (spawn (_type_ vector) none 11) - (sparticle-launch-control-method-12 (_type_ matrix) none 12) - (sparticle-launch-control-method-13 (_type_ cspace) none 13) + (spawn-with-matrix (_type_ matrix) none 12) + (spawn-with-cspace (_type_ cspace) none 13) (kill-and-free-particles (_type_) none 14) (kill-particles (_type_) none 15) ) diff --git a/goal_src/jak2/engine/gfx/sprite/particles/sparticle-launcher.gc b/goal_src/jak2/engine/gfx/sprite/particles/sparticle-launcher.gc index da3aabcdba..971b6ca654 100644 --- a/goal_src/jak2/engine/gfx/sprite/particles/sparticle-launcher.gc +++ b/goal_src/jak2/engine/gfx/sprite/particles/sparticle-launcher.gc @@ -5,6 +5,8 @@ ;; name in dgo: sparticle-launcher ;; dgos: ENGINE, GAME +;; TODO sparticle-texture-day-night vf1/vf2 issue + ;; og:ignore-form:sp-relaunch-particle-3d ;; og:ignore-form:execute-part-engine ;; og:ignore-form:sparticle-respawn-heights @@ -19,7 +21,6 @@ (define-extern sp-init-fields! (function object (inline-array sp-field-init-spec) sp-field-id sp-field-id symbol object)) ;; TODO - mips2c (define-extern particle-adgif (function adgif-shader texture-id none)) ;; TODO - particle-adgif atomic ops, MIPS2C -(define-extern particle-adgif-callback (function adgif-shader none)) ;; TODO bad VF dependencies (define-extern sp-launch-particles-var (function sparticle-system sparticle-launcher matrix sparticle-launch-state sparticle-launch-control float none)) ;; TODO - mips2c ;; DECOMP BEGINS @@ -95,7 +96,7 @@ 0 ) -;; ERROR: function was not converted to expressions. Cannot decompile. +(def-mips2c sp-init-fields! (function object (inline-array sp-field-init-spec) sp-field-id sp-field-id symbol object)) (deftype sp-queued-launch-particles (structure) ((sp-system sparticle-system :offset-assert 0) @@ -128,7 +129,32 @@ (kmemclose) -;; ERROR: function has no type analysis. Cannot decompile. +(defun particle-setup-adgif ((arg0 adgif-shader) (arg1 int)) + (let ((a1-1 (lookup-texture-by-id-fast (the-as texture-id arg1))) + (s5-0 #f) + ) + (when (not a1-1) + (set! a1-1 (lookup-texture-by-id-fast (new 'static 'texture-id :index #x9b :page #xb))) + (set! s5-0 #t) + ) + (set! (-> arg0 tex1) (new 'static 'gs-tex1 :mmag #x1 :mmin #x1)) + (set! (-> arg0 tex0 tfx) 0) + (adgif-shader<-texture! arg0 a1-1) + (set! (-> arg0 prims 1) (gs-reg64 tex0-1)) + (set! (-> arg0 prims 3) (the-as gs-reg64 (logior arg1 20))) + (set! (-> arg0 prims 5) (gs-reg64 miptbp1-1)) + (set! (-> arg0 clamp-reg) (gs-reg64 zbuf-1)) + (set! (-> arg0 prims 9) (gs-reg64 alpha-1)) + (if s5-0 + (logior! (-> arg0 link-test) (link-test-flags backup-sprite-tex)) + ) + ) + (set! (-> arg0 alpha) (new 'static 'gs-alpha :b #x1 :d #x1)) + (set! (-> arg0 clamp) (new 'static 'gs-clamp :minu #x13 :minv #x101)) + 0 + (none) + ) + (deftype particle-adgif-cache (basic) ((used int32 :offset-assert 4) @@ -159,9 +185,46 @@ (none) ) -;; ERROR: function was not converted to expressions. Cannot decompile. +(def-mips2c particle-adgif (function adgif-shader texture-id none)) -;; ERROR: function was not converted to expressions. Cannot decompile. + +(defun particle-adgif-callback ((arg0 adgif-shader) (arg1 texture-id)) + "Callback to update the adgif of a particle, keeping only alpha and clamp. + This is new for jak 2. + There is some funny stuff going on with vf16 - vf20, but it seems like this function just + preserves those registers (which particle-adgif likely clobbers) so this doesn't clobber + registers used by particle system, which it assumes are preserved across callbacks." + (local-vars (v1-0 float)) + (rlet ((vf16 :class vf) + (vf17 :class vf) + (vf18 :class vf) + (vf19 :class vf) + (vf20 :class vf) + ) + (let ((s5-0 (new 'stack-no-clear 'inline-array 'vector 4))) + (let ((s4-0 (-> arg0 alpha)) + (s3-0 (-> arg0 clamp)) + ) + ; (.svf (&-> s5-0 0 quad) vf16) + ; (.svf (&-> s5-0 1 quad) vf17) + ; (.svf (&-> s5-0 2 quad) vf18) + ; (.svf (&-> s5-0 3 quad) vf19) + ; (.svf (&-> s5-0 4 quad) vf20) + (particle-adgif arg0 arg1) + (set! (-> arg0 alpha) s4-0) + (set! (-> arg0 clamp) s3-0) + ) + ; (.lvf vf16 (&-> s5-0 0 quad)) + ; (.lvf vf17 (&-> s5-0 1 quad)) + ; (.lvf vf18 (&-> s5-0 2 quad)) + ; (.lvf vf19 (&-> s5-0 3 quad)) + ; (.lvf vf20 (&-> s5-0 4 quad)) + ) + (.mov v1-0 vf20) + 0 + (none) + ) + ) (defun sp-queue-launch ((arg0 sparticle-system) (arg1 sparticle-launcher) (arg2 matrix)) (let ((v1-0 *sp-launch-queue*)) @@ -327,7 +390,7 @@ ) -;; ERROR: function was not converted to expressions. Cannot decompile. +(def-mips2c sp-launch-particles-var (function sparticle-system sparticle-launcher matrix sparticle-launch-state sparticle-launch-control float none)) (define *death-adgif* (the-as adgif-shader #f)) @@ -567,11 +630,83 @@ (none) ) -;; ERROR: failed type prop at 32: Could not figure out load: (set! a1 (l.w (+ gp 104))) +(defun sp-relaunch-particle-3d ((arg0 object) (arg1 sparticle-launcher) (arg2 sparticle-cpuinfo) (arg3 sprite-vec-data-3d)) + (local-vars (v1-9 float) (v1-10 float)) + (rlet ((vf0 :class vf) + (vf1 :class vf) + (vf2 :class vf) + ) + (init-vf0-vector) + (let ((s4-0 (new 'stack-no-clear 'quaternion))) + (let* ((v1-0 s4-0) + (a2-1 arg3) + (f0-0 (-> a2-1 qx-qy-qz-sy x)) + (f1-0 (-> a2-1 qx-qy-qz-sy y)) + (f2-0 (-> a2-1 qx-qy-qz-sy z)) + ) + (set! (-> v1-0 x) f0-0) + (set! (-> v1-0 y) f1-0) + (set! (-> v1-0 z) f2-0) + (set! (-> v1-0 w) (sqrtf (- (- (- 1.0 (* f2-0 f2-0)) (* f1-0 f1-0)) (* f0-0 f0-0)))) + ) + (set! (-> arg3 qx-qy-qz-sy x) 0.0) + (set! (-> arg3 qx-qy-qz-sy y) 0.0) + (set! (-> arg3 qx-qy-qz-sy z) 0.0) + (sp-relaunch-setup-fields arg0 arg1 arg2 arg3) -;; TODO stub -(defmethod spawn sparticle-launch-control ((obj sparticle-launch-control) (arg0 vector)) - (none) + ;; some truly strange flag weirdness. + (let* ((a1-1 (-> arg2 flags-s32)) + (v1-1 -2) + (a0-1 (the-as uint (-> arg3 r-g-b-a x))) + (a1-2 (logand a1-1 (sp-cpuinfo-flag-s32 sp-cpuinfo-flag-14))) + ) + 1 + (let ((a1-3 (sar (the-as int a1-2) 14))) + (set! (-> arg3 r-g-b-a x) (the-as float (logior (logand a0-1 (the-as uint v1-1)) a1-3))) + ) + ) + (let ((a1-4 (new 'stack-no-clear 'vector)) + (s3-0 (new 'stack-no-clear 'quaternion)) + ) + (set-vector! a1-4 (-> arg3 qx-qy-qz-sy x) (-> arg3 qx-qy-qz-sy y) (-> arg3 qx-qy-qz-sy z) 1.0) + (quaternion-zxy! s3-0 a1-4) + (if (logtest? (sp-cpuinfo-flag left-multiply-quat) (-> arg2 flags)) + (quaternion*! s3-0 s4-0 s3-0) + ) + (cond + ((< (-> s3-0 w) 0.0) + (.lvf vf1 (&-> arg3 qx-qy-qz-sy quad)) + (.lvf vf2 (&-> s3-0 vec quad)) + (.sub.vf vf1 vf0 vf2 :mask #b111) + (.svf (&-> arg3 qx-qy-qz-sy quad) vf1) + (.mov v1-9 vf1) + ) + (else + (.lvf vf1 (&-> arg3 qx-qy-qz-sy quad)) + (.lvf vf2 (&-> s3-0 vec quad)) + (.add.vf vf1 vf0 vf2 :mask #b111) + (.svf (&-> arg3 qx-qy-qz-sy quad) vf1) + (.mov v1-10 vf1) + ) + ) + ) + ) + (cond + (*sp-60-hz* + (set! (-> arg2 rot-syvel x) (* 5.0 (-> arg2 rot-syvel x))) + (set! (-> arg2 rot-syvel y) (* 5.0 (-> arg2 rot-syvel y))) + (set! (-> arg2 rot-syvel z) (* 5.0 (-> arg2 rot-syvel z))) + ) + (else + (set! (-> arg2 rot-syvel x) (* 6.0 (-> arg2 rot-syvel x))) + (set! (-> arg2 rot-syvel y) (* 6.0 (-> arg2 rot-syvel y))) + (set! (-> arg2 rot-syvel z) (* 6.0 (-> arg2 rot-syvel z))) + ) + ) + (quaternion-zxy! (-> arg2 rotvel3d) (-> arg2 rot-syvel)) + 0 + (none) + ) ) (defmethod initialize sparticle-launch-control ((obj sparticle-launch-control) (arg0 sparticle-launch-group) (arg1 process)) @@ -695,7 +830,7 @@ (none) ) -(defmethod sparticle-launch-control-method-10 sparticle-launch-control ((obj sparticle-launch-control) (arg0 vector)) +(defmethod is-visible? sparticle-launch-control ((obj sparticle-launch-control) (arg0 vector)) (let* ((v1-0 (-> obj group)) (f0-0 (-> v1-0 bounds r)) ) @@ -726,7 +861,7 @@ ) ) -(defmethod sparticle-launch-control-method-12 sparticle-launch-control ((obj sparticle-launch-control) (arg0 matrix)) +(defmethod spawn-with-matrix sparticle-launch-control ((obj sparticle-launch-control) (arg0 matrix)) (let* ((a2-0 (-> obj origin)) (a3-0 arg0) (v1-0 (-> a3-0 vector 0 quad)) @@ -772,7 +907,7 @@ (none) ) -(defmethod sparticle-launch-control-method-13 sparticle-launch-control ((obj sparticle-launch-control) (arg0 cspace)) +(defmethod spawn-with-cspace sparticle-launch-control ((obj sparticle-launch-control) (arg0 cspace)) (let* ((v1-0 (-> obj origin)) (a3-0 (-> arg0 bone transform)) (a0-2 (-> a3-0 vector 0 quad)) @@ -818,10 +953,298 @@ (none) ) -;; ERROR: function was not converted to expressions. Cannot decompile. +(defmethod spawn sparticle-launch-control ((obj sparticle-launch-control) (arg0 vector)) + (with-pp + (set! (-> obj origin trans quad) (-> arg0 quad)) + (if (not (or (is-visible? obj arg0) (logtest? (-> obj group flags) (sp-group-flag always-draw screen-space)))) + (return 0) + ) + (let ((s4-0 (the-as int (-> pp clock frame-counter))) + (s5-0 (-> obj last-spawn-time)) + ) + (let ((v1-10 (-> *display* real-frame-clock integral-frame-counter))) + (if (!= v1-10 (+ (-> obj last-spawn-frame) 1)) + (set! s5-0 (the-as int (- (the-as time-frame s4-0) (logand (the-as int (-> pp clock sparticle-data x)) 255)))) + ) + ) + (set! (-> obj last-spawn-frame) (the-as int (-> *display* real-frame-clock integral-frame-counter))) + (set! (-> obj last-spawn-time) s4-0) + (when (logtest? (-> obj group flags) (sp-group-flag use-local-clock)) + (set! s5-0 (-> obj local-clock)) + (+! (-> obj local-clock) (logand (the-as int (-> pp clock sparticle-data x)) 255)) + (set! s4-0 (-> obj local-clock)) + ) + (let* ((f30-0 (vector-vector-distance arg0 (math-camera-pos))) + (v1-26 1) + (a0-13 *time-of-day*) + (s3-1 (ash v1-26 (if a0-13 + (-> a0-13 0 hours) + 0 + ) + ) + ) + ) + (if (nonzero? (-> obj matrix)) + (set! f30-0 0.0) + ) + (let ((s2-1 (-> obj length))) + (b! #t cfg-95 :delay (nop!)) + (label cfg-19) + (+! s2-1 -1) + (let* ((a3-0 (-> obj data s2-1)) + (v1-33 (-> a3-0 group-item)) + (a1-4 (-> *part-id-table* (-> v1-33 launcher))) + ) + (b! + (not (and a1-4 (nonzero? a1-4) (logtest? (-> a3-0 flags) (sp-launch-state-flags launcher-active)))) + cfg-95 + :delay (empty-form) + ) + (let* ((f1-3 (if (!= (-> v1-33 falloff-to) 0.0) + (- 1.0 (/ f30-0 (-> v1-33 falloff-to))) + 1.0 + ) + ) + (f0-5 f1-3) + ) + (let ((a0-25 sparticle-launcher)) + (b! (!= (-> a1-4 type) a0-25) cfg-94 :delay (nop!)) + ) + (b! (not (logtest? (-> v1-33 flags) (sp-group-item-flag launch-asap))) cfg-42 :delay (nop!)) + (when (not (logtest? (-> a3-0 flags) (sp-launch-state-flags particles-active))) + (set! (-> a3-0 spawn-time) (the-as uint s4-0)) + (logior! (-> a3-0 flags) (sp-launch-state-flags particles-active)) + (when (< 0.0 f0-5) + (b! (not (logtest? (-> v1-33 flags) (sp-group-item-flag bit7))) cfg-37 :delay (nop!)) + (let ((t9-3 sp-launch-particles-var)) + (b! (not (logtest? (-> v1-33 flags) (sp-group-item-flag is-3d))) cfg-35 :delay (nop!)) + (let ((a0-36 *sp-particle-system-3d*)) + (b! #t cfg-36 :delay (nop!)) + (label cfg-35) + (set! a0-36 *sp-particle-system-2d*) + (label cfg-36) + (t9-3 a0-36 a1-4 (-> obj origin) a3-0 obj f0-5) + ) + ) + (b! #t cfg-41 :delay (nop!)) + (label cfg-37) + (let ((t9-4 sp-launch-particles-var) + (a0-38 (if (logtest? (-> v1-33 flags) (sp-group-item-flag is-3d)) + *sp-particle-system-3d* + *sp-particle-system-2d* + ) + ) + (a2-4 *launch-matrix*) + ) + (set! (-> a2-4 trans quad) (-> a3-0 center quad)) + (t9-4 a0-38 a1-4 a2-4 a3-0 obj f0-5) + ) + ) + ) + (label cfg-41) + (b! #t cfg-93 :delay (nop!)) + (label cfg-42) + (when (or (logtest? s3-1 (-> v1-33 hour-mask)) + (not (or (= (-> v1-33 fade-after) 0.0) (< f30-0 (-> v1-33 fade-after)))) + ) + 0 + (goto cfg-93) + ) + (b! (nonzero? (-> v1-33 period)) cfg-59 :delay (empty-form)) + (if (not (logtest? (-> v1-33 flags) (sp-group-item-flag bit6))) + (set! f0-5 (* 0.2 (the float (- s4-0 s5-0)) f0-5)) + ) + (b! #t cfg-81 :delay (nop!)) + (label cfg-59) + 0 + 0 + (let* ((a2-5 (-> v1-33 length)) + (a0-57 (-> v1-33 period)) + (t0-10 (mod (+ (- s5-0 (the-as int (-> obj data s2-1 offset))) a0-57) (the-as int a0-57))) + (a0-58 (mod (the-as uint (+ (- s4-0 (the-as int (-> obj data s2-1 offset))) a0-57)) a0-57)) + ) + (set! f0-5 (cond + ((and (< t0-10 (the-as int a2-5)) (< (the-as int a0-58) (the-as int a2-5))) + (* 0.2 (the float (- s4-0 s5-0)) f0-5) + ) + ((and (< t0-10 (the-as int a2-5)) (>= (the-as int a0-58) (the-as int a2-5))) + (* 0.2 (the float (- a2-5 (the-as uint t0-10))) f0-5) + ) + ((and (>= t0-10 (the-as int a2-5)) (< (the-as int a0-58) (the-as int a2-5))) + (* 0.2 (the float a0-58) f0-5) + ) + (else + (when (not (logtest? (-> v1-33 flags) (sp-group-item-flag bit1))) + 0 + (goto cfg-93) + ) + (when (< (the-as uint (- s4-0 (the-as int (-> obj data s2-1 spawn-time)))) (-> v1-33 period)) + 0 + (goto cfg-93) + ) + (set! (-> obj data s2-1 offset) (- (-> v1-33 period) a0-58)) + (* 0.2 (the float (- s4-0 s5-0)) f0-5) + ) + ) + ) + ) + (label cfg-81) + (set! (-> a3-0 spawn-time) (the-as uint s4-0)) + (logior! (-> a3-0 flags) (sp-launch-state-flags particles-active)) + (when (< 0.0 f0-5) + (if (logtest? (-> v1-33 flags) (sp-group-item-flag bit6)) + (set! f0-5 f1-3) + ) + (cond + ((logtest? (-> v1-33 flags) (sp-group-item-flag bit7)) + (sp-launch-particles-var + (if (logtest? (-> v1-33 flags) (sp-group-item-flag is-3d)) + *sp-particle-system-3d* + *sp-particle-system-2d* + ) + a1-4 + (-> obj origin) + a3-0 + obj + f0-5 + ) + ) + (else + (let ((t9-6 sp-launch-particles-var) + (a0-83 (if (logtest? (-> v1-33 flags) (sp-group-item-flag is-3d)) + *sp-particle-system-3d* + *sp-particle-system-2d* + ) + ) + (a2-22 *launch-matrix*) + ) + (set! (-> a2-22 trans quad) (-> a3-0 center quad)) + (t9-6 a0-83 a1-4 a2-22 a3-0 obj f0-5) + ) + ) + ) + ) + ) + ) + (label cfg-93) + (b! #t cfg-95 :delay (nop!)) + (label cfg-94) + (format 0 "spawn called for non-sparticle-launcher~%") + (label cfg-95) + (b! (nonzero? s2-1) cfg-19 :delay (nop!)) + ) + ) + ) + 0 + (none) + ) + ) -;; ERROR: failed type prop at 12: Could not figure out load: (set! a1 (l.wu (+ a0 132))) +(defun execute-part-engine () + (local-vars (sv-96 sparticle-launcher) (sv-104 int)) + (let ((gp-0 *sp-particle-system-2d*)) + (let* ((s5-0 *part-engine*) + (s4-0 *part-id-table*) + (s3-0 (new 'stack-no-clear 'matrix)) + (s2-0 (new 'stack-no-clear 'vector)) + (v1-1 (-> s5-0 alive-list next0)) + (s1-0 (-> v1-1 next0)) + ) + (while (!= v1-1 (-> s5-0 alive-list-end)) + (let* ((a0-2 (the-as process-drawable (-> (the-as connection v1-1) param1))) + (a1-0 (-> a0-2 draw)) + (s0-0 (the-as object (-> (the-as connection v1-1) param3))) + ) + (when (and (logtest? (-> a1-0 status) (draw-control-status on-screen)) + (< (-> a1-0 distance) (-> (the-as vector s0-0) w)) + ) + (set! sv-96 (-> s4-0 (-> (the-as connection v1-1) param2))) + (set! sv-104 (the-as int (-> (the-as connection v1-1) param0))) + (when (nonzero? sv-96) + (let ((a1-8 (-> a0-2 node-list data sv-104))) + (let* ((v1-7 s3-0) + (t0-0 (-> a1-8 bone transform)) + (a0-5 (-> t0-0 vector 0 quad)) + (a2-2 (-> t0-0 vector 1 quad)) + (a3-0 (-> t0-0 vector 2 quad)) + (t0-1 (-> t0-0 trans quad)) + ) + (set! (-> v1-7 vector 0 quad) a0-5) + (set! (-> v1-7 vector 1 quad) a2-2) + (set! (-> v1-7 vector 2 quad) a3-0) + (set! (-> v1-7 trans quad) t0-1) + ) + (vector<-cspace! (-> s3-0 trans) a1-8) + ) + (set! (-> s2-0 quad) (-> (the-as vector s0-0) quad)) + (set! (-> s2-0 w) 1.0) + (vector-matrix*! (-> s3-0 trans) s2-0 s3-0) + (sp-launch-particles-var + gp-0 + sv-96 + s3-0 + (the-as sparticle-launch-state #f) + (the-as sparticle-launch-control #f) + 1.0 + ) + ) + ) + ) + (set! v1-1 s1-0) + (set! s1-0 (-> s1-0 next0)) + ) + ) + (let* ((s5-1 (camera-pos)) + (v1-12 1) + (a0-14 *time-of-day*) + (s4-1 (ash v1-12 (if a0-14 + (-> a0-14 0 hours) + 0 + ) + ) + ) + ) + (dotimes (s3-1 (-> *level* length)) + (let ((v1-16 (-> *level* level s3-1))) + (when (= (-> v1-16 status) 'active) + (let ((s2-1 (-> v1-16 part-engine))) + (when s2-1 + (countdown (s1-1 (-> s2-1 length)) + (let ((s0-1 (-> s2-1 data s1-1))) + (when (and (or (zero? (-> s0-1 param3)) + (< (vector-vector-distance s5-1 (the-as vector (&-> s0-1 param0))) (the-as float (-> s0-1 param3))) + ) + (zero? (logand s4-1 (the-as int (-> s0-1 prev1)))) + ) + (let ((a1-14 (-> s0-1 next1)) + (t9-5 sp-launch-particles-var) + (a0-25 gp-0) + (a2-5 *launch-matrix*) + ) + (set! (-> a2-5 trans quad) (-> (the-as vector (&-> s0-1 param0)) quad)) + (t9-5 + a0-25 + (the-as sparticle-launcher a1-14) + a2-5 + (the-as sparticle-launch-state #f) + (the-as sparticle-launch-control #f) + 1.0 + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + 0 + (none) + ) (defun sparticle-track-root ((arg0 object) (arg1 sparticle-cpuinfo) (arg2 vector)) (let ((v1-3 (-> arg1 key proc root trans))) (set! (-> arg2 x) (-> v1-3 x)) @@ -1027,29 +1450,335 @@ (none) ) -;; ERROR: failed type prop at 12: Could not figure out load: (set! v1 (l.w (+ gp 16))) +(defun sparticle-respawn-heights ((arg0 sparticle-system) (arg1 sparticle-cpuinfo) (arg2 vector)) + (let ((gp-0 (the-as (array int32) (-> arg1 user-float)))) + (when (and (nonzero? gp-0) + (or (and (< (-> arg1 vel-sxvel y) 0.0) (< (-> arg2 y) (the-as float (-> gp-0 1)))) + (and (< 0.0 (-> arg1 vel-sxvel y)) (< (the-as float (-> gp-0 2)) (-> arg2 y))) + ) + ) + (sp-kill-particle arg0 arg1) + (let ((s3-0 (+ (the-as int (-> gp-0 length)) -1))) + (when (< 2 s3-0) + (let ((s2-0 (new 'stack-no-clear 'vector)) + (s1-0 (if (zero? (-> gp-0 0)) + *sp-particle-system-2d* + *sp-particle-system-3d* + ) + ) + ) + (set-vector! s2-0 (-> arg2 x) (-> arg1 user-float) (-> arg2 z) 1.0) + (let ((s5-1 3)) + (while (>= s3-0 s5-1) + (let ((t9-1 sp-launch-particles-var) + (a0-2 s1-0) + (a1-3 (-> *part-id-table* (-> gp-0 s5-1))) + (a2-1 *launch-matrix*) + ) + (set! (-> a2-1 trans quad) (-> s2-0 quad)) + (t9-1 a0-2 a1-3 a2-1 (the-as sparticle-launch-state #f) (the-as sparticle-launch-control #f) 1.0) + ) + (+! s5-1 1) + ) + ) + ) + ) + ) + ) + ) + 0 + (none) + ) -;; ERROR: failed type prop at 9: Could not figure out load: (set! v1 (l.w gp)) -;; ERROR: failed type prop at 2: Could not figure out load: (set! a0 (l.w (+ v1 20))) +(defun sparticle-respawn-timer ((arg0 sparticle-system) (arg1 sparticle-cpuinfo) (arg2 vector)) + (when (<= (-> arg1 timer) 0) + (let ((gp-0 (the-as object (-> arg1 user-float)))) + (when (nonzero? (the-as float gp-0)) + (sp-kill-particle arg0 arg1) + (let ((s5-0 (+ (the-as int (-> (the-as (array int32) gp-0) length)) -1))) + (when (< 2 s5-0) + (let ((s4-0 (new 'stack-no-clear 'vector)) + (s3-0 (if (zero? (-> (the-as (array int32) gp-0) 0)) + *sp-particle-system-2d* + *sp-particle-system-3d* + ) + ) + ) + (set-vector! s4-0 (-> arg2 x) (-> arg1 user-float) (-> arg2 z) 1.0) + (let ((s2-1 3)) + (while (>= s5-0 s2-1) + (let ((t9-1 sp-launch-particles-var) + (a0-2 s3-0) + (a1-3 (-> *part-id-table* (-> (the-as (array int32) gp-0) s2-1))) + (a2-1 *launch-matrix*) + ) + (set! (-> a2-1 trans quad) (-> s4-0 quad)) + (t9-1 a0-2 a1-3 a2-1 (the-as sparticle-launch-state #f) (the-as sparticle-launch-control #f) 1.0) + ) + (+! s2-1 1) + ) + ) + ) + ) + ) + ) + ) + ) + 0 + (none) + ) -;; ERROR: failed type prop at 21: Could not figure out load: (set! a1 (l.w (+ s2 40))) -;; ERROR: Bad vector register dependency: vf1 -;; ERROR: Bad vector register dependency: vf2 +(defun sparticle-texture-animate ((arg0 sparticle-system) (arg1 sparticle-cpuinfo) (arg2 vector)) + (let ((v1-0 (the-as (array int32) (-> arg1 user-float)))) + (when (nonzero? v1-0) + (if (zero? (-> v1-0 2)) + (set! (-> v1-0 2) (-> arg1 timer)) + ) + (let* ((a0-6 (+ (-> v1-0 length) -3)) + (a2-1 (-> v1-0 0)) + (a3-0 (-> v1-0 2)) + (t0-1 (if (< (-> arg1 timer) 0) + (the-as int (-> *display* base-clock frame-counter)) + (- a3-0 (-> arg1 timer)) + ) + ) + ) + (cond + ((zero? (-> v1-0 1)) + (let ((v1-2 (-> v1-0 (+ (max 0 (min (+ (/ t0-1 a2-1) (-> arg1 user1-int16)) (+ a0-6 -1))) 3)))) + (if (nonzero? v1-2) + (particle-adgif-callback (-> arg1 adgif) (the-as texture-id v1-2)) + ) + ) + ) + (else + (let ((v1-4 (-> v1-0 (+ (mod (max 0 (+ (/ t0-1 a2-1) (-> arg1 user1-int16))) a0-6) 3)))) + (if (nonzero? v1-4) + (particle-adgif-callback (-> arg1 adgif) (the-as texture-id v1-4)) + ) + ) + ) + ) + ) + ) + ) + (none) + ) -;; ERROR: failed type prop at 5: Could not figure out load: (set! a1 (l.w (+ v1 12))) +;; TODO: vf1/vf2 get set from somewhere... +(defun sparticle-texture-day-night ((arg0 sparticle-system) (arg1 sparticle-cpuinfo) (arg2 sprite-vec-data-2d)) + (local-vars + (v1-9 uint128) + (v1-10 uint128) + (v1-13 uint128) + (v1-14 uint128) + (v1-23 uint128) + (v1-24 uint128) + (v1-27 uint128) + (v1-28 uint128) + (v1-33 float) + (a0-5 float) + (a0-11 float) + (t7-0 uint) ;; changed + (t7-3 uint) ;; changed + (s3-0 float) + (s4-0 float) + ) + (rlet ((vf1 :class vf) + (vf2 :class vf) + ) + (let ((s2-0 (the-as object (-> arg1 user-float)))) + (when (nonzero? (the-as float s2-0)) + (let* ((v1-1 *time-of-day*) + (s1-0 (if v1-1 + (-> v1-1 0 hours) + 0 + ) + ) + (f0-0 (rand-vu)) + ) + (.mov s4-0 vf1) + (.mov s3-0 vf2) + (cond + ((or (< s1-0 6) (< 18 s1-0)) + (let ((a1-1 (-> (the-as (array int32) s2-0) 7))) + (when (nonzero? a1-1) + (let ((v1-6 f0-0)) + (.mov vf2 v1-6) + ) + (let ((v1-8 (the-as uint128 (make-u128 0 (-> (the-as (array int32) s2-0) 9))))) + (.pextlb v1-9 0 v1-8) + ) + (.pextlb v1-10 0 v1-9) + (.mov vf1 v1-10) + (.itof.vf vf1 vf1) + (.mul.x.vf vf1 vf1 vf2) + (let ((v1-12 (the-as uint128 (make-u128 0 (-> (the-as (array int32) s2-0) 8))))) + (.pextlb v1-13 0 v1-12) + ) + (.pextlb v1-14 0 v1-13) + (.mov vf2 v1-14) + (.itof.vf vf2 vf2) + (.add.vf vf1 vf1 vf2) + (let ((v1-15 (-> arg1 flags-s32))) + (when (nonzero? (-> (the-as (array int32) s2-0) 10)) + (.lvf vf2 (&-> *time-of-day-context* current-prt-color quad)) + (.mul.vf vf1 vf1 vf2) + (.mov a0-5 vf1) + ) + (let ((v1-16 (logand v1-15 (sp-cpuinfo-flag-s32 sp-cpuinfo-flag-14)))) + (.mov t7-0 vf1) + (let ((v1-17 (sar (the-as int v1-16) 14))) + (set! (-> arg2 r-g-b-a quad) (the-as uint128 (logior (logand t7-0 (the-as uint -2)) v1-17))) + ) + ) + ) + (particle-adgif-callback (-> arg1 adgif) (the-as texture-id a1-1)) + ) + ) + ) + (else + (let ((a1-2 (-> (the-as (array int32) s2-0) 3))) + (when (nonzero? a1-2) + (let ((v1-20 f0-0)) + (.mov vf2 v1-20) + ) + (let ((v1-22 (the-as uint128 (make-u128 0 (-> (the-as (array int32) s2-0) 5))))) + (.pextlb v1-23 0 v1-22) + ) + (.pextlb v1-24 0 v1-23) + (.mov vf1 v1-24) + (.itof.vf vf1 vf1) + (.mul.x.vf vf1 vf1 vf2) + (let ((v1-26 (the-as uint128 (make-u128 0 (-> (the-as (array int32) s2-0) 4))))) + (.pextlb v1-27 0 v1-26) + ) + (.pextlb v1-28 0 v1-27) + (.mov vf2 v1-28) + (.itof.vf vf2 vf2) + (.add.vf vf1 vf1 vf2) + (let ((v1-29 (-> arg1 flags-s32))) + (when (nonzero? (-> (the-as (array int32) s2-0) 6)) + (.lvf vf2 (&-> *time-of-day-context* current-prt-color quad)) + (.mul.vf vf1 vf1 vf2) + (.mov a0-11 vf1) + ) + (let ((v1-30 (logand v1-29 (sp-cpuinfo-flag-s32 sp-cpuinfo-flag-14)))) + (.mov t7-3 vf1) + (let ((v1-31 (sar (the-as int v1-30) 14))) + (set! (-> arg2 r-g-b-a quad) (the-as uint128 (logior (logand t7-3 (the-as uint -2)) v1-31))) + ) + ) + ) + (particle-adgif-callback (-> arg1 adgif) (the-as texture-id a1-2)) + ) + ) + ) + ) + ) + (.mov vf1 s4-0) + (.mov vf2 s3-0) + (.mov v1-33 vf2) + ) + ) + (none) + ) + ) -;; ERROR: Expression building failed: In sparticle-motion-blur: [OP: 78] - Floating point math attempted on invalid types: uint and float in op (-.s f2-0 f3-0). -;; ERROR: Inline assembly instruction marked with TODO - [TODO.VCLIP] -;; ERROR: Unsupported inline assembly instruction kind - [cfc2.i v1, Clipping] -;; ERROR: Inline assembly instruction marked with TODO - [TODO.VCLIP] -;; ERROR: Unsupported inline assembly instruction kind - [cfc2.i v1, Clipping] -;; ERROR: Unsupported inline assembly instruction kind - [mula.s f3, f3] -;; ERROR: Unsupported inline assembly instruction kind - [madd.s f3, f4, f4] -;; ERROR: Unsupported inline assembly instruction kind - [mula.s f0, f3] -;; ERROR: Unsupported inline assembly instruction kind - [madd.s f0, f2, f5] +(defun sparticle-mode-animate ((arg0 sparticle-system) (arg1 sparticle-cpuinfo) (arg2 sprite-vec-data-2d)) + (let ((a0-1 (-> arg1 key)) + (v1-0 (the-as object (-> arg1 user-float))) + ) + (when (nonzero? (the-as float v1-0)) + (let ((a1-2 (the-as (array uint32) (-> (the-as (array symbol) v1-0) 0 value)))) + (when (nonzero? a1-2) + (let* ((a1-4 (the-as object (-> a1-2 (min (the-as int (+ (-> a0-1 state-mode 0) 1)) (+ (-> a1-2 length) -1))))) + (a0-8 (the-as + object + (-> (the-as (array int32) a1-4) + (+ (mod + (the-as int (/ (-> a0-1 state-counter) (/ (the-as int (-> (the-as vector4w a1-4) w)) 8))) + (+ (-> (the-as (pointer int32) a1-4) 0) -1) + ) + 1 + ) + ) + ) + ) + (a1-6 (/ (-> (the-as (array int32) v1-0) 1) 8)) + (a2-14 (-> (the-as (pointer int64) a0-8) (/ a1-6 64))) + (a0-11 (logtest? a2-14 (ash 1 (logand a1-6 63)))) + (s4-0 (if a0-11 + (-> (the-as (pointer int32) v1-0) 6) + (-> (the-as (pointer int32) v1-0) 5) + ) + ) + ) + (if a0-11 + (set! (-> arg2 r-g-b-a x) (rand-vu-float-range 64.0 192.0)) + (set! (-> arg2 r-g-b-a x) (rand-vu-float-range 32.0 48.0)) + ) + (set! (-> arg2 r-g-b-a y) (-> arg2 r-g-b-a x)) + (set! (-> arg2 r-g-b-a z) (-> arg2 r-g-b-a x)) + (if (nonzero? s4-0) + (particle-adgif-callback (-> arg1 adgif) (the-as texture-id s4-0)) + ) + ) + ) + ) + ) + ) + 0 + (none) + ) -;; WARN: Return type mismatch int vs object. +(def-mips2c sparticle-motion-blur (function sparticle-system sparticle-cpuinfo vector none)) + +(defun-debug sparticle-motion-blur-old ((arg0 object) (arg1 sparticle-cpuinfo) (arg2 sprite-vec-data-3d)) + "Unused" + (let ((s2-0 (new 'stack-no-clear 'vector)) + (s5-0 (new 'stack-no-clear 'vector4w)) + (s3-0 (new 'stack-no-clear 'vector4w)) + ) + (set! (-> s2-0 x) (-> arg2 x-y-z-sx x)) + (set! (-> s2-0 y) (-> arg2 x-y-z-sx y)) + (set! (-> s2-0 z) (-> arg2 x-y-z-sx z)) + (set! (-> s2-0 w) 1.0) + (when (and (or (!= (-> arg1 vel-sxvel x) 0.0) (!= (-> arg1 vel-sxvel y) 0.0) (!= (-> arg1 vel-sxvel z) 0.0)) + (transform-point-qword! s5-0 s2-0) + ) + (+! (-> s2-0 x) (* 32.0 (-> arg1 vel-sxvel x))) + (+! (-> s2-0 y) (* 32.0 (-> arg1 vel-sxvel y))) + (+! (-> s2-0 z) (* 32.0 (-> arg1 vel-sxvel z))) + (when (transform-point-qword! s3-0 s2-0) + (let* ((f0-14 (the float (+ (-> s5-0 x) -28672))) + (f1-10 (the float (+ (-> s5-0 y) -29440))) + (f2-4 (the float (+ (-> s3-0 x) -28672))) + (f3-1 (the float (+ (-> s3-0 y) -29440))) + (f30-0 (- f2-4 f0-14)) + (f28-0 (- f3-1 f1-10)) + ) + (set! (-> arg2 qx-qy-qz-sy z) (+ -16384.0 (atan f30-0 f28-0))) + (let ((f0-17 (-> arg1 omega))) + (if (!= f0-17 0.0) + (set! (-> arg2 x-y-z-sx w) (* (sqrtf (+ (* f30-0 f30-0) (* f28-0 f28-0))) + f0-17 + (lerp-scale 3.0 0.25 (/ 1.0 (the float (-> s5-0 z))) 0.000001 0.00000014285715) + ) + ) + ) + ) + ) + (return (the-as object #f)) + ) + ) + ) + (if (!= (-> arg1 omega) 0.0) + (set! (-> arg2 x-y-z-sx w) 0.0) + ) + 0 + ) (defun sparticle-set-conerot ((arg0 sparticle-launcher) (arg1 vector)) (let ((s5-0 (get-field-spec-by-id arg0 (sp-field-id spt-conerot-x))) @@ -1187,6 +1916,21 @@ (none) ) +(defun birth-func-texture-group ((arg0 int) (arg1 sparticle-cpuinfo) (arg2 sparticle-launchinfo)) + (let ((s5-0 (the-as (array int32) (-> arg1 user-float)))) + (when (nonzero? s5-0) + (let* ((a0-1 (+ (-> s5-0 length) -3)) + (a1-1 (-> s5-0 (+ (rand-vu-int-count a0-1) 3))) + ) + (if (nonzero? a1-1) + (particle-adgif-callback (-> arg1 adgif) (the-as texture-id a1-1)) + ) + ) + ) + ) + 0 + (none) + ) ;; WARN: new jak 2 until loop case, check carefully (defmethod get-field-spec-by-id sparticle-launcher ((obj sparticle-launcher) (arg0 sp-field-id)) @@ -1211,4 +1955,37 @@ (the-as sp-field-init-spec #f) ) -;; ERROR: failed type prop at 45: Could not figure out load: (set! v1 (l.w (+ gp 12))) +(defmethod setup-user-array sparticle-launcher ((obj sparticle-launcher) (arg0 string)) + (let ((s5-0 (get-field-spec-by-id obj (sp-field-id spt-texture))) + (v1-1 (lookup-texture-id-by-name arg0 (the-as string #f))) + ) + (if s5-0 + (set! (-> s5-0 initial-valuef) (the-as float v1-1)) + ) + ) + (let ((v1-3 (get-field-spec-by-id obj (sp-field-id spt-userdata)))) + (when (and v1-3 (= (-> v1-3 flags) (sp-flag plain-v2))) + (let ((gp-1 (the-as object (-> v1-3 initial-valuef)))) + (when (and (= (logand (the-as int gp-1) 7) 4) + (type? (the-as float gp-1) array) + (logtest? (-> (the-as (array int32) gp-1) 1) 128) + ) + (set! (-> (the-as (array int32) gp-1) 0) (/ (-> (the-as (array int32) gp-1) 0) 8)) + (set! (-> (the-as (array int32) gp-1) 1) (/ (logand (-> (the-as (array int32) gp-1) 1) 8) 8)) + (set! (-> (the-as (array int32) gp-1) 2) (/ (-> (the-as (array int32) gp-1) 2) 8)) + (set! (-> (the-as (array int32) gp-1) content-type) int32) + (dotimes (s5-1 (+ (-> (the-as (array int32) gp-1) length) -3)) + (set! (-> (the-as (array int32) gp-1) (+ s5-1 3)) + (the-as + int + (lookup-texture-id-by-name (the-as string (-> (the-as (array int32) gp-1) (+ s5-1 3))) (the-as string #f)) + ) + ) + ) + ) + ) + ) + ) + 0 + (none) + ) diff --git a/goal_src/jak2/engine/gfx/sprite/particles/sparticle.gc b/goal_src/jak2/engine/gfx/sprite/particles/sparticle.gc index 7ea652b686..9d0d4d7426 100644 --- a/goal_src/jak2/engine/gfx/sprite/particles/sparticle.gc +++ b/goal_src/jak2/engine/gfx/sprite/particles/sparticle.gc @@ -161,12 +161,113 @@ (none) ) -;; ERROR: Unsupported inline assembly instruction kind - [movz a2, t3, t2] -;; ERROR: Unsupported inline assembly instruction kind - [movz a2, t3, t2] -;; ERROR: Unsupported inline assembly instruction kind - [movz a2, t3, t2] -;; ERROR: Unsupported inline assembly instruction kind - [movz a2, t3, t2] -;; ERROR: Unsupported inline assembly instruction kind - [movz a2, t3, t2] -;; ERROR: Unsupported inline assembly instruction kind - [movz a2, t2, t1] +(defmacro .movn (result value check original) + `(if (!= ,check 0) + (set! ,result (the-as int ,value)) + (set! ,result (the-as int ,original)) + ) + ) + +(defmacro .movz (result value check original) + `(if (= ,check 0) + (set! ,result (the-as int ,value)) + (set! ,result (the-as int ,original)) + ) + ) + +(defun sp-get-particle ((arg0 sparticle-system) (arg1 int) (arg2 sparticle-launch-state)) + (local-vars + (a2-3 int) + (a2-4 int) + (a2-5 int) + (a2-6 int) + (a2-7 int) + (a2-8 int) + (t1-16 int) + (t1-17 int) + (t1-18 int) + (t1-19 int) + (t1-20 int) + (t3-5 int) + ) + (let ((v1-0 0) + (t0-0 (-> arg0 blocks 0)) + (a3-0 0) + ) + (when (= arg1 1) + (set! v1-0 t0-0) + (set! t0-0 (-> arg0 blocks 1)) + ) + (when arg2 + (set! a3-0 (the-as int (-> arg2 randomize))) + (+! (-> arg2 randomize) 1) + (when (= (-> arg2 randomize) t0-0) + (set! (-> arg2 randomize) (the-as uint 0)) + 0 + ) + ) + (dotimes (a2-1 t0-0) + (when (nonzero? (-> arg0 alloc-table (+ v1-0 a3-0))) + (let ((a2-2 0) + (t1-15 (-> arg0 alloc-table (+ v1-0 a3-0))) + (t0-4 (* (+ v1-0 a3-0) 64)) + ) + 0 + 0 + (let ((t2-4 (shl t1-15 32)) + (t3-0 (+ a2-2 32)) + ) + (.movn t1-16 t2-4 t2-4 t1-15) + (.movz a2-3 t3-0 t2-4 a2-2) + ) + (let ((t2-5 (shl t1-16 16)) + (t3-1 (+ a2-3 16)) + ) + (.movn t1-17 t2-5 t2-5 t1-16) + (.movz a2-4 t3-1 t2-5 a2-3) + ) + (let ((t2-6 (* t1-17 256)) + (t3-2 (+ a2-4 8)) + ) + (.movn t1-18 t2-6 t2-6 t1-17) + (.movz a2-5 t3-2 t2-6 a2-4) + ) + (let ((t2-7 (* t1-18 16)) + (t3-3 (+ a2-5 4)) + ) + (.movn t1-19 t2-7 t2-7 t1-18) + (.movz a2-6 t3-3 t2-7 a2-5) + ) + (let ((t2-8 (* t1-19 4)) + (t3-4 (+ a2-6 2)) + ) + (.movn t1-20 t2-8 t2-8 t1-19) + (.movz a2-7 t3-4 t2-8 a2-6) + (let ((t1-21 (* t1-20 2)) + (t2-9 (+ a2-7 1)) + ) + (.movn t3-5 t1-21 t1-21 t3-4) + (.movz a2-8 t2-9 t1-21 a2-7) + ) + ) + (let ((t0-5 (+ t0-4 a2-8))) + (logxor! (-> arg0 alloc-table (+ v1-0 a3-0)) (the-as uint (ash 1 a2-8))) + (+! (-> arg0 num-alloc arg1) 1) + (let ((v1-9 (-> arg0 cpuinfo-table t0-5))) + (set! (-> v1-9 valid) (the-as uint 1)) + (return v1-9) + ) + ) + ) + ) + (+! a3-0 1) + (if (= a3-0 t0-0) + (set! a3-0 0) + ) + ) + ) + (the-as sparticle-cpuinfo #f) + ) (defun sp-kill-particle ((arg0 sparticle-system) (arg1 sparticle-cpuinfo)) (cond @@ -226,13 +327,13 @@ (none) ) -;; ERROR: function was not converted to expressions. Cannot decompile. - -;; ERROR: function was not converted to expressions. Cannot decompile. +(def-mips2c sp-process-block-2d (function sparticle-system int int int int symbol none)) +(def-mips2c sp-process-block-3d (function sparticle-system int int int int symbol none)) (defun sp-copy-to-spr ((arg0 int) (arg1 pointer) (arg2 int)) (let ((a2-1 (/ (+ arg2 15) 16))) - (dma-send-to-spr-no-flush (the-as uint arg0) (the-as uint arg1) (the-as uint a2-1) #t) + ;(dma-send-to-spr-no-flush (the-as uint arg0) (the-as uint arg1) (the-as uint a2-1) #t) + (__mem-move (&+ (scratchpad-start) arg0) arg1 (the uint (* a2-1 16))) ) 0 (none) @@ -240,13 +341,15 @@ (defun sp-copy-from-spr ((arg0 int) (arg1 pointer) (arg2 int)) (let ((a2-1 (/ (+ arg2 15) 16))) - (dma-send-from-spr-no-flush (the-as uint arg1) (the-as uint arg0) (the-as uint a2-1) #t) + ;(dma-send-from-spr-no-flush (the-as uint arg1) (the-as uint arg0) (the-as uint a2-1) #t) + (__mem-move arg1 (&+ (scratchpad-start) arg0) (the uint (* a2-1 16))) ) 0 (none) ) ;; ERROR: function was not converted to expressions. Cannot decompile. +;; unused memcpy function (defun sp-process-block ((arg0 sparticle-system) (arg1 int) (arg2 sprite-array-2d) (arg3 int)) (local-vars (sv-16 int) (sv-32 int) (sv-48 int) (sv-64 int)) @@ -264,8 +367,8 @@ ) (t9-2 sv-16 (the-as pointer a1-7) sv-32) ) - (set! sv-48 (+ #x70000000 s3-0)) - (set! sv-64 (+ #x70000000 s1-0)) + (set! sv-48 (+ (the int (scratchpad-start)) s3-0)) + (set! sv-64 (+ (the int (scratchpad-start)) s1-0)) (let ((t1-0 (paused?))) (cond ((-> arg0 is-3d) @@ -292,7 +395,7 @@ (defun sp-process-particle-system ((arg0 sparticle-system) (arg1 int) (arg2 sprite-array-2d)) (countdown (v1-0 13) (let ((a0-4 (-> *display* clock v1-0 sparticle-data quad))) - (set! (-> (the-as vector (+ #x70000000 (* v1-0 16))) quad) a0-4) + (set! (-> (the-as vector (+ (the int (scratchpad-start)) (* v1-0 16))) quad) a0-4) ) ) (let* ((v1-3 208) diff --git a/goal_src/jak2/engine/gfx/sprite/sprite.gc b/goal_src/jak2/engine/gfx/sprite/sprite.gc index eb843965f5..63746c113b 100644 --- a/goal_src/jak2/engine/gfx/sprite/sprite.gc +++ b/goal_src/jak2/engine/gfx/sprite/sprite.gc @@ -6,6 +6,8 @@ ;; dgos: ENGINE, GAME ;; the sprite renderer draw 2D or 3D sprites +;; TODO: glow is commented out. +;; TODO: distort is commented out. (defenum sprite-aux-type :bitfield #f @@ -126,21 +128,6 @@ :flag-assert #x900000010 ) -(defmethod inspect sprite-aux-elem ((obj sprite-aux-elem)) - (when (not obj) - (set! obj obj) - (goto cfg-4) - ) - (format #t "[~8x] ~A~%" obj 'sprite-aux-elem) - (format #t "~1Taux-type: ~D~%" (-> obj aux-type)) - (format #t "~1Tdata[3] @ #x~X~%" (-> obj data)) - (format #t "~1Tvec-data: #~%" (-> obj vec-data)) - (format #t "~1Tgif-data: #~%" (-> obj gif-data)) - (format #t "~1Taux-data: #~%" (-> obj aux-data)) - (label cfg-4) - obj - ) - (deftype sprite-aux-list (basic) ((num-entries int32 :offset-assert 4) ;; capacity (entry int32 :offset-assert 8) ;; current size @@ -254,50 +241,6 @@ :flag-assert #x9000002a0 ) -(defmethod inspect sprite-frame-data ((obj sprite-frame-data)) - (when (not obj) - (set! obj obj) - (goto cfg-4) - ) - (format #t "[~8x] ~A~%" obj 'sprite-frame-data) - (format #t "~1Tdata[42] @ #x~X~%" (-> obj cdata)) - (format #t "~1Tcdata[16] @ #x~X~%" (-> obj cdata)) - (format #t "~1Tfdata[26] @ #x~X~%" (-> obj hmge-scale)) - (format #t "~1Txy-array[8] @ #x~X~%" (-> obj cdata)) - (format #t "~1Tst-array[4] @ #x~X~%" (-> obj st-array)) - (format #t "~1Txyz-array[4] @ #x~X~%" (-> obj xyz-array)) - (format #t "~1Thmge-scale: #~%" (-> obj hmge-scale)) - (format #t "~1Tconsts: #~%" (&-> obj pfog0)) - (format #t "~1Tpfog0: ~f~%" (-> obj pfog0)) - (format #t "~1Tdeg-to-rad: ~f~%" (-> obj deg-to-rad)) - (format #t "~1Tmin-scale: ~f~%" (-> obj min-scale)) - (format #t "~1Tinv-area: ~f~%" (-> obj inv-area)) - (format #t "~1Tadgif-giftag: #~%" (-> obj adgif-giftag)) - (format #t "~1Tsprite-2d-giftag: #~%" (-> obj sprite-2d-giftag)) - (format #t "~1Tsprite-2d-giftag-2: #~%" (-> obj sprite-2d-giftag-2)) - (format #t "~1Tsincos-01: #~%" (-> obj sincos-01)) - (format #t "~1Tsincos-23: #~%" (-> obj sincos-23)) - (format #t "~1Tsincos-45: #~%" (-> obj sincos-45)) - (format #t "~1Tsincos-67: #~%" (-> obj sincos-67)) - (format #t "~1Tsincos-89: #~%" (-> obj sincos-89)) - (format #t "~1Tbasis-x: #~%" (-> obj basis-x)) - (format #t "~1Tbasis-y: #~%" (-> obj basis-y)) - (format #t "~1Tsprite-3d-giftag: #~%" (-> obj sprite-3d-giftag)) - (format #t "~1Tsprite-3d-giftag-2: #~%" (-> obj sprite-3d-giftag-2)) - (format #t "~1Tscreen-shader: #~%" (-> obj screen-shader)) - (format #t "~1Tinv-hmge-scale: #~%" (-> obj inv-hmge-scale)) - (format #t "~1Tstq-offset: #~%" (-> obj stq-offset)) - (format #t "~1Tstq-scale: #~%" (-> obj stq-scale)) - (format #t "~1Trgba-plain: #~%" (-> obj rgba-plain)) - (format #t "~1Twarp-giftag: #~%" (-> obj warp-giftag)) - (format #t "~1Tfog-clamp: #~%" (-> obj fog-clamp)) - (format #t "~1Tfog-min: ~f~%" (-> obj fog-clamp x)) - (format #t "~1Tfog-max: ~f~%" (-> obj fog-clamp y)) - (format #t "~1Tmax-scale: ~f~%" (-> obj max-scale)) - (label cfg-4) - obj - ) - (defun sprite-setup-frame-data ((data sprite-frame-data) (tbp-offset uint)) "Build the sprite-frame-data. This should be done once per frame" (set! (-> data hmge-scale quad) (-> *math-camera* hmge-scale quad)) @@ -476,7 +419,7 @@ (none) ) -(define sprite-vu1-block (new 'static 'vu-function :length #x35f :qlength #x1b0)) +(define sprite-vu1-block (new 'static 'vu-function :length 0 :qlength 0)) ;;;;;;;;;;;;;;;;;; ;; sprite-arrays @@ -872,10 +815,10 @@ ) ;; run the distorters - (when (or (zero? *screen-shot-work*) (= (-> *screen-shot-work* count) -1)) - (sprite-init-distorter dma-buff) - (sprite-draw-distorters dma-buff) - ) + ; (when (or (zero? *screen-shot-work*) (= (-> *screen-shot-work* count) -1)) + ; (sprite-init-distorter dma-buff) + ; (sprite-draw-distorters dma-buff) + ; ) ;; first packet - set up the GS registers (let* ((v1-17 dma-buff) @@ -987,9 +930,9 @@ ;;;;;;;;;;;;;;;; ;; TODO: figure out what this is doing - (sprite-glow-init-engine dma-buff) - (sprite-glow-draw dma-buff) - (simple-sprite-system-method-10 *simple-sprite-system* dma-buff) + ; (sprite-glow-init-engine dma-buff) + ; (sprite-glow-draw dma-buff) + ; (simple-sprite-system-method-10 *simple-sprite-system* dma-buff) (let* ((v1-26 dma-buff) (pkt6 (the-as dma-packet (-> v1-26 base))) ) @@ -1007,7 +950,7 @@ ) (dma-bucket-insert-tag (-> *display* frames (-> *display* on-screen) bucket-group) - (bucket-id bucket-313) + (bucket-id particles) dma-bucket-begin (the-as (pointer dma-tag) a3-0) ) diff --git a/goal_src/jak2/engine/gfx/texture/texture-anim.gc b/goal_src/jak2/engine/gfx/texture/texture-anim.gc index da3faaf24b..a43785f561 100644 --- a/goal_src/jak2/engine/gfx/texture/texture-anim.gc +++ b/goal_src/jak2/engine/gfx/texture/texture-anim.gc @@ -6,4 +6,8 @@ ;; dgos: ENGINE, GAME ;; DECOMP BEGINS +(defun update-texture-anim ((id bucket-id)) + ;; hack! + (none) + ) diff --git a/goal_src/jak2/engine/gfx/texture/texture-h.gc b/goal_src/jak2/engine/gfx/texture/texture-h.gc index 10d6932105..1b84a20913 100644 --- a/goal_src/jak2/engine/gfx/texture/texture-h.gc +++ b/goal_src/jak2/engine/gfx/texture/texture-h.gc @@ -289,6 +289,7 @@ :bitfield #t (needs-log-in 8) (bit-9 9) + (backup-sprite-tex 10) ;; set when particle-setup-adgif fails texture lookup. ) ;; GS texturing/blending settings, called adgif-shader. diff --git a/goal_src/jak2/engine/gfx/texture/texture.gc b/goal_src/jak2/engine/gfx/texture/texture.gc index 2d9a7fd199..2988b7c2df 100644 --- a/goal_src/jak2/engine/gfx/texture/texture.gc +++ b/goal_src/jak2/engine/gfx/texture/texture.gc @@ -1111,6 +1111,13 @@ (set! (-> (the-as (pointer gs-reg64) a0-28) 1) (gs-reg64 texflush)) (set! (-> v1-53 base) (&+ a0-28 16)) ) + + (#when PC_PORT + (dma-buffer-add-cnt-vif2 dma-buf 1 (new 'static 'vif-tag :cmd (vif-cmd pc-port)) (the-as vif-tag 3)) + (dma-buffer-add-uint64 dma-buf tpage) + (dma-buffer-add-uint64 dma-buf mode) + ) + (let ((a3-3 (-> dma-buf base))) (let ((v1-54 (the-as dma-packet (-> dma-buf base)))) (set! (-> v1-54 dma) (new 'static 'dma-tag :id (dma-tag-id next))) @@ -1628,10 +1635,10 @@ ) (((tpage-category sprite)) ;; sprite skips uploads if the level isn't drawing, but otherwise uploads the whole thing. - (if (or (= (-> lev display?) 'display) (= (-> lev display?) 'actor) (= (-> lev index) 6)) - (set! (-> lev upload-size 7) - (upload-vram-pages pool (-> pool segment-common) tpage (tex-upload-mode seg0-1-2) bucket) - ) + (when (or (= (-> lev display?) 'display) (= (-> lev display?) 'actor) (= (-> lev index) 6)) + (set! (-> lev upload-size 7) + (upload-vram-pages pool (-> pool segment-common) tpage (tex-upload-mode seg0-1-2) bucket) + ) ) ) (((tpage-category map)) diff --git a/goal_src/jak2/engine/gfx/vu1-user-h.gc b/goal_src/jak2/engine/gfx/vu1-user-h.gc index d049ac2b32..b409bffe4b 100644 --- a/goal_src/jak2/engine/gfx/vu1-user-h.gc +++ b/goal_src/jak2/engine/gfx/vu1-user-h.gc @@ -392,7 +392,7 @@ (bucket-311 311) ;; depth-cue (tex-all-sprite 312) - (bucket-313 313) ;; particles + (particles 313) ;; particles (bucket-314 314) ;; shadow (bucket-315 315) ;; effects (tex-all-warp 316) ;; tex diff --git a/test/decompiler/reference/jak2/engine/debug/part-tester_REF.gc b/test/decompiler/reference/jak2/engine/debug/part-tester_REF.gc new file mode 100644 index 0000000000..596a51cc79 --- /dev/null +++ b/test/decompiler/reference/jak2/engine/debug/part-tester_REF.gc @@ -0,0 +1,136 @@ +;;-*-Lisp-*- +(in-package goal) + +;; this file is debug only +(declare-file (debug)) +(when *debug-segment* +;; failed to figure out what this is: +(defpartgroup group-part-tester + :id 127 + :flags (unk-4 unk-6) + :bounds (static-bspherem 0 0 0 640) + :rotate ((degrees 2) (degrees 0) (degrees 0)) + :parts ((sp-item 209)) + ) + +;; definition of type part-tester +(deftype part-tester (process) + ((root trsqv :offset-assert 128) + (part sparticle-launch-control :offset-assert 132) + (old-group sparticle-launch-group :offset-assert 136) + ) + :heap-base #x10 + :method-count-assert 14 + :size-assert #x8c + :flag-assert #xe0010008c + ) + +;; definition for method 3 of type part-tester +(defmethod inspect part-tester ((obj part-tester)) + (when (not obj) + (set! obj obj) + (goto cfg-4) + ) + (let ((t9-0 (method-of-type process inspect))) + (t9-0 obj) + ) + (format #t "~2Troot: ~A~%" (-> obj root)) + (format #t "~2Tpart: ~A~%" (-> obj part)) + (format #t "~2Told-group: ~A~%" (-> obj old-group)) + (label cfg-4) + obj + ) + +;; definition for symbol *part-tester-name*, type string +(define *part-tester-name* (the-as string #f)) + +;; definition for method 10 of type part-tester +(defmethod deactivate part-tester ((obj part-tester)) + (if (nonzero? (-> obj part)) + (kill-and-free-particles (-> obj part)) + ) + ((method-of-type process deactivate) obj) + (none) + ) + +;; failed to figure out what this is: +(defstate part-tester-idle (part-tester) + :code (behavior () + (until #f + (let ((gp-0 (entity-by-name *part-tester-name*))) + (when gp-0 + (let ((s5-0 (-> gp-0 extra process))) + (if (and s5-0 (type? s5-0 process-drawable) (nonzero? (-> (the-as process-drawable s5-0) root))) + (set! (-> self root trans quad) (-> (the-as process-drawable s5-0) root trans quad)) + (set! (-> self root trans quad) (-> gp-0 extra trans quad)) + ) + ) + ) + ) + (add-debug-x + #t + (bucket-id debug-no-zbuf1) + (-> self root trans) + (new 'static 'rgba :r #xff :g #xff :b #xff :a #x80) + ) + (let ((gp-1 (-> *part-group-id-table* 127))) + (let ((s5-1 (-> self root trans))) + (when (!= gp-1 (-> self old-group)) + (when (nonzero? (-> self part)) + (kill-and-free-particles (-> self part)) + (set! (-> self heap-cur) (&-> (-> self part) type)) + ) + (set! (-> self part) (create-launch-control gp-1 self)) + ) + (if (nonzero? (-> self part)) + (spawn (-> self part) (cond + ((logtest? (-> gp-1 flags) (sp-group-flag screen-space)) + *zero-vector* + ) + (else + (empty) + s5-1 + ) + ) + ) + ) + ) + (set! (-> self old-group) gp-1) + ) + (suspend) + ) + #f + (none) + ) + ) + +;; definition for function part-tester-init-by-other +;; INFO: Used lq/sq +;; WARN: Return type mismatch object vs none. +(defbehavior part-tester-init-by-other process-drawable ((arg0 vector)) + (set! (-> self root) (new 'process 'trsqv)) + (set! (-> self root trans quad) (-> arg0 quad)) + (set! *part-tester* (process->ppointer self)) + (go part-tester-idle) + (none) + ) + +;; definition (perm) for symbol *debug-part-dead-pool*, type dead-pool +(define-perm *debug-part-dead-pool* dead-pool (new 'debug 'dead-pool 1 #x10000 "*debug-part-dead-pool*")) + +;; definition for function start-part +;; WARN: Return type mismatch (pointer process) vs none. +(defun start-part () + (kill-by-type part-tester *active-pool*) + (process-spawn + part-tester + (if *anim-tester* + (-> *anim-tester* 0 root trans) + (target-pos 0) + ) + :from *debug-part-dead-pool* + ) + (none) + ) + +) diff --git a/test/decompiler/reference/jak2/engine/gfx/mood/time-of-day_REF.gc b/test/decompiler/reference/jak2/engine/gfx/mood/time-of-day_REF.gc index 1ed80206d4..00fd577c7f 100644 --- a/test/decompiler/reference/jak2/engine/gfx/mood/time-of-day_REF.gc +++ b/test/decompiler/reference/jak2/engine/gfx/mood/time-of-day_REF.gc @@ -43,10 +43,10 @@ ) ) (when (and (-> *setting-control* user-current weather) gp-0) - (let ((s5-0 (new 'stack-no-clear 'vector))) - (let ((s4-0 (new 'stack-no-clear 'vector)) - (v1-8 (-> *math-camera* inv-camera-rot vector 2)) - ) + (let ((s5-0 (new 'stack-no-clear 'vector)) + (s4-0 (new 'stack-no-clear 'vector)) + ) + (let ((v1-8 (-> *math-camera* inv-camera-rot vector 2))) (set! (-> s5-0 quad) (-> *math-camera* trans quad)) (vector-! s4-0 s5-0 (-> *math-camera* prev-trans)) (let ((f0-1 (vector-dot s4-0 v1-8))) @@ -54,13 +54,13 @@ ) ) (set! (-> s5-0 y) (-> *math-camera* trans y)) + (if (< 0.0 (-> *setting-control* user-current rain)) + (update-rain (-> *setting-control* user-current rain) s5-0 s4-0) + ) + (if (< 0.0 (-> *setting-control* user-current snow)) + (update-snow (-> *setting-control* user-current snow) s5-0 s4-0) + ) ) - (if (< 0.0 (-> *setting-control* user-current rain)) - (update-rain (the-as target (-> *setting-control* user-current rain))) - ) - (if (< 0.0 (-> *setting-control* user-current snow)) - (update-snow (the-as target (-> *setting-control* user-current snow))) - ) ) (cond ((and (>= (-> self time-of-day) 6.25) @@ -691,7 +691,3 @@ ;; failed to figure out what this is: (start-time-of-day) - - - - diff --git a/test/decompiler/reference/jak2/engine/gfx/mood/weather-part_REF.gc b/test/decompiler/reference/jak2/engine/gfx/mood/weather-part_REF.gc new file mode 100644 index 0000000000..7c78f44376 --- /dev/null +++ b/test/decompiler/reference/jak2/engine/gfx/mood/weather-part_REF.gc @@ -0,0 +1,963 @@ +;;-*-Lisp-*- +(in-package goal) + +;; failed to figure out what this is: +(defpartgroup group-rain-screend-drop-real + :id 1 + :flags (screen-space) + :bounds (static-bspherem 0 0 0 16) + :parts ((sp-item 45 :binding 41) + (sp-item 41 :flags (start-dead launch-asap) :binding 42) + (sp-item 41 :flags (start-dead launch-asap) :binding 42) + (sp-item 41 :flags (start-dead launch-asap) :binding 42) + (sp-item 41 :flags (start-dead launch-asap) :binding 42) + (sp-item 41 :flags (start-dead launch-asap) :binding 42) + (sp-item 41 :flags (start-dead launch-asap) :binding 42) + (sp-item 41 :flags (start-dead launch-asap) :binding 42) + (sp-item 41 :flags (start-dead launch-asap) :binding 42) + (sp-item 41 :flags (start-dead launch-asap) :binding 42) + (sp-item 41 :flags (start-dead launch-asap) :binding 42) + (sp-item 41 :flags (start-dead launch-asap) :binding 42) + (sp-item 41 :flags (start-dead launch-asap) :binding 42) + (sp-item 41 :flags (start-dead launch-asap) :binding 42) + (sp-item 41 :flags (start-dead launch-asap) :binding 42) + (sp-item 41 :flags (start-dead launch-asap) :binding 42) + (sp-item 41 :flags (start-dead launch-asap) :binding 42) + (sp-item 42 :flags (start-dead launch-asap)) + (sp-item 42 :flags (start-dead launch-asap)) + (sp-item 42 :flags (start-dead launch-asap)) + (sp-item 42 :flags (start-dead launch-asap)) + (sp-item 42 :flags (start-dead launch-asap)) + (sp-item 42 :flags (start-dead launch-asap)) + (sp-item 42 :flags (start-dead launch-asap)) + (sp-item 42 :flags (start-dead launch-asap)) + (sp-item 42 :flags (start-dead launch-asap)) + (sp-item 42 :flags (start-dead launch-asap)) + (sp-item 42 :flags (start-dead launch-asap)) + (sp-item 42 :flags (start-dead launch-asap)) + (sp-item 42 :flags (start-dead launch-asap)) + (sp-item 42 :flags (start-dead launch-asap)) + (sp-item 42 :flags (start-dead launch-asap)) + (sp-item 42 :flags (start-dead launch-asap)) + (sp-item 46 :binding 43) + (sp-item 43 :flags (start-dead launch-asap) :binding 44) + (sp-item 43 :flags (start-dead launch-asap) :binding 44) + (sp-item 43 :flags (start-dead launch-asap) :binding 44) + (sp-item 43 :flags (start-dead launch-asap) :binding 44) + (sp-item 43 :flags (start-dead launch-asap) :binding 44) + (sp-item 43 :flags (start-dead launch-asap) :binding 44) + (sp-item 43 :flags (start-dead launch-asap) :binding 44) + (sp-item 43 :flags (start-dead launch-asap) :binding 44) + (sp-item 43 :flags (start-dead launch-asap) :binding 44) + (sp-item 43 :flags (start-dead launch-asap) :binding 44) + (sp-item 43 :flags (start-dead launch-asap) :binding 44) + (sp-item 43 :flags (start-dead launch-asap) :binding 44) + (sp-item 43 :flags (start-dead launch-asap) :binding 44) + (sp-item 43 :flags (start-dead launch-asap) :binding 44) + (sp-item 43 :flags (start-dead launch-asap) :binding 44) + (sp-item 43 :flags (start-dead launch-asap) :binding 44) + (sp-item 44 :flags (start-dead launch-asap)) + (sp-item 44 :flags (start-dead launch-asap)) + (sp-item 44 :flags (start-dead launch-asap)) + (sp-item 44 :flags (start-dead launch-asap)) + (sp-item 44 :flags (start-dead launch-asap)) + (sp-item 44 :flags (start-dead launch-asap)) + (sp-item 44 :flags (start-dead launch-asap)) + (sp-item 44 :flags (start-dead launch-asap)) + (sp-item 44 :flags (start-dead launch-asap)) + (sp-item 44 :flags (start-dead launch-asap)) + (sp-item 44 :flags (start-dead launch-asap)) + (sp-item 44 :flags (start-dead launch-asap)) + (sp-item 44 :flags (start-dead launch-asap)) + (sp-item 44 :flags (start-dead launch-asap)) + (sp-item 44 :flags (start-dead launch-asap)) + (sp-item 44 :flags (start-dead launch-asap)) + ) + ) + +;; definition for symbol group-rain-screend-drop, type sparticle-launch-group +(define group-rain-screend-drop (-> *part-group-id-table* 1)) + +;; failed to figure out what this is: +(defpart 46 + :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #x29 :page #xc)) + (sp-flt spt-num 0.1) + (sp-rnd-flt spt-x (meters -4.5) (meters 9) 1.0) + (sp-rnd-flt spt-y (meters -3) (meters 6) 1.0) + (sp-flt spt-scale-x (meters 2.5)) + (sp-rnd-flt spt-rot-z (degrees 0.0) (degrees 360.0) 1.0) + (sp-copy-from-other spt-scale-y -4) + (sp-flt spt-r 128.0) + (sp-flt spt-g 128.0) + (sp-flt spt-b 128.0) + (sp-flt spt-a 12.0) + (sp-flt spt-scalevel-x (meters 0.16666667)) + (sp-copy-from-other spt-scalevel-y -4) + (sp-flt spt-fade-a -0.8) + (sp-int spt-timer 10) + (sp-cpuinfo-flags sp-cpuinfo-flag-2 sp-cpuinfo-flag-3 sp-cpuinfo-flag-14) + ) + ) + +;; failed to figure out what this is: +(defpart 43 + :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #x21 :page #xc)) + (sp-flt spt-num 1.0) + (sp-flt spt-scale-x (meters 1.5)) + (sp-copy-from-other spt-scale-y -4) + (sp-flt spt-r 128.0) + (sp-flt spt-g 128.0) + (sp-flt spt-b 255.0) + (sp-flt spt-a 20.0) + (sp-flt spt-scalevel-x (meters 0.033333335)) + (sp-copy-from-other spt-scalevel-y -4) + (sp-flt spt-fade-a -0.8) + (sp-flt spt-accel-y -2.7306666) + (sp-int spt-timer 270) + (sp-cpuinfo-flags sp-cpuinfo-flag-2 sp-cpuinfo-flag-3 sp-cpuinfo-flag-14) + (sp-int spt-next-time 15) + (sp-launcher-by-id spt-next-launcher 47) + ) + ) + +;; failed to figure out what this is: +(defpart 47 + :init-specs ((sp-flt spt-scalevel-x (meters 0.004166667)) + (sp-copy-from-other spt-scalevel-y -4) + (sp-flt spt-fade-a -0.06666667) + ) + ) + +;; failed to figure out what this is: +(defpart 44 + :init-specs ((sp-flt spt-num 1.0) + (sp-int spt-rot-x 12) + (sp-flt spt-r 4096.0) + (sp-flt spt-g 3276.8) + (sp-flt spt-b 3276.8) + (sp-flt spt-fade-r 6.068148) + (sp-flt spt-fade-g 68.26667) + (sp-flt spt-fade-b 3.034074) + (sp-flt spt-accel-y -2.7306666) + (sp-int spt-timer 270) + (sp-cpuinfo-flags distort) + (sp-int spt-next-time 30) + (sp-launcher-by-id spt-next-launcher 48) + ) + ) + +;; failed to figure out what this is: +(defpart 48 + :init-specs ((sp-flt spt-fade-g -5.1200004)) + ) + +;; failed to figure out what this is: +(defpart 45 + :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #x29 :page #xc)) + (sp-flt spt-num 0.1) + (sp-rnd-flt spt-x (meters -4.5) (meters 9) 1.0) + (sp-rnd-flt spt-y (meters -3) (meters 6) 1.0) + (sp-flt spt-scale-x (meters 4)) + (sp-rnd-flt spt-rot-z (degrees 0.0) (degrees 360.0) 1.0) + (sp-copy-from-other spt-scale-y -4) + (sp-flt spt-r 128.0) + (sp-flt spt-g 128.0) + (sp-flt spt-b 128.0) + (sp-flt spt-a 12.0) + (sp-flt spt-scalevel-x (meters 0.26666668)) + (sp-copy-from-other spt-scalevel-y -4) + (sp-flt spt-fade-a -0.8) + (sp-int spt-timer 10) + (sp-cpuinfo-flags sp-cpuinfo-flag-2 sp-cpuinfo-flag-3 sp-cpuinfo-flag-14) + ) + ) + +;; failed to figure out what this is: +(defpart 41 + :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #x21 :page #xc)) + (sp-flt spt-num 1.0) + (sp-flt spt-scale-x (meters 2.6)) + (sp-copy-from-other spt-scale-y -4) + (sp-flt spt-r 128.0) + (sp-flt spt-g 128.0) + (sp-flt spt-b 255.0) + (sp-flt spt-a 20.0) + (sp-flt spt-scalevel-x (meters 0.06666667)) + (sp-copy-from-other spt-scalevel-y -4) + (sp-flt spt-fade-a -0.8) + (sp-flt spt-accel-y -2.7306666) + (sp-int spt-timer 270) + (sp-cpuinfo-flags sp-cpuinfo-flag-2 sp-cpuinfo-flag-3 sp-cpuinfo-flag-14) + (sp-int spt-next-time 15) + (sp-launcher-by-id spt-next-launcher 49) + ) + ) + +;; failed to figure out what this is: +(defpart 49 + :init-specs ((sp-flt spt-scalevel-x (meters 0.008333334)) + (sp-copy-from-other spt-scalevel-y -4) + (sp-flt spt-fade-a -0.06666667) + ) + ) + +;; failed to figure out what this is: +(defpart 42 + :init-specs ((sp-flt spt-num 1.0) + (sp-int spt-rot-x 24) + (sp-flt spt-r 12288.0) + (sp-flt spt-g 6553.6) + (sp-flt spt-b 6553.6) + (sp-flt spt-fade-r 12.136296) + (sp-flt spt-fade-g 136.53334) + (sp-flt spt-fade-b 6.068148) + (sp-flt spt-accel-y -2.7306666) + (sp-int spt-timer 270) + (sp-cpuinfo-flags distort) + (sp-int spt-next-time 30) + (sp-launcher-by-id spt-next-launcher 50) + ) + ) + +;; failed to figure out what this is: +(defpart 50 + :init-specs ((sp-flt spt-fade-g -10.240001)) + ) + +;; failed to figure out what this is: +(defpartgroup group-stars + :id 2 + :flags (always-draw) + :bounds (static-bspherem 0 0 0 8) + :parts ((sp-item 51 :flags (bit6)) (sp-item 52 :flags (bit6)) (sp-item 53 :flags (bit6))) + ) + +;; failed to figure out what this is: +(defpart 51 + :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #xc9 :page #xc)) + (sp-flt spt-num 1.0) + (sp-rnd-flt spt-scale-x (meters 30) (meters 20) 1.0) + (sp-copy-from-other spt-scale-y -4) + (sp-flt spt-r 256.0) + (sp-flt spt-g 256.0) + (sp-flt spt-b 256.0) + (sp-flt spt-a 0.0) + (sp-flt spt-fade-a 0.42666668) + (sp-int spt-timer -1) + (sp-cpuinfo-flags sp-cpuinfo-flag-2 sp-cpuinfo-flag-3 sp-cpuinfo-flag-14) + (sp-int-plain-rnd spt-next-time 60 239 1) + (sp-launcher-by-id spt-next-launcher 54) + (sp-rnd-flt spt-conerot-x (degrees -89.0) (degrees 178.0) 1.0) + (sp-rnd-flt spt-conerot-y (degrees 0.0) (degrees 1440.0) 1.0) + (sp-rnd-flt spt-rotate-y (degrees 0.0) (degrees 3600.0) 1.0) + (sp-flt spt-conerot-radius (meters 5000)) + ) + ) + +;; failed to figure out what this is: +(defpart 54 + :init-specs ((sp-flt spt-fade-a 0.0) (sp-int spt-next-time 29999700) (sp-launcher-by-id spt-next-launcher 55)) + ) + +;; failed to figure out what this is: +(defpart 55 + :init-specs ((sp-flt spt-fade-a -0.42666668)) + ) + +;; failed to figure out what this is: +(defpart 52 + :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #xc9 :page #xc)) + (sp-flt spt-num 1.0) + (sp-rnd-flt spt-scale-x (meters 30) (meters 20) 1.0) + (sp-copy-from-other spt-scale-y -4) + (sp-flt spt-r 256.0) + (sp-flt spt-g 256.0) + (sp-flt spt-b 256.0) + (sp-flt spt-a 0.0) + (sp-flt spt-fade-a 0.42666668) + (sp-int spt-timer -1) + (sp-cpuinfo-flags sp-cpuinfo-flag-2 sp-cpuinfo-flag-3 sp-cpuinfo-flag-14) + (sp-int-plain-rnd spt-next-time 60 239 1) + (sp-launcher-by-id spt-next-launcher 54) + (sp-rnd-flt spt-conerot-x (degrees 30.0) (degrees 59.0) 1.0) + (sp-rnd-flt spt-conerot-y (degrees 0.0) (degrees 2880.0) 1.0) + (sp-rnd-flt spt-rotate-y (degrees 0.0) (degrees 3600.0) 1.0) + (sp-flt spt-conerot-radius (meters 5000)) + ) + ) + +;; failed to figure out what this is: +(defpart 53 + :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #xc9 :page #xc)) + (sp-flt spt-num 1.0) + (sp-rnd-flt spt-scale-x (meters 30) (meters 20) 1.0) + (sp-copy-from-other spt-scale-y -4) + (sp-flt spt-r 128.0) + (sp-flt spt-g 128.0) + (sp-flt spt-b 128.0) + (sp-flt spt-a 0.0) + (sp-flt spt-fade-a 0.42666668) + (sp-int spt-timer -1) + (sp-cpuinfo-flags sp-cpuinfo-flag-2 sp-cpuinfo-flag-3 sp-cpuinfo-flag-14) + (sp-int-plain-rnd spt-next-time 60 239 1) + (sp-launcher-by-id spt-next-launcher 54) + (sp-rnd-flt spt-conerot-x (degrees 60.0) (degrees 29.0) 1.0) + (sp-rnd-flt spt-conerot-y (degrees 0.0) (degrees 5760.0) 1.0) + (sp-rnd-flt spt-rotate-y (degrees 0.0) (degrees 3600.0) 1.0) + (sp-flt spt-conerot-radius (meters 5000)) + ) + ) + +;; failed to figure out what this is: +(defpart 56 + :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #xc9 :page #xc)) + (sp-flt spt-num 4.0) + (sp-rnd-flt spt-x (meters 10) (meters 10) 1.0) + (sp-rnd-flt spt-y (meters 2) (meters 14) 1.0) + (sp-rnd-flt spt-scale-x (meters 0.2) (meters 0.1) 1.0) + (sp-int spt-rot-x 4) + (sp-rnd-flt spt-rot-z (degrees 0.0) (degrees 360.0) 1.0) + (sp-copy-from-other spt-scale-y -4) + (sp-flt spt-r 255.0) + (sp-flt spt-g 255.0) + (sp-flt spt-b 255.0) + (sp-flt spt-a 0.0) + (sp-rnd-flt spt-vel-y (meters -0.01) (meters -0.0033333334) 1.0) + (sp-rnd-flt spt-rotvel-z (degrees -1.2) (degrees 2.4) 1.0) + (sp-flt spt-fade-a 0.85333335) + (sp-int spt-timer 1500) + (sp-cpuinfo-flags sp-cpuinfo-flag-2 sp-cpuinfo-flag-12 sp-cpuinfo-flag-14) + (sp-int-plain-rnd spt-next-time 75 74 1) + (sp-launcher-by-id spt-next-launcher 57) + (sp-rnd-flt spt-rotate-y (degrees 0.0) (degrees 180.0) 1.0) + ) + ) + +;; failed to figure out what this is: +(defpart 58 + :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #xc9 :page #xc)) + (sp-flt spt-num 0.0) + (sp-rnd-flt spt-x (meters 0) (meters 20) 1.0) + (sp-flt spt-y (meters 16)) + (sp-rnd-flt spt-scale-x (meters 0.2) (meters 0.1) 1.0) + (sp-int spt-rot-x 4) + (sp-rnd-flt spt-rot-z (degrees 0.0) (degrees 360.0) 1.0) + (sp-copy-from-other spt-scale-y -4) + (sp-flt spt-r 255.0) + (sp-flt spt-g 255.0) + (sp-flt spt-b 255.0) + (sp-flt spt-a 0.0) + (sp-rnd-flt spt-vel-y (meters -0.01) (meters -0.0033333334) 1.0) + (sp-rnd-flt spt-rotvel-z (degrees -1.2) (degrees 2.4) 1.0) + (sp-flt spt-fade-a 0.85333335) + (sp-int spt-timer 1500) + (sp-cpuinfo-flags sp-cpuinfo-flag-2 sp-cpuinfo-flag-12 sp-cpuinfo-flag-14) + (sp-int-plain-rnd spt-next-time 75 74 1) + (sp-launcher-by-id spt-next-launcher 57) + (sp-rnd-flt spt-rotate-y (degrees 0.0) (degrees 360.0) 1.0) + ) + ) + +;; failed to figure out what this is: +(defpart 57 + :init-specs ((sp-flt spt-fade-a 0.0) (sp-int spt-next-time 1200) (sp-launcher-by-id spt-next-launcher 59)) + ) + +;; failed to figure out what this is: +(defpart 59 + :init-specs ((sp-flt spt-fade-a -0.85333335)) + ) + +;; definition for function update-snow +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs none. +(defun update-snow ((arg0 float) (arg1 vector) (arg2 vector)) + (let ((f0-0 (lerp-scale 0.0 1.0 (vector-length arg2) 2048.0 40960.0))) + (set! (-> *part-id-table* 58 init-specs 1 initial-valuef) (- 1.0 f0-0)) + (set! (-> *part-id-table* 56 init-specs 1 initial-valuef) (* 4.0 f0-0)) + ) + (set! (-> *part-id-table* 56 init-specs 19 initial-valuef) (+ 32768.0 (vector-y-angle arg2))) + (let ((t9-2 sp-launch-particles-var) + (a0-3 *sp-particle-system-2d*) + (a1-2 (-> *part-id-table* 58)) + (a2-2 *launch-matrix*) + ) + (set! (-> a2-2 trans quad) (-> arg1 quad)) + (t9-2 a0-3 a1-2 a2-2 (the-as sparticle-launch-state #f) (the-as sparticle-launch-control #f) 1.0) + ) + (let ((t9-3 sp-launch-particles-var) + (a0-4 *sp-particle-system-2d*) + (a1-3 (-> *part-id-table* 56)) + (a2-3 *launch-matrix*) + ) + (set! (-> a2-3 trans quad) (-> arg1 quad)) + (t9-3 a0-4 a1-3 a2-3 (the-as sparticle-launch-state #f) (the-as sparticle-launch-control #f) 1.0) + ) + 0 + (none) + ) + +;; failed to figure out what this is: +(defpart 60 + :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #x21 :page #xc)) + (sp-func spt-birth-func 'birth-func-rain) + (sp-flt spt-num 1.0) + (sp-rnd-flt spt-x (meters -20) (meters 40) 1.0) + (sp-flt spt-y (meters 30)) + (sp-rnd-flt spt-scale-x (meters 0.03) (meters 0.03) 1.0) + (sp-rnd-flt spt-scale-y (meters 0.5) (meters 0.5) 1.0) + (sp-rnd-flt spt-r 32.0 32.0 1.0) + (sp-copy-from-other spt-g -1) + (sp-rnd-flt spt-b 64.0 32.0 1.0) + (sp-rnd-flt spt-a 32.0 64.0 1.0) + (sp-rnd-flt spt-vel-y (meters -0.1) (meters -0.2) 1.0) + (sp-int spt-timer 900) + (sp-cpuinfo-flags sp-cpuinfo-flag-2 sp-cpuinfo-flag-3 sp-cpuinfo-flag-14) + (sp-flt spt-userdata 0.0) + (sp-func spt-func 'check-drop-level-rain) + (sp-rnd-flt spt-rotate-y (degrees 0.0) (degrees 3600.0) 1.0) + ) + ) + +;; failed to figure out what this is: +(defpart 61 + :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #x21 :page #xc)) + (sp-func spt-birth-func 'birth-func-rain) + (sp-flt spt-num 4.0) + (sp-rnd-flt spt-x (meters -20) (meters 40) 1.0) + (sp-flt spt-y (meters 30)) + (sp-rnd-flt spt-scale-x (meters 0.03) (meters 0.03) 1.0) + (sp-rnd-flt spt-scale-y (meters 0.5) (meters 0.5) 1.0) + (sp-rnd-flt spt-r 32.0 32.0 1.0) + (sp-copy-from-other spt-g -1) + (sp-rnd-flt spt-b 64.0 32.0 1.0) + (sp-rnd-flt spt-a 32.0 64.0 1.0) + (sp-rnd-flt spt-vel-y (meters -0.06666667) (meters -0.033333335) 1.0) + (sp-int spt-timer 900) + (sp-cpuinfo-flags sp-cpuinfo-flag-2 sp-cpuinfo-flag-3 sp-cpuinfo-flag-14) + (sp-flt spt-userdata 0.0) + (sp-func spt-func 'check-drop-level-rain2) + (sp-rnd-flt spt-rotate-y (degrees 0.0) (degrees 3600.0) 1.0) + ) + ) + +;; failed to figure out what this is: +(defpart 62 + :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #x21 :page #xc)) + (sp-rnd-flt spt-num 1.0 3.0 1.0) + (sp-rnd-flt spt-scale-x (meters 0.08) (meters 0.03) 1.0) + (sp-int spt-rot-x 4) + (sp-copy-from-other spt-scale-y -4) + (sp-rnd-flt spt-r 32.0 32.0 1.0) + (sp-copy-from-other spt-g -1) + (sp-rnd-flt spt-b 64.0 32.0 1.0) + (sp-rnd-flt spt-a 64.0 64.0 1.0) + (sp-rnd-flt spt-omega 2.8672 1.6384 1.0) + (sp-rnd-flt spt-vel-y (meters 0.033333335) (meters 0.06666667) 1.0) + (sp-rnd-flt spt-fade-a -0.21333334 -0.21333334 1.0) + (sp-rnd-flt spt-accel-y -20.48 -2.7306666 1.0) + (sp-flt spt-friction 0.98) + (sp-int spt-timer 300) + (sp-cpuinfo-flags sp-cpuinfo-flag-2 sp-cpuinfo-flag-3 sp-cpuinfo-flag-14 use-global-acc) + (sp-flt spt-userdata 0.0) + (sp-func spt-func 'check-drop-level-splash) + (sp-int-plain-rnd spt-next-time 0 99 1) + (sp-launcher-by-id spt-next-launcher 63) + (sp-rnd-flt spt-conerot-x (degrees 0.0) (degrees 50.000004) 1.0) + (sp-rnd-flt spt-conerot-y (degrees 0.0) (degrees 3600.0) 1.0) + (sp-flt spt-rotate-x (degrees 0.0)) + (sp-flt spt-rotate-y (degrees 0.0)) + ) + ) + +;; failed to figure out what this is: +(defpart 64 + :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #xc9 :page #xc)) + (sp-func spt-birth-func 'birth-func-omega-normal-orient) + (sp-flt spt-num 1.0) + (sp-flt spt-y (meters 0.2)) + (sp-rnd-flt spt-scale-x (meters 0.5) (meters 0.25) 1.0) + (sp-copy-from-other spt-scale-y -4) + (sp-rnd-flt spt-r 32.0 32.0 1.0) + (sp-copy-from-other spt-g -1) + (sp-rnd-flt spt-b 64.0 32.0 1.0) + (sp-rnd-flt spt-a 64.0 32.0 1.0) + (sp-flt spt-omega 0.0) + (sp-rnd-flt spt-scalevel-x (meters 0.006666667) (meters 0.006666667) 1.0) + (sp-copy-from-other spt-scalevel-y -4) + (sp-flt spt-fade-a -1.2) + (sp-int spt-timer 300) + (sp-cpuinfo-flags sp-cpuinfo-flag-2 sp-cpuinfo-flag-3 sp-cpuinfo-flag-14) + (new 'static 'sp-field-init-spec + :field (sp-field-id spt-userdata) + :flags (sp-flag plain-v2) + :object (new 'static 'boxed-array :type int32 10 0 0 #xc0c900 #xc02600 #xc03300 #xc02c00) + ) + (sp-func spt-func 'sparticle-texture-animate) + ) + ) + +;; failed to figure out what this is: +(defpart 65 + :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #x92 :page #xc)) + (sp-rnd-flt spt-num 2.0 4.0 1.0) + (sp-flt spt-scale-x (meters 2.5)) + (sp-int spt-rot-x 4) + (sp-rnd-flt spt-scale-y (meters 0.06) (meters 0.03) 1.0) + (sp-flt spt-r 255.0) + (sp-rnd-flt spt-g 128.0 128.0 1.0) + (sp-rnd-flt spt-b 0.0 128.0 1.0) + (sp-flt spt-a 128.0) + (sp-rnd-flt spt-omega 3.2768 2.048 1.0) + (sp-rnd-flt spt-vel-y (meters 0.1) (meters 0.06666667) 1.0) + (sp-rnd-flt spt-fade-g -2.55 -2.55 1.0) + (sp-flt spt-fade-b -8.0) + (sp-rnd-flt spt-fade-a -0.32 -0.64 1.0) + (sp-rnd-flt spt-friction 0.8 0.02 1.0) + (sp-int-plain-rnd spt-timer 100 99 1) + (sp-cpuinfo-flags sp-cpuinfo-flag-2 sp-cpuinfo-flag-3) + (sp-func spt-func 'sparticle-motion-blur) + (sp-rnd-flt spt-conerot-x (degrees 0.0) (degrees 80.0) 1.0) + (sp-rnd-flt spt-conerot-y (degrees 0.0) (degrees 3600.0) 1.0) + ) + ) + +;; failed to figure out what this is: +(defpart 66 + :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #xbb :page #xc)) + (sp-flt spt-num 1.0) + (sp-flt spt-scale-x (meters 0.25)) + (sp-flt spt-rot-x 40.96) + (sp-rnd-flt spt-rot-z (degrees 0.0) (degrees 3600.0) 1.0) + (sp-copy-from-other spt-scale-y -4) + (sp-flt spt-r 255.0) + (sp-rnd-flt spt-g 196.0 128.0 1.0) + (sp-rnd-flt spt-b 128.0 64.0 1.0) + (sp-rnd-flt spt-a 96.0 16.0 1.0) + (sp-flt spt-omega 656998.4) + (sp-flt spt-scalevel-x (meters 0.08)) + (sp-copy-from-other spt-scalevel-y -4) + (sp-flt spt-fade-g -6.375) + (sp-flt spt-fade-b -13.066667) + (sp-flt spt-fade-a -2.8) + (sp-int-plain-rnd spt-timer 15 9 1) + (sp-cpuinfo-flags sp-cpuinfo-flag-2 sp-cpuinfo-flag-3 glow) + (sp-flt spt-userdata 2048.0) + ) + ) + +;; definition for function birth-func-omega-normal-orient +;; WARN: Return type mismatch int vs none. +(defun birth-func-omega-normal-orient ((arg0 sparticle-system) + (arg1 sparticle-cpuinfo) + (arg2 sprite-vec-data-3d) + (arg3 sparticle-launcher) + (arg4 sparticle-launch-state) + ) + (local-vars (v1-6 float) (v1-7 float)) + (rlet ((vf0 :class vf) + (vf1 :class vf) + (vf2 :class vf) + ) + (init-vf0-vector) + (let ((s4-0 (new 'stack-no-clear 'vector)) + (gp-0 (new 'stack-no-clear 'quaternion)) + ) + (set! (-> s4-0 x) (* 0.007874016 (the float (-> arg1 datab 2)))) + (set! (-> s4-0 y) 0.0) + (set! (-> s4-0 z) (* -0.007874016 (the float (-> arg1 datab 0)))) + (vector-normalize! s4-0 1.0) + (quaternion-vector-angle! gp-0 s4-0 (acos (* 0.007874016 (the float (-> arg1 datab 1))))) + (cond + ((< (-> gp-0 w) 0.0) + (.lvf vf1 (&-> arg2 qx-qy-qz-sy quad)) + (.lvf vf2 (&-> gp-0 vec quad)) + (.sub.vf vf1 vf0 vf2 :mask #b111) + (.svf (&-> arg2 qx-qy-qz-sy quad) vf1) + (.mov v1-6 vf1) + ) + (else + (.lvf vf1 (&-> arg2 qx-qy-qz-sy quad)) + (.lvf vf2 (&-> gp-0 vec quad)) + (.add.vf vf1 vf0 vf2 :mask #b111) + (.svf (&-> arg2 qx-qy-qz-sy quad) vf1) + (.mov v1-7 vf1) + ) + ) + ) + 0 + (none) + ) + ) + +;; definition for function birth-func-rain +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs none. +(defun birth-func-rain ((arg0 sparticle-system) + (arg1 sparticle-cpuinfo) + (arg2 sprite-vec-data-3d) + (arg3 sparticle-launcher) + (arg4 sparticle-launch-state) + ) + (let ((s4-0 (new 'stack-no-clear 'collide-query))) + (set! (-> s4-0 start-pos quad) (-> arg2 x-y-z-sx quad)) + (set-vector! (-> s4-0 move-dist) 0.0 -163840.0 0.0 1.0) + (let ((v1-2 s4-0)) + (set! (-> v1-2 radius) 40.96) + (set! (-> v1-2 collide-with) (collide-spec backgnd)) + (set! (-> v1-2 ignore-process0) #f) + (set! (-> v1-2 ignore-process1) #f) + (set! (-> v1-2 ignore-pat) (new 'static 'pat-surface :noentity #x1 :nojak #x1 :probe #x1 :noendlessfall #x1)) + (set! (-> v1-2 action-mask) (collide-action solid)) + ) + (fill-using-line-sphere *collide-cache* s4-0) + (cond + ((>= (collide-cache-method-16 *collide-cache* s4-0) 0.0) + (set! (-> arg1 user-float) (-> s4-0 best-other-tri intersect y)) + (let ((f0-8 (+ 65536.0 (-> *math-camera* trans y)))) + (if (< (-> arg1 user-float) f0-8) + (set! (-> arg2 x-y-z-sx y) f0-8) + ) + ) + (set! (-> arg1 datab 0) (the int (* 127.0 (-> s4-0 best-other-tri normal x)))) + (set! (-> arg1 datab 1) (the int (* 127.0 (-> s4-0 best-other-tri normal y)))) + (set! (-> arg1 datab 2) (the int (* 127.0 (-> s4-0 best-other-tri normal z)))) + (set! (-> arg1 datab 3) (the-as int (-> s4-0 best-other-tri pat event))) + ) + (else + (set! (-> arg1 omega) 65280.0) + (set! (-> arg1 user-float) (+ -204800.0 (-> arg2 x-y-z-sx y))) + ) + ) + ) + (let ((f0-21 (ocean-method-11 *ocean* (the-as (inline-array vector) (-> arg2 x-y-z-sx)) #f))) + (when (!= f0-21 4095996000.0) + (when (< (-> arg1 user-float) f0-21) + (set! (-> arg1 user-float) f0-21) + (set! (-> arg1 datab 0) 0) + (set! (-> arg1 datab 1) 127) + (set! (-> arg1 datab 2) 0) + (set! (-> arg1 datab 3) 0) + 0 + ) + ) + ) + 0 + (none) + ) + +;; definition for function check-drop-level-rain +;; INFO: Used lq/sq +(defun check-drop-level-rain ((arg0 sparticle-system) (arg1 sparticle-cpuinfo) (arg2 vector)) + (when (< (-> arg2 y) (-> arg1 user-float)) + (let ((s4-0 (new 'stack-no-clear 'vector)) + (gp-0 (new 'stack-no-clear 'matrix)) + ) + (let ((f30-0 (-> arg1 user-float))) + (sp-kill-particle arg0 arg1) + (set-vector! s4-0 (-> arg2 x) (-> arg1 user-float) (-> arg2 z) 1.0) + (-> arg1 omega) + (set-vector! + (-> gp-0 vector 1) + (* 0.007874016 (the float (-> arg1 datab 0))) + (* 0.007874016 (the float (-> arg1 datab 1))) + (* 0.007874016 (the float (-> arg1 datab 2))) + 0.0 + ) + (set-vector! (-> gp-0 vector 2) 0.0 0.0 1.0 0.0) + (vector-cross! (the-as vector (-> gp-0 vector)) (-> gp-0 vector 1) (-> gp-0 vector 2)) + (set! (-> gp-0 trans quad) (-> s4-0 quad)) + (set! (-> *part-id-table* 62 init-specs 23 initial-valuef) (vector-y-angle (-> gp-0 vector 1))) + (set! (-> *part-id-table* 62 init-specs 22 initial-valuef) (- 16384.0 (vector-x-angle (-> gp-0 vector 1)))) + (set! (-> *part-id-table* 62 init-specs 16 initial-valuef) f30-0) + ) + (sp-launch-particles-var + *sp-particle-system-2d* + (-> *part-id-table* 62) + gp-0 + (the-as sparticle-launch-state #f) + (the-as sparticle-launch-control #f) + 1.0 + ) + (case (-> arg1 datab 3) + ((11 10) + (sound-play "sizzle-drips") + (sp-launch-particles-var + *sp-particle-system-2d* + (-> *part-id-table* 66) + gp-0 + (the-as sparticle-launch-state #f) + (the-as sparticle-launch-control #f) + 1.0 + ) + (sp-launch-particles-var + *sp-particle-system-2d* + (-> *part-id-table* 65) + gp-0 + (the-as sparticle-launch-state #f) + (the-as sparticle-launch-control #f) + 1.0 + ) + ) + (else + (sound-play "dry-drips") + (set! (-> *part-id-table* 64 init-specs 10 initial-valuef) (-> arg1 omega)) + (sp-launch-particles-var + *sp-particle-system-3d* + (-> *part-id-table* 64) + gp-0 + (the-as sparticle-launch-state #f) + (the-as sparticle-launch-control #f) + 1.0 + ) + ) + ) + ) + ) + (none) + ) + +;; definition for function check-drop-level-rain2 +;; WARN: Return type mismatch symbol vs none. +(defun check-drop-level-rain2 ((arg0 sparticle-system) (arg1 sparticle-cpuinfo) (arg2 vector)) + (if (< (-> arg2 y) (-> arg1 user-float)) + (sp-kill-particle arg0 arg1) + ) + (none) + ) + +;; definition for function check-drop-level-splash +;; WARN: Return type mismatch symbol vs none. +(defun check-drop-level-splash ((arg0 sparticle-system) (arg1 sparticle-cpuinfo) (arg2 vector)) + (sparticle-motion-blur arg0 arg1 arg2) + (if (< (-> arg2 y) (-> arg1 user-float)) + (sp-kill-particle arg0 arg1) + ) + (none) + ) + +;; definition for function update-rain +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs none. +(defun update-rain ((arg0 float) (arg1 vector) (arg2 vector)) + (let ((v1-0 (new 'stack-no-clear 'vector))) + (set! (-> v1-0 x) (-> arg2 x)) + (set! (-> v1-0 y) 0.0) + (set! (-> v1-0 z) (-> arg2 z)) + (set! (-> v1-0 w) 1.0) + (let ((gp-1 (vector+float*! (new 'stack-no-clear 'vector) arg1 v1-0 0.0))) + (let ((t9-0 matrix-local->world) + (a0-3 #f) + ) + (let* ((s4-0 (t9-0 a0-3)) + (f28-0 (lerp-scale 122.88 245.76 (fabs (-> s4-0 vector 2 y)) 0.0 0.7)) + (f30-0 (lerp-scale 2048.0 245.76 (fabs (-> s4-0 vector 2 y)) 0.0 0.7)) + ) + (let ((f26-0 (lerp-scale 0.0 0.1 (-> s4-0 vector 2 y) 0.3 0.7)) + (f0-11 (lerp-scale 1.0 0.1 (-> s4-0 vector 2 y) 0.3 0.7)) + ) + (if (< 0.0 f26-0) + (send-event *camera* 'part-water-drip f26-0 f0-11) + ) + ) + (set! (-> *part-id-table* 60 init-specs 5 initial-valuef) f28-0) + (set! (-> *part-id-table* 60 init-specs 5 random-rangef) f28-0) + (set! (-> *part-id-table* 61 init-specs 5 initial-valuef) f28-0) + (set! (-> *part-id-table* 61 init-specs 5 random-rangef) f28-0) + (set! (-> *part-id-table* 60 init-specs 6 initial-valuef) f30-0) + (set! (-> *part-id-table* 60 init-specs 6 random-rangef) f30-0) + (set! (-> *part-id-table* 61 init-specs 6 initial-valuef) f30-0) + (set! (-> *part-id-table* 61 init-specs 6 random-rangef) f30-0) + ) + ) + (set! (-> *part-id-table* 60 init-specs 2 initial-valuef) arg0) + (set! (-> *part-id-table* 61 init-specs 2 initial-valuef) (* 4.0 arg0)) + (let ((t9-6 sp-launch-particles-var) + (a0-10 *sp-particle-system-2d*) + (a1-7 (-> *part-id-table* 60)) + (a2-5 *launch-matrix*) + ) + (set! (-> a2-5 trans quad) (-> gp-1 quad)) + (t9-6 a0-10 a1-7 a2-5 (the-as sparticle-launch-state #f) (the-as sparticle-launch-control #f) 1.0) + ) + (let ((t9-7 sp-launch-particles-var) + (a0-11 *sp-particle-system-2d*) + (a1-8 (-> *part-id-table* 61)) + (a2-6 *launch-matrix*) + ) + (set! (-> a2-6 trans quad) (-> gp-1 quad)) + (t9-7 a0-11 a1-8 a2-6 (the-as sparticle-launch-state #f) (the-as sparticle-launch-control #f) 1.0) + ) + ) + ) + 0 + (none) + ) + +;; definition for function cam-master-effect +;; WARN: Return type mismatch int vs none. +(defbehavior cam-master-effect camera-master () + (when (not (or (movie?) (>= (+ (-> self clock frame-counter) (seconds -10)) (-> self water-drip-time)))) + (set! (-> *part-id-table* 46 init-specs 1 initial-valuef) (-> self water-drip-mult)) + (set! (-> *part-id-table* 45 init-specs 1 initial-valuef) (* 0.9 (-> self water-drip-mult))) + (set! (-> *part-id-table* 43 init-specs 11 initial-valuef) (* -2.7306666 (-> self water-drip-speed))) + (set! (-> *part-id-table* 44 init-specs 8 initial-valuef) (* -2.7306666 (-> self water-drip-speed))) + (set! (-> *part-id-table* 41 init-specs 11 initial-valuef) (* -2.7306666 (-> self water-drip-speed))) + (set! (-> *part-id-table* 42 init-specs 8 initial-valuef) (* -2.7306666 (-> self water-drip-speed))) + (spawn (-> self water-drip) *zero-vector*) + ) + 0 + (none) + ) + +;; definition for function sparticle-track-sun +;; WARN: Return type mismatch int vs none. +(defun sparticle-track-sun ((arg0 int) (arg1 sparticle-cpuinfo) (arg2 matrix)) + (-> arg1 key) + (let* ((s3-0 (the int (-> arg1 user-float))) + (s5-0 (math-camera-pos)) + (s4-0 (+ (the-as uint (-> *sky-work* upload-data)) (* (/ s3-0 4) 64))) + ) + (let ((v1-3 (/ s3-0 4))) + (cond + ((zero? v1-3) + (set! (-> arg2 vector 1 z) (+ 8192.0 (* 0.5 (vector-y-angle (-> (math-camera-matrix) vector 2))))) + ) + ((= v1-3 1) + (set! (-> arg2 vector 1 z) (+ -8192.0 (* 0.5 (vector-y-angle (-> (math-camera-matrix) vector 2))))) + ) + ) + ) + (let ((v1-12 (vector+float*! (new 'stack-no-clear 'vector) s5-0 (the-as vector s4-0) 4096.0))) + (set! (-> arg2 vector 0 x) (-> v1-12 x)) + (set! (-> arg2 vector 0 y) (-> v1-12 y)) + (set! (-> arg2 vector 0 z) (-> v1-12 z)) + ) + ) + 0 + (none) + ) + +;; failed to figure out what this is: +(defpartgroup group-sun + :id 3 + :flags (always-draw) + :bounds (static-bspherem 0 0 0 70) + :parts ((sp-item 67 :flags (bit6)) (sp-item 68 :flags (bit6))) + ) + +;; failed to figure out what this is: +(defpart 67 + :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #xbb :page #xc)) + (sp-flt spt-num 1.0) + (sp-flt spt-scale-x (meters 2550)) + (sp-flt spt-rot-x 307200.0) + (sp-flt spt-rot-z (degrees 30.0)) + (sp-flt spt-scale-y (meters 2550)) + (sp-flt spt-r 64.0) + (sp-flt spt-g 64.0) + (sp-flt spt-b 16.0) + (sp-flt spt-a 70.0) + (sp-flt spt-omega 0.0) + (sp-int spt-timer -1) + (sp-cpuinfo-flags sp-cpuinfo-flag-2 sp-cpuinfo-flag-3 sp-cpuinfo-flag-14 glow) + (sp-flt spt-userdata 1.0) + (sp-func spt-func 'sparticle-track-sun) + ) + ) + +;; failed to figure out what this is: +(defpart 68 + :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #xbb :page #xc)) + (sp-flt spt-num 1.0) + (sp-flt spt-scale-x (meters 12000)) + (sp-flt spt-rot-x 307200.0) + (sp-flt spt-rot-z (degrees 30.0)) + (sp-flt spt-scale-y (meters 12000)) + (sp-flt spt-r 64.0) + (sp-flt spt-g 32.0) + (sp-flt spt-b 0.0) + (sp-flt spt-a 80.0) + (sp-flt spt-omega 0.0) + (sp-int spt-timer -1) + (sp-cpuinfo-flags sp-cpuinfo-flag-2 sp-cpuinfo-flag-3 sp-cpuinfo-flag-14 glow) + (sp-flt spt-userdata 1.0) + (sp-func spt-func 'sparticle-track-sun) + ) + ) + +;; failed to figure out what this is: +(defpartgroup group-green-sun + :id 4 + :flags (always-draw) + :bounds (static-bspherem 0 0 0 70) + :parts ((sp-item 69 :flags (bit6)) (sp-item 70 :flags (bit6))) + ) + +;; failed to figure out what this is: +(defpart 69 + :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #xbb :page #xc)) + (sp-flt spt-num 1.0) + (sp-flt spt-scale-x (meters 1500)) + (sp-flt spt-rot-x 204800.0) + (sp-flt spt-rot-z (degrees 30.0)) + (sp-flt spt-scale-y (meters 1500)) + (sp-flt spt-r 16.0) + (sp-flt spt-g 64.0) + (sp-flt spt-b 32.0) + (sp-flt spt-a 64.0) + (sp-flt spt-omega 0.0) + (sp-int spt-timer -1) + (sp-cpuinfo-flags sp-cpuinfo-flag-2 sp-cpuinfo-flag-3 sp-cpuinfo-flag-14 glow) + (sp-flt spt-userdata 4.0) + (sp-func spt-func 'sparticle-track-sun) + ) + ) + +;; failed to figure out what this is: +(defpart 70 + :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #xbb :page #xc)) + (sp-flt spt-num 1.0) + (sp-flt spt-scale-x (meters 3000)) + (sp-flt spt-rot-x 204800.0) + (sp-flt spt-rot-z (degrees 30.0)) + (sp-flt spt-scale-y (meters 3000)) + (sp-flt spt-r 0.0) + (sp-flt spt-g 43.0) + (sp-flt spt-b 8.0) + (sp-flt spt-a 64.0) + (sp-flt spt-omega 0.0) + (sp-int spt-timer -1) + (sp-cpuinfo-flags sp-cpuinfo-flag-2 sp-cpuinfo-flag-3 sp-cpuinfo-flag-14 glow) + (sp-flt spt-userdata 4.0) + (sp-func spt-func 'sparticle-track-sun) + ) + ) + +;; failed to figure out what this is: +(defpartgroup group-moon + :id 5 + :flags (always-draw) + :bounds (static-bspherem 0 0 0 70) + :parts ((sp-item 71 :flags (bit6))) + ) + +;; failed to figure out what this is: +(defpart 71 + :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #xca :page #xc)) + (sp-flt spt-num 1.0) + (sp-flt spt-scale-x (meters 6000)) + (sp-flt spt-rot-x 544768.0) + (sp-flt spt-rot-z (degrees 30.0)) + (sp-flt spt-scale-y (meters 6000)) + (sp-flt spt-r 16.0) + (sp-flt spt-g 32.0) + (sp-flt spt-b 64.0) + (sp-flt spt-a 64.0) + (sp-flt spt-omega 0.0) + (sp-int spt-timer -1) + (sp-cpuinfo-flags sp-cpuinfo-flag-2 sp-cpuinfo-flag-3 sp-cpuinfo-flag-14 glow) + (sp-flt spt-userdata 8.0) + (sp-func spt-func 'sparticle-track-sun) + ) + ) diff --git a/test/decompiler/reference/jak2/engine/gfx/sprite/particles/sparticle-h_REF.gc b/test/decompiler/reference/jak2/engine/gfx/sprite/particles/sparticle-h_REF.gc index dd48d317a2..969c3e118c 100644 --- a/test/decompiler/reference/jak2/engine/gfx/sprite/particles/sparticle-h_REF.gc +++ b/test/decompiler/reference/jak2/engine/gfx/sprite/particles/sparticle-h_REF.gc @@ -22,6 +22,7 @@ (friction float :offset-assert 96) (timer int32 :offset-assert 100) (flags sp-cpuinfo-flag :offset-assert 104) + (flags-s32 sp-cpuinfo-flag-s32 :offset 104) (user-int32 int32 :offset-assert 108) (user-uint32 uint32 :offset 108) (user-float float :offset 108) @@ -39,7 +40,7 @@ (key-alt sparticle-launch-state :offset 132) (binding sparticle-launch-state :offset-assert 136) (data uint32 1 :offset 12) - (datab uint8 4 :offset 12) + (datab int8 4 :offset 12) (dataf float 1 :offset 12) (datac uint8 1 :offset 12) ) diff --git a/test/decompiler/reference/jak2/engine/gfx/sprite/particles/sparticle-launcher-h_REF.gc b/test/decompiler/reference/jak2/engine/gfx/sprite/particles/sparticle-launcher-h_REF.gc index 39987b36b3..7d29221fad 100644 --- a/test/decompiler/reference/jak2/engine/gfx/sprite/particles/sparticle-launcher-h_REF.gc +++ b/test/decompiler/reference/jak2/engine/gfx/sprite/particles/sparticle-launcher-h_REF.gc @@ -96,7 +96,7 @@ :flag-assert #xb00000010 (:methods (get-field-spec-by-id (_type_ sp-field-id) sp-field-init-spec 9) - (sparticle-launcher-method-10 (_type_ string) none 10) + (setup-user-array (_type_ string) none 10) ) ) @@ -272,10 +272,10 @@ :flag-assert #x1000000070 (:methods (initialize (_type_ sparticle-launch-group process) none 9) - (sparticle-launch-control-method-10 (_type_ vector) symbol 10) + (is-visible? (_type_ vector) symbol 10) (spawn (_type_ vector) none 11) - (sparticle-launch-control-method-12 (_type_ matrix) none 12) - (sparticle-launch-control-method-13 (_type_ cspace) none 13) + (spawn-with-matrix (_type_ matrix) none 12) + (spawn-with-cspace (_type_ cspace) none 13) (kill-and-free-particles (_type_) none 14) (kill-particles (_type_) none 15) ) diff --git a/test/decompiler/reference/jak2/engine/gfx/sprite/particles/sparticle-launcher_REF.gc b/test/decompiler/reference/jak2/engine/gfx/sprite/particles/sparticle-launcher_REF.gc index edd52bf81e..44724a183a 100644 --- a/test/decompiler/reference/jak2/engine/gfx/sprite/particles/sparticle-launcher_REF.gc +++ b/test/decompiler/reference/jak2/engine/gfx/sprite/particles/sparticle-launcher_REF.gc @@ -397,7 +397,32 @@ (kmemclose) ;; definition for function particle-setup-adgif -;; ERROR: function has no type analysis. Cannot decompile. +;; WARN: Return type mismatch int vs none. +(defun particle-setup-adgif ((arg0 adgif-shader) (arg1 int)) + (let ((a1-1 (lookup-texture-by-id-fast (the-as texture-id arg1))) + (s5-0 #f) + ) + (when (not a1-1) + (set! a1-1 (lookup-texture-by-id-fast (new 'static 'texture-id :index #x9b :page #xb))) + (set! s5-0 #t) + ) + (set! (-> arg0 tex1) (new 'static 'gs-tex1 :mmag #x1 :mmin #x1)) + (set! (-> arg0 tex0 tfx) 0) + (adgif-shader<-texture! arg0 a1-1) + (set! (-> arg0 prims 1) (gs-reg64 tex0-1)) + (set! (-> arg0 prims 3) (the-as gs-reg64 (logior arg1 20))) + (set! (-> arg0 prims 5) (gs-reg64 miptbp1-1)) + (set! (-> arg0 clamp-reg) (gs-reg64 zbuf-1)) + (set! (-> arg0 prims 9) (gs-reg64 alpha-1)) + (if s5-0 + (logior! (-> arg0 link-test) (link-test-flags backup-sprite-tex)) + ) + ) + (set! (-> arg0 alpha) (new 'static 'gs-alpha :b #x1 :d #x1)) + (set! (-> arg0 clamp) (new 'static 'gs-clamp :minu #x13 :minv #x101)) + 0 + (none) + ) ;; definition of type particle-adgif-cache (deftype particle-adgif-cache (basic) @@ -454,7 +479,44 @@ ;; ERROR: function was not converted to expressions. Cannot decompile. ;; definition for function particle-adgif-callback -;; ERROR: function was not converted to expressions. Cannot decompile. +;; WARN: Return type mismatch int vs none. +;; ERROR: Bad vector register dependency: vf16 +;; ERROR: Bad vector register dependency: vf17 +;; ERROR: Bad vector register dependency: vf18 +;; ERROR: Bad vector register dependency: vf19 +;; ERROR: Bad vector register dependency: vf20 +(defun particle-adgif-callback ((arg0 adgif-shader) (arg1 texture-id)) + (local-vars (v1-0 float)) + (rlet ((vf16 :class vf) + (vf17 :class vf) + (vf18 :class vf) + (vf19 :class vf) + (vf20 :class vf) + ) + (let ((s5-0 (new 'stack-no-clear 'inline-array 'vector 4))) + (let ((s4-0 (-> arg0 alpha)) + (s3-0 (-> arg0 clamp)) + ) + (.svf (&-> s5-0 0 quad) vf16) + (.svf (&-> s5-0 1 quad) vf17) + (.svf (&-> s5-0 2 quad) vf18) + (.svf (&-> s5-0 3 quad) vf19) + (.svf (&-> s5-0 4 quad) vf20) + (particle-adgif arg0 arg1) + (set! (-> arg0 alpha) s4-0) + (set! (-> arg0 clamp) s3-0) + ) + (.lvf vf16 (&-> s5-0 0 quad)) + (.lvf vf17 (&-> s5-0 1 quad)) + (.lvf vf18 (&-> s5-0 2 quad)) + (.lvf vf19 (&-> s5-0 3 quad)) + (.lvf vf20 (&-> s5-0 4 quad)) + ) + (.mov v1-0 vf20) + 0 + (none) + ) + ) ;; definition for function sp-queue-launch ;; INFO: Used lq/sq @@ -909,223 +971,81 @@ ) ;; definition for function sp-relaunch-particle-3d -;; ERROR: failed type prop at 32: Could not figure out load: (set! a1 (l.w (+ gp 104))) -(defun sp-relaunch-particle-3d ((a0-0 object) (a1-0 sparticle-launcher) (a2-0 sparticle-cpuinfo) (a3-0 sprite-vec-data-3d)) - (local-vars - (v0-0 none) - (v0-1 none) - (v0-2 none) - (v0-3 none) - (v0-4 none) - (v1-0 quaternion) - (v1-1 none) - (v1-2 none) - (v1-3 none) - (v1-4 none) - (v1-5 none) - (v1-6 none) - (v1-9 none) - (v1-10 none) - (v1-11 none) - (v1-12 none) - (v1-13 none) - (v1-14 none) - (v1-16 none) - (v1-17 none) - (v1-18 none) - (a0-1 none) - (a0-2 none) - (a0-4 none) - (a0-6 none) - (a1-1 none) - (a1-2 none) - (a1-3 none) - (a1-4 none) - (a1-6 none) - (a2-1 sprite-vec-data-3d) - (a2-2 int) - (a2-4 sparticle-cpuinfo) - (a2-5 none) - (a3-1 sprite-vec-data-3d) - (s3-0 none) - (s4-0 quaternion) - (t9-0 (function object sparticle-launcher sparticle-cpuinfo sprite-vec-data-3d none)) - (t9-1 none) - (t9-2 none) - (t9-3 none) - (sp-0 none) - (f0-0 float) - (f0-1 float) - (f0-2 float) - (f0-3 float) - (f0-4 float) - (f0-5 float) - (f0-6 float) - (f0-7 none) - (f0-8 none) - (f0-9 none) - (f0-10 none) - (f0-11 none) - (f0-12 none) - (f0-13 none) - (f0-14 none) - (f0-15 none) - (f0-16 none) - (f0-17 none) - (f0-18 none) - (f0-19 none) - (f0-20 none) - (f0-21 none) - (f0-22 none) - (f0-23 none) - (f1-0 float) - (f1-1 float) - (f1-2 float) - (f1-3 none) - (f1-4 none) - (f1-5 none) - (f1-6 none) - (f1-7 none) - (f1-8 none) - (f1-9 none) - (f2-0 float) - (f2-1 float) - (f2-2 float) - (f3-0 float) - ) +;; WARN: Return type mismatch int vs none. +(defun sp-relaunch-particle-3d ((arg0 object) (arg1 sparticle-launcher) (arg2 sparticle-cpuinfo) (arg3 sprite-vec-data-3d)) + (local-vars (v1-9 float) (v1-10 float)) (rlet ((vf0 :class vf) (vf1 :class vf) (vf2 :class vf) ) (init-vf0-vector) - (when (begin - (set! s4-0 (new 'stack-no-clear 'quaternion)) - (set! v1-0 s4-0) - (set! a2-1 a3-0) - (set! f0-0 (-> a2-1 qx-qy-qz-sy x)) - (set! f1-0 (-> a2-1 qx-qy-qz-sy y)) - (set! f2-0 (-> a2-1 qx-qy-qz-sy z)) - (set! (-> v1-0 x) f0-0) - (set! (-> v1-0 y) f1-0) - (set! (-> v1-0 z) f2-0) - (set! a2-2 #x3f800000) - (set! f3-0 (the-as float (gpr->fpr a2-2))) - (set! f2-1 (*.s f2-0 f2-0)) - (set! f2-2 (-.s f3-0 f2-1)) - (set! f1-1 (*.s f1-0 f1-0)) - (set! f1-2 (-.s f2-2 f1-1)) - (set! f0-1 (*.s f0-0 f0-0)) - (set! f0-2 (-.s f1-2 f0-1)) - (set! f0-3 (sqrt.s f0-2)) - (set! (-> v1-0 w) f0-3) - (set! a2-3 (fpr->gpr f0-3)) - (set! f0-4 (the-as float 0)) - (set! (-> a3-0 qx-qy-qz-sy x) f0-4) - (set! f0-5 (the-as float 0)) - (set! (-> a3-0 qx-qy-qz-sy y) f0-5) - (set! f0-6 (the-as float 0)) - (set! (-> a3-0 qx-qy-qz-sy z) f0-6) - (set! t9-0 sp-relaunch-setup-fields) - (set! a2-4 a2-0) - (set! a3-1 a3-0) - (call! a0-0 a1-0 a2-4 a3-1) - (set! a1-1 (the-as none (l.w (+ a2-0 104)))) - (set! v1-1 (the-as none -2)) - (set! a0-1 (the-as none (-> a3-0 r-g-b-a x))) - (set! a1-2 (the-as none (logand a1-1 #x4000))) - (set! a2-5 (the-as none 1)) - (set! a1-3 (the-as none (sra a1-2 14))) - (set! v1-2 (the-as none (logand a0-1 v1-1))) - (set! v1-3 (the-as none (logior v1-2 a1-3))) - (set! (-> a3-0 r-g-b-a x) (the-as float v1-3)) - (set! a1-4 (the-as none (+ sp-0 32))) - (set! s3-0 (the-as none (+ sp-0 48))) - (set! v1-4 (the-as none a1-4)) - (set! f0-7 (the-as none (-> a3-0 qx-qy-qz-sy x))) - (s.f! v1-4 f0-7) - (set! f0-8 (the-as none (-> a3-0 qx-qy-qz-sy y))) - (s.f! (+ v1-4 4) f0-8) - (set! f0-9 (the-as none (-> a3-0 qx-qy-qz-sy z))) - (s.f! (+ v1-4 8) f0-9) - (set! a0-2 (the-as none #x3f800000)) - (set! f0-10 (the-as none (gpr->fpr a0-2))) - (s.f! (+ v1-4 12) f0-10) - (set! t9-1 (the-as none quaternion-zxy!)) - (set! a0-3 (the-as none s3-0)) - (call!) - (set! v1-5 (the-as none #x40000)) - (set! a0-4 (the-as none (-> a2-0 flags))) - (set! v1-6 (the-as none (logand v1-5 a0-4))) - (nonzero? v1-6) + (let ((s4-0 (new 'stack-no-clear 'quaternion))) + (let* ((v1-0 s4-0) + (a2-1 arg3) + (f0-0 (-> a2-1 qx-qy-qz-sy x)) + (f1-0 (-> a2-1 qx-qy-qz-sy y)) + (f2-0 (-> a2-1 qx-qy-qz-sy z)) + ) + (set! (-> v1-0 x) f0-0) + (set! (-> v1-0 y) f1-0) + (set! (-> v1-0 z) f2-0) + (set! (-> v1-0 w) (sqrtf (- (- (- 1.0 (* f2-0 f2-0)) (* f1-0 f1-0)) (* f0-0 f0-0)))) + ) + (set! (-> arg3 qx-qy-qz-sy x) 0.0) + (set! (-> arg3 qx-qy-qz-sy y) 0.0) + (set! (-> arg3 qx-qy-qz-sy z) 0.0) + (sp-relaunch-setup-fields arg0 arg1 arg2 arg3) + (let* ((a1-1 (-> arg2 flags-s32)) + (v1-1 -2) + (a0-1 (-> arg3 r-g-b-a x)) + (a1-2 (logand a1-1 (sp-cpuinfo-flag-s32 sp-cpuinfo-flag-14))) + ) + 1 + (let ((a1-3 (sar (the-as int a1-2) 14))) + (set! (-> arg3 r-g-b-a x) (the-as float (logior (logand a0-1 (the-as uint v1-1)) a1-3))) + ) + ) + (let ((a1-4 (new 'stack-no-clear 'vector)) + (s3-0 (new 'stack-no-clear 'quaternion)) ) - (set! t9-2 (the-as none quaternion*!)) - (set! a0-5 (the-as none s3-0)) - (set! a2-6 (the-as none s3-0)) - (set! a1-5 (the-as none s4-0)) - (call!) - (set! v1-8 (the-as none v0-2)) - ) - (cond - ((begin (set! f0-11 (the-as none (l.f (+ s3-0 12)))) (set! f1-3 (the-as none 0)) (<.s f0-11 f1-3)) - (.lvf vf1 (+ a3-0 16)) - (.lvf vf2 s3-0) - (.sub.vf vf1 vf0 vf2 :mask #b111) - (s.vf! (+ a3-0 16) vf1) - (.mov v1-9 vf1) - ) - (else - (.lvf vf1 (+ a3-0 16)) - (.lvf vf2 s3-0) - (.add.vf vf1 vf0 vf2 :mask #b111) - (s.vf! (+ a3-0 16) vf1) - (.mov v1-10 vf1) + (set-vector! a1-4 (-> arg3 qx-qy-qz-sy x) (-> arg3 qx-qy-qz-sy y) (-> arg3 qx-qy-qz-sy z) 1.0) + (quaternion-zxy! s3-0 a1-4) + (if (logtest? (sp-cpuinfo-flag left-multiply-quat) (-> arg2 flags)) + (quaternion*! s3-0 s4-0 s3-0) + ) + (cond + ((< (-> s3-0 w) 0.0) + (.lvf vf1 (&-> arg3 qx-qy-qz-sy quad)) + (.lvf vf2 (&-> s3-0 vec quad)) + (.sub.vf vf1 vf0 vf2 :mask #b111) + (.svf (&-> arg3 qx-qy-qz-sy quad) vf1) + (.mov v1-9 vf1) + ) + (else + (.lvf vf1 (&-> arg3 qx-qy-qz-sy quad)) + (.lvf vf2 (&-> s3-0 vec quad)) + (.add.vf vf1 vf0 vf2 :mask #b111) + (.svf (&-> arg3 qx-qy-qz-sy quad) vf1) + (.mov v1-10 vf1) + ) + ) ) ) (cond - ((begin (set! v1-11 (the-as none *sp-60-hz*)) v1-11) - (set! v1-12 (the-as none #x40a00000)) - (set! f0-12 (the-as none (gpr->fpr v1-12))) - (set! f1-4 (the-as none (l.f (+ a2-0 32)))) - (set! f0-13 (the-as none (*.s f0-12 f1-4))) - (s.f! (+ a2-0 32) f0-13) - (set! v1-13 (the-as none #x40a00000)) - (set! f0-14 (the-as none (gpr->fpr v1-13))) - (set! f1-5 (the-as none (l.f (+ a2-0 36)))) - (set! f0-15 (the-as none (*.s f0-14 f1-5))) - (s.f! (+ a2-0 36) f0-15) - (set! v1-14 (the-as none #x40a00000)) - (set! f0-16 (the-as none (gpr->fpr v1-14))) - (set! f1-6 (the-as none (l.f (+ a2-0 40)))) - (set! f0-17 (the-as none (*.s f0-16 f1-6))) - (s.f! (+ a2-0 40) f0-17) - (set! v1-15 (the-as none (fpr->gpr f0-17))) - ) + (*sp-60-hz* + (set! (-> arg2 rot-syvel x) (* 5.0 (-> arg2 rot-syvel x))) + (set! (-> arg2 rot-syvel y) (* 5.0 (-> arg2 rot-syvel y))) + (set! (-> arg2 rot-syvel z) (* 5.0 (-> arg2 rot-syvel z))) + ) (else - (set! v1-16 (the-as none #x40c00000)) - (set! f0-18 (the-as none (gpr->fpr v1-16))) - (set! f1-7 (the-as none (l.f (+ a2-0 32)))) - (set! f0-19 (the-as none (*.s f0-18 f1-7))) - (s.f! (+ a2-0 32) f0-19) - (set! v1-17 (the-as none #x40c00000)) - (set! f0-20 (the-as none (gpr->fpr v1-17))) - (set! f1-8 (the-as none (l.f (+ a2-0 36)))) - (set! f0-21 (the-as none (*.s f0-20 f1-8))) - (s.f! (+ a2-0 36) f0-21) - (set! v1-18 (the-as none #x40c00000)) - (set! f0-22 (the-as none (gpr->fpr v1-18))) - (set! f1-9 (the-as none (l.f (+ a2-0 40)))) - (set! f0-23 (the-as none (*.s f0-22 f1-9))) - (s.f! (+ a2-0 40) f0-23) - (set! v1-19 (the-as none (fpr->gpr f0-23))) + (set! (-> arg2 rot-syvel x) (* 6.0 (-> arg2 rot-syvel x))) + (set! (-> arg2 rot-syvel y) (* 6.0 (-> arg2 rot-syvel y))) + (set! (-> arg2 rot-syvel z) (* 6.0 (-> arg2 rot-syvel z))) ) ) - (set! t9-3 (the-as none quaternion-zxy!)) - (set! a0-6 (the-as none (+ a2-0 80))) - (set! a1-6 (the-as none (+ a2-0 32))) - (call!) - (set! v1-20 (the-as none v0-3)) - (set! v0-4 (the-as none 0)) - (ret-none) + (quaternion-zxy! (-> arg2 rotvel3d) (-> arg2 rot-syvel)) + 0 + (none) ) ) @@ -1257,7 +1177,7 @@ ) ;; definition for method 10 of type sparticle-launch-control -(defmethod sparticle-launch-control-method-10 sparticle-launch-control ((obj sparticle-launch-control) (arg0 vector)) +(defmethod is-visible? sparticle-launch-control ((obj sparticle-launch-control) (arg0 vector)) (let* ((v1-0 (-> obj group)) (f0-0 (-> v1-0 bounds r)) ) @@ -1290,7 +1210,7 @@ ;; definition for method 12 of type sparticle-launch-control ;; INFO: Used lq/sq -(defmethod sparticle-launch-control-method-12 sparticle-launch-control ((obj sparticle-launch-control) (arg0 matrix)) +(defmethod spawn-with-matrix sparticle-launch-control ((obj sparticle-launch-control) (arg0 matrix)) (let* ((a2-0 (-> obj origin)) (a3-0 arg0) (v1-0 (-> a3-0 vector 0 quad)) @@ -1338,7 +1258,7 @@ ;; definition for method 13 of type sparticle-launch-control ;; INFO: Used lq/sq -(defmethod sparticle-launch-control-method-13 sparticle-launch-control ((obj sparticle-launch-control) (arg0 cspace)) +(defmethod spawn-with-cspace sparticle-launch-control ((obj sparticle-launch-control) (arg0 cspace)) (let* ((v1-0 (-> obj origin)) (a3-0 (-> arg0 bone transform)) (a0-2 (-> a3-0 vector 0 quad)) @@ -1391,10 +1311,7 @@ (defmethod spawn sparticle-launch-control ((obj sparticle-launch-control) (arg0 vector)) (with-pp (set! (-> obj origin trans quad) (-> arg0 quad)) - (if (not (or (sparticle-launch-control-method-10 obj arg0) - (logtest? (-> obj group flags) (sp-group-flag always-draw screen-space)) - ) - ) + (if (not (or (is-visible? obj arg0) (logtest? (-> obj group flags) (sp-group-flag always-draw screen-space)))) (return 0) ) (let ((s4-0 (the-as int (-> pp clock frame-counter))) @@ -1580,280 +1497,110 @@ ;; definition for function execute-part-engine ;; INFO: Used lq/sq -;; ERROR: failed type prop at 12: Could not figure out load: (set! a1 (l.wu (+ a0 132))) ;; WARN: Return type mismatch int vs none. (defun execute-part-engine () - (local-vars - (v0-0 none) - (v0-1 none) - (v0-2 none) - (v0-3 vector) - (v0-4 float) - (v0-5 none) - (v0-6 int) - (v1-0 engine) - (v1-1 connectable) - (v1-2 none) - (v1-3 none) - (v1-4 none) - (v1-5 none) - (v1-6 none) - (v1-7 none) - (v1-8 none) - (v1-9 none) - (v1-12 int) - (v1-13 int) - (v1-14 int) - (v1-15 int) - (v1-16 level) - (v1-17 int) - (v1-18 int) - (v1-19 int) - (v1-20 symbol) - (v1-21 int) - (v1-22 symbol) - (v1-23 symbol) - (v1-25 vector) - (v1-28 level-group) - (v1-29 int) - (a0-1 connectable) - (a0-2 basic) - (a0-3 none) - (a0-4 none) - (a0-5 none) - (a0-6 none) - (a0-7 none) - (a0-8 none) - (a0-11 none) - (a0-12 engine) - (a0-13 connectable) - (a0-14 (pointer time-of-day-proc)) - (a0-15 time-of-day-proc) - (a0-16 int) - (a0-18 level-group) - (a0-19 symbol) - (a0-22 vector) - (a0-23 connectable) - (a0-24 int) - (a0-25 sparticle-system) - (a1-0 none) - (a1-1 none) - (a1-3 none) - (a1-4 none) - (a1-5 none) - (a1-6 none) - (a1-8 none) - (a1-10 none) - (a1-12 symbol) - (a1-13 (pointer basic)) - (a1-14 connectable) - (a2-0 none) - (a2-1 none) - (a2-2 none) - (a2-5 matrix) - (a3-0 none) - (a3-2 vector) - (a3-3 uint128) - (a3-4 symbol) - (t0-0 none) - (t0-1 none) - (t0-3 symbol) - (t1-0 none) - (t1-1 float) - (s0-0 none) - (s0-1 connection) - (s1-0 connectable) - (s1-1 int) - (s2-0 vector) - (s2-1 engine) - (s3-0 matrix) - (s3-1 int) - (s4-0 (array sparticle-launcher)) - (s4-1 int) - (s5-0 engine) - (s5-1 vector) - (t9-0 none) - (t9-1 none) - (t9-2 none) - (t9-3 (function vector)) - (t9-4 (function vector vector float)) - (t9-5 - (function sparticle-system sparticle-launcher matrix sparticle-launch-state sparticle-launch-control float none) - ) - (gp-0 sparticle-system) - (f0-0 none) - (f0-1 none) - (f0-2 float) - (f1-0 none) - (f1-1 int) - (sv-96 none) - (sv-104 none) - ) - (set! gp-0 *sp-particle-system-2d*) - (set! s5-0 *part-engine*) - (set! s4-0 *part-id-table*) - (set! s3-0 (new 'stack-no-clear 'matrix)) - (set! s2-0 (new 'stack-no-clear 'vector)) - (set! v1-0 s5-0) - (set! v1-1 (-> v1-0 alive-list next0)) - (set! a0-0 s5-0) - (set! a0-1 v1-1) - (set! s1-0 (-> a0-1 next0)) - (while (begin (set! a0-12 s5-0) (set! a0-13 (-> a0-12 alive-list-end)) (!= v1-1 a0-13)) - (when (begin - (and (begin - (set! a0-2 (-> v1-1 param1)) - (set! a1-0 (the-as none (l.wu (+ a0-2 132)))) - (set! s0-0 (the-as none (l.w (+ v1-1 28)))) - (set! a2-0 (the-as none (l.hu (+ a1-0 4)))) - (set! a2-1 (the-as none (logand a2-0 8))) - (nonzero? a2-1) - ) - (begin - (set! f0-0 (the-as none (l.f (+ a1-0 108)))) - (set! f1-0 (the-as none (l.f (+ s0-0 12)))) - (set! a1-1 (the-as none (<.s f0-0 f1-0))) - ) - ) - a1-1 - ) - (when (begin - (set! a1-3 (the-as none (l.w (+ v1-1 24)))) - (set! a1-4 (the-as none (sll a1-3 2))) - (set! a1-5 (the-as none (+ a1-4 s4-0))) - (set! a1-6 (the-as none (l.wu (+ a1-5 12)))) - (set! sv-96 a1-6) - (set! v1-2 (the-as none (l.wu (+ v1-1 16)))) - (set! sv-104 v1-2) - (set! v1-3 sv-96) - (nonzero? v1-3) + (local-vars (sv-96 sparticle-launcher) (sv-104 int)) + (let ((gp-0 *sp-particle-system-2d*)) + (let* ((s5-0 *part-engine*) + (s4-0 *part-id-table*) + (s3-0 (new 'stack-no-clear 'matrix)) + (s2-0 (new 'stack-no-clear 'vector)) + (v1-1 (-> s5-0 alive-list next0)) + (s1-0 (-> v1-1 next0)) + ) + (while (!= v1-1 (-> s5-0 alive-list-end)) + (let* ((a0-2 (the-as process-drawable (-> (the-as connection v1-1) param1))) + (a1-0 (-> a0-2 draw)) + (s0-0 (the-as object (-> (the-as connection v1-1) param3))) + ) + (when (and (logtest? (-> a1-0 status) (draw-control-status on-screen)) + (< (-> a1-0 distance) (-> (the-as vector s0-0) w)) + ) + (set! sv-96 (-> s4-0 (-> (the-as connection v1-1) param2))) + (set! sv-104 (the-as int (-> (the-as connection v1-1) param0))) + (when (nonzero? sv-96) + (let ((a1-8 (-> a0-2 node-list data sv-104))) + (let* ((v1-7 s3-0) + (t0-0 (-> a1-8 bone transform)) + (a0-5 (-> t0-0 vector 0 quad)) + (a2-2 (-> t0-0 vector 1 quad)) + (a3-0 (-> t0-0 vector 2 quad)) + (t0-1 (-> t0-0 trans quad)) + ) + (set! (-> v1-7 vector 0 quad) a0-5) + (set! (-> v1-7 vector 1 quad) a2-2) + (set! (-> v1-7 vector 2 quad) a3-0) + (set! (-> v1-7 trans quad) t0-1) + ) + (vector<-cspace! (-> s3-0 trans) a1-8) + ) + (set! (-> s2-0 quad) (-> (the-as vector s0-0) quad)) + (set! (-> s2-0 w) 1.0) + (vector-matrix*! (-> s3-0 trans) s2-0 s3-0) + (sp-launch-particles-var + gp-0 + sv-96 + s3-0 + (the-as sparticle-launch-state #f) + (the-as sparticle-launch-control #f) + 1.0 + ) ) - (set! v1-4 sv-104) - (set! v1-5 (the-as none (sll v1-4 5))) - (set! v1-6 (the-as none (+ v1-5 12))) - (set! a0-3 (the-as none (l.wu (+ a0-2 128)))) - (set! a1-8 (the-as none (+ v1-6 a0-3))) - (set! v1-7 (the-as none s3-0)) - (set! a0-4 (the-as none (l.wu (+ a1-8 16)))) - (set! t0-0 (the-as none (+ a0-4 0))) - (set! a0-5 (the-as none (l.q t0-0))) - (set! a2-2 (the-as none (l.q (+ t0-0 16)))) - (set! a3-0 (the-as none (l.q (+ t0-0 32)))) - (set! t0-1 (the-as none (l.q (+ t0-0 48)))) - (s.q! v1-7 a0-5) - (s.q! (+ v1-7 16) a2-2) - (s.q! (+ v1-7 32) a3-0) - (s.q! (+ v1-7 48) t0-1) - (set! t9-0 (the-as none vector<-cspace!)) - (set! a0-6 (the-as none (+ s3-0 48))) - (call!) - (set! v1-8 (the-as none s2-0)) - (set! a0-7 (the-as none (l.q s0-0))) - (s.q! v1-8 a0-7) - (set! v1-9 (the-as none #x3f800000)) - (set! f0-1 (the-as none (gpr->fpr v1-9))) - (s.f! (+ s2-0 12) f0-1) - (set! t9-1 (the-as none vector-matrix*!)) - (set! a0-8 (the-as none (+ s3-0 48))) - (set! a1-9 (the-as none s2-0)) - (set! a2-3 (the-as none s3-0)) - (call!) - (set! t9-2 (the-as none sp-launch-particles-var)) - (set! a0-9 (the-as none gp-0)) - (set! a1-10 sv-96) - (set! a2-4 (the-as none s3-0)) - (set! t1-0 (the-as none #x3f800000)) - (call!) - (set! a1-11 (the-as none v0-2)) + ) + ) + (set! v1-1 s1-0) + (set! s1-0 (-> s1-0 next0)) ) ) - (set! v1-1 (the-as connectable s1-0)) - (set! a0-10 (the-as none s5-0)) - (set! a0-11 (the-as none (l.wu s1-0))) - (set! s1-0 (the-as connectable a0-11)) - ) - (cond - ((begin - (set! t9-3 camera-pos) - (set! v0-3 (call!)) - (set! s5-1 v0-3) - (set! v1-12 1) - (set! a0-14 *time-of-day*) - a0-14 - ) - (set! a0-15 (-> a0-14 0)) - (set! a0-16 (-> a0-15 hours)) - ) - (else - (set! a0-16 0) - ) - ) - (set! s4-1 (ash.si v1-12 a0-16)) - (set! s3-1 0) - (while (begin (set! v1-28 *level*) (set! v1-29 (-> v1-28 length)) (<.si s3-1 v1-29)) - (when (begin - (set! v1-13 5232) - (set! v1-14 (*.si v1-13 s3-1)) - (set! v1-15 (+ v1-14 256)) - (set! a0-18 *level*) - (set! v1-16 (+ v1-15 a0-18)) - (set! a0-19 'active) - (set! a1-12 (-> v1-16 status)) - (= a1-12 a0-19) - ) - (when (begin (set! s2-1 (-> v1-16 part-engine)) s2-1) - (set! s1-1 (-> s2-1 length)) - (while (nonzero? s1-1) - (when (begin - (or (begin - (set! s1-1 (+ s1-1 -1)) - (set! v1-17 (sll s1-1 5)) - (set! v1-18 (+ v1-17 92)) - (set! s0-1 (+ v1-18 s2-1)) - (set! v1-19 (-> s0-1 param3)) - (zero? v1-19) - ) - (begin - (set! t9-4 vector-vector-distance) - (set! a0-22 s5-1) - (set! a1-13 (&-> s0-1 param0)) - (set! v0-4 (call! a0-22 a1-13)) - (set! f0-2 (gpr->fpr v0-4)) - (set! v1-21 (-> s0-1 param3)) - (set! f1-1 (gpr->fpr v1-21)) - (set! v1-20 (<.s f0-2 f1-1)) + (let* ((s5-1 (camera-pos)) + (v1-12 1) + (a0-14 *time-of-day*) + (s4-1 (ash v1-12 (if a0-14 + (-> a0-14 0 hours) + 0 + ) + ) + ) + ) + (dotimes (s3-1 (-> *level* length)) + (let ((v1-16 (-> *level* level s3-1))) + (when (= (-> v1-16 status) 'active) + (let ((s2-1 (-> v1-16 part-engine))) + (when s2-1 + (countdown (s1-1 (-> s2-1 length)) + (let ((s0-1 (-> s2-1 data s1-1))) + (when (and (or (zero? (-> s0-1 param3)) + (< (vector-vector-distance s5-1 (the-as vector (&-> s0-1 param0))) (the-as float (gpr->fpr (-> s0-1 param3)))) + ) + (zero? (logand s4-1 (the-as int (-> s0-1 prev1)))) + ) + (let ((a1-14 (-> s0-1 next1)) + (t9-5 sp-launch-particles-var) + (a0-25 gp-0) + (a2-5 *launch-matrix*) + ) + (set! (-> a2-5 trans quad) (-> (the-as vector (&-> s0-1 param0)) quad)) + (t9-5 + a0-25 + (the-as sparticle-launcher a1-14) + a2-5 + (the-as sparticle-launch-state #f) + (the-as sparticle-launch-control #f) + 1.0 + ) ) ) - (and v1-20 (begin - (set! v1-23 #t) - (set! a0-23 (-> s0-1 prev1)) - (set! a0-24 (logand s4-1 a0-23)) - (cmove-#f-nonzero v1-22 a0-24 v1-23) - ) - ) - v1-22 + ) ) - (set! a1-14 (-> s0-1 next1)) - (set! t9-5 sp-launch-particles-var) - (set! a0-25 gp-0) - (set! a2-5 *launch-matrix*) - (set! v1-25 (-> a2-5 trans)) - (set! a3-2 (the-as vector (&-> s0-1 param0))) - (set! a3-3 (-> a3-2 quad)) - (set! (-> v1-25 quad) a3-3) - (set! a3-4 #f) - (set! t0-3 #f) - (set! t1-1 (the-as float #x3f800000)) - (call! a0-25 a1-14 a2-5 a3-4 t0-3 t1-1) - (set! v1-26 v0-5) + ) + ) ) ) ) ) - (set! s3-1 (+ s3-1 1)) ) - (set! v0-6 0) - (ret-none) + 0 + (none) ) ;; definition for function sparticle-track-root @@ -2081,873 +1828,302 @@ ;; definition for function sparticle-respawn-heights ;; INFO: Used lq/sq -;; ERROR: failed type prop at 12: Could not figure out load: (set! v1 (l.w (+ gp 16))) -(defun sparticle-respawn-heights ((a0-0 sparticle-system) (a1-0 sparticle-cpuinfo) (a2-0 vector)) - (local-vars - (v0-0 none) - (v0-1 none) - (v0-2 none) - (v1-0 none) - (v1-1 symbol) - (v1-2 none) - (v1-3 none) - (v1-4 none) - (v1-5 none) - (v1-7 none) - (v1-8 none) - (v1-10 none) - (v1-11 none) - (v1-12 none) - (v1-13 none) - (v1-14 none) - (v1-15 none) - (v1-16 none) - (v1-17 none) - (a0-1 none) - (a1-2 none) - (a1-3 none) - (a2-1 none) - (a3-0 none) - (a3-1 none) - (t1-0 none) - (s1-0 none) - (s2-0 none) - (s3-0 none) - (s5-1 none) - (t9-0 none) - (t9-1 none) - (gp-0 float) - (sp-0 none) - (f0-0 float) - (f0-1 float) - (f0-2 none) - (f0-3 none) - (f0-4 none) - (f0-5 none) - (f0-6 none) - (f0-7 none) - (f1-0 float) - (f1-1 none) - (f1-2 none) - (f1-3 none) - ) - (when (begin - (and (begin (set! gp-0 (-> a1-0 user-float)) (nonzero? gp-0)) - (or (begin - (and (begin (set! f0-0 (-> a1-0 vel-sxvel y)) (set! f1-0 (the-as float 0)) (set! v1-1 (<.s f0-0 f1-0)) v1-1) - (begin - (set! f0-1 (-> a2-0 y)) - (set! v1-3 (the-as none (l.w (+ gp-0 16)))) - (set! f1-1 (the-as none (gpr->fpr v1-3))) - (set! v1-2 (the-as none (<.s f0-1 f1-1))) - ) - ) - v1-2 - ) - (and (begin - (set! f0-2 (the-as none 0)) - (set! f1-2 (the-as none (l.f (+ a1-0 20)))) - (set! v1-4 (the-as none (<.s f0-2 f1-2))) - v1-4 - ) - (begin - (set! v1-5 (the-as none (l.w (+ gp-0 20)))) - (set! f0-3 (the-as none (gpr->fpr v1-5))) - (set! f1-3 (the-as none (l.f (+ a2-0 4)))) - (set! v1-0 (the-as none (<.s f0-3 f1-3))) - ) - ) +;; WARN: Return type mismatch int vs none. +(defun sparticle-respawn-heights ((arg0 sparticle-system) (arg1 sparticle-cpuinfo) (arg2 vector)) + (let ((gp-0 (the-as (array int32) (-> arg1 user-float)))) + (when (and (nonzero? gp-0) + (or (and (< (-> arg1 vel-sxvel y) 0.0) (< (-> arg2 y) (the-as float (gpr->fpr (-> gp-0 1))))) + (and (< 0.0 (-> arg1 vel-sxvel y)) (< (the-as float (gpr->fpr (-> gp-0 2))) (-> arg2 y))) ) ) - v1-0 - ) - (when (begin - (set! t9-0 (the-as none sp-kill-particle)) - (set! a1-1 (the-as none a1-0)) - (call!) - (set! v1-7 (the-as none (l.w gp-0))) - (set! s3-0 (the-as none (+ v1-7 -1))) - (set! v1-8 (the-as none 2)) - (<.si v1-8 s3-0) + (sp-kill-particle arg0 arg1) + (let ((s3-0 (+ (the-as int (-> gp-0 length)) -1))) + (when (< 2 s3-0) + (let ((s2-0 (new 'stack-no-clear 'vector)) + (s1-0 (if (zero? (-> gp-0 0)) + *sp-particle-system-2d* + *sp-particle-system-3d* + ) + ) + ) + (set-vector! s2-0 (-> arg2 x) (-> arg1 user-float) (-> arg2 z) 1.0) + (let ((s5-1 3)) + (while (>= s3-0 s5-1) + (let ((t9-1 sp-launch-particles-var) + (a0-2 s1-0) + (a1-3 (-> *part-id-table* (-> gp-0 s5-1))) + (a2-1 *launch-matrix*) + ) + (set! (-> a2-1 trans quad) (-> s2-0 quad)) + (t9-1 a0-2 a1-3 a2-1 (the-as sparticle-launch-state #f) (the-as sparticle-launch-control #f) 1.0) + ) + (+! s5-1 1) + ) + ) ) - (if (begin (set! s2-0 (the-as none (+ sp-0 16))) (set! v1-10 (the-as none (l.w (+ gp-0 12)))) (zero? v1-10)) - (set! s1-0 (the-as none *sp-particle-system-2d*)) - (set! s1-0 (the-as none *sp-particle-system-3d*)) ) - (set! v1-11 (the-as none s2-0)) - (set! f0-4 (the-as none (l.f a2-0))) - (s.f! v1-11 f0-4) - (set! f0-5 (the-as none (l.f (+ a1-0 108)))) - (s.f! (+ v1-11 4) f0-5) - (set! f0-6 (the-as none (l.f (+ a2-0 8)))) - (s.f! (+ v1-11 8) f0-6) - (set! a0-1 (the-as none #x3f800000)) - (set! f0-7 (the-as none (gpr->fpr a0-1))) - (s.f! (+ v1-11 12) f0-7) - (set! s5-1 (the-as none 3)) - (while (>=.si s3-0 s5-1) - (set! t9-1 (the-as none sp-launch-particles-var)) - (set! a0-2 (the-as none s1-0)) - (set! v1-12 (the-as none (sll s5-1 2))) - (set! v1-13 (the-as none (+ v1-12 gp-0))) - (set! v1-14 (the-as none (l.w (+ v1-13 12)))) - (set! v1-15 (the-as none (sll v1-14 2))) - (set! a1-2 (the-as none *part-id-table*)) - (set! v1-16 (the-as none (+ v1-15 a1-2))) - (set! a1-3 (the-as none (l.wu (+ v1-16 12)))) - (set! a2-1 (the-as none *launch-matrix*)) - (set! v1-17 (the-as none (+ a2-1 48))) - (set! a3-0 (the-as none s2-0)) - (set! a3-1 (the-as none (l.q a3-0))) - (s.q! v1-17 a3-1) - (set! t1-0 (the-as none #x3f800000)) - (call!) - (set! s5-1 (the-as none (+ s5-1 1))) ) ) ) - (set! v0-2 (the-as none 0)) - (ret-none) + 0 + (none) ) ;; definition for function sparticle-respawn-timer ;; INFO: Used lq/sq -;; ERROR: failed type prop at 9: Could not figure out load: (set! v1 (l.w gp)) -(defun sparticle-respawn-timer ((a0-0 sparticle-system) (a1-0 sparticle-cpuinfo) (a2-0 vector)) - (local-vars - (v0-0 symbol) - (v0-1 none) - (v0-2 none) - (v1-0 int) - (v1-3 none) - (v1-4 none) - (v1-6 none) - (v1-7 none) - (v1-8 none) - (v1-9 none) - (v1-10 none) - (v1-11 none) - (v1-12 none) - (v1-13 none) - (a0-1 none) - (a1-1 sparticle-cpuinfo) - (a1-2 none) - (a1-3 none) - (a2-1 none) - (a3-0 none) - (a3-1 none) - (t1-0 none) - (s2-1 none) - (s3-0 none) - (s4-0 none) - (s5-0 none) - (t9-0 (function sparticle-system sparticle-cpuinfo symbol)) - (t9-1 none) - (gp-0 float) - (sp-0 none) - (f0-0 none) - (f0-1 none) - (f0-2 none) - (f0-3 none) - ) - (when (begin (set! v1-0 (-> a1-0 timer)) (<=0.si v1-0)) - (when (begin (set! gp-0 (-> a1-0 user-float)) (nonzero? gp-0)) - (when (begin - (set! t9-0 sp-kill-particle) - (set! a1-1 a1-0) - (call! a0-0 a1-1) - (set! v1-3 (the-as none (l.w gp-0))) - (set! s5-0 (the-as none (+ v1-3 -1))) - (set! v1-4 (the-as none 2)) - (<.si v1-4 s5-0) +;; WARN: Return type mismatch int vs none. +(defun sparticle-respawn-timer ((arg0 sparticle-system) (arg1 sparticle-cpuinfo) (arg2 vector)) + (when (<= (-> arg1 timer) 0) + (let ((gp-0 (the-as object (-> arg1 user-float)))) + (when (nonzero? (the-as float gp-0)) + (sp-kill-particle arg0 arg1) + (let ((s5-0 (+ (the-as int (-> (the-as (array int32) gp-0) length)) -1))) + (when (< 2 s5-0) + (let ((s4-0 (new 'stack-no-clear 'vector)) + (s3-0 (if (zero? (-> (the-as (array int32) gp-0) 0)) + *sp-particle-system-2d* + *sp-particle-system-3d* + ) + ) + ) + (set-vector! s4-0 (-> arg2 x) (-> arg1 user-float) (-> arg2 z) 1.0) + (let ((s2-1 3)) + (while (>= s5-0 s2-1) + (let ((t9-1 sp-launch-particles-var) + (a0-2 s3-0) + (a1-3 (-> *part-id-table* (-> (the-as (array int32) gp-0) s2-1))) + (a2-1 *launch-matrix*) + ) + (set! (-> a2-1 trans quad) (-> s4-0 quad)) + (t9-1 a0-2 a1-3 a2-1 (the-as sparticle-launch-state #f) (the-as sparticle-launch-control #f) 1.0) + ) + (+! s2-1 1) + ) + ) ) - (if (begin (set! s4-0 (the-as none (+ sp-0 16))) (set! v1-6 (the-as none (l.w (+ gp-0 12)))) (zero? v1-6)) - (set! s3-0 (the-as none *sp-particle-system-2d*)) - (set! s3-0 (the-as none *sp-particle-system-3d*)) ) - (set! v1-7 (the-as none s4-0)) - (set! f0-0 (the-as none (l.f a2-0))) - (s.f! v1-7 f0-0) - (set! f0-1 (the-as none (l.f (+ a1-0 108)))) - (s.f! (+ v1-7 4) f0-1) - (set! f0-2 (the-as none (l.f (+ a2-0 8)))) - (s.f! (+ v1-7 8) f0-2) - (set! a0-1 (the-as none #x3f800000)) - (set! f0-3 (the-as none (gpr->fpr a0-1))) - (s.f! (+ v1-7 12) f0-3) - (set! s2-1 (the-as none 3)) - (while (>=.si s5-0 s2-1) - (set! t9-1 (the-as none sp-launch-particles-var)) - (set! a0-2 (the-as none s3-0)) - (set! v1-8 (the-as none (sll s2-1 2))) - (set! v1-9 (the-as none (+ v1-8 gp-0))) - (set! v1-10 (the-as none (l.w (+ v1-9 12)))) - (set! v1-11 (the-as none (sll v1-10 2))) - (set! a1-2 (the-as none *part-id-table*)) - (set! v1-12 (the-as none (+ v1-11 a1-2))) - (set! a1-3 (the-as none (l.wu (+ v1-12 12)))) - (set! a2-1 (the-as none *launch-matrix*)) - (set! v1-13 (the-as none (+ a2-1 48))) - (set! a3-0 (the-as none s4-0)) - (set! a3-1 (the-as none (l.q a3-0))) - (s.q! v1-13 a3-1) - (set! t1-0 (the-as none #x3f800000)) - (call!) - (set! s2-1 (the-as none (+ s2-1 1))) ) ) ) ) - (set! v0-2 (the-as none 0)) - (ret-none) + 0 + (none) ) ;; definition for function sparticle-texture-animate -;; ERROR: failed type prop at 2: Could not figure out load: (set! a0 (l.w (+ v1 20))) -(defun sparticle-texture-animate ((a0-0 sparticle-system) (a1-0 sparticle-cpuinfo) (a2-0 vector)) - (local-vars - (v0-0 none) - (v0-1 none) - (v1-0 float) - (v1-1 none) - (v1-2 none) - (v1-3 none) - (v1-4 none) - (a0-2 none) - (a0-4 none) - (a0-5 none) - (a0-6 none) - (a0-7 none) - (a0-8 none) - (a0-9 none) - (a0-11 none) - (a0-13 none) - (a0-14 none) - (a0-15 none) - (a0-17 none) - (a2-1 none) - (a2-2 none) - (a2-3 none) - (a2-4 none) - (a2-5 none) - (a2-6 none) - (a2-7 none) - (a3-0 none) - (a3-1 none) - (a3-2 none) - (a3-3 none) - (a3-4 none) - (a3-5 none) - (a3-6 none) - (a3-7 none) - (t0-0 none) - (t0-1 none) - (t0-2 none) - (t0-3 none) - (t0-4 none) - (t9-0 none) - (t9-1 none) - ) - (when (begin (set! v1-0 (-> a1-0 user-float)) (nonzero? v1-0)) - (cond - ((begin - (when (begin (set! a0-2 (the-as none (l.w (+ v1-0 20)))) (zero? a0-2)) - (set! a0-4 (the-as none (l.w (+ a1-0 100)))) - (s.w! (+ v1-0 20) a0-4) - ) - (cond - ((begin - (set! a0-5 (the-as none (l.w v1-0))) - (set! a0-6 (the-as none (+ a0-5 -3))) - (set! a2-1 (the-as none (l.w (+ v1-0 12)))) - (set! a3-0 (the-as none (l.w (+ v1-0 20)))) - (set! t0-0 (the-as none (l.w (+ a1-0 100)))) - (<0.si t0-0) - ) - (set! a3-1 (the-as none *display*)) - (set! a3-2 (the-as none (l.wu (+ a3-1 44)))) - (set! t0-1 (the-as none (l.d (+ a3-2 20)))) - ) - (else - (set! t0-2 (the-as none (l.w (+ a1-0 100)))) - (set! t0-1 (the-as none (- a3-0 t0-2))) +;; WARN: Return type mismatch symbol vs none. +(defun sparticle-texture-animate ((arg0 sparticle-system) (arg1 sparticle-cpuinfo) (arg2 vector)) + (let ((v1-0 (the-as (array int32) (-> arg1 user-float)))) + (when (nonzero? v1-0) + (if (zero? (-> v1-0 2)) + (set! (-> v1-0 2) (-> arg1 timer)) + ) + (let* ((a0-6 (+ (-> v1-0 length) -3)) + (a2-1 (-> v1-0 0)) + (a3-0 (-> v1-0 2)) + (t0-1 (if (< (-> arg1 timer) 0) + (the-as int (-> *display* base-clock frame-counter)) + (- a3-0 (-> arg1 timer)) + ) + ) + ) + (cond + ((zero? (-> v1-0 1)) + (let ((v1-2 (-> v1-0 (+ (max 0 (min (+ (/ t0-1 a2-1) (-> arg1 user1-int16)) (+ a0-6 -1))) 3)))) + (if (nonzero? v1-2) + (particle-adgif-callback (-> arg1 adgif) (the-as texture-id v1-2)) + ) ) ) - (set! a3-3 (the-as none (l.w (+ v1-0 16)))) - (zero? a3-3) - ) - (when (begin - (set! a3-4 (the-as none 0)) - (set! a2-2 (the-as none (/.si t0-1 a2-1))) - (set! t0-3 (the-as none (l.hu (+ a1-0 130)))) - (set! a2-3 (the-as none (+ a2-2 t0-3))) - (set! a2-4 (the-as none a2-3)) - (set! a0-7 (the-as none (+ a0-6 -1))) - (set! a2-5 (the-as none (min.si a2-4 a0-7))) - (set! a3-5 (the-as none (max.si a3-4 a2-5))) - (set! a0-8 (the-as none (+ a3-5 3))) - (set! a0-9 (the-as none (sll a0-8 2))) - (set! v1-1 (the-as none (+ a0-9 v1-0))) - (set! v1-2 (the-as none (l.w (+ v1-1 12)))) - (nonzero? v1-2) - ) - (set! t9-0 (the-as none particle-adgif-callback)) - (set! a0-11 (the-as none (l.wu (+ a1-0 4)))) - (set! a1-1 (the-as none v1-2)) - (call!) - (set! a0-12 (the-as none v0-0)) - ) - ) - (else - (when (begin - (set! a3-6 (the-as none 0)) - (set! a2-6 (the-as none (/.si t0-1 a2-1))) - (set! t0-4 (the-as none (l.hu (+ a1-0 130)))) - (set! a2-7 (the-as none (+ a2-6 t0-4))) - (set! a3-7 (the-as none (max.si a3-6 a2-7))) - (set! a0-13 (the-as none (mod.si a3-7 a0-6))) - (set! a0-14 (the-as none (+ a0-13 3))) - (set! a0-15 (the-as none (sll a0-14 2))) - (set! v1-3 (the-as none (+ a0-15 v1-0))) - (set! v1-4 (the-as none (l.w (+ v1-3 12)))) - (nonzero? v1-4) - ) - (set! t9-1 (the-as none particle-adgif-callback)) - (set! a0-17 (the-as none (l.wu (+ a1-0 4)))) - (set! a1-2 (the-as none v1-4)) - (call!) - (set! a0-18 (the-as none v0-1)) + (else + (let ((v1-4 (-> v1-0 (+ (mod (max 0 (+ (/ t0-1 a2-1) (-> arg1 user1-int16))) a0-6) 3)))) + (if (nonzero? v1-4) + (particle-adgif-callback (-> arg1 adgif) (the-as texture-id v1-4)) + ) + ) + ) ) ) ) ) - (ret-none) + (none) ) ;; definition for function sparticle-texture-day-night ;; INFO: Used lq/sq -;; ERROR: failed type prop at 21: Could not figure out load: (set! a1 (l.w (+ s2 40))) +;; WARN: Return type mismatch symbol vs none. ;; ERROR: Bad vector register dependency: vf1 ;; ERROR: Bad vector register dependency: vf2 -(defun sparticle-texture-day-night ((a0-0 sparticle-system) (a1-0 sparticle-cpuinfo) (a2-0 vector)) +(defun sparticle-texture-day-night ((arg0 sparticle-system) (arg1 sparticle-cpuinfo) (arg2 sprite-vec-data-2d)) (local-vars - (v0-0 float) - (v0-1 none) - (v0-2 none) - (v1-1 (pointer time-of-day-proc)) - (v1-2 time-of-day-proc) - (v1-3 symbol) - (v1-4 int) - (v1-6 none) - (v1-7 none) - (v1-8 uint128) (v1-9 uint128) (v1-10 uint128) - (v1-11 none) - (v1-12 uint128) (v1-13 uint128) (v1-14 uint128) - (v1-15 none) - (v1-16 none) - (v1-17 none) - (v1-20 none) - (v1-21 none) - (v1-22 uint128) (v1-23 uint128) (v1-24 uint128) - (v1-25 none) - (v1-26 uint128) (v1-27 uint128) (v1-28 uint128) - (v1-29 none) - (v1-30 none) - (v1-31 none) - (v1-33 none) - (a0-1 symbol) - (a0-2 none) - (a0-4 none) - (a0-5 none) - (a0-6 none) - (a0-7 none) - (a0-8 none) - (a0-10 none) - (a0-11 none) - (a0-12 none) - (a0-13 none) - (a1-1 none) - (a1-2 none) - (t7-0 none) - (t7-1 none) - (t7-2 none) - (t7-3 none) - (t7-4 none) - (t7-5 none) - (s1-0 int) - (s2-0 float) + (v1-33 float) + (a0-5 float) + (a0-11 float) + (t7-0 float) + (t7-3 float) (s3-0 float) (s4-0 float) - (t9-0 (function float)) - (t9-1 none) - (t9-2 none) - (f0-0 float) ) (rlet ((vf1 :class vf) (vf2 :class vf) ) - (when (begin (set! s2-0 (-> a1-0 user-float)) (nonzero? s2-0)) - (cond - ((begin - (or (begin - (cond - ((begin (set! v1-1 *time-of-day*) v1-1) - (set! v1-2 (-> v1-1 0)) - (set! s1-0 (-> v1-2 hours)) - ) - (else - (set! s1-0 (the-as int 0)) + (let ((s2-0 (the-as object (-> arg1 user-float)))) + (when (nonzero? (the-as float s2-0)) + (let* ((v1-1 *time-of-day*) + (s1-0 (if v1-1 + (-> v1-1 0 hours) + 0 + ) + ) + (f0-0 (rand-vu)) + ) + (.mov s4-0 vf1) + (.mov s3-0 vf2) + (cond + ((or (< s1-0 6) (< 18 s1-0)) + (let ((a1-1 (-> (the-as (array int32) s2-0) 7))) + (when (nonzero? a1-1) + (let ((v1-6 f0-0)) + (.mov vf2 v1-6) + ) + (let ((v1-8 (the-as uint128 (make-u128 0 (-> (the-as (array int32) s2-0) 9))))) + (.pextlb v1-9 0 v1-8) + ) + (.pextlb v1-10 0 v1-9) + (.mov vf1 v1-10) + (.itof.vf vf1 vf1) + (.mul.x.vf vf1 vf1 vf2) + (let ((v1-12 (the-as uint128 (make-u128 0 (-> (the-as (array int32) s2-0) 8))))) + (.pextlb v1-13 0 v1-12) + ) + (.pextlb v1-14 0 v1-13) + (.mov vf2 v1-14) + (.itof.vf vf2 vf2) + (.add.vf vf1 vf1 vf2) + (let ((v1-15 (-> arg1 flags-s32))) + (when (nonzero? (-> (the-as (array int32) s2-0) 10)) + (.lvf vf2 (&-> *time-of-day-context* current-prt-color quad)) + (.mul.vf vf1 vf1 vf2) + (.mov a0-5 vf1) + ) + (let ((v1-16 (logand v1-15 (sp-cpuinfo-flag-s32 sp-cpuinfo-flag-14)))) + (.mov t7-0 vf1) + (let ((v1-17 (sar (the-as int v1-16) 14))) + (set! (-> arg2 r-g-b-a quad) (the-as uint128 (logior (logand t7-0 (the-as uint -2)) v1-17))) + ) ) ) - (set! t9-0 rand-vu) - (set! v0-0 (call!)) - (set! f0-0 (gpr->fpr v0-0)) - (.mov s4-0 vf1) - (.mov s3-0 vf2) - (set! a0-1 (<.si s1-0 6)) - a0-1 + (particle-adgif-callback (-> arg1 adgif) (the-as texture-id a1-1)) ) - (begin (set! v1-4 18) (set! v1-3 (<.si v1-4 s1-0))) ) - v1-3 - ) - (when (begin (set! a1-1 (the-as none (l.w (+ s2-0 40)))) (nonzero? a1-1)) - (when (begin - (set! v1-6 (the-as none (fpr->gpr f0-0))) - (.mov vf2 v1-6) - (set! v1-7 (the-as none (l.w (+ s2-0 48)))) - (set! v1-8 (the-as uint128 (pcypld 0 v1-7))) - (.pextlb v1-9 0 v1-8) - (.pextlb v1-10 0 v1-9) - (.mov vf1 v1-10) - (.itof.vf vf1 vf1) - (.mul.x.vf vf1 vf1 vf2) - (set! v1-11 (the-as none (l.w (+ s2-0 44)))) - (set! v1-12 (the-as uint128 (pcypld 0 v1-11))) - (.pextlb v1-13 0 v1-12) - (.pextlb v1-14 0 v1-13) - (.mov vf2 v1-14) - (.itof.vf vf2 vf2) - (.add.vf vf1 vf1 vf2) - (set! v1-15 (the-as none (l.w (+ a1-0 104)))) - (set! a0-2 (the-as none (l.w (+ s2-0 52)))) - (nonzero? a0-2) - ) - (set! a0-4 (the-as none *time-of-day-context*)) - (.lvf vf2 (+ a0-4 108)) - (.mul.vf vf1 vf1 vf2) - (.mov a0-5 vf1) ) - (set! v1-16 (the-as none (logand v1-15 #x4000))) - (.mov t7-0 vf1) - (set! v1-17 (the-as none (sra v1-16 14))) - (set! a0-6 (the-as none -2)) - (set! t7-1 (the-as none (logand t7-0 a0-6))) - (set! t7-2 (the-as none (logior t7-1 v1-17))) - (s.q! (+ a2-0 32) t7-2) - (set! t9-1 (the-as none particle-adgif-callback)) - (set! a0-7 (the-as none (l.wu (+ a1-0 4)))) - (call!) - (set! v1-18 (the-as none v0-1)) - ) - ) - (else - (when (begin (set! a1-2 (the-as none (l.w (+ s2-0 24)))) (nonzero? a1-2)) - (when (begin - (set! v1-20 (the-as none (fpr->gpr f0-0))) + (else + (let ((a1-2 (-> (the-as (array int32) s2-0) 3))) + (when (nonzero? a1-2) + (let ((v1-20 f0-0)) (.mov vf2 v1-20) - (set! v1-21 (the-as none (l.w (+ s2-0 32)))) - (set! v1-22 (the-as uint128 (pcypld 0 v1-21))) - (.pextlb v1-23 0 v1-22) - (.pextlb v1-24 0 v1-23) - (.mov vf1 v1-24) - (.itof.vf vf1 vf1) - (.mul.x.vf vf1 vf1 vf2) - (set! v1-25 (the-as none (l.w (+ s2-0 28)))) - (set! v1-26 (the-as uint128 (pcypld 0 v1-25))) - (.pextlb v1-27 0 v1-26) - (.pextlb v1-28 0 v1-27) - (.mov vf2 v1-28) - (.itof.vf vf2 vf2) - (.add.vf vf1 vf1 vf2) - (set! v1-29 (the-as none (l.w (+ a1-0 104)))) - (set! a0-8 (the-as none (l.w (+ s2-0 36)))) - (nonzero? a0-8) ) - (set! a0-10 (the-as none *time-of-day-context*)) - (.lvf vf2 (+ a0-10 108)) - (.mul.vf vf1 vf1 vf2) - (.mov a0-11 vf1) + (let ((v1-22 (the-as uint128 (make-u128 0 (-> (the-as (array int32) s2-0) 5))))) + (.pextlb v1-23 0 v1-22) + ) + (.pextlb v1-24 0 v1-23) + (.mov vf1 v1-24) + (.itof.vf vf1 vf1) + (.mul.x.vf vf1 vf1 vf2) + (let ((v1-26 (the-as uint128 (make-u128 0 (-> (the-as (array int32) s2-0) 4))))) + (.pextlb v1-27 0 v1-26) + ) + (.pextlb v1-28 0 v1-27) + (.mov vf2 v1-28) + (.itof.vf vf2 vf2) + (.add.vf vf1 vf1 vf2) + (let ((v1-29 (-> arg1 flags-s32))) + (when (nonzero? (-> (the-as (array int32) s2-0) 6)) + (.lvf vf2 (&-> *time-of-day-context* current-prt-color quad)) + (.mul.vf vf1 vf1 vf2) + (.mov a0-11 vf1) + ) + (let ((v1-30 (logand v1-29 (sp-cpuinfo-flag-s32 sp-cpuinfo-flag-14)))) + (.mov t7-3 vf1) + (let ((v1-31 (sar (the-as int v1-30) 14))) + (set! (-> arg2 r-g-b-a quad) (the-as uint128 (logior (logand t7-3 (the-as uint -2)) v1-31))) + ) + ) + ) + (particle-adgif-callback (-> arg1 adgif) (the-as texture-id a1-2)) + ) + ) ) - (set! v1-30 (the-as none (logand v1-29 #x4000))) - (.mov t7-3 vf1) - (set! v1-31 (the-as none (sra v1-30 14))) - (set! a0-12 (the-as none -2)) - (set! t7-4 (the-as none (logand t7-3 a0-12))) - (set! t7-5 (the-as none (logior t7-4 v1-31))) - (s.q! (+ a2-0 32) t7-5) - (set! t9-2 (the-as none particle-adgif-callback)) - (set! a0-13 (the-as none (l.wu (+ a1-0 4)))) - (call!) - (set! v1-32 (the-as none v0-2)) ) ) + (.mov vf1 s4-0) + (.mov vf2 s3-0) + (.mov v1-33 vf2) ) - (.mov vf1 s4-0) - (.mov vf2 s3-0) - (.mov v1-33 vf2) ) - (ret-none) + (none) ) ) ;; definition for function sparticle-mode-animate -;; ERROR: failed type prop at 5: Could not figure out load: (set! a1 (l.w (+ v1 12))) -(defun sparticle-mode-animate ((a0-0 sparticle-system) (a1-0 sparticle-cpuinfo) (a2-0 vector)) - (local-vars - (v0-0 none) - (v0-1 none) - (v0-2 none) - (v0-3 none) - (v1-0 float) - (a0-1 sparticle-launch-control) - (a0-2 none) - (a0-3 none) - (a0-4 none) - (a0-5 none) - (a0-6 none) - (a0-7 none) - (a0-8 none) - (a0-9 none) - (a0-10 none) - (a0-11 none) - (a0-12 none) - (a0-13 none) - (a0-14 none) - (a1-1 none) - (a1-2 none) - (a1-3 none) - (a1-4 none) - (a1-5 none) - (a1-6 none) - (a1-7 none) - (a1-8 none) - (a1-10 none) - (a1-11 none) - (a1-12 none) - (a2-3 none) - (a2-4 none) - (a2-5 none) - (a2-6 none) - (a2-7 none) - (a2-8 none) - (a2-9 none) - (a2-10 none) - (a2-11 none) - (a2-12 none) - (a2-13 none) - (a2-14 none) - (a3-0 none) - (a3-1 none) - (a3-2 none) - (s4-0 none) - (t9-0 none) - (t9-1 none) - (t9-2 none) - (f0-0 none) - (f0-1 none) - (f0-2 none) - (f0-3 none) - ) - (when (begin (set! a0-1 (-> a1-0 key)) (set! v1-0 (-> a1-0 user-float)) (nonzero? v1-0)) - (when (begin - (set! a1-1 (the-as none (l.w (+ v1-0 12)))) - (set! a1-2 (the-as none (l.w (+ a1-1 -1)))) - (nonzero? a1-2) - ) - (when (begin - (set! a2-3 (the-as none (l.bu (+ a0-1 29)))) - (set! a2-4 (the-as none (+ a2-3 1))) - (set! a2-5 (the-as none a2-4)) - (set! a3-0 (the-as none (l.w a1-2))) - (set! a3-1 (the-as none (+ a3-0 -1))) - (set! a2-6 (the-as none (min.si a2-5 a3-1))) - (set! a2-7 (the-as none (sll a2-6 2))) - (set! a1-3 (the-as none (+ a2-7 a1-2))) - (set! a1-4 (the-as none (l.wu (+ a1-3 12)))) - (set! a0-2 (the-as none (l.wu (+ a0-1 32)))) - (set! a2-8 (the-as none (l.w (+ a1-4 12)))) - (set! a2-9 (the-as none (sra a2-8 3))) - (set! a0-3 (the-as none (/.ui a0-2 a2-9))) - (set! a2-10 (the-as none (l.w a1-4))) - (set! a2-11 (the-as none (+ a2-10 -1))) - (set! a0-4 (the-as none (mod.si a0-3 a2-11))) - (set! a0-5 (the-as none (+ a0-4 1))) - (set! a0-6 (the-as none (sll a0-5 2))) - (set! a0-7 (the-as none (+ a0-6 a1-4))) - (set! a0-8 (the-as none (l.w (+ a0-7 12)))) - (set! a1-5 (the-as none (l.w (+ v1-0 16)))) - (set! a1-6 (the-as none (sra a1-5 3))) - (set! a2-12 (the-as none (sra a1-6 6))) - (set! a2-13 (the-as none (sll a2-12 3))) - (set! a0-9 (the-as none (+ a0-8 a2-13))) - (set! a2-14 (the-as none (l.d a0-9))) - (set! a0-10 (the-as none #t)) - (set! a3-2 (the-as none 1)) - (set! a1-7 (the-as none (logand a1-6 63))) - (set! a1-8 (the-as none (ash.si a3-2 a1-7))) - (if (begin (set! a1-10 (the-as none (logand a2-14 a1-8))) (cmove-#f-zero a0-11 a1-10 a0-10) a0-11) - (set! s4-0 (the-as none (l.w (+ v1-0 24)))) - (set! s4-0 (the-as none (l.w (+ v1-0 20)))) - ) - (cond - (a0-11 - (set! t9-0 (the-as none rand-vu-float-range)) - (set! a0-12 (the-as none #x42800000)) - (set! a1-11 (the-as none #x43400000)) - (set! v0-0 (the-as none (call!))) - (set! f0-0 (the-as none (gpr->fpr v0-0))) - (s.f! (+ a2-0 32) f0-0) - (set! v1-1 (the-as none (fpr->gpr f0-0))) - ) - (else - (set! t9-1 (the-as none rand-vu-float-range)) - (set! a0-13 (the-as none #x42000000)) - (set! a1-12 (the-as none #x42400000)) - (set! v0-1 (the-as none (call!))) - (set! f0-1 (the-as none (gpr->fpr v0-1))) - (s.f! (+ a2-0 32) f0-1) - (set! v1-2 (the-as none (fpr->gpr f0-1))) - ) +;; WARN: Return type mismatch int vs none. +(defun sparticle-mode-animate ((arg0 sparticle-system) (arg1 sparticle-cpuinfo) (arg2 sprite-vec-data-2d)) + (let ((a0-1 (-> arg1 key)) + (v1-0 (the-as object (-> arg1 user-float))) + ) + (when (nonzero? (the-as float v1-0)) + (let ((a1-2 (the-as (array uint32) (-> (the-as (array symbol) v1-0) 0 value)))) + (when (nonzero? a1-2) + (let* ((a1-4 (the-as object (-> a1-2 (min (the-as int (+ (-> a0-1 state-mode 0) 1)) (+ (-> a1-2 length) -1))))) + (a0-8 (the-as + object + (-> (the-as (array int32) a1-4) + (+ (mod + (the-as int (/ (-> a0-1 state-counter) (/ (the-as int (-> (the-as vector4w a1-4) w)) 8))) + (+ (-> (the-as (pointer int32) a1-4) 0) -1) + ) + 1 + ) + ) + ) + ) + (a1-6 (/ (-> (the-as (array int32) v1-0) 1) 8)) + (a2-14 (-> (the-as (pointer int64) a0-8) (/ a1-6 64))) + (a0-11 (logtest? a2-14 (ash 1 (logand a1-6 63)))) + (s4-0 (if a0-11 + (-> (the-as (pointer int32) v1-0) 6) + (-> (the-as (pointer int32) v1-0) 5) + ) + ) + ) + (if a0-11 + (set! (-> arg2 r-g-b-a x) (rand-vu-float-range 64.0 192.0)) + (set! (-> arg2 r-g-b-a x) (rand-vu-float-range 32.0 48.0)) ) - (set! f0-2 (the-as none (l.f (+ a2-0 32)))) - (s.f! (+ a2-0 36) f0-2) - (set! f0-3 (the-as none (l.f (+ a2-0 32)))) - (s.f! (+ a2-0 40) f0-3) - (nonzero? s4-0) - ) - (set! t9-2 (the-as none particle-adgif-callback)) - (set! a0-14 (the-as none (l.wu (+ a1-0 4)))) - (set! a1-13 (the-as none s4-0)) - (call!) - (set! a2-16 (the-as none v0-2)) + (set! (-> arg2 r-g-b-a y) (-> arg2 r-g-b-a x)) + (set! (-> arg2 r-g-b-a z) (-> arg2 r-g-b-a x)) + (if (nonzero? s4-0) + (particle-adgif-callback (-> arg1 adgif) (the-as texture-id s4-0)) + ) + ) + ) ) ) ) - (set! v0-3 (the-as none 0)) - (ret-none) + 0 + (none) ) ;; definition for function sparticle-motion-blur -;; INFO: Used lq/sq -;; WARN: Return type mismatch int vs none. -;; ERROR: Expression building failed: In sparticle-motion-blur: [OP: 78] - Floating point math attempted on invalid types: uint and float in op (-.s f2-0 f3-0). -;; ERROR: Inline assembly instruction marked with TODO - [TODO.VCLIP] -;; ERROR: Unsupported inline assembly instruction kind - [cfc2.i v1, Clipping] -;; ERROR: Inline assembly instruction marked with TODO - [TODO.VCLIP] -;; ERROR: Unsupported inline assembly instruction kind - [cfc2.i v1, Clipping] -;; ERROR: Unsupported inline assembly instruction kind - [mula.s f3, f3] -;; ERROR: Unsupported inline assembly instruction kind - [madd.s f3, f4, f4] -;; ERROR: Unsupported inline assembly instruction kind - [mula.s f0, f3] -;; ERROR: Unsupported inline assembly instruction kind - [madd.s f0, f2, f5] -(defun sparticle-motion-blur ((arg0 sparticle-system) (arg1 sparticle-cpuinfo) (arg2 vector)) - (local-vars - (v0-0 float) - (v0-1 int) - (v1-0 math-camera) - (v1-1 int) - (v1-2 int) - (v1-3 int) - (v1-4 int) - (v1-5 float) - (a0-1 int) - (a0-2 uint128) - (a0-3 int) - (a0-4 float) - (a0-5 float) - (a0-6 uint) - (a0-7 float) - (a0-8 int) - (a1-1 int) - (a1-2 uint128) - (a1-3 uint128) - (a1-4 uint) - (a1-5 float) - (a1-6 float) - (a1-7 int) - (a2-1 uint128) - (a2-2 uint128) - (a2-3 float) - (s4-0 float) - (s5-0 uint) - (t9-0 (function float float float)) - (f0-0 float) - (f0-1 float) - (f0-2 float) - (f0-3 float) - (f0-4 float) - (f0-5 float) - (f0-6 float) - (f0-7 float) - (f0-8 float) - (f1-0 float) - (f1-1 float) - (f1-2 float) - (f1-3 float) - (f2-0 uint) - (f2-1 float) - (f2-2 float) - (f2-3 float) - (f2-4 float) - (f3-0 float) - (f3-1 float) - (f3-2 float) - (f3-3 float) - (f3-4 int) - (f4-0 float) - (f4-1 uint) - (f4-2 float) - (f5-0 int) - ) - (rlet ((acc :class vf) - (Q :class vf) - (vf0 :class vf) - (vf1 :class vf) - (vf10 :class vf) - (vf11 :class vf) - (vf12 :class vf) - (vf13 :class vf) - (vf2 :class vf) - (vf24 :class vf) - (vf25 :class vf) - (vf26 :class vf) - (vf27 :class vf) - (vf29 :class vf) - (vf3 :class vf) - (vf30 :class vf) - (vf4 :class vf) - (vf5 :class vf) - (vf6 :class vf) - (vf7 :class vf) - (vf8 :class vf) - (vf9 :class vf) - ) - (init-vf0-vector) - (set! a0-1 #xffff) - (set! v1-0 *math-camera*) - (set! a1-1 (shl a0-1 48)) - (set! a0-2 (-> arg1 vel-sxvel quad)) - (.lvf vf1 (&-> arg2 quad)) - (.pceqw a2-1 a0-2 0) - (.lvf vf24 (&-> v1-0 camera-temp vector 0 quad)) - (.ppach a2-2 (the-as uint128 0) a2-1) - (.lvf vf25 (&-> v1-0 camera-temp vector 1 quad)) - (set! a1-2 (logior a2-2 a1-1)) - (.lvf vf26 (&-> v1-0 camera-temp vector 2 quad)) - (set! a1-3 (+ a1-2 1)) - (.lvf vf27 (&-> v1-0 camera-temp trans quad)) - ((b! (zero? a1-3) L36 (.qmtc2.i vf4 a0-2)) (.mov vf4 a0-2)) - (set! a0-3 #x42000000) - (.lvf vf30 (&-> v1-0 hvdf-off quad)) - (.lvf vf29 (&-> v1-0 hmge-scale quad)) - (.mul.x.vf acc vf24 vf1) - (.add.mul.y.vf acc vf25 vf1 acc) - (.add.mul.z.vf acc vf26 vf1 acc) - (.add.mul.w.vf vf10 vf27 vf0 acc) - (.mov vf5 a0-3) - (.mul.vf vf12 vf10 vf29) - (.mul.w.vf acc vf1 vf0) - (.add.mul.x.vf vf1 vf4 vf5 acc) - (.div.vf Q vf0 vf12 :fsf #b11 :ftf #b11) - (TODO.VCLIP vf12 vf12) - (.mul.x.vf acc vf24 vf1) - (.add.mul.y.vf acc vf25 vf1 acc) - (.add.mul.z.vf acc vf26 vf1 acc) - (.add.mul.w.vf vf11 vf27 vf0 acc) - (.wait.vf) - (.cfc2.i v1-1 Clipping) - (.mul.vf vf10 vf10 Q :mask #b111) - (.mul.vf vf13 vf11 vf29) - (set! v1-2 (logand v1-1 63)) - ((b! (nonzero? v1-2) L36 (.vadd.xyzw vf10 vf10 vf30)) (.add.vf vf10 vf10 vf30)) - (.div.vf Q vf0 vf13 :fsf #b11 :ftf #b11) - (TODO.VCLIP vf13 vf13) - (.max.x.vf vf10 vf10 vf0 :mask #b1000) - (vftoi4.xyzw vf2 vf10) - (.wait.vf) - (.mul.vf vf11 vf11 Q :mask #b111) - (.cfc2.i v1-3 Clipping) - (.itof.vf vf6 vf2) - (.add.vf vf11 vf11 vf30) - (set! v1-4 (logand v1-3 63)) - ((b! (nonzero? v1-4) L36 (.vdiv Q vf0 .w vf6 .z)) (.div.vf Q vf0 vf6 :fsf #b11 :ftf #b10)) - (.max.x.vf vf11 vf11 vf0 :mask #b1000) - (.add.w.vf vf9 vf0 vf0 :mask #b1) - (vftoi4.xyzw vf3 vf11) - (.itof.vf vf7 vf3) - (.sub.vf vf8 vf7 vf6 :mask #b11) - (.mov s4-0 vf8) - (set! s5-0 (sar (the-as int s4-0) 32)) - (.mul.vf vf9 vf9 Q :mask #b1) - (set! t9-0 atan) - (set! a0-4 s4-0) - (set! a1-4 s5-0) - (set! v0-0 (atan s4-0 (the-as float s5-0))) - (set! a0-5 v0-0) - (set! v1-5 (-> arg1 omega)) - (set! a1-5 -16384.0) - (set! f0-0 -16384.0) - (set! f1-0 a0-5) - (set! f0-1 (+ -16384.0 a0-5)) - (s.f! (+ arg2 24) f0-1) - ((b! (zero? v1-5) L37 (.qmfc2.i a0-6 vf9)) (.mov a0-6 vf9)) - (set! f2-0 (gpr->fpr a0-6)) - (set! a0-7 1.0) - (set! f1-1 0.0) - (set! a1-6 0.000001) - (set! a2-3 0.00000014285715) - (set! f0-2 a0-7) - (set! f3-0 a1-6) - (set! f4-0 a2-3) - (set! f2-1 (-.s f2-0 f3-0)) - (set! f3-1 (-.s f4-0 f3-0)) - (set! f2-2 (/.s f2-1 f3-1)) - (set! f3-2 (gpr->fpr s4-0)) - (set! f4-1 (gpr->fpr s5-0)) - (.mula.s f3-2 f3-2) - (.madd.s f3-3 f4-1 f4-1) - (set! f2-3 (max.s f2-2 f1-1)) - (set! f1-2 (sqrt.s f3-3)) - (set! f2-4 (min.s f2-3 f0-2)) - (set! a0-8 #x40400000) - (set! f0-3 (-.s f0-2 f2-4)) - (set! a1-7 #x3e800000) - (set! f3-4 (gpr->fpr a0-8)) - (set! f5-0 (gpr->fpr a1-7)) - (set! f4-2 (gpr->fpr v1-5)) - (.mula.s f0-3 f3-4) - (.madd.s f0-4 f2-4 f5-0) - (set! f0-5 (*.s f0-4 f1-2)) - (set! f0-6 (*.s f0-5 f4-2)) - ((b! #t L37 (s.f! (+ arg2 12) f0-6)) (set! (-> arg2 w) f0-6)) - (when (begin (label cfg-5) (set! f0-7 (-> arg1 omega)) (set! f1-3 0.0) (!=.s f0-7 f1-3)) - (set! f0-8 0.0) - (set! (-> arg2 w) f0-8) - (set! v1-7 (fpr->gpr f0-8)) - ) - (label cfg-7) - (set! v0-1 0) - (ret-none) - ) - ) +;; ERROR: function was not converted to expressions. Cannot decompile. ;; definition (debug) for function sparticle-motion-blur-old ;; WARN: Return type mismatch int vs object. @@ -3152,11 +2328,13 @@ ;; definition for function birth-func-texture-group ;; WARN: Return type mismatch int vs none. (defun birth-func-texture-group ((arg0 int) (arg1 sparticle-cpuinfo) (arg2 sparticle-launchinfo)) - (let ((s5-0 (the-as object (-> arg1 user-float)))) - (when (nonzero? (the-as float s5-0)) - (let ((a0-1 (+ (-> (the-as (pointer int32) s5-0) 0) -3))) - (if (nonzero? (l.w (+ (* (+ (rand-vu-int-count a0-1) 3) 4) (the-as int s5-0) 12))) - (particle-adgif-callback (-> arg1 adgif)) + (let ((s5-0 (the-as (array int32) (-> arg1 user-float)))) + (when (nonzero? s5-0) + (let* ((a0-1 (+ (-> s5-0 length) -3)) + (a1-1 (-> s5-0 (+ (rand-vu-int-count a0-1) 3))) + ) + (if (nonzero? a1-1) + (particle-adgif-callback (-> arg1 adgif) (the-as texture-id a1-1)) ) ) ) @@ -3190,140 +2368,38 @@ ) ;; definition for method 10 of type sparticle-launcher -;; ERROR: failed type prop at 45: Could not figure out load: (set! v1 (l.w (+ gp 12))) -(defmethod sparticle-launcher-method-10 sparticle-launcher ((a0-0 sparticle-launcher) (a1-0 string)) - (local-vars - (v0-0 sp-field-init-spec) - (v0-1 texture-id) - (v0-2 sp-field-init-spec) - (v0-3 symbol) - (v0-4 none) - (v0-5 none) - (v1-0 type) - (v1-1 texture-id) - (v1-2 type) - (v1-3 sp-field-init-spec) - (v1-4 int) - (v1-5 int) - (v1-6 symbol) - (v1-7 symbol) - (v1-8 none) - (v1-9 none) - (v1-10 none) - (v1-11 none) - (v1-12 none) - (v1-13 none) - (v1-14 none) - (v1-15 none) - (v1-16 none) - (v1-17 none) - (v1-18 none) - (v1-19 none) - (v1-20 none) - (v1-21 none) - (v1-22 none) - (v1-23 none) - (a0-1 sparticle-launcher) - (a0-2 string) - (a0-5 sparticle-launcher) - (a0-6 symbol) - (a0-7 sp-flag) - (a0-9 symbol) - (a0-10 float) - (a0-11 float) - (a0-12 int) - (a0-14 none) - (a1-1 int) - (a1-2 symbol) - (a1-3 int) - (a1-4 sp-flag) - (a1-5 type) - (s5-0 sp-field-init-spec) - (s5-1 none) - (t9-0 (function sparticle-launcher sp-field-id sp-field-init-spec)) - (t9-1 (function string string texture-id)) - (t9-2 (function sparticle-launcher sp-field-id sp-field-init-spec)) - (t9-3 (function object type symbol)) - (t9-4 none) - (gp-1 object) +;; WARN: Return type mismatch int vs none. +(defmethod setup-user-array sparticle-launcher ((obj sparticle-launcher) (arg0 string)) + (let ((s5-0 (get-field-spec-by-id obj (sp-field-id spt-texture))) + (v1-1 (lookup-texture-id-by-name arg0 (the-as string #f))) + ) + (if s5-0 + (set! (-> s5-0 initial-valuef) (the-as float v1-1)) + ) ) - (when (begin - (when (begin - (set! a0-1 a0-0) - (set! v1-0 (-> a0-1 type)) - (set! t9-0 (method-of-type v1-0 get-field-spec-by-id)) - (set! a1-1 1) - (set! v0-0 (call! a0-1 a1-1)) - (set! s5-0 v0-0) - (set! t9-1 lookup-texture-id-by-name) - (set! a1-2 #f) - (set! a0-2 a1-0) - (set! v0-1 (call! a0-2 a1-2)) - (set! v1-1 v0-1) - s5-0 + (let ((v1-3 (get-field-spec-by-id obj (sp-field-id spt-userdata)))) + (when (and v1-3 (= (-> v1-3 flags) (sp-flag plain-v2))) + (let ((gp-1 (the-as object (-> v1-3 initial-valuef)))) + (when (and (= (logand (the-as int gp-1) 7) 4) + (type? (the-as float gp-1) array) + (logtest? (-> (the-as (array int32) gp-1) 1) 128) + ) + (set! (-> (the-as (array int32) gp-1) 0) (/ (-> (the-as (array int32) gp-1) 0) 8)) + (set! (-> (the-as (array int32) gp-1) 1) (/ (logand (-> (the-as (array int32) gp-1) 1) 8) 8)) + (set! (-> (the-as (array int32) gp-1) 2) (/ (-> (the-as (array int32) gp-1) 2) 8)) + (set! (-> (the-as (array int32) gp-1) content-type) int32) + (dotimes (s5-1 (+ (-> (the-as (array int32) gp-1) length) -3)) + (set! (-> (the-as (array int32) gp-1) (+ s5-1 3)) + (the-as + int + (lookup-texture-id-by-name (the-as string (-> (the-as (array int32) gp-1) (+ s5-1 3))) (the-as string #f)) + ) ) - (set! (-> s5-0 initial-valuef) (the-as float v1-1)) - (set! a0-4 v1-1) ) - (and (begin - (set! v1-2 (-> a0-0 type)) - (set! t9-2 (method-of-type v1-2 get-field-spec-by-id)) - (set! a1-3 48) - (set! a0-5 a0-0) - (set! v0-2 (call! a0-5 a1-3)) - (set! v1-3 v0-2) - v1-3 - ) - (begin (set! a0-7 (-> v1-3 flags)) (set! a1-4 (+ a0-7 -4)) (set! a0-6 (zero? a1-4))) - ) - a0-6 ) - (when (begin - (and (begin - (set! gp-1 (-> v1-3 initial-valuef)) - (set! v1-4 (logand gp-1 7)) - (set! v1-5 (+ v1-4 -4)) - (set! a0-9 (zero? v1-5)) - a0-9 - ) - (begin (set! t9-3 type?) (set! a0-10 gp-1) (set! a1-5 array) (set! v0-3 (call! a0-10 a1-5)) v0-3) - (begin - (set! v1-7 #t) - (set! a0-11 (-> gp-1 1)) - (set! a0-12 (logand a0-11 128)) - (cmove-#f-zero v1-6 a0-12 v1-7) - ) - ) - v1-6 - ) - (set! v1-8 (the-as none (l.w (+ gp-1 12)))) - (set! v1-9 (the-as none (sra v1-8 3))) - (s.w! (+ gp-1 12) v1-9) - (set! v1-10 (the-as none (l.w (+ gp-1 16)))) - (set! v1-11 (the-as none (logand v1-10 8))) - (set! v1-12 (the-as none (sra v1-11 3))) - (s.w! (+ gp-1 16) v1-12) - (set! v1-13 (the-as none (l.w (+ gp-1 20)))) - (set! v1-14 (the-as none (sra v1-13 3))) - (s.w! (+ gp-1 20) v1-14) - (set! v1-15 (the-as none int32)) - (s.w! (+ gp-1 8) v1-15) - (set! s5-1 (the-as none 0)) - (while (begin (set! v1-22 (the-as none (l.w gp-1))) (set! v1-23 (the-as none (+ v1-22 -3))) (<.si s5-1 v1-23)) - (set! t9-4 (the-as none lookup-texture-id-by-name)) - (set! v1-16 (the-as none (+ s5-1 3))) - (set! v1-17 (the-as none (sll v1-16 2))) - (set! v1-18 (the-as none (+ v1-17 gp-1))) - (set! a0-14 (the-as none (l.w (+ v1-18 12)))) - (set! v0-4 (the-as none (call!))) - (set! v1-19 (the-as none (+ s5-1 3))) - (set! v1-20 (the-as none (sll v1-19 2))) - (set! v1-21 (the-as none (+ v1-20 gp-1))) - (s.w! (+ v1-21 12) v0-4) - (set! s5-1 (the-as none (+ s5-1 1))) ) ) ) - (set! v0-5 (the-as none 0)) - (ret-none) + 0 + (none) ) diff --git a/test/decompiler/reference/jak2/engine/gfx/sprite/sprite_REF.gc b/test/decompiler/reference/jak2/engine/gfx/sprite/sprite_REF.gc index 3eb1e49299..fa5c836f95 100644 --- a/test/decompiler/reference/jak2/engine/gfx/sprite/sprite_REF.gc +++ b/test/decompiler/reference/jak2/engine/gfx/sprite/sprite_REF.gc @@ -894,7 +894,7 @@ ) (dma-bucket-insert-tag (-> *display* frames (-> *display* on-screen) bucket-group) - (bucket-id bucket-313) + (bucket-id particles) dma-bucket-begin (the-as (pointer dma-tag) a3-0) )