From b2b47eec5cd693fd0ae9478bed11ccaca1a76d9a Mon Sep 17 00:00:00 2001 From: water111 <48171810+water111@users.noreply.github.com> Date: Fri, 11 Nov 2022 16:23:26 -0500 Subject: [PATCH] [decomp] `spatial-hash` (#2009) --- decompiler/IR2/FormExpressionAnalysis.cpp | 4 +- decompiler/analysis/mips2c.cpp | 6 + decompiler/config/jak2/all-types.gc | 90 +- .../jak2/anonymous_function_types.jsonc | 3 + decompiler/config/jak2/hacks.jsonc | 22 +- decompiler/config/jak2/stack_structures.jsonc | 7 +- decompiler/config/jak2/type_casts.jsonc | 33 + decompiler/util/data_decompile.cpp | 17 +- game/CMakeLists.txt | 1 + game/mips2c/jak2_functions/spatial_hash.cpp | 2782 +++++++++++++++++ game/mips2c/mips2c_private.h | 20 + game/mips2c/mips2c_table.cpp | 27 +- .../jak2/engine/common_objs/water-anim.gc | 108 +- .../jak2/engine/common_objs/water-flow.gc | 319 +- goal_src/jak2/engine/gfx/lightning.gc | 3 + goal_src/jak2/engine/gfx/merc/merc-death.gc | 154 + .../jak2/engine/spatial-hash/actor-hash.gc | 206 ++ .../engine/spatial-hash/spatial-hash-h.gc | 50 +- .../jak2/engine/spatial-hash/spatial-hash.gc | 899 ++++++ goal_src/jak2/engine/target/target-darkjak.gc | 40 +- .../jak2/engine/common_objs/water-anim_REF.gc | 99 +- .../jak2/engine/common_objs/water-flow_REF.gc | 470 +++ .../jak2/engine/gfx/merc/merc-death_REF.gc | 192 ++ .../engine/spatial-hash/actor-hash_REF.gc | 1328 ++++++++ .../engine/spatial-hash/spatial-hash-h_REF.gc | 50 +- .../engine/spatial-hash/spatial-hash_REF.gc | 951 ++++++ test/offline/config/jak2/config.jsonc | 3 + 27 files changed, 7654 insertions(+), 230 deletions(-) create mode 100644 game/mips2c/jak2_functions/spatial_hash.cpp create mode 100644 test/decompiler/reference/jak2/engine/common_objs/water-flow_REF.gc create mode 100644 test/decompiler/reference/jak2/engine/gfx/merc/merc-death_REF.gc create mode 100644 test/decompiler/reference/jak2/engine/spatial-hash/actor-hash_REF.gc create mode 100644 test/decompiler/reference/jak2/engine/spatial-hash/spatial-hash_REF.gc diff --git a/decompiler/IR2/FormExpressionAnalysis.cpp b/decompiler/IR2/FormExpressionAnalysis.cpp index 215fd30f09..1abd8f4db6 100644 --- a/decompiler/IR2/FormExpressionAnalysis.cpp +++ b/decompiler/IR2/FormExpressionAnalysis.cpp @@ -1092,7 +1092,9 @@ void SimpleExpressionElement::update_from_stack_add_i(const Env& env, result->push_back(pool.alloc_element(args.at(1), out.addr_of, tokens)); return; } else { - throw std::runtime_error("Failed to match for stride 1 address access with add."); + throw std::runtime_error( + fmt::format("Failed to match for stride 1 address access with add: {}", + args.at(0)->to_string(env))); } } } else if (arg0_type.kind == TP_Type::Kind::INTEGER_CONSTANT_PLUS_VAR_MULT) { diff --git a/decompiler/analysis/mips2c.cpp b/decompiler/analysis/mips2c.cpp index 4d4c532fed..fb1eeabfea 100644 --- a/decompiler/analysis/mips2c.cpp +++ b/decompiler/analysis/mips2c.cpp @@ -1034,6 +1034,8 @@ Mips2C_Line handle_normal_instr(Mips2C_Output& output, return handle_generic_op2_mask(i0, instr_str, "vabs"); case InstructionKind::VADDQ: return handle_generic_op2_mask(i0, instr_str, "vaddq"); + case InstructionKind::VMR32: + return handle_generic_op2_mask(i0, instr_str, "vmr32"); case InstructionKind::ANDI: case InstructionKind::ORI: case InstructionKind::XORI: @@ -1108,6 +1110,8 @@ Mips2C_Line handle_normal_instr(Mips2C_Output& output, return handle_generic_op3(i0, instr_str, "xor_"); case InstructionKind::AND: return handle_generic_op3(i0, instr_str, "and_"); // and isn't allowed in C++ + case InstructionKind::NOR: + return handle_generic_op3(i0, instr_str, "nor"); // and isn't allowed in C++ case InstructionKind::DADDIU: return handle_daddiu(output, i0, instr_str, version); case InstructionKind::ADDIU: @@ -1159,6 +1163,8 @@ Mips2C_Line handle_normal_instr(Mips2C_Output& output, return handle_generic_op2(i0, instr_str, "mtc1"); case InstructionKind::NEGS: return handle_generic_op2(i0, instr_str, "negs"); + case InstructionKind::ABSS: + return handle_generic_op2(i0, instr_str, "abss"); case InstructionKind::MOVS: return handle_generic_op2(i0, instr_str, "movs"); case InstructionKind::CVTWS: diff --git a/decompiler/config/jak2/all-types.gc b/decompiler/config/jak2/all-types.gc index 0bbcd5c8b5..45677ceac0 100644 --- a/decompiler/config/jak2/all-types.gc +++ b/decompiler/config/jak2/all-types.gc @@ -22541,7 +22541,7 @@ ((work grid-hash-work :offset-assert 4) (search-box grid-hash-box :inline :offset-assert 8) (bucket-size int16 :offset-assert 14) - (axis-scale uint32 3 :offset-assert 16) + (axis-scale float 3 :offset-assert 16) (dimension-array int8 3 :offset-assert 28) (vertical-cell-count int8 :offset-assert 31) (bucket-array (pointer grid-hash-word) :offset-assert 32) @@ -22560,24 +22560,24 @@ :size-assert #x58 :flag-assert #x1900000058 (:methods - (new (symbol type process int) _type_ 0) - (grid-hash-method-9 (_type_ int (array float) int) none 9) - (grid-hash-method-10 (_type_) none 10) - (grid-hash-method-11 (_type_) none 11) - (grid-hash-method-12 (_type_ vector) grid-hash-box 12) - (grid-hash-method-13 (_type_ vector float) grid-hash-box 13) - (draw-grid "Draws the grid-hash" (_type_ rgba) none 14) + (new (symbol type int int) _type_ 0) + (update-grid-for-objects-in-box (_type_ int vector vector) none 9) + (clear-bucket-array (_type_) none 10) + (setup-search-box (_type_ int vector vector vector) none 11) + (search-for-point (_type_ vector) (pointer uint8) 12) + (search-for-sphere (_type_ vector float) (pointer uint8) 13) + (draw "Draws the grid-hash" (_type_ rgba) none 14) (dump-grid-info "Prints out info about the grid-hash, also draws via [[grid-hash::draw-grid]] if `debug-draw` is `#t`" (_type_) none 15) - (grid-hash-method-16 (_type_ grid-hash-box grid-hash-box) none 16) - (grid-hash-method-17 (_type_) none 17) + (verify-bits-in-bucket (_type_ grid-hash-box grid-hash-box) none 16) + (box-of-everything (_type_ object grid-hash-box) none 17) (grid-hash-method-18 (_type_ grid-hash-box int) none 18) (grid-hash-method-19 (_type_ grid-hash-box int) none 19) - (grid-hash-method-20 (_type_ grid-hash-box (pointer uint8)) none 20) - (grid-hash-method-21 (_type_ float int int) none 21) - (grid-hash-method-22 (_type_ grid-hash-box sphere) none 22) - (grid-hash-method-23 (_type_ grid-hash-box vector vector float) none 23) + (do-search! (_type_ grid-hash-box (pointer uint8)) none 20) + (set-up-box (_type_ grid-hash-box vector vector) none 21) + (sphere-to-grid-box (_type_ grid-hash-box sphere) none 22) + (line-sphere-to-grid-box (_type_ grid-hash-box vector vector float) none 23) (update-grid (_type_) none 24) ) ) @@ -22606,15 +22606,16 @@ :size-assert #x68 :flag-assert #x2200000068 (:methods + (new (symbol type int int) _type_ 0) (clear-objects! (_type_) none 25) - (sphere-hash-method-26 (_type_ vector) none 26) - (sphere-hash-method-27 (_type_) none 27) - (sphere-hash-method-28 (_type_) none 28) + (add-a-sphere (_type_ vector) int 26) + (add-a-sphere-with-flag (_type_ vector int) int 27) + (update-from-spheres (_type_) none 28) (sphere-hash-method-29 (_type_ find-nav-sphere-ids-params int int int) none 29) (sphere-hash-method-30 (_type_ find-nav-sphere-ids-params) none 30) (sphere-hash-method-31 (_type_ vector int int) none 31) (sphere-hash-method-32 (_type_ vector vector float int) symbol 32) - (sphere-hash-method-33 (_type_ object int) none 33) + (sphere-hash-method-33 (_type_ sphere int) none 33) ) ) @@ -22627,21 +22628,22 @@ ) (deftype spatial-hash (sphere-hash) - ((object-array (pointer hash-object-info) :offset-assert 104) - (mem-object-array (pointer hash-object-info) :offset-assert 108) - (spr-object-array (pointer hash-object-info) :offset-assert 112) + ((object-array (inline-array hash-object-info) :offset-assert 104) + (mem-object-array (inline-array hash-object-info) :offset-assert 108) + (spr-object-array (inline-array hash-object-info) :offset-assert 112) ) :method-count-assert 41 :size-assert #x74 :flag-assert #x2900000074 (:methods - (spatial-hash-method-34 (_type_ vector hash-object-info) int 34) + (new (symbol type int int) _type_ 0) + (add-an-object (_type_ vector hash-object-info) int 34) (spatial-hash-method-35 (_type_) none 35) (fill-actor-list-for-sphere (_type_ sphere (pointer collide-shape) int) int 36) (spatial-hash-method-37 (_type_) none 37) - (spatial-hash-method-38 (_type_) none 38) + (fill-actor-list-for-vec+r (_type_ vector (pointer collide-shape) int) none 38) (spatial-hash-method-39 (_type_ object hash-object-info) none 39) - (spatial-hash-method-40 (_type_) none 40) + (validate-objects (_type_) none 40) ) ) @@ -26462,7 +26464,7 @@ (define-extern *grid-hash-work* grid-hash-work) (define-extern validate-bucket-bits (function grid-hash (pointer grid-hash-word) symbol)) (define-extern draw-grid (function vector vector (pointer int8) rgba none)) -(define-extern draw-sphere-box (function sphere none)) +(define-extern draw-sphere-box (function sphere rgba none)) (define-extern draw-line-sphere (function vector vector float rgba none)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -26480,20 +26482,20 @@ (deftype actor-hash-bucket (structure) ((length int16 :offset-assert 0) (max-length int16 :offset-assert 2) - (data (pointer uint32) :offset-assert 4) ;; an array of....something TODO + (data (inline-array actor-cshape-ptr) :offset-assert 4) ;; an array of....something TODO ) :allow-misaligned :method-count-assert 10 :size-assert #x8 :flag-assert #xa00000008 (:methods - (actor-hash-bucket-method-9 () none 9) + (add-actor-cshape (_type_ collide-shape) none 9) ) ) (deftype actor-hash-buckets (structure) - ((hash basic :offset-assert 0) - (list basic :offset-assert 4) + ((hash spatial-hash :offset-assert 0) + (list engine :offset-assert 4) (data actor-hash-bucket 4 :inline :offset-assert 8) (tpos vector :inline :offset-assert 80) ) @@ -26501,7 +26503,7 @@ :size-assert #x60 :flag-assert #xa00000060 (:methods - (actor-hash-buckets-method-9 () none 9) + (hash-actors (_type_) none 9) ) ) @@ -26513,7 +26515,6 @@ ;; merc-death ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype death-info (basic) ((vertex-skip uint16 :offset-assert 4) (timer uint8 :offset-assert 6) @@ -26525,17 +26526,16 @@ :size-assert #x10 :flag-assert #x900000010 ) -|# -;; (define-extern *merc-death-globals* object) ;; vector -;; (define-extern birth-func-death-sparks function) ;; (function none) -;; (define-extern death-seed death-info) -;; (define-extern start-seed-effect function) -;; (define-extern death-default death-info) ;; death-info -;; (define-extern death-warp-in death-info) ;; death-info -;; (define-extern death-warp-out death-info) ;; death-info -;; (define-extern sparticle-texture-glow-soft function) -;; (define-extern merc-death-spawn function) ;; (function int vector vector none) +(define-extern *merc-death-globals* vector) +(define-extern birth-func-death-sparks (function none)) +(define-extern death-seed death-info) +(define-extern start-seed-effect (function process-drawable vector cspace none)) +(define-extern death-default death-info) +(define-extern death-warp-in death-info) +(define-extern death-warp-out death-info) +(define-extern sparticle-texture-glow-soft (function sparticle-system sparticle-cpuinfo vector none)) +(define-extern merc-death-spawn (function int vector vector none)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; water-flow ;; @@ -26553,7 +26553,7 @@ ) (deftype flow-section-array (inline-array-class) - ((data flow-section :dynamic :offset-assert 16) + ((data flow-section :inline :dynamic :offset-assert 16) ) :method-count-assert 9 :size-assert #x10 @@ -26574,9 +26574,9 @@ (:methods (new (symbol type process-drawable res-lump) _type_ 0) (draw-path (_type_) none 9) - (flow-control-method-10 () none 10) - (flow-control-method-11 () none 11) - (flow-control-method-12 () none 12) + (setup (_type_) none 10) + (push-process (_type_ process-focusable) none 11) + (find-and-push-things (_type_) none 12) ) ) diff --git a/decompiler/config/jak2/anonymous_function_types.jsonc b/decompiler/config/jak2/anonymous_function_types.jsonc index 334a5ad92a..5ea022764e 100644 --- a/decompiler/config/jak2/anonymous_function_types.jsonc +++ b/decompiler/config/jak2/anonymous_function_types.jsonc @@ -454,5 +454,8 @@ ], "crimson-guard-level": [ [28, "(function crimson-guard-level collide-shape-moving vector symbol)"] + ], + "merc-death": [ + [3, "(function none :behavior process-drawable)"] ] } diff --git a/decompiler/config/jak2/hacks.jsonc b/decompiler/config/jak2/hacks.jsonc index 1ba7938340..b9fe59ced3 100644 --- a/decompiler/config/jak2/hacks.jsonc +++ b/decompiler/config/jak2/hacks.jsonc @@ -385,7 +385,9 @@ "(method 12 collide-shape-prim-group)": [1, 2, 3, 4, 5, 6], "(method 13 collide-shape-prim)": [1, 2, 3, 4, 5, 6], "(method 12 collide-shape-prim-sphere)": [1, 2, 3, 4, 5, 8, 10, 11, 13, 14, 15], - "(method 12 collide-shape-prim-mesh)": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 14, 15, 16] + "(method 12 collide-shape-prim-mesh)": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 14, 15, 16], + "(method 24 grid-hash)": [39, 35, 22, 15], + "(method 12 flow-control)": [11, 12, 13, 14, 15, 18, 20, 22, 29] }, // Sometimes the game might use format strings that are fetched dynamically, @@ -466,7 +468,23 @@ "init-ocean-far-regs", "(method 14 ocean)", "(method 15 ocean)", - "(method 16 ocean)" + "(method 16 ocean)", + "(method 18 grid-hash)", + "(method 19 grid-hash)", + "(method 20 grid-hash)", + "(method 22 grid-hash)", + "(method 28 sphere-hash)", + "(method 33 sphere-hash)", + "(method 29 sphere-hash)", + "(method 30 sphere-hash)", + "(method 31 sphere-hash)", + "(method 32 sphere-hash)", + "(method 33 spatial-hash)", + "(method 39 spatial-hash)", + "(method 36 spatial-hash)", + "(method 37 spatial-hash)", + "(method 35 spatial-hash)" + ], "mips2c_jump_table_functions": {}, diff --git a/decompiler/config/jak2/stack_structures.jsonc b/decompiler/config/jak2/stack_structures.jsonc index 479e8457cb..00fac61cb0 100644 --- a/decompiler/config/jak2/stack_structures.jsonc +++ b/decompiler/config/jak2/stack_structures.jsonc @@ -1185,5 +1185,10 @@ [32, "vector"] ], "spawn-metalhead-grenade": [[16, "projectile-init-by-other-params"]], - "spawn-metalhead-projectile": [[16, "projectile-init-by-other-params"]] + "spawn-metalhead-projectile": [[16, "projectile-init-by-other-params"]], + "(method 24 grid-hash)": [[16, "vector"]], + "(method 11 grid-hash)": [ + [16, "vector"], [32, "vector"] + ], + "(method 11 flow-control)": [[80, "vector"], [128, "vector"]] } diff --git a/decompiler/config/jak2/type_casts.jsonc b/decompiler/config/jak2/type_casts.jsonc index fe8302d59a..af23ef39e9 100644 --- a/decompiler/config/jak2/type_casts.jsonc +++ b/decompiler/config/jak2/type_casts.jsonc @@ -4672,5 +4672,38 @@ [267, "v1", "art-joint-anim"], [366, "v1", "art-joint-anim"], [463, "v1", "art-joint-anim"] + ], + "(method 10 grid-hash)": [ + [12, "a0", "(pointer uint128)"] + ], + "(method 24 grid-hash)": [ + [78, "v1", "(pointer uint128)"], + [191, "t0", "(pointer int8)"], + [195, "a2", "(pointer uint8)"], + [237, "v1", "(pointer uint128)"] + ], + "(method 11 grid-hash)": [ + [[141, 147], "t6", "pointer"], + [128, "t1", "pointer"], + [149, "t4", "pointer"], + [152, "t1", "pointer"] + ], + "(method 27 sphere-hash)": [ + [44, "s2", "(pointer int8)"] + ], + "(method 9 actor-hash-buckets)": [ + [19, "v1", "connection"], + [[16, 160], "s4", "collide-shape"], + [76, "s4", "collide-shape"], + [108, "v1", "connection"] + ], + "(method 12 flow-control)": [ + [23, "a0", "connection"], + [24, "a0", "collide-shape"], + [71, "a0", "connection"], + [72, "a0", "collide-shape"] + ], + "(method 10 flow-control)": [ + ["_stack_", 32, "flow-section"] ] } diff --git a/decompiler/util/data_decompile.cpp b/decompiler/util/data_decompile.cpp index 31deb6cd68..c7d05d6536 100644 --- a/decompiler/util/data_decompile.cpp +++ b/decompiler/util/data_decompile.cpp @@ -290,6 +290,12 @@ goos::Object decompile_value_array(const TypeSpec& elt_type, for (int j = start; j < end; j++) { auto& word = obj_words.at(j / 4); if (word.kind() != LinkedWord::PLAIN_DATA) { + if (word.kind() == LinkedWord::TYPE_PTR) { + throw std::runtime_error( + fmt::format("Got bad word in kind in array of values: expecting array of {}'s, got a " + "type pointer {}\n", + elt_type.print(), word.symbol_name())); + } throw std::runtime_error(fmt::format( "Got bad word in kind in array of values: expecting array of {}'s, got a {}\n", elt_type.print(), (int)word.kind())); @@ -426,6 +432,11 @@ goos::Object decomp_ref_to_integer_array_guess_size( } } + // if we end exactly on a type_ptr, take off an element. + if (all_words.at(my_seg).at((end_offset - 1) / 4).kind() == LinkedWord::TYPE_PTR) { + size_elts--; + } + return decompile_value_array(array_elt_type, elt_type_info, size_elts, stride, start_label.offset, all_words.at(start_label.target_segment), ts); } @@ -726,9 +737,9 @@ const std::unordered_map< {"racer-array", ArrayFieldDecompMeta(TypeSpec("race-racer-info"), 16)}, {"decision-point-array", ArrayFieldDecompMeta(TypeSpec("race-decision-point"), 16)}}}, {"actor-hash-bucket", - {{"data", ArrayFieldDecompMeta(TypeSpec("uint32"), - 4, - ArrayFieldDecompMeta::Kind::REF_TO_INTEGER_ARR)}}}, + {{"data", ArrayFieldDecompMeta(TypeSpec("actor-cshape-ptr"), + 16, + ArrayFieldDecompMeta::Kind::REF_TO_INLINE_ARR)}}}, {"xz-height-map", {{"data", ArrayFieldDecompMeta(TypeSpec("int8"), 1, diff --git a/game/CMakeLists.txt b/game/CMakeLists.txt index 8e293798e5..10e4527742 100644 --- a/game/CMakeLists.txt +++ b/game/CMakeLists.txt @@ -92,6 +92,7 @@ set(RUNTIME_SOURCE mips2c/jak2_functions/sky.cpp mips2c/jak2_functions/sparticle.cpp mips2c/jak2_functions/sparticle_launcher.cpp + mips2c/jak2_functions/spatial_hash.cpp mips2c/jak2_functions/texture.cpp mips2c/jak2_functions/ocean.cpp mips2c/jak2_functions/ocean_vu0.cpp diff --git a/game/mips2c/jak2_functions/spatial_hash.cpp b/game/mips2c/jak2_functions/spatial_hash.cpp new file mode 100644 index 0000000000..a41af0f0d9 --- /dev/null +++ b/game/mips2c/jak2_functions/spatial_hash.cpp @@ -0,0 +1,2782 @@ +//--------------------------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 method_18_grid_hash { +u64 execute(void* ctxt) { + auto* c = (ExecutionContext*)ctxt; + bool bc = false; + u32 call_addr = 0; + c->lh(v1, 10, a0); // lh v1, 10(a0) + c->lb(a3, 24, a0); // lb a3, 24(a0) + c->mult3(a3, a3, v1); // mult3 a3, a3, v1 + c->lb(t0, 26, a0); // lb t0, 26(a0) + c->mult3(t0, t0, a3); // mult3 t0, t0, a3 + c->addiu(t1, r0, 1); // addiu t1, r0, 1 + c->lb(t2, 0, a1); // lb t2, 0(a1) + c->dsubu(t1, t1, t2); // dsubu t1, t1, t2 + c->lb(t2, 3, a1); // lb t2, 3(a1) + c->daddu(t1, t1, t2); // daddu t1, t1, t2 + c->addiu(t2, r0, 1); // addiu t2, r0, 1 + c->lb(t3, 2, a1); // lb t3, 2(a1) + c->dsubu(t2, t2, t3); // dsubu t2, t2, t3 + c->lb(t3, 5, a1); // lb t3, 5(a1) + c->daddu(t2, t2, t3); // daddu t2, t2, t3 + c->addiu(t3, r0, 1); // addiu t3, r0, 1 + c->lb(t4, 1, a1); // lb t4, 1(a1) + c->dsubu(t3, t3, t4); // dsubu t3, t3, t4 + c->lb(t4, 4, a1); // lb t4, 4(a1) + c->daddu(t3, t3, t4); // daddu t3, t3, t4 + c->lb(t4, 0, a1); // lb t4, 0(a1) + c->mult3(t4, t4, v1); // mult3 t4, t4, v1 + c->lb(t5, 1, a1); // lb t5, 1(a1) + c->mult3(t5, t5, t0); // mult3 t5, t5, t0 + c->daddu(t4, t4, t5); // daddu t4, t4, t5 + c->lb(a1, 2, a1); // lb a1, 2(a1) + c->mult3(a1, a1, a3); // mult3 a1, a1, a3 + c->daddu(a1, t4, a1); // daddu a1, t4, a1 + c->dsra(t4, a2, 3); // dsra t4, a2, 3 + c->daddu(a1, a1, t4); // daddu a1, a1, t4 + c->daddu(a1, r0, a1); // daddu a1, r0, a1 + c->lwu(a0, 28, a0); // lwu a0, 28(a0) + c->daddu(a0, a1, a0); // daddu a0, a1, a0 + c->addiu(a1, r0, 1); // addiu a1, r0, 1 + c->andi(a2, a2, 7); // andi a2, a2, 7 + if (((s64)c->sgpr64(a2)) >= 0) { // bgezl a2, L196 + c->dsllv(a1, a1, a2); // dsllv a1, a1, a2 + goto block_3; + } + + block_2: + c->dsubu(a2, r0, a2); // dsubu a2, r0, a2 + c->dsrav(a1, a1, a2); // dsrav a1, a1, a2 + + block_3: + c->mov64(a2, t3); // or a2, t3, r0 + // nop // sll r0, r0, 0 + + block_4: + c->mov64(t3, t2); // or t3, t2, r0 + c->mov64(t4, a0); // or t4, a0, r0 + + block_5: + c->mov64(t5, t1); // or t5, t1, r0 + c->mov64(t6, t4); // or t6, t4, r0 + + block_6: + // nop // sll r0, r0, 0 + c->lbu(t7, 0, t6); // lbu t7, 0(t6) + // nop // sll r0, r0, 0 + c->or_(t7, t7, a1); // or t7, t7, a1 + c->daddiu(t5, t5, -1); // daddiu t5, t5, -1 + c->sb(t7, 0, t6); // sb t7, 0(t6) + bc = c->sgpr64(t5) != 0; // bne t5, r0, L199 + c->daddu(t6, t6, v1); // daddu t6, t6, v1 + if (bc) {goto block_6;} // branch non-likely + + c->daddiu(t3, t3, -1); // daddiu t3, t3, -1 + // nop // sll r0, r0, 0 + bc = c->sgpr64(t3) != 0; // bne t3, r0, L198 + c->daddu(t4, t4, a3); // daddu t4, t4, a3 + if (bc) {goto block_5;} // branch non-likely + + c->daddiu(a2, a2, -1); // daddiu a2, a2, -1 + // nop // sll r0, r0, 0 + bc = c->sgpr64(a2) != 0; // bne a2, r0, L197 + c->daddu(a0, a0, t0); // daddu a0, a0, t0 + if (bc) {goto block_4;} // branch non-likely + + c->gprs[v0].du64[0] = 0; // or v0, r0, r0 + //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() { + gLinkedFunctionTable.reg("(method 18 grid-hash)", execute, 128); +} + +} // namespace method_18_grid_hash +} // 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 method_19_grid_hash { +u64 execute(void* ctxt) { + auto* c = (ExecutionContext*)ctxt; + bool bc = false; + u32 call_addr = 0; + c->lh(v1, 10, a0); // lh v1, 10(a0) + c->lb(a3, 24, a0); // lb a3, 24(a0) + c->mult3(a3, a3, v1); // mult3 a3, a3, v1 + c->lb(t0, 26, a0); // lb t0, 26(a0) + c->mult3(t0, t0, a3); // mult3 t0, t0, a3 + c->addiu(t1, r0, 1); // addiu t1, r0, 1 + c->lb(t2, 0, a1); // lb t2, 0(a1) + c->dsubu(t1, t1, t2); // dsubu t1, t1, t2 + c->lb(t2, 3, a1); // lb t2, 3(a1) + c->daddu(t1, t1, t2); // daddu t1, t1, t2 + c->addiu(t2, r0, 1); // addiu t2, r0, 1 + c->lb(t3, 2, a1); // lb t3, 2(a1) + c->dsubu(t2, t2, t3); // dsubu t2, t2, t3 + c->lb(t3, 5, a1); // lb t3, 5(a1) + c->daddu(t2, t2, t3); // daddu t2, t2, t3 + c->addiu(t3, r0, 1); // addiu t3, r0, 1 + c->lb(t4, 1, a1); // lb t4, 1(a1) + c->dsubu(t3, t3, t4); // dsubu t3, t3, t4 + c->lb(t4, 4, a1); // lb t4, 4(a1) + c->daddu(t3, t3, t4); // daddu t3, t3, t4 + c->lb(t4, 0, a1); // lb t4, 0(a1) + c->mult3(t4, t4, v1); // mult3 t4, t4, v1 + c->lb(t5, 1, a1); // lb t5, 1(a1) + c->mult3(t5, t5, t0); // mult3 t5, t5, t0 + c->daddu(t4, t4, t5); // daddu t4, t4, t5 + c->lb(a1, 2, a1); // lb a1, 2(a1) + c->mult3(a1, a1, a3); // mult3 a1, a1, a3 + c->daddu(a1, t4, a1); // daddu a1, t4, a1 + c->dsra(t4, a2, 3); // dsra t4, a2, 3 + c->daddu(a1, a1, t4); // daddu a1, a1, t4 + c->daddu(a1, r0, a1); // daddu a1, r0, a1 + c->lwu(a0, 28, a0); // lwu a0, 28(a0) + c->daddu(a0, a1, a0); // daddu a0, a1, a0 + c->addiu(a1, r0, 1); // addiu a1, r0, 1 + c->andi(a2, a2, 7); // andi a2, a2, 7 + if (((s64)c->sgpr64(a2)) >= 0) { // bgezl a2, L191 + c->dsllv(a1, a1, a2); // dsllv a1, a1, a2 + goto block_3; + } + + block_2: + c->dsubu(a2, r0, a2); // dsubu a2, r0, a2 + c->dsrav(a1, a1, a2); // dsrav a1, a1, a2 + + block_3: + c->nor(a1, a1, r0); // nor a1, a1, r0 + c->mov64(a2, t3); // or a2, t3, r0 + + block_4: + c->mov64(t3, t2); // or t3, t2, r0 + c->mov64(t4, a0); // or t4, a0, r0 + + block_5: + c->mov64(t5, t1); // or t5, t1, r0 + c->mov64(t6, t4); // or t6, t4, r0 + + block_6: + // nop // sll r0, r0, 0 + c->lbu(t7, 0, t6); // lbu t7, 0(t6) + // nop // sll r0, r0, 0 + c->and_(t7, t7, a1); // and t7, t7, a1 + c->daddiu(t5, t5, -1); // daddiu t5, t5, -1 + c->sb(t7, 0, t6); // sb t7, 0(t6) + bc = c->sgpr64(t5) != 0; // bne t5, r0, L194 + c->daddu(t6, t6, v1); // daddu t6, t6, v1 + if (bc) {goto block_6;} // branch non-likely + + c->daddiu(t3, t3, -1); // daddiu t3, t3, -1 + // nop // sll r0, r0, 0 + bc = c->sgpr64(t3) != 0; // bne t3, r0, L193 + c->daddu(t4, t4, a3); // daddu t4, t4, a3 + if (bc) {goto block_5;} // branch non-likely + + c->daddiu(a2, a2, -1); // daddiu a2, a2, -1 + // nop // sll r0, r0, 0 + bc = c->sgpr64(a2) != 0; // bne a2, r0, L192 + c->daddu(a0, a0, t0); // daddu a0, a0, t0 + if (bc) {goto block_4;} // branch non-likely + + c->gprs[v0].du64[0] = 0; // or v0, r0, r0 + //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() { + gLinkedFunctionTable.reg("(method 19 grid-hash)", execute, 128); +} + +} // namespace method_19_grid_hash +} // 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 method_20_grid_hash { +u64 execute(void* ctxt) { + auto* c = (ExecutionContext*)ctxt; + bool bc = false; + u32 call_addr = 0; + c->daddiu(sp, sp, -48); // daddiu sp, sp, -48 + c->sd(ra, 0, sp); // sd ra, 0(sp) + c->sq(s5, 16, sp); // sq s5, 16(sp) + c->sq(gp, 32, sp); // sq gp, 32(sp) + c->lh(v1, 10, a0); // lh v1, 10(a0) + c->lb(a3, 24, a0); // lb a3, 24(a0) + c->mult3(a3, v1, a3); // mult3 a3, v1, a3 + c->lb(t0, 26, a0); // lb t0, 26(a0) + c->mult3(t0, a3, t0); // mult3 t0, a3, t0 + c->lb(t1, 3, a1); // lb t1, 3(a1) + c->lb(t2, 0, a1); // lb t2, 0(a1) + c->dsubu(t1, t1, t2); // dsubu t1, t1, t2 + c->lb(t2, 5, a1); // lb t2, 5(a1) + c->lb(t3, 2, a1); // lb t3, 2(a1) + c->dsubu(t2, t2, t3); // dsubu t2, t2, t3 + c->lb(t3, 4, a1); // lb t3, 4(a1) + c->lb(t4, 1, a1); // lb t4, 1(a1) + c->dsubu(t3, t3, t4); // dsubu t3, t3, t4 + c->lb(t4, 0, a1); // lb t4, 0(a1) + c->mult3(t4, t4, v1); // mult3 t4, t4, v1 + c->lb(t5, 1, a1); // lb t5, 1(a1) + c->mult3(t5, t5, t0); // mult3 t5, t5, t0 + c->daddu(t4, t4, t5); // daddu t4, t4, t5 + c->lb(a1, 2, a1); // lb a1, 2(a1) + c->mult3(a1, a1, a3); // mult3 a1, a1, a3 + c->daddu(a1, t4, a1); // daddu a1, t4, a1 + c->daddu(a1, r0, a1); // daddu a1, r0, a1 + c->lwu(a0, 28, a0); // lwu a0, 28(a0) + c->daddu(a0, a1, a0); // daddu a0, a1, a0 + c->sq(r0, 0, a2); // sq r0, 0(a2) + c->sq(r0, 16, a2); // sq r0, 16(a2) + c->mov64(a1, t3); // or a1, t3, r0 + // nop // sll r0, r0, 0 + + block_1: + c->mov64(t3, t2); // or t3, t2, r0 + c->mov64(t4, a0); // or t4, a0, r0 + + block_2: + c->mov64(t5, t1); // or t5, t1, r0 + c->mov64(t6, t4); // or t6, t4, r0 + + block_3: + c->slti(t8, v1, 9); // slti t8, v1, 9 + c->mov64(t7, v1); // or t7, v1, r0 + bc = c->sgpr64(t8) != 0; // bne t8, r0, L188 + c->mov64(t8, a2); // or t8, a2, r0 + if (bc) {goto block_6;} // branch non-likely + + + block_4: + c->mov64(ra, t8); // or ra, t8, r0 + c->ldr(t9, 0, t6); // ldr t9, 0(t6) + c->daddiu(t8, t8, 8); // daddiu t8, t8, 8 + c->ldl(t9, 7, t6); // ldl t9, 7(t6) + c->daddiu(t7, t7, -8); // daddiu t7, t7, -8 + c->ld(s5, 0, ra); // ld s5, 0(ra) + c->slti(gp, t7, 8); // slti gp, t7, 8 + c->or_(t9, s5, t9); // or t9, s5, t9 + c->daddiu(t6, t6, 8); // daddiu t6, t6, 8 + c->sd(t9, 0, ra); // sd t9, 0(ra) + bc = c->sgpr64(gp) == 0; // beq gp, r0, L187 + c->gprs[t9].du64[0] = 0; // or t9, r0, r0 + if (bc) {goto block_4;} // branch non-likely + + bc = c->sgpr64(t7) == 0; // beq t7, r0, L189 + // nop // sll r0, r0, 0 + if (bc) {goto block_7;} // branch non-likely + + + block_6: + // nop // sll r0, r0, 0 + c->ld(ra, 0, t8); // ld ra, 0(t8) + // nop // sll r0, r0, 0 + c->ldr(t9, 0, t6); // ldr t9, 0(t6) + // nop // sll r0, r0, 0 + c->ldl(t9, 7, t6); // ldl t9, 7(t6) + c->daddu(t6, t6, t7); // daddu t6, t6, t7 + c->or_(t7, ra, t9); // or t7, ra, t9 + // nop // sll r0, r0, 0 + c->sd(t7, 0, t8); // sd t7, 0(t8) + + block_7: + bc = ((s64)c->sgpr64(t5)) > 0; // bgtz t5, L186 + c->daddiu(t5, t5, -1); // daddiu t5, t5, -1 + if (bc) {goto block_3;} // branch non-likely + + c->daddu(t4, t4, a3); // daddu t4, t4, a3 + // nop // sll r0, r0, 0 + bc = ((s64)c->sgpr64(t3)) > 0; // bgtz t3, L185 + c->daddiu(t3, t3, -1); // daddiu t3, t3, -1 + if (bc) {goto block_2;} // branch non-likely + + c->daddu(a0, a0, t0); // daddu a0, a0, t0 + // nop // sll r0, r0, 0 + bc = ((s64)c->sgpr64(a1)) > 0; // bgtz a1, L184 + c->daddiu(a1, a1, -1); // daddiu a1, a1, -1 + if (bc) {goto block_1;} // branch non-likely + + c->mov64(v0, a2); // or v0, a2, r0 + c->ld(ra, 0, sp); // ld ra, 0(sp) + c->lq(gp, 32, sp); // lq gp, 32(sp) + c->lq(s5, 16, sp); // lq s5, 16(sp) + //jr ra // jr ra + c->daddiu(sp, sp, 48); // daddiu sp, sp, 48 + 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() { + gLinkedFunctionTable.reg("(method 20 grid-hash)", execute, 128); +} + +} // namespace method_20_grid_hash +} // 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 method_22_grid_hash { +u64 execute(void* ctxt) { + auto* c = (ExecutionContext*)ctxt; + bool bc = false; + u32 call_addr = 0; + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + c->lq(v1, 0, a2); // lq v1, 0(a2) + c->mov128_vf_gpr(vf1, v1); // qmtc2.i vf1, v1 + c->lq(v1, 12, a0); // lq v1, 12(a0) + c->mov128_vf_gpr(vf5, v1); // qmtc2.i vf5, v1 + c->vsub_bc(DEST::xyzw, BC::w, vf3, vf1, vf1); // vsubw.xyzw vf3, vf1, vf1 + c->vadd_bc(DEST::xyzw, BC::w, vf2, vf1, vf1); // vaddw.xyzw vf2, vf1, vf1 + c->lq(v1, 28, a0); // lq v1, 28(a0) + c->mov128_vf_gpr(vf4, v1); // qmtc2.i vf4, v1 + c->vmr32(DEST::xyzw, vf4, vf4); // vmr32.xyzw vf4, vf4 + c->vsub(DEST::xyzw, vf6, vf3, vf4); // vsub.xyzw vf6, vf3, vf4 + c->vsub(DEST::xyzw, vf7, vf2, vf4); // vsub.xyzw vf7, vf2, vf4 + c->vmul(DEST::xyzw, vf6, vf6, vf5); // vmul.xyzw vf6, vf6, vf5 + c->vmul(DEST::xyzw, vf7, vf7, vf5); // vmul.xyzw vf7, vf7, vf5 + c->vftoi0(DEST::xyz, vf6, vf6); // vftoi0.xyz vf6, vf6 + c->vftoi0(DEST::xyz, vf7, vf7); // vftoi0.xyz vf7, vf7 + c->nor(v1, r0, r0); // nor v1, r0, r0 + c->lw(a0, 24, a0); // lw a0, 24(a0) + c->sll(a2, a0, 8); // sll a2, a0, 8 + c->lui(a0, 1); // lui a0, 1 + c->srl(a2, a2, 8); // srl a2, a2, 8 + c->ori(a0, a0, 257); // ori a0, a0, 257 + c->dsubu(a0, a2, a0); // dsubu a0, a2, a0 + // nop // sll r0, r0, 0 + c->pextlb(a0, r0, a0); // pextlb a0, r0, a0 + // nop // sll r0, r0, 0 + c->pextlh(a0, r0, a0); // pextlh a0, r0, a0 + // nop // sll r0, r0, 0 + c->mov128_gpr_vf(a3, vf6); // qmfc2.i a3, vf6 + c->mov128_gpr_vf(a2, vf7); // qmfc2.i a2, vf7 + c->pmaxw(a3, a3, r0); // pmaxw a3, a3, r0 + c->pmaxw(a2, a2, r0); // pmaxw a2, a2, r0 + c->pminw(a3, a3, a0); // pminw a3, a3, a0 + c->pminw(a0, a2, a0); // pminw a0, a2, a0 + c->ppach(a2, r0, a3); // ppach a2, r0, a3 + c->ppach(a3, r0, a0); // ppach a3, r0, a0 + c->ppacb(a0, r0, a2); // ppacb a0, r0, a2 + c->ppacb(a2, r0, a3); // ppacb a2, r0, a3 + c->dsll(a2, a2, 24); // dsll a2, a2, 24 + c->or_(a0, a0, a2); // or a0, a0, a2 + c->dsll32(v1, v1, 16); // dsll32 v1, v1, 16 + c->ld(a2, 0, a1); // ld a2, 0(a1) + c->and_(v1, a2, v1); // and v1, a2, v1 + c->or_(v1, v1, a0); // or v1, v1, a0 + c->sd(v1, 0, a1); // sd v1, 0(a1) + c->gprs[v0].du64[0] = 0; // or v0, r0, r0 + //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() { + gLinkedFunctionTable.reg("(method 22 grid-hash)", execute, 128); +} + +} // namespace method_22_grid_hash +} // 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 method_28_sphere_hash { +u64 execute(void* ctxt) { + auto* c = (ExecutionContext*)ctxt; + bool bc = false; + u32 call_addr = 0; + c->daddiu(sp, sp, -48); // daddiu sp, sp, -48 + c->sd(ra, 0, sp); // sd ra, 0(sp) + c->sq(s5, 16, sp); // sq s5, 16(sp) + c->sq(gp, 32, sp); // sq gp, 32(sp) + c->mov64(gp, a0); // or gp, a0, r0 + c->mov64(a0, gp); // or a0, gp, r0 + c->lwu(v1, -4, a0); // lwu v1, -4(a0) + c->lwu(t9, 112, v1); // lwu t9, 112(v1) + 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(v1, v0); // or v1, v0, r0 + c->addiu(s5, r0, 0); // addiu s5, r0, 0 + //beq r0, r0, L118 // beq r0, r0, L118 + // nop // sll r0, r0, 0 + goto block_11; // branch always + + + block_1: + c->lwu(v1, 84, gp); // lwu v1, 84(gp) + c->dsll(a0, s5, 4); // dsll a0, s5, 4 + c->daddu(a2, v1, a0); // daddu a2, v1, a0 + c->mov64(a0, gp); // or a0, gp, r0 + c->lwu(v1, -4, a0); // lwu v1, -4(a0) + c->lwu(t9, 104, v1); // lwu t9, 104(v1) + c->daddiu(a1, gp, 4); // daddiu a1, gp, 4 + 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(v1, v0); // or v1, v0, r0 + c->mov64(t1, gp); // or t1, gp, r0 + c->daddiu(t2, gp, 4); // daddiu t2, gp, 4 + c->mov64(a3, s5); // or a3, s5, r0 + c->lh(v1, 10, t1); // lh v1, 10(t1) + c->lb(a0, 24, t1); // lb a0, 24(t1) + c->mult3(a0, a0, v1); // mult3 a0, a0, v1 + c->lb(a1, 26, t1); // lb a1, 26(t1) + c->mult3(a1, a1, a0); // mult3 a1, a1, a0 + c->addiu(a2, r0, 1); // addiu a2, r0, 1 + c->lb(t0, 0, t2); // lb t0, 0(t2) + c->dsubu(a2, a2, t0); // dsubu a2, a2, t0 + c->lb(t0, 3, t2); // lb t0, 3(t2) + c->daddu(a2, a2, t0); // daddu a2, a2, t0 + c->addiu(t0, r0, 1); // addiu t0, r0, 1 + c->lb(t3, 2, t2); // lb t3, 2(t2) + c->dsubu(t0, t0, t3); // dsubu t0, t0, t3 + c->lb(t3, 5, t2); // lb t3, 5(t2) + c->daddu(t0, t0, t3); // daddu t0, t0, t3 + c->addiu(t3, r0, 1); // addiu t3, r0, 1 + c->lb(t4, 1, t2); // lb t4, 1(t2) + c->dsubu(t3, t3, t4); // dsubu t3, t3, t4 + c->lb(t4, 4, t2); // lb t4, 4(t2) + c->daddu(t3, t3, t4); // daddu t3, t3, t4 + c->lb(t4, 0, t2); // lb t4, 0(t2) + c->mult3(t4, t4, v1); // mult3 t4, t4, v1 + c->lb(t5, 1, t2); // lb t5, 1(t2) + c->mult3(t5, t5, a1); // mult3 t5, t5, a1 + c->daddu(t4, t4, t5); // daddu t4, t4, t5 + c->lb(t2, 2, t2); // lb t2, 2(t2) + c->mult3(t2, t2, a0); // mult3 t2, t2, a0 + c->daddu(t2, t4, t2); // daddu t2, t4, t2 + c->dsra(t4, a3, 3); // dsra t4, a3, 3 + c->daddu(t2, t2, t4); // daddu t2, t2, t4 + c->daddu(t2, r0, t2); // daddu t2, r0, t2 + c->lwu(t1, 28, t1); // lwu t1, 28(t1) + c->daddu(t1, t2, t1); // daddu t1, t2, t1 + c->addiu(t2, r0, 1); // addiu t2, r0, 1 + c->andi(a3, a3, 7); // andi a3, a3, 7 + if (((s64)c->sgpr64(a3)) >= 0) { // bgezl a3, L114 + c->dsllv(a3, t2, a3); // dsllv a3, t2, a3 + goto block_4; + } + + block_3: + c->dsubu(a3, r0, a3); // dsubu a3, r0, a3 + c->dsrav(a3, t2, a3); // dsrav a3, t2, a3 + + block_4: + c->mov64(t2, t3); // or t2, t3, r0 + + block_5: + c->mov64(t3, t0); // or t3, t0, r0 + c->mov64(t4, t1); // or t4, t1, r0 + + block_6: + c->mov64(t5, a2); // or t5, a2, r0 + c->mov64(t6, t4); // or t6, t4, r0 + + block_7: + // nop // sll r0, r0, 0 + c->lbu(t7, 0, t6); // lbu t7, 0(t6) + // nop // sll r0, r0, 0 + c->or_(t7, t7, a3); // or t7, t7, a3 + c->daddiu(t5, t5, -1); // daddiu t5, t5, -1 + c->sb(t7, 0, t6); // sb t7, 0(t6) + bc = c->sgpr64(t5) != 0; // bne t5, r0, L117 + c->daddu(t6, t6, v1); // daddu t6, t6, v1 + if (bc) {goto block_7;} // branch non-likely + + c->daddiu(t3, t3, -1); // daddiu t3, t3, -1 + // nop // sll r0, r0, 0 + bc = c->sgpr64(t3) != 0; // bne t3, r0, L116 + c->daddu(t4, t4, a0); // daddu t4, t4, a0 + if (bc) {goto block_6;} // branch non-likely + + c->daddiu(t2, t2, -1); // daddiu t2, t2, -1 + // nop // sll r0, r0, 0 + bc = c->sgpr64(t2) != 0; // bne t2, r0, L115 + c->daddu(t1, t1, a1); // daddu t1, t1, a1 + if (bc) {goto block_5;} // branch non-likely + + c->gprs[v1].du64[0] = 0; // or v1, r0, r0 + c->daddiu(s5, s5, 1); // daddiu s5, s5, 1 + + block_11: + c->lh(v1, 56, gp); // lh v1, 56(gp) + c->slt(v1, s5, v1); // slt v1, s5, v1 + bc = c->sgpr64(v1) != 0; // bne v1, r0, L113 + // nop // sll r0, r0, 0 + if (bc) {goto block_1;} // branch non-likely + + c->mov64(v1, s7); // or v1, s7, r0 + c->mov64(v1, s7); // or v1, s7, r0 + c->gprs[v0].du64[0] = 0; // or v0, r0, r0 + c->ld(ra, 0, sp); // ld ra, 0(sp) + c->lq(gp, 32, sp); // lq gp, 32(sp) + c->lq(s5, 16, sp); // lq s5, 16(sp) + //jr ra // jr ra + c->daddiu(sp, sp, 48); // daddiu sp, sp, 48 + 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() { + gLinkedFunctionTable.reg("(method 28 sphere-hash)", execute, 128); +} + +} // namespace method_28_sphere_hash +} // 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 method_33_sphere_hash { +u64 execute(void* ctxt) { + auto* c = (ExecutionContext*)ctxt; + bool bc = false; + u32 call_addr = 0; + c->daddiu(sp, sp, -48); // daddiu sp, sp, -48 + c->sd(ra, 0, sp); // sd ra, 0(sp) + c->sq(s5, 16, sp); // sq s5, 16(sp) + c->sq(gp, 32, sp); // sq gp, 32(sp) + c->mov64(s5, a0); // or s5, a0, r0 + c->mov64(gp, a2); // or gp, a2, r0 + c->mov64(a0, s5); // or a0, s5, r0 + c->lwu(v1, -4, a0); // lwu v1, -4(a0) + c->lwu(t9, 104, v1); // lwu t9, 104(v1) + c->daddiu(v1, s5, 4); // daddiu v1, s5, 4 + c->mov64(a2, a1); // or a2, a1, r0 + c->mov64(a1, v1); // or a1, v1, 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(v1, v0); // or v1, v0, r0 + c->mov64(t0, s5); // or t0, s5, r0 + c->daddiu(t1, s5, 4); // daddiu t1, s5, 4 + c->lh(v1, 10, t0); // lh v1, 10(t0) + c->lb(a0, 24, t0); // lb a0, 24(t0) + c->mult3(a0, a0, v1); // mult3 a0, a0, v1 + c->lb(a1, 26, t0); // lb a1, 26(t0) + c->mult3(a1, a1, a0); // mult3 a1, a1, a0 + c->addiu(a2, r0, 1); // addiu a2, r0, 1 + c->lb(a3, 0, t1); // lb a3, 0(t1) + c->dsubu(a2, a2, a3); // dsubu a2, a2, a3 + c->lb(a3, 3, t1); // lb a3, 3(t1) + c->daddu(a2, a2, a3); // daddu a2, a2, a3 + c->addiu(a3, r0, 1); // addiu a3, r0, 1 + c->lb(t2, 2, t1); // lb t2, 2(t1) + c->dsubu(a3, a3, t2); // dsubu a3, a3, t2 + c->lb(t2, 5, t1); // lb t2, 5(t1) + c->daddu(a3, a3, t2); // daddu a3, a3, t2 + c->addiu(t2, r0, 1); // addiu t2, r0, 1 + c->lb(t3, 1, t1); // lb t3, 1(t1) + c->dsubu(t2, t2, t3); // dsubu t2, t2, t3 + c->lb(t3, 4, t1); // lb t3, 4(t1) + c->daddu(t2, t2, t3); // daddu t2, t2, t3 + c->lb(t3, 0, t1); // lb t3, 0(t1) + c->mult3(t3, t3, v1); // mult3 t3, t3, v1 + c->lb(t4, 1, t1); // lb t4, 1(t1) + c->mult3(t4, t4, a1); // mult3 t4, t4, a1 + c->daddu(t3, t3, t4); // daddu t3, t3, t4 + c->lb(t1, 2, t1); // lb t1, 2(t1) + c->mult3(t1, t1, a0); // mult3 t1, t1, a0 + c->daddu(t1, t3, t1); // daddu t1, t3, t1 + c->dsra(t3, gp, 3); // dsra t3, gp, 3 + c->daddu(t1, t1, t3); // daddu t1, t1, t3 + c->daddu(t1, r0, t1); // daddu t1, r0, t1 + c->lwu(t0, 28, t0); // lwu t0, 28(t0) + c->daddu(t0, t1, t0); // daddu t0, t1, t0 + c->addiu(t1, r0, 1); // addiu t1, r0, 1 + c->andi(t3, gp, 7); // andi t3, gp, 7 + if (((s64)c->sgpr64(t3)) >= 0) { // bgezl t3, L98 + c->dsllv(t1, t1, t3); // dsllv t1, t1, t3 + goto block_3; + } + + block_2: + c->dsubu(t3, r0, t3); // dsubu t3, r0, t3 + c->dsrav(t1, t1, t3); // dsrav t1, t1, t3 + + block_3: + c->nor(t1, t1, r0); // nor t1, t1, r0 + c->mov64(t2, t2); // or t2, t2, r0 + // nop // sll r0, r0, 0 + + block_4: + c->mov64(t3, a3); // or t3, a3, r0 + c->mov64(t4, t0); // or t4, t0, r0 + + block_5: + c->mov64(t5, a2); // or t5, a2, r0 + c->mov64(t6, t4); // or t6, t4, r0 + + block_6: + // nop // sll r0, r0, 0 + c->lbu(t7, 0, t6); // lbu t7, 0(t6) + // nop // sll r0, r0, 0 + c->and_(t7, t7, t1); // and t7, t7, t1 + c->daddiu(t5, t5, -1); // daddiu t5, t5, -1 + c->sb(t7, 0, t6); // sb t7, 0(t6) + bc = c->sgpr64(t5) != 0; // bne t5, r0, L101 + c->daddu(t6, t6, v1); // daddu t6, t6, v1 + if (bc) {goto block_6;} // branch non-likely + + c->daddiu(t3, t3, -1); // daddiu t3, t3, -1 + // nop // sll r0, r0, 0 + bc = c->sgpr64(t3) != 0; // bne t3, r0, L100 + c->daddu(t4, t4, a0); // daddu t4, t4, a0 + if (bc) {goto block_5;} // branch non-likely + + c->daddiu(t2, t2, -1); // daddiu t2, t2, -1 + // nop // sll r0, r0, 0 + bc = c->sgpr64(t2) != 0; // bne t2, r0, L99 + c->daddu(t0, t0, a1); // daddu t0, t0, a1 + if (bc) {goto block_4;} // branch non-likely + + c->gprs[v1].du64[0] = 0; // or v1, r0, r0 + c->gprs[v0].du64[0] = 0; // or v0, r0, r0 + c->ld(ra, 0, sp); // ld ra, 0(sp) + c->lq(gp, 32, sp); // lq gp, 32(sp) + c->lq(s5, 16, sp); // lq s5, 16(sp) + //jr ra // jr ra + c->daddiu(sp, sp, 48); // daddiu sp, sp, 48 + 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() { + gLinkedFunctionTable.reg("(method 33 sphere-hash)", execute, 128); +} + +} // namespace method_33_sphere_hash +} // 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 method_29_sphere_hash { +struct Cache { + void* perf_stats; // *perf-stats* +} cache; + +u64 execute(void* ctxt) { + auto* c = (ExecutionContext*)ctxt; + bool bc = false; + u32 call_addr = 0; + bool cop1_bc = false; + c->daddiu(sp, sp, -144); // daddiu sp, sp, -144 + c->sd(ra, 0, sp); // sd ra, 0(sp) + c->sq(s2, 64, sp); // sq s2, 64(sp) + c->sq(s3, 80, sp); // sq s3, 80(sp) + c->sq(s4, 96, sp); // sq s4, 96(sp) + c->sq(s5, 112, sp); // sq s5, 112(sp) + c->sq(gp, 128, sp); // sq gp, 128(sp) + c->mov64(s5, a0); // or s5, a0, r0 + c->mov64(gp, a1); // or gp, a1, r0 + c->mov64(s4, a2); // or s4, a2, r0 + c->mov64(s3, a3); // or s3, a3, r0 + c->mov64(s2, t0); // or s2, t0, r0 + c->load_symbol2(v1, cache.perf_stats); // lw v1, *perf-stats*(s7) + c->daddiu(v1, v1, 116); // daddiu v1, v1, 116 + c->lwu(a0, 28, v1); // lwu a0, 28(v1) + c->lwu(a1, 4, v1); // lwu a1, 4(v1) + c->daddiu(a1, a1, 1); // daddiu a1, a1, 1 + c->sw(a1, 4, v1); // sw a1, 4(v1) + bc = c->sgpr64(a0) == 0; // beq a0, r0, L90 + // nop // sll r0, r0, 0 + if (bc) {goto block_2;} // branch non-likely + + // Unknown instr: mtc0 Perf, r0 + // Unknown instr: sync.l + // Unknown instr: sync.p + // Unknown instr: mtpc pcr0, r0 + // Unknown instr: mtpc pcr1, r0 + // Unknown instr: sync.l + // Unknown instr: sync.p + // Unknown instr: mtc0 Perf, a0 + // Unknown instr: sync.l + // Unknown instr: sync.p + + block_2: + c->gprs[v1].du64[0] = 0; // or v1, r0, r0 + c->mov64(a0, s5); // or a0, s5, r0 + c->lwu(v1, -4, a0); // lwu v1, -4(a0) + c->lwu(t9, 104, v1); // lwu t9, 104(v1) + c->daddiu(a1, s5, 4); // daddiu a1, s5, 4 + c->mov64(a2, gp); // or a2, gp, 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(v1, v0); // or v1, v0, r0 + c->lwu(v1, 0, s5); // lwu v1, 0(s5) + c->daddiu(v1, v1, 12); // daddiu v1, v1, 12 + c->sw(v1, 16, sp); // sw v1, 16(sp) + c->mov64(a0, s5); // or a0, s5, r0 + c->lwu(v1, -4, a0); // lwu v1, -4(a0) + c->lwu(t9, 96, v1); // lwu t9, 96(v1) + c->daddiu(a1, s5, 4); // daddiu a1, s5, 4 + c->lwu(a2, 16, sp); // lwu a2, 16(sp) + 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(v1, v0); // or v1, v0, r0 + c->sd(r0, 24, sp); // sd r0, 24(sp) + c->sw(s5, 32, sp); // sw s5, 32(sp) + c->sd(s4, 40, sp); // sd s4, 40(sp) + c->sw(s3, 48, sp); // sw s3, 48(sp) + c->sd(s2, 56, sp); // sd s2, 56(sp) + c->lwu(v1, 32, sp); // lwu v1, 32(sp) + c->lh(v1, 10, v1); // lh v1, 10(v1) + c->lwu(a0, 16, sp); // lwu a0, 16(sp) + c->gprs[a1].du64[0] = 0; // or a1, r0, r0 + + block_3: + c->dsll(a2, a1, 3); // dsll a2, a1, 3 + c->lbu(a3, 0, a0); // lbu a3, 0(a0) + bc = c->sgpr64(a3) == 0; // beq a3, r0, L95 + // nop // sll r0, r0, 0 + if (bc) {goto block_12;} // branch non-likely + + + block_4: + c->andi(t0, a3, 1); // andi t0, a3, 1 + // nop // sll r0, r0, 0 + bc = c->sgpr64(t0) == 0; // beq t0, r0, L94 + // nop // sll r0, r0, 0 + if (bc) {goto block_11;} // branch non-likely + + c->lwu(t0, 32, sp); // lwu t0, 32(sp) + c->lwu(t0, 84, t0); // lwu t0, 84(t0) + c->dsll(t1, a2, 4); // dsll t1, a2, 4 + c->daddu(t0, t0, t1); // daddu t0, t0, t1 + c->ld(t1, 40, sp); // ld t1, 40(sp) + c->lwc1(f0, 12, t0); // lwc1 f0, 12(t0) + c->mfc1(t2, f0); // mfc1 t2, f0 + c->and_(t1, t1, t2); // and t1, t1, t2 + bc = c->sgpr64(t1) == 0; // beq t1, r0, L93 + // nop // sll r0, r0, 0 + if (bc) {goto block_10;} // branch non-likely + + c->mov64(t1, s7); // or t1, s7, r0 + c->lwc1(f3, 0, gp); // lwc1 f3, 0(gp) + c->lwc1(f1, 8, gp); // lwc1 f1, 8(gp) + c->lwc1(f4, 0, t0); // lwc1 f4, 0(t0) + c->lwc1(f2, 8, t0); // lwc1 f2, 8(t0) + c->lwc1(f0, 12, gp); // lwc1 f0, 12(gp) + c->subs(f3, f4, f3); // sub.s f3, f4, f3 + c->subs(f1, f2, f1); // sub.s f1, f2, f1 + c->mtc1(f2, r0); // mtc1 f2, r0 + // Unknown instr: mula.s f3, f3 + // Unknown instr: madd.s f1, f1, f1 + c->fprs[f1] = (c->fprs[f3] * c->fprs[f3]) + (c->fprs[f1] * c->fprs[f1]); + cop1_bc = c->fprs[f2] < c->fprs[f1]; // c.lt.s f2, f1 + bc = !cop1_bc; // bc1f L93 + // nop // sll r0, r0, 0 + if (bc) {goto block_10;} // branch non-likely + + c->lwc1(f2, 12, t0); // lwc1 f2, 12(t0) + c->adds(f0, f2, f0); // add.s f0, f2, f0 + c->muls(f0, f0, f0); // mul.s f0, f0, f0 + cop1_bc = c->fprs[f1] < c->fprs[f0]; // c.lt.s f1, f0 + bc = !cop1_bc; // bc1f L93 + // nop // sll r0, r0, 0 + if (bc) {goto block_10;} // branch non-likely + + c->ld(t0, 24, sp); // ld t0, 24(sp) + c->ld(t1, 56, sp); // ld t1, 56(sp) + c->slt(t0, t0, t1); // slt t0, t0, t1 + bc = c->sgpr64(t0) == 0; // beq t0, r0, L93 + // nop // sll r0, r0, 0 + if (bc) {goto block_10;} // branch non-likely + + c->lwu(t0, 48, sp); // lwu t0, 48(sp) + c->ld(t1, 24, sp); // ld t1, 24(sp) + c->daddu(t0, t0, t1); // daddu t0, t0, t1 + c->sb(a2, 0, t0); // sb a2, 0(t0) + c->ld(t0, 24, sp); // ld t0, 24(sp) + c->daddiu(t0, t0, 1); // daddiu t0, t0, 1 + c->sd(t0, 24, sp); // sd t0, 24(sp) + + block_10: + c->gprs[t0].du64[0] = 0; // or t0, r0, r0 + // nop // sll r0, r0, 0 + + block_11: + c->dsra(a3, a3, 1); // dsra a3, a3, 1 + // nop // sll r0, r0, 0 + bc = c->sgpr64(a3) != 0; // bne a3, r0, L92 + c->daddiu(a2, a2, 1); // daddiu a2, a2, 1 + if (bc) {goto block_4;} // branch non-likely + + + block_12: + c->daddiu(a1, a1, 1); // daddiu a1, a1, 1 + c->daddiu(a0, a0, 1); // daddiu a0, a0, 1 + c->slt(a2, a1, v1); // slt a2, a1, v1 + // nop // sll r0, r0, 0 + bc = c->sgpr64(a2) != 0; // bne a2, r0, L91 + // nop // sll r0, r0, 0 + if (bc) {goto block_3;} // branch non-likely + + c->load_symbol2(v1, cache.perf_stats); // lw v1, *perf-stats*(s7) + c->daddiu(v1, v1, 116); // daddiu v1, v1, 116 + c->lwu(a0, 28, v1); // lwu a0, 28(v1) + bc = c->sgpr64(a0) == 0; // beq a0, r0, L96 + // nop // sll r0, r0, 0 + if (bc) {goto block_15;} // branch non-likely + + // Unknown instr: mtc0 Perf, r0 + // Unknown instr: sync.l + // Unknown instr: sync.p + // Unknown instr: mfpc a0, pcr0 + c->lwu(a1, 32, v1); // lwu a1, 32(v1) + c->daddu(a0, a1, a0); // daddu a0, a1, a0 + c->sw(a0, 32, v1); // sw a0, 32(v1) + // Unknown instr: mfpc a0, pcr1 + c->lwu(a1, 36, v1); // lwu a1, 36(v1) + c->daddu(a0, a1, a0); // daddu a0, a1, a0 + c->sw(a0, 36, v1); // sw a0, 36(v1) + + block_15: + c->gprs[v1].du64[0] = 0; // or v1, r0, r0 + c->ld(v0, 24, sp); // ld v0, 24(sp) + c->ld(ra, 0, sp); // ld ra, 0(sp) + c->lq(gp, 128, sp); // lq gp, 128(sp) + c->lq(s5, 112, sp); // lq s5, 112(sp) + c->lq(s4, 96, sp); // lq s4, 96(sp) + c->lq(s3, 80, sp); // lq s3, 80(sp) + c->lq(s2, 64, sp); // lq s2, 64(sp) + //jr ra // jr ra + c->daddiu(sp, sp, 144); // daddiu sp, sp, 144 + 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.perf_stats = intern_from_c("*perf-stats*").c(); + gLinkedFunctionTable.reg("(method 29 sphere-hash)", execute, 256); +} + +} // namespace method_29_sphere_hash +} // 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 method_30_sphere_hash { +struct Cache { + void* perf_stats; // *perf-stats* +} cache; + +u64 execute(void* ctxt) { + auto* c = (ExecutionContext*)ctxt; + bool bc = false; + u32 call_addr = 0; + bool cop1_bc = false; + c->daddiu(sp, sp, -64); // daddiu sp, sp, -64 + c->sd(ra, 0, sp); // sd ra, 0(sp) + c->sq(s4, 16, sp); // sq s4, 16(sp) + c->sq(s5, 32, sp); // sq s5, 32(sp) + c->sq(gp, 48, sp); // sq gp, 48(sp) + c->mov64(s5, a0); // or s5, a0, r0 + c->mov64(gp, a1); // or gp, a1, r0 + c->load_symbol2(v1, cache.perf_stats); // lw v1, *perf-stats*(s7) + c->daddiu(v1, v1, 116); // daddiu v1, v1, 116 + c->lwu(a0, 28, v1); // lwu a0, 28(v1) + c->lwu(a1, 4, v1); // lwu a1, 4(v1) + c->daddiu(a1, a1, 1); // daddiu a1, a1, 1 + c->sw(a1, 4, v1); // sw a1, 4(v1) + bc = c->sgpr64(a0) == 0; // beq a0, r0, L82 + // nop // sll r0, r0, 0 + if (bc) {goto block_2;} // branch non-likely + + // Unknown instr: mtc0 Perf, r0 + // Unknown instr: sync.l + // Unknown instr: sync.p + // Unknown instr: mtpc pcr0, r0 + // Unknown instr: mtpc pcr1, r0 + // Unknown instr: sync.l + // Unknown instr: sync.p + // Unknown instr: mtc0 Perf, a0 + // Unknown instr: sync.l + // Unknown instr: sync.p + + block_2: + c->gprs[v1].du64[0] = 0; // or v1, r0, r0 + c->mov64(a0, s5); // or a0, s5, r0 + c->lwu(v1, -4, a0); // lwu v1, -4(a0) + c->lwu(t9, 104, v1); // lwu t9, 104(v1) + c->daddiu(a1, s5, 4); // daddiu a1, s5, 4 + c->daddu(a2, r0, gp); // daddu a2, r0, gp + 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(v1, v0); // or v1, v0, r0 + c->lwu(v1, 0, s5); // lwu v1, 0(s5) + c->daddiu(s4, v1, 12); // daddiu s4, v1, 12 + c->mov64(a0, s5); // or a0, s5, r0 + c->lwu(v1, -4, a0); // lwu v1, -4(a0) + c->lwu(t9, 96, v1); // lwu t9, 96(v1) + c->daddiu(a1, s5, 4); // daddiu a1, s5, 4 + c->mov64(a2, s4); // or a2, 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 + c->mov64(v1, v0); // or v1, v0, r0 + c->sh(r0, 20, gp); // sh r0, 20(gp) + c->lh(v1, 10, s5); // lh v1, 10(s5) + c->gprs[a0].du64[0] = 0; // or a0, r0, r0 + + block_3: + c->dsll(a1, a0, 3); // dsll a1, a0, 3 + c->lbu(a2, 0, s4); // lbu a2, 0(s4) + bc = c->sgpr64(a2) == 0; // beq a2, r0, L87 + // nop // sll r0, r0, 0 + if (bc) {goto block_13;} // branch non-likely + + + block_4: + c->andi(a3, a2, 1); // andi a3, a2, 1 + // nop // sll r0, r0, 0 + bc = c->sgpr64(a3) == 0; // beq a3, r0, L86 + // nop // sll r0, r0, 0 + if (bc) {goto block_12;} // branch non-likely + + c->lwu(a3, 84, s5); // lwu a3, 84(s5) + c->dsll(t0, a1, 4); // dsll t0, a1, 4 + c->daddu(a3, a3, t0); // daddu a3, a3, t0 + c->lbu(t0, 24, gp); // lbu t0, 24(gp) + c->lwc1(f0, 12, a3); // lwc1 f0, 12(a3) + c->mfc1(t1, f0); // mfc1 t1, f0 + c->and_(t0, t0, t1); // and t0, t0, t1 + bc = c->sgpr64(t0) == 0; // beq t0, r0, L85 + // nop // sll r0, r0, 0 + if (bc) {goto block_11;} // branch non-likely + + c->mov64(t0, s7); // or t0, s7, r0 + c->lwc1(f3, 0, gp); // lwc1 f3, 0(gp) + c->lwc1(f1, 8, gp); // lwc1 f1, 8(gp) + c->lwc1(f4, 0, a3); // lwc1 f4, 0(a3) + c->lwc1(f2, 8, a3); // lwc1 f2, 8(a3) + c->lwc1(f0, 12, gp); // lwc1 f0, 12(gp) + c->subs(f3, f4, f3); // sub.s f3, f4, f3 + c->subs(f1, f2, f1); // sub.s f1, f2, f1 + c->mtc1(f2, r0); // mtc1 f2, r0 + // Unknown instr: mula.s f3, f3 + // Unknown instr: madd.s f1, f1, f1 + c->fprs[f1] = (c->fprs[f3] * c->fprs[f3]) + (c->fprs[f1] * c->fprs[f1]); + cop1_bc = c->fprs[f2] < c->fprs[f1]; // c.lt.s f2, f1 + bc = !cop1_bc; // bc1f L85 + // nop // sll r0, r0, 0 + if (bc) {goto block_11;} // branch non-likely + + c->lwc1(f2, 4, gp); // lwc1 f2, 4(gp) + c->lwc1(f3, 4, a3); // lwc1 f3, 4(a3) + c->subs(f3, f3, f2); // sub.s f3, f3, f2 + c->lwc1(f2, 16, gp); // lwc1 f2, 16(gp) + c->abss(f3, f3); // abs.s f3, f3 + cop1_bc = c->fprs[f3] < c->fprs[f2]; // c.lt.s f3, f2 + bc = !cop1_bc; // bc1f L85 + // nop // sll r0, r0, 0 + if (bc) {goto block_11;} // branch non-likely + + c->lwc1(f2, 12, a3); // lwc1 f2, 12(a3) + c->adds(f0, f2, f0); // add.s f0, f2, f0 + c->muls(f0, f0, f0); // mul.s f0, f0, f0 + cop1_bc = c->fprs[f1] < c->fprs[f0]; // c.lt.s f1, f0 + bc = !cop1_bc; // bc1f L85 + // nop // sll r0, r0, 0 + if (bc) {goto block_11;} // branch non-likely + + c->lh(a3, 20, gp); // lh a3, 20(gp) + c->lh(t0, 22, gp); // lh t0, 22(gp) + c->slt(a3, a3, t0); // slt a3, a3, t0 + bc = c->sgpr64(a3) == 0; // beq a3, r0, L85 + // nop // sll r0, r0, 0 + if (bc) {goto block_11;} // branch non-likely + + c->mov64(a3, s7); // or a3, s7, r0 + c->lwu(a3, 28, gp); // lwu a3, 28(gp) + c->lh(t0, 20, gp); // lh t0, 20(gp) + c->daddu(a3, a3, t0); // daddu a3, a3, t0 + c->sb(a1, 0, a3); // sb a1, 0(a3) + c->lh(a3, 20, gp); // lh a3, 20(gp) + c->daddiu(a3, a3, 1); // daddiu a3, a3, 1 + c->sh(a3, 20, gp); // sh a3, 20(gp) + + block_11: + c->gprs[a3].du64[0] = 0; // or a3, r0, r0 + // nop // sll r0, r0, 0 + + block_12: + c->dsra(a2, a2, 1); // dsra a2, a2, 1 + // nop // sll r0, r0, 0 + bc = c->sgpr64(a2) != 0; // bne a2, r0, L84 + c->daddiu(a1, a1, 1); // daddiu a1, a1, 1 + if (bc) {goto block_4;} // branch non-likely + + + block_13: + c->daddiu(a0, a0, 1); // daddiu a0, a0, 1 + c->daddiu(s4, s4, 1); // daddiu s4, s4, 1 + c->slt(a1, a0, v1); // slt a1, a0, v1 + // nop // sll r0, r0, 0 + bc = c->sgpr64(a1) != 0; // bne a1, r0, L83 + // nop // sll r0, r0, 0 + if (bc) {goto block_3;} // branch non-likely + + c->load_symbol2(v1, cache.perf_stats); // lw v1, *perf-stats*(s7) + c->daddiu(v1, v1, 116); // daddiu v1, v1, 116 + c->lwu(a0, 28, v1); // lwu a0, 28(v1) + bc = c->sgpr64(a0) == 0; // beq a0, r0, L88 + // nop // sll r0, r0, 0 + if (bc) {goto block_16;} // branch non-likely + + // Unknown instr: mtc0 Perf, r0 + // Unknown instr: sync.l + // Unknown instr: sync.p + // Unknown instr: mfpc a0, pcr0 + c->lwu(a1, 32, v1); // lwu a1, 32(v1) + c->daddu(a0, a1, a0); // daddu a0, a1, a0 + c->sw(a0, 32, v1); // sw a0, 32(v1) + // Unknown instr: mfpc a0, pcr1 + c->lwu(a1, 36, v1); // lwu a1, 36(v1) + c->daddu(a0, a1, a0); // daddu a0, a1, a0 + c->sw(a0, 36, v1); // sw a0, 36(v1) + + block_16: + c->gprs[v1].du64[0] = 0; // or v1, r0, r0 + c->gprs[v0].du64[0] = 0; // or v0, r0, r0 + c->ld(ra, 0, sp); // ld ra, 0(sp) + c->lq(gp, 48, sp); // lq gp, 48(sp) + c->lq(s5, 32, sp); // lq s5, 32(sp) + c->lq(s4, 16, sp); // lq s4, 16(sp) + //jr ra // jr ra + c->daddiu(sp, sp, 64); // daddiu sp, sp, 64 + 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.perf_stats = intern_from_c("*perf-stats*").c(); + gLinkedFunctionTable.reg("(method 30 sphere-hash)", execute, 128); +} + +} // namespace method_30_sphere_hash +} // 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 method_31_sphere_hash { +struct Cache { + void* perf_stats; // *perf-stats* +} cache; + +u64 execute(void* ctxt) { + auto* c = (ExecutionContext*)ctxt; + bool bc = false; + u32 call_addr = 0; + bool cop1_bc = false; + c->daddiu(sp, sp, -96); // daddiu sp, sp, -96 + c->sd(ra, 0, sp); // sd ra, 0(sp) + c->sq(s3, 32, sp); // sq s3, 32(sp) + c->sq(s4, 48, sp); // sq s4, 48(sp) + c->sq(s5, 64, sp); // sq s5, 64(sp) + c->sq(gp, 80, sp); // sq gp, 80(sp) + c->mov64(s4, a0); // or s4, a0, r0 + c->mov64(gp, a1); // or gp, a1, r0 + c->mov64(s5, a2); // or s5, a2, r0 + c->mov64(s3, a3); // or s3, a3, r0 + c->load_symbol2(v1, cache.perf_stats); // lw v1, *perf-stats*(s7) + c->daddiu(v1, v1, 116); // daddiu v1, v1, 116 + c->lwu(a0, 28, v1); // lwu a0, 28(v1) + c->lwu(a1, 4, v1); // lwu a1, 4(v1) + c->daddiu(a1, a1, 1); // daddiu a1, a1, 1 + c->sw(a1, 4, v1); // sw a1, 4(v1) + bc = c->sgpr64(a0) == 0; // beq a0, r0, L70 + // nop // sll r0, r0, 0 + if (bc) {goto block_2;} // branch non-likely + + // Unknown instr: mtc0 Perf, r0 + // Unknown instr: sync.l + // Unknown instr: sync.p + // Unknown instr: mtpc pcr0, r0 + // Unknown instr: mtpc pcr1, r0 + // Unknown instr: sync.l + // Unknown instr: sync.p + // Unknown instr: mtc0 Perf, a0 + // Unknown instr: sync.l + // Unknown instr: sync.p + + block_2: + c->gprs[v1].du64[0] = 0; // or v1, r0, r0 + c->mov64(a0, s4); // or a0, s4, r0 + c->lwu(v1, -4, a0); // lwu v1, -4(a0) + c->lwu(t9, 104, v1); // lwu t9, 104(v1) + c->daddiu(a1, s4, 4); // daddiu a1, s4, 4 + c->mov64(a2, gp); // or a2, gp, 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(v1, v0); // or v1, v0, r0 + c->lwu(v1, 0, s4); // lwu v1, 0(s4) + c->daddiu(v1, v1, 12); // daddiu v1, v1, 12 + c->sw(v1, 16, sp); // sw v1, 16(sp) + c->mov64(a0, s4); // or a0, s4, r0 + c->lwu(v1, -4, a0); // lwu v1, -4(a0) + c->lwu(t9, 96, v1); // lwu t9, 96(v1) + c->daddiu(a1, s4, 4); // daddiu a1, s4, 4 + c->lwu(a2, 16, sp); // lwu a2, 16(sp) + 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(v1, v0); // or v1, v0, r0 + c->addiu(v1, r0, -1); // addiu v1, r0, -1 + bc = c->sgpr64(s3) == c->sgpr64(v1); // beq s3, v1, L72 + c->mov64(v1, s7); // or v1, s7, r0 + if (bc) {goto block_7;} // branch non-likely + + c->dsra(v1, s3, 3); // dsra v1, s3, 3 + c->andi(a1, s3, 7); // andi a1, s3, 7 + c->addiu(a0, r0, 1); // addiu a0, r0, 1 + if (((s64)c->sgpr64(a1)) >= 0) { // bgezl a1, L71 + c->dsllv(a0, a0, a1); // dsllv a0, a0, a1 + goto block_6; + } + + block_5: + c->dsubu(a1, r0, a1); // dsubu a1, r0, a1 + c->dsrav(a0, a0, a1); // dsrav a0, a0, a1 + + block_6: + c->nor(a0, a0, r0); // nor a0, a0, r0 + c->lwu(a1, 16, sp); // lwu a1, 16(sp) + c->daddu(a1, a1, v1); // daddu a1, a1, v1 + c->lbu(a1, 0, a1); // lbu a1, 0(a1) + c->and_(a0, a1, a0); // and a0, a1, a0 + c->lwu(a1, 16, sp); // lwu a1, 16(sp) + c->daddu(v1, a1, v1); // daddu v1, a1, v1 + c->sb(a0, 0, v1); // sb a0, 0(v1) + + block_7: + c->daddiu(v1, s7, 4); // daddiu v1, s7, #t + c->sw(v1, 20, sp); // sw v1, 20(sp) + c->sw(s4, 24, sp); // sw s4, 24(sp) + c->lwu(v1, 24, sp); // lwu v1, 24(sp) + c->lh(v1, 10, v1); // lh v1, 10(v1) + c->lwu(a0, 16, sp); // lwu a0, 16(sp) + c->gprs[a1].du64[0] = 0; // or a1, r0, r0 + + block_8: + c->dsll(a2, a1, 3); // dsll a2, a1, 3 + c->lbu(a3, 0, a0); // lbu a3, 0(a0) + bc = c->sgpr64(a3) == 0; // beq a3, r0, L78 + // nop // sll r0, r0, 0 + if (bc) {goto block_15;} // branch non-likely + + + block_9: + c->andi(t0, a3, 1); // andi t0, a3, 1 + // nop // sll r0, r0, 0 + bc = c->sgpr64(t0) == 0; // beq t0, r0, L77 + // nop // sll r0, r0, 0 + if (bc) {goto block_14;} // branch non-likely + + c->lwu(t0, 24, sp); // lwu t0, 24(sp) + c->lwu(t0, 84, t0); // lwu t0, 84(t0) + c->dsll(t1, a2, 4); // dsll t1, a2, 4 + c->daddu(t0, t0, t1); // daddu t0, t0, t1 + c->sw(t0, 28, sp); // sw t0, 28(sp) + c->lwu(t0, 28, sp); // lwu t0, 28(sp) + c->lwc1(f0, 12, t0); // lwc1 f0, 12(t0) + c->mfc1(t0, f0); // mfc1 t0, f0 + c->and_(t0, s5, t0); // and t0, s5, t0 + bc = c->sgpr64(t0) != 0; // bne t0, r0, L75 + c->mov64(t0, s7); // or t0, s7, r0 + if (bc) {goto block_12;} // branch non-likely + + //beq r0, r0, L76 // beq r0, r0, L76 + // nop // sll r0, r0, 0 + goto block_13; // branch always + + + block_12: + c->lwc1(f0, 0, gp); // lwc1 f0, 0(gp) + c->lwu(t0, 28, sp); // lwu t0, 28(sp) + c->lwc1(f1, 0, t0); // lwc1 f1, 0(t0) + c->lwc1(f2, 4, gp); // lwc1 f2, 4(gp) + c->lwu(t0, 28, sp); // lwu t0, 28(sp) + c->lwc1(f2, 4, t0); // lwc1 f2, 4(t0) + c->lwc1(f2, 8, gp); // lwc1 f2, 8(gp) + c->lwu(t0, 28, sp); // lwu t0, 28(sp) + c->lwc1(f3, 8, t0); // lwc1 f3, 8(t0) + c->subs(f0, f1, f0); // sub.s f0, f1, f0 + c->subs(f1, f3, f2); // sub.s f1, f3, f2 + c->subs(f2, f3, f2); // sub.s f2, f3, f2 + // Unknown instr: mula.s f0, f0 + // Unknown instr: madda.s f1, f1 + // Unknown instr: madd.s f0, f2, f2 + c->fprs[f0] = (c->fprs[f2] * c->fprs[f2]) + (c->fprs[f1] * c->fprs[f1])+ (c->fprs[f0] * c->fprs[f0]); + + c->lwu(t0, 28, sp); // lwu t0, 28(sp) + c->lwc1(f1, 12, t0); // lwc1 f1, 12(t0) + c->lwc1(f2, 12, gp); // lwc1 f2, 12(gp) + c->adds(f1, f1, f2); // add.s f1, f1, f2 + c->muls(f1, f1, f1); // mul.s f1, f1, f1 + cop1_bc = c->fprs[f0] < c->fprs[f1]; // c.lt.s f0, f1 + bc = cop1_bc; // bc1t L79 + // nop // sll r0, r0, 0 + if (bc) {goto block_17;} // branch non-likely + + + block_13: + c->gprs[t0].du64[0] = 0; // or t0, r0, r0 + // nop // sll r0, r0, 0 + + block_14: + c->dsra(a3, a3, 1); // dsra a3, a3, 1 + // nop // sll r0, r0, 0 + bc = c->sgpr64(a3) != 0; // bne a3, r0, L74 + c->daddiu(a2, a2, 1); // daddiu a2, a2, 1 + if (bc) {goto block_9;} // branch non-likely + + + block_15: + c->daddiu(a1, a1, 1); // daddiu a1, a1, 1 + c->daddiu(a0, a0, 1); // daddiu a0, a0, 1 + c->slt(a2, a1, v1); // slt a2, a1, v1 + // nop // sll r0, r0, 0 + bc = c->sgpr64(a2) != 0; // bne a2, r0, L73 + // nop // sll r0, r0, 0 + if (bc) {goto block_8;} // branch non-likely + + c->sw(s7, 20, sp); // sw s7, 20(sp) + + block_17: + c->load_symbol2(v1, cache.perf_stats); // lw v1, *perf-stats*(s7) + c->daddiu(v1, v1, 116); // daddiu v1, v1, 116 + c->lwu(a0, 28, v1); // lwu a0, 28(v1) + bc = c->sgpr64(a0) == 0; // beq a0, r0, L80 + // nop // sll r0, r0, 0 + if (bc) {goto block_19;} // branch non-likely + + // Unknown instr: mtc0 Perf, r0 + // Unknown instr: sync.l + // Unknown instr: sync.p + // Unknown instr: mfpc a0, pcr0 + c->lwu(a1, 32, v1); // lwu a1, 32(v1) + c->daddu(a0, a1, a0); // daddu a0, a1, a0 + c->sw(a0, 32, v1); // sw a0, 32(v1) + // Unknown instr: mfpc a0, pcr1 + c->lwu(a1, 36, v1); // lwu a1, 36(v1) + c->daddu(a0, a1, a0); // daddu a0, a1, a0 + c->sw(a0, 36, v1); // sw a0, 36(v1) + + block_19: + c->gprs[v1].du64[0] = 0; // or v1, r0, r0 + c->lwu(v0, 20, sp); // lwu v0, 20(sp) + c->ld(ra, 0, sp); // ld ra, 0(sp) + c->lq(gp, 80, sp); // lq gp, 80(sp) + c->lq(s5, 64, sp); // lq s5, 64(sp) + c->lq(s4, 48, sp); // lq s4, 48(sp) + c->lq(s3, 32, sp); // lq s3, 32(sp) + //jr ra // jr ra + c->daddiu(sp, sp, 96); // daddiu sp, sp, 96 + 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.perf_stats = intern_from_c("*perf-stats*").c(); + gLinkedFunctionTable.reg("(method 31 sphere-hash)", execute, 128); +} + +} // namespace method_31_sphere_hash +} // 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 method_32_sphere_hash { +struct Cache { + void* perf_stats; // *perf-stats* + void* vector_vector_distance_squared; // vector-vector-distance-squared +} cache; + +u64 execute(void* ctxt) { + auto* c = (ExecutionContext*)ctxt; + bool bc = false; + u32 call_addr = 0; + bool cop1_bc = false; + c->daddiu(sp, sp, -192); // daddiu sp, sp, -192 + c->sd(ra, 0, sp); // sd ra, 0(sp) + c->sq(s0, 80, sp); // sq s0, 80(sp) + c->sq(s1, 96, sp); // sq s1, 96(sp) + c->sq(s2, 112, sp); // sq s2, 112(sp) + c->sq(s3, 128, sp); // sq s3, 128(sp) + c->sq(s4, 144, sp); // sq s4, 144(sp) + c->sq(s5, 160, sp); // sq s5, 160(sp) + c->sq(gp, 176, sp); // sq gp, 176(sp) + c->mov64(gp, a0); // or gp, a0, r0 + c->mov64(s5, t0); // or s5, t0, r0 + c->load_symbol2(v1, cache.perf_stats); // lw v1, *perf-stats*(s7) + c->daddiu(v1, v1, 116); // daddiu v1, v1, 116 + c->lwu(a0, 28, v1); // lwu a0, 28(v1) + c->lwu(t0, 4, v1); // lwu t0, 4(v1) + c->daddiu(t0, t0, 1); // daddiu t0, t0, 1 + c->sw(t0, 4, v1); // sw t0, 4(v1) + bc = c->sgpr64(a0) == 0; // beq a0, r0, L59 + // nop // sll r0, r0, 0 + if (bc) {goto block_2;} // branch non-likely + + // Unknown instr: mtc0 Perf, r0 + // Unknown instr: sync.l + // Unknown instr: sync.p + // Unknown instr: mtpc pcr0, r0 + // Unknown instr: mtpc pcr1, r0 + // Unknown instr: sync.l + // Unknown instr: sync.p + // Unknown instr: mtc0 Perf, a0 + // Unknown instr: sync.l + // Unknown instr: sync.p + + block_2: + c->gprs[v1].du64[0] = 0; // or v1, r0, r0 + c->sw(a1, 16, sp); // sw a1, 16(sp) + c->sw(a2, 20, sp); // sw a2, 20(sp) + c->mtc1(f0, a3); // mtc1 f0, a3 + c->swc1(f0, 24, sp); // swc1 f0, 24(sp) + c->mov64(a0, gp); // or a0, gp, r0 + c->lwu(v1, -4, a0); // lwu v1, -4(a0) + c->lwu(t9, 108, v1); // lwu t9, 108(v1) + c->daddiu(a1, gp, 4); // daddiu a1, gp, 4 + c->lwu(a2, 16, sp); // lwu a2, 16(sp) + c->lwu(a3, 20, sp); // lwu a3, 20(sp) + c->lw(t0, 24, sp); // lw t0, 24(sp) + 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(v1, v0); // or v1, v0, r0 + c->lwu(v1, 0, gp); // lwu v1, 0(gp) + c->daddiu(v1, v1, 12); // daddiu v1, v1, 12 + c->sw(v1, 28, sp); // sw v1, 28(sp) + c->mov64(a0, gp); // or a0, gp, r0 + c->lwu(v1, -4, a0); // lwu v1, -4(a0) + c->lwu(t9, 96, v1); // lwu t9, 96(v1) + c->daddiu(a1, gp, 4); // daddiu a1, gp, 4 + c->lwu(a2, 28, sp); // lwu a2, 28(sp) + 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(v1, v0); // or v1, v0, r0 + c->addiu(v1, r0, -1); // addiu v1, r0, -1 + bc = c->sgpr64(s5) == c->sgpr64(v1); // beq s5, v1, L61 + c->mov64(v1, s7); // or v1, s7, r0 + if (bc) {goto block_7;} // branch non-likely + + c->dsra(v1, s5, 3); // dsra v1, s5, 3 + c->andi(a1, s5, 7); // andi a1, s5, 7 + c->addiu(a0, r0, 1); // addiu a0, r0, 1 + if (((s64)c->sgpr64(a1)) >= 0) { // bgezl a1, L60 + c->dsllv(a0, a0, a1); // dsllv a0, a0, a1 + goto block_6; + } + + block_5: + c->dsubu(a1, r0, a1); // dsubu a1, r0, a1 + c->dsrav(a0, a0, a1); // dsrav a0, a0, a1 + + block_6: + c->nor(a0, a0, r0); // nor a0, a0, r0 + c->lwu(a1, 28, sp); // lwu a1, 28(sp) + c->daddu(a1, a1, v1); // daddu a1, a1, v1 + c->lbu(a1, 0, a1); // lbu a1, 0(a1) + c->and_(a0, a1, a0); // and a0, a1, a0 + c->lwu(a1, 28, sp); // lwu a1, 28(sp) + c->daddu(v1, a1, v1); // daddu v1, a1, v1 + c->sb(a0, 0, v1); // sb a0, 0(v1) + + block_7: + c->daddiu(v1, s7, 4); // daddiu v1, s7, #t + c->sw(v1, 48, sp); // sw v1, 48(sp) + c->daddiu(v1, sp, 32); // daddiu v1, sp, 32 + c->sw(v1, 52, sp); // sw v1, 52(sp) + c->mtc1(f0, r0); // mtc1 f0, r0 + c->swc1(f0, 56, sp); // swc1 f0, 56(sp) + c->lwu(v1, 20, sp); // lwu v1, 20(sp) + c->lqc2(vf1, 0, v1); // lqc2 vf1, 0(v1) + c->vadd_bc(DEST::x, BC::w, vf2, vf0, vf0); // vaddw.x vf2, vf0, vf0 + c->vmul(DEST::xyzw, vf1, vf1, vf1); // vmul.xyzw vf1, vf1, vf1 + c->vmula_bc(DEST::x, BC::x, vf2, vf1); // vmulax.x acc, vf2, vf1 + c->vmadda_bc(DEST::x, BC::y, vf2, vf1); // vmadday.x acc, vf2, vf1 + c->vmadd_bc(DEST::x, BC::z, vf1, vf2, vf1); // vmaddz.x vf1, vf2, vf1 + c->mov128_gpr_vf(v1, vf1); // qmfc2.i v1, vf1 + c->mtc1(f0, v1); // mtc1 f0, v1 + c->mtc1(f1, r0); // mtc1 f1, r0 + cop1_bc = c->fprs[f1] < c->fprs[f0]; // c.lt.s f1, f0 + bc = !cop1_bc; // bc1f L62 + c->mov64(v1, s7); // or v1, s7, r0 + if (bc) {goto block_9;} // branch non-likely + + c->lui(v1, 16256); // lui v1, 16256 + c->mtc1(f1, v1); // mtc1 f1, v1 + c->divs(f0, f1, f0); // div.s f0, f1, f0 + c->mfc1(v1, f0); // mfc1 v1, f0 + c->mtc1(f0, v1); // mtc1 f0, v1 + c->swc1(f0, 56, sp); // swc1 f0, 56(sp) + c->mfc1(v1, f0); // mfc1 v1, f0 + + block_9: + c->lh(s5, 10, gp); // lh s5, 10(gp) + c->lwu(s4, 28, sp); // lwu s4, 28(sp) + c->gprs[s3].du64[0] = 0; // or s3, r0, r0 + // nop // sll r0, r0, 0 + + block_10: + c->dsll(s2, s3, 3); // dsll s2, s3, 3 + c->lbu(s1, 0, s4); // lbu s1, 0(s4) + bc = c->sgpr64(s1) == 0; // beq s1, r0, L66 + // nop // sll r0, r0, 0 + if (bc) {goto block_16;} // branch non-likely + + + block_11: + c->andi(v1, s1, 1); // andi v1, s1, 1 + // nop // sll r0, r0, 0 + bc = c->sgpr64(v1) == 0; // beq v1, r0, L65 + // nop // sll r0, r0, 0 + if (bc) {goto block_15;} // branch non-likely + + c->lwu(v1, 84, gp); // lwu v1, 84(gp) + c->dsll(a0, s2, 4); // dsll a0, s2, 4 + c->daddu(s0, v1, a0); // daddu s0, v1, a0 + c->daddiu(v1, sp, 64); // daddiu v1, sp, 64 + c->mov64(a2, v1); // or a2, v1, r0 + c->mov64(a0, s0); // or a0, s0, r0 + c->lwu(a1, 16, sp); // lwu a1, 16(sp) + c->lqc2(vf4, 0, a0); // lqc2 vf4, 0(a0) + c->lqc2(vf5, 0, a1); // lqc2 vf5, 0(a1) + c->vmove(DEST::w, vf6, vf0); // vmove.w vf6, vf0 + c->vsub(DEST::xyz, vf6, vf4, vf5); // vsub.xyz vf6, vf4, vf5 + c->sqc2(vf6, 0, a2); // sqc2 vf6, 0(a2) + c->lwu(a0, 20, sp); // lwu a0, 20(sp) + c->lwc1(f0, 0, a0); // lwc1 f0, 0(a0) + c->lwc1(f1, 4, a0); // lwc1 f1, 4(a0) + c->lwc1(f2, 8, a0); // lwc1 f2, 8(a0) + c->lwc1(f3, 0, v1); // lwc1 f3, 0(v1) + c->lwc1(f4, 4, v1); // lwc1 f4, 4(v1) + c->lwc1(f5, 8, v1); // lwc1 f5, 8(v1) + // Unknown instr: mula.s f0, f3 + // Unknown instr: madda.s f1, f4 + // Unknown instr: madd.s f0, f2, f5 + c->fprs[f0] = (c->fprs[f0] * c->fprs[f3]) + (c->fprs[f1] * c->fprs[f4]) + (c->fprs[f2] * c->fprs[f5]); + c->mfc1(v1, f0); // mfc1 v1, f0 + c->mtc1(f0, v1); // mtc1 f0, v1 + c->lw(v1, 56, sp); // lw v1, 56(sp) + c->mtc1(f1, v1); // mtc1 f1, v1 + c->muls(f1, f0, f1); // mul.s f1, f0, f1 + c->mtc1(f0, r0); // mtc1 f0, r0 + c->lui(v1, 16256); // lui v1, 16256 + c->mtc1(f2, v1); // mtc1 f2, v1 + c->mins(f1, f2, f1); // min.s f1, f2, f1 + c->maxs(f0, f0, f1); // max.s f0, f0, f1 + c->lwu(v1, 52, sp); // lwu v1, 52(sp) + c->lwu(a0, 16, sp); // lwu a0, 16(sp) + c->lwu(a1, 20, sp); // lwu a1, 20(sp) + c->lqc2(vf2, 0, a1); // lqc2 vf2, 0(a1) + c->lqc2(vf1, 0, a0); // lqc2 vf1, 0(a0) + c->mfc1(a0, f0); // mfc1 a0, f0 + c->mov128_vf_gpr(vf3, a0); // qmtc2.i vf3, a0 + c->vadd_bc(DEST::w, BC::x, vf4, vf0, vf0); // vaddx.w vf4, vf0, vf0 + c->vmula_bc(DEST::xyzw, BC::x, vf2, vf3); // vmulax.xyzw acc, vf2, vf3 + c->vmadd_bc(DEST::xyz, BC::w, vf4, vf1, vf0); // vmaddw.xyz vf4, vf1, vf0 + c->sqc2(vf4, 0, v1); // sqc2 vf4, 0(v1) + c->load_symbol2(t9, cache.vector_vector_distance_squared);// lw t9, vector-vector-distance-squared(s7) + c->lwu(a0, 52, sp); // lwu a0, 52(sp) + c->mov64(a1, s0); // or a1, s0, 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->mtc1(f0, v0); // mtc1 f0, v0 + c->lw(v1, 24, sp); // lw v1, 24(sp) + c->mtc1(f1, v1); // mtc1 f1, v1 + c->lwc1(f2, 12, s0); // lwc1 f2, 12(s0) + c->adds(f1, f1, f2); // add.s f1, f1, f2 + c->muls(f1, f1, f1); // mul.s f1, f1, f1 + c->mfc1(v1, f1); // mfc1 v1, f1 + c->mtc1(f1, v1); // mtc1 f1, v1 + cop1_bc = c->fprs[f0] < c->fprs[f1]; // c.lt.s f0, f1 + bc = !cop1_bc; // bc1f L65 + c->mov64(v1, s7); // or v1, s7, r0 + if (bc) {goto block_15;} // branch non-likely + + //beq r0, r0, L67 // beq r0, r0, L67 + // nop // sll r0, r0, 0 + goto block_18; // branch always + + // nop // sll r0, r0, 0 + + block_15: + c->dsra(s1, s1, 1); // dsra s1, s1, 1 + // nop // sll r0, r0, 0 + bc = c->sgpr64(s1) != 0; // bne s1, r0, L64 + c->daddiu(s2, s2, 1); // daddiu s2, s2, 1 + if (bc) {goto block_11;} // branch non-likely + + + block_16: + c->daddiu(s3, s3, 1); // daddiu s3, s3, 1 + c->daddiu(s4, s4, 1); // daddiu s4, s4, 1 + c->slt(v1, s3, s5); // slt v1, s3, s5 + // nop // sll r0, r0, 0 + bc = c->sgpr64(v1) != 0; // bne v1, r0, L63 + // nop // sll r0, r0, 0 + if (bc) {goto block_10;} // branch non-likely + + c->sw(s7, 48, sp); // sw s7, 48(sp) + + block_18: + c->load_symbol2(v1, cache.perf_stats); // lw v1, *perf-stats*(s7) + c->daddiu(v1, v1, 116); // daddiu v1, v1, 116 + c->lwu(a0, 28, v1); // lwu a0, 28(v1) + bc = c->sgpr64(a0) == 0; // beq a0, r0, L68 + // nop // sll r0, r0, 0 + if (bc) {goto block_20;} // branch non-likely + + // Unknown instr: mtc0 Perf, r0 + // Unknown instr: sync.l + // Unknown instr: sync.p + // Unknown instr: mfpc a0, pcr0 + c->lwu(a1, 32, v1); // lwu a1, 32(v1) + c->daddu(a0, a1, a0); // daddu a0, a1, a0 + c->sw(a0, 32, v1); // sw a0, 32(v1) + // Unknown instr: mfpc a0, pcr1 + c->lwu(a1, 36, v1); // lwu a1, 36(v1) + c->daddu(a0, a1, a0); // daddu a0, a1, a0 + c->sw(a0, 36, v1); // sw a0, 36(v1) + + block_20: + c->gprs[v1].du64[0] = 0; // or v1, r0, r0 + c->lwu(v0, 48, sp); // lwu v0, 48(sp) + c->ld(ra, 0, sp); // ld ra, 0(sp) + c->lq(gp, 176, sp); // lq gp, 176(sp) + c->lq(s5, 160, sp); // lq s5, 160(sp) + c->lq(s4, 144, sp); // lq s4, 144(sp) + c->lq(s3, 128, sp); // lq s3, 128(sp) + c->lq(s2, 112, sp); // lq s2, 112(sp) + c->lq(s1, 96, sp); // lq s1, 96(sp) + c->lq(s0, 80, sp); // lq s0, 80(sp) + //jr ra // jr ra + c->daddiu(sp, sp, 192); // daddiu sp, sp, 192 + 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.perf_stats = intern_from_c("*perf-stats*").c(); + cache.vector_vector_distance_squared = intern_from_c("vector-vector-distance-squared").c(); + gLinkedFunctionTable.reg("(method 32 sphere-hash)", execute, 256); +} + +} // namespace method_32_sphere_hash +} // 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 method_33_spatial_hash { +u64 execute(void* ctxt) { + auto* c = (ExecutionContext*)ctxt; + bool bc = false; + u32 call_addr = 0; + c->daddiu(sp, sp, -48); // daddiu sp, sp, -48 + c->sd(ra, 0, sp); // sd ra, 0(sp) + c->sq(s5, 16, sp); // sq s5, 16(sp) + c->sq(gp, 32, sp); // sq gp, 32(sp) + c->mov64(gp, a0); // or gp, a0, r0 + c->mov64(s5, a2); // or s5, a2, r0 + c->mov64(a0, gp); // or a0, gp, r0 + c->lwu(v1, -4, a0); // lwu v1, -4(a0) + c->lwu(t9, 104, v1); // lwu t9, 104(v1) + c->daddiu(v1, gp, 4); // daddiu v1, gp, 4 + c->mov64(a2, a1); // or a2, a1, r0 + c->mov64(a1, v1); // or a1, v1, 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(v1, v0); // or v1, v0, r0 + c->mov64(t1, gp); // or t1, gp, r0 + c->daddiu(t2, gp, 4); // daddiu t2, gp, 4 + c->mov64(t0, s5); // or t0, s5, r0 + c->lh(v1, 10, t1); // lh v1, 10(t1) + c->lb(a0, 24, t1); // lb a0, 24(t1) + c->mult3(a0, a0, v1); // mult3 a0, a0, v1 + c->lb(a1, 26, t1); // lb a1, 26(t1) + c->mult3(a1, a1, a0); // mult3 a1, a1, a0 + c->addiu(a2, r0, 1); // addiu a2, r0, 1 + c->lb(a3, 0, t2); // lb a3, 0(t2) + c->dsubu(a2, a2, a3); // dsubu a2, a2, a3 + c->lb(a3, 3, t2); // lb a3, 3(t2) + c->daddu(a2, a2, a3); // daddu a2, a2, a3 + c->addiu(a3, r0, 1); // addiu a3, r0, 1 + c->lb(t3, 2, t2); // lb t3, 2(t2) + c->dsubu(a3, a3, t3); // dsubu a3, a3, t3 + c->lb(t3, 5, t2); // lb t3, 5(t2) + c->daddu(a3, a3, t3); // daddu a3, a3, t3 + c->addiu(t3, r0, 1); // addiu t3, r0, 1 + c->lb(t4, 1, t2); // lb t4, 1(t2) + c->dsubu(t3, t3, t4); // dsubu t3, t3, t4 + c->lb(t4, 4, t2); // lb t4, 4(t2) + c->daddu(t3, t3, t4); // daddu t3, t3, t4 + c->lb(t4, 0, t2); // lb t4, 0(t2) + c->mult3(t4, t4, v1); // mult3 t4, t4, v1 + c->lb(t5, 1, t2); // lb t5, 1(t2) + c->mult3(t5, t5, a1); // mult3 t5, t5, a1 + c->daddu(t4, t4, t5); // daddu t4, t4, t5 + c->lb(t2, 2, t2); // lb t2, 2(t2) + c->mult3(t2, t2, a0); // mult3 t2, t2, a0 + c->daddu(t2, t4, t2); // daddu t2, t4, t2 + c->dsra(t4, t0, 3); // dsra t4, t0, 3 + c->daddu(t2, t2, t4); // daddu t2, t2, t4 + c->daddu(t2, r0, t2); // daddu t2, r0, t2 + c->lwu(t1, 28, t1); // lwu t1, 28(t1) + c->daddu(t1, t2, t1); // daddu t1, t2, t1 + c->addiu(t2, r0, 1); // addiu t2, r0, 1 + c->andi(t0, t0, 7); // andi t0, t0, 7 + if (((s64)c->sgpr64(t0)) >= 0) { // bgezl t0, L45 + c->dsllv(t0, t2, t0); // dsllv t0, t2, t0 + goto block_3; + } + + block_2: + c->dsubu(t0, r0, t0); // dsubu t0, r0, t0 + c->dsrav(t0, t2, t0); // dsrav t0, t2, t0 + + block_3: + c->nor(t0, t0, r0); // nor t0, t0, r0 + c->mov64(t2, t3); // or t2, t3, r0 + + block_4: + c->mov64(t3, a3); // or t3, a3, r0 + c->mov64(t4, t1); // or t4, t1, r0 + + block_5: + c->mov64(t5, a2); // or t5, a2, r0 + c->mov64(t6, t4); // or t6, t4, r0 + + block_6: + // nop // sll r0, r0, 0 + c->lbu(t7, 0, t6); // lbu t7, 0(t6) + // nop // sll r0, r0, 0 + c->and_(t7, t7, t0); // and t7, t7, t0 + c->daddiu(t5, t5, -1); // daddiu t5, t5, -1 + c->sb(t7, 0, t6); // sb t7, 0(t6) + bc = c->sgpr64(t5) != 0; // bne t5, r0, L48 + c->daddu(t6, t6, v1); // daddu t6, t6, v1 + if (bc) {goto block_6;} // branch non-likely + + c->daddiu(t3, t3, -1); // daddiu t3, t3, -1 + // nop // sll r0, r0, 0 + bc = c->sgpr64(t3) != 0; // bne t3, r0, L47 + c->daddu(t4, t4, a0); // daddu t4, t4, a0 + if (bc) {goto block_5;} // branch non-likely + + c->daddiu(t2, t2, -1); // daddiu t2, t2, -1 + // nop // sll r0, r0, 0 + bc = c->sgpr64(t2) != 0; // bne t2, r0, L46 + c->daddu(t1, t1, a1); // daddu t1, t1, a1 + if (bc) {goto block_4;} // branch non-likely + + c->gprs[v1].du64[0] = 0; // or v1, r0, r0 + c->dsll(v1, s5, 4); // dsll v1, s5, 4 + c->lwu(a0, 100, gp); // lwu a0, 100(gp) + c->daddu(v1, v1, a0); // daddu v1, v1, a0 + c->sw(s7, 0, v1); // sw s7, 0(v1) + c->gprs[v0].du64[0] = 0; // or v0, r0, r0 + c->ld(ra, 0, sp); // ld ra, 0(sp) + c->lq(gp, 32, sp); // lq gp, 32(sp) + c->lq(s5, 16, sp); // lq s5, 16(sp) + //jr ra // jr ra + c->daddiu(sp, sp, 48); // daddiu sp, sp, 48 + 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() { + gLinkedFunctionTable.reg("(method 33 spatial-hash)", execute, 128); +} + +} // namespace method_33_spatial_hash +} // 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 method_39_spatial_hash { +struct Cache { + void* mem_copy; // mem-copy! +} cache; + +u64 execute(void* ctxt) { + auto* c = (ExecutionContext*)ctxt; + bool bc = false; + u32 call_addr = 0; + c->daddiu(sp, sp, -96); // daddiu sp, sp, -96 + c->sd(ra, 0, sp); // sd ra, 0(sp) + c->sq(s2, 16, sp); // sq s2, 16(sp) + c->sq(s3, 32, sp); // sq s3, 32(sp) + c->sq(s4, 48, sp); // sq s4, 48(sp) + c->sq(s5, 64, sp); // sq s5, 64(sp) + c->sq(gp, 80, sp); // sq gp, 80(sp) + c->mov64(s5, a0); // or s5, a0, r0 + c->mov64(s4, a2); // or s4, a2, r0 + c->lh(gp, 56, s5); // lh gp, 56(s5) + c->lh(v1, 88, s5); // lh v1, 88(s5) + c->slt(v1, gp, v1); // slt v1, gp, v1 + bc = c->sgpr64(v1) == 0; // beq v1, r0, L37 + // nop // sll r0, r0, 0 + if (bc) {goto block_11;} // branch non-likely + + c->lwu(v1, 84, s5); // lwu v1, 84(s5) + c->dsll(a0, gp, 4); // dsll a0, gp, 4 + c->daddu(s3, v1, a0); // daddu s3, v1, a0 + c->lwu(v1, 100, s5); // lwu v1, 100(s5) + c->dsll(a0, gp, 4); // dsll a0, gp, 4 + c->daddu(s2, v1, a0); // daddu s2, v1, a0 + c->load_symbol2(t9, cache.mem_copy); // lw t9, mem-copy!(s7) + c->mov64(a0, s3); // or a0, s3, r0 + c->addiu(a2, r0, 16); // addiu a2, r0, 16 + 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->sw(s4, 0, s2); // sw s4, 0(s2) + c->mov64(a0, s5); // or a0, s5, r0 + c->lwu(v1, -4, a0); // lwu v1, -4(a0) + c->lwu(t9, 104, v1); // lwu t9, 104(v1) + c->daddiu(a1, s5, 4); // daddiu a1, s5, 4 + c->mov64(a2, s3); // or a2, s3, 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(v1, v0); // or v1, v0, r0 + c->mov64(t1, s5); // or t1, s5, r0 + c->daddiu(t2, s5, 4); // daddiu t2, s5, 4 + c->mov64(a3, gp); // or a3, gp, r0 + c->lh(v1, 10, t1); // lh v1, 10(t1) + c->lb(a0, 24, t1); // lb a0, 24(t1) + c->mult3(a0, a0, v1); // mult3 a0, a0, v1 + c->lb(a1, 26, t1); // lb a1, 26(t1) + c->mult3(a1, a1, a0); // mult3 a1, a1, a0 + c->addiu(a2, r0, 1); // addiu a2, r0, 1 + c->lb(t0, 0, t2); // lb t0, 0(t2) + c->dsubu(a2, a2, t0); // dsubu a2, a2, t0 + c->lb(t0, 3, t2); // lb t0, 3(t2) + c->daddu(a2, a2, t0); // daddu a2, a2, t0 + c->addiu(t0, r0, 1); // addiu t0, r0, 1 + c->lb(t3, 2, t2); // lb t3, 2(t2) + c->dsubu(t0, t0, t3); // dsubu t0, t0, t3 + c->lb(t3, 5, t2); // lb t3, 5(t2) + c->daddu(t0, t0, t3); // daddu t0, t0, t3 + c->addiu(t3, r0, 1); // addiu t3, r0, 1 + c->lb(t4, 1, t2); // lb t4, 1(t2) + c->dsubu(t3, t3, t4); // dsubu t3, t3, t4 + c->lb(t4, 4, t2); // lb t4, 4(t2) + c->daddu(t3, t3, t4); // daddu t3, t3, t4 + c->lb(t4, 0, t2); // lb t4, 0(t2) + c->mult3(t4, t4, v1); // mult3 t4, t4, v1 + c->lb(t5, 1, t2); // lb t5, 1(t2) + c->mult3(t5, t5, a1); // mult3 t5, t5, a1 + c->daddu(t4, t4, t5); // daddu t4, t4, t5 + c->lb(t2, 2, t2); // lb t2, 2(t2) + c->mult3(t2, t2, a0); // mult3 t2, t2, a0 + c->daddu(t2, t4, t2); // daddu t2, t4, t2 + c->dsra(t4, a3, 3); // dsra t4, a3, 3 + c->daddu(t2, t2, t4); // daddu t2, t2, t4 + c->daddu(t2, r0, t2); // daddu t2, r0, t2 + c->lwu(t1, 28, t1); // lwu t1, 28(t1) + c->daddu(t1, t2, t1); // daddu t1, t2, t1 + c->addiu(t2, r0, 1); // addiu t2, r0, 1 + c->andi(a3, a3, 7); // andi a3, a3, 7 + if (((s64)c->sgpr64(a3)) >= 0) { // bgezl a3, L33 + c->dsllv(a3, t2, a3); // dsllv a3, t2, a3 + goto block_4; + } + + block_3: + c->dsubu(a3, r0, a3); // dsubu a3, r0, a3 + c->dsrav(a3, t2, a3); // dsrav a3, t2, a3 + + block_4: + c->mov64(t2, t3); // or t2, t3, r0 + + block_5: + c->mov64(t3, t0); // or t3, t0, r0 + c->mov64(t4, t1); // or t4, t1, r0 + + block_6: + c->mov64(t5, a2); // or t5, a2, r0 + c->mov64(t6, t4); // or t6, t4, r0 + + block_7: + // nop // sll r0, r0, 0 + c->lbu(t7, 0, t6); // lbu t7, 0(t6) + // nop // sll r0, r0, 0 + c->or_(t7, t7, a3); // or t7, t7, a3 + c->daddiu(t5, t5, -1); // daddiu t5, t5, -1 + c->sb(t7, 0, t6); // sb t7, 0(t6) + bc = c->sgpr64(t5) != 0; // bne t5, r0, L36 + c->daddu(t6, t6, v1); // daddu t6, t6, v1 + if (bc) {goto block_7;} // branch non-likely + + c->daddiu(t3, t3, -1); // daddiu t3, t3, -1 + // nop // sll r0, r0, 0 + bc = c->sgpr64(t3) != 0; // bne t3, r0, L35 + c->daddu(t4, t4, a0); // daddu t4, t4, a0 + if (bc) {goto block_6;} // branch non-likely + + c->daddiu(t2, t2, -1); // daddiu t2, t2, -1 + // nop // sll r0, r0, 0 + bc = c->sgpr64(t2) != 0; // bne t2, r0, L34 + c->daddu(t1, t1, a1); // daddu t1, t1, a1 + if (bc) {goto block_5;} // branch non-likely + + c->gprs[v1].du64[0] = 0; // or v1, r0, r0 + c->lh(v1, 56, s5); // lh v1, 56(s5) + c->daddiu(v1, v1, 1); // daddiu v1, v1, 1 + c->sh(v1, 56, s5); // sh v1, 56(s5) + //beq r0, r0, L38 // beq r0, r0, L38 + // nop // sll r0, r0, 0 + goto block_12; // branch always + + + block_11: + c->addiu(gp, r0, -1); // addiu gp, r0, -1 + c->mov64(v1, gp); // or v1, gp, r0 + + block_12: + c->mov64(v0, gp); // or v0, gp, r0 + c->ld(ra, 0, sp); // ld ra, 0(sp) + c->lq(gp, 80, sp); // lq gp, 80(sp) + c->lq(s5, 64, sp); // lq s5, 64(sp) + c->lq(s4, 48, sp); // lq s4, 48(sp) + c->lq(s3, 32, sp); // lq s3, 32(sp) + c->lq(s2, 16, sp); // lq s2, 16(sp) + //jr ra // jr ra + c->daddiu(sp, sp, 96); // daddiu sp, sp, 96 + 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.mem_copy = intern_from_c("mem-copy!").c(); + gLinkedFunctionTable.reg("(method 39 spatial-hash)", execute, 128); +} + +} // namespace method_39_spatial_hash +} // 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 method_36_spatial_hash { +struct Cache { + void* perf_stats; // *perf-stats* +} cache; + +u64 execute(void* ctxt) { + auto* c = (ExecutionContext*)ctxt; + bool bc = false; + u32 call_addr = 0; + bool cop1_bc = false; + c->daddiu(sp, sp, -112); // daddiu sp, sp, -112 + c->sd(ra, 0, sp); // sd ra, 0(sp) + c->sq(s3, 48, sp); // sq s3, 48(sp) + c->sq(s4, 64, sp); // sq s4, 64(sp) + c->sq(s5, 80, sp); // sq s5, 80(sp) + c->sq(gp, 96, sp); // sq gp, 96(sp) + c->mov64(s5, a0); // or s5, a0, r0 + c->mov64(gp, a1); // or gp, a1, r0 + c->mov64(s4, a2); // or s4, a2, r0 + c->mov64(s3, a3); // or s3, a3, r0 + c->load_symbol2(v1, cache.perf_stats); // lw v1, *perf-stats*(s7) + c->daddiu(v1, v1, 116); // daddiu v1, v1, 116 + c->lwu(a0, 28, v1); // lwu a0, 28(v1) + c->lwu(a1, 4, v1); // lwu a1, 4(v1) + c->daddiu(a1, a1, 1); // daddiu a1, a1, 1 + c->sw(a1, 4, v1); // sw a1, 4(v1) + bc = c->sgpr64(a0) == 0; // beq a0, r0, L26 + // nop // sll r0, r0, 0 + if (bc) {goto block_2;} // branch non-likely + + // Unknown instr: mtc0 Perf, r0 + // Unknown instr: sync.l + // Unknown instr: sync.p + // Unknown instr: mtpc pcr0, r0 + // Unknown instr: mtpc pcr1, r0 + // Unknown instr: sync.l + // Unknown instr: sync.p + // Unknown instr: mtc0 Perf, a0 + // Unknown instr: sync.l + // Unknown instr: sync.p + + block_2: + c->gprs[v1].du64[0] = 0; // or v1, r0, r0 + c->mov64(a0, s5); // or a0, s5, r0 + c->lwu(v1, -4, a0); // lwu v1, -4(a0) + c->lwu(t9, 104, v1); // lwu t9, 104(v1) + c->daddiu(a1, s5, 4); // daddiu a1, s5, 4 + c->mov64(a2, gp); // or a2, gp, 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(v1, v0); // or v1, v0, r0 + c->lwu(v1, 0, s5); // lwu v1, 0(s5) + c->daddiu(v1, v1, 12); // daddiu v1, v1, 12 + c->sw(v1, 16, sp); // sw v1, 16(sp) + c->mov64(a0, s5); // or a0, s5, r0 + c->lwu(v1, -4, a0); // lwu v1, -4(a0) + c->lwu(t9, 96, v1); // lwu t9, 96(v1) + c->daddiu(a1, s5, 4); // daddiu a1, s5, 4 + c->lwu(a2, 16, sp); // lwu a2, 16(sp) + 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(v1, v0); // or v1, v0, r0 + c->sd(r0, 24, sp); // sd r0, 24(sp) + c->sw(s5, 32, sp); // sw s5, 32(sp) + c->sw(s4, 36, sp); // sw s4, 36(sp) + c->sd(s3, 40, sp); // sd s3, 40(sp) + c->lwu(v1, 32, sp); // lwu v1, 32(sp) + c->lh(v1, 10, v1); // lh v1, 10(v1) + c->lwu(a0, 16, sp); // lwu a0, 16(sp) + c->gprs[a1].du64[0] = 0; // or a1, r0, r0 + // nop // sll r0, r0, 0 + + block_3: + c->dsll(a2, a1, 3); // dsll a2, a1, 3 + c->lbu(a3, 0, a0); // lbu a3, 0(a0) + bc = c->sgpr64(a3) == 0; // beq a3, r0, L30 + // nop // sll r0, r0, 0 + if (bc) {goto block_9;} // branch non-likely + + + block_4: + c->andi(t0, a3, 1); // andi t0, a3, 1 + // nop // sll r0, r0, 0 + bc = c->sgpr64(t0) == 0; // beq t0, r0, L29 + // nop // sll r0, r0, 0 + if (bc) {goto block_8;} // branch non-likely + + c->lwu(t0, 32, sp); // lwu t0, 32(sp) + c->lwu(t0, 84, t0); // lwu t0, 84(t0) + c->dsll(t1, a2, 4); // dsll t1, a2, 4 + c->daddu(t0, t0, t1); // daddu t0, t0, t1 + c->mov64(t1, gp); // or t1, gp, r0 + c->mov64(t2, t0); // or t2, t0, r0 + c->lqc2(vf2, 0, t1); // lqc2 vf2, 0(t1) + c->lqc2(vf3, 0, t2); // lqc2 vf3, 0(t2) + c->vsub(DEST::xyzw, vf1, vf3, vf2); // vsub.xyzw vf1, vf3, vf2 + c->vmul(DEST::xyzw, vf1, vf1, vf1); // vmul.xyzw vf1, vf1, vf1 + c->vadd_bc(DEST::x, BC::y, vf1, vf1, vf1); // vaddy.x vf1, vf1, vf1 + c->vadd_bc(DEST::x, BC::z, vf1, vf1, vf1); // vaddz.x vf1, vf1, vf1 + c->mov128_gpr_vf(t1, vf1); // qmfc2.i t1, vf1 + c->mtc1(f0, t1); // mtc1 f0, t1 + c->lwc1(f1, 12, gp); // lwc1 f1, 12(gp) + c->lwc1(f2, 12, t0); // lwc1 f2, 12(t0) + c->adds(f1, f1, f2); // add.s f1, f1, f2 + c->muls(f1, f1, f1); // mul.s f1, f1, f1 + c->mfc1(t0, f1); // mfc1 t0, f1 + c->mtc1(f1, t0); // mtc1 f1, t0 + cop1_bc = c->fprs[f0] < c->fprs[f1]; // c.lt.s f0, f1 + bc = !cop1_bc; // bc1f L29 + c->mov64(t0, s7); // or t0, s7, r0 + if (bc) {goto block_8;} // branch non-likely + + c->ld(t0, 24, sp); // ld t0, 24(sp) + c->ld(t1, 40, sp); // ld t1, 40(sp) + c->slt(t0, t0, t1); // slt t0, t0, t1 + bc = c->sgpr64(t0) == 0; // beq t0, r0, L29 + c->mov64(t0, s7); // or t0, s7, r0 + if (bc) {goto block_8;} // branch non-likely + + c->dsll(t0, a2, 4); // dsll t0, a2, 4 + c->lwu(t1, 32, sp); // lwu t1, 32(sp) + c->lwu(t1, 100, t1); // lwu t1, 100(t1) + c->daddu(t0, t0, t1); // daddu t0, t0, t1 + c->lwu(t0, 0, t0); // lwu t0, 0(t0) + c->lwu(t1, 36, sp); // lwu t1, 36(sp) + c->ld(t2, 24, sp); // ld t2, 24(sp) + c->dsll(t2, t2, 2); // dsll t2, t2, 2 + c->daddu(t1, t1, t2); // daddu t1, t1, t2 + c->sw(t0, 0, t1); // sw t0, 0(t1) + c->ld(t0, 24, sp); // ld t0, 24(sp) + c->daddiu(t0, t0, 1); // daddiu t0, t0, 1 + c->sd(t0, 24, sp); // sd t0, 24(sp) + // nop // sll r0, r0, 0 + + block_8: + c->dsra(a3, a3, 1); // dsra a3, a3, 1 + // nop // sll r0, r0, 0 + bc = c->sgpr64(a3) != 0; // bne a3, r0, L28 + c->daddiu(a2, a2, 1); // daddiu a2, a2, 1 + if (bc) {goto block_4;} // branch non-likely + + + block_9: + c->daddiu(a1, a1, 1); // daddiu a1, a1, 1 + c->daddiu(a0, a0, 1); // daddiu a0, a0, 1 + c->slt(a2, a1, v1); // slt a2, a1, v1 + // nop // sll r0, r0, 0 + bc = c->sgpr64(a2) != 0; // bne a2, r0, L27 + // nop // sll r0, r0, 0 + if (bc) {goto block_3;} // branch non-likely + + c->load_symbol2(v1, cache.perf_stats); // lw v1, *perf-stats*(s7) + c->daddiu(v1, v1, 116); // daddiu v1, v1, 116 + c->lwu(a0, 28, v1); // lwu a0, 28(v1) + bc = c->sgpr64(a0) == 0; // beq a0, r0, L31 + // nop // sll r0, r0, 0 + if (bc) {goto block_12;} // branch non-likely + + // Unknown instr: mtc0 Perf, r0 + // Unknown instr: sync.l + // Unknown instr: sync.p + // Unknown instr: mfpc a0, pcr0 + c->lwu(a1, 32, v1); // lwu a1, 32(v1) + c->daddu(a0, a1, a0); // daddu a0, a1, a0 + c->sw(a0, 32, v1); // sw a0, 32(v1) + // Unknown instr: mfpc a0, pcr1 + c->lwu(a1, 36, v1); // lwu a1, 36(v1) + c->daddu(a0, a1, a0); // daddu a0, a1, a0 + c->sw(a0, 36, v1); // sw a0, 36(v1) + + block_12: + c->gprs[v1].du64[0] = 0; // or v1, r0, r0 + c->ld(v0, 24, sp); // ld v0, 24(sp) + c->ld(ra, 0, sp); // ld ra, 0(sp) + c->lq(gp, 96, sp); // lq gp, 96(sp) + c->lq(s5, 80, sp); // lq s5, 80(sp) + c->lq(s4, 64, sp); // lq s4, 64(sp) + c->lq(s3, 48, sp); // lq s3, 48(sp) + //jr ra // jr ra + c->daddiu(sp, sp, 112); // daddiu sp, sp, 112 + 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.perf_stats = intern_from_c("*perf-stats*").c(); + gLinkedFunctionTable.reg("(method 36 spatial-hash)", execute, 256); +} + +} // namespace method_36_spatial_hash +} // 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 method_37_spatial_hash { +struct Cache { + void* vector_vector_distance_squared; // vector-vector-distance-squared +} cache; + +u64 execute(void* ctxt) { + auto* c = (ExecutionContext*)ctxt; + bool bc = false; + u32 call_addr = 0; + bool cop1_bc = false; + c->daddiu(sp, sp, -208); // daddiu sp, sp, -208 + c->sd(ra, 0, sp); // sd ra, 0(sp) + c->sq(s1, 112, sp); // sq s1, 112(sp) + c->sq(s2, 128, sp); // sq s2, 128(sp) + c->sq(s3, 144, sp); // sq s3, 144(sp) + c->sq(s4, 160, sp); // sq s4, 160(sp) + c->sq(s5, 176, sp); // sq s5, 176(sp) + c->sq(gp, 192, sp); // sq gp, 192(sp) + c->mov64(gp, a0); // or gp, a0, r0 + c->mov64(s5, t2); // or s5, t2, r0 + c->sw(a1, 16, sp); // sw a1, 16(sp) + c->sw(a2, 20, sp); // sw a2, 20(sp) + c->mtc1(f0, a3); // mtc1 f0, a3 + c->swc1(f0, 24, sp); // swc1 f0, 24(sp) + c->sw(t0, 28, sp); // sw t0, 28(sp) + c->sd(t1, 32, sp); // sd t1, 32(sp) + c->mov64(a0, gp); // or a0, gp, r0 + c->lwu(v1, -4, a0); // lwu v1, -4(a0) + c->lwu(t9, 108, v1); // lwu t9, 108(v1) + c->daddiu(a1, gp, 4); // daddiu a1, gp, 4 + c->lwu(a2, 16, sp); // lwu a2, 16(sp) + c->lwu(a3, 20, sp); // lwu a3, 20(sp) + c->lw(t0, 24, sp); // lw t0, 24(sp) + 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(v1, v0); // or v1, v0, r0 + c->lwu(v1, 0, gp); // lwu v1, 0(gp) + c->daddiu(v1, v1, 12); // daddiu v1, v1, 12 + c->sw(v1, 40, sp); // sw v1, 40(sp) + c->mov64(a0, gp); // or a0, gp, r0 + c->lwu(v1, -4, a0); // lwu v1, -4(a0) + c->lwu(t9, 96, v1); // lwu t9, 96(v1) + c->daddiu(a1, gp, 4); // daddiu a1, gp, 4 + c->lwu(a2, 40, sp); // lwu a2, 40(sp) + 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(v1, v0); // or v1, v0, r0 + c->addiu(v1, r0, -1); // addiu v1, r0, -1 + bc = c->sgpr64(s5) == c->sgpr64(v1); // beq s5, v1, L19 + c->mov64(v1, s7); // or v1, s7, r0 + if (bc) {goto block_5;} // branch non-likely + + c->dsra(v1, s5, 3); // dsra v1, s5, 3 + c->andi(a1, s5, 7); // andi a1, s5, 7 + c->addiu(a0, r0, 1); // addiu a0, r0, 1 + if (((s64)c->sgpr64(a1)) >= 0) { // bgezl a1, L18 + c->dsllv(a0, a0, a1); // dsllv a0, a0, a1 + goto block_4; + } + + block_3: + c->dsubu(a1, r0, a1); // dsubu a1, r0, a1 + c->dsrav(a0, a0, a1); // dsrav a0, a0, a1 + + block_4: + c->nor(a0, a0, r0); // nor a0, a0, r0 + c->lwu(a1, 40, sp); // lwu a1, 40(sp) + c->daddu(a1, a1, v1); // daddu a1, a1, v1 + c->lbu(a1, 0, a1); // lbu a1, 0(a1) + c->and_(a0, a1, a0); // and a0, a1, a0 + c->lwu(a1, 40, sp); // lwu a1, 40(sp) + c->daddu(v1, a1, v1); // daddu v1, a1, v1 + c->sb(a0, 0, v1); // sb a0, 0(v1) + + block_5: + c->sd(r0, 64, sp); // sd r0, 64(sp) + c->daddiu(v1, sp, 48); // daddiu v1, sp, 48 + c->sw(v1, 72, sp); // sw v1, 72(sp) + c->mtc1(f0, r0); // mtc1 f0, r0 + c->swc1(f0, 76, sp); // swc1 f0, 76(sp) + c->lwu(v1, 20, sp); // lwu v1, 20(sp) + c->lqc2(vf1, 0, v1); // lqc2 vf1, 0(v1) + c->vadd_bc(DEST::x, BC::w, vf2, vf0, vf0); // vaddw.x vf2, vf0, vf0 + c->vmul(DEST::xyzw, vf1, vf1, vf1); // vmul.xyzw vf1, vf1, vf1 + c->vmula_bc(DEST::x, BC::x, vf2, vf1); // vmulax.x acc, vf2, vf1 + c->vmadda_bc(DEST::x, BC::y, vf2, vf1); // vmadday.x acc, vf2, vf1 + c->vmadd_bc(DEST::x, BC::z, vf1, vf2, vf1); // vmaddz.x vf1, vf2, vf1 + c->mov128_gpr_vf(v1, vf1); // qmfc2.i v1, vf1 + c->mtc1(f0, v1); // mtc1 f0, v1 + c->mtc1(f1, r0); // mtc1 f1, r0 + cop1_bc = c->fprs[f1] < c->fprs[f0]; // c.lt.s f1, f0 + bc = !cop1_bc; // bc1f L20 + c->mov64(v1, s7); // or v1, s7, r0 + if (bc) {goto block_7;} // branch non-likely + + c->lui(v1, 16256); // lui v1, 16256 + c->mtc1(f1, v1); // mtc1 f1, v1 + c->divs(f0, f1, f0); // div.s f0, f1, f0 + c->mfc1(v1, f0); // mfc1 v1, f0 + c->mtc1(f0, v1); // mtc1 f0, v1 + c->swc1(f0, 76, sp); // swc1 f0, 76(sp) + c->mfc1(v1, f0); // mfc1 v1, f0 + + block_7: + c->lh(s5, 10, gp); // lh s5, 10(gp) + c->lwu(s4, 40, sp); // lwu s4, 40(sp) + c->gprs[s3].du64[0] = 0; // or s3, r0, r0 + + block_8: + c->dsll(s2, s3, 3); // dsll s2, s3, 3 + c->lbu(s1, 0, s4); // lbu s1, 0(s4) + bc = c->sgpr64(s1) == 0; // beq s1, r0, L24 + // nop // sll r0, r0, 0 + if (bc) {goto block_14;} // branch non-likely + + + block_9: + c->andi(v1, s1, 1); // andi v1, s1, 1 + // nop // sll r0, r0, 0 + bc = c->sgpr64(v1) == 0; // beq v1, r0, L23 + // nop // sll r0, r0, 0 + if (bc) {goto block_13;} // branch non-likely + + c->lwu(v1, 84, gp); // lwu v1, 84(gp) + c->dsll(a0, s2, 4); // dsll a0, s2, 4 + c->daddu(v1, v1, a0); // daddu v1, v1, a0 + c->sw(v1, 80, sp); // sw v1, 80(sp) + c->daddiu(v1, sp, 96); // daddiu v1, sp, 96 + c->mov64(a2, v1); // or a2, v1, r0 + c->lwu(a0, 80, sp); // lwu a0, 80(sp) + c->lwu(a1, 16, sp); // lwu a1, 16(sp) + c->lqc2(vf4, 0, a0); // lqc2 vf4, 0(a0) + c->lqc2(vf5, 0, a1); // lqc2 vf5, 0(a1) + c->vmove(DEST::w, vf6, vf0); // vmove.w vf6, vf0 + c->vsub(DEST::xyz, vf6, vf4, vf5); // vsub.xyz vf6, vf4, vf5 + c->sqc2(vf6, 0, a2); // sqc2 vf6, 0(a2) + c->lwu(a0, 20, sp); // lwu a0, 20(sp) + c->lwc1(f0, 0, a0); // lwc1 f0, 0(a0) + c->lwc1(f1, 4, a0); // lwc1 f1, 4(a0) + c->lwc1(f2, 8, a0); // lwc1 f2, 8(a0) + c->lwc1(f3, 0, v1); // lwc1 f3, 0(v1) + c->lwc1(f4, 4, v1); // lwc1 f4, 4(v1) + c->lwc1(f5, 8, v1); // lwc1 f5, 8(v1) + // Unknown instr: mula.s f0, f3 + // Unknown instr: madda.s f1, f4 + // Unknown instr: madd.s f0, f2, f5 + c->fprs[f0] = (c->fprs[f0] * c->fprs[f3]) + (c->fprs[f1] * c->fprs[f4]) + (c->fprs[f2] * c->fprs[f5]); + c->mfc1(v1, f0); // mfc1 v1, f0 + c->mtc1(f0, v1); // mtc1 f0, v1 + c->lw(v1, 76, sp); // lw v1, 76(sp) + c->mtc1(f1, v1); // mtc1 f1, v1 + c->muls(f1, f0, f1); // mul.s f1, f0, f1 + c->mtc1(f0, r0); // mtc1 f0, r0 + c->lui(v1, 16256); // lui v1, 16256 + c->mtc1(f2, v1); // mtc1 f2, v1 + c->mins(f1, f2, f1); // min.s f1, f2, f1 + c->maxs(f0, f0, f1); // max.s f0, f0, f1 + c->lwu(v1, 72, sp); // lwu v1, 72(sp) + c->lwu(a0, 16, sp); // lwu a0, 16(sp) + c->lwu(a1, 20, sp); // lwu a1, 20(sp) + c->lqc2(vf2, 0, a1); // lqc2 vf2, 0(a1) + c->lqc2(vf1, 0, a0); // lqc2 vf1, 0(a0) + c->mfc1(a0, f0); // mfc1 a0, f0 + c->mov128_vf_gpr(vf3, a0); // qmtc2.i vf3, a0 + c->vadd_bc(DEST::w, BC::x, vf4, vf0, vf0); // vaddx.w vf4, vf0, vf0 + c->vmula_bc(DEST::xyzw, BC::x, vf2, vf3); // vmulax.xyzw acc, vf2, vf3 + c->vmadd_bc(DEST::xyz, BC::w, vf4, vf1, vf0); // vmaddw.xyz vf4, vf1, vf0 + c->sqc2(vf4, 0, v1); // sqc2 vf4, 0(v1) + c->load_symbol2(t9, cache.vector_vector_distance_squared);// lw t9, vector-vector-distance-squared(s7) + c->lwu(a0, 72, sp); // lwu a0, 72(sp) + c->lwu(a1, 80, sp); // lwu a1, 80(sp) + 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->mtc1(f0, v0); // mtc1 f0, v0 + c->lw(v1, 24, sp); // lw v1, 24(sp) + c->mtc1(f1, v1); // mtc1 f1, v1 + c->lwu(v1, 80, sp); // lwu v1, 80(sp) + c->lwc1(f2, 12, v1); // lwc1 f2, 12(v1) + c->adds(f1, f1, f2); // add.s f1, f1, f2 + c->muls(f1, f1, f1); // mul.s f1, f1, f1 + c->mfc1(v1, f1); // mfc1 v1, f1 + c->mtc1(f1, v1); // mtc1 f1, v1 + cop1_bc = c->fprs[f0] < c->fprs[f1]; // c.lt.s f0, f1 + bc = !cop1_bc; // bc1f L23 + c->mov64(v1, s7); // or v1, s7, r0 + if (bc) {goto block_13;} // branch non-likely + + c->ld(v1, 64, sp); // ld v1, 64(sp) + c->ld(a0, 32, sp); // ld a0, 32(sp) + c->slt(v1, v1, a0); // slt v1, v1, a0 + bc = c->sgpr64(v1) == 0; // beq v1, r0, L23 + c->mov64(v1, s7); // or v1, s7, r0 + if (bc) {goto block_13;} // branch non-likely + + c->dsll(v1, s2, 4); // dsll v1, s2, 4 + c->lwu(a0, 100, gp); // lwu a0, 100(gp) + c->daddu(v1, v1, a0); // daddu v1, v1, a0 + c->lwu(v1, 0, v1); // lwu v1, 0(v1) + c->lwu(a0, 28, sp); // lwu a0, 28(sp) + c->ld(a1, 64, sp); // ld a1, 64(sp) + c->dsll(a1, a1, 2); // dsll a1, a1, 2 + c->daddu(a0, a0, a1); // daddu a0, a0, a1 + c->sw(v1, 0, a0); // sw v1, 0(a0) + c->gprs[v1].du64[0] = 0; // or v1, r0, r0 + c->ld(v1, 64, sp); // ld v1, 64(sp) + c->daddiu(v1, v1, 1); // daddiu v1, v1, 1 + c->sd(v1, 64, sp); // sd v1, 64(sp) + // nop // sll r0, r0, 0 + + block_13: + c->dsra(s1, s1, 1); // dsra s1, s1, 1 + // nop // sll r0, r0, 0 + bc = c->sgpr64(s1) != 0; // bne s1, r0, L22 + c->daddiu(s2, s2, 1); // daddiu s2, s2, 1 + if (bc) {goto block_9;} // branch non-likely + + + block_14: + c->daddiu(s3, s3, 1); // daddiu s3, s3, 1 + c->daddiu(s4, s4, 1); // daddiu s4, s4, 1 + c->slt(v1, s3, s5); // slt v1, s3, s5 + // nop // sll r0, r0, 0 + bc = c->sgpr64(v1) != 0; // bne v1, r0, L21 + // nop // sll r0, r0, 0 + if (bc) {goto block_8;} // branch non-likely + + c->ld(v0, 64, sp); // ld v0, 64(sp) + c->ld(ra, 0, sp); // ld ra, 0(sp) + c->lq(gp, 192, sp); // lq gp, 192(sp) + c->lq(s5, 176, sp); // lq s5, 176(sp) + c->lq(s4, 160, sp); // lq s4, 160(sp) + c->lq(s3, 144, sp); // lq s3, 144(sp) + c->lq(s2, 128, sp); // lq s2, 128(sp) + c->lq(s1, 112, sp); // lq s1, 112(sp) + //jr ra // jr ra + c->daddiu(sp, sp, 208); // daddiu sp, sp, 208 + 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.vector_vector_distance_squared = intern_from_c("vector-vector-distance-squared").c(); + gLinkedFunctionTable.reg("(method 37 spatial-hash)", execute, 256); +} + +} // namespace method_37_spatial_hash +} // 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 method_35_spatial_hash { +struct Cache { + void* perf_stats; // *perf-stats* +} cache; + +u64 execute(void* ctxt) { + auto* c = (ExecutionContext*)ctxt; + bool bc = false; + u32 call_addr = 0; + bool cop1_bc = false; + c->daddiu(sp, sp, -64); // daddiu sp, sp, -64 + c->sd(ra, 0, sp); // sd ra, 0(sp) + c->sq(gp, 48, sp); // sq gp, 48(sp) + c->mov64(gp, a1); // or gp, a1, r0 + c->load_symbol2(v1, cache.perf_stats); // lw v1, *perf-stats*(s7) + c->daddiu(v1, v1, 116); // daddiu v1, v1, 116 + c->lwu(a1, 28, v1); // lwu a1, 28(v1) + c->lwu(t0, 4, v1); // lwu t0, 4(v1) + c->daddiu(t0, t0, 1); // daddiu t0, t0, 1 + c->sw(t0, 4, v1); // sw t0, 4(v1) + bc = c->sgpr64(a1) == 0; // beq a1, r0, L3 + // nop // sll r0, r0, 0 + if (bc) {goto block_2;} // branch non-likely + + // Unknown instr: mtc0 Perf, r0 + // Unknown instr: sync.l + // Unknown instr: sync.p + // Unknown instr: mtpc pcr0, r0 + // Unknown instr: mtpc pcr1, r0 + // Unknown instr: sync.l + // Unknown instr: sync.p + // Unknown instr: mtc0 Perf, a1 + // Unknown instr: sync.l + // Unknown instr: sync.p + + block_2: + c->gprs[v1].du64[0] = 0; // or v1, r0, r0 + c->mov64(v1, a0); // or v1, a0, r0 + c->daddiu(a1, a0, 4); // daddiu a1, a0, 4 + c->daddu(t0, r0, gp); // daddu t0, r0, gp + c->daddiu(t1, gp, 16); // daddiu t1, gp, 16 + c->addiu(t2, r0, 0); // addiu t2, r0, 0 + //beq r0, r0, L5 // beq r0, r0, L5 + // nop // sll r0, r0, 0 + goto block_4; // branch always + + + block_3: + c->mtc1(f0, r0); // mtc1 f0, r0 + c->dsll(t3, t2, 2); // dsll t3, t2, 2 + c->daddu(t3, t3, t0); // daddu t3, t3, t0 + c->lwc1(f1, 0, t3); // lwc1 f1, 0(t3) + c->dsll(t3, t2, 2); // dsll t3, t2, 2 + c->daddu(t3, t3, v1); // daddu t3, t3, v1 + c->lwc1(f2, 32, t3); // lwc1 f2, 32(t3) + c->subs(f1, f1, f2); // sub.s f1, f1, f2 + c->dsll(t3, t2, 2); // dsll t3, t2, 2 + c->daddu(t3, t3, v1); // daddu t3, t3, v1 + c->lwc1(f2, 12, t3); // lwc1 f2, 12(t3) + c->muls(f1, f1, f2); // mul.s f1, f1, f2 + c->daddu(t3, t2, v1); // daddu t3, t2, v1 + c->lb(t3, 24, t3); // lb t3, 24(t3) + c->daddiu(t3, t3, -1); // daddiu t3, t3, -1 + c->mtc1(f2, t3); // mtc1 f2, t3 + c->cvtsw(f2, f2); // cvt.s.w f2, f2 + c->mins(f1, f1, f2); // min.s f1, f1, f2 + c->maxs(f0, f0, f1); // max.s f0, f0, f1 + c->cvtws(f0, f0); // cvt.w.s f0, f0 + c->mfc1(t3, f0); // mfc1 t3, f0 + c->daddu(t4, t2, a1); // daddu t4, t2, a1 + c->sb(t3, 0, t4); // sb t3, 0(t4) + c->mtc1(f0, r0); // mtc1 f0, r0 + c->dsll(t3, t2, 2); // dsll t3, t2, 2 + c->daddu(t3, t3, t1); // daddu t3, t3, t1 + c->lwc1(f1, 0, t3); // lwc1 f1, 0(t3) + c->dsll(t3, t2, 2); // dsll t3, t2, 2 + c->daddu(t3, t3, v1); // daddu t3, t3, v1 + c->lwc1(f2, 32, t3); // lwc1 f2, 32(t3) + c->subs(f1, f1, f2); // sub.s f1, f1, f2 + c->dsll(t3, t2, 2); // dsll t3, t2, 2 + c->daddu(t3, t3, v1); // daddu t3, t3, v1 + c->lwc1(f2, 12, t3); // lwc1 f2, 12(t3) + c->muls(f1, f1, f2); // mul.s f1, f1, f2 + c->daddu(t3, t2, v1); // daddu t3, t2, v1 + c->lb(t3, 24, t3); // lb t3, 24(t3) + c->daddiu(t3, t3, -1); // daddiu t3, t3, -1 + c->mtc1(f2, t3); // mtc1 f2, t3 + c->cvtsw(f2, f2); // cvt.s.w f2, f2 + c->mins(f1, f1, f2); // min.s f1, f1, f2 + c->maxs(f0, f0, f1); // max.s f0, f0, f1 + c->cvtws(f0, f0); // cvt.w.s f0, f0 + c->mfc1(t3, f0); // mfc1 t3, f0 + c->daddu(t4, t2, a1); // daddu t4, t2, a1 + c->sb(t3, 3, t4); // sb t3, 3(t4) + c->daddiu(t2, t2, 1); // daddiu t2, t2, 1 + + block_4: + c->slti(t3, t2, 3); // slti t3, t2, 3 + bc = c->sgpr64(t3) != 0; // bne t3, r0, L4 + // nop // sll r0, r0, 0 + if (bc) {goto block_3;} // branch non-likely + + c->mov64(v1, s7); // or v1, s7, r0 + c->mov64(v1, s7); // or v1, s7, r0 + c->gprs[v1].du64[0] = 0; // or v1, r0, r0 + c->lwu(v1, 0, a0); // lwu v1, 0(a0) + c->daddiu(v1, v1, 12); // daddiu v1, v1, 12 + c->sw(v1, 16, sp); // sw v1, 16(sp) + c->sw(a0, 20, sp); // sw a0, 20(sp) + c->sw(a2, 24, sp); // sw a2, 24(sp) + c->sd(a3, 32, sp); // sd a3, 32(sp) + c->lwu(a0, 20, sp); // lwu a0, 20(sp) + c->lwu(v1, -4, a0); // lwu v1, -4(a0) + c->lwu(t9, 96, v1); // lwu t9, 96(v1) + c->lwu(v1, 20, sp); // lwu v1, 20(sp) + c->daddiu(a1, v1, 4); // daddiu a1, v1, 4 + c->lwu(a2, 16, sp); // lwu a2, 16(sp) + 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(v1, v0); // or v1, v0, r0 + c->sd(r0, 40, sp); // sd r0, 40(sp) + c->lwu(v1, 20, sp); // lwu v1, 20(sp) + c->lh(v1, 10, v1); // lh v1, 10(v1) + c->lwu(a0, 16, sp); // lwu a0, 16(sp) + c->gprs[a1].du64[0] = 0; // or a1, r0, r0 + + block_6: + c->dsll(a2, a1, 3); // dsll a2, a1, 3 + c->lbu(a3, 0, a0); // lbu a3, 0(a0) + bc = c->sgpr64(a3) == 0; // beq a3, r0, L15 + // nop // sll r0, r0, 0 + if (bc) {goto block_34;} // branch non-likely + + + block_7: + c->andi(t0, a3, 1); // andi t0, a3, 1 + // nop // sll r0, r0, 0 + bc = c->sgpr64(t0) == 0; // beq t0, r0, L14 + // nop // sll r0, r0, 0 + if (bc) {goto block_33;} // branch non-likely + + c->lwu(t0, 20, sp); // lwu t0, 20(sp) + c->lwu(t0, 84, t0); // lwu t0, 84(t0) + c->dsll(t1, a2, 4); // dsll t1, a2, 4 + c->daddu(t0, t0, t1); // daddu t0, t0, t1 + c->lwc1(f0, 0, t0); // lwc1 f0, 0(t0) + c->lwc1(f1, 12, t0); // lwc1 f1, 12(t0) + c->adds(f0, f0, f1); // add.s f0, f0, f1 + c->lwc1(f1, 0, gp); // lwc1 f1, 0(gp) + cop1_bc = c->fprs[f0] < c->fprs[f1]; // c.lt.s f0, f1 + bc = !cop1_bc; // bc1f L8 + c->daddiu(t1, s7, 4); // daddiu t1, s7, 4 + if (bc) {goto block_10;} // branch non-likely + + c->mov64(t1, s7); // or t1, s7, r0 + + block_10: + if (((s64)c->sgpr64(s7)) == ((s64)c->sgpr64(t1))) {// beql s7, t1, L13 + c->mov64(t0, t1); // or t0, t1, r0 + goto block_30; + } + + block_12: + c->lwc1(f0, 16, gp); // lwc1 f0, 16(gp) + c->lwc1(f1, 0, t0); // lwc1 f1, 0(t0) + c->lwc1(f2, 12, t0); // lwc1 f2, 12(t0) + c->subs(f1, f1, f2); // sub.s f1, f1, f2 + cop1_bc = c->fprs[f0] < c->fprs[f1]; // c.lt.s f0, f1 + bc = !cop1_bc; // bc1f L9 + c->daddiu(t1, s7, 4); // daddiu t1, s7, 4 + if (bc) {goto block_14;} // branch non-likely + + c->mov64(t1, s7); // or t1, s7, r0 + + block_14: + if (((s64)c->sgpr64(s7)) == ((s64)c->sgpr64(t1))) {// beql s7, t1, L13 + c->mov64(t0, t1); // or t0, t1, r0 + goto block_30; + } + + block_16: + c->lwc1(f0, 4, t0); // lwc1 f0, 4(t0) + c->lwc1(f1, 12, t0); // lwc1 f1, 12(t0) + c->adds(f0, f0, f1); // add.s f0, f0, f1 + c->lwc1(f1, 4, gp); // lwc1 f1, 4(gp) + cop1_bc = c->fprs[f0] < c->fprs[f1]; // c.lt.s f0, f1 + bc = !cop1_bc; // bc1f L10 + c->daddiu(t1, s7, 4); // daddiu t1, s7, 4 + if (bc) {goto block_18;} // branch non-likely + + c->mov64(t1, s7); // or t1, s7, r0 + + block_18: + if (((s64)c->sgpr64(s7)) == ((s64)c->sgpr64(t1))) {// beql s7, t1, L13 + c->mov64(t0, t1); // or t0, t1, r0 + goto block_30; + } + + block_20: + c->lwc1(f0, 20, gp); // lwc1 f0, 20(gp) + c->lwc1(f1, 4, t0); // lwc1 f1, 4(t0) + c->lwc1(f2, 12, t0); // lwc1 f2, 12(t0) + c->subs(f1, f1, f2); // sub.s f1, f1, f2 + cop1_bc = c->fprs[f0] < c->fprs[f1]; // c.lt.s f0, f1 + bc = !cop1_bc; // bc1f L11 + c->daddiu(t1, s7, 4); // daddiu t1, s7, 4 + if (bc) {goto block_22;} // branch non-likely + + c->mov64(t1, s7); // or t1, s7, r0 + + block_22: + if (((s64)c->sgpr64(s7)) == ((s64)c->sgpr64(t1))) {// beql s7, t1, L13 + c->mov64(t0, t1); // or t0, t1, r0 + goto block_30; + } + + block_24: + c->lwc1(f0, 8, t0); // lwc1 f0, 8(t0) + c->lwc1(f1, 12, t0); // lwc1 f1, 12(t0) + c->adds(f0, f0, f1); // add.s f0, f0, f1 + c->lwc1(f1, 8, gp); // lwc1 f1, 8(gp) + cop1_bc = c->fprs[f0] < c->fprs[f1]; // c.lt.s f0, f1 + bc = !cop1_bc; // bc1f L12 + c->daddiu(t1, s7, 4); // daddiu t1, s7, 4 + if (bc) {goto block_26;} // branch non-likely + + c->mov64(t1, s7); // or t1, s7, r0 + + block_26: + if (((s64)c->sgpr64(s7)) == ((s64)c->sgpr64(t1))) {// beql s7, t1, L13 + c->mov64(t0, t1); // or t0, t1, r0 + goto block_30; + } + + block_28: + c->lwc1(f0, 24, gp); // lwc1 f0, 24(gp) + c->lwc1(f1, 8, t0); // lwc1 f1, 8(t0) + c->lwc1(f2, 12, t0); // lwc1 f2, 12(t0) + c->subs(f1, f1, f2); // sub.s f1, f1, f2 + cop1_bc = c->fprs[f0] < c->fprs[f1]; // c.lt.s f0, f1 + bc = !cop1_bc; // bc1f L13 + c->daddiu(t0, s7, 4); // daddiu t0, s7, 4 + if (bc) {goto block_30;} // branch non-likely + + c->mov64(t0, s7); // or t0, s7, r0 + + block_30: + bc = c->sgpr64(s7) == c->sgpr64(t0); // beq s7, t0, L14 + c->mov64(t0, s7); // or t0, s7, r0 + if (bc) {goto block_33;} // branch non-likely + + c->ld(t0, 40, sp); // ld t0, 40(sp) + c->ld(t1, 32, sp); // ld t1, 32(sp) + c->slt(t0, t0, t1); // slt t0, t0, t1 + bc = c->sgpr64(t0) == 0; // beq t0, r0, L14 + c->mov64(t0, s7); // or t0, s7, r0 + if (bc) {goto block_33;} // branch non-likely + + c->dsll(t0, a2, 4); // dsll t0, a2, 4 + c->lwu(t1, 20, sp); // lwu t1, 20(sp) + c->lwu(t1, 100, t1); // lwu t1, 100(t1) + c->daddu(t0, t0, t1); // daddu t0, t0, t1 + c->lwu(t0, 0, t0); // lwu t0, 0(t0) + c->lwu(t1, 24, sp); // lwu t1, 24(sp) + c->ld(t2, 40, sp); // ld t2, 40(sp) + c->dsll(t2, t2, 2); // dsll t2, t2, 2 + c->daddu(t1, t1, t2); // daddu t1, t1, t2 + c->sw(t0, 0, t1); // sw t0, 0(t1) + c->ld(t0, 40, sp); // ld t0, 40(sp) + c->daddiu(t0, t0, 1); // daddiu t0, t0, 1 + c->sd(t0, 40, sp); // sd t0, 40(sp) + + block_33: + c->dsra(a3, a3, 1); // dsra a3, a3, 1 + // nop // sll r0, r0, 0 + bc = c->sgpr64(a3) != 0; // bne a3, r0, L7 + c->daddiu(a2, a2, 1); // daddiu a2, a2, 1 + if (bc) {goto block_7;} // branch non-likely + + + block_34: + c->daddiu(a1, a1, 1); // daddiu a1, a1, 1 + c->daddiu(a0, a0, 1); // daddiu a0, a0, 1 + c->slt(a2, a1, v1); // slt a2, a1, v1 + // nop // sll r0, r0, 0 + bc = c->sgpr64(a2) != 0; // bne a2, r0, L6 + // nop // sll r0, r0, 0 + if (bc) {goto block_6;} // branch non-likely + + c->load_symbol2(v1, cache.perf_stats); // lw v1, *perf-stats*(s7) + c->daddiu(v1, v1, 116); // daddiu v1, v1, 116 + c->lwu(a0, 28, v1); // lwu a0, 28(v1) + bc = c->sgpr64(a0) == 0; // beq a0, r0, L16 + // nop // sll r0, r0, 0 + if (bc) {goto block_37;} // branch non-likely + + // Unknown instr: mtc0 Perf, r0 + // Unknown instr: sync.l + // Unknown instr: sync.p + // Unknown instr: mfpc a0, pcr0 + c->lwu(a1, 32, v1); // lwu a1, 32(v1) + c->daddu(a0, a1, a0); // daddu a0, a1, a0 + c->sw(a0, 32, v1); // sw a0, 32(v1) + // Unknown instr: mfpc a0, pcr1 + c->lwu(a1, 36, v1); // lwu a1, 36(v1) + c->daddu(a0, a1, a0); // daddu a0, a1, a0 + c->sw(a0, 36, v1); // sw a0, 36(v1) + + block_37: + c->gprs[v1].du64[0] = 0; // or v1, r0, r0 + c->ld(v0, 40, sp); // ld v0, 40(sp) + c->ld(ra, 0, sp); // ld ra, 0(sp) + c->lq(gp, 48, sp); // lq gp, 48(sp) + //jr ra // jr ra + c->daddiu(sp, sp, 64); // daddiu sp, sp, 64 + 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.perf_stats = intern_from_c("*perf-stats*").c(); + gLinkedFunctionTable.reg("(method 35 spatial-hash)", execute, 128); +} + +} // namespace method_35_spatial_hash +} // namespace Mips2C + diff --git a/game/mips2c/mips2c_private.h b/game/mips2c/mips2c_private.h index 3597d4e387..70e0349233 100644 --- a/game/mips2c/mips2c_private.h +++ b/game/mips2c/mips2c_private.h @@ -828,6 +828,25 @@ struct ExecutionContext { } } + void vmr32(DEST mask, int dest, int src) { + auto s = vf_src(src); + if ((u64)mask & 1) { + vfs[dest].f[0] = s.f[1]; + } + + if ((u64)mask & 2) { + vfs[dest].f[1] = s.f[2]; + } + + if ((u64)mask & 4) { + vfs[dest].f[2] = s.f[3]; + } + + if ((u64)mask & 8) { + vfs[dest].f[3] = s.f[0]; + } + } + void vsub(DEST mask, int dest, int src0, int src1) { auto s0 = vf_src(src0); auto s1 = vf_src(src1); @@ -1107,6 +1126,7 @@ struct ExecutionContext { } void xor_(int dst, int src0, int src1) { gprs[dst].du64[0] = sgpr64(src0) ^ sgpr64(src1); } void or_(int dst, int src0, int src1) { gprs[dst].du64[0] = sgpr64(src0) | sgpr64(src1); } + void nor(int dst, int src0, int src1) { gprs[dst].du64[0] = ~(sgpr64(src0) | sgpr64(src1)); } void movz(int dst, int src0, int src1) { if (sgpr64(src1) == 0) { diff --git a/game/mips2c/mips2c_table.cpp b/game/mips2c/mips2c_table.cpp index 8d89707cdd..1a9bb15e5b 100644 --- a/game/mips2c/mips2c_table.cpp +++ b/game/mips2c/mips2c_table.cpp @@ -166,6 +166,22 @@ namespace render_ocean_quad { extern void link(); } namespace method_16_ocean { extern void link(); } namespace method_15_ocean { extern void link(); } namespace method_14_ocean { extern void link(); } +namespace method_18_grid_hash { extern void link(); } +namespace method_19_grid_hash { extern void link(); } +namespace method_20_grid_hash { extern void link(); } +namespace method_22_grid_hash { extern void link(); } +namespace method_28_sphere_hash { extern void link(); } +namespace method_33_sphere_hash { extern void link(); } +namespace method_29_sphere_hash { extern void link(); } +namespace method_30_sphere_hash { extern void link(); } +namespace method_31_sphere_hash { extern void link(); } +namespace method_32_sphere_hash { extern void link(); } +namespace method_33_spatial_hash { extern void link(); } +namespace method_39_spatial_hash { extern void link(); } +namespace method_36_spatial_hash { extern void link(); } +namespace method_37_spatial_hash { extern void link(); } +namespace method_35_spatial_hash { extern void link(); } + } // clang-format on @@ -275,7 +291,16 @@ PerGameVersion>> gMips2C {jak2::method_16_ocean::link, jak2::method_15_ocean::link, jak2::method_14_ocean::link}}, {"ocean", {jak2::init_ocean_far_regs::link, jak2::draw_large_polygon_ocean::link, - jak2::render_ocean_quad::link}}}, + jak2::render_ocean_quad::link}}, + {"spatial-hash", + {jak2::method_18_grid_hash::link, jak2::method_19_grid_hash::link, + jak2::method_20_grid_hash::link, jak2::method_22_grid_hash::link, + jak2::method_28_sphere_hash::link, jak2::method_33_sky_work::link, + jak2::method_29_sphere_hash::link, jak2::method_30_sphere_hash::link, + jak2::method_31_sphere_hash::link, jak2::method_32_sphere_hash::link, + jak2::method_33_spatial_hash::link, jak2::method_39_spatial_hash::link, + jak2::method_36_spatial_hash::link, jak2::method_37_spatial_hash::link, + jak2::method_35_spatial_hash::link, jak2::method_33_sphere_hash::link}}}, }; void LinkedFunctionTable::reg(const std::string& name, u64 (*exec)(void*), u32 stack_size) { diff --git a/goal_src/jak2/engine/common_objs/water-anim.gc b/goal_src/jak2/engine/common_objs/water-anim.gc index d3d034ab73..976aa0fa14 100644 --- a/goal_src/jak2/engine/common_objs/water-anim.gc +++ b/goal_src/jak2/engine/common_objs/water-anim.gc @@ -40,6 +40,7 @@ ) ) + (defmethod relocate water-anim ((obj water-anim) (arg0 int)) (if (nonzero? (-> obj flow)) (&+! (-> obj flow) arg0) @@ -227,6 +228,7 @@ :flag-assert #x90000000c ) + (define *water-anim-look* (new 'static 'boxed-array :type water-anim-look (new 'static 'water-anim-look :skel-group "water-anim-nest-dark-eco-largepool" :anim 8 :ambient-sound-spec #f) @@ -303,6 +305,8 @@ ) ) +;; WARN: Return type mismatch none vs object. +;; WARN: rewrite_to_get_var got a none typed variable. Is there unreachable code? [OP: 210] (defbehavior water-anim-event-handler water-anim ((arg0 process) (arg1 int) (arg2 symbol) (arg3 event-message-block)) (local-vars (v0-1 none)) (let ((v1-0 arg2)) @@ -326,60 +330,59 @@ v0-1 ) ((= v1-0 'water) - (let ((s5-0 (the-as object (-> arg3 param 0)))) - (let* ((s4-0 (the-as object (-> arg3 param 1))) - (gp-0 (if (type? (the-as process s4-0) process-focusable) - (the-as uint s4-0) - ) - ) + (let* ((s5-0 (the-as object (-> arg3 param 0))) + (s4-0 (the-as object (-> arg3 param 1))) + (gp-0 (if (type? (the-as process s4-0) process-focusable) + (the-as uint s4-0) + ) + ) + ) + (when (and (logtest? (-> self flags) (water-flags deadly)) + (logtest? (water-flags touch-water) (-> (the-as water-info s5-0) flags)) + (the-as uint gp-0) + ) + (let ((v1-15 (-> self attack-event))) + (case v1-15 + ((#f) ) - (when (and (logtest? (-> self flags) (water-flags deadly)) - (logtest? (water-flags touch-water) (-> (the-as water-info s5-0) flags)) - (the-as uint gp-0) - ) - (let ((v1-15 (-> self attack-event))) - (case v1-15 - ((#f) - ) - (('heat) - (send-event (the-as process-tree gp-0) 'heat (* 10.0 (-> self clock seconds-per-frame))) - ) - (('drown-death 'lava 'dark-eco-pool) - (if (and (not (logtest? (focus-status board) (-> (the-as process-focusable gp-0) focus-status))) - (let ((a1-10 (new 'stack-no-clear 'event-message-block))) - (set! (-> a1-10 from) (process->ppointer self)) - (set! (-> a1-10 num-params) 2) - (set! (-> a1-10 message) 'attack-invinc) - (set! (-> a1-10 param 0) (the-as uint #f)) - (let ((a2-4 (new 'static 'attack-info :mask (attack-info-mask mode id)))) - (set! (-> a2-4 id) (-> self attack-id)) - (set! (-> a2-4 mode) v1-15) - (set! (-> a1-10 param 1) (the-as uint a2-4)) - ) - (send-event-function (the-as process-focusable gp-0) a1-10) + (('heat) + (send-event (the-as process-tree gp-0) 'heat (* 10.0 (-> self clock seconds-per-frame))) + ) + (('drown-death 'lava 'dark-eco-pool) + (if (and (not (logtest? (focus-status board) (-> (the-as process-focusable gp-0) focus-status))) + (let ((a1-10 (new 'stack-no-clear 'event-message-block))) + (set! (-> a1-10 from) (process->ppointer self)) + (set! (-> a1-10 num-params) 2) + (set! (-> a1-10 message) 'attack-invinc) + (set! (-> a1-10 param 0) (the-as uint #f)) + (let ((a2-4 (new 'static 'attack-info :mask (attack-info-mask mode id)))) + (set! (-> a2-4 id) (-> self attack-id)) + (set! (-> a2-4 mode) v1-15) + (set! (-> a1-10 param 1) (the-as uint a2-4)) ) + (send-event-function (the-as process-focusable gp-0) a1-10) ) - (send-event self 'notify 'attack) - ) - ) - (else - (if (and (not (logtest? (focus-status board) (-> (the-as process-focusable gp-0) focus-status))) - (let ((a1-13 (new 'stack-no-clear 'event-message-block))) - (set! (-> a1-13 from) (process->ppointer self)) - (set! (-> a1-13 num-params) 2) - (set! (-> a1-13 message) 'attack) - (set! (-> a1-13 param 0) (the-as uint #f)) - (let ((a2-6 (new 'static 'attack-info :mask (attack-info-mask mode id)))) - (set! (-> a2-6 id) (-> self attack-id)) - (set! (-> a2-6 mode) v1-15) - (set! (-> a1-13 param 1) (the-as uint a2-6)) - ) - (send-event-function (the-as process-tree gp-0) a1-13) + ) + (send-event self 'notify 'attack) + ) + ) + (else + (if (and (not (logtest? (focus-status board) (-> (the-as process-focusable gp-0) focus-status))) + (let ((a1-13 (new 'stack-no-clear 'event-message-block))) + (set! (-> a1-13 from) (process->ppointer self)) + (set! (-> a1-13 num-params) 2) + (set! (-> a1-13 message) 'attack) + (set! (-> a1-13 param 0) (the-as uint #f)) + (let ((a2-6 (new 'static 'attack-info :mask (attack-info-mask mode id)))) + (set! (-> a2-6 id) (-> self attack-id)) + (set! (-> a2-6 mode) v1-15) + (set! (-> a1-13 param 1) (the-as uint a2-6)) ) + (send-event-function (the-as process-tree gp-0) a1-13) ) - (send-event self 'notify 'attack) - ) - ) + ) + (send-event self 'notify 'attack) + ) ) ) ) @@ -389,7 +392,7 @@ ) (let ((a0-40 (-> self flow))) (if (nonzero? a0-40) - ((method-of-object a0-40 flow-control-method-11)) + (push-process a0-40 (the-as process-focusable gp-0)) ) ) ) @@ -461,11 +464,13 @@ (ripple-find-height obj 0 arg0) ) +;; WARN: Return type mismatch symbol vs none. (defmethod water-anim-method-27 water-anim ((obj water-anim)) "Empty." (none) ) +;; WARN: Return type mismatch quaternion vs none. (defmethod offset! water-anim ((obj water-anim)) "Offset a [[water-anim]]'s `trans` and `quat` by the lump data in `entity`." (local-vars (sv-16 res-tag)) @@ -529,6 +534,7 @@ ) ) +;; WARN: Return type mismatch water-flags vs none. (defmethod water-anim-init! water-anim ((obj water-anim)) "Initialize a [[water-anim]]." (local-vars (sv-16 res-tag)) @@ -599,6 +605,7 @@ (none) ) +;; WARN: Return type mismatch object vs none. (defbehavior water-anim-init-by-other water-anim ((arg0 entity-actor)) (process-entity-set! self arg0) (water-anim-method-27 self) @@ -610,6 +617,7 @@ (none) ) +;; WARN: Return type mismatch object vs none. (defmethod init-from-entity! water-anim ((obj water-anim) (arg0 entity-actor)) (water-anim-method-27 obj) (reset-root! obj) diff --git a/goal_src/jak2/engine/common_objs/water-flow.gc b/goal_src/jak2/engine/common_objs/water-flow.gc index 9a32ba167f..b5bf0ee57d 100644 --- a/goal_src/jak2/engine/common_objs/water-flow.gc +++ b/goal_src/jak2/engine/common_objs/water-flow.gc @@ -28,16 +28,13 @@ :flag-assert #x900000040 ) - (deftype flow-section-array (inline-array-class) - ((data flow-section :dynamic :offset-assert 16) + ((data flow-section :inline :dynamic :offset-assert 16) ) :method-count-assert 9 :size-assert #x10 :flag-assert #x900000010 ) - - (set! (-> flow-section-array heap-base) (the-as uint 64)) (deftype flow-control (basic) @@ -54,13 +51,12 @@ (:methods (new (symbol type process-drawable res-lump) _type_ 0) (draw-path (_type_) none 9) - (flow-control-method-10 () none 10) - (flow-control-method-11 () none 11) - (flow-control-method-12 () none 12) + (setup (_type_) none 10) + (push-process (_type_ process-focusable) none 11) + (find-and-push-things (_type_) none 12) ) ) - (defmethod relocate flow-control ((obj flow-control) (arg0 int)) (if (nonzero? (-> obj sections)) (&+! (-> obj sections) arg0) @@ -81,6 +77,307 @@ (none) ) +(defmethod push-process flow-control ((obj flow-control) (arg0 process-focusable)) + (with-pp + (rlet ((acc :class vf) + (vf0 :class vf) + (vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + (vf7 :class vf) + ) + (init-vf0-vector) + (let ((s5-0 (new 'stack-no-clear 'vector))) + (set! (-> s5-0 quad) (-> (get-trans arg0 0) quad)) + (set! (-> s5-0 w) 1.0) + (when (>= (vector4-dot s5-0 (the-as vector (-> obj leading))) 0.0) + (let* ((v1-7 (-> obj sections)) + (a0-3 (-> v1-7 length)) + (a3-0 (the-as object (-> obj leading))) + ) + (dotimes (s3-1 a0-3) + (let ((s2-0 (-> v1-7 data s3-1))) + (when (< (vector4-dot s5-0 (the-as vector (-> s2-0 trailing))) 0.0) + (let ((v1-8 (new 'stack-no-clear 'vector))) + (vector-! v1-8 s5-0 (-> s2-0 start)) + (when (>= (-> obj belt-radius) (fabs (vector-dot v1-8 (-> s2-0 radial-dir)))) + (let* ((f0-7 (vector-dot v1-8 (-> s2-0 pull-dir))) + (f0-9 (- (-> v1-8 y) (* (-> s2-0 pull-dir y) f0-7))) + ) + (when (and (>= f0-9 -41984.0) (>= 41779.2 f0-9)) + (let* ((a0-11 (new 'stack-no-clear 'vector)) + (s1-0 (new 'stack-no-clear 'vector)) + (f30-0 (ray-plane-equation-intersect a0-11 s5-0 (-> s2-0 pull-dir) (the-as vector a3-0))) + (f0-10 (ray-plane-equation-intersect s1-0 s5-0 (-> s2-0 pull-dir) (-> s2-0 trailing))) + ) + (let ((a0-13 (new 'stack-no-clear 'vector))) + (let ((v1-13 (-> s2-0 start))) + (let ((a1-12 (-> s2-0 pull-dir))) + (let ((a2-6 12288.0)) + (.mov vf7 a2-6) + ) + (.lvf vf5 (&-> a1-12 quad)) + ) + (.lvf vf4 (&-> v1-13 quad)) + ) + (.add.x.vf vf6 vf0 vf0 :mask #b1000) + (.mul.x.vf acc vf5 vf7 :mask #b111) + (.add.mul.w.vf vf6 vf4 vf0 acc :mask #b111) + (.svf (&-> a0-13 quad) vf6) + ) + 0 + (let ((f0-12 (/ f30-0 (- f30-0 f0-10))) + (s2-1 (new 'stack-no-clear 'vector)) + ) + (displacement-between-two-points-normalized! (-> obj path) s2-1 (+ (the float s3-1) f0-12)) + (let ((v1-17 (new 'stack-no-clear 'vector))) + (vector-float*! v1-17 s2-1 (* (-> obj speed) (-> pp clock seconds-per-frame))) + (let ((a1-15 (new 'stack-no-clear 'vector))) + (let ((a0-17 v1-17)) + (let ((a2-9 2048.0)) + (.mov vf7 a2-9) + ) + (.lvf vf5 (&-> a0-17 quad)) + ) + (.lvf vf4 (&-> s5-0 quad)) + (.add.x.vf vf6 vf0 vf0 :mask #b1000) + (.mul.x.vf acc vf5 vf7 :mask #b111) + (.add.mul.w.vf vf6 vf4 vf0 acc :mask #b111) + (.svf (&-> a1-15 quad) vf6) + ) + 0 + (send-event arg0 'push-trans v1-17 3000) + ) + ) + ) + ) + ) + ) + ) + (return #f) + ) + ) + (set! a3-0 (+ (the-as uint (-> v1-7 data 0 trailing)) (* s3-1 64))) + ) + ) + ) + ) + 0 + (none) + ) + ) + ) + +(defmethod find-and-push-things flow-control ((obj flow-control)) + (local-vars (a0-10 float) (a2-5 float) (a2-12 float)) + (rlet ((acc :class vf) + (vf0 :class vf) + (vf1 :class vf) + (vf2 :class vf) + (vf3 :class vf) + (vf4 :class vf) + ) + (init-vf0-vector) + (set! *actor-list-length* 0) + (if #t + (set! *actor-list-length* (fill-actor-list-for-sphere *actor-hash* (-> obj collide-bounds) *actor-list* 256)) + ) + (when #t + (let ((a0-2 (-> *collide-player-list* alive-list next0))) + *collide-player-list* + (let ((v1-11 (-> a0-2 next0))) + (while (!= a0-2 (-> *collide-player-list* alive-list-end)) + (let* ((a0-3 (-> (the-as connection a0-2) param1)) + (a1-1 (-> (the-as collide-shape a0-3) root-prim)) + ) + (when (logtest? (-> a1-1 prim-core collide-as) (collide-spec jak bot enemy hit-by-others-list player-list)) + (let ((a1-2 (-> a1-1 prim-core))) + (let ((a2-4 a1-2) + (a3-1 (-> obj collide-bounds)) + ) + (.lvf vf2 (&-> a2-4 world-sphere quad)) + (.lvf vf3 (&-> a3-1 quad)) + ) + (.sub.vf vf1 vf3 vf2) + (.mul.vf vf1 vf1 vf1) + (.add.y.vf vf1 vf1 vf1 :mask #b1) + (.add.z.vf vf1 vf1 vf1 :mask #b1) + (.mov a2-5 vf1) + (let ((f0-0 a2-5) + (f1-1 (+ (-> a1-2 world-sphere w) (-> obj collide-bounds r))) + ) + (when (< f0-0 (* f1-1 f1-1)) + (when (< *actor-list-length* 256) + (set! (-> *actor-list* *actor-list-length*) (the-as collide-shape a0-3)) + (set! *actor-list-length* (+ *actor-list-length* 1)) + ) + ) + ) + ) + ) + ) + (set! a0-2 v1-11) + *collide-player-list* + (set! v1-11 (-> v1-11 next0)) + ) + ) + ) + ) + (b! (not #f) cfg-20 :delay (empty-form)) + (let ((a0-5 (-> *collide-hit-by-player-list* alive-list next0))) + *collide-hit-by-player-list* + (let ((v1-18 (-> a0-5 next0))) + (b! #t cfg-18 :delay (nop!)) + (label cfg-13) + (let ((a0-6 (-> (the-as connection a0-5) param1))) + (let ((a1-13 (-> (the-as collide-shape a0-6) root-prim))) + (b! + (not (logtest? (-> a1-13 prim-core collide-as) (collide-spec jak bot enemy hit-by-others-list player-list))) + cfg-17 + :delay (empty-form) + ) + (let ((a1-14 (-> a1-13 prim-core))) + (let ((a2-11 a1-14) + (a3-2 (-> obj collide-bounds)) + ) + (.lvf vf2 (&-> a2-11 world-sphere quad)) + (.lvf vf3 (&-> a3-2 quad)) + ) + (.sub.vf vf1 vf3 vf2) + (.mul.vf vf1 vf1 vf1) + (.add.y.vf vf1 vf1 vf1 :mask #b1) + (.add.z.vf vf1 vf1 vf1 :mask #b1) + (.mov a2-12 vf1) + (let ((f0-1 a2-12) + (f1-5 (+ (-> a1-14 world-sphere w) (-> obj collide-bounds r))) + ) + (b! (>= f0-1 (* f1-5 f1-5)) cfg-17 :delay #f) + ) + ) + ) + (b! (>= *actor-list-length* 256) cfg-17 :delay #f) + (set! (-> *actor-list* *actor-list-length*) (the-as collide-shape a0-6)) + ) + (set! *actor-list-length* (+ *actor-list-length* 1)) + (label cfg-17) + (set! a0-5 v1-18) + *collide-hit-by-player-list* + (set! v1-18 (-> v1-18 next0)) + ) + (label cfg-18) + (b! (!= a0-5 (-> *collide-hit-by-player-list* alive-list-end)) cfg-13 :delay (nop!)) + ) + (label cfg-20) + (let ((s5-0 0)) + (b! #t cfg-29 :delay (nop!)) + (label cfg-21) + (let* ((v1-23 (-> *actor-list* s5-0)) + (a0-9 (-> v1-23 root-prim)) + ) + (when (logtest? (-> a0-9 prim-core collide-as) (collide-spec jak bot enemy hit-by-others-list player-list)) + (.lvf vf1 (&-> obj collide-bounds quad)) + (.lvf vf2 (&-> a0-9 prim-core world-sphere quad)) + (.sub.vf vf3 vf1 vf2) + (.add.w.vf vf4 vf1 vf2 :mask #b1000) + (.mul.vf vf3 vf3 vf3 :mask #b111) + (.mul.w.vf vf4 vf4 vf4 :mask #b1000) + (.mul.x.vf acc vf0 vf3 :mask #b1000) + (.add.mul.y.vf acc vf0 vf3 acc :mask #b1000) + (.add.mul.z.vf vf3 vf0 vf3 acc :mask #b1000) + (.sub.w.vf vf3 vf3 vf4 :mask #b1000) + (let ((f0-2 0.0)) + (.add.w.vf vf3 vf0 vf3 :mask #b1) + (.mov a0-10 vf3) + (let ((s4-0 (-> v1-23 process))) + (b! (< f0-2 a0-10) cfg-27) + (let ((a1-29 (if (type? s4-0 process-focusable) + s4-0 + ) + ) + ) + (if a1-29 + (push-process obj (the-as process-focusable a1-29)) + ) + ) + ) + ) + (label cfg-27) + 0 + ) + ) + (+! s5-0 1) + (label cfg-29) + (b! (< s5-0 *actor-list-length*) cfg-21) + ) + 0 + (none) + ) + ) + +(defmethod setup flow-control ((obj flow-control)) + (local-vars (sv-32 flow-section) (sv-48 flow-section)) + (let* ((s5-0 (-> obj path)) + (s4-0 (-> s5-0 curve num-cverts)) + (s3-0 (new 'stack-no-clear 'vector)) + ) + (let ((s2-0 (new 'process 'flow-section-array (+ s4-0 -1)))) + (set! (-> obj sections) s2-0) + (set! (-> obj collide-bounds quad) (the-as uint128 0)) + (get-point-in-path! s5-0 s3-0 0.0 'interp) + (vector+! (the-as vector (-> obj collide-bounds)) (the-as vector (-> obj collide-bounds)) s3-0) + (let ((s1-0 (+ s4-0 -1))) + (set! sv-32 (the-as flow-section #f)) + (dotimes (s0-0 s1-0) + (set! sv-48 (-> s2-0 data s0-0)) + (set! (-> sv-48 start quad) (-> s3-0 quad)) + (get-point-in-path! s5-0 s3-0 (the float (+ s0-0 1)) 'interp) + (vector+! (the-as vector (-> obj collide-bounds)) (the-as vector (-> obj collide-bounds)) s3-0) + (vector-! (-> sv-48 pull-dir) s3-0 (-> sv-48 start)) + (vector-normalize! (-> sv-48 pull-dir) 1.0) + (set! (-> sv-48 trailing quad) (-> sv-48 pull-dir quad)) + (set! (-> sv-48 trailing y) 0.0) + (vector-normalize! (-> sv-48 trailing) 1.0) + (set-vector! (-> sv-48 radial-dir) (- (-> sv-48 trailing z)) 0.0 (-> sv-48 trailing x) 1.0) + (set! (-> sv-48 trailing w) (- (vector-dot s3-0 (the-as vector (-> sv-48 trailing))))) + (when sv-32 + (vector+! + (the-as vector (-> sv-32 trailing)) + (the-as vector (-> sv-32 trailing)) + (the-as vector (-> sv-48 trailing)) + ) + (vector-normalize! (-> sv-32 trailing) 1.0) + (set! (-> sv-32 trailing w) (- (vector-dot (-> sv-48 start) (the-as vector (-> sv-32 trailing))))) + ) + (set! sv-32 sv-48) + sv-32 + ) + ) + ) + (let ((s2-1 (-> obj sections data))) + (set! (-> obj leading quad) (-> s2-1 0 pull-dir quad)) + (set! (-> obj leading y) 0.0) + (vector-normalize! (-> obj leading) 1.0) + (set! (-> obj leading w) (- (vector-dot (the-as vector (-> s2-1 0)) (the-as vector (-> obj leading))))) + ) + (let ((f0-19 (/ 1.0 (the float s4-0))) + (f30-0 0.0) + ) + (vector-float*! (the-as vector (-> obj collide-bounds)) (the-as vector (-> obj collide-bounds)) f0-19) + (dotimes (s2-2 s4-0) + (get-point-in-path! s5-0 s3-0 (the float s2-2) 'interp) + (let ((f0-22 (vector-vector-distance-squared s3-0 (-> obj collide-bounds)))) + (if (< f30-0 f0-22) + (set! f30-0 f0-22) + ) + ) + ) + (set! (-> obj collide-bounds r) (+ (sqrtf f30-0) (-> obj belt-radius))) + ) + ) + 0 + (none) + ) + (defmethod new flow-control ((allocation symbol) (type-to-make type) (arg0 process-drawable) (arg1 res-lump)) (if (not arg1) (set! arg1 (-> arg0 entity)) @@ -97,7 +394,7 @@ ) (set! (-> s5-0 speed) (res-lump-float arg1 'speed :default 12288.0)) (set! (-> s5-0 belt-radius) (res-lump-float arg1 'extra-radius :default 16384.0)) - ((method-of-object s5-0 flow-control-method-10)) + (setup s5-0) ) (else (go process-drawable-art-error "no flow path") @@ -108,3 +405,7 @@ s5-0 ) ) + + + + diff --git a/goal_src/jak2/engine/gfx/lightning.gc b/goal_src/jak2/engine/gfx/lightning.gc index b82c609b26..7d424ff394 100644 --- a/goal_src/jak2/engine/gfx/lightning.gc +++ b/goal_src/jak2/engine/gfx/lightning.gc @@ -7,3 +7,6 @@ ;; DECOMP BEGINS + (kmemopen global "part-tables") + (define *lightning-spec-id-table* (new 'global 'boxed-array lightning-spec 128)) + (kmemclose) \ No newline at end of file diff --git a/goal_src/jak2/engine/gfx/merc/merc-death.gc b/goal_src/jak2/engine/gfx/merc/merc-death.gc index dc5cc9db40..15e6eea350 100644 --- a/goal_src/jak2/engine/gfx/merc/merc-death.gc +++ b/goal_src/jak2/engine/gfx/merc/merc-death.gc @@ -7,3 +7,157 @@ ;; DECOMP BEGINS +(define *merc-death-globals* (new 'global 'vector)) + +(deftype death-info (basic) + ((vertex-skip uint16 :offset-assert 4) + (timer uint8 :offset-assert 6) + (overlap uint8 :offset-assert 7) + (effect uint32 :offset-assert 8) + (sound symbol :offset-assert 12) + ) + :method-count-assert 9 + :size-assert #x10 + :flag-assert #x900000010 + ) + +(defun birth-func-death-sparks () + 0 + (none) + ) + +(define death-seed + (new 'static 'death-info :vertex-skip #x8 :timer #xe0 :overlap #xff :effect #x48 :sound 'temp-enemy-die) + ) + +(defun start-seed-effect ((arg0 process-drawable) (arg1 vector) (arg2 cspace)) + (let ((v1-0 (-> arg0 draw)) + (a1-1 death-seed) + ) + (set! (-> v1-0 death-vertex-skip) (-> a1-1 vertex-skip)) + (set! (-> v1-0 death-effect) (-> a1-1 effect)) + (set! (-> v1-0 death-timer) (+ (-> a1-1 timer) 1)) + (set! (-> v1-0 death-timer-org) (-> v1-0 death-timer)) + (set! (-> v1-0 death-draw-overlap) (-> a1-1 overlap)) + ) + (send-event + arg0 + 'trans-hook + (lambda :behavior process-drawable () (set! (-> self draw death-timer) (the-as uint 200)) (none)) + ) + 0 + (none) + ) + +(defpart 72 + :init-specs ((sp-flt spt-scale-x (meters 1)) + (sp-flt spt-rot-x 409.6) + (sp-copy-from-other spt-scale-y -4) + (sp-rnd-flt spt-r 64.0 196.0 1.0) + (sp-rnd-flt spt-g 196.0 64.0 1.0) + (sp-flt spt-b 0.0) + (sp-rnd-flt spt-a 4.0 2.0 1.0) + (sp-int spt-timer 5) + (sp-cpuinfo-flags sp-cpuinfo-flag-2 sp-cpuinfo-flag-3 glow) + (sp-func spt-func 'sparticle-texture-glow-soft) + ) + ) + +(define death-default + (new 'static 'death-info :vertex-skip #xa :timer #x4b :overlap #x4 :effect #x49 :sound 'enemy-fizz) + ) + +(define death-warp-in + (new 'static 'death-info :vertex-skip #x96 :timer #x4b :effect #x4a :sound 'warpgate-tele) + ) + +(define death-warp-out + (new 'static 'death-info :vertex-skip #x96 :timer #x96 :effect #x4a :sound 'warpgate-tele) + ) + +(defun sparticle-texture-glow-soft ((arg0 sparticle-system) (arg1 sparticle-cpuinfo) (arg2 vector)) + (particle-adgif-callback (-> arg1 adgif) (new 'static 'texture-id :index #xca :page #xc)) + (set! (-> arg1 sp-func) (the-as (function sparticle-system sparticle-cpuinfo sprite-vec-data-3d uint none) 0)) + 0 + (none) + ) + +(defpart 74 + :init-specs ((sp-rnd-flt spt-scale-x (meters 0.5) (meters 0.5) 1.0) + (sp-copy-from-other spt-scale-y -4) + (sp-rnd-flt spt-r 32.0 32.0 1.0) + (sp-rnd-flt spt-g 32.0 64.0 1.0) + (sp-rnd-flt spt-b 128.0 128.0 1.0) + (sp-flt spt-a 128.0) + (sp-rnd-flt spt-scalevel-x (meters 0.02) (meters 0.02) 1.0) + (sp-copy-from-other spt-scalevel-y -4) + (sp-rnd-flt spt-fade-a 0.0 -1.28 1.0) + (sp-rnd-flt spt-friction 0.92 0.02 1.0) + (sp-int spt-timer 500) + (sp-cpuinfo-flags sp-cpuinfo-flag-0 sp-cpuinfo-flag-3 sp-cpuinfo-flag-12) + (sp-int-plain-rnd spt-next-time 30 19 1) + (sp-launcher-by-id spt-next-launcher 75) + ) + ) + +(defpart 75 + :init-specs ((sp-rnd-flt spt-scale-x (meters 0.3) (meters 0.2) 1.0) + (sp-copy-from-other spt-scale-y -4) + (sp-rnd-flt spt-a 64.0 32.0 1.0) + (sp-rnd-flt spt-omega 8.192 6.144 1.0) + (sp-rnd-flt spt-vel-x (meters -0.053333335) (meters 0.10666667) 1.0) + (sp-rnd-flt spt-vel-y (meters -0.026666667) (meters 0.093333334) 1.0) + (sp-rnd-flt spt-vel-z (meters -0.053333335) (meters 0.10666667) 1.0) + (sp-rnd-flt spt-scalevel-x (meters -0.001) (meters -0.008) 1.0) + (sp-copy-from-other spt-scalevel-y -4) + (sp-flt spt-fade-a 0.0) + (sp-func spt-func 'sparticle-motion-blur) + ) + ) + +(defpart 73 + :init-specs ((sp-rnd-flt spt-scale-x (meters 0.5) (meters 0.5) 1.0) + (sp-copy-from-other spt-scale-y -4) + (sp-rnd-flt spt-r 96.0 150.0 1.0) + (sp-rnd-flt spt-g 32.0 64.0 1.0) + (sp-rnd-flt spt-b 128.0 128.0 1.0) + (sp-flt spt-a 128.0) + (sp-rnd-flt spt-scalevel-x (meters 0.02) (meters 0.02) 1.0) + (sp-copy-from-other spt-scalevel-y -4) + (sp-rnd-flt spt-fade-a 0.0 -1.28 1.0) + (sp-rnd-flt spt-friction 0.92 0.02 1.0) + (sp-int spt-timer 500) + (sp-cpuinfo-flags sp-cpuinfo-flag-0 sp-cpuinfo-flag-3 sp-cpuinfo-flag-12) + (sp-int-plain-rnd spt-next-time 30 19 1) + (sp-launcher-by-id spt-next-launcher 76) + ) + ) + +(defpart 76 + :init-specs ((sp-rnd-flt spt-scale-x (meters 0.3) (meters 0.2) 1.0) + (sp-copy-from-other spt-scale-y -4) + (sp-rnd-flt spt-a 64.0 32.0 1.0) + (sp-rnd-flt spt-omega 8.192 6.144 1.0) + (sp-rnd-flt spt-vel-x (meters -0.053333335) (meters 0.10666667) 1.0) + (sp-rnd-flt spt-vel-y (meters -0.026666667) (meters 0.093333334) 1.0) + (sp-rnd-flt spt-vel-z (meters -0.053333335) (meters 0.10666667) 1.0) + (sp-rnd-flt spt-scalevel-x (meters -0.001) (meters -0.008) 1.0) + (sp-copy-from-other spt-scalevel-y -4) + (sp-flt spt-fade-a 0.0) + (sp-func spt-func 'sparticle-motion-blur) + ) + ) + +(defun merc-death-spawn ((arg0 int) (arg1 vector) (arg2 vector)) + (let ((v1-2 (-> *part-id-table* arg0))) + (if (and (nonzero? v1-2) (= (-> v1-2 type) sparticle-launcher)) + (sp-launch-particles-death *sp-particle-system-2d* v1-2 arg1) + ) + ) + 0 + (none) + ) + + + + diff --git a/goal_src/jak2/engine/spatial-hash/actor-hash.gc b/goal_src/jak2/engine/spatial-hash/actor-hash.gc index 5ab10d7c0f..f67f481dd6 100644 --- a/goal_src/jak2/engine/spatial-hash/actor-hash.gc +++ b/goal_src/jak2/engine/spatial-hash/actor-hash.gc @@ -7,3 +7,209 @@ ;; DECOMP BEGINS +(kmemopen global "actor-hash") +(define *actor-hash* (new 'global 'spatial-hash 4096 256)) +(kmemclose) + +(deftype actor-cshape-ptr (structure) + ((cshape collide-shape :offset-assert 0) + ) + :method-count-assert 9 + :size-assert #x4 + :flag-assert #x900000004 + ) + +(deftype actor-hash-bucket (structure) + ((length int16 :offset-assert 0) + (max-length int16 :offset-assert 2) + (data (inline-array actor-cshape-ptr) :offset-assert 4) + ) + :allow-misaligned + :method-count-assert 10 + :size-assert #x8 + :flag-assert #xa00000008 + (:methods + (add-actor-cshape (_type_ collide-shape) none 9) + ) + ) + +(defmethod add-actor-cshape actor-hash-bucket ((obj actor-hash-bucket) (arg0 collide-shape)) + (let ((v1-0 (-> obj length))) + (when (< v1-0 (-> obj max-length)) + (set! (-> obj data v1-0 cshape) arg0) + (set! (-> obj length) (+ v1-0 1)) + ) + ) + 0 + (none) + ) + +(deftype actor-hash-buckets (structure) + ((hash spatial-hash :offset-assert 0) + (list engine :offset-assert 4) + (data actor-hash-bucket 4 :inline :offset-assert 8) + (tpos vector :inline :offset-assert 80) + ) + :method-count-assert 10 + :size-assert #x60 + :flag-assert #xa00000060 + (:methods + (hash-actors (_type_) none 9) + ) + ) + +(defmethod hash-actors actor-hash-buckets ((obj actor-hash-buckets)) + (local-vars (sv-16 hash-object-info) (sv-32 collide-prim-core) (sv-48 collide-shape) (sv-64 hash-object-info)) + (set! (-> obj hash) *actor-hash*) + (set! (-> obj list) *collide-hit-by-others-list*) + (clear-objects! (-> obj hash)) + (cond + ((>= 256 (-> obj list length)) + (let ((v1-5 (-> obj list alive-list next0))) + (-> obj list) + (let ((s5-0 (-> v1-5 next0))) + (while (!= v1-5 (-> obj list alive-list-end)) + (let* ((s4-0 (the-as collide-shape (-> (the-as connection v1-5) param1))) + (s3-0 (-> obj hash)) + (s1-0 (-> s4-0 root-prim prim-core)) + (s0-0 s4-0) + (s2-0 (-> s3-0 object-count)) + ) + (set! s2-0 + (cond + ((< s2-0 (-> s3-0 max-object-count)) + (let ((a0-7 (-> s3-0 sphere-array s2-0))) + (set! sv-16 (-> s3-0 object-array s2-0)) + (mem-copy! (the-as pointer a0-7) (the-as pointer s1-0) 16) + ) + (set! (-> sv-16 object) s0-0) + (dotimes (v1-12 3) + (set! (-> s3-0 box-min v1-12) + (fmin (-> s3-0 box-min v1-12) (- (-> s1-0 world-sphere data v1-12) (-> s1-0 world-sphere w))) + ) + (set! (-> s3-0 box-max v1-12) + (fmax (-> s3-0 box-max v1-12) (+ (-> s1-0 world-sphere data v1-12) (-> s1-0 world-sphere w))) + ) + ) + (+! (-> s3-0 object-count) 1) + s2-0 + ) + (else + -1 + ) + ) + ) + (set! (-> s4-0 actor-hash-index) s2-0) + ) + (set! v1-5 s5-0) + (-> obj list) + (set! s5-0 (-> s5-0 next0)) + ) + ) + ) + ) + (else + (set! (-> obj tpos quad) (-> (target-pos 0) quad)) + (dotimes (v1-21 4) + (set! (-> obj data v1-21 length) 0) + ) + (let ((v1-25 (-> obj list alive-list next0))) + (-> obj list) + (let ((s5-2 (-> v1-25 next0))) + (while (!= v1-25 (-> obj list alive-list-end)) + (let* ((s4-1 (the-as collide-shape (-> (the-as connection v1-25) param1))) + (f0-4 (vector-vector-distance-squared (-> obj tpos) (-> s4-1 trans))) + (f1-4 102400.0) + ) + (cond + ((< f0-4 (* f1-4 f1-4)) + ((method-of-type actor-hash-bucket add-actor-cshape) (the-as actor-hash-bucket (-> obj data)) s4-1) + ) + ((let ((f1-7 204800.0)) + (< f0-4 (* f1-7 f1-7)) + ) + (add-actor-cshape (-> obj data 1) s4-1) + ) + ((let ((f1-10 307200.0)) + (< f0-4 (* f1-10 f1-10)) + ) + (add-actor-cshape (-> obj data 2) s4-1) + ) + (else + (add-actor-cshape (-> obj data 3) s4-1) + ) + ) + ) + (set! v1-25 s5-2) + (-> obj list) + (set! s5-2 (-> s5-2 next0)) + ) + ) + ) + (dotimes (s5-3 4) + (let ((s4-2 (-> obj data s5-3))) + (countdown (s3-1 (-> s4-2 length)) + (let ((s2-1 (-> s4-2 data s3-1 cshape)) + (s1-1 (-> obj hash)) + ) + (set! sv-32 (-> s2-1 root-prim prim-core)) + (set! sv-48 s2-1) + (let ((s0-1 (-> s1-1 object-count))) + (set! s0-1 + (cond + ((< s0-1 (-> s1-1 max-object-count)) + (let ((a0-40 (-> s1-1 sphere-array s0-1))) + (set! sv-64 (-> s1-1 object-array s0-1)) + (mem-copy! (the-as pointer a0-40) (the-as pointer sv-32) 16) + ) + (set! (-> sv-64 object) sv-48) + (dotimes (v1-53 3) + (set! (-> s1-1 box-min v1-53) + (fmin (-> s1-1 box-min v1-53) (- (-> sv-32 world-sphere data v1-53) (-> sv-32 world-sphere w))) + ) + (set! (-> s1-1 box-max v1-53) + (fmax (-> s1-1 box-max v1-53) (+ (-> sv-32 world-sphere data v1-53) (-> sv-32 world-sphere w))) + ) + ) + (+! (-> s1-1 object-count) 1) + s0-1 + ) + (else + -1 + ) + ) + ) + (set! (-> s2-1 actor-hash-index) s0-1) + ) + ) + ) + ) + ) + ) + ) + (update-from-spheres (-> obj hash)) + 0 + (none) + ) + +(define *actor-hash-buckets* + (new 'static 'actor-hash-buckets + :data (new 'static 'inline-array actor-hash-bucket 4 + (new 'static 'actor-hash-bucket :max-length #x100 :data (new 'static 'inline-array actor-cshape-ptr 256)) + (new 'static 'actor-hash-bucket :max-length #x100 :data (new 'static 'inline-array actor-cshape-ptr 256)) + (new 'static 'actor-hash-bucket :max-length #x100 :data (new 'static 'inline-array actor-cshape-ptr 256)) + (new 'static 'actor-hash-bucket :max-length #x100 :data (new 'static 'inline-array actor-cshape-ptr 256)) + ) + ) + ) + +(defun update-actor-hash () + (reset! (-> *perf-stats* data (perf-stat-bucket actor-hash))) + (hash-actors *actor-hash-buckets*) + (read! (-> *perf-stats* data (perf-stat-bucket actor-hash))) + (none) + ) + + + + diff --git a/goal_src/jak2/engine/spatial-hash/spatial-hash-h.gc b/goal_src/jak2/engine/spatial-hash/spatial-hash-h.gc index 300f605226..5ead921ef2 100644 --- a/goal_src/jak2/engine/spatial-hash/spatial-hash-h.gc +++ b/goal_src/jak2/engine/spatial-hash/spatial-hash-h.gc @@ -31,7 +31,7 @@ ((work grid-hash-work :offset-assert 4) (search-box grid-hash-box :inline :offset-assert 8) (bucket-size int16 :offset-assert 14) - (axis-scale uint32 3 :offset-assert 16) + (axis-scale float 3 :offset-assert 16) (dimension-array int8 3 :offset-assert 28) (vertical-cell-count int8 :offset-assert 31) (bucket-array (pointer grid-hash-word) :offset-assert 32) @@ -50,22 +50,22 @@ :size-assert #x58 :flag-assert #x1900000058 (:methods - (new (symbol type process int) _type_ 0) - (grid-hash-method-9 (_type_ int (array float) int) none 9) - (grid-hash-method-10 (_type_) none 10) - (grid-hash-method-11 (_type_) none 11) - (grid-hash-method-12 (_type_ vector) grid-hash-box 12) - (grid-hash-method-13 (_type_ vector float) grid-hash-box 13) - (draw-grid (_type_ rgba) none 14) + (new (symbol type int int) _type_ 0) + (update-grid-for-objects-in-box (_type_ int vector vector) none 9) + (clear-bucket-array (_type_) none 10) + (setup-search-box (_type_ int vector vector vector) none 11) + (search-for-point (_type_ vector) (pointer uint8) 12) + (search-for-sphere (_type_ vector float) (pointer uint8) 13) + (draw (_type_ rgba) none 14) (dump-grid-info (_type_) none 15) - (grid-hash-method-16 (_type_ grid-hash-box grid-hash-box) none 16) - (grid-hash-method-17 (_type_) none 17) + (verify-bits-in-bucket (_type_ grid-hash-box grid-hash-box) none 16) + (box-of-everything (_type_ object grid-hash-box) none 17) (grid-hash-method-18 (_type_ grid-hash-box int) none 18) (grid-hash-method-19 (_type_ grid-hash-box int) none 19) - (grid-hash-method-20 (_type_ grid-hash-box (pointer uint8)) none 20) - (grid-hash-method-21 (_type_ float int int) none 21) - (grid-hash-method-22 (_type_ grid-hash-box sphere) none 22) - (grid-hash-method-23 (_type_ grid-hash-box vector vector float) none 23) + (do-search! (_type_ grid-hash-box (pointer uint8)) none 20) + (set-up-box (_type_ grid-hash-box vector vector) none 21) + (sphere-to-grid-box (_type_ grid-hash-box sphere) none 22) + (line-sphere-to-grid-box (_type_ grid-hash-box vector vector float) none 23) (update-grid (_type_) none 24) ) ) @@ -96,15 +96,16 @@ :size-assert #x68 :flag-assert #x2200000068 (:methods + (new (symbol type int int) _type_ 0) (clear-objects! (_type_) none 25) - (sphere-hash-method-26 (_type_ vector) none 26) - (sphere-hash-method-27 (_type_) none 27) - (sphere-hash-method-28 (_type_) none 28) + (add-a-sphere (_type_ vector) int 26) + (add-a-sphere-with-flag (_type_ vector int) int 27) + (update-from-spheres (_type_) none 28) (sphere-hash-method-29 (_type_ find-nav-sphere-ids-params int int int) none 29) (sphere-hash-method-30 (_type_ find-nav-sphere-ids-params) none 30) (sphere-hash-method-31 (_type_ vector int int) none 31) (sphere-hash-method-32 (_type_ vector vector float int) symbol 32) - (sphere-hash-method-33 (_type_ object int) none 33) + (sphere-hash-method-33 (_type_ sphere int) none 33) ) ) @@ -119,20 +120,21 @@ (deftype spatial-hash (sphere-hash) - ((object-array (pointer hash-object-info) :offset-assert 104) - (mem-object-array (pointer hash-object-info) :offset-assert 108) - (spr-object-array (pointer hash-object-info) :offset-assert 112) + ((object-array (inline-array hash-object-info) :offset-assert 104) + (mem-object-array (inline-array hash-object-info) :offset-assert 108) + (spr-object-array (inline-array hash-object-info) :offset-assert 112) ) :method-count-assert 41 :size-assert #x74 :flag-assert #x2900000074 (:methods - (spatial-hash-method-34 (_type_ vector hash-object-info) int 34) + (new (symbol type int int) _type_ 0) + (add-an-object (_type_ vector hash-object-info) int 34) (spatial-hash-method-35 (_type_) none 35) (fill-actor-list-for-sphere (_type_ sphere (pointer collide-shape) int) int 36) (spatial-hash-method-37 (_type_) none 37) - (spatial-hash-method-38 (_type_) none 38) + (fill-actor-list-for-vec+r (_type_ vector (pointer collide-shape) int) none 38) (spatial-hash-method-39 (_type_ object hash-object-info) none 39) - (spatial-hash-method-40 (_type_) none 40) + (validate-objects (_type_) none 40) ) ) diff --git a/goal_src/jak2/engine/spatial-hash/spatial-hash.gc b/goal_src/jak2/engine/spatial-hash/spatial-hash.gc index cd00b66b00..35468d364e 100644 --- a/goal_src/jak2/engine/spatial-hash/spatial-hash.gc +++ b/goal_src/jak2/engine/spatial-hash/spatial-hash.gc @@ -7,3 +7,902 @@ ;; DECOMP BEGINS +(deftype grid-hash-work (basic) + ((result-words uint8 32 :offset 16) + (result-bits uint8 32 :offset 16) + (object-id int32 :offset-assert 48) + (temp-box-min vector :inline :offset-assert 64) + (temp-box-max vector :inline :offset-assert 80) + (visit-count int32 :offset-assert 96) + (temp-time uint32 :offset-assert 100) + (queue-object-time uint32 :offset-assert 104) + (make-hash-time uint32 :offset-assert 108) + (search-time uint32 :offset-assert 112) + (add-object-time uint32 :offset-assert 116) + ) + :method-count-assert 9 + :size-assert #x78 + :flag-assert #x900000078 + ) + +(define *grid-hash-work* (new 'static 'grid-hash-work)) + +(defmethod new grid-hash ((allocation symbol) (type-to-make type) (arg0 int) (arg1 int)) + (let ((gp-0 (the-as object (object-new allocation type-to-make (the-as int (-> type-to-make size)))))) + (when (zero? (the-as grid-hash gp-0)) + (set! gp-0 0) + (goto cfg-4) + ) + (set! (-> (the-as grid-hash gp-0) work) *grid-hash-work*) + (set! (-> (the-as grid-hash gp-0) object-count) 0) + (set! (-> (the-as grid-hash gp-0) bucket-memory-size) arg0) + (set! (-> (the-as grid-hash gp-0) vertical-cell-count) 1) + (set! (-> (the-as grid-hash gp-0) min-cell-size) 16384.0) + (set! (-> (the-as grid-hash gp-0) mem-bucket-array) + (the-as (pointer grid-hash-word) (malloc allocation arg0)) + ) + (set! (-> (the-as grid-hash gp-0) spr-bucket-array) (the-as (pointer grid-hash-word) #x70000000)) + (set! (-> (the-as grid-hash gp-0) bucket-array) (-> (the-as grid-hash gp-0) mem-bucket-array)) + (set! (-> (the-as grid-hash gp-0) debug-draw) #f) + (set! (-> (the-as grid-hash gp-0) use-scratch-ram) #f) + (label cfg-4) + (the-as grid-hash gp-0) + ) + ) + + +(defmethod verify-bits-in-bucket grid-hash ((obj grid-hash) (arg0 grid-hash-box) (arg1 grid-hash-box)) + (let ((s5-0 0)) + 0 + (let ((v1-1 8) + (a0-1 (-> obj object-count)) + (a1-2 (* (-> obj bucket-size) 8)) + ) + (while (< a0-1 a1-2) + (let ((a3-0 (- a0-1 (* (/ a0-1 v1-1) v1-1)))) + (set! s5-0 (logior s5-0 (ash 1 a3-0))) + ) + (+! a0-1 1) + ) + ) + (dotimes (s4-0 (-> obj bucket-count)) + (let ((a3-2 (-> obj bucket-array (+ (-> obj bucket-size) -1 (* s4-0 (-> obj bucket-size)))))) + (when (logtest? a3-2 s5-0) + (format 0 "bad bits in bucket ~d bucket-word ~8x test-word ~8x~%" s4-0 a3-2 s5-0) + (break!) + 0 + ) + ) + ) + ) + 0 + (none) + ) + +(defmethod box-of-everything grid-hash ((obj grid-hash) (arg0 object) (arg1 grid-hash-box)) + (dotimes (v1-0 3) + (set! (-> arg1 min v1-0) (-> obj dimension-array v1-0)) + (set! (-> arg1 max v1-0) -1) + ) + (let* ((v1-3 (-> obj bucket-size)) + (a3-4 (* (-> obj dimension-array 0) v1-3)) + (t0-3 (* (-> obj dimension-array 2) a3-4)) + (t1-0 (-> obj dimension-array 0)) + (t2-0 (-> obj dimension-array 2)) + (t3-0 (-> obj dimension-array 1)) + (a0-2 (&-> (-> obj bucket-array) (/ (the-as int arg0) 8))) + (a1-2 (ash 1 (logand (the-as int arg0) 7))) + ) + (dotimes (t4-3 t3-0) + (let ((t5-0 a0-2)) + (dotimes (t6-0 t2-0) + (let ((t7-0 t5-0)) + (dotimes (t8-0 t1-0) + (when (logtest? (-> t7-0 0) a1-2) + (set! (-> arg1 min 0) (min (-> arg1 min 0) t8-0)) + (set! (-> arg1 min 1) (min (-> arg1 min 1) t4-3)) + (set! (-> arg1 min 2) (min (-> arg1 min 2) t6-0)) + (set! (-> arg1 max 0) (max (-> arg1 max 0) t8-0)) + (set! (-> arg1 max 1) (max (-> arg1 max 1) t4-3)) + (set! (-> arg1 max 2) (max (-> arg1 max 2) t6-0)) + ) + (&+! t7-0 v1-3) + ) + ) + (&+! t5-0 a3-4) + ) + ) + (&+! a0-2 t0-3) + ) + ) + 0 + (none) + ) + +(defun-debug validate-bucket-bits ((arg0 grid-hash) (arg1 (pointer grid-hash-word))) + (let ((s3-0 (-> arg0 object-count)) + (s2-0 (* (-> arg0 bucket-size) 8)) + (gp-0 0) + (s5-0 0) + ) + (while (< s3-0 s2-0) + (let* ((s1-0 (/ s3-0 8)) + (a0-1 (- s3-0 (* s1-0 8))) + ) + (when (logtest? (-> arg1 s1-0) (ash 1 a0-1)) + (format 0 "bit ~d, " s3-0) + (+! gp-0 1) + (set! s5-0 (the-as int (-> arg1 s1-0))) + ) + ) + (+! s3-0 1) + ) + (when (> gp-0 0) + (format 0 "~%~d bad bits found~%" gp-0) + (format 0 "bad-word ~x~%" s5-0) + (break!) + 0 + ) + ) + (the-as symbol 0) + ) + +;; definition for method 18 of type grid-hash +;; ERROR: function was not converted to expressions. Cannot decompile. +(defmethod-mips2c "(method 18 grid-hash)" 18 grid-hash) + +;; definition for method 19 of type grid-hash +;; ERROR: function was not converted to expressions. Cannot decompile. +(defmethod-mips2c "(method 19 grid-hash)" 19 grid-hash) + +;; definition for method 20 of type grid-hash +;; ERROR: function was not converted to expressions. Cannot decompile. +(defmethod-mips2c "(method 20 grid-hash)" 20 grid-hash) + + +(defmethod set-up-box grid-hash ((obj grid-hash) (arg0 grid-hash-box) (arg1 vector) (arg2 vector)) + (dotimes (v1-0 3) + (set! (-> arg0 min v1-0) + (the int + (fmax + 0.0 + (fmin + (* (- (-> arg1 data v1-0) (-> obj box-min v1-0)) (-> obj axis-scale v1-0)) + (the float (+ (-> obj dimension-array v1-0) -1)) + ) + ) + ) + ) + (set! (-> arg0 max v1-0) + (the int (fmax 0.0 (fmin + (* (- (-> arg2 data v1-0) (-> obj box-min v1-0)) (-> obj axis-scale v1-0)) + (the float (+ (-> obj dimension-array v1-0) -1)) + ) + ) + ) + ) + ) + 0 + (none) + ) + +;; definition for method 22 of type grid-hash +;; ERROR: function was not converted to expressions. Cannot decompile. +(defmethod-mips2c "(method 22 grid-hash)" 22 grid-hash) + + +(defmethod line-sphere-to-grid-box grid-hash ((obj grid-hash) (arg0 grid-hash-box) (arg1 vector) (arg2 vector) (arg3 float)) + (let ((s4-0 (new 'stack-no-clear 'grid-hash-box)) + (s5-0 (new 'stack-no-clear 'grid-hash-box)) + ) + (let ((v1-0 (new 'stack-no-clear 'vector)) + (s2-0 (new 'stack-no-clear 'vector)) + ) + (set! (-> v1-0 quad) (-> arg1 quad)) + (vector+! s2-0 arg1 arg2) + (set! (-> v1-0 w) arg3) + (set! (-> s2-0 w) arg3) + (sphere-to-grid-box obj s4-0 (the-as sphere v1-0)) + (sphere-to-grid-box obj s5-0 (the-as sphere s2-0)) + ) + (set! (-> arg0 min 0) (min (-> s4-0 min 0) (-> s5-0 min 0))) + (set! (-> arg0 min 1) (min (-> s4-0 min 1) (-> s5-0 min 1))) + (set! (-> arg0 min 2) (min (-> s4-0 min 2) (-> s5-0 min 2))) + (set! (-> arg0 max 0) (max (-> s4-0 max 0) (-> s5-0 max 0))) + (set! (-> arg0 max 1) (max (-> s4-0 max 1) (-> s5-0 max 1))) + (set! (-> arg0 max 2) (max (-> s4-0 max 2) (-> s5-0 max 2))) + ) + 0 + (none) + ) + +(defmethod clear-bucket-array grid-hash ((obj grid-hash)) + (let ((v1-5 (/ (+ (* (* (* (-> obj dimension-array 0) (-> obj dimension-array 1)) (-> obj dimension-array 2)) + (-> obj bucket-size) + ) + 15 + ) + 16 + ) + ) + (a0-1 (the-as (pointer uinteger) (-> obj bucket-array))) + ) + (while (nonzero? v1-5) + (+! v1-5 -1) + (set! (-> (the-as (pointer uint128) a0-1) 0) (the-as uint128 0)) + (set! a0-1 (&-> (the-as (pointer grid-hash-word) a0-1) 16)) + ) + ) + 0 + (none) + ) + +(defmethod update-grid grid-hash ((obj grid-hash)) + (let ((v1-0 (new 'stack-no-clear 'vector))) + (dotimes (a1-0 3) + (set! (-> v1-0 data a1-0) (fmax (-> obj min-cell-size) (- (-> obj box-max a1-0) (-> obj box-min a1-0)))) + ) + (b! + (and (> (-> obj object-count) 0) (< 0.0 (-> v1-0 x)) (< 0.0 (-> v1-0 y)) (< 0.0 (-> v1-0 z))) + cfg-23 + :delay (empty-form) + ) + (set! (-> obj bucket-count) 1) + (set! (-> obj bucket-size) 1) + (dotimes (v1-3 3) + (set! (-> obj box-min v1-3) 0.0) + (set! (-> obj box-max v1-3) 0.0) + (set! (-> obj axis-scale v1-3) 0.0) + (set! (-> obj dimension-array v1-3) 1) + ) + (let* ((v1-6 obj) + (a0-6 + (/ (+ (* (* (* (-> v1-6 dimension-array 0) (-> v1-6 dimension-array 1)) (-> v1-6 dimension-array 2)) + (-> v1-6 bucket-size) + ) + 15 + ) + 16 + ) + ) + (v1-7 (the-as (pointer uinteger) (-> v1-6 bucket-array))) + ) + (while (nonzero? a0-6) + (+! a0-6 -1) + (set! (-> (the-as (pointer uint128) v1-7) 0) (the-as uint128 0)) + (set! v1-7 (&-> (the-as (pointer grid-hash-word) v1-7) 16)) + ) + ) + 0 + (b! #t cfg-41 :delay (nop!)) + (label cfg-23) + (let ((a1-18 8)) + (set! (-> obj bucket-size) (/ (+ a1-18 -1 (-> obj object-count)) a1-18)) + ) + (set! (-> obj bucket-count) + (min (* (-> obj object-count) 16) (/ (-> obj bucket-memory-size) (-> obj bucket-size))) + ) + (let ((f0-11 + (sqrtf + (/ (the float (-> obj bucket-count)) (* (-> v1-0 x) (-> v1-0 z) (the float (-> obj vertical-cell-count)))) + ) + ) + ) + (let ((a1-27 (min 126 (+ (-> obj bucket-count) -1)))) + (set! (-> obj dimension-array 0) (max 1 (min (the int (* f0-11 (-> v1-0 x))) a1-27))) + (set! (-> obj dimension-array 1) (-> obj vertical-cell-count)) + (set! (-> obj dimension-array 2) (max 1 (min (the int (* f0-11 (-> v1-0 z))) a1-27))) + ) + (let* ((f1-15 (* f0-11 (-> v1-0 z))) + (f1-17 (- f1-15 (the float (the int f1-15)))) + (f0-12 (* f0-11 (-> v1-0 x))) + ) + (cond + ((< f1-17 (- f0-12 (the float (the int f0-12)))) + (if (>= (-> obj bucket-count) + (* (* (+ (-> obj dimension-array 0) 1) (-> obj dimension-array 1)) (-> obj dimension-array 2)) + ) + (+! (-> obj dimension-array 0) 1) + ) + ) + (else + (if (>= (-> obj bucket-count) + (* (* (-> obj dimension-array 0) (-> obj dimension-array 1)) (+ (-> obj dimension-array 2) 1)) + ) + (+! (-> obj dimension-array 2) 1) + ) + ) + ) + ) + ) + (dotimes (a1-40 2) + (let* ((a2-26 (* a1-40 2)) + (a3-12 (max 1 (the int (/ (-> v1-0 data a2-26) (-> obj min-cell-size))))) + ) + (set! (-> (the-as (pointer uint8) (+ a2-26 (the-as int obj))) 24) + (the-as uint (min (-> (the-as (pointer int8) (+ a2-26 (the-as int obj))) 24) a3-12)) + ) + ) + ) + (dotimes (a1-43 3) + (set! (-> obj axis-scale a1-43) (/ (the float (-> obj dimension-array a1-43)) (-> v1-0 data a1-43))) + ) + ) + (let ((a2-34 (* (* (-> obj dimension-array 0) (-> obj dimension-array 1)) (-> obj dimension-array 2)))) + (b! (< (-> obj bucket-count) a2-34) cfg-40) + (let* ((v1-16 obj) + (a0-12 + (/ (+ (* (* (* (-> v1-16 dimension-array 0) (-> v1-16 dimension-array 1)) (-> v1-16 dimension-array 2)) + (-> v1-16 bucket-size) + ) + 15 + ) + 16 + ) + ) + (v1-17 (the-as (pointer uinteger) (-> v1-16 bucket-array))) + ) + (while (nonzero? a0-12) + (+! a0-12 -1) + (set! (-> (the-as (pointer uint128) v1-17) 0) (the-as uint128 0)) + (set! v1-17 (&-> (the-as (pointer grid-hash-word) v1-17) 16)) + ) + ) + 0 + (b! #t cfg-41 :delay (nop!)) + (label cfg-40) + (format + *stdcon* + "grid-hash::update-grid: bucket overflow! ~d dim ~d ~d ~d~%" + a2-34 + (-> obj dimension-array 0) + (-> obj dimension-array 1) + (-> obj dimension-array 2) + ) + ) + (label cfg-41) + 0 + (none) + ) + +(defmethod update-grid-for-objects-in-box grid-hash ((obj grid-hash) (arg0 int) (arg1 vector) (arg2 vector)) + (set! (-> obj object-count) arg0) + (dotimes (v1-0 3) + (set! (-> obj box-min v1-0) (-> arg1 data v1-0)) + (set! (-> obj box-max v1-0) (-> arg2 data v1-0)) + ) + (update-grid obj) + 0 + (none) + ) + + +(defmethod setup-search-box grid-hash ((obj grid-hash) (arg0 int) (arg1 vector) (arg2 vector) (arg3 vector)) + (let ((v1-0 (new 'stack-no-clear 'vector)) + (t1-0 (new 'stack-no-clear 'vector)) + ) + (dotimes (t2-0 3) + (set! (-> v1-0 data t2-0) (fmin (fmin (-> arg1 data t2-0) (-> arg2 data t2-0)) (-> arg3 data t2-0))) + (set! (-> t1-0 data t2-0) (fmax (fmax (-> arg1 data t2-0) (-> arg2 data t2-0)) (-> arg3 data t2-0))) + ) + (let ((a2-3 obj) + (a3-1 (-> obj search-box)) + ) + (dotimes (t0-1 3) + (set! (-> a3-1 min t0-1) + (the int + (fmax + 0.0 + (fmin + (* (- (-> v1-0 data t0-1) (-> a2-3 box-min t0-1)) (-> a2-3 axis-scale t0-1)) + (the float (+ (-> a2-3 dimension-array t0-1) -1)) + ) + ) + ) + ) + (set! (-> a3-1 max t0-1) + (the int (fmax 0.0 (fmin + (* (- (-> t1-0 data t0-1) (-> a2-3 box-min t0-1)) (-> a2-3 axis-scale t0-1)) + (the float (+ (-> a2-3 dimension-array t0-1) -1)) + ) + ) + ) + ) + ) + ) + ) + 0 + (set! (-> obj work object-id) arg0) + (let* ((t1-1 obj) + (t2-21 (-> obj search-box)) + (a3-2 arg0) + (v1-5 (-> t1-1 bucket-size)) + (a0-2 (* (-> t1-1 dimension-array 0) v1-5)) + (a1-2 (* (-> t1-1 dimension-array 2) a0-2)) + (a2-6 (+ (- 1 (-> t2-21 min 0)) (-> t2-21 max 0))) + (t0-6 (+ (- 1 (-> t2-21 min 2)) (-> t2-21 max 2))) + (t3-22 (+ (- 1 (-> t2-21 min 1)) (-> t2-21 max 1))) + (t1-3 (the-as + object + (+ (+ (* (-> t2-21 min 0) v1-5) (* (-> t2-21 min 1) a1-2) (* (-> t2-21 min 2) a0-2) (/ a3-2 8) 0) + (the-as int (the-as pointer (-> t1-1 bucket-array))) + ) + ) + ) + (a3-4 (ash 1 (logand a3-2 7))) + (t2-28 t3-22) + ) + (label cfg-10) + (let ((t3-23 t0-6) + (t4-6 t1-3) + ) + (label cfg-11) + (let ((t5-2 a2-6) + (t6-0 t4-6) + ) + (label cfg-12) + (nop!) + (let ((t7-0 (-> (the-as (pointer uint8) t6-0)))) + (nop!) + (let ((t7-1 (logior t7-0 a3-4))) + (+! t5-2 -1) + (set! (-> (the-as (pointer uint8) t6-0)) t7-1) + ) + ) + (b! (nonzero? t5-2) cfg-12 :delay (set! t6-0 (&+ (the-as pointer t6-0) v1-5))) + ) + (+! t3-23 -1) + (nop!) + (b! (nonzero? t3-23) cfg-11 :delay (set! t4-6 (&+ (the-as pointer t4-6) a0-2))) + ) + (+! t2-28 -1) + (nop!) + (b! (nonzero? t2-28) cfg-10 :delay (set! t1-3 (&+ (the-as pointer t1-3) a1-2))) + ) + 0 + 0 + (none) + ) + +(defmethod search-for-point grid-hash ((obj grid-hash) (arg0 vector)) + (let ((v1-0 obj) + (a0-1 (-> obj search-box)) + (a2-0 arg0) + ) + (dotimes (a3-0 3) + (set! (-> a0-1 min a3-0) + (the int + (fmax + 0.0 + (fmin + (* (- (-> a2-0 data a3-0) (-> v1-0 box-min a3-0)) (-> v1-0 axis-scale a3-0)) + (the float (+ (-> v1-0 dimension-array a3-0) -1)) + ) + ) + ) + ) + (set! (-> a0-1 max a3-0) + (the int (fmax 0.0 (fmin + (* (- (-> arg0 data a3-0) (-> v1-0 box-min a3-0)) (-> v1-0 axis-scale a3-0)) + (the float (+ (-> v1-0 dimension-array a3-0) -1)) + ) + ) + ) + ) + ) + ) + 0 + (do-search! obj (-> obj search-box) (-> obj work result-words)) + (-> obj work result-words) + ) + +(defmethod search-for-sphere grid-hash ((obj grid-hash) (arg0 vector) (arg1 float)) + (let ((v1-0 (new 'stack-no-clear 'sphere))) + (set! (-> v1-0 quad) (-> arg0 quad)) + (set! (-> v1-0 r) arg1) + (sphere-to-grid-box obj (-> obj search-box) v1-0) + ) + (let ((s5-0 (-> obj work result-words)) + (s4-0 0) + ) + (label cfg-1) + (do-search! obj (-> obj search-box) s5-0) + (dotimes (v1-5 (-> obj bucket-size)) + (set! s4-0 (logior s4-0 (-> s5-0 v1-5))) + ) + (when (zero? s4-0) + (when (or (> (-> obj search-box min 0) 0) + (> (-> obj search-box min 2) 0) + (< (-> obj search-box max 0) (+ (-> obj dimension-array 0) -1)) + (< (-> obj search-box max 2) (+ (-> obj dimension-array 2) -1)) + ) + (set! (-> obj search-box min 0) (max 0 (+ (-> obj search-box min 0) -1))) + (set! (-> obj search-box min 2) (max 0 (+ (-> obj search-box min 2) -1))) + (set! (-> obj search-box max 0) (min (+ (-> obj dimension-array 0) -1) (+ (-> obj search-box max 0) 1))) + (set! (-> obj search-box max 2) (min (+ (-> obj dimension-array 2) -1) (+ (-> obj search-box max 2) 1))) + (goto cfg-1) + ) + ) + ) + (-> obj work result-words) + ) + +(defun-debug draw-grid ((arg0 vector) (arg1 vector) (arg2 (pointer int8)) (arg3 rgba)) + (local-vars (sv-64 vector) (sv-68 vector) (sv-72 vector)) + (set! sv-64 (new 'stack-no-clear 'vector)) + (set! sv-68 (new 'stack-no-clear 'vector)) + (set! sv-72 (new 'stack-no-clear 'vector)) + (dotimes (v1-3 3) + (set! (-> sv-64 data v1-3) (/ (- (-> arg1 data v1-3) (-> arg0 data v1-3)) (the float (-> arg2 v1-3)))) + ) + (set! (-> sv-68 x) (-> arg0 x)) + (set! (-> sv-72 x) (-> arg1 x)) + (dotimes (s2-0 (+ (-> arg2 1) 1)) + (set! (-> sv-68 y) (+ (-> arg0 y) (* (the float s2-0) (-> sv-64 y)))) + (set! (-> sv-72 y) (-> sv-68 y)) + (dotimes (s1-0 (+ (-> arg2 2) 1)) + (set! (-> sv-68 z) (+ (-> arg0 z) (* (the float s1-0) (-> sv-64 z)))) + (set! (-> sv-72 z) (-> sv-68 z)) + (add-debug-line #t (bucket-id debug2) sv-68 sv-72 arg3 #f (the-as rgba -1)) + ) + ) + (set! (-> sv-68 z) (-> arg0 z)) + (set! (-> sv-72 z) (-> arg1 z)) + (dotimes (s2-1 (+ (-> arg2 1) 1)) + (set! (-> sv-68 y) (+ (-> arg0 y) (* (the float s2-1) (-> sv-64 y)))) + (set! (-> sv-72 y) (-> sv-68 y)) + (dotimes (s1-1 (+ (-> arg2 0) 1)) + (set! (-> sv-68 x) (+ (-> arg0 x) (* (the float s1-1) (-> sv-64 x)))) + (set! (-> sv-72 x) (-> sv-68 x)) + (add-debug-line #t (bucket-id debug2) sv-68 sv-72 arg3 #f (the-as rgba -1)) + ) + ) + (set! (-> sv-68 y) (-> arg0 y)) + (set! (-> sv-72 y) (-> arg1 y)) + (dotimes (s3-1 (+ (-> arg2 0) 1)) + (set! (-> sv-68 x) (+ (-> arg0 x) (* (the float s3-1) (-> sv-64 x)))) + (set! (-> sv-72 x) (-> sv-68 x)) + (dotimes (s2-2 (+ (-> arg2 2) 1)) + (set! (-> sv-68 z) (+ (-> arg0 z) (* (the float s2-2) (-> sv-64 z)))) + (set! (-> sv-72 z) (-> sv-68 z)) + (add-debug-line #t (bucket-id debug2) sv-68 sv-72 arg3 #f (the-as rgba -1)) + ) + ) + 0 + (none) + ) + +(defmethod draw grid-hash ((obj grid-hash) (arg0 rgba)) + "Draws the grid-hash" + (let ((v1-0 (new 'stack-no-clear 'vector)) + (t0-0 (new 'stack-no-clear 'vector)) + ) + (dotimes (a2-0 3) + (set! (-> v1-0 data a2-0) (-> obj box-min a2-0)) + (set! (-> t0-0 data a2-0) (-> obj box-max a2-0)) + ) + (draw-grid v1-0 t0-0 (-> obj dimension-array) arg0) + ) + 0 + (none) + ) + +(defmethod dump-grid-info grid-hash ((obj grid-hash)) + "Prints out info about the grid-hash, also draws via [[grid-hash::draw-grid]] if `debug-draw` is `#t`" + (if (-> obj debug-draw) + (draw obj *color-light-blue*) + ) + (format + *stdcon* + "bucket memory ~d, bucket-size ~d, word-size ~d bits~%" + (-> obj bucket-memory-size) + (-> obj bucket-size) + 8 + ) + (format + *stdcon* + "bucket dimensions ~d ~d ~d~%" + (-> obj dimension-array 0) + (-> obj dimension-array 1) + (-> obj dimension-array 2) + ) + (format *stdcon* "object-count ~d, bucket-count ~d~%" (-> obj object-count) (-> obj bucket-count)) + 0 + (none) + ) + +(defun-debug draw-sphere-box ((arg0 sphere) (arg1 rgba)) + (local-vars (a1-0 none)) + (let ((a2-0 (new 'stack-no-clear 'vector)) + (a3-0 (new 'stack-no-clear 'vector)) + ) + (dotimes (v1-0 3) + (set! (-> a2-0 data v1-0) (- (-> arg0 data v1-0) (-> arg0 r))) + (set! (-> a3-0 data v1-0) (+ (-> arg0 data v1-0) (-> arg0 r))) + ) + (add-debug-box #t (bucket-id debug-no-zbuf1) a2-0 a3-0 arg1) + ) + 0 + (none) + ) + +(defun-debug draw-line-sphere ((arg0 vector) (arg1 vector) (arg2 float) (arg3 rgba)) + (let ((gp-0 (new 'stack-no-clear 'vector))) + (vector+! gp-0 arg0 arg1) + (add-debug-sphere #t (bucket-id debug-no-zbuf1) arg0 arg2 arg3) + (add-debug-sphere #t (bucket-id debug-no-zbuf1) gp-0 arg2 arg3) + ) + 0 + (none) + ) + + +(defmethod new sphere-hash ((allocation symbol) (type-to-make type) (arg0 int) (arg1 int)) + (let ((s5-0 (the-as object (object-new allocation type-to-make (the-as int (-> type-to-make size)))))) + (when (zero? (the-as sphere-hash s5-0)) + (set! s5-0 0) + (goto cfg-4) + ) + (set! (-> (the-as sphere-hash s5-0) work) *grid-hash-work*) + (set! (-> (the-as sphere-hash s5-0) object-count) 0) + (set! (-> (the-as sphere-hash s5-0) bucket-memory-size) arg0) + (set! (-> (the-as sphere-hash s5-0) vertical-cell-count) 1) + (set! (-> (the-as sphere-hash s5-0) min-cell-size) 16384.0) + (set! (-> (the-as sphere-hash s5-0) mem-bucket-array) + (the-as (pointer grid-hash-word) (malloc allocation arg0)) + ) + (set! (-> (the-as sphere-hash s5-0) spr-bucket-array) (the-as (pointer grid-hash-word) #x70000000)) + (set! (-> (the-as sphere-hash s5-0) bucket-array) (-> (the-as sphere-hash s5-0) mem-bucket-array)) + (set! (-> (the-as sphere-hash s5-0) debug-draw) #f) + (set! (-> (the-as sphere-hash s5-0) use-scratch-ram) #f) + (set! (-> (the-as sphere-hash s5-0) max-object-count) arg1) + (set! (-> (the-as sphere-hash s5-0) mem-sphere-array) (the-as uint (malloc allocation (* arg1 16)))) + (set! (-> (the-as sphere-hash s5-0) spr-sphere-array) (the-as uint (+ #x70000000 arg0))) + (set! (-> (the-as sphere-hash s5-0) sphere-array) + (the-as (inline-array sphere) (-> (the-as sphere-hash s5-0) mem-sphere-array)) + ) + (label cfg-4) + (the-as sphere-hash s5-0) + ) + ) + +(defmethod clear-objects! sphere-hash ((obj sphere-hash)) + (set! (-> obj object-count) 0) + (dotimes (v1-0 3) + (set! (-> obj box-min v1-0) 10000000000000000000000000000000000000.0) + (set! (-> obj box-max v1-0) -10000000000000000000000000000000000000.0) + ) + (cond + ((-> obj use-scratch-ram) + (set! (-> obj sphere-array) (the-as (inline-array sphere) (-> obj spr-sphere-array))) + (set! (-> obj bucket-array) (-> obj spr-bucket-array)) + ) + (else + (set! (-> obj sphere-array) (the-as (inline-array sphere) (-> obj mem-sphere-array))) + (set! (-> obj bucket-array) (-> obj mem-bucket-array)) + ) + ) + 0 + (none) + ) + +;; definition for method 28 of type sphere-hash +;; ERROR: function was not converted to expressions. Cannot decompile. +(defmethod-mips2c "(method 28 sphere-hash)" 28 sphere-hash) + + +;; definition for method 26 of type sphere-hash +(defmethod add-a-sphere sphere-hash ((obj sphere-hash) (arg0 vector)) + (let ((gp-0 (-> obj object-count))) + (cond + ((< gp-0 (-> obj max-object-count)) + (let ((a0-2 (-> obj sphere-array gp-0))) + (mem-copy! (the-as pointer a0-2) (the-as pointer arg0) 16) + ) + (dotimes (v1-2 3) + (set! (-> obj box-min v1-2) (fmin (-> obj box-min v1-2) (- (-> arg0 data v1-2) (-> arg0 w)))) + (set! (-> obj box-max v1-2) (fmax (-> obj box-max v1-2) (+ (-> arg0 data v1-2) (-> arg0 w)))) + ) + (+! (-> obj object-count) 1) + gp-0 + ) + (else + -1 + ) + ) + ) + ) + +;; definition for method 27 of type sphere-hash +(defmethod add-a-sphere-with-flag sphere-hash ((obj sphere-hash) (arg0 vector) (arg1 int)) + (let ((gp-0 (-> obj object-count))) + (cond + ((< gp-0 (-> obj max-object-count)) + (let ((s2-0 (the-as object (-> obj sphere-array gp-0)))) + (mem-copy! (the-as pointer s2-0) (the-as pointer arg0) 16) + (dotimes (v1-2 3) + (set! (-> obj box-min v1-2) (fmin (-> obj box-min v1-2) (- (-> arg0 data v1-2) (-> arg0 w)))) + (set! (-> obj box-max v1-2) (fmax (-> obj box-max v1-2) (+ (-> arg0 data v1-2) (-> arg0 w)))) + ) + (set! (-> (the-as (pointer int8) s2-0) 12) arg1) + ) + (+! (-> obj object-count) 1) + gp-0 + ) + (else + -1 + ) + ) + ) + ) + +;; definition for method 33 of type sphere-hash +;; ERROR: function was not converted to expressions. Cannot decompile. +(defmethod-mips2c "(method 33 sphere-hash)" 33 sphere-hash) + +;; definition for method 29 of type sphere-hash +;; ERROR: function was not converted to expressions. Cannot decompile. +(defmethod-mips2c "(method 29 sphere-hash)" 29 sphere-hash) + +;; definition for method 30 of type sphere-hash +;; ERROR: function was not converted to expressions. Cannot decompile. +(defmethod-mips2c "(method 30 sphere-hash)" 30 sphere-hash) + +;; definition for method 31 of type sphere-hash +;; ERROR: function was not converted to expressions. Cannot decompile. +(defmethod-mips2c "(method 31 sphere-hash)" 31 sphere-hash) + +;; definition for method 32 of type sphere-hash +;; ERROR: function was not converted to expressions. Cannot decompile. +(defmethod-mips2c "(method 32 sphere-hash)" 32 sphere-hash) + +(defmethod dump-grid-info sphere-hash ((obj sphere-hash)) + "Prints out info about the grid-hash, also draws via [[grid-hash::draw-grid]] if `debug-draw` is `#t`" + ((the (function sphere-hash none) (find-parent-method sphere-hash 15)) obj) + (new 'stack-no-clear 'vector) + (let ((f30-0 6144.0)) + (set! (-> obj work temp-box-min quad) (-> (target-pos 0) quad)) + (+! (-> obj work temp-box-min y) f30-0) + ) + (set! (-> obj work temp-box-max quad) (-> obj work temp-box-min quad)) + (set! (-> obj work visit-count) 0) + (set! (-> obj debug-draw) #t) + (set! (-> obj work add-object-time) (the-as uint 0)) + 0 + (none) + ) + +(defmethod new spatial-hash ((allocation symbol) (type-to-make type) (arg0 int) (arg1 int)) + (let ((gp-0 (the-as object (object-new allocation type-to-make (the-as int (-> type-to-make size)))))) + (when (zero? (the-as spatial-hash gp-0)) + (set! gp-0 0) + (goto cfg-4) + ) + (set! (-> (the-as spatial-hash gp-0) work) *grid-hash-work*) + (set! (-> (the-as spatial-hash gp-0) object-count) 0) + (set! (-> (the-as spatial-hash gp-0) bucket-memory-size) arg0) + (set! (-> (the-as spatial-hash gp-0) vertical-cell-count) 1) + (set! (-> (the-as spatial-hash gp-0) min-cell-size) 16384.0) + (set! (-> (the-as spatial-hash gp-0) mem-bucket-array) + (the-as (pointer grid-hash-word) (malloc allocation arg0)) + ) + (set! (-> (the-as spatial-hash gp-0) spr-bucket-array) (the-as (pointer grid-hash-word) #x70000000)) + (set! (-> (the-as spatial-hash gp-0) bucket-array) (-> (the-as spatial-hash gp-0) mem-bucket-array)) + (set! (-> (the-as spatial-hash gp-0) debug-draw) #f) + (set! (-> (the-as spatial-hash gp-0) use-scratch-ram) #f) + (set! (-> (the-as spatial-hash gp-0) max-object-count) arg1) + (set! (-> (the-as spatial-hash gp-0) mem-sphere-array) (the-as uint (malloc allocation (* arg1 16)))) + (set! (-> (the-as spatial-hash gp-0) mem-object-array) + (the-as (inline-array hash-object-info) (malloc allocation (* arg1 16))) + ) + (set! (-> (the-as spatial-hash gp-0) spr-sphere-array) (the-as uint (+ #x70000000 arg0))) + (set! (-> (the-as spatial-hash gp-0) spr-object-array) + (the-as (inline-array hash-object-info) (+ #x70000000 (* arg1 16) arg0)) + ) + (set! (-> (the-as spatial-hash gp-0) sphere-array) + (the-as (inline-array sphere) (-> (the-as spatial-hash gp-0) mem-sphere-array)) + ) + (set! (-> (the-as spatial-hash gp-0) object-array) (-> (the-as spatial-hash gp-0) mem-object-array)) + (label cfg-4) + (the-as spatial-hash gp-0) + ) + ) + +(defmethod clear-objects! spatial-hash ((obj spatial-hash)) + (set! (-> obj object-count) 0) + (dotimes (v1-0 3) + (set! (-> obj box-min v1-0) 10000000000000000000000000000000000000.0) + (set! (-> obj box-max v1-0) -10000000000000000000000000000000000000.0) + ) + (cond + ((-> obj use-scratch-ram) + (set! (-> obj sphere-array) (the-as (inline-array sphere) (-> obj spr-sphere-array))) + (set! (-> obj object-array) (-> obj spr-object-array)) + (set! (-> obj bucket-array) (-> obj spr-bucket-array)) + ) + (else + (set! (-> obj sphere-array) (the-as (inline-array sphere) (-> obj mem-sphere-array))) + (set! (-> obj object-array) (-> obj mem-object-array)) + (set! (-> obj bucket-array) (-> obj mem-bucket-array)) + ) + ) + 0 + (none) + ) + +;; definition for method 33 of type spatial-hash +;; ERROR: function was not converted to expressions. Cannot decompile. +(defmethod-mips2c "(method 33 spatial-hash)" 33 spatial-hash) + + +;; definition for method 34 of type spatial-hash +(defmethod add-an-object spatial-hash ((obj spatial-hash) (arg0 vector) (arg1 hash-object-info)) + (let ((gp-0 (-> obj object-count))) + (cond + ((< gp-0 (-> obj max-object-count)) + (let ((a0-2 (-> obj sphere-array gp-0)) + (s2-0 (-> obj object-array gp-0)) + ) + (mem-copy! (the-as pointer a0-2) (the-as pointer arg0) 16) + (set! (-> s2-0 object) (the-as basic arg1)) + ) + (dotimes (v1-3 3) + (set! (-> obj box-min v1-3) (fmin (-> obj box-min v1-3) (- (-> arg0 data v1-3) (-> arg0 w)))) + (set! (-> obj box-max v1-3) (fmax (-> obj box-max v1-3) (+ (-> arg0 data v1-3) (-> arg0 w)))) + ) + (+! (-> obj object-count) 1) + gp-0 + ) + (else + -1 + ) + ) + ) + ) + +;; definition for method 39 of type spatial-hash +;; ERROR: function was not converted to expressions. Cannot decompile. +(defmethod-mips2c "(method 39 spatial-hash)" 39 spatial-hash) + +;; definition for method 36 of type spatial-hash +;; ERROR: function was not converted to expressions. Cannot decompile. +(defmethod-mips2c "(method 36 spatial-hash)" 36 spatial-hash) + +;; definition for method 37 of type spatial-hash +;; ERROR: function was not converted to expressions. Cannot decompile. +(defmethod-mips2c "(method 37 spatial-hash)" 37 spatial-hash) + +;; definition for method 35 of type spatial-hash +;; ERROR: function was not converted to expressions. Cannot decompile. +(defmethod-mips2c "(method 35 spatial-hash)" 35 spatial-hash) + +;; definition for method 38 of type spatial-hash +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs none. +(defmethod fill-actor-list-for-vec+r spatial-hash ((obj spatial-hash) (arg0 vector) (arg1 (pointer collide-shape)) (arg2 int)) + (let ((v1-0 (new 'stack-no-clear 'sphere))) + (set! (-> v1-0 quad) (-> arg0 quad)) + (set! (-> v1-0 r) 0.0) + (fill-actor-list-for-sphere obj v1-0 arg1 arg2) + ) + (none) + ) + +;; definition for method 40 of type spatial-hash +;; WARN: Return type mismatch int vs none. +(defmethod validate-objects spatial-hash ((obj spatial-hash)) + (dotimes (s5-0 (-> obj object-count)) + (let ((a0-2 (-> obj object-array s5-0 object))) + (when (not (valid? a0-2 basic (the-as symbol "") #t 0)) + (break!) + 0 + ) + ) + ) + 0 + (none) + ) + + + + diff --git a/goal_src/jak2/engine/target/target-darkjak.gc b/goal_src/jak2/engine/target/target-darkjak.gc index 1a5a01ed5a..ba51cd27d0 100644 --- a/goal_src/jak2/engine/target/target-darkjak.gc +++ b/goal_src/jak2/engine/target/target-darkjak.gc @@ -1505,26 +1505,26 @@ :post target-no-stick-post ) -;; (set! (-> *lightning-spec-id-table* 10) (new 'static 'lightning-spec -;; :name "lightning-darkjak-bomb1" -;; :flags (lightning-spec-flags lsf0 size-from-adjust-dist) -;; :adjust-distance #xa -;; :start-color #x80ffffff -;; :end-color #x80ffffff -;; :fade-to-color #x58f00bf -;; :fade-start-factor 0.2 -;; :texture #xc08400 -;; :reduction 0.42 -;; :num-points 96 -;; :box-size 32768.0 -;; :merge-factor 0.2 -;; :merge-count 2 -;; :radius 2048.0 -;; :duration 300.0 -;; :duration-rand 90.0 -;; :sound (static-sound-spec "transform-zap") -;; ) -;; ) +(set! (-> *lightning-spec-id-table* 10) (new 'static 'lightning-spec + :name "lightning-darkjak-bomb1" + :flags (lightning-spec-flags lsf0 size-from-adjust-dist) + :adjust-distance #xa + :start-color #x80ffffff + :end-color #x80ffffff + :fade-to-color #x58f00bf + :fade-start-factor 0.2 + :texture #xc08400 + :reduction 0.42 + :num-points 96 + :box-size 32768.0 + :merge-factor 0.2 + :merge-count 2 + :radius 2048.0 + :duration 300.0 + :duration-rand 90.0 + :sound (static-sound-spec "transform-zap") + ) + ) ;; WARN: Return type mismatch object vs none. (defbehavior target-bomb1-fire-shot target ((arg0 (pointer handle)) (arg1 int) (arg2 int) (arg3 int)) diff --git a/test/decompiler/reference/jak2/engine/common_objs/water-anim_REF.gc b/test/decompiler/reference/jak2/engine/common_objs/water-anim_REF.gc index 9b4f215ea5..c46fc6cf24 100644 --- a/test/decompiler/reference/jak2/engine/common_objs/water-anim_REF.gc +++ b/test/decompiler/reference/jak2/engine/common_objs/water-anim_REF.gc @@ -399,60 +399,59 @@ v0-1 ) ((= v1-0 'water) - (let ((s5-0 (the-as object (-> arg3 param 0)))) - (let* ((s4-0 (the-as object (-> arg3 param 1))) - (gp-0 (if (type? (the-as process s4-0) process-focusable) - (the-as uint s4-0) - ) - ) + (let* ((s5-0 (the-as object (-> arg3 param 0))) + (s4-0 (the-as object (-> arg3 param 1))) + (gp-0 (if (type? (the-as process s4-0) process-focusable) + (the-as uint s4-0) + ) + ) + ) + (when (and (logtest? (-> self flags) (water-flags deadly)) + (logtest? (water-flags touch-water) (-> (the-as water-info s5-0) flags)) + (the-as uint gp-0) + ) + (let ((v1-15 (-> self attack-event))) + (case v1-15 + ((#f) ) - (when (and (logtest? (-> self flags) (water-flags deadly)) - (logtest? (water-flags touch-water) (-> (the-as water-info s5-0) flags)) - (the-as uint gp-0) - ) - (let ((v1-15 (-> self attack-event))) - (case v1-15 - ((#f) - ) - (('heat) - (send-event (the-as process-tree gp-0) 'heat (* 10.0 (-> self clock seconds-per-frame))) - ) - (('drown-death 'lava 'dark-eco-pool) - (if (and (not (logtest? (focus-status board) (-> (the-as process-focusable gp-0) focus-status))) - (let ((a1-10 (new 'stack-no-clear 'event-message-block))) - (set! (-> a1-10 from) (process->ppointer self)) - (set! (-> a1-10 num-params) 2) - (set! (-> a1-10 message) 'attack-invinc) - (set! (-> a1-10 param 0) (the-as uint #f)) - (let ((a2-4 (new 'static 'attack-info :mask (attack-info-mask mode id)))) - (set! (-> a2-4 id) (-> self attack-id)) - (set! (-> a2-4 mode) v1-15) - (set! (-> a1-10 param 1) (the-as uint a2-4)) - ) - (send-event-function (the-as process-focusable gp-0) a1-10) + (('heat) + (send-event (the-as process-tree gp-0) 'heat (* 10.0 (-> self clock seconds-per-frame))) + ) + (('drown-death 'lava 'dark-eco-pool) + (if (and (not (logtest? (focus-status board) (-> (the-as process-focusable gp-0) focus-status))) + (let ((a1-10 (new 'stack-no-clear 'event-message-block))) + (set! (-> a1-10 from) (process->ppointer self)) + (set! (-> a1-10 num-params) 2) + (set! (-> a1-10 message) 'attack-invinc) + (set! (-> a1-10 param 0) (the-as uint #f)) + (let ((a2-4 (new 'static 'attack-info :mask (attack-info-mask mode id)))) + (set! (-> a2-4 id) (-> self attack-id)) + (set! (-> a2-4 mode) v1-15) + (set! (-> a1-10 param 1) (the-as uint a2-4)) ) + (send-event-function (the-as process-focusable gp-0) a1-10) ) - (send-event self 'notify 'attack) - ) - ) - (else - (if (and (not (logtest? (focus-status board) (-> (the-as process-focusable gp-0) focus-status))) - (let ((a1-13 (new 'stack-no-clear 'event-message-block))) - (set! (-> a1-13 from) (process->ppointer self)) - (set! (-> a1-13 num-params) 2) - (set! (-> a1-13 message) 'attack) - (set! (-> a1-13 param 0) (the-as uint #f)) - (let ((a2-6 (new 'static 'attack-info :mask (attack-info-mask mode id)))) - (set! (-> a2-6 id) (-> self attack-id)) - (set! (-> a2-6 mode) v1-15) - (set! (-> a1-13 param 1) (the-as uint a2-6)) - ) - (send-event-function (the-as process-tree gp-0) a1-13) + ) + (send-event self 'notify 'attack) + ) + ) + (else + (if (and (not (logtest? (focus-status board) (-> (the-as process-focusable gp-0) focus-status))) + (let ((a1-13 (new 'stack-no-clear 'event-message-block))) + (set! (-> a1-13 from) (process->ppointer self)) + (set! (-> a1-13 num-params) 2) + (set! (-> a1-13 message) 'attack) + (set! (-> a1-13 param 0) (the-as uint #f)) + (let ((a2-6 (new 'static 'attack-info :mask (attack-info-mask mode id)))) + (set! (-> a2-6 id) (-> self attack-id)) + (set! (-> a2-6 mode) v1-15) + (set! (-> a1-13 param 1) (the-as uint a2-6)) ) + (send-event-function (the-as process-tree gp-0) a1-13) ) - (send-event self 'notify 'attack) - ) - ) + ) + (send-event self 'notify 'attack) + ) ) ) ) @@ -462,7 +461,7 @@ ) (let ((a0-40 (-> self flow))) (if (nonzero? a0-40) - ((method-of-object a0-40 flow-control-method-11)) + (push-process a0-40 (the-as process-focusable gp-0)) ) ) ) diff --git a/test/decompiler/reference/jak2/engine/common_objs/water-flow_REF.gc b/test/decompiler/reference/jak2/engine/common_objs/water-flow_REF.gc new file mode 100644 index 0000000000..669f4ab320 --- /dev/null +++ b/test/decompiler/reference/jak2/engine/common_objs/water-flow_REF.gc @@ -0,0 +1,470 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition for function ray-plane-equation-intersect +(defun ray-plane-equation-intersect ((arg0 vector) (arg1 vector) (arg2 vector) (arg3 vector)) + (let* ((f0-1 (vector4-dot arg3 arg1)) + (f1-1 (vector-dot arg3 arg2)) + (f30-0 (/ (- f0-1) f1-1)) + ) + (vector-v*float+! arg0 arg1 arg2 f30-0) + f30-0 + ) + ) + +;; definition of type flow-section +(deftype flow-section (structure) + ((start vector :inline :offset-assert 0) + (trailing plane :inline :offset-assert 16) + (pull-dir vector :inline :offset-assert 32) + (radial-dir vector :inline :offset-assert 48) + ) + :method-count-assert 9 + :size-assert #x40 + :flag-assert #x900000040 + ) + +;; definition for method 3 of type flow-section +(defmethod inspect flow-section ((obj flow-section)) + (when (not obj) + (set! obj obj) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" obj 'flow-section) + (format #t "~1Tstart: #~%" (-> obj start)) + (format #t "~1Ttrailing: #~%" (-> obj trailing)) + (format #t "~1Tpull-dir: #~%" (-> obj pull-dir)) + (format #t "~1Tradial-dir: #~%" (-> obj radial-dir)) + (label cfg-4) + obj + ) + +;; definition of type flow-section-array +(deftype flow-section-array (inline-array-class) + ((data flow-section :inline :dynamic :offset-assert 16) + ) + :method-count-assert 9 + :size-assert #x10 + :flag-assert #x900000010 + ) + +;; definition for method 3 of type flow-section-array +(defmethod inspect flow-section-array ((obj flow-section-array)) + (when (not obj) + (set! obj obj) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" obj (-> obj type)) + (format #t "~1Tlength: ~D~%" (-> obj length)) + (format #t "~1Tallocated-length: ~D~%" (-> obj allocated-length)) + (format #t "~1Tdata[0] @ #x~X~%" (-> obj data)) + (label cfg-4) + obj + ) + +;; failed to figure out what this is: +(set! (-> flow-section-array heap-base) (the-as uint 64)) + +;; definition of type flow-control +(deftype flow-control (basic) + ((path path-control :offset-assert 4) + (speed float :offset-assert 8) + (belt-radius float :offset-assert 12) + (sections flow-section-array :offset-assert 16) + (leading plane :inline :offset-assert 32) + (collide-bounds sphere :inline :offset-assert 48) + ) + :method-count-assert 13 + :size-assert #x40 + :flag-assert #xd00000040 + (:methods + (new (symbol type process-drawable res-lump) _type_ 0) + (draw-path (_type_) none 9) + (setup (_type_) none 10) + (push-process (_type_ process-focusable) none 11) + (find-and-push-things (_type_) none 12) + ) + ) + +;; definition for method 3 of type flow-control +(defmethod inspect flow-control ((obj flow-control)) + (when (not obj) + (set! obj obj) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" obj (-> obj type)) + (format #t "~1Tpath: ~A~%" (-> obj path)) + (format #t "~1Tspeed: ~f~%" (-> obj speed)) + (format #t "~1Tbelt-radius: ~f~%" (-> obj belt-radius)) + (format #t "~1Tsections: ~A~%" (-> obj sections)) + (format #t "~1Tleading: #~%" (-> obj leading)) + (format #t "~1Tcollide-bounds: #~%" (-> obj collide-bounds)) + (label cfg-4) + obj + ) + +;; definition for method 7 of type flow-control +(defmethod relocate flow-control ((obj flow-control) (arg0 int)) + (if (nonzero? (-> obj sections)) + (&+! (-> obj sections) arg0) + ) + (if (nonzero? (-> obj path)) + (&+! (-> obj path) arg0) + ) + ((the-as (function flow-control int flow-control) (find-parent-method flow-control 7)) obj arg0) + ) + +;; definition for method 9 of type flow-control +;; WARN: Return type mismatch int vs none. +(defmethod draw-path flow-control ((obj flow-control)) + (let ((a0-1 (-> obj path))) + (if (nonzero? a0-1) + (debug-draw a0-1) + ) + ) + 0 + (none) + ) + +;; definition for method 11 of type flow-control +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs none. +;; WARN: Function (method 11 flow-control) has a return type of none, but the expression builder found a return statement. +(defmethod push-process flow-control ((obj flow-control) (arg0 process-focusable)) + (with-pp + (rlet ((acc :class vf) + (vf0 :class vf) + (vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + (vf7 :class vf) + ) + (init-vf0-vector) + (let ((s5-0 (new 'stack-no-clear 'vector))) + (set! (-> s5-0 quad) (-> (get-trans arg0 0) quad)) + (set! (-> s5-0 w) 1.0) + (when (>= (vector4-dot s5-0 (the-as vector (-> obj leading))) 0.0) + (let* ((v1-7 (-> obj sections)) + (a0-3 (-> v1-7 length)) + (a3-0 (the-as object (-> obj leading))) + ) + (dotimes (s3-1 a0-3) + (let ((s2-0 (-> v1-7 data s3-1))) + (when (< (vector4-dot s5-0 (the-as vector (-> s2-0 trailing))) 0.0) + (let ((v1-8 (new 'stack-no-clear 'vector))) + (vector-! v1-8 s5-0 (-> s2-0 start)) + (when (>= (-> obj belt-radius) (fabs (vector-dot v1-8 (-> s2-0 radial-dir)))) + (let* ((f0-7 (vector-dot v1-8 (-> s2-0 pull-dir))) + (f0-9 (- (-> v1-8 y) (* (-> s2-0 pull-dir y) f0-7))) + ) + (when (and (>= f0-9 -41984.0) (>= 41779.2 f0-9)) + (let* ((a0-11 (new 'stack-no-clear 'vector)) + (s1-0 (new 'stack-no-clear 'vector)) + (f30-0 (ray-plane-equation-intersect a0-11 s5-0 (-> s2-0 pull-dir) (the-as vector a3-0))) + (f0-10 (ray-plane-equation-intersect s1-0 s5-0 (-> s2-0 pull-dir) (-> s2-0 trailing))) + ) + (let ((a0-13 (new 'stack-no-clear 'vector))) + (let ((v1-13 (-> s2-0 start))) + (let ((a1-12 (-> s2-0 pull-dir))) + (let ((a2-6 12288.0)) + (.mov vf7 a2-6) + ) + (.lvf vf5 (&-> a1-12 quad)) + ) + (.lvf vf4 (&-> v1-13 quad)) + ) + (.add.x.vf vf6 vf0 vf0 :mask #b1000) + (.mul.x.vf acc vf5 vf7 :mask #b111) + (.add.mul.w.vf vf6 vf4 vf0 acc :mask #b111) + (.svf (&-> a0-13 quad) vf6) + ) + 0 + (let ((f0-12 (/ f30-0 (- f30-0 f0-10))) + (s2-1 (new 'stack-no-clear 'vector)) + ) + (displacement-between-two-points-normalized! (-> obj path) s2-1 (+ (the float s3-1) f0-12)) + (let ((v1-17 (new 'stack-no-clear 'vector))) + (vector-float*! v1-17 s2-1 (* (-> obj speed) (-> pp clock seconds-per-frame))) + (let ((a1-15 (new 'stack-no-clear 'vector))) + (let ((a0-17 v1-17)) + (let ((a2-9 2048.0)) + (.mov vf7 a2-9) + ) + (.lvf vf5 (&-> a0-17 quad)) + ) + (.lvf vf4 (&-> s5-0 quad)) + (.add.x.vf vf6 vf0 vf0 :mask #b1000) + (.mul.x.vf acc vf5 vf7 :mask #b111) + (.add.mul.w.vf vf6 vf4 vf0 acc :mask #b111) + (.svf (&-> a1-15 quad) vf6) + ) + 0 + (send-event arg0 'push-trans v1-17 3000) + ) + ) + ) + ) + ) + ) + ) + (return #f) + ) + ) + (set! a3-0 (+ (the-as uint (-> v1-7 data 0 trailing)) (* s3-1 64))) + ) + ) + ) + ) + 0 + (none) + ) + ) + ) + +;; definition for method 12 of type flow-control +;; WARN: Return type mismatch int vs none. +(defmethod find-and-push-things flow-control ((obj flow-control)) + (local-vars (a0-10 float) (a2-5 float) (a2-12 float)) + (rlet ((acc :class vf) + (vf0 :class vf) + (vf1 :class vf) + (vf2 :class vf) + (vf3 :class vf) + (vf4 :class vf) + ) + (init-vf0-vector) + (set! *actor-list-length* 0) + (if #t + (set! *actor-list-length* (fill-actor-list-for-sphere *actor-hash* (-> obj collide-bounds) *actor-list* 256)) + ) + (when #t + (let ((a0-2 (-> *collide-player-list* alive-list next0))) + *collide-player-list* + (let ((v1-11 (-> a0-2 next0))) + (while (!= a0-2 (-> *collide-player-list* alive-list-end)) + (let* ((a0-3 (-> (the-as connection a0-2) param1)) + (a1-1 (-> (the-as collide-shape a0-3) root-prim)) + ) + (when (logtest? (-> a1-1 prim-core collide-as) (collide-spec jak bot enemy hit-by-others-list player-list)) + (let ((a1-2 (-> a1-1 prim-core))) + (let ((a2-4 a1-2) + (a3-1 (-> obj collide-bounds)) + ) + (.lvf vf2 (&-> a2-4 world-sphere quad)) + (.lvf vf3 (&-> a3-1 quad)) + ) + (.sub.vf vf1 vf3 vf2) + (.mul.vf vf1 vf1 vf1) + (.add.y.vf vf1 vf1 vf1 :mask #b1) + (.add.z.vf vf1 vf1 vf1 :mask #b1) + (.mov a2-5 vf1) + (let ((f0-0 a2-5) + (f1-1 (+ (-> a1-2 world-sphere w) (-> obj collide-bounds r))) + ) + (when (< f0-0 (* f1-1 f1-1)) + (when (< *actor-list-length* 256) + (set! (-> *actor-list* *actor-list-length*) (the-as collide-shape a0-3)) + (set! *actor-list-length* (+ *actor-list-length* 1)) + ) + ) + ) + ) + ) + ) + (set! a0-2 v1-11) + *collide-player-list* + (set! v1-11 (-> v1-11 next0)) + ) + ) + ) + ) + (b! (not #f) cfg-20 :delay (empty-form)) + (let ((a0-5 (-> *collide-hit-by-player-list* alive-list next0))) + *collide-hit-by-player-list* + (let ((v1-18 (-> a0-5 next0))) + (b! #t cfg-18 :delay (nop!)) + (label cfg-13) + (let ((a0-6 (-> (the-as connection a0-5) param1))) + (let ((a1-13 (-> (the-as collide-shape a0-6) root-prim))) + (b! + (not (logtest? (-> a1-13 prim-core collide-as) (collide-spec jak bot enemy hit-by-others-list player-list))) + cfg-17 + :delay (empty-form) + ) + (let ((a1-14 (-> a1-13 prim-core))) + (let ((a2-11 a1-14) + (a3-2 (-> obj collide-bounds)) + ) + (.lvf vf2 (&-> a2-11 world-sphere quad)) + (.lvf vf3 (&-> a3-2 quad)) + ) + (.sub.vf vf1 vf3 vf2) + (.mul.vf vf1 vf1 vf1) + (.add.y.vf vf1 vf1 vf1 :mask #b1) + (.add.z.vf vf1 vf1 vf1 :mask #b1) + (.mov a2-12 vf1) + (let ((f0-1 a2-12) + (f1-5 (+ (-> a1-14 world-sphere w) (-> obj collide-bounds r))) + ) + (b! (>= f0-1 (* f1-5 f1-5)) cfg-17 :delay #f) + ) + ) + ) + (b! (>= *actor-list-length* 256) cfg-17 :delay #f) + (set! (-> *actor-list* *actor-list-length*) (the-as collide-shape a0-6)) + ) + (set! *actor-list-length* (+ *actor-list-length* 1)) + (label cfg-17) + (set! a0-5 v1-18) + *collide-hit-by-player-list* + (set! v1-18 (-> v1-18 next0)) + ) + (label cfg-18) + (b! (!= a0-5 (-> *collide-hit-by-player-list* alive-list-end)) cfg-13 :delay (nop!)) + ) + (label cfg-20) + (let ((s5-0 0)) + (b! #t cfg-29 :delay (nop!)) + (label cfg-21) + (let* ((v1-23 (-> *actor-list* s5-0)) + (a0-9 (-> v1-23 root-prim)) + ) + (when (logtest? (-> a0-9 prim-core collide-as) (collide-spec jak bot enemy hit-by-others-list player-list)) + (.lvf vf1 (&-> obj collide-bounds quad)) + (.lvf vf2 (&-> a0-9 prim-core world-sphere quad)) + (.sub.vf vf3 vf1 vf2) + (.add.w.vf vf4 vf1 vf2 :mask #b1000) + (.mul.vf vf3 vf3 vf3 :mask #b111) + (.mul.w.vf vf4 vf4 vf4 :mask #b1000) + (.mul.x.vf acc vf0 vf3 :mask #b1000) + (.add.mul.y.vf acc vf0 vf3 acc :mask #b1000) + (.add.mul.z.vf vf3 vf0 vf3 acc :mask #b1000) + (.sub.w.vf vf3 vf3 vf4 :mask #b1000) + (let ((f0-2 0.0)) + (.add.w.vf vf3 vf0 vf3 :mask #b1) + (.mov a0-10 vf3) + (let ((s4-0 (-> v1-23 process))) + (b! (< f0-2 a0-10) cfg-27) + (let ((a1-29 (if (type? s4-0 process-focusable) + s4-0 + ) + ) + ) + (if a1-29 + (push-process obj (the-as process-focusable a1-29)) + ) + ) + ) + ) + (label cfg-27) + 0 + ) + ) + (+! s5-0 1) + (label cfg-29) + (b! (< s5-0 *actor-list-length*) cfg-21) + ) + 0 + (none) + ) + ) + +;; definition for method 10 of type flow-control +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs none. +(defmethod setup flow-control ((obj flow-control)) + (local-vars (sv-32 flow-section) (sv-48 flow-section)) + (let* ((s5-0 (-> obj path)) + (s4-0 (-> s5-0 curve num-cverts)) + (s3-0 (new 'stack-no-clear 'vector)) + ) + (let ((s2-0 (new 'process 'flow-section-array (+ s4-0 -1)))) + (set! (-> obj sections) s2-0) + (set! (-> obj collide-bounds quad) (the-as uint128 0)) + (get-point-in-path! s5-0 s3-0 0.0 'interp) + (vector+! (the-as vector (-> obj collide-bounds)) (the-as vector (-> obj collide-bounds)) s3-0) + (let ((s1-0 (+ s4-0 -1))) + (set! sv-32 (the-as flow-section #f)) + (dotimes (s0-0 s1-0) + (set! sv-48 (-> s2-0 data s0-0)) + (set! (-> sv-48 start quad) (-> s3-0 quad)) + (get-point-in-path! s5-0 s3-0 (the float (+ s0-0 1)) 'interp) + (vector+! (the-as vector (-> obj collide-bounds)) (the-as vector (-> obj collide-bounds)) s3-0) + (vector-! (-> sv-48 pull-dir) s3-0 (-> sv-48 start)) + (vector-normalize! (-> sv-48 pull-dir) 1.0) + (set! (-> sv-48 trailing quad) (-> sv-48 pull-dir quad)) + (set! (-> sv-48 trailing y) 0.0) + (vector-normalize! (-> sv-48 trailing) 1.0) + (set-vector! (-> sv-48 radial-dir) (- (-> sv-48 trailing z)) 0.0 (-> sv-48 trailing x) 1.0) + (set! (-> sv-48 trailing w) (- (vector-dot s3-0 (the-as vector (-> sv-48 trailing))))) + (when sv-32 + (vector+! + (the-as vector (-> sv-32 trailing)) + (the-as vector (-> sv-32 trailing)) + (the-as vector (-> sv-48 trailing)) + ) + (vector-normalize! (-> sv-32 trailing) 1.0) + (set! (-> sv-32 trailing w) (- (vector-dot (-> sv-48 start) (the-as vector (-> sv-32 trailing))))) + ) + (set! sv-32 sv-48) + sv-32 + ) + ) + ) + (let ((s2-1 (-> obj sections data))) + (set! (-> obj leading quad) (-> s2-1 0 pull-dir quad)) + (set! (-> obj leading y) 0.0) + (vector-normalize! (-> obj leading) 1.0) + (set! (-> obj leading w) (- (vector-dot (the-as vector (-> s2-1 0)) (the-as vector (-> obj leading))))) + ) + (let ((f0-19 (/ 1.0 (the float s4-0))) + (f30-0 0.0) + ) + (vector-float*! (the-as vector (-> obj collide-bounds)) (the-as vector (-> obj collide-bounds)) f0-19) + (dotimes (s2-2 s4-0) + (get-point-in-path! s5-0 s3-0 (the float s2-2) 'interp) + (let ((f0-22 (vector-vector-distance-squared s3-0 (-> obj collide-bounds)))) + (if (< f30-0 f0-22) + (set! f30-0 f0-22) + ) + ) + ) + (set! (-> obj collide-bounds r) (+ (sqrtf f30-0) (-> obj belt-radius))) + ) + ) + 0 + (none) + ) + +;; definition for method 0 of type flow-control +(defmethod new flow-control ((allocation symbol) (type-to-make type) (arg0 process-drawable) (arg1 res-lump)) + (if (not arg1) + (set! arg1 (-> arg0 entity)) + ) + (let ((s5-0 (object-new allocation type-to-make (the-as int (-> type-to-make size))))) + (when (nonzero? s5-0) + (let ((v1-6 (new 'process 'curve-control arg0 'flow -1000000000.0))) + (cond + ((nonzero? v1-6) + (set! (-> s5-0 path) v1-6) + (logior! (-> v1-6 flags) (path-control-flag display draw-line draw-point draw-text)) + (if (< (-> v1-6 curve num-cverts) 2) + (go process-drawable-art-error "bad flow path") + ) + (set! (-> s5-0 speed) (res-lump-float arg1 'speed :default 12288.0)) + (set! (-> s5-0 belt-radius) (res-lump-float arg1 'extra-radius :default 16384.0)) + (setup s5-0) + ) + (else + (go process-drawable-art-error "no flow path") + ) + ) + ) + ) + s5-0 + ) + ) + + + + diff --git a/test/decompiler/reference/jak2/engine/gfx/merc/merc-death_REF.gc b/test/decompiler/reference/jak2/engine/gfx/merc/merc-death_REF.gc new file mode 100644 index 0000000000..e39b11d9ab --- /dev/null +++ b/test/decompiler/reference/jak2/engine/gfx/merc/merc-death_REF.gc @@ -0,0 +1,192 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition for symbol *merc-death-globals*, type vector +(define *merc-death-globals* (new 'global 'vector)) + +;; definition of type death-info +(deftype death-info (basic) + ((vertex-skip uint16 :offset-assert 4) + (timer uint8 :offset-assert 6) + (overlap uint8 :offset-assert 7) + (effect uint32 :offset-assert 8) + (sound symbol :offset-assert 12) + ) + :method-count-assert 9 + :size-assert #x10 + :flag-assert #x900000010 + ) + +;; definition for method 3 of type death-info +(defmethod inspect death-info ((obj death-info)) + (when (not obj) + (set! obj obj) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" obj (-> obj type)) + (format #t "~1Tvertex-skip: ~D~%" (-> obj vertex-skip)) + (format #t "~1Ttimer: ~D~%" (-> obj timer)) + (format #t "~1Toverlap: ~D~%" (-> obj overlap)) + (format #t "~1Teffect: ~D~%" (-> obj effect)) + (format #t "~1Tsound: ~A~%" (-> obj sound)) + (label cfg-4) + obj + ) + +;; definition for function birth-func-death-sparks +;; WARN: Return type mismatch int vs none. +(defun birth-func-death-sparks () + 0 + (none) + ) + +;; definition for symbol death-seed, type death-info +(define death-seed + (new 'static 'death-info :vertex-skip #x8 :timer #xe0 :overlap #xff :effect #x48 :sound 'temp-enemy-die) + ) + +;; definition for function start-seed-effect +;; WARN: Return type mismatch int vs none. +(defun start-seed-effect ((arg0 process-drawable) (arg1 vector) (arg2 cspace)) + (let ((v1-0 (-> arg0 draw)) + (a1-1 death-seed) + ) + (set! (-> v1-0 death-vertex-skip) (-> a1-1 vertex-skip)) + (set! (-> v1-0 death-effect) (-> a1-1 effect)) + (set! (-> v1-0 death-timer) (+ (-> a1-1 timer) 1)) + (set! (-> v1-0 death-timer-org) (-> v1-0 death-timer)) + (set! (-> v1-0 death-draw-overlap) (-> a1-1 overlap)) + ) + (send-event + arg0 + 'trans-hook + (lambda :behavior process-drawable () (set! (-> self draw death-timer) (the-as uint 200)) (none)) + ) + 0 + (none) + ) + +;; failed to figure out what this is: +(defpart 72 + :init-specs ((sp-flt spt-scale-x (meters 1)) + (sp-flt spt-rot-x 409.6) + (sp-copy-from-other spt-scale-y -4) + (sp-rnd-flt spt-r 64.0 196.0 1.0) + (sp-rnd-flt spt-g 196.0 64.0 1.0) + (sp-flt spt-b 0.0) + (sp-rnd-flt spt-a 4.0 2.0 1.0) + (sp-int spt-timer 5) + (sp-cpuinfo-flags sp-cpuinfo-flag-2 sp-cpuinfo-flag-3 glow) + (sp-func spt-func 'sparticle-texture-glow-soft) + ) + ) + +;; definition for symbol death-default, type death-info +(define death-default + (new 'static 'death-info :vertex-skip #xa :timer #x4b :overlap #x4 :effect #x49 :sound 'enemy-fizz) + ) + +;; definition for symbol death-warp-in, type death-info +(define death-warp-in + (new 'static 'death-info :vertex-skip #x96 :timer #x4b :effect #x4a :sound 'warpgate-tele) + ) + +;; definition for symbol death-warp-out, type death-info +(define death-warp-out + (new 'static 'death-info :vertex-skip #x96 :timer #x96 :effect #x4a :sound 'warpgate-tele) + ) + +;; definition for function sparticle-texture-glow-soft +;; WARN: Return type mismatch int vs none. +(defun sparticle-texture-glow-soft ((arg0 sparticle-system) (arg1 sparticle-cpuinfo) (arg2 vector)) + (particle-adgif-callback (-> arg1 adgif) (new 'static 'texture-id :index #xca :page #xc)) + (set! (-> arg1 sp-func) (the-as (function sparticle-system sparticle-cpuinfo sprite-vec-data-3d uint none) 0)) + 0 + (none) + ) + +;; failed to figure out what this is: +(defpart 74 + :init-specs ((sp-rnd-flt spt-scale-x (meters 0.5) (meters 0.5) 1.0) + (sp-copy-from-other spt-scale-y -4) + (sp-rnd-flt spt-r 32.0 32.0 1.0) + (sp-rnd-flt spt-g 32.0 64.0 1.0) + (sp-rnd-flt spt-b 128.0 128.0 1.0) + (sp-flt spt-a 128.0) + (sp-rnd-flt spt-scalevel-x (meters 0.02) (meters 0.02) 1.0) + (sp-copy-from-other spt-scalevel-y -4) + (sp-rnd-flt spt-fade-a 0.0 -1.28 1.0) + (sp-rnd-flt spt-friction 0.92 0.02 1.0) + (sp-int spt-timer 500) + (sp-cpuinfo-flags sp-cpuinfo-flag-0 sp-cpuinfo-flag-3 sp-cpuinfo-flag-12) + (sp-int-plain-rnd spt-next-time 30 19 1) + (sp-launcher-by-id spt-next-launcher 75) + ) + ) + +;; failed to figure out what this is: +(defpart 75 + :init-specs ((sp-rnd-flt spt-scale-x (meters 0.3) (meters 0.2) 1.0) + (sp-copy-from-other spt-scale-y -4) + (sp-rnd-flt spt-a 64.0 32.0 1.0) + (sp-rnd-flt spt-omega 8.192 6.144 1.0) + (sp-rnd-flt spt-vel-x (meters -0.053333335) (meters 0.10666667) 1.0) + (sp-rnd-flt spt-vel-y (meters -0.026666667) (meters 0.093333334) 1.0) + (sp-rnd-flt spt-vel-z (meters -0.053333335) (meters 0.10666667) 1.0) + (sp-rnd-flt spt-scalevel-x (meters -0.001) (meters -0.008) 1.0) + (sp-copy-from-other spt-scalevel-y -4) + (sp-flt spt-fade-a 0.0) + (sp-func spt-func 'sparticle-motion-blur) + ) + ) + +;; failed to figure out what this is: +(defpart 73 + :init-specs ((sp-rnd-flt spt-scale-x (meters 0.5) (meters 0.5) 1.0) + (sp-copy-from-other spt-scale-y -4) + (sp-rnd-flt spt-r 96.0 150.0 1.0) + (sp-rnd-flt spt-g 32.0 64.0 1.0) + (sp-rnd-flt spt-b 128.0 128.0 1.0) + (sp-flt spt-a 128.0) + (sp-rnd-flt spt-scalevel-x (meters 0.02) (meters 0.02) 1.0) + (sp-copy-from-other spt-scalevel-y -4) + (sp-rnd-flt spt-fade-a 0.0 -1.28 1.0) + (sp-rnd-flt spt-friction 0.92 0.02 1.0) + (sp-int spt-timer 500) + (sp-cpuinfo-flags sp-cpuinfo-flag-0 sp-cpuinfo-flag-3 sp-cpuinfo-flag-12) + (sp-int-plain-rnd spt-next-time 30 19 1) + (sp-launcher-by-id spt-next-launcher 76) + ) + ) + +;; failed to figure out what this is: +(defpart 76 + :init-specs ((sp-rnd-flt spt-scale-x (meters 0.3) (meters 0.2) 1.0) + (sp-copy-from-other spt-scale-y -4) + (sp-rnd-flt spt-a 64.0 32.0 1.0) + (sp-rnd-flt spt-omega 8.192 6.144 1.0) + (sp-rnd-flt spt-vel-x (meters -0.053333335) (meters 0.10666667) 1.0) + (sp-rnd-flt spt-vel-y (meters -0.026666667) (meters 0.093333334) 1.0) + (sp-rnd-flt spt-vel-z (meters -0.053333335) (meters 0.10666667) 1.0) + (sp-rnd-flt spt-scalevel-x (meters -0.001) (meters -0.008) 1.0) + (sp-copy-from-other spt-scalevel-y -4) + (sp-flt spt-fade-a 0.0) + (sp-func spt-func 'sparticle-motion-blur) + ) + ) + +;; definition for function merc-death-spawn +;; WARN: Return type mismatch int vs none. +(defun merc-death-spawn ((arg0 int) (arg1 vector) (arg2 vector)) + (let ((v1-2 (-> *part-id-table* arg0))) + (if (and (nonzero? v1-2) (= (-> v1-2 type) sparticle-launcher)) + (sp-launch-particles-death *sp-particle-system-2d* v1-2 arg1) + ) + ) + 0 + (none) + ) + + + + diff --git a/test/decompiler/reference/jak2/engine/spatial-hash/actor-hash_REF.gc b/test/decompiler/reference/jak2/engine/spatial-hash/actor-hash_REF.gc new file mode 100644 index 0000000000..d4f4397d2b --- /dev/null +++ b/test/decompiler/reference/jak2/engine/spatial-hash/actor-hash_REF.gc @@ -0,0 +1,1328 @@ +;;-*-Lisp-*- +(in-package goal) + +;; failed to figure out what this is: +(kmemopen global "actor-hash") + +;; definition for symbol *actor-hash*, type spatial-hash +(define *actor-hash* (new 'global 'spatial-hash 4096 256)) + +;; failed to figure out what this is: +(kmemclose) + +;; definition of type actor-cshape-ptr +(deftype actor-cshape-ptr (structure) + ((cshape collide-shape :offset-assert 0) + ) + :method-count-assert 9 + :size-assert #x4 + :flag-assert #x900000004 + ) + +;; definition for method 3 of type actor-cshape-ptr +(defmethod inspect actor-cshape-ptr ((obj actor-cshape-ptr)) + (when (not obj) + (set! obj obj) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" obj 'actor-cshape-ptr) + (format #t "~1Tcshape: ~A~%" (-> obj cshape)) + (label cfg-4) + obj + ) + +;; definition of type actor-hash-bucket +(deftype actor-hash-bucket (structure) + ((length int16 :offset-assert 0) + (max-length int16 :offset-assert 2) + (data (inline-array actor-cshape-ptr) :offset-assert 4) + ) + :allow-misaligned + :method-count-assert 10 + :size-assert #x8 + :flag-assert #xa00000008 + (:methods + (add-actor-cshape (_type_ collide-shape) none 9) + ) + ) + +;; definition for method 3 of type actor-hash-bucket +(defmethod inspect actor-hash-bucket ((obj actor-hash-bucket)) + (when (not obj) + (set! obj obj) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" obj 'actor-hash-bucket) + (format #t "~1Tlength: ~D~%" (-> obj length)) + (format #t "~1Tmax-length: ~D~%" (-> obj max-length)) + (format #t "~1Tdata: #x~X~%" (-> obj data)) + (label cfg-4) + obj + ) + +;; definition for method 9 of type actor-hash-bucket +;; WARN: Return type mismatch int vs none. +(defmethod add-actor-cshape actor-hash-bucket ((obj actor-hash-bucket) (arg0 collide-shape)) + (let ((v1-0 (-> obj length))) + (when (< v1-0 (-> obj max-length)) + (set! (-> obj data v1-0 cshape) arg0) + (set! (-> obj length) (+ v1-0 1)) + ) + ) + 0 + (none) + ) + +;; definition of type actor-hash-buckets +(deftype actor-hash-buckets (structure) + ((hash spatial-hash :offset-assert 0) + (list engine :offset-assert 4) + (data actor-hash-bucket 4 :inline :offset-assert 8) + (tpos vector :inline :offset-assert 80) + ) + :method-count-assert 10 + :size-assert #x60 + :flag-assert #xa00000060 + (:methods + (hash-actors (_type_) none 9) + ) + ) + +;; definition for method 3 of type actor-hash-buckets +(defmethod inspect actor-hash-buckets ((obj actor-hash-buckets)) + (when (not obj) + (set! obj obj) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" obj 'actor-hash-buckets) + (format #t "~1Thash: ~A~%" (-> obj hash)) + (format #t "~1Tlist: ~A~%" (-> obj list)) + (format #t "~1Tdata[4] @ #x~X~%" (-> obj data)) + (format #t "~1Ttpos: #~%" (-> obj tpos)) + (label cfg-4) + obj + ) + +;; definition for method 9 of type actor-hash-buckets +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs none. +(defmethod hash-actors actor-hash-buckets ((obj actor-hash-buckets)) + (local-vars (sv-16 hash-object-info) (sv-32 collide-prim-core) (sv-48 collide-shape) (sv-64 hash-object-info)) + (set! (-> obj hash) *actor-hash*) + (set! (-> obj list) *collide-hit-by-others-list*) + (clear-objects! (-> obj hash)) + (cond + ((>= 256 (-> obj list length)) + (let ((v1-5 (-> obj list alive-list next0))) + (-> obj list) + (let ((s5-0 (-> v1-5 next0))) + (while (!= v1-5 (-> obj list alive-list-end)) + (let* ((s4-0 (the-as collide-shape (-> (the-as connection v1-5) param1))) + (s3-0 (-> obj hash)) + (s1-0 (-> s4-0 root-prim prim-core)) + (s0-0 s4-0) + (s2-0 (-> s3-0 object-count)) + ) + (set! s2-0 + (cond + ((< s2-0 (-> s3-0 max-object-count)) + (let ((a0-7 (-> s3-0 sphere-array s2-0))) + (set! sv-16 (-> s3-0 object-array s2-0)) + (mem-copy! (the-as pointer a0-7) (the-as pointer s1-0) 16) + ) + (set! (-> sv-16 object) s0-0) + (dotimes (v1-12 3) + (set! (-> s3-0 box-min v1-12) + (fmin (-> s3-0 box-min v1-12) (- (-> s1-0 world-sphere data v1-12) (-> s1-0 world-sphere w))) + ) + (set! (-> s3-0 box-max v1-12) + (fmax (-> s3-0 box-max v1-12) (+ (-> s1-0 world-sphere data v1-12) (-> s1-0 world-sphere w))) + ) + ) + (+! (-> s3-0 object-count) 1) + s2-0 + ) + (else + -1 + ) + ) + ) + (set! (-> s4-0 actor-hash-index) s2-0) + ) + (set! v1-5 s5-0) + (-> obj list) + (set! s5-0 (-> s5-0 next0)) + ) + ) + ) + ) + (else + (set! (-> obj tpos quad) (-> (target-pos 0) quad)) + (dotimes (v1-21 4) + (set! (-> obj data v1-21 length) 0) + ) + (let ((v1-25 (-> obj list alive-list next0))) + (-> obj list) + (let ((s5-2 (-> v1-25 next0))) + (while (!= v1-25 (-> obj list alive-list-end)) + (let* ((s4-1 (the-as collide-shape (-> (the-as connection v1-25) param1))) + (f0-4 (vector-vector-distance-squared (-> obj tpos) (-> s4-1 trans))) + (f1-4 102400.0) + ) + (cond + ((< f0-4 (* f1-4 f1-4)) + ((method-of-type actor-hash-bucket add-actor-cshape) (the-as actor-hash-bucket (-> obj data)) s4-1) + ) + ((let ((f1-7 204800.0)) + (< f0-4 (* f1-7 f1-7)) + ) + (add-actor-cshape (-> obj data 1) s4-1) + ) + ((let ((f1-10 307200.0)) + (< f0-4 (* f1-10 f1-10)) + ) + (add-actor-cshape (-> obj data 2) s4-1) + ) + (else + (add-actor-cshape (-> obj data 3) s4-1) + ) + ) + ) + (set! v1-25 s5-2) + (-> obj list) + (set! s5-2 (-> s5-2 next0)) + ) + ) + ) + (dotimes (s5-3 4) + (let ((s4-2 (-> obj data s5-3))) + (countdown (s3-1 (-> s4-2 length)) + (let ((s2-1 (-> s4-2 data s3-1 cshape)) + (s1-1 (-> obj hash)) + ) + (set! sv-32 (-> s2-1 root-prim prim-core)) + (set! sv-48 s2-1) + (let ((s0-1 (-> s1-1 object-count))) + (set! s0-1 + (cond + ((< s0-1 (-> s1-1 max-object-count)) + (let ((a0-40 (-> s1-1 sphere-array s0-1))) + (set! sv-64 (-> s1-1 object-array s0-1)) + (mem-copy! (the-as pointer a0-40) (the-as pointer sv-32) 16) + ) + (set! (-> sv-64 object) sv-48) + (dotimes (v1-53 3) + (set! (-> s1-1 box-min v1-53) + (fmin (-> s1-1 box-min v1-53) (- (-> sv-32 world-sphere data v1-53) (-> sv-32 world-sphere w))) + ) + (set! (-> s1-1 box-max v1-53) + (fmax (-> s1-1 box-max v1-53) (+ (-> sv-32 world-sphere data v1-53) (-> sv-32 world-sphere w))) + ) + ) + (+! (-> s1-1 object-count) 1) + s0-1 + ) + (else + -1 + ) + ) + ) + (set! (-> s2-1 actor-hash-index) s0-1) + ) + ) + ) + ) + ) + ) + ) + (update-from-spheres (-> obj hash)) + 0 + (none) + ) + +;; definition for symbol *actor-hash-buckets*, type actor-hash-buckets +(define *actor-hash-buckets* + (new 'static 'actor-hash-buckets + :data (new 'static 'inline-array actor-hash-bucket 4 + (new 'static 'actor-hash-bucket :max-length #x100 :data (new 'static 'inline-array actor-cshape-ptr 256 + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + ) + ) + (new 'static 'actor-hash-bucket :max-length #x100 :data (new 'static 'inline-array actor-cshape-ptr 256 + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + ) + ) + (new 'static 'actor-hash-bucket :max-length #x100 :data (new 'static 'inline-array actor-cshape-ptr 256 + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + ) + ) + (new 'static 'actor-hash-bucket :max-length #x100 :data (new 'static 'inline-array actor-cshape-ptr 256 + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + (new 'static 'actor-cshape-ptr) + ) + ) + ) + ) + ) + +;; definition for function update-actor-hash +;; WARN: Return type mismatch int vs none. +(defun update-actor-hash () + (local-vars (a0-3 int) (a0-5 int)) + (let* ((v1-1 (-> *perf-stats* data 6)) + (a0-0 (-> v1-1 ctrl)) + ) + (+! (-> v1-1 count) 1) + (b! (zero? a0-0) cfg-2 :delay (nop!)) + (.mtc0 Perf 0) + (.sync.l) + (.sync.p) + (.mtpc pcr0 0) + (.mtpc pcr1 0) + (.sync.l) + (.sync.p) + (.mtc0 Perf a0-0) + ) + (.sync.l) + (.sync.p) + (label cfg-2) + 0 + (hash-actors *actor-hash-buckets*) + (let ((v1-6 (-> *perf-stats* data 6))) + (b! (zero? (-> v1-6 ctrl)) cfg-4 :delay (nop!)) + (.mtc0 Perf 0) + (.sync.l) + (.sync.p) + (.mfpc a0-3 pcr0) + (+! (-> v1-6 accum0) a0-3) + (.mfpc a0-5 pcr1) + (+! (-> v1-6 accum1) a0-5) + ) + (label cfg-4) + 0 + 0 + (none) + ) + + + + diff --git a/test/decompiler/reference/jak2/engine/spatial-hash/spatial-hash-h_REF.gc b/test/decompiler/reference/jak2/engine/spatial-hash/spatial-hash-h_REF.gc index c0a96ba1fa..73846894c1 100644 --- a/test/decompiler/reference/jak2/engine/spatial-hash/spatial-hash-h_REF.gc +++ b/test/decompiler/reference/jak2/engine/spatial-hash/spatial-hash-h_REF.gc @@ -38,7 +38,7 @@ ((work grid-hash-work :offset-assert 4) (search-box grid-hash-box :inline :offset-assert 8) (bucket-size int16 :offset-assert 14) - (axis-scale uint32 3 :offset-assert 16) + (axis-scale float 3 :offset-assert 16) (dimension-array int8 3 :offset-assert 28) (vertical-cell-count int8 :offset-assert 31) (bucket-array (pointer grid-hash-word) :offset-assert 32) @@ -57,22 +57,22 @@ :size-assert #x58 :flag-assert #x1900000058 (:methods - (new (symbol type process int) _type_ 0) - (grid-hash-method-9 (_type_ int (array float) int) none 9) - (grid-hash-method-10 (_type_) none 10) - (grid-hash-method-11 (_type_) none 11) - (grid-hash-method-12 (_type_ vector) grid-hash-box 12) - (grid-hash-method-13 (_type_ vector float) grid-hash-box 13) - (draw-grid (_type_ rgba) none 14) + (new (symbol type int int) _type_ 0) + (update-grid-for-objects-in-box (_type_ int vector vector) none 9) + (clear-bucket-array (_type_) none 10) + (setup-search-box (_type_ int vector vector vector) none 11) + (search-for-point (_type_ vector) (pointer uint8) 12) + (search-for-sphere (_type_ vector float) (pointer uint8) 13) + (draw (_type_ rgba) none 14) (dump-grid-info (_type_) none 15) - (grid-hash-method-16 (_type_ grid-hash-box grid-hash-box) none 16) - (grid-hash-method-17 (_type_) none 17) + (verify-bits-in-bucket (_type_ grid-hash-box grid-hash-box) none 16) + (box-of-everything (_type_ object grid-hash-box) none 17) (grid-hash-method-18 (_type_ grid-hash-box int) none 18) (grid-hash-method-19 (_type_ grid-hash-box int) none 19) - (grid-hash-method-20 (_type_ grid-hash-box (pointer uint8)) none 20) - (grid-hash-method-21 (_type_ float int int) none 21) - (grid-hash-method-22 (_type_ grid-hash-box sphere) none 22) - (grid-hash-method-23 (_type_ grid-hash-box vector vector float) none 23) + (do-search! (_type_ grid-hash-box (pointer uint8)) none 20) + (set-up-box (_type_ grid-hash-box vector vector) none 21) + (sphere-to-grid-box (_type_ grid-hash-box sphere) none 22) + (line-sphere-to-grid-box (_type_ grid-hash-box vector vector float) none 23) (update-grid (_type_) none 24) ) ) @@ -148,15 +148,16 @@ :size-assert #x68 :flag-assert #x2200000068 (:methods + (new (symbol type int int) _type_ 0) (clear-objects! (_type_) none 25) - (sphere-hash-method-26 (_type_ vector) none 26) - (sphere-hash-method-27 (_type_) none 27) - (sphere-hash-method-28 (_type_) none 28) + (add-a-sphere (_type_ vector) int 26) + (add-a-sphere-with-flag (_type_ vector int) int 27) + (update-from-spheres (_type_) none 28) (sphere-hash-method-29 (_type_ find-nav-sphere-ids-params int int int) none 29) (sphere-hash-method-30 (_type_ find-nav-sphere-ids-params) none 30) (sphere-hash-method-31 (_type_ vector int int) none 31) (sphere-hash-method-32 (_type_ vector vector float int) symbol 32) - (sphere-hash-method-33 (_type_ object int) none 33) + (sphere-hash-method-33 (_type_ sphere int) none 33) ) ) @@ -216,21 +217,22 @@ ;; definition of type spatial-hash (deftype spatial-hash (sphere-hash) - ((object-array (pointer hash-object-info) :offset-assert 104) - (mem-object-array (pointer hash-object-info) :offset-assert 108) - (spr-object-array (pointer hash-object-info) :offset-assert 112) + ((object-array (inline-array hash-object-info) :offset-assert 104) + (mem-object-array (inline-array hash-object-info) :offset-assert 108) + (spr-object-array (inline-array hash-object-info) :offset-assert 112) ) :method-count-assert 41 :size-assert #x74 :flag-assert #x2900000074 (:methods - (spatial-hash-method-34 (_type_ vector hash-object-info) int 34) + (new (symbol type int int) _type_ 0) + (add-an-object (_type_ vector hash-object-info) int 34) (spatial-hash-method-35 (_type_) none 35) (fill-actor-list-for-sphere (_type_ sphere (pointer collide-shape) int) int 36) (spatial-hash-method-37 (_type_) none 37) - (spatial-hash-method-38 (_type_) none 38) + (fill-actor-list-for-vec+r (_type_ vector (pointer collide-shape) int) none 38) (spatial-hash-method-39 (_type_ object hash-object-info) none 39) - (spatial-hash-method-40 (_type_) none 40) + (validate-objects (_type_) none 40) ) ) diff --git a/test/decompiler/reference/jak2/engine/spatial-hash/spatial-hash_REF.gc b/test/decompiler/reference/jak2/engine/spatial-hash/spatial-hash_REF.gc new file mode 100644 index 0000000000..99d3ddc69e --- /dev/null +++ b/test/decompiler/reference/jak2/engine/spatial-hash/spatial-hash_REF.gc @@ -0,0 +1,951 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition of type grid-hash-work +(deftype grid-hash-work (basic) + ((result-words uint8 32 :offset 16) + (result-bits uint8 32 :offset 16) + (object-id int32 :offset-assert 48) + (temp-box-min vector :inline :offset-assert 64) + (temp-box-max vector :inline :offset-assert 80) + (visit-count int32 :offset-assert 96) + (temp-time uint32 :offset-assert 100) + (queue-object-time uint32 :offset-assert 104) + (make-hash-time uint32 :offset-assert 108) + (search-time uint32 :offset-assert 112) + (add-object-time uint32 :offset-assert 116) + ) + :method-count-assert 9 + :size-assert #x78 + :flag-assert #x900000078 + ) + +;; definition for method 3 of type grid-hash-work +(defmethod inspect grid-hash-work ((obj grid-hash-work)) + (when (not obj) + (set! obj obj) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" obj (-> obj type)) + (format #t "~1Tresult-words[32] @ #x~X~%" (-> obj result-words)) + (format #t "~1Tresult-bits[32] @ #x~X~%" (-> obj result-words)) + (format #t "~1Tobject-id: ~D~%" (-> obj object-id)) + (format #t "~1Ttemp-box-min: #~%" (-> obj temp-box-min)) + (format #t "~1Ttemp-box-max: #~%" (-> obj temp-box-max)) + (format #t "~1Tvisit-count: ~D~%" (-> obj visit-count)) + (format #t "~1Ttemp-time: ~D~%" (-> obj temp-time)) + (format #t "~1Tqueue-object-time: ~D~%" (-> obj queue-object-time)) + (format #t "~1Tmake-hash-time: ~D~%" (-> obj make-hash-time)) + (format #t "~1Tsearch-time: ~D~%" (-> obj search-time)) + (format #t "~1Tadd-object-time: ~D~%" (-> obj add-object-time)) + (label cfg-4) + obj + ) + +;; definition for symbol *grid-hash-work*, type grid-hash-work +(define *grid-hash-work* (new 'static 'grid-hash-work)) + +;; definition for method 0 of type grid-hash +;; WARN: Return type mismatch object vs grid-hash. +(defmethod new grid-hash ((allocation symbol) (type-to-make type) (arg0 int) (arg1 int)) + (let ((gp-0 (the-as object (object-new allocation type-to-make (the-as int (-> type-to-make size)))))) + (when (zero? (the-as grid-hash gp-0)) + (set! gp-0 0) + (goto cfg-4) + ) + (set! (-> (the-as grid-hash gp-0) work) *grid-hash-work*) + (set! (-> (the-as grid-hash gp-0) object-count) 0) + (set! (-> (the-as grid-hash gp-0) bucket-memory-size) arg0) + (set! (-> (the-as grid-hash gp-0) vertical-cell-count) 1) + (set! (-> (the-as grid-hash gp-0) min-cell-size) 16384.0) + (set! (-> (the-as grid-hash gp-0) mem-bucket-array) + (the-as (pointer grid-hash-word) (malloc allocation arg0)) + ) + (set! (-> (the-as grid-hash gp-0) spr-bucket-array) (the-as (pointer grid-hash-word) #x70000000)) + (set! (-> (the-as grid-hash gp-0) bucket-array) (-> (the-as grid-hash gp-0) mem-bucket-array)) + (set! (-> (the-as grid-hash gp-0) debug-draw) #f) + (set! (-> (the-as grid-hash gp-0) use-scratch-ram) #f) + (label cfg-4) + (the-as grid-hash gp-0) + ) + ) + +;; definition for method 16 of type grid-hash +;; WARN: Return type mismatch int vs none. +(defmethod verify-bits-in-bucket grid-hash ((obj grid-hash) (arg0 grid-hash-box) (arg1 grid-hash-box)) + (let ((s5-0 0)) + 0 + (let ((v1-1 8) + (a0-1 (-> obj object-count)) + (a1-2 (* (-> obj bucket-size) 8)) + ) + (while (< a0-1 a1-2) + (let ((a3-0 (- a0-1 (* (/ a0-1 v1-1) v1-1)))) + (set! s5-0 (logior s5-0 (ash 1 a3-0))) + ) + (+! a0-1 1) + ) + ) + (dotimes (s4-0 (-> obj bucket-count)) + (let ((a3-2 (-> obj bucket-array (+ (-> obj bucket-size) -1 (* s4-0 (-> obj bucket-size)))))) + (when (logtest? a3-2 s5-0) + (format 0 "bad bits in bucket ~d bucket-word ~8x test-word ~8x~%" s4-0 a3-2 s5-0) + (break!) + 0 + ) + ) + ) + ) + 0 + (none) + ) + +;; definition for method 17 of type grid-hash +;; WARN: Return type mismatch int vs none. +(defmethod box-of-everything grid-hash ((obj grid-hash) (arg0 object) (arg1 grid-hash-box)) + (dotimes (v1-0 3) + (set! (-> arg1 min v1-0) (-> obj dimension-array v1-0)) + (set! (-> arg1 max v1-0) -1) + ) + (let* ((v1-3 (-> obj bucket-size)) + (a3-4 (* (-> obj dimension-array 0) v1-3)) + (t0-3 (* (-> obj dimension-array 2) a3-4)) + (t1-0 (-> obj dimension-array 0)) + (t2-0 (-> obj dimension-array 2)) + (t3-0 (-> obj dimension-array 1)) + (a0-2 (&-> (-> obj bucket-array) (/ (the-as int arg0) 8))) + (a1-2 (ash 1 (logand (the-as int arg0) 7))) + ) + (dotimes (t4-3 t3-0) + (let ((t5-0 a0-2)) + (dotimes (t6-0 t2-0) + (let ((t7-0 t5-0)) + (dotimes (t8-0 t1-0) + (when (logtest? (-> t7-0 0) a1-2) + (set! (-> arg1 min 0) (min (-> arg1 min 0) t8-0)) + (set! (-> arg1 min 1) (min (-> arg1 min 1) t4-3)) + (set! (-> arg1 min 2) (min (-> arg1 min 2) t6-0)) + (set! (-> arg1 max 0) (max (-> arg1 max 0) t8-0)) + (set! (-> arg1 max 1) (max (-> arg1 max 1) t4-3)) + (set! (-> arg1 max 2) (max (-> arg1 max 2) t6-0)) + ) + (&+! t7-0 v1-3) + ) + ) + (&+! t5-0 a3-4) + ) + ) + (&+! a0-2 t0-3) + ) + ) + 0 + (none) + ) + +;; definition (debug) for function validate-bucket-bits +;; WARN: Return type mismatch int vs symbol. +(defun-debug validate-bucket-bits ((arg0 grid-hash) (arg1 (pointer grid-hash-word))) + (let ((s3-0 (-> arg0 object-count)) + (s2-0 (* (-> arg0 bucket-size) 8)) + (gp-0 0) + (s5-0 0) + ) + (while (< s3-0 s2-0) + (let* ((s1-0 (/ s3-0 8)) + (a0-1 (- s3-0 (* s1-0 8))) + ) + (when (logtest? (-> arg1 s1-0) (ash 1 a0-1)) + (format 0 "bit ~d, " s3-0) + (+! gp-0 1) + (set! s5-0 (the-as int (-> arg1 s1-0))) + ) + ) + (+! s3-0 1) + ) + (when (> gp-0 0) + (format 0 "~%~d bad bits found~%" gp-0) + (format 0 "bad-word ~x~%" s5-0) + (break!) + 0 + ) + ) + (the-as symbol 0) + ) + +;; definition for method 18 of type grid-hash +;; ERROR: function was not converted to expressions. Cannot decompile. + +;; definition for method 19 of type grid-hash +;; ERROR: function was not converted to expressions. Cannot decompile. + +;; definition for method 20 of type grid-hash +;; ERROR: function was not converted to expressions. Cannot decompile. + +;; definition for method 21 of type grid-hash +;; WARN: Return type mismatch int vs none. +(defmethod set-up-box grid-hash ((obj grid-hash) (arg0 grid-hash-box) (arg1 vector) (arg2 vector)) + (dotimes (v1-0 3) + (set! (-> arg0 min v1-0) + (the int + (fmax + 0.0 + (fmin + (* (- (-> arg1 data v1-0) (-> obj box-min v1-0)) (-> obj axis-scale v1-0)) + (the float (+ (-> obj dimension-array v1-0) -1)) + ) + ) + ) + ) + (set! (-> arg0 max v1-0) + (the int (fmax 0.0 (fmin + (* (- (-> arg2 data v1-0) (-> obj box-min v1-0)) (-> obj axis-scale v1-0)) + (the float (+ (-> obj dimension-array v1-0) -1)) + ) + ) + ) + ) + ) + 0 + (none) + ) + +;; definition for method 22 of type grid-hash +;; ERROR: function was not converted to expressions. Cannot decompile. + +;; definition for method 23 of type grid-hash +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs none. +(defmethod line-sphere-to-grid-box grid-hash ((obj grid-hash) (arg0 grid-hash-box) (arg1 vector) (arg2 vector) (arg3 float)) + (let ((s4-0 (new 'stack-no-clear 'grid-hash-box)) + (s5-0 (new 'stack-no-clear 'grid-hash-box)) + ) + (let ((v1-0 (new 'stack-no-clear 'vector)) + (s2-0 (new 'stack-no-clear 'vector)) + ) + (set! (-> v1-0 quad) (-> arg1 quad)) + (vector+! s2-0 arg1 arg2) + (set! (-> v1-0 w) arg3) + (set! (-> s2-0 w) arg3) + (sphere-to-grid-box obj s4-0 (the-as sphere v1-0)) + (sphere-to-grid-box obj s5-0 (the-as sphere s2-0)) + ) + (set! (-> arg0 min 0) (min (-> s4-0 min 0) (-> s5-0 min 0))) + (set! (-> arg0 min 1) (min (-> s4-0 min 1) (-> s5-0 min 1))) + (set! (-> arg0 min 2) (min (-> s4-0 min 2) (-> s5-0 min 2))) + (set! (-> arg0 max 0) (max (-> s4-0 max 0) (-> s5-0 max 0))) + (set! (-> arg0 max 1) (max (-> s4-0 max 1) (-> s5-0 max 1))) + (set! (-> arg0 max 2) (max (-> s4-0 max 2) (-> s5-0 max 2))) + ) + 0 + (none) + ) + +;; definition for method 10 of type grid-hash +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs none. +(defmethod clear-bucket-array grid-hash ((obj grid-hash)) + (let ((v1-5 (/ (+ (* (* (* (-> obj dimension-array 0) (-> obj dimension-array 1)) (-> obj dimension-array 2)) + (-> obj bucket-size) + ) + 15 + ) + 16 + ) + ) + (a0-1 (the-as (pointer uinteger) (-> obj bucket-array))) + ) + (while (nonzero? v1-5) + (+! v1-5 -1) + (set! (-> (the-as (pointer uint128) a0-1) 0) (the-as uint128 0)) + (set! a0-1 (&-> (the-as (pointer grid-hash-word) a0-1) 16)) + ) + ) + 0 + (none) + ) + +;; definition for method 24 of type grid-hash +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs none. +(defmethod update-grid grid-hash ((obj grid-hash)) + (let ((v1-0 (new 'stack-no-clear 'vector))) + (dotimes (a1-0 3) + (set! (-> v1-0 data a1-0) (fmax (-> obj min-cell-size) (- (-> obj box-max a1-0) (-> obj box-min a1-0)))) + ) + (b! + (and (> (-> obj object-count) 0) (< 0.0 (-> v1-0 x)) (< 0.0 (-> v1-0 y)) (< 0.0 (-> v1-0 z))) + cfg-23 + :delay (empty-form) + ) + (set! (-> obj bucket-count) 1) + (set! (-> obj bucket-size) 1) + (dotimes (v1-3 3) + (set! (-> obj box-min v1-3) 0.0) + (set! (-> obj box-max v1-3) 0.0) + (set! (-> obj axis-scale v1-3) 0.0) + (set! (-> obj dimension-array v1-3) 1) + ) + (let* ((v1-6 obj) + (a0-6 + (/ (+ (* (* (* (-> v1-6 dimension-array 0) (-> v1-6 dimension-array 1)) (-> v1-6 dimension-array 2)) + (-> v1-6 bucket-size) + ) + 15 + ) + 16 + ) + ) + (v1-7 (the-as (pointer uinteger) (-> v1-6 bucket-array))) + ) + (while (nonzero? a0-6) + (+! a0-6 -1) + (set! (-> (the-as (pointer uint128) v1-7) 0) (the-as uint128 0)) + (set! v1-7 (&-> (the-as (pointer grid-hash-word) v1-7) 16)) + ) + ) + 0 + (b! #t cfg-41 :delay (nop!)) + (label cfg-23) + (let ((a1-18 8)) + (set! (-> obj bucket-size) (/ (+ a1-18 -1 (-> obj object-count)) a1-18)) + ) + (set! (-> obj bucket-count) + (min (* (-> obj object-count) 16) (/ (-> obj bucket-memory-size) (-> obj bucket-size))) + ) + (let ((f0-11 + (sqrtf + (/ (the float (-> obj bucket-count)) (* (-> v1-0 x) (-> v1-0 z) (the float (-> obj vertical-cell-count)))) + ) + ) + ) + (let ((a1-27 (min 126 (+ (-> obj bucket-count) -1)))) + (set! (-> obj dimension-array 0) (max 1 (min (the int (* f0-11 (-> v1-0 x))) a1-27))) + (set! (-> obj dimension-array 1) (-> obj vertical-cell-count)) + (set! (-> obj dimension-array 2) (max 1 (min (the int (* f0-11 (-> v1-0 z))) a1-27))) + ) + (let* ((f1-15 (* f0-11 (-> v1-0 z))) + (f1-17 (- f1-15 (the float (the int f1-15)))) + (f0-12 (* f0-11 (-> v1-0 x))) + ) + (cond + ((< f1-17 (- f0-12 (the float (the int f0-12)))) + (if (>= (-> obj bucket-count) + (* (* (+ (-> obj dimension-array 0) 1) (-> obj dimension-array 1)) (-> obj dimension-array 2)) + ) + (+! (-> obj dimension-array 0) 1) + ) + ) + (else + (if (>= (-> obj bucket-count) + (* (* (-> obj dimension-array 0) (-> obj dimension-array 1)) (+ (-> obj dimension-array 2) 1)) + ) + (+! (-> obj dimension-array 2) 1) + ) + ) + ) + ) + ) + (dotimes (a1-40 2) + (let* ((a2-26 (* a1-40 2)) + (a3-12 (max 1 (the int (/ (-> v1-0 data a2-26) (-> obj min-cell-size))))) + ) + (set! (-> (the-as (pointer uint8) (+ a2-26 (the-as int obj))) 24) + (the-as uint (min (-> (the-as (pointer int8) (+ a2-26 (the-as int obj))) 24) a3-12)) + ) + ) + ) + (dotimes (a1-43 3) + (set! (-> obj axis-scale a1-43) (/ (the float (-> obj dimension-array a1-43)) (-> v1-0 data a1-43))) + ) + ) + (let ((a2-34 (* (* (-> obj dimension-array 0) (-> obj dimension-array 1)) (-> obj dimension-array 2)))) + (b! (< (-> obj bucket-count) a2-34) cfg-40) + (let* ((v1-16 obj) + (a0-12 + (/ (+ (* (* (* (-> v1-16 dimension-array 0) (-> v1-16 dimension-array 1)) (-> v1-16 dimension-array 2)) + (-> v1-16 bucket-size) + ) + 15 + ) + 16 + ) + ) + (v1-17 (the-as (pointer uinteger) (-> v1-16 bucket-array))) + ) + (while (nonzero? a0-12) + (+! a0-12 -1) + (set! (-> (the-as (pointer uint128) v1-17) 0) (the-as uint128 0)) + (set! v1-17 (&-> (the-as (pointer grid-hash-word) v1-17) 16)) + ) + ) + 0 + (b! #t cfg-41 :delay (nop!)) + (label cfg-40) + (format + *stdcon* + "grid-hash::update-grid: bucket overflow! ~d dim ~d ~d ~d~%" + a2-34 + (-> obj dimension-array 0) + (-> obj dimension-array 1) + (-> obj dimension-array 2) + ) + ) + (label cfg-41) + 0 + (none) + ) + +;; definition for method 9 of type grid-hash +;; WARN: Return type mismatch int vs none. +(defmethod update-grid-for-objects-in-box grid-hash ((obj grid-hash) (arg0 int) (arg1 vector) (arg2 vector)) + (set! (-> obj object-count) arg0) + (dotimes (v1-0 3) + (set! (-> obj box-min v1-0) (-> arg1 data v1-0)) + (set! (-> obj box-max v1-0) (-> arg2 data v1-0)) + ) + (update-grid obj) + 0 + (none) + ) + +;; definition for method 11 of type grid-hash +;; WARN: Return type mismatch int vs none. +(defmethod setup-search-box grid-hash ((obj grid-hash) (arg0 int) (arg1 vector) (arg2 vector) (arg3 vector)) + (let ((v1-0 (new 'stack-no-clear 'vector)) + (t1-0 (new 'stack-no-clear 'vector)) + ) + (dotimes (t2-0 3) + (set! (-> v1-0 data t2-0) (fmin (fmin (-> arg1 data t2-0) (-> arg2 data t2-0)) (-> arg3 data t2-0))) + (set! (-> t1-0 data t2-0) (fmax (fmax (-> arg1 data t2-0) (-> arg2 data t2-0)) (-> arg3 data t2-0))) + ) + (let ((a2-3 obj) + (a3-1 (-> obj search-box)) + ) + (dotimes (t0-1 3) + (set! (-> a3-1 min t0-1) + (the int + (fmax + 0.0 + (fmin + (* (- (-> v1-0 data t0-1) (-> a2-3 box-min t0-1)) (-> a2-3 axis-scale t0-1)) + (the float (+ (-> a2-3 dimension-array t0-1) -1)) + ) + ) + ) + ) + (set! (-> a3-1 max t0-1) + (the int (fmax 0.0 (fmin + (* (- (-> t1-0 data t0-1) (-> a2-3 box-min t0-1)) (-> a2-3 axis-scale t0-1)) + (the float (+ (-> a2-3 dimension-array t0-1) -1)) + ) + ) + ) + ) + ) + ) + ) + 0 + (set! (-> obj work object-id) arg0) + (let* ((t1-1 obj) + (t2-21 (-> obj search-box)) + (a3-2 arg0) + (v1-5 (-> t1-1 bucket-size)) + (a0-2 (* (-> t1-1 dimension-array 0) v1-5)) + (a1-2 (* (-> t1-1 dimension-array 2) a0-2)) + (a2-6 (+ (- 1 (-> t2-21 min 0)) (-> t2-21 max 0))) + (t0-6 (+ (- 1 (-> t2-21 min 2)) (-> t2-21 max 2))) + (t3-22 (+ (- 1 (-> t2-21 min 1)) (-> t2-21 max 1))) + (t1-3 (the-as + object + (+ (+ (* (-> t2-21 min 0) v1-5) (* (-> t2-21 min 1) a1-2) (* (-> t2-21 min 2) a0-2) (/ a3-2 8) 0) + (the-as int (the-as pointer (-> t1-1 bucket-array))) + ) + ) + ) + (a3-4 (ash 1 (logand a3-2 7))) + (t2-28 t3-22) + ) + (label cfg-10) + (let ((t3-23 t0-6) + (t4-6 t1-3) + ) + (label cfg-11) + (let ((t5-2 a2-6) + (t6-0 t4-6) + ) + (label cfg-12) + (nop!) + (let ((t7-0 (-> (the-as (pointer uint8) t6-0)))) + (nop!) + (let ((t7-1 (logior t7-0 a3-4))) + (+! t5-2 -1) + (set! (-> (the-as (pointer uint8) t6-0)) t7-1) + ) + ) + (b! (nonzero? t5-2) cfg-12 :delay (set! t6-0 (+ (the-as pointer t6-0) v1-5))) + ) + (+! t3-23 -1) + (nop!) + (b! (nonzero? t3-23) cfg-11 :delay (set! t4-6 (+ (the-as pointer t4-6) a0-2))) + ) + (+! t2-28 -1) + (nop!) + (b! (nonzero? t2-28) cfg-10 :delay (set! t1-3 (+ (the-as pointer t1-3) a1-2))) + ) + 0 + 0 + (none) + ) + +;; definition for method 12 of type grid-hash +(defmethod search-for-point grid-hash ((obj grid-hash) (arg0 vector)) + (let ((v1-0 obj) + (a0-1 (-> obj search-box)) + (a2-0 arg0) + ) + (dotimes (a3-0 3) + (set! (-> a0-1 min a3-0) + (the int + (fmax + 0.0 + (fmin + (* (- (-> a2-0 data a3-0) (-> v1-0 box-min a3-0)) (-> v1-0 axis-scale a3-0)) + (the float (+ (-> v1-0 dimension-array a3-0) -1)) + ) + ) + ) + ) + (set! (-> a0-1 max a3-0) + (the int (fmax 0.0 (fmin + (* (- (-> arg0 data a3-0) (-> v1-0 box-min a3-0)) (-> v1-0 axis-scale a3-0)) + (the float (+ (-> v1-0 dimension-array a3-0) -1)) + ) + ) + ) + ) + ) + ) + 0 + (do-search! obj (-> obj search-box) (-> obj work result-words)) + (-> obj work result-words) + ) + +;; definition for method 13 of type grid-hash +;; WARN: Found some very strange gotos. Check result carefully, this is not well tested. +;; INFO: Used lq/sq +(defmethod search-for-sphere grid-hash ((obj grid-hash) (arg0 vector) (arg1 float)) + (let ((v1-0 (new 'stack-no-clear 'sphere))) + (set! (-> v1-0 quad) (-> arg0 quad)) + (set! (-> v1-0 r) arg1) + (sphere-to-grid-box obj (-> obj search-box) v1-0) + ) + (let ((s5-0 (-> obj work result-words)) + (s4-0 0) + ) + (label cfg-1) + (do-search! obj (-> obj search-box) s5-0) + (dotimes (v1-5 (-> obj bucket-size)) + (set! s4-0 (logior s4-0 (-> s5-0 v1-5))) + ) + (when (zero? s4-0) + (when (or (> (-> obj search-box min 0) 0) + (> (-> obj search-box min 2) 0) + (< (-> obj search-box max 0) (+ (-> obj dimension-array 0) -1)) + (< (-> obj search-box max 2) (+ (-> obj dimension-array 2) -1)) + ) + (set! (-> obj search-box min 0) (max 0 (+ (-> obj search-box min 0) -1))) + (set! (-> obj search-box min 2) (max 0 (+ (-> obj search-box min 2) -1))) + (set! (-> obj search-box max 0) (min (+ (-> obj dimension-array 0) -1) (+ (-> obj search-box max 0) 1))) + (set! (-> obj search-box max 2) (min (+ (-> obj dimension-array 2) -1) (+ (-> obj search-box max 2) 1))) + (goto cfg-1) + ) + ) + ) + (-> obj work result-words) + ) + +;; definition (debug) for function draw-grid +;; WARN: Return type mismatch int vs none. +(defun-debug draw-grid ((arg0 vector) (arg1 vector) (arg2 (pointer int8)) (arg3 rgba)) + (local-vars (sv-64 vector) (sv-68 vector) (sv-72 vector)) + (set! sv-64 (new 'stack-no-clear 'vector)) + (set! sv-68 (new 'stack-no-clear 'vector)) + (set! sv-72 (new 'stack-no-clear 'vector)) + (dotimes (v1-3 3) + (set! (-> sv-64 data v1-3) (/ (- (-> arg1 data v1-3) (-> arg0 data v1-3)) (the float (-> arg2 v1-3)))) + ) + (set! (-> sv-68 x) (-> arg0 x)) + (set! (-> sv-72 x) (-> arg1 x)) + (dotimes (s2-0 (+ (-> arg2 1) 1)) + (set! (-> sv-68 y) (+ (-> arg0 y) (* (the float s2-0) (-> sv-64 y)))) + (set! (-> sv-72 y) (-> sv-68 y)) + (dotimes (s1-0 (+ (-> arg2 2) 1)) + (set! (-> sv-68 z) (+ (-> arg0 z) (* (the float s1-0) (-> sv-64 z)))) + (set! (-> sv-72 z) (-> sv-68 z)) + (add-debug-line #t (bucket-id debug2) sv-68 sv-72 arg3 #f (the-as rgba -1)) + ) + ) + (set! (-> sv-68 z) (-> arg0 z)) + (set! (-> sv-72 z) (-> arg1 z)) + (dotimes (s2-1 (+ (-> arg2 1) 1)) + (set! (-> sv-68 y) (+ (-> arg0 y) (* (the float s2-1) (-> sv-64 y)))) + (set! (-> sv-72 y) (-> sv-68 y)) + (dotimes (s1-1 (+ (-> arg2 0) 1)) + (set! (-> sv-68 x) (+ (-> arg0 x) (* (the float s1-1) (-> sv-64 x)))) + (set! (-> sv-72 x) (-> sv-68 x)) + (add-debug-line #t (bucket-id debug2) sv-68 sv-72 arg3 #f (the-as rgba -1)) + ) + ) + (set! (-> sv-68 y) (-> arg0 y)) + (set! (-> sv-72 y) (-> arg1 y)) + (dotimes (s3-1 (+ (-> arg2 0) 1)) + (set! (-> sv-68 x) (+ (-> arg0 x) (* (the float s3-1) (-> sv-64 x)))) + (set! (-> sv-72 x) (-> sv-68 x)) + (dotimes (s2-2 (+ (-> arg2 2) 1)) + (set! (-> sv-68 z) (+ (-> arg0 z) (* (the float s2-2) (-> sv-64 z)))) + (set! (-> sv-72 z) (-> sv-68 z)) + (add-debug-line #t (bucket-id debug2) sv-68 sv-72 arg3 #f (the-as rgba -1)) + ) + ) + 0 + (none) + ) + +;; definition for method 14 of type grid-hash +;; WARN: Return type mismatch int vs none. +(defmethod draw grid-hash ((obj grid-hash) (arg0 rgba)) + "Draws the grid-hash" + (let ((v1-0 (new 'stack-no-clear 'vector)) + (t0-0 (new 'stack-no-clear 'vector)) + ) + (dotimes (a2-0 3) + (set! (-> v1-0 data a2-0) (-> obj box-min a2-0)) + (set! (-> t0-0 data a2-0) (-> obj box-max a2-0)) + ) + (draw-grid v1-0 t0-0 (-> obj dimension-array) arg0) + ) + 0 + (none) + ) + +;; definition for method 15 of type grid-hash +;; WARN: Return type mismatch int vs none. +(defmethod dump-grid-info grid-hash ((obj grid-hash)) + "Prints out info about the grid-hash, also draws via [[grid-hash::draw-grid]] if `debug-draw` is `#t`" + (if (-> obj debug-draw) + (draw obj *color-light-blue*) + ) + (format + *stdcon* + "bucket memory ~d, bucket-size ~d, word-size ~d bits~%" + (-> obj bucket-memory-size) + (-> obj bucket-size) + 8 + ) + (format + *stdcon* + "bucket dimensions ~d ~d ~d~%" + (-> obj dimension-array 0) + (-> obj dimension-array 1) + (-> obj dimension-array 2) + ) + (format *stdcon* "object-count ~d, bucket-count ~d~%" (-> obj object-count) (-> obj bucket-count)) + 0 + (none) + ) + +;; definition (debug) for function draw-sphere-box +;; WARN: Return type mismatch int vs none. +(defun-debug draw-sphere-box ((arg0 sphere) (arg1 rgba)) + (let ((a2-0 (new 'stack-no-clear 'vector)) + (a3-0 (new 'stack-no-clear 'vector)) + ) + (dotimes (v1-0 3) + (set! (-> a2-0 data v1-0) (- (-> arg0 data v1-0) (-> arg0 r))) + (set! (-> a3-0 data v1-0) (+ (-> arg0 data v1-0) (-> arg0 r))) + ) + (add-debug-box #t (bucket-id debug-no-zbuf1) a2-0 a3-0 arg1) + ) + 0 + (none) + ) + +;; definition (debug) for function draw-line-sphere +;; WARN: Return type mismatch int vs none. +(defun-debug draw-line-sphere ((arg0 vector) (arg1 vector) (arg2 float) (arg3 rgba)) + (let ((gp-0 (new 'stack-no-clear 'vector))) + (vector+! gp-0 arg0 arg1) + (add-debug-sphere #t (bucket-id debug-no-zbuf1) arg0 arg2 arg3) + (add-debug-sphere #t (bucket-id debug-no-zbuf1) gp-0 arg2 arg3) + ) + 0 + (none) + ) + +;; definition for method 0 of type sphere-hash +;; WARN: Return type mismatch object vs sphere-hash. +(defmethod new sphere-hash ((allocation symbol) (type-to-make type) (arg0 int) (arg1 int)) + (let ((s5-0 (the-as object (object-new allocation type-to-make (the-as int (-> type-to-make size)))))) + (when (zero? (the-as sphere-hash s5-0)) + (set! s5-0 0) + (goto cfg-4) + ) + (set! (-> (the-as sphere-hash s5-0) work) *grid-hash-work*) + (set! (-> (the-as sphere-hash s5-0) object-count) 0) + (set! (-> (the-as sphere-hash s5-0) bucket-memory-size) arg0) + (set! (-> (the-as sphere-hash s5-0) vertical-cell-count) 1) + (set! (-> (the-as sphere-hash s5-0) min-cell-size) 16384.0) + (set! (-> (the-as sphere-hash s5-0) mem-bucket-array) + (the-as (pointer grid-hash-word) (malloc allocation arg0)) + ) + (set! (-> (the-as sphere-hash s5-0) spr-bucket-array) (the-as (pointer grid-hash-word) #x70000000)) + (set! (-> (the-as sphere-hash s5-0) bucket-array) (-> (the-as sphere-hash s5-0) mem-bucket-array)) + (set! (-> (the-as sphere-hash s5-0) debug-draw) #f) + (set! (-> (the-as sphere-hash s5-0) use-scratch-ram) #f) + (set! (-> (the-as sphere-hash s5-0) max-object-count) arg1) + (set! (-> (the-as sphere-hash s5-0) mem-sphere-array) (the-as uint (malloc allocation (* arg1 16)))) + (set! (-> (the-as sphere-hash s5-0) spr-sphere-array) (the-as uint (+ #x70000000 arg0))) + (set! (-> (the-as sphere-hash s5-0) sphere-array) + (the-as (inline-array sphere) (-> (the-as sphere-hash s5-0) mem-sphere-array)) + ) + (label cfg-4) + (the-as sphere-hash s5-0) + ) + ) + +;; definition for method 25 of type sphere-hash +;; WARN: Return type mismatch int vs none. +(defmethod clear-objects! sphere-hash ((obj sphere-hash)) + (set! (-> obj object-count) 0) + (dotimes (v1-0 3) + (set! (-> obj box-min v1-0) 10000000000000000000000000000000000000.0) + (set! (-> obj box-max v1-0) -10000000000000000000000000000000000000.0) + ) + (cond + ((-> obj use-scratch-ram) + (set! (-> obj sphere-array) (the-as (inline-array sphere) (-> obj spr-sphere-array))) + (set! (-> obj bucket-array) (-> obj spr-bucket-array)) + ) + (else + (set! (-> obj sphere-array) (the-as (inline-array sphere) (-> obj mem-sphere-array))) + (set! (-> obj bucket-array) (-> obj mem-bucket-array)) + ) + ) + 0 + (none) + ) + +;; definition for method 28 of type sphere-hash +;; ERROR: function was not converted to expressions. Cannot decompile. + +;; definition for method 26 of type sphere-hash +(defmethod add-a-sphere sphere-hash ((obj sphere-hash) (arg0 vector)) + (let ((gp-0 (-> obj object-count))) + (cond + ((< gp-0 (-> obj max-object-count)) + (let ((a0-2 (-> obj sphere-array gp-0))) + (mem-copy! (the-as pointer a0-2) (the-as pointer arg0) 16) + ) + (dotimes (v1-2 3) + (set! (-> obj box-min v1-2) (fmin (-> obj box-min v1-2) (- (-> arg0 data v1-2) (-> arg0 w)))) + (set! (-> obj box-max v1-2) (fmax (-> obj box-max v1-2) (+ (-> arg0 data v1-2) (-> arg0 w)))) + ) + (+! (-> obj object-count) 1) + gp-0 + ) + (else + -1 + ) + ) + ) + ) + +;; definition for method 27 of type sphere-hash +(defmethod add-a-sphere-with-flag sphere-hash ((obj sphere-hash) (arg0 vector) (arg1 int)) + (let ((gp-0 (-> obj object-count))) + (cond + ((< gp-0 (-> obj max-object-count)) + (let ((s2-0 (the-as object (-> obj sphere-array gp-0)))) + (mem-copy! (the-as pointer s2-0) (the-as pointer arg0) 16) + (dotimes (v1-2 3) + (set! (-> obj box-min v1-2) (fmin (-> obj box-min v1-2) (- (-> arg0 data v1-2) (-> arg0 w)))) + (set! (-> obj box-max v1-2) (fmax (-> obj box-max v1-2) (+ (-> arg0 data v1-2) (-> arg0 w)))) + ) + (set! (-> (the-as (pointer int8) s2-0) 12) arg1) + ) + (+! (-> obj object-count) 1) + gp-0 + ) + (else + -1 + ) + ) + ) + ) + +;; definition for method 33 of type sphere-hash +;; ERROR: function was not converted to expressions. Cannot decompile. + +;; definition for method 29 of type sphere-hash +;; ERROR: function was not converted to expressions. Cannot decompile. + +;; definition for method 30 of type sphere-hash +;; ERROR: function was not converted to expressions. Cannot decompile. + +;; definition for method 31 of type sphere-hash +;; ERROR: function was not converted to expressions. Cannot decompile. + +;; definition for method 32 of type sphere-hash +;; ERROR: function was not converted to expressions. Cannot decompile. + +;; definition for method 15 of type sphere-hash +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs none. +(defmethod dump-grid-info sphere-hash ((obj sphere-hash)) + "Prints out info about the grid-hash, also draws via [[grid-hash::draw-grid]] if `debug-draw` is `#t`" + ((find-parent-method sphere-hash 15) obj) + (new 'stack-no-clear 'vector) + (let ((f30-0 6144.0)) + (set! (-> obj work temp-box-min quad) (-> (target-pos 0) quad)) + (+! (-> obj work temp-box-min y) f30-0) + ) + (set! (-> obj work temp-box-max quad) (-> obj work temp-box-min quad)) + (set! (-> obj work visit-count) 0) + (set! (-> obj debug-draw) #t) + (set! (-> obj work add-object-time) (the-as uint 0)) + 0 + (none) + ) + +;; definition for method 0 of type spatial-hash +;; WARN: Return type mismatch object vs spatial-hash. +(defmethod new spatial-hash ((allocation symbol) (type-to-make type) (arg0 int) (arg1 int)) + (let ((gp-0 (the-as object (object-new allocation type-to-make (the-as int (-> type-to-make size)))))) + (when (zero? (the-as spatial-hash gp-0)) + (set! gp-0 0) + (goto cfg-4) + ) + (set! (-> (the-as spatial-hash gp-0) work) *grid-hash-work*) + (set! (-> (the-as spatial-hash gp-0) object-count) 0) + (set! (-> (the-as spatial-hash gp-0) bucket-memory-size) arg0) + (set! (-> (the-as spatial-hash gp-0) vertical-cell-count) 1) + (set! (-> (the-as spatial-hash gp-0) min-cell-size) 16384.0) + (set! (-> (the-as spatial-hash gp-0) mem-bucket-array) + (the-as (pointer grid-hash-word) (malloc allocation arg0)) + ) + (set! (-> (the-as spatial-hash gp-0) spr-bucket-array) (the-as (pointer grid-hash-word) #x70000000)) + (set! (-> (the-as spatial-hash gp-0) bucket-array) (-> (the-as spatial-hash gp-0) mem-bucket-array)) + (set! (-> (the-as spatial-hash gp-0) debug-draw) #f) + (set! (-> (the-as spatial-hash gp-0) use-scratch-ram) #f) + (set! (-> (the-as spatial-hash gp-0) max-object-count) arg1) + (set! (-> (the-as spatial-hash gp-0) mem-sphere-array) (the-as uint (malloc allocation (* arg1 16)))) + (set! (-> (the-as spatial-hash gp-0) mem-object-array) + (the-as (inline-array hash-object-info) (malloc allocation (* arg1 16))) + ) + (set! (-> (the-as spatial-hash gp-0) spr-sphere-array) (the-as uint (+ #x70000000 arg0))) + (set! (-> (the-as spatial-hash gp-0) spr-object-array) + (the-as (inline-array hash-object-info) (+ #x70000000 (* arg1 16) arg0)) + ) + (set! (-> (the-as spatial-hash gp-0) sphere-array) + (the-as (inline-array sphere) (-> (the-as spatial-hash gp-0) mem-sphere-array)) + ) + (set! (-> (the-as spatial-hash gp-0) object-array) (-> (the-as spatial-hash gp-0) mem-object-array)) + (label cfg-4) + (the-as spatial-hash gp-0) + ) + ) + +;; definition for method 25 of type spatial-hash +;; WARN: Return type mismatch int vs none. +(defmethod clear-objects! spatial-hash ((obj spatial-hash)) + (set! (-> obj object-count) 0) + (dotimes (v1-0 3) + (set! (-> obj box-min v1-0) 10000000000000000000000000000000000000.0) + (set! (-> obj box-max v1-0) -10000000000000000000000000000000000000.0) + ) + (cond + ((-> obj use-scratch-ram) + (set! (-> obj sphere-array) (the-as (inline-array sphere) (-> obj spr-sphere-array))) + (set! (-> obj object-array) (-> obj spr-object-array)) + (set! (-> obj bucket-array) (-> obj spr-bucket-array)) + ) + (else + (set! (-> obj sphere-array) (the-as (inline-array sphere) (-> obj mem-sphere-array))) + (set! (-> obj object-array) (-> obj mem-object-array)) + (set! (-> obj bucket-array) (-> obj mem-bucket-array)) + ) + ) + 0 + (none) + ) + +;; definition for method 33 of type spatial-hash +;; ERROR: function was not converted to expressions. Cannot decompile. + +;; definition for method 34 of type spatial-hash +(defmethod add-an-object spatial-hash ((obj spatial-hash) (arg0 vector) (arg1 hash-object-info)) + (let ((gp-0 (-> obj object-count))) + (cond + ((< gp-0 (-> obj max-object-count)) + (let ((a0-2 (-> obj sphere-array gp-0)) + (s2-0 (-> obj object-array gp-0)) + ) + (mem-copy! (the-as pointer a0-2) (the-as pointer arg0) 16) + (set! (-> s2-0 object) (the-as basic arg1)) + ) + (dotimes (v1-3 3) + (set! (-> obj box-min v1-3) (fmin (-> obj box-min v1-3) (- (-> arg0 data v1-3) (-> arg0 w)))) + (set! (-> obj box-max v1-3) (fmax (-> obj box-max v1-3) (+ (-> arg0 data v1-3) (-> arg0 w)))) + ) + (+! (-> obj object-count) 1) + gp-0 + ) + (else + -1 + ) + ) + ) + ) + +;; definition for method 39 of type spatial-hash +;; ERROR: function was not converted to expressions. Cannot decompile. + +;; definition for method 36 of type spatial-hash +;; ERROR: function was not converted to expressions. Cannot decompile. + +;; definition for method 37 of type spatial-hash +;; ERROR: function was not converted to expressions. Cannot decompile. + +;; definition for method 35 of type spatial-hash +;; ERROR: function was not converted to expressions. Cannot decompile. + +;; definition for method 38 of type spatial-hash +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs none. +(defmethod fill-actor-list-for-vec+r spatial-hash ((obj spatial-hash) (arg0 vector) (arg1 (pointer collide-shape)) (arg2 int)) + (let ((v1-0 (new 'stack-no-clear 'sphere))) + (set! (-> v1-0 quad) (-> arg0 quad)) + (set! (-> v1-0 r) 0.0) + (fill-actor-list-for-sphere obj v1-0 arg1 arg2) + ) + (none) + ) + +;; definition for method 40 of type spatial-hash +;; WARN: Return type mismatch int vs none. +(defmethod validate-objects spatial-hash ((obj spatial-hash)) + (dotimes (s5-0 (-> obj object-count)) + (let ((a0-2 (-> obj object-array s5-0 object))) + (when (not (valid? a0-2 basic (the-as symbol "") #t 0)) + (break!) + 0 + ) + ) + ) + 0 + (none) + ) + + + + diff --git a/test/offline/config/jak2/config.jsonc b/test/offline/config/jak2/config.jsonc index 18cc3c3fac..8432a712e5 100644 --- a/test/offline/config/jak2/config.jsonc +++ b/test/offline/config/jak2/config.jsonc @@ -198,6 +198,9 @@ "(method 13 collide-shape-prim)", "collide-shape-draw-debug-marks", + "(method 11 grid-hash)", + "(method 15 sphere-hash)", + "i-hopefully-will-never-exist-dont-add-anything-after-me-please"