diff --git a/.vscode/settings.json b/.vscode/settings.json index 7a44546b29..08ff5ce5e2 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -58,13 +58,21 @@ } ] }, + "(\\d+\\(sp\\))": { + "filterFileRegex": ".*ir2\\.asm", + "decorations": [ + { + "overviewRulerColor": "transparent", + "color": "#00ff08" + } + ] + }, "(sp, -?\\d+ )": { "filterFileRegex": ".*ir2\\.asm", "decorations": [ { "overviewRulerColor": "transparent", - "color": "#00ff08", - "fontWeight": "bold" + "color": "#00ff08" } ] }, @@ -282,7 +290,18 @@ } ] }, - "(WARN:.*)": { + "(WARN: Unsupported.*)": { + "filterFileRegex": ".*ir2\\.asm", + "decorations": [ + { + "overviewRulerColor": "#ea00ff", + "color": "#ea00ff", + "fontWeight": "bold", + "filterFileRegex": ".*ir2\\.asm" + } + ] + }, + "(WARN: (?!Unsupported).*)": { "filterFileRegex": ".*ir2\\.asm", "decorations": [ { diff --git a/Taskfile.yml b/Taskfile.yml index a6f5c6a09c..229c5d42d0 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -9,7 +9,7 @@ tasks: ignore_error: true run-game: cmds: - - ./out/build/Release/bin/gk.exe -fakeiso -debug + - ./out/build/Release/bin/gk.exe -fakeiso -debug -v run-game-headless: cmds: - ./out/build/Release/bin/gk.exe -fakeiso -debug -nodisplay diff --git a/decompiler/IR2/AtomicOp.cpp b/decompiler/IR2/AtomicOp.cpp index 8deeb63dd6..f0c0ea12da 100644 --- a/decompiler/IR2/AtomicOp.cpp +++ b/decompiler/IR2/AtomicOp.cpp @@ -306,6 +306,9 @@ std::string get_simple_expression_op_name(SimpleExpression::Kind kind) { return "vec3dot"; case SimpleExpression::Kind::VECTOR_4_DOT: return "vec4dot"; + case SimpleExpression::Kind::SET_ON_LESS_THAN: + case SimpleExpression::Kind::SET_ON_LESS_THAN_IMM: + return "set-on-less-than"; default: assert(false); return {}; @@ -367,6 +370,9 @@ int get_simple_expression_arg_count(SimpleExpression::Kind kind) { case SimpleExpression::Kind::VECTOR_3_DOT: case SimpleExpression::Kind::VECTOR_4_DOT: return 2; + case SimpleExpression::Kind::SET_ON_LESS_THAN: + case SimpleExpression::Kind::SET_ON_LESS_THAN_IMM: + return 2; default: assert(false); return -1; @@ -512,7 +518,10 @@ AsmOp::AsmOp(Instruction instr, int my_idx) : AtomicOp(my_idx), m_instr(std::mov if (src.is_reg()) { auto reg = src.get_reg(); if (reg.get_kind() == Reg::FPR || reg.get_kind() == Reg::GPR || reg.get_kind() == Reg::VF) { - m_src[i] = RegisterAccess(AccessMode::READ, reg, my_idx, true); + if (reg != Register(Reg::GPR, Reg::R0) || + (m_instr.kind == InstructionKind::PCPYUD || m_instr.kind == InstructionKind::PEXTUW)) { + m_src[i] = RegisterAccess(AccessMode::READ, reg, my_idx, true); + } } } } diff --git a/decompiler/IR2/AtomicOp.h b/decompiler/IR2/AtomicOp.h index e8c36ffc0e..e48e7efece 100644 --- a/decompiler/IR2/AtomicOp.h +++ b/decompiler/IR2/AtomicOp.h @@ -235,7 +235,9 @@ class SimpleExpression { VECTOR_CROSS, SUBU_L32_S7, // use SUBU X, src0, s7 to check if lower 32-bits are s7. VECTOR_3_DOT, - VECTOR_4_DOT + VECTOR_4_DOT, + SET_ON_LESS_THAN, + SET_ON_LESS_THAN_IMM }; // how many arguments? diff --git a/decompiler/IR2/AtomicOpTypeAnalysis.cpp b/decompiler/IR2/AtomicOpTypeAnalysis.cpp index 6066cc6ff9..5f525dccb8 100644 --- a/decompiler/IR2/AtomicOpTypeAnalysis.cpp +++ b/decompiler/IR2/AtomicOpTypeAnalysis.cpp @@ -828,7 +828,8 @@ TypeState AsmOp::propagate_types_internal(const TypeState& input, } // sllv out, in, r0 - if (m_instr.kind == InstructionKind::SLLV && m_src[1]->reg() == Register(Reg::GPR, Reg::R0)) { + if (m_instr.kind == InstructionKind::SLLV && + instruction().src[1].is_reg(Register(Reg::GPR, Reg::R0))) { auto type = dts.ts.lookup_type(result.get(m_src[0]->reg()).typespec()); auto as_bitfield = dynamic_cast(type); if (as_bitfield) { diff --git a/decompiler/IR2/Form.h b/decompiler/IR2/Form.h index 5c32d372e1..15908907a0 100644 --- a/decompiler/IR2/Form.h +++ b/decompiler/IR2/Form.h @@ -572,6 +572,10 @@ class ConditionElement : public FormElement { FormPool& pool, const std::vector& source_forms, const std::vector& types); + FormElement* make_geq_zero_unsigned_check_generic(const Env& env, + FormPool& pool, + const std::vector& source_forms, + const std::vector& types); FormElement* make_geq_zero_signed_check_generic(const Env& env, FormPool& pool, const std::vector& source_forms, diff --git a/decompiler/IR2/FormExpressionAnalysis.cpp b/decompiler/IR2/FormExpressionAnalysis.cpp index 5a6933e939..056e06210f 100644 --- a/decompiler/IR2/FormExpressionAnalysis.cpp +++ b/decompiler/IR2/FormExpressionAnalysis.cpp @@ -1065,7 +1065,8 @@ void SimpleExpressionElement::update_from_stack_add_i(const Env& env, result->push_back(pool.alloc_element(args.at(1), rd_ok.addr_of, tokens)); return; } else { - lg::error("Bad is {}\n", args.at(0)->to_string(env)); + // TODO - output error to IR + lg::error("Bad {} at OP: {}\n", args.at(0)->to_string(env), m_my_idx); throw std::runtime_error("Failed to match product_with_constant inline array access 2."); } } @@ -4022,6 +4023,31 @@ FormElement* ConditionElement::make_geq_zero_signed_check_generic( } } +FormElement* ConditionElement::make_geq_zero_unsigned_check_generic( + const Env& env, + FormPool& pool, + const std::vector& source_forms, + const std::vector& types) { + assert(source_forms.size() == 1); + // (>= (shl (the-as int iter) 62) 0) -> (not (pair? iter)) + + // match (shl [(the-as int [x]) | [x]] 62) + auto shift_match = + match(Matcher::op(GenericOpMatcher::fixed(FixedOperatorKind::SHL), + { + Matcher::match_or({Matcher::cast("uint", Matcher::any(0)), + Matcher::any(0)}), // the val + Matcher::integer(62) // get the bit in the highest position. + }), + source_forms.at(0)); + + auto casted = make_casts_if_needed(source_forms, types, TypeSpec("uint"), pool, env); + auto zero = + pool.alloc_single_element_form(nullptr, SimpleAtom::make_int_constant(0)); + casted.push_back(zero); + return pool.alloc_element(GenericOperator::make_fixed(FixedOperatorKind::GEQ), + casted); +} FormElement* ConditionElement::make_generic(const Env& env, FormPool& pool, const std::vector& source_forms, @@ -4092,6 +4118,10 @@ FormElement* ConditionElement::make_generic(const Env& env, return make_geq_zero_signed_check_generic(env, pool, source_forms, types); } + case IR2_Condition::Kind::GEQ_ZERO_UNSIGNED: { + return make_geq_zero_unsigned_check_generic(env, pool, source_forms, types); + } + case IR2_Condition::Kind::GREATER_THAN_ZERO_UNSIGNED: { auto casted = make_casts_if_needed(source_forms, types, TypeSpec("uint"), pool, env); auto zero = pool.alloc_single_element_form( @@ -4352,13 +4382,10 @@ void push_asm_sllv_to_stack(const AsmOp* op, auto dst = op->dst(); assert(dst.has_value()); - auto sav = op->src(1); - assert(sav.has_value()); - auto arg0_type = env.get_variable_type(*var, true); auto type_info = env.dts->ts.lookup_type(arg0_type); auto bitfield_info = dynamic_cast(type_info); - if (sav->reg() == Register(Reg::GPR, Reg::R0)) { + if (op->instruction().src[1].is_reg(Register(Reg::GPR, Reg::R0))) { if (bitfield_info) { auto base = pop_to_forms({*var}, env, pool, stack, true).at(0); auto read_elt = pool.alloc_element(base, arg0_type); diff --git a/decompiler/IR2/OpenGoalMapping.cpp b/decompiler/IR2/OpenGoalMapping.cpp index ecf5792479..21d89f3f60 100644 --- a/decompiler/IR2/OpenGoalMapping.cpp +++ b/decompiler/IR2/OpenGoalMapping.cpp @@ -18,7 +18,7 @@ const std::map MIPS_ASM_TO_OPEN_GOAL_FUN {InstructionKind::PAND, {".pand", {}}}, // Parallel Pack - {InstructionKind::PPACH, {".ppach", {}}}, + {InstructionKind::PPACH, {".ppach", {MOD::QWORD_CAST}}}, // Parallel Compares {InstructionKind::PCEQB, {".pceqb", {}}}, @@ -42,6 +42,11 @@ const std::map MIPS_ASM_TO_OPEN_GOAL_FUN // lots of implicit logic in OpenGOAL depending on argument types! {InstructionKind::MFC1, {".mov", {}}}, + {InstructionKind::MOVN, {"move-if-not-zero", {}}}, // s7 special case is handled elsewhere + {InstructionKind::SLT, {"set-on-less-than", {}}}, + {InstructionKind::SLTI, {"set-on-less-than", {}}}, + {InstructionKind::SRA, {"shift-arith-right-32", {}}}, + // ---- COP2 ----- // TODO - VMOVE supports dest, but OpenGOAL does NOT yet! {InstructionKind::VMOVE, {".mov.vf", {MOD::DEST_MASK}}}, @@ -143,11 +148,11 @@ bool OpenGOALAsm::Function::allows_modifier(InstructionModifiers mod) { return std::find(modifiers.begin(), modifiers.end(), mod) != modifiers.end(); } -OpenGOALAsm::OpenGOALAsm(Instruction _instr) : instr(_instr) { - if (MIPS_ASM_TO_OPEN_GOAL_FUNCS.count(instr.kind) == 0) { +OpenGOALAsm::OpenGOALAsm(Instruction _instr) : m_instr(_instr) { + if (MIPS_ASM_TO_OPEN_GOAL_FUNCS.count(m_instr.kind) == 0) { valid = false; } else { - func = MIPS_ASM_TO_OPEN_GOAL_FUNCS.at(instr.kind); + func = MIPS_ASM_TO_OPEN_GOAL_FUNCS.at(m_instr.kind); if (func.funcTemplate.rfind("TODO", 0) == 0) { todo = true; } @@ -157,11 +162,11 @@ OpenGOALAsm::OpenGOALAsm(Instruction _instr) : instr(_instr) { OpenGOALAsm::OpenGOALAsm(Instruction _instr, std::optional _dst, const std::vector>& _src) - : instr(_instr), m_dst(_dst), m_src(_src) { - if (MIPS_ASM_TO_OPEN_GOAL_FUNCS.count(instr.kind) == 0) { + : m_instr(_instr), m_dst(_dst), m_src(_src) { + if (MIPS_ASM_TO_OPEN_GOAL_FUNCS.count(m_instr.kind) == 0) { valid = false; } else { - func = MIPS_ASM_TO_OPEN_GOAL_FUNCS.at(instr.kind); + func = MIPS_ASM_TO_OPEN_GOAL_FUNCS.at(m_instr.kind); if (func.funcTemplate.rfind("TODO", 0) == 0) { todo = true; } @@ -172,8 +177,8 @@ std::string OpenGOALAsm::full_function_name() { std::string func_name = func.funcTemplate; // OpenGOAL uses the function name for broadcast specification if (func.allows_modifier(MOD::BROADCAST)) { - if (instr.cop2_bc != 0xff) { - std::string bc = std::string(1, instr.cop2_bc_to_char()); + if (m_instr.cop2_bc != 0xff) { + std::string bc = std::string(1, m_instr.cop2_bc_to_char()); func_name = fmt::format(func_name, bc); } } @@ -186,9 +191,9 @@ std::vector OpenGOALAsm::get_args(const std::vector named_args; bool got_fsf = false; - for (int i = 0; i < instr.n_src; i++) { + for (int i = 0; i < m_instr.n_src; i++) { auto v = m_src.at(i); - InstructionAtom atom = instr.get_src(i); + InstructionAtom atom = m_instr.get_src(i); if (v.has_value()) { // Normal register / constant args @@ -219,7 +224,19 @@ std::vector OpenGOALAsm::get_args(const std::vector OpenGOALAsm::get_args(const std::vector OpenGOALAsm::get_args(const std::vectorreg(), m_dst->idx()); + args.push_back(ra.to_form(env)); + } + args.insert(args.end(), named_args.begin(), named_args.end()); return args; } diff --git a/decompiler/IR2/OpenGoalMapping.h b/decompiler/IR2/OpenGoalMapping.h index 0b633da20d..2b14735482 100644 --- a/decompiler/IR2/OpenGoalMapping.h +++ b/decompiler/IR2/OpenGoalMapping.h @@ -22,7 +22,8 @@ struct OpenGOALAsm { FSF, OFFSET, SWAP_FIRST_TWO_SOURCE_ARGS, - ACC_THIRD_SRC_ARG + ACC_THIRD_SRC_ARG, + QWORD_CAST }; struct Function { @@ -40,7 +41,7 @@ struct OpenGOALAsm { bool valid = true; bool todo = false; - Instruction instr; + Instruction m_instr; std::optional m_dst; std::vector> m_src; OpenGOALAsm::Function func; diff --git a/decompiler/analysis/atomic_op_builder.cpp b/decompiler/analysis/atomic_op_builder.cpp index 049543e02f..1c766d3451 100644 --- a/decompiler/analysis/atomic_op_builder.cpp +++ b/decompiler/analysis/atomic_op_builder.cpp @@ -2201,4 +2201,4 @@ FunctionAtomicOps convert_function_to_atomic_ops( assert(func.basic_blocks.size() == result.block_id_to_first_atomic_op.size()); return result; } -} // namespace decompiler \ No newline at end of file +} // namespace decompiler diff --git a/decompiler/analysis/inline_asm_rewrite.cpp b/decompiler/analysis/inline_asm_rewrite.cpp index 2701f27d70..16f328cff3 100644 --- a/decompiler/analysis/inline_asm_rewrite.cpp +++ b/decompiler/analysis/inline_asm_rewrite.cpp @@ -42,7 +42,7 @@ bool rewrite_inline_asm_instructions(Form* top_level_form, /*lg::warn("[ASM Re-Write] - Unsupported inline assembly instruction kind - [{}]", asmOp.instr.kind);*/ f.warnings.general_warning("Unsupported inline assembly instruction kind - [{}]", - asmOp.instr.to_string(f.ir2.env.file->labels)); + asmOp.m_instr.to_string(f.ir2.env.file->labels)); new_entries.push_back(entry); continue; } else if (asmOp.todo) { diff --git a/decompiler/config/all-types.gc b/decompiler/config/all-types.gc index f88e956ec4..cc2afe938f 100644 --- a/decompiler/config/all-types.gc +++ b/decompiler/config/all-types.gc @@ -647,20 +647,24 @@ :bitfield #t :type uint32 (display-marks 0) - (bit1 1) - (bit2 2) - (bit3 3) ;; TODO - nav-enemy::45 - (bit4 4) - (bit5 5) ;; TODO - nav-enemy::45 - (bit6 6) ;; TODO - nav-enemy::45 - (bit7 7) ;; TODO - nav-enemy::45 + (bit1 1) ;; TODO - nav-control::9 + (bit2 2) ;; TODO - nav-control::9 + (bit3 3) ;; TODO - nav-enemy::45 | nav-control::9 + (bit4 4) ;; TODO - nav-control::9 + (bit5 5) ;; TODO - nav-enemy::45 | ;; TODO - nav-control::9 + (bit6 6) ;; TODO - nav-enemy::45 | ;; TODO - nav-control::9 + (bit7 7) ;; TODO - nav-enemy::45 | ;; TODO - nav-control::9 (bit8 8) + (bit9 9) ;; TODO - nav-control::14 | 11 (bit10 10) ;; TODO - nav-enemy::nav-enemy-patrol-post + (bit11 11) ;; TODO - nav-control::28 (bit12 12) ;; TODO - rolling-lightning-mole::(enter nav-enemy-chase fleeing-nav-enemy) (bit13 13) - (bit17 17) - (bit19 19) ;; TODO - nav-enemy::lambda::17 - (bit21 21) + (bit17 17) ;; TODO - nav-control::11 + (bit18 18) ;; TODO - nav-control::11 + (bit19 19) ;; TODO - nav-control::11 | 17 + (bit20 20) ;; TODO - nav-mesh::28 + (bit21 21) ;; TODO - nav-control::19 ) (defenum task-status @@ -1959,7 +1963,7 @@ (deftype vector4w-3 (structure) ((data int32 12 :score -9999 :offset-assert 0) (quad uint128 3 :offset 0) - (vector vector4w 3 :inline :offset 0) + (vector vector4w 3 :inline :score 100 :offset 0) ) :method-count-assert 9 :size-assert #x30 @@ -10231,6 +10235,7 @@ (declare-type sparticle-launch-control basic) (declare-type water-control basic) (declare-type collide-shape basic) +(declare-type nav-control basic) (deftype process-drawable (process) ((root trsqv :offset-assert 112) (node-list cspace-array :offset-assert 116) @@ -11182,6 +11187,54 @@ (mother-spider 13) (cak-14 14) ;; unused (blue-eco-suck 15) ;; manipy, orb-cache-top, + (unknown-16 16) + (unknown-17 17) + (unknown-18 18) + (unknown-19 19) + (unknown-20 20) + (unknown-21 21) + (unknown-22 22) + (unknown-23 23) + (unknown-24 24) + (unknown-25 25) + (unknown-26 26) + (unknown-27 27) + (unknown-28 28) + (unknown-29 29) + (unknown-30 30) + (unknown-31 31) + (unknown-32 32) + (unknown-33 33) + (unknown-34 34) + (unknown-35 35) + (unknown-36 36) + (unknown-37 37) + (unknown-38 38) + (unknown-39 39) + (unknown-40 40) + (unknown-41 41) + (unknown-42 42) + (unknown-43 43) + (unknown-44 44) + (unknown-45 45) + (unknown-46 46) + (unknown-47 47) + (unknown-48 48) + (unknown-49 49) + (unknown-50 50) + (unknown-51 51) + (unknown-52 52) + (unknown-53 53) + (unknown-54 54) + (unknown-55 55) + (unknown-56 56) + (unknown-57 57) + (unknown-58 58) + (unknown-59 59) + (unknown-60 60) + (unknown-61 61) + (unknown-62 62) + (unknown-63 63) ) (defenum collide-action @@ -15257,6 +15310,7 @@ (adj-poly uint8 3 :offset-assert 4) (pat uint8 :offset-assert 7) ) + :pack-me :method-count-assert 9 :size-assert #x8 :flag-assert #x900000008 @@ -15285,10 +15339,10 @@ (next-poly nav-poly :offset-assert 52) (len meters :offset-assert 56) (last-edge int8 :offset-assert 60) - (terminated basic :offset-assert 64) - (reached-dest basic :offset-assert 68) - (hit-boundary basic :offset-assert 72) - (hit-gap basic :offset-assert 76) + (terminated symbol :offset-assert 64) ;; TODO - guesses + (reached-dest symbol :offset-assert 68) ;; TODO - guesses + (hit-boundary symbol :offset-assert 72) ;; TODO - guesses + (hit-gap symbol :offset-assert 76) ;; TODO - guesses ) :method-count-assert 9 :size-assert #x50 @@ -15306,7 +15360,7 @@ ) (deftype clip-travel-vector-to-mesh-return-info (structure) - ((found-boundary basic :offset-assert 0) + ((found-boundary symbol :offset-assert 0) (intersection vector :inline :offset-assert 16) (boundary-normal vector :inline :offset-assert 32) (prev-normal vector :inline :offset-assert 48) @@ -15366,46 +15420,60 @@ (deftype nav-mesh (basic) ((user-list engine :offset-assert 4) - (poly-lookup-history uint8 2 :offset-assert 8) + (poly-lookup-history uint8 2 :offset-assert 8) (debug-time uint8 :offset-assert 10) (static-sphere-count uint8 :offset-assert 11) - (static-sphere uint32 :offset-assert 12) + (static-sphere (inline-array nav-sphere) :offset-assert 12) (bounds sphere :inline :offset-assert 16) (origin vector :inline :offset-assert 32) (cache nav-lookup-elem 4 :inline :offset-assert 48) ;; guess on type (node-count int32 :offset-assert 176) - (nodes uint32 :offset-assert 180) + (nodes (inline-array nav-node) :offset-assert 180) (vertex-count int32 :offset-assert 184) - (vertex (inline-array vector) :offset-assert 188) + (vertex (inline-array nav-vertex) :offset-assert 188) (poly-count int32 :offset-assert 192) - (poly uint32 :offset-assert 196) - (route uint32 :offset-assert 200) + (poly (inline-array nav-poly) :offset-assert 196) + (route (inline-array vector4ub) :offset-assert 200) ;; this is a guess, it's probably wrong -- but its something with a uint8 at offset 0 ) :method-count-assert 30 :size-assert #xcc :flag-assert #x1e000000cc (:methods - (dummy-9 () none 9) - (dummy-10 () none 10) - (dummy-11 () none 11) - (dummy-12 () none 12) - (dummy-13 (_type_) none 13) - (dummy-14 () none 14) - (dummy-15 () none 15) - (dummy-16 () none 16) - (dummy-17 (_type_) none 17) - (dummy-18 () none 18) + (tri-centroid-world (_type_ nav-poly vector) vector 9) ;; finds the centroid of the given triangle, in the "world" coordinate system. + (tri-centroid-local (_type_ nav-poly vector) vector 10) ;; finds the centroid of the given triangle, in the local nav-mesh coordinate system. + (get-adj-poly (_type_ nav-poly nav-poly symbol) nav-poly 11) + (setup-portal (_type_ nav-poly nav-poly nav-route-portal) object 12) ;; sets up a portal between two polys. + (initialize-mesh! (_type_) none 13) + (move-along-nav-ray! (_type_ nav-ray) none 14) ;; think this updates the current position in a nav-ray, and updates which triangle you're in. + ;; this takes in a point/direction/distance, and see what would happen if you tried to move this way. + ;; it returns the distance you can go before one of these happens: + ;; - you reach the destination + ;; - you hit a nav mesh boundary/gap + ;; - you cross 15 triangles. + (try-move-along-ray (_type_ nav-poly vector vector float) meters 15) + (TODO-RENAME-16 (_type_ vector nav-poly vector symbol float clip-travel-vector-to-mesh-return-info) none 16) + (update-route-table (_type_) none 17) ;; (initialization related) + (dummy-18 (_type_ int vector int (pointer int8) int) none 18) ;; something to do with routes. (compute-bounding-box (_type_ vector vector) none 19) - (dummy-20 () none 20) - (dummy-21 () none 21) - (dummy-22 () none 22) - (dummy-23 () none 23) - (dummy-24 () none 24) - (dummy-25 () none 25) - (dummy-26 () none 26) - (dummy-27 () none 27) - (dummy-28 () none 28) - (dummy-29 () none 29) + (debug-draw-poly (_type_ nav-poly rgba) none 20) ;; TODO - is rgba a vector4w? + (point-in-poly? (_type_ nav-poly vector) symbol 21) ;; is the point inside of the triangle? + (find-opposite-vertices (_type_ nav-poly nav-poly) uint 22) ;; given two triangles that share an edge, get the indices of the two vertices that aren't part of the edge. + (dummy-23 (_type_ nav-poly vector vector vector nav-route-portal) vector 23) + (closest-point-on-boundary (_type_ nav-poly vector vector) vector 24) ;; find the closest point on the perimeter of the triangle. + (project-point-into-tri-3d (_type_ nav-poly vector vector) none 25) ;; will move a 3D point in space to the surface of this nav-poly + ;; Looking from the top down, is the point inside the nav-poly? + ;; - if the point is inside the triangle, returns that point. + ;; - if the point is outside the triangle, move it to the closest point (will be on the edge) + (project-point-into-tri-2d (_type_ nav-poly vector vector) vector 26) + ;; finds which triangle the given point is in. + ;; also has some caching stuff so if you look up the same point multiple times, it won't redo the work. + ;; I _think_ this is only an approximate check that may return #f even if you are inside. + ;; But, if it returns a poly, it will be right. + (find-poly-fast (_type_ vector meters) nav-poly 27) + (find-poly (_type_ vector meters (pointer nav-control-flags)) nav-poly 28) ;; The accurate version of find-poly (tries find-poly-fast first) + ;; checks to see if the triangle is in the mesh or not. + ;; not sure why it's separate from 27 (and such a different implementation). there might be some details I'm missing here. + (is-in-mesh? (_type_ vector float meters) symbol 29) ) ) @@ -15461,31 +15529,31 @@ :flag-assert #x24000000e0 (:methods (new (symbol type collide-shape int float) _type_) - (dummy-9 (_type_) none 9) + (debug-draw (_type_) none 9) (point-in-bounds? (_type_ vector) symbol 10) - (dummy-11 (_type_ vector) none 11) - (dummy-12 () none 12) - (dummy-13 (_type_ vector vector) vector 13) ;; see - puffer::20 + (dummy-11 (_type_ vector) vector 11) + (TODO-RENAME-12 (_type_ nav-gap-info) symbol 12) + (dummy-13 (_type_ vector vector) vector 13) ;; see - puffer::20 | second vector may be clip-travel-vector-to-mesh-return-info though (set-current-poly! (_type_ nav-poly) none 14) (set-target-pos! (_type_ vector) none 15) (dummy-16 (_type_ vector) nav-poly 16) ; see - nav-enemy-test-point-in-nav-mesh? - (dummy-17 (_type_ vector vector) none 17) - (TODO-RENAME-18 (_type_ vector) nav-poly 18) - (dummy-19 (_type_ vector collide-shape-moving vector float) none 19) - (dummy-20 () none 20) - (dummy-21 (_type_ vector) symbol 21) - (dummy-22 () none 22) - (dummy-23 (_type_ vector check-vector-collision-with-nav-spheres-info) float 23) ;; TODO - unconfirmed + (project-onto-nav-mesh (_type_ vector vector) vector 17) ;; moves point to nav-mesh. + (find-poly (_type_ vector) nav-poly 18) + (dummy-19 (_type_ vector collide-shape-moving vector float) none 19) ;; csm not trsqv? ret not vector? + (project-point-into-tri-3d (_type_ nav-poly vector vector) vector 20) + (TODO-RENAME-21 (_type_ vector) nav-poly 21) + (TODO-RENAME-22 (_type_ vector float) symbol 22) + (dummy-23 (_type_ vector check-vector-collision-with-nav-spheres-info) float 23) ;; TODO - unconfirmed maybe (dummy-23 (_type_ vector matrix) float 23) (dummy-24 (_type_ float clip-travel-vector-to-mesh-return-info) none 24) - (dummy-25 (_type_ vector float) symbol 25) ; see - nav-enemy-test-point-near-nav-mesh? - (dummy-26 (_type_) none 26) - (dummy-27 (_type_) none 27) - (dummy-28 (_type_ int) none 28) + (is-in-mesh? (_type_ vector float) symbol 25) ; see - nav-enemy-test-point-near-nav-mesh? + (TODO-RENAME-26 (_type_) none 26) ;; stub + (TODO-RENAME-27 (_type_) none 27) + (TODO-RENAME-28 (_type_ collide-kind) none 28) (should-display? (_type_) symbol 29) - (dummy-30 () none 30) - (dummy-31 () none 31) - (dummy-32 () none 32) - (dummy-33 () none 33) + (dummy-30 (_type_ vector vector vector) sphere 30) ;; TODO - last arg? - it has a float as the first arg, vector is a total guess + (intersect-ray-line-segment? (_type_ vector vector vector vector) symbol 31) + (TODO-ASM-32 (_type_ vector vector vector vector float) symbol 32) + (TODO-RENAME-33 (_type_ vector vector vector vector float) symbol 33) (dummy-34 () none 34) (dummy-35 (_type_ vector vector vector vector float) none 35) ) @@ -20601,149 +20669,149 @@ ;; - Types -; (deftype cfs-travel-vec (structure) -; ((dir vector :inline :offset-assert 0) -; (delta-angle float :offset-assert 16) -; ) -; :method-count-assert 9 -; :size-assert #x14 -; :flag-assert #x900000014 -; ) +(deftype cfs-travel-vec (structure) + ((dir vector :inline :offset-assert 0) + (delta-angle float :offset-assert 16) + ) + :method-count-assert 9 + :size-assert #x14 + :flag-assert #x900000014 + ) -; (deftype cfs-work (structure) -; ((desired-travel-dist float :offset-assert 0) -; (desired-angle float :offset-assert 4) -; (max-dist float :offset-assert 8) -; (old-angle float :offset-assert 12) -; (modified int32 :offset-assert 16) -; (blocked-mask uint64 :offset-assert 24) -; (travel vector :inline :offset-assert 32) -; (current vector :inline :offset-assert 48) -; (new-travel UNKNOWN 2 :offset-assert 64) -; (temp-travel UNKNOWN 2 :offset-assert 128) -; (prev-dir vector :inline :offset-assert 192) -; (attempt-dir vector :inline :offset-assert 208) -; (tangent UNKNOWN 2 :offset-assert 224) -; ) -; :method-count-assert 9 -; :size-assert #x100 -; :flag-assert #x900000100 -; ) +(deftype cfs-work (structure) + ((desired-travel-dist float :offset-assert 0) + (desired-angle float :offset-assert 4) + (max-dist float :offset-assert 8) + (old-angle float :offset-assert 12) + (modified int32 :offset-assert 16) + (blocked-mask uint64 :offset-assert 24) + (travel vector :inline :offset-assert 32) + (current vector :inline :offset-assert 48) + (new-travel cfs-travel-vec 2 :inline :offset-assert 64) + (temp-travel cfs-travel-vec 2 :inline :offset-assert 128) + (prev-dir vector :inline :offset-assert 192) + (attempt-dir vector :inline :offset-assert 208) + (tangent vector 2 :inline :offset-assert 224) + ) + :method-count-assert 9 + :size-assert #x100 + :flag-assert #x900000100 + ) -; (deftype nav-control-cfs-work (structure) -; ((in-dir vector :inline :offset-assert 0) -; (right-dir vector :inline :offset-assert 16) -; (best-dir UNKNOWN 2 :offset-assert 32) -; (temp-dir UNKNOWN 2 :offset-assert 64) -; (away-dir vector :inline :offset-assert 96) -; (best-dir-angle UNKNOWN 2 :offset-assert 112) -; (ignore-mask uint64 :offset-assert 120) -; (initial-ignore-mask uint64 :offset-assert 128) -; (i-sphere int32 :offset-assert 136) -; (i-first-sphere int32 :offset-assert 140) -; (i-inside-sphere int32 :offset-assert 144) -; (inside-sphere-dist float :offset-assert 148) -; (sign float :offset-assert 152) -; (travel-len float :offset-assert 156) -; (dist2 float :offset-assert 160) -; (inside-dist float :offset-assert 164) -; (rand-angle float :offset-assert 168) -; (dir-update basic :offset-assert 172) -; (debug-offset vector :inline :offset-assert 176) -; ) -; :method-count-assert 9 -; :size-assert #xc0 -; :flag-assert #x9000000c0 -; ) +(deftype nav-control-cfs-work (structure) + ((in-dir vector :inline :offset-assert 0) + (right-dir vector :inline :offset-assert 16) + (best-dir vector 2 :inline :offset-assert 32) + (temp-dir vector 2 :inline :offset-assert 64) + (away-dir vector :inline :offset-assert 96) + (best-dir-angle degrees 2 :offset-assert 112) ;; maybe degs? + (ignore-mask uint64 :offset-assert 120) + (initial-ignore-mask uint64 :offset-assert 128) + (i-sphere int32 :offset-assert 136) + (i-first-sphere int32 :offset-assert 140) + (i-inside-sphere int32 :offset-assert 144) + (inside-sphere-dist float :offset-assert 148) + (sign float :offset-assert 152) + (travel-len float :offset-assert 156) + (dist2 float :offset-assert 160) + (inside-dist float :offset-assert 164) + (rand-angle float :offset-assert 168) + (dir-update basic :offset-assert 172) + (debug-offset vector :inline :offset-assert 176) + ) + :method-count-assert 9 + :size-assert #xc0 + :flag-assert #x9000000c0 + ) ;; - Functions -(define-extern test-xz-point-on-line-segment? function) -(define-extern ray-ccw-line-segment-intersection? function) -(define-extern choose-travel-portal-vertex function) -(define-extern init-ray function) -(define-extern ray-line-segment-intersection? function) -(define-extern point-triangle-distance-min function) -(define-extern nav-mesh-update-route-table function) -(define-extern nav-mesh-lookup-route function) -(define-extern nav-ray-test-local? function) -(define-extern init-ray-local function) -(define-extern init-ray-dir-local function) -(define-extern circle-triangle-intersection? function) -(define-extern point-inside-rect? function) -(define-extern recursive-inside-poly function) -(define-extern point-inside-poly? function) -(define-extern vu-point-triangle-intersection? function) -(define-extern pke-nav-hack function) -(define-extern debug-report-nav-stats function) -(define-extern inc-mod3 function) -(define-extern dec-mod3 function) -(define-extern circle-triangle-intersection-proc? function) -(define-extern nav-ray-test function) -(define-extern clip-vector-to-halfspace! function) -(define-extern add-nav-sphere function) -(define-extern add-collide-shape-spheres function) -(define-extern circle-tangent-directions function) -(define-extern find-closest-circle-ray-intersection function) -(define-extern sign-bit function) -(define-extern compute-dir-parm function) -(define-extern debug-nav-validate-current-poly function) -(define-extern start-collect-nav function) -(define-extern end-collect-nav function) -(define-extern nav-sphere-from-cam function) +(define-extern test-xz-point-on-line-segment? (function vector vector vector float symbol)) +(define-extern ray-ccw-line-segment-intersection? (function vector vector vector vector symbol)) +(define-extern choose-travel-portal-vertex (function nav-mesh nav-route-portal nav-poly vector int)) +(define-extern init-ray (function nav-ray symbol)) +(define-extern ray-line-segment-intersection? (function vector vector vector vector symbol)) +(define-extern point-triangle-distance-min (function vector float (inline-array nav-vertex) float)) +(define-extern nav-mesh-update-route-table (function nav-mesh int int uint uint)) +(define-extern nav-mesh-lookup-route (function nav-mesh int int uint)) +(define-extern nav-ray-test-local? (function nav-mesh nav-poly vector vector symbol)) +(define-extern init-ray-local (function nav-ray nav-poly vector vector symbol)) +(define-extern init-ray-dir-local (function nav-ray nav-poly vector vector float symbol)) +(define-extern circle-triangle-intersection? (function vector float (inline-array nav-vertex) symbol)) +(define-extern point-inside-rect? (function nav-node vector float symbol)) +(define-extern recursive-inside-poly (function nav-mesh nav-node vector float int)) ;; unused +(define-extern point-inside-poly? (function nav-mesh uint vector float symbol)) +(define-extern vu-point-triangle-intersection? (function vector vector vector vector symbol)) +(define-extern pke-nav-hack (function none)) +(define-extern debug-report-nav-stats (function none)) ;; empty stub +(define-extern inc-mod3 (function int int)) +(define-extern dec-mod3 (function int int)) +(define-extern circle-triangle-intersection-proc? (function vector float (inline-array nav-vertex) symbol)) +(define-extern nav-ray-test (function nav-mesh nav-poly vector vector meters)) +(define-extern clip-vector-to-halfspace! (function vector float float float float)) +(define-extern add-nav-sphere (function nav-control vector none)) +(define-extern add-collide-shape-spheres (function nav-control collide-shape vector none)) ;; unused +(define-extern circle-tangent-directions (function vector vector vector vector vector)) +(define-extern find-closest-circle-ray-intersection (function vector vector float int (inline-array vector) int int)) ;; last int arg may be a float but...it does a logand with it +(define-extern sign-bit (function int int)) +(define-extern compute-dir-parm (function vector vector vector float)) +(define-extern debug-nav-validate-current-poly (function nav-mesh nav-poly vector symbol)) ;; unused +(define-extern start-collect-nav (function none)) +(define-extern end-collect-nav (function none)) +(define-extern nav-sphere-from-cam (function none)) ;; - Unknowns -;;(define-extern *edge-vert0-table* object) ;; unknown type -;;(define-extern *edge-vert1-table* object) ;; unknown type -;;(define-extern *edge-mask-table* object) ;; unknown type -;;(define-extern *nav-patch-route-table* object) ;; unknown type -;;(define-extern *nav-timer* object) ;; unknown type -;;(define-extern *nav-update-route-table-ray-count* object) ;; unknown type -;;(define-extern *nav-update-route-table-route-count* object) ;; unknown type -;;(define-extern *debug-traverse* object) ;; unknown type -;;(define-extern *debug-tests* object) ;; unknown type -;;(define-extern *color-red* object) ;; unknown type -;;(define-extern *color-blue* object) ;; unknown type -;;(define-extern *color-green* object) ;; unknown type -;;(define-extern *color-cyan* object) ;; unknown type -;;(define-extern *color-yellow* object) ;; unknown type -;;(define-extern *color-white* object) ;; unknown type -;;(define-extern *travel-timer* object) ;; unknown type -;;(define-extern *clip-for-spheres-timer* object) ;; unknown type -;;(define-extern *find-poly-timer* object) ;; unknown type -;;(define-extern *nav-timer-enable* object) ;; unknown type -;;(define-extern *nav-triangle-test-count* object) ;; unknown type -;;(define-extern *nav-last-triangle-test-count* object) ;; unknown type -;;(define-extern *debug-output* object) ;; unknown type -;;(define-extern *debug-nav* object) ;; unknown type -;;(define-extern *debug-nav-ray* object) ;; unknown type -;;(define-extern *debug-ray-offset* object) ;; unknown type -;;(define-extern *debug-nav-travel* object) ;; unknown type -;;(define-extern *color-black* object) ;; unknown type -;;(define-extern *color-gray* object) ;; unknown type -;;(define-extern *color-magenta* object) ;; unknown type -;;(define-extern *color-light-red* object) ;; unknown type -;;(define-extern *color-light-green* object) ;; unknown type -;;(define-extern *color-light-blue* object) ;; unknown type -;;(define-extern *color-light-cyan* object) ;; unknown type -;;(define-extern *color-light-magenta* object) ;; unknown type -;;(define-extern *color-light-yellow* object) ;; unknown type -;;(define-extern *color-dark-red* object) ;; unknown type -;;(define-extern *color-dark-green* object) ;; unknown type -;;(define-extern *color-dark-blue* object) ;; unknown type -;;(define-extern *color-dark-cyan* object) ;; unknown type -;;(define-extern *color-dark-magenta* object) ;; unknown type -;;(define-extern *color-dark-yellow* object) ;; unknown type -;;(define-extern *color-orange* object) ;; unknown type -;;(define-extern *nav-one-third* object) ;; unknown type -;;(define-extern *debug-offset* object) ;; unknown type -;;(define-extern *debug-ray-test* object) ;; unknown type -;;(define-extern *debug-ray-test-capture-mode* object) ;; unknown type -;;(define-extern *debug-ray-test-capture-output* object) ;; unknown type -;;(define-extern *test-ray-start-poly-id* object) ;; unknown type -;;(define-extern *test-ray-src-pos* object) ;; unknown type -;;(define-extern *test-ray-dest-pos* object) ;; unknown type +(define-extern *edge-vert0-table* (array int8)) +(define-extern *edge-vert1-table* (array int8)) +(define-extern *edge-mask-table* (array int8)) +(define-extern *nav-patch-route-table* symbol) +(define-extern *nav-timer* stopwatch) +(define-extern *nav-update-route-table-ray-count* int) +(define-extern *nav-update-route-table-route-count* int) +(define-extern *debug-traverse* int) +(define-extern *debug-tests* int) +(define-extern *color-red* rgba) +(define-extern *color-blue* rgba) +(define-extern *color-green* rgba) +(define-extern *color-cyan* rgba) +(define-extern *color-yellow* rgba) +(define-extern *color-white* rgba) +(define-extern *travel-timer* stopwatch) +(define-extern *clip-for-spheres-timer* stopwatch) +(define-extern *find-poly-timer* stopwatch) +(define-extern *nav-timer-enable* symbol) +(define-extern *nav-triangle-test-count* int) +(define-extern *nav-last-triangle-test-count* int) +(define-extern *debug-output* symbol) ;; TODO - could be wrong +(define-extern *debug-nav* symbol) +(define-extern *debug-nav-ray* nav-ray) +(define-extern *debug-ray-offset* vector) ;; TODO - or some other 4 word type +(define-extern *debug-nav-travel* symbol) ;; TODO - ?? +(define-extern *color-black* rgba) +(define-extern *color-gray* rgba) +(define-extern *color-magenta* rgba) +(define-extern *color-light-red* rgba) +(define-extern *color-light-green* rgba) +(define-extern *color-light-blue* rgba) +(define-extern *color-light-cyan* rgba) +(define-extern *color-light-magenta* rgba) +(define-extern *color-light-yellow* rgba) +(define-extern *color-dark-red* rgba) +(define-extern *color-dark-green* rgba) +(define-extern *color-dark-blue* rgba) +(define-extern *color-dark-cyan* rgba) +(define-extern *color-dark-magenta* rgba) +(define-extern *color-dark-yellow* rgba) +(define-extern *color-orange* rgba) +(define-extern *nav-one-third* vector) +(define-extern *debug-offset* vector) ;; TODO - or some other 4 word type +(define-extern *debug-ray-test* nav-ray) ;; TODO - ?? +(define-extern *debug-ray-test-capture-mode* symbol) ;; TODO - ?? +(define-extern *debug-ray-test-capture-output* symbol) ;; TODO - ?? +(define-extern *test-ray-start-poly-id* int) +(define-extern *test-ray-src-pos* vector) ;; TODO - or some other 4 word type +(define-extern *test-ray-dest-pos* vector) ;; TODO - or some other 4 word type ;; ---------------------- @@ -31883,11 +31951,11 @@ (define-extern lightning-mole-task-complete? (function symbol :behavior lightning-mole)) (define-extern fleeing-nav-enemy-clip-travel (function fleeing-nav-enemy vector symbol)) -(define-extern fleeing-nav-enemy-adjust-travel (function fleeing-nav-enemy vector)) +(define-extern fleeing-nav-enemy-adjust-travel (function fleeing-nav-enemy object vector)) ;; unused second arg (define-extern fleeing-nav-enemy-chase-post-func (function float :behavior fleeing-nav-enemy)) (define-extern fleeing-nav-enemy-adjust-nav-info (function float :behavior fleeing-nav-enemy)) -(define-extern find-adjacent-bounds-one function) -(define-extern find-adjacent-bounds (function basic clip-travel-vector-to-mesh-return-info none)) +(define-extern find-adjacent-bounds-one (function nav-mesh nav-poly int (array int8) (array int8) vector symbol)) +(define-extern find-adjacent-bounds (function nav-mesh clip-travel-vector-to-mesh-return-info none)) (define-extern fleeing-nav-enemy-chase-post (function none :behavior fleeing-nav-enemy)) (define-extern lightning-mole-hole-post (function none :behavior lightning-mole)) (define-extern lightning-mole-run-code (function none :behavior lightning-mole)) diff --git a/decompiler/config/jak1_ntsc_black_label/hacks.jsonc b/decompiler/config/jak1_ntsc_black_label/hacks.jsonc index af945421c7..123d38c748 100644 --- a/decompiler/config/jak1_ntsc_black_label/hacks.jsonc +++ b/decompiler/config/jak1_ntsc_black_label/hacks.jsonc @@ -275,9 +275,6 @@ // memory-usage BUG //"(method 14 level)", - // navigate BUG - "(method 32 nav-control)", - // ocean "draw-large-polygon-ocean", // CFG @@ -496,9 +493,13 @@ "(anon-function 9 racer)" : [75], "(method 13 collide-edge-work)" : [0, 2], "(method 17 collide-edge-work)" : [0, 1, 2, 3, 4], - "(method 9 edge-grab-info)" : [15, 16, 18, 19, 21, 22, 24] -// "(method 18 collide-edge-work)" : [1, 2, 3, 4, 5, 6, 8, 9, 10, 11, 12, 13, 14, 16, 17, 18, 19, 20, 21, 22, 23, 24] - + "(method 9 edge-grab-info)" : [15, 16, 18, 19, 21, 22, 24], +// "(method 18 collide-edge-work)" : [1, 2, 3, 4, 5, 6, 8, 9, 10, 11, 12, 13, 14, 16, 17, 18, 19, 20, 21, 22, 23, 24], + "target-falling-anim-trans" : [5, 6], + "(method 27 nav-mesh)" : [8], + "(method 32 nav-control)": [12, 21, 32], + "start-collect-nav": [0], + "end-collect-nav": [0] }, // Sometimes the game might use format strings that are fetched dynamically, diff --git a/decompiler/config/jak1_ntsc_black_label/label_types.jsonc b/decompiler/config/jak1_ntsc_black_label/label_types.jsonc index c7b3ae5a44..e856b3e4b6 100644 --- a/decompiler/config/jak1_ntsc_black_label/label_types.jsonc +++ b/decompiler/config/jak1_ntsc_black_label/label_types.jsonc @@ -1609,11 +1609,17 @@ "rolling-lightning-mole": [ ["L181", "vector"], - ["L185", "rgba", true], - ["L186", "rgba", true], - ["L187", "rgba", true], - ["L189", "rgba", true], - ["L195", "vector"] + ["L185", "vector4w"], + ["L186", "vector4w"], + ["L187", "vector4w"], + ["L189", "vector4w"], + ["L195", "vector"], + ["L201", "vector4w"], + ["L202", "vector4w"], + ["L203", "vector4w"], + ["L204", "vector4w"], + ["L205", "vector4w"], + ["L206", "vector4w"] ], "rolling-robber": [ @@ -2080,11 +2086,31 @@ ["L38", "vector"] ], - "depth-cue": [ ["L17", "depth-cue-work"] ], + "navigate": [ + ["L402", "vector"], + ["L403", "vector"], + ["L404", "vector"], + ["L405", "vector"], + ["L406", "vector"], + ["L422", "vector"], + ["L419", "(pointer uint8)", 4], + ["L425", "float", true], + ["L426", "float", true], + ["L429", "float", true], + ["L430", "float", true], + ["L436", "float", true], + ["L438", "float", true], + ["L444", "float", true], + ["L442", "float", true], + ["L520", "vector"], + ["L522", "float", true], // TODO - meters + ["L523", "float", true] // TODO - meters + ], + // please do not add things after this entry! git is dumb. "object-file-that-doesnt-actually-exist-and-i-just-put-this-here-to-prevent-merge-conflicts-with-this-file": [] } diff --git a/decompiler/config/jak1_ntsc_black_label/stack_structures.jsonc b/decompiler/config/jak1_ntsc_black_label/stack_structures.jsonc index b993ce4a1e..a9d510b5a8 100644 --- a/decompiler/config/jak1_ntsc_black_label/stack_structures.jsonc +++ b/decompiler/config/jak1_ntsc_black_label/stack_structures.jsonc @@ -6199,5 +6199,159 @@ [48, "event-message-block"] ], + "(method 20 nav-mesh)": [ + [16, "vector"], + [32, "vector"] + ], + + "nav-ray-test": [ + [16, "vector"], + [32, "vector"] + ], + + "circle-tangent-directions": [ + [16, "vector"], + [32, "vector"], + [48, "vector"], + [64, "vector"] + ], + + "(method 18 nav-control)": [ + [16, "vector"] + ], + "(method 9 nav-control)": [ + [16, "vector"], + [32, "vector"], + [48, "vector"], + [64, "vector"], + [80, "vector"], + [96, "vector"], + [112, "vector"], + [128, "vector"], + [144, "vector"], + [160, "vector"], + [176, "vector"] + ], + "(method 11 nav-control)": [ + [16, "vector"], + [32, "nav-gap-info"], + [64, "event-message-block"] + ], + "(method 12 nav-control)": [ + [16, "vector"] + ], + "(method 13 nav-mesh)": [ + [16, "vector"] + ], + "(method 18 nav-mesh)": [ + [16, "vector"] + ], + "(method 24 nav-control)": [ + [16, "vector"] + ], + "(method 24 nav-mesh)": [ + [16, "vector"], + [32, "vector"] + ], + "(method 22 nav-control)": [ + [16, "vector"] + ], + "(method 17 nav-control)": [ + [16, "vector"] + ], + "(method 19 nav-control)": [ + [16, "vector"], + [32, "vector"] + ], + "(method 17 nav-mesh)": [ + [16, "vector"], + [32, "vector"], + [48, ["array", "int8", 256]] + ], + "(method 25 nav-mesh)": [ + [16, "vector"], + [32, "matrix"] + ], + "debug-nav-validate-current-poly": [ + [16, "vector"] + ], + "(method 13 nav-control)": [ + [16, "vector"], + [32, "vector"], + [48, "vector"], + [64, "nav-route-portal"], // nav-poly | nav-route-portal | nav-route-portal + [112, "vector"], + [128, "clip-travel-vector-to-mesh-return-info"], + [288, "vector"] + ], + + "(method 28 nav-mesh)": [ + [16, ["inline-array", "nav-vertex", 3]] + ], + + "choose-travel-portal-vertex": [ + [16, "nav-route-portal"] + ], + + "(method 33 nav-control)": [ + [16, "event-message-block"] + ], + + "(method 27 nav-control)": [ + [16, "nav-ray"] + ], + "(method 16 nav-mesh)": [ + [16, "nav-ray"] + ], + + "(method 29 nav-mesh)": [ + [16, ["inline-array", "nav-vertex", 6]] + ], + + "find-closest-circle-ray-intersection": [ + [16, "vector"] + ], + + "(method 20 nav-control)": [ + [16, "vector"] + ], + "(method 21 nav-control)": [ + [16, "vector"] + ], + "(method 23 nav-control)": [ + [16, "vector"], + [32, "vector"], + [48, "vector"] + ], + "(method 16 nav-control)": [ + [16, "vector"] + ], + "(method 25 nav-control)": [ + [16, "vector"] + ], + "(method 28 nav-control)": [ + [16, "vector"] + ], + + "(method 35 nav-control)": [ + [16, "vector"] + ], + + "(method 15 nav-mesh)": [ + [16, "nav-ray"] + ], + + "nav-ray-test-local?": [ + [16, "nav-ray"] + ], + + "find-adjacent-bounds": [ + [16, "vector"] + ], + + "(method 32 nav-control)": [ + [16, "nav-control-cfs-work"] + ], + "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 9fc33b3d55..b6eb4f8b02 100644 --- a/decompiler/config/jak1_ntsc_black_label/type_casts.jsonc +++ b/decompiler/config/jak1_ntsc_black_label/type_casts.jsonc @@ -7775,5 +7775,52 @@ [29, "a0", "process-drawable"], [156, "s5", "collide-shape-prim"] ], + "circle-triangle-intersection-proc?": [ + [[113, 134], "v1", "vector"] + ], + + "(method 28 nav-control)": [ + [170, "v1", "connection"], + [[170, 245], "s0", "collide-shape"] + ], + + "(method 29 nav-mesh)": [ + [38, "v1", "int"], + [40, "v1", "int"], + [41, "v1", "int"], + [64, "f1", "float"], + [63, "v1", "float"] + ], + + "nav-mesh-update-route-table": [ + [19, "a3", "(pointer uint8)"], + [24, "a0", "(pointer uint8)"] + ], + + "nav-mesh-lookup-route": [ + [6, "a0", "(pointer uint8)"] + ], + + "(method 11 nav-mesh)": [ + [12, "a2", "(pointer uint8)"] + ], + + "(method 12 nav-mesh)": [ + [13, "a2", "(pointer uint8)"] + ], + + "recursive-inside-poly": [ + [16, "a0", "(pointer nav-node)"], + [29, "v1", "(pointer nav-node)"] + ], + + "entity-nav-login": [ + ["_stack_", 16, "res-tag"] + ], + + "(method 18 nav-mesh)": [ + [34, "v1", "nav-poly"] + ], + "placeholder-do-not-add-below": [] } diff --git a/decompiler/config/jak1_ntsc_black_label/var_names.jsonc b/decompiler/config/jak1_ntsc_black_label/var_names.jsonc index f485425103..fa2f5e6ced 100644 --- a/decompiler/config/jak1_ntsc_black_label/var_names.jsonc +++ b/decompiler/config/jak1_ntsc_black_label/var_names.jsonc @@ -3944,5 +3944,33 @@ } }, + "recursive-inside-poly": { + "vars": { + "a1-2": ["a1-2", "nav-node"] + } + }, + + "vu-point-triangle-intersection?": { + "vars": { + "v1-0": ["v1-0", "int"], + "a0-1": ["a0-1", "int"], + "a1-1": ["a1-1", "int"] + } + }, + + "point-inside-poly?": { + "vars": { + "v1-6": ["v1-6", "int"], + "a0-3": ["a0-3", "int"], + "a1-6": ["a1-6", "int"] + } + }, + + "(method 29 nav-mesh)": { + "vars": { + "v1-10": ["v1-10", "int"] + } + }, + "aaaaaaaaaaaaaaaaaaaaaaa": {} } diff --git a/decompiler/util/data_decompile.cpp b/decompiler/util/data_decompile.cpp index dda1028096..f81a230c5e 100644 --- a/decompiler/util/data_decompile.cpp +++ b/decompiler/util/data_decompile.cpp @@ -336,8 +336,9 @@ goos::Object decomp_ref_to_inline_array_guess_size( // verify the stride matches the type system auto elt_type_info = ts.lookup_type(array_elt_type); - assert(stride == align(elt_type_info->get_size_in_memory(), - elt_type_info->get_inline_array_stride_alignment())); + int ye = align(elt_type_info->get_size_in_memory(), + elt_type_info->get_inline_array_stride_alignment()); + assert(stride == ye); // the input is the location of the data field. // we expect that to be a label: @@ -450,6 +451,39 @@ goos::Object sp_field_init_spec_decompile(const std::vector& words, file, TypeSpec("sp-field-init-spec"), 16); } +goos::Object nav_mesh_vertex_arr_decompile(const std::vector& words, + const std::vector& labels, + int my_seg, + int field_location, + const TypeSystem& ts, + const std::vector>& all_words, + const LinkedObjectFile* file) { + return decomp_ref_to_inline_array_guess_size(words, labels, my_seg, field_location, ts, all_words, + file, TypeSpec("nav-vertex"), 16); +} + +goos::Object nav_mesh_poly_arr_decompile(const std::vector& words, + const std::vector& labels, + int my_seg, + int field_location, + const TypeSystem& ts, + const std::vector>& all_words, + const LinkedObjectFile* file) { + return decomp_ref_to_inline_array_guess_size(words, labels, my_seg, field_location, ts, all_words, + file, TypeSpec("nav-poly"), 8); +} + +goos::Object nav_mesh_route_arr_decompile(const std::vector& words, + const std::vector& labels, + int my_seg, + int field_location, + const TypeSystem& ts, + const std::vector>& all_words, + const LinkedObjectFile* file) { + return decomp_ref_to_inline_array_guess_size(words, labels, my_seg, field_location, ts, all_words, + file, TypeSpec("vector4ub"), 4); +} + goos::Object sp_launch_grp_launcher_decompile(const std::vector& words, const std::vector& labels, int my_seg, @@ -676,6 +710,18 @@ goos::Object decompile_structure(const TypeSpec& type, field_defs_out.emplace_back( field.name(), sp_field_init_spec_decompile(obj_words, labels, label.target_segment, field_start, ts, words, file)); + } else if (field.name() == "vertex" && type.print() == "nav-mesh") { + field_defs_out.emplace_back( + field.name(), nav_mesh_vertex_arr_decompile(obj_words, labels, label.target_segment, + field_start, ts, words, file)); + } else if (field.name() == "poly" && type.print() == "nav-mesh") { + field_defs_out.emplace_back( + field.name(), nav_mesh_poly_arr_decompile(obj_words, labels, label.target_segment, + field_start, ts, words, file)); + } else if (field.name() == "route" && type.print() == "nav-mesh") { + field_defs_out.emplace_back( + field.name(), nav_mesh_route_arr_decompile(obj_words, labels, label.target_segment, + field_start, ts, words, file)); } else if (field.name() == "launcher" && type.print() == "sparticle-launch-group") { field_defs_out.emplace_back(field.name(), sp_launch_grp_launcher_decompile( obj_words, labels, label.target_segment, diff --git a/goal_src/engine/camera/cam-debug-h.gc b/goal_src/engine/camera/cam-debug-h.gc index 953d471e90..438e383885 100644 --- a/goal_src/engine/camera/cam-debug-h.gc +++ b/goal_src/engine/camera/cam-debug-h.gc @@ -28,6 +28,8 @@ (define-extern cam-collision-record-save (function vector vector int symbol 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 +;; TODO - for rolling-lightning-mole +(define-extern camera-line-rel (function vector vector vector4w none)) (declare-type clm basic) (define-extern *clm* clm) ;; unknown type diff --git a/goal_src/engine/collide/collide-shape-h.gc b/goal_src/engine/collide/collide-shape-h.gc index 6840e6eaf1..1c9ab88f98 100644 --- a/goal_src/engine/collide/collide-shape-h.gc +++ b/goal_src/engine/collide/collide-shape-h.gc @@ -236,9 +236,9 @@ :type uint64 :bitfield #t (background 0) - (cak-1 1) ;; - (cak-2 2) - (cak-3 3) + (cak-1 1) ;; hit by player + (cak-2 2) ;; usually hit by player + (cak-3 3) ;; hit by others (target 4) ;; target (water 5) (powerup 6) @@ -250,7 +250,55 @@ (target-attack 12) ;; all target attacks (mother-spider 13) (cak-14 14) ;; unused - (blue-eco-suck 15) ;; manipy, orb-cache-top, + (blue-eco-suck 15) ;; manipy, orb-cache-top, + (unknown-16 16) + (unknown-17 17) + (unknown-18 18) + (unknown-19 19) + (unknown-20 20) + (unknown-21 21) + (unknown-22 22) + (unknown-23 23) + (unknown-24 24) + (unknown-25 25) + (unknown-26 26) + (unknown-27 27) + (unknown-28 28) + (unknown-29 29) + (unknown-30 30) + (unknown-31 31) + (unknown-32 32) + (unknown-33 33) + (unknown-34 34) + (unknown-35 35) + (unknown-36 36) + (unknown-37 37) + (unknown-38 38) + (unknown-39 39) + (unknown-40 40) + (unknown-41 41) + (unknown-42 42) + (unknown-43 43) + (unknown-44 44) + (unknown-45 45) + (unknown-46 46) + (unknown-47 47) + (unknown-48 48) + (unknown-49 49) + (unknown-50 50) + (unknown-51 51) + (unknown-52 52) + (unknown-53 53) + (unknown-54 54) + (unknown-55 55) + (unknown-56 56) + (unknown-57 57) + (unknown-58 58) + (unknown-59 59) + (unknown-60 60) + (unknown-61 61) + (unknown-62 62) + (unknown-63 63) ) (defenum collide-action diff --git a/goal_src/engine/entity/entity.gc b/goal_src/engine/entity/entity.gc index 2df0a5ee12..cd4b3329fa 100644 --- a/goal_src/engine/entity/entity.gc +++ b/goal_src/engine/entity/entity.gc @@ -1054,7 +1054,7 @@ (debug-print-channels (-> (the-as process-drawable s5-2) skel) (the-as symbol *stdcon*)) ) (if (nonzero? (-> (the-as process-drawable s5-2) nav)) - (dummy-9 (-> (the-as process-drawable s5-2) nav)) + (debug-draw (-> (the-as process-drawable s5-2) nav)) ) (if (nonzero? (-> (the-as process-drawable s5-2) path)) (dummy-9 (-> (the-as process-drawable s5-2) path)) @@ -1115,7 +1115,7 @@ (the-as (function object object) (lambda ((arg0 process-drawable)) (when (type-type? (-> arg0 type) process-drawable) (if (nonzero? (-> arg0 nav)) - (dummy-9 (-> arg0 nav)) + (debug-draw (-> arg0 nav)) ) (if (nonzero? (-> arg0 path)) (dummy-9 (-> arg0 path)) @@ -1258,6 +1258,7 @@ (define-extern racer type) (define-extern launcher type) (define-extern warp-gate-switch type) +(define-extern lurkercrab type) (defmacro heap-size-hack (info entity-type) `(cond @@ -1286,6 +1287,7 @@ (type-type? (-> obj etype) racer) (type-type? (-> obj etype) launcher) (type-type? (-> obj etype) warp-gate-switch) + (type-type? (-> obj etype) lurkercrab) ;; crash on death ;(type-type? (-> obj etype) crate) ) diff --git a/goal_src/engine/nav/navigate-h.gc b/goal_src/engine/nav/navigate-h.gc index 7b8139b21d..5ca950b6bd 100644 --- a/goal_src/engine/nav/navigate-h.gc +++ b/goal_src/engine/nav/navigate-h.gc @@ -5,32 +5,41 @@ ;; name in dgo: navigate-h ;; dgos: GAME, ENGINE +(declare-type nav-mesh basic) +(declare-type nav-node structure) +(define-extern recursive-inside-poly (function nav-mesh nav-node vector float int)) + (defenum nav-control-flags :bitfield #t :type uint32 (display-marks 0) - (bit1 1) - (bit2 2) - (bit3 3) ;; TODO - nav-enemy::45 - (bit4 4) - (bit5 5) ;; TODO - nav-enemy::45 - (bit6 6) ;; TODO - nav-enemy::45 - (bit7 7) ;; TODO - nav-enemy::45 + (bit1 1) ;; TODO - nav-control::9 + (bit2 2) ;; TODO - nav-control::9 + (bit3 3) ;; TODO - nav-enemy::45 | nav-control::9 + (bit4 4) ;; TODO - nav-control::9 + (bit5 5) ;; TODO - nav-enemy::45 | ;; TODO - nav-control::9 + (bit6 6) ;; TODO - nav-enemy::45 | ;; TODO - nav-control::9 + (bit7 7) ;; TODO - nav-enemy::45 | ;; TODO - nav-control::9 (bit8 8) + (bit9 9) ;; TODO - nav-control::14 | 11 (bit10 10) ;; TODO - nav-enemy::nav-enemy-patrol-post + (bit11 11) ;; TODO - nav-control::28 (bit12 12) ;; TODO - rolling-lightning-mole::(enter nav-enemy-chase fleeing-nav-enemy) (bit13 13) - (bit17 17) - (bit19 19) ;; TODO - nav-enemy::lambda::17 - (bit21 21) + (bit17 17) ;; TODO - nav-control::11 + (bit18 18) ;; TODO - nav-control::11 + (bit19 19) ;; TODO - nav-control::11 | 17 + (bit20 20) ;; TODO - nav-mesh::28 + (bit21 21) ;; TODO - nav-control::19 ) (deftype nav-poly (structure) - ((id uint8 :offset-assert 0) + ((id uint8 :offset-assert 0) (vertex uint8 3 :offset-assert 1) (adj-poly uint8 3 :offset-assert 4) - (pat uint8 :offset-assert 7) ;; pat-material, mode, event? + (pat uint8 :offset-assert 7) ) + :pack-me :method-count-assert 9 :size-assert #x8 :flag-assert #x900000008 @@ -52,17 +61,17 @@ ) (deftype nav-ray (structure) - ((current-pos vector :inline :offset-assert 0) - (dir vector :inline :offset-assert 16) - (dest-pos vector :inline :offset-assert 32) - (current-poly nav-poly :offset-assert 48) - (next-poly nav-poly :offset-assert 52) - (len meters :offset-assert 56) - (last-edge int8 :offset-assert 60) - (terminated basic :offset-assert 64) - (reached-dest basic :offset-assert 68) - (hit-boundary basic :offset-assert 72) - (hit-gap basic :offset-assert 76) + ((current-pos vector :inline :offset-assert 0) + (dir vector :inline :offset-assert 16) + (dest-pos vector :inline :offset-assert 32) + (current-poly nav-poly :offset-assert 48) + (next-poly nav-poly :offset-assert 52) + (len meters :offset-assert 56) + (last-edge int8 :offset-assert 60) + (terminated symbol :offset-assert 64) ;; TODO - guesses + (reached-dest symbol :offset-assert 68) ;; TODO - guesses + (hit-boundary symbol :offset-assert 72) ;; TODO - guesses + (hit-gap symbol :offset-assert 76) ;; TODO - guesses ) :method-count-assert 9 :size-assert #x50 @@ -81,7 +90,7 @@ (deftype clip-travel-vector-to-mesh-return-info (structure) - ((found-boundary basic :offset-assert 0) + ((found-boundary symbol :offset-assert 0) (intersection vector :inline :offset-assert 16) (boundary-normal vector :inline :offset-assert 32) (prev-normal vector :inline :offset-assert 48) @@ -140,47 +149,61 @@ ) (deftype nav-mesh (basic) - ((user-list engine :offset-assert 4) - (poly-lookup-history uint8 2 :offset-assert 8) - (debug-time uint8 :offset-assert 10) - (static-sphere-count uint8 :offset-assert 11) - (static-sphere uint32 :offset-assert 12) - (bounds sphere :inline :offset-assert 16) - (origin vector :inline :offset-assert 32) - (cache nav-lookup-elem 4 :inline :offset-assert 48) - (node-count int32 :offset-assert 176) - (nodes uint32 :offset-assert 180) - (vertex-count int32 :offset-assert 184) - (vertex (inline-array vector) :offset-assert 188) - (poly-count int32 :offset-assert 192) - (poly uint32 :offset-assert 196) - (route uint32 :offset-assert 200) + ((user-list engine :offset-assert 4) + (poly-lookup-history uint8 2 :offset-assert 8) + (debug-time uint8 :offset-assert 10) + (static-sphere-count uint8 :offset-assert 11) + (static-sphere (inline-array nav-sphere) :offset-assert 12) + (bounds sphere :inline :offset-assert 16) + (origin vector :inline :offset-assert 32) + (cache nav-lookup-elem 4 :inline :offset-assert 48) ;; guess on type + (node-count int32 :offset-assert 176) + (nodes (inline-array nav-node) :offset-assert 180) + (vertex-count int32 :offset-assert 184) + (vertex (inline-array nav-vertex) :offset-assert 188) + (poly-count int32 :offset-assert 192) + (poly (inline-array nav-poly) :offset-assert 196) + (route (inline-array vector4ub) :offset-assert 200) ;; this is a guess, it's probably wrong -- but its something with a uint8 at offset 0 ) :method-count-assert 30 :size-assert #xcc :flag-assert #x1e000000cc (:methods - (dummy-9 () none 9) - (dummy-10 () none 10) - (dummy-11 () none 11) - (dummy-12 () none 12) - (dummy-13 (_type_) none 13) - (dummy-14 () none 14) - (dummy-15 () none 15) - (dummy-16 () none 16) - (dummy-17 (_type_) none 17) - (dummy-18 () none 18) + (tri-centroid-world (_type_ nav-poly vector) vector 9) ;; finds the centroid of the given triangle, in the "world" coordinate system. + (tri-centroid-local (_type_ nav-poly vector) vector 10) ;; finds the centroid of the given triangle, in the local nav-mesh coordinate system. + (get-adj-poly (_type_ nav-poly nav-poly symbol) nav-poly 11) + (setup-portal (_type_ nav-poly nav-poly nav-route-portal) object 12) ;; sets up a portal between two polys. + (initialize-mesh! (_type_) none 13) + (move-along-nav-ray! (_type_ nav-ray) none 14) ;; think this updates the current position in a nav-ray, and updates which triangle you're in. + ;; this takes in a point/direction/distance, and see what would happen if you tried to move this way. + ;; it returns the distance you can go before one of these happens: + ;; - you reach the destination + ;; - you hit a nav mesh boundary/gap + ;; - you cross 15 triangles. + (try-move-along-ray (_type_ nav-poly vector vector float) meters 15) + (TODO-RENAME-16 (_type_ vector nav-poly vector symbol float clip-travel-vector-to-mesh-return-info) none 16) + (update-route-table (_type_) none 17) ;; (initialization related) + (dummy-18 (_type_ int vector int (pointer int8) int) none 18) ;; something to do with routes. (compute-bounding-box (_type_ vector vector) none 19) - (dummy-20 () none 20) - (dummy-21 () none 21) - (dummy-22 () none 22) - (dummy-23 () none 23) - (dummy-24 () none 24) - (dummy-25 () none 25) - (dummy-26 () none 26) - (dummy-27 () none 27) - (dummy-28 () none 28) - (dummy-29 () none 29) + (debug-draw-poly (_type_ nav-poly rgba) none 20) ;; TODO - is rgba a vector4w? + (point-in-poly? (_type_ nav-poly vector) symbol 21) ;; is the point inside of the triangle? + (find-opposite-vertices (_type_ nav-poly nav-poly) uint 22) ;; given two triangles that share an edge, get the indices of the two vertices that aren't part of the edge. + (dummy-23 (_type_ nav-poly vector vector vector nav-route-portal) vector 23) + (closest-point-on-boundary (_type_ nav-poly vector vector) vector 24) ;; find the closest point on the perimeter of the triangle. + (project-point-into-tri-3d (_type_ nav-poly vector vector) none 25) ;; will move a 3D point in space to the surface of this nav-poly + ;; Looking from the top down, is the point inside the nav-poly? + ;; - if the point is inside the triangle, returns that point. + ;; - if the point is outside the triangle, move it to the closest point (will be on the edge) + (project-point-into-tri-2d (_type_ nav-poly vector vector) vector 26) + ;; finds which triangle the given point is in. + ;; also has some caching stuff so if you look up the same point multiple times, it won't redo the work. + ;; I _think_ this is only an approximate check that may return #f even if you are inside. + ;; But, if it returns a poly, it will be right. + (find-poly-fast (_type_ vector meters) nav-poly 27) + (find-poly (_type_ vector meters (pointer nav-control-flags)) nav-poly 28) ;; The accurate version of find-poly (tries find-poly-fast first) + ;; checks to see if the triangle is in the mesh or not. + ;; not sure why it's separate from 27 (and such a different implementation). there might be some details I'm missing here. + (is-in-mesh? (_type_ vector float meters) symbol 29) ) ) @@ -238,31 +261,31 @@ :flag-assert #x24000000e0 (:methods (new (symbol type collide-shape int float) _type_) - (dummy-9 (_type_) none 9) + (debug-draw (_type_) none 9) (point-in-bounds? (_type_ vector) symbol 10) - (dummy-11 (_type_ vector) none 11) - (dummy-12 () none 12) - (dummy-13 (_type_ vector vector) vector 13) ;; see - puffer::20 + (dummy-11 (_type_ vector) vector 11) + (TODO-RENAME-12 (_type_ nav-gap-info) symbol 12) + (dummy-13 (_type_ vector vector) vector 13) ;; see - puffer::20 | second vector may be clip-travel-vector-to-mesh-return-info though (set-current-poly! (_type_ nav-poly) none 14) (set-target-pos! (_type_ vector) none 15) (dummy-16 (_type_ vector) nav-poly 16) ; see - nav-enemy-test-point-in-nav-mesh? - (dummy-17 (_type_ vector vector) none 17) - (TODO-RENAME-18 (_type_ vector) nav-poly 18) - (dummy-19 (_type_ vector collide-shape-moving vector float) none 19) - (dummy-20 () none 20) - (dummy-21 (_type_ vector) symbol 21) - (dummy-22 () none 22) - (dummy-23 (_type_ vector check-vector-collision-with-nav-spheres-info) float 23) ;; TODO - unconfirmed + (project-onto-nav-mesh (_type_ vector vector) vector 17) ;; moves point to nav-mesh. + (find-poly (_type_ vector) nav-poly 18) + (dummy-19 (_type_ vector collide-shape-moving vector float) none 19) ;; csm not trsqv? ret not vector? + (project-point-into-tri-3d (_type_ nav-poly vector vector) vector 20) + (TODO-RENAME-21 (_type_ vector) nav-poly 21) + (TODO-RENAME-22 (_type_ vector float) symbol 22) + (dummy-23 (_type_ vector check-vector-collision-with-nav-spheres-info) float 23) ;; TODO - unconfirmed maybe (dummy-23 (_type_ vector matrix) float 23) (dummy-24 (_type_ float clip-travel-vector-to-mesh-return-info) none 24) - (dummy-25 (_type_ vector float) symbol 25) ; see - nav-enemy-test-point-near-nav-mesh? - (dummy-26 (_type_) none 26) - (dummy-27 (_type_) none 27) - (dummy-28 (_type_ int) none 28) + (is-in-mesh? (_type_ vector float) symbol 25) ; see - nav-enemy-test-point-near-nav-mesh? + (TODO-RENAME-26 (_type_) none 26) ;; stub + (TODO-RENAME-27 (_type_) none 27) + (TODO-RENAME-28 (_type_ collide-kind) none 28) (should-display? (_type_) symbol 29) - (dummy-30 () none 30) - (dummy-31 () none 31) - (dummy-32 () none 32) - (dummy-33 () none 33) + (dummy-30 (_type_ vector vector vector) sphere 30) ;; TODO - last arg? - it has a float as the first arg, vector is a total guess + (intersect-ray-line-segment? (_type_ vector vector vector vector) symbol 31) + (TODO-ASM-32 (_type_ vector vector vector vector float) symbol 32) + (TODO-RENAME-33 (_type_ vector vector vector vector float) symbol 33) (dummy-34 () none 34) (dummy-35 (_type_ vector vector vector vector float) none 35) ) @@ -305,8 +328,8 @@ ) ;; do some setup - (dummy-13 entity-nav-mesh) - (dummy-17 entity-nav-mesh) + (initialize-mesh! entity-nav-mesh) + (update-route-table entity-nav-mesh) ) ;; in all cases, do the connection diff --git a/goal_src/engine/nav/navigate.gc b/goal_src/engine/nav/navigate.gc index 61536be926..541d7b5184 100644 --- a/goal_src/engine/nav/navigate.gc +++ b/goal_src/engine/nav/navigate.gc @@ -5,3 +5,3086 @@ ;; name in dgo: navigate ;; dgos: GAME, ENGINE +;; DECOMP BEGINS + +(define *nav-timer* (new 'global 'stopwatch)) + +(define *travel-timer* (new 'global 'stopwatch)) + +(define *clip-for-spheres-timer* (new 'global 'stopwatch)) + +(define *find-poly-timer* (new 'global 'stopwatch)) + +(define *nav-timer-enable* #t) + +(define *nav-patch-route-table* #t) + +(define *nav-triangle-test-count* 0) + +(define *nav-last-triangle-test-count* 0) + +(define *debug-traverse* 0) + +(define *debug-tests* 0) + +(defun pke-nav-hack () + (format *stdcon* "travs: ~d, tests: ~d~%" *debug-traverse* *debug-tests*) + (set! *debug-traverse* 0) + (set! *debug-tests* 0) + 0 + (none) + ) + +(defun debug-report-nav-stats () + 0 + (none) + ) + +(define *debug-output* #f) + +(define *debug-nav* #t) + +(define *debug-nav-ray* (the-as nav-ray #f)) + +(define *debug-ray-offset* (new 'static 'vector)) + +(define *debug-nav-travel* #f) + +(define *color-black* (new 'static 'rgba :a #x80)) + +(define *color-white* (new 'static 'rgba :r #xff :g #xff :b #xff :a #x80)) + +(define *color-gray* (new 'static 'rgba :r #x80 :g #x80 :b #x80 :a #x80)) + +(define *color-red* (new 'static 'rgba :r #xff :a #x80)) + +(define *color-green* (new 'static 'rgba :g #xff :a #x80)) + +(define *color-blue* (new 'static 'rgba :b #xff :a #x80)) + +(define *color-cyan* (new 'static 'rgba :g #xff :b #xff :a #x80)) + +(define *color-magenta* (new 'static 'rgba :r #xff :b #xff :a #x80)) + +(define *color-yellow* (new 'static 'rgba :r #xff :g #xff :a #x80)) + +(define *color-light-red* (new 'static 'rgba :r #xff :g #x80 :b #x80 :a #x80)) + +(define *color-light-green* (new 'static 'rgba :r #x80 :g #xff :b #x80 :a #x80)) + +(define *color-light-blue* (new 'static 'rgba :r #x80 :g #x80 :b #xff :a #x80)) + +(define *color-light-cyan* (new 'static 'rgba :r #x80 :g #xff :b #xff :a #x80)) + +(define *color-light-magenta* (new 'static 'rgba :r #xff :g #x80 :b #xff :a #x80)) + +(define *color-light-yellow* (new 'static 'rgba :r #xff :g #xff :b #x80 :a #x80)) + +(define *color-dark-red* (new 'static 'rgba :r #x80 :a #x80)) + +(define *color-dark-green* (new 'static 'rgba :g #x80 :a #x80)) + +(define *color-dark-blue* (new 'static 'rgba :b #x80 :a #x80)) + +(define *color-dark-cyan* (new 'static 'rgba :g #x80 :b #x80 :a #x80)) + +(define *color-dark-magenta* (new 'static 'rgba :r #x80 :b #x80 :a #x80)) + +(define *color-dark-yellow* (new 'static 'rgba :r #x80 :g #x80 :a #x80)) + +(define *color-orange* (new 'static 'rgba :r #xff :g #x80 :a #x80)) + +(defun entity-nav-login ((arg0 entity-actor)) + (local-vars (sv-16 res-tag)) + (let ((gp-0 (if (nonzero? (-> arg0 nav-mesh)) + (-> arg0 nav-mesh) + ) + ) + ) + (when gp-0 + (when (zero? (-> gp-0 user-list)) + (set! (-> gp-0 user-list) + (new 'loading-level 'engine 'nav-engine (res-lump-value arg0 'nav-max-users int :default (the-as uint128 32))) + ) + (initialize-mesh! gp-0) + (update-route-table gp-0) + ) + (when (zero? (-> gp-0 static-sphere)) + (set! sv-16 (new 'static 'res-tag)) + (let ((v1-11 (res-lump-data arg0 'nav-mesh-sphere pointer :tag-ptr (& sv-16)))) + (when v1-11 + (set! (-> gp-0 static-sphere-count) (-> sv-16 elt-count)) + (set! (-> gp-0 static-sphere) (the-as (inline-array nav-sphere) v1-11)) + ) + ) + ) + ) + ) + 0 + (none) + ) + +(defmethod length nav-control ((obj nav-control)) + (-> obj num-spheres) + ) + +(defmethod asize-of nav-control ((obj nav-control)) + (the-as int (+ (-> nav-control size) (* (-> obj max-spheres) 16))) + ) + +(define *default-nav-mesh* (new 'static 'nav-mesh + :bounds + (new 'static 'sphere :x 12288.0 :y -200704.0 :z 12288.0 :w 20480.0) + :origin + (new 'static 'vector :y -200704.0 :w 1.0) + :vertex-count 4 + :vertex + (new 'static 'inline-array nav-vertex 4 + (new 'static 'nav-vertex :z 16384.0 :w 1.0) + (new 'static 'nav-vertex :z 8192.0 :w 1.0) + (new 'static 'nav-vertex :x 8192.0 :z 8192.0 :w 1.0) + (new 'static 'nav-vertex :x 8192.0 :w 1.0) + ) + :poly-count 2 + :poly + (new 'static 'inline-array nav-poly 2 + (new 'static 'nav-poly + :vertex + (new 'static 'array uint8 3 #x0 #x2 #x1) + :adj-poly + (new 'static 'array uint8 3 #xff #x1 #xff) + ) + (new 'static 'nav-poly + :id #x1 + :vertex + (new 'static 'array uint8 3 #x1 #x2 #x3) + :adj-poly + (new 'static 'array uint8 3 #x0 #xff #xff) + ) + ) + :route + (new 'static 'inline-array vector4ub 4 + (new 'static 'vector4ub :data (new 'static 'array uint8 4 #xcb #x0 #x0 #x0)) + (new 'static 'vector4ub) + (new 'static 'vector4ub) + (new 'static 'vector4ub) + ) + ) + ) + +(let ((gp-0 *default-nav-mesh*)) + (if (zero? (-> gp-0 user-list)) + (set! (-> gp-0 user-list) (new 'global 'engine 'nav-engine 32)) + ) + ) + +(defmethod length nav-mesh ((obj nav-mesh)) + (-> obj poly-count) + ) + +(defmethod debug-draw-poly nav-mesh ((obj nav-mesh) (arg0 nav-poly) (arg1 rgba)) + (let ((s5-0 (-> obj origin)) + (s2-0 (-> obj vertex)) + (gp-0 (new 'stack-no-clear 'vector)) + (s4-0 (new 'stack-no-clear 'vector)) + ) + (add-debug-line + #t + (bucket-id debug-draw1) + (vector+! gp-0 s5-0 (the-as vector (-> s2-0 (-> arg0 vertex 0)))) + (vector+! s4-0 s5-0 (the-as vector (-> s2-0 (-> arg0 vertex 1)))) + arg1 + #f + (the-as rgba -1) + ) + (add-debug-line + #t + (bucket-id debug-draw1) + (vector+! gp-0 s5-0 (the-as vector (-> s2-0 (-> arg0 vertex 1)))) + (vector+! s4-0 s5-0 (the-as vector (-> s2-0 (-> arg0 vertex 2)))) + arg1 + #f + (the-as rgba -1) + ) + (add-debug-line + #t + (bucket-id debug-draw1) + (vector+! gp-0 s5-0 (the-as vector (-> s2-0 (-> arg0 vertex 2)))) + (vector+! s4-0 s5-0 (the-as vector (-> s2-0 (-> arg0 vertex 0)))) + arg1 + #f + (the-as rgba -1) + ) + ) + 0 + (none) + ) + +(define *nav-one-third* (new 'global 'vector)) + +(set! (-> *nav-one-third* x) 0.33333334) + +(defmethod tri-centroid-local nav-mesh ((obj nav-mesh) (arg0 nav-poly) (arg1 vector)) + (set! (-> arg1 quad) (-> obj vertex (-> arg0 vertex 0) quad)) + (vector+! arg1 arg1 (the-as vector (-> obj vertex (-> arg0 vertex 1)))) + (vector+! arg1 arg1 (the-as vector (-> obj vertex (-> arg0 vertex 2)))) + (vector-float*! arg1 arg1 0.333333) + ) + +(defmethod tri-centroid-world nav-mesh ((obj nav-mesh) (arg0 nav-poly) (arg1 vector)) + (tri-centroid-local obj arg0 arg1) + (vector+! arg1 arg1 (-> obj origin)) + ) + +(define + *edge-vert0-table* + (the-as (array int8) (new 'static 'boxed-array :type int8 :length 3 :allocated-length 3 1 2 0)) + ) + +(define + *edge-vert1-table* + (the-as (array int8) (new 'static 'boxed-array :type int8 :length 3 :allocated-length 3 2 0 1)) + ) + +(define + *edge-mask-table* + (the-as (array int8) (new 'static 'boxed-array :type int8 :length 3 :allocated-length 3 1 2 4)) + ) + +(defun inc-mod3 ((arg0 int)) + (local-vars (v0-1 int) (v1-1 int)) + (let ((v0-0 (+ arg0 1))) + (let ((v1-0 2)) + (set-on-less-than v1-1 v1-0 v0-0) + ) + (move-if-not-zero v0-1 0 v1-1 v0-0) + ) + v0-1 + ) + +(defun dec-mod3 ((arg0 int)) + (local-vars (v0-1 int) (a0-1 int)) + (let ((v0-0 (+ arg0 -1)) + (v1-0 2) + ) + (set-on-less-than a0-1 v0-0 0) + (move-if-not-zero v0-1 v1-0 a0-1 v0-0) + ) + v0-1 + ) + +(defun vu-point-triangle-intersection? ((arg0 vector) (arg1 vector) (arg2 vector) (arg3 vector)) + (local-vars (v1-0 int) (v1-1 int) (v1-3 int) (a0-1 int) (a0-2 int) (a0-4 int) (a1-1 int) (a1-2 int)) + (rlet ((acc :class vf) + (vf1 :class vf) + (vf10 :class vf) + (vf11 :class vf) + (vf12 :class vf) + (vf13 :class vf) + (vf14 :class vf) + (vf15 :class vf) + (vf2 :class vf) + (vf3 :class vf) + (vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + (vf9 :class vf) + ) + (.lvf vf1 (&-> arg1 quad)) + (.lvf vf2 (&-> arg2 quad)) + (.sub.vf vf1 vf1 vf1 :mask #b1010) + (.lvf vf3 (&-> arg3 quad)) + (.sub.vf vf2 vf2 vf2 :mask #b1010) + (.lvf vf12 (&-> arg0 quad)) + (.sub.vf vf3 vf3 vf3 :mask #b1010) + (.sub.vf vf4 vf2 vf1) + (.sub.vf vf9 vf1 vf12) + (.sub.vf vf5 vf3 vf2) + (.sub.vf vf10 vf2 vf12) + (.sub.vf vf6 vf1 vf3) + (.sub.vf vf11 vf3 vf12) + (.outer.product.a.vf acc vf9 vf4) + (.outer.product.b.vf vf13 vf4 vf9 acc) + (.outer.product.a.vf acc vf10 vf5) + (.outer.product.b.vf vf14 vf5 vf10 acc) + (.outer.product.a.vf acc vf11 vf6) + (.outer.product.b.vf vf15 vf6 vf11 acc) + (.mov v1-0 vf13) + (.mov a1-1 vf14) + (.mov a0-1 vf15) + (set-on-less-than v1-1 v1-0 0) + (set-on-less-than a1-2 a1-1 0) + (set-on-less-than a0-2 a0-1 0) + (let ((a0-3 (logxor a1-2 a0-2)) + (v1-2 (logxor v1-1 a1-2)) + ) + (set-on-less-than a0-4 a0-3 1) + (set-on-less-than v1-3 v1-2 1) + ) + (logtest? v1-3 a0-4) + ) + ) + +(defmethod point-in-poly? nav-mesh ((obj nav-mesh) (arg0 nav-poly) (arg1 vector)) + (vu-point-triangle-intersection? + arg1 + (-> obj vertex (-> arg0 vertex 0)) + (-> obj vertex (-> arg0 vertex 1)) + (-> obj vertex (-> arg0 vertex 2)) + ) + ) + +(defmethod closest-point-on-boundary nav-mesh ((obj nav-mesh) (arg0 nav-poly) (arg1 vector) (arg2 vector)) + (let ((s2-0 (-> obj vertex)) + (s1-0 (new 'stack-no-clear 'vector)) + (s5-0 (new 'stack-no-clear 'vector)) + ) + (let ((f30-0 10000000000000000000000000000000000000.0)) + (dotimes (s0-0 3) + (let* ((a1-1 (-> s2-0 (-> arg0 vertex s0-0))) + (f0-0 (vector-segment-distance-point! arg2 a1-1 (-> s2-0 (-> arg0 vertex (mod (+ s0-0 1) 3))) s1-0)) + ) + (when (< f0-0 f30-0) + (set! f30-0 f0-0) + (set! (-> s5-0 quad) (-> s1-0 quad)) + ) + ) + ) + ) + (set! (-> arg1 quad) (-> s5-0 quad)) + ) + arg1 + ) + +(defmethod project-point-into-tri-2d nav-mesh ((obj nav-mesh) (arg0 nav-poly) (arg1 vector) (arg2 vector)) + (if (point-in-poly? obj arg0 arg2) + (set! (-> arg1 quad) (-> arg2 quad)) + (closest-point-on-boundary obj arg0 arg1 arg2) + ) + arg1 + ) + +(defun point-inside-rect? ((arg0 nav-node) (arg1 vector) (arg2 float)) + (and (>= (-> arg1 x) (- (-> arg0 center-x) (-> arg0 radius-x))) + (>= (+ (-> arg0 center-x) (-> arg0 radius-x)) (-> arg1 x)) + (>= (-> arg1 z) (- (-> arg0 center-z) (-> arg0 radius-z))) + (>= (+ (-> arg0 center-z) (-> arg0 radius-z)) (-> arg1 z)) + (>= (+ (-> arg1 y) arg2) (- (-> arg0 center-y) (-> arg0 radius-y))) + (>= (+ (-> arg0 center-y) (-> arg0 radius-y)) (- (-> arg1 y) arg2)) + ) + ) + +(defun point-inside-poly? ((arg0 nav-mesh) (arg1 uint) (arg2 vector) (arg3 float)) + (local-vars (v1-6 int) (v1-7 int) (v1-9 int) (a0-3 int) (a0-4 int) (a0-6 int) (a1-6 int) (a1-7 int)) + (rlet ((acc :class vf) + (vf1 :class vf) + (vf10 :class vf) + (vf11 :class vf) + (vf12 :class vf) + (vf13 :class vf) + (vf14 :class vf) + (vf15 :class vf) + (vf2 :class vf) + (vf3 :class vf) + (vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + (vf9 :class vf) + ) + (let ((t0-0 (-> arg0 poly arg1))) + (when (zero? (logand (-> t0-0 pat) 1)) + (let ((v1-5 (-> arg0 vertex (-> t0-0 vertex 0))) + (a1-5 (-> arg0 vertex (-> t0-0 vertex 1))) + (a0-2 (-> arg0 vertex (-> t0-0 vertex 2))) + ) + 0.0 + (let ((f0-3 (fabs (- (-> arg2 y) (* 0.333333 (+ (-> v1-5 y) (-> a1-5 y) (-> a0-2 y))))))) + (when (>= arg3 f0-3) + (.lvf vf1 (&-> v1-5 quad)) + (.lvf vf2 (&-> a1-5 quad)) + (.sub.vf vf1 vf1 vf1 :mask #b1010) + (.lvf vf3 (&-> a0-2 quad)) + (.sub.vf vf2 vf2 vf2 :mask #b1010) + (.lvf vf12 (&-> arg2 quad)) + (.sub.vf vf3 vf3 vf3 :mask #b1010) + (.sub.vf vf4 vf2 vf1) + (.sub.vf vf9 vf1 vf12) + (.sub.vf vf5 vf3 vf2) + (.sub.vf vf10 vf2 vf12) + (.sub.vf vf6 vf1 vf3) + (.sub.vf vf11 vf3 vf12) + (.outer.product.a.vf acc vf9 vf4) + (.outer.product.b.vf vf13 vf4 vf9 acc) + (.outer.product.a.vf acc vf10 vf5) + (.outer.product.b.vf vf14 vf5 vf10 acc) + (.outer.product.a.vf acc vf11 vf6) + (.outer.product.b.vf vf15 vf6 vf11 acc) + (.mov v1-6 vf13) + (.mov a1-6 vf14) + (.mov a0-3 vf15) + (set-on-less-than v1-7 v1-6 0) + (set-on-less-than a1-7 a1-6 0) + (set-on-less-than a0-4 a0-3 0) + (let ((a0-5 (logxor a1-7 a0-4)) + (v1-8 (logxor v1-7 a1-7)) + ) + (set-on-less-than a0-6 a0-5 1) + (set-on-less-than v1-9 v1-8 1) + ) + (if (logtest? v1-9 a0-6) + (return #t) + ) + ) + ) + ) + ) + ) + #f + ) + ) + +(defun recursive-inside-poly ((arg0 nav-mesh) (arg1 nav-node) (arg2 vector) (arg3 float)) + (when (point-inside-rect? arg1 arg2 arg3) + (cond + ((zero? (-> arg1 type)) + (let ((v1-2 (-> arg1 left-offset)) + (s3-0 (-> arg1 right-offset)) + ) + (when (>= v1-2 0) + (let* ((a1-2 (the-as nav-node (&+ (the-as (pointer nav-node) (-> arg0 nodes)) v1-2))) + (v1-3 (recursive-inside-poly arg0 a1-2 arg2 arg3)) + ) + (if (>= v1-3 0) + (return v1-3) + ) + ) + ) + (when (>= s3-0 0) + (let* ((a1-3 (&+ (the-as (pointer nav-node) (-> arg0 nodes)) s3-0)) + (v1-7 (recursive-inside-poly arg0 (the-as nav-node a1-3) arg2 arg3)) + ) + (if (>= v1-7 0) + (return v1-7) + ) + ) + ) + ) + (return -1) + ) + (else + (let ((s3-1 (-> arg1 num-tris)) + (s2-1 (-> arg1 first-tris)) + ) + (dotimes (s1-0 (the-as int s3-1)) + (let ((s0-0 (-> s2-1 0))) + (if (point-inside-poly? arg0 s0-0 arg2 arg3) + (return (the-as int s0-0)) + ) + ) + (set! s2-1 (&-> s2-1 1)) + (if (= s1-0 3) + (set! s2-1 (&-> s2-1 4)) + ) + ) + ) + (return -1) + ) + ) + (the-as none 0) + ) + -1 + ) + +(defmethod find-poly-fast nav-mesh ((obj nav-mesh) (arg0 vector) (arg1 meters)) + (local-vars (a0-6 symbol) (a2-3 uint128) (a2-4 uint128)) + -1 + (let ((s2-0 -1) + (s3-0 (-> *display* base-frame-counter)) + (f0-0 (-> obj bounds w)) + ) + (when (>= (* f0-0 f0-0) (vector-length-squared arg0)) + (dotimes (v1-3 4) + (set! a0-6 (and (= (-> obj cache v1-3 time) s3-0) + (= (-> obj cache v1-3 vec w) arg1) + (begin + (let ((a3-0 (-> obj cache v1-3)) + (a2-1 arg0) + ) + (set! a0-6 #t) + (let* ((a1-3 #xffff) + (a3-1 (-> a3-0 vec quad)) + (a1-4 (shl a1-3 48)) + ) + (let ((a2-2 (-> a2-1 quad))) + (.pceqw a2-3 a3-1 a2-2) + ) + (.ppach a2-4 (the-as uint128 0) a2-3) + (b! (= (logior (the-as int a2-4) a1-4) -1) cfg-10 :delay (nop!)) + ) + ) + #f + ) + ) + ) + (label cfg-10) + (if a0-6 + (return (-> obj poly (-> obj cache v1-3 poly-ind))) + ) + (if (and (< s2-0 0) (!= (-> obj cache v1-3 time) s3-0)) + (set! s2-0 v1-3) + ) + ) + (let ((v1-12 (recursive-inside-poly obj (-> obj nodes 0) arg0 arg1))) + (when (>= v1-12 0) + (when (>= s2-0 0) + (let ((a0-24 (-> obj cache s2-0))) + (set! (-> a0-24 vec x) (-> arg0 x)) + (set! (-> a0-24 vec y) (-> arg0 y)) + (set! (-> a0-24 vec z) (-> arg0 z)) + (set! (-> a0-24 vec w) arg1) + (set! (-> a0-24 time) (the-as uint s3-0)) + (set! (-> a0-24 poly-ind) (the-as uint v1-12)) + ) + ) + (return (-> obj poly v1-12)) + ) + ) + ) + ) + (the-as nav-poly #f) + ) + +(defun circle-triangle-intersection-proc? ((arg0 vector) (arg1 float) (arg2 (inline-array nav-vertex))) + (let ((v1-0 0)) + (dotimes (a3-0 3) + (let* ((t0-4 (-> arg2 (-> *edge-vert0-table* a3-0))) + (t1-4 (-> arg2 (-> *edge-vert1-table* a3-0))) + (f0-1 (- (-> t0-4 z) (-> t1-4 z))) + (f1-2 (- (-> t1-4 x) (-> t0-4 x))) + (f2-2 (- (-> arg0 x) (-> t0-4 x))) + (f3-2 (- (-> arg0 z) (-> t0-4 z))) + (f4-1 f0-1) + (f4-3 (* f4-1 f4-1)) + (f5-0 f1-2) + (f4-5 (sqrtf (+ f4-3 (* f5-0 f5-0)))) + (f4-7 (/ 1.0 f4-5)) + (f0-2 (* f0-1 f4-7)) + (f1-3 (* f1-2 f4-7)) + (f0-4 (+ (* f2-2 f0-2) (* f3-2 f1-3))) + ) + (cond + ((< arg1 f0-4) + (return #f) + ) + ((< f0-4 0.0) + (+! v1-0 (-> *edge-mask-table* a3-0)) + ) + ) + ) + ) + (if (= v1-0 7) + (return #t) + ) + (let ((t0-15 #f) + (a3-5 0) + ) + (cond + ((= v1-0 1) + (set! t0-15 #t) + (set! a3-5 0) + ) + ((= v1-0 2) + (set! t0-15 #t) + (set! a3-5 1) + ) + ((= v1-0 4) + (set! t0-15 #t) + (set! a3-5 2) + ) + ((= v1-0 6) + (set! a3-5 0) + ) + ((= v1-0 5) + (set! a3-5 1) + ) + ((= v1-0 3) + (set! a3-5 2) + ) + ) + (when (not t0-15) + (let* ((t0-16 (-> arg2 (-> *edge-vert0-table* a3-5))) + (v1-18 (the-as vector (-> arg2 (-> *edge-vert1-table* a3-5)))) + (f1-8 (- (-> v1-18 x) (-> t0-16 x))) + (f0-7 (- (-> v1-18 z) (-> t0-16 z))) + (f2-7 (+ (* f1-8 (- (-> arg0 x) (-> t0-16 x))) (* f0-7 (- (-> arg0 z) (-> t0-16 z))))) + (f0-9 (+ (* f1-8 (- (-> arg0 x) (-> v1-18 x))) (* f0-7 (- (-> arg0 z) (-> v1-18 z))))) + ) + (cond + ((< f2-7 0.0) + (set! t0-15 #t) + (set! a3-5 (-> *edge-vert0-table* a3-5)) + ) + ((< 0.0 f0-9) + (set! t0-15 #t) + (set! a3-5 (-> *edge-vert1-table* a3-5)) + ) + (else + (return #t) + ) + ) + ) + ) + (when t0-15 + (let* ((v1-28 (-> arg2 a3-5)) + (f0-11 (- (-> v1-28 x) (-> arg0 x))) + (f0-13 (* f0-11 f0-11)) + (f1-14 (- (-> v1-28 z) (-> arg0 z))) + (f0-14 (+ f0-13 (* f1-14 f1-14))) + (f1-17 arg1) + ) + (if (>= (* f1-17 f1-17) f0-14) + #t + ) + ) + ) + ) + ) + ) + +(defun circle-triangle-intersection? ((arg0 vector) (arg1 float) (arg2 (inline-array nav-vertex))) + (let ((v1-0 arg0) + (f0-0 arg1) + (a0-1 arg2) + (a1-1 0) + ) + (dotimes (a2-1 3) + (let* ((a3-4 (-> a0-1 (-> *edge-vert0-table* a2-1))) + (t0-4 (-> a0-1 (-> *edge-vert1-table* a2-1))) + (f1-1 (- (-> a3-4 z) (-> t0-4 z))) + (f2-2 (- (-> t0-4 x) (-> a3-4 x))) + (f3-2 (- (-> v1-0 x) (-> a3-4 x))) + (f4-2 (- (-> v1-0 z) (-> a3-4 z))) + (f5-1 f1-1) + (f5-3 (* f5-1 f5-1)) + (f6-0 f2-2) + (f5-5 (sqrtf (+ f5-3 (* f6-0 f6-0)))) + (f5-7 (/ 1.0 f5-5)) + (f1-2 (* f1-1 f5-7)) + (f2-3 (* f2-2 f5-7)) + (f1-4 (+ (* f3-2 f1-2) (* f4-2 f2-3))) + ) + (cond + ((< f0-0 f1-4) + (return #f) + ) + ((< f1-4 0.0) + (+! a1-1 (-> *edge-mask-table* a2-1)) + ) + ) + ) + ) + (if (= a1-1 7) + (return #t) + ) + (let ((a3-15 #f) + (a2-6 0) + ) + (cond + ((= a1-1 1) + (set! a3-15 #t) + (set! a2-6 0) + ) + ((= a1-1 2) + (set! a3-15 #t) + (set! a2-6 1) + ) + ((= a1-1 4) + (set! a3-15 #t) + (set! a2-6 2) + ) + ((= a1-1 6) + (set! a2-6 0) + ) + ((= a1-1 5) + (set! a2-6 1) + ) + ((= a1-1 3) + (set! a2-6 2) + ) + ) + (when (not a3-15) + (let* ((a3-16 (-> a0-1 (-> *edge-vert0-table* a2-6))) + (a1-18 (-> a0-1 (-> *edge-vert1-table* a2-6))) + (f2-7 (- (-> a1-18 x) (-> a3-16 x))) + (f1-7 (- (-> a1-18 z) (-> a3-16 z))) + (f3-7 (+ (* f2-7 (- (-> v1-0 x) (-> a3-16 x))) (* f1-7 (- (-> v1-0 z) (-> a3-16 z))))) + (f1-9 (+ (* f2-7 (- (-> v1-0 x) (-> a1-18 x))) (* f1-7 (- (-> v1-0 z) (-> a1-18 z))))) + ) + (cond + ((< f3-7 0.0) + (set! a3-15 #t) + (set! a2-6 (-> *edge-vert0-table* a2-6)) + ) + ((< 0.0 f1-9) + (set! a3-15 #t) + (set! a2-6 (-> *edge-vert1-table* a2-6)) + ) + (else + (return #t) + ) + ) + ) + ) + (when a3-15 + (let* ((a0-2 (-> a0-1 a2-6)) + (f1-11 (- (-> a0-2 x) (-> v1-0 x))) + (f1-13 (* f1-11 f1-11)) + (f2-13 (- (-> a0-2 z) (-> v1-0 z))) + (f1-14 (+ f1-13 (* f2-13 f2-13))) + ) + (if (>= (* f0-0 f0-0) f1-14) + #t + ) + ) + ) + ) + ) + ) + +(defmethod is-in-mesh? nav-mesh ((obj nav-mesh) (arg0 vector) (arg1 float) (arg2 meters)) + (local-vars (v1-10 int)) + (rlet ((vf1 :class vf) + (vf2 :class vf) + (vf3 :class vf) + (vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + (vf7 :class vf) + ) + (let ((f0-1 (+ arg1 (-> obj bounds w)))) + (when (>= (* f0-1 f0-1) (vector-length-squared arg0)) + (let ((s2-0 (new 'stack-no-clear 'inline-array 'nav-vertex 6)) + (f30-1 0.33333334) + ) + (countdown (s1-0 (-> obj poly-count)) + (set! *debug-traverse* (+ *debug-traverse* 1)) + (let ((a0-3 (-> obj poly s1-0))) + (when (zero? (logand (-> a0-3 pat) 1)) + (nop!) + (let ((v1-8 (the-as object (-> obj vertex)))) + (nop!) + (let ((a2-1 (-> a0-3 vertex 0))) + (nop!) + (let* ((a1-1 (-> a0-3 vertex 1)) + (a2-2 (* a2-1 16)) + (a3-1 (-> a0-3 vertex 2)) + (a1-2 (* a1-1 16)) + (a0-4 (+ a2-2 (the-as int v1-8))) + (a2-3 (* a3-1 16)) + (a1-3 (+ a1-2 (the-as int v1-8))) + (v1-9 (+ a2-3 (the-as int v1-8))) + ) + (.lvf vf3 a0-4) + (let ((a0-5 f30-1)) + (.mov vf7 a0-5) + ) + (.lvf vf4 a1-3) + (.lvf vf5 v1-9) + ) + ) + ) + (.min.vf vf1 vf3 vf4 :mask #b111) + (.lvf vf6 (&-> arg0 quad)) + (.add.y.vf vf7 vf3 vf4 :mask #b10) + (.svf (&-> s2-0 0 quad) vf3) + (.max.vf vf2 vf3 vf4 :mask #b111) + (.svf (&-> s2-0 1 quad) vf4) + (.min.vf vf1 vf1 vf5 :mask #b111) + (.svf (&-> s2-0 2 quad) vf5) + (.max.vf vf2 vf2 vf5 :mask #b111) + (.mul.x.vf vf7 vf7 vf7 :mask #b10) + (.svf (&-> s2-0 3 quad) vf1) + (.svf (&-> s2-0 4 quad) vf2) + (.sub.y.vf vf7 vf6 vf7 :mask #b10) + (.mov v1-10 vf7) + (let ((v1-11 (the-as number (sar (the-as int v1-10) 32)))) + (when (and (>= arg2 (fabs (the-as float v1-11))) + (>= (+ (-> arg0 x) arg1) (-> s2-0 3 x)) + (>= (-> s2-0 4 x) (- (-> arg0 x) arg1)) + (>= (+ (-> arg0 z) arg1) (-> s2-0 3 z)) + (>= (-> s2-0 4 z) (- (-> arg0 z) arg1)) + ) + (set! *debug-tests* (+ *debug-tests* 1)) + (if (circle-triangle-intersection? arg0 arg1 s2-0) + (return #t) + ) + ) + ) + ) + ) + ) + ) + ) + ) + #f + ) + ) + +(defmethod move-along-nav-ray! nav-mesh ((obj nav-mesh) (arg0 nav-ray)) + (local-vars (a2-7 int) (a3-3 int)) + (let ((v1-0 -1) + (f0-1 (- (-> arg0 dest-pos x) (-> arg0 current-pos x))) + (f1-2 (- (-> arg0 dest-pos z) (-> arg0 current-pos z))) + ) + (dotimes (a2-0 3) + (let* ((a3-1 (-> obj vertex (-> arg0 current-poly vertex (-> *edge-vert0-table* a2-0)))) + (t0-7 (-> obj vertex (-> arg0 current-poly vertex (-> *edge-vert1-table* a2-0)))) + (f4-0 (- (-> a3-1 z) (-> t0-7 z))) + (f3-2 (- (-> t0-7 x) (-> a3-1 x))) + (f2-4 (+ (* f0-1 f4-0) (* f1-2 f3-2))) + ) + (when (< 0.0 f2-4) + (let ((f3-4 (+ (* f4-0 (- (-> a3-1 x) (-> arg0 current-pos x))) (* f3-2 (- (-> a3-1 z) (-> arg0 current-pos z)))))) + (when (< f3-4 f2-4) + (set! v1-0 a2-0) + (let ((f2-6 (fmax 0.0 (/ f3-4 f2-4)))) + (set! f0-1 (* f0-1 f2-6)) + (set! f1-2 (* f1-2 f2-6)) + ) + ) + ) + ) + ) + ) + (let ((f2-9 (+ (* f0-1 (-> arg0 dir x)) (* f1-2 (-> arg0 dir z))))) + (+! (-> arg0 len) f2-9) + ) + 0 + (set! (-> arg0 next-poly) #f) + (cond + ((= v1-0 -1) + (set! (-> arg0 current-pos quad) (-> arg0 dest-pos quad)) + (set! (-> arg0 reached-dest) #t) + (set! (-> arg0 terminated) #t) + ) + (else + (+! (-> arg0 current-pos x) f0-1) + (+! (-> arg0 current-pos z) f1-2) + (let ((a2-6 (+ v1-0 1))) + (let ((a3-2 2)) + (set-on-less-than a3-3 a3-2 a2-6) + ) + (move-if-not-zero a2-7 0 a3-3 a2-6) + ) + (let ((a2-9 (-> arg0 current-poly adj-poly a2-7))) + (if (!= a2-9 255) + (set! (-> arg0 next-poly) (-> obj poly a2-9)) + ) + ) + (cond + ((and (-> arg0 next-poly) (zero? (logand (-> arg0 next-poly pat) 1))) + (set! (-> arg0 current-poly) (-> arg0 next-poly)) + ) + (else + (set! (-> arg0 last-edge) v1-0) + (if (-> arg0 next-poly) + (set! (-> arg0 hit-gap) #t) + (set! (-> arg0 hit-boundary) #t) + ) + (set! (-> arg0 terminated) #t) + ) + ) + ) + ) + ) + 0 + (none) + ) + +(defun init-ray ((arg0 nav-ray)) + (vector-! (-> arg0 dir) (-> arg0 dest-pos) (-> arg0 current-pos)) + (set! (-> arg0 dir y) 0.0) + (vector-xz-normalize! (-> arg0 dir) 1.0) + (set! (-> arg0 next-poly) #f) + (set! (-> arg0 len) 0.0) + (set! (-> arg0 last-edge) -1) + (set! (-> arg0 terminated) #f) + (set! (-> arg0 reached-dest) #f) + (set! (-> arg0 hit-boundary) #f) + (set! (-> arg0 hit-gap) #f) + #f + ) + +(defun init-ray-local ((arg0 nav-ray) (arg1 nav-poly) (arg2 vector) (arg3 vector)) + (set! (-> arg0 current-pos quad) (-> arg2 quad)) + (set! (-> arg0 dest-pos quad) (-> arg3 quad)) + (set! (-> arg0 current-poly) arg1) + (init-ray arg0) + ) + +(defun init-ray-dir-local ((arg0 nav-ray) (arg1 nav-poly) (arg2 vector) (arg3 vector) (arg4 float)) + (set! (-> arg0 current-poly) arg1) + (set! (-> arg0 current-pos quad) (-> arg2 quad)) + (vector+*! (-> arg0 dest-pos) (-> arg0 current-pos) arg3 arg4) + (init-ray arg0) + ) + +(defmethod try-move-along-ray nav-mesh ((obj nav-mesh) (arg0 nav-poly) (arg1 vector) (arg2 vector) (arg3 float)) + (local-vars (v1-2 symbol)) + (let ((gp-0 (new 'stack-no-clear 'nav-ray))) + (let ((s4-0 0)) + (init-ray-dir-local gp-0 arg0 arg1 arg2 arg3) + (until v1-2 + (+! s4-0 1) + (move-along-nav-ray! obj gp-0) + (set! v1-2 (or (>= s4-0 15) (-> gp-0 terminated))) + ) + ) + (-> gp-0 len) + ) + ) + +(defun nav-ray-test ((arg0 nav-mesh) (arg1 nav-poly) (arg2 vector) (arg3 vector)) + (let ((s4-1 (vector-! (new 'stack-no-clear 'vector) arg2 (-> arg0 origin))) + (s3-1 (vector-! (new 'stack-no-clear 'vector) arg3 arg2)) + ) + 0.0 + (set! (-> s3-1 y) 0.0) + (let ((f30-0 (vector-vector-xz-distance arg2 arg3))) + (vector-xz-normalize! s3-1 1.0) + (try-move-along-ray arg0 arg1 s4-1 s3-1 f30-0) + ) + ) + ) + +(defun nav-ray-test-local? ((arg0 nav-mesh) (arg1 nav-poly) (arg2 vector) (arg3 vector)) + (local-vars (v1-2 symbol)) + (let ((gp-0 (new 'stack-no-clear 'nav-ray))) + (let ((s4-0 0)) + (init-ray-local gp-0 arg1 arg2 arg3) + (until v1-2 + (+! s4-0 1) + (move-along-nav-ray! arg0 gp-0) + (set! v1-2 (or (>= s4-0 15) (-> gp-0 terminated))) + ) + ) + (-> gp-0 reached-dest) + ) + ) + +(defun nav-mesh-update-route-table ((arg0 nav-mesh) (arg1 int) (arg2 int) (arg3 uint)) + (let* ((a1-1 (* (+ arg2 (* arg1 (-> arg0 poly-count))) 2)) + (v1-3 (/ a1-1 8)) + (a2-2 (- a1-1 (* v1-3 8))) + (a1-4 (lognot (ash 3 a2-2))) + (v0-0 (logior (ash (logand arg3 3) a2-2) (logand a1-4 (-> (the-as (pointer uint8) (-> arg0 route)) v1-3)))) + ) + (set! (-> (the-as (pointer uint8) (-> arg0 route)) v1-3) (the-as uint v0-0)) + (the-as uint v0-0) + ) + ) + +(defun nav-mesh-lookup-route ((arg0 nav-mesh) (arg1 int) (arg2 int)) + (let ((v1-3 (* (+ arg1 (* arg2 (-> arg0 poly-count))) 2))) + (logand (ash (-> (the-as (pointer uint8) (-> arg0 route)) (/ v1-3 8)) (- (logand v1-3 7))) 3) + ) + ) + +(define *nav-update-route-table-ray-count* 0) + +(define *nav-update-route-table-route-count* 0) + +(defmethod dummy-18 nav-mesh ((obj nav-mesh) (arg0 int) (arg1 vector) (arg2 int) (arg3 (pointer int8)) (arg4 int)) + (local-vars (sv-32 int) (sv-48 uint)) + (set! (-> arg3 arg2) 1) + (nav-mesh-update-route-table obj arg0 arg2 (the-as uint 3)) + (nav-mesh-update-route-table obj arg2 arg0 (the-as uint 3)) + (set! *nav-update-route-table-route-count* (+ *nav-update-route-table-route-count* 1)) + (when (> arg4 0) + (let ((s1-1 (-> obj poly arg2)) + (s0-0 (new 'stack-no-clear 'vector)) + ) + (set! sv-32 0) + (while (< sv-32 3) + (set! sv-48 (-> (the-as nav-poly (+ sv-32 (the-as int s1-1))) adj-poly 0)) + (when (and (!= sv-48 255) (!= 1 (-> (the-as (pointer uint8) (&+ arg3 sv-48))))) + (set! (-> arg3 sv-48) 1) + (when (zero? (logand (-> obj poly sv-48 pat) 1)) + (let ((v0-3 (= (nav-mesh-lookup-route obj arg0 (the-as int sv-48)) 3))) + (when (not v0-3) + (tri-centroid-local obj s1-1 s0-0) + (set! *nav-update-route-table-ray-count* (+ *nav-update-route-table-ray-count* 1)) + (set! v0-3 (nav-ray-test-local? obj (-> obj poly arg0) arg1 s0-0)) + ) + (when v0-3 + (let* ((a0-16 obj) + (t9-5 (method-of-object a0-16 dummy-18)) + (a1-7 arg0) + (a2-6 arg1) + (t0-1 arg3) + (t1-1 (+ arg4 -1)) + ) + (t9-5 a0-16 a1-7 a2-6 (the-as int sv-48) t0-1 t1-1) + ) + ) + ) + ) + ) + (set! sv-32 (+ sv-32 1)) + ) + ) + ) + 0 + (none) + ) + +(defmethod update-route-table nav-mesh ((obj nav-mesh)) + (when *nav-patch-route-table* + (stopwatch-init *nav-timer*) + (stopwatch-begin *nav-timer*) + (let ((s5-0 (new 'stack-no-clear 'vector))) + (new 'stack-no-clear 'vector) + (let ((s4-0 (new 'stack-no-clear 'array 'int8 256))) + (set! *nav-update-route-table-ray-count* 0) + (set! *nav-update-route-table-route-count* 0) + (countdown (s3-0 (-> obj poly-count)) + (let ((s2-0 (-> obj poly s3-0))) + (when (zero? (logand (-> s2-0 pat) 1)) + (tri-centroid-local obj s2-0 s5-0) + (mem-set32! s4-0 64 0) + (set! (-> s4-0 s3-0) 1) + (dotimes (s1-0 3) + (let ((a3-0 (-> s2-0 adj-poly s1-0))) + (when (!= a3-0 255) + (if (zero? (logand (-> obj poly a3-0 pat) 1)) + (dummy-18 obj s3-0 s5-0 (the-as int a3-0) s4-0 0) + ) + ) + ) + ) + ) + ) + ) + ) + ) + (stopwatch-end *nav-timer*) + ) + 0 + (none) + ) + +(defun point-triangle-distance-min ((arg0 vector) (arg1 float) (arg2 (inline-array nav-vertex))) + (let ((v1-0 0) + (f0-0 arg1) + ) + (dotimes (a3-0 3) + (let* ((t0-4 (-> arg2 (-> *edge-vert0-table* a3-0))) + (t1-4 (-> arg2 (-> *edge-vert1-table* a3-0))) + (f1-1 (- (-> t0-4 z) (-> t1-4 z))) + (f2-2 (- (-> t1-4 x) (-> t0-4 x))) + (f3-2 (- (-> arg0 x) (-> t0-4 x))) + (f4-2 (- (-> arg0 z) (-> t0-4 z))) + (f5-1 f1-1) + (f5-3 (* f5-1 f5-1)) + (f6-0 f2-2) + (f5-5 (sqrtf (+ f5-3 (* f6-0 f6-0)))) + (f5-7 (/ 1.0 f5-5)) + (f1-2 (* f1-1 f5-7)) + (f2-3 (* f2-2 f5-7)) + (f1-4 (+ (* f1-2 f3-2) (* f2-3 f4-2))) + ) + (cond + ((< arg1 f1-4) + (return arg1) + ) + ((>= 0.0 f1-4) + (+! v1-0 (-> *edge-mask-table* a3-0)) + ) + (else + (set! f0-0 f1-4) + ) + ) + ) + ) + (if (= v1-0 7) + (return 0.0) + ) + (let ((t0-14 #f) + (a3-5 0) + ) + (cond + ((= v1-0 1) + (set! t0-14 #t) + (set! a3-5 0) + ) + ((= v1-0 2) + (set! t0-14 #t) + (set! a3-5 1) + ) + ((= v1-0 4) + (set! t0-14 #t) + (set! a3-5 2) + ) + ((= v1-0 6) + (set! a3-5 0) + ) + ((= v1-0 5) + (set! a3-5 1) + ) + ((= v1-0 3) + (set! a3-5 2) + ) + ) + (when (not t0-14) + (let* ((t0-15 (-> arg2 (-> *edge-vert0-table* a3-5))) + (v1-17 (-> arg2 (-> *edge-vert1-table* a3-5))) + (f2-8 (- (-> v1-17 x) (-> t0-15 x))) + (f1-7 (- (-> v1-17 z) (-> t0-15 z))) + (f3-7 (+ (* f2-8 (- (-> arg0 x) (-> t0-15 x))) (* f1-7 (- (-> arg0 z) (-> t0-15 z))))) + (f1-9 (+ (* f2-8 (- (-> arg0 x) (-> v1-17 x))) (* f1-7 (- (-> arg0 z) (-> v1-17 z))))) + ) + (cond + ((< f3-7 0.0) + (set! t0-14 #t) + (set! a3-5 (-> *edge-vert0-table* a3-5)) + ) + ((< 0.0 f1-9) + (set! t0-14 #t) + (set! a3-5 (-> *edge-vert1-table* a3-5)) + ) + (else + (return f0-0) + ) + ) + ) + ) + (when t0-14 + (let* ((v1-27 (-> arg2 a3-5)) + (f0-2 (- (-> v1-27 x) (-> arg0 x))) + (f0-4 (* f0-2 f0-2)) + (f1-12 (- (-> v1-27 z) (-> arg0 z))) + ) + (set! f0-0 (fmin (sqrtf (+ f0-4 (* f1-12 f1-12))) arg1)) + ) + ) + ) + f0-0 + ) + ) + +(defmethod find-poly nav-mesh ((obj nav-mesh) (arg0 vector) (arg1 meters) (arg2 (pointer nav-control-flags))) + (local-vars (s3-1 nav-poly)) + (let ((v1-1 (find-poly-fast obj arg0 arg1))) + (when v1-1 + (if arg2 + (set! (-> arg2 0) (logior (nav-control-flags bit20) (-> arg2 0))) + ) + (set! s3-1 v1-1) + (goto cfg-14) + ) + ) + (if arg2 + (logclear! (-> arg2 0) (nav-control-flags bit20)) + ) + (let ((s2-0 (new 'stack-no-clear 'inline-array 'nav-vertex 3))) + (set! s3-1 (the-as nav-poly #f)) + (let ((f30-0 10000000000000000000000000000000000000.0)) + (countdown (s1-0 (-> obj poly-count)) + (let ((s0-0 (-> obj poly s1-0))) + (when (zero? (logand (-> s0-0 pat) 1)) + (set! (-> s2-0 0 quad) (-> obj vertex (-> s0-0 vertex 0) quad)) + (set! (-> s2-0 1 quad) (-> obj vertex (-> s0-0 vertex 1) quad)) + (set! (-> s2-0 2 quad) (-> obj vertex (-> s0-0 vertex 2) quad)) + (let ((f1-2 (- (-> arg0 y) (* 0.333333 (+ (-> s2-0 0 y) (-> s2-0 1 y) (-> s2-0 2 y)))))) + (when (>= arg1 (fabs f1-2)) + (let ((f0-2 (point-triangle-distance-min arg0 f30-0 s2-0))) + (when (< f0-2 f30-0) + (set! f30-0 f0-2) + (set! s3-1 s0-0) + ) + ) + ) + ) + ) + ) + ) + ) + ) + (label cfg-14) + s3-1 + ) + +(defmethod setup-portal nav-mesh ((obj nav-mesh) (arg0 nav-poly) (arg1 nav-poly) (arg2 nav-route-portal)) + (local-vars (t0-6 int) (t1-1 int)) + (set! (-> arg2 next-poly) #f) + (cond + ((and arg0 arg1) + (let* ((v1-3 (* (+ (-> arg1 id) (* (the-as int (-> arg0 id)) (-> obj poly-count))) 2)) + (v1-8 + (logand (ash (-> (the-as (pointer uint8) (-> obj route)) (/ (the-as int v1-3) 8)) (- (the-as int (logand v1-3 7)))) + 3 + ) + ) + ) + (set! (-> arg2 edge-index) -1) + (when (!= v1-8 3) + (let ((a2-9 (-> arg0 adj-poly v1-8))) + (when (!= a2-9 255) + (set! (-> arg2 edge-index) (the-as int v1-8)) + (set! (-> arg2 next-poly) (-> obj poly a2-9)) + (let ((a2-12 (-> obj vertex))) + (let ((t0-5 (+ v1-8 1))) + (let ((t1-0 2)) + (set-on-less-than t1-1 t1-0 t0-5) + ) + (move-if-not-zero t0-6 0 t1-1 t0-5) + ) + (set! (-> arg2 vertex 0) (-> a2-12 (-> arg0 vertex t0-6))) + ) + (set! (-> arg2 vertex 1) (-> obj vertex (-> arg0 vertex v1-8))) + #t + ) + ) + ) + ) + ) + (else + 0 + ) + ) + ) + +(defmethod get-adj-poly nav-mesh ((obj nav-mesh) (arg0 nav-poly) (arg1 nav-poly) (arg2 symbol)) + (local-vars (v1-12 uint) (t0-6 int) (t1-1 int)) + (cond + ((and arg0 arg1) + (let* ((v1-3 (* (+ (-> arg1 id) (* (the-as int (-> arg0 id)) (-> obj poly-count))) 2)) + (a2-6 + (logand (ash (-> (the-as (pointer uint8) (-> obj route)) (/ (the-as int v1-3) 8)) (- (the-as int (logand v1-3 7)))) + 3 + ) + ) + ) + (if arg2 + (set! (-> arg2 value) (the-as uint #xffffffff)) + ) + (cond + ((= a2-6 3) + (the-as nav-poly #f) + ) + ((begin (set! v1-12 (-> arg0 adj-poly a2-6)) (= v1-12 255)) + (the-as nav-poly #f) + ) + (else + (when arg2 + (let ((t0-5 (+ a2-6 1))) + (let ((t1-0 2)) + (set-on-less-than t1-1 t1-0 t0-5) + ) + (move-if-not-zero t0-6 0 t1-1 t0-5) + ) + (set! (-> arg2 value) (logior (-> arg0 vertex t0-6) (shl (-> arg0 vertex a2-6) 16))) + ) + (-> obj poly v1-12) + ) + ) + ) + ) + (else + (the-as nav-poly #f) + ) + ) + ) + +(defmethod compute-bounding-box nav-mesh ((obj nav-mesh) (arg0 vector) (arg1 vector)) + (let ((f0-0 10000000000000000000000000000000000000.0) + (f1-0 -10000000000000000000000000000000000000.0) + ) + (set! (-> arg0 x) f0-0) + (set! (-> arg0 y) f0-0) + (set! (-> arg0 z) f0-0) + (set! (-> arg1 x) f1-0) + (set! (-> arg1 y) f1-0) + (set! (-> arg1 z) f1-0) + ) + (dotimes (v1-1 (-> obj vertex-count)) + (let ((a3-1 (-> obj vertex v1-1))) + (set! (-> arg0 x) (fmin (-> arg0 x) (-> a3-1 x))) + (set! (-> arg0 y) (fmin (-> arg0 y) (-> a3-1 y))) + (set! (-> arg0 z) (fmin (-> arg0 z) (-> a3-1 z))) + (set! (-> arg1 x) (fmax (-> arg1 x) (-> a3-1 x))) + (set! (-> arg1 y) (fmax (-> arg1 y) (-> a3-1 y))) + (set! (-> arg1 z) (fmax (-> arg1 z) (-> a3-1 z))) + ) + ) + (vector+! arg0 arg0 (-> obj origin)) + (vector+! arg1 arg1 (-> obj origin)) + 0 + (none) + ) + +(defmethod initialize-mesh! nav-mesh ((obj nav-mesh)) + (local-vars (sv-32 vector) (sv-48 int)) + (with-pp + (set! sv-32 (new 'stack-no-clear 'vector)) + (let ((s5-0 (-> obj poly-count)) + (s3-0 (-> obj vertex-count)) + (s1-0 0) + (s2-0 0) + (s4-0 0) + (gp-0 #f) + ) + (set! sv-48 s5-0) + (while (nonzero? sv-48) + (set! sv-48 (+ sv-48 -1)) + (let ((v1-4 (-> obj poly sv-48))) + (if (logtest? (-> v1-4 pat) 1) + (+! s4-0 1) + ) + (let ((a1-2 (-> obj vertex (-> v1-4 vertex 0))) + (a2-2 (-> obj vertex (-> v1-4 vertex 1))) + (a3-0 (-> obj vertex (-> v1-4 vertex 2))) + ) + (vector-3pt-cross! sv-32 a1-2 a2-2 a3-0) + ) + ) + (cond + ((= (vector-length sv-32) 0.0) + (+! s1-0 1) + ) + (else + (vector-normalize! sv-32 1.0) + (if (>= 0.0 (-> sv-32 y)) + (+! s2-0 1) + ) + ) + ) + ) + (when (zero? s5-0) + (format #t "WARNING: nav-mesh has no triangles. ") + (set! gp-0 #t) + ) + (when (> s1-0 0) + (format #t "WARNING: nav-mesh has ~D triangles with zero area (out of ~D triangles). " s1-0 s5-0) + (set! gp-0 #t) + ) + (when (> s2-0 0) + (format #t "WARNING: nav-mesh has ~D triangles with inverted normals (out of ~D triangles). " s2-0 s5-0) + (set! gp-0 #t) + ) + (when (< 255 s5-0) + (format #t "WARNING: nav-mesh has ~D triangles (only up to ~D are allowed). " s5-0 255) + (set! gp-0 #t) + ) + (when (< 255 s3-0) + (format #t "WARNING: nav-mesh has ~D vertices (only up to ~D are allowed). " s3-0 255) + (set! gp-0 #t) + ) + (when (= s4-0 s5-0) + (format #t "WARNING: nav-mesh only contains gap triangles (~D triangles total). " s5-0) + (set! gp-0 #t) + ) + (when gp-0 + (if pp + (format #t "current process is ~A~%" (-> pp name)) + (format #t "(no current process).~%") + ) + ) + ) + 0 + (none) + ) + ) + +(defmethod find-opposite-vertices nav-mesh ((obj nav-mesh) (arg0 nav-poly) (arg1 nav-poly)) + (when (!= arg0 arg1) + (dotimes (v1-1 3) + (dotimes (a0-1 3) + (when (= (-> arg0 vertex v1-1) (-> arg1 vertex a0-1)) + (let ((a3-6 (-> arg0 vertex (mod (+ v1-1 1) 3)))) + (dotimes (t0-3 3) + (if (and (!= t0-3 a0-1) (= a3-6 (-> arg1 vertex t0-3))) + (return (logior a3-6 (shl (-> arg0 vertex v1-1) 16))) + ) + ) + ) + ) + ) + ) + ) + (the-as uint #xffffffff) + ) + +(defun ray-ccw-line-segment-intersection? ((arg0 vector) (arg1 vector) (arg2 vector) (arg3 vector)) + (let ((f0-2 (- (* (-> arg2 x) (-> arg1 z)) (* (-> arg2 z) (-> arg1 x)))) + (f2-4 (- (* (-> arg3 x) (-> arg1 z)) (* (-> arg3 z) (-> arg1 x)))) + (f3-4 (- (* (-> arg0 x) (-> arg1 z)) (* (-> arg0 z) (-> arg1 x)))) + (v0-0 #f) + ) + (let ((f1-7 (- f2-4 f0-2)) + (f2-5 (- f2-4 f3-4)) + (f3-5 (- f3-4 f0-2)) + ) + (when (and (>= (fabs f1-7) (fmax (fabs f3-5) (fabs f2-5))) (!= f1-7 0.0)) + (let ((f0-7 (+ (* (-> arg1 x) (- (-> arg3 z) (-> arg2 z))) (* (-> arg1 z) (- (-> arg2 x) (-> arg3 x)))))) + (set! v0-0 (< 0.0 f0-7)) + ) + ) + ) + v0-0 + ) + ) + +(defun ray-line-segment-intersection? ((arg0 vector) (arg1 vector) (arg2 vector) (arg3 vector)) + (let ((f1-3 (- (* (-> arg2 x) (-> arg1 z)) (* (-> arg2 z) (-> arg1 x)))) + (f0-4 (- (* (-> arg3 x) (-> arg1 z)) (* (-> arg3 z) (-> arg1 x)))) + (f2-6 (- (* (-> arg0 x) (-> arg1 z)) (* (-> arg0 z) (-> arg1 x)))) + (gp-0 #f) + ) + (let ((f30-0 (- f0-4 f1-3)) + (f0-5 (- f0-4 f2-6)) + (f1-4 (- f2-6 f1-3)) + ) + (when (and (>= (fabs f30-0) (fmax (fabs f1-4) (fabs f0-5))) (!= f30-0 0.0)) + (let ((f2-11 (+ (* (-> arg2 x) (-> arg1 x)) (* (-> arg2 z) (-> arg1 z)))) + (f3-11 (+ (* (-> arg3 x) (-> arg1 x)) (* (-> arg3 z) (-> arg1 z)))) + (f28-0 (+ (* (-> arg0 x) (-> arg1 x)) (* (-> arg0 z) (-> arg1 z)))) + ) + (if (>= (* (+ (* f2-11 f0-5) (* f3-11 f1-4)) (sign f30-0)) (* f28-0 (fabs f30-0))) + (set! gp-0 #t) + ) + ) + ) + ) + gp-0 + ) + ) + +(define *debug-offset* (new 'static 'vector :y 4096.0 :w 1.0)) + +(defun clip-vector-to-halfspace! ((arg0 vector) (arg1 float) (arg2 float) (arg3 float)) + (let ((f0-2 (+ (* arg1 (-> arg0 x)) (* arg2 (-> arg0 z))))) + (when (< arg3 f0-2) + (let ((f0-3 (/ arg3 f0-2))) + (set! (-> arg0 x) (* (-> arg0 x) f0-3)) + (let ((f0-4 (* (-> arg0 z) f0-3))) + (set! (-> arg0 z) f0-4) + f0-4 + ) + ) + ) + ) + ) + +(defmethod dummy-23 nav-mesh ((obj nav-mesh) (arg0 nav-poly) (arg1 vector) (arg2 vector) (arg3 vector) (arg4 nav-route-portal)) + (local-vars (v1-32 int) (a0-14 int) (a0-17 int) (a1-10 int) (sv-16 nav-vertex)) + (let ((s1-0 (-> obj vertex)) + (s0-0 -1) + ) + (set! (-> arg2 quad) (-> arg3 quad)) + (dotimes (v1-1 3) + (let* ((a0-8 (-> s1-0 (-> arg0 vertex (-> *edge-vert0-table* v1-1)))) + (a1-7 (-> s1-0 (-> arg0 vertex (-> *edge-vert1-table* v1-1)))) + (f0-1 (- (-> a0-8 z) (-> a1-7 z))) + (f1-2 (- (-> a1-7 x) (-> a0-8 x))) + (f2-4 (+ (* f0-1 (- (-> a0-8 x) (-> arg1 x))) (* f1-2 (- (-> a0-8 z) (-> arg1 z))))) + (f0-3 (+ (* (-> arg2 x) f0-1) (* (-> arg2 z) f1-2))) + ) + (when (< f2-4 f0-3) + (set! s0-0 v1-1) + (let ((f0-4 (/ f2-4 f0-3))) + (set! (-> arg2 x) (* (-> arg2 x) f0-4)) + (set! (-> arg2 z) (* (-> arg2 z) f0-4)) + ) + ) + ) + ) + (when arg4 + (cond + ((= s0-0 -1) + (set! (-> arg4 next-poly) #f) + ) + (else + (while (!= s0-0 -1) + (let ((v1-11 (-> arg0 adj-poly (-> *edge-vert0-table* s0-0)))) + (cond + ((!= v1-11 255) + (set! (-> arg4 next-poly) (-> obj poly v1-11)) + (set! s0-0 -1) + ) + ((let ((a1-8 (-> s1-0 (-> arg0 vertex (-> *edge-vert0-table* s0-0))))) + (set! sv-16 (-> s1-0 (-> arg0 vertex (-> *edge-vert1-table* s0-0)))) + (< (vector-vector-xz-distance arg1 a1-8) 204.8) + ) + (let ((a1-9 (+ s0-0 -1)) + (v1-28 2) + ) + (set-on-less-than a0-14 a1-9 0) + (move-if-not-zero a1-10 v1-28 a0-14 a1-9) + ) + (set! s0-0 a1-10) + ) + ((< (vector-vector-xz-distance arg1 sv-16) 204.8) + (let ((v1-31 (+ s0-0 1))) + (let ((a0-16 2)) + (set-on-less-than a0-17 a0-16 v1-31) + ) + (move-if-not-zero v1-32 0 a0-17 v1-31) + ) + (set! s0-0 v1-32) + ) + (else + (set! (-> arg4 next-poly) #f) + (set! s0-0 -1) + ) + ) + ) + ) + ) + ) + ) + ) + (set! (-> arg2 y) (-> arg1 y)) + arg2 + ) + +(defmethod project-point-into-tri-3d nav-mesh ((obj nav-mesh) (arg0 nav-poly) (arg1 vector) (arg2 vector)) + (let ((s3-0 (new 'stack-no-clear 'vector)) + (s4-0 (new 'stack-no-clear 'matrix)) + ) + (dotimes (v1-0 3) + (set! (-> s4-0 vector v1-0 quad) (the-as uint128 0)) + ) + (set! (-> s4-0 vector 0 quad) (-> obj vertex (-> arg0 vertex 0) quad)) + (set! (-> s4-0 vector 1 quad) (-> obj vertex (-> arg0 vertex 1) quad)) + (set! (-> s4-0 vector 2 quad) (-> obj vertex (-> arg0 vertex 2) quad)) + (normal-of-plane s3-0 (the-as vector (-> s4-0 vector)) (-> s4-0 vector 1) (-> s4-0 vector 2)) + (closest-pt-in-triangle arg1 arg2 s4-0 s3-0) + ) + (none) + ) + +(defmethod project-onto-nav-mesh nav-control ((obj nav-control) (arg0 vector) (arg1 vector)) + (local-vars (sv-32 int)) + (let ((s5-0 (-> obj mesh)) + (s3-1 (vector-! (new 'stack-no-clear 'vector) arg1 (-> obj mesh origin))) + ) + (set! sv-32 0) + (let ((a1-5 (find-poly s5-0 s3-1 (-> obj nearest-y-threshold) (the-as (pointer nav-control-flags) (& sv-32))))) + (cond + ((logtest? #x100000 sv-32) + (set! (-> arg0 quad) (-> arg1 quad)) + ) + (else + (closest-point-on-boundary s5-0 a1-5 arg0 s3-1) + (vector+! arg0 arg0 (-> s5-0 origin)) + ) + ) + ) + ) + arg0 + ) + +(defmethod find-poly nav-control ((obj nav-control) (arg0 vector)) + (find-poly + (-> obj mesh) + (vector-! (new 'stack-no-clear 'vector) arg0 (-> obj mesh origin)) + (-> obj nearest-y-threshold) + (the-as (pointer nav-control-flags) #f) + ) + ) + +(defmethod project-point-into-tri-3d nav-control ((obj nav-control) (arg0 nav-poly) (arg1 vector) (arg2 vector)) + (project-point-into-tri-3d + (-> obj mesh) + arg0 + arg1 + (vector-! (new 'stack-no-clear 'vector) arg2 (-> obj mesh origin)) + ) + (vector+! arg1 arg1 (-> obj mesh origin)) + arg1 + ) + +(defmethod is-in-mesh? nav-control ((obj nav-control) (arg0 vector) (arg1 float)) + (let ((v1-1 (vector-! (new 'stack-no-clear 'vector) arg0 (-> obj mesh origin))) + (a1-1 (-> obj mesh)) + ) + (is-in-mesh? a1-1 v1-1 arg1 (-> obj nearest-y-threshold)) + ) + ) + +(defmethod debug-draw nav-control ((obj nav-control)) + (local-vars + (sv-192 vector) + (sv-208 uint) + (sv-224 int) + (sv-240 (function _varargs_ object)) + (sv-256 string) + (sv-272 int) + (sv-288 (function _varargs_ object)) + ) + (let ((a0-1 obj)) + (when (and *display-nav-marks* (logtest? (-> a0-1 flags) (nav-control-flags display-marks))) + (let ((s5-0 (-> obj mesh)) + (s4-0 (new 'stack-no-clear 'vector)) + ) + (= (-> obj mesh debug-time) (logand (-> *display* actual-frame-counter) 255)) + (when #t + (set! (-> s5-0 debug-time) (the-as uint (-> *display* actual-frame-counter))) + (add-debug-sphere + (logtest? (-> obj flags) (nav-control-flags bit1)) + (bucket-id debug-draw0) + (-> s5-0 bounds) + (-> s5-0 bounds w) + (new 'static 'rgba :r #xff :g #xff :a #x20) + ) + (add-debug-vector #t (bucket-id debug-draw1) (-> s5-0 origin) *x-vector* (meters 1.0) *color-red*) + (add-debug-vector #t (bucket-id debug-draw1) (-> s5-0 origin) *z-vector* (meters 1.0) *color-blue*) + (when (logtest? (-> obj flags) (nav-control-flags bit2)) + (dotimes (s3-0 (-> s5-0 vertex-count)) + (add-debug-x + #t + (bucket-id debug-draw1) + (vector+! s4-0 (-> s5-0 origin) (the-as vector (-> s5-0 vertex s3-0))) + *color-green* + ) + ) + ) + (when #f + (dotimes (s3-1 (-> s5-0 node-count)) + (let ((a1-4 (-> s5-0 nodes s3-1)) + (a0-15 (new 'stack-no-clear 'vector)) + (v1-20 (new 'stack-no-clear 'vector)) + ) + (set! sv-192 (new 'stack-no-clear 'vector)) + (let ((s2-0 (new 'stack-no-clear 'vector)) + (s1-0 (new 'stack-no-clear 'vector)) + (s0-0 (new 'stack-no-clear 'vector)) + ) + (set! sv-208 (the-as uint #x80808080)) + (set! (-> a0-15 quad) (-> a1-4 center quad)) + (set! (-> v1-20 quad) (-> a1-4 radius quad)) + (set! (-> sv-192 w) 1.0) + (set! (-> s2-0 w) 1.0) + (set! (-> s1-0 w) 1.0) + (set! (-> s0-0 w) 1.0) + (set! (-> sv-192 x) (+ (-> a0-15 x) (-> v1-20 x))) + (set! (-> sv-192 y) (+ (-> a0-15 y) (-> v1-20 y))) + (set! (-> sv-192 z) (+ (-> a0-15 z) (-> v1-20 z))) + (set! (-> s2-0 x) (+ (-> a0-15 x) (-> v1-20 x))) + (set! (-> s2-0 y) (+ (-> a0-15 y) (-> v1-20 y))) + (set! (-> s2-0 z) (- (-> a0-15 z) (-> v1-20 z))) + (set! (-> s1-0 x) (- (-> a0-15 x) (-> v1-20 x))) + (set! (-> s1-0 y) (+ (-> a0-15 y) (-> v1-20 y))) + (set! (-> s1-0 z) (- (-> a0-15 z) (-> v1-20 z))) + (set! (-> s0-0 x) (- (-> a0-15 x) (-> v1-20 x))) + (set! (-> s0-0 y) (+ (-> a0-15 y) (-> v1-20 y))) + (set! (-> s0-0 z) (+ (-> a0-15 z) (-> v1-20 z))) + (add-debug-line #t (bucket-id debug-draw1) sv-192 s2-0 (the-as rgba sv-208) #f (the-as rgba -1)) + (add-debug-line #t (bucket-id debug-draw1) s2-0 s1-0 (the-as rgba sv-208) #f (the-as rgba -1)) + (add-debug-line #t (bucket-id debug-draw1) s1-0 s0-0 (the-as rgba sv-208) #f (the-as rgba -1)) + (let ((t9-7 add-debug-line) + (a0-19 #t) + (a1-13 68) + (t1-5 #f) + (t2-3 -1) + ) + (t9-7 a0-19 (the-as bucket-id a1-13) s0-0 sv-192 (the-as rgba sv-208) t1-5 (the-as rgba t2-3)) + ) + ) + ) + ) + ) + (when (logtest? (-> obj flags) (nav-control-flags bit3)) + (dotimes (s3-2 (-> s5-0 poly-count)) + (let ((s2-1 (-> s5-0 poly s3-2))) + (debug-draw-poly s5-0 s2-1 (the-as rgba (cond + ((logtest? (-> s2-1 pat) 1) + #x40808000 + ) + ((logtest? (-> s2-1 pat) 2) + #x4080ff00 + ) + ((logtest? (-> s2-1 pat) 4) + (the-as int (the-as uint #x8040ff00)) + ) + ((logtest? (-> s2-1 pat) 8) + (the-as int (the-as uint #xff408000)) + ) + ((logtest? (-> s2-1 pat) 16) + (the-as int (the-as uint #xff408000)) + ) + (else + (the-as int (the-as uint #x80ff8000)) + ) + ) + ) + ) + (when (logtest? (-> obj flags) (nav-control-flags bit4)) + (let ((s1-1 add-debug-text-3d) + (s0-1 #t) + ) + (set! sv-224 68) + (set! sv-240 format) + (let ((a0-23 (clear *temp-string*)) + (a1-15 "~D") + (a2-13 (-> s2-1 id)) + ) + (sv-240 a0-23 a1-15 a2-13) + ) + (set! sv-256 *temp-string*) + (let ((a3-10 (tri-centroid-world s5-0 s2-1 s4-0)) + (t0-8 8) + (t1-6 #f) + ) + (s1-1 s0-1 (the-as bucket-id sv-224) sv-256 a3-10 (the-as font-color t0-8) (the-as vector2h t1-6)) + ) + ) + ) + ) + ) + ) + (when (logtest? (-> obj flags) (nav-control-flags bit5)) + (if (-> obj next-poly) + (debug-draw-poly s5-0 (-> obj next-poly) *color-cyan*) + ) + (if (-> obj target-poly) + (debug-draw-poly s5-0 (-> obj target-poly) *color-yellow*) + ) + (if (-> obj current-poly) + (debug-draw-poly s5-0 (-> obj current-poly) *color-red*) + ) + ) + (when (logtest? (-> obj flags) (nav-control-flags bit7)) + (dotimes (s3-3 (the-as int (-> s5-0 static-sphere-count))) + (let ((s2-2 (-> s5-0 static-sphere s3-3))) + (add-debug-sphere #t (bucket-id debug-draw0) (the-as vector s2-2) (-> s2-2 trans w) *color-blue*) + (let ((s1-2 add-debug-text-3d) + (s0-2 #t) + ) + (set! sv-272 68) + (set! sv-288 format) + (let ((a0-32 (clear *temp-string*)) + (a1-22 "~D") + (a2-20 s3-3) + ) + (sv-288 a0-32 a1-22 a2-20) + ) + (let ((a2-21 *temp-string*) + (t0-10 8) + (t1-7 #f) + ) + (s1-2 + s0-2 + (the-as bucket-id sv-272) + a2-21 + (the-as vector s2-2) + (the-as font-color t0-10) + (the-as vector2h t1-7) + ) + ) + ) + ) + ) + ) + ) + (when (logtest? (-> obj flags) (nav-control-flags bit6)) + (when (and (-> obj portal 0) (-> obj portal 1)) + (let ((v1-80 (-> s5-0 origin)) + (a2-22 (new 'stack-no-clear 'vector)) + (a3-13 (new 'stack-no-clear 'vector)) + ) + (add-debug-line + #t + (bucket-id debug-draw1) + (vector+! a2-22 v1-80 (the-as vector (-> obj portal 0))) + (vector+! a3-13 v1-80 (the-as vector (-> obj portal 1))) + (new 'static 'rgba :r #xff :g #x80 :b #x40 :a #x80) + #f + (the-as rgba -1) + ) + ) + ) + (add-debug-vector + #t + (bucket-id debug-draw1) + (-> obj shape trans) + (-> obj travel) + (meters 0.00024414062) + *color-white* + ) + (add-debug-vector + #t + (bucket-id debug-draw1) + (vector+! (new 'stack-no-clear 'vector) (-> obj shape trans) (new 'static 'vector :y 4096.0 :w 1.0)) + (-> obj old-travel) + (meters 0.00024414062) + *color-yellow* + ) + (add-debug-x + #t + (bucket-id debug-draw1) + (vector+! (new 'stack-no-clear 'vector) (-> obj shape trans) (-> obj travel)) + (new 'static 'rgba :r #xff :g #xff :b #xff :a #x80) + ) + ) + (when (logtest? (-> obj flags) (nav-control-flags bit7)) + (add-debug-sphere + #t + (bucket-id debug-draw1) + (the-as vector (-> obj shape root-prim prim-core)) + (-> obj shape nav-radius) + (new 'static 'rgba :g #xff :b #xff :a #x20) + ) + (dotimes (s3-4 (-> obj num-spheres)) + (let ((v1-95 (-> obj sphere s3-4))) + (vector+! s4-0 (-> s5-0 origin) (the-as vector (&-> v1-95 x))) + (add-debug-sphere + #t + (bucket-id debug-draw1) + s4-0 + (- (-> v1-95 w) (-> obj shape nav-radius)) + (new 'static 'rgba :g #xff :b #xff :a #x20) + ) + ) + ) + ) + ) + 0 + ) + ) + (none) + ) + +(defmethod mem-usage nav-mesh ((obj nav-mesh) (arg0 memory-usage-block) (arg1 int)) + (set! (-> arg0 length) (max 46 (-> arg0 length))) + (set! (-> arg0 data 45 name) "nav-mesh") + (+! (-> arg0 data 45 count) 1) + (let ((v1-6 (asize-of obj))) + (+! (-> arg0 data 45 used) v1-6) + (+! (-> arg0 data 45 total) (logand -16 (+ v1-6 15))) + ) + (set! (-> arg0 length) (max 46 (-> arg0 length))) + (set! (-> arg0 data 45 name) "nav-mesh") + (+! (-> arg0 data 45 count) 1) + (let ((v1-16 (* (-> obj vertex-count) 16))) + (+! (-> arg0 data 45 used) v1-16) + (+! (-> arg0 data 45 total) (logand -16 (+ v1-16 15))) + ) + (set! (-> arg0 length) (max 46 (-> arg0 length))) + (set! (-> arg0 data 45 name) "nav-mesh") + (+! (-> arg0 data 45 count) 1) + (let ((v1-26 (* (-> obj poly-count) 8))) + (+! (-> arg0 data 45 used) v1-26) + (+! (-> arg0 data 45 total) (logand -16 (+ v1-26 15))) + ) + (set! (-> arg0 length) (max 46 (-> arg0 length))) + (set! (-> arg0 data 45 name) "nav-mesh") + (+! (-> arg0 data 45 count) 1) + (let ((v1-38 (/ (* (* (-> obj poly-count) (-> obj poly-count)) 2) 8))) + (+! (-> arg0 data 45 used) v1-38) + (+! (-> arg0 data 45 total) (logand -16 (+ v1-38 15))) + ) + (the-as nav-mesh 0) + ) + +(defmethod set-current-poly! nav-control ((obj nav-control) (arg0 nav-poly)) + (set! (-> obj current-poly) arg0) + (logior! (-> obj flags) (nav-control-flags bit9)) + 0 + (none) + ) + +(defmethod dummy-30 nav-control ((obj nav-control) (arg0 vector) (arg1 vector) (arg2 vector)) + (let ((s5-0 (the-as sphere #f))) + (let ((f30-0 -0.000001)) + (countdown (s1-0 (-> obj num-spheres)) + (let* ((s0-0 (-> obj sphere s1-0)) + (f0-1 (ray-circle-intersect arg0 arg1 (the-as vector (&-> s0-0 x)) (-> s0-0 w))) + ) + (when (< f30-0 f0-1) + (set! s5-0 s0-0) + (set! f30-0 f0-1) + ) + ) + ) + (set! (-> arg2 x) f30-0) + ) + s5-0 + ) + ) + +(defmethod intersect-ray-line-segment? nav-control ((obj nav-control) (arg0 vector) (arg1 vector) (arg2 vector) (arg3 vector)) + (ray-line-segment-intersection? arg0 arg1 arg2 arg3) + ) + +(defun add-nav-sphere ((arg0 nav-control) (arg1 vector)) + (when (< (-> arg0 num-spheres) (-> arg0 max-spheres)) + (let* ((s4-0 (-> arg0 sphere (-> arg0 num-spheres))) + (f1-0 (vector-vector-xz-distance-squared arg1 (-> arg0 shape trans))) + (f0-1 (+ (-> arg1 w) (-> arg0 shape nav-radius))) + (f2-2 (+ 40960.0 f0-1)) + ) + (when (< f1-0 (* f2-2 f2-2)) + (vector-! (the-as vector s4-0) arg1 (-> arg0 mesh origin)) + (set! (-> s4-0 w) f0-1) + (+! (-> arg0 num-spheres) 1) + ) + ) + ) + 0 + (none) + ) + +(defun add-collide-shape-spheres ((arg0 nav-control) (arg1 collide-shape) (arg2 vector)) + (when (logtest? (-> arg1 nav-flags) 1) + (set! (-> arg2 quad) (-> arg1 root-prim prim-core world-sphere quad)) + (set! (-> arg2 w) (-> arg1 nav-radius)) + (let ((s4-0 arg0) + (s3-0 arg2) + ) + (when (< (-> s4-0 num-spheres) (-> s4-0 max-spheres)) + (let* ((s2-0 (-> s4-0 sphere (-> s4-0 num-spheres))) + (f1-0 (vector-vector-xz-distance-squared s3-0 (-> s4-0 shape trans))) + (f0-2 (+ (-> s3-0 w) (-> s4-0 shape nav-radius))) + (f2-2 (+ 40960.0 f0-2)) + ) + (when (< f1-0 (* f2-2 f2-2)) + (vector-! (the-as vector s2-0) s3-0 (-> s4-0 mesh origin)) + (set! (-> s2-0 w) f0-2) + (+! (-> s4-0 num-spheres) 1) + ) + ) + ) + ) + 0 + ) + (when (logtest? (-> arg1 nav-flags) 2) + (let ((s5-1 (-> arg1 process nav extra-nav-sphere))) + (when (< (-> arg0 num-spheres) (-> arg0 max-spheres)) + (let* ((s4-1 (-> arg0 sphere (-> arg0 num-spheres))) + (f1-1 (vector-vector-xz-distance-squared s5-1 (-> arg0 shape trans))) + (f0-4 (+ (-> s5-1 w) (-> arg0 shape nav-radius))) + (f2-7 (+ 40960.0 f0-4)) + ) + (when (< f1-1 (* f2-7 f2-7)) + (vector-! (the-as vector s4-1) s5-1 (-> arg0 mesh origin)) + (set! (-> s4-1 w) f0-4) + (+! (-> arg0 num-spheres) 1) + ) + ) + ) + ) + 0 + ) + (none) + ) + +(defmethod TODO-RENAME-28 nav-control ((obj nav-control) (arg0 collide-kind)) + (local-vars + (sv-32 nav-control) + (sv-48 sphere) + (sv-64 sphere) + (sv-80 nav-control) + (sv-96 sphere) + (sv-112 vector) + (sv-128 sphere) + ) + (set! (-> obj num-spheres) 0) + (let ((s4-0 (-> obj mesh user-list)) + (s3-0 (new 'stack-no-clear 'vector)) + ) + (when (and *target* + (or (logtest? (-> obj flags) (nav-control-flags bit11)) (logtest? (-> *target* state-flags) #x80f8)) + ) + (let ((s2-0 obj) + (s1-0 (-> *target* control)) + ) + (let ((s0-0 s3-0)) + (when (logtest? (-> s1-0 nav-flags) 1) + (set! (-> s0-0 quad) (-> s1-0 root-prim prim-core world-sphere quad)) + (set! (-> s0-0 w) (-> s1-0 nav-radius)) + (set! sv-32 s2-0) + (when (< (-> sv-32 num-spheres) (-> sv-32 max-spheres)) + (set! sv-48 (-> sv-32 sphere (-> sv-32 num-spheres))) + (let* ((f1-0 (vector-vector-xz-distance-squared s0-0 (-> sv-32 shape trans))) + (f0-2 (+ (-> s0-0 w) (-> sv-32 shape nav-radius))) + (f2-2 (+ 40960.0 f0-2)) + ) + (when (< f1-0 (* f2-2 f2-2)) + (vector-! (the-as vector sv-48) s0-0 (-> sv-32 mesh origin)) + (set! (-> sv-48 w) f0-2) + (+! (-> sv-32 num-spheres) 1) + ) + ) + ) + 0 + ) + ) + (when (logtest? (-> s1-0 nav-flags) 2) + (let ((s1-1 (-> s1-0 process nav extra-nav-sphere))) + (when (< (-> s2-0 num-spheres) (-> s2-0 max-spheres)) + (let* ((s0-1 (-> s2-0 sphere (-> s2-0 num-spheres))) + (f1-1 (vector-vector-xz-distance-squared s1-1 (-> s2-0 shape trans))) + (f0-4 (+ (-> s1-1 w) (-> s2-0 shape nav-radius))) + (f2-7 (+ 40960.0 f0-4)) + ) + (when (< f1-1 (* f2-7 f2-7)) + (vector-! (the-as vector s0-1) s1-1 (-> s2-0 mesh origin)) + (set! (-> s0-1 w) f0-4) + (+! (-> s2-0 num-spheres) 1) + ) + ) + ) + ) + 0 + ) + ) + ) + (when (logtest? (-> obj flags) (nav-control-flags bit13)) + (countdown (s2-1 (-> obj mesh static-sphere-count)) + (let ((s1-2 obj) + (s0-2 (-> obj mesh static-sphere s2-1)) + ) + (when (< (-> s1-2 num-spheres) (-> s1-2 max-spheres)) + (set! sv-64 (-> s1-2 sphere (-> s1-2 num-spheres))) + (let* ((f1-2 (vector-vector-xz-distance-squared (the-as vector s0-2) (-> s1-2 shape trans))) + (f0-6 (+ (-> s0-2 trans w) (-> s1-2 shape nav-radius))) + (f2-12 (+ 40960.0 f0-6)) + ) + (when (< f1-2 (* f2-12 f2-12)) + (vector-! (the-as vector sv-64) (the-as vector s0-2) (-> s1-2 mesh origin)) + (set! (-> sv-64 w) f0-6) + (+! (-> s1-2 num-spheres) 1) + ) + ) + ) + ) + 0 + ) + ) + (let* ((v1-71 (-> s4-0 alive-list next0)) + (s2-2 (-> v1-71 next0)) + ) + (while (!= v1-71 (-> s4-0 alive-list-end)) + (let ((s0-3 (the-as collide-shape (-> (the-as connection v1-71) param3)))) + (when (not (or (= s0-3 (-> obj shape)) (zero? (logand arg0 (-> s0-3 root-prim prim-core collide-as))))) + (let ((s1-3 obj)) + (set! sv-112 s3-0) + (when (logtest? (-> s0-3 nav-flags) 1) + (set! (-> sv-112 quad) (-> s0-3 root-prim prim-core world-sphere quad)) + (set! (-> sv-112 w) (-> s0-3 nav-radius)) + (set! sv-80 s1-3) + (when (< (-> sv-80 num-spheres) (-> sv-80 max-spheres)) + (set! sv-96 (-> sv-80 sphere (-> sv-80 num-spheres))) + (let* ((f1-3 (vector-vector-xz-distance-squared sv-112 (-> sv-80 shape trans))) + (f0-9 (+ (-> sv-112 w) (-> sv-80 shape nav-radius))) + (f2-17 (+ 40960.0 f0-9)) + ) + (when (< f1-3 (* f2-17 f2-17)) + (let ((v1-94 sv-96) + (a0-47 (-> sv-80 mesh origin)) + ) + (vector-! (the-as vector v1-94) sv-112 a0-47) + ) + (set! (-> sv-96 w) f0-9) + (+! (-> sv-80 num-spheres) 1) + ) + ) + ) + 0 + ) + (when (logtest? (-> s0-3 nav-flags) 2) + (let ((s0-4 (-> s0-3 process nav extra-nav-sphere))) + (when (< (-> s1-3 num-spheres) (-> s1-3 max-spheres)) + (set! sv-128 (-> s1-3 sphere (-> s1-3 num-spheres))) + (let* ((f1-4 (vector-vector-xz-distance-squared s0-4 (-> s1-3 shape trans))) + (f0-11 (+ (-> s0-4 w) (-> s1-3 shape nav-radius))) + (f2-22 (+ 40960.0 f0-11)) + ) + (when (< f1-4 (* f2-22 f2-22)) + (vector-! (the-as vector sv-128) s0-4 (-> s1-3 mesh origin)) + (set! (-> sv-128 w) f0-11) + (+! (-> s1-3 num-spheres) 1) + ) + ) + ) + ) + 0 + ) + ) + ) + ) + (set! v1-71 s2-2) + (set! s2-2 (-> s2-2 next0)) + ) + ) + ) + 0 + (none) + ) + +(defmethod dummy-35 nav-control ((obj nav-control) (arg0 vector) (arg1 vector) (arg2 vector) (arg3 vector) (arg4 float)) + (let ((v1-0 (new 'stack-no-clear 'vector))) + (vector-! v1-0 arg1 (-> obj mesh origin)) + (TODO-ASM-32 obj arg0 v1-0 arg2 arg3 arg4) + ) + (none) + ) + +(deftype cfs-travel-vec (structure) + ((dir vector :inline :offset-assert 0) + (delta-angle float :offset-assert 16) + ) + :method-count-assert 9 + :size-assert #x14 + :flag-assert #x900000014 + ) + + +(deftype cfs-work (structure) + ((desired-travel-dist float :offset-assert 0) + (desired-angle float :offset-assert 4) + (max-dist float :offset-assert 8) + (old-angle float :offset-assert 12) + (modified int32 :offset-assert 16) + (blocked-mask uint64 :offset-assert 24) + (travel vector :inline :offset-assert 32) + (current vector :inline :offset-assert 48) + (new-travel cfs-travel-vec 2 :inline :offset-assert 64) + (temp-travel cfs-travel-vec 2 :inline :offset-assert 128) + (prev-dir vector :inline :offset-assert 192) + (attempt-dir vector :inline :offset-assert 208) + (tangent vector 2 :inline :offset-assert 224) + ) + :method-count-assert 9 + :size-assert #x100 + :flag-assert #x900000100 + ) + + +(deftype nav-control-cfs-work (structure) + ((in-dir vector :inline :offset-assert 0) + (right-dir vector :inline :offset-assert 16) + (best-dir vector 2 :inline :offset-assert 32) + (temp-dir vector 2 :inline :offset-assert 64) + (away-dir vector :inline :offset-assert 96) + (best-dir-angle degrees 2 :offset-assert 112) + (ignore-mask uint64 :offset-assert 120) + (initial-ignore-mask uint64 :offset-assert 128) + (i-sphere int32 :offset-assert 136) + (i-first-sphere int32 :offset-assert 140) + (i-inside-sphere int32 :offset-assert 144) + (inside-sphere-dist float :offset-assert 148) + (sign float :offset-assert 152) + (travel-len float :offset-assert 156) + (dist2 float :offset-assert 160) + (inside-dist float :offset-assert 164) + (rand-angle float :offset-assert 168) + (dir-update basic :offset-assert 172) + (debug-offset vector :inline :offset-assert 176) + ) + :method-count-assert 9 + :size-assert #xc0 + :flag-assert #x9000000c0 + ) + + +(defun circle-tangent-directions ((arg0 vector) (arg1 vector) (arg2 vector) (arg3 vector)) + (let ((s2-0 (new 'stack-no-clear 'vector)) + (s3-0 (new 'stack-no-clear 'vector)) + (s5-0 (new 'stack-no-clear 'vector)) + ) + (vector-! s2-0 arg1 arg0) + (set! (-> s2-0 y) 0.0) + (vector-normalize-copy! s3-0 s2-0 1.0) + (set! (-> s5-0 quad) (-> s3-0 quad)) + (set! (-> s5-0 x) (-> s3-0 z)) + (set! (-> s5-0 z) (- (-> s3-0 x))) + (let ((f0-4 (-> arg1 w)) + (f1-1 (vector-dot s3-0 s2-0)) + ) + (if (< f1-1 f0-4) + (set! f0-4 f1-1) + ) + (let* ((f2-0 f1-1) + (f2-2 (* f2-0 f2-0)) + (f3-0 f0-4) + (f2-4 (sqrtf (- f2-2 (* f3-0 f3-0)))) + (f3-4 (/ 1.0 f1-1)) + (f1-3 (* f2-4 f3-4)) + (f30-0 (* f0-4 f3-4)) + (s2-1 (new 'stack-no-clear 'vector)) + ) + (vector-float*! s2-1 s3-0 f1-3) + (vector+*! arg2 s2-1 s5-0 f30-0) + (vector+*! arg3 s2-1 s5-0 (- f30-0)) + ) + ) + ) + ) + +(defun find-closest-circle-ray-intersection ((arg0 vector) (arg1 vector) (arg2 float) (arg3 int) (arg4 (inline-array vector)) (arg5 int)) + (let ((f30-0 1.0) + (gp-0 -1) + ) + (let ((s1-0 (new 'stack-no-clear 'vector))) + (vector-float*! s1-0 arg1 arg2) + (dotimes (s0-0 arg3) + (when (zero? (logand arg5 (ash 1 s0-0))) + (let* ((v1-7 (-> arg4 s0-0)) + (f0-2 (ray-circle-intersect arg0 s1-0 v1-7 (-> v1-7 w))) + ) + (when (and (>= f0-2 0.0) (< f0-2 f30-0)) + (set! f30-0 f0-2) + (set! gp-0 s0-0) + ) + ) + ) + ) + ) + gp-0 + ) + ) + +(defun sign-bit ((arg0 int)) + (local-vars (v1-1 int)) + (let ((v1-0 arg0)) + (shift-arith-right-32 v1-1 v1-0 31) + ) + (logand v1-1 1) + ) + +(defun compute-dir-parm ((arg0 vector) (arg1 vector) (arg2 vector)) + (local-vars (a2-3 int)) + (let ((v1-0 (new 'static 'vector :x 1.0 :y -1.0))) + (let ((a2-2 (vector-dot arg0 arg2))) + (shift-arith-right-32 a2-3 a2-2 31) + ) + (* (-> v1-0 data (logand a2-3 1)) (- 1.0 (vector-dot arg0 arg1))) + ) + ) + +(defmethod TODO-ASM-32 nav-control ((obj nav-control) (arg0 vector) (arg1 vector) (arg2 vector) (arg3 vector) (arg4 float)) + (local-vars (v0-3 symbol) (v1-38 int) (a0-29 int) (a3-7 int) (sv-208 sphere)) + (let ((gp-0 (new 'stack-no-clear 'nav-control-cfs-work))) + (set! (-> gp-0 in-dir quad) (-> arg2 quad)) + (set! (-> gp-0 in-dir y) 0.0) + (vector-normalize! (-> gp-0 in-dir) 1.0) + (set! (-> gp-0 travel-len) (vector-dot (-> gp-0 in-dir) arg2)) + (set! (-> gp-0 right-dir quad) (-> gp-0 in-dir quad)) + (set! (-> gp-0 right-dir x) (- (-> gp-0 in-dir z))) + (set! (-> gp-0 right-dir z) (-> gp-0 in-dir x)) + (set! (-> gp-0 best-dir 0 quad) (-> gp-0 in-dir quad)) + (set! (-> gp-0 best-dir 1 quad) (-> gp-0 in-dir quad)) + (set! (-> gp-0 best-dir-angle 0) 0.0) + (set! (-> gp-0 best-dir-angle 1) 0.0) + (set! (-> gp-0 initial-ignore-mask) (the-as uint 0)) + (set! (-> gp-0 i-inside-sphere) -1) + (set! (-> gp-0 inside-sphere-dist) 0.0) + (dotimes (s0-0 (-> obj num-spheres)) + (set! sv-208 (-> obj sphere s0-0)) + (set! (-> gp-0 dist2) (vector-vector-xz-distance-squared arg1 sv-208)) + (let ((f0-10 (-> gp-0 dist2)) + (f1-0 (-> sv-208 w)) + ) + (when (< f0-10 (* f1-0 f1-0)) + (vector-! (the-as vector (-> gp-0 temp-dir)) arg1 (the-as vector sv-208)) + (set! (-> gp-0 temp-dir 0 y) 0.0) + (if (< 0.0 (vector-dot (the-as vector (-> gp-0 temp-dir)) (-> gp-0 in-dir))) + (+! (-> gp-0 initial-ignore-mask) (ash 1 s0-0)) + ) + (set! (-> gp-0 inside-dist) (- (-> sv-208 w) (sqrtf (-> gp-0 dist2)))) + (when (< (-> gp-0 inside-sphere-dist) (-> gp-0 inside-dist)) + (set! (-> gp-0 i-inside-sphere) s0-0) + (set! (-> gp-0 inside-sphere-dist) (-> gp-0 inside-dist)) + ) + ) + ) + ) + (set! (-> gp-0 i-first-sphere) (find-closest-circle-ray-intersection + arg1 + (-> gp-0 in-dir) + (-> gp-0 travel-len) + (-> obj num-spheres) + (-> obj sphere) + (the-as int (-> gp-0 initial-ignore-mask)) + ) + ) + (when (= (-> gp-0 i-first-sphere) -1) + (set! (-> arg0 quad) (-> arg2 quad)) + (set! v0-3 #f) + (b! #t cfg-46 :delay (nop!)) + (the-as none 0) + ) + (+! (-> gp-0 initial-ignore-mask) (ash 1 (-> gp-0 i-first-sphere))) + (let ((a1-9 (-> obj sphere (-> gp-0 i-first-sphere)))) + (circle-tangent-directions arg1 a1-9 (the-as vector (-> gp-0 temp-dir)) (-> gp-0 temp-dir 1)) + ) + (dotimes (v1-31 2) + (let ((a0-28 (vector-dot (-> gp-0 right-dir) (-> gp-0 temp-dir v1-31)))) + (shift-arith-right-32 a0-29 a0-28 31) + ) + (let ((a0-30 (logand a0-29 1)) + (f0-21 (- 1.0 (vector-dot (-> gp-0 in-dir) (-> gp-0 temp-dir v1-31)))) + ) + (set! (-> gp-0 best-dir a0-30 quad) (-> gp-0 temp-dir v1-31 quad)) + (set! (-> gp-0 best-dir-angle a0-30) f0-21) + ) + ) + 0 + (set! (-> gp-0 sign) 1.0) + (dotimes (s1-1 2) + (-> gp-0 i-first-sphere) + (set! (-> gp-0 dir-update) #t) + (set! (-> gp-0 ignore-mask) (-> gp-0 initial-ignore-mask)) + (b! #t cfg-31 :delay (nop!)) + (label cfg-22) + (+! (-> gp-0 ignore-mask) (ash 1 v1-38)) + (circle-tangent-directions arg1 (-> obj sphere v1-38) (the-as vector (-> gp-0 temp-dir)) (-> gp-0 temp-dir 1)) + (set! (-> gp-0 dir-update) #f) + (dotimes (v1-40 2) + (let ((f0-23 (-> gp-0 sign)) + (a1-22 (-> gp-0 temp-dir v1-40)) + (a0-39 (-> gp-0 in-dir)) + (a3-4 (-> gp-0 right-dir)) + (a2-10 (new 'static 'vector :x 1.0 :y -1.0)) + ) + (let ((a3-6 (vector-dot a1-22 a3-4))) + (shift-arith-right-32 a3-7 a3-6 31) + ) + (let ((f0-24 (* f0-23 (* (-> a2-10 data (logand a3-7 1)) (- 1.0 (vector-dot a1-22 a0-39)))))) + (when (< (-> gp-0 best-dir-angle s1-1) f0-24) + (set! (-> gp-0 best-dir s1-1 quad) (-> gp-0 temp-dir v1-40 quad)) + (set! (-> gp-0 best-dir-angle s1-1) f0-24) + (set! (-> gp-0 dir-update) #t) + ) + ) + ) + ) + (label cfg-31) + (when (-> gp-0 dir-update) + (set! v1-38 (find-closest-circle-ray-intersection + arg1 + (-> gp-0 best-dir s1-1) + (-> gp-0 travel-len) + (-> obj num-spheres) + (-> obj sphere) + (the-as int (-> gp-0 ignore-mask)) + ) + ) + (b! (!= v1-38 -1) cfg-22 :delay (nop!)) + ) + (set! (-> gp-0 sign) (* -1.0 (-> gp-0 sign))) + ) + (when (!= (-> gp-0 i-inside-sphere) -1) + (let ((s2-1 (-> obj sphere (-> gp-0 i-inside-sphere)))) + (vector-! (-> gp-0 away-dir) arg1 (the-as vector s2-1)) + (set! (-> gp-0 away-dir y) 0.0) + (when (>= 40.96 (vector-length (-> gp-0 away-dir))) + (set! (-> gp-0 rand-angle) (* 65536.0 (rand-vu))) + (set! (-> gp-0 away-dir x) (cos (-> gp-0 rand-angle))) + (set! (-> gp-0 away-dir z) (sin (-> gp-0 rand-angle))) + ) + (vector-normalize! (-> gp-0 away-dir) 1.0) + (let ((f30-2 (/ (-> gp-0 inside-sphere-dist) (-> s2-1 w)))) + (vector-lerp! (the-as vector (-> gp-0 best-dir)) (the-as vector (-> gp-0 best-dir)) (-> gp-0 away-dir) f30-2) + (vector-lerp! (-> gp-0 best-dir 1) (-> gp-0 best-dir 1) (-> gp-0 away-dir) f30-2) + ) + ) + (vector-normalize! (the-as vector (-> gp-0 best-dir)) 1.0) + (vector-normalize! (-> gp-0 best-dir 1) 1.0) + ) + (let ((f30-3 (vector-dot (-> gp-0 in-dir) (the-as vector (-> gp-0 best-dir)))) + (f28-0 (vector-dot (-> gp-0 in-dir) (-> gp-0 best-dir 1))) + ) + (when (< (fmax f30-3 f28-0) (cos 1820.4445)) + (set! f30-3 (vector-dot arg3 (the-as vector (-> gp-0 best-dir)))) + (set! f28-0 (vector-dot arg3 (-> gp-0 best-dir 1))) + ) + (vector-float*! + arg0 + (-> gp-0 best-dir (if (< f28-0 f30-3) + 0 + 1 + ) + ) + (-> gp-0 travel-len) + ) + ) + ) + 0 + (set! v0-3 #t) + (label cfg-46) + v0-3 + ) + +(defmethod dummy-23 nav-control ((obj nav-control) (arg0 vector) (arg1 check-vector-collision-with-nav-spheres-info)) + (let ((s2-1 (vector-! (new 'stack-no-clear 'vector) (-> obj shape trans) (-> obj mesh origin))) + (f30-0 -1.0) + ) + (let ((s3-0 -1)) + (countdown (s1-0 (-> obj num-spheres)) + (let* ((s0-0 (-> obj sphere s1-0)) + (f0-1 (ray-circle-intersect s2-1 arg0 (the-as vector (&-> s0-0 x)) (-> s0-0 w))) + ) + (when (>= f0-1 0.0) + (let ((v1-5 (new 'stack-no-clear 'vector))) + (vector-! v1-5 (the-as vector (&-> s0-0 x)) s2-1) + (when (>= (vector-dot v1-5 arg0) 0.0) + (when (or (< f30-0 0.0) (< f0-1 f30-0)) + (set! f30-0 f0-1) + (set! s3-0 s1-0) + ) + ) + ) + ) + ) + ) + (when arg1 + (set! (-> arg1 u) f30-0) + (when (>= f30-0 0.0) + (vector+float*! (-> arg1 intersect) (-> obj shape trans) arg0 f30-0) + (let ((a1-4 (-> obj sphere s3-0)) + (v1-19 (new 'stack-no-clear 'vector)) + ) + (vector+! v1-19 (the-as vector (&-> a1-4 x)) (-> obj mesh origin)) + (vector-! (-> arg1 normal) (-> arg1 intersect) v1-19) + ) + (set! (-> arg1 normal w) 1.0) + (vector-normalize! (-> arg1 normal) 1.0) + ) + ) + ) + f30-0 + ) + ) + +(defmethod TODO-RENAME-33 nav-control ((obj nav-control) (arg0 vector) (arg1 vector) (arg2 vector) (arg3 vector) (arg4 float)) + (let ((f30-0 (vector-xz-length (-> obj travel)))) + (when (TODO-ASM-32 obj arg0 arg1 arg2 arg3 f30-0) + (set! (-> obj blocked-travel quad) (-> obj travel quad)) + (let ((f0-0 (vector-xz-length (-> obj travel)))) + (when (and (>= f30-0 f0-0) (< f0-0 204.8)) + (set! (-> obj flags) (logior (nav-control-flags bit17) (-> obj flags))) + (set! (-> obj block-time) (the-as uint (-> *display* base-frame-counter))) + (set! (-> obj block-count) (+ 1.0 (-> obj block-count))) + (if (-> obj block-event) + (send-event (the-as process-tree (-> obj process)) (the-as symbol (-> obj block-event)) obj) + ) + ) + ) + #t + ) + ) + ) + +(define *debug-ray-test* (the-as nav-ray #f)) + +(define *debug-ray-test-capture-mode* #f) + +(define *debug-ray-test-capture-output* #f) + +(define *test-ray-start-poly-id* 62) + +(define *test-ray-src-pos* (new 'static 'vector :x -705089.6 :y 9769.325 :z -963339.0 :w 1.0)) + +(define *test-ray-dest-pos* (new 'static 'vector :x -722887.7 :y 9532.475 :z -958862.25 :w 1.0)) + +(defmethod dummy-19 nav-control ((obj nav-control) (arg0 vector) (arg1 collide-shape-moving) (arg2 vector) (arg3 float)) + (local-vars (sv-48 float)) + (let ((f30-0 (* arg3 (-> *display* seconds-per-frame))) + (s0-0 arg1) + (s1-0 arg2) + (s2-0 deg-diff) + ) + (set! sv-48 (y-angle s0-0)) + (let* ((a1-1 (vector-y-angle (vector-! (new 'stack-no-clear 'vector) s1-0 (-> s0-0 trans)))) + (f28-0 (s2-0 sv-48 a1-1)) + ) + (cond + ((or (vector= arg2 (-> obj target-pos)) (< (fabs f28-0) 364.0889)) + (set! (-> obj flags) (logior (nav-control-flags bit21) (-> obj flags))) + (set! (-> arg0 quad) (-> arg2 quad)) + ) + (else + (let ((s2-1 (vector-z-quaternion! (new 'stack-no-clear 'vector) (-> arg1 quat)))) + (vector-rotate-y! s2-1 s2-1 (fmax (fmin f28-0 f30-0) (- f30-0))) + (vector-normalize! s2-1 819.2) + (logclear! (-> obj flags) (nav-control-flags bit21)) + (vector+! arg0 (-> arg1 trans) s2-1) + ) + (when (or (not (dummy-16 obj arg0)) + (logtest? (nav-control-flags bit17) (-> obj flags)) + (zero? (logand (-> obj flags) (nav-control-flags bit10))) + ) + (set! (-> obj flags) (logior (nav-control-flags bit21) (-> obj flags))) + (vector-! (-> obj travel) arg2 (-> arg1 trans)) + (set! (-> arg0 quad) (-> arg2 quad)) + ) + ) + ) + ) + ) + (none) + ) + +(defmethod dummy-16 nav-control ((obj nav-control) (arg0 vector)) + (find-poly-fast + (-> obj mesh) + (vector-! (new 'stack-no-clear 'vector) arg0 (-> obj mesh origin)) + (-> obj nearest-y-threshold) + ) + ) + +(defmethod TODO-RENAME-21 nav-control ((obj nav-control) (arg0 vector)) + (find-poly-fast + (-> obj mesh) + (vector-! (new 'stack-no-clear 'vector) arg0 (-> obj mesh origin)) + (-> obj nearest-y-threshold) + ) + ) + +(defmethod TODO-RENAME-22 nav-control ((obj nav-control) (arg0 vector) (arg1 float)) + (the-as symbol (and (find-poly-fast + (-> obj mesh) + (vector-! (new 'stack-no-clear 'vector) arg0 (-> obj mesh origin)) + (-> obj nearest-y-threshold) + ) + (< (-> arg0 y) (+ (-> obj mesh origin y) arg1)) + ) + ) + ) + +(defun debug-nav-validate-current-poly ((arg0 nav-mesh) (arg1 nav-poly) (arg2 vector)) + (when (not (point-in-poly? arg0 arg1 arg2)) + (let ((s3-0 (new 'stack-no-clear 'vector))) + (project-point-into-tri-2d arg0 arg1 s3-0 arg2) + (vector-vector-xz-distance arg2 s3-0) + ) + #f + ) + ) + +(defmethod TODO-RENAME-26 nav-control ((obj nav-control)) + 0 + (none) + ) + +(defmethod TODO-RENAME-27 nav-control ((obj nav-control)) + (local-vars (v1-7 symbol)) + (cond + ((-> obj current-poly) + (let ((s4-0 (-> obj mesh)) + (s5-0 (new 'stack-no-clear 'nav-ray)) + ) + (let ((s3-0 0)) + (set! (-> s5-0 current-poly) (-> obj current-poly)) + (vector-! (-> s5-0 current-pos) (-> obj prev-pos) (-> s4-0 origin)) + (vector-! (-> s5-0 dest-pos) (-> obj shape trans) (-> s4-0 origin)) + (init-ray s5-0) + (until v1-7 + (+! s3-0 1) + (move-along-nav-ray! s4-0 s5-0) + (set! v1-7 (or (>= s3-0 15) (-> s5-0 terminated))) + ) + ) + (set! (-> obj current-poly) (-> s5-0 current-poly)) + (when (-> s5-0 reached-dest) + (if (not (point-in-poly? s4-0 (-> s5-0 current-poly) (-> s5-0 dest-pos))) + (set! (-> s5-0 reached-dest) #f) + ) + ) + (cond + ((-> s5-0 reached-dest) + (set! (-> obj prev-pos quad) (-> obj shape trans quad)) + ) + (else + (set! (-> obj prev-pos quad) (-> obj shape trans quad)) + (set! (-> obj current-poly) (find-poly obj (-> obj shape trans))) + ) + ) + ) + 0 + ) + (else + (set! (-> obj prev-pos quad) (-> obj shape trans quad)) + (set! (-> obj current-poly) (find-poly obj (-> obj shape trans))) + ) + ) + (TODO-RENAME-26 obj) + 0 + (none) + ) + +(defmethod TODO-RENAME-16 nav-mesh ((obj nav-mesh) + (arg0 vector) + (arg1 nav-poly) + (arg2 vector) + (arg3 symbol) + (arg4 float) + (arg5 clip-travel-vector-to-mesh-return-info) + ) + (local-vars (v1-10 symbol) (sv-96 symbol) (sv-112 int) (sv-128 int)) + (when arg5 + (set! (-> arg5 found-boundary) #f) + (set! (-> arg5 gap-poly) #f) + ) + (let ((s0-0 (new 'stack-no-clear 'nav-ray))) + (set! sv-96 (the-as symbol #f)) + (set! sv-112 0) + (set! (-> s0-0 current-poly) arg1) + (set! (-> s0-0 current-pos quad) (-> arg0 quad)) + (vector+! (-> s0-0 dest-pos) arg0 arg2) + (until sv-96 + (set! sv-128 0) + (init-ray s0-0) + (until v1-10 + (set! sv-128 (+ sv-128 1)) + (move-along-nav-ray! obj s0-0) + (set! v1-10 (or (>= sv-128 15) (or (>= (-> s0-0 len) (fmax 20480.0 arg4)) (-> s0-0 terminated)))) + ) + (cond + ((and (-> s0-0 hit-boundary) (and (< (-> s0-0 len) arg4) (!= (-> s0-0 last-edge) -1) (< sv-112 1))) + (set! sv-112 (+ sv-112 1)) + (let* ((v1-22 (-> obj vertex (-> s0-0 current-poly vertex (-> *edge-vert0-table* (-> s0-0 last-edge))))) + (a0-15 (-> obj vertex (-> s0-0 current-poly vertex (-> *edge-vert1-table* (-> s0-0 last-edge))))) + (f2-1 (- (-> v1-22 z) (-> a0-15 z))) + (f3-0 (- (-> a0-15 x) (-> v1-22 x))) + (f1-5 (-> arg2 x)) + (f0-4 (-> arg2 z)) + (f4-0 f2-1) + (f4-2 (* f4-0 f4-0)) + (f5-0 f3-0) + (f4-4 (sqrtf (+ f4-2 (* f5-0 f5-0)))) + (f4-6 (/ 1.0 f4-4)) + (f2-2 (* f2-1 f4-6)) + (f3-1 (* f3-0 f4-6)) + ) + (when arg5 + (set! (-> arg5 found-boundary) #t) + (vector+! (-> arg5 intersection) (-> s0-0 current-pos) (-> obj origin)) + (set! (-> arg5 boundary-normal x) f2-2) + (set! (-> arg5 boundary-normal y) 0.0) + (set! (-> arg5 boundary-normal z) f3-1) + (set! (-> arg5 poly) (-> s0-0 current-poly)) + (set! (-> arg5 edge) (-> s0-0 last-edge)) + (vector+! (-> arg5 vert-0) (the-as vector v1-22) (-> obj origin)) + (vector+! (-> arg5 vert-1) (the-as vector a0-15) (-> obj origin)) + ) + (set! (-> s0-0 dest-pos quad) (-> s0-0 current-pos quad)) + (cond + (arg3 + (let* ((f4-9 (* 1.01 (+ (* f2-2 f1-5) (* f3-1 f0-4)))) + (f1-6 (- f1-5 (* f2-2 f4-9))) + (f0-5 (- f0-4 (* f3-1 f4-9))) + ) + (+! (-> s0-0 dest-pos x) f1-6) + (+! (-> s0-0 dest-pos z) f0-5) + ) + ) + (else + (set! sv-96 #t) + sv-96 + ) + ) + ) + ) + ((-> s0-0 hit-gap) + (if arg5 + (set! (-> arg5 gap-poly) (-> s0-0 next-poly)) + ) + (set! sv-96 #t) + sv-96 + ) + (else + (set! sv-96 #t) + sv-96 + ) + ) + ) + (vector-! arg2 (-> s0-0 current-pos) arg0) + ) + 0 + 0 + (none) + ) + +(defmethod dummy-24 nav-control ((obj nav-control) (arg0 float) (arg1 clip-travel-vector-to-mesh-return-info)) + (let ((v1-0 (new 'stack-no-clear 'vector))) + (vector-! v1-0 (-> obj shape trans) (-> obj mesh origin)) + (TODO-RENAME-16 + (-> obj mesh) + v1-0 + (-> obj current-poly) + (-> obj travel) + (zero? (logand (-> obj flags) (nav-control-flags bit12))) + arg0 + arg1 + ) + ) + (when arg1 + (if (-> arg1 gap-poly) + (set! (-> obj next-poly) (-> arg1 gap-poly)) + ) + ) + 0 + (none) + ) + +(defun test-xz-point-on-line-segment? ((arg0 vector) (arg1 vector) (arg2 vector) (arg3 float)) + (let ((v0-2 (>= arg3 (fmin (vector-vector-xz-distance arg0 arg1) (vector-vector-xz-distance arg0 arg2))))) + (when (not v0-2) + (let* ((f0-3 (- (-> arg2 x) (-> arg1 x))) + (f1-2 (- (-> arg2 z) (-> arg1 z))) + (f2-1 f0-3) + (f2-3 (* f2-1 f2-1)) + (f3-0 f1-2) + (f2-5 (sqrtf (+ f2-3 (* f3-0 f3-0)))) + (f3-3 f2-5) + (f3-5 (/ 1.0 f3-3)) + (f4-2 (* f3-5 (- f1-2))) + (f5-0 (* f3-5 f0-3)) + (f3-7 (- (-> arg0 x) (-> arg1 x))) + (f6-2 (- (-> arg0 z) (-> arg1 z))) + ) + (when (>= arg3 (fabs (+ (* f3-7 f4-2) (* f6-2 f5-0)))) + (let ((f0-5 (+ (* f3-7 f0-3) (* f6-2 f1-2)))) + (set! v0-2 (and (>= f0-5 0.0) (>= (* f2-5 f2-5) f0-5))) + ) + ) + ) + ) + v0-2 + ) + ) + +(defun choose-travel-portal-vertex ((arg0 nav-mesh) (arg1 nav-route-portal) (arg2 nav-poly) (arg3 vector)) + (let ((f0-1 (- (-> arg1 vertex 1 x) (-> arg1 vertex 0 x))) + (f1-2 (- (-> arg1 vertex 1 z) (-> arg1 vertex 0 z))) + ) + 0.0 + (let ((s2-0 (new 'stack-no-clear 'nav-route-portal)) + (s1-0 0) + ) + (let* ((s0-0 #f) + (f2-2 f0-1) + (f2-4 (* f2-2 f2-2)) + (f3-0 f1-2) + (f2-6 (sqrtf (+ f2-4 (* f3-0 f3-0)))) + (f2-8 (/ 1.0 f2-6)) + (f30-0 (* f0-1 f2-8)) + (f28-0 (* f1-2 f2-8)) + (f26-0 (* -0.5 (+ (* f30-0 (-> arg1 vertex 0 x)) + (* f28-0 (-> arg1 vertex 0 z)) + (+ (* f30-0 (-> arg1 vertex 1 x)) (* f28-0 (-> arg1 vertex 1 z))) + ) + ) + ) + ) + (set! (-> s2-0 vertex 0) (-> arg1 vertex 0)) + (set! (-> s2-0 vertex 1) (-> arg1 vertex 1)) + (set! (-> s2-0 next-poly) (-> arg1 next-poly)) + (until s0-0 + (setup-portal arg0 (-> s2-0 next-poly) arg2 s2-0) + (cond + ((-> s2-0 next-poly) + (let ((v1-18 0)) + (dotimes (a0-2 2) + (if (< 0.0 (+ (* f30-0 (-> s2-0 vertex a0-2 x)) (* f28-0 (-> s2-0 vertex a0-2 z)) f26-0)) + (+! v1-18 1) + ) + ) + (when (= v1-18 2) + (set! s1-0 1) + (set! s0-0 #t) + ) + (when (zero? v1-18) + (set! s1-0 0) + (set! s0-0 #t) + ) + ) + 0 + ) + (else + (let ((v1-22 + (if (< (vector-vector-xz-distance (-> s2-0 vertex 0) arg3) (vector-vector-xz-distance (-> s2-0 vertex 1) arg3)) + 0 + 1 + ) + ) + ) + (set! s1-0 (if (< 0.0 (+ (* f30-0 (-> arg1 vertex v1-22 x)) (* f28-0 (-> arg1 vertex v1-22 z)) f26-0)) + 1 + 0 + ) + ) + ) + (set! s0-0 #t) + 0 + ) + ) + ) + ) + s1-0 + ) + ) + ) + +(defmethod dummy-13 nav-control ((obj nav-control) (arg0 vector) (arg1 vector)) + (local-vars + (sv-80 vector) + (sv-84 vector) + (sv-88 nav-poly) + (sv-92 vector) + (sv-96 nav-route-portal) + (sv-100 symbol) + ) + (set! sv-80 (new 'stack-no-clear 'vector)) + (set! sv-84 (new 'stack-no-clear 'vector)) + (set! sv-88 (-> obj current-poly)) + (set! sv-92 (new 'stack-no-clear 'vector)) + (set! sv-96 (new 'stack-no-clear 'nav-route-portal)) + (set! sv-100 (the-as symbol #f)) + (vector-! sv-80 (-> obj shape trans) (-> obj mesh origin)) + (set! (-> sv-84 quad) (-> sv-80 quad)) + (let ((s4-0 (new 'stack-no-clear 'vector))) + (vector-! s4-0 arg0 (-> obj mesh origin)) + (set! (-> obj target-poly) (find-poly (-> obj mesh) s4-0 (-> obj nearest-y-threshold) (&-> obj flags))) + (if (not (-> obj target-poly)) + (set! (-> obj target-poly) (-> obj current-poly)) + ) + (project-point-into-tri-2d (-> obj mesh) (-> obj target-poly) sv-92 s4-0) + ) + (vector-! (-> obj travel) sv-92 sv-80) + (setup-portal (-> obj mesh) (-> obj current-poly) (-> obj target-poly) sv-96) + (cond + ((not (-> sv-96 next-poly)) + (set! (-> obj next-poly) #f) + (set! (-> obj portal 0) #f) + (set! (-> obj portal 1) #f) + ) + (else + (set! (-> obj next-poly) (-> sv-96 next-poly)) + (set! (-> obj portal 0) (the-as nav-route-portal (-> sv-96 vertex 0))) + (set! (-> obj portal 1) (the-as nav-route-portal (-> sv-96 vertex 1))) + (set! sv-100 #t) + (while (and sv-100 + (-> sv-96 next-poly) + (test-xz-point-on-line-segment? sv-80 (-> sv-96 vertex 0) (-> sv-96 vertex 1) 409.59998) + ) + (when #t + #t + (vector-segment-distance-point! sv-80 (-> sv-96 vertex 0) (-> sv-96 vertex 1) sv-84) + (vector-! (-> obj travel) sv-92 sv-84) + 0 + ) + (cond + ((logtest? (-> sv-96 next-poly pat) 1) + (vector-segment-distance-point! sv-80 (-> sv-96 vertex 0) (-> sv-96 vertex 1) sv-92) + (vector-! (-> obj travel) sv-92 sv-84) + (set! (-> obj next-poly) (-> sv-96 next-poly)) + (set! sv-100 (the-as symbol #f)) + ) + ((begin + (set! sv-88 (-> sv-96 next-poly)) + (setup-portal (-> obj mesh) (-> sv-96 next-poly) (-> obj target-poly) sv-96) + ) + (set! (-> obj next-poly) (-> sv-96 next-poly)) + (set! (-> obj portal 0) (the-as nav-route-portal (-> sv-96 vertex 0))) + (set! (-> obj portal 1) (the-as nav-route-portal (-> sv-96 vertex 1))) + 0 + ) + (else + (set! (-> obj next-poly) #f) + (set! (-> obj portal 0) #f) + (set! (-> obj portal 1) #f) + (set! sv-100 (the-as symbol #f)) + ) + ) + ) + ) + ) + (when sv-100 + (when (not + (ray-ccw-line-segment-intersection? + sv-84 + (-> obj travel) + (the-as vector (-> obj portal 0)) + (the-as vector (-> obj portal 1)) + ) + ) + (let ((a0-18 (choose-travel-portal-vertex (-> obj mesh) sv-96 (-> obj target-poly) sv-92))) + (vector-! (-> obj travel) (the-as vector (-> sv-96 vertex a0-18)) sv-84) + ) + ) + ) + (TODO-RENAME-33 + obj + (-> obj travel) + sv-84 + (-> obj travel) + arg1 + 40960.0 + ) + (let ((s5-1 (new 'stack-no-clear 'clip-travel-vector-to-mesh-return-info))) + (TODO-RENAME-16 + (-> obj mesh) + sv-84 + sv-88 + (-> obj travel) + (zero? (logand (-> obj flags) (nav-control-flags bit12))) + 204.8 + s5-1 + ) + (if (-> s5-1 gap-poly) + (set! (-> obj next-poly) (-> s5-1 gap-poly)) + ) + ) + (let ((v1-82 (new 'stack-no-clear 'vector))) + (vector-! v1-82 sv-84 sv-80) + (vector+! (-> obj travel) (-> obj travel) v1-82) + ) + (set! (-> obj travel y) 0.0) + (-> obj travel) + ) + +(defmethod TODO-RENAME-12 nav-control ((obj nav-control) (arg0 nav-gap-info)) + (when (and (-> obj next-poly) (logtest? (-> obj next-poly pat) 1)) + (let ((s4-0 (-> obj next-poly)) + (s3-1 (vector-! (new 'stack-no-clear 'vector) (-> obj shape trans) (-> obj mesh origin))) + ) + (while (and s4-0 (logtest? (-> s4-0 pat) 1)) + (set! s4-0 (get-adj-poly (-> obj mesh) s4-0 (-> obj target-poly) #f)) + ) + (when (and s4-0 (-> obj gap-event)) + (let ((s2-0 (-> obj event-temp))) + (closest-point-on-boundary (-> obj mesh) s4-0 s2-0 s3-1) + (vector+! s2-0 s2-0 (-> obj mesh origin)) + (set! (-> arg0 dest quad) (-> s2-0 quad)) + ) + (set! (-> arg0 poly) s4-0) + #t + ) + ) + ) + ) + +(defmethod dummy-11 nav-control ((obj nav-control) (arg0 vector)) + (set! (-> obj old-travel quad) (-> obj travel quad)) + (-> obj block-count) + (set! (-> obj block-count) (seek (-> obj block-count) 0.0 0.016666668)) + (logclear! (-> obj flags) (nav-control-flags bit9 bit17 bit18 bit19)) + (TODO-RENAME-27 obj) + (if (logtest? (-> obj flags) (nav-control-flags bit8)) + (TODO-RENAME-28 obj (collide-kind + background + cak-1 + cak-2 + cak-3 + target + water + powerup + crate + enemy + wall-object + projectile + ground-object + target-attack + mother-spider + cak-14 + blue-eco-suck + unknown-16 + unknown-17 + unknown-18 + unknown-19 + unknown-20 + unknown-21 + unknown-22 + unknown-23 + unknown-24 + unknown-25 + unknown-26 + unknown-27 + unknown-28 + unknown-29 + unknown-30 + unknown-31 + unknown-32 + unknown-33 + unknown-34 + unknown-35 + unknown-36 + unknown-37 + unknown-38 + unknown-39 + unknown-40 + unknown-41 + unknown-42 + unknown-43 + unknown-44 + unknown-45 + unknown-46 + unknown-47 + unknown-48 + unknown-49 + unknown-50 + unknown-51 + unknown-52 + unknown-53 + unknown-54 + unknown-55 + unknown-56 + unknown-57 + unknown-58 + unknown-59 + unknown-60 + unknown-61 + unknown-62 + unknown-63 + ) + ) + ) + (dummy-13 obj arg0 (-> obj old-travel)) + (-> obj mesh) + (vector-! (new 'stack-no-clear 'vector) (-> obj shape trans) (-> obj mesh origin)) + (let ((s5-1 (new 'stack-no-clear 'nav-gap-info))) + (when (< (vector-xz-length (-> obj travel)) 204.8) + (cond + ((logtest? (nav-control-flags bit17) (-> obj flags)) + ) + ((-> obj next-poly) + (cond + ((TODO-RENAME-12 obj s5-1) + (set! (-> obj next-poly) #f) + (send-event + (the-as process-tree (-> obj process)) + (the-as symbol (-> obj gap-event)) + (-> s5-1 dest) + (-> s5-1 poly) + ) + ) + (else + ) + ) + ) + (else + (set! (-> obj flags) (logior (nav-control-flags bit19) (-> obj flags))) + ) + ) + ) + ) + (-> obj travel) + ) + +(defun-debug nav-sphere-from-cam () + (let ((v1-0 (camera-pos))) + (format #t "SPHEREM(~4,,1M, ~4,,1M, ~4,,1M, 1.0)~%" (-> v1-0 x) (-> v1-0 y) (-> v1-0 z)) + ) + 0 + (none) + ) + + + + diff --git a/goal_src/engine/target/sidekick.gc b/goal_src/engine/target/sidekick.gc index 47b4e08973..385aeed893 100644 --- a/goal_src/engine/target/sidekick.gc +++ b/goal_src/engine/target/sidekick.gc @@ -9,64 +9,26 @@ ;; DECOMP BEGINS -(define - *sidekick-remap* - '( - ("run-to-stance-left" - "run-to-stance" - ) - ("run-to-stance-loop-left" - "run-to-stance-loop" - ) - ("stance-loop-left" - "stance-loop" - ) - ("run-to-stance-right" - "run-to-stance" - ) - ("run-to-stance-loop-right" - "run-to-stance-loop" - ) - ("stance-loop-right" - "stance-loop" - ) - ("run-to-stance-up" - "run-to-stance" - ) - ("run-to-stance-loop-up" - "run-to-stance-loop" - ) - ("stance-loop-up" - "stance-loop" - ) - ("run-to-stance-down" - "run-to-stance" - ) - ("run-to-stance-loop-down" - "run-to-stance-loop" - ) - ("stance-loop-down" - "stance-loop" - ) - ("run-right" - "run" - ) - ("run-left" - "run" - ) - ("walk-right" - "walk" - ) - ("walk-left" - "walk" - ) - ("edge-grab-stance1" - "edge-grab-stance1" - "edge-grab-stance1-alt" - ) - ("pole-cycle" "pole-cycle" "pole-cycle2") - ) - ) +(define *sidekick-remap* '(("run-to-stance-left" "run-to-stance") + ("run-to-stance-loop-left" "run-to-stance-loop") + ("stance-loop-left" "stance-loop") + ("run-to-stance-right" "run-to-stance") + ("run-to-stance-loop-right" "run-to-stance-loop") + ("stance-loop-right" "stance-loop") + ("run-to-stance-up" "run-to-stance") + ("run-to-stance-loop-up" "run-to-stance-loop") + ("stance-loop-up" "stance-loop") + ("run-to-stance-down" "run-to-stance") + ("run-to-stance-loop-down" "run-to-stance-loop") + ("stance-loop-down" "stance-loop") + ("run-right" "run") + ("run-left" "run") + ("walk-right" "walk") + ("walk-left" "walk") + ("edge-grab-stance1" "edge-grab-stance1" "edge-grab-stance1-alt") + ("pole-cycle" "pole-cycle" "pole-cycle2") + ) + ) (defun cspace<-cspace+quaternion! ((arg0 cspace) (arg1 cspace) (arg2 quaternion)) (rlet ((Q :class vf) @@ -77,223 +39,184 @@ (vf4 :class vf) (vf5 :class vf) ) - (init-vf0-vector) - (let ((s5-0 (-> arg0 bone transform))) - (quaternion->matrix s5-0 arg2) - (.lvf vf1 (&-> (new 'static 'vector :x 1.0 :y 1.0 :z 1.0 :w 1.0) quad)) - (.lvf vf2 (&-> (-> arg1 bone) transform vector 3 quad)) - (.lvf vf3 (&-> s5-0 vector 0 quad)) - (.lvf vf4 (&-> s5-0 vector 1 quad)) - (.lvf vf5 (&-> s5-0 vector 2 quad)) - (.div.vf Q vf0 vf2 :fsf #b11 :ftf #b11) - (.wait.vf) - (.mul.vf vf2 vf2 Q :mask #b111) - (.mov.vf vf2 vf0 :mask #b1000) - (.mul.x.vf vf3 vf3 vf1) - (.mul.y.vf vf4 vf4 vf1) - (.mul.z.vf vf5 vf5 vf1) - (.svf (&-> s5-0 vector 3 quad) vf2) - (.svf (&-> s5-0 vector 0 quad) vf3) - (.svf (&-> s5-0 vector 1 quad) vf4) - (.svf (&-> s5-0 vector 2 quad) vf5) - s5-0 + (init-vf0-vector) + (let ((s5-0 (-> arg0 bone transform))) + (quaternion->matrix s5-0 arg2) + (.lvf vf1 (&-> (new 'static 'vector :x 1.0 :y 1.0 :z 1.0 :w 1.0) quad)) + (.lvf vf2 (&-> (-> arg1 bone) transform vector 3 quad)) + (.lvf vf3 (&-> s5-0 vector 0 quad)) + (.lvf vf4 (&-> s5-0 vector 1 quad)) + (.lvf vf5 (&-> s5-0 vector 2 quad)) + (.div.vf Q vf0 vf2 :fsf #b11 :ftf #b11) + (.wait.vf) + (.mul.vf vf2 vf2 Q :mask #b111) + (.mov.vf vf2 vf0 :mask #b1000) + (.mul.x.vf vf3 vf3 vf1) + (.mul.y.vf vf4 vf4 vf1) + (.mul.z.vf vf5 vf5 vf1) + (.svf (&-> s5-0 vector 3 quad) vf2) + (.svf (&-> s5-0 vector 0 quad) vf3) + (.svf (&-> s5-0 vector 1 quad) vf4) + (.svf (&-> s5-0 vector 2 quad) vf5) + s5-0 + ) ) - ) ) (defstate sidekick-clone (sidekick) :event (behavior ((arg0 process) (arg1 int) (arg2 symbol) (arg3 event-message-block)) - (local-vars (v0-0 object)) - (case arg2 - (('matrix) - (case (-> arg3 param 0) - (('play-anim) - (set! v0-0 (-> self node-list data)) - (set! - (-> (the-as (inline-array cspace) v0-0) 0 param0) - cspace<-cspace+quaternion! + (local-vars (v0-0 object)) + (case arg2 + (('matrix) + (case (-> arg3 param 0) + (('play-anim) + (set! v0-0 (-> self node-list data)) + (set! (-> (the-as (inline-array cspace) v0-0) 0 param0) cspace<-cspace+quaternion!) + (set! (-> (the-as (inline-array cspace) v0-0) 0 param1) + (the-as basic (-> self parent-override 0 node-list data)) + ) + (set! (-> (the-as (inline-array cspace) v0-0) 0 param2) + (the-as basic (-> self parent-override 0 control quat)) + ) ) - (set! - (-> (the-as (inline-array cspace) v0-0) 0 param1) - (the-as basic (-> self parent-override 0 node-list data)) - ) - (set! - (-> (the-as (inline-array cspace) v0-0) 0 param2) - (the-as basic (-> self parent-override 0 control quat)) + (('copy-parent) + (set! v0-0 (-> self node-list data)) + (set! (-> (the-as (inline-array cspace) v0-0) 0 param0) cspace<-cspace!) + (set! (-> (the-as (inline-array cspace) v0-0) 0 param1) + (the-as basic (-> self parent-override 0 node-list data)) + ) + (set! (-> (the-as (inline-array cspace) v0-0) 0 param2) #f) ) + (else + (set! v0-0 (-> self node-list data)) + (set! (-> (the-as (inline-array cspace) v0-0) 0 param0) cspace<-cspace+quaternion!) + (set! (-> (the-as (inline-array cspace) v0-0) 0 param1) + (the-as basic (-> self parent-override 0 control unknown-cspace10 parent)) + ) + (set! (-> (the-as (inline-array cspace) v0-0) 0 param2) + (the-as basic (-> self parent-override 0 control quat)) + ) + ) ) - (('copy-parent) - (set! v0-0 (-> self node-list data)) - (set! (-> (the-as (inline-array cspace) v0-0) 0 param0) cspace<-cspace!) - (set! - (-> (the-as (inline-array cspace) v0-0) 0 param1) - (the-as basic (-> self parent-override 0 node-list data)) - ) - (set! (-> (the-as (inline-array cspace) v0-0) 0 param2) #f) - ) - (else - (set! v0-0 (-> self node-list data)) - (set! - (-> (the-as (inline-array cspace) v0-0) 0 param0) - cspace<-cspace+quaternion! - ) - (set! - (-> (the-as (inline-array cspace) v0-0) 0 param1) - (the-as - basic - (-> self parent-override 0 control unknown-cspace10 parent) - ) - ) - (set! - (-> (the-as (inline-array cspace) v0-0) 0 param2) - (the-as basic (-> self parent-override 0 control quat)) - ) - ) + v0-0 ) - v0-0 - ) - (('shadow) - (set! v0-0 (-> arg3 param 0)) - (set! (-> self shadow-in-movie?) (the-as symbol v0-0)) - v0-0 - ) - (('blend-shape) - (cond - ((-> arg3 param 0) - (set! v0-0 (logior (-> self skel status) 8)) - (set! (-> self skel status) (the-as uint v0-0)) + (('shadow) + (set! v0-0 (-> arg3 param 0)) + (set! (-> self shadow-in-movie?) (the-as symbol v0-0)) + v0-0 ) - (else - (set! v0-0 (logand -9 (-> self skel status))) - (set! (-> self skel status) (the-as uint v0-0)) + (('blend-shape) + (cond + ((-> arg3 param 0) + (set! v0-0 (logior (-> self skel status) 8)) + (set! (-> self skel status) (the-as uint v0-0)) + ) + (else + (set! v0-0 (logand -9 (-> self skel status))) + (set! (-> self skel status) (the-as uint v0-0)) + ) + ) + v0-0 ) ) - v0-0 - ) ) - ) :code (the-as (function none :behavior sidekick) looping-code) :post (behavior () - (let ((v1-0 'process-drawable-art-error) - (a0-0 (-> self parent-override)) - ) - (when (!= (-> (if a0-0 - (-> a0-0 0 self-override) - ) - next-state - name - ) - v1-0 - ) - (quaternion-copy! - (-> self root quat) - (-> self parent-override 0 control quat) - ) - (set! (-> self anim-seed) (-> self parent-override 0 anim-seed)) - (set! (-> self draw status) (-> self parent-override 0 draw status)) - (joint-control-copy! (-> self skel) (-> self parent-override 0 skel)) - (joint-control-remap! - (-> self skel) - (-> self draw art-group) - (-> self parent-override 0 draw art-group) - *sidekick-remap* - (the-as int (-> self anim-seed)) - "" - ) - (let ((v1-22 (-> self parent-override 0 draw color-mult quad))) - (set! (-> self draw color-mult quad) v1-22) - ) - (let ((v1-26 (-> self parent-override 0 draw color-emissive quad))) - (set! (-> self draw color-emissive quad) v1-26) - ) - (set! - (-> self draw secondary-interp) - (-> self parent-override 0 draw secondary-interp) - ) - (if *debug-segment* - (add-frame - (-> *display* frames (-> *display* on-screen) frame profile-bar 0) - 'draw - (new 'static 'rgba :r #x40 :b #x40 :a #x80) - ) - ) - (dummy-17 self) - (if *debug-segment* - (add-frame - (-> *display* frames (-> *display* on-screen) frame profile-bar 0) - 'draw - (new 'static 'rgba :r #x80 :a #x80) - ) - ) - (vector<-cspace! - (-> self draw origin) - (-> self node-list data (-> self draw origin-joint-index)) - ) - ) - ) - (when *display-sidekick-stats* - (format *stdcon* "~%") - (debug-print-channels (-> self skel) (the-as symbol *stdcon*)) - (add-debug-sphere - *display-sidekick-stats* - (bucket-id debug-draw1) - (-> - self - parent-override - 0 - control - unknown-cspace10 - parent - bone - transform - vector - 3 - ) - 409.6 - (new 'static 'rgba :g #xff :a #x80) - ) - (add-debug-sphere - *display-sidekick-stats* - (bucket-id debug-draw1) - (-> self node-list data 3 bone transform vector 3) - 409.6 - (new 'static 'rgba :r #xff :g #xff :a #x80) - ) - (add-debug-sphere - *display-sidekick-stats* - (bucket-id debug-draw1) - (-> self draw origin) - 409.6 - (new 'static 'rgba :r #xff :g #x80 :a #x80) - ) - ) - (set! - (-> self draw shadow) - (the-as shadow-geo (if (and (movie?) (-> self shadow-in-movie?)) - (-> self draw art-group data 2) + (let ((v1-0 'process-drawable-art-error) + (a0-0 (-> self parent-override)) + ) + (when (!= (-> (if a0-0 + (-> a0-0 0 self-override) ) - ) - ) - - (#unless TARGET_STARTUP_HACKS - (let ((a0-26 (-> self skel effect))) - (if a0-26 - (TODO-RENAME-9 a0-26) - ) + next-state + name + ) + v1-0 + ) + (quaternion-copy! (-> self root quat) (-> self parent-override 0 control quat)) + (set! (-> self anim-seed) (-> self parent-override 0 anim-seed)) + (set! (-> self draw status) (-> self parent-override 0 draw status)) + (joint-control-copy! (-> self skel) (-> self parent-override 0 skel)) + (joint-control-remap! + (-> self skel) + (-> self draw art-group) + (-> self parent-override 0 draw art-group) + *sidekick-remap* + (the-as int (-> self anim-seed)) + "" + ) + (let ((v1-22 (-> self parent-override 0 draw color-mult quad))) + (set! (-> self draw color-mult quad) v1-22) + ) + (let ((v1-26 (-> self parent-override 0 draw color-emissive quad))) + (set! (-> self draw color-emissive quad) v1-26) + ) + (set! (-> self draw secondary-interp) (-> self parent-override 0 draw secondary-interp)) + (if *debug-segment* + (add-frame + (-> *display* frames (-> *display* on-screen) frame profile-bar 0) + 'draw + (new 'static 'rgba :r #x40 :b #x40 :a #x80) ) - (if (logtest? (-> self skel status) 72) - (merc-blend-shape self) - ) - (if (logtest? (-> self skel status) 384) - (merc-eye-anim self) - ) ) - - (none) - ) + (dummy-17 self) + (if *debug-segment* + (add-frame + (-> *display* frames (-> *display* on-screen) frame profile-bar 0) + 'draw + (new 'static 'rgba :r #x80 :a #x80) + ) + ) + (vector<-cspace! (-> self draw origin) (-> self node-list data (-> self draw origin-joint-index))) + ) + ) + (when *display-sidekick-stats* + (format *stdcon* "~%") + (debug-print-channels (-> self skel) (the-as symbol *stdcon*)) + (add-debug-sphere + *display-sidekick-stats* + (bucket-id debug-draw1) + (-> self parent-override 0 control unknown-cspace10 parent bone transform vector 3) + 409.6 + (new 'static 'rgba :g #xff :a #x80) + ) + (add-debug-sphere + *display-sidekick-stats* + (bucket-id debug-draw1) + (-> self node-list data 3 bone transform vector 3) + 409.6 + (new 'static 'rgba :r #xff :g #xff :a #x80) + ) + (add-debug-sphere + *display-sidekick-stats* + (bucket-id debug-draw1) + (-> self draw origin) + 409.6 + (new 'static 'rgba :r #xff :g #x80 :a #x80) + ) + ) + (set! (-> self draw shadow) (the-as shadow-geo (if (and (movie?) (-> self shadow-in-movie?)) + (-> self draw art-group data 2) + ) + ) + ) + (#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) + ) ) (defskelgroup *sidekick-sg* sidekick @@ -318,16 +241,10 @@ (set! (-> self draw shadow-ctrl) *target-shadow-control*) (logior! (-> self skel status) 256) (let ((v1-14 (-> self node-list data))) - (set! (-> v1-14 0 param0) cspace<-cspace+quaternion!) - (set! - (-> v1-14 0 param1) - (the-as basic (-> self parent-override 0 control unknown-cspace10 parent)) + (set! (-> v1-14 0 param0) cspace<-cspace+quaternion!) + (set! (-> v1-14 0 param1) (the-as basic (-> self parent-override 0 control unknown-cspace10 parent))) + (set! (-> v1-14 0 param2) (the-as basic (-> self parent-override 0 control quat))) ) - (set! - (-> v1-14 0 param2) - (the-as basic (-> self parent-override 0 control quat)) - ) - ) (set! (-> self shadow-in-movie?) #t) (go sidekick-clone) (none) diff --git a/goal_src/goal-lib.gc b/goal_src/goal-lib.gc index 9ab0d735a4..48c4631494 100644 --- a/goal_src/goal-lib.gc +++ b/goal_src/goal-lib.gc @@ -113,6 +113,21 @@ `(#cond (,clause ,true) (#t ,false)) ) +(defmacro move-if-not-zero (result value check original) + `(if (!= ,check 0) + (set! ,result (the-as int ,value)) + (set! ,result (the-as int ,original)) + ) + ) + +(defmacro set-on-less-than (dest src1 src2) + "dest = src1 < src2 ? 1 : 0 -- Compare as Signed Integers" + `(if (< (the int ,src1) (the int ,src2)) + (set! ,dest 1) + (set! ,dest 0) + ) + ) + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; TARGET CONTROL ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -578,6 +593,10 @@ `(&-> (the-as (pointer ,t) ,addr) ,@fields) ) +(defmacro shift-arith-right-32 (result in sa) + `(set! ,result (sext32 (sar (logand #xffffffff (the-as int ,in)) ,sa))) + ) + ;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Bit Macros ;;;;;;;;;;;;;;;;;;;;;;;;;;; diff --git a/goal_src/levels/common/nav-enemy.gc b/goal_src/levels/common/nav-enemy.gc index 3111f953fe..f65b58fd6b 100644 --- a/goal_src/levels/common/nav-enemy.gc +++ b/goal_src/levels/common/nav-enemy.gc @@ -83,7 +83,7 @@ (set-collide-offense (-> obj collide-info) 2 (collide-offense touch)) (set! (-> obj nav-enemy-flags) (logand -257 (-> obj nav-enemy-flags))) ) - (dummy-14 (-> obj draw shadow-ctrl)) + (#unless TARGET_STARTUP_HACKS (dummy-14 (-> obj draw shadow-ctrl))) (when *target* (if *target* (look-at-enemy! @@ -551,7 +551,7 @@ nav-enemy-default-event-handler ) (defbehavior nav-enemy-test-point-near-nav-mesh? nav-enemy ((arg0 vector)) - (and (dummy-25 (-> self nav) arg0 (-> self nav-info notice-nav-radius)) + (and (is-in-mesh? (-> self nav) arg0 (-> self nav-info notice-nav-radius)) (< (-> arg0 y) (+ (-> self collide-info trans y) (-> self enemy-info notice-top))) ) ) @@ -727,7 +727,8 @@ nav-enemy-default-event-handler (and (>= (+ (-> *ACTOR-bank* pause-dist) (-> obj collide-info pause-adjust-distance)) (vector-vector-distance (-> obj collide-info trans) (camera-pos)) ) - (or (logtest? (-> obj draw status) (draw-status drwf03)) (!= (-> obj next-state name) 'nav-enemy-idle)) + (or (#if TARGET_STARTUP_HACKS #t (logtest? (-> self draw status) (draw-status drwf03))) + (!= (-> obj next-state name) 'nav-enemy-idle)) ) ) (and (nonzero? (-> obj skel)) (!= (-> obj skel root-channel 0) (-> obj skel channel))) @@ -768,7 +769,7 @@ nav-enemy-default-event-handler ) (>= (- (-> *display* base-frame-counter) (-> self state-time)) (-> self state-timeout)) (nonzero? (-> self draw)) - (logtest? (-> self draw status) (draw-status drwf03)) + (#if TARGET_STARTUP_HACKS #t (logtest? (-> self draw status) (draw-status drwf03))) ) (go-virtual nav-enemy-patrol) ) @@ -832,7 +833,8 @@ nav-enemy-default-event-handler (behavior () (when (>= (- (-> *display* base-frame-counter) (-> self state-time)) 30) (when (>= (- (-> *display* base-frame-counter) (-> self state-time)) (-> self state-timeout)) - (if (and (nonzero? (-> self draw)) (logtest? (-> self draw status) (draw-status drwf03))) + (if (and (nonzero? (-> self draw)) + (#if TARGET_STARTUP_HACKS #t (logtest? (-> self draw status) (draw-status drwf03)))) (set! (-> self free-time) (-> *display* base-frame-counter)) ) (if (or (or (not *target*) (< (-> self enemy-info idle-distance) @@ -2116,7 +2118,7 @@ nav-enemy-default-event-handler (set! (-> obj nav) (new 'process 'nav-control (-> obj collide-info) 16 (-> arg0 nav-nearest-y-threshold))) (logior! (-> obj nav flags) (nav-control-flags display-marks bit3 bit5 bit6 bit7)) (set! (-> obj nav gap-event) 'jump) - (dummy-26 (-> obj nav)) + (TODO-RENAME-26 (-> obj nav)) (set! (-> obj path) (new 'process 'path-control obj 'path 0.0)) (logior! (-> obj path flags) (path-control-flag display draw-line draw-point draw-text)) (set! (-> obj enemy-info) @@ -2198,7 +2200,75 @@ nav-enemy-default-event-handler (set! (-> s4-0 quad) (-> obj collide-info trans quad)) (set! (-> obj collide-info trans quad) (-> arg0 quad)) (let ((gp-0 (-> obj nav))) - (dummy-28 gp-0 -1) + (TODO-RENAME-28 + gp-0 + (collide-kind + background + cak-1 + cak-2 + cak-3 + target + water + powerup + crate + enemy + wall-object + projectile + ground-object + target-attack + mother-spider + cak-14 + blue-eco-suck + unknown-16 + unknown-17 + unknown-18 + unknown-19 + unknown-20 + unknown-21 + unknown-22 + unknown-23 + unknown-24 + unknown-25 + unknown-26 + unknown-27 + unknown-28 + unknown-29 + unknown-30 + unknown-31 + unknown-32 + unknown-33 + unknown-34 + unknown-35 + unknown-36 + unknown-37 + unknown-38 + unknown-39 + unknown-40 + unknown-41 + unknown-42 + unknown-43 + unknown-44 + unknown-45 + unknown-46 + unknown-47 + unknown-48 + unknown-49 + unknown-50 + unknown-51 + unknown-52 + unknown-53 + unknown-54 + unknown-55 + unknown-56 + unknown-57 + unknown-58 + unknown-59 + unknown-60 + unknown-61 + unknown-62 + unknown-63 + ) + ) (set! (-> obj collide-info trans quad) (-> s4-0 quad)) (let* ((v1-8 (-> gp-0 mesh origin)) (f0-1 (- (-> arg0 x) (-> v1-8 x))) diff --git a/goal_src/levels/common/sharkey.gc b/goal_src/levels/common/sharkey.gc index 2d78b0d461..44d31ab7f7 100644 --- a/goal_src/levels/common/sharkey.gc +++ b/goal_src/levels/common/sharkey.gc @@ -207,7 +207,7 @@ nav-enemy-default-event-handler (vector-normalize! (-> self dir) 1.0) (vector+*! gp-0 s4-0 (-> self dir) (- (-> self spawn-distance))) ) - (dummy-17 (-> self nav) gp-0 gp-0) + (project-onto-nav-mesh (-> self nav) gp-0 gp-0) (set! (-> gp-0 y) (-> self y-min)) (set! (-> self spawn-point quad) (-> gp-0 quad)) ) diff --git a/goal_src/levels/maincave/mother-spider.gc b/goal_src/levels/maincave/mother-spider.gc index 058a8da47c..7271eaaea8 100644 --- a/goal_src/levels/maincave/mother-spider.gc +++ b/goal_src/levels/maincave/mother-spider.gc @@ -1408,7 +1408,7 @@ (> (-> self birthing-counter) 0) (and (>= 49152.0 (- (-> self max-dist-from-anchor) (-> self dist-from-anchor))) (zero? (logand (-> *target* state-flags) #x80f8)) - (dummy-21 (-> self nav) (-> self root-override trans)) + (TODO-RENAME-21 (-> self nav) (-> self root-override trans)) ) ) (go mother-spider-birth-baby) @@ -1480,7 +1480,7 @@ (if (letgo-player? self) (go mother-spider-traveling (the-as uint 0)) ) - (if (not (dummy-21 (-> self nav) (-> self root-override trans))) + (if (not (TODO-RENAME-21 (-> self nav) (-> self root-override trans))) (go mother-spider-birthing) ) (TODO-RENAME-29 self #t #t) @@ -1546,7 +1546,73 @@ (defmethod TODO-RENAME-20 mother-spider ((obj mother-spider) (arg0 vector) (arg1 vector)) (set! (-> obj nav nav-cull-radius) 40960.0) (set-current-poly! (-> obj nav) (dummy-16 (-> obj nav) (-> obj root-override trans))) - (dummy-28 (-> obj nav) -1) + (TODO-RENAME-28 (-> obj nav) (collide-kind + background + cak-1 + cak-2 + cak-3 + target + water + powerup + crate + enemy + wall-object + projectile + ground-object + target-attack + mother-spider + cak-14 + blue-eco-suck + unknown-16 + unknown-17 + unknown-18 + unknown-19 + unknown-20 + unknown-21 + unknown-22 + unknown-23 + unknown-24 + unknown-25 + unknown-26 + unknown-27 + unknown-28 + unknown-29 + unknown-30 + unknown-31 + unknown-32 + unknown-33 + unknown-34 + unknown-35 + unknown-36 + unknown-37 + unknown-38 + unknown-39 + unknown-40 + unknown-41 + unknown-42 + unknown-43 + unknown-44 + unknown-45 + unknown-46 + unknown-47 + unknown-48 + unknown-49 + unknown-50 + unknown-51 + unknown-52 + unknown-53 + unknown-54 + unknown-55 + unknown-56 + unknown-57 + unknown-58 + unknown-59 + unknown-60 + unknown-61 + unknown-62 + unknown-63 + ) + ) (dotimes (s3-1 4) (let ((f28-0 (+ 32768.0 (-> obj orient-rot y))) (f30-0 (rand-vu-float-range 16384.0 40960.0)) @@ -1594,7 +1660,7 @@ ) ) ) - (dummy-17 (-> obj nav) arg0 (-> obj root-override trans)) + (project-onto-nav-mesh (-> obj nav) arg0 (-> obj root-override trans)) (let ((a1-12 (new 'stack-no-clear 'vector)) (s3-2 (new 'stack-no-clear 'collide-tri-result)) ) diff --git a/goal_src/levels/rolling/rolling-lightning-mole.gc b/goal_src/levels/rolling/rolling-lightning-mole.gc index 2be2c4ecc5..932b8a7f5e 100644 --- a/goal_src/levels/rolling/rolling-lightning-mole.gc +++ b/goal_src/levels/rolling/rolling-lightning-mole.gc @@ -5,3 +5,1505 @@ ;; name in dgo: rolling-lightning-mole ;; dgos: L1, ROL +;; DECOMP BEGINS + +(defun find-adjacent-bounds-one ((arg0 nav-mesh) (arg1 nav-poly) (arg2 int) (arg3 (array int8)) (arg4 (array int8)) (arg5 vector)) + (local-vars (v0-2 object) (v1-2 int) (v1-30 int) (a0-2 int) (a0-12 int) (sv-16 nav-poly) (sv-32 int)) + (let ((v1-1 (+ arg2 1))) + (let ((a0-1 2)) + (set-on-less-than a0-2 a0-1 v1-1) + ) + (move-if-not-zero v1-2 0 a0-2 v1-1) + ) + (let ((v1-4 (-> arg1 adj-poly v1-2))) + (cond + ((= v1-4 255) + ) + ((zero? (logand (-> arg0 poly v1-4 pat) 1)) + (format 0 "ERROR: find-adjacent-bounds-one given a non-boundary edge to start~%") + (return #f) + ) + ) + ) + (let ((s0-0 (-> arg1 vertex (-> arg3 arg2)))) + (set! sv-16 arg1) + (while (begin (label cfg-28) #t) + (set! sv-32 0) + (while (< sv-32 3) + (cond + ((and (= sv-32 arg2) (= sv-16 arg1)) + ) + ((= s0-0 (-> sv-16 vertex (-> arg4 sv-32))) + (vector+! arg5 (-> arg0 origin) (the-as vector (-> arg0 vertex (-> sv-16 vertex (-> arg3 sv-32))))) + (let ((v1-29 (+ sv-32 1))) + (let ((a0-11 2)) + (set-on-less-than a0-12 a0-11 v1-29) + ) + (move-if-not-zero v1-30 0 a0-12 v1-29) + ) + (let ((v1-32 (-> sv-16 adj-poly v1-30))) + (if (= v1-32 255) + (return #t) + ) + (let ((v1-35 (-> arg0 poly v1-32))) + (set! v0-2 (cond + ((= arg1 v1-35) + (format 0 "ERROR: find-adjacent-bounds-one given tried to go back~%") + ) + (else + (cond + ((logtest? (-> v1-35 pat) 1) + (return #t) + ) + (else + (set! arg1 sv-16) + (set! sv-16 v1-35) + (goto cfg-28) + ) + ) + v0-2 + ) + ) + ) + ) + ) + ) + ) + (set! sv-32 (+ sv-32 1)) + ) + (format 0 "ERROR: abnormal exit from find-adjacent-bounds-one~%") + (return #f) + ) + ) + #f + ) + +;; WARN: Expression building failed: Function find-adjacent-bounds has a return type of none, but the expression builder found a return statement. +(defun find-adjacent-bounds ((arg0 nav-mesh) (arg1 clip-travel-vector-to-mesh-return-info)) + (when (!= (-> arg1 found-boundary) #t) + (format 0 "ERROR: find-adjacent-bounds passed info which doesn't specify a boundary edge~%") + (return #f) + ) + (find-adjacent-bounds-one + arg0 + (-> arg1 poly) + (-> arg1 edge) + *edge-vert0-table* + *edge-vert1-table* + (-> arg1 vert-prev) + ) + (find-adjacent-bounds-one + arg0 + (-> arg1 poly) + (-> arg1 edge) + *edge-vert1-table* + *edge-vert0-table* + (-> arg1 vert-next) + ) + (vector-reset! (-> arg1 prev-normal)) + (vector-reset! (-> arg1 next-normal)) + (set! (-> arg1 prev-normal x) (- (-> arg1 vert-prev z) (-> arg1 vert-0 z))) + (set! (-> arg1 prev-normal z) (- (-> arg1 vert-0 x) (-> arg1 vert-prev x))) + (set! (-> arg1 next-normal x) (- (-> arg1 vert-1 z) (-> arg1 vert-next z))) + (set! (-> arg1 next-normal z) (- (-> arg1 vert-next x) (-> arg1 vert-1 x))) + (vector-normalize! (-> arg1 prev-normal) 1.0) + (vector-normalize! (-> arg1 next-normal) 1.0) + (camera-line (-> arg1 vert-prev) (-> arg1 vert-0) (new 'static 'vector4w :x #xff :w #x80)) + (camera-line (-> arg1 vert-0) (-> arg1 vert-1) (new 'static 'vector4w :y #xff :w #x80)) + (camera-line (-> arg1 vert-1) (-> arg1 vert-next) (new 'static 'vector4w :z #xff :w #x80)) + (let ((s5-1 (new 'stack-no-clear 'vector))) + (vector+! s5-1 (-> arg1 vert-prev) (-> arg1 vert-0)) + (vector-float*! s5-1 s5-1 0.5) + (camera-line-rel-len s5-1 (-> arg1 prev-normal) 8192.0 (new 'static 'vector4w :x #xff :w #x80)) + (vector+! s5-1 (-> arg1 vert-0) (-> arg1 vert-1)) + (vector-float*! s5-1 s5-1 0.5) + (camera-line-rel-len s5-1 (-> arg1 boundary-normal) 8192.0 (new 'static 'vector4w :y #xff :w #x80)) + (vector+! s5-1 (-> arg1 vert-1) (-> arg1 vert-next)) + (vector-float*! s5-1 s5-1 0.5) + (camera-line-rel-len s5-1 (-> arg1 next-normal) 8192.0 (new 'static 'vector4w :z #xff :w #x80)) + ) + (none) + ) + +(deftype fleeing-nav-enemy-info (structure) + ((min-reflect-angle float :offset-assert 0) + (max-reflect-angle float :offset-assert 4) + (max-boundary-deflection float :offset-assert 8) + (deflection-min-dist float :offset-assert 12) + (deflection-max-dist float :offset-assert 16) + (reflection-time int32 :offset-assert 20) + (travel-rotate-speed float :offset-assert 24) + (blend_interp_angle float :offset-assert 28) + (min-speed-adjust float :offset-assert 32) + (max-speed-adjust float :offset-assert 36) + (speed-adjust-center float :offset-assert 40) + (speed-adjust-range float :offset-assert 44) + (abort-notice-distance float :offset-assert 48) + (min-notice-dist float :offset-assert 52) + (max-notice-dist float :offset-assert 56) + (min-stop-chase-dist float :offset-assert 60) + (max-stop-chase-dist float :offset-assert 64) + (max-flee-rotation float :offset-assert 68) + ) + :allow-misaligned + :method-count-assert 9 + :size-assert #x48 + :flag-assert #x900000048 + ) + + +(deftype fleeing-nav-enemy (nav-enemy) + ((last-reflection-time uint64 :offset-assert 400) + (run-blend-interp float :offset-assert 408) + (desired-travel vector :inline :offset-assert 416) + (saved-travel vector :inline :offset-assert 432) + (speed-adjust float :offset-assert 448) + (flee-info fleeing-nav-enemy-info :inline :offset-assert 452) + ) + :heap-base #x1a0 + :method-count-assert 76 + :size-assert #x20c + :flag-assert #x4c01a0020c + (:states + fleeing-nav-enemy-debug + ) + ) + + +(defbehavior fleeing-nav-enemy-adjust-nav-info fleeing-nav-enemy () + (let ((f30-0 (vector-vector-distance (-> *camera* tpos-curr-adj) (-> *camera* tpos-old-adj)))) + (set! (-> self nav-info notice-distance) (lerp-clamp + (-> self flee-info min-notice-dist) + (-> self flee-info max-notice-dist) + (parameter-ease-sin-clamp (* 0.00081380206 (+ -409.6 f30-0))) + ) + ) + (let ((f0-9 (lerp-clamp + (-> self flee-info min-stop-chase-dist) + (-> self flee-info max-stop-chase-dist) + (parameter-ease-sin-clamp (* 0.00081380206 (+ -409.6 f30-0))) + ) + ) + ) + (set! (-> self nav-info stop-chase-distance) f0-9) + f0-9 + ) + ) + ) + +(defun fleeing-nav-enemy-clip-travel ((arg0 fleeing-nav-enemy) (arg1 vector)) + (local-vars (sv-224 vector) (sv-240 vector) (sv-256 vector) (sv-272 vector) (sv-288 vector)) + (let ((s2-0 (new 'stack 'clip-travel-vector-to-mesh-return-info)) + (gp-0 (new 'stack-no-clear 'vector)) + (s1-0 #f) + ) + (set! (-> gp-0 quad) (-> arg0 nav travel quad)) + (set! (-> arg0 nav travel quad) (-> arg1 quad)) + (dummy-24 (-> arg0 nav) (-> arg0 flee-info deflection-max-dist) s2-0) + (when (-> s2-0 found-boundary) + (let ((s0-0 (new 'stack-no-clear 'vector)) + (s3-0 (new 'stack-no-clear 'vector)) + ) + 0.0 + 0.0 + (vector-! s0-0 (-> s2-0 intersection) (-> arg0 collide-info trans)) + (set! (-> arg0 nav travel quad) (-> s0-0 quad)) + (let ((f28-0 (vector-dot s0-0 (-> s2-0 boundary-normal)))) + (set! (-> s0-0 quad) (-> arg1 quad)) + (set! (-> s0-0 y) 0.0) + (vector-normalize! s0-0 1.0) + (let ((f30-0 (vector-dot s0-0 (-> s2-0 boundary-normal)))) + (cond + ((< (-> arg0 flee-info deflection-min-dist) f28-0) + (let* ((f0-9 (/ (- f28-0 (-> arg0 flee-info deflection-min-dist)) + (- (-> arg0 flee-info deflection-max-dist) (-> arg0 flee-info deflection-min-dist)) + ) + ) + (f0-10 (fmin 1.0 f0-9)) + (f28-1 (* (- 1.0 f0-10) (-> arg0 flee-info max-boundary-deflection))) + ) + (cond + ((< (cos f28-1) f30-0) + (vector--float*! s3-0 s0-0 (-> s2-0 boundary-normal) f30-0) + (let ((s0-1 vector-normalize!)) + (set! sv-224 s3-0) + (let ((a1-7 (sin f28-1))) + (s0-1 sv-224 a1-7) + ) + ) + (let ((s0-2 vector+float*!)) + (set! sv-240 s3-0) + (set! sv-256 s3-0) + (let ((s2-1 (-> s2-0 boundary-normal)) + (a3-1 (cos f28-1)) + ) + (s0-2 sv-240 sv-256 s2-1 a3-1) + ) + ) + ) + (else + (let ((v1-15 s3-0)) + (set! (-> v1-15 quad) (-> s0-0 quad)) + v1-15 + ) + ) + ) + ) + ) + ((< (cos (-> arg0 flee-info min-reflect-angle)) f30-0) + (vector--float*! s3-0 s0-0 (-> s2-0 boundary-normal) f30-0) + (vector-normalize! s3-0 (sin (-> arg0 flee-info min-reflect-angle))) + (let ((s1-2 vector--float*!) + (s0-4 s3-0) + ) + (set! sv-272 s3-0) + (let ((s2-2 (-> s2-0 boundary-normal)) + (a3-3 (cos (-> arg0 flee-info min-reflect-angle))) + ) + (s1-2 s0-4 sv-272 s2-2 a3-3) + ) + ) + (set! s1-0 #t) + ) + ((< f30-0 (cos (-> arg0 flee-info max-reflect-angle))) + (vector--float*! s3-0 s0-0 (-> s2-0 boundary-normal) f30-0) + (vector-normalize! s3-0 (sin (-> arg0 flee-info max-reflect-angle))) + (let ((s1-4 vector--float*!) + (s0-6 s3-0) + ) + (set! sv-288 s3-0) + (let ((s2-3 (-> s2-0 boundary-normal)) + (a3-5 (cos (-> arg0 flee-info max-reflect-angle))) + ) + (s1-4 s0-6 sv-288 s2-3 a3-5) + ) + ) + (set! s1-0 #t) + ) + (else + (vector--float*! s3-0 s0-0 (-> s2-0 boundary-normal) (* 2.0 f30-0)) + (set! s1-0 #t) + ) + ) + ) + ) + (vector-normalize-copy! arg1 s3-0 (-> arg0 flee-info deflection-max-dist)) + ) + ) + (set! (-> arg0 nav travel quad) (-> gp-0 quad)) + s1-0 + ) + ) + +(defun fleeing-nav-enemy-adjust-travel ((arg0 fleeing-nav-enemy) (arg1 object)) + (let ((s3-0 (new 'stack-no-clear 'matrix)) + (s4-0 (new 'stack-no-clear 'vector)) + ) + (let ((s5-0 (new 'stack-no-clear 'vector))) + (set! (-> s4-0 quad) (-> arg0 saved-travel quad)) + (set! (-> s4-0 y) 0.0) + (set! (-> s5-0 quad) (-> arg0 desired-travel quad)) + (set! (-> s5-0 y) 0.0) + (vector-normalize! s4-0 1.0) + (vector-normalize! s5-0 1.0) + (matrix-from-two-vectors-max-angle-partial! s3-0 s4-0 s5-0 (-> arg0 flee-info travel-rotate-speed) 0.2) + ) + (vector-matrix*! (-> arg0 saved-travel) s4-0 s3-0) + ) + (vector-float*! (-> arg0 saved-travel) (-> arg0 saved-travel) (-> arg0 flee-info deflection-max-dist)) + (set! (-> arg0 nav travel quad) (-> arg0 saved-travel quad)) + (vector+! (-> arg0 nav target-pos) (-> arg0 collide-info trans) (-> arg0 nav travel)) + ) + +(defbehavior fleeing-nav-enemy-chase-post-func fleeing-nav-enemy () + (let ((gp-0 (new 'stack-no-clear 'matrix)) + (s5-0 (new 'stack-no-clear 'matrix)) + ) + (quaternion->matrix gp-0 (-> self collide-info quat)) + (set! (-> self collide-info old-y-angle-diff) 0.0) + (nav-enemy-travel-post) + (quaternion->matrix s5-0 (-> self collide-info quat)) + (set! (-> self run-blend-interp) (acos (vector-dot (-> s5-0 vector 2) (-> gp-0 vector 2)))) + (set! (-> self run-blend-interp) (/ (-> self run-blend-interp) (-> self flee-info blend_interp_angle))) + (when (< (vector-dot (-> s5-0 vector 2) (the-as vector (-> gp-0 vector))) 0.0) + (let ((f0-8 (- (-> self run-blend-interp)))) + (set! (-> self run-blend-interp) f0-8) + f0-8 + ) + ) + ) + ) + +(defbehavior fleeing-nav-enemy-chase-post fleeing-nav-enemy () + (let ((gp-0 (new 'stack-no-clear 'vector))) + (vector-! gp-0 (-> self collide-info trans) (target-pos 0)) + (let* ((f0-1 (vector-dot (vector-normalize-copy! (new 'stack-no-clear 'vector) (-> self desired-travel) 1.0) gp-0)) + (f0-3 (/ (- (-> self flee-info speed-adjust-center) f0-1) (-> self flee-info speed-adjust-range))) + (f1-3 (+ 1.0 f0-3)) + ) + (set! (-> self target-speed) + (* (fmax (-> self flee-info min-speed-adjust) (fmin (-> self flee-info max-speed-adjust) f1-3)) + (-> self nav-info run-travel-speed) + ) + ) + ) + (when (>= (- (-> *display* base-frame-counter) (the-as int (-> self last-reflection-time))) + (-> self flee-info reflection-time) + ) + (let ((s3-0 (new 'stack-no-clear 'matrix)) + (s5-2 (new 'stack-no-clear 'vector)) + ) + (let ((s4-1 (new 'stack-no-clear 'vector))) + (set! (-> s5-2 quad) (-> self desired-travel quad)) + (set! (-> s5-2 y) 0.0) + (set! (-> s4-1 quad) (-> gp-0 quad)) + (set! (-> s4-1 y) 0.0) + (if (= (vector-normalize-ret-len! s5-2 1.0) 0.0) + (set! (-> s5-2 quad) (-> s4-1 quad)) + ) + (vector-normalize-ret-len! s4-1 1.0) + (matrix-from-two-vectors-max-angle-partial! s3-0 s5-2 s4-1 (-> self flee-info max-flee-rotation) 0.25) + ) + (vector-matrix*! s5-2 s5-2 s3-0) + (vector-float*! (-> self desired-travel) s5-2 (-> self flee-info deflection-max-dist)) + ) + ) + ) + (if (fleeing-nav-enemy-clip-travel self (-> self desired-travel)) + (set! (-> self last-reflection-time) (the-as uint (-> *display* base-frame-counter))) + ) + (fleeing-nav-enemy-adjust-travel self (-> self desired-travel)) + (fleeing-nav-enemy-chase-post-func) + 0 + (none) + ) + +(defstate nav-enemy-patrol (fleeing-nav-enemy) + :virtual #t + :enter + (-> (method-of-type nav-enemy nav-enemy-patrol) enter) + :exit + (-> (method-of-type nav-enemy nav-enemy-patrol) exit) + :trans + (behavior () + ((-> (method-of-type nav-enemy nav-enemy-patrol) trans)) + (fleeing-nav-enemy-adjust-nav-info) + (none) + ) + :code + (-> (method-of-type nav-enemy nav-enemy-patrol) code) + :post + (-> (method-of-type nav-enemy nav-enemy-patrol) post) + ) + +(defstate nav-enemy-notice (fleeing-nav-enemy) + :virtual #t + :enter + (-> (method-of-type nav-enemy nav-enemy-notice) enter) + :trans + (behavior () + (fleeing-nav-enemy-adjust-nav-info) + (none) + ) + :code + (behavior () + (ja-channel-push! 1 22) + (let ((f30-0 (nav-enemy-rnd-float-range 1.0 1.2))) + (let ((a0-2 (-> self skel root-channel 0))) + (set! (-> a0-2 frame-group) + (the-as art-joint-anim (-> self draw art-group data (-> self nav-info notice-anim))) + ) + (set! (-> a0-2 param 0) + (the float + (+ (-> (the-as art-joint-anim (-> self draw art-group data (-> self nav-info notice-anim))) data 0 length) -1) + ) + ) + (set! (-> a0-2 param 1) f30-0) + (set! (-> a0-2 frame-num) 0.0) + (joint-control-channel-group! + a0-2 + (the-as art-joint-anim (-> self draw art-group data (-> self nav-info notice-anim))) + num-func-seek! + ) + ) + (until (ja-done? 0) + (seek-toward-heading-vec! + (-> self collide-info) + (-> self nav travel) + (-> self rotate-speed) + (-> self turn-time) + ) + (if (and *target* (>= (-> self flee-info abort-notice-distance) + (vector-vector-distance (-> self collide-info trans) (-> *target* control trans)) + ) + ) + (go-virtual nav-enemy-chase) + ) + (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) f30-0) + (joint-control-channel-group-eval! a0-5 (the-as art-joint-anim #f) num-func-seek!) + ) + ) + ) + (go-virtual nav-enemy-chase) + (none) + ) + :post + (-> (method-of-type nav-enemy nav-enemy-notice) post) + ) + +(defstate nav-enemy-chase (fleeing-nav-enemy) + :virtual #t + :enter + (behavior () + (logior! (-> self nav flags) (nav-control-flags bit12)) + ((-> (method-of-type nav-enemy nav-enemy-chase) enter)) + (none) + ) + :exit + (behavior () + (logclear! (-> self nav flags) (nav-control-flags bit12)) + (none) + ) + :trans + (behavior () + ((-> (method-of-type nav-enemy nav-enemy-chase) trans)) + (fleeing-nav-enemy-adjust-nav-info) + (none) + ) + :code + (-> (method-of-type nav-enemy nav-enemy-chase) code) + :post + (-> (method-of-type nav-enemy nav-enemy-chase) post) + ) + +(defstate nav-enemy-stop-chase (fleeing-nav-enemy) + :virtual #t + :enter + (-> (method-of-type nav-enemy nav-enemy-stop-chase) enter) + :trans + (behavior () + ((-> (method-of-type nav-enemy nav-enemy-stop-chase) trans)) + (fleeing-nav-enemy-adjust-nav-info) + (none) + ) + :code + (-> (method-of-type nav-enemy nav-enemy-stop-chase) code) + :post + (-> (method-of-type nav-enemy nav-enemy-stop-chase) post) + ) + +(defstate fleeing-nav-enemy-debug (fleeing-nav-enemy) + :enter + (-> (method-of-type nav-enemy nav-enemy-chase) enter) + :code + (behavior () + (let ((gp-0 (new-stack-vector0)) + (s5-0 (new-stack-vector0)) + ) + (set! (-> gp-0 x) 1.0) + (set! (-> s5-0 x) 1.0) + (while #t + (when (cpad-pressed? 1 r3) + (suspend) + (go fleeing-nav-enemy-debug) + ) + (let ((s2-0 (new-stack-vector0)) + (s4-0 (new-stack-vector0)) + ) + (let ((s3-0 (new-stack-matrix0))) + (clmf-input s2-0 s4-0 1) + (vector-float*! s2-0 s2-0 409.6) + (vector-float*! s4-0 s4-0 1820.4445) + (matrix-axis-angle! s3-0 (-> *camera* local-down) (-> s2-0 y)) + (vector-matrix*! gp-0 gp-0 s3-0) + ) + (if *target* + (vector-! gp-0 (-> self collide-info trans) (target-pos 0)) + ) + (vector-normalize! gp-0 (-> self flee-info deflection-max-dist)) + (let ((s3-3 (new 'stack-no-clear 'vector))) + (set! (-> s3-3 quad) (-> self nav travel quad)) + (set! (-> self nav travel quad) (-> s5-0 quad)) + (set! (-> self desired-travel quad) (-> gp-0 quad)) + (fleeing-nav-enemy-clip-travel self (-> self desired-travel)) + (fleeing-nav-enemy-adjust-travel self (-> self desired-travel)) + (set! (-> s5-0 quad) (-> self nav travel quad)) + (set! (-> self nav travel quad) (-> s3-3 quad)) + ) + (vector+! (-> self nav target-pos) (-> self collide-info trans) s4-0) + ) + (suspend) + ) + ) + (none) + ) + :post + (the-as (function none :behavior fleeing-nav-enemy) nav-enemy-travel-post) + ) + +(define *lightning-mole-hole* (new 'static 'vector :x -241664.0 :y 106496.0 :z -6393856.0)) + +(deftype lightning-mole (fleeing-nav-enemy) + ((debug-vector vector :inline :offset-assert 528) + (alt-actor entity-actor :offset-assert 544) + ) + :heap-base #x1c0 + :method-count-assert 76 + :size-assert #x224 + :flag-assert #x4c01c00224 + (:states + lightning-mole-debug-blend + lightning-mole-debug-run + lightning-mole-dive + lightning-mole-gone + lightning-mole-head-for-hole + lightning-mole-hiding + lightning-mole-yelp + ) + ) + + +(defskelgroup *lightning-mole-sg* lightning-mole + 0 + 5 + ((1 (meters 20)) (2 (meters 40)) (3 (meters 999999))) + :bounds (static-spherem 0 0 0 8) + :longest-edge (meters 0) + :shadow 4 + ) + +(defbehavior lightning-mole-task-complete? lightning-mole () + (local-vars (sv-16 symbol)) + (process-entity-status! self (entity-perm-status complete) #t) + (when (or (-> self link prev) (-> self link next)) + (set! sv-16 (the-as symbol #f)) + (apply-all (-> self link) actor-link-subtask-complete-hook (& sv-16)) + (cond + (sv-16 + (close-specific-task! (-> self entity extra perm task) (task-status need-reminder)) + (let ((gp-0 (get-process *default-dead-pool* process #x4000))) + (when gp-0 + (let ((t9-4 (method-of-type process activate))) + (t9-4 gp-0 self 'process (the-as pointer #x70004000)) + ) + (run-next-time-in-process gp-0 (lambda :behavior lightning-mole + () + (while (or (-> *setting-control* current ambient) + (-> *setting-control* current movie) + (-> *setting-control* current hint) + ) + (suspend) + ) + (level-hint-spawn + (game-text-id rolling-lightning-moles-completion) + "sksp0112" + (the-as entity #f) + *entity-pool* + (game-task none) + ) + (none) + ) + ) + (-> gp-0 ppointer) + ) + ) + (format #t "lightning-mole task is complete~%") + ) + (else + ) + ) + sv-16 + ) + ) + +(defbehavior lightning-mole-hole-post lightning-mole () + (set! (-> self nav target-pos quad) (-> *lightning-mole-hole* quad)) + (nav-enemy-travel-post) + 0 + (none) + ) + +(defbehavior lightning-mole-run-code lightning-mole () + (when (!= (if (> (-> self skel active-channels) 0) + (-> self skel root-channel 0 frame-group) + ) + (-> self draw art-group data 7) + ) + (ja-channel-push! 1 60) + (let ((v1-6 (-> self skel root-channel 0))) + (set! (-> v1-6 frame-group) (the-as art-joint-anim (-> self draw art-group data 7))) + ) + ) + (while #t + (let ((a0-9 (-> self skel root-channel 0))) + (set! (-> a0-9 param 0) (-> self speed-adjust)) + (joint-control-channel-group-eval! a0-9 (the-as art-joint-anim #f) num-func-loop!) + ) + (suspend) + ) + (none) + ) + +(defstate lightning-mole-debug-blend (lightning-mole) + :trans + (behavior () + (let ((gp-0 (new-stack-vector0))) + (let ((a1-0 (new-stack-vector0))) + (clmf-input gp-0 a1-0 1) + ) + (set! (-> self run-blend-interp) (-> gp-0 y)) + ) + (set! (-> self speed-adjust) 1.0) + (none) + ) + :code + lightning-mole-run-code + :post + (the-as (function none :behavior lightning-mole) ja-post) + ) + +(defstate lightning-mole-debug-run (lightning-mole) + :enter + (behavior () + (set! (-> self speed-adjust) 1.0) + (set-vector! (-> self debug-vector) 0.0 0.0 1.0 1.0) + (set! (-> self saved-travel quad) (-> self debug-vector quad)) + ((-> (method-of-type nav-enemy nav-enemy-chase) enter)) + (none) + ) + :trans + (behavior () + (when (cpad-pressed? 1 r3) + (logclear! (-> *cpad-list* cpads 1 button0-abs 0) (pad-buttons r3)) + (logclear! (-> *cpad-list* cpads 1 button0-rel 0) (pad-buttons r3)) + (go lightning-mole-debug-run) + ) + (none) + ) + :code + lightning-mole-run-code + :post + (behavior () + (let ((gp-0 (new 'stack-no-clear 'vector))) + (let ((s4-0 (new-stack-vector0)) + (a1-0 (new-stack-vector0)) + (s5-0 (new-stack-matrix0)) + ) + (clmf-input s4-0 a1-0 1) + (vector-float*! s4-0 s4-0 1820.4445) + (matrix-axis-angle! s5-0 (-> *camera* local-down) (-> s4-0 y)) + (vector-matrix*! (-> self debug-vector) (-> self debug-vector) s5-0) + ) + (vector-normalize! (-> self debug-vector) (-> self flee-info deflection-max-dist)) + (camera-line-rel + (-> self collide-info trans) + (-> self debug-vector) + (new 'static 'vector4w :x #x80 :y #x80 :w #x80) + ) + (set! (-> gp-0 quad) (-> self debug-vector quad)) + (set! (-> self target-speed) (-> self nav-info run-travel-speed)) + (format *stdcon* "tgt-speed ~M defmd ~M~%" (-> self target-speed) (-> self flee-info deflection-max-dist)) + (if (>= (- (-> *display* base-frame-counter) (the-as int (-> self last-reflection-time))) + (-> self flee-info reflection-time) + ) + (vector-normalize-copy! (-> self desired-travel) gp-0 (-> self flee-info deflection-max-dist)) + ) + ) + (if (fleeing-nav-enemy-clip-travel self (-> self desired-travel)) + (set! (-> self last-reflection-time) (the-as uint (-> *display* base-frame-counter))) + ) + (set! (-> self debug-vector quad) (-> self desired-travel quad)) + (fleeing-nav-enemy-adjust-travel self (-> self desired-travel)) + (fleeing-nav-enemy-chase-post-func) + (camera-line-rel + (-> self collide-info trans) + (-> self desired-travel) + (new 'static 'vector4w :x #x80 :w #x80) + ) + (camera-line-rel (-> self collide-info trans) (-> self nav travel) (new 'static 'vector4w :z #x80 :w #x80)) + (camera-line (-> self collide-info trans) (-> self nav target-pos) (new 'static 'vector4w :z #x80 :w #x80)) + (none) + ) + ) + +(defstate lightning-mole-gone (lightning-mole) + :code + (behavior () + (dummy-18 self) + (ja-channel-set! 0) + (ja-post) + (while (-> self child) + (suspend) + ) + (deactivate self) + (none) + ) + ) + +(defstate lightning-mole-hiding (lightning-mole) + :enter + (behavior () + (ja-channel-set! 0) + (clear-collide-with-as (-> self collide-info)) + (none) + ) + :trans + (behavior () + (when (task-closed? (-> self entity extra perm task) (task-status need-introduction)) + (ja-channel-set! 1) + (let ((v1-4 (-> self skel root-channel 0))) + (set! (-> v1-4 frame-group) (the-as art-joint-anim (-> self draw art-group data 5))) + ) + (restore-collide-with-as (-> self collide-info)) + (go-virtual nav-enemy-idle) + ) + (none) + ) + :code + (behavior () + (while #t + (suspend) + ) + (none) + ) + ) + +(defstate lightning-mole-dive (lightning-mole) + :trans + (behavior () + (when (< (vector-vector-xz-distance *lightning-mole-hole* (-> self collide-info trans)) 61440.0) + (let ((a1-1 (new 'stack-no-clear 'event-message-block))) + (set! (-> a1-1 from) self) + (set! (-> a1-1 num-params) 0) + (set! (-> a1-1 message) 'hide) + (let ((t9-1 send-event-function) + (v1-2 (-> self alt-actor)) + ) + (t9-1 + (if v1-2 + (-> v1-2 extra process) + ) + a1-1 + ) + ) + ) + ) + (none) + ) + :code + (behavior () + (let ((f30-0 (nav-enemy-rnd-float-range 0.9 1.1)) + (gp-0 (new 'stack-no-clear 'vector)) + ) + (vector+! gp-0 *lightning-mole-hole* (new 'static 'vector :x 81920.0 :y 40960.0)) + (hide-hud-quick) + (if *target* + (logior! (-> *target* mask) (process-mask sleep)) + ) + (ambient-hint-spawn "gamcam20" (the-as vector #f) *entity-pool* 'camera) + (ja-channel-push! 1 60) + (let ((a0-5 (-> self skel root-channel 0))) + (set! (-> a0-5 frame-group) (the-as art-joint-anim (-> self draw art-group data 12))) + (set! (-> a0-5 param 0) + (the float (+ (-> (the-as art-joint-anim (-> self draw art-group data 12)) data 0 length) -1)) + ) + (set! (-> a0-5 param 1) f30-0) + (set! (-> a0-5 frame-num) 0.0) + (joint-control-channel-group! a0-5 (the-as art-joint-anim (-> self draw art-group data 12)) num-func-seek!) + ) + (until (ja-done? 0) + (let ((s5-0 (new 'stack-no-clear 'vector))) + (set! (-> *camera-other-fov* data) 11650.845) + (vector-! s5-0 *lightning-mole-hole* gp-0) + (vector-normalize! s5-0 1.0) + (forward-down->inv-matrix *camera-other-matrix* s5-0 (-> *camera* local-down)) + ) + (set! (-> *camera-other-trans* quad) (-> gp-0 quad)) + (set! (-> *camera-other-root* quad) (-> *lightning-mole-hole* quad)) + (set! *camera-look-through-other* 2) + (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) f30-0) + (joint-control-channel-group-eval! a0-13 (the-as art-joint-anim #f) num-func-seek!) + ) + ) + ) + (lightning-mole-task-complete?) + (if *target* + (logclear! (-> *target* mask) (process-mask sleep)) + ) + (go lightning-mole-gone) + (none) + ) + :post + lightning-mole-hole-post + ) + +(defstate lightning-mole-head-for-hole (lightning-mole) + :enter + (behavior () + (clear-collide-with-as (-> self collide-info)) + (none) + ) + :trans + (behavior () + (when (< (vector-vector-xz-distance *lightning-mole-hole* (-> self collide-info trans)) 61440.0) + (let ((a1-1 (new 'stack-no-clear 'event-message-block))) + (set! (-> a1-1 from) self) + (set! (-> a1-1 num-params) 0) + (set! (-> a1-1 message) 'hide) + (let ((t9-1 send-event-function) + (v1-3 (-> self alt-actor)) + ) + (t9-1 + (if v1-3 + (-> v1-3 extra process) + ) + a1-1 + ) + ) + ) + ) + (if (< (vector-vector-distance (-> self collide-info trans) *lightning-mole-hole*) 40960.0) + (go lightning-mole-dive) + ) + (none) + ) + :code + (-> (method-of-type fleeing-nav-enemy nav-enemy-chase) code) + :post + lightning-mole-hole-post + ) + +(defstate lightning-mole-yelp (lightning-mole) + :enter + (behavior () + (clear-collide-with-as (-> self collide-info)) + ((-> (method-of-type fleeing-nav-enemy nav-enemy-chase) enter)) + (none) + ) + :exit + (behavior () + (restore-collide-with-as (-> self collide-info)) + (none) + ) + :trans + (-> (method-of-type fleeing-nav-enemy nav-enemy-chase) trans) + :code + (behavior () + (ja-channel-push! 1 60) + (let ((f30-0 (nav-enemy-rnd-float-range 0.9 1.1))) + (let ((a0-2 (-> self skel root-channel 0))) + (set! (-> a0-2 frame-group) (the-as art-joint-anim (-> self draw art-group data 10))) + (set! (-> a0-2 param 0) + (the float (+ (-> (the-as art-joint-anim (-> self draw art-group data 10)) data 0 length) -1)) + ) + (set! (-> a0-2 param 1) f30-0) + (set! (-> a0-2 frame-num) 0.0) + (joint-control-channel-group! a0-2 (the-as art-joint-anim (-> self draw art-group data 10)) num-func-seek!) + ) + (until (ja-done? 0) + (suspend) + (let ((a0-3 (-> self skel root-channel 0))) + (set! (-> a0-3 param 0) (the float (+ (-> a0-3 frame-group data 0 length) -1))) + (set! (-> a0-3 param 1) f30-0) + (joint-control-channel-group-eval! a0-3 (the-as art-joint-anim #f) num-func-seek!) + ) + ) + ) + (go-virtual nav-enemy-chase) + (none) + ) + :post + (the-as (function none :behavior lightning-mole) nav-enemy-simple-post) + ) + +(defstate nav-enemy-stop-chase (lightning-mole) + :virtual #t + :code + lightning-mole-run-code + :post + (the-as (function none :behavior lightning-mole) fleeing-nav-enemy-chase-post) + ) + +(defstate nav-enemy-chase (lightning-mole) + :virtual #t + :enter + (behavior () + (set! (-> self speed-adjust) 1.0) + (set! (-> self run-blend-interp) 0.0) + (vector-! (-> self saved-travel) (-> self collide-info trans) (target-pos 0)) + ((-> (method-of-type fleeing-nav-enemy nav-enemy-chase) enter)) + (none) + ) + :trans + (behavior () + (let ((s3-0 (new 'stack-no-clear 'vector)) + (s4-0 (new 'stack-no-clear 'vector)) + (gp-0 (new 'stack-no-clear 'vector)) + ) + 0.0 + 0.0 + (let ((f30-0 (vector-vector-distance (-> self collide-info trans) (target-pos 0)))) + 0.0 + 0.0 + (let ((s5-1 (new 'stack-no-clear 'vector))) + (vector-! s3-0 *lightning-mole-hole* (-> self collide-info trans)) + (vector-! s4-0 (-> self collide-info trans) (target-pos 0)) + (vector-! gp-0 *lightning-mole-hole* (target-pos 0)) + (let ((f26-0 (vector-normalize-ret-len! s3-0 1.0)) + (f28-0 (vector-normalize-ret-len! s4-0 1.0)) + ) + (vector-normalize! gp-0 1.0) + (set! (-> s5-1 quad) (-> *camera* tgt-face-mat vector 2 quad)) + (set! (-> s5-1 y) 0.0) + (vector-normalize! s5-1 1.0) + (let ((f24-0 (vector-dot s5-1 s4-0))) + (when (< f26-0 61440.0) + (let ((a1-7 (new 'stack-no-clear 'event-message-block))) + (set! (-> a1-7 from) self) + (set! (-> a1-7 num-params) 0) + (set! (-> a1-7 message) 'hide) + (let ((t9-8 send-event-function) + (v1-10 (-> self alt-actor)) + ) + (t9-8 + (if v1-10 + (-> v1-10 extra process) + ) + a1-7 + ) + ) + ) + ) + (if (and (< 40960.0 f26-0) + (< f26-0 81920.0) + (< f30-0 204800.0) + (< (+ 20480.0 f26-0) f28-0) + (< (cos 7281.778) (vector-dot s5-1 gp-0)) + (< (cos 7281.778) f24-0) + ) + (go lightning-mole-head-for-hole) + ) + ) + ) + ) + ) + ) + ((-> (method-of-type fleeing-nav-enemy nav-enemy-chase) trans)) + (none) + ) + :code + lightning-mole-run-code + :post + (the-as (function none :behavior lightning-mole) fleeing-nav-enemy-chase-post) + ) + +(defmethod dummy-43 lightning-mole ((obj lightning-mole) (arg0 process) (arg1 event-message-block)) + (send-event arg0 'get-attack-count 1) + (when (!= (-> obj state) lightning-mole-yelp) + (send-event arg0 'jump 32768.0 32768.0) + (go lightning-mole-yelp) + ) + (the-as object #t) + ) + +(defmethod dummy-44 lightning-mole ((obj lightning-mole) (arg0 process) (arg1 event-message-block)) + (when (!= (-> obj state) lightning-mole-yelp) + (send-event arg0 'jump 32768.0 32768.0) + (go lightning-mole-yelp) + ) + (the-as object #t) + ) + +(define *lightning-mole-nav-enemy-info* (new 'static 'nav-enemy-info + :idle-anim 5 + :walk-anim 7 + :turn-anim -1 + :notice-anim 6 + :run-anim 7 + :jump-anim -1 + :jump-land-anim -1 + :victory-anim 12 + :taunt-anim -1 + :die-anim -1 + :neck-joint 5 + :player-look-at-joint 5 + :run-travel-speed (meters 30.0) + :run-rotate-speed (degrees 3000.0) + :run-acceleration (meters 1.0) + :run-turn-time (seconds 0.1) + :walk-travel-speed (meters 30.0) + :walk-rotate-speed (degrees 3000.0) + :walk-acceleration (meters 1.0) + :walk-turn-time (seconds 0.1) + :attack-shove-back (meters 3.0) + :attack-shove-up (meters 2.0) + :shadow-size (meters 2.0) + :notice-nav-radius (meters 2.0) + :nav-nearest-y-threshold (meters 10.0) + :notice-distance (meters 35.0) + :stop-chase-distance (meters 45.0) + :frustration-distance (meters 8.0) + :frustration-time #x4b0 + :die-anim-hold-frame 10000000000.0 + :jump-land-anim-end-frame 10000000000.0 + :jump-height-min (meters 1.0) + :jump-height-factor 0.5 + :jump-start-anim-speed 1.0 + :shadow-max-y (meters 1.0) + :shadow-min-y (meters -1.0) + :shadow-locus-dist (meters 150.0) + :use-align #f + :draw-shadow #f + :move-to-ground #t + :hover-if-no-ground #t + :use-momentum #f + :use-flee #f + :use-proximity-notice #f + :use-jump-blocked #f + :use-jump-patrol #f + :gnd-collide-with #x1 + :debug-draw-neck #f + :debug-draw-jump #f + ) + ) + +(defmethod init-from-entity! lightning-mole ((obj lightning-mole) (arg0 entity-actor)) + (let ((s4-0 (new 'process 'collide-shape-moving obj (collide-list-enum hit-by-player)))) + (set! (-> s4-0 dynam) (copy *standard-dynamics* 'process)) + (set! (-> s4-0 reaction) default-collision-reaction) + (set! (-> s4-0 no-reaction) + (the-as (function collide-shape-moving collide-shape-intersect vector vector none) nothing) + ) + (let ((s3-0 (new 'process 'collide-shape-prim-sphere s4-0 (the-as uint 0)))) + (set! (-> s3-0 prim-core collide-as) (collide-kind enemy)) + (set! (-> s3-0 collide-with) (collide-kind target)) + (set! (-> s3-0 prim-core action) (collide-action solid ca-10 ca-11)) + (set! (-> s3-0 prim-core offense) (collide-offense indestructible)) + (set-vector! (-> s3-0 local-sphere) 0.0 10240.0 0.0 10240.0) + (set-root-prim! s4-0 s3-0) + ) + (set! (-> s4-0 nav-radius) (* 0.75 (-> s4-0 root-prim local-sphere w))) + (backup-collide-with-as s4-0) + (set! (-> obj collide-info) s4-0) + ) + (process-drawable-from-entity! obj arg0) + (initialize-skeleton obj *lightning-mole-sg* '()) + (TODO-RENAME-45 obj *lightning-mole-nav-enemy-info*) + (logclear! (-> obj nav flags) (nav-control-flags bit5 bit6 bit7)) + (set! (-> obj draw origin-joint-index) (the-as uint 3)) + (set! (-> obj reaction-time) 15) + (set! (-> obj last-reflection-time) (the-as uint 0)) + (set! (-> obj collide-info pause-adjust-distance) 122880.0) + (set! (-> obj link) (new 'process 'actor-link-info obj)) + (set! (-> obj alt-actor) (entity-actor-lookup arg0 'alt-actor 0)) + (set! (-> obj flee-info min-reflect-angle) 10922.667) + (set! (-> obj flee-info max-reflect-angle) 14563.556) + (set! (-> obj flee-info max-boundary-deflection) 18204.445) + (set! (-> obj flee-info deflection-min-dist) 20480.0) + (set! (-> obj flee-info deflection-max-dist) 49152.0) + (set! (-> obj flee-info reflection-time) 225) + (set! (-> obj flee-info travel-rotate-speed) 1820.4445) + (set! (-> obj flee-info blend_interp_angle) 2184.5334) + (set! (-> obj flee-info min-speed-adjust) 0.8) + (set! (-> obj flee-info max-speed-adjust) 1.2) + (set! (-> obj flee-info speed-adjust-center) 40960.0) + (set! (-> obj flee-info speed-adjust-range) 20480.0) + (set! (-> obj flee-info abort-notice-distance) 49152.0) + (set! (-> obj flee-info min-notice-dist) 61440.0) + (set! (-> obj flee-info max-notice-dist) 143360.0) + (set! (-> obj flee-info min-stop-chase-dist) 40960.0) + (set! (-> obj flee-info max-stop-chase-dist) 184320.0) + (set! (-> obj flee-info max-flee-rotation) 364.0889) + (cond + ((and (-> obj entity) (logtest? (-> obj entity extra perm status) (entity-perm-status complete))) + (go lightning-mole-gone) + ) + ((task-closed? (-> obj entity extra perm task) (task-status need-introduction)) + (go (method-of-object obj nav-enemy-idle)) + ) + (else + (go lightning-mole-hiding) + ) + ) + (none) + ) + +(defpartgroup group-peeper + :id 456 + :duration 5 + :bounds (static-bspherem 0 0 0 15) + :parts + ((sp-item 1768) (sp-item 1769 :period 120 :length 30) (sp-item 1770 :period 120 :length 60)) + ) + +(defpart 1768 + :init-specs + ((sp-tex spt-texture (new 'static 'texture-id :page #x2)) + (sp-flt spt-num 0.25) + (sp-rnd-flt spt-x (meters -2) (meters 4) 1.0) + (sp-flt spt-y (meters -2)) + (sp-rnd-flt spt-z (meters -2) (meters 4) 1.0) + (sp-rnd-flt spt-scale-x (meters 4) (meters 2) 1.0) + (sp-rnd-flt spt-rot-z (degrees 0.0) (degrees 360.0) 1.0) + (sp-copy-from-other spt-scale-y -4) + (sp-rnd-flt spt-r 128.0 64.0 1.0) + (sp-rnd-flt spt-g 96.0 32.0 1.0) + (sp-rnd-flt spt-b 64.0 16.0 1.0) + (sp-rnd-flt spt-a 32.0 32.0 1.0) + (sp-rnd-flt spt-vel-x (meters -0.006666667) (meters 0.013333334) 1.0) + (sp-rnd-flt spt-vel-y (meters 0.04) (meters 0.026666667) 1.0) + (sp-rnd-flt spt-vel-z (meters -0.006666667) (meters 0.013333334) 1.0) + (sp-rnd-flt spt-rotvel-z (degrees -1.2) (degrees 2.4) 1.0) + (sp-flt spt-fade-a -0.21333334) + (sp-flt spt-accel-y -2.7306666) + (sp-flt spt-friction 0.97) + (sp-int spt-timer 450) + (sp-cpuinfo-flags bit2 bit12) + ) + ) + +(defpart 1769 + :init-specs + ((sp-tex spt-texture (new 'static 'texture-id :page #x2)) + (sp-flt spt-num 0.5) + (sp-rnd-flt spt-x (meters -2) (meters 4) 1.0) + (sp-flt spt-y (meters -2)) + (sp-rnd-flt spt-z (meters -2) (meters 4) 1.0) + (sp-rnd-flt spt-scale-x (meters 4) (meters 2) 1.0) + (sp-rnd-flt spt-rot-z (degrees 0.0) (degrees 360.0) 1.0) + (sp-copy-from-other spt-scale-y -4) + (sp-rnd-flt spt-r 128.0 64.0 1.0) + (sp-rnd-flt spt-g 96.0 32.0 1.0) + (sp-rnd-flt spt-b 64.0 16.0 1.0) + (sp-rnd-flt spt-a 32.0 32.0 1.0) + (sp-rnd-flt spt-vel-x (meters -0.006666667) (meters 0.013333334) 1.0) + (sp-rnd-flt spt-vel-y (meters 0.04) (meters 0.026666667) 1.0) + (sp-rnd-flt spt-vel-z (meters -0.006666667) (meters 0.013333334) 1.0) + (sp-rnd-flt spt-rotvel-z (degrees -1.2) (degrees 2.4) 1.0) + (sp-flt spt-fade-a -0.21333334) + (sp-flt spt-friction 0.98) + (sp-int spt-timer 450) + (sp-cpuinfo-flags bit2 bit12) + ) + ) + +(defpart 1770 + :init-specs + ((sp-tex spt-texture (new 'static 'texture-id :index #x1d :page #x2)) + (sp-flt spt-num 5.0) + (sp-rnd-flt spt-x (meters -1) (meters 2) 1.0) + (sp-flt spt-y (meters 0)) + (sp-rnd-flt spt-z (meters -1) (meters 2) 1.0) + (sp-rnd-flt spt-scale-x (meters 0.25) (meters 0.1) 1.0) + (sp-rnd-flt spt-rot-z (degrees 0.0) (degrees 360.0) 1.0) + (sp-copy-from-other spt-scale-y -4) + (sp-rnd-flt spt-r 128.0 64.0 1.0) + (sp-rnd-flt spt-g 96.0 32.0 1.0) + (sp-rnd-flt spt-b 64.0 16.0 1.0) + (sp-flt spt-a 128.0) + (sp-rnd-flt spt-vel-y (meters 0.06666667) (meters 0.053333335) 1.0) + (sp-rnd-flt spt-rotvel-z (degrees -1.2) (degrees 2.4) 1.0) + (sp-flt spt-accel-y -10.922667) + (sp-int spt-timer 450) + (sp-cpuinfo-flags bit2 bit12) + (sp-flt spt-userdata 106496.0) + (sp-func spt-func 'check-drop-level-rolling-dirt) + (sp-rnd-flt spt-conerot-x (degrees 0.0) (degrees 20.0) 1.0) + (sp-rnd-flt spt-conerot-y (degrees 180.0) (degrees 180.0) 1.0) + (sp-rnd-flt spt-conerot-radius (meters 0) (meters 2) 1.0) + ) + ) + +(defpart 1771 + :init-specs + ((sp-tex spt-texture (new 'static 'texture-id :index #x1d :page #x2)) + (sp-rnd-flt spt-num 1.0 1.0 1.0) + (sp-flt spt-y (meters 0)) + (sp-rnd-flt spt-scale-x (meters 0.15) (meters 0.05) 1.0) + (sp-rnd-flt spt-rot-z (degrees 0.0) (degrees 360.0) 1.0) + (sp-copy-from-other spt-scale-y -4) + (sp-rnd-flt spt-r 128.0 64.0 1.0) + (sp-rnd-flt spt-g 96.0 32.0 1.0) + (sp-rnd-flt spt-b 64.0 16.0 1.0) + (sp-flt spt-a 128.0) + (sp-rnd-flt spt-vel-y (meters 0.033333335) (meters 0.016666668) 1.0) + (sp-rnd-flt spt-rotvel-z (degrees -1.2) (degrees 2.4) 1.0) + (sp-flt spt-accel-y -10.922667) + (sp-int spt-timer 300) + (sp-cpuinfo-flags bit2 bit12) + (sp-flt spt-userdata 106496.0) + (sp-func spt-func 'check-drop-level-rolling-dirt-finish) + (sp-rnd-flt spt-conerot-x (degrees 0.0) (degrees 30.0) 1.0) + (sp-rnd-flt spt-conerot-y (degrees 0.0) (degrees 360.0) 1.0) + (sp-flt spt-conerot-radius (meters 0)) + ) + ) + +(defpart 1772 + :init-specs + ((sp-tex spt-texture (new 'static 'texture-id :index #x1d :page #x2)) + (sp-flt spt-num 1.0) + (sp-rnd-flt spt-scale-x (meters 0.15) (meters 0.05) 1.0) + (sp-rnd-flt spt-rot-z (degrees 0.0) (degrees 360.0) 1.0) + (sp-copy-from-other spt-scale-y -4) + (sp-rnd-flt spt-r 128.0 64.0 1.0) + (sp-rnd-flt spt-g 96.0 32.0 1.0) + (sp-rnd-flt spt-b 64.0 16.0 1.0) + (sp-rnd-flt spt-a 64.0 64.0 1.0) + (sp-rnd-flt spt-vel-y (meters 0) (meters 0.013333334) 1.0) + (sp-rnd-flt spt-rotvel-z (degrees -1.2) (degrees 2.4) 1.0) + (sp-flt spt-fade-a -0.14222223) + (sp-flt spt-friction 0.9) + (sp-int spt-timer 900) + (sp-cpuinfo-flags bit2 bit12) + (sp-flt spt-conerot-x (degrees 90.0)) + (sp-rnd-flt spt-conerot-y (degrees 0.0) (degrees 360.0) 1.0) + ) + ) + +(defun check-drop-level-rolling-dirt ((arg0 sparticle-system) (arg1 sparticle-cpuinfo) (arg2 vector)) + (when (< (-> arg2 y) (-> arg1 user-float)) + (let ((gp-0 (new 'stack-no-clear 'vector))) + (sp-kill-particle arg0 arg1) + (set-vector! gp-0 (-> arg2 x) (-> arg1 user-float) (-> arg2 z) 1.0) + (sp-launch-particles-var + *sp-particle-system-2d* + (-> *part-id-table* 1771) + gp-0 + (the-as sparticle-launch-state #f) + (the-as sparticle-launch-control #f) + 1.0 + ) + ) + ) + (none) + ) + +(defun check-drop-level-rolling-dirt-finish ((arg0 sparticle-system) (arg1 sparticle-cpuinfo) (arg2 vector)) + (when (< (-> arg2 y) (-> arg1 user-float)) + (let ((gp-0 (new 'stack-no-clear 'vector))) + (sp-kill-particle arg0 arg1) + (let* ((v1-1 (/ (the-as int (rand-uint31-gen *random-generator*)) 256)) + (v1-2 (the-as number (logior #x3f800000 v1-1))) + ) + (if (< (+ -1.0 (the-as float v1-2)) 0.05) + (sound-play-by-name (static-sound-name "land-grass") (new-sound-id) 1024 0 0 1 #t) + ) + ) + (set-vector! gp-0 (-> arg2 x) (-> arg1 user-float) (-> arg2 z) 1.0) + (sp-launch-particles-var + *sp-particle-system-2d* + (-> *part-id-table* 1772) + gp-0 + (the-as sparticle-launch-state #f) + (the-as sparticle-launch-control #f) + 1.0 + ) + ) + ) + (none) + ) + +(deftype peeper (process-drawable) + () + :heap-base #x40 + :method-count-assert 20 + :size-assert #xb0 + :flag-assert #x14004000b0 + (:states + peeper-down + peeper-hide + peeper-up + peeper-wait + ) + ) + + +(defstate peeper-wait (peeper) + :event + (behavior ((arg0 process) (arg1 int) (arg2 symbol) (arg3 event-message-block)) + (let ((v1-0 arg2)) + (the-as object (when (= v1-0 'hide) + (let ((v0-0 (-> *display* base-frame-counter))) + (set! (-> self state-time) v0-0) + v0-0 + ) + ) + ) + ) + ) + :enter + (behavior () + (if (nonzero? (-> self sound)) + (stop! (-> self sound)) + ) + (set! (-> self state-time) (-> *display* base-frame-counter)) + (none) + ) + :trans + (behavior () + (if (and (>= (- (-> *display* base-frame-counter) (-> self state-time)) 300) + (not (and *target* (>= 81920.0 (vector-vector-xz-distance (-> self root trans) (-> *target* control trans))))) + ) + (go peeper-up) + ) + (none) + ) + :code + (behavior () + (logior! (-> self draw status) (draw-status drwf01)) + (while #t + (suspend) + ) + (none) + ) + :post + (the-as (function none :behavior peeper) ja-post) + ) + +(defstate peeper-hide (peeper) + :code + (behavior () + (if (nonzero? (-> self sound)) + (stop! (-> self sound)) + ) + (let ((a0-1 (-> self skel root-channel 0))) + (set! (-> a0-1 param 0) (the float (+ (-> a0-1 frame-group data 0 length) -1))) + (set! (-> a0-1 param 1) 2.0) + (joint-control-channel-group! a0-1 (the-as art-joint-anim #f) num-func-seek!) + ) + (while (not (ja-done? 0)) + (suspend) + (ja-eval) + ) + (logior! (-> self draw status) (draw-status drwf01)) + (go peeper-wait) + (none) + ) + :post + (the-as (function none :behavior peeper) ja-post) + ) + +(defstate peeper-down (peeper) + :event + (behavior ((arg0 process) (arg1 int) (arg2 symbol) (arg3 event-message-block)) + (case arg2 + (('hide) + (go peeper-wait) + ) + ) + ) + :trans + (behavior () + (if (and *target* (>= 61440.0 (vector-vector-xz-distance (-> self root trans) (-> *target* control trans)))) + (go peeper-wait) + ) + (none) + ) + :code + (behavior () + (logior! (-> self draw status) (draw-status drwf01)) + (set! (-> self state-time) (-> *display* base-frame-counter)) + (until (>= (- (-> *display* base-frame-counter) (-> self state-time)) 300) + (suspend) + ) + (let* ((f30-0 2.0) + (v1-10 (/ (the-as int (rand-uint31-gen *random-generator*)) 256)) + (v1-11 (the-as number (logior #x3f800000 v1-10))) + ) + (countdown (gp-0 (+ (the int (* f30-0 (+ -1.0 (the-as float v1-11)))) 1)) + (set! (-> self state-time) (-> *display* base-frame-counter)) + (until (>= (- (-> *display* base-frame-counter) (-> self state-time)) 1500) + (if (nonzero? (-> self sound)) + (update! (-> self sound)) + ) + (spawn (-> self part) (-> self root trans)) + (suspend) + ) + (set! (-> self state-time) (-> *display* base-frame-counter)) + (if (nonzero? (-> self sound)) + (stop! (-> self sound)) + ) + (until (>= (- (-> *display* base-frame-counter) (-> self state-time)) 900) + (suspend) + ) + ) + ) + (go peeper-up) + (none) + ) + :post + (the-as (function none :behavior peeper) ja-post) + ) + +(defstate peeper-up (peeper) + :event + (behavior ((arg0 process) (arg1 int) (arg2 symbol) (arg3 event-message-block)) + (case arg2 + (('hide) + (go peeper-hide) + ) + ) + ) + :enter + (behavior () + (if (nonzero? (-> self sound)) + (stop! (-> self sound)) + ) + (logclear! (-> self draw status) (draw-status drwf01)) + (none) + ) + :trans + (behavior () + (if (and *target* (>= 61440.0 (vector-vector-xz-distance (-> self root trans) (-> *target* control trans)))) + (go peeper-hide) + ) + (none) + ) + :code + (behavior () + (while #t + (let ((a0-0 (-> self skel root-channel 0))) + (set! (-> a0-0 frame-group) (the-as art-joint-anim (-> self draw art-group data 13))) + (set! (-> a0-0 param 0) + (the float (+ (-> (the-as art-joint-anim (-> self draw art-group data 13)) data 0 length) -1)) + ) + (set! (-> a0-0 param 1) 1.0) + (set! (-> a0-0 frame-num) 0.0) + (joint-control-channel-group! a0-0 (the-as art-joint-anim (-> self draw art-group data 13)) num-func-seek!) + ) + (until (ja-done? 0) + (suspend) + (let ((a0-1 (-> self skel root-channel 0))) + (set! (-> a0-1 param 0) (the float (+ (-> a0-1 frame-group data 0 length) -1))) + (set! (-> a0-1 param 1) 1.0) + (joint-control-channel-group-eval! a0-1 (the-as art-joint-anim #f) num-func-seek!) + ) + ) + (go peeper-down) + ) + (none) + ) + :post + (the-as (function none :behavior peeper) ja-post) + ) + +(defmethod init-from-entity! peeper ((obj peeper) (arg0 entity-actor)) + (set! (-> obj root) (new 'process 'trsqv)) + (process-drawable-from-entity! obj arg0) + (initialize-skeleton obj *lightning-mole-sg* '()) + (set! (-> obj part) (create-launch-control (-> *part-group-id-table* 456) obj)) + (set! (-> obj sound) (new 'process 'ambient-sound arg0 (-> obj root trans))) + (go peeper-up) + (none) + ) + + + + diff --git a/goal_src/levels/sunken/bully.gc b/goal_src/levels/sunken/bully.gc index 33ac18f157..d6fdc50e9d 100644 --- a/goal_src/levels/sunken/bully.gc +++ b/goal_src/levels/sunken/bully.gc @@ -457,7 +457,7 @@ 1.0 ) (let ((s5-1 #f)) - (dummy-28 (-> obj nav) 2560) + (TODO-RENAME-28 (-> obj nav) (collide-kind wall-object ground-object)) (let ((v1-4 (-> obj nav travel))) (.lvf vf1 (&-> (-> obj root-override transv) quad)) (let ((f0-8 (-> *display* seconds-per-frame))) @@ -749,7 +749,7 @@ #f #f ) - (dummy-27 (-> self nav)) + (TODO-RENAME-27 (-> self nav)) (none) ) :code diff --git a/goal_src/levels/sunken/double-lurker.gc b/goal_src/levels/sunken/double-lurker.gc index 531a2cff3f..8d24439ec8 100644 --- a/goal_src/levels/sunken/double-lurker.gc +++ b/goal_src/levels/sunken/double-lurker.gc @@ -363,7 +363,7 @@ ) (logior! (-> self collide-info nav-flags) 1) (set! (-> self collide-info nav-flags) (logand -3 (-> self collide-info nav-flags))) - (dummy-27 (-> self nav)) + (TODO-RENAME-27 (-> self nav)) (go double-lurker-top-resume) (none) ) @@ -441,7 +441,7 @@ (defmethod dummy-51 double-lurker-top ((obj double-lurker-top)) (restore-collide-with-as (-> obj collide-info)) (logior! (-> obj collide-info nav-flags) 1) - (the-as object (dummy-27 (-> obj nav))) + (the-as object (TODO-RENAME-27 (-> obj nav))) ) (defmethod initialize-collision double-lurker-top ((obj double-lurker-top)) @@ -815,7 +815,75 @@ (.svf (&-> v1-7 quad) vf1) ) (let ((gp-0 #f)) - (dummy-28 (-> self nav) -1) + (TODO-RENAME-28 + (-> self nav) + (collide-kind + background + cak-1 + cak-2 + cak-3 + target + water + powerup + crate + enemy + wall-object + projectile + ground-object + target-attack + mother-spider + cak-14 + blue-eco-suck + unknown-16 + unknown-17 + unknown-18 + unknown-19 + unknown-20 + unknown-21 + unknown-22 + unknown-23 + unknown-24 + unknown-25 + unknown-26 + unknown-27 + unknown-28 + unknown-29 + unknown-30 + unknown-31 + unknown-32 + unknown-33 + unknown-34 + unknown-35 + unknown-36 + unknown-37 + unknown-38 + unknown-39 + unknown-40 + unknown-41 + unknown-42 + unknown-43 + unknown-44 + unknown-45 + unknown-46 + unknown-47 + unknown-48 + unknown-49 + unknown-50 + unknown-51 + unknown-52 + unknown-53 + unknown-54 + unknown-55 + unknown-56 + unknown-57 + unknown-58 + unknown-59 + unknown-60 + unknown-61 + unknown-62 + unknown-63 + ) + ) (let ((a2-1 (new 'stack-no-clear 'check-vector-collision-with-nav-spheres-info))) (if (>= (dummy-23 (-> self nav) (-> self nav travel) a2-1) 0.0) (set! gp-0 #t) @@ -846,7 +914,7 @@ (-> self nav-info hover-if-no-ground) #f ) - (dummy-27 (-> self nav)) + (TODO-RENAME-27 (-> self nav)) (none) ) ) @@ -878,7 +946,73 @@ ) (defmethod dummy-52 double-lurker ((obj double-lurker) (arg0 vector)) - (dummy-28 (-> obj nav) -1) + (TODO-RENAME-28 (-> obj nav) (collide-kind + background + cak-1 + cak-2 + cak-3 + target + water + powerup + crate + enemy + wall-object + projectile + ground-object + target-attack + mother-spider + cak-14 + blue-eco-suck + unknown-16 + unknown-17 + unknown-18 + unknown-19 + unknown-20 + unknown-21 + unknown-22 + unknown-23 + unknown-24 + unknown-25 + unknown-26 + unknown-27 + unknown-28 + unknown-29 + unknown-30 + unknown-31 + unknown-32 + unknown-33 + unknown-34 + unknown-35 + unknown-36 + unknown-37 + unknown-38 + unknown-39 + unknown-40 + unknown-41 + unknown-42 + unknown-43 + unknown-44 + unknown-45 + unknown-46 + unknown-47 + unknown-48 + unknown-49 + unknown-50 + unknown-51 + unknown-52 + unknown-53 + unknown-54 + unknown-55 + unknown-56 + unknown-57 + unknown-58 + unknown-59 + unknown-60 + unknown-61 + unknown-62 + unknown-63 + ) + ) (let ((a1-2 (new 'stack-no-clear 'vector))) (vector-float*! a1-2 (-> obj hit-from-dir) 22937.602) (vector+! a1-2 a1-2 (-> obj collide-info trans)) @@ -994,7 +1128,75 @@ (.svf (&-> v1-7 quad) vf1) ) (let ((gp-0 #f)) - (dummy-28 (-> self nav) -1) + (TODO-RENAME-28 + (-> self nav) + (collide-kind + background + cak-1 + cak-2 + cak-3 + target + water + powerup + crate + enemy + wall-object + projectile + ground-object + target-attack + mother-spider + cak-14 + blue-eco-suck + unknown-16 + unknown-17 + unknown-18 + unknown-19 + unknown-20 + unknown-21 + unknown-22 + unknown-23 + unknown-24 + unknown-25 + unknown-26 + unknown-27 + unknown-28 + unknown-29 + unknown-30 + unknown-31 + unknown-32 + unknown-33 + unknown-34 + unknown-35 + unknown-36 + unknown-37 + unknown-38 + unknown-39 + unknown-40 + unknown-41 + unknown-42 + unknown-43 + unknown-44 + unknown-45 + unknown-46 + unknown-47 + unknown-48 + unknown-49 + unknown-50 + unknown-51 + unknown-52 + unknown-53 + unknown-54 + unknown-55 + unknown-56 + unknown-57 + unknown-58 + unknown-59 + unknown-60 + unknown-61 + unknown-62 + unknown-63 + ) + ) (let ((a2-1 (new 'stack-no-clear 'check-vector-collision-with-nav-spheres-info))) (if (>= (dummy-23 (-> self nav) (-> self nav travel) a2-1) 0.0) (set! gp-0 #t) @@ -1025,7 +1227,7 @@ (-> self nav-info hover-if-no-ground) #f ) - (dummy-27 (-> self nav)) + (TODO-RENAME-27 (-> self nav)) (none) ) ) diff --git a/goal_src/levels/sunken/puffer.gc b/goal_src/levels/sunken/puffer.gc index 24f83dda3a..8516934594 100644 --- a/goal_src/levels/sunken/puffer.gc +++ b/goal_src/levels/sunken/puffer.gc @@ -208,7 +208,7 @@ ) (defmethod dummy-24 puffer ((obj puffer) (arg0 vector)) - (and (dummy-25 (-> obj nav) arg0 11468.8) + (and (is-in-mesh? (-> obj nav) arg0 11468.8) (< (-> arg0 y) (+ (-> obj root-override trans y) (-> obj fact-info-override notice-top))) ) ) @@ -361,8 +361,76 @@ (seek-with-smooth (-> obj travel-speed) 18432.0 (* 2048.0 (-> *display* seconds-per-frame)) 0.125 40.96) ) ) - (dummy-27 (-> obj nav)) - (dummy-28 (-> obj nav) -1) + (TODO-RENAME-27 (-> obj nav)) + (TODO-RENAME-28 + (-> obj nav) + (collide-kind + background + cak-1 + cak-2 + cak-3 + target + water + powerup + crate + enemy + wall-object + projectile + ground-object + target-attack + mother-spider + cak-14 + blue-eco-suck + unknown-16 + unknown-17 + unknown-18 + unknown-19 + unknown-20 + unknown-21 + unknown-22 + unknown-23 + unknown-24 + unknown-25 + unknown-26 + unknown-27 + unknown-28 + unknown-29 + unknown-30 + unknown-31 + unknown-32 + unknown-33 + unknown-34 + unknown-35 + unknown-36 + unknown-37 + unknown-38 + unknown-39 + unknown-40 + unknown-41 + unknown-42 + unknown-43 + unknown-44 + unknown-45 + unknown-46 + unknown-47 + unknown-48 + unknown-49 + unknown-50 + unknown-51 + unknown-52 + unknown-53 + unknown-54 + unknown-55 + unknown-56 + unknown-57 + unknown-58 + unknown-59 + unknown-60 + unknown-61 + unknown-62 + unknown-63 + ) + ) (dummy-13 (-> obj nav) arg0 (-> obj root-override transv)) (let ((f30-0 (* (vector-xz-length (-> obj nav travel)) (-> *display* frames-per-second)))) (let ((f0-11 (atan (-> obj nav travel x) (-> obj nav travel z))) @@ -1139,7 +1207,7 @@ (set! (-> obj give-up-dist) (+ 20480.0 (-> obj notice-dist))) (set! (-> obj nav) (new 'process 'nav-control (-> obj root-override) 16 40960.0)) (logior! (-> obj nav flags) (nav-control-flags display-marks bit3 bit5 bit6 bit7)) - (dummy-26 (-> obj nav)) + (TODO-RENAME-26 (-> obj nav)) (set! (-> obj path) (new 'process 'path-control obj 'path 0.0)) (logior! (-> obj path flags) (path-control-flag display draw-line draw-point draw-text)) (set! (-> obj fact-info-override) diff --git a/goal_src/levels/swamp/swamp-rat-nest.gc b/goal_src/levels/swamp/swamp-rat-nest.gc index be81bcf0da..1fcfe0c6f6 100644 --- a/goal_src/levels/swamp/swamp-rat-nest.gc +++ b/goal_src/levels/swamp/swamp-rat-nest.gc @@ -913,7 +913,7 @@ ) (set! (-> self nav) (new 'process 'nav-control (-> self root-override) 16 40960.0)) (logior! (-> self nav flags) (nav-control-flags display-marks bit3 bit5 bit6 bit7)) - (set-current-poly! (-> self nav) (TODO-RENAME-18 (-> self nav) (-> self root-override trans))) + (set-current-poly! (-> self nav) (find-poly (-> self nav) (-> self root-override trans))) (+! (-> self parent-process 0 hit-points) 3) (dummy-21 self) (when (zero? (-> self skel)) diff --git a/goalc/compiler/Compiler.h b/goalc/compiler/Compiler.h index 074e49ed65..f10acd9016 100644 --- a/goalc/compiler/Compiler.h +++ b/goalc/compiler/Compiler.h @@ -436,6 +436,8 @@ class Compiler { Val* compile_asm_load_sym(const goos::Object& form, const goos::Object& rest, Env* env); Val* compile_asm_jr(const goos::Object& form, const goos::Object& rest, Env* env); Val* compile_asm_mov(const goos::Object& form, const goos::Object& rest, Env* env); + Val* compile_asm_movn(const goos::Object& form, const goos::Object& rest, Env* env); + Val* compile_asm_slt(const goos::Object& form, const goos::Object& rest, Env* env); // Vector Float Operations Val* compile_asm_lvf(const goos::Object& form, const goos::Object& rest, Env* env); diff --git a/scripts/update-goal-src.py b/scripts/update-goal-src.py index 1f11ee8f7d..87ef871069 100644 --- a/scripts/update-goal-src.py +++ b/scripts/update-goal-src.py @@ -37,7 +37,9 @@ files_with_modifications = [ "sage-finalboss-FIN", "progress", "entity", - "ogreboss" + "ogreboss", + "navigate", + "nav-enemy" ] for file in files: diff --git a/test/decompiler/reference/decompiler-macros.gc b/test/decompiler/reference/decompiler-macros.gc index e1424e041e..e2742a75da 100644 --- a/test/decompiler/reference/decompiler-macros.gc +++ b/test/decompiler/reference/decompiler-macros.gc @@ -814,6 +814,25 @@ ) ) +(defmacro move-if-not-zero (result value check original) + `(if (!= ,check 0) + (set! ,result (the-as int ,value)) + (set! ,result (the-as int ,original)) + ) + ) + +(defmacro shift-arith-right-32 (result in sa) + `(set! ,result (sext32 (sar (logand #xffffffff (the-as int ,in)) ,sa))) + ) + +(defmacro set-on-less-than (dest src1 src2) + "dest = src1 < src2 ? 1 : 0 -- Compare as Signed Integers" + `(if (< (the int ,src1) (the int ,src2)) + (set! ,dest 1) + (set! ,dest 0) + ) + ) + (defmacro send-event (proc msg &rest params) "Send an event to a process. This should be used over send-event-function" @@ -902,4 +921,4 @@ ;; Copies the contents of a gpr to a cop0 (system control) register (fake-asm .mtc0 dest src) (fake-asm .mtpc dest src) -(fake-asm .mfpc dest src) \ No newline at end of file +(fake-asm .mfpc dest src) diff --git a/test/decompiler/reference/engine/anim/joint-h_REF.gc b/test/decompiler/reference/engine/anim/joint-h_REF.gc index 1d5a937d43..2ec044a1e9 100644 --- a/test/decompiler/reference/engine/anim/joint-h_REF.gc +++ b/test/decompiler/reference/engine/anim/joint-h_REF.gc @@ -20,7 +20,7 @@ :size-assert #x30 :flag-assert #xa00000030 (:methods - (dummy-9 (_type_) _type_ 9) + (debug-print-frames (_type_) _type_ 9) ) ) @@ -70,7 +70,7 @@ (:methods (new (symbol type int) _type_ 0) (dummy-9 (_type_) float 9) - (dummy-10 (_type_ symbol) int 10) + (debug-print-channels (_type_ symbol) int 10) ) ) diff --git a/test/decompiler/reference/engine/anim/joint_REF.gc b/test/decompiler/reference/engine/anim/joint_REF.gc index b007290de8..c44b416a12 100644 --- a/test/decompiler/reference/engine/anim/joint_REF.gc +++ b/test/decompiler/reference/engine/anim/joint_REF.gc @@ -175,7 +175,7 @@ ) ;; definition for method 9 of type joint-control-channel -(defmethod dummy-9 joint-control-channel ((obj joint-control-channel)) +(defmethod debug-print-frames joint-control-channel ((obj joint-control-channel)) (let ((s5-0 (-> obj frame-group)) (f30-0 (-> obj frame-num)) ) @@ -188,7 +188,7 @@ ) ;; definition for method 10 of type joint-control -(defmethod dummy-10 joint-control ((obj joint-control) (arg0 symbol)) +(defmethod debug-print-channels joint-control ((obj joint-control) (arg0 symbol)) (dotimes (s4-0 (-> obj active-channels)) (let* ((v1-6 (if (and (-> obj channel s4-0 frame-group) (nonzero? (-> obj channel s4-0 frame-group))) (-> obj channel s4-0 frame-group) diff --git a/test/decompiler/reference/engine/collide/main-collide_REF.gc b/test/decompiler/reference/engine/collide/main-collide_REF.gc index 784779e987..445c408522 100644 --- a/test/decompiler/reference/engine/collide/main-collide_REF.gc +++ b/test/decompiler/reference/engine/collide/main-collide_REF.gc @@ -8,7 +8,7 @@ (local-vars (r0-0 int) (r0-1 int) - (r0-2 uint128) + (r0-2 int) (r0-3 int) (v1-1 uint128) (v1-2 uint128) @@ -46,7 +46,7 @@ (.mov r0-1 f31-0) (.por v1-2 a1-2 v1-1) (.mov r0-2 f31-0) - (.ppach v1-3 r0-2 v1-2) + (.ppach v1-3 (the-as uint128 0) v1-2) (.mov r0-3 f31-0) (let ((v1-4 (shl (the-as int v1-3) 16))) (nop!) @@ -60,13 +60,12 @@ ;; Used lq/sq (defun instance-sphere-box-intersect? ((arg0 drawable) (arg1 instance-tie) (arg2 bounding-box4w)) (local-vars - (r0-0 uint128) + (r0-0 int) (r0-1 int) - (r0-2 uint128) + (r0-2 int) (r0-3 int) (r0-4 int) - (r0-5 uint128) - (r0-6 int) + (r0-5 int) (v1-3 uint128) (v1-4 uint128) (v1-5 uint128) @@ -103,19 +102,19 @@ (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 0) (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 0) + (.mov r0-0 f31-0) (.pw.sra t2-2 t2-1 16) - (.mov r0-2 f31-0) - (.pextlh t0-1 t0-0 r0-2) + (.mov r0-1 f31-0) + (.pextlh t0-1 t0-0 0) (.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 0) ) ) ) @@ -166,14 +165,14 @@ (nop!) (.pcgtw a1-2 a2-1 a1-1) ) - (.mov r0-3 f31-0) + (.mov r0-2 f31-0) (.pcgtw v1-3 v1-2 a0-2) ) - (.mov r0-4 f31-0) + (.mov r0-3 f31-0) (.por v1-4 a1-2 v1-3) + (.mov r0-4 f31-0) + (.ppach v1-5 (the-as uint128 0) v1-4) (.mov r0-5 f31-0) - (.ppach v1-5 r0-5 v1-4) - (.mov r0-6 f31-0) (let ((v1-6 (shl (the-as int v1-5) 16))) (nop!) (zero? v1-6) @@ -184,7 +183,7 @@ ;; definition for function instance-tfragment-add-debug-sphere ;; Used lq/sq (defun instance-tfragment-add-debug-sphere ((arg0 drawable) (arg1 instance-tie)) - (local-vars (r0-0 uint128) (v1-1 uint128) (v1-2 uint128) (a3-0 float)) + (local-vars (v1-1 uint128) (v1-2 uint128) (a3-0 float)) (rlet ((vf0 :class vf) (vf10 :class vf) (vf11 :class vf) @@ -194,7 +193,7 @@ (init-vf0-vector) (nop!) (let ((v1-0 (the-as uint128 (-> arg1 origin vector4h 3 long)))) - (.pextlh v1-1 v1-0 r0-0) + (.pextlh v1-1 v1-0 0) ) (.lvf vf9 (&-> arg0 bsphere quad)) (.pw.sra v1-2 v1-1 10) @@ -217,3 +216,7 @@ ) ) ) + + + + diff --git a/test/decompiler/reference/engine/debug/anim-tester_REF.gc b/test/decompiler/reference/engine/debug/anim-tester_REF.gc index 0a19cfdbf8..0d599429ec 100644 --- a/test/decompiler/reference/engine/debug/anim-tester_REF.gc +++ b/test/decompiler/reference/engine/debug/anim-tester_REF.gc @@ -944,7 +944,7 @@ (ja-post) (when (logtest? (-> self flags) (anim-tester-flags fanimt4)) (draw-joint-spheres self) - (dummy-10 (-> self skel) (the-as symbol *stdcon*)) + (debug-print-channels (-> self skel) (the-as symbol *stdcon*)) ) ) (none) @@ -2497,7 +2497,7 @@ ) (logclear! (-> self flags) (anim-tester-flags fanimt1)) (when (!= *master-mode* 'menu) - (dummy-10 (-> self skel) (the-as symbol *stdcon*)) + (debug-print-channels (-> self skel) (the-as symbol *stdcon*)) (add-debug-x #t (bucket-id debug-draw1) diff --git a/test/decompiler/reference/engine/debug/debug_REF.gc b/test/decompiler/reference/engine/debug/debug_REF.gc index 68d2ad74e7..c1eb3f31eb 100644 --- a/test/decompiler/reference/engine/debug/debug_REF.gc +++ b/test/decompiler/reference/engine/debug/debug_REF.gc @@ -395,9 +395,9 @@ (set! (-> arg2 w) 1.0) (set! (-> arg3 w) 1.0) (set! (-> arg4 w) 1.0) - (when (and (transform-point-qword! (the-as vector4w (-> s5-0 quad)) arg2) - (transform-point-qword! (the-as vector4w (&-> s5-0 quad 1)) arg3) - (transform-point-qword! (the-as vector4w (&-> s5-0 quad 2)) arg4) + (when (and (transform-point-qword! (the-as vector4w (-> s5-0 vector)) arg2) + (transform-point-qword! (-> s5-0 vector 1) arg3) + (transform-point-qword! (-> s5-0 vector 2) arg4) ) (let* ((v1-9 (-> *display* frames (-> *display* on-screen) frame debug-buf)) (a2-1 (-> v1-9 base)) @@ -445,12 +445,12 @@ (let* ((a1-21 v1-9) (a3-5 (the-as (inline-array vector4w-3) (-> a1-21 base))) ) - (set! (-> a3-5 0 quad 0) (-> s4-0 quad 0)) - (set! (-> a3-5 0 quad 1) (-> s5-0 quad 0)) - (set! (-> a3-5 0 quad 2) (-> s4-0 quad 0)) - (set! (-> a3-5 1 quad 0) (-> (&-> s5-0 quad 1) 0)) - (set! (-> a3-5 1 quad 1) (-> s4-0 quad 0)) - (set! (-> a3-5 1 quad 2) (-> (&-> s5-0 quad 2) 0)) + (set! (-> a3-5 0 vector 0 quad) (-> s4-0 vector 0 quad)) + (set! (-> a3-5 0 vector 1 quad) (-> s5-0 vector 0 quad)) + (set! (-> a3-5 0 vector 2 quad) (-> s4-0 vector 0 quad)) + (set! (-> a3-5 1 vector 0 quad) (-> s5-0 vector 1 quad)) + (set! (-> a3-5 1 vector 1 quad) (-> s4-0 vector 0 quad)) + (set! (-> a3-5 1 vector 2 quad) (-> s5-0 vector 2 quad)) (set! (-> a1-21 base) (&+ (the-as pointer a3-5) 96)) ) (let ((a1-25 (/ (the-as int (+ (&- (the-as pointer -16) (the-as uint a0-9)) (the-as int (-> v1-9 base)))) 16))) diff --git a/test/decompiler/reference/engine/debug/stats-h_REF.gc b/test/decompiler/reference/engine/debug/stats-h_REF.gc index 08cde746b6..fcfaace3a9 100644 --- a/test/decompiler/reference/engine/debug/stats-h_REF.gc +++ b/test/decompiler/reference/engine/debug/stats-h_REF.gc @@ -127,15 +127,14 @@ ;; WARN: Unsupported inline assembly instruction kind - [sync.l] ;; WARN: Unsupported inline assembly instruction kind - [sync.p] (defmethod reset! perf-stat ((obj perf-stat)) - (local-vars (r0-0 none)) (let ((v1-0 (-> obj ctrl))) (+! (-> obj count) 1) (b! (zero? v1-0) cfg-2 :delay (nop!)) - (.mtc0 Perf r0-0) + (.mtc0 Perf r0) (.sync.l) (.sync.p) - (.mtpc pcr0 r0-0) - (.mtpc pcr1 r0-0) + (.mtpc pcr0 r0) + (.mtpc pcr1 r0) (.sync.l) (.sync.p) (.mtc0 Perf v1-0) @@ -155,9 +154,9 @@ ;; WARN: Unsupported inline assembly instruction kind - [mfpc v1, pcr0] ;; WARN: Unsupported inline assembly instruction kind - [mfpc v1, pcr1] (defmethod read! perf-stat ((obj perf-stat)) - (local-vars (r0-0 none) (v1-1 int) (v1-3 int)) + (local-vars (v1-1 int) (v1-3 int)) (b! (zero? (-> obj ctrl)) cfg-2 :delay (nop!)) - (.mtc0 Perf r0-0) + (.mtc0 Perf r0) (.sync.l) (.sync.p) (.mfpc v1-1 pcr0) diff --git a/test/decompiler/reference/engine/draw/drawable-tree_REF.gc b/test/decompiler/reference/engine/draw/drawable-tree_REF.gc index 9a09c4818a..5ee003c6c6 100644 --- a/test/decompiler/reference/engine/draw/drawable-tree_REF.gc +++ b/test/decompiler/reference/engine/draw/drawable-tree_REF.gc @@ -40,7 +40,6 @@ ) ;; definition for method 16 of type drawable-tree -;; WARN: Unsupported inline assembly instruction kind - [sra t4, t4, 1] (defmethod unpack-vis drawable-tree ((obj drawable-tree) (arg0 (pointer int8)) (arg1 (pointer int8))) (local-vars (t5-1 int)) (let* ((v1-0 (the-as drawable-inline-array-node (-> obj data 0))) @@ -78,7 +77,7 @@ (set! (-> t2-3 0) t5-1) (label cfg-9) (+! t0-5 -1) - (b! (zero? t0-5) cfg-12 :delay (.sra t4-0 t4-0 1)) + (b! (zero? t0-5) cfg-12 :delay (shift-arith-right-32 t4-0 t4-0 1)) (b! (nonzero? t4-0) cfg-7 :delay (set! t2-3 (&-> t2-3 1))) ) ) @@ -92,7 +91,3 @@ ) arg1 ) - - - - diff --git a/test/decompiler/reference/engine/draw/drawable_REF.gc b/test/decompiler/reference/engine/draw/drawable_REF.gc index 65c86214e1..526dd3bc43 100644 --- a/test/decompiler/reference/engine/draw/drawable_REF.gc +++ b/test/decompiler/reference/engine/draw/drawable_REF.gc @@ -7,7 +7,7 @@ ;; WARN: Bad vector register dependency: vf18 ;; WARN: Bad vector register dependency: vf19 (defun sphere-cull ((arg0 vector)) - (local-vars (r0-0 uint128) (v1-0 uint128) (v1-1 uint128) (v1-2 uint128)) + (local-vars (v1-0 uint128) (v1-1 uint128) (v1-2 uint128)) (rlet ((acc :class vf) (vf0 :class vf) (vf10 :class vf) @@ -25,8 +25,8 @@ (.sub.mul.w.vf vf9 vf19 vf0 acc) (.add.w.vf vf9 vf9 vf10) (.mov v1-0 vf9) - (.pcgtw v1-1 r0-0 v1-0) - (.ppach v1-2 r0-0 v1-1) + (.pcgtw v1-1 0 v1-0) + (.ppach v1-2 (the-as uint128 0) v1-1) (zero? (the-as int v1-2)) ) ) @@ -37,7 +37,7 @@ ;; WARN: Bad vector register dependency: vf22 ;; WARN: Bad vector register dependency: vf23 (defun guard-band-cull ((arg0 vector)) - (local-vars (r0-0 uint128) (v1-0 uint128) (v1-1 uint128) (v1-2 uint128)) + (local-vars (v1-0 uint128) (v1-1 uint128) (v1-2 uint128)) (rlet ((acc :class vf) (vf0 :class vf) (vf10 :class vf) @@ -55,15 +55,15 @@ (.sub.mul.w.vf vf9 vf23 vf0 acc) (.sub.w.vf vf9 vf9 vf10) (.mov v1-0 vf9) - (.pcgtw v1-1 r0-0 v1-0) - (.ppach v1-2 r0-0 v1-1) + (.pcgtw v1-1 0 v1-0) + (.ppach v1-2 (the-as uint128 0) v1-1) (nonzero? (the-as int v1-2)) ) ) ;; definition for function sphere-in-view-frustum? (defun sphere-in-view-frustum? ((arg0 sphere)) - (local-vars (r0-0 uint128) (v1-1 uint128) (v1-2 uint128) (v1-3 uint128)) + (local-vars (v1-1 uint128) (v1-2 uint128) (v1-3 uint128)) (rlet ((acc :class vf) (vf0 :class vf) (vf1 :class vf) @@ -87,23 +87,15 @@ (.sub.mul.w.vf vf5 vf4 vf0 acc) (.add.w.vf vf5 vf5 vf6) (.mov v1-1 vf5) - (.pcgtw v1-2 r0-0 v1-1) - (.ppach v1-3 r0-0 v1-2) + (.pcgtw v1-2 0 v1-1) + (.ppach v1-3 (the-as uint128 0) v1-2) (zero? (the-as int v1-3)) ) ) ;; definition for function line-in-view-frustum? (defun line-in-view-frustum? ((arg0 vector) (arg1 vector)) - (local-vars - (r0-0 uint128) - (v1-1 uint128) - (v1-2 uint128) - (v1-3 uint128) - (a0-1 uint128) - (a0-2 uint128) - (a0-3 uint128) - ) + (local-vars (v1-1 uint128) (v1-2 uint128) (v1-3 uint128) (a0-1 uint128) (a0-2 uint128) (a0-3 uint128)) (rlet ((acc :class vf) (vf0 :class vf) (vf10 :class vf) @@ -131,11 +123,11 @@ (.add.mul.z.vf acc vf18 vf10 acc) (.sub.mul.w.vf vf10 vf19 vf0 acc) (.mov v1-1 vf9) - (.pcgtw v1-2 r0-0 v1-1) - (.ppach v1-3 r0-0 v1-2) + (.pcgtw v1-2 0 v1-1) + (.ppach v1-3 (the-as uint128 0) v1-2) (.mov a0-1 vf10) - (.pcgtw a0-2 r0-0 a0-1) - (.ppach a0-3 r0-0 a0-2) + (.pcgtw a0-2 0 a0-1) + (.ppach a0-3 (the-as uint128 0) a0-2) (zero? (logand (the-as int v1-3) (the-as int a0-3))) ) ) @@ -143,12 +135,11 @@ ;; definition for function vis-cull ;; WARN: Type Propagation failed: Failed type prop at op 3 ((set! v1 (l.b (+ v1 #x38b0)))): Could not get type of load: (set! v1 (l.b (+ v1 #x38b0))). ;; WARN: Type Propagation failed: Type analysis failed -;; WARN: Unsupported inline assembly instruction kind - [sra a1, a0, 3] ;; WARN: Unsupported inline assembly instruction kind - [addiu a0, a0, 56] (defun vis-cull ((a0-0 int)) (local-vars (v0-0 none) (v1-0 int) (v1-1 int) (v1-2 none) (v1-3 none) (a0-1 none) (a0-2 none) (a1-0 int)) (set! v1-0 #x70000000) - (.sra a1-0 a0-0 3) + (shift-arith-right-32 a1-0 a0-0 3) (set! v1-1 (+ a1-0 v1-0)) (set! v1-2 (the-as none (l.b (+ v1-1 #x38b0)))) (set! a0-1 (the-as none (logand a0-0 7))) @@ -1209,7 +1200,7 @@ ;; WARN: Unsupported inline assembly instruction kind - [mfpc a0, pcr0] ;; WARN: Unsupported inline assembly instruction kind - [mfpc a0, pcr1] (defun real-main-draw-hook () - (local-vars (r0-0 none) (a0-74 int) (a0-76 int)) + (local-vars (a0-74 int) (a0-76 int)) (when *slow-frame-rate* (dotimes (v1-2 #xc3500) (nop!) @@ -1478,11 +1469,11 @@ ) (+! (-> v1-178 count) 1) (b! (zero? a0-72) cfg-77 :delay (nop!)) - (.mtc0 Perf r0-0) + (.mtc0 Perf r0) (.sync.l) (.sync.p) - (.mtpc pcr0 r0-0) - (.mtpc pcr1 r0-0) + (.mtpc pcr0 r0) + (.mtpc pcr1 r0) (.sync.l) (.sync.p) (.mtc0 Perf a0-72) @@ -1494,7 +1485,7 @@ (finish-background) (let ((v1-181 (-> *perf-stats* data 3))) (b! (zero? (-> v1-181 ctrl)) cfg-79 :delay (nop!)) - (.mtc0 Perf r0-0) + (.mtc0 Perf r0) (.sync.l) (.sync.p) (.mfpc a0-74 pcr0) @@ -2205,7 +2196,3 @@ (debug-set-camera-pos-rot! a0-0 a1-0) ) ) - - - - diff --git a/test/decompiler/reference/engine/entity/entity_REF.gc b/test/decompiler/reference/engine/entity/entity_REF.gc index e8fffdd884..8438023e49 100644 --- a/test/decompiler/reference/engine/entity/entity_REF.gc +++ b/test/decompiler/reference/engine/entity/entity_REF.gc @@ -1030,10 +1030,10 @@ ) ) (if (nonzero? (-> (the-as process-drawable s5-2) skel)) - (dummy-10 (-> (the-as process-drawable s5-2) skel) (the-as symbol *stdcon*)) + (debug-print-channels (-> (the-as process-drawable s5-2) skel) (the-as symbol *stdcon*)) ) (if (nonzero? (-> (the-as process-drawable s5-2) nav)) - (dummy-9 (-> (the-as process-drawable s5-2) nav)) + (debug-draw (-> (the-as process-drawable s5-2) nav)) ) (if (nonzero? (-> (the-as process-drawable s5-2) path)) (dummy-9 (-> (the-as process-drawable s5-2) path)) @@ -1092,7 +1092,7 @@ (the-as (function object object) (lambda ((arg0 process-drawable)) (when (type-type? (-> arg0 type) process-drawable) (if (nonzero? (-> arg0 nav)) - (dummy-9 (-> arg0 nav)) + (debug-draw (-> arg0 nav)) ) (if (nonzero? (-> arg0 path)) (dummy-9 (-> arg0 path)) @@ -1889,14 +1889,14 @@ ;; WARN: Unsupported inline assembly instruction kind - [sync.p] ;; WARN: Unsupported inline assembly instruction kind - [mfc0 s4, Count] (defun-debug entity-speed-test ((arg0 string)) - (local-vars (r0-0 none) (s4-0 int)) + (local-vars (s4-0 int)) (let ((gp-0 (entity-by-name arg0))) (when gp-0 (set! *spawn-actors* #f) (reset-actors 'debug) 0 (disable-irq) - (.mtc0 Count r0-0) + (.mtc0 Count r0) (.sync.p) (birth! gp-0) (.mfc0 s4-0 Count) diff --git a/test/decompiler/reference/engine/game/main_REF.gc b/test/decompiler/reference/engine/game/main_REF.gc index d52d1aebdc..4c30cb4bd0 100644 --- a/test/decompiler/reference/engine/game/main_REF.gc +++ b/test/decompiler/reference/engine/game/main_REF.gc @@ -979,7 +979,7 @@ ;; WARN: Unsupported inline assembly instruction kind - [sync.l] ;; WARN: Unsupported inline assembly instruction kind - [sync.p] (defbehavior display-loop process () - (local-vars (r0-0 none) (a0-54 int) (a0-56 int) (a0-73 int) (a0-75 int)) + (local-vars (a0-54 int) (a0-56 int) (a0-73 int) (a0-75 int)) (stack-size-set! (-> self main-thread) 512) (let ((disp *display*)) (dma-send-to-spr (the-as uint #x70000000) (the-as uint *terrain-context*) (the-as uint 0) #t) @@ -1109,7 +1109,7 @@ ) (let ((v1-112 (-> *perf-stats* data))) (b! (zero? (-> v1-112 0 ctrl)) cfg-46 :delay (nop!)) - (.mtc0 Perf r0-0) + (.mtc0 Perf r0) (.sync.l) (.sync.p) (.mfpc a0-54 pcr0) @@ -1135,11 +1135,11 @@ ) (+! (-> v1-123 0 count) 1) (b! (zero? a0-60) cfg-51 :delay (nop!)) - (.mtc0 Perf r0-0) + (.mtc0 Perf r0) (.sync.l) (.sync.p) - (.mtpc pcr0 r0-0) - (.mtpc pcr1 r0-0) + (.mtpc pcr0 r0) + (.mtpc pcr1 r0) (.sync.l) (.sync.p) (.mtc0 Perf a0-60) @@ -1168,7 +1168,7 @@ ) (let ((v1-152 (-> *perf-stats* data))) (b! (zero? (-> v1-152 0 ctrl)) cfg-68 :delay (nop!)) - (.mtc0 Perf r0-0) + (.mtc0 Perf r0) (.sync.l) (.sync.p) (.mfpc a0-73 pcr0) @@ -1362,11 +1362,11 @@ ) (+! (-> v1-228 0 count) 1) (b! (zero? a0-112) cfg-98 :delay (nop!)) - (.mtc0 Perf r0-0) + (.mtc0 Perf r0) (.sync.l) (.sync.p) - (.mtpc pcr0 r0-0) - (.mtpc pcr1 r0-0) + (.mtpc pcr0 r0) + (.mtpc pcr1 r0) (.sync.l) (.sync.p) (.mtc0 Perf a0-112) diff --git a/test/decompiler/reference/engine/gfx/ocean/ocean-transition_REF.gc b/test/decompiler/reference/engine/gfx/ocean/ocean-transition_REF.gc index fe3b6bee49..6adc5b376b 100644 --- a/test/decompiler/reference/engine/gfx/ocean/ocean-transition_REF.gc +++ b/test/decompiler/reference/engine/gfx/ocean/ocean-transition_REF.gc @@ -103,12 +103,11 @@ ;; Used lq/sq (defun ocean-trans-add-upload-table ((arg0 dma-buffer) (arg1 int) (arg2 int) (arg3 (pointer float)) (arg4 int) (arg5 symbol)) (local-vars - (r0-0 uint128) - (r0-1 uint128) - (r0-2 uint128) - (r0-3 uint128) - (r0-4 uint128) - (r0-5 uint128) + (r0-0 int) + (r0-1 int) + (r0-2 int) + (r0-3 int) + (r0-4 int) (v1-12 (inline-array vector)) (v1-14 float) (a0-23 uint128) @@ -215,23 +214,23 @@ (t0-10 (the-as uint128 (-> *ocean-map* ocean-colors colors (+ (* 52 (+ a0-16 1)) a1-11)))) (a0-22 (the-as uint128 (-> *ocean-map* ocean-colors colors (+ a1-11 1 (* 52 (+ a0-16 1)))))) ) - (.pextlb a1-15 r0-0 a2-14) + (.pextlb a1-15 0 a2-14) + (.mov r0-0 f31-0) + (.pextlb a2-15 0 a3-9) (.mov r0-1 f31-0) - (.pextlb a2-15 r0-1 a3-9) + (.pextlb a3-10 0 t0-10) (.mov r0-2 f31-0) - (.pextlb a3-10 r0-2 t0-10) - (.mov r0-3 f31-0) - (.pextlb a0-23 r0-3 a0-22) + (.pextlb a0-23 0 a0-22) ) ) + (.mov r0-3 f31-0) + (.pextlh a1-16 0 a1-15) (.mov r0-4 f31-0) - (.pextlh a1-16 r0-4 a1-15) - (.mov r0-5 f31-0) - (.pextlh a2-16 r0-5 a2-15) + (.pextlh a2-16 0 a2-15) (.mov vf1 a1-16) - (.pextlh a1-17 r0-5 a3-10) + (.pextlh a1-17 0 a3-10) (.mov vf2 a2-16) - (.pextlh a0-24 r0-5 a0-23) + (.pextlh a0-24 0 a0-23) (.mov vf3 a1-17) (nop!) (.mov vf4 a0-24) @@ -306,12 +305,11 @@ ;; Used lq/sq (defun ocean-trans-add-upload-strip ((arg0 dma-buffer) (arg1 uint) (arg2 uint) (arg3 uint) (arg4 uint) (arg5 uint)) (local-vars - (r0-0 uint128) - (r0-1 uint128) - (r0-2 uint128) - (r0-3 uint128) - (r0-4 uint128) - (r0-5 uint128) + (r0-0 int) + (r0-1 int) + (r0-2 int) + (r0-3 int) + (r0-4 int) (v1-8 float) (a0-23 uint128) (a0-24 uint128) @@ -366,22 +364,22 @@ (a2-14 (the-as uint128 (-> *ocean-map* ocean-colors colors (+ (* 52 (the-as int (+ arg1 1))) arg2)))) (a3-10 (the-as uint128 (-> *ocean-map* ocean-colors colors (+ arg2 1 (* 52 (the-as int (+ arg1 1))))))) ) - (.pextlb a0-23 r0-0 a0-22) + (.pextlb a0-23 0 a0-22) + (.mov r0-0 f31-0) + (.pextlb a1-14 0 a1-13) (.mov r0-1 f31-0) - (.pextlb a1-14 r0-1 a1-13) + (.pextlb a2-15 0 a2-14) (.mov r0-2 f31-0) - (.pextlb a2-15 r0-2 a2-14) - (.mov r0-3 f31-0) - (.pextlb a3-11 r0-3 a3-10) + (.pextlb a3-11 0 a3-10) ) + (.mov r0-3 f31-0) + (.pextlh a0-24 0 a0-23) (.mov r0-4 f31-0) - (.pextlh a0-24 r0-4 a0-23) - (.mov r0-5 f31-0) - (.pextlh a1-15 r0-5 a1-14) + (.pextlh a1-15 0 a1-14) (.mov vf1 a0-24) - (.pextlh a0-25 r0-5 a2-15) + (.pextlh a0-25 0 a2-15) (.mov vf2 a1-15) - (.pextlh a1-16 r0-5 a3-11) + (.pextlh a1-16 0 a3-11) (.mov vf3 a0-25) (nop!) (.mov vf4 a1-16) diff --git a/test/decompiler/reference/engine/gfx/sparticle/sparticle_REF.gc b/test/decompiler/reference/engine/gfx/sparticle/sparticle_REF.gc index b06219857f..6c542b6315 100644 --- a/test/decompiler/reference/engine/gfx/sparticle/sparticle_REF.gc +++ b/test/decompiler/reference/engine/gfx/sparticle/sparticle_REF.gc @@ -161,17 +161,11 @@ ) ;; definition for function sp-get-particle -;; WARN: Unsupported inline assembly instruction kind - [movn t1, t2, t2] ;; WARN: Unsupported inline assembly instruction kind - [movz a2, t3, t2] -;; WARN: Unsupported inline assembly instruction kind - [movn t1, t2, t2] ;; WARN: Unsupported inline assembly instruction kind - [movz a2, t3, t2] -;; WARN: Unsupported inline assembly instruction kind - [movn t1, t2, t2] ;; WARN: Unsupported inline assembly instruction kind - [movz a2, t3, t2] -;; WARN: Unsupported inline assembly instruction kind - [movn t1, t2, t2] ;; WARN: Unsupported inline assembly instruction kind - [movz a2, t3, t2] -;; WARN: Unsupported inline assembly instruction kind - [movn t1, t2, t2] ;; WARN: Unsupported inline assembly instruction kind - [movz a2, t3, t2] -;; WARN: Unsupported inline assembly instruction kind - [movn t3, t1, t1] ;; WARN: Unsupported inline assembly instruction kind - [movz a2, t2, t1] (defun sp-get-particle ((arg0 sparticle-system) (arg1 int) (arg2 sparticle-launch-state)) (local-vars @@ -215,36 +209,36 @@ (let ((t2-4 (shl t1-15 32)) (t3-0 (+ a2-2 32)) ) - (.movn t1-16 t2-4 t2-4 t1-15) + (move-if-not-zero t1-16 t2-4 t2-4 t1-15) (.movz a2-3 t3-0 t2-4 a2-2) ) (let ((t2-5 (shl t1-16 16)) (t3-1 (+ a2-3 16)) ) - (.movn t1-17 t2-5 t2-5 t1-16) + (move-if-not-zero t1-17 t2-5 t2-5 t1-16) (.movz a2-4 t3-1 t2-5 a2-3) ) (let ((t2-6 (* t1-17 256)) (t3-2 (+ a2-4 8)) ) - (.movn t1-18 t2-6 t2-6 t1-17) + (move-if-not-zero t1-18 t2-6 t2-6 t1-17) (.movz a2-5 t3-2 t2-6 a2-4) ) (let ((t2-7 (* t1-18 16)) (t3-3 (+ a2-5 4)) ) - (.movn t1-19 t2-7 t2-7 t1-18) + (move-if-not-zero t1-19 t2-7 t2-7 t1-18) (.movz a2-6 t3-3 t2-7 a2-5) ) (let ((t2-8 (* t1-19 4)) (t3-4 (+ a2-6 2)) ) - (.movn t1-20 t2-8 t2-8 t1-19) + (move-if-not-zero t1-20 t2-8 t2-8 t1-19) (.movz a2-7 t3-4 t2-8 a2-6) (let ((t1-21 (* t1-20 2)) (t2-9 (+ a2-7 1)) ) - (.movn t3-5 t1-21 t1-21 t3-4) + (move-if-not-zero t3-5 t1-21 t1-21 t3-4) (.movz a2-8 t2-9 t1-21 a2-7) ) ) diff --git a/test/decompiler/reference/engine/gfx/tfrag/subdivide_REF.gc b/test/decompiler/reference/engine/gfx/tfrag/subdivide_REF.gc index 089dc4339d..6bc5445c8f 100644 --- a/test/decompiler/reference/engine/gfx/tfrag/subdivide_REF.gc +++ b/test/decompiler/reference/engine/gfx/tfrag/subdivide_REF.gc @@ -290,7 +290,6 @@ ;; WARN: Unsupported inline assembly instruction kind - [sync.l] ;; WARN: Unsupported inline assembly instruction kind - [sync.p] (defun-debug start-perf-stat-collection () - (local-vars (r0-0 none)) (let ((frame-idx (+ (-> *perf-stats* data 0 frame-number) 1))) (set! (-> *perf-stats* data 0 frame-number) frame-idx) (let ((gp-0 (mod frame-idx (the-as uint 34)))) @@ -369,11 +368,11 @@ ) (+! (-> v1-31 0 count) 1) (b! (zero? a0-76) cfg-28 :delay (nop!)) - (.mtc0 Perf r0-0) + (.mtc0 Perf r0) (.sync.l) (.sync.p) - (.mtpc pcr0 r0-0) - (.mtpc pcr1 r0-0) + (.mtpc pcr0 r0) + (.mtpc pcr1 r0) (.sync.l) (.sync.p) (.mtc0 Perf a0-76) @@ -394,10 +393,10 @@ ;; WARN: Unsupported inline assembly instruction kind - [mfpc a0, pcr0] ;; WARN: Unsupported inline assembly instruction kind - [mfpc a0, pcr1] (defun-debug end-perf-stat-collection () - (local-vars (r0-0 none) (a0-1 int) (a0-3 int)) + (local-vars (a0-1 int) (a0-3 int)) (let ((v1-1 (-> *perf-stats* data))) (b! (zero? (-> v1-1 0 ctrl)) cfg-2 :delay (nop!)) - (.mtc0 Perf r0-0) + (.mtc0 Perf r0) (.sync.l) (.sync.p) (.mfpc a0-1 pcr0) diff --git a/test/decompiler/reference/engine/gfx/tfrag/tfrag-methods_REF.gc b/test/decompiler/reference/engine/gfx/tfrag/tfrag-methods_REF.gc index 06ba3c8a1a..2f47ddb2be 100644 --- a/test/decompiler/reference/engine/gfx/tfrag/tfrag-methods_REF.gc +++ b/test/decompiler/reference/engine/gfx/tfrag/tfrag-methods_REF.gc @@ -59,7 +59,7 @@ ;; WARN: Unsupported inline assembly instruction kind - [mfpc a0, pcr0] ;; WARN: Unsupported inline assembly instruction kind - [mfpc a0, pcr1] (defun draw-drawable-tree-tfrag ((arg0 drawable-tree-tfrag)) - (local-vars (r0-0 none) (a0-20 int) (a0-22 int) (a0-38 int) (a0-40 int) (sv-16 (pointer uint8))) + (local-vars (a0-20 int) (a0-22 int) (a0-38 int) (a0-40 int) (sv-16 (pointer uint8))) (when (logtest? *vu1-enable-user* (vu1-renderer-mask tfrag)) (let ((s5-0 (+ (-> arg0 length) -1))) (when (nonzero? s5-0) @@ -107,11 +107,11 @@ ) (+! (-> v1-28 count) 1) (b! (zero? a0-17) cfg-8 :delay (nop!)) - (.mtc0 Perf r0-0) + (.mtc0 Perf r0) (.sync.l) (.sync.p) - (.mtpc pcr0 r0-0) - (.mtpc pcr1 r0-0) + (.mtpc pcr0 r0) + (.mtpc pcr1 r0) (.sync.l) (.sync.p) (.mtc0 Perf a0-17) @@ -123,7 +123,7 @@ (draw-inline-array-tfrag sv-16 (the-as drawable-inline-array s4-1) s3-0 s1-0) (let ((v1-31 (-> *perf-stats* data 5))) (b! (zero? (-> v1-31 ctrl)) cfg-10 :delay (nop!)) - (.mtc0 Perf r0-0) + (.mtc0 Perf r0) (.sync.l) (.sync.p) (.mfpc a0-20 pcr0) @@ -180,11 +180,11 @@ ) (+! (-> v1-52 count) 1) (b! (zero? a0-35) cfg-15 :delay (nop!)) - (.mtc0 Perf r0-0) + (.mtc0 Perf r0) (.sync.l) (.sync.p) - (.mtpc pcr0 r0-0) - (.mtpc pcr1 r0-0) + (.mtpc pcr0 r0) + (.mtpc pcr1 r0) (.sync.l) (.sync.p) (.mtc0 Perf a0-35) @@ -196,7 +196,7 @@ (draw-inline-array-tfrag-near sv-16 (the-as drawable-inline-array s4-1) s3-0 s1-1) (let ((v1-55 (-> *perf-stats* data 6))) (b! (zero? (-> v1-55 ctrl)) cfg-17 :delay (nop!)) - (.mtc0 Perf r0-0) + (.mtc0 Perf r0) (.sync.l) (.sync.p) (.mfpc a0-38 pcr0) @@ -283,7 +283,7 @@ ;; WARN: Unsupported inline assembly instruction kind - [mfpc a0, pcr0] ;; WARN: Unsupported inline assembly instruction kind - [mfpc a0, pcr1] (defun draw-drawable-tree-trans-tfrag ((arg0 drawable-tree-trans-tfrag)) - (local-vars (r0-0 none) (a0-18 int) (a0-20 int) (a0-35 int) (a0-37 int) (sv-16 (pointer uint8))) + (local-vars (a0-18 int) (a0-20 int) (a0-35 int) (a0-37 int) (sv-16 (pointer uint8))) (when (logtest? *vu1-enable-user* (vu1-renderer-mask trans-frag)) (let ((s5-0 (+ (-> arg0 length) -1))) (when (nonzero? s5-0) @@ -331,11 +331,11 @@ ) (+! (-> v1-24 count) 1) (b! (zero? a0-14) cfg-8 :delay (nop!)) - (.mtc0 Perf r0-0) + (.mtc0 Perf r0) (.sync.l) (.sync.p) - (.mtpc pcr0 r0-0) - (.mtpc pcr1 r0-0) + (.mtpc pcr0 r0) + (.mtpc pcr1 r0) (.sync.l) (.sync.p) (.mtc0 Perf a0-14) @@ -353,7 +353,7 @@ ) (let ((v1-32 (-> *perf-stats* data 5))) (b! (zero? (-> v1-32 ctrl)) cfg-10 :delay (nop!)) - (.mtc0 Perf r0-0) + (.mtc0 Perf r0) (.sync.l) (.sync.p) (.mfpc a0-18 pcr0) @@ -405,11 +405,11 @@ ) (+! (-> v1-48 count) 1) (b! (zero? a0-32) cfg-15 :delay (nop!)) - (.mtc0 Perf r0-0) + (.mtc0 Perf r0) (.sync.l) (.sync.p) - (.mtpc pcr0 r0-0) - (.mtpc pcr1 r0-0) + (.mtpc pcr0 r0) + (.mtpc pcr1 r0) (.sync.l) (.sync.p) (.mtc0 Perf a0-32) @@ -421,7 +421,7 @@ (draw-inline-array-tfrag-near sv-16 s5-1 s4-1 s2-1) (let ((v1-51 (-> *perf-stats* data 6))) (b! (zero? (-> v1-51 ctrl)) cfg-17 :delay (nop!)) - (.mtc0 Perf r0-0) + (.mtc0 Perf r0) (.sync.l) (.sync.p) (.mfpc a0-35 pcr0) @@ -496,7 +496,7 @@ ;; WARN: Unsupported inline assembly instruction kind - [mfpc a0, pcr0] ;; WARN: Unsupported inline assembly instruction kind - [mfpc a0, pcr1] (defun draw-drawable-tree-dirt-tfrag ((arg0 drawable-tree-dirt-tfrag)) - (local-vars (r0-0 none) (a0-18 int) (a0-20 int) (a0-35 int) (a0-37 int) (sv-16 (pointer uint8))) + (local-vars (a0-18 int) (a0-20 int) (a0-35 int) (a0-37 int) (sv-16 (pointer uint8))) (when (logtest? *vu1-enable-user* (vu1-renderer-mask trans-frag)) (let ((s5-0 (+ (-> arg0 length) -1))) (when (nonzero? s5-0) @@ -533,11 +533,11 @@ ) (+! (-> v1-24 count) 1) (b! (zero? a0-14) cfg-8 :delay (nop!)) - (.mtc0 Perf r0-0) + (.mtc0 Perf r0) (.sync.l) (.sync.p) - (.mtpc pcr0 r0-0) - (.mtpc pcr1 r0-0) + (.mtpc pcr0 r0) + (.mtpc pcr1 r0) (.sync.l) (.sync.p) (.mtc0 Perf a0-14) @@ -555,7 +555,7 @@ ) (let ((v1-32 (-> *perf-stats* data 5))) (b! (zero? (-> v1-32 ctrl)) cfg-10 :delay (nop!)) - (.mtc0 Perf r0-0) + (.mtc0 Perf r0) (.sync.l) (.sync.p) (.mfpc a0-18 pcr0) @@ -600,11 +600,11 @@ ) (+! (-> v1-48 count) 1) (b! (zero? a0-32) cfg-15 :delay (nop!)) - (.mtc0 Perf r0-0) + (.mtc0 Perf r0) (.sync.l) (.sync.p) - (.mtpc pcr0 r0-0) - (.mtpc pcr1 r0-0) + (.mtpc pcr0 r0) + (.mtpc pcr1 r0) (.sync.l) (.sync.p) (.mtc0 Perf a0-32) @@ -616,7 +616,7 @@ (draw-inline-array-tfrag-near sv-16 s5-1 s4-1 s2-1) (let ((v1-51 (-> *perf-stats* data 6))) (b! (zero? (-> v1-51 ctrl)) cfg-17 :delay (nop!)) - (.mtc0 Perf r0-0) + (.mtc0 Perf r0) (.sync.l) (.sync.p) (.mfpc a0-35 pcr0) @@ -691,7 +691,7 @@ ;; WARN: Unsupported inline assembly instruction kind - [mfpc a0, pcr0] ;; WARN: Unsupported inline assembly instruction kind - [mfpc a0, pcr1] (defun draw-drawable-tree-ice-tfrag ((arg0 drawable-tree-ice-tfrag)) - (local-vars (r0-0 none) (a0-18 int) (a0-20 int) (a0-35 int) (a0-37 int) (sv-16 (pointer uint8))) + (local-vars (a0-18 int) (a0-20 int) (a0-35 int) (a0-37 int) (sv-16 (pointer uint8))) (when (logtest? *vu1-enable-user* (vu1-renderer-mask trans-frag)) (let ((s5-0 (+ (-> arg0 length) -1))) (when (nonzero? s5-0) @@ -732,11 +732,11 @@ ) (+! (-> v1-24 count) 1) (b! (zero? a0-14) cfg-8 :delay (nop!)) - (.mtc0 Perf r0-0) + (.mtc0 Perf r0) (.sync.l) (.sync.p) - (.mtpc pcr0 r0-0) - (.mtpc pcr1 r0-0) + (.mtpc pcr0 r0) + (.mtpc pcr1 r0) (.sync.l) (.sync.p) (.mtc0 Perf a0-14) @@ -754,7 +754,7 @@ ) (let ((v1-32 (-> *perf-stats* data 5))) (b! (zero? (-> v1-32 ctrl)) cfg-10 :delay (nop!)) - (.mtc0 Perf r0-0) + (.mtc0 Perf r0) (.sync.l) (.sync.p) (.mfpc a0-18 pcr0) @@ -799,11 +799,11 @@ ) (+! (-> v1-48 count) 1) (b! (zero? a0-32) cfg-15 :delay (nop!)) - (.mtc0 Perf r0-0) + (.mtc0 Perf r0) (.sync.l) (.sync.p) - (.mtpc pcr0 r0-0) - (.mtpc pcr1 r0-0) + (.mtpc pcr0 r0) + (.mtpc pcr1 r0) (.sync.l) (.sync.p) (.mtc0 Perf a0-32) @@ -815,7 +815,7 @@ (draw-inline-array-tfrag-near sv-16 s5-1 s4-1 s2-1) (let ((v1-51 (-> *perf-stats* data 6))) (b! (zero? (-> v1-51 ctrl)) cfg-17 :delay (nop!)) - (.mtc0 Perf r0-0) + (.mtc0 Perf r0) (.sync.l) (.sync.p) (.mfpc a0-35 pcr0) diff --git a/test/decompiler/reference/engine/gfx/tie/tie-methods_REF.gc b/test/decompiler/reference/engine/gfx/tie/tie-methods_REF.gc index c918adc0ac..05364a1195 100644 --- a/test/decompiler/reference/engine/gfx/tie/tie-methods_REF.gc +++ b/test/decompiler/reference/engine/gfx/tie/tie-methods_REF.gc @@ -309,7 +309,6 @@ ;; Used lq/sq (defun draw-drawable-tree-instance-tie ((arg0 drawable-tree-instance-tie) (arg1 level)) (local-vars - (r0-0 none) (a0-31 int) (a0-33 int) (a0-46 int) @@ -376,11 +375,11 @@ ) (+! (-> v1-32 count) 1) (b! (zero? a0-28) cfg-12 :delay (nop!)) - (.mtc0 Perf r0-0) + (.mtc0 Perf r0) (.sync.l) (.sync.p) - (.mtpc pcr0 r0-0) - (.mtpc pcr1 r0-0) + (.mtpc pcr0 r0) + (.mtpc pcr1 r0) (.sync.l) (.sync.p) (.mtc0 Perf a0-28) @@ -396,7 +395,7 @@ ) (let ((v1-35 (-> *perf-stats* data 9))) (b! (zero? (-> v1-35 ctrl)) cfg-14 :delay (nop!)) - (.mtc0 Perf r0-0) + (.mtc0 Perf r0) (.sync.l) (.sync.p) (.mfpc a0-31 pcr0) @@ -439,11 +438,11 @@ ) (+! (-> v1-60 count) 1) (b! (zero? a0-43) cfg-20 :delay (nop!)) - (.mtc0 Perf r0-0) + (.mtc0 Perf r0) (.sync.l) (.sync.p) - (.mtpc pcr0 r0-0) - (.mtpc pcr1 r0-0) + (.mtpc pcr0 r0) + (.mtpc pcr1 r0) (.sync.l) (.sync.p) (.mtc0 Perf a0-43) @@ -455,7 +454,7 @@ (draw-inline-array-prototype-tie-generic-asm s3-1 s5-1 s4-1) (let ((v1-63 (-> *perf-stats* data 10))) (b! (zero? (-> v1-63 ctrl)) cfg-22 :delay (nop!)) - (.mtc0 Perf r0-0) + (.mtc0 Perf r0) (.sync.l) (.sync.p) (.mfpc a0-46 pcr0) @@ -498,11 +497,11 @@ ) (+! (-> v1-85 count) 1) (b! (zero? a0-59) cfg-28 :delay (nop!)) - (.mtc0 Perf r0-0) + (.mtc0 Perf r0) (.sync.l) (.sync.p) - (.mtpc pcr0 r0-0) - (.mtpc pcr1 r0-0) + (.mtpc pcr0 r0) + (.mtpc pcr1 r0) (.sync.l) (.sync.p) (.mtc0 Perf a0-59) @@ -514,7 +513,7 @@ (draw-inline-array-prototype-tie-asm s1-1 s5-1 s4-1) (let ((v1-88 (-> *perf-stats* data 11))) (b! (zero? (-> v1-88 ctrl)) cfg-30 :delay (nop!)) - (.mtc0 Perf r0-0) + (.mtc0 Perf r0) (.sync.l) (.sync.p) (.mfpc a0-62 pcr0) @@ -575,11 +574,11 @@ ) (+! (-> v1-114 count) 1) (b! (zero? a0-79) cfg-39 :delay (nop!)) - (.mtc0 Perf r0-0) + (.mtc0 Perf r0) (.sync.l) (.sync.p) - (.mtpc pcr0 r0-0) - (.mtpc pcr1 r0-0) + (.mtpc pcr0 r0) + (.mtpc pcr1 r0) (.sync.l) (.sync.p) (.mtc0 Perf a0-79) @@ -591,7 +590,7 @@ (draw-inline-array-prototype-tie-near-asm s1-2 s5-1 s4-1) (let ((v1-117 (-> *perf-stats* data 12))) (b! (zero? (-> v1-117 ctrl)) cfg-41 :delay (nop!)) - (.mtc0 Perf r0-0) + (.mtc0 Perf r0) (.sync.l) (.sync.p) (.mfpc a0-82 pcr0) diff --git a/test/decompiler/reference/engine/gfx/vis/bsp_REF.gc b/test/decompiler/reference/engine/gfx/vis/bsp_REF.gc index 5b13bd7f2d..06ea7f4287 100644 --- a/test/decompiler/reference/engine/gfx/vis/bsp_REF.gc +++ b/test/decompiler/reference/engine/gfx/vis/bsp_REF.gc @@ -154,7 +154,7 @@ ;; definition for method 10 of type bsp-header ;; Used lq/sq (defmethod draw bsp-header ((obj bsp-header) (other-draw bsp-header) (disp-frame display-frame)) - (local-vars (r0-0 uint128) (a3-4 uint128) (a3-5 uint128)) + (local-vars (a3-4 uint128) (a3-5 uint128)) (rlet ((vf16 :class vf) (vf17 :class vf) (vf18 :class vf) @@ -196,7 +196,7 @@ ) (dotimes (current-qw vis-list-qwc2) (let ((a3-3 (-> vis-list-spad current-qw))) - (.pnor a3-4 a3-3 r0-0) + (.pnor a3-4 a3-3 0) ) (let ((t0-2 (-> vis-list-lev current-qw))) (.pand a3-5 a3-4 t0-2) diff --git a/test/decompiler/reference/engine/level/level_REF.gc b/test/decompiler/reference/engine/level/level_REF.gc index e447642b40..e07dd1b075 100644 --- a/test/decompiler/reference/engine/level/level_REF.gc +++ b/test/decompiler/reference/engine/level/level_REF.gc @@ -802,12 +802,11 @@ ) ;; definition for method 10 of type level -;; WARN: Unsupported inline assembly instruction kind - [sra a0, a1, 3] ;; WARN: Unsupported inline assembly instruction kind - [addiu a0, a0, 56] (defmethod is-object-visible? level ((obj level) (arg0 int)) (local-vars (a0-1 int) (a0-3 int)) (let ((v1-0 (-> obj vis-bits))) - (.sra a0-1 arg0 3) + (shift-arith-right-32 a0-1 arg0 3) (let ((v1-2 (-> (the-as (pointer int8) (+ a0-1 (the-as int v1-0)))))) (let ((a0-2 (logand arg0 7))) (.addiu a0-3 a0-2 56) diff --git a/test/decompiler/reference/engine/load/decomp_REF.gc b/test/decompiler/reference/engine/load/decomp_REF.gc index 49865a368b..61bc8621ac 100644 --- a/test/decompiler/reference/engine/load/decomp_REF.gc +++ b/test/decompiler/reference/engine/load/decomp_REF.gc @@ -60,7 +60,6 @@ ;; definition for function unpack-comp-huf ;; INFO: Return type mismatch int vs none. -;; WARN: Unsupported inline assembly instruction kind - [sra v1, v1, 1] (defun unpack-comp-huf ((arg0 (pointer uint8)) (arg1 (pointer uint8)) (arg2 uint) (arg3 huf-dictionary-node)) (local-vars (t1-1 uint) (t3-2 object)) (nop!) @@ -76,7 +75,7 @@ (set! arg1 (&-> arg1 1)) (label cfg-2) (let ((t3-0 (logand t0-0 v1-4))) - (.sra v1-4 v1-4 1) + (shift-arith-right-32 v1-4 v1-4 1) (b! (zero? t3-0) cfg-4 :delay (set! t1-1 t1-0)) ) ) @@ -108,7 +107,6 @@ ) ;; definition for method 16 of type level -;; WARN: Unsupported inline assembly instruction kind - [sra s2, s2, 3] ;; Used lq/sq (defmethod update-vis! level ((obj level) (vis-info level-vis-info) (arg1 uint) (arg2 uint)) (local-vars (t0-3 uint128) (vis-buffer object)) @@ -209,7 +207,7 @@ (set! vis-buffer (the-as int spad-start)) (set! spad-start spad-end) (set! spad-end (the-as int vis-buffer)) - (.sra lower-flag-bits lower-flag-bits 3) + (shift-arith-right-32 lower-flag-bits lower-flag-bits 3) ) (let ((s2-1 vis-buffer) (s1-1 (the-as (pointer uinteger) (-> obj bsp all-visible-list))) diff --git a/test/decompiler/reference/engine/math/vector-h_REF.gc b/test/decompiler/reference/engine/math/vector-h_REF.gc index 1c751ac62c..e416cf054a 100644 --- a/test/decompiler/reference/engine/math/vector-h_REF.gc +++ b/test/decompiler/reference/engine/math/vector-h_REF.gc @@ -307,9 +307,9 @@ ;; definition for method 3 of type vector4w-3 (defmethod inspect vector4w-3 ((obj vector4w-3)) (format #t "[~8x] ~A~%" obj 'vector4w-3) - (format #t "~Tdata[12] @ #x~X~%" (-> obj quad)) - (format #t "~Tquad[3] @ #x~X~%" (-> obj quad)) - (format #t "~Tvector[3] @ #x~X~%" (-> obj quad)) + (format #t "~Tdata[12] @ #x~X~%" (-> obj vector)) + (format #t "~Tquad[3] @ #x~X~%" (-> obj vector)) + (format #t "~Tvector[3] @ #x~X~%" (-> obj vector)) obj ) diff --git a/test/decompiler/reference/engine/nav/navigate-h_REF.gc b/test/decompiler/reference/engine/nav/navigate-h_REF.gc index 3b04f8c6df..d353b08d21 100644 --- a/test/decompiler/reference/engine/nav/navigate-h_REF.gc +++ b/test/decompiler/reference/engine/nav/navigate-h_REF.gc @@ -8,6 +8,7 @@ (adj-poly uint8 3 :offset-assert 4) (pat uint8 :offset-assert 7) ) + :pack-me :method-count-assert 9 :size-assert #x8 :flag-assert #x900000008 @@ -69,10 +70,10 @@ (next-poly nav-poly :offset-assert 52) (len meters :offset-assert 56) (last-edge int8 :offset-assert 60) - (terminated basic :offset-assert 64) - (reached-dest basic :offset-assert 68) - (hit-boundary basic :offset-assert 72) - (hit-gap basic :offset-assert 76) + (terminated symbol :offset-assert 64) + (reached-dest symbol :offset-assert 68) + (hit-boundary symbol :offset-assert 72) + (hit-gap symbol :offset-assert 76) ) :method-count-assert 9 :size-assert #x50 @@ -118,7 +119,7 @@ ;; definition of type clip-travel-vector-to-mesh-return-info (deftype clip-travel-vector-to-mesh-return-info (structure) - ((found-boundary basic :offset-assert 0) + ((found-boundary symbol :offset-assert 0) (intersection vector :inline :offset-assert 16) (boundary-normal vector :inline :offset-assert 32) (prev-normal vector :inline :offset-assert 48) @@ -236,47 +237,47 @@ ;; definition of type nav-mesh (deftype nav-mesh (basic) - ((user-list engine :offset-assert 4) - (poly-lookup-history uint8 2 :offset-assert 8) - (debug-time uint8 :offset-assert 10) - (static-sphere-count uint8 :offset-assert 11) - (static-sphere uint32 :offset-assert 12) - (bounds sphere :inline :offset-assert 16) - (origin vector :inline :offset-assert 32) - (cache nav-lookup-elem 4 :inline :offset-assert 48) - (node-count int32 :offset-assert 176) - (nodes uint32 :offset-assert 180) - (vertex-count int32 :offset-assert 184) - (vertex (inline-array vector) :offset-assert 188) - (poly-count int32 :offset-assert 192) - (poly uint32 :offset-assert 196) - (route uint32 :offset-assert 200) + ((user-list engine :offset-assert 4) + (poly-lookup-history uint8 2 :offset-assert 8) + (debug-time uint8 :offset-assert 10) + (static-sphere-count uint8 :offset-assert 11) + (static-sphere (inline-array nav-sphere) :offset-assert 12) + (bounds sphere :inline :offset-assert 16) + (origin vector :inline :offset-assert 32) + (cache nav-lookup-elem 4 :inline :offset-assert 48) + (node-count int32 :offset-assert 176) + (nodes (inline-array nav-node) :offset-assert 180) + (vertex-count int32 :offset-assert 184) + (vertex (inline-array nav-vertex) :offset-assert 188) + (poly-count int32 :offset-assert 192) + (poly (inline-array nav-poly) :offset-assert 196) + (route (inline-array vector4ub) :offset-assert 200) ) :method-count-assert 30 :size-assert #xcc :flag-assert #x1e000000cc (:methods - (dummy-9 () none 9) - (dummy-10 () none 10) - (dummy-11 () none 11) - (dummy-12 () none 12) - (dummy-13 (_type_) none 13) - (dummy-14 () none 14) - (dummy-15 () none 15) - (dummy-16 () none 16) - (dummy-17 (_type_) none 17) - (dummy-18 () none 18) + (tri-centroid-world (_type_ nav-poly vector) vector 9) + (tri-centroid-local (_type_ nav-poly vector) vector 10) + (get-adj-poly (_type_ nav-poly nav-poly symbol) nav-poly 11) + (setup-portal (_type_ nav-poly nav-poly nav-route-portal) object 12) + (initialize-mesh! (_type_) none 13) + (move-along-nav-ray! (_type_ nav-ray) none 14) + (try-move-along-ray (_type_ nav-poly vector vector float) meters 15) + (TODO-RENAME-16 (_type_ vector nav-poly vector symbol float clip-travel-vector-to-mesh-return-info) none 16) + (update-route-table (_type_) none 17) + (dummy-18 (_type_ int vector int (pointer int8) int) none 18) (compute-bounding-box (_type_ vector vector) none 19) - (dummy-20 () none 20) - (dummy-21 () none 21) - (dummy-22 () none 22) - (dummy-23 () none 23) - (dummy-24 () none 24) - (dummy-25 () none 25) - (dummy-26 () none 26) - (dummy-27 () none 27) - (dummy-28 () none 28) - (dummy-29 () none 29) + (debug-draw-poly (_type_ nav-poly rgba) none 20) + (point-in-poly? (_type_ nav-poly vector) symbol 21) + (find-opposite-vertices (_type_ nav-poly nav-poly) uint 22) + (dummy-23 (_type_ nav-poly vector vector vector nav-route-portal) vector 23) + (closest-point-on-boundary (_type_ nav-poly vector vector) vector 24) + (project-point-into-tri-3d (_type_ nav-poly vector vector) none 25) + (project-point-into-tri-2d (_type_ nav-poly vector vector) vector 26) + (find-poly-fast (_type_ vector meters) nav-poly 27) + (find-poly (_type_ vector meters (pointer nav-control-flags)) nav-poly 28) + (is-in-mesh? (_type_ vector float meters) symbol 29) ) ) @@ -373,31 +374,31 @@ :flag-assert #x24000000e0 (:methods (new (symbol type collide-shape int float) _type_ 0) - (dummy-9 (_type_) none 9) + (debug-draw (_type_) none 9) (point-in-bounds? (_type_ vector) symbol 10) - (dummy-11 (_type_ vector) none 11) - (dummy-12 () none 12) + (dummy-11 (_type_ vector) vector 11) + (TODO-RENAME-12 (_type_ nav-gap-info) symbol 12) (dummy-13 (_type_ vector vector) vector 13) (set-current-poly! (_type_ nav-poly) none 14) (set-target-pos! (_type_ vector) none 15) (dummy-16 (_type_ vector) nav-poly 16) - (dummy-17 (_type_ vector vector) none 17) - (TODO-RENAME-18 (_type_ vector) nav-poly 18) + (project-onto-nav-mesh (_type_ vector vector) vector 17) + (find-poly (_type_ vector) nav-poly 18) (dummy-19 (_type_ vector collide-shape-moving vector float) none 19) - (dummy-20 () none 20) - (dummy-21 (_type_ vector) symbol 21) - (dummy-22 () none 22) + (project-point-into-tri-3d (_type_ nav-poly vector vector) vector 20) + (TODO-RENAME-21 (_type_ vector) nav-poly 21) + (TODO-RENAME-22 (_type_ vector float) symbol 22) (dummy-23 (_type_ vector check-vector-collision-with-nav-spheres-info) float 23) (dummy-24 (_type_ float clip-travel-vector-to-mesh-return-info) none 24) - (dummy-25 (_type_ vector float) symbol 25) - (dummy-26 (_type_) none 26) - (dummy-27 (_type_) none 27) - (dummy-28 (_type_ int) none 28) + (is-in-mesh? (_type_ vector float) symbol 25) + (TODO-RENAME-26 (_type_) none 26) + (TODO-RENAME-27 (_type_) none 27) + (TODO-RENAME-28 (_type_ collide-kind) none 28) (should-display? (_type_) symbol 29) - (dummy-30 () none 30) - (dummy-31 () none 31) - (dummy-32 () none 32) - (dummy-33 () none 33) + (dummy-30 (_type_ vector vector vector) sphere 30) + (intersect-ray-line-segment? (_type_ vector vector vector vector) symbol 31) + (TODO-ASM-32 (_type_ vector vector vector vector float) symbol 32) + (TODO-RENAME-33 (_type_ vector vector vector vector float) symbol 33) (dummy-34 () none 34) (dummy-35 (_type_ vector vector vector vector float) none 35) ) @@ -462,8 +463,8 @@ (set! (-> entity-nav-mesh user-list) (s1-0 s0-0 sv-16 sv-32 (the-as int a3-1))) ) ) - (dummy-13 entity-nav-mesh) - (dummy-17 entity-nav-mesh) + (initialize-mesh! entity-nav-mesh) + (update-route-table entity-nav-mesh) ) (add-connection (-> entity-nav-mesh user-list) proc nothing proc nav-cont trans) ) diff --git a/test/decompiler/reference/engine/nav/navigate_REF.gc b/test/decompiler/reference/engine/nav/navigate_REF.gc new file mode 100644 index 0000000000..536139955f --- /dev/null +++ b/test/decompiler/reference/engine/nav/navigate_REF.gc @@ -0,0 +1,3368 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition for symbol *nav-timer*, type stopwatch +(define *nav-timer* (new 'global 'stopwatch)) + +;; definition for symbol *travel-timer*, type stopwatch +(define *travel-timer* (new 'global 'stopwatch)) + +;; definition for symbol *clip-for-spheres-timer*, type stopwatch +(define *clip-for-spheres-timer* (new 'global 'stopwatch)) + +;; definition for symbol *find-poly-timer*, type stopwatch +(define *find-poly-timer* (new 'global 'stopwatch)) + +;; definition for symbol *nav-timer-enable*, type symbol +(define *nav-timer-enable* #t) + +;; definition for symbol *nav-patch-route-table*, type symbol +(define *nav-patch-route-table* #t) + +;; definition for symbol *nav-triangle-test-count*, type int +(define *nav-triangle-test-count* 0) + +;; definition for symbol *nav-last-triangle-test-count*, type int +(define *nav-last-triangle-test-count* 0) + +;; definition for symbol *debug-traverse*, type int +(define *debug-traverse* 0) + +;; definition for symbol *debug-tests*, type int +(define *debug-tests* 0) + +;; definition for function pke-nav-hack +;; INFO: Return type mismatch int vs none. +(defun pke-nav-hack () + (format *stdcon* "travs: ~d, tests: ~d~%" *debug-traverse* *debug-tests*) + (set! *debug-traverse* 0) + (set! *debug-tests* 0) + 0 + (none) + ) + +;; definition for function debug-report-nav-stats +;; INFO: Return type mismatch int vs none. +(defun debug-report-nav-stats () + 0 + (none) + ) + +;; definition for symbol *debug-output*, type symbol +(define *debug-output* #f) + +;; definition for symbol *debug-nav*, type symbol +(define *debug-nav* #t) + +;; definition for symbol *debug-nav-ray*, type nav-ray +(define *debug-nav-ray* (the-as nav-ray #f)) + +;; definition for symbol *debug-ray-offset*, type vector +(define *debug-ray-offset* (new 'static 'vector)) + +;; definition for symbol *debug-nav-travel*, type symbol +(define *debug-nav-travel* #f) + +;; definition for symbol *color-black*, type rgba +(define *color-black* (new 'static 'rgba :a #x80)) + +;; definition for symbol *color-white*, type rgba +(define *color-white* (new 'static 'rgba :r #xff :g #xff :b #xff :a #x80)) + +;; definition for symbol *color-gray*, type rgba +(define *color-gray* (new 'static 'rgba :r #x80 :g #x80 :b #x80 :a #x80)) + +;; definition for symbol *color-red*, type rgba +(define *color-red* (new 'static 'rgba :r #xff :a #x80)) + +;; definition for symbol *color-green*, type rgba +(define *color-green* (new 'static 'rgba :g #xff :a #x80)) + +;; definition for symbol *color-blue*, type rgba +(define *color-blue* (new 'static 'rgba :b #xff :a #x80)) + +;; definition for symbol *color-cyan*, type rgba +(define *color-cyan* (new 'static 'rgba :g #xff :b #xff :a #x80)) + +;; definition for symbol *color-magenta*, type rgba +(define *color-magenta* (new 'static 'rgba :r #xff :b #xff :a #x80)) + +;; definition for symbol *color-yellow*, type rgba +(define *color-yellow* (new 'static 'rgba :r #xff :g #xff :a #x80)) + +;; definition for symbol *color-light-red*, type rgba +(define *color-light-red* (new 'static 'rgba :r #xff :g #x80 :b #x80 :a #x80)) + +;; definition for symbol *color-light-green*, type rgba +(define *color-light-green* (new 'static 'rgba :r #x80 :g #xff :b #x80 :a #x80)) + +;; definition for symbol *color-light-blue*, type rgba +(define *color-light-blue* (new 'static 'rgba :r #x80 :g #x80 :b #xff :a #x80)) + +;; definition for symbol *color-light-cyan*, type rgba +(define *color-light-cyan* (new 'static 'rgba :r #x80 :g #xff :b #xff :a #x80)) + +;; definition for symbol *color-light-magenta*, type rgba +(define *color-light-magenta* (new 'static 'rgba :r #xff :g #x80 :b #xff :a #x80)) + +;; definition for symbol *color-light-yellow*, type rgba +(define *color-light-yellow* (new 'static 'rgba :r #xff :g #xff :b #x80 :a #x80)) + +;; definition for symbol *color-dark-red*, type rgba +(define *color-dark-red* (new 'static 'rgba :r #x80 :a #x80)) + +;; definition for symbol *color-dark-green*, type rgba +(define *color-dark-green* (new 'static 'rgba :g #x80 :a #x80)) + +;; definition for symbol *color-dark-blue*, type rgba +(define *color-dark-blue* (new 'static 'rgba :b #x80 :a #x80)) + +;; definition for symbol *color-dark-cyan*, type rgba +(define *color-dark-cyan* (new 'static 'rgba :g #x80 :b #x80 :a #x80)) + +;; definition for symbol *color-dark-magenta*, type rgba +(define *color-dark-magenta* (new 'static 'rgba :r #x80 :b #x80 :a #x80)) + +;; definition for symbol *color-dark-yellow*, type rgba +(define *color-dark-yellow* (new 'static 'rgba :r #x80 :g #x80 :a #x80)) + +;; definition for symbol *color-orange*, type rgba +(define *color-orange* (new 'static 'rgba :r #xff :g #x80 :a #x80)) + +;; definition for function entity-nav-login +;; INFO: Return type mismatch int vs none. +;; Used lq/sq +(defun entity-nav-login ((arg0 entity-actor)) + (local-vars (sv-16 res-tag)) + (let ((gp-0 (if (nonzero? (-> arg0 nav-mesh)) + (-> arg0 nav-mesh) + ) + ) + ) + (when gp-0 + (when (zero? (-> gp-0 user-list)) + (set! (-> gp-0 user-list) + (new 'loading-level 'engine 'nav-engine (res-lump-value arg0 'nav-max-users int :default (the-as uint128 32))) + ) + (initialize-mesh! gp-0) + (update-route-table gp-0) + ) + (when (zero? (-> gp-0 static-sphere)) + (set! sv-16 (new 'static 'res-tag)) + (let ((v1-11 (res-lump-data arg0 'nav-mesh-sphere pointer :tag-ptr (& sv-16)))) + (when v1-11 + (set! (-> gp-0 static-sphere-count) (-> sv-16 elt-count)) + (set! (-> gp-0 static-sphere) (the-as (inline-array nav-sphere) v1-11)) + ) + ) + ) + ) + ) + 0 + (none) + ) + +;; definition for method 4 of type nav-control +(defmethod length nav-control ((obj nav-control)) + (-> obj num-spheres) + ) + +;; definition for method 5 of type nav-control +;; INFO: Return type mismatch uint vs int. +(defmethod asize-of nav-control ((obj nav-control)) + (the-as int (+ (-> nav-control size) (* (-> obj max-spheres) 16))) + ) + +;; definition for symbol *default-nav-mesh*, type nav-mesh +(define *default-nav-mesh* (new 'static 'nav-mesh + :bounds + (new 'static 'sphere :x 12288.0 :y -200704.0 :z 12288.0 :w 20480.0) + :origin + (new 'static 'vector :y -200704.0 :w 1.0) + :vertex-count 4 + :vertex + (new 'static 'inline-array nav-vertex 4 + (new 'static 'nav-vertex :z 16384.0 :w 1.0) + (new 'static 'nav-vertex :z 8192.0 :w 1.0) + (new 'static 'nav-vertex :x 8192.0 :z 8192.0 :w 1.0) + (new 'static 'nav-vertex :x 8192.0 :w 1.0) + ) + :poly-count 2 + :poly + (new 'static 'inline-array nav-poly 2 + (new 'static 'nav-poly + :vertex + (new 'static 'array uint8 3 #x0 #x2 #x1) + :adj-poly + (new 'static 'array uint8 3 #xff #x1 #xff) + ) + (new 'static 'nav-poly + :id #x1 + :vertex + (new 'static 'array uint8 3 #x1 #x2 #x3) + :adj-poly + (new 'static 'array uint8 3 #x0 #xff #xff) + ) + ) + :route + (new 'static 'inline-array vector4ub 4 + (new 'static 'vector4ub :data (new 'static 'array uint8 4 #xcb #x0 #x0 #x0)) + (new 'static 'vector4ub) + (new 'static 'vector4ub) + (new 'static 'vector4ub) + ) + ) + ) + +;; failed to figure out what this is: +(let ((gp-0 *default-nav-mesh*)) + (if (zero? (-> gp-0 user-list)) + (set! (-> gp-0 user-list) (new 'global 'engine 'nav-engine 32)) + ) + ) + +;; definition for method 4 of type nav-mesh +(defmethod length nav-mesh ((obj nav-mesh)) + (-> obj poly-count) + ) + +;; definition for method 20 of type nav-mesh +;; INFO: Return type mismatch int vs none. +(defmethod debug-draw-poly nav-mesh ((obj nav-mesh) (arg0 nav-poly) (arg1 rgba)) + (let ((s5-0 (-> obj origin)) + (s2-0 (-> obj vertex)) + (gp-0 (new 'stack-no-clear 'vector)) + (s4-0 (new 'stack-no-clear 'vector)) + ) + (add-debug-line + #t + (bucket-id debug-draw1) + (vector+! gp-0 s5-0 (the-as vector (-> s2-0 (-> arg0 vertex 0)))) + (vector+! s4-0 s5-0 (the-as vector (-> s2-0 (-> arg0 vertex 1)))) + arg1 + #f + (the-as rgba -1) + ) + (add-debug-line + #t + (bucket-id debug-draw1) + (vector+! gp-0 s5-0 (the-as vector (-> s2-0 (-> arg0 vertex 1)))) + (vector+! s4-0 s5-0 (the-as vector (-> s2-0 (-> arg0 vertex 2)))) + arg1 + #f + (the-as rgba -1) + ) + (add-debug-line + #t + (bucket-id debug-draw1) + (vector+! gp-0 s5-0 (the-as vector (-> s2-0 (-> arg0 vertex 2)))) + (vector+! s4-0 s5-0 (the-as vector (-> s2-0 (-> arg0 vertex 0)))) + arg1 + #f + (the-as rgba -1) + ) + ) + 0 + (none) + ) + +;; definition for symbol *nav-one-third*, type vector +(define *nav-one-third* (new 'global 'vector)) + +;; failed to figure out what this is: +(set! (-> *nav-one-third* x) 0.33333334) + +;; definition for method 10 of type nav-mesh +;; Used lq/sq +(defmethod tri-centroid-local nav-mesh ((obj nav-mesh) (arg0 nav-poly) (arg1 vector)) + (set! (-> arg1 quad) (-> obj vertex (-> arg0 vertex 0) quad)) + (vector+! arg1 arg1 (the-as vector (-> obj vertex (-> arg0 vertex 1)))) + (vector+! arg1 arg1 (the-as vector (-> obj vertex (-> arg0 vertex 2)))) + (vector-float*! arg1 arg1 0.333333) + ) + +;; definition for method 9 of type nav-mesh +(defmethod tri-centroid-world nav-mesh ((obj nav-mesh) (arg0 nav-poly) (arg1 vector)) + (tri-centroid-local obj arg0 arg1) + (vector+! arg1 arg1 (-> obj origin)) + ) + +;; definition for symbol *edge-vert0-table*, type (array int8) +(define + *edge-vert0-table* + (the-as (array int8) (new 'static 'boxed-array :type int8 :length 3 :allocated-length 3 1 2 0)) + ) + +;; definition for symbol *edge-vert1-table*, type (array int8) +(define + *edge-vert1-table* + (the-as (array int8) (new 'static 'boxed-array :type int8 :length 3 :allocated-length 3 2 0 1)) + ) + +;; definition for symbol *edge-mask-table*, type (array int8) +(define + *edge-mask-table* + (the-as (array int8) (new 'static 'boxed-array :type int8 :length 3 :allocated-length 3 1 2 4)) + ) + +;; definition for function inc-mod3 +(defun inc-mod3 ((arg0 int)) + (local-vars (v0-1 int) (v1-1 int)) + (let ((v0-0 (+ arg0 1))) + (let ((v1-0 2)) + (set-on-less-than v1-1 v1-0 v0-0) + ) + (move-if-not-zero v0-1 0 v1-1 v0-0) + ) + v0-1 + ) + +;; definition for function dec-mod3 +(defun dec-mod3 ((arg0 int)) + (local-vars (v0-1 int) (a0-1 int)) + (let ((v0-0 (+ arg0 -1)) + (v1-0 2) + ) + (set-on-less-than a0-1 v0-0 0) + (move-if-not-zero v0-1 v1-0 a0-1 v0-0) + ) + v0-1 + ) + +;; definition for function vu-point-triangle-intersection? +(defun vu-point-triangle-intersection? ((arg0 vector) (arg1 vector) (arg2 vector) (arg3 vector)) + (local-vars (v1-0 float) (v1-1 int) (v1-3 int) (a0-1 float) (a0-2 int) (a0-4 int) (a1-1 float) (a1-2 int)) + (rlet ((acc :class vf) + (vf1 :class vf) + (vf10 :class vf) + (vf11 :class vf) + (vf12 :class vf) + (vf13 :class vf) + (vf14 :class vf) + (vf15 :class vf) + (vf2 :class vf) + (vf3 :class vf) + (vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + (vf9 :class vf) + ) + (.lvf vf1 (&-> arg1 quad)) + (.lvf vf2 (&-> arg2 quad)) + (.sub.vf vf1 vf1 vf1 :mask #b1010) + (.lvf vf3 (&-> arg3 quad)) + (.sub.vf vf2 vf2 vf2 :mask #b1010) + (.lvf vf12 (&-> arg0 quad)) + (.sub.vf vf3 vf3 vf3 :mask #b1010) + (.sub.vf vf4 vf2 vf1) + (.sub.vf vf9 vf1 vf12) + (.sub.vf vf5 vf3 vf2) + (.sub.vf vf10 vf2 vf12) + (.sub.vf vf6 vf1 vf3) + (.sub.vf vf11 vf3 vf12) + (.outer.product.a.vf acc vf9 vf4) + (.outer.product.b.vf vf13 vf4 vf9 acc) + (.outer.product.a.vf acc vf10 vf5) + (.outer.product.b.vf vf14 vf5 vf10 acc) + (.outer.product.a.vf acc vf11 vf6) + (.outer.product.b.vf vf15 vf6 vf11 acc) + (.mov v1-0 vf13) + (.mov a1-1 vf14) + (.mov a0-1 vf15) + (set-on-less-than v1-1 v1-0 0) + (set-on-less-than a1-2 a1-1 0) + (set-on-less-than a0-2 a0-1 0) + (let ((a0-3 (logxor a1-2 a0-2)) + (v1-2 (logxor v1-1 a1-2)) + ) + (set-on-less-than a0-4 a0-3 1) + (set-on-less-than v1-3 v1-2 1) + ) + (logtest? v1-3 a0-4) + ) + ) + +;; definition for method 21 of type nav-mesh +(defmethod point-in-poly? nav-mesh ((obj nav-mesh) (arg0 nav-poly) (arg1 vector)) + (vu-point-triangle-intersection? + arg1 + (-> obj vertex (-> arg0 vertex 0)) + (-> obj vertex (-> arg0 vertex 1)) + (-> obj vertex (-> arg0 vertex 2)) + ) + ) + +;; definition for method 24 of type nav-mesh +;; Used lq/sq +(defmethod closest-point-on-boundary nav-mesh ((obj nav-mesh) (arg0 nav-poly) (arg1 vector) (arg2 vector)) + (let ((s2-0 (-> obj vertex)) + (s1-0 (new 'stack-no-clear 'vector)) + (s5-0 (new 'stack-no-clear 'vector)) + ) + (let ((f30-0 10000000000000000000000000000000000000.0)) + (dotimes (s0-0 3) + (let* ((a1-1 (-> s2-0 (-> arg0 vertex s0-0))) + (f0-0 (vector-segment-distance-point! arg2 a1-1 (-> s2-0 (-> arg0 vertex (mod (+ s0-0 1) 3))) s1-0)) + ) + (when (< f0-0 f30-0) + (set! f30-0 f0-0) + (set! (-> s5-0 quad) (-> s1-0 quad)) + ) + ) + ) + ) + (set! (-> arg1 quad) (-> s5-0 quad)) + ) + arg1 + ) + +;; definition for method 26 of type nav-mesh +;; Used lq/sq +(defmethod project-point-into-tri-2d nav-mesh ((obj nav-mesh) (arg0 nav-poly) (arg1 vector) (arg2 vector)) + (if (point-in-poly? obj arg0 arg2) + (set! (-> arg1 quad) (-> arg2 quad)) + (closest-point-on-boundary obj arg0 arg1 arg2) + ) + arg1 + ) + +;; definition for function point-inside-rect? +(defun point-inside-rect? ((arg0 nav-node) (arg1 vector) (arg2 float)) + (and (>= (-> arg1 x) (- (-> arg0 center-x) (-> arg0 radius-x))) + (>= (+ (-> arg0 center-x) (-> arg0 radius-x)) (-> arg1 x)) + (>= (-> arg1 z) (- (-> arg0 center-z) (-> arg0 radius-z))) + (>= (+ (-> arg0 center-z) (-> arg0 radius-z)) (-> arg1 z)) + (>= (+ (-> arg1 y) arg2) (- (-> arg0 center-y) (-> arg0 radius-y))) + (>= (+ (-> arg0 center-y) (-> arg0 radius-y)) (- (-> arg1 y) arg2)) + ) + ) + +;; definition for function point-inside-poly? +(defun point-inside-poly? ((arg0 nav-mesh) (arg1 uint) (arg2 vector) (arg3 float)) + (local-vars (v1-6 float) (v1-7 int) (v1-9 int) (a0-3 float) (a0-4 int) (a0-6 int) (a1-6 float) (a1-7 int)) + (rlet ((acc :class vf) + (vf1 :class vf) + (vf10 :class vf) + (vf11 :class vf) + (vf12 :class vf) + (vf13 :class vf) + (vf14 :class vf) + (vf15 :class vf) + (vf2 :class vf) + (vf3 :class vf) + (vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + (vf9 :class vf) + ) + (let ((t0-0 (-> arg0 poly arg1))) + (when (zero? (logand (-> t0-0 pat) 1)) + (let ((v1-5 (-> arg0 vertex (-> t0-0 vertex 0))) + (a1-5 (-> arg0 vertex (-> t0-0 vertex 1))) + (a0-2 (-> arg0 vertex (-> t0-0 vertex 2))) + ) + 0.0 + (let ((f0-3 (fabs (- (-> arg2 y) (* 0.333333 (+ (-> v1-5 y) (-> a1-5 y) (-> a0-2 y))))))) + (when (>= arg3 f0-3) + (.lvf vf1 (&-> v1-5 quad)) + (.lvf vf2 (&-> a1-5 quad)) + (.sub.vf vf1 vf1 vf1 :mask #b1010) + (.lvf vf3 (&-> a0-2 quad)) + (.sub.vf vf2 vf2 vf2 :mask #b1010) + (.lvf vf12 (&-> arg2 quad)) + (.sub.vf vf3 vf3 vf3 :mask #b1010) + (.sub.vf vf4 vf2 vf1) + (.sub.vf vf9 vf1 vf12) + (.sub.vf vf5 vf3 vf2) + (.sub.vf vf10 vf2 vf12) + (.sub.vf vf6 vf1 vf3) + (.sub.vf vf11 vf3 vf12) + (.outer.product.a.vf acc vf9 vf4) + (.outer.product.b.vf vf13 vf4 vf9 acc) + (.outer.product.a.vf acc vf10 vf5) + (.outer.product.b.vf vf14 vf5 vf10 acc) + (.outer.product.a.vf acc vf11 vf6) + (.outer.product.b.vf vf15 vf6 vf11 acc) + (.mov v1-6 vf13) + (.mov a1-6 vf14) + (.mov a0-3 vf15) + (set-on-less-than v1-7 v1-6 0) + (set-on-less-than a1-7 a1-6 0) + (set-on-less-than a0-4 a0-3 0) + (let ((a0-5 (logxor a1-7 a0-4)) + (v1-8 (logxor v1-7 a1-7)) + ) + (set-on-less-than a0-6 a0-5 1) + (set-on-less-than v1-9 v1-8 1) + ) + (if (logtest? v1-9 a0-6) + (return #t) + ) + ) + ) + ) + ) + ) + #f + ) + ) + +;; definition for function recursive-inside-poly +(defun recursive-inside-poly ((arg0 nav-mesh) (arg1 nav-node) (arg2 vector) (arg3 float)) + (when (point-inside-rect? arg1 arg2 arg3) + (cond + ((zero? (-> arg1 type)) + (let ((v1-2 (-> arg1 left-offset)) + (s3-0 (-> arg1 right-offset)) + ) + (when (>= v1-2 0) + (let* ((a1-2 (the-as nav-node (&+ (the-as (pointer nav-node) (-> arg0 nodes)) v1-2))) + (v1-3 (recursive-inside-poly arg0 a1-2 arg2 arg3)) + ) + (if (>= v1-3 0) + (return v1-3) + ) + ) + ) + (when (>= s3-0 0) + (let* ((a1-3 (&+ (the-as (pointer nav-node) (-> arg0 nodes)) s3-0)) + (v1-7 (recursive-inside-poly arg0 (the-as nav-node a1-3) arg2 arg3)) + ) + (if (>= v1-7 0) + (return v1-7) + ) + ) + ) + ) + (return -1) + ) + (else + (let ((s3-1 (-> arg1 num-tris)) + (s2-1 (-> arg1 first-tris)) + ) + (dotimes (s1-0 (the-as int s3-1)) + (let ((s0-0 (-> s2-1 0))) + (if (point-inside-poly? arg0 s0-0 arg2 arg3) + (return (the-as int s0-0)) + ) + ) + (set! s2-1 (&-> s2-1 1)) + (if (= s1-0 3) + (set! s2-1 (&-> s2-1 4)) + ) + ) + ) + (return -1) + ) + ) + (the-as none 0) + ) + -1 + ) + +;; definition for method 27 of type nav-mesh +;; Used lq/sq +(defmethod find-poly-fast nav-mesh ((obj nav-mesh) (arg0 vector) (arg1 meters)) + (local-vars (a0-6 symbol) (a2-3 uint128) (a2-4 uint128)) + -1 + (let ((s2-0 -1) + (s3-0 (-> *display* base-frame-counter)) + (f0-0 (-> obj bounds w)) + ) + (when (>= (* f0-0 f0-0) (vector-length-squared arg0)) + (dotimes (v1-3 4) + (set! a0-6 (and (= (-> obj cache v1-3 time) s3-0) + (= (-> obj cache v1-3 vec w) arg1) + (begin + (let ((a3-0 (-> obj cache v1-3)) + (a2-1 arg0) + ) + (set! a0-6 #t) + (let* ((a1-3 #xffff) + (a3-1 (-> a3-0 vec quad)) + (a1-4 (shl a1-3 48)) + ) + (let ((a2-2 (-> a2-1 quad))) + (.pceqw a2-3 a3-1 a2-2) + ) + (.ppach a2-4 (the-as uint128 0) a2-3) + (b! (= (logior (the-as int a2-4) a1-4) -1) cfg-10 :delay (nop!)) + ) + ) + #f + ) + ) + ) + (label cfg-10) + (if a0-6 + (return (-> obj poly (-> obj cache v1-3 poly-ind))) + ) + (if (and (< s2-0 0) (!= (-> obj cache v1-3 time) s3-0)) + (set! s2-0 v1-3) + ) + ) + (let ((v1-12 (recursive-inside-poly obj (-> obj nodes 0) arg0 arg1))) + (when (>= v1-12 0) + (when (>= s2-0 0) + (let ((a0-24 (-> obj cache s2-0))) + (set! (-> a0-24 vec x) (-> arg0 x)) + (set! (-> a0-24 vec y) (-> arg0 y)) + (set! (-> a0-24 vec z) (-> arg0 z)) + (set! (-> a0-24 vec w) arg1) + (set! (-> a0-24 time) (the-as uint s3-0)) + (set! (-> a0-24 poly-ind) (the-as uint v1-12)) + ) + ) + (return (-> obj poly v1-12)) + ) + ) + ) + ) + (the-as nav-poly #f) + ) + +;; definition for function circle-triangle-intersection-proc? +(defun circle-triangle-intersection-proc? ((arg0 vector) (arg1 float) (arg2 (inline-array nav-vertex))) + (let ((v1-0 0)) + (dotimes (a3-0 3) + (let* ((t0-4 (-> arg2 (-> *edge-vert0-table* a3-0))) + (t1-4 (-> arg2 (-> *edge-vert1-table* a3-0))) + (f0-1 (- (-> t0-4 z) (-> t1-4 z))) + (f1-2 (- (-> t1-4 x) (-> t0-4 x))) + (f2-2 (- (-> arg0 x) (-> t0-4 x))) + (f3-2 (- (-> arg0 z) (-> t0-4 z))) + (f4-1 f0-1) + (f4-3 (* f4-1 f4-1)) + (f5-0 f1-2) + (f4-5 (sqrtf (+ f4-3 (* f5-0 f5-0)))) + (f4-7 (/ 1.0 f4-5)) + (f0-2 (* f0-1 f4-7)) + (f1-3 (* f1-2 f4-7)) + (f0-4 (+ (* f2-2 f0-2) (* f3-2 f1-3))) + ) + (cond + ((< arg1 f0-4) + (return #f) + ) + ((< f0-4 0.0) + (+! v1-0 (-> *edge-mask-table* a3-0)) + ) + ) + ) + ) + (if (= v1-0 7) + (return #t) + ) + (let ((t0-15 #f) + (a3-5 0) + ) + (cond + ((= v1-0 1) + (set! t0-15 #t) + (set! a3-5 0) + ) + ((= v1-0 2) + (set! t0-15 #t) + (set! a3-5 1) + ) + ((= v1-0 4) + (set! t0-15 #t) + (set! a3-5 2) + ) + ((= v1-0 6) + (set! a3-5 0) + ) + ((= v1-0 5) + (set! a3-5 1) + ) + ((= v1-0 3) + (set! a3-5 2) + ) + ) + (when (not t0-15) + (let* ((t0-16 (-> arg2 (-> *edge-vert0-table* a3-5))) + (v1-18 (the-as vector (-> arg2 (-> *edge-vert1-table* a3-5)))) + (f1-8 (- (-> v1-18 x) (-> t0-16 x))) + (f0-7 (- (-> v1-18 z) (-> t0-16 z))) + (f2-7 (+ (* f1-8 (- (-> arg0 x) (-> t0-16 x))) (* f0-7 (- (-> arg0 z) (-> t0-16 z))))) + (f0-9 (+ (* f1-8 (- (-> arg0 x) (-> v1-18 x))) (* f0-7 (- (-> arg0 z) (-> v1-18 z))))) + ) + (cond + ((< f2-7 0.0) + (set! t0-15 #t) + (set! a3-5 (-> *edge-vert0-table* a3-5)) + ) + ((< 0.0 f0-9) + (set! t0-15 #t) + (set! a3-5 (-> *edge-vert1-table* a3-5)) + ) + (else + (return #t) + ) + ) + ) + ) + (when t0-15 + (let* ((v1-28 (-> arg2 a3-5)) + (f0-11 (- (-> v1-28 x) (-> arg0 x))) + (f0-13 (* f0-11 f0-11)) + (f1-14 (- (-> v1-28 z) (-> arg0 z))) + (f0-14 (+ f0-13 (* f1-14 f1-14))) + (f1-17 arg1) + ) + (if (>= (* f1-17 f1-17) f0-14) + #t + ) + ) + ) + ) + ) + ) + +;; definition for function circle-triangle-intersection? +(defun circle-triangle-intersection? ((arg0 vector) (arg1 float) (arg2 (inline-array nav-vertex))) + (let ((v1-0 arg0) + (f0-0 arg1) + (a0-1 arg2) + (a1-1 0) + ) + (dotimes (a2-1 3) + (let* ((a3-4 (-> a0-1 (-> *edge-vert0-table* a2-1))) + (t0-4 (-> a0-1 (-> *edge-vert1-table* a2-1))) + (f1-1 (- (-> a3-4 z) (-> t0-4 z))) + (f2-2 (- (-> t0-4 x) (-> a3-4 x))) + (f3-2 (- (-> v1-0 x) (-> a3-4 x))) + (f4-2 (- (-> v1-0 z) (-> a3-4 z))) + (f5-1 f1-1) + (f5-3 (* f5-1 f5-1)) + (f6-0 f2-2) + (f5-5 (sqrtf (+ f5-3 (* f6-0 f6-0)))) + (f5-7 (/ 1.0 f5-5)) + (f1-2 (* f1-1 f5-7)) + (f2-3 (* f2-2 f5-7)) + (f1-4 (+ (* f3-2 f1-2) (* f4-2 f2-3))) + ) + (cond + ((< f0-0 f1-4) + (return #f) + ) + ((< f1-4 0.0) + (+! a1-1 (-> *edge-mask-table* a2-1)) + ) + ) + ) + ) + (if (= a1-1 7) + (return #t) + ) + (let ((a3-15 #f) + (a2-6 0) + ) + (cond + ((= a1-1 1) + (set! a3-15 #t) + (set! a2-6 0) + ) + ((= a1-1 2) + (set! a3-15 #t) + (set! a2-6 1) + ) + ((= a1-1 4) + (set! a3-15 #t) + (set! a2-6 2) + ) + ((= a1-1 6) + (set! a2-6 0) + ) + ((= a1-1 5) + (set! a2-6 1) + ) + ((= a1-1 3) + (set! a2-6 2) + ) + ) + (when (not a3-15) + (let* ((a3-16 (-> a0-1 (-> *edge-vert0-table* a2-6))) + (a1-18 (-> a0-1 (-> *edge-vert1-table* a2-6))) + (f2-7 (- (-> a1-18 x) (-> a3-16 x))) + (f1-7 (- (-> a1-18 z) (-> a3-16 z))) + (f3-7 (+ (* f2-7 (- (-> v1-0 x) (-> a3-16 x))) (* f1-7 (- (-> v1-0 z) (-> a3-16 z))))) + (f1-9 (+ (* f2-7 (- (-> v1-0 x) (-> a1-18 x))) (* f1-7 (- (-> v1-0 z) (-> a1-18 z))))) + ) + (cond + ((< f3-7 0.0) + (set! a3-15 #t) + (set! a2-6 (-> *edge-vert0-table* a2-6)) + ) + ((< 0.0 f1-9) + (set! a3-15 #t) + (set! a2-6 (-> *edge-vert1-table* a2-6)) + ) + (else + (return #t) + ) + ) + ) + ) + (when a3-15 + (let* ((a0-2 (-> a0-1 a2-6)) + (f1-11 (- (-> a0-2 x) (-> v1-0 x))) + (f1-13 (* f1-11 f1-11)) + (f2-13 (- (-> a0-2 z) (-> v1-0 z))) + (f1-14 (+ f1-13 (* f2-13 f2-13))) + ) + (if (>= (* f0-0 f0-0) f1-14) + #t + ) + ) + ) + ) + ) + ) + +;; definition for method 29 of type nav-mesh +(defmethod is-in-mesh? nav-mesh ((obj nav-mesh) (arg0 vector) (arg1 float) (arg2 meters)) + (local-vars (v1-10 float)) + (rlet ((vf1 :class vf) + (vf2 :class vf) + (vf3 :class vf) + (vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + (vf7 :class vf) + ) + (let ((f0-1 (+ arg1 (-> obj bounds w)))) + (when (>= (* f0-1 f0-1) (vector-length-squared arg0)) + (let ((s2-0 (new 'stack-no-clear 'inline-array 'nav-vertex 6)) + (f30-1 0.33333334) + ) + (countdown (s1-0 (-> obj poly-count)) + (set! *debug-traverse* (+ *debug-traverse* 1)) + (let ((a0-3 (-> obj poly s1-0))) + (when (zero? (logand (-> a0-3 pat) 1)) + (nop!) + (let ((v1-8 (the-as object (-> obj vertex)))) + (nop!) + (let ((a2-1 (-> a0-3 vertex 0))) + (nop!) + (let* ((a1-1 (-> a0-3 vertex 1)) + (a2-2 (* a2-1 16)) + (a3-1 (-> a0-3 vertex 2)) + (a1-2 (* a1-1 16)) + (a0-4 (+ a2-2 (the-as int v1-8))) + (a2-3 (* a3-1 16)) + (a1-3 (+ a1-2 (the-as int v1-8))) + (v1-9 (+ a2-3 (the-as int v1-8))) + ) + (.lvf vf3 a0-4) + (let ((a0-5 f30-1)) + (.mov vf7 a0-5) + ) + (.lvf vf4 a1-3) + (.lvf vf5 v1-9) + ) + ) + ) + (.min.vf vf1 vf3 vf4 :mask #b111) + (.lvf vf6 (&-> arg0 quad)) + (.add.y.vf vf7 vf3 vf4 :mask #b10) + (.svf (&-> s2-0 0 quad) vf3) + (.max.vf vf2 vf3 vf4 :mask #b111) + (.svf (&-> s2-0 1 quad) vf4) + (.min.vf vf1 vf1 vf5 :mask #b111) + (.svf (&-> s2-0 2 quad) vf5) + (.max.vf vf2 vf2 vf5 :mask #b111) + (.mul.x.vf vf7 vf7 vf7 :mask #b10) + (.svf (&-> s2-0 3 quad) vf1) + (.svf (&-> s2-0 4 quad) vf2) + (.sub.y.vf vf7 vf6 vf7 :mask #b10) + (.mov v1-10 vf7) + (let ((v1-11 (the-as number (sar (the-as int v1-10) 32)))) + (when (and (>= arg2 (fabs (the-as float v1-11))) + (>= (+ (-> arg0 x) arg1) (-> s2-0 3 x)) + (>= (-> s2-0 4 x) (- (-> arg0 x) arg1)) + (>= (+ (-> arg0 z) arg1) (-> s2-0 3 z)) + (>= (-> s2-0 4 z) (- (-> arg0 z) arg1)) + ) + (set! *debug-tests* (+ *debug-tests* 1)) + (if (circle-triangle-intersection? arg0 arg1 s2-0) + (return #t) + ) + ) + ) + ) + ) + ) + ) + ) + ) + #f + ) + ) + +;; definition for method 14 of type nav-mesh +;; INFO: Return type mismatch int vs none. +;; Used lq/sq +(defmethod move-along-nav-ray! nav-mesh ((obj nav-mesh) (arg0 nav-ray)) + (local-vars (a2-7 int) (a3-3 int)) + (let ((v1-0 -1) + (f0-1 (- (-> arg0 dest-pos x) (-> arg0 current-pos x))) + (f1-2 (- (-> arg0 dest-pos z) (-> arg0 current-pos z))) + ) + (dotimes (a2-0 3) + (let* ((a3-1 (-> obj vertex (-> arg0 current-poly vertex (-> *edge-vert0-table* a2-0)))) + (t0-7 (-> obj vertex (-> arg0 current-poly vertex (-> *edge-vert1-table* a2-0)))) + (f4-0 (- (-> a3-1 z) (-> t0-7 z))) + (f3-2 (- (-> t0-7 x) (-> a3-1 x))) + (f2-4 (+ (* f0-1 f4-0) (* f1-2 f3-2))) + ) + (when (< 0.0 f2-4) + (let ((f3-4 (+ (* f4-0 (- (-> a3-1 x) (-> arg0 current-pos x))) (* f3-2 (- (-> a3-1 z) (-> arg0 current-pos z)))))) + (when (< f3-4 f2-4) + (set! v1-0 a2-0) + (let ((f2-6 (fmax 0.0 (/ f3-4 f2-4)))) + (set! f0-1 (* f0-1 f2-6)) + (set! f1-2 (* f1-2 f2-6)) + ) + ) + ) + ) + ) + ) + (let ((f2-9 (+ (* f0-1 (-> arg0 dir x)) (* f1-2 (-> arg0 dir z))))) + (+! (-> arg0 len) f2-9) + ) + 0 + (set! (-> arg0 next-poly) #f) + (cond + ((= v1-0 -1) + (set! (-> arg0 current-pos quad) (-> arg0 dest-pos quad)) + (set! (-> arg0 reached-dest) #t) + (set! (-> arg0 terminated) #t) + ) + (else + (+! (-> arg0 current-pos x) f0-1) + (+! (-> arg0 current-pos z) f1-2) + (let ((a2-6 (+ v1-0 1))) + (let ((a3-2 2)) + (set-on-less-than a3-3 a3-2 a2-6) + ) + (move-if-not-zero a2-7 0 a3-3 a2-6) + ) + (let ((a2-9 (-> arg0 current-poly adj-poly a2-7))) + (if (!= a2-9 255) + (set! (-> arg0 next-poly) (-> obj poly a2-9)) + ) + ) + (cond + ((and (-> arg0 next-poly) (zero? (logand (-> arg0 next-poly pat) 1))) + (set! (-> arg0 current-poly) (-> arg0 next-poly)) + ) + (else + (set! (-> arg0 last-edge) v1-0) + (if (-> arg0 next-poly) + (set! (-> arg0 hit-gap) #t) + (set! (-> arg0 hit-boundary) #t) + ) + (set! (-> arg0 terminated) #t) + ) + ) + ) + ) + ) + 0 + (none) + ) + +;; definition for function init-ray +(defun init-ray ((arg0 nav-ray)) + (vector-! (-> arg0 dir) (-> arg0 dest-pos) (-> arg0 current-pos)) + (set! (-> arg0 dir y) 0.0) + (vector-xz-normalize! (-> arg0 dir) 1.0) + (set! (-> arg0 next-poly) #f) + (set! (-> arg0 len) 0.0) + (set! (-> arg0 last-edge) -1) + (set! (-> arg0 terminated) #f) + (set! (-> arg0 reached-dest) #f) + (set! (-> arg0 hit-boundary) #f) + (set! (-> arg0 hit-gap) #f) + #f + ) + +;; definition for function init-ray-local +;; Used lq/sq +(defun init-ray-local ((arg0 nav-ray) (arg1 nav-poly) (arg2 vector) (arg3 vector)) + (set! (-> arg0 current-pos quad) (-> arg2 quad)) + (set! (-> arg0 dest-pos quad) (-> arg3 quad)) + (set! (-> arg0 current-poly) arg1) + (init-ray arg0) + ) + +;; definition for function init-ray-dir-local +;; Used lq/sq +(defun init-ray-dir-local ((arg0 nav-ray) (arg1 nav-poly) (arg2 vector) (arg3 vector) (arg4 float)) + (set! (-> arg0 current-poly) arg1) + (set! (-> arg0 current-pos quad) (-> arg2 quad)) + (vector+*! (-> arg0 dest-pos) (-> arg0 current-pos) arg3 arg4) + (init-ray arg0) + ) + +;; definition for method 15 of type nav-mesh +(defmethod try-move-along-ray nav-mesh ((obj nav-mesh) (arg0 nav-poly) (arg1 vector) (arg2 vector) (arg3 float)) + (local-vars (v1-2 symbol)) + (let ((gp-0 (new 'stack-no-clear 'nav-ray))) + (let ((s4-0 0)) + (init-ray-dir-local gp-0 arg0 arg1 arg2 arg3) + (until v1-2 + (+! s4-0 1) + (move-along-nav-ray! obj gp-0) + (set! v1-2 (or (>= s4-0 15) (-> gp-0 terminated))) + ) + ) + (-> gp-0 len) + ) + ) + +;; definition for function nav-ray-test +(defun nav-ray-test ((arg0 nav-mesh) (arg1 nav-poly) (arg2 vector) (arg3 vector)) + (let ((s4-1 (vector-! (new 'stack-no-clear 'vector) arg2 (-> arg0 origin))) + (s3-1 (vector-! (new 'stack-no-clear 'vector) arg3 arg2)) + ) + 0.0 + (set! (-> s3-1 y) 0.0) + (let ((f30-0 (vector-vector-xz-distance arg2 arg3))) + (vector-xz-normalize! s3-1 1.0) + (try-move-along-ray arg0 arg1 s4-1 s3-1 f30-0) + ) + ) + ) + +;; definition for function nav-ray-test-local? +(defun nav-ray-test-local? ((arg0 nav-mesh) (arg1 nav-poly) (arg2 vector) (arg3 vector)) + (local-vars (v1-2 symbol)) + (let ((gp-0 (new 'stack-no-clear 'nav-ray))) + (let ((s4-0 0)) + (init-ray-local gp-0 arg1 arg2 arg3) + (until v1-2 + (+! s4-0 1) + (move-along-nav-ray! arg0 gp-0) + (set! v1-2 (or (>= s4-0 15) (-> gp-0 terminated))) + ) + ) + (-> gp-0 reached-dest) + ) + ) + +;; definition for function nav-mesh-update-route-table +;; INFO: Return type mismatch int vs uint. +(defun nav-mesh-update-route-table ((arg0 nav-mesh) (arg1 int) (arg2 int) (arg3 uint)) + (let* ((a1-1 (* (+ arg2 (* arg1 (-> arg0 poly-count))) 2)) + (v1-3 (/ a1-1 8)) + (a2-2 (- a1-1 (* v1-3 8))) + (a1-4 (lognot (ash 3 a2-2))) + (v0-0 (logior (ash (logand arg3 3) a2-2) (logand a1-4 (-> (the-as (pointer uint8) (-> arg0 route)) v1-3)))) + ) + (set! (-> (the-as (pointer uint8) (-> arg0 route)) v1-3) (the-as uint v0-0)) + (the-as uint v0-0) + ) + ) + +;; definition for function nav-mesh-lookup-route +(defun nav-mesh-lookup-route ((arg0 nav-mesh) (arg1 int) (arg2 int)) + (let ((v1-3 (* (+ arg1 (* arg2 (-> arg0 poly-count))) 2))) + (logand (ash (-> (the-as (pointer uint8) (-> arg0 route)) (/ v1-3 8)) (- (logand v1-3 7))) 3) + ) + ) + +;; definition for symbol *nav-update-route-table-ray-count*, type int +(define *nav-update-route-table-ray-count* 0) + +;; definition for symbol *nav-update-route-table-route-count*, type int +(define *nav-update-route-table-route-count* 0) + +;; definition for method 18 of type nav-mesh +;; INFO: Return type mismatch int vs none. +;; Used lq/sq +(defmethod dummy-18 nav-mesh ((obj nav-mesh) (arg0 int) (arg1 vector) (arg2 int) (arg3 (pointer int8)) (arg4 int)) + (local-vars (sv-32 int) (sv-48 uint)) + (set! (-> arg3 arg2) 1) + (nav-mesh-update-route-table obj arg0 arg2 (the-as uint 3)) + (nav-mesh-update-route-table obj arg2 arg0 (the-as uint 3)) + (set! *nav-update-route-table-route-count* (+ *nav-update-route-table-route-count* 1)) + (when (> arg4 0) + (let ((s1-1 (-> obj poly arg2)) + (s0-0 (new 'stack-no-clear 'vector)) + ) + (set! sv-32 0) + (while (< sv-32 3) + (set! sv-48 (-> (the-as nav-poly (+ sv-32 (the-as int s1-1))) adj-poly 0)) + (when (and (!= sv-48 255) (!= 1 (-> (the-as (pointer uint8) (&+ arg3 sv-48))))) + (set! (-> arg3 sv-48) 1) + (when (zero? (logand (-> obj poly sv-48 pat) 1)) + (let ((v0-3 (= (nav-mesh-lookup-route obj arg0 (the-as int sv-48)) 3))) + (when (not v0-3) + (tri-centroid-local obj s1-1 s0-0) + (set! *nav-update-route-table-ray-count* (+ *nav-update-route-table-ray-count* 1)) + (set! v0-3 (nav-ray-test-local? obj (-> obj poly arg0) arg1 s0-0)) + ) + (when v0-3 + (let* ((a0-16 obj) + (t9-5 (method-of-object a0-16 dummy-18)) + (a1-7 arg0) + (a2-6 arg1) + (t0-1 arg3) + (t1-1 (+ arg4 -1)) + ) + (t9-5 a0-16 a1-7 a2-6 (the-as int sv-48) t0-1 t1-1) + ) + ) + ) + ) + ) + (set! sv-32 (+ sv-32 1)) + ) + ) + ) + 0 + (none) + ) + +;; definition for method 17 of type nav-mesh +;; INFO: Return type mismatch int vs none. +(defmethod update-route-table nav-mesh ((obj nav-mesh)) + (when *nav-patch-route-table* + (stopwatch-init *nav-timer*) + (stopwatch-begin *nav-timer*) + (let ((s5-0 (new 'stack-no-clear 'vector))) + (new 'stack-no-clear 'vector) + (let ((s4-0 (new 'stack-no-clear 'array 'int8 256))) + (set! *nav-update-route-table-ray-count* 0) + (set! *nav-update-route-table-route-count* 0) + (countdown (s3-0 (-> obj poly-count)) + (let ((s2-0 (-> obj poly s3-0))) + (when (zero? (logand (-> s2-0 pat) 1)) + (tri-centroid-local obj s2-0 s5-0) + (mem-set32! s4-0 64 0) + (set! (-> s4-0 s3-0) 1) + (dotimes (s1-0 3) + (let ((a3-0 (-> s2-0 adj-poly s1-0))) + (when (!= a3-0 255) + (if (zero? (logand (-> obj poly a3-0 pat) 1)) + (dummy-18 obj s3-0 s5-0 (the-as int a3-0) s4-0 0) + ) + ) + ) + ) + ) + ) + ) + ) + ) + (stopwatch-end *nav-timer*) + ) + 0 + (none) + ) + +;; definition for function point-triangle-distance-min +(defun point-triangle-distance-min ((arg0 vector) (arg1 float) (arg2 (inline-array nav-vertex))) + (let ((v1-0 0) + (f0-0 arg1) + ) + (dotimes (a3-0 3) + (let* ((t0-4 (-> arg2 (-> *edge-vert0-table* a3-0))) + (t1-4 (-> arg2 (-> *edge-vert1-table* a3-0))) + (f1-1 (- (-> t0-4 z) (-> t1-4 z))) + (f2-2 (- (-> t1-4 x) (-> t0-4 x))) + (f3-2 (- (-> arg0 x) (-> t0-4 x))) + (f4-2 (- (-> arg0 z) (-> t0-4 z))) + (f5-1 f1-1) + (f5-3 (* f5-1 f5-1)) + (f6-0 f2-2) + (f5-5 (sqrtf (+ f5-3 (* f6-0 f6-0)))) + (f5-7 (/ 1.0 f5-5)) + (f1-2 (* f1-1 f5-7)) + (f2-3 (* f2-2 f5-7)) + (f1-4 (+ (* f1-2 f3-2) (* f2-3 f4-2))) + ) + (cond + ((< arg1 f1-4) + (return arg1) + ) + ((>= 0.0 f1-4) + (+! v1-0 (-> *edge-mask-table* a3-0)) + ) + (else + (set! f0-0 f1-4) + ) + ) + ) + ) + (if (= v1-0 7) + (return 0.0) + ) + (let ((t0-14 #f) + (a3-5 0) + ) + (cond + ((= v1-0 1) + (set! t0-14 #t) + (set! a3-5 0) + ) + ((= v1-0 2) + (set! t0-14 #t) + (set! a3-5 1) + ) + ((= v1-0 4) + (set! t0-14 #t) + (set! a3-5 2) + ) + ((= v1-0 6) + (set! a3-5 0) + ) + ((= v1-0 5) + (set! a3-5 1) + ) + ((= v1-0 3) + (set! a3-5 2) + ) + ) + (when (not t0-14) + (let* ((t0-15 (-> arg2 (-> *edge-vert0-table* a3-5))) + (v1-17 (-> arg2 (-> *edge-vert1-table* a3-5))) + (f2-8 (- (-> v1-17 x) (-> t0-15 x))) + (f1-7 (- (-> v1-17 z) (-> t0-15 z))) + (f3-7 (+ (* f2-8 (- (-> arg0 x) (-> t0-15 x))) (* f1-7 (- (-> arg0 z) (-> t0-15 z))))) + (f1-9 (+ (* f2-8 (- (-> arg0 x) (-> v1-17 x))) (* f1-7 (- (-> arg0 z) (-> v1-17 z))))) + ) + (cond + ((< f3-7 0.0) + (set! t0-14 #t) + (set! a3-5 (-> *edge-vert0-table* a3-5)) + ) + ((< 0.0 f1-9) + (set! t0-14 #t) + (set! a3-5 (-> *edge-vert1-table* a3-5)) + ) + (else + (return f0-0) + ) + ) + ) + ) + (when t0-14 + (let* ((v1-27 (-> arg2 a3-5)) + (f0-2 (- (-> v1-27 x) (-> arg0 x))) + (f0-4 (* f0-2 f0-2)) + (f1-12 (- (-> v1-27 z) (-> arg0 z))) + ) + (set! f0-0 (fmin (sqrtf (+ f0-4 (* f1-12 f1-12))) arg1)) + ) + ) + ) + f0-0 + ) + ) + +;; definition for method 28 of type nav-mesh +;; Used lq/sq +(defmethod find-poly nav-mesh ((obj nav-mesh) (arg0 vector) (arg1 meters) (arg2 (pointer nav-control-flags))) + (local-vars (s3-1 nav-poly)) + (let ((v1-1 (find-poly-fast obj arg0 arg1))) + (when v1-1 + (if arg2 + (set! (-> arg2 0) (logior (nav-control-flags bit20) (-> arg2 0))) + ) + (set! s3-1 v1-1) + (goto cfg-14) + ) + ) + (if arg2 + (logclear! (-> arg2 0) (nav-control-flags bit20)) + ) + (let ((s2-0 (new 'stack-no-clear 'inline-array 'nav-vertex 3))) + (set! s3-1 (the-as nav-poly #f)) + (let ((f30-0 10000000000000000000000000000000000000.0)) + (countdown (s1-0 (-> obj poly-count)) + (let ((s0-0 (-> obj poly s1-0))) + (when (zero? (logand (-> s0-0 pat) 1)) + (set! (-> s2-0 0 quad) (-> obj vertex (-> s0-0 vertex 0) quad)) + (set! (-> s2-0 1 quad) (-> obj vertex (-> s0-0 vertex 1) quad)) + (set! (-> s2-0 2 quad) (-> obj vertex (-> s0-0 vertex 2) quad)) + (let ((f1-2 (- (-> arg0 y) (* 0.333333 (+ (-> s2-0 0 y) (-> s2-0 1 y) (-> s2-0 2 y)))))) + (when (>= arg1 (fabs f1-2)) + (let ((f0-2 (point-triangle-distance-min arg0 f30-0 s2-0))) + (when (< f0-2 f30-0) + (set! f30-0 f0-2) + (set! s3-1 s0-0) + ) + ) + ) + ) + ) + ) + ) + ) + ) + (label cfg-14) + s3-1 + ) + +;; definition for method 12 of type nav-mesh +(defmethod setup-portal nav-mesh ((obj nav-mesh) (arg0 nav-poly) (arg1 nav-poly) (arg2 nav-route-portal)) + (local-vars (t0-6 int) (t1-1 int)) + (set! (-> arg2 next-poly) #f) + (cond + ((and arg0 arg1) + (let* ((v1-3 (* (+ (-> arg1 id) (* (the-as int (-> arg0 id)) (-> obj poly-count))) 2)) + (v1-8 + (logand (ash (-> (the-as (pointer uint8) (-> obj route)) (/ (the-as int v1-3) 8)) (- (the-as int (logand v1-3 7)))) + 3 + ) + ) + ) + (set! (-> arg2 edge-index) -1) + (when (!= v1-8 3) + (let ((a2-9 (-> arg0 adj-poly v1-8))) + (when (!= a2-9 255) + (set! (-> arg2 edge-index) (the-as int v1-8)) + (set! (-> arg2 next-poly) (-> obj poly a2-9)) + (let ((a2-12 (-> obj vertex))) + (let ((t0-5 (+ v1-8 1))) + (let ((t1-0 2)) + (set-on-less-than t1-1 t1-0 t0-5) + ) + (move-if-not-zero t0-6 0 t1-1 t0-5) + ) + (set! (-> arg2 vertex 0) (-> a2-12 (-> arg0 vertex t0-6))) + ) + (set! (-> arg2 vertex 1) (-> obj vertex (-> arg0 vertex v1-8))) + #t + ) + ) + ) + ) + ) + (else + 0 + ) + ) + ) + +;; definition for method 11 of type nav-mesh +(defmethod get-adj-poly nav-mesh ((obj nav-mesh) (arg0 nav-poly) (arg1 nav-poly) (arg2 symbol)) + (local-vars (v1-12 uint) (t0-6 int) (t1-1 int)) + (cond + ((and arg0 arg1) + (let* ((v1-3 (* (+ (-> arg1 id) (* (the-as int (-> arg0 id)) (-> obj poly-count))) 2)) + (a2-6 + (logand (ash (-> (the-as (pointer uint8) (-> obj route)) (/ (the-as int v1-3) 8)) (- (the-as int (logand v1-3 7)))) + 3 + ) + ) + ) + (if arg2 + (set! (-> arg2 value) (the-as uint #xffffffff)) + ) + (cond + ((= a2-6 3) + (the-as nav-poly #f) + ) + ((begin (set! v1-12 (-> arg0 adj-poly a2-6)) (= v1-12 255)) + (the-as nav-poly #f) + ) + (else + (when arg2 + (let ((t0-5 (+ a2-6 1))) + (let ((t1-0 2)) + (set-on-less-than t1-1 t1-0 t0-5) + ) + (move-if-not-zero t0-6 0 t1-1 t0-5) + ) + (set! (-> arg2 value) (logior (-> arg0 vertex t0-6) (shl (-> arg0 vertex a2-6) 16))) + ) + (-> obj poly v1-12) + ) + ) + ) + ) + (else + (the-as nav-poly #f) + ) + ) + ) + +;; definition for method 19 of type nav-mesh +;; INFO: Return type mismatch int vs none. +(defmethod compute-bounding-box nav-mesh ((obj nav-mesh) (arg0 vector) (arg1 vector)) + (let ((f0-0 10000000000000000000000000000000000000.0) + (f1-0 -10000000000000000000000000000000000000.0) + ) + (set! (-> arg0 x) f0-0) + (set! (-> arg0 y) f0-0) + (set! (-> arg0 z) f0-0) + (set! (-> arg1 x) f1-0) + (set! (-> arg1 y) f1-0) + (set! (-> arg1 z) f1-0) + ) + (dotimes (v1-1 (-> obj vertex-count)) + (let ((a3-1 (-> obj vertex v1-1))) + (set! (-> arg0 x) (fmin (-> arg0 x) (-> a3-1 x))) + (set! (-> arg0 y) (fmin (-> arg0 y) (-> a3-1 y))) + (set! (-> arg0 z) (fmin (-> arg0 z) (-> a3-1 z))) + (set! (-> arg1 x) (fmax (-> arg1 x) (-> a3-1 x))) + (set! (-> arg1 y) (fmax (-> arg1 y) (-> a3-1 y))) + (set! (-> arg1 z) (fmax (-> arg1 z) (-> a3-1 z))) + ) + ) + (vector+! arg0 arg0 (-> obj origin)) + (vector+! arg1 arg1 (-> obj origin)) + 0 + (none) + ) + +;; definition for method 13 of type nav-mesh +;; INFO: Return type mismatch int vs none. +;; Used lq/sq +(defmethod initialize-mesh! nav-mesh ((obj nav-mesh)) + (local-vars (sv-32 vector) (sv-48 int)) + (with-pp + (set! sv-32 (new 'stack-no-clear 'vector)) + (let ((s5-0 (-> obj poly-count)) + (s3-0 (-> obj vertex-count)) + (s1-0 0) + (s2-0 0) + (s4-0 0) + (gp-0 #f) + ) + (set! sv-48 s5-0) + (while (nonzero? sv-48) + (set! sv-48 (+ sv-48 -1)) + (let ((v1-4 (-> obj poly sv-48))) + (if (logtest? (-> v1-4 pat) 1) + (+! s4-0 1) + ) + (let ((a1-2 (-> obj vertex (-> v1-4 vertex 0))) + (a2-2 (-> obj vertex (-> v1-4 vertex 1))) + (a3-0 (-> obj vertex (-> v1-4 vertex 2))) + ) + (vector-3pt-cross! sv-32 a1-2 a2-2 a3-0) + ) + ) + (cond + ((= (vector-length sv-32) 0.0) + (+! s1-0 1) + ) + (else + (vector-normalize! sv-32 1.0) + (if (>= 0.0 (-> sv-32 y)) + (+! s2-0 1) + ) + ) + ) + ) + (when (zero? s5-0) + (format #t "WARNING: nav-mesh has no triangles. ") + (set! gp-0 #t) + ) + (when (> s1-0 0) + (format #t "WARNING: nav-mesh has ~D triangles with zero area (out of ~D triangles). " s1-0 s5-0) + (set! gp-0 #t) + ) + (when (> s2-0 0) + (format #t "WARNING: nav-mesh has ~D triangles with inverted normals (out of ~D triangles). " s2-0 s5-0) + (set! gp-0 #t) + ) + (when (< 255 s5-0) + (format #t "WARNING: nav-mesh has ~D triangles (only up to ~D are allowed). " s5-0 255) + (set! gp-0 #t) + ) + (when (< 255 s3-0) + (format #t "WARNING: nav-mesh has ~D vertices (only up to ~D are allowed). " s3-0 255) + (set! gp-0 #t) + ) + (when (= s4-0 s5-0) + (format #t "WARNING: nav-mesh only contains gap triangles (~D triangles total). " s5-0) + (set! gp-0 #t) + ) + (when gp-0 + (if pp + (format #t "current process is ~A~%" (-> pp name)) + (format #t "(no current process).~%") + ) + ) + ) + 0 + (none) + ) + ) + +;; definition for method 22 of type nav-mesh +(defmethod find-opposite-vertices nav-mesh ((obj nav-mesh) (arg0 nav-poly) (arg1 nav-poly)) + (when (!= arg0 arg1) + (dotimes (v1-1 3) + (dotimes (a0-1 3) + (when (= (-> arg0 vertex v1-1) (-> arg1 vertex a0-1)) + (let ((a3-6 (-> arg0 vertex (mod (+ v1-1 1) 3)))) + (dotimes (t0-3 3) + (if (and (!= t0-3 a0-1) (= a3-6 (-> arg1 vertex t0-3))) + (return (logior a3-6 (shl (-> arg0 vertex v1-1) 16))) + ) + ) + ) + ) + ) + ) + ) + (the-as uint #xffffffff) + ) + +;; definition for function ray-ccw-line-segment-intersection? +(defun ray-ccw-line-segment-intersection? ((arg0 vector) (arg1 vector) (arg2 vector) (arg3 vector)) + (let ((f0-2 (- (* (-> arg2 x) (-> arg1 z)) (* (-> arg2 z) (-> arg1 x)))) + (f2-4 (- (* (-> arg3 x) (-> arg1 z)) (* (-> arg3 z) (-> arg1 x)))) + (f3-4 (- (* (-> arg0 x) (-> arg1 z)) (* (-> arg0 z) (-> arg1 x)))) + (v0-0 #f) + ) + (let ((f1-7 (- f2-4 f0-2)) + (f2-5 (- f2-4 f3-4)) + (f3-5 (- f3-4 f0-2)) + ) + (when (and (>= (fabs f1-7) (fmax (fabs f3-5) (fabs f2-5))) (!= f1-7 0.0)) + (let ((f0-7 (+ (* (-> arg1 x) (- (-> arg3 z) (-> arg2 z))) (* (-> arg1 z) (- (-> arg2 x) (-> arg3 x)))))) + (set! v0-0 (< 0.0 f0-7)) + ) + ) + ) + v0-0 + ) + ) + +;; definition for function ray-line-segment-intersection? +(defun ray-line-segment-intersection? ((arg0 vector) (arg1 vector) (arg2 vector) (arg3 vector)) + (let ((f1-3 (- (* (-> arg2 x) (-> arg1 z)) (* (-> arg2 z) (-> arg1 x)))) + (f0-4 (- (* (-> arg3 x) (-> arg1 z)) (* (-> arg3 z) (-> arg1 x)))) + (f2-6 (- (* (-> arg0 x) (-> arg1 z)) (* (-> arg0 z) (-> arg1 x)))) + (gp-0 #f) + ) + (let ((f30-0 (- f0-4 f1-3)) + (f0-5 (- f0-4 f2-6)) + (f1-4 (- f2-6 f1-3)) + ) + (when (and (>= (fabs f30-0) (fmax (fabs f1-4) (fabs f0-5))) (!= f30-0 0.0)) + (let ((f2-11 (+ (* (-> arg2 x) (-> arg1 x)) (* (-> arg2 z) (-> arg1 z)))) + (f3-11 (+ (* (-> arg3 x) (-> arg1 x)) (* (-> arg3 z) (-> arg1 z)))) + (f28-0 (+ (* (-> arg0 x) (-> arg1 x)) (* (-> arg0 z) (-> arg1 z)))) + ) + (if (>= (* (+ (* f2-11 f0-5) (* f3-11 f1-4)) (sign f30-0)) (* f28-0 (fabs f30-0))) + (set! gp-0 #t) + ) + ) + ) + ) + gp-0 + ) + ) + +;; definition for symbol *debug-offset*, type vector +(define *debug-offset* (new 'static 'vector :y 4096.0 :w 1.0)) + +;; definition for function clip-vector-to-halfspace! +(defun clip-vector-to-halfspace! ((arg0 vector) (arg1 float) (arg2 float) (arg3 float)) + (let ((f0-2 (+ (* arg1 (-> arg0 x)) (* arg2 (-> arg0 z))))) + (when (< arg3 f0-2) + (let ((f0-3 (/ arg3 f0-2))) + (set! (-> arg0 x) (* (-> arg0 x) f0-3)) + (let ((f0-4 (* (-> arg0 z) f0-3))) + (set! (-> arg0 z) f0-4) + f0-4 + ) + ) + ) + ) + ) + +;; definition for method 23 of type nav-mesh +;; Used lq/sq +(defmethod dummy-23 nav-mesh ((obj nav-mesh) (arg0 nav-poly) (arg1 vector) (arg2 vector) (arg3 vector) (arg4 nav-route-portal)) + (local-vars (v1-32 int) (a0-14 int) (a0-17 int) (a1-10 int) (sv-16 nav-vertex)) + (let ((s1-0 (-> obj vertex)) + (s0-0 -1) + ) + (set! (-> arg2 quad) (-> arg3 quad)) + (dotimes (v1-1 3) + (let* ((a0-8 (-> s1-0 (-> arg0 vertex (-> *edge-vert0-table* v1-1)))) + (a1-7 (-> s1-0 (-> arg0 vertex (-> *edge-vert1-table* v1-1)))) + (f0-1 (- (-> a0-8 z) (-> a1-7 z))) + (f1-2 (- (-> a1-7 x) (-> a0-8 x))) + (f2-4 (+ (* f0-1 (- (-> a0-8 x) (-> arg1 x))) (* f1-2 (- (-> a0-8 z) (-> arg1 z))))) + (f0-3 (+ (* (-> arg2 x) f0-1) (* (-> arg2 z) f1-2))) + ) + (when (< f2-4 f0-3) + (set! s0-0 v1-1) + (let ((f0-4 (/ f2-4 f0-3))) + (set! (-> arg2 x) (* (-> arg2 x) f0-4)) + (set! (-> arg2 z) (* (-> arg2 z) f0-4)) + ) + ) + ) + ) + (when arg4 + (cond + ((= s0-0 -1) + (set! (-> arg4 next-poly) #f) + ) + (else + (while (!= s0-0 -1) + (let ((v1-11 (-> arg0 adj-poly (-> *edge-vert0-table* s0-0)))) + (cond + ((!= v1-11 255) + (set! (-> arg4 next-poly) (-> obj poly v1-11)) + (set! s0-0 -1) + ) + ((let ((a1-8 (-> s1-0 (-> arg0 vertex (-> *edge-vert0-table* s0-0))))) + (set! sv-16 (-> s1-0 (-> arg0 vertex (-> *edge-vert1-table* s0-0)))) + (< (vector-vector-xz-distance arg1 a1-8) 204.8) + ) + (let ((a1-9 (+ s0-0 -1)) + (v1-28 2) + ) + (set-on-less-than a0-14 a1-9 0) + (move-if-not-zero a1-10 v1-28 a0-14 a1-9) + ) + (set! s0-0 a1-10) + ) + ((< (vector-vector-xz-distance arg1 sv-16) 204.8) + (let ((v1-31 (+ s0-0 1))) + (let ((a0-16 2)) + (set-on-less-than a0-17 a0-16 v1-31) + ) + (move-if-not-zero v1-32 0 a0-17 v1-31) + ) + (set! s0-0 v1-32) + ) + (else + (set! (-> arg4 next-poly) #f) + (set! s0-0 -1) + ) + ) + ) + ) + ) + ) + ) + ) + (set! (-> arg2 y) (-> arg1 y)) + arg2 + ) + +;; definition for method 25 of type nav-mesh +;; Used lq/sq +(defmethod project-point-into-tri-3d nav-mesh ((obj nav-mesh) (arg0 nav-poly) (arg1 vector) (arg2 vector)) + (let ((s3-0 (new 'stack-no-clear 'vector)) + (s4-0 (new 'stack-no-clear 'matrix)) + ) + (dotimes (v1-0 3) + (set! (-> s4-0 vector v1-0 quad) (the-as uint128 0)) + ) + (set! (-> s4-0 vector 0 quad) (-> obj vertex (-> arg0 vertex 0) quad)) + (set! (-> s4-0 vector 1 quad) (-> obj vertex (-> arg0 vertex 1) quad)) + (set! (-> s4-0 vector 2 quad) (-> obj vertex (-> arg0 vertex 2) quad)) + (normal-of-plane s3-0 (the-as vector (-> s4-0 vector)) (-> s4-0 vector 1) (-> s4-0 vector 2)) + (closest-pt-in-triangle arg1 arg2 s4-0 s3-0) + ) + (none) + ) + +;; definition for method 17 of type nav-control +;; Used lq/sq +(defmethod project-onto-nav-mesh nav-control ((obj nav-control) (arg0 vector) (arg1 vector)) + (local-vars (sv-32 int)) + (let ((s5-0 (-> obj mesh)) + (s3-1 (vector-! (new 'stack-no-clear 'vector) arg1 (-> obj mesh origin))) + ) + (set! sv-32 0) + (let ((a1-5 (find-poly s5-0 s3-1 (-> obj nearest-y-threshold) (the-as (pointer nav-control-flags) (& sv-32))))) + (cond + ((logtest? #x100000 sv-32) + (set! (-> arg0 quad) (-> arg1 quad)) + ) + (else + (closest-point-on-boundary s5-0 a1-5 arg0 s3-1) + (vector+! arg0 arg0 (-> s5-0 origin)) + ) + ) + ) + ) + arg0 + ) + +;; definition for method 18 of type nav-control +(defmethod find-poly nav-control ((obj nav-control) (arg0 vector)) + (find-poly + (-> obj mesh) + (vector-! (new 'stack-no-clear 'vector) arg0 (-> obj mesh origin)) + (-> obj nearest-y-threshold) + (the-as (pointer nav-control-flags) #f) + ) + ) + +;; definition for method 20 of type nav-control +(defmethod project-point-into-tri-3d nav-control ((obj nav-control) (arg0 nav-poly) (arg1 vector) (arg2 vector)) + (project-point-into-tri-3d + (-> obj mesh) + arg0 + arg1 + (vector-! (new 'stack-no-clear 'vector) arg2 (-> obj mesh origin)) + ) + (vector+! arg1 arg1 (-> obj mesh origin)) + arg1 + ) + +;; definition for method 25 of type nav-control +(defmethod is-in-mesh? nav-control ((obj nav-control) (arg0 vector) (arg1 float)) + (let ((v1-1 (vector-! (new 'stack-no-clear 'vector) arg0 (-> obj mesh origin))) + (a1-1 (-> obj mesh)) + ) + (is-in-mesh? a1-1 v1-1 arg1 (-> obj nearest-y-threshold)) + ) + ) + +;; definition for method 9 of type nav-control +;; INFO: Return type mismatch int vs none. +;; Used lq/sq +(defmethod debug-draw nav-control ((obj nav-control)) + (local-vars + (sv-192 vector) + (sv-208 uint) + (sv-224 int) + (sv-240 (function _varargs_ object)) + (sv-256 string) + (sv-272 int) + (sv-288 (function _varargs_ object)) + ) + (let ((a0-1 obj)) + (when (and *display-nav-marks* (logtest? (-> a0-1 flags) (nav-control-flags display-marks))) + (let ((s5-0 (-> obj mesh)) + (s4-0 (new 'stack-no-clear 'vector)) + ) + (= (-> obj mesh debug-time) (logand (-> *display* actual-frame-counter) 255)) + (when #t + (set! (-> s5-0 debug-time) (the-as uint (-> *display* actual-frame-counter))) + (add-debug-sphere + (logtest? (-> obj flags) (nav-control-flags bit1)) + (bucket-id debug-draw0) + (-> s5-0 bounds) + (-> s5-0 bounds w) + (new 'static 'rgba :r #xff :g #xff :a #x20) + ) + (add-debug-vector #t (bucket-id debug-draw1) (-> s5-0 origin) *x-vector* (meters 1.0) *color-red*) + (add-debug-vector #t (bucket-id debug-draw1) (-> s5-0 origin) *z-vector* (meters 1.0) *color-blue*) + (when (logtest? (-> obj flags) (nav-control-flags bit2)) + (dotimes (s3-0 (-> s5-0 vertex-count)) + (add-debug-x + #t + (bucket-id debug-draw1) + (vector+! s4-0 (-> s5-0 origin) (the-as vector (-> s5-0 vertex s3-0))) + *color-green* + ) + ) + ) + (when #f + (dotimes (s3-1 (-> s5-0 node-count)) + (let ((a1-4 (-> s5-0 nodes s3-1)) + (a0-15 (new 'stack-no-clear 'vector)) + (v1-20 (new 'stack-no-clear 'vector)) + ) + (set! sv-192 (new 'stack-no-clear 'vector)) + (let ((s2-0 (new 'stack-no-clear 'vector)) + (s1-0 (new 'stack-no-clear 'vector)) + (s0-0 (new 'stack-no-clear 'vector)) + ) + (set! sv-208 (the-as uint #x80808080)) + (set! (-> a0-15 quad) (-> a1-4 center quad)) + (set! (-> v1-20 quad) (-> a1-4 radius quad)) + (set! (-> sv-192 w) 1.0) + (set! (-> s2-0 w) 1.0) + (set! (-> s1-0 w) 1.0) + (set! (-> s0-0 w) 1.0) + (set! (-> sv-192 x) (+ (-> a0-15 x) (-> v1-20 x))) + (set! (-> sv-192 y) (+ (-> a0-15 y) (-> v1-20 y))) + (set! (-> sv-192 z) (+ (-> a0-15 z) (-> v1-20 z))) + (set! (-> s2-0 x) (+ (-> a0-15 x) (-> v1-20 x))) + (set! (-> s2-0 y) (+ (-> a0-15 y) (-> v1-20 y))) + (set! (-> s2-0 z) (- (-> a0-15 z) (-> v1-20 z))) + (set! (-> s1-0 x) (- (-> a0-15 x) (-> v1-20 x))) + (set! (-> s1-0 y) (+ (-> a0-15 y) (-> v1-20 y))) + (set! (-> s1-0 z) (- (-> a0-15 z) (-> v1-20 z))) + (set! (-> s0-0 x) (- (-> a0-15 x) (-> v1-20 x))) + (set! (-> s0-0 y) (+ (-> a0-15 y) (-> v1-20 y))) + (set! (-> s0-0 z) (+ (-> a0-15 z) (-> v1-20 z))) + (add-debug-line #t (bucket-id debug-draw1) sv-192 s2-0 (the-as rgba sv-208) #f (the-as rgba -1)) + (add-debug-line #t (bucket-id debug-draw1) s2-0 s1-0 (the-as rgba sv-208) #f (the-as rgba -1)) + (add-debug-line #t (bucket-id debug-draw1) s1-0 s0-0 (the-as rgba sv-208) #f (the-as rgba -1)) + (let ((t9-7 add-debug-line) + (a0-19 #t) + (a1-13 68) + (t1-5 #f) + (t2-3 -1) + ) + (t9-7 a0-19 (the-as bucket-id a1-13) s0-0 sv-192 (the-as rgba sv-208) t1-5 (the-as rgba t2-3)) + ) + ) + ) + ) + ) + (when (logtest? (-> obj flags) (nav-control-flags bit3)) + (dotimes (s3-2 (-> s5-0 poly-count)) + (let ((s2-1 (-> s5-0 poly s3-2))) + (debug-draw-poly s5-0 s2-1 (the-as rgba (cond + ((logtest? (-> s2-1 pat) 1) + #x40808000 + ) + ((logtest? (-> s2-1 pat) 2) + #x4080ff00 + ) + ((logtest? (-> s2-1 pat) 4) + (the-as int (the-as uint #x8040ff00)) + ) + ((logtest? (-> s2-1 pat) 8) + (the-as int (the-as uint #xff408000)) + ) + ((logtest? (-> s2-1 pat) 16) + (the-as int (the-as uint #xff408000)) + ) + (else + (the-as int (the-as uint #x80ff8000)) + ) + ) + ) + ) + (when (logtest? (-> obj flags) (nav-control-flags bit4)) + (let ((s1-1 add-debug-text-3d) + (s0-1 #t) + ) + (set! sv-224 68) + (set! sv-240 format) + (let ((a0-23 (clear *temp-string*)) + (a1-15 "~D") + (a2-13 (-> s2-1 id)) + ) + (sv-240 a0-23 a1-15 a2-13) + ) + (set! sv-256 *temp-string*) + (let ((a3-10 (tri-centroid-world s5-0 s2-1 s4-0)) + (t0-8 8) + (t1-6 #f) + ) + (s1-1 s0-1 (the-as bucket-id sv-224) sv-256 a3-10 (the-as font-color t0-8) (the-as vector2h t1-6)) + ) + ) + ) + ) + ) + ) + (when (logtest? (-> obj flags) (nav-control-flags bit5)) + (if (-> obj next-poly) + (debug-draw-poly s5-0 (-> obj next-poly) *color-cyan*) + ) + (if (-> obj target-poly) + (debug-draw-poly s5-0 (-> obj target-poly) *color-yellow*) + ) + (if (-> obj current-poly) + (debug-draw-poly s5-0 (-> obj current-poly) *color-red*) + ) + ) + (when (logtest? (-> obj flags) (nav-control-flags bit7)) + (dotimes (s3-3 (the-as int (-> s5-0 static-sphere-count))) + (let ((s2-2 (-> s5-0 static-sphere s3-3))) + (add-debug-sphere #t (bucket-id debug-draw0) (the-as vector s2-2) (-> s2-2 trans w) *color-blue*) + (let ((s1-2 add-debug-text-3d) + (s0-2 #t) + ) + (set! sv-272 68) + (set! sv-288 format) + (let ((a0-32 (clear *temp-string*)) + (a1-22 "~D") + (a2-20 s3-3) + ) + (sv-288 a0-32 a1-22 a2-20) + ) + (let ((a2-21 *temp-string*) + (t0-10 8) + (t1-7 #f) + ) + (s1-2 + s0-2 + (the-as bucket-id sv-272) + a2-21 + (the-as vector s2-2) + (the-as font-color t0-10) + (the-as vector2h t1-7) + ) + ) + ) + ) + ) + ) + ) + (when (logtest? (-> obj flags) (nav-control-flags bit6)) + (when (and (-> obj portal 0) (-> obj portal 1)) + (let ((v1-80 (-> s5-0 origin)) + (a2-22 (new 'stack-no-clear 'vector)) + (a3-13 (new 'stack-no-clear 'vector)) + ) + (add-debug-line + #t + (bucket-id debug-draw1) + (vector+! a2-22 v1-80 (the-as vector (-> obj portal 0))) + (vector+! a3-13 v1-80 (the-as vector (-> obj portal 1))) + (new 'static 'rgba :r #xff :g #x80 :b #x40 :a #x80) + #f + (the-as rgba -1) + ) + ) + ) + (add-debug-vector + #t + (bucket-id debug-draw1) + (-> obj shape trans) + (-> obj travel) + (meters 0.00024414062) + *color-white* + ) + (add-debug-vector + #t + (bucket-id debug-draw1) + (vector+! (new 'stack-no-clear 'vector) (-> obj shape trans) (new 'static 'vector :y 4096.0 :w 1.0)) + (-> obj old-travel) + (meters 0.00024414062) + *color-yellow* + ) + (add-debug-x + #t + (bucket-id debug-draw1) + (vector+! (new 'stack-no-clear 'vector) (-> obj shape trans) (-> obj travel)) + (new 'static 'rgba :r #xff :g #xff :b #xff :a #x80) + ) + ) + (when (logtest? (-> obj flags) (nav-control-flags bit7)) + (add-debug-sphere + #t + (bucket-id debug-draw1) + (the-as vector (-> obj shape root-prim prim-core)) + (-> obj shape nav-radius) + (new 'static 'rgba :g #xff :b #xff :a #x20) + ) + (dotimes (s3-4 (-> obj num-spheres)) + (let ((v1-95 (-> obj sphere s3-4))) + (vector+! s4-0 (-> s5-0 origin) (the-as vector (&-> v1-95 x))) + (add-debug-sphere + #t + (bucket-id debug-draw1) + s4-0 + (- (-> v1-95 w) (-> obj shape nav-radius)) + (new 'static 'rgba :g #xff :b #xff :a #x20) + ) + ) + ) + ) + ) + 0 + ) + ) + (none) + ) + +;; definition for method 8 of type nav-mesh +;; INFO: Return type mismatch int vs nav-mesh. +(defmethod mem-usage nav-mesh ((obj nav-mesh) (arg0 memory-usage-block) (arg1 int)) + (set! (-> arg0 length) (max 46 (-> arg0 length))) + (set! (-> arg0 data 45 name) "nav-mesh") + (+! (-> arg0 data 45 count) 1) + (let ((v1-6 (asize-of obj))) + (+! (-> arg0 data 45 used) v1-6) + (+! (-> arg0 data 45 total) (logand -16 (+ v1-6 15))) + ) + (set! (-> arg0 length) (max 46 (-> arg0 length))) + (set! (-> arg0 data 45 name) "nav-mesh") + (+! (-> arg0 data 45 count) 1) + (let ((v1-16 (* (-> obj vertex-count) 16))) + (+! (-> arg0 data 45 used) v1-16) + (+! (-> arg0 data 45 total) (logand -16 (+ v1-16 15))) + ) + (set! (-> arg0 length) (max 46 (-> arg0 length))) + (set! (-> arg0 data 45 name) "nav-mesh") + (+! (-> arg0 data 45 count) 1) + (let ((v1-26 (* (-> obj poly-count) 8))) + (+! (-> arg0 data 45 used) v1-26) + (+! (-> arg0 data 45 total) (logand -16 (+ v1-26 15))) + ) + (set! (-> arg0 length) (max 46 (-> arg0 length))) + (set! (-> arg0 data 45 name) "nav-mesh") + (+! (-> arg0 data 45 count) 1) + (let ((v1-38 (/ (* (* (-> obj poly-count) (-> obj poly-count)) 2) 8))) + (+! (-> arg0 data 45 used) v1-38) + (+! (-> arg0 data 45 total) (logand -16 (+ v1-38 15))) + ) + (the-as nav-mesh 0) + ) + +;; definition for method 14 of type nav-control +;; INFO: Return type mismatch int vs none. +(defmethod set-current-poly! nav-control ((obj nav-control) (arg0 nav-poly)) + (set! (-> obj current-poly) arg0) + (logior! (-> obj flags) (nav-control-flags bit9)) + 0 + (none) + ) + +;; definition for method 30 of type nav-control +(defmethod dummy-30 nav-control ((obj nav-control) (arg0 vector) (arg1 vector) (arg2 vector)) + (let ((s5-0 (the-as sphere #f))) + (let ((f30-0 -0.000001)) + (countdown (s1-0 (-> obj num-spheres)) + (let* ((s0-0 (-> obj sphere s1-0)) + (f0-1 (ray-circle-intersect arg0 arg1 (the-as vector (&-> s0-0 x)) (-> s0-0 w))) + ) + (when (< f30-0 f0-1) + (set! s5-0 s0-0) + (set! f30-0 f0-1) + ) + ) + ) + (set! (-> arg2 x) f30-0) + ) + s5-0 + ) + ) + +;; definition for method 31 of type nav-control +(defmethod intersect-ray-line-segment? nav-control ((obj nav-control) (arg0 vector) (arg1 vector) (arg2 vector) (arg3 vector)) + (ray-line-segment-intersection? arg0 arg1 arg2 arg3) + ) + +;; definition for function add-nav-sphere +;; INFO: Return type mismatch int vs none. +(defun add-nav-sphere ((arg0 nav-control) (arg1 vector)) + (when (< (-> arg0 num-spheres) (-> arg0 max-spheres)) + (let* ((s4-0 (-> arg0 sphere (-> arg0 num-spheres))) + (f1-0 (vector-vector-xz-distance-squared arg1 (-> arg0 shape trans))) + (f0-1 (+ (-> arg1 w) (-> arg0 shape nav-radius))) + (f2-2 (+ 40960.0 f0-1)) + ) + (when (< f1-0 (* f2-2 f2-2)) + (vector-! (the-as vector s4-0) arg1 (-> arg0 mesh origin)) + (set! (-> s4-0 w) f0-1) + (+! (-> arg0 num-spheres) 1) + ) + ) + ) + 0 + (none) + ) + +;; definition for function add-collide-shape-spheres +;; INFO: Return type mismatch int vs none. +;; Used lq/sq +(defun add-collide-shape-spheres ((arg0 nav-control) (arg1 collide-shape) (arg2 vector)) + (when (logtest? (-> arg1 nav-flags) 1) + (set! (-> arg2 quad) (-> arg1 root-prim prim-core world-sphere quad)) + (set! (-> arg2 w) (-> arg1 nav-radius)) + (let ((s4-0 arg0) + (s3-0 arg2) + ) + (when (< (-> s4-0 num-spheres) (-> s4-0 max-spheres)) + (let* ((s2-0 (-> s4-0 sphere (-> s4-0 num-spheres))) + (f1-0 (vector-vector-xz-distance-squared s3-0 (-> s4-0 shape trans))) + (f0-2 (+ (-> s3-0 w) (-> s4-0 shape nav-radius))) + (f2-2 (+ 40960.0 f0-2)) + ) + (when (< f1-0 (* f2-2 f2-2)) + (vector-! (the-as vector s2-0) s3-0 (-> s4-0 mesh origin)) + (set! (-> s2-0 w) f0-2) + (+! (-> s4-0 num-spheres) 1) + ) + ) + ) + ) + 0 + ) + (when (logtest? (-> arg1 nav-flags) 2) + (let ((s5-1 (-> arg1 process nav extra-nav-sphere))) + (when (< (-> arg0 num-spheres) (-> arg0 max-spheres)) + (let* ((s4-1 (-> arg0 sphere (-> arg0 num-spheres))) + (f1-1 (vector-vector-xz-distance-squared s5-1 (-> arg0 shape trans))) + (f0-4 (+ (-> s5-1 w) (-> arg0 shape nav-radius))) + (f2-7 (+ 40960.0 f0-4)) + ) + (when (< f1-1 (* f2-7 f2-7)) + (vector-! (the-as vector s4-1) s5-1 (-> arg0 mesh origin)) + (set! (-> s4-1 w) f0-4) + (+! (-> arg0 num-spheres) 1) + ) + ) + ) + ) + 0 + ) + (none) + ) + +;; definition for method 28 of type nav-control +;; INFO: Return type mismatch int vs none. +;; Used lq/sq +(defmethod TODO-RENAME-28 nav-control ((obj nav-control) (arg0 collide-kind)) + (local-vars + (sv-32 nav-control) + (sv-48 sphere) + (sv-64 sphere) + (sv-80 nav-control) + (sv-96 sphere) + (sv-112 vector) + (sv-128 sphere) + ) + (set! (-> obj num-spheres) 0) + (let ((s4-0 (-> obj mesh user-list)) + (s3-0 (new 'stack-no-clear 'vector)) + ) + (when (and *target* + (or (logtest? (-> obj flags) (nav-control-flags bit11)) (logtest? (-> *target* state-flags) #x80f8)) + ) + (let ((s2-0 obj) + (s1-0 (-> *target* control)) + ) + (let ((s0-0 s3-0)) + (when (logtest? (-> s1-0 nav-flags) 1) + (set! (-> s0-0 quad) (-> s1-0 root-prim prim-core world-sphere quad)) + (set! (-> s0-0 w) (-> s1-0 nav-radius)) + (set! sv-32 s2-0) + (when (< (-> sv-32 num-spheres) (-> sv-32 max-spheres)) + (set! sv-48 (-> sv-32 sphere (-> sv-32 num-spheres))) + (let* ((f1-0 (vector-vector-xz-distance-squared s0-0 (-> sv-32 shape trans))) + (f0-2 (+ (-> s0-0 w) (-> sv-32 shape nav-radius))) + (f2-2 (+ 40960.0 f0-2)) + ) + (when (< f1-0 (* f2-2 f2-2)) + (vector-! (the-as vector sv-48) s0-0 (-> sv-32 mesh origin)) + (set! (-> sv-48 w) f0-2) + (+! (-> sv-32 num-spheres) 1) + ) + ) + ) + 0 + ) + ) + (when (logtest? (-> s1-0 nav-flags) 2) + (let ((s1-1 (-> s1-0 process nav extra-nav-sphere))) + (when (< (-> s2-0 num-spheres) (-> s2-0 max-spheres)) + (let* ((s0-1 (-> s2-0 sphere (-> s2-0 num-spheres))) + (f1-1 (vector-vector-xz-distance-squared s1-1 (-> s2-0 shape trans))) + (f0-4 (+ (-> s1-1 w) (-> s2-0 shape nav-radius))) + (f2-7 (+ 40960.0 f0-4)) + ) + (when (< f1-1 (* f2-7 f2-7)) + (vector-! (the-as vector s0-1) s1-1 (-> s2-0 mesh origin)) + (set! (-> s0-1 w) f0-4) + (+! (-> s2-0 num-spheres) 1) + ) + ) + ) + ) + 0 + ) + ) + ) + (when (logtest? (-> obj flags) (nav-control-flags bit13)) + (countdown (s2-1 (-> obj mesh static-sphere-count)) + (let ((s1-2 obj) + (s0-2 (-> obj mesh static-sphere s2-1)) + ) + (when (< (-> s1-2 num-spheres) (-> s1-2 max-spheres)) + (set! sv-64 (-> s1-2 sphere (-> s1-2 num-spheres))) + (let* ((f1-2 (vector-vector-xz-distance-squared (the-as vector s0-2) (-> s1-2 shape trans))) + (f0-6 (+ (-> s0-2 trans w) (-> s1-2 shape nav-radius))) + (f2-12 (+ 40960.0 f0-6)) + ) + (when (< f1-2 (* f2-12 f2-12)) + (vector-! (the-as vector sv-64) (the-as vector s0-2) (-> s1-2 mesh origin)) + (set! (-> sv-64 w) f0-6) + (+! (-> s1-2 num-spheres) 1) + ) + ) + ) + ) + 0 + ) + ) + (let* ((v1-71 (-> s4-0 alive-list next0)) + (s2-2 (-> v1-71 next0)) + ) + (while (!= v1-71 (-> s4-0 alive-list-end)) + (let ((s0-3 (the-as collide-shape (-> (the-as connection v1-71) param3)))) + (when (not (or (= s0-3 (-> obj shape)) (zero? (logand arg0 (-> s0-3 root-prim prim-core collide-as))))) + (let ((s1-3 obj)) + (set! sv-112 s3-0) + (when (logtest? (-> s0-3 nav-flags) 1) + (set! (-> sv-112 quad) (-> s0-3 root-prim prim-core world-sphere quad)) + (set! (-> sv-112 w) (-> s0-3 nav-radius)) + (set! sv-80 s1-3) + (when (< (-> sv-80 num-spheres) (-> sv-80 max-spheres)) + (set! sv-96 (-> sv-80 sphere (-> sv-80 num-spheres))) + (let* ((f1-3 (vector-vector-xz-distance-squared sv-112 (-> sv-80 shape trans))) + (f0-9 (+ (-> sv-112 w) (-> sv-80 shape nav-radius))) + (f2-17 (+ 40960.0 f0-9)) + ) + (when (< f1-3 (* f2-17 f2-17)) + (let ((v1-94 sv-96) + (a0-47 (-> sv-80 mesh origin)) + ) + (vector-! (the-as vector v1-94) sv-112 a0-47) + ) + (set! (-> sv-96 w) f0-9) + (+! (-> sv-80 num-spheres) 1) + ) + ) + ) + 0 + ) + (when (logtest? (-> s0-3 nav-flags) 2) + (let ((s0-4 (-> s0-3 process nav extra-nav-sphere))) + (when (< (-> s1-3 num-spheres) (-> s1-3 max-spheres)) + (set! sv-128 (-> s1-3 sphere (-> s1-3 num-spheres))) + (let* ((f1-4 (vector-vector-xz-distance-squared s0-4 (-> s1-3 shape trans))) + (f0-11 (+ (-> s0-4 w) (-> s1-3 shape nav-radius))) + (f2-22 (+ 40960.0 f0-11)) + ) + (when (< f1-4 (* f2-22 f2-22)) + (vector-! (the-as vector sv-128) s0-4 (-> s1-3 mesh origin)) + (set! (-> sv-128 w) f0-11) + (+! (-> s1-3 num-spheres) 1) + ) + ) + ) + ) + 0 + ) + ) + ) + ) + (set! v1-71 s2-2) + (set! s2-2 (-> s2-2 next0)) + ) + ) + ) + 0 + (none) + ) + +;; definition for method 35 of type nav-control +;; INFO: Return type mismatch symbol vs none. +(defmethod dummy-35 nav-control ((obj nav-control) (arg0 vector) (arg1 vector) (arg2 vector) (arg3 vector) (arg4 float)) + (let ((v1-0 (new 'stack-no-clear 'vector))) + (vector-! v1-0 arg1 (-> obj mesh origin)) + (TODO-ASM-32 obj arg0 v1-0 arg2 arg3 arg4) + ) + (none) + ) + +;; definition of type cfs-travel-vec +(deftype cfs-travel-vec (structure) + ((dir vector :inline :offset-assert 0) + (delta-angle float :offset-assert 16) + ) + :method-count-assert 9 + :size-assert #x14 + :flag-assert #x900000014 + ) + +;; definition for method 3 of type cfs-travel-vec +(defmethod inspect cfs-travel-vec ((obj cfs-travel-vec)) + (format #t "[~8x] ~A~%" obj 'cfs-travel-vec) + (format #t "~Tdir: #~%" (-> obj dir)) + (format #t "~Tdelta-angle: ~f~%" (-> obj delta-angle)) + obj + ) + +;; definition of type cfs-work +(deftype cfs-work (structure) + ((desired-travel-dist float :offset-assert 0) + (desired-angle float :offset-assert 4) + (max-dist float :offset-assert 8) + (old-angle float :offset-assert 12) + (modified int32 :offset-assert 16) + (blocked-mask uint64 :offset-assert 24) + (travel vector :inline :offset-assert 32) + (current vector :inline :offset-assert 48) + (new-travel cfs-travel-vec 2 :inline :offset-assert 64) + (temp-travel cfs-travel-vec 2 :inline :offset-assert 128) + (prev-dir vector :inline :offset-assert 192) + (attempt-dir vector :inline :offset-assert 208) + (tangent vector 2 :inline :offset-assert 224) + ) + :method-count-assert 9 + :size-assert #x100 + :flag-assert #x900000100 + ) + +;; definition for method 3 of type cfs-work +(defmethod inspect cfs-work ((obj cfs-work)) + (format #t "[~8x] ~A~%" obj 'cfs-work) + (format #t "~Tdesired-travel-dist: ~f~%" (-> obj desired-travel-dist)) + (format #t "~Tdesired-angle: ~f~%" (-> obj desired-angle)) + (format #t "~Tmax-dist: ~f~%" (-> obj max-dist)) + (format #t "~Told-angle: ~f~%" (-> obj old-angle)) + (format #t "~Tmodified: ~D~%" (-> obj modified)) + (format #t "~Tblocked-mask: ~D~%" (-> obj blocked-mask)) + (format #t "~Ttravel: #~%" (-> obj travel)) + (format #t "~Tcurrent: #~%" (-> obj current)) + (format #t "~Tnew-travel[2] @ #x~X~%" (-> obj new-travel)) + (format #t "~Ttemp-travel[2] @ #x~X~%" (-> obj temp-travel)) + (format #t "~Tprev-dir: #~%" (-> obj prev-dir)) + (format #t "~Tattempt-dir: #~%" (-> obj attempt-dir)) + (format #t "~Ttangent[2] @ #x~X~%" (-> obj tangent)) + obj + ) + +;; definition of type nav-control-cfs-work +(deftype nav-control-cfs-work (structure) + ((in-dir vector :inline :offset-assert 0) + (right-dir vector :inline :offset-assert 16) + (best-dir vector 2 :inline :offset-assert 32) + (temp-dir vector 2 :inline :offset-assert 64) + (away-dir vector :inline :offset-assert 96) + (best-dir-angle degrees 2 :offset-assert 112) + (ignore-mask uint64 :offset-assert 120) + (initial-ignore-mask uint64 :offset-assert 128) + (i-sphere int32 :offset-assert 136) + (i-first-sphere int32 :offset-assert 140) + (i-inside-sphere int32 :offset-assert 144) + (inside-sphere-dist float :offset-assert 148) + (sign float :offset-assert 152) + (travel-len float :offset-assert 156) + (dist2 float :offset-assert 160) + (inside-dist float :offset-assert 164) + (rand-angle float :offset-assert 168) + (dir-update basic :offset-assert 172) + (debug-offset vector :inline :offset-assert 176) + ) + :method-count-assert 9 + :size-assert #xc0 + :flag-assert #x9000000c0 + ) + +;; definition for method 3 of type nav-control-cfs-work +(defmethod inspect nav-control-cfs-work ((obj nav-control-cfs-work)) + (format #t "[~8x] ~A~%" obj 'nav-control-cfs-work) + (format #t "~Tin-dir: #~%" (-> obj in-dir)) + (format #t "~Tright-dir: #~%" (-> obj right-dir)) + (format #t "~Tbest-dir[2] @ #x~X~%" (-> obj best-dir)) + (format #t "~Ttemp-dir[2] @ #x~X~%" (-> obj temp-dir)) + (format #t "~Taway-dir: #~%" (-> obj away-dir)) + (format #t "~Tbest-dir-angle[2] @ #x~X~%" (-> obj best-dir-angle)) + (format #t "~Tignore-mask: ~D~%" (-> obj ignore-mask)) + (format #t "~Tinitial-ignore-mask: ~D~%" (-> obj initial-ignore-mask)) + (format #t "~Ti-sphere: ~D~%" (-> obj i-sphere)) + (format #t "~Ti-first-sphere: ~D~%" (-> obj i-first-sphere)) + (format #t "~Ti-inside-sphere: ~D~%" (-> obj i-inside-sphere)) + (format #t "~Tinside-sphere-dist: ~f~%" (-> obj inside-sphere-dist)) + (format #t "~Tsign: ~f~%" (-> obj sign)) + (format #t "~Ttravel-len: ~f~%" (-> obj travel-len)) + (format #t "~Tdist2: ~f~%" (-> obj dist2)) + (format #t "~Tinside-dist: ~f~%" (-> obj inside-dist)) + (format #t "~Trand-angle: ~f~%" (-> obj rand-angle)) + (format #t "~Tdir-update: ~A~%" (-> obj dir-update)) + (format #t "~Tdebug-offset: #~%" (-> obj debug-offset)) + obj + ) + +;; definition for function circle-tangent-directions +;; Used lq/sq +(defun circle-tangent-directions ((arg0 vector) (arg1 vector) (arg2 vector) (arg3 vector)) + (let ((s2-0 (new 'stack-no-clear 'vector)) + (s3-0 (new 'stack-no-clear 'vector)) + (s5-0 (new 'stack-no-clear 'vector)) + ) + (vector-! s2-0 arg1 arg0) + (set! (-> s2-0 y) 0.0) + (vector-normalize-copy! s3-0 s2-0 1.0) + (set! (-> s5-0 quad) (-> s3-0 quad)) + (set! (-> s5-0 x) (-> s3-0 z)) + (set! (-> s5-0 z) (- (-> s3-0 x))) + (let ((f0-4 (-> arg1 w)) + (f1-1 (vector-dot s3-0 s2-0)) + ) + (if (< f1-1 f0-4) + (set! f0-4 f1-1) + ) + (let* ((f2-0 f1-1) + (f2-2 (* f2-0 f2-0)) + (f3-0 f0-4) + (f2-4 (sqrtf (- f2-2 (* f3-0 f3-0)))) + (f3-4 (/ 1.0 f1-1)) + (f1-3 (* f2-4 f3-4)) + (f30-0 (* f0-4 f3-4)) + (s2-1 (new 'stack-no-clear 'vector)) + ) + (vector-float*! s2-1 s3-0 f1-3) + (vector+*! arg2 s2-1 s5-0 f30-0) + (vector+*! arg3 s2-1 s5-0 (- f30-0)) + ) + ) + ) + ) + +;; definition for function find-closest-circle-ray-intersection +(defun find-closest-circle-ray-intersection ((arg0 vector) (arg1 vector) (arg2 float) (arg3 int) (arg4 (inline-array vector)) (arg5 int)) + (let ((f30-0 1.0) + (gp-0 -1) + ) + (let ((s1-0 (new 'stack-no-clear 'vector))) + (vector-float*! s1-0 arg1 arg2) + (dotimes (s0-0 arg3) + (when (zero? (logand arg5 (ash 1 s0-0))) + (let* ((v1-7 (-> arg4 s0-0)) + (f0-2 (ray-circle-intersect arg0 s1-0 v1-7 (-> v1-7 w))) + ) + (when (and (>= f0-2 0.0) (< f0-2 f30-0)) + (set! f30-0 f0-2) + (set! gp-0 s0-0) + ) + ) + ) + ) + ) + gp-0 + ) + ) + +;; definition for function sign-bit +(defun sign-bit ((arg0 int)) + (local-vars (v1-1 int)) + (let ((v1-0 arg0)) + (shift-arith-right-32 v1-1 v1-0 31) + ) + (logand v1-1 1) + ) + +;; definition for function compute-dir-parm +(defun compute-dir-parm ((arg0 vector) (arg1 vector) (arg2 vector)) + (local-vars (a2-3 int)) + (let ((v1-0 (new 'static 'vector :x 1.0 :y -1.0))) + (let ((a2-2 (vector-dot arg0 arg2))) + (shift-arith-right-32 a2-3 a2-2 31) + ) + (* (-> v1-0 data (logand a2-3 1)) (- 1.0 (vector-dot arg0 arg1))) + ) + ) + +;; definition for method 32 of type nav-control +;; Used lq/sq +(defmethod TODO-ASM-32 nav-control ((obj nav-control) (arg0 vector) (arg1 vector) (arg2 vector) (arg3 vector) (arg4 float)) + (local-vars (v0-3 symbol) (v1-38 int) (a0-29 int) (a3-7 int) (sv-208 sphere)) + (let ((gp-0 (new 'stack-no-clear 'nav-control-cfs-work))) + (set! (-> gp-0 in-dir quad) (-> arg2 quad)) + (set! (-> gp-0 in-dir y) 0.0) + (vector-normalize! (-> gp-0 in-dir) 1.0) + (set! (-> gp-0 travel-len) (vector-dot (-> gp-0 in-dir) arg2)) + (set! (-> gp-0 right-dir quad) (-> gp-0 in-dir quad)) + (set! (-> gp-0 right-dir x) (- (-> gp-0 in-dir z))) + (set! (-> gp-0 right-dir z) (-> gp-0 in-dir x)) + (set! (-> gp-0 best-dir 0 quad) (-> gp-0 in-dir quad)) + (set! (-> gp-0 best-dir 1 quad) (-> gp-0 in-dir quad)) + (set! (-> gp-0 best-dir-angle 0) 0.0) + (set! (-> gp-0 best-dir-angle 1) 0.0) + (set! (-> gp-0 initial-ignore-mask) (the-as uint 0)) + (set! (-> gp-0 i-inside-sphere) -1) + (set! (-> gp-0 inside-sphere-dist) 0.0) + (dotimes (s0-0 (-> obj num-spheres)) + (set! sv-208 (-> obj sphere s0-0)) + (set! (-> gp-0 dist2) (vector-vector-xz-distance-squared arg1 sv-208)) + (let ((f0-10 (-> gp-0 dist2)) + (f1-0 (-> sv-208 w)) + ) + (when (< f0-10 (* f1-0 f1-0)) + (vector-! (the-as vector (-> gp-0 temp-dir)) arg1 (the-as vector sv-208)) + (set! (-> gp-0 temp-dir 0 y) 0.0) + (if (< 0.0 (vector-dot (the-as vector (-> gp-0 temp-dir)) (-> gp-0 in-dir))) + (+! (-> gp-0 initial-ignore-mask) (ash 1 s0-0)) + ) + (set! (-> gp-0 inside-dist) (- (-> sv-208 w) (sqrtf (-> gp-0 dist2)))) + (when (< (-> gp-0 inside-sphere-dist) (-> gp-0 inside-dist)) + (set! (-> gp-0 i-inside-sphere) s0-0) + (set! (-> gp-0 inside-sphere-dist) (-> gp-0 inside-dist)) + ) + ) + ) + ) + (set! (-> gp-0 i-first-sphere) (find-closest-circle-ray-intersection + arg1 + (-> gp-0 in-dir) + (-> gp-0 travel-len) + (-> obj num-spheres) + (-> obj sphere) + (the-as int (-> gp-0 initial-ignore-mask)) + ) + ) + (when (= (-> gp-0 i-first-sphere) -1) + (set! (-> arg0 quad) (-> arg2 quad)) + (set! v0-3 #f) + (b! #t cfg-46 :delay (nop!)) + (the-as none 0) + ) + (+! (-> gp-0 initial-ignore-mask) (ash 1 (-> gp-0 i-first-sphere))) + (let ((a1-9 (-> obj sphere (-> gp-0 i-first-sphere)))) + (circle-tangent-directions arg1 a1-9 (the-as vector (-> gp-0 temp-dir)) (-> gp-0 temp-dir 1)) + ) + (dotimes (v1-31 2) + (let ((a0-28 (vector-dot (-> gp-0 right-dir) (-> gp-0 temp-dir v1-31)))) + (shift-arith-right-32 a0-29 a0-28 31) + ) + (let ((a0-30 (logand a0-29 1)) + (f0-21 (- 1.0 (vector-dot (-> gp-0 in-dir) (-> gp-0 temp-dir v1-31)))) + ) + (set! (-> gp-0 best-dir a0-30 quad) (-> gp-0 temp-dir v1-31 quad)) + (set! (-> gp-0 best-dir-angle a0-30) f0-21) + ) + ) + 0 + (set! (-> gp-0 sign) 1.0) + (dotimes (s1-1 2) + (-> gp-0 i-first-sphere) + (set! (-> gp-0 dir-update) #t) + (set! (-> gp-0 ignore-mask) (-> gp-0 initial-ignore-mask)) + (b! #t cfg-31 :delay (nop!)) + (label cfg-22) + (+! (-> gp-0 ignore-mask) (ash 1 v1-38)) + (circle-tangent-directions arg1 (-> obj sphere v1-38) (the-as vector (-> gp-0 temp-dir)) (-> gp-0 temp-dir 1)) + (set! (-> gp-0 dir-update) #f) + (dotimes (v1-40 2) + (let ((f0-23 (-> gp-0 sign)) + (a1-22 (-> gp-0 temp-dir v1-40)) + (a0-39 (-> gp-0 in-dir)) + (a3-4 (-> gp-0 right-dir)) + (a2-10 (new 'static 'vector :x 1.0 :y -1.0)) + ) + (let ((a3-6 (vector-dot a1-22 a3-4))) + (shift-arith-right-32 a3-7 a3-6 31) + ) + (let ((f0-24 (* f0-23 (* (-> a2-10 data (logand a3-7 1)) (- 1.0 (vector-dot a1-22 a0-39)))))) + (when (< (-> gp-0 best-dir-angle s1-1) f0-24) + (set! (-> gp-0 best-dir s1-1 quad) (-> gp-0 temp-dir v1-40 quad)) + (set! (-> gp-0 best-dir-angle s1-1) f0-24) + (set! (-> gp-0 dir-update) #t) + ) + ) + ) + ) + (label cfg-31) + (when (-> gp-0 dir-update) + (set! v1-38 (find-closest-circle-ray-intersection + arg1 + (-> gp-0 best-dir s1-1) + (-> gp-0 travel-len) + (-> obj num-spheres) + (-> obj sphere) + (the-as int (-> gp-0 ignore-mask)) + ) + ) + (b! (!= v1-38 -1) cfg-22 :delay (nop!)) + ) + (set! (-> gp-0 sign) (* -1.0 (-> gp-0 sign))) + ) + (when (!= (-> gp-0 i-inside-sphere) -1) + (let ((s2-1 (-> obj sphere (-> gp-0 i-inside-sphere)))) + (vector-! (-> gp-0 away-dir) arg1 (the-as vector s2-1)) + (set! (-> gp-0 away-dir y) 0.0) + (when (>= 40.96 (vector-length (-> gp-0 away-dir))) + (set! (-> gp-0 rand-angle) (* 65536.0 (rand-vu))) + (set! (-> gp-0 away-dir x) (cos (-> gp-0 rand-angle))) + (set! (-> gp-0 away-dir z) (sin (-> gp-0 rand-angle))) + ) + (vector-normalize! (-> gp-0 away-dir) 1.0) + (let ((f30-2 (/ (-> gp-0 inside-sphere-dist) (-> s2-1 w)))) + (vector-lerp! (the-as vector (-> gp-0 best-dir)) (the-as vector (-> gp-0 best-dir)) (-> gp-0 away-dir) f30-2) + (vector-lerp! (-> gp-0 best-dir 1) (-> gp-0 best-dir 1) (-> gp-0 away-dir) f30-2) + ) + ) + (vector-normalize! (the-as vector (-> gp-0 best-dir)) 1.0) + (vector-normalize! (-> gp-0 best-dir 1) 1.0) + ) + (let ((f30-3 (vector-dot (-> gp-0 in-dir) (the-as vector (-> gp-0 best-dir)))) + (f28-0 (vector-dot (-> gp-0 in-dir) (-> gp-0 best-dir 1))) + ) + (when (< (fmax f30-3 f28-0) (cos 1820.4445)) + (set! f30-3 (vector-dot arg3 (the-as vector (-> gp-0 best-dir)))) + (set! f28-0 (vector-dot arg3 (-> gp-0 best-dir 1))) + ) + (vector-float*! + arg0 + (-> gp-0 best-dir (if (< f28-0 f30-3) + 0 + 1 + ) + ) + (-> gp-0 travel-len) + ) + ) + ) + 0 + (set! v0-3 #t) + (label cfg-46) + v0-3 + ) + +;; definition for method 23 of type nav-control +(defmethod dummy-23 nav-control ((obj nav-control) (arg0 vector) (arg1 check-vector-collision-with-nav-spheres-info)) + (let ((s2-1 (vector-! (new 'stack-no-clear 'vector) (-> obj shape trans) (-> obj mesh origin))) + (f30-0 -1.0) + ) + (let ((s3-0 -1)) + (countdown (s1-0 (-> obj num-spheres)) + (let* ((s0-0 (-> obj sphere s1-0)) + (f0-1 (ray-circle-intersect s2-1 arg0 (the-as vector (&-> s0-0 x)) (-> s0-0 w))) + ) + (when (>= f0-1 0.0) + (let ((v1-5 (new 'stack-no-clear 'vector))) + (vector-! v1-5 (the-as vector (&-> s0-0 x)) s2-1) + (when (>= (vector-dot v1-5 arg0) 0.0) + (when (or (< f30-0 0.0) (< f0-1 f30-0)) + (set! f30-0 f0-1) + (set! s3-0 s1-0) + ) + ) + ) + ) + ) + ) + (when arg1 + (set! (-> arg1 u) f30-0) + (when (>= f30-0 0.0) + (vector+float*! (-> arg1 intersect) (-> obj shape trans) arg0 f30-0) + (let ((a1-4 (-> obj sphere s3-0)) + (v1-19 (new 'stack-no-clear 'vector)) + ) + (vector+! v1-19 (the-as vector (&-> a1-4 x)) (-> obj mesh origin)) + (vector-! (-> arg1 normal) (-> arg1 intersect) v1-19) + ) + (set! (-> arg1 normal w) 1.0) + (vector-normalize! (-> arg1 normal) 1.0) + ) + ) + ) + f30-0 + ) + ) + +;; definition for method 33 of type nav-control +;; Used lq/sq +(defmethod TODO-RENAME-33 nav-control ((obj nav-control) (arg0 vector) (arg1 vector) (arg2 vector) (arg3 vector) (arg4 float)) + (let ((f30-0 (vector-xz-length (-> obj travel)))) + (when (TODO-ASM-32 obj arg0 arg1 arg2 arg3 f30-0) + (set! (-> obj blocked-travel quad) (-> obj travel quad)) + (let ((f0-0 (vector-xz-length (-> obj travel)))) + (when (and (>= f30-0 f0-0) (< f0-0 204.8)) + (set! (-> obj flags) (logior (nav-control-flags bit17) (-> obj flags))) + (set! (-> obj block-time) (the-as uint (-> *display* base-frame-counter))) + (set! (-> obj block-count) (+ 1.0 (-> obj block-count))) + (if (-> obj block-event) + (send-event (the-as process-tree (-> obj process)) (the-as symbol (-> obj block-event)) obj) + ) + ) + ) + #t + ) + ) + ) + +;; definition for symbol *debug-ray-test*, type nav-ray +(define *debug-ray-test* (the-as nav-ray #f)) + +;; definition for symbol *debug-ray-test-capture-mode*, type symbol +(define *debug-ray-test-capture-mode* #f) + +;; definition for symbol *debug-ray-test-capture-output*, type symbol +(define *debug-ray-test-capture-output* #f) + +;; definition for symbol *test-ray-start-poly-id*, type int +(define *test-ray-start-poly-id* 62) + +;; definition for symbol *test-ray-src-pos*, type vector +(define *test-ray-src-pos* (new 'static 'vector :x -705089.6 :y 9769.325 :z -963339.0 :w 1.0)) + +;; definition for symbol *test-ray-dest-pos*, type vector +(define *test-ray-dest-pos* (new 'static 'vector :x -722887.7 :y 9532.475 :z -958862.25 :w 1.0)) + +;; definition for method 19 of type nav-control +;; INFO: Return type mismatch vector vs none. +;; Used lq/sq +(defmethod dummy-19 nav-control ((obj nav-control) (arg0 vector) (arg1 collide-shape-moving) (arg2 vector) (arg3 float)) + (local-vars (sv-48 float)) + (let ((f30-0 (* arg3 (-> *display* seconds-per-frame))) + (s0-0 arg1) + (s1-0 arg2) + (s2-0 deg-diff) + ) + (set! sv-48 (y-angle s0-0)) + (let* ((a1-1 (vector-y-angle (vector-! (new 'stack-no-clear 'vector) s1-0 (-> s0-0 trans)))) + (f28-0 (s2-0 sv-48 a1-1)) + ) + (cond + ((or (vector= arg2 (-> obj target-pos)) (< (fabs f28-0) 364.0889)) + (set! (-> obj flags) (logior (nav-control-flags bit21) (-> obj flags))) + (set! (-> arg0 quad) (-> arg2 quad)) + ) + (else + (let ((s2-1 (vector-z-quaternion! (new 'stack-no-clear 'vector) (-> arg1 quat)))) + (vector-rotate-y! s2-1 s2-1 (fmax (fmin f28-0 f30-0) (- f30-0))) + (vector-normalize! s2-1 819.2) + (logclear! (-> obj flags) (nav-control-flags bit21)) + (vector+! arg0 (-> arg1 trans) s2-1) + ) + (when (or (not (dummy-16 obj arg0)) + (logtest? (nav-control-flags bit17) (-> obj flags)) + (zero? (logand (-> obj flags) (nav-control-flags bit10))) + ) + (set! (-> obj flags) (logior (nav-control-flags bit21) (-> obj flags))) + (vector-! (-> obj travel) arg2 (-> arg1 trans)) + (set! (-> arg0 quad) (-> arg2 quad)) + ) + ) + ) + ) + ) + (none) + ) + +;; definition for method 16 of type nav-control +(defmethod dummy-16 nav-control ((obj nav-control) (arg0 vector)) + (find-poly-fast + (-> obj mesh) + (vector-! (new 'stack-no-clear 'vector) arg0 (-> obj mesh origin)) + (-> obj nearest-y-threshold) + ) + ) + +;; definition for method 21 of type nav-control +(defmethod TODO-RENAME-21 nav-control ((obj nav-control) (arg0 vector)) + (find-poly-fast + (-> obj mesh) + (vector-! (new 'stack-no-clear 'vector) arg0 (-> obj mesh origin)) + (-> obj nearest-y-threshold) + ) + ) + +;; definition for method 22 of type nav-control +;; INFO: Return type mismatch structure vs symbol. +(defmethod TODO-RENAME-22 nav-control ((obj nav-control) (arg0 vector) (arg1 float)) + (the-as symbol (and (find-poly-fast + (-> obj mesh) + (vector-! (new 'stack-no-clear 'vector) arg0 (-> obj mesh origin)) + (-> obj nearest-y-threshold) + ) + (< (-> arg0 y) (+ (-> obj mesh origin y) arg1)) + ) + ) + ) + +;; definition for function debug-nav-validate-current-poly +(defun debug-nav-validate-current-poly ((arg0 nav-mesh) (arg1 nav-poly) (arg2 vector)) + (when (not (point-in-poly? arg0 arg1 arg2)) + (let ((s3-0 (new 'stack-no-clear 'vector))) + (project-point-into-tri-2d arg0 arg1 s3-0 arg2) + (vector-vector-xz-distance arg2 s3-0) + ) + #f + ) + ) + +;; definition for method 26 of type nav-control +;; INFO: Return type mismatch int vs none. +(defmethod TODO-RENAME-26 nav-control ((obj nav-control)) + 0 + (none) + ) + +;; definition for method 27 of type nav-control +;; INFO: Return type mismatch int vs none. +;; Used lq/sq +(defmethod TODO-RENAME-27 nav-control ((obj nav-control)) + (local-vars (v1-7 symbol)) + (cond + ((-> obj current-poly) + (let ((s4-0 (-> obj mesh)) + (s5-0 (new 'stack-no-clear 'nav-ray)) + ) + (let ((s3-0 0)) + (set! (-> s5-0 current-poly) (-> obj current-poly)) + (vector-! (-> s5-0 current-pos) (-> obj prev-pos) (-> s4-0 origin)) + (vector-! (-> s5-0 dest-pos) (-> obj shape trans) (-> s4-0 origin)) + (init-ray s5-0) + (until v1-7 + (+! s3-0 1) + (move-along-nav-ray! s4-0 s5-0) + (set! v1-7 (or (>= s3-0 15) (-> s5-0 terminated))) + ) + ) + (set! (-> obj current-poly) (-> s5-0 current-poly)) + (when (-> s5-0 reached-dest) + (if (not (point-in-poly? s4-0 (-> s5-0 current-poly) (-> s5-0 dest-pos))) + (set! (-> s5-0 reached-dest) #f) + ) + ) + (cond + ((-> s5-0 reached-dest) + (set! (-> obj prev-pos quad) (-> obj shape trans quad)) + ) + (else + (set! (-> obj prev-pos quad) (-> obj shape trans quad)) + (set! (-> obj current-poly) (find-poly obj (-> obj shape trans))) + ) + ) + ) + 0 + ) + (else + (set! (-> obj prev-pos quad) (-> obj shape trans quad)) + (set! (-> obj current-poly) (find-poly obj (-> obj shape trans))) + ) + ) + (TODO-RENAME-26 obj) + 0 + (none) + ) + +;; definition for method 16 of type nav-mesh +;; INFO: Return type mismatch int vs none. +;; Used lq/sq +(defmethod TODO-RENAME-16 nav-mesh ((obj nav-mesh) + (arg0 vector) + (arg1 nav-poly) + (arg2 vector) + (arg3 symbol) + (arg4 float) + (arg5 clip-travel-vector-to-mesh-return-info) + ) + (local-vars (v1-10 symbol) (sv-96 symbol) (sv-112 int) (sv-128 int)) + (when arg5 + (set! (-> arg5 found-boundary) #f) + (set! (-> arg5 gap-poly) #f) + ) + (let ((s0-0 (new 'stack-no-clear 'nav-ray))) + (set! sv-96 (the-as symbol #f)) + (set! sv-112 0) + (set! (-> s0-0 current-poly) arg1) + (set! (-> s0-0 current-pos quad) (-> arg0 quad)) + (vector+! (-> s0-0 dest-pos) arg0 arg2) + (until sv-96 + (set! sv-128 0) + (init-ray s0-0) + (until v1-10 + (set! sv-128 (+ sv-128 1)) + (move-along-nav-ray! obj s0-0) + (set! v1-10 (or (>= sv-128 15) (or (>= (-> s0-0 len) (fmax 20480.0 arg4)) (-> s0-0 terminated)))) + ) + (cond + ((and (-> s0-0 hit-boundary) (and (< (-> s0-0 len) arg4) (!= (-> s0-0 last-edge) -1) (< sv-112 1))) + (set! sv-112 (+ sv-112 1)) + (let* ((v1-22 (-> obj vertex (-> s0-0 current-poly vertex (-> *edge-vert0-table* (-> s0-0 last-edge))))) + (a0-15 (-> obj vertex (-> s0-0 current-poly vertex (-> *edge-vert1-table* (-> s0-0 last-edge))))) + (f2-1 (- (-> v1-22 z) (-> a0-15 z))) + (f3-0 (- (-> a0-15 x) (-> v1-22 x))) + (f1-5 (-> arg2 x)) + (f0-4 (-> arg2 z)) + (f4-0 f2-1) + (f4-2 (* f4-0 f4-0)) + (f5-0 f3-0) + (f4-4 (sqrtf (+ f4-2 (* f5-0 f5-0)))) + (f4-6 (/ 1.0 f4-4)) + (f2-2 (* f2-1 f4-6)) + (f3-1 (* f3-0 f4-6)) + ) + (when arg5 + (set! (-> arg5 found-boundary) #t) + (vector+! (-> arg5 intersection) (-> s0-0 current-pos) (-> obj origin)) + (set! (-> arg5 boundary-normal x) f2-2) + (set! (-> arg5 boundary-normal y) 0.0) + (set! (-> arg5 boundary-normal z) f3-1) + (set! (-> arg5 poly) (-> s0-0 current-poly)) + (set! (-> arg5 edge) (-> s0-0 last-edge)) + (vector+! (-> arg5 vert-0) (the-as vector v1-22) (-> obj origin)) + (vector+! (-> arg5 vert-1) (the-as vector a0-15) (-> obj origin)) + ) + (set! (-> s0-0 dest-pos quad) (-> s0-0 current-pos quad)) + (cond + (arg3 + (let* ((f4-9 (* 1.01 (+ (* f2-2 f1-5) (* f3-1 f0-4)))) + (f1-6 (- f1-5 (* f2-2 f4-9))) + (f0-5 (- f0-4 (* f3-1 f4-9))) + ) + (+! (-> s0-0 dest-pos x) f1-6) + (+! (-> s0-0 dest-pos z) f0-5) + ) + ) + (else + (set! sv-96 #t) + sv-96 + ) + ) + ) + ) + ((-> s0-0 hit-gap) + (if arg5 + (set! (-> arg5 gap-poly) (-> s0-0 next-poly)) + ) + (set! sv-96 #t) + sv-96 + ) + (else + (set! sv-96 #t) + sv-96 + ) + ) + ) + (vector-! arg2 (-> s0-0 current-pos) arg0) + ) + 0 + 0 + (none) + ) + +;; definition for method 24 of type nav-control +;; INFO: Return type mismatch int vs none. +(defmethod dummy-24 nav-control ((obj nav-control) (arg0 float) (arg1 clip-travel-vector-to-mesh-return-info)) + (let ((v1-0 (new 'stack-no-clear 'vector))) + (vector-! v1-0 (-> obj shape trans) (-> obj mesh origin)) + (TODO-RENAME-16 + (-> obj mesh) + v1-0 + (-> obj current-poly) + (-> obj travel) + (zero? (logand (-> obj flags) (nav-control-flags bit12))) + arg0 + arg1 + ) + ) + (when arg1 + (if (-> arg1 gap-poly) + (set! (-> obj next-poly) (-> arg1 gap-poly)) + ) + ) + 0 + (none) + ) + +;; definition for function test-xz-point-on-line-segment? +(defun test-xz-point-on-line-segment? ((arg0 vector) (arg1 vector) (arg2 vector) (arg3 float)) + (let ((v0-2 (>= arg3 (fmin (vector-vector-xz-distance arg0 arg1) (vector-vector-xz-distance arg0 arg2))))) + (when (not v0-2) + (let* ((f0-3 (- (-> arg2 x) (-> arg1 x))) + (f1-2 (- (-> arg2 z) (-> arg1 z))) + (f2-1 f0-3) + (f2-3 (* f2-1 f2-1)) + (f3-0 f1-2) + (f2-5 (sqrtf (+ f2-3 (* f3-0 f3-0)))) + (f3-3 f2-5) + (f3-5 (/ 1.0 f3-3)) + (f4-2 (* f3-5 (- f1-2))) + (f5-0 (* f3-5 f0-3)) + (f3-7 (- (-> arg0 x) (-> arg1 x))) + (f6-2 (- (-> arg0 z) (-> arg1 z))) + ) + (when (>= arg3 (fabs (+ (* f3-7 f4-2) (* f6-2 f5-0)))) + (let ((f0-5 (+ (* f3-7 f0-3) (* f6-2 f1-2)))) + (set! v0-2 (and (>= f0-5 0.0) (>= (* f2-5 f2-5) f0-5))) + ) + ) + ) + ) + v0-2 + ) + ) + +;; definition for function choose-travel-portal-vertex +(defun choose-travel-portal-vertex ((arg0 nav-mesh) (arg1 nav-route-portal) (arg2 nav-poly) (arg3 vector)) + (let ((f0-1 (- (-> arg1 vertex 1 x) (-> arg1 vertex 0 x))) + (f1-2 (- (-> arg1 vertex 1 z) (-> arg1 vertex 0 z))) + ) + 0.0 + (let ((s2-0 (new 'stack-no-clear 'nav-route-portal)) + (s1-0 0) + ) + (let* ((s0-0 #f) + (f2-2 f0-1) + (f2-4 (* f2-2 f2-2)) + (f3-0 f1-2) + (f2-6 (sqrtf (+ f2-4 (* f3-0 f3-0)))) + (f2-8 (/ 1.0 f2-6)) + (f30-0 (* f0-1 f2-8)) + (f28-0 (* f1-2 f2-8)) + (f26-0 (* -0.5 (+ (* f30-0 (-> arg1 vertex 0 x)) + (* f28-0 (-> arg1 vertex 0 z)) + (+ (* f30-0 (-> arg1 vertex 1 x)) (* f28-0 (-> arg1 vertex 1 z))) + ) + ) + ) + ) + (set! (-> s2-0 vertex 0) (-> arg1 vertex 0)) + (set! (-> s2-0 vertex 1) (-> arg1 vertex 1)) + (set! (-> s2-0 next-poly) (-> arg1 next-poly)) + (until s0-0 + (setup-portal arg0 (-> s2-0 next-poly) arg2 s2-0) + (cond + ((-> s2-0 next-poly) + (let ((v1-18 0)) + (dotimes (a0-2 2) + (if (< 0.0 (+ (* f30-0 (-> s2-0 vertex a0-2 x)) (* f28-0 (-> s2-0 vertex a0-2 z)) f26-0)) + (+! v1-18 1) + ) + ) + (when (= v1-18 2) + (set! s1-0 1) + (set! s0-0 #t) + ) + (when (zero? v1-18) + (set! s1-0 0) + (set! s0-0 #t) + ) + ) + 0 + ) + (else + (let ((v1-22 + (if (< (vector-vector-xz-distance (-> s2-0 vertex 0) arg3) (vector-vector-xz-distance (-> s2-0 vertex 1) arg3)) + 0 + 1 + ) + ) + ) + (set! s1-0 (if (< 0.0 (+ (* f30-0 (-> arg1 vertex v1-22 x)) (* f28-0 (-> arg1 vertex v1-22 z)) f26-0)) + 1 + 0 + ) + ) + ) + (set! s0-0 #t) + 0 + ) + ) + ) + ) + s1-0 + ) + ) + ) + +;; definition for method 13 of type nav-control +;; Used lq/sq +(defmethod dummy-13 nav-control ((obj nav-control) (arg0 vector) (arg1 vector)) + (local-vars + (sv-80 vector) + (sv-84 vector) + (sv-88 nav-poly) + (sv-92 vector) + (sv-96 nav-route-portal) + (sv-100 symbol) + ) + (set! sv-80 (new 'stack-no-clear 'vector)) + (set! sv-84 (new 'stack-no-clear 'vector)) + (set! sv-88 (-> obj current-poly)) + (set! sv-92 (new 'stack-no-clear 'vector)) + (set! sv-96 (new 'stack-no-clear 'nav-route-portal)) + (set! sv-100 (the-as symbol #f)) + (vector-! sv-80 (-> obj shape trans) (-> obj mesh origin)) + (set! (-> sv-84 quad) (-> sv-80 quad)) + (let ((s4-0 (new 'stack-no-clear 'vector))) + (vector-! s4-0 arg0 (-> obj mesh origin)) + (set! (-> obj target-poly) (find-poly (-> obj mesh) s4-0 (-> obj nearest-y-threshold) (&-> obj flags))) + (if (not (-> obj target-poly)) + (set! (-> obj target-poly) (-> obj current-poly)) + ) + (project-point-into-tri-2d (-> obj mesh) (-> obj target-poly) sv-92 s4-0) + ) + (vector-! (-> obj travel) sv-92 sv-80) + (setup-portal (-> obj mesh) (-> obj current-poly) (-> obj target-poly) sv-96) + (cond + ((not (-> sv-96 next-poly)) + (set! (-> obj next-poly) #f) + (set! (-> obj portal 0) #f) + (set! (-> obj portal 1) #f) + ) + (else + (set! (-> obj next-poly) (-> sv-96 next-poly)) + (set! (-> obj portal 0) (the-as nav-route-portal (-> sv-96 vertex 0))) + (set! (-> obj portal 1) (the-as nav-route-portal (-> sv-96 vertex 1))) + (set! sv-100 #t) + (while (and sv-100 + (-> sv-96 next-poly) + (test-xz-point-on-line-segment? sv-80 (-> sv-96 vertex 0) (-> sv-96 vertex 1) 409.59998) + ) + (when #t + #t + (vector-segment-distance-point! sv-80 (-> sv-96 vertex 0) (-> sv-96 vertex 1) sv-84) + (vector-! (-> obj travel) sv-92 sv-84) + 0 + ) + (cond + ((logtest? (-> sv-96 next-poly pat) 1) + (vector-segment-distance-point! sv-80 (-> sv-96 vertex 0) (-> sv-96 vertex 1) sv-92) + (vector-! (-> obj travel) sv-92 sv-84) + (set! (-> obj next-poly) (-> sv-96 next-poly)) + (set! sv-100 (the-as symbol #f)) + ) + ((begin + (set! sv-88 (-> sv-96 next-poly)) + (setup-portal (-> obj mesh) (-> sv-96 next-poly) (-> obj target-poly) sv-96) + ) + (set! (-> obj next-poly) (-> sv-96 next-poly)) + (set! (-> obj portal 0) (the-as nav-route-portal (-> sv-96 vertex 0))) + (set! (-> obj portal 1) (the-as nav-route-portal (-> sv-96 vertex 1))) + 0 + ) + (else + (set! (-> obj next-poly) #f) + (set! (-> obj portal 0) #f) + (set! (-> obj portal 1) #f) + (set! sv-100 (the-as symbol #f)) + ) + ) + ) + ) + ) + (when sv-100 + (when (not (ray-ccw-line-segment-intersection? + sv-84 + (-> obj travel) + (the-as vector (-> obj portal 0)) + (the-as vector (-> obj portal 1)) + ) + ) + (let ((a0-18 (choose-travel-portal-vertex (-> obj mesh) sv-96 (-> obj target-poly) sv-92))) + (vector-! (-> obj travel) (the-as vector (-> sv-96 vertex a0-18)) sv-84) + ) + ) + ) + (TODO-RENAME-33 obj (-> obj travel) sv-84 (-> obj travel) arg1 40960.0) + (let ((s5-1 (new 'stack-no-clear 'clip-travel-vector-to-mesh-return-info))) + (TODO-RENAME-16 + (-> obj mesh) + sv-84 + sv-88 + (-> obj travel) + (zero? (logand (-> obj flags) (nav-control-flags bit12))) + 204.8 + s5-1 + ) + (if (-> s5-1 gap-poly) + (set! (-> obj next-poly) (-> s5-1 gap-poly)) + ) + ) + (let ((v1-82 (new 'stack-no-clear 'vector))) + (vector-! v1-82 sv-84 sv-80) + (vector+! (-> obj travel) (-> obj travel) v1-82) + ) + (set! (-> obj travel y) 0.0) + (-> obj travel) + ) + +;; definition for method 12 of type nav-control +;; Used lq/sq +(defmethod TODO-RENAME-12 nav-control ((obj nav-control) (arg0 nav-gap-info)) + (when (and (-> obj next-poly) (logtest? (-> obj next-poly pat) 1)) + (let ((s4-0 (-> obj next-poly)) + (s3-1 (vector-! (new 'stack-no-clear 'vector) (-> obj shape trans) (-> obj mesh origin))) + ) + (while (and s4-0 (logtest? (-> s4-0 pat) 1)) + (set! s4-0 (get-adj-poly (-> obj mesh) s4-0 (-> obj target-poly) #f)) + ) + (when (and s4-0 (-> obj gap-event)) + (let ((s2-0 (-> obj event-temp))) + (closest-point-on-boundary (-> obj mesh) s4-0 s2-0 s3-1) + (vector+! s2-0 s2-0 (-> obj mesh origin)) + (set! (-> arg0 dest quad) (-> s2-0 quad)) + ) + (set! (-> arg0 poly) s4-0) + #t + ) + ) + ) + ) + +;; definition for function start-collect-nav +;; INFO: Return type mismatch int vs none. +;; WARN: Unsupported inline assembly instruction kind - [mtc0 Perf, r0] +;; WARN: Unsupported inline assembly instruction kind - [sync.l] +;; WARN: Unsupported inline assembly instruction kind - [sync.p] +;; WARN: Unsupported inline assembly instruction kind - [mtpc pcr0, r0] +;; WARN: Unsupported inline assembly instruction kind - [mtpc pcr1, r0] +;; WARN: Unsupported inline assembly instruction kind - [sync.l] +;; WARN: Unsupported inline assembly instruction kind - [sync.p] +;; WARN: Unsupported inline assembly instruction kind - [mtc0 Perf, a0] +;; WARN: Unsupported inline assembly instruction kind - [sync.l] +;; WARN: Unsupported inline assembly instruction kind - [sync.p] +(defun start-collect-nav () + (let* ((v1-1 (-> *perf-stats* data 14)) + (a0-0 (-> v1-1 ctrl)) + ) + (+! (-> v1-1 count) 1) + (b! (zero? a0-0) cfg-2 :delay (nop!)) + (.mtc0 Perf r0) + (.sync.l) + (.sync.p) + (.mtpc pcr0 r0) + (.mtpc pcr1 r0) + (.sync.l) + (.sync.p) + (.mtc0 Perf a0-0) + ) + (.sync.l) + (.sync.p) + (label cfg-2) + 0 + 0 + (none) + ) + +;; definition for function end-collect-nav +;; INFO: Return type mismatch int vs none. +;; WARN: Unsupported inline assembly instruction kind - [mtc0 Perf, r0] +;; WARN: Unsupported inline assembly instruction kind - [sync.l] +;; WARN: Unsupported inline assembly instruction kind - [sync.p] +;; WARN: Unsupported inline assembly instruction kind - [mfpc a0, pcr0] +;; WARN: Unsupported inline assembly instruction kind - [mfpc a0, pcr1] +(defun end-collect-nav () + (local-vars (a0-1 int) (a0-3 int)) + (let ((v1-1 (-> *perf-stats* data 14))) + (b! (zero? (-> v1-1 ctrl)) cfg-2 :delay (nop!)) + (.mtc0 Perf r0) + (.sync.l) + (.sync.p) + (.mfpc a0-1 pcr0) + (+! (-> v1-1 accum0) a0-1) + (.mfpc a0-3 pcr1) + (+! (-> v1-1 accum1) a0-3) + ) + (label cfg-2) + 0 + 0 + (none) + ) + +;; definition for method 11 of type nav-control +;; Used lq/sq +(defmethod dummy-11 nav-control ((obj nav-control) (arg0 vector)) + (set! (-> obj old-travel quad) (-> obj travel quad)) + (-> obj block-count) + (set! (-> obj block-count) (seek (-> obj block-count) 0.0 0.016666668)) + (logclear! (-> obj flags) (nav-control-flags bit9 bit17 bit18 bit19)) + (TODO-RENAME-27 obj) + (if (logtest? (-> obj flags) (nav-control-flags bit8)) + (TODO-RENAME-28 obj (collide-kind + background + cak-1 + cak-2 + cak-3 + target + water + powerup + crate + enemy + wall-object + projectile + ground-object + target-attack + mother-spider + cak-14 + blue-eco-suck + unknown-16 + unknown-17 + unknown-18 + unknown-19 + unknown-20 + unknown-21 + unknown-22 + unknown-23 + unknown-24 + unknown-25 + unknown-26 + unknown-27 + unknown-28 + unknown-29 + unknown-30 + unknown-31 + unknown-32 + unknown-33 + unknown-34 + unknown-35 + unknown-36 + unknown-37 + unknown-38 + unknown-39 + unknown-40 + unknown-41 + unknown-42 + unknown-43 + unknown-44 + unknown-45 + unknown-46 + unknown-47 + unknown-48 + unknown-49 + unknown-50 + unknown-51 + unknown-52 + unknown-53 + unknown-54 + unknown-55 + unknown-56 + unknown-57 + unknown-58 + unknown-59 + unknown-60 + unknown-61 + unknown-62 + unknown-63 + ) + ) + ) + (dummy-13 obj arg0 (-> obj old-travel)) + (-> obj mesh) + (vector-! (new 'stack-no-clear 'vector) (-> obj shape trans) (-> obj mesh origin)) + (let ((s5-1 (new 'stack-no-clear 'nav-gap-info))) + (when (< (vector-xz-length (-> obj travel)) 204.8) + (cond + ((logtest? (nav-control-flags bit17) (-> obj flags)) + ) + ((-> obj next-poly) + (cond + ((TODO-RENAME-12 obj s5-1) + (set! (-> obj next-poly) #f) + (send-event + (the-as process-tree (-> obj process)) + (the-as symbol (-> obj gap-event)) + (-> s5-1 dest) + (-> s5-1 poly) + ) + ) + (else + ) + ) + ) + (else + (set! (-> obj flags) (logior (nav-control-flags bit19) (-> obj flags))) + ) + ) + ) + ) + (-> obj travel) + ) + +;; definition (debug) for function nav-sphere-from-cam +;; INFO: Return type mismatch int vs none. +(defun-debug nav-sphere-from-cam () + (let ((v1-0 (camera-pos))) + (format #t "SPHEREM(~4,,1M, ~4,,1M, ~4,,1M, 1.0)~%" (-> v1-0 x) (-> v1-0 y) (-> v1-0 z)) + ) + 0 + (none) + ) diff --git a/test/decompiler/reference/engine/target/logic-target_REF.gc b/test/decompiler/reference/engine/target/logic-target_REF.gc index 97fd72c91b..1f0ad4c145 100644 --- a/test/decompiler/reference/engine/target/logic-target_REF.gc +++ b/test/decompiler/reference/engine/target/logic-target_REF.gc @@ -480,7 +480,7 @@ (-> arg0 control unknown-float81) (-> arg0 control unknown-float82) ) - (dummy-10 (-> arg0 skel) arg1) + (debug-print-channels (-> arg0 skel) arg1) ) (draw-history (-> arg0 control)) #f diff --git a/test/decompiler/reference/engine/target/sidekick_REF.gc b/test/decompiler/reference/engine/target/sidekick_REF.gc index 4390a0b6d1..ea90889cba 100644 --- a/test/decompiler/reference/engine/target/sidekick_REF.gc +++ b/test/decompiler/reference/engine/target/sidekick_REF.gc @@ -170,7 +170,7 @@ ) (when *display-sidekick-stats* (format *stdcon* "~%") - (dummy-10 (-> self skel) (the-as symbol *stdcon*)) + (debug-print-channels (-> self skel) (the-as symbol *stdcon*)) (add-debug-sphere *display-sidekick-stats* (bucket-id debug-draw1) diff --git a/test/decompiler/reference/levels/common/nav-enemy_REF.gc b/test/decompiler/reference/levels/common/nav-enemy_REF.gc index 043882d8d6..065582522f 100644 --- a/test/decompiler/reference/levels/common/nav-enemy_REF.gc +++ b/test/decompiler/reference/levels/common/nav-enemy_REF.gc @@ -617,7 +617,7 @@ nav-enemy-default-event-handler ;; definition for function nav-enemy-test-point-near-nav-mesh? (defbehavior nav-enemy-test-point-near-nav-mesh? nav-enemy ((arg0 vector)) - (and (dummy-25 (-> self nav) arg0 (-> self nav-info notice-nav-radius)) + (and (is-in-mesh? (-> self nav) arg0 (-> self nav-info notice-nav-radius)) (< (-> arg0 y) (+ (-> self collide-info trans y) (-> self enemy-info notice-top))) ) ) @@ -2238,7 +2238,7 @@ nav-enemy-default-event-handler (set! (-> obj nav) (new 'process 'nav-control (-> obj collide-info) 16 (-> arg0 nav-nearest-y-threshold))) (logior! (-> obj nav flags) (nav-control-flags display-marks bit3 bit5 bit6 bit7)) (set! (-> obj nav gap-event) 'jump) - (dummy-26 (-> obj nav)) + (TODO-RENAME-26 (-> obj nav)) (set! (-> obj path) (new 'process 'path-control obj 'path 0.0)) (logior! (-> obj path flags) (path-control-flag display draw-line draw-point draw-text)) (set! (-> obj enemy-info) @@ -2334,7 +2334,75 @@ nav-enemy-default-event-handler (set! (-> s4-0 quad) (-> obj collide-info trans quad)) (set! (-> obj collide-info trans quad) (-> arg0 quad)) (let ((gp-0 (-> obj nav))) - (dummy-28 gp-0 -1) + (TODO-RENAME-28 + gp-0 + (collide-kind + background + cak-1 + cak-2 + cak-3 + target + water + powerup + crate + enemy + wall-object + projectile + ground-object + target-attack + mother-spider + cak-14 + blue-eco-suck + unknown-16 + unknown-17 + unknown-18 + unknown-19 + unknown-20 + unknown-21 + unknown-22 + unknown-23 + unknown-24 + unknown-25 + unknown-26 + unknown-27 + unknown-28 + unknown-29 + unknown-30 + unknown-31 + unknown-32 + unknown-33 + unknown-34 + unknown-35 + unknown-36 + unknown-37 + unknown-38 + unknown-39 + unknown-40 + unknown-41 + unknown-42 + unknown-43 + unknown-44 + unknown-45 + unknown-46 + unknown-47 + unknown-48 + unknown-49 + unknown-50 + unknown-51 + unknown-52 + unknown-53 + unknown-54 + unknown-55 + unknown-56 + unknown-57 + unknown-58 + unknown-59 + unknown-60 + unknown-61 + unknown-62 + unknown-63 + ) + ) (set! (-> obj collide-info trans quad) (-> s4-0 quad)) (let* ((v1-8 (-> gp-0 mesh origin)) (f0-1 (- (-> arg0 x) (-> v1-8 x))) diff --git a/test/decompiler/reference/levels/common/sharkey_REF.gc b/test/decompiler/reference/levels/common/sharkey_REF.gc index 7ab14e719b..47d7fee132 100644 --- a/test/decompiler/reference/levels/common/sharkey_REF.gc +++ b/test/decompiler/reference/levels/common/sharkey_REF.gc @@ -250,7 +250,7 @@ nav-enemy-default-event-handler (vector-normalize! (-> self dir) 1.0) (vector+*! gp-0 s4-0 (-> self dir) (- (-> self spawn-distance))) ) - (dummy-17 (-> self nav) gp-0 gp-0) + (project-onto-nav-mesh (-> self nav) gp-0 gp-0) (set! (-> gp-0 y) (-> self y-min)) (set! (-> self spawn-point quad) (-> gp-0 quad)) ) diff --git a/test/decompiler/reference/levels/common/texture-upload_REF.gc b/test/decompiler/reference/levels/common/texture-upload_REF.gc new file mode 100644 index 0000000000..d62f900330 --- /dev/null +++ b/test/decompiler/reference/levels/common/texture-upload_REF.gc @@ -0,0 +1,17 @@ +;;-*-Lisp-*- +(in-package goal) + +;; failed to figure out what this is: +(setup-font-texture! *texture-pool*) + +;; definition for symbol *shadow-middot-texture*, type texture +(define *shadow-middot-texture* (lookup-texture-by-id (new 'static 'texture-id :index #x4 :page #x2))) + +;; definition for symbol *generic-envmap-texture*, type texture +(define *generic-envmap-texture* (lookup-texture-by-id (the-as texture-id #x10000014))) + +;; definition for symbol *ocean-texture*, type texture +(define *ocean-texture* (lookup-texture-by-id (new 'static 'texture-id :page #x370))) + +;; failed to figure out what this is: +(set! (-> *texture-pool* allocate-func) texture-page-common-boot-allocate) diff --git a/test/decompiler/reference/levels/maincave/mother-spider_REF.gc b/test/decompiler/reference/levels/maincave/mother-spider_REF.gc index b6648f64aa..fcd13a47f0 100644 --- a/test/decompiler/reference/levels/maincave/mother-spider_REF.gc +++ b/test/decompiler/reference/levels/maincave/mother-spider_REF.gc @@ -1437,7 +1437,7 @@ (> (-> self birthing-counter) 0) (and (>= 49152.0 (- (-> self max-dist-from-anchor) (-> self dist-from-anchor))) (zero? (logand (-> *target* state-flags) #x80f8)) - (dummy-21 (-> self nav) (-> self root-override trans)) + (TODO-RENAME-21 (-> self nav) (-> self root-override trans)) ) ) (go mother-spider-birth-baby) @@ -1510,7 +1510,7 @@ (if (letgo-player? self) (go mother-spider-traveling (the-as uint 0)) ) - (if (not (dummy-21 (-> self nav) (-> self root-override trans))) + (if (not (TODO-RENAME-21 (-> self nav) (-> self root-override trans))) (go mother-spider-birthing) ) (TODO-RENAME-29 self #t #t) @@ -1578,7 +1578,73 @@ (defmethod TODO-RENAME-20 mother-spider ((obj mother-spider) (arg0 vector) (arg1 vector)) (set! (-> obj nav nav-cull-radius) 40960.0) (set-current-poly! (-> obj nav) (dummy-16 (-> obj nav) (-> obj root-override trans))) - (dummy-28 (-> obj nav) -1) + (TODO-RENAME-28 (-> obj nav) (collide-kind + background + cak-1 + cak-2 + cak-3 + target + water + powerup + crate + enemy + wall-object + projectile + ground-object + target-attack + mother-spider + cak-14 + blue-eco-suck + unknown-16 + unknown-17 + unknown-18 + unknown-19 + unknown-20 + unknown-21 + unknown-22 + unknown-23 + unknown-24 + unknown-25 + unknown-26 + unknown-27 + unknown-28 + unknown-29 + unknown-30 + unknown-31 + unknown-32 + unknown-33 + unknown-34 + unknown-35 + unknown-36 + unknown-37 + unknown-38 + unknown-39 + unknown-40 + unknown-41 + unknown-42 + unknown-43 + unknown-44 + unknown-45 + unknown-46 + unknown-47 + unknown-48 + unknown-49 + unknown-50 + unknown-51 + unknown-52 + unknown-53 + unknown-54 + unknown-55 + unknown-56 + unknown-57 + unknown-58 + unknown-59 + unknown-60 + unknown-61 + unknown-62 + unknown-63 + ) + ) (dotimes (s3-1 4) (let ((f28-0 (+ 32768.0 (-> obj orient-rot y))) (f30-0 (rand-vu-float-range 16384.0 40960.0)) @@ -1626,7 +1692,7 @@ ) ) ) - (dummy-17 (-> obj nav) arg0 (-> obj root-override trans)) + (project-onto-nav-mesh (-> obj nav) arg0 (-> obj root-override trans)) (let ((a1-12 (new 'stack-no-clear 'vector)) (s3-2 (new 'stack-no-clear 'collide-tri-result)) ) diff --git a/test/decompiler/reference/levels/rolling/rolling-lightning-mole_REF.gc b/test/decompiler/reference/levels/rolling/rolling-lightning-mole_REF.gc new file mode 100644 index 0000000000..9e0f89f203 --- /dev/null +++ b/test/decompiler/reference/levels/rolling/rolling-lightning-mole_REF.gc @@ -0,0 +1,1609 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition for function find-adjacent-bounds-one +;; Used lq/sq +(defun find-adjacent-bounds-one ((arg0 nav-mesh) (arg1 nav-poly) (arg2 int) (arg3 (array int8)) (arg4 (array int8)) (arg5 vector)) + (local-vars (v0-2 object) (v1-2 int) (v1-30 int) (a0-2 int) (a0-12 int) (sv-16 nav-poly) (sv-32 int)) + (let ((v1-1 (+ arg2 1))) + (let ((a0-1 2)) + (set-on-less-than a0-2 a0-1 v1-1) + ) + (move-if-not-zero v1-2 0 a0-2 v1-1) + ) + (let ((v1-4 (-> arg1 adj-poly v1-2))) + (cond + ((= v1-4 255) + ) + ((zero? (logand (-> arg0 poly v1-4 pat) 1)) + (format 0 "ERROR: find-adjacent-bounds-one given a non-boundary edge to start~%") + (return #f) + ) + ) + ) + (let ((s0-0 (-> arg1 vertex (-> arg3 arg2)))) + (set! sv-16 arg1) + (while (begin (label cfg-28) #t) + (set! sv-32 0) + (while (< sv-32 3) + (cond + ((and (= sv-32 arg2) (= sv-16 arg1)) + ) + ((= s0-0 (-> sv-16 vertex (-> arg4 sv-32))) + (vector+! arg5 (-> arg0 origin) (the-as vector (-> arg0 vertex (-> sv-16 vertex (-> arg3 sv-32))))) + (let ((v1-29 (+ sv-32 1))) + (let ((a0-11 2)) + (set-on-less-than a0-12 a0-11 v1-29) + ) + (move-if-not-zero v1-30 0 a0-12 v1-29) + ) + (let ((v1-32 (-> sv-16 adj-poly v1-30))) + (if (= v1-32 255) + (return #t) + ) + (let ((v1-35 (-> arg0 poly v1-32))) + (set! v0-2 (cond + ((= arg1 v1-35) + (format 0 "ERROR: find-adjacent-bounds-one given tried to go back~%") + ) + (else + (cond + ((logtest? (-> v1-35 pat) 1) + (return #t) + ) + (else + (set! arg1 sv-16) + (set! sv-16 v1-35) + (goto cfg-28) + ) + ) + v0-2 + ) + ) + ) + ) + ) + ) + ) + (set! sv-32 (+ sv-32 1)) + ) + (format 0 "ERROR: abnormal exit from find-adjacent-bounds-one~%") + (return #f) + ) + ) + #f + ) + +;; definition for function find-adjacent-bounds +;; WARN: Expression building failed: Function find-adjacent-bounds has a return type of none, but the expression builder found a return statement. +(defun find-adjacent-bounds ((arg0 nav-mesh) (arg1 clip-travel-vector-to-mesh-return-info)) + (when (!= (-> arg1 found-boundary) #t) + (format 0 "ERROR: find-adjacent-bounds passed info which doesn't specify a boundary edge~%") + (return #f) + ) + (find-adjacent-bounds-one + arg0 + (-> arg1 poly) + (-> arg1 edge) + *edge-vert0-table* + *edge-vert1-table* + (-> arg1 vert-prev) + ) + (find-adjacent-bounds-one + arg0 + (-> arg1 poly) + (-> arg1 edge) + *edge-vert1-table* + *edge-vert0-table* + (-> arg1 vert-next) + ) + (vector-reset! (-> arg1 prev-normal)) + (vector-reset! (-> arg1 next-normal)) + (set! (-> arg1 prev-normal x) (- (-> arg1 vert-prev z) (-> arg1 vert-0 z))) + (set! (-> arg1 prev-normal z) (- (-> arg1 vert-0 x) (-> arg1 vert-prev x))) + (set! (-> arg1 next-normal x) (- (-> arg1 vert-1 z) (-> arg1 vert-next z))) + (set! (-> arg1 next-normal z) (- (-> arg1 vert-next x) (-> arg1 vert-1 x))) + (vector-normalize! (-> arg1 prev-normal) 1.0) + (vector-normalize! (-> arg1 next-normal) 1.0) + (camera-line (-> arg1 vert-prev) (-> arg1 vert-0) (new 'static 'vector4w :x #xff :w #x80)) + (camera-line (-> arg1 vert-0) (-> arg1 vert-1) (new 'static 'vector4w :y #xff :w #x80)) + (camera-line (-> arg1 vert-1) (-> arg1 vert-next) (new 'static 'vector4w :z #xff :w #x80)) + (let ((s5-1 (new 'stack-no-clear 'vector))) + (vector+! s5-1 (-> arg1 vert-prev) (-> arg1 vert-0)) + (vector-float*! s5-1 s5-1 0.5) + (camera-line-rel-len s5-1 (-> arg1 prev-normal) 8192.0 (new 'static 'vector4w :x #xff :w #x80)) + (vector+! s5-1 (-> arg1 vert-0) (-> arg1 vert-1)) + (vector-float*! s5-1 s5-1 0.5) + (camera-line-rel-len s5-1 (-> arg1 boundary-normal) 8192.0 (new 'static 'vector4w :y #xff :w #x80)) + (vector+! s5-1 (-> arg1 vert-1) (-> arg1 vert-next)) + (vector-float*! s5-1 s5-1 0.5) + (camera-line-rel-len s5-1 (-> arg1 next-normal) 8192.0 (new 'static 'vector4w :z #xff :w #x80)) + ) + (none) + ) + +;; definition of type fleeing-nav-enemy-info +(deftype fleeing-nav-enemy-info (structure) + ((min-reflect-angle float :offset-assert 0) + (max-reflect-angle float :offset-assert 4) + (max-boundary-deflection float :offset-assert 8) + (deflection-min-dist float :offset-assert 12) + (deflection-max-dist float :offset-assert 16) + (reflection-time int32 :offset-assert 20) + (travel-rotate-speed float :offset-assert 24) + (blend_interp_angle float :offset-assert 28) + (min-speed-adjust float :offset-assert 32) + (max-speed-adjust float :offset-assert 36) + (speed-adjust-center float :offset-assert 40) + (speed-adjust-range float :offset-assert 44) + (abort-notice-distance float :offset-assert 48) + (min-notice-dist float :offset-assert 52) + (max-notice-dist float :offset-assert 56) + (min-stop-chase-dist float :offset-assert 60) + (max-stop-chase-dist float :offset-assert 64) + (max-flee-rotation float :offset-assert 68) + ) + :allow-misaligned + :method-count-assert 9 + :size-assert #x48 + :flag-assert #x900000048 + ) + +;; definition for method 3 of type fleeing-nav-enemy-info +(defmethod inspect fleeing-nav-enemy-info ((obj fleeing-nav-enemy-info)) + (format #t "[~8x] ~A~%" obj 'fleeing-nav-enemy-info) + (format #t "~Tmin-reflect-angle: ~f~%" (-> obj min-reflect-angle)) + (format #t "~Tmax-reflect-angle: ~f~%" (-> obj max-reflect-angle)) + (format #t "~Tmax-boundary-deflection: ~f~%" (-> obj max-boundary-deflection)) + (format #t "~Tdeflection-min-dist: ~f~%" (-> obj deflection-min-dist)) + (format #t "~Tdeflection-max-dist: ~f~%" (-> obj deflection-max-dist)) + (format #t "~Treflection-time: ~D~%" (-> obj reflection-time)) + (format #t "~Ttravel-rotate-speed: ~f~%" (-> obj travel-rotate-speed)) + (format #t "~Tblend_interp_angle: ~f~%" (-> obj blend_interp_angle)) + (format #t "~Tmin-speed-adjust: ~f~%" (-> obj min-speed-adjust)) + (format #t "~Tmax-speed-adjust: ~f~%" (-> obj max-speed-adjust)) + (format #t "~Tspeed-adjust-center: ~f~%" (-> obj speed-adjust-center)) + (format #t "~Tspeed-adjust-range: ~f~%" (-> obj speed-adjust-range)) + (format #t "~Tabort-notice-distance: ~f~%" (-> obj abort-notice-distance)) + (format #t "~Tmin-notice-dist: ~f~%" (-> obj min-notice-dist)) + (format #t "~Tmax-notice-dist: ~f~%" (-> obj max-notice-dist)) + (format #t "~Tmin-stop-chase-dist: ~f~%" (-> obj min-stop-chase-dist)) + (format #t "~Tmax-stop-chase-dist: ~f~%" (-> obj max-stop-chase-dist)) + (format #t "~Tmax-flee-rotation: ~f~%" (-> obj max-flee-rotation)) + obj + ) + +;; definition of type fleeing-nav-enemy +(deftype fleeing-nav-enemy (nav-enemy) + ((last-reflection-time uint64 :offset-assert 400) + (run-blend-interp float :offset-assert 408) + (desired-travel vector :inline :offset-assert 416) + (saved-travel vector :inline :offset-assert 432) + (speed-adjust float :offset-assert 448) + (flee-info fleeing-nav-enemy-info :inline :offset-assert 452) + ) + :heap-base #x1a0 + :method-count-assert 76 + :size-assert #x20c + :flag-assert #x4c01a0020c + (:states + fleeing-nav-enemy-debug + ) + ) + +;; definition for method 3 of type fleeing-nav-enemy +(defmethod inspect fleeing-nav-enemy ((obj fleeing-nav-enemy)) + (let ((t9-0 (method-of-type nav-enemy inspect))) + (t9-0 obj) + ) + (format #t "~T~Tlast-reflection-time: ~D~%" (-> obj last-reflection-time)) + (format #t "~T~Trun-blend-interp: ~f~%" (-> obj run-blend-interp)) + (format #t "~T~Tdesired-travel: #~%" (-> obj desired-travel)) + (format #t "~T~Tsaved-travel: #~%" (-> obj saved-travel)) + (format #t "~T~Tspeed-adjust: ~f~%" (-> obj speed-adjust)) + (format #t "~T~Tflee-info: #~%" (-> obj flee-info)) + obj + ) + +;; definition for function fleeing-nav-enemy-adjust-nav-info +(defbehavior fleeing-nav-enemy-adjust-nav-info fleeing-nav-enemy () + (let ((f30-0 (vector-vector-distance (-> *camera* tpos-curr-adj) (-> *camera* tpos-old-adj)))) + (set! (-> self nav-info notice-distance) (lerp-clamp + (-> self flee-info min-notice-dist) + (-> self flee-info max-notice-dist) + (parameter-ease-sin-clamp (* 0.00081380206 (+ -409.6 f30-0))) + ) + ) + (let ((f0-9 (lerp-clamp + (-> self flee-info min-stop-chase-dist) + (-> self flee-info max-stop-chase-dist) + (parameter-ease-sin-clamp (* 0.00081380206 (+ -409.6 f30-0))) + ) + ) + ) + (set! (-> self nav-info stop-chase-distance) f0-9) + f0-9 + ) + ) + ) + +;; definition for function fleeing-nav-enemy-clip-travel +;; Used lq/sq +(defun fleeing-nav-enemy-clip-travel ((arg0 fleeing-nav-enemy) (arg1 vector)) + (local-vars (sv-224 vector) (sv-240 vector) (sv-256 vector) (sv-272 vector) (sv-288 vector)) + (let ((s2-0 (new 'stack 'clip-travel-vector-to-mesh-return-info)) + (gp-0 (new 'stack-no-clear 'vector)) + (s1-0 #f) + ) + (set! (-> gp-0 quad) (-> arg0 nav travel quad)) + (set! (-> arg0 nav travel quad) (-> arg1 quad)) + (dummy-24 (-> arg0 nav) (-> arg0 flee-info deflection-max-dist) s2-0) + (when (-> s2-0 found-boundary) + (let ((s0-0 (new 'stack-no-clear 'vector)) + (s3-0 (new 'stack-no-clear 'vector)) + ) + 0.0 + 0.0 + (vector-! s0-0 (-> s2-0 intersection) (-> arg0 collide-info trans)) + (set! (-> arg0 nav travel quad) (-> s0-0 quad)) + (let ((f28-0 (vector-dot s0-0 (-> s2-0 boundary-normal)))) + (set! (-> s0-0 quad) (-> arg1 quad)) + (set! (-> s0-0 y) 0.0) + (vector-normalize! s0-0 1.0) + (let ((f30-0 (vector-dot s0-0 (-> s2-0 boundary-normal)))) + (cond + ((< (-> arg0 flee-info deflection-min-dist) f28-0) + (let* ((f0-9 (/ (- f28-0 (-> arg0 flee-info deflection-min-dist)) + (- (-> arg0 flee-info deflection-max-dist) (-> arg0 flee-info deflection-min-dist)) + ) + ) + (f0-10 (fmin 1.0 f0-9)) + (f28-1 (* (- 1.0 f0-10) (-> arg0 flee-info max-boundary-deflection))) + ) + (cond + ((< (cos f28-1) f30-0) + (vector--float*! s3-0 s0-0 (-> s2-0 boundary-normal) f30-0) + (let ((s0-1 vector-normalize!)) + (set! sv-224 s3-0) + (let ((a1-7 (sin f28-1))) + (s0-1 sv-224 a1-7) + ) + ) + (let ((s0-2 vector+float*!)) + (set! sv-240 s3-0) + (set! sv-256 s3-0) + (let ((s2-1 (-> s2-0 boundary-normal)) + (a3-1 (cos f28-1)) + ) + (s0-2 sv-240 sv-256 s2-1 a3-1) + ) + ) + ) + (else + (let ((v1-15 s3-0)) + (set! (-> v1-15 quad) (-> s0-0 quad)) + v1-15 + ) + ) + ) + ) + ) + ((< (cos (-> arg0 flee-info min-reflect-angle)) f30-0) + (vector--float*! s3-0 s0-0 (-> s2-0 boundary-normal) f30-0) + (vector-normalize! s3-0 (sin (-> arg0 flee-info min-reflect-angle))) + (let ((s1-2 vector--float*!) + (s0-4 s3-0) + ) + (set! sv-272 s3-0) + (let ((s2-2 (-> s2-0 boundary-normal)) + (a3-3 (cos (-> arg0 flee-info min-reflect-angle))) + ) + (s1-2 s0-4 sv-272 s2-2 a3-3) + ) + ) + (set! s1-0 #t) + ) + ((< f30-0 (cos (-> arg0 flee-info max-reflect-angle))) + (vector--float*! s3-0 s0-0 (-> s2-0 boundary-normal) f30-0) + (vector-normalize! s3-0 (sin (-> arg0 flee-info max-reflect-angle))) + (let ((s1-4 vector--float*!) + (s0-6 s3-0) + ) + (set! sv-288 s3-0) + (let ((s2-3 (-> s2-0 boundary-normal)) + (a3-5 (cos (-> arg0 flee-info max-reflect-angle))) + ) + (s1-4 s0-6 sv-288 s2-3 a3-5) + ) + ) + (set! s1-0 #t) + ) + (else + (vector--float*! s3-0 s0-0 (-> s2-0 boundary-normal) (* 2.0 f30-0)) + (set! s1-0 #t) + ) + ) + ) + ) + (vector-normalize-copy! arg1 s3-0 (-> arg0 flee-info deflection-max-dist)) + ) + ) + (set! (-> arg0 nav travel quad) (-> gp-0 quad)) + s1-0 + ) + ) + +;; definition for function fleeing-nav-enemy-adjust-travel +;; Used lq/sq +(defun fleeing-nav-enemy-adjust-travel ((arg0 fleeing-nav-enemy) (arg1 object)) + (let ((s3-0 (new 'stack-no-clear 'matrix)) + (s4-0 (new 'stack-no-clear 'vector)) + ) + (let ((s5-0 (new 'stack-no-clear 'vector))) + (set! (-> s4-0 quad) (-> arg0 saved-travel quad)) + (set! (-> s4-0 y) 0.0) + (set! (-> s5-0 quad) (-> arg0 desired-travel quad)) + (set! (-> s5-0 y) 0.0) + (vector-normalize! s4-0 1.0) + (vector-normalize! s5-0 1.0) + (matrix-from-two-vectors-max-angle-partial! s3-0 s4-0 s5-0 (-> arg0 flee-info travel-rotate-speed) 0.2) + ) + (vector-matrix*! (-> arg0 saved-travel) s4-0 s3-0) + ) + (vector-float*! (-> arg0 saved-travel) (-> arg0 saved-travel) (-> arg0 flee-info deflection-max-dist)) + (set! (-> arg0 nav travel quad) (-> arg0 saved-travel quad)) + (vector+! (-> arg0 nav target-pos) (-> arg0 collide-info trans) (-> arg0 nav travel)) + ) + +;; definition for function fleeing-nav-enemy-chase-post-func +(defbehavior fleeing-nav-enemy-chase-post-func fleeing-nav-enemy () + (let ((gp-0 (new 'stack-no-clear 'matrix)) + (s5-0 (new 'stack-no-clear 'matrix)) + ) + (quaternion->matrix gp-0 (-> self collide-info quat)) + (set! (-> self collide-info old-y-angle-diff) 0.0) + (nav-enemy-travel-post) + (quaternion->matrix s5-0 (-> self collide-info quat)) + (set! (-> self run-blend-interp) (acos (vector-dot (-> s5-0 vector 2) (-> gp-0 vector 2)))) + (set! (-> self run-blend-interp) (/ (-> self run-blend-interp) (-> self flee-info blend_interp_angle))) + (when (< (vector-dot (-> s5-0 vector 2) (the-as vector (-> gp-0 vector))) 0.0) + (let ((f0-8 (- (-> self run-blend-interp)))) + (set! (-> self run-blend-interp) f0-8) + f0-8 + ) + ) + ) + ) + +;; definition for function fleeing-nav-enemy-chase-post +;; INFO: Return type mismatch int vs none. +;; Used lq/sq +(defbehavior fleeing-nav-enemy-chase-post fleeing-nav-enemy () + (let ((gp-0 (new 'stack-no-clear 'vector))) + (vector-! gp-0 (-> self collide-info trans) (target-pos 0)) + (let* ((f0-1 (vector-dot (vector-normalize-copy! (new 'stack-no-clear 'vector) (-> self desired-travel) 1.0) gp-0)) + (f0-3 (/ (- (-> self flee-info speed-adjust-center) f0-1) (-> self flee-info speed-adjust-range))) + (f1-3 (+ 1.0 f0-3)) + ) + (set! (-> self target-speed) + (* (fmax (-> self flee-info min-speed-adjust) (fmin (-> self flee-info max-speed-adjust) f1-3)) + (-> self nav-info run-travel-speed) + ) + ) + ) + (when (>= (- (-> *display* base-frame-counter) (the-as int (-> self last-reflection-time))) + (-> self flee-info reflection-time) + ) + (let ((s3-0 (new 'stack-no-clear 'matrix)) + (s5-2 (new 'stack-no-clear 'vector)) + ) + (let ((s4-1 (new 'stack-no-clear 'vector))) + (set! (-> s5-2 quad) (-> self desired-travel quad)) + (set! (-> s5-2 y) 0.0) + (set! (-> s4-1 quad) (-> gp-0 quad)) + (set! (-> s4-1 y) 0.0) + (if (= (vector-normalize-ret-len! s5-2 1.0) 0.0) + (set! (-> s5-2 quad) (-> s4-1 quad)) + ) + (vector-normalize-ret-len! s4-1 1.0) + (matrix-from-two-vectors-max-angle-partial! s3-0 s5-2 s4-1 (-> self flee-info max-flee-rotation) 0.25) + ) + (vector-matrix*! s5-2 s5-2 s3-0) + (vector-float*! (-> self desired-travel) s5-2 (-> self flee-info deflection-max-dist)) + ) + ) + ) + (if (fleeing-nav-enemy-clip-travel self (-> self desired-travel)) + (set! (-> self last-reflection-time) (the-as uint (-> *display* base-frame-counter))) + ) + (fleeing-nav-enemy-adjust-travel self (-> self desired-travel)) + (fleeing-nav-enemy-chase-post-func) + 0 + (none) + ) + +;; failed to figure out what this is: +(defstate nav-enemy-patrol (fleeing-nav-enemy) + :virtual #t + :enter + (-> (method-of-type nav-enemy nav-enemy-patrol) enter) + :exit + (-> (method-of-type nav-enemy nav-enemy-patrol) exit) + :trans + (behavior () + ((-> (method-of-type nav-enemy nav-enemy-patrol) trans)) + (fleeing-nav-enemy-adjust-nav-info) + (none) + ) + :code + (-> (method-of-type nav-enemy nav-enemy-patrol) code) + :post + (-> (method-of-type nav-enemy nav-enemy-patrol) post) + ) + +;; failed to figure out what this is: +(defstate nav-enemy-notice (fleeing-nav-enemy) + :virtual #t + :enter + (-> (method-of-type nav-enemy nav-enemy-notice) enter) + :trans + (behavior () + (fleeing-nav-enemy-adjust-nav-info) + (none) + ) + :code + (behavior () + (ja-channel-push! 1 22) + (let ((f30-0 (nav-enemy-rnd-float-range 1.0 1.2))) + (let ((a0-2 (-> self skel root-channel 0))) + (set! (-> a0-2 frame-group) + (the-as art-joint-anim (-> self draw art-group data (-> self nav-info notice-anim))) + ) + (set! (-> a0-2 param 0) + (the float + (+ (-> (the-as art-joint-anim (-> self draw art-group data (-> self nav-info notice-anim))) data 0 length) -1) + ) + ) + (set! (-> a0-2 param 1) f30-0) + (set! (-> a0-2 frame-num) 0.0) + (joint-control-channel-group! + a0-2 + (the-as art-joint-anim (-> self draw art-group data (-> self nav-info notice-anim))) + num-func-seek! + ) + ) + (until (ja-done? 0) + (seek-toward-heading-vec! + (-> self collide-info) + (-> self nav travel) + (-> self rotate-speed) + (-> self turn-time) + ) + (if (and *target* (>= (-> self flee-info abort-notice-distance) + (vector-vector-distance (-> self collide-info trans) (-> *target* control trans)) + ) + ) + (go-virtual nav-enemy-chase) + ) + (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) f30-0) + (joint-control-channel-group-eval! a0-5 (the-as art-joint-anim #f) num-func-seek!) + ) + ) + ) + (go-virtual nav-enemy-chase) + (none) + ) + :post + (-> (method-of-type nav-enemy nav-enemy-notice) post) + ) + +;; failed to figure out what this is: +(defstate nav-enemy-chase (fleeing-nav-enemy) + :virtual #t + :enter + (behavior () + (logior! (-> self nav flags) (nav-control-flags bit12)) + ((-> (method-of-type nav-enemy nav-enemy-chase) enter)) + (none) + ) + :exit + (behavior () + (logclear! (-> self nav flags) (nav-control-flags bit12)) + (none) + ) + :trans + (behavior () + ((-> (method-of-type nav-enemy nav-enemy-chase) trans)) + (fleeing-nav-enemy-adjust-nav-info) + (none) + ) + :code + (-> (method-of-type nav-enemy nav-enemy-chase) code) + :post + (-> (method-of-type nav-enemy nav-enemy-chase) post) + ) + +;; failed to figure out what this is: +(defstate nav-enemy-stop-chase (fleeing-nav-enemy) + :virtual #t + :enter + (-> (method-of-type nav-enemy nav-enemy-stop-chase) enter) + :trans + (behavior () + ((-> (method-of-type nav-enemy nav-enemy-stop-chase) trans)) + (fleeing-nav-enemy-adjust-nav-info) + (none) + ) + :code + (-> (method-of-type nav-enemy nav-enemy-stop-chase) code) + :post + (-> (method-of-type nav-enemy nav-enemy-stop-chase) post) + ) + +;; failed to figure out what this is: +(defstate fleeing-nav-enemy-debug (fleeing-nav-enemy) + :enter + (-> (method-of-type nav-enemy nav-enemy-chase) enter) + :code + (behavior () + (let ((gp-0 (new-stack-vector0)) + (s5-0 (new-stack-vector0)) + ) + (set! (-> gp-0 x) 1.0) + (set! (-> s5-0 x) 1.0) + (while #t + (when (cpad-pressed? 1 r3) + (suspend) + (go fleeing-nav-enemy-debug) + ) + (let ((s2-0 (new-stack-vector0)) + (s4-0 (new-stack-vector0)) + ) + (let ((s3-0 (new-stack-matrix0))) + (clmf-input s2-0 s4-0 1) + (vector-float*! s2-0 s2-0 409.6) + (vector-float*! s4-0 s4-0 1820.4445) + (matrix-axis-angle! s3-0 (-> *camera* local-down) (-> s2-0 y)) + (vector-matrix*! gp-0 gp-0 s3-0) + ) + (if *target* + (vector-! gp-0 (-> self collide-info trans) (target-pos 0)) + ) + (vector-normalize! gp-0 (-> self flee-info deflection-max-dist)) + (let ((s3-3 (new 'stack-no-clear 'vector))) + (set! (-> s3-3 quad) (-> self nav travel quad)) + (set! (-> self nav travel quad) (-> s5-0 quad)) + (set! (-> self desired-travel quad) (-> gp-0 quad)) + (fleeing-nav-enemy-clip-travel self (-> self desired-travel)) + (fleeing-nav-enemy-adjust-travel self (-> self desired-travel)) + (set! (-> s5-0 quad) (-> self nav travel quad)) + (set! (-> self nav travel quad) (-> s3-3 quad)) + ) + (vector+! (-> self nav target-pos) (-> self collide-info trans) s4-0) + ) + (suspend) + ) + ) + (none) + ) + :post + (the-as (function none :behavior fleeing-nav-enemy) nav-enemy-travel-post) + ) + +;; definition for symbol *lightning-mole-hole*, type vector +(define *lightning-mole-hole* (new 'static 'vector :x -241664.0 :y 106496.0 :z -6393856.0)) + +;; definition of type lightning-mole +(deftype lightning-mole (fleeing-nav-enemy) + ((debug-vector vector :inline :offset-assert 528) + (alt-actor entity-actor :offset-assert 544) + ) + :heap-base #x1c0 + :method-count-assert 76 + :size-assert #x224 + :flag-assert #x4c01c00224 + (:states + lightning-mole-debug-blend + lightning-mole-debug-run + lightning-mole-dive + lightning-mole-gone + lightning-mole-head-for-hole + lightning-mole-hiding + lightning-mole-yelp + ) + ) + +;; definition for method 3 of type lightning-mole +(defmethod inspect lightning-mole ((obj lightning-mole)) + (let ((t9-0 (method-of-type fleeing-nav-enemy inspect))) + (t9-0 obj) + ) + (format #t "~T~Tdebug-vector: #~%" (-> obj debug-vector)) + (format #t "~T~Talt-actor: ~A~%" (-> obj alt-actor)) + obj + ) + +;; failed to figure out what this is: +(defskelgroup *lightning-mole-sg* lightning-mole + 0 + 5 + ((1 (meters 20)) (2 (meters 40)) (3 (meters 999999))) + :bounds (static-spherem 0 0 0 8) + :longest-edge (meters 0) + :shadow 4 + ) + +;; definition for function lightning-mole-task-complete? +(defbehavior lightning-mole-task-complete? lightning-mole () + (local-vars (sv-16 symbol)) + (process-entity-status! self (entity-perm-status complete) #t) + (when (or (-> self link prev) (-> self link next)) + (set! sv-16 (the-as symbol #f)) + (apply-all (-> self link) actor-link-subtask-complete-hook (& sv-16)) + (cond + (sv-16 + (close-specific-task! (-> self entity extra perm task) (task-status need-reminder)) + (let ((gp-0 (get-process *default-dead-pool* process #x4000))) + (when gp-0 + (let ((t9-4 (method-of-type process activate))) + (t9-4 gp-0 self 'process (the-as pointer #x70004000)) + ) + (run-next-time-in-process gp-0 (lambda :behavior lightning-mole + () + (while (or (-> *setting-control* current ambient) + (-> *setting-control* current movie) + (-> *setting-control* current hint) + ) + (suspend) + ) + (level-hint-spawn + (game-text-id rolling-lightning-moles-completion) + "sksp0112" + (the-as entity #f) + *entity-pool* + (game-task none) + ) + (none) + ) + ) + (-> gp-0 ppointer) + ) + ) + (format #t "lightning-mole task is complete~%") + ) + (else + ) + ) + sv-16 + ) + ) + +;; definition for function lightning-mole-hole-post +;; INFO: Return type mismatch int vs none. +;; Used lq/sq +(defbehavior lightning-mole-hole-post lightning-mole () + (set! (-> self nav target-pos quad) (-> *lightning-mole-hole* quad)) + (nav-enemy-travel-post) + 0 + (none) + ) + +;; definition for function lightning-mole-run-code +(defbehavior lightning-mole-run-code lightning-mole () + (when (!= (if (> (-> self skel active-channels) 0) + (-> self skel root-channel 0 frame-group) + ) + (-> self draw art-group data 7) + ) + (ja-channel-push! 1 60) + (let ((v1-6 (-> self skel root-channel 0))) + (set! (-> v1-6 frame-group) (the-as art-joint-anim (-> self draw art-group data 7))) + ) + ) + (while #t + (let ((a0-9 (-> self skel root-channel 0))) + (set! (-> a0-9 param 0) (-> self speed-adjust)) + (joint-control-channel-group-eval! a0-9 (the-as art-joint-anim #f) num-func-loop!) + ) + (suspend) + ) + (none) + ) + +;; failed to figure out what this is: +(defstate lightning-mole-debug-blend (lightning-mole) + :trans + (behavior () + (let ((gp-0 (new-stack-vector0))) + (let ((a1-0 (new-stack-vector0))) + (clmf-input gp-0 a1-0 1) + ) + (set! (-> self run-blend-interp) (-> gp-0 y)) + ) + (set! (-> self speed-adjust) 1.0) + (none) + ) + :code + lightning-mole-run-code + :post + (the-as (function none :behavior lightning-mole) ja-post) + ) + +;; failed to figure out what this is: +(defstate lightning-mole-debug-run (lightning-mole) + :enter + (behavior () + (set! (-> self speed-adjust) 1.0) + (set-vector! (-> self debug-vector) 0.0 0.0 1.0 1.0) + (set! (-> self saved-travel quad) (-> self debug-vector quad)) + ((-> (method-of-type nav-enemy nav-enemy-chase) enter)) + (none) + ) + :trans + (behavior () + (when (cpad-pressed? 1 r3) + (logclear! (-> *cpad-list* cpads 1 button0-abs 0) (pad-buttons r3)) + (logclear! (-> *cpad-list* cpads 1 button0-rel 0) (pad-buttons r3)) + (go lightning-mole-debug-run) + ) + (none) + ) + :code + lightning-mole-run-code + :post + (behavior () + (let ((gp-0 (new 'stack-no-clear 'vector))) + (let ((s4-0 (new-stack-vector0)) + (a1-0 (new-stack-vector0)) + (s5-0 (new-stack-matrix0)) + ) + (clmf-input s4-0 a1-0 1) + (vector-float*! s4-0 s4-0 1820.4445) + (matrix-axis-angle! s5-0 (-> *camera* local-down) (-> s4-0 y)) + (vector-matrix*! (-> self debug-vector) (-> self debug-vector) s5-0) + ) + (vector-normalize! (-> self debug-vector) (-> self flee-info deflection-max-dist)) + (camera-line-rel + (-> self collide-info trans) + (-> self debug-vector) + (new 'static 'vector4w :x #x80 :y #x80 :w #x80) + ) + (set! (-> gp-0 quad) (-> self debug-vector quad)) + (set! (-> self target-speed) (-> self nav-info run-travel-speed)) + (format *stdcon* "tgt-speed ~M defmd ~M~%" (-> self target-speed) (-> self flee-info deflection-max-dist)) + (if (>= (- (-> *display* base-frame-counter) (the-as int (-> self last-reflection-time))) + (-> self flee-info reflection-time) + ) + (vector-normalize-copy! (-> self desired-travel) gp-0 (-> self flee-info deflection-max-dist)) + ) + ) + (if (fleeing-nav-enemy-clip-travel self (-> self desired-travel)) + (set! (-> self last-reflection-time) (the-as uint (-> *display* base-frame-counter))) + ) + (set! (-> self debug-vector quad) (-> self desired-travel quad)) + (fleeing-nav-enemy-adjust-travel self (-> self desired-travel)) + (fleeing-nav-enemy-chase-post-func) + (camera-line-rel + (-> self collide-info trans) + (-> self desired-travel) + (new 'static 'vector4w :x #x80 :w #x80) + ) + (camera-line-rel (-> self collide-info trans) (-> self nav travel) (new 'static 'vector4w :z #x80 :w #x80)) + (camera-line (-> self collide-info trans) (-> self nav target-pos) (new 'static 'vector4w :z #x80 :w #x80)) + (none) + ) + ) + +;; failed to figure out what this is: +(defstate lightning-mole-gone (lightning-mole) + :code + (behavior () + (dummy-18 self) + (ja-channel-set! 0) + (ja-post) + (while (-> self child) + (suspend) + ) + (deactivate self) + (none) + ) + ) + +;; failed to figure out what this is: +(defstate lightning-mole-hiding (lightning-mole) + :enter + (behavior () + (ja-channel-set! 0) + (clear-collide-with-as (-> self collide-info)) + (none) + ) + :trans + (behavior () + (when (task-closed? (-> self entity extra perm task) (task-status need-introduction)) + (ja-channel-set! 1) + (let ((v1-4 (-> self skel root-channel 0))) + (set! (-> v1-4 frame-group) (the-as art-joint-anim (-> self draw art-group data 5))) + ) + (restore-collide-with-as (-> self collide-info)) + (go-virtual nav-enemy-idle) + ) + (none) + ) + :code + (behavior () + (while #t + (suspend) + ) + (none) + ) + ) + +;; failed to figure out what this is: +(defstate lightning-mole-dive (lightning-mole) + :trans + (behavior () + (when (< (vector-vector-xz-distance *lightning-mole-hole* (-> self collide-info trans)) 61440.0) + (let ((a1-1 (new 'stack-no-clear 'event-message-block))) + (set! (-> a1-1 from) self) + (set! (-> a1-1 num-params) 0) + (set! (-> a1-1 message) 'hide) + (let ((t9-1 send-event-function) + (v1-2 (-> self alt-actor)) + ) + (t9-1 + (if v1-2 + (-> v1-2 extra process) + ) + a1-1 + ) + ) + ) + ) + (none) + ) + :code + (behavior () + (let ((f30-0 (nav-enemy-rnd-float-range 0.9 1.1)) + (gp-0 (new 'stack-no-clear 'vector)) + ) + (vector+! gp-0 *lightning-mole-hole* (new 'static 'vector :x 81920.0 :y 40960.0)) + (hide-hud-quick) + (if *target* + (logior! (-> *target* mask) (process-mask sleep)) + ) + (ambient-hint-spawn "gamcam20" (the-as vector #f) *entity-pool* 'camera) + (ja-channel-push! 1 60) + (let ((a0-5 (-> self skel root-channel 0))) + (set! (-> a0-5 frame-group) (the-as art-joint-anim (-> self draw art-group data 12))) + (set! (-> a0-5 param 0) + (the float (+ (-> (the-as art-joint-anim (-> self draw art-group data 12)) data 0 length) -1)) + ) + (set! (-> a0-5 param 1) f30-0) + (set! (-> a0-5 frame-num) 0.0) + (joint-control-channel-group! a0-5 (the-as art-joint-anim (-> self draw art-group data 12)) num-func-seek!) + ) + (until (ja-done? 0) + (let ((s5-0 (new 'stack-no-clear 'vector))) + (set! (-> *camera-other-fov* data) 11650.845) + (vector-! s5-0 *lightning-mole-hole* gp-0) + (vector-normalize! s5-0 1.0) + (forward-down->inv-matrix *camera-other-matrix* s5-0 (-> *camera* local-down)) + ) + (set! (-> *camera-other-trans* quad) (-> gp-0 quad)) + (set! (-> *camera-other-root* quad) (-> *lightning-mole-hole* quad)) + (set! *camera-look-through-other* 2) + (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) f30-0) + (joint-control-channel-group-eval! a0-13 (the-as art-joint-anim #f) num-func-seek!) + ) + ) + ) + (lightning-mole-task-complete?) + (if *target* + (logclear! (-> *target* mask) (process-mask sleep)) + ) + (go lightning-mole-gone) + (none) + ) + :post + lightning-mole-hole-post + ) + +;; failed to figure out what this is: +(defstate lightning-mole-head-for-hole (lightning-mole) + :enter + (behavior () + (clear-collide-with-as (-> self collide-info)) + (none) + ) + :trans + (behavior () + (when (< (vector-vector-xz-distance *lightning-mole-hole* (-> self collide-info trans)) 61440.0) + (let ((a1-1 (new 'stack-no-clear 'event-message-block))) + (set! (-> a1-1 from) self) + (set! (-> a1-1 num-params) 0) + (set! (-> a1-1 message) 'hide) + (let ((t9-1 send-event-function) + (v1-3 (-> self alt-actor)) + ) + (t9-1 + (if v1-3 + (-> v1-3 extra process) + ) + a1-1 + ) + ) + ) + ) + (if (< (vector-vector-distance (-> self collide-info trans) *lightning-mole-hole*) 40960.0) + (go lightning-mole-dive) + ) + (none) + ) + :code + (-> (method-of-type fleeing-nav-enemy nav-enemy-chase) code) + :post + lightning-mole-hole-post + ) + +;; failed to figure out what this is: +(defstate lightning-mole-yelp (lightning-mole) + :enter + (behavior () + (clear-collide-with-as (-> self collide-info)) + ((-> (method-of-type fleeing-nav-enemy nav-enemy-chase) enter)) + (none) + ) + :exit + (behavior () + (restore-collide-with-as (-> self collide-info)) + (none) + ) + :trans + (-> (method-of-type fleeing-nav-enemy nav-enemy-chase) trans) + :code + (behavior () + (ja-channel-push! 1 60) + (let ((f30-0 (nav-enemy-rnd-float-range 0.9 1.1))) + (let ((a0-2 (-> self skel root-channel 0))) + (set! (-> a0-2 frame-group) (the-as art-joint-anim (-> self draw art-group data 10))) + (set! (-> a0-2 param 0) + (the float (+ (-> (the-as art-joint-anim (-> self draw art-group data 10)) data 0 length) -1)) + ) + (set! (-> a0-2 param 1) f30-0) + (set! (-> a0-2 frame-num) 0.0) + (joint-control-channel-group! a0-2 (the-as art-joint-anim (-> self draw art-group data 10)) num-func-seek!) + ) + (until (ja-done? 0) + (suspend) + (let ((a0-3 (-> self skel root-channel 0))) + (set! (-> a0-3 param 0) (the float (+ (-> a0-3 frame-group data 0 length) -1))) + (set! (-> a0-3 param 1) f30-0) + (joint-control-channel-group-eval! a0-3 (the-as art-joint-anim #f) num-func-seek!) + ) + ) + ) + (go-virtual nav-enemy-chase) + (none) + ) + :post + (the-as (function none :behavior lightning-mole) nav-enemy-simple-post) + ) + +;; failed to figure out what this is: +(defstate nav-enemy-stop-chase (lightning-mole) + :virtual #t + :code + lightning-mole-run-code + :post + (the-as (function none :behavior lightning-mole) fleeing-nav-enemy-chase-post) + ) + +;; failed to figure out what this is: +(defstate nav-enemy-chase (lightning-mole) + :virtual #t + :enter + (behavior () + (set! (-> self speed-adjust) 1.0) + (set! (-> self run-blend-interp) 0.0) + (vector-! (-> self saved-travel) (-> self collide-info trans) (target-pos 0)) + ((-> (method-of-type fleeing-nav-enemy nav-enemy-chase) enter)) + (none) + ) + :trans + (behavior () + (let ((s3-0 (new 'stack-no-clear 'vector)) + (s4-0 (new 'stack-no-clear 'vector)) + (gp-0 (new 'stack-no-clear 'vector)) + ) + 0.0 + 0.0 + (let ((f30-0 (vector-vector-distance (-> self collide-info trans) (target-pos 0)))) + 0.0 + 0.0 + (let ((s5-1 (new 'stack-no-clear 'vector))) + (vector-! s3-0 *lightning-mole-hole* (-> self collide-info trans)) + (vector-! s4-0 (-> self collide-info trans) (target-pos 0)) + (vector-! gp-0 *lightning-mole-hole* (target-pos 0)) + (let ((f26-0 (vector-normalize-ret-len! s3-0 1.0)) + (f28-0 (vector-normalize-ret-len! s4-0 1.0)) + ) + (vector-normalize! gp-0 1.0) + (set! (-> s5-1 quad) (-> *camera* tgt-face-mat vector 2 quad)) + (set! (-> s5-1 y) 0.0) + (vector-normalize! s5-1 1.0) + (let ((f24-0 (vector-dot s5-1 s4-0))) + (when (< f26-0 61440.0) + (let ((a1-7 (new 'stack-no-clear 'event-message-block))) + (set! (-> a1-7 from) self) + (set! (-> a1-7 num-params) 0) + (set! (-> a1-7 message) 'hide) + (let ((t9-8 send-event-function) + (v1-10 (-> self alt-actor)) + ) + (t9-8 + (if v1-10 + (-> v1-10 extra process) + ) + a1-7 + ) + ) + ) + ) + (if (and (< 40960.0 f26-0) + (< f26-0 81920.0) + (< f30-0 204800.0) + (< (+ 20480.0 f26-0) f28-0) + (< (cos 7281.778) (vector-dot s5-1 gp-0)) + (< (cos 7281.778) f24-0) + ) + (go lightning-mole-head-for-hole) + ) + ) + ) + ) + ) + ) + ((-> (method-of-type fleeing-nav-enemy nav-enemy-chase) trans)) + (none) + ) + :code + lightning-mole-run-code + :post + (the-as (function none :behavior lightning-mole) fleeing-nav-enemy-chase-post) + ) + +;; definition for method 43 of type lightning-mole +;; INFO: Return type mismatch symbol vs object. +(defmethod dummy-43 lightning-mole ((obj lightning-mole) (arg0 process) (arg1 event-message-block)) + (send-event arg0 'get-attack-count 1) + (when (!= (-> obj state) lightning-mole-yelp) + (send-event arg0 'jump 32768.0 32768.0) + (go lightning-mole-yelp) + ) + (the-as object #t) + ) + +;; definition for method 44 of type lightning-mole +;; INFO: Return type mismatch symbol vs object. +(defmethod dummy-44 lightning-mole ((obj lightning-mole) (arg0 process) (arg1 event-message-block)) + (when (!= (-> obj state) lightning-mole-yelp) + (send-event arg0 'jump 32768.0 32768.0) + (go lightning-mole-yelp) + ) + (the-as object #t) + ) + +;; definition for symbol *lightning-mole-nav-enemy-info*, type nav-enemy-info +(define *lightning-mole-nav-enemy-info* (new 'static 'nav-enemy-info + :idle-anim 5 + :walk-anim 7 + :turn-anim -1 + :notice-anim 6 + :run-anim 7 + :jump-anim -1 + :jump-land-anim -1 + :victory-anim 12 + :taunt-anim -1 + :die-anim -1 + :neck-joint 5 + :player-look-at-joint 5 + :run-travel-speed (meters 30.0) + :run-rotate-speed (degrees 3000.0) + :run-acceleration (meters 1.0) + :run-turn-time (seconds 0.1) + :walk-travel-speed (meters 30.0) + :walk-rotate-speed (degrees 3000.0) + :walk-acceleration (meters 1.0) + :walk-turn-time (seconds 0.1) + :attack-shove-back (meters 3.0) + :attack-shove-up (meters 2.0) + :shadow-size (meters 2.0) + :notice-nav-radius (meters 2.0) + :nav-nearest-y-threshold (meters 10.0) + :notice-distance (meters 35.0) + :stop-chase-distance (meters 45.0) + :frustration-distance (meters 8.0) + :frustration-time #x4b0 + :die-anim-hold-frame 10000000000.0 + :jump-land-anim-end-frame 10000000000.0 + :jump-height-min (meters 1.0) + :jump-height-factor 0.5 + :jump-start-anim-speed 1.0 + :shadow-max-y (meters 1.0) + :shadow-min-y (meters -1.0) + :shadow-locus-dist (meters 150.0) + :use-align #f + :draw-shadow #f + :move-to-ground #t + :hover-if-no-ground #t + :use-momentum #f + :use-flee #f + :use-proximity-notice #f + :use-jump-blocked #f + :use-jump-patrol #f + :gnd-collide-with #x1 + :debug-draw-neck #f + :debug-draw-jump #f + ) + ) + +;; definition for method 11 of type lightning-mole +;; INFO: Return type mismatch object vs none. +(defmethod init-from-entity! lightning-mole ((obj lightning-mole) (arg0 entity-actor)) + (let ((s4-0 (new 'process 'collide-shape-moving obj (collide-list-enum hit-by-player)))) + (set! (-> s4-0 dynam) (copy *standard-dynamics* 'process)) + (set! (-> s4-0 reaction) default-collision-reaction) + (set! (-> s4-0 no-reaction) + (the-as (function collide-shape-moving collide-shape-intersect vector vector none) nothing) + ) + (let ((s3-0 (new 'process 'collide-shape-prim-sphere s4-0 (the-as uint 0)))) + (set! (-> s3-0 prim-core collide-as) (collide-kind enemy)) + (set! (-> s3-0 collide-with) (collide-kind target)) + (set! (-> s3-0 prim-core action) (collide-action solid ca-10 ca-11)) + (set! (-> s3-0 prim-core offense) (collide-offense indestructible)) + (set-vector! (-> s3-0 local-sphere) 0.0 10240.0 0.0 10240.0) + (set-root-prim! s4-0 s3-0) + ) + (set! (-> s4-0 nav-radius) (* 0.75 (-> s4-0 root-prim local-sphere w))) + (backup-collide-with-as s4-0) + (set! (-> obj collide-info) s4-0) + ) + (process-drawable-from-entity! obj arg0) + (initialize-skeleton obj *lightning-mole-sg* '()) + (TODO-RENAME-45 obj *lightning-mole-nav-enemy-info*) + (logclear! (-> obj nav flags) (nav-control-flags bit5 bit6 bit7)) + (set! (-> obj draw origin-joint-index) (the-as uint 3)) + (set! (-> obj reaction-time) 15) + (set! (-> obj last-reflection-time) (the-as uint 0)) + (set! (-> obj collide-info pause-adjust-distance) 122880.0) + (set! (-> obj link) (new 'process 'actor-link-info obj)) + (set! (-> obj alt-actor) (entity-actor-lookup arg0 'alt-actor 0)) + (set! (-> obj flee-info min-reflect-angle) 10922.667) + (set! (-> obj flee-info max-reflect-angle) 14563.556) + (set! (-> obj flee-info max-boundary-deflection) 18204.445) + (set! (-> obj flee-info deflection-min-dist) 20480.0) + (set! (-> obj flee-info deflection-max-dist) 49152.0) + (set! (-> obj flee-info reflection-time) 225) + (set! (-> obj flee-info travel-rotate-speed) 1820.4445) + (set! (-> obj flee-info blend_interp_angle) 2184.5334) + (set! (-> obj flee-info min-speed-adjust) 0.8) + (set! (-> obj flee-info max-speed-adjust) 1.2) + (set! (-> obj flee-info speed-adjust-center) 40960.0) + (set! (-> obj flee-info speed-adjust-range) 20480.0) + (set! (-> obj flee-info abort-notice-distance) 49152.0) + (set! (-> obj flee-info min-notice-dist) 61440.0) + (set! (-> obj flee-info max-notice-dist) 143360.0) + (set! (-> obj flee-info min-stop-chase-dist) 40960.0) + (set! (-> obj flee-info max-stop-chase-dist) 184320.0) + (set! (-> obj flee-info max-flee-rotation) 364.0889) + (cond + ((and (-> obj entity) (logtest? (-> obj entity extra perm status) (entity-perm-status complete))) + (go lightning-mole-gone) + ) + ((task-closed? (-> obj entity extra perm task) (task-status need-introduction)) + (go (method-of-object obj nav-enemy-idle)) + ) + (else + (go lightning-mole-hiding) + ) + ) + (none) + ) + +;; failed to figure out what this is: +(defpartgroup group-peeper + :id 456 + :duration 5 + :bounds (static-bspherem 0 0 0 15) + :parts + ((sp-item 1768) (sp-item 1769 :period 120 :length 30) (sp-item 1770 :period 120 :length 60)) + ) + +;; failed to figure out what this is: +(defpart 1768 + :init-specs + ((sp-tex spt-texture (new 'static 'texture-id :page #x2)) + (sp-flt spt-num 0.25) + (sp-rnd-flt spt-x (meters -2) (meters 4) 1.0) + (sp-flt spt-y (meters -2)) + (sp-rnd-flt spt-z (meters -2) (meters 4) 1.0) + (sp-rnd-flt spt-scale-x (meters 4) (meters 2) 1.0) + (sp-rnd-flt spt-rot-z (degrees 0.0) (degrees 360.0) 1.0) + (sp-copy-from-other spt-scale-y -4) + (sp-rnd-flt spt-r 128.0 64.0 1.0) + (sp-rnd-flt spt-g 96.0 32.0 1.0) + (sp-rnd-flt spt-b 64.0 16.0 1.0) + (sp-rnd-flt spt-a 32.0 32.0 1.0) + (sp-rnd-flt spt-vel-x (meters -0.006666667) (meters 0.013333334) 1.0) + (sp-rnd-flt spt-vel-y (meters 0.04) (meters 0.026666667) 1.0) + (sp-rnd-flt spt-vel-z (meters -0.006666667) (meters 0.013333334) 1.0) + (sp-rnd-flt spt-rotvel-z (degrees -1.2) (degrees 2.4) 1.0) + (sp-flt spt-fade-a -0.21333334) + (sp-flt spt-accel-y -2.7306666) + (sp-flt spt-friction 0.97) + (sp-int spt-timer 450) + (sp-cpuinfo-flags bit2 bit12) + ) + ) + +;; failed to figure out what this is: +(defpart 1769 + :init-specs + ((sp-tex spt-texture (new 'static 'texture-id :page #x2)) + (sp-flt spt-num 0.5) + (sp-rnd-flt spt-x (meters -2) (meters 4) 1.0) + (sp-flt spt-y (meters -2)) + (sp-rnd-flt spt-z (meters -2) (meters 4) 1.0) + (sp-rnd-flt spt-scale-x (meters 4) (meters 2) 1.0) + (sp-rnd-flt spt-rot-z (degrees 0.0) (degrees 360.0) 1.0) + (sp-copy-from-other spt-scale-y -4) + (sp-rnd-flt spt-r 128.0 64.0 1.0) + (sp-rnd-flt spt-g 96.0 32.0 1.0) + (sp-rnd-flt spt-b 64.0 16.0 1.0) + (sp-rnd-flt spt-a 32.0 32.0 1.0) + (sp-rnd-flt spt-vel-x (meters -0.006666667) (meters 0.013333334) 1.0) + (sp-rnd-flt spt-vel-y (meters 0.04) (meters 0.026666667) 1.0) + (sp-rnd-flt spt-vel-z (meters -0.006666667) (meters 0.013333334) 1.0) + (sp-rnd-flt spt-rotvel-z (degrees -1.2) (degrees 2.4) 1.0) + (sp-flt spt-fade-a -0.21333334) + (sp-flt spt-friction 0.98) + (sp-int spt-timer 450) + (sp-cpuinfo-flags bit2 bit12) + ) + ) + +;; failed to figure out what this is: +(defpart 1770 + :init-specs + ((sp-tex spt-texture (new 'static 'texture-id :index #x1d :page #x2)) + (sp-flt spt-num 5.0) + (sp-rnd-flt spt-x (meters -1) (meters 2) 1.0) + (sp-flt spt-y (meters 0)) + (sp-rnd-flt spt-z (meters -1) (meters 2) 1.0) + (sp-rnd-flt spt-scale-x (meters 0.25) (meters 0.1) 1.0) + (sp-rnd-flt spt-rot-z (degrees 0.0) (degrees 360.0) 1.0) + (sp-copy-from-other spt-scale-y -4) + (sp-rnd-flt spt-r 128.0 64.0 1.0) + (sp-rnd-flt spt-g 96.0 32.0 1.0) + (sp-rnd-flt spt-b 64.0 16.0 1.0) + (sp-flt spt-a 128.0) + (sp-rnd-flt spt-vel-y (meters 0.06666667) (meters 0.053333335) 1.0) + (sp-rnd-flt spt-rotvel-z (degrees -1.2) (degrees 2.4) 1.0) + (sp-flt spt-accel-y -10.922667) + (sp-int spt-timer 450) + (sp-cpuinfo-flags bit2 bit12) + (sp-flt spt-userdata 106496.0) + (sp-func spt-func 'check-drop-level-rolling-dirt) + (sp-rnd-flt spt-conerot-x (degrees 0.0) (degrees 20.0) 1.0) + (sp-rnd-flt spt-conerot-y (degrees 180.0) (degrees 180.0) 1.0) + (sp-rnd-flt spt-conerot-radius (meters 0) (meters 2) 1.0) + ) + ) + +;; failed to figure out what this is: +(defpart 1771 + :init-specs + ((sp-tex spt-texture (new 'static 'texture-id :index #x1d :page #x2)) + (sp-rnd-flt spt-num 1.0 1.0 1.0) + (sp-flt spt-y (meters 0)) + (sp-rnd-flt spt-scale-x (meters 0.15) (meters 0.05) 1.0) + (sp-rnd-flt spt-rot-z (degrees 0.0) (degrees 360.0) 1.0) + (sp-copy-from-other spt-scale-y -4) + (sp-rnd-flt spt-r 128.0 64.0 1.0) + (sp-rnd-flt spt-g 96.0 32.0 1.0) + (sp-rnd-flt spt-b 64.0 16.0 1.0) + (sp-flt spt-a 128.0) + (sp-rnd-flt spt-vel-y (meters 0.033333335) (meters 0.016666668) 1.0) + (sp-rnd-flt spt-rotvel-z (degrees -1.2) (degrees 2.4) 1.0) + (sp-flt spt-accel-y -10.922667) + (sp-int spt-timer 300) + (sp-cpuinfo-flags bit2 bit12) + (sp-flt spt-userdata 106496.0) + (sp-func spt-func 'check-drop-level-rolling-dirt-finish) + (sp-rnd-flt spt-conerot-x (degrees 0.0) (degrees 30.0) 1.0) + (sp-rnd-flt spt-conerot-y (degrees 0.0) (degrees 360.0) 1.0) + (sp-flt spt-conerot-radius (meters 0)) + ) + ) + +;; failed to figure out what this is: +(defpart 1772 + :init-specs + ((sp-tex spt-texture (new 'static 'texture-id :index #x1d :page #x2)) + (sp-flt spt-num 1.0) + (sp-rnd-flt spt-scale-x (meters 0.15) (meters 0.05) 1.0) + (sp-rnd-flt spt-rot-z (degrees 0.0) (degrees 360.0) 1.0) + (sp-copy-from-other spt-scale-y -4) + (sp-rnd-flt spt-r 128.0 64.0 1.0) + (sp-rnd-flt spt-g 96.0 32.0 1.0) + (sp-rnd-flt spt-b 64.0 16.0 1.0) + (sp-rnd-flt spt-a 64.0 64.0 1.0) + (sp-rnd-flt spt-vel-y (meters 0) (meters 0.013333334) 1.0) + (sp-rnd-flt spt-rotvel-z (degrees -1.2) (degrees 2.4) 1.0) + (sp-flt spt-fade-a -0.14222223) + (sp-flt spt-friction 0.9) + (sp-int spt-timer 900) + (sp-cpuinfo-flags bit2 bit12) + (sp-flt spt-conerot-x (degrees 90.0)) + (sp-rnd-flt spt-conerot-y (degrees 0.0) (degrees 360.0) 1.0) + ) + ) + +;; definition for function check-drop-level-rolling-dirt +(defun check-drop-level-rolling-dirt ((arg0 sparticle-system) (arg1 sparticle-cpuinfo) (arg2 vector)) + (when (< (-> arg2 y) (-> arg1 user-float)) + (let ((gp-0 (new 'stack-no-clear 'vector))) + (sp-kill-particle arg0 arg1) + (set-vector! gp-0 (-> arg2 x) (-> arg1 user-float) (-> arg2 z) 1.0) + (sp-launch-particles-var + *sp-particle-system-2d* + (-> *part-id-table* 1771) + gp-0 + (the-as sparticle-launch-state #f) + (the-as sparticle-launch-control #f) + 1.0 + ) + ) + ) + (none) + ) + +;; definition for function check-drop-level-rolling-dirt-finish +(defun check-drop-level-rolling-dirt-finish ((arg0 sparticle-system) (arg1 sparticle-cpuinfo) (arg2 vector)) + (when (< (-> arg2 y) (-> arg1 user-float)) + (let ((gp-0 (new 'stack-no-clear 'vector))) + (sp-kill-particle arg0 arg1) + (let* ((v1-1 (/ (the-as int (rand-uint31-gen *random-generator*)) 256)) + (v1-2 (the-as number (logior #x3f800000 v1-1))) + ) + (if (< (+ -1.0 (the-as float v1-2)) 0.05) + (sound-play-by-name (static-sound-name "land-grass") (new-sound-id) 1024 0 0 1 #t) + ) + ) + (set-vector! gp-0 (-> arg2 x) (-> arg1 user-float) (-> arg2 z) 1.0) + (sp-launch-particles-var + *sp-particle-system-2d* + (-> *part-id-table* 1772) + gp-0 + (the-as sparticle-launch-state #f) + (the-as sparticle-launch-control #f) + 1.0 + ) + ) + ) + (none) + ) + +;; definition of type peeper +(deftype peeper (process-drawable) + () + :heap-base #x40 + :method-count-assert 20 + :size-assert #xb0 + :flag-assert #x14004000b0 + (:states + peeper-down + peeper-hide + peeper-up + peeper-wait + ) + ) + +;; definition for method 3 of type peeper +(defmethod inspect peeper ((obj peeper)) + (let ((t9-0 (method-of-type process-drawable inspect))) + (t9-0 obj) + ) + obj + ) + +;; failed to figure out what this is: +(defstate peeper-wait (peeper) + :event + (behavior ((arg0 process) (arg1 int) (arg2 symbol) (arg3 event-message-block)) + (let ((v1-0 arg2)) + (the-as object (when (= v1-0 'hide) + (let ((v0-0 (-> *display* base-frame-counter))) + (set! (-> self state-time) v0-0) + v0-0 + ) + ) + ) + ) + ) + :enter + (behavior () + (if (nonzero? (-> self sound)) + (stop! (-> self sound)) + ) + (set! (-> self state-time) (-> *display* base-frame-counter)) + (none) + ) + :trans + (behavior () + (if (and (>= (- (-> *display* base-frame-counter) (-> self state-time)) 300) + (not (and *target* (>= 81920.0 (vector-vector-xz-distance (-> self root trans) (-> *target* control trans))))) + ) + (go peeper-up) + ) + (none) + ) + :code + (behavior () + (logior! (-> self draw status) (draw-status drwf01)) + (while #t + (suspend) + ) + (none) + ) + :post + (the-as (function none :behavior peeper) ja-post) + ) + +;; failed to figure out what this is: +(defstate peeper-hide (peeper) + :code + (behavior () + (if (nonzero? (-> self sound)) + (stop! (-> self sound)) + ) + (let ((a0-1 (-> self skel root-channel 0))) + (set! (-> a0-1 param 0) (the float (+ (-> a0-1 frame-group data 0 length) -1))) + (set! (-> a0-1 param 1) 2.0) + (joint-control-channel-group! a0-1 (the-as art-joint-anim #f) num-func-seek!) + ) + (while (not (ja-done? 0)) + (suspend) + (ja-eval) + ) + (logior! (-> self draw status) (draw-status drwf01)) + (go peeper-wait) + (none) + ) + :post + (the-as (function none :behavior peeper) ja-post) + ) + +;; failed to figure out what this is: +(defstate peeper-down (peeper) + :event + (behavior ((arg0 process) (arg1 int) (arg2 symbol) (arg3 event-message-block)) + (case arg2 + (('hide) + (go peeper-wait) + ) + ) + ) + :trans + (behavior () + (if (and *target* (>= 61440.0 (vector-vector-xz-distance (-> self root trans) (-> *target* control trans)))) + (go peeper-wait) + ) + (none) + ) + :code + (behavior () + (logior! (-> self draw status) (draw-status drwf01)) + (set! (-> self state-time) (-> *display* base-frame-counter)) + (until (>= (- (-> *display* base-frame-counter) (-> self state-time)) 300) + (suspend) + ) + (let* ((f30-0 2.0) + (v1-10 (/ (the-as int (rand-uint31-gen *random-generator*)) 256)) + (v1-11 (the-as number (logior #x3f800000 v1-10))) + ) + (countdown (gp-0 (+ (the int (* f30-0 (+ -1.0 (the-as float v1-11)))) 1)) + (set! (-> self state-time) (-> *display* base-frame-counter)) + (until (>= (- (-> *display* base-frame-counter) (-> self state-time)) 1500) + (if (nonzero? (-> self sound)) + (update! (-> self sound)) + ) + (spawn (-> self part) (-> self root trans)) + (suspend) + ) + (set! (-> self state-time) (-> *display* base-frame-counter)) + (if (nonzero? (-> self sound)) + (stop! (-> self sound)) + ) + (until (>= (- (-> *display* base-frame-counter) (-> self state-time)) 900) + (suspend) + ) + ) + ) + (go peeper-up) + (none) + ) + :post + (the-as (function none :behavior peeper) ja-post) + ) + +;; failed to figure out what this is: +(defstate peeper-up (peeper) + :event + (behavior ((arg0 process) (arg1 int) (arg2 symbol) (arg3 event-message-block)) + (case arg2 + (('hide) + (go peeper-hide) + ) + ) + ) + :enter + (behavior () + (if (nonzero? (-> self sound)) + (stop! (-> self sound)) + ) + (logclear! (-> self draw status) (draw-status drwf01)) + (none) + ) + :trans + (behavior () + (if (and *target* (>= 61440.0 (vector-vector-xz-distance (-> self root trans) (-> *target* control trans)))) + (go peeper-hide) + ) + (none) + ) + :code + (behavior () + (while #t + (let ((a0-0 (-> self skel root-channel 0))) + (set! (-> a0-0 frame-group) (the-as art-joint-anim (-> self draw art-group data 13))) + (set! (-> a0-0 param 0) + (the float (+ (-> (the-as art-joint-anim (-> self draw art-group data 13)) data 0 length) -1)) + ) + (set! (-> a0-0 param 1) 1.0) + (set! (-> a0-0 frame-num) 0.0) + (joint-control-channel-group! a0-0 (the-as art-joint-anim (-> self draw art-group data 13)) num-func-seek!) + ) + (until (ja-done? 0) + (suspend) + (let ((a0-1 (-> self skel root-channel 0))) + (set! (-> a0-1 param 0) (the float (+ (-> a0-1 frame-group data 0 length) -1))) + (set! (-> a0-1 param 1) 1.0) + (joint-control-channel-group-eval! a0-1 (the-as art-joint-anim #f) num-func-seek!) + ) + ) + (go peeper-down) + ) + (none) + ) + :post + (the-as (function none :behavior peeper) ja-post) + ) + +;; definition for method 11 of type peeper +;; INFO: Return type mismatch object vs none. +(defmethod init-from-entity! peeper ((obj peeper) (arg0 entity-actor)) + (set! (-> obj root) (new 'process 'trsqv)) + (process-drawable-from-entity! obj arg0) + (initialize-skeleton obj *lightning-mole-sg* '()) + (set! (-> obj part) (create-launch-control (-> *part-group-id-table* 456) obj)) + (set! (-> obj sound) (new 'process 'ambient-sound arg0 (-> obj root trans))) + (go peeper-up) + (none) + ) diff --git a/test/decompiler/reference/levels/sunken/bully_REF.gc b/test/decompiler/reference/levels/sunken/bully_REF.gc index 5c50189d55..8d4fe3237d 100644 --- a/test/decompiler/reference/levels/sunken/bully_REF.gc +++ b/test/decompiler/reference/levels/sunken/bully_REF.gc @@ -498,7 +498,7 @@ 1.0 ) (let ((s5-1 #f)) - (dummy-28 (-> obj nav) 2560) + (TODO-RENAME-28 (-> obj nav) (collide-kind wall-object ground-object)) (let ((v1-4 (-> obj nav travel))) (.lvf vf1 (&-> (-> obj root-override transv) quad)) (let ((f0-8 (-> *display* seconds-per-frame))) @@ -793,7 +793,7 @@ #f #f ) - (dummy-27 (-> self nav)) + (TODO-RENAME-27 (-> self nav)) (none) ) :code diff --git a/test/decompiler/reference/levels/sunken/double-lurker_REF.gc b/test/decompiler/reference/levels/sunken/double-lurker_REF.gc index 88d45b3043..85650d01ae 100644 --- a/test/decompiler/reference/levels/sunken/double-lurker_REF.gc +++ b/test/decompiler/reference/levels/sunken/double-lurker_REF.gc @@ -385,7 +385,7 @@ ) (logior! (-> self collide-info nav-flags) 1) (set! (-> self collide-info nav-flags) (logand -3 (-> self collide-info nav-flags))) - (dummy-27 (-> self nav)) + (TODO-RENAME-27 (-> self nav)) (go double-lurker-top-resume) (none) ) @@ -468,7 +468,7 @@ (defmethod dummy-51 double-lurker-top ((obj double-lurker-top)) (restore-collide-with-as (-> obj collide-info)) (logior! (-> obj collide-info nav-flags) 1) - (the-as object (dummy-27 (-> obj nav))) + (the-as object (TODO-RENAME-27 (-> obj nav))) ) ;; definition for method 47 of type double-lurker-top @@ -861,7 +861,75 @@ (.svf (&-> v1-7 quad) vf1) ) (let ((gp-0 #f)) - (dummy-28 (-> self nav) -1) + (TODO-RENAME-28 + (-> self nav) + (collide-kind + background + cak-1 + cak-2 + cak-3 + target + water + powerup + crate + enemy + wall-object + projectile + ground-object + target-attack + mother-spider + cak-14 + blue-eco-suck + unknown-16 + unknown-17 + unknown-18 + unknown-19 + unknown-20 + unknown-21 + unknown-22 + unknown-23 + unknown-24 + unknown-25 + unknown-26 + unknown-27 + unknown-28 + unknown-29 + unknown-30 + unknown-31 + unknown-32 + unknown-33 + unknown-34 + unknown-35 + unknown-36 + unknown-37 + unknown-38 + unknown-39 + unknown-40 + unknown-41 + unknown-42 + unknown-43 + unknown-44 + unknown-45 + unknown-46 + unknown-47 + unknown-48 + unknown-49 + unknown-50 + unknown-51 + unknown-52 + unknown-53 + unknown-54 + unknown-55 + unknown-56 + unknown-57 + unknown-58 + unknown-59 + unknown-60 + unknown-61 + unknown-62 + unknown-63 + ) + ) (let ((a2-1 (new 'stack-no-clear 'check-vector-collision-with-nav-spheres-info))) (if (>= (dummy-23 (-> self nav) (-> self nav travel) a2-1) 0.0) (set! gp-0 #t) @@ -892,7 +960,7 @@ (-> self nav-info hover-if-no-ground) #f ) - (dummy-27 (-> self nav)) + (TODO-RENAME-27 (-> self nav)) (none) ) ) @@ -926,7 +994,73 @@ ;; definition for method 52 of type double-lurker ;; Used lq/sq (defmethod dummy-52 double-lurker ((obj double-lurker) (arg0 vector)) - (dummy-28 (-> obj nav) -1) + (TODO-RENAME-28 (-> obj nav) (collide-kind + background + cak-1 + cak-2 + cak-3 + target + water + powerup + crate + enemy + wall-object + projectile + ground-object + target-attack + mother-spider + cak-14 + blue-eco-suck + unknown-16 + unknown-17 + unknown-18 + unknown-19 + unknown-20 + unknown-21 + unknown-22 + unknown-23 + unknown-24 + unknown-25 + unknown-26 + unknown-27 + unknown-28 + unknown-29 + unknown-30 + unknown-31 + unknown-32 + unknown-33 + unknown-34 + unknown-35 + unknown-36 + unknown-37 + unknown-38 + unknown-39 + unknown-40 + unknown-41 + unknown-42 + unknown-43 + unknown-44 + unknown-45 + unknown-46 + unknown-47 + unknown-48 + unknown-49 + unknown-50 + unknown-51 + unknown-52 + unknown-53 + unknown-54 + unknown-55 + unknown-56 + unknown-57 + unknown-58 + unknown-59 + unknown-60 + unknown-61 + unknown-62 + unknown-63 + ) + ) (let ((a1-2 (new 'stack-no-clear 'vector))) (vector-float*! a1-2 (-> obj hit-from-dir) 22937.602) (vector+! a1-2 a1-2 (-> obj collide-info trans)) @@ -1045,7 +1179,75 @@ (.svf (&-> v1-7 quad) vf1) ) (let ((gp-0 #f)) - (dummy-28 (-> self nav) -1) + (TODO-RENAME-28 + (-> self nav) + (collide-kind + background + cak-1 + cak-2 + cak-3 + target + water + powerup + crate + enemy + wall-object + projectile + ground-object + target-attack + mother-spider + cak-14 + blue-eco-suck + unknown-16 + unknown-17 + unknown-18 + unknown-19 + unknown-20 + unknown-21 + unknown-22 + unknown-23 + unknown-24 + unknown-25 + unknown-26 + unknown-27 + unknown-28 + unknown-29 + unknown-30 + unknown-31 + unknown-32 + unknown-33 + unknown-34 + unknown-35 + unknown-36 + unknown-37 + unknown-38 + unknown-39 + unknown-40 + unknown-41 + unknown-42 + unknown-43 + unknown-44 + unknown-45 + unknown-46 + unknown-47 + unknown-48 + unknown-49 + unknown-50 + unknown-51 + unknown-52 + unknown-53 + unknown-54 + unknown-55 + unknown-56 + unknown-57 + unknown-58 + unknown-59 + unknown-60 + unknown-61 + unknown-62 + unknown-63 + ) + ) (let ((a2-1 (new 'stack-no-clear 'check-vector-collision-with-nav-spheres-info))) (if (>= (dummy-23 (-> self nav) (-> self nav travel) a2-1) 0.0) (set! gp-0 #t) @@ -1076,7 +1278,7 @@ (-> self nav-info hover-if-no-ground) #f ) - (dummy-27 (-> self nav)) + (TODO-RENAME-27 (-> self nav)) (none) ) ) diff --git a/test/decompiler/reference/levels/sunken/puffer_REF.gc b/test/decompiler/reference/levels/sunken/puffer_REF.gc index 122ec6243e..036775a37c 100644 --- a/test/decompiler/reference/levels/sunken/puffer_REF.gc +++ b/test/decompiler/reference/levels/sunken/puffer_REF.gc @@ -241,7 +241,7 @@ ;; definition for method 24 of type puffer (defmethod dummy-24 puffer ((obj puffer) (arg0 vector)) - (and (dummy-25 (-> obj nav) arg0 11468.8) + (and (is-in-mesh? (-> obj nav) arg0 11468.8) (< (-> arg0 y) (+ (-> obj root-override trans y) (-> obj fact-info-override notice-top))) ) ) @@ -412,8 +412,76 @@ (seek-with-smooth (-> obj travel-speed) 18432.0 (* 2048.0 (-> *display* seconds-per-frame)) 0.125 40.96) ) ) - (dummy-27 (-> obj nav)) - (dummy-28 (-> obj nav) -1) + (TODO-RENAME-27 (-> obj nav)) + (TODO-RENAME-28 + (-> obj nav) + (collide-kind + background + cak-1 + cak-2 + cak-3 + target + water + powerup + crate + enemy + wall-object + projectile + ground-object + target-attack + mother-spider + cak-14 + blue-eco-suck + unknown-16 + unknown-17 + unknown-18 + unknown-19 + unknown-20 + unknown-21 + unknown-22 + unknown-23 + unknown-24 + unknown-25 + unknown-26 + unknown-27 + unknown-28 + unknown-29 + unknown-30 + unknown-31 + unknown-32 + unknown-33 + unknown-34 + unknown-35 + unknown-36 + unknown-37 + unknown-38 + unknown-39 + unknown-40 + unknown-41 + unknown-42 + unknown-43 + unknown-44 + unknown-45 + unknown-46 + unknown-47 + unknown-48 + unknown-49 + unknown-50 + unknown-51 + unknown-52 + unknown-53 + unknown-54 + unknown-55 + unknown-56 + unknown-57 + unknown-58 + unknown-59 + unknown-60 + unknown-61 + unknown-62 + unknown-63 + ) + ) (dummy-13 (-> obj nav) arg0 (-> obj root-override transv)) (let ((f30-0 (* (vector-xz-length (-> obj nav travel)) (-> *display* frames-per-second)))) (let ((f0-11 (atan (-> obj nav travel x) (-> obj nav travel z))) @@ -1208,7 +1276,7 @@ (set! (-> obj give-up-dist) (+ 20480.0 (-> obj notice-dist))) (set! (-> obj nav) (new 'process 'nav-control (-> obj root-override) 16 40960.0)) (logior! (-> obj nav flags) (nav-control-flags display-marks bit3 bit5 bit6 bit7)) - (dummy-26 (-> obj nav)) + (TODO-RENAME-26 (-> obj nav)) (set! (-> obj path) (new 'process 'path-control obj 'path 0.0)) (logior! (-> obj path flags) (path-control-flag display draw-line draw-point draw-text)) (set! (-> obj fact-info-override) diff --git a/test/decompiler/reference/levels/swamp/swamp-rat-nest_REF.gc b/test/decompiler/reference/levels/swamp/swamp-rat-nest_REF.gc index b24e8a689d..a4177c9fdb 100644 --- a/test/decompiler/reference/levels/swamp/swamp-rat-nest_REF.gc +++ b/test/decompiler/reference/levels/swamp/swamp-rat-nest_REF.gc @@ -996,7 +996,7 @@ ) (set! (-> self nav) (new 'process 'nav-control (-> self root-override) 16 40960.0)) (logior! (-> self nav flags) (nav-control-flags display-marks bit3 bit5 bit6 bit7)) - (set-current-poly! (-> self nav) (TODO-RENAME-18 (-> self nav) (-> self root-override trans))) + (set-current-poly! (-> self nav) (find-poly (-> self nav) (-> self root-override trans))) (+! (-> self parent-process 0 hit-points) 3) (dummy-21 self) (when (zero? (-> self skel)) diff --git a/test/decompiler/test_FormExpressionBuild2.cpp b/test/decompiler/test_FormExpressionBuild2.cpp index bbea3252b0..885771a602 100644 --- a/test/decompiler/test_FormExpressionBuild2.cpp +++ b/test/decompiler/test_FormExpressionBuild2.cpp @@ -1613,4 +1613,4 @@ TEST_F(FormRegressionTest, VectorLineDistance) { " )"; test_with_stack_structures(func, type, expected, R"([[16, "vector"], [32, "vector"], [48, "vector"], [64, "vector"]])"); -} \ No newline at end of file +} diff --git a/test/offline/config.jsonc b/test/offline/config.jsonc index 819b6ae416..825dc95947 100644 --- a/test/offline/config.jsonc +++ b/test/offline/config.jsonc @@ -203,6 +203,10 @@ // generic-obs "command-get-process", // handle casts + // navigate + "end-collect-nav", + "start-collect-nav", + // appears twice "(method 9 drawable-tree-instance-tie)", "(method 11 drawable-tree-instance-tie)",