diff --git a/decompiler/analysis/mips2c.cpp b/decompiler/analysis/mips2c.cpp index b151fef10..607298db7 100644 --- a/decompiler/analysis/mips2c.cpp +++ b/decompiler/analysis/mips2c.cpp @@ -2,6 +2,7 @@ #include "mips2c.h" +#include "common/symbols.h" #include "common/util/print_float.h" #include "decompiler/Disasm/InstructionMatching.h" #include "decompiler/Function/Function.h" @@ -570,8 +571,29 @@ Mips2C_Line handle_generic_op2_u16(const Instruction& i0, const std::string& ins instr_str}; } +Mips2C_Line handle_daddiu(Mips2C_Output& out, const Instruction& i0, const std::string& instr_str) { + if (i0.get_src(1).is_label()) { + return {instr_str, instr_str}; + } else if (i0.get_src(0).is_reg(rs7()) && i0.get_src(1).is_sym("#t")) { + return {fmt::format("c->{}({}, {}, {});", i0.op_name_to_string(), reg_to_name(i0.get_dst(0)), + reg_to_name(i0.get_src(0)), FIX_SYM_TRUE), + instr_str}; + } else if (i0.get_src(0).is_reg(rs7()) && i0.get_src(1).is_sym()) { + out.require_symbol(i0.get_src(1).get_sym()); + return {fmt::format("c->load_symbol_addr({}, cache.{});", reg_to_name(i0.get_dst(0)), + goal_to_c_name(i0.get_src(1).get_sym())), + instr_str}; + } else { + return handle_generic_op2_u16(i0, instr_str); + } +} + Mips2C_Line handle_sw(Mips2C_Output& out, const Instruction& i0, const std::string& instr_str) { if (i0.get_src(1).is_sym() && i0.get_src(2).is_reg(rs7())) { + out.require_symbol(i0.get_src(1).get_sym()); + return {fmt::format("c->store_symbol({}, cache.{});", reg_to_name(i0.get_src(0)), + goal_to_c_name(i0.get_src(1).get_sym())), + instr_str}; return handle_unknown(instr_str); // auto name = i0.get_src(1).get_sym(); // // store into symbol table! @@ -747,12 +769,22 @@ Mips2C_Line handle_likely_branch_bc(const Instruction& i0, const std::string& in switch (i0.kind) { case InstructionKind::BLTZL: return {fmt::format("((s64){}) < 0", reg64_or_zero(i0.get_src(0))), instr_str}; + case InstructionKind::BGEZL: + return {fmt::format("((s64){}) >= 0", reg64_or_zero(i0.get_src(0))), instr_str}; + case InstructionKind::BGTZL: + return {fmt::format("((s64){}) > 0", reg64_or_zero(i0.get_src(0))), instr_str}; case InstructionKind::BNEL: return {fmt::format("((s64){}) != ((s64){})", reg64_or_zero(i0.get_src(0)), reg64_or_zero(i0.get_src(1))), instr_str}; + case InstructionKind::BEQL: + return {fmt::format("((s64){}) == ((s64){})", reg64_or_zero(i0.get_src(0)), + reg64_or_zero(i0.get_src(1))), + instr_str}; case InstructionKind::BC1TL: return {"cop1_bc", instr_str}; + case InstructionKind::BC1FL: + return {"!cop1_bc", instr_str}; default: return handle_unknown(instr_str); } @@ -834,6 +866,12 @@ Mips2C_Line handle_cles(const Instruction& i0, const std::string& instr_string) instr_string}; } +Mips2C_Line handle_ceqs(const Instruction& i0, const std::string& instr_string) { + return {fmt::format("cop1_bc = c->fprs[{}] == c->fprs[{}];", reg_to_name(i0.get_src(0)), + reg_to_name(i0.get_src(1))), + instr_string}; +} + Mips2C_Line handle_pmfhl_lh(const Instruction& i0, const std::string& instr_string) { return {fmt::format("c->pmfhl_lh({});", reg_to_name(i0.get_dst(0))), instr_string}; } @@ -892,12 +930,16 @@ Mips2C_Line handle_normal_instr(Mips2C_Output& output, return handle_generic_op2_mask(i0, instr_str, "vmove"); case InstructionKind::VITOF0: return handle_generic_op2_mask(i0, instr_str, "vitof0"); + case InstructionKind::VITOF12: + return handle_generic_op2_mask(i0, instr_str, "vitof12"); case InstructionKind::VFTOI0: return handle_generic_op2_mask(i0, instr_str, "vftoi0"); case InstructionKind::VFTOI4: return handle_generic_op2_mask(i0, instr_str, "vftoi4"); case InstructionKind::VFTOI12: return handle_generic_op2_mask(i0, instr_str, "vftoi12"); + case InstructionKind::VABS: + return handle_generic_op2_mask(i0, instr_str, "vabs"); case InstructionKind::VADDQ: return handle_generic_op2_mask(i0, instr_str, "vaddq"); case InstructionKind::ANDI: @@ -956,6 +998,7 @@ Mips2C_Line handle_normal_instr(Mips2C_Output& output, case InstructionKind::AND: return handle_generic_op3(i0, instr_str, "and_"); // and isn't allowed in C++ case InstructionKind::DADDIU: + return handle_daddiu(output, i0, instr_str); case InstructionKind::ADDIU: return handle_generic_op2_u16(i0, instr_str); case InstructionKind::QMTC2: @@ -996,6 +1039,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::MOVS: + return handle_generic_op2(i0, instr_str, "movs"); case InstructionKind::CVTWS: return handle_generic_op2(i0, instr_str, "cvtws"); case InstructionKind::CVTSW: @@ -1014,6 +1059,9 @@ Mips2C_Line handle_normal_instr(Mips2C_Output& output, case InstructionKind::CLES: output.needs_cop1_bc = true; return handle_cles(i0, instr_str); + case InstructionKind::CEQS: + output.needs_cop1_bc = true; + return handle_ceqs(i0, instr_str); case InstructionKind::VWAITQ: return handle_plain_op(i0, instr_str, "vwaitq"); case InstructionKind::VOPMULA: diff --git a/decompiler/config/all-types.gc b/decompiler/config/all-types.gc index 690d71fb4..d0bc89ef0 100644 --- a/decompiler/config/all-types.gc +++ b/decompiler/config/all-types.gc @@ -11238,6 +11238,7 @@ (declare-type collide-cache-prim structure) (declare-type collide-shape-prim-group basic) +(declare-type collide-cache basic) (deftype collide-shape-prim (basic) ((cshape collide-shape :offset-assert 4) (prim-id uint32 :offset-assert 8) @@ -11260,9 +11261,9 @@ (move-by-vector! (_type_ vector) none 9) (find-prim-by-id (_type_ uint) collide-shape-prim 10) (debug-draw-world-sphere (_type_) symbol 11) - (add-fg-prim-using-box (_type_ process-drawable) none 12) - (add-fg-prim-using-line-sphere (_type_ process-drawable) none 13) - (add-fg-prim-using-y-probe (_type_ process-drawable) none 14) + (add-fg-prim-using-box (_type_ collide-cache) none 12) + (add-fg-prim-using-line-sphere (_type_ collide-cache) none 13) + (add-fg-prim-using-y-probe (_type_ collide-cache) none 14) (overlaps-others-test (_type_ overlaps-others-params collide-shape-prim) symbol 15) (overlaps-others-group (_type_ overlaps-others-params collide-shape-prim-group) symbol 16) (dummy-17 () none 17) @@ -11357,10 +11358,10 @@ (on-platform (_type_ collide-shape collide-overlap-result) symbol 39) (find-overlapping-shapes (_type_ overlaps-others-params) symbol 40) ;; check if blocked?? (dummy-41 (_type_ attack-info float) vector 41) - (compute-overlap (_type_ collide-shape collide-overlap-result) symbol 42) + (should-push-away (_type_ collide-shape collide-overlap-result) symbol 42) (pull-rider! (_type_ pull-rider-info) none 43) (pull-riders! (_type_) symbol 44) - (respond-to-collisions! (_type_) symbol 45) + (do-push-aways! (_type_) symbol 45) (set-root-prim! (_type_ collide-shape-prim) collide-shape-prim 46) (update-transforms! (_type_) symbol 47) (clear-collide-with-as (_type_) none 48) @@ -11516,6 +11517,15 @@ (unknown-float64 float :offset 1316) ;; from - logic-target::target-compute-slopes (unknown-dword20 int64 :offset 1320) ;; from target-util::turn-around? - TODO (unknown-dword21 int64 :offset 1328) ;; from target-util::turn-around? - TODO + (unknown-dword-coverage int64 :offset 1336) + (unknown-float-coverage-0 float :offset 1344) + (unknown-float-coverage-1 float :offset 1348) + (unknown-float-coverage-2 float :offset 1352) + (unknown-u32-coverage-0 uint32 :offset 1356) + (unknown-vector-coverage-0 vector :inline :offset 1376) + (unknown-vector-coverage-1 vector :inline :offset 1392) + (unknown-vector-coverage-2 vector :inline :offset 1440) + (unknown-vector-coverage-3 vector :inline :offset 1472) (unknown-vector60 vector :inline :offset 1456) ;; from - logic-target::add-thrust (unknown-vector61 vector :inline :offset 1504) ;; from - logic-target::add-thrust (unknown-float70 float :offset 1520) ;; from - logic-target::add-thrust @@ -11601,6 +11611,7 @@ (unknown-dword82 int64 :offset 18912) ;; from logic-target::reset-target-state (unknown-vector120 vector :inline :offset 18928) ;; from target::(code target-running-attack) (unknown-float150 float :offset 18944) ;; from target::(code target-wheel-flip) + (unknown-vector121 vector :inline :offset 18960) ;; from target collide response (unknown-int60 uint32 :offset 18976) ;; from logic-target::print-target-stats (unknown-soundid00 sound-id :offset 18980) ;; from powerups::target-powerup-process (unknown-float141 float :offset 18984) ;; from powerups::target-powerup-process @@ -11790,7 +11801,7 @@ :flag-assert #xb00000810 (:methods (debug-draw (_type_) object 9) - (dummy-10 () none 10) + (dummy-10 (_type_ collide-edge-hold-item) none 10) ) ) @@ -11832,12 +11843,12 @@ (debug-draw-edges (_type_) object 10) (dummy-11 (_type_) none 11) (debug-draw-sphere (_type_) symbol 12) - (dummy-13 (_type_) none 13) + (dummy-13 (_type_ collide-edge-hold-item vector) none 13) (dummy-14 (_type_ vector vector int) float 14) (dummy-15 (_type_) none 15) - (dummy-16 (_type_) none 16) + (find-grabbable-tris! (_type_) none 16) (dummy-17 (_type_) none 17) - (dummy-18 (_type_) none 18) + (dummy-18 (_type_ collide-edge-hold-list edge-grab-info) none 18) (dummy-19 (_type_ collide-edge-hold-item edge-grab-info) symbol 19) ) ) @@ -12482,8 +12493,8 @@ :size-assert #xc60 :flag-assert #xb00000c60 (:methods - (dummy-9 () none 9) - (dummy-10 () none 10) + (dummy-9 (_type_ object object) symbol 9) + (dummy-10 (_type_ object object) symbol 10) ) ) @@ -12502,10 +12513,11 @@ (deftype collide-cache-tri (structure) ((vertex vector 3 :inline :offset-assert 0) ;(extra-quad UNKNOWN 16 :offset-assert 48) - (pat pat-surface :offset-assert 48) - (prim-index uint16 :offset-assert 52) - (user16 uint16 :offset-assert 54) - (user32 uint32 2 :offset-assert 56) + (extra-quad uint128 :offset 48) + (pat pat-surface :offset 48) + (prim-index uint16 :offset 52) + (user16 uint16 :offset 54) + (user32 uint32 2 :offset 56) ) :method-count-assert 9 :size-assert #x40 @@ -12514,12 +12526,12 @@ (deftype collide-cache-prim (structure) ((prim-core collide-prim-core :inline :offset-assert 0) - ;;(extra-quad UNKNOWN 16 :offset-assert 32) - (ccache collide-cache :offset-assert 32) - (prim collide-shape-prim :offset-assert 36) - (first-tri uint16 :offset-assert 40) - (num-tris uint16 :offset-assert 42) - (unused uint8 4 :offset-assert 44) + (extra-quad uint128 :offset-assert 32) + (ccache collide-cache :offset 32) + (prim collide-shape-prim :offset 36) + (first-tri uint16 :offset 40) + (num-tris uint16 :offset 42) + (unused uint8 4 :offset 44) (world-sphere vector :inline :offset 0) (collide-as collide-kind :offset 16) (action collide-action :offset 24) @@ -12554,7 +12566,7 @@ (:methods (debug-draw (_type_) none 9) (fill-and-probe-using-line-sphere (_type_ vector vector float collide-kind process collide-tri-result int) float 10) - (fill-and-probe-using-spheres (_type_ collide-using-spheres-params) none 11) + (fill-and-probe-using-spheres (_type_ collide-using-spheres-params) symbol 11) (fill-and-probe-using-y-probe (_type_ vector float collide-kind process collide-tri-result uint) float 12) (fill-using-bounding-box (_type_ bounding-box collide-kind process-drawable pat-surface) none 13) (fill-using-line-sphere (_type_ vector vector float collide-kind process-drawable int) none 14) @@ -12562,20 +12574,20 @@ (fill-using-y-probe (_type_ vector float collide-kind process-drawable uint) none 16) (initialize (_type_) none 17) (probe-using-line-sphere (_type_ vector vector float collide-kind collide-tri-result int) float 18) - (probe-using-spheres (_type_) none 19) + (probe-using-spheres (_type_ collide-using-spheres-params) symbol 19) (probe-using-y-probe (_type_ vector float collide-kind collide-tri-result uint) float 20) - (fill-from-background (_type_ (function bsp-header int collide-list none) (function collide-cache none)) none 21) ;; second functiom is method 28 - (fill-from-foreground-using-spheres (_type_) none 22) + (fill-from-background (_type_ (function bsp-header int collide-list none) (function collide-cache object none)) none 21) ;; second functiom is method 28 + (fill-from-foreground-using-box (_type_) none 22) (fill-from-foreground-using-line-sphere (_type_) none 23) (fill-from-foreground-using-y-probe (_type_) none 24) (fill-from-water (_type_ water-control) none 25) ;; or whatever is from 152 in the process passed to 16 - (dummy-26 (_type_) none 26) + (load-mesh-from-spad-in-box (_type_ collide-frag-mesh) none 26) (dummy-27 (_type_) none 27) (dummy-28 (_type_) none 28) (dummy-29 (_type_ collide-frag-mesh) none 29) - (dummy-30 (_type_) none 30) - (dummy-31 (_type_ collide-puyp-work collide-cache-prim) vector 31) - (dummy-32 (_type_) none 32) + (puyp-mesh (_type_ collide-puyp-work collide-cache-prim) none 30) + (puyp-sphere (_type_ collide-puyp-work collide-cache-prim) vector 31) + (unpack-background-collide-mesh (_type_ object object object) none 32) ;; helper for fill from background. ) ) @@ -14439,7 +14451,7 @@ (print-nth-point (_type_ int) none 11) (TODO-RENAME-12 (_type_) none 12) (TODO-RENAME-13 (_type_ int) none 13) - (TODO-RENAME-14 (_type_ vector) none 14) + (TODO-RENAME-14 (_type_ tracking-spline-sampler) none 14) (TODO-RENAME-15 (_type_) none 15) (TODO-RENAME-16 (_type_ float) none 16) (TODO-RENAME-17 (_type_ vector float float symbol) int 17) ; - return value is actually none but they do a manual `return` @@ -19940,7 +19952,7 @@ ;; - Functions (define-extern collide-shape-moving-angle-set! (function collide-shape-moving vector vector none)) -(define-extern target-collision-low-coverage (function control-info collide-shape-intersect vector (pointer int) (pointer int) (pointer symbol) uint)) ;; i think the pointers are lies - TODO +(define-extern target-collision-low-coverage (function control-info collide-shape-intersect vector (pointer uint32) (pointer uint64) (pointer symbol) uint)) ;; i think the pointers are lies - TODO (define-extern poly-find-nearest-edge (function vector (inline-array vector) vector vector vector)) (define-extern target-collision-reaction (function control-info collide-shape-intersect vector vector none)) (define-extern target-collision-no-reaction (function control-info collide-shape-intersect vector vector none)) @@ -20080,7 +20092,7 @@ (define-extern target-apply-tongue (function vector symbol :behavior target)) (define-extern get-intersect-point (function vector touching-prims-entry control-info process vector)) (define-extern target-powerup-effect (function symbol none :behavior target)) -(define-extern target-shoved (function meters meters process (state target) object :behavior target)) +(define-extern target-shoved (function meters meters process (state object object target) object :behavior target)) (define-extern target-dangerous-event-handler (function process int symbol event-message-block object :behavior target)) (define-extern target-jump-event-handler (function process int symbol event-message-block object :behavior target)) (define-extern target-walk-event-handler (function process int symbol event-message-block object :behavior target)) diff --git a/decompiler/config/jak1_ntsc_black_label/hacks.jsonc b/decompiler/config/jak1_ntsc_black_label/hacks.jsonc index f342e9c14..5d5198e5b 100644 --- a/decompiler/config/jak1_ntsc_black_label/hacks.jsonc +++ b/decompiler/config/jak1_ntsc_black_label/hacks.jsonc @@ -237,10 +237,10 @@ "(method 13 collide-edge-work)", // CFG "(method 17 collide-edge-work)", // CFG "(method 15 collide-edge-work)", // CFG - "(method 16 collide-edge-work)", // CFG + // CFG "(method 9 edge-grab-info)", // CFG "(method 18 collide-edge-work)", // CFG - "(method 10 collide-edge-hold-list)", // CFG + // CFG "(method 12 collide-mesh)", @@ -253,7 +253,7 @@ "ambient-inspect", // target BUG - "target-falling-anim-trans", // CFG resolution + //"target-falling-anim-trans", // CFG resolution // target2 BUG "look-for-points-of-interest", // Failed to split nested sc - looks like dead code to me @@ -261,20 +261,14 @@ // collide-cache "(method 10 collide-puss-work)", // CFG "(method 9 collide-puss-work)", // decompiler crash - "(method 19 collide-cache)", // decompiler crash - "(method 10 collide-cache-prim)", // CFG - "(method 9 collide-cache-prim)", // CFG - "(method 30 collide-cache)", // unsupported asm - c.le.s - "(method 13 collide-shape-prim-group)", // CFG - "(method 13 collide-shape-prim-mesh)", // CFG - "(method 14 collide-shape-prim-group)", // CFG - "(method 14 collide-shape-prim-mesh)", // CFG - "(method 12 collide-shape-prim-group)", // CFG - "(method 12 collide-shape-prim-mesh)", // CFG - "(method 27 collide-cache)", // CFG + // decompiler crash + + // CFG + // CFG + // CFG // "(method 14 collide-cache)", // CFG - "(method 28 collide-cache)", // CFG - "(method 26 collide-cache)", // CFG + // CFG + // "(method 26 collide-cache)", // CFG //"(method 21 collide-cache)", // CFG "(method 32 collide-cache)", // CFG @@ -487,7 +481,20 @@ "(method 16 collide-shape-prim)" : [1, 2, 3, 4, 5, 6], "(method 15 collide-shape-prim-sphere)" : [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19], "(method 15 collide-shape-prim-mesh)" : [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 29], - "(method 35 collide-shape)" : [1] + "(method 35 collide-shape)" : [1], + "(method 22 collide-cache)":[2, 3, 4, 13, 14, 15, 23, 24, 25, 33, 34, 35], + "(method 12 collide-shape-prim-sphere)" : [0, 1], + "(method 12 collide-shape-prim-group)" : [1, 2, 3, 4], + "(method 24 collide-cache)" : [2, 3, 4, 13, 14, 15, 23, 24, 25, 33, 34, 35], + "(method 14 collide-shape-prim-sphere)" : [0, 1, 2, 3], + "(method 14 collide-shape-prim-group)" : [0, 1, 2, 3, 4], + "(method 23 collide-cache)" : [2, 3, 4, 13, 14, 15, 23, 24, 25, 33, 34, 35], + "(method 13 collide-shape-prim-sphere)" : [0, 1, 2], + "(method 13 collide-shape-prim-group)" : [0, 1, 2,3,4], + "(method 19 collide-cache)" : [0, 1, 3, 4, 5, 18, 19], + "(method 10 collide-mesh)" : [1, 2, 4, 5], + "target-falling-anim-trans" : [5, 6] + }, // Sometimes the game might use format strings that are fetched dynamically, @@ -539,7 +546,27 @@ "(method 12 collide-mesh)", "(method 11 collide-mesh)", "collide-probe-node", - "collide-probe-instance-tie" + "collide-probe-instance-tie", + "(method 32 collide-cache)", + "(method 28 collide-cache)", + "(method 26 collide-cache)", + "(method 27 collide-cache)", + "(method 29 collide-cache)", + "(method 12 collide-shape-prim-mesh)", + "(method 14 collide-shape-prim-mesh)", + "(method 13 collide-shape-prim-mesh)", + "(method 30 collide-cache)", + "(method 9 collide-cache-prim)", + "(method 10 collide-cache-prim)", + "(method 9 collide-puss-work)", + "(method 10 collide-puss-work)", + + // these could easily be goal, but probably faster/easier this way. + "(method 14 collide-mesh)", + "(method 15 collide-mesh)", + + "(method 16 collide-edge-work)", + "(method 10 collide-edge-hold-list)" ], // there are some missing textures. I don't know what the game actually does here. diff --git a/decompiler/config/jak1_ntsc_black_label/stack_structures.jsonc b/decompiler/config/jak1_ntsc_black_label/stack_structures.jsonc index 472cc78f6..05cdf9696 100644 --- a/decompiler/config/jak1_ntsc_black_label/stack_structures.jsonc +++ b/decompiler/config/jak1_ntsc_black_label/stack_structures.jsonc @@ -696,7 +696,7 @@ [48, "collide-tri-result"] ], - "(method 20 collide-cache)": [[16, "vector"]], + "(method 20 collide-cache)": [[16, "collide-puyp-work"]], "(method 12 wobbler)": [[16, "vector"]], @@ -4366,7 +4366,7 @@ "target-collision-reaction": [ [16, "vector"], [32, "vector"], - [48, "vector"], + [48, "matrix"], [112, "vector"], [128, "vector"], [144, "vector"], @@ -6082,6 +6082,15 @@ "(method 18 collide-shape-prim-sphere)" : [ [16, "collide-tri-result"] ], + "target-collision-low-coverage" : [ + [64, "collide-tri-result"], + [176, "vector"], + [192, "vector"], + [224, "vector"], + [240, "vector"], + [256, "vector"], + [288, "vector"] + ], "placeholder-do-not-add-below!": [] } diff --git a/decompiler/config/jak1_ntsc_black_label/type_casts.jsonc b/decompiler/config/jak1_ntsc_black_label/type_casts.jsonc index d5abb81d2..07d106778 100644 --- a/decompiler/config/jak1_ntsc_black_label/type_casts.jsonc +++ b/decompiler/config/jak1_ntsc_black_label/type_casts.jsonc @@ -5795,16 +5795,13 @@ ], "(method 9 collide-cache)": [ - [5, "gp", "collide-cache-tri"], - [19, "gp", "collide-cache-tri"], - [20, "gp", "collide-cache-tri"], - [21, "gp", "collide-cache-tri"], - [23, "gp", "(inline-array collide-cache-tri)"], - [33, "gp", "collide-cache-prim"], + [[1,29], "gp", "collide-cache-tri"], + [[29,56], "gp", "collide-cache-prim"], [35, "gp", "collide-cache-prim"], [50, "gp", "collide-cache-prim"], [51, "gp", "collide-cache-prim"], - [55, "gp", "(inline-array collide-cache-prim)"] + [55, "gp", "collide-cache-prim"], + [36, "v1", "collide-shape-prim-sphere"] ], "(method 9 collide-mesh)": [ @@ -7547,6 +7544,9 @@ [190, "v1", "(pointer int32)"], [147, "v1", "collide-list-item"], [148, "v1", "collide-list-item"], + [[91, 95], "v1", "dma-packet"], + [[112, 141], "v1", "dma-bank-spr"], + [[154, 188], "a2", "dma-bank-spr"], [[217, 227], "s3", "collide-list-item"] ], @@ -7590,5 +7590,63 @@ [[16, 55], "gp", "collide-shape-prim-mesh"] ], + "(method 25 collide-cache)" : [ + [[83, 104], "a2", "(inline-array collide-cache-tri)"] + ], + + "(method 22 collide-cache)" : [ + [14, "v1", "connection"], + [[15,31], "v1", "collide-shape"], + [74, "v1", "connection"], + [[75, 91], "v1", "collide-shape"], + [130, "v1", "connection"], + [[131, 148], "v1", "collide-shape"], + [187, "v1", "connection"], + [[188, 205], "v1", "collide-shape"] + ], + + "(method 12 collide-shape-prim-sphere)" : [ + [[13, 23], "t0", "collide-cache-prim"] + ], + + "(method 24 collide-cache)" : [ + [14, "v1", "connection"], + [[15,31], "v1", "collide-shape"], + [74, "v1", "connection"], + [[75, 91], "v1", "collide-shape"], + [130, "v1", "connection"], + [[131, 148], "v1", "collide-shape"], + [187, "v1", "connection"], + [[188, 205], "v1", "collide-shape"] + ], + + "(method 14 collide-shape-prim-sphere)" : [ + [[11, 23], "t0", "collide-cache-prim"] + ], + + "(method 23 collide-cache)" : [ + [20, "v1", "connection"], + [[21,43], "v1", "collide-shape"], + [86, "v1", "connection"], + [[87,109], "v1", "collide-shape"], + [148, "v1", "connection"], + [[149, 174], "v1", "collide-shape"], + [211, "v1", "connection"], + [[212, 235], "v1", "collide-shape"] + ], + + "(method 13 collide-shape-prim-sphere)" : [ + [[11, 23], "t0", "collide-cache-prim"] + ], + + "(method 31 collide-cache)" : [ + [22, "v1", "collide-shape-prim-sphere"] + ], + + "(method 19 collide-cache)" : [ + [[52, 94], "s4", "collide-cache-prim"], + [[1, 100], "s5", "collide-puss-work"] + ], + "placeholder-do-not-add-below": [] } diff --git a/game/CMakeLists.txt b/game/CMakeLists.txt index b823dbcbc..57d98ca14 100644 --- a/game/CMakeLists.txt +++ b/game/CMakeLists.txt @@ -60,6 +60,8 @@ set(RUNTIME_SOURCE kernel/ksocket.cpp kernel/ksound.cpp mips2c/mips2c_table.cpp + mips2c/functions/collide_cache.cpp + mips2c/functions/collide_edge_grab.cpp mips2c/functions/collide_func.cpp mips2c/functions/collide_mesh.cpp mips2c/functions/collide_probe.cpp diff --git a/game/graphics/opengl_renderer/BucketRenderer.h b/game/graphics/opengl_renderer/BucketRenderer.h index c1f9e8af3..283f70947 100644 --- a/game/graphics/opengl_renderer/BucketRenderer.h +++ b/game/graphics/opengl_renderer/BucketRenderer.h @@ -63,6 +63,9 @@ struct SharedRenderState { bool dump_playback = false; bool use_sky_cpu = true; + + bool has_camera_planes = false; + math::Vector4f camera_planes[4]; }; /*! diff --git a/game/graphics/opengl_renderer/OpenGLRenderer.cpp b/game/graphics/opengl_renderer/OpenGLRenderer.cpp index a8316ea8f..369988fbe 100644 --- a/game/graphics/opengl_renderer/OpenGLRenderer.cpp +++ b/game/graphics/opengl_renderer/OpenGLRenderer.cpp @@ -120,6 +120,7 @@ void OpenGLRenderer::render(DmaFollower dma, const RenderOptions& settings) { m_render_state.dump_playback = settings.playing_from_dump; m_render_state.ee_main_memory = settings.playing_from_dump ? nullptr : g_ee_main_mem; m_render_state.offset_of_s7 = offset_of_s7(); + m_render_state.has_camera_planes = false; { auto prof = m_profiler.root()->make_scoped_child("frame-setup"); diff --git a/game/graphics/opengl_renderer/SpriteRenderer.cpp b/game/graphics/opengl_renderer/SpriteRenderer.cpp index 2ff4cd71a..63a410c15 100644 --- a/game/graphics/opengl_renderer/SpriteRenderer.cpp +++ b/game/graphics/opengl_renderer/SpriteRenderer.cpp @@ -2,6 +2,7 @@ #include "third-party/imgui/imgui.h" #include "SpriteRenderer.h" #include "game/graphics/opengl_renderer/dma_helpers.h" +#include "game/graphics/opengl_renderer/tfrag/tfrag_common.h" namespace { @@ -99,12 +100,12 @@ SpriteRenderer::SpriteRenderer(const std::string& name, BucketId my_id) * the table upload stuff that runs every frame, even if there are no sprites. */ void SpriteRenderer::render_distorter(DmaFollower& dma, - SharedRenderState* render_state, - ScopedProfilerNode& prof) { + SharedRenderState* /*render_state*/, + ScopedProfilerNode& /*prof*/) { // Next thing should be the sprite-distorter setup // m_direct_renderer.reset_state(); while (dma.current_tag().qwc != 7) { - auto direct_data = dma.read_and_advance(); + dma.read_and_advance(); // m_direct_renderer.render_vif(direct_data.vif0(), direct_data.vif1(), direct_data.data, // direct_data.size_bytes, render_state, prof); } @@ -194,10 +195,6 @@ void SpriteRenderer::render_2d_group0(DmaFollower& dma, m_3d_matrix_data.hvdf_offset.data()); glUniform1f(glGetUniformLocation(render_state->shaders[ShaderId::SPRITE].id(), "pfog0"), m_frame_data.pfog0); - glUniform1f(glGetUniformLocation(render_state->shaders[ShaderId::SPRITE].id(), "fog_min"), - m_frame_data.fog_min); - glUniform1f(glGetUniformLocation(render_state->shaders[ShaderId::SPRITE].id(), "fog_max"), - m_frame_data.fog_max); glUniform1f(glGetUniformLocation(render_state->shaders[ShaderId::SPRITE].id(), "min_scale"), m_frame_data.min_scale); glUniform1f(glGetUniformLocation(render_state->shaders[ShaderId::SPRITE].id(), "max_scale"), @@ -417,16 +414,10 @@ void SpriteRenderer::draw_debug_window() { m_debug_stats.count_2d_grp0); ImGui::Text("2D Group 1 (HUD) blocks: %d sprites: %d", m_debug_stats.blocks_2d_grp1, m_debug_stats.count_2d_grp1); - ImGui::Checkbox("Extra Debug", &m_extra_debug); + ImGui::Checkbox("Culling", &m_enable_culling); ImGui::Checkbox("2d", &m_2d_enable); ImGui::SameLine(); ImGui::Checkbox("3d", &m_3d_enable); - ImGui::SameLine(); - ImGui::Checkbox("3d-debug", &m_3d_debug); - if (ImGui::TreeNode("direct")) { - // m_sprite_renderer.draw_debug_window(); - ImGui::TreePop(); - } } /////////////////////////////////////////////////////////////////////////////////////////////////// @@ -471,8 +462,8 @@ void SpriteRenderer::flush_sprites(SharedRenderState* render_state, ScopedProfil } void SpriteRenderer::handle_tex0(u64 val, - SharedRenderState* render_state, - ScopedProfilerNode& prof) { + SharedRenderState* /*render_state*/, + ScopedProfilerNode& /*prof*/) { GsTex0 reg(val); // update tbp @@ -495,8 +486,8 @@ void SpriteRenderer::handle_tex0(u64 val, } void SpriteRenderer::handle_tex1(u64 val, - SharedRenderState* render_state, - ScopedProfilerNode& prof) { + SharedRenderState* /*render_state*/, + ScopedProfilerNode& /*prof*/) { GsTex1 reg(val); // for now, we aren't going to handle mipmapping. I don't think it's used with direct. // assert(reg.mxl() == 0); @@ -512,8 +503,8 @@ void SpriteRenderer::handle_tex1(u64 val, } void SpriteRenderer::handle_zbuf(u64 val, - SharedRenderState* render_state, - ScopedProfilerNode& prof) { + SharedRenderState* /*render_state*/, + ScopedProfilerNode& /*prof*/) { // note: we can basically ignore this. There's a single z buffer that's always configured the same // way - 24-bit, at offset 448. GsZbuf x(val); @@ -524,8 +515,8 @@ void SpriteRenderer::handle_zbuf(u64 val, } void SpriteRenderer::handle_clamp(u64 val, - SharedRenderState* render_state, - ScopedProfilerNode& prof) { + SharedRenderState* /*render_state*/, + ScopedProfilerNode& /*prof*/) { if (!(val == 0b101 || val == 0 || val == 1 || val == 0b100)) { fmt::print("clamp: 0x{:x}\n", val); assert(false); @@ -559,20 +550,20 @@ void SpriteRenderer::update_gl_blend(AdGifState& state) { // unsupported blend: a 0 b 2 c 2 d 1 lg::error("unsupported blend: a {} b {} c {} d {}\n", (int)state.a, (int)state.b, (int)state.c, (int)state.d); - assert(false); + // assert(false); } } } void SpriteRenderer::handle_alpha(u64 val, - SharedRenderState* render_state, - ScopedProfilerNode& prof) { + SharedRenderState* /*render_state*/, + ScopedProfilerNode& /*prof*/) { GsAlpha reg(val); m_adgif_state.from_register(reg); } -void SpriteRenderer::update_gl_prim(SharedRenderState* render_state) { +void SpriteRenderer::update_gl_prim(SharedRenderState* /*render_state*/) { // currently gouraud is handled in setup. const auto& state = m_prim_gl_state; if (state.fogging_enable) { @@ -655,6 +646,16 @@ void SpriteRenderer::do_block_common(SpriteMode mode, flush_sprites(render_state, prof); } + if (mode == Mode2D && render_state->has_camera_planes && m_enable_culling) { + // we can skip sprites that are out of view + // it's probably possible to do this for 3D as well. + auto bsphere = m_vec_data_2d[sprite_idx].xyz_sx; + bsphere.w() = std::max(bsphere.w(), m_vec_data_2d[sprite_idx].sy()); + if (bsphere.w() == 0 || !sphere_in_view_ref(bsphere, render_state->camera_planes)) { + continue; + } + } + auto& adgif = m_adgif[sprite_idx]; // fmt::print("adgif: {:X} {:X} {:X} {:X}\n", adgif.tex0_data, adgif.tex1_data, // adgif.clamp_data, adgif.alpha_data); fmt::print("adgif regs: {} {} {} {} {}\n", diff --git a/game/graphics/opengl_renderer/SpriteRenderer.h b/game/graphics/opengl_renderer/SpriteRenderer.h index 4362db66e..e95a5834b 100644 --- a/game/graphics/opengl_renderer/SpriteRenderer.h +++ b/game/graphics/opengl_renderer/SpriteRenderer.h @@ -197,8 +197,7 @@ class SpriteRenderer : public BucketRenderer { int count_2d_grp1 = 0; } m_debug_stats; - bool m_extra_debug = false; - bool m_3d_debug = false; + bool m_enable_culling = true; bool m_2d_enable = true; bool m_3d_enable = true; diff --git a/game/graphics/opengl_renderer/shaders/sprite_3d.vert b/game/graphics/opengl_renderer/shaders/sprite_3d.vert index 9b4a56174..b584ec030 100644 --- a/game/graphics/opengl_renderer/shaders/sprite_3d.vert +++ b/game/graphics/opengl_renderer/shaders/sprite_3d.vert @@ -12,8 +12,6 @@ uniform mat4 hud_matrix; uniform vec4 hud_hvdf_offset; uniform vec4 hud_hvdf_user[75]; uniform float pfog0; -uniform float fog_min; -uniform float fog_max; uniform float min_scale; uniform float max_scale; uniform float bonus; @@ -62,8 +60,6 @@ vec4 sprite_transform2(vec3 root, vec4 off, mat3 sprite_rot, float sx, float sy) float Q = pfog0 / transformed_pos.w; transformed_pos.xyz *= Q; transformed_pos.xyz += hvdf_offset.xyz; - // transformed_pos.w = max(transformed_pos.w, fog_max); - // transformed_pos.w = min(transformed_pos.w, fog_min); return transformed_pos; } @@ -108,8 +104,7 @@ void main() { transformed_pos_vf02.xyz *= Q; vec4 offset_pos_vf10 = transformed_pos_vf02 + hvdf_offset; - offset_pos_vf10.w = max(offset_pos_vf10.w, fog_max); - offset_pos_vf10.w = min(offset_pos_vf10.w, fog_min); + /* transformed_pos_vf02.w = offset_pos_vf10.w - fog_max; int fge = matrix == 0; if (transformed_pos_vf02.w != 0) { @@ -136,8 +131,6 @@ void main() { transformed_pos_vf02.xyz *= Q; vec4 offset_pos_vf10 = transformed_pos_vf02 + (matrix == 0 ? hud_hvdf_offset : hud_hvdf_user[matrix - 1]); - offset_pos_vf10.w = max(offset_pos_vf10.w, fog_max); - offset_pos_vf10.w = min(offset_pos_vf10.w, fog_min); scales_vf01.z = min(max(scales_vf01.z, min_scale), max_scale); scales_vf01.w = min(max(scales_vf01.w, min_scale), max_scale); diff --git a/game/graphics/opengl_renderer/tfrag/TFragment.cpp b/game/graphics/opengl_renderer/tfrag/TFragment.cpp index 856dcecfd..e33bd9878 100644 --- a/game/graphics/opengl_renderer/tfrag/TFragment.cpp +++ b/game/graphics/opengl_renderer/tfrag/TFragment.cpp @@ -111,7 +111,9 @@ void TFragment::render(DmaFollower& dma, for (int i = 0; i < 4; i++) { settings.planes[i] = m_pc_port_data.planes[i]; + render_state->camera_planes[i] = m_pc_port_data.planes[i]; } + render_state->has_camera_planes = true; if (m_override_time_of_day) { for (int i = 0; i < 8; i++) { diff --git a/game/graphics/opengl_renderer/tfrag/Tie3.cpp b/game/graphics/opengl_renderer/tfrag/Tie3.cpp index 0d42d88a0..66f7def4c 100644 --- a/game/graphics/opengl_renderer/tfrag/Tie3.cpp +++ b/game/graphics/opengl_renderer/tfrag/Tie3.cpp @@ -429,7 +429,9 @@ void Tie3::render(DmaFollower& dma, SharedRenderState* render_state, ScopedProfi for (int i = 0; i < 4; i++) { settings.planes[i] = m_pc_port_data.planes[i]; + render_state->camera_planes[i] = m_pc_port_data.planes[i]; } + render_state->has_camera_planes = true; if (false) { // for (int i = 0; i < 8; i++) { diff --git a/game/graphics/opengl_renderer/tfrag/tfrag_common.h b/game/graphics/opengl_renderer/tfrag/tfrag_common.h index b51e596e0..fcd333bbf 100644 --- a/game/graphics/opengl_renderer/tfrag/tfrag_common.h +++ b/game/graphics/opengl_renderer/tfrag/tfrag_common.h @@ -44,6 +44,7 @@ void interp_time_of_day_fast(const float weights[8], void cull_check_all_slow(const math::Vector4f* planes, const std::vector& nodes, u8* out); +bool sphere_in_view_ref(const math::Vector4f& sphere, const math::Vector4f* planes); struct TfragPcPortData { math::Vector4f planes[4]; diff --git a/game/kernel/klink.cpp b/game/kernel/klink.cpp index 009810d7e..765e59cc5 100644 --- a/game/kernel/klink.cpp +++ b/game/kernel/klink.cpp @@ -889,6 +889,7 @@ void ultimate_memcpy(void* dst, void* src, uint32_t size) { auto sym = find_symbol_from_c("ultimate-memcpy"); if (sym->value == 0) { memmove(dst, src, size); + return; } gfunc_774.offset = sym->value; } diff --git a/game/mips2c/functions/collide_cache.cpp b/game/mips2c/functions/collide_cache.cpp new file mode 100644 index 000000000..a6fda43c0 --- /dev/null +++ b/game/mips2c/functions/collide_cache.cpp @@ -0,0 +1,3277 @@ +//--------------------------MIPS2C--------------------- +#include "game/mips2c/mips2c_private.h" +#include "game/kernel/kscheme.h" + +#include "common/dma/gs.h" + +namespace { +u32 vu0_buffer[1024]; // todo, maybe can be 512. +u32 vi1 = 0; + +void vlqi(Mips2C::ExecutionContext* c, int reg) { + memcpy(&c->vfs[reg].f[0], &vu0_buffer[vi1 * 4], 16); + vi1++; +} +} // namespace + +namespace Mips2C { + +namespace pc_upload_collide_frag { +u64 execute(void* ctxt) { + auto* c = (ExecutionContext*)ctxt; + // vif init is + // #x30000000 = STROW + // #x4d000000 ROW x + // #x4d000000 ROW y + // #x4d000000 ROW z + // #x3f800000 ROW w + // #x5000001 = STMOD 0b1 + // #x20000000 = STMASK + // #x40404040 = 1's on all w's + // #x1000404 = STCYCL cl: 4 wl: 4 + + // int qw_in_source = c->sgpr64(a1); + int qw_to_write = c->sgpr64(a2); + const u16* data_in = (const u16*)(g_ee_main_mem + c->sgpr64(a0)); + // I don't quite get why this is wrong sometimes. + // assert(qw_to_write * 3 == qw_in_source * 8); + assert(qw_to_write <= 128); + + int in_idx = 0; + int out_idx = 0; + + while (out_idx < qw_to_write * 4) { + vu0_buffer[out_idx++] = 0x4d000000 + data_in[in_idx++]; + vu0_buffer[out_idx++] = 0x4d000000 + data_in[in_idx++]; + vu0_buffer[out_idx++] = 0x4d000000 + data_in[in_idx++]; + vu0_buffer[out_idx++] = 0x3f800000; + } + + return 0; + + // (vif-cmd unpack-v3-16) + // (__pc-upload-collide-frag (-> frag mesh packed-data) (-> frag mesh vertex-data-qwc) (-> frag + // mesh vertex-count)) +} + +void link() { + gLinkedFunctionTable.reg("__pc-upload-collide-frag", execute, 128); +} + +} // namespace pc_upload_collide_frag + +// clang-format off + + +// download from VU0. + +namespace method_32_collide_cache { + +struct Cache { + void* fake_scratchpad_data; // *fake-scratchpad-data* +} cache; + +u64 execute(void* ctxt) { + auto* c = (ExecutionContext*)ctxt; + bool bc = false; + // u32 call_addr = 0; + c->daddiu(sp, sp, -16); // daddiu sp, sp, -16 + c->sd(fp, 8, sp); // sd fp, 8(sp) + c->mov64(fp, t9); // or fp, t9, r0 + // daddiu a0, fp, L307 // daddiu a0, fp, L307 + // handled at the lq's + // nop // sll r0, r0, 0 + bc = c->sgpr64(a2) == c->sgpr64(s7); // beq a2, s7, L293 + // nop // sll r0, r0, 0 + if (bc) {goto block_6;} // branch non-likely + + //c->lui(v1, 28672); // lui v1, 28672 + get_fake_spad_addr(v1, cache.fake_scratchpad_data, 0, c); + c->lqc2(vf14, 12, a1); // lqc2 vf14, 12(a1) + c->vmove(DEST::xyzw, vf1, vf0); // vmove.xyzw vf1, vf0 + // c->lqc2(vf13, 0, a0); // lqc2 vf13, 0(a0) + c->vfs[vf13].du32[0] = 0x4d000000; + c->vfs[vf13].du32[1] = 0x4d000000; + c->vfs[vf13].du32[2] = 0x4d000000; + c->vfs[vf13].du32[3] = 0; + c->vmove(DEST::xyzw, vf2, vf0); // vmove.xyzw vf2, vf0 + c->lbu(a0, 24, a1); // lbu a0, 24(a1) + assert(c->sgpr64(a3) == 0); + vi1 = 0; + // Unknown instr: ctc2.i vi1, a3 + c->vmove(DEST::xyzw, vf3, vf0); // vmove.xyzw vf3, vf0 + c->vitof0(DEST::xyzw, vf14, vf14); // vitof0.xyzw vf14, vf14 + c->vmove(DEST::xyzw, vf4, vf0); // vmove.xyzw vf4, vf0 + c->vmove(DEST::xyzw, vf5, vf0); // vmove.xyzw vf5, vf0 + // nop // sll r0, r0, 0 + c->vmove(DEST::xyzw, vf6, vf0); // vmove.xyzw vf6, vf0 + // nop // sll r0, r0, 0 + c->vmove(DEST::xyzw, vf7, vf0); // vmove.xyzw vf7, vf0 + // nop // sll r0, r0, 0 + c->vmove(DEST::xyzw, vf8, vf0); // vmove.xyzw vf8, vf0 + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + c->ld(a1, 52, a2); // ld a1, 52(a2) + // nop // sll r0, r0, 0 + c->ld(t1, 28, a2); // ld t1, 28(a2) + c->pextlh(a1, a1, r0); // pextlh a1, a1, r0 + c->ld(a3, 36, a2); // ld a3, 36(a2) + c->psraw(t0, a1, 10); // psraw t0, a1, 10 + c->ld(a1, 44, a2); // ld a1, 44(a2) + c->pextlh(t1, t1, r0); // pextlh t1, t1, r0 + c->mfc1(r0, f31); // mfc1 r0, f31 + c->psraw(t1, t1, 16); // psraw t1, t1, 16 + c->mfc1(r0, f31); // mfc1 r0, f31 + c->pextlh(a3, a3, r0); // pextlh a3, a3, r0 + c->mov128_vf_gpr(vf18, t0); // qmtc2.i vf18, t0 + c->psraw(a3, a3, 16); // psraw a3, a3, 16 + c->mov128_vf_gpr(vf15, t1); // qmtc2.i vf15, t1 + c->pextlh(a1, a1, r0); // pextlh a1, a1, r0 + c->mov128_vf_gpr(vf16, a3); // qmtc2.i vf16, a3 + c->psraw(a1, a1, 16); // psraw a1, a1, 16 + c->lqc2(vf1, 12, a2); // lqc2 vf1, 12(a2) + // nop // sll r0, r0, 0 + c->mov128_vf_gpr(vf17, a1); // qmtc2.i vf17, a1 + c->vitof0(DEST::xyzw, vf18, vf18); // vitof0.xyzw vf18, vf18 + // nop // sll r0, r0, 0 + c->vitof12(DEST::xyzw, vf15, vf15); // vitof12.xyzw vf15, vf15 + // nop // sll r0, r0, 0 + c->vitof12(DEST::xyzw, vf16, vf16); // vitof12.xyzw vf16, vf16 + // nop // sll r0, r0, 0 + c->vitof12(DEST::xyzw, vf17, vf17); // vitof12.xyzw vf17, vf17 + // nop // sll r0, r0, 0 + c->vadd(DEST::xyz, vf18, vf18, vf1); // vadd.xyz vf18, vf18, vf1 + // nop // sll r0, r0, 0 + c->vsub(DEST::xyzw, vf13, vf13, vf14); // vsub.xyzw vf13, vf13, vf14 + // Unknown instr: vlqi.xyz vf1, vi1 + vlqi(c, vf1); + c->daddiu(a0, a0, -4); // daddiu a0, a0, -4 + // Unknown instr: vlqi.xyz vf2, vi1 + vlqi(c, vf2); + // nop // sll r0, r0, 0 + // Unknown instr: vlqi.xyz vf3, vi1 + vlqi(c, vf3); + // nop // sll r0, r0, 0 + // Unknown instr: vlqi.xyz vf4, vi1 + vlqi(c, vf4); + c->vsub(DEST::xyz, vf1, vf1, vf13); // vsub.xyz vf1, vf1, vf13 + // Unknown instr: vlqi.xyz vf5, vi1 + vlqi(c, vf5); + c->vsub(DEST::xyz, vf2, vf2, vf13); // vsub.xyz vf2, vf2, vf13 + // Unknown instr: vlqi.xyz vf6, vi1 + vlqi(c, vf6); + c->vsub(DEST::xyz, vf3, vf3, vf13); // vsub.xyz vf3, vf3, vf13 + // Unknown instr: vlqi.xyz vf7, vi1 + vlqi(c, vf7); + c->vsub(DEST::xyz, vf4, vf4, vf13); // vsub.xyz vf4, vf4, vf13 + // Unknown instr: vlqi.xyz vf8, vi1 + vlqi(c, vf8); + c->vmula_bc(DEST::xyzw, BC::w, vf18, vf0); // vmulaw.xyzw acc, vf18, vf0 + // nop // sll r0, r0, 0 + c->vmadda_bc(DEST::xyzw, BC::x, vf15, vf1); // vmaddax.xyzw acc, vf15, vf1 + // nop // sll r0, r0, 0 + c->vmadda_bc(DEST::xyzw, BC::y, vf16, vf1); // vmadday.xyzw acc, vf16, vf1 + // nop // sll r0, r0, 0 + c->vmadd_bc(DEST::xyzw, BC::z, vf1, vf17, vf1); // vmaddz.xyzw vf1, vf17, vf1 + // nop // sll r0, r0, 0 + c->vmula_bc(DEST::xyzw, BC::w, vf18, vf0); // vmulaw.xyzw acc, vf18, vf0 + // nop // sll r0, r0, 0 + c->vmadda_bc(DEST::xyzw, BC::x, vf15, vf2); // vmaddax.xyzw acc, vf15, vf2 + // nop // sll r0, r0, 0 + c->vmadda_bc(DEST::xyzw, BC::y, vf16, vf2); // vmadday.xyzw acc, vf16, vf2 + // nop // sll r0, r0, 0 + c->vmadd_bc(DEST::xyzw, BC::z, vf2, vf17, vf2); // vmaddz.xyzw vf2, vf17, vf2 + // nop // sll r0, r0, 0 + c->vmula_bc(DEST::xyzw, BC::w, vf18, vf0); // vmulaw.xyzw acc, vf18, vf0 + // nop // sll r0, r0, 0 + c->vmadda_bc(DEST::xyzw, BC::x, vf15, vf3); // vmaddax.xyzw acc, vf15, vf3 + // nop // sll r0, r0, 0 + c->vmadda_bc(DEST::xyzw, BC::y, vf16, vf3); // vmadday.xyzw acc, vf16, vf3 + // nop // sll r0, r0, 0 + c->vmadd_bc(DEST::xyzw, BC::z, vf3, vf17, vf3); // vmaddz.xyzw vf3, vf17, vf3 + // nop // sll r0, r0, 0 + c->vmula_bc(DEST::xyzw, BC::w, vf18, vf0); // vmulaw.xyzw acc, vf18, vf0 + // nop // sll r0, r0, 0 + c->vmadda_bc(DEST::xyzw, BC::x, vf15, vf4); // vmaddax.xyzw acc, vf15, vf4 + // nop // sll r0, r0, 0 + c->vmadda_bc(DEST::xyzw, BC::y, vf16, vf4); // vmadday.xyzw acc, vf16, vf4 + // nop // sll r0, r0, 0 + c->vmadd_bc(DEST::xyzw, BC::z, vf4, vf17, vf4); // vmaddz.xyzw vf4, vf17, vf4 + // nop // sll r0, r0, 0 + c->vftoi0(DEST::xyzw, vf9, vf1); // vftoi0.xyzw vf9, vf1 + c->sqc2(vf1, 16, v1); // sqc2 vf1, 16(v1) + c->vftoi0(DEST::xyzw, vf10, vf2); // vftoi0.xyzw vf10, vf2 + c->sqc2(vf2, 48, v1); // sqc2 vf2, 48(v1) + c->vftoi0(DEST::xyzw, vf11, vf3); // vftoi0.xyzw vf11, vf3 + c->sqc2(vf3, 80, v1); // sqc2 vf3, 80(v1) + c->vftoi0(DEST::xyzw, vf12, vf4); // vftoi0.xyzw vf12, vf4 + c->sqc2(vf4, 112, v1); // sqc2 vf4, 112(v1) + c->vsub(DEST::xyz, vf5, vf5, vf13); // vsub.xyz vf5, vf5, vf13 + c->sqc2(vf9, 0, v1); // sqc2 vf9, 0(v1) + c->vsub(DEST::xyz, vf6, vf6, vf13); // vsub.xyz vf6, vf6, vf13 + c->sqc2(vf10, 32, v1); // sqc2 vf10, 32(v1) + c->vsub(DEST::xyz, vf7, vf7, vf13); // vsub.xyz vf7, vf7, vf13 + c->sqc2(vf11, 64, v1); // sqc2 vf11, 64(v1) + c->vsub(DEST::xyz, vf8, vf8, vf13); // vsub.xyz vf8, vf8, vf13 + c->sqc2(vf12, 96, v1); // sqc2 vf12, 96(v1) + c->vmula_bc(DEST::xyzw, BC::w, vf18, vf0); // vmulaw.xyzw acc, vf18, vf0 + // nop // sll r0, r0, 0 + bc = ((s64)c->sgpr64(a0)) <= 0; // blez a0, L295 + c->vmadda_bc(DEST::xyzw, BC::x, vf15, vf5); // vmaddax.xyzw acc, vf15, vf5 + if (bc) {goto block_8;} // branch non-likely + + c->vmadda_bc(DEST::xyzw, BC::y, vf16, vf5); // vmadday.xyzw acc, vf16, vf5 + // nop // sll r0, r0, 0 + c->vmadd_bc(DEST::xyzw, BC::z, vf5, vf17, vf5); // vmaddz.xyzw vf5, vf17, vf5 + // nop // sll r0, r0, 0 + c->vmula_bc(DEST::xyzw, BC::w, vf18, vf0); // vmulaw.xyzw acc, vf18, vf0 + // nop // sll r0, r0, 0 + c->vmadda_bc(DEST::xyzw, BC::x, vf15, vf6); // vmaddax.xyzw acc, vf15, vf6 + // nop // sll r0, r0, 0 + c->vmadda_bc(DEST::xyzw, BC::y, vf16, vf6); // vmadday.xyzw acc, vf16, vf6 + // nop // sll r0, r0, 0 + c->vmadd_bc(DEST::xyzw, BC::z, vf6, vf17, vf6); // vmaddz.xyzw vf6, vf17, vf6 + // nop // sll r0, r0, 0 + c->vmula_bc(DEST::xyzw, BC::w, vf18, vf0); // vmulaw.xyzw acc, vf18, vf0 + // nop // sll r0, r0, 0 + c->vmadda_bc(DEST::xyzw, BC::x, vf15, vf7); // vmaddax.xyzw acc, vf15, vf7 + // nop // sll r0, r0, 0 + c->vmadda_bc(DEST::xyzw, BC::y, vf16, vf7); // vmadday.xyzw acc, vf16, vf7 + // nop // sll r0, r0, 0 + c->vmadd_bc(DEST::xyzw, BC::z, vf7, vf17, vf7); // vmaddz.xyzw vf7, vf17, vf7 + c->daddiu(v1, v1, 256); // daddiu v1, v1, 256 + c->vmula_bc(DEST::xyzw, BC::w, vf18, vf0); // vmulaw.xyzw acc, vf18, vf0 + // Unknown instr: vlqi.xyz vf1, vi1 + vlqi(c, vf1); + c->vmadda_bc(DEST::xyzw, BC::x, vf15, vf8); // vmaddax.xyzw acc, vf15, vf8 + // Unknown instr: vlqi.xyz vf2, vi1 + vlqi(c, vf2); + c->vmadda_bc(DEST::xyzw, BC::y, vf16, vf8); // vmadday.xyzw acc, vf16, vf8 + // Unknown instr: vlqi.xyz vf3, vi1 + vlqi(c, vf3); + c->vmadd_bc(DEST::xyzw, BC::z, vf8, vf17, vf8); // vmaddz.xyzw vf8, vf17, vf8 + // Unknown instr: vlqi.xyz vf4, vi1 + vlqi(c, vf4); + c->vftoi0(DEST::xyzw, vf9, vf5); // vftoi0.xyzw vf9, vf5 + c->sqc2(vf5, -112, v1); // sqc2 vf5, -112(v1) + c->vftoi0(DEST::xyzw, vf10, vf6); // vftoi0.xyzw vf10, vf6 + c->sqc2(vf6, -80, v1); // sqc2 vf6, -80(v1) + c->vftoi0(DEST::xyzw, vf11, vf7); // vftoi0.xyzw vf11, vf7 + c->sqc2(vf7, -48, v1); // sqc2 vf7, -48(v1) + c->vftoi0(DEST::xyzw, vf12, vf8); // vftoi0.xyzw vf12, vf8 + c->sqc2(vf8, -16, v1); // sqc2 vf8, -16(v1) + c->daddiu(a0, a0, -4); // daddiu a0, a0, -4 + c->sqc2(vf9, -128, v1); // sqc2 vf9, -128(v1) + // nop // sll r0, r0, 0 + c->sqc2(vf10, -96, v1); // sqc2 vf10, -96(v1) + // nop // sll r0, r0, 0 + c->sqc2(vf11, -64, v1); // sqc2 vf11, -64(v1) + bc = ((s64)c->sgpr64(a0)) <= 0; // blez a0, L295 + c->sqc2(vf12, -32, v1); // sqc2 vf12, -32(v1) + if (bc) {goto block_8;} // branch non-likely + + + block_3: + c->vsub(DEST::xyz, vf1, vf1, vf13); // vsub.xyz vf1, vf1, vf13 + // Unknown instr: vlqi.xyz vf5, vi1 + vlqi(c, vf5); + c->vsub(DEST::xyz, vf2, vf2, vf13); // vsub.xyz vf2, vf2, vf13 + // Unknown instr: vlqi.xyz vf6, vi1 + vlqi(c, vf6); + c->vsub(DEST::xyz, vf3, vf3, vf13); // vsub.xyz vf3, vf3, vf13 + // Unknown instr: vlqi.xyz vf7, vi1 + vlqi(c, vf7); + c->vsub(DEST::xyz, vf4, vf4, vf13); // vsub.xyz vf4, vf4, vf13 + // Unknown instr: vlqi.xyz vf8, vi1 + vlqi(c, vf8); + c->vmula_bc(DEST::xyzw, BC::w, vf18, vf0); // vmulaw.xyzw acc, vf18, vf0 + // nop // sll r0, r0, 0 + c->vmadda_bc(DEST::xyzw, BC::x, vf15, vf1); // vmaddax.xyzw acc, vf15, vf1 + // nop // sll r0, r0, 0 + c->vmadda_bc(DEST::xyzw, BC::y, vf16, vf1); // vmadday.xyzw acc, vf16, vf1 + // nop // sll r0, r0, 0 + c->vmadd_bc(DEST::xyzw, BC::z, vf1, vf17, vf1); // vmaddz.xyzw vf1, vf17, vf1 + // nop // sll r0, r0, 0 + c->vmula_bc(DEST::xyzw, BC::w, vf18, vf0); // vmulaw.xyzw acc, vf18, vf0 + // nop // sll r0, r0, 0 + c->vmadda_bc(DEST::xyzw, BC::x, vf15, vf2); // vmaddax.xyzw acc, vf15, vf2 + // nop // sll r0, r0, 0 + c->vmadda_bc(DEST::xyzw, BC::y, vf16, vf2); // vmadday.xyzw acc, vf16, vf2 + // nop // sll r0, r0, 0 + c->vmadd_bc(DEST::xyzw, BC::z, vf2, vf17, vf2); // vmaddz.xyzw vf2, vf17, vf2 + // nop // sll r0, r0, 0 + c->vmula_bc(DEST::xyzw, BC::w, vf18, vf0); // vmulaw.xyzw acc, vf18, vf0 + // nop // sll r0, r0, 0 + c->vmadda_bc(DEST::xyzw, BC::x, vf15, vf3); // vmaddax.xyzw acc, vf15, vf3 + // nop // sll r0, r0, 0 + c->vmadda_bc(DEST::xyzw, BC::y, vf16, vf3); // vmadday.xyzw acc, vf16, vf3 + // nop // sll r0, r0, 0 + c->vmadd_bc(DEST::xyzw, BC::z, vf3, vf17, vf3); // vmaddz.xyzw vf3, vf17, vf3 + // nop // sll r0, r0, 0 + c->vmula_bc(DEST::xyzw, BC::w, vf18, vf0); // vmulaw.xyzw acc, vf18, vf0 + // nop // sll r0, r0, 0 + c->vmadda_bc(DEST::xyzw, BC::x, vf15, vf4); // vmaddax.xyzw acc, vf15, vf4 + // nop // sll r0, r0, 0 + c->vmadda_bc(DEST::xyzw, BC::y, vf16, vf4); // vmadday.xyzw acc, vf16, vf4 + // nop // sll r0, r0, 0 + c->vmadd_bc(DEST::xyzw, BC::z, vf4, vf17, vf4); // vmaddz.xyzw vf4, vf17, vf4 + // nop // sll r0, r0, 0 + c->vftoi0(DEST::xyzw, vf9, vf1); // vftoi0.xyzw vf9, vf1 + c->sqc2(vf1, 16, v1); // sqc2 vf1, 16(v1) + c->vftoi0(DEST::xyzw, vf10, vf2); // vftoi0.xyzw vf10, vf2 + c->sqc2(vf2, 48, v1); // sqc2 vf2, 48(v1) + c->vftoi0(DEST::xyzw, vf11, vf3); // vftoi0.xyzw vf11, vf3 + c->sqc2(vf3, 80, v1); // sqc2 vf3, 80(v1) + c->vftoi0(DEST::xyzw, vf12, vf4); // vftoi0.xyzw vf12, vf4 + c->sqc2(vf4, 112, v1); // sqc2 vf4, 112(v1) + c->vsub(DEST::xyz, vf5, vf5, vf13); // vsub.xyz vf5, vf5, vf13 + c->sqc2(vf9, 0, v1); // sqc2 vf9, 0(v1) + c->vsub(DEST::xyz, vf6, vf6, vf13); // vsub.xyz vf6, vf6, vf13 + c->sqc2(vf10, 32, v1); // sqc2 vf10, 32(v1) + c->vsub(DEST::xyz, vf7, vf7, vf13); // vsub.xyz vf7, vf7, vf13 + c->sqc2(vf11, 64, v1); // sqc2 vf11, 64(v1) + c->vsub(DEST::xyz, vf8, vf8, vf13); // vsub.xyz vf8, vf8, vf13 + c->sqc2(vf12, 96, v1); // sqc2 vf12, 96(v1) + c->daddiu(a0, a0, -4); // daddiu a0, a0, -4 + c->vmula_bc(DEST::xyzw, BC::w, vf18, vf0); // vmulaw.xyzw acc, vf18, vf0 + bc = ((s64)c->sgpr64(a0)) <= 0; // blez a0, L292 + c->vmadda_bc(DEST::xyzw, BC::x, vf15, vf5); // vmaddax.xyzw acc, vf15, vf5 + if (bc) {goto block_5;} // branch non-likely + + c->vmadda_bc(DEST::xyzw, BC::y, vf16, vf5); // vmadday.xyzw acc, vf16, vf5 + // nop // sll r0, r0, 0 + c->vmadd_bc(DEST::xyzw, BC::z, vf5, vf17, vf5); // vmaddz.xyzw vf5, vf17, vf5 + // nop // sll r0, r0, 0 + c->vmula_bc(DEST::xyzw, BC::w, vf18, vf0); // vmulaw.xyzw acc, vf18, vf0 + // nop // sll r0, r0, 0 + c->vmadda_bc(DEST::xyzw, BC::x, vf15, vf6); // vmaddax.xyzw acc, vf15, vf6 + // nop // sll r0, r0, 0 + c->vmadda_bc(DEST::xyzw, BC::y, vf16, vf6); // vmadday.xyzw acc, vf16, vf6 + // nop // sll r0, r0, 0 + c->vmadd_bc(DEST::xyzw, BC::z, vf6, vf17, vf6); // vmaddz.xyzw vf6, vf17, vf6 + // nop // sll r0, r0, 0 + c->vmula_bc(DEST::xyzw, BC::w, vf18, vf0); // vmulaw.xyzw acc, vf18, vf0 + // nop // sll r0, r0, 0 + c->vmadda_bc(DEST::xyzw, BC::x, vf15, vf7); // vmaddax.xyzw acc, vf15, vf7 + // nop // sll r0, r0, 0 + c->vmadda_bc(DEST::xyzw, BC::y, vf16, vf7); // vmadday.xyzw acc, vf16, vf7 + // nop // sll r0, r0, 0 + c->vmadd_bc(DEST::xyzw, BC::z, vf7, vf17, vf7); // vmaddz.xyzw vf7, vf17, vf7 + c->daddiu(v1, v1, 256); // daddiu v1, v1, 256 + c->vmula_bc(DEST::xyzw, BC::w, vf18, vf0); // vmulaw.xyzw acc, vf18, vf0 + // Unknown instr: vlqi.xyz vf1, vi1 + vlqi(c, vf1); + c->vmadda_bc(DEST::xyzw, BC::x, vf15, vf8); // vmaddax.xyzw acc, vf15, vf8 + // Unknown instr: vlqi.xyz vf2, vi1 + vlqi(c, vf2); + c->vmadda_bc(DEST::xyzw, BC::y, vf16, vf8); // vmadday.xyzw acc, vf16, vf8 + // Unknown instr: vlqi.xyz vf3, vi1 + vlqi(c, vf3); + c->vmadd_bc(DEST::xyzw, BC::z, vf8, vf17, vf8); // vmaddz.xyzw vf8, vf17, vf8 + // Unknown instr: vlqi.xyz vf4, vi1 + vlqi(c, vf4); + c->vftoi0(DEST::xyzw, vf9, vf5); // vftoi0.xyzw vf9, vf5 + c->sqc2(vf5, -112, v1); // sqc2 vf5, -112(v1) + c->vftoi0(DEST::xyzw, vf10, vf6); // vftoi0.xyzw vf10, vf6 + c->sqc2(vf6, -80, v1); // sqc2 vf6, -80(v1) + c->vftoi0(DEST::xyzw, vf11, vf7); // vftoi0.xyzw vf11, vf7 + c->sqc2(vf7, -48, v1); // sqc2 vf7, -48(v1) + c->vftoi0(DEST::xyzw, vf12, vf8); // vftoi0.xyzw vf12, vf8 + c->sqc2(vf8, -16, v1); // sqc2 vf8, -16(v1) + // nop // sll r0, r0, 0 + c->sqc2(vf9, -128, v1); // sqc2 vf9, -128(v1) + c->daddiu(a0, a0, -4); // daddiu a0, a0, -4 + c->sqc2(vf10, -96, v1); // sqc2 vf10, -96(v1) + // nop // sll r0, r0, 0 + c->sqc2(vf11, -64, v1); // sqc2 vf11, -64(v1) + bc = ((s64)c->sgpr64(a0)) > 0; // bgtz a0, L291 + c->sqc2(vf12, -32, v1); // sqc2 vf12, -32(v1) + if (bc) {goto block_3;} // branch non-likely + + + block_5: + //beq r0, r0, L295 // beq r0, r0, L295 + // nop // sll r0, r0, 0 + goto block_8; // branch always + + + block_6: + // c->lui(v1, 28672); // lui v1, 28672 + get_fake_spad_addr(v1, cache.fake_scratchpad_data, 0, c); + + c->lqc2(vf14, 12, a1); // lqc2 vf14, 12(a1) + c->vmove(DEST::xyzw, vf1, vf0); // vmove.xyzw vf1, vf0 + // c->lqc2(vf13, 0, a0); // lqc2 vf13, 0(a0) + c->vfs[vf13].du32[0] = 0x4d000000; + c->vfs[vf13].du32[1] = 0x4d000000; + c->vfs[vf13].du32[2] = 0x4d000000; + c->vfs[vf13].du32[3] = 0; + c->vmove(DEST::xyzw, vf2, vf0); // vmove.xyzw vf2, vf0 + c->lbu(a0, 24, a1); // lbu a0, 24(a1) + // Unknown instr: ctc2.i vi1, a3 + assert(c->sgpr64(a3) == 0); + vi1 = c->sgpr64(a3); + c->vmove(DEST::xyzw, vf3, vf0); // vmove.xyzw vf3, vf0 + c->vitof0(DEST::xyzw, vf14, vf14); // vitof0.xyzw vf14, vf14 + c->vmove(DEST::xyzw, vf4, vf0); // vmove.xyzw vf4, vf0 + // nop // sll r0, r0, 0 + c->vmove(DEST::xyzw, vf5, vf0); // vmove.xyzw vf5, vf0 + // nop // sll r0, r0, 0 + c->vmove(DEST::xyzw, vf6, vf0); // vmove.xyzw vf6, vf0 + // nop // sll r0, r0, 0 + c->vmove(DEST::xyzw, vf7, vf0); // vmove.xyzw vf7, vf0 + c->vsub(DEST::xyzw, vf13, vf13, vf14); // vsub.xyzw vf13, vf13, vf14 + c->vmove(DEST::xyzw, vf8, vf0); // vmove.xyzw vf8, vf0 + + block_7: + // nop // sll r0, r0, 0 + // Unknown instr: vlqi.xyz vf1, vi1 + vlqi(c, vf1); + // nop // sll r0, r0, 0 + // Unknown instr: vlqi.xyz vf2, vi1 + vlqi(c, vf2); + // nop // sll r0, r0, 0 + // Unknown instr: vlqi.xyz vf3, vi1 + vlqi(c, vf3); + c->daddiu(v1, v1, 256); // daddiu v1, v1, 256 + // Unknown instr: vlqi.xyz vf4, vi1 + vlqi(c, vf4); + c->vsub(DEST::xyz, vf1, vf1, vf13); // vsub.xyz vf1, vf1, vf13 + // Unknown instr: vlqi.xyz vf5, vi1 + vlqi(c, vf5); + c->vsub(DEST::xyz, vf2, vf2, vf13); // vsub.xyz vf2, vf2, vf13 + // Unknown instr: vlqi.xyz vf6, vi1 + vlqi(c, vf6); + c->vsub(DEST::xyz, vf3, vf3, vf13); // vsub.xyz vf3, vf3, vf13 + // Unknown instr: vlqi.xyz vf7, vi1 + vlqi(c, vf7); + c->vsub(DEST::xyz, vf4, vf4, vf13); // vsub.xyz vf4, vf4, vf13 + // Unknown instr: vlqi.xyz vf8, vi1 + vlqi(c, vf8); + c->vftoi0(DEST::xyzw, vf9, vf1); // vftoi0.xyzw vf9, vf1 + c->sqc2(vf1, -240, v1); // sqc2 vf1, -240(v1) + c->vftoi0(DEST::xyzw, vf10, vf2); // vftoi0.xyzw vf10, vf2 + c->sqc2(vf2, -208, v1); // sqc2 vf2, -208(v1) + c->vftoi0(DEST::xyzw, vf11, vf3); // vftoi0.xyzw vf11, vf3 + c->sqc2(vf3, -176, v1); // sqc2 vf3, -176(v1) + c->vftoi0(DEST::xyzw, vf12, vf4); // vftoi0.xyzw vf12, vf4 + c->sqc2(vf4, -144, v1); // sqc2 vf4, -144(v1) + c->vsub(DEST::xyz, vf5, vf5, vf13); // vsub.xyz vf5, vf5, vf13 + c->sqc2(vf9, -256, v1); // sqc2 vf9, -256(v1) + c->vsub(DEST::xyz, vf6, vf6, vf13); // vsub.xyz vf6, vf6, vf13 + c->sqc2(vf10, -224, v1); // sqc2 vf10, -224(v1) + c->vsub(DEST::xyz, vf7, vf7, vf13); // vsub.xyz vf7, vf7, vf13 + c->sqc2(vf11, -192, v1); // sqc2 vf11, -192(v1) + c->vsub(DEST::xyz, vf8, vf8, vf13); // vsub.xyz vf8, vf8, vf13 + c->sqc2(vf12, -160, v1); // sqc2 vf12, -160(v1) + c->vftoi0(DEST::xyzw, vf9, vf5); // vftoi0.xyzw vf9, vf5 + c->sqc2(vf5, -112, v1); // sqc2 vf5, -112(v1) + c->vftoi0(DEST::xyzw, vf10, vf6); // vftoi0.xyzw vf10, vf6 + c->sqc2(vf6, -80, v1); // sqc2 vf6, -80(v1) + c->vftoi0(DEST::xyzw, vf11, vf7); // vftoi0.xyzw vf11, vf7 + c->sqc2(vf7, -48, v1); // sqc2 vf7, -48(v1) + c->vftoi0(DEST::xyzw, vf12, vf8); // vftoi0.xyzw vf12, vf8 + c->sqc2(vf8, -16, v1); // sqc2 vf8, -16(v1) + // nop // sll r0, r0, 0 + c->sqc2(vf9, -128, v1); // sqc2 vf9, -128(v1) + c->daddiu(a0, a0, -8); // daddiu a0, a0, -8 + c->sqc2(vf10, -96, v1); // sqc2 vf10, -96(v1) + // nop // sll r0, r0, 0 + c->sqc2(vf11, -64, v1); // sqc2 vf11, -64(v1) + bc = ((s64)c->sgpr64(a0)) > 0; // bgtz a0, L294 + c->sqc2(vf12, -32, v1); // sqc2 vf12, -32(v1) + if (bc) {goto block_7;} // branch non-likely + + + block_8: + c->gprs[v0].du64[0] = 0; // or v0, r0, r0 + c->ld(fp, 8, sp); // ld fp, 8(sp) + //jr ra // jr ra + c->daddiu(sp, sp, 16); // daddiu sp, sp, 16 + goto end_of_function; // return + + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + end_of_function: + return c->gprs[v0].du64[0]; +} + +void link() { + cache.fake_scratchpad_data = intern_from_c("*fake-scratchpad-data*").c(); + gLinkedFunctionTable.reg("(method 32 collide-cache)", execute, 128); +} + +} // namespace method_32_collide_cache +} // namespace Mips2C + + +namespace Mips2C { + +// clip by box +namespace method_26_collide_cache { +struct Cache { + void* already_printed_exeeded_max_cache_tris; // *already-printed-exeeded-max-cache-tris* + void* cheat_mode; // *cheat-mode* + void* stdcon; // *stdcon* + void* debug; // debug + void* format; // format + void* fake_scratchpad_data; // *fake-scratchpad-data* +} cache; + + +u64 execute(void* ctxt) { + auto* c = (ExecutionContext*)ctxt; + bool bc = false; + u32 call_addr = 0; + c->daddiu(sp, sp, -112); // daddiu sp, sp, -112 + c->sd(ra, 0, sp); // sd ra, 0(sp) + c->sd(fp, 8, sp); // sd fp, 8(sp) + c->mov64(fp, t9); // or fp, t9, r0 + c->sq(s1, 16, sp); // sq s1, 16(sp) + c->sq(s2, 32, sp); // sq s2, 32(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) + // nop // sll r0, r0, 0 + c->addiu(v1, r0, 460); // addiu v1, r0, 460 + c->lwu(a2, 0, a0); // lwu a2, 0(a0) + c->dsubu(t0, v1, a2); // dsubu t0, v1, a2 + c->addiu(a3, r0, 64); // addiu a3, r0, 64 + c->mult3(a3, a2, a3); // mult3 a3, a2, a3 + bc = ((s64)c->sgpr64(t0)) < 0; // bltz t0, L249 + c->mov64(t0, a0); // or t0, a0, r0 + if (bc) {goto block_17;} // branch non-likely + + // nop // sll r0, r0, 0 + c->lbu(t2, 25, a1); // lbu t2, 25(a1) + c->daddiu(t0, t0, 4908); // daddiu t0, t0, 4908 + c->lwu(t1, 0, a1); // lwu t1, 0(a1) + c->dsll(t2, t2, 4); // dsll t2, t2, 4 + c->lhu(t3, 8, a1); // lhu t3, 8(a1) + c->daddu(a3, t0, a3); // daddu a3, t0, a3 + c->lq(t0, 60, a0); // lq t0, 60(a0) + c->daddu(t1, t1, t2); // daddu t1, t1, t2 + c->lq(t2, 76, a0); // lq t2, 76(a0) + // nop // sll r0, r0, 0 + c->lwu(a1, 4, a1); // lwu a1, 4(a1) + c->daddu(t3, t1, t3); // daddu t3, t1, t3 + c->lwu(t4, 8, a0); // lwu t4, 8(a0) + + block_2: + // c->lui(t5, 28672); // lui t5, 28672 + get_fake_spad_addr(t5, cache.fake_scratchpad_data, 0, c); + c->lb(t7, 0, t1); // lb t7, 0(t1) + // nop // sll r0, r0, 0 + c->lb(t8, 1, t1); // lb t8, 1(t1) + bc = ((s64)c->sgpr64(t7)) < 0; // bltz t7, L248 + c->lb(t6, 2, t1); // lb t6, 2(t1) + if (bc) {goto block_16;} // branch non-likely + + c->dsll(t7, t7, 5); // dsll t7, t7, 5 + c->dsll(t8, t8, 5); // dsll t8, t8, 5 + c->dsll(t9, t6, 5); // dsll t9, t6, 5 + c->daddu(t6, t7, t5); // daddu t6, t7, t5 + c->daddu(t7, t8, t5); // daddu t7, t8, t5 + c->lq(t8, 0, t6); // lq t8, 0(t6) + c->daddu(ra, t9, t5); // daddu ra, t9, t5 + c->lq(t9, 0, t7); // lq t9, 0(t7) + c->pminw(s4, t8, t9); // pminw s4, t8, t9 + c->lq(gp, 0, ra); // lq gp, 0(ra) + c->pmaxw(s5, t8, t9); // pmaxw s5, t8, t9 + c->mfc1(r0, f31); // mfc1 r0, f31 + c->pminw(s4, s4, gp); // pminw s4, s4, gp + c->mfc1(r0, f31); // mfc1 r0, f31 + c->pmaxw(s5, s5, gp); // pmaxw s5, s5, gp + c->mfc1(r0, f31); // mfc1 r0, f31 + c->pcgtw(s4, s4, t2); // pcgtw s4, s4, t2 + c->mfc1(r0, f31); // mfc1 r0, f31 + c->pcgtw(s5, t0, s5); // pcgtw s5, t0, s5 + c->mfc1(r0, f31); // mfc1 r0, f31 + c->por(s4, s4, s5); // por s4, s4, s5 + c->lbu(s5, 0, t3); // lbu s5, 0(t3) + c->ppach(s4, r0, s4); // ppach s4, r0, s4 + c->mfc1(r0, f31); // mfc1 r0, f31 + c->dsll(s4, s4, 16); // dsll s4, s4, 16 + c->dsll(s5, s5, 2); // dsll s5, s5, 2 + bc = c->sgpr64(s4) != 0; // bne s4, r0, L245 + c->daddu(s5, s5, a1); // daddu s5, s5, a1 + if (bc) {goto block_7;} // branch non-likely + + bc = c->sgpr64(a2) == c->sgpr64(v1); // beq a2, v1, L249 + c->lwu(s5, 0, s5); // lwu s5, 0(s5) + if (bc) {goto block_17;} // branch non-likely + + c->and_(s4, s5, t4); // and s4, s5, t4 + // nop // sll r0, r0, 0 + bc = c->sgpr64(s4) != 0; // bne s4, r0, L245 + // nop // sll r0, r0, 0 + if (bc) {goto block_7;} // branch non-likely + + // nop // sll r0, r0, 0 + c->sq(r0, 48, a3); // sq r0, 48(a3) + c->daddiu(a2, a2, 1); // daddiu a2, a2, 1 + c->sw(s5, 48, a3); // sw s5, 48(a3) + c->daddiu(a3, a3, 64); // daddiu a3, a3, 64 + c->lq(s5, 16, t6); // lq s5, 16(t6) + // nop // sll r0, r0, 0 + c->lq(s4, 16, t7); // lq s4, 16(t7) + // nop // sll r0, r0, 0 + c->lq(s3, 16, ra); // lq s3, 16(ra) + // nop // sll r0, r0, 0 + c->sq(s5, -64, a3); // sq s5, -64(a3) + // nop // sll r0, r0, 0 + c->sq(s4, -48, a3); // sq s4, -48(a3) + // nop // sll r0, r0, 0 + c->sq(s3, -32, a3); // sq s3, -32(a3) + + block_7: + c->daddiu(t3, t3, 1); // daddiu t3, t3, 1 + c->daddiu(t1, t1, 3); // daddiu t1, t1, 3 + c->addiu(s5, r0, 16); // addiu s5, r0, 16 + // nop // sll r0, r0, 0 + + block_8: + // nop // sll r0, r0, 0 + c->lb(s4, 0, t1); // lb s4, 0(t1) + c->daddiu(t1, t1, 1); // daddiu t1, t1, 1 + // nop // sll r0, r0, 0 + bc = c->sgpr64(s4) == 0; // beq s4, r0, L244 + // nop // sll r0, r0, 0 + if (bc) {goto block_2;} // branch non-likely + + if (((s64)c->sgpr64(s4)) < 0) { // bltzl s4, L247 + c->dsubu(s4, r0, s4); // dsubu s4, r0, s4 + goto block_12; + } + + // block_11: + c->mov128_gpr_gpr(t8, t9); // por t8, t9, r0 + c->mov64(t6, t7); // or t6, t7, r0 + c->dsubu(s5, r0, s5); // dsubu s5, r0, s5 + // nop // sll r0, r0, 0 + + block_12: + c->daddiu(s4, s4, -1); // daddiu s4, s4, -1 + c->mov64(t7, ra); // or t7, ra, r0 + c->mov128_gpr_gpr(t9, gp); // por t9, gp, r0 + c->dsll(ra, s4, 5); // dsll ra, s4, 5 + c->daddu(ra, ra, t5); // daddu ra, ra, t5 + c->lbu(s4, 0, t3); // lbu s4, 0(t3) + c->pminw(s2, t8, t9); // pminw s2, t8, t9 + c->lq(gp, 0, ra); // lq gp, 0(ra) + c->pmaxw(s3, t8, t9); // pmaxw s3, t8, t9 + c->mfc1(r0, f31); // mfc1 r0, f31 + c->pminw(s2, s2, gp); // pminw s2, s2, gp + c->mfc1(r0, f31); // mfc1 r0, f31 + c->pmaxw(s3, s3, gp); // pmaxw s3, s3, gp + c->mfc1(r0, f31); // mfc1 r0, f31 + c->pcgtw(s2, s2, t2); // pcgtw s2, s2, t2 + c->mfc1(r0, f31); // mfc1 r0, f31 + c->pcgtw(s3, t0, s3); // pcgtw s3, t0, s3 + c->mfc1(r0, f31); // mfc1 r0, f31 + c->por(s3, s2, s3); // por s3, s2, s3 + c->mfc1(r0, f31); // mfc1 r0, f31 + c->ppach(s3, r0, s3); // ppach s3, r0, s3 + c->mfc1(r0, f31); // mfc1 r0, f31 + c->dsll(s3, s3, 16); // dsll s3, s3, 16 + c->dsll(s4, s4, 2); // dsll s4, s4, 2 + bc = c->sgpr64(s3) != 0; // bne s3, r0, L246 + c->daddiu(t3, t3, 1); // daddiu t3, t3, 1 + if (bc) {goto block_8;} // branch non-likely + + c->daddu(s4, s4, a1); // daddu s4, s4, a1 + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + c->lwu(s4, 0, s4); // lwu s4, 0(s4) + c->and_(s3, s4, t4); // and s3, s4, t4 + // nop // sll r0, r0, 0 + bc = c->sgpr64(s3) != 0; // bne s3, r0, L246 + // nop // sll r0, r0, 0 + if (bc) {goto block_8;} // branch non-likely + + bc = c->sgpr64(a2) == c->sgpr64(v1); // beq a2, v1, L249 + // nop // sll r0, r0, 0 + if (bc) {goto block_17;} // branch non-likely + + // nop // sll r0, r0, 0 + c->sq(r0, 48, a3); // sq r0, 48(a3) + c->daddiu(a2, a2, 1); // daddiu a2, a2, 1 + c->sw(s4, 48, a3); // sw s4, 48(a3) + c->daddiu(s2, a3, 16); // daddiu s2, a3, 16 + c->lq(s1, 16, t7); // lq s1, 16(t7) + c->daddiu(a3, a3, 64); // daddiu a3, a3, 64 + c->lq(s4, 16, t6); // lq s4, 16(t6) + // nop // sll r0, r0, 0 + c->lq(s3, 16, ra); // lq s3, 16(ra) + // nop // sll r0, r0, 0 + c->sq(s1, 0, s2); // sq s1, 0(s2) + c->dsubu(s1, s2, s5); // dsubu s1, s2, s5 + c->daddu(s2, s2, s5); // daddu s2, s2, s5 + // nop // sll r0, r0, 0 + c->sq(s4, 0, s1); // sq s4, 0(s1) + //beq r0, r0, L246 // beq r0, r0, L246 + c->sq(s3, 0, s2); // sq s3, 0(s2) + goto block_8; // branch always + + + block_16: + // nop // sll r0, r0, 0 + c->sw(a2, 0, a0); // sw a2, 0(a0) + //beq r0, r0, L251 // beq r0, r0, L251 + // nop // sll r0, r0, 0 + goto block_21; // branch always + + + block_17: + // nop // sll r0, r0, 0 + c->sw(v1, 0, a0); // sw v1, 0(a0) + c->load_symbol(v1, cache.already_printed_exeeded_max_cache_tris);// lw v1, *already-printed-exeeded-max-cache-tris*(s7) + bc = c->sgpr64(s7) != c->sgpr64(v1); // bne s7, v1, L250 + c->mov64(v1, s7); // or v1, s7, r0 + if (bc) {goto block_20;} // branch non-likely + + c->daddiu(v1, s7, 8); // daddiu v1, s7, #t + //c->store_symbol(v1, cache.already_printed_exeeded_max_cache_tris);// sw v1, *already-printed-exeeded-max-cache-tris*(s7) + //c->load_symbol_addr(v1, cache.debug); // daddiu v1, s7, debug + c->load_symbol(a0, cache.cheat_mode); // lw a0, *cheat-mode*(s7) + bc = c->sgpr64(a0) != c->sgpr64(v1); // bne a0, v1, L250 + c->mov64(v1, s7); // or v1, s7, r0 + if (bc) {goto block_20;} // branch non-likely + + c->load_symbol(t9, cache.format); // lw t9, format(s7) + c->load_symbol(a0, cache.stdcon); // lw a0, *stdcon*(s7) + //daddiu a1, fp, L305 // daddiu a1, fp, L305 + 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 + printf("exceeded maximum collide cache tris (should print on screen but too lazy for that now)\n"); + c->mov64(v1, v0); // or v1, v0, r0 + + block_20: + //beq r0, r0, L251 // beq r0, r0, L251 + // nop // sll r0, r0, 0 + goto block_21; // branch always + + + block_21: + c->gprs[v0].du64[0] = 0; // or v0, r0, r0 + c->ld(ra, 0, sp); // ld ra, 0(sp) + c->ld(fp, 8, sp); // ld fp, 8(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) + c->lq(s2, 32, sp); // lq s2, 32(sp) + c->lq(s1, 16, sp); // lq s1, 16(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.already_printed_exeeded_max_cache_tris = intern_from_c("*already-printed-exeeded-max-cache-tris*").c(); + cache.cheat_mode = intern_from_c("*cheat-mode*").c(); + cache.stdcon = intern_from_c("*stdcon*").c(); + cache.debug = intern_from_c("debug").c(); + cache.format = intern_from_c("format").c(); + cache.fake_scratchpad_data = intern_from_c("*fake-scratchpad-data*").c(); + gLinkedFunctionTable.reg("(method 26 collide-cache)", execute, 512); +} + +} // namespace method_26_collide_cache +} // namespace Mips2C + +//--------------------------MIPS2C--------------------- +#include "game/mips2c/mips2c_private.h" +#include "game/kernel/kscheme.h" +namespace Mips2C { +namespace method_28_collide_cache { +struct Cache { + void* already_printed_exeeded_max_cache_tris; // *already-printed-exeeded-max-cache-tris* + void* cheat_mode; // *cheat-mode* + void* stdcon; // *stdcon* + void* debug; // debug + void* format; // format + void* fake_scratchpad_data; +} cache; + +u64 execute(void* ctxt) { + auto* c = (ExecutionContext*)ctxt; + bool bc = false; + u32 call_addr = 0; + c->daddiu(sp, sp, -112); // daddiu sp, sp, -112 + c->sd(ra, 0, sp); // sd ra, 0(sp) + c->sd(fp, 8, sp); // sd fp, 8(sp) + c->mov64(fp, t9); // or fp, t9, r0 + c->sq(s1, 16, sp); // sq s1, 16(sp) + c->sq(s2, 32, sp); // sq s2, 32(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) + // nop // sll r0, r0, 0 + c->addiu(v1, r0, 460); // addiu v1, r0, 460 + c->lwu(a2, 0, a0); // lwu a2, 0(a0) + c->dsubu(t0, v1, a2); // dsubu t0, v1, a2 + c->addiu(a3, r0, 64); // addiu a3, r0, 64 + c->mult3(a3, a2, a3); // mult3 a3, a2, a3 + bc = ((s64)c->sgpr64(t0)) < 0; // bltz t0, L222 + c->mov64(t0, a0); // or t0, a0, r0 + if (bc) {goto block_17;} // branch non-likely + + // nop // sll r0, r0, 0 + c->lbu(t2, 25, a1); // lbu t2, 25(a1) + c->daddiu(t0, t0, 4908); // daddiu t0, t0, 4908 + c->lwu(t1, 0, a1); // lwu t1, 0(a1) + c->dsll(t2, t2, 4); // dsll t2, t2, 4 + c->lhu(t3, 8, a1); // lhu t3, 8(a1) + c->daddu(a3, t0, a3); // daddu a3, t0, a3 + c->lq(t0, 60, a0); // lq t0, 60(a0) + c->daddu(t1, t1, t2); // daddu t1, t1, t2 + c->lq(t2, 76, a0); // lq t2, 76(a0) + // nop // sll r0, r0, 0 + c->lwu(a1, 4, a1); // lwu a1, 4(a1) + c->daddu(t3, t1, t3); // daddu t3, t1, t3 + c->lwu(t4, 8, a0); // lwu t4, 8(a0) + + block_2: + // c->lui(t5, 28672); // lui t5, 28672 + get_fake_spad_addr(t5, cache.fake_scratchpad_data, 0, c); + c->lb(t7, 0, t1); // lb t7, 0(t1) + // nop // sll r0, r0, 0 + c->lb(t8, 1, t1); // lb t8, 1(t1) + bc = ((s64)c->sgpr64(t7)) < 0; // bltz t7, L221 + c->lb(t6, 2, t1); // lb t6, 2(t1) + if (bc) {goto block_16;} // branch non-likely + + c->dsll(t7, t7, 5); // dsll t7, t7, 5 + c->dsll(t8, t8, 5); // dsll t8, t8, 5 + c->dsll(t9, t6, 5); // dsll t9, t6, 5 + c->daddu(t6, t7, t5); // daddu t6, t7, t5 + c->daddu(t7, t8, t5); // daddu t7, t8, t5 + c->lq(t8, 0, t6); // lq t8, 0(t6) + c->daddu(ra, t9, t5); // daddu ra, t9, t5 + c->lq(t9, 0, t7); // lq t9, 0(t7) + c->pminw(s4, t8, t9); // pminw s4, t8, t9 + c->lq(gp, 0, ra); // lq gp, 0(ra) + c->pmaxw(s5, t8, t9); // pmaxw s5, t8, t9 + c->mfc1(r0, f31); // mfc1 r0, f31 + c->pminw(s4, s4, gp); // pminw s4, s4, gp + c->mfc1(r0, f31); // mfc1 r0, f31 + c->pmaxw(s5, s5, gp); // pmaxw s5, s5, gp + c->mfc1(r0, f31); // mfc1 r0, f31 + c->pcgtw(s4, s4, t2); // pcgtw s4, s4, t2 + c->mfc1(r0, f31); // mfc1 r0, f31 + c->pcgtw(s5, t0, s5); // pcgtw s5, t0, s5 + c->mfc1(r0, f31); // mfc1 r0, f31 + c->por(s4, s4, s5); // por s4, s4, s5 + c->lbu(s5, 0, t3); // lbu s5, 0(t3) + c->ppach(s4, r0, s4); // ppach s4, r0, s4 + c->mfc1(r0, f31); // mfc1 r0, f31 + c->dsll(s4, s4, 16); // dsll s4, s4, 16 + c->dsll(s5, s5, 2); // dsll s5, s5, 2 + bc = c->sgpr64(s4) != 0; // bne s4, r0, L218 + c->daddu(s5, s5, a1); // daddu s5, s5, a1 + if (bc) {goto block_7;} // branch non-likely + + bc = c->sgpr64(a2) == c->sgpr64(v1); // beq a2, v1, L222 + c->lwu(s5, 0, s5); // lwu s5, 0(s5) + if (bc) {goto block_17;} // branch non-likely + + c->and_(s4, s5, t4); // and s4, s5, t4 + // nop // sll r0, r0, 0 + bc = c->sgpr64(s4) != 0; // bne s4, r0, L218 + // nop // sll r0, r0, 0 + if (bc) {goto block_7;} // branch non-likely + + // nop // sll r0, r0, 0 + c->sq(r0, 48, a3); // sq r0, 48(a3) + c->daddiu(a2, a2, 1); // daddiu a2, a2, 1 + c->sw(s5, 48, a3); // sw s5, 48(a3) + c->daddiu(a3, a3, 64); // daddiu a3, a3, 64 + c->lq(s5, 16, t6); // lq s5, 16(t6) + // nop // sll r0, r0, 0 + c->lq(s4, 16, t7); // lq s4, 16(t7) + // nop // sll r0, r0, 0 + c->lq(s3, 16, ra); // lq s3, 16(ra) + // nop // sll r0, r0, 0 + c->sq(s5, -64, a3); // sq s5, -64(a3) + // nop // sll r0, r0, 0 + c->sq(s4, -48, a3); // sq s4, -48(a3) + // nop // sll r0, r0, 0 + c->sq(s3, -32, a3); // sq s3, -32(a3) + + block_7: + c->daddiu(t3, t3, 1); // daddiu t3, t3, 1 + c->daddiu(t1, t1, 3); // daddiu t1, t1, 3 + c->addiu(s5, r0, 16); // addiu s5, r0, 16 + // nop // sll r0, r0, 0 + + block_8: + // nop // sll r0, r0, 0 + c->lb(s4, 0, t1); // lb s4, 0(t1) + c->daddiu(t1, t1, 1); // daddiu t1, t1, 1 + // nop // sll r0, r0, 0 + bc = c->sgpr64(s4) == 0; // beq s4, r0, L217 + // nop // sll r0, r0, 0 + if (bc) {goto block_2;} // branch non-likely + + if (((s64)c->sgpr64(s4)) < 0) { // bltzl s4, L220 + c->dsubu(s4, r0, s4); // dsubu s4, r0, s4 + goto block_12; + } + + // block_11: + c->mov128_gpr_gpr(t8, t9); // por t8, t9, r0 + c->mov64(t6, t7); // or t6, t7, r0 + c->dsubu(s5, r0, s5); // dsubu s5, r0, s5 + // nop // sll r0, r0, 0 + + block_12: + c->daddiu(s4, s4, -1); // daddiu s4, s4, -1 + c->mov64(t7, ra); // or t7, ra, r0 + c->mov128_gpr_gpr(t9, gp); // por t9, gp, r0 + c->dsll(ra, s4, 5); // dsll ra, s4, 5 + c->daddu(ra, ra, t5); // daddu ra, ra, t5 + c->lbu(s4, 0, t3); // lbu s4, 0(t3) + c->pminw(s2, t8, t9); // pminw s2, t8, t9 + c->lq(gp, 0, ra); // lq gp, 0(ra) + c->pmaxw(s3, t8, t9); // pmaxw s3, t8, t9 + c->mfc1(r0, f31); // mfc1 r0, f31 + c->pminw(s2, s2, gp); // pminw s2, s2, gp + c->mfc1(r0, f31); // mfc1 r0, f31 + c->pmaxw(s3, s3, gp); // pmaxw s3, s3, gp + c->mfc1(r0, f31); // mfc1 r0, f31 + c->pcgtw(s2, s2, t2); // pcgtw s2, s2, t2 + c->mfc1(r0, f31); // mfc1 r0, f31 + c->pcgtw(s3, t0, s3); // pcgtw s3, t0, s3 + c->mfc1(r0, f31); // mfc1 r0, f31 + c->por(s3, s2, s3); // por s3, s2, s3 + c->mfc1(r0, f31); // mfc1 r0, f31 + c->ppach(s3, r0, s3); // ppach s3, r0, s3 + c->mfc1(r0, f31); // mfc1 r0, f31 + c->dsll(s3, s3, 16); // dsll s3, s3, 16 + c->dsll(s4, s4, 2); // dsll s4, s4, 2 + bc = c->sgpr64(s3) != 0; // bne s3, r0, L219 + c->daddiu(t3, t3, 1); // daddiu t3, t3, 1 + if (bc) {goto block_8;} // branch non-likely + + c->daddu(s4, s4, a1); // daddu s4, s4, a1 + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + c->lwu(s4, 0, s4); // lwu s4, 0(s4) + c->and_(s3, s4, t4); // and s3, s4, t4 + // nop // sll r0, r0, 0 + bc = c->sgpr64(s3) != 0; // bne s3, r0, L219 + // nop // sll r0, r0, 0 + if (bc) {goto block_8;} // branch non-likely + + bc = c->sgpr64(a2) == c->sgpr64(v1); // beq a2, v1, L222 + // nop // sll r0, r0, 0 + if (bc) {goto block_17;} // branch non-likely + + // nop // sll r0, r0, 0 + c->sq(r0, 48, a3); // sq r0, 48(a3) + c->daddiu(a2, a2, 1); // daddiu a2, a2, 1 + c->sw(s4, 48, a3); // sw s4, 48(a3) + c->daddiu(s2, a3, 16); // daddiu s2, a3, 16 + c->lq(s1, 16, t7); // lq s1, 16(t7) + c->daddiu(a3, a3, 64); // daddiu a3, a3, 64 + c->lq(s4, 16, t6); // lq s4, 16(t6) + // nop // sll r0, r0, 0 + c->lq(s3, 16, ra); // lq s3, 16(ra) + // nop // sll r0, r0, 0 + c->sq(s1, 0, s2); // sq s1, 0(s2) + c->dsubu(s1, s2, s5); // dsubu s1, s2, s5 + c->daddu(s2, s2, s5); // daddu s2, s2, s5 + // nop // sll r0, r0, 0 + c->sq(s4, 0, s1); // sq s4, 0(s1) + //beq r0, r0, L219 // beq r0, r0, L219 + c->sq(s3, 0, s2); // sq s3, 0(s2) + goto block_8; // branch always + + + block_16: + // nop // sll r0, r0, 0 + c->sw(a2, 0, a0); // sw a2, 0(a0) + //beq r0, r0, L224 // beq r0, r0, L224 + // nop // sll r0, r0, 0 + goto block_21; // branch always + + + block_17: + // nop // sll r0, r0, 0 + c->sw(v1, 0, a0); // sw v1, 0(a0) + c->load_symbol(v1, cache.already_printed_exeeded_max_cache_tris);// lw v1, *already-printed-exeeded-max-cache-tris*(s7) + bc = c->sgpr64(s7) != c->sgpr64(v1); // bne s7, v1, L223 + c->mov64(v1, s7); // or v1, s7, r0 + if (bc) {goto block_20;} // branch non-likely + + c->daddiu(v1, s7, 8); // daddiu v1, s7, #t + //c->store_symbol(v1, cache.already_printed_exeeded_max_cache_tris);// sw v1, *already-printed-exeeded-max-cache-tris*(s7) + //c->load_symbol_addr(v1, cache.debug); // daddiu v1, s7, debug + c->load_symbol(a0, cache.cheat_mode); // lw a0, *cheat-mode*(s7) + bc = c->sgpr64(a0) != c->sgpr64(v1); // bne a0, v1, L223 + c->mov64(v1, s7); // or v1, s7, r0 + if (bc) {goto block_20;} // branch non-likely + + c->load_symbol(t9, cache.format); // lw t9, format(s7) + c->load_symbol(a0, cache.stdcon); // lw a0, *stdcon*(s7) + //daddiu a1, fp, L305 // daddiu a1, fp, L305 + 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 + printf("exceeded maximum collide cache tris (should print on screen but too lazy for that now)\n"); + c->mov64(v1, v0); // or v1, v0, r0 + + block_20: + //beq r0, r0, L224 // beq r0, r0, L224 + // nop // sll r0, r0, 0 + goto block_21; // branch always + + + block_21: + c->gprs[v0].du64[0] = 0; // or v0, r0, r0 + c->ld(ra, 0, sp); // ld ra, 0(sp) + c->ld(fp, 8, sp); // ld fp, 8(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) + c->lq(s2, 32, sp); // lq s2, 32(sp) + c->lq(s1, 16, sp); // lq s1, 16(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.already_printed_exeeded_max_cache_tris = intern_from_c("*already-printed-exeeded-max-cache-tris*").c(); + cache.cheat_mode = intern_from_c("*cheat-mode*").c(); + cache.stdcon = intern_from_c("*stdcon*").c(); + cache.debug = intern_from_c("debug").c(); + cache.format = intern_from_c("format").c(); + cache.fake_scratchpad_data = intern_from_c("*fake-scratchpad-data*").c(); + gLinkedFunctionTable.reg("(method 28 collide-cache)", execute, 512); +} + +} // namespace method_28_collide_cache +} // namespace Mips2C + +//--------------------------MIPS2C--------------------- +#include "game/mips2c/mips2c_private.h" +#include "game/kernel/kscheme.h" +namespace Mips2C { +namespace method_27_collide_cache { +struct Cache { + void* already_printed_exeeded_max_cache_tris; // *already-printed-exeeded-max-cache-tris* + void* cheat_mode; // *cheat-mode* + void* collide_work; // *collide-work* + void* stdcon; // *stdcon* + void* debug; // debug + void* format; // format + void* fake_scratchpad_data; +} cache; + +u64 execute(void* ctxt) { + auto* c = (ExecutionContext*)ctxt; + bool bc = false; + u32 call_addr = 0; + c->daddiu(sp, sp, -112); // daddiu sp, sp, -112 + c->sd(ra, 0, sp); // sd ra, 0(sp) + c->sd(fp, 8, sp); // sd fp, 8(sp) + c->mov64(fp, t9); // or fp, t9, r0 + c->sq(s1, 16, sp); // sq s1, 16(sp) + c->sq(s2, 32, sp); // sq s2, 32(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(gp, a0); // or gp, a0, r0 + c->mov64(s5, a1); // or s5, a1, r0 + c->mov64(a0, gp); // or a0, gp, r0 + c->lwu(v1, -4, a0); // lwu v1, -4(a0) + c->lwu(t9, 132, v1); // lwu t9, 132(v1) + c->mov64(a1, s5); // or a1, s5, r0 + call_addr = c->gprs[t9].du32[0]; // function call: + c->sll(v0, ra, 0); // sll v0, ra, 0 + c->jalr(call_addr); // jalr ra, t9 + c->mov64(v1, v0); // or v1, v0, r0 + // nop // sll r0, r0, 0 + c->load_symbol(t0, cache.collide_work); // lw t0, *collide-work*(s7) + c->addiu(v1, r0, 460); // addiu v1, r0, 460 + c->lwu(a0, 0, gp); // lwu a0, 0(gp) + c->dsubu(a2, v1, a0); // dsubu a2, v1, a0 + c->dsll(a1, a0, 6); // dsll a1, a0, 6 + bc = ((s64)c->sgpr64(a2)) < 0; // bltz a2, L179 + c->mov64(a2, gp); // or a2, gp, r0 + if (bc) {goto block_17;} // branch non-likely + + // nop // sll r0, r0, 0 + c->lbu(t1, 25, s5); // lbu t1, 25(s5) + c->daddiu(a2, a2, 4908); // daddiu a2, a2, 4908 + c->lwu(a3, 0, s5); // lwu a3, 0(s5) + c->dsll(t1, t1, 4); // dsll t1, t1, 4 + c->lhu(t2, 8, s5); // lhu t2, 8(s5) + c->daddu(a1, a2, a1); // daddu a1, a2, a1 + c->lq(a2, 16, t0); // lq a2, 16(t0) + c->daddu(a3, a3, t1); // daddu a3, a3, t1 + c->lq(t0, 32, t0); // lq t0, 32(t0) + // nop // sll r0, r0, 0 + c->lwu(t1, 4, s5); // lwu t1, 4(s5) + c->daddu(t2, a3, t2); // daddu t2, a3, t2 + c->lwu(t3, 8, gp); // lwu t3, 8(gp) + + block_2: + // c->lui(t4, 28672); // lui t4, 28672 + get_fake_spad_addr(t4, cache.fake_scratchpad_data, 0, c); + c->lb(t6, 0, a3); // lb t6, 0(a3) + // nop // sll r0, r0, 0 + c->lb(t7, 1, a3); // lb t7, 1(a3) + bc = ((s64)c->sgpr64(t6)) < 0; // bltz t6, L178 + c->lb(t5, 2, a3); // lb t5, 2(a3) + if (bc) {goto block_16;} // branch non-likely + + c->dsll(t6, t6, 5); // dsll t6, t6, 5 + c->dsll(t7, t7, 5); // dsll t7, t7, 5 + c->dsll(t8, t5, 5); // dsll t8, t5, 5 + c->daddu(t5, t6, t4); // daddu t5, t6, t4 + c->daddu(t6, t7, t4); // daddu t6, t7, t4 + c->lq(t7, 4096, t5); // lq t7, 4096(t5) + c->daddu(t9, t8, t4); // daddu t9, t8, t4 + c->lq(t8, 4096, t6); // lq t8, 4096(t6) + c->pminw(s4, t7, t8); // pminw s4, t7, t8 + c->lq(ra, 4096, t9); // lq ra, 4096(t9) + c->pmaxw(s5, t7, t8); // pmaxw s5, t7, t8 + c->mfc1(r0, f31); // mfc1 r0, f31 + c->pminw(s4, s4, ra); // pminw s4, s4, ra + c->mfc1(r0, f31); // mfc1 r0, f31 + c->pmaxw(s5, s5, ra); // pmaxw s5, s5, ra + c->mfc1(r0, f31); // mfc1 r0, f31 + c->pcgtw(s4, s4, t0); // pcgtw s4, s4, t0 + c->mfc1(r0, f31); // mfc1 r0, f31 + c->pcgtw(s5, a2, s5); // pcgtw s5, a2, s5 + c->mfc1(r0, f31); // mfc1 r0, f31 + c->por(s4, s4, s5); // por s4, s4, s5 + c->lbu(s5, 0, t2); // lbu s5, 0(t2) + c->ppach(s4, r0, s4); // ppach s4, r0, s4 + c->mfc1(r0, f31); // mfc1 r0, f31 + c->dsll(s4, s4, 16); // dsll s4, s4, 16 + c->dsll(s5, s5, 2); // dsll s5, s5, 2 + bc = c->sgpr64(s4) != 0; // bne s4, r0, L175 + c->daddu(s5, s5, t1); // daddu s5, s5, t1 + if (bc) {goto block_7;} // branch non-likely + + bc = c->sgpr64(a0) == c->sgpr64(v1); // beq a0, v1, L179 + c->lwu(s5, 0, s5); // lwu s5, 0(s5) + if (bc) {goto block_17;} // branch non-likely + + c->and_(s4, s5, t3); // and s4, s5, t3 + // nop // sll r0, r0, 0 + bc = c->sgpr64(s4) != 0; // bne s4, r0, L175 + // nop // sll r0, r0, 0 + if (bc) {goto block_7;} // branch non-likely + + // nop // sll r0, r0, 0 + c->sq(r0, 48, a1); // sq r0, 48(a1) + c->daddiu(a0, a0, 1); // daddiu a0, a0, 1 + c->sw(s5, 48, a1); // sw s5, 48(a1) + c->daddiu(a1, a1, 64); // daddiu a1, a1, 64 + c->lq(s5, 16, t5); // lq s5, 16(t5) + // nop // sll r0, r0, 0 + c->lq(s4, 16, t6); // lq s4, 16(t6) + // nop // sll r0, r0, 0 + c->lq(s3, 16, t9); // lq s3, 16(t9) + // nop // sll r0, r0, 0 + c->sq(s5, -64, a1); // sq s5, -64(a1) + // nop // sll r0, r0, 0 + c->sq(s4, -48, a1); // sq s4, -48(a1) + // nop // sll r0, r0, 0 + c->sq(s3, -32, a1); // sq s3, -32(a1) + + block_7: + c->daddiu(t2, t2, 1); // daddiu t2, t2, 1 + c->daddiu(a3, a3, 3); // daddiu a3, a3, 3 + c->addiu(s5, r0, 16); // addiu s5, r0, 16 + // nop // sll r0, r0, 0 + + block_8: + // nop // sll r0, r0, 0 + c->lb(s4, 0, a3); // lb s4, 0(a3) + c->daddiu(a3, a3, 1); // daddiu a3, a3, 1 + // nop // sll r0, r0, 0 + bc = c->sgpr64(s4) == 0; // beq s4, r0, L174 + // nop // sll r0, r0, 0 + if (bc) {goto block_2;} // branch non-likely + + if (((s64)c->sgpr64(s4)) < 0) { // bltzl s4, L177 + c->dsubu(s4, r0, s4); // dsubu s4, r0, s4 + goto block_12; + } + + // block_11: + c->mov128_gpr_gpr(t7, t8); // por t7, t8, r0 + c->mov64(t5, t6); // or t5, t6, r0 + c->dsubu(s5, r0, s5); // dsubu s5, r0, s5 + // nop // sll r0, r0, 0 + + block_12: + c->daddiu(s4, s4, -1); // daddiu s4, s4, -1 + c->mov64(t6, t9); // or t6, t9, r0 + c->mov128_gpr_gpr(t8, ra); // por t8, ra, r0 + c->dsll(t9, s4, 5); // dsll t9, s4, 5 + c->daddu(t9, t9, t4); // daddu t9, t9, t4 + c->lbu(s4, 0, t2); // lbu s4, 0(t2) + c->pminw(s2, t7, t8); // pminw s2, t7, t8 + c->lq(ra, 4096, t9); // lq ra, 4096(t9) + c->pmaxw(s3, t7, t8); // pmaxw s3, t7, t8 + c->mfc1(r0, f31); // mfc1 r0, f31 + c->pminw(s2, s2, ra); // pminw s2, s2, ra + c->mfc1(r0, f31); // mfc1 r0, f31 + c->pmaxw(s3, s3, ra); // pmaxw s3, s3, ra + c->mfc1(r0, f31); // mfc1 r0, f31 + c->pcgtw(s2, s2, t0); // pcgtw s2, s2, t0 + c->mfc1(r0, f31); // mfc1 r0, f31 + c->pcgtw(s3, a2, s3); // pcgtw s3, a2, s3 + c->mfc1(r0, f31); // mfc1 r0, f31 + c->por(s3, s2, s3); // por s3, s2, s3 + c->mfc1(r0, f31); // mfc1 r0, f31 + c->ppach(s3, r0, s3); // ppach s3, r0, s3 + c->mfc1(r0, f31); // mfc1 r0, f31 + c->dsll(s3, s3, 16); // dsll s3, s3, 16 + c->dsll(s4, s4, 2); // dsll s4, s4, 2 + bc = c->sgpr64(s3) != 0; // bne s3, r0, L176 + c->daddiu(t2, t2, 1); // daddiu t2, t2, 1 + if (bc) {goto block_8;} // branch non-likely + + c->daddu(s4, s4, t1); // daddu s4, s4, t1 + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + c->lwu(s4, 0, s4); // lwu s4, 0(s4) + c->and_(s3, s4, t3); // and s3, s4, t3 + // nop // sll r0, r0, 0 + bc = c->sgpr64(s3) != 0; // bne s3, r0, L176 + // nop // sll r0, r0, 0 + if (bc) {goto block_8;} // branch non-likely + + bc = c->sgpr64(a0) == c->sgpr64(v1); // beq a0, v1, L179 + // nop // sll r0, r0, 0 + if (bc) {goto block_17;} // branch non-likely + + // nop // sll r0, r0, 0 + c->sq(r0, 48, a1); // sq r0, 48(a1) + c->daddiu(a0, a0, 1); // daddiu a0, a0, 1 + c->sw(s4, 48, a1); // sw s4, 48(a1) + c->daddiu(s2, a1, 16); // daddiu s2, a1, 16 + c->lq(s1, 16, t6); // lq s1, 16(t6) + c->daddiu(a1, a1, 64); // daddiu a1, a1, 64 + c->lq(s4, 16, t5); // lq s4, 16(t5) + // nop // sll r0, r0, 0 + c->lq(s3, 16, t9); // lq s3, 16(t9) + // nop // sll r0, r0, 0 + c->sq(s1, 0, s2); // sq s1, 0(s2) + c->dsubu(s1, s2, s5); // dsubu s1, s2, s5 + c->daddu(s2, s2, s5); // daddu s2, s2, s5 + // nop // sll r0, r0, 0 + c->sq(s4, 0, s1); // sq s4, 0(s1) + //beq r0, r0, L176 // beq r0, r0, L176 + c->sq(s3, 0, s2); // sq s3, 0(s2) + goto block_8; // branch always + + + block_16: + // nop // sll r0, r0, 0 + c->sw(a0, 0, gp); // sw a0, 0(gp) + //beq r0, r0, L181 // beq r0, r0, L181 + // nop // sll r0, r0, 0 + goto block_21; // branch always + + + block_17: + // nop // sll r0, r0, 0 + c->sw(v1, 0, gp); // sw v1, 0(gp) + c->load_symbol(v1, cache.already_printed_exeeded_max_cache_tris);// lw v1, *already-printed-exeeded-max-cache-tris*(s7) + bc = c->sgpr64(s7) != c->sgpr64(v1); // bne s7, v1, L180 + c->mov64(v1, s7); // or v1, s7, r0 + if (bc) {goto block_20;} // branch non-likely + + c->daddiu(v1, s7, 8); // daddiu v1, s7, #t + // c->store_symbol(v1, cache.already_printed_exeeded_max_cache_tris);// sw v1, *already-printed-exeeded-max-cache-tris*(s7) + // c->load_symbol_addr(v1, cache.debug); // daddiu v1, s7, debug + c->load_symbol(a0, cache.cheat_mode); // lw a0, *cheat-mode*(s7) + bc = c->sgpr64(a0) != c->sgpr64(v1); // bne a0, v1, L180 + c->mov64(v1, s7); // or v1, s7, r0 + if (bc) {goto block_20;} // branch non-likely + + c->load_symbol(t9, cache.format); // lw t9, format(s7) + c->load_symbol(a0, cache.stdcon); // lw a0, *stdcon*(s7) + //daddiu a1, fp, L305 // daddiu a1, fp, L305 + 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 + printf("exceeded maximum collide cache tris (should print on screen but too lazy for that now)\n"); + c->mov64(v1, v0); // or v1, v0, r0 + // nop // sll r0, r0, 0 + + block_20: + //beq r0, r0, L181 // beq r0, r0, L181 + // nop // sll r0, r0, 0 + goto block_21; // branch always + + + block_21: + c->gprs[v0].du64[0] = 0; // or v0, r0, r0 + c->ld(ra, 0, sp); // ld ra, 0(sp) + c->ld(fp, 8, sp); // ld fp, 8(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) + c->lq(s2, 32, sp); // lq s2, 32(sp) + c->lq(s1, 16, sp); // lq s1, 16(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.already_printed_exeeded_max_cache_tris = intern_from_c("*already-printed-exeeded-max-cache-tris*").c(); + cache.cheat_mode = intern_from_c("*cheat-mode*").c(); + cache.collide_work = intern_from_c("*collide-work*").c(); + cache.stdcon = intern_from_c("*stdcon*").c(); + cache.debug = intern_from_c("debug").c(); + cache.format = intern_from_c("format").c(); + cache.fake_scratchpad_data = intern_from_c("*fake-scratchpad-data*").c(); + gLinkedFunctionTable.reg("(method 27 collide-cache)", execute, 512); +} + +} // namespace method_27_collide_cache +} // namespace Mips2C + +//--------------------------MIPS2C--------------------- +#include "game/mips2c/mips2c_private.h" +#include "game/kernel/kscheme.h" +namespace Mips2C { +namespace method_29_collide_cache { +struct Cache { + void* collide_work; // *collide-work* + void* fake_scratchpad_data; +} cache; + +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->load_symbol(a0, cache.collide_work); // lw a0, *collide-work*(s7) + // c->lui(v1, 28672); // lui v1, 28672 + get_fake_spad_addr(v1, cache.fake_scratchpad_data, 0, c); + c->lbu(a1, 24, a1); // lbu a1, 24(a1) + // nop // sll r0, r0, 0 + c->lqc2(vf1, 48, a0); // lqc2 vf1, 48(a0) + // nop // sll r0, r0, 0 + c->lqc2(vf2, 64, a0); // lqc2 vf2, 64(a0) + // nop // sll r0, r0, 0 + c->lqc2(vf3, 80, a0); // lqc2 vf3, 80(a0) + // nop // sll r0, r0, 0 + c->lqc2(vf4, 96, a0); // lqc2 vf4, 96(a0) + // nop // sll r0, r0, 0 + c->lqc2(vf5, 16, v1); // lqc2 vf5, 16(v1) + // nop // sll r0, r0, 0 + c->lqc2(vf6, 48, v1); // lqc2 vf6, 48(v1) + // nop // sll r0, r0, 0 + c->lqc2(vf7, 80, v1); // lqc2 vf7, 80(v1) + // nop // sll r0, r0, 0 + c->lqc2(vf8, 112, v1); // lqc2 vf8, 112(v1) + c->vmula_bc(DEST::xyzw, BC::w, vf4, vf0); // vmulaw.xyzw acc, vf4, vf0 + c->lqc2(vf9, 144, v1); // lqc2 vf9, 144(v1) + c->vmadda_bc(DEST::xyzw, BC::x, vf1, vf5); // vmaddax.xyzw acc, vf1, vf5 + c->lqc2(vf10, 176, v1); // lqc2 vf10, 176(v1) + c->vmadda_bc(DEST::xyzw, BC::y, vf2, vf5); // vmadday.xyzw acc, vf2, vf5 + c->lqc2(vf11, 208, v1); // lqc2 vf11, 208(v1) + c->vmadd_bc(DEST::xyzw, BC::z, vf5, vf3, vf5); // vmaddz.xyzw vf5, vf3, vf5 + c->lqc2(vf12, 240, v1); // lqc2 vf12, 240(v1) + c->vmula_bc(DEST::xyzw, BC::w, vf4, vf0); // vmulaw.xyzw acc, vf4, vf0 + // nop // sll r0, r0, 0 + c->vmadda_bc(DEST::xyzw, BC::x, vf1, vf6); // vmaddax.xyzw acc, vf1, vf6 + // nop // sll r0, r0, 0 + c->vmadda_bc(DEST::xyzw, BC::y, vf2, vf6); // vmadday.xyzw acc, vf2, vf6 + // nop // sll r0, r0, 0 + c->vmadd_bc(DEST::xyzw, BC::z, vf6, vf3, vf6); // vmaddz.xyzw vf6, vf3, vf6 + // nop // sll r0, r0, 0 + c->vmula_bc(DEST::xyzw, BC::w, vf4, vf0); // vmulaw.xyzw acc, vf4, vf0 + // nop // sll r0, r0, 0 + c->vmadda_bc(DEST::xyzw, BC::x, vf1, vf7); // vmaddax.xyzw acc, vf1, vf7 + // nop // sll r0, r0, 0 + c->vmadda_bc(DEST::xyzw, BC::y, vf2, vf7); // vmadday.xyzw acc, vf2, vf7 + // nop // sll r0, r0, 0 + c->vmadd_bc(DEST::xyzw, BC::z, vf7, vf3, vf7); // vmaddz.xyzw vf7, vf3, vf7 + // nop // sll r0, r0, 0 + c->vmula_bc(DEST::xyzw, BC::w, vf4, vf0); // vmulaw.xyzw acc, vf4, vf0 + // nop // sll r0, r0, 0 + c->vmadda_bc(DEST::xyzw, BC::x, vf1, vf8); // vmaddax.xyzw acc, vf1, vf8 + // nop // sll r0, r0, 0 + c->vmadda_bc(DEST::xyzw, BC::y, vf2, vf8); // vmadday.xyzw acc, vf2, vf8 + // nop // sll r0, r0, 0 + c->vmadd_bc(DEST::xyzw, BC::z, vf8, vf3, vf8); // vmaddz.xyzw vf8, vf3, vf8 + // nop // sll r0, r0, 0 + c->vftoi0(DEST::xyzw, vf5, vf5); // vftoi0.xyzw vf5, vf5 + // nop // sll r0, r0, 0 + c->vftoi0(DEST::xyzw, vf6, vf6); // vftoi0.xyzw vf6, vf6 + // nop // sll r0, r0, 0 + c->vftoi0(DEST::xyzw, vf7, vf7); // vftoi0.xyzw vf7, vf7 + // nop // sll r0, r0, 0 + c->vftoi0(DEST::xyzw, vf8, vf8); // vftoi0.xyzw vf8, vf8 + // nop // sll r0, r0, 0 + + block_1: + c->vmula_bc(DEST::xyzw, BC::w, vf4, vf0); // vmulaw.xyzw acc, vf4, vf0 + c->sqc2(vf5, 4096, v1); // sqc2 vf5, 4096(v1) + c->vmadda_bc(DEST::xyzw, BC::x, vf1, vf9); // vmaddax.xyzw acc, vf1, vf9 + c->sqc2(vf6, 4128, v1); // sqc2 vf6, 4128(v1) + c->vmadda_bc(DEST::xyzw, BC::y, vf2, vf9); // vmadday.xyzw acc, vf2, vf9 + c->sqc2(vf7, 4160, v1); // sqc2 vf7, 4160(v1) + c->vmadd_bc(DEST::xyzw, BC::z, vf9, vf3, vf9); // vmaddz.xyzw vf9, vf3, vf9 + c->sqc2(vf8, 4192, v1); // sqc2 vf8, 4192(v1) + c->vmula_bc(DEST::xyzw, BC::w, vf4, vf0); // vmulaw.xyzw acc, vf4, vf0 + c->lqc2(vf5, 272, v1); // lqc2 vf5, 272(v1) + c->vmadda_bc(DEST::xyzw, BC::x, vf1, vf10); // vmaddax.xyzw acc, vf1, vf10 + c->lqc2(vf6, 304, v1); // lqc2 vf6, 304(v1) + c->vmadda_bc(DEST::xyzw, BC::y, vf2, vf10); // vmadday.xyzw acc, vf2, vf10 + c->lqc2(vf7, 336, v1); // lqc2 vf7, 336(v1) + c->vmadd_bc(DEST::xyzw, BC::z, vf10, vf3, vf10); // vmaddz.xyzw vf10, vf3, vf10 + c->lqc2(vf8, 368, v1); // lqc2 vf8, 368(v1) + c->daddiu(v1, v1, 256); // daddiu v1, v1, 256 + c->vmula_bc(DEST::xyzw, BC::w, vf4, vf0); // vmulaw.xyzw acc, vf4, vf0 + // nop // sll r0, r0, 0 + c->vmadda_bc(DEST::xyzw, BC::x, vf1, vf11); // vmaddax.xyzw acc, vf1, vf11 + c->daddiu(a0, a1, -4); // daddiu a0, a1, -4 + c->vmadda_bc(DEST::xyzw, BC::y, vf2, vf11); // vmadday.xyzw acc, vf2, vf11 + bc = ((s64)c->sgpr64(a0)) <= 0; // blez a0, L172 + c->vmadd_bc(DEST::xyzw, BC::z, vf11, vf3, vf11); // vmaddz.xyzw vf11, vf3, vf11 + if (bc) {goto block_4;} // branch non-likely + + c->vmula_bc(DEST::xyzw, BC::w, vf4, vf0); // vmulaw.xyzw acc, vf4, vf0 + // nop // sll r0, r0, 0 + c->vmadda_bc(DEST::xyzw, BC::x, vf1, vf12); // vmaddax.xyzw acc, vf1, vf12 + // nop // sll r0, r0, 0 + c->vmadda_bc(DEST::xyzw, BC::y, vf2, vf12); // vmadday.xyzw acc, vf2, vf12 + // nop // sll r0, r0, 0 + c->vmadd_bc(DEST::xyzw, BC::z, vf12, vf3, vf12); // vmaddz.xyzw vf12, vf3, vf12 + // nop // sll r0, r0, 0 + c->vftoi0(DEST::xyzw, vf9, vf9); // vftoi0.xyzw vf9, vf9 + // nop // sll r0, r0, 0 + c->vftoi0(DEST::xyzw, vf10, vf10); // vftoi0.xyzw vf10, vf10 + // nop // sll r0, r0, 0 + c->vftoi0(DEST::xyzw, vf11, vf11); // vftoi0.xyzw vf11, vf11 + // nop // sll r0, r0, 0 + c->vftoi0(DEST::xyzw, vf12, vf12); // vftoi0.xyzw vf12, vf12 + // nop // sll r0, r0, 0 + c->vmula_bc(DEST::xyzw, BC::w, vf4, vf0); // vmulaw.xyzw acc, vf4, vf0 + c->sqc2(vf9, 3968, v1); // sqc2 vf9, 3968(v1) + c->vmadda_bc(DEST::xyzw, BC::x, vf1, vf5); // vmaddax.xyzw acc, vf1, vf5 + c->sqc2(vf10, 4000, v1); // sqc2 vf10, 4000(v1) + c->vmadda_bc(DEST::xyzw, BC::y, vf2, vf5); // vmadday.xyzw acc, vf2, vf5 + c->sqc2(vf11, 4032, v1); // sqc2 vf11, 4032(v1) + c->vmadd_bc(DEST::xyzw, BC::z, vf5, vf3, vf5); // vmaddz.xyzw vf5, vf3, vf5 + c->sqc2(vf12, 4064, v1); // sqc2 vf12, 4064(v1) + // nop // sll r0, r0, 0 + c->vmula_bc(DEST::xyzw, BC::w, vf4, vf0); // vmulaw.xyzw acc, vf4, vf0 + // nop // sll r0, r0, 0 + c->vmadda_bc(DEST::xyzw, BC::x, vf1, vf6); // vmaddax.xyzw acc, vf1, vf6 + c->daddiu(a1, a0, -4); // daddiu a1, a0, -4 + c->vmadda_bc(DEST::xyzw, BC::y, vf2, vf6); // vmadday.xyzw acc, vf2, vf6 + bc = ((s64)c->sgpr64(a1)) <= 0; // blez a1, L172 + c->vmadd_bc(DEST::xyzw, BC::z, vf6, vf3, vf6); // vmaddz.xyzw vf6, vf3, vf6 + if (bc) {goto block_4;} // branch non-likely + + c->vmula_bc(DEST::xyzw, BC::w, vf4, vf0); // vmulaw.xyzw acc, vf4, vf0 + c->lqc2(vf9, 144, v1); // lqc2 vf9, 144(v1) + c->vmadda_bc(DEST::xyzw, BC::x, vf1, vf7); // vmaddax.xyzw acc, vf1, vf7 + c->lqc2(vf10, 176, v1); // lqc2 vf10, 176(v1) + c->vmadda_bc(DEST::xyzw, BC::y, vf2, vf7); // vmadday.xyzw acc, vf2, vf7 + c->lqc2(vf11, 208, v1); // lqc2 vf11, 208(v1) + c->vmadd_bc(DEST::xyzw, BC::z, vf7, vf3, vf7); // vmaddz.xyzw vf7, vf3, vf7 + c->lqc2(vf12, 240, v1); // lqc2 vf12, 240(v1) + c->vmula_bc(DEST::xyzw, BC::w, vf4, vf0); // vmulaw.xyzw acc, vf4, vf0 + // nop // sll r0, r0, 0 + c->vmadda_bc(DEST::xyzw, BC::x, vf1, vf8); // vmaddax.xyzw acc, vf1, vf8 + // nop // sll r0, r0, 0 + c->vmadda_bc(DEST::xyzw, BC::y, vf2, vf8); // vmadday.xyzw acc, vf2, vf8 + // nop // sll r0, r0, 0 + c->vmadd_bc(DEST::xyzw, BC::z, vf8, vf3, vf8); // vmaddz.xyzw vf8, vf3, vf8 + // nop // sll r0, r0, 0 + c->vftoi0(DEST::xyzw, vf5, vf5); // vftoi0.xyzw vf5, vf5 + // nop // sll r0, r0, 0 + c->vftoi0(DEST::xyzw, vf6, vf6); // vftoi0.xyzw vf6, vf6 + // nop // sll r0, r0, 0 + c->vftoi0(DEST::xyzw, vf7, vf7); // vftoi0.xyzw vf7, vf7 + // nop // sll r0, r0, 0 + c->vftoi0(DEST::xyzw, vf8, vf8); // vftoi0.xyzw vf8, vf8 + // nop // sll r0, r0, 0 + //beq r0, r0, L171 // beq r0, r0, L171 + // nop // sll r0, r0, 0 + goto block_1; // branch always + + + block_4: + 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() { + cache.collide_work = intern_from_c("*collide-work*").c(); + cache.fake_scratchpad_data = intern_from_c("*fake-scratchpad-data*").c(); + gLinkedFunctionTable.reg("(method 29 collide-cache)", execute, 128); +} + +} // namespace method_29_collide_cache +} // namespace Mips2C + +//--------------------------MIPS2C--------------------- +#include "game/mips2c/mips2c_private.h" +#include "game/kernel/kscheme.h" +namespace Mips2C { +namespace method_12_collide_shape_prim_mesh { +struct Cache { + void* already_printed_exeeded_max_cache_tris; // *already-printed-exeeded-max-cache-tris* + void* cheat_mode; // *cheat-mode* + void* stdcon; // *stdcon* + void* debug; // debug + void* format; // format + void* fake_scratchpad_data; +} cache; + +u64 execute(void* ctxt) { + auto* c = (ExecutionContext*)ctxt; + bool bc = false; + u32 call_addr = 0; + c->daddiu(sp, sp, -80); // daddiu sp, sp, -80 + c->sd(ra, 0, sp); // sd ra, 0(sp) + c->sd(fp, 8, sp); // sd fp, 8(sp) + c->mov64(fp, t9); // or fp, t9, r0 + c->sq(s3, 16, sp); // sq s3, 16(sp) + c->sq(s4, 32, sp); // sq s4, 32(sp) + c->sq(s5, 48, sp); // sq s5, 48(sp) + c->sq(gp, 64, sp); // sq gp, 64(sp) + c->mov64(s5, a0); // or s5, a0, r0 + c->mov64(gp, a1); // or gp, a1, r0 + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + c->lwu(s3, 68, s5); // lwu s3, 68(s5) + c->daddiu(v1, gp, 108); // daddiu v1, gp, 108 + c->lwu(a0, 4, gp); // lwu a0, 4(gp) + bc = c->sgpr64(s3) == c->sgpr64(s7); // beq s3, s7, L147 + // nop // sll r0, r0, 0 + if (bc) {goto block_15;} // branch non-likely + + c->addiu(a1, r0, 100); // addiu a1, r0, 100 + c->dsll(a2, a0, 1); // dsll a2, a0, 1 + bc = c->sgpr64(a0) == c->sgpr64(a1); // beq a0, a1, L145 + c->daddu(a0, a2, a0); // daddu a0, a2, a0 + if (bc) {goto block_11;} // branch non-likely + + c->dsll(a0, a0, 4); // dsll a0, a0, 4 + c->daddu(s4, v1, a0); // daddu s4, v1, a0 + c->mov64(a0, s3); // or a0, s3, r0 + c->lwu(v1, -4, a0); // lwu v1, -4(a0) + c->lwu(t9, 72, v1); // lwu t9, 72(v1) + c->lwu(v1, 0, s5); // lwu v1, 0(s5) + c->lwu(v1, 136, v1); // lwu v1, 136(v1) + c->lwu(v1, 112, v1); // lwu v1, 112(v1) + c->lb(a1, 8, s5); // lb a1, 8(s5) + c->dsll(a1, a1, 5); // dsll a1, a1, 5 + c->daddu(v1, v1, a1); // daddu v1, v1, a1 + c->lwu(v1, 28, v1); // lwu v1, 28(v1) + c->daddu(a1, r0, v1); // daddu a1, r0, v1 + // c->lui(a2, 28672); // lui a2, 28672 + get_fake_spad_addr(a2, cache.fake_scratchpad_data, 0, c); + 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 + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + c->lwu(a0, 4, gp); // lwu a0, 4(gp) + c->addiu(a1, r0, 460); // addiu a1, r0, 460 + c->lwu(v1, 0, gp); // lwu v1, 0(gp) + c->dsll32(a0, a0, 0); // dsll32 a0, a0, 0 + // nop // sll r0, r0, 0 + c->mov128_vf_gpr(vf1, a0); // qmtc2.i vf1, a0 + // nop // sll r0, r0, 0 + c->dsubu(a0, a1, v1); // dsubu a0, a1, v1 + c->dsll(t1, v1, 6); // dsll t1, v1, 6 + bc = ((s64)c->sgpr64(a0)) < 0; // bltz a0, L146 + c->daddiu(a2, s3, 28); // daddiu a2, s3, 28 + if (bc) {goto block_12;} // branch non-likely + + c->mov64(a0, v1); // or a0, v1, r0 + c->lwu(a3, 4, s3); // lwu a3, 4(s3) + c->daddiu(t2, gp, 4908); // daddiu t2, gp, 4908 + c->lq(t0, 60, gp); // lq t0, 60(gp) + c->daddu(t1, t2, t1); // daddu t1, t2, t1 + c->lq(t2, 76, gp); // lq t2, 76(gp) + // c->lui(t3, 28672); // lui t3, 28672 + get_fake_spad_addr(t3, cache.fake_scratchpad_data, 0, c); + c->lwu(t4, 8, gp); // lwu t4, 8(gp) + c->vsub(DEST::zw, vf1, vf0, vf0); // vsub.zw vf1, vf0, vf0 + // nop // sll r0, r0, 0 + + block_4: + bc = c->sgpr64(a3) == 0; // beq a3, r0, L144 + c->lbu(t5, 0, a2); // lbu t5, 0(a2) + if (bc) {goto block_9;} // branch non-likely + + c->daddiu(a3, a3, -1); // daddiu a3, a3, -1 + c->lbu(t6, 1, a2); // lbu t6, 1(a2) + c->dsll(t8, t5, 5); // dsll t8, t5, 5 + c->lbu(t5, 2, a2); // lbu t5, 2(a2) + c->dsll(t7, t6, 5); // dsll t7, t6, 5 + c->daddu(t6, t8, t3); // daddu t6, t8, t3 + c->dsll(t5, t5, 5); // dsll t5, t5, 5 + // nop // sll r0, r0, 0 + c->daddu(t7, t7, t3); // daddu t7, t7, t3 + c->lq(t9, 16, t6); // lq t9, 16(t6) + c->daddu(t5, t5, t3); // daddu t5, t5, t3 + c->lq(s3, 16, t7); // lq s3, 16(t7) + c->pminw(ra, t9, s3); // pminw ra, t9, s3 + c->lq(t8, 16, t5); // lq t8, 16(t5) + c->pmaxw(t9, t9, s3); // pmaxw t9, t9, s3 + c->mfc1(r0, f31); // mfc1 r0, f31 + c->pminw(ra, ra, t8); // pminw ra, ra, t8 + c->mfc1(r0, f31); // mfc1 r0, f31 + c->pmaxw(t8, t9, t8); // pmaxw t8, t9, t8 + c->mfc1(r0, f31); // mfc1 r0, f31 + c->pcgtw(t9, ra, t2); // pcgtw t9, ra, t2 + c->mfc1(r0, f31); // mfc1 r0, f31 + c->pcgtw(ra, t0, t8); // pcgtw ra, t0, t8 + c->lwu(t8, 4, a2); // lwu t8, 4(a2) + c->por(t9, t9, ra); // por t9, t9, ra + c->lq(t6, 0, t6); // lq t6, 0(t6) + c->ppach(t9, r0, t9); // ppach t9, r0, t9 + c->lq(t7, 0, t7); // lq t7, 0(t7) + c->dsll(t9, t9, 16); // dsll t9, t9, 16 + c->lq(t5, 0, t5); // lq t5, 0(t5) + bc = c->sgpr64(t9) != 0; // bne t9, r0, L143 + c->daddiu(a2, a2, 8); // daddiu a2, a2, 8 + if (bc) {goto block_4;} // branch non-likely + + bc = c->sgpr64(v1) == c->sgpr64(a1); // beq v1, a1, L146 + c->sqc2(vf1, 48, t1); // sqc2 vf1, 48(t1) + if (bc) {goto block_12;} // branch non-likely + + c->and_(t9, t8, t4); // and t9, t8, t4 + c->sw(t8, 48, t1); // sw t8, 48(t1) + bc = c->sgpr64(t9) != 0; // bne t9, r0, L143 + c->sq(t6, 0, t1); // sq t6, 0(t1) + if (bc) {goto block_4;} // branch non-likely + + // nop // sll r0, r0, 0 + c->sq(t7, 16, t1); // sq t7, 16(t1) + c->daddiu(v1, v1, 1); // daddiu v1, v1, 1 + c->sq(t5, 32, t1); // sq t5, 32(t1) + //beq r0, r0, L143 // beq r0, r0, L143 + c->daddiu(t1, t1, 64); // daddiu t1, t1, 64 + goto block_4; // branch always + + + block_9: + c->dsubu(a3, v1, a0); // dsubu a3, v1, a0 + c->lwu(t0, 4, gp); // lwu t0, 4(gp) + bc = c->sgpr64(a3) == 0; // beq a3, r0, L147 + c->lq(a1, 12, s5); // lq a1, 12(s5) + if (bc) {goto block_15;} // branch non-likely + + // nop // sll r0, r0, 0 + c->lq(a2, 28, s5); // lq a2, 28(s5) + // nop // sll r0, r0, 0 + c->sq(r0, 32, s4); // sq r0, 32(s4) + // nop // sll r0, r0, 0 + c->sh(a3, 42, s4); // sh a3, 42(s4) + // nop // sll r0, r0, 0 + c->sw(gp, 32, s4); // sw gp, 32(s4) + // nop // sll r0, r0, 0 + c->sw(s5, 36, s4); // sw s5, 36(s4) + // nop // sll r0, r0, 0 + c->sh(a0, 40, s4); // sh a0, 40(s4) + c->daddiu(a0, t0, 1); // daddiu a0, t0, 1 + c->sq(a1, 0, s4); // sq a1, 0(s4) + // nop // sll r0, r0, 0 + c->sq(a2, 16, s4); // sq a2, 16(s4) + // nop // sll r0, r0, 0 + c->sw(a0, 4, gp); // sw a0, 4(gp) + //beq r0, r0, L147 // beq r0, r0, L147 + c->sw(v1, 0, gp); // sw v1, 0(gp) + goto block_15; // branch always + + + block_11: + c->load_symbol(t9, cache.format); // lw t9, format(s7) + c->addiu(a0, r0, 0); // addiu a0, r0, 0 + // daddiu a1, fp, L306 // daddiu a1, fp, L306 + printf("too many prims\n"); + 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 + //beq r0, r0, L147 // beq r0, r0, L147 + // nop // sll r0, r0, 0 + goto block_15; // branch always + + + block_12: + c->load_symbol(v1, cache.already_printed_exeeded_max_cache_tris);// lw v1, *already-printed-exeeded-max-cache-tris*(s7) + bc = c->sgpr64(s7) != c->sgpr64(v1); // bne s7, v1, L147 + c->mov64(v1, s7); // or v1, s7, r0 + if (bc) {goto block_15;} // branch non-likely + + c->daddiu(v1, s7, 8); // daddiu v1, s7, #t + // c->store_symbol(v1, cache.already_printed_exeeded_max_cache_tris);// sw v1, *already-printed-exeeded-max-cache-tris*(s7) + // c->load_symbol_addr(v1, cache.debug); // daddiu v1, s7, debug + c->load_symbol(a0, cache.cheat_mode); // lw a0, *cheat-mode*(s7) + bc = c->sgpr64(a0) != c->sgpr64(v1); // bne a0, v1, L147 + c->mov64(v1, s7); // or v1, s7, r0 + if (bc) {goto block_15;} // branch non-likely + + c->load_symbol(t9, cache.format); // lw t9, format(s7) + c->load_symbol(a0, cache.stdcon); // lw a0, *stdcon*(s7) + // daddiu a1, fp, L305 // daddiu a1, fp, L305 + 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 + printf("too many tris\n"); + c->mov64(v1, v0); // or v1, v0, r0 + + block_15: + c->gprs[v0].du64[0] = 0; // or v0, r0, r0 + c->ld(ra, 0, sp); // ld ra, 0(sp) + c->ld(fp, 8, sp); // ld fp, 8(sp) + c->lq(gp, 64, sp); // lq gp, 64(sp) + c->lq(s5, 48, sp); // lq s5, 48(sp) + c->lq(s4, 32, sp); // lq s4, 32(sp) + c->lq(s3, 16, sp); // lq s3, 16(sp) + //jr ra // jr ra + c->daddiu(sp, sp, 80); // daddiu sp, sp, 80 + goto end_of_function; // return + + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + end_of_function: + return c->gprs[v0].du64[0]; +} + +void link() { + cache.already_printed_exeeded_max_cache_tris = intern_from_c("*already-printed-exeeded-max-cache-tris*").c(); + cache.cheat_mode = intern_from_c("*cheat-mode*").c(); + cache.stdcon = intern_from_c("*stdcon*").c(); + cache.debug = intern_from_c("debug").c(); + cache.format = intern_from_c("format").c(); + cache.fake_scratchpad_data = intern_from_c("*fake-scratchpad-data*").c(); + gLinkedFunctionTable.reg("(method 12 collide-shape-prim-mesh)", execute, 128); +} + +} // namespace method_12_collide_shape_prim_mesh +} // namespace Mips2C + + +//--------------------------MIPS2C--------------------- +#include "game/mips2c/mips2c_private.h" +#include "game/kernel/kscheme.h" +namespace Mips2C { +namespace method_14_collide_shape_prim_mesh { +struct Cache { + void* already_printed_exeeded_max_cache_tris; // *already-printed-exeeded-max-cache-tris* + void* cheat_mode; // *cheat-mode* + void* stdcon; // *stdcon* + void* debug; // debug + void* format; // format + void* fake_scratchpad_data; +} cache; + +u64 execute(void* ctxt) { + auto* c = (ExecutionContext*)ctxt; + bool bc = false; + u32 call_addr = 0; + c->daddiu(sp, sp, -80); // daddiu sp, sp, -80 + c->sd(ra, 0, sp); // sd ra, 0(sp) + c->sd(fp, 8, sp); // sd fp, 8(sp) + c->mov64(fp, t9); // or fp, t9, r0 + c->sq(s3, 16, sp); // sq s3, 16(sp) + c->sq(s4, 32, sp); // sq s4, 32(sp) + c->sq(s5, 48, sp); // sq s5, 48(sp) + c->sq(gp, 64, sp); // sq gp, 64(sp) + c->mov64(s5, a0); // or s5, a0, r0 + c->mov64(gp, a1); // or gp, a1, r0 + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + c->lwu(s3, 68, s5); // lwu s3, 68(s5) + c->daddiu(v1, gp, 108); // daddiu v1, gp, 108 + c->lwu(a0, 4, gp); // lwu a0, 4(gp) + bc = c->sgpr64(s3) == c->sgpr64(s7); // beq s3, s7, L112 + // nop // sll r0, r0, 0 + if (bc) {goto block_15;} // branch non-likely + + c->addiu(a1, r0, 100); // addiu a1, r0, 100 + c->dsll(a2, a0, 1); // dsll a2, a0, 1 + bc = c->sgpr64(a0) == c->sgpr64(a1); // beq a0, a1, L110 + c->daddu(a0, a2, a0); // daddu a0, a2, a0 + if (bc) {goto block_11;} // branch non-likely + + c->dsll(a0, a0, 4); // dsll a0, a0, 4 + c->daddu(s4, v1, a0); // daddu s4, v1, a0 + c->mov64(a0, s3); // or a0, s3, r0 + c->lwu(v1, -4, a0); // lwu v1, -4(a0) + c->lwu(t9, 72, v1); // lwu t9, 72(v1) + c->lwu(v1, 0, s5); // lwu v1, 0(s5) + c->lwu(v1, 136, v1); // lwu v1, 136(v1) + c->lwu(v1, 112, v1); // lwu v1, 112(v1) + c->lb(a1, 8, s5); // lb a1, 8(s5) + c->dsll(a1, a1, 5); // dsll a1, a1, 5 + c->daddu(v1, v1, a1); // daddu v1, v1, a1 + c->lwu(v1, 28, v1); // lwu v1, 28(v1) + c->daddu(a1, r0, v1); // daddu a1, r0, v1 + // c->lui(a2, 28672); // lui a2, 28672 + get_fake_spad_addr(a2, cache.fake_scratchpad_data, 0, c); + 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 + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + c->lwu(a0, 4, gp); // lwu a0, 4(gp) + c->addiu(a1, r0, 460); // addiu a1, r0, 460 + c->lwu(v1, 0, gp); // lwu v1, 0(gp) + c->dsll32(a0, a0, 0); // dsll32 a0, a0, 0 + // nop // sll r0, r0, 0 + c->mov128_vf_gpr(vf1, a0); // qmtc2.i vf1, a0 + // nop // sll r0, r0, 0 + c->dsubu(a0, a1, v1); // dsubu a0, a1, v1 + c->dsll(t1, v1, 6); // dsll t1, v1, 6 + bc = ((s64)c->sgpr64(a0)) < 0; // bltz a0, L111 + c->daddiu(a2, s3, 28); // daddiu a2, s3, 28 + if (bc) {goto block_12;} // branch non-likely + + c->mov64(a0, v1); // or a0, v1, r0 + c->lwu(a3, 4, s3); // lwu a3, 4(s3) + c->daddiu(t2, gp, 4908); // daddiu t2, gp, 4908 + c->lq(t0, 60, gp); // lq t0, 60(gp) + c->daddu(t1, t2, t1); // daddu t1, t2, t1 + c->lq(t2, 76, gp); // lq t2, 76(gp) + // c->lui(t3, 28672); // lui t3, 28672 + get_fake_spad_addr(t3, cache.fake_scratchpad_data, 0, c); + c->lwu(t4, 8, gp); // lwu t4, 8(gp) + c->vsub(DEST::zw, vf1, vf0, vf0); // vsub.zw vf1, vf0, vf0 + // nop // sll r0, r0, 0 + + block_4: + bc = c->sgpr64(a3) == 0; // beq a3, r0, L109 + c->lbu(t5, 0, a2); // lbu t5, 0(a2) + if (bc) {goto block_9;} // branch non-likely + + c->daddiu(a3, a3, -1); // daddiu a3, a3, -1 + c->lbu(t6, 1, a2); // lbu t6, 1(a2) + c->dsll(t8, t5, 5); // dsll t8, t5, 5 + c->lbu(t5, 2, a2); // lbu t5, 2(a2) + c->dsll(t7, t6, 5); // dsll t7, t6, 5 + c->daddu(t6, t8, t3); // daddu t6, t8, t3 + c->dsll(t5, t5, 5); // dsll t5, t5, 5 + // nop // sll r0, r0, 0 + c->daddu(t7, t7, t3); // daddu t7, t7, t3 + c->lq(t9, 16, t6); // lq t9, 16(t6) + c->daddu(t5, t5, t3); // daddu t5, t5, t3 + c->lq(s3, 16, t7); // lq s3, 16(t7) + c->pminw(ra, t9, s3); // pminw ra, t9, s3 + c->lq(t8, 16, t5); // lq t8, 16(t5) + c->pmaxw(t9, t9, s3); // pmaxw t9, t9, s3 + c->mfc1(r0, f31); // mfc1 r0, f31 + c->pminw(ra, ra, t8); // pminw ra, ra, t8 + c->mfc1(r0, f31); // mfc1 r0, f31 + c->pmaxw(t8, t9, t8); // pmaxw t8, t9, t8 + c->mfc1(r0, f31); // mfc1 r0, f31 + c->pcgtw(t9, ra, t2); // pcgtw t9, ra, t2 + c->mfc1(r0, f31); // mfc1 r0, f31 + c->pcgtw(ra, t0, t8); // pcgtw ra, t0, t8 + c->lwu(t8, 4, a2); // lwu t8, 4(a2) + c->por(t9, t9, ra); // por t9, t9, ra + c->lq(t6, 0, t6); // lq t6, 0(t6) + c->ppach(t9, r0, t9); // ppach t9, r0, t9 + c->lq(t7, 0, t7); // lq t7, 0(t7) + c->dsll(t9, t9, 16); // dsll t9, t9, 16 + c->lq(t5, 0, t5); // lq t5, 0(t5) + bc = c->sgpr64(t9) != 0; // bne t9, r0, L108 + c->daddiu(a2, a2, 8); // daddiu a2, a2, 8 + if (bc) {goto block_4;} // branch non-likely + + bc = c->sgpr64(v1) == c->sgpr64(a1); // beq v1, a1, L111 + c->sqc2(vf1, 48, t1); // sqc2 vf1, 48(t1) + if (bc) {goto block_12;} // branch non-likely + + c->and_(t9, t8, t4); // and t9, t8, t4 + c->sw(t8, 48, t1); // sw t8, 48(t1) + bc = c->sgpr64(t9) != 0; // bne t9, r0, L108 + c->sq(t6, 0, t1); // sq t6, 0(t1) + if (bc) {goto block_4;} // branch non-likely + + c->daddiu(v1, v1, 1); // daddiu v1, v1, 1 + c->sq(t7, 16, t1); // sq t7, 16(t1) + // nop // sll r0, r0, 0 + c->sq(t5, 32, t1); // sq t5, 32(t1) + //beq r0, r0, L108 // beq r0, r0, L108 + c->daddiu(t1, t1, 64); // daddiu t1, t1, 64 + goto block_4; // branch always + + + block_9: + c->dsubu(a3, v1, a0); // dsubu a3, v1, a0 + c->lwu(t0, 4, gp); // lwu t0, 4(gp) + bc = c->sgpr64(a3) == 0; // beq a3, r0, L112 + c->lq(a1, 12, s5); // lq a1, 12(s5) + if (bc) {goto block_15;} // branch non-likely + + // nop // sll r0, r0, 0 + c->lq(a2, 28, s5); // lq a2, 28(s5) + // nop // sll r0, r0, 0 + c->sq(r0, 32, s4); // sq r0, 32(s4) + // nop // sll r0, r0, 0 + c->sh(a3, 42, s4); // sh a3, 42(s4) + // nop // sll r0, r0, 0 + c->sw(gp, 32, s4); // sw gp, 32(s4) + // nop // sll r0, r0, 0 + c->sw(s5, 36, s4); // sw s5, 36(s4) + // nop // sll r0, r0, 0 + c->sh(a0, 40, s4); // sh a0, 40(s4) + c->daddiu(a0, t0, 1); // daddiu a0, t0, 1 + c->sq(a1, 0, s4); // sq a1, 0(s4) + // nop // sll r0, r0, 0 + c->sq(a2, 16, s4); // sq a2, 16(s4) + // nop // sll r0, r0, 0 + c->sw(a0, 4, gp); // sw a0, 4(gp) + //beq r0, r0, L112 // beq r0, r0, L112 + c->sw(v1, 0, gp); // sw v1, 0(gp) + goto block_15; // branch always + + + block_11: + c->load_symbol(t9, cache.format); // lw t9, format(s7) + c->addiu(a0, r0, 0); // addiu a0, r0, 0 + // daddiu a1, fp, L306 // daddiu a1, fp, L306 + 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 + printf("too many prims\n"); + //beq r0, r0, L112 // beq r0, r0, L112 + // nop // sll r0, r0, 0 + goto block_15; // branch always + + + block_12: + c->load_symbol(v1, cache.already_printed_exeeded_max_cache_tris);// lw v1, *already-printed-exeeded-max-cache-tris*(s7) + bc = c->sgpr64(s7) != c->sgpr64(v1); // bne s7, v1, L112 + c->mov64(v1, s7); // or v1, s7, r0 + if (bc) {goto block_15;} // branch non-likely + + c->daddiu(v1, s7, 8); // daddiu v1, s7, #t + // c->store_symbol(v1, cache.already_printed_exeeded_max_cache_tris);// sw v1, *already-printed-exeeded-max-cache-tris*(s7) + // c->load_symbol_addr(v1, cache.debug); // daddiu v1, s7, debug + c->load_symbol(a0, cache.cheat_mode); // lw a0, *cheat-mode*(s7) + bc = c->sgpr64(a0) != c->sgpr64(v1); // bne a0, v1, L112 + c->mov64(v1, s7); // or v1, s7, r0 + if (bc) {goto block_15;} // branch non-likely + + c->load_symbol(t9, cache.format); // lw t9, format(s7) + c->load_symbol(a0, cache.stdcon); // lw a0, *stdcon*(s7) + // daddiu a1, fp, L305 // daddiu a1, fp, L305 + 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 + printf("too many tris\n"); + c->mov64(v1, v0); // or v1, v0, r0 + + block_15: + c->gprs[v0].du64[0] = 0; // or v0, r0, r0 + c->ld(ra, 0, sp); // ld ra, 0(sp) + c->ld(fp, 8, sp); // ld fp, 8(sp) + c->lq(gp, 64, sp); // lq gp, 64(sp) + c->lq(s5, 48, sp); // lq s5, 48(sp) + c->lq(s4, 32, sp); // lq s4, 32(sp) + c->lq(s3, 16, sp); // lq s3, 16(sp) + //jr ra // jr ra + c->daddiu(sp, sp, 80); // daddiu sp, sp, 80 + goto end_of_function; // return + + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + end_of_function: + return c->gprs[v0].du64[0]; +} + +void link() { + cache.already_printed_exeeded_max_cache_tris = intern_from_c("*already-printed-exeeded-max-cache-tris*").c(); + cache.cheat_mode = intern_from_c("*cheat-mode*").c(); + cache.stdcon = intern_from_c("*stdcon*").c(); + cache.debug = intern_from_c("debug").c(); + cache.format = intern_from_c("format").c(); + cache.fake_scratchpad_data = intern_from_c("*fake-scratchpad-data*").c(); + gLinkedFunctionTable.reg("(method 14 collide-shape-prim-mesh)", execute, 256); +} + +} // namespace method_14_collide_shape_prim_mesh +} // namespace Mips2C + +//--------------------------MIPS2C--------------------- +#include "game/mips2c/mips2c_private.h" +#include "game/kernel/kscheme.h" +namespace Mips2C { +namespace method_13_collide_shape_prim_mesh { +struct Cache { + void* already_printed_exeeded_max_cache_tris; // *already-printed-exeeded-max-cache-tris* + void* cheat_mode; // *cheat-mode* + void* collide_work; // *collide-work* + void* stdcon; // *stdcon* + void* debug; // debug + void* format; // format + void* fake_scratchpad_data; +} cache; + +u64 execute(void* ctxt) { + auto* c = (ExecutionContext*)ctxt; + bool bc = false; + u32 call_addr = 0; + c->daddiu(sp, sp, -80); // daddiu sp, sp, -80 + c->sd(ra, 0, sp); // sd ra, 0(sp) + c->sd(fp, 8, sp); // sd fp, 8(sp) + c->mov64(fp, t9); // or fp, t9, r0 + c->sq(s3, 16, sp); // sq s3, 16(sp) + c->sq(s4, 32, sp); // sq s4, 32(sp) + c->sq(s5, 48, sp); // sq s5, 48(sp) + c->sq(gp, 64, sp); // sq gp, 64(sp) + c->mov64(s5, a0); // or s5, a0, r0 + c->mov64(gp, a1); // or gp, a1, r0 + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + c->lwu(s3, 68, s5); // lwu s3, 68(s5) + c->daddiu(v1, gp, 108); // daddiu v1, gp, 108 + c->lwu(a0, 4, gp); // lwu a0, 4(gp) + bc = c->sgpr64(s3) == c->sgpr64(s7); // beq s3, s7, L77 + // nop // sll r0, r0, 0 + if (bc) {goto block_15;} // branch non-likely + + c->addiu(a1, r0, 100); // addiu a1, r0, 100 + c->dsll(a2, a0, 1); // dsll a2, a0, 1 + bc = c->sgpr64(a0) == c->sgpr64(a1); // beq a0, a1, L75 + c->daddu(a0, a2, a0); // daddu a0, a2, a0 + if (bc) {goto block_11;} // branch non-likely + + c->dsll(a0, a0, 4); // dsll a0, a0, 4 + c->daddu(s4, v1, a0); // daddu s4, v1, a0 + c->mov64(a0, s3); // or a0, s3, r0 + c->lwu(v1, -4, a0); // lwu v1, -4(a0) + c->lwu(t9, 76, v1); // lwu t9, 76(v1) + c->lwu(v1, 0, s5); // lwu v1, 0(s5) + c->lwu(v1, 136, v1); // lwu v1, 136(v1) + c->lwu(v1, 112, v1); // lwu v1, 112(v1) + c->lb(a1, 8, s5); // lb a1, 8(s5) + c->dsll(a1, a1, 5); // dsll a1, a1, 5 + c->daddu(v1, v1, a1); // daddu v1, v1, a1 + c->lwu(v1, 28, v1); // lwu v1, 28(v1) + c->daddu(a1, r0, v1); // daddu a1, r0, v1 + c->load_symbol(v1, cache.collide_work); // lw v1, *collide-work*(s7) + c->daddiu(a2, v1, 48); // daddiu a2, v1, 48 + // c->lui(a3, 28672); // lui a3, 28672 + get_fake_spad_addr(a3, cache.fake_scratchpad_data, 0, c); + 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->load_symbol(t2, cache.collide_work); // lw t2, *collide-work*(s7) + // nop // sll r0, r0, 0 + c->lwu(a0, 4, gp); // lwu a0, 4(gp) + c->addiu(a1, r0, 460); // addiu a1, r0, 460 + c->lwu(v1, 0, gp); // lwu v1, 0(gp) + c->dsll32(a0, a0, 0); // dsll32 a0, a0, 0 + // nop // sll r0, r0, 0 + c->mov128_vf_gpr(vf1, a0); // qmtc2.i vf1, a0 + // nop // sll r0, r0, 0 + c->dsubu(a0, a1, v1); // dsubu a0, a1, v1 + c->dsll(t1, v1, 6); // dsll t1, v1, 6 + bc = ((s64)c->sgpr64(a0)) < 0; // bltz a0, L76 + c->daddiu(a2, s3, 28); // daddiu a2, s3, 28 + if (bc) {goto block_12;} // branch non-likely + + c->mov64(a0, v1); // or a0, v1, r0 + c->lwu(a3, 4, s3); // lwu a3, 4(s3) + c->daddiu(t3, gp, 4908); // daddiu t3, gp, 4908 + c->lq(t0, 16, t2); // lq t0, 16(t2) + c->daddu(t1, t3, t1); // daddu t1, t3, t1 + c->lq(t2, 32, t2); // lq t2, 32(t2) + // c->lui(t3, 28672); // lui t3, 28672 + get_fake_spad_addr(t3, cache.fake_scratchpad_data, 0, c); + c->lwu(t4, 8, gp); // lwu t4, 8(gp) + c->vsub(DEST::zw, vf1, vf0, vf0); // vsub.zw vf1, vf0, vf0 + // nop // sll r0, r0, 0 + + block_4: + bc = c->sgpr64(a3) == 0; // beq a3, r0, L74 + c->lbu(t5, 0, a2); // lbu t5, 0(a2) + if (bc) {goto block_9;} // branch non-likely + + c->daddiu(a3, a3, -1); // daddiu a3, a3, -1 + c->lbu(t6, 1, a2); // lbu t6, 1(a2) + c->dsll(t8, t5, 5); // dsll t8, t5, 5 + c->lbu(t5, 2, a2); // lbu t5, 2(a2) + c->dsll(t7, t6, 5); // dsll t7, t6, 5 + c->daddu(t6, t8, t3); // daddu t6, t8, t3 + c->dsll(t5, t5, 5); // dsll t5, t5, 5 + // nop // sll r0, r0, 0 + c->daddu(t7, t7, t3); // daddu t7, t7, t3 + c->lq(t9, 16, t6); // lq t9, 16(t6) + c->daddu(t5, t5, t3); // daddu t5, t5, t3 + c->lq(s3, 16, t7); // lq s3, 16(t7) + // nop // sll r0, r0, 0 + c->lq(t8, 16, t5); // lq t8, 16(t5) + c->pminw(ra, t9, s3); // pminw ra, t9, s3 + c->mfc1(r0, f31); // mfc1 r0, f31 + c->pmaxw(t9, t9, s3); // pmaxw t9, t9, s3 + c->mfc1(r0, f31); // mfc1 r0, f31 + c->pminw(ra, ra, t8); // pminw ra, ra, t8 + c->mfc1(r0, f31); // mfc1 r0, f31 + c->pmaxw(t8, t9, t8); // pmaxw t8, t9, t8 + c->mfc1(r0, f31); // mfc1 r0, f31 + c->pcgtw(t9, ra, t2); // pcgtw t9, ra, t2 + c->mfc1(r0, f31); // mfc1 r0, f31 + c->pcgtw(ra, t0, t8); // pcgtw ra, t0, t8 + c->lwu(t8, 4, a2); // lwu t8, 4(a2) + c->por(t9, t9, ra); // por t9, t9, ra + c->lq(t6, 0, t6); // lq t6, 0(t6) + c->ppach(t9, r0, t9); // ppach t9, r0, t9 + c->lq(t7, 0, t7); // lq t7, 0(t7) + c->dsll(t9, t9, 16); // dsll t9, t9, 16 + c->lq(t5, 0, t5); // lq t5, 0(t5) + bc = c->sgpr64(t9) != 0; // bne t9, r0, L73 + c->daddiu(a2, a2, 8); // daddiu a2, a2, 8 + if (bc) {goto block_4;} // branch non-likely + + bc = c->sgpr64(v1) == c->sgpr64(a1); // beq v1, a1, L76 + c->sqc2(vf1, 48, t1); // sqc2 vf1, 48(t1) + if (bc) {goto block_12;} // branch non-likely + + c->and_(t9, t8, t4); // and t9, t8, t4 + c->sw(t8, 48, t1); // sw t8, 48(t1) + bc = c->sgpr64(t9) != 0; // bne t9, r0, L73 + c->sq(t6, 0, t1); // sq t6, 0(t1) + if (bc) {goto block_4;} // branch non-likely + + c->daddiu(v1, v1, 1); // daddiu v1, v1, 1 + c->sq(t7, 16, t1); // sq t7, 16(t1) + // nop // sll r0, r0, 0 + c->sq(t5, 32, t1); // sq t5, 32(t1) + //beq r0, r0, L73 // beq r0, r0, L73 + c->daddiu(t1, t1, 64); // daddiu t1, t1, 64 + goto block_4; // branch always + + + block_9: + c->dsubu(a3, v1, a0); // dsubu a3, v1, a0 + c->lwu(t0, 4, gp); // lwu t0, 4(gp) + bc = c->sgpr64(a3) == 0; // beq a3, r0, L77 + c->lq(a1, 12, s5); // lq a1, 12(s5) + if (bc) {goto block_15;} // branch non-likely + + // nop // sll r0, r0, 0 + c->lq(a2, 28, s5); // lq a2, 28(s5) + // nop // sll r0, r0, 0 + c->sq(r0, 32, s4); // sq r0, 32(s4) + // nop // sll r0, r0, 0 + c->sh(a3, 42, s4); // sh a3, 42(s4) + // nop // sll r0, r0, 0 + c->sw(gp, 32, s4); // sw gp, 32(s4) + // nop // sll r0, r0, 0 + c->sw(s5, 36, s4); // sw s5, 36(s4) + // nop // sll r0, r0, 0 + c->sh(a0, 40, s4); // sh a0, 40(s4) + c->daddiu(a0, t0, 1); // daddiu a0, t0, 1 + c->sq(a1, 0, s4); // sq a1, 0(s4) + // nop // sll r0, r0, 0 + c->sq(a2, 16, s4); // sq a2, 16(s4) + // nop // sll r0, r0, 0 + c->sw(a0, 4, gp); // sw a0, 4(gp) + //beq r0, r0, L77 // beq r0, r0, L77 + c->sw(v1, 0, gp); // sw v1, 0(gp) + goto block_15; // branch always + + + block_11: + c->load_symbol(t9, cache.format); // lw t9, format(s7) + c->addiu(a0, r0, 0); // addiu a0, r0, 0 + // daddiu a1, fp, L306 // daddiu a1, fp, L306 + 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 + printf("too many prims\n"); + //beq r0, r0, L77 // beq r0, r0, L77 + // nop // sll r0, r0, 0 + goto block_15; // branch always + + + block_12: + c->load_symbol(v1, cache.already_printed_exeeded_max_cache_tris);// lw v1, *already-printed-exeeded-max-cache-tris*(s7) + bc = c->sgpr64(s7) != c->sgpr64(v1); // bne s7, v1, L77 + c->mov64(v1, s7); // or v1, s7, r0 + if (bc) {goto block_15;} // branch non-likely + + c->daddiu(v1, s7, 8); // daddiu v1, s7, #t + // c->store_symbol(v1, cache.already_printed_exeeded_max_cache_tris);// sw v1, *already-printed-exeeded-max-cache-tris*(s7) + // c->load_symbol_addr(v1, cache.debug); // daddiu v1, s7, debug + c->load_symbol(a0, cache.cheat_mode); // lw a0, *cheat-mode*(s7) + bc = c->sgpr64(a0) != c->sgpr64(v1); // bne a0, v1, L77 + c->mov64(v1, s7); // or v1, s7, r0 + if (bc) {goto block_15;} // branch non-likely + + c->load_symbol(t9, cache.format); // lw t9, format(s7) + c->load_symbol(a0, cache.stdcon); // lw a0, *stdcon*(s7) + // daddiu a1, fp, L305 // daddiu a1, fp, L305 + 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 + printf("too many tris\n"); + c->mov64(v1, v0); // or v1, v0, r0 + + block_15: + c->gprs[v0].du64[0] = 0; // or v0, r0, r0 + c->ld(ra, 0, sp); // ld ra, 0(sp) + c->ld(fp, 8, sp); // ld fp, 8(sp) + c->lq(gp, 64, sp); // lq gp, 64(sp) + c->lq(s5, 48, sp); // lq s5, 48(sp) + c->lq(s4, 32, sp); // lq s4, 32(sp) + c->lq(s3, 16, sp); // lq s3, 16(sp) + //jr ra // jr ra + c->daddiu(sp, sp, 80); // daddiu sp, sp, 80 + goto end_of_function; // return + + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + end_of_function: + return c->gprs[v0].du64[0]; +} + +void link() { + cache.already_printed_exeeded_max_cache_tris = intern_from_c("*already-printed-exeeded-max-cache-tris*").c(); + cache.cheat_mode = intern_from_c("*cheat-mode*").c(); + cache.collide_work = intern_from_c("*collide-work*").c(); + cache.stdcon = intern_from_c("*stdcon*").c(); + cache.debug = intern_from_c("debug").c(); + cache.format = intern_from_c("format").c(); + cache.fake_scratchpad_data = intern_from_c("*fake-scratchpad-data*").c(); + gLinkedFunctionTable.reg("(method 13 collide-shape-prim-mesh)", execute, 128); +} + +} // namespace method_13_collide_shape_prim_mesh +} // namespace Mips2C + +//--------------------------MIPS2C--------------------- +#include "game/mips2c/mips2c_private.h" +#include "game/kernel/kscheme.h" +namespace Mips2C { +namespace method_30_collide_cache { +u64 execute(void* ctxt) { + auto* c = (ExecutionContext*)ctxt; + bool bc = false; + // u32 call_addr = 0; + bool cop1_bc = false; + // nop // sll r0, r0, 0 + c->daddiu(a0, a0, 4908); // daddiu a0, a0, 4908 + c->lhu(a3, 40, a2); // lhu a3, 40(a2) + // nop // sll r0, r0, 0 + c->lhu(v1, 42, a2); // lhu v1, 42(a2) + c->dsll(a2, a3, 6); // dsll a2, a3, 6 + c->lwc1(f4, 0, a1); // lwc1 f4, 0(a1) + c->daddu(a0, a0, a2); // daddu a0, a0, a2 + // nop // sll r0, r0, 0 + + block_1: + bc = c->sgpr64(v1) == 0; // beq v1, r0, L56 + c->lqc2(vf1, 0, a0); // lqc2 vf1, 0(a0) + if (bc) {goto block_9;} // branch non-likely + + c->daddiu(v1, v1, -1); // daddiu v1, v1, -1 + c->lqc2(vf2, 16, a0); // lqc2 vf2, 16(a0) + c->vsub(DEST::xyzw, vf5, vf2, vf1); // vsub.xyzw vf5, vf2, vf1 + c->lqc2(vf3, 32, a0); // lqc2 vf3, 32(a0) + + c->vsub(DEST::xyzw, vf6, vf2, vf3); // vsub.xyzw vf6, vf2, vf3 + c->lqc2(vf4, 16, a1); // lqc2 vf4, 16(a1) + // nop // sll r0, r0, 0 + c->lqc2(vf20, 32, a1); // lqc2 vf20, 32(a1) + c->vsub(DEST::xyzw, vf7, vf2, vf4); // vsub.xyzw vf7, vf2, vf4 + c->lwu(a2, 48, a0); // lwu a2, 48(a0) + c->vmul(DEST::xyzw, vf8, vf20, vf20); // vmul.xyzw vf8, vf20, vf20 + c->lwu(a3, 4, a1); // lwu a3, 4(a1) + c->vopmula(vf6, vf5); // vopmula.xyz acc, vf6, vf5 + c->daddiu(a0, a0, 64); // daddiu a0, a0, 64 + c->vopmsub(vf9, vf5, vf6); // vopmsub.xyz vf9, vf5, vf6 + c->and_(a2, a2, a3); // and a2, a2, a3 + bc = c->sgpr64(a2) != 0; // bne a2, r0, L55 + c->vadd_bc(DEST::x, BC::y, vf8, vf8, vf8); // vaddy.x vf8, vf8, vf8 + if (bc) {goto block_1;} // branch non-likely + + c->vmul(DEST::xyzw, vf10, vf9, vf9); // vmul.xyzw vf10, vf9, vf9 + // nop // sll r0, r0, 0 + c->vmul(DEST::xyzw, vf7, vf7, vf9); // vmul.xyzw vf7, vf7, vf9 + // nop // sll r0, r0, 0 + c->vmul(DEST::xyzw, vf11, vf20, vf9); // vmul.xyzw vf11, vf20, vf9 + + // nop // sll r0, r0, 0 + c->vadd_bc(DEST::x, BC::z, vf8, vf8, vf8); // vaddz.x vf8, vf8, vf8 + // nop // sll r0, r0, 0 + c->vadd_bc(DEST::x, BC::y, vf10, vf10, vf10); // vaddy.x vf10, vf10, vf10 + // nop // sll r0, r0, 0 + c->vadd_bc(DEST::x, BC::y, vf7, vf7, vf7); // vaddy.x vf7, vf7, vf7 + // nop // sll r0, r0, 0 + c->vadd_bc(DEST::x, BC::y, vf11, vf11, vf11); // vaddy.x vf11, vf11, vf11 + // nop // sll r0, r0, 0 + c->vadd_bc(DEST::x, BC::z, vf10, vf10, vf10); // vaddz.x vf10, vf10, vf10 + // nop // sll r0, r0, 0 + c->vadd_bc(DEST::x, BC::z, vf7, vf7, vf7); // vaddz.x vf7, vf7, vf7 + // nop // sll r0, r0, 0 + c->vadd_bc(DEST::x, BC::z, vf11, vf11, vf11); // vaddz.x vf11, vf11, vf11 + // nop // sll r0, r0, 0 + c->vrsqrt(vf0, BC::w, vf10, BC::x); // vrsqrt Q, vf0.w, vf10.x + // nop // sll r0, r0, 0 + c->mov128_gpr_vf(a2, vf11); // qmfc2.i a2, vf11 + // nop // sll r0, r0, 0 + c->mov128_gpr_vf(a3, vf7); // qmfc2.i a3, vf7 + c->mtc1(f2, a2); // mtc1 f2, a2 + c->mtc1(f1, a3); // mtc1 f1, a3 + c->divs(f3, f1, f2); // div.s f3, f1, f2 + c->vmove(DEST::w, vf9, vf0); // vmove.w vf9, vf0 + c->sll(a2, a2, 1); // sll a2, a2, 1 + bc = c->sgpr64(a2) == 0; // beq a2, r0, L55 + // nop // sll r0, r0, 0 + if (bc) {goto block_1;} // branch non-likely + + c->vwaitq(); // vwaitq + // nop // sll r0, r0, 0 + c->vmulq(DEST::xyz, vf9, vf9); // vmulq.xyz vf9, vf9, Q + c->mfc1(a2, f3); // mfc1 a2, f3 + bc = ((s64)c->sgpr64(a2)) < 0; // bltz a2, L55 + // nop // sll r0, r0, 0 + if (bc) {goto block_1;} // branch non-likely + + c->mov128_vf_gpr(vf12, a2); // qmtc2.i vf12, a2 + // nop // sll r0, r0, 0 + cop1_bc = c->fprs[f4] <= c->fprs[f3]; // c.le.s f4, f3 + // nop // sll r0, r0, 0 + bc = cop1_bc; // bc1t L55 + c->vmula_bc(DEST::xyzw, BC::x, vf20, vf12); // vmulax.xyzw acc, vf20, vf12 + if (bc) {goto block_1;} // branch non-likely + + c->vmadd_bc(DEST::xyzw, BC::w, vf13, vf4, vf0); // vmaddw.xyzw vf13, vf4, vf0 + // nop // sll r0, r0, 0 + c->vsub(DEST::xyzw, vf14, vf2, vf13); // vsub.xyzw vf14, vf2, vf13 + // nop // sll r0, r0, 0 + c->vsub(DEST::xyzw, vf15, vf13, vf3); // vsub.xyzw vf15, vf13, vf3 + // nop // sll r0, r0, 0 + c->vsub(DEST::xyzw, vf16, vf13, vf1); // vsub.xyzw vf16, vf13, vf1 + // nop // sll r0, r0, 0 + c->vopmula(vf6, vf14); // vopmula.xyz acc, vf6, vf14 + // nop // sll r0, r0, 0 + c->vmul(DEST::xyzw, vf21, vf20, vf9); // vmul.xyzw vf21, vf20, vf9 + // nop // sll r0, r0, 0 + c->vopmsub(vf17, vf14, vf6); // vopmsub.xyz vf17, vf14, vf6 + // nop // sll r0, r0, 0 + c->vadd_bc(DEST::x, BC::y, vf21, vf21, vf21); // vaddy.x vf21, vf21, vf21 + // nop // sll r0, r0, 0 + c->vopmula(vf14, vf5); // vopmula.xyz acc, vf14, vf5 + // nop // sll r0, r0, 0 + c->vadd_bc(DEST::x, BC::z, vf21, vf21, vf21); // vaddz.x vf21, vf21, vf21 + // nop // sll r0, r0, 0 + c->mtc1(f6, r0); // mtc1 f6, r0 + // nop // sll r0, r0, 0 + c->vopmsub(vf18, vf5, vf14); // vopmsub.xyz vf18, vf5, vf14 + // nop // sll r0, r0, 0 + c->mov128_gpr_vf(a2, vf21); // qmfc2.i a2, vf21 + // nop // sll r0, r0, 0 + c->mtc1(f5, a2); // mtc1 f5, a2 + // nop // sll r0, r0, 0 + cop1_bc = c->fprs[f6] <= c->fprs[f5]; // c.le.s f6, f5 + // nop // sll r0, r0, 0 + bc = cop1_bc; // bc1t L55 + c->vopmula(vf15, vf16); // vopmula.xyz acc, vf15, vf16 + if (bc) {goto block_1;} // branch non-likely + + c->vopmsub(vf19, vf16, vf15); // vopmsub.xyz vf19, vf16, vf15 + // nop // sll r0, r0, 0 + c->vmul(DEST::xyz, vf17, vf17, vf9); // vmul.xyz vf17, vf17, vf9 + // nop // sll r0, r0, 0 + c->vmul(DEST::xyz, vf18, vf18, vf9); // vmul.xyz vf18, vf18, vf9 + // nop // sll r0, r0, 0 + c->vmul(DEST::xyz, vf19, vf19, vf9); // vmul.xyz vf19, vf19, vf9 + // nop // sll r0, r0, 0 + c->vadd_bc(DEST::y, BC::x, vf17, vf17, vf17); // vaddx.y vf17, vf17, vf17 + // nop // sll r0, r0, 0 + c->vadd_bc(DEST::y, BC::x, vf18, vf18, vf18); // vaddx.y vf18, vf18, vf18 + // nop // sll r0, r0, 0 + c->vadd_bc(DEST::y, BC::x, vf19, vf19, vf19); // vaddx.y vf19, vf19, vf19 + // nop // sll r0, r0, 0 + c->vadd_bc(DEST::y, BC::z, vf17, vf17, vf17); // vaddz.y vf17, vf17, vf17 + // nop // sll r0, r0, 0 + c->vadd_bc(DEST::y, BC::z, vf18, vf18, vf18); // vaddz.y vf18, vf18, vf18 + // nop // sll r0, r0, 0 + c->vadd_bc(DEST::y, BC::z, vf19, vf19, vf19); // vaddz.y vf19, vf19, vf19 + // nop // sll r0, r0, 0 + c->mov128_gpr_vf(a3, vf17); // qmfc2.i a3, vf17 + // nop // sll r0, r0, 0 + c->mov128_gpr_vf(t0, vf18); // qmfc2.i t0, vf18 + // nop // sll r0, r0, 0 + c->mov128_gpr_vf(a2, vf19); // qmfc2.i a2, vf19 + // nop // sll r0, r0, 0 + c->or_(a3, a3, t0); // or a3, a3, t0 + // nop // sll r0, r0, 0 + c->or_(a3, a3, a2); // or a3, a3, a2 + c->lwu(a2, 8, a1); // lwu a2, 8(a1) + bc = ((s64)c->sgpr64(a3)) < 0; // bltz a3, L55 + c->lwu(a3, -16, a0); // lwu a3, -16(a0) + if (bc) {goto block_1;} // branch non-likely + + // nop // sll r0, r0, 0 + c->swc1(f3, 0, a1); // swc1 f3, 0(a1) + c->movs(f4, f3); // mov.s f4, f3 + c->sqc2(vf1, 0, a2); // sqc2 vf1, 0(a2) + // nop // sll r0, r0, 0 + c->sqc2(vf2, 16, a2); // sqc2 vf2, 16(a2) + // nop // sll r0, r0, 0 + c->sqc2(vf3, 32, a2); // sqc2 vf3, 32(a2) + // nop // sll r0, r0, 0 + c->sqc2(vf9, 64, a2); // sqc2 vf9, 64(a2) + // nop // sll r0, r0, 0 + c->sw(a3, 80, a2); // sw a3, 80(a2) + //beq r0, r0, L55 // beq r0, r0, L55 + c->sqc2(vf13, 48, a2); // sqc2 vf13, 48(a2) + goto block_1; // branch always + + + block_9: + 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 30 collide-cache)", execute, 128); +} + +} // namespace method_30_collide_cache +} // namespace Mips2C + +//--------------------------MIPS2C--------------------- +#include "game/mips2c/mips2c_private.h" +#include "game/kernel/kscheme.h" +namespace Mips2C { +namespace method_9_collide_cache_prim { +struct Cache { + void* moving_sphere_triangle_intersect; // moving-sphere-triangle-intersect +} cache; + +u64 execute(void* ctxt) { + auto* c = (ExecutionContext*)ctxt; + bool bc = false; + u32 call_addr = 0; + bool cop1_bc = false; + c->daddiu(sp, sp, -224); // daddiu sp, sp, -224 + c->sd(ra, 0, sp); // sd ra, 0(sp) + c->sd(fp, 8, sp); // sd fp, 8(sp) + c->mov64(fp, t9); // or fp, t9, r0 + c->sq(s1, 128, sp); // sq s1, 128(sp) + c->sq(s2, 144, sp); // sq s2, 144(sp) + c->sq(s3, 160, sp); // sq s3, 160(sp) + c->sq(s4, 176, sp); // sq s4, 176(sp) + c->sq(s5, 192, sp); // sq s5, 192(sp) + c->sq(gp, 208, sp); // sq gp, 208(sp) + c->mov64(gp, a1); // or gp, a1, r0 + c->mov64(s5, a2); // or s5, a2, r0 + c->mov64(s4, a3); // or s4, a3, r0 + c->daddiu(s3, sp, 16); // daddiu s3, sp, 16 + // nop // sll r0, r0, 0 + c->mtc1(f0, r0); // mtc1 f0, r0 + c->sw(t1, 8, s3); // sw t1, 8(s3) + c->mtc1(f1, t0); // mtc1 f1, t0 + c->lhu(a1, 40, a0); // lhu a1, 40(a0) + // nop // sll r0, r0, 0 + c->lwu(v1, 32, a0); // lwu v1, 32(a0) + cop1_bc = c->fprs[f0] <= c->fprs[f1]; // c.le.s f0, f1 + c->dsll(a1, a1, 6); // dsll a1, a1, 6 + bc = cop1_bc; // bc1t L37 + c->daddiu(v1, v1, 4908); // daddiu v1, v1, 4908 + if (bc) {goto block_2;} // branch non-likely + + c->fprs[f1] = 2.0; // lwc1 f1, L310(fp) + // nop // sll r0, r0, 0 + + block_2: + c->daddu(s2, v1, a1); // daddu s2, v1, a1 + c->swc1(f1, 0, s3); // swc1 f1, 0(s3) + // nop // sll r0, r0, 0 + c->lhu(s1, 42, a0); // lhu s1, 42(a0) + // nop // sll r0, r0, 0 + c->swc1(f1, 4, s3); // swc1 f1, 4(s3) + + block_3: + bc = c->sgpr64(s1) == 0; // beq s1, r0, L40 + c->daddiu(s1, s1, -1); // daddiu s1, s1, -1 + if (bc) {goto block_14;} // branch non-likely + + c->load_symbol(t9, cache.moving_sphere_triangle_intersect);// lw t9, moving-sphere-triangle-intersect(s7) + c->mov64(a0, s5); // or a0, s5, r0 + c->mov64(a1, s4); // or a1, s4, r0 + c->lwc1(f0, 12, s5); // lwc1 f0, 12(s5) + c->mfc1(a2, f0); // mfc1 a2, f0 + c->daddu(a3, r0, s2); // daddu a3, r0, s2 + c->daddiu(t0, s3, 64); // daddiu t0, s3, 64 + c->daddiu(t1, s3, 80); // daddiu t1, s3, 80 + call_addr = c->gprs[t9].du32[0]; // function call: + c->sll(v0, ra, 0); // sll v0, ra, 0 + c->jalr(call_addr); // jalr ra, t9 + c->mov64(v1, v0); // or v1, v0, r0 + // nop // sll r0, r0, 0 + c->mtc1(f0, r0); // mtc1 f0, r0 + c->lqc2(vf1, 0, s4); // lqc2 vf1, 0(s4) + c->mtc1(f2, v1); // mtc1 f2, v1 + c->lwc1(f1, 0, s3); // lwc1 f1, 0(s3) + cop1_bc = c->fprs[f2] < c->fprs[f0]; // c.lt.s f2, f0 + c->lqc2(vf2, 80, s3); // lqc2 vf2, 80(s3) + if (cop1_bc) { // bc1tl L38 + c->daddiu(s2, s2, 64); // daddiu s2, s2, 64 + goto block_3; + } + + // block_6: + cop1_bc = c->fprs[f1] <= c->fprs[f2]; // c.le.s f1, f2 + c->lqc2(vf3, 64, s3); // lqc2 vf3, 64(s3) + if (cop1_bc) { // bc1tl L38 + c->daddiu(s2, s2, 64); // daddiu s2, s2, 64 + goto block_3; + } + + // block_8: + c->vmul(DEST::xyzw, vf5, vf1, vf2); // vmul.xyzw vf5, vf1, vf2 + c->lqc2(vf4, 0, s5); // lqc2 vf4, 0(s5) + // nop // sll r0, r0, 0 + c->lwu(v1, 8, s3); // lwu v1, 8(s3) + c->vsub(DEST::xyzw, vf7, vf4, vf3); // vsub.xyzw vf7, vf4, vf3 + c->andi(v1, v1, 1); // andi v1, v1, 1 + bc = c->sgpr64(v1) == 0; // beq v1, r0, L39 + c->vadd_bc(DEST::x, BC::y, vf5, vf5, vf5); // vaddy.x vf5, vf5, vf5 + if (bc) {goto block_13;} // branch non-likely + + c->vmul(DEST::xyzw, vf6, vf7, vf2); // vmul.xyzw vf6, vf7, vf2 + // nop // sll r0, r0, 0 + c->vadd_bc(DEST::x, BC::z, vf5, vf5, vf5); // vaddz.x vf5, vf5, vf5 + // nop // sll r0, r0, 0 + c->vadd_bc(DEST::x, BC::y, vf6, vf6, vf6); // vaddy.x vf6, vf6, vf6 + // nop // sll r0, r0, 0 + c->mov128_gpr_vf(v1, vf5); // qmfc2.i v1, vf5 + // nop // sll r0, r0, 0 + c->mtc1(f3, v1); // mtc1 f3, v1 + // nop // sll r0, r0, 0 + cop1_bc = c->fprs[f0] <= c->fprs[f3]; // c.le.s f0, f3 + // nop // sll r0, r0, 0 + if (cop1_bc) { // bc1tl L38 + c->daddiu(s2, s2, 64); // daddiu s2, s2, 64 + goto block_3; + } + + // block_11: + c->vadd_bc(DEST::x, BC::z, vf6, vf6, vf6); // vaddz.x vf6, vf6, vf6 + // nop // sll r0, r0, 0 + c->mov128_gpr_vf(v1, vf6); // qmfc2.i v1, vf6 + // nop // sll r0, r0, 0 + c->mtc1(f4, v1); // mtc1 f4, v1 + // nop // sll r0, r0, 0 + cop1_bc = c->fprs[f4] < c->fprs[f0]; // c.lt.s f4, f0 + // nop // sll r0, r0, 0 + if (cop1_bc) { // bc1tl L38 + c->daddiu(s2, s2, 64); // daddiu s2, s2, 64 + goto block_3; + } + + block_13: + c->lqc2(vf8, 0, s2); // lqc2 vf8, 0(s2) + c->lqc2(vf9, 16, s2); // lqc2 vf9, 16(s2) + c->lqc2(vf10, 32, s2); // lqc2 vf10, 32(s2) + c->lwu(v1, 48, s2); // lwu v1, 48(s2) + c->swc1(f2, 0, s3); // swc1 f2, 0(s3) + c->sqc2(vf3, 48, gp); // sqc2 vf3, 48(gp) + c->sqc2(vf2, 64, gp); // sqc2 vf2, 64(gp) + c->sqc2(vf8, 0, gp); // sqc2 vf8, 0(gp) + c->sqc2(vf9, 16, gp); // sqc2 vf9, 16(gp) + c->sqc2(vf10, 32, gp); // sqc2 vf10, 32(gp) + c->sw(v1, 80, gp); // sw v1, 80(gp) + //beq r0, r0, L38 // beq r0, r0, L38 + c->daddiu(s2, s2, 64); // daddiu s2, s2, 64 + goto block_3; // branch always + + + block_14: + c->lwc1(f1, 0, s3); // lwc1 f1, 0(s3) + c->lwc1(f5, 4, s3); // lwc1 f5, 4(s3) + cop1_bc = c->fprs[f1] == c->fprs[f5]; // c.eq.s f1, f5 + if (!cop1_bc) { // bc1fl L41 + c->mfc1(v0, f1); // mfc1 v0, f1 + goto block_17; + } + + // block_16: + c->lw_float_constant(v0, 0xccbebc20); // lw v0, L313(fp) -100000000.0 + + block_17: + c->ld(ra, 0, sp); // ld ra, 0(sp) + c->ld(fp, 8, sp); // ld fp, 8(sp) + c->lq(gp, 208, sp); // lq gp, 208(sp) + c->lq(s5, 192, sp); // lq s5, 192(sp) + c->lq(s4, 176, sp); // lq s4, 176(sp) + c->lq(s3, 160, sp); // lq s3, 160(sp) + c->lq(s2, 144, sp); // lq s2, 144(sp) + c->lq(s1, 128, sp); // lq s1, 128(sp) + //jr ra // jr ra + c->daddiu(sp, sp, 224); // daddiu sp, sp, 224 + 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.moving_sphere_triangle_intersect = intern_from_c("moving-sphere-triangle-intersect").c(); + gLinkedFunctionTable.reg("(method 9 collide-cache-prim)", execute, 512); +} + +} // namespace method_9_collide_cache_prim +} // namespace Mips2C + +//--------------------------MIPS2C--------------------- +#include "game/mips2c/mips2c_private.h" +#include "game/kernel/kscheme.h" +namespace Mips2C { +namespace method_10_collide_cache_prim { +struct Cache { + void* moving_sphere_sphere_intersect; // moving-sphere-sphere-intersect +} cache; + +u64 execute(void* ctxt) { + auto* c = (ExecutionContext*)ctxt; + bool bc = false; + u32 call_addr = 0; + bool cop1_bc = false; + c->daddiu(sp, sp, -128); // daddiu sp, sp, -128 + c->sd(ra, 0, sp); // sd ra, 0(sp) + c->sd(fp, 8, sp); // sd fp, 8(sp) + c->mov64(fp, t9); // or fp, t9, r0 + c->sq(s1, 32, sp); // sq s1, 32(sp) + c->sq(s2, 48, sp); // sq s2, 48(sp) + c->sq(s3, 64, sp); // sq s3, 64(sp) + c->sq(s4, 80, sp); // sq s4, 80(sp) + c->sq(s5, 96, sp); // sq s5, 96(sp) + c->sq(gp, 112, sp); // sq gp, 112(sp) + c->mov64(s3, a0); // or s3, a0, r0 + c->mov64(gp, a1); // or gp, a1, r0 + c->mov64(s5, a3); // or s5, a3, r0 + c->mov64(s2, t0); // or s2, t0, r0 + c->mov64(s4, t1); // or s4, t1, r0 + c->daddiu(s1, sp, 16); // daddiu s1, sp, 16 + c->load_symbol(t9, cache.moving_sphere_sphere_intersect);// lw t9, moving-sphere-sphere-intersect(s7) + c->mov64(a0, a2); // or a0, a2, r0 + c->mov64(a1, s5); // or a1, s5, r0 + c->daddu(a2, r0, s3); // daddu a2, r0, s3 + c->mov64(a3, s1); // or a3, s1, r0 + call_addr = c->gprs[t9].du32[0]; // function call: + c->sll(v0, ra, 0); // sll v0, ra, 0 + c->jalr(call_addr); // jalr ra, t9 + c->mtc1(f3, v0); // mtc1 f3, v0 + c->fprs[f4] = -100000000.0; // lwc1 f4, L313(fp) + c->mtc1(f0, r0); // mtc1 f0, r0 + c->lqc2(vf4, 0, s1); // lqc2 vf4, 0(s1) + c->movs(f1, f3); // mov.s f1, f3 + c->lqc2(vf5, 0, s3); // lqc2 vf5, 0(s3) + cop1_bc = c->fprs[f1] < c->fprs[f0]; // c.lt.s f1, f0 + c->vmove(DEST::xyzw, vf1, vf0); // vmove.xyzw vf1, vf0 + bc = cop1_bc; // bc1t L35 + c->mtc1(f2, s2); // mtc1 f2, s2 + if (bc) {goto block_11;} // branch non-likely + + cop1_bc = c->fprs[f2] < c->fprs[f0]; // c.lt.s f2, f0 + c->vsub(DEST::xyz, vf1, vf4, vf5); // vsub.xyz vf1, vf4, vf5 + bc = cop1_bc; // bc1t L32 + c->lwu(v1, 36, s3); // lwu v1, 36(s3) + if (bc) {goto block_4;} // branch non-likely + + cop1_bc = c->fprs[f2] <= c->fprs[f1]; // c.le.s f2, f1 + c->andi(a0, s4, 1); // andi a0, s4, 1 + if (cop1_bc) { // bc1tl L35 + c->movs(f3, f4); // mov.s f3, f4 + goto block_11; + } + + block_4: + bc = c->sgpr64(a0) == 0; // beq a0, r0, L33 + c->lqc2(vf15, 0, s5); // lqc2 vf15, 0(s5) + if (bc) {goto block_7;} // branch non-likely + + c->vmul(DEST::xyzw, vf16, vf15, vf1); // vmul.xyzw vf16, vf15, vf1 + c->vadd_bc(DEST::y, BC::x, vf16, vf16, vf16); // vaddx.y vf16, vf16, vf16 + c->vadd_bc(DEST::y, BC::z, vf16, vf16, vf16); // vaddz.y vf16, vf16, vf16 + c->mov128_gpr_vf(a0, vf16); // qmfc2.i a0, vf16 + if (((s64)c->sgpr64(a0)) >= 0) { // bgezl a0, L35 + c->movs(f3, f4); // mov.s f3, f4 + goto block_11; + } + + block_7: + //daddiu a0, fp, L299 // daddiu a0, fp, L299 + //L299: + // .word 0x0 + // .word 0x45800000 + // .word 0x0 + // .word 0x3f800000 + + // .word 0x0 + // .word 0xc5800000 + // .word 0x45800000 + // .word 0x3f800000 + + // .word 0x0 + // .word 0xc5800000 + // .word 0xc5800000 + // .word 0x3f800000 + // nop // sll r0, r0, 0 + c->vmul(DEST::xyzw, vf12, vf1, vf1); // vmul.xyzw vf12, vf1, vf1 + c->sqc2(vf4, 48, gp); // sqc2 vf4, 48(gp) + c->vmula_bc(DEST::w, BC::x, vf0, vf12); // vmulax.w acc, vf0, vf12 + //c->lqc2(vf9, 0, a0); // lqc2 vf9, 0(a0) + c->vfs[vf9].du32[0] = 0; + c->vfs[vf9].du32[1] = 0x45800000; + c->vfs[vf9].du32[2] = 0; + c->vfs[vf9].du32[3] = 0x3f800000; + + c->vmadda_bc(DEST::w, BC::y, vf0, vf12); // vmadday.w acc, vf0, vf12 + // c->lqc2(vf10, 16, a0); // lqc2 vf10, 16(a0) + c->vfs[vf10].du32[0] = 0; + c->vfs[vf10].du32[1] = 0xc5800000; + c->vfs[vf10].du32[2] = 0x45800000; + c->vfs[vf10].du32[3] = 0x3f800000; + c->vmadd_bc(DEST::w, BC::z, vf12, vf0, vf12); // vmaddz.w vf12, vf0, vf12 + // c->lqc2(vf11, 32, a0); // lqc2 vf11, 32(a0) + c->vfs[vf11].du32[0] = 0; + c->vfs[vf11].du32[1] = 0xc5800000; + c->vfs[vf11].du32[2] = 0xc5800000; + c->vfs[vf11].du32[3] = 0x3f800000; + c->vrsqrt(vf0, BC::w, vf12, BC::w); // vrsqrt Q, vf0.w, vf12.w + // nop // sll r0, r0, 0 + c->vwaitq(); // vwaitq + c->lwu(v1, 68, v1); // lwu v1, 68(v1) + c->vmulq(DEST::xyz, vf1, vf1); // vmulq.xyz vf1, vf1, Q + // nop // sll r0, r0, 0 + c->vmul(DEST::xyzw, vf14, vf1, vf1); // vmul.xyzw vf14, vf1, vf1 + c->sqc2(vf1, 64, gp); // sqc2 vf1, 64(gp) + c->vabs(DEST::xyzw, vf13, vf1); // vabs.xyzw vf13, vf1 + c->sw(v1, 80, gp); // sw v1, 80(gp) + c->vmove(DEST::xyzw, vf2, vf0); // vmove.xyzw vf2, vf0 + // nop // sll r0, r0, 0 + c->vadd_bc(DEST::x, BC::y, vf14, vf14, vf14); // vaddy.x vf14, vf14, vf14 + c->mov128_gpr_vf(v1, vf13); // qmfc2.i v1, vf13 + if (((s64)c->sgpr64(v1)) == ((s64)0)) { // beql v1, r0, L34 + c->vadd_bc(DEST::x, BC::z, vf2, vf0, vf1); // vaddz.x vf2, vf0, vf1 + goto block_10; + } + + // block_9: + c->vsub_bc(DEST::x, BC::y, vf2, vf0, vf1); // vsuby.x vf2, vf0, vf1 + // nop // sll r0, r0, 0 + c->vrsqrt(vf0, BC::w, vf14, BC::x); // vrsqrt Q, vf0.w, vf14.x + // nop // sll r0, r0, 0 + c->vadd_bc(DEST::y, BC::x, vf2, vf0, vf1); // vaddx.y vf2, vf0, vf1 + // nop // sll r0, r0, 0 + c->vwaitq(); // vwaitq + // nop // sll r0, r0, 0 + c->vmulq(DEST::xy, vf2, vf2); // vmulq.xy vf2, vf2, Q + // nop // sll r0, r0, 0 + + block_10: + c->vopmula(vf1, vf2); // vopmula.xyz acc, vf1, vf2 + // nop // sll r0, r0, 0 + c->vopmsub(vf3, vf2, vf1); // vopmsub.xyz vf3, vf2, vf1 + // nop // sll r0, r0, 0 + c->vmula_bc(DEST::xyzw, BC::w, vf4, vf0); // vmulaw.xyzw acc, vf4, vf0 + // nop // sll r0, r0, 0 + c->vmadda_bc(DEST::xyzw, BC::x, vf1, vf9); // vmaddax.xyzw acc, vf1, vf9 + // nop // sll r0, r0, 0 + c->vmadda_bc(DEST::xyzw, BC::y, vf2, vf9); // vmadday.xyzw acc, vf2, vf9 + // nop // sll r0, r0, 0 + c->vmadd_bc(DEST::xyz, BC::z, vf9, vf3, vf9); // vmaddz.xyz vf9, vf3, vf9 + // nop // sll r0, r0, 0 + c->vmula_bc(DEST::xyzw, BC::w, vf4, vf0); // vmulaw.xyzw acc, vf4, vf0 + // nop // sll r0, r0, 0 + c->vmadda_bc(DEST::xyzw, BC::x, vf1, vf10); // vmaddax.xyzw acc, vf1, vf10 + // nop // sll r0, r0, 0 + c->vmadda_bc(DEST::xyzw, BC::y, vf2, vf10); // vmadday.xyzw acc, vf2, vf10 + // nop // sll r0, r0, 0 + c->vmadd_bc(DEST::xyz, BC::z, vf10, vf3, vf10); // vmaddz.xyz vf10, vf3, vf10 + // nop // sll r0, r0, 0 + c->vmula_bc(DEST::xyzw, BC::w, vf4, vf0); // vmulaw.xyzw acc, vf4, vf0 + // nop // sll r0, r0, 0 + c->vmadda_bc(DEST::xyzw, BC::x, vf1, vf11); // vmaddax.xyzw acc, vf1, vf11 + // nop // sll r0, r0, 0 + c->vmadda_bc(DEST::xyzw, BC::y, vf2, vf11); // vmadday.xyzw acc, vf2, vf11 + // nop // sll r0, r0, 0 + c->vmadd_bc(DEST::xyz, BC::z, vf11, vf3, vf11); // vmaddz.xyz vf11, vf3, vf11 + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + c->sqc2(vf9, 0, gp); // sqc2 vf9, 0(gp) + // nop // sll r0, r0, 0 + c->sqc2(vf10, 16, gp); // sqc2 vf10, 16(gp) + // nop // sll r0, r0, 0 + c->sqc2(vf11, 32, gp); // sqc2 vf11, 32(gp) + c->gprs[v1].du64[0] = 0; // or v1, r0, r0 + + block_11: + c->mfc1(v0, f3); // mfc1 v0, f3 + c->ld(ra, 0, sp); // ld ra, 0(sp) + c->ld(fp, 8, sp); // ld fp, 8(sp) + c->lq(gp, 112, sp); // lq gp, 112(sp) + c->lq(s5, 96, sp); // lq s5, 96(sp) + c->lq(s4, 80, sp); // lq s4, 80(sp) + c->lq(s3, 64, sp); // lq s3, 64(sp) + c->lq(s2, 48, sp); // lq s2, 48(sp) + c->lq(s1, 32, sp); // lq s1, 32(sp) + //jr ra // jr ra + c->daddiu(sp, sp, 128); // daddiu sp, sp, 128 + goto end_of_function; // return + + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + end_of_function: + return c->gprs[v0].du64[0]; +} + +void link() { + cache.moving_sphere_sphere_intersect = intern_from_c("moving-sphere-sphere-intersect").c(); + gLinkedFunctionTable.reg("(method 10 collide-cache-prim)", execute, 512); +} + +} // namespace method_10_collide_cache_prim +} // namespace Mips2C + +//--------------------------MIPS2C--------------------- +#include "game/mips2c/mips2c_private.h" +#include "game/kernel/kscheme.h" +namespace Mips2C { +namespace method_10_collide_puss_work { +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->lwu(v1, 4, a2); // lwu v1, 4(a2) + c->daddiu(a2, a0, 96); // daddiu a2, a0, 96 + c->lqc2(vf1, 0, a1); // lqc2 vf1, 0(a1) + bc = c->sgpr64(v1) == 0; // beq v1, r0, L10 + c->lq(a1, 64, a0); // lq a1, 64(a0) + if (bc) {goto block_12;} // branch non-likely + + c->vmax_bc(DEST::xyzw, BC::w, vf4, vf0, vf0); // vmaxw.xyzw vf4, vf0, vf0 + c->lq(a3, 80, a0); // lq a3, 80(a0) + c->vsub_bc(DEST::xyz, BC::w, vf2, vf1, vf1); // vsubw.xyz vf2, vf1, vf1 + c->gprs[a0].du64[0] = 0; // or a0, r0, r0 + c->vadd_bc(DEST::xyz, BC::w, vf3, vf1, vf1); // vaddw.xyz vf3, vf1, vf1 + c->lqc2(vf5, 0, a2); // lqc2 vf5, 0(a2) + c->vftoi0(DEST::xyzw, vf2, vf2); // vftoi0.xyzw vf2, vf2 + c->lqc2(vf6, 48, a2); // lqc2 vf6, 48(a2) + c->vftoi0(DEST::xyzw, vf3, vf3); // vftoi0.xyzw vf3, vf3 + c->lqc2(vf7, 96, a2); // lqc2 vf7, 96(a2) + // nop // sll r0, r0, 0 + c->vsub_bc(DEST::w, BC::w, vf1, vf0, vf1); // vsubw.w vf1, vf0, vf1 + c->mov128_gpr_vf(t0, vf2); // qmfc2.i t0, vf2 + c->lqc2(vf8, 144, a2); // lqc2 vf8, 144(a2) + c->mov128_gpr_vf(t1, vf3); // qmfc2.i t1, vf3 + // nop // sll r0, r0, 0 + c->pcgtw(a1, a1, t1); // pcgtw a1, a1, t1 + c->mfc1(r0, f31); // mfc1 r0, f31 + c->pcgtw(a3, t0, a3); // pcgtw a3, t0, a3 + c->mfc1(r0, f31); // mfc1 r0, f31 + c->por(a1, a1, a3); // por a1, a1, a3 + c->mfc1(r0, f31); // mfc1 r0, f31 + c->ppach(a1, r0, a1); // ppach a1, r0, a1 + c->mfc1(r0, f31); // mfc1 r0, f31 + c->dsll(a1, a1, 16); // dsll a1, a1, 16 + // nop // sll r0, r0, 0 + bc = c->sgpr64(a1) != 0; // bne a1, r0, L10 + // nop // sll r0, r0, 0 + if (bc) {goto block_12;} // branch non-likely + + + block_2: + c->vsub(DEST::xyzw, vf9, vf5, vf1); // vsub.xyzw vf9, vf5, vf1 + c->daddiu(a2, a2, 192); // daddiu a2, a2, 192 + c->vsub(DEST::xyzw, vf10, vf6, vf1); // vsub.xyzw vf10, vf6, vf1 + c->lqc2(vf5, 0, a2); // lqc2 vf5, 0(a2) + c->vsub(DEST::xyzw, vf11, vf7, vf1); // vsub.xyzw vf11, vf7, vf1 + c->lqc2(vf6, 48, a2); // lqc2 vf6, 48(a2) + c->vsub(DEST::xyzw, vf12, vf8, vf1); // vsub.xyzw vf12, vf8, vf1 + c->lqc2(vf7, 96, a2); // lqc2 vf7, 96(a2) + c->vmul(DEST::xyzw, vf9, vf9, vf9); // vmul.xyzw vf9, vf9, vf9 + c->lqc2(vf8, 144, a2); // lqc2 vf8, 144(a2) + c->vmul(DEST::xyzw, vf10, vf10, vf10); // vmul.xyzw vf10, vf10, vf10 + // nop // sll r0, r0, 0 + c->vmul(DEST::xyzw, vf11, vf11, vf11); // vmul.xyzw vf11, vf11, vf11 + // nop // sll r0, r0, 0 + c->vmul(DEST::xyzw, vf12, vf12, vf12); // vmul.xyzw vf12, vf12, vf12 + // nop // sll r0, r0, 0 + c->vmula_bc(DEST::xyzw, BC::x, vf4, vf9); // vmulax.xyzw acc, vf4, vf9 + // nop // sll r0, r0, 0 + c->vmadda_bc(DEST::xyzw, BC::y, vf4, vf9); // vmadday.xyzw acc, vf4, vf9 + // nop // sll r0, r0, 0 + c->vmadda_bc(DEST::xyzw, BC::z, vf4, vf9); // vmaddaz.xyzw acc, vf4, vf9 + // nop // sll r0, r0, 0 + c->vmsub_bc(DEST::xyzw, BC::w, vf9, vf4, vf9); // vmsubw.xyzw vf9, vf4, vf9 + // nop // sll r0, r0, 0 + c->vmula_bc(DEST::xyzw, BC::x, vf4, vf10); // vmulax.xyzw acc, vf4, vf10 + // nop // sll r0, r0, 0 + c->vmadda_bc(DEST::xyzw, BC::y, vf4, vf10); // vmadday.xyzw acc, vf4, vf10 + // nop // sll r0, r0, 0 + c->vmadda_bc(DEST::xyzw, BC::z, vf4, vf10); // vmaddaz.xyzw acc, vf4, vf10 + // nop // sll r0, r0, 0 + c->vmsub_bc(DEST::xyzw, BC::w, vf10, vf4, vf10); // vmsubw.xyzw vf10, vf4, vf10 + // nop // sll r0, r0, 0 + c->mov128_gpr_vf(a1, vf9); // qmfc2.i a1, vf9 + c->daddiu(a0, a0, 1); // daddiu a0, a0, 1 + bc = ((s64)c->sgpr64(a1)) <= 0; // blez a1, L9 + c->vmula_bc(DEST::xyzw, BC::x, vf4, vf11); // vmulax.xyzw acc, vf4, vf11 + if (bc) {goto block_11;} // branch non-likely + + bc = c->sgpr64(a0) == c->sgpr64(v1); // beq a0, v1, L10 + c->vmadda_bc(DEST::xyzw, BC::y, vf4, vf11); // vmadday.xyzw acc, vf4, vf11 + if (bc) {goto block_12;} // branch non-likely + + c->vmadda_bc(DEST::xyzw, BC::z, vf4, vf11); // vmaddaz.xyzw acc, vf4, vf11 + // nop // sll r0, r0, 0 + c->vmsub_bc(DEST::xyzw, BC::w, vf11, vf4, vf11); // vmsubw.xyzw vf11, vf4, vf11 + // nop // sll r0, r0, 0 + c->mov128_gpr_vf(a1, vf10); // qmfc2.i a1, vf10 + c->daddiu(a0, a0, 1); // daddiu a0, a0, 1 + bc = ((s64)c->sgpr64(a1)) <= 0; // blez a1, L9 + c->vmula_bc(DEST::xyzw, BC::x, vf4, vf12); // vmulax.xyzw acc, vf4, vf12 + if (bc) {goto block_11;} // branch non-likely + + bc = c->sgpr64(a0) == c->sgpr64(v1); // beq a0, v1, L10 + c->vmadda_bc(DEST::xyzw, BC::y, vf4, vf12); // vmadday.xyzw acc, vf4, vf12 + if (bc) {goto block_12;} // branch non-likely + + c->vmadda_bc(DEST::xyzw, BC::z, vf4, vf12); // vmaddaz.xyzw acc, vf4, vf12 + // nop // sll r0, r0, 0 + c->vmsub_bc(DEST::xyzw, BC::w, vf12, vf4, vf12); // vmsubw.xyzw vf12, vf4, vf12 + // nop // sll r0, r0, 0 + c->mov128_gpr_vf(a1, vf11); // qmfc2.i a1, vf11 + c->daddiu(a0, a0, 1); // daddiu a0, a0, 1 + bc = ((s64)c->sgpr64(a1)) <= 0; // blez a1, L9 + // nop // sll r0, r0, 0 + if (bc) {goto block_11;} // branch non-likely + + bc = c->sgpr64(a0) == c->sgpr64(v1); // beq a0, v1, L10 + // nop // sll r0, r0, 0 + if (bc) {goto block_12;} // branch non-likely + + c->mov128_gpr_vf(a1, vf12); // qmfc2.i a1, vf12 + c->daddiu(a0, a0, 1); // daddiu a0, a0, 1 + bc = ((s64)c->sgpr64(a1)) <= 0; // blez a1, L9 + // nop // sll r0, r0, 0 + if (bc) {goto block_11;} // branch non-likely + + bc = c->sgpr64(a0) != c->sgpr64(v1); // bne a0, v1, L8 + // nop // sll r0, r0, 0 + if (bc) {goto block_2;} // branch non-likely + + //beq r0, r0, L10 // beq r0, r0, L10 + // nop // sll r0, r0, 0 + goto block_12; // branch always + + + block_11: + c->daddiu(v1, s7, 8); // daddiu v1, s7, #t + c->mov64(v0, v1); // or v0, v1, r0 + //beq r0, r0, L11 // beq r0, r0, L11 + // nop // sll r0, r0, 0 + goto block_14; // branch always + + + block_12: + c->mov64(v0, s7); // or v0, s7, r0 + //beq r0, r0, L11 // beq r0, r0, L11 + // nop // sll r0, r0, 0 + goto block_14; // branch always + + c->gprs[v0].du64[0] = 0; // or v0, r0, r0 + + block_14: + //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 10 collide-puss-work)", execute, 128); +} + +} // namespace method_10_collide_puss_work +} // namespace Mips2C + +//--------------------------MIPS2C--------------------- +#include "game/mips2c/mips2c_private.h" +#include "game/kernel/kscheme.h" +namespace Mips2C { +namespace method_9_collide_puss_work { +struct Cache { + void* closest_pt_in_triangle; // closest-pt-in-triangle +} cache; + +u64 execute(void* ctxt) { + auto* c = (ExecutionContext*)ctxt; + bool bc = false; + u32 call_addr = 0; + c->daddiu(sp, sp, -128); // daddiu sp, sp, -128 + c->sd(ra, 0, sp); // sd ra, 0(sp) + c->sq(s0, 16, sp); // sq s0, 16(sp) + c->sq(s1, 32, sp); // sq s1, 32(sp) + c->sq(s2, 48, sp); // sq s2, 48(sp) + c->sq(s3, 64, sp); // sq s3, 64(sp) + c->sq(s4, 80, sp); // sq s4, 80(sp) + c->sq(s5, 96, sp); // sq s5, 96(sp) + c->sq(gp, 112, sp); // sq gp, 112(sp) + c->mov64(gp, a0); // or gp, a0, r0 + c->mov64(s5, a2); // or s5, a2, r0 + // nop // sll r0, r0, 0 + c->lwu(a0, 32, a1); // lwu a0, 32(a1) + // nop // sll r0, r0, 0 + c->lhu(v1, 40, a1); // lhu v1, 40(a1) + c->daddiu(a0, a0, 4908); // daddiu a0, a0, 4908 + c->lhu(s4, 42, a1); // lhu s4, 42(a1) + c->dsll(v1, v1, 6); // dsll v1, v1, 6 + // nop // sll r0, r0, 0 + c->daddu(s3, a0, v1); // daddu s3, a0, v1 + // nop // sll r0, r0, 0 + + block_1: + bc = c->sgpr64(s4) == 0; // beq s4, r0, L15 + c->lqc2(vf1, 0, s3); // lqc2 vf1, 0(s3) + if (bc) {goto block_12;} // branch non-likely + + c->daddiu(s4, s4, -1); // daddiu s4, s4, -1 + c->lqc2(vf2, 16, s3); // lqc2 vf2, 16(s3) + // nop // sll r0, r0, 0 + c->lqc2(vf3, 32, s3); // lqc2 vf3, 32(s3) + c->vsub(DEST::xyzw, vf4, vf2, vf1); // vsub.xyzw vf4, vf2, vf1 + c->lq(a1, 64, gp); // lq a1, 64(gp) + c->vsub(DEST::xyzw, vf5, vf3, vf1); // vsub.xyzw vf5, vf3, vf1 + c->lq(v1, 80, gp); // lq v1, 80(gp) + c->vmini(DEST::xyzw, vf6, vf1, vf2); // vmini.xyzw vf6, vf1, vf2 + // nop // sll r0, r0, 0 + c->vmax(DEST::xyzw, vf7, vf1, vf2); // vmax.xyzw vf7, vf1, vf2 + // nop // sll r0, r0, 0 + c->vopmula(vf4, vf5); // vopmula.xyz acc, vf4, vf5 + // nop // sll r0, r0, 0 + c->vmove(DEST::xyzw, vf8, vf0); // vmove.xyzw vf8, vf0 + // nop // sll r0, r0, 0 + c->vmini(DEST::xyzw, vf6, vf6, vf3); // vmini.xyzw vf6, vf6, vf3 + // nop // sll r0, r0, 0 + c->vmax(DEST::xyzw, vf7, vf7, vf3); // vmax.xyzw vf7, vf7, vf3 + // nop // sll r0, r0, 0 + c->vopmsub(vf8, vf5, vf4); // vopmsub.xyz vf8, vf5, vf4 + // nop // sll r0, r0, 0 + c->vftoi0(DEST::xyzw, vf6, vf6); // vftoi0.xyzw vf6, vf6 + // nop // sll r0, r0, 0 + c->vftoi0(DEST::xyzw, vf7, vf7); // vftoi0.xyzw vf7, vf7 + // nop // sll r0, r0, 0 + c->vmul(DEST::xyzw, vf9, vf8, vf8); // vmul.xyzw vf9, vf8, vf8 + // nop // sll r0, r0, 0 + c->mov128_gpr_vf(a0, vf6); // qmfc2.i a0, vf6 + // nop // sll r0, r0, 0 + c->mov128_gpr_vf(a2, vf7); // qmfc2.i a2, vf7 + // nop // sll r0, r0, 0 + c->vmula_bc(DEST::w, BC::x, vf0, vf9); // vmulax.w acc, vf0, vf9 + c->sqc2(vf6, 32, gp); // sqc2 vf6, 32(gp) + c->vmadda_bc(DEST::w, BC::y, vf0, vf9); // vmadday.w acc, vf0, vf9 + c->sqc2(vf7, 48, gp); // sqc2 vf7, 48(gp) + c->vmadd_bc(DEST::w, BC::z, vf9, vf0, vf9); // vmaddz.w vf9, vf0, vf9 + // nop // sll r0, r0, 0 + c->pcgtw(a1, a1, a2); // pcgtw a1, a1, a2 + c->mfc1(r0, f31); // mfc1 r0, f31 + c->pcgtw(v1, a0, v1); // pcgtw v1, a0, v1 + c->mfc1(r0, f31); // mfc1 r0, f31 + c->por(v1, a1, v1); // por v1, a1, v1 + c->mfc1(r0, f31); // mfc1 r0, f31 + c->vrsqrt(vf0, BC::w, vf9, BC::w); // vrsqrt Q, vf0.w, vf9.w + // nop // sll r0, r0, 0 + c->ppach(v1, r0, v1); // ppach v1, r0, v1 + c->mfc1(r0, f31); // mfc1 r0, f31 + c->dsll(v1, v1, 16); // dsll v1, v1, 16 + // nop // sll r0, r0, 0 + if (((s64)c->sgpr64(v1)) != ((s64)0)) { // bnel v1, r0, L13 + c->daddiu(s3, s3, 64); // daddiu s3, s3, 64 + goto block_1; + } + + // block_4: + c->vwaitq(); // vwaitq + // nop // sll r0, r0, 0 + c->vmulq(DEST::xyz, vf8, vf8); // vmulq.xyz vf8, vf8, Q + c->daddiu(s2, gp, 96); // daddiu s2, gp, 96 + // nop // sll r0, r0, 0 + c->lwu(s1, 4, s5); // lwu s1, 4(s5) + c->gprs[s0].du64[0] = 0; // or s0, r0, r0 + c->sqc2(vf8, 16, gp); // sqc2 vf8, 16(gp) + + block_5: + if (((s64)c->sgpr64(s0)) == ((s64)c->sgpr64(s1))) {// beql s0, s1, L13 + c->daddiu(s3, s3, 64); // daddiu s3, s3, 64 + goto block_1; + } + + // block_7: + c->daddiu(s0, s0, 1); // daddiu s0, s0, 1 + c->lq(a1, 16, s2); // lq a1, 16(s2) + // nop // sll r0, r0, 0 + c->lq(a2, 48, gp); // lq a2, 48(gp) + // nop // sll r0, r0, 0 + c->lq(v1, 32, s2); // lq v1, 32(s2) + // nop // sll r0, r0, 0 + c->lq(a0, 32, gp); // lq a0, 32(gp) + c->pcgtw(a1, a1, a2); // pcgtw a1, a1, a2 + c->mfc1(r0, f31); // mfc1 r0, f31 + c->pcgtw(v1, a0, v1); // pcgtw v1, a0, v1 + c->mfc1(r0, f31); // mfc1 r0, f31 + c->por(v1, a1, v1); // por v1, a1, v1 + c->mfc1(r0, f31); // mfc1 r0, f31 + c->ppach(v1, r0, v1); // ppach v1, r0, v1 + c->mfc1(r0, f31); // mfc1 r0, f31 + c->dsll(v1, v1, 16); // dsll v1, v1, 16 + // nop // sll r0, r0, 0 + if (((s64)c->sgpr64(v1)) != ((s64)0)) { // bnel v1, r0, L14 + c->daddiu(s2, s2, 48); // daddiu s2, s2, 48 + goto block_5; + } + + // block_9: + c->load_symbol(t9, cache.closest_pt_in_triangle); // lw t9, closest-pt-in-triangle(s7) + c->daddu(a0, r0, gp); // daddu a0, r0, gp + c->daddu(a1, r0, s2); // daddu a1, r0, s2 + c->daddu(a2, r0, s3); // daddu a2, r0, s3 + c->daddiu(a3, gp, 16); // daddiu a3, gp, 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->lqc2(vf10, 0, gp); // lqc2 vf10, 0(gp) + c->lqc2(vf11, 0, s2); // lqc2 vf11, 0(s2) + c->daddiu(s2, s2, 48); // daddiu s2, s2, 48 + c->vsub(DEST::xyz, vf9, vf10, vf11); // vsub.xyz vf9, vf10, vf11 + c->vmul(DEST::w, vf11, vf11, vf11); // vmul.w vf11, vf11, vf11 + c->vmul(DEST::xyzw, vf9, vf9, vf9); // vmul.xyzw vf9, vf9, vf9 + c->vmula_bc(DEST::w, BC::x, vf0, vf9); // vmulax.w acc, vf0, vf9 + c->vmadda_bc(DEST::w, BC::y, vf0, vf9); // vmadday.w acc, vf0, vf9 + c->vmadd_bc(DEST::w, BC::z, vf9, vf0, vf9); // vmaddz.w vf9, vf0, vf9 + c->vsub(DEST::w, vf9, vf9, vf11); // vsub.w vf9, vf9, vf11 + c->mov128_gpr_vf(v1, vf9); // qmfc2.i v1, vf9 + c->pcpyud(v1, v1, v1); // pcpyud v1, v1, v1 + if (((s64)c->sgpr64(v1)) > 0) { // bgtzl v1, L14 + // nop // sll r0, r0, 0 + goto block_5; + } + + // block_11: + c->daddiu(v1, s7, 8); // daddiu v1, s7, #t + c->mov64(v0, v1); // or v0, v1, r0 + //beq r0, r0, L16 // beq r0, r0, L16 + // nop // sll r0, r0, 0 + goto block_14; // branch always + + + block_12: + c->mov64(v0, s7); // or v0, s7, r0 + //beq r0, r0, L16 // beq r0, r0, L16 + // nop // sll r0, r0, 0 + goto block_14; // branch always + + c->gprs[v0].du64[0] = 0; // or v0, r0, r0 + + block_14: + c->ld(ra, 0, sp); // ld ra, 0(sp) + c->lq(gp, 112, sp); // lq gp, 112(sp) + c->lq(s5, 96, sp); // lq s5, 96(sp) + c->lq(s4, 80, sp); // lq s4, 80(sp) + c->lq(s3, 64, sp); // lq s3, 64(sp) + c->lq(s2, 48, sp); // lq s2, 48(sp) + c->lq(s1, 32, sp); // lq s1, 32(sp) + c->lq(s0, 16, sp); // lq s0, 16(sp) + //jr ra // jr ra + c->daddiu(sp, sp, 128); // daddiu sp, sp, 128 + goto end_of_function; // return + + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + end_of_function: + return c->gprs[v0].du64[0]; +} + +void link() { + cache.closest_pt_in_triangle = intern_from_c("closest-pt-in-triangle").c(); + gLinkedFunctionTable.reg("(method 9 collide-puss-work)", execute, 256); +} + +} // namespace method_9_collide_puss_work +} // namespace Mips2C + + diff --git a/game/mips2c/functions/collide_edge_grab.cpp b/game/mips2c/functions/collide_edge_grab.cpp new file mode 100644 index 000000000..68da53729 --- /dev/null +++ b/game/mips2c/functions/collide_edge_grab.cpp @@ -0,0 +1,191 @@ + +//--------------------------MIPS2C--------------------- +#include "game/mips2c/mips2c_private.h" +#include "game/kernel/kscheme.h" +namespace Mips2C { +namespace method_16_collide_edge_work { +struct Cache { + void* format; // format +} cache; + +// clang-format off +u64 execute(void* ctxt) { + auto* c = (ExecutionContext*)ctxt; + bool bc = false; + u32 call_addr = 0; + bool cop1_bc = false; + c->daddiu(sp, sp, -32); // daddiu sp, sp, -32 + c->sd(ra, 0, sp); // sd ra, 0(sp) + c->sd(fp, 8, sp); // sd fp, 8(sp) + c->mov64(fp, t9); // or fp, t9, r0 + c->sq(gp, 16, sp); // sq gp, 16(sp) + c->mov64(gp, a0); // or gp, a0, r0 + c->fprs[f0] = 0.707; // lwc1 f0, L95(fp) + c->addiu(v1, r0, 5); // addiu v1, r0, 5 + // nop // sll r0, r0, 0 + c->addiu(a0, r0, 56); // addiu a0, r0, 56 + c->lwu(t3, 0, gp); // lwu t3, 0(gp) + c->addiu(a1, r0, 0); // addiu a1, r0, 0 + c->daddiu(a2, gp, 6272); // daddiu a2, gp, 6272 + c->addiu(a3, r0, 16); // addiu a3, r0, 16 + c->lwu(t0, 0, t3); // lwu t0, 0(t3) + c->gprs[t1].du64[0] = 0; // or t1, r0, r0 + c->lq(t2, 96, gp); // lq t2, 96(gp) + c->daddiu(t3, t3, 4908); // daddiu t3, t3, 4908 + c->lq(t4, 112, gp); // lq t4, 112(gp) + + block_1: + bc = c->sgpr64(t0) == 0; // beq t0, r0, L30 + c->lwu(t5, 48, t3); // lwu t5, 48(t3) + if (bc) {goto block_14;} // branch non-likely + + c->daddiu(t0, t0, -1); // daddiu t0, t0, -1 + c->lqc2(vf1, 0, t3); // lqc2 vf1, 0(t3) + c->and_(t6, t5, a0); // and t6, t5, a0 + c->lqc2(vf2, 16, t3); // lqc2 vf2, 16(t3) + bc = c->sgpr64(t6) == c->sgpr64(a1); // beq t6, a1, L29 + c->lqc2(vf3, 32, t3); // lqc2 vf3, 32(t3) + if (bc) {goto block_5;} // branch non-likely + + if (((s64)c->sgpr64(t6)) != ((s64)c->sgpr64(a3))) {// bnel t6, a3, L28 + c->daddiu(t3, t3, 64); // daddiu t3, t3, 64 + goto block_1; + } + + block_5: + c->and_(t6, t5, v1); // and t6, t5, v1 + c->vmini(DEST::xyzw, vf7, vf1, vf2); // vmini.xyzw vf7, vf1, vf2 + bc = c->sgpr64(t6) != 0; // bne t6, r0, L28 + c->vmax(DEST::xyzw, vf8, vf1, vf2); // vmax.xyzw vf8, vf1, vf2 + if (bc) {goto block_1;} // branch non-likely + + c->vsub(DEST::xyz, vf4, vf2, vf1); // vsub.xyz vf4, vf2, vf1 + // nop // sll r0, r0, 0 + c->vsub(DEST::xyz, vf5, vf3, vf1); // vsub.xyz vf5, vf3, vf1 + // nop // sll r0, r0, 0 + c->vmini(DEST::xyzw, vf7, vf7, vf3); // vmini.xyzw vf7, vf7, vf3 + // nop // sll r0, r0, 0 + c->vmax(DEST::xyzw, vf8, vf8, vf3); // vmax.xyzw vf8, vf8, vf3 + // nop // sll r0, r0, 0 + c->vopmula(vf4, vf5); // vopmula.xyz acc, vf4, vf5 + // nop // sll r0, r0, 0 + c->vftoi0(DEST::xyzw, vf7, vf7); // vftoi0.xyzw vf7, vf7 + // nop // sll r0, r0, 0 + c->vftoi0(DEST::xyzw, vf8, vf8); // vftoi0.xyzw vf8, vf8 + // nop // sll r0, r0, 0 + c->vopmsub(vf6, vf5, vf4); // vopmsub.xyz vf6, vf5, vf4 + // nop // sll r0, r0, 0 + c->mov128_gpr_vf(t7, vf7); // qmfc2.i t7, vf7 + // nop // sll r0, r0, 0 + c->mov128_gpr_vf(t6, vf8); // qmfc2.i t6, vf8 + // nop // sll r0, r0, 0 + c->pcgtw(t7, t7, t4); // pcgtw t7, t7, t4 + c->mfc1(r0, f31); // mfc1 r0, f31 + c->vmul(DEST::xyzw, vf9, vf6, vf6); // vmul.xyzw vf9, vf6, vf6 + // nop // sll r0, r0, 0 + c->pcgtw(t6, t2, t6); // pcgtw t6, t2, t6 + c->mfc1(r0, f31); // mfc1 r0, f31 + c->por(t6, t7, t6); // por t6, t7, t6 + c->mfc1(r0, f31); // mfc1 r0, f31 + c->ppach(t6, r0, t6); // ppach t6, r0, t6 + c->mfc1(r0, f31); // mfc1 r0, f31 + c->dsll(t6, t6, 16); // dsll t6, t6, 16 + // nop // sll r0, r0, 0 + if (((s64)c->sgpr64(t6)) != ((s64)0)) { // bnel t6, r0, L28 + c->daddiu(t3, t3, 64); // daddiu t3, t3, 64 + goto block_1; + } + + // block_8: + c->vmula_bc(DEST::w, BC::x, vf0, vf9); // vmulax.w acc, vf0, vf9 + // nop // sll r0, r0, 0 + c->vmadda_bc(DEST::w, BC::y, vf0, vf9); // vmadday.w acc, vf0, vf9 + // nop // sll r0, r0, 0 + c->vmadd_bc(DEST::w, BC::z, vf9, vf0, vf9); // vmaddz.w vf9, vf0, vf9 + // nop // sll r0, r0, 0 + c->vrsqrt(vf0, BC::w, vf9, BC::w); // vrsqrt Q, vf0.w, vf9.w + // nop // sll r0, r0, 0 + c->dsll32(t5, t5, 12); // dsll32 t5, t5, 12 + c->dsrl32(t5, t5, 26); // dsrl32 t5, t5, 26 + c->addiu(t6, r0, 2); // addiu t6, r0, 2 + // nop // sll r0, r0, 0 + c->vwaitq(); // vwaitq + // nop // sll r0, r0, 0 + c->vmulq(DEST::xyz, vf6, vf6); // vmulq.xyz vf6, vf6, Q + // nop // sll r0, r0, 0 + c->mov128_gpr_vf(t7, vf6); // qmfc2.i t7, vf6 + // nop // sll r0, r0, 0 + c->dsra32(t7, t7, 0); // dsra32 t7, t7, 0 + // nop // sll r0, r0, 0 + c->mtc1(f1, t7); // mtc1 f1, t7 + // nop // sll r0, r0, 0 + cop1_bc = c->fprs[f1] < c->fprs[f0]; // c.lt.s f1, f0 + c->addiu(t7, r0, 48); // addiu t7, r0, 48 + if (cop1_bc) { // bc1tl L28 + c->daddiu(t3, t3, 64); // daddiu t3, t3, 64 + goto block_1; + } + + // block_10: + if (((s64)c->sgpr64(t5)) == ((s64)c->sgpr64(t6))) {// beql t5, t6, L28 + c->daddiu(t3, t3, 64); // daddiu t3, t3, 64 + goto block_1; + } + + // block_12: + bc = c->sgpr64(t1) == c->sgpr64(t7); // beq t1, t7, L31 + // nop // sll r0, r0, 0 + if (bc) {goto block_15;} // branch non-likely + + c->daddiu(t1, t1, 1); // daddiu t1, t1, 1 + c->sw(t3, 0, a2); // sw t3, 0(a2) + // nop // sll r0, r0, 0 + c->sqc2(vf6, 16, a2); // sqc2 vf6, 16(a2) + c->daddiu(a2, a2, 32); // daddiu a2, a2, 32 + // nop // sll r0, r0, 0 + //beq r0, r0, L28 // beq r0, r0, L28 + c->daddiu(t3, t3, 64); // daddiu t3, t3, 64 + goto block_1; // branch always + + + block_14: + //beq r0, r0, L32 // beq r0, r0, L32 + c->sw(t1, 16, gp); // sw t1, 16(gp) + goto block_16; // branch always + + + block_15: + c->load_symbol(t9, cache.format); // lw t9, format(s7) + c->addiu(a0, r0, 0); // addiu a0, r0, 0 + //daddiu a1, fp, L88 // daddiu a1, fp, L88 + 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 + printf("ERROR: Exceeded max # of grabbable tris\n"); + c->addiu(v1, r0, 48); // addiu v1, r0, 48 + c->sw(v1, 16, gp); // sw v1, 16(gp) + + block_16: + c->gprs[v0].du64[0] = 0; // or v0, r0, r0 + c->ld(ra, 0, sp); // ld ra, 0(sp) + c->ld(fp, 8, sp); // ld fp, 8(sp) + c->lq(gp, 16, sp); // lq gp, 16(sp) + //jr ra // jr ra + c->daddiu(sp, sp, 32); // daddiu sp, sp, 32 + 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.format = intern_from_c("format").c(); + gLinkedFunctionTable.reg("(method 16 collide-edge-work)", execute, 128); +} + +} // namespace method_16_collide_edge_work +} // namespace Mips2C + diff --git a/game/mips2c/functions/collide_mesh.cpp b/game/mips2c/functions/collide_mesh.cpp index 43cc24f8a..0a3d9d2a1 100644 --- a/game/mips2c/functions/collide_mesh.cpp +++ b/game/mips2c/functions/collide_mesh.cpp @@ -375,3 +375,513 @@ void link() { } // namespace method_11_collide_mesh } // namespace Mips2C +//--------------------------MIPS2C--------------------- +#include "game/mips2c/mips2c_private.h" +#include "game/kernel/kscheme.h" +namespace Mips2C { +namespace method_14_collide_mesh { +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->lwu(v1, 12, a0); // lwu v1, 12(a0) + // nop // sll r0, r0, 0 + c->lwu(a0, 8, a0); // lwu a0, 8(a0) + // nop // sll r0, r0, 0 + c->lqc2(vf1, 0, a1); // lqc2 vf1, 0(a1) + // nop // sll r0, r0, 0 + c->lqc2(vf2, 16, a1); // lqc2 vf2, 16(a1) + // nop // sll r0, r0, 0 + c->lqc2(vf3, 32, a1); // lqc2 vf3, 32(a1) + // nop // sll r0, r0, 0 + c->lqc2(vf4, 48, a1); // lqc2 vf4, 48(a1) + // nop // sll r0, r0, 0 + c->lqc2(vf5, 0, v1); // lqc2 vf5, 0(v1) + // nop // sll r0, r0, 0 + c->lqc2(vf6, 16, v1); // lqc2 vf6, 16(v1) + // nop // sll r0, r0, 0 + c->lqc2(vf7, 32, v1); // lqc2 vf7, 32(v1) + // nop // sll r0, r0, 0 + c->lqc2(vf8, 48, v1); // lqc2 vf8, 48(v1) + c->vmula_bc(DEST::xyzw, BC::w, vf4, vf0); // vmulaw.xyzw acc, vf4, vf0 + c->lqc2(vf9, 64, v1); // lqc2 vf9, 64(v1) + c->vmadda_bc(DEST::xyzw, BC::x, vf1, vf5); // vmaddax.xyzw acc, vf1, vf5 + c->lqc2(vf10, 80, v1); // lqc2 vf10, 80(v1) + c->vmadda_bc(DEST::xyzw, BC::y, vf2, vf5); // vmadday.xyzw acc, vf2, vf5 + c->lqc2(vf11, 96, v1); // lqc2 vf11, 96(v1) + c->vmadd_bc(DEST::xyzw, BC::z, vf5, vf3, vf5); // vmaddz.xyzw vf5, vf3, vf5 + c->lqc2(vf12, 112, v1); // lqc2 vf12, 112(v1) + c->vmula_bc(DEST::xyzw, BC::w, vf4, vf0); // vmulaw.xyzw acc, vf4, vf0 + // nop // sll r0, r0, 0 + c->vmadda_bc(DEST::xyzw, BC::x, vf1, vf6); // vmaddax.xyzw acc, vf1, vf6 + // nop // sll r0, r0, 0 + c->vmadda_bc(DEST::xyzw, BC::y, vf2, vf6); // vmadday.xyzw acc, vf2, vf6 + // nop // sll r0, r0, 0 + c->vmadd_bc(DEST::xyzw, BC::z, vf6, vf3, vf6); // vmaddz.xyzw vf6, vf3, vf6 + // nop // sll r0, r0, 0 + c->vmula_bc(DEST::xyzw, BC::w, vf4, vf0); // vmulaw.xyzw acc, vf4, vf0 + // nop // sll r0, r0, 0 + c->vmadda_bc(DEST::xyzw, BC::x, vf1, vf7); // vmaddax.xyzw acc, vf1, vf7 + // nop // sll r0, r0, 0 + c->vmadda_bc(DEST::xyzw, BC::y, vf2, vf7); // vmadday.xyzw acc, vf2, vf7 + // nop // sll r0, r0, 0 + c->vmadd_bc(DEST::xyzw, BC::z, vf7, vf3, vf7); // vmaddz.xyzw vf7, vf3, vf7 + // nop // sll r0, r0, 0 + c->vmula_bc(DEST::xyzw, BC::w, vf4, vf0); // vmulaw.xyzw acc, vf4, vf0 + // nop // sll r0, r0, 0 + c->vmadda_bc(DEST::xyzw, BC::x, vf1, vf8); // vmaddax.xyzw acc, vf1, vf8 + // nop // sll r0, r0, 0 + c->vmadda_bc(DEST::xyzw, BC::y, vf2, vf8); // vmadday.xyzw acc, vf2, vf8 + // nop // sll r0, r0, 0 + c->vmadd_bc(DEST::xyzw, BC::z, vf8, vf3, vf8); // vmaddz.xyzw vf8, vf3, vf8 + // nop // sll r0, r0, 0 + c->vftoi0(DEST::xyzw, vf13, vf5); // vftoi0.xyzw vf13, vf5 + c->sqc2(vf5, 0, a2); // sqc2 vf5, 0(a2) + c->vftoi0(DEST::xyzw, vf14, vf6); // vftoi0.xyzw vf14, vf6 + c->sqc2(vf6, 32, a2); // sqc2 vf6, 32(a2) + c->vftoi0(DEST::xyzw, vf15, vf7); // vftoi0.xyzw vf15, vf7 + c->sqc2(vf7, 64, a2); // sqc2 vf7, 64(a2) + c->vftoi0(DEST::xyzw, vf16, vf8); // vftoi0.xyzw vf16, vf8 + c->sqc2(vf8, 96, a2); // sqc2 vf8, 96(a2) + // nop // sll r0, r0, 0 + c->sqc2(vf13, 16, a2); // sqc2 vf13, 16(a2) + c->daddiu(a0, a0, -4); // daddiu a0, a0, -4 + c->sqc2(vf14, 48, a2); // sqc2 vf14, 48(a2) + c->daddiu(v1, v1, 128); // daddiu v1, v1, 128 + c->sqc2(vf15, 80, a2); // sqc2 vf15, 80(a2) + bc = ((s64)c->sgpr64(a0)) <= 0; // blez a0, L20 + c->sqc2(vf16, 112, a2); // sqc2 vf16, 112(a2) + if (bc) {goto block_3;} // branch non-likely + + + block_1: + c->vmula_bc(DEST::xyzw, BC::w, vf4, vf0); // vmulaw.xyzw acc, vf4, vf0 + c->lqc2(vf5, 0, v1); // lqc2 vf5, 0(v1) + c->vmadda_bc(DEST::xyzw, BC::x, vf1, vf9); // vmaddax.xyzw acc, vf1, vf9 + c->lqc2(vf6, 16, v1); // lqc2 vf6, 16(v1) + c->vmadda_bc(DEST::xyzw, BC::y, vf2, vf9); // vmadday.xyzw acc, vf2, vf9 + c->lqc2(vf7, 32, v1); // lqc2 vf7, 32(v1) + c->vmadd_bc(DEST::xyzw, BC::z, vf9, vf3, vf9); // vmaddz.xyzw vf9, vf3, vf9 + c->lqc2(vf8, 48, v1); // lqc2 vf8, 48(v1) + c->vmula_bc(DEST::xyzw, BC::w, vf4, vf0); // vmulaw.xyzw acc, vf4, vf0 + // nop // sll r0, r0, 0 + c->vmadda_bc(DEST::xyzw, BC::x, vf1, vf10); // vmaddax.xyzw acc, vf1, vf10 + // nop // sll r0, r0, 0 + c->vmadda_bc(DEST::xyzw, BC::y, vf2, vf10); // vmadday.xyzw acc, vf2, vf10 + // nop // sll r0, r0, 0 + c->vmadd_bc(DEST::xyzw, BC::z, vf10, vf3, vf10); // vmaddz.xyzw vf10, vf3, vf10 + // nop // sll r0, r0, 0 + c->vmula_bc(DEST::xyzw, BC::w, vf4, vf0); // vmulaw.xyzw acc, vf4, vf0 + // nop // sll r0, r0, 0 + c->vmadda_bc(DEST::xyzw, BC::x, vf1, vf11); // vmaddax.xyzw acc, vf1, vf11 + // nop // sll r0, r0, 0 + c->vmadda_bc(DEST::xyzw, BC::y, vf2, vf11); // vmadday.xyzw acc, vf2, vf11 + // nop // sll r0, r0, 0 + c->vmadd_bc(DEST::xyzw, BC::z, vf11, vf3, vf11); // vmaddz.xyzw vf11, vf3, vf11 + // nop // sll r0, r0, 0 + c->vmula_bc(DEST::xyzw, BC::w, vf4, vf0); // vmulaw.xyzw acc, vf4, vf0 + // nop // sll r0, r0, 0 + c->vmadda_bc(DEST::xyzw, BC::x, vf1, vf12); // vmaddax.xyzw acc, vf1, vf12 + // nop // sll r0, r0, 0 + c->vmadda_bc(DEST::xyzw, BC::y, vf2, vf12); // vmadday.xyzw acc, vf2, vf12 + // nop // sll r0, r0, 0 + c->vmadd_bc(DEST::xyzw, BC::z, vf12, vf3, vf12); // vmaddz.xyzw vf12, vf3, vf12 + // nop // sll r0, r0, 0 + c->vftoi0(DEST::xyzw, vf17, vf9); // vftoi0.xyzw vf17, vf9 + c->sqc2(vf9, 128, a2); // sqc2 vf9, 128(a2) + c->vftoi0(DEST::xyzw, vf18, vf10); // vftoi0.xyzw vf18, vf10 + c->sqc2(vf10, 160, a2); // sqc2 vf10, 160(a2) + c->vftoi0(DEST::xyzw, vf19, vf11); // vftoi0.xyzw vf19, vf11 + c->sqc2(vf11, 192, a2); // sqc2 vf11, 192(a2) + c->vftoi0(DEST::xyzw, vf20, vf12); // vftoi0.xyzw vf20, vf12 + c->sqc2(vf12, 224, a2); // sqc2 vf12, 224(a2) + // nop // sll r0, r0, 0 + c->sqc2(vf17, 144, a2); // sqc2 vf17, 144(a2) + c->daddiu(a0, a0, -4); // daddiu a0, a0, -4 + c->sqc2(vf18, 176, a2); // sqc2 vf18, 176(a2) + // nop // sll r0, r0, 0 + c->sqc2(vf19, 208, a2); // sqc2 vf19, 208(a2) + bc = ((s64)c->sgpr64(a0)) <= 0; // blez a0, L20 + c->sqc2(vf20, 240, a2); // sqc2 vf20, 240(a2) + if (bc) {goto block_3;} // branch non-likely + + c->vmula_bc(DEST::xyzw, BC::w, vf4, vf0); // vmulaw.xyzw acc, vf4, vf0 + c->lqc2(vf9, 64, v1); // lqc2 vf9, 64(v1) + c->vmadda_bc(DEST::xyzw, BC::x, vf1, vf5); // vmaddax.xyzw acc, vf1, vf5 + c->lqc2(vf10, 80, v1); // lqc2 vf10, 80(v1) + c->vmadda_bc(DEST::xyzw, BC::y, vf2, vf5); // vmadday.xyzw acc, vf2, vf5 + c->lqc2(vf11, 96, v1); // lqc2 vf11, 96(v1) + c->vmadd_bc(DEST::xyzw, BC::z, vf5, vf3, vf5); // vmaddz.xyzw vf5, vf3, vf5 + c->lqc2(vf12, 112, v1); // lqc2 vf12, 112(v1) + c->vmula_bc(DEST::xyzw, BC::w, vf4, vf0); // vmulaw.xyzw acc, vf4, vf0 + c->daddiu(a2, a2, 256); // daddiu a2, a2, 256 + c->vmadda_bc(DEST::xyzw, BC::x, vf1, vf6); // vmaddax.xyzw acc, vf1, vf6 + // nop // sll r0, r0, 0 + c->vmadda_bc(DEST::xyzw, BC::y, vf2, vf6); // vmadday.xyzw acc, vf2, vf6 + // nop // sll r0, r0, 0 + c->vmadd_bc(DEST::xyzw, BC::z, vf6, vf3, vf6); // vmaddz.xyzw vf6, vf3, vf6 + // nop // sll r0, r0, 0 + c->vmula_bc(DEST::xyzw, BC::w, vf4, vf0); // vmulaw.xyzw acc, vf4, vf0 + // nop // sll r0, r0, 0 + c->vmadda_bc(DEST::xyzw, BC::x, vf1, vf7); // vmaddax.xyzw acc, vf1, vf7 + // nop // sll r0, r0, 0 + c->vmadda_bc(DEST::xyzw, BC::y, vf2, vf7); // vmadday.xyzw acc, vf2, vf7 + // nop // sll r0, r0, 0 + c->vmadd_bc(DEST::xyzw, BC::z, vf7, vf3, vf7); // vmaddz.xyzw vf7, vf3, vf7 + // nop // sll r0, r0, 0 + c->vmula_bc(DEST::xyzw, BC::w, vf4, vf0); // vmulaw.xyzw acc, vf4, vf0 + // nop // sll r0, r0, 0 + c->vmadda_bc(DEST::xyzw, BC::x, vf1, vf8); // vmaddax.xyzw acc, vf1, vf8 + // nop // sll r0, r0, 0 + c->vmadda_bc(DEST::xyzw, BC::y, vf2, vf8); // vmadday.xyzw acc, vf2, vf8 + // nop // sll r0, r0, 0 + c->vmadd_bc(DEST::xyzw, BC::z, vf8, vf3, vf8); // vmaddz.xyzw vf8, vf3, vf8 + // nop // sll r0, r0, 0 + c->vftoi0(DEST::xyzw, vf13, vf5); // vftoi0.xyzw vf13, vf5 + c->sqc2(vf5, 0, a2); // sqc2 vf5, 0(a2) + c->vftoi0(DEST::xyzw, vf14, vf6); // vftoi0.xyzw vf14, vf6 + c->sqc2(vf6, 32, a2); // sqc2 vf6, 32(a2) + c->vftoi0(DEST::xyzw, vf15, vf7); // vftoi0.xyzw vf15, vf7 + c->sqc2(vf7, 64, a2); // sqc2 vf7, 64(a2) + c->vftoi0(DEST::xyzw, vf16, vf8); // vftoi0.xyzw vf16, vf8 + c->sqc2(vf8, 96, a2); // sqc2 vf8, 96(a2) + // nop // sll r0, r0, 0 + c->sqc2(vf13, 16, a2); // sqc2 vf13, 16(a2) + c->daddiu(a0, a0, -4); // daddiu a0, a0, -4 + c->sqc2(vf14, 48, a2); // sqc2 vf14, 48(a2) + c->daddiu(v1, v1, 128); // daddiu v1, v1, 128 + c->sqc2(vf15, 80, a2); // sqc2 vf15, 80(a2) + bc = ((s64)c->sgpr64(a0)) > 0; // bgtz a0, L19 + c->sqc2(vf16, 112, a2); // sqc2 vf16, 112(a2) + if (bc) {goto block_1;} // branch non-likely + + + block_3: + 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 14 collide-mesh)", execute, 128); +} + +} // namespace method_14_collide_mesh +} // namespace Mips2C + + +//--------------------------MIPS2C--------------------- +#include "game/mips2c/mips2c_private.h" +#include "game/kernel/kscheme.h" +namespace Mips2C { +namespace method_15_collide_mesh { +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->lwu(v1, 12, a0); // lwu v1, 12(a0) + // nop // sll r0, r0, 0 + c->lwu(a0, 8, a0); // lwu a0, 8(a0) + // nop // sll r0, r0, 0 + c->lqc2(vf1, 0, a1); // lqc2 vf1, 0(a1) + // nop // sll r0, r0, 0 + c->lqc2(vf2, 16, a1); // lqc2 vf2, 16(a1) + // nop // sll r0, r0, 0 + c->lqc2(vf3, 32, a1); // lqc2 vf3, 32(a1) + // nop // sll r0, r0, 0 + c->lqc2(vf4, 48, a1); // lqc2 vf4, 48(a1) + // nop // sll r0, r0, 0 + c->lqc2(vf13, 0, a2); // lqc2 vf13, 0(a2) + // nop // sll r0, r0, 0 + c->lqc2(vf14, 16, a2); // lqc2 vf14, 16(a2) + // nop // sll r0, r0, 0 + c->lqc2(vf15, 32, a2); // lqc2 vf15, 32(a2) + // nop // sll r0, r0, 0 + c->lqc2(vf16, 48, a2); // lqc2 vf16, 48(a2) + // nop // sll r0, r0, 0 + c->lqc2(vf5, 0, v1); // lqc2 vf5, 0(v1) + // nop // sll r0, r0, 0 + c->lqc2(vf6, 16, v1); // lqc2 vf6, 16(v1) + // nop // sll r0, r0, 0 + c->lqc2(vf7, 32, v1); // lqc2 vf7, 32(v1) + // nop // sll r0, r0, 0 + c->lqc2(vf8, 48, v1); // lqc2 vf8, 48(v1) + c->vmula_bc(DEST::xyzw, BC::w, vf4, vf0); // vmulaw.xyzw acc, vf4, vf0 + c->lqc2(vf9, 64, v1); // lqc2 vf9, 64(v1) + c->vmadda_bc(DEST::xyzw, BC::x, vf1, vf5); // vmaddax.xyzw acc, vf1, vf5 + c->lqc2(vf10, 80, v1); // lqc2 vf10, 80(v1) + c->vmadda_bc(DEST::xyzw, BC::y, vf2, vf5); // vmadday.xyzw acc, vf2, vf5 + c->lqc2(vf11, 96, v1); // lqc2 vf11, 96(v1) + c->vmadd_bc(DEST::xyzw, BC::z, vf5, vf3, vf5); // vmaddz.xyzw vf5, vf3, vf5 + c->lqc2(vf12, 112, v1); // lqc2 vf12, 112(v1) + c->vmula_bc(DEST::xyzw, BC::w, vf4, vf0); // vmulaw.xyzw acc, vf4, vf0 + // nop // sll r0, r0, 0 + c->vmadda_bc(DEST::xyzw, BC::x, vf1, vf6); // vmaddax.xyzw acc, vf1, vf6 + // nop // sll r0, r0, 0 + c->vmadda_bc(DEST::xyzw, BC::y, vf2, vf6); // vmadday.xyzw acc, vf2, vf6 + // nop // sll r0, r0, 0 + c->vmadd_bc(DEST::xyzw, BC::z, vf6, vf3, vf6); // vmaddz.xyzw vf6, vf3, vf6 + // nop // sll r0, r0, 0 + c->vmula_bc(DEST::xyzw, BC::w, vf4, vf0); // vmulaw.xyzw acc, vf4, vf0 + // nop // sll r0, r0, 0 + c->vmadda_bc(DEST::xyzw, BC::x, vf1, vf7); // vmaddax.xyzw acc, vf1, vf7 + // nop // sll r0, r0, 0 + c->vmadda_bc(DEST::xyzw, BC::y, vf2, vf7); // vmadday.xyzw acc, vf2, vf7 + // nop // sll r0, r0, 0 + c->vmadd_bc(DEST::xyzw, BC::z, vf7, vf3, vf7); // vmaddz.xyzw vf7, vf3, vf7 + // nop // sll r0, r0, 0 + c->vmula_bc(DEST::xyzw, BC::w, vf4, vf0); // vmulaw.xyzw acc, vf4, vf0 + // nop // sll r0, r0, 0 + c->vmadda_bc(DEST::xyzw, BC::x, vf1, vf8); // vmaddax.xyzw acc, vf1, vf8 + // nop // sll r0, r0, 0 + c->vmadda_bc(DEST::xyzw, BC::y, vf2, vf8); // vmadday.xyzw acc, vf2, vf8 + // nop // sll r0, r0, 0 + c->vmadd_bc(DEST::xyzw, BC::z, vf8, vf3, vf8); // vmaddz.xyzw vf8, vf3, vf8 + // nop // sll r0, r0, 0 + c->vmula_bc(DEST::xyzw, BC::w, vf16, vf0); // vmulaw.xyzw acc, vf16, vf0 + c->sqc2(vf5, 0, a3); // sqc2 vf5, 0(a3) + c->vmadda_bc(DEST::xyzw, BC::x, vf13, vf5); // vmaddax.xyzw acc, vf13, vf5 + c->sqc2(vf6, 32, a3); // sqc2 vf6, 32(a3) + c->vmadda_bc(DEST::xyzw, BC::y, vf14, vf5); // vmadday.xyzw acc, vf14, vf5 + c->sqc2(vf7, 64, a3); // sqc2 vf7, 64(a3) + c->vmadd_bc(DEST::xyzw, BC::z, vf5, vf15, vf5); // vmaddz.xyzw vf5, vf15, vf5 + c->sqc2(vf8, 96, a3); // sqc2 vf8, 96(a3) + c->vmula_bc(DEST::xyzw, BC::w, vf16, vf0); // vmulaw.xyzw acc, vf16, vf0 + // nop // sll r0, r0, 0 + c->vmadda_bc(DEST::xyzw, BC::x, vf13, vf6); // vmaddax.xyzw acc, vf13, vf6 + // nop // sll r0, r0, 0 + c->vmadda_bc(DEST::xyzw, BC::y, vf14, vf6); // vmadday.xyzw acc, vf14, vf6 + // nop // sll r0, r0, 0 + c->vmadd_bc(DEST::xyzw, BC::z, vf6, vf15, vf6); // vmaddz.xyzw vf6, vf15, vf6 + // nop // sll r0, r0, 0 + c->vmula_bc(DEST::xyzw, BC::w, vf16, vf0); // vmulaw.xyzw acc, vf16, vf0 + // nop // sll r0, r0, 0 + c->vmadda_bc(DEST::xyzw, BC::x, vf13, vf7); // vmaddax.xyzw acc, vf13, vf7 + // nop // sll r0, r0, 0 + c->vmadda_bc(DEST::xyzw, BC::y, vf14, vf7); // vmadday.xyzw acc, vf14, vf7 + // nop // sll r0, r0, 0 + c->vmadd_bc(DEST::xyzw, BC::z, vf7, vf15, vf7); // vmaddz.xyzw vf7, vf15, vf7 + // nop // sll r0, r0, 0 + c->vmula_bc(DEST::xyzw, BC::w, vf16, vf0); // vmulaw.xyzw acc, vf16, vf0 + // nop // sll r0, r0, 0 + c->vmadda_bc(DEST::xyzw, BC::x, vf13, vf8); // vmaddax.xyzw acc, vf13, vf8 + // nop // sll r0, r0, 0 + c->vmadda_bc(DEST::xyzw, BC::y, vf14, vf8); // vmadday.xyzw acc, vf14, vf8 + // nop // sll r0, r0, 0 + c->vmadd_bc(DEST::xyzw, BC::z, vf8, vf15, vf8); // vmaddz.xyzw vf8, vf15, vf8 + // nop // sll r0, r0, 0 + c->vftoi0(DEST::xyzw, vf5, vf5); // vftoi0.xyzw vf5, vf5 + // nop // sll r0, r0, 0 + c->vftoi0(DEST::xyzw, vf6, vf6); // vftoi0.xyzw vf6, vf6 + // nop // sll r0, r0, 0 + c->vftoi0(DEST::xyzw, vf7, vf7); // vftoi0.xyzw vf7, vf7 + // nop // sll r0, r0, 0 + c->vftoi0(DEST::xyzw, vf8, vf8); // vftoi0.xyzw vf8, vf8 + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + c->sqc2(vf5, 16, a3); // sqc2 vf5, 16(a3) + c->daddiu(a0, a0, -4); // daddiu a0, a0, -4 + c->sqc2(vf6, 48, a3); // sqc2 vf6, 48(a3) + c->daddiu(v1, v1, 128); // daddiu v1, v1, 128 + c->sqc2(vf7, 80, a3); // sqc2 vf7, 80(a3) + bc = ((s64)c->sgpr64(a0)) <= 0; // blez a0, L17 + c->sqc2(vf8, 112, a3); // sqc2 vf8, 112(a3) + if (bc) {goto block_3;} // branch non-likely + + + block_1: + c->vmula_bc(DEST::xyzw, BC::w, vf4, vf0); // vmulaw.xyzw acc, vf4, vf0 + c->lqc2(vf5, 0, v1); // lqc2 vf5, 0(v1) + c->vmadda_bc(DEST::xyzw, BC::x, vf1, vf9); // vmaddax.xyzw acc, vf1, vf9 + c->lqc2(vf6, 16, v1); // lqc2 vf6, 16(v1) + c->vmadda_bc(DEST::xyzw, BC::y, vf2, vf9); // vmadday.xyzw acc, vf2, vf9 + c->lqc2(vf7, 32, v1); // lqc2 vf7, 32(v1) + c->vmadd_bc(DEST::xyzw, BC::z, vf9, vf3, vf9); // vmaddz.xyzw vf9, vf3, vf9 + c->lqc2(vf8, 48, v1); // lqc2 vf8, 48(v1) + c->vmula_bc(DEST::xyzw, BC::w, vf4, vf0); // vmulaw.xyzw acc, vf4, vf0 + // nop // sll r0, r0, 0 + c->vmadda_bc(DEST::xyzw, BC::x, vf1, vf10); // vmaddax.xyzw acc, vf1, vf10 + // nop // sll r0, r0, 0 + c->vmadda_bc(DEST::xyzw, BC::y, vf2, vf10); // vmadday.xyzw acc, vf2, vf10 + // nop // sll r0, r0, 0 + c->vmadd_bc(DEST::xyzw, BC::z, vf10, vf3, vf10); // vmaddz.xyzw vf10, vf3, vf10 + // nop // sll r0, r0, 0 + c->vmula_bc(DEST::xyzw, BC::w, vf4, vf0); // vmulaw.xyzw acc, vf4, vf0 + // nop // sll r0, r0, 0 + c->vmadda_bc(DEST::xyzw, BC::x, vf1, vf11); // vmaddax.xyzw acc, vf1, vf11 + // nop // sll r0, r0, 0 + c->vmadda_bc(DEST::xyzw, BC::y, vf2, vf11); // vmadday.xyzw acc, vf2, vf11 + // nop // sll r0, r0, 0 + c->vmadd_bc(DEST::xyzw, BC::z, vf11, vf3, vf11); // vmaddz.xyzw vf11, vf3, vf11 + // nop // sll r0, r0, 0 + c->vmula_bc(DEST::xyzw, BC::w, vf4, vf0); // vmulaw.xyzw acc, vf4, vf0 + // nop // sll r0, r0, 0 + c->vmadda_bc(DEST::xyzw, BC::x, vf1, vf12); // vmaddax.xyzw acc, vf1, vf12 + // nop // sll r0, r0, 0 + c->vmadda_bc(DEST::xyzw, BC::y, vf2, vf12); // vmadday.xyzw acc, vf2, vf12 + // nop // sll r0, r0, 0 + c->vmadd_bc(DEST::xyzw, BC::z, vf12, vf3, vf12); // vmaddz.xyzw vf12, vf3, vf12 + // nop // sll r0, r0, 0 + c->vmula_bc(DEST::xyzw, BC::w, vf16, vf0); // vmulaw.xyzw acc, vf16, vf0 + c->sqc2(vf9, 128, a3); // sqc2 vf9, 128(a3) + c->vmadda_bc(DEST::xyzw, BC::x, vf13, vf9); // vmaddax.xyzw acc, vf13, vf9 + c->sqc2(vf10, 160, a3); // sqc2 vf10, 160(a3) + c->vmadda_bc(DEST::xyzw, BC::y, vf14, vf9); // vmadday.xyzw acc, vf14, vf9 + c->sqc2(vf11, 192, a3); // sqc2 vf11, 192(a3) + c->vmadd_bc(DEST::xyzw, BC::z, vf9, vf15, vf9); // vmaddz.xyzw vf9, vf15, vf9 + c->sqc2(vf12, 224, a3); // sqc2 vf12, 224(a3) + c->vmula_bc(DEST::xyzw, BC::w, vf16, vf0); // vmulaw.xyzw acc, vf16, vf0 + // nop // sll r0, r0, 0 + c->vmadda_bc(DEST::xyzw, BC::x, vf13, vf10); // vmaddax.xyzw acc, vf13, vf10 + // nop // sll r0, r0, 0 + c->vmadda_bc(DEST::xyzw, BC::y, vf14, vf10); // vmadday.xyzw acc, vf14, vf10 + // nop // sll r0, r0, 0 + c->vmadd_bc(DEST::xyzw, BC::z, vf10, vf15, vf10); // vmaddz.xyzw vf10, vf15, vf10 + // nop // sll r0, r0, 0 + c->vmula_bc(DEST::xyzw, BC::w, vf16, vf0); // vmulaw.xyzw acc, vf16, vf0 + // nop // sll r0, r0, 0 + c->vmadda_bc(DEST::xyzw, BC::x, vf13, vf11); // vmaddax.xyzw acc, vf13, vf11 + // nop // sll r0, r0, 0 + c->vmadda_bc(DEST::xyzw, BC::y, vf14, vf11); // vmadday.xyzw acc, vf14, vf11 + // nop // sll r0, r0, 0 + c->vmadd_bc(DEST::xyzw, BC::z, vf11, vf15, vf11); // vmaddz.xyzw vf11, vf15, vf11 + // nop // sll r0, r0, 0 + c->vmula_bc(DEST::xyzw, BC::w, vf16, vf0); // vmulaw.xyzw acc, vf16, vf0 + // nop // sll r0, r0, 0 + c->vmadda_bc(DEST::xyzw, BC::x, vf13, vf12); // vmaddax.xyzw acc, vf13, vf12 + // nop // sll r0, r0, 0 + c->vmadda_bc(DEST::xyzw, BC::y, vf14, vf12); // vmadday.xyzw acc, vf14, vf12 + // nop // sll r0, r0, 0 + c->vmadd_bc(DEST::xyzw, BC::z, vf12, vf15, vf12); // vmaddz.xyzw vf12, vf15, vf12 + // nop // sll r0, r0, 0 + c->vftoi0(DEST::xyzw, vf9, vf9); // vftoi0.xyzw vf9, vf9 + // nop // sll r0, r0, 0 + c->vftoi0(DEST::xyzw, vf10, vf10); // vftoi0.xyzw vf10, vf10 + // nop // sll r0, r0, 0 + c->vftoi0(DEST::xyzw, vf11, vf11); // vftoi0.xyzw vf11, vf11 + // nop // sll r0, r0, 0 + c->vftoi0(DEST::xyzw, vf12, vf12); // vftoi0.xyzw vf12, vf12 + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + c->sqc2(vf9, 144, a3); // sqc2 vf9, 144(a3) + c->daddiu(a0, a0, -4); // daddiu a0, a0, -4 + c->sqc2(vf10, 176, a3); // sqc2 vf10, 176(a3) + // nop // sll r0, r0, 0 + c->sqc2(vf11, 208, a3); // sqc2 vf11, 208(a3) + bc = ((s64)c->sgpr64(a0)) <= 0; // blez a0, L17 + c->sqc2(vf12, 240, a3); // sqc2 vf12, 240(a3) + if (bc) {goto block_3;} // branch non-likely + + c->vmula_bc(DEST::xyzw, BC::w, vf4, vf0); // vmulaw.xyzw acc, vf4, vf0 + c->lqc2(vf9, 64, v1); // lqc2 vf9, 64(v1) + c->vmadda_bc(DEST::xyzw, BC::x, vf1, vf5); // vmaddax.xyzw acc, vf1, vf5 + c->lqc2(vf10, 80, v1); // lqc2 vf10, 80(v1) + c->vmadda_bc(DEST::xyzw, BC::y, vf2, vf5); // vmadday.xyzw acc, vf2, vf5 + c->lqc2(vf11, 96, v1); // lqc2 vf11, 96(v1) + c->vmadd_bc(DEST::xyzw, BC::z, vf5, vf3, vf5); // vmaddz.xyzw vf5, vf3, vf5 + c->lqc2(vf12, 112, v1); // lqc2 vf12, 112(v1) + c->vmula_bc(DEST::xyzw, BC::w, vf4, vf0); // vmulaw.xyzw acc, vf4, vf0 + c->daddiu(a3, a3, 256); // daddiu a3, a3, 256 + c->vmadda_bc(DEST::xyzw, BC::x, vf1, vf6); // vmaddax.xyzw acc, vf1, vf6 + // nop // sll r0, r0, 0 + c->vmadda_bc(DEST::xyzw, BC::y, vf2, vf6); // vmadday.xyzw acc, vf2, vf6 + // nop // sll r0, r0, 0 + c->vmadd_bc(DEST::xyzw, BC::z, vf6, vf3, vf6); // vmaddz.xyzw vf6, vf3, vf6 + // nop // sll r0, r0, 0 + c->vmula_bc(DEST::xyzw, BC::w, vf4, vf0); // vmulaw.xyzw acc, vf4, vf0 + // nop // sll r0, r0, 0 + c->vmadda_bc(DEST::xyzw, BC::x, vf1, vf7); // vmaddax.xyzw acc, vf1, vf7 + // nop // sll r0, r0, 0 + c->vmadda_bc(DEST::xyzw, BC::y, vf2, vf7); // vmadday.xyzw acc, vf2, vf7 + // nop // sll r0, r0, 0 + c->vmadd_bc(DEST::xyzw, BC::z, vf7, vf3, vf7); // vmaddz.xyzw vf7, vf3, vf7 + // nop // sll r0, r0, 0 + c->vmula_bc(DEST::xyzw, BC::w, vf4, vf0); // vmulaw.xyzw acc, vf4, vf0 + // nop // sll r0, r0, 0 + c->vmadda_bc(DEST::xyzw, BC::x, vf1, vf8); // vmaddax.xyzw acc, vf1, vf8 + // nop // sll r0, r0, 0 + c->vmadda_bc(DEST::xyzw, BC::y, vf2, vf8); // vmadday.xyzw acc, vf2, vf8 + // nop // sll r0, r0, 0 + c->vmadd_bc(DEST::xyzw, BC::z, vf8, vf3, vf8); // vmaddz.xyzw vf8, vf3, vf8 + // nop // sll r0, r0, 0 + c->vmula_bc(DEST::xyzw, BC::w, vf16, vf0); // vmulaw.xyzw acc, vf16, vf0 + c->sqc2(vf5, 0, a3); // sqc2 vf5, 0(a3) + c->vmadda_bc(DEST::xyzw, BC::x, vf13, vf5); // vmaddax.xyzw acc, vf13, vf5 + c->sqc2(vf6, 32, a3); // sqc2 vf6, 32(a3) + c->vmadda_bc(DEST::xyzw, BC::y, vf14, vf5); // vmadday.xyzw acc, vf14, vf5 + c->sqc2(vf7, 64, a3); // sqc2 vf7, 64(a3) + c->vmadd_bc(DEST::xyzw, BC::z, vf5, vf15, vf5); // vmaddz.xyzw vf5, vf15, vf5 + c->sqc2(vf8, 96, a3); // sqc2 vf8, 96(a3) + c->vmula_bc(DEST::xyzw, BC::w, vf16, vf0); // vmulaw.xyzw acc, vf16, vf0 + // nop // sll r0, r0, 0 + c->vmadda_bc(DEST::xyzw, BC::x, vf13, vf6); // vmaddax.xyzw acc, vf13, vf6 + // nop // sll r0, r0, 0 + c->vmadda_bc(DEST::xyzw, BC::y, vf14, vf6); // vmadday.xyzw acc, vf14, vf6 + // nop // sll r0, r0, 0 + c->vmadd_bc(DEST::xyzw, BC::z, vf6, vf15, vf6); // vmaddz.xyzw vf6, vf15, vf6 + // nop // sll r0, r0, 0 + c->vmula_bc(DEST::xyzw, BC::w, vf16, vf0); // vmulaw.xyzw acc, vf16, vf0 + // nop // sll r0, r0, 0 + c->vmadda_bc(DEST::xyzw, BC::x, vf13, vf7); // vmaddax.xyzw acc, vf13, vf7 + // nop // sll r0, r0, 0 + c->vmadda_bc(DEST::xyzw, BC::y, vf14, vf7); // vmadday.xyzw acc, vf14, vf7 + // nop // sll r0, r0, 0 + c->vmadd_bc(DEST::xyzw, BC::z, vf7, vf15, vf7); // vmaddz.xyzw vf7, vf15, vf7 + // nop // sll r0, r0, 0 + c->vmula_bc(DEST::xyzw, BC::w, vf16, vf0); // vmulaw.xyzw acc, vf16, vf0 + // nop // sll r0, r0, 0 + c->vmadda_bc(DEST::xyzw, BC::x, vf13, vf8); // vmaddax.xyzw acc, vf13, vf8 + // nop // sll r0, r0, 0 + c->vmadda_bc(DEST::xyzw, BC::y, vf14, vf8); // vmadday.xyzw acc, vf14, vf8 + // nop // sll r0, r0, 0 + c->vmadd_bc(DEST::xyzw, BC::z, vf8, vf15, vf8); // vmaddz.xyzw vf8, vf15, vf8 + // nop // sll r0, r0, 0 + c->vftoi0(DEST::xyzw, vf5, vf5); // vftoi0.xyzw vf5, vf5 + // nop // sll r0, r0, 0 + c->vftoi0(DEST::xyzw, vf6, vf6); // vftoi0.xyzw vf6, vf6 + // nop // sll r0, r0, 0 + c->vftoi0(DEST::xyzw, vf7, vf7); // vftoi0.xyzw vf7, vf7 + // nop // sll r0, r0, 0 + c->vftoi0(DEST::xyzw, vf8, vf8); // vftoi0.xyzw vf8, vf8 + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + c->sqc2(vf5, 16, a3); // sqc2 vf5, 16(a3) + c->daddiu(a0, a0, -4); // daddiu a0, a0, -4 + c->sqc2(vf6, 48, a3); // sqc2 vf6, 48(a3) + c->daddiu(v1, v1, 128); // daddiu v1, v1, 128 + c->sqc2(vf7, 80, a3); // sqc2 vf7, 80(a3) + bc = ((s64)c->sgpr64(a0)) > 0; // bgtz a0, L16 + c->sqc2(vf8, 112, a3); // sqc2 vf8, 112(a3) + if (bc) {goto block_1;} // branch non-likely + + + block_3: + 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 15 collide-mesh)", execute, 128); +} + +} // namespace method_15_collide_mesh +} // namespace Mips2C diff --git a/game/mips2c/functions/collide_probe.cpp b/game/mips2c/functions/collide_probe.cpp index df935dc17..4418c2050 100644 --- a/game/mips2c/functions/collide_probe.cpp +++ b/game/mips2c/functions/collide_probe.cpp @@ -833,7 +833,7 @@ u64 execute(void* ctxt) { block_40: // Unknown instr: vcallms 54 - fmt::print("vcallms54\n"); + // fmt::print("vcallms54\n"); // nop | maddx.xyz vf19, vf04, vf00 c->vmadd_bc(DEST::xyz, BC::w, vf19, vf4, vf0); // nop | mulaw.xyzw ACC, vf20, vf00 diff --git a/game/mips2c/mips2c_private.h b/game/mips2c/mips2c_private.h index 881d75490..c9afb91f1 100644 --- a/game/mips2c/mips2c_private.h +++ b/game/mips2c/mips2c_private.h @@ -759,6 +759,15 @@ struct ExecutionContext { } } + void vabs(DEST mask, int dst, int src) { + auto s = vf_src(src); + for (int i = 0; i < 4; i++) { + if ((u64)mask & (1 << i)) { + vfs[dst].f[i] = std::abs(s.f[i]); + } + } + } + void vrnext(DEST mask, int dst) { gRng.advance(); float r = gRng.R; @@ -988,7 +997,7 @@ struct ExecutionContext { void adds(int dst, int src0, int src1) { fprs[dst] = fprs[src0] + fprs[src1]; } void subs(int dst, int src0, int src1) { fprs[dst] = fprs[src0] - fprs[src1]; } void divs(int dst, int src0, int src1) { - assert(fprs[src1] != 0); + // assert(fprs[src1] != 0); fprs[dst] = fprs[src0] / fprs[src1]; } void negs(int dst, int src) { @@ -998,6 +1007,8 @@ struct ExecutionContext { memcpy(&fprs[dst], &v, 4); } + void movs(int dst, int src) { fprs[dst] = fprs[src]; } + void cvtws(int dst, int src) { // float to int s32 value = fprs[src]; diff --git a/game/mips2c/mips2c_table.cpp b/game/mips2c/mips2c_table.cpp index 851769531..0ad9c9c9d 100644 --- a/game/mips2c/mips2c_table.cpp +++ b/game/mips2c/mips2c_table.cpp @@ -124,6 +124,73 @@ namespace collide_probe_instance_tie { extern void link(); } +namespace method_26_collide_cache { +extern void link(); +} + +namespace method_32_collide_cache { +extern void link(); +} + +namespace pc_upload_collide_frag { +extern void link(); +} + +namespace method_28_collide_cache { +extern void link(); +} + +namespace method_27_collide_cache { +extern void link(); +} + +namespace method_29_collide_cache { +extern void link(); +} + +namespace method_12_collide_shape_prim_mesh { +extern void link(); +} + +namespace method_14_collide_shape_prim_mesh { +extern void link(); +} + +namespace method_13_collide_shape_prim_mesh { +extern void link(); +} + +namespace method_30_collide_cache { +extern void link(); +} + +namespace method_9_collide_cache_prim { +extern void link(); +} + +namespace method_10_collide_cache_prim { +extern void link(); +} + +namespace method_10_collide_puss_work { +extern void link(); +} + +namespace method_9_collide_puss_work { +extern void link(); +} +namespace method_15_collide_mesh { +extern void link(); +} + +namespace method_14_collide_mesh { +extern void link(); +} + +namespace method_16_collide_edge_work { +extern void link(); +} + LinkedFunctionTable gLinkedFunctionTable; Rng gRng; std::unordered_map> gMips2CLinkCallbacks = { @@ -143,7 +210,17 @@ std::unordered_map> gMips2CLinkCallbacks = {"time-of-day", {time_of_day_interp_colors_scratch::link}}, {"collide-func", {collide_do_primitives::link, moving_sphere_triangle_intersect::link}}, {"collide-probe", {collide_probe_node::link, collide_probe_instance_tie::link}}, - {"collide-mesh", {method_12_collide_mesh::link, method_11_collide_mesh::link}}}; + {"collide-mesh", + {method_12_collide_mesh::link, method_11_collide_mesh::link, method_15_collide_mesh::link, + method_14_collide_mesh::link}}, + {"collide-cache", + {method_26_collide_cache::link, method_32_collide_cache::link, pc_upload_collide_frag::link, + method_28_collide_cache::link, method_27_collide_cache::link, method_29_collide_cache::link, + method_12_collide_shape_prim_mesh::link, method_14_collide_shape_prim_mesh::link, + method_13_collide_shape_prim_mesh::link, method_30_collide_cache::link, + method_9_collide_cache_prim::link, method_10_collide_cache_prim::link, + method_10_collide_puss_work::link, method_9_collide_puss_work::link}}, + {"collide-edge-grab", {method_16_collide_edge_work::link}}}; void LinkedFunctionTable::reg(const std::string& name, u64 (*exec)(void*), u32 stack_size) { const auto& it = m_executes.insert({name, {exec, Ptr()}}); diff --git a/game/overlord/srpc.cpp b/game/overlord/srpc.cpp index 22fd39525..78d830865 100644 --- a/game/overlord/srpc.cpp +++ b/game/overlord/srpc.cpp @@ -85,6 +85,12 @@ void* RPC_Loader(unsigned int /*fno*/, void* data, int size) { printf("IOP language: %s\n", gLanguage); // added. break; } + case SoundCommand::LOAD_MUSIC: + printf("ignoring load music\n"); + break; + case SoundCommand::UNLOAD_MUSIC: + printf("ignoring unload music\n"); + break; default: printf("Unhandled RPC Loader command %d\n", (int)cmd->command); assert(false); diff --git a/goal_src/engine/camera/cam-debug.gc b/goal_src/engine/camera/cam-debug.gc index dee1df848..14c057e63 100644 --- a/goal_src/engine/camera/cam-debug.gc +++ b/goal_src/engine/camera/cam-debug.gc @@ -50,3 +50,14 @@ ) ) + + +(define-extern cam-debug-add-los-tri (function (inline-array collide-cache-tri) vector vector none)) +(defun cam-debug-add-los-tri ((a (inline-array collide-cache-tri)) (b vector) (c vector)) + (none) + ) +(defun cam-collision-record-save ((a vector) (b vector) (c int) (d symbol) (e camera-slave)) + (none) + ) +(define-extern slave-los-state->string (function slave-los-state string)) +(define-extern cam-debug-reset-coll-tri (function none)) ;; not confirmed \ No newline at end of file diff --git a/goal_src/engine/camera/cam-states.gc b/goal_src/engine/camera/cam-states.gc index fbeac4d2d..f1720d2c6 100644 --- a/goal_src/engine/camera/cam-states.gc +++ b/goal_src/engine/camera/cam-states.gc @@ -1962,7 +1962,10 @@ (when *debug-segment* (let ((a1-22 (new 'stack-no-clear 'vector))) (vector-! a1-22 (-> self good-point) (-> self string-trans)) - (cam-collision-record-save (-> self string-trans) a1-22 -3 'jump self) + (when (nonzero? cam-collision-record-save) + ;; HACK + (cam-collision-record-save (-> self string-trans) a1-22 -3 'jump self) + ) ) ) (set! (-> self desired-pos quad) (-> self good-point quad)) @@ -2697,7 +2700,9 @@ (defbehavior cam-string-code camera-slave () (if *debug-segment* - (cam-debug-reset-coll-tri) + (when (nonzero? cam-debug-reset-coll-tri) ;; hack + (cam-debug-reset-coll-tri) + ) ) (cam-string-follow) (if (logtest? (-> self options) 512) diff --git a/goal_src/engine/camera/camera-h.gc b/goal_src/engine/camera/camera-h.gc index f5f14b4f3..f54286c57 100644 --- a/goal_src/engine/camera/camera-h.gc +++ b/goal_src/engine/camera/camera-h.gc @@ -156,7 +156,7 @@ (print-nth-point (_type_ int) none 11) (TODO-RENAME-12 (_type_) none 12) (TODO-RENAME-13 (_type_ int) none 13) - (TODO-RENAME-14 (_type_ vector) none 14) + (TODO-RENAME-14 (_type_ tracking-spline-sampler) none 14) (TODO-RENAME-15 (_type_) none 15) (TODO-RENAME-16 (_type_ float) none 16) (TODO-RENAME-17 (_type_ vector float float symbol) int 17) diff --git a/goal_src/engine/camera/camera.gc b/goal_src/engine/camera/camera.gc index 70bc236d2..404cd4c2e 100644 --- a/goal_src/engine/camera/camera.gc +++ b/goal_src/engine/camera/camera.gc @@ -10,485 +10,461 @@ (define *cam-res-string* (new 'global 'string 64 (the-as string #f))) -(defun - cam-slave-get-vector-with-offset - ((arg0 entity-actor) (arg1 vector) (arg2 symbol)) +;; definition for function cam-slave-get-vector-with-offset +;; Used lq/sq +(defun cam-slave-get-vector-with-offset ((arg0 entity-actor) (arg1 vector) (arg2 symbol)) (local-vars (s3-0 structure)) (cond - ((= arg2 'trans) - (set! s3-0 (-> arg0 trans)) + ((= arg2 'trans) + (set! s3-0 (-> arg0 trans)) + ) + ((= arg2 'rot) + (set! s3-0 (-> arg0 quat)) + ) + (else + (set! s3-0 (res-lump-struct arg0 arg2 structure)) + ) ) - ((= arg2 'rot) - (set! s3-0 (-> arg0 quat)) - ) - (else - (set! s3-0 (res-lump-struct arg0 arg2 structure)) - ) - ) (let ((s2-0 (method-of-type res-lump get-property-struct))) - (format (clear *res-key-string*) "~S~S" arg2 '-offset) - (let - ((a0-6 - (s2-0 - arg0 - (string->symbol *res-key-string*) - 'interp - -1000000000.0 - #f - (the-as (pointer res-tag) #f) - *res-static-buf* - ) + (format (clear *res-key-string*) "~S~S" arg2 '-offset) + (let ((a0-6 (s2-0 + arg0 + (string->symbol *res-key-string*) + 'interp + -1000000000.0 + #f + (the-as (pointer res-tag) #f) + *res-static-buf* + ) + ) + ) + (cond + ((and s3-0 a0-6) + (vector+! arg1 (the-as vector s3-0) (the-as vector a0-6)) + #t + ) + ((the-as vector s3-0) + (set! (-> arg1 quad) (-> (the-as vector s3-0) quad)) + #t + ) + (else + #f + ) + ) ) - ) - (cond - ((and s3-0 a0-6) - (vector+! arg1 (the-as vector s3-0) (the-as vector a0-6)) - #t - ) - ((the-as vector s3-0) - (set! (-> arg1 quad) (-> (the-as vector s3-0) quad)) - #t - ) - (else - #f - ) - ) ) - ) ) +;; definition for function cam-slave-get-flags (defun cam-slave-get-flags ((arg0 entity) (arg1 symbol)) (let ((gp-0 (res-lump-value arg0 arg1 uint128)) (s3-0 (method-of-type res-lump get-property-value)) (s2-0 arg0) ) - (format (clear *res-key-string*) "~S~S" arg1 '-on) - (let - ((s3-1 - (s3-0 - s2-0 - (string->symbol *res-key-string*) - 'interp - -1000000000.0 - (the-as uint128 0) - (the-as (pointer res-tag) #f) - *res-static-buf* - ) - ) - (s2-1 (method-of-type res-lump get-property-value)) - ) - (format (clear *res-key-string*) "~S~S" arg1 '-off) - (let - ((v1-3 - (s2-1 - arg0 - (string->symbol *res-key-string*) - 'interp - -1000000000.0 - (the-as uint128 0) - (the-as (pointer res-tag) #f) - *res-static-buf* + (format (clear *res-key-string*) "~S~S" arg1 '-on) + (let ((s3-1 (s3-0 + s2-0 + (string->symbol *res-key-string*) + 'interp + -1000000000.0 + (the-as uint128 0) + (the-as (pointer res-tag) #f) + *res-static-buf* + ) + ) + (s2-1 (method-of-type res-lump get-property-value)) + ) + (format (clear *res-key-string*) "~S~S" arg1 '-off) + (let ((v1-3 (s2-1 + arg0 + (string->symbol *res-key-string*) + 'interp + -1000000000.0 + (the-as uint128 0) + (the-as (pointer res-tag) #f) + *res-static-buf* + ) + ) + ) + (logclear (logior gp-0 s3-1) v1-3) ) - ) ) - (logclear (logior gp-0 s3-1) v1-3) - ) ) - ) ) +;; definition for function cam-slave-get-float (defun cam-slave-get-float ((arg0 entity) (arg1 symbol) (arg2 float)) (let ((f30-0 (res-lump-float arg0 arg1 :default arg2)) (s4-0 (method-of-type res-lump get-property-value-float)) ) - (format (clear *res-key-string*) "~S~S" arg1 '-offset) - (+ - f30-0 - (s4-0 - arg0 - (string->symbol *res-key-string*) - 'interp - -1000000000.0 - 0.0 - (the-as (pointer res-tag) #f) - *res-static-buf* - ) + (format (clear *res-key-string*) "~S~S" arg1 '-offset) + (+ f30-0 (s4-0 + arg0 + (string->symbol *res-key-string*) + 'interp + -1000000000.0 + 0.0 + (the-as (pointer res-tag) #f) + *res-static-buf* + ) + ) ) - ) ) +;; definition for function cam-slave-get-fov (defun cam-slave-get-fov ((arg0 entity)) (let ((f30-0 (res-lump-float arg0 'fov)) (s5-0 (method-of-type res-lump get-property-value-float)) ) - (format (clear *res-key-string*) "~S~S" 'fov '-offset) - (let - ((f0-0 - (s5-0 - arg0 - (string->symbol *res-key-string*) - 'interp - -1000000000.0 - 0.0 - (the-as (pointer res-tag) #f) - *res-static-buf* - ) + (format (clear *res-key-string*) "~S~S" 'fov '-offset) + (let ((f0-0 (s5-0 + arg0 + (string->symbol *res-key-string*) + 'interp + -1000000000.0 + 0.0 + (the-as (pointer res-tag) #f) + *res-static-buf* + ) + ) + ) + (if (= f30-0 0.0) + (+ 11650.845 f0-0) + (+ f30-0 f0-0) + ) ) - ) - (if (= f30-0 0.0) - (+ 11650.845 f0-0) - (+ f30-0 f0-0) - ) ) - ) ) +;; definition for function cam-slave-get-intro-step (defun cam-slave-get-intro-step ((arg0 entity)) (let ((f30-0 (res-lump-float arg0 'intro-time)) (s5-0 (method-of-type res-lump get-property-value-float)) ) - (format (clear *res-key-string*) "~S~S" 'intro-time '-offset) - (let - ((f0-1 - (+ - f30-0 - (s5-0 - arg0 - (string->symbol *res-key-string*) - 'interp - -1000000000.0 - 0.0 - (the-as (pointer res-tag) #f) - *res-static-buf* - ) - ) + (format (clear *res-key-string*) "~S~S" 'intro-time '-offset) + (let ((f0-1 (+ f30-0 (s5-0 + arg0 + (string->symbol *res-key-string*) + 'interp + -1000000000.0 + 0.0 + (the-as (pointer res-tag) #f) + *res-static-buf* + ) + ) + ) + ) + (if (>= 0.0 f0-1) + 0.004166667 + (/ 0.016666668 f0-1) + ) ) - ) - (if (>= 0.0 f0-1) - 0.004166667 - (/ 0.016666668 f0-1) - ) ) - ) ) +;; definition for function cam-slave-get-interp-time (defun cam-slave-get-interp-time ((arg0 entity)) (let ((f30-0 (res-lump-float arg0 'interpTime)) (s5-0 (method-of-type res-lump get-property-value-float)) ) - (format (clear *res-key-string*) "~S~S" 'interpTime '-offset) - (let - ((f0-1 - (+ - f30-0 - (s5-0 - arg0 - (string->symbol *res-key-string*) - 'interp - -1000000000.0 - 0.0 - (the-as (pointer res-tag) #f) - *res-static-buf* - ) - ) + (format (clear *res-key-string*) "~S~S" 'interpTime '-offset) + (let ((f0-1 (+ f30-0 (s5-0 + arg0 + (string->symbol *res-key-string*) + 'interp + -1000000000.0 + 0.0 + (the-as (pointer res-tag) #f) + *res-static-buf* + ) + ) + ) + ) + (if (>= 0.001 f0-1) + (set! f0-1 0.0) + ) + f0-1 ) - ) - (if (>= 0.001 f0-1) - (set! f0-1 0.0) - ) - f0-1 ) - ) ) +;; definition for function cam-slave-get-rot (defun cam-slave-get-rot ((arg0 entity-actor) (arg1 matrix)) (let ((s4-0 (method-of-type res-lump get-property-struct)) (s3-0 arg0) ) - (format (clear *res-key-string*) "~S~S" 'rot '-offset) - (let - ((a1-3 - (s4-0 - s3-0 - (string->symbol *res-key-string*) - 'interp - -1000000000.0 - #f - (the-as (pointer res-tag) #f) - *res-static-buf* - ) + (format (clear *res-key-string*) "~S~S" 'rot '-offset) + (let ((a1-3 (s4-0 + s3-0 + (string->symbol *res-key-string*) + 'interp + -1000000000.0 + #f + (the-as (pointer res-tag) #f) + *res-static-buf* + ) + ) + ) + (cond + (a1-3 + (let ((s4-1 (new 'stack-no-clear 'quaternion))) + (quaternion*! s4-1 (the-as quaternion a1-3) (-> arg0 quat)) + (quaternion-normalize! s4-1) + (quaternion->matrix arg1 s4-1) + ) + ) + (else + (quaternion->matrix arg1 (-> arg0 quat)) + ) + ) ) - ) - (cond - (a1-3 - (let ((s4-1 (new 'stack-no-clear 'quaternion))) - (quaternion*! s4-1 (the-as quaternion a1-3) (-> arg0 quat)) - (quaternion-normalize! s4-1) - (quaternion->matrix arg1 s4-1) - ) - ) - (else - (quaternion->matrix arg1 (-> arg0 quat)) - ) - ) ) - ) arg1 ) +;; definition for function cam-state-from-entity +;; INFO: Return type mismatch (state camera-slave) vs state. (defun cam-state-from-entity ((arg0 entity)) (let ((s5-0 (new 'stack 'curve))) - (cond - ((not arg0) - (the-as state #f) - ) - ((res-lump-struct arg0 'pivot structure) - cam-circular - ) - ((res-lump-struct arg0 'align structure) - cam-standoff-read-entity - ) - ((get-curve-data! arg0 s5-0 'campath 'campath-k -1000000000.0) - cam-spline - ) - ((< 0.0 (cam-slave-get-float arg0 'stringMaxLength 0.0)) - *camera-base-mode* - ) - (else - cam-fixed-read-entity - ) + (the-as state (cond + ((not arg0) + (the-as (state camera-slave) #f) + ) + ((res-lump-struct arg0 'pivot structure) + cam-circular + ) + ((res-lump-struct arg0 'align structure) + cam-standoff-read-entity + ) + ((get-curve-data! arg0 s5-0 'campath 'campath-k -1000000000.0) + cam-spline + ) + ((< 0.0 (cam-slave-get-float arg0 'stringMaxLength 0.0)) + *camera-base-mode* + ) + (else + cam-fixed-read-entity + ) + ) + ) ) - ) ) +;; definition for function parameter-ease-none (defun parameter-ease-none ((arg0 object)) arg0 ) +;; definition for function parameter-ease-clamp (defun parameter-ease-clamp ((arg0 float)) (cond - ((>= arg0 1.0) - (set! arg0 1.0) + ((>= arg0 1.0) + (set! arg0 1.0) + ) + ((>= 0.0 arg0) + (set! arg0 0.0) + ) ) - ((>= 0.0 arg0) - (set! arg0 0.0) - ) - ) arg0 ) +;; definition for function parameter-ease-lerp-clamp (defun parameter-ease-lerp-clamp ((arg0 float)) (cond - ((>= arg0 1.0) - 1.0 + ((>= arg0 1.0) + 1.0 + ) + ((>= 0.0 arg0) + 0.0 + ) + ((>= 0.25 arg0) + (* 0.5 arg0) + ) + ((>= arg0 0.75) + (- 1.0 (* 0.5 (- 1.0 arg0))) + ) + (else + (+ 0.125 (* 1.5 (+ -0.25 arg0))) + ) ) - ((>= 0.0 arg0) - 0.0 - ) - ((>= 0.25 arg0) - (* 0.5 arg0) - ) - ((>= arg0 0.75) - (- 1.0 (* 0.5 (- 1.0 arg0))) - ) - (else - (+ 0.125 (* 1.5 (+ -0.25 arg0))) - ) - ) ) +;; definition for function parameter-ease-sqrt-clamp (defun parameter-ease-sqrt-clamp ((arg0 float)) (cond - ((>= arg0 1.0) - 1.0 + ((>= arg0 1.0) + 1.0 + ) + ((>= 0.0 arg0) + 0.0 + ) + ((>= 0.5 arg0) + (* 0.5 (- 1.0 (sqrtf (- 1.0 (* 2.0 arg0))))) + ) + (else + (* 0.5 (+ 1.0 (sqrtf (+ -1.0 (* 2.0 arg0))))) + ) ) - ((>= 0.0 arg0) - 0.0 - ) - ((>= 0.5 arg0) - (* 0.5 (- 1.0 (sqrtf (- 1.0 (* 2.0 arg0))))) - ) - (else - (* 0.5 (+ 1.0 (sqrtf (+ -1.0 (* 2.0 arg0))))) - ) - ) ) +;; definition for function fourth-power (defun fourth-power ((arg0 float)) (let ((f0-2 (* arg0 arg0))) - (* f0-2 f0-2) - ) + (* f0-2 f0-2) + ) ) +;; definition for function third-power (defun third-power ((arg0 float)) (* arg0 arg0 arg0) ) +;; definition for function parameter-ease-sqr-clamp (defun parameter-ease-sqr-clamp ((arg0 float)) (cond - ((>= arg0 1.0) - 1.0 - ) - ((>= 0.0 arg0) - 0.0 - ) - ((>= 0.5 arg0) - (let ((f0-3 0.5) - (f1-4 (* 2.0 arg0)) - ) - (* f0-3 (* f1-4 f1-4)) + ((>= arg0 1.0) + 1.0 ) - ) - (else - (let ((f0-5 1.0) - (f1-7 0.5) - (f2-2 (* 2.0 (- 1.0 arg0))) - ) - (- f0-5 (* f1-7 (* f2-2 f2-2))) + ((>= 0.0 arg0) + 0.0 ) + ((>= 0.5 arg0) + (let ((f0-3 0.5) + (f1-4 (* 2.0 arg0)) + ) + (* f0-3 (* f1-4 f1-4)) + ) + ) + (else + (let ((f0-5 1.0) + (f1-7 0.5) + (f2-2 (* 2.0 (- 1.0 arg0))) + ) + (- f0-5 (* f1-7 (* f2-2 f2-2))) + ) + ) ) - ) ) +;; definition for function parameter-ease-sin-clamp (defun parameter-ease-sin-clamp ((arg0 float)) (cond - ((>= arg0 1.0) - 1.0 + ((>= arg0 1.0) + 1.0 + ) + ((>= 0.0 arg0) + 0.0 + ) + (else + (+ 0.5 (* 0.5 (sin (* 182.04445 (+ -90.0 (* 180.0 arg0)))))) + ) ) - ((>= 0.0 arg0) - 0.0 - ) - (else - (+ 0.5 (* 0.5 (sin (* 182.04445 (+ -90.0 (* 180.0 arg0)))))) - ) - ) ) -(defmethod - dummy-9 - cam-index - ((obj cam-index) (arg0 symbol) (arg1 entity) (arg2 vector) (arg3 curve)) +;; definition for method 9 of type cam-index +;; Used lq/sq +(defmethod dummy-9 cam-index ((obj cam-index) (arg0 symbol) (arg1 entity) (arg2 vector) (arg3 curve)) (local-vars (sv-32 (function _varargs_ object))) (format (clear *cam-res-string*) "~S-flags" arg0) - (set! - (-> obj flags) - (the-as - cam-index-options - (cam-slave-get-flags arg1 (string->symbol *res-key-string*)) - ) - ) + (set! (-> obj flags) (the-as cam-index-options (cam-slave-get-flags arg1 (string->symbol *res-key-string*)))) (let ((s3-2 (res-lump-data arg1 arg0 pointer)) (s0-1 (method-of-type res-lump get-property-struct)) ) - (set! sv-32 format) - (let ((a0-7 (clear *res-key-string*)) - (a1-4 "~S~S") - (a3-2 '-offset) - ) - (sv-32 a0-7 a1-4 arg0 a3-2) - ) - (let - ((v0-8 - (s0-1 - arg1 - (string->symbol *res-key-string*) - 'interp - -1000000000.0 - #f - (the-as (pointer res-tag) #f) - *res-static-buf* - ) + (set! sv-32 format) + (let ((a0-7 (clear *res-key-string*)) + (a1-4 "~S~S") + (a3-2 '-offset) + ) + (sv-32 a0-7 a1-4 arg0 a3-2) ) - ) - (cond - (s3-2 + (let ((v0-8 (s0-1 + arg1 + (string->symbol *res-key-string*) + 'interp + -1000000000.0 + #f + (the-as (pointer res-tag) #f) + *res-static-buf* + ) + ) + ) (cond - (v0-8 - (vector+! - (the-as vector (-> obj vec)) - (the-as vector (&+ s3-2 0)) - (the-as vector v0-8) - ) - (vector+! - (-> obj vec 1) - (the-as vector (&+ s3-2 16)) - (the-as vector v0-8) - ) + (s3-2 + (cond + (v0-8 + (vector+! (the-as vector (-> obj vec)) (the-as vector (&+ s3-2 0)) (the-as vector v0-8)) + (vector+! (-> obj vec 1) (the-as vector (&+ s3-2 16)) (the-as vector v0-8)) + ) + (else + (set! (-> obj vec 0 quad) (-> (the-as (pointer uint128) (&+ s3-2 0)))) + (set! (-> obj vec 1 quad) (-> (the-as (pointer uint128) (&+ s3-2 16)))) + ) + ) + ) + (arg3 + (set! (-> obj vec 0 quad) (-> (the-as (pointer uint128) (&+ (-> arg3 cverts) 0)))) + (set! (-> obj vec 1 quad) + (-> (the-as (pointer uint128) (&+ (-> arg3 cverts) (* (+ (-> arg3 num-cverts) -1) 16)))) + ) + ) + (else + (return #f) + ) ) - (else - (set! (-> obj vec 0 quad) (-> (the-as (pointer uint128) (&+ s3-2 0)))) - (set! (-> obj vec 1 quad) (-> (the-as (pointer uint128) (&+ s3-2 16)))) - ) - ) ) - (arg3 - (set! - (-> obj vec 0 quad) - (-> (the-as (pointer uint128) (&+ (-> arg3 cverts) 0))) - ) - (set! - (-> obj vec 1 quad) - (-> - (the-as - (pointer uint128) - (&+ (-> arg3 cverts) (* (+ (-> arg3 num-cverts) -1) 16)) - ) - ) - ) - ) - (else - (return #f) - ) - ) ) - ) (let ((s4-1 (new-stack-vector0))) - 0.0 - (cond - ((logtest? (-> obj flags) (cam-index-options SPHERICAL)) - (vector-! s4-1 (-> obj vec 1) arg2) - (set! (-> obj vec 1 w) (vector-length s4-1)) - (vector-! s4-1 (the-as vector (-> obj vec)) arg2) - (set! (-> obj vec 1 x) (vector-length s4-1)) - (set! (-> obj vec 1 w) (- (-> obj vec 1 w) (-> obj vec 1 x))) - (set! (-> obj vec 0 quad) (-> arg2 quad)) - ) - ((logtest? (-> obj flags) (cam-index-options RADIAL)) - (vector-! s4-1 (-> obj vec 1) arg2) - (set! (-> obj vec 1 w) (vector-length s4-1)) - (vector-! s4-1 (the-as vector (-> obj vec)) arg2) - (set! (-> obj vec 1 x) (vector-length s4-1)) - (set! (-> obj vec 1 w) (- (-> obj vec 1 w) (-> obj vec 1 x))) - (set! (-> obj vec 0 quad) (-> arg2 quad)) - ) - (else - (vector-! (-> obj vec 1) (-> obj vec 1) (the-as vector (-> obj vec))) - (set! (-> obj vec 1 w) (vector-normalize-ret-len! (-> obj vec 1) 1.0)) - ) + 0.0 + (cond + ((logtest? (-> obj flags) (cam-index-options SPHERICAL)) + (vector-! s4-1 (-> obj vec 1) arg2) + (set! (-> obj vec 1 w) (vector-length s4-1)) + (vector-! s4-1 (the-as vector (-> obj vec)) arg2) + (set! (-> obj vec 1 x) (vector-length s4-1)) + (set! (-> obj vec 1 w) (- (-> obj vec 1 w) (-> obj vec 1 x))) + (set! (-> obj vec 0 quad) (-> arg2 quad)) + ) + ((logtest? (-> obj flags) (cam-index-options RADIAL)) + (vector-! s4-1 (-> obj vec 1) arg2) + (set! (-> obj vec 1 w) (vector-length s4-1)) + (vector-! s4-1 (the-as vector (-> obj vec)) arg2) + (set! (-> obj vec 1 x) (vector-length s4-1)) + (set! (-> obj vec 1 w) (- (-> obj vec 1 w) (-> obj vec 1 x))) + (set! (-> obj vec 0 quad) (-> arg2 quad)) + ) + (else + (vector-! (-> obj vec 1) (-> obj vec 1) (the-as vector (-> obj vec))) + (set! (-> obj vec 1 w) (vector-normalize-ret-len! (-> obj vec 1) 1.0)) + ) + ) ) - ) #t ) +;; definition for method 10 of type cam-index +;; Used lq/sq (defmethod dummy-10 cam-index ((obj cam-index) (arg0 vector)) (let ((s5-0 (new-stack-vector0))) - 0.0 - (vector-! s5-0 arg0 (the-as vector (-> obj vec))) - (cond - ((logtest? (-> obj flags) (cam-index-options SPHERICAL)) - (vector-flatten! s5-0 s5-0 (-> *camera* local-down)) - (/ (- (vector-length s5-0) (-> obj vec 1 x)) (-> obj vec 1 w)) - ) - ((logtest? (-> obj flags) (cam-index-options RADIAL)) - (/ (- (vector-length s5-0) (-> obj vec 1 x)) (-> obj vec 1 w)) - ) - (else - (/ (vector-dot s5-0 (-> obj vec 1)) (-> obj vec 1 w)) - ) + 0.0 + (vector-! s5-0 arg0 (the-as vector (-> obj vec))) + (cond + ((logtest? (-> obj flags) (cam-index-options SPHERICAL)) + (vector-flatten! s5-0 s5-0 (-> *camera* local-down)) + (/ (- (vector-length s5-0) (-> obj vec 1 x)) (-> obj vec 1 w)) + ) + ((logtest? (-> obj flags) (cam-index-options RADIAL)) + (/ (- (vector-length s5-0) (-> obj vec 1 x)) (-> obj vec 1 w)) + ) + (else + (/ (vector-dot s5-0 (-> obj vec 1)) (-> obj vec 1 w)) + ) + ) ) - ) ) +;; definition for method 10 of type tracking-spline +;; INFO: Return type mismatch int vs none. +;; Used lq/sq (defmethod TODO-RENAME-10 tracking-spline ((obj tracking-spline) (arg0 vector)) (set! (-> obj point 0 position quad) (-> arg0 quad)) (set! (-> obj point 0 next) -134250495) @@ -503,639 +479,524 @@ (set! (-> obj used-count) 1) (set! (-> obj old-position quad) (-> arg0 quad)) (let ((v1-6 1)) - (while (!= v1-6 31) - (set! (-> obj point v1-6 next) (+ v1-6 1)) - (+! v1-6 1) + (while (!= v1-6 31) + (set! (-> obj point v1-6 next) (+ v1-6 1)) + (+! v1-6 1) + ) + (set! (-> obj point v1-6 next) -134250495) ) - (set! (-> obj point v1-6 next) -134250495) - ) 0 (none) ) +;; definition for method 13 of type tracking-spline +;; INFO: Return type mismatch int vs none. (defmethod TODO-RENAME-13 tracking-spline ((obj tracking-spline) (arg0 int)) (let ((v1-3 (-> obj point arg0 next))) - (cond - ((= v1-3 -134250495) - ) - ((= (-> obj point v1-3 next) -134250495) - ) - (else - (set! (-> obj point arg0 next) (-> obj point v1-3 next)) - (set! - (-> obj summed-len) - (- (-> obj summed-len) (-> obj point v1-3 tp-length)) - ) - (set! (-> obj point v1-3 next) (-> obj free-point)) - (set! (-> obj free-point) v1-3) - (+! (-> obj point v1-3 incarnation) 1) - (let ((v1-11 (-> obj point arg0 next))) - (set! - (-> obj summed-len) - (- (-> obj summed-len) (-> obj point arg0 tp-length)) - ) - (vector-! - (the-as vector (+ (the-as uint (-> obj point 0 direction)) (* 48 arg0))) - (the-as vector (-> obj point v1-11)) - (the-as vector (-> obj point arg0)) - ) - ) - (set! - (-> obj point arg0 tp-length) - (vector-normalize-ret-len! - (the-as vector (+ (the-as uint (-> obj point 0 direction)) (* 48 arg0))) - 1.0 - ) - ) - (+! (-> obj summed-len) (-> obj point arg0 tp-length)) - (+! (-> obj used-count) -1) - ) - ) - ) - 0 - (none) - ) - -(defmethod TODO-RENAME-14 tracking-spline ((obj tracking-spline) (arg0 vector)) - (let ((v1-0 (-> obj used-point))) - (set! (-> obj partial-point) (-> arg0 y)) - (when (= (-> obj next-to-last-point) v1-0) - (set! (-> obj summed-len) (-> obj point v1-0 tp-length)) - (if (= (-> arg0 x) (-> obj end-point)) - (set! (-> obj partial-point) 0.99999) - ) - ) - (when (!= (-> arg0 x) v1-0) - (while - (and - (!= (-> obj point v1-0 next) (-> arg0 x)) - (!= (-> obj point v1-0 next) (-> obj next-to-last-point)) - ) - (set! - (-> obj summed-len) - (- (-> obj summed-len) (-> obj point v1-0 tp-length)) - ) - (+! (-> obj point v1-0 incarnation) 1) - (+! (-> obj used-count) -1) - (set! v1-0 (-> obj point v1-0 next)) - ) - (set! - (-> obj summed-len) - (- (-> obj summed-len) (-> obj point v1-0 tp-length)) - ) - (+! (-> obj point v1-0 incarnation) 1) - (+! (-> obj used-count) -1) - (set! (-> obj point v1-0 next) (-> obj free-point)) - (set! (-> obj free-point) (-> obj used-point)) - (set! (-> obj used-point) (the-as int (-> arg0 x))) (cond - ((= (-> arg0 x) (-> obj end-point)) - (set! (-> obj partial-point) 0.0) - (set! (-> obj summed-len) 0.0) - ) - ((= (-> arg0 x) (-> obj next-to-last-point)) - (set! - (-> obj summed-len) - (-> obj point (-> obj next-to-last-point) tp-length) + ((= v1-3 -134250495) ) + ((= (-> obj point v1-3 next) -134250495) + ) + (else + (set! (-> obj point arg0 next) (-> obj point v1-3 next)) + (set! (-> obj summed-len) (- (-> obj summed-len) (-> obj point v1-3 tp-length))) + (set! (-> obj point v1-3 next) (-> obj free-point)) + (set! (-> obj free-point) v1-3) + (+! (-> obj point v1-3 incarnation) 1) + (let ((v1-11 (-> obj point arg0 next))) + (set! (-> obj summed-len) (- (-> obj summed-len) (-> obj point arg0 tp-length))) + (vector-! + (the-as vector (+ (the-as uint (-> obj point 0 direction)) (* 48 arg0))) + (the-as vector (-> obj point v1-11)) + (the-as vector (-> obj point arg0)) + ) + ) + (set! (-> obj point arg0 tp-length) + (vector-normalize-ret-len! (the-as vector (+ (the-as uint (-> obj point 0 direction)) (* 48 arg0))) 1.0) + ) + (+! (-> obj summed-len) (-> obj point arg0 tp-length)) + (+! (-> obj used-count) -1) + ) ) - ) ) - ) 0 (none) ) +;; definition for method 14 of type tracking-spline +;; INFO: Return type mismatch int vs none. +(defmethod TODO-RENAME-14 tracking-spline ((obj tracking-spline) (arg0 tracking-spline-sampler)) + (let ((v1-0 (-> obj used-point))) + (set! (-> obj partial-point) (-> arg0 partial-pt)) + (when (= (-> obj next-to-last-point) v1-0) + (set! (-> obj summed-len) (-> obj point v1-0 tp-length)) + (if (= (-> arg0 cur-pt) (-> obj end-point)) + (set! (-> obj partial-point) 0.99999) + ) + ) + (when (!= (-> arg0 cur-pt) v1-0) + (while (and (!= (-> obj point v1-0 next) (-> arg0 cur-pt)) (!= (-> obj point v1-0 next) (-> obj next-to-last-point))) + (set! (-> obj summed-len) (- (-> obj summed-len) (-> obj point v1-0 tp-length))) + (+! (-> obj point v1-0 incarnation) 1) + (+! (-> obj used-count) -1) + (set! v1-0 (-> obj point v1-0 next)) + ) + (set! (-> obj summed-len) (- (-> obj summed-len) (-> obj point v1-0 tp-length))) + (+! (-> obj point v1-0 incarnation) 1) + (+! (-> obj used-count) -1) + (set! (-> obj point v1-0 next) (-> obj free-point)) + (set! (-> obj free-point) (-> obj used-point)) + (set! (-> obj used-point) (-> arg0 cur-pt)) + (cond + ((= (-> arg0 cur-pt) (-> obj end-point)) + (set! (-> obj partial-point) 0.0) + (set! (-> obj summed-len) 0.0) + ) + ((= (-> arg0 cur-pt) (-> obj next-to-last-point)) + (set! (-> obj summed-len) (-> obj point (-> obj next-to-last-point) tp-length)) + ) + ) + ) + ) + 0 + (none) + ) + +;; definition for method 15 of type tracking-spline +;; INFO: Return type mismatch int vs none. (defmethod TODO-RENAME-15 tracking-spline ((obj tracking-spline)) (let ((s5-0 (new 'stack-no-clear 'tracking-spline-sampler))) - (let ((a2-0 (new 'stack-no-clear 'tracking-point))) - (set! (-> s5-0 cur-pt) (-> obj used-point)) - (set! (-> s5-0 partial-pt) (-> obj partial-point)) - (TODO-RENAME-19 obj (-> obj sample-len) (the-as vector a2-0) s5-0) - ) - (if - (or - (= (-> s5-0 cur-pt) (-> obj end-point)) - (= (-> s5-0 cur-pt) (-> obj next-to-last-point)) - (= (-> obj point (-> s5-0 cur-pt) next) (-> obj next-to-last-point)) - ) - (set! (-> s5-0 cur-pt) (-> obj used-point)) - ) - (let ((v1-15 (-> obj point (-> s5-0 cur-pt) next))) - (when (!= v1-15 -134250495) - (let ((a0-14 (-> obj point v1-15 next)) - (a1-1 v1-15) - (f0-2 -2.0) - ) - 0.0 - (while (not (or (= a0-14 -134250495) (= a0-14 (-> obj end-point)))) - (let - ((f1-2 - (vector-dot - (the-as - vector - (+ (the-as uint (-> obj point 0 direction)) (* 48 v1-15)) - ) - (the-as - vector - (+ - (the-as uint (the-as vector (-> obj point 0 direction))) - (* 48 a0-14) - ) - ) - ) - ) - ) - (when (>= f1-2 f0-2) - (set! f0-2 f1-2) - (set! a1-1 v1-15) - ) - ) - (set! v1-15 a0-14) - (set! a0-14 (-> obj point v1-15 next)) - ) - (if (< -2.0 f0-2) - (TODO-RENAME-13 obj a1-1) - ) + (let ((a2-0 (new 'stack-no-clear 'tracking-point))) + (set! (-> s5-0 cur-pt) (-> obj used-point)) + (set! (-> s5-0 partial-pt) (-> obj partial-point)) + (TODO-RENAME-19 obj (-> obj sample-len) (the-as vector a2-0) s5-0) + ) + (if (or (= (-> s5-0 cur-pt) (-> obj end-point)) + (= (-> s5-0 cur-pt) (-> obj next-to-last-point)) + (= (-> obj point (-> s5-0 cur-pt) next) (-> obj next-to-last-point)) + ) + (set! (-> s5-0 cur-pt) (-> obj used-point)) + ) + (let ((v1-15 (-> obj point (-> s5-0 cur-pt) next))) + (when (!= v1-15 -134250495) + (let ((a0-14 (-> obj point v1-15 next)) + (a1-1 v1-15) + (f0-2 -2.0) + ) + 0.0 + (while (not (or (= a0-14 -134250495) (= a0-14 (-> obj end-point)))) + (let ((f1-2 (vector-dot + (the-as vector (+ (the-as uint (-> obj point 0 direction)) (* 48 v1-15))) + (the-as vector (+ (the-as uint (the-as vector (-> obj point 0 direction))) (* 48 a0-14))) + ) + ) + ) + (when (>= f1-2 f0-2) + (set! f0-2 f1-2) + (set! a1-1 v1-15) + ) + ) + (set! v1-15 a0-14) + (set! a0-14 (-> obj point v1-15 next)) + ) + (if (< -2.0 f0-2) + (TODO-RENAME-13 obj a1-1) + ) + ) + ) ) - ) ) - ) 0 (none) ) +;; definition for method 16 of type tracking-spline +;; INFO: Return type mismatch int vs none. (defmethod TODO-RENAME-16 tracking-spline ((obj tracking-spline) (arg0 float)) (let ((s4-0 (new 'stack-no-clear 'tracking-spline-sampler))) - (let ((a2-0 (new 'stack-no-clear 'vector))) - (set! (-> s4-0 cur-pt) (-> obj used-point)) - (set! (-> s4-0 partial-pt) (-> obj partial-point)) - (TODO-RENAME-19 obj (-> obj sample-len) a2-0 s4-0) - ) - (let ((s4-1 (-> obj point (-> s4-0 cur-pt) next))) - (when (!= s4-1 -134250495) - (let ((v1-11 (-> obj point s4-1 next))) - (while - (not - (or - (= v1-11 -134250495) - (= (-> obj point v1-11 next) -134250495) - (= (-> obj point v1-11 next) (-> obj end-point)) - (= (-> obj point v1-11 next) (-> obj next-to-last-point)) - ) - ) - (if - (< - (* - (-> obj point s4-1 tp-length) - (+ - 1.0 - (vector-dot - (the-as - vector - (+ (the-as uint (-> obj point 0 direction)) (* 48 s4-1)) - ) - (the-as - vector - (+ - (the-as uint (the-as vector (-> obj point 0 direction))) - (* 48 v1-11) - ) - ) - ) - ) - ) - arg0 - ) - (TODO-RENAME-13 obj s4-1) - (set! s4-1 v1-11) - ) - (set! v1-11 (-> obj point s4-1 next)) - ) + (let ((a2-0 (new 'stack-no-clear 'vector))) + (set! (-> s4-0 cur-pt) (-> obj used-point)) + (set! (-> s4-0 partial-pt) (-> obj partial-point)) + (TODO-RENAME-19 obj (-> obj sample-len) a2-0 s4-0) + ) + (let ((s4-1 (-> obj point (-> s4-0 cur-pt) next))) + (when (!= s4-1 -134250495) + (let ((v1-11 (-> obj point s4-1 next))) + (while (not (or (= v1-11 -134250495) + (= (-> obj point v1-11 next) -134250495) + (= (-> obj point v1-11 next) (-> obj end-point)) + (= (-> obj point v1-11 next) (-> obj next-to-last-point)) + ) + ) + (if (< (* (-> obj point s4-1 tp-length) + (+ 1.0 (vector-dot + (the-as vector (+ (the-as uint (-> obj point 0 direction)) (* 48 s4-1))) + (the-as vector (+ (the-as uint (the-as vector (-> obj point 0 direction))) (* 48 v1-11))) + ) + ) + ) + arg0 + ) + (TODO-RENAME-13 obj s4-1) + (set! s4-1 v1-11) + ) + (set! v1-11 (-> obj point s4-1 next)) + ) + ) + ) ) - ) ) - ) 0 (none) ) -(defmethod - TODO-RENAME-17 - tracking-spline - ((obj tracking-spline) (arg0 vector) (arg1 float) (arg2 float) (arg3 symbol)) +;; definition for method 17 of type tracking-spline +;; Used lq/sq +(defmethod TODO-RENAME-17 tracking-spline ((obj tracking-spline) (arg0 vector) (arg1 float) (arg2 float) (arg3 symbol)) (let ((s3-0 (-> obj free-point)) (s2-0 (-> obj end-point)) ) - (vector-! - (the-as vector (+ (the-as uint (-> obj point 0 direction)) (* 48 s2-0))) - arg0 - (the-as vector (-> obj point s2-0)) - ) - (set! - (-> obj point s2-0 tp-length) - (vector-normalize-ret-len! - (the-as vector (+ (the-as uint (-> obj point 0 direction)) (* 48 s2-0))) - 1.0 - ) - ) - (if (< (-> obj point s2-0 tp-length) arg1) - (return 0) - ) - (when (and arg3 (= s3-0 -134250495)) - (TODO-RENAME-15 obj) - (set! s3-0 (-> obj free-point)) - ) - (cond - ((= s3-0 -134250495) - (format 0 "ERROR : pos spline overflow~%") - ) - (else - (+! (-> obj summed-len) (-> obj point s2-0 tp-length)) - (set! (-> obj free-point) (-> obj point s3-0 next)) - (set! (-> obj point s2-0 next) s3-0) - (set! (-> obj end-point) s3-0) - (set! (-> obj next-to-last-point) s2-0) - (set! (-> obj point s3-0 next) -134250495) - (set! (-> obj point s3-0 position quad) (-> arg0 quad)) - (+! (-> obj used-count) 1) - (if (< 0.0 arg2) - (TODO-RENAME-16 obj arg2) + (vector-! + (the-as vector (+ (the-as uint (-> obj point 0 direction)) (* 48 s2-0))) + arg0 + (the-as vector (-> obj point s2-0)) + ) + (set! (-> obj point s2-0 tp-length) + (vector-normalize-ret-len! (the-as vector (+ (the-as uint (-> obj point 0 direction)) (* 48 s2-0))) 1.0) + ) + (if (< (-> obj point s2-0 tp-length) arg1) + (return 0) + ) + (when (and arg3 (= s3-0 -134250495)) + (TODO-RENAME-15 obj) + (set! s3-0 (-> obj free-point)) + ) + (cond + ((= s3-0 -134250495) + (format 0 "ERROR : pos spline overflow~%") + ) + (else + (+! (-> obj summed-len) (-> obj point s2-0 tp-length)) + (set! (-> obj free-point) (-> obj point s3-0 next)) + (set! (-> obj point s2-0 next) s3-0) + (set! (-> obj end-point) s3-0) + (set! (-> obj next-to-last-point) s2-0) + (set! (-> obj point s3-0 next) -134250495) + (set! (-> obj point s3-0 position quad) (-> arg0 quad)) + (+! (-> obj used-count) 1) + (if (< 0.0 arg2) + (TODO-RENAME-16 obj arg2) + ) + ) ) - ) ) - ) 0 ) -(defmethod - TODO-RENAME-18 - tracking-spline - ((obj tracking-spline) - (arg0 float) - (arg1 vector) - (arg2 tracking-spline-sampler) - ) +;; definition for method 18 of type tracking-spline +(defmethod TODO-RENAME-18 tracking-spline ((obj tracking-spline) (arg0 float) (arg1 vector) (arg2 tracking-spline-sampler)) (local-vars (f0-4 float)) (when (not arg2) - (set! arg2 (new 'stack-no-clear 'tracking-spline-sampler)) - (set! (-> arg2 cur-pt) (-> obj used-point)) - (set! (-> arg2 partial-pt) (-> obj partial-point)) - ) + (set! arg2 (new 'stack-no-clear 'tracking-spline-sampler)) + (set! (-> arg2 cur-pt) (-> obj used-point)) + (set! (-> arg2 partial-pt) (-> obj partial-point)) + ) 0.0 (while #t - (cond - ((= (-> arg2 cur-pt) (-> obj end-point)) - (set! (-> arg2 partial-pt) 0.0) - (vector+! arg1 arg1 (the-as vector (-> obj point (-> arg2 cur-pt)))) - (return arg1) - ) - ((begin - (set! - f0-4 - (+ - (-> arg2 partial-pt) - (/ arg0 (-> obj point (-> arg2 cur-pt) tp-length)) - ) + (cond + ((= (-> arg2 cur-pt) (-> obj end-point)) + (set! (-> arg2 partial-pt) 0.0) + (vector+! arg1 arg1 (the-as vector (-> obj point (-> arg2 cur-pt)))) + (return arg1) ) - (< f0-4 1.0) - ) - (set! (-> arg2 partial-pt) f0-4) - (let ((s5-0 (new 'stack-no-clear 'tracking-spline-sampler))) - (let ((a2-5 (-> obj point (-> arg2 cur-pt) next))) - (vector-lerp! - (the-as vector s5-0) - (the-as vector (-> obj point (-> arg2 cur-pt))) - (the-as vector (-> obj point a2-5)) - f0-4 - ) - ) - (vector+! arg1 arg1 (the-as vector s5-0)) - ) - (return arg1) - ) - (else - (let - ((f0-7 - (* - (- 1.0 (-> arg2 partial-pt)) - (-> obj point (-> arg2 cur-pt) tp-length) + ((begin (set! f0-4 (+ (-> arg2 partial-pt) (/ arg0 (-> obj point (-> arg2 cur-pt) tp-length)))) (< f0-4 1.0)) + (set! (-> arg2 partial-pt) f0-4) + (let ((s5-0 (new 'stack-no-clear 'tracking-spline-sampler))) + (let ((a2-5 (-> obj point (-> arg2 cur-pt) next))) + (vector-lerp! + (the-as vector s5-0) + (the-as vector (-> obj point (-> arg2 cur-pt))) + (the-as vector (-> obj point a2-5)) + f0-4 + ) + ) + (vector+! arg1 arg1 (the-as vector s5-0)) ) - ) + (return arg1) ) - (set! arg0 (- arg0 f0-7)) + (else + (let ((f0-7 (* (- 1.0 (-> arg2 partial-pt)) (-> obj point (-> arg2 cur-pt) tp-length)))) + (set! arg0 (- arg0 f0-7)) + ) + (set! (-> arg2 partial-pt) 0.0) + (set! (-> arg2 cur-pt) (-> obj point (-> arg2 cur-pt) next)) + ) ) - (set! (-> arg2 partial-pt) 0.0) - (set! (-> arg2 cur-pt) (-> obj point (-> arg2 cur-pt) next)) - ) ) - ) (the-as vector #f) ) -(defmethod - TODO-RENAME-19 - tracking-spline - ((obj tracking-spline) - (arg0 float) - (arg1 vector) - (arg2 tracking-spline-sampler) - ) +;; definition for method 19 of type tracking-spline +(defmethod TODO-RENAME-19 tracking-spline ((obj tracking-spline) (arg0 float) (arg1 vector) (arg2 tracking-spline-sampler)) (vector-reset! arg1) (TODO-RENAME-18 obj arg0 arg1 arg2) arg1 ) -(defmethod - TODO-RENAME-20 - tracking-spline - ((obj tracking-spline) (arg0 vector) (arg1 int)) +;; definition for method 20 of type tracking-spline +;; INFO: Return type mismatch int vs none. +(defmethod TODO-RENAME-20 tracking-spline ((obj tracking-spline) (arg0 vector) (arg1 int)) (let ((s3-0 (new 'stack-no-clear 'vector))) - (vector-! - s3-0 - (the-as vector (-> obj point (-> obj used-point))) - (the-as vector (-> obj point (-> obj end-point))) - ) - (let* ((f0-0 (vector-length s3-0)) - (f1-1 (* 0.33333334 (- 1.5 (* 0.00024414062 f0-0)))) - ) - 0.0 - (let* ((f1-2 (fmax 0.0 f1-1)) - (f30-0 (+ 0.3 f1-2)) - (f0-1 (cond - ((< - (-> *CAMERA-bank* min-detectable-velocity) - (-> obj summed-len) - ) - (vector-float*! s3-0 s3-0 (/ 1.0 f0-0)) - (/ f0-0 (-> obj summed-len)) + (vector-! + s3-0 + (the-as vector (-> obj point (-> obj used-point))) + (the-as vector (-> obj point (-> obj end-point))) + ) + (let* ((f0-0 (vector-length s3-0)) + (f1-1 (* 0.33333334 (- 1.5 (* 0.00024414062 f0-0)))) + ) + 0.0 + (let* ((f1-2 (fmax 0.0 f1-1)) + (f30-0 (+ 0.3 f1-2)) + (f0-1 (cond + ((< (-> *CAMERA-bank* min-detectable-velocity) (-> obj summed-len)) + (vector-float*! s3-0 s3-0 (/ 1.0 f0-0)) + (/ f0-0 (-> obj summed-len)) + ) + (else + (vector-reset! s3-0) + 0.0 + ) + ) + ) + (f0-2 (+ -0.2 f0-1)) + (f1-9 (* 2.0 f0-2)) + (f28-0 (fmin 1.0 (fmax 0.05 f1-9))) + (v1-8 (-> obj used-point)) + (s2-0 (new 'stack-no-clear 'vector)) + ) + (while (and (!= v1-8 (-> obj end-point)) (!= v1-8 (-> obj next-to-last-point)) (!= v1-8 arg1)) + (let ((s1-0 (-> obj point v1-8 next))) + (vector-! + s2-0 + (the-as vector (+ (the-as uint (-> obj point 0 direction)) (* 48 s1-0))) + (the-as vector (+ (the-as uint (-> obj point 0 direction)) (* 48 v1-8))) + ) + (let* ((f0-4 (vector-normalize-ret-len! s2-0 1.0)) + (f0-5 (* 0.5 f0-4)) + (f26-0 (* (fmin 1.0 f0-5) f30-0 (vector-dot arg0 s2-0))) + ) + (let ((f2-7 (vector-dot s2-0 s3-0))) + (cond + ((>= 0.0 f2-7) ) (else - (vector-reset! s3-0) - 0.0 - ) + (set! f26-0 (* f26-0 (fmax 0.0 (- 0.75 (fabs (* f28-0 f2-7)))))) + ) ) + ) + (cond + ((< f26-0 0.0) + (if (and *debug-segment* *display-camera-marks*) + (camera-line-rel-len + (the-as vector (-> obj point s1-0)) + s2-0 + (* -40.96 f26-0) + (the-as vector4w (new 'static 'inline-array qword 1 + (new 'static 'qword :data (new 'static 'array uint32 4 #xff #xff #x0 #x80)) + ) + ) + ) + ) + (vector--float*! arg0 arg0 s2-0 f26-0) + ) + ((and *debug-segment* *display-camera-marks*) + (camera-line-rel-len + (the-as vector (-> obj point s1-0)) + s2-0 + (* 40.96 f26-0) + (the-as vector4w (new 'static 'inline-array qword 1 + (new 'static 'qword :data (new 'static 'array uint32 4 #x80 #x80 #x0 #x80)) + ) + ) + ) + ) + ) + ) + (set! v1-8 s1-0) ) - (f0-2 (+ -0.2 f0-1)) - (f1-9 (* 2.0 f0-2)) - (f28-0 (fmin 1.0 (fmax 0.05 f1-9))) - (v1-8 (-> obj used-point)) - (s2-0 (new 'stack-no-clear 'vector)) - ) - (while - (and - (!= v1-8 (-> obj end-point)) - (!= v1-8 (-> obj next-to-last-point)) - (!= v1-8 arg1) - ) - (let ((s1-0 (-> obj point v1-8 next))) - (vector-! - s2-0 - (the-as vector (+ (the-as uint (-> obj point 0 direction)) (* 48 s1-0))) - (the-as vector (+ (the-as uint (-> obj point 0 direction)) (* 48 v1-8))) + ) ) - (let* ((f0-4 (vector-normalize-ret-len! s2-0 1.0)) - (f0-5 (* 0.5 f0-4)) - (f26-0 (* (fmin 1.0 f0-5) f30-0 (vector-dot arg0 s2-0))) - ) - (let ((f2-7 (vector-dot s2-0 s3-0))) - (cond - ((>= 0.0 f2-7) - ) - (else - (set! f26-0 (* f26-0 (fmax 0.0 (- 0.75 (fabs (* f28-0 f2-7)))))) - ) - ) - ) - (cond - ((< f26-0 0.0) - (if (and *debug-segment* *display-camera-marks*) - (camera-line-rel-len - (the-as vector (-> obj point s1-0)) - s2-0 - (* -40.96 f26-0) - (the-as - vector4w - (new 'static 'inline-array qword 1 - (new 'static 'qword - :data - (new 'static 'array uint32 4 #xff #xff #x0 #x80) - ) - ) - ) - ) - ) - (vector--float*! arg0 arg0 s2-0 f26-0) - ) - ((and *debug-segment* *display-camera-marks*) - (camera-line-rel-len - (the-as vector (-> obj point s1-0)) - s2-0 - (* 40.96 f26-0) - (the-as - vector4w - (new 'static 'inline-array qword 1 - (new 'static 'qword - :data - (new 'static 'array uint32 4 #x80 #x80 #x0 #x80) - ) - ) - ) - ) - ) - ) - ) - (set! v1-8 s1-0) - ) ) - ) ) - ) 0 (none) ) -(defmethod - TODO-RENAME-21 - tracking-spline - ((obj tracking-spline) (arg0 vector) (arg1 float) (arg2 float)) +;; definition for method 21 of type tracking-spline +;; Used lq/sq +(defmethod TODO-RENAME-21 tracking-spline ((obj tracking-spline) (arg0 vector) (arg1 float) (arg2 float)) (let ((v1-0 (-> obj used-point)) (f0-0 (-> obj partial-point)) ) - (let ((f1-0 (-> obj summed-len))) - 0.0 - 0.0 - (let* ((f1-1 (- f1-0 (* f0-0 (-> obj point v1-0 tp-length)))) - (f2-5 (* 0.1 f1-1)) - (f2-8 - (* - (fmin arg1 (- f2-5 (-> obj max-move))) - (-> *display* time-adjust-ratio) + (let ((f1-0 (-> obj summed-len))) + 0.0 + 0.0 + (let* ((f1-1 (- f1-0 (* f0-0 (-> obj point v1-0 tp-length)))) + (f2-5 (* 0.1 f1-1)) + (f2-8 (* (fmin arg1 (- f2-5 (-> obj max-move))) (-> *display* time-adjust-ratio))) ) - ) - ) - (set! (-> obj max-move) (fmin arg2 (+ (-> obj max-move) f2-8))) - ) - ) - (set! (-> obj max-move) (fmax 0.4096 (-> obj max-move))) - (let ((f1-8 (-> obj summed-len))) - 0.0 - (let* ((f2-14 (- f1-8 (* f0-0 (-> obj point v1-0 tp-length)))) - (f2-16 (fmin 204.8 (- f2-14 (-> obj sample-len)))) - ) - (set! (-> obj sample-len) (fmin 16384.0 (+ (-> obj sample-len) f2-16))) - ) - ) - (let ((s4-0 (new 'stack-no-clear 'tracking-spline-sampler))) - (set! (-> s4-0 cur-pt) v1-0) - (set! (-> s4-0 partial-pt) f0-0) - (TODO-RENAME-19 - obj - (* (-> obj max-move) (-> *display* time-adjust-ratio)) - arg0 - s4-0 - ) - (TODO-RENAME-14 obj (the-as vector s4-0)) - (dotimes (s3-0 63) - (TODO-RENAME-18 obj (* 0.015625 (-> obj sample-len)) arg0 s4-0) - ) - (vector-float*! arg0 arg0 0.015625) - (let ((a2-3 (-> s4-0 cur-pt))) - (set! (-> obj debug-last-point) a2-3) - (let ((s4-1 (new 'stack-no-clear 'vector))) - (set! (-> obj debug-old-position quad) (-> obj old-position quad)) - (set! (-> obj debug-out-position quad) (-> arg0 quad)) - (vector-! s4-1 arg0 (-> obj old-position)) - (TODO-RENAME-20 obj s4-1 a2-3) - (vector+! arg0 (-> obj old-position) s4-1) + (set! (-> obj max-move) (fmin arg2 (+ (-> obj max-move) f2-8))) + ) + ) + (set! (-> obj max-move) (fmax 0.4096 (-> obj max-move))) + (let ((f1-8 (-> obj summed-len))) + 0.0 + (let* ((f2-14 (- f1-8 (* f0-0 (-> obj point v1-0 tp-length)))) + (f2-16 (fmin 204.8 (- f2-14 (-> obj sample-len)))) + ) + (set! (-> obj sample-len) (fmin 16384.0 (+ (-> obj sample-len) f2-16))) + ) + ) + (let ((s4-0 (new 'stack-no-clear 'tracking-spline-sampler))) + (set! (-> s4-0 cur-pt) v1-0) + (set! (-> s4-0 partial-pt) f0-0) + (TODO-RENAME-19 obj (* (-> obj max-move) (-> *display* time-adjust-ratio)) arg0 s4-0) + (TODO-RENAME-14 obj s4-0) + (dotimes (s3-0 63) + (TODO-RENAME-18 obj (* 0.015625 (-> obj sample-len)) arg0 s4-0) + ) + (vector-float*! arg0 arg0 0.015625) + (let ((a2-3 (-> s4-0 cur-pt))) + (set! (-> obj debug-last-point) a2-3) + (let ((s4-1 (new 'stack-no-clear 'vector))) + (set! (-> obj debug-old-position quad) (-> obj old-position quad)) + (set! (-> obj debug-out-position quad) (-> arg0 quad)) + (vector-! s4-1 arg0 (-> obj old-position)) + (TODO-RENAME-20 obj s4-1 a2-3) + (vector+! arg0 (-> obj old-position) s4-1) + ) + ) ) - ) ) - ) (set! (-> obj old-position quad) (-> arg0 quad)) arg0 ) +;; definition for method 22 of type tracking-spline +;; INFO: Return type mismatch int vs none. (defmethod TODO-RENAME-22 tracking-spline ((obj tracking-spline) (arg0 float)) (when (< arg0 (-> obj summed-len)) - (let ((s5-0 (new 'stack-no-clear 'tracking-spline-sampler))) - (let ((a2-0 (new 'stack-no-clear 'vector))) - (set! (-> s5-0 cur-pt) (-> obj used-point)) - (set! (-> s5-0 partial-pt) 0.0) - (TODO-RENAME-19 obj (- (-> obj summed-len) arg0) a2-0 s5-0) - ) - (TODO-RENAME-14 obj (the-as vector s5-0)) + (let ((s5-0 (new 'stack-no-clear 'tracking-spline-sampler))) + (let ((a2-0 (new 'stack-no-clear 'vector))) + (set! (-> s5-0 cur-pt) (-> obj used-point)) + (set! (-> s5-0 partial-pt) 0.0) + (TODO-RENAME-19 obj (- (-> obj summed-len) arg0) a2-0 s5-0) + ) + (TODO-RENAME-14 obj s5-0) + ) ) - ) 0 (none) ) +;; definition for method 9 of type tracking-spline +;; INFO: Return type mismatch int vs none. (defmethod TODO-RENAME-9 tracking-spline ((obj tracking-spline)) (let ((v1-0 (-> obj used-point)) (s4-0 0) (s5-0 0) ) - (while (!= v1-0 -134250495) - (set! s5-0 (logior s5-0 (ash 1 v1-0))) - (+! s4-0 1) - (set! v1-0 (-> obj point v1-0 next)) - ) - (when (!= s4-0 (-> obj used-count)) - (if *debug-segment* - (format - 0 - "ERROR: tracking spline used count ~D actual ~D~%" - (-> obj used-count) - s4-0 + (while (!= v1-0 -134250495) + (set! s5-0 (logior s5-0 (ash 1 v1-0))) + (+! s4-0 1) + (set! v1-0 (-> obj point v1-0 next)) ) - ) - (set! (-> obj used-count) s4-0) - ) - (let ((v1-9 (-> obj free-point)) - (a3-1 0) - ) - (while (!= v1-9 -134250495) - (+! a3-1 1) - (set! v1-9 (-> obj point v1-9 next)) - ) - (when (!= a3-1 (- 32 (-> obj used-count))) - (if *debug-segment* - (format - 0 - "ERROR: tracking spline free count ~D actual ~D~%" - (- 32 (-> obj used-count)) - a3-1 - ) + (when (!= s4-0 (-> obj used-count)) + (if *debug-segment* + (format 0 "ERROR: tracking spline used count ~D actual ~D~%" (-> obj used-count) s4-0) + ) + (set! (-> obj used-count) s4-0) ) - (set! (-> obj free-point) -134250495) - (dotimes (v1-21 32) - (when (zero? (logand s5-0 1)) - (set! (-> obj point v1-21 next) (-> obj free-point)) - (set! (-> obj free-point) v1-21) - ) - (set! s5-0 (shr s5-0 1)) + (let ((v1-9 (-> obj free-point)) + (a3-1 0) + ) + (while (!= v1-9 -134250495) + (+! a3-1 1) + (set! v1-9 (-> obj point v1-9 next)) + ) + (when (!= a3-1 (- 32 (-> obj used-count))) + (if *debug-segment* + (format 0 "ERROR: tracking spline free count ~D actual ~D~%" (- 32 (-> obj used-count)) a3-1) + ) + (set! (-> obj free-point) -134250495) + (dotimes (v1-21 32) + (when (zero? (logand s5-0 1)) + (set! (-> obj point v1-21 next) (-> obj free-point)) + (set! (-> obj free-point) v1-21) + ) + (set! s5-0 (shr s5-0 1)) + ) + ) ) - ) ) - ) 0 (none) ) +;; definition for function cam-slave-init-vars +;; Used lq/sq (defbehavior cam-slave-init-vars camera-slave () (cond - (*camera* - (set! (-> self options) (-> *camera* slave-options)) - (set! - (-> self change-event-from) - (the-as (pointer process-drawable) (-> *camera* changer)) - ) - ) - (else - (set! (-> self options) (the-as uint 0)) - (set! (-> self change-event-from) (the-as (pointer process-drawable) #f)) - ) - ) - (cond - (*camera-combiner* - (set! (-> self trans quad) (-> *camera-combiner* trans quad)) - (let* ((v1-9 (-> self tracking)) - (a3-0 (-> *camera-combiner* inv-camera-rot)) - (a0-1 (-> a3-0 vector 0 quad)) - (a1-0 (-> a3-0 vector 1 quad)) - (a2-0 (-> a3-0 vector 2 quad)) - (a3-1 (-> a3-0 vector 3 quad)) - ) - (set! (-> v1-9 inv-mat vector 0 quad) a0-1) - (set! (-> v1-9 inv-mat vector 1 quad) a1-0) - (set! (-> v1-9 inv-mat vector 2 quad) a2-0) - (set! (-> v1-9 inv-mat vector 3 quad) a3-1) - ) - (when *camera-init-mat* - (let* ((a2-1 (-> self tracking)) - (a3-2 *camera-init-mat*) - (v1-12 (-> a3-2 vector 0 quad)) - (a0-2 (-> a3-2 vector 1 quad)) - (a1-1 (-> a3-2 vector 2 quad)) - (a3-3 (-> a3-2 vector 3 quad)) - ) - (set! (-> a2-1 inv-mat vector 0 quad) v1-12) - (set! (-> a2-1 inv-mat vector 1 quad) a0-2) - (set! (-> a2-1 inv-mat vector 2 quad) a1-1) - (set! (-> a2-1 inv-mat vector 3 quad) a3-3) + (*camera* + (set! (-> self options) (-> *camera* slave-options)) + (set! (-> self change-event-from) (the-as (pointer process-drawable) (-> *camera* changer))) + ) + (else + (set! (-> self options) (the-as uint 0)) + (set! (-> self change-event-from) (the-as (pointer process-drawable) #f)) ) - ) - (set! (-> self fov) (-> *camera-combiner* fov)) - (set! (-> self velocity quad) (-> *camera-combiner* velocity quad)) ) - (else - (vector-reset! (-> self trans)) - (matrix-identity! (the-as matrix (-> self tracking))) - (set! (-> self fov) 11650.845) - (vector-reset! (-> self velocity)) + (cond + (*camera-combiner* + (set! (-> self trans quad) (-> *camera-combiner* trans quad)) + (let* ((v1-9 (-> self tracking)) + (a3-0 (-> *camera-combiner* inv-camera-rot)) + (a0-1 (-> a3-0 vector 0 quad)) + (a1-0 (-> a3-0 vector 1 quad)) + (a2-0 (-> a3-0 vector 2 quad)) + (a3-1 (-> a3-0 vector 3 quad)) + ) + (set! (-> v1-9 inv-mat vector 0 quad) a0-1) + (set! (-> v1-9 inv-mat vector 1 quad) a1-0) + (set! (-> v1-9 inv-mat vector 2 quad) a2-0) + (set! (-> v1-9 inv-mat vector 3 quad) a3-1) + ) + (when *camera-init-mat* + (let* ((a2-1 (-> self tracking)) + (a3-2 *camera-init-mat*) + (v1-12 (-> a3-2 vector 0 quad)) + (a0-2 (-> a3-2 vector 1 quad)) + (a1-1 (-> a3-2 vector 2 quad)) + (a3-3 (-> a3-2 vector 3 quad)) + ) + (set! (-> a2-1 inv-mat vector 0 quad) v1-12) + (set! (-> a2-1 inv-mat vector 1 quad) a0-2) + (set! (-> a2-1 inv-mat vector 2 quad) a1-1) + (set! (-> a2-1 inv-mat vector 3 quad) a3-3) + ) + ) + (set! (-> self fov) (-> *camera-combiner* fov)) + (set! (-> self velocity quad) (-> *camera-combiner* velocity quad)) + ) + (else + (vector-reset! (-> self trans)) + (matrix-identity! (the-as matrix (-> self tracking))) + (set! (-> self fov) 11650.845) + (vector-reset! (-> self velocity)) + ) ) - ) (set! (-> self time-dist-too-far) (the-as uint 0)) (set! (-> self intro-t) 1.0) (set! (-> self intro-t-step) 0.0) @@ -1145,1086 +1006,944 @@ (set! (-> self cam-entity) #f) (set! (-> self tracking no-follow) #f) (init-cam-float-seeker - (-> self tracking tilt-adjust) - (-> *CAMERA-bank* default-tilt-adjust) - 9.102222 - 91.022224 - 0.25 - ) + (-> self tracking tilt-adjust) + (-> *CAMERA-bank* default-tilt-adjust) + 9.102222 + 91.022224 + 0.25 + ) (set! (-> self tracking follow-blend) 1.0) (set! (-> self have-phony-joystick) #f) (set! (-> self string-val-locked) #f) - (init-cam-float-seeker - (-> self tracking point-of-interest-blend) - 0.0 - 0.005 - 0.02 - 0.125 - ) - (init-cam-float-seeker - (-> self tracking underwater-blend) - 0.0 - 0.007 - 0.03 - 0.125 - ) + (init-cam-float-seeker (-> self tracking point-of-interest-blend) 0.0 0.005 0.02 0.125) + (init-cam-float-seeker (-> self tracking underwater-blend) 0.0 0.007 0.03 0.125) (set! (-> self tracking use-point-of-interest) #f) (TODO-RENAME-10 (-> self position-spline) (-> self trans)) (none) ) +;; definition for function cam-slave-go +;; INFO: Return type mismatch int vs none. (defun cam-slave-go ((arg0 state)) (with-pp - (cam-slave-init-vars) - (let ((t9-1 (the-as (function object) enter-state))) - (set! (-> pp next-state) arg0) - (t9-1) + (cam-slave-init-vars) + (let ((t9-1 (the-as (function object) enter-state))) + (set! (-> pp next-state) arg0) + (t9-1) + ) + 0 + (none) ) - 0 - (none) - ) ) +;; definition for function cam-slave-init +;; INFO: Return type mismatch int vs none. (defbehavior cam-slave-init camera-slave ((arg0 state) (arg1 entity)) (stack-size-set! (-> self main-thread) 512) (change-to-last-brother self) (if (and (nonzero? camera-slave-debug) *debug-segment*) - (add-connection *debug-engine* self camera-slave-debug self #f #f) - ) + (add-connection *debug-engine* self camera-slave-debug self #f #f) + ) (cam-slave-init-vars) (let ((v1-7 'cam-voicebox) (a0-4 (the-as basic (-> arg0 name))) ) - (cond - ((= (the-as symbol a0-4) v1-7) - ) - (arg1 - (set! (-> self cam-entity) arg1) - ) - (else - (let ((a1-3 (new 'stack-no-clear 'event-message-block))) - (set! (-> a1-3 from) self) - (set! (-> a1-3 num-params) 1) - (set! (-> a1-3 message) 'slave-activated) - (set! (-> a1-3 param 0) (the-as uint self)) - (let ((t9-4 send-event-function)) - (set! a0-4 *camera*) - (t9-4 (the-as camera-master a0-4) a1-3) + (cond + ((= (the-as symbol a0-4) v1-7) ) + (arg1 + (set! (-> self cam-entity) arg1) + ) + (else + (let ((a1-3 (new 'stack-no-clear 'event-message-block))) + (set! (-> a1-3 from) self) + (set! (-> a1-3 num-params) 1) + (set! (-> a1-3 message) 'slave-activated) + (set! (-> a1-3 param 0) (the-as uint self)) + (let ((t9-4 send-event-function)) + (set! a0-4 *camera*) + (t9-4 (the-as camera-master a0-4) a1-3) + ) + ) + ) + ) + (let ((t9-5 (the-as (function object object) (-> arg0 enter)))) + (if t9-5 + (t9-5 (the-as symbol a0-4)) + ) + ) + (set! (-> self enter-has-run) #t) + (set! (-> self event-hook) (-> arg0 event)) + (let ((t9-6 (the-as (function object object) enter-state))) + (set! (-> self next-state) arg0) + (t9-6 (the-as symbol a0-4)) ) - ) ) - (let ((t9-5 (the-as (function object object) (-> arg0 enter)))) - (if t9-5 - (t9-5 (the-as symbol a0-4)) - ) - ) - (set! (-> self enter-has-run) #t) - (set! (-> self event-hook) (-> arg0 event)) - (let ((t9-6 (the-as (function object object) enter-state))) - (set! (-> self next-state) arg0) - (t9-6 (the-as symbol a0-4)) - ) - ) 0 (none) ) -;; WARN: rewrite_to_get_var got a none typed variable. Is there unreachable code? -;; WARN: rewrite_to_get_var got a none typed variable. Is there unreachable code? -;; WARN: rewrite_to_get_var got a none typed variable. Is there unreachable code? -;; WARN: rewrite_to_get_var got a none typed variable. Is there unreachable code? -(defbehavior - cam-standard-event-handler camera-slave - ((arg0 process) (arg1 int) (arg2 symbol) (arg3 event-message-block)) +;; definition for function cam-standard-event-handler +;; INFO: Return type mismatch none vs object. +;; WARN: rewrite_to_get_var got a none typed variable. Is there unreachable code? [OP: 7] +;; WARN: rewrite_to_get_var got a none typed variable. Is there unreachable code? [OP: 31] +;; WARN: rewrite_to_get_var got a none typed variable. Is there unreachable code? [OP: 45] +;; WARN: rewrite_to_get_var got a none typed variable. Is there unreachable code? [OP: 50] +;; Used lq/sq +(defbehavior cam-standard-event-handler camera-slave ((arg0 process) (arg1 int) (arg2 symbol) (arg3 event-message-block)) (let ((v1-0 arg2)) - (the-as object (cond - ((= v1-0 'go) - (let ((v1-1 (-> arg3 param 0)) - (t9-0 (the-as (function object) enter-state)) - ) - (set! (-> self next-state) (the-as state v1-1)) - (t9-0) - ) - ) - ((or (= v1-0 'change-state) (= v1-0 'change-state-no-go)) - (let ((s5-0 (the-as object (-> arg3 param 0)))) - (cam-slave-init-vars) - (let - ((t9-2 - (the-as - (function object) - (-> (the-as state s5-0) enter) - ) - ) - ) - (if t9-2 - (t9-2) - ) - ) - (set! (-> self enter-has-run) #t) - (set! (-> self event-hook) (-> (the-as state s5-0) event)) - (when (= arg2 'change-state) - (let ((t9-3 (the-as (function object) enter-state))) - (set! (-> self next-state) (the-as state s5-0)) - (t9-3) - ) - ) - ) - ) - ((= v1-0 'point-of-interest) - (cond - ((-> arg3 param 0) - (set! (-> self tracking use-point-of-interest) #t) - (set! - (-> self tracking point-of-interest quad) - (-> (the-as vector (-> arg3 param 0)) quad) - ) - (let ((f0-0 1.0)) - (set! - (-> self tracking point-of-interest-blend target) - f0-0 - ) - f0-0 - ) - ) - (else - (set! (-> self tracking use-point-of-interest) #f) - (let ((f0-1 0.0)) - (set! - (-> self tracking point-of-interest-blend target) - f0-1 - ) - f0-1 - ) - ) - ) - ) - ((= v1-0 'teleport) - (cam-calc-follow! (-> self tracking) (-> self trans) #f) - (slave-set-rotation! - (-> self tracking) - (-> self trans) - (the-as float (-> self options)) - (-> self fov) - #f - ) - ) - ) + (the-as + object + (cond + ((= v1-0 'go) + (let ((v1-1 (-> arg3 param 0)) + (t9-0 (the-as (function object) enter-state)) + ) + (set! (-> self next-state) (the-as state v1-1)) + (t9-0) + ) + ) + ((or (= v1-0 'change-state) (= v1-0 'change-state-no-go)) + (let ((s5-0 (the-as object (-> arg3 param 0)))) + (cam-slave-init-vars) + (let ((t9-2 (the-as (function object) (-> (the-as state s5-0) enter)))) + (if t9-2 + (t9-2) + ) + ) + (set! (-> self enter-has-run) #t) + (set! (-> self event-hook) (-> (the-as state s5-0) event)) + (when (= arg2 'change-state) + (let ((t9-3 (the-as (function object) enter-state))) + (set! (-> self next-state) (the-as state s5-0)) + (t9-3) + ) + ) + ) + ) + ((= v1-0 'point-of-interest) + (cond + ((-> arg3 param 0) + (set! (-> self tracking use-point-of-interest) #t) + (set! (-> self tracking point-of-interest quad) (-> (the-as vector (-> arg3 param 0)) quad)) + (let ((f0-0 1.0)) + (set! (-> self tracking point-of-interest-blend target) f0-0) + f0-0 + ) + ) + (else + (set! (-> self tracking use-point-of-interest) #f) + (let ((f0-1 0.0)) + (set! (-> self tracking point-of-interest-blend target) f0-1) + f0-1 + ) + ) + ) + ) + ((= v1-0 'teleport) + (cam-calc-follow! (-> self tracking) (-> self trans) #f) + (slave-set-rotation! (-> self tracking) (-> self trans) (the-as float (-> self options)) (-> self fov) #f) + ) + ) + ) ) - ) ) -(defbehavior - cam-curve-pos camera-slave - ((arg0 vector) (arg1 vector) (arg2 curve) (arg3 symbol)) +;; definition for function cam-curve-pos +;; Used lq/sq +(defbehavior cam-curve-pos camera-slave ((arg0 vector) (arg1 vector) (arg2 curve) (arg3 symbol)) (let ((s5-0 (new-stack-vector0))) - 0.0 - (let ((s2-0 (new-stack-vector0))) - (if arg1 - (set! (-> arg1 w) 0.0) - ) - (when (< (-> self intro-t) 1.0) - (+! - (-> self intro-t) - (* (-> self intro-t-step) (-> *display* time-adjust-ratio)) - ) - (if (< 1.0 (-> self intro-t)) - (set! (-> self intro-t) 1.0) - ) - (curve-get-pos! - s5-0 - (parameter-ease-sin-clamp (-> self intro-t)) - (-> self intro-curve) - ) - (vector+! s5-0 s5-0 (-> self intro-offset)) - (vector+! arg0 arg0 s5-0) - (cond - ((not arg1) - ) - ((< (-> self intro-t) 0.5) - (curve-get-pos! - s2-0 - (+ 0.0001 (parameter-ease-sin-clamp (-> self intro-t))) - (-> self intro-curve) + 0.0 + (let ((s2-0 (new-stack-vector0))) + (if arg1 + (set! (-> arg1 w) 0.0) + ) + (when (< (-> self intro-t) 1.0) + (+! (-> self intro-t) (* (-> self intro-t-step) (-> *display* time-adjust-ratio))) + (if (< 1.0 (-> self intro-t)) + (set! (-> self intro-t) 1.0) + ) + (curve-get-pos! s5-0 (parameter-ease-sin-clamp (-> self intro-t)) (-> self intro-curve)) + (vector+! s5-0 s5-0 (-> self intro-offset)) + (vector+! arg0 arg0 s5-0) + (cond + ((not arg1) + ) + ((< (-> self intro-t) 0.5) + (curve-get-pos! s2-0 (+ 0.0001 (parameter-ease-sin-clamp (-> self intro-t))) (-> self intro-curve)) + (vector+! s2-0 s2-0 (-> self intro-offset)) + (vector-! arg1 s2-0 s5-0) + (set! (-> arg1 w) 1.0) + ) + (else + (curve-get-pos! s2-0 (+ -0.0001 (parameter-ease-sin-clamp (-> self intro-t))) (-> self intro-curve)) + (vector+! s2-0 s2-0 (-> self intro-offset)) + (vector-! arg1 s5-0 s2-0) + (set! (-> arg1 w) 1.0) + ) + ) ) - (vector+! s2-0 s2-0 (-> self intro-offset)) - (vector-! arg1 s2-0 s5-0) - (set! (-> arg1 w) 1.0) + ) + (cond + ((not (-> self spline-exists)) + ) + ((= (-> self spline-follow-dist) 0.0) + (let ((f0-18 (if arg3 + (dummy-10 (-> self index) (-> self tracking follow-pt)) + (dummy-10 (-> self index) (-> *camera* tpos-curr-adj)) + ) + ) + ) + (curve-get-pos! s5-0 f0-18 (-> self spline-curve)) + ) + (vector+! s5-0 s5-0 (-> self spline-offset)) + (vector+! arg0 arg0 s5-0) ) (else - (curve-get-pos! - s2-0 - (+ -0.0001 (parameter-ease-sin-clamp (-> self intro-t))) - (-> self intro-curve) + (let ((s3-1 (new 'stack-no-clear 'vector))) + (curve-length (-> self spline-curve)) + (if arg3 + (set! (-> s3-1 quad) (-> self tracking follow-pt quad)) + (set! (-> s3-1 quad) (-> *camera* tpos-curr-adj quad)) + ) + (set! (-> self spline-tt) + (curve-closest-point (-> self spline-curve) s3-1 (-> self spline-tt) 1024.0 10 (-> self spline-follow-dist)) + ) + ) + (curve-get-pos! s5-0 (-> self spline-tt) (-> self spline-curve)) + (vector+! s5-0 s5-0 (-> self spline-offset)) + (vector+! arg0 arg0 s5-0) ) - (vector+! s2-0 s2-0 (-> self intro-offset)) - (vector-! arg1 s5-0 s2-0) - (set! (-> arg1 w) 1.0) - ) ) - ) ) - (cond - ((not (-> self spline-exists)) - ) - ((= (-> self spline-follow-dist) 0.0) - (let ((f0-18 (if arg3 - (dummy-10 (-> self index) (-> self tracking follow-pt)) - (dummy-10 (-> self index) (-> *camera* tpos-curr-adj)) - ) - ) - ) - (curve-get-pos! s5-0 f0-18 (-> self spline-curve)) - ) - (vector+! s5-0 s5-0 (-> self spline-offset)) - (vector+! arg0 arg0 s5-0) - ) - (else - (let ((s3-1 (new 'stack-no-clear 'vector))) - (curve-length (-> self spline-curve)) - (if arg3 - (set! (-> s3-1 quad) (-> self tracking follow-pt quad)) - (set! (-> s3-1 quad) (-> *camera* tpos-curr-adj quad)) - ) - (set! - (-> self spline-tt) - (curve-closest-point - (-> self spline-curve) - s3-1 - (-> self spline-tt) - 1024.0 - 10 - (-> self spline-follow-dist) - ) - ) - ) - (curve-get-pos! s5-0 (-> self spline-tt) (-> self spline-curve)) - (vector+! s5-0 s5-0 (-> self spline-offset)) - (vector+! arg0 arg0 s5-0) - ) - ) - ) arg0 ) +;; definition for function cam-curve-setup +;; INFO: Return type mismatch int vs none. (defbehavior cam-curve-setup camera-slave ((arg0 vector)) - (when - (get-curve-data! - (-> self cam-entity) - (-> self spline-curve) - 'campath - 'campath-k - -1000000000.0 + (when (get-curve-data! (-> self cam-entity) (-> self spline-curve) 'campath 'campath-k -1000000000.0) + (curve-get-pos! (-> self spline-offset) 0.0 (-> self spline-curve)) + (vector-negate! (-> self spline-offset) (-> self spline-offset)) + (dummy-9 (-> self index) 'campoints (-> self cam-entity) arg0 (-> self spline-curve)) + (set! (-> self spline-exists) #t) ) - (curve-get-pos! (-> self spline-offset) 0.0 (-> self spline-curve)) - (vector-negate! (-> self spline-offset) (-> self spline-offset)) - (dummy-9 - (-> self index) - 'campoints - (-> self cam-entity) - arg0 - (-> self spline-curve) - ) - (set! (-> self spline-exists) #t) - ) (cond - ((get-curve-data! - (-> self cam-entity) - (-> self intro-curve) - 'intro - 'intro-k - -1000000000.0 - ) - (curve-get-pos! (-> self intro-offset) 1.0 (-> self intro-curve)) - (vector-negate! (-> self intro-offset) (-> self intro-offset)) - (set! (-> self intro-t) 0.0) - (set! - (-> self intro-t-step) - (cam-slave-get-intro-step (-> self cam-entity)) - ) - (set! - (-> self outro-exit-value) - (cam-slave-get-float (-> self cam-entity) 'intro-exitValue 0.0) - ) - (if (= (-> self outro-exit-value) 0.0) - (set! (-> self outro-exit-value) 0.5) + ((get-curve-data! (-> self cam-entity) (-> self intro-curve) 'intro 'intro-k -1000000000.0) + (curve-get-pos! (-> self intro-offset) 1.0 (-> self intro-curve)) + (vector-negate! (-> self intro-offset) (-> self intro-offset)) + (set! (-> self intro-t) 0.0) + (set! (-> self intro-t-step) (cam-slave-get-intro-step (-> self cam-entity))) + (set! (-> self outro-exit-value) (cam-slave-get-float (-> self cam-entity) 'intro-exitValue 0.0)) + (if (= (-> self outro-exit-value) 0.0) + (set! (-> self outro-exit-value) 0.5) + ) ) + (else + (set! (-> self intro-t) 1.0) + (set! (-> self intro-t-step) 0.0) + ) ) - (else - (set! (-> self intro-t) 1.0) - (set! (-> self intro-t-step) 0.0) - ) - ) (if (nonzero? (-> *camera* no-intro)) - (set! (-> self intro-t) 1.0) - ) + (set! (-> self intro-t) 1.0) + ) 0 (none) ) +;; definition for function cam-calc-follow! +;; Used lq/sq (defun cam-calc-follow! ((arg0 cam-rotation-tracker) (arg1 vector) (arg2 symbol)) (with-pp - (cond - (arg2 - (update! (-> arg0 tilt-adjust) 0.0) - (update! (-> arg0 point-of-interest-blend) 0.0) - (update! (-> arg0 underwater-blend) 0.0) - ) - (else - (jump-to-target! (-> arg0 tilt-adjust) 0.0) - (jump-to-target! (-> arg0 point-of-interest-blend) 0.0) - (jump-to-target! (-> arg0 underwater-blend) 0.0) - ) - ) - (let ((a1-7 (new 'stack-no-clear 'event-message-block))) - (set! (-> a1-7 from) pp) - (set! (-> a1-7 num-params) 1) - (set! (-> a1-7 message) 'slave-option?) - (set! (-> a1-7 param 0) (the-as uint #x4000)) (cond - ((send-event-function *camera* a1-7) - (let ((s3-0 (new 'stack-no-clear 'vector)) - (s2-0 (new 'stack-no-clear 'vector)) - (f30-0 - (vector-vector-distance - (-> *camera* tpos-curr-adj) - (-> *camera* tpos-old-adj) - ) + (arg2 + (update! (-> arg0 tilt-adjust) 0.0) + (update! (-> arg0 point-of-interest-blend) 0.0) + (update! (-> arg0 underwater-blend) 0.0) + ) + (else + (jump-to-target! (-> arg0 tilt-adjust) 0.0) + (jump-to-target! (-> arg0 point-of-interest-blend) 0.0) + (jump-to-target! (-> arg0 underwater-blend) 0.0) + ) + ) + (let ((a1-7 (new 'stack-no-clear 'event-message-block))) + (set! (-> a1-7 from) pp) + (set! (-> a1-7 num-params) 1) + (set! (-> a1-7 message) 'slave-option?) + (set! (-> a1-7 param 0) (the-as uint #x4000)) + (cond + ((send-event-function *camera* a1-7) + (let ((s3-0 (new 'stack-no-clear 'vector)) + (s2-0 (new 'stack-no-clear 'vector)) + (f30-0 (vector-vector-distance (-> *camera* tpos-curr-adj) (-> *camera* tpos-old-adj))) + (s5-1 (new 'stack-no-clear 'vector)) + ) + (vector-flatten! s3-0 (-> *camera* tgt-face-mat vector 2) (-> *camera* local-down)) + (vector-normalize! s3-0 1.0) + (vector-! s2-0 (-> *camera* tpos-curr-adj) arg1) + (vector-flatten! s2-0 s2-0 (-> *camera* local-down)) + (vector-normalize! s2-0 1.0) + (vector-float*! s5-1 (-> *camera* tgt-face-mat vector 2) 32768.0) + (let* ((f30-1 (lerp-clamp 0.7 0.4 (parameter-ease-sin-clamp (* 0.00081380206 (+ -409.6 f30-0))))) + (f0-4 (acos (vector-dot s2-0 s3-0))) + (f28-0 (fmax 1820.4445 f0-4)) + ) + (if (< f28-0 8192.0) + (vector-float*! + s5-1 + s5-1 + (+ f30-1 + (* (/ (- 1.0 f30-1) (- 1.0 (cos 32768.0))) (+ (- (cos 32768.0)) (cos (* 5.142857 (- 8192.0 f28-0))))) + ) + ) + ) ) - (s5-1 (new 'stack-no-clear 'vector)) - ) - (vector-flatten! - s3-0 - (-> *camera* tgt-face-mat vector 2) - (-> *camera* local-down) - ) - (vector-normalize! s3-0 1.0) - (vector-! s2-0 (-> *camera* tpos-curr-adj) arg1) - (vector-flatten! s2-0 s2-0 (-> *camera* local-down)) - (vector-normalize! s2-0 1.0) - (vector-float*! s5-1 (-> *camera* tgt-face-mat vector 2) 32768.0) - (let* - ((f30-1 - (lerp-clamp - 0.7 - 0.4 - (parameter-ease-sin-clamp (* 0.00081380206 (+ -409.6 f30-0))) - ) - ) - (f0-4 (acos (vector-dot s2-0 s3-0))) - (f28-0 (fmax 1820.4445 f0-4)) - ) - (if (< f28-0 8192.0) - (vector-float*! - s5-1 - s5-1 - (+ - f30-1 - (* - (/ (- 1.0 f30-1) (- 1.0 (cos 32768.0))) - (+ (- (cos 32768.0)) (cos (* 5.142857 (- 8192.0 f28-0)))) - ) - ) - ) - ) - ) - (cond - ((< (-> *camera* ease-t) 1.0) - ) - ((< (-> arg0 follow-blend) 1.0) - (let* ((f0-18 (-> arg0 follow-blend)) - (f0-19 (* f0-18 f0-18)) - (f0-20 (* f0-19 f0-19)) + (cond + ((< (-> *camera* ease-t) 1.0) + ) + ((< (-> arg0 follow-blend) 1.0) + (let* ((f0-18 (-> arg0 follow-blend)) + (f0-19 (* f0-18 f0-18)) + (f0-20 (* f0-19 f0-19)) + ) + (vector-! s5-1 s5-1 (-> arg0 follow-off)) + (vector-float*! s5-1 s5-1 f0-20) ) - (vector-! s5-1 s5-1 (-> arg0 follow-off)) - (vector-float*! s5-1 s5-1 f0-20) - ) - (+! - (-> arg0 follow-blend) - (* 0.016666668 (-> *display* time-adjust-ratio)) - ) - (vector+! (-> arg0 follow-off) (-> arg0 follow-off) s5-1) + (+! (-> arg0 follow-blend) (* 0.016666668 (-> *display* time-adjust-ratio))) + (vector+! (-> arg0 follow-off) (-> arg0 follow-off) s5-1) + ) + (else + (set! (-> arg0 follow-off quad) (-> s5-1 quad)) + ) + ) + ) + (vector+! (-> arg0 follow-pt) (-> *camera* tpos-curr-adj) (-> arg0 follow-off)) + (vector--float*! + (-> arg0 follow-pt) + (-> arg0 follow-pt) + (-> *camera* local-down) + (+ 12288.0 (-> *camera* target-height)) + ) ) (else - (set! (-> arg0 follow-off quad) (-> s5-1 quad)) - ) - ) - ) - (vector+! - (-> arg0 follow-pt) - (-> *camera* tpos-curr-adj) - (-> arg0 follow-off) - ) - (vector--float*! - (-> arg0 follow-pt) - (-> arg0 follow-pt) - (-> *camera* local-down) - (+ 12288.0 (-> *camera* target-height)) - ) - ) - (else - 0.0 - (let ((s3-2 (new-stack-vector0))) - (set! (-> arg0 follow-blend) 0.0) - (cond - ((-> arg0 no-follow) - (vector-reset! s3-2) - ) - (else - (vector-! s3-2 (-> *camera* tpos-curr-adj) arg1) - (vector-normalize! s3-2 1.0) - (let* ((f0-28 (vector-dot (-> *camera* tgt-rot-mat vector 2) s3-2)) - (f30-2 (cond - ((< f0-28 0.0) - 1.0 - ) - (else - (let* ((f0-29 (* f0-28 f0-28)) - (f0-30 (- 1.0 f0-29)) + 0.0 + (let ((s3-2 (new-stack-vector0))) + (set! (-> arg0 follow-blend) 0.0) + (cond + ((-> arg0 no-follow) + (vector-reset! s3-2) + ) + (else + (vector-! s3-2 (-> *camera* tpos-curr-adj) arg1) + (vector-normalize! s3-2 1.0) + (let* ((f0-28 (vector-dot (-> *camera* tgt-rot-mat vector 2) s3-2)) + (f30-2 (cond + ((< f0-28 0.0) + 1.0 + ) + (else + (let* ((f0-29 (* f0-28 f0-28)) (f0-30 (- 1.0 f0-29))) (* f0-30 (* f0-30 f0-30))) + ) ) - (* f0-30 (* f0-30 f0-30)) - ) + ) + ) + (vector-! s3-2 arg1 (-> *camera* tpos-curr-adj)) + (vector-flatten! s3-2 s3-2 (-> *camera* local-down)) + (let* ((f0-33 (* 0.000022194603 (+ -20480.0 (vector-length s3-2)))) + (f0-34 (fmin 1.0 f0-33)) + (f0-35 (fmax 0.0 f0-34)) ) - ) - ) + (vector-float*! s3-2 (-> *camera* tgt-rot-mat vector 2) (* (lerp 2048.0 8192.0 f0-35) f30-2)) + ) + ) + ) + ) + (if arg2 + (vector-seek-3d-smooth! (-> arg0 follow-off) s3-2 (* 20480.0 (-> *display* seconds-per-frame)) 0.05) + (set! (-> arg0 follow-off quad) (-> s3-2 quad)) ) - (vector-! s3-2 arg1 (-> *camera* tpos-curr-adj)) - (vector-flatten! s3-2 s3-2 (-> *camera* local-down)) - (let* ((f0-33 (* 0.000022194603 (+ -20480.0 (vector-length s3-2)))) - (f0-34 (fmin 1.0 f0-33)) - (f0-35 (fmax 0.0 f0-34)) - ) - (vector-float*! - s3-2 - (-> *camera* tgt-rot-mat vector 2) - (* (lerp 2048.0 8192.0 f0-35) f30-2) ) - ) + (vector+! (-> arg0 follow-pt) (-> *camera* tpos-curr-adj) (-> arg0 follow-off)) + (vector--float*! (-> arg0 follow-pt) (-> arg0 follow-pt) (-> *camera* local-down) (-> *camera* target-height)) ) - ) ) - (if arg2 - (vector-seek-3d-smooth! - (-> arg0 follow-off) - s3-2 - (* 20480.0 (-> *display* seconds-per-frame)) - 0.05 - ) - (set! (-> arg0 follow-off quad) (-> s3-2 quad)) - ) - ) - (vector+! - (-> arg0 follow-pt) - (-> *camera* tpos-curr-adj) - (-> arg0 follow-off) - ) - (vector--float*! - (-> arg0 follow-pt) - (-> arg0 follow-pt) - (-> *camera* local-down) - (-> *camera* target-height) - ) ) - ) + (-> arg0 follow-pt) ) - (-> arg0 follow-pt) - ) ) +;; definition for function mat-remove-z-rot +;; Used lq/sq (defun mat-remove-z-rot ((arg0 matrix) (arg1 vector)) (let ((s4-0 (new-stack-vector0))) - 0.0 - 0.0 - (let ((s5-0 (new-stack-matrix0))) - (vector-negate! s4-0 arg1) - (vector-flatten! s4-0 s4-0 (-> arg0 vector 2)) - (vector-normalize! s4-0 1.0) - (let ((f30-0 (vector-dot (-> arg0 vector 1) s4-0))) - (when (< f30-0 0.99999) - (vector-cross! s4-0 (-> arg0 vector 1) s4-0) - (let ((f0-4 (vector-length s4-0))) - (if (< 0.0 (vector-dot s4-0 (-> arg0 vector 2))) - (set! f0-4 (- f0-4)) + 0.0 + 0.0 + (let ((s5-0 (new-stack-matrix0))) + (vector-negate! s4-0 arg1) + (vector-flatten! s4-0 s4-0 (-> arg0 vector 2)) + (vector-normalize! s4-0 1.0) + (let ((f30-0 (vector-dot (-> arg0 vector 1) s4-0))) + (when (< f30-0 0.99999) + (vector-cross! s4-0 (-> arg0 vector 1) s4-0) + (let ((f0-4 (vector-length s4-0))) + (if (< 0.0 (vector-dot s4-0 (-> arg0 vector 2))) + (set! f0-4 (- f0-4)) + ) + (matrix-axis-sin-cos! s5-0 (-> arg0 vector 2) f0-4 f30-0) + ) + (matrix*! arg0 arg0 s5-0) + ) ) - (matrix-axis-sin-cos! s5-0 (-> arg0 vector 2) f0-4 f30-0) - ) - (matrix*! arg0 arg0 s5-0) ) - ) ) - ) arg0 ) -(defun - slave-matrix-blend-2 - ((arg0 matrix) (arg1 float) (arg2 vector) (arg3 matrix)) +;; definition for function slave-matrix-blend-2 +;; Used lq/sq +(defun slave-matrix-blend-2 ((arg0 matrix) (arg1 float) (arg2 vector) (arg3 matrix)) (let ((s1-0 (new-stack-vector0)) (s4-0 (new-stack-quaternion0)) ) - (let ((s2-0 (new-stack-quaternion0)) - (gp-0 (new-stack-quaternion0)) - ) - 0.0 - (let* ((f0-1 (cond - ((logtest? (the-as int arg1) 4) - (vector-length arg2) + (let ((s2-0 (new-stack-quaternion0)) + (gp-0 (new-stack-quaternion0)) + ) + 0.0 + (let* ((f0-1 (cond + ((logtest? (the-as int arg1) 4) + (vector-length arg2) + ) + (else + (vector-flatten! s1-0 arg2 (-> *camera* local-down)) + (vector-length s1-0) + ) + ) ) - (else - (vector-flatten! s1-0 arg2 (-> *camera* local-down)) - (vector-length s1-0) - ) - ) - ) - (f0-3 (* 0.00048828125 (+ -1024.0 f0-1))) + (f0-3 (* 0.00048828125 (+ -1024.0 f0-1))) + ) + (cond + ((< f0-3 0.0) + (set! f0-3 0.0) ) - (cond - ((< f0-3 0.0) - (set! f0-3 0.0) - ) - ((< 1.0 f0-3) - (set! f0-3 1.0) - ) - ) - (let ((f30-0 (* 364.0889 (-> *display* time-adjust-ratio) f0-3))) - (matrix->quaternion s4-0 arg0) - (matrix->quaternion s2-0 arg3) - (quaternion-conjugate! gp-0 s4-0) - (quaternion*! gp-0 gp-0 s2-0) - (quaternion-normalize! gp-0) - (if (< (-> gp-0 w) 0.0) - (quaternion-negate! gp-0 gp-0) - ) - (let ((f28-0 (acos (-> gp-0 w)))) - (if (< (* 0.25 (-> *display* time-adjust-ratio) f28-0) f30-0) - (set! f30-0 (* 0.25 (-> *display* time-adjust-ratio) f28-0)) + ((< 1.0 f0-3) + (set! f0-3 1.0) + ) + ) + (let ((f30-0 (* 364.0889 (-> *display* time-adjust-ratio) f0-3))) + (matrix->quaternion s4-0 arg0) + (matrix->quaternion s2-0 arg3) + (quaternion-conjugate! gp-0 s4-0) + (quaternion*! gp-0 gp-0 s2-0) + (quaternion-normalize! gp-0) + (if (< (-> gp-0 w) 0.0) + (quaternion-negate! gp-0 gp-0) + ) + (let ((f28-0 (acos (-> gp-0 w)))) + (if (< (* 0.25 (-> *display* time-adjust-ratio) f28-0) f30-0) + (set! f30-0 (* 0.25 (-> *display* time-adjust-ratio) f28-0)) + ) + (cond + ((< (-> gp-0 w) 0.9999999) + (quaternion-float*! gp-0 gp-0 (/ (sin f30-0) (sin f28-0))) + (set! (-> gp-0 w) (cos f30-0)) + ) + (else + (quaternion-identity! gp-0) + ) + ) + ) + ) ) - (cond - ((< (-> gp-0 w) 0.9999999) - (quaternion-float*! gp-0 gp-0 (/ (sin f30-0) (sin f28-0))) - (set! (-> gp-0 w) (cos f30-0)) - ) - (else - (quaternion-identity! gp-0) - ) - ) - ) + (quaternion*! s4-0 s4-0 gp-0) ) - ) - (quaternion*! s4-0 s4-0 gp-0) + (quaternion-normalize! s4-0) + (quaternion->matrix arg0 s4-0) ) - (quaternion-normalize! s4-0) - (quaternion->matrix arg0 s4-0) - ) ) +;; definition for function vector-into-frustum-nosmooth! +;; Used lq/sq (defun vector-into-frustum-nosmooth! ((arg0 matrix) (arg1 vector) (arg2 float)) - (local-vars - (sv-112 (inline-array vector)) - (sv-128 vector) - (sv-144 vector) - (sv-160 vector) - (sv-176 vector) - ) + (local-vars (sv-112 (inline-array vector)) (sv-128 vector) (sv-144 vector) (sv-160 vector) (sv-176 vector)) (rlet ((vf0 :class vf) (vf1 :class vf) (vf2 :class vf) ) - (init-vf0-vector) - (let ((s5-0 (new-stack-matrix0))) - (let ((s3-0 (new-stack-vector0)) - (s2-0 (new-stack-vector0)) - ) - 0.0 - 0.0 - (let ((f30-0 1.0) - (s4-0 #t) - ) - (vector-! s3-0 (-> *camera* tpos-curr) arg1) - (vector-flatten! s3-0 s3-0 (-> arg0 vector 1)) - (vector-normalize! s3-0 1.0) - (let ((f28-0 (vector-dot s3-0 (the-as vector (-> arg0 vector))))) - (set! sv-128 s2-0) - (set! sv-112 (-> arg0 vector)) - (let ((f0-6 (* 0.8 (tan (* 0.5 arg2))))) - (.lvf vf1 (&-> sv-112 0 quad)) - (let ((v1-6 f0-6)) - (.mov vf2 v1-6) - ) - ) - (.add.x.vf vf1 vf0 vf0 :mask #b1000) - (.mul.x.vf vf1 vf1 vf2 :mask #b111) - (.svf (&-> sv-128 quad) vf1) - (vector+! s2-0 s2-0 (-> arg0 vector 2)) - (vector-normalize! s2-0 1.0) - (let ((f0-8 (vector-dot s2-0 (the-as vector (-> arg0 vector))))) - (when (< f0-8 (fabs f28-0)) - (if (< f28-0 0.0) - (vector--float*! - s2-0 - s2-0 - (the-as vector (-> arg0 vector)) - (* 2.0 f0-8) - ) - ) - (matrix-from-two-vectors! s5-0 s2-0 s3-0) - (vector-matrix*! (-> arg0 vector 2) (-> arg0 vector 2) s5-0) - (vector-cross! - (the-as vector (-> arg0 vector)) - (-> arg0 vector 1) - (-> arg0 vector 2) - ) - ) - ) - ) - (vector-! s3-0 (-> *camera* tpos-curr) (-> *camera* pitch-off)) - (vector-! s3-0 s3-0 arg1) - (vector--float*! - s3-0 - s3-0 - (-> *camera* local-down) - (-> *camera* foot-offset) - ) - (vector-flatten! s3-0 s3-0 (the-as vector (-> arg0 vector))) - (vector-normalize! s3-0 1.0) - (let ((f28-1 (vector-dot s3-0 (-> arg0 vector 1)))) - (set! sv-160 s2-0) - (set! sv-144 (-> arg0 vector 1)) - (let ((f0-15 (* 0.525 (tan (* 0.5 arg2))))) - (.lvf vf1 (&-> sv-144 quad)) - (let ((v1-23 f0-15)) - (.mov vf2 v1-23) - ) - ) - (.add.x.vf vf1 vf0 vf0 :mask #b1000) - (.mul.x.vf vf1 vf1 vf2 :mask #b111) - (.svf (&-> sv-160 quad) vf1) - (vector+! s2-0 s2-0 (-> arg0 vector 2)) - (vector-normalize! s2-0 1.0) - (let ((f0-17 (vector-dot s2-0 (-> arg0 vector 1)))) - (when (and (< f28-1 0.0) (< f0-17 (- f28-1))) - (vector--float*! s2-0 s2-0 (-> arg0 vector 1) (* 2.0 f0-17)) - (set! f30-0 (vector-dot s2-0 s3-0)) - ) - ) - ) - (vector-! s3-0 (-> *camera* tpos-curr) (-> *camera* pitch-off)) - (vector-! s3-0 s3-0 arg1) - (vector--float*! - s3-0 - s3-0 - (-> *camera* local-down) - (-> *camera* head-offset) - ) - (vector-flatten! s3-0 s3-0 (the-as vector (-> arg0 vector))) - (vector-normalize! s3-0 1.0) - (let ((f28-2 (vector-dot s3-0 (-> arg0 vector 1)))) - (let ((s0-1 s2-0)) - (set! sv-176 (-> arg0 vector 1)) - (let ((f0-25 (* 0.525 (tan (* 0.5 arg2))))) - (vector-float*! s0-1 sv-176 f0-25) - ) - ) - (vector+! s2-0 s2-0 (-> arg0 vector 2)) - (vector-normalize! s2-0 1.0) - (let ((f0-27 (vector-dot s2-0 (-> arg0 vector 1)))) - (cond - ((and (< 0.0 f28-2) (< f0-27 f28-2)) - (set! f30-0 (vector-dot s2-0 s3-0)) - (set! s4-0 #f) - ) - ((< f30-0 0.0) - (let ((f0-32 (- (vector-dot s2-0 s3-0)))) - (if (< f0-32 f30-0) - (set! f30-0 f0-32) + (init-vf0-vector) + (let ((s5-0 (new-stack-matrix0))) + (let ((s3-0 (new-stack-vector0)) + (s2-0 (new-stack-vector0)) ) - ) - ) - ) - ) - ) - (let ((f0-34 (if s4-0 - (- (acos f30-0)) - (acos f30-0) + 0.0 + 0.0 + (let ((f30-0 1.0) + (s4-0 #t) + ) + (vector-! s3-0 (-> *camera* tpos-curr) arg1) + (vector-flatten! s3-0 s3-0 (-> arg0 vector 1)) + (vector-normalize! s3-0 1.0) + (let ((f28-0 (vector-dot s3-0 (the-as vector (-> arg0 vector))))) + (set! sv-128 s2-0) + (set! sv-112 (-> arg0 vector)) + (let ((f0-6 (* 0.8 (tan (* 0.5 arg2))))) + (.lvf vf1 (&-> sv-112 0 quad)) + (let ((v1-6 f0-6)) + (.mov vf2 v1-6) + ) + ) + (.add.x.vf vf1 vf0 vf0 :mask #b1000) + (.mul.x.vf vf1 vf1 vf2 :mask #b111) + (.svf (&-> sv-128 quad) vf1) + (vector+! s2-0 s2-0 (-> arg0 vector 2)) + (vector-normalize! s2-0 1.0) + (let ((f0-8 (vector-dot s2-0 (the-as vector (-> arg0 vector))))) + (when (< f0-8 (fabs f28-0)) + (if (< f28-0 0.0) + (vector--float*! s2-0 s2-0 (the-as vector (-> arg0 vector)) (* 2.0 f0-8)) ) - ) + (matrix-from-two-vectors! s5-0 s2-0 s3-0) + (vector-matrix*! (-> arg0 vector 2) (-> arg0 vector 2) s5-0) + (vector-cross! (the-as vector (-> arg0 vector)) (-> arg0 vector 1) (-> arg0 vector 2)) + ) + ) ) - (matrix-axis-angle! s5-0 (the-as vector (-> arg0 vector)) f0-34) - ) + (vector-! s3-0 (-> *camera* tpos-curr) (-> *camera* pitch-off)) + (vector-! s3-0 s3-0 arg1) + (vector--float*! s3-0 s3-0 (-> *camera* local-down) (-> *camera* foot-offset)) + (vector-flatten! s3-0 s3-0 (the-as vector (-> arg0 vector))) + (vector-normalize! s3-0 1.0) + (let ((f28-1 (vector-dot s3-0 (-> arg0 vector 1)))) + (set! sv-160 s2-0) + (set! sv-144 (-> arg0 vector 1)) + (let ((f0-15 (* 0.525 (tan (* 0.5 arg2))))) + (.lvf vf1 (&-> sv-144 quad)) + (let ((v1-23 f0-15)) + (.mov vf2 v1-23) + ) + ) + (.add.x.vf vf1 vf0 vf0 :mask #b1000) + (.mul.x.vf vf1 vf1 vf2 :mask #b111) + (.svf (&-> sv-160 quad) vf1) + (vector+! s2-0 s2-0 (-> arg0 vector 2)) + (vector-normalize! s2-0 1.0) + (let ((f0-17 (vector-dot s2-0 (-> arg0 vector 1)))) + (when (and (< f28-1 0.0) (< f0-17 (- f28-1))) + (vector--float*! s2-0 s2-0 (-> arg0 vector 1) (* 2.0 f0-17)) + (set! f30-0 (vector-dot s2-0 s3-0)) + ) + ) + ) + (vector-! s3-0 (-> *camera* tpos-curr) (-> *camera* pitch-off)) + (vector-! s3-0 s3-0 arg1) + (vector--float*! s3-0 s3-0 (-> *camera* local-down) (-> *camera* head-offset)) + (vector-flatten! s3-0 s3-0 (the-as vector (-> arg0 vector))) + (vector-normalize! s3-0 1.0) + (let ((f28-2 (vector-dot s3-0 (-> arg0 vector 1)))) + (let ((s0-1 s2-0)) + (set! sv-176 (-> arg0 vector 1)) + (let ((f0-25 (* 0.525 (tan (* 0.5 arg2))))) + (vector-float*! s0-1 sv-176 f0-25) + ) + ) + (vector+! s2-0 s2-0 (-> arg0 vector 2)) + (vector-normalize! s2-0 1.0) + (let ((f0-27 (vector-dot s2-0 (-> arg0 vector 1)))) + (cond + ((and (< 0.0 f28-2) (< f0-27 f28-2)) + (set! f30-0 (vector-dot s2-0 s3-0)) + (set! s4-0 #f) + ) + ((< f30-0 0.0) + (let ((f0-32 (- (vector-dot s2-0 s3-0)))) + (if (< f0-32 f30-0) + (set! f30-0 f0-32) + ) + ) + ) + ) + ) + ) + (let ((f0-34 (if s4-0 + (- (acos f30-0)) + (acos f30-0) + ) + ) + ) + (matrix-axis-angle! s5-0 (the-as vector (-> arg0 vector)) f0-34) + ) + ) + ) + (vector-matrix*! (-> arg0 vector 2) (-> arg0 vector 2) s5-0) ) - ) - (vector-matrix*! (-> arg0 vector 2) (-> arg0 vector 2) s5-0) + (vector-cross! (-> arg0 vector 1) (-> arg0 vector 2) (the-as vector (-> arg0 vector))) ) - (vector-cross! - (-> arg0 vector 1) - (-> arg0 vector 2) - (the-as vector (-> arg0 vector)) - ) - ) ) ;; TODO - fix me! ;; WARN: Unsupported inline assembly instruction kind - [mula.s f0, f3] ;; WARN: Unsupported inline assembly instruction kind - [madda.s f1, f4] ;; WARN: Unsupported inline assembly instruction kind - [madd.s f0, f2, f5] -; (defun -; slave-set-rotation! -; ((arg0 cam-rotation-tracker) -; (arg1 vector) -; (arg2 float) -; (arg3 float) -; (arg4 symbol) -; ) -; (local-vars -; (f0-8 float) -; (sv-192 vector) -; (sv-208 vector) -; (sv-224 matrix) -; (sv-240 (function matrix vector float vector)) -; (sv-256 matrix) -; ) -; (rlet ((vf0 :class vf) -; (vf4 :class vf) -; (vf5 :class vf) -; (vf6 :class vf) -; ) -; (init-vf0-vector) -; (let ((s1-0 (new-stack-vector0)) -; (s5-0 (new-stack-matrix0)) -; ) -; (let ((f30-0 (-> arg0 tilt-adjust value))) -; (cond -; ((< 0.0001 (-> arg0 point-of-interest-blend value)) -; (set! sv-192 (new 'stack-no-clear 'vector)) -; 0.0 -; (vector-! s1-0 (-> arg0 follow-pt) arg1) -; (let ((f28-0 (vector-length s1-0))) -; (vector-! sv-192 (-> arg0 point-of-interest) arg1) -; (vector-normalize! -; sv-192 -; (* f28-0 (-> arg0 point-of-interest-blend value)) -; ) -; (let ((v1-3 s1-0)) -; (let ((a0-5 s1-0)) -; (.mov.vf vf6 vf0 :mask #b1000) -; (.lvf vf4 (&-> a0-5 quad)) -; ) -; (.lvf vf5 (&-> sv-192 quad)) -; (.add.vf vf6 vf4 vf5 :mask #b111) -; (.svf (&-> v1-3 quad) vf6) -; ) -; (vector-normalize! s1-0 f28-0) -; ) -; ) -; (else -; (vector-! s1-0 (-> arg0 follow-pt) arg1) -; ) -; ) -; (forward-down->inv-matrix s5-0 s1-0 (-> *camera* local-down)) -; (when (!= f30-0 0.0) -; 0.0 -; 0.0 -; (set! sv-224 (new 'stack-no-clear 'matrix)) -; (set! sv-208 (new 'stack-no-clear 'vector)) -; (vector-normalize-copy! sv-208 s1-0 1.0) -; (let* ((v1-11 (-> *camera* local-down)) -; (f0-7 (-> sv-208 x)) -; (f1-1 (-> sv-208 y)) -; (f2-0 (-> sv-208 z)) -; (f3-0 (-> v1-11 x)) -; (f4-0 (-> v1-11 y)) -; (f5-0 (-> v1-11 z)) -; ) -; (.mula.s f0-7 f3-0) -; (.madda.s f1-1 f4-0) -; (.madd.s f0-8 f2-0 f5-0) -; ) -; (let* ((f28-1 f0-8) -; (f0-10 (acos (fabs f28-1))) -; ) -; (cond -; ((< 0.0 f30-0) -; (set! f30-0 (if (< 0.0 f28-1) -; (fmin f30-0 (fmax 0.0 (+ -2730.6667 f0-10))) -; (fmin f30-0 (fmax 0.0 (- 32768.0 (+ 2730.6667 f0-10)))) -; ) -; ) -; ) -; ((< f30-0 0.0) -; (set! f30-0 (if (< 0.0 f28-1) -; (fmax -; f30-0 -; (- (fmax 0.0 (- 32768.0 (+ 2730.6667 f0-10)))) -; ) -; (fmax f30-0 (- (fmax 0.0 (+ -2730.6667 f0-10)))) -; ) -; ) -; ) -; ) -; ) -; (matrix-rotate-x! sv-224 f30-0) -; (let ((t9-7 matrix*!) -; (a0-16 s5-0) -; (a2-3 s5-0) -; ) -; (t9-7 a0-16 sv-224 a2-3) -; ) -; ) -; ) -; (if -; (and -; (= (-> *camera* under-water) 2) -; *target* -; (!= (-> *target* next-state name) 'target-swim-up) -; ) -; (set! (-> arg0 underwater-blend target) 1.0) -; (set! (-> arg0 underwater-blend target) 0.0) -; ) -; (set! sv-240 vector-into-frustum-nosmooth!) -; (set! sv-256 s5-0) -; (let -; ((a2-5 (lerp-clamp arg3 (* 0.25 arg3) (-> arg0 underwater-blend value)))) -; (sv-240 sv-256 arg1 a2-5) -; ) -; (cond -; (arg4 -; (slave-matrix-blend-2 (-> arg0 inv-mat) arg2 s1-0 s5-0) -; ) -; (else -; (let* ((v1-31 (-> arg0 inv-mat)) -; (a3-2 s5-0) -; (a0-22 (-> a3-2 vector 0 quad)) -; (a1-16 (-> a3-2 vector 1 quad)) -; (a2-7 (-> a3-2 vector 2 quad)) -; (a3-3 (-> a3-2 vector 3 quad)) -; ) -; (set! (-> v1-31 vector 0 quad) a0-22) -; (set! (-> v1-31 vector 1 quad) a1-16) -; (set! (-> v1-31 vector 2 quad) a2-7) -; (set! (-> v1-31 vector 3 quad) a3-3) -; ) -; ) -; ) -; ) -; (mat-remove-z-rot (-> arg0 inv-mat) (-> *camera* local-down)) -; 0 -; (none) -; ) -; ) +(defun + slave-set-rotation! + ((arg0 cam-rotation-tracker) + (arg1 vector) + (arg2 float) + (arg3 float) + (arg4 symbol) + ) + (local-vars + (f0-8 float) + (sv-192 vector) + (sv-208 vector) + (sv-224 matrix) + (sv-240 (function matrix vector float vector)) + (sv-256 matrix) + ) + (rlet ((vf0 :class vf) + (vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + ) + (init-vf0-vector) + (let ((s1-0 (new-stack-vector0)) + (s5-0 (new-stack-matrix0)) + ) + (let ((f30-0 (-> arg0 tilt-adjust value))) + (cond + ((< 0.0001 (-> arg0 point-of-interest-blend value)) + (set! sv-192 (new 'stack-no-clear 'vector)) + 0.0 + (vector-! s1-0 (-> arg0 follow-pt) arg1) + (let ((f28-0 (vector-length s1-0))) + (vector-! sv-192 (-> arg0 point-of-interest) arg1) + (vector-normalize! + sv-192 + (* f28-0 (-> arg0 point-of-interest-blend value)) + ) + (let ((v1-3 s1-0)) + (let ((a0-5 s1-0)) + (.mov.vf vf6 vf0 :mask #b1000) + (.lvf vf4 (&-> a0-5 quad)) + ) + (.lvf vf5 (&-> sv-192 quad)) + (.add.vf vf6 vf4 vf5 :mask #b111) + (.svf (&-> v1-3 quad) vf6) + ) + (vector-normalize! s1-0 f28-0) + ) + ) + (else + (vector-! s1-0 (-> arg0 follow-pt) arg1) + ) + ) + (forward-down->inv-matrix s5-0 s1-0 (-> *camera* local-down)) + (when (!= f30-0 0.0) + 0.0 + 0.0 + (set! sv-224 (new 'stack-no-clear 'matrix)) + (set! sv-208 (new 'stack-no-clear 'vector)) + (vector-normalize-copy! sv-208 s1-0 1.0) + (let* ((v1-11 (-> *camera* local-down)) + (f0-7 (-> sv-208 x)) + (f1-1 (-> sv-208 y)) + (f2-0 (-> sv-208 z)) + (f3-0 (-> v1-11 x)) + (f4-0 (-> v1-11 y)) + (f5-0 (-> v1-11 z)) + ) + ; (.mula.s f0-7 f3-0) + ; (.madda.s f1-1 f4-0) + ; (.madd.s f0-8 f2-0 f5-0) + (set! f0-8 (+ (* f0-7 f3-0) (* f1-1 f4-0) (* f2-0 f5-0))) + ) + (let* ((f28-1 f0-8) + (f0-10 (acos (fabs f28-1))) + ) + (cond + ((< 0.0 f30-0) + (set! f30-0 (if (< 0.0 f28-1) + (fmin f30-0 (fmax 0.0 (+ -2730.6667 f0-10))) + (fmin f30-0 (fmax 0.0 (- 32768.0 (+ 2730.6667 f0-10)))) + ) + ) + ) + ((< f30-0 0.0) + (set! f30-0 (if (< 0.0 f28-1) + (fmax + f30-0 + (- (fmax 0.0 (- 32768.0 (+ 2730.6667 f0-10)))) + ) + (fmax f30-0 (- (fmax 0.0 (+ -2730.6667 f0-10)))) + ) + ) + ) + ) + ) + (matrix-rotate-x! sv-224 f30-0) + (let ((t9-7 matrix*!) + (a0-16 s5-0) + (a2-3 s5-0) + ) + (t9-7 a0-16 sv-224 a2-3) + ) + ) + ) + (if + (and + (= (-> *camera* under-water) 2) + *target* + (!= (-> *target* next-state name) 'target-swim-up) + ) + (set! (-> arg0 underwater-blend target) 1.0) + (set! (-> arg0 underwater-blend target) 0.0) + ) + (set! sv-240 vector-into-frustum-nosmooth!) + (set! sv-256 s5-0) + (let + ((a2-5 (lerp-clamp arg3 (* 0.25 arg3) (-> arg0 underwater-blend value)))) + (sv-240 sv-256 arg1 a2-5) + ) + (cond + (arg4 + (slave-matrix-blend-2 (-> arg0 inv-mat) arg2 s1-0 s5-0) + ) + (else + (let* ((v1-31 (-> arg0 inv-mat)) + (a3-2 s5-0) + (a0-22 (-> a3-2 vector 0 quad)) + (a1-16 (-> a3-2 vector 1 quad)) + (a2-7 (-> a3-2 vector 2 quad)) + (a3-3 (-> a3-2 vector 3 quad)) + ) + (set! (-> v1-31 vector 0 quad) a0-22) + (set! (-> v1-31 vector 1 quad) a1-16) + (set! (-> v1-31 vector 2 quad) a2-7) + (set! (-> v1-31 vector 3 quad) a3-3) + ) + ) + ) + ) + (mat-remove-z-rot (-> arg0 inv-mat) (-> *camera* local-down)) + 0 + (none) + ) + ) -; ;; WARN: Stack slot offset 144 signed mismatch -; ;; WARN: Stack slot offset 144 signed mismatch -; ;; WARN: Unsupported inline assembly instruction kind - [mula.s f0, f3] -; ;; WARN: Unsupported inline assembly instruction kind - [madda.s f1, f4] -; ;; WARN: Unsupported inline assembly instruction kind - [madd.s f0, f2, f5] -; (defun -; v-slrp2! -; ((arg0 vector) -; (arg1 vector) -; (arg2 vector) -; (arg3 float) -; (arg4 vector) -; (arg5 float) -; ) -; (local-vars -; (f0-10 float) -; (f28-0 float) -; (f30-0 float) -; (sv-144 float) -; (sv-160 vector) -; (sv-176 matrix) -; (sv-192 vector) -; ) -; (set! sv-144 arg5) -; (let ((s0-0 (new-stack-vector0))) -; (set! sv-160 (new 'stack-no-clear 'vector)) -; (set! (-> sv-160 quad) (the-as uint128 0)) -; 1.0 -; 1.0 -; (let ((s3-0 (new-stack-vector0))) -; 0.0 -; 1.0 -; (set! sv-176 (new 'stack-no-clear 'matrix)) -; (set! (-> sv-176 vector 0 quad) (the-as uint128 0)) -; (set! (-> sv-176 vector 1 quad) (the-as uint128 0)) -; (set! (-> sv-176 vector 2 quad) (the-as uint128 0)) -; (set! (-> sv-176 vector 3 quad) (the-as uint128 0)) -; (cond -; ((< 1.0 arg3) -; (set! arg3 1.0) -; ) -; ((< arg3 0.0) -; (set! arg3 0.0) -; ) -; ) -; (cond -; (arg4 -; (vector-flatten! s0-0 arg1 arg4) -; (vector-flatten! sv-160 arg2 arg4) -; (set! f30-0 (vector-normalize-ret-len! s0-0 1.0)) -; (set! f28-0 (vector-normalize-ret-len! sv-160 1.0)) -; (vector-normalize! (vector-cross! s3-0 sv-160 s0-0) 1.0) -; (let ((f26-0 (vector-dot arg4 s3-0))) -; (vector-normalize-copy! s3-0 arg4 1.0) -; (if (< f26-0 0.0) -; (vector-negate! s3-0 s3-0) -; ) -; ) -; ) -; (else -; (set! (-> s0-0 quad) (-> arg1 quad)) -; (set! (-> sv-160 quad) (-> arg2 quad)) -; (set! f30-0 (vector-normalize-ret-len! s0-0 1.0)) -; (set! f28-0 (vector-normalize-ret-len! sv-160 1.0)) -; (vector-normalize! (vector-cross! s3-0 arg2 arg1) 1.0) -; ) -; ) -; (let ((t9-10 acos)) -; (let* ((v1-18 s0-0) -; (f0-9 (-> v1-18 x)) -; (f1-2 (-> v1-18 y)) -; (f2-0 (-> v1-18 z)) -; (f3-0 (-> sv-160 x)) -; (f4-0 (-> sv-160 y)) -; (f5-0 (-> sv-160 z)) -; ) -; (.mula.s f0-9 f3-0) -; (.madda.s f1-2 f4-0) -; (.madd.s f0-10 f2-0 f5-0) -; ) -; (let* ((f1-3 (t9-10 f0-10)) -; (f0-12 (* arg3 f1-3)) -; ) -; (when (< sv-144 f0-12) -; (set! f0-12 sv-144) -; (set! arg3 (/ sv-144 f1-3)) -; ) -; (let* ((f0-13 (cos f0-12)) -; (t9-12 matrix-axis-sin-cos!) -; (a0-20 sv-176) -; (a1-13 s3-0) -; (f1-5 1.0) -; (f2-3 f0-13) -; ) -; (t9-12 a0-20 a1-13 (sqrtf (- f1-5 (* f2-3 f2-3))) f0-13) -; ) -; ) -; ) -; (vector-matrix*! arg0 s0-0 sv-176) -; (let ((s0-1 vector-normalize!)) -; (set! sv-192 arg0) -; (let ((a1-16 (lerp f30-0 f28-0 arg3))) -; (s0-1 sv-192 a1-16) -; ) -; ) -; (when arg4 -; (vector+float*! arg0 arg0 s3-0 (vector-dot arg1 s3-0)) -; (vector+float*! -; arg0 -; arg0 -; s3-0 -; (* arg3 (vector-dot (vector-! (new-stack-vector0) arg2 arg1) s3-0)) -; ) -; ) -; ) -; ) -; arg0 -; ) +;; WARN: Stack slot offset 144 signed mismatch +;; WARN: Stack slot offset 144 signed mismatch +;; WARN: Unsupported inline assembly instruction kind - [mula.s f0, f3] +;; WARN: Unsupported inline assembly instruction kind - [madda.s f1, f4] +;; WARN: Unsupported inline assembly instruction kind - [madd.s f0, f2, f5] +(defun + v-slrp2! + ((arg0 vector) + (arg1 vector) + (arg2 vector) + (arg3 float) + (arg4 vector) + (arg5 float) + ) + (local-vars + (f0-10 float) + (f28-0 float) + (f30-0 float) + (sv-144 float) + (sv-160 vector) + (sv-176 matrix) + (sv-192 vector) + ) + (set! sv-144 arg5) + (let ((s0-0 (new-stack-vector0))) + (set! sv-160 (new 'stack-no-clear 'vector)) + (set! (-> sv-160 quad) (the-as uint128 0)) + 1.0 + 1.0 + (let ((s3-0 (new-stack-vector0))) + 0.0 + 1.0 + (set! sv-176 (new 'stack-no-clear 'matrix)) + (set! (-> sv-176 vector 0 quad) (the-as uint128 0)) + (set! (-> sv-176 vector 1 quad) (the-as uint128 0)) + (set! (-> sv-176 vector 2 quad) (the-as uint128 0)) + (set! (-> sv-176 vector 3 quad) (the-as uint128 0)) + (cond + ((< 1.0 arg3) + (set! arg3 1.0) + ) + ((< arg3 0.0) + (set! arg3 0.0) + ) + ) + (cond + (arg4 + (vector-flatten! s0-0 arg1 arg4) + (vector-flatten! sv-160 arg2 arg4) + (set! f30-0 (vector-normalize-ret-len! s0-0 1.0)) + (set! f28-0 (vector-normalize-ret-len! sv-160 1.0)) + (vector-normalize! (vector-cross! s3-0 sv-160 s0-0) 1.0) + (let ((f26-0 (vector-dot arg4 s3-0))) + (vector-normalize-copy! s3-0 arg4 1.0) + (if (< f26-0 0.0) + (vector-negate! s3-0 s3-0) + ) + ) + ) + (else + (set! (-> s0-0 quad) (-> arg1 quad)) + (set! (-> sv-160 quad) (-> arg2 quad)) + (set! f30-0 (vector-normalize-ret-len! s0-0 1.0)) + (set! f28-0 (vector-normalize-ret-len! sv-160 1.0)) + (vector-normalize! (vector-cross! s3-0 arg2 arg1) 1.0) + ) + ) + (let ((t9-10 acos)) + (let* ((v1-18 s0-0) + (f0-9 (-> v1-18 x)) + (f1-2 (-> v1-18 y)) + (f2-0 (-> v1-18 z)) + (f3-0 (-> sv-160 x)) + (f4-0 (-> sv-160 y)) + (f5-0 (-> sv-160 z)) + ) + (set! f0-10 (+ (* f2-0 f5-0) (* f1-2 f4-0) (* f0-9 f3-0))) + ; (.mula.s f0-9 f3-0) + ; (.madda.s f1-2 f4-0) + ; (.madd.s f0-10 f2-0 f5-0) + ) + (let* ((f1-3 (t9-10 f0-10)) + (f0-12 (* arg3 f1-3)) + ) + (when (< sv-144 f0-12) + (set! f0-12 sv-144) + (set! arg3 (/ sv-144 f1-3)) + ) + (let* ((f0-13 (cos f0-12)) + (t9-12 matrix-axis-sin-cos!) + (a0-20 sv-176) + (a1-13 s3-0) + (f1-5 1.0) + (f2-3 f0-13) + ) + (t9-12 a0-20 a1-13 (sqrtf (- f1-5 (* f2-3 f2-3))) f0-13) + ) + ) + ) + (vector-matrix*! arg0 s0-0 sv-176) + (let ((s0-1 vector-normalize!)) + (set! sv-192 arg0) + (let ((a1-16 (lerp f30-0 f28-0 arg3))) + (s0-1 sv-192 a1-16) + ) + ) + (when arg4 + (vector+float*! arg0 arg0 s3-0 (vector-dot arg1 s3-0)) + (vector+float*! + arg0 + arg0 + s3-0 + (* arg3 (vector-dot (vector-! (new-stack-vector0) arg2 arg1) s3-0)) + ) + ) + ) + ) + arg0 + ) -; ;; WARN: Stack slot offset 144 signed mismatch -; ;; WARN: Stack slot offset 144 signed mismatch -; ;; WARN: Unsupported inline assembly instruction kind - [mula.s f0, f3] -; ;; WARN: Unsupported inline assembly instruction kind - [madda.s f1, f4] -; ;; WARN: Unsupported inline assembly instruction kind - [madd.s f0, f2, f5] -; (defun -; v-slrp3! -; ((arg0 vector) (arg1 vector) (arg2 vector) (arg3 vector) (arg4 float)) -; (local-vars -; (f0-7 float) -; (f26-0 float) -; (f28-0 float) -; (sv-144 float) -; (sv-160 vector) -; ) -; (set! sv-144 arg4) -; (let ((s1-0 (new-stack-vector0))) -; (set! sv-160 (new 'stack-no-clear 'vector)) -; (set! (-> sv-160 quad) (the-as uint128 0)) -; 0.0 -; 0.0 -; (let ((s3-0 (new-stack-vector0)) -; (f30-0 1.0) -; ) -; 0.0 -; (let ((s0-0 (new-stack-matrix0))) -; (cond -; (arg3 -; (vector-flatten! s1-0 arg1 arg3) -; (vector-flatten! sv-160 arg2 arg3) -; (set! f28-0 (vector-normalize-ret-len! s1-0 1.0)) -; (set! f26-0 (vector-normalize-ret-len! sv-160 1.0)) -; (vector-normalize! (vector-cross! s3-0 sv-160 s1-0) 1.0) -; (let ((f24-0 (vector-dot arg3 s3-0))) -; (vector-normalize-copy! s3-0 arg3 1.0) -; (if (< f24-0 0.0) -; (vector-negate! s3-0 s3-0) -; ) -; ) -; ) -; (else -; (set! (-> s1-0 quad) (-> arg1 quad)) -; (set! (-> sv-160 quad) (-> arg2 quad)) -; (set! f28-0 (vector-normalize-ret-len! s1-0 1.0)) -; (set! f26-0 (vector-normalize-ret-len! sv-160 1.0)) -; (vector-normalize! (vector-cross! s3-0 arg2 arg1) 1.0) -; ) -; ) -; (let ((t9-10 acos)) -; (let* ((v1-9 s1-0) -; (f0-6 (-> v1-9 x)) -; (f1-0 (-> v1-9 y)) -; (f2-0 (-> v1-9 z)) -; (f3-0 (-> sv-160 x)) -; (f4-0 (-> sv-160 y)) -; (f5-0 (-> sv-160 z)) -; ) -; (.mula.s f0-6 f3-0) -; (.madda.s f1-0 f4-0) -; (.madd.s f0-7 f2-0 f5-0) -; ) -; (let ((f0-8 (t9-10 f0-7))) -; (when (< sv-144 f0-8) -; (set! f30-0 (/ sv-144 f0-8)) -; (set! f0-8 sv-144) -; ) -; (let* ((f0-9 (cos f0-8)) -; (t9-12 matrix-axis-sin-cos!) -; (a0-20 s0-0) -; (a1-13 s3-0) -; (f1-3 1.0) -; (f2-1 f0-9) -; ) -; (t9-12 a0-20 a1-13 (sqrtf (- f1-3 (* f2-1 f2-1))) f0-9) -; ) -; ) -; ) -; (vector-matrix*! arg0 s1-0 s0-0) -; ) -; (vector-normalize! arg0 (lerp f28-0 f26-0 f30-0)) -; (when arg3 -; (vector+float*! arg0 arg0 s3-0 (vector-dot arg1 s3-0)) -; (vector+float*! -; arg0 -; arg0 -; s3-0 -; (* f30-0 (vector-dot (vector-! (new-stack-vector0) arg2 arg1) s3-0)) -; ) -; ) -; ) -; ) -; arg0 -; ) +;; WARN: Stack slot offset 144 signed mismatch +;; WARN: Stack slot offset 144 signed mismatch +;; WARN: Unsupported inline assembly instruction kind - [mula.s f0, f3] +;; WARN: Unsupported inline assembly instruction kind - [madda.s f1, f4] +;; WARN: Unsupported inline assembly instruction kind - [madd.s f0, f2, f5] +(defun + v-slrp3! + ((arg0 vector) (arg1 vector) (arg2 vector) (arg3 vector) (arg4 float)) + (local-vars + (f0-7 float) + (f26-0 float) + (f28-0 float) + (sv-144 float) + (sv-160 vector) + ) + (set! sv-144 arg4) + (let ((s1-0 (new-stack-vector0))) + (set! sv-160 (new 'stack-no-clear 'vector)) + (set! (-> sv-160 quad) (the-as uint128 0)) + 0.0 + 0.0 + (let ((s3-0 (new-stack-vector0)) + (f30-0 1.0) + ) + 0.0 + (let ((s0-0 (new-stack-matrix0))) + (cond + (arg3 + (vector-flatten! s1-0 arg1 arg3) + (vector-flatten! sv-160 arg2 arg3) + (set! f28-0 (vector-normalize-ret-len! s1-0 1.0)) + (set! f26-0 (vector-normalize-ret-len! sv-160 1.0)) + (vector-normalize! (vector-cross! s3-0 sv-160 s1-0) 1.0) + (let ((f24-0 (vector-dot arg3 s3-0))) + (vector-normalize-copy! s3-0 arg3 1.0) + (if (< f24-0 0.0) + (vector-negate! s3-0 s3-0) + ) + ) + ) + (else + (set! (-> s1-0 quad) (-> arg1 quad)) + (set! (-> sv-160 quad) (-> arg2 quad)) + (set! f28-0 (vector-normalize-ret-len! s1-0 1.0)) + (set! f26-0 (vector-normalize-ret-len! sv-160 1.0)) + (vector-normalize! (vector-cross! s3-0 arg2 arg1) 1.0) + ) + ) + (let ((t9-10 acos)) + (let* ((v1-9 s1-0) + (f0-6 (-> v1-9 x)) + (f1-0 (-> v1-9 y)) + (f2-0 (-> v1-9 z)) + (f3-0 (-> sv-160 x)) + (f4-0 (-> sv-160 y)) + (f5-0 (-> sv-160 z)) + ) + ; (.mula.s f0-6 f3-0) + ; (.madda.s f1-0 f4-0) + ; (.madd.s f0-7 f2-0 f5-0) + (set! f0-7 (+ (* f0-6 f3-0) (* f1-0 f4-0) (* f2-0 f5-0))) + ) + (let ((f0-8 (t9-10 f0-7))) + (when (< sv-144 f0-8) + (set! f30-0 (/ sv-144 f0-8)) + (set! f0-8 sv-144) + ) + (let* ((f0-9 (cos f0-8)) + (t9-12 matrix-axis-sin-cos!) + (a0-20 s0-0) + (a1-13 s3-0) + (f1-3 1.0) + (f2-1 f0-9) + ) + (t9-12 a0-20 a1-13 (sqrtf (- f1-3 (* f2-1 f2-1))) f0-9) + ) + ) + ) + (vector-matrix*! arg0 s1-0 s0-0) + ) + (vector-normalize! arg0 (lerp f28-0 f26-0 f30-0)) + (when arg3 + (vector+float*! arg0 arg0 s3-0 (vector-dot arg1 s3-0)) + (vector+float*! + arg0 + arg0 + s3-0 + (* f30-0 (vector-dot (vector-! (new-stack-vector0) arg2 arg1) s3-0)) + ) + ) + ) + ) + arg0 + ) diff --git a/goal_src/engine/collide/collide-cache-h.gc b/goal_src/engine/collide/collide-cache-h.gc index 505687266..f03a68a2e 100644 --- a/goal_src/engine/collide/collide-cache-h.gc +++ b/goal_src/engine/collide/collide-cache-h.gc @@ -10,11 +10,6 @@ (define-extern collide-cache-using-box-test (function vector symbol)) -;; The collide cache system tries to make collision queries faster by caching intermediate results. -;; Almost all collision operations are done by calling a method of the global *collide-cache*. -;; In cases where the collide cache does not have the data in its cache, it will fill itself -;; using the appropriate collision functions. - ;;;;;;;;;;;;;;;;;;;;;;; ;; Collide Helpers @@ -55,8 +50,8 @@ :size-assert #xc60 :flag-assert #xb00000c60 (:methods - (dummy-9 () none 9) - (dummy-10 () none 10) + (dummy-9 (_type_ object object) symbol 9) + (dummy-10 (_type_ object object) symbol 10) ) ) @@ -81,10 +76,11 @@ ;; This is a common return type of collision queries. (deftype collide-cache-tri (structure) ((vertex vector 3 :inline :offset-assert 0) ;; actual locations - (pat pat-surface :offset-assert 48) ;; metadata about the surface of this tri - (prim-index uint16 :offset-assert 52) ;; in the collide-cache-prim list - (user16 uint16 :offset-assert 54) - (user32 uint32 2 :offset-assert 56) + (extra-quad uint128 :offset 48) + (pat pat-surface :offset 48) ;; metadata about the surface of this tri + (prim-index uint16 :offset 52) ;; in the collide-cache-prim list + (user16 uint16 :offset 54) + (user32 uint32 2 :offset 56) ) :method-count-assert 9 :size-assert #x40 @@ -94,18 +90,18 @@ ;; The primitives stored in the cache. ;; The "core" is extracted from the normal collide-shape-prim and placed inline here. (deftype collide-cache-prim (structure) - ((prim-core collide-prim-core :inline :offset-assert 0) - (ccache collide-cache :offset-assert 32) - (prim collide-shape-prim :offset-assert 36) - (first-tri uint16 :offset-assert 40) - (num-tris uint16 :offset-assert 42) - (unused uint8 4 :offset-assert 44) - (world-sphere vector :inline :offset 0) - ;; overlays of the core - (collide-as collide-kind :offset 16) + ((prim-core collide-prim-core :inline :offset-assert 0) + (extra-quad uint128 :offset-assert 32) + (ccache collide-cache :offset 32) + (prim collide-shape-prim :offset 36) + (first-tri uint16 :offset 40) + (num-tris uint16 :offset 42) + (unused uint8 4 :offset 44) + (world-sphere vector :inline :offset 0) + (collide-as collide-kind :offset 16) (action collide-action :offset 24) (offense collide-offense :offset 28) - (prim-type int8 :offset 29) + (prim-type int8 :offset 29) ) :method-count-assert 11 :size-assert #x30 @@ -136,7 +132,7 @@ (:methods (debug-draw (_type_) none 9) (fill-and-probe-using-line-sphere (_type_ vector vector float collide-kind process collide-tri-result int) float 10) - (fill-and-probe-using-spheres (_type_ collide-using-spheres-params) none 11) + (fill-and-probe-using-spheres (_type_ collide-using-spheres-params) symbol 11) (fill-and-probe-using-y-probe (_type_ vector float collide-kind process collide-tri-result uint) float 12) (fill-using-bounding-box (_type_ bounding-box collide-kind process-drawable pat-surface) none 13) (fill-using-line-sphere (_type_ vector vector float collide-kind process-drawable int) none 14) @@ -144,20 +140,20 @@ (fill-using-y-probe (_type_ vector float collide-kind process-drawable uint) none 16) (initialize (_type_) none 17) (probe-using-line-sphere (_type_ vector vector float collide-kind collide-tri-result int) float 18) - (probe-using-spheres (_type_) none 19) + (probe-using-spheres (_type_ collide-using-spheres-params) symbol 19) (probe-using-y-probe (_type_ vector float collide-kind collide-tri-result uint) float 20) - (fill-from-background (_type_ (function bsp-header int collide-list none) (function collide-cache none)) none 21) ;; second functiom is method 28 - (fill-from-foreground-using-spheres (_type_) none 22) + (fill-from-background (_type_ (function bsp-header int collide-list none) (function collide-cache object none)) none 21) ;; second functiom is method 28 + (fill-from-foreground-using-box (_type_) none 22) (fill-from-foreground-using-line-sphere (_type_) none 23) (fill-from-foreground-using-y-probe (_type_) none 24) (fill-from-water (_type_ water-control) none 25) ;; or whatever is from 152 in the process passed to 16 - (dummy-26 (_type_) none 26) + (load-mesh-from-spad-in-box (_type_ collide-frag-mesh) none 26) (dummy-27 (_type_) none 27) (dummy-28 (_type_) none 28) (dummy-29 (_type_ collide-frag-mesh) none 29) - (dummy-30 (_type_) none 30) - (dummy-31 (_type_ collide-puyp-work collide-cache-prim) vector 31) - (dummy-32 (_type_) none 32) + (puyp-mesh (_type_ collide-puyp-work collide-cache-prim) none 30) + (puyp-sphere (_type_ collide-puyp-work collide-cache-prim) vector 31) + (unpack-background-collide-mesh (_type_ object object object) none 32) ;; helper for fill from background. ) ) diff --git a/goal_src/engine/collide/collide-cache.gc b/goal_src/engine/collide/collide-cache.gc index 2dd660ade..9e922fbec 100644 --- a/goal_src/engine/collide/collide-cache.gc +++ b/goal_src/engine/collide/collide-cache.gc @@ -5,9 +5,338 @@ ;; name in dgo: collide-cache ;; dgos: GAME, ENGINE -;; TODO this doesnt work properly due to qmfc2 bugs +(defmethod debug-draw collide-cache ((obj collide-cache)) + "Debug draw all the things in the collide cache!" + (let ((gp-0 (the-as collide-cache-tri (-> obj tris)))) + (countdown (s4-0 (-> obj num-tris)) + (let ((t1-0 (copy-and-set-field (-> *pat-mode-info* (-> gp-0 pat mode) color) a 64))) + (add-debug-flat-triangle + #t + (bucket-id debug-draw1) + (the-as vector (-> gp-0 vertex)) + (-> gp-0 vertex 1) + (-> gp-0 vertex 2) + t1-0 + ) + ) + (&+! gp-0 64) + ) + ) + (let ((gp-1 (the-as collide-cache-prim (-> obj prims)))) + (countdown (s5-1 (-> obj num-prims)) + (when (= (-> gp-1 prim-core prim-type) -1) + (let ((t0-1 + (copy-and-set-field + (-> *pat-mode-info* (-> (the-as collide-shape-prim-sphere (-> gp-1 prim)) pat mode) color) + a + 64 + ) + ) + ) + (add-debug-sphere + #t + (bucket-id debug-draw1) + (the-as vector (-> gp-1 prim-core)) + (-> gp-1 prim-core world-sphere w) + t0-1 + ) + ) + ) + (&+! gp-1 48) + ) + ) + 0 + (none) + ) + +;;;;;;;;;;;;;;;;;;;;;;;; +;; Setup +;;;;;;;;;;;;;;;;;;;;;;;; + +(define *already-printed-exeeded-max-cache-tris* #f) + +(defmethod initialize collide-cache ((obj collide-cache)) + "Clear the collide-cache." + (set! (-> obj num-tris) 0) + (set! (-> obj num-prims) 0) + (set! (-> obj proc) #f) + (set! *already-printed-exeeded-max-cache-tris* #f) + (none) + ) + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; Fill using Bounding Box +;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +;; As is typcial of ND, this is complicated. +;; We have 3 stages for loading the background mesh. +;; 1). We acquire mesh fragments. This can be with bsp methods or collide probe. +;; 2). We upload these meshes to VU0 data memory and unpack. +;; 3). We run the unpack function which downloads them with vlqi and puts the spad. +;; 4). We run the filter by box function to download only tris in the box into the cache. + +(defmethod-mips2c "(method 26 collide-cache)" 26 collide-cache) +(defmethod-mips2c "(method 27 collide-cache)" 27 collide-cache) +(defmethod-mips2c "(method 28 collide-cache)" 28 collide-cache) +(defmethod-mips2c "(method 29 collide-cache)" 29 collide-cache) +(defmethod-mips2c "(method 32 collide-cache)" 32 collide-cache) +(defmethod-mips2c "(method 12 collide-shape-prim-mesh)" 12 collide-shape-prim-mesh) +(defmethod-mips2c "(method 14 collide-shape-prim-mesh)" 14 collide-shape-prim-mesh) +(defmethod-mips2c "(method 13 collide-shape-prim-mesh)" 13 collide-shape-prim-mesh) +(defmethod-mips2c "(method 30 collide-cache)" 30 collide-cache) +(defmethod-mips2c "(method 9 collide-cache-prim)" 9 collide-cache-prim) +(defmethod-mips2c "(method 10 collide-cache-prim)" 10 collide-cache-prim) +(defmethod-mips2c "(method 9 collide-puss-work)" 9 collide-puss-work) +(defmethod-mips2c "(method 10 collide-puss-work)" 10 collide-puss-work) +(def-mips2c __pc-upload-collide-frag (function object object object none)) + + +(defmethod fill-from-background collide-cache ((obj collide-cache) + (bsp-find-mesh-func (function bsp-header int collide-list none)) + (import-mesh-func (function collide-cache object none)) + ) + "This terrible function fills the collide cache with background tris from a bounding box." + + (local-vars (a0-4 int) (a0-6 int)) + + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + ;; Step 1: Build Collide List + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + + ;; this is a list of fragments that we will look at. + + + (set! (-> *collide-list* num-items) 0) + (cond + ((= bsp-find-mesh-func (method-of-type bsp-header collide-ray)) + ;; for collide-ray (actually line-sphere), we have a fancy version. + (dotimes (s4-1 (-> *level* length)) + (let ((a0-2 (-> *level* level s4-1))) + (when (= (-> a0-2 status) 'active) + (reset! (-> *perf-stats* data 14)) + (collide-probe-make-list a0-2 *collide-list*) + (read! (-> *perf-stats* data 14)) + ) + ) + ) + ) + (else + ;; for the othes, we don't have a fancy version, so use the versio provided by the user. + (dotimes (s3-0 (-> *level* length)) + (let ((v1-21 (-> *level* level s3-0))) + (if (= (-> v1-21 status) 'active) + (bsp-find-mesh-func (-> v1-21 bsp) 0 *collide-list*) + ) + ) + ) + ) + ) + + + (when (> (-> *collide-list* num-items) 0) + + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + ;; Step 2: Upload to VU0 Data + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + + ;; in classic ND style, this is double buffered. + ;; we'll undo this. + (dotimes (i (-> *collide-list* num-items)) + (let ((frag (-> *collide-list* items i))) + ;; to VU0 memory + (__pc-upload-collide-frag (-> frag mesh packed-data) (-> frag mesh vertex-data-qwc) (-> frag mesh vertex-count)) + ;; from VU0 memory to scratchpad + (unpack-background-collide-mesh obj (-> frag mesh) (-> frag inst) 0) + ;; from scratchpad to collide-cache memory. + (import-mesh-func obj (-> frag mesh)) + ) + ) + + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + ;; Fake it as a prim + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + + ;; The old system can actually read out lists of prims. + ;; Note that this assumes the cache has been emptied and we're the first to fill it here. + + (let ((a0-28 (-> obj num-tris))) + (when (> a0-28 0) + (let ((v1-55 (-> obj prims)) + (a1-17 *collide-shape-prim-backgnd*) + ) + (set! (-> v1-55 0 num-tris) (the-as uint a0-28)) + (set! (-> v1-55 0 prim) a1-17) + (set! (-> obj num-prims) 1) + (set! (-> v1-55 0 first-tri) (the-as uint 0)) + (set! (-> v1-55 0 ccache) obj) + (set! (-> v1-55 0 prim-core world-sphere quad) (-> a1-17 prim-core world-sphere quad)) + (set! (-> v1-55 0 prim-core quad 1) (-> a1-17 prim-core quad 1)) + ) + ) + ) + + ) + 0 + (none) + ) + +(defmethod fill-from-water collide-cache ((obj collide-cache) (arg0 water-control)) + (rlet ((vf0 :class vf) + (vf1 :class vf) + (vf2 :class vf) + (vf3 :class vf) + (vf4 :class vf) + (vf5 :class vf) + ) + (init-vf0-vector) + (when (= (-> obj num-prims) 100) + (if (= *cheat-mode* 'debug) + (format 0 "ERROR: Exceeded max number of collide-cache prims!~%") + ) + (return #f) + ) + (when (< 460 (+ (-> obj num-tris) 2)) + (when (not *already-printed-exeeded-max-cache-tris*) + (set! *already-printed-exeeded-max-cache-tris* #t) + (if (= *cheat-mode* 'debug) + (format *stdcon* "Exceeded collide cache max # of tris!~%") + ) + ) + (return #f) + ) + (if (not + (and (logtest? (-> arg0 flags) 2) (logtest? (-> arg0 flags) 144) (zero? (logand #x10000 (-> arg0 flags)))) + ) + (return #f) + ) + (let ((v1-28 (cond + ((logtest? (-> *target* control root-prim prim-core action) (collide-action ca-9)) + (+ -819.2 (-> arg0 height)) + ) + ((logtest? (-> arg0 flags) 16) + (- (-> arg0 height) (-> arg0 swim-height)) + ) + (else + (- (-> arg0 base-height) (-> arg0 bottom-height)) + ) + ) + ) + ) + (.lvf vf1 (&-> obj collide-box min quad)) + (.lvf vf3 (&-> obj collide-box max quad)) + (let ((a1-6 (-> obj num-prims-u)) + (a2-8 (the-as (inline-array collide-cache-tri) (-> obj tris (-> obj num-tris)))) + ) + (.mov vf5 v1-28) + (.add.x.vf vf1 vf0 vf5 :mask #b10) + (set! (-> a2-8 0 extra-quad) (the-as uint128 0)) + (set! (-> a2-8 0 prim-index) a1-6) + (.add.x.vf vf3 vf0 vf5 :mask #b10) + (set! (-> a2-8 1 extra-quad) (the-as uint128 0)) + (set! (-> a2-8 1 prim-index) a1-6) + (.mov.vf vf2 vf1) + (.mov.vf vf4 vf1) + (.add.z.vf vf2 vf0 vf3 :mask #b100) + (.add.x.vf vf4 vf0 vf3 :mask #b1) + (.svf (&-> a2-8 0 vertex 0 quad) vf1) + (.svf (&-> a2-8 0 vertex 1 quad) vf2) + (.svf (&-> a2-8 0 vertex 2 quad) vf3) + (set! (-> a2-8 0 pat) (new 'static 'pat-surface :material (pat-material waterbottom))) + (.svf (&-> a2-8 1 vertex 0 quad) vf1) + (.svf (&-> a2-8 1 vertex 1 quad) vf3) + (.svf (&-> a2-8 1 vertex 2 quad) vf4) + (set! (-> a2-8 1 pat) (new 'static 'pat-surface :material (pat-material waterbottom))) + ) + ) + (let ((v1-33 *collide-shape-prim-water*) + (a1-10 (-> obj prims (-> obj num-prims))) + ) + (set! (-> a1-10 first-tri) (the-as uint (-> obj num-tris))) + (set! (-> a1-10 num-tris) (the-as uint 2)) + (set! (-> a1-10 prim) v1-33) + (set! (-> a1-10 ccache) obj) + (set! (-> a1-10 prim-core world-sphere quad) (-> v1-33 prim-core world-sphere quad)) + (set! (-> a1-10 prim-core quad 1) (-> v1-33 prim-core quad 1)) + ) + (+! (-> obj num-prims) 1) + (+! (-> obj num-tris) 2) + (none) + ) + ) + +(defmethod fill-using-bounding-box collide-cache ((obj collide-cache) (arg0 bounding-box) (arg1 collide-kind) (arg2 process-drawable) (arg3 pat-surface)) + (rlet ((Q :class vf) + (vf0 :class vf) + (vf1 :class vf) + (vf2 :class vf) + (vf3 :class vf) + (vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + (vf7 :class vf) + ) + (init-vf0-vector) + (let ((v1-0 (new 'static 'vector :x 0.5))) + (nop!) + (.lvf vf1 (&-> arg0 min quad)) + (nop!) + (.lvf vf2 (&-> arg0 max quad)) + (nop!) + (set! (-> obj proc) arg2) + (.mov.vf vf1 vf0 :mask #b1000) + (let ((a0-1 *collide-work*)) + (.mov.vf vf2 vf0 :mask #b1000) + (set! (-> obj ignore-mask) arg3) + (.ftoi.vf vf3 vf1) + (.lvf vf6 (&-> v1-0 quad)) + (.ftoi.vf vf4 vf2) + (set! (-> obj num-tris) 0) + (.add.vf vf5 vf2 vf1 :mask #b111) + (.svf (&-> obj collide-box min quad) vf1) + (.mul.x.vf vf5 vf5 vf6 :mask #b111) + (.svf (&-> obj collide-box max quad) vf2) + (.sub.vf vf7 vf5 vf1 :mask #b111) + (.sub.vf vf5 vf5 vf5 :mask #b1000) + (.mul.vf vf7 vf7 vf7 :mask #b111) + (.svf (&-> obj collide-box4w min quad) vf3) + (.add.y.vf vf7 vf7 vf7 :mask #b1) + (.svf (&-> obj collide-box4w max quad) vf4) + (.add.z.vf vf7 vf7 vf7 :mask #b1) + (.svf (&-> a0-1 collide-box4w min quad) vf3) + (.sqrt.vf Q vf7 :ftf #b0) + (.svf (&-> a0-1 collide-box4w max quad) vf4) + (set! *already-printed-exeeded-max-cache-tris* #f) + (nop!) + (.wait.vf) + (set! (-> obj num-prims) 0) + (.sub.vf vf5 vf5 Q :mask #b1000) + (set! (-> obj collide-with) arg1) + (nop!) + (.svf (&-> a0-1 collide-sphere-neg-r quad) vf5) + ) + ) + 0 + (if (logtest? arg1 (collide-kind background)) + (fill-from-background + obj + (method-of-type bsp-header collide-with-box) + (method-of-type collide-cache load-mesh-from-spad-in-box) + ) + ) + (if (logtest? arg1 (collide-kind water)) + (fill-from-water obj (-> arg2 water)) + ) + (if (logtest? arg1 (collide-kind cak-1 cak-2 cak-3 target)) + (fill-from-foreground-using-box obj) + ) + 0 + (none) + ) + ) + (defun collide-cache-using-box-test ((arg0 vector)) - (local-vars (v1-1 float)) + (local-vars (v1-1 int)) (rlet ((acc :class vf) (vf0 :class vf) (vf1 :class vf) @@ -40,6 +369,208 @@ ) ) +(defmethod collide-with-box collide-fragment ((obj collide-fragment) (arg0 int) (arg1 collide-list)) + (let ((s3-0 *collide-work*)) + (dotimes (s2-0 arg0) + (when (and (collide-cache-using-box-test (-> obj bsphere)) + (drawable-sphere-box-intersect? obj (-> s3-0 collide-box4w)) + ) + (let ((v1-5 (-> arg1 items (-> arg1 num-items)))) + (set! (-> v1-5 mesh) (-> obj mesh)) + (set! (-> v1-5 inst) #f) + ) + (+! (-> arg1 num-items) 1) + ) + (&+! obj 32) + ) + ) + 0 + (none) + ) + +(defmethod collide-with-box instance-tie ((obj instance-tie) (arg0 int) (arg1 collide-list)) + (dotimes (s3-0 arg0) + (when (and (zero? (logand (-> obj flags) 1)) + (collide-cache-using-box-test (-> obj bsphere)) + (drawable-sphere-box-intersect? obj (-> *collide-work* collide-box4w)) + ) + (let ((s2-0 (-> obj bucket-ptr collide-frag))) + (when (nonzero? s2-0) + (let ((s1-0 (the-as object (-> s2-0 data)))) + (dotimes (s0-0 (-> s2-0 length)) + (when (instance-sphere-box-intersect? (the-as collide-fragment s1-0) obj (-> *collide-work* collide-box4w)) + (let ((v1-12 (-> arg1 items (-> arg1 num-items)))) + (set! (-> v1-12 mesh) (-> (the-as collide-fragment s1-0) mesh)) + (set! (-> v1-12 inst) obj) + ) + (+! (-> arg1 num-items) 1) + ) + (set! s1-0 (-> (the-as (inline-array collide-fragment) s1-0) 1)) + ) + ) + ) + ) + ) + (&+! obj 64) + ) + 0 + (none) + ) + + +;;;;;;;;;;;;;;;;;;;;;;;;;; +;; Y PROBE +;;;;;;;;;;;;;;;;;;;;;;;;;; + +(defmethod fill-using-y-probe collide-cache ((obj collide-cache) (arg0 vector) (arg1 float) (arg2 collide-kind) (arg3 process-drawable) (arg4 uint)) + (rlet ((vf1 :class vf) + (vf2 :class vf) + (vf3 :class vf) + (vf4 :class vf) + (vf5 :class vf) + ) + (set! *already-printed-exeeded-max-cache-tris* #f) + (.mov vf5 arg1) + (.lvf vf2 (&-> arg0 quad)) + (nop!) + (let ((v1-0 *collide-work*)) + (.mov.vf vf1 vf2) + (set! (-> obj ignore-mask) (the-as pat-surface arg4)) + (.add.x.vf vf2 vf2 vf5 :mask #b10) + (set! (-> obj num-tris) 0) + (.sub.x.vf vf1 vf1 vf5 :mask #b10) + (set! (-> obj num-prims) 0) + (nop!) + (set! (-> obj collide-with) arg2) + (nop!) + (set! (-> obj proc) arg3) + (.ftoi.vf vf4 vf2) + (.svf (&-> obj collide-box max quad) vf2) + (.ftoi.vf vf3 vf1) + (.svf (&-> obj collide-box min quad) vf1) + (nop!) + (.svf (&-> obj collide-box4w max quad) vf4) + (nop!) + (.svf (&-> obj collide-box4w min quad) vf3) + (nop!) + (.svf (&-> v1-0 collide-box4w max quad) vf4) + (nop!) + (.svf (&-> v1-0 collide-box4w min quad) vf3) + ) + (if (logtest? arg2 (collide-kind background)) + (fill-from-background + obj + (method-of-type bsp-header collide-y-probe) + (the-as (function collide-cache object none) (method-of-type collide-cache dummy-28)) + ) + ) + (if (logtest? arg2 (collide-kind water)) + (fill-from-water obj (-> arg3 water)) + ) + (if (logtest? arg2 (collide-kind cak-1 cak-2 cak-3 target)) + (fill-from-foreground-using-y-probe obj) + ) + 0 + (none) + ) + ) + +(defun collide-cache-using-y-probe-test ((arg0 vector)) + (local-vars + (zero uint128) + (v1-1 uint128) + (v1-2 uint128) + (v1-3 uint128) + (a0-1 uint128) + (a1-2 uint128) + (a2-0 uint128) + (f31-0 none) + ) + (rlet ((vf1 :class vf) + (vf2 :class vf) + (vf3 :class vf) + (vf4 :class vf) + (vf5 :class vf) + ) + (set! zero (the-as uint128 0)) + (nop!) + (let ((a1-0 *collide-work*)) + (nop!) + (.lvf vf1 (&-> arg0 quad)) + (nop!) + (let ((v1-0 (-> a1-0 collide-box4w min quad))) + (.sub.w.vf vf2 vf1 vf1 :mask #b111) + (let ((a1-1 (-> a1-0 collide-box4w max quad))) + (.add.w.vf vf3 vf1 vf1 :mask #b111) + (nop!) + (.ftoi.vf vf4 vf2) + (nop!) + (.ftoi.vf vf5 vf3) + (nop!) + (.mov a2-0 vf4) + (nop!) + (.mov a0-1 vf5) + (nop!) + (.pcgtw a1-2 a2-0 a1-1) + ) + (.pcgtw v1-1 v1-0 a0-1) + ) + ) + (.por v1-2 a1-2 v1-1) + (.ppach v1-3 zero v1-2) + (let ((v1-4 (shl (the-as int v1-3) 16))) + (nop!) + (zero? v1-4) + ) + ) + ) + +;; definition for method 12 of type collide-fragment +;; INFO: Return type mismatch int vs none. +(defmethod collide-y-probe collide-fragment ((obj collide-fragment) (arg0 int) (arg1 collide-list)) + *collide-work* + (dotimes (s3-0 arg0) + (when (collide-cache-using-y-probe-test (-> obj bsphere)) + (let ((v1-5 (-> arg1 items (-> arg1 num-items)))) + (set! (-> v1-5 mesh) (-> obj mesh)) + (set! (-> v1-5 inst) #f) + ) + (+! (-> arg1 num-items) 1) + ) + (&+! obj 32) + ) + 0 + (none) + ) + +;; definition for method 12 of type instance-tie +;; INFO: Return type mismatch int vs none. +(defmethod collide-y-probe instance-tie ((obj instance-tie) (arg0 int) (arg1 collide-list)) + (dotimes (s3-0 arg0) + (when (and (zero? (logand (-> obj flags) 1)) (collide-cache-using-y-probe-test (-> obj bsphere))) + (let ((s2-0 (-> obj bucket-ptr collide-frag))) + (when (nonzero? s2-0) + (let ((s1-0 (the-as object (-> s2-0 data)))) + (dotimes (s0-0 (-> s2-0 length)) + (when (instance-sphere-box-intersect? (the-as collide-fragment s1-0) obj (-> *collide-work* collide-box4w)) + (let ((v1-11 (-> arg1 items (-> arg1 num-items)))) + (set! (-> v1-11 mesh) (-> (the-as collide-fragment s1-0) mesh)) + (set! (-> v1-11 inst) obj) + ) + (+! (-> arg1 num-items) 1) + ) + (set! s1-0 (-> (the-as (inline-array collide-fragment) s1-0) 1)) + ) + ) + ) + ) + ) + (&+! obj 64) + ) + 0 + (none) + ) + ;;;;;;;;;;;;;;;;;;;;; ;; Line Sphere Test ;;;;;;;;;;;;;;;;;;;;; @@ -48,6 +579,175 @@ ;; The first pass sets up a non-axis-aligned bounding box in *collide-work* ;; The box is stored as an axis-aligned box, and an inv-rot to transform from world to aligned-box coordinates. +(defmacro pabsw-hack (out in) + `(let ((temp (new 'stack-no-clear 'array 'int32 4))) + (set! (-> (the (pointer uint128) temp)) ,in) + (set! (-> temp 0) (abs (-> temp 0))) + (set! (-> temp 1) (abs (-> temp 1))) + (set! (-> temp 2) (abs (-> temp 2))) + (set! (-> temp 3) (abs (-> temp 3))) + (set! ,out (-> (the (pointer uint128) temp))) + ) + ) + + +(defmethod fill-using-line-sphere collide-cache ((obj collide-cache) + (arg0 vector) + (arg1 vector) + (arg2 float) + (arg3 collide-kind) + (arg4 process-drawable) + (arg5 int) + ) + (local-vars + (zero uint128) + (a0-2 uint128) + (a0-3 uint128) + (a0-7 int) + (t0-1 uint128) + (t0-2 uint128) + ) + (rlet ((acc :class vf) + (Q :class vf) + (vf0 :class vf) + (vf1 :class vf) + (vf10 :class vf) + (vf11 :class vf) + (vf12 :class vf) + (vf13 :class vf) + (vf14 :class vf) + (vf15 :class vf) + (vf16 :class vf) + (vf17 :class vf) + (vf18 :class vf) + (vf19 :class vf) + (vf2 :class vf) + (vf20 :class vf) + (vf21 :class vf) + (vf22 :class vf) + (vf23 :class vf) + (vf3 :class vf) + (vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + (vf7 :class vf) + (vf8 :class vf) + (vf9 :class vf) + ) + (set! zero (the uint128 0)) + (init-vf0-vector) + (let ((v1-0 (new 'static 'vector4w :x #x1000 :y #x1000 :z #x1000))) + (nop!) + (.mov vf9 arg2) + (.lvf vf3 (&-> arg1 quad)) + (nop!) + (let ((a0-1 (-> v1-0 quad))) + (.ftoi.vf vf21 vf3) + (.lvf vf1 (&-> arg0 quad)) + (.mul.vf vf8 vf3 vf3) + (let ((v1-1 *collide-work*)) + (.add.vf vf2 vf1 vf3) + (set! (-> obj ignore-mask) (the-as pat-surface arg5)) + (.mov t0-1 vf21) + (nop!) + (pabsw-hack t0-2 t0-1) ;; t0-2 is the line, absolute value + (.pcgtw a0-2 t0-2 a0-1) + (.ppach a0-3 zero a0-2) + (let ((a0-4 (shl (the-as int a0-3) 16))) + (b! (nonzero? a0-4) cfg-3) + ) + (let ((s2-0 (new 'stack-no-clear 'bounding-box))) + (set-from-point-offset-pad! s2-0 (the-as vector3s arg0) (the-as vector3s arg1) arg2) + (fill-using-bounding-box obj s2-0 arg3 arg4 (the-as pat-surface arg5)) + ) + (b! #t cfg-13 :delay (nop!)) + (set! v1-1 (the-as collide-work 0)) + (label cfg-3) + (.add.y.vf vf8 vf8 vf8 :mask #b1) + (set! (-> obj num-tris) 0) + (.min.vf vf4 vf1 vf2) + (set! (-> obj num-prims) 0) + (.max.vf vf5 vf1 vf2) + (set! (-> obj collide-with) arg3) + (.sub.x.vf vf10 vf0 vf9 :mask #b111) + (set! (-> obj proc) arg4) + (.add.z.vf vf8 vf8 vf8 :mask #b1) + (.sub.x.vf vf4 vf4 vf9 :mask #b111) + (.add.x.vf vf5 vf5 vf9 :mask #b111) + (.ftoi.vf vf15 vf10) + (.isqrt.vf Q vf0 vf8 :fsf #b11 :ftf #b0) + (.add.x.vf vf11 vf0 vf9 :mask #b111) + (.svf (&-> v1-1 collide-box4w min quad) vf15) + (.ftoi.vf vf6 vf4) + (.svf (&-> obj collide-box min quad) vf4) + (.ftoi.vf vf7 vf5) + (.svf (&-> obj collide-box max quad) vf5) + (.mov.vf vf13 vf0) + (.svf (&-> obj collide-box4w min quad) vf6) + (.svf (&-> obj collide-box4w max quad) vf7) + (.add.vf vf8 vf0 Q :mask #b1) + (.mul.x.vf vf12 vf3 vf8) + (.div.vf Q vf0 vf8 :fsf #b11 :ftf #b0) + (.mul.vf vf22 vf12 vf12) + (.abs.vf vf23 vf12) + (.add.y.vf vf22 vf22 vf22 :mask #b1) + (.mov a0-7 vf23) + (.wait.vf) + (.add.vf vf8 vf0 Q :mask #b1) + (b! (zero? a0-7) cfg-6 :likely-delay (.add.z.vf vf13 vf0 vf12 :mask #b1)) + (.sub.y.vf vf13 vf0 vf12 :mask #b1) + (.isqrt.vf Q vf0 vf22 :fsf #b11 :ftf #b0) + (.add.x.vf vf13 vf0 vf12 :mask #b10) + (.wait.vf) + (.mul.vf vf13 vf13 Q :mask #b11) + (label cfg-6) + (.outer.product.a.vf acc vf12 vf13) + (.add.x.vf vf11 vf11 vf8 :mask #b1) + (.outer.product.b.vf vf14 vf13 vf12 acc) + (.ftoi.vf vf16 vf11) + (.mov.vf vf17 vf12) + (.mov.vf vf18 vf13) + (.mov.vf vf19 vf14) + (.mov.vf vf17 vf0 :mask #b1110) + (.svf (&-> v1-1 collide-box4w max quad) vf16) + (.mov.vf vf18 vf0 :mask #b1101) + (.mov.vf vf19 vf0 :mask #b1011) + (.add.x.vf vf17 vf17 vf13 :mask #b10) + (.add.y.vf vf18 vf18 vf12 :mask #b1) + (.add.z.vf vf19 vf19 vf12 :mask #b1) + (.add.x.vf vf17 vf17 vf14 :mask #b100) + (.add.y.vf vf18 vf18 vf14 :mask #b100) + (.add.z.vf vf19 vf19 vf13 :mask #b10) + (.mul.x.vf acc vf17 vf1) + (.add.mul.y.vf acc vf18 vf1 acc) + (.svf (&-> v1-1 inv-mat vector 0 quad) vf17) + (.add.mul.z.vf vf20 vf19 vf1 acc) + (.svf (&-> v1-1 inv-mat vector 1 quad) vf18) + (.sub.vf vf20 vf0 vf20) + (.svf (&-> v1-1 inv-mat vector 2 quad) vf19) + (.svf (&-> v1-1 inv-mat vector 3 quad) vf20) + ) + ) + ) + 0 + (if (logtest? arg3 (collide-kind background)) + (fill-from-background + obj + (method-of-type bsp-header collide-ray) + (the-as (function collide-cache object none) (method-of-type collide-cache dummy-27)) + ) + ) + (if (logtest? arg3 (collide-kind water)) + (fill-from-water obj (-> arg4 water)) + ) + (if (logtest? arg3 (collide-kind cak-1 cak-2 cak-3 target)) + (fill-from-foreground-using-line-sphere obj) + ) + 0 + (label cfg-13) + (none) + ) + ) (defun collide-cache-using-line-sphere-test ((arg0 vector)) "Check if the input sphere is in the rotated bounding box volume of the current @@ -244,4 +944,1582 @@ ) 0 (none) - ) \ No newline at end of file + ) + + +;;;;;;;;;;;;;;;;;;; +;; foreground box +;;;;;;;;;;;;;;;;;;; + +;; for an unknown reason, the goal compiler went insane on this function + +(defmethod fill-from-foreground-using-box collide-cache ((obj collide-cache)) + (local-vars + (zero uint128) + (v1-2 uint128) + (v1-15 uint128) + (v1-18 uint128) + (v1-31 uint128) + (v1-44 uint128) + (a1-1 uint128) + (a1-6 uint128) + (a1-11 uint128) + (a1-16 uint128) + (a2-0 uint128) + (a2-1 uint128) + (a2-2 uint128) + (a2-3 uint128) + (a2-5 uint128) + (a2-6 uint128) + (a2-7 uint128) + (a2-8 uint128) + (a2-10 uint128) + (a2-11 uint128) + (a2-12 uint128) + (a2-13 uint128) + (a2-15 uint128) + (a2-16 uint128) + (a2-17 uint128) + (a2-18 uint128) + (a3-0 uint128) + (a3-1 uint128) + (a3-2 uint128) + (a3-3 uint128) + (a3-4 uint128) + (a3-5 uint128) + (a3-6 uint128) + (a3-7 uint128) + (f31-0 none) + ) + (rlet ((vf1 :class vf) + (vf2 :class vf) + (vf3 :class vf) + (vf4 :class vf) + (vf5 :class vf) + ) + (set! zero (the-as uint128 0)) + (let ((s5-0 (the-as uint128 (-> obj collide-with))) + (s4-0 (-> obj collide-box4w min quad)) + (s3-0 (-> obj collide-box4w max quad)) + ) + (let ((v1-1 (the-as uint128 (make-u128 0 16)))) + (.pand v1-2 v1-1 s5-0) + ) + (when (nonzero? (the-as int v1-2)) + (let ((v1-5 (-> *collide-player-list* alive-list next0))) + *collide-player-list* + (let ((s2-0 (-> v1-5 next0))) + (while (!= v1-5 (-> *collide-player-list* alive-list-end)) + (let* ((v1-6 (the-as collide-shape (-> (the-as connection v1-5) param1))) + (a0-3 (-> v1-6 root-prim)) + ) + (let ((a1-0 (the-as uint128 (-> a0-3 prim-core collide-as)))) + (.pand a1-1 s5-0 a1-0) + ) + (b! (zero? (the-as int a1-1)) cfg-7) + (nop!) + (.lvf vf1 (&-> a0-3 prim-core world-sphere quad)) + (.sub.w.vf vf2 vf1 vf1) + (nop!) + (.add.w.vf vf3 vf1 vf1) + (nop!) + (.ftoi.vf vf4 vf2) + (nop!) + (.ftoi.vf vf5 vf3) + (nop!) + (.mov a2-0 vf4) + (let ((v1-7 (-> v1-6 process))) + (.mov a3-0 vf5) + (let ((a1-3 (-> obj proc))) + (.pcgtw a2-1 a2-0 s3-0) + (.pcgtw a3-1 s4-0 a3-0) + (.por a2-2 a2-1 a3-1) + (.ppach a2-3 zero a2-2) + (let ((a2-4 (shl (the-as int a2-3) 16))) + (nop!) + (b! (nonzero? a2-4) cfg-6 :delay (nop!)) + ) + (b! (= a1-3 v1-7) cfg-6 :delay (nop!)) + ) + ) + (add-fg-prim-using-box a0-3 obj) + ) + (label cfg-6) + 0 + (label cfg-7) + (set! v1-5 s2-0) + *collide-player-list* + (set! s2-0 (-> s2-0 next0)) + ) + ) + ) + ) + (let ((v1-14 (the-as uint128 (make-u128 0 14)))) + (.pand v1-15 v1-14 s5-0) + ) + (when (nonzero? (the-as int v1-15)) + (let ((v1-17 (the-as uint128 (make-u128 0 2)))) + (.pand v1-18 v1-17 s5-0) + ) + (when (nonzero? (the-as int v1-18)) + (let ((v1-21 (-> *collide-hit-by-player-list* alive-list next0))) + *collide-hit-by-player-list* + (let ((s2-1 (-> v1-21 next0))) + (while (!= v1-21 (-> *collide-hit-by-player-list* alive-list-end)) + (let* ((v1-22 (the-as collide-shape (-> (the-as connection v1-21) param1))) + (a0-10 (-> v1-22 root-prim)) + ) + (let ((a1-5 (the-as uint128 (-> a0-10 prim-core collide-as)))) + (.pand a1-6 s5-0 a1-5) + ) + (b! (zero? (the-as int a1-6)) cfg-18) + (nop!) + (.lvf vf1 (&-> a0-10 prim-core world-sphere quad)) + (.sub.w.vf vf2 vf1 vf1) + (nop!) + (.add.w.vf vf3 vf1 vf1) + (nop!) + (.ftoi.vf vf4 vf2) + (nop!) + (.ftoi.vf vf5 vf3) + (nop!) + (.mov a2-5 vf4) + (let ((v1-23 (-> v1-22 process))) + (.mov a3-2 vf5) + (let ((a1-8 (-> obj proc))) + (.pcgtw a2-6 a2-5 s3-0) + (.pcgtw a3-3 s4-0 a3-2) + (.por a2-7 a2-6 a3-3) + (.ppach a2-8 zero a2-7) + (let ((a2-9 (shl (the-as int a2-8) 16))) + (nop!) + (b! (nonzero? a2-9) cfg-17 :delay (nop!)) + ) + (b! (= a1-8 v1-23) cfg-17 :delay (nop!)) + ) + ) + (add-fg-prim-using-box a0-10 obj) + ) + (label cfg-17) + 0 + (label cfg-18) + (set! v1-21 s2-1) + *collide-hit-by-player-list* + (set! s2-1 (-> s2-1 next0)) + ) + ) + ) + ) + (let ((v1-30 (the-as uint128 (make-u128 0 4)))) + (.pand v1-31 v1-30 s5-0) + ) + (when (nonzero? (the-as int v1-31)) + (let ((v1-34 (-> *collide-usually-hit-by-player-list* alive-list next0))) + *collide-usually-hit-by-player-list* + (let ((s2-2 (-> v1-34 next0))) + (while (!= v1-34 (-> *collide-usually-hit-by-player-list* alive-list-end)) + (let* ((v1-35 (the-as collide-shape (-> (the-as connection v1-34) param1))) + (a0-17 (-> v1-35 root-prim)) + ) + (let ((a1-10 (the-as uint128 (-> a0-17 prim-core collide-as)))) + (.pand a1-11 s5-0 a1-10) + ) + (b! (zero? (the-as int a1-11)) cfg-28) + (nop!) + (nop!) + (.lvf vf1 (&-> a0-17 prim-core world-sphere quad)) + (.sub.w.vf vf2 vf1 vf1) + (nop!) + (.add.w.vf vf3 vf1 vf1) + (nop!) + (.ftoi.vf vf4 vf2) + (nop!) + (.ftoi.vf vf5 vf3) + (nop!) + (.mov a2-10 vf4) + (let ((v1-36 (-> v1-35 process))) + (.mov a3-4 vf5) + (let ((a1-13 (-> obj proc))) + (.pcgtw a2-11 a2-10 s3-0) + (.pcgtw a3-5 s4-0 a3-4) + (.por a2-12 a2-11 a3-5) + (.ppach a2-13 zero a2-12) + (let ((a2-14 (shl (the-as int a2-13) 16))) + (nop!) + (b! (nonzero? a2-14) cfg-27 :delay (nop!)) + ) + (b! (= a1-13 v1-36) cfg-27 :delay (nop!)) + ) + ) + (add-fg-prim-using-box a0-17 obj) + ) + (label cfg-27) + 0 + (label cfg-28) + (set! v1-34 s2-2) + *collide-usually-hit-by-player-list* + (set! s2-2 (-> s2-2 next0)) + ) + ) + ) + ) + (let ((v1-43 (the-as uint128 (make-u128 0 8)))) + (.pand v1-44 v1-43 s5-0) + ) + (when (nonzero? (the-as int v1-44)) + (let ((v1-46 (-> *collide-hit-by-others-list* alive-list next0))) + *collide-hit-by-others-list* + (let ((s2-3 (-> v1-46 next0))) + (while (!= v1-46 (-> *collide-hit-by-others-list* alive-list-end)) + (let* ((v1-47 (the-as collide-shape (-> (the-as connection v1-46) param1))) + (a0-24 (-> v1-47 root-prim)) + ) + (let ((a1-15 (the-as uint128 (-> a0-24 prim-core collide-as)))) + (.pand a1-16 s5-0 a1-15) + ) + (b! (zero? (the-as int a1-16)) cfg-38) + (nop!) + (nop!) + (.lvf vf1 (&-> a0-24 prim-core world-sphere quad)) + (.sub.w.vf vf2 vf1 vf1) + (nop!) + (.add.w.vf vf3 vf1 vf1) + (nop!) + (.ftoi.vf vf4 vf2) + (nop!) + (.ftoi.vf vf5 vf3) + (nop!) + (.mov a2-15 vf4) + (let ((v1-48 (-> v1-47 process))) + (.mov a3-6 vf5) + (let ((a1-18 (-> obj proc))) + (.pcgtw a2-16 a2-15 s3-0) + (.pcgtw a3-7 s4-0 a3-6) + (.por a2-17 a2-16 a3-7) + (.ppach a2-18 zero a2-17) + (let ((a2-19 (shl (the-as int a2-18) 16))) + (nop!) + (b! (nonzero? a2-19) cfg-37 :delay (nop!)) + ) + (b! (= a1-18 v1-48) cfg-37 :delay (nop!)) + ) + ) + (add-fg-prim-using-box a0-24 obj) + ) + (label cfg-37) + 0 + (label cfg-38) + (set! v1-46 s2-3) + *collide-hit-by-others-list* + (set! s2-3 (-> s2-3 next0)) + ) + ) + ) + ) + ) + ) + (none) + ) + ) + +(defmethod add-fg-prim-using-box collide-shape-prim ((obj collide-shape-prim) (arg0 collide-cache)) + (format 0 "ERROR: Illegal collide-shape-prim type passed to collide-shape-prim::add-fg-prim-using-box!~%") + (none) + ) + +(defmethod add-fg-prim-using-box collide-shape-prim-sphere ((obj collide-shape-prim-sphere) (arg0 collide-cache)) + (local-vars (t1-1 uint)) + (nop!) + (let* ((t0-0 (-> arg0 prims)) + (a3-0 (-> arg0 num-prims-u)) + (t1-0 100) + (v1-0 (-> obj prim-core world-sphere quad)) + (t2-0 (* a3-0 2)) + (a2-0 (-> obj prim-core quad 1)) + ) + (b! (= a3-0 t1-0) cfg-2 :delay (set! t1-1 (+ t2-0 a3-0))) + (let ((t0-1 (the-as object (&-> t0-0 0 prim-core quad t1-1)))) + (let ((a3-1 (+ a3-0 1))) + (set! (-> (the-as (pointer uint128) t0-1) 2) (the-as uint128 0)) + (nop!) + (set! (-> (the-as collide-cache-prim t0-1) prim) obj) + (nop!) + (set! (-> (the-as collide-cache-prim t0-1) prim-core world-sphere quad) v1-0) + (nop!) + (set! (-> (the-as collide-cache-prim t0-1) prim-core quad 1) a2-0) + (nop!) + (set! (-> arg0 num-prims) (the-as int a3-1)) + ) + (nop!) + (set! (-> (the-as collide-cache-prim t0-1) ccache) arg0) + ) + ) + (b! #t cfg-3 :delay (nop!)) + (label cfg-2) + (format 0 "ERROR: Exceeded max number of collide-cache prims!~%") + (label cfg-3) + (none) + ) + +(defmethod add-fg-prim-using-box collide-shape-prim-group ((obj collide-shape-prim-group) (arg0 collide-cache)) + (local-vars + (zero uint128) + (v1-2 uint128) + (v1-3 uint128) + (v1-4 uint128) + (v1-5 uint128) + (a0-1 collide-shape-prim) + (a1-1 uint128) + (a1-2 uint128) + ) + (set! zero (the-as uint128 0)) + (rlet ((vf1 :class vf) + (vf2 :class vf) + (vf3 :class vf) + (vf4 :class vf) + (vf5 :class vf) + ) + (nop!) + (let ((s5-0 (-> obj prims)) + (s4-0 (-> obj num-prims-u)) + ) + (nop!) + (let ((s3-0 (-> arg0 collide-box4w min quad))) + (nop!) + (let ((s2-0 (-> arg0 collide-box4w max quad))) + (nop!) + (let ((s1-0 (-> s5-0 0))) + (nop!) + (let ((s0-0 (-> arg0 collide-with))) + (label cfg-1) + (b! (zero? s4-0) cfg-5 :delay (set! a0-1 s1-0)) + (label cfg-2) + (+! s4-0 -1) + (.lvf vf1 (&-> a0-1 prim-core world-sphere quad)) + (nop!) + (let ((v1-0 (-> a0-1 prim-core collide-as))) + (.sub.w.vf vf2 vf1 vf1) + (set! s5-0 (&-> s5-0 1)) + (.add.w.vf vf3 vf1 vf1) + (set! s1-0 (-> s5-0 0)) + (let ((v1-1 (logand s0-0 v1-0))) + (nop!) + (b! (zero? v1-1) cfg-1 :delay (nop!)) + ) + ) + ) + (.ftoi.vf vf4 vf2) + (nop!) + (.ftoi.vf vf5 vf3) + (nop!) + (.mov a1-1 vf4) + (nop!) + (.mov v1-2 vf5) + (nop!) + (.pcgtw a1-2 a1-1 s2-0) + (.pcgtw v1-3 s3-0 v1-2) + (.por v1-4 a1-2 v1-3) + (.ppach v1-5 zero v1-4) + (let ((v1-6 (shl (the-as int v1-5) 16))) + (nop!) + (b! (nonzero? v1-6) cfg-1 :delay (nop!)) + ) + (add-fg-prim-using-box a0-1 arg0) + (b! (nonzero? s4-0) cfg-2 :delay (set! a0-1 s1-0)) + ) + ) + ) + ) + (label cfg-5) + 0 + (none) + ) + ) + + +;;;;;;;;;;;;;;;;;;;;;;;;; +;; Foreground Y PROBE +;;;;;;;;;;;;;;;;;;;;;;;;; + +(defmethod fill-from-foreground-using-y-probe collide-cache ((obj collide-cache)) + (local-vars + (zero uint128) + (v1-2 uint128) + (v1-15 uint128) + (v1-18 uint128) + (v1-31 uint128) + (v1-44 uint128) + (a1-1 uint128) + (a1-6 uint128) + (a1-11 uint128) + (a1-16 uint128) + (a2-0 uint128) + (a2-1 uint128) + (a2-2 uint128) + (a2-3 uint128) + (a2-5 uint128) + (a2-6 uint128) + (a2-7 uint128) + (a2-8 uint128) + (a2-10 uint128) + (a2-11 uint128) + (a2-12 uint128) + (a2-13 uint128) + (a2-15 uint128) + (a2-16 uint128) + (a2-17 uint128) + (a2-18 uint128) + (a3-0 uint128) + (a3-1 uint128) + (a3-2 uint128) + (a3-3 uint128) + (a3-4 uint128) + (a3-5 uint128) + (a3-6 uint128) + (a3-7 uint128) + ) + (set! zero (the uint128 0)) + (rlet ((vf1 :class vf) + (vf2 :class vf) + (vf3 :class vf) + (vf4 :class vf) + (vf5 :class vf) + ) + (let ((s5-0 (the-as uint128 (-> obj collide-with))) + (s4-0 (-> obj collide-box4w min quad)) + (s3-0 (-> obj collide-box4w max quad)) + ) + (let ((v1-1 (the-as uint128 (make-u128 0 16)))) + (.pand v1-2 v1-1 s5-0) + ) + (when (nonzero? (the-as int v1-2)) + (let ((v1-5 (-> *collide-player-list* alive-list next0))) + *collide-player-list* + (let ((s2-0 (-> v1-5 next0))) + (while (!= v1-5 (-> *collide-player-list* alive-list-end)) + (let* ((v1-6 (the-as collide-shape (-> (the-as connection v1-5) param1))) + (a0-3 (-> v1-6 root-prim)) + ) + (let ((a1-0 (the-as uint128 (-> a0-3 prim-core collide-as)))) + (.pand a1-1 s5-0 a1-0) + ) + (b! (zero? (the-as int a1-1)) cfg-7) + (.lvf vf1 (&-> a0-3 prim-core world-sphere quad)) + (.sub.w.vf vf2 vf1 vf1) + (.add.w.vf vf3 vf1 vf1) + (.ftoi.vf vf4 vf2) + (.ftoi.vf vf5 vf3) + (.mov a2-0 vf4) + (let ((v1-7 (-> v1-6 process))) + (.mov a3-0 vf5) + (let ((a1-3 (-> obj proc))) + (.pcgtw a2-1 a2-0 s3-0) + (.pcgtw a3-1 s4-0 a3-0) + (.por a2-2 a2-1 a3-1) + (.ppach a2-3 zero a2-2) + (let ((a2-4 (shl (the-as int a2-3) 16))) + (nop!) + (b! (nonzero? a2-4) cfg-6 :delay (nop!)) + ) + (b! (= a1-3 v1-7) cfg-6 :delay (nop!)) + ) + ) + (add-fg-prim-using-y-probe a0-3 obj) + ) + (label cfg-6) + 0 + (label cfg-7) + (set! v1-5 s2-0) + *collide-player-list* + (set! s2-0 (-> s2-0 next0)) + ) + ) + ) + ) + (let ((v1-14 (the-as uint128 (make-u128 0 14)))) + (.pand v1-15 v1-14 s5-0) + ) + (when (nonzero? (the-as int v1-15)) + (let ((v1-17 (the-as uint128 (make-u128 0 2)))) + (.pand v1-18 v1-17 s5-0) + ) + (when (nonzero? (the-as int v1-18)) + (let ((v1-21 (-> *collide-hit-by-player-list* alive-list next0))) + *collide-hit-by-player-list* + (let ((s2-1 (-> v1-21 next0))) + (while (!= v1-21 (-> *collide-hit-by-player-list* alive-list-end)) + (let* ((v1-22 (the-as collide-shape (-> (the-as connection v1-21) param1))) + (a0-10 (-> v1-22 root-prim)) + ) + (let ((a1-5 (the-as uint128 (-> a0-10 prim-core collide-as)))) + (.pand a1-6 s5-0 a1-5) + ) + (b! (zero? (the-as int a1-6)) cfg-18) + (nop!) + (.lvf vf1 (&-> a0-10 prim-core world-sphere quad)) + (.sub.w.vf vf2 vf1 vf1) + (nop!) + (.add.w.vf vf3 vf1 vf1) + (nop!) + (.ftoi.vf vf4 vf2) + (nop!) + (.ftoi.vf vf5 vf3) + (nop!) + (.mov a2-5 vf4) + (let ((v1-23 (-> v1-22 process))) + (.mov a3-2 vf5) + (let ((a1-8 (-> obj proc))) + (.pcgtw a2-6 a2-5 s3-0) + (.pcgtw a3-3 s4-0 a3-2) + (.por a2-7 a2-6 a3-3) + (.ppach a2-8 zero a2-7) + (let ((a2-9 (shl (the-as int a2-8) 16))) + (nop!) + (b! (nonzero? a2-9) cfg-17 :delay (nop!)) + ) + (b! (= a1-8 v1-23) cfg-17 :delay (nop!)) + ) + ) + (add-fg-prim-using-y-probe a0-10 obj) + ) + (label cfg-17) + 0 + (label cfg-18) + (set! v1-21 s2-1) + *collide-hit-by-player-list* + (set! s2-1 (-> s2-1 next0)) + ) + ) + ) + ) + (let ((v1-30 (the-as uint128 (make-u128 0 4)))) + (.pand v1-31 v1-30 s5-0) + ) + (when (nonzero? (the-as int v1-31)) + (let ((v1-34 (-> *collide-usually-hit-by-player-list* alive-list next0))) + *collide-usually-hit-by-player-list* + (let ((s2-2 (-> v1-34 next0))) + (while (!= v1-34 (-> *collide-usually-hit-by-player-list* alive-list-end)) + (let* ((v1-35 (the-as collide-shape (-> (the-as connection v1-34) param1))) + (a0-17 (-> v1-35 root-prim)) + ) + (let ((a1-10 (the-as uint128 (-> a0-17 prim-core collide-as)))) + (.pand a1-11 s5-0 a1-10) + ) + (b! (zero? (the-as int a1-11)) cfg-28) + (nop!) + (nop!) + (.lvf vf1 (&-> a0-17 prim-core world-sphere quad)) + (.sub.w.vf vf2 vf1 vf1) + (nop!) + (.add.w.vf vf3 vf1 vf1) + (nop!) + (.ftoi.vf vf4 vf2) + (nop!) + (.ftoi.vf vf5 vf3) + (nop!) + (.mov a2-10 vf4) + (let ((v1-36 (-> v1-35 process))) + (.mov a3-4 vf5) + (let ((a1-13 (-> obj proc))) + (.pcgtw a2-11 a2-10 s3-0) + (.pcgtw a3-5 s4-0 a3-4) + (.por a2-12 a2-11 a3-5) + (.ppach a2-13 zero a2-12) + (let ((a2-14 (shl (the-as int a2-13) 16))) + (nop!) + (b! (nonzero? a2-14) cfg-27 :delay (nop!)) + ) + (b! (= a1-13 v1-36) cfg-27 :delay (nop!)) + ) + ) + (add-fg-prim-using-y-probe a0-17 obj) + ) + (label cfg-27) + 0 + (label cfg-28) + (set! v1-34 s2-2) + *collide-usually-hit-by-player-list* + (set! s2-2 (-> s2-2 next0)) + ) + ) + ) + ) + (let ((v1-43 (the-as uint128 (make-u128 0 8)))) + (.pand v1-44 v1-43 s5-0) + ) + (when (nonzero? (the-as int v1-44)) + (let ((v1-46 (-> *collide-hit-by-others-list* alive-list next0))) + *collide-hit-by-others-list* + (let ((s2-3 (-> v1-46 next0))) + (while (!= v1-46 (-> *collide-hit-by-others-list* alive-list-end)) + (let* ((v1-47 (the-as collide-shape (-> (the-as connection v1-46) param1))) + (a0-24 (-> v1-47 root-prim)) + ) + (let ((a1-15 (the-as uint128 (-> a0-24 prim-core collide-as)))) + (.pand a1-16 s5-0 a1-15) + ) + (b! (zero? (the-as int a1-16)) cfg-38) + (nop!) + (nop!) + (.lvf vf1 (&-> a0-24 prim-core world-sphere quad)) + (.sub.w.vf vf2 vf1 vf1) + (nop!) + (.add.w.vf vf3 vf1 vf1) + (nop!) + (.ftoi.vf vf4 vf2) + (nop!) + (.ftoi.vf vf5 vf3) + (nop!) + (.mov a2-15 vf4) + (let ((v1-48 (-> v1-47 process))) + (.mov a3-6 vf5) + (let ((a1-18 (-> obj proc))) + (.pcgtw a2-16 a2-15 s3-0) + (.pcgtw a3-7 s4-0 a3-6) + (.por a2-17 a2-16 a3-7) + (.ppach a2-18 zero a2-17) + (let ((a2-19 (shl (the-as int a2-18) 16))) + (nop!) + (b! (nonzero? a2-19) cfg-37 :delay (nop!)) + ) + (b! (= a1-18 v1-48) cfg-37 :delay (nop!)) + ) + ) + (add-fg-prim-using-y-probe a0-24 obj) + ) + (label cfg-37) + 0 + (label cfg-38) + (set! v1-46 s2-3) + *collide-hit-by-others-list* + (set! s2-3 (-> s2-3 next0)) + ) + ) + ) + ) + ) + ) + (none) + ) + ) + +(defmethod add-fg-prim-using-y-probe collide-shape-prim ((obj collide-shape-prim) (arg0 collide-cache)) + (format 0 "ERROR: Illegal collide-shape-prim type passed to collide-shape-prim::add-fg-prim-using-y-probe!~%") + (none) + ) + +(defmethod add-fg-prim-using-y-probe collide-shape-prim-sphere ((obj collide-shape-prim-sphere) (arg0 collide-cache)) + (local-vars (t1-1 uint)) + (nop!) + (let* ((t0-0 (-> arg0 prims)) + (a3-0 (-> arg0 num-prims-u)) + (t1-0 100) + (v1-0 (-> obj prim-core world-sphere quad)) + (t2-0 (* a3-0 2)) + (a2-0 (-> obj prim-core quad 1)) + ) + (b! (= a3-0 t1-0) cfg-2 :delay (set! t1-1 (+ t2-0 a3-0))) + (let ((t0-1 (the-as object (&-> t0-0 0 prim-core quad t1-1)))) + (let ((a3-1 (+ a3-0 1))) + (set! (-> (the-as collide-cache-prim t0-1) extra-quad) (the-as uint128 0)) + (nop!) + (set! (-> (the-as collide-cache-prim t0-1) prim) obj) + (nop!) + (set! (-> (the-as collide-cache-prim t0-1) prim-core world-sphere quad) v1-0) + (nop!) + (set! (-> (the-as collide-cache-prim t0-1) prim-core quad 1) a2-0) + (nop!) + (set! (-> arg0 num-prims) (the-as int a3-1)) + ) + (nop!) + (set! (-> (the-as collide-cache-prim t0-1) ccache) arg0) + ) + ) + (b! #t cfg-3 :delay (nop!)) + (label cfg-2) + (format 0 "ERROR: Exceeded max number of collide-cache prims!~%") + (label cfg-3) + (none) + ) + + +(defmethod add-fg-prim-using-y-probe collide-shape-prim-group ((obj collide-shape-prim-group) (arg0 collide-cache)) + (local-vars + (r0-0 int) + (r0-1 int) + (r0-2 uint128) + (r0-3 int) + (v1-2 uint128) + (v1-3 uint128) + (v1-4 uint128) + (v1-5 uint128) + (a0-1 collide-shape-prim) + (a1-1 uint128) + (a1-2 uint128) + (f31-0 none) + ) + (rlet ((vf1 :class vf) + (vf2 :class vf) + (vf3 :class vf) + (vf4 :class vf) + (vf5 :class vf) + ) + (nop!) + (let ((s5-0 (-> obj prims)) + (s4-0 (-> obj num-prims-u)) + ) + (nop!) + (let ((s3-0 (-> arg0 collide-box4w min quad))) + (nop!) + (let ((s2-0 (-> arg0 collide-box4w max quad))) + (nop!) + (let ((s1-0 (-> s5-0 0))) + (nop!) + (let ((s0-0 (-> arg0 collide-with))) + (label cfg-1) + (b! (zero? s4-0) cfg-5 :delay (set! a0-1 s1-0)) + (label cfg-2) + (+! s4-0 -1) + (.lvf vf1 (&-> a0-1 prim-core world-sphere quad)) + (nop!) + (let ((v1-0 (-> a0-1 prim-core collide-as))) + (.sub.w.vf vf2 vf1 vf1) + (set! s5-0 (&-> s5-0 1)) + (.add.w.vf vf3 vf1 vf1) + (set! s1-0 (-> s5-0 0)) + (let ((v1-1 (logand s0-0 v1-0))) + (nop!) + (b! (zero? v1-1) cfg-1 :delay (nop!)) + ) + ) + ) + (.ftoi.vf vf4 vf2) + (nop!) + (.ftoi.vf vf5 vf3) + (nop!) + (.mov a1-1 vf4) + (nop!) + (.mov v1-2 vf5) + (nop!) + (.pcgtw a1-2 a1-1 s2-0) + (.mov r0-0 f31-0) + (.pcgtw v1-3 s3-0 v1-2) + (.mov r0-1 f31-0) + (.por v1-4 a1-2 v1-3) + (.mov r0-2 f31-0) + (.ppach v1-5 r0-2 v1-4) + (.mov r0-3 f31-0) + (let ((v1-6 (shl (the-as int v1-5) 16))) + (nop!) + (b! (nonzero? v1-6) cfg-1 :delay (nop!)) + ) + (add-fg-prim-using-y-probe a0-1 arg0) + (b! (nonzero? s4-0) cfg-2 :delay (set! a0-1 s1-0)) + ) + ) + ) + ) + (label cfg-5) + 0 + (none) + ) + ) + + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; foreground Line Sphere +;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +;; added (fill from foreground using line sphere) +(deftype pc-fffuls-work (structure) + ((reg-vf28 vector :inline) + (reg-vf29 vector :inline) + (reg-vf30 vector :inline) + (reg-vf31 vector :inline) + ) + ) + +(define *pc-fffuls-work* (new 'global 'pc-fffuls-work)) + +(defmacro save-fffuls-work () + `(begin + (.svf (&-> *pc-fffuls-work* reg-vf31 quad) vf31) + (.svf (&-> *pc-fffuls-work* reg-vf30 quad) vf30) + (.svf (&-> *pc-fffuls-work* reg-vf29 quad) vf29) + (.svf (&-> *pc-fffuls-work* reg-vf28 quad) vf28) + ) + ) + +(defmacro load-fffuls-work () + `(begin + (.lvf vf28 (&-> *pc-fffuls-work* reg-vf28 quad)) + (.lvf vf29 (&-> *pc-fffuls-work* reg-vf29 quad)) + (.lvf vf30 (&-> *pc-fffuls-work* reg-vf30 quad)) + (.lvf vf31 (&-> *pc-fffuls-work* reg-vf31 quad)) + ) + ) + +(defmethod fill-from-foreground-using-line-sphere collide-cache ((obj collide-cache)) + (local-vars + (zero uint128) + (v1-1 float) + (v1-4 uint128) + (v1-17 uint128) + (v1-20 uint128) + (v1-33 uint128) + (v1-46 uint128) + (a1-1 uint128) + (a1-6 uint128) + (a1-11 uint128) + (a1-16 uint128) + (a2-0 uint128) + (a2-1 uint128) + (a2-2 uint128) + (a2-3 uint128) + (a2-5 uint128) + (a2-6 uint128) + (a2-7 uint128) + (a2-8 uint128) + (a2-10 uint128) + (a2-11 uint128) + (a2-12 uint128) + (a2-13 uint128) + (a2-15 uint128) + (a2-16 uint128) + (a2-17 uint128) + (a2-18 uint128) + (a3-0 uint128) + (a3-1 uint128) + (a3-2 uint128) + (a3-3 uint128) + (a3-4 uint128) + (a3-5 uint128) + (a3-6 uint128) + (a3-7 uint128) + (f31-0 none) + ) + (rlet ((acc :class vf) + (vf0 :class vf) + (vf1 :class vf) + (vf2 :class vf) + (vf28 :class vf) + (vf29 :class vf) + (vf3 :class vf) + (vf30 :class vf) + (vf31 :class vf) + (vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + ) + (init-vf0-vector) + (set! zero (the uint128 0)) + (let* ((v1-0 *collide-work*) + (s5-0 (-> v1-0 collide-box4w min quad)) + (s4-0 (-> v1-0 collide-box4w max quad)) + (s3-0 (the-as uint128 (-> obj collide-with))) + ) + (.lvf vf28 (&-> v1-0 inv-mat vector 0 quad)) + (.lvf vf29 (&-> v1-0 inv-mat vector 1 quad)) + (.lvf vf30 (&-> v1-0 inv-mat vector 2 quad)) + (.lvf vf31 (&-> v1-0 inv-mat vector 3 quad)) + (save-fffuls-work) + (.mov v1-1 vf31) + (let ((v1-3 (the-as uint128 (make-u128 0 16)))) + (.pand v1-4 v1-3 s3-0) + ) + (when (nonzero? (the-as int v1-4)) + (let ((v1-7 (-> *collide-player-list* alive-list next0))) + *collide-player-list* + (let ((s2-0 (-> v1-7 next0))) + (while (!= v1-7 (-> *collide-player-list* alive-list-end)) + (let* ((v1-8 (the-as collide-shape (-> (the-as connection v1-7) param1))) + (a0-3 (-> v1-8 root-prim)) + ) + (let ((a1-0 (the-as uint128 (-> a0-3 prim-core collide-as)))) + (.pand a1-1 s3-0 a1-0) + ) + (b! (zero? (the-as int a1-1)) cfg-7) + (.mul.w.vf acc vf31 vf0) + (.lvf vf1 (&-> a0-3 prim-core world-sphere quad)) + (.add.mul.x.vf acc vf28 vf1 acc) + (nop!) + (.add.mul.y.vf acc vf29 vf1 acc) + (nop!) + (.add.mul.z.vf vf6 vf30 vf1 acc) + (nop!) + (.sub.w.vf vf2 vf6 vf1 :mask #b111) + (nop!) + (.add.w.vf vf3 vf6 vf1 :mask #b111) + (nop!) + (.ftoi.vf vf4 vf2) + (nop!) + (.ftoi.vf vf5 vf3) + (nop!) + (.mov a2-0 vf4) + (let ((v1-9 (-> v1-8 process))) + (.mov a3-0 vf5) + (let ((a1-3 (-> obj proc))) + (.pcgtw a2-1 a2-0 s4-0) + (.pcgtw a3-1 s5-0 a3-0) + (.por a2-2 a2-1 a3-1) + (.ppach a2-3 zero a2-2) + (let ((a2-4 (shl (the-as int a2-3) 16))) + (nop!) + (b! (nonzero? a2-4) cfg-6 :delay (nop!)) + ) + (b! (= a1-3 v1-9) cfg-6 :delay (nop!)) + ) + ) + (add-fg-prim-using-line-sphere a0-3 obj) + ) + (label cfg-6) + 0 + (label cfg-7) + (set! v1-7 s2-0) + *collide-player-list* + (set! s2-0 (-> s2-0 next0)) + ) + ) + ) + ) + (let ((v1-16 (the-as uint128 (make-u128 0 14)))) + (.pand v1-17 v1-16 s3-0) + ) + (when (nonzero? (the-as int v1-17)) + (let ((v1-19 (the-as uint128 (make-u128 0 2)))) + (.pand v1-20 v1-19 s3-0) + ) + (when (nonzero? (the-as int v1-20)) + (let ((v1-23 (-> *collide-hit-by-player-list* alive-list next0))) + *collide-hit-by-player-list* + (let ((s2-1 (-> v1-23 next0))) + (while (!= v1-23 (-> *collide-hit-by-player-list* alive-list-end)) + (let* ((v1-24 (the-as collide-shape (-> (the-as connection v1-23) param1))) + (a0-10 (-> v1-24 root-prim)) + ) + (let ((a1-5 (the-as uint128 (-> a0-10 prim-core collide-as)))) + (.pand a1-6 s3-0 a1-5) + ) + (b! (zero? (the-as int a1-6)) cfg-18) + (.mul.w.vf acc vf31 vf0) + (.lvf vf1 (&-> a0-10 prim-core world-sphere quad)) + (.add.mul.x.vf acc vf28 vf1 acc) + (nop!) + (.add.mul.y.vf acc vf29 vf1 acc) + (nop!) + (.add.mul.z.vf vf6 vf30 vf1 acc) + (nop!) + (.sub.w.vf vf2 vf6 vf1 :mask #b111) + (nop!) + (.add.w.vf vf3 vf6 vf1 :mask #b111) + (nop!) + (.ftoi.vf vf4 vf2) + (nop!) + (.ftoi.vf vf5 vf3) + (nop!) + (.mov a2-5 vf4) + (let ((v1-25 (-> v1-24 process))) + (.mov a3-2 vf5) + (let ((a1-8 (-> obj proc))) + (.pcgtw a2-6 a2-5 s4-0) + (.pcgtw a3-3 s5-0 a3-2) + (.por a2-7 a2-6 a3-3) + (.ppach a2-8 zero a2-7) + (let ((a2-9 (shl (the-as int a2-8) 16))) + (nop!) + (b! (nonzero? a2-9) cfg-17 :delay (nop!)) + ) + (b! (= a1-8 v1-25) cfg-17 :delay (nop!)) + ) + ) + (add-fg-prim-using-line-sphere a0-10 obj) + ) + (label cfg-17) + 0 + (label cfg-18) + (set! v1-23 s2-1) + *collide-hit-by-player-list* + (set! s2-1 (-> s2-1 next0)) + ) + ) + ) + ) + (let ((v1-32 (the-as uint128 (make-u128 0 4)))) + (.pand v1-33 v1-32 s3-0) + ) + (when (nonzero? (the-as int v1-33)) + (let ((v1-36 (-> *collide-usually-hit-by-player-list* alive-list next0))) + *collide-usually-hit-by-player-list* + (let ((s2-2 (-> v1-36 next0))) + (while (!= v1-36 (-> *collide-usually-hit-by-player-list* alive-list-end)) + (let* ((v1-37 (the-as collide-shape (-> (the-as connection v1-36) param1))) + (a0-17 (-> v1-37 root-prim)) + ) + (let ((a1-10 (the-as uint128 (-> a0-17 prim-core collide-as)))) + (.pand a1-11 s3-0 a1-10) + ) + (b! (zero? (the-as int a1-11)) cfg-28) + (nop!) + (.mul.w.vf acc vf31 vf0) + (.lvf vf1 (&-> a0-17 prim-core world-sphere quad)) + (.add.mul.x.vf acc vf28 vf1 acc) + (nop!) + (.add.mul.y.vf acc vf29 vf1 acc) + (nop!) + (.add.mul.z.vf vf6 vf30 vf1 acc) + (nop!) + (.sub.w.vf vf2 vf6 vf1 :mask #b111) + (nop!) + (.add.w.vf vf3 vf6 vf1 :mask #b111) + (nop!) + (.ftoi.vf vf4 vf2) + (nop!) + (.ftoi.vf vf5 vf3) + (nop!) + (.mov a2-10 vf4) + (let ((v1-38 (the-as basic (-> v1-37 process)))) + (.mov a3-4 vf5) + (let ((a1-13 (-> obj proc))) + (.pcgtw a2-11 a2-10 s4-0) + (.pcgtw a3-5 s5-0 a3-4) + (.por a2-12 a2-11 a3-5) + (.ppach a2-13 zero a2-12) + (let ((a2-14 (shl (the-as int a2-13) 16))) + (nop!) + (b! (nonzero? a2-14) cfg-27 :delay (nop!)) + ) + (b! (= a1-13 (the-as process-drawable v1-38)) cfg-27 :delay (nop!)) + ) + ) + (add-fg-prim-using-line-sphere a0-17 obj) + ) + (label cfg-27) + 0 + (label cfg-28) + (set! v1-36 s2-2) + *collide-usually-hit-by-player-list* + (set! s2-2 (-> s2-2 next0)) + ) + ) + ) + ) + (let ((v1-45 (the-as uint128 (make-u128 0 8)))) + (.pand v1-46 v1-45 s3-0) + ) + (when (nonzero? (the-as int v1-46)) + (let ((v1-48 (-> *collide-hit-by-others-list* alive-list next0))) + *collide-hit-by-others-list* + (let ((s2-3 (-> v1-48 next0))) + (while (!= v1-48 (-> *collide-hit-by-others-list* alive-list-end)) + (let* ((v1-49 (the-as collide-shape (-> (the-as connection v1-48) param1))) + (a0-24 (-> v1-49 root-prim)) + ) + (let ((a1-15 (the-as uint128 (-> a0-24 prim-core collide-as)))) + (.pand a1-16 s3-0 a1-15) + ) + (b! (zero? (the-as int a1-16)) cfg-38) + (nop!) + (.mul.w.vf acc vf31 vf0) + (.lvf vf1 (&-> a0-24 prim-core world-sphere quad)) + (.add.mul.x.vf acc vf28 vf1 acc) + (nop!) + (.add.mul.y.vf acc vf29 vf1 acc) + (nop!) + (.add.mul.z.vf vf6 vf30 vf1 acc) + (nop!) + (.sub.w.vf vf2 vf6 vf1 :mask #b111) + (nop!) + (.add.w.vf vf3 vf6 vf1 :mask #b111) + (nop!) + (.ftoi.vf vf4 vf2) + (nop!) + (.ftoi.vf vf5 vf3) + (nop!) + (.mov a2-15 vf4) + (let ((v1-50 (-> v1-49 process))) + (.mov a3-6 vf5) + (let ((a1-18 (-> obj proc))) + (.pcgtw a2-16 a2-15 s4-0) + (.pcgtw a3-7 s5-0 a3-6) + (.por a2-17 a2-16 a3-7) + (.ppach a2-18 zero a2-17) + (let ((a2-19 (shl (the-as int a2-18) 16))) + (nop!) + (b! (nonzero? a2-19) cfg-37 :delay (nop!)) + ) + (b! (= a1-18 v1-50) cfg-37 :delay (nop!)) + ) + ) + (add-fg-prim-using-line-sphere a0-24 obj) + ) + (label cfg-37) + 0 + (label cfg-38) + (set! v1-48 s2-3) + *collide-hit-by-others-list* + (set! s2-3 (-> s2-3 next0)) + ) + ) + ) + ) + ) + ) + (none) + ) + ) + +(defmethod add-fg-prim-using-line-sphere collide-shape-prim ((obj collide-shape-prim) (arg0 collide-cache)) + (format + 0 + "ERROR: Illegal collide-shape-prim type passed to collide-shape-prim::add-fg-prim-using-line-sphere!~%" + ) + (none) + ) + +(defmethod add-fg-prim-using-line-sphere collide-shape-prim-sphere ((obj collide-shape-prim-sphere) (arg0 collide-cache)) + (local-vars (t1-1 uint)) + (nop!) + (let* ((t0-0 (-> arg0 prims)) + (a3-0 (-> arg0 num-prims-u)) + (t1-0 100) + (v1-0 (-> obj prim-core world-sphere quad)) + (t2-0 (* a3-0 2)) + (a2-0 (-> obj prim-core quad 1)) + ) + (b! (= a3-0 t1-0) cfg-2 :delay (set! t1-1 (+ t2-0 a3-0))) + (let ((t0-1 (the-as object (&-> t0-0 0 prim-core quad t1-1)))) + (let ((a3-1 (+ a3-0 1))) + (set! (-> (the-as collide-cache-prim t0-1) extra-quad) (the-as uint128 0)) + (nop!) + (set! (-> (the-as collide-cache-prim t0-1) prim) obj) + (nop!) + (set! (-> (the-as collide-cache-prim t0-1) prim-core world-sphere quad) v1-0) + (nop!) + (set! (-> (the-as collide-cache-prim t0-1) prim-core quad 1) a2-0) + (nop!) + (set! (-> arg0 num-prims) (the-as int a3-1)) + ) + (nop!) + (set! (-> (the-as collide-cache-prim t0-1) ccache) arg0) + ) + ) + (b! #t cfg-3 :delay (nop!)) + (label cfg-2) + (format 0 "ERROR: Exceeded max number of collide-cache prims!~%") + (label cfg-3) + (none) + ) + +(defmethod add-fg-prim-using-line-sphere collide-shape-prim-group ((obj collide-shape-prim-group) (arg0 collide-cache)) + (local-vars + (zero uint128) + (v1-3 uint128) + (v1-4 uint128) + (v1-5 uint128) + (v1-6 uint128) + (a0-1 collide-shape-prim) + (a1-1 uint128) + (a1-2 uint128) + ) + (rlet ((acc :class vf) + (vf0 :class vf) + (vf1 :class vf) + (vf10 :class vf) + (vf2 :class vf) + (vf28 :class vf) + (vf29 :class vf) + (vf3 :class vf) + (vf30 :class vf) + (vf31 :class vf) + (vf4 :class vf) + (vf5 :class vf) + ) + (init-vf0-vector) + (load-fffuls-work) + (set! zero (the-as uint128 0)) + (let ((v1-0 *collide-work*) + (s5-0 (-> obj prims)) + (s4-0 (-> obj num-prims-u)) + ) + (nop!) + (let ((s3-0 (-> v1-0 collide-box4w min quad))) + (nop!) + (let ((s2-0 (-> v1-0 collide-box4w max quad))) + (nop!) + (let ((s1-0 (-> s5-0 0))) + (nop!) + (let ((s0-0 (-> arg0 collide-with))) + (label cfg-1) + (b! (zero? s4-0) cfg-5 :delay (set! a0-1 s1-0)) + (label cfg-2) + (+! s4-0 -1) + (.lvf vf1 (&-> a0-1 prim-core world-sphere quad)) + (nop!) + (let ((v1-1 (-> a0-1 prim-core collide-as))) + (.mul.w.vf acc vf31 vf0) + (set! s5-0 (&-> s5-0 1)) + (.add.mul.x.vf acc vf28 vf1 acc) + (set! s1-0 (-> s5-0 0)) + (let ((v1-2 (logand s0-0 v1-1))) + (.add.mul.y.vf acc vf29 vf1 acc) + (b! (zero? v1-2) cfg-1 :delay (.add.mul.z.vf vf10 vf30 vf1 acc)) + ) + ) + ) + (.sub.w.vf vf2 vf10 vf1 :mask #b111) + (nop!) + (.add.w.vf vf3 vf10 vf1 :mask #b111) + (nop!) + (.ftoi.vf vf4 vf2) + (nop!) + (.ftoi.vf vf5 vf3) + (nop!) + (.mov a1-1 vf4) + (nop!) + (.mov v1-3 vf5) + (nop!) + (.pcgtw a1-2 a1-1 s2-0) + (.pcgtw v1-4 s3-0 v1-3) + (.por v1-5 a1-2 v1-4) + (.ppach v1-6 zero v1-5) + (let ((v1-7 (shl (the-as int v1-6) 16))) + (nop!) + (b! (nonzero? v1-7) cfg-1 :delay (nop!)) + ) + (add-fg-prim-using-line-sphere a0-1 arg0) + (b! (nonzero? s4-0) cfg-2 :delay (set! a0-1 s1-0)) + ) + ) + ) + ) + (label cfg-5) + 0 + (none) + ) + ) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; PROBE ;; PROBE ;; PROBE ;; PROBE ;; PROBE ;; PROBE ;; PROBE ;; PROBE ;; PROBE ;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + + +(defmethod fill-and-probe-using-y-probe collide-cache ((obj collide-cache) + (arg0 vector) + (arg1 float) + (arg2 collide-kind) + (arg3 process) + (arg4 collide-tri-result) + (arg5 uint) + ) + (fill-using-y-probe obj arg0 arg1 arg2 (the-as process-drawable arg3) arg5) + (probe-using-y-probe obj arg0 arg1 arg2 arg4 arg5) + ) + +(defmethod probe-using-y-probe collide-cache ((obj collide-cache) (arg0 vector) (arg1 float) (arg2 collide-kind) (arg3 collide-tri-result) (arg4 uint)) + (rlet ((vf0 :class vf) + (vf1 :class vf) + (vf3 :class vf) + ) + (init-vf0-vector) + (let ((gp-0 (new 'stack-no-clear 'collide-puyp-work))) + (.mov vf3 arg1) + (.lvf vf1 (&-> arg0 quad)) + (set! (-> gp-0 best-u) 2.0) + (set! (-> gp-0 ignore-pat) (the-as pat-surface arg4)) + (set! (-> gp-0 tri-out) arg3) + (.sub.x.vf vf3 vf0 vf3 :mask #b10) + (.svf (&-> gp-0 start-pos quad) vf1) + (.mov.vf vf3 vf0 :mask #b1101) + (.svf (&-> gp-0 move-dist quad) vf3) + (let ((s2-0 (the-as object (-> obj prims)))) + (countdown (s1-0 (-> obj num-prims)) + (when (and (logtest? arg2 (-> (the-as collide-cache-prim s2-0) prim-core collide-as)) + (logtest? (-> (the-as collide-cache-prim s2-0) prim-core action) (collide-action solid)) + ) + (cond + ((>= (-> (the-as collide-cache-prim s2-0) prim-core prim-type) 0) + (puyp-mesh obj gp-0 (the-as collide-cache-prim s2-0)) + ) + (else + (if (zero? (logand (the-as pat-surface arg4) + (-> (the-as collide-shape-prim-sphere (-> (the-as collide-cache-prim s2-0) prim)) pat) + ) + ) + (puyp-sphere obj gp-0 (the-as collide-cache-prim s2-0)) + ) + ) + ) + ) + (set! s2-0 (-> (the-as (inline-array collide-cache-prim) s2-0) 1)) + ) + ) + (let ((f0-1 (-> gp-0 best-u))) + (if (< 1.0 f0-1) + (set! f0-1 -100000000.0) + ) + f0-1 + ) + ) + ) + ) + + +(defmethod puyp-sphere collide-cache ((obj collide-cache) (arg0 collide-puyp-work) (arg1 collide-cache-prim)) + (let ((f0-1 (ray-sphere-intersect + (-> arg0 start-pos) + (-> arg0 move-dist) + (the-as vector (-> arg1 prim-core)) + (-> arg1 prim-core world-sphere w) + ) + ) + ) + (when (and (>= f0-1 0.0) (< f0-1 (-> arg0 best-u))) + (set! (-> arg0 best-u) f0-1) + (let ((gp-0 (-> arg0 tri-out))) + (set! (-> gp-0 pat) (-> (the-as collide-shape-prim-sphere (-> arg1 prim)) pat)) + (vector+*! (-> gp-0 intersect) (-> arg0 start-pos) (-> arg0 move-dist) f0-1) + (vector-! (-> gp-0 normal) (-> gp-0 intersect) (the-as vector (-> arg1 prim-core))) + (vector-normalize! (-> gp-0 normal) 1.0) + (set! (-> gp-0 vertex 0 quad) (-> gp-0 intersect quad)) + (point-in-plane-<-point+normal! (-> gp-0 vertex 1) (-> gp-0 intersect) (-> gp-0 normal)) + (let* ((a0-11 (vector-normalize! + (vector-! (new 'stack-no-clear 'vector) (-> gp-0 vertex 1) (the-as vector (-> gp-0 vertex))) + 1.0 + ) + ) + (a2-5 (vector-cross! (new 'stack-no-clear 'vector) (-> gp-0 normal) a0-11)) + ) + (vector+*! (-> gp-0 vertex 2) (-> gp-0 intersect) a2-5 4096.0) + ) + ) + ) + ) + ) + +(defmethod fill-and-probe-using-line-sphere collide-cache ((obj collide-cache) + (arg0 vector) + (arg1 vector) + (arg2 float) + (arg3 collide-kind) + (arg4 process) + (arg5 collide-tri-result) + (arg6 int) + ) + (fill-using-line-sphere obj arg0 arg1 arg2 arg3 (the-as process-drawable arg4) arg6) + (probe-using-line-sphere obj arg0 arg1 arg2 arg3 arg5 arg6) + ) + +(deftype collide-puls-work (structure) + ((ignore-pat uint32 :offset-assert 0) + (tri-out collide-tri-result :offset-assert 4) + (bsphere sphere :inline :offset-assert 16) + (move-dist vector :inline :offset-assert 32) + ) + :method-count-assert 9 + :size-assert #x30 + :flag-assert #x900000030 + ) + + +(defmethod probe-using-line-sphere collide-cache ((obj collide-cache) + (arg0 vector) + (arg1 vector) + (arg2 float) + (arg3 collide-kind) + (arg4 collide-tri-result) + (arg5 int) + ) + (rlet ((vf0 :class vf) + (vf2 :class vf) + (vf3 :class vf) + (vf4 :class vf) + ) + (init-vf0-vector) + (let ((s4-0 (new 'stack-no-clear 'collide-puls-work))) + (.mov vf4 arg2) + (.lvf vf3 (&-> arg0 quad)) + (.lvf vf2 (&-> arg1 quad)) + (set! (-> s4-0 ignore-pat) (the-as uint arg5)) + (.mul.x.vf vf3 vf0 vf4 :mask #b1000) + (set! (-> s4-0 tri-out) arg4) + (.svf (&-> s4-0 move-dist quad) vf2) + (.svf (&-> s4-0 bsphere quad) vf3) + (let ((s3-0 (the-as object (-> obj prims))) + (f30-0 -100000000.0) + ) + (countdown (s2-0 (-> obj num-prims)) + (when (and (logtest? arg3 (-> (the-as collide-cache-prim s3-0) prim-core collide-as)) + (logtest? (-> (the-as collide-cache-prim s3-0) prim-core action) (collide-action solid)) + ) + (cond + ((>= (-> (the-as collide-cache-prim s3-0) prim-core prim-type) 0) + (let ((f0-0 ((method-of-type collide-cache-prim resolve-moving-sphere-tri) + (the-as collide-cache-prim s3-0) + (-> s4-0 tri-out) + (the-as collide-prim-core (-> s4-0 bsphere)) + (-> s4-0 move-dist) + f30-0 + (collide-action solid) + ) + ) + ) + (if (>= f0-0 0.0) + (set! f30-0 f0-0) + ) + ) + ) + (else + (when (zero? (logand (the-as pat-surface arg5) + (-> (the-as collide-shape-prim-sphere (-> (the-as collide-cache-prim s3-0) prim)) pat) + ) + ) + (let ((f0-1 ((method-of-type collide-cache-prim resolve-moving-sphere-sphere) + (the-as collide-cache-prim s3-0) + (-> s4-0 tri-out) + (the-as collide-prim-core (-> s4-0 bsphere)) + (-> s4-0 move-dist) + f30-0 + (collide-action solid) + ) + ) + ) + (if (>= f0-1 0.0) + (set! f30-0 f0-1) + ) + ) + ) + ) + ) + ) + (set! s3-0 (-> (the-as (inline-array collide-cache-prim) s3-0) 1)) + ) + f30-0 + ) + ) + ) + ) + +(defmethod fill-and-probe-using-spheres collide-cache ((obj collide-cache) (arg0 collide-using-spheres-params)) + (fill-using-spheres obj arg0) + (probe-using-spheres obj arg0) + ) + +(defmethod fill-using-spheres collide-cache ((obj collide-cache) (arg0 collide-using-spheres-params)) + (let ((s4-0 (new 'stack-no-clear 'bounding-box))) + (set-from-spheres! s4-0 (-> arg0 spheres) (the-as int (-> arg0 num-spheres))) + ;; this box looks correct + (fill-using-bounding-box + obj + s4-0 + (-> arg0 collide-with) + (-> arg0 proc) + (the-as pat-surface (-> arg0 ignore-pat)) + ) + ) + (none) + ) + +(defmethod probe-using-spheres collide-cache ((obj collide-cache) (arg0 collide-using-spheres-params)) + (local-vars (v1-12 symbol)) + (rlet ((vf1 :class vf) + (vf2 :class vf) + (vf3 :class vf) + (vf4 :class vf) + (vf5 :class vf) + ) + (let ((s5-0 (scratchpad-object collide-puss-work)) + (a3-0 64) + (a2-0 (-> arg0 num-spheres)) + ) + (let ((v1-0 (-> s5-0 spheres)) + (a1-1 (-> arg0 spheres)) + ) + (let ((a3-1 (- a2-0 (the-as uint a3-0)))) + (nop!) + (b! (> (the-as int a3-1) 0) cfg-20 :delay (nop!)) + ) + (b! (zero? a2-0) cfg-5 :delay (.lvf vf1 a1-1)) + (let ((a2-1 (+ a2-0 -1)) + (a1-2 (&-> a1-1 4)) + ) + (.sub.w.vf vf2 vf1 vf1 :mask #b111) + (.svf (&-> v1-0 0 bsphere quad) vf1) + (.add.w.vf vf3 vf1 vf1 :mask #b111) + (let ((v1-1 (-> v1-0 1))) + (.ftoi.vf vf4 vf2) + (nop!) + (.ftoi.vf vf5 vf3) + (nop!) + (nop!) + (.svf (+ (the int v1-1) -32) vf4) + (nop!) + (.svf (+ (the int v1-1) -16) vf5) + (label cfg-3) + (b! (zero? a2-1) cfg-5 :delay (.lvf vf1 a1-2)) + (+! a2-1 -1) + (set! a1-2 (&-> a1-2 4)) + (.sub.w.vf vf4 vf1 vf1 :mask #b111) + (.svf (&-> v1-1 bsphere quad) vf1) + (.add.w.vf vf5 vf1 vf1 :mask #b111) + (nop!) + (.min.vf vf2 vf2 vf4 :mask #b111) + (nop!) + (.max.vf vf3 vf3 vf5 :mask #b111) + (nop!) + (.ftoi.vf vf4 vf4) + (nop!) + (.ftoi.vf vf5 vf5) + (nop!) + (nop!) + (.svf (&-> v1-1 bbox4w min quad) vf4) + (nop!) + (.svf (&-> v1-1 bbox4w max quad) vf5) + (b! #t cfg-3 :delay (set! v1-1 (&+ v1-1 48))) + ) + ) + ) + (label cfg-5) + (.ftoi.vf vf2 vf2) + (nop!) + (.ftoi.vf vf3 vf3) + (nop!) + (nop!) + (.svf (&-> s5-0 spheres-bbox4w min quad) vf2) + (nop!) + (.svf (&-> s5-0 spheres-bbox4w max quad) vf3) + (let ((s4-0 (the-as collide-cache-prim (-> obj prims))) + (s3-0 (-> arg0 collide-with)) + (s2-0 (-> obj num-prims)) + ) + (b! #t cfg-18 :delay (nop!)) + (label cfg-6) + (+! s2-0 -1) + (when (logtest? s3-0 (-> s4-0 prim-core collide-as)) + (when (or (not (-> arg0 solid-only)) (logtest? (-> s4-0 prim-core action) (collide-action solid))) + (if (>= (-> s4-0 prim-core prim-type) 0) + (set! v1-12 (dummy-9 s5-0 s4-0 arg0)) + (set! v1-12 (dummy-10 s5-0 s4-0 arg0)) + ) + (when v1-12 + ;; uncomment to view the point that blocks you from exiting duck. + ;;(add-debug-point #t (bucket-id debug-draw1) (-> s5-0 closest-pt)) + (return #t) + ) + ) + ) + (&+! s4-0 48) + (label cfg-18) + (b! (nonzero? s2-0) cfg-6 :delay (nop!)) + ) + (b! #t cfg-21 :delay (nop!)) + (label cfg-20) + (format 0 "ERROR: Exceeded max # of spheres in collide-cache::probe-using-spheres!~" a2-0) + ) + (label cfg-21) + #f + ) + ) + +;; todo a bunch of suffering. \ No newline at end of file diff --git a/goal_src/engine/collide/collide-edge-grab-h.gc b/goal_src/engine/collide/collide-edge-grab-h.gc index fd46297b0..e4b85de8e 100644 --- a/goal_src/engine/collide/collide-edge-grab-h.gc +++ b/goal_src/engine/collide/collide-edge-grab-h.gc @@ -83,7 +83,7 @@ :flag-assert #xb00000810 (:methods (debug-draw (_type_) object 9) - (dummy-10 () none 10) + (dummy-10 (_type_ collide-edge-hold-item) none 10) ) ) @@ -125,12 +125,12 @@ (debug-draw-edges (_type_) object 10) (dummy-11 (_type_) none 11) (debug-draw-sphere (_type_) symbol 12) - (dummy-13 (_type_) none 13) + (dummy-13 (_type_ collide-edge-hold-item vector) none 13) (dummy-14 (_type_ vector vector int) float 14) (dummy-15 (_type_) none 15) - (dummy-16 (_type_) none 16) + (find-grabbable-tris! (_type_) none 16) (dummy-17 (_type_) none 17) - (dummy-18 (_type_) none 18) + (dummy-18 (_type_ collide-edge-hold-list edge-grab-info) none 18) (dummy-19 (_type_ collide-edge-hold-item edge-grab-info) symbol 19) ) ) diff --git a/goal_src/engine/collide/collide-edge-grab.gc b/goal_src/engine/collide/collide-edge-grab.gc index cb9182655..32a2e7578 100644 --- a/goal_src/engine/collide/collide-edge-grab.gc +++ b/goal_src/engine/collide/collide-edge-grab.gc @@ -85,4 +85,10 @@ ) (set! (-> v1-2 touch-hook) nothing) (set! (-> v1-2 active-hook) nothing) + ) + + +(defmethod find-edge-grabs! target ((obj target) (arg0 collide-cache)) + (format *stdcon* "no edge grabs for you!~%") + (the object 0) ) \ No newline at end of file diff --git a/goal_src/engine/collide/collide-mesh.gc b/goal_src/engine/collide/collide-mesh.gc index 00bc9160d..fddab3e2d 100644 --- a/goal_src/engine/collide/collide-mesh.gc +++ b/goal_src/engine/collide/collide-mesh.gc @@ -105,4 +105,293 @@ :flag-assert #x900000030 ) -(defmethod-mips2c "(method 11 collide-mesh)" 11 collide-mesh) \ No newline at end of file +(defmethod-mips2c "(method 11 collide-mesh)" 11 collide-mesh) + +(defmethod-mips2c "(method 14 collide-mesh)" 11 collide-mesh) +(defmethod-mips2c "(method 15 collide-mesh)" 11 collide-mesh) + +(defmethod allocate! collide-mesh-cache ((obj collide-mesh-cache) (arg0 int)) + (local-vars (a1-2 int) (a2-2 int)) + (let* ((v1-0 (+ arg0 15)) + (a1-1 (-> obj used-size)) + (v1-1 (/ v1-0 16)) + (a3-0 (-> obj data)) + (a2-0 (-> obj max-size)) + (v1-2 (* v1-1 16)) + (a3-1 (&+ a3-0 a1-1)) + ) + (let ((t1-0 (- a2-0 (the-as uint v1-2))) + (t0-0 (-> obj id)) + ) + (b! (< (the-as int t1-0) 0) cfg-6 :delay (set! a1-2 (the-as int (+ a1-1 v1-2)))) + (b! (>= (the-as int (- a2-0 (the-as uint a1-2))) 0) cfg-5 :delay (set! a2-2 (the-as int (+ t0-0 1)))) + ) + (b! (zero? (the-as uint a2-2)) cfg-4 :likely-delay (set! a2-2 1)) + (label cfg-4) + (set! a1-2 v1-2) + (set! a3-1 (-> obj data)) + (set! (-> obj id) (the-as uint a2-2)) + (label cfg-5) + (set! (-> obj used-size) (the-as uint a1-2)) + (let ((v0-0 a3-1)) + (b! #t cfg-7 :delay (nop!)) + (label cfg-6) + (format 0 "ERROR: Attempted to allocate something bigger than the entire mesh cache!~%") + (set! v0-0 (the-as (pointer uint8) #f)) + (label cfg-7) + (the-as int v0-0) + ) + ) + ) + +(defmethod populate-cache! collide-mesh ((obj collide-mesh) (arg0 collide-mesh-cache-tri) (arg1 matrix)) + (local-vars (t0-2 uint)) + (rlet ((acc :class vf) + (Q :class vf) + (vf0 :class vf) + (vf1 :class vf) + (vf10 :class vf) + (vf11 :class vf) + (vf12 :class vf) + (vf2 :class vf) + (vf3 :class vf) + (vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + (vf7 :class vf) + (vf8 :class vf) + (vf9 :class vf) + ) + (init-vf0-vector) + (nop!) + (let ((t0-0 (scratchpad-object int)) + (v1-0 (-> obj num-verts)) + ) + (nop!) + (let ((a3-0 (-> obj vertex-data))) + (b! (zero? v1-0) cfg-3 :delay (.lvf vf1 (&-> arg1 vector 0 quad))) + (nop!) + (.lvf vf2 (&-> arg1 vector 1 quad)) + (let ((t0-1 (+ t0-0 -64))) + (.lvf vf3 (&-> arg1 vector 2 quad)) + (nop!) + (.lvf vf4 (&-> arg1 vector 3 quad)) + (nop!) + (.lvf vf5 (&-> a3-0 0 quad)) + (nop!) + (.lvf vf6 (&-> a3-0 1 quad)) + (nop!) + (.lvf vf7 (&-> a3-0 2 quad)) + (nop!) + (.lvf vf8 (&-> a3-0 3 quad)) + (label cfg-2) + (.mul.w.vf acc vf4 vf0) + (set! a3-0 (the-as (inline-array vector) (-> a3-0 4))) + (.add.mul.x.vf acc vf1 vf5 acc) + (+! t0-1 64) + (.add.mul.y.vf acc vf2 vf5 acc) + (nop!) + (.add.mul.z.vf vf9 vf3 vf5 acc) + (nop!) + (.mul.w.vf acc vf4 vf0) + (.lvf vf5 (&-> a3-0 0 quad)) + (.add.mul.x.vf acc vf1 vf6 acc) + (nop!) + (.add.mul.y.vf acc vf2 vf6 acc) + (nop!) + (.add.mul.z.vf vf10 vf3 vf6 acc) + (nop!) + (.mul.w.vf acc vf4 vf0) + (.lvf vf6 (&-> a3-0 1 quad)) + (.add.mul.x.vf acc vf1 vf7 acc) + (nop!) + (.add.mul.y.vf acc vf2 vf7 acc) + (nop!) + (.add.mul.z.vf vf11 vf3 vf7 acc) + (nop!) + (.mul.w.vf acc vf4 vf0) + (.lvf vf7 (&-> a3-0 2 quad)) + (.add.mul.x.vf acc vf1 vf8 acc) + (nop!) + (.add.mul.y.vf acc vf2 vf8 acc) + (nop!) + (.add.mul.z.vf vf12 vf3 vf8 acc) + (nop!) + (nop!) + (.lvf vf8 (&-> a3-0 3 quad)) + (+! v1-0 -4) + (.svf t0-1 vf9) + (nop!) + (.svf (+ t0-1 16) vf10) + (nop!) + (.svf (+ t0-1 32) vf11) + (b! (> (the-as int v1-0) 0) cfg-2 :delay (.svf (+ t0-1 48) vf12)) + ) + ) + ) + (label cfg-3) + (let ((v1-1 (the-as collide-mesh-tri (-> obj tris)))) + (nop!) + (let ((a2-1 (scratchpad-object int)) + (a0-1 (-> obj num-tris)) + ) + (b! (zero? a0-1) cfg-6 :delay (set! t0-2 (-> v1-1 vertex-index 0))) + (let* ((a1-1 (&+ arg0 -96)) + (a3-1 (-> v1-1 vertex-index 1)) + (t0-3 (* t0-2 16)) + (t2-0 (-> v1-1 vertex-index 2)) + (t1-0 (* a3-1 16)) + (a3-2 (-> v1-1 pat)) + ) + (let* ((t2-1 (* t2-0 16)) + (t0-4 (+ t0-3 a2-1)) + (t1-1 (+ t1-0 a2-1)) + (t2-2 (+ t2-1 a2-1)) + ) + (label cfg-5) + (+! a0-1 -1) + (.lvf vf1 t0-4) + (&+! v1-1 8) + (.lvf vf2 t1-1) + (&+! a1-1 96) + (.lvf vf3 t2-2) + (.sub.vf vf4 vf2 vf1) + (.svf (&-> a1-1 vertex 0 quad) vf1) + (.min.vf vf8 vf1 vf2) + (.svf (&-> a1-1 vertex 1 quad) vf2) + (.sub.vf vf5 vf3 vf1) + (.svf (&-> a1-1 vertex 2 quad) vf3) + (.max.vf vf9 vf1 vf2) + (let ((t1-2 (-> v1-1 vertex-index 0))) + (.outer.product.a.vf acc vf4 vf5) + (let ((t2-3 (-> v1-1 vertex-index 1))) + (.outer.product.b.vf vf6 vf5 vf4 acc) + (let ((t0-5 (-> v1-1 vertex-index 2))) + (.mul.vf vf7 vf6 vf6) + (nop!) + (.min.vf vf8 vf8 vf3) + (let ((t1-3 (* t1-2 16))) + (.max.vf vf9 vf9 vf3) + (let ((t2-4 (* t2-3 16))) + (.mul.x.vf acc vf0 vf7 :mask #b1000) + (let ((t3-0 (* t0-5 16))) + (.add.mul.y.vf acc vf0 vf7 acc :mask #b1000) + (set! t0-4 (+ t1-3 a2-1)) + (.add.mul.z.vf vf7 vf0 vf7 acc :mask #b1000) + (set! t1-1 (+ t2-4 a2-1)) + (.isqrt.vf Q vf0 vf7 :fsf #b11 :ftf #b11) + (set! t2-2 (+ t3-0 a2-1)) + ) + ) + ) + ) + ) + ) + ) + (.ftoi.vf vf8 vf8) + (nop!) + (.ftoi.vf vf9 vf9) + (nop!) + (nop!) + (.svf (&-> a1-1 bbox4w min quad) vf8) + (.wait.vf) + (.svf (&-> a1-1 bbox4w max quad) vf9) + (.mul.vf vf6 vf6 Q :mask #b111) + (nop!) + (nop!) + (.svf (&-> a1-1 normal quad) vf6) + (nop!) + (set! (-> a1-1 normal w) (the-as float a3-2)) + (b! (nonzero? a0-1) cfg-5 :delay (set! a3-2 (-> v1-1 pat))) + ) + ) + ) + (label cfg-6) + 0 + (none) + ) + ) + + +(defmethod overlap-test collide-mesh ((obj collide-mesh) (arg0 collide-mesh-cache-tri) (arg1 vector)) + (local-vars + (zero uint128) + (v1-0 uint128) + (a0-1 uint128) + (a1-2 uint128) + (a1-3 uint128) + (a1-4 uint128) + (a1-7 uint) + (a2-1 uint128) + (a2-2 uint128) + ) + (rlet ((acc :class vf) + (vf0 :class vf) + (vf1 :class vf) + (vf2 :class vf) + (vf3 :class vf) + (vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + ) + (init-vf0-vector) + (set! zero (the-as uint128 0)) + (let ((s5-0 (new 'stack-no-clear 'matrix)) + (s4-0 arg0) + ) + (.lvf vf2 (&-> arg1 quad)) + (let ((s3-0 (-> obj num-tris))) + (.sub.w.vf vf5 vf2 vf2) + (.add.w.vf vf6 vf2 vf2) + (.ftoi.vf vf5 vf5) + (.ftoi.vf vf6 vf6) + (.mov v1-0 vf5) + (.svf (&-> s5-0 vector 1 quad) vf5) + (.mov a0-1 vf6) + (.svf (&-> s5-0 vector 2 quad) vf6) + (label cfg-1) + (b! (zero? s3-0) cfg-7 :delay (set! a2-1 (-> s4-0 bbox4w min quad))) + (+! s3-0 -1) + ) + (let ((a1-1 (-> s4-0 bbox4w max quad))) + (.pcgtw a2-2 a2-1 a0-1) + (.pcgtw a1-2 v1-0 a1-1) + ) + (.por a1-3 a2-2 a1-2) + (nop!) + (.ppach a1-4 zero a1-3) + (let ((a1-5 (shl (the-as int a1-4) 16))) + (nop!) + (b! (nonzero? a1-5) cfg-1 :likely-delay (set! s4-0 (&+ s4-0 96))) + ) + (closest-pt-in-triangle + (the-as vector (-> s5-0 vector)) + arg1 + (the-as matrix (-> s4-0 vertex)) + (-> s4-0 normal) + ) + (.lvf vf1 (&-> s5-0 vector 0 quad)) + (.lvf vf2 (&-> arg1 quad)) + (set! v1-0 (-> s5-0 vector 1 quad)) + (set! a0-1 (-> s5-0 vector 2 quad)) + (.sub.vf vf3 vf2 vf1) + (.mul.w.vf vf4 vf2 vf2 :mask #b1000) + (.mul.vf vf3 vf3 vf3) + (.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) + (.add.w.vf vf3 vf0 vf3 :mask #b10) + (.mov a1-7 vf3) + (b! (>= (the-as int a1-7) 0) cfg-1 :delay (set! s4-0 (&+ s4-0 96))) + ) + (let ((v0-1 #t)) + (b! #t cfg-8 :delay (nop!)) + (the-as none 0) + (label cfg-7) + (set! v0-1 #f) + (label cfg-8) + v0-1 + ) + ) + ) \ No newline at end of file diff --git a/goal_src/engine/collide/collide-reaction-target.gc b/goal_src/engine/collide/collide-reaction-target.gc index 1d1167543..6af0d99e4 100644 --- a/goal_src/engine/collide/collide-reaction-target.gc +++ b/goal_src/engine/collide/collide-reaction-target.gc @@ -11,3 +11,389 @@ ;; TODO - for collide-reaction-racer (define-extern collide-shape-moving-angle-set! (function collide-shape-moving vector vector none)) ;; not confirmed + +(defun collide-shape-moving-angle-set! ((arg0 collide-shape-moving) (arg1 vector) (arg2 vector)) + (set! (-> arg0 surface-normal quad) (-> arg1 quad)) + (set! (-> arg0 surface-angle) (vector-dot arg1 (-> arg0 dynam gravity-normal))) + (set! (-> arg0 poly-angle) (vector-dot (-> arg0 poly-normal) (-> arg0 dynam gravity-normal))) + (set! (-> arg0 touch-angle) + (fmax + (-> arg0 touch-angle) + (vector-dot arg1 (vector-normalize! (vector-negate! (new-stack-vector0) arg2) 1.0)) + ) + ) + 0 + (none) + ) + +(defun target-collision-low-coverage ((arg0 control-info) + (arg1 collide-shape-intersect) + (arg2 vector) + (arg3 (pointer uint32)) + (arg4 (pointer uint64)) + (arg5 (pointer symbol)) + ) + (local-vars + (sv-16 vector) + (sv-20 (pointer uint32)) + (sv-24 (pointer uint64)) + (sv-28 (pointer symbol)) + (sv-32 uint) + (sv-40 uint) + (sv-48 symbol) + (sv-52 vector) + (sv-56 vector) + (sv-160 vector) + (sv-164 collide-tri-result) + (sv-208 vector) + (sv-212 vector) + (sv-272 vector) + (sv-276 vector) + ) + (set! sv-16 arg2) + (set! sv-20 arg3) + (set! sv-24 arg4) + (set! sv-28 arg5) + (set! sv-32 (-> arg3 0)) + (set! sv-40 (-> arg4 0)) + (set! sv-48 (-> arg5 0)) + (set! sv-52 (-> arg0 unknown-vector60)) + (set! sv-56 (vector-cross! (-> arg0 unknown-vector-coverage-2) (-> arg0 poly-normal) sv-16)) + (vector-normalize! sv-56 1.0) + (if (>= (fabs (vector-dot (-> arg0 dynam gravity-normal) sv-56)) 0.866) + (set! sv-32 (logior sv-32 512)) + ) + (vector-cross! sv-52 sv-16 sv-56) + (if (< 0.0 (vector-dot (-> arg0 dynam gravity-normal) sv-52)) + (vector-negate! sv-52 sv-52) + ) + (vector-normalize! sv-52 1.0) + (set! sv-160 (vector-flatten! (-> arg0 unknown-vector-coverage-3) sv-52 (-> arg0 dynam gravity-normal))) + (set! sv-164 (new 'stack 'collide-tri-result)) + (vector-normalize! sv-160 1.0) + (if (< (vector-dot sv-160 sv-16) 0.0) + (vector-negate! sv-160 sv-160) + ) + (set! (-> arg0 unknown-float-coverage-0) 4095996000.0) + (set! (-> arg0 unknown-float-coverage-2) 4095996000.0) + (set! sv-208 (vector+float*! (new 'stack-no-clear 'vector) (-> arg1 best-tri intersect) sv-160 2867.2)) + (set! sv-212 (vector-normalize-copy! (new 'stack-no-clear 'vector) (-> arg0 dynam gravity-normal) -20480.0)) + (vector+float*! sv-212 sv-212 sv-160 4096.0) + (when (>= (probe-using-line-sphere *collide-cache* sv-208 sv-212 409.6 (-> arg1 best-from-prim collide-with) sv-164 1) + 0.0 + ) + (set! (-> arg0 unknown-float-coverage-0) + (vector-dot + (-> arg0 dynam gravity-normal) + (vector-! (new 'stack-no-clear 'vector) (-> arg1 best-tri intersect) (-> sv-164 intersect)) + ) + ) + (set! (-> arg0 unknown-float-coverage-1) (the-as float (-> sv-164 pat))) + (set! (-> arg0 unknown-vector-coverage-0 quad) (-> sv-164 normal quad)) + 0 + ) + (set! sv-272 (vector+float*! + (new 'stack-no-clear 'vector) + (-> arg1 best-tri intersect) + (-> arg0 dynam gravity-normal) + 819.2 + ) + ) + (set! sv-276 (vector-normalize-copy! (new 'stack-no-clear 'vector) (-> arg0 dynam gravity-normal) -20480.0)) + (vector+float*! sv-272 sv-272 sv-160 -819.2) + (vector+float*! sv-276 sv-276 sv-160 -4096.0) + (when (>= (probe-using-line-sphere *collide-cache* sv-272 sv-276 409.6 (-> arg1 best-from-prim collide-with) sv-164 1) + 0.0 + ) + (set! (-> arg0 unknown-float-coverage-2) (vector-vector-distance sv-272 (-> sv-164 intersect))) + (set! (-> arg0 unknown-u32-coverage-0) (the-as uint (-> sv-164 pat))) + (set! (-> arg0 unknown-vector-coverage-1 quad) (-> sv-164 normal quad)) + 0 + ) + (when (and (zero? (logand sv-32 512)) + (and (or (< (* 1.25 (-> arg1 best-from-prim local-sphere w)) (-> arg0 unknown-float-coverage-0)) + (= (shr (shl (the-as int (-> arg0 unknown-float-coverage-1)) 58) 61) 1) + ) + (and (< (-> arg0 unknown-float-coverage-2) (* 2.0 (-> arg1 best-from-prim local-sphere w))) + (zero? (shr (shl (-> arg0 unknown-u32-coverage-0) 58) 61)) + ) + ) + ) + (set! sv-32 (logior sv-32 128)) + (set! (-> arg0 unknown-dword-coverage) (-> *display* base-frame-counter)) + (set! sv-40 (logior sv-40 128)) + (set! (-> arg0 unknown-dword21) (-> *display* base-frame-counter)) + (let ((f30-0 (vector-dot sv-52 (-> arg0 unknown-vector22))) + (f0-21 (if (logtest? sv-32 2) + (cos (- 16384.0 (acos (-> arg0 coverage)))) + (-> arg0 coverage) + ) + ) + (f1-11 (vector-dot + (-> arg0 dynam gravity-normal) + (vector-! (new 'stack-no-clear 'vector) (-> arg0 trans) (-> arg1 best-tri intersect)) + ) + ) + ) + (if (or (zero? (logand sv-32 32)) (< 0.5 f0-21)) + (set! sv-48 (the-as symbol #f)) + ) + (when (and (or (and (< f0-21 0.95) (>= f30-0 0.0)) + (and (logtest? sv-32 32) (< f0-21 0.3)) + (< f1-11 (* -0.25 (-> arg1 best-from-prim local-sphere w))) + ) + (>= (vector-dot sv-52 sv-16) -0.000001) + ) + (set! (-> arg0 surf) *edge-surface*) + (set! sv-32 (logior sv-32 1024)) + (set! sv-48 (the-as symbol #f)) + (when (logtest? sv-32 32) + (set! sv-48 #t) + (set! sv-32 (logior sv-32 4096)) + ) + ) + ) + ) + (if (< (-> arg0 surface-angle) 0.0) + (set! sv-48 #t) + ) + (when sv-48 + (cond + ((and (or (= (-> arg0 poly-pat mode) (pat-mode ground)) + (and (logtest? sv-32 8) + (>= (* 1.25 (-> arg1 best-from-prim local-sphere w)) (-> arg0 unknown-float-coverage-0)) + (zero? (shr (shl (the-as int (-> arg0 unknown-float-coverage-1)) 58) 61)) + (< 0.3 (fabs (-> arg0 surface-angle))) + ) + ) + (zero? (logand sv-32 128)) + ) + (set! sv-32 (logior sv-32 64)) + (set! sv-40 (logior sv-40 128)) + (set! (-> arg0 unknown-dword21) (-> *display* base-frame-counter)) + (set! sv-48 (the-as symbol #f)) + ) + (#t + (set! sv-32 (logior sv-32 64)) + (set! sv-40 (logior sv-40 128)) + (set! (-> arg0 unknown-dword21) (-> *display* base-frame-counter)) + ) + ) + ) + (set! (-> sv-24 0) sv-40) + (set! (-> sv-20 0) sv-32) + (set! (-> sv-28 0) sv-48) + (the-as uint 0) + ) + +(defun target-collision-reaction ((arg0 control-info) (arg1 collide-shape-intersect) (arg2 vector) (arg3 vector)) + (local-vars (sv-80 vector) (sv-84 vector) (sv-88 matrix) (sv-96 int) (sv-104 int) (sv-160 symbol)) + (set! sv-80 (new-stack-vector0)) + (set! sv-84 (new-stack-vector0)) + (let ((v1-2 (new 'stack-no-clear 'matrix))) + (dotimes (a0-1 2) + (set! (-> v1-2 vector a0-1 quad) (the-as uint128 0)) + ) + (set! sv-88 v1-2) + ) + (set! sv-96 0) + (set! sv-104 0) + (set! (-> sv-88 vector 0 quad) (-> arg3 quad)) + (set! (-> sv-88 vector 1 quad) (-> arg3 quad)) + (let ((a1-3 (new 'stack-no-clear 'vector))) + (vector-float*! a1-3 (-> arg1 move-vec) (-> arg1 best-u)) + (move-by-vector! arg0 a1-3) + ) + (set-and-handle-pat! arg0 (-> arg1 best-tri pat)) + (if (= (-> arg0 poly-pat mode) (pat-mode wall)) + (set! sv-104 (logior sv-104 1)) + ) + (if (logtest? (-> arg0 unknown-surface00 flags) 2048) + (set! sv-104 (logior sv-104 32)) + ) + (let ((v1-23 (new 'stack-no-clear 'vector))) + (set! (-> v1-23 quad) (-> arg1 best-from-prim prim-core world-sphere quad)) + (vector-! sv-80 v1-23 (-> arg1 best-tri intersect)) + ) + (vector-normalize! sv-80 1.0) + (set! (-> arg0 coverage) (vector-dot sv-80 (-> arg1 best-tri normal))) + (when (< (-> arg0 coverage) 0.0) + (set! (-> arg0 coverage) 0.0) + (vector-flatten! sv-80 sv-80 (-> arg1 best-tri normal)) + (vector-normalize! sv-80 1.0) + ) + (if (< (-> arg0 coverage) 0.9999) + (set! sv-104 (logior sv-104 24)) + ) + (let ((v1-33 (-> sv-80 quad))) + (set! (-> sv-84 quad) v1-33) + ) + (if (= (-> arg1 best-u) 0.0) + (move-by-vector! arg0 (vector-normalize-copy! (new-stack-vector0) sv-84 3.0)) + ) + (set! (-> arg0 poly-normal quad) (-> arg1 best-tri normal quad)) + (collide-shape-moving-angle-set! arg0 sv-84 (the-as vector (-> sv-88 vector))) + (if (< (-> arg0 poly-angle) -0.2) + (set! sv-96 (logior sv-96 16)) + ) + (if (< (-> arg0 poly-angle) 0.0) + (set! sv-96 (logior sv-96 #x4000)) + ) + (set! sv-160 (< (fabs (-> arg0 surface-angle)) (-> *pat-mode-info* (-> arg0 cur-pat mode) wall-angle))) + (if (and sv-160 (and (= (-> arg0 unknown-surface00 mode) 'dive) (< 0.2 (fabs (-> arg0 surface-angle))))) + (set! sv-160 (the-as symbol #f)) + ) + (if sv-160 + (set! sv-104 (logior sv-104 2)) + ) + (if (logtest? sv-104 8) + (target-collision-low-coverage + arg0 + arg1 + sv-84 + (the-as (pointer uint32) (& sv-104)) + (the-as (pointer uint64) (& sv-96)) + (& sv-160) + ) + ) + (when (zero? (logand (-> arg0 prev-status) 1)) + (set! (-> arg0 ground-impact-vel) (- (vector-dot (-> arg0 transv) (-> arg0 dynam gravity-normal)))) + (set! sv-96 (logior sv-96 2048)) + (when (not sv-160) + (let ((f30-0 (- 1.0 (-> arg0 surf impact-fric)))) + (when (< f30-0 1.0) + (let ((s3-1 (new-stack-vector0)) + (f28-0 (vector-dot (-> arg0 dynam gravity-normal) (the-as vector (-> sv-88 vector)))) + ) + 0.0 + (vector-! s3-1 (the-as vector (-> sv-88 vector)) (vector-float*! s3-1 (-> arg0 dynam gravity-normal) f28-0)) + (let* ((f0-20 (vector-length s3-1)) + (f1-9 f0-20) + ) + (if (< f28-0 0.0) + (set! f28-0 (* f28-0 f30-0)) + ) + (vector+! + (the-as vector (-> sv-88 vector)) + (vector-float*! (the-as vector (-> sv-88 vector)) (-> arg0 dynam gravity-normal) f28-0) + (vector-float*! s3-1 s3-1 (/ f0-20 f1-9)) + ) + ) + ) + ) + ) + ) + ) + (set! sv-96 (logior sv-96 4)) + (cond + ((-> arg1 best-to-prim) + (set! sv-96 (logior sv-96 32)) + (set! (-> arg0 unknown-vector72 quad) (-> arg1 best-tri intersect quad)) + (set! (-> arg0 unknown-vector73 quad) (-> arg0 poly-normal quad)) + (set! (-> arg0 unknown-handle00) (process->handle (-> arg1 best-to-prim cshape process))) + ) + ((= (-> arg0 poly-pat material) (pat-material waterbottom)) + ) + (else + (set! sv-96 (logior sv-96 4096)) + ) + ) + (cond + (sv-160 + (set! sv-104 (logior sv-104 4)) + (set! sv-96 (logior sv-96 8)) + (set! (-> arg0 cur-pat mode) 1) + (set! (-> arg0 unknown-vector70 quad) (-> arg1 best-tri intersect quad)) + (set! (-> arg0 unknown-vector71 quad) (-> arg0 poly-normal quad)) + (set! (-> arg0 unknown-vector121 quad) (-> sv-84 quad)) + (set! (-> arg0 unknown-int60) (the-as uint (-> arg1 best-tri pat))) + (-> arg0 history-data (logand (+ (-> arg0 unknown-halfword00) 127) 127)) + (cond + (#f + (sound-play-by-name (static-sound-name "cursor-options") (new-sound-id) 1024 0 0 1 #t) + (set! sv-104 (logior sv-104 8192)) + (vector-reflect-flat-above! arg2 (the-as vector (-> sv-88 vector)) sv-84) + ) + (else + (vector-reflect-flat! arg2 (the-as vector (-> sv-88 vector)) sv-84) + ) + ) + (cond + ((not + (and (>= (-> arg1 best-from-prim local-sphere w) + (vector-dot + (-> arg0 ground-poly-normal) + (vector-! (new 'stack-no-clear 'vector) (-> arg1 best-tri intersect) (-> arg0 ground-touch-point)) + ) + ) + (and (< 0.0 (vector-dot (-> arg0 ground-poly-normal) arg2)) + (< (- (-> *display* base-frame-counter) (-> arg0 unknown-dword10)) 90) + (zero? (logand sv-104 32)) + ) + ) + ) + ) + (else + (set! sv-104 (logior sv-104 256)) + (set! sv-104 (logand -65 sv-104)) + (let ((s3-4 (vector-cross! (new 'stack-no-clear 'vector) (-> arg0 poly-normal) (-> arg0 ground-poly-normal)))) + (vector-normalize! s3-4 1.0) + (vector-float*! arg2 s3-4 (vector-dot (the-as vector (-> sv-88 vector)) s3-4)) + ) + (vector+! arg2 arg2 (-> arg0 poly-normal)) + ) + ) + ) + (else + (set! sv-96 (logior sv-96 1)) + (set! (-> arg0 cur-pat mode) 0) + (if (= (-> arg1 best-from-prim prim-id) 6) + (set! (-> arg0 local-normal quad) (-> sv-84 quad)) + ) + (vector-reflect-flat! arg2 (the-as vector (-> sv-88 vector)) sv-84) + (vector+! arg2 arg2 sv-84) + (set! (-> arg0 ground-touch-point w) 0.0) + (when (not (or (logtest? sv-104 15) (nonzero? (-> arg0 poly-pat event)))) + (set! sv-96 (logior sv-96 2)) + (set! (-> arg0 ground-poly-normal quad) (-> arg0 poly-normal quad)) + (set! (-> arg0 unknown-vector53 quad) (-> sv-84 quad)) + (set! (-> arg0 unknown-float60) (vector-dot sv-84 (-> arg0 dynam gravity-normal))) + (set! (-> arg0 unknown-dword10) (-> *display* base-frame-counter)) + (set! (-> arg0 ground-pat) (-> arg0 poly-pat)) + (set! (-> arg0 ground-touch-point quad) (-> arg1 best-tri intersect quad)) + (set! (-> arg0 unknown-vector55 quad) (-> arg1 best-from-prim prim-core world-sphere quad)) + (set! sv-104 (logior sv-104 2048)) + (if (= (-> arg0 poly-pat material) (pat-material waterbottom)) + (set! sv-96 (logior sv-96 1024)) + ) + ) + ) + ) + (logior! (-> arg0 status) sv-96) + (set! (-> arg0 reaction-flag) (the-as uint sv-104)) + (update! + (-> arg0 history-data (-> arg0 unknown-halfword00)) + arg0 + (-> arg1 best-tri intersect) + (-> sv-88 vector 1) + arg2 + ) + (set! (-> arg0 unknown-halfword00) (logand (+ (-> arg0 unknown-halfword00) 1) 127)) + sv-96 + (none) + ) + +;; definition for function target-collision-no-reaction +;; INFO: Return type mismatch int vs none. +(defun target-collision-no-reaction ((arg0 control-info) (arg1 collide-shape-intersect) (arg2 vector) (arg3 vector)) + (if (= (-> arg0 unknown-surface00 mode) 'air) + (logior! (-> arg0 reaction-flag) 32) + ) + (let ((s5-0 (-> arg0 history-data (-> arg0 unknown-halfword00)))) + (update! s5-0 arg0 (-> arg0 trans) arg3 arg2) + (logior! (-> s5-0 status) 256) + ) + (set! (-> arg0 unknown-halfword00) (logand (+ (-> arg0 unknown-halfword00) 1) 127)) + 0 + (none) + ) \ No newline at end of file diff --git a/goal_src/engine/collide/collide-shape-h.gc b/goal_src/engine/collide/collide-shape-h.gc index 82bfeeeb6..6840e6eaf 100644 --- a/goal_src/engine/collide/collide-shape-h.gc +++ b/goal_src/engine/collide/collide-shape-h.gc @@ -9,8 +9,75 @@ ;; A collide shape is a group of collision geometry. Typically, each actor will have a single collide shape. ;; Each collide shape may contain a number of collide-shape-prim's. -;; There are many subclasses of collide-shape-prim for different types of collision primitives. -;; Some subclasses can contain multiple collide-shape-prims. +;; There are subclasses of collide-shape-prim for different types of collision primitives. +;; The types are: +;; - mesh. A foreground collision mesh. This has a fixed max size, so something have multiple meshes. +;; - group. A list of other prims. +;; - sphere. A sphere. + +;; The non-sphere classes also store a bsphere that must contain all collision geometry. + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +;; New vs. Old Collide System +;; There are, effectively, two systems for collision queries. + +;; Things that are shared: +;; Both systems use "collide-shape". +;; Both systems track foreground collision objects through the lists: +;; - collide-player-list +;; - collide-hit-by-player-list +;; - collide-usually-hit-by-player-list + +;; The "old" system: +;; - generally uses recursive traversals through the collide shape tree +;; - uses "collide-mesh-cache". +;; - can't collide with water or the background. + + +;; The "new" system: +;; - is the only way to collide with the background/water +;; - uses "collide-cache" +;; - generally dumps stuff into the collide-cache, then uses collide-cache functions (not decompiled yet) +;; - does not support a few of the weirder collision checks + +;; There is some duplicate implemenations because both the new and old system collide +;; foreground meshes. + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +;; Collision queries: + +;; Push Away. +;; Some objects move on fixed paths (like platforms). When these move forward, they should "push away" +;; things they hit (generally, Jak). Push Away only works between foreground objects and uses the old system. +;; The do-push-aways! function should be called after moving a shape to push away things that you hit. +;; Internally, this uses things called SPAT/should-push-away-test. +;; The push-aways use the collide resolve system (described below) to actually push things aways +;; (you can't push-away something through a wall, for example.) + +;; Collide Resolve. (made up name) +;; Some objects (like Jak) do not move on fixed paths, and will be stopped by walls or other obstacles. +;; This works on background and foreground objects, and uses the new system. +;; The fill-cache-integrate-and-collide! function should be called, which will fill the collide cache +;; and then do an iterative collision algorithm. +;; This will call the reaction function. The default "default-collision-reaction" function is in collide-shape.gc +;; will fill the touching list. + + +;; Nav Enemy Collision (made up name) +;; dummy-58 and integrate-for-enemy-with-move-to-ground are nav-enemy specific. +;; the details aren't super well understood yet. But they basically try to go forward if they aren't blocked. +;; Uses find-overlapping-shapes as the detector. (old system) + +;; Move To Ground. +;; move-to-ground. Does what it says. (new system) + +;; detect-riders +;; for platforms, detect if somebody is on the platform. (on-platform-test) +;; uses old system. Sends event adds to rider list. + (declare-type touching-list structure) (declare-type collide-shape-prim basic) @@ -242,6 +309,8 @@ (declare-type collide-shape basic) (declare-type collide-cache-prim structure) (declare-type collide-shape-prim-group basic) +(declare-type collide-cache basic) + ;; the base class for collision shapes. (deftype collide-shape-prim (basic) ((cshape collide-shape :offset-assert 4) ;; our parent collide-shape @@ -267,9 +336,9 @@ (move-by-vector! (_type_ vector) none 9) (find-prim-by-id (_type_ uint) collide-shape-prim 10) (debug-draw-world-sphere (_type_) symbol 11) - (add-fg-prim-using-box (_type_ process-drawable) none 12) - (add-fg-prim-using-line-sphere (_type_ process-drawable) none 13) - (add-fg-prim-using-y-probe (_type_ process-drawable) none 14) + (add-fg-prim-using-box (_type_ collide-cache) none 12) + (add-fg-prim-using-line-sphere (_type_ collide-cache) none 13) + (add-fg-prim-using-y-probe (_type_ collide-cache) none 14) (overlaps-others-test (_type_ overlaps-others-params collide-shape-prim) symbol 15) (overlaps-others-group (_type_ overlaps-others-params collide-shape-prim-group) symbol 16) (dummy-17 () none 17) @@ -392,10 +461,10 @@ (on-platform (_type_ collide-shape collide-overlap-result) symbol 39) (find-overlapping-shapes (_type_ overlaps-others-params) symbol 40) ;; check if blocked?? (dummy-41 (_type_ attack-info float) vector 41) - (compute-overlap (_type_ collide-shape collide-overlap-result) symbol 42) + (should-push-away (_type_ collide-shape collide-overlap-result) symbol 42) (pull-rider! (_type_ pull-rider-info) none 43) (pull-riders! (_type_) symbol 44) - (respond-to-collisions! (_type_) symbol 45) + (do-push-aways! (_type_) symbol 45) (set-root-prim! (_type_ collide-shape-prim) collide-shape-prim 46) (update-transforms! (_type_) symbol 47) (clear-collide-with-as (_type_) none 48) diff --git a/goal_src/engine/collide/collide-shape.gc b/goal_src/engine/collide/collide-shape.gc index 5b577ffb4..a3e968b15 100644 --- a/goal_src/engine/collide/collide-shape.gc +++ b/goal_src/engine/collide/collide-shape.gc @@ -8,18 +8,18 @@ ;; The collide shape system is used to handle collision reactions. ;;;;;;;;;;;;;;;;;;;;;;; -;; OVERLAP +;; Should Push Away ;;;;;;;;;;;;;;;;;;;;;;; -;; The overlap algorithm determines if two collide shapes are in contact. +;; The overlap algorithm determines if the new position of obj should push away arg0. + ;; If shapes are far away, it will abort early and just return #f. -;; overlap and "should push away" are the same thing. ;; both check collision flags and require "solid" flags. So this is only for solid collisions. ;; the collision isn't symmetric [collide(a, b) != collide(b, a)] because the with/as flags. ;; so there's some weirdness to get all the method dispatch stuff to work around (you can only dispatch on one type) -(defmethod compute-overlap collide-shape ((obj collide-shape) (arg0 collide-shape) (arg1 collide-overlap-result)) +(defmethod should-push-away collide-shape ((obj collide-shape) (arg0 collide-shape) (arg1 collide-overlap-result)) "Find the overlap between two collide shapes. This is the main entry point for the overlap algorithm. The result is returned in arg1. The obj is collided _with_ arg0 (meaning obj uses its collide-with, arg0 uses colide-as). The best-dist is only valid if the result is #t (it should be negative then)" @@ -1744,8 +1744,10 @@ ;; fill with the gox (fill-using-bounding-box *collide-cache* s5-0 arg1 (-> obj process) (-> obj pat-ignore-mask)) ;; only draw collide cache, if we're the target - (if (and *display-collide-cache* (= (-> obj process type) target)) + (when (and *display-collide-cache* (= (-> obj process type) target)) (debug-draw *collide-cache*) + ;; NOTE: added + (add-debug-box #t (bucket-id debug-draw0) (-> s5-0 min) (-> s5-0 max) (new 'static 'rgba :a #x80 :b #x70 :g #x70)) ) ) (else @@ -1861,7 +1863,6 @@ (vf31 :class vf) (vf4 :class vf) ) - (load-bounding-box-work) ;; this first loop looks for a non-empty group. (let ((s4-0 (-> obj num-prims)) @@ -2493,7 +2494,7 @@ #f ) -(defmethod respond-to-collisions! collide-shape ((obj collide-shape)) +(defmethod do-push-aways! collide-shape ((obj collide-shape)) "This is the main function to call to respond" (local-vars (at-0 int) @@ -2541,12 +2542,12 @@ (when (!= (-> obj process) (-> s3-0 process)) ;; self check ;; see if we collide! (let ((s2-0 (new 'stack-no-clear 'collide-overlap-result))) - (when (and (compute-overlap obj s3-0 s2-0) (>= -81.92 (-> s2-0 best-dist))) ;; we collide! + (when (and (should-push-away obj s3-0 s2-0) (>= -81.92 (-> s2-0 best-dist))) ;; we collide! ;; fill the collide cache. (fill-cache-for-shape! s3-0 8192.0 (-> s3-0 root-prim collide-with)) ;; 3 iterations to solve it. (let ((s5-1 3)) - (until (or (<= s5-1 0) (not (compute-overlap obj s3-0 s2-0))) ;; run until we're out. + (until (or (<= s5-1 0) (not (should-push-away obj s3-0 s2-0))) ;; run until we're out. (let ((s1-0 (new 'stack-no-clear 'vector))) (let ((v1-19 (new 'stack-no-clear 'vector))) (set! (-> v1-19 quad) (-> s3-0 trans quad)) @@ -2627,10 +2628,10 @@ (when (logtest? s5-0 (-> s3-1 root-prim prim-core collide-as)) (when (!= (-> obj process) (-> s3-1 process)) (let ((s2-1 (new 'stack-no-clear 'collide-overlap-result))) - (when (and (compute-overlap obj s3-1 s2-1) (>= -81.92 (-> s2-1 best-dist))) + (when (and (should-push-away obj s3-1 s2-1) (>= -81.92 (-> s2-1 best-dist))) (fill-cache-for-shape! s3-1 8192.0 (-> s3-1 root-prim collide-with)) (let ((s5-2 3)) - (until (or (<= s5-2 0) (not (compute-overlap obj s3-1 s2-1))) + (until (or (<= s5-2 0) (not (should-push-away obj s3-1 s2-1))) (let ((s1-1 (new 'stack-no-clear 'vector))) (let ((v1-52 (new 'stack-no-clear 'vector))) (set! (-> v1-52 quad) (-> s3-1 trans quad)) @@ -2704,10 +2705,10 @@ (when (logtest? s5-0 (-> s3-2 root-prim prim-core collide-as)) (when (!= (-> obj process) (-> s3-2 process)) (let ((s2-2 (new 'stack-no-clear 'collide-overlap-result))) - (when (and (compute-overlap obj s3-2 s2-2) (>= -81.92 (-> s2-2 best-dist))) + (when (and (should-push-away obj s3-2 s2-2) (>= -81.92 (-> s2-2 best-dist))) (fill-cache-for-shape! s3-2 8192.0 (-> s3-2 root-prim collide-with)) (let ((s5-3 3)) - (until (or (<= s5-3 0) (not (compute-overlap obj s3-2 s2-2))) + (until (or (<= s5-3 0) (not (should-push-away obj s3-2 s2-2))) (let ((s1-2 (new 'stack-no-clear 'vector))) (let ((v1-84 (new 'stack-no-clear 'vector))) (set! (-> v1-84 quad) (-> s3-2 trans quad)) @@ -2779,10 +2780,10 @@ (when (logtest? s5-0 (-> s3-3 root-prim prim-core collide-as)) (when (!= (-> obj process) (-> s3-3 process)) (let ((s2-3 (new 'stack-no-clear 'collide-overlap-result))) - (when (and (compute-overlap obj s3-3 s2-3) (>= -81.92 (-> s2-3 best-dist))) + (when (and (should-push-away obj s3-3 s2-3) (>= -81.92 (-> s2-3 best-dist))) (fill-cache-for-shape! s3-3 8192.0 (-> s3-3 root-prim collide-with)) (let ((s5-4 3)) - (until (or (<= s5-4 0) (not (compute-overlap obj s3-3 s2-3))) + (until (or (<= s5-4 0) (not (should-push-away obj s3-3 s2-3))) (let ((s1-3 (new 'stack-no-clear 'vector))) (let ((v1-115 (new 'stack-no-clear 'vector))) (set! (-> v1-115 quad) (-> s3-3 trans quad)) diff --git a/goal_src/engine/collide/collide-target-h.gc b/goal_src/engine/collide/collide-target-h.gc index 2660cb667..e43568a52 100644 --- a/goal_src/engine/collide/collide-target-h.gc +++ b/goal_src/engine/collide/collide-target-h.gc @@ -90,6 +90,15 @@ (unknown-float64 float :offset 1316) ;; from - logic-target::target-compute-slopes (unknown-dword20 int64 :offset 1320) ;; from target-util::turn-around? - TODO (unknown-dword21 int64 :offset 1328) ;; from target-util::turn-around? - TODO + (unknown-dword-coverage int64 :offset 1336) + (unknown-float-coverage-0 float :offset 1344) + (unknown-float-coverage-1 float :offset 1348) + (unknown-float-coverage-2 float :offset 1352) + (unknown-u32-coverage-0 uint32 :offset 1356) + (unknown-vector-coverage-0 vector :inline :offset 1376) + (unknown-vector-coverage-1 vector :inline :offset 1392) + (unknown-vector-coverage-2 vector :inline :offset 1440) + (unknown-vector-coverage-3 vector :inline :offset 1472) (unknown-vector60 vector :inline :offset 1456) ;; from - logic-target::add-thrust (unknown-vector61 vector :inline :offset 1504) ;; from - logic-target::add-thrust (unknown-float70 float :offset 1520) ;; from - logic-target::add-thrust @@ -175,6 +184,7 @@ (unknown-dword82 int64 :offset 18912) ;; from logic-target::reset-target-state (unknown-vector120 vector :inline :offset 18928) ;; from target::(code target-running-attack) (unknown-float150 float :offset 18944) ;; from target::(code target-wheel-flip) + (unknown-vector121 vector :inline :offset 18960) ;; from target collide response (unknown-int60 uint32 :offset 18976) ;; from logic-target::print-target-stats (unknown-soundid00 sound-id :offset 18980) ;; from powerups::target-powerup-process (unknown-float141 float :offset 18984) ;; from powerups::target-powerup-process diff --git a/goal_src/engine/collide/main-collide.gc b/goal_src/engine/collide/main-collide.gc index 542bcb808..24f28032d 100644 --- a/goal_src/engine/collide/main-collide.gc +++ b/goal_src/engine/collide/main-collide.gc @@ -66,13 +66,7 @@ instance-sphere-box-intersect? ((arg0 drawable) (arg1 instance-tie) (arg2 bounding-box4w)) (local-vars - (r0-0 uint128) - (r0-1 int) - (r0-2 uint128) - (r0-3 int) - (r0-4 int) - (r0-5 uint128) - (r0-6 int) + (zero uint128) (v1-3 uint128) (v1-4 uint128) (v1-5 uint128) @@ -109,19 +103,17 @@ (let ((a3-0 (the-as uint128 (-> arg1 origin vector4h 3 long)))) (nop!) (let ((t2-0 (the-as uint128 (-> arg1 origin vector4h 0 long)))) - (.pextlh a3-1 a3-0 r0-0) + (.pextlh a3-1 a3-0 zero) (let ((t0-0 (the-as uint128 (-> arg1 origin vector4h 1 long)))) (.pw.sra t1-0 a3-1 10) (let ((a3-2 (the-as uint128 (-> arg1 origin vector4h 2 long)))) - (.pextlh t2-1 t2-0 r0-0) - (.mov r0-1 f31-0) + (.pextlh t2-1 t2-0 zero) (.pw.sra t2-2 t2-1 16) - (.mov r0-2 f31-0) - (.pextlh t0-1 t0-0 r0-2) + (.pextlh t0-1 t0-0 zero) (.mov vf8 t1-0) (.pw.sra t0-2 t0-1 16) (.mov vf5 t2-2) - (.pextlh a3-3 a3-2 r0-2) + (.pextlh a3-3 a3-2 zero) ) ) ) @@ -172,14 +164,10 @@ (nop!) (.pcgtw a1-2 a2-1 a1-1) ) - (.mov r0-3 f31-0) (.pcgtw v1-3 v1-2 a0-2) ) - (.mov r0-4 f31-0) (.por v1-4 a1-2 v1-3) - (.mov r0-5 f31-0) - (.ppach v1-5 r0-5 v1-4) - (.mov r0-6 f31-0) + (.ppach v1-5 zero v1-4) (let ((v1-6 (shl (the-as int v1-5) 16))) (nop!) (zero? v1-6) diff --git a/goal_src/engine/draw/drawable.gc b/goal_src/engine/draw/drawable.gc index 8b443cceb..93c9dd616 100644 --- a/goal_src/engine/draw/drawable.gc +++ b/goal_src/engine/draw/drawable.gc @@ -297,20 +297,25 @@ ;; gmerc ;; shadow ;; eyes - (when (logtest? #x10000 *vu1-enable-user*) + (when (logtest? (vu1-renderer-mask sprite) *vu1-enable-user*) (swap-fake-shadow-buffers) (sprite-draw *display*) ) ;; lots more in this function. (when *debug-segment* (debug-draw-actors *level* *display-actor-marks*) - ;; collide-shape-debug + (collide-shape-draw-debug-marks) ) (render-boundaries) - ;; boundaries - ;; touching + (send-events-for-touching-shapes *touching-list*) + (free-all-prim-nodes *touching-list*) + (actors-update *level*) - ;; collide stats + (when (not (paused?)) + (if *stats-collide* + (print-collide-stats) + ) + ) (none) ) @@ -323,6 +328,17 @@ (define *draw-hook* main-draw-hook) +(defun-debug main-debug-hook () + (when (not (or (= *master-mode* 'menu) (= *master-mode* 'progress))) + (execute-connections *debug-engine* #f) + ;; (draw-instance-info *stdcon*) + ) + (none) + ) + +;; definition for symbol *debug-hook*, type (function none) +(define *debug-hook* main-debug-hook) + (defun debug-init-buffer ((arg0 bucket-id) (arg1 gs-zbuf) (arg2 gs-test)) "Initialize a bucket for debug draw with the given zbuf and test settings" (let* ((t0-0 (-> *display* frames (-> *display* on-screen) frame global-buf)) @@ -1139,6 +1155,16 @@ ) (defmethod collide-ray drawable ((obj drawable) (arg0 int) (arg1 collide-list)) + 0 + (none) + ) + +(defmethod collide-with-box drawable ((obj drawable) (arg0 int) (arg1 collide-list)) + 0 + (none) + ) + +(defmethod collide-y-probe drawable ((obj drawable) (arg0 int) (arg1 collide-list)) 0 (none) ) \ No newline at end of file diff --git a/goal_src/engine/draw/process-drawable.gc b/goal_src/engine/draw/process-drawable.gc index f6a52e23c..a50c2df6a 100644 --- a/goal_src/engine/draw/process-drawable.gc +++ b/goal_src/engine/draw/process-drawable.gc @@ -889,8 +889,23 @@ (logclear! (-> self draw status) (draw-status drwf02 drwf04)) (when (nonzero? (-> self skel)) ;(dummy-19 self) TODO + + (#when TARGET_STARTUP_HACKS + (when (eq? (-> self type) target) + (format *stdcon* "no bones for you~%") + (dotimes (i (length (-> self node-list))) + (matrix-identity! (-> self node-list data i bone transform)) + (set! (-> self node-list data i bone position quad) + (-> (the-as target self) control trans quad) + ) + (set! (-> self node-list data i bone position w) 1.0) + (+! (-> self node-list data i bone position y) (meters 0.0)) + ) + ) + ) + (when (or (logtest? (-> self skel status) 1) gp-1) - (dummy-17 self) + ;; (dummy-17 self) TODO (if (and gp-1 (type-type? (-> self root type) collide-shape)) (update-transforms! (the-as collide-shape (-> self root))) ) @@ -964,7 +979,7 @@ (let ((gp-0 (the-as collide-shape (-> self root)))) (update-transforms! gp-0) (pull-riders! gp-0) - (respond-to-collisions! gp-0) + (do-push-aways! gp-0) ) 0 ) @@ -973,7 +988,7 @@ (ja-post) (let ((gp-0 (the-as collide-shape (-> self root)))) (update-transforms! gp-0) - (respond-to-collisions! gp-0) + (do-push-aways! gp-0) ) 0 ) diff --git a/goal_src/engine/entity/entity.gc b/goal_src/engine/entity/entity.gc index 2de9ec7ec..d5ad72043 100644 --- a/goal_src/engine/entity/entity.gc +++ b/goal_src/engine/entity/entity.gc @@ -1253,6 +1253,21 @@ (define-extern collectable type) (define-extern ecovalve type) (define-extern crate type) + +(defmacro heap-size-hack (info entity-type) + `(cond + ((type-type? ,entity-type collectable) + #x1000 + ) + (else + (if ,info + (-> ,info heap-size) + #x4000 + ) + ) + ) + ) + (defmethod birth! entity-actor ((obj entity-actor)) "Create a process for this entity and start it." @@ -1272,10 +1287,7 @@ (let* ((entity-type (-> obj etype)) (info (entity-info-lookup entity-type)) - (entity-process (get-process *default-dead-pool* entity-type (if info - (-> info heap-size) - #x4000 - ) + (entity-process (get-process *default-dead-pool* entity-type (heap-size-hack info entity-type) ;; hack, modified this. ) ) ) diff --git a/goal_src/engine/game/collectables.gc b/goal_src/engine/game/collectables.gc index 0125300dd..7aead9815 100644 --- a/goal_src/engine/game/collectables.gc +++ b/goal_src/engine/game/collectables.gc @@ -131,7 +131,7 @@ (defmethod initialize eco-collectable ((obj eco-collectable)) - (stack-size-set! (-> obj main-thread) 128) + (stack-size-set! (-> obj main-thread) 256) ;; hack increased from 128 (logior! (-> obj mask) (process-mask actor-pause)) (set! (-> obj actor-pause) #t) (set! (-> obj notify-parent) #f) @@ -1273,7 +1273,7 @@ ) (defmethod initialize money ((obj money)) - (stack-size-set! (-> obj main-thread) 128) + (stack-size-set! (-> obj main-thread) 256) ;; hack increased from 128 (let ((s5-0 (new 'process 'collide-shape-moving obj (collide-list-enum hit-by-player)))) (set! (-> s5-0 dynam) (copy *standard-dynamics* 'process)) (set! (-> s5-0 reaction) default-collision-reaction) diff --git a/goal_src/engine/game/main-h.gc b/goal_src/engine/game/main-h.gc index 21c37ba4d..c36a19653 100644 --- a/goal_src/engine/game/main-h.gc +++ b/goal_src/engine/game/main-h.gc @@ -6,6 +6,7 @@ ;; dgos: GAME, ENGINE ;; Global engine settings: +(defglobalconstant TARGET_STARTUP_HACKS #t) (define *stats-poly* #f) (define *stats-memory* #f) (define *stats-memory-short* #f) diff --git a/goal_src/engine/game/main.gc b/goal_src/engine/game/main.gc index adf4c7146..65490d874 100644 --- a/goal_src/engine/game/main.gc +++ b/goal_src/engine/game/main.gc @@ -556,6 +556,7 @@ (add-ee-profile-frame 'draw :r #x80) (add-ee-profile-frame 'draw :r #x40 :b #x40) ;; debug hook + (*debug-hook*) (main-cheats) (add-ee-profile-frame 'draw :r #x20 :g #x20) (update-camera) diff --git a/goal_src/engine/game/projectiles.gc b/goal_src/engine/game/projectiles.gc index c7305e7d8..8385d2b6a 100644 --- a/goal_src/engine/game/projectiles.gc +++ b/goal_src/engine/game/projectiles.gc @@ -1129,22 +1129,24 @@ (spawn (-> obj part) (the-as vector (-> obj root-override root-prim prim-core))) ) ) - (let ((s5-0 (the-as sound-rpc-set-param (get-sound-buffer-entry)))) - (set! (-> s5-0 command) (sound-command set-param)) - (set! (-> s5-0 id) (-> obj sound-id)) - (let ((a1-3 (-> obj root-override trans))) - (let ((gp-1 pp)) - (when (= a1-3 #t) - (if (and gp-1 (type-type? (-> gp-1 type) process-drawable) (nonzero? (-> (the-as process-drawable gp-1) root))) - (set! a1-3 (-> (the-as process-drawable gp-1) root trans)) - (set! a1-3 (the-as vector #f)) - ) + (#when PC_DEBUG_SOUND_ENABLE + (let ((s5-0 (the-as sound-rpc-set-param (get-sound-buffer-entry)))) + (set! (-> s5-0 command) (sound-command set-param)) + (set! (-> s5-0 id) (-> obj sound-id)) + (let ((a1-3 (-> obj root-override trans))) + (let ((gp-1 pp)) + (when (= a1-3 #t) + (if (and gp-1 (type-type? (-> gp-1 type) process-drawable) (nonzero? (-> (the-as process-drawable gp-1) root))) + (set! a1-3 (-> (the-as process-drawable gp-1) root trans)) + (set! a1-3 (the-as vector #f)) + ) + ) ) + (sound-trans-convert (-> s5-0 parms trans) a1-3) ) - (sound-trans-convert (-> s5-0 parms trans) a1-3) + (set! (-> s5-0 parms mask) (the-as uint 32)) + (-> s5-0 id) ) - (set! (-> s5-0 parms mask) (the-as uint 32)) - (-> s5-0 id) ) 0 (none) diff --git a/goal_src/engine/game/settings.gc b/goal_src/engine/game/settings.gc index 01d054137..e11aff31a 100644 --- a/goal_src/engine/game/settings.gc +++ b/goal_src/engine/game/settings.gc @@ -450,8 +450,10 @@ ) ) (#when PC_PORT - (set! (-> gp-0 aspect-ratio) (-> *pc-settings* aspect-setting)) - ) + (when (nonzero? (-> *pc-settings* aspect-setting)) + (set! (-> gp-0 aspect-ratio) (-> *pc-settings* aspect-setting)) + ) + ) (if (zero? *boot-video-mode*) (set! (-> gp-0 video-mode) 'ntsc) (set! (-> gp-0 video-mode) 'pal) diff --git a/goal_src/engine/geometry/bounding-box.gc b/goal_src/engine/geometry/bounding-box.gc index 7ebe5b042..14ae9ddb9 100644 --- a/goal_src/engine/geometry/bounding-box.gc +++ b/goal_src/engine/geometry/bounding-box.gc @@ -172,7 +172,7 @@ 0 ) -(defmethod set-from-spheres! bounding-box ((obj bounding-box) (spheres (pointer sphere)) (count int)) +(defmethod set-from-spheres! bounding-box ((obj bounding-box) (spheres-bad (pointer sphere)) (count int)) "Reset box to hold the given spheres. Note: this implementation could be optimized." ;; This is also unrolled, but does 7 at a time. (rlet ((vf0 :class vf) @@ -186,13 +186,15 @@ ;; init min/max. in the case we don't have any spheres, we should return (0,0,0,1) for min/max. (set! current-min vf0) (set! current-max vf0) + + (let ((spheres (the (inline-array sphere) spheres-bad))) (dotimes (i count) (.lvf sph (-> spheres i)) (.sub.w.vf sph-min sph sph :mask #b111) (.add.w.vf sph-max sph sph :mask #b111) (cond - ((zero? count) + ((zero? i) (set! current-min sph-min) (set! current-max sph-max) ) @@ -202,6 +204,7 @@ ) ) ) + ) (.svf (-> obj min) current-min) (.svf (-> obj max) current-max) diff --git a/goal_src/engine/gfx/background.gc b/goal_src/engine/gfx/background.gc index f909e53af..a7bc49783 100644 --- a/goal_src/engine/gfx/background.gc +++ b/goal_src/engine/gfx/background.gc @@ -248,7 +248,7 @@ ;; update colors, but only if needed (when (not (or (zero? s0-0) (= s4-1 s0-0))) (flush-cache 0) - (time-of-day-interp-colors-scratch (scratchpad-ptr rgba :offset 6160) s0-0 (-> s1-0 mood)) + ;;(time-of-day-interp-colors-scratch (scratchpad-ptr rgba :offset 6160) s0-0 (-> s1-0 mood)) ;; remember the previous colors (set! s4-1 s0-0) ) @@ -277,7 +277,7 @@ (upload-vis-bits s1-1 gp-1 a2-6) (when (not (or (zero? s0-1) (= s4-1 s0-1))) (flush-cache 0) - (time-of-day-interp-colors-scratch (scratchpad-ptr rgba :offset 6160) s0-1 (-> s1-1 mood)) + ;;(time-of-day-interp-colors-scratch (scratchpad-ptr rgba :offset 6160) s0-1 (-> s1-1 mood)) (set! s4-1 s0-1) ) ) @@ -303,7 +303,7 @@ (upload-vis-bits s1-2 gp-1 a2-8) (when (not (or (zero? s0-2) (= s4-1 s0-2))) (flush-cache 0) - (time-of-day-interp-colors-scratch (scratchpad-ptr rgba :offset 6160) s0-2 (-> s1-2 mood)) + ;;(time-of-day-interp-colors-scratch (scratchpad-ptr rgba :offset 6160) s0-2 (-> s1-2 mood)) (set! s4-1 s0-2) ) ) @@ -331,7 +331,7 @@ (upload-vis-bits s1-3 gp-1 a2-10) (when (not (or (zero? s0-3) (= s4-1 s0-3))) (flush-cache 0) - (time-of-day-interp-colors-scratch (scratchpad-ptr rgba :offset 6160) s0-3 (-> s1-3 mood)) + ;;(time-of-day-interp-colors-scratch (scratchpad-ptr rgba :offset 6160) s0-3 (-> s1-3 mood)) (set! s4-1 s0-3) ) ) @@ -360,7 +360,7 @@ (upload-vis-bits s1-4 gp-1 a2-12) (when (not (or (zero? s0-4) (= s4-1 s0-4))) (flush-cache 0) - (time-of-day-interp-colors-scratch (scratchpad-ptr rgba :offset 6160) s0-4 (-> s1-4 mood)) + ;;(time-of-day-interp-colors-scratch (scratchpad-ptr rgba :offset 6160) s0-4 (-> s1-4 mood)) (set! s4-1 s0-4) ) ) @@ -382,7 +382,7 @@ (upload-vis-bits s1-5 gp-1 a2-14) (when (not (or (zero? s0-5) (= s4-1 s0-5))) (flush-cache 0) - (time-of-day-interp-colors-scratch (scratchpad-ptr rgba :offset 6160) s0-5 (-> s1-5 mood)) + ;;(time-of-day-interp-colors-scratch (scratchpad-ptr rgba :offset 6160) s0-5 (-> s1-5 mood)) (set! s4-1 s0-5) ) ) diff --git a/goal_src/engine/gfx/tfrag/tfrag-methods.gc b/goal_src/engine/gfx/tfrag/tfrag-methods.gc index ef14b60f6..ab0507589 100644 --- a/goal_src/engine/gfx/tfrag/tfrag-methods.gc +++ b/goal_src/engine/gfx/tfrag/tfrag-methods.gc @@ -113,7 +113,7 @@ ;; do the draw! (reset! (-> *perf-stats* data 5)) ;;(format 0 "DRAW: ~D~%" s3-0) - (draw-inline-array-tfrag sv-16 (the-as drawable-inline-array s4-1) s3-0 s1-0) + ;; (draw-inline-array-tfrag sv-16 (the-as drawable-inline-array s4-1) s3-0 s1-0) (read! (-> *perf-stats* data 5)) ;; update stats for the draw @@ -252,7 +252,7 @@ lev ) (reset! (-> *perf-stats* data 5)) - (draw-inline-array-tfrag sv-16 s5-1 s4-1 s2-0) + ;; (draw-inline-array-tfrag sv-16 s5-1 s4-1 s2-0) (update-wait-stats (-> *perf-stats* data 5) (the-as uint 0) (-> *tfrag-work* wait-to-spr) (-> *tfrag-work* wait-from-spr)) (read! (-> *perf-stats* data 5)) (tfrag-end-buffer s2-0) @@ -426,7 +426,7 @@ (tfrag-init-buffer s2-0 (new 'static 'gs-test :ate #x1 :afail #x1 :zte #x1 :ztst (gs-ztest greater-equal)) 1 lev) (reset! (-> *perf-stats* data 5)) - (draw-inline-array-tfrag sv-16 s5-1 s4-1 s2-0) + ;; (draw-inline-array-tfrag sv-16 s5-1 s4-1 s2-0) (update-wait-stats (-> *perf-stats* data 5) (the-as uint 0) @@ -596,7 +596,7 @@ lev ) (reset! (-> *perf-stats* data 5)) - (draw-inline-array-tfrag sv-16 s5-1 s4-1 s2-0) + ;; (draw-inline-array-tfrag sv-16 s5-1 s4-1 s2-0) (update-wait-stats (-> *perf-stats* data 5) (the-as uint 0) diff --git a/goal_src/engine/math/math.gc b/goal_src/engine/math/math.gc index 34b8584c1..06aac7d0c 100644 --- a/goal_src/engine/math/math.gc +++ b/goal_src/engine/math/math.gc @@ -7,22 +7,8 @@ ;; contains various math helpers -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;;; float macros -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -(defmacro fabs (x) - "Floating point absolute value" - ;; in GOAL this was implemented by the compiler. - ;; at some point, this could be more optimized. - ;; MIPS has an explicit abs.s instruction, but x86-64 doesn't. - ;; modern clang on O3 does a comiss/branch and this is probably pretty close. - `(if (< (the float ,x) 0) - (- (the float ,x)) - (the float ,x)) - ) - ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;; float utility diff --git a/goal_src/engine/math/vector.gc b/goal_src/engine/math/vector.gc index 5be373f56..474ab0c8b 100644 --- a/goal_src/engine/math/vector.gc +++ b/goal_src/engine/math/vector.gc @@ -751,66 +751,83 @@ (defun vector-normalize! ((arg0 vector) (arg1 float)) "Modify arg0 in place to have length arg1 for its xyz components. The w part is not changed." - (rlet ((acc :class vf) - (Q :class vf) - (vf0 :class vf) - (vf1 :class vf) - (vf2 :class vf) - (vf3 :class vf) - ) - (init-vf0-vector) - (.lvf vf1 (&-> arg0 quad)) - (.mul.vf vf2 vf1 vf1 :mask #b111) - (let ((v1-0 arg1)) - (.mov vf3 v1-0) + (let ((f0-0 (vector-length arg0))) + (let ((v1-1 (/ arg1 f0-0))) + (set! (-> arg0 data 0) (* (-> arg0 data 0) v1-1)) + (set! (-> arg0 data 1) (* (-> arg0 data 1) v1-1)) + (set! (-> arg0 data 2) (* (-> arg0 data 2) v1-1)) + ) ) - (.mul.x.vf acc vf0 vf2 :mask #b1000) - (.add.mul.y.vf acc vf0 vf2 acc :mask #b1000) - (.add.mul.z.vf vf2 vf0 vf2 acc :mask #b1000) - (.isqrt.vf Q vf3 vf2 :fsf #b0 :ftf #b11) - (.wait.vf) - (.mul.vf vf1 vf1 Q :mask #b111) - (.nop.vf) - (.nop.vf) - (.nop.vf) - (.svf (&-> arg0 quad) vf1) - arg0 - ) + arg0 + ; (rlet ((acc :class vf) + ; (Q :class vf) + ; (vf0 :class vf) + ; (vf1 :class vf) + ; (vf2 :class vf) + ; (vf3 :class vf) + ; ) + ; (init-vf0-vector) + ; (.lvf vf1 (&-> arg0 quad)) + ; (.mul.vf vf2 vf1 vf1 :mask #b111) + ; (let ((v1-0 arg1)) + ; (.mov vf3 v1-0) + ; ) + ; (.mul.x.vf acc vf0 vf2 :mask #b1000) + ; (.add.mul.y.vf acc vf0 vf2 acc :mask #b1000) + ; (.add.mul.z.vf vf2 vf0 vf2 acc :mask #b1000) + ; (.isqrt.vf Q vf3 vf2 :fsf #b0 :ftf #b11) + ; (.wait.vf) + ; (.mul.vf vf1 vf1 Q :mask #b111) + ; (.nop.vf) + ; (.nop.vf) + ; (.nop.vf) + ; (.svf (&-> arg0 quad) vf1) + ; arg0 + ; ) ) (defun vector-normalize-ret-len! ((arg0 vector) (arg1 float)) "Modify arg0 in place to have length arg1 for its xyz components. The w part isn't changed and the _original_ length is returned." - (local-vars (v1-1 float)) - (rlet ((acc :class vf) - (Q :class vf) - (vf0 :class vf) - (vf1 :class vf) - (vf2 :class vf) - (vf3 :class vf) - ) - (init-vf0-vector) - (.lvf vf1 (&-> arg0 quad)) - (.mul.vf vf2 vf1 vf1 :mask #b111) - (let ((v1-0 arg1)) - (.mov vf3 v1-0) + (let ((f0-0 (vector-length arg0))) + (let ((v1-1 (/ arg1 f0-0))) + (set! (-> arg0 data 0) (* (-> arg0 data 0) v1-1)) + (set! (-> arg0 data 1) (* (-> arg0 data 1) v1-1)) + (set! (-> arg0 data 2) (* (-> arg0 data 2) v1-1)) + ) + f0-0 ) - (.mul.x.vf acc vf0 vf2 :mask #b1000) - (.add.mul.y.vf acc vf0 vf2 acc :mask #b1000) - (.add.mul.z.vf vf2 vf0 vf2 acc :mask #b1000) - (.isqrt.vf Q vf3 vf2 :fsf #b0 :ftf #b11) - (.add.w.vf vf2 vf0 vf2 :mask #b1) - (.mov v1-1 vf2) - (let ((v0-0 (sqrtf v1-1))) - (.wait.vf) - (.mul.vf vf1 vf1 Q :mask #b111) - (.nop.vf) - (.nop.vf) - (.nop.vf) - (.svf (&-> arg0 quad) vf1) - v0-0 - ) - ) + + ; (local-vars (v1-1 float)) + ; (rlet ((acc :class vf) + ; (Q :class vf) + ; (vf0 :class vf) + ; (vf1 :class vf) + ; (vf2 :class vf) + ; (vf3 :class vf) + ; ) + ; (init-vf0-vector) + ; (.lvf vf1 (&-> arg0 quad)) + ; (.mul.vf vf2 vf1 vf1 :mask #b111) + ; (let ((v1-0 arg1)) + ; (.mov vf3 v1-0) + ; ) + ; (.mul.x.vf acc vf0 vf2 :mask #b1000) + ; (.add.mul.y.vf acc vf0 vf2 acc :mask #b1000) + ; (.add.mul.z.vf vf2 vf0 vf2 acc :mask #b1000) + ; (.isqrt.vf Q vf3 vf2 :fsf #b0 :ftf #b11) + ; (.add.w.vf vf2 vf0 vf2 :mask #b1) + ; (.mov v1-1 vf2) + ; (let ((v0-0 (sqrtf v1-1))) + ; (.wait.vf) + ; (.mul.vf vf1 vf1 Q :mask #b111) + ; (.nop.vf) + ; (.nop.vf) + ; (.nop.vf) + ; (.svf (&-> arg0 quad) vf1) + ; v0-0 + ; ) + ; ) ) (defun vector-normalize-copy! ((arg0 vector) (arg1 vector) (arg2 float)) diff --git a/goal_src/engine/target/logic-target.gc b/goal_src/engine/target/logic-target.gc index bbb110186..dce201c54 100644 --- a/goal_src/engine/target/logic-target.gc +++ b/goal_src/engine/target/logic-target.gc @@ -1938,7 +1938,7 @@ (set! arg0 (get-or-create-continue! *game-info*)) ) (set-continue! *game-info* arg0) - (stack-size-set! (-> self main-thread) 1024) + (stack-size-set! (-> self main-thread) 4096) ;; changed for PC (logior! (-> self mask) (process-mask target)) (set! (-> self state-hook) (the-as (function none :behavior target) nothing)) (let ((s5-0 (new 'process 'control-info self (collide-list-enum player)))) @@ -2079,8 +2079,8 @@ ;; hack for not starting target. (defun start ((arg0 symbol) (arg1 continue-point)) - (set! *target* #f) - (return *target*) + ; (set! *target* #f) + ; (return *target*) (set! (-> *level* border?) #f) (set! (-> *setting-control* default border-mode) #f) @@ -2100,6 +2100,8 @@ (set! *target* #f) ) ) + ;; hack added. + (set! *display-target-marks* #t) *target* ) diff --git a/goal_src/engine/target/sidekick.gc b/goal_src/engine/target/sidekick.gc index d049af289..485a6d81a 100644 --- a/goal_src/engine/target/sidekick.gc +++ b/goal_src/engine/target/sidekick.gc @@ -277,17 +277,21 @@ ) ) ) - (let ((a0-26 (-> self skel effect))) - (if a0-26 - (TODO-RENAME-9 a0-26) - ) - ) - (if (logtest? (-> self skel status) 72) - (merc-blend-shape self) - ) - (if (logtest? (-> self skel status) 384) - (merc-eye-anim self) - ) + + (#unless TARGET_STARTUP_HACKS + (let ((a0-26 (-> self skel effect))) + (if a0-26 + (TODO-RENAME-9 a0-26) + ) + ) + (if (logtest? (-> self skel status) 72) + (merc-blend-shape self) + ) + (if (logtest? (-> self skel status) 384) + (merc-eye-anim self) + ) + ) + (none) ) ) diff --git a/goal_src/engine/target/target-handler.gc b/goal_src/engine/target/target-handler.gc index 9df85949f..7c050cafc 100644 --- a/goal_src/engine/target/target-handler.gc +++ b/goal_src/engine/target/target-handler.gc @@ -5,3 +5,1130 @@ ;; name in dgo: target-handler ;; dgos: GAME, ENGINE +(define-extern target-powerup-effect (function symbol none :behavior target)) + +;; definition for function target-generic-event-handler +;; INFO: Return type mismatch none vs object. +;; WARN: rewrite_to_get_var got a none typed variable. Is there unreachable code? [OP: 37] +;; WARN: rewrite_to_get_var got a none typed variable. Is there unreachable code? [OP: 39] +;; WARN: rewrite_to_get_var got a none typed variable. Is there unreachable code? [OP: 60] +;; WARN: rewrite_to_get_var got a none typed variable. Is there unreachable code? [OP: 69] +;; WARN: rewrite_to_get_var got a none typed variable. Is there unreachable code? [OP: 73] +;; WARN: rewrite_to_get_var got a none typed variable. Is there unreachable code? [OP: 151] +;; WARN: rewrite_to_get_var got a none typed variable. Is there unreachable code? [OP: 168] +;; WARN: rewrite_to_get_var got a none typed variable. Is there unreachable code? [OP: 185] +;; WARN: rewrite_to_get_var got a none typed variable. Is there unreachable code? [OP: 196] +;; WARN: rewrite_to_get_var got a none typed variable. Is there unreachable code? [OP: 201] +;; WARN: rewrite_to_get_var got a none typed variable. Is there unreachable code? [OP: 222] +;; WARN: rewrite_to_get_var got a none typed variable. Is there unreachable code? [OP: 292] +;; WARN: rewrite_to_get_var got a none typed variable. Is there unreachable code? [OP: 351] +;; WARN: rewrite_to_get_var got a none typed variable. Is there unreachable code? [OP: 366] +;; WARN: rewrite_to_get_var got a none typed variable. Is there unreachable code? [OP: 408] +;; WARN: rewrite_to_get_var got a none typed variable. Is there unreachable code? [OP: 420] +;; WARN: rewrite_to_get_var got a none typed variable. Is there unreachable code? [OP: 427] +;; WARN: rewrite_to_get_var got a none typed variable. Is there unreachable code? [OP: 451] +;; WARN: rewrite_to_get_var got a none typed variable. Is there unreachable code? [OP: 465] +;; WARN: rewrite_to_get_var got a none typed variable. Is there unreachable code? [OP: 472] +;; WARN: rewrite_to_get_var got a none typed variable. Is there unreachable code? [OP: 482] +;; WARN: rewrite_to_get_var got a none typed variable. Is there unreachable code? [OP: 524] +;; WARN: rewrite_to_get_var got a none typed variable. Is there unreachable code? [OP: 552] +;; WARN: rewrite_to_get_var got a none typed variable. Is there unreachable code? [OP: 563] +;; Used lq/sq +(defbehavior target-generic-event-handler target ((arg0 process) (arg1 int) (arg2 symbol) (arg3 event-message-block)) + (local-vars (v0-0 object)) + (let ((v1-0 arg2)) + ;;(format 0 "target-generic-event-handler: ~A~%" v1-0) + (the-as + object + (cond + ((= v1-0 'get-pickup) + (when (zero? (logand (-> self state-flags) #x8000)) + (let ((s4-0 (-> arg3 param 0)) + (f28-0 (the-as float (-> arg3 param 1))) + ) + (if (!= (pickup-collectable! + (-> self fact-info-target) + (the-as pickup-type s4-0) + (-> (new 'static 'array float 1 0.0) 0) + (the-as handle #f) + ) + (pickup-collectable! (-> self fact-info-target) (the-as pickup-type s4-0) f28-0 (process->handle arg0)) + ) + #t + 'full + ) + ) + ) + ) + ((= v1-0 'reset-pickup) + (reset! (-> self fact-info-target) (the-as symbol (-> arg3 param 0))) + ) + ((= v1-0 'reset-collide) + (cond + ((-> self control unknown-symbol00) + (target-collide-set! (-> self control unknown-symbol00) (-> self control unknown-float90)) + ) + ((-> self control unknown-symbol30) + (target-danger-set! (-> self control unknown-symbol30) #f) + ) + ) + ) + ((= v1-0 'level-deactivate) + #f + ) + ((= v1-0 'level-enter) + (let ((v1-21 (level-get *level* (the-as symbol (-> arg3 param 0))))) + (when v1-21 + (let ((s5-1 (-> v1-21 info))) + (let ((v1-22 (-> s5-1 buzzer))) + (if (zero? v1-22) + (set! (-> self fact-info-target buzzer) 0.0) + (set! (-> self fact-info-target buzzer) (pickup-collectable! + (-> self fact-info-target) + (pickup-type buzzer) + (the float (logior -65536 v1-22)) + (the-as handle #f) + ) + ) + ) + ) + (if (and (zero? (-> *game-info* enter-level-time (-> s5-1 index))) + (>= (-> *level-task-data-remap* length) (-> s5-1 index)) + ) + (set! (-> *game-info* enter-level-time (-> *level-task-data-remap* (+ (-> s5-1 index) -1))) + (-> *display* base-frame-counter) + ) + ) + ) + (send-event (ppointer->process (-> *hud-parts* buzzers)) 'sync) + (format #t "GAMEPLAY: enter ~A~%" (-> arg3 param 0)) + ) + ) + ) + ((= v1-0 'get-attack-count) + (set! v0-0 (the-as object (+ (-> self control unknown-dword51) (-> arg3 param 0)))) + (set! (-> self control unknown-dword51) (the-as int v0-0)) + v0-0 + ) + ((= v1-0 'continue) + (go target-continue (the-as continue-point (-> arg3 param 0))) + ) + ((= v1-0 'query) + (case (-> arg3 param 0) + (('powerup) + (and (= (-> self fact-info-target eco-type) (-> arg3 param 1)) (< 0.0 (-> self fact-info-target eco-level))) + ) + (('pickup) + (pickup-collectable! + (-> self fact-info-target) + (the-as pickup-type (-> arg3 param 1)) + (-> (new 'static 'array float 1 0.0) 0) + (the-as handle #f) + ) + ) + (('ground-height) + (target-height-above-ground) + ) + ) + ) + ((= v1-0 'trans) + (case (-> arg3 param 0) + (('save) + (set! (-> self alt-cam-pos quad) (-> self control trans quad)) + (set! (-> self state-flags) (logior #x20000 (-> self state-flags))) + (mem-copy! (the-as pointer (-> arg3 param 1)) (the-as pointer (-> self control trans)) 48) + ) + (('restore) + (set! (-> self state-flags) (logand -131073 (-> self state-flags))) + (let ((gp-1 (-> arg3 param 1))) + (move-to-point! (-> self control) (the-as vector (+ gp-1 0))) + (quaternion-copy! (-> self control quat) (the-as quaternion (+ gp-1 16))) + ) + (rot->dir-targ! (-> self control)) + (logior! (-> self control status) 7) + (set! v0-0 (the-as object (-> *display* base-frame-counter))) + (set! (-> self control unknown-dword11) (the-as int v0-0)) + v0-0 + ) + (('reset) + (set! v0-0 (the-as object (logand -131073 (-> self state-flags)))) + (set! (-> self state-flags) (the-as uint v0-0)) + v0-0 + ) + ) + ) + ((= v1-0 'effect) + (target-powerup-effect (the-as symbol (-> arg3 param 0))) + ) + ((= v1-0 'do-effect) + (dummy-10 (-> self skel effect) (the-as symbol (-> arg3 param 0)) (the-as float (-> arg3 param 1)) -1) + (if (-> self sidekick) + (dummy-10 + (-> self sidekick 0 skel effect) + (the-as symbol (-> arg3 param 0)) + (the-as float (-> arg3 param 1)) + -1 + ) + ) + ) + ((= v1-0 'neck) + (set! (-> self neck flex-blend) (the-as float (-> arg3 param 0))) + (cond + ((-> arg3 param 1) + (set! (-> self state-flags) (logior #x40000 (-> self state-flags))) + (set! (-> self alt-neck-pos quad) (-> (the-as vector (-> arg3 param 1)) quad)) + (look-at-enemy! (-> self neck) (-> self alt-neck-pos) 'force arg0) + ) + (else + (set! v0-0 (the-as object (logand -262145 (-> self state-flags)))) + (set! (-> self state-flags) (the-as uint v0-0)) + v0-0 + ) + ) + ) + ((= v1-0 'sidekick) + (cond + ((and (-> arg3 param 0) (not (-> self sidekick))) + (let ((gp-2 (get-process *default-dead-pool* sidekick #x4000))) + (set! v0-0 (when gp-2 + (let ((t9-21 (method-of-type sidekick activate))) + (t9-21 (the-as sidekick gp-2) self 'sidekick (the-as pointer #x70004000)) + ) + (run-now-in-process gp-2 init-sidekick) + (-> gp-2 ppointer) + ) + ) + ) + (set! (-> self sidekick) (the-as (pointer sidekick) v0-0)) + v0-0 + ) + ((and (not (-> arg3 param 0)) (-> self sidekick)) + (deactivate (-> self sidekick 0)) + (set! (-> self sidekick) (the-as (pointer sidekick) #f)) + #f + ) + ) + ) + ((= v1-0 'blend-shape) + (if (-> arg3 param 0) + (logior! (-> self skel status) 8) + (set! (-> self skel status) (logand -9 (-> self skel status))) + ) + (let ((v1-105 (new 'stack-no-clear 'event-message-block))) + (set! (-> v1-105 from) arg0) + (set! (-> v1-105 num-params) arg1) + (set! (-> v1-105 message) arg2) + (set! (-> v1-105 param 0) (-> arg3 param 0)) + (set! (-> v1-105 param 1) (-> arg3 param 1)) + (set! (-> v1-105 param 2) (-> arg3 param 2)) + (set! (-> v1-105 param 3) (-> arg3 param 3)) + (set! (-> v1-105 param 4) (-> arg3 param 4)) + (set! (-> v1-105 param 5) (-> arg3 param 5)) + (set! (-> v1-105 param 6) (-> arg3 param 6)) + (send-event-function (ppointer->process (-> self sidekick)) v1-105) + ) + ) + ((= v1-0 'shadow) + (cond + ((-> arg3 param 0) + (let ((v1-108 (-> self draw shadow-ctrl))) + (set! (-> v1-108 settings flags) (logand -33 (-> v1-108 settings flags))) + ) + 0 + ) + (else + (let ((v1-110 (-> self draw shadow-ctrl))) + (logior! (-> v1-110 settings flags) 32) + ) + 0 + ) + ) + ) + ((= v1-0 'rotate-y-angle) + (format 0 "doing roty angle~%") + (break!) + (quaternion-rotate-y! + (-> self control unknown-quaternion00) + (-> self control unknown-quaternion00) + (the-as float (-> arg3 param 0)) + ) + (if (= (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) stick0-speed) 0.0) + (rot->dir-targ! (-> self control)) + ) + ) + ((= v1-0 'touched) + (send-event arg0 'touch (-> arg3 param 0)) + ) + ((= v1-0 'dry) + (let ((f0-9 0.0)) + (set! (-> self water drip-wetness) f0-9) + f0-9 + ) + ) + ((= v1-0 'reset-height) + (set! (-> self control unknown-vector52 quad) (-> self control trans quad)) + #f + ) + ((= v1-0 'draw) + (if (-> arg3 param 0) + (logclear! (-> self draw status) (draw-status drwf05)) + (logior! (-> self draw status) (draw-status drwf05)) + ) + (let ((v1-132 (new 'stack-no-clear 'event-message-block))) + (set! (-> v1-132 from) arg0) + (set! (-> v1-132 num-params) arg1) + (set! (-> v1-132 message) arg2) + (set! (-> v1-132 param 0) (-> arg3 param 0)) + (set! (-> v1-132 param 1) (-> arg3 param 1)) + (set! (-> v1-132 param 2) (-> arg3 param 2)) + (set! (-> v1-132 param 3) (-> arg3 param 3)) + (set! (-> v1-132 param 4) (-> arg3 param 4)) + (set! (-> v1-132 param 5) (-> arg3 param 5)) + (set! (-> v1-132 param 6) (-> arg3 param 6)) + (send-event-function (ppointer->process (-> self manipy)) v1-132) + ) + ) + ((= v1-0 'no-load-wait) + (set! v0-0 (the-as object (+ (-> *display* base-frame-counter) (-> arg3 param 0)))) + (set! (-> self no-load-wait) (the-as uint v0-0)) + v0-0 + ) + ((= v1-0 'no-look-around) + (set! (-> self no-look-around-wait) (the-as uint (+ (-> *display* base-frame-counter) (-> arg3 param 0)))) + (if (= (-> self next-state name) 'target-look-around) + (send-event self 'end-mode) + ) + ) + ((= v1-0 'change-state) + enter-state + (-> arg3 param 1) + (-> arg3 param 2) + (-> arg3 param 3) + (-> arg3 param 4) + (go (the-as (state target) (-> arg3 param 0))) + ) + ) + ) + ) + ) + +;; definition for function target-shoved +(defbehavior target-shoved target ((arg0 meters) (arg1 meters) (arg2 process) (arg3 (state object object target))) + (let ((s5-0 (new 'static 'attack-info))) + (set! (-> s5-0 attacker) (process->handle arg2)) + (set! (-> s5-0 shove-back) arg0) + (set! (-> s5-0 shove-up) arg1) + (set! (-> s5-0 angle) (if (zero? (logand (logior (-> self control status) (-> self control old-status)) 1)) + 'air + 'shove + ) + ) + (set! (-> s5-0 mask) (the-as uint 2248)) + (cpad-set-buzz! (-> *cpad-list* cpads 0) 1 255 30) + (go arg3 'shove s5-0) + ) + ) + + +;; definition for function get-intersect-point +;; Used lq/sq +(defun get-intersect-point ((arg0 vector) (arg1 touching-prims-entry) (arg2 control-info) (arg3 process)) + (let ((a0-2 (get-touched-tri arg1 arg2 (the-as touching-shapes-entry arg3)))) + (if a0-2 + (set! (-> arg0 quad) (-> a0-2 intersect quad)) + (get-middle-of-bsphere-overlap arg1 arg0) + ) + ) + arg0 + ) + +;; definition for function target-attacked +(defbehavior target-attacked target ((arg0 symbol) (arg1 attack-info) (arg2 process) (arg3 process) (arg4 (state handle attack-info target))) + (when (zero? (logand (-> self state-flags) 8)) + (cond + ((or (logtest? (-> self state-flags) 112) + (and (logtest? (-> arg1 mask) 32) + (= (-> arg1 mode) 'darkeco) + (and (and (= (-> self fact-info-target eco-type) 2) (>= (-> self fact-info-target eco-level) 1.0)) + (logtest? #x100002 (-> self state-flags)) + ) + ) + ) + (case arg0 + (('attack-or-shove) + ) + (('attack-invinc) + (set! arg0 'attack) + ) + (else + (return #f) + ) + ) + ) + (else + (case arg0 + (('attack-or-shove 'attack-invinc) + (set! arg0 'attack) + ) + ) + ) + ) + (mem-copy! (the-as pointer (-> self attack-info-rec)) (the-as pointer arg1) 104) + (when arg3 + (let ((a1-2 ((method-of-type touching-shapes-entry prims-touching?) + (the-as touching-shapes-entry arg3) + (-> self control) + (the-as uint -1) + ) + ) + ) + (when a1-2 + (get-intersect-point (-> self attack-info-rec intersection) a1-2 (-> self control) arg3) + (logior! (-> self attack-info-rec mask) 4) + ) + ) + ) + (set! (-> self attack-info-rec prev-state) (-> self state)) + (logior! (-> self attack-info-rec mask) 8192) + (when (zero? (logand (-> self attack-info-rec mask) 8)) + (set! (-> self attack-info-rec attacker) (process->handle arg2)) + (logior! (-> self attack-info-rec mask) 8) + ) + (cond + ((and (logtest? (-> self attack-info-rec mask) 32) + (and (= (-> self attack-info-rec mode) 'damage) + (not (and (= (-> self game mode) 'play) (>= 1.0 (-> self fact-info-target health)))) + ) + ) + (pickup-collectable! + (-> self fact-info-target) + (pickup-type eco-green) + (- (-> *FACT-bank* health-single-inc)) + (the-as handle #f) + ) + (let ((gp-1 (get-process *default-dead-pool* part-tracker #x4000))) + (when gp-1 + (let ((t9-5 (method-of-type part-tracker activate))) + (t9-5 (the-as part-tracker gp-1) self 'part-tracker (the-as pointer #x70004000)) + ) + (run-now-in-process + gp-1 + part-tracker-init + (-> *part-group-id-table* 1) + -1 + #f + #f + #f + (if (logtest? (-> self attack-info-rec mask) 4) + (-> self attack-info-rec intersection) + (-> self control root-prim prim-core) + ) + ) + (-> gp-1 ppointer) + ) + ) + (target-timed-invulnerable + (if (logtest? (-> self attack-info-rec mask) 16) + (-> self attack-info-rec invinc-time) + (-> *TARGET-bank* hit-invulnerable-timeout) + ) + self + ) + (cpad-set-buzz! (-> *cpad-list* cpads 0) 0 255 150) + (sound-play-by-name (static-sound-name "oof") (new-sound-id) 1024 0 0 1 #t) + #t + ) + (else + (logior! (-> self state-flags) 8) + (if (and (= (-> self game mode) 'play) (and (>= 1.0 (-> self fact-info-target health)) (= arg0 'attack))) + (logior! (-> self state-flags) #x8000) + ) + (go arg4 (the-as handle arg0) (-> self attack-info-rec)) + ) + ) + ) + ) + +;; definition for function target-send-attack +;; INFO: Return type mismatch object vs symbol. +;; Used lq/sq +(defbehavior target-send-attack target ((arg0 process) (arg1 uint) (arg2 uint) (arg3 int) (arg4 int)) + (local-vars + (sv-96 touching-prims-entry) + (sv-128 touching-prims-entry) + (sv-176 touching-prims-entry) + (sv-224 int) + (sv-240 symbol) + (sv-256 symbol) + (sv-272 symbol) + (sv-288 int) + (sv-304 symbol) + (sv-320 symbol) + (sv-336 symbol) + (sv-352 int) + (sv-368 symbol) + (sv-384 symbol) + (sv-400 symbol) + (sv-416 int) + (sv-432 symbol) + (sv-448 symbol) + (sv-464 symbol) + (sv-480 int) + (sv-496 symbol) + (sv-512 symbol) + (sv-528 symbol) + ) + (let ((v1-0 (new 'stack-no-clear 'event-message-block))) + (set! (-> v1-0 from) self) + (set! (-> v1-0 num-params) 4) + (set! (-> v1-0 message) 'attack) + (set! (-> v1-0 param 0) arg2) + (set! (-> v1-0 param 1) arg1) + (set! (-> v1-0 param 2) (the-as uint arg3)) + (set! (-> v1-0 param 3) (the-as uint arg4)) + (let ((gp-0 (send-event-function arg0 v1-0))) + (when (and gp-0 (!= gp-0 'push)) + (let ((v1-5 (-> self control unknown-symbol30))) + (cond + ((or (= v1-5 'spin) (= v1-5 'spin-air)) + (set! sv-96 + ((method-of-type touching-shapes-entry prims-touching?) + (the-as touching-shapes-entry arg2) + (-> self control) + (the-as uint 64) + ) + ) + (cond + (sv-96 + (let ((s4-0 (get-process *default-dead-pool* part-tracker #x4000))) + (when s4-0 + (let ((t9-3 (method-of-type part-tracker activate))) + (t9-3 (the-as part-tracker s4-0) self 'part-tracker (the-as pointer #x70004000)) + ) + (let ((s3-0 run-function-in-process) + (s2-0 s4-0) + (s1-0 part-tracker-init) + (s0-0 (-> *part-group-id-table* 4)) + ) + (set! sv-224 -1) + (set! sv-240 (the-as symbol #f)) + (set! sv-256 (the-as symbol #f)) + (set! sv-272 (the-as symbol #f)) + (let ((t3-0 (get-intersect-point (new 'stack-no-clear 'vector) sv-96 (-> self control) (the-as process arg2)))) + ((the-as (function object object object object object object object object none) s3-0) + s2-0 + s1-0 + s0-0 + sv-224 + sv-240 + sv-256 + sv-272 + t3-0 + ) + ) + ) + (-> s4-0 ppointer) + ) + ) + ) + (else + (dummy-10 (-> self skel effect) 'group-spin-hit (the-as float -1.0) 74) + ) + ) + (dummy-12 + (-> self skel effect) + (-> self control unknown-symbol30) + (the-as basic -1.0) + 74 + #f + (static-sound-name "spin-hit") + ) + (cpad-set-buzz! (-> *cpad-list* cpads 0) 1 127 60) + ) + ((= v1-5 'punch) + (set! sv-128 + ((method-of-type touching-shapes-entry prims-touching?) + (the-as touching-shapes-entry arg2) + (-> self control) + (the-as uint 64) + ) + ) + (cond + (sv-128 + (let ((s4-1 (get-process *default-dead-pool* part-tracker #x4000))) + (when s4-1 + (let ((t9-11 (method-of-type part-tracker activate))) + (t9-11 (the-as part-tracker s4-1) self 'part-tracker (the-as pointer #x70004000)) + ) + (let ((s3-1 run-function-in-process) + (s2-1 s4-1) + (s1-1 part-tracker-init) + (s0-1 (-> *part-group-id-table* 5)) + ) + (set! sv-288 -1) + (set! sv-304 (the-as symbol #f)) + (set! sv-320 (the-as symbol #f)) + (set! sv-336 (the-as symbol #f)) + (let ((t3-1 (get-intersect-point (new 'stack-no-clear 'vector) sv-128 (-> self control) (the-as process arg2)))) + ((the-as (function object object object object object object object object none) s3-1) + s2-1 + s1-1 + s0-1 + sv-288 + sv-304 + sv-320 + sv-336 + t3-1 + ) + ) + ) + (-> s4-1 ppointer) + ) + ) + ) + ((let ((v0-14 + ((method-of-type touching-shapes-entry prims-touching?) + (the-as touching-shapes-entry arg2) + (-> self control) + (the-as uint 32) + ) + ) + ) + (set! sv-128 v0-14) + v0-14 + ) + (let ((s4-2 (get-process *default-dead-pool* part-tracker #x4000))) + (when s4-2 + (let ((t9-16 (method-of-type part-tracker activate))) + (t9-16 (the-as part-tracker s4-2) self 'part-tracker (the-as pointer #x70004000)) + ) + (let ((s3-2 run-function-in-process) + (s2-2 s4-2) + (s1-2 part-tracker-init) + (s0-2 (-> *part-group-id-table* 5)) + ) + (set! sv-352 -1) + (set! sv-368 (the-as symbol #f)) + (set! sv-384 (the-as symbol #f)) + (set! sv-400 (the-as symbol #f)) + (let ((t3-2 (get-intersect-point (new 'stack-no-clear 'vector) sv-128 (-> self control) (the-as process arg2)))) + ((the-as (function object object object object object object object object none) s3-2) + s2-2 + s1-2 + s0-2 + sv-352 + sv-368 + sv-384 + sv-400 + t3-2 + ) + ) + ) + (-> s4-2 ppointer) + ) + ) + ) + ) + (dummy-12 + (-> self skel effect) + (-> self control unknown-symbol30) + (the-as basic -1.0) + 23 + #f + (static-sound-name "punch-hit") + ) + (cpad-set-buzz! (-> *cpad-list* cpads 0) 1 178 30) + ) + ((= v1-5 'flip) + (dummy-12 + (-> self skel effect) + (-> self control unknown-symbol30) + (the-as basic -1.0) + 74 + #f + (static-sound-name "punch-hit") + ) + (cpad-set-buzz! (-> *cpad-list* cpads 0) 1 127 30) + ) + ((= v1-5 'uppercut) + (set! sv-176 + ((method-of-type touching-shapes-entry prims-touching?) + (the-as touching-shapes-entry arg2) + (-> self control) + (the-as uint 64) + ) + ) + (cond + (sv-176 + (let ((s4-3 (get-process *default-dead-pool* part-tracker #x4000))) + (when s4-3 + (let ((t9-25 (method-of-type part-tracker activate))) + (t9-25 (the-as part-tracker s4-3) self 'part-tracker (the-as pointer #x70004000)) + ) + (let ((s3-3 run-function-in-process) + (s2-3 s4-3) + (s1-3 part-tracker-init) + (s0-3 (-> *part-group-id-table* 5)) + ) + (set! sv-416 -1) + (set! sv-432 (the-as symbol #f)) + (set! sv-448 (the-as symbol #f)) + (set! sv-464 (the-as symbol #f)) + (let ((t3-3 (get-intersect-point (new 'stack-no-clear 'vector) sv-176 (-> self control) (the-as process arg2)))) + ((the-as (function object object object object object object object object none) s3-3) + s2-3 + s1-3 + s0-3 + sv-416 + sv-432 + sv-448 + sv-464 + t3-3 + ) + ) + ) + (-> s4-3 ppointer) + ) + ) + ) + ((let ((v0-26 + ((method-of-type touching-shapes-entry prims-touching?) + (the-as touching-shapes-entry arg2) + (-> self control) + (the-as uint 32) + ) + ) + ) + (set! sv-176 v0-26) + v0-26 + ) + (let ((s4-4 (get-process *default-dead-pool* part-tracker #x4000))) + (when s4-4 + (let ((t9-30 (method-of-type part-tracker activate))) + (t9-30 (the-as part-tracker s4-4) self 'part-tracker (the-as pointer #x70004000)) + ) + (let ((s3-4 run-function-in-process) + (s2-4 s4-4) + (s1-4 part-tracker-init) + (s0-4 (-> *part-group-id-table* 5)) + ) + (set! sv-480 -1) + (set! sv-496 (the-as symbol #f)) + (set! sv-512 (the-as symbol #f)) + (set! sv-528 (the-as symbol #f)) + (let ((t3-4 (get-intersect-point (new 'stack-no-clear 'vector) sv-176 (-> self control) (the-as process arg2)))) + ((the-as (function object object object object object object object object none) s3-4) + s2-4 + s1-4 + s0-4 + sv-480 + sv-496 + sv-512 + sv-528 + t3-4 + ) + ) + ) + (-> s4-4 ppointer) + ) + ) + ) + ) + (dummy-10 (-> self skel effect) 'group-uppercut-hit (the-as float -1.0) 23) + (dummy-12 + (-> self skel effect) + (-> self control unknown-symbol30) + (the-as basic -1.0) + 23 + #f + (static-sound-name "uppercut-hit") + ) + (cpad-set-buzz! (-> *cpad-list* cpads 0) 1 178 30) + ) + ((or (= v1-5 'flop) (= v1-5 'flop-down)) + (dummy-10 (-> self skel effect) 'group-flop-hit (the-as float -1.0) 23) + (dummy-10 (-> self skel effect) 'group-flop-hit (the-as float -1.0) 17) + (dummy-12 + (-> self skel effect) + (-> self control unknown-symbol30) + (the-as basic -1.0) + 23 + #f + (static-sound-name "flop-hit") + ) + (cpad-set-buzz! (-> *cpad-list* cpads 0) 1 178 30) + ) + ((= v1-5 'flut-attack) + (dummy-12 + (-> self skel effect) + (-> self control unknown-symbol30) + (the-as basic -1.0) + 23 + #f + (static-sound-name "punch-hit") + ) + (cpad-set-buzz! (-> *cpad-list* cpads 0) 1 255 60) + ) + ) + ) + ) + (the-as symbol gp-0) + ) + ) + ) + +;; definition for function target-apply-tongue +(defbehavior target-apply-tongue target ((arg0 vector)) + (when (zero? (logand (-> self state-flags) 8)) + (logior! (-> self state-flags) #x7000) + (let ((gp-1 (vector-! (new 'stack-no-clear 'vector) arg0 (-> self control trans)))) + (set! (-> self control unknown-float41) (lerp-scale + (-> *TARGET-bank* tongue-pull-speed-min) + (-> *TARGET-bank* tongue-pull-speed-max) + (vector-length gp-1) + (the-as float 20480.0) + (the-as float 61440.0) + ) + ) + (if (zero? (-> self control unknown-int00)) + (vector-reset! (-> self control unknown-vector40)) + ) + (vector-flatten! gp-1 gp-1 (-> self control local-normal)) + (vector-normalize! gp-1 (the-as float 1.0)) + (vector+! (-> self control unknown-vector40) (-> self control unknown-vector40) gp-1) + ) + (set! (-> self control unknown-float50) 1.0) + (+! (-> self control unknown-int00) 1) + #t + ) + ) + +;; definition for function target-standard-event-handler +(defbehavior target-standard-event-handler target ((arg0 process) (arg1 int) (arg2 symbol) (arg3 event-message-block)) + ;; (format 0 "target-standard-event-handler: ~A~%" arg2) + (case arg2 + (('attack 'attack-or-shove 'attack-invinc) + (target-attacked + arg2 + (the-as attack-info (-> arg3 param 1)) + arg0 + (the-as process (-> arg3 param 0)) + (the-as (state handle attack-info target) target-hit) + ) + ) + (('shove) + (when (!= (-> self next-state name) 'target-hit) + (mem-copy! (the-as pointer (-> self attack-info-rec)) (the-as pointer (-> arg3 param 1)) 104) + (when (zero? (logand (-> self attack-info-rec mask) 8)) + (set! (-> self attack-info-rec attacker) (process->handle arg0)) + (logior! (-> self attack-info-rec mask) 8) + ) + (go target-hit 'shove (-> self attack-info-rec)) + ) + ) + (('launch) + (mem-copy! (&-> (-> self control) unknown-pointer00) (the-as pointer arg3) 72) + #t + ) + (('powerup) + (if (or (= (-> self next-state name) 'target-stance) + (= (-> self next-state name) 'target-walk) + (= (-> self next-state name) 'target-stance-look-around) + ) + (go target-eco-powerup (-> arg3 param 0) (the-as float (-> arg3 param 1))) + ) + ) + (('loading) + (if (not + (or (and (logtest? (-> self control unknown-surface00 flags) 2048) (zero? (logand (-> self control status) 1))) + (or (logtest? (-> self water flags) 512) + (logtest? (-> self state-flags) #x830e) + (logtest? (-> self control root-prim prim-core action) (collide-action ca-7 ca-8 ca-9 ca-12 ca-13 ca-14)) + (>= (the-as int (-> self no-load-wait)) (-> *display* base-frame-counter)) + ) + ) + ) + (go target-load-wait) + ) + ) + (('change-mode) + (case (-> arg3 param 0) + (('grab) + (go target-grab) + ) + (('look-around) + (go target-look-around) + ) + (('billy) + (go target-billy-game) + ) + (('falling) + (go target-falling #f) + ) + (('racing) + (go target-racing-start (process->handle (the-as process (-> arg3 param 1)))) + ) + (('flut) + (go target-flut-start (process->handle (the-as process (-> arg3 param 1)))) + ) + (('snowball) + (go target-snowball-start (process->handle (the-as process (-> arg3 param 1)))) + ) + (('tube) + (if (and (logtest? (-> self control status) 1) (zero? (logand (-> self water flags) 512))) + (go target-tube-start (process->handle (the-as process (-> arg3 param 1)))) + ) + ) + (('periscope) + (if (logtest? (-> self control status) 1) + (go target-periscope (process->handle (the-as process (-> arg3 param 1)))) + ) + ) + (('fishing) + (go target-fishing (process->handle (the-as process (-> arg3 param 1)))) + ) + (('final-door) + (go + target-final-door + (the-as basic (process->handle (the-as process (-> arg3 param 1)))) + (process->handle (the-as process (-> arg3 param 2))) + ) + ) + ) + ) + (('play-anim) + (go target-play-anim (the-as string (-> arg3 param 0)) (the-as handle arg1)) + ) + (('clone-anim) + (go target-clone-anim (process->handle (the-as process (-> arg3 param 0)))) + ) + (('edge-grab) + (go target-edge-grab) + ) + (('pole-grab) + (if (zero? (logand (-> self control root-prim prim-core action) (collide-action ca-8))) + (go target-pole-cycle (process->handle (the-as process (-> arg3 param 0)))) + ) + ) + (('swim) + (if (not (or (= (-> self control unknown-surface00 mode) 'swim) + (= (-> self control unknown-surface00 mode) 'dive) + (= (-> self next-state name) 'target-hit) + (logtest? (-> self state-flags) 8) + ) + ) + (go target-swim-stance) + ) + ) + (('wade) + (if (and (!= (-> self control unknown-surface00 mode) 'wade) + (or (= (-> self next-state name) 'target-stance) + (= (-> self next-state name) 'target-walk) + (= (-> self next-state name) 'target-stance-look-around) + ) + ) + (go target-wade-stance) + ) + ) + (('tongue) + (target-apply-tongue (the-as vector (-> arg3 param 0))) + ) + (else + (target-generic-event-handler arg0 arg1 arg2 arg3) + ) + ) + ) + +;; definition for function target-dangerous-event-handler +(defbehavior target-dangerous-event-handler target ((arg0 process) (arg1 int) (arg2 symbol) (arg3 event-message-block)) + (case arg2 + (('touched) + (if ((method-of-type touching-shapes-entry prims-touching?) + (the-as touching-shapes-entry (-> arg3 param 0)) + (-> self control) + (the-as uint 224) + ) + (target-send-attack + arg0 + (the-as uint (-> self control unknown-symbol30)) + (-> arg3 param 0) + (-> self control unknown-dword50) + (-> self control unknown-dword51) + ) + (target-standard-event-handler arg0 arg1 arg2 arg3) + ) + ) + (('attack 'attack-or-shove 'attack-invinc) + (target-attacked + arg2 + (the-as attack-info (-> arg3 param 1)) + arg0 + (the-as process (-> arg3 param 0)) + (the-as (state handle attack-info target) target-hit) + ) + ) + (else + (target-standard-event-handler arg0 arg1 arg2 arg3) + ) + ) + ) + +;; definition for function target-bonk-event-handler +;; Used lq/sq +(defbehavior target-bonk-event-handler target ((arg0 process) (arg1 int) (arg2 symbol) (arg3 event-message-block)) + (let ((s4-0 (new 'stack-no-clear 'vector))) + (cond + ((and (= arg2 'touched) + ((method-of-type touching-shapes-entry prims-touching?) + (the-as touching-shapes-entry (-> arg3 param 0)) + (-> self control) + (the-as uint 6) + ) + (< (* 16384.0 (-> *display* time-adjust-ratio)) + (vector-dot + (-> self control dynam gravity-normal) + (vector-! (new 'stack-no-clear 'vector) (-> self control transv) (-> self control unknown-vector10)) + ) + ) + (begin + (vector-normalize! + (vector-! + s4-0 + (the-as vector (-> self control unknown-sphere-array00 0 prim-core)) + (-> self control unknown-vector72) + ) + (the-as float 1.0) + ) + (< 0.01 (-> s4-0 y)) + ) + ) + (if (< 0.75 (-> s4-0 y)) + (send-event + arg0 + 'bonk + (-> arg3 param 0) + (fmax + (-> self control ground-impact-vel) + (- (vector-dot (-> self control transv) (-> self control dynam gravity-normal))) + ) + ) + ) + (let ((f0-7 (vector-dot + (-> self control dynam gravity-normal) + (vector-! (new 'stack-no-clear 'vector) (-> self control unknown-vector111) (-> self control trans)) + ) + ) + ) + (when (< (-> *TARGET-bank* fall-far) f0-7) + (when (and (target-send-attack + arg0 + (the-as uint 'bonk) + (-> arg3 param 0) + (-> self control unknown-dword50) + (-> self control unknown-dword51) + ) + (zero? (logand (-> self state-flags) #x8008)) + ) + (set! (-> self control unknown-vector52 quad) (-> self control trans quad)) + (target-timed-invulnerable 30 self) + (go target-jump (-> *TARGET-bank* jump-height-min) (-> *TARGET-bank* jump-height-max) (the-as surface #f)) + ) + ) + ) + #f + ) + ((= arg2 'jump) + (sound-play-by-name (static-sound-name "jump-long") (new-sound-id) 1024 0 0 1 #t) + (go + target-jump + (the-as float (-> arg3 param 0)) + (the-as float (-> arg3 param 1)) + (the-as surface (-> arg3 param 2)) + ) + ) + ) + ) + ) + +;; definition for function target-jump-event-handler +(defbehavior target-jump-event-handler target ((arg0 process) (arg1 int) (arg2 symbol) (arg3 event-message-block)) + (if (and (= arg2 'swim) (< 0.0 (vector-dot (-> self control dynam gravity-normal) (-> self control transv)))) + (return #f) + ) + (let ((v0-0 (target-bonk-event-handler arg0 arg1 arg2 arg3))) + (cond + (v0-0 + (empty) + v0-0 + ) + (else + (target-standard-event-handler arg0 arg1 arg2 arg3) + ) + ) + ) + ) + +;; definition for function target-walk-event-handler +(defbehavior target-walk-event-handler target ((arg0 process) (arg1 int) (arg2 symbol) (arg3 event-message-block)) + (let ((v0-0 (target-bonk-event-handler arg0 arg1 arg2 arg3))) + (cond + (v0-0 + (empty) + v0-0 + ) + (else + (target-standard-event-handler arg0 arg1 arg2 arg3) + ) + ) + ) + ) + +;; failed to figure out what this is: +target-post + +;; failed to figure out what this is: +target-standard-event-handler + +;; definition for function target-exit +;; INFO: Return type mismatch int vs none. +;; Used lq/sq +(defbehavior target-exit target () + (set! (-> self control unknown-surface00) *walk-mods*) + (set! (-> self control unknown-vector13 quad) (the-as uint128 0)) + (set! (-> self control unknown-vector14 quad) (the-as uint128 0)) + (set! (-> self control unknown-vector15 quad) (the-as uint128 0)) + (set! (-> self control unknown-vector11 quad) (the-as uint128 0)) + (set! (-> self control unknown-float41) 0.0) + (set! (-> self control unknown-float81) 0.0) + (set! (-> self state-flags) (logand -1835917 (-> self state-flags))) + (target-danger-set! 'harmless #f) + (logior! (-> self water flags) 16) + (set! (-> self water flags) (logand -65537 (-> self water flags))) + (set! (-> self water drip-mult) 1.0) + (set! (-> self neck flex-blend) 1.0) + (set! (-> self control unknown-float91) 0.0) + (logclear! (-> self draw status) (draw-status drwf01)) + (set! (-> self skel status) (logand -33 (-> self skel status))) + (set! (-> self control status) (logand -16385 (-> self control status))) + 0 + (none) + ) + +;; definition for function target-state-hook-exit +;; INFO: Return type mismatch (function none) vs none. +(defbehavior target-state-hook-exit target () + (set! (-> self state-hook) (the-as (function none :behavior target) nothing)) + (none) + ) + +;; definition for function target-effect-exit +;; INFO: Return type mismatch int vs none. +(defbehavior target-effect-exit target () + (let ((v1-1 (-> self skel effect))) + (set! (-> v1-1 channel-offset) 0) + ) + 0 + (none) + ) + + diff --git a/goal_src/engine/target/target-util.gc b/goal_src/engine/target/target-util.gc index 85825fc9b..85ddcb916 100644 --- a/goal_src/engine/target/target-util.gc +++ b/goal_src/engine/target/target-util.gc @@ -862,6 +862,21 @@ (set! (-> gp-0 proc) #f) (set! (-> gp-0 ignore-pat) (the-as uint 1)) (set! (-> gp-0 solid-only) #t) + + ;; NOTE: added this. + ;; exit duck has failed for 2 reasons: + ;; there seems to be a bogus triangle in the cache sometimes (rare) + ;; sometimes it thinks we hit the spheres, but we don't. + ; (dotimes (i 2) + ; (add-debug-sphere + ; #t + ; (bucket-id debug-draw0) + ; (-> (the (inline-array sphere) (-> gp-0 spheres)) i) + ; (-> (the (inline-array sphere) (-> gp-0 spheres)) i w) + ; (new 'static 'rgba :r #x80 :a #x80) + ; ) + ; ) + (if (fill-and-probe-using-spheres *collide-cache* gp-0) #f #t diff --git a/goal_src/engine/target/target.gc b/goal_src/engine/target/target.gc index bd84a47dc..4a6bbac3a 100644 --- a/goal_src/engine/target/target.gc +++ b/goal_src/engine/target/target.gc @@ -15,7534 +15,4604 @@ (define-extern target-dangerous-event-handler (function process int symbol event-message-block object :behavior target)) (define-extern target-standard-event-handler (function process int symbol event-message-block object :behavior target)) (define-extern target-jump-event-handler (function process int symbol event-message-block object :behavior target)) -(define-extern target-shoved (function meters meters process (state target) object :behavior target)) +(define-extern target-shoved (function meters meters process (state object object target) object :behavior target)) (define-extern target-send-attack (function process uint uint int int symbol :behavior target)) ;; i suspect the uints are actually structures/basics (define-extern target-bonk-event-handler (function process int symbol event-message-block object :behavior target)) ;; DECOMP BEGINS +;; definition for function target-falling-anim (defbehavior target-falling-anim target ((arg0 int) (arg1 int)) (let ((v1-2 (if (> (-> self skel active-channels) 0) - (-> self skel root-channel 0 frame-group) - ) - ) - ) - (cond - ((or - (= v1-2 (-> self draw art-group data 38)) - (= v1-2 (-> self draw art-group data 62)) - ) - ) - ((let ((v1-8 (if (> (-> self skel active-channels) 0) (-> self skel root-channel 0 frame-group) ) - ) + ) + ) + (cond + ((or (= v1-2 (-> self draw art-group data 38)) (= v1-2 (-> self draw art-group data 62))) + ) + ((let ((v1-8 (if (> (-> self skel active-channels) 0) + (-> self skel root-channel 0 frame-group) + ) + ) + ) + (or (= v1-8 (-> self draw art-group data 44)) (= v1-8 (-> self draw art-group data 45))) + ) + (ja-channel-push! 1 45) + (let ((a0-16 (-> self skel root-channel 0))) + (set! (-> a0-16 frame-group) (the-as art-joint-anim (-> self draw art-group data 50))) + (set! (-> a0-16 param 0) + (the float (+ (-> (the-as art-joint-anim (-> self draw art-group data 50)) data 0 length) -1)) + ) + (set! (-> a0-16 param 1) (-> (new 'static 'array float 1 1.0) 0)) + (set! (-> a0-16 frame-num) 0.0) + (joint-control-channel-group! a0-16 (the-as art-joint-anim (-> self draw art-group data 50)) num-func-seek!) + ) + (until (ja-done? 0) + (suspend) + (let ((a0-17 (-> self skel root-channel 0))) + (set! (-> a0-17 param 0) (the float (+ (-> a0-17 frame-group data 0 length) -1))) + (set! (-> a0-17 param 1) (-> (new 'static 'array float 1 1.0) 0)) + (joint-control-channel-group-eval! a0-17 (the-as art-joint-anim #f) num-func-seek!) ) - (or - (= v1-8 (-> self draw art-group data 44)) - (= v1-8 (-> self draw art-group data 45)) + ) ) - ) - (ja-channel-push! 1 45) - (let ((a0-16 (-> self skel root-channel 0))) - (set! - (-> a0-16 frame-group) - (the-as art-joint-anim (-> self draw art-group data 50)) - ) - (set! - (-> a0-16 param 0) - (the - float - (+ - (-> - (the-as art-joint-anim (-> self draw art-group data 50)) - data - 0 - length + ((= (if (> (-> self skel active-channels) 0) + (-> self skel root-channel 0 frame-group) + ) + (-> self draw art-group data 50) ) - -1 + (until (ja-done? 0) + (suspend) + (let ((a0-23 (-> self skel root-channel 0))) + (set! (-> a0-23 param 0) (the float (+ (-> a0-23 frame-group data 0 length) -1))) + (set! (-> a0-23 param 1) (-> (new 'static 'array float 1 1.0) 0)) + (joint-control-channel-group-eval! a0-23 (the-as art-joint-anim #f) num-func-seek!) + ) ) - ) + (ja-channel-push! 1 45) ) - (set! (-> a0-16 param 1) (-> (new 'static 'array float 1 1.0) 0)) - (set! (-> a0-16 frame-num) 0.0) - (joint-control-channel-group! - a0-16 - (the-as art-joint-anim (-> self draw art-group data 50)) - num-func-seek! - ) - ) - (until (ja-done? 0) - (suspend) - (let ((a0-17 (-> self skel root-channel 0))) - (set! - (-> a0-17 param 0) - (the float (+ (-> a0-17 frame-group data 0 length) -1)) - ) - (set! (-> a0-17 param 1) (-> (new 'static 'array float 1 1.0) 0)) - (joint-control-channel-group-eval! - a0-17 - (the-as art-joint-anim #f) - num-func-seek! - ) - ) - ) - ) - ((= (if (> (-> self skel active-channels) 0) - (-> self skel root-channel 0 frame-group) - ) - (-> self draw art-group data 50) - ) - (until (ja-done? 0) - (suspend) - (let ((a0-23 (-> self skel root-channel 0))) - (set! - (-> a0-23 param 0) - (the float (+ (-> a0-23 frame-group data 0 length) -1)) - ) - (set! (-> a0-23 param 1) (-> (new 'static 'array float 1 1.0) 0)) - (joint-control-channel-group-eval! - a0-23 - (the-as art-joint-anim #f) - num-func-seek! - ) - ) - ) - (ja-channel-push! 1 45) - ) - ((= (if (> (-> self skel active-channels) 0) - (-> self skel root-channel 0 frame-group) - ) - (-> self draw art-group data 86) - ) - (ja-channel-push! 1 45) - (let ((s5-0 (-> self skel root-channel 0))) - (set! - (-> s5-0 frame-group) - (the-as art-joint-anim (-> self draw art-group data 34)) - ) - (set! - (-> s5-0 param 0) - (the - float - (+ - (-> - (the-as art-joint-anim (-> self draw art-group data 34)) - data - 0 - length + ((= (if (> (-> self skel active-channels) 0) + (-> self skel root-channel 0 frame-group) + ) + (-> self draw art-group data 86) ) - -1 + (ja-channel-push! 1 45) + (let ((s5-0 (-> self skel root-channel 0))) + (set! (-> s5-0 frame-group) (the-as art-joint-anim (-> self draw art-group data 34))) + (set! (-> s5-0 param 0) + (the float (+ (-> (the-as art-joint-anim (-> self draw art-group data 34)) data 0 length) -1)) + ) + (set! (-> s5-0 param 1) (-> (new 'static 'array float 1 1.0) 0)) + (set! (-> s5-0 frame-num) (ja-aframe (the-as float 20.0) 0)) + (joint-control-channel-group! s5-0 (the-as art-joint-anim (-> self draw art-group data 34)) num-func-seek!) ) + (until (ja-done? 0) + (let ((a0-33 (-> self skel root-channel 0))) + (set! (-> a0-33 param 0) (the float (+ (-> a0-33 frame-group data 0 length) -1))) + (set! (-> a0-33 param 1) (-> (new 'static 'array float 1 1.0) 0)) + (joint-control-channel-group-eval! a0-33 (the-as art-joint-anim #f) num-func-seek!) + ) + (suspend) + ) + ) + (else + (ja-channel-push! 1 arg1) + (let ((v1-82 (-> self skel root-channel 0))) + (set! (-> v1-82 frame-group) (the-as art-joint-anim (-> self draw art-group data 38))) + ) + (while (!= (-> self skel root-channel 0) (-> self skel channel)) + (suspend) + ) ) - ) - (set! (-> s5-0 param 1) (-> (new 'static 'array float 1 1.0) 0)) - (set! (-> s5-0 frame-num) (ja-aframe (the-as float 20.0) 0)) - (joint-control-channel-group! - s5-0 - (the-as art-joint-anim (-> self draw art-group data 34)) - num-func-seek! - ) ) - (until (ja-done? 0) - (let ((a0-33 (-> self skel root-channel 0))) - (set! - (-> a0-33 param 0) - (the float (+ (-> a0-33 frame-group data 0 length) -1)) - ) - (set! (-> a0-33 param 1) (-> (new 'static 'array float 1 1.0) 0)) - (joint-control-channel-group-eval! - a0-33 - (the-as art-joint-anim #f) - num-func-seek! - ) - ) - (suspend) - ) - ) - (else - (ja-channel-push! 1 arg1) - (let ((v1-82 (-> self skel root-channel 0))) - (set! - (-> v1-82 frame-group) - (the-as art-joint-anim (-> self draw art-group data 38)) - ) - ) - (while (!= (-> self skel root-channel 0) (-> self skel channel)) - (suspend) - ) - ) ) - ) (let ((a0-42 (-> self skel root-channel 0))) - (set! - (-> a0-42 frame-group) - (the-as art-joint-anim (-> self draw art-group data 38)) + (set! (-> a0-42 frame-group) (the-as art-joint-anim (-> self draw art-group data 38))) + (set! (-> a0-42 param 0) (-> (new 'static 'array float 1 1.0) 0)) + (set! (-> a0-42 frame-num) 0.0) + (joint-control-channel-group! a0-42 (the-as art-joint-anim (-> self draw art-group data 38)) num-func-loop!) ) - (set! (-> a0-42 param 0) (-> (new 'static 'array float 1 1.0) 0)) - (set! (-> a0-42 frame-num) 0.0) - (joint-control-channel-group! - a0-42 - (the-as art-joint-anim (-> self draw art-group data 38)) - num-func-loop! - ) - ) (let ((s5-1 (-> *display* base-frame-counter))) - (while (or (= arg0 -1) (< (- (-> *display* base-frame-counter) s5-1) arg0)) - (suspend) - (let ((a0-43 (-> self skel root-channel 0))) - (set! - (-> a0-43 frame-group) - (the-as art-joint-anim (-> self draw art-group data 38)) + (while (or (= arg0 -1) (< (- (-> *display* base-frame-counter) s5-1) arg0)) + (suspend) + (let ((a0-43 (-> self skel root-channel 0))) + (set! (-> a0-43 frame-group) (the-as art-joint-anim (-> self draw art-group data 38))) + (set! (-> a0-43 param 0) (-> (new 'static 'array float 1 1.0) 0)) + (joint-control-channel-group-eval! + a0-43 + (the-as art-joint-anim (-> self draw art-group data 38)) + num-func-loop! + ) + ) ) - (set! (-> a0-43 param 0) (-> (new 'static 'array float 1 1.0) 0)) - (joint-control-channel-group-eval! - a0-43 - (the-as art-joint-anim (-> self draw art-group data 38)) - num-func-loop! - ) - ) ) - ) #f ) -;; ERROR: function was not converted to expressions. Cannot decompile. - -(defbehavior target-falling-trans target ((arg0 basic) (arg1 cpad-list)) - (if - (and - (logtest? - (-> - *cpad-list* - cpads - (-> self control unknown-cpad-info00 number) - button0-rel - 0 +;; definition for function target-falling-anim-trans +(defbehavior target-falling-anim-trans target () + (let ((v1-2 (if (> (-> self skel active-channels) 0) + (-> self skel root-channel 0 frame-group) + ) + ) + ) + (b! (or (= v1-2 (-> self draw art-group data 38)) (= v1-2 (-> self draw art-group data 35))) + cfg-7 ) - (pad-buttons circle) - ) - (can-feet?) ) - (go target-attack-air #f) - ) - (when (= arg0 'target-eco-powerup) - (if - (and - (logtest? - (logior - (logior - (-> - *cpad-list* - cpads - (-> self control unknown-cpad-info00 number) - button0-rel - 0 - ) - (-> - *cpad-list* - cpads - (-> self control unknown-cpad-info00 number) - button0-rel - 1 - ) - ) - (-> - *cpad-list* - cpads - (-> self control unknown-cpad-info00 number) - button0-rel - 2 - ) + (ja-channel-push! 1 99) + (let ((v1-8 (-> self skel root-channel 0))) + (set! (-> v1-8 frame-group) (the-as art-joint-anim (-> self draw art-group data 38))) + ) + (b! #t cfg-23 :delay (nop!)) + (label cfg-7) + (cond + ((and (logtest? (-> self control status) 1) (not (= (if (> (-> self skel active-channels) 0) + (-> self skel root-channel 0 frame-group) + ) + (-> self draw art-group data 35) + ) + ) + ) + (ja-channel-push! 1 6) + (let ((v1-21 (-> self skel root-channel 0))) + (set! (-> v1-21 frame-group) (the-as art-joint-anim (-> self draw art-group data 35))) ) - (pad-buttons x) - ) - (zero? (logand (-> self water flags) 512)) - (< (- (-> *display* base-frame-counter) (-> self state-time)) 900) - (zero? (logand (-> self state-flags) 2048)) ) - (go - target-jump - (-> *TARGET-bank* jump-height-min) - (-> *TARGET-bank* jump-height-max) - (the-as surface #f) - ) - ) - ) - (if (logtest? (-> self control status) 1) - (go target-hit-ground #f) - ) - (when - (if - (and - (< - (target-move-dist (the-as int (-> *TARGET-bank* stuck-time))) - (-> *TARGET-bank* stuck-distance) - ) - (>= (the-as int arg1) 0) - (>= - (- (-> *display* base-frame-counter) (-> self state-time)) - (the-as int arg1) - ) - (not - (and - *cheat-mode* - (logtest? - (-> - *cpad-list* - cpads - (-> self control unknown-cpad-info00 number) - button0-abs - 0 - ) - (pad-buttons r2) + ((= (if (> (-> self skel active-channels) 0) + (-> self skel root-channel 0 frame-group) + ) + (-> self draw art-group data 38) ) + (let ((a0-23 (-> self skel root-channel 0))) + (set! (-> a0-23 param 0) (-> (new 'static 'array float 1 1.0) 0)) + (joint-control-channel-group-eval! a0-23 (the-as art-joint-anim #f) num-func-loop!) + ) + ) + ((= (if (> (-> self skel active-channels) 0) + (-> self skel root-channel 0 frame-group) + ) + (-> self draw art-group data 35) + ) + (let ((a0-28 (-> self skel root-channel 0))) + (set! (-> a0-28 param 0) (the float (+ (-> a0-28 frame-group data 0 length) -1))) + (set! (-> a0-28 param 1) (-> (new 'static 'array float 1 1.0) 0)) + (joint-control-channel-group-eval! a0-28 (the-as art-joint-anim #f) num-func-seek!) ) - ) ) - #t ) - (logior! (-> self control status) 1) - (go target-hit-ground 'stuck) - ) - (if (!= (-> self state-time) (-> *display* base-frame-counter)) - (slide-down-test) - ) + (label cfg-23) 0 (none) ) -(defbehavior target-hit-ground-anim target ((arg0 symbol)) - (let ((v1-2 (if (> (-> self skel active-channels) 0) - (-> self skel root-channel 0 frame-group) - ) - ) - ) - (cond - ((or - (= v1-2 (-> self draw art-group data 63)) - (= v1-2 (-> self draw art-group data 64)) - (= v1-2 (-> self draw art-group data 66)) - (= v1-2 (-> self draw art-group data 67)) - ) - (let - ((gp-0 - (or - (= - (-> - *cpad-list* - cpads - (-> self control unknown-cpad-info00 number) - stick0-speed +;; definition for function target-falling-trans +;; INFO: Return type mismatch int vs none. +(defbehavior target-falling-trans target ((arg0 basic) (arg1 cpad-list)) + (if (and (logtest? (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) button0-rel 0) + (pad-buttons circle) + ) + (can-feet?) ) - 0.0 - ) - (< - (-> self control unknown-float01) - (-> (new 'static 'array float 1 61440.0) 0) - ) - ) - ) - (f30-0 (if (= arg0 'swim) - (-> (new 'static 'array float 1 0.4) 0) - (-> (new 'static 'array float 1 1.0) 0) - ) - ) - ) - (ja-channel-set! 1) - (let ((s5-0 (-> self skel root-channel 0))) - (set! (-> s5-0 frame-group) (the-as art-joint-anim (if gp-0 - (-> - self - draw - art-group - data - 65 - ) - (-> - self - draw - art-group - data - 68 - ) - ) - ) - ) - (set! (-> s5-0 param 0) (the float (+ (-> (the-as art-joint-anim (if gp-0 - (-> - self - draw - art-group - data - 65 - ) - (-> - self - draw - art-group - data - 68 - ) - ) - ) - data 0 length - ) - -1 - ) - ) - ) - (let - ((f30-1 - (seek - f30-0 - (-> (new 'static 'array float 1 1.0) 0) - (* 0.5 (-> *display* seconds-per-frame)) - ) - ) - ) - (set! (-> s5-0 param 1) f30-1) - (set! (-> s5-0 frame-num) 0.0) - (joint-control-channel-group! s5-0 (the-as art-joint-anim (if gp-0 - (-> - self - draw - art-group - data - 65 - ) - (-> - self - draw - art-group - data - 68 - ) - ) - ) - num-func-seek! - ) - (until (ja-done? 0) - (TODO-RENAME-9 (-> self align)) - (TODO-RENAME-10 (-> self align) (if gp-0 - 2 - 6 - ) - (-> (new 'static 'array float 1 1.0) 0) - (-> (new 'static 'array float 1 1.0) 0) - (the-as float 1.5) - ) - (when - (and - (>= 25.0 (ja-aframe-num 0)) - (and - (>= (ja-aframe-num 0) 21.0) - (= (-> self next-state name) 'target-flop-hit-ground) - (!= (-> self control unknown-spoolanim00) 'stuck) - ) - ) - (set! (-> self event-hook) target-jump-event-handler) - (when - (and - (logtest? - (-> - *cpad-list* - cpads - (-> self control unknown-cpad-info00 number) - button0-abs - 0 - ) - (pad-buttons x) - ) - (can-jump? #f) - ) - (ja-channel-set! 0) - (go - target-high-jump - (-> *TARGET-bank* flop-jump-height-min) - (-> *TARGET-bank* flop-jump-height-max) - (if gp-0 - 'flop - 'flop-forward - ) - ) - ) - ) - (suspend) - (let ((s5-1 (-> self skel root-channel 0))) - (set! - (-> s5-1 param 0) - (the float (+ (-> s5-1 frame-group data 0 length) -1)) - ) - (set! - f30-1 - (seek - f30-1 - (-> (new 'static 'array float 1 1.0) 0) - (* 0.5 (-> *display* seconds-per-frame)) - ) - ) - (set! (-> s5-1 param 1) f30-1) - (joint-control-channel-group-eval! - s5-1 - (the-as art-joint-anim #f) - num-func-seek! - ) - ) - ) - ) - ) + (go target-attack-air #f) ) - #f - ) - ((and - (= (-> self control ground-pat material) (pat-material ice)) - (< 16384.0 (-> self control unknown-float01)) - ) - #f - ) - ((let ((v1-95 (if (> (-> self skel active-channels) 0) - (-> self skel root-channel 0 frame-group) - ) - ) - ) - (or - (or - (= v1-95 (-> self draw art-group data 38)) - (= v1-95 (-> self draw art-group data 42)) - (= v1-95 (-> self draw art-group data 43)) - ) - (and (= (if (> (-> self skel active-channels) 0) - (-> self skel root-channel 0 frame-group) - ) - (-> self draw art-group data 34) - ) - (>= (ja-aframe-num 0) 38.0) - ) - ) - ) - (ja-channel-push! 1 6) - (let ((a0-35 (-> self skel root-channel 0))) - (set! - (-> a0-35 frame-group) - (the-as art-joint-anim (-> self draw art-group data 35)) - ) - (set! - (-> a0-35 param 0) - (the - float - (+ - (-> - (the-as art-joint-anim (-> self draw art-group data 35)) - data - 0 - length - ) - -1 - ) - ) - ) - (set! (-> a0-35 param 1) (-> (new 'static 'array float 1 1.0) 0)) - (set! (-> a0-35 frame-num) 0.0) - (joint-control-channel-group! - a0-35 - (the-as art-joint-anim (-> self draw art-group data 35)) - num-func-seek! - ) - ) - (until (ja-done? 0) - (suspend) - (let ((a0-36 (-> self skel root-channel 0))) - (set! - (-> a0-36 param 0) - (the float (+ (-> a0-36 frame-group data 0 length) -1)) - ) - (set! (-> a0-36 param 1) (-> (new 'static 'array float 1 1.0) 0)) - (joint-control-channel-group-eval! - a0-36 - (the-as art-joint-anim #f) - num-func-seek! - ) - ) - ) - #f - ) - ((and (= (if (> (-> self skel active-channels) 0) - (-> self skel root-channel 0 frame-group) - ) - (-> self draw art-group data 34) - ) - (>= (ja-aframe-num 0) 35.0) - ) - (ja-channel-set! 1) - (let ((a0-44 (-> self skel root-channel 0))) - (set! - (-> a0-44 frame-group) - (the-as art-joint-anim (-> self draw art-group data 39)) - ) - (set! - (-> a0-44 param 0) - (the - float - (+ - (-> - (the-as art-joint-anim (-> self draw art-group data 39)) - data - 0 - length - ) - -1 - ) - ) - ) - (set! (-> a0-44 param 1) (-> (new 'static 'array float 1 1.0) 0)) - (set! (-> a0-44 frame-num) 0.0) - (joint-control-channel-group! - a0-44 - (the-as art-joint-anim (-> self draw art-group data 39)) - num-func-seek! - ) - ) - (until (ja-done? 0) - (suspend) - (let ((a0-45 (-> self skel root-channel 0))) - (set! - (-> a0-45 param 0) - (the float (+ (-> a0-45 frame-group data 0 length) -1)) - ) - (set! (-> a0-45 param 1) (-> (new 'static 'array float 1 1.0) 0)) - (joint-control-channel-group-eval! - a0-45 - (the-as art-joint-anim #f) - num-func-seek! - ) - ) - ) - (let ((gp-1 (-> self skel root-channel 0))) - (set! - (-> gp-1 frame-group) - (the-as art-joint-anim (-> self draw art-group data 35)) - ) - (set! - (-> gp-1 param 0) - (the - float - (+ - (-> - (the-as art-joint-anim (-> self draw art-group data 35)) - data - 0 - length - ) - -1 - ) - ) - ) - (set! (-> gp-1 param 1) (-> (new 'static 'array float 1 1.0) 0)) - (set! (-> gp-1 frame-num) (ja-aframe (the-as float 50.0) 0)) - (joint-control-channel-group! - gp-1 - (the-as art-joint-anim (-> self draw art-group data 35)) - num-func-seek! - ) - ) - (until (ja-done? 0) - (suspend) - (let ((a0-49 (-> self skel root-channel 0))) - (set! - (-> a0-49 param 0) - (the float (+ (-> a0-49 frame-group data 0 length) -1)) - ) - (set! (-> a0-49 param 1) (-> (new 'static 'array float 1 1.0) 0)) - (joint-control-channel-group-eval! - a0-49 - (the-as art-joint-anim #f) - num-func-seek! - ) - ) - ) - #f - ) - ((let ((v1-187 (if (> (-> self skel active-channels) 0) - (-> self skel root-channel 0 frame-group) - ) - ) - ) - (or - (= v1-187 (-> self draw art-group data 34)) - (= v1-187 (-> self draw art-group data 41)) - ) - ) - (ja-channel-set! 1) - (let ((gp-2 (-> self skel root-channel 0))) - (set! - (-> gp-2 frame-group) - (the-as art-joint-anim (-> self draw art-group data 39)) - ) - (set! - (-> gp-2 param 0) - (the - float - (+ - (-> - (the-as art-joint-anim (-> self draw art-group data 39)) - data - 0 - length - ) - -1 - ) - ) - ) - (set! (-> gp-2 param 1) (-> (new 'static 'array float 1 1.0) 0)) - (set! (-> gp-2 frame-num) (ja-aframe (the-as float 38.0) 0)) - (joint-control-channel-group! - gp-2 - (the-as art-joint-anim (-> self draw art-group data 39)) - num-func-seek! - ) - ) - (until (ja-done? 0) - (suspend) - (let ((a0-61 (-> self skel root-channel 0))) - (set! - (-> a0-61 param 0) - (the float (+ (-> a0-61 frame-group data 0 length) -1)) - ) - (set! (-> a0-61 param 1) (-> (new 'static 'array float 1 1.0) 0)) - (joint-control-channel-group-eval! - a0-61 - (the-as art-joint-anim #f) - num-func-seek! - ) - ) - ) - (let ((gp-3 (-> self skel root-channel 0))) - (set! - (-> gp-3 frame-group) - (the-as art-joint-anim (-> self draw art-group data 35)) - ) - (set! - (-> gp-3 param 0) - (the - float - (+ - (-> - (the-as art-joint-anim (-> self draw art-group data 35)) - data - 0 - length - ) - -1 - ) - ) - ) - (set! (-> gp-3 param 1) (-> (new 'static 'array float 1 1.0) 0)) - (set! (-> gp-3 frame-num) (ja-aframe (the-as float 50.0) 0)) - (joint-control-channel-group! - gp-3 - (the-as art-joint-anim (-> self draw art-group data 35)) - num-func-seek! - ) - ) - (until (ja-done? 0) - (suspend) - (let ((a0-65 (-> self skel root-channel 0))) - (set! - (-> a0-65 param 0) - (the float (+ (-> a0-65 frame-group data 0 length) -1)) - ) - (set! (-> a0-65 param 1) (-> (new 'static 'array float 1 1.0) 0)) - (joint-control-channel-group-eval! - a0-65 - (the-as art-joint-anim #f) - num-func-seek! - ) - ) - ) - #f - ) - ((let ((v1-242 (if (> (-> self skel active-channels) 0) - (-> self skel root-channel 0 frame-group) - ) - ) - ) - (or - (= v1-242 (-> self draw art-group data 73)) - (= v1-242 (-> self draw art-group data 74)) - ) - ) - (let ((f30-2 (if (= (if (> (-> self skel active-channels) 0) - (-> self skel root-channel 0 frame-group) - ) - (-> self draw art-group data 74) + (when (= arg0 'target-eco-powerup) + (if (and (logtest? (logior (logior (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) button0-rel 0) + (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) button0-rel 1) + ) + (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) button0-rel 2) + ) + (pad-buttons x) ) - (-> (new 'static 'array float 1 24576.0) 0) - (-> (new 'static 'array float 1 -24576.0) 0) - ) - ) - ) - (ja-channel-push! 1 12) - (let ((gp-4 (-> self skel root-channel 0))) - (set! - (-> gp-4 frame-group) - (the-as art-joint-anim (-> self draw art-group data 39)) + (zero? (logand (-> self water flags) 512)) + (< (- (-> *display* base-frame-counter) (-> self state-time)) 900) + (zero? (logand (-> self state-flags) 2048)) + ) + (go target-jump (-> *TARGET-bank* jump-height-min) (-> *TARGET-bank* jump-height-max) (the-as surface #f)) ) - (set! - (-> gp-4 param 0) - (the - float - (+ - (-> - (the-as art-joint-anim (-> self draw art-group data 39)) - data - 0 - length - ) - -1 - ) - ) - ) - (set! (-> gp-4 param 1) (-> (new 'static 'array float 1 1.0) 0)) - (set! (-> gp-4 frame-num) (ja-aframe (the-as float 38.0) 0)) - (joint-control-channel-group! - gp-4 - (the-as art-joint-anim (-> self draw art-group data 39)) - num-func-seek! - ) - ) - (until (ja-done? 0) - (set-forward-vel f30-2) - (suspend) - (let ((a0-82 (-> self skel root-channel 0))) - (set! - (-> a0-82 param 0) - (the float (+ (-> a0-82 frame-group data 0 length) -1)) - ) - (set! (-> a0-82 param 1) (-> (new 'static 'array float 1 1.0) 0)) - (joint-control-channel-group-eval! - a0-82 - (the-as art-joint-anim #f) - num-func-seek! - ) - ) - ) - ) - (let ((gp-5 (-> self skel root-channel 0))) - (set! - (-> gp-5 frame-group) - (the-as art-joint-anim (-> self draw art-group data 35)) - ) - (set! - (-> gp-5 param 0) - (the - float - (+ - (-> - (the-as art-joint-anim (-> self draw art-group data 35)) - data - 0 - length - ) - -1 - ) - ) - ) - (set! (-> gp-5 param 1) (-> (new 'static 'array float 1 1.0) 0)) - (set! (-> gp-5 frame-num) (ja-aframe (the-as float 50.0) 0)) - (joint-control-channel-group! - gp-5 - (the-as art-joint-anim (-> self draw art-group data 35)) - num-func-seek! - ) - ) - (until (ja-done? 0) - (suspend) - (let ((a0-86 (-> self skel root-channel 0))) - (set! - (-> a0-86 param 0) - (the float (+ (-> a0-86 frame-group data 0 length) -1)) - ) - (set! (-> a0-86 param 1) (-> (new 'static 'array float 1 1.0) 0)) - (joint-control-channel-group-eval! - a0-86 - (the-as art-joint-anim #f) - num-func-seek! - ) - ) - ) - #f - ) - ((let ((v1-305 (if (> (-> self skel active-channels) 0) - (-> self skel root-channel 0 frame-group) - ) - ) - ) - (or - (= v1-305 (-> self draw art-group data 34)) - (= v1-305 (-> self draw art-group data 56)) - (= v1-305 (-> self draw art-group data 57)) - (= v1-305 (-> self draw art-group data 58)) - (= v1-305 (-> self draw art-group data 68)) - (= v1-305 (-> self draw art-group data 65)) - (= v1-305 (-> self draw art-group data 62)) - ) - ) - (ja-channel-push! 1 12) - (let ((gp-6 (-> self skel root-channel 0))) - (set! - (-> gp-6 frame-group) - (the-as art-joint-anim (-> self draw art-group data 35)) - ) - (set! - (-> gp-6 param 0) - (the - float - (+ - (-> - (the-as art-joint-anim (-> self draw art-group data 35)) - data - 0 - length - ) - -1 - ) - ) - ) - (set! (-> gp-6 param 1) (-> (new 'static 'array float 1 1.0) 0)) - (set! (-> gp-6 frame-num) (ja-aframe (the-as float 42.0) 0)) - (joint-control-channel-group! - gp-6 - (the-as art-joint-anim (-> self draw art-group data 35)) - num-func-seek! - ) - ) - (until (ja-done? 0) - (suspend) - (let ((a0-113 (-> self skel root-channel 0))) - (set! - (-> a0-113 param 0) - (the float (+ (-> a0-113 frame-group data 0 length) -1)) - ) - (set! (-> a0-113 param 1) (-> (new 'static 'array float 1 1.0) 0)) - (joint-control-channel-group-eval! - a0-113 - (the-as art-joint-anim #f) - num-func-seek! - ) - ) - ) - #f - ) - ((= (if (> (-> self skel active-channels) 0) - (-> self skel root-channel 0 frame-group) - ) - (-> self draw art-group data 35) - ) - (let ((a0-119 (-> self skel root-channel 0))) - (set! - (-> a0-119 param 0) - (the float (+ (-> a0-119 frame-group data 0 length) -1)) - ) - (set! (-> a0-119 param 1) (-> (new 'static 'array float 1 1.0) 0)) - (joint-control-channel-group! - a0-119 - (the-as art-joint-anim #f) - num-func-seek! - ) - ) - (while (not (ja-done? 0)) - (suspend) - (ja-eval) - ) - #f - ) ) - ) + (if (logtest? (-> self control status) 1) + (go target-hit-ground #f) + ) + (when (if (and (< (target-move-dist (the-as int (-> *TARGET-bank* stuck-time))) (-> *TARGET-bank* stuck-distance)) + (>= (the-as int arg1) 0) + (>= (- (-> *display* base-frame-counter) (-> self state-time)) (the-as int arg1)) + (not + (and *cheat-mode* + (logtest? (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) button0-abs 0) (pad-buttons r2)) + ) + ) + ) + #t + ) + (logior! (-> self control status) 1) + (go target-hit-ground 'stuck) + ) + (if (!= (-> self state-time) (-> *display* base-frame-counter)) + (slide-down-test) + ) + 0 + (none) ) +;; definition for function target-hit-ground-anim +(defbehavior target-hit-ground-anim target ((arg0 symbol)) + (let ((v1-2 (if (> (-> self skel active-channels) 0) + (-> self skel root-channel 0 frame-group) + ) + ) + ) + (cond + ((or (= v1-2 (-> self draw art-group data 63)) + (= v1-2 (-> self draw art-group data 64)) + (= v1-2 (-> self draw art-group data 66)) + (= v1-2 (-> self draw art-group data 67)) + ) + (let ((gp-0 (or (= (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) stick0-speed) 0.0) + (< (-> self control unknown-float01) (-> (new 'static 'array float 1 61440.0) 0)) + ) + ) + (f30-0 (if (= arg0 'swim) + (-> (new 'static 'array float 1 0.4) 0) + (-> (new 'static 'array float 1 1.0) 0) + ) + ) + ) + (ja-channel-set! 1) + (let ((s5-0 (-> self skel root-channel 0))) + (set! (-> s5-0 frame-group) (the-as art-joint-anim (if gp-0 + (-> self draw art-group data 65) + (-> self draw art-group data 68) + ) + ) + ) + (set! (-> s5-0 param 0) (the float (+ (-> (the-as art-joint-anim (if gp-0 + (-> self draw art-group data 65) + (-> self draw art-group data 68) + ) + ) + data + 0 + length + ) + -1 + ) + ) + ) + (let ((f30-1 (seek f30-0 (-> (new 'static 'array float 1 1.0) 0) (* 0.5 (-> *display* seconds-per-frame))))) + (set! (-> s5-0 param 1) f30-1) + (set! (-> s5-0 frame-num) 0.0) + (joint-control-channel-group! + s5-0 + (the-as art-joint-anim (if gp-0 + (-> self draw art-group data 65) + (-> self draw art-group data 68) + ) + ) + num-func-seek! + ) + (until (ja-done? 0) + (TODO-RENAME-9 (-> self align)) + (TODO-RENAME-10 + (-> self align) + (if gp-0 + 2 + 6 + ) + (-> (new 'static 'array float 1 1.0) 0) + (-> (new 'static 'array float 1 1.0) 0) + (the-as float 1.5) + ) + (when (and (>= 25.0 (ja-aframe-num 0)) (and (>= (ja-aframe-num 0) 21.0) + (= (-> self next-state name) 'target-flop-hit-ground) + (!= (-> self control unknown-spoolanim00) 'stuck) + ) + ) + (set! (-> self event-hook) target-jump-event-handler) + (when (and (logtest? (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) button0-abs 0) (pad-buttons x)) + (can-jump? #f) + ) + (ja-channel-set! 0) + (go + target-high-jump + (-> *TARGET-bank* flop-jump-height-min) + (-> *TARGET-bank* flop-jump-height-max) + (if gp-0 + 'flop + 'flop-forward + ) + ) + ) + ) + (suspend) + (let ((s5-1 (-> self skel root-channel 0))) + (set! (-> s5-1 param 0) (the float (+ (-> s5-1 frame-group data 0 length) -1))) + (set! f30-1 (seek f30-1 (-> (new 'static 'array float 1 1.0) 0) (* 0.5 (-> *display* seconds-per-frame)))) + (set! (-> s5-1 param 1) f30-1) + (joint-control-channel-group-eval! s5-1 (the-as art-joint-anim #f) num-func-seek!) + ) + ) + ) + ) + ) + #f + ) + ((and (= (-> self control ground-pat material) (pat-material ice)) + (< 16384.0 (-> self control unknown-float01)) + ) + #f + ) + ((let ((v1-95 (if (> (-> self skel active-channels) 0) + (-> self skel root-channel 0 frame-group) + ) + ) + ) + (or (or (= v1-95 (-> self draw art-group data 38)) + (= v1-95 (-> self draw art-group data 42)) + (= v1-95 (-> self draw art-group data 43)) + ) + (and (= (if (> (-> self skel active-channels) 0) + (-> self skel root-channel 0 frame-group) + ) + (-> self draw art-group data 34) + ) + (>= (ja-aframe-num 0) 38.0) + ) + ) + ) + (ja-channel-push! 1 6) + (let ((a0-35 (-> self skel root-channel 0))) + (set! (-> a0-35 frame-group) (the-as art-joint-anim (-> self draw art-group data 35))) + (set! (-> a0-35 param 0) + (the float (+ (-> (the-as art-joint-anim (-> self draw art-group data 35)) data 0 length) -1)) + ) + (set! (-> a0-35 param 1) (-> (new 'static 'array float 1 1.0) 0)) + (set! (-> a0-35 frame-num) 0.0) + (joint-control-channel-group! a0-35 (the-as art-joint-anim (-> self draw art-group data 35)) num-func-seek!) + ) + (until (ja-done? 0) + (suspend) + (let ((a0-36 (-> self skel root-channel 0))) + (set! (-> a0-36 param 0) (the float (+ (-> a0-36 frame-group data 0 length) -1))) + (set! (-> a0-36 param 1) (-> (new 'static 'array float 1 1.0) 0)) + (joint-control-channel-group-eval! a0-36 (the-as art-joint-anim #f) num-func-seek!) + ) + ) + #f + ) + ((and (= (if (> (-> self skel active-channels) 0) + (-> self skel root-channel 0 frame-group) + ) + (-> self draw art-group data 34) + ) + (>= (ja-aframe-num 0) 35.0) + ) + (ja-channel-set! 1) + (let ((a0-44 (-> self skel root-channel 0))) + (set! (-> a0-44 frame-group) (the-as art-joint-anim (-> self draw art-group data 39))) + (set! (-> a0-44 param 0) + (the float (+ (-> (the-as art-joint-anim (-> self draw art-group data 39)) data 0 length) -1)) + ) + (set! (-> a0-44 param 1) (-> (new 'static 'array float 1 1.0) 0)) + (set! (-> a0-44 frame-num) 0.0) + (joint-control-channel-group! a0-44 (the-as art-joint-anim (-> self draw art-group data 39)) num-func-seek!) + ) + (until (ja-done? 0) + (suspend) + (let ((a0-45 (-> self skel root-channel 0))) + (set! (-> a0-45 param 0) (the float (+ (-> a0-45 frame-group data 0 length) -1))) + (set! (-> a0-45 param 1) (-> (new 'static 'array float 1 1.0) 0)) + (joint-control-channel-group-eval! a0-45 (the-as art-joint-anim #f) num-func-seek!) + ) + ) + (let ((gp-1 (-> self skel root-channel 0))) + (set! (-> gp-1 frame-group) (the-as art-joint-anim (-> self draw art-group data 35))) + (set! (-> gp-1 param 0) + (the float (+ (-> (the-as art-joint-anim (-> self draw art-group data 35)) data 0 length) -1)) + ) + (set! (-> gp-1 param 1) (-> (new 'static 'array float 1 1.0) 0)) + (set! (-> gp-1 frame-num) (ja-aframe (the-as float 50.0) 0)) + (joint-control-channel-group! gp-1 (the-as art-joint-anim (-> self draw art-group data 35)) num-func-seek!) + ) + (until (ja-done? 0) + (suspend) + (let ((a0-49 (-> self skel root-channel 0))) + (set! (-> a0-49 param 0) (the float (+ (-> a0-49 frame-group data 0 length) -1))) + (set! (-> a0-49 param 1) (-> (new 'static 'array float 1 1.0) 0)) + (joint-control-channel-group-eval! a0-49 (the-as art-joint-anim #f) num-func-seek!) + ) + ) + #f + ) + ((let ((v1-187 (if (> (-> self skel active-channels) 0) + (-> self skel root-channel 0 frame-group) + ) + ) + ) + (or (= v1-187 (-> self draw art-group data 34)) (= v1-187 (-> self draw art-group data 41))) + ) + (ja-channel-set! 1) + (let ((gp-2 (-> self skel root-channel 0))) + (set! (-> gp-2 frame-group) (the-as art-joint-anim (-> self draw art-group data 39))) + (set! (-> gp-2 param 0) + (the float (+ (-> (the-as art-joint-anim (-> self draw art-group data 39)) data 0 length) -1)) + ) + (set! (-> gp-2 param 1) (-> (new 'static 'array float 1 1.0) 0)) + (set! (-> gp-2 frame-num) (ja-aframe (the-as float 38.0) 0)) + (joint-control-channel-group! gp-2 (the-as art-joint-anim (-> self draw art-group data 39)) num-func-seek!) + ) + (until (ja-done? 0) + (suspend) + (let ((a0-61 (-> self skel root-channel 0))) + (set! (-> a0-61 param 0) (the float (+ (-> a0-61 frame-group data 0 length) -1))) + (set! (-> a0-61 param 1) (-> (new 'static 'array float 1 1.0) 0)) + (joint-control-channel-group-eval! a0-61 (the-as art-joint-anim #f) num-func-seek!) + ) + ) + (let ((gp-3 (-> self skel root-channel 0))) + (set! (-> gp-3 frame-group) (the-as art-joint-anim (-> self draw art-group data 35))) + (set! (-> gp-3 param 0) + (the float (+ (-> (the-as art-joint-anim (-> self draw art-group data 35)) data 0 length) -1)) + ) + (set! (-> gp-3 param 1) (-> (new 'static 'array float 1 1.0) 0)) + (set! (-> gp-3 frame-num) (ja-aframe (the-as float 50.0) 0)) + (joint-control-channel-group! gp-3 (the-as art-joint-anim (-> self draw art-group data 35)) num-func-seek!) + ) + (until (ja-done? 0) + (suspend) + (let ((a0-65 (-> self skel root-channel 0))) + (set! (-> a0-65 param 0) (the float (+ (-> a0-65 frame-group data 0 length) -1))) + (set! (-> a0-65 param 1) (-> (new 'static 'array float 1 1.0) 0)) + (joint-control-channel-group-eval! a0-65 (the-as art-joint-anim #f) num-func-seek!) + ) + ) + #f + ) + ((let ((v1-242 (if (> (-> self skel active-channels) 0) + (-> self skel root-channel 0 frame-group) + ) + ) + ) + (or (= v1-242 (-> self draw art-group data 73)) (= v1-242 (-> self draw art-group data 74))) + ) + (let ((f30-2 (if (= (if (> (-> self skel active-channels) 0) + (-> self skel root-channel 0 frame-group) + ) + (-> self draw art-group data 74) + ) + (-> (new 'static 'array float 1 24576.0) 0) + (-> (new 'static 'array float 1 -24576.0) 0) + ) + ) + ) + (ja-channel-push! 1 12) + (let ((gp-4 (-> self skel root-channel 0))) + (set! (-> gp-4 frame-group) (the-as art-joint-anim (-> self draw art-group data 39))) + (set! (-> gp-4 param 0) + (the float (+ (-> (the-as art-joint-anim (-> self draw art-group data 39)) data 0 length) -1)) + ) + (set! (-> gp-4 param 1) (-> (new 'static 'array float 1 1.0) 0)) + (set! (-> gp-4 frame-num) (ja-aframe (the-as float 38.0) 0)) + (joint-control-channel-group! gp-4 (the-as art-joint-anim (-> self draw art-group data 39)) num-func-seek!) + ) + (until (ja-done? 0) + (set-forward-vel f30-2) + (suspend) + (let ((a0-82 (-> self skel root-channel 0))) + (set! (-> a0-82 param 0) (the float (+ (-> a0-82 frame-group data 0 length) -1))) + (set! (-> a0-82 param 1) (-> (new 'static 'array float 1 1.0) 0)) + (joint-control-channel-group-eval! a0-82 (the-as art-joint-anim #f) num-func-seek!) + ) + ) + ) + (let ((gp-5 (-> self skel root-channel 0))) + (set! (-> gp-5 frame-group) (the-as art-joint-anim (-> self draw art-group data 35))) + (set! (-> gp-5 param 0) + (the float (+ (-> (the-as art-joint-anim (-> self draw art-group data 35)) data 0 length) -1)) + ) + (set! (-> gp-5 param 1) (-> (new 'static 'array float 1 1.0) 0)) + (set! (-> gp-5 frame-num) (ja-aframe (the-as float 50.0) 0)) + (joint-control-channel-group! gp-5 (the-as art-joint-anim (-> self draw art-group data 35)) num-func-seek!) + ) + (until (ja-done? 0) + (suspend) + (let ((a0-86 (-> self skel root-channel 0))) + (set! (-> a0-86 param 0) (the float (+ (-> a0-86 frame-group data 0 length) -1))) + (set! (-> a0-86 param 1) (-> (new 'static 'array float 1 1.0) 0)) + (joint-control-channel-group-eval! a0-86 (the-as art-joint-anim #f) num-func-seek!) + ) + ) + #f + ) + ((let ((v1-305 (if (> (-> self skel active-channels) 0) + (-> self skel root-channel 0 frame-group) + ) + ) + ) + (or (= v1-305 (-> self draw art-group data 34)) + (= v1-305 (-> self draw art-group data 56)) + (= v1-305 (-> self draw art-group data 57)) + (= v1-305 (-> self draw art-group data 58)) + (= v1-305 (-> self draw art-group data 68)) + (= v1-305 (-> self draw art-group data 65)) + (= v1-305 (-> self draw art-group data 62)) + ) + ) + (ja-channel-push! 1 12) + (let ((gp-6 (-> self skel root-channel 0))) + (set! (-> gp-6 frame-group) (the-as art-joint-anim (-> self draw art-group data 35))) + (set! (-> gp-6 param 0) + (the float (+ (-> (the-as art-joint-anim (-> self draw art-group data 35)) data 0 length) -1)) + ) + (set! (-> gp-6 param 1) (-> (new 'static 'array float 1 1.0) 0)) + (set! (-> gp-6 frame-num) (ja-aframe (the-as float 42.0) 0)) + (joint-control-channel-group! gp-6 (the-as art-joint-anim (-> self draw art-group data 35)) num-func-seek!) + ) + (until (ja-done? 0) + (suspend) + (let ((a0-113 (-> self skel root-channel 0))) + (set! (-> a0-113 param 0) (the float (+ (-> a0-113 frame-group data 0 length) -1))) + (set! (-> a0-113 param 1) (-> (new 'static 'array float 1 1.0) 0)) + (joint-control-channel-group-eval! a0-113 (the-as art-joint-anim #f) num-func-seek!) + ) + ) + #f + ) + ((= (if (> (-> self skel active-channels) 0) + (-> self skel root-channel 0 frame-group) + ) + (-> self draw art-group data 35) + ) + (let ((a0-119 (-> self skel root-channel 0))) + (set! (-> a0-119 param 0) (the float (+ (-> a0-119 frame-group data 0 length) -1))) + (set! (-> a0-119 param 1) (-> (new 'static 'array float 1 1.0) 0)) + (joint-control-channel-group! a0-119 (the-as art-joint-anim #f) num-func-seek!) + ) + (while (not (ja-done? 0)) + (suspend) + (ja-eval) + ) + #f + ) + ) + ) + ) + +;; failed to figure out what this is: (defstate target-startup (target) :event target-standard-event-handler :code (behavior () - (suspend) - (suspend) - (go target-stance) - (none) - ) + (suspend) + (suspend) + (go target-stance) + (none) + ) :post target-no-move-post ) +;; failed to figure out what this is: (defstate target-stance (target) :event target-standard-event-handler :enter (behavior () - (set! (-> self control unknown-surface00) *walk-mods*) - (set! (-> self state-time) (-> *display* base-frame-counter)) - (none) - ) + (set! (-> self control unknown-surface00) *walk-mods*) + (set! (-> self state-time) (-> *display* base-frame-counter)) + (none) + ) :exit (behavior () - (set! (-> self control unknown-float81) 0.0) - (target-state-hook-exit) - (none) - ) + (set! (-> self control unknown-float81) 0.0) + (target-state-hook-exit) + (none) + ) :trans (behavior () - ((-> self state-hook)) - (if (logtest? (-> self water flags) 1024) - (go target-wade-stance) - ) - (when (= (-> self control ground-pat material) (pat-material ice)) - (set! (-> self control unknown-float81) 0.0) - (remove-exit) - (go target-ice-stance) - ) - (when (move-legs?) - (set! (-> self control unknown-float81) 0.0) - (remove-exit) - (go target-walk) - ) - (when - (and - (logtest? - (-> - *cpad-list* - cpads - (-> self control unknown-cpad-info00 number) - button0-abs - 0 - ) - (pad-buttons l1 r1) + ((-> self state-hook)) + (if (logtest? (-> self water flags) 1024) + (go target-wade-stance) + ) + (when (= (-> self control ground-pat material) (pat-material ice)) + (set! (-> self control unknown-float81) 0.0) + (remove-exit) + (go target-ice-stance) ) - (can-duck?) - ) - (set! (-> self control unknown-float81) 0.0) - (remove-exit) - (go target-duck-stance) - ) - (if - (and - (logtest? - (logior - (logior - (-> - *cpad-list* - cpads - (-> self control unknown-cpad-info00 number) - button0-rel - 0 - ) - (-> - *cpad-list* - cpads - (-> self control unknown-cpad-info00 number) - button0-rel - 1 - ) - ) - (-> - *cpad-list* - cpads - (-> self control unknown-cpad-info00 number) - button0-rel - 2 - ) - ) - (pad-buttons x) + (when (move-legs?) + (set! (-> self control unknown-float81) 0.0) + (remove-exit) + (go target-walk) ) - (can-jump? #f) - ) - (go - target-jump - (-> *TARGET-bank* jump-height-min) - (-> *TARGET-bank* jump-height-max) - (the-as surface #f) - ) - ) - (if - (and - (logtest? - (logior - (logior - (-> - *cpad-list* - cpads - (-> self control unknown-cpad-info00 number) - button0-rel - 0 - ) - (-> - *cpad-list* - cpads - (-> self control unknown-cpad-info00 number) - button0-rel - 1 - ) - ) - (-> - *cpad-list* - cpads - (-> self control unknown-cpad-info00 number) - button0-rel - 2 - ) - ) - (pad-buttons circle) + (when (and (logtest? (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) button0-abs 0) + (pad-buttons l1 r1) + ) + (can-duck?) + ) + (set! (-> self control unknown-float81) 0.0) + (remove-exit) + (go target-duck-stance) ) - (can-feet?) - ) - (go target-attack) + (if (and (logtest? (logior (logior (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) button0-rel 0) + (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) button0-rel 1) + ) + (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) button0-rel 2) + ) + (pad-buttons x) + ) + (can-jump? #f) + ) + (go target-jump (-> *TARGET-bank* jump-height-min) (-> *TARGET-bank* jump-height-max) (the-as surface #f)) + ) + (if (and (logtest? (logior (logior (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) button0-rel 0) + (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) button0-rel 1) + ) + (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) button0-rel 2) + ) + (pad-buttons circle) + ) + (can-feet?) + ) + (go target-attack) + ) + (if (can-hands? #t) + (go target-running-attack) + ) + (slide-down-test) + (fall-test) + (none) ) - (if (can-hands? #t) - (go target-running-attack) - ) - (slide-down-test) - (fall-test) - (none) - ) :code (behavior () - (let ((s5-0 22) - (gp-0 (new 'stack 'ground-tween-info)) - ) - (let ((v1-3 (if (> (-> self skel active-channels) 0) - (-> self skel root-channel 0 frame-group) - ) - ) + (let ((s5-0 22) + (gp-0 (new 'stack 'ground-tween-info)) ) - (cond - ((or - (= v1-3 (-> self draw art-group data 89)) - (= v1-3 (-> self draw art-group data 90)) - ) - (set! s5-0 45) - ) - ((= (if (> (-> self skel active-channels) 0) - (-> self skel root-channel 0 frame-group) - ) - (-> self draw art-group data 71) - ) - (let ((a0-12 (-> self skel root-channel 0))) - (set! - (-> a0-12 frame-group) - (the-as art-joint-anim (-> self draw art-group data 72)) - ) - (set! - (-> a0-12 param 0) - (the - float - (+ - (-> - (the-as art-joint-anim (-> self draw art-group data 72)) - data - 0 - length - ) - -1 - ) - ) - ) - (set! (-> a0-12 param 1) (-> (new 'static 'array float 1 1.0) 0)) - (set! (-> a0-12 frame-num) 0.0) - (joint-control-channel-group! - a0-12 - (the-as art-joint-anim (-> self draw art-group data 72)) - num-func-seek! - ) - ) - (until (ja-done? 0) - (suspend) - (let ((a0-13 (-> self skel root-channel 0))) - (set! - (-> a0-13 param 0) - (the float (+ (-> a0-13 frame-group data 0 length) -1)) - ) - (set! (-> a0-13 param 1) (-> (new 'static 'array float 1 1.0) 0)) - (joint-control-channel-group-eval! - a0-13 - (the-as art-joint-anim #f) - num-func-seek! - ) - ) - ) - ) - ((= (if (> (-> self skel active-channels) 0) - (-> self skel root-channel 0 frame-group) - ) - (-> self draw art-group data 51) - ) - (cond - ((rand-vu-percent? (the-as float 0.3)) - (let ((a0-20 (-> self skel root-channel 0))) - (set! - (-> a0-20 frame-group) - (the-as art-joint-anim (-> self draw art-group data 53)) - ) - (set! - (-> a0-20 param 0) - (the - float - (+ - (-> - (the-as art-joint-anim (-> self draw art-group data 53)) - data - 0 - length - ) - -1 - ) - ) - ) - (set! (-> a0-20 param 1) (-> (new 'static 'array float 1 1.0) 0)) - (set! (-> a0-20 frame-num) 0.0) - (joint-control-channel-group! - a0-20 - (the-as art-joint-anim (-> self draw art-group data 53)) - num-func-seek! - ) - ) - (until (ja-done? 0) - (suspend) - (let ((a0-21 (-> self skel root-channel 0))) - (set! - (-> a0-21 param 0) - (the float (+ (-> a0-21 frame-group data 0 length) -1)) - ) - (set! (-> a0-21 param 1) (-> (new 'static 'array float 1 1.0) 0)) - (joint-control-channel-group-eval! - a0-21 - (the-as art-joint-anim #f) - num-func-seek! - ) - ) - ) - ) - (else - (let ((a0-23 (-> self skel root-channel 0))) - (set! - (-> a0-23 frame-group) - (the-as art-joint-anim (-> self draw art-group data 52)) - ) - (set! - (-> a0-23 param 0) - (the - float - (+ - (-> - (the-as art-joint-anim (-> self draw art-group data 52)) - data - 0 - length - ) - -1 - ) - ) - ) - (set! (-> a0-23 param 1) (-> (new 'static 'array float 1 1.0) 0)) - (set! (-> a0-23 frame-num) 0.0) - (joint-control-channel-group! - a0-23 - (the-as art-joint-anim (-> self draw art-group data 52)) - num-func-seek! - ) - ) - (until (ja-done? 0) - (suspend) - (let ((a0-24 (-> self skel root-channel 0))) - (set! - (-> a0-24 param 0) - (the float (+ (-> a0-24 frame-group data 0 length) -1)) - ) - (set! (-> a0-24 param 1) (-> (new 'static 'array float 1 1.0) 0)) - (joint-control-channel-group-eval! - a0-24 - (the-as art-joint-anim #f) - num-func-seek! - ) - ) - ) - ) - ) - ) - ((= (if (> (-> self skel active-channels) 0) - (-> self skel root-channel 0 frame-group) - ) - (-> self draw art-group data 78) - ) - (let ((a0-30 (-> self skel root-channel 0))) - (set! - (-> a0-30 frame-group) - (the-as art-joint-anim (-> self draw art-group data 79)) - ) - (set! - (-> a0-30 param 0) - (the - float - (+ - (-> - (the-as art-joint-anim (-> self draw art-group data 79)) - data - 0 - length - ) - -1 - ) - ) - ) - (set! (-> a0-30 param 1) (-> (new 'static 'array float 1 1.0) 0)) - (set! (-> a0-30 frame-num) 0.0) - (joint-control-channel-group! - a0-30 - (the-as art-joint-anim (-> self draw art-group data 79)) - num-func-seek! - ) - ) - (until (ja-done? 0) - (suspend) - (let ((a0-31 (-> self skel root-channel 0))) - (set! - (-> a0-31 param 0) - (the float (+ (-> a0-31 frame-group data 0 length) -1)) - ) - (set! (-> a0-31 param 1) (-> (new 'static 'array float 1 1.0) 0)) - (joint-control-channel-group-eval! - a0-31 - (the-as art-joint-anim #f) - num-func-seek! - ) - ) - ) - ) - ((= (if (> (-> self skel active-channels) 0) - (-> self skel root-channel 0 frame-group) - ) - (-> self draw art-group data 84) - ) - (let ((a0-37 (-> self skel root-channel 0))) - (set! - (-> a0-37 frame-group) - (the-as art-joint-anim (-> self draw art-group data 85)) - ) - (set! - (-> a0-37 param 0) - (the - float - (+ - (-> - (the-as art-joint-anim (-> self draw art-group data 85)) - data - 0 - length - ) - -1 - ) - ) - ) - (set! (-> a0-37 param 1) (-> (new 'static 'array float 1 1.0) 0)) - (set! (-> a0-37 frame-num) 0.0) - (joint-control-channel-group! - a0-37 - (the-as art-joint-anim (-> self draw art-group data 85)) - num-func-seek! - ) - ) - (until (ja-done? 0) - (suspend) - (let ((a0-38 (-> self skel root-channel 0))) - (set! - (-> a0-38 param 0) - (the float (+ (-> a0-38 frame-group data 0 length) -1)) - ) - (set! (-> a0-38 param 1) (-> (new 'static 'array float 1 1.0) 0)) - (joint-control-channel-group-eval! - a0-38 - (the-as art-joint-anim #f) - num-func-seek! - ) - ) - ) - (set! s5-0 0) - ) - ((= (if (> (-> self skel active-channels) 0) - (-> self skel root-channel 0 frame-group) - ) - (-> self draw art-group data 59) - ) - (set! - (-> self control unknown-float81) - (-> self control unknown-float80) - ) - (set! (-> self control unknown-surface00) *walk-no-turn-mods*) - (let ((s4-0 (-> self skel root-channel 0))) - (set! - (-> s4-0 frame-group) - (the-as art-joint-anim (if (rand-vu-percent? (the-as float 0.3)) - (-> self draw art-group data 61) - (-> self draw art-group data 60) - ) - ) - ) - (set! - (-> s4-0 param 0) - (the - float - (+ - (-> (the-as art-joint-anim (if (rand-vu-percent? (the-as float 0.3)) - (-> self draw art-group data 61) - (-> self draw art-group data 60) - ) - ) - data 0 length - ) - -1 - ) - ) - ) - (set! (-> s4-0 param 1) (-> (new 'static 'array float 1 1.0) 0)) - (set! (-> s4-0 frame-num) 0.0) - (joint-control-channel-group! - s4-0 - (the-as art-joint-anim (if (rand-vu-percent? (the-as float 0.3)) - (-> self draw art-group data 61) - (-> self draw art-group data 60) - ) - ) - num-func-seek! - ) - ) - (until (ja-done? 0) - (set! - (-> self control unknown-float81) - (seek - (-> self control unknown-float81) - (-> (new 'static 'array float 1 0.0) 0) - (-> *display* seconds-per-frame) - ) - ) - (suspend) - (let ((a0-50 (-> self skel root-channel 0))) - (set! - (-> a0-50 param 0) - (the float (+ (-> a0-50 frame-group data 0 length) -1)) - ) - (set! (-> a0-50 param 1) (-> (new 'static 'array float 1 1.0) 0)) - (joint-control-channel-group-eval! - a0-50 - (the-as art-joint-anim #f) - num-func-seek! - ) - ) - ) - (set! (-> self control unknown-surface00) *walk-mods*) - (set! (-> self control unknown-float81) 0.0) - (rot->dir-targ! (-> self control)) - ) - ((let ((v1-206 (if (> (-> self skel active-channels) 0) + (let ((v1-3 (if (> (-> self skel active-channels) 0) (-> self skel root-channel 0 frame-group) ) - ) - ) - (or - (= v1-206 (-> self draw art-group data 31)) - (= v1-206 (-> self draw art-group data 32)) - ) - ) - (ja-channel-push! 1 12) - (let ((a0-62 (-> self skel root-channel 0))) - (set! - (-> a0-62 frame-group) - (the-as art-joint-anim (-> self draw art-group data 30)) - ) - (set! (-> a0-62 param 0) 0.0) - (set! (-> a0-62 param 1) 1.2) - (set! - (-> a0-62 frame-num) - (the - float - (+ - (-> - (the-as art-joint-anim (-> self draw art-group data 30)) - data - 0 - length + ) ) - -1 + (cond + ((or (= v1-3 (-> self draw art-group data 89)) (= v1-3 (-> self draw art-group data 90))) + (set! s5-0 45) ) - ) - ) - (joint-control-channel-group! - a0-62 - (the-as art-joint-anim (-> self draw art-group data 30)) - num-func-seek! - ) - ) - (until (ja-done? 0) - (suspend) - (let ((a0-63 (-> self skel root-channel 0))) - (set! (-> a0-63 param 0) 0.0) - (set! (-> a0-63 param 1) 1.2) - (joint-control-channel-group-eval! - a0-63 - (the-as art-joint-anim #f) - num-func-seek! - ) - ) - ) - (set! s5-0 12) - ) - ((or (and (= (if (> (-> self skel active-channels) 0) - (-> self skel root-channel 0 frame-group) - ) - (-> self draw art-group data 23) - ) - (begin - (set! s5-0 45) - (< 0.5 (-> self skel root-channel 6 frame-interp)) - ) - ) - (let ((v1-243 (if (> (-> self skel active-channels) 0) - (-> self skel root-channel 0 frame-group) - ) - ) + ((= (if (> (-> self skel active-channels) 0) + (-> self skel root-channel 0 frame-group) + ) + (-> self draw art-group data 71) ) - (or - (= v1-243 (-> self draw art-group data 28)) - (= v1-243 (-> self draw art-group data 29)) - (= v1-243 (-> self draw art-group data 54)) - (= v1-243 (-> self draw art-group data 55)) - ) - ) - ) - (let ((f30-1 (cond - ((= (if (> (-> self skel active-channels) 0) - (-> self skel root-channel 0 frame-group) - ) + (let ((a0-12 (-> self skel root-channel 0))) + (set! (-> a0-12 frame-group) (the-as art-joint-anim (-> self draw art-group data 72))) + (set! (-> a0-12 param 0) + (the float (+ (-> (the-as art-joint-anim (-> self draw art-group data 72)) data 0 length) -1)) + ) + (set! (-> a0-12 param 1) (-> (new 'static 'array float 1 1.0) 0)) + (set! (-> a0-12 frame-num) 0.0) + (joint-control-channel-group! a0-12 (the-as art-joint-anim (-> self draw art-group data 72)) num-func-seek!) + ) + (until (ja-done? 0) + (suspend) + (let ((a0-13 (-> self skel root-channel 0))) + (set! (-> a0-13 param 0) (the float (+ (-> a0-13 frame-group data 0 length) -1))) + (set! (-> a0-13 param 1) (-> (new 'static 'array float 1 1.0) 0)) + (joint-control-channel-group-eval! a0-13 (the-as art-joint-anim #f) num-func-seek!) + ) + ) + ) + ((= (if (> (-> self skel active-channels) 0) + (-> self skel root-channel 0 frame-group) + ) + (-> self draw art-group data 51) + ) + (cond + ((rand-vu-percent? (the-as float 0.3)) + (let ((a0-20 (-> self skel root-channel 0))) + (set! (-> a0-20 frame-group) (the-as art-joint-anim (-> self draw art-group data 53))) + (set! (-> a0-20 param 0) + (the float (+ (-> (the-as art-joint-anim (-> self draw art-group data 53)) data 0 length) -1)) + ) + (set! (-> a0-20 param 1) (-> (new 'static 'array float 1 1.0) 0)) + (set! (-> a0-20 frame-num) 0.0) + (joint-control-channel-group! a0-20 (the-as art-joint-anim (-> self draw art-group data 53)) num-func-seek!) + ) + (until (ja-done? 0) + (suspend) + (let ((a0-21 (-> self skel root-channel 0))) + (set! (-> a0-21 param 0) (the float (+ (-> a0-21 frame-group data 0 length) -1))) + (set! (-> a0-21 param 1) (-> (new 'static 'array float 1 1.0) 0)) + (joint-control-channel-group-eval! a0-21 (the-as art-joint-anim #f) num-func-seek!) + ) + ) + ) + (else + (let ((a0-23 (-> self skel root-channel 0))) + (set! (-> a0-23 frame-group) (the-as art-joint-anim (-> self draw art-group data 52))) + (set! (-> a0-23 param 0) + (the float (+ (-> (the-as art-joint-anim (-> self draw art-group data 52)) data 0 length) -1)) + ) + (set! (-> a0-23 param 1) (-> (new 'static 'array float 1 1.0) 0)) + (set! (-> a0-23 frame-num) 0.0) + (joint-control-channel-group! a0-23 (the-as art-joint-anim (-> self draw art-group data 52)) num-func-seek!) + ) + (until (ja-done? 0) + (suspend) + (let ((a0-24 (-> self skel root-channel 0))) + (set! (-> a0-24 param 0) (the float (+ (-> a0-24 frame-group data 0 length) -1))) + (set! (-> a0-24 param 1) (-> (new 'static 'array float 1 1.0) 0)) + (joint-control-channel-group-eval! a0-24 (the-as art-joint-anim #f) num-func-seek!) + ) + ) + ) + ) + ) + ((= (if (> (-> self skel active-channels) 0) + (-> self skel root-channel 0 frame-group) + ) + (-> self draw art-group data 78) + ) + (let ((a0-30 (-> self skel root-channel 0))) + (set! (-> a0-30 frame-group) (the-as art-joint-anim (-> self draw art-group data 79))) + (set! (-> a0-30 param 0) + (the float (+ (-> (the-as art-joint-anim (-> self draw art-group data 79)) data 0 length) -1)) + ) + (set! (-> a0-30 param 1) (-> (new 'static 'array float 1 1.0) 0)) + (set! (-> a0-30 frame-num) 0.0) + (joint-control-channel-group! a0-30 (the-as art-joint-anim (-> self draw art-group data 79)) num-func-seek!) + ) + (until (ja-done? 0) + (suspend) + (let ((a0-31 (-> self skel root-channel 0))) + (set! (-> a0-31 param 0) (the float (+ (-> a0-31 frame-group data 0 length) -1))) + (set! (-> a0-31 param 1) (-> (new 'static 'array float 1 1.0) 0)) + (joint-control-channel-group-eval! a0-31 (the-as art-joint-anim #f) num-func-seek!) + ) + ) + ) + ((= (if (> (-> self skel active-channels) 0) + (-> self skel root-channel 0 frame-group) + ) + (-> self draw art-group data 84) + ) + (let ((a0-37 (-> self skel root-channel 0))) + (set! (-> a0-37 frame-group) (the-as art-joint-anim (-> self draw art-group data 85))) + (set! (-> a0-37 param 0) + (the float (+ (-> (the-as art-joint-anim (-> self draw art-group data 85)) data 0 length) -1)) + ) + (set! (-> a0-37 param 1) (-> (new 'static 'array float 1 1.0) 0)) + (set! (-> a0-37 frame-num) 0.0) + (joint-control-channel-group! a0-37 (the-as art-joint-anim (-> self draw art-group data 85)) num-func-seek!) + ) + (until (ja-done? 0) + (suspend) + (let ((a0-38 (-> self skel root-channel 0))) + (set! (-> a0-38 param 0) (the float (+ (-> a0-38 frame-group data 0 length) -1))) + (set! (-> a0-38 param 1) (-> (new 'static 'array float 1 1.0) 0)) + (joint-control-channel-group-eval! a0-38 (the-as art-joint-anim #f) num-func-seek!) + ) + ) + (set! s5-0 0) + ) + ((= (if (> (-> self skel active-channels) 0) + (-> self skel root-channel 0 frame-group) + ) + (-> self draw art-group data 59) + ) + (set! (-> self control unknown-float81) (-> self control unknown-float80)) + (set! (-> self control unknown-surface00) *walk-no-turn-mods*) + (let ((s4-0 (-> self skel root-channel 0))) + (set! (-> s4-0 frame-group) (the-as art-joint-anim (if (rand-vu-percent? (the-as float 0.3)) + (-> self draw art-group data 61) + (-> self draw art-group data 60) + ) + ) + ) + (set! (-> s4-0 param 0) (the float (+ (-> (the-as art-joint-anim (if (rand-vu-percent? (the-as float 0.3)) + (-> self draw art-group data 61) + (-> self draw art-group data 60) + ) + ) + data + 0 + length + ) + -1 + ) + ) + ) + (set! (-> s4-0 param 1) (-> (new 'static 'array float 1 1.0) 0)) + (set! (-> s4-0 frame-num) 0.0) + (joint-control-channel-group! + s4-0 + (the-as art-joint-anim (if (rand-vu-percent? (the-as float 0.3)) + (-> self draw art-group data 61) + (-> self draw art-group data 60) + ) + ) + num-func-seek! + ) + ) + (until (ja-done? 0) + (set! (-> self control unknown-float81) + (seek + (-> self control unknown-float81) + (-> (new 'static 'array float 1 0.0) 0) + (-> *display* seconds-per-frame) + ) + ) + (suspend) + (let ((a0-50 (-> self skel root-channel 0))) + (set! (-> a0-50 param 0) (the float (+ (-> a0-50 frame-group data 0 length) -1))) + (set! (-> a0-50 param 1) (-> (new 'static 'array float 1 1.0) 0)) + (joint-control-channel-group-eval! a0-50 (the-as art-joint-anim #f) num-func-seek!) + ) + ) + (set! (-> self control unknown-surface00) *walk-mods*) + (set! (-> self control unknown-float81) 0.0) + (rot->dir-targ! (-> self control)) + ) + ((let ((v1-206 (if (> (-> self skel active-channels) 0) + (-> self skel root-channel 0 frame-group) + ) + ) + ) + (or (= v1-206 (-> self draw art-group data 31)) (= v1-206 (-> self draw art-group data 32))) + ) + (ja-channel-push! 1 12) + (let ((a0-62 (-> self skel root-channel 0))) + (set! (-> a0-62 frame-group) (the-as art-joint-anim (-> self draw art-group data 30))) + (set! (-> a0-62 param 0) 0.0) + (set! (-> a0-62 param 1) 1.2) + (set! (-> a0-62 frame-num) + (the float (+ (-> (the-as art-joint-anim (-> self draw art-group data 30)) data 0 length) -1)) + ) + (joint-control-channel-group! a0-62 (the-as art-joint-anim (-> self draw art-group data 30)) num-func-seek!) + ) + (until (ja-done? 0) + (suspend) + (let ((a0-63 (-> self skel root-channel 0))) + (set! (-> a0-63 param 0) 0.0) + (set! (-> a0-63 param 1) 1.2) + (joint-control-channel-group-eval! a0-63 (the-as art-joint-anim #f) num-func-seek!) + ) + ) + (set! s5-0 12) + ) + ((or (and (= (if (> (-> self skel active-channels) 0) + (-> self skel root-channel 0 frame-group) + ) (-> self draw art-group data 23) ) - (let - ((f0-57 - (+ 50.0 (* 0.8333333 (+ -25.0 (ja-aframe-num 0)))) - ) - ) - (- f0-57 (* (the float (the int (/ f0-57 50.0))) 50.0)) - ) - ) - (else - (-> (new 'static 'array float 1 0.0) 0) - ) + (begin (set! s5-0 45) (< 0.5 (-> self skel root-channel 6 frame-interp))) + ) + (let ((v1-243 (if (> (-> self skel active-channels) 0) + (-> self skel root-channel 0 frame-group) + ) + ) ) - ) + (or (= v1-243 (-> self draw art-group data 28)) + (= v1-243 (-> self draw art-group data 29)) + (= v1-243 (-> self draw art-group data 54)) + (= v1-243 (-> self draw art-group data 55)) + ) + ) + ) + (let ((f30-1 (cond + ((= (if (> (-> self skel active-channels) 0) + (-> self skel root-channel 0 frame-group) + ) + (-> self draw art-group data 23) + ) + (let ((f0-57 (+ 50.0 (* 0.8333333 (+ -25.0 (ja-aframe-num 0)))))) + (- f0-57 (* (the float (the int (/ f0-57 50.0))) 50.0)) + ) + ) + (else + (-> (new 'static 'array float 1 0.0) 0) + ) + ) + ) + ) + (set! s5-0 45) + (ja-channel-push! 3 s5-0) + (ground-tween-initialize + gp-0 + (the-as uint 0) + (the-as uint (-> self draw art-group data 4)) + (the-as uint (-> self draw art-group data 13)) + (the-as uint (-> self draw art-group data 16)) + (the-as uint (-> self draw art-group data 7)) + (the-as uint (-> self draw art-group data 10)) + ) + (let ((s4-1 (-> self skel root-channel 0))) + (set! (-> s4-1 num-func) num-func-identity) + (set! (-> s4-1 frame-num) (ja-aframe f30-1 0)) + ) + ) + (let ((a0-89 (-> self skel root-channel 1))) + (set! (-> a0-89 param 0) 0.0) + (joint-control-channel-group-eval! a0-89 (the-as art-joint-anim #f) num-func-chan) + ) + (let ((a0-90 (-> self skel root-channel 2))) + (set! (-> a0-90 param 0) 0.0) + (joint-control-channel-group-eval! a0-90 (the-as art-joint-anim #f) num-func-chan) + ) + (dotimes (s4-2 3) + (until (ja-done? 0) + (ground-tween-update gp-0 (-> self control unknown-float61) (-> self control unknown-float62)) + (suspend) + (let ((a0-92 (-> self skel root-channel 0))) + (set! (-> a0-92 param 0) (the float (+ (-> a0-92 frame-group data 0 length) -1))) + (set! (-> a0-92 param 1) (-> (new 'static 'array float 1 1.0) 0)) + (joint-control-channel-group-eval! a0-92 (the-as art-joint-anim #f) num-func-seek!) + ) + (let ((a0-93 (-> self skel root-channel 1))) + (set! (-> a0-93 param 0) 0.0) + (joint-control-channel-group-eval! a0-93 (the-as art-joint-anim #f) num-func-chan) + ) + (let ((a0-94 (-> self skel root-channel 2))) + (set! (-> a0-94 param 0) 0.0) + (joint-control-channel-group-eval! a0-94 (the-as art-joint-anim #f) num-func-chan) + ) + ) + (let ((v1-298 (-> self skel root-channel 0))) + (set! (-> v1-298 num-func) num-func-identity) + (set! (-> v1-298 frame-num) 0.0) + ) + ) + (ground-tween-initialize + gp-0 + (the-as uint 0) + (the-as uint (-> self draw art-group data 3)) + (the-as uint (-> self draw art-group data 12)) + (the-as uint (-> self draw art-group data 15)) + (the-as uint (-> self draw art-group data 6)) + (the-as uint (-> self draw art-group data 9)) + ) + (until (ja-done? 0) + (ground-tween-update gp-0 (-> self control unknown-float61) (-> self control unknown-float62)) + (suspend) + (let ((a0-99 (-> self skel root-channel 0))) + (set! (-> a0-99 param 0) (the float (+ (-> a0-99 frame-group data 0 length) -1))) + (set! (-> a0-99 param 1) (-> (new 'static 'array float 1 1.0) 0)) + (joint-control-channel-group-eval! a0-99 (the-as art-joint-anim #f) num-func-seek!) + ) + (let ((a0-100 (-> self skel root-channel 1))) + (set! (-> a0-100 param 0) 0.0) + (joint-control-channel-group-eval! a0-100 (the-as art-joint-anim #f) num-func-chan) + ) + (let ((a0-101 (-> self skel root-channel 2))) + (set! (-> a0-101 param 0) 0.0) + (joint-control-channel-group-eval! a0-101 (the-as art-joint-anim #f) num-func-chan) + ) ) - (set! s5-0 45) - (ja-channel-push! 3 s5-0) - (ground-tween-initialize - gp-0 - (the-as uint 0) - (the-as uint (-> self draw art-group data 4)) - (the-as uint (-> self draw art-group data 13)) - (the-as uint (-> self draw art-group data 16)) - (the-as uint (-> self draw art-group data 7)) - (the-as uint (-> self draw art-group data 10)) - ) - (let ((s4-1 (-> self skel root-channel 0))) - (set! (-> s4-1 num-func) num-func-identity) - (set! (-> s4-1 frame-num) (ja-aframe f30-1 0)) - ) - ) - (let ((a0-89 (-> self skel root-channel 1))) - (set! (-> a0-89 param 0) 0.0) - (joint-control-channel-group-eval! - a0-89 - (the-as art-joint-anim #f) - num-func-chan - ) - ) - (let ((a0-90 (-> self skel root-channel 2))) - (set! (-> a0-90 param 0) 0.0) - (joint-control-channel-group-eval! - a0-90 - (the-as art-joint-anim #f) - num-func-chan - ) - ) - (dotimes (s4-2 3) - (until (ja-done? 0) - (ground-tween-update - gp-0 - (-> self control unknown-float61) - (-> self control unknown-float62) - ) - (suspend) - (let ((a0-92 (-> self skel root-channel 0))) - (set! - (-> a0-92 param 0) - (the float (+ (-> a0-92 frame-group data 0 length) -1)) ) - (set! (-> a0-92 param 1) (-> (new 'static 'array float 1 1.0) 0)) - (joint-control-channel-group-eval! - a0-92 - (the-as art-joint-anim #f) - num-func-seek! + ((and (= (if (> (-> self skel active-channels) 0) + (-> self skel root-channel 0 frame-group) + ) + (-> self draw art-group data 23) + ) + (>= (-> self control unknown-float01) 5734.4) + ) + (set! s5-0 45) ) ) - (let ((a0-93 (-> self skel root-channel 1))) - (set! (-> a0-93 param 0) 0.0) - (joint-control-channel-group-eval! - a0-93 - (the-as art-joint-anim #f) - num-func-chan - ) - ) - (let ((a0-94 (-> self skel root-channel 2))) - (set! (-> a0-94 param 0) 0.0) - (joint-control-channel-group-eval! - a0-94 - (the-as art-joint-anim #f) - num-func-chan - ) - ) - ) - (let ((v1-298 (-> self skel root-channel 0))) - (set! (-> v1-298 num-func) num-func-identity) - (set! (-> v1-298 frame-num) 0.0) - ) ) - (ground-tween-initialize + (if (not (and (= (if (> (-> self skel active-channels) 0) + (-> self skel root-channel 0 frame-group) + ) + (-> self draw art-group data 5) + ) + (= (ja-group-size) 3) + ) + ) + (ja-channel-push! 3 s5-0) + ) + (ground-tween-initialize gp-0 (the-as uint 0) - (the-as uint (-> self draw art-group data 3)) - (the-as uint (-> self draw art-group data 12)) - (the-as uint (-> self draw art-group data 15)) - (the-as uint (-> self draw art-group data 6)) - (the-as uint (-> self draw art-group data 9)) + (the-as uint (-> self draw art-group data 5)) + (the-as uint (-> self draw art-group data 14)) + (the-as uint (-> self draw art-group data 17)) + (the-as uint (-> self draw art-group data 8)) + (the-as uint (-> self draw art-group data 11)) ) - (until (ja-done? 0) - (ground-tween-update - gp-0 - (-> self control unknown-float61) - (-> self control unknown-float62) - ) + (while #t + (ground-tween-update gp-0 (-> self control unknown-float61) (-> self control unknown-float62)) (suspend) - (let ((a0-99 (-> self skel root-channel 0))) - (set! - (-> a0-99 param 0) - (the float (+ (-> a0-99 frame-group data 0 length) -1)) + (let ((a0-115 (-> self skel root-channel 0))) + (set! (-> a0-115 param 0) (-> (new 'static 'array float 1 1.0) 0)) + (joint-control-channel-group-eval! a0-115 (the-as art-joint-anim #f) num-func-loop!) ) - (set! (-> a0-99 param 1) (-> (new 'static 'array float 1 1.0) 0)) - (joint-control-channel-group-eval! - a0-99 - (the-as art-joint-anim #f) - num-func-seek! + (let ((a0-116 (-> self skel root-channel 1))) + (set! (-> a0-116 param 0) 0.0) + (joint-control-channel-group-eval! a0-116 (the-as art-joint-anim #f) num-func-chan) ) - ) - (let ((a0-100 (-> self skel root-channel 1))) - (set! (-> a0-100 param 0) 0.0) - (joint-control-channel-group-eval! - a0-100 - (the-as art-joint-anim #f) - num-func-chan + (let ((a0-117 (-> self skel root-channel 2))) + (set! (-> a0-117 param 0) 0.0) + (joint-control-channel-group-eval! a0-117 (the-as art-joint-anim #f) num-func-chan) ) - ) - (let ((a0-101 (-> self skel root-channel 2))) - (set! (-> a0-101 param 0) 0.0) - (joint-control-channel-group-eval! - a0-101 - (the-as art-joint-anim #f) - num-func-chan - ) - ) + (if (can-play-stance-amibent?) + (go target-stance-ambient) + ) ) - ) - ((and (= (if (> (-> self skel active-channels) 0) - (-> self skel root-channel 0 frame-group) - ) - (-> self draw art-group data 23) - ) - (>= (-> self control unknown-float01) 5734.4) - ) - (set! s5-0 45) - ) ) - ) - (if (not (and (= (if (> (-> self skel active-channels) 0) - (-> self skel root-channel 0 frame-group) - ) - (-> self draw art-group data 5) - ) - (= (ja-group-size) 3) - ) - ) - (ja-channel-push! 3 s5-0) - ) - (ground-tween-initialize - gp-0 - (the-as uint 0) - (the-as uint (-> self draw art-group data 5)) - (the-as uint (-> self draw art-group data 14)) - (the-as uint (-> self draw art-group data 17)) - (the-as uint (-> self draw art-group data 8)) - (the-as uint (-> self draw art-group data 11)) - ) - (while #t - (ground-tween-update - gp-0 - (-> self control unknown-float61) - (-> self control unknown-float62) - ) - (suspend) - (let ((a0-115 (-> self skel root-channel 0))) - (set! (-> a0-115 param 0) (-> (new 'static 'array float 1 1.0) 0)) - (joint-control-channel-group-eval! - a0-115 - (the-as art-joint-anim #f) - num-func-loop! - ) - ) - (let ((a0-116 (-> self skel root-channel 1))) - (set! (-> a0-116 param 0) 0.0) - (joint-control-channel-group-eval! - a0-116 - (the-as art-joint-anim #f) - num-func-chan - ) - ) - (let ((a0-117 (-> self skel root-channel 2))) - (set! (-> a0-117 param 0) 0.0) - (joint-control-channel-group-eval! - a0-117 - (the-as art-joint-anim #f) - num-func-chan - ) - ) - (if (can-play-stance-amibent?) - (go target-stance-ambient) - ) - ) + (none) ) - (none) - ) :post (the-as (function none :behavior target) target-post) ) +;; failed to figure out what this is: (defstate target-walk (target) :event target-walk-event-handler :enter (behavior () - (set! (-> self state-time) (-> *display* base-frame-counter)) - (set! (-> self control unknown-surface00) *walk-mods*) - (none) - ) + (set! (-> self state-time) (-> *display* base-frame-counter)) + (set! (-> self control unknown-surface00) *walk-mods*) + (none) + ) :exit (behavior () - (target-effect-exit) - (target-state-hook-exit) - (none) - ) + (target-effect-exit) + (target-state-hook-exit) + (none) + ) :trans (behavior () - ((-> self state-hook)) - (when (= (-> self control ground-pat material) (pat-material ice)) - (target-effect-exit) - (remove-exit) - (go target-ice-walk) - ) - (if - (and - (logtest? - (logior - (logior - (-> - *cpad-list* - cpads - (-> self control unknown-cpad-info00 number) - button0-rel - 0 - ) - (-> - *cpad-list* - cpads - (-> self control unknown-cpad-info00 number) - button0-rel - 1 - ) - ) - (-> - *cpad-list* - cpads - (-> self control unknown-cpad-info00 number) - button0-rel - 2 - ) - ) - (pad-buttons l1 r1) + ((-> self state-hook)) + (when (= (-> self control ground-pat material) (pat-material ice)) + (target-effect-exit) + (remove-exit) + (go target-ice-walk) ) - (and - (>= - (- - (-> *display* base-frame-counter) - (the-as int (-> *TARGET-bank* wheel-timeout)) + (if (and (logtest? (logior (logior (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) button0-rel 0) + (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) button0-rel 1) + ) + (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) button0-rel 2) + ) + (pad-buttons l1 r1) + ) + (and (>= (- (-> *display* base-frame-counter) (the-as int (-> *TARGET-bank* wheel-timeout))) + (-> self control unknown-dword30) + ) + (and (!= (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) stick0-speed) 0.0) (can-wheel?)) + ) + ) + (go target-wheel) ) - (-> self control unknown-dword30) - ) - (and - (!= - (-> - *cpad-list* - cpads - (-> self control unknown-cpad-info00 number) - stick0-speed - ) - 0.0 - ) - (can-wheel?) - ) + (when (and (logtest? (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) button0-abs 0) + (pad-buttons l1 r1) + ) + (can-duck?) + ) + (target-effect-exit) + (remove-exit) + (go target-duck-walk) ) - ) - (go target-wheel) - ) - (when - (and - (logtest? - (-> - *cpad-list* - cpads - (-> self control unknown-cpad-info00 number) - button0-abs - 0 - ) - (pad-buttons l1 r1) + (when (not (move-legs?)) + (target-effect-exit) + (remove-exit) + (go target-stance) ) - (can-duck?) - ) - (target-effect-exit) - (remove-exit) - (go target-duck-walk) - ) - (when (not (move-legs?)) - (target-effect-exit) - (remove-exit) - (go target-stance) - ) - (if - (and - (logtest? - (logior - (logior - (-> - *cpad-list* - cpads - (-> self control unknown-cpad-info00 number) - button0-rel - 0 - ) - (-> - *cpad-list* - cpads - (-> self control unknown-cpad-info00 number) - button0-rel - 1 - ) + (if (and (logtest? (logior (logior (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) button0-rel 0) + (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) button0-rel 1) + ) + (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) button0-rel 2) + ) + (pad-buttons x) + ) + (can-jump? #f) + ) + (go target-jump (-> *TARGET-bank* jump-height-min) (-> *TARGET-bank* jump-height-max) (the-as surface #f)) ) - (-> - *cpad-list* - cpads - (-> self control unknown-cpad-info00 number) - button0-rel - 2 + (if (and (logtest? (logior (logior (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) button0-rel 0) + (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) button0-rel 1) + ) + (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) button0-rel 2) + ) + (pad-buttons circle) + ) + (can-feet?) + ) + (go target-attack) ) - ) - (pad-buttons x) + (if (can-hands? #t) + (go target-running-attack) + ) + (when (and (turn-around?) (>= (- (-> *display* base-frame-counter) (-> self state-time)) 90)) + (set! (-> self control transv quad) + (-> self control unknown-vector-array10 (-> self control unknown-int10) quad) + ) + (set! (-> self control transv w) (-> (new 'static 'array float 1 1.0) 0)) + (go target-turn-around) ) - (can-jump? #f) - ) - (go - target-jump - (-> *TARGET-bank* jump-height-min) - (-> *TARGET-bank* jump-height-max) - (the-as surface #f) - ) + (slide-down-test) + (fall-test) + (none) ) - (if - (and - (logtest? - (logior - (logior - (-> - *cpad-list* - cpads - (-> self control unknown-cpad-info00 number) - button0-rel - 0 - ) - (-> - *cpad-list* - cpads - (-> self control unknown-cpad-info00 number) - button0-rel - 1 - ) - ) - (-> - *cpad-list* - cpads - (-> self control unknown-cpad-info00 number) - button0-rel - 2 - ) - ) - (pad-buttons circle) - ) - (can-feet?) - ) - (go target-attack) - ) - (if (can-hands? #t) - (go target-running-attack) - ) - (when - (and - (turn-around?) - (>= (- (-> *display* base-frame-counter) (-> self state-time)) 90) - ) - (set! - (-> self control transv quad) - (-> - self - control - unknown-vector-array10 - (-> self control unknown-int10) - quad - ) - ) - (set! (-> self control transv w) (-> (new 'static 'array float 1 1.0) 0)) - (go target-turn-around) - ) - (slide-down-test) - (fall-test) - (none) - ) :code (behavior () - (let ((f28-0 0.0) - (f30-0 - (fmax - 0.0 - (fmin - (-> (new 'static 'array float 1 1.0) 0) - (* 0.000048828126 (+ -16384.0 (-> self control unknown-float01))) - ) - ) + (let ((f28-0 0.0) + (f30-0 (fmax 0.0 (fmin + (-> (new 'static 'array float 1 1.0) 0) + (* 0.000048828126 (+ -16384.0 (-> self control unknown-float01))) + ) + ) + ) + (gp-0 #f) ) - (gp-0 #f) - ) - (cond - ((= (if (> (-> self skel active-channels) 0) - (-> self skel root-channel 0 frame-group) - ) - (-> self draw art-group data 33) - ) - (set! f30-0 (-> (new 'static 'array float 1 1.0) 0)) - (ja-channel-push! 7 15) - ) - ((= (if (> (-> self skel active-channels) 0) - (-> self skel root-channel 0 frame-group) - ) - (-> self draw art-group data 69) - ) - (ja-channel-push! 7 22) - (set! f30-0 (-> (new 'static 'array float 1 1.0) 0)) - ) - ((= (if (> (-> self skel active-channels) 0) - (-> self skel root-channel 0 frame-group) - ) - (-> self draw art-group data 51) - ) - (let - ((f30-1 - (fmax - 0.8 - (fmin - (-> (new 'static 'array float 1 1.0) 0) - (* 0.000048828126 (-> self control unknown-float01)) - ) - ) - ) - ) - (cond - ((and - (rand-vu-percent? (the-as float 0.3)) - (< 20480.0 (-> self control unknown-float01)) - ) - (let ((s5-0 (-> self skel root-channel 0))) - (set! - (-> s5-0 frame-group) - (the-as art-joint-anim (-> self draw art-group data 53)) - ) - (set! (-> s5-0 param 0) (ja-aframe (the-as float 29.0) 0)) - (set! (-> s5-0 param 1) f30-1) - (set! (-> s5-0 frame-num) 0.0) - (joint-control-channel-group! - s5-0 - (the-as art-joint-anim (-> self draw art-group data 53)) - num-func-seek! - ) - ) - (until (ja-done? 0) - (suspend) - (let ((s5-1 (-> self skel root-channel 0))) - (set! (-> s5-1 param 0) (ja-aframe (the-as float 29.0) 0)) - (set! (-> s5-1 param 1) f30-1) - (joint-control-channel-group-eval! - s5-1 - (the-as art-joint-anim #f) - num-func-seek! - ) - ) - ) - (let ((a0-20 (-> self skel root-channel 0))) - (set! - (-> a0-20 frame-group) - (the-as art-joint-anim (-> self draw art-group data 55)) - ) - (set! - (-> a0-20 param 0) - (the - float - (+ - (-> - (the-as art-joint-anim (-> self draw art-group data 55)) - data - 0 - length - ) - -1 - ) - ) - ) - (set! (-> a0-20 param 1) f30-1) - (set! (-> a0-20 frame-num) 0.0) - (joint-control-channel-group! - a0-20 - (the-as art-joint-anim (-> self draw art-group data 55)) - num-func-seek! - ) - ) - (until (ja-done? 0) - (suspend) - (let ((a0-21 (-> self skel root-channel 0))) - (set! - (-> a0-21 param 0) - (the float (+ (-> a0-21 frame-group data 0 length) -1)) - ) - (set! (-> a0-21 param 1) f30-1) - (joint-control-channel-group-eval! - a0-21 - (the-as art-joint-anim #f) - num-func-seek! - ) - ) - ) - ) - (else - (let ((s5-2 (-> self skel root-channel 0))) - (set! - (-> s5-2 frame-group) - (the-as art-joint-anim (-> self draw art-group data 52)) - ) - (set! (-> s5-2 param 0) (ja-aframe (the-as float 29.0) 0)) - (set! (-> s5-2 param 1) f30-1) - (set! (-> s5-2 frame-num) 0.0) - (joint-control-channel-group! - s5-2 - (the-as art-joint-anim (-> self draw art-group data 52)) - num-func-seek! - ) - ) - (until (ja-done? 0) - (suspend) - (let ((s5-3 (-> self skel root-channel 0))) - (set! (-> s5-3 param 0) (ja-aframe (the-as float 29.0) 0)) - (set! (-> s5-3 param 1) f30-1) - (joint-control-channel-group-eval! - s5-3 - (the-as art-joint-anim #f) - num-func-seek! - ) - ) - ) - (let ((a0-28 (-> self skel root-channel 0))) - (set! - (-> a0-28 frame-group) - (the-as art-joint-anim (-> self draw art-group data 54)) - ) - (set! - (-> a0-28 param 0) - (the - float - (+ - (-> - (the-as art-joint-anim (-> self draw art-group data 54)) - data - 0 - length - ) - -1 - ) - ) - ) - (set! (-> a0-28 param 1) f30-1) - (set! (-> a0-28 frame-num) 0.0) - (joint-control-channel-group! - a0-28 - (the-as art-joint-anim (-> self draw art-group data 54)) - num-func-seek! - ) - ) - (until (ja-done? 0) - (suspend) - (let ((a0-29 (-> self skel root-channel 0))) - (set! - (-> a0-29 param 0) - (the float (+ (-> a0-29 frame-group data 0 length) -1)) - ) - (set! (-> a0-29 param 1) f30-1) - (joint-control-channel-group-eval! - a0-29 - (the-as art-joint-anim #f) - num-func-seek! - ) - ) - ) - ) - ) - ) - (ja-channel-push! 7 15) - (set! f30-0 (-> (new 'static 'array float 1 1.0) 0)) - (set! f28-0 30.0) - ) - (else - (let ((v1-108 (if (> (-> self skel active-channels) 0) - (-> self skel root-channel 0 frame-group) - ) - ) - ) - (cond - ((or - (= v1-108 (-> self draw art-group data 59)) - (= v1-108 (-> self draw art-group data 60)) - ) - (set! f30-0 (-> (new 'static 'array float 1 1.0) 0)) - (set! f28-0 30.0) - (ja-channel-push! 7 45) - ) - ((let ((v1-116 (if (> (-> self skel active-channels) 0) - (-> self skel root-channel 0 frame-group) - ) + (cond + ((= (if (> (-> self skel active-channels) 0) + (-> self skel root-channel 0 frame-group) ) - ) - (or - (= v1-116 (-> self draw art-group data 84)) - (= v1-116 (-> self draw art-group data 85)) - ) - ) + (-> self draw art-group data 33) + ) (set! f30-0 (-> (new 'static 'array float 1 1.0) 0)) - (set! f28-0 26.0) - (ja-channel-push! 7 30) - ) - ((and (= (if (> (-> self skel active-channels) 0) - (-> self skel root-channel 0 frame-group) - ) - (-> self draw art-group data 23) - ) - (= (-> self skel root-channel 0) (-> self skel channel)) - ) - (set! f28-0 (ja-aframe-num 0)) - ) - ((= (if (> (-> self skel active-channels) 0) - (-> self skel root-channel 0 frame-group) - ) - (-> self draw art-group data 102) - ) - (set! f28-0 (ja-aframe-num 0)) - (ja-channel-push! 7 30) - ) - ((= (if (> (-> self skel active-channels) 0) - (-> self skel root-channel 0 frame-group) - ) - (-> self draw art-group data 89) - ) - (set! f28-0 (ja-aframe-num 0)) (ja-channel-push! 7 15) ) - ((let ((v1-146 (if (> (-> self skel active-channels) 0) - (-> self skel root-channel 0 frame-group) + ((= (if (> (-> self skel active-channels) 0) + (-> self skel root-channel 0 frame-group) + ) + (-> self draw art-group data 69) + ) + (ja-channel-push! 7 22) + (set! f30-0 (-> (new 'static 'array float 1 1.0) 0)) + ) + ((= (if (> (-> self skel active-channels) 0) + (-> self skel root-channel 0 frame-group) + ) + (-> self draw art-group data 51) + ) + (let ((f30-1 + (fmax 0.8 (fmin (-> (new 'static 'array float 1 1.0) 0) (* 0.000048828126 (-> self control unknown-float01)))) + ) + ) + (cond + ((and (rand-vu-percent? (the-as float 0.3)) (< 20480.0 (-> self control unknown-float01))) + (let ((s5-0 (-> self skel root-channel 0))) + (set! (-> s5-0 frame-group) (the-as art-joint-anim (-> self draw art-group data 53))) + (set! (-> s5-0 param 0) (ja-aframe (the-as float 29.0) 0)) + (set! (-> s5-0 param 1) f30-1) + (set! (-> s5-0 frame-num) 0.0) + (joint-control-channel-group! s5-0 (the-as art-joint-anim (-> self draw art-group data 53)) num-func-seek!) + ) + (until (ja-done? 0) + (suspend) + (let ((s5-1 (-> self skel root-channel 0))) + (set! (-> s5-1 param 0) (ja-aframe (the-as float 29.0) 0)) + (set! (-> s5-1 param 1) f30-1) + (joint-control-channel-group-eval! s5-1 (the-as art-joint-anim #f) num-func-seek!) + ) + ) + (let ((a0-20 (-> self skel root-channel 0))) + (set! (-> a0-20 frame-group) (the-as art-joint-anim (-> self draw art-group data 55))) + (set! (-> a0-20 param 0) + (the float (+ (-> (the-as art-joint-anim (-> self draw art-group data 55)) data 0 length) -1)) + ) + (set! (-> a0-20 param 1) f30-1) + (set! (-> a0-20 frame-num) 0.0) + (joint-control-channel-group! a0-20 (the-as art-joint-anim (-> self draw art-group data 55)) num-func-seek!) + ) + (until (ja-done? 0) + (suspend) + (let ((a0-21 (-> self skel root-channel 0))) + (set! (-> a0-21 param 0) (the float (+ (-> a0-21 frame-group data 0 length) -1))) + (set! (-> a0-21 param 1) f30-1) + (joint-control-channel-group-eval! a0-21 (the-as art-joint-anim #f) num-func-seek!) + ) + ) + ) + (else + (let ((s5-2 (-> self skel root-channel 0))) + (set! (-> s5-2 frame-group) (the-as art-joint-anim (-> self draw art-group data 52))) + (set! (-> s5-2 param 0) (ja-aframe (the-as float 29.0) 0)) + (set! (-> s5-2 param 1) f30-1) + (set! (-> s5-2 frame-num) 0.0) + (joint-control-channel-group! s5-2 (the-as art-joint-anim (-> self draw art-group data 52)) num-func-seek!) + ) + (until (ja-done? 0) + (suspend) + (let ((s5-3 (-> self skel root-channel 0))) + (set! (-> s5-3 param 0) (ja-aframe (the-as float 29.0) 0)) + (set! (-> s5-3 param 1) f30-1) + (joint-control-channel-group-eval! s5-3 (the-as art-joint-anim #f) num-func-seek!) + ) + ) + (let ((a0-28 (-> self skel root-channel 0))) + (set! (-> a0-28 frame-group) (the-as art-joint-anim (-> self draw art-group data 54))) + (set! (-> a0-28 param 0) + (the float (+ (-> (the-as art-joint-anim (-> self draw art-group data 54)) data 0 length) -1)) + ) + (set! (-> a0-28 param 1) f30-1) + (set! (-> a0-28 frame-num) 0.0) + (joint-control-channel-group! a0-28 (the-as art-joint-anim (-> self draw art-group data 54)) num-func-seek!) + ) + (until (ja-done? 0) + (suspend) + (let ((a0-29 (-> self skel root-channel 0))) + (set! (-> a0-29 param 0) (the float (+ (-> a0-29 frame-group data 0 length) -1))) + (set! (-> a0-29 param 1) f30-1) + (joint-control-channel-group-eval! a0-29 (the-as art-joint-anim #f) num-func-seek!) + ) + ) + ) + ) + ) + (ja-channel-push! 7 15) + (set! f30-0 (-> (new 'static 'array float 1 1.0) 0)) + (set! f28-0 30.0) + ) + (else + (let ((v1-108 (if (> (-> self skel active-channels) 0) + (-> self skel root-channel 0 frame-group) + ) ) ) + (cond + ((or (= v1-108 (-> self draw art-group data 59)) (= v1-108 (-> self draw art-group data 60))) + (set! f30-0 (-> (new 'static 'array float 1 1.0) 0)) + (set! f28-0 30.0) + (ja-channel-push! 7 45) ) - (and - (or - (or - (= v1-146 (-> self draw art-group data 38)) - (= v1-146 (-> self draw art-group data 71)) - (= v1-146 (-> self draw art-group data 58)) - (= v1-146 (-> self draw art-group data 62)) - (= v1-146 (-> self draw art-group data 65)) - (= v1-146 (-> self draw art-group data 68)) - ) - (and (= (if (> (-> self skel active-channels) 0) - (-> self skel root-channel 0 frame-group) + ((let ((v1-116 (if (> (-> self skel active-channels) 0) + (-> self skel root-channel 0 frame-group) + ) + ) ) - (-> self draw art-group data 34) - ) - (< 30.0 (ja-aframe-num 0)) - ) - ) - (< 12288.0 (-> self control unknown-float01)) - ) - ) - (let ((s5-4 (if (> (-> self skel active-channels) 0) + (or (= v1-116 (-> self draw art-group data 84)) (= v1-116 (-> self draw art-group data 85))) + ) + (set! f30-0 (-> (new 'static 'array float 1 1.0) 0)) + (set! f28-0 26.0) + (ja-channel-push! 7 30) + ) + ((and (= (if (> (-> self skel active-channels) 0) + (-> self skel root-channel 0 frame-group) + ) + (-> self draw art-group data 23) + ) + (= (-> self skel root-channel 0) (-> self skel channel)) + ) + (set! f28-0 (ja-aframe-num 0)) + ) + ((= (if (> (-> self skel active-channels) 0) (-> self skel root-channel 0 frame-group) ) - ) - (f30-2 (-> self control ground-impact-vel)) + (-> self draw art-group data 102) + ) + (set! f28-0 (ja-aframe-num 0)) + (ja-channel-push! 7 30) ) - (case (if (> (-> self skel active-channels) 0) - (-> self skel root-channel 0 frame-group) + ((= (if (> (-> self skel active-channels) 0) + (-> self skel root-channel 0 frame-group) + ) + (-> self draw art-group data 89) + ) + (set! f28-0 (ja-aframe-num 0)) + (ja-channel-push! 7 15) + ) + ((let ((v1-146 (if (> (-> self skel active-channels) 0) + (-> self skel root-channel 0 frame-group) + ) + ) + ) + (and (or (or (= v1-146 (-> self draw art-group data 38)) + (= v1-146 (-> self draw art-group data 71)) + (= v1-146 (-> self draw art-group data 58)) + (= v1-146 (-> self draw art-group data 62)) + (= v1-146 (-> self draw art-group data 65)) + (= v1-146 (-> self draw art-group data 68)) + ) + (and (= (if (> (-> self skel active-channels) 0) + (-> self skel root-channel 0 frame-group) + ) + (-> self draw art-group data 34) + ) + (< 30.0 (ja-aframe-num 0)) + ) + ) + (< 12288.0 (-> self control unknown-float01)) + ) ) - - (((-> self draw art-group data 71) (-> self draw art-group data 58)) - (ja-channel-push! 1 15) - ) - (else - (ja-channel-set! 1) + (let ((s5-4 (if (> (-> self skel active-channels) 0) + (-> self skel root-channel 0 frame-group) + ) + ) + (f30-2 (-> self control ground-impact-vel)) + ) + (case (if (> (-> self skel active-channels) 0) + (-> self skel root-channel 0 frame-group) + ) + (((-> self draw art-group data 71) (-> self draw art-group data 58)) + (ja-channel-push! 1 15) + ) + (else + (ja-channel-set! 1) + ) + ) + (cond + ((< (if (= s5-4 (-> self draw art-group data 34)) + (-> (new 'static 'array float 1 77824.0) 0) + (-> (new 'static 'array float 1 102400.0) 0) + ) + f30-2 + ) + (let ((s5-5 (-> self skel root-channel 0))) + (set! (-> s5-5 frame-group) (the-as art-joint-anim (-> self draw art-group data 28))) + (set! (-> s5-5 param 0) (ja-aframe (-> (new 'static 'array float 1 3.0) 0) 0)) + (set! (-> s5-5 param 1) 1.00001) + (set! (-> s5-5 frame-num) 0.0) + (joint-control-channel-group! s5-5 (the-as art-joint-anim (-> self draw art-group data 28)) num-func-seek!) + ) + (until (ja-done? 0) + (suspend) + (let ((s5-6 (-> self skel root-channel 0))) + (set! (-> s5-6 param 0) (ja-aframe (-> (new 'static 'array float 1 3.0) 0) 0)) + (set! (-> s5-6 param 1) 1.00001) + (joint-control-channel-group-eval! s5-6 (the-as art-joint-anim #f) num-func-seek!) + ) + ) + ) + ((< (if (= s5-4 (-> self draw art-group data 34)) + (-> (new 'static 'array float 1 61440.0) 0) + (-> (new 'static 'array float 1 102400.0) 0) + ) + f30-2 + ) + (let ((s5-7 (-> self skel root-channel 0))) + (set! (-> s5-7 frame-group) (the-as art-joint-anim (-> self draw art-group data 28))) + (set! (-> s5-7 param 0) (ja-aframe (-> (new 'static 'array float 1 3.0) 0) 0)) + (set! (-> s5-7 param 1) 1.00001) + (set! (-> s5-7 frame-num) (ja-aframe (-> (new 'static 'array float 1 -1.0) 0) 0)) + (joint-control-channel-group! s5-7 (the-as art-joint-anim (-> self draw art-group data 28)) num-func-seek!) + ) + (until (ja-done? 0) + (suspend) + (let ((s5-8 (-> self skel root-channel 0))) + (set! (-> s5-8 param 0) (ja-aframe (-> (new 'static 'array float 1 3.0) 0) 0)) + (set! (-> s5-8 param 1) 1.00001) + (joint-control-channel-group-eval! s5-8 (the-as art-joint-anim #f) num-func-seek!) + ) + ) + ) + (else + (let ((s5-9 (-> self skel root-channel 0))) + (set! (-> s5-9 frame-group) (the-as art-joint-anim (-> self draw art-group data 29))) + (set! (-> s5-9 param 0) (ja-aframe (the-as float 4.0) 0)) + (set! (-> s5-9 param 1) 1.00001) + (set! (-> s5-9 frame-num) 0.0) + (joint-control-channel-group! s5-9 (the-as art-joint-anim (-> self draw art-group data 29)) num-func-seek!) + ) + (until (ja-done? 0) + (suspend) + (let ((s5-10 (-> self skel root-channel 0))) + (set! (-> s5-10 param 0) (ja-aframe (the-as float 4.0) 0)) + (set! (-> s5-10 param 1) 1.00001) + (joint-control-channel-group-eval! s5-10 (the-as art-joint-anim #f) num-func-seek!) + ) + ) + ) + ) + ) + (until (ja-done? 0) + (suspend) + (let ((a0-116 (-> self skel root-channel 0))) + (set! (-> a0-116 param 0) (the float (+ (-> a0-116 frame-group data 0 length) -1))) + (set! (-> a0-116 param 1) + (/ (* (fmax 20480.0 (-> self control unknown-float01)) (-> *display* seconds-per-frame)) + (/ (-> *TARGET-bank* run-up-cycle-dist) (-> *TARGET-bank* run-cycle-length)) + ) + ) + (joint-control-channel-group-eval! a0-116 (the-as art-joint-anim #f) num-func-seek!) + ) + ) + (set! f28-0 30.0) + (set! f30-0 (-> (new 'static 'array float 1 1.0) 0)) + (ja-channel-set! 7) + ) + ((= (if (> (-> self skel active-channels) 0) + (-> self skel root-channel 0 frame-group) + ) + (-> self draw art-group data 34) + ) + (ja-channel-push! 7 15) + (set! gp-0 #t) + ) + ((= (if (> (-> self skel active-channels) 0) + (-> self skel root-channel 0 frame-group) + ) + (-> self draw art-group data 78) + ) + (ja-channel-push! 7 45) + ) + (else + (ja-channel-push! 7 15) + ) + ) + ) + ) + ) + (set! (-> self skel root-channel 3 command) 'push) + (set! (-> self skel root-channel 6 command) 'stack) + (let ((v1-265 (-> self skel root-channel 0))) + (set! (-> v1-265 frame-group) (the-as art-joint-anim (-> self draw art-group data 23))) + ) + (let ((f28-1 (ja-aframe f28-0 0))) + (let ((s5-11 (-> self skel root-channel 0))) + (set! (-> s5-11 frame-interp) 0.0) + (set! (-> s5-11 dist) (-> *TARGET-bank* walk-cycle-dist)) + (joint-control-channel-group-eval! + s5-11 + (the-as art-joint-anim (-> self draw art-group data 23)) + num-func-identity + ) + (set! (-> s5-11 frame-num) f28-1) + ) + (let ((s5-12 (-> self skel root-channel 1))) + (set! (-> s5-12 frame-interp) 0.0) + (set! (-> s5-12 dist) (-> *TARGET-bank* walk-down-cycle-dist)) + (joint-control-channel-group-eval! + s5-12 + (the-as art-joint-anim (-> self draw art-group data 25)) + num-func-identity + ) + (set! (-> s5-12 frame-num) f28-1) + ) + (let ((s5-13 (-> self skel root-channel 2))) + (set! (-> s5-13 frame-interp) 0.0) + (set! (-> s5-13 dist) (-> *TARGET-bank* walk-side-cycle-dist)) + (joint-control-channel-group-eval! + s5-13 + (the-as art-joint-anim (-> self draw art-group data 27)) + num-func-identity + ) + (set! (-> s5-13 frame-num) f28-1) + ) + (let ((s5-14 (-> self skel root-channel 4))) + (set! (-> s5-14 frame-interp) 0.0) + (set! (-> s5-14 dist) (-> *TARGET-bank* run-down-cycle-dist)) + (joint-control-channel-group-eval! + s5-14 + (the-as art-joint-anim (-> self draw art-group data 20)) + num-func-identity + ) + (set! (-> s5-14 frame-num) f28-1) + ) + (let ((s5-15 (-> self skel root-channel 5))) + (set! (-> s5-15 frame-interp) 0.0) + (set! (-> s5-15 dist) (-> *TARGET-bank* run-side-cycle-dist)) + (joint-control-channel-group-eval! + s5-15 + (the-as art-joint-anim (-> self draw art-group data 22)) + num-func-identity + ) + (set! (-> s5-15 frame-num) f28-1) + ) + (let ((s5-16 (-> self skel root-channel 3))) + (set! (-> s5-16 frame-interp) 0.0) + (set! (-> s5-16 dist) (-> *TARGET-bank* run-cycle-dist)) + (joint-control-channel-group-eval! + s5-16 + (the-as art-joint-anim (-> self draw art-group data 18)) + num-func-identity + ) + (set! (-> s5-16 frame-num) f28-1) + ) + ) + (let ((f28-2 0.0) + (f26-1 0.0) + ) + (while #t + (let ((f22-0 (fmax + (-> (new 'static 'array float 1 -1.0) 0) + (fmin (-> (new 'static 'array float 1 1.0) 0) (* 2.0 (-> self control unknown-float61))) + ) + ) + (f24-0 (fmax + (-> (new 'static 'array float 1 -1.0) 0) + (fmin (-> (new 'static 'array float 1 1.0) 0) (* 1.6 (-> self control unknown-float62))) + ) + ) + ) + (set! f30-0 (seek + f30-0 + (fmax 0.0 (fmin + (-> (new 'static 'array float 1 1.0) 0) + (* 0.000048828126 (+ -16384.0 (-> self control unknown-float01))) + ) + ) + (* 2.0 (-> *display* seconds-per-frame)) + ) + ) + (let ((v1-317 (-> self skel effect))) + (set! (-> v1-317 channel-offset) (if (< 0.5 f30-0) + 3 + 0 + ) + ) + ) + 0 + (let ((f0-64 (fabs (- f22-0 f28-2)))) + (set! f28-2 (seek f28-2 f22-0 (fmax 0.05 (fmin 0.2 (* 0.25 f0-64))))) + ) + (let ((f0-69 (fabs (- f24-0 f26-1)))) + (set! f26-1 (seek f26-1 f24-0 (fmax 0.05 (fmin 0.2 (* 0.25 f0-69))))) + ) ) - ) (cond - ((< (if (= s5-4 (-> self draw art-group data 34)) - (-> (new 'static 'array float 1 77824.0) 0) - (-> (new 'static 'array float 1 102400.0) 0) + ((>= f28-2 0.0) + (let ((v1-329 (-> self skel root-channel 1))) + (set! (-> v1-329 frame-interp) (fabs f28-2)) + (set! (-> v1-329 dist) (-> *TARGET-bank* walk-up-cycle-dist)) + (set! (-> v1-329 frame-group) (the-as art-joint-anim (-> self draw art-group data 24))) + ) + (let ((v1-332 (-> self skel root-channel 4))) + (set! (-> v1-332 frame-interp) (fabs f28-2)) + (set! (-> v1-332 dist) (-> *TARGET-bank* run-up-cycle-dist)) + (set! (-> v1-332 frame-group) (the-as art-joint-anim (-> self draw art-group data 19))) + ) + ) + (else + (let ((v1-335 (-> self skel root-channel 1))) + (set! (-> v1-335 frame-interp) (fabs f28-2)) + (set! (-> v1-335 dist) (-> *TARGET-bank* walk-down-cycle-dist)) + (set! (-> v1-335 frame-group) (the-as art-joint-anim (-> self draw art-group data 25))) ) - f30-2 - ) - (let ((s5-5 (-> self skel root-channel 0))) - (set! - (-> s5-5 frame-group) - (the-as art-joint-anim (-> self draw art-group data 28)) - ) - (set! - (-> s5-5 param 0) - (ja-aframe (-> (new 'static 'array float 1 3.0) 0) 0) - ) - (set! (-> s5-5 param 1) 1.00001) - (set! (-> s5-5 frame-num) 0.0) - (joint-control-channel-group! - s5-5 - (the-as art-joint-anim (-> self draw art-group data 28)) - num-func-seek! - ) - ) - (until (ja-done? 0) - (suspend) - (let ((s5-6 (-> self skel root-channel 0))) - (set! - (-> s5-6 param 0) - (ja-aframe (-> (new 'static 'array float 1 3.0) 0) 0) - ) - (set! (-> s5-6 param 1) 1.00001) - (joint-control-channel-group-eval! - s5-6 - (the-as art-joint-anim #f) - num-func-seek! - ) - ) - ) - ) - ((< (if (= s5-4 (-> self draw art-group data 34)) - (-> (new 'static 'array float 1 61440.0) 0) - (-> (new 'static 'array float 1 102400.0) 0) + (let ((v1-338 (-> self skel root-channel 4))) + (set! (-> v1-338 frame-interp) (fabs f28-2)) + (set! (-> v1-338 dist) (-> *TARGET-bank* run-down-cycle-dist)) + (set! (-> v1-338 frame-group) (the-as art-joint-anim (-> self draw art-group data 20))) ) - f30-2 - ) - (let ((s5-7 (-> self skel root-channel 0))) - (set! - (-> s5-7 frame-group) - (the-as art-joint-anim (-> self draw art-group data 28)) ) - (set! - (-> s5-7 param 0) - (ja-aframe (-> (new 'static 'array float 1 3.0) 0) 0) - ) - (set! (-> s5-7 param 1) 1.00001) - (set! - (-> s5-7 frame-num) - (ja-aframe (-> (new 'static 'array float 1 -1.0) 0) 0) - ) - (joint-control-channel-group! - s5-7 - (the-as art-joint-anim (-> self draw art-group data 28)) - num-func-seek! - ) - ) - (until (ja-done? 0) - (suspend) - (let ((s5-8 (-> self skel root-channel 0))) - (set! - (-> s5-8 param 0) - (ja-aframe (-> (new 'static 'array float 1 3.0) 0) 0) - ) - (set! (-> s5-8 param 1) 1.00001) - (joint-control-channel-group-eval! - s5-8 - (the-as art-joint-anim #f) - num-func-seek! - ) - ) - ) ) - (else - (let ((s5-9 (-> self skel root-channel 0))) - (set! - (-> s5-9 frame-group) - (the-as art-joint-anim (-> self draw art-group data 29)) - ) - (set! (-> s5-9 param 0) (ja-aframe (the-as float 4.0) 0)) - (set! (-> s5-9 param 1) 1.00001) - (set! (-> s5-9 frame-num) 0.0) - (joint-control-channel-group! - s5-9 - (the-as art-joint-anim (-> self draw art-group data 29)) - num-func-seek! - ) - ) - (until (ja-done? 0) - (suspend) - (let ((s5-10 (-> self skel root-channel 0))) - (set! (-> s5-10 param 0) (ja-aframe (the-as float 4.0) 0)) - (set! (-> s5-10 param 1) 1.00001) - (joint-control-channel-group-eval! - s5-10 - (the-as art-joint-anim #f) - num-func-seek! + (cond + ((>= f26-1 0.0) + (let ((v1-341 (-> self skel root-channel 2))) + (set! (-> v1-341 frame-interp) (fabs f26-1)) + (set! (-> v1-341 dist) (-> *TARGET-bank* walk-side-cycle-dist)) + (set! (-> v1-341 frame-group) (the-as art-joint-anim (-> self draw art-group data 26))) + ) + (let ((v1-344 (-> self skel root-channel 5))) + (set! (-> v1-344 frame-interp) (fabs f26-1)) + (set! (-> v1-344 dist) (-> *TARGET-bank* run-side-cycle-dist)) + (set! (-> v1-344 frame-group) (the-as art-joint-anim (-> self draw art-group data 21))) ) - ) ) + (else + (let ((v1-347 (-> self skel root-channel 2))) + (set! (-> v1-347 frame-interp) (fabs f26-1)) + (set! (-> v1-347 dist) (-> *TARGET-bank* walk-side-cycle-dist)) + (set! (-> v1-347 frame-group) (the-as art-joint-anim (-> self draw art-group data 27))) + ) + (let ((v1-350 (-> self skel root-channel 5))) + (set! (-> v1-350 frame-interp) (fabs f26-1)) + (set! (-> v1-350 dist) (-> *TARGET-bank* run-side-cycle-dist)) + (set! (-> v1-350 frame-group) (the-as art-joint-anim (-> self draw art-group data 22))) + ) + ) ) - ) - ) - (until (ja-done? 0) + (set! (-> self skel root-channel 6 frame-interp) f30-0) + (let* ((f1-19 (dummy-9 (-> self skel))) + (f0-92 (/ (-> self control unknown-float01) (* 60.0 (/ f1-19 (-> *TARGET-bank* run-cycle-length))))) + (a0-182 (-> self skel root-channel 0)) + ) + (set! (-> a0-182 param 0) f0-92) + (joint-control-channel-group-eval! a0-182 (the-as art-joint-anim #f) num-func-loop!) + ) + (let ((a0-183 (-> self skel root-channel 1))) + (set! (-> a0-183 param 0) 0.0) + (joint-control-channel-group-eval! a0-183 (the-as art-joint-anim #f) num-func-chan) + ) + (let ((a0-184 (-> self skel root-channel 2))) + (set! (-> a0-184 param 0) 0.0) + (joint-control-channel-group-eval! a0-184 (the-as art-joint-anim #f) num-func-chan) + ) + (let ((a0-185 (-> self skel root-channel 3))) + (set! (-> a0-185 param 0) 0.0) + (joint-control-channel-group-eval! a0-185 (the-as art-joint-anim #f) num-func-chan) + ) + (let ((a0-186 (-> self skel root-channel 4))) + (set! (-> a0-186 param 0) 0.0) + (joint-control-channel-group-eval! a0-186 (the-as art-joint-anim #f) num-func-chan) + ) + (let ((a0-187 (-> self skel root-channel 5))) + (set! (-> a0-187 param 0) 0.0) + (joint-control-channel-group-eval! a0-187 (the-as art-joint-anim #f) num-func-chan) + ) + (if (and gp-0 (!= (-> self skel root-channel 0) (-> self skel channel))) + (ja-blend-eval) + ) (suspend) - (let ((a0-116 (-> self skel root-channel 0))) - (set! - (-> a0-116 param 0) - (the float (+ (-> a0-116 frame-group data 0 length) -1)) - ) - (set! - (-> a0-116 param 1) - (/ - (* - (fmax 20480.0 (-> self control unknown-float01)) - (-> *display* seconds-per-frame) - ) - (/ - (-> *TARGET-bank* run-up-cycle-dist) - (-> *TARGET-bank* run-cycle-length) - ) - ) - ) - (joint-control-channel-group-eval! - a0-116 - (the-as art-joint-anim #f) - num-func-seek! - ) - ) ) - (set! f28-0 30.0) - (set! f30-0 (-> (new 'static 'array float 1 1.0) 0)) - (ja-channel-set! 7) - ) - ((= (if (> (-> self skel active-channels) 0) - (-> self skel root-channel 0 frame-group) - ) - (-> self draw art-group data 34) - ) - (ja-channel-push! 7 15) - (set! gp-0 #t) - ) - ((= (if (> (-> self skel active-channels) 0) - (-> self skel root-channel 0 frame-group) - ) - (-> self draw art-group data 78) - ) - (ja-channel-push! 7 45) - ) - (else - (ja-channel-push! 7 15) - ) ) - ) ) - ) - (set! (-> self skel root-channel 3 command) 'push) - (set! (-> self skel root-channel 6 command) 'stack) - (let ((v1-265 (-> self skel root-channel 0))) - (set! - (-> v1-265 frame-group) - (the-as art-joint-anim (-> self draw art-group data 23)) - ) - ) - (let ((f28-1 (ja-aframe f28-0 0))) - (let ((s5-11 (-> self skel root-channel 0))) - (set! (-> s5-11 frame-interp) 0.0) - (set! (-> s5-11 dist) (-> *TARGET-bank* walk-cycle-dist)) - (joint-control-channel-group-eval! - s5-11 - (the-as art-joint-anim (-> self draw art-group data 23)) - num-func-identity - ) - (set! (-> s5-11 frame-num) f28-1) - ) - (let ((s5-12 (-> self skel root-channel 1))) - (set! (-> s5-12 frame-interp) 0.0) - (set! (-> s5-12 dist) (-> *TARGET-bank* walk-down-cycle-dist)) - (joint-control-channel-group-eval! - s5-12 - (the-as art-joint-anim (-> self draw art-group data 25)) - num-func-identity - ) - (set! (-> s5-12 frame-num) f28-1) - ) - (let ((s5-13 (-> self skel root-channel 2))) - (set! (-> s5-13 frame-interp) 0.0) - (set! (-> s5-13 dist) (-> *TARGET-bank* walk-side-cycle-dist)) - (joint-control-channel-group-eval! - s5-13 - (the-as art-joint-anim (-> self draw art-group data 27)) - num-func-identity - ) - (set! (-> s5-13 frame-num) f28-1) - ) - (let ((s5-14 (-> self skel root-channel 4))) - (set! (-> s5-14 frame-interp) 0.0) - (set! (-> s5-14 dist) (-> *TARGET-bank* run-down-cycle-dist)) - (joint-control-channel-group-eval! - s5-14 - (the-as art-joint-anim (-> self draw art-group data 20)) - num-func-identity - ) - (set! (-> s5-14 frame-num) f28-1) - ) - (let ((s5-15 (-> self skel root-channel 5))) - (set! (-> s5-15 frame-interp) 0.0) - (set! (-> s5-15 dist) (-> *TARGET-bank* run-side-cycle-dist)) - (joint-control-channel-group-eval! - s5-15 - (the-as art-joint-anim (-> self draw art-group data 22)) - num-func-identity - ) - (set! (-> s5-15 frame-num) f28-1) - ) - (let ((s5-16 (-> self skel root-channel 3))) - (set! (-> s5-16 frame-interp) 0.0) - (set! (-> s5-16 dist) (-> *TARGET-bank* run-cycle-dist)) - (joint-control-channel-group-eval! - s5-16 - (the-as art-joint-anim (-> self draw art-group data 18)) - num-func-identity - ) - (set! (-> s5-16 frame-num) f28-1) - ) - ) - (let ((f28-2 0.0) - (f26-1 0.0) - ) - (while #t - (let - ((f22-0 - (fmax - (-> (new 'static 'array float 1 -1.0) 0) - (fmin - (-> (new 'static 'array float 1 1.0) 0) - (* 2.0 (-> self control unknown-float61)) - ) - ) - ) - (f24-0 - (fmax - (-> (new 'static 'array float 1 -1.0) 0) - (fmin - (-> (new 'static 'array float 1 1.0) 0) - (* 1.6 (-> self control unknown-float62)) - ) - ) - ) - ) - (set! - f30-0 - (seek - f30-0 - (fmax - 0.0 - (fmin - (-> (new 'static 'array float 1 1.0) 0) - (* 0.000048828126 (+ -16384.0 (-> self control unknown-float01))) - ) - ) - (* 2.0 (-> *display* seconds-per-frame)) - ) - ) - (let ((v1-317 (-> self skel effect))) - (set! (-> v1-317 channel-offset) (if (< 0.5 f30-0) - 3 - 0 - ) - ) - ) - 0 - (let ((f0-64 (fabs (- f22-0 f28-2)))) - (set! f28-2 (seek f28-2 f22-0 (fmax 0.05 (fmin 0.2 (* 0.25 f0-64))))) - ) - (let ((f0-69 (fabs (- f24-0 f26-1)))) - (set! f26-1 (seek f26-1 f24-0 (fmax 0.05 (fmin 0.2 (* 0.25 f0-69))))) - ) - ) - (cond - ((>= f28-2 0.0) - (let ((v1-329 (-> self skel root-channel 1))) - (set! (-> v1-329 frame-interp) (fabs f28-2)) - (set! (-> v1-329 dist) (-> *TARGET-bank* walk-up-cycle-dist)) - (set! - (-> v1-329 frame-group) - (the-as art-joint-anim (-> self draw art-group data 24)) - ) - ) - (let ((v1-332 (-> self skel root-channel 4))) - (set! (-> v1-332 frame-interp) (fabs f28-2)) - (set! (-> v1-332 dist) (-> *TARGET-bank* run-up-cycle-dist)) - (set! - (-> v1-332 frame-group) - (the-as art-joint-anim (-> self draw art-group data 19)) - ) - ) - ) - (else - (let ((v1-335 (-> self skel root-channel 1))) - (set! (-> v1-335 frame-interp) (fabs f28-2)) - (set! (-> v1-335 dist) (-> *TARGET-bank* walk-down-cycle-dist)) - (set! - (-> v1-335 frame-group) - (the-as art-joint-anim (-> self draw art-group data 25)) - ) - ) - (let ((v1-338 (-> self skel root-channel 4))) - (set! (-> v1-338 frame-interp) (fabs f28-2)) - (set! (-> v1-338 dist) (-> *TARGET-bank* run-down-cycle-dist)) - (set! - (-> v1-338 frame-group) - (the-as art-joint-anim (-> self draw art-group data 20)) - ) - ) - ) - ) - (cond - ((>= f26-1 0.0) - (let ((v1-341 (-> self skel root-channel 2))) - (set! (-> v1-341 frame-interp) (fabs f26-1)) - (set! (-> v1-341 dist) (-> *TARGET-bank* walk-side-cycle-dist)) - (set! - (-> v1-341 frame-group) - (the-as art-joint-anim (-> self draw art-group data 26)) - ) - ) - (let ((v1-344 (-> self skel root-channel 5))) - (set! (-> v1-344 frame-interp) (fabs f26-1)) - (set! (-> v1-344 dist) (-> *TARGET-bank* run-side-cycle-dist)) - (set! - (-> v1-344 frame-group) - (the-as art-joint-anim (-> self draw art-group data 21)) - ) - ) - ) - (else - (let ((v1-347 (-> self skel root-channel 2))) - (set! (-> v1-347 frame-interp) (fabs f26-1)) - (set! (-> v1-347 dist) (-> *TARGET-bank* walk-side-cycle-dist)) - (set! - (-> v1-347 frame-group) - (the-as art-joint-anim (-> self draw art-group data 27)) - ) - ) - (let ((v1-350 (-> self skel root-channel 5))) - (set! (-> v1-350 frame-interp) (fabs f26-1)) - (set! (-> v1-350 dist) (-> *TARGET-bank* run-side-cycle-dist)) - (set! - (-> v1-350 frame-group) - (the-as art-joint-anim (-> self draw art-group data 22)) - ) - ) - ) - ) - (set! (-> self skel root-channel 6 frame-interp) f30-0) - (let* ((f1-19 (dummy-9 (-> self skel))) - (f0-92 - (/ - (-> self control unknown-float01) - (* 60.0 (/ f1-19 (-> *TARGET-bank* run-cycle-length))) - ) - ) - (a0-182 (-> self skel root-channel 0)) - ) - (set! (-> a0-182 param 0) f0-92) - (joint-control-channel-group-eval! - a0-182 - (the-as art-joint-anim #f) - num-func-loop! - ) - ) - (let ((a0-183 (-> self skel root-channel 1))) - (set! (-> a0-183 param 0) 0.0) - (joint-control-channel-group-eval! - a0-183 - (the-as art-joint-anim #f) - num-func-chan - ) - ) - (let ((a0-184 (-> self skel root-channel 2))) - (set! (-> a0-184 param 0) 0.0) - (joint-control-channel-group-eval! - a0-184 - (the-as art-joint-anim #f) - num-func-chan - ) - ) - (let ((a0-185 (-> self skel root-channel 3))) - (set! (-> a0-185 param 0) 0.0) - (joint-control-channel-group-eval! - a0-185 - (the-as art-joint-anim #f) - num-func-chan - ) - ) - (let ((a0-186 (-> self skel root-channel 4))) - (set! (-> a0-186 param 0) 0.0) - (joint-control-channel-group-eval! - a0-186 - (the-as art-joint-anim #f) - num-func-chan - ) - ) - (let ((a0-187 (-> self skel root-channel 5))) - (set! (-> a0-187 param 0) 0.0) - (joint-control-channel-group-eval! - a0-187 - (the-as art-joint-anim #f) - num-func-chan - ) - ) - (if (and gp-0 (!= (-> self skel root-channel 0) (-> self skel channel))) - (ja-blend-eval) - ) - (suspend) - ) - ) + (none) ) - (none) - ) :post (the-as (function none :behavior target) target-post) ) +;; failed to figure out what this is: (defstate target-turn-around (target) :event target-standard-event-handler :enter (behavior () - (vector-turn-to (-> self control transv)) - (set! (-> self control unknown-surface00) *turn-around-mods*) - (set! - (-> self control unknown-float81) - (-> (new 'static 'array float 1 1.0) 0) + (vector-turn-to (-> self control transv)) + (set! (-> self control unknown-surface00) *turn-around-mods*) + (set! (-> self control unknown-float81) (-> (new 'static 'array float 1 1.0) 0)) + (none) ) - (none) - ) :exit (behavior () - (target-state-hook-exit) - (set-forward-vel (-> (new 'static 'array float 1 0.0) 0)) - (set! (-> self control unknown-float01) 0.0) - (set-quaternion! (-> self control) (-> self control dir-targ)) - (set! (-> self control unknown-float81) 0.0) - (none) - ) + (target-state-hook-exit) + (set-forward-vel (-> (new 'static 'array float 1 0.0) 0)) + (set! (-> self control unknown-float01) 0.0) + (set-quaternion! (-> self control) (-> self control dir-targ)) + (set! (-> self control unknown-float81) 0.0) + (none) + ) :trans (behavior () - ((-> self state-hook)) - (if - (and - (logtest? - (logior - (logior - (-> - *cpad-list* - cpads - (-> self control unknown-cpad-info00 number) - button0-rel - 0 - ) - (-> - *cpad-list* - cpads - (-> self control unknown-cpad-info00 number) - button0-rel - 1 - ) + ((-> self state-hook)) + (if (and (logtest? (logior (logior (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) button0-rel 0) + (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) button0-rel 1) + ) + (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) button0-rel 2) + ) + (pad-buttons x) + ) + (can-jump? #f) + ) + (go target-jump (-> *TARGET-bank* jump-height-min) (-> *TARGET-bank* jump-height-max) (the-as surface #f)) ) - (-> - *cpad-list* - cpads - (-> self control unknown-cpad-info00 number) - button0-rel - 2 + (if (and (logtest? (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) button0-rel 0) + (pad-buttons circle) + ) + (can-feet?) + ) + (go target-attack) ) - ) - (pad-buttons x) - ) - (can-jump? #f) - ) - (go - target-jump - (-> *TARGET-bank* jump-height-min) - (-> *TARGET-bank* jump-height-max) - (the-as surface #f) - ) + (if (can-hands? #t) + (go target-running-attack) + ) + (if (and (zero? (logand (-> self control status) 1)) + (>= (- (-> *display* base-frame-counter) (-> self control unknown-dword11)) 24) + ) + (go target-falling #f) + ) + (slide-down-test) + (none) ) - (if - (and - (logtest? - (-> - *cpad-list* - cpads - (-> self control unknown-cpad-info00 number) - button0-rel - 0 - ) - (pad-buttons circle) - ) - (can-feet?) - ) - (go target-attack) - ) - (if (can-hands? #t) - (go target-running-attack) - ) - (if - (and - (zero? (logand (-> self control status) 1)) - (>= - (- (-> *display* base-frame-counter) (-> self control unknown-dword11)) - 24 - ) - ) - (go target-falling #f) - ) - (slide-down-test) - (none) - ) :code (behavior () - (ja-channel-push! 1 12) - (let ((gp-0 (-> self skel root-channel 0))) - (joint-control-channel-group-eval! - gp-0 - (the-as art-joint-anim (-> self draw art-group data 33)) - num-func-identity - ) - (set! (-> gp-0 frame-num) 0.0) - ) - (quaternion-rotate-y! - (-> self control dir-targ) - (-> self control dir-targ) - (the-as float 32768.0) - ) - (TODO-RENAME-9 (-> self align)) - (until (ja-done? 0) - (suspend) - (let ((a0-4 (-> self skel root-channel 0))) - (set! - (-> a0-4 param 0) - (the float (+ (-> a0-4 frame-group data 0 length) -1)) + (ja-channel-push! 1 12) + (let ((gp-0 (-> self skel root-channel 0))) + (joint-control-channel-group-eval! + gp-0 + (the-as art-joint-anim (-> self draw art-group data 33)) + num-func-identity + ) + (set! (-> gp-0 frame-num) 0.0) ) - (set! (-> a0-4 param 1) 2.0) - (joint-control-channel-group-eval! - a0-4 - (the-as art-joint-anim #f) - num-func-seek! - ) - ) + (quaternion-rotate-y! (-> self control dir-targ) (-> self control dir-targ) (the-as float 32768.0)) (TODO-RENAME-9 (-> self align)) - (TODO-RENAME-10 - (-> self align) - 16 - (-> (new 'static 'array float 1 1.0) 0) - (-> (new 'static 'array float 1 1.0) 0) - (-> (new 'static 'array float 1 1.0) 0) - ) + (until (ja-done? 0) + (suspend) + (let ((a0-4 (-> self skel root-channel 0))) + (set! (-> a0-4 param 0) (the float (+ (-> a0-4 frame-group data 0 length) -1))) + (set! (-> a0-4 param 1) 2.0) + (joint-control-channel-group-eval! a0-4 (the-as art-joint-anim #f) num-func-seek!) + ) + (TODO-RENAME-9 (-> self align)) + (TODO-RENAME-10 + (-> self align) + 16 + (-> (new 'static 'array float 1 1.0) 0) + (-> (new 'static 'array float 1 1.0) 0) + (-> (new 'static 'array float 1 1.0) 0) + ) + ) + (remove-exit) + (set! (-> self control unknown-float81) 0.0) + (set-forward-vel (the-as float 40960.0)) + (set! (-> self control unknown-float01) 40960.0) + (target-state-hook-exit) + (go target-walk) + (none) ) - (remove-exit) - (set! (-> self control unknown-float81) 0.0) - (set-forward-vel (the-as float 40960.0)) - (set! (-> self control unknown-float01) 40960.0) - (target-state-hook-exit) - (go target-walk) - (none) - ) :post target-no-stick-post ) +;; failed to figure out what this is: (defstate target-slide-down (target) :event target-walk-event-handler :enter (behavior () - (set! (-> self control unknown-surface00) *jump-mods*) - (none) - ) + (set! (-> self control unknown-surface00) *jump-mods*) + (none) + ) :exit (behavior () - (set! (-> self control unknown-dword35) (-> *display* base-frame-counter)) - (none) - ) + (set! (-> self control unknown-dword35) (-> *display* base-frame-counter)) + (none) + ) :trans (behavior () - (when - (or - (logtest? (-> self control status) 1) - (if - (< - (target-move-dist (the-as int (-> *TARGET-bank* stuck-time))) - (-> *TARGET-bank* stuck-distance) - ) - #t + (when (or (logtest? (-> self control status) 1) + (if (< (target-move-dist (the-as int (-> *TARGET-bank* stuck-time))) (-> *TARGET-bank* stuck-distance)) + #t + ) + ) + (logior! (-> self control status) 1) + (go target-duck-stance) ) - ) - (logior! (-> self control status) 1) - (go target-duck-stance) + (none) ) - (none) - ) :code (behavior () - (if (not (= (if (> (-> self skel active-channels) 0) - (-> self skel root-channel 0 frame-group) + (if (not (= (if (> (-> self skel active-channels) 0) + (-> self skel root-channel 0 frame-group) + ) + (-> self draw art-group data 31) ) - (-> self draw art-group data 31) ) + (ja-channel-push! 1 30) ) - (ja-channel-push! 1 30) - ) - (while #t - (let ((a0-5 (-> self skel root-channel 0))) - (set! - (-> a0-5 frame-group) - (the-as art-joint-anim (-> self draw art-group data 31)) - ) - (set! - (-> a0-5 param 0) - (the - float - (+ - (-> - (the-as art-joint-anim (-> self draw art-group data 31)) - data - 0 - length - ) - -1 + (while #t + (let ((a0-5 (-> self skel root-channel 0))) + (set! (-> a0-5 frame-group) (the-as art-joint-anim (-> self draw art-group data 31))) + (set! (-> a0-5 param 0) + (the float (+ (-> (the-as art-joint-anim (-> self draw art-group data 31)) data 0 length) -1)) + ) + (set! (-> a0-5 param 1) (-> (new 'static 'array float 1 1.0) 0)) + (set! (-> a0-5 frame-num) 0.0) + (joint-control-channel-group! a0-5 (the-as art-joint-anim (-> self draw art-group data 31)) num-func-seek!) + ) + (until (ja-done? 0) + (suspend) + (let ((a0-6 (-> self skel root-channel 0))) + (set! (-> a0-6 param 0) (the float (+ (-> a0-6 frame-group data 0 length) -1))) + (set! (-> a0-6 param 1) (-> (new 'static 'array float 1 1.0) 0)) + (joint-control-channel-group-eval! a0-6 (the-as art-joint-anim #f) num-func-seek!) + ) ) - ) ) - (set! (-> a0-5 param 1) (-> (new 'static 'array float 1 1.0) 0)) - (set! (-> a0-5 frame-num) 0.0) - (joint-control-channel-group! - a0-5 - (the-as art-joint-anim (-> self draw art-group data 31)) - num-func-seek! - ) - ) - (until (ja-done? 0) - (suspend) - (let ((a0-6 (-> self skel root-channel 0))) - (set! - (-> a0-6 param 0) - (the float (+ (-> a0-6 frame-group data 0 length) -1)) - ) - (set! (-> a0-6 param 1) (-> (new 'static 'array float 1 1.0) 0)) - (joint-control-channel-group-eval! - a0-6 - (the-as art-joint-anim #f) - num-func-seek! - ) - ) - ) + (none) ) - (none) - ) :post (the-as (function none :behavior target) target-post) ) -(defbehavior - init-var-jump target - ((arg0 float) (arg1 float) (arg2 vector) (arg3 vector) (arg4 vector)) +;; definition for function init-var-jump +;; Used lq/sq +(defbehavior init-var-jump target ((arg0 float) (arg1 float) (arg2 vector) (arg3 vector) (arg4 vector)) (set! (-> self control status) (logand -16385 (-> self control status))) (delete-back-vel) - (when - (< - (- - (-> *display* base-frame-counter) - (the-as int (-> self control rider-time)) - ) - 15 - ) - (let - ((f0-1 - (fmax - 0.0 - (fmin - 28672.0 - (* - 0.5 - (vector-dot - (-> self control dynam gravity-normal) - (-> self control rider-last-move) + (when (< (- (-> *display* base-frame-counter) (the-as int (-> self control rider-time))) 15) + (let ((f0-1 + (fmax + 0.0 + (fmin 28672.0 (* 0.5 (vector-dot (-> self control dynam gravity-normal) (-> self control rider-last-move)))) + ) + ) ) - ) - ) - ) + (set! arg0 (+ arg0 f0-1)) + (set! arg1 (+ arg1 f0-1)) + ) + (when (or (logtest? (-> self control unknown-surface01 flags) #x4000) + (= (-> self control poly-pat material) (pat-material rotate)) + ) + (+! (-> self control transv x) (-> self control rider-last-move x)) + (+! (-> self control transv z) (-> self control rider-last-move z)) ) - ) - (set! arg0 (+ arg0 f0-1)) - (set! arg1 (+ arg1 f0-1)) ) - (when - (or - (logtest? (-> self control unknown-surface01 flags) #x4000) - (= (-> self control poly-pat material) (pat-material rotate)) - ) - (+! (-> self control transv x) (-> self control rider-last-move x)) - (+! (-> self control transv z) (-> self control rider-last-move z)) - ) - ) (set! (-> self control unknown-float123) 0.0) (set! (-> self control unknown-float124) 0.0) (cond - (arg3 - (set! - (-> self control unknown-uint20) - (the-as uint (- arg0 (+ -409.6 (-> *TARGET-bank* jump-collide-offset)))) - ) - (set! - (-> self control unknown-int21) - (the-as int (- arg1 (-> *TARGET-bank* jump-collide-offset))) - ) - ) - (else - (set! (-> self control unknown-uint20) (the-as uint arg0)) - (set! (-> self control unknown-int21) (the-as int arg1)) - ) - ) - (when arg2 - (let ((s4-1 (new-stack-vector0))) - (let ((f0-16 (vector-dot (-> self control dynam gravity-normal) arg4))) - 0.0 - (vector-! - s4-1 - arg4 - (vector-float*! s4-1 (-> self control dynam gravity-normal) f0-16) - ) - ) - (let* ((f0-17 (vector-length s4-1)) - (f1-11 f0-17) - (f2-7 - (- - (sqrtf (* 2.0 (-> self control dynam gravity-length) arg0)) - (* 0.008333334 (- (-> self control dynam gravity-length))) - ) + (arg3 + (set! (-> self control unknown-uint20) + (the-as uint (- arg0 (+ -409.6 (-> *TARGET-bank* jump-collide-offset)))) ) - ) - (vector+! - arg4 - (vector-float*! arg4 (-> self control dynam gravity-normal) f2-7) - (vector-float*! s4-1 s4-1 (/ f0-17 f1-11)) + (set! (-> self control unknown-int21) (the-as int (- arg1 (-> *TARGET-bank* jump-collide-offset)))) ) - ) - ) - ) - (let ((v0-2 (-> self control unknown-vector102))) - (set! (-> v0-2 quad) (-> self control trans quad)) - v0-2 - ) - ) - -(defbehavior - mod-var-jump target - ((arg0 symbol) (arg1 symbol) (arg2 symbol) (arg3 vector)) - (local-vars (v0-2 vector)) - (let - ((f30-0 - (* - 0.033333335 - (the float (- (-> *display* base-frame-counter) (-> self state-time))) - ) - ) - ) - (cond - ((or - (< (-> (new 'static 'array float 1 1.0) 0) f30-0) - (< (-> self control unknown-float123) 0.0) - (not arg2) - ) - (set! - (-> self control unknown-float123) - (-> (new 'static 'array float 1 -1.0) 0) - ) - ) (else - (set! (-> self control unknown-float123) f30-0) - (set! (-> self control unknown-float124) f30-0) - (when arg0 - (let - ((s3-1 - (vector-! - (new-stack-vector0) - (-> self control trans) - (-> self control unknown-vector102) - ) - ) - (s4-0 (new-stack-vector0)) - ) - (let ((f0-5 (vector-dot (-> self control dynam gravity-normal) arg3))) + (set! (-> self control unknown-uint20) (the-as uint arg0)) + (set! (-> self control unknown-int21) (the-as int arg1)) + ) + ) + (when arg2 + (let ((s4-1 (new-stack-vector0))) + (let ((f0-16 (vector-dot (-> self control dynam gravity-normal) arg4))) 0.0 - (vector-! - s4-0 - arg3 - (vector-float*! s4-0 (-> self control dynam gravity-normal) f0-5) - ) + (vector-! s4-1 arg4 (vector-float*! s4-1 (-> self control dynam gravity-normal) f0-16)) ) - (let* ((f28-0 (vector-length s4-0)) - (f26-0 f28-0) - (f0-13 - (- - (sqrtf - (* - 2.0 - (-> self control dynam gravity-length) - (- - (lerp-scale - (the-as float (-> self control unknown-uint20)) - (the-as float (-> self control unknown-uint30)) - f30-0 - (-> (new 'static 'array float 1 0.0) 0) - (-> (new 'static 'array float 1 1.0) 0) - ) - (vector-dot (-> self control dynam gravity-normal) s3-1) - ) + (let* ((f0-17 (vector-length s4-1)) + (f1-11 f0-17) + (f2-7 + (- (sqrtf (* 2.0 (-> self control dynam gravity-length) arg0)) + (* 0.008333334 (- (-> self control dynam gravity-length))) ) - ) - (* 0.008333334 (- (-> self control dynam gravity-length))) - ) ) - ) + ) (vector+! - arg3 - (vector-float*! arg3 (-> self control dynam gravity-normal) f0-13) - (vector-float*! s4-0 s4-0 (/ f28-0 f26-0)) - ) + arg4 + (vector-float*! arg4 (-> self control dynam gravity-normal) f2-7) + (vector-float*! s4-1 s4-1 (/ f0-17 f1-11)) + ) ) - ) ) - ) ) - ) - 0 - (when (and arg1 (if (> (-> self skel active-channels) 0) - (-> self skel root-channel 0 frame-group) - ) - (and (-> (if (> (-> self skel active-channels) 0) - (-> self skel root-channel 0 frame-group) - ) - extra - ) - #t - ) - ) - (let ((v1-57 (res-lump-struct (-> (if (> (-> self skel active-channels) 0) - (-> self skel root-channel 0 frame-group) - ) - extra - ) - 'collide-offset vector :time (ja-frame-num 0) - ) - ) - ) - (cond - (v1-57 - (set! v0-2 (-> self control unknown-vector13)) - (set! (-> v0-2 quad) (-> v1-57 quad)) - ) - (else - (set! v0-2 (-> self control unknown-vector13)) - (set! (-> v0-2 quad) (the-as uint128 0)) - ) - ) + (let ((v0-2 (-> self control unknown-vector102))) + (set! (-> v0-2 quad) (-> self control trans quad)) + v0-2 ) - v0-2 - ) ) +;; definition for function mod-var-jump +;; Used lq/sq +(defbehavior mod-var-jump target ((arg0 symbol) (arg1 symbol) (arg2 symbol) (arg3 vector)) + (local-vars (v0-2 vector)) + (let ((f30-0 (* 0.033333335 (the float (- (-> *display* base-frame-counter) (-> self state-time)))))) + (cond + ((or (< (-> (new 'static 'array float 1 1.0) 0) f30-0) (< (-> self control unknown-float123) 0.0) (not arg2)) + (set! (-> self control unknown-float123) (-> (new 'static 'array float 1 -1.0) 0)) + ) + (else + (set! (-> self control unknown-float123) f30-0) + (set! (-> self control unknown-float124) f30-0) + (when arg0 + (let ((s3-1 (vector-! (new-stack-vector0) (-> self control trans) (-> self control unknown-vector102))) + (s4-0 (new-stack-vector0)) + ) + (let ((f0-5 (vector-dot (-> self control dynam gravity-normal) arg3))) + 0.0 + (vector-! s4-0 arg3 (vector-float*! s4-0 (-> self control dynam gravity-normal) f0-5)) + ) + (let* ((f28-0 (vector-length s4-0)) + (f26-0 f28-0) + (f0-13 + (- (sqrtf + (* 2.0 + (-> self control dynam gravity-length) + (- (lerp-scale + (the-as float (-> self control unknown-uint20)) + (the-as float (-> self control unknown-uint30)) + f30-0 + (-> (new 'static 'array float 1 0.0) 0) + (-> (new 'static 'array float 1 1.0) 0) + ) + (vector-dot (-> self control dynam gravity-normal) s3-1) + ) + ) + ) + (* 0.008333334 (- (-> self control dynam gravity-length))) + ) + ) + ) + (vector+! + arg3 + (vector-float*! arg3 (-> self control dynam gravity-normal) f0-13) + (vector-float*! s4-0 s4-0 (/ f28-0 f26-0)) + ) + ) + ) + ) + ) + ) + ) + 0 + (when (and arg1 + (if (> (-> self skel active-channels) 0) + (-> self skel root-channel 0 frame-group) + ) + (and (-> (if (> (-> self skel active-channels) 0) + (-> self skel root-channel 0 frame-group) + ) + extra + ) + #t + ) + ) + (let ((v1-57 (res-lump-struct + (-> (if (> (-> self skel active-channels) 0) + (-> self skel root-channel 0 frame-group) + ) + extra + ) + 'collide-offset + vector + :time + (ja-frame-num 0) + ) + ) + ) + (cond + (v1-57 + (set! v0-2 (-> self control unknown-vector13)) + (set! (-> v0-2 quad) (-> v1-57 quad)) + ) + (else + (set! v0-2 (-> self control unknown-vector13)) + (set! (-> v0-2 quad) (the-as uint128 0)) + ) + ) + ) + v0-2 + ) + ) + +;; failed to figure out what this is: (defstate target-duck-stance (target) :event target-standard-event-handler :enter (behavior () - (set! - (-> self control unknown-float81) - (-> (new 'static 'array float 1 1.0) 0) + (set! (-> self control unknown-float81) (-> (new 'static 'array float 1 1.0) 0)) + (set! (-> self control unknown-surface00) *duck-mods*) + (target-collide-set! 'duck (-> (new 'static 'array float 1 1.0) 0)) + (none) ) - (set! (-> self control unknown-surface00) *duck-mods*) - (target-collide-set! 'duck (-> (new 'static 'array float 1 1.0) 0)) - (none) - ) :exit (behavior () - (if - (not - (or - (= (-> self next-state name) 'target-duck-walk) - (= (-> self next-state name) 'target-duck-stance) - (= (-> self next-state name) 'target-walk) - (= (-> self next-state name) 'target-stance) - (= (-> self next-state name) 'target-stance-look-around) - ) - ) - (target-state-hook-exit) + (if (not (or (= (-> self next-state name) 'target-duck-walk) + (= (-> self next-state name) 'target-duck-stance) + (= (-> self next-state name) 'target-walk) + (= (-> self next-state name) 'target-stance) + (= (-> self next-state name) 'target-stance-look-around) + ) + ) + (target-state-hook-exit) + ) + (target-exit) + (target-collide-set! 'normal (-> (new 'static 'array float 1 0.0) 0)) + (none) ) - (target-exit) - (target-collide-set! 'normal (-> (new 'static 'array float 1 0.0) 0)) - (none) - ) :trans (behavior () - ((-> self state-hook)) - (if - (and - (or - (zero? - (logand - (-> - *cpad-list* - cpads - (-> self control unknown-cpad-info00 number) - button0-abs - 0 - ) - (pad-buttons l1 r1) - ) - ) - (logtest? (-> self state-flags) 8192) - ) - (let ((v1-13 (if (> (-> self skel active-channels) 0) - (-> self skel root-channel 0 frame-group) + ((-> self state-hook)) + (if (and (or (zero? + (logand (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) button0-abs 0) (pad-buttons l1 r1)) ) - ) - ) - (and - (not - (or - (= v1-13 (-> self draw art-group data 70)) - (= v1-13 (-> self draw art-group data 69)) - ) + (logtest? (-> self state-flags) 8192) + ) + (let ((v1-13 (if (> (-> self skel active-channels) 0) + (-> self skel root-channel 0 frame-group) + ) + ) + ) + (and (not (or (= v1-13 (-> self draw art-group data 70)) (= v1-13 (-> self draw art-group data 69)))) + (can-exit-duck?) + ) + ) + ) + (go target-stance) ) - (can-exit-duck?) - ) - ) - ) - (go target-stance) - ) - (if (move-legs?) - (go target-duck-walk) - ) - (when - (and - (logtest? - (logior - (logior - (-> - *cpad-list* - cpads - (-> self control unknown-cpad-info00 number) - button0-rel - 0 - ) - (-> - *cpad-list* - cpads - (-> self control unknown-cpad-info00 number) - button0-rel - 1 - ) + (if (move-legs?) + (go target-duck-walk) ) - (-> - *cpad-list* - cpads - (-> self control unknown-cpad-info00 number) - button0-rel - 2 + (when (and (logtest? (logior (logior (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) button0-rel 0) + (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) button0-rel 1) + ) + (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) button0-rel 2) + ) + (pad-buttons x) + ) + (can-jump? #f) + ) + (if (= (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) stick0-speed) 0.0) + (go target-high-jump (-> *TARGET-bank* duck-jump-height-min) (-> *TARGET-bank* duck-jump-height-max) 'duck) + (go target-jump (-> *TARGET-bank* jump-height-min) (-> *TARGET-bank* jump-height-max) (the-as surface #f)) + ) + ) + (if (and (can-hands? #t) (can-exit-duck?)) + (go + target-attack-uppercut + (-> *TARGET-bank* attack-jump-height-min) + (-> *TARGET-bank* attack-jump-height-max) + ) ) - ) - (pad-buttons x) - ) - (can-jump? #f) - ) - (if - (= - (-> - *cpad-list* - cpads - (-> self control unknown-cpad-info00 number) - stick0-speed - ) - 0.0 - ) - (go - target-high-jump - (-> *TARGET-bank* duck-jump-height-min) - (-> *TARGET-bank* duck-jump-height-max) - 'duck - ) - (go - target-jump - (-> *TARGET-bank* jump-height-min) - (-> *TARGET-bank* jump-height-max) - (the-as surface #f) - ) - ) + (fall-test) + (slide-down-test) + (none) ) - (if (and (can-hands? #t) (can-exit-duck?)) - (go - target-attack-uppercut - (-> *TARGET-bank* attack-jump-height-min) - (-> *TARGET-bank* attack-jump-height-max) - ) - ) - (fall-test) - (slide-down-test) - (none) - ) :code (behavior () - (cond - ((= (if (> (-> self skel active-channels) 0) - (-> self skel root-channel 0 frame-group) - ) - (-> self draw art-group data 69) - ) - (let ((a0-4 (-> self skel root-channel 0))) - (set! - (-> a0-4 frame-group) - (the-as art-joint-anim (-> self draw art-group data 70)) - ) - (set! - (-> a0-4 param 0) - (the - float - (+ - (-> - (the-as art-joint-anim (-> self draw art-group data 70)) - data - 0 - length - ) - -1 - ) - ) - ) - (set! (-> a0-4 param 1) (-> (new 'static 'array float 1 1.0) 0)) - (set! (-> a0-4 frame-num) 0.0) - (joint-control-channel-group! - a0-4 - (the-as art-joint-anim (-> self draw art-group data 70)) - num-func-seek! - ) - ) - (until (ja-done? 0) - (suspend) - (let ((a0-5 (-> self skel root-channel 0))) - (set! - (-> a0-5 param 0) - (the float (+ (-> a0-5 frame-group data 0 length) -1)) - ) - (set! (-> a0-5 param 1) (-> (new 'static 'array float 1 1.0) 0)) - (joint-control-channel-group-eval! - a0-5 - (the-as art-joint-anim #f) - num-func-seek! - ) - ) - ) - ) - ((and (= (if (> (-> self skel active-channels) 0) + (cond + ((= (if (> (-> self skel active-channels) 0) (-> self skel root-channel 0 frame-group) ) - (-> self draw art-group data 31) - ) - (= (-> self skel root-channel 0) (-> self skel channel)) - ) - ) - ((= (if (> (-> self skel active-channels) 0) - (-> self skel root-channel 0 frame-group) - ) - (-> self draw art-group data 32) - ) - (ja-channel-push! 1 30) - ) - (else - (ja-channel-push! 1 12) - (let ((a0-19 (-> self skel root-channel 0))) - (set! - (-> a0-19 frame-group) - (the-as art-joint-anim (-> self draw art-group data 30)) - ) - (set! - (-> a0-19 param 0) - (the - float - (+ - (-> - (the-as art-joint-anim (-> self draw art-group data 30)) - data - 0 - length + (-> self draw art-group data 69) ) - -1 + (let ((a0-4 (-> self skel root-channel 0))) + (set! (-> a0-4 frame-group) (the-as art-joint-anim (-> self draw art-group data 70))) + (set! (-> a0-4 param 0) + (the float (+ (-> (the-as art-joint-anim (-> self draw art-group data 70)) data 0 length) -1)) + ) + (set! (-> a0-4 param 1) (-> (new 'static 'array float 1 1.0) 0)) + (set! (-> a0-4 frame-num) 0.0) + (joint-control-channel-group! a0-4 (the-as art-joint-anim (-> self draw art-group data 70)) num-func-seek!) ) - ) - ) - (set! (-> a0-19 param 1) (-> (new 'static 'array float 1 1.0) 0)) - (set! (-> a0-19 frame-num) 0.0) - (joint-control-channel-group! - a0-19 - (the-as art-joint-anim (-> self draw art-group data 30)) - num-func-seek! - ) - ) - (until (ja-done? 0) - (suspend) - (let ((a0-20 (-> self skel root-channel 0))) - (set! - (-> a0-20 param 0) - (the float (+ (-> a0-20 frame-group data 0 length) -1)) - ) - (set! (-> a0-20 param 1) (-> (new 'static 'array float 1 1.0) 0)) - (joint-control-channel-group-eval! - a0-20 - (the-as art-joint-anim #f) - num-func-seek! - ) - ) - ) - ) - ) - (while #t - (let ((a0-22 (-> self skel root-channel 0))) - (set! - (-> a0-22 frame-group) - (the-as art-joint-anim (-> self draw art-group data 31)) - ) - (set! - (-> a0-22 param 0) - (the - float - (+ - (-> - (the-as art-joint-anim (-> self draw art-group data 31)) - data - 0 - length + (until (ja-done? 0) + (suspend) + (let ((a0-5 (-> self skel root-channel 0))) + (set! (-> a0-5 param 0) (the float (+ (-> a0-5 frame-group data 0 length) -1))) + (set! (-> a0-5 param 1) (-> (new 'static 'array float 1 1.0) 0)) + (joint-control-channel-group-eval! a0-5 (the-as art-joint-anim #f) num-func-seek!) + ) ) - -1 + ) + ((and (= (if (> (-> self skel active-channels) 0) + (-> self skel root-channel 0 frame-group) + ) + (-> self draw art-group data 31) + ) + (= (-> self skel root-channel 0) (-> self skel channel)) + ) + ) + ((= (if (> (-> self skel active-channels) 0) + (-> self skel root-channel 0 frame-group) + ) + (-> self draw art-group data 32) + ) + (ja-channel-push! 1 30) + ) + (else + (ja-channel-push! 1 12) + (let ((a0-19 (-> self skel root-channel 0))) + (set! (-> a0-19 frame-group) (the-as art-joint-anim (-> self draw art-group data 30))) + (set! (-> a0-19 param 0) + (the float (+ (-> (the-as art-joint-anim (-> self draw art-group data 30)) data 0 length) -1)) + ) + (set! (-> a0-19 param 1) (-> (new 'static 'array float 1 1.0) 0)) + (set! (-> a0-19 frame-num) 0.0) + (joint-control-channel-group! a0-19 (the-as art-joint-anim (-> self draw art-group data 30)) num-func-seek!) + ) + (until (ja-done? 0) + (suspend) + (let ((a0-20 (-> self skel root-channel 0))) + (set! (-> a0-20 param 0) (the float (+ (-> a0-20 frame-group data 0 length) -1))) + (set! (-> a0-20 param 1) (-> (new 'static 'array float 1 1.0) 0)) + (joint-control-channel-group-eval! a0-20 (the-as art-joint-anim #f) num-func-seek!) + ) + ) ) - ) ) - (set! (-> a0-22 param 1) (-> (new 'static 'array float 1 1.0) 0)) - (set! (-> a0-22 frame-num) 0.0) - (joint-control-channel-group! - a0-22 - (the-as art-joint-anim (-> self draw art-group data 31)) - num-func-seek! + (while #t + (let ((a0-22 (-> self skel root-channel 0))) + (set! (-> a0-22 frame-group) (the-as art-joint-anim (-> self draw art-group data 31))) + (set! (-> a0-22 param 0) + (the float (+ (-> (the-as art-joint-anim (-> self draw art-group data 31)) data 0 length) -1)) + ) + (set! (-> a0-22 param 1) (-> (new 'static 'array float 1 1.0) 0)) + (set! (-> a0-22 frame-num) 0.0) + (joint-control-channel-group! a0-22 (the-as art-joint-anim (-> self draw art-group data 31)) num-func-seek!) + ) + (until (ja-done? 0) + (suspend) + (let ((a0-23 (-> self skel root-channel 0))) + (set! (-> a0-23 param 0) (the float (+ (-> a0-23 frame-group data 0 length) -1))) + (set! (-> a0-23 param 1) (-> (new 'static 'array float 1 1.0) 0)) + (joint-control-channel-group-eval! a0-23 (the-as art-joint-anim #f) num-func-seek!) + ) + ) ) - ) - (until (ja-done? 0) - (suspend) - (let ((a0-23 (-> self skel root-channel 0))) - (set! - (-> a0-23 param 0) - (the float (+ (-> a0-23 frame-group data 0 length) -1)) - ) - (set! (-> a0-23 param 1) (-> (new 'static 'array float 1 1.0) 0)) - (joint-control-channel-group-eval! - a0-23 - (the-as art-joint-anim #f) - num-func-seek! - ) - ) - ) + (none) ) - (none) - ) :post (the-as (function none :behavior target) target-post) ) +;; failed to figure out what this is: (defstate target-duck-walk (target) :event target-standard-event-handler :enter (behavior () - (set! - (-> self control unknown-float81) - (-> (new 'static 'array float 1 1.0) 0) - ) - (target-collide-set! 'duck (-> (new 'static 'array float 1 1.0) 0)) - (if (not (= (if (> (-> self skel active-channels) 0) - (-> self skel root-channel 0 frame-group) + (set! (-> self control unknown-float81) (-> (new 'static 'array float 1 1.0) 0)) + (target-collide-set! 'duck (-> (new 'static 'array float 1 1.0) 0)) + (if (not (= (if (> (-> self skel active-channels) 0) + (-> self skel root-channel 0 frame-group) + ) + (-> self draw art-group data 69) ) - (-> self draw art-group data 69) ) + (set! (-> self control unknown-surface00) *duck-mods*) ) - (set! (-> self control unknown-surface00) *duck-mods*) + (none) ) - (none) - ) :exit (-> target-duck-stance exit) :trans (behavior () - ((-> self state-hook)) - (if - (and - (or - (zero? - (logand - (-> - *cpad-list* - cpads - (-> self control unknown-cpad-info00 number) - button0-abs - 0 - ) - (pad-buttons l1 r1) + ((-> self state-hook)) + (if (and (or (zero? + (logand (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) button0-abs 0) (pad-buttons l1 r1)) + ) + (logtest? (-> self state-flags) 8192) + (and (logtest? (-> self water flags) 1024) + (>= (- (- (-> self control trans y) (- (-> self water base-height) (-> self water wade-height)))) 2457.6) + ) + ) + (can-exit-duck?) + ) + (go target-walk) ) - ) - (logtest? (-> self state-flags) 8192) - (and - (logtest? (-> self water flags) 1024) - (>= - (- - (- - (-> self control trans y) - (- (-> self water base-height) (-> self water wade-height)) + (if (not (move-legs?)) + (go target-duck-stance) + ) + (when (and (logtest? (logior (logior (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) button0-rel 0) + (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) button0-rel 1) + ) + (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) button0-rel 2) + ) + (pad-buttons x) + ) + (can-jump? #f) + ) + (if (= (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) stick0-speed) 0.0) + (go target-high-jump (-> *TARGET-bank* duck-jump-height-min) (-> *TARGET-bank* duck-jump-height-max) 'duck) + (go target-jump (-> *TARGET-bank* jump-height-min) (-> *TARGET-bank* jump-height-max) (the-as surface #f)) + ) + ) + (if (and (can-hands? #t) (can-exit-duck?)) + (go + target-attack-uppercut + (-> *TARGET-bank* attack-jump-height-min) + (-> *TARGET-bank* attack-jump-height-max) ) - ) - 2457.6 ) - ) - ) - (can-exit-duck?) - ) - (go target-walk) + (fall-test) + (slide-down-test) + (none) ) - (if (not (move-legs?)) - (go target-duck-stance) - ) - (when - (and - (logtest? - (logior - (logior - (-> - *cpad-list* - cpads - (-> self control unknown-cpad-info00 number) - button0-rel - 0 - ) - (-> - *cpad-list* - cpads - (-> self control unknown-cpad-info00 number) - button0-rel - 1 - ) - ) - (-> - *cpad-list* - cpads - (-> self control unknown-cpad-info00 number) - button0-rel - 2 - ) - ) - (pad-buttons x) - ) - (can-jump? #f) - ) - (if - (= - (-> - *cpad-list* - cpads - (-> self control unknown-cpad-info00 number) - stick0-speed - ) - 0.0 - ) - (go - target-high-jump - (-> *TARGET-bank* duck-jump-height-min) - (-> *TARGET-bank* duck-jump-height-max) - 'duck - ) - (go - target-jump - (-> *TARGET-bank* jump-height-min) - (-> *TARGET-bank* jump-height-max) - (the-as surface #f) - ) - ) - ) - (if (and (can-hands? #t) (can-exit-duck?)) - (go - target-attack-uppercut - (-> *TARGET-bank* attack-jump-height-min) - (-> *TARGET-bank* attack-jump-height-max) - ) - ) - (fall-test) - (slide-down-test) - (none) - ) :code (behavior () - (cond - ((and (= (if (> (-> self skel active-channels) 0) + (cond + ((and (= (if (> (-> self skel active-channels) 0) + (-> self skel root-channel 0 frame-group) + ) + (-> self draw art-group data 32) + ) + (= (-> self skel root-channel 0) (-> self skel channel)) + ) + ) + ((= (if (> (-> self skel active-channels) 0) (-> self skel root-channel 0 frame-group) ) - (-> self draw art-group data 32) - ) - (= (-> self skel root-channel 0) (-> self skel channel)) - ) - ) - ((= (if (> (-> self skel active-channels) 0) - (-> self skel root-channel 0 frame-group) - ) - (-> self draw art-group data 31) - ) - (ja-channel-push! 1 135) - (let ((gp-0 (-> self skel root-channel 0))) - (joint-control-channel-group-eval! - gp-0 - (the-as art-joint-anim (-> self draw art-group data 32)) - num-func-identity - ) - (set! (-> gp-0 frame-num) 0.0) - ) - ) - (else - (ja-channel-push! 1 30) - (let ((gp-1 (-> self skel root-channel 0))) - (joint-control-channel-group-eval! - gp-1 - (the-as art-joint-anim (-> self draw art-group data 32)) - num-func-identity - ) - (set! (-> gp-1 frame-num) 0.0) - ) - ) - ) - (while #t - (if (= (-> self skel root-channel 0) (-> self skel channel)) - (set! (-> self control unknown-surface00) *duck-mods*) - ) - (let ((a0-18 (-> self skel root-channel 0))) - (set! - (-> a0-18 param 0) - (fmin - (-> (new 'static 'array float 1 1.0) 0) - (/ - (-> self control unknown-float01) - (* - 60.0 - (/ - (-> *TARGET-bank* duck-walk-cycle-dist) - (-> *TARGET-bank* run-cycle-length) + (-> self draw art-group data 31) ) + (ja-channel-push! 1 135) + (let ((gp-0 (-> self skel root-channel 0))) + (joint-control-channel-group-eval! + gp-0 + (the-as art-joint-anim (-> self draw art-group data 32)) + num-func-identity + ) + (set! (-> gp-0 frame-num) 0.0) ) - ) ) + (else + (ja-channel-push! 1 30) + (let ((gp-1 (-> self skel root-channel 0))) + (joint-control-channel-group-eval! + gp-1 + (the-as art-joint-anim (-> self draw art-group data 32)) + num-func-identity + ) + (set! (-> gp-1 frame-num) 0.0) + ) + ) ) - (joint-control-channel-group-eval! - a0-18 - (the-as art-joint-anim #f) - num-func-loop! + (while #t + (if (= (-> self skel root-channel 0) (-> self skel channel)) + (set! (-> self control unknown-surface00) *duck-mods*) + ) + (let ((a0-18 (-> self skel root-channel 0))) + (set! (-> a0-18 param 0) + (fmin + (-> (new 'static 'array float 1 1.0) 0) + (/ (-> self control unknown-float01) + (* 60.0 (/ (-> *TARGET-bank* duck-walk-cycle-dist) (-> *TARGET-bank* run-cycle-length))) + ) + ) + ) + (joint-control-channel-group-eval! a0-18 (the-as art-joint-anim #f) num-func-loop!) + ) + (suspend) ) - ) - (suspend) + (none) ) - (none) - ) :post (the-as (function none :behavior target) target-post) ) +;; failed to figure out what this is: (defstate target-jump (target) :event target-jump-event-handler :enter (behavior ((arg0 float) (arg1 float) (arg2 surface)) - (when (= (-> self control unknown-symbol40) 'launch) - (level-hint-spawn - (game-text-id daxter-screaming-jump) - "sksp009d" - (the-as entity #f) - *entity-pool* - (game-task none) - ) - (level-hint-spawn - (game-text-id daxter-wahoo-jump) - "sksp009e" - (the-as entity #f) - *entity-pool* - (game-task none) - ) - (case (-> (level-get-target-inside *level*) name) - (('citadel) - (level-hint-spawn - (game-text-id daxter-land-on-the-next-launcher) - "sksp0393" + (when (= (-> self control unknown-symbol40) 'launch) + (level-hint-spawn + (game-text-id daxter-screaming-jump) + "sksp009d" (the-as entity #f) *entity-pool* (game-task none) ) - (level-hint-spawn - (game-text-id daxter-dont-miss-the-next-launcher) - "sksp0388" + (level-hint-spawn + (game-text-id daxter-wahoo-jump) + "sksp009e" (the-as entity #f) *entity-pool* (game-task none) ) - ) - ) - enter-state - (let ((a0-9 (-> self control unknown-dword60)) - (a1-5 (-> self control unknown-dword61)) - (a2-5 (-> self control unknown-vector102)) + (case (-> (level-get-target-inside *level*) name) + (('citadel) + (level-hint-spawn + (game-text-id daxter-land-on-the-next-launcher) + "sksp0393" + (the-as entity #f) + *entity-pool* + (game-task none) + ) + (level-hint-spawn + (game-text-id daxter-dont-miss-the-next-launcher) + "sksp0388" + (the-as entity #f) + *entity-pool* + (game-task none) + ) + ) + ) + enter-state + (let ((a0-9 (-> self control unknown-dword60)) + (a1-5 (-> self control unknown-dword61)) + (a2-5 (-> self control unknown-vector102)) + ) + (set! (-> a2-5 quad) (-> (the-as vector (-> self control unknown-dword62)) quad)) + (go target-launch (the-as float a0-9) (the-as symbol a1-5) a2-5 (-> self control unknown-dword63)) + ) + ) + (set! (-> self state-time) (-> *display* base-frame-counter)) + (sound-play-by-name (static-sound-name "jump") (new-sound-id) 716 0 0 1 #t) + (init-var-jump arg0 arg1 (the-as vector #t) (the-as vector #t) (-> self control transv)) + (set! (-> self control status) (logand -8 (-> self control status))) + (set! arg2 (cond + (arg2 + (empty) + arg2 + ) + (else + *jump-mods* + ) + ) ) - (set! - (-> a2-5 quad) - (-> (the-as vector (-> self control unknown-dword62)) quad) - ) - (go - target-launch - (the-as float a0-9) - (the-as symbol a1-5) - a2-5 - (-> self control unknown-dword63) - ) - ) - ) - (set! (-> self state-time) (-> *display* base-frame-counter)) - (sound-play-by-name (static-sound-name "jump") (new-sound-id) 716 0 0 1 #t) - (init-var-jump - arg0 - arg1 - (the-as vector #t) - (the-as vector #t) - (-> self control transv) - ) - (set! (-> self control status) (logand -8 (-> self control status))) - (set! arg2 (cond - (arg2 - (empty) - arg2 + (set! (-> self control unknown-surface00) arg2) + (set! (-> self control unknown-float123) + (fmax + 0.0 + (fmin + (-> (new 'static 'array float 1 1.0) 0) + (* 0.00004359654 (+ -11468.8 (-> self control unknown-float01))) + ) + ) + ) + (set! (-> self control unknown-float122) + (fmax 0.0 (fmin + (-> (new 'static 'array float 1 1.0) 0) + (* 0.000048828126 (+ -10240.0 (-> self control unknown-float01))) + ) ) - (else - *jump-mods* - ) - ) + ) + (none) ) - (set! (-> self control unknown-surface00) arg2) - (set! - (-> self control unknown-float123) - (fmax - 0.0 - (fmin - (-> (new 'static 'array float 1 1.0) 0) - (* 0.00004359654 (+ -11468.8 (-> self control unknown-float01))) - ) - ) - ) - (set! - (-> self control unknown-float122) - (fmax - 0.0 - (fmin - (-> (new 'static 'array float 1 1.0) 0) - (* 0.000048828126 (+ -10240.0 (-> self control unknown-float01))) - ) - ) - ) - (none) - ) :exit target-exit :trans (behavior () - (set! - (-> self control unknown-float123) - (fmax - (-> self control unknown-float123) - (* - 0.003921569 - (the - float - (-> - *cpad-list* - cpads - (-> self control unknown-cpad-info00 number) - abutton - 6 + (set! (-> self control unknown-float123) + (fmax + (-> self control unknown-float123) + (* 0.003921569 (the float (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) abutton 6))) + ) + ) + (target-falling-trans #f (the-as cpad-list (if (= (if (> (-> self skel active-channels) 0) + (-> self skel root-channel 0 frame-group) + ) + (-> self draw art-group data 38) + ) + 15 + -1 + ) + ) + ) + (if (and (logtest? (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) button0-rel 0) (pad-buttons x)) + (< (vector-dot (-> self control dynam gravity-normal) (-> self control transv)) 12288.0) + (and (< -61440.0 (vector-dot (-> self control dynam gravity-normal) (-> self control transv))) + (zero? (logand (-> self water flags) 512)) + (zero? (logand (-> self state-flags) 2048)) + ) + ) + (go target-double-jump (-> *TARGET-bank* double-jump-height-min) (-> *TARGET-bank* double-jump-height-max)) ) - ) - ) - ) - ) - (target-falling-trans - #f - (the-as cpad-list (if (= (if (> (-> self skel active-channels) 0) - (-> self skel root-channel 0 frame-group) - ) - (-> self draw art-group data 38) - ) - 15 - -1 + (if (and (logtest? (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) button0-rel 0) + (pad-buttons square) ) - ) - ) - (if - (and - (logtest? - (-> - *cpad-list* - cpads - (-> self control unknown-cpad-info00 number) - button0-rel - 0 - ) - (pad-buttons x) - ) - (< - (vector-dot - (-> self control dynam gravity-normal) - (-> self control transv) - ) - 12288.0 - ) - (and - (< - -61440.0 - (vector-dot - (-> self control dynam gravity-normal) - (-> self control transv) + (< (vector-dot (-> self control dynam gravity-normal) (-> self control transv)) 26624.0) + (and (< -61440.0 (vector-dot (-> self control dynam gravity-normal) (-> self control transv))) + (>= (- (-> *display* base-frame-counter) (-> self control unknown-dword36)) + (the-as int (-> *TARGET-bank* stuck-timeout)) + ) + (zero? (logand (-> self state-flags) 4096)) + (zero? (logand (-> self control unknown-surface01 flags) 384)) + ) + ) + (go + target-flop + (the-as float 65502.96) + (the-as float -163840.0) + (the-as float (if (= (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) stick0-speed) 0.0) + (-> (new 'static 'array float 1 0.0) 0) + 68812.8 + ) + ) + ) ) - ) - (zero? (logand (-> self water flags) 512)) - (zero? (logand (-> self state-flags) 2048)) + (mod-var-jump + #t + #t + (logtest? (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) button0-abs 0) (pad-buttons x)) + (-> self control transv) ) - ) - (go - target-double-jump - (-> *TARGET-bank* double-jump-height-min) - (-> *TARGET-bank* double-jump-height-max) - ) + (slide-down-test) + (set! (-> self control unknown-float122) + (seek + (-> self control unknown-float122) + (fmax 0.0 (fmin + (-> (new 'static 'array float 1 1.0) 0) + (* 0.000048828126 (+ -10240.0 (-> self control unknown-float01))) + ) + ) + (-> *display* seconds-per-frame) + ) + ) + (none) ) - (if - (and - (logtest? - (-> - *cpad-list* - cpads - (-> self control unknown-cpad-info00 number) - button0-rel - 0 - ) - (pad-buttons square) - ) - (< - (vector-dot - (-> self control dynam gravity-normal) - (-> self control transv) - ) - 26624.0 - ) - (and - (< - -61440.0 - (vector-dot - (-> self control dynam gravity-normal) - (-> self control transv) - ) - ) - (>= - (- (-> *display* base-frame-counter) (-> self control unknown-dword36)) - (the-as int (-> *TARGET-bank* stuck-timeout)) - ) - (zero? (logand (-> self state-flags) 4096)) - (zero? (logand (-> self control unknown-surface01 flags) 384)) - ) - ) - (go - target-flop - (the-as float 65502.96) - (the-as float -163840.0) - (the-as - float - (if - (= - (-> - *cpad-list* - cpads - (-> self control unknown-cpad-info00 number) - stick0-speed - ) - 0.0 - ) - (-> (new 'static 'array float 1 0.0) 0) - 68812.8 - ) - ) - ) - ) - (mod-var-jump - #t - #t - (logtest? - (-> - *cpad-list* - cpads - (-> self control unknown-cpad-info00 number) - button0-abs - 0 - ) - (pad-buttons x) - ) - (-> self control transv) - ) - (slide-down-test) - (set! - (-> self control unknown-float122) - (seek - (-> self control unknown-float122) - (fmax - 0.0 - (fmin - (-> (new 'static 'array float 1 1.0) 0) - (* 0.000048828126 (+ -10240.0 (-> self control unknown-float01))) - ) - ) - (-> *display* seconds-per-frame) - ) - ) - (none) - ) :code (behavior ((arg0 float) (arg1 float) (arg2 surface)) - (ja-channel-push! 2 15) - (let ((gp-0 (-> self skel root-channel 0))) - (joint-control-channel-group-eval! - gp-0 - (the-as art-joint-anim (-> self draw art-group data 34)) - num-func-identity - ) - (set! (-> gp-0 frame-num) 0.0) - ) - (let ((a0-3 (-> self skel root-channel 1))) - (set! (-> a0-3 frame-interp) (-> self control unknown-float122)) - (set! - (-> a0-3 frame-group) - (the-as art-joint-anim (-> self draw art-group data 40)) - ) - (set! (-> a0-3 param 0) 0.0) - (joint-control-channel-group-eval! - a0-3 - (the-as art-joint-anim (-> self draw art-group data 40)) - num-func-chan - ) - ) - (suspend) - (let ((a0-4 (-> self skel root-channel 0))) - (set! - (-> a0-4 frame-group) - (the-as art-joint-anim (-> self draw art-group data 34)) - ) - (set! (-> a0-4 param 0) (-> (new 'static 'array float 1 1.0) 0)) - (joint-control-channel-group-eval! - a0-4 - (the-as art-joint-anim (-> self draw art-group data 34)) - num-func-+! - ) - ) - (let ((a0-5 (-> self skel root-channel 1))) - (set! (-> a0-5 frame-interp) (-> self control unknown-float122)) - (set! - (-> a0-5 frame-group) - (the-as art-joint-anim (-> self draw art-group data 40)) - ) - (set! (-> a0-5 param 0) 0.0) - (joint-control-channel-group-eval! - a0-5 - (the-as art-joint-anim (-> self draw art-group data 40)) - num-func-chan - ) - ) - (suspend) - (until (ja-done? 0) - (let - ((f30-0 - (vector-dot - (-> self control dynam gravity-normal) - (-> self control transv) + (ja-channel-push! 2 15) + (let ((gp-0 (-> self skel root-channel 0))) + (joint-control-channel-group-eval! + gp-0 + (the-as art-joint-anim (-> self draw art-group data 34)) + num-func-identity ) - ) - (f0-8 (- 20.0 (ja-aframe-num 0))) - (gp-1 (-> self skel root-channel 0)) + (set! (-> gp-0 frame-num) 0.0) ) - (set! - (-> gp-1 param 0) - (the float (+ (-> gp-1 frame-group data 0 length) -1)) + (let ((a0-3 (-> self skel root-channel 1))) + (set! (-> a0-3 frame-interp) (-> self control unknown-float122)) + (set! (-> a0-3 frame-group) (the-as art-joint-anim (-> self draw art-group data 40))) + (set! (-> a0-3 param 0) 0.0) + (joint-control-channel-group-eval! + a0-3 + (the-as art-joint-anim (-> self draw art-group data 40)) + num-func-chan + ) ) - (let ((v1-45 (and (< 0.0 f30-0) (< 0.0 f0-8)))) - (set! (-> gp-1 param 1) (if v1-45 - (fmin - (fmin - (-> (new 'static 'array float 1 3.0) 0) - f0-8 - ) - (/ - (* 5.0 f0-8) - (the - float - (time-to-apex f30-0 (the-as float -245760.0)) - ) - ) - ) - (-> (new 'static 'array float 1 1.0) 0) - ) - ) - ) - (joint-control-channel-group-eval! - gp-1 - (the-as art-joint-anim #f) - num-func-seek! - ) - ) - (let ((a0-10 (-> self skel root-channel 1))) - (set! (-> a0-10 frame-interp) (-> self control unknown-float122)) - (set! (-> a0-10 param 0) 0.0) - (joint-control-channel-group-eval! - a0-10 - (the-as art-joint-anim #f) - num-func-chan - ) - ) (suspend) + (let ((a0-4 (-> self skel root-channel 0))) + (set! (-> a0-4 frame-group) (the-as art-joint-anim (-> self draw art-group data 34))) + (set! (-> a0-4 param 0) (-> (new 'static 'array float 1 1.0) 0)) + (joint-control-channel-group-eval! a0-4 (the-as art-joint-anim (-> self draw art-group data 34)) num-func-+!) + ) + (let ((a0-5 (-> self skel root-channel 1))) + (set! (-> a0-5 frame-interp) (-> self control unknown-float122)) + (set! (-> a0-5 frame-group) (the-as art-joint-anim (-> self draw art-group data 40))) + (set! (-> a0-5 param 0) 0.0) + (joint-control-channel-group-eval! + a0-5 + (the-as art-joint-anim (-> self draw art-group data 40)) + num-func-chan + ) + ) + (suspend) + (until (ja-done? 0) + (let ((f30-0 (vector-dot (-> self control dynam gravity-normal) (-> self control transv))) + (f0-8 (- 20.0 (ja-aframe-num 0))) + (gp-1 (-> self skel root-channel 0)) + ) + (set! (-> gp-1 param 0) (the float (+ (-> gp-1 frame-group data 0 length) -1))) + (let ((v1-45 (and (< 0.0 f30-0) (< 0.0 f0-8)))) + (set! (-> gp-1 param 1) (if v1-45 + (fmin + (fmin (-> (new 'static 'array float 1 3.0) 0) f0-8) + (/ (* 5.0 f0-8) (the float (time-to-apex f30-0 (the-as float -245760.0)))) + ) + (-> (new 'static 'array float 1 1.0) 0) + ) + ) + ) + (joint-control-channel-group-eval! gp-1 (the-as art-joint-anim #f) num-func-seek!) + ) + (let ((a0-10 (-> self skel root-channel 1))) + (set! (-> a0-10 frame-interp) (-> self control unknown-float122)) + (set! (-> a0-10 param 0) 0.0) + (joint-control-channel-group-eval! a0-10 (the-as art-joint-anim #f) num-func-chan) + ) + (suspend) + ) + (target-falling-anim -1 60) + (none) ) - (target-falling-anim -1 60) - (none) - ) :post (the-as (function none :behavior target) target-post) ) +;; failed to figure out what this is: (defstate target-jump-forward (target) :event target-jump-event-handler :enter (behavior ((arg0 float) (arg1 float)) - ((-> target-jump enter) arg0 arg1 (the-as surface #f)) - (set! (-> self control unknown-surface00) *forward-jump-mods*) - (none) - ) + ((-> target-jump enter) arg0 arg1 (the-as surface #f)) + (set! (-> self control unknown-surface00) *forward-jump-mods*) + (none) + ) :exit target-exit :trans (-> target-jump trans) :code (behavior ((arg0 float) (arg1 float)) - (ja-channel-set! 1) - (let ((gp-0 (-> self skel root-channel 0))) - (set! - (-> gp-0 frame-group) - (the-as art-joint-anim (-> self draw art-group data 34)) - ) - (set! - (-> gp-0 param 0) - (the - float - (+ - (-> - (the-as art-joint-anim (-> self draw art-group data 34)) - data - 0 - length + (ja-channel-set! 1) + (let ((gp-0 (-> self skel root-channel 0))) + (set! (-> gp-0 frame-group) (the-as art-joint-anim (-> self draw art-group data 34))) + (set! (-> gp-0 param 0) + (the float (+ (-> (the-as art-joint-anim (-> self draw art-group data 34)) data 0 length) -1)) + ) + (set! (-> gp-0 param 1) (-> (new 'static 'array float 1 1.0) 0)) + (set! (-> gp-0 frame-num) (ja-aframe (-> (new 'static 'array float 1 3.0) 0) 0)) + (joint-control-channel-group! gp-0 (the-as art-joint-anim (-> self draw art-group data 34)) num-func-seek!) + ) + (until (ja-done? 0) + (set! (-> self control unknown-dword70) 0) + (suspend) + (let ((a0-4 (-> self skel root-channel 0))) + (set! (-> a0-4 param 0) (the float (+ (-> a0-4 frame-group data 0 length) -1))) + (set! (-> a0-4 param 1) (-> (new 'static 'array float 1 1.0) 0)) + (joint-control-channel-group-eval! a0-4 (the-as art-joint-anim #f) num-func-seek!) ) - -1 - ) ) - ) - (set! (-> gp-0 param 1) (-> (new 'static 'array float 1 1.0) 0)) - (set! - (-> gp-0 frame-num) - (ja-aframe (-> (new 'static 'array float 1 3.0) 0) 0) - ) - (joint-control-channel-group! - gp-0 - (the-as art-joint-anim (-> self draw art-group data 34)) - num-func-seek! - ) + (let ((a0-6 (-> self skel root-channel 0))) + (set! (-> a0-6 frame-group) (the-as art-joint-anim (-> self draw art-group data 38))) + (set! (-> a0-6 param 0) (-> (new 'static 'array float 1 1.0) 0)) + (set! (-> a0-6 frame-num) 0.0) + (joint-control-channel-group! a0-6 (the-as art-joint-anim (-> self draw art-group data 38)) num-func-loop!) + ) + (while #t + (suspend) + (let ((a0-7 (-> self skel root-channel 0))) + (set! (-> a0-7 frame-group) (the-as art-joint-anim (-> self draw art-group data 38))) + (set! (-> a0-7 param 0) (-> (new 'static 'array float 1 1.0) 0)) + (joint-control-channel-group-eval! + a0-7 + (the-as art-joint-anim (-> self draw art-group data 38)) + num-func-loop! + ) + ) + ) + (none) ) - (until (ja-done? 0) - (set! (-> self control unknown-dword70) 0) - (suspend) - (let ((a0-4 (-> self skel root-channel 0))) - (set! - (-> a0-4 param 0) - (the float (+ (-> a0-4 frame-group data 0 length) -1)) - ) - (set! (-> a0-4 param 1) (-> (new 'static 'array float 1 1.0) 0)) - (joint-control-channel-group-eval! - a0-4 - (the-as art-joint-anim #f) - num-func-seek! - ) - ) - ) - (let ((a0-6 (-> self skel root-channel 0))) - (set! - (-> a0-6 frame-group) - (the-as art-joint-anim (-> self draw art-group data 38)) - ) - (set! (-> a0-6 param 0) (-> (new 'static 'array float 1 1.0) 0)) - (set! (-> a0-6 frame-num) 0.0) - (joint-control-channel-group! - a0-6 - (the-as art-joint-anim (-> self draw art-group data 38)) - num-func-loop! - ) - ) - (while #t - (suspend) - (let ((a0-7 (-> self skel root-channel 0))) - (set! - (-> a0-7 frame-group) - (the-as art-joint-anim (-> self draw art-group data 38)) - ) - (set! (-> a0-7 param 0) (-> (new 'static 'array float 1 1.0) 0)) - (joint-control-channel-group-eval! - a0-7 - (the-as art-joint-anim (-> self draw art-group data 38)) - num-func-loop! - ) - ) - ) - (none) - ) :post (the-as (function none :behavior target) target-post) ) +;; failed to figure out what this is: (defstate target-double-jump (target) :event target-jump-event-handler :enter (behavior ((arg0 float) (arg1 float)) - (when (= (-> self control unknown-symbol40) 'launch) - enter-state - (let ((a0-3 (-> self control unknown-dword60)) - (a1-1 (-> self control unknown-dword61)) - (a2-0 (-> self control unknown-vector102)) - ) - (set! - (-> a2-0 quad) - (-> (the-as vector (-> self control unknown-dword62)) quad) + (when (= (-> self control unknown-symbol40) 'launch) + enter-state + (let ((a0-3 (-> self control unknown-dword60)) + (a1-1 (-> self control unknown-dword61)) + (a2-0 (-> self control unknown-vector102)) + ) + (set! (-> a2-0 quad) (-> (the-as vector (-> self control unknown-dword62)) quad)) + (go target-launch (the-as float a0-3) (the-as symbol a1-1) a2-0 (-> self control unknown-dword63)) + ) ) - (go - target-launch - (the-as float a0-3) - (the-as symbol a1-1) - a2-0 - (-> self control unknown-dword63) - ) - ) + (set! (-> self state-time) (-> *display* base-frame-counter)) + (init-var-jump arg0 arg1 (the-as vector #t) (the-as vector #t) (-> self control transv)) + (set! (-> self control status) (logand -8 (-> self control status))) + (set! (-> self control unknown-surface00) *double-jump-mods*) + (none) ) - (set! (-> self state-time) (-> *display* base-frame-counter)) - (init-var-jump - arg0 - arg1 - (the-as vector #t) - (the-as vector #t) - (-> self control transv) - ) - (set! (-> self control status) (logand -8 (-> self control status))) - (set! (-> self control unknown-surface00) *double-jump-mods*) - (none) - ) :exit target-exit :trans (behavior () - (target-falling-trans - #f - (the-as cpad-list (if (= (if (> (-> self skel active-channels) 0) - (-> self skel root-channel 0 frame-group) - ) - (-> self draw art-group data 38) - ) - 15 - -1 + (target-falling-trans #f (the-as cpad-list (if (= (if (> (-> self skel active-channels) 0) + (-> self skel root-channel 0 frame-group) + ) + (-> self draw art-group data 38) + ) + 15 + -1 + ) + ) + ) + (if (and (logtest? (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) button0-rel 0) + (pad-buttons square) ) - ) - ) - (if - (and - (logtest? - (-> - *cpad-list* - cpads - (-> self control unknown-cpad-info00 number) - button0-rel - 0 - ) - (pad-buttons square) - ) - (< - (vector-dot - (-> self control dynam gravity-normal) - (-> self control transv) - ) - 22118.4 - ) - (and - (< - -61440.0 - (vector-dot - (-> self control dynam gravity-normal) - (-> self control transv) + (< (vector-dot (-> self control dynam gravity-normal) (-> self control transv)) 22118.4) + (and (< -61440.0 (vector-dot (-> self control dynam gravity-normal) (-> self control transv))) + (>= (- (-> *display* base-frame-counter) (-> self control unknown-dword36)) + (the-as int (-> *TARGET-bank* stuck-timeout)) + ) + (zero? (logand (-> self state-flags) 4096)) + (zero? (logand (-> self control unknown-surface01 flags) 384)) + ) + ) + (go + target-flop + (the-as float 33775.48) + (the-as float -122880.0) + (the-as float (if (= (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) stick0-speed) 0.0) + (-> (new 'static 'array float 1 0.0) 0) + 68812.8 + ) + ) + ) ) - ) - (>= - (- (-> *display* base-frame-counter) (-> self control unknown-dword36)) - (the-as int (-> *TARGET-bank* stuck-timeout)) - ) - (zero? (logand (-> self state-flags) 4096)) - (zero? (logand (-> self control unknown-surface01 flags) 384)) - ) - ) - (go - target-flop - (the-as float 33775.48) - (the-as float -122880.0) - (the-as - float - (if - (= - (-> - *cpad-list* - cpads - (-> self control unknown-cpad-info00 number) - stick0-speed - ) - 0.0 + (if (!= (-> self state-time) (-> *display* base-frame-counter)) + (mod-var-jump + #t + #t + (logtest? (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) button0-abs 0) (pad-buttons x)) + (-> self control transv) + ) ) - (-> (new 'static 'array float 1 0.0) 0) - 68812.8 - ) - ) - ) + (set! (-> self control unknown-float122) + (seek + (-> self control unknown-float122) + (fmax 0.0 (fmin + (-> (new 'static 'array float 1 1.0) 0) + (* 0.000048828126 (+ -10240.0 (-> self control unknown-float01))) + ) + ) + (-> *display* seconds-per-frame) + ) + ) + (none) ) - (if (!= (-> self state-time) (-> *display* base-frame-counter)) - (mod-var-jump - #t - #t - (logtest? - (-> - *cpad-list* - cpads - (-> self control unknown-cpad-info00 number) - button0-abs - 0 - ) - (pad-buttons x) - ) - (-> self control transv) - ) - ) - (set! - (-> self control unknown-float122) - (seek - (-> self control unknown-float122) - (fmax - 0.0 - (fmin - (-> (new 'static 'array float 1 1.0) 0) - (* 0.000048828126 (+ -10240.0 (-> self control unknown-float01))) - ) - ) - (-> *display* seconds-per-frame) - ) - ) - (none) - ) :code (behavior ((arg0 float) (arg1 float)) - (ja-channel-push! 2 15) - (dummy-10 - (-> self skel effect) - 'jump-double - (-> (new 'static 'array float 1 -1.0) 0) - -1 - ) - (let ((gp-0 (-> self skel root-channel 0))) - (set! - (-> gp-0 frame-group) - (the-as art-joint-anim (-> self draw art-group data 34)) - ) - (set! - (-> gp-0 param 0) - (the - float - (+ - (-> - (the-as art-joint-anim (-> self draw art-group data 34)) - data - 0 - length + (ja-channel-push! 2 15) + (dummy-10 (-> self skel effect) 'jump-double (-> (new 'static 'array float 1 -1.0) 0) -1) + (let ((gp-0 (-> self skel root-channel 0))) + (set! (-> gp-0 frame-group) (the-as art-joint-anim (-> self draw art-group data 34))) + (set! (-> gp-0 param 0) + (the float (+ (-> (the-as art-joint-anim (-> self draw art-group data 34)) data 0 length) -1)) + ) + (set! (-> gp-0 param 1) (-> (new 'static 'array float 1 1.0) 0)) + (set! (-> gp-0 frame-num) (ja-aframe (the-as float 5.0) 0)) + (joint-control-channel-group! gp-0 (the-as art-joint-anim (-> self draw art-group data 34)) num-func-seek!) + ) + (let ((a0-5 (-> self skel root-channel 1))) + (set! (-> a0-5 frame-group) (the-as art-joint-anim (-> self draw art-group data 40))) + (set! (-> a0-5 param 0) 0.0) + (joint-control-channel-group-eval! + a0-5 + (the-as art-joint-anim (-> self draw art-group data 40)) + num-func-chan ) - -1 - ) ) - ) - (set! (-> gp-0 param 1) (-> (new 'static 'array float 1 1.0) 0)) - (set! (-> gp-0 frame-num) (ja-aframe (the-as float 5.0) 0)) - (joint-control-channel-group! - gp-0 - (the-as art-joint-anim (-> self draw art-group data 34)) - num-func-seek! - ) + (until (ja-done? 0) + (suspend) + (let ((a0-6 (-> self skel root-channel 0))) + (set! (-> a0-6 param 0) (the float (+ (-> a0-6 frame-group data 0 length) -1))) + (set! (-> a0-6 param 1) (-> (new 'static 'array float 1 1.0) 0)) + (joint-control-channel-group-eval! a0-6 (the-as art-joint-anim #f) num-func-seek!) + ) + (let ((a0-7 (-> self skel root-channel 1))) + (set! (-> a0-7 frame-interp) (-> self control unknown-float122)) + (set! (-> a0-7 param 0) 0.0) + (joint-control-channel-group-eval! a0-7 (the-as art-joint-anim #f) num-func-chan) + ) + ) + (target-falling-anim -1 60) + (none) ) - (let ((a0-5 (-> self skel root-channel 1))) - (set! - (-> a0-5 frame-group) - (the-as art-joint-anim (-> self draw art-group data 40)) - ) - (set! (-> a0-5 param 0) 0.0) - (joint-control-channel-group-eval! - a0-5 - (the-as art-joint-anim (-> self draw art-group data 40)) - num-func-chan - ) - ) - (until (ja-done? 0) - (suspend) - (let ((a0-6 (-> self skel root-channel 0))) - (set! - (-> a0-6 param 0) - (the float (+ (-> a0-6 frame-group data 0 length) -1)) - ) - (set! (-> a0-6 param 1) (-> (new 'static 'array float 1 1.0) 0)) - (joint-control-channel-group-eval! - a0-6 - (the-as art-joint-anim #f) - num-func-seek! - ) - ) - (let ((a0-7 (-> self skel root-channel 1))) - (set! (-> a0-7 frame-interp) (-> self control unknown-float122)) - (set! (-> a0-7 param 0) 0.0) - (joint-control-channel-group-eval! - a0-7 - (the-as art-joint-anim #f) - num-func-chan - ) - ) - ) - (target-falling-anim -1 60) - (none) - ) :post (the-as (function none :behavior target) target-post) ) +;; failed to figure out what this is: (defstate target-high-jump (target) :event target-jump-event-handler :enter (behavior ((arg0 float) (arg1 float) (arg2 basic)) - (when (and (= (-> self control unknown-symbol40) 'launch) (!= arg2 'launch)) - enter-state - (let ((a0-3 (-> self control unknown-dword60)) - (a1-1 (-> self control unknown-dword61)) - (a2-1 (-> self control unknown-vector102)) + (when (and (= (-> self control unknown-symbol40) 'launch) (!= arg2 'launch)) + enter-state + (let ((a0-3 (-> self control unknown-dword60)) + (a1-1 (-> self control unknown-dword61)) + (a2-1 (-> self control unknown-vector102)) + ) + (set! (-> a2-1 quad) (-> (the-as vector (-> self control unknown-dword62)) quad)) + (go target-launch (the-as float a0-3) (the-as symbol a1-1) a2-1 (-> self control unknown-dword63)) + ) + ) + (set! (-> self control unknown-uint31) (the-as uint arg2)) + (if (or (= arg2 'duck) (= arg2 'launch)) + (go target-duck-high-jump arg0 arg1 (the-as symbol arg2)) + ) + (set! (-> self state-time) (-> *display* base-frame-counter)) + (set! (-> self control status) (logand -8 (-> self control status))) + (sound-play-by-name (static-sound-name "jump") (new-sound-id) 1024 457 0 1 #t) + (init-var-jump arg0 arg1 (the-as vector #t) (the-as vector #t) (-> self control transv)) + (set! (-> self control unknown-surface00) (cond + ((= arg2 'flip) + *flip-jump-mods* + ) + ((= arg2 'flop-forward) + *forward-high-jump-mods* + ) + (else + *high-jump-mods* + ) + ) ) - (set! - (-> a2-1 quad) - (-> (the-as vector (-> self control unknown-dword62)) quad) - ) - (go - target-launch - (the-as float a0-3) - (the-as symbol a1-1) - a2-1 - (-> self control unknown-dword63) - ) - ) + (set! (-> self control unknown-float122) + (fmax 0.0 (fmin 0.5 (* 0.00008138021 (+ -409.6 (-> self control unknown-float01))))) + ) + (none) ) - (set! (-> self control unknown-uint31) (the-as uint arg2)) - (if (or (= arg2 'duck) (= arg2 'launch)) - (go target-duck-high-jump arg0 arg1 (the-as symbol arg2)) - ) - (set! (-> self state-time) (-> *display* base-frame-counter)) - (set! (-> self control status) (logand -8 (-> self control status))) - (sound-play-by-name - (static-sound-name "jump") - (new-sound-id) - 1024 - 457 - 0 - 1 - #t - ) - (init-var-jump - arg0 - arg1 - (the-as vector #t) - (the-as vector #t) - (-> self control transv) - ) - (set! (-> self control unknown-surface00) (cond - ((= arg2 'flip) - *flip-jump-mods* - ) - ((= arg2 'flop-forward) - *forward-high-jump-mods* - ) - (else - *high-jump-mods* - ) - ) - ) - (set! - (-> self control unknown-float122) - (fmax - 0.0 - (fmin 0.5 (* 0.00008138021 (+ -409.6 (-> self control unknown-float01)))) - ) - ) - (none) - ) :exit target-exit :trans (behavior () - (target-falling-trans - #f - (the-as cpad-list (if (= (if (> (-> self skel active-channels) 0) - (-> self skel root-channel 0 frame-group) - ) - (-> self draw art-group data 38) - ) - 15 - -1 + (target-falling-trans #f (the-as cpad-list (if (= (if (> (-> self skel active-channels) 0) + (-> self skel root-channel 0 frame-group) + ) + (-> self draw art-group data 38) + ) + 15 + -1 + ) + ) + ) + (if (and (logtest? (logior (logior (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) button0-rel 0) + (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) button0-rel 1) + ) + (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) button0-rel 2) + ) + (pad-buttons square) ) - ) - ) - (if - (and - (logtest? - (logior - (logior - (-> - *cpad-list* - cpads - (-> self control unknown-cpad-info00 number) - button0-rel - 0 - ) - (-> - *cpad-list* - cpads - (-> self control unknown-cpad-info00 number) - button0-rel - 1 - ) + (< (vector-dot (-> self control dynam gravity-normal) (-> self control transv)) 73728.0) + (and (< -61440.0 (vector-dot (-> self control dynam gravity-normal) (-> self control transv))) + (>= (- (-> *display* base-frame-counter) (-> self control unknown-dword36)) + (the-as int (-> *TARGET-bank* stuck-timeout)) + ) + (zero? (logand (-> self state-flags) 4096)) + (zero? (logand (-> self control unknown-surface01 flags) 384)) + ) + ) + (go + target-flop + (the-as float 33775.48) + (the-as float -122880.0) + (the-as float (if (= (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) stick0-speed) 0.0) + (-> (new 'static 'array float 1 0.0) 0) + 68812.8 + ) + ) + ) ) - (-> - *cpad-list* - cpads - (-> self control unknown-cpad-info00 number) - button0-rel - 2 - ) - ) - (pad-buttons square) + (mod-var-jump + #t + #t + (logtest? (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) button0-abs 0) (pad-buttons x)) + (-> self control transv) ) - (< - (vector-dot - (-> self control dynam gravity-normal) - (-> self control transv) - ) - 73728.0 - ) - (and - (< - -61440.0 - (vector-dot - (-> self control dynam gravity-normal) - (-> self control transv) - ) - ) - (>= - (- (-> *display* base-frame-counter) (-> self control unknown-dword36)) - (the-as int (-> *TARGET-bank* stuck-timeout)) - ) - (zero? (logand (-> self state-flags) 4096)) - (zero? (logand (-> self control unknown-surface01 flags) 384)) - ) - ) - (go - target-flop - (the-as float 33775.48) - (the-as float -122880.0) - (the-as - float - (if - (= - (-> - *cpad-list* - cpads - (-> self control unknown-cpad-info00 number) - stick0-speed - ) - 0.0 - ) - (-> (new 'static 'array float 1 0.0) 0) - 68812.8 - ) - ) - ) + (set! (-> self control unknown-float122) + (seek + (-> self control unknown-float122) + (fmax + 0.0 + (fmin (-> (new 'static 'array float 1 1.0) 0) (* 0.00012207031 (+ -2048.0 (-> self control unknown-float01)))) + ) + (-> *display* seconds-per-frame) + ) + ) + (none) ) - (mod-var-jump - #t - #t - (logtest? - (-> - *cpad-list* - cpads - (-> self control unknown-cpad-info00 number) - button0-abs - 0 - ) - (pad-buttons x) - ) - (-> self control transv) - ) - (set! - (-> self control unknown-float122) - (seek - (-> self control unknown-float122) - (fmax - 0.0 - (fmin - (-> (new 'static 'array float 1 1.0) 0) - (* 0.00012207031 (+ -2048.0 (-> self control unknown-float01))) - ) - ) - (-> *display* seconds-per-frame) - ) - ) - (none) - ) :code (-> target-jump code) :post (the-as (function none :behavior target) target-post) ) +;; failed to figure out what this is: (defstate target-duck-high-jump (target) :event target-standard-event-handler :enter (behavior ((arg0 float) (arg1 float) (arg2 symbol)) - (set! (-> self state-time) (-> *display* base-frame-counter)) - (set! (-> self control status) (logand -8 (-> self control status))) - (set! (-> self control unknown-surface00) *turn-around-mods*) - (none) - ) + (set! (-> self state-time) (-> *display* base-frame-counter)) + (set! (-> self control status) (logand -8 (-> self control status))) + (set! (-> self control unknown-surface00) *turn-around-mods*) + (none) + ) :exit target-exit :code (behavior ((arg0 float) (arg1 float) (arg2 symbol)) - (if (not (and (= (if (> (-> self skel active-channels) 0) - (-> self skel root-channel 0 frame-group) + (if (not (and (= (if (> (-> self skel active-channels) 0) + (-> self skel root-channel 0 frame-group) + ) + (-> self draw art-group data 31) ) - (-> self draw art-group data 31) + (= (-> self skel root-channel 0) (-> self skel channel)) ) - (= (-> self skel root-channel 0) (-> self skel channel)) ) + (ja-channel-push! 1 12) ) - (ja-channel-push! 1 12) - ) - (case arg2 - (('launch) - (let ((s3-0 (-> self skel root-channel 0))) - (set! - (-> s3-0 frame-group) - (the-as art-joint-anim (-> self draw art-group data 42)) - ) - (set! (-> s3-0 param 0) (ja-aframe (the-as float 16.0) 0)) - (set! (-> s3-0 param 1) (-> (new 'static 'array float 1 1.0) 0)) - (set! (-> s3-0 frame-num) 0.0) - (joint-control-channel-group! - s3-0 - (the-as art-joint-anim (-> self draw art-group data 42)) - num-func-seek! - ) - ) - (until (ja-done? 0) - (suspend) - (let ((s3-1 (-> self skel root-channel 0))) - (set! (-> s3-1 param 0) (ja-aframe (the-as float 16.0) 0)) - (set! (-> s3-1 param 1) (-> (new 'static 'array float 1 1.0) 0)) - (joint-control-channel-group-eval! - s3-1 - (the-as art-joint-anim #f) - num-func-seek! + (case arg2 + (('launch) + (let ((s3-0 (-> self skel root-channel 0))) + (set! (-> s3-0 frame-group) (the-as art-joint-anim (-> self draw art-group data 42))) + (set! (-> s3-0 param 0) (ja-aframe (the-as float 16.0) 0)) + (set! (-> s3-0 param 1) (-> (new 'static 'array float 1 1.0) 0)) + (set! (-> s3-0 frame-num) 0.0) + (joint-control-channel-group! s3-0 (the-as art-joint-anim (-> self draw art-group data 42)) num-func-seek!) ) + (until (ja-done? 0) + (suspend) + (let ((s3-1 (-> self skel root-channel 0))) + (set! (-> s3-1 param 0) (ja-aframe (the-as float 16.0) 0)) + (set! (-> s3-1 param 1) (-> (new 'static 'array float 1 1.0) 0)) + (joint-control-channel-group-eval! s3-1 (the-as art-joint-anim #f) num-func-seek!) + ) + ) + ) + (else + (let ((s3-2 (-> self skel root-channel 0))) + (set! (-> s3-2 frame-group) (the-as art-joint-anim (-> self draw art-group data 41))) + (set! (-> s3-2 param 0) (ja-aframe (the-as float 16.0) 0)) + (set! (-> s3-2 param 1) (-> (new 'static 'array float 1 1.0) 0)) + (set! (-> s3-2 frame-num) 0.0) + (joint-control-channel-group! s3-2 (the-as art-joint-anim (-> self draw art-group data 41)) num-func-seek!) + ) + (until (ja-done? 0) + (suspend) + (let ((s3-3 (-> self skel root-channel 0))) + (set! (-> s3-3 param 0) (ja-aframe (the-as float 16.0) 0)) + (set! (-> s3-3 param 1) (-> (new 'static 'array float 1 1.0) 0)) + (joint-control-channel-group-eval! s3-3 (the-as art-joint-anim #f) num-func-seek!) + ) + ) ) - ) ) - (else - (let ((s3-2 (-> self skel root-channel 0))) - (set! - (-> s3-2 frame-group) - (the-as art-joint-anim (-> self draw art-group data 41)) - ) - (set! (-> s3-2 param 0) (ja-aframe (the-as float 16.0) 0)) - (set! (-> s3-2 param 1) (-> (new 'static 'array float 1 1.0) 0)) - (set! (-> s3-2 frame-num) 0.0) - (joint-control-channel-group! - s3-2 - (the-as art-joint-anim (-> self draw art-group data 41)) - num-func-seek! - ) - ) - (until (ja-done? 0) - (suspend) - (let ((s3-3 (-> self skel root-channel 0))) - (set! (-> s3-3 param 0) (ja-aframe (the-as float 16.0) 0)) - (set! (-> s3-3 param 1) (-> (new 'static 'array float 1 1.0) 0)) - (joint-control-channel-group-eval! - s3-3 - (the-as art-joint-anim #f) - num-func-seek! - ) - ) - ) - ) + (go target-duck-high-jump-jump arg0 arg1 arg2) + (none) ) - (go target-duck-high-jump-jump arg0 arg1 arg2) - (none) - ) :post (the-as (function none :behavior target) target-post) ) +;; failed to figure out what this is: (defstate target-duck-high-jump-jump (target) :event target-jump-event-handler :enter (behavior ((arg0 float) (arg1 float) (arg2 symbol)) - (set! (-> self state-time) (-> *display* base-frame-counter)) - (sound-play-by-name - (static-sound-name "jump") - (new-sound-id) - 819 - -609 - 0 - 1 - #t + (set! (-> self state-time) (-> *display* base-frame-counter)) + (sound-play-by-name (static-sound-name "jump") (new-sound-id) 819 -609 0 1 #t) + (init-var-jump arg0 arg1 (the-as vector #t) (the-as vector #f) (-> self control transv)) + (set! (-> self control status) (logand -8 (-> self control status))) + (cond + ((= arg2 'launch) + (set! (-> self neck flex-blend) 0.0) + (set! (-> self control unknown-surface00) *launch-jump-mods*) + ) + (else + (set! (-> self control unknown-surface00) *high-jump-mods*) + ) + ) + (none) ) - (init-var-jump - arg0 - arg1 - (the-as vector #t) - (the-as vector #f) - (-> self control transv) - ) - (set! (-> self control status) (logand -8 (-> self control status))) - (cond - ((= arg2 'launch) - (set! (-> self neck flex-blend) 0.0) - (set! (-> self control unknown-surface00) *launch-jump-mods*) - ) - (else - (set! (-> self control unknown-surface00) *high-jump-mods*) - ) - ) - (none) - ) :exit target-exit :trans (-> target-high-jump trans) :code (behavior ((arg0 float) (arg1 float) (arg2 symbol)) - (let ((f30-0 (the-as float (if (= arg2 'launch) - 110.0 - 35.0 - ) + (let ((f30-0 (the-as float (if (= arg2 'launch) + 110.0 + 35.0 + ) + ) ) + (f28-0 (-> (new 'static 'array float 1 1.0) 0)) ) - (f28-0 (-> (new 'static 'array float 1 1.0) 0)) - ) - (until (ja-done? 0) - (let* - ((f24-0 - (vector-dot - (-> self control dynam gravity-normal) - (-> self control transv) - ) - ) - (f26-0 (- f30-0 (ja-aframe-num 0))) - (f22-1 - (fmin - (fmin (-> (new 'static 'array float 1 3.0) 0) f26-0) - (/ - (* 5.0 f26-0) - (the float (time-to-apex f24-0 (the-as float -245760.0))) - ) - ) - ) - (s5-0 (-> self skel root-channel 0)) - ) - (set! - (-> s5-0 param 0) - (the float (+ (-> s5-0 frame-group data 0 length) -1)) - ) - (let ((v1-26 (cond - ((and (< 0.0 f24-0) (< 0.0 f26-0)) - (if (= arg2 'launch) - (set! - f28-0 - (lerp f28-0 (* 4.0 f22-1) (the-as float 0.25)) - ) + (until (ja-done? 0) + (let* ((f24-0 (vector-dot (-> self control dynam gravity-normal) (-> self control transv))) + (f26-0 (- f30-0 (ja-aframe-num 0))) + (f22-1 (fmin + (fmin (-> (new 'static 'array float 1 3.0) 0) f26-0) + (/ (* 5.0 f26-0) (the float (time-to-apex f24-0 (the-as float -245760.0)))) + ) ) - f22-1 - ) - (else - f28-0 - ) - ) - ) + (s5-0 (-> self skel root-channel 0)) + ) + (set! (-> s5-0 param 0) (the float (+ (-> s5-0 frame-group data 0 length) -1))) + (let ((v1-26 (cond + ((and (< 0.0 f24-0) (< 0.0 f26-0)) + (if (= arg2 'launch) + (set! f28-0 (lerp f28-0 (* 4.0 f22-1) (the-as float 0.25))) + ) + f22-1 + ) + (else + f28-0 + ) + ) + ) + ) + (set! (-> s5-0 param 1) v1-26) ) - (set! (-> s5-0 param 1) v1-26) - ) - (joint-control-channel-group-eval! - s5-0 - (the-as art-joint-anim #f) - num-func-seek! - ) + (joint-control-channel-group-eval! s5-0 (the-as art-joint-anim #f) num-func-seek!) + ) + (suspend) + ) + (cond + ((= arg2 'launch) + (let ((a0-7 (-> self skel root-channel 0))) + (set! (-> a0-7 frame-group) (the-as art-joint-anim (-> self draw art-group data 43))) + (set! (-> a0-7 param 0) f28-0) + (set! (-> a0-7 frame-num) 0.0) + (joint-control-channel-group! a0-7 (the-as art-joint-anim (-> self draw art-group data 43)) num-func-loop!) + ) + (while #t + (suspend) + (let ((a0-8 (-> self skel root-channel 0))) + (set! (-> a0-8 frame-group) (the-as art-joint-anim (-> self draw art-group data 43))) + (set! (-> a0-8 param 0) f28-0) + (joint-control-channel-group-eval! + a0-8 + (the-as art-joint-anim (-> self draw art-group data 43)) + num-func-loop! + ) + ) + ) + ) + (else + (let ((a0-9 (-> self skel root-channel 0))) + (set! (-> a0-9 frame-group) (the-as art-joint-anim (-> self draw art-group data 38))) + (set! (-> a0-9 param 0) (-> (new 'static 'array float 1 1.0) 0)) + (set! (-> a0-9 frame-num) 0.0) + (joint-control-channel-group! a0-9 (the-as art-joint-anim (-> self draw art-group data 38)) num-func-loop!) + ) + (while #t + (suspend) + (let ((a0-10 (-> self skel root-channel 0))) + (set! (-> a0-10 frame-group) (the-as art-joint-anim (-> self draw art-group data 38))) + (set! (-> a0-10 param 0) (-> (new 'static 'array float 1 1.0) 0)) + (joint-control-channel-group-eval! + a0-10 + (the-as art-joint-anim (-> self draw art-group data 38)) + num-func-loop! + ) + ) + ) + ) + ) ) - (suspend) - ) - (cond - ((= arg2 'launch) - (let ((a0-7 (-> self skel root-channel 0))) - (set! - (-> a0-7 frame-group) - (the-as art-joint-anim (-> self draw art-group data 43)) - ) - (set! (-> a0-7 param 0) f28-0) - (set! (-> a0-7 frame-num) 0.0) - (joint-control-channel-group! - a0-7 - (the-as art-joint-anim (-> self draw art-group data 43)) - num-func-loop! - ) - ) - (while #t - (suspend) - (let ((a0-8 (-> self skel root-channel 0))) - (set! - (-> a0-8 frame-group) - (the-as art-joint-anim (-> self draw art-group data 43)) - ) - (set! (-> a0-8 param 0) f28-0) - (joint-control-channel-group-eval! - a0-8 - (the-as art-joint-anim (-> self draw art-group data 43)) - num-func-loop! - ) - ) - ) - ) - (else - (let ((a0-9 (-> self skel root-channel 0))) - (set! - (-> a0-9 frame-group) - (the-as art-joint-anim (-> self draw art-group data 38)) - ) - (set! (-> a0-9 param 0) (-> (new 'static 'array float 1 1.0) 0)) - (set! (-> a0-9 frame-num) 0.0) - (joint-control-channel-group! - a0-9 - (the-as art-joint-anim (-> self draw art-group data 38)) - num-func-loop! - ) - ) - (while #t - (suspend) - (let ((a0-10 (-> self skel root-channel 0))) - (set! - (-> a0-10 frame-group) - (the-as art-joint-anim (-> self draw art-group data 38)) - ) - (set! (-> a0-10 param 0) (-> (new 'static 'array float 1 1.0) 0)) - (joint-control-channel-group-eval! - a0-10 - (the-as art-joint-anim (-> self draw art-group data 38)) - num-func-loop! - ) - ) - ) - ) - ) + (the-as none 0) + (none) ) - (the-as none 0) - (none) - ) :post (the-as (function none :behavior target) target-post) ) +;; failed to figure out what this is: (defstate target-falling (target) :event target-jump-event-handler :enter (behavior ((arg0 symbol)) - (set! (-> self control unknown-surface00) *jump-mods*) - (set! (-> self control unknown-uint20) (the-as uint arg0)) - (set! (-> self state-time) (-> *display* base-frame-counter)) - (none) - ) + (set! (-> self control unknown-surface00) *jump-mods*) + (set! (-> self control unknown-uint20) (the-as uint arg0)) + (set! (-> self state-time) (-> *display* base-frame-counter)) + (none) + ) :trans (behavior () - (target-falling-trans - (-> self control unknown-spoolanim00) - (the-as cpad-list (if (= (-> self control unknown-spoolanim00) #f) - 0 - (/ (the-as int (-> *TARGET-bank* stuck-time)) 2) - ) - ) + (target-falling-trans + (-> self control unknown-spoolanim00) + (the-as cpad-list (if (= (-> self control unknown-spoolanim00) #f) + 0 + (/ (the-as int (-> *TARGET-bank* stuck-time)) 2) + ) + ) + ) + (none) ) - (none) - ) :code (behavior ((arg0 symbol)) - (target-falling-anim -1 99) - (none) - ) + (target-falling-anim -1 99) + (none) + ) :post (the-as (function none :behavior target) target-post) ) +;; failed to figure out what this is: (defstate target-hit-ground (target) :event target-walk-event-handler :enter (behavior ((arg0 symbol)) - (cond - ((= arg0 'stuck) - ) - ((let ((v1-4 (if (> (-> self skel active-channels) 0) - (-> self skel root-channel 0 frame-group) - ) - ) - ) - (or - (= v1-4 (-> self draw art-group data 42)) - (= v1-4 (-> self draw art-group data 43)) + (cond + ((= arg0 'stuck) ) - ) - (dummy-10 - (-> self skel effect) - 'group-blue-hit-ground-effect - (-> (new 'static 'array float 1 0.0) 0) - -1 - ) - (cpad-set-buzz! (-> *cpad-list* cpads 0) 1 255 90) - ) - (else - (let - ((f0-1 - (vector-dot - (-> self control dynam gravity-normal) - (vector-! - (new 'stack-no-clear 'vector) - (-> self control unknown-vector52) - (-> self control trans) - ) + ((let ((v1-4 (if (> (-> self skel active-channels) 0) + (-> self skel root-channel 0 frame-group) + ) + ) + ) + (or (= v1-4 (-> self draw art-group data 42)) (= v1-4 (-> self draw art-group data 43))) ) - ) + (dummy-10 (-> self skel effect) 'group-blue-hit-ground-effect (-> (new 'static 'array float 1 0.0) 0) -1) + (cpad-set-buzz! (-> *cpad-list* cpads 0) 1 255 90) ) - (if - (and - (< (-> *TARGET-bank* fall-far) f0-1) - (zero? (logand (-> self control status) 1024)) + (else + (let ((f0-1 (vector-dot + (-> self control dynam gravity-normal) + (vector-! (new 'stack-no-clear 'vector) (-> self control unknown-vector52) (-> self control trans)) + ) + ) + ) + (if (and (< (-> *TARGET-bank* fall-far) f0-1) (zero? (logand (-> self control status) 1024))) + (go target-hit-ground-hard f0-1) + ) + ) ) - (go target-hit-ground-hard f0-1) - ) ) - ) + (cond + ((= arg0 'stuck) + ) + (else + (target-land-effect) + ) + ) + (set! (-> self control unknown-dword31) 0) + (set! (-> self control unknown-dword33) 0) + (if (>= (-> self control ground-impact-vel) (-> *TARGET-bank* fall-stumble-threshold)) + (set-forward-vel (-> (new 'static 'array float 1 0.0) 0)) + ) + (if (!= (-> self control ground-pat material) (pat-material ice)) + (delete-back-vel) + ) + (set! (-> self control unknown-surface00) *walk-mods*) + (start-bobbing! + (-> self water) + (lerp-scale + (-> (new 'static 'array float 1 0.0) 0) + (the-as float 4096.0) + (-> self control ground-impact-vel) + (the-as float 40960.0) + (-> (new 'static 'array float 1 102400.0) 0) + ) + 600 + 1500 + ) + (none) ) - (cond - ((= arg0 'stuck) - ) - (else - (target-land-effect) - ) - ) - (set! (-> self control unknown-dword31) 0) - (set! (-> self control unknown-dword33) 0) - (if - (>= - (-> self control ground-impact-vel) - (-> *TARGET-bank* fall-stumble-threshold) - ) - (set-forward-vel (-> (new 'static 'array float 1 0.0) 0)) - ) - (if (!= (-> self control ground-pat material) (pat-material ice)) - (delete-back-vel) - ) - (set! (-> self control unknown-surface00) *walk-mods*) - (start-bobbing! - (-> self water) - (lerp-scale - (-> (new 'static 'array float 1 0.0) 0) - (the-as float 4096.0) - (-> self control ground-impact-vel) - (the-as float 40960.0) - (-> (new 'static 'array float 1 102400.0) 0) - ) - 600 - 1500 - ) - (none) - ) :trans (behavior () - (if - (and - (logtest? - (logior - (logior - (-> - *cpad-list* - cpads - (-> self control unknown-cpad-info00 number) - button0-rel - 0 - ) - (-> - *cpad-list* - cpads - (-> self control unknown-cpad-info00 number) - button0-rel - 1 - ) + (if (and (logtest? (logior (logior (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) button0-rel 0) + (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) button0-rel 1) + ) + (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) button0-rel 2) + ) + (pad-buttons x) + ) + (can-jump? #f) + ) + (go target-jump (-> *TARGET-bank* jump-height-min) (-> *TARGET-bank* jump-height-max) (the-as surface #f)) ) - (-> - *cpad-list* - cpads - (-> self control unknown-cpad-info00 number) - button0-rel - 2 + (if (and (not (can-exit-duck?)) (can-duck?)) + (go target-duck-stance) ) - ) - (pad-buttons x) + (when (!= (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) stick0-speed) 0.0) + (if (logtest? (-> self water flags) 1024) + (go target-wade-walk) + (go target-walk) + ) ) - (can-jump? #f) - ) - (go - target-jump - (-> *TARGET-bank* jump-height-min) - (-> *TARGET-bank* jump-height-max) - (the-as surface #f) - ) - ) - (if (and (not (can-exit-duck?)) (can-duck?)) - (go target-duck-stance) - ) - (when - (!= - (-> - *cpad-list* - cpads - (-> self control unknown-cpad-info00 number) - stick0-speed - ) - 0.0 - ) - (if (logtest? (-> self water flags) 1024) - (go target-wade-walk) - (go target-walk) - ) - ) - (if - (and - (or - (logtest? - (-> - *cpad-list* - cpads - (-> self control unknown-cpad-info00 number) - button0-abs - 0 + (if (and (or (logtest? (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) button0-abs 0) + (pad-buttons l1 r1) + ) + (not (can-exit-duck?)) + ) + (can-duck?) + ) + (go target-duck-stance) ) - (pad-buttons l1 r1) - ) - (not (can-exit-duck?)) - ) - (can-duck?) - ) - (go target-duck-stance) + (if (and (logtest? (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) button0-rel 0) + (pad-buttons circle) + ) + (can-feet?) + ) + (go target-attack) + ) + (if (can-hands? #t) + (go target-running-attack) + ) + (fall-test) + (slide-down-test) + (none) ) - (if - (and - (logtest? - (-> - *cpad-list* - cpads - (-> self control unknown-cpad-info00 number) - button0-rel - 0 - ) - (pad-buttons circle) - ) - (can-feet?) - ) - (go target-attack) - ) - (if (can-hands? #t) - (go target-running-attack) - ) - (fall-test) - (slide-down-test) - (none) - ) :code (behavior ((arg0 symbol)) - (target-hit-ground-anim #f) - (go target-stance) - (none) - ) + (target-hit-ground-anim #f) + (go target-stance) + (none) + ) :post (the-as (function none :behavior target) target-post) ) +;; failed to figure out what this is: (defstate target-attack (target) :event target-dangerous-event-handler :enter (behavior () - (set! (-> self state-time) (-> *display* base-frame-counter)) - (target-start-attack) - (target-danger-set! 'spin #f) - (set! (-> self control unknown-surface00) *attack-mods*) - (set! (-> self water drip-mult) 4.0) - (set! (-> self neck flex-blend) 0.0) - (none) - ) + (set! (-> self state-time) (-> *display* base-frame-counter)) + (target-start-attack) + (target-danger-set! 'spin #f) + (set! (-> self control unknown-surface00) *attack-mods*) + (set! (-> self water drip-mult) 4.0) + (set! (-> self neck flex-blend) 0.0) + (none) + ) :exit (behavior () - (set! (-> self control unknown-dword33) (-> *display* base-frame-counter)) - (target-exit) - (none) - ) + (set! (-> self control unknown-dword33) (-> *display* base-frame-counter)) + (target-exit) + (none) + ) :code (behavior () - (ja-channel-push! 1 15) - (let ((a0-1 (-> self skel root-channel 0))) - (set! - (-> a0-1 frame-group) - (the-as art-joint-anim (-> self draw art-group data 51)) - ) - (set! - (-> a0-1 param 0) - (the - float - (+ - (-> - (the-as art-joint-anim (-> self draw art-group data 51)) - data - 0 - length - ) - -1 - ) + (ja-channel-push! 1 15) + (let ((a0-1 (-> self skel root-channel 0))) + (set! (-> a0-1 frame-group) (the-as art-joint-anim (-> self draw art-group data 51))) + (set! (-> a0-1 param 0) + (the float (+ (-> (the-as art-joint-anim (-> self draw art-group data 51)) data 0 length) -1)) + ) + (set! (-> a0-1 param 1) (-> self control unknown-surface01 align-speed)) + (set! (-> a0-1 frame-num) 0.0) + (joint-control-channel-group! a0-1 (the-as art-joint-anim (-> self draw art-group data 51)) num-func-seek!) ) - ) - (set! (-> a0-1 param 1) (-> self control unknown-surface01 align-speed)) - (set! (-> a0-1 frame-num) 0.0) - (joint-control-channel-group! - a0-1 - (the-as art-joint-anim (-> self draw art-group data 51)) - num-func-seek! - ) - ) - (until (ja-done? 0) - (when - (and - (= (-> self fact-info-target eco-type) 2) - (>= - (-> self fact-info-target eco-level) - (-> (new 'static 'array float 1 1.0) 0) - ) - ) - (dummy-10 - (-> self skel effect) - 'group-red-eco-spinkick - (ja-frame-num 0) - 74 - ) - (cpad-set-buzz! (-> *cpad-list* cpads 0) 1 153 30) - (level-hint-spawn - (game-text-id red-eco-tutorial) - "sksp0072" - (the-as entity #f) - *entity-pool* - (game-task none) - ) - ) - (if - (and - (logtest? - (logior - (logior - (-> - *cpad-list* - cpads - (-> self control unknown-cpad-info00 number) - button0-rel - 0 + (until (ja-done? 0) + (when (and (= (-> self fact-info-target eco-type) 2) + (>= (-> self fact-info-target eco-level) (-> (new 'static 'array float 1 1.0) 0)) + ) + (dummy-10 (-> self skel effect) 'group-red-eco-spinkick (ja-frame-num 0) 74) + (cpad-set-buzz! (-> *cpad-list* cpads 0) 1 153 30) + (level-hint-spawn + (game-text-id red-eco-tutorial) + "sksp0072" + (the-as entity #f) + *entity-pool* + (game-task none) ) - (-> - *cpad-list* - cpads - (-> self control unknown-cpad-info00 number) - button0-rel - 1 - ) - ) - (-> - *cpad-list* - cpads - (-> self control unknown-cpad-info00 number) - button0-rel - 2 - ) ) - (pad-buttons x) - ) - (can-jump? #f) + (if (and (logtest? (logior (logior (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) button0-rel 0) + (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) button0-rel 1) + ) + (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) button0-rel 2) + ) + (pad-buttons x) + ) + (can-jump? #f) + ) + (go target-jump (-> *TARGET-bank* jump-height-min) (-> *TARGET-bank* jump-height-max) (the-as surface #f)) + ) + (suspend) + (let ((a0-24 (-> self skel root-channel 0))) + (set! (-> a0-24 param 0) (the float (+ (-> a0-24 frame-group data 0 length) -1))) + (set! (-> a0-24 param 1) (-> self control unknown-surface01 align-speed)) + (joint-control-channel-group-eval! a0-24 (the-as art-joint-anim #f) num-func-seek!) + ) ) - (go - target-jump - (-> *TARGET-bank* jump-height-min) - (-> *TARGET-bank* jump-height-max) - (the-as surface #f) - ) - ) - (suspend) - (let ((a0-24 (-> self skel root-channel 0))) - (set! - (-> a0-24 param 0) - (the float (+ (-> a0-24 frame-group data 0 length) -1)) - ) - (set! (-> a0-24 param 1) (-> self control unknown-surface01 align-speed)) - (joint-control-channel-group-eval! - a0-24 - (the-as art-joint-anim #f) - num-func-seek! - ) - ) + (go target-stance) + (none) ) - (go target-stance) - (none) - ) :post (the-as (function none :behavior target) target-post) ) +;; failed to figure out what this is: (defstate target-running-attack (target) :event (behavior ((arg0 process) (arg1 int) (arg2 symbol) (arg3 event-message-block)) - (case arg2 - (('touched) - (cond - (((method-of-type touching-shapes-entry prims-touching?) - (the-as touching-shapes-entry (-> arg3 param 0)) - (-> self control) - (the-as uint 224) - ) - (let - ((gp-1 - (target-send-attack - arg0 - (the-as uint (-> self control unknown-symbol30)) - (-> arg3 param 0) - (-> self control unknown-dword50) - (-> self control unknown-dword51) - ) + (case arg2 + (('touched) + (cond + (((method-of-type touching-shapes-entry prims-touching?) + (the-as touching-shapes-entry (-> arg3 param 0)) + (-> self control) + (the-as uint 224) ) - ) - (when gp-1 - (set! - (-> self control unknown-uint20) - (the-as uint (-> *display* base-frame-counter)) - ) - (let - ((v1-9 - (if - (and (nonzero? arg0) (type-type? (-> arg0 type) process-drawable)) - arg0 - ) - ) - ) - (when v1-9 - (let* ((s5-1 (-> (the-as process-drawable v1-9) root)) - (v1-11 - (if - (and - (nonzero? s5-1) - (type-type? (-> s5-1 type) collide-shape) + (let ((gp-1 (target-send-attack + arg0 + (the-as uint (-> self control unknown-symbol30)) + (-> arg3 param 0) + (-> self control unknown-dword50) + (-> self control unknown-dword51) + ) ) - (the-as collide-shape s5-1) - ) - ) - ) - (if - (and - v1-11 - (or - (logtest? (-> v1-11 root-prim prim-core collide-as) 256) - (logtest? (-> v1-11 root-prim prim-core action) 1024) ) - ) - (set! (-> self control unknown-uint31) (the-as uint 1)) + (when gp-1 + (set! (-> self control unknown-uint20) (the-as uint (-> *display* base-frame-counter))) + (let ((v1-9 (if (and (nonzero? arg0) (type-type? (-> arg0 type) process-drawable)) + arg0 + ) + ) + ) + (when v1-9 + (let* ((s5-1 (-> (the-as process-drawable v1-9) root)) + (v1-11 (if (and (nonzero? s5-1) (type-type? (-> s5-1 type) collide-shape)) + (the-as collide-shape s5-1) + ) + ) + ) + (if (and v1-11 (or (logtest? (-> v1-11 root-prim prim-core collide-as) (collide-kind enemy)) + (logtest? (-> v1-11 root-prim prim-core action) (collide-action ca-10)) + ) + ) + (set! (-> self control unknown-uint31) (the-as uint 1)) + ) + ) + ) + ) + (when (or (= gp-1 'die) (= gp-1 'push)) + (let ((v0-2 (the-as object (-> *display* base-frame-counter)))) + (set! (-> self control unknown-int21) (the-as int v0-2)) + v0-2 + ) + ) ) - ) ) - ) - (when (or (= gp-1 'die) (= gp-1 'push)) - (let ((v0-2 (the-as object (-> *display* base-frame-counter)))) - (set! (-> self control unknown-int21) (the-as int v0-2)) - v0-2 - ) - ) ) + (else + (target-dangerous-event-handler arg0 arg1 arg2 arg3) + ) ) - ) - (else + ) + (else (target-dangerous-event-handler arg0 arg1 arg2 arg3) ) - ) ) - (else - (target-dangerous-event-handler arg0 arg1 arg2 arg3) - ) ) - ) :enter (behavior () - (if - (or - (and - (= (-> self fact-info-target eco-type) 1) - (>= - (-> self fact-info-target eco-level) - (-> (new 'static 'array float 1 1.0) 0) - ) - ) - (< - (- (-> *display* base-frame-counter) (-> self control unknown-dword82)) - 450 - ) - ) - (go target-yellow-blast) + (if (or (and (= (-> self fact-info-target eco-type) 1) + (>= (-> self fact-info-target eco-level) (-> (new 'static 'array float 1 1.0) 0)) + ) + (< (- (-> *display* base-frame-counter) (-> self control unknown-dword82)) 450) + ) + (go target-yellow-blast) + ) + (set! (-> self state-time) (-> *display* base-frame-counter)) + (set! (-> self control unknown-uint20) (the-as uint 0)) + (set! (-> self control unknown-int21) 0) + (set! (-> self control unknown-uint31) (the-as uint 0)) + (set! (-> self control unknown-surface00) *run-attack-mods*) + (set! (-> *run-attack-mods* turnv) 655360.0) + (set! (-> *run-attack-mods* turnvv) 655360.0) + (target-start-attack) + (target-danger-set! 'punch #f) + (if (or (< (fabs (-> self control unknown-float62)) 0.3) (< 0.3 (fabs (-> self control unknown-float61)))) + (set! (-> self control unknown-float81) (-> (new 'static 'array float 1 1.0) 0)) + ) + (none) ) - (set! (-> self state-time) (-> *display* base-frame-counter)) - (set! (-> self control unknown-uint20) (the-as uint 0)) - (set! (-> self control unknown-int21) 0) - (set! (-> self control unknown-uint31) (the-as uint 0)) - (set! (-> self control unknown-surface00) *run-attack-mods*) - (set! (-> *run-attack-mods* turnv) 655360.0) - (set! (-> *run-attack-mods* turnvv) 655360.0) - (target-start-attack) - (target-danger-set! 'punch #f) - (if - (or - (< (fabs (-> self control unknown-float62)) 0.3) - (< 0.3 (fabs (-> self control unknown-float61))) - ) - (set! - (-> self control unknown-float81) - (-> (new 'static 'array float 1 1.0) 0) - ) - ) - (none) - ) :exit (behavior () - (set! - (-> self control dynam gravity-max) - (-> self control unknown-dynamics00 gravity-max) + (set! (-> self control dynam gravity-max) (-> self control unknown-dynamics00 gravity-max)) + (set! (-> self control dynam gravity-length) (-> self control unknown-dynamics00 gravity-length)) + (set! (-> *run-attack-mods* turnv) 0.0) + (set! (-> *run-attack-mods* turnvv) 0.0) + (set! (-> self control unknown-dword31) (-> *display* base-frame-counter)) + (target-exit) + (none) ) - (set! - (-> self control dynam gravity-length) - (-> self control unknown-dynamics00 gravity-length) - ) - (set! (-> *run-attack-mods* turnv) 0.0) - (set! (-> *run-attack-mods* turnvv) 0.0) - (set! (-> self control unknown-dword31) (-> *display* base-frame-counter)) - (target-exit) - (none) - ) :trans (behavior () - (when (!= (-> self state-time) (-> *display* base-frame-counter)) - (if - (and - (or - (smack-surface? #t) - (and - (>= (-> self control unknown-float63) 0.7) - (zero? (logand (-> self control status) 32)) - ) - ) - (begin - (set! (-> self control unknown-int21) (-> *display* base-frame-counter)) - (set! (-> self control unknown-float81) 0.0) - (let ((gp-0 (new-stack-vector0)) - (f30-0 - (vector-dot - (-> self control dynam gravity-normal) - (-> self control transv) + (when (!= (-> self state-time) (-> *display* base-frame-counter)) + (if (and (or (smack-surface? #t) + (and (>= (-> self control unknown-float63) 0.7) (zero? (logand (-> self control status) 32))) + ) + (begin + (set! (-> self control unknown-int21) (-> *display* base-frame-counter)) + (set! (-> self control unknown-float81) 0.0) + (let ((gp-0 (new-stack-vector0)) + (f30-0 (vector-dot (-> self control dynam gravity-normal) (-> self control transv))) + ) + 0.0 + (vector-! gp-0 (-> self control transv) (vector-float*! gp-0 (-> self control dynam gravity-normal) f30-0)) + (let* ((f0-5 (vector-length gp-0)) + (f1-1 f0-5) + (f2-1 (fmin 0.0 f30-0)) + ) + (vector+! + (-> self control transv) + (vector-float*! (-> self control transv) (-> self control dynam gravity-normal) f2-1) + (vector-float*! gp-0 gp-0 (/ f0-5 f1-1)) + ) + ) + ) + #t + ) + (or (zero? (-> self control unknown-uint20)) + (>= (the-as uint (- (-> *display* base-frame-counter) (the-as int (-> self control unknown-uint20)))) + (the-as uint 12) + ) + ) + (!= (-> self control unknown-uint31) 1) ) - ) - ) - 0.0 - (vector-! - gp-0 - (-> self control transv) - (vector-float*! gp-0 (-> self control dynam gravity-normal) f30-0) - ) - (let* ((f0-5 (vector-length gp-0)) - (f1-1 f0-5) - (f2-1 (fmin 0.0 f30-0)) + (target-shoved + (-> *TARGET-bank* smack-surface-dist) + (-> *TARGET-bank* smack-surface-height) + (the-as process #f) + target-hit + ) + ) + (if (and (logtest? (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) button0-rel 0) (pad-buttons x)) + (and (< 4096.0 (-> self control unknown-float01)) + (or (>= (- (-> *display* base-frame-counter) (-> self state-time)) 30) + (zero? + (logand (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) button0-abs 0) + (pad-buttons square) + ) + ) + ) + (zero? (logand (-> self state-flags) 6144)) + (zero? (logand (-> self control unknown-surface01 flags) 128)) + ) ) - (vector+! - (-> self control transv) - (vector-float*! - (-> self control transv) - (-> self control dynam gravity-normal) - f2-1 - ) - (vector-float*! gp-0 gp-0 (/ f0-5 f1-1)) + (go + target-attack-uppercut + (-> *TARGET-bank* attack-jump-height-min) + (-> *TARGET-bank* attack-jump-height-max) + ) ) - ) - ) - #t - ) - (or - (zero? (-> self control unknown-uint20)) - (>= - (the-as - uint - (- - (-> *display* base-frame-counter) - (the-as int (-> self control unknown-uint20)) + (if (and (logtest? (-> self water flags) 512) + (zero? (mod (- (-> *display* base-frame-counter) (-> self state-time)) 21)) + ) + (dummy-13 + (-> self water) + (the-as float 0.6) + (vector<-cspace! (new 'stack-no-clear 'vector) (-> self node-list data 37)) + 0 + (-> self control transv) + ) ) - ) - (the-as uint 12) - ) - ) - (!= (-> self control unknown-uint31) 1) - ) - (target-shoved - (-> *TARGET-bank* smack-surface-dist) - (-> *TARGET-bank* smack-surface-height) - (the-as process #f) - (the-as (state target) target-hit) - ) - ) - (if - (and - (logtest? - (-> - *cpad-list* - cpads - (-> self control unknown-cpad-info00 number) - button0-rel - 0 - ) - (pad-buttons x) - ) - (and - (< 4096.0 (-> self control unknown-float01)) - (or - (>= (- (-> *display* base-frame-counter) (-> self state-time)) 30) - (zero? - (logand - (-> - *cpad-list* - cpads - (-> self control unknown-cpad-info00 number) - button0-abs - 0 - ) - (pad-buttons square) + (when (and (= (-> self fact-info-target eco-type) 2) + (>= (-> self fact-info-target eco-level) (-> (new 'static 'array float 1 1.0) 0)) + ) + (dummy-10 (-> self skel effect) 'group-red-eco-spinkick (ja-frame-num 0) 23) + (cpad-set-buzz! (-> *cpad-list* cpads 0) 1 153 30) + (level-hint-spawn + (game-text-id red-eco-tutorial) + "sksp0072" + (the-as entity #f) + *entity-pool* + (game-task none) ) - ) ) - (zero? (logand (-> self state-flags) 6144)) - (zero? (logand (-> self control unknown-surface01 flags) 128)) - ) ) - (go - target-attack-uppercut - (-> *TARGET-bank* attack-jump-height-min) - (-> *TARGET-bank* attack-jump-height-max) - ) - ) - (if - (and - (logtest? (-> self water flags) 512) - (zero? - (mod (- (-> *display* base-frame-counter) (-> self state-time)) 21) - ) - ) - (dummy-13 - (-> self water) - (the-as float 0.6) - (vector<-cspace! - (new 'stack-no-clear 'vector) - (-> self node-list data 37) - ) - 0 - (-> self control transv) - ) - ) - (when - (and - (= (-> self fact-info-target eco-type) 2) - (>= - (-> self fact-info-target eco-level) - (-> (new 'static 'array float 1 1.0) 0) - ) - ) - (dummy-10 - (-> self skel effect) - 'group-red-eco-spinkick - (ja-frame-num 0) - 23 - ) - (cpad-set-buzz! (-> *cpad-list* cpads 0) 1 153 30) - (level-hint-spawn - (game-text-id red-eco-tutorial) - "sksp0072" - (the-as entity #f) - *entity-pool* - (game-task none) - ) - ) + (none) ) - (none) - ) :code (behavior () - (if (logtest? (-> self water flags) 512) - (sound-play-by-name - (static-sound-name "swim-stroke") - (new-sound-id) - 1024 - 0 - 0 - 1 - #t - ) - ) - (ja-channel-push! 1 6) - (let ((gp-1 (-> self skel root-channel 0))) - (joint-control-channel-group-eval! - gp-1 - (the-as art-joint-anim (-> self draw art-group data 59)) - num-func-identity - ) - (set! (-> gp-1 frame-num) 0.0) - ) - (set! (-> self control dynam gravity-max) 368640.0) - (set! (-> self control dynam gravity-length) 368640.0) - (let ((f28-0 0.0) - (f30-0 (-> (new 'static 'array float 1 1.0) 0)) - (gp-2 0) - ) - (until (ja-done? 0) - (TODO-RENAME-9 (-> self align)) - (when (not (ja-min? 0)) - (cond - ((and - (>= (ja-aframe-num 0) 20.0) - (and - (and - (zero? (logand (-> self control status) 1)) - (>= - (- - (-> *display* base-frame-counter) - (-> self control unknown-dword11) - ) - (the-as int (-> *TARGET-bank* ground-timeout)) - ) - (>= - 0.0 - (vector-dot - (-> self control dynam gravity-normal) - (-> self control transv) - ) - ) - (let ((v1-39 (if (> (-> self skel active-channels) 0) - (-> self skel root-channel 0 frame-group) - ) - ) - ) - (or - (not - (or - (= v1-39 (-> self draw art-group data 59)) - (= v1-39 (-> self draw art-group data 60)) - (= v1-39 (-> self draw art-group data 61)) - ) - ) - (< 4096.0 (target-height-above-ground)) - ) - ) - ) - (>= - (the-as - uint - (- - (-> *display* base-frame-counter) - (the-as int (-> self control unknown-uint20)) - ) - ) - (the-as uint 12) - ) + (if (logtest? (-> self water flags) 512) + (sound-play-by-name (static-sound-name "swim-stroke") (new-sound-id) 1024 0 0 1 #t) + ) + (ja-channel-push! 1 6) + (let ((gp-1 (-> self skel root-channel 0))) + (joint-control-channel-group-eval! + gp-1 + (the-as art-joint-anim (-> self draw art-group data 59)) + num-func-identity + ) + (set! (-> gp-1 frame-num) 0.0) + ) + (set! (-> self control dynam gravity-max) 368640.0) + (set! (-> self control dynam gravity-length) 368640.0) + (let ((f28-0 0.0) + (f30-0 (-> (new 'static 'array float 1 1.0) 0)) + (gp-2 0) ) - ) + (until (ja-done? 0) + (TODO-RENAME-9 (-> self align)) + (when (not (ja-min? 0)) + (cond + ((and (>= (ja-aframe-num 0) 20.0) + (and (and (zero? (logand (-> self control status) 1)) + (>= (- (-> *display* base-frame-counter) (-> self control unknown-dword11)) + (the-as int (-> *TARGET-bank* ground-timeout)) + ) + (>= 0.0 (vector-dot (-> self control dynam gravity-normal) (-> self control transv))) + (let ((v1-39 (if (> (-> self skel active-channels) 0) + (-> self skel root-channel 0 frame-group) + ) + ) + ) + (or (not + (or (= v1-39 (-> self draw art-group data 59)) + (= v1-39 (-> self draw art-group data 60)) + (= v1-39 (-> self draw art-group data 61)) + ) + ) + (< 4096.0 (target-height-above-ground)) + ) + ) + ) + (>= (the-as uint (- (-> *display* base-frame-counter) (the-as int (-> self control unknown-uint20)))) + (the-as uint 12) + ) + ) + ) + (go target-falling #f) + ) + ((and (nonzero? (-> self control unknown-uint30)) + (>= (the-as uint (- (-> *display* base-frame-counter) (the-as int (-> self control unknown-uint30)))) + (the-as uint 12) + ) + ) + (set-forward-vel (-> (new 'static 'array float 1 0.0) 0)) + ) + ((and (zero? (logand (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) button0-abs 0) + (pad-buttons square) + ) + ) + (>= (- (-> *display* base-frame-counter) (-> self state-time)) 15) + ) + (if (= (-> self control ground-pat material) (pat-material ice)) + (set-forward-vel (fmax 32768.0 (* 0.8 (-> self control unknown-float01)))) + (set-forward-vel (* 0.8 (-> self control unknown-float01))) + ) + ) + ((ja-done? 0) + (set-forward-vel f28-0) + ) + (else + (set! f28-0 + (* (target-align-vel-z-adjust (-> self align delta trans z)) (-> *display* frames-per-second) f30-0) + ) + (set-forward-vel f28-0) + ) + ) + ) + (let ((s5-1 (new-stack-vector0))) + (vector-matrix*! s5-1 (-> self control transv) (-> self control unknown-matrix00)) + (set! (-> s5-1 y) 0.0) + (vector-matrix*! (-> self control unknown-vector120) s5-1 (-> self control unknown-matrix01)) + ) + (suspend) + (let ((a0-44 (-> self skel root-channel 0))) + (set! (-> a0-44 param 0) (the float (+ (-> a0-44 frame-group data 0 length) -1))) + (set! (-> a0-44 param 1) (-> self control unknown-surface01 align-speed)) + (joint-control-channel-group-eval! a0-44 (the-as art-joint-anim #f) num-func-seek!) + ) + (if (>= (- (-> *display* base-frame-counter) (-> self state-time)) 30) + (set! (-> *run-attack-mods* turnvv) 0.0) + ) + (if (< 2 gp-2) + (set! f30-0 (* f30-0 (fmin (-> (new 'static 'array float 1 1.0) 0) (-> self control unknown-float140)))) + ) + (+! gp-2 1) + ) + ) + (if (and (zero? (logand (-> self control status) 1)) + (>= (- (-> *display* base-frame-counter) (-> self control unknown-dword11)) + (the-as int (-> *TARGET-bank* ground-timeout)) + ) + (>= 0.0 (vector-dot (-> self control dynam gravity-normal) (-> self control transv))) + (let ((v1-121 (if (> (-> self skel active-channels) 0) + (-> self skel root-channel 0 frame-group) + ) + ) + ) + (or (not (or (= v1-121 (-> self draw art-group data 59)) + (= v1-121 (-> self draw art-group data 60)) + (= v1-121 (-> self draw art-group data 61)) + ) + ) + (< 4096.0 (target-height-above-ground)) + ) + ) + ) (go target-falling #f) ) - ((and - (nonzero? (-> self control unknown-uint30)) - (>= - (the-as - uint - (- - (-> *display* base-frame-counter) - (the-as int (-> self control unknown-uint30)) - ) - ) - (the-as uint 12) - ) - ) - (set-forward-vel (-> (new 'static 'array float 1 0.0) 0)) - ) - ((and - (zero? - (logand - (-> - *cpad-list* - cpads - (-> self control unknown-cpad-info00 number) - button0-abs - 0 - ) - (pad-buttons square) - ) - ) - (>= (- (-> *display* base-frame-counter) (-> self state-time)) 15) - ) - (if (= (-> self control ground-pat material) (pat-material ice)) - (set-forward-vel - (fmax 32768.0 (* 0.8 (-> self control unknown-float01))) - ) - (set-forward-vel (* 0.8 (-> self control unknown-float01))) - ) - ) - ((ja-done? 0) - (set-forward-vel f28-0) - ) - (else - (set! - f28-0 - (* - (target-align-vel-z-adjust (-> self align delta trans z)) - (-> *display* frames-per-second) - f30-0 - ) - ) - (set-forward-vel f28-0) - ) - ) - ) - (let ((s5-1 (new-stack-vector0))) - (vector-matrix*! - s5-1 - (-> self control transv) - (-> self control unknown-matrix00) - ) - (set! (-> s5-1 y) 0.0) - (vector-matrix*! - (-> self control unknown-vector120) - s5-1 - (-> self control unknown-matrix01) - ) - ) - (suspend) - (let ((a0-44 (-> self skel root-channel 0))) - (set! - (-> a0-44 param 0) - (the float (+ (-> a0-44 frame-group data 0 length) -1)) - ) - (set! (-> a0-44 param 1) (-> self control unknown-surface01 align-speed)) - (joint-control-channel-group-eval! - a0-44 - (the-as art-joint-anim #f) - num-func-seek! - ) - ) - (if (>= (- (-> *display* base-frame-counter) (-> self state-time)) 30) - (set! (-> *run-attack-mods* turnvv) 0.0) - ) - (if (< 2 gp-2) - (set! - f30-0 - (* - f30-0 - (fmin - (-> (new 'static 'array float 1 1.0) 0) - (-> self control unknown-float140) - ) - ) - ) - ) - (+! gp-2 1) - ) + (go target-stance) + (none) ) - (if - (and - (zero? (logand (-> self control status) 1)) - (>= - (- (-> *display* base-frame-counter) (-> self control unknown-dword11)) - (the-as int (-> *TARGET-bank* ground-timeout)) - ) - (>= - 0.0 - (vector-dot - (-> self control dynam gravity-normal) - (-> self control transv) - ) - ) - (let ((v1-121 (if (> (-> self skel active-channels) 0) - (-> self skel root-channel 0 frame-group) - ) - ) - ) - (or - (not - (or - (= v1-121 (-> self draw art-group data 59)) - (= v1-121 (-> self draw art-group data 60)) - (= v1-121 (-> self draw art-group data 61)) - ) - ) - (< 4096.0 (target-height-above-ground)) - ) - ) - ) - (go target-falling #f) - ) - (go target-stance) - (none) - ) :post (the-as (function none :behavior target) target-post) ) +;; failed to figure out what this is: (defstate target-attack-air (target) :event (behavior ((arg0 process) (arg1 int) (arg2 symbol) (arg3 event-message-block)) - (let ((v0-0 (target-bonk-event-handler arg0 arg1 arg2 arg3))) - (cond - (v0-0 - (empty) - v0-0 + (let ((v0-0 (target-bonk-event-handler arg0 arg1 arg2 arg3))) + (cond + (v0-0 + (empty) + v0-0 + ) + (else + (target-dangerous-event-handler arg0 arg1 arg2 arg3) + ) + ) ) - (else - (target-dangerous-event-handler arg0 arg1 arg2 arg3) - ) - ) ) - ) :enter (behavior ((arg0 symbol)) - (set! (-> self state-time) (-> *display* base-frame-counter)) - (set! (-> self control status) (logand -8 (-> self control status))) - (target-start-attack) - (target-danger-set! 'spin-air #f) - (set! (-> self control unknown-surface00) *jump-attack-mods*) - (let - ((f0-1 - (vector-dot - (-> self control dynam gravity-normal) - (-> self control transv) - ) - ) - ) - (cond - ((or (>= 0.0 f0-1) (= arg0 'flop)) - (let ((gp-1 (new-stack-vector0))) - (let - ((f0-3 - (vector-dot - (-> self control dynam gravity-normal) - (-> self control transv) - ) - ) - ) - 0.0 - (vector-! - gp-1 - (-> self control transv) - (vector-float*! gp-1 (-> self control dynam gravity-normal) f0-3) - ) - ) - (let* ((f0-4 (vector-length gp-1)) - (f1-2 f0-4) - (f2-0 33775.48) - ) - (vector+! - (-> self control transv) - (vector-float*! - (-> self control transv) - (-> self control dynam gravity-normal) - f2-0 - ) - (vector-float*! gp-1 gp-1 (/ f0-4 f1-2)) - ) - ) - ) - ) - (else - (let* - ((f1-5 - (/ - f0-1 - (* - (-> self control dynam gravity-length) - (-> *display* seconds-per-frame) - ) - ) - ) - (f30-0 (* 0.5 f1-5 (-> *display* seconds-per-frame) f0-1)) - ) - (if (= (if (> (-> self skel active-channels) 0) - (-> self skel root-channel 0 frame-group) - ) - (-> self draw art-group data 62) - ) - (set! - f30-0 - (fmax - 0.0 - (- - (-> *TARGET-bank* attack-jump-height-max) - (vector-dot - (-> self control dynam gravity-normal) - (vector-! - (new 'stack-no-clear 'vector) - (-> self control trans) - (-> self control unknown-vector52) + (set! (-> self state-time) (-> *display* base-frame-counter)) + (set! (-> self control status) (logand -8 (-> self control status))) + (target-start-attack) + (target-danger-set! 'spin-air #f) + (set! (-> self control unknown-surface00) *jump-attack-mods*) + (let ((f0-1 (vector-dot (-> self control dynam gravity-normal) (-> self control transv)))) + (cond + ((or (>= 0.0 f0-1) (= arg0 'flop)) + (let ((gp-1 (new-stack-vector0))) + (let ((f0-3 (vector-dot (-> self control dynam gravity-normal) (-> self control transv)))) + 0.0 + (vector-! gp-1 (-> self control transv) (vector-float*! gp-1 (-> self control dynam gravity-normal) f0-3)) ) - ) - ) - ) - ) - ) - (let ((gp-2 (new-stack-vector0))) - (let - ((f0-8 - (vector-dot - (-> self control dynam gravity-normal) - (-> self control transv) - ) - ) - ) - 0.0 - (vector-! - gp-2 - (-> self control transv) - (vector-float*! gp-2 (-> self control dynam gravity-normal) f0-8) - ) - ) - (let* ((f0-9 (vector-length gp-2)) - (f1-11 f0-9) - (f2-7 (+ 1024.0 (sqrtf (* 245760.0 (+ 2048.0 f30-0))))) + (let* ((f0-4 (vector-length gp-1)) + (f1-2 f0-4) + (f2-0 33775.48) + ) + (vector+! + (-> self control transv) + (vector-float*! (-> self control transv) (-> self control dynam gravity-normal) f2-0) + (vector-float*! gp-1 gp-1 (/ f0-4 f1-2)) ) - (vector+! - (-> self control transv) - (vector-float*! - (-> self control transv) - (-> self control dynam gravity-normal) - f2-7 + ) ) - (vector-float*! gp-2 gp-2 (/ f0-9 f1-11)) - ) ) + (else + (let* ((f1-5 (/ f0-1 (* (-> self control dynam gravity-length) (-> *display* seconds-per-frame)))) + (f30-0 (* 0.5 f1-5 (-> *display* seconds-per-frame) f0-1)) + ) + (if (= (if (> (-> self skel active-channels) 0) + (-> self skel root-channel 0 frame-group) + ) + (-> self draw art-group data 62) + ) + (set! f30-0 + (fmax + 0.0 + (- (-> *TARGET-bank* attack-jump-height-max) + (vector-dot + (-> self control dynam gravity-normal) + (vector-! (new 'stack-no-clear 'vector) (-> self control trans) (-> self control unknown-vector52)) + ) + ) + ) + ) + ) + (let ((gp-2 (new-stack-vector0))) + (let ((f0-8 (vector-dot (-> self control dynam gravity-normal) (-> self control transv)))) + 0.0 + (vector-! gp-2 (-> self control transv) (vector-float*! gp-2 (-> self control dynam gravity-normal) f0-8)) + ) + (let* ((f0-9 (vector-length gp-2)) + (f1-11 f0-9) + (f2-7 (+ 1024.0 (sqrtf (* 245760.0 (+ 2048.0 f30-0))))) + ) + (vector+! + (-> self control transv) + (vector-float*! (-> self control transv) (-> self control dynam gravity-normal) f2-7) + (vector-float*! gp-2 gp-2 (/ f0-9 f1-11)) + ) + ) + ) + ) + ) ) - ) ) - ) + (set! (-> self control dynam gravity-length) 122880.0) + (set! (-> self control unknown-vector52 quad) (-> self control trans quad)) + (none) ) - (set! (-> self control dynam gravity-length) 122880.0) - (set! (-> self control unknown-vector52 quad) (-> self control trans quad)) - (none) - ) :exit (behavior () - (set! - (-> self control dynam gravity-max) - (-> self control unknown-dynamics00 gravity-max) + (set! (-> self control dynam gravity-max) (-> self control unknown-dynamics00 gravity-max)) + (set! (-> self control dynam gravity-length) (-> self control unknown-dynamics00 gravity-length)) + ((-> target-attack exit)) + (none) ) - (set! - (-> self control dynam gravity-length) - (-> self control unknown-dynamics00 gravity-length) - ) - ((-> target-attack exit)) - (none) - ) :trans (behavior () - (when (logtest? (-> self control status) 1) - (set-quaternion! (-> self control) (-> self control dir-targ)) - (go target-hit-ground #f) - ) - (if (>= (- (-> *display* base-frame-counter) (-> self state-time)) 150) - (set! - (-> self control dynam gravity-length) - (seek - (-> self control dynam gravity-length) - (-> self control unknown-dynamics00 gravity-length) - (* 245760.0 (-> *display* seconds-per-frame)) + (when (logtest? (-> self control status) 1) + (set-quaternion! (-> self control) (-> self control dir-targ)) + (go target-hit-ground #f) ) - ) - ) - (when - (and - (>= (- (-> *display* base-frame-counter) (-> self state-time)) 15) - (< - (vector-dot - (-> self control dynam gravity-normal) - (-> self control unknown-vector10) - ) - (vector-dot - (-> self control dynam gravity-normal) - (-> self control transv) - ) + (if (>= (- (-> *display* base-frame-counter) (-> self state-time)) 150) + (set! (-> self control dynam gravity-length) (seek + (-> self control dynam gravity-length) + (-> self control unknown-dynamics00 gravity-length) + (* 245760.0 (-> *display* seconds-per-frame)) + ) + ) + ) + (when (and (>= (- (-> *display* base-frame-counter) (-> self state-time)) 15) + (< (vector-dot (-> self control dynam gravity-normal) (-> self control unknown-vector10)) + (vector-dot (-> self control dynam gravity-normal) (-> self control transv)) + ) + ) + (set! (-> self control dynam gravity-max) (-> self control unknown-dynamics00 gravity-max)) + (set! (-> self control dynam gravity-length) (-> self control unknown-dynamics00 gravity-length)) ) - ) - (set! - (-> self control dynam gravity-max) - (-> self control unknown-dynamics00 gravity-max) - ) - (set! - (-> self control dynam gravity-length) - (-> self control unknown-dynamics00 gravity-length) - ) - ) - (when - (and - (= (-> self fact-info-target eco-type) 2) - (>= - (-> self fact-info-target eco-level) - (-> (new 'static 'array float 1 1.0) 0) + (when (and (= (-> self fact-info-target eco-type) 2) + (>= (-> self fact-info-target eco-level) (-> (new 'static 'array float 1 1.0) 0)) + ) + (dummy-10 (-> self skel effect) 'group-red-eco-spinkick (ja-frame-num 0) 70) + (cpad-set-buzz! (-> *cpad-list* cpads 0) 1 153 30) + (level-hint-spawn + (game-text-id red-eco-tutorial) + "sksp0072" + (the-as entity #f) + *entity-pool* + (game-task none) + ) ) - ) - (dummy-10 (-> self skel effect) 'group-red-eco-spinkick (ja-frame-num 0) 70) - (cpad-set-buzz! (-> *cpad-list* cpads 0) 1 153 30) - (level-hint-spawn - (game-text-id red-eco-tutorial) - "sksp0072" - (the-as entity #f) - *entity-pool* - (game-task none) - ) + (none) ) - (none) - ) :code (behavior ((arg0 symbol)) - (ja-channel-push! 1 22) - (let ((a0-2 (-> self skel root-channel 0))) - (set! - (-> a0-2 frame-group) - (the-as art-joint-anim (-> self draw art-group data 56)) - ) - (set! - (-> a0-2 param 0) - (the - float - (+ - (-> - (the-as art-joint-anim (-> self draw art-group data 56)) - data - 0 - length - ) - -1 - ) - ) - ) - (set! (-> a0-2 param 1) (-> (new 'static 'array float 1 1.0) 0)) - (set! (-> a0-2 frame-num) 0.0) - (joint-control-channel-group! - a0-2 - (the-as art-joint-anim (-> self draw art-group data 56)) - num-func-seek! - ) - ) - (until (ja-done? 0) - (TODO-RENAME-9 (-> self align)) - (TODO-RENAME-10 - (-> self align) - 16 - (-> (new 'static 'array float 1 1.0) 0) - (-> (new 'static 'array float 1 1.0) 0) - (-> (new 'static 'array float 1 1.0) 0) - ) - (suspend) - (let ((a0-5 (-> self skel root-channel 0))) - (set! - (-> a0-5 param 0) - (the float (+ (-> a0-5 frame-group data 0 length) -1)) - ) - (set! (-> a0-5 param 1) (-> (new 'static 'array float 1 1.0) 0)) - (joint-control-channel-group-eval! - a0-5 - (the-as art-joint-anim #f) - num-func-seek! - ) - ) - ) - (let ((gp-0 (-> self skel root-channel 0))) - (joint-control-channel-group-eval! - gp-0 - (the-as art-joint-anim (-> self draw art-group data 57)) - num-func-identity - ) - (set! (-> gp-0 frame-num) 0.0) - ) - (let ((f30-0 393216.0)) - (let ((f0-8 (target-height-above-ground)) - (f1-1 - (vector-dot - (-> self control dynam gravity-normal) - (-> self control transv) + (ja-channel-push! 1 22) + (let ((a0-2 (-> self skel root-channel 0))) + (set! (-> a0-2 frame-group) (the-as art-joint-anim (-> self draw art-group data 56))) + (set! (-> a0-2 param 0) + (the float (+ (-> (the-as art-joint-anim (-> self draw art-group data 56)) data 0 length) -1)) ) - ) - ) - (while - (not - (or - (and (< (fabs (/ f0-8 (* 0.0033333334 f1-1))) 150.0) (< f1-1 0.0)) - (>= (- (-> *display* base-frame-counter) (-> self state-time)) 510) - ) - ) - (quaternion-rotate-y! - (-> self control unknown-quaternion00) - (-> self control unknown-quaternion00) - (* f30-0 (-> *display* seconds-per-frame)) - ) - (suspend) - (let ((a0-10 (-> self skel root-channel 0))) - (set! (-> a0-10 param 0) (-> (new 'static 'array float 1 1.0) 0)) - (joint-control-channel-group-eval! - a0-10 - (the-as art-joint-anim #f) - num-func-loop! - ) - ) - (set! f0-8 (target-height-above-ground)) - (set! - f1-1 - (vector-dot - (-> self control dynam gravity-normal) - (-> self control transv) - ) - ) + (set! (-> a0-2 param 1) (-> (new 'static 'array float 1 1.0) 0)) + (set! (-> a0-2 frame-num) 0.0) + (joint-control-channel-group! a0-2 (the-as art-joint-anim (-> self draw art-group data 56)) num-func-seek!) ) - ) - (let ((a0-13 (-> self skel root-channel 0))) - (set! - (-> a0-13 frame-group) - (the-as art-joint-anim (-> self draw art-group data 58)) - ) - (set! - (-> a0-13 param 0) - (the - float - (+ - (-> - (the-as art-joint-anim (-> self draw art-group data 58)) - data - 0 - length - ) - -1 - ) - ) - ) - (set! (-> a0-13 param 1) (-> (new 'static 'array float 1 1.0) 0)) - (set! (-> a0-13 frame-num) 0.0) - (joint-control-channel-group! - a0-13 - (the-as art-joint-anim (-> self draw art-group data 58)) - num-func-seek! - ) - ) (until (ja-done? 0) - (cond - ((< (ja-aframe-num 0) 32.0) - (quaternion-rotate-y! - (-> self control unknown-quaternion00) - (-> self control unknown-quaternion00) - (* f30-0 (-> *display* seconds-per-frame)) + (TODO-RENAME-9 (-> self align)) + (TODO-RENAME-10 + (-> self align) + 16 + (-> (new 'static 'array float 1 1.0) 0) + (-> (new 'static 'array float 1 1.0) 0) + (-> (new 'static 'array float 1 1.0) 0) ) - ) - (else - (let - ((f0-22 - (deg-diff - (quaternion-y-angle (-> self control unknown-quaternion00)) - (quaternion-y-angle (-> self control dir-targ)) - ) - ) - ) - (quaternion-rotate-y! - (-> self control unknown-quaternion00) - (-> self control unknown-quaternion00) - (* 0.2 (fabs f0-22)) - ) + (suspend) + (let ((a0-5 (-> self skel root-channel 0))) + (set! (-> a0-5 param 0) (the float (+ (-> a0-5 frame-group data 0 length) -1))) + (set! (-> a0-5 param 1) (-> (new 'static 'array float 1 1.0) 0)) + (joint-control-channel-group-eval! a0-5 (the-as art-joint-anim #f) num-func-seek!) ) - ) ) - (suspend) - (let ((a0-20 (-> self skel root-channel 0))) - (set! - (-> a0-20 param 0) - (the float (+ (-> a0-20 frame-group data 0 length) -1)) - ) - (set! (-> a0-20 param 1) (-> (new 'static 'array float 1 1.0) 0)) + (let ((gp-0 (-> self skel root-channel 0))) (joint-control-channel-group-eval! - a0-20 - (the-as art-joint-anim #f) - num-func-seek! - ) + gp-0 + (the-as art-joint-anim (-> self draw art-group data 57)) + num-func-identity + ) + (set! (-> gp-0 frame-num) 0.0) ) - ) + (let ((f30-0 393216.0)) + (let ((f0-8 (target-height-above-ground)) + (f1-1 (vector-dot (-> self control dynam gravity-normal) (-> self control transv))) + ) + (while (not + (or (and (< (fabs (/ f0-8 (* 0.0033333334 f1-1))) 150.0) (< f1-1 0.0)) + (>= (- (-> *display* base-frame-counter) (-> self state-time)) 510) + ) + ) + (quaternion-rotate-y! + (-> self control unknown-quaternion00) + (-> self control unknown-quaternion00) + (* f30-0 (-> *display* seconds-per-frame)) + ) + (suspend) + (let ((a0-10 (-> self skel root-channel 0))) + (set! (-> a0-10 param 0) (-> (new 'static 'array float 1 1.0) 0)) + (joint-control-channel-group-eval! a0-10 (the-as art-joint-anim #f) num-func-loop!) + ) + (set! f0-8 (target-height-above-ground)) + (set! f1-1 (vector-dot (-> self control dynam gravity-normal) (-> self control transv))) + ) + ) + (let ((a0-13 (-> self skel root-channel 0))) + (set! (-> a0-13 frame-group) (the-as art-joint-anim (-> self draw art-group data 58))) + (set! (-> a0-13 param 0) + (the float (+ (-> (the-as art-joint-anim (-> self draw art-group data 58)) data 0 length) -1)) + ) + (set! (-> a0-13 param 1) (-> (new 'static 'array float 1 1.0) 0)) + (set! (-> a0-13 frame-num) 0.0) + (joint-control-channel-group! a0-13 (the-as art-joint-anim (-> self draw art-group data 58)) num-func-seek!) + ) + (until (ja-done? 0) + (cond + ((< (ja-aframe-num 0) 32.0) + (quaternion-rotate-y! + (-> self control unknown-quaternion00) + (-> self control unknown-quaternion00) + (* f30-0 (-> *display* seconds-per-frame)) + ) + ) + (else + (let ((f0-22 + (deg-diff + (quaternion-y-angle (-> self control unknown-quaternion00)) + (quaternion-y-angle (-> self control dir-targ)) + ) + ) + ) + (quaternion-rotate-y! + (-> self control unknown-quaternion00) + (-> self control unknown-quaternion00) + (* 0.2 (fabs f0-22)) + ) + ) + ) + ) + (suspend) + (let ((a0-20 (-> self skel root-channel 0))) + (set! (-> a0-20 param 0) (the float (+ (-> a0-20 frame-group data 0 length) -1))) + (set! (-> a0-20 param 1) (-> (new 'static 'array float 1 1.0) 0)) + (joint-control-channel-group-eval! a0-20 (the-as art-joint-anim #f) num-func-seek!) + ) + ) + ) + (go target-falling #f) + (none) ) - (go target-falling #f) - (none) - ) :post (the-as (function none :behavior target) target-post) ) +;; failed to figure out what this is: (defstate target-attack-uppercut (target) :event target-dangerous-event-handler :enter (behavior ((arg0 float) (arg1 float)) - (set! (-> self state-time) (-> *display* base-frame-counter)) - (target-start-attack) - (target-danger-set! 'uppercut #f) - (set! (-> self control unknown-surface00) *turn-around-mods*) - (none) - ) + (set! (-> self state-time) (-> *display* base-frame-counter)) + (target-start-attack) + (target-danger-set! 'uppercut #f) + (set! (-> self control unknown-surface00) *turn-around-mods*) + (none) + ) :exit target-exit :code (behavior ((arg0 float) (arg1 float)) - (let ((s3-0 (= (if (> (-> self skel active-channels) 0) - (-> self skel root-channel 0 frame-group) + (let ((s3-0 (= (if (> (-> self skel active-channels) 0) + (-> self skel root-channel 0 frame-group) + ) + (-> self draw art-group data 31) ) - (-> self draw art-group data 31) ) + (s4-0 (-> self skel root-channel 0)) ) - (s4-0 (-> self skel root-channel 0)) - ) - (set! - (-> s4-0 frame-group) - (the-as art-joint-anim (-> self draw art-group data 62)) - ) - (set! (-> s4-0 param 0) (ja-aframe (the-as float 7.0) 0)) - (set! (-> s4-0 param 1) (-> (new 'static 'array float 1 1.0) 0)) - (set! (-> s4-0 frame-num) (if s3-0 - (ja-aframe (the-as float 5.0) 0) - (-> (new 'static 'array float 1 0.0) 0) - ) - ) - (joint-control-channel-group! - s4-0 - (the-as art-joint-anim (-> self draw art-group data 62)) - num-func-seek! - ) - ) - (until (ja-done? 0) - (suspend) - (let ((s4-1 (-> self skel root-channel 0))) - (set! (-> s4-1 param 0) (ja-aframe (the-as float 7.0) 0)) - (set! (-> s4-1 param 1) (-> (new 'static 'array float 1 1.0) 0)) - (joint-control-channel-group-eval! - s4-1 - (the-as art-joint-anim #f) - num-func-seek! + (set! (-> s4-0 frame-group) (the-as art-joint-anim (-> self draw art-group data 62))) + (set! (-> s4-0 param 0) (ja-aframe (the-as float 7.0) 0)) + (set! (-> s4-0 param 1) (-> (new 'static 'array float 1 1.0) 0)) + (set! (-> s4-0 frame-num) (if s3-0 + (ja-aframe (the-as float 5.0) 0) + (-> (new 'static 'array float 1 0.0) 0) + ) + ) + (joint-control-channel-group! s4-0 (the-as art-joint-anim (-> self draw art-group data 62)) num-func-seek!) ) - ) + (until (ja-done? 0) + (suspend) + (let ((s4-1 (-> self skel root-channel 0))) + (set! (-> s4-1 param 0) (ja-aframe (the-as float 7.0) 0)) + (set! (-> s4-1 param 1) (-> (new 'static 'array float 1 1.0) 0)) + (joint-control-channel-group-eval! s4-1 (the-as art-joint-anim #f) num-func-seek!) + ) + ) + (go target-attack-uppercut-jump arg0 arg1) + (none) ) - (go target-attack-uppercut-jump arg0 arg1) - (none) - ) :post (the-as (function none :behavior target) target-post) ) +;; failed to figure out what this is: (defstate target-attack-uppercut-jump (target) :event target-dangerous-event-handler :enter (behavior ((arg0 float) (arg1 float)) - (if - (and - (= (-> self control ground-pat material) (pat-material ice)) - (< 32768.0 (-> self control unknown-float01)) - ) - (set-forward-vel (the-as float 32768.0)) + (if (and (= (-> self control ground-pat material) (pat-material ice)) + (< 32768.0 (-> self control unknown-float01)) + ) + (set-forward-vel (the-as float 32768.0)) + ) + (set! (-> self state-time) (-> *display* base-frame-counter)) + (init-var-jump arg0 arg1 (the-as vector #t) (the-as vector #f) (-> self control transv)) + (set! (-> self control status) (logand -8 (-> self control status))) + (set! (-> self control unknown-surface00) *uppercut-jump-mods*) + (target-start-attack) + (target-danger-set! 'uppercut #f) + (none) ) - (set! (-> self state-time) (-> *display* base-frame-counter)) - (init-var-jump - arg0 - arg1 - (the-as vector #t) - (the-as vector #f) - (-> self control transv) - ) - (set! (-> self control status) (logand -8 (-> self control status))) - (set! (-> self control unknown-surface00) *uppercut-jump-mods*) - (target-start-attack) - (target-danger-set! 'uppercut #f) - (none) - ) :exit target-exit :trans (behavior () - (if (logtest? (-> self control status) 1) - (go target-hit-ground #f) - ) - (when - (and - (logtest? - (-> - *cpad-list* - cpads - (-> self control unknown-cpad-info00 number) - button0-rel - 0 - ) - (pad-buttons square) - ) - (< - (vector-dot - (-> self control dynam gravity-normal) - (-> self control transv) - ) - 22118.4 - ) - (and - (< - -61440.0 - (vector-dot - (-> self control dynam gravity-normal) - (-> self control transv) + (if (logtest? (-> self control status) 1) + (go target-hit-ground #f) ) - ) - (>= - (- (-> *display* base-frame-counter) (-> self control unknown-dword36)) - (the-as int (-> *TARGET-bank* stuck-timeout)) - ) - (zero? (logand (-> self state-flags) 4096)) - (zero? (logand (-> self control unknown-surface01 flags) 384)) - ) - ) - (set-quaternion! (-> self control) (-> self control dir-targ)) - (build-conversions (-> self control transv)) - (go - target-flop - (the-as float 65502.96) - (the-as float -163840.0) - (the-as - float - (if - (= - (-> - *cpad-list* - cpads - (-> self control unknown-cpad-info00 number) - stick0-speed - ) - 0.0 + (when (and (logtest? (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) button0-rel 0) + (pad-buttons square) + ) + (< (vector-dot (-> self control dynam gravity-normal) (-> self control transv)) 22118.4) + (and (< -61440.0 (vector-dot (-> self control dynam gravity-normal) (-> self control transv))) + (>= (- (-> *display* base-frame-counter) (-> self control unknown-dword36)) + (the-as int (-> *TARGET-bank* stuck-timeout)) + ) + (zero? (logand (-> self state-flags) 4096)) + (zero? (logand (-> self control unknown-surface01 flags) 384)) + ) + ) + (set-quaternion! (-> self control) (-> self control dir-targ)) + (build-conversions (-> self control transv)) + (go + target-flop + (the-as float 65502.96) + (the-as float -163840.0) + (the-as float (if (= (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) stick0-speed) 0.0) + (-> (new 'static 'array float 1 0.0) 0) + 68812.8 + ) + ) ) - (-> (new 'static 'array float 1 0.0) 0) - 68812.8 - ) ) - ) + (if (and (logtest? (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) button0-rel 0) + (pad-buttons circle) + ) + (can-feet?) + (= (if (> (-> self skel active-channels) 0) + (-> self skel root-channel 0 frame-group) + ) + (-> self draw art-group data 62) + ) + (>= (ja-aframe-num 0) 12.0) + ) + (go target-attack-air 'uppercut) + ) + (mod-var-jump + #t + #t + (logtest? (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) button0-abs 0) (pad-buttons x)) + (-> self control transv) + ) + (when (and (= (-> self fact-info-target eco-type) 2) + (>= (-> self fact-info-target eco-level) (-> (new 'static 'array float 1 1.0) 0)) + ) + (dummy-10 (-> self skel effect) 'group-red-eco-spinkick (ja-frame-num 0) 23) + (cpad-set-buzz! (-> *cpad-list* cpads 0) 1 153 30) + ) + (if (and (= (-> self control unknown-symbol30) 'uppercut) + (< (vector-dot (-> self control dynam gravity-normal) (-> self control transv)) -8192.0) + ) + (target-danger-set! 'harmless #f) + ) + (slide-down-test) + (none) ) - (if - (and - (logtest? - (-> - *cpad-list* - cpads - (-> self control unknown-cpad-info00 number) - button0-rel - 0 - ) - (pad-buttons circle) - ) - (can-feet?) - (= (if (> (-> self skel active-channels) 0) - (-> self skel root-channel 0 frame-group) - ) - (-> self draw art-group data 62) - ) - (>= (ja-aframe-num 0) 12.0) - ) - (go target-attack-air 'uppercut) - ) - (mod-var-jump - #t - #t - (logtest? - (-> - *cpad-list* - cpads - (-> self control unknown-cpad-info00 number) - button0-abs - 0 - ) - (pad-buttons x) - ) - (-> self control transv) - ) - (when - (and - (= (-> self fact-info-target eco-type) 2) - (>= - (-> self fact-info-target eco-level) - (-> (new 'static 'array float 1 1.0) 0) - ) - ) - (dummy-10 (-> self skel effect) 'group-red-eco-spinkick (ja-frame-num 0) 23) - (cpad-set-buzz! (-> *cpad-list* cpads 0) 1 153 30) - ) - (if - (and - (= (-> self control unknown-symbol30) 'uppercut) - (< - (vector-dot - (-> self control dynam gravity-normal) - (-> self control transv) - ) - -8192.0 - ) - ) - (target-danger-set! 'harmless #f) - ) - (slide-down-test) - (none) - ) :code (behavior ((arg0 float) (arg1 float)) - (TODO-RENAME-9 (-> self align)) - (until (ja-done? 0) - (suspend) - (let ((a0-2 (-> self skel root-channel 0))) - (set! - (-> a0-2 param 0) - (the float (+ (-> a0-2 frame-group data 0 length) -1)) - ) - (set! (-> a0-2 param 1) 0.9) - (joint-control-channel-group-eval! - a0-2 - (the-as art-joint-anim #f) - num-func-seek! - ) - ) (TODO-RENAME-9 (-> self align)) - (let* ((gp-0 (-> self align)) - (s5-0 (method-of-object gp-0 TODO-RENAME-10)) - (a1-2 (cond - ((>= 30.0 (ja-aframe-num 0)) - 18 + (until (ja-done? 0) + (suspend) + (let ((a0-2 (-> self skel root-channel 0))) + (set! (-> a0-2 param 0) (the float (+ (-> a0-2 frame-group data 0 length) -1))) + (set! (-> a0-2 param 1) 0.9) + (joint-control-channel-group-eval! a0-2 (the-as art-joint-anim #f) num-func-seek!) + ) + (TODO-RENAME-9 (-> self align)) + (let* ((gp-0 (-> self align)) + (s5-0 (method-of-object gp-0 TODO-RENAME-10)) + (a1-2 (cond + ((>= 30.0 (ja-aframe-num 0)) + 18 + ) + ((>= 43.0 (ja-aframe-num 0)) + (set! (-> self control unknown-surface00) *double-jump-mods*) + 2 + ) + (else + 0 + ) + ) ) - ((>= 43.0 (ja-aframe-num 0)) - (set! (-> self control unknown-surface00) *double-jump-mods*) - 2 - ) - (else - 0 - ) - ) - ) - ) - (s5-0 - gp-0 - a1-2 - (-> (new 'static 'array float 1 1.0) 0) - (the-as float 0.95) - (-> (new 'static 'array float 1 1.0) 0) + ) + (s5-0 + gp-0 + a1-2 + (-> (new 'static 'array float 1 1.0) 0) + (the-as float 0.95) + (-> (new 'static 'array float 1 1.0) 0) + ) + ) ) - ) + (go target-falling #f) + (none) ) - (go target-falling #f) - (none) - ) :post (the-as (function none :behavior target) target-post) ) +;; failed to figure out what this is: (defstate target-flop (target) :event (behavior ((arg0 process) (arg1 int) (arg2 symbol) (arg3 event-message-block)) - (let ((v0-0 (target-bonk-event-handler arg0 arg1 arg2 arg3))) - (cond - (v0-0 - (empty) - v0-0 - ) - ((let ((v1-0 arg2)) - (= v1-0 'swim) - ) + (let ((v0-0 (target-bonk-event-handler arg0 arg1 arg2 arg3))) (cond - ((< 6144.0 (target-height-above-ground)) - (dummy-10 - (-> self skel effect) - 'swim-flop - (-> (new 'static 'array float 1 -1.0) 0) - -1 - ) - (let ((t9-3 enter-state)) - (set! (-> self next-state) target-swim-down) - ((the-as (function object :behavior target) t9-3)) - ) - ) - (else - (let ((t9-4 enter-state) - (a0-4 'swim) + (v0-0 + (empty) + v0-0 + ) + ((let ((v1-0 arg2)) + (= v1-0 'swim) + ) + (cond + ((< 6144.0 (target-height-above-ground)) + (dummy-10 (-> self skel effect) 'swim-flop (-> (new 'static 'array float 1 -1.0) 0) -1) + (let ((t9-3 enter-state)) + (set! (-> self next-state) target-swim-down) + ((the-as (function object :behavior target) t9-3)) ) - (set! (-> self next-state) target-flop-hit-ground) - ((the-as (function symbol object :behavior target) t9-4) a0-4) + ) + (else + (let ((t9-4 enter-state) + (a0-4 'swim) + ) + (set! (-> self next-state) target-flop-hit-ground) + ((the-as (function symbol object :behavior target) t9-4) a0-4) + ) + ) + ) ) + (else + (target-dangerous-event-handler arg0 arg1 arg2 arg3) + ) ) - ) ) - (else - (target-dangerous-event-handler arg0 arg1 arg2 arg3) - ) - ) ) - ) :enter (behavior ((arg0 float) (arg1 float) (arg2 float)) - (if - (and - (= (-> self fact-info-target eco-type) 1) - (>= - (-> self fact-info-target eco-level) - (-> (new 'static 'array float 1 1.0) 0) - ) - ) - (go target-yellow-jump-blast) - ) - (if (= arg2 0.0) - (set-forward-vel arg2) - (set-forward-vel (-> self control unknown-float01)) - ) - (set! (-> self state-time) (-> *display* base-frame-counter)) - (set! (-> self control status) (logand -8 (-> self control status))) - (set! (-> self control unknown-surface00) *flop-mods*) - (set! (-> self control unknown-uint20) (the-as uint 0)) - (set! (-> self control dynam gravity-max) 245760.0) - (set! (-> self control dynam gravity-length) 245760.0) - (let ((gp-1 (new-stack-vector0))) - (let - ((f0-6 - (vector-dot - (-> self control dynam gravity-normal) - (-> self control transv) + (if (and (= (-> self fact-info-target eco-type) 1) + (>= (-> self fact-info-target eco-level) (-> (new 'static 'array float 1 1.0) 0)) + ) + (go target-yellow-jump-blast) + ) + (if (= arg2 0.0) + (set-forward-vel arg2) + (set-forward-vel (-> self control unknown-float01)) + ) + (set! (-> self state-time) (-> *display* base-frame-counter)) + (set! (-> self control status) (logand -8 (-> self control status))) + (set! (-> self control unknown-surface00) *flop-mods*) + (set! (-> self control unknown-uint20) (the-as uint 0)) + (set! (-> self control dynam gravity-max) 245760.0) + (set! (-> self control dynam gravity-length) 245760.0) + (let ((gp-1 (new-stack-vector0))) + (let ((f0-6 (vector-dot (-> self control dynam gravity-normal) (-> self control transv)))) + 0.0 + (vector-! gp-1 (-> self control transv) (vector-float*! gp-1 (-> self control dynam gravity-normal) f0-6)) + ) + (let* ((f0-7 (vector-length gp-1)) + (f1-3 f0-7) + (f2-0 29491.2) + ) + (vector+! + (-> self control transv) + (vector-float*! (-> self control transv) (-> self control dynam gravity-normal) f2-0) + (vector-float*! gp-1 gp-1 (/ f0-7 f1-3)) + ) ) - ) ) - 0.0 - (vector-! - gp-1 - (-> self control transv) - (vector-float*! gp-1 (-> self control dynam gravity-normal) f0-6) - ) - ) - (let* ((f0-7 (vector-length gp-1)) - (f1-3 f0-7) - (f2-0 29491.2) - ) - (vector+! - (-> self control transv) - (vector-float*! - (-> self control transv) - (-> self control dynam gravity-normal) - f2-0 - ) - (vector-float*! gp-1 gp-1 (/ f0-7 f1-3)) - ) - ) + (none) ) - (none) - ) :exit (behavior () - (target-danger-set! 'harmless #f) - (set! - (-> self control dynam gravity-max) - (-> self control unknown-dynamics00 gravity-max) + (target-danger-set! 'harmless #f) + (set! (-> self control dynam gravity-max) (-> self control unknown-dynamics00 gravity-max)) + (set! (-> self control dynam gravity-length) (-> self control unknown-dynamics00 gravity-length)) + (set! (-> self control dynam gravity quad) (-> self control unknown-dynamics00 gravity quad)) + (none) ) - (set! - (-> self control dynam gravity-length) - (-> self control unknown-dynamics00 gravity-length) - ) - (set! - (-> self control dynam gravity quad) - (-> self control unknown-dynamics00 gravity quad) - ) - (none) - ) :trans (behavior () - (delete-back-vel) - (let ((gp-1 (logtest? (-> self control status) 1))) - (when (and (not gp-1) (let ((v1-6 (if (> (-> self skel active-channels) 0) - (-> self skel root-channel 0 frame-group) - ) - ) - ) - (or - (= v1-6 (-> self draw art-group data 64)) - (= v1-6 (-> self draw art-group data 66)) - ) + (delete-back-vel) + (let ((gp-1 (logtest? (-> self control status) 1))) + (when (and (not gp-1) (let ((v1-6 (if (> (-> self skel active-channels) 0) + (-> self skel root-channel 0 frame-group) + ) + ) + ) + (or (= v1-6 (-> self draw art-group data 64)) (= v1-6 (-> self draw art-group data 66))) + ) + ) + (when (and (or (< (target-move-dist 30) 1638.4) + (and (logtest? (-> self control status) 8) (< 0.7 (-> self control poly-angle))) + ) + (zero? (logand (-> self control status) 32)) + (>= (-> self control unknown-uint20) (the-as uint 2)) + ) + (set! (-> self control unknown-dword36) (-> *display* base-frame-counter)) + (set! gp-1 'stuck) + ) + ) + (when gp-1 + (logior! (-> self control status) 1) + (when (and (= (-> self fact-info-target eco-type) 2) + (>= (-> self fact-info-target eco-level) (-> (new 'static 'array float 1 1.0) 0)) + ) + (cpad-set-buzz! (-> *cpad-list* cpads 0) 1 255 150) + (dummy-10 (-> self skel effect) 'group-red-eco-strike-ground (ja-frame-num 0) 0) + (let* ((s4-1 (get-process *default-dead-pool* touch-tracker #x4000)) + (s5-1 (when s4-1 + (let ((t9-6 (method-of-type touch-tracker activate))) + (t9-6 (the-as touch-tracker s4-1) self 'touch-tracker (the-as pointer #x70004000)) ) - ) - (when - (and - (or - (< (target-move-dist 30) 1638.4) - (and - (logtest? (-> self control status) 8) - (< 0.7 (-> self control poly-angle)) - ) - ) - (zero? (logand (-> self control status) 32)) - (>= (-> self control unknown-uint20) (the-as uint 2)) - ) - (set! (-> self control unknown-dword36) (-> *display* base-frame-counter)) - (set! gp-1 'stuck) - ) - ) - (when gp-1 - (logior! (-> self control status) 1) - (when - (and - (= (-> self fact-info-target eco-type) 2) - (>= - (-> self fact-info-target eco-level) - (-> (new 'static 'array float 1 1.0) 0) - ) - ) - (cpad-set-buzz! (-> *cpad-list* cpads 0) 1 255 150) - (dummy-10 - (-> self skel effect) - 'group-red-eco-strike-ground - (ja-frame-num 0) - 0 - ) - (let* ((s4-1 (get-process *default-dead-pool* touch-tracker #x4000)) - (s5-1 (when s4-1 - (let ((t9-6 (method-of-type touch-tracker activate))) - (t9-6 - (the-as touch-tracker s4-1) - self - 'touch-tracker - (the-as pointer #x70004000) + (run-now-in-process s4-1 touch-tracker-init (-> self control trans) 4096.0 30) + (-> s4-1 ppointer) + ) + ) + ) + (send-event (ppointer->process s5-1) 'event 'attack 'flop) + (send-event + (ppointer->process s5-1) + 'function + (lambda ((arg0 target)) (let ((f0-3 (seek + (-> arg0 control root-prim local-sphere w) + (the-as float 28672.0) + (* 286720.0 (-> *display* seconds-per-frame)) + ) + ) + ) + (set! (-> arg0 control root-prim local-sphere w) f0-3) + f0-3 + ) ) - ) - (run-now-in-process - s4-1 - touch-tracker-init - (-> self control trans) - 4096.0 - 30 - ) - (-> s4-1 ppointer) - ) ) - ) - (send-event (ppointer->process s5-1) 'event 'attack 'flop) - (send-event (ppointer->process s5-1) 'function (lambda ((arg0 target)) - (let - ((f0-3 - (seek - (-> - arg0 - control - root-prim - local-sphere - w - ) - (the-as - float - 28672.0 - ) - (* - 286720.0 - (-> - *display* - seconds-per-frame - ) - ) - ) - ) - ) - (set! - (-> - arg0 - control - root-prim - local-sphere - w - ) - f0-3 - ) - f0-3 - ) - ) + ) + ) + (go target-flop-hit-ground gp-1) ) - ) ) - (go target-flop-hit-ground gp-1) - ) + (when (and (= (-> self fact-info-target eco-type) 2) + (>= (-> self fact-info-target eco-level) (-> (new 'static 'array float 1 1.0) 0)) + ) + (dummy-10 + (-> self skel effect) + 'group-red-eco-spinkick + (ja-frame-num 0) + (if (rand-vu-percent? (the-as float 0.5)) + 23 + 17 + ) + ) + (cpad-set-buzz! (-> *cpad-list* cpads 0) 1 153 30) + ) + (when (and (not (-> self control unknown-symbol30)) + (= (if (> (-> self skel active-channels) 0) + (-> self skel root-channel 0 frame-group) + ) + (-> self draw art-group data 63) + ) + (>= (ja-aframe-num 0) 8.0) + ) + (target-start-attack) + (target-danger-set! 'flop #f) + ) + (none) ) - (when - (and - (= (-> self fact-info-target eco-type) 2) - (>= - (-> self fact-info-target eco-level) - (-> (new 'static 'array float 1 1.0) 0) - ) - ) - (dummy-10 - (-> self skel effect) - 'group-red-eco-spinkick - (ja-frame-num 0) - (if (rand-vu-percent? (the-as float 0.5)) - 23 - 17 - ) - ) - (cpad-set-buzz! (-> *cpad-list* cpads 0) 1 153 30) - ) - (when - (and - (not (-> self control unknown-symbol30)) - (= (if (> (-> self skel active-channels) 0) - (-> self skel root-channel 0 frame-group) - ) - (-> self draw art-group data 63) - ) - (>= (ja-aframe-num 0) 8.0) - ) - (target-start-attack) - (target-danger-set! 'flop #f) - ) - (none) - ) :code (behavior ((arg0 float) (arg1 float) (arg2 float)) - (ja-channel-set! 2) - (let ((a0-2 (-> self skel root-channel 0))) - (set! - (-> a0-2 frame-group) - (the-as art-joint-anim (-> self draw art-group data 63)) - ) - (set! - (-> a0-2 param 0) - (the - float - (+ - (-> - (the-as art-joint-anim (-> self draw art-group data 63)) - data - 0 - length - ) - -1 - ) - ) - ) - (set! (-> a0-2 param 1) (-> (new 'static 'array float 1 1.0) 0)) - (set! (-> a0-2 frame-num) 0.0) - (joint-control-channel-group! - a0-2 - (the-as art-joint-anim (-> self draw art-group data 63)) - num-func-seek! - ) - ) - (let ((a0-3 (-> self skel root-channel 1))) - (set! - (-> a0-3 frame-group) - (the-as art-joint-anim (-> self draw art-group data 66)) - ) - (set! (-> a0-3 param 0) 0.0) - (set! (-> a0-3 frame-num) 0.0) - (joint-control-channel-group-eval! - a0-3 - (the-as art-joint-anim (-> self draw art-group data 66)) - num-func-chan - ) - ) - (until (ja-done? 0) - (suspend) - (let ((a0-4 (-> self skel root-channel 0))) - (set! - (-> a0-4 param 0) - (the float (+ (-> a0-4 frame-group data 0 length) -1)) - ) - (set! (-> a0-4 param 1) (-> (new 'static 'array float 1 1.0) 0)) - (joint-control-channel-group-eval! - a0-4 - (the-as art-joint-anim #f) - num-func-seek! - ) - ) - (let ((gp-0 (-> self skel root-channel 1))) - (set! - (-> gp-0 frame-interp) - (lerp-scale - (-> (new 'static 'array float 1 0.0) 0) - (-> (new 'static 'array float 1 1.0) 0) - (-> self control unknown-float01) - (-> (new 'static 'array float 1 0.0) 0) - (the-as float 40960.0) - ) - ) - (set! - (-> gp-0 param 0) - (the float (+ (-> gp-0 frame-group data 0 length) -1)) - ) - (set! (-> gp-0 param 1) (-> (new 'static 'array float 1 1.0) 0)) - (joint-control-channel-group-eval! - gp-0 - (the-as art-joint-anim #f) - num-func-seek! - ) - ) - ) - (set! - (-> self control dynam gravity-length) - (-> self control unknown-dynamics00 gravity-length) - ) - (set! - (-> self control dynam gravity quad) - (-> self control unknown-dynamics00 gravity quad) - ) - (target-danger-set! 'flop-down #f) - (let ((gp-1 (-> self skel root-channel 0))) - (joint-control-channel-group-eval! - gp-1 - (the-as art-joint-anim (-> self draw art-group data 64)) - num-func-identity - ) - (set! (-> gp-1 frame-num) 0.0) - ) - (let ((gp-2 (-> self skel root-channel 1))) - (joint-control-channel-group-eval! - gp-2 - (the-as art-joint-anim (-> self draw art-group data 67)) - num-func-identity - ) - (set! (-> gp-2 frame-num) 0.0) - ) - (let ((f30-0 (-> (new 'static 'array float 1 1.0) 0))) - (let ((gp-3 (new-stack-vector0))) - (let - ((f0-18 - (vector-dot - (-> self control dynam gravity-normal) - (-> self control unknown-vector120) - ) - ) - ) - 0.0 - (vector-! - gp-3 - (-> self control unknown-vector120) - (vector-float*! gp-3 (-> self control dynam gravity-normal) f0-18) - ) - ) - (let* ((f0-19 (vector-length gp-3)) - (f1-1 f0-19) - (f2-0 -368640.0) + (ja-channel-set! 2) + (let ((a0-2 (-> self skel root-channel 0))) + (set! (-> a0-2 frame-group) (the-as art-joint-anim (-> self draw art-group data 63))) + (set! (-> a0-2 param 0) + (the float (+ (-> (the-as art-joint-anim (-> self draw art-group data 63)) data 0 length) -1)) ) - (vector+! - (-> self control unknown-vector120) - (vector-float*! - (-> self control unknown-vector120) - (-> self control dynam gravity-normal) - f2-0 - ) - (vector-float*! gp-3 gp-3 (/ f0-19 f1-1)) - ) + (set! (-> a0-2 param 1) (-> (new 'static 'array float 1 1.0) 0)) + (set! (-> a0-2 frame-num) 0.0) + (joint-control-channel-group! a0-2 (the-as art-joint-anim (-> self draw art-group data 63)) num-func-seek!) ) - ) - (let ((gp-4 (new-stack-vector0))) - (let - ((f0-22 - (vector-dot - (-> self control dynam gravity-normal) - (-> self control transv) - ) - ) - ) - 0.0 - (vector-! - gp-4 - (-> self control transv) - (vector-float*! gp-4 (-> self control dynam gravity-normal) f0-22) - ) - ) - (let* ((f0-23 (vector-length gp-4)) - (f1-3 f0-23) - (f2-2 (* -368640.0 f30-0)) - ) - (vector+! - (-> self control transv) - (vector-float*! - (-> self control transv) - (-> self control dynam gravity-normal) - f2-2 - ) - (vector-float*! gp-4 gp-4 (/ f0-23 f1-3)) - ) - ) - ) - (suspend) - (while #t - (+! (-> self control unknown-uint20) 1) - (let ((a0-30 (-> self skel root-channel 0))) - (set! (-> a0-30 param 0) (-> (new 'static 'array float 1 1.0) 0)) + (let ((a0-3 (-> self skel root-channel 1))) + (set! (-> a0-3 frame-group) (the-as art-joint-anim (-> self draw art-group data 66))) + (set! (-> a0-3 param 0) 0.0) + (set! (-> a0-3 frame-num) 0.0) (joint-control-channel-group-eval! - a0-30 - (the-as art-joint-anim #f) - num-func-+! - ) - ) - (let ((gp-5 (-> self skel root-channel 1))) - (set! - (-> gp-5 frame-interp) - (lerp-scale - (-> (new 'static 'array float 1 0.0) 0) - (-> (new 'static 'array float 1 1.0) 0) - (-> self control unknown-float01) - (-> (new 'static 'array float 1 0.0) 0) - (the-as float 40960.0) + a0-3 + (the-as art-joint-anim (-> self draw art-group data 66)) + num-func-chan ) - ) - (set! (-> gp-5 param 0) 0.0) + ) + (until (ja-done? 0) + (suspend) + (let ((a0-4 (-> self skel root-channel 0))) + (set! (-> a0-4 param 0) (the float (+ (-> a0-4 frame-group data 0 length) -1))) + (set! (-> a0-4 param 1) (-> (new 'static 'array float 1 1.0) 0)) + (joint-control-channel-group-eval! a0-4 (the-as art-joint-anim #f) num-func-seek!) + ) + (let ((gp-0 (-> self skel root-channel 1))) + (set! (-> gp-0 frame-interp) (lerp-scale + (-> (new 'static 'array float 1 0.0) 0) + (-> (new 'static 'array float 1 1.0) 0) + (-> self control unknown-float01) + (-> (new 'static 'array float 1 0.0) 0) + (the-as float 40960.0) + ) + ) + (set! (-> gp-0 param 0) (the float (+ (-> gp-0 frame-group data 0 length) -1))) + (set! (-> gp-0 param 1) (-> (new 'static 'array float 1 1.0) 0)) + (joint-control-channel-group-eval! gp-0 (the-as art-joint-anim #f) num-func-seek!) + ) + ) + (set! (-> self control dynam gravity-length) (-> self control unknown-dynamics00 gravity-length)) + (set! (-> self control dynam gravity quad) (-> self control unknown-dynamics00 gravity quad)) + (target-danger-set! 'flop-down #f) + (let ((gp-1 (-> self skel root-channel 0))) (joint-control-channel-group-eval! - gp-5 - (the-as art-joint-anim #f) - num-func-chan - ) - ) - (set! - f30-0 - (* - f30-0 - (fmin - (-> (new 'static 'array float 1 1.0) 0) - (-> self control unknown-float140) + gp-1 + (the-as art-joint-anim (-> self draw art-group data 64)) + num-func-identity ) - ) + (set! (-> gp-1 frame-num) 0.0) ) - (let ((gp-6 (new-stack-vector0)) - (f28-0 - (vector-dot - (-> self control dynam gravity-normal) - (-> self control transv) - ) + (let ((gp-2 (-> self skel root-channel 1))) + (joint-control-channel-group-eval! + gp-2 + (the-as art-joint-anim (-> self draw art-group data 67)) + num-func-identity + ) + (set! (-> gp-2 frame-num) 0.0) + ) + (let ((f30-0 (-> (new 'static 'array float 1 1.0) 0))) + (let ((gp-3 (new-stack-vector0))) + (let ((f0-18 (vector-dot (-> self control dynam gravity-normal) (-> self control unknown-vector120)))) + 0.0 + (vector-! + gp-3 + (-> self control unknown-vector120) + (vector-float*! gp-3 (-> self control dynam gravity-normal) f0-18) ) - ) - 0.0 - (vector-! - gp-6 - (-> self control transv) - (vector-float*! gp-6 (-> self control dynam gravity-normal) f28-0) - ) - (let* ((f1-5 (vector-length gp-6)) - (f0-34 f1-5) - ) - (if (< (-> self control unknown-surface01 transv-max) f1-5) - (set! f1-5 (-> self control unknown-surface01 transv-max)) + ) + (let* ((f0-19 (vector-length gp-3)) + (f1-1 f0-19) + (f2-0 -368640.0) + ) + (vector+! + (-> self control unknown-vector120) + (vector-float*! (-> self control unknown-vector120) (-> self control dynam gravity-normal) f2-0) + (vector-float*! gp-3 gp-3 (/ f0-19 f1-1)) + ) + ) ) - (vector+! - (-> self control transv) - (vector-float*! - (-> self control transv) - (-> self control dynam gravity-normal) - f28-0 - ) - (vector-float*! gp-6 gp-6 (/ f1-5 f0-34)) + (let ((gp-4 (new-stack-vector0))) + (let ((f0-22 (vector-dot (-> self control dynam gravity-normal) (-> self control transv)))) + 0.0 + (vector-! gp-4 (-> self control transv) (vector-float*! gp-4 (-> self control dynam gravity-normal) f0-22)) + ) + (let* ((f0-23 (vector-length gp-4)) + (f1-3 f0-23) + (f2-2 (* -368640.0 f30-0)) + ) + (vector+! + (-> self control transv) + (vector-float*! (-> self control transv) (-> self control dynam gravity-normal) f2-2) + (vector-float*! gp-4 gp-4 (/ f0-23 f1-3)) + ) + ) ) - ) - ) - (if - (>= - (- (-> *display* base-frame-counter) (-> self state-time)) - (the-as int (-> *TARGET-bank* fall-timeout)) - ) - (go target-falling #f) - ) - (if - (and - (= *cheat-mode* 'debug) - (logtest? - (-> - *cpad-list* - cpads - (-> self control unknown-cpad-info00 number) - button0-abs - 0 - ) - (pad-buttons r2) + (suspend) + (while #t + (+! (-> self control unknown-uint20) 1) + (let ((a0-30 (-> self skel root-channel 0))) + (set! (-> a0-30 param 0) (-> (new 'static 'array float 1 1.0) 0)) + (joint-control-channel-group-eval! a0-30 (the-as art-joint-anim #f) num-func-+!) + ) + (let ((gp-5 (-> self skel root-channel 1))) + (set! (-> gp-5 frame-interp) (lerp-scale + (-> (new 'static 'array float 1 0.0) 0) + (-> (new 'static 'array float 1 1.0) 0) + (-> self control unknown-float01) + (-> (new 'static 'array float 1 0.0) 0) + (the-as float 40960.0) + ) + ) + (set! (-> gp-5 param 0) 0.0) + (joint-control-channel-group-eval! gp-5 (the-as art-joint-anim #f) num-func-chan) + ) + (set! f30-0 (* f30-0 (fmin (-> (new 'static 'array float 1 1.0) 0) (-> self control unknown-float140)))) + (let ((gp-6 (new-stack-vector0)) + (f28-0 (vector-dot (-> self control dynam gravity-normal) (-> self control transv))) + ) + 0.0 + (vector-! gp-6 (-> self control transv) (vector-float*! gp-6 (-> self control dynam gravity-normal) f28-0)) + (let* ((f1-5 (vector-length gp-6)) + (f0-34 f1-5) + ) + (if (< (-> self control unknown-surface01 transv-max) f1-5) + (set! f1-5 (-> self control unknown-surface01 transv-max)) + ) + (vector+! + (-> self control transv) + (vector-float*! (-> self control transv) (-> self control dynam gravity-normal) f28-0) + (vector-float*! gp-6 gp-6 (/ f1-5 f0-34)) + ) + ) + ) + (if (>= (- (-> *display* base-frame-counter) (-> self state-time)) (the-as int (-> *TARGET-bank* fall-timeout))) + (go target-falling #f) + ) + (if (and (= *cheat-mode* 'debug) + (logtest? (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) button0-abs 0) (pad-buttons r2)) + (not *pause-lock*) + ) + (go target-falling #f) + ) + (suspend) ) - (not *pause-lock*) - ) - (go target-falling #f) ) - (suspend) - ) + (none) ) - (none) - ) :post (the-as (function none :behavior target) target-post) ) +;; failed to figure out what this is: (defstate target-flop-hit-ground (target) :event (behavior ((arg0 process) (arg1 int) (arg2 symbol) (arg3 event-message-block)) - (case arg2 - (('swim) - #f + (case arg2 + (('swim) + #f + ) + (else + (target-standard-event-handler arg0 arg1 arg2 arg3) + ) ) - (else - (target-standard-event-handler arg0 arg1 arg2 arg3) - ) ) - ) :enter (behavior ((arg0 symbol)) - (let - ((f0-1 - (vector-dot - (-> self control dynam gravity-normal) - (vector-! - (new 'stack-no-clear 'vector) - (-> self control unknown-vector111) - (-> self control trans) - ) - ) + (let ((f0-1 (vector-dot + (-> self control dynam gravity-normal) + (vector-! (new 'stack-no-clear 'vector) (-> self control unknown-vector111) (-> self control trans)) + ) + ) + ) + (if (< (-> *TARGET-bank* fall-far) f0-1) + (go target-hit-ground-hard f0-1) + ) ) - ) - (if (< (-> *TARGET-bank* fall-far) f0-1) - (go target-hit-ground-hard f0-1) - ) + (target-land-effect) + (cpad-set-buzz! (-> *cpad-list* cpads 0) 1 255 30) + (set! (-> self state-time) (-> *display* base-frame-counter)) + (set! (-> self control unknown-uint20) (the-as uint arg0)) + (set-forward-vel (-> (new 'static 'array float 1 0.0) 0)) + (set! (-> self control unknown-surface00) *flop-land-mods*) + (set! (-> *flop-land-mods* flags) (logand -1025 (-> *flop-land-mods* flags))) + (set! (-> self state-flags) (logior #x100000 (-> self state-flags))) + (none) ) - (target-land-effect) - (cpad-set-buzz! (-> *cpad-list* cpads 0) 1 255 30) - (set! (-> self state-time) (-> *display* base-frame-counter)) - (set! (-> self control unknown-uint20) (the-as uint arg0)) - (set-forward-vel (-> (new 'static 'array float 1 0.0) 0)) - (set! (-> self control unknown-surface00) *flop-land-mods*) - (set! (-> *flop-land-mods* flags) (logand -1025 (-> *flop-land-mods* flags))) - (set! (-> self state-flags) (logior #x100000 (-> self state-flags))) - (none) - ) :exit target-exit :trans (behavior () - (when (!= (-> self control unknown-spoolanim00) 'stuck) - (if - (and - (logtest? - (-> - *cpad-list* - cpads - (-> self control unknown-cpad-info00 number) - button0-rel - 0 + (when (!= (-> self control unknown-spoolanim00) 'stuck) + (if (and (logtest? (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) button0-rel 0) + (pad-buttons circle) + ) + (can-feet?) + ) + (go target-attack-air 'flop) + ) + ) + (when (and (and (= (-> self fact-info-target eco-type) 2) + (>= (-> self fact-info-target eco-level) (-> (new 'static 'array float 1 1.0) 0)) + ) + (< (- (-> *display* base-frame-counter) (-> self state-time)) 75) + ) + (dummy-10 + (-> self skel effect) + 'group-red-eco-spinkick + (ja-frame-num 0) + (if (rand-vu-percent? (the-as float 0.5)) + 23 + 17 + ) ) - (pad-buttons circle) - ) - (can-feet?) + (cpad-set-buzz! (-> *cpad-list* cpads 0) 1 153 30) ) - (go target-attack-air 'flop) - ) - ) - (when - (and - (and - (= (-> self fact-info-target eco-type) 2) - (>= - (-> self fact-info-target eco-level) - (-> (new 'static 'array float 1 1.0) 0) - ) - ) - (< (- (-> *display* base-frame-counter) (-> self state-time)) 75) - ) - (dummy-10 - (-> self skel effect) - 'group-red-eco-spinkick - (ja-frame-num 0) - (if (rand-vu-percent? (the-as float 0.5)) - 23 - 17 - ) - ) - (cpad-set-buzz! (-> *cpad-list* cpads 0) 1 153 30) - ) - (let ((v1-33 (if (> (-> self skel active-channels) 0) - (-> self skel root-channel 0 frame-group) + (let ((v1-33 (if (> (-> self skel active-channels) 0) + (-> self skel root-channel 0 frame-group) + ) ) ) - ) - (if - (and - (or - (= v1-33 (-> self draw art-group data 65)) - (= v1-33 (-> self draw art-group data 68)) - ) - (>= (ja-aframe-num 0) 28.0) + (if (and (or (= v1-33 (-> self draw art-group data 65)) (= v1-33 (-> self draw art-group data 68))) + (>= (ja-aframe-num 0) 28.0) + ) + (logior! (-> *flop-land-mods* flags) 1024) + ) ) - (logior! (-> *flop-land-mods* flags) 1024) - ) + (slide-down-test) + (none) ) - (slide-down-test) - (none) - ) :code (behavior ((arg0 symbol)) - (target-hit-ground-anim arg0) - (go target-falling #f) - (none) - ) + (target-hit-ground-anim arg0) + (go target-falling #f) + (none) + ) :post (the-as (function none :behavior target) target-post) ) +;; failed to figure out what this is: (defstate target-wheel (target) :event (behavior ((arg0 process) (arg1 int) (arg2 symbol) (arg3 event-message-block)) - (if (= arg2 'touched) - (send-event arg0 'roll) + (if (= arg2 'touched) + (send-event arg0 'roll) + ) + (target-standard-event-handler arg0 arg1 arg2 arg3) ) - (target-standard-event-handler arg0 arg1 arg2 arg3) - ) :enter (behavior () - (set! (-> self state-time) (-> *display* base-frame-counter)) - (set! (-> self control unknown-surface00) *wheel-mods*) - (+! (-> self control unknown-int50) 1) - (rot->dir-targ! (-> self control)) - (set-forward-vel - (+ - (-> *TARGET-bank* wheel-speed-min) - (* - (-> *TARGET-bank* wheel-speed-inc) - (the float (+ (-> self control unknown-int50) -1)) - ) - ) + (set! (-> self state-time) (-> *display* base-frame-counter)) + (set! (-> self control unknown-surface00) *wheel-mods*) + (+! (-> self control unknown-int50) 1) + (rot->dir-targ! (-> self control)) + (set-forward-vel (+ (-> *TARGET-bank* wheel-speed-min) + (* (-> *TARGET-bank* wheel-speed-inc) (the float (+ (-> self control unknown-int50) -1))) + ) + ) + (if (or (< (fabs (-> self control unknown-float62)) 0.3) (< 0.3 (fabs (-> self control unknown-float61)))) + (set! (-> self control unknown-float81) (-> (new 'static 'array float 1 1.0) 0)) + ) + (set! (-> self control unknown-uint20) (the-as uint 0)) + (set! (-> self control unknown-int21) 0) + 0 + (none) ) - (if - (or - (< (fabs (-> self control unknown-float62)) 0.3) - (< 0.3 (fabs (-> self control unknown-float61))) - ) - (set! - (-> self control unknown-float81) - (-> (new 'static 'array float 1 1.0) 0) - ) - ) - (set! (-> self control unknown-uint20) (the-as uint 0)) - (set! (-> self control unknown-int21) 0) - 0 - (none) - ) :exit (behavior () - (when (!= (-> self next-state name) 'target-wheel) - (set! (-> self control unknown-int50) 0) - (set! (-> self control unknown-dword30) (-> *display* base-frame-counter)) + (when (!= (-> self next-state name) 'target-wheel) + (set! (-> self control unknown-int50) 0) + (set! (-> self control unknown-dword30) (-> *display* base-frame-counter)) + ) + (target-exit) + (none) ) - (target-exit) - (none) - ) :code (behavior () - (let ((gp-0 0)) - 0 - (let ((s5-0 0) - (f30-0 (-> (new 'static 'array float 1 1.0) 0)) + (let ((gp-0 0)) + 0 + (let ((s5-0 0) + (f30-0 (-> (new 'static 'array float 1 1.0) 0)) + ) + (ja-channel-push! 1 12) + (let ((s4-0 (-> self skel root-channel 0))) + (joint-control-channel-group-eval! + s4-0 + (the-as art-joint-anim (-> self draw art-group data 69)) + num-func-identity + ) + (set! (-> s4-0 frame-num) 0.0) ) - (ja-channel-push! 1 12) - (let ((s4-0 (-> self skel root-channel 0))) - (joint-control-channel-group-eval! - s4-0 - (the-as art-joint-anim (-> self draw art-group data 69)) - num-func-identity - ) - (set! (-> s4-0 frame-num) 0.0) - ) - (until (ja-done? 0) - (if - (logtest? - (-> - *cpad-list* - cpads - (-> self control unknown-cpad-info00 number) - button0-rel - 0 - ) - (pad-buttons x) - ) - (set! gp-0 (-> *display* base-frame-counter)) - ) - (when - (and - (or (smack-surface? #f) (>= (-> self control unknown-float63) 0.7)) - (>= - (the-as - uint - (- - (-> *display* base-frame-counter) - (the-as int (-> self control unknown-uint20)) - ) + (until (ja-done? 0) + (if (logtest? (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) button0-rel 0) (pad-buttons x)) + (set! gp-0 (-> *display* base-frame-counter)) + ) + (when (and (or (smack-surface? #f) (>= (-> self control unknown-float63) 0.7)) + (>= (the-as uint (- (-> *display* base-frame-counter) (the-as int (-> self control unknown-uint20)))) + (the-as uint 3) + ) + (>= (- (-> *display* base-frame-counter) (-> self state-time)) 1) + ) + (if (>= 6.0 (ja-aframe-num 0)) + (target-shoved + (-> *TARGET-bank* smack-surface-dist) + (-> *TARGET-bank* smack-surface-height) + (the-as process #f) + target-hit + ) + ) + (if (zero? s5-0) + (set! s5-0 (-> *display* base-frame-counter)) + ) + ) + (if (logtest? (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) button0-rel 0) + (pad-buttons square) + ) + (-> *display* base-frame-counter) + ) + (TODO-RENAME-9 (-> self align)) + (cond + ((nonzero? s5-0) + ) + (else + (TODO-RENAME-10 + (-> self align) + 4 + (-> (new 'static 'array float 1 1.0) 0) + (-> (new 'static 'array float 1 1.0) 0) + f30-0 + ) + (let ((s4-1 (new-stack-vector0))) + (vector-matrix*! s4-1 (-> self control transv) (-> self control unknown-matrix00)) + (set! (-> s4-1 y) 0.0) + (vector-matrix*! (-> self control unknown-vector120) s4-1 (-> self control unknown-matrix01)) + ) + ) + ) + (suspend) + (let ((a0-15 (-> self skel root-channel 0))) + (set! (-> a0-15 param 0) (the float (+ (-> a0-15 frame-group data 0 length) -1))) + (set! (-> a0-15 param 1) (-> (new 'static 'array float 1 1.0) 0)) + (joint-control-channel-group-eval! a0-15 (the-as art-joint-anim #f) num-func-seek!) + ) + (set! f30-0 (* f30-0 (fmin (-> (new 'static 'array float 1 1.0) 0) (-> self control unknown-float140)))) ) - (the-as uint 3) - ) - (>= (- (-> *display* base-frame-counter) (-> self state-time)) 1) ) - (if (>= 6.0 (ja-aframe-num 0)) - (target-shoved - (-> *TARGET-bank* smack-surface-dist) - (-> *TARGET-bank* smack-surface-height) - (the-as process #f) - (the-as (state target) target-hit) - ) - ) - (if (zero? s5-0) - (set! s5-0 (-> *display* base-frame-counter)) - ) - ) - (if - (logtest? - (-> - *cpad-list* - cpads - (-> self control unknown-cpad-info00 number) - button0-rel - 0 - ) - (pad-buttons square) - ) - (-> *display* base-frame-counter) - ) - (TODO-RENAME-9 (-> self align)) - (cond - ((nonzero? s5-0) - ) - (else - (TODO-RENAME-10 - (-> self align) - 4 - (-> (new 'static 'array float 1 1.0) 0) - (-> (new 'static 'array float 1 1.0) 0) - f30-0 - ) - (let ((s4-1 (new-stack-vector0))) - (vector-matrix*! - s4-1 - (-> self control transv) - (-> self control unknown-matrix00) + (if (and (or (< (- (-> *display* base-frame-counter) gp-0) (the-as int (-> *TARGET-bank* wheel-jump-pre-window))) + (logtest? (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) button0-rel 0) (pad-buttons x)) + ) + (can-jump? 'target-wheel-flip) + ) + (go target-wheel-flip (-> *TARGET-bank* wheel-flip-height) (-> *TARGET-bank* wheel-flip-dist)) ) - (set! (-> s4-1 y) 0.0) - (vector-matrix*! - (-> self control unknown-vector120) - s4-1 - (-> self control unknown-matrix01) + ) + (set! (-> self state-hook-time) (the-as uint (-> *display* base-frame-counter))) + (set! (-> self state-hook) + (lambda :behavior target + () + (cond + ((>= (- (-> *display* base-frame-counter) (the-as int (-> self state-hook-time))) + (the-as int (-> *TARGET-bank* wheel-jump-post-window)) + ) + (set! (-> self state-hook) (the-as (function none :behavior target) nothing)) + ) + (else + (if (and (logtest? (logior (logior (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) button0-rel 0) + (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) button0-rel 1) + ) + (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) button0-rel 2) + ) + (pad-buttons x) + ) + (can-jump? 'target-wheel-flip) + ) + (go target-wheel-flip (-> *TARGET-bank* wheel-flip-height) (-> *TARGET-bank* wheel-flip-dist)) + ) + ) + ) + (none) + ) ) - ) - ) - ) - (suspend) - (let ((a0-15 (-> self skel root-channel 0))) - (set! - (-> a0-15 param 0) - (the float (+ (-> a0-15 frame-group data 0 length) -1)) - ) - (set! (-> a0-15 param 1) (-> (new 'static 'array float 1 1.0) 0)) - (joint-control-channel-group-eval! - a0-15 - (the-as art-joint-anim #f) - num-func-seek! - ) - ) - (set! - f30-0 - (* - f30-0 - (fmin - (-> (new 'static 'array float 1 1.0) 0) - (-> self control unknown-float140) - ) - ) - ) - ) - ) - (if - (and - (or - (< - (- (-> *display* base-frame-counter) gp-0) - (the-as int (-> *TARGET-bank* wheel-jump-pre-window)) - ) - (logtest? - (-> - *cpad-list* - cpads - (-> self control unknown-cpad-info00 number) - button0-rel - 0 - ) - (pad-buttons x) - ) - ) - (can-jump? 'target-wheel-flip) - ) - (go - target-wheel-flip - (-> *TARGET-bank* wheel-flip-height) - (-> *TARGET-bank* wheel-flip-dist) - ) - ) + (go target-duck-stance) + (none) ) - (set! - (-> self state-hook-time) - (the-as uint (-> *display* base-frame-counter)) - ) - (set! (-> self state-hook) (lambda :behavior target () (cond - ((>= - (- - (-> - *display* - base-frame-counter - ) - (the-as - int - (-> - self - state-hook-time - ) - ) - ) - (the-as - int - (-> - *TARGET-bank* - wheel-jump-post-window - ) - ) - ) - (set! - (-> - self - state-hook - ) - (the-as - (function none :behavior target) - nothing - ) - ) - ) - (else - (if - (and - (logtest? - (logior - (logior - (-> - *cpad-list* - cpads - (-> - self - control - unknown-cpad-info00 - number - ) - button0-rel - 0 - ) - (-> - *cpad-list* - cpads - (-> - self - control - unknown-cpad-info00 - number - ) - button0-rel - 1 - ) - ) - (-> - *cpad-list* - cpads - (-> - self - control - unknown-cpad-info00 - number - ) - button0-rel - 2 - ) - ) - (pad-buttons x) - ) - (can-jump? - 'target-wheel-flip - ) - ) - (go - target-wheel-flip - (-> - *TARGET-bank* - wheel-flip-height - ) - (-> - *TARGET-bank* - wheel-flip-dist - ) - ) - ) - ) - ) - (none) - ) - ) - (go target-duck-stance) - (none) - ) :post (the-as (function none :behavior target) target-post) ) +;; failed to figure out what this is: (defstate target-wheel-flip (target) :event target-standard-event-handler :enter (behavior ((arg0 float) (arg1 float)) - (set! (-> self control unknown-surface00) *wheel-flip-mods*) - (none) - ) + (set! (-> self control unknown-surface00) *wheel-flip-mods*) + (none) + ) :exit target-exit :trans (behavior () - (if - (and - (or - (smack-surface? #f) - (< - (target-move-dist (the-as int (-> *TARGET-bank* stuck-time))) - (-> *TARGET-bank* stuck-distance) - ) - ) - (!= (-> self state-time) (-> *display* base-frame-counter)) - ) - (target-shoved - (-> *TARGET-bank* smack-surface-dist) - (-> *TARGET-bank* smack-surface-height) - (the-as process #f) - (the-as (state target) target-hit) - ) + (if (and (or (smack-surface? #f) + (< (target-move-dist (the-as int (-> *TARGET-bank* stuck-time))) (-> *TARGET-bank* stuck-distance)) + ) + (!= (-> self state-time) (-> *display* base-frame-counter)) + ) + (target-shoved + (-> *TARGET-bank* smack-surface-dist) + (-> *TARGET-bank* smack-surface-height) + (the-as process #f) + target-hit + ) + ) + (if (and (logtest? (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) button0-rel 0) + (pad-buttons circle) + ) + (can-feet?) + (and (= (if (> (-> self skel active-channels) 0) + (-> self skel root-channel 0 frame-group) + ) + (-> self draw art-group data 38) + ) + (= (-> self skel root-channel 0) (-> self skel channel)) + ) + ) + (go target-attack-air #f) + ) + (none) ) - (if - (and - (logtest? - (-> - *cpad-list* - cpads - (-> self control unknown-cpad-info00 number) - button0-rel - 0 - ) - (pad-buttons circle) - ) - (can-feet?) - (and (= (if (> (-> self skel active-channels) 0) - (-> self skel root-channel 0 frame-group) - ) - (-> self draw art-group data 38) - ) - (= (-> self skel root-channel 0) (-> self skel channel)) - ) - ) - (go target-attack-air #f) - ) - (none) - ) :code (behavior ((arg0 float) (arg1 float)) - (ja-channel-push! 1 12) - (let ((s4-0 (-> self skel root-channel 0))) - (joint-control-channel-group-eval! - s4-0 - (the-as art-joint-anim (-> self draw art-group data 71)) - num-func-identity - ) - (set! (-> s4-0 frame-num) 0.0) - ) - (let ((f30-0 (-> (new 'static 'array float 1 1.0) 0))) - (until - (or - (ja-max? 0) - (and (>= (ja-aframe-num 0) 4.0) (logtest? (-> self control status) 1)) - ) - (when - (and - (>= (ja-aframe-num 0) (-> (new 'static 'array float 1 3.0) 0)) - (not (-> self control unknown-symbol30)) - ) - (set! (-> self event-hook) target-dangerous-event-handler) - (target-start-attack) - (target-danger-set! 'flip #f) - ) - (TODO-RENAME-9 (-> self align)) - (if (not (ja-max? 0)) - (TODO-RENAME-10 - (-> self align) - 6 - (-> (new 'static 'array float 1 1.0) 0) - (/ arg0 (-> *TARGET-bank* wheel-flip-art-height)) - (* f30-0 (/ arg1 (-> *TARGET-bank* wheel-flip-art-dist))) - ) - (TODO-RENAME-10 - (-> self align) - 4 - (-> (new 'static 'array float 1 1.0) 0) - (-> (new 'static 'array float 1 1.0) 0) - (* f30-0 (/ arg1 (-> *TARGET-bank* wheel-flip-art-dist))) - ) - ) - (let ((s4-1 (new-stack-vector0))) - (vector-matrix*! - s4-1 - (-> self control transv) - (-> self control unknown-matrix00) - ) - (set! (-> s4-1 y) 0.0) - (vector-matrix*! - (-> self control unknown-vector120) - s4-1 - (-> self control unknown-matrix01) - ) - ) - (suspend) - (let ((a0-11 (-> self skel root-channel 0))) - (set! - (-> a0-11 param 0) - (the float (+ (-> a0-11 frame-group data 0 length) -1)) - ) - (set! (-> a0-11 param 1) (-> (new 'static 'array float 1 1.0) 0)) + (ja-channel-push! 1 12) + (let ((s4-0 (-> self skel root-channel 0))) (joint-control-channel-group-eval! - a0-11 - (the-as art-joint-anim #f) - num-func-seek! - ) - ) - (set! - f30-0 - (* - f30-0 - (fmin - (-> (new 'static 'array float 1 1.0) 0) - (-> self control unknown-float140) - ) - ) - ) - ) - ) - (set! (-> self state-time) (-> *display* base-frame-counter)) - (while (zero? (logand (-> self control status) 1)) - (when (>= (- (-> *display* base-frame-counter) (-> self state-time)) 3) - (when (not (= (if (> (-> self skel active-channels) 0) - (-> self skel root-channel 0 frame-group) - ) - (-> self draw art-group data 38) - ) - ) - (ja-channel-push! 1 30) - (let ((gp-1 (-> self skel root-channel 0))) - (joint-control-channel-group-eval! - gp-1 - (the-as art-joint-anim (-> self draw art-group data 38)) + s4-0 + (the-as art-joint-anim (-> self draw art-group data 71)) num-func-identity ) - (set! (-> gp-1 frame-num) 0.0) - ) + (set! (-> s4-0 frame-num) 0.0) ) - ) - (let ((gp-2 (new-stack-vector0)) - (f30-1 - (vector-dot - (-> self control dynam gravity-normal) + (let ((f30-0 (-> (new 'static 'array float 1 1.0) 0))) + (until (or (ja-max? 0) (and (>= (ja-aframe-num 0) 4.0) (logtest? (-> self control status) 1))) + (when (and (>= (ja-aframe-num 0) (-> (new 'static 'array float 1 3.0) 0)) (not (-> self control unknown-symbol30))) + (set! (-> self event-hook) target-dangerous-event-handler) + (target-start-attack) + (target-danger-set! 'flip #f) + ) + (TODO-RENAME-9 (-> self align)) + (if (not (ja-max? 0)) + (TODO-RENAME-10 + (-> self align) + 6 + (-> (new 'static 'array float 1 1.0) 0) + (/ arg0 (-> *TARGET-bank* wheel-flip-art-height)) + (* f30-0 (/ arg1 (-> *TARGET-bank* wheel-flip-art-dist))) + ) + (TODO-RENAME-10 + (-> self align) + 4 + (-> (new 'static 'array float 1 1.0) 0) + (-> (new 'static 'array float 1 1.0) 0) + (* f30-0 (/ arg1 (-> *TARGET-bank* wheel-flip-art-dist))) + ) + ) + (let ((s4-1 (new-stack-vector0))) + (vector-matrix*! s4-1 (-> self control transv) (-> self control unknown-matrix00)) + (set! (-> s4-1 y) 0.0) + (vector-matrix*! (-> self control unknown-vector120) s4-1 (-> self control unknown-matrix01)) + ) + (suspend) + (let ((a0-11 (-> self skel root-channel 0))) + (set! (-> a0-11 param 0) (the float (+ (-> a0-11 frame-group data 0 length) -1))) + (set! (-> a0-11 param 1) (-> (new 'static 'array float 1 1.0) 0)) + (joint-control-channel-group-eval! a0-11 (the-as art-joint-anim #f) num-func-seek!) + ) + (set! f30-0 (* f30-0 (fmin (-> (new 'static 'array float 1 1.0) 0) (-> self control unknown-float140)))) + ) + ) + (set! (-> self state-time) (-> *display* base-frame-counter)) + (while (zero? (logand (-> self control status) 1)) + (when (>= (- (-> *display* base-frame-counter) (-> self state-time)) 3) + (when (not (= (if (> (-> self skel active-channels) 0) + (-> self skel root-channel 0 frame-group) + ) + (-> self draw art-group data 38) + ) + ) + (ja-channel-push! 1 30) + (let ((gp-1 (-> self skel root-channel 0))) + (joint-control-channel-group-eval! + gp-1 + (the-as art-joint-anim (-> self draw art-group data 38)) + num-func-identity + ) + (set! (-> gp-1 frame-num) 0.0) + ) + ) + ) + (let ((gp-2 (new-stack-vector0)) + (f30-1 (vector-dot (-> self control dynam gravity-normal) (-> self control transv))) + ) + 0.0 + (vector-! gp-2 (-> self control transv) (vector-float*! gp-2 (-> self control dynam gravity-normal) f30-1)) + (let* ((f1-6 (vector-length gp-2)) + (f0-21 f1-6) + (f1-7 (* 0.9 f1-6)) + ) + (vector+! (-> self control transv) + (vector-float*! (-> self control transv) (-> self control dynam gravity-normal) f30-1) + (vector-float*! gp-2 gp-2 (/ f1-7 f0-21)) ) - ) ) - 0.0 - (vector-! - gp-2 - (-> self control transv) - (vector-float*! gp-2 (-> self control dynam gravity-normal) f30-1) - ) - (let* ((f1-6 (vector-length gp-2)) - (f0-21 f1-6) - (f1-7 (* 0.9 f1-6)) + ) + (suspend) + (cond + ((= (if (> (-> self skel active-channels) 0) + (-> self skel root-channel 0 frame-group) + ) + (-> self draw art-group data 38) ) - (vector+! - (-> self control transv) - (vector-float*! - (-> self control transv) - (-> self control dynam gravity-normal) - f30-1 - ) - (vector-float*! gp-2 gp-2 (/ f1-7 f0-21)) - ) - ) - ) - (suspend) - (cond - ((= (if (> (-> self skel active-channels) 0) - (-> self skel root-channel 0 frame-group) - ) - (-> self draw art-group data 38) - ) - (let ((a0-35 (-> self skel root-channel 0))) - (set! (-> a0-35 param 0) (-> (new 'static 'array float 1 1.0) 0)) - (joint-control-channel-group-eval! - a0-35 - (the-as art-joint-anim #f) - num-func-loop! - ) - ) - ) - (else - (let ((v1-85 (-> self skel root-channel 0))) - (set! (-> v1-85 num-func) num-func-identity) - (set! - (-> v1-85 frame-num) - (the float (+ (-> v1-85 frame-group data 0 length) -1)) - ) - ) - ) - ) - ) - (target-land-effect) - (set! - (-> self state-hook-time) - (the-as uint (-> *display* base-frame-counter)) - ) - (set! (-> self state-hook) (lambda :behavior target () (cond - ((>= - (- - (-> - *display* - base-frame-counter - ) - (the-as - int - (-> - self - state-hook-time - ) - ) - ) - 30 - ) - (set! - (-> - self - state-hook - ) - (the-as - (function none :behavior target) - nothing - ) - ) - ) - (else - (if - (and - (logtest? - (logior - (logior - (-> - *cpad-list* - cpads - (-> - self - control - unknown-cpad-info00 - number - ) - button0-rel - 0 - ) - (-> - *cpad-list* - cpads - (-> - self - control - unknown-cpad-info00 - number - ) - button0-rel - 1 - ) - ) - (-> - *cpad-list* - cpads - (-> - self - control - unknown-cpad-info00 - number - ) - button0-rel - 2 - ) - ) - (pad-buttons x) - ) - (can-jump? #f) - ) - (go - target-high-jump - (-> - *TARGET-bank* - flip-jump-height-min - ) - (-> - *TARGET-bank* - flip-jump-height-max - ) - 'flip - ) - ) - ) - ) - (none) - ) - ) - (if (= (if (> (-> self skel active-channels) 0) - (-> self skel root-channel 0 frame-group) + (let ((a0-35 (-> self skel root-channel 0))) + (set! (-> a0-35 param 0) (-> (new 'static 'array float 1 1.0) 0)) + (joint-control-channel-group-eval! a0-35 (the-as art-joint-anim #f) num-func-loop!) ) - (-> self draw art-group data 38) + ) + (else + (let ((v1-85 (-> self skel root-channel 0))) + (set! (-> v1-85 num-func) num-func-identity) + (set! (-> v1-85 frame-num) (the float (+ (-> v1-85 frame-group data 0 length) -1))) + ) + ) ) - (go target-hit-ground #f) - (go target-stance) + ) + (target-land-effect) + (set! (-> self state-hook-time) (the-as uint (-> *display* base-frame-counter))) + (set! (-> self state-hook) + (lambda :behavior target + () + (cond + ((>= (- (-> *display* base-frame-counter) (the-as int (-> self state-hook-time))) 30) + (set! (-> self state-hook) (the-as (function none :behavior target) nothing)) + ) + (else + (if (and (logtest? (logior (logior (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) button0-rel 0) + (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) button0-rel 1) + ) + (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) button0-rel 2) + ) + (pad-buttons x) + ) + (can-jump? #f) + ) + (go target-high-jump (-> *TARGET-bank* flip-jump-height-min) (-> *TARGET-bank* flip-jump-height-max) 'flip) + ) + ) + ) + (none) + ) + ) + (if (= (if (> (-> self skel active-channels) 0) + (-> self skel root-channel 0 frame-group) + ) + (-> self draw art-group data 38) + ) + (go target-hit-ground #f) + (go target-stance) + ) + (none) ) - (none) - ) :post (the-as (function none :behavior target) target-post) ) diff --git a/goal_src/examples/debug-collide.gc b/goal_src/examples/debug-collide.gc index 570853a6d..f9c3988dd 100644 --- a/goal_src/examples/debug-collide.gc +++ b/goal_src/examples/debug-collide.gc @@ -141,52 +141,34 @@ ;; incrementing counter to make the test input move around. (define *debug-counter* 0) -(defun debug-draw-collide-work () +(defun debug-draw-collide-work ((my-off float)) + (when (not (paused?)) (+! *debug-counter* 1) + + ) ;; create a test input that moves around sandover (let ((origin (new 'static 'vector :y (meters 7.0) :x (meters 5.) :z (meters 0.0))) (line (new 'static 'vector :y (meters 5.0) :x (meters -5.0))) - (radius (meters 0.5)) + (radius (meters 2.0)) + (val (+ my-off (* 0.003 (the float *debug-counter*)))) ) - (set! (-> line z) (* (sin (degrees (the float *debug-counter*))) (meters 15.0))) - (set! (-> line x) (* (cos (degrees (the float *debug-counter*))) (meters 15.0))) + (set! (-> line z) (* (sin (degrees val)) (meters 35.0))) + (set! (-> line x) (* (cos (degrees val)) (meters 35.0))) - (let ((dbg2 (/ (the float *debug-counter*) 2))) - (set! (-> origin x) (* (sin (degrees dbg2)) (meters 30.))) - (set! (-> origin z) (* (cos (* 3.0 (degrees dbg2))) (meters 30.))) + (let ((dbg2 (/ val 2))) + (set! (-> origin x) (* (sin (degrees dbg2)) (meters 100.))) + (set! (-> origin z) (* (cos (* 3.0 (degrees dbg2))) (meters 100.))) (+! (-> origin x) (meters -50.)) ) - +#| + ;;; PROBE (at the frag finding level) + ;; setup the collide work (setup-collide-for-line-sphere origin line radius) - ;; draw the line we're going to check - (add-debug-line - #t - (bucket-id debug-draw0) - origin - (vector+! (new 'stack-no-clear 'vector) origin line) - (new 'static 'rgba :r #x80) - #f - (the rgba -1) - ) - - ;; debug draw spheres along the line - (dotimes (i 10) - (add-debug-sphere - #t - (bucket-id debug-draw0) - (vector-lerp! (new 'stack-no-clear 'vector) - origin - (vector+! (new 'stack-no-clear 'vector) origin line) - (/ (the float i) 9.0) - ) - radius - (new 'static 'rgba :g #x80 :r #x80 :b #x80 :a #x80) - ) - ) + ;; clear collide list (set! (-> *collide-list* num-items) 0) @@ -246,23 +228,150 @@ ) ) ) +|# + + ;; CCACHE (fill from bounding box) + (let ((bbox-fake (new 'stack 'bounding-box)) + (bbox (new 'stack 'bounding-box))) + + ;; make box + (set! (-> bbox-fake min quad) (-> origin quad)) + (vector+! (-> bbox-fake max) origin line) + + (dotimes (i 3) + (set! (-> bbox min data i) (fmin (-> bbox-fake min data i) (-> bbox-fake max data i))) + (set! (-> bbox max data i) (fmax (-> bbox-fake min data i) (-> bbox-fake max data i))) + ) + (set! (-> bbox min w) 1.0) + (set! (-> bbox max w) 1.0) + + ;; BBOX + ;; draw box + ;(add-debug-box #t (bucket-id debug-draw0) (-> bbox min) (-> bbox max) (new 'static 'rgba :g #x30 :a #x80)) + ;; now fill! + ; (fill-using-bounding-box *collide-cache* + ; bbox + ; (collide-kind background) + ; (the process-drawable #f) + ; (the pat-surface 0) + ; ) + + + + ;; Y PROBE + ; (+! (-> bbox min y) (meters 8.0)) + ; (let ((vec (new 'stack-no-clear 'vector))) + ; (set! (-> vec quad) (-> bbox min quad)) + ; (-! (-> vec y) (meters 20.0)) + ; (add-debug-line + ; #t + ; (bucket-id debug-draw0) + ; (-> bbox min) + ; vec + ; (new 'static 'rgba :r #x80 :a #x80) + ; #f + ; (the rgba -1) + ; ) + ; ) + ; (fill-using-y-probe *collide-cache* (-> bbox min) (meters 20.0) (collide-kind background) (the process-drawable #f) (the uint 0)) + + ;; LINE SPHERE + ; (fill-using-line-sphere *collide-cache* origin line radius (collide-kind background) (the process-drawable #f) 0) + ; ;; draw the line we're going to check + ; (add-debug-line + ; #t + ; (bucket-id debug-draw0) + ; origin + ; (vector+! (new 'stack-no-clear 'vector) origin line) + ; (new 'static 'rgba :r #x80) + ; #f + ; (the rgba -1) + ; ) + + ; ;; debug draw spheres along the line + ; (dotimes (i 10) + ; (add-debug-sphere + ; #t + ; (bucket-id debug-draw0) + ; (vector-lerp! (new 'stack-no-clear 'vector) + ; origin + ; (vector+! (new 'stack-no-clear 'vector) origin line) + ; (/ (the float i) 9.0) + ; ) + ; radius + ; (new 'static 'rgba :g #x80 :r #x80 :b #x80 :a #x80) + ; ) + ; ) + + ;; Y probe (actual probe) + (+! (-> bbox min y) (meters 8.0)) + (let ((vec (new 'stack-no-clear 'vector))) + (set! (-> vec quad) (-> bbox min quad)) + (-! (-> vec y) (meters 20.0)) + ; (add-debug-line + ; #t + ; (bucket-id debug-draw0) + ; (-> bbox min) + ; vec + ; (new 'static 'rgba :r #x80 :a #x80) + ; #f + ; (the rgba -1) + ; ) + ) + + (let ((result (new 'stack-no-clear 'collide-tri-result))) + + (let ((u (fill-and-probe-using-y-probe *collide-cache* (-> bbox min) (meters 20.0) (collide-kind background) (the process-drawable #f) result (the uint 0)))) + (-! (-> bbox min y) (* u (meters 20.0))) + ;; (format *stdcon* "u = ~f : ~`vector`P ~%" u (-> result vertex 0)) + (add-debug-sphere + #t + (bucket-id debug-draw0) + (-> bbox min) + (meters 2.0) + (new 'static 'rgba :r #x80 :a #x80) + ) + ) + ;(add-debug-outline-triangle #t (bucket-id debug-draw1) (-> result vertex 0) (-> result vertex 1) (-> result vertex 2) (new 'static 'rgba :r #x80 :g #x80 :a #x80)) + + + + + ) + + + + ;(debug-draw *collide-cache*) + + + ) #f ) ) (defun start-debug-drawer () - (kill-by-name 'debug-drawer *active-pool*) + ;;(kill-by-name 'debug-drawer *active-pool*) (let ((proc (get-process *nk-dead-pool* process 1024))) (activate proc *active-pool* 'debug-drawer *kernel-dram-stack*) (run-next-time-in-process proc (lambda () - (while #t - (debug-draw-collide-work) - (suspend) + (let ((my-off (rand-vu-float-range 0.0 1000.0))) + (while #t + (debug-draw-collide-work my-off) + (suspend) + ) + + ) ) ) ) ) + +(defun start-100-debug-drawer () + (dotimes (i 100) + (start-debug-drawer) + ) + ) \ No newline at end of file diff --git a/goal_src/game.gp b/goal_src/game.gp index 9bf728f39..a68decaa8 100644 --- a/goal_src/game.gp +++ b/goal_src/game.gp @@ -257,6 +257,10 @@ "FUCV6" "FUCV7" "FUCV8" + "EIA1" + "EIA2" + "EIA3" + "EIA4" ) diff --git a/goal_src/goal-lib.gc b/goal_src/goal-lib.gc index 6261d18d3..9ab0d735a 100644 --- a/goal_src/goal-lib.gc +++ b/goal_src/goal-lib.gc @@ -818,6 +818,25 @@ ) ) +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;;; float macros +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + + +(defmacro fabs (x) + "Floating point absolute value" + ;; in GOAL this was implemented by the compiler. + ;; at some point, this could be more optimized. + ;; MIPS has an explicit abs.s instruction, but x86-64 doesn't. + ;; modern clang on O3 does a comiss/branch and this is probably pretty close. + `(if (< (the float ,x) 0) + (- (the float ,x)) + (the float ,x)) + ) + +(defmacro sqrtf (x) + `(sqrtf-no-fabs (fabs ,x)) + ) ;; load the default project (load-project "goal_src/game.gp") diff --git a/goal_src/kernel/gkernel.gc b/goal_src/kernel/gkernel.gc index 6fca7f5eb..4285db3c6 100644 --- a/goal_src/kernel/gkernel.gc +++ b/goal_src/kernel/gkernel.gc @@ -219,6 +219,7 @@ ) (else (msg-err "illegal attempt change stack size of ~A after more heap allocation has occured.~%" proc) + (break) ) ) ) diff --git a/goal_src/levels/beach/lurkercrab.gc b/goal_src/levels/beach/lurkercrab.gc index e0ecd01d4..6bae779bc 100644 --- a/goal_src/levels/beach/lurkercrab.gc +++ b/goal_src/levels/beach/lurkercrab.gc @@ -109,7 +109,7 @@ 16384.0 ) (the-as object (if (zero? (logand (-> obj nav-enemy-flags) 256)) - (respond-to-collisions! (-> obj collide-info)) + (do-push-aways! (-> obj collide-info)) ) ) ) diff --git a/goal_src/levels/beach/mayor.gc b/goal_src/levels/beach/mayor.gc index 5079ccfad..3814cceab 100644 --- a/goal_src/levels/beach/mayor.gc +++ b/goal_src/levels/beach/mayor.gc @@ -716,7 +716,7 @@ ((the-as (function none) t9-0)) ) ) - (respond-to-collisions! (-> self root-override)) + (do-push-aways! (-> self root-override)) (none) ) ) diff --git a/goal_src/levels/beach/pelican.gc b/goal_src/levels/beach/pelican.gc index 3259e5c3a..6911df9f2 100644 --- a/goal_src/levels/beach/pelican.gc +++ b/goal_src/levels/beach/pelican.gc @@ -656,7 +656,7 @@ (vector-seek! gp-0 a1-0 (* (-> self state-float 0) (-> *display* seconds-per-frame))) (move-to-point! (-> self root-override) gp-0) ) - (respond-to-collisions! (-> self root-override)) + (do-push-aways! (-> self root-override)) (seek-toward-heading-vec! (-> self root-override) (-> self path-vector) 131072.0 300) (spool-push *art-control* "pelican-spit-ext" 0 self -99.0) (none) diff --git a/goal_src/levels/flut_common/target-flut.gc b/goal_src/levels/flut_common/target-flut.gc index 4352eafb3..1a7efe074 100644 --- a/goal_src/levels/flut_common/target-flut.gc +++ b/goal_src/levels/flut_common/target-flut.gc @@ -1667,7 +1667,7 @@ (meters 2.0) (-> *TARGET-bank* smack-surface-height) (the-as process #f) - (the-as (state target) target-flut-hit) + target-flut-hit ) ) (if (and (logtest? (-> self water flags) 512) diff --git a/goal_src/levels/jungle/darkvine.gc b/goal_src/levels/jungle/darkvine.gc index 64772cd47..4606a280b 100644 --- a/goal_src/levels/jungle/darkvine.gc +++ b/goal_src/levels/jungle/darkvine.gc @@ -152,7 +152,7 @@ (let ((v1-0 arg2)) (the-as object (cond ((= v1-0 'touch) - (respond-to-collisions! (-> self root-override)) + (do-push-aways! (-> self root-override)) (when (-> self dangerous) (let ((a1-1 (new 'stack-no-clear 'event-message-block))) (set! (-> a1-1 from) self) @@ -172,7 +172,7 @@ ((!= v1-10 (-> self player-attack-id)) (set! (-> self player-attack-id) (the-as int v1-10)) (when (-> self vulnerable) - (respond-to-collisions! (-> self root-override)) + (do-push-aways! (-> self root-override)) (go darkvine-retreat) ) ) diff --git a/goal_src/levels/jungle/junglesnake.gc b/goal_src/levels/jungle/junglesnake.gc index 6c9a56afa..d60edf3d2 100644 --- a/goal_src/levels/jungle/junglesnake.gc +++ b/goal_src/levels/jungle/junglesnake.gc @@ -143,7 +143,7 @@ ) ) (else - (respond-to-collisions! (-> self root-override)) + (do-push-aways! (-> self root-override)) (let ((a1-3 (new 'stack-no-clear 'event-message-block))) (set! (-> a1-3 from) self) (set! (-> a1-3 num-params) 2) @@ -734,7 +734,7 @@ junglesnake-default-event-handler (let ((v1-4 (-> (the-as collide-shape-prim-group (-> obj root-override root-prim)) prims 0))) (logior! (-> v1-4 prim-core action) (collide-action solid)) ) - (respond-to-collisions! (-> obj root-override)) + (do-push-aways! (-> obj root-override)) ) 0 (none) diff --git a/goal_src/levels/jungleb/plant-boss.gc b/goal_src/levels/jungleb/plant-boss.gc index ffb0bfcf1..fd9ded47f 100644 --- a/goal_src/levels/jungleb/plant-boss.gc +++ b/goal_src/levels/jungleb/plant-boss.gc @@ -2384,7 +2384,7 @@ :post (behavior () (plant-boss-post) - (respond-to-collisions! (-> self root-override)) + (do-push-aways! (-> self root-override)) (none) ) ) @@ -2424,7 +2424,7 @@ (let ((gp-1 (-> *display* base-frame-counter))) (until (>= (- (-> *display* base-frame-counter) gp-1) 1500) (transform-post) - (respond-to-collisions! (-> self root-override)) + (do-push-aways! (-> self root-override)) (suspend) ) ) diff --git a/goal_src/levels/misty/balloonlurker.gc b/goal_src/levels/misty/balloonlurker.gc index 70566c868..1ad230d35 100644 --- a/goal_src/levels/misty/balloonlurker.gc +++ b/goal_src/levels/misty/balloonlurker.gc @@ -469,7 +469,7 @@ (-> self root-overlay) (the-as uint 1) ) - (respond-to-collisions! (-> self root-overlay)) + (do-push-aways! (-> self root-overlay)) (let ((a1-3 (new 'stack-no-clear 'event-message-block))) (set! (-> a1-3 from) self) (set! (-> a1-3 num-params) 2) diff --git a/goal_src/levels/sunken/helix-water.gc b/goal_src/levels/sunken/helix-water.gc index aa94b0ff2..823bb27fc 100644 --- a/goal_src/levels/sunken/helix-water.gc +++ b/goal_src/levels/sunken/helix-water.gc @@ -363,7 +363,7 @@ (set! (-> gp-1 y) 0.0) (vector-normalize! gp-1 4096.0) (move-by-vector! (-> *target* control) gp-1) - (respond-to-collisions! (-> self root-override)) + (do-push-aways! (-> self root-override)) (detect-riders! (-> self root-override)) ) ) diff --git a/goal_src/levels/swamp/swamp-obs.gc b/goal_src/levels/swamp/swamp-obs.gc index d58f70184..97e9b8a26 100644 --- a/goal_src/levels/swamp/swamp-obs.gc +++ b/goal_src/levels/swamp/swamp-obs.gc @@ -205,7 +205,7 @@ (set! (-> a1-0 to) (the-as process 1)) (set! (-> a1-0 from) (the-as process *touching-list*)) (if (find-overlapping-shapes (-> self root-override) (the-as overlaps-others-params a1-0)) - (respond-to-collisions! (-> self root-override)) + (do-push-aways! (-> self root-override)) ) ) (none) diff --git a/goal_src/levels/village1/yakow.gc b/goal_src/levels/village1/yakow.gc index c877521e8..d66413dd4 100644 --- a/goal_src/levels/village1/yakow.gc +++ b/goal_src/levels/village1/yakow.gc @@ -158,7 +158,7 @@ ) ) (when (and v1-2 (< 8192.0 (- (-> v1-2 root trans y) (-> self root-override trans y)))) - (respond-to-collisions! (-> self root-override)) + (do-push-aways! (-> self root-override)) (send-shove-back (-> self root-override) arg0 diff --git a/goalc/compiler/Compiler.h b/goalc/compiler/Compiler.h index 467f5621c..505c9a360 100644 --- a/goalc/compiler/Compiler.h +++ b/goalc/compiler/Compiler.h @@ -296,6 +296,11 @@ class Compiler { u8 sa, Env* env, IntegerMathKind kind); + Val* compile_floating_point_division(const goos::Object& form, + const TypeSpec& result_type, + RegVal* a, + RegVal* b, + Env* env); Val* compile_format_string(const goos::Object& form, Env* env, diff --git a/goalc/compiler/compilation/Atoms.cpp b/goalc/compiler/compilation/Atoms.cpp index 603979678..7b56aaa16 100644 --- a/goalc/compiler/compilation/Atoms.cpp +++ b/goalc/compiler/compilation/Atoms.cpp @@ -251,7 +251,7 @@ const std::unordered_map< {"&+", &Compiler::compile_pointer_add}, {"fmax", &Compiler::compile_fmax}, {"fmin", &Compiler::compile_fmin}, - {"sqrtf", &Compiler::compile_sqrtf}, + {"sqrtf-no-fabs", &Compiler::compile_sqrtf}, // BUILDER (build-dgo/build-cgo?) {"build-dgos", &Compiler::compile_build_dgo}, diff --git a/goalc/compiler/compilation/Math.cpp b/goalc/compiler/compilation/Math.cpp index 88272f0ac..c30582d03 100644 --- a/goalc/compiler/compilation/Math.cpp +++ b/goalc/compiler/compilation/Math.cpp @@ -1,5 +1,6 @@ #include "goalc/compiler/Compiler.h" #include "common/util/BitUtils.h" +#include MathMode Compiler::get_math_mode(const TypeSpec& ts) { if (m_ts.tc(m_ts.make_typespec("binteger"), ts)) { @@ -371,6 +372,61 @@ Val* Compiler::compile_sub(const goos::Object& form, const goos::Object& rest, E return get_none(); } +Val* Compiler::compile_floating_point_division(const goos::Object& form, + const TypeSpec& result_type, + RegVal* a, + RegVal* b, + Env* env) { + constexpr bool use_accurate = true; + auto result = env->make_fpr(result_type); + + if (use_accurate) { + auto fenv = env->function_env(); + auto end_label = fenv->alloc_unnamed_label(); + end_label->func = fenv; + end_label->idx = -10; // placeholder + + auto zero = compile_float(0.0, env, fenv->segment_for_static_data())->to_fpr(form, env); + Condition zero_check; + zero_check.kind = ConditionKind::EQUAL; + zero_check.a = zero; + zero_check.b = b; + zero_check.is_float = true; + + // check for divide by zero + auto branch_ir = std::make_unique(zero_check, Label()); + auto branch_ir_ref = branch_ir.get(); + env->emit(form, std::move(branch_ir)); + + // code for not dividing by zero + env->emit_ir(form, result, a); + env->emit_ir(form, FloatMathKind::DIV_SS, result, b); + + env->emit_ir(form, end_label); + + branch_ir_ref->mark_as_resolved(); + branch_ir_ref->label.idx = fenv->code().size(); + + auto flt_max = compile_integer(0x7f7fffff, env)->to_gpr(form, env); + auto mask = compile_integer(0xf0000000, env)->to_gpr(form, env); + auto temp_int = env->make_gpr(result_type); + env->emit_ir(form, temp_int, a); + env->emit_ir(form, IntegerMathKind::AND_64, temp_int, mask); + env->emit_ir(form, IntegerMathKind::XOR_64, flt_max, temp_int); + env->emit_ir(form, temp_int, b); + env->emit_ir(form, IntegerMathKind::AND_64, temp_int, mask); + env->emit_ir(form, IntegerMathKind::XOR_64, flt_max, temp_int); + env->emit_ir(form, result, flt_max); + + end_label->idx = fenv->code().size(); + + } else { + env->emit_ir(form, result, a); + env->emit_ir(form, FloatMathKind::DIV_SS, result, b); + } + return result; +} + Val* Compiler::compile_div(const goos::Object& form, const goos::Object& rest, Env* env) { auto args = get_va(form, rest); if (!args.named.empty() || args.unnamed.size() != 2) { @@ -427,13 +483,10 @@ Val* Compiler::compile_div(const goos::Object& form, const goos::Object& rest, E } case MATH_FLOAT: { - auto result = env->make_fpr(first_type); - env->emit_ir(form, result, first_val->to_fpr(form, env)); - env->emit_ir( - form, FloatMathKind::DIV_SS, result, - to_math_type(form, compile_error_guard(args.unnamed.at(1), env), math_type, env) - ->to_fpr(form, env)); - return result; + auto a = first_val->to_fpr(form, env); + auto b = to_math_type(form, compile_error_guard(args.unnamed.at(1), env), math_type, env) + ->to_fpr(form, env); + return compile_floating_point_division(form, first_type, a, b, env); } case MATH_INVALID: diff --git a/test/decompiler/reference/engine/camera/camera-h_REF.gc b/test/decompiler/reference/engine/camera/camera-h_REF.gc index 350e7a199..120010a2b 100644 --- a/test/decompiler/reference/engine/camera/camera-h_REF.gc +++ b/test/decompiler/reference/engine/camera/camera-h_REF.gc @@ -139,7 +139,7 @@ (print-nth-point (_type_ int) none 11) (TODO-RENAME-12 (_type_) none 12) (TODO-RENAME-13 (_type_ int) none 13) - (TODO-RENAME-14 (_type_ vector) none 14) + (TODO-RENAME-14 (_type_ tracking-spline-sampler) none 14) (TODO-RENAME-15 (_type_) none 15) (TODO-RENAME-16 (_type_ float) none 16) (TODO-RENAME-17 (_type_ vector float float symbol) int 17) diff --git a/test/decompiler/reference/engine/camera/camera_REF.gc b/test/decompiler/reference/engine/camera/camera_REF.gc index 466958ba8..29046d4c1 100644 --- a/test/decompiler/reference/engine/camera/camera_REF.gc +++ b/test/decompiler/reference/engine/camera/camera_REF.gc @@ -520,17 +520,17 @@ ;; definition for method 14 of type tracking-spline ;; INFO: Return type mismatch int vs none. -(defmethod TODO-RENAME-14 tracking-spline ((obj tracking-spline) (arg0 vector)) +(defmethod TODO-RENAME-14 tracking-spline ((obj tracking-spline) (arg0 tracking-spline-sampler)) (let ((v1-0 (-> obj used-point))) - (set! (-> obj partial-point) (-> arg0 y)) + (set! (-> obj partial-point) (-> arg0 partial-pt)) (when (= (-> obj next-to-last-point) v1-0) (set! (-> obj summed-len) (-> obj point v1-0 tp-length)) - (if (= (-> arg0 x) (-> obj end-point)) + (if (= (-> arg0 cur-pt) (-> obj end-point)) (set! (-> obj partial-point) 0.99999) ) ) - (when (!= (-> arg0 x) v1-0) - (while (and (!= (-> obj point v1-0 next) (-> arg0 x)) (!= (-> obj point v1-0 next) (-> obj next-to-last-point))) + (when (!= (-> arg0 cur-pt) v1-0) + (while (and (!= (-> obj point v1-0 next) (-> arg0 cur-pt)) (!= (-> obj point v1-0 next) (-> obj next-to-last-point))) (set! (-> obj summed-len) (- (-> obj summed-len) (-> obj point v1-0 tp-length))) (+! (-> obj point v1-0 incarnation) 1) (+! (-> obj used-count) -1) @@ -541,13 +541,13 @@ (+! (-> obj used-count) -1) (set! (-> obj point v1-0 next) (-> obj free-point)) (set! (-> obj free-point) (-> obj used-point)) - (set! (-> obj used-point) (the-as int (-> arg0 x))) + (set! (-> obj used-point) (-> arg0 cur-pt)) (cond - ((= (-> arg0 x) (-> obj end-point)) + ((= (-> arg0 cur-pt) (-> obj end-point)) (set! (-> obj partial-point) 0.0) (set! (-> obj summed-len) 0.0) ) - ((= (-> arg0 x) (-> obj next-to-last-point)) + ((= (-> arg0 cur-pt) (-> obj next-to-last-point)) (set! (-> obj summed-len) (-> obj point (-> obj next-to-last-point) tp-length)) ) ) @@ -857,7 +857,7 @@ (set! (-> s4-0 cur-pt) v1-0) (set! (-> s4-0 partial-pt) f0-0) (TODO-RENAME-19 obj (* (-> obj max-move) (-> *display* time-adjust-ratio)) arg0 s4-0) - (TODO-RENAME-14 obj (the-as vector s4-0)) + (TODO-RENAME-14 obj s4-0) (dotimes (s3-0 63) (TODO-RENAME-18 obj (* 0.015625 (-> obj sample-len)) arg0 s4-0) ) @@ -888,7 +888,7 @@ (set! (-> s5-0 partial-pt) 0.0) (TODO-RENAME-19 obj (- (-> obj summed-len) arg0) a2-0 s5-0) ) - (TODO-RENAME-14 obj (the-as vector s5-0)) + (TODO-RENAME-14 obj s5-0) ) ) 0 diff --git a/test/decompiler/reference/engine/collide/collide-cache-h_REF.gc b/test/decompiler/reference/engine/collide/collide-cache-h_REF.gc index ceab15c62..901f88f25 100644 --- a/test/decompiler/reference/engine/collide/collide-cache-h_REF.gc +++ b/test/decompiler/reference/engine/collide/collide-cache-h_REF.gc @@ -57,8 +57,8 @@ :size-assert #xc60 :flag-assert #xb00000c60 (:methods - (dummy-9 () none 9) - (dummy-10 () none 10) + (dummy-9 (_type_ object object) symbol 9) + (dummy-10 (_type_ object object) symbol 10) ) ) @@ -100,10 +100,11 @@ ;; definition of type collide-cache-tri (deftype collide-cache-tri (structure) ((vertex vector 3 :inline :offset-assert 0) - (pat pat-surface :offset-assert 48) - (prim-index uint16 :offset-assert 52) - (user16 uint16 :offset-assert 54) - (user32 uint32 2 :offset-assert 56) + (extra-quad uint128 :offset 48) + (pat pat-surface :offset 48) + (prim-index uint16 :offset 52) + (user16 uint16 :offset 54) + (user32 uint32 2 :offset 56) ) :method-count-assert 9 :size-assert #x40 @@ -114,7 +115,7 @@ (defmethod inspect collide-cache-tri ((obj collide-cache-tri)) (format #t "[~8x] ~A~%" obj 'collide-cache-tri) (format #t "~Tvertex[3] @ #x~X~%" (-> obj vertex)) - (format #t "~Textra-quad[16] @ #x~X~%" (&-> obj pat)) + (format #t "~Textra-quad[16] @ #x~X~%" (&-> obj extra-quad)) (format #t "~Tpat: ~D~%" (-> obj pat)) (format #t "~Tprim-index: ~D~%" (-> obj prim-index)) (format #t "~Tuser16: ~D~%" (-> obj user16)) @@ -125,11 +126,12 @@ ;; definition of type collide-cache-prim (deftype collide-cache-prim (structure) ((prim-core collide-prim-core :inline :offset-assert 0) - (ccache collide-cache :offset-assert 32) - (prim collide-shape-prim :offset-assert 36) - (first-tri uint16 :offset-assert 40) - (num-tris uint16 :offset-assert 42) - (unused uint8 4 :offset-assert 44) + (extra-quad uint128 :offset-assert 32) + (ccache collide-cache :offset 32) + (prim collide-shape-prim :offset 36) + (first-tri uint16 :offset 40) + (num-tris uint16 :offset 42) + (unused uint8 4 :offset 44) (world-sphere vector :inline :offset 0) (collide-as collide-kind :offset 16) (action collide-action :offset 24) @@ -149,7 +151,7 @@ (defmethod inspect collide-cache-prim ((obj collide-cache-prim)) (format #t "[~8x] ~A~%" obj 'collide-cache-prim) (format #t "~Tprim-core: #~%" (-> obj prim-core)) - (format #t "~Textra-quad[16] @ #x~X~%" (&-> obj ccache)) + (format #t "~Textra-quad[16] @ #x~X~%" (&-> obj extra-quad)) (format #t "~Tccache: ~A~%" (-> obj ccache)) (format #t "~Tprim: ~A~%" (-> obj prim)) (format #t "~Tfirst-tri: ~D~%" (-> obj first-tri)) @@ -182,7 +184,7 @@ (:methods (debug-draw (_type_) none 9) (fill-and-probe-using-line-sphere (_type_ vector vector float collide-kind process collide-tri-result int) float 10) - (fill-and-probe-using-spheres (_type_ collide-using-spheres-params) none 11) + (fill-and-probe-using-spheres (_type_ collide-using-spheres-params) symbol 11) (fill-and-probe-using-y-probe (_type_ vector float collide-kind process collide-tri-result uint) float 12) (fill-using-bounding-box (_type_ bounding-box collide-kind process-drawable pat-surface) none 13) (fill-using-line-sphere (_type_ vector vector float collide-kind process-drawable int) none 14) @@ -190,20 +192,20 @@ (fill-using-y-probe (_type_ vector float collide-kind process-drawable uint) none 16) (initialize (_type_) none 17) (probe-using-line-sphere (_type_ vector vector float collide-kind collide-tri-result int) float 18) - (probe-using-spheres (_type_) none 19) + (probe-using-spheres (_type_ collide-using-spheres-params) symbol 19) (probe-using-y-probe (_type_ vector float collide-kind collide-tri-result uint) float 20) - (fill-from-background (_type_ (function bsp-header int collide-list none) (function collide-cache none)) none 21) - (fill-from-foreground-using-spheres (_type_) none 22) + (fill-from-background (_type_ (function bsp-header int collide-list none) (function collide-cache object none)) none 21) + (fill-from-foreground-using-box (_type_) none 22) (fill-from-foreground-using-line-sphere (_type_) none 23) (fill-from-foreground-using-y-probe (_type_) none 24) (fill-from-water (_type_ water-control) none 25) - (dummy-26 (_type_) none 26) + (load-mesh-from-spad-in-box (_type_ collide-frag-mesh) none 26) (dummy-27 (_type_) none 27) (dummy-28 (_type_) none 28) (dummy-29 (_type_ collide-frag-mesh) none 29) - (dummy-30 (_type_) none 30) - (dummy-31 (_type_ collide-puyp-work collide-cache-prim) vector 31) - (dummy-32 (_type_) none 32) + (puyp-mesh (_type_ collide-puyp-work collide-cache-prim) none 30) + (puyp-sphere (_type_ collide-puyp-work collide-cache-prim) vector 31) + (unpack-background-collide-mesh (_type_ object object object) none 32) ) ) diff --git a/test/decompiler/reference/engine/collide/collide-edge-grab-h_REF.gc b/test/decompiler/reference/engine/collide/collide-edge-grab-h_REF.gc index 78ea8911d..90fd542a2 100644 --- a/test/decompiler/reference/engine/collide/collide-edge-grab-h_REF.gc +++ b/test/decompiler/reference/engine/collide/collide-edge-grab-h_REF.gc @@ -124,7 +124,7 @@ :flag-assert #xb00000810 (:methods (debug-draw (_type_) object 9) - (dummy-10 () none 10) + (dummy-10 (_type_ collide-edge-hold-item) none 10) ) ) @@ -176,12 +176,12 @@ (debug-draw-edges (_type_) object 10) (dummy-11 (_type_) none 11) (debug-draw-sphere (_type_) symbol 12) - (dummy-13 (_type_) none 13) + (dummy-13 (_type_ collide-edge-hold-item vector) none 13) (dummy-14 (_type_ vector vector int) float 14) (dummy-15 (_type_) none 15) - (dummy-16 (_type_) none 16) + (find-grabbable-tris! (_type_) none 16) (dummy-17 (_type_) none 17) - (dummy-18 (_type_) none 18) + (dummy-18 (_type_ collide-edge-hold-list edge-grab-info) none 18) (dummy-19 (_type_ collide-edge-hold-item edge-grab-info) symbol 19) ) ) diff --git a/test/decompiler/reference/engine/collide/collide-shape-h_REF.gc b/test/decompiler/reference/engine/collide/collide-shape-h_REF.gc index c4260551f..c5356e6f5 100644 --- a/test/decompiler/reference/engine/collide/collide-shape-h_REF.gc +++ b/test/decompiler/reference/engine/collide/collide-shape-h_REF.gc @@ -228,9 +228,9 @@ (move-by-vector! (_type_ vector) none 9) (find-prim-by-id (_type_ uint) collide-shape-prim 10) (debug-draw-world-sphere (_type_) symbol 11) - (add-fg-prim-using-box (_type_ process-drawable) none 12) - (add-fg-prim-using-line-sphere (_type_ process-drawable) none 13) - (add-fg-prim-using-y-probe (_type_ process-drawable) none 14) + (add-fg-prim-using-box (_type_ collide-cache) none 12) + (add-fg-prim-using-line-sphere (_type_ collide-cache) none 13) + (add-fg-prim-using-y-probe (_type_ collide-cache) none 14) (overlaps-others-test (_type_ overlaps-others-params collide-shape-prim) symbol 15) (overlaps-others-group (_type_ overlaps-others-params collide-shape-prim-group) symbol 16) (dummy-17 () none 17) @@ -406,10 +406,10 @@ (on-platform (_type_ collide-shape collide-overlap-result) symbol 39) (find-overlapping-shapes (_type_ overlaps-others-params) symbol 40) (dummy-41 (_type_ attack-info float) vector 41) - (compute-overlap (_type_ collide-shape collide-overlap-result) symbol 42) + (should-push-away (_type_ collide-shape collide-overlap-result) symbol 42) (pull-rider! (_type_ pull-rider-info) none 43) (pull-riders! (_type_) symbol 44) - (respond-to-collisions! (_type_) symbol 45) + (do-push-aways! (_type_) symbol 45) (set-root-prim! (_type_ collide-shape-prim) collide-shape-prim 46) (update-transforms! (_type_) symbol 47) (clear-collide-with-as (_type_) none 48) diff --git a/test/decompiler/reference/engine/collide/collide-target-h_REF.gc b/test/decompiler/reference/engine/collide/collide-target-h_REF.gc index 0c018e5d6..6f2bf5778 100644 --- a/test/decompiler/reference/engine/collide/collide-target-h_REF.gc +++ b/test/decompiler/reference/engine/collide/collide-target-h_REF.gc @@ -40,151 +40,161 @@ ;; definition of type control-info (deftype control-info (collide-shape-moving) - ((unknown-vector00 vector :inline :offset 448) - (unknown-vector01 vector :inline :offset 464) - (unknown-vector02 vector :inline :offset 480) - (unknown-quaternion00 quaternion :inline :offset 496) - (unknown-quaternion01 quaternion :inline :offset 512) - (unknown-float00 float :offset 528) - (unknown-float01 float :offset 532) - (unknown-float02 float :offset 536) - (unknown-vector10 vector :inline :offset 544) - (unknown-vector11 vector :inline :offset 560) - (unknown-vector12 vector :inline :offset 576) - (unknown-vector13 vector :inline :offset 592) - (unknown-vector14 vector :inline :offset 608) - (unknown-vector15 vector :inline :offset 624) - (unknown-vector16 vector :inline :offset 640) - (unknown-dynamics00 dynamics :offset 656) - (unknown-surface00 surface :offset 660) - (unknown-surface01 surface :offset 664) - (unknown-cpad-info00 cpad-info :offset 668) - (unknown-float10 float :offset 672) - (unknown-float11 float :offset 676) - (unknown-float12 float :offset 680) - (unknown-float13 float :offset 684) - (unknown-vector20 vector :inline :offset 688) - (unknown-vector21 vector :inline :offset 704) - (unknown-vector22 vector :inline :offset 720) - (unknown-vector23 vector :inline :offset 736) - (unknown-vector-array00 vector 7 :inline :offset 752) - (unknown-vector30 vector :inline :offset 880) - (unknown-vector31 vector :inline :offset 896) - (unknown-float20 float :offset 912) - (unknown-float21 float :offset 916) - (unknown-dword00 uint64 :offset 920) - (unknown-matrix00 matrix :inline :offset 928) - (unknown-matrix01 matrix :inline :offset 992) - (unknown-matrix02 matrix :inline :offset 1056) - (unknown-qword00 uint128 :offset 1136) - (unknown-float30 float :offset 1140) - (unknown-vector40 vector :inline :offset 1152) - (unknown-float40 float :offset 1172) - (unknown-float41 float :offset 1176) - (unknown-int00 int32 :offset 1180) - (unknown-float50 float :offset 1168) - (unknown-vector50 vector :inline :offset 1184) - (unknown-vector51 vector :inline :offset 1200) - (unknown-vector52 vector :inline :offset 1216) - (unknown-vector53 vector :inline :offset 1232) - (last-known-safe-ground vector :inline :offset 1248) - (unknown-vector55 vector :inline :offset 1264) - (unknown-dword10 int64 :offset 1280) - (unknown-dword11 int64 :offset 1288) - (unknown-float60 float :offset 1300) - (unknown-float61 float :offset 1304) - (unknown-float62 float :offset 1308) - (unknown-float63 float :offset 1312) - (unknown-float64 float :offset 1316) - (unknown-dword20 int64 :offset 1320) - (unknown-dword21 int64 :offset 1328) - (unknown-vector60 vector :inline :offset 1456) - (unknown-vector61 vector :inline :offset 1504) - (unknown-float70 float :offset 1520) - (unknown-float71 float :offset 1524) - (unknown-vector70 vector :inline :offset 1536) - (unknown-vector71 vector :inline :offset 1552) - (unknown-vector72 vector :inline :offset 1568) - (unknown-vector73 vector :inline :offset 1584) - (unknown-handle00 handle :offset 1600) - (unknown-sphere-array00 collide-shape-prim-sphere 3 :offset 1608) - (unknown-sphere00 collide-shape-prim-sphere :offset 1632) - (unknown-sphere01 collide-shape-prim-sphere :offset 1636) - (unknown-sphere02 collide-shape-prim-sphere :offset 1640) - (unknown-int50 int32 :offset 1656) - (unknown-dword30 int64 :offset 1664) - (unknown-dword31 int64 :offset 1672) - (unknown-dword32 int64 :offset 1680) - (unknown-dword33 int64 :offset 1688) - (unknown-dword34 int64 :offset 1696) - (unknown-dword35 int64 :offset 1704) - (unknown-dword36 int64 :offset 1712) - (unknown-float80 float :offset 1724) - (unknown-float81 float :offset 1728) - (unknown-float82 float :offset 1732) - (unknown-vector80 vector :inline :offset 1744) - (unknown-cspace00 cspace :inline :offset 1760) - (unknown-vector90 vector :inline :offset 1776) - (unknown-vector91 vector :inline :offset 1792) - (unknown-vector92 vector :inline :offset 1824) - (unknown-cspace10 cspace :inline :offset 1808) - (unknown-symbol00 symbol :offset 1840) - (unknown-float90 float :offset 1844) - (unknown-float91 float :offset 1848) - (unknown-vector-array10 vector 16 :inline :offset 1856) - (unknown-float100 float :offset 2112) - (unknown-int10 int32 :offset 2116) - (unknown-float110 float :offset 2120) - (unknown-vector100 vector :inline :offset 2128) - (unknown-vector101 vector :inline :offset 2144) - (unknown-dword40 int64 :offset 2160) - (unknown-dword41 int64 :offset 2168) - (unknown-handle10 handle :offset 2176) - (unknown-uint20 uint32 :offset 2184) - (unknown-spoolanim00 spool-anim :offset 2184) - (unknown-int20 int32 :offset 2184) - (unknown-symbol20 symbol :offset 2184) - (unknown-float120 float :offset 2184) - (unknown-int21 int32 :offset 2188) - (unknown-uint30 uint32 :offset 2188) - (unknown-float121 float :offset 2188) - (unknown-uint31 uint32 :offset 2192) - (unknown-float122 float :offset 2196) - (unknown-float123 float :offset 2200) - (unknown-float124 float :offset 2204) - (unknown-vector102 vector :inline :offset 2224) - (unknown-vector103 vector :inline :offset 2240) - (unknown-quaternion02 quaternion :inline :offset 2256) - (unknown-quaternion03 quaternion :inline :offset 2272) - (unknown-smush00 smush-control :inline :offset 2288) - (unknown-vector110 vector :inline :offset 2320) - (unknown-vector111 vector :inline :offset 2336) - (unknown-symbol30 symbol :offset 2384) - (unknown-int31 uint32 :offset 2384) - (unknown-dword50 int64 :offset 2392) - (unknown-dword51 int64 :offset 2400) - (unknown-pointer00 pointer :offset 2416) - (unknown-symbol40 symbol :offset 2428) - (unknown-dword60 int64 :offset 2432) - (unknown-dword61 int64 :offset 2440) - (unknown-dword62 int64 :offset 2448) - (unknown-dword63 int64 :offset 2456) - (unknown-halfword00 int16 :offset 2488) - (history-length int16 :offset 2490) - (history-data collide-history 128 :inline :offset-assert 2496) - (unknown-float140 float :offset 18944) - (unknown-dword70 int64 :offset 18952) - (unknown-int40 int32 :offset 18880) - (unknown-dword80 int64 :offset 18888) - (unknown-dword81 int64 :offset 18896) - (unknown-float130 float :offset 18904) - (unknown-float131 float :offset 18908) - (unknown-dword82 int64 :offset 18912) - (unknown-vector120 vector :inline :offset 18928) - (unknown-float150 float :offset 18944) - (unknown-int60 uint32 :offset 18976) - (unknown-soundid00 sound-id :offset 18980) - (unknown-float141 float :offset 18984) + ((unknown-vector00 vector :inline :offset 448) + (unknown-vector01 vector :inline :offset 464) + (unknown-vector02 vector :inline :offset 480) + (unknown-quaternion00 quaternion :inline :offset 496) + (unknown-quaternion01 quaternion :inline :offset 512) + (unknown-float00 float :offset 528) + (unknown-float01 float :offset 532) + (unknown-float02 float :offset 536) + (unknown-vector10 vector :inline :offset 544) + (unknown-vector11 vector :inline :offset 560) + (unknown-vector12 vector :inline :offset 576) + (unknown-vector13 vector :inline :offset 592) + (unknown-vector14 vector :inline :offset 608) + (unknown-vector15 vector :inline :offset 624) + (unknown-vector16 vector :inline :offset 640) + (unknown-dynamics00 dynamics :offset 656) + (unknown-surface00 surface :offset 660) + (unknown-surface01 surface :offset 664) + (unknown-cpad-info00 cpad-info :offset 668) + (unknown-float10 float :offset 672) + (unknown-float11 float :offset 676) + (unknown-float12 float :offset 680) + (unknown-float13 float :offset 684) + (unknown-vector20 vector :inline :offset 688) + (unknown-vector21 vector :inline :offset 704) + (unknown-vector22 vector :inline :offset 720) + (unknown-vector23 vector :inline :offset 736) + (unknown-vector-array00 vector 7 :inline :offset 752) + (unknown-vector30 vector :inline :offset 880) + (unknown-vector31 vector :inline :offset 896) + (unknown-float20 float :offset 912) + (unknown-float21 float :offset 916) + (unknown-dword00 uint64 :offset 920) + (unknown-matrix00 matrix :inline :offset 928) + (unknown-matrix01 matrix :inline :offset 992) + (unknown-matrix02 matrix :inline :offset 1056) + (unknown-qword00 uint128 :offset 1136) + (unknown-float30 float :offset 1140) + (unknown-vector40 vector :inline :offset 1152) + (unknown-float40 float :offset 1172) + (unknown-float41 float :offset 1176) + (unknown-int00 int32 :offset 1180) + (unknown-float50 float :offset 1168) + (unknown-vector50 vector :inline :offset 1184) + (unknown-vector51 vector :inline :offset 1200) + (unknown-vector52 vector :inline :offset 1216) + (unknown-vector53 vector :inline :offset 1232) + (last-known-safe-ground vector :inline :offset 1248) + (unknown-vector55 vector :inline :offset 1264) + (unknown-dword10 int64 :offset 1280) + (unknown-dword11 int64 :offset 1288) + (unknown-float60 float :offset 1300) + (unknown-float61 float :offset 1304) + (unknown-float62 float :offset 1308) + (unknown-float63 float :offset 1312) + (unknown-float64 float :offset 1316) + (unknown-dword20 int64 :offset 1320) + (unknown-dword21 int64 :offset 1328) + (unknown-dword-coverage int64 :offset 1336) + (unknown-float-coverage-0 float :offset 1344) + (unknown-float-coverage-1 float :offset 1348) + (unknown-float-coverage-2 float :offset 1352) + (unknown-u32-coverage-0 uint32 :offset 1356) + (unknown-vector-coverage-0 vector :inline :offset 1376) + (unknown-vector-coverage-1 vector :inline :offset 1392) + (unknown-vector-coverage-2 vector :inline :offset 1440) + (unknown-vector-coverage-3 vector :inline :offset 1472) + (unknown-vector60 vector :inline :offset 1456) + (unknown-vector61 vector :inline :offset 1504) + (unknown-float70 float :offset 1520) + (unknown-float71 float :offset 1524) + (unknown-vector70 vector :inline :offset 1536) + (unknown-vector71 vector :inline :offset 1552) + (unknown-vector72 vector :inline :offset 1568) + (unknown-vector73 vector :inline :offset 1584) + (unknown-handle00 handle :offset 1600) + (unknown-sphere-array00 collide-shape-prim-sphere 3 :offset 1608) + (unknown-sphere00 collide-shape-prim-sphere :offset 1632) + (unknown-sphere01 collide-shape-prim-sphere :offset 1636) + (unknown-sphere02 collide-shape-prim-sphere :offset 1640) + (unknown-int50 int32 :offset 1656) + (unknown-dword30 int64 :offset 1664) + (unknown-dword31 int64 :offset 1672) + (unknown-dword32 int64 :offset 1680) + (unknown-dword33 int64 :offset 1688) + (unknown-dword34 int64 :offset 1696) + (unknown-dword35 int64 :offset 1704) + (unknown-dword36 int64 :offset 1712) + (unknown-float80 float :offset 1724) + (unknown-float81 float :offset 1728) + (unknown-float82 float :offset 1732) + (unknown-vector80 vector :inline :offset 1744) + (unknown-cspace00 cspace :inline :offset 1760) + (unknown-vector90 vector :inline :offset 1776) + (unknown-vector91 vector :inline :offset 1792) + (unknown-vector92 vector :inline :offset 1824) + (unknown-cspace10 cspace :inline :offset 1808) + (unknown-symbol00 symbol :offset 1840) + (unknown-float90 float :offset 1844) + (unknown-float91 float :offset 1848) + (unknown-vector-array10 vector 16 :inline :offset 1856) + (unknown-float100 float :offset 2112) + (unknown-int10 int32 :offset 2116) + (unknown-float110 float :offset 2120) + (unknown-vector100 vector :inline :offset 2128) + (unknown-vector101 vector :inline :offset 2144) + (unknown-dword40 int64 :offset 2160) + (unknown-dword41 int64 :offset 2168) + (unknown-handle10 handle :offset 2176) + (unknown-uint20 uint32 :offset 2184) + (unknown-spoolanim00 spool-anim :offset 2184) + (unknown-int20 int32 :offset 2184) + (unknown-symbol20 symbol :offset 2184) + (unknown-float120 float :offset 2184) + (unknown-int21 int32 :offset 2188) + (unknown-uint30 uint32 :offset 2188) + (unknown-float121 float :offset 2188) + (unknown-uint31 uint32 :offset 2192) + (unknown-float122 float :offset 2196) + (unknown-float123 float :offset 2200) + (unknown-float124 float :offset 2204) + (unknown-vector102 vector :inline :offset 2224) + (unknown-vector103 vector :inline :offset 2240) + (unknown-quaternion02 quaternion :inline :offset 2256) + (unknown-quaternion03 quaternion :inline :offset 2272) + (unknown-smush00 smush-control :inline :offset 2288) + (unknown-vector110 vector :inline :offset 2320) + (unknown-vector111 vector :inline :offset 2336) + (unknown-symbol30 symbol :offset 2384) + (unknown-int31 uint32 :offset 2384) + (unknown-dword50 int64 :offset 2392) + (unknown-dword51 int64 :offset 2400) + (unknown-pointer00 pointer :offset 2416) + (unknown-symbol40 symbol :offset 2428) + (unknown-dword60 int64 :offset 2432) + (unknown-dword61 int64 :offset 2440) + (unknown-dword62 int64 :offset 2448) + (unknown-dword63 int64 :offset 2456) + (unknown-halfword00 int16 :offset 2488) + (history-length int16 :offset 2490) + (history-data collide-history 128 :inline :offset-assert 2496) + (unknown-float140 float :offset 18944) + (unknown-dword70 int64 :offset 18952) + (unknown-int40 int32 :offset 18880) + (unknown-dword80 int64 :offset 18888) + (unknown-dword81 int64 :offset 18896) + (unknown-float130 float :offset 18904) + (unknown-float131 float :offset 18908) + (unknown-dword82 int64 :offset 18912) + (unknown-vector120 vector :inline :offset 18928) + (unknown-float150 float :offset 18944) + (unknown-vector121 vector :inline :offset 18960) + (unknown-int60 uint32 :offset 18976) + (unknown-soundid00 sound-id :offset 18980) + (unknown-float141 float :offset 18984) ) :method-count-assert 65 :size-assert #x4a2c diff --git a/test/decompiler/reference/engine/draw/process-drawable_REF.gc b/test/decompiler/reference/engine/draw/process-drawable_REF.gc index 4bf8bee75..a86095b29 100644 --- a/test/decompiler/reference/engine/draw/process-drawable_REF.gc +++ b/test/decompiler/reference/engine/draw/process-drawable_REF.gc @@ -1012,7 +1012,7 @@ (let ((gp-0 (the-as collide-shape (-> self root)))) (update-transforms! gp-0) (pull-riders! gp-0) - (respond-to-collisions! gp-0) + (do-push-aways! gp-0) ) 0 ) @@ -1022,7 +1022,7 @@ (ja-post) (let ((gp-0 (the-as collide-shape (-> self root)))) (update-transforms! gp-0) - (respond-to-collisions! gp-0) + (do-push-aways! gp-0) ) 0 ) diff --git a/test/decompiler/reference/engine/target/target_REF.gc b/test/decompiler/reference/engine/target/target_REF.gc index 023b92ebc..e05cce63c 100644 --- a/test/decompiler/reference/engine/target/target_REF.gc +++ b/test/decompiler/reference/engine/target/target_REF.gc @@ -111,7 +111,65 @@ ) ;; definition for function target-falling-anim-trans -;; ERROR: function was not converted to expressions. Cannot decompile. +;; INFO: Return type mismatch int vs none. +(defbehavior target-falling-anim-trans target () + (let ((v1-2 (if (> (-> self skel active-channels) 0) + (-> self skel root-channel 0 frame-group) + ) + ) + ) + (b! + (or (= v1-2 (-> self draw art-group data 38)) (= v1-2 (-> self draw art-group data 35))) + cfg-7 + :delay + (empty-form) + ) + ) + (ja-channel-push! 1 99) + (let ((v1-8 (-> self skel root-channel 0))) + (set! (-> v1-8 frame-group) (the-as art-joint-anim (-> self draw art-group data 38))) + ) + (b! #t cfg-23 :delay (nop!)) + (label cfg-7) + (cond + ((and (logtest? (-> self control status) 1) (not (= (if (> (-> self skel active-channels) 0) + (-> self skel root-channel 0 frame-group) + ) + (-> self draw art-group data 35) + ) + ) + ) + (ja-channel-push! 1 6) + (let ((v1-21 (-> self skel root-channel 0))) + (set! (-> v1-21 frame-group) (the-as art-joint-anim (-> self draw art-group data 35))) + ) + ) + ((= (if (> (-> self skel active-channels) 0) + (-> self skel root-channel 0 frame-group) + ) + (-> self draw art-group data 38) + ) + (let ((a0-23 (-> self skel root-channel 0))) + (set! (-> a0-23 param 0) (-> (new 'static 'array float 1 1.0) 0)) + (joint-control-channel-group-eval! a0-23 (the-as art-joint-anim #f) num-func-loop!) + ) + ) + ((= (if (> (-> self skel active-channels) 0) + (-> self skel root-channel 0 frame-group) + ) + (-> self draw art-group data 35) + ) + (let ((a0-28 (-> self skel root-channel 0))) + (set! (-> a0-28 param 0) (the float (+ (-> a0-28 frame-group data 0 length) -1))) + (set! (-> a0-28 param 1) (-> (new 'static 'array float 1 1.0) 0)) + (joint-control-channel-group-eval! a0-28 (the-as art-joint-anim #f) num-func-seek!) + ) + ) + ) + (label cfg-23) + 0 + (none) + ) ;; definition for function target-falling-trans ;; INFO: Return type mismatch int vs none. @@ -3204,7 +3262,7 @@ (-> *TARGET-bank* smack-surface-dist) (-> *TARGET-bank* smack-surface-height) (the-as process #f) - (the-as (state target) target-hit) + target-hit ) ) (if (and (logtest? (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) button0-rel 0) (pad-buttons x)) @@ -4275,7 +4333,7 @@ (-> *TARGET-bank* smack-surface-dist) (-> *TARGET-bank* smack-surface-height) (the-as process #f) - (the-as (state target) target-hit) + target-hit ) ) (if (zero? s5-0) @@ -4379,7 +4437,7 @@ (-> *TARGET-bank* smack-surface-dist) (-> *TARGET-bank* smack-surface-height) (the-as process #f) - (the-as (state target) target-hit) + target-hit ) ) (if (and (logtest? (-> *cpad-list* cpads (-> self control unknown-cpad-info00 number) button0-rel 0) diff --git a/test/decompiler/reference/levels/beach/lurkercrab_REF.gc b/test/decompiler/reference/levels/beach/lurkercrab_REF.gc index ca093f021..ae376a0db 100644 --- a/test/decompiler/reference/levels/beach/lurkercrab_REF.gc +++ b/test/decompiler/reference/levels/beach/lurkercrab_REF.gc @@ -118,7 +118,7 @@ 16384.0 ) (the-as object (if (zero? (logand (-> obj nav-enemy-flags) 256)) - (respond-to-collisions! (-> obj collide-info)) + (do-push-aways! (-> obj collide-info)) ) ) ) diff --git a/test/decompiler/reference/levels/beach/mayor_REF.gc b/test/decompiler/reference/levels/beach/mayor_REF.gc index f8d0fe1a5..095da5b59 100644 --- a/test/decompiler/reference/levels/beach/mayor_REF.gc +++ b/test/decompiler/reference/levels/beach/mayor_REF.gc @@ -728,7 +728,7 @@ ((the-as (function none) t9-0)) ) ) - (respond-to-collisions! (-> self root-override)) + (do-push-aways! (-> self root-override)) (none) ) ) diff --git a/test/decompiler/reference/levels/beach/pelican_REF.gc b/test/decompiler/reference/levels/beach/pelican_REF.gc index 08a24beea..80d78edfd 100644 --- a/test/decompiler/reference/levels/beach/pelican_REF.gc +++ b/test/decompiler/reference/levels/beach/pelican_REF.gc @@ -708,7 +708,7 @@ (vector-seek! gp-0 a1-0 (* (-> self state-float 0) (-> *display* seconds-per-frame))) (move-to-point! (-> self root-override) gp-0) ) - (respond-to-collisions! (-> self root-override)) + (do-push-aways! (-> self root-override)) (seek-toward-heading-vec! (-> self root-override) (-> self path-vector) 131072.0 300) (spool-push *art-control* "pelican-spit-ext" 0 self -99.0) (none) diff --git a/test/decompiler/reference/levels/flut_common/target-flut_REF.gc b/test/decompiler/reference/levels/flut_common/target-flut_REF.gc index a024e2ac6..c4c9b4c84 100644 --- a/test/decompiler/reference/levels/flut_common/target-flut_REF.gc +++ b/test/decompiler/reference/levels/flut_common/target-flut_REF.gc @@ -1702,12 +1702,7 @@ ) (!= (-> self control unknown-uint31) 1) ) - (target-shoved - (meters 2.0) - (-> *TARGET-bank* smack-surface-height) - (the-as process #f) - (the-as (state target) target-flut-hit) - ) + (target-shoved (meters 2.0) (-> *TARGET-bank* smack-surface-height) (the-as process #f) target-flut-hit) ) (if (and (logtest? (-> self water flags) 512) (zero? (mod (- (-> *display* base-frame-counter) (-> self state-time)) 21)) diff --git a/test/decompiler/reference/levels/jungle/darkvine_REF.gc b/test/decompiler/reference/levels/jungle/darkvine_REF.gc index dc98aec2b..0ea6d7874 100644 --- a/test/decompiler/reference/levels/jungle/darkvine_REF.gc +++ b/test/decompiler/reference/levels/jungle/darkvine_REF.gc @@ -164,7 +164,7 @@ (let ((v1-0 arg2)) (the-as object (cond ((= v1-0 'touch) - (respond-to-collisions! (-> self root-override)) + (do-push-aways! (-> self root-override)) (when (-> self dangerous) (let ((a1-1 (new 'stack-no-clear 'event-message-block))) (set! (-> a1-1 from) self) @@ -184,7 +184,7 @@ ((!= v1-10 (-> self player-attack-id)) (set! (-> self player-attack-id) (the-as int v1-10)) (when (-> self vulnerable) - (respond-to-collisions! (-> self root-override)) + (do-push-aways! (-> self root-override)) (go darkvine-retreat) ) ) diff --git a/test/decompiler/reference/levels/jungle/junglesnake_REF.gc b/test/decompiler/reference/levels/jungle/junglesnake_REF.gc index 4da215474..fb9cbf0bd 100644 --- a/test/decompiler/reference/levels/jungle/junglesnake_REF.gc +++ b/test/decompiler/reference/levels/jungle/junglesnake_REF.gc @@ -178,7 +178,7 @@ ) ) (else - (respond-to-collisions! (-> self root-override)) + (do-push-aways! (-> self root-override)) (let ((a1-3 (new 'stack-no-clear 'event-message-block))) (set! (-> a1-3 from) self) (set! (-> a1-3 num-params) 2) @@ -784,7 +784,7 @@ junglesnake-default-event-handler (let ((v1-4 (-> (the-as collide-shape-prim-group (-> obj root-override root-prim)) prims 0))) (logior! (-> v1-4 prim-core action) (collide-action solid)) ) - (respond-to-collisions! (-> obj root-override)) + (do-push-aways! (-> obj root-override)) ) 0 (none) diff --git a/test/decompiler/reference/levels/jungleb/plant-boss_REF.gc b/test/decompiler/reference/levels/jungleb/plant-boss_REF.gc index 49fab44f2..8daa5f243 100644 --- a/test/decompiler/reference/levels/jungleb/plant-boss_REF.gc +++ b/test/decompiler/reference/levels/jungleb/plant-boss_REF.gc @@ -2476,7 +2476,7 @@ :post (behavior () (plant-boss-post) - (respond-to-collisions! (-> self root-override)) + (do-push-aways! (-> self root-override)) (none) ) ) @@ -2517,7 +2517,7 @@ (let ((gp-1 (-> *display* base-frame-counter))) (until (>= (- (-> *display* base-frame-counter) gp-1) 1500) (transform-post) - (respond-to-collisions! (-> self root-override)) + (do-push-aways! (-> self root-override)) (suspend) ) ) diff --git a/test/decompiler/reference/levels/misty/balloonlurker_REF.gc b/test/decompiler/reference/levels/misty/balloonlurker_REF.gc index 1c5895ce3..07ed5ca9e 100644 --- a/test/decompiler/reference/levels/misty/balloonlurker_REF.gc +++ b/test/decompiler/reference/levels/misty/balloonlurker_REF.gc @@ -547,7 +547,7 @@ (-> self root-overlay) (the-as uint 1) ) - (respond-to-collisions! (-> self root-overlay)) + (do-push-aways! (-> self root-overlay)) (let ((a1-3 (new 'stack-no-clear 'event-message-block))) (set! (-> a1-3 from) self) (set! (-> a1-3 num-params) 2) diff --git a/test/decompiler/reference/levels/sunken/helix-water_REF.gc b/test/decompiler/reference/levels/sunken/helix-water_REF.gc index 8997245cf..d96539786 100644 --- a/test/decompiler/reference/levels/sunken/helix-water_REF.gc +++ b/test/decompiler/reference/levels/sunken/helix-water_REF.gc @@ -404,7 +404,7 @@ (set! (-> gp-1 y) 0.0) (vector-normalize! gp-1 4096.0) (move-by-vector! (-> *target* control) gp-1) - (respond-to-collisions! (-> self root-override)) + (do-push-aways! (-> self root-override)) (detect-riders! (-> self root-override)) ) ) diff --git a/test/decompiler/reference/levels/swamp/swamp-obs_REF.gc b/test/decompiler/reference/levels/swamp/swamp-obs_REF.gc index da103b480..a217c2405 100644 --- a/test/decompiler/reference/levels/swamp/swamp-obs_REF.gc +++ b/test/decompiler/reference/levels/swamp/swamp-obs_REF.gc @@ -209,7 +209,7 @@ (set! (-> a1-0 to) (the-as process 1)) (set! (-> a1-0 from) (the-as process *touching-list*)) (if (find-overlapping-shapes (-> self root-override) (the-as overlaps-others-params a1-0)) - (respond-to-collisions! (-> self root-override)) + (do-push-aways! (-> self root-override)) ) ) (none) diff --git a/test/decompiler/reference/levels/village1/yakow_REF.gc b/test/decompiler/reference/levels/village1/yakow_REF.gc index b470f3a08..00341ec95 100644 --- a/test/decompiler/reference/levels/village1/yakow_REF.gc +++ b/test/decompiler/reference/levels/village1/yakow_REF.gc @@ -213,7 +213,7 @@ ) ) (when (and v1-2 (< 8192.0 (- (-> v1-2 root trans y) (-> self root-override trans y)))) - (respond-to-collisions! (-> self root-override)) + (do-push-aways! (-> self root-override)) (send-shove-back (-> self root-override) arg0